diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/.cargo-checksum.json b/third_party/cargo/vendor/aho-corasick-0.7.6/.cargo-checksum.json new file mode 100644 index 0000000..499cc0d --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"COPYING":"01c266bced4a434da0051174d6bee16a4c82cf634e2679b6155d40d75012390f","Cargo.toml":"a2f9a1263aa35a92af4ffc1935b264f062738bc25761aa62b3d582031d6bf5f0","DESIGN.md":"44d4516ef38d60e9638f756baf40bcd9eff1b8e8ce7538a1d8549e02d6605d48","LICENSE-MIT":"0f96a83840e146e43c0ec96a22ec1f392e0680e6c1226e6f3ba87e0740af850f","README.md":"626d74e4bdac78d2446c75c722a7e46d0eaa4e506a1068ff693b5abc338a384f","UNLICENSE":"7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c","rustfmt.toml":"1ca600239a27401c4a43f363cf3f38183a212affc1f31bff3ae93234bbaec228","src/ahocorasick.rs":"46c57a83a75a8f25fdf19a15deae10748d12b8af9445ae74700a546a92024608","src/automaton.rs":"85e79ceb964f824fcceca026abd255980840116704834d70a1b9c44833df299f","src/buffer.rs":"c40992e7d1ba0bac6d1c268d41069aad81f2226686c64192ed888a60f66db8cd","src/byte_frequencies.rs":"2fb85b381c038c1e44ce94294531cdcd339dca48b1e61f41455666e802cbbc9e","src/classes.rs":"590f2e257bf7c630bea3a28d4a1f75c78db7a0802f5921aced017a056146b4e6","src/dfa.rs":"2fb1077edfefd2b7f7e9c0d9df55df1441d4571500a2c45aa5b41960a36441e4","src/error.rs":"36dbf2cefbfaa8a69186551320dbff023d3e82780a6c925e87c3e3997b967e66","src/lib.rs":"028ab998e8f0d1a98650b139bcca83681cbb52545060b9253b76d7e19117b53d","src/nfa.rs":"6bc3479ad37c576bba4bbdc9e3d0c6e69a4b7f0d9a88fcbbf727bf4a9b288494","src/packed/api.rs":"aa89627c7114c057c98ad1c7ab9ce18c6ed55267a6bcf7bc8efb917b6cfe5532","src/packed/mod.rs":"29c76ad3cbb1f831140cefac7a27fb504ac4af4f454975a571965b48aad417eb","src/packed/pattern.rs":"b88c57af057997da0a5a06f4c5604a7e598c20acfc11c15cd8977727f6e1cf9c","src/packed/rabinkarp.rs":"b3242a8631ea5607163dcbb641e4ac9c6da26774378da1e51651b0ab5656b390","src/packed/teddy/README.md":"5819f40d221af93288e705eadef5393a41d7a0900881b4d676e01fd65d5adf15","src/packed/teddy/compile.rs":"21b18cbee9bc33918b85b1dc51a0faed57acb426f61e6b72aeaf69faa7595701","src/packed/teddy/mod.rs":"f63db3419b1d378929bf0bc1f0e3b909ff3c38b9f2b6e86ba4546b8f39907cd3","src/packed/teddy/runtime.rs":"0a1250ea73159b3be6e0fa9a3f55ecedbb2cb90cb798d1709e9f5ee48f8855d5","src/packed/tests.rs":"0b52ab9eef73a1a4f141f475a9fa98e54d447104aa69acba3a7f8248ce7164b2","src/packed/vector.rs":"ab3c0535fca5f09198d58cbfae44c292aeb3ce44bc92bca36d30dc72963639fc","src/prefilter.rs":"3dbe93d85c6fb985a9aea0b5eab003fe81a228e02adba00c8f63a35c3fd246b8","src/state_id.rs":"ebecd7046760e6bd72303f288be93342b446e7fe95f20b5ce23653d802c48b09","src/tests.rs":"9201cc0662bc9a1e8fa15c59e33a18a55ec6b3bd6bbea294d9cace0053bb8d24"},"package":"58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"} \ No newline at end of file diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/BUILD b/third_party/cargo/vendor/aho-corasick-0.7.6/BUILD new file mode 100644 index 0000000..46455a3 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" + "unencumbered", # "Unlicense" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "aho_corasick", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/memchr-2.3.0:memchr", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.7.6", + crate_features = [ + "default", + "memchr", + "std", + ], +) + diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/COPYING b/third_party/cargo/vendor/aho-corasick-0.7.6/COPYING new file mode 100644 index 0000000..bb9c20a --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/Cargo.toml b/third_party/cargo/vendor/aho-corasick-0.7.6/Cargo.toml new file mode 100644 index 0000000..a4542e1 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/Cargo.toml @@ -0,0 +1,47 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "aho-corasick" +version = "0.7.6" +authors = ["Andrew Gallant "] +exclude = ["/aho-corasick-debug", "/ci/*", "/.travis.yml", "/appveyor.yml"] +autotests = false +description = "Fast multiple substring searching." +homepage = "https://github.com/BurntSushi/aho-corasick" +readme = "README.md" +keywords = ["string", "search", "text", "aho", "multi"] +categories = ["text-processing"] +license = "Unlicense/MIT" +repository = "https://github.com/BurntSushi/aho-corasick" +[profile.bench] +debug = true + +[profile.release] +debug = true + +[lib] +name = "aho_corasick" +[dependencies.memchr] +version = "2.2.0" +default-features = false +[dev-dependencies.doc-comment] +version = "0.3.1" + +[features] +default = ["std"] +std = ["memchr/use_std"] +[badges.appveyor] +repository = "BurntSushi/aho-corasick" + +[badges.travis-ci] +repository = "BurntSushi/aho-corasick" diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/DESIGN.md b/third_party/cargo/vendor/aho-corasick-0.7.6/DESIGN.md new file mode 100644 index 0000000..8d63a01 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/DESIGN.md @@ -0,0 +1,483 @@ +This document describes the internal design of this crate, which is an object +lesson in what happens when you take a fairly simple old algorithm like +Aho-Corasick and make it fast and production ready. + +The target audience of this crate is Rust programmers that have some +familiarity with string searching, however, one does not need to know the +Aho-Corasick algorithm in order to read this (it is explained below). One +should, however, know what a trie is. (If you don't, go read its Wikipedia +article.) + +The center-piece of this crate is an implementation of Aho-Corasick. On its +own, Aho-Corasick isn't that complicated. The complex pieces come from the +different variants of Aho-Corasick implemented in this crate. Specifically, +they are: + +* Aho-Corasick as an NFA, using dense transitions near root with sparse + transitions elsewhere. +* Aho-Corasick as a DFA. (An NFA is slower to search, but cheaper to construct + and uses less memory.) + * A DFA with pre-multiplied state identifiers. This saves a multiplication + instruction in the core search loop. + * A DFA with equivalence classes of bytes as the alphabet, instead of the + traditional 256-byte alphabet. This shrinks the size of the DFA in memory, + but adds an extra lookup in the core search loop to map the input byte to + an equivalent class. +* The option to choose how state identifiers are represented, via one of + u8, u16, u32, u64 or usize. This permits creating compact automatons when + matching a small number of patterns. +* Supporting "standard" match semantics, along with its overlapping variant, + in addition to leftmost-first and leftmost-longest semantics. The "standard" + semantics are typically what you see in a textbook description of + Aho-Corasick. However, Aho-Corasick is also useful as an optimization in + regex engines, which often use leftmost-first or leftmost-longest semantics. + Thus, it is useful to implement those semantics here. The "standard" and + "leftmost" search algorithms are subtly different, and also require slightly + different construction algorithms. +* Support for ASCII case insensitive matching. +* Support for accelerating searches when the patterns all start with a small + number of fixed bytes. Or alternatively, when the patterns all contain a + small number of rare bytes. (Searching for these bytes uses SIMD vectorized + code courtesy of `memchr`.) +* Transparent support for alternative SIMD vectorized search routines for + smaller number of literals, such as the Teddy algorithm. We called these + "packed" search routines because they use SIMD. They can often be an order of + magnitude faster than just Aho-Corasick, but don't scale as well. +* Support for searching streams. This can reuse most of the underlying code, + but does require careful buffering support. +* Support for anchored searches, which permit efficient `is_prefix` checks for + a large number of patterns. + +When you combine all of this together along with trying to make everything as +fast as possible, what you end up with is enitrely too much code with too much +`unsafe`. Alas, I was not smart enough to figure out how to reduce it. Instead, +we will explain it. + + +# Basics + +The fundamental problem this crate is trying to solve is to determine the +occurrences of possibly many patterns in a haystack. The naive way to solve +this is to look for a match for each pattern at each position in the haystack: + + for i in 0..haystack.len(): + for p in patterns.iter(): + if haystack[i..].starts_with(p.bytes()): + return Match(p.id(), i, i + p.bytes().len()) + +Those four lines are effectively all this crate does. The problem with those +four lines is that they are very slow, especially when you're searching for a +large number of patterns. + +While there are many different algorithms available to solve this, a popular +one is Aho-Corasick. It's a common solution because it's not too hard to +implement, scales quite well even when searching for thousands of patterns and +is generally pretty fast. Aho-Corasick does well here because, regardless of +the number of patterns you're searching for, it always visits each byte in the +haystack exactly ocne. This means, generally speaking, adding more patterns to +an Aho-Corasick automaton does not make it slower. (Strictly speaking, however, +this is not true, since a larger automaton will make less effective use of the +CPU's cache.) + +Aho-Corasick can be succinctly described as a trie with state transitions +between some of the nodes that efficiently instruct the search algorithm to +try matching alternative keys in the automaton. The trick is that these state +transitions are arranged such that each byte of input needs to be inspected +only once. These state transitions are typically called "failure transitions," +because they instruct the searcher (the thing traversing the automaton while +reading from the haystack) what to do when a byte in the haystack does not +correspond to a valid transition in the current state of the trie. + +More formally, a failure transition points to a state in the automaton that may +lead to a match whose prefix is a proper suffix of the path traversed through +the trie so far. (If no such proper suffix exists, then the failure transition +points back to the start state of the trie, effectively restarting the search.) +This is perhaps simpler to explain pictorally. For example, let's say we built +an Aho-Corasick automaton with the following patterns: 'abcd' and 'cef'. The +trie looks like this: + + a - S1 - b - S2 - c - S3 - d - S4* + / + S0 - c - S5 - e - S6 - f - S7* + +where states marked with a `*` are match states (meaning, the search algorithm +should stop and report a match to the caller). + +So given this trie, it should be somewhat straight-forward to see how it can +be used to determine whether any particular haystack *starts* with either +`abcd` or `cef`. It's easy to express this in code: + + fn has_prefix(trie: &Trie, haystack: &[u8]) -> bool { + let mut state_id = trie.start(); + // If the empty pattern is in trie, then state_id is a match state. + if trie.is_match(state_id) { + return true; + } + for (i, &b) in haystack.iter().enumerate() { + state_id = match trie.next_state(state_id, b) { + Some(id) => id, + // If there was no transition for this state and byte, then we know + // the haystack does not start with one of the patterns in our trie. + None => return false, + }; + if trie.is_match(state_id) { + return true; + } + } + false + } + +And that's pretty much it. All we do is move through the trie starting with the +bytes at the beginning of the haystack. If we find ourselves in a position +where we can't move, or if we've looked through the entire haystack without +seeing a match state, then we know the haystack does not start with any of the +patterns in the trie. + +The meat of the Aho-Corasick algorithm is in how we add failure transitions to +our trie to keep searching efficient. Specifically, it permits us to not only +check whether a haystack *starts* with any one of a number of patterns, but +rather, whether the haystack contains any of a number of patterns *anywhere* in +the haystack. + +As mentioned before, failure transitions connect a proper suffix of the path +traversed through the trie before, with a path that leads to a match that has a +prefix corresponding to that proper suffix. So in our case, for patterns `abcd` +and `cef`, with a haystack `abcef`, we want to transition to state `S5` (from +the diagram above) from `S3` upon seeing that the byte following `c` is not +`d`. Namely, the proper suffix in this example is `c`, which is a prefix of +`cef`. So the modified diagram looks like this: + + + a - S1 - b - S2 - c - S3 - d - S4* + / / + / ---------------- + / / + S0 - c - S5 - e - S6 - f - S7* + +One thing that isn't shown in this diagram is that *all* states have a failure +transition, but only `S3` has a *non-trivial* failure transition. That is, all +other states have a failure transition back to the start state. So if our +haystack was `abzabcd`, then the searcher would transition back to `S0` after +seeing `z`, which effectively restarts the search. (Because there is no pattern +in our trie that has a prefix of `bz` or `z`.) + +The code for traversing this *automaton* or *finite state machine* (it is no +longer just a trie) is not that much different from the `has_prefix` code +above: + + fn contains(fsm: &FiniteStateMachine, haystack: &[u8]) -> bool { + let mut state_id = fsm.start(); + // If the empty pattern is in fsm, then state_id is a match state. + if fsm.is_match(state_id) { + return true; + } + for (i, &b) in haystack.iter().enumerate() { + // While the diagram above doesn't show this, we may wind up needing + // to follow multiple failure transitions before we land on a state + // in which we can advance. Therefore, when searching for the next + // state, we need to loop until we don't see a failure transition. + // + // This loop terminates because the start state has no empty + // transitions. Every transition from the start state either points to + // another state, or loops back to the start state. + loop { + match fsm.next_state(state_id, b) { + Some(id) => { + state_id = id; + break; + } + // Unlike our code above, if there was no transition for this + // state, then we don't quit. Instead, we look for this state's + // failure transition and follow that instead. + None => { + state_id = fsm.next_fail_state(state_id); + } + }; + } + if fsm.is_match(state_id) { + return true; + } + } + false + } + +Other than the complication around traversing failure transitions, this code +is still roughly "traverse the automaton with bytes from the haystack, and quit +when a match is seen." + +And that concludes our section on the basics. While we didn't go deep into +how the automaton is built (see `src/nfa.rs`, which has detailed comments about +that), the basic structure of Aho-Corasick should be reasonably clear. + + +# NFAs and DFAs + +There are generally two types of finite automata: non-deterministic finite +automata (NFA) and deterministic finite automata (DFA). The difference between +them is, principally, that an NFA can be in multiple states at once. This is +typically accomplished by things called _epsilon_ transitions, where one could +move to a new state without consuming any bytes from the input. (The other +mechanism by which NFAs can be in more than one state is where the same byte in +a particular state transitions to multiple distinct states.) In contrast, a DFA +can only ever be in one state at a time. A DFA has no epsilon transitions, and +for any given state, a byte transitions to at most one other state. + +By this formulation, the Aho-Corasick automaton described in the previous +section is an NFA. This is because failure transitions are, effectively, +epsilon transitions. That is, whenever the automaton is in state `S`, it is +actually in the set of states that are reachable by recursively following +failure transitions from `S`. (This means that, for example, the start state +is always active since the start state is reachable via failure transitions +from any state in the automaton.) + +NFAs have a lot of nice properties. They tend to be easier to construct, and +also tend to use less memory. However, their primary downside is that they are +typically slower to execute. For example, the code above showing how to search +with an Aho-Corasick automaton needs to potentially iterate through many +failure transitions for every byte of input. While this is a fairly small +amount of overhead, this can add up, especially if the automaton has a lot of +overlapping patterns with a lot of failure transitions. + +A DFA's search code, by contrast, looks like this: + + fn contains(dfa: &DFA, haystack: &[u8]) -> bool { + let mut state_id = dfa.start(); + // If the empty pattern is in dfa, then state_id is a match state. + if dfa.is_match(state_id) { + return true; + } + for (i, &b) in haystack.iter().enumerate() { + // An Aho-Corasick DFA *never* has a missing state that requires + // failure transitions to be followed. One byte of input advances the + // automaton by one state. Always. + state_id = trie.next_state(state_id, b); + if fsm.is_match(state_id) { + return true; + } + } + false + } + +The search logic here is much simpler than for the NFA, and this tends to +translate into significant performance benefits as well, since there's a lot +less work being done for each byte in the haystack. How is this accomplished? +It's done by pre-following all failure transitions for all states for all bytes +in the alphabet, and then building a single state transition table. Building +this DFA can be much more costly than building the NFA, and use much more +memory, but the better performance can be worth it. + +Users of this crate can actually choose between using an NFA or a DFA. By +default, an NFA is used, because it typically strikes the best balance between +space usage and search performance. But the DFA option is available for cases +where a little extra memory and upfront time building the automaton is okay. +For example, the `AhoCorasick::auto_configure` and +`AhoCorasickBuilder::auto_configure` methods will enable the DFA setting if +there are a small number of patterns. + + +# More DFA tricks + +As described in the previous section, one of the downsides of using a DFA is +that is uses more memory and can take longer to builder. One small way of +mitigating these concerns is to map the alphabet used by the automaton into a +smaller space. Typically, the alphabet of a DFA has 256 elements in it: one +element for each possible value that fits into a byte. However, in many cases, +one does not need the full alphabet. For example, if all patterns in an +Aho-Corasick automaton are ASCII letters, then this only uses up 52 distinct +bytes. As far as the automaton is concerned, the rest of the 204 bytes are +indistinguishable from one another: they will never disrciminate between a +match or a non-match. Therefore, in cases like that, the alphabet can be shrunk +to just 53 elements. One for each ASCII letter, and then another to serve as a +placeholder for every other unused byte. + +In practice, this library doesn't quite compute the optimal set of equivalence +classes, but it's close enough in most cases. The key idea is that this then +allows the transition table for the DFA to be potentially much smaller. The +downside of doing this, however, is that since the transition table is defined +in terms of this smaller alphabet space, every byte in the haystack must be +re-mapped to this smaller space. This requires an additional 256-byte table. +In practice, this can lead to a small search time hit, but it can be difficult +to measure. Moreover, it can sometimes lead to faster search times for bigger +automata, since it could be difference between more parts of the automaton +staying in the CPU cache or not. + +One other trick for DFAs employed by this crate is the notion of premultiplying +state identifiers. Specifically, the normal way to compute the next transition +in a DFA is via the following (assuming that the transition table is laid out +sequentially in memory, in row-major order, where the rows are states): + + next_state_id = dfa.transitions[current_state_id * 256 + current_byte] + +However, since the value `256` is a fixed constant, we can actually premultiply +the state identifiers in the table when we build the table initially. Then, the +next transition computation simply becomes: + + next_state_id = dfa.transitions[current_state_id + current_byte] + +This doesn't seem like much, but when this is being executed for every byte of +input that you're searching, saving that extra multiplication instruction can +add up. + +The same optimization works even when equivalence classes are enabled, as +described above. The only difference is that the premultiplication is by the +total number of equivalence classes instead of 256. + +There isn't much downside to premultiplying state identifiers, other than the +fact that you may need to choose a bigger integer representation than you would +otherwise. For example, if you don't premultiply state identifiers, then an +automaton that uses `u8` as a state identifier can hold up to 256 states. +However, if they are premultiplied, then it can only hold up to +`floor(256 / len(alphabet))` states. Thus premultiplication impacts how compact +your DFA can be. In practice, it's pretty rare to use `u8` as a state +identifier, so premultiplication is usually a good thing to do. + +Both equivalence classes and premultiplication are tuneable parameters via the +`AhoCorasickBuilder` type, and both are enabled by default. + + +# Match semantics + +One of the more interesting things about this implementation of Aho-Corasick +that (as far as this author knows) separates it from other implementations, is +that it natively supports leftmost-first and leftmost-longest match semantics. +Briefly, match semantics refer to the decision procedure by which searching +will disambiguate matches when there are multiple to choose from: + +* **standard** match semantics emits matches as soon as they are detected by + the automaton. This is typically equivalent to the textbook non-overlapping + formulation of Aho-Corasick. +* **leftmost-first** match semantics means that 1) the next match is the match + starting at the leftmost position and 2) among multiple matches starting at + the same leftmost position, the match corresponding to the pattern provided + first by the caller is reported. +* **leftmost-longest** is like leftmost-first, except when there are multiple + matches starting at the same leftmost position, the pattern corresponding to + the longest match is returned. + +(The crate API documentation discusses these differences, with examples, in +more depth on the `MatchKind` type.) + +The reason why supporting these match semantics is important is because it +gives the user more control over the match procedure. For example, +leftmost-first permits users to implement match priority by simply putting the +higher priority patterns first. Leftmost-longest, on the other hand, permits +finding the longest possible match, which might be useful when trying to find +words matching a dictionary. Additionally, regex engines often want to use +Aho-Corasick as an optimization when searching for an alternation of literals. +In order to preserve correct match semantics, regex engines typically can't use +the standard textbook definition directly, since regex engines will implement +either leftmost-first (Perl-like) or leftmost-longest (POSIX) match semantics. + +Supporting leftmost semantics requires a couple key changes: + +* Constructing the Aho-Corasick automaton changes a bit in both how the trie is + constructed and how failure transitions are found. Namely, only a subset of + the failure transitions are added. Specifically, only the failure transitions + that either do not occur after a match or do occur after a match but preserve + that match are kept. (More details on this can be found in `src/nfa.rs`.) +* The search algorithm changes slightly. Since we are looking for the leftmost + match, we cannot quit as soon as a match is detected. Instead, after a match + is detected, we must keep searching until either the end of the input or + until a dead state is seen. (Dead states are not used for standard match + semantics. Dead states mean that searching should stop after a match has been + found.) + +Other implementations of Aho-Corasick do support leftmost match semantics, but +they do it with more overhead at search time, or even worse, with a queue of +matches and sophisticated hijinks to disambiguate the matches. While our +construction algorithm becomes a bit more complicated, the correct match +semantics fall out from the structure of the automaton itself. + + +# Overlapping matches + +One of the nice properties of an Aho-Corasick automaton is that it can report +all possible matches, even when they overlap with one another. In this mode, +the match semantics don't matter, since all possible matches are reported. +Overlapping searches work just like regular searches, except the state +identifier at which the previous search left off is carried over to the next +search, so that it can pick up where it left off. If there are additional +matches at that state, then they are reported before resuming the search. + +Enabling leftmost-first or leftmost-longest match semantics causes the +automaton to use a subset of all failure transitions, which means that +overlapping searches cannot be used. Therefore, if leftmost match semantics are +used, attempting to do an overlapping search will panic. Thus, to get +overlapping searches, the caller must use the default standard match semantics. +This behavior was chosen because there are only two alternatives, which were +deemed worse: + +* Compile two automatons internally, one for standard semantics and one for + the semantics requested by the caller (if not standard). +* Create a new type, distinct from the `AhoCorasick` type, which has different + capabilities based on the configuration options. + +The first is untenable because of the amount of memory used by the automaton. +The second increases the complexity of the API too much by adding too many +types that do similar things. It is conceptually much simpler to keep all +searching isolated to a single type. Callers may query whether the automaton +supports overlapping searches via the `AhoCorasick::supports_overlapping` +method. + + +# Stream searching + +Since Aho-Corasick is an automaton, it is possible to do partial searches on +partial parts of the haystack, and then resume that search on subsequent pieces +of the haystack. This is useful when the haystack you're trying to search is +not stored contiguous in memory, or if one does not want to read the entire +haystack into memory at once. + +Currently, only standard semantics are supported for stream searching. This is +some of the more complicated code in this crate, and is something I would very +much like to improve. In particular, it currently has the restriction that it +must buffer at least enough of the haystack in memory in order to fit the +longest possible match. The difficulty in getting stream searching right is +that the implementation choices (such as the buffer size) often impact what the +API looks like and what it's allowed to do. + + +# Prefilters + +In some cases, Aho-Corasick is not the fastest way to find matches containing +multiple patterns. Sometimes, the search can be accelerated using highly +optimized SIMD routines. For example, consider searching the following +patterns: + + Sherlock + Moriarty + Watson + +It is plausible that it would be much faster to quickly look for occurrences of +the leading bytes, `S`, `M` or `W`, before trying to start searching via the +automaton. Indeed, this is exactly what this crate will do. + +When there are more than three distinct starting bytes, then this crate will +look for three distinct bytes occurring at any position in the patterns, while +preferring bytes that are heuristically determined to be rare over others. For +example: + + Abuzz + Sanchez + Vasquez + Topaz + Waltz + +Here, we have more than 3 distinct starting bytes, but all of the patterns +contain `z`, which is typically a rare byte. In this case, the prefilter will +scan for `z`, back up a bit, and then execute the Aho-Corasick automaton. + +If all of that fails, then a packed multiple substring algorithm will be +attempted. Currently, the only algorithm available for this is Teddy, but more +may be added in the future. Teddy is unlike the above prefilters in that it +confirms its own matches, so when Teddy is active, it might not be necessary +for Aho-Corasick to run at all. (See `Automaton::leftmost_find_at_no_state_imp` +in `src/automaton.rs`.) However, the current Teddy implementation only works +in `x86_64` and when SSSE3 or AVX2 are available, and moreover, only works +_well_ when there are a small number of patterns (say, less than 100). Teddy +also requires the haystack to be of a certain length (more than 16-34 bytes). +When the haystack is shorter than that, Rabin-Karp is used instead. (See +`src/packed/rabinkarp.rs`.) + +There is a more thorough description of Teddy at +[`src/packed/teddy/README.md`](src/packed/teddy/README.md). diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/LICENSE-MIT b/third_party/cargo/vendor/aho-corasick-0.7.6/LICENSE-MIT new file mode 100644 index 0000000..3b0a5dc --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/README.md b/third_party/cargo/vendor/aho-corasick-0.7.6/README.md new file mode 100644 index 0000000..b4acbee --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/README.md @@ -0,0 +1,184 @@ +aho-corasick +============ +A library for finding occurrences of many patterns at once with SIMD +acceleration in some cases. This library provides multiple pattern +search principally through an implementation of the +[Aho-Corasick algorithm](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm), +which builds a finite state machine for executing searches in linear time. +Features include case insensitive matching, overlapping matches and search & +replace in streams. + +[![Linux build status](https://api.travis-ci.org/BurntSushi/aho-corasick.svg)](https://travis-ci.org/BurntSushi/aho-corasick) +[![Windows build status](https://ci.appveyor.com/api/projects/status/github/BurntSushi/aho-corasick?svg=true)](https://ci.appveyor.com/project/BurntSushi/aho-corasick) +[![](http://meritbadge.herokuapp.com/aho-corasick)](https://crates.io/crates/aho-corasick) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + + +### Documentation + +https://docs.rs/aho-corasick + + +### Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +aho-corasick = "0.7" +``` + +and this to your crate root (if you're using Rust 2015): + +```rust +extern crate aho_corasick; +``` + + +### Example: basic searching + +This example shows how to search for occurrences of multiple patterns +simultaneously. Each match includes the pattern that matched along with the +byte offsets of the match. + +```rust +use aho_corasick::AhoCorasick; + +let patterns = &["apple", "maple", "Snapple"]; +let haystack = "Nobody likes maple in their apple flavored Snapple."; + +let ac = AhoCorasick::new(patterns); +let mut matches = vec![]; +for mat in ac.find_iter(haystack) { + matches.push((mat.pattern(), mat.start(), mat.end())); +} +assert_eq!(matches, vec![ + (1, 13, 18), + (0, 28, 33), + (2, 43, 50), +]); +``` + + +### Example: case insensitivity + +This is like the previous example, but matches `Snapple` case insensitively +using `AhoCorasickBuilder`: + +```rust +use aho_corasick::AhoCorasickBuilder; + +let patterns = &["apple", "maple", "snapple"]; +let haystack = "Nobody likes maple in their apple flavored Snapple."; + +let ac = AhoCorasickBuilder::new() + .ascii_case_insensitive(true) + .build(patterns); +let mut matches = vec![]; +for mat in ac.find_iter(haystack) { + matches.push((mat.pattern(), mat.start(), mat.end())); +} +assert_eq!(matches, vec![ + (1, 13, 18), + (0, 28, 33), + (2, 43, 50), +]); +``` + + +### Example: replacing matches in a stream + +This example shows how to execute a search and replace on a stream without +loading the entire stream into memory first. + +```rust +use aho_corasick::AhoCorasick; + +# fn example() -> Result<(), ::std::io::Error> { +let patterns = &["fox", "brown", "quick"]; +let replace_with = &["sloth", "grey", "slow"]; + +// In a real example, these might be `std::fs::File`s instead. All you need to +// do is supply a pair of `std::io::Read` and `std::io::Write` implementations. +let rdr = "The quick brown fox."; +let mut wtr = vec![]; + +let ac = AhoCorasick::new(patterns); +ac.stream_replace_all(rdr.as_bytes(), &mut wtr, replace_with)?; +assert_eq!(b"The slow grey sloth.".to_vec(), wtr); +# Ok(()) }; example().unwrap() +``` + + +### Example: finding the leftmost first match + +In the textbook description of Aho-Corasick, its formulation is typically +structured such that it reports all possible matches, even when they overlap +with another. In many cases, overlapping matches may not be desired, such as +the case of finding all successive non-overlapping matches like you might with +a standard regular expression. + +Unfortunately the "obvious" way to modify the Aho-Corasick algorithm to do +this doesn't always work in the expected way, since it will report matches as +soon as they are seen. For example, consider matching the regex `Samwise|Sam` +against the text `Samwise`. Most regex engines (that are Perl-like, or +non-POSIX) will report `Samwise` as a match, but the standard Aho-Corasick +algorithm modified for reporting non-overlapping matches will report `Sam`. + +A novel contribution of this library is the ability to change the match +semantics of Aho-Corasick (without additional search time overhead) such that +`Samwise` is reported instead. For example, here's the standard approach: + +```rust +use aho_corasick::AhoCorasick; + +let patterns = &["Samwise", "Sam"]; +let haystack = "Samwise"; + +let ac = AhoCorasick::new(patterns); +let mat = ac.find(haystack).expect("should have a match"); +assert_eq!("Sam", &haystack[mat.start()..mat.end()]); +``` + +And now here's the leftmost-first version, which matches how a Perl-like +regex will work: + +```rust +use aho_corasick::{AhoCorasickBuilder, MatchKind}; + +let patterns = &["Samwise", "Sam"]; +let haystack = "Samwise"; + +let ac = AhoCorasickBuilder::new() + .match_kind(MatchKind::LeftmostFirst) + .build(patterns); +let mat = ac.find(haystack).expect("should have a match"); +assert_eq!("Samwise", &haystack[mat.start()..mat.end()]); +``` + +In addition to leftmost-first semantics, this library also supports +leftmost-longest semantics, which match the POSIX behavior of a regular +expression alternation. See `MatchKind` in the docs for more details. + + +### Minimum Rust version policy + +This crate's minimum supported `rustc` version is `1.28.0`. + +In general, this crate will be conservative with respect to the minimum +supported version of Rust. In general, it will follow the `regex` crate's +policy, since `regex` is an important dependent. + + +### Future work + +Here are some plans for the future: + +* Assuming the current API is sufficient, I'd like to commit to it and release + a `1.0` version of this crate some time in the next 6-12 months. +* Support stream searching with leftmost match semantics. Currently, only + standard match semantics are supported. Getting this right seems possible, + but is tricky since the match state needs to be propagated through multiple + searches. (With standard semantics, as soon as a match is seen the search + ends.) diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/UNLICENSE b/third_party/cargo/vendor/aho-corasick-0.7.6/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/rustfmt.toml b/third_party/cargo/vendor/aho-corasick-0.7.6/rustfmt.toml new file mode 100644 index 0000000..aa37a21 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/rustfmt.toml @@ -0,0 +1,2 @@ +max_width = 79 +use_small_heuristics = "max" diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/ahocorasick.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/ahocorasick.rs new file mode 100644 index 0000000..9b7d9e7 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/ahocorasick.rs @@ -0,0 +1,2087 @@ +use std::io; + +use automaton::Automaton; +use buffer::Buffer; +use dfa::{self, DFA}; +use error::Result; +use nfa::{self, NFA}; +use packed; +use prefilter::PrefilterState; +use state_id::StateID; +use Match; + +/// An automaton for searching multiple strings in linear time. +/// +/// The `AhoCorasick` type supports a few basic ways of constructing an +/// automaton, including +/// [`AhoCorasick::new`](struct.AhoCorasick.html#method.new) +/// and +/// [`AhoCorasick::new_auto_configured`](struct.AhoCorasick.html#method.new_auto_configured). +/// However, there are a fair number of configurable options that can be set +/// by using +/// [`AhoCorasickBuilder`](struct.AhoCorasickBuilder.html) +/// instead. Such options include, but are not limited to, how matches are +/// determined, simple case insensitivity, whether to use a DFA or not and +/// various knobs for controlling the space-vs-time trade offs taken when +/// building the automaton. +/// +/// If you aren't sure where to start, try beginning with +/// [`AhoCorasick::new_auto_configured`](struct.AhoCorasick.html#method.new_auto_configured). +/// +/// # Resource usage +/// +/// Aho-Corasick automatons are always constructed in `O(p)` time, where `p` +/// is the combined length of all patterns being searched. With that said, +/// building an automaton can be fairly costly because of high constant +/// factors, particularly when enabling the +/// [DFA](struct.AhoCorasickBuilder.html#method.dfa) +/// option (which is disabled by default). For this reason, it's generally a +/// good idea to build an automaton once and reuse it as much as possible. +/// +/// Aho-Corasick automatons can also use a fair bit of memory. To get a +/// concrete idea of how much memory is being used, try using the +/// [`AhoCorasick::heap_bytes`](struct.AhoCorasick.html#method.heap_bytes) +/// method. +/// +/// # Examples +/// +/// This example shows how to search for occurrences of multiple patterns +/// simultaneously in a case insensitive fashion. Each match includes the +/// pattern that matched along with the byte offsets of the match. +/// +/// ``` +/// use aho_corasick::AhoCorasickBuilder; +/// +/// let patterns = &["apple", "maple", "snapple"]; +/// let haystack = "Nobody likes maple in their apple flavored Snapple."; +/// +/// let ac = AhoCorasickBuilder::new() +/// .ascii_case_insensitive(true) +/// .build(patterns); +/// let mut matches = vec![]; +/// for mat in ac.find_iter(haystack) { +/// matches.push((mat.pattern(), mat.start(), mat.end())); +/// } +/// assert_eq!(matches, vec![ +/// (1, 13, 18), +/// (0, 28, 33), +/// (2, 43, 50), +/// ]); +/// ``` +/// +/// This example shows how to replace matches with some other string: +/// +/// ``` +/// use aho_corasick::AhoCorasick; +/// +/// let patterns = &["fox", "brown", "quick"]; +/// let haystack = "The quick brown fox."; +/// let replace_with = &["sloth", "grey", "slow"]; +/// +/// let ac = AhoCorasick::new(patterns); +/// let result = ac.replace_all(haystack, replace_with); +/// assert_eq!(result, "The slow grey sloth."); +/// ``` +#[derive(Clone, Debug)] +pub struct AhoCorasick { + imp: Imp, + match_kind: MatchKind, +} + +impl AhoCorasick { + /// Create a new Aho-Corasick automaton using the default configuration. + /// + /// The default configuration optimizes for less space usage, but at the + /// expense of longer search times. To change the configuration, use + /// [`AhoCorasickBuilder`](struct.AhoCorasickBuilder.html) + /// for fine-grained control, or + /// [`AhoCorasick::new_auto_configured`](struct.AhoCorasick.html#method.new_auto_configured) + /// for automatic configuration if you aren't sure which settings to pick. + /// + /// This uses the default + /// [`MatchKind::Standard`](enum.MatchKind.html#variant.Standard) + /// match semantics, which reports a match as soon as it is found. This + /// corresponds to the standard match semantics supported by textbook + /// descriptions of the Aho-Corasick algorithm. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasick; + /// + /// let ac = AhoCorasick::new(&[ + /// "foo", "bar", "baz", + /// ]); + /// assert_eq!(Some(1), ac.find("xxx bar xxx").map(|m| m.pattern())); + /// ``` + pub fn new(patterns: I) -> AhoCorasick + where + I: IntoIterator, + P: AsRef<[u8]>, + { + AhoCorasickBuilder::new().build(patterns) + } + + /// Build an Aho-Corasick automaton with an automatically determined + /// configuration. + /// + /// Specifically, this requires a slice of patterns instead of an iterator + /// since the configuration is determined by looking at the patterns before + /// constructing the automaton. The idea here is to balance space and time + /// automatically. That is, when searching a small number of patterns, this + /// will attempt to use the fastest possible configuration since the total + /// space required will be small anyway. As the number of patterns grows, + /// this will fall back to slower configurations that use less space. + /// + /// If you want auto configuration but with match semantics different from + /// the default `MatchKind::Standard`, then use + /// [`AhoCorasickBuilder::auto_configure`](struct.AhoCorasickBuilder.html#method.auto_configure). + /// + /// # Examples + /// + /// Basic usage is just like `new`, except you must provide a slice: + /// + /// ``` + /// use aho_corasick::AhoCorasick; + /// + /// let ac = AhoCorasick::new_auto_configured(&[ + /// "foo", "bar", "baz", + /// ]); + /// assert_eq!(Some(1), ac.find("xxx bar xxx").map(|m| m.pattern())); + /// ``` + pub fn new_auto_configured(patterns: &[B]) -> AhoCorasick + where + B: AsRef<[u8]>, + { + AhoCorasickBuilder::new().auto_configure(patterns).build(patterns) + } +} + +impl AhoCorasick { + /// Returns true if and only if this automaton matches the haystack at any + /// position. + /// + /// `haystack` may be any type that is cheaply convertible to a `&[u8]`. + /// This includes, but is not limited to, `String`, `&str`, `Vec`, and + /// `&[u8]` itself. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasick; + /// + /// let ac = AhoCorasick::new(&[ + /// "foo", "bar", "quux", "baz", + /// ]); + /// assert!(ac.is_match("xxx bar xxx")); + /// assert!(!ac.is_match("xxx qux xxx")); + /// ``` + pub fn is_match>(&self, haystack: B) -> bool { + self.earliest_find(haystack).is_some() + } + + /// Returns the location of the first detected match in `haystack`. + /// + /// This method has the same behavior regardless of the + /// [`MatchKind`](enum.MatchKind.html) + /// of this automaton. + /// + /// `haystack` may be any type that is cheaply convertible to a `&[u8]`. + /// This includes, but is not limited to, `String`, `&str`, `Vec`, and + /// `&[u8]` itself. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasick; + /// + /// let ac = AhoCorasick::new(&[ + /// "abc", "b", + /// ]); + /// let mat = ac.earliest_find("abcd").expect("should have match"); + /// assert_eq!(1, mat.pattern()); + /// assert_eq!((1, 2), (mat.start(), mat.end())); + /// ``` + pub fn earliest_find>(&self, haystack: B) -> Option { + let mut prestate = PrefilterState::new(self.max_pattern_len()); + let mut start = self.imp.start_state(); + self.imp.earliest_find_at( + &mut prestate, + haystack.as_ref(), + 0, + &mut start, + ) + } + + /// Returns the location of the first match according to the match + /// semantics that this automaton was constructed with. + /// + /// When using `MatchKind::Standard`, this corresponds precisely to the + /// same behavior as + /// [`earliest_find`](struct.AhoCorasick.html#method.earliest_find). + /// Otherwise, match semantics correspond to either + /// [leftmost-first](enum.MatchKind.html#variant.LeftmostFirst) + /// or + /// [leftmost-longest](enum.MatchKind.html#variant.LeftmostLongest). + /// + /// `haystack` may be any type that is cheaply convertible to a `&[u8]`. + /// This includes, but is not limited to, `String`, `&str`, `Vec`, and + /// `&[u8]` itself. + /// + /// # Examples + /// + /// Basic usage, with standard semantics: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["b", "abc", "abcd"]; + /// let haystack = "abcd"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::Standard) // default, not necessary + /// .build(patterns); + /// let mat = ac.find(haystack).expect("should have a match"); + /// assert_eq!("b", &haystack[mat.start()..mat.end()]); + /// ``` + /// + /// Now with leftmost-first semantics: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["b", "abc", "abcd"]; + /// let haystack = "abcd"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostFirst) + /// .build(patterns); + /// let mat = ac.find(haystack).expect("should have a match"); + /// assert_eq!("abc", &haystack[mat.start()..mat.end()]); + /// ``` + /// + /// And finally, leftmost-longest semantics: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["b", "abc", "abcd"]; + /// let haystack = "abcd"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostLongest) + /// .build(patterns); + /// let mat = ac.find(haystack).expect("should have a match"); + /// assert_eq!("abcd", &haystack[mat.start()..mat.end()]); + /// ``` + pub fn find>(&self, haystack: B) -> Option { + let mut prestate = PrefilterState::new(self.max_pattern_len()); + self.imp.find_at_no_state(&mut prestate, haystack.as_ref(), 0) + } + + /// Returns an iterator of non-overlapping matches, using the match + /// semantics that this automaton was constructed with. + /// + /// `haystack` may be any type that is cheaply convertible to a `&[u8]`. + /// This includes, but is not limited to, `String`, `&str`, `Vec`, and + /// `&[u8]` itself. + /// + /// # Examples + /// + /// Basic usage, with standard semantics: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["append", "appendage", "app"]; + /// let haystack = "append the app to the appendage"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::Standard) // default, not necessary + /// .build(patterns); + /// let matches: Vec = ac + /// .find_iter(haystack) + /// .map(|mat| mat.pattern()) + /// .collect(); + /// assert_eq!(vec![2, 2, 2], matches); + /// ``` + /// + /// Now with leftmost-first semantics: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["append", "appendage", "app"]; + /// let haystack = "append the app to the appendage"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostFirst) + /// .build(patterns); + /// let matches: Vec = ac + /// .find_iter(haystack) + /// .map(|mat| mat.pattern()) + /// .collect(); + /// assert_eq!(vec![0, 2, 0], matches); + /// ``` + /// + /// And finally, leftmost-longest semantics: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["append", "appendage", "app"]; + /// let haystack = "append the app to the appendage"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostLongest) + /// .build(patterns); + /// let matches: Vec = ac + /// .find_iter(haystack) + /// .map(|mat| mat.pattern()) + /// .collect(); + /// assert_eq!(vec![0, 2, 1], matches); + /// ``` + pub fn find_iter<'a, 'b, B: ?Sized + AsRef<[u8]>>( + &'a self, + haystack: &'b B, + ) -> FindIter<'a, 'b, S> { + FindIter::new(self, haystack.as_ref()) + } + + /// Returns an iterator of overlapping matches in the given `haystack`. + /// + /// Overlapping matches can _only_ be detected using + /// `MatchKind::Standard` semantics. If this automaton was constructed with + /// leftmost semantics, then this method will panic. To determine whether + /// this will panic at runtime, use the + /// [`AhoCorasick::supports_overlapping`](struct.AhoCorasick.html#method.supports_overlapping) + /// method. + /// + /// `haystack` may be any type that is cheaply convertible to a `&[u8]`. + /// This includes, but is not limited to, `String`, `&str`, `Vec`, and + /// `&[u8]` itself. + /// + /// # Panics + /// + /// This panics when `AhoCorasick::supports_overlapping` returns `false`. + /// That is, this panics when this automaton's match semantics are not + /// `MatchKind::Standard`. + /// + /// # Examples + /// + /// Basic usage, with standard semantics: + /// + /// ``` + /// use aho_corasick::AhoCorasick; + /// + /// let patterns = &["append", "appendage", "app"]; + /// let haystack = "append the app to the appendage"; + /// + /// let ac = AhoCorasick::new(patterns); + /// let matches: Vec = ac + /// .find_overlapping_iter(haystack) + /// .map(|mat| mat.pattern()) + /// .collect(); + /// assert_eq!(vec![2, 0, 2, 2, 0, 1], matches); + /// ``` + pub fn find_overlapping_iter<'a, 'b, B: ?Sized + AsRef<[u8]>>( + &'a self, + haystack: &'b B, + ) -> FindOverlappingIter<'a, 'b, S> { + FindOverlappingIter::new(self, haystack.as_ref()) + } + + /// Replace all matches with a corresponding value in the `replace_with` + /// slice given. Matches correspond to the same matches as reported by + /// [`find_iter`](struct.AhoCorasick.html#method.find_iter). + /// + /// Replacements are determined by the index of the matching pattern. + /// For example, if the pattern with index `2` is found, then it is + /// replaced by `replace_with[2]`. + /// + /// # Panics + /// + /// This panics when `replace_with.len()` does not equal the total number + /// of patterns that are matched by this automaton. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["append", "appendage", "app"]; + /// let haystack = "append the app to the appendage"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostFirst) + /// .build(patterns); + /// let result = ac.replace_all(haystack, &["x", "y", "z"]); + /// assert_eq!("x the z to the xage", result); + /// ``` + pub fn replace_all(&self, haystack: &str, replace_with: &[B]) -> String + where + B: AsRef, + { + assert_eq!( + replace_with.len(), + self.pattern_count(), + "replace_all requires a replacement for every pattern \ + in the automaton" + ); + let mut dst = String::with_capacity(haystack.len()); + self.replace_all_with(haystack, &mut dst, |mat, _, dst| { + dst.push_str(replace_with[mat.pattern()].as_ref()); + true + }); + dst + } + + /// Replace all matches using raw bytes with a corresponding value in the + /// `replace_with` slice given. Matches correspond to the same matches as + /// reported by [`find_iter`](struct.AhoCorasick.html#method.find_iter). + /// + /// Replacements are determined by the index of the matching pattern. + /// For example, if the pattern with index `2` is found, then it is + /// replaced by `replace_with[2]`. + /// + /// # Panics + /// + /// This panics when `replace_with.len()` does not equal the total number + /// of patterns that are matched by this automaton. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["append", "appendage", "app"]; + /// let haystack = b"append the app to the appendage"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostFirst) + /// .build(patterns); + /// let result = ac.replace_all_bytes(haystack, &["x", "y", "z"]); + /// assert_eq!(b"x the z to the xage".to_vec(), result); + /// ``` + pub fn replace_all_bytes( + &self, + haystack: &[u8], + replace_with: &[B], + ) -> Vec + where + B: AsRef<[u8]>, + { + assert_eq!( + replace_with.len(), + self.pattern_count(), + "replace_all_bytes requires a replacement for every pattern \ + in the automaton" + ); + let mut dst = Vec::with_capacity(haystack.len()); + self.replace_all_with_bytes(haystack, &mut dst, |mat, _, dst| { + dst.extend(replace_with[mat.pattern()].as_ref()); + true + }); + dst + } + + /// Replace all matches using a closure called on each match. + /// Matches correspond to the same matches as reported by + /// [`find_iter`](struct.AhoCorasick.html#method.find_iter). + /// + /// The closure accepts three parameters: the match found, the text of + /// the match and a string buffer with which to write the replaced text + /// (if any). If the closure returns `true`, then it continues to the next + /// match. If the closure returns false, then searching is stopped. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["append", "appendage", "app"]; + /// let haystack = "append the app to the appendage"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostFirst) + /// .build(patterns); + /// let mut result = String::new(); + /// ac.replace_all_with(haystack, &mut result, |mat, _, dst| { + /// dst.push_str(&mat.pattern().to_string()); + /// true + /// }); + /// assert_eq!("0 the 2 to the 0age", result); + /// ``` + pub fn replace_all_with( + &self, + haystack: &str, + dst: &mut String, + mut replace_with: F, + ) where + F: FnMut(&Match, &str, &mut String) -> bool, + { + let mut last_match = 0; + for mat in self.find_iter(haystack) { + dst.push_str(&haystack[last_match..mat.start()]); + last_match = mat.end(); + replace_with(&mat, &haystack[mat.start()..mat.end()], dst); + } + dst.push_str(&haystack[last_match..]); + } + + /// Replace all matches using raw bytes with a closure called on each + /// match. Matches correspond to the same matches as reported by + /// [`find_iter`](struct.AhoCorasick.html#method.find_iter). + /// + /// The closure accepts three parameters: the match found, the text of + /// the match and a byte buffer with which to write the replaced text + /// (if any). If the closure returns `true`, then it continues to the next + /// match. If the closure returns false, then searching is stopped. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["append", "appendage", "app"]; + /// let haystack = b"append the app to the appendage"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostFirst) + /// .build(patterns); + /// let mut result = vec![]; + /// ac.replace_all_with_bytes(haystack, &mut result, |mat, _, dst| { + /// dst.extend(mat.pattern().to_string().bytes()); + /// true + /// }); + /// assert_eq!(b"0 the 2 to the 0age".to_vec(), result); + /// ``` + pub fn replace_all_with_bytes( + &self, + haystack: &[u8], + dst: &mut Vec, + mut replace_with: F, + ) where + F: FnMut(&Match, &[u8], &mut Vec) -> bool, + { + let mut last_match = 0; + for mat in self.find_iter(haystack) { + dst.extend(&haystack[last_match..mat.start()]); + last_match = mat.end(); + replace_with(&mat, &haystack[mat.start()..mat.end()], dst); + } + dst.extend(&haystack[last_match..]); + } + + /// Returns an iterator of non-overlapping matches in the given + /// stream. Matches correspond to the same matches as reported by + /// [`find_iter`](struct.AhoCorasick.html#method.find_iter). + /// + /// The matches yielded by this iterator use absolute position offsets in + /// the stream given, where the first byte has index `0`. Matches are + /// yieled until the stream is exhausted. + /// + /// Each item yielded by the iterator is an `io::Result`, where an + /// error is yielded if there was a problem reading from the reader given. + /// + /// When searching a stream, an internal buffer is used. Therefore, callers + /// should avoiding providing a buffered reader, if possible. + /// + /// Searching a stream requires that the automaton was built with + /// `MatchKind::Standard` semantics. If this automaton was constructed + /// with leftmost semantics, then this method will panic. To determine + /// whether this will panic at runtime, use the + /// [`AhoCorasick::supports_stream`](struct.AhoCorasick.html#method.supports_stream) + /// method. + /// + /// # Memory usage + /// + /// In general, searching streams will use a constant amount of memory for + /// its internal buffer. The one requirement is that the internal buffer + /// must be at least the size of the longest possible match. In most use + /// cases, the default buffer size will be much larger than any individual + /// match. + /// + /// # Panics + /// + /// This panics when `AhoCorasick::supports_stream` returns `false`. + /// That is, this panics when this automaton's match semantics are not + /// `MatchKind::Standard`. This restriction may be lifted in the future. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasick; + /// + /// # fn example() -> Result<(), ::std::io::Error> { + /// let patterns = &["append", "appendage", "app"]; + /// let haystack = "append the app to the appendage"; + /// + /// let ac = AhoCorasick::new(patterns); + /// let mut matches = vec![]; + /// for result in ac.stream_find_iter(haystack.as_bytes()) { + /// let mat = result?; + /// matches.push(mat.pattern()); + /// } + /// assert_eq!(vec![2, 2, 2], matches); + /// # Ok(()) }; example().unwrap() + /// ``` + pub fn stream_find_iter<'a, R: io::Read>( + &'a self, + rdr: R, + ) -> StreamFindIter<'a, R, S> { + StreamFindIter::new(self, rdr) + } + + /// Search for and replace all matches of this automaton in + /// the given reader, and write the replacements to the given + /// writer. Matches correspond to the same matches as reported by + /// [`find_iter`](struct.AhoCorasick.html#method.find_iter). + /// + /// Replacements are determined by the index of the matching pattern. + /// For example, if the pattern with index `2` is found, then it is + /// replaced by `replace_with[2]`. + /// + /// After all matches are replaced, the writer is _not_ flushed. + /// + /// If there was a problem reading from the given reader or writing to the + /// given writer, then the corresponding `io::Error` is returned and all + /// replacement is stopped. + /// + /// When searching a stream, an internal buffer is used. Therefore, callers + /// should avoiding providing a buffered reader, if possible. However, + /// callers may want to provide a buffered writer. + /// + /// Searching a stream requires that the automaton was built with + /// `MatchKind::Standard` semantics. If this automaton was constructed + /// with leftmost semantics, then this method will panic. To determine + /// whether this will panic at runtime, use the + /// [`AhoCorasick::supports_stream`](struct.AhoCorasick.html#method.supports_stream) + /// method. + /// + /// # Memory usage + /// + /// In general, searching streams will use a constant amount of memory for + /// its internal buffer. The one requirement is that the internal buffer + /// must be at least the size of the longest possible match. In most use + /// cases, the default buffer size will be much larger than any individual + /// match. + /// + /// # Panics + /// + /// This panics when `AhoCorasick::supports_stream` returns `false`. + /// That is, this panics when this automaton's match semantics are not + /// `MatchKind::Standard`. This restriction may be lifted in the future. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasick; + /// + /// # fn example() -> Result<(), ::std::io::Error> { + /// let patterns = &["fox", "brown", "quick"]; + /// let haystack = "The quick brown fox."; + /// let replace_with = &["sloth", "grey", "slow"]; + /// + /// let ac = AhoCorasick::new(patterns); + /// let mut result = vec![]; + /// ac.stream_replace_all(haystack.as_bytes(), &mut result, replace_with)?; + /// assert_eq!(b"The slow grey sloth.".to_vec(), result); + /// # Ok(()) }; example().unwrap() + /// ``` + pub fn stream_replace_all( + &self, + rdr: R, + wtr: W, + replace_with: &[B], + ) -> io::Result<()> + where + R: io::Read, + W: io::Write, + B: AsRef<[u8]>, + { + assert_eq!( + replace_with.len(), + self.pattern_count(), + "stream_replace_all requires a replacement for every pattern \ + in the automaton" + ); + self.stream_replace_all_with(rdr, wtr, |mat, _, wtr| { + wtr.write_all(replace_with[mat.pattern()].as_ref()) + }) + } + + /// Search the given reader and replace all matches of this automaton + /// using the given closure. The result is written to the given + /// writer. Matches correspond to the same matches as reported by + /// [`find_iter`](struct.AhoCorasick.html#method.find_iter). + /// + /// The closure accepts three parameters: the match found, the text of + /// the match and the writer with which to write the replaced text + /// (if any). If the closure returns `true`, then it continues to the next + /// match. If the closure returns false, then searching is stopped. + /// + /// After all matches are replaced, the writer is _not_ flushed. + /// + /// If there was a problem reading from the given reader or writing to the + /// given writer, then the corresponding `io::Error` is returned and all + /// replacement is stopped. + /// + /// When searching a stream, an internal buffer is used. Therefore, callers + /// should avoiding providing a buffered reader, if possible. However, + /// callers may want to provide a buffered writer. + /// + /// Searching a stream requires that the automaton was built with + /// `MatchKind::Standard` semantics. If this automaton was constructed + /// with leftmost semantics, then this method will panic. To determine + /// whether this will panic at runtime, use the + /// [`AhoCorasick::supports_stream`](struct.AhoCorasick.html#method.supports_stream) + /// method. + /// + /// # Memory usage + /// + /// In general, searching streams will use a constant amount of memory for + /// its internal buffer. The one requirement is that the internal buffer + /// must be at least the size of the longest possible match. In most use + /// cases, the default buffer size will be much larger than any individual + /// match. + /// + /// # Panics + /// + /// This panics when `AhoCorasick::supports_stream` returns `false`. + /// That is, this panics when this automaton's match semantics are not + /// `MatchKind::Standard`. This restriction may be lifted in the future. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use std::io::Write; + /// use aho_corasick::AhoCorasick; + /// + /// # fn example() -> Result<(), ::std::io::Error> { + /// let patterns = &["fox", "brown", "quick"]; + /// let haystack = "The quick brown fox."; + /// + /// let ac = AhoCorasick::new(patterns); + /// let mut result = vec![]; + /// ac.stream_replace_all_with( + /// haystack.as_bytes(), + /// &mut result, + /// |mat, _, wtr| { + /// wtr.write_all(mat.pattern().to_string().as_bytes()) + /// }, + /// )?; + /// assert_eq!(b"The 2 1 0.".to_vec(), result); + /// # Ok(()) }; example().unwrap() + /// ``` + pub fn stream_replace_all_with( + &self, + rdr: R, + mut wtr: W, + mut replace_with: F, + ) -> io::Result<()> + where + R: io::Read, + W: io::Write, + F: FnMut(&Match, &[u8], &mut W) -> io::Result<()>, + { + let mut it = StreamChunkIter::new(self, rdr); + while let Some(result) = it.next() { + let chunk = result?; + match chunk { + StreamChunk::NonMatch { bytes, .. } => { + wtr.write_all(bytes)?; + } + StreamChunk::Match { bytes, mat } => { + replace_with(&mat, bytes, &mut wtr)?; + } + } + } + Ok(()) + } + + /// Returns the match kind used by this automaton. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::{AhoCorasick, MatchKind}; + /// + /// let ac = AhoCorasick::new(&[ + /// "foo", "bar", "quux", "baz", + /// ]); + /// assert_eq!(&MatchKind::Standard, ac.match_kind()); + /// ``` + pub fn match_kind(&self) -> &MatchKind { + self.imp.match_kind() + } + + /// Returns the length of the longest pattern matched by this automaton. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasick; + /// + /// let ac = AhoCorasick::new(&[ + /// "foo", "bar", "quux", "baz", + /// ]); + /// assert_eq!(4, ac.max_pattern_len()); + /// ``` + pub fn max_pattern_len(&self) -> usize { + self.imp.max_pattern_len() + } + + /// Return the total number of patterns matched by this automaton. + /// + /// This includes patterns that may never participate in a match. For + /// example, if + /// [`MatchKind::LeftmostFirst`](enum.MatchKind.html#variant.LeftmostFirst) + /// match semantics are used, and the patterns `Sam` and `Samwise` were + /// used to build the automaton, then `Samwise` can never participate in a + /// match because `Sam` will always take priority. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasick; + /// + /// let ac = AhoCorasick::new(&[ + /// "foo", "bar", "baz", + /// ]); + /// assert_eq!(3, ac.pattern_count()); + /// ``` + pub fn pattern_count(&self) -> usize { + self.imp.pattern_count() + } + + /// Returns true if and only if this automaton supports reporting + /// overlapping matches. + /// + /// If this returns false and overlapping matches are requested, then it + /// will result in a panic. + /// + /// Since leftmost matching is inherently incompatible with overlapping + /// matches, only + /// [`MatchKind::Standard`](enum.MatchKind.html#variant.Standard) + /// supports overlapping matches. This is unlikely to change in the future. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::Standard) + /// .build(&["foo", "bar", "baz"]); + /// assert!(ac.supports_overlapping()); + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostFirst) + /// .build(&["foo", "bar", "baz"]); + /// assert!(!ac.supports_overlapping()); + /// ``` + pub fn supports_overlapping(&self) -> bool { + self.match_kind.supports_overlapping() + } + + /// Returns true if and only if this automaton supports stream searching. + /// + /// If this returns false and stream searching (or replacing) is attempted, + /// then it will result in a panic. + /// + /// Currently, only + /// [`MatchKind::Standard`](enum.MatchKind.html#variant.Standard) + /// supports streaming. This may be expanded in the future. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::Standard) + /// .build(&["foo", "bar", "baz"]); + /// assert!(ac.supports_stream()); + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostFirst) + /// .build(&["foo", "bar", "baz"]); + /// assert!(!ac.supports_stream()); + /// ``` + pub fn supports_stream(&self) -> bool { + self.match_kind.supports_stream() + } + + /// Returns the approximate total amount of heap used by this automaton, in + /// units of bytes. + /// + /// # Examples + /// + /// This example shows the difference in heap usage between a few + /// configurations: + /// + /// ```ignore + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let ac = AhoCorasickBuilder::new() + /// .dfa(false) // default + /// .build(&["foo", "bar", "baz"]); + /// assert_eq!(10_336, ac.heap_bytes()); + /// + /// let ac = AhoCorasickBuilder::new() + /// .dfa(false) // default + /// .ascii_case_insensitive(true) + /// .build(&["foo", "bar", "baz"]); + /// assert_eq!(10_384, ac.heap_bytes()); + /// + /// let ac = AhoCorasickBuilder::new() + /// .dfa(true) + /// .byte_classes(false) + /// .build(&["foo", "bar", "baz"]); + /// assert_eq!(20_768, ac.heap_bytes()); + /// + /// let ac = AhoCorasickBuilder::new() + /// .dfa(true) + /// .byte_classes(true) // default + /// .build(&["foo", "bar", "baz"]); + /// assert_eq!(1_248, ac.heap_bytes()); + /// + /// let ac = AhoCorasickBuilder::new() + /// .dfa(true) + /// .ascii_case_insensitive(true) + /// .build(&["foo", "bar", "baz"]); + /// assert_eq!(1_248, ac.heap_bytes()); + /// ``` + pub fn heap_bytes(&self) -> usize { + match self.imp { + Imp::NFA(ref nfa) => nfa.heap_bytes(), + Imp::DFA(ref dfa) => dfa.heap_bytes(), + } + } +} + +/// The internal implementation of Aho-Corasick, which is either an NFA or +/// a DFA. The NFA is slower but uses less memory. The DFA is faster but uses +/// more memory. +#[derive(Clone, Debug)] +enum Imp { + NFA(NFA), + DFA(DFA), +} + +impl Imp { + /// Returns the type of match semantics implemented by this automaton. + fn match_kind(&self) -> &MatchKind { + match *self { + Imp::NFA(ref nfa) => nfa.match_kind(), + Imp::DFA(ref dfa) => dfa.match_kind(), + } + } + + /// Returns the identifier of the start state. + fn start_state(&self) -> S { + match *self { + Imp::NFA(ref nfa) => nfa.start_state(), + Imp::DFA(ref dfa) => dfa.start_state(), + } + } + + /// The length, in bytes, of the longest pattern in this automaton. This + /// information is useful for maintaining correct buffer sizes when + /// searching on streams. + fn max_pattern_len(&self) -> usize { + match *self { + Imp::NFA(ref nfa) => nfa.max_pattern_len(), + Imp::DFA(ref dfa) => dfa.max_pattern_len(), + } + } + + /// The total number of patterns added to this automaton. This includes + /// patterns that may never match. The maximum matching pattern that can be + /// reported is exactly one less than this number. + fn pattern_count(&self) -> usize { + match *self { + Imp::NFA(ref nfa) => nfa.pattern_count(), + Imp::DFA(ref dfa) => dfa.pattern_count(), + } + } + + #[inline(always)] + fn overlapping_find_at( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + state_id: &mut S, + match_index: &mut usize, + ) -> Option { + match *self { + Imp::NFA(ref nfa) => nfa.overlapping_find_at( + prestate, + haystack, + at, + state_id, + match_index, + ), + Imp::DFA(ref dfa) => dfa.overlapping_find_at( + prestate, + haystack, + at, + state_id, + match_index, + ), + } + } + + #[inline(always)] + fn earliest_find_at( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + state_id: &mut S, + ) -> Option { + match *self { + Imp::NFA(ref nfa) => { + nfa.earliest_find_at(prestate, haystack, at, state_id) + } + Imp::DFA(ref dfa) => { + dfa.earliest_find_at(prestate, haystack, at, state_id) + } + } + } + + #[inline(always)] + fn find_at_no_state( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Option { + match *self { + Imp::NFA(ref nfa) => nfa.find_at_no_state(prestate, haystack, at), + Imp::DFA(ref dfa) => dfa.find_at_no_state(prestate, haystack, at), + } + } +} + +/// An iterator of non-overlapping matches in a particular haystack. +/// +/// This iterator yields matches according to the +/// [`MatchKind`](enum.MatchKind.html) +/// used by this automaton. +/// +/// This iterator is constructed via the +/// [`AhoCorasick::find_iter`](struct.AhoCorasick.html#method.find_iter) +/// method. +/// +/// The type variable `S` refers to the representation used for state +/// identifiers. (By default, this is `usize`.) +/// +/// The lifetime `'a` refers to the lifetime of the `AhoCorasick` automaton. +/// +/// The lifetime `'b` refers to the lifetime of the haystack being searched. +#[derive(Debug)] +pub struct FindIter<'a, 'b, S: 'a + StateID> { + fsm: &'a Imp, + prestate: PrefilterState, + haystack: &'b [u8], + pos: usize, +} + +impl<'a, 'b, S: StateID> FindIter<'a, 'b, S> { + fn new(ac: &'a AhoCorasick, haystack: &'b [u8]) -> FindIter<'a, 'b, S> { + let prestate = PrefilterState::new(ac.max_pattern_len()); + FindIter { fsm: &ac.imp, prestate, haystack, pos: 0 } + } +} + +impl<'a, 'b, S: StateID> Iterator for FindIter<'a, 'b, S> { + type Item = Match; + + fn next(&mut self) -> Option { + if self.pos > self.haystack.len() { + return None; + } + let result = self.fsm.find_at_no_state( + &mut self.prestate, + self.haystack, + self.pos, + ); + let mat = match result { + None => return None, + Some(mat) => mat, + }; + if mat.end() == self.pos { + // If the automaton can match the empty string and if we found an + // empty match, then we need to forcefully move the position. + self.pos += 1; + } else { + self.pos = mat.end(); + } + Some(mat) + } +} + +/// An iterator of overlapping matches in a particular haystack. +/// +/// This iterator will report all possible matches in a particular haystack, +/// even when the matches overlap. +/// +/// This iterator is constructed via the +/// [`AhoCorasick::find_overlapping_iter`](struct.AhoCorasick.html#method.find_overlapping_iter) +/// method. +/// +/// The type variable `S` refers to the representation used for state +/// identifiers. (By default, this is `usize`.) +/// +/// The lifetime `'a` refers to the lifetime of the `AhoCorasick` automaton. +/// +/// The lifetime `'b` refers to the lifetime of the haystack being searched. +#[derive(Debug)] +pub struct FindOverlappingIter<'a, 'b, S: 'a + StateID> { + fsm: &'a Imp, + prestate: PrefilterState, + haystack: &'b [u8], + pos: usize, + last_match_end: usize, + state_id: S, + match_index: usize, +} + +impl<'a, 'b, S: StateID> FindOverlappingIter<'a, 'b, S> { + fn new( + ac: &'a AhoCorasick, + haystack: &'b [u8], + ) -> FindOverlappingIter<'a, 'b, S> { + assert!( + ac.supports_overlapping(), + "automaton does not support overlapping searches" + ); + let prestate = PrefilterState::new(ac.max_pattern_len()); + FindOverlappingIter { + fsm: &ac.imp, + prestate, + haystack, + pos: 0, + last_match_end: 0, + state_id: ac.imp.start_state(), + match_index: 0, + } + } +} + +impl<'a, 'b, S: StateID> Iterator for FindOverlappingIter<'a, 'b, S> { + type Item = Match; + + fn next(&mut self) -> Option { + let result = self.fsm.overlapping_find_at( + &mut self.prestate, + self.haystack, + self.pos, + &mut self.state_id, + &mut self.match_index, + ); + match result { + None => return None, + Some(m) => { + self.pos = m.end(); + Some(m) + } + } + } +} + +/// An iterator that reports Aho-Corasick matches in a stream. +/// +/// This iterator yields elements of type `io::Result`, where an error +/// is reported if there was a problem reading from the underlying stream. +/// The iterator terminates only when the underlying stream reaches `EOF`. +/// +/// This iterator is constructed via the +/// [`AhoCorasick::stream_find_iter`](struct.AhoCorasick.html#method.stream_find_iter) +/// method. +/// +/// The type variable `R` refers to the `io::Read` stream that is being read +/// from. +/// +/// The type variable `S` refers to the representation used for state +/// identifiers. (By default, this is `usize`.) +/// +/// The lifetime `'a` refers to the lifetime of the `AhoCorasick` automaton. +#[derive(Debug)] +pub struct StreamFindIter<'a, R, S: 'a + StateID> { + it: StreamChunkIter<'a, R, S>, +} + +impl<'a, R: io::Read, S: StateID> StreamFindIter<'a, R, S> { + fn new(ac: &'a AhoCorasick, rdr: R) -> StreamFindIter<'a, R, S> { + StreamFindIter { it: StreamChunkIter::new(ac, rdr) } + } +} + +impl<'a, R: io::Read, S: StateID> Iterator for StreamFindIter<'a, R, S> { + type Item = io::Result; + + fn next(&mut self) -> Option> { + loop { + match self.it.next() { + None => return None, + Some(Err(err)) => return Some(Err(err)), + Some(Ok(StreamChunk::NonMatch { .. })) => {} + Some(Ok(StreamChunk::Match { mat, .. })) => { + return Some(Ok(mat)); + } + } + } + } +} + +/// An iterator over chunks in an underlying reader. Each chunk either +/// corresponds to non-matching bytes or matching bytes, but all bytes from +/// the underlying reader are reported in sequence. There may be an arbitrary +/// number of non-matching chunks before seeing a matching chunk. +/// +/// N.B. This does not actually implement Iterator because we need to borrow +/// from the underlying reader. But conceptually, it's still an iterator. +#[derive(Debug)] +struct StreamChunkIter<'a, R, S: 'a + StateID> { + /// The AC automaton. + fsm: &'a Imp, + /// State associated with this automaton's prefilter. It is a heuristic + /// for stopping the prefilter if it's deemed ineffective. + prestate: PrefilterState, + /// The source of bytes we read from. + rdr: R, + /// A fixed size buffer. This is what we actually search. There are some + /// invariants around the buffer's size, namely, it must be big enough to + /// contain the longest possible match. + buf: Buffer, + /// The ID of the FSM state we're currently in. + state_id: S, + /// The current position at which to start the next search in `buf`. + search_pos: usize, + /// The absolute position of `search_pos`, where `0` corresponds to the + /// position of the first byte read from `rdr`. + absolute_pos: usize, + /// The ending position of the last StreamChunk that was returned to the + /// caller. This position is used to determine whether we need to emit + /// non-matching bytes before emitting a match. + report_pos: usize, + /// A match that should be reported on the next call. + pending_match: Option, + /// Enabled only when the automaton can match the empty string. When + /// enabled, we need to execute one final search after consuming the + /// reader to find the trailing empty match. + has_empty_match_at_end: bool, +} + +/// A single chunk yielded by the stream chunk iterator. +/// +/// The `'r` lifetime refers to the lifetime of the stream chunk iterator. +#[derive(Debug)] +enum StreamChunk<'r> { + /// A chunk that does not contain any matches. + NonMatch { bytes: &'r [u8], start: usize }, + /// A chunk that precisely contains a match. + Match { bytes: &'r [u8], mat: Match }, +} + +impl<'a, R: io::Read, S: StateID> StreamChunkIter<'a, R, S> { + fn new(ac: &'a AhoCorasick, rdr: R) -> StreamChunkIter<'a, R, S> { + assert!( + ac.supports_stream(), + "stream searching is only supported for Standard match semantics" + ); + + let prestate = PrefilterState::new(ac.max_pattern_len()); + let buf = Buffer::new(ac.imp.max_pattern_len()); + let state_id = ac.imp.start_state(); + StreamChunkIter { + fsm: &ac.imp, + prestate, + rdr, + buf, + state_id, + absolute_pos: 0, + report_pos: 0, + search_pos: 0, + pending_match: None, + has_empty_match_at_end: ac.is_match(""), + } + } + + fn next<'r>(&'r mut self) -> Option>> { + loop { + if let Some(mut mat) = self.pending_match.take() { + let bytes = &self.buf.buffer()[mat.start()..mat.end()]; + self.report_pos = mat.end(); + mat = mat.increment(self.absolute_pos); + return Some(Ok(StreamChunk::Match { bytes, mat })); + } + if self.search_pos >= self.buf.len() { + if let Some(end) = self.unreported() { + let bytes = &self.buf.buffer()[self.report_pos..end]; + let start = self.absolute_pos + self.report_pos; + self.report_pos = end; + return Some(Ok(StreamChunk::NonMatch { bytes, start })); + } + if self.buf.len() >= self.buf.min_buffer_len() { + // This is the point at which we roll our buffer, which we + // only do if our buffer has at least the minimum amount of + // bytes in it. Before rolling, we update our various + // positions to be consistent with the buffer after it has + // been rolled. + + self.report_pos -= + self.buf.len() - self.buf.min_buffer_len(); + self.absolute_pos += + self.search_pos - self.buf.min_buffer_len(); + self.search_pos = self.buf.min_buffer_len(); + self.buf.roll(); + } + match self.buf.fill(&mut self.rdr) { + Err(err) => return Some(Err(err)), + Ok(false) => { + // We've hit EOF, but if there are still some + // unreported bytes remaining, return them now. + if self.report_pos < self.buf.len() { + let bytes = &self.buf.buffer()[self.report_pos..]; + let start = self.absolute_pos + self.report_pos; + self.report_pos = self.buf.len(); + + let chunk = StreamChunk::NonMatch { bytes, start }; + return Some(Ok(chunk)); + } else { + // We've reported everything, but there might still + // be a match at the very last position. + if !self.has_empty_match_at_end { + return None; + } + // fallthrough for another search to get trailing + // empty matches + self.has_empty_match_at_end = false; + } + } + Ok(true) => {} + } + } + let result = self.fsm.earliest_find_at( + &mut self.prestate, + self.buf.buffer(), + self.search_pos, + &mut self.state_id, + ); + match result { + None => { + self.search_pos = self.buf.len(); + } + Some(mat) => { + self.state_id = self.fsm.start_state(); + if mat.end() == self.search_pos { + // If the automaton can match the empty string and if + // we found an empty match, then we need to forcefully + // move the position. + self.search_pos += 1; + } else { + self.search_pos = mat.end(); + } + self.pending_match = Some(mat.clone()); + if self.report_pos < mat.start() { + let bytes = + &self.buf.buffer()[self.report_pos..mat.start()]; + let start = self.absolute_pos + self.report_pos; + self.report_pos = mat.start(); + + let chunk = StreamChunk::NonMatch { bytes, start }; + return Some(Ok(chunk)); + } + } + } + } + } + + fn unreported(&self) -> Option { + let end = self.search_pos.saturating_sub(self.buf.min_buffer_len()); + if self.report_pos < end { + Some(end) + } else { + None + } + } +} + +/// A builder for configuring an Aho-Corasick automaton. +#[derive(Clone, Debug)] +pub struct AhoCorasickBuilder { + nfa_builder: nfa::Builder, + dfa_builder: dfa::Builder, + dfa: bool, +} + +impl Default for AhoCorasickBuilder { + fn default() -> AhoCorasickBuilder { + AhoCorasickBuilder::new() + } +} + +impl AhoCorasickBuilder { + /// Create a new builder for configuring an Aho-Corasick automaton. + /// + /// If you don't need fine grained configuration or aren't sure which knobs + /// to set, try using + /// [`AhoCorasick::new_auto_configured`](struct.AhoCorasick.html#method.new_auto_configured) + /// instead. + pub fn new() -> AhoCorasickBuilder { + AhoCorasickBuilder { + nfa_builder: nfa::Builder::new(), + dfa_builder: dfa::Builder::new(), + dfa: false, + } + } + + /// Build an Aho-Corasick automaton using the configuration set on this + /// builder. + /// + /// A builder may be reused to create more automatons. + /// + /// This method will use the default for representing internal state + /// identifiers, which is `usize`. This guarantees that building the + /// automaton will succeed and is generally a good default, but can make + /// the size of the automaton 2-8 times bigger than it needs to be, + /// depending on your target platform. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasickBuilder; + /// + /// let patterns = &["foo", "bar", "baz"]; + /// let ac = AhoCorasickBuilder::new() + /// .build(patterns); + /// assert_eq!(Some(1), ac.find("xxx bar xxx").map(|m| m.pattern())); + /// ``` + pub fn build(&self, patterns: I) -> AhoCorasick + where + I: IntoIterator, + P: AsRef<[u8]>, + { + // The builder only returns an error if the chosen state ID + // representation is too small to fit all of the given patterns. In + // this case, since we fix the representation to usize, it will always + // work because it's impossible to overflow usize since the underlying + // storage would OOM long before that happens. + self.build_with_size::(patterns) + .expect("usize state ID type should always work") + } + + /// Build an Aho-Corasick automaton using the configuration set on this + /// builder with a specific state identifier representation. This only has + /// an effect when the `dfa` option is enabled. + /// + /// Generally, the choices for a state identifier representation are + /// `u8`, `u16`, `u32`, `u64` or `usize`, with `usize` being the default. + /// The advantage of choosing a smaller state identifier representation + /// is that the automaton produced will be smaller. This might be + /// beneficial for just generally using less space, or might even allow it + /// to fit more of the automaton in your CPU's cache, leading to overall + /// better search performance. + /// + /// Unlike the standard `build` method, this can report an error if the + /// state identifier representation cannot support the size of the + /// automaton. + /// + /// Note that the state identifier representation is determined by the + /// `S` type variable. This requires a type hint of some sort, either + /// by specifying the return type or using the turbofish, e.g., + /// `build_with_size::(...)`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::{AhoCorasick, AhoCorasickBuilder}; + /// + /// # fn example() -> Result<(), ::aho_corasick::Error> { + /// let patterns = &["foo", "bar", "baz"]; + /// let ac: AhoCorasick = AhoCorasickBuilder::new() + /// .build_with_size(patterns)?; + /// assert_eq!(Some(1), ac.find("xxx bar xxx").map(|m| m.pattern())); + /// # Ok(()) }; example().unwrap() + /// ``` + /// + /// Or alternatively, with turbofish: + /// + /// ``` + /// use aho_corasick::AhoCorasickBuilder; + /// + /// # fn example() -> Result<(), ::aho_corasick::Error> { + /// let patterns = &["foo", "bar", "baz"]; + /// let ac = AhoCorasickBuilder::new() + /// .build_with_size::(patterns)?; + /// assert_eq!(Some(1), ac.find("xxx bar xxx").map(|m| m.pattern())); + /// # Ok(()) }; example().unwrap() + /// ``` + pub fn build_with_size( + &self, + patterns: I, + ) -> Result> + where + S: StateID, + I: IntoIterator, + P: AsRef<[u8]>, + { + let nfa = self.nfa_builder.build(patterns)?; + let match_kind = nfa.match_kind().clone(); + let imp = if self.dfa { + let dfa = self.dfa_builder.build(&nfa)?; + Imp::DFA(dfa) + } else { + Imp::NFA(nfa) + }; + Ok(AhoCorasick { imp, match_kind }) + } + + /// Automatically configure the settings on this builder according to the + /// patterns that will be used to construct the automaton. + /// + /// The idea here is to balance space and time automatically. That is, when + /// searching a small number of patterns, this will attempt to use the + /// fastest possible configuration since the total space required will be + /// small anyway. As the number of patterns grows, this will fall back to + /// slower configurations that use less space. + /// + /// This is guaranteed to never set `match_kind`, but any other option may + /// be overridden. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasickBuilder; + /// + /// let patterns = &["foo", "bar", "baz"]; + /// let ac = AhoCorasickBuilder::new() + /// .auto_configure(patterns) + /// .build(patterns); + /// assert_eq!(Some(1), ac.find("xxx bar xxx").map(|m| m.pattern())); + /// ``` + pub fn auto_configure>( + &mut self, + patterns: &[B], + ) -> &mut AhoCorasickBuilder { + // N.B. Currently we only use the length of `patterns` to make a + // decision here, and could therefore ask for an `ExactSizeIterator` + // instead. But it's conceivable that we might adapt this to look at + // the total number of bytes, which would requires a second pass. + // + // The logic here is fairly rudimentary at the moment, but probably + // OK. The idea here is to use the fastest thing possible for a small + // number of patterns. That is, a DFA with no byte classes, since byte + // classes require an extra indirection for every byte searched. With a + // moderate number of patterns, we still want a DFA, but save on both + // space and compilation time by enabling byte classes. Finally, fall + // back to the slower but smaller NFA. + if patterns.len() <= 100 { + // N.B. Using byte classes can actually be faster by improving + // locality, but this only really applies for multi-megabyte + // automata (i.e., automata that don't fit in your CPU's cache). + self.dfa(true).byte_classes(false); + } else if patterns.len() <= 5000 { + self.dfa(true); + } + self + } + + /// Set the desired match semantics. + /// + /// The default is `MatchKind::Standard`, which corresponds to the match + /// semantics supported by the standard textbook description of the + /// Aho-Corasick algorithm. Namely, matches are reported as soon as they + /// are found. Moreover, this is the only way to get overlapping matches + /// or do stream searching. + /// + /// The other kinds of match semantics that are supported are + /// `MatchKind::LeftmostFirst` and `MatchKind::LeftmostLongest`. The former + /// corresponds to the match you would get if you were to try to match + /// each pattern at each position in the haystack in the same order that + /// you give to the automaton. That is, it returns the leftmost match + /// corresponding the earliest pattern given to the automaton. The latter + /// corresponds to finding the longest possible match among all leftmost + /// matches. + /// + /// For more details on match semantics, see the + /// [documentation for `MatchKind`](enum.MatchKind.html). + /// + /// # Examples + /// + /// In these examples, we demonstrate the differences between match + /// semantics for a particular set of patterns in a specific order: + /// `b`, `abc`, `abcd`. + /// + /// Standard semantics: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["b", "abc", "abcd"]; + /// let haystack = "abcd"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::Standard) // default, not necessary + /// .build(patterns); + /// let mat = ac.find(haystack).expect("should have a match"); + /// assert_eq!("b", &haystack[mat.start()..mat.end()]); + /// ``` + /// + /// Leftmost-first semantics: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["b", "abc", "abcd"]; + /// let haystack = "abcd"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostFirst) + /// .build(patterns); + /// let mat = ac.find(haystack).expect("should have a match"); + /// assert_eq!("abc", &haystack[mat.start()..mat.end()]); + /// ``` + /// + /// Leftmost-longest semantics: + /// + /// ``` + /// use aho_corasick::{AhoCorasickBuilder, MatchKind}; + /// + /// let patterns = &["b", "abc", "abcd"]; + /// let haystack = "abcd"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .match_kind(MatchKind::LeftmostLongest) + /// .build(patterns); + /// let mat = ac.find(haystack).expect("should have a match"); + /// assert_eq!("abcd", &haystack[mat.start()..mat.end()]); + /// ``` + pub fn match_kind(&mut self, kind: MatchKind) -> &mut AhoCorasickBuilder { + self.nfa_builder.match_kind(kind); + self + } + + /// Enable anchored mode, which requires all matches to start at the + /// first position in a haystack. + /// + /// This option is disabled by default. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasickBuilder; + /// + /// let patterns = &["foo", "bar"]; + /// let haystack = "foobar"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .anchored(true) + /// .build(patterns); + /// assert_eq!(1, ac.find_iter(haystack).count()); + /// ``` + /// + /// When searching for overlapping matches, all matches that start at + /// the beginning of a haystack will be reported: + /// + /// ``` + /// use aho_corasick::AhoCorasickBuilder; + /// + /// let patterns = &["foo", "foofoo"]; + /// let haystack = "foofoo"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .anchored(true) + /// .build(patterns); + /// assert_eq!(2, ac.find_overlapping_iter(haystack).count()); + /// // A non-anchored search would return 3 matches. + /// ``` + pub fn anchored(&mut self, yes: bool) -> &mut AhoCorasickBuilder { + self.nfa_builder.anchored(yes); + self + } + + /// Enable ASCII-aware case insensitive matching. + /// + /// When this option is enabled, searching will be performed without + /// respect to case for ASCII letters (`a-z` and `A-Z`) only. + /// + /// Enabling this option does not change the search algorithm, but it may + /// increase the size of the automaton. + /// + /// **NOTE:** In the future, support for full Unicode case insensitivity + /// may be added, but ASCII case insensitivity is comparatively much + /// simpler to add. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::AhoCorasickBuilder; + /// + /// let patterns = &["FOO", "bAr", "BaZ"]; + /// let haystack = "foo bar baz"; + /// + /// let ac = AhoCorasickBuilder::new() + /// .ascii_case_insensitive(true) + /// .build(patterns); + /// assert_eq!(3, ac.find_iter(haystack).count()); + /// ``` + pub fn ascii_case_insensitive( + &mut self, + yes: bool, + ) -> &mut AhoCorasickBuilder { + self.nfa_builder.ascii_case_insensitive(yes); + self + } + + /// Set the limit on how many NFA states use a dense representation for + /// their transitions. + /// + /// A dense representation uses more space, but supports faster access to + /// transitions at search time. Thus, this setting permits the control of a + /// space vs time trade off when using the NFA variant of Aho-Corasick. + /// + /// This limit is expressed in terms of the depth of a state, i.e., the + /// number of transitions from the starting state of the NFA. The idea is + /// that most of the time searching will be spent near the starting state + /// of the automaton, so states near the start state should use a dense + /// representation. States further away from the start state would then use + /// a sparse representation, which uses less space but is slower to access + /// transitions at search time. + /// + /// By default, this is set to a low but non-zero number. + /// + /// This setting has no effect if the `dfa` option is enabled. + pub fn dense_depth(&mut self, depth: usize) -> &mut AhoCorasickBuilder { + self.nfa_builder.dense_depth(depth); + self + } + + /// Compile the standard Aho-Corasick automaton into a deterministic finite + /// automaton (DFA). + /// + /// When this is disabled (which is the default), then a non-deterministic + /// finite automaton (NFA) is used instead. + /// + /// The main benefit to a DFA is that it can execute searches more quickly + /// than a DFA (perhaps 2-4 times as fast). The main drawback is that the + /// DFA uses more space and can take much longer to build. + /// + /// Enabling this option does not change the time complexity for + /// constructing the Aho-Corasick automaton (which is `O(p)` where + /// `p` is the total number of patterns being compiled). Enabling this + /// option does however reduce the time complexity of non-overlapping + /// searches from `O(n + p)` to `O(n)`, where `n` is the length of the + /// haystack. + /// + /// In general, it's a good idea to enable this if you're searching a + /// small number of fairly short patterns (~1000), or if you want the + /// fastest possible search without regard to compilation time or space + /// usage. + pub fn dfa(&mut self, yes: bool) -> &mut AhoCorasickBuilder { + self.dfa = yes; + self + } + + /// Enable heuristic prefilter optimizations. + /// + /// When enabled, searching will attempt to quickly skip to match + /// candidates using specialized literal search routines. A prefilter + /// cannot always be used, and is generally treated as a heuristic. It + /// can be useful to disable this if the prefilter is observed to be + /// sub-optimal for a particular workload. + /// + /// This is enabled by default. + pub fn prefilter(&mut self, yes: bool) -> &mut AhoCorasickBuilder { + self.nfa_builder.prefilter(yes); + self + } + + /// Shrink the size of the transition alphabet by mapping bytes to their + /// equivalence classes. This only has an effect when the `dfa` option is + /// enabled. + /// + /// When enabled, each a DFA will use a map from all possible bytes + /// to their corresponding equivalence class. Each equivalence class + /// represents a set of bytes that does not discriminate between a match + /// and a non-match in the DFA. For example, the patterns `bar` and `baz` + /// have at least five equivalence classes: singleton sets of `b`, `a`, `r` + /// and `z`, and a final set that contains every other byte. + /// + /// The advantage of this map is that the size of the transition table can + /// be reduced drastically from `#states * 256 * sizeof(id)` to + /// `#states * k * sizeof(id)` where `k` is the number of equivalence + /// classes. As a result, total space usage can decrease substantially. + /// Moreover, since a smaller alphabet is used, compilation becomes faster + /// as well. + /// + /// The disadvantage of this map is that every byte searched must be + /// passed through this map before it can be used to determine the next + /// transition. This has a small match time performance cost. However, if + /// the DFA is otherwise very large without byte classes, then using byte + /// classes can greatly improve memory locality and thus lead to better + /// overall performance. + /// + /// This option is enabled by default. + pub fn byte_classes(&mut self, yes: bool) -> &mut AhoCorasickBuilder { + self.dfa_builder.byte_classes(yes); + self + } + + /// Premultiply state identifiers in the transition table. This only has + /// an effect when the `dfa` option is enabled. + /// + /// When enabled, state identifiers are premultiplied to point to their + /// corresponding row in the transition table. That is, given the `i`th + /// state, its corresponding premultiplied identifier is `i * k` where `k` + /// is the alphabet size of the automaton. (The alphabet size is at most + /// 256, but is in practice smaller if byte classes is enabled.) + /// + /// When state identifiers are not premultiplied, then the identifier of + /// the `i`th state is `i`. + /// + /// The advantage of premultiplying state identifiers is that is saves a + /// multiplication instruction per byte when searching with a DFA. This has + /// been observed to lead to a 20% performance benefit in micro-benchmarks. + /// + /// The primary disadvantage of premultiplying state identifiers is + /// that they require a larger integer size to represent. For example, + /// if the DFA has 200 states, then its premultiplied form requires 16 + /// bits to represent every possible state identifier, where as its + /// non-premultiplied form only requires 8 bits. + /// + /// This option is enabled by default. + pub fn premultiply(&mut self, yes: bool) -> &mut AhoCorasickBuilder { + self.dfa_builder.premultiply(yes); + self + } +} + +/// A knob for controlling the match semantics of an Aho-Corasick automaton. +/// +/// There are two generally different ways that Aho-Corasick automatons can +/// report matches. The first way is the "standard" approach that results from +/// implementing most textbook explanations of Aho-Corasick. The second way is +/// to report only the leftmost non-overlapping matches. The leftmost approach +/// is in turn split into two different ways of resolving ambiguous matches: +/// leftmost-first and leftmost-longest. +/// +/// The `Standard` match kind is the default and is the only one that supports +/// overlapping matches and stream searching. (Trying to find overlapping +/// or streaming matches using leftmost match semantics will result in a +/// panic.) The `Standard` match kind will report matches as they are seen. +/// When searching for overlapping matches, then all possible matches are +/// reported. When searching for non-overlapping matches, the first match seen +/// is reported. For example, for non-overlapping matches, given the patterns +/// `abcd` and `b` and the subject string `abcdef`, only a match for `b` is +/// reported since it is detected first. The `abcd` match is never reported +/// since it overlaps with the `b` match. +/// +/// In contrast, the leftmost match kind always prefers the leftmost match +/// among all possible matches. Given the same example as above with `abcd` and +/// `b` as patterns and `abcdef` as the subject string, the leftmost match is +/// `abcd` since it begins before the `b` match, even though the `b` match is +/// detected before the `abcd` match. In this case, the `b` match is not +/// reported at all since it overlaps with the `abcd` match. +/// +/// The difference between leftmost-first and leftmost-longest is in how they +/// resolve ambiguous matches when there are multiple leftmost matches to +/// choose from. Leftmost-first always chooses the pattern that was provided +/// earliest, where as leftmost-longest always chooses the longest matching +/// pattern. For example, given the patterns `a` and `ab` and the subject +/// string `ab`, the leftmost-first match is `a` but the leftmost-longest match +/// is `ab`. Conversely, if the patterns were given in reverse order, i.e., +/// `ab` and `a`, then both the leftmost-first and leftmost-longest matches +/// would be `ab`. Stated differently, the leftmost-first match depends on the +/// order in which the patterns were given to the Aho-Corasick automaton. +/// Because of that, when leftmost-first matching is used, if a pattern `A` +/// that appears before a pattern `B` is a prefix of `B`, then it is impossible +/// to ever observe a match of `B`. +/// +/// If you're not sure which match kind to pick, then stick with the standard +/// kind, which is the default. In particular, if you need overlapping or +/// streaming matches, then you _must_ use the standard kind. The leftmost +/// kinds are useful in specific circumstances. For example, leftmost-first can +/// be very useful as a way to implement match priority based on the order of +/// patterns given and leftmost-longest can be useful for dictionary searching +/// such that only the longest matching words are reported. +/// +/// # Relationship with regular expression alternations +/// +/// Understanding match semantics can be a little tricky, and one easy way +/// to conceptualize non-overlapping matches from an Aho-Corasick automaton +/// is to think about them as a simple alternation of literals in a regular +/// expression. For example, let's say we wanted to match the strings +/// `Sam` and `Samwise`, which would turn into the regex `Sam|Samwise`. It +/// turns out that regular expression engines have two different ways of +/// matching this alternation. The first way, leftmost-longest, is commonly +/// found in POSIX compatible implementations of regular expressions (such as +/// `grep`). The second way, leftmost-first, is commonly found in backtracking +/// implementations such as Perl. (Some regex engines, such as RE2 and Rust's +/// regex engine do not use backtracking, but still implement leftmost-first +/// semantics in an effort to match the behavior of dominant backtracking +/// regex engines such as those found in Perl, Ruby, Python, Javascript and +/// PHP.) +/// +/// That is, when matching `Sam|Samwise` against `Samwise`, a POSIX regex +/// will match `Samwise` because it is the longest possible match, but a +/// Perl-like regex will match `Sam` since it appears earlier in the +/// alternation. Indeed, the regex `Sam|Samwise` in a Perl-like regex engine +/// will never match `Samwise` since `Sam` will always have higher priority. +/// Conversely, matching the regex `Samwise|Sam` against `Samwise` will lead to +/// a match of `Samwise` in both POSIX and Perl-like regexes since `Samwise` is +/// still longest match, but it also appears earlier than `Sam`. +/// +/// The "standard" match semantics of Aho-Corasick generally don't correspond +/// to the match semantics of any large group of regex implementations, so +/// there's no direct analogy that can be made here. Standard match semantics +/// are generally useful for overlapping matches, or if you just want to see +/// matches as they are detected. +/// +/// The main conclusion to draw from this section is that the match semantics +/// can be tweaked to precisely match either Perl-like regex alternations or +/// POSIX regex alternations. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum MatchKind { + /// Use standard match semantics, which support overlapping matches. When + /// used with non-overlapping matches, matches are reported as they are + /// seen. + Standard, + /// Use leftmost-first match semantics, which reports leftmost matches. + /// When there are multiple possible leftmost matches, the match + /// corresponding to the pattern that appeared earlier when constructing + /// the automaton is reported. + /// + /// This does **not** support overlapping matches or stream searching. If + /// this match kind is used, attempting to find overlapping matches or + /// stream matches will panic. + LeftmostFirst, + /// Use leftmost-longest match semantics, which reports leftmost matches. + /// When there are multiple possible leftmost matches, the longest match + /// is chosen. + /// + /// This does **not** support overlapping matches or stream searching. If + /// this match kind is used, attempting to find overlapping matches or + /// stream matches will panic. + LeftmostLongest, + /// Hints that destructuring should not be exhaustive. + /// + /// This enum may grow additional variants, so this makes sure clients + /// don't count on exhaustive matching. (Otherwise, adding a new variant + /// could break existing code.) + #[doc(hidden)] + __Nonexhaustive, +} + +/// The default match kind is `MatchKind::Standard`. +impl Default for MatchKind { + fn default() -> MatchKind { + MatchKind::Standard + } +} + +impl MatchKind { + fn supports_overlapping(&self) -> bool { + self.is_standard() + } + + fn supports_stream(&self) -> bool { + // TODO: It may be possible to support this. It's hard. + // + // See: https://github.com/rust-lang/regex/issues/425#issuecomment-471367838 + self.is_standard() + } + + pub(crate) fn is_standard(&self) -> bool { + *self == MatchKind::Standard + } + + pub(crate) fn is_leftmost(&self) -> bool { + *self == MatchKind::LeftmostFirst + || *self == MatchKind::LeftmostLongest + } + + pub(crate) fn is_leftmost_first(&self) -> bool { + *self == MatchKind::LeftmostFirst + } + + /// Convert this match kind into a packed match kind. If this match kind + /// corresponds to standard semantics, then this returns None, since + /// packed searching does not support standard semantics. + pub(crate) fn as_packed(&self) -> Option { + match *self { + MatchKind::Standard => None, + MatchKind::LeftmostFirst => Some(packed::MatchKind::LeftmostFirst), + MatchKind::LeftmostLongest => { + Some(packed::MatchKind::LeftmostLongest) + } + MatchKind::__Nonexhaustive => unreachable!(), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn oibits() { + use std::panic::{RefUnwindSafe, UnwindSafe}; + + fn assert_send() {} + fn assert_sync() {} + fn assert_unwind_safe() {} + + assert_send::(); + assert_sync::(); + assert_unwind_safe::(); + assert_send::(); + assert_sync::(); + assert_unwind_safe::(); + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/automaton.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/automaton.rs new file mode 100644 index 0000000..2447639 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/automaton.rs @@ -0,0 +1,589 @@ +use ahocorasick::MatchKind; +use prefilter::{self, Candidate, Prefilter, PrefilterState}; +use state_id::{dead_id, fail_id, StateID}; +use Match; + +// NOTE: This trait essentially started as a copy of the same trait from from +// regex-automata, with some wording changed since we use this trait for +// NFAs in addition to DFAs in this crate. Additionally, we do not export +// this trait. It's only used internally to reduce code duplication. The +// regex-automata crate needs to expose it because its Regex type is generic +// over implementations of this trait. In this crate, we encapsulate everything +// behind the AhoCorasick type. +// +// This trait is a bit of a mess, but it's not quite clear how to fix it. +// Basically, there are several competing concerns: +// +// * We need performance, so everything effectively needs to get monomorphized. +// * There are several variations on searching Aho-Corasick automatons: +// overlapping, standard and leftmost. Overlapping and standard are somewhat +// combined together below, but there is no real way to combine standard with +// leftmost. Namely, leftmost requires continuing a search even after a match +// is found, in order to correctly disambiguate a match. +// * On top of that, *sometimes* callers want to know which state the automaton +// is in after searching. This is principally useful for overlapping and +// stream searches. However, when callers don't care about this, we really +// do not want to be forced to compute it, since it sometimes requires extra +// work. Thus, there are effectively two copies of leftmost searching: one +// for tracking the state ID and one that doesn't. We should ideally do the +// same for standard searching, but my sanity stopped me. + +/// A trait describing the interface of an Aho-Corasick finite state machine. +/// +/// Every automaton has exactly one fail state, one dead state and exactly one +/// start state. Generally, these correspond to the first, second and third +/// states, respectively. The failure state is always treated as a sentinel. +/// That is, no correct Aho-Corasick automaton will ever transition into the +/// fail state. The dead state, however, can be transitioned into, but only +/// when leftmost-first or leftmost-longest match semantics are enabled and +/// only when at least one match has been observed. +/// +/// Every automaton also has one or more match states, such that +/// `Automaton::is_match_state_unchecked(id)` returns `true` if and only if +/// `id` corresponds to a match state. +pub trait Automaton { + /// The representation used for state identifiers in this automaton. + /// + /// Typically, this is one of `u8`, `u16`, `u32`, `u64` or `usize`. + type ID: StateID; + + /// The type of matching that should be done. + fn match_kind(&self) -> &MatchKind; + + /// Returns true if and only if this automaton uses anchored searches. + fn anchored(&self) -> bool; + + /// An optional prefilter for quickly skipping to the next candidate match. + /// A prefilter must report at least every match, although it may report + /// positions that do not correspond to a match. That is, it must not allow + /// false negatives, but can allow false positives. + /// + /// Currently, a prefilter only runs when the automaton is in the start + /// state. That is, the position reported by a prefilter should always + /// correspond to the start of a potential match. + fn prefilter(&self) -> Option<&dyn Prefilter>; + + /// Return the identifier of this automaton's start state. + fn start_state(&self) -> Self::ID; + + /// Returns true if and only if the given state identifier refers to a + /// valid state. + fn is_valid(&self, id: Self::ID) -> bool; + + /// Returns true if and only if the given identifier corresponds to a match + /// state. + /// + /// The state ID given must be valid, or else implementors may panic. + fn is_match_state(&self, id: Self::ID) -> bool; + + /// Returns true if and only if the given identifier corresponds to a state + /// that is either the dead state or a match state. + /// + /// Depending on the implementation of the automaton, this routine can + /// be used to save a branch in the core matching loop. Nevertheless, + /// `is_match_state(id) || id == dead_id()` is always a valid + /// implementation. Indeed, this is the default implementation. + /// + /// The state ID given must be valid, or else implementors may panic. + fn is_match_or_dead_state(&self, id: Self::ID) -> bool { + id == dead_id() || self.is_match_state(id) + } + + /// If the given state is a match state, return the match corresponding + /// to the given match index. `end` must be the ending position of the + /// detected match. If no match exists or if `match_index` exceeds the + /// number of matches in this state, then `None` is returned. + /// + /// The state ID given must be valid, or else implementors may panic. + /// + /// If the given state ID is correct and if the `match_index` is less than + /// the number of matches for that state, then this is guaranteed to return + /// a match. + fn get_match( + &self, + id: Self::ID, + match_index: usize, + end: usize, + ) -> Option; + + /// Returns the number of matches for the given state. If the given state + /// is not a match state, then this returns 0. + /// + /// The state ID given must be valid, or else implementors must panic. + fn match_count(&self, id: Self::ID) -> usize; + + /// Given the current state that this automaton is in and the next input + /// byte, this method returns the identifier of the next state. The + /// identifier returned must always be valid and may never correspond to + /// the fail state. The returned identifier may, however, point to the + /// dead state. + /// + /// This is not safe so that implementors may look up the next state + /// without memory safety checks such as bounds checks. As such, callers + /// must ensure that the given identifier corresponds to a valid automaton + /// state. Implementors must, in turn, ensure that this routine is safe for + /// all valid state identifiers and for all possible `u8` values. + unsafe fn next_state_unchecked( + &self, + current: Self::ID, + input: u8, + ) -> Self::ID; + + /// Like next_state_unchecked, but debug_asserts that the underlying + /// implementation never returns a `fail_id()` for the next state. + unsafe fn next_state_unchecked_no_fail( + &self, + current: Self::ID, + input: u8, + ) -> Self::ID { + let next = self.next_state_unchecked(current, input); + // We should never see a transition to the failure state. + debug_assert!( + next != fail_id(), + "automaton should never return fail_id for next state" + ); + next + } + + /// Execute a search using standard match semantics. + /// + /// This can be used even when the automaton was constructed with leftmost + /// match semantics when you want to find the earliest possible match. This + /// can also be used as part of an overlapping search implementation. + /// + /// N.B. This does not report a match if `state_id` is given as a matching + /// state. As such, this should not be used directly. + #[inline(always)] + fn standard_find_at( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + state_id: &mut Self::ID, + ) -> Option { + if let Some(pre) = self.prefilter() { + self.standard_find_at_imp( + prestate, + Some(pre), + haystack, + at, + state_id, + ) + } else { + self.standard_find_at_imp(prestate, None, haystack, at, state_id) + } + } + + // It's important for this to always be inlined. Namely, it's only caller + // is standard_find_at, and the inlining should remove the case analysis + // for prefilter scanning when there is no prefilter available. + #[inline(always)] + fn standard_find_at_imp( + &self, + prestate: &mut PrefilterState, + prefilter: Option<&dyn Prefilter>, + haystack: &[u8], + at: usize, + state_id: &mut Self::ID, + ) -> Option { + // This is necessary for guaranteeing a safe API, since we use the + // state ID below in a function that exhibits UB if called with an + // invalid state ID. + assert!( + self.is_valid(*state_id), + "{} is not a valid state ID", + state_id.to_usize() + ); + unsafe { + let start = haystack.as_ptr(); + let end = haystack[haystack.len()..].as_ptr(); + let mut ptr = haystack[at..].as_ptr(); + while ptr < end { + if let Some(pre) = prefilter { + let at = ptr as usize - start as usize; + if prestate.is_effective(at) + && *state_id == self.start_state() + { + let c = prefilter::next(prestate, pre, haystack, at) + .into_option(); + match c { + None => return None, + Some(i) => { + ptr = start.offset(i as isize); + } + } + } + } + // SAFETY: next_state is safe for all possible u8 values, + // so the only thing we're concerned about is the validity + // of `state_id`. `state_id` either comes from the caller + // (in which case, we assert above that it is valid), or it + // comes from the return value of next_state, which is also + // guaranteed to be valid. + *state_id = self.next_state_unchecked_no_fail(*state_id, *ptr); + ptr = ptr.offset(1); + // This routine always quits immediately after seeing a + // match, and since dead states can only come after seeing + // a match, seeing a dead state here is impossible. (Unless + // we have an anchored automaton, in which case, dead states + // are used to stop a search.) + debug_assert!( + *state_id != dead_id() || self.anchored(), + "standard find should never see a dead state" + ); + + if self.is_match_or_dead_state(*state_id) { + return if *state_id == dead_id() { + None + } else { + let end = ptr as usize - start as usize; + self.get_match(*state_id, 0, end) + }; + } + } + None + } + } + + /// Execute a search using leftmost (either first or longest) match + /// semantics. + /// + /// The principle difference between searching with standard semantics and + /// searching with leftmost semantics is that leftmost searching will + /// continue searching even after a match has been found. Once a match + /// is found, the search does not stop until either the haystack has been + /// exhausted or a dead state is observed in the automaton. (Dead states + /// only exist in automatons constructed with leftmost semantics.) That is, + /// we rely on the construction of the automaton to tell us when to quit. + #[inline(never)] + fn leftmost_find_at( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + state_id: &mut Self::ID, + ) -> Option { + if let Some(pre) = self.prefilter() { + self.leftmost_find_at_imp( + prestate, + Some(pre), + haystack, + at, + state_id, + ) + } else { + self.leftmost_find_at_imp(prestate, None, haystack, at, state_id) + } + } + + // It's important for this to always be inlined. Namely, it's only caller + // is leftmost_find_at, and the inlining should remove the case analysis + // for prefilter scanning when there is no prefilter available. + #[inline(always)] + fn leftmost_find_at_imp( + &self, + prestate: &mut PrefilterState, + prefilter: Option<&dyn Prefilter>, + haystack: &[u8], + at: usize, + state_id: &mut Self::ID, + ) -> Option { + debug_assert!(self.match_kind().is_leftmost()); + // This is necessary for guaranteeing a safe API, since we use the + // state ID below in a function that exhibits UB if called with an + // invalid state ID. + assert!( + self.is_valid(*state_id), + "{} is not a valid state ID", + state_id.to_usize() + ); + if self.anchored() && at > 0 && *state_id == self.start_state() { + return None; + } + unsafe { + let start = haystack.as_ptr(); + let end = haystack[haystack.len()..].as_ptr(); + let mut ptr = haystack[at..].as_ptr(); + + let mut last_match = self.get_match(*state_id, 0, at); + while ptr < end { + if let Some(pre) = prefilter { + let at = ptr as usize - start as usize; + if prestate.is_effective(at) + && *state_id == self.start_state() + { + let c = prefilter::next(prestate, pre, haystack, at) + .into_option(); + match c { + None => return None, + Some(i) => { + ptr = start.offset(i as isize); + } + } + } + } + // SAFETY: next_state is safe for all possible u8 values, + // so the only thing we're concerned about is the validity + // of `state_id`. `state_id` either comes from the caller + // (in which case, we assert above that it is valid), or it + // comes from the return value of next_state, which is also + // guaranteed to be valid. + *state_id = self.next_state_unchecked_no_fail(*state_id, *ptr); + ptr = ptr.offset(1); + if self.is_match_or_dead_state(*state_id) { + if *state_id == dead_id() { + // The only way to enter into a dead state is if a + // match has been found, so we assert as much. This + // is different from normal automata, where you might + // enter a dead state if you know a subsequent match + // will never be found (regardless of whether a match + // has already been found). For Aho-Corasick, it is + // built so that we can match at any position, so the + // possibility of a match always exists. + // + // (Unless we have an anchored automaton, in which + // case, dead states are used to stop a search.) + debug_assert!( + last_match.is_some() || self.anchored(), + "failure state should only be seen after match" + ); + return last_match; + } + let end = ptr as usize - start as usize; + last_match = self.get_match(*state_id, 0, end); + } + } + last_match + } + } + + /// This is like leftmost_find_at, but does not need to track a caller + /// provided state id. In other words, the only output of this routine is a + /// match, if one exists. + /// + /// It is regrettable that we need to effectively copy a chunk of + /// implementation twice, but when we don't need to track the state ID, we + /// can allow the prefilter to report matches immediately without having + /// to re-confirm them with the automaton. The re-confirmation step is + /// necessary in leftmost_find_at because tracing through the automaton is + /// the only way to correctly set the state ID. (Perhaps an alternative + /// would be to keep a map from pattern ID to matching state ID, but that + /// complicates the code and still doesn't permit us to defer to the + /// prefilter entirely when possible.) + /// + /// I did try a few things to avoid the code duplication here, but nothing + /// optimized as well as this approach. (In microbenchmarks, there was + /// about a 25% difference.) + #[inline(never)] + fn leftmost_find_at_no_state( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Option { + if let Some(pre) = self.prefilter() { + self.leftmost_find_at_no_state_imp( + prestate, + Some(pre), + haystack, + at, + ) + } else { + self.leftmost_find_at_no_state_imp(prestate, None, haystack, at) + } + } + + // It's important for this to always be inlined. Namely, it's only caller + // is leftmost_find_at_no_state, and the inlining should remove the case + // analysis for prefilter scanning when there is no prefilter available. + #[inline(always)] + fn leftmost_find_at_no_state_imp( + &self, + prestate: &mut PrefilterState, + prefilter: Option<&dyn Prefilter>, + haystack: &[u8], + at: usize, + ) -> Option { + debug_assert!(self.match_kind().is_leftmost()); + if self.anchored() && at > 0 { + return None; + } + // If our prefilter handles confirmation of matches 100% of the + // time, and since we don't need to track state IDs, we can avoid + // Aho-Corasick completely. + if let Some(pre) = prefilter { + // We should never have a prefilter during an anchored search. + debug_assert!(!self.anchored()); + if !pre.reports_false_positives() { + return match pre.next_candidate(prestate, haystack, at) { + Candidate::None => None, + Candidate::Match(m) => Some(m), + Candidate::PossibleStartOfMatch(_) => unreachable!(), + }; + } + } + let mut state_id = self.start_state(); + unsafe { + let start = haystack.as_ptr(); + let end = haystack[haystack.len()..].as_ptr(); + let mut ptr = haystack[at..].as_ptr(); + + let mut last_match = self.get_match(state_id, 0, at); + while ptr < end { + if let Some(pre) = prefilter { + let at = ptr as usize - start as usize; + if prestate.is_effective(at) + && state_id == self.start_state() + { + match prefilter::next(prestate, pre, haystack, at) { + Candidate::None => return None, + // Since we aren't tracking a state ID, we can + // quit early once we know we have a match. + Candidate::Match(m) => return Some(m), + Candidate::PossibleStartOfMatch(i) => { + ptr = start.offset(i as isize); + } + } + } + } + // SAFETY: next_state is safe for all possible u8 values, + // so the only thing we're concerned about is the validity + // of `state_id`. `state_id` either comes from the caller + // (in which case, we assert above that it is valid), or it + // comes from the return value of next_state, which is also + // guaranteed to be valid. + state_id = self.next_state_unchecked_no_fail(state_id, *ptr); + ptr = ptr.offset(1); + if self.is_match_or_dead_state(state_id) { + if state_id == dead_id() { + // The only way to enter into a dead state is if a + // match has been found, so we assert as much. This + // is different from normal automata, where you might + // enter a dead state if you know a subsequent match + // will never be found (regardless of whether a match + // has already been found). For Aho-Corasick, it is + // built so that we can match at any position, so the + // possibility of a match always exists. + // + // (Unless we have an anchored automaton, in which + // case, dead states are used to stop a search.) + debug_assert!( + last_match.is_some() || self.anchored(), + "failure state should only be seen after match" + ); + return last_match; + } + let end = ptr as usize - start as usize; + last_match = self.get_match(state_id, 0, end); + } + } + last_match + } + } + + /// Execute an overlapping search. + /// + /// When executing an overlapping match, the previous state ID in addition + /// to the previous match index should be given. If there are more matches + /// at the given state, then the match is reported and the given index is + /// incremented. + #[inline(always)] + fn overlapping_find_at( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + state_id: &mut Self::ID, + match_index: &mut usize, + ) -> Option { + if self.anchored() && at > 0 && *state_id == self.start_state() { + return None; + } + + let match_count = self.match_count(*state_id); + if *match_index < match_count { + // This is guaranteed to return a match since + // match_index < match_count. + let result = self.get_match(*state_id, *match_index, at); + debug_assert!(result.is_some(), "must be a match"); + *match_index += 1; + return result; + } + + *match_index = 0; + match self.standard_find_at(prestate, haystack, at, state_id) { + None => None, + Some(m) => { + *match_index = 1; + Some(m) + } + } + } + + /// Return the earliest match found. This returns as soon as we know that + /// we have a match. As such, this does not necessarily correspond to the + /// leftmost starting match, but rather, the leftmost position at which a + /// match ends. + #[inline(always)] + fn earliest_find_at( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + state_id: &mut Self::ID, + ) -> Option { + if *state_id == self.start_state() { + if self.anchored() && at > 0 { + return None; + } + if let Some(m) = self.get_match(*state_id, 0, at) { + return Some(m); + } + } + self.standard_find_at(prestate, haystack, at, state_id) + } + + /// A convenience function for finding the next match according to the + /// match semantics of this automaton. For standard match semantics, this + /// finds the earliest match. Otherwise, the leftmost match is found. + #[inline(always)] + fn find_at( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + state_id: &mut Self::ID, + ) -> Option { + match *self.match_kind() { + MatchKind::Standard => { + self.earliest_find_at(prestate, haystack, at, state_id) + } + MatchKind::LeftmostFirst | MatchKind::LeftmostLongest => { + self.leftmost_find_at(prestate, haystack, at, state_id) + } + MatchKind::__Nonexhaustive => unreachable!(), + } + } + + /// Like find_at, but does not track state identifiers. This permits some + /// optimizations when a prefilter that confirms its own matches is + /// present. + #[inline(always)] + fn find_at_no_state( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Option { + match *self.match_kind() { + MatchKind::Standard => { + let mut state = self.start_state(); + self.earliest_find_at(prestate, haystack, at, &mut state) + } + MatchKind::LeftmostFirst | MatchKind::LeftmostLongest => { + self.leftmost_find_at_no_state(prestate, haystack, at) + } + MatchKind::__Nonexhaustive => unreachable!(), + } + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/buffer.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/buffer.rs new file mode 100644 index 0000000..01a8453 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/buffer.rs @@ -0,0 +1,128 @@ +use std::cmp; +use std::io; +use std::ptr; + +/// The default buffer capacity that we use for the stream buffer. +const DEFAULT_BUFFER_CAPACITY: usize = 8 * (1 << 10); // 8 KB + +/// A fairly simple roll buffer for supporting stream searches. +/// +/// This buffer acts as a temporary place to store a fixed amount of data when +/// reading from a stream. Its central purpose is to allow "rolling" some +/// suffix of the data to the beginning of the buffer before refilling it with +/// more data from the stream. For example, let's say we are trying to match +/// "foobar" on a stream. When we report the match, we'd like to not only +/// report the correct offsets at which the match occurs, but also the matching +/// bytes themselves. So let's say our stream is a file with the following +/// contents: `test test foobar test test`. Now assume that we happen to read +/// the aforementioned file in two chunks: `test test foo` and `bar test test`. +/// Naively, it would not be possible to report a single contiguous `foobar` +/// match, but this roll buffer allows us to do that. Namely, after the second +/// read, the contents of the buffer should be `st foobar test test`, where the +/// search should ultimately resume immediately after `foo`. (The prefix `st ` +/// is included because the roll buffer saves N bytes at the end of the buffer, +/// where N is the maximum possible length of a match.) +/// +/// A lot of the logic for dealing with this is unfortunately split out between +/// this roll buffer and the `StreamChunkIter`. +#[derive(Debug)] +pub struct Buffer { + /// The raw buffer contents. This has a fixed size and never increases. + buf: Vec, + /// The minimum size of the buffer, which is equivalent to the maximum + /// possible length of a match. This corresponds to the amount that we + /// roll + min: usize, + /// The end of the contents of this buffer. + end: usize, +} + +impl Buffer { + /// Create a new buffer for stream searching. The minimum buffer length + /// given should be the size of the maximum possible match length. + pub fn new(min_buffer_len: usize) -> Buffer { + let min = cmp::max(1, min_buffer_len); + // The minimum buffer amount is also the amount that we roll our + // buffer in order to support incremental searching. To this end, + // our actual capacity needs to be at least 1 byte bigger than our + // minimum amount, otherwise we won't have any overlap. In actuality, + // we want our buffer to be a bit bigger than that for performance + // reasons, so we set a lower bound of `8 * min`. + // + // TODO: It would be good to find a way to test the streaming + // implementation with the minimal buffer size. + let capacity = cmp::max(min * 8, DEFAULT_BUFFER_CAPACITY); + Buffer { buf: vec![0; capacity], min, end: 0 } + } + + /// Return the contents of this buffer. + #[inline] + pub fn buffer(&self) -> &[u8] { + &self.buf[..self.end] + } + + /// Return the minimum size of the buffer. The only way a buffer may be + /// smaller than this is if the stream itself contains less than the + /// minimum buffer amount. + #[inline] + pub fn min_buffer_len(&self) -> usize { + self.min + } + + /// Return the total length of the contents in the buffer. + #[inline] + pub fn len(&self) -> usize { + self.end + } + + /// Return all free capacity in this buffer. + fn free_buffer(&mut self) -> &mut [u8] { + &mut self.buf[self.end..] + } + + /// Refill the contents of this buffer by reading as much as possible into + /// this buffer's free capacity. If no more bytes could be read, then this + /// returns false. Otherwise, this reads until it has filled the buffer + /// past the minimum amount. + pub fn fill(&mut self, mut rdr: R) -> io::Result { + let mut readany = false; + loop { + let readlen = rdr.read(self.free_buffer())?; + if readlen == 0 { + return Ok(readany); + } + readany = true; + self.end += readlen; + if self.len() >= self.min { + return Ok(true); + } + } + } + + /// Roll the contents of the buffer so that the suffix of this buffer is + /// moved to the front and all other contents are dropped. The size of the + /// suffix corresponds precisely to the minimum buffer length. + /// + /// This should only be called when the entire contents of this buffer have + /// been searched. + pub fn roll(&mut self) { + let roll_start = self + .end + .checked_sub(self.min) + .expect("buffer capacity should be bigger than minimum amount"); + let roll_len = self.min; + + assert!(roll_start + roll_len <= self.end); + unsafe { + // SAFETY: A buffer contains Copy data, so there's no problem + // moving it around. Safety also depends on our indices being in + // bounds, which they always should be, given the assert above. + ptr::copy( + self.buf[roll_start..].as_ptr(), + self.buf.as_mut_ptr(), + roll_len, + ); + } + self.end = roll_len; + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/byte_frequencies.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/byte_frequencies.rs new file mode 100644 index 0000000..c313b62 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/byte_frequencies.rs @@ -0,0 +1,258 @@ +pub const BYTE_FREQUENCIES: [u8; 256] = [ + 55, // '\x00' + 52, // '\x01' + 51, // '\x02' + 50, // '\x03' + 49, // '\x04' + 48, // '\x05' + 47, // '\x06' + 46, // '\x07' + 45, // '\x08' + 103, // '\t' + 242, // '\n' + 66, // '\x0b' + 67, // '\x0c' + 229, // '\r' + 44, // '\x0e' + 43, // '\x0f' + 42, // '\x10' + 41, // '\x11' + 40, // '\x12' + 39, // '\x13' + 38, // '\x14' + 37, // '\x15' + 36, // '\x16' + 35, // '\x17' + 34, // '\x18' + 33, // '\x19' + 56, // '\x1a' + 32, // '\x1b' + 31, // '\x1c' + 30, // '\x1d' + 29, // '\x1e' + 28, // '\x1f' + 255, // ' ' + 148, // '!' + 164, // '"' + 149, // '#' + 136, // '$' + 160, // '%' + 155, // '&' + 173, // "'" + 221, // '(' + 222, // ')' + 134, // '*' + 122, // '+' + 232, // ',' + 202, // '-' + 215, // '.' + 224, // '/' + 208, // '0' + 220, // '1' + 204, // '2' + 187, // '3' + 183, // '4' + 179, // '5' + 177, // '6' + 168, // '7' + 178, // '8' + 200, // '9' + 226, // ':' + 195, // ';' + 154, // '<' + 184, // '=' + 174, // '>' + 126, // '?' + 120, // '@' + 191, // 'A' + 157, // 'B' + 194, // 'C' + 170, // 'D' + 189, // 'E' + 162, // 'F' + 161, // 'G' + 150, // 'H' + 193, // 'I' + 142, // 'J' + 137, // 'K' + 171, // 'L' + 176, // 'M' + 185, // 'N' + 167, // 'O' + 186, // 'P' + 112, // 'Q' + 175, // 'R' + 192, // 'S' + 188, // 'T' + 156, // 'U' + 140, // 'V' + 143, // 'W' + 123, // 'X' + 133, // 'Y' + 128, // 'Z' + 147, // '[' + 138, // '\\' + 146, // ']' + 114, // '^' + 223, // '_' + 151, // '`' + 249, // 'a' + 216, // 'b' + 238, // 'c' + 236, // 'd' + 253, // 'e' + 227, // 'f' + 218, // 'g' + 230, // 'h' + 247, // 'i' + 135, // 'j' + 180, // 'k' + 241, // 'l' + 233, // 'm' + 246, // 'n' + 244, // 'o' + 231, // 'p' + 139, // 'q' + 245, // 'r' + 243, // 's' + 251, // 't' + 235, // 'u' + 201, // 'v' + 196, // 'w' + 240, // 'x' + 214, // 'y' + 152, // 'z' + 182, // '{' + 205, // '|' + 181, // '}' + 127, // '~' + 27, // '\x7f' + 212, // '\x80' + 211, // '\x81' + 210, // '\x82' + 213, // '\x83' + 228, // '\x84' + 197, // '\x85' + 169, // '\x86' + 159, // '\x87' + 131, // '\x88' + 172, // '\x89' + 105, // '\x8a' + 80, // '\x8b' + 98, // '\x8c' + 96, // '\x8d' + 97, // '\x8e' + 81, // '\x8f' + 207, // '\x90' + 145, // '\x91' + 116, // '\x92' + 115, // '\x93' + 144, // '\x94' + 130, // '\x95' + 153, // '\x96' + 121, // '\x97' + 107, // '\x98' + 132, // '\x99' + 109, // '\x9a' + 110, // '\x9b' + 124, // '\x9c' + 111, // '\x9d' + 82, // '\x9e' + 108, // '\x9f' + 118, // '\xa0' + 141, // '¡' + 113, // '¢' + 129, // '£' + 119, // '¤' + 125, // '¥' + 165, // '¦' + 117, // '§' + 92, // '¨' + 106, // '©' + 83, // 'ª' + 72, // '«' + 99, // '¬' + 93, // '\xad' + 65, // '®' + 79, // '¯' + 166, // '°' + 237, // '±' + 163, // '²' + 199, // '³' + 190, // '´' + 225, // 'µ' + 209, // '¶' + 203, // '·' + 198, // '¸' + 217, // '¹' + 219, // 'º' + 206, // '»' + 234, // '¼' + 248, // '½' + 158, // '¾' + 239, // '¿' + 255, // 'À' + 255, // 'Á' + 255, // 'Â' + 255, // 'Ã' + 255, // 'Ä' + 255, // 'Å' + 255, // 'Æ' + 255, // 'Ç' + 255, // 'È' + 255, // 'É' + 255, // 'Ê' + 255, // 'Ë' + 255, // 'Ì' + 255, // 'Í' + 255, // 'Î' + 255, // 'Ï' + 255, // 'Ð' + 255, // 'Ñ' + 255, // 'Ò' + 255, // 'Ó' + 255, // 'Ô' + 255, // 'Õ' + 255, // 'Ö' + 255, // '×' + 255, // 'Ø' + 255, // 'Ù' + 255, // 'Ú' + 255, // 'Û' + 255, // 'Ü' + 255, // 'Ý' + 255, // 'Þ' + 255, // 'ß' + 255, // 'à' + 255, // 'á' + 255, // 'â' + 255, // 'ã' + 255, // 'ä' + 255, // 'å' + 255, // 'æ' + 255, // 'ç' + 255, // 'è' + 255, // 'é' + 255, // 'ê' + 255, // 'ë' + 255, // 'ì' + 255, // 'í' + 255, // 'î' + 255, // 'ï' + 255, // 'ð' + 255, // 'ñ' + 255, // 'ò' + 255, // 'ó' + 255, // 'ô' + 255, // 'õ' + 255, // 'ö' + 255, // '÷' + 255, // 'ø' + 255, // 'ù' + 255, // 'ú' + 255, // 'û' + 255, // 'ü' + 255, // 'ý' + 255, // 'þ' + 255, // 'ÿ' +]; diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/classes.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/classes.rs new file mode 100644 index 0000000..fe20668 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/classes.rs @@ -0,0 +1,238 @@ +use std::fmt; + +/// A representation of byte oriented equivalence classes. +/// +/// This is used in an FSM to reduce the size of the transition table. This can +/// have a particularly large impact not only on the total size of an FSM, but +/// also on compile times. +#[derive(Clone, Copy)] +pub struct ByteClasses([u8; 256]); + +impl ByteClasses { + /// Creates a new set of equivalence classes where all bytes are mapped to + /// the same class. + pub fn empty() -> ByteClasses { + ByteClasses([0; 256]) + } + + /// Creates a new set of equivalence classes where each byte belongs to + /// its own equivalence class. + pub fn singletons() -> ByteClasses { + let mut classes = ByteClasses::empty(); + for i in 0..256 { + classes.set(i as u8, i as u8); + } + classes + } + + /// Set the equivalence class for the given byte. + #[inline] + pub fn set(&mut self, byte: u8, class: u8) { + self.0[byte as usize] = class; + } + + /// Get the equivalence class for the given byte. + #[inline] + pub fn get(&self, byte: u8) -> u8 { + // SAFETY: This is safe because all dense transitions have + // exactly 256 elements, so all u8 values are valid indices. + unsafe { *self.0.get_unchecked(byte as usize) } + } + + /// Return the total number of elements in the alphabet represented by + /// these equivalence classes. Equivalently, this returns the total number + /// of equivalence classes. + #[inline] + pub fn alphabet_len(&self) -> usize { + self.0[255] as usize + 1 + } + + /// Returns true if and only if every byte in this class maps to its own + /// equivalence class. Equivalently, there are 256 equivalence classes + /// and each class contains exactly one byte. + #[inline] + pub fn is_singleton(&self) -> bool { + self.alphabet_len() == 256 + } + + /// Returns an iterator over a sequence of representative bytes from each + /// equivalence class. Namely, this yields exactly N items, where N is + /// equivalent to the number of equivalence classes. Each item is an + /// arbitrary byte drawn from each equivalence class. + /// + /// This is useful when one is determinizing an NFA and the NFA's alphabet + /// hasn't been converted to equivalence classes yet. Picking an arbitrary + /// byte from each equivalence class then permits a full exploration of + /// the NFA instead of using every possible byte value. + pub fn representatives(&self) -> ByteClassRepresentatives { + ByteClassRepresentatives { classes: self, byte: 0, last_class: None } + } + + /// Returns all of the bytes in the given equivalence class. + /// + /// The second element in the tuple indicates the number of elements in + /// the array. + fn elements(&self, equiv: u8) -> ([u8; 256], usize) { + let (mut array, mut len) = ([0; 256], 0); + for b in 0..256 { + if self.get(b as u8) == equiv { + array[len] = b as u8; + len += 1; + } + } + (array, len) + } +} + +impl fmt::Debug for ByteClasses { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.is_singleton() { + write!(f, "ByteClasses({{singletons}})") + } else { + write!(f, "ByteClasses(")?; + for equiv in 0..self.alphabet_len() { + let (members, len) = self.elements(equiv as u8); + write!(f, " {} => {:?}", equiv, &members[..len])?; + } + write!(f, ")") + } + } +} + +/// An iterator over representative bytes from each equivalence class. +#[derive(Debug)] +pub struct ByteClassRepresentatives<'a> { + classes: &'a ByteClasses, + byte: usize, + last_class: Option, +} + +impl<'a> Iterator for ByteClassRepresentatives<'a> { + type Item = u8; + + fn next(&mut self) -> Option { + while self.byte < 256 { + let byte = self.byte as u8; + let class = self.classes.get(byte); + self.byte += 1; + + if self.last_class != Some(class) { + self.last_class = Some(class); + return Some(byte); + } + } + None + } +} + +/// A byte class builder keeps track of an *approximation* of equivalence +/// classes of bytes during NFA construction. That is, every byte in an +/// equivalence class cannot discriminate between a match and a non-match. +/// +/// For example, in the literals `abc` and `xyz`, the bytes [\x00-`], [d-w] +/// and [{-\xFF] never discriminate between a match and a non-match, precisely +/// because they never occur in the literals anywhere. +/// +/// Note though that this does not necessarily compute the minimal set of +/// equivalence classes. For example, in the literals above, the byte ranges +/// [\x00-`], [d-w] and [{-\xFF] are all treated as distinct equivalence +/// classes even though they could be treated a single class. The reason for +/// this is implementation complexity. In the future, we should endeavor to +/// compute the minimal equivalence classes since they can have a rather large +/// impact on the size of the DFA. +/// +/// The representation here is 256 booleans, all initially set to false. Each +/// boolean maps to its corresponding byte based on position. A `true` value +/// indicates the end of an equivalence class, where its corresponding byte +/// and all of the bytes corresponding to all previous contiguous `false` +/// values are in the same equivalence class. +/// +/// This particular representation only permits contiguous ranges of bytes to +/// be in the same equivalence class, which means that we can never discover +/// the true minimal set of equivalence classes. +#[derive(Debug)] +pub struct ByteClassBuilder(Vec); + +impl ByteClassBuilder { + /// Create a new builder of byte classes where all bytes are part of the + /// same equivalence class. + pub fn new() -> ByteClassBuilder { + ByteClassBuilder(vec![false; 256]) + } + + /// Indicate the the range of byte given (inclusive) can discriminate a + /// match between it and all other bytes outside of the range. + pub fn set_range(&mut self, start: u8, end: u8) { + debug_assert!(start <= end); + if start > 0 { + self.0[start as usize - 1] = true; + } + self.0[end as usize] = true; + } + + /// Build byte classes that map all byte values to their corresponding + /// equivalence class. The last mapping indicates the largest equivalence + /// class identifier (which is never bigger than 255). + pub fn build(&self) -> ByteClasses { + let mut classes = ByteClasses::empty(); + let mut class = 0u8; + let mut i = 0; + loop { + classes.set(i as u8, class as u8); + if i >= 255 { + break; + } + if self.0[i] { + class = class.checked_add(1).unwrap(); + } + i += 1; + } + classes + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn byte_classes() { + let mut set = ByteClassBuilder::new(); + set.set_range(b'a', b'z'); + + let classes = set.build(); + assert_eq!(classes.get(0), 0); + assert_eq!(classes.get(1), 0); + assert_eq!(classes.get(2), 0); + assert_eq!(classes.get(b'a' - 1), 0); + assert_eq!(classes.get(b'a'), 1); + assert_eq!(classes.get(b'm'), 1); + assert_eq!(classes.get(b'z'), 1); + assert_eq!(classes.get(b'z' + 1), 2); + assert_eq!(classes.get(254), 2); + assert_eq!(classes.get(255), 2); + + let mut set = ByteClassBuilder::new(); + set.set_range(0, 2); + set.set_range(4, 6); + let classes = set.build(); + assert_eq!(classes.get(0), 0); + assert_eq!(classes.get(1), 0); + assert_eq!(classes.get(2), 0); + assert_eq!(classes.get(3), 1); + assert_eq!(classes.get(4), 2); + assert_eq!(classes.get(5), 2); + assert_eq!(classes.get(6), 2); + assert_eq!(classes.get(7), 3); + assert_eq!(classes.get(255), 3); + } + + #[test] + fn full_byte_classes() { + let mut set = ByteClassBuilder::new(); + for i in 0..256u16 { + set.set_range(i as u8, i as u8); + } + assert_eq!(set.build().alphabet_len(), 256); + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/dfa.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/dfa.rs new file mode 100644 index 0000000..6eee336 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/dfa.rs @@ -0,0 +1,709 @@ +use std::mem::size_of; + +use ahocorasick::MatchKind; +use automaton::Automaton; +use classes::ByteClasses; +use error::Result; +use nfa::{PatternID, PatternLength, NFA}; +use prefilter::{Prefilter, PrefilterObj, PrefilterState}; +use state_id::{dead_id, fail_id, premultiply_overflow_error, StateID}; +use Match; + +#[derive(Clone, Debug)] +pub enum DFA { + Standard(Standard), + ByteClass(ByteClass), + Premultiplied(Premultiplied), + PremultipliedByteClass(PremultipliedByteClass), +} + +impl DFA { + fn repr(&self) -> &Repr { + match *self { + DFA::Standard(ref dfa) => dfa.repr(), + DFA::ByteClass(ref dfa) => dfa.repr(), + DFA::Premultiplied(ref dfa) => dfa.repr(), + DFA::PremultipliedByteClass(ref dfa) => dfa.repr(), + } + } + + pub fn match_kind(&self) -> &MatchKind { + &self.repr().match_kind + } + + pub fn heap_bytes(&self) -> usize { + self.repr().heap_bytes + } + + pub fn max_pattern_len(&self) -> usize { + self.repr().max_pattern_len + } + + pub fn pattern_count(&self) -> usize { + self.repr().pattern_count + } + + pub fn start_state(&self) -> S { + self.repr().start_id + } + + #[inline(always)] + pub fn overlapping_find_at( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + state_id: &mut S, + match_index: &mut usize, + ) -> Option { + match *self { + DFA::Standard(ref dfa) => dfa.overlapping_find_at( + prestate, + haystack, + at, + state_id, + match_index, + ), + DFA::ByteClass(ref dfa) => dfa.overlapping_find_at( + prestate, + haystack, + at, + state_id, + match_index, + ), + DFA::Premultiplied(ref dfa) => dfa.overlapping_find_at( + prestate, + haystack, + at, + state_id, + match_index, + ), + DFA::PremultipliedByteClass(ref dfa) => dfa.overlapping_find_at( + prestate, + haystack, + at, + state_id, + match_index, + ), + } + } + + #[inline(always)] + pub fn earliest_find_at( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + state_id: &mut S, + ) -> Option { + match *self { + DFA::Standard(ref dfa) => { + dfa.earliest_find_at(prestate, haystack, at, state_id) + } + DFA::ByteClass(ref dfa) => { + dfa.earliest_find_at(prestate, haystack, at, state_id) + } + DFA::Premultiplied(ref dfa) => { + dfa.earliest_find_at(prestate, haystack, at, state_id) + } + DFA::PremultipliedByteClass(ref dfa) => { + dfa.earliest_find_at(prestate, haystack, at, state_id) + } + } + } + + #[inline(always)] + pub fn find_at_no_state( + &self, + prestate: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Option { + match *self { + DFA::Standard(ref dfa) => { + dfa.find_at_no_state(prestate, haystack, at) + } + DFA::ByteClass(ref dfa) => { + dfa.find_at_no_state(prestate, haystack, at) + } + DFA::Premultiplied(ref dfa) => { + dfa.find_at_no_state(prestate, haystack, at) + } + DFA::PremultipliedByteClass(ref dfa) => { + dfa.find_at_no_state(prestate, haystack, at) + } + } + } +} + +#[derive(Clone, Debug)] +pub struct Standard(Repr); + +impl Standard { + fn repr(&self) -> &Repr { + &self.0 + } +} + +impl Automaton for Standard { + type ID = S; + + fn match_kind(&self) -> &MatchKind { + &self.repr().match_kind + } + + fn anchored(&self) -> bool { + self.repr().anchored + } + + fn prefilter(&self) -> Option<&dyn Prefilter> { + self.repr().prefilter.as_ref().map(|p| p.as_ref()) + } + + fn start_state(&self) -> S { + self.repr().start_id + } + + fn is_valid(&self, id: S) -> bool { + id.to_usize() < self.repr().state_count + } + + fn is_match_state(&self, id: S) -> bool { + self.repr().is_match_state(id) + } + + fn is_match_or_dead_state(&self, id: S) -> bool { + self.repr().is_match_or_dead_state(id) + } + + fn get_match( + &self, + id: S, + match_index: usize, + end: usize, + ) -> Option { + self.repr().get_match(id, match_index, end) + } + + fn match_count(&self, id: S) -> usize { + self.repr().match_count(id) + } + + unsafe fn next_state_unchecked(&self, current: S, input: u8) -> S { + let o = current.to_usize() * 256 + input as usize; + *self.repr().trans.get_unchecked(o) + } +} + +#[derive(Clone, Debug)] +pub struct ByteClass(Repr); + +impl ByteClass { + fn repr(&self) -> &Repr { + &self.0 + } +} + +impl Automaton for ByteClass { + type ID = S; + + fn match_kind(&self) -> &MatchKind { + &self.repr().match_kind + } + + fn anchored(&self) -> bool { + self.repr().anchored + } + + fn prefilter(&self) -> Option<&dyn Prefilter> { + self.repr().prefilter.as_ref().map(|p| p.as_ref()) + } + + fn start_state(&self) -> S { + self.repr().start_id + } + + fn is_valid(&self, id: S) -> bool { + id.to_usize() < self.repr().state_count + } + + fn is_match_state(&self, id: S) -> bool { + self.repr().is_match_state(id) + } + + fn is_match_or_dead_state(&self, id: S) -> bool { + self.repr().is_match_or_dead_state(id) + } + + fn get_match( + &self, + id: S, + match_index: usize, + end: usize, + ) -> Option { + self.repr().get_match(id, match_index, end) + } + + fn match_count(&self, id: S) -> usize { + self.repr().match_count(id) + } + + unsafe fn next_state_unchecked(&self, current: S, input: u8) -> S { + let alphabet_len = self.repr().byte_classes.alphabet_len(); + let input = self.repr().byte_classes.get(input); + let o = current.to_usize() * alphabet_len + input as usize; + *self.repr().trans.get_unchecked(o) + } +} + +#[derive(Clone, Debug)] +pub struct Premultiplied(Repr); + +impl Premultiplied { + fn repr(&self) -> &Repr { + &self.0 + } +} + +impl Automaton for Premultiplied { + type ID = S; + + fn match_kind(&self) -> &MatchKind { + &self.repr().match_kind + } + + fn anchored(&self) -> bool { + self.repr().anchored + } + + fn prefilter(&self) -> Option<&dyn Prefilter> { + self.repr().prefilter.as_ref().map(|p| p.as_ref()) + } + + fn start_state(&self) -> S { + self.repr().start_id + } + + fn is_valid(&self, id: S) -> bool { + (id.to_usize() / 256) < self.repr().state_count + } + + fn is_match_state(&self, id: S) -> bool { + self.repr().is_match_state(id) + } + + fn is_match_or_dead_state(&self, id: S) -> bool { + self.repr().is_match_or_dead_state(id) + } + + fn get_match( + &self, + id: S, + match_index: usize, + end: usize, + ) -> Option { + if id > self.repr().max_match { + return None; + } + self.repr() + .matches + .get(id.to_usize() / 256) + .and_then(|m| m.get(match_index)) + .map(|&(id, len)| Match { pattern: id, len, end }) + } + + fn match_count(&self, id: S) -> usize { + let o = id.to_usize() / 256; + self.repr().matches[o].len() + } + + unsafe fn next_state_unchecked(&self, current: S, input: u8) -> S { + let o = current.to_usize() + input as usize; + *self.repr().trans.get_unchecked(o) + } +} + +#[derive(Clone, Debug)] +pub struct PremultipliedByteClass(Repr); + +impl PremultipliedByteClass { + fn repr(&self) -> &Repr { + &self.0 + } +} + +impl Automaton for PremultipliedByteClass { + type ID = S; + + fn match_kind(&self) -> &MatchKind { + &self.repr().match_kind + } + + fn anchored(&self) -> bool { + self.repr().anchored + } + + fn prefilter(&self) -> Option<&dyn Prefilter> { + self.repr().prefilter.as_ref().map(|p| p.as_ref()) + } + + fn start_state(&self) -> S { + self.repr().start_id + } + + fn is_valid(&self, id: S) -> bool { + (id.to_usize() / self.repr().alphabet_len()) < self.repr().state_count + } + + fn is_match_state(&self, id: S) -> bool { + self.repr().is_match_state(id) + } + + fn is_match_or_dead_state(&self, id: S) -> bool { + self.repr().is_match_or_dead_state(id) + } + + fn get_match( + &self, + id: S, + match_index: usize, + end: usize, + ) -> Option { + if id > self.repr().max_match { + return None; + } + self.repr() + .matches + .get(id.to_usize() / self.repr().alphabet_len()) + .and_then(|m| m.get(match_index)) + .map(|&(id, len)| Match { pattern: id, len, end }) + } + + fn match_count(&self, id: S) -> usize { + let o = id.to_usize() / self.repr().alphabet_len(); + self.repr().matches[o].len() + } + + unsafe fn next_state_unchecked(&self, current: S, input: u8) -> S { + let input = self.repr().byte_classes.get(input); + let o = current.to_usize() + input as usize; + *self.repr().trans.get_unchecked(o) + } +} + +#[derive(Clone, Debug)] +pub struct Repr { + match_kind: MatchKind, + anchored: bool, + premultiplied: bool, + start_id: S, + /// The length, in bytes, of the longest pattern in this automaton. This + /// information is useful for keeping correct buffer sizes when searching + /// on streams. + max_pattern_len: usize, + /// The total number of patterns added to this automaton. This includes + /// patterns that may never match. + pattern_count: usize, + state_count: usize, + max_match: S, + /// The number of bytes of heap used by this NFA's transition table. + heap_bytes: usize, + /// A prefilter for quickly detecting candidate matchs, if pertinent. + prefilter: Option, + byte_classes: ByteClasses, + trans: Vec, + matches: Vec>, +} + +impl Repr { + /// Returns the total alphabet size for this DFA. + /// + /// If byte classes are enabled, then this corresponds to the number of + /// equivalence classes. If they are disabled, then this is always 256. + fn alphabet_len(&self) -> usize { + self.byte_classes.alphabet_len() + } + + /// Returns true only if the given state is a match state. + fn is_match_state(&self, id: S) -> bool { + id <= self.max_match && id > dead_id() + } + + /// Returns true only if the given state is either a dead state or a match + /// state. + fn is_match_or_dead_state(&self, id: S) -> bool { + id <= self.max_match + } + + /// Get the ith match for the given state, where the end position of a + /// match was found at `end`. + /// + /// # Panics + /// + /// The caller must ensure that the given state identifier is valid, + /// otherwise this may panic. The `match_index` need not be valid. That is, + /// if the given state has no matches then this returns `None`. + fn get_match( + &self, + id: S, + match_index: usize, + end: usize, + ) -> Option { + if id > self.max_match { + return None; + } + self.matches + .get(id.to_usize()) + .and_then(|m| m.get(match_index)) + .map(|&(id, len)| Match { pattern: id, len, end }) + } + + /// Return the total number of matches for the given state. + /// + /// # Panics + /// + /// The caller must ensure that the given identifier is valid, or else + /// this panics. + fn match_count(&self, id: S) -> usize { + self.matches[id.to_usize()].len() + } + + /// Get the next state given `from` as the current state and `byte` as the + /// current input byte. + fn next_state(&self, from: S, byte: u8) -> S { + let alphabet_len = self.alphabet_len(); + let byte = self.byte_classes.get(byte); + self.trans[from.to_usize() * alphabet_len + byte as usize] + } + + /// Set the `byte` transition for the `from` state to point to `to`. + fn set_next_state(&mut self, from: S, byte: u8, to: S) { + let alphabet_len = self.alphabet_len(); + let byte = self.byte_classes.get(byte); + self.trans[from.to_usize() * alphabet_len + byte as usize] = to; + } + + /// Swap the given states in place. + fn swap_states(&mut self, id1: S, id2: S) { + assert!(!self.premultiplied, "can't swap states in premultiplied DFA"); + + let o1 = id1.to_usize() * self.alphabet_len(); + let o2 = id2.to_usize() * self.alphabet_len(); + for b in 0..self.alphabet_len() { + self.trans.swap(o1 + b, o2 + b); + } + self.matches.swap(id1.to_usize(), id2.to_usize()); + } + + /// This routine shuffles all match states in this DFA to the beginning + /// of the DFA such that every non-match state appears after every match + /// state. (With one exception: the special fail and dead states remain as + /// the first two states.) + /// + /// The purpose of doing this shuffling is to avoid an extra conditional + /// in the search loop, and in particular, detecting whether a state is a + /// match or not does not need to access any memory. + /// + /// This updates `self.max_match` to point to the last matching state as + /// well as `self.start` if the starting state was moved. + fn shuffle_match_states(&mut self) { + assert!( + !self.premultiplied, + "cannot shuffle match states of premultiplied DFA" + ); + + if self.state_count <= 1 { + return; + } + + let mut first_non_match = self.start_id.to_usize(); + while first_non_match < self.state_count + && self.matches[first_non_match].len() > 0 + { + first_non_match += 1; + } + + let mut swaps: Vec = vec![fail_id(); self.state_count]; + let mut cur = self.state_count - 1; + while cur > first_non_match { + if self.matches[cur].len() > 0 { + self.swap_states( + S::from_usize(cur), + S::from_usize(first_non_match), + ); + swaps[cur] = S::from_usize(first_non_match); + swaps[first_non_match] = S::from_usize(cur); + + first_non_match += 1; + while first_non_match < cur + && self.matches[first_non_match].len() > 0 + { + first_non_match += 1; + } + } + cur -= 1; + } + for id in (0..self.state_count).map(S::from_usize) { + let alphabet_len = self.alphabet_len(); + let offset = id.to_usize() * alphabet_len; + for next in &mut self.trans[offset..offset + alphabet_len] { + if swaps[next.to_usize()] != fail_id() { + *next = swaps[next.to_usize()]; + } + } + } + if swaps[self.start_id.to_usize()] != fail_id() { + self.start_id = swaps[self.start_id.to_usize()]; + } + self.max_match = S::from_usize(first_non_match - 1); + } + + fn premultiply(&mut self) -> Result<()> { + if self.premultiplied || self.state_count <= 1 { + return Ok(()); + } + + let alpha_len = self.alphabet_len(); + premultiply_overflow_error( + S::from_usize(self.state_count - 1), + alpha_len, + )?; + + for id in (2..self.state_count).map(S::from_usize) { + let offset = id.to_usize() * alpha_len; + for next in &mut self.trans[offset..offset + alpha_len] { + if *next == dead_id() { + continue; + } + *next = S::from_usize(next.to_usize() * alpha_len); + } + } + self.premultiplied = true; + self.start_id = S::from_usize(self.start_id.to_usize() * alpha_len); + self.max_match = S::from_usize(self.max_match.to_usize() * alpha_len); + Ok(()) + } + + /// Computes the total amount of heap used by this NFA in bytes. + fn calculate_size(&mut self) { + let mut size = (self.trans.len() * size_of::()) + + (self.matches.len() + * size_of::>()); + for state_matches in &self.matches { + size += + state_matches.len() * size_of::<(PatternID, PatternLength)>(); + } + size += self.prefilter.as_ref().map_or(0, |p| p.as_ref().heap_bytes()); + self.heap_bytes = size; + } +} + +/// A builder for configuring the determinization of an NFA into a DFA. +#[derive(Clone, Debug)] +pub struct Builder { + premultiply: bool, + byte_classes: bool, +} + +impl Builder { + /// Create a new builder for a DFA. + pub fn new() -> Builder { + Builder { premultiply: true, byte_classes: true } + } + + /// Build a DFA from the given NFA. + /// + /// This returns an error if the state identifiers exceed their + /// representation size. This can only happen when state ids are + /// premultiplied (which is enabled by default). + pub fn build(&self, nfa: &NFA) -> Result> { + let byte_classes = if self.byte_classes { + nfa.byte_classes().clone() + } else { + ByteClasses::singletons() + }; + let alphabet_len = byte_classes.alphabet_len(); + let trans = vec![fail_id(); alphabet_len * nfa.state_len()]; + let matches = vec![vec![]; nfa.state_len()]; + let mut repr = Repr { + match_kind: nfa.match_kind().clone(), + anchored: nfa.anchored(), + premultiplied: false, + start_id: nfa.start_state(), + max_pattern_len: nfa.max_pattern_len(), + pattern_count: nfa.pattern_count(), + state_count: nfa.state_len(), + max_match: fail_id(), + heap_bytes: 0, + prefilter: nfa.prefilter_obj().map(|p| p.clone()), + byte_classes: byte_classes.clone(), + trans: trans, + matches: matches, + }; + for id in (0..nfa.state_len()).map(S::from_usize) { + repr.matches[id.to_usize()].extend_from_slice(nfa.matches(id)); + + let fail = nfa.failure_transition(id); + nfa.iter_all_transitions(&byte_classes, id, |b, mut next| { + if next == fail_id() { + next = nfa_next_state_memoized(nfa, &repr, id, fail, b); + } + repr.set_next_state(id, b, next); + }); + } + repr.shuffle_match_states(); + repr.calculate_size(); + if self.premultiply { + repr.premultiply()?; + if byte_classes.is_singleton() { + Ok(DFA::Premultiplied(Premultiplied(repr))) + } else { + Ok(DFA::PremultipliedByteClass(PremultipliedByteClass(repr))) + } + } else { + if byte_classes.is_singleton() { + Ok(DFA::Standard(Standard(repr))) + } else { + Ok(DFA::ByteClass(ByteClass(repr))) + } + } + } + + /// Whether to use byte classes or in the DFA. + pub fn byte_classes(&mut self, yes: bool) -> &mut Builder { + self.byte_classes = yes; + self + } + + /// Whether to premultiply state identifier in the DFA. + pub fn premultiply(&mut self, yes: bool) -> &mut Builder { + self.premultiply = yes; + self + } +} + +/// This returns the next NFA transition (including resolving failure +/// transitions), except once it sees a state id less than the id of the DFA +/// state that is currently being populated, then we no longer need to follow +/// failure transitions and can instead query the pre-computed state id from +/// the DFA itself. +/// +/// In general, this should only be called when a failure transition is seen. +fn nfa_next_state_memoized( + nfa: &NFA, + dfa: &Repr, + populating: S, + mut current: S, + input: u8, +) -> S { + loop { + if current < populating { + return dfa.next_state(current, input); + } + let next = nfa.next_state(current, input); + if next != fail_id() { + return next; + } + current = nfa.failure_transition(current); + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/error.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/error.rs new file mode 100644 index 0000000..7dace63 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/error.rs @@ -0,0 +1,101 @@ +use std::error; +use std::fmt; +use std::result; + +pub type Result = result::Result; + +/// An error that occurred during the construction of an Aho-Corasick +/// automaton. +#[derive(Clone, Debug)] +pub struct Error { + kind: ErrorKind, +} + +/// The kind of error that occurred. +#[derive(Clone, Debug)] +pub enum ErrorKind { + /// An error that occurs when constructing an automaton would require the + /// use of a state ID that overflows the chosen state ID representation. + /// For example, if one is using `u8` for state IDs and builds a DFA with + /// 257 states, then the last state's ID will be `256` which cannot be + /// represented with `u8`. + StateIDOverflow { + /// The maximum possible state ID. + max: usize, + }, + /// An error that occurs when premultiplication of state IDs is requested + /// when constructing an Aho-Corasick DFA, but doing so would overflow the + /// chosen state ID representation. + /// + /// When `max == requested_max`, then the state ID would overflow `usize`. + PremultiplyOverflow { + /// The maximum possible state id. + max: usize, + /// The maximum ID required by premultiplication. + requested_max: usize, + }, +} + +impl Error { + /// Return the kind of this error. + pub fn kind(&self) -> &ErrorKind { + &self.kind + } + + pub(crate) fn state_id_overflow(max: usize) -> Error { + Error { kind: ErrorKind::StateIDOverflow { max } } + } + + pub(crate) fn premultiply_overflow( + max: usize, + requested_max: usize, + ) -> Error { + Error { kind: ErrorKind::PremultiplyOverflow { max, requested_max } } + } +} + +impl error::Error for Error { + fn description(&self) -> &str { + match self.kind { + ErrorKind::StateIDOverflow { .. } => { + "state id representation too small" + } + ErrorKind::PremultiplyOverflow { .. } => { + "state id representation too small for premultiplication" + } + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.kind { + ErrorKind::StateIDOverflow { max } => write!( + f, + "building the automaton failed because it required \ + building more states that can be identified, where the \ + maximum ID for the chosen representation is {}", + max, + ), + ErrorKind::PremultiplyOverflow { max, requested_max } => { + if max == requested_max { + write!( + f, + "premultiplication of states requires the ability to \ + represent a state ID greater than what can fit on \ + this platform's usize, which is {}", + ::std::usize::MAX, + ) + } else { + write!( + f, + "premultiplication of states requires the ability to \ + represent at least a state ID of {}, but the chosen \ + representation only permits a maximum state ID of {}", + requested_max, max, + ) + } + } + } + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/lib.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/lib.rs new file mode 100644 index 0000000..cbaf945 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/lib.rs @@ -0,0 +1,297 @@ +/*! +A library for finding occurrences of many patterns at once. This library +provides multiple pattern search principally through an implementation of the +[Aho-Corasick algorithm](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm), +which builds a fast finite state machine for executing searches in linear time. + +Additionally, this library provides a number of configuration options for +building the automaton that permit controlling the space versus time trade +off. Other features include simple ASCII case insensitive matching, finding +overlapping matches, replacements, searching streams and even searching and +replacing text in streams. + +Finally, unlike all other (known) Aho-Corasick implementations, this one +supports enabling +[leftmost-first](enum.MatchKind.html#variant.LeftmostFirst) +or +[leftmost-longest](enum.MatchKind.html#variant.LeftmostFirst) +match semantics, using a (seemingly) novel alternative construction algorithm. +For more details on what match semantics means, see the +[`MatchKind`](enum.MatchKind.html) +type. + +# Overview + +This section gives a brief overview of the primary types in this crate: + +* [`AhoCorasick`](struct.AhoCorasick.html) is the primary type and represents + an Aho-Corasick automaton. This is the type you use to execute searches. +* [`AhoCorasickBuilder`](struct.AhoCorasickBuilder.html) can be used to build + an Aho-Corasick automaton, and supports configuring a number of options. +* [`Match`](struct.Match.html) represents a single match reported by an + Aho-Corasick automaton. Each match has two pieces of information: the pattern + that matched and the start and end byte offsets corresponding to the position + in the haystack at which it matched. + +Additionally, the [`packed`](packed/index.html) sub-module contains a lower +level API for using fast vectorized routines for finding a small number of +patterns in a haystack. + +# Example: basic searching + +This example shows how to search for occurrences of multiple patterns +simultaneously. Each match includes the pattern that matched along with the +byte offsets of the match. + +``` +use aho_corasick::AhoCorasick; + +let patterns = &["apple", "maple", "Snapple"]; +let haystack = "Nobody likes maple in their apple flavored Snapple."; + +let ac = AhoCorasick::new(patterns); +let mut matches = vec![]; +for mat in ac.find_iter(haystack) { + matches.push((mat.pattern(), mat.start(), mat.end())); +} +assert_eq!(matches, vec![ + (1, 13, 18), + (0, 28, 33), + (2, 43, 50), +]); +``` + +# Example: case insensitivity + +This is like the previous example, but matches `Snapple` case insensitively +using `AhoCorasickBuilder`: + +``` +use aho_corasick::AhoCorasickBuilder; + +let patterns = &["apple", "maple", "snapple"]; +let haystack = "Nobody likes maple in their apple flavored Snapple."; + +let ac = AhoCorasickBuilder::new() + .ascii_case_insensitive(true) + .build(patterns); +let mut matches = vec![]; +for mat in ac.find_iter(haystack) { + matches.push((mat.pattern(), mat.start(), mat.end())); +} +assert_eq!(matches, vec![ + (1, 13, 18), + (0, 28, 33), + (2, 43, 50), +]); +``` + +# Example: replacing matches in a stream + +This example shows how to execute a search and replace on a stream without +loading the entire stream into memory first. + +``` +use aho_corasick::AhoCorasick; + +# fn example() -> Result<(), ::std::io::Error> { +let patterns = &["fox", "brown", "quick"]; +let replace_with = &["sloth", "grey", "slow"]; + +// In a real example, these might be `std::fs::File`s instead. All you need to +// do is supply a pair of `std::io::Read` and `std::io::Write` implementations. +let rdr = "The quick brown fox."; +let mut wtr = vec![]; + +let ac = AhoCorasick::new(patterns); +ac.stream_replace_all(rdr.as_bytes(), &mut wtr, replace_with)?; +assert_eq!(b"The slow grey sloth.".to_vec(), wtr); +# Ok(()) }; example().unwrap() +``` + +# Example: finding the leftmost first match + +In the textbook description of Aho-Corasick, its formulation is typically +structured such that it reports all possible matches, even when they overlap +with another. In many cases, overlapping matches may not be desired, such as +the case of finding all successive non-overlapping matches like you might with +a standard regular expression. + +Unfortunately the "obvious" way to modify the Aho-Corasick algorithm to do +this doesn't always work in the expected way, since it will report matches as +soon as they are seen. For example, consider matching the regex `Samwise|Sam` +against the text `Samwise`. Most regex engines (that are Perl-like, or +non-POSIX) will report `Samwise` as a match, but the standard Aho-Corasick +algorithm modified for reporting non-overlapping matches will report `Sam`. + +A novel contribution of this library is the ability to change the match +semantics of Aho-Corasick (without additional search time overhead) such that +`Samwise` is reported instead. For example, here's the standard approach: + +``` +use aho_corasick::AhoCorasick; + +let patterns = &["Samwise", "Sam"]; +let haystack = "Samwise"; + +let ac = AhoCorasick::new(patterns); +let mat = ac.find(haystack).expect("should have a match"); +assert_eq!("Sam", &haystack[mat.start()..mat.end()]); +``` + +And now here's the leftmost-first version, which matches how a Perl-like +regex will work: + +``` +use aho_corasick::{AhoCorasickBuilder, MatchKind}; + +let patterns = &["Samwise", "Sam"]; +let haystack = "Samwise"; + +let ac = AhoCorasickBuilder::new() + .match_kind(MatchKind::LeftmostFirst) + .build(patterns); +let mat = ac.find(haystack).expect("should have a match"); +assert_eq!("Samwise", &haystack[mat.start()..mat.end()]); +``` + +In addition to leftmost-first semantics, this library also supports +leftmost-longest semantics, which match the POSIX behavior of a regular +expression alternation. See +[`MatchKind`](enum.MatchKind.html) +for more details. + +# Prefilters + +While an Aho-Corasick automaton can perform admirably when compared to more +naive solutions, it is generally slower than more specialized algorithms that +are accelerated using vector instructions such as SIMD. + +For that reason, this library will internally use a "prefilter" to attempt +to accelerate searches when possible. Currently, this library has fairly +limited implementation that only applies when there are 3 or fewer unique +starting bytes among all patterns in an automaton. + +While a prefilter is generally good to have on by default since it works well +in the common case, it can lead to less predictable or even sub-optimal +performance in some cases. For that reason, prefilters can be disabled via +[`AhoCorasickBuilder::prefilter`](struct.AhoCorasickBuilder.html#method.prefilter). +*/ + +#![deny(missing_docs)] + +// We can never be truly no_std, but we could be alloc-only some day, so +// require the std feature for now. +#[cfg(not(feature = "std"))] +compile_error!("`std` feature is currently required to build this crate"); + +extern crate memchr; +#[cfg(test)] +#[macro_use] +extern crate doc_comment; + +#[cfg(test)] +doctest!("../README.md"); + +pub use ahocorasick::{ + AhoCorasick, AhoCorasickBuilder, FindIter, FindOverlappingIter, MatchKind, + StreamFindIter, +}; +pub use error::{Error, ErrorKind}; +pub use state_id::StateID; + +mod ahocorasick; +mod automaton; +mod buffer; +mod byte_frequencies; +mod classes; +mod dfa; +mod error; +mod nfa; +pub mod packed; +mod prefilter; +mod state_id; +#[cfg(test)] +mod tests; + +/// A representation of a match reported by an Aho-Corasick automaton. +/// +/// A match has two essential pieces of information: the identifier of the +/// pattern that matched, along with the start and end offsets of the match +/// in the haystack. +/// +/// # Examples +/// +/// Basic usage: +/// +/// ``` +/// use aho_corasick::AhoCorasick; +/// +/// let ac = AhoCorasick::new(&[ +/// "foo", "bar", "baz", +/// ]); +/// let mat = ac.find("xxx bar xxx").expect("should have a match"); +/// assert_eq!(1, mat.pattern()); +/// assert_eq!(4, mat.start()); +/// assert_eq!(7, mat.end()); +/// ``` +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct Match { + /// The pattern id. + pattern: usize, + /// The length of this match, such that the starting position of the match + /// is `end - len`. + /// + /// We use length here because, other than the pattern id, the only + /// information about each pattern that the automaton stores is its length. + /// So using the length here is just a bit more natural. But it isn't + /// technically required. + len: usize, + /// The end offset of the match, exclusive. + end: usize, +} + +impl Match { + /// Returns the identifier of the pattern that matched. + /// + /// The identifier of a pattern is derived from the position in which it + /// was originally inserted into the corresponding automaton. The first + /// pattern has identifier `0`, and each subsequent pattern is `1`, `2` + /// and so on. + #[inline] + pub fn pattern(&self) -> usize { + self.pattern + } + + /// The starting position of the match. + #[inline] + pub fn start(&self) -> usize { + self.end - self.len + } + + /// The ending position of the match. + #[inline] + pub fn end(&self) -> usize { + self.end + } + + /// Returns true if and only if this match is empty. That is, when + /// `start() == end()`. + /// + /// An empty match can only be returned when the empty string was among + /// the patterns used to build the Aho-Corasick automaton. + #[inline] + pub fn is_empty(&self) -> bool { + self.len == 0 + } + + #[inline] + fn increment(&self, by: usize) -> Match { + Match { pattern: self.pattern, len: self.len, end: self.end + by } + } + + #[inline] + fn from_span(id: usize, start: usize, end: usize) -> Match { + Match { pattern: id, len: end - start, end: end } + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/nfa.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/nfa.rs new file mode 100644 index 0000000..1e8fe39 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/nfa.rs @@ -0,0 +1,1358 @@ +use std::cmp; +use std::collections::{BTreeSet, VecDeque}; +use std::fmt; +use std::mem::size_of; +use std::ops::{Index, IndexMut}; + +use ahocorasick::MatchKind; +use automaton::Automaton; +use classes::{ByteClassBuilder, ByteClasses}; +use error::Result; +use prefilter::{self, opposite_ascii_case, Prefilter, PrefilterObj}; +use state_id::{dead_id, fail_id, usize_to_state_id, StateID}; +use Match; + +/// The identifier for a pattern, which is simply the position of the pattern +/// in the sequence of patterns given by the caller. +pub type PatternID = usize; + +/// The length of a pattern, in bytes. +pub type PatternLength = usize; + +/// An Aho-Corasick automaton, represented as an NFA. +/// +/// This is the classical formulation of Aho-Corasick, which involves building +/// up a prefix trie of a given set of patterns, and then wiring up failure +/// transitions between states in order to guarantee linear time matching. The +/// standard formulation is, technically, an NFA because of these failure +/// transitions. That is, one can see them as enabling the automaton to be in +/// multiple states at once. Indeed, during search, it is possible to check +/// the transitions on multiple states for a single input byte. +/// +/// This particular implementation not only supports the standard style of +/// matching, but also provides a mode for choosing leftmost-first or +/// leftmost-longest match semantics. When a leftmost mode is chosen, some +/// failure transitions that would otherwise be added are elided. See +/// the documentation of `MatchKind` for more details and examples on how the +/// match semantics may differ. +/// +/// If one wants a DFA, then it is necessary to first build an NFA and convert +/// it into a DFA. Note, however, that because we've constrained ourselves to +/// matching literal patterns, this does not need to use subset construction +/// for determinization. Instead, the DFA has at most a number of states +/// equivalent to the number of NFA states. The only real difference between +/// them is that all failure transitions are followed and pre-computed. This +/// uses much more memory, but also executes searches more quickly. +#[derive(Clone)] +pub struct NFA { + /// The match semantics built into this NFA. + match_kind: MatchKind, + /// The start state id as an index into `states`. + start_id: S, + /// The length, in bytes, of the longest pattern in this automaton. This + /// information is useful for keeping correct buffer sizes when searching + /// on streams. + max_pattern_len: usize, + /// The total number of patterns added to this automaton, including + /// patterns that may never be matched. + pattern_count: usize, + /// The number of bytes of heap used by this NFA's transition table. + heap_bytes: usize, + /// A prefilter for quickly skipping to candidate matches, if pertinent. + prefilter: Option, + /// Whether this automaton anchors all matches to the start of input. + anchored: bool, + /// A set of equivalence classes in terms of bytes. We compute this while + /// building the NFA, but don't use it in the NFA's states. Instead, we + /// use this for building the DFA. We store it on the NFA since it's easy + /// to compute while visiting the the patterns. + byte_classes: ByteClasses, + /// A set of states. Each state defines its own transitions, a fail + /// transition and a set of indices corresponding to matches. + /// + /// The first state is always the fail state, which is used only as a + /// sentinel. Namely, in the final NFA, no transition into the fail state + /// exists. (Well, they do, but they aren't followed. Instead, the state's + /// failure transition is followed.) + /// + /// The second state (index 1) is always the dead state. Dead states are + /// in every automaton, but only used when leftmost-{first,longest} match + /// semantics are enabled. Specifically, they instruct search to stop + /// at specific points in order to report the correct match location. In + /// the standard Aho-Corasick construction, there are no transitions to + /// the dead state. + /// + /// The third state (index 2) is generally intended to be the starting or + /// "root" state. + states: Vec>, +} + +impl NFA { + /// Returns the equivalence classes of bytes found while constructing + /// this NFA. + /// + /// Note that the NFA doesn't actually make use of these equivalence + /// classes. Instead, these are useful for building the DFA when desired. + pub fn byte_classes(&self) -> &ByteClasses { + &self.byte_classes + } + + /// Returns a prefilter, if one exists. + pub fn prefilter_obj(&self) -> Option<&PrefilterObj> { + self.prefilter.as_ref() + } + + /// Returns the total number of heap bytes used by this NFA's transition + /// table. + pub fn heap_bytes(&self) -> usize { + self.heap_bytes + + self.prefilter.as_ref().map_or(0, |p| p.as_ref().heap_bytes()) + } + + /// Return the length of the longest pattern in this automaton. + pub fn max_pattern_len(&self) -> usize { + self.max_pattern_len + } + + /// Return the total number of patterns added to this automaton. + pub fn pattern_count(&self) -> usize { + self.pattern_count + } + + /// Returns the total number of states in this NFA. + pub fn state_len(&self) -> usize { + self.states.len() + } + + /// Returns the matches for the given state. + pub fn matches(&self, id: S) -> &[(PatternID, PatternLength)] { + &self.states[id.to_usize()].matches + } + + /// Returns an iterator over all transitions in the given state according + /// to the given equivalence classes, including transitions to `fail_id()`. + /// The number of transitions returned is always equivalent to the number + /// of equivalence classes. + pub fn iter_all_transitions( + &self, + byte_classes: &ByteClasses, + id: S, + f: F, + ) { + self.states[id.to_usize()].trans.iter_all(byte_classes, f); + } + + /// Returns the failure transition for the given state. + pub fn failure_transition(&self, id: S) -> S { + self.states[id.to_usize()].fail + } + + /// Returns the next state for the given state and input byte. + /// + /// Note that this does not follow failure transitions. As such, the id + /// returned may be `fail_id`. + pub fn next_state(&self, current: S, input: u8) -> S { + self.states[current.to_usize()].next_state(input) + } + + fn state(&self, id: S) -> &State { + &self.states[id.to_usize()] + } + + fn state_mut(&mut self, id: S) -> &mut State { + &mut self.states[id.to_usize()] + } + + fn start(&self) -> &State { + self.state(self.start_id) + } + + fn start_mut(&mut self) -> &mut State { + let id = self.start_id; + self.state_mut(id) + } + + fn iter_transitions_mut(&mut self, id: S) -> IterTransitionsMut { + IterTransitionsMut::new(self, id) + } + + fn copy_matches(&mut self, src: S, dst: S) { + let (src, dst) = + get_two_mut(&mut self.states, src.to_usize(), dst.to_usize()); + dst.matches.extend_from_slice(&src.matches); + } + + fn copy_empty_matches(&mut self, dst: S) { + let start_id = self.start_id; + self.copy_matches(start_id, dst); + } + + fn add_dense_state(&mut self, depth: usize) -> Result { + let trans = Transitions::Dense(Dense::new()); + let id = usize_to_state_id(self.states.len())?; + self.states.push(State { + trans, + // Anchored automatons do not have any failure transitions. + fail: if self.anchored { dead_id() } else { self.start_id }, + depth: depth, + matches: vec![], + }); + Ok(id) + } + + fn add_sparse_state(&mut self, depth: usize) -> Result { + let trans = Transitions::Sparse(vec![]); + let id = usize_to_state_id(self.states.len())?; + self.states.push(State { + trans, + // Anchored automatons do not have any failure transitions. + fail: if self.anchored { dead_id() } else { self.start_id }, + depth: depth, + matches: vec![], + }); + Ok(id) + } +} + +impl Automaton for NFA { + type ID = S; + + fn match_kind(&self) -> &MatchKind { + &self.match_kind + } + + fn anchored(&self) -> bool { + self.anchored + } + + fn prefilter(&self) -> Option<&dyn Prefilter> { + self.prefilter.as_ref().map(|p| p.as_ref()) + } + + fn start_state(&self) -> S { + self.start_id + } + + fn is_valid(&self, id: S) -> bool { + id.to_usize() < self.states.len() + } + + fn is_match_state(&self, id: S) -> bool { + self.states[id.to_usize()].is_match() + } + + fn get_match( + &self, + id: S, + match_index: usize, + end: usize, + ) -> Option { + let state = match self.states.get(id.to_usize()) { + None => return None, + Some(state) => state, + }; + state.matches.get(match_index).map(|&(id, len)| Match { + pattern: id, + len, + end, + }) + } + + fn match_count(&self, id: S) -> usize { + self.states[id.to_usize()].matches.len() + } + + unsafe fn next_state_unchecked(&self, mut current: S, input: u8) -> S { + // This terminates since: + // + // 1. `State.fail` never points to fail_id(). + // 2. All `State.fail` values point to a state closer to `start`. + // 3. The start state has no transitions to fail_id(). + loop { + let state = self.states.get_unchecked(current.to_usize()); + let next = state.next_state(input); + if next != fail_id() { + return next; + } + current = state.fail; + } + } +} + +/// A representation of an NFA state for an Aho-Corasick automaton. +/// +/// It contains the transitions to the next state, a failure transition for +/// cases where there exists no other transition for the current input byte, +/// the matches implied by visiting this state (if any) and the depth of this +/// state. The depth of a state is simply the distance from it to the start +/// state in the automaton, where the depth of the start state is 0. +#[derive(Clone, Debug)] +pub struct State { + trans: Transitions, + fail: S, + matches: Vec<(PatternID, PatternLength)>, + // TODO: Strictly speaking, this isn't needed for searching. It's only + // used when building an NFA that supports leftmost match semantics. We + // could drop this from the state and dynamically build a map only when + // computing failure transitions, but it's not clear which is better. + // Benchmark this. + depth: usize, +} + +impl State { + fn heap_bytes(&self) -> usize { + self.trans.heap_bytes() + + (self.matches.len() * size_of::<(PatternID, PatternLength)>()) + } + + fn add_match(&mut self, i: PatternID, len: PatternLength) { + self.matches.push((i, len)); + } + + fn is_match(&self) -> bool { + !self.matches.is_empty() + } + + fn get_longest_match_len(&self) -> Option { + // Why is this true? Because the first match in any matching state + // will always correspond to the match added to it during trie + // construction (since when we copy matches due to failure transitions, + // we always append them). Therefore, it follows that the first match + // must always be longest since any subsequent match must be from a + // failure transition, and a failure transition by construction points + // to a proper suffix. A proper suffix is, by definition, smaller. + self.matches.get(0).map(|&(_, len)| len) + } + + fn next_state(&self, input: u8) -> S { + self.trans.next_state(input) + } + + fn set_next_state(&mut self, input: u8, next: S) { + self.trans.set_next_state(input, next); + } +} + +/// Represents the transitions for a single dense state. +/// +/// The primary purpose here is to encapsulate unchecked index access. Namely, +/// since a dense representation always contains 256 elements, all values of +/// `u8` are valid indices. +#[derive(Clone, Debug)] +struct Dense(Vec); + +impl Dense +where + S: StateID, +{ + fn new() -> Self { + Dense(vec![fail_id(); 256]) + } + + #[inline] + fn len(&self) -> usize { + self.0.len() + } +} + +impl Index for Dense { + type Output = S; + + #[inline] + fn index(&self, i: u8) -> &S { + // SAFETY: This is safe because all dense transitions have + // exactly 256 elements, so all u8 values are valid indices. + unsafe { self.0.get_unchecked(i as usize) } + } +} + +impl IndexMut for Dense { + #[inline] + fn index_mut(&mut self, i: u8) -> &mut S { + // SAFETY: This is safe because all dense transitions have + // exactly 256 elements, so all u8 values are valid indices. + unsafe { self.0.get_unchecked_mut(i as usize) } + } +} + +/// A representation of transitions in an NFA. +/// +/// Transitions have either a sparse representation, which is slower for +/// lookups but uses less memory, or a dense representation, which is faster +/// for lookups but uses more memory. In the sparse representation, the absence +/// of a state implies a transition to `fail_id()`. Transitions to `dead_id()` +/// are still explicitly represented. +/// +/// For the NFA, by default, we use a dense representation for transitions for +/// states close to the start state because it's likely these are the states +/// that will be most frequently visited. +#[derive(Clone, Debug)] +enum Transitions { + Sparse(Vec<(u8, S)>), + Dense(Dense), +} + +impl Transitions { + fn heap_bytes(&self) -> usize { + match *self { + Transitions::Sparse(ref sparse) => { + sparse.len() * size_of::<(u8, S)>() + } + Transitions::Dense(ref dense) => dense.len() * size_of::(), + } + } + + fn next_state(&self, input: u8) -> S { + match *self { + Transitions::Sparse(ref sparse) => { + for &(b, id) in sparse { + if b == input { + return id; + } + } + fail_id() + } + Transitions::Dense(ref dense) => dense[input], + } + } + + fn set_next_state(&mut self, input: u8, next: S) { + match *self { + Transitions::Sparse(ref mut sparse) => { + match sparse.binary_search_by_key(&input, |&(b, _)| b) { + Ok(i) => sparse[i] = (input, next), + Err(i) => sparse.insert(i, (input, next)), + } + } + Transitions::Dense(ref mut dense) => { + dense[input] = next; + } + } + } + + /// Iterate over transitions in this state while skipping over transitions + /// to `fail_id()`. + fn iter(&self, mut f: F) { + match *self { + Transitions::Sparse(ref sparse) => { + for &(b, id) in sparse { + f(b, id); + } + } + Transitions::Dense(ref dense) => { + for b in AllBytesIter::new() { + let id = dense[b]; + if id != fail_id() { + f(b, id); + } + } + } + } + } + + /// Iterate over all transitions in this state according to the given + /// equivalence classes, including transitions to `fail_id()`. + fn iter_all(&self, classes: &ByteClasses, mut f: F) { + if classes.is_singleton() { + match *self { + Transitions::Sparse(ref sparse) => { + sparse_iter(sparse, f); + } + Transitions::Dense(ref dense) => { + for b in AllBytesIter::new() { + f(b, dense[b]); + } + } + } + } else { + // In this case, we only want to yield a single byte for each + // equivalence class. + match *self { + Transitions::Sparse(ref sparse) => { + let mut last_class = None; + sparse_iter(sparse, |b, next| { + let class = classes.get(b); + if last_class != Some(class) { + last_class = Some(class); + f(b, next); + } + }) + } + Transitions::Dense(ref dense) => { + for b in classes.representatives() { + f(b, dense[b]); + } + } + } + } + } +} + +/// Iterator over transitions in a state, skipping transitions to `fail_id()`. +/// +/// This abstracts over the representation of NFA transitions, which may be +/// either in a sparse or dense representation. +/// +/// This somewhat idiosyncratically borrows the NFA mutably, so that when one +/// is iterating over transitions, the caller can still mutate the NFA. This +/// is useful when creating failure transitions. +#[derive(Debug)] +struct IterTransitionsMut<'a, S: StateID + 'a> { + nfa: &'a mut NFA, + state_id: S, + cur: usize, +} + +impl<'a, S: StateID> IterTransitionsMut<'a, S> { + fn new(nfa: &'a mut NFA, state_id: S) -> IterTransitionsMut<'a, S> { + IterTransitionsMut { nfa, state_id, cur: 0 } + } + + fn nfa(&mut self) -> &mut NFA { + self.nfa + } +} + +impl<'a, S: StateID> Iterator for IterTransitionsMut<'a, S> { + type Item = (u8, S); + + fn next(&mut self) -> Option<(u8, S)> { + match self.nfa.states[self.state_id.to_usize()].trans { + Transitions::Sparse(ref sparse) => { + if self.cur >= sparse.len() { + return None; + } + let i = self.cur; + self.cur += 1; + Some(sparse[i]) + } + Transitions::Dense(ref dense) => { + while self.cur < dense.len() { + // There are always exactly 255 transitions in dense repr. + debug_assert!(self.cur < 256); + + let b = self.cur as u8; + let id = dense[b]; + self.cur += 1; + if id != fail_id() { + return Some((b, id)); + } + } + None + } + } + } +} + +/// A simple builder for configuring the NFA construction of Aho-Corasick. +#[derive(Clone, Debug)] +pub struct Builder { + dense_depth: usize, + match_kind: MatchKind, + prefilter: bool, + anchored: bool, + ascii_case_insensitive: bool, +} + +impl Default for Builder { + fn default() -> Builder { + Builder { + dense_depth: 2, + match_kind: MatchKind::default(), + prefilter: true, + anchored: false, + ascii_case_insensitive: false, + } + } +} + +impl Builder { + pub fn new() -> Builder { + Builder::default() + } + + pub fn build(&self, patterns: I) -> Result> + where + I: IntoIterator, + P: AsRef<[u8]>, + { + Compiler::new(self)?.compile(patterns) + } + + pub fn match_kind(&mut self, kind: MatchKind) -> &mut Builder { + self.match_kind = kind; + self + } + + pub fn dense_depth(&mut self, depth: usize) -> &mut Builder { + self.dense_depth = depth; + self + } + + pub fn prefilter(&mut self, yes: bool) -> &mut Builder { + self.prefilter = yes; + self + } + + pub fn anchored(&mut self, yes: bool) -> &mut Builder { + self.anchored = yes; + self + } + + pub fn ascii_case_insensitive(&mut self, yes: bool) -> &mut Builder { + self.ascii_case_insensitive = yes; + self + } +} + +/// A compiler uses a builder configuration and builds up the NFA formulation +/// of an Aho-Corasick automaton. This roughly corresponds to the standard +/// formulation described in textbooks. +#[derive(Debug)] +struct Compiler<'a, S: StateID> { + builder: &'a Builder, + prefilter: prefilter::Builder, + nfa: NFA, + byte_classes: ByteClassBuilder, +} + +impl<'a, S: StateID> Compiler<'a, S> { + fn new(builder: &'a Builder) -> Result> { + Ok(Compiler { + builder: builder, + prefilter: prefilter::Builder::new(builder.match_kind) + .ascii_case_insensitive(builder.ascii_case_insensitive), + nfa: NFA { + match_kind: builder.match_kind, + start_id: usize_to_state_id(2)?, + max_pattern_len: 0, + pattern_count: 0, + heap_bytes: 0, + prefilter: None, + anchored: builder.anchored, + byte_classes: ByteClasses::singletons(), + states: vec![], + }, + byte_classes: ByteClassBuilder::new(), + }) + } + + fn compile(mut self, patterns: I) -> Result> + where + I: IntoIterator, + P: AsRef<[u8]>, + { + self.add_state(0)?; // the fail state, which is never entered + self.add_state(0)?; // the dead state, only used for leftmost + self.add_state(0)?; // the start state + self.build_trie(patterns)?; + self.add_start_state_loop(); + self.add_dead_state_loop(); + if !self.builder.anchored { + if self.match_kind().is_leftmost() { + self.fill_failure_transitions_leftmost(); + } else { + self.fill_failure_transitions_standard(); + } + } + self.close_start_state_loop(); + self.nfa.byte_classes = self.byte_classes.build(); + if !self.builder.anchored { + self.nfa.prefilter = self.prefilter.build(); + } + self.calculate_size(); + Ok(self.nfa) + } + + /// This sets up the initial prefix trie that makes up the Aho-Corasick + /// automaton. Effectively, it creates the basic structure of the + /// automaton, where every pattern given has a path from the start state to + /// the end of the pattern. + fn build_trie(&mut self, patterns: I) -> Result<()> + where + I: IntoIterator, + P: AsRef<[u8]>, + { + 'PATTERNS: for (pati, pat) in patterns.into_iter().enumerate() { + let pat = pat.as_ref(); + self.nfa.max_pattern_len = + cmp::max(self.nfa.max_pattern_len, pat.len()); + self.nfa.pattern_count += 1; + + let mut prev = self.nfa.start_id; + let mut saw_match = false; + for (depth, &b) in pat.iter().enumerate() { + // When leftmost-first match semantics are requested, we + // specifically stop adding patterns when a previously added + // pattern is a prefix of it. We avoid adding it because + // leftmost-first semantics imply that the pattern can never + // match. This is not just an optimization to save space! It + // is necessary for correctness. In fact, this is the only + // difference in the automaton between the implementations for + // leftmost-first and leftmost-longest. + saw_match = saw_match || self.nfa.state(prev).is_match(); + if self.builder.match_kind.is_leftmost_first() && saw_match { + // Skip to the next pattern immediately. This avoids + // incorrectly adding a match after this loop terminates. + continue 'PATTERNS; + } + + // Add this byte to our equivalence classes. We don't use these + // for NFA construction. These are instead used only if we're + // building a DFA. They would technically be useful for the + // NFA, but it would require a second pass over the patterns. + self.byte_classes.set_range(b, b); + + // If the transition from prev using the current byte already + // exists, then just move through it. Otherwise, add a new + // state. We track the depth here so that we can determine + // how to represent transitions. States near the start state + // use a dense representation that uses more memory but is + // faster. Other states use a sparse representation that uses + // less memory but is slower. + let next = self.nfa.state(prev).next_state(b); + if next != fail_id() { + prev = next; + } else { + let next = self.add_state(depth + 1)?; + self.nfa.state_mut(prev).set_next_state(b, next); + if self.builder.ascii_case_insensitive { + let b = opposite_ascii_case(b); + self.nfa.state_mut(prev).set_next_state(b, next); + } + prev = next; + } + } + // Once the pattern has been added, log the match in the final + // state that it reached. + self.nfa.state_mut(prev).add_match(pati, pat.len()); + // ... and hand it to the prefilter builder, if applicable. + if self.builder.prefilter { + self.prefilter.add(pat); + } + } + Ok(()) + } + + /// This routine creates failure transitions according to the standard + /// textbook formulation of the Aho-Corasick algorithm. + /// + /// Building failure transitions is the most interesting part of building + /// the Aho-Corasick automaton, because they are what allow searches to + /// be performed in linear time. Specifically, a failure transition is + /// a single transition associated with each state that points back to + /// the longest proper suffix of the pattern being searched. The failure + /// transition is followed whenever there exists no transition on the + /// current state for the current input byte. If there is no other proper + /// suffix, then the failure transition points back to the starting state. + /// + /// For example, let's say we built an Aho-Corasick automaton with the + /// following patterns: 'abcd' and 'cef'. The trie looks like this: + /// + /// ```ignore + /// a - S1 - b - S2 - c - S3 - d - S4* + /// / + /// S0 - c - S5 - e - S6 - f - S7* + /// ``` + /// + /// At this point, it should be fairly straight-forward to see how this + /// trie can be used in a simplistic way. At any given position in the + /// text we're searching (called the "subject" string), all we need to do + /// is follow the transitions in the trie by consuming one transition for + /// each byte in the subject string. If we reach a match state, then we can + /// report that location as a match. + /// + /// The trick comes when searching a subject string like 'abcef'. We'll + /// initially follow the transition from S0 to S1 and wind up in S3 after + /// observng the 'c' byte. At this point, the next byte is 'e' but state + /// S3 has no transition for 'e', so the search fails. We then would need + /// to restart the search at the next position in 'abcef', which + /// corresponds to 'b'. The match would fail, but the next search starting + /// at 'c' would finally succeed. The problem with this approach is that + /// we wind up searching the subject string potentially many times. In + /// effect, this makes the algorithm have worst case `O(n * m)` complexity, + /// where `n ~ len(subject)` and `m ~ len(all patterns)`. We would instead + /// like to achieve a `O(n + m)` worst case complexity. + /// + /// This is where failure transitions come in. Instead of dying at S3 in + /// the first search, the automaton can instruct the search to move to + /// another part of the automaton that corresponds to a suffix of what + /// we've seen so far. Recall that we've seen 'abc' in the subject string, + /// and the automaton does indeed have a non-empty suffix, 'c', that could + /// potentially lead to another match. Thus, the actual Aho-Corasick + /// automaton for our patterns in this case looks like this: + /// + /// ```ignore + /// a - S1 - b - S2 - c - S3 - d - S4* + /// / / + /// / ---------------- + /// / / + /// S0 - c - S5 - e - S6 - f - S7* + /// ``` + /// + /// That is, we have a failure transition from S3 to S5, which is followed + /// exactly in cases when we are in state S3 but see any byte other than + /// 'd' (that is, we've "failed" to find a match in this portion of our + /// trie). We know we can transition back to S5 because we've already seen + /// a 'c' byte, so we don't need to re-scan it. We can then pick back up + /// with the search starting at S5 and complete our match. + /// + /// Adding failure transitions to a trie is fairly simple, but subtle. The + /// key issue is that you might have multiple failure transition that you + /// need to follow. For example, look at the trie for the patterns + /// 'abcd', 'b', 'bcd' and 'cd': + /// + /// ```ignore + /// - a - S1 - b - S2 - c - S3 - d - S4* + /// / + /// S0 - b - S5* - c - S6 - d - S7* + /// \ + /// - c - S8 - d - S9* + /// ``` + /// + /// The failure transitions for this trie are defined from S2 to S5, + /// S3 to S6 and S6 to S8. Moreover, state S2 needs to track that it + /// corresponds to a match, since its failure transition to S5 is itself + /// a match state. + /// + /// Perhaps simplest way to think about adding these failure transitions + /// is recursively. That is, if you know the failure transitions for every + /// possible previous state that could be visited (e.g., when computing the + /// failure transition for S3, you already know the failure transitions + /// for S0, S1 and S2), then you can simply follow the failure transition + /// of the previous state and check whether the incoming transition is + /// defined after following the failure transition. + /// + /// For example, when determining the failure state for S3, by our + /// assumptions, we already know that there is a failure transition from + /// S2 (the previous state) to S5. So we follow that transition and check + /// whether the transition connecting S2 to S3 is defined. Indeed, it is, + /// as there is a transition from S5 to S6 for the byte 'c'. If no such + /// transition existed, we could keep following the failure transitions + /// until we reach the start state, which is the failure transition for + /// every state that has no corresponding proper suffix. + /// + /// We don't actually use recursion to implement this, but instead, use a + /// breadth first search of the automaton. Our base case is the start + /// state, whose failure transition is just a transition to itself. + fn fill_failure_transitions_standard(&mut self) { + // Initialize the queue for breadth first search with all transitions + // out of the start state. We handle the start state specially because + // we only want to follow non-self transitions. If we followed self + // transitions, then this would never terminate. + let mut queue = VecDeque::new(); + let mut seen = self.queued_set(); + for b in AllBytesIter::new() { + let next = self.nfa.start().next_state(b); + if next != self.nfa.start_id { + if !seen.contains(next) { + queue.push_back(next); + seen.insert(next); + } + } + } + while let Some(id) = queue.pop_front() { + let mut it = self.nfa.iter_transitions_mut(id); + while let Some((b, next)) = it.next() { + if !seen.contains(next) { + queue.push_back(next); + seen.insert(next); + } + + let mut fail = it.nfa().state(id).fail; + while it.nfa().state(fail).next_state(b) == fail_id() { + fail = it.nfa().state(fail).fail; + } + fail = it.nfa().state(fail).next_state(b); + it.nfa().state_mut(next).fail = fail; + it.nfa().copy_matches(fail, next); + } + // If the start state is a match state, then this automaton can + // match the empty string. This implies all states are match states + // since every position matches the empty string, so copy the + // matches from the start state to every state. Strictly speaking, + // this is only necessary for overlapping matches since each + // non-empty non-start match state needs to report empty matches + // in addition to its own. For the non-overlapping case, such + // states only report the first match, which is never empty since + // it isn't a start state. + it.nfa().copy_empty_matches(id); + } + } + + /// This routine is just like fill_failure_transitions_standard, except + /// it adds failure transitions in a way that preserves leftmost match + /// semantics (for both leftmost-first and leftmost-longest). + /// + /// The algorithms are so similar that it would be possible to write it + /// generically. But doing so without overhead would require a bit of + /// ceremony, so we just copy it and add in the extra leftmost logic. + /// Moreover, the standard algorithm above is so simple that it feels like + /// a crime to disturb it. + /// + /// In effect, this proceeds just like the standard approach, but we + /// specifically add only a subset of all failure transitions. Namely, we + /// only add failure transitions that either do not occur after a match + /// or failure transitions that do occur after a match but preserve the + /// match. The comments in the implementation below should help. + /// + /// N.B. The only differences in the automaton between leftmost-first and + /// leftmost-longest are in trie construction. Otherwise, both have exactly + /// the same set of failure transitions. leftmost-longest adds everything + /// to the trie, where as leftmost-first skips any patterns for which there + /// exists a prefix of it that was added earlier. + /// + /// N.B. I came up with this algorithm on my own, and after scouring all of + /// the other AC implementations I know of (Perl, Snort, many on GitHub). + /// I couldn't find any that implement leftmost semantics like this. + /// Perl of course needs leftmost-first semantics, but they implement it + /// with a seeming hack at *search* time instead of encoding it into the + /// automaton. There are also a couple Java libraries that support leftmost + /// longest semantics, but they do it by building a queue of matches at + /// search time, which is even worse than what Perl is doing. ---AG + fn fill_failure_transitions_leftmost(&mut self) { + /// Represents an item in our queue of states to process. + /// + /// Fundamentally, this queue serves the same purpose as the queue + /// for filling failure transitions using the standard formulation. + /// In the leftmost case, though, we need to track a bit more + /// information. See comments below. + #[derive(Clone, Copy, Debug)] + struct QueuedState { + /// The id of the state to visit. + id: S, + /// The depth at which the first match was observed in the path + /// to this state. Note that this corresponds to the depth at + /// which the beginning of the match was detected. If no match + /// has been seen, then this is None. + match_at_depth: Option, + } + + impl QueuedState { + /// Create a queued state corresponding to the given NFA's start + /// state. + fn start(nfa: &NFA) -> QueuedState { + let match_at_depth = + if nfa.start().is_match() { Some(0) } else { None }; + QueuedState { id: nfa.start_id, match_at_depth } + } + + /// Return the next state to queue up. The given id must be a state + /// corresponding to a single transition from this queued state. + fn next_queued_state( + &self, + nfa: &NFA, + id: S, + ) -> QueuedState { + let match_at_depth = self.next_match_at_depth(nfa, id); + QueuedState { id, match_at_depth } + } + + /// Return the earliest depth at which a match has occurred for + /// the given state. The given state must correspond to a single + /// transition from this queued state. + fn next_match_at_depth( + &self, + nfa: &NFA, + next: S, + ) -> Option { + // This is a little tricky. If the previous state has already + // seen a match or if `next` isn't a match state, then nothing + // needs to change since a later state cannot find an earlier + // match. + match self.match_at_depth { + Some(x) => return Some(x), + None if nfa.state(next).is_match() => {} + None => return None, + } + let depth = nfa.state(next).depth + - nfa.state(next).get_longest_match_len().unwrap() + + 1; + Some(depth) + } + } + + // Initialize the queue for breadth first search with all transitions + // out of the start state. We handle the start state specially because + // we only want to follow non-self transitions. If we followed self + // transitions, then this would never terminate. + let mut queue: VecDeque> = VecDeque::new(); + let mut seen = self.queued_set(); + let start = QueuedState::start(&self.nfa); + for b in AllBytesIter::new() { + let next_id = self.nfa.start().next_state(b); + if next_id != start.id { + let next = start.next_queued_state(&self.nfa, next_id); + if !seen.contains(next.id) { + queue.push_back(next); + seen.insert(next.id); + } + // If a state immediately following the start state is a match + // state, then we never want to follow its failure transition + // since the failure transition necessarily leads back to the + // start state, which we never want to do for leftmost matching + // after a match has been found. + // + // N.B. This is a special case of the more general handling + // found below. + if self.nfa.state(next_id).is_match() { + self.nfa.state_mut(next_id).fail = dead_id(); + } + } + } + while let Some(item) = queue.pop_front() { + let mut any_trans = false; + let mut it = self.nfa.iter_transitions_mut(item.id); + while let Some((b, next_id)) = it.next() { + any_trans = true; + + // Queue up the next state. + let next = item.next_queued_state(it.nfa(), next_id); + if !seen.contains(next.id) { + queue.push_back(next); + seen.insert(next.id); + } + + // Find the failure state for next. Same as standard. + let mut fail = it.nfa().state(item.id).fail; + while it.nfa().state(fail).next_state(b) == fail_id() { + fail = it.nfa().state(fail).fail; + } + fail = it.nfa().state(fail).next_state(b); + + // This is the key difference from the standard formulation. + // Namely, if we've seen a match, then we only want a failure + // transition if the failure transition preserves the match + // we've seen. In general, this is not true of all failure + // transitions since they can point back to any suffix of what + // we've seen so far. Instead, we only want to point back to + // suffixes that contain any match we've seen. + // + // We achieve this by comparing the depth of the failure + // transition with the number of states between this state + // and the beginning of the earliest match detected. If the + // depth of the failure state is smaller than this difference, + // then it cannot contain the match. If it's bigger or equal + // to the difference, then it necessarily includes the match + // we've seen since all failure transitions correspond to a + // suffix. + // + // If we've determined that we don't want the failure + // transition, then we set this state's failure transition to + // the dead state. In other words, when a search hits this + // state, it will not continue and correctly stop. (N.B. A + // dead state is different than a fail state. A dead state + // MUST be preceded by a match and acts as a sentinel to search + // routines to terminate.) + // + // Understanding this is tricky, and it took me several days + // to think through this and get it right. If you want to grok + // it, then I'd recommend: 1) switch the implementation to + // always use the standard algorithm for filling in failure + // transitions, 2) run the test suite and 3) examine the test + // failures. Write out the automatons for them and try to work + // backwards by figuring out which failure transitions should + // be removed. You should arrive at the same rule used below. + if let Some(match_depth) = next.match_at_depth { + let fail_depth = it.nfa().state(fail).depth; + let next_depth = it.nfa().state(next.id).depth; + if next_depth - match_depth + 1 > fail_depth { + it.nfa().state_mut(next.id).fail = dead_id(); + continue; + } + assert_ne!( + start.id, + it.nfa().state(next.id).fail, + "states that are match states or follow match \ + states should never have a failure transition \ + back to the start state in leftmost searching", + ); + } + it.nfa().state_mut(next.id).fail = fail; + it.nfa().copy_matches(fail, next.id); + } + // If there are no transitions for this state and if it's a match + // state, then we must set its failure transition to the dead + // state since we never want it to restart the search. + if !any_trans && it.nfa().state(item.id).is_match() { + it.nfa().state_mut(item.id).fail = dead_id(); + } + // We don't need to copy empty matches from the start state here + // because that's only necessary for overlapping matches and + // leftmost match kinds don't support overlapping matches. + } + } + + /// Returns a set that tracked queued states. + /// + /// This is only necessary when ASCII case insensitivity is enabled, since + /// it is the only way to visit the same state twice. Otherwise, this + /// returns an inert set that nevers adds anything and always reports + /// `false` for every member test. + fn queued_set(&self) -> QueuedSet { + if self.builder.ascii_case_insensitive { + QueuedSet::active() + } else { + QueuedSet::inert() + } + } + + /// Set the failure transitions on the start state to loop back to the + /// start state. This effectively permits the Aho-Corasick automaton to + /// match at any position. This is also required for finding the next + /// state to terminate, namely, finding the next state should never return + /// a fail_id. + /// + /// This must be done after building the initial trie, since trie + /// construction depends on transitions to `fail_id` to determine whether a + /// state already exists or not. + fn add_start_state_loop(&mut self) { + let start_id = self.nfa.start_id; + let start = self.nfa.start_mut(); + for b in AllBytesIter::new() { + if start.next_state(b) == fail_id() { + start.set_next_state(b, start_id); + } + } + } + + /// Remove the start state loop by rewriting any transitions on the start + /// state back to the start state with transitions to the dead state. + /// + /// The loop is only closed when two conditions are met: the start state + /// is a match state and the match kind is leftmost-first or + /// leftmost-longest. (Alternatively, if this is an anchored automaton, + /// then the start state is always closed, regardless of aforementioned + /// conditions.) + /// + /// The reason for this is that under leftmost semantics, a start state + /// that is also a match implies that we should never restart the search + /// process. We allow normal transitions out of the start state, but if + /// none exist, we transition to the dead state, which signals that + /// searching should stop. + fn close_start_state_loop(&mut self) { + if self.builder.anchored + || (self.match_kind().is_leftmost() && self.nfa.start().is_match()) + { + let start_id = self.nfa.start_id; + let start = self.nfa.start_mut(); + for b in AllBytesIter::new() { + if start.next_state(b) == start_id { + start.set_next_state(b, dead_id()); + } + } + } + } + + /// Sets all transitions on the dead state to point back to the dead state. + /// Normally, missing transitions map back to the failure state, but the + /// point of the dead state is to act as a sink that can never be escaped. + fn add_dead_state_loop(&mut self) { + let dead = self.nfa.state_mut(dead_id()); + for b in AllBytesIter::new() { + dead.set_next_state(b, dead_id()); + } + } + + /// Computes the total amount of heap used by this NFA in bytes. + fn calculate_size(&mut self) { + let mut size = 0; + for state in &self.nfa.states { + size += state.heap_bytes(); + } + self.nfa.heap_bytes = size; + } + + /// Add a new state to the underlying NFA with the given depth. The depth + /// is used to determine how to represent the transitions. + /// + /// If adding the new state would overflow the chosen state ID + /// representation, then this returns an error. + fn add_state(&mut self, depth: usize) -> Result { + if depth < self.builder.dense_depth { + self.nfa.add_dense_state(depth) + } else { + self.nfa.add_sparse_state(depth) + } + } + + /// Returns the match kind configured on the underlying builder. + fn match_kind(&self) -> MatchKind { + self.builder.match_kind + } +} + +/// A set of state identifiers used to avoid revisiting the same state multiple +/// times when filling in failure transitions. +/// +/// This set has an "inert" and an "active" mode. When inert, the set never +/// stores anything and always returns `false` for every member test. This is +/// useful to avoid the performance and memory overhead of maintaining this +/// set when it is not needed. +#[derive(Debug)] +struct QueuedSet { + set: Option>, +} + +impl QueuedSet { + /// Return an inert set that returns `false` for every state ID membership + /// test. + fn inert() -> QueuedSet { + QueuedSet { set: None } + } + + /// Return an active set that tracks state ID membership. + fn active() -> QueuedSet { + QueuedSet { set: Some(BTreeSet::new()) } + } + + /// Inserts the given state ID into this set. (If the set is inert, then + /// this is a no-op.) + fn insert(&mut self, state_id: S) { + if let Some(ref mut set) = self.set { + set.insert(state_id); + } + } + + /// Returns true if and only if the given state ID is in this set. If the + /// set is inert, this always returns false. + fn contains(&self, state_id: S) -> bool { + match self.set { + None => false, + Some(ref set) => set.contains(&state_id), + } + } +} + +/// An iterator over every byte value. +/// +/// We use this instead of (0..256).map(|b| b as u8) because this optimizes +/// better in debug builds. +/// +/// We also use this instead of 0..=255 because we're targeting Rust 1.24 and +/// inclusive range syntax was stabilized in Rust 1.26. We can get rid of this +/// once our MSRV is Rust 1.26 or newer. +#[derive(Debug)] +struct AllBytesIter(u16); + +impl AllBytesIter { + fn new() -> AllBytesIter { + AllBytesIter(0) + } +} + +impl Iterator for AllBytesIter { + type Item = u8; + + fn next(&mut self) -> Option { + if self.0 >= 256 { + None + } else { + let b = self.0 as u8; + self.0 += 1; + Some(b) + } + } +} + +impl fmt::Debug for NFA { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + writeln!(f, "NFA(")?; + writeln!(f, "match_kind: {:?}", self.match_kind)?; + writeln!(f, "{}", "-".repeat(79))?; + for (id, s) in self.states.iter().enumerate() { + let mut trans = vec![]; + s.trans.iter(|byte, next| { + // The start state has a bunch of uninteresting transitions + // back into itself. It's questionable to hide them since they + // are critical to understanding the automaton, but they are + // very noisy without better formatting for contiugous ranges + // to the same state. + if id == self.start_id.to_usize() && next == self.start_id { + return; + } + // Similarly, the dead state has a bunch of uninteresting + // transitions too. + if id == dead_id() { + return; + } + trans.push(format!("{} => {}", escape(byte), next.to_usize())); + }); + writeln!(f, "{:04}: {}", id, trans.join(", "))?; + + let matches: Vec = s + .matches + .iter() + .map(|&(pattern_id, _)| pattern_id.to_string()) + .collect(); + writeln!(f, " matches: {}", matches.join(", "))?; + writeln!(f, " fail: {}", s.fail.to_usize())?; + writeln!(f, " depth: {}", s.depth)?; + } + writeln!(f, "{}", "-".repeat(79))?; + writeln!(f, ")")?; + Ok(()) + } +} + +/// Iterate over all possible byte transitions given a sparse set. +fn sparse_iter(trans: &[(u8, S)], mut f: F) { + let mut byte = 0u16; + for &(b, id) in trans { + while byte < (b as u16) { + f(byte as u8, fail_id()); + byte += 1; + } + f(b, id); + byte += 1; + } + for b in byte..256 { + f(b as u8, fail_id()); + } +} + +/// Safely return two mutable borrows to two different locations in the given +/// slice. +/// +/// This panics if i == j. +fn get_two_mut(xs: &mut [T], i: usize, j: usize) -> (&mut T, &mut T) { + assert!(i != j, "{} must not be equal to {}", i, j); + if i < j { + let (before, after) = xs.split_at_mut(j); + (&mut before[i], &mut after[0]) + } else { + let (before, after) = xs.split_at_mut(i); + (&mut after[0], &mut before[j]) + } +} + +/// Return the given byte as its escaped string form. +fn escape(b: u8) -> String { + use std::ascii; + + String::from_utf8(ascii::escape_default(b).collect::>()).unwrap() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn scratch() { + let nfa: NFA = Builder::new() + .dense_depth(0) + // .match_kind(MatchKind::LeftmostShortest) + // .match_kind(MatchKind::LeftmostLongest) + .match_kind(MatchKind::LeftmostFirst) + // .build(&["abcd", "ce", "b"]) + // .build(&["ab", "bc"]) + // .build(&["b", "bcd", "ce"]) + // .build(&["abc", "bx"]) + // .build(&["abc", "bd", "ab"]) + // .build(&["abcdefghi", "hz", "abcdefgh"]) + // .build(&["abcd", "bce", "b"]) + .build(&["abcdefg", "bcde", "bcdef"]) + .unwrap(); + println!("{:?}", nfa); + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/api.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/api.rs new file mode 100644 index 0000000..1740643 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/api.rs @@ -0,0 +1,632 @@ +use std::u16; + +use packed::pattern::Patterns; +use packed::rabinkarp::RabinKarp; +use packed::teddy::{self, Teddy}; +use Match; + +/// This is a limit placed on the total number of patterns we're willing to try +/// and match at once. As more sophisticated algorithms are added, this number +/// may be increased. +const PATTERN_LIMIT: usize = 128; + +/// A knob for controlling the match semantics of a packed multiple string +/// searcher. +/// +/// This differs from the +/// [`MatchKind`](../enum.MatchKind.html) +/// type in the top-level crate module in that it doesn't support +/// "standard" match semantics, and instead only supports leftmost-first or +/// leftmost-longest. Namely, "standard" semantics cannot be easily supported +/// by packed searchers. +/// +/// For more information on the distinction between leftmost-first and +/// leftmost-longest, see the docs on the top-level `MatchKind` type. +/// +/// Unlike the top-level `MatchKind` type, the default match semantics for this +/// type are leftmost-first. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum MatchKind { + /// Use leftmost-first match semantics, which reports leftmost matches. + /// When there are multiple possible leftmost matches, the match + /// corresponding to the pattern that appeared earlier when constructing + /// the automaton is reported. + /// + /// This is the default. + LeftmostFirst, + /// Use leftmost-longest match semantics, which reports leftmost matches. + /// When there are multiple possible leftmost matches, the longest match + /// is chosen. + LeftmostLongest, + /// Hints that destructuring should not be exhaustive. + /// + /// This enum may grow additional variants, so this makes sure clients + /// don't count on exhaustive matching. (Otherwise, adding a new variant + /// could break existing code.) + #[doc(hidden)] + __Nonexhaustive, +} + +impl Default for MatchKind { + fn default() -> MatchKind { + MatchKind::LeftmostFirst + } +} + +/// The configuration for a packed multiple pattern searcher. +/// +/// The configuration is currently limited only to being able to select the +/// match semantics (leftmost-first or leftmost-longest) of a searcher. In the +/// future, more knobs may be made available. +/// +/// A configuration produces a [`packed::Builder`](struct.Builder.html), which +/// in turn can be used to construct a +/// [`packed::Searcher`](struct.Searcher.html) for searching. +/// +/// # Example +/// +/// This example shows how to use leftmost-longest semantics instead of the +/// default (leftmost-first). +/// +/// ``` +/// use aho_corasick::packed::{Config, MatchKind}; +/// +/// # fn example() -> Option<()> { +/// let searcher = Config::new() +/// .match_kind(MatchKind::LeftmostLongest) +/// .builder() +/// .add("foo") +/// .add("foobar") +/// .build()?; +/// let matches: Vec = searcher +/// .find_iter("foobar") +/// .map(|mat| mat.pattern()) +/// .collect(); +/// assert_eq!(vec![1], matches); +/// # Some(()) } +/// # if cfg!(target_arch = "x86_64") { +/// # example().unwrap() +/// # } else { +/// # assert!(example().is_none()); +/// # } +/// ``` +#[derive(Clone, Debug)] +pub struct Config { + kind: MatchKind, + force: Option, + force_teddy_fat: Option, + force_avx: Option, +} + +/// An internal option for forcing the use of a particular packed algorithm. +/// +/// When an algorithm is forced, if a searcher could not be constructed for it, +/// then no searcher will be returned even if an alternative algorithm would +/// work. +#[derive(Clone, Debug)] +enum ForceAlgorithm { + Teddy, + RabinKarp, +} + +impl Default for Config { + fn default() -> Config { + Config::new() + } +} + +impl Config { + /// Create a new default configuration. A default configuration uses + /// leftmost-first match semantics. + pub fn new() -> Config { + Config { + kind: MatchKind::LeftmostFirst, + force: None, + force_teddy_fat: None, + force_avx: None, + } + } + + /// Create a packed builder from this configuration. The builder can be + /// used to accumulate patterns and create a + /// [`Searcher`](struct.Searcher.html) + /// from them. + pub fn builder(&self) -> Builder { + Builder::from_config(self.clone()) + } + + /// Set the match semantics for this configuration. + pub fn match_kind(&mut self, kind: MatchKind) -> &mut Config { + self.kind = kind; + self + } + + /// An undocumented method for forcing the use of the Teddy algorithm. + /// + /// This is only exposed for more precise testing and benchmarks. Callers + /// should not use it as it is not part of the API stability guarantees of + /// this crate. + #[doc(hidden)] + pub fn force_teddy(&mut self, yes: bool) -> &mut Config { + if yes { + self.force = Some(ForceAlgorithm::Teddy); + } else { + self.force = None; + } + self + } + + /// An undocumented method for forcing the use of the Fat Teddy algorithm. + /// + /// This is only exposed for more precise testing and benchmarks. Callers + /// should not use it as it is not part of the API stability guarantees of + /// this crate. + #[doc(hidden)] + pub fn force_teddy_fat(&mut self, yes: Option) -> &mut Config { + self.force_teddy_fat = yes; + self + } + + /// An undocumented method for forcing the use of SSE (`Some(false)`) or + /// AVX (`Some(true)`) algorithms. + /// + /// This is only exposed for more precise testing and benchmarks. Callers + /// should not use it as it is not part of the API stability guarantees of + /// this crate. + #[doc(hidden)] + pub fn force_avx(&mut self, yes: Option) -> &mut Config { + self.force_avx = yes; + self + } + + /// An undocumented method for forcing the use of the Rabin-Karp algorithm. + /// + /// This is only exposed for more precise testing and benchmarks. Callers + /// should not use it as it is not part of the API stability guarantees of + /// this crate. + #[doc(hidden)] + pub fn force_rabin_karp(&mut self, yes: bool) -> &mut Config { + if yes { + self.force = Some(ForceAlgorithm::RabinKarp); + } else { + self.force = None; + } + self + } +} + +/// A builder for constructing a packed searcher from a collection of patterns. +/// +/// # Example +/// +/// This example shows how to use a builder to construct a searcher. By +/// default, leftmost-first match semantics are used. +/// +/// ``` +/// use aho_corasick::packed::{Builder, MatchKind}; +/// +/// # fn example() -> Option<()> { +/// let searcher = Builder::new() +/// .add("foobar") +/// .add("foo") +/// .build()?; +/// let matches: Vec = searcher +/// .find_iter("foobar") +/// .map(|mat| mat.pattern()) +/// .collect(); +/// assert_eq!(vec![0], matches); +/// # Some(()) } +/// # if cfg!(target_arch = "x86_64") { +/// # example().unwrap() +/// # } else { +/// # assert!(example().is_none()); +/// # } +/// ``` +#[derive(Clone, Debug)] +pub struct Builder { + /// The configuration of this builder and subsequent matcher. + config: Config, + /// Set to true if the builder detects that a matcher cannot be built. + inert: bool, + /// The patterns provided by the caller. + patterns: Patterns, +} + +impl Builder { + /// Create a new builder for constructing a multi-pattern searcher. This + /// constructor uses the default configuration. + pub fn new() -> Builder { + Builder::from_config(Config::new()) + } + + fn from_config(config: Config) -> Builder { + Builder { config, inert: false, patterns: Patterns::new() } + } + + /// Build a searcher from the patterns added to this builder so far. + pub fn build(&self) -> Option { + if self.inert || self.patterns.is_empty() { + return None; + } + let mut patterns = self.patterns.clone(); + patterns.set_match_kind(self.config.kind); + let rabinkarp = RabinKarp::new(&patterns); + // Effectively, we only want to return a searcher if we can use Teddy, + // since Teddy is our only fast packed searcher at the moment. + // Rabin-Karp is only used when searching haystacks smaller than what + // Teddy can support. Thus, the only way to get a Rabin-Karp searcher + // is to force it using undocumented APIs (for tests/benchmarks). + let (search_kind, minimum_len) = match self.config.force { + None | Some(ForceAlgorithm::Teddy) => { + let teddy = match self.build_teddy(&patterns) { + None => return None, + Some(teddy) => teddy, + }; + let minimum_len = teddy.minimum_len(); + (SearchKind::Teddy(teddy), minimum_len) + } + Some(ForceAlgorithm::RabinKarp) => (SearchKind::RabinKarp, 0), + }; + Some(Searcher { + config: self.config.clone(), + patterns: patterns, + rabinkarp: rabinkarp, + search_kind, + minimum_len, + }) + } + + fn build_teddy(&self, patterns: &Patterns) -> Option { + teddy::Builder::new() + .avx(self.config.force_avx) + .fat(self.config.force_teddy_fat) + .build(&patterns) + } + + /// Add the given pattern to this set to match. + /// + /// The order in which patterns are added is significant. Namely, when + /// using leftmost-first match semantics, then when multiple patterns can + /// match at a particular location, the pattern that was added first is + /// used as the match. + /// + /// If the number of patterns added exceeds the amount supported by packed + /// searchers, then the builder will stop accumulating patterns and render + /// itself inert. At this point, constructing a searcher will always return + /// `None`. + pub fn add>(&mut self, pattern: P) -> &mut Builder { + if self.inert { + return self; + } else if self.patterns.len() >= PATTERN_LIMIT { + self.inert = true; + self.patterns.reset(); + return self; + } + // Just in case PATTERN_LIMIT increases beyond u16::MAX. + assert!(self.patterns.len() <= u16::MAX as usize); + + let pattern = pattern.as_ref(); + if pattern.is_empty() { + self.inert = true; + self.patterns.reset(); + return self; + } + self.patterns.add(pattern); + self + } + + /// Add the given iterator of patterns to this set to match. + /// + /// The iterator must yield elements that can be converted into a `&[u8]`. + /// + /// The order in which patterns are added is significant. Namely, when + /// using leftmost-first match semantics, then when multiple patterns can + /// match at a particular location, the pattern that was added first is + /// used as the match. + /// + /// If the number of patterns added exceeds the amount supported by packed + /// searchers, then the builder will stop accumulating patterns and render + /// itself inert. At this point, constructing a searcher will always return + /// `None`. + pub fn extend(&mut self, patterns: I) -> &mut Builder + where + I: IntoIterator, + P: AsRef<[u8]>, + { + for p in patterns { + self.add(p); + } + self + } +} + +impl Default for Builder { + fn default() -> Builder { + Builder::new() + } +} + +/// A packed searcher for quickly finding occurrences of multiple patterns. +/// +/// If callers need more flexible construction, or if one wants to change the +/// match semantics (either leftmost-first or leftmost-longest), then one can +/// use the [`Config`](struct.Config.html) and/or +/// [`Builder`](struct.Builder.html) types for more fine grained control. +/// +/// # Example +/// +/// This example shows how to create a searcher from an iterator of patterns. +/// By default, leftmost-first match semantics are used. +/// +/// ``` +/// use aho_corasick::packed::{MatchKind, Searcher}; +/// +/// # fn example() -> Option<()> { +/// let searcher = Searcher::new(["foobar", "foo"].iter().cloned())?; +/// let matches: Vec = searcher +/// .find_iter("foobar") +/// .map(|mat| mat.pattern()) +/// .collect(); +/// assert_eq!(vec![0], matches); +/// # Some(()) } +/// # if cfg!(target_arch = "x86_64") { +/// # example().unwrap() +/// # } else { +/// # assert!(example().is_none()); +/// # } +/// ``` +#[derive(Clone, Debug)] +pub struct Searcher { + config: Config, + patterns: Patterns, + rabinkarp: RabinKarp, + search_kind: SearchKind, + minimum_len: usize, +} + +#[derive(Clone, Debug)] +enum SearchKind { + Teddy(Teddy), + RabinKarp, +} + +impl Searcher { + /// A convenience function for constructing a searcher from an iterator + /// of things that can be converted to a `&[u8]`. + /// + /// If a searcher could not be constructed (either because of an + /// unsupported CPU or because there are too many patterns), then `None` + /// is returned. + /// + /// # Example + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::packed::{MatchKind, Searcher}; + /// + /// # fn example() -> Option<()> { + /// let searcher = Searcher::new(["foobar", "foo"].iter().cloned())?; + /// let matches: Vec = searcher + /// .find_iter("foobar") + /// .map(|mat| mat.pattern()) + /// .collect(); + /// assert_eq!(vec![0], matches); + /// # Some(()) } + /// # if cfg!(target_arch = "x86_64") { + /// # example().unwrap() + /// # } else { + /// # assert!(example().is_none()); + /// # } + /// ``` + pub fn new(patterns: I) -> Option + where + I: IntoIterator, + P: AsRef<[u8]>, + { + Builder::new().extend(patterns).build() + } + + /// Return the first occurrence of any of the patterns in this searcher, + /// according to its match semantics, in the given haystack. The `Match` + /// returned will include the identifier of the pattern that matched, which + /// corresponds to the index of the pattern (starting from `0`) in which it + /// was added. + /// + /// # Example + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::packed::{MatchKind, Searcher}; + /// + /// # fn example() -> Option<()> { + /// let searcher = Searcher::new(["foobar", "foo"].iter().cloned())?; + /// let mat = searcher.find("foobar")?; + /// assert_eq!(0, mat.pattern()); + /// assert_eq!(0, mat.start()); + /// assert_eq!(6, mat.end()); + /// # Some(()) } + /// # if cfg!(target_arch = "x86_64") { + /// # example().unwrap() + /// # } else { + /// # assert!(example().is_none()); + /// # } + /// ``` + pub fn find>(&self, haystack: B) -> Option { + self.find_at(haystack, 0) + } + + /// Return the first occurrence of any of the patterns in this searcher, + /// according to its match semantics, in the given haystack starting from + /// the given position. + /// + /// The `Match` returned will include the identifier of the pattern that + /// matched, which corresponds to the index of the pattern (starting from + /// `0`) in which it was added. The offsets in the `Match` will be relative + /// to the start of `haystack` (and not `at`). + /// + /// # Example + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::packed::{MatchKind, Searcher}; + /// + /// # fn example() -> Option<()> { + /// let searcher = Searcher::new(["foobar", "foo"].iter().cloned())?; + /// let mat = searcher.find_at("foofoobar", 3)?; + /// assert_eq!(0, mat.pattern()); + /// assert_eq!(3, mat.start()); + /// assert_eq!(9, mat.end()); + /// # Some(()) } + /// # if cfg!(target_arch = "x86_64") { + /// # example().unwrap() + /// # } else { + /// # assert!(example().is_none()); + /// # } + /// ``` + pub fn find_at>( + &self, + haystack: B, + at: usize, + ) -> Option { + let haystack = haystack.as_ref(); + match self.search_kind { + SearchKind::Teddy(ref teddy) => { + if haystack[at..].len() < teddy.minimum_len() { + return self.slow_at(haystack, at); + } + teddy.find_at(&self.patterns, haystack, at) + } + SearchKind::RabinKarp => { + self.rabinkarp.find_at(&self.patterns, haystack, at) + } + } + } + + /// Return an iterator of non-overlapping occurrences of the patterns in + /// this searcher, according to its match semantics, in the given haystack. + /// + /// # Example + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::packed::{MatchKind, Searcher}; + /// + /// # fn example() -> Option<()> { + /// let searcher = Searcher::new(["foobar", "foo"].iter().cloned())?; + /// let matches: Vec = searcher + /// .find_iter("foobar fooba foofoo") + /// .map(|mat| mat.pattern()) + /// .collect(); + /// assert_eq!(vec![0, 1, 1, 1], matches); + /// # Some(()) } + /// # if cfg!(target_arch = "x86_64") { + /// # example().unwrap() + /// # } else { + /// # assert!(example().is_none()); + /// # } + /// ``` + pub fn find_iter<'a, 'b, B: ?Sized + AsRef<[u8]>>( + &'a self, + haystack: &'b B, + ) -> FindIter<'a, 'b> { + FindIter { searcher: self, haystack: haystack.as_ref(), at: 0 } + } + + /// Returns the match kind used by this packed searcher. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use aho_corasick::packed::{MatchKind, Searcher}; + /// + /// # fn example() -> Option<()> { + /// let searcher = Searcher::new(["foobar", "foo"].iter().cloned())?; + /// // leftmost-first is the default. + /// assert_eq!(&MatchKind::LeftmostFirst, searcher.match_kind()); + /// # Some(()) } + /// # if cfg!(target_arch = "x86_64") { + /// # example().unwrap() + /// # } else { + /// # assert!(example().is_none()); + /// # } + /// ``` + pub fn match_kind(&self) -> &MatchKind { + self.patterns.match_kind() + } + + /// Returns the minimum length of a haystack that is required in order for + /// packed searching to be effective. + /// + /// In some cases, the underlying packed searcher may not be able to search + /// very short haystacks. When that occurs, the implementation will defer + /// to a slower non-packed searcher (which is still generally faster than + /// Aho-Corasick for a small number of patterns). However, callers may + /// want to avoid ever using the slower variant, which one can do by + /// never passing a haystack shorter than the minimum length returned by + /// this method. + pub fn minimum_len(&self) -> usize { + self.minimum_len + } + + /// Returns the approximate total amount of heap used by this searcher, in + /// units of bytes. + pub fn heap_bytes(&self) -> usize { + self.patterns.heap_bytes() + + self.rabinkarp.heap_bytes() + + self.search_kind.heap_bytes() + } + + /// Use a slow (non-packed) searcher. + /// + /// This is useful when a packed searcher could be constructed, but could + /// not be used to search a specific haystack. For example, if Teddy was + /// built but the haystack is smaller than ~34 bytes, then Teddy might not + /// be able to run. + fn slow_at(&self, haystack: &[u8], at: usize) -> Option { + self.rabinkarp.find_at(&self.patterns, haystack, at) + } +} + +impl SearchKind { + fn heap_bytes(&self) -> usize { + match *self { + SearchKind::Teddy(ref ted) => ted.heap_bytes(), + SearchKind::RabinKarp => 0, + } + } +} + +/// An iterator over non-overlapping matches from a packed searcher. +/// +/// The lifetime `'s` refers to the lifetime of the underlying +/// [`Searcher`](struct.Searcher.html), while the lifetime `'h` refers to the +/// lifetime of the haystack being searched. +#[derive(Debug)] +pub struct FindIter<'s, 'h> { + searcher: &'s Searcher, + haystack: &'h [u8], + at: usize, +} + +impl<'s, 'h> Iterator for FindIter<'s, 'h> { + type Item = Match; + + fn next(&mut self) -> Option { + if self.at > self.haystack.len() { + return None; + } + match self.searcher.find_at(&self.haystack, self.at) { + None => None, + Some(c) => { + self.at = c.end; + Some(c) + } + } + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/mod.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/mod.rs new file mode 100644 index 0000000..5a3aa2e --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/mod.rs @@ -0,0 +1,117 @@ +/*! +A lower level API for packed multiple substring search, principally for a small +number of patterns. + +This sub-module provides vectorized routines for quickly finding matches of a +small number of patterns. In general, users of this crate shouldn't need to +interface with this module directory, as the primary +[`AhoCorasick`](../struct.AhoCorasick.html) +searcher will use these routines automatically as a prefilter when applicable. +However, in some cases, callers may want to bypass the Aho-Corasick machinery +entirely and use this vectorized searcher directly. + +# Overview + +The primary types in this sub-module are: + +* [`Searcher`](struct.Searcher.html) executes the actual search algorithm to + report matches in a haystack. +* [`Builder`](struct.Builder.html) accumulates patterns incrementally and can + construct a `Searcher`. +* [`Config`](struct.Config.html) permits tuning the searcher, and itself will + produce a `Builder` (which can then be used to build a `Searcher`). + Currently, the only tuneable knob are the match semantics, but this may be + expanded in the future. + +# Examples + +This example shows how to create a searcher from an iterator of patterns. +By default, leftmost-first match semantics are used. (See the top-level +[`MatchKind`](../enum.MatchKind.html) type for more details about match +semantics, which apply similarly to packed substring search.) + +``` +use aho_corasick::packed::{MatchKind, Searcher}; + +# fn example() -> Option<()> { +let searcher = Searcher::new(["foobar", "foo"].iter().cloned())?; +let matches: Vec = searcher + .find_iter("foobar") + .map(|mat| mat.pattern()) + .collect(); +assert_eq!(vec![0], matches); +# Some(()) } +# if cfg!(target_arch = "x86_64") { +# example().unwrap() +# } else { +# assert!(example().is_none()); +# } +``` + +This example shows how to use [`Config`](struct.Config.html) to change the +match semantics to leftmost-longest: + +``` +use aho_corasick::packed::{Config, MatchKind}; + +# fn example() -> Option<()> { +let searcher = Config::new() + .match_kind(MatchKind::LeftmostLongest) + .builder() + .add("foo") + .add("foobar") + .build()?; +let matches: Vec = searcher + .find_iter("foobar") + .map(|mat| mat.pattern()) + .collect(); +assert_eq!(vec![1], matches); +# Some(()) } +# if cfg!(target_arch = "x86_64") { +# example().unwrap() +# } else { +# assert!(example().is_none()); +# } +``` + +# Packed substring searching + +Packed substring searching refers to the use of SIMD (Single Instruction, +Multiple Data) to accelerate the detection of matches in a haystack. Unlike +conventional algorithms, such as Aho-Corasick, SIMD algorithms for substring +search tend to do better with a small number of patterns, where as Aho-Corasick +generally maintains reasonably consistent performance regardless of the number +of patterns you give it. Because of this, the vectorized searcher in this +sub-module cannot be used as a general purpose searcher, since building the +searcher may fail. However, in exchange, when searching for a small number of +patterns, searching can be quite a bit faster than Aho-Corasick (sometimes by +an order of magnitude). + +The key take away here is that constructing a searcher from a list of patterns +is a fallible operation. While the precise conditions under which building a +searcher can fail is specifically an implementation detail, here are some +common reasons: + +* Too many patterns were given. Typically, the limit is on the order of 100 or + so, but this limit may fluctuate based on available CPU features. +* The available packed algorithms require CPU features that aren't available. + For example, currently, this crate only provides packed algorithms for + `x86_64`. Therefore, constructing a packed searcher on any other target + (e.g., ARM) will always fail. +* Zero patterns were given, or one of the patterns given was empty. Packed + searchers require at least one pattern and that all patterns are non-empty. +* Something else about the nature of the patterns (typically based on + heuristics) suggests that a packed searcher would perform very poorly, so + no searcher is built. +*/ + +pub use packed::api::{Builder, Config, FindIter, MatchKind, Searcher}; + +mod api; +mod pattern; +mod rabinkarp; +mod teddy; +#[cfg(test)] +mod tests; +#[cfg(target_arch = "x86_64")] +mod vector; diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/pattern.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/pattern.rs new file mode 100644 index 0000000..dfb07e9 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/pattern.rs @@ -0,0 +1,318 @@ +use std::cmp; +use std::fmt; +use std::mem; +use std::u16; +use std::usize; + +use packed::api::MatchKind; + +/// The type used for representing a pattern identifier. +/// +/// We don't use `usize` here because our packed searchers don't scale to +/// huge numbers of patterns, so we keep things a bit smaller. +pub type PatternID = u16; + +/// A non-empty collection of non-empty patterns to search for. +/// +/// This collection of patterns is what is passed around to both execute +/// searches and to construct the searchers themselves. Namely, this permits +/// searches to avoid copying all of the patterns, and allows us to keep only +/// one copy throughout all packed searchers. +/// +/// Note that this collection is not a set. The same pattern can appear more +/// than once. +#[derive(Clone, Debug)] +pub struct Patterns { + /// The match semantics supported by this collection of patterns. + /// + /// The match semantics determines the order of the iterator over patterns. + /// For leftmost-first, patterns are provided in the same order as were + /// provided by the caller. For leftmost-longest, patterns are provided in + /// descending order of length, with ties broken by the order in which they + /// were provided by the caller. + kind: MatchKind, + /// The collection of patterns, indexed by their identifier. + by_id: Vec>, + /// The order of patterns defined for iteration, given by pattern + /// identifiers. The order of `by_id` and `order` is always the same for + /// leftmost-first semantics, but may be different for leftmost-longest + /// semantics. + order: Vec, + /// The length of the smallest pattern, in bytes. + minimum_len: usize, + /// The largest pattern identifier. This should always be equivalent to + /// the number of patterns minus one in this collection. + max_pattern_id: PatternID, + /// The total number of pattern bytes across the entire collection. This + /// is used for reporting total heap usage in constant time. + total_pattern_bytes: usize, +} + +impl Patterns { + /// Create a new collection of patterns for the given match semantics. The + /// ID of each pattern is the index of the pattern at which it occurs in + /// the `by_id` slice. + /// + /// If any of the patterns in the slice given are empty, then this panics. + /// Similarly, if the number of patterns given is zero, then this also + /// panics. + pub fn new() -> Patterns { + Patterns { + kind: MatchKind::default(), + by_id: vec![], + order: vec![], + minimum_len: usize::MAX, + max_pattern_id: 0, + total_pattern_bytes: 0, + } + } + + /// Add a pattern to this collection. + /// + /// This panics if the pattern given is empty. + pub fn add(&mut self, bytes: &[u8]) { + assert!(!bytes.is_empty()); + assert!(self.by_id.len() <= u16::MAX as usize); + + let id = self.by_id.len() as u16; + self.max_pattern_id = id; + self.order.push(id); + self.by_id.push(bytes.to_vec()); + self.minimum_len = cmp::min(self.minimum_len, bytes.len()); + self.total_pattern_bytes += bytes.len(); + } + + /// Set the match kind semantics for this collection of patterns. + /// + /// If the kind is not set, then the default is leftmost-first. + pub fn set_match_kind(&mut self, kind: MatchKind) { + match kind { + MatchKind::LeftmostFirst => { + self.order.sort(); + } + MatchKind::LeftmostLongest => { + let (order, by_id) = (&mut self.order, &mut self.by_id); + order.sort_by(|&id1, &id2| { + by_id[id1 as usize] + .len() + .cmp(&by_id[id2 as usize].len()) + .reverse() + }); + } + MatchKind::__Nonexhaustive => unreachable!(), + } + } + + /// Return the number of patterns in this collection. + /// + /// This is guaranteed to be greater than zero. + pub fn len(&self) -> usize { + self.by_id.len() + } + + /// Returns true if and only if this collection of patterns is empty. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Returns the approximate total amount of heap used by these patterns, in + /// units of bytes. + pub fn heap_bytes(&self) -> usize { + self.order.len() * mem::size_of::() + + self.by_id.len() * mem::size_of::>() + + self.total_pattern_bytes + } + + /// Clears all heap memory associated with this collection of patterns and + /// resets all state such that it is a valid empty collection. + pub fn reset(&mut self) { + self.kind = MatchKind::default(); + self.by_id.clear(); + self.order.clear(); + self.minimum_len = usize::MAX; + self.max_pattern_id = 0; + } + + /// Return the maximum pattern identifier in this collection. This can be + /// useful in searchers for ensuring that the collection of patterns they + /// are provided at search time and at build time have the same size. + pub fn max_pattern_id(&self) -> PatternID { + assert_eq!((self.max_pattern_id + 1) as usize, self.len()); + self.max_pattern_id + } + + /// Returns the length, in bytes, of the smallest pattern. + /// + /// This is guaranteed to be at least one. + pub fn minimum_len(&self) -> usize { + self.minimum_len + } + + /// Returns the match semantics used by these patterns. + pub fn match_kind(&self) -> &MatchKind { + &self.kind + } + + /// Return the pattern with the given identifier. If such a pattern does + /// not exist, then this panics. + pub fn get(&self, id: PatternID) -> Pattern { + Pattern(&self.by_id[id as usize]) + } + + /// Return the pattern with the given identifier without performing bounds + /// checks. + /// + /// # Safety + /// + /// Callers must ensure that a pattern with the given identifier exists + /// before using this method. + #[cfg(target_arch = "x86_64")] + pub unsafe fn get_unchecked(&self, id: PatternID) -> Pattern { + Pattern(self.by_id.get_unchecked(id as usize)) + } + + /// Return an iterator over all the patterns in this collection, in the + /// order in which they should be matched. + /// + /// Specifically, in a naive multi-pattern matcher, the following is + /// guaranteed to satisfy the match semantics of this collection of + /// patterns: + /// + /// ```ignore + /// for i in 0..haystack.len(): + /// for p in patterns.iter(): + /// if haystack[i..].starts_with(p.bytes()): + /// return Match(p.id(), i, i + p.bytes().len()) + /// ``` + /// + /// Namely, among the patterns in a collection, if they are matched in + /// the order provided by this iterator, then the result is guaranteed + /// to satisfy the correct match semantics. (Either leftmost-first or + /// leftmost-longest.) + pub fn iter(&self) -> PatternIter { + PatternIter { patterns: self, i: 0 } + } +} + +/// An iterator over the patterns in the `Patterns` collection. +/// +/// The order of the patterns provided by this iterator is consistent with the +/// match semantics of the originating collection of patterns. +/// +/// The lifetime `'p` corresponds to the lifetime of the collection of patterns +/// this is iterating over. +#[derive(Debug)] +pub struct PatternIter<'p> { + patterns: &'p Patterns, + i: usize, +} + +impl<'p> Iterator for PatternIter<'p> { + type Item = (PatternID, Pattern<'p>); + + fn next(&mut self) -> Option<(PatternID, Pattern<'p>)> { + if self.i >= self.patterns.len() { + return None; + } + let id = self.patterns.order[self.i]; + let p = self.patterns.get(id); + self.i += 1; + Some((id, p)) + } +} + +/// A pattern that is used in packed searching. +#[derive(Clone)] +pub struct Pattern<'a>(&'a [u8]); + +impl<'a> fmt::Debug for Pattern<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Pattern") + .field("lit", &String::from_utf8_lossy(&self.0)) + .finish() + } +} + +impl<'p> Pattern<'p> { + /// Returns the length of this pattern, in bytes. + pub fn len(&self) -> usize { + self.0.len() + } + + /// Returns the bytes of this pattern. + pub fn bytes(&self) -> &[u8] { + &self.0 + } + + /// Returns the first `len` low nybbles from this pattern. If this pattern + /// is shorter than `len`, then this panics. + #[cfg(target_arch = "x86_64")] + pub fn low_nybbles(&self, len: usize) -> Vec { + let mut nybs = vec![]; + for &b in self.bytes().iter().take(len) { + nybs.push(b & 0xF); + } + nybs + } + + /// Returns true if this pattern is a prefix of the given bytes. + #[inline(always)] + pub fn is_prefix(&self, bytes: &[u8]) -> bool { + self.len() <= bytes.len() && self.equals(&bytes[..self.len()]) + } + + /// Returns true if and only if this pattern equals the given bytes. + #[inline(always)] + pub fn equals(&self, bytes: &[u8]) -> bool { + // Why not just use memcmp for this? Well, memcmp requires calling out + // to libc, and this routine is called in fairly hot code paths. Other + // than just calling out to libc, it also seems to result in worse + // codegen. By rolling our own memcpy in pure Rust, it seems to appear + // more friendly to the optimizer. + // + // This results in an improvement in just about every benchmark. Some + // smaller than others, but in some cases, up to 30% faster. + + if self.len() != bytes.len() { + return false; + } + if self.len() < 8 { + for (&b1, &b2) in self.bytes().iter().zip(bytes) { + if b1 != b2 { + return false; + } + } + return true; + } + // When we have 8 or more bytes to compare, then proceed in chunks of + // 8 at a time using unaligned loads. + let mut p1 = self.bytes().as_ptr(); + let mut p2 = bytes.as_ptr(); + let p1end = self.bytes()[self.len() - 8..].as_ptr(); + let p2end = bytes[bytes.len() - 8..].as_ptr(); + // SAFETY: Via the conditional above, we know that both `p1` and `p2` + // have the same length, so `p1 < p1end` implies that `p2 < p2end`. + // Thus, derefencing both `p1` and `p2` in the loop below is safe. + // + // Moreover, we set `p1end` and `p2end` to be 8 bytes before the actual + // end of of `p1` and `p2`. Thus, the final dereference outside of the + // loop is guaranteed to be valid. + // + // Finally, we needn't worry about 64-bit alignment here, since we + // do unaligned loads. + unsafe { + while p1 < p1end { + let v1 = (p1 as *const u64).read_unaligned(); + let v2 = (p2 as *const u64).read_unaligned(); + if v1 != v2 { + return false; + } + p1 = p1.add(8); + p2 = p2.add(8); + } + let v1 = (p1end as *const u64).read_unaligned(); + let v2 = (p2end as *const u64).read_unaligned(); + v1 == v2 + } + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/rabinkarp.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/rabinkarp.rs new file mode 100644 index 0000000..3992296 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/rabinkarp.rs @@ -0,0 +1,185 @@ +use std::mem; + +use packed::pattern::{PatternID, Patterns}; +use Match; + +/// The type of the rolling hash used in the Rabin-Karp algorithm. +type Hash = usize; + +/// The number of buckets to store our patterns in. We don't want this to be +/// too big in order to avoid wasting memory, but we don't want it to be too +/// small either to avoid spending too much time confirming literals. +/// +/// The number of buckets MUST be a power of two. Otherwise, determining the +/// bucket from a hash will slow down the code considerably. Using a power +/// of two means `hash % NUM_BUCKETS` can compile down to a simple `and` +/// instruction. +const NUM_BUCKETS: usize = 64; + +/// An implementation of the Rabin-Karp algorithm. The main idea of this +/// algorithm is to maintain a rolling hash as it moves through the input, and +/// then check whether that hash corresponds to the same hash for any of the +/// patterns we're looking for. +/// +/// A draw back of naively scaling Rabin-Karp to multiple patterns is that +/// it requires all of the patterns to be the same length, which in turn +/// corresponds to the number of bytes to hash. We adapt this to work for +/// multiple patterns of varying size by fixing the number of bytes to hash +/// to be the length of the smallest pattern. We also split the patterns into +/// several buckets to hopefully make the confirmation step faster. +/// +/// Wikipedia has a decent explanation, if a bit heavy on the theory: +/// https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm +/// +/// But ESMAJ provides something a bit more concrete: +/// http://www-igm.univ-mlv.fr/~lecroq/string/node5.html +#[derive(Clone, Debug)] +pub struct RabinKarp { + /// The order of patterns in each bucket is significant. Namely, they are + /// arranged such that the first one to match is the correct match. This + /// may not necessarily correspond to the order provided by the caller. + /// For example, if leftmost-longest semantics are used, then the patterns + /// are sorted by their length in descending order. If leftmost-first + /// semantics are used, then the patterns are sorted by their pattern ID + /// in ascending order (which corresponds to the caller's order). + buckets: Vec>, + /// The length of the hashing window. Generally, this corresponds to the + /// length of the smallest pattern. + hash_len: usize, + /// The factor to subtract out of a hash before updating it with a new + /// byte. + hash_2pow: usize, + /// The maximum identifier of a pattern. This is used as a sanity check + /// to ensure that the patterns provided by the caller are the same as + /// the patterns that were used to compile the matcher. This sanity check + /// possibly permits safely eliminating bounds checks regardless of what + /// patterns are provided by the caller. + /// + /// (Currently, we don't use this to elide bounds checks since it doesn't + /// result in a measurable performance improvement, but we do use it for + /// better failure modes.) + max_pattern_id: PatternID, +} + +impl RabinKarp { + /// Compile a new Rabin-Karp matcher from the patterns given. + /// + /// This panics if any of the patterns in the collection are empty, or if + /// the collection is itself empty. + pub fn new(patterns: &Patterns) -> RabinKarp { + assert!(patterns.len() >= 1); + let hash_len = patterns.minimum_len(); + assert!(hash_len >= 1); + + let mut hash_2pow = 1usize; + for _ in 1..hash_len { + hash_2pow = hash_2pow.wrapping_shl(1); + } + + let mut rk = RabinKarp { + buckets: vec![vec![]; NUM_BUCKETS], + hash_len, + hash_2pow, + max_pattern_id: patterns.max_pattern_id(), + }; + for (id, pat) in patterns.iter() { + let hash = rk.hash(&pat.bytes()[..rk.hash_len]); + let bucket = hash % NUM_BUCKETS; + rk.buckets[bucket].push((hash, id)); + } + rk + } + + /// Return the first matching pattern in the given haystack, begining the + /// search at `at`. + pub fn find_at( + &self, + patterns: &Patterns, + haystack: &[u8], + mut at: usize, + ) -> Option { + assert_eq!(NUM_BUCKETS, self.buckets.len()); + assert_eq!( + self.max_pattern_id, + patterns.max_pattern_id(), + "Rabin-Karp must be called with same patterns it was built with", + ); + + if at + self.hash_len > haystack.len() { + return None; + } + let mut hash = self.hash(&haystack[at..at + self.hash_len]); + loop { + let bucket = &self.buckets[hash % NUM_BUCKETS]; + for &(phash, pid) in bucket { + if phash == hash { + if let Some(c) = self.verify(patterns, pid, haystack, at) { + return Some(c); + } + } + } + if at + self.hash_len >= haystack.len() { + return None; + } + hash = self.update_hash( + hash, + haystack[at], + haystack[at + self.hash_len], + ); + at += 1; + } + } + + /// Returns the approximate total amount of heap used by this searcher, in + /// units of bytes. + pub fn heap_bytes(&self) -> usize { + let num_patterns = self.max_pattern_id as usize + 1; + self.buckets.len() * mem::size_of::>() + + num_patterns * mem::size_of::<(Hash, PatternID)>() + } + + /// Verify whether the pattern with the given id matches at + /// `haystack[at..]`. + /// + /// We tag this function as `cold` because it helps improve codegen. + /// Intuitively, it would seem like inlining it would be better. However, + /// the only time this is called and a match is not found is when there + /// there is a hash collision, or when a prefix of a pattern matches but + /// the entire pattern doesn't match. This is hopefully fairly rare, and + /// if it does occur a lot, it's going to be slow no matter what we do. + #[cold] + fn verify( + &self, + patterns: &Patterns, + id: PatternID, + haystack: &[u8], + at: usize, + ) -> Option { + let pat = patterns.get(id); + if pat.is_prefix(&haystack[at..]) { + Some(Match::from_span(id as usize, at, at + pat.len())) + } else { + None + } + } + + /// Hash the given bytes. + fn hash(&self, bytes: &[u8]) -> Hash { + assert_eq!(self.hash_len, bytes.len()); + + let mut hash = 0usize; + for &b in bytes { + hash = hash.wrapping_shl(1).wrapping_add(b as usize); + } + hash + } + + /// Update the hash given based on removing `old_byte` at the beginning + /// of some byte string, and appending `new_byte` to the end of that same + /// byte string. + fn update_hash(&self, prev: Hash, old_byte: u8, new_byte: u8) -> Hash { + prev.wrapping_sub((old_byte as usize).wrapping_mul(self.hash_2pow)) + .wrapping_shl(1) + .wrapping_add(new_byte as usize) + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/README.md b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/README.md new file mode 100644 index 0000000..0c42383 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/README.md @@ -0,0 +1,386 @@ +Teddy is a simd accelerated multiple substring matching algorithm. The name +and the core ideas in the algorithm were learned from the [Hyperscan][1_u] +project. The implementation in this repository was mostly motivated for use in +accelerating regex searches by searching for small sets of required literals +extracted from the regex. + + +# Background + +The key idea of Teddy is to do *packed* substring matching. In the literature, +packed substring matching is the idea of examining multiple bytes in a haystack +at a time to detect matches. Implementations of, for example, memchr (which +detects matches of a single byte) have been doing this for years. Only +recently, with the introduction of various SIMD instructions, has this been +extended to substring matching. The PCMPESTRI instruction (and its relatives), +for example, implements substring matching in hardware. It is, however, limited +to substrings of length 16 bytes or fewer, but this restriction is fine in a +regex engine, since we rarely care about the performance difference between +searching for a 16 byte literal and a 16 + N literal; 16 is already long +enough. The key downside of the PCMPESTRI instruction, on current (2016) CPUs +at least, is its latency and throughput. As a result, it is often faster to +do substring search with a Boyer-Moore (or Two-Way) variant and a well placed +memchr to quickly skip through the haystack. + +There are fewer results from the literature on packed substring matching, +and even fewer for packed multiple substring matching. Ben-Kiki et al. [2] +describes use of PCMPESTRI for substring matching, but is mostly theoretical +and hand-waves performance. There is other theoretical work done by Bille [3] +as well. + +The rest of the work in the field, as far as I'm aware, is by Faro and Kulekci +and is generally focused on multiple pattern search. Their first paper [4a] +introduces the concept of a fingerprint, which is computed for every block of +N bytes in every pattern. The haystack is then scanned N bytes at a time and +a fingerprint is computed in the same way it was computed for blocks in the +patterns. If the fingerprint corresponds to one that was found in a pattern, +then a verification step follows to confirm that one of the substrings with the +corresponding fingerprint actually matches at the current location. Various +implementation tricks are employed to make sure the fingerprint lookup is fast; +typically by truncating the fingerprint. (This may, of course, provoke more +steps in the verification process, so a balance must be struck.) + +The main downside of [4a] is that the minimum substring length is 32 bytes, +presumably because of how the algorithm uses certain SIMD instructions. This +essentially makes it useless for general purpose regex matching, where a small +number of short patterns is far more likely. + +Faro and Kulekci published another paper [4b] that is conceptually very similar +to [4a]. The key difference is that it uses the CRC32 instruction (introduced +as part of SSE 4.2) to compute fingerprint values. This also enables the +algorithm to work effectively on substrings as short as 7 bytes with 4 byte +windows. 7 bytes is unfortunately still too long. The window could be +technically shrunk to 2 bytes, thereby reducing minimum length to 3, but the +small window size ends up negating most performance benefits—and it's likely +the common case in a general purpose regex engine. + +Faro and Kulekci also published [4c] that appears to be intended as a +replacement to using PCMPESTRI. In particular, it is specifically motivated by +the high throughput/latency time of PCMPESTRI and therefore chooses other SIMD +instructions that are faster. While this approach works for short substrings, +I personally couldn't see a way to generalize it to multiple substring search. + +Faro and Kulekci have another paper [4d] that I haven't been able to read +because it is behind a paywall. + + +# Teddy + +Finally, we get to Teddy. If the above literature review is complete, then it +appears that Teddy is a novel algorithm. More than that, in my experience, it +completely blows away the competition for short substrings, which is exactly +what we want in a general purpose regex engine. Again, the algorithm appears +to be developed by the authors of [Hyperscan][1_u]. Hyperscan was open sourced +late 2015, and no earlier history could be found. Therefore, tracking the exact +provenance of the algorithm with respect to the published literature seems +difficult. + +At a high level, Teddy works somewhat similarly to the fingerprint algorithms +published by Faro and Kulekci, but Teddy does it in a way that scales a bit +better. Namely: + +1. Teddy's core algorithm scans the haystack in 16 (for SSE, or 32 for AVX) + byte chunks. 16 (or 32) is significant because it corresponds to the number + of bytes in a SIMD vector. +2. Bitwise operations are performed on each chunk to discover if any region of + it matches a set of precomputed fingerprints from the patterns. If there are + matches, then a verification step is performed. In this implementation, our + verification step is naive. This can be improved upon. + +The details to make this work are quite clever. First, we must choose how to +pick our fingerprints. In Hyperscan's implementation, I *believe* they use the +last N bytes of each substring, where N must be at least the minimum length of +any substring in the set being searched. In this implementation, we use the +first N bytes of each substring. (The tradeoffs between these choices aren't +yet clear to me.) We then must figure out how to quickly test whether an +occurrence of any fingerprint from the set of patterns appears in a 16 byte +block from the haystack. To keep things simple, let's assume N = 1 and examine +some examples to motivate the approach. Here are our patterns: + +```ignore +foo +bar +baz +``` + +The corresponding fingerprints, for N = 1, are `f`, `b` and `b`. Now let's set +our 16 byte block to: + +```ignore +bat cat foo bump +xxxxxxxxxxxxxxxx +``` + +To cut to the chase, Teddy works by using bitsets. In particular, Teddy creates +a mask that allows us to quickly compute membership of a fingerprint in a 16 +byte block that also tells which pattern the fingerprint corresponds to. In +this case, our fingerprint is a single byte, so an appropriate abstraction is +a map from a single byte to a list of patterns that contain that fingerprint: + +```ignore +f |--> foo +b |--> bar, baz +``` + +Now, all we need to do is figure out how to represent this map in vector space +and use normal SIMD operations to perform a lookup. The first simplification +we can make is to represent our patterns as bit fields occupying a single +byte. This is important, because a single SIMD vector can store 16 bytes. + +```ignore +f |--> 00000001 +b |--> 00000010, 00000100 +``` + +How do we perform lookup though? It turns out that SSSE3 introduced a very cool +instruction called PSHUFB. The instruction takes two SIMD vectors, `A` and `B`, +and returns a third vector `C`. All vectors are treated as 16 8-bit integers. +`C` is formed by `C[i] = A[B[i]]`. (This is a bit of a simplification, but true +for the purposes of this algorithm. For full details, see [Intel's Intrinsics +Guide][5_u].) This essentially lets us use the values in `B` to lookup values +in `A`. + +If we could somehow cause `B` to contain our 16 byte block from the haystack, +and if `A` could contain our bitmasks, then we'd end up with something like +this for `A`: + +```ignore + 0x00 0x01 ... 0x62 ... 0x66 ... 0xFF +A = 0 0 00000110 00000001 0 +``` + +And if `B` contains our window from our haystack, we could use shuffle to take +the values from `B` and use them to look up our bitsets in `A`. But of course, +we can't do this because `A` in the above example contains 256 bytes, which +is much larger than the size of a SIMD vector. + +Nybbles to the rescue! A nybble is 4 bits. Instead of one mask to hold all of +our bitsets, we can use two masks, where one mask corresponds to the lower four +bits of our fingerprint and the other mask corresponds to the upper four bits. +So our map now looks like: + +```ignore +'f' & 0xF = 0x6 |--> 00000001 +'f' >> 4 = 0x6 |--> 00000111 +'b' & 0xF = 0x2 |--> 00000110 +'b' >> 4 = 0x6 |--> 00000111 +``` + +Notice that the bitsets for each nybble correspond to the union of all +fingerprints that contain that nybble. For example, both `f` and `b` have the +same upper 4 bits but differ on the lower 4 bits. Putting this together, we +have `A0`, `A1` and `B`, where `A0` is our mask for the lower nybble, `A1` is +our mask for the upper nybble and `B` is our 16 byte block from the haystack: + +```ignore + 0x00 0x01 0x02 0x03 ... 0x06 ... 0xF +A0 = 0 0 00000110 0 00000001 0 +A1 = 0 0 0 0 00000111 0 +B = b a t _ t p +B = 0x62 0x61 0x74 0x20 0x74 0x70 +``` + +But of course, we can't use `B` with `PSHUFB` yet, since its values are 8 bits, +and we need indexes that are at most 4 bits (corresponding to one of 16 +values). We can apply the same transformation to split `B` into lower and upper +nybbles as we did `A`. As before, `B0` corresponds to the lower nybbles and +`B1` corresponds to the upper nybbles: + +```ignore + b a t _ c a t _ f o o _ b u m p +B0 = 0x2 0x1 0x4 0x0 0x3 0x1 0x4 0x0 0x6 0xF 0xF 0x0 0x2 0x5 0xD 0x0 +B1 = 0x6 0x6 0x7 0x2 0x6 0x6 0x7 0x2 0x6 0x6 0x6 0x2 0x6 0x7 0x6 0x7 +``` + +And now we have a nice correspondence. `B0` can index `A0` and `B1` can index +`A1`. Here's what we get when we apply `C0 = PSHUFB(A0, B0)`: + +```ignore + b a ... f o ... p + A0[0x2] A0[0x1] A0[0x6] A0[0xF] A0[0x0] +C0 = 00000110 0 00000001 0 0 +``` + +And `C1 = PSHUFB(A1, B1)`: + +```ignore + b a ... f o ... p + A1[0x6] A1[0x6] A1[0x6] A1[0x6] A1[0x7] +C1 = 00000111 00000111 00000111 00000111 0 +``` + +Notice how neither one of `C0` or `C1` is guaranteed to report fully correct +results all on its own. For example, `C1` claims that `b` is a fingerprint for +the pattern `foo` (since `A1[0x6] = 00000111`), and that `o` is a fingerprint +for all of our patterns. But if we combined `C0` and `C1` with an `AND` +operation: + +```ignore + b a ... f o ... p +C = 00000110 0 00000001 0 0 +``` + +Then we now have that `C[i]` contains a bitset corresponding to the matching +fingerprints in a haystack's 16 byte block, where `i` is the `ith` byte in that +block. + +Once we have that, we can look for the position of the least significant bit +in `C`. (Least significant because we only target `x86_64` here, which is +always little endian. Thus, the least significant bytes correspond to bytes +in our haystack at a lower address.) That position, modulo `8`, gives us +the pattern that the fingerprint matches. That position, integer divided by +`8`, also gives us the byte offset that the fingerprint occurs in inside the +16 byte haystack block. Using those two pieces of information, we can run a +verification procedure that tries to match all substrings containing that +fingerprint at that position in the haystack. + + +# Implementation notes + +The problem with the algorithm as described above is that it uses a single byte +for a fingerprint. This will work well if the fingerprints are rare in the +haystack (e.g., capital letters or special characters in normal English text), +but if the fingerprints are common, you'll wind up spending too much time in +the verification step, which effectively negates the performance benefits of +scanning 16 bytes at a time. Remember, the key to the performance of this +algorithm is to do as little work as possible per 16 (or 32) bytes. + +This algorithm can be extrapolated in a relatively straight-forward way to use +larger fingerprints. That is, instead of a single byte prefix, we might use a +two or three byte prefix. The implementation here implements N = {1, 2, 3} +and always picks the largest N possible. The rationale is that the bigger the +fingerprint, the fewer verification steps we'll do. Of course, if N is too +large, then we'll end up doing too much on each step. + +The way to extend it is: + +1. Add a mask for each byte in the fingerprint. (Remember that each mask is + composed of two SIMD vectors.) This results in a value of `C` for each byte + in the fingerprint while searching. +2. When testing each 16 (or 32) byte block, each value of `C` must be shifted + so that they are aligned. Once aligned, they should all be `AND`'d together. + This will give you only the bitsets corresponding to the full match of the + fingerprint. To do this, one needs to save the last byte (for N=2) or last + two bytes (for N=3) from the previous iteration, and then line them up with + the first one or two bytes of the next iteration. + +## Verification + +Verification generally follows the procedure outlined above. The tricky parts +are in the right formulation of operations to get our bits out of our vectors. +We have a limited set of operations available to us on SIMD vectors as 128-bit +or 256-bit numbers, so we wind up needing to rip out 2 (or 4) 64-bit integers +from our vectors, and then run our verification step on each of those. The +verification step looks at the least significant bit set, and from its +position, we can derive the byte offset and bucket. (Again, as described +above.) Once we know the bucket, we do a fairly naive exhaustive search for +every literal in that bucket. (Hyperscan is a bit smarter here and uses a hash +table, but I haven't had time to thoroughly explore that. A few initial +half-hearted attempts resulted in worse performance.) + +## AVX + +The AVX version of Teddy extrapolates almost perfectly from the SSE version. +The only hickup is that PALIGNR is used to align chunks in the 16-bit version, +and there is no equivalent instruction in AVX. AVX does have VPALIGNR, but it +only works within 128-bit lanes. So there's a bit of tomfoolery to get around +this by shuffling the vectors before calling VPALIGNR. + +The only other aspect to AVX is that since our masks are still fundamentally +16-bytes (0x0-0xF), they are duplicated to 32-bytes, so that they can apply to +32-byte chunks. + +## Fat Teddy + +In the version of Teddy described above, 8 buckets are used to group patterns +that we want to search for. However, when AVX is available, we can extend the +number of buckets to 16 by permitting each byte in our masks to use 16-bits +instead of 8-bits to represent the buckets it belongs to. (This variant is also +in Hyperscan.) However, what we give up is the ability to scan 32 bytes at a +time, even though we're using AVX. Instead, we have to scan 16 bytes at a time. +What we gain, though, is (hopefully) less work in our verification routine. +It patterns are more spread out across more buckets, then there should overall +be fewer false positives. In general, Fat Teddy permits us to grow our capacity +a bit and search for more literals before Teddy gets overwhelmed. + +The tricky part of Fat Teddy is in how we adjust our masks and our verification +procedure. For the masks, we simply represent the first 8 buckets in each of +the low 16 bytes, and then the second 8 buckets in each of the high 16 bytes. +Then, in the search loop, instead of loading 32 bytes from the haystack, we +load the same 16 bytes from the haystack into both the low and high 16 byte +portions of our 256-bit vector. So for example, a mask might look like this: + + bits: 00100001 00000000 ... 11000000 00000000 00000001 ... 00000000 + byte: 31 30 16 15 14 0 + offset: 15 14 0 15 14 0 + buckets: 8-15 8-15 8-15 0-7 0-7 0-7 + +Where `byte` is the position in the vector (higher numbers corresponding to +more significant bits), `offset` is the corresponding position in the haystack +chunk, and `buckets` corresponds to the bucket assignments for that particular +byte. + +In particular, notice that the bucket assignments for offset `0` are spread +out between bytes `0` and `16`. This works well for the chunk-by-chunk search +procedure, but verification really wants to process all bucket assignments for +each offset at once. Otherwise, we might wind up finding a match at offset +`1` in one the first 8 buckets, when we really should have reported a match +at offset `0` in one of the second 8 buckets. (Because we want the leftmost +match.) + +Thus, for verification, we rearrange the above vector such that it is a +sequence of 16-bit integers, where the least significant 16-bit integer +corresponds to all of the bucket assignments for offset `0`. So with the +above vector, the least significant 16-bit integer would be + + 11000000 000000 + +which was taken from bytes `16` and `0`. Then the verification step pretty much +runs as described, except with 16 buckets instead of 8. + + +# References + +- **[1]** [Hyperscan on GitHub](https://github.com/01org/hyperscan), + [webpage](https://01.org/hyperscan) +- **[2a]** Ben-Kiki, O., Bille, P., Breslauer, D., Gasieniec, L., Grossi, R., + & Weimann, O. (2011). + _Optimal packed string matching_. + In LIPIcs-Leibniz International Proceedings in Informatics (Vol. 13). + Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik. + DOI: 10.4230/LIPIcs.FSTTCS.2011.423. + [PDF](http://drops.dagstuhl.de/opus/volltexte/2011/3355/pdf/37.pdf). +- **[2b]** Ben-Kiki, O., Bille, P., Breslauer, D., Ga̧sieniec, L., Grossi, R., + & Weimann, O. (2014). + _Towards optimal packed string matching_. + Theoretical Computer Science, 525, 111-129. + DOI: 10.1016/j.tcs.2013.06.013. + [PDF](http://www.cs.haifa.ac.il/~oren/Publications/bpsm.pdf). +- **[3]** Bille, P. (2011). + _Fast searching in packed strings_. + Journal of Discrete Algorithms, 9(1), 49-56. + DOI: 10.1016/j.jda.2010.09.003. + [PDF](http://www.sciencedirect.com/science/article/pii/S1570866710000353). +- **[4a]** Faro, S., & Külekci, M. O. (2012, October). + _Fast multiple string matching using streaming SIMD extensions technology_. + In String Processing and Information Retrieval (pp. 217-228). + Springer Berlin Heidelberg. + DOI: 10.1007/978-3-642-34109-0_23. + [PDF](http://www.dmi.unict.it/~faro/papers/conference/faro32.pdf). +- **[4b]** Faro, S., & Külekci, M. O. (2013, September). + _Towards a Very Fast Multiple String Matching Algorithm for Short Patterns_. + In Stringology (pp. 78-91). + [PDF](http://www.dmi.unict.it/~faro/papers/conference/faro36.pdf). +- **[4c]** Faro, S., & Külekci, M. O. (2013, January). + _Fast packed string matching for short patterns_. + In Proceedings of the Meeting on Algorithm Engineering & Expermiments + (pp. 113-121). + Society for Industrial and Applied Mathematics. + [PDF](http://arxiv.org/pdf/1209.6449.pdf). +- **[4d]** Faro, S., & Külekci, M. O. (2014). + _Fast and flexible packed string matching_. + Journal of Discrete Algorithms, 28, 61-72. + DOI: 10.1016/j.jda.2014.07.003. + +[1_u]: https://github.com/01org/hyperscan +[5_u]: https://software.intel.com/sites/landingpage/IntrinsicsGuide diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/compile.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/compile.rs new file mode 100644 index 0000000..bd5e971 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/compile.rs @@ -0,0 +1,414 @@ +// See the README in this directory for an explanation of the Teddy algorithm. + +use std::cmp; +use std::collections::BTreeMap; +use std::fmt; + +use packed::pattern::{PatternID, Patterns}; +use packed::teddy::Teddy; + +/// A builder for constructing a Teddy matcher. +/// +/// The builder primarily permits fine grained configuration of the Teddy +/// matcher. Most options are made only available for testing/benchmarking +/// purposes. In reality, options are automatically determined by the nature +/// and number of patterns given to the builder. +#[derive(Clone, Debug)] +pub struct Builder { + /// When none, this is automatically determined. Otherwise, `false` means + /// slim Teddy is used (8 buckets) and `true` means fat Teddy is used + /// (16 buckets). Fat Teddy requires AVX2, so if that CPU feature isn't + /// available and Fat Teddy was requested, no matcher will be built. + fat: Option, + /// When none, this is automatically determined. Otherwise, `false` means + /// that 128-bit vectors will be used (up to SSSE3 instructions) where as + /// `true` means that 256-bit vectors will be used. As with `fat`, if + /// 256-bit vectors are requested and they aren't available, then a + /// searcher will not be built. + avx: Option, +} + +impl Default for Builder { + fn default() -> Builder { + Builder::new() + } +} + +impl Builder { + /// Create a new builder for configuring a Teddy matcher. + pub fn new() -> Builder { + Builder { fat: None, avx: None } + } + + /// Build a matcher for the set of patterns given. If a matcher could not + /// be built, then `None` is returned. + /// + /// Generally, a matcher isn't built if the necessary CPU features aren't + /// available, an unsupported target or if the searcher is believed to be + /// slower than standard techniques (i.e., if there are too many literals). + pub fn build(&self, patterns: &Patterns) -> Option { + self.build_imp(patterns) + } + + /// Require the use of Fat (true) or Slim (false) Teddy. Fat Teddy uses + /// 16 buckets where as Slim Teddy uses 8 buckets. More buckets are useful + /// for a larger set of literals. + /// + /// `None` is the default, which results in an automatic selection based + /// on the number of literals and available CPU features. + pub fn fat(&mut self, yes: Option) -> &mut Builder { + self.fat = yes; + self + } + + /// Request the use of 256-bit vectors (true) or 128-bit vectors (false). + /// Generally, a larger vector size is better since it either permits + /// matching more patterns or matching more bytes in the haystack at once. + /// + /// `None` is the default, which results in an automatic selection based on + /// the number of literals and available CPU features. + pub fn avx(&mut self, yes: Option) -> &mut Builder { + self.avx = yes; + self + } + + fn build_imp(&self, patterns: &Patterns) -> Option { + use packed::teddy::runtime; + + // Most of the logic here is just about selecting the optimal settings, + // or perhaps even rejecting construction altogether. The choices + // we have are: fat (avx only) or not, ssse3 or avx2, and how many + // patterns we allow ourselves to search. Additionally, for testing + // and benchmarking, we permit callers to try to "force" a setting, + // and if the setting isn't allowed (e.g., forcing AVX when AVX isn't + // available), then we bail and return nothing. + + if patterns.len() > 64 { + return None; + } + let has_ssse3 = is_x86_feature_detected!("ssse3"); + let has_avx = is_x86_feature_detected!("avx2"); + let avx = if self.avx == Some(true) { + if !has_avx { + return None; + } + true + } else if self.avx == Some(false) { + if !has_ssse3 { + return None; + } + false + } else if !has_ssse3 && !has_avx { + return None; + } else { + has_avx + }; + let fat = match self.fat { + None => avx && patterns.len() > 32, + Some(false) => false, + Some(true) if !avx => return None, + Some(true) => true, + }; + + let mut compiler = Compiler::new(patterns, fat); + compiler.compile(); + let Compiler { buckets, masks, .. } = compiler; + // SAFETY: It is required that the builder only produce Teddy matchers + // that are allowed to run on the current CPU, since we later assume + // that the presence of (for example) TeddySlim1Mask256 means it is + // safe to call functions marked with the `avx2` target feature. + match (masks.len(), avx, fat) { + (1, false, _) => Some(Teddy { + buckets: buckets, + max_pattern_id: patterns.max_pattern_id(), + exec: runtime::Exec::TeddySlim1Mask128( + runtime::TeddySlim1Mask128 { + mask1: runtime::Mask128::new(masks[0]), + }, + ), + }), + (1, true, false) => Some(Teddy { + buckets: buckets, + max_pattern_id: patterns.max_pattern_id(), + exec: runtime::Exec::TeddySlim1Mask256( + runtime::TeddySlim1Mask256 { + mask1: runtime::Mask256::new(masks[0]), + }, + ), + }), + (1, true, true) => Some(Teddy { + buckets: buckets, + max_pattern_id: patterns.max_pattern_id(), + exec: runtime::Exec::TeddyFat1Mask256( + runtime::TeddyFat1Mask256 { + mask1: runtime::Mask256::new(masks[0]), + }, + ), + }), + (2, false, _) => Some(Teddy { + buckets: buckets, + max_pattern_id: patterns.max_pattern_id(), + exec: runtime::Exec::TeddySlim2Mask128( + runtime::TeddySlim2Mask128 { + mask1: runtime::Mask128::new(masks[0]), + mask2: runtime::Mask128::new(masks[1]), + }, + ), + }), + (2, true, false) => Some(Teddy { + buckets: buckets, + max_pattern_id: patterns.max_pattern_id(), + exec: runtime::Exec::TeddySlim2Mask256( + runtime::TeddySlim2Mask256 { + mask1: runtime::Mask256::new(masks[0]), + mask2: runtime::Mask256::new(masks[1]), + }, + ), + }), + (2, true, true) => Some(Teddy { + buckets: buckets, + max_pattern_id: patterns.max_pattern_id(), + exec: runtime::Exec::TeddyFat2Mask256( + runtime::TeddyFat2Mask256 { + mask1: runtime::Mask256::new(masks[0]), + mask2: runtime::Mask256::new(masks[1]), + }, + ), + }), + (3, false, _) => Some(Teddy { + buckets: buckets, + max_pattern_id: patterns.max_pattern_id(), + exec: runtime::Exec::TeddySlim3Mask128( + runtime::TeddySlim3Mask128 { + mask1: runtime::Mask128::new(masks[0]), + mask2: runtime::Mask128::new(masks[1]), + mask3: runtime::Mask128::new(masks[2]), + }, + ), + }), + (3, true, false) => Some(Teddy { + buckets: buckets, + max_pattern_id: patterns.max_pattern_id(), + exec: runtime::Exec::TeddySlim3Mask256( + runtime::TeddySlim3Mask256 { + mask1: runtime::Mask256::new(masks[0]), + mask2: runtime::Mask256::new(masks[1]), + mask3: runtime::Mask256::new(masks[2]), + }, + ), + }), + (3, true, true) => Some(Teddy { + buckets: buckets, + max_pattern_id: patterns.max_pattern_id(), + exec: runtime::Exec::TeddyFat3Mask256( + runtime::TeddyFat3Mask256 { + mask1: runtime::Mask256::new(masks[0]), + mask2: runtime::Mask256::new(masks[1]), + mask3: runtime::Mask256::new(masks[2]), + }, + ), + }), + _ => unreachable!(), + } + } +} + +/// A compiler is in charge of allocating patterns into buckets and generating +/// the masks necessary for searching. +#[derive(Clone)] +struct Compiler<'p> { + patterns: &'p Patterns, + buckets: Vec>, + masks: Vec, +} + +impl<'p> Compiler<'p> { + /// Create a new Teddy compiler for the given patterns. If `fat` is true, + /// then 16 buckets will be used instead of 8. + /// + /// This panics if any of the patterns given are empty. + fn new(patterns: &'p Patterns, fat: bool) -> Compiler<'p> { + let mask_len = cmp::min(3, patterns.minimum_len()); + assert!(1 <= mask_len && mask_len <= 3); + + Compiler { + patterns, + buckets: vec![vec![]; if fat { 16 } else { 8 }], + masks: vec![Mask::default(); mask_len], + } + } + + /// Compile the patterns in this compiler into buckets and masks. + fn compile(&mut self) { + let mut lonibble_to_bucket: BTreeMap, usize> = BTreeMap::new(); + for (id, pattern) in self.patterns.iter() { + // We try to be slightly clever in how we assign patterns into + // buckets. Generally speaking, we want patterns with the same + // prefix to be in the same bucket, since it minimizes the amount + // of time we spend churning through buckets in the verification + // step. + // + // So we could assign patterns with the same N-prefix (where N + // is the size of the mask, which is one of {1, 2, 3}) to the + // same bucket. However, case insensitive searches are fairly + // common, so we'd for example, ideally want to treat `abc` and + // `ABC` as if they shared the same prefix. ASCII has the nice + // property that the lower 4 bits of A and a are the same, so we + // therefore group patterns with the same low-nybbe-N-prefix into + // the same bucket. + // + // MOREOVER, this is actually necessary for correctness! In + // particular, by grouping patterns with the same prefix into the + // same bucket, we ensure that we preserve correct leftmost-first + // and leftmost-longest match semantics. In addition to the fact + // that `patterns.iter()` iterates in the correct order, this + // guarantees that all possible ambiguous matches will occur in + // the same bucket. The verification routine could be adjusted to + // support correct leftmost match semantics regardless of bucket + // allocation, but that results in a performance hit. It's much + // nicer to be able to just stop as soon as a match is found. + let lonybs = pattern.low_nybbles(self.masks.len()); + if let Some(&bucket) = lonibble_to_bucket.get(&lonybs) { + self.buckets[bucket].push(id); + } else { + // N.B. We assign buckets in reverse because it shouldn't have + // any influence on performance, but it does make it harder to + // get leftmost match semantics accidentally correct. + let bucket = (self.buckets.len() - 1) + - (id as usize % self.buckets.len()); + self.buckets[bucket].push(id); + lonibble_to_bucket.insert(lonybs, bucket); + } + } + for (bucket_index, bucket) in self.buckets.iter().enumerate() { + for &pat_id in bucket { + let pat = self.patterns.get(pat_id); + for (i, mask) in self.masks.iter_mut().enumerate() { + if self.buckets.len() == 8 { + mask.add_slim(bucket_index as u8, pat.bytes()[i]); + } else { + mask.add_fat(bucket_index as u8, pat.bytes()[i]); + } + } + } + } + } +} + +impl<'p> fmt::Debug for Compiler<'p> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut buckets = vec![vec![]; self.buckets.len()]; + for (i, bucket) in self.buckets.iter().enumerate() { + for &patid in bucket { + buckets[i].push(self.patterns.get(patid)); + } + } + f.debug_struct("Compiler") + .field("buckets", &buckets) + .field("masks", &self.masks) + .finish() + } +} + +/// Mask represents the low and high nybble masks that will be used during +/// search. Each mask is 32 bytes wide, although only the first 16 bytes are +/// used for the SSSE3 runtime. +/// +/// Each byte in the mask corresponds to a 8-bit bitset, where bit `i` is set +/// if and only if the corresponding nybble is in the ith bucket. The index of +/// the byte (0-15, inclusive) corresponds to the nybble. +/// +/// Each mask is used as the target of a shuffle, where the indices for the +/// shuffle are taken from the haystack. AND'ing the shuffles for both the +/// low and high masks together also results in 8-bit bitsets, but where bit +/// `i` is set if and only if the correspond *byte* is in the ith bucket. +/// +/// During compilation, masks are just arrays. But during search, these masks +/// are represented as 128-bit or 256-bit vectors. +/// +/// (See the README is this directory for more details.) +#[derive(Clone, Copy, Default)] +pub struct Mask { + lo: [u8; 32], + hi: [u8; 32], +} + +impl Mask { + /// Update this mask by adding the given byte to the given bucket. The + /// given bucket must be in the range 0-7. + /// + /// This is for "slim" Teddy, where there are only 8 buckets. + fn add_slim(&mut self, bucket: u8, byte: u8) { + assert!(bucket < 8); + + let byte_lo = (byte & 0xF) as usize; + let byte_hi = ((byte >> 4) & 0xF) as usize; + // When using 256-bit vectors, we need to set this bucket assignment in + // the low and high 128-bit portions of the mask. This allows us to + // process 32 bytes at a time. Namely, AVX2 shuffles operate on each + // of the 128-bit lanes, rather than the full 256-bit vector at once. + self.lo[byte_lo] |= 1 << bucket; + self.lo[byte_lo + 16] |= 1 << bucket; + self.hi[byte_hi] |= 1 << bucket; + self.hi[byte_hi + 16] |= 1 << bucket; + } + + /// Update this mask by adding the given byte to the given bucket. The + /// given bucket must be in the range 0-15. + /// + /// This is for "fat" Teddy, where there are 16 buckets. + fn add_fat(&mut self, bucket: u8, byte: u8) { + assert!(bucket < 16); + + let byte_lo = (byte & 0xF) as usize; + let byte_hi = ((byte >> 4) & 0xF) as usize; + // Unlike slim teddy, fat teddy only works with AVX2. For fat teddy, + // the high 128 bits of our mask correspond to buckets 8-15, while the + // low 128 bits correspond to buckets 0-7. + if bucket < 8 { + self.lo[byte_lo] |= 1 << bucket; + self.hi[byte_hi] |= 1 << bucket; + } else { + self.lo[byte_lo + 16] |= 1 << (bucket % 8); + self.hi[byte_hi + 16] |= 1 << (bucket % 8); + } + } + + /// Return the low 128 bits of the low-nybble mask. + pub fn lo128(&self) -> [u8; 16] { + let mut tmp = [0; 16]; + tmp.copy_from_slice(&self.lo[..16]); + tmp + } + + /// Return the full low-nybble mask. + pub fn lo256(&self) -> [u8; 32] { + self.lo + } + + /// Return the low 128 bits of the high-nybble mask. + pub fn hi128(&self) -> [u8; 16] { + let mut tmp = [0; 16]; + tmp.copy_from_slice(&self.hi[..16]); + tmp + } + + /// Return the full high-nybble mask. + pub fn hi256(&self) -> [u8; 32] { + self.hi + } +} + +impl fmt::Debug for Mask { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let (mut parts_lo, mut parts_hi) = (vec![], vec![]); + for i in 0..32 { + parts_lo.push(format!("{:02}: {:08b}", i, self.lo[i])); + parts_hi.push(format!("{:02}: {:08b}", i, self.hi[i])); + } + f.debug_struct("Mask") + .field("lo", &parts_lo) + .field("hi", &parts_hi) + .finish() + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/mod.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/mod.rs new file mode 100644 index 0000000..b896023 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/mod.rs @@ -0,0 +1,62 @@ +#[cfg(target_arch = "x86_64")] +pub use packed::teddy::compile::Builder; +#[cfg(not(target_arch = "x86_64"))] +pub use packed::teddy::fallback::Builder; +#[cfg(not(target_arch = "x86_64"))] +pub use packed::teddy::fallback::Teddy; +#[cfg(target_arch = "x86_64")] +pub use packed::teddy::runtime::Teddy; + +#[cfg(target_arch = "x86_64")] +mod compile; +#[cfg(target_arch = "x86_64")] +mod runtime; + +#[cfg(not(target_arch = "x86_64"))] +mod fallback { + use packed::pattern::Patterns; + use Match; + + #[derive(Clone, Debug, Default)] + pub struct Builder(()); + + impl Builder { + pub fn new() -> Builder { + Builder(()) + } + + pub fn build(&self, _: &Patterns) -> Option { + None + } + + pub fn fat(&mut self, _: Option) -> &mut Builder { + self + } + + pub fn avx(&mut self, _: Option) -> &mut Builder { + self + } + } + + #[derive(Clone, Debug)] + pub struct Teddy(()); + + impl Teddy { + pub fn find_at( + &self, + _: &Patterns, + _: &[u8], + _: usize, + ) -> Option { + None + } + + pub fn minimum_len(&self) -> usize { + 0 + } + + pub fn heap_bytes(&self) -> usize { + 0 + } + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/runtime.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/runtime.rs new file mode 100644 index 0000000..a736948 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/teddy/runtime.rs @@ -0,0 +1,1204 @@ +// See the README in this directory for an explanation of the Teddy algorithm. +// It is strongly recommended to peruse the README before trying to grok this +// code, as its use of SIMD is pretty opaque, although I tried to add comments +// where appropriate. +// +// Moreover, while there is a lot of code in this file, most of it is +// repeated variants of the same thing. Specifically, there are three Teddy +// variants: Slim 128-bit Teddy (8 buckets), Slim 256-bit Teddy (8 buckets) +// and Fat 256-bit Teddy (16 buckets). For each variant, there are three +// implementations, corresponding to mask lengths of 1, 2 and 3. Bringing it to +// a total of nine variants. Each one is structured roughly the same: +// +// while at <= len(haystack) - CHUNK_SIZE: +// let candidate = find_candidate_in_chunk(haystack, at) +// if not all zeroes(candidate): +// if match = verify(haystack, at, candidate): +// return match +// +// For the most part, this remains unchanged. The parts that vary are the +// verification routine (for slim vs fat Teddy) and the candidate extraction +// (based on the number of masks). +// +// In the code below, a "candidate" corresponds to a single vector with 8-bit +// lanes. Each lane is itself an 8-bit bitset, where the ith bit is set in the +// jth lane if and only if the byte occurring at position `j` is in the +// bucket `i` (where the `j`th position is the position in the current window +// of the haystack, which is always 16 or 32 bytes). Note to be careful here: +// the ith bit and the jth lane correspond to the least significant bits of the +// vector. So when visualizing how the current window of bytes is stored in a +// vector, you often need to flip it around. For example, the text `abcd` in a +// 4-byte vector would look like this: +// +// 01100100 01100011 01100010 01100001 +// d c b a +// +// When the mask length is 1, then finding the candidate is pretty straight +// forward: you just apply the shuffle indices (from the haystack window) to +// the masks, and then AND them together, as described in the README. But for +// masks of length 2 and 3, you need to keep a little state. Specifically, +// you need to store the final 1 (for mask length 2) or 2 (for mask length 3) +// bytes of the candidate for use when searching the next window. This is for +// handling matches that span two windows. +// +// With respect to the repeated code, it would likely be possible to reduce +// the number of copies of code below using polymorphism, but I find this +// formulation clearer instead of needing to reason through generics. However, +// I admit, there may be a simpler generic construction that I'm missing. +// +// All variants are fairly heavily tested in src/packed/tests.rs. + +use std::arch::x86_64::*; +use std::mem; + +use packed::pattern::{PatternID, Patterns}; +use packed::teddy::compile; +use packed::vector::*; +use Match; + +/// The Teddy runtime. +/// +/// A Teddy runtime can be used to quickly search for occurrences of one or +/// more patterns. While it does not scale to an arbitrary number of patterns +/// like Aho-Corasick, it does find occurrences for a small set of patterns +/// much more quickly than Aho-Corasick. +/// +/// Teddy cannot run on small haystacks below a certain size, which is +/// dependent on the type of matcher used. This size can be queried via the +/// `minimum_len` method. Violating this will result in a panic. +/// +/// Finally, when callers use a Teddy runtime, they must provide precisely the +/// patterns used to construct the Teddy matcher. Violating this will result +/// in either a panic or incorrect results, but will never sacrifice memory +/// safety. +#[derive(Clone, Debug)] +pub struct Teddy { + /// The allocation of patterns in buckets. This only contains the IDs of + /// patterns. In order to do full verification, callers must provide the + /// actual patterns when using Teddy. + pub buckets: Vec>, + /// The maximum identifier of a pattern. This is used as a sanity check to + /// ensure that the patterns provided by the caller are the same as the + /// patterns that were used to compile the matcher. This sanity check + /// permits safely eliminating bounds checks regardless of what patterns + /// are provided by the caller. + /// + /// Note that users of the aho-corasick crate cannot get this wrong. Only + /// code internal to this crate can get it wrong, since neither `Patterns` + /// type nor the Teddy runtime are public API items. + pub max_pattern_id: PatternID, + /// The actual runtime to use. + pub exec: Exec, +} + +impl Teddy { + /// Return the first occurrence of a match in the given haystack after or + /// starting at `at`. + /// + /// The patterns provided must be precisely the same patterns given to the + /// Teddy builder, otherwise this may panic or produce incorrect results. + /// + /// All matches are consistent with the match semantics (leftmost-first or + /// leftmost-longest) set on `pats`. + pub fn find_at( + &self, + pats: &Patterns, + haystack: &[u8], + at: usize, + ) -> Option { + // This assert is a bit subtle, but it's an important guarantee. + // Namely, if the maximum pattern ID seen by Teddy is the same as the + // one in the patterns given, then we are guaranteed that every pattern + // ID in all Teddy buckets are valid indices into `pats`. While this + // is nominally true, there is no guarantee that callers provide the + // same `pats` to both the Teddy builder and the searcher, which would + // otherwise make `find_at` unsafe to call. But this assert lets us + // keep this routine safe and eliminate an important bounds check in + // verification. + assert_eq!( + self.max_pattern_id, + pats.max_pattern_id(), + "teddy must be called with same patterns it was built with", + ); + // SAFETY: The haystack must have at least a minimum number of bytes + // for Teddy to be able to work. The minimum number varies depending on + // which matcher is used below. If this is violated, then it's possible + // for searching to do out-of-bounds writes. + assert!(haystack[at..].len() >= self.minimum_len()); + // SAFETY: The various Teddy matchers are always safe to call because + // the Teddy builder guarantees that a particular Exec variant is + // built only when it can be run the current CPU. That is, the Teddy + // builder will not produce a Exec::TeddySlim1Mask256 unless AVX2 is + // enabled. That is, our dynamic CPU feature detection is performed + // once in the builder, and we rely on the type system to avoid needing + // to do it again. + unsafe { + match self.exec { + Exec::TeddySlim1Mask128(ref e) => { + e.find_at(pats, self, haystack, at) + } + Exec::TeddySlim1Mask256(ref e) => { + e.find_at(pats, self, haystack, at) + } + Exec::TeddyFat1Mask256(ref e) => { + e.find_at(pats, self, haystack, at) + } + Exec::TeddySlim2Mask128(ref e) => { + e.find_at(pats, self, haystack, at) + } + Exec::TeddySlim2Mask256(ref e) => { + e.find_at(pats, self, haystack, at) + } + Exec::TeddyFat2Mask256(ref e) => { + e.find_at(pats, self, haystack, at) + } + Exec::TeddySlim3Mask128(ref e) => { + e.find_at(pats, self, haystack, at) + } + Exec::TeddySlim3Mask256(ref e) => { + e.find_at(pats, self, haystack, at) + } + Exec::TeddyFat3Mask256(ref e) => { + e.find_at(pats, self, haystack, at) + } + } + } + } + + /// Returns the minimum length of a haystack that must be provided by + /// callers to this Teddy searcher. Providing a haystack shorter than this + /// will result in a panic, but will never violate memory safety. + pub fn minimum_len(&self) -> usize { + // SAFETY: These values must be correct in order to ensure safety. + // The Teddy runtime assumes their haystacks have at least these + // lengths. Violating this will sacrifice memory safety. + match self.exec { + Exec::TeddySlim1Mask128(_) => 16, + Exec::TeddySlim1Mask256(_) => 32, + Exec::TeddyFat1Mask256(_) => 16, + Exec::TeddySlim2Mask128(_) => 17, + Exec::TeddySlim2Mask256(_) => 33, + Exec::TeddyFat2Mask256(_) => 17, + Exec::TeddySlim3Mask128(_) => 18, + Exec::TeddySlim3Mask256(_) => 34, + Exec::TeddyFat3Mask256(_) => 34, + } + } + + /// Returns the approximate total amount of heap used by this searcher, in + /// units of bytes. + pub fn heap_bytes(&self) -> usize { + let num_patterns = self.max_pattern_id as usize + 1; + self.buckets.len() * mem::size_of::>() + + num_patterns * mem::size_of::() + } + + /// Runs the verification routine for Slim 128-bit Teddy. + /// + /// The candidate given should be a collection of 8-bit bitsets (one bitset + /// per lane), where the ith bit is set in the jth lane if and only if the + /// byte occurring at `at + j` in `haystack` is in the bucket `i`. + /// + /// This is not safe to call unless the SSSE3 target feature is enabled. + /// The `target_feature` attribute is not applied since this function is + /// always forcefully inlined. + #[inline(always)] + unsafe fn verify128( + &self, + pats: &Patterns, + haystack: &[u8], + at: usize, + cand: __m128i, + ) -> Option { + debug_assert!(!is_all_zeroes128(cand)); + debug_assert_eq!(8, self.buckets.len()); + + // Convert the candidate into 64-bit chunks, and then verify each of + // those chunks. + let parts = unpack64x128(cand); + for (i, &part) in parts.iter().enumerate() { + let pos = at + i * 8; + if let Some(m) = self.verify64(pats, 8, haystack, pos, part) { + return Some(m); + } + } + None + } + + /// Runs the verification routine for Slim 256-bit Teddy. + /// + /// The candidate given should be a collection of 8-bit bitsets (one bitset + /// per lane), where the ith bit is set in the jth lane if and only if the + /// byte occurring at `at + j` in `haystack` is in the bucket `i`. + /// + /// This is not safe to call unless the AVX2 target feature is enabled. + /// The `target_feature` attribute is not applied since this function is + /// always forcefully inlined. + #[inline(always)] + unsafe fn verify256( + &self, + pats: &Patterns, + haystack: &[u8], + at: usize, + cand: __m256i, + ) -> Option { + debug_assert!(!is_all_zeroes256(cand)); + debug_assert_eq!(8, self.buckets.len()); + + // Convert the candidate into 64-bit chunks, and then verify each of + // those chunks. + let parts = unpack64x256(cand); + for (i, &part) in parts.iter().enumerate() { + let pos = at + i * 8; + if let Some(m) = self.verify64(pats, 8, haystack, pos, part) { + return Some(m); + } + } + None + } + + /// Runs the verification routine for Fat 256-bit Teddy. + /// + /// The candidate given should be a collection of 8-bit bitsets (one bitset + /// per lane), where the ith bit is set in the jth lane if and only if the + /// byte occurring at `at + (j < 16 ? j : j - 16)` in `haystack` is in the + /// bucket `j < 16 ? i : i + 8`. + /// + /// This is not safe to call unless the AVX2 target feature is enabled. + /// The `target_feature` attribute is not applied since this function is + /// always forcefully inlined. + #[inline(always)] + unsafe fn verify_fat256( + &self, + pats: &Patterns, + haystack: &[u8], + at: usize, + cand: __m256i, + ) -> Option { + debug_assert!(!is_all_zeroes256(cand)); + debug_assert_eq!(16, self.buckets.len()); + + // This is a bit tricky, but we basically want to convert our + // candidate, which looks like this + // + // a31 a30 ... a17 a16 a15 a14 ... a01 a00 + // + // where each a(i) is an 8-bit bitset corresponding to the activated + // buckets, to this + // + // a31 a15 a30 a14 a29 a13 ... a18 a02 a17 a01 a16 a00 + // + // Namely, for Fat Teddy, the high 128-bits of the candidate correspond + // to the same bytes in the haystack in the low 128-bits (so we only + // scan 16 bytes at a time), but are for buckets 8-15 instead of 0-7. + // + // The verification routine wants to look at all potentially matching + // buckets before moving on to the next lane. So for example, both + // a16 and a00 both correspond to the first byte in our window; a00 + // contains buckets 0-7 and a16 contains buckets 8-15. Specifically, + // a16 should be checked before a01. So the transformation shown above + // allows us to use our normal verification procedure with one small + // change: we treat each bitset as 16 bits instead of 8 bits. + + // Swap the 128-bit lanes in the candidate vector. + let swap = _mm256_permute4x64_epi64(cand, 0x4E); + // Interleave the bytes from the low 128-bit lanes, starting with + // cand first. + let r1 = _mm256_unpacklo_epi8(cand, swap); + // Interleave the bytes from the high 128-bit lanes, starting with + // cand first. + let r2 = _mm256_unpackhi_epi8(cand, swap); + // Now just take the 2 low 64-bit integers from both r1 and r2. We + // can drop the high 64-bit integers because they are a mirror image + // of the low 64-bit integers. All we care about are the low 128-bit + // lanes of r1 and r2. Combined, they contain all our 16-bit bitsets + // laid out in the desired order, as described above. + let parts = unpacklo64x256(r1, r2); + for (i, &part) in parts.iter().enumerate() { + let pos = at + i * 4; + if let Some(m) = self.verify64(pats, 16, haystack, pos, part) { + return Some(m); + } + } + None + } + + /// Verify whether there are any matches starting at or after `at` in the + /// given `haystack`. The candidate given should correspond to either 8-bit + /// (for 8 buckets) or 16-bit (16 buckets) bitsets. + #[inline(always)] + fn verify64( + &self, + pats: &Patterns, + bucket_count: usize, + haystack: &[u8], + at: usize, + mut cand: u64, + ) -> Option { + // N.B. While the bucket count is known from self.buckets.len(), + // requiring it as a parameter makes it easier for the optimizer to + // know its value, and thus produce more efficient codegen. + debug_assert!(bucket_count == 8 || bucket_count == 16); + while cand != 0 { + let bit = cand.trailing_zeros() as usize; + cand &= !(1 << bit); + + let at = at + (bit / bucket_count); + let bucket = bit % bucket_count; + if let Some(m) = self.verify_bucket(pats, haystack, bucket, at) { + return Some(m); + } + } + None + } + + /// Verify whether there are any matches starting at `at` in the given + /// `haystack` corresponding only to patterns in the given bucket. + #[inline(always)] + fn verify_bucket( + &self, + pats: &Patterns, + haystack: &[u8], + bucket: usize, + at: usize, + ) -> Option { + // Forcing this function to not inline and be "cold" seems to help + // the codegen for Teddy overall. Interestingly, this is good for a + // 16% boost in the sherlock/packed/teddy/name/alt1 benchmark (among + // others). Overall, this seems like a problem with codegen, since + // creating the Match itself is a very small amount of code. + #[cold] + #[inline(never)] + fn match_from_span( + pati: PatternID, + start: usize, + end: usize, + ) -> Match { + Match::from_span(pati as usize, start, end) + } + + // N.B. The bounds check for this bucket lookup *should* be elided + // since we assert the number of buckets in each `find_at` routine, + // and the compiler can prove that the `% 8` (or `% 16`) in callers + // of this routine will always be in bounds. + for &pati in &self.buckets[bucket] { + // SAFETY: This is safe because we are guaranteed that every + // index in a Teddy bucket is a valid index into `pats`. This + // guarantee is upheld by the assert checking `max_pattern_id` in + // the beginning of `find_at` above. + // + // This explicit bounds check elision is (amazingly) good for a + // 25-50% boost in some benchmarks, particularly ones with a lot + // of short literals. + let pat = unsafe { pats.get_unchecked(pati) }; + if pat.is_prefix(&haystack[at..]) { + return Some(match_from_span(pati, at, at + pat.len())); + } + } + None + } +} + +/// Exec represents the different search strategies supported by the Teddy +/// runtime. +/// +/// This enum is an important safety abstraction. Namely, callers should only +/// construct a variant in this enum if it is safe to execute its corresponding +/// target features on the current CPU. The 128-bit searchers require SSSE3, +/// while the 256-bit searchers require AVX2. +#[derive(Clone, Debug)] +pub enum Exec { + TeddySlim1Mask128(TeddySlim1Mask128), + TeddySlim1Mask256(TeddySlim1Mask256), + TeddyFat1Mask256(TeddyFat1Mask256), + TeddySlim2Mask128(TeddySlim2Mask128), + TeddySlim2Mask256(TeddySlim2Mask256), + TeddyFat2Mask256(TeddyFat2Mask256), + TeddySlim3Mask128(TeddySlim3Mask128), + TeddySlim3Mask256(TeddySlim3Mask256), + TeddyFat3Mask256(TeddyFat3Mask256), +} + +// Most of the code below remains undocumented because they are effectively +// repeated versions of themselves. The general structure is described in the +// README and in the comments above. + +#[derive(Clone, Debug)] +pub struct TeddySlim1Mask128 { + pub mask1: Mask128, +} + +impl TeddySlim1Mask128 { + #[target_feature(enable = "ssse3")] + unsafe fn find_at( + &self, + pats: &Patterns, + teddy: &Teddy, + haystack: &[u8], + mut at: usize, + ) -> Option { + debug_assert!(haystack[at..].len() >= teddy.minimum_len()); + // This assert helps eliminate bounds checks for bucket lookups in + // Teddy::verify_bucket, which has a small (3-4%) performance boost. + assert_eq!(8, teddy.buckets.len()); + + let len = haystack.len(); + while at <= len - 16 { + let c = self.candidate(haystack, at); + if !is_all_zeroes128(c) { + if let Some(m) = teddy.verify128(pats, haystack, at, c) { + return Some(m); + } + } + at += 16; + } + if at < len { + at = len - 16; + let c = self.candidate(haystack, at); + if !is_all_zeroes128(c) { + if let Some(m) = teddy.verify128(pats, haystack, at, c) { + return Some(m); + } + } + } + None + } + + #[inline(always)] + unsafe fn candidate(&self, haystack: &[u8], at: usize) -> __m128i { + debug_assert!(haystack[at..].len() >= 16); + + let chunk = loadu128(haystack, at); + members1m128(chunk, self.mask1) + } +} + +#[derive(Clone, Debug)] +pub struct TeddySlim1Mask256 { + pub mask1: Mask256, +} + +impl TeddySlim1Mask256 { + #[target_feature(enable = "avx2")] + unsafe fn find_at( + &self, + pats: &Patterns, + teddy: &Teddy, + haystack: &[u8], + mut at: usize, + ) -> Option { + debug_assert!(haystack[at..].len() >= teddy.minimum_len()); + // This assert helps eliminate bounds checks for bucket lookups in + // Teddy::verify_bucket, which has a small (3-4%) performance boost. + assert_eq!(8, teddy.buckets.len()); + + let len = haystack.len(); + while at <= len - 32 { + let c = self.candidate(haystack, at); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify256(pats, haystack, at, c) { + return Some(m); + } + } + at += 32; + } + if at < len { + at = len - 32; + let c = self.candidate(haystack, at); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify256(pats, haystack, at, c) { + return Some(m); + } + } + } + None + } + + #[inline(always)] + unsafe fn candidate(&self, haystack: &[u8], at: usize) -> __m256i { + debug_assert!(haystack[at..].len() >= 32); + + let chunk = loadu256(haystack, at); + members1m256(chunk, self.mask1) + } +} + +#[derive(Clone, Debug)] +pub struct TeddyFat1Mask256 { + pub mask1: Mask256, +} + +impl TeddyFat1Mask256 { + #[target_feature(enable = "avx2")] + unsafe fn find_at( + &self, + pats: &Patterns, + teddy: &Teddy, + haystack: &[u8], + mut at: usize, + ) -> Option { + debug_assert!(haystack[at..].len() >= teddy.minimum_len()); + // This assert helps eliminate bounds checks for bucket lookups in + // Teddy::verify_bucket, which has a small (3-4%) performance boost. + assert_eq!(16, teddy.buckets.len()); + + let len = haystack.len(); + while at <= len - 16 { + let c = self.candidate(haystack, at); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify_fat256(pats, haystack, at, c) { + return Some(m); + } + } + at += 16; + } + if at < len { + at = len - 16; + let c = self.candidate(haystack, at); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify_fat256(pats, haystack, at, c) { + return Some(m); + } + } + } + None + } + + #[inline(always)] + unsafe fn candidate(&self, haystack: &[u8], at: usize) -> __m256i { + debug_assert!(haystack[at..].len() >= 16); + + let chunk = _mm256_broadcastsi128_si256(loadu128(haystack, at)); + members1m256(chunk, self.mask1) + } +} + +#[derive(Clone, Debug)] +pub struct TeddySlim2Mask128 { + pub mask1: Mask128, + pub mask2: Mask128, +} + +impl TeddySlim2Mask128 { + #[target_feature(enable = "ssse3")] + unsafe fn find_at( + &self, + pats: &Patterns, + teddy: &Teddy, + haystack: &[u8], + mut at: usize, + ) -> Option { + debug_assert!(haystack[at..].len() >= teddy.minimum_len()); + // This assert helps eliminate bounds checks for bucket lookups in + // Teddy::verify_bucket, which has a small (3-4%) performance boost. + assert_eq!(8, teddy.buckets.len()); + + at += 1; + let len = haystack.len(); + let mut prev0 = ones128(); + while at <= len - 16 { + let c = self.candidate(haystack, at, &mut prev0); + if !is_all_zeroes128(c) { + if let Some(m) = teddy.verify128(pats, haystack, at - 1, c) { + return Some(m); + } + } + at += 16; + } + if at < len { + at = len - 16; + prev0 = ones128(); + + let c = self.candidate(haystack, at, &mut prev0); + if !is_all_zeroes128(c) { + if let Some(m) = teddy.verify128(pats, haystack, at - 1, c) { + return Some(m); + } + } + } + None + } + + #[inline(always)] + unsafe fn candidate( + &self, + haystack: &[u8], + at: usize, + prev0: &mut __m128i, + ) -> __m128i { + debug_assert!(haystack[at..].len() >= 16); + + let chunk = loadu128(haystack, at); + let (res0, res1) = members2m128(chunk, self.mask1, self.mask2); + let res0prev0 = _mm_alignr_epi8(res0, *prev0, 15); + _mm_and_si128(res0prev0, res1) + } +} + +#[derive(Clone, Debug)] +pub struct TeddySlim2Mask256 { + pub mask1: Mask256, + pub mask2: Mask256, +} + +impl TeddySlim2Mask256 { + #[target_feature(enable = "avx2")] + unsafe fn find_at( + &self, + pats: &Patterns, + teddy: &Teddy, + haystack: &[u8], + mut at: usize, + ) -> Option { + debug_assert!(haystack[at..].len() >= teddy.minimum_len()); + // This assert helps eliminate bounds checks for bucket lookups in + // Teddy::verify_bucket, which has a small (3-4%) performance boost. + assert_eq!(8, teddy.buckets.len()); + + at += 1; + let len = haystack.len(); + let mut prev0 = ones256(); + while at <= len - 32 { + let c = self.candidate(haystack, at, &mut prev0); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify256(pats, haystack, at - 1, c) { + return Some(m); + } + } + at += 32; + } + if at < len { + at = len - 32; + prev0 = ones256(); + + let c = self.candidate(haystack, at, &mut prev0); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify256(pats, haystack, at - 1, c) { + return Some(m); + } + } + } + None + } + + #[inline(always)] + unsafe fn candidate( + &self, + haystack: &[u8], + at: usize, + prev0: &mut __m256i, + ) -> __m256i { + debug_assert!(haystack[at..].len() >= 32); + + let chunk = loadu256(haystack, at); + let (res0, res1) = members2m256(chunk, self.mask1, self.mask2); + let res0prev0 = alignr256_15(res0, *prev0); + let res = _mm256_and_si256(res0prev0, res1); + *prev0 = res0; + res + } +} + +#[derive(Clone, Debug)] +pub struct TeddyFat2Mask256 { + pub mask1: Mask256, + pub mask2: Mask256, +} + +impl TeddyFat2Mask256 { + #[target_feature(enable = "avx2")] + unsafe fn find_at( + &self, + pats: &Patterns, + teddy: &Teddy, + haystack: &[u8], + mut at: usize, + ) -> Option { + debug_assert!(haystack[at..].len() >= teddy.minimum_len()); + // This assert helps eliminate bounds checks for bucket lookups in + // Teddy::verify_bucket, which has a small (3-4%) performance boost. + assert_eq!(16, teddy.buckets.len()); + + at += 1; + let len = haystack.len(); + let mut prev0 = ones256(); + while at <= len - 16 { + let c = self.candidate(haystack, at, &mut prev0); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify_fat256(pats, haystack, at - 1, c) + { + return Some(m); + } + } + at += 16; + } + if at < len { + at = len - 16; + prev0 = ones256(); + + let c = self.candidate(haystack, at, &mut prev0); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify_fat256(pats, haystack, at - 1, c) + { + return Some(m); + } + } + } + None + } + + #[inline(always)] + unsafe fn candidate( + &self, + haystack: &[u8], + at: usize, + prev0: &mut __m256i, + ) -> __m256i { + debug_assert!(haystack[at..].len() >= 16); + + let chunk = _mm256_broadcastsi128_si256(loadu128(haystack, at)); + let (res0, res1) = members2m256(chunk, self.mask1, self.mask2); + let res0prev0 = _mm256_alignr_epi8(res0, *prev0, 15); + let res = _mm256_and_si256(res0prev0, res1); + *prev0 = res0; + res + } +} + +#[derive(Clone, Debug)] +pub struct TeddySlim3Mask128 { + pub mask1: Mask128, + pub mask2: Mask128, + pub mask3: Mask128, +} + +impl TeddySlim3Mask128 { + #[target_feature(enable = "ssse3")] + unsafe fn find_at( + &self, + pats: &Patterns, + teddy: &Teddy, + haystack: &[u8], + mut at: usize, + ) -> Option { + debug_assert!(haystack[at..].len() >= teddy.minimum_len()); + // This assert helps eliminate bounds checks for bucket lookups in + // Teddy::verify_bucket, which has a small (3-4%) performance boost. + assert_eq!(8, teddy.buckets.len()); + + at += 2; + let len = haystack.len(); + let (mut prev0, mut prev1) = (ones128(), ones128()); + while at <= len - 16 { + let c = self.candidate(haystack, at, &mut prev0, &mut prev1); + if !is_all_zeroes128(c) { + if let Some(m) = teddy.verify128(pats, haystack, at - 2, c) { + return Some(m); + } + } + at += 16; + } + if at < len { + at = len - 16; + prev0 = ones128(); + prev1 = ones128(); + + let c = self.candidate(haystack, at, &mut prev0, &mut prev1); + if !is_all_zeroes128(c) { + if let Some(m) = teddy.verify128(pats, haystack, at - 2, c) { + return Some(m); + } + } + } + None + } + + #[inline(always)] + unsafe fn candidate( + &self, + haystack: &[u8], + at: usize, + prev0: &mut __m128i, + prev1: &mut __m128i, + ) -> __m128i { + debug_assert!(haystack[at..].len() >= 16); + + let chunk = loadu128(haystack, at); + let (res0, res1, res2) = + members3m128(chunk, self.mask1, self.mask2, self.mask3); + let res0prev0 = _mm_alignr_epi8(res0, *prev0, 14); + let res1prev1 = _mm_alignr_epi8(res1, *prev1, 15); + let res = _mm_and_si128(_mm_and_si128(res0prev0, res1prev1), res2); + *prev0 = res0; + *prev1 = res1; + res + } +} + +#[derive(Clone, Debug)] +pub struct TeddySlim3Mask256 { + pub mask1: Mask256, + pub mask2: Mask256, + pub mask3: Mask256, +} + +impl TeddySlim3Mask256 { + #[target_feature(enable = "avx2")] + unsafe fn find_at( + &self, + pats: &Patterns, + teddy: &Teddy, + haystack: &[u8], + mut at: usize, + ) -> Option { + debug_assert!(haystack[at..].len() >= teddy.minimum_len()); + // This assert helps eliminate bounds checks for bucket lookups in + // Teddy::verify_bucket, which has a small (3-4%) performance boost. + assert_eq!(8, teddy.buckets.len()); + + at += 2; + let len = haystack.len(); + let (mut prev0, mut prev1) = (ones256(), ones256()); + while at <= len - 32 { + let c = self.candidate(haystack, at, &mut prev0, &mut prev1); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify256(pats, haystack, at - 2, c) { + return Some(m); + } + } + at += 32; + } + if at < len { + at = len - 32; + prev0 = ones256(); + prev1 = ones256(); + + let c = self.candidate(haystack, at, &mut prev0, &mut prev1); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify256(pats, haystack, at - 2, c) { + return Some(m); + } + } + } + None + } + + #[inline(always)] + unsafe fn candidate( + &self, + haystack: &[u8], + at: usize, + prev0: &mut __m256i, + prev1: &mut __m256i, + ) -> __m256i { + debug_assert!(haystack[at..].len() >= 32); + + let chunk = loadu256(haystack, at); + let (res0, res1, res2) = + members3m256(chunk, self.mask1, self.mask2, self.mask3); + let res0prev0 = alignr256_14(res0, *prev0); + let res1prev1 = alignr256_15(res1, *prev1); + let res = + _mm256_and_si256(_mm256_and_si256(res0prev0, res1prev1), res2); + *prev0 = res0; + *prev1 = res1; + res + } +} + +#[derive(Clone, Debug)] +pub struct TeddyFat3Mask256 { + pub mask1: Mask256, + pub mask2: Mask256, + pub mask3: Mask256, +} + +impl TeddyFat3Mask256 { + #[target_feature(enable = "avx2")] + unsafe fn find_at( + &self, + pats: &Patterns, + teddy: &Teddy, + haystack: &[u8], + mut at: usize, + ) -> Option { + debug_assert!(haystack[at..].len() >= teddy.minimum_len()); + // This assert helps eliminate bounds checks for bucket lookups in + // Teddy::verify_bucket, which has a small (3-4%) performance boost. + assert_eq!(16, teddy.buckets.len()); + + at += 2; + let len = haystack.len(); + let (mut prev0, mut prev1) = (ones256(), ones256()); + while at <= len - 16 { + let c = self.candidate(haystack, at, &mut prev0, &mut prev1); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify_fat256(pats, haystack, at - 2, c) + { + return Some(m); + } + } + at += 16; + } + if at < len { + at = len - 16; + prev0 = ones256(); + prev1 = ones256(); + + let c = self.candidate(haystack, at, &mut prev0, &mut prev1); + if !is_all_zeroes256(c) { + if let Some(m) = teddy.verify_fat256(pats, haystack, at - 2, c) + { + return Some(m); + } + } + } + None + } + + #[inline(always)] + unsafe fn candidate( + &self, + haystack: &[u8], + at: usize, + prev0: &mut __m256i, + prev1: &mut __m256i, + ) -> __m256i { + debug_assert!(haystack[at..].len() >= 16); + + let chunk = _mm256_broadcastsi128_si256(loadu128(haystack, at)); + let (res0, res1, res2) = + members3m256(chunk, self.mask1, self.mask2, self.mask3); + let res0prev0 = _mm256_alignr_epi8(res0, *prev0, 14); + let res1prev1 = _mm256_alignr_epi8(res1, *prev1, 15); + let res = + _mm256_and_si256(_mm256_and_si256(res0prev0, res1prev1), res2); + *prev0 = res0; + *prev1 = res1; + res + } +} + +/// A 128-bit mask for the low and high nybbles in a set of patterns. Each +/// lane `j` corresponds to a bitset where the `i`th bit is set if and only if +/// the nybble `j` is in the bucket `i` at a particular position. +#[derive(Clone, Copy, Debug)] +pub struct Mask128 { + lo: __m128i, + hi: __m128i, +} + +impl Mask128 { + /// Create a new SIMD mask from the mask produced by the Teddy builder. + pub fn new(mask: compile::Mask) -> Mask128 { + // SAFETY: This is safe since [u8; 16] has the same representation + // as __m128i. + unsafe { + Mask128 { + lo: mem::transmute(mask.lo128()), + hi: mem::transmute(mask.hi128()), + } + } + } +} + +/// A 256-bit mask for the low and high nybbles in a set of patterns. Each +/// lane `j` corresponds to a bitset where the `i`th bit is set if and only if +/// the nybble `j` is in the bucket `i` at a particular position. +/// +/// This is slightly tweaked dependending on whether Slim or Fat Teddy is being +/// used. For Slim Teddy, the bitsets in the lower 128-bits are the same as +/// the bitsets in the higher 128-bits, so that we can search 32 bytes at a +/// time. (Remember, the nybbles in the haystack are used as indices into these +/// masks, and 256-bit shuffles only operate on 128-bit lanes.) +/// +/// For Fat Teddy, the bitsets are not repeated, but instead, the high 128 +/// bits correspond to buckets 8-15. So that a bitset `00100010` has buckets +/// 1 and 5 set if it's in the lower 128 bits, but has buckets 9 and 13 set +/// if it's in the higher 128 bits. +#[derive(Clone, Copy, Debug)] +pub struct Mask256 { + lo: __m256i, + hi: __m256i, +} + +impl Mask256 { + /// Create a new SIMD mask from the mask produced by the Teddy builder. + pub fn new(mask: compile::Mask) -> Mask256 { + // SAFETY: This is safe since [u8; 32] has the same representation + // as __m256i. + unsafe { + Mask256 { + lo: mem::transmute(mask.lo256()), + hi: mem::transmute(mask.hi256()), + } + } + } +} + +// The "members" routines below are responsible for taking a chunk of bytes, +// a number of nybble masks and returning the result of using the masks to +// lookup bytes in the chunk. The results of the high and low nybble masks are +// AND'ed together, such that each candidate returned is a vector, with byte +// sized lanes, and where each lane is an 8-bit bitset corresponding to the +// buckets that contain the corresponding byte. +// +// In the case of masks of length greater than 1, callers will need to keep +// the results from the previous haystack's window, and then shift the vectors +// so that they all line up. Then they can be AND'ed together. + +/// Return a candidate for Slim 128-bit Teddy, where `chunk` corresponds to a +/// 16-byte window of the haystack (where the least significant byte +/// corresponds to the start of the window), and `mask1` corresponds to a +/// low/high mask for the first byte of all patterns that are being searched. +#[target_feature(enable = "ssse3")] +unsafe fn members1m128(chunk: __m128i, mask1: Mask128) -> __m128i { + let lomask = _mm_set1_epi8(0xF); + let hlo = _mm_and_si128(chunk, lomask); + let hhi = _mm_and_si128(_mm_srli_epi16(chunk, 4), lomask); + _mm_and_si128( + _mm_shuffle_epi8(mask1.lo, hlo), + _mm_shuffle_epi8(mask1.hi, hhi), + ) +} + +/// Return a candidate for Slim 256-bit Teddy, where `chunk` corresponds to a +/// 32-byte window of the haystack (where the least significant byte +/// corresponds to the start of the window), and `mask1` corresponds to a +/// low/high mask for the first byte of all patterns that are being searched. +/// +/// Note that this can also be used for Fat Teddy, where the high 128 bits in +/// `chunk` is the same as the low 128 bits, which corresponds to a 16 byte +/// window in the haystack. +#[target_feature(enable = "avx2")] +unsafe fn members1m256(chunk: __m256i, mask1: Mask256) -> __m256i { + let lomask = _mm256_set1_epi8(0xF); + let hlo = _mm256_and_si256(chunk, lomask); + let hhi = _mm256_and_si256(_mm256_srli_epi16(chunk, 4), lomask); + _mm256_and_si256( + _mm256_shuffle_epi8(mask1.lo, hlo), + _mm256_shuffle_epi8(mask1.hi, hhi), + ) +} + +/// Return candidates for Slim 128-bit Teddy, where `chunk` corresponds +/// to a 16-byte window of the haystack (where the least significant byte +/// corresponds to the start of the window), and the masks correspond to a +/// low/high mask for the first and second bytes of all patterns that are being +/// searched. The vectors returned correspond to candidates for the first and +/// second bytes in the patterns represented by the masks. +#[target_feature(enable = "ssse3")] +unsafe fn members2m128( + chunk: __m128i, + mask1: Mask128, + mask2: Mask128, +) -> (__m128i, __m128i) { + let lomask = _mm_set1_epi8(0xF); + let hlo = _mm_and_si128(chunk, lomask); + let hhi = _mm_and_si128(_mm_srli_epi16(chunk, 4), lomask); + let res0 = _mm_and_si128( + _mm_shuffle_epi8(mask1.lo, hlo), + _mm_shuffle_epi8(mask1.hi, hhi), + ); + let res1 = _mm_and_si128( + _mm_shuffle_epi8(mask2.lo, hlo), + _mm_shuffle_epi8(mask2.hi, hhi), + ); + (res0, res1) +} + +/// Return candidates for Slim 256-bit Teddy, where `chunk` corresponds +/// to a 32-byte window of the haystack (where the least significant byte +/// corresponds to the start of the window), and the masks correspond to a +/// low/high mask for the first and second bytes of all patterns that are being +/// searched. The vectors returned correspond to candidates for the first and +/// second bytes in the patterns represented by the masks. +/// +/// Note that this can also be used for Fat Teddy, where the high 128 bits in +/// `chunk` is the same as the low 128 bits, which corresponds to a 16 byte +/// window in the haystack. +#[target_feature(enable = "avx2")] +unsafe fn members2m256( + chunk: __m256i, + mask1: Mask256, + mask2: Mask256, +) -> (__m256i, __m256i) { + let lomask = _mm256_set1_epi8(0xF); + let hlo = _mm256_and_si256(chunk, lomask); + let hhi = _mm256_and_si256(_mm256_srli_epi16(chunk, 4), lomask); + let res0 = _mm256_and_si256( + _mm256_shuffle_epi8(mask1.lo, hlo), + _mm256_shuffle_epi8(mask1.hi, hhi), + ); + let res1 = _mm256_and_si256( + _mm256_shuffle_epi8(mask2.lo, hlo), + _mm256_shuffle_epi8(mask2.hi, hhi), + ); + (res0, res1) +} + +/// Return candidates for Slim 128-bit Teddy, where `chunk` corresponds +/// to a 16-byte window of the haystack (where the least significant byte +/// corresponds to the start of the window), and the masks correspond to a +/// low/high mask for the first, second and third bytes of all patterns that +/// are being searched. The vectors returned correspond to candidates for the +/// first, second and third bytes in the patterns represented by the masks. +#[target_feature(enable = "ssse3")] +unsafe fn members3m128( + chunk: __m128i, + mask1: Mask128, + mask2: Mask128, + mask3: Mask128, +) -> (__m128i, __m128i, __m128i) { + let lomask = _mm_set1_epi8(0xF); + let hlo = _mm_and_si128(chunk, lomask); + let hhi = _mm_and_si128(_mm_srli_epi16(chunk, 4), lomask); + let res0 = _mm_and_si128( + _mm_shuffle_epi8(mask1.lo, hlo), + _mm_shuffle_epi8(mask1.hi, hhi), + ); + let res1 = _mm_and_si128( + _mm_shuffle_epi8(mask2.lo, hlo), + _mm_shuffle_epi8(mask2.hi, hhi), + ); + let res2 = _mm_and_si128( + _mm_shuffle_epi8(mask3.lo, hlo), + _mm_shuffle_epi8(mask3.hi, hhi), + ); + (res0, res1, res2) +} + +/// Return candidates for Slim 256-bit Teddy, where `chunk` corresponds +/// to a 32-byte window of the haystack (where the least significant byte +/// corresponds to the start of the window), and the masks correspond to a +/// low/high mask for the first, second and third bytes of all patterns that +/// are being searched. The vectors returned correspond to candidates for the +/// first, second and third bytes in the patterns represented by the masks. +/// +/// Note that this can also be used for Fat Teddy, where the high 128 bits in +/// `chunk` is the same as the low 128 bits, which corresponds to a 16 byte +/// window in the haystack. +#[target_feature(enable = "avx2")] +unsafe fn members3m256( + chunk: __m256i, + mask1: Mask256, + mask2: Mask256, + mask3: Mask256, +) -> (__m256i, __m256i, __m256i) { + let lomask = _mm256_set1_epi8(0xF); + let hlo = _mm256_and_si256(chunk, lomask); + let hhi = _mm256_and_si256(_mm256_srli_epi16(chunk, 4), lomask); + let res0 = _mm256_and_si256( + _mm256_shuffle_epi8(mask1.lo, hlo), + _mm256_shuffle_epi8(mask1.hi, hhi), + ); + let res1 = _mm256_and_si256( + _mm256_shuffle_epi8(mask2.lo, hlo), + _mm256_shuffle_epi8(mask2.hi, hhi), + ); + let res2 = _mm256_and_si256( + _mm256_shuffle_epi8(mask3.lo, hlo), + _mm256_shuffle_epi8(mask3.hi, hhi), + ); + (res0, res1, res2) +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/tests.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/tests.rs new file mode 100644 index 0000000..a384396 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/tests.rs @@ -0,0 +1,568 @@ +use std::collections::HashMap; +use std::usize; + +use packed::{Config, MatchKind}; +use Match; + +/// A description of a single test against a multi-pattern searcher. +/// +/// A single test may not necessarily pass on every configuration of a +/// searcher. The tests are categorized and grouped appropriately below. +#[derive(Clone, Debug, Eq, PartialEq)] +struct SearchTest { + /// The name of this test, for debugging. + name: &'static str, + /// The patterns to search for. + patterns: &'static [&'static str], + /// The text to search. + haystack: &'static str, + /// Each match is a triple of (pattern_index, start, end), where + /// pattern_index is an index into `patterns` and `start`/`end` are indices + /// into `haystack`. + matches: &'static [(usize, usize, usize)], +} + +struct SearchTestOwned { + offset: usize, + name: String, + patterns: Vec, + haystack: String, + matches: Vec<(usize, usize, usize)>, +} + +impl SearchTest { + fn variations(&self) -> Vec { + let mut tests = vec![]; + for i in 0..=260 { + tests.push(self.offset_prefix(i)); + tests.push(self.offset_suffix(i)); + tests.push(self.offset_both(i)); + } + tests + } + + fn offset_both(&self, off: usize) -> SearchTestOwned { + SearchTestOwned { + offset: off, + name: self.name.to_string(), + patterns: self.patterns.iter().map(|s| s.to_string()).collect(), + haystack: format!( + "{}{}{}", + "Z".repeat(off), + self.haystack, + "Z".repeat(off) + ), + matches: self + .matches + .iter() + .map(|&(id, s, e)| (id, s + off, e + off)) + .collect(), + } + } + + fn offset_prefix(&self, off: usize) -> SearchTestOwned { + SearchTestOwned { + offset: off, + name: self.name.to_string(), + patterns: self.patterns.iter().map(|s| s.to_string()).collect(), + haystack: format!("{}{}", "Z".repeat(off), self.haystack), + matches: self + .matches + .iter() + .map(|&(id, s, e)| (id, s + off, e + off)) + .collect(), + } + } + + fn offset_suffix(&self, off: usize) -> SearchTestOwned { + SearchTestOwned { + offset: off, + name: self.name.to_string(), + patterns: self.patterns.iter().map(|s| s.to_string()).collect(), + haystack: format!("{}{}", self.haystack, "Z".repeat(off)), + matches: self.matches.to_vec(), + } + } + + // fn to_owned(&self) -> SearchTestOwned { + // SearchTestOwned { + // name: self.name.to_string(), + // patterns: self.patterns.iter().map(|s| s.to_string()).collect(), + // haystack: self.haystack.to_string(), + // matches: self.matches.iter().cloned().collect(), + // } + // } +} + +/// Short-hand constructor for SearchTest. We use it a lot below. +macro_rules! t { + ($name:ident, $patterns:expr, $haystack:expr, $matches:expr) => { + SearchTest { + name: stringify!($name), + patterns: $patterns, + haystack: $haystack, + matches: $matches, + } + }; +} + +/// A collection of test groups. +type TestCollection = &'static [&'static [SearchTest]]; + +// Define several collections corresponding to the different type of match +// semantics supported. These collections have some overlap, but each +// collection should have some tests that no other collection has. + +/// Tests for leftmost-first match semantics. +const PACKED_LEFTMOST_FIRST: TestCollection = + &[BASICS, LEFTMOST, LEFTMOST_FIRST, REGRESSION, TEDDY]; + +/// Tests for leftmost-longest match semantics. +const PACKED_LEFTMOST_LONGEST: TestCollection = + &[BASICS, LEFTMOST, LEFTMOST_LONGEST, REGRESSION, TEDDY]; + +// Now define the individual tests that make up the collections above. + +/// A collection of tests for the that should always be true regardless of +/// match semantics. That is, all combinations of leftmost-{first, longest} +/// should produce the same answer. +const BASICS: &'static [SearchTest] = &[ + t!(basic001, &["a"], "", &[]), + t!(basic010, &["a"], "a", &[(0, 0, 1)]), + t!(basic020, &["a"], "aa", &[(0, 0, 1), (0, 1, 2)]), + t!(basic030, &["a"], "aaa", &[(0, 0, 1), (0, 1, 2), (0, 2, 3)]), + t!(basic040, &["a"], "aba", &[(0, 0, 1), (0, 2, 3)]), + t!(basic050, &["a"], "bba", &[(0, 2, 3)]), + t!(basic060, &["a"], "bbb", &[]), + t!(basic070, &["a"], "bababbbba", &[(0, 1, 2), (0, 3, 4), (0, 8, 9)]), + t!(basic100, &["aa"], "", &[]), + t!(basic110, &["aa"], "aa", &[(0, 0, 2)]), + t!(basic120, &["aa"], "aabbaa", &[(0, 0, 2), (0, 4, 6)]), + t!(basic130, &["aa"], "abbab", &[]), + t!(basic140, &["aa"], "abbabaa", &[(0, 5, 7)]), + t!(basic150, &["aaa"], "aaa", &[(0, 0, 3)]), + t!(basic200, &["abc"], "abc", &[(0, 0, 3)]), + t!(basic210, &["abc"], "zazabzabcz", &[(0, 6, 9)]), + t!(basic220, &["abc"], "zazabczabcz", &[(0, 3, 6), (0, 7, 10)]), + t!(basic300, &["a", "b"], "", &[]), + t!(basic310, &["a", "b"], "z", &[]), + t!(basic320, &["a", "b"], "b", &[(1, 0, 1)]), + t!(basic330, &["a", "b"], "a", &[(0, 0, 1)]), + t!( + basic340, + &["a", "b"], + "abba", + &[(0, 0, 1), (1, 1, 2), (1, 2, 3), (0, 3, 4),] + ), + t!( + basic350, + &["b", "a"], + "abba", + &[(1, 0, 1), (0, 1, 2), (0, 2, 3), (1, 3, 4),] + ), + t!(basic360, &["abc", "bc"], "xbc", &[(1, 1, 3),]), + t!(basic400, &["foo", "bar"], "", &[]), + t!(basic410, &["foo", "bar"], "foobar", &[(0, 0, 3), (1, 3, 6),]), + t!(basic420, &["foo", "bar"], "barfoo", &[(1, 0, 3), (0, 3, 6),]), + t!(basic430, &["foo", "bar"], "foofoo", &[(0, 0, 3), (0, 3, 6),]), + t!(basic440, &["foo", "bar"], "barbar", &[(1, 0, 3), (1, 3, 6),]), + t!(basic450, &["foo", "bar"], "bafofoo", &[(0, 4, 7),]), + t!(basic460, &["bar", "foo"], "bafofoo", &[(1, 4, 7),]), + t!(basic470, &["foo", "bar"], "fobabar", &[(1, 4, 7),]), + t!(basic480, &["bar", "foo"], "fobabar", &[(0, 4, 7),]), + t!(basic700, &["yabcdef", "abcdezghi"], "yabcdefghi", &[(0, 0, 7),]), + t!(basic710, &["yabcdef", "abcdezghi"], "yabcdezghi", &[(1, 1, 10),]), + t!( + basic720, + &["yabcdef", "bcdeyabc", "abcdezghi"], + "yabcdezghi", + &[(2, 1, 10),] + ), + t!(basic810, &["abcd", "bcd", "cd"], "abcd", &[(0, 0, 4),]), + t!(basic820, &["bcd", "cd", "abcd"], "abcd", &[(2, 0, 4),]), + t!(basic830, &["abc", "bc"], "zazabcz", &[(0, 3, 6),]), + t!( + basic840, + &["ab", "ba"], + "abababa", + &[(0, 0, 2), (0, 2, 4), (0, 4, 6),] + ), + t!(basic850, &["foo", "foo"], "foobarfoo", &[(0, 0, 3), (0, 6, 9),]), +]; + +/// Tests for leftmost match semantics. These should pass for both +/// leftmost-first and leftmost-longest match kinds. Stated differently, among +/// ambiguous matches, the longest match and the match that appeared first when +/// constructing the automaton should always be the same. +const LEFTMOST: &'static [SearchTest] = &[ + t!(leftmost000, &["ab", "ab"], "abcd", &[(0, 0, 2)]), + t!(leftmost030, &["a", "ab"], "aa", &[(0, 0, 1), (0, 1, 2)]), + t!(leftmost031, &["ab", "a"], "aa", &[(1, 0, 1), (1, 1, 2)]), + t!(leftmost032, &["ab", "a"], "xayabbbz", &[(1, 1, 2), (0, 3, 5)]), + t!(leftmost300, &["abcd", "bce", "b"], "abce", &[(1, 1, 4)]), + t!(leftmost310, &["abcd", "ce", "bc"], "abce", &[(2, 1, 3)]), + t!(leftmost320, &["abcd", "bce", "ce", "b"], "abce", &[(1, 1, 4)]), + t!(leftmost330, &["abcd", "bce", "cz", "bc"], "abcz", &[(3, 1, 3)]), + t!(leftmost340, &["bce", "cz", "bc"], "bcz", &[(2, 0, 2)]), + t!(leftmost350, &["abc", "bd", "ab"], "abd", &[(2, 0, 2)]), + t!( + leftmost360, + &["abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(2, 0, 8),] + ), + t!( + leftmost370, + &["abcdefghi", "cde", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!( + leftmost380, + &["abcdefghi", "hz", "abcdefgh", "a"], + "abcdefghz", + &[(2, 0, 8),] + ), + t!( + leftmost390, + &["b", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!( + leftmost400, + &["h", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!( + leftmost410, + &["z", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8), (0, 8, 9),] + ), +]; + +/// Tests for non-overlapping leftmost-first match semantics. These tests +/// should generally be specific to leftmost-first, which means they should +/// generally fail under leftmost-longest semantics. +const LEFTMOST_FIRST: &'static [SearchTest] = &[ + t!(leftfirst000, &["ab", "abcd"], "abcd", &[(0, 0, 2)]), + t!(leftfirst020, &["abcd", "ab"], "abcd", &[(0, 0, 4)]), + t!(leftfirst030, &["ab", "ab"], "abcd", &[(0, 0, 2)]), + t!(leftfirst040, &["a", "ab"], "xayabbbz", &[(0, 1, 2), (0, 3, 4)]), + t!(leftfirst100, &["abcdefg", "bcde", "bcdef"], "abcdef", &[(1, 1, 5)]), + t!(leftfirst110, &["abcdefg", "bcdef", "bcde"], "abcdef", &[(1, 1, 6)]), + t!(leftfirst300, &["abcd", "b", "bce"], "abce", &[(1, 1, 2)]), + t!( + leftfirst310, + &["abcd", "b", "bce", "ce"], + "abce", + &[(1, 1, 2), (3, 2, 4),] + ), + t!( + leftfirst320, + &["a", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(0, 0, 1), (2, 7, 9),] + ), + t!(leftfirst330, &["a", "abab"], "abab", &[(0, 0, 1), (0, 2, 3)]), + t!( + leftfirst340, + &["abcdef", "x", "x", "x", "x", "x", "x", "abcde"], + "abcdef", + &[(0, 0, 6)] + ), +]; + +/// Tests for non-overlapping leftmost-longest match semantics. These tests +/// should generally be specific to leftmost-longest, which means they should +/// generally fail under leftmost-first semantics. +const LEFTMOST_LONGEST: &'static [SearchTest] = &[ + t!(leftlong000, &["ab", "abcd"], "abcd", &[(1, 0, 4)]), + t!(leftlong010, &["abcd", "bcd", "cd", "b"], "abcd", &[(0, 0, 4),]), + t!(leftlong040, &["a", "ab"], "a", &[(0, 0, 1)]), + t!(leftlong050, &["a", "ab"], "ab", &[(1, 0, 2)]), + t!(leftlong060, &["ab", "a"], "a", &[(1, 0, 1)]), + t!(leftlong070, &["ab", "a"], "ab", &[(0, 0, 2)]), + t!(leftlong100, &["abcdefg", "bcde", "bcdef"], "abcdef", &[(2, 1, 6)]), + t!(leftlong110, &["abcdefg", "bcdef", "bcde"], "abcdef", &[(1, 1, 6)]), + t!(leftlong300, &["abcd", "b", "bce"], "abce", &[(2, 1, 4)]), + t!( + leftlong310, + &["a", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!(leftlong320, &["a", "abab"], "abab", &[(1, 0, 4)]), + t!(leftlong330, &["abcd", "b", "ce"], "abce", &[(1, 1, 2), (2, 2, 4),]), + t!(leftlong340, &["a", "ab"], "xayabbbz", &[(0, 1, 2), (1, 3, 5)]), +]; + +/// Regression tests that are applied to all combinations. +/// +/// If regression tests are needed for specific match semantics, then add them +/// to the appropriate group above. +const REGRESSION: &'static [SearchTest] = &[ + t!(regression010, &["inf", "ind"], "infind", &[(0, 0, 3), (1, 3, 6),]), + t!(regression020, &["ind", "inf"], "infind", &[(1, 0, 3), (0, 3, 6),]), + t!( + regression030, + &["libcore/", "libstd/"], + "libcore/char/methods.rs", + &[(0, 0, 8),] + ), + t!( + regression040, + &["libstd/", "libcore/"], + "libcore/char/methods.rs", + &[(1, 0, 8),] + ), + t!( + regression050, + &["\x00\x00\x01", "\x00\x00\x00"], + "\x00\x00\x00", + &[(1, 0, 3),] + ), + t!( + regression060, + &["\x00\x00\x00", "\x00\x00\x01"], + "\x00\x00\x00", + &[(0, 0, 3),] + ), +]; + +const TEDDY: &'static [SearchTest] = &[ + t!( + teddy010, + &["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"], + "abcdefghijk", + &[ + (0, 0, 1), + (1, 1, 2), + (2, 2, 3), + (3, 3, 4), + (4, 4, 5), + (5, 5, 6), + (6, 6, 7), + (7, 7, 8), + (8, 8, 9), + (9, 9, 10), + (10, 10, 11) + ] + ), + t!( + teddy020, + &["ab", "bc", "cd", "de", "ef", "fg", "gh", "hi", "ij", "jk", "kl"], + "abcdefghijk", + &[(0, 0, 2), (2, 2, 4), (4, 4, 6), (6, 6, 8), (8, 8, 10),] + ), + t!( + teddy030, + &["abc"], + "abcdefghijklmnopqrstuvwxyzabcdefghijk", + &[(0, 0, 3), (0, 26, 29)] + ), +]; + +// Now define a test for each combination of things above that we want to run. +// Since there are a few different combinations for each collection of tests, +// we define a couple of macros to avoid repetition drudgery. The testconfig +// macro constructs the automaton from a given match kind, and runs the search +// tests one-by-one over the given collection. The `with` parameter allows one +// to configure the config with additional parameters. The testcombo macro +// invokes testconfig in precisely this way: it sets up several tests where +// each one turns a different knob on Config. + +macro_rules! testconfig { + ($name:ident, $collection:expr, $with:expr) => { + #[test] + fn $name() { + run_search_tests($collection, |test| { + let mut config = Config::new(); + $with(&mut config); + config + .builder() + .extend(test.patterns.iter().map(|p| p.as_bytes())) + .build() + .unwrap() + .find_iter(&test.haystack) + .collect() + }); + } + }; +} + +#[cfg(target_arch = "x86_64")] +testconfig!( + search_default_leftmost_first, + PACKED_LEFTMOST_FIRST, + |_: &mut Config| {} +); + +#[cfg(target_arch = "x86_64")] +testconfig!( + search_default_leftmost_longest, + PACKED_LEFTMOST_LONGEST, + |c: &mut Config| { + c.match_kind(MatchKind::LeftmostLongest); + } +); + +#[cfg(target_arch = "x86_64")] +testconfig!( + search_teddy_leftmost_first, + PACKED_LEFTMOST_FIRST, + |c: &mut Config| { + c.force_teddy(true); + } +); + +#[cfg(target_arch = "x86_64")] +testconfig!( + search_teddy_leftmost_longest, + PACKED_LEFTMOST_LONGEST, + |c: &mut Config| { + c.force_teddy(true).match_kind(MatchKind::LeftmostLongest); + } +); + +#[cfg(target_arch = "x86_64")] +testconfig!( + search_teddy_ssse3_leftmost_first, + PACKED_LEFTMOST_FIRST, + |c: &mut Config| { + c.force_teddy(true); + if is_x86_feature_detected!("ssse3") { + c.force_avx(Some(false)); + } + } +); + +#[cfg(target_arch = "x86_64")] +testconfig!( + search_teddy_ssse3_leftmost_longest, + PACKED_LEFTMOST_LONGEST, + |c: &mut Config| { + c.force_teddy(true).match_kind(MatchKind::LeftmostLongest); + if is_x86_feature_detected!("ssse3") { + c.force_avx(Some(false)); + } + } +); + +#[cfg(target_arch = "x86_64")] +testconfig!( + search_teddy_avx2_leftmost_first, + PACKED_LEFTMOST_FIRST, + |c: &mut Config| { + c.force_teddy(true); + if is_x86_feature_detected!("avx2") { + c.force_avx(Some(true)); + } + } +); + +#[cfg(target_arch = "x86_64")] +testconfig!( + search_teddy_avx2_leftmost_longest, + PACKED_LEFTMOST_LONGEST, + |c: &mut Config| { + c.force_teddy(true).match_kind(MatchKind::LeftmostLongest); + if is_x86_feature_detected!("avx2") { + c.force_avx(Some(true)); + } + } +); + +#[cfg(target_arch = "x86_64")] +testconfig!( + search_teddy_fat_leftmost_first, + PACKED_LEFTMOST_FIRST, + |c: &mut Config| { + c.force_teddy(true); + if is_x86_feature_detected!("avx2") { + c.force_teddy_fat(Some(true)); + } + } +); + +#[cfg(target_arch = "x86_64")] +testconfig!( + search_teddy_fat_leftmost_longest, + PACKED_LEFTMOST_LONGEST, + |c: &mut Config| { + c.force_teddy(true).match_kind(MatchKind::LeftmostLongest); + if is_x86_feature_detected!("avx2") { + c.force_teddy_fat(Some(true)); + } + } +); + +testconfig!( + search_rabinkarp_leftmost_first, + PACKED_LEFTMOST_FIRST, + |c: &mut Config| { + c.force_rabin_karp(true); + } +); + +testconfig!( + search_rabinkarp_leftmost_longest, + PACKED_LEFTMOST_LONGEST, + |c: &mut Config| { + c.force_rabin_karp(true).match_kind(MatchKind::LeftmostLongest); + } +); + +#[test] +fn search_tests_have_unique_names() { + let assert = |constname, tests: &[SearchTest]| { + let mut seen = HashMap::new(); // map from test name to position + for (i, test) in tests.iter().enumerate() { + if !seen.contains_key(test.name) { + seen.insert(test.name, i); + } else { + let last = seen[test.name]; + panic!( + "{} tests have duplicate names at positions {} and {}", + constname, last, i + ); + } + } + }; + assert("BASICS", BASICS); + assert("LEFTMOST", LEFTMOST); + assert("LEFTMOST_FIRST", LEFTMOST_FIRST); + assert("LEFTMOST_LONGEST", LEFTMOST_LONGEST); + assert("REGRESSION", REGRESSION); + assert("TEDDY", TEDDY); +} + +fn run_search_tests Vec>( + which: TestCollection, + mut f: F, +) { + let get_match_triples = + |matches: Vec| -> Vec<(usize, usize, usize)> { + matches + .into_iter() + .map(|m| (m.pattern(), m.start(), m.end())) + .collect() + }; + for &tests in which { + for spec in tests { + for test in spec.variations() { + assert_eq!( + test.matches, + get_match_triples(f(&test)).as_slice(), + "test: {}, patterns: {:?}, haystack: {:?}, offset: {:?}", + test.name, + test.patterns, + test.haystack, + test.offset, + ); + } + } + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/vector.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/vector.rs new file mode 100644 index 0000000..ca6c2b0 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/packed/vector.rs @@ -0,0 +1,181 @@ +// This file contains a set of fairly generic utility functions when working +// with SIMD vectors. +// +// SAFETY: All of the routines below are unsafe to call because they assume +// the necessary CPU target features in order to use particular vendor +// intrinsics. Calling these routines when the underlying CPU does not support +// the appropriate target features is NOT safe. Callers must ensure this +// themselves. +// +// Note that it may not look like this safety invariant is being upheld when +// these routines are called. Namely, the CPU feature check is typically pretty +// far away from when these routines are used. Instead, we rely on the fact +// that certain types serve as a guaranteed receipt that pertinent target +// features are enabled. For example, the only way TeddySlim3Mask256 can be +// constructed is if the AVX2 CPU feature is available. Thus, any code running +// inside of TeddySlim3Mask256 can use any of the functions below without any +// additional checks: its very existence *is* the check. + +use std::arch::x86_64::*; + +/// Shift `a` to the left by two bytes (removing its two most significant +/// bytes), and concatenate it with the the two most significant bytes of `b`. +#[target_feature(enable = "avx2")] +pub unsafe fn alignr256_14(a: __m256i, b: __m256i) -> __m256i { + // Credit goes to jneem for figuring this out: + // https://github.com/jneem/teddy/blob/9ab5e899ad6ef6911aecd3cf1033f1abe6e1f66c/src/x86/teddy_simd.rs#L145-L184 + // + // TL;DR avx2's PALIGNR instruction is actually just two 128-bit PALIGNR + // instructions, which is not what we want, so we need to do some extra + // shuffling. + + // This permute gives us the low 16 bytes of a concatenated with the high + // 16 bytes of b, in order of most significant to least significant. So + // `v = a[15:0] b[31:16]`. + let v = _mm256_permute2x128_si256(b, a, 0x21); + // This effectively does this (where we deal in terms of byte-indexing + // and byte-shifting, and use inclusive ranges): + // + // ret[15:0] := ((a[15:0] << 16) | v[15:0]) >> 14 + // = ((a[15:0] << 16) | b[31:16]) >> 14 + // ret[31:16] := ((a[31:16] << 16) | v[31:16]) >> 14 + // = ((a[31:16] << 16) | a[15:0]) >> 14 + // + // Which therefore results in: + // + // ret[31:0] := a[29:16] a[15:14] a[13:0] b[31:30] + // + // The end result is that we've effectively done this: + // + // (a << 2) | (b >> 30) + // + // When `A` and `B` are strings---where the beginning of the string is in + // the least significant bits---we effectively result in the following + // semantic operation: + // + // (A >> 2) | (B << 30) + // + // The reversal being attributed to the fact that we are in little-endian. + _mm256_alignr_epi8(a, v, 14) +} + +/// Shift `a` to the left by one byte (removing its most significant byte), and +/// concatenate it with the the most significant byte of `b`. +#[target_feature(enable = "avx2")] +pub unsafe fn alignr256_15(a: __m256i, b: __m256i) -> __m256i { + // For explanation, see alignr256_14. + let v = _mm256_permute2x128_si256(b, a, 0x21); + _mm256_alignr_epi8(a, v, 15) +} + +/// Unpack the given 128-bit vector into its 64-bit components. The first +/// element of the array returned corresponds to the least significant 64-bit +/// lane in `a`. +#[target_feature(enable = "ssse3")] +pub unsafe fn unpack64x128(a: __m128i) -> [u64; 2] { + [ + _mm_cvtsi128_si64(a) as u64, + _mm_cvtsi128_si64(_mm_srli_si128(a, 8)) as u64, + ] +} + +/// Unpack the given 256-bit vector into its 64-bit components. The first +/// element of the array returned corresponds to the least significant 64-bit +/// lane in `a`. +#[target_feature(enable = "avx2")] +pub unsafe fn unpack64x256(a: __m256i) -> [u64; 4] { + // Using transmute here is precisely equivalent, but actually slower. It's + // not quite clear why. + let lo = _mm256_extracti128_si256(a, 0); + let hi = _mm256_extracti128_si256(a, 1); + [ + _mm_cvtsi128_si64(lo) as u64, + _mm_cvtsi128_si64(_mm_srli_si128(lo, 8)) as u64, + _mm_cvtsi128_si64(hi) as u64, + _mm_cvtsi128_si64(_mm_srli_si128(hi, 8)) as u64, + ] +} + +/// Unpack the low 128-bits of `a` and `b`, and return them as 4 64-bit +/// integers. +/// +/// More precisely, if a = a4 a3 a2 a1 and b = b4 b3 b2 b1, where each element +/// is a 64-bit integer and a1/b1 correspond to the least significant 64 bits, +/// then the return value is `b2 b1 a2 a1`. +#[target_feature(enable = "avx2")] +pub unsafe fn unpacklo64x256(a: __m256i, b: __m256i) -> [u64; 4] { + let lo = _mm256_castsi256_si128(a); + let hi = _mm256_castsi256_si128(b); + [ + _mm_cvtsi128_si64(lo) as u64, + _mm_cvtsi128_si64(_mm_srli_si128(lo, 8)) as u64, + _mm_cvtsi128_si64(hi) as u64, + _mm_cvtsi128_si64(_mm_srli_si128(hi, 8)) as u64, + ] +} + +/// Returns true if and only if all bits in the given 128-bit vector are 0. +#[target_feature(enable = "ssse3")] +pub unsafe fn is_all_zeroes128(a: __m128i) -> bool { + let cmp = _mm_cmpeq_epi8(a, zeroes128()); + _mm_movemask_epi8(cmp) as u32 == 0xFFFF +} + +/// Returns true if and only if all bits in the given 256-bit vector are 0. +#[target_feature(enable = "avx2")] +pub unsafe fn is_all_zeroes256(a: __m256i) -> bool { + let cmp = _mm256_cmpeq_epi8(a, zeroes256()); + _mm256_movemask_epi8(cmp) as u32 == 0xFFFFFFFF +} + +/// Load a 128-bit vector from slice at the given position. The slice does +/// not need to be unaligned. +/// +/// Since this code assumes little-endian (there is no big-endian x86), the +/// bytes starting in `slice[at..]` will be at the least significant bits of +/// the returned vector. This is important for the surrounding code, since for +/// example, shifting the resulting vector right is equivalent to logically +/// shifting the bytes in `slice` left. +#[target_feature(enable = "sse2")] +pub unsafe fn loadu128(slice: &[u8], at: usize) -> __m128i { + let ptr = slice.get_unchecked(at..).as_ptr(); + _mm_loadu_si128(ptr as *const u8 as *const __m128i) +} + +/// Load a 256-bit vector from slice at the given position. The slice does +/// not need to be unaligned. +/// +/// Since this code assumes little-endian (there is no big-endian x86), the +/// bytes starting in `slice[at..]` will be at the least significant bits of +/// the returned vector. This is important for the surrounding code, since for +/// example, shifting the resulting vector right is equivalent to logically +/// shifting the bytes in `slice` left. +#[target_feature(enable = "avx2")] +pub unsafe fn loadu256(slice: &[u8], at: usize) -> __m256i { + let ptr = slice.get_unchecked(at..).as_ptr(); + _mm256_loadu_si256(ptr as *const u8 as *const __m256i) +} + +/// Returns a 128-bit vector with all bits set to 0. +#[target_feature(enable = "sse2")] +pub unsafe fn zeroes128() -> __m128i { + _mm_set1_epi8(0) +} + +/// Returns a 256-bit vector with all bits set to 0. +#[target_feature(enable = "avx2")] +pub unsafe fn zeroes256() -> __m256i { + _mm256_set1_epi8(0) +} + +/// Returns a 128-bit vector with all bits set to 1. +#[target_feature(enable = "sse2")] +pub unsafe fn ones128() -> __m128i { + _mm_set1_epi8(0xFF as u8 as i8) +} + +/// Returns a 256-bit vector with all bits set to 1. +#[target_feature(enable = "avx2")] +pub unsafe fn ones256() -> __m256i { + _mm256_set1_epi8(0xFF as u8 as i8) +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/prefilter.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/prefilter.rs new file mode 100644 index 0000000..21b5658 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/prefilter.rs @@ -0,0 +1,955 @@ +use std::cmp; +use std::fmt; +use std::panic::{RefUnwindSafe, UnwindSafe}; +use std::u8; + +use memchr::{memchr, memchr2, memchr3}; + +use ahocorasick::MatchKind; +use packed; +use Match; + +/// A candidate is the result of running a prefilter on a haystack at a +/// particular position. The result is either no match, a confirmed match or +/// a possible match. +/// +/// When no match is returned, the prefilter is guaranteeing that no possible +/// match can be found in the haystack, and the caller may trust this. That is, +/// all correct prefilters must never report false negatives. +/// +/// In some cases, a prefilter can confirm a match very quickly, in which case, +/// the caller may use this to stop what it's doing and report the match. In +/// this case, prefilter implementations must never report a false positive. +/// In other cases, the prefilter can only report a potential match, in which +/// case the callers must attempt to confirm the match. In this case, prefilter +/// implementations are permitted to return false positives. +#[derive(Clone, Debug)] +pub enum Candidate { + None, + Match(Match), + PossibleStartOfMatch(usize), +} + +impl Candidate { + /// Convert this candidate into an option. This is useful when callers + /// do not distinguish between true positives and false positives (i.e., + /// the caller must always confirm the match in order to update some other + /// state). + pub fn into_option(self) -> Option { + match self { + Candidate::None => None, + Candidate::Match(ref m) => Some(m.start()), + Candidate::PossibleStartOfMatch(start) => Some(start), + } + } +} + +/// A prefilter describes the behavior of fast literal scanners for quickly +/// skipping past bytes in the haystack that we know cannot possibly +/// participate in a match. +pub trait Prefilter: + Send + Sync + RefUnwindSafe + UnwindSafe + fmt::Debug +{ + /// Returns the next possible match candidate. This may yield false + /// positives, so callers must confirm a match starting at the position + /// returned. This, however, must never produce false negatives. That is, + /// this must, at minimum, return the starting position of the next match + /// in the given haystack after or at the given position. + fn next_candidate( + &self, + state: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Candidate; + + /// A method for cloning a prefilter, to work-around the fact that Clone + /// is not object-safe. + fn clone_prefilter(&self) -> Box; + + /// Returns the approximate total amount of heap used by this prefilter, in + /// units of bytes. + fn heap_bytes(&self) -> usize; + + /// Returns true if and only if this prefilter never returns false + /// positives. This is useful for completely avoiding the automaton + /// when the prefilter can quickly confirm its own matches. + /// + /// By default, this returns true, which is conservative; it is always + /// correct to return `true`. Returning `false` here and reporting a false + /// positive will result in incorrect searches. + fn reports_false_positives(&self) -> bool { + true + } +} + +impl<'a, P: Prefilter + ?Sized> Prefilter for &'a P { + #[inline] + fn next_candidate( + &self, + state: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Candidate { + (**self).next_candidate(state, haystack, at) + } + + fn clone_prefilter(&self) -> Box { + (**self).clone_prefilter() + } + + fn heap_bytes(&self) -> usize { + (**self).heap_bytes() + } + + fn reports_false_positives(&self) -> bool { + (**self).reports_false_positives() + } +} + +/// A convenience object for representing any type that implements Prefilter +/// and is cloneable. +#[derive(Debug)] +pub struct PrefilterObj(Box); + +impl Clone for PrefilterObj { + fn clone(&self) -> Self { + PrefilterObj(self.0.clone_prefilter()) + } +} + +impl PrefilterObj { + /// Create a new prefilter object. + pub fn new(t: T) -> PrefilterObj { + PrefilterObj(Box::new(t)) + } + + /// Return the underlying prefilter trait object. + pub fn as_ref(&self) -> &dyn Prefilter { + &*self.0 + } +} + +/// PrefilterState tracks state associated with the effectiveness of a +/// prefilter. It is used to track how many bytes, on average, are skipped by +/// the prefilter. If this average dips below a certain threshold over time, +/// then the state renders the prefilter inert and stops using it. +/// +/// A prefilter state should be created for each search. (Where creating an +/// iterator via, e.g., `find_iter`, is treated as a single search.) +#[derive(Clone, Debug)] +pub struct PrefilterState { + /// The number of skips that has been executed. + skips: usize, + /// The total number of bytes that have been skipped. + skipped: usize, + /// The maximum length of a match. This is used to help determine how many + /// bytes on average should be skipped in order for a prefilter to be + /// effective. + max_match_len: usize, + /// Once this heuristic has been deemed permanently ineffective, it will be + /// inert throughout the rest of its lifetime. This serves as a cheap way + /// to check inertness. + inert: bool, + /// The last (absolute) position at which a prefilter scanned to. + /// Prefilters can use this position to determine whether to re-scan or + /// not. + /// + /// Unlike other things that impact effectiveness, this is a fleeting + /// condition. That is, a prefilter can be considered ineffective if it is + /// at a position before `last_scan_at`, but can become effective again + /// once the search moves past `last_scan_at`. + /// + /// The utility of this is to both avoid additional overhead from calling + /// the prefilter and to avoid quadratic behavior. This ensures that a + /// prefilter will scan any particular byte at most once. (Note that some + /// prefilters, like the start-byte prefilter, do not need to use this + /// field at all, since it only looks for starting bytes.) + last_scan_at: usize, +} + +impl PrefilterState { + /// The minimum number of skip attempts to try before considering whether + /// a prefilter is effective or not. + const MIN_SKIPS: usize = 40; + + /// The minimum amount of bytes that skipping must average, expressed as a + /// factor of the multiple of the length of a possible match. + /// + /// That is, after MIN_SKIPS have occurred, if the average number of bytes + /// skipped ever falls below MIN_AVG_FACTOR * max-match-length, then the + /// prefilter outed to be rendered inert. + const MIN_AVG_FACTOR: usize = 2; + + /// Create a fresh prefilter state. + pub fn new(max_match_len: usize) -> PrefilterState { + PrefilterState { + skips: 0, + skipped: 0, + max_match_len, + inert: false, + last_scan_at: 0, + } + } + + /// Update this state with the number of bytes skipped on the last + /// invocation of the prefilter. + #[inline] + fn update_skipped_bytes(&mut self, skipped: usize) { + self.skips += 1; + self.skipped += skipped; + } + + /// Updates the position at which the last scan stopped. This may be + /// greater than the position of the last candidate reported. For example, + /// searching for the "rare" byte `z` in `abczdef` for the pattern `abcz` + /// will report a candidate at position `0`, but the end of its last scan + /// will be at position `3`. + /// + /// This position factors into the effectiveness of this prefilter. If the + /// current position is less than the last position at which a scan ended, + /// then the prefilter should not be re-run until the search moves past + /// that position. + #[inline] + fn update_at(&mut self, at: usize) { + if at > self.last_scan_at { + self.last_scan_at = at; + } + } + + /// Return true if and only if this state indicates that a prefilter is + /// still effective. + /// + /// The given pos should correspond to the current starting position of the + /// search. + #[inline] + pub fn is_effective(&mut self, at: usize) -> bool { + if self.inert { + return false; + } + if at < self.last_scan_at { + return false; + } + if self.skips < PrefilterState::MIN_SKIPS { + return true; + } + + let min_avg = PrefilterState::MIN_AVG_FACTOR * self.max_match_len; + if self.skipped >= min_avg * self.skips { + return true; + } + + // We're inert. + self.inert = true; + false + } +} + +/// A builder for constructing the best possible prefilter. When constructed, +/// this builder will heuristically select the best prefilter it can build, +/// if any, and discard the rest. +#[derive(Debug)] +pub struct Builder { + count: usize, + ascii_case_insensitive: bool, + start_bytes: StartBytesBuilder, + rare_bytes: RareBytesBuilder, + packed: Option, +} + +impl Builder { + /// Create a new builder for constructing the best possible prefilter. + pub fn new(kind: MatchKind) -> Builder { + let pbuilder = kind + .as_packed() + .map(|kind| packed::Config::new().match_kind(kind).builder()); + Builder { + count: 0, + ascii_case_insensitive: false, + start_bytes: StartBytesBuilder::new(), + rare_bytes: RareBytesBuilder::new(), + packed: pbuilder, + } + } + + /// Enable ASCII case insensitivity. When set, byte strings added to this + /// builder will be interpreted without respect to ASCII case. + pub fn ascii_case_insensitive(mut self, yes: bool) -> Builder { + self.ascii_case_insensitive = yes; + self.start_bytes = self.start_bytes.ascii_case_insensitive(yes); + self.rare_bytes = self.rare_bytes.ascii_case_insensitive(yes); + self + } + + /// Return a prefilter suitable for quickly finding potential matches. + /// + /// All patterns added to an Aho-Corasick automaton should be added to this + /// builder before attempting to construct the prefilter. + pub fn build(&self) -> Option { + match (self.start_bytes.build(), self.rare_bytes.build()) { + // If we could build both start and rare prefilters, then there are + // a few cases in which we'd want to use the start-byte prefilter + // over the rare-byte prefilter, since the former has lower + // overhead. + (prestart @ Some(_), prerare @ Some(_)) => { + // If the start-byte prefilter can scan for a smaller number + // of bytes than the rare-byte prefilter, then it's probably + // faster. + let has_fewer_bytes = + self.start_bytes.count < self.rare_bytes.count; + // Otherwise, if the combined frequency rank of the detected + // bytes in the start-byte prefilter is "close" to the combined + // frequency rank of the rare-byte prefilter, then we pick + // the start-byte prefilter even if the rare-byte prefilter + // heuristically searches for rare bytes. This is because the + // rare-byte prefilter has higher constant costs, so we tend to + // prefer the start-byte prefilter when we can. + let has_rarer_bytes = + self.start_bytes.rank_sum <= self.rare_bytes.rank_sum + 50; + if has_fewer_bytes || has_rarer_bytes { + prestart + } else { + prerare + } + } + (prestart @ Some(_), None) => prestart, + (None, prerare @ Some(_)) => prerare, + (None, None) if self.ascii_case_insensitive => None, + (None, None) => self + .packed + .as_ref() + .and_then(|b| b.build()) + .map(|s| PrefilterObj::new(Packed(s))), + } + } + + /// Add a literal string to this prefilter builder. + pub fn add(&mut self, bytes: &[u8]) { + self.count += 1; + self.start_bytes.add(bytes); + self.rare_bytes.add(bytes); + if let Some(ref mut pbuilder) = self.packed { + pbuilder.add(bytes); + } + } +} + +/// A type that wraps a packed searcher and implements the `Prefilter` +/// interface. +#[derive(Clone, Debug)] +struct Packed(packed::Searcher); + +impl Prefilter for Packed { + fn next_candidate( + &self, + _state: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Candidate { + self.0.find_at(haystack, at).map_or(Candidate::None, Candidate::Match) + } + + fn clone_prefilter(&self) -> Box { + Box::new(self.clone()) + } + + fn heap_bytes(&self) -> usize { + self.0.heap_bytes() + } + + fn reports_false_positives(&self) -> bool { + false + } +} + +/// A builder for constructing a rare byte prefilter. +/// +/// A rare byte prefilter attempts to pick out a small set of rare bytes that +/// occurr in the patterns, and then quickly scan to matches of those rare +/// bytes. +#[derive(Clone, Debug)] +struct RareBytesBuilder { + /// Whether this prefilter should account for ASCII case insensitivity or + /// not. + ascii_case_insensitive: bool, + /// A set of byte offsets associated with detected rare bytes. An entry is + /// only set if a rare byte is detected in a pattern. + byte_offsets: RareByteOffsets, + /// Whether this is available as a prefilter or not. This can be set to + /// false during construction if a condition is seen that invalidates the + /// use of the rare-byte prefilter. + available: bool, + /// The number of bytes set to an active value in `byte_offsets`. + count: usize, + /// The sum of frequency ranks for the rare bytes detected. This is + /// intended to give a heuristic notion of how rare the bytes are. + rank_sum: u16, +} + +/// A set of rare byte offsets, keyed by byte. +#[derive(Clone, Copy)] +struct RareByteOffsets { + /// When an item in this set has an offset of u8::MAX (255), then it is + /// considered unset. + set: [RareByteOffset; 256], +} + +impl RareByteOffsets { + /// Create a new empty set of rare byte offsets. + pub fn empty() -> RareByteOffsets { + RareByteOffsets { set: [RareByteOffset::default(); 256] } + } + + /// Add the given offset for the given byte to this set. If the offset is + /// greater than the existing offset, then it overwrites the previous + /// value and returns false. If there is no previous value set, then this + /// sets it and returns true. + /// + /// The given offset must be active, otherwise this panics. + pub fn apply(&mut self, byte: u8, off: RareByteOffset) -> bool { + assert!(off.is_active()); + + let existing = &mut self.set[byte as usize]; + if !existing.is_active() { + *existing = off; + true + } else { + if existing.max < off.max { + *existing = off; + } + false + } + } +} + +impl fmt::Debug for RareByteOffsets { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut offsets = vec![]; + for off in self.set.iter() { + if off.is_active() { + offsets.push(off); + } + } + f.debug_struct("RareByteOffsets").field("set", &offsets).finish() + } +} + +/// Offsets associated with an occurrence of a "rare" byte in any of the +/// patterns used to construct a single Aho-Corasick automaton. +#[derive(Clone, Copy, Debug)] +struct RareByteOffset { + /// The maximum offset at which a particular byte occurs from the start + /// of any pattern. This is used as a shift amount. That is, when an + /// occurrence of this byte is found, the candidate position reported by + /// the prefilter is `position_of_byte - max`, such that the automaton + /// will begin its search at a position that is guaranteed to observe a + /// match. + /// + /// To avoid accidentally quadratic behavior, a prefilter is considered + /// ineffective when it is asked to start scanning from a position that it + /// has already scanned past. + /// + /// N.B. The maximum value for this is 254. A value of 255 indicates that + /// this is unused. If a rare byte is found at an offset of 255 or greater, + /// then the rare-byte prefilter is disabled for simplicity. + max: u8, +} + +impl Default for RareByteOffset { + fn default() -> RareByteOffset { + RareByteOffset { max: u8::MAX } + } +} + +impl RareByteOffset { + /// Create a new rare byte offset. If the given offset is too big, then + /// an inactive `RareByteOffset` is returned. + fn new(max: usize) -> RareByteOffset { + if max > (u8::MAX - 1) as usize { + RareByteOffset::default() + } else { + RareByteOffset { max: max as u8 } + } + } + + /// Returns true if and only if this offset is active. If it's inactive, + /// then it should not be used. + fn is_active(&self) -> bool { + self.max < u8::MAX + } +} + +impl RareBytesBuilder { + /// Create a new builder for constructing a rare byte prefilter. + fn new() -> RareBytesBuilder { + RareBytesBuilder { + ascii_case_insensitive: false, + byte_offsets: RareByteOffsets::empty(), + available: true, + count: 0, + rank_sum: 0, + } + } + + /// Enable ASCII case insensitivity. When set, byte strings added to this + /// builder will be interpreted without respect to ASCII case. + fn ascii_case_insensitive(mut self, yes: bool) -> RareBytesBuilder { + self.ascii_case_insensitive = yes; + self + } + + /// Build the rare bytes prefilter. + /// + /// If there are more than 3 distinct starting bytes, or if heuristics + /// otherwise determine that this prefilter should not be used, then `None` + /// is returned. + fn build(&self) -> Option { + if !self.available || self.count > 3 { + return None; + } + let (mut bytes, mut len) = ([0; 3], 0); + for b in 0..256 { + if self.byte_offsets.set[b].is_active() { + bytes[len] = b as u8; + len += 1; + } + } + match len { + 0 => None, + 1 => Some(PrefilterObj::new(RareBytesOne { + byte1: bytes[0], + offset: self.byte_offsets.set[bytes[0] as usize], + })), + 2 => Some(PrefilterObj::new(RareBytesTwo { + offsets: self.byte_offsets, + byte1: bytes[0], + byte2: bytes[1], + })), + 3 => Some(PrefilterObj::new(RareBytesThree { + offsets: self.byte_offsets, + byte1: bytes[0], + byte2: bytes[1], + byte3: bytes[2], + })), + _ => unreachable!(), + } + } + + /// Add a byte string to this builder. + /// + /// All patterns added to an Aho-Corasick automaton should be added to this + /// builder before attempting to construct the prefilter. + fn add(&mut self, bytes: &[u8]) { + // If we've already blown our budget, then don't waste time looking + // for more rare bytes. + if self.count > 3 { + self.available = false; + return; + } + let mut rarest = match bytes.get(0) { + None => return, + Some(&b) => (b, 0, freq_rank(b)), + }; + // The idea here is to look for the rarest byte in each pattern, and + // add that to our set. As a special exception, if we see a byte that + // we've already added, then we immediately stop and choose that byte, + // even if there's another rare byte in the pattern. This helps us + // apply the rare byte optimization in more cases by attempting to pick + // bytes that are in common between patterns. So for example, if we + // were searching for `Sherlock` and `lockjaw`, then this would pick + // `k` for both patterns, resulting in the use of `memchr` instead of + // `memchr2` for `k` and `j`. + for (pos, &b) in bytes.iter().enumerate() { + if self.byte_offsets.set[b as usize].is_active() { + self.add_rare_byte(b, pos); + return; + } + let rank = freq_rank(b); + if rank < rarest.2 { + rarest = (b, pos, rank); + } + } + self.add_rare_byte(rarest.0, rarest.1); + } + + fn add_rare_byte(&mut self, byte: u8, pos: usize) { + self.add_one_byte(byte, pos); + if self.ascii_case_insensitive { + self.add_one_byte(opposite_ascii_case(byte), pos); + } + } + + fn add_one_byte(&mut self, byte: u8, pos: usize) { + let off = RareByteOffset::new(pos); + if !off.is_active() { + self.available = false; + return; + } + if self.byte_offsets.apply(byte, off) { + self.count += 1; + self.rank_sum += freq_rank(byte) as u16; + } + } +} + +/// A prefilter for scanning for a single "rare" byte. +#[derive(Clone, Debug)] +struct RareBytesOne { + byte1: u8, + offset: RareByteOffset, +} + +impl Prefilter for RareBytesOne { + fn next_candidate( + &self, + state: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Candidate { + memchr(self.byte1, &haystack[at..]) + .map(|i| { + let pos = at + i; + state.last_scan_at = pos; + cmp::max(at, pos.saturating_sub(self.offset.max as usize)) + }) + .map_or(Candidate::None, Candidate::PossibleStartOfMatch) + } + + fn clone_prefilter(&self) -> Box { + Box::new(self.clone()) + } + + fn heap_bytes(&self) -> usize { + 0 + } +} + +/// A prefilter for scanning for two "rare" bytes. +#[derive(Clone, Debug)] +struct RareBytesTwo { + offsets: RareByteOffsets, + byte1: u8, + byte2: u8, +} + +impl Prefilter for RareBytesTwo { + fn next_candidate( + &self, + state: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Candidate { + memchr2(self.byte1, self.byte2, &haystack[at..]) + .map(|i| { + let pos = at + i; + state.update_at(pos); + let offset = self.offsets.set[haystack[pos] as usize].max; + cmp::max(at, pos.saturating_sub(offset as usize)) + }) + .map_or(Candidate::None, Candidate::PossibleStartOfMatch) + } + + fn clone_prefilter(&self) -> Box { + Box::new(self.clone()) + } + + fn heap_bytes(&self) -> usize { + 0 + } +} + +/// A prefilter for scanning for three "rare" bytes. +#[derive(Clone, Debug)] +struct RareBytesThree { + offsets: RareByteOffsets, + byte1: u8, + byte2: u8, + byte3: u8, +} + +impl Prefilter for RareBytesThree { + fn next_candidate( + &self, + state: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Candidate { + memchr3(self.byte1, self.byte2, self.byte3, &haystack[at..]) + .map(|i| { + let pos = at + i; + state.update_at(pos); + let offset = self.offsets.set[haystack[pos] as usize].max; + cmp::max(at, pos.saturating_sub(offset as usize)) + }) + .map_or(Candidate::None, Candidate::PossibleStartOfMatch) + } + + fn clone_prefilter(&self) -> Box { + Box::new(self.clone()) + } + + fn heap_bytes(&self) -> usize { + 0 + } +} + +/// A builder for constructing a starting byte prefilter. +/// +/// A starting byte prefilter is a simplistic prefilter that looks for possible +/// matches by reporting all positions corresponding to a particular byte. This +/// generally only takes affect when there are at most 3 distinct possible +/// starting bytes. e.g., the patterns `foo`, `bar`, and `baz` have two +/// distinct starting bytes (`f` and `b`), and this prefiler returns all +/// occurrences of either `f` or `b`. +/// +/// In some cases, a heuristic frequency analysis may determine that it would +/// be better not to use this prefilter even when there are 3 or fewer distinct +/// starting bytes. +#[derive(Clone, Debug)] +struct StartBytesBuilder { + /// Whether this prefilter should account for ASCII case insensitivity or + /// not. + ascii_case_insensitive: bool, + /// The set of starting bytes observed. + byteset: Vec, + /// The number of bytes set to true in `byteset`. + count: usize, + /// The sum of frequency ranks for the rare bytes detected. This is + /// intended to give a heuristic notion of how rare the bytes are. + rank_sum: u16, +} + +impl StartBytesBuilder { + /// Create a new builder for constructing a start byte prefilter. + fn new() -> StartBytesBuilder { + StartBytesBuilder { + ascii_case_insensitive: false, + byteset: vec![false; 256], + count: 0, + rank_sum: 0, + } + } + + /// Enable ASCII case insensitivity. When set, byte strings added to this + /// builder will be interpreted without respect to ASCII case. + fn ascii_case_insensitive(mut self, yes: bool) -> StartBytesBuilder { + self.ascii_case_insensitive = yes; + self + } + + /// Build the starting bytes prefilter. + /// + /// If there are more than 3 distinct starting bytes, or if heuristics + /// otherwise determine that this prefilter should not be used, then `None` + /// is returned. + fn build(&self) -> Option { + if self.count > 3 { + return None; + } + let (mut bytes, mut len) = ([0; 3], 0); + for b in 0..256 { + if !self.byteset[b] { + continue; + } + // We don't handle non-ASCII bytes for now. Getting non-ASCII + // bytes right is trickier, since we generally don't want to put + // a leading UTF-8 code unit into a prefilter that isn't ASCII, + // since they can frequently. Instead, it would be better to use a + // continuation byte, but this requires more sophisticated analysis + // of the automaton and a richer prefilter API. + if b > 0x7F { + return None; + } + bytes[len] = b as u8; + len += 1; + } + match len { + 0 => None, + 1 => Some(PrefilterObj::new(StartBytesOne { byte1: bytes[0] })), + 2 => Some(PrefilterObj::new(StartBytesTwo { + byte1: bytes[0], + byte2: bytes[1], + })), + 3 => Some(PrefilterObj::new(StartBytesThree { + byte1: bytes[0], + byte2: bytes[1], + byte3: bytes[2], + })), + _ => unreachable!(), + } + } + + /// Add a byte string to this builder. + /// + /// All patterns added to an Aho-Corasick automaton should be added to this + /// builder before attempting to construct the prefilter. + fn add(&mut self, bytes: &[u8]) { + if self.count > 3 { + return; + } + if let Some(&byte) = bytes.get(0) { + self.add_one_byte(byte); + if self.ascii_case_insensitive { + self.add_one_byte(opposite_ascii_case(byte)); + } + } + } + + fn add_one_byte(&mut self, byte: u8) { + if !self.byteset[byte as usize] { + self.byteset[byte as usize] = true; + self.count += 1; + self.rank_sum += freq_rank(byte) as u16; + } + } +} + +/// A prefilter for scanning for a single starting byte. +#[derive(Clone, Debug)] +struct StartBytesOne { + byte1: u8, +} + +impl Prefilter for StartBytesOne { + fn next_candidate( + &self, + _state: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Candidate { + memchr(self.byte1, &haystack[at..]) + .map(|i| at + i) + .map_or(Candidate::None, Candidate::PossibleStartOfMatch) + } + + fn clone_prefilter(&self) -> Box { + Box::new(self.clone()) + } + + fn heap_bytes(&self) -> usize { + 0 + } +} + +/// A prefilter for scanning for two starting bytes. +#[derive(Clone, Debug)] +struct StartBytesTwo { + byte1: u8, + byte2: u8, +} + +impl Prefilter for StartBytesTwo { + fn next_candidate( + &self, + _state: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Candidate { + memchr2(self.byte1, self.byte2, &haystack[at..]) + .map(|i| at + i) + .map_or(Candidate::None, Candidate::PossibleStartOfMatch) + } + + fn clone_prefilter(&self) -> Box { + Box::new(self.clone()) + } + + fn heap_bytes(&self) -> usize { + 0 + } +} + +/// A prefilter for scanning for three starting bytes. +#[derive(Clone, Debug)] +struct StartBytesThree { + byte1: u8, + byte2: u8, + byte3: u8, +} + +impl Prefilter for StartBytesThree { + fn next_candidate( + &self, + _state: &mut PrefilterState, + haystack: &[u8], + at: usize, + ) -> Candidate { + memchr3(self.byte1, self.byte2, self.byte3, &haystack[at..]) + .map(|i| at + i) + .map_or(Candidate::None, Candidate::PossibleStartOfMatch) + } + + fn clone_prefilter(&self) -> Box { + Box::new(self.clone()) + } + + fn heap_bytes(&self) -> usize { + 0 + } +} + +/// Return the next candidate reported by the given prefilter while +/// simultaneously updating the given prestate. +/// +/// The caller is responsible for checking the prestate before deciding whether +/// to initiate a search. +#[inline] +pub fn next( + prestate: &mut PrefilterState, + prefilter: P, + haystack: &[u8], + at: usize, +) -> Candidate { + let cand = prefilter.next_candidate(prestate, haystack, at); + match cand { + Candidate::None => { + prestate.update_skipped_bytes(haystack.len() - at); + } + Candidate::Match(ref m) => { + prestate.update_skipped_bytes(m.start() - at); + } + Candidate::PossibleStartOfMatch(i) => { + prestate.update_skipped_bytes(i - at); + } + } + cand +} + +/// If the given byte is an ASCII letter, then return it in the opposite case. +/// e.g., Given `b'A'`, this returns `b'a'`, and given `b'a'`, this returns +/// `b'A'`. If a non-ASCII letter is given, then the given byte is returned. +pub fn opposite_ascii_case(b: u8) -> u8 { + if b'A' <= b && b <= b'Z' { + b.to_ascii_lowercase() + } else if b'a' <= b && b <= b'z' { + b.to_ascii_uppercase() + } else { + b + } +} + +/// Return the frequency rank of the given byte. The higher the rank, the more +/// common the byte (heuristically speaking). +fn freq_rank(b: u8) -> u8 { + use byte_frequencies::BYTE_FREQUENCIES; + BYTE_FREQUENCIES[b as usize] +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn scratch() { + let mut b = Builder::new(MatchKind::LeftmostFirst); + b.add(b"Sherlock"); + b.add(b"locjaw"); + // b.add(b"Sherlock"); + // b.add(b"Holmes"); + // b.add(b"Watson"); + // b.add("Шерлок Холмс".as_bytes()); + // b.add("Джон Уотсон".as_bytes()); + + let s = b.build().unwrap(); + println!("{:?}", s); + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/state_id.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/state_id.rs new file mode 100644 index 0000000..8ee58c6 --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/state_id.rs @@ -0,0 +1,203 @@ +use std::fmt::Debug; +use std::hash::Hash; + +use error::{Error, Result}; + +// NOTE: Most of this code was copied from regex-automata, but without the +// (de)serialization specific stuff. + +/// Check that the premultiplication of the given state identifier can +/// fit into the representation indicated by `S`. If it cannot, or if it +/// overflows `usize` itself, then an error is returned. +pub fn premultiply_overflow_error( + last_state: S, + alphabet_len: usize, +) -> Result<()> { + let requested = match last_state.to_usize().checked_mul(alphabet_len) { + Some(requested) => requested, + None => return Err(Error::premultiply_overflow(0, 0)), + }; + if requested > S::max_id() { + return Err(Error::premultiply_overflow(S::max_id(), requested)); + } + Ok(()) +} + +/// Convert the given `usize` to the chosen state identifier +/// representation. If the given value cannot fit in the chosen +/// representation, then an error is returned. +pub fn usize_to_state_id(value: usize) -> Result { + if value > S::max_id() { + Err(Error::state_id_overflow(S::max_id())) + } else { + Ok(S::from_usize(value)) + } +} + +/// Return the unique identifier for an automaton's fail state in the chosen +/// representation indicated by `S`. +pub fn fail_id() -> S { + S::from_usize(0) +} + +/// Return the unique identifier for an automaton's fail state in the chosen +/// representation indicated by `S`. +pub fn dead_id() -> S { + S::from_usize(1) +} + +mod private { + /// Sealed stops crates other than aho-corasick from implementing any + /// traits that use it. + pub trait Sealed {} + impl Sealed for u8 {} + impl Sealed for u16 {} + impl Sealed for u32 {} + impl Sealed for u64 {} + impl Sealed for usize {} +} + +/// A trait describing the representation of an automaton's state identifier. +/// +/// The purpose of this trait is to safely express both the possible state +/// identifier representations that can be used in an automaton and to convert +/// between state identifier representations and types that can be used to +/// efficiently index memory (such as `usize`). +/// +/// In general, one should not need to implement this trait explicitly. Indeed, +/// for now, this trait is sealed such that it cannot be implemented by any +/// other type. In particular, this crate provides implementations for `u8`, +/// `u16`, `u32`, `u64` and `usize`. (`u32` and `u64` are only provided for +/// targets that can represent all corresponding values in a `usize`.) +/// +/// # Safety +/// +/// This trait is unsafe because the correctness of its implementations may be +/// relied upon by other unsafe code. For example, one possible way to +/// implement this trait incorrectly would be to return a maximum identifier +/// in `max_id` that is greater than the real maximum identifier. This will +/// likely result in wrap-on-overflow semantics in release mode, which can in +/// turn produce incorrect state identifiers. Those state identifiers may then +/// in turn access out-of-bounds memory in an automaton's search routine, where +/// bounds checks are explicitly elided for performance reasons. +pub unsafe trait StateID: + private::Sealed + + Clone + + Copy + + Debug + + Eq + + Hash + + PartialEq + + PartialOrd + + Ord +{ + /// Convert from a `usize` to this implementation's representation. + /// + /// Implementors may assume that `n <= Self::max_id`. That is, implementors + /// do not need to check whether `n` can fit inside this implementation's + /// representation. + fn from_usize(n: usize) -> Self; + + /// Convert this implementation's representation to a `usize`. + /// + /// Implementors must not return a `usize` value greater than + /// `Self::max_id` and must not permit overflow when converting between the + /// implementor's representation and `usize`. In general, the preferred + /// way for implementors to achieve this is to simply not provide + /// implementations of `StateID` that cannot fit into the target platform's + /// `usize`. + fn to_usize(self) -> usize; + + /// Return the maximum state identifier supported by this representation. + /// + /// Implementors must return a correct bound. Doing otherwise may result + /// in memory unsafety. + fn max_id() -> usize; +} + +unsafe impl StateID for usize { + #[inline] + fn from_usize(n: usize) -> usize { + n + } + + #[inline] + fn to_usize(self) -> usize { + self + } + + #[inline] + fn max_id() -> usize { + ::std::usize::MAX + } +} + +unsafe impl StateID for u8 { + #[inline] + fn from_usize(n: usize) -> u8 { + n as u8 + } + + #[inline] + fn to_usize(self) -> usize { + self as usize + } + + #[inline] + fn max_id() -> usize { + ::std::u8::MAX as usize + } +} + +unsafe impl StateID for u16 { + #[inline] + fn from_usize(n: usize) -> u16 { + n as u16 + } + + #[inline] + fn to_usize(self) -> usize { + self as usize + } + + #[inline] + fn max_id() -> usize { + ::std::u16::MAX as usize + } +} + +#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] +unsafe impl StateID for u32 { + #[inline] + fn from_usize(n: usize) -> u32 { + n as u32 + } + + #[inline] + fn to_usize(self) -> usize { + self as usize + } + + #[inline] + fn max_id() -> usize { + ::std::u32::MAX as usize + } +} + +#[cfg(target_pointer_width = "64")] +unsafe impl StateID for u64 { + #[inline] + fn from_usize(n: usize) -> u64 { + n as u64 + } + + #[inline] + fn to_usize(self) -> usize { + self as usize + } + + #[inline] + fn max_id() -> usize { + ::std::u64::MAX as usize + } +} diff --git a/third_party/cargo/vendor/aho-corasick-0.7.6/src/tests.rs b/third_party/cargo/vendor/aho-corasick-0.7.6/src/tests.rs new file mode 100644 index 0000000..a181bac --- /dev/null +++ b/third_party/cargo/vendor/aho-corasick-0.7.6/src/tests.rs @@ -0,0 +1,1022 @@ +use std::collections::HashMap; +use std::io; +use std::usize; + +use {AhoCorasickBuilder, Match, MatchKind}; + +/// A description of a single test against an Aho-Corasick automaton. +/// +/// A single test may not necessarily pass on every configuration of an +/// Aho-Corasick automaton. The tests are categorized and grouped appropriately +/// below. +#[derive(Clone, Debug, Eq, PartialEq)] +struct SearchTest { + /// The name of this test, for debugging. + name: &'static str, + /// The patterns to search for. + patterns: &'static [&'static str], + /// The text to search. + haystack: &'static str, + /// Each match is a triple of (pattern_index, start, end), where + /// pattern_index is an index into `patterns` and `start`/`end` are indices + /// into `haystack`. + matches: &'static [(usize, usize, usize)], +} + +/// Short-hand constructor for SearchTest. We use it a lot below. +macro_rules! t { + ($name:ident, $patterns:expr, $haystack:expr, $matches:expr) => { + SearchTest { + name: stringify!($name), + patterns: $patterns, + haystack: $haystack, + matches: $matches, + } + }; +} + +/// A collection of test groups. +type TestCollection = &'static [&'static [SearchTest]]; + +// Define several collections corresponding to the different type of match +// semantics supported by Aho-Corasick. These collections have some overlap, +// but each collection should have some tests that no other collection has. + +/// Tests for Aho-Corasick's standard non-overlapping match semantics. +const AC_STANDARD_NON_OVERLAPPING: TestCollection = + &[BASICS, NON_OVERLAPPING, STANDARD, REGRESSION]; + +/// Tests for Aho-Corasick's anchored standard non-overlapping match semantics. +const AC_STANDARD_ANCHORED_NON_OVERLAPPING: TestCollection = + &[ANCHORED_BASICS, ANCHORED_NON_OVERLAPPING, STANDARD_ANCHORED]; + +/// Tests for Aho-Corasick's standard overlapping match semantics. +const AC_STANDARD_OVERLAPPING: TestCollection = + &[BASICS, OVERLAPPING, REGRESSION]; + +/// Tests for Aho-Corasick's anchored standard overlapping match semantics. +const AC_STANDARD_ANCHORED_OVERLAPPING: TestCollection = + &[ANCHORED_BASICS, ANCHORED_OVERLAPPING]; + +/// Tests for Aho-Corasick's leftmost-first match semantics. +const AC_LEFTMOST_FIRST: TestCollection = + &[BASICS, NON_OVERLAPPING, LEFTMOST, LEFTMOST_FIRST, REGRESSION]; + +/// Tests for Aho-Corasick's anchored leftmost-first match semantics. +const AC_LEFTMOST_FIRST_ANCHORED: TestCollection = &[ + ANCHORED_BASICS, + ANCHORED_NON_OVERLAPPING, + ANCHORED_LEFTMOST, + ANCHORED_LEFTMOST_FIRST, +]; + +/// Tests for Aho-Corasick's leftmost-longest match semantics. +const AC_LEFTMOST_LONGEST: TestCollection = + &[BASICS, NON_OVERLAPPING, LEFTMOST, LEFTMOST_LONGEST, REGRESSION]; + +/// Tests for Aho-Corasick's anchored leftmost-longest match semantics. +const AC_LEFTMOST_LONGEST_ANCHORED: TestCollection = &[ + ANCHORED_BASICS, + ANCHORED_NON_OVERLAPPING, + ANCHORED_LEFTMOST, + ANCHORED_LEFTMOST_LONGEST, +]; + +// Now define the individual tests that make up the collections above. + +/// A collection of tests for the Aho-Corasick algorithm that should always be +/// true regardless of match semantics. That is, all combinations of +/// leftmost-{shortest, first, longest} x {overlapping, non-overlapping} +/// should produce the same answer. +const BASICS: &'static [SearchTest] = &[ + t!(basic000, &[], "", &[]), + t!(basic001, &["a"], "", &[]), + t!(basic010, &["a"], "a", &[(0, 0, 1)]), + t!(basic020, &["a"], "aa", &[(0, 0, 1), (0, 1, 2)]), + t!(basic030, &["a"], "aaa", &[(0, 0, 1), (0, 1, 2), (0, 2, 3)]), + t!(basic040, &["a"], "aba", &[(0, 0, 1), (0, 2, 3)]), + t!(basic050, &["a"], "bba", &[(0, 2, 3)]), + t!(basic060, &["a"], "bbb", &[]), + t!(basic070, &["a"], "bababbbba", &[(0, 1, 2), (0, 3, 4), (0, 8, 9)]), + t!(basic100, &["aa"], "", &[]), + t!(basic110, &["aa"], "aa", &[(0, 0, 2)]), + t!(basic120, &["aa"], "aabbaa", &[(0, 0, 2), (0, 4, 6)]), + t!(basic130, &["aa"], "abbab", &[]), + t!(basic140, &["aa"], "abbabaa", &[(0, 5, 7)]), + t!(basic200, &["abc"], "abc", &[(0, 0, 3)]), + t!(basic210, &["abc"], "zazabzabcz", &[(0, 6, 9)]), + t!(basic220, &["abc"], "zazabczabcz", &[(0, 3, 6), (0, 7, 10)]), + t!(basic300, &["a", "b"], "", &[]), + t!(basic310, &["a", "b"], "z", &[]), + t!(basic320, &["a", "b"], "b", &[(1, 0, 1)]), + t!(basic330, &["a", "b"], "a", &[(0, 0, 1)]), + t!( + basic340, + &["a", "b"], + "abba", + &[(0, 0, 1), (1, 1, 2), (1, 2, 3), (0, 3, 4),] + ), + t!( + basic350, + &["b", "a"], + "abba", + &[(1, 0, 1), (0, 1, 2), (0, 2, 3), (1, 3, 4),] + ), + t!(basic360, &["abc", "bc"], "xbc", &[(1, 1, 3),]), + t!(basic400, &["foo", "bar"], "", &[]), + t!(basic410, &["foo", "bar"], "foobar", &[(0, 0, 3), (1, 3, 6),]), + t!(basic420, &["foo", "bar"], "barfoo", &[(1, 0, 3), (0, 3, 6),]), + t!(basic430, &["foo", "bar"], "foofoo", &[(0, 0, 3), (0, 3, 6),]), + t!(basic440, &["foo", "bar"], "barbar", &[(1, 0, 3), (1, 3, 6),]), + t!(basic450, &["foo", "bar"], "bafofoo", &[(0, 4, 7),]), + t!(basic460, &["bar", "foo"], "bafofoo", &[(1, 4, 7),]), + t!(basic470, &["foo", "bar"], "fobabar", &[(1, 4, 7),]), + t!(basic480, &["bar", "foo"], "fobabar", &[(0, 4, 7),]), + t!(basic600, &[""], "", &[(0, 0, 0)]), + t!(basic610, &[""], "a", &[(0, 0, 0), (0, 1, 1)]), + t!(basic620, &[""], "abc", &[(0, 0, 0), (0, 1, 1), (0, 2, 2), (0, 3, 3)]), + t!(basic700, &["yabcdef", "abcdezghi"], "yabcdefghi", &[(0, 0, 7),]), + t!(basic710, &["yabcdef", "abcdezghi"], "yabcdezghi", &[(1, 1, 10),]), + t!( + basic720, + &["yabcdef", "bcdeyabc", "abcdezghi"], + "yabcdezghi", + &[(2, 1, 10),] + ), +]; + +/// A collection of *anchored* tests for the Aho-Corasick algorithm that should +/// always be true regardless of match semantics. That is, all combinations of +/// leftmost-{shortest, first, longest} x {overlapping, non-overlapping} should +/// produce the same answer. +const ANCHORED_BASICS: &'static [SearchTest] = &[ + t!(abasic000, &[], "", &[]), + t!(abasic010, &[""], "", &[(0, 0, 0)]), + t!(abasic020, &[""], "a", &[(0, 0, 0)]), + t!(abasic030, &[""], "abc", &[(0, 0, 0)]), + t!(abasic100, &["a"], "a", &[(0, 0, 1)]), + t!(abasic110, &["a"], "aa", &[(0, 0, 1)]), + t!(abasic120, &["a", "b"], "ab", &[(0, 0, 1)]), + t!(abasic130, &["a", "b"], "ba", &[(1, 0, 1)]), + t!(abasic140, &["foo", "foofoo"], "foo", &[(0, 0, 3)]), + t!(abasic150, &["foofoo", "foo"], "foo", &[(1, 0, 3)]), +]; + +/// Tests for non-overlapping standard match semantics. +/// +/// These tests generally shouldn't pass for leftmost-{first,longest}, although +/// some do in order to write clearer tests. For example, standard000 will +/// pass with leftmost-first semantics, but standard010 will not. We write +/// both to emphasize how the match semantics work. +const STANDARD: &'static [SearchTest] = &[ + t!(standard000, &["ab", "abcd"], "abcd", &[(0, 0, 2)]), + t!(standard010, &["abcd", "ab"], "abcd", &[(1, 0, 2)]), + t!(standard020, &["abcd", "ab", "abc"], "abcd", &[(1, 0, 2)]), + t!(standard030, &["abcd", "abc", "ab"], "abcd", &[(2, 0, 2)]), + t!(standard040, &["a", ""], "a", &[(1, 0, 0), (1, 1, 1)]), + t!( + standard400, + &["abcd", "bcd", "cd", "b"], + "abcd", + &[(3, 1, 2), (2, 2, 4),] + ), + t!(standard410, &["", "a"], "a", &[(0, 0, 0), (0, 1, 1),]), + t!(standard420, &["", "a"], "aa", &[(0, 0, 0), (0, 1, 1), (0, 2, 2),]), + t!(standard430, &["", "a", ""], "a", &[(0, 0, 0), (0, 1, 1),]), + t!(standard440, &["a", "", ""], "a", &[(1, 0, 0), (1, 1, 1),]), + t!(standard450, &["", "", "a"], "a", &[(0, 0, 0), (0, 1, 1),]), +]; + +/// Like STANDARD, but for anchored searches. +const STANDARD_ANCHORED: &'static [SearchTest] = &[ + t!(astandard000, &["ab", "abcd"], "abcd", &[(0, 0, 2)]), + t!(astandard010, &["abcd", "ab"], "abcd", &[(1, 0, 2)]), + t!(astandard020, &["abcd", "ab", "abc"], "abcd", &[(1, 0, 2)]), + t!(astandard030, &["abcd", "abc", "ab"], "abcd", &[(2, 0, 2)]), + t!(astandard040, &["a", ""], "a", &[(1, 0, 0)]), + t!(astandard050, &["abcd", "bcd", "cd", "b"], "abcd", &[(0, 0, 4)]), + t!(astandard410, &["", "a"], "a", &[(0, 0, 0)]), + t!(astandard420, &["", "a"], "aa", &[(0, 0, 0)]), + t!(astandard430, &["", "a", ""], "a", &[(0, 0, 0)]), + t!(astandard440, &["a", "", ""], "a", &[(1, 0, 0)]), + t!(astandard450, &["", "", "a"], "a", &[(0, 0, 0)]), +]; + +/// Tests for non-overlapping leftmost match semantics. These should pass for +/// both leftmost-first and leftmost-longest match kinds. Stated differently, +/// among ambiguous matches, the longest match and the match that appeared +/// first when constructing the automaton should always be the same. +const LEFTMOST: &'static [SearchTest] = &[ + t!(leftmost000, &["ab", "ab"], "abcd", &[(0, 0, 2)]), + t!(leftmost010, &["a", ""], "a", &[(0, 0, 1), (1, 1, 1)]), + t!(leftmost020, &["", ""], "a", &[(0, 0, 0), (0, 1, 1)]), + t!(leftmost030, &["a", "ab"], "aa", &[(0, 0, 1), (0, 1, 2)]), + t!(leftmost031, &["ab", "a"], "aa", &[(1, 0, 1), (1, 1, 2)]), + t!(leftmost032, &["ab", "a"], "xayabbbz", &[(1, 1, 2), (0, 3, 5)]), + t!(leftmost300, &["abcd", "bce", "b"], "abce", &[(1, 1, 4)]), + t!(leftmost310, &["abcd", "ce", "bc"], "abce", &[(2, 1, 3)]), + t!(leftmost320, &["abcd", "bce", "ce", "b"], "abce", &[(1, 1, 4)]), + t!(leftmost330, &["abcd", "bce", "cz", "bc"], "abcz", &[(3, 1, 3)]), + t!(leftmost340, &["bce", "cz", "bc"], "bcz", &[(2, 0, 2)]), + t!(leftmost350, &["abc", "bd", "ab"], "abd", &[(2, 0, 2)]), + t!( + leftmost360, + &["abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(2, 0, 8),] + ), + t!( + leftmost370, + &["abcdefghi", "cde", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!( + leftmost380, + &["abcdefghi", "hz", "abcdefgh", "a"], + "abcdefghz", + &[(2, 0, 8),] + ), + t!( + leftmost390, + &["b", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!( + leftmost400, + &["h", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!( + leftmost410, + &["z", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8), (0, 8, 9),] + ), +]; + +/// Like LEFTMOST, but for anchored searches. +const ANCHORED_LEFTMOST: &'static [SearchTest] = &[ + t!(aleftmost000, &["ab", "ab"], "abcd", &[(0, 0, 2)]), + t!(aleftmost010, &["a", ""], "a", &[(0, 0, 1)]), + t!(aleftmost020, &["", ""], "a", &[(0, 0, 0)]), + t!(aleftmost030, &["a", "ab"], "aa", &[(0, 0, 1)]), + t!(aleftmost031, &["ab", "a"], "aa", &[(1, 0, 1)]), + t!(aleftmost032, &["ab", "a"], "xayabbbz", &[]), + t!(aleftmost300, &["abcd", "bce", "b"], "abce", &[]), + t!(aleftmost310, &["abcd", "ce", "bc"], "abce", &[]), + t!(aleftmost320, &["abcd", "bce", "ce", "b"], "abce", &[]), + t!(aleftmost330, &["abcd", "bce", "cz", "bc"], "abcz", &[]), + t!(aleftmost340, &["bce", "cz", "bc"], "bcz", &[(2, 0, 2)]), + t!(aleftmost350, &["abc", "bd", "ab"], "abd", &[(2, 0, 2)]), + t!( + aleftmost360, + &["abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(2, 0, 8),] + ), + t!( + aleftmost370, + &["abcdefghi", "cde", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!( + aleftmost380, + &["abcdefghi", "hz", "abcdefgh", "a"], + "abcdefghz", + &[(2, 0, 8),] + ), + t!( + aleftmost390, + &["b", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!( + aleftmost400, + &["h", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!( + aleftmost410, + &["z", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8)] + ), +]; + +/// Tests for non-overlapping leftmost-first match semantics. These tests +/// should generally be specific to leftmost-first, which means they should +/// generally fail under leftmost-longest semantics. +const LEFTMOST_FIRST: &'static [SearchTest] = &[ + t!(leftfirst000, &["ab", "abcd"], "abcd", &[(0, 0, 2)]), + t!(leftfirst010, &["", "a"], "a", &[(0, 0, 0), (0, 1, 1)]), + t!(leftfirst011, &["", "a", ""], "a", &[(0, 0, 0), (0, 1, 1),]), + t!(leftfirst012, &["a", "", ""], "a", &[(0, 0, 1), (1, 1, 1),]), + t!(leftfirst013, &["", "", "a"], "a", &[(0, 0, 0), (0, 1, 1),]), + t!(leftfirst020, &["abcd", "ab"], "abcd", &[(0, 0, 4)]), + t!(leftfirst030, &["ab", "ab"], "abcd", &[(0, 0, 2)]), + t!(leftfirst040, &["a", "ab"], "xayabbbz", &[(0, 1, 2), (0, 3, 4)]), + t!(leftfirst100, &["abcdefg", "bcde", "bcdef"], "abcdef", &[(1, 1, 5)]), + t!(leftfirst110, &["abcdefg", "bcdef", "bcde"], "abcdef", &[(1, 1, 6)]), + t!(leftfirst300, &["abcd", "b", "bce"], "abce", &[(1, 1, 2)]), + t!( + leftfirst310, + &["abcd", "b", "bce", "ce"], + "abce", + &[(1, 1, 2), (3, 2, 4),] + ), + t!( + leftfirst320, + &["a", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(0, 0, 1), (2, 7, 9),] + ), + t!(leftfirst330, &["a", "abab"], "abab", &[(0, 0, 1), (0, 2, 3)]), +]; + +/// Like LEFTMOST_FIRST, but for anchored searches. +const ANCHORED_LEFTMOST_FIRST: &'static [SearchTest] = &[ + t!(aleftfirst000, &["ab", "abcd"], "abcd", &[(0, 0, 2)]), + t!(aleftfirst010, &["", "a"], "a", &[(0, 0, 0)]), + t!(aleftfirst011, &["", "a", ""], "a", &[(0, 0, 0)]), + t!(aleftfirst012, &["a", "", ""], "a", &[(0, 0, 1)]), + t!(aleftfirst013, &["", "", "a"], "a", &[(0, 0, 0)]), + t!(aleftfirst020, &["abcd", "ab"], "abcd", &[(0, 0, 4)]), + t!(aleftfirst030, &["ab", "ab"], "abcd", &[(0, 0, 2)]), + t!(aleftfirst040, &["a", "ab"], "xayabbbz", &[]), + t!(aleftfirst100, &["abcdefg", "bcde", "bcdef"], "abcdef", &[]), + t!(aleftfirst110, &["abcdefg", "bcdef", "bcde"], "abcdef", &[]), + t!(aleftfirst300, &["abcd", "b", "bce"], "abce", &[]), + t!(aleftfirst310, &["abcd", "b", "bce", "ce"], "abce", &[]), + t!( + aleftfirst320, + &["a", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(0, 0, 1)] + ), + t!(aleftfirst330, &["a", "abab"], "abab", &[(0, 0, 1)]), +]; + +/// Tests for non-overlapping leftmost-longest match semantics. These tests +/// should generally be specific to leftmost-longest, which means they should +/// generally fail under leftmost-first semantics. +const LEFTMOST_LONGEST: &'static [SearchTest] = &[ + t!(leftlong000, &["ab", "abcd"], "abcd", &[(1, 0, 4)]), + t!(leftlong010, &["abcd", "bcd", "cd", "b"], "abcd", &[(0, 0, 4),]), + t!(leftlong020, &["", "a"], "a", &[(1, 0, 1), (0, 1, 1),]), + t!(leftlong021, &["", "a", ""], "a", &[(1, 0, 1), (0, 1, 1),]), + t!(leftlong022, &["a", "", ""], "a", &[(0, 0, 1), (1, 1, 1),]), + t!(leftlong023, &["", "", "a"], "a", &[(2, 0, 1), (0, 1, 1),]), + t!(leftlong030, &["", "a"], "aa", &[(1, 0, 1), (1, 1, 2), (0, 2, 2),]), + t!(leftlong040, &["a", "ab"], "a", &[(0, 0, 1)]), + t!(leftlong050, &["a", "ab"], "ab", &[(1, 0, 2)]), + t!(leftlong060, &["ab", "a"], "a", &[(1, 0, 1)]), + t!(leftlong070, &["ab", "a"], "ab", &[(0, 0, 2)]), + t!(leftlong100, &["abcdefg", "bcde", "bcdef"], "abcdef", &[(2, 1, 6)]), + t!(leftlong110, &["abcdefg", "bcdef", "bcde"], "abcdef", &[(1, 1, 6)]), + t!(leftlong300, &["abcd", "b", "bce"], "abce", &[(2, 1, 4)]), + t!( + leftlong310, + &["a", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!(leftlong320, &["a", "abab"], "abab", &[(1, 0, 4)]), + t!(leftlong330, &["abcd", "b", "ce"], "abce", &[(1, 1, 2), (2, 2, 4),]), + t!(leftlong340, &["a", "ab"], "xayabbbz", &[(0, 1, 2), (1, 3, 5)]), +]; + +/// Like LEFTMOST_LONGEST, but for anchored searches. +const ANCHORED_LEFTMOST_LONGEST: &'static [SearchTest] = &[ + t!(aleftlong000, &["ab", "abcd"], "abcd", &[(1, 0, 4)]), + t!(aleftlong010, &["abcd", "bcd", "cd", "b"], "abcd", &[(0, 0, 4),]), + t!(aleftlong020, &["", "a"], "a", &[(1, 0, 1)]), + t!(aleftlong021, &["", "a", ""], "a", &[(1, 0, 1)]), + t!(aleftlong022, &["a", "", ""], "a", &[(0, 0, 1)]), + t!(aleftlong023, &["", "", "a"], "a", &[(2, 0, 1)]), + t!(aleftlong030, &["", "a"], "aa", &[(1, 0, 1)]), + t!(aleftlong040, &["a", "ab"], "a", &[(0, 0, 1)]), + t!(aleftlong050, &["a", "ab"], "ab", &[(1, 0, 2)]), + t!(aleftlong060, &["ab", "a"], "a", &[(1, 0, 1)]), + t!(aleftlong070, &["ab", "a"], "ab", &[(0, 0, 2)]), + t!(aleftlong100, &["abcdefg", "bcde", "bcdef"], "abcdef", &[]), + t!(aleftlong110, &["abcdefg", "bcdef", "bcde"], "abcdef", &[]), + t!(aleftlong300, &["abcd", "b", "bce"], "abce", &[]), + t!( + aleftlong310, + &["a", "abcdefghi", "hz", "abcdefgh"], + "abcdefghz", + &[(3, 0, 8),] + ), + t!(aleftlong320, &["a", "abab"], "abab", &[(1, 0, 4)]), + t!(aleftlong330, &["abcd", "b", "ce"], "abce", &[]), + t!(aleftlong340, &["a", "ab"], "xayabbbz", &[]), +]; + +/// Tests for non-overlapping match semantics. +/// +/// Generally these tests shouldn't pass when using overlapping semantics. +/// These should pass for both standard and leftmost match semantics. +const NON_OVERLAPPING: &'static [SearchTest] = &[ + t!(nover010, &["abcd", "bcd", "cd"], "abcd", &[(0, 0, 4),]), + t!(nover020, &["bcd", "cd", "abcd"], "abcd", &[(2, 0, 4),]), + t!(nover030, &["abc", "bc"], "zazabcz", &[(0, 3, 6),]), + t!( + nover100, + &["ab", "ba"], + "abababa", + &[(0, 0, 2), (0, 2, 4), (0, 4, 6),] + ), + t!(nover200, &["foo", "foo"], "foobarfoo", &[(0, 0, 3), (0, 6, 9),]), + t!(nover300, &["", ""], "", &[(0, 0, 0),]), + t!(nover310, &["", ""], "a", &[(0, 0, 0), (0, 1, 1),]), +]; + +/// Like NON_OVERLAPPING, but for anchored searches. +const ANCHORED_NON_OVERLAPPING: &'static [SearchTest] = &[ + t!(anover010, &["abcd", "bcd", "cd"], "abcd", &[(0, 0, 4),]), + t!(anover020, &["bcd", "cd", "abcd"], "abcd", &[(2, 0, 4),]), + t!(anover030, &["abc", "bc"], "zazabcz", &[]), + t!(anover100, &["ab", "ba"], "abababa", &[(0, 0, 2)]), + t!(anover200, &["foo", "foo"], "foobarfoo", &[(0, 0, 3)]), + t!(anover300, &["", ""], "", &[(0, 0, 0),]), + t!(anover310, &["", ""], "a", &[(0, 0, 0)]), +]; + +/// Tests for overlapping match semantics. +/// +/// This only supports standard match semantics, since leftmost-{first,longest} +/// do not support overlapping matches. +const OVERLAPPING: &'static [SearchTest] = &[ + t!( + over000, + &["abcd", "bcd", "cd", "b"], + "abcd", + &[(3, 1, 2), (0, 0, 4), (1, 1, 4), (2, 2, 4),] + ), + t!( + over010, + &["bcd", "cd", "b", "abcd"], + "abcd", + &[(2, 1, 2), (3, 0, 4), (0, 1, 4), (1, 2, 4),] + ), + t!( + over020, + &["abcd", "bcd", "cd"], + "abcd", + &[(0, 0, 4), (1, 1, 4), (2, 2, 4),] + ), + t!( + over030, + &["bcd", "abcd", "cd"], + "abcd", + &[(1, 0, 4), (0, 1, 4), (2, 2, 4),] + ), + t!( + over040, + &["bcd", "cd", "abcd"], + "abcd", + &[(2, 0, 4), (0, 1, 4), (1, 2, 4),] + ), + t!(over050, &["abc", "bc"], "zazabcz", &[(0, 3, 6), (1, 4, 6),]), + t!( + over100, + &["ab", "ba"], + "abababa", + &[(0, 0, 2), (1, 1, 3), (0, 2, 4), (1, 3, 5), (0, 4, 6), (1, 5, 7),] + ), + t!( + over200, + &["foo", "foo"], + "foobarfoo", + &[(0, 0, 3), (1, 0, 3), (0, 6, 9), (1, 6, 9),] + ), + t!(over300, &["", ""], "", &[(0, 0, 0), (1, 0, 0),]), + t!( + over310, + &["", ""], + "a", + &[(0, 0, 0), (1, 0, 0), (0, 1, 1), (1, 1, 1),] + ), + t!(over320, &["", "a"], "a", &[(0, 0, 0), (1, 0, 1), (0, 1, 1),]), + t!( + over330, + &["", "a", ""], + "a", + &[(0, 0, 0), (2, 0, 0), (1, 0, 1), (0, 1, 1), (2, 1, 1),] + ), + t!( + over340, + &["a", "", ""], + "a", + &[(1, 0, 0), (2, 0, 0), (0, 0, 1), (1, 1, 1), (2, 1, 1),] + ), + t!( + over350, + &["", "", "a"], + "a", + &[(0, 0, 0), (1, 0, 0), (2, 0, 1), (0, 1, 1), (1, 1, 1),] + ), + t!( + over360, + &["foo", "foofoo"], + "foofoo", + &[(0, 0, 3), (1, 0, 6), (0, 3, 6)] + ), +]; + +/// Like OVERLAPPING, but for anchored searches. +const ANCHORED_OVERLAPPING: &'static [SearchTest] = &[ + t!(aover000, &["abcd", "bcd", "cd", "b"], "abcd", &[(0, 0, 4)]), + t!(aover010, &["bcd", "cd", "b", "abcd"], "abcd", &[(3, 0, 4)]), + t!(aover020, &["abcd", "bcd", "cd"], "abcd", &[(0, 0, 4)]), + t!(aover030, &["bcd", "abcd", "cd"], "abcd", &[(1, 0, 4)]), + t!(aover040, &["bcd", "cd", "abcd"], "abcd", &[(2, 0, 4)]), + t!(aover050, &["abc", "bc"], "zazabcz", &[]), + t!(aover100, &["ab", "ba"], "abababa", &[(0, 0, 2)]), + t!(aover200, &["foo", "foo"], "foobarfoo", &[(0, 0, 3), (1, 0, 3)]), + t!(aover300, &["", ""], "", &[(0, 0, 0), (1, 0, 0),]), + t!(aover310, &["", ""], "a", &[(0, 0, 0), (1, 0, 0)]), + t!(aover320, &["", "a"], "a", &[(0, 0, 0), (1, 0, 1)]), + t!(aover330, &["", "a", ""], "a", &[(0, 0, 0), (2, 0, 0), (1, 0, 1)]), + t!(aover340, &["a", "", ""], "a", &[(1, 0, 0), (2, 0, 0), (0, 0, 1)]), + t!(aover350, &["", "", "a"], "a", &[(0, 0, 0), (1, 0, 0), (2, 0, 1)]), + t!(aover360, &["foo", "foofoo"], "foofoo", &[(0, 0, 3), (1, 0, 6)]), +]; + +/// Regression tests that are applied to all Aho-Corasick combinations. +/// +/// If regression tests are needed for specific match semantics, then add them +/// to the appropriate group above. +const REGRESSION: &'static [SearchTest] = &[ + t!(regression010, &["inf", "ind"], "infind", &[(0, 0, 3), (1, 3, 6),]), + t!(regression020, &["ind", "inf"], "infind", &[(1, 0, 3), (0, 3, 6),]), + t!( + regression030, + &["libcore/", "libstd/"], + "libcore/char/methods.rs", + &[(0, 0, 8),] + ), + t!( + regression040, + &["libstd/", "libcore/"], + "libcore/char/methods.rs", + &[(1, 0, 8),] + ), + t!( + regression050, + &["\x00\x00\x01", "\x00\x00\x00"], + "\x00\x00\x00", + &[(1, 0, 3),] + ), + t!( + regression060, + &["\x00\x00\x00", "\x00\x00\x01"], + "\x00\x00\x00", + &[(0, 0, 3),] + ), +]; + +// Now define a test for each combination of things above that we want to run. +// Since there are a few different combinations for each collection of tests, +// we define a couple of macros to avoid repetition drudgery. The testconfig +// macro constructs the automaton from a given match kind, and runs the search +// tests one-by-one over the given collection. The `with` parameter allows one +// to configure the builder with additional parameters. The testcombo macro +// invokes testconfig in precisely this way: it sets up several tests where +// each one turns a different knob on AhoCorasickBuilder. + +macro_rules! testconfig { + (overlapping, $name:ident, $collection:expr, $kind:ident, $with:expr) => { + #[test] + fn $name() { + run_search_tests($collection, |test| { + let mut builder = AhoCorasickBuilder::new(); + $with(&mut builder); + builder + .match_kind(MatchKind::$kind) + .build(test.patterns) + .find_overlapping_iter(test.haystack) + .collect() + }); + } + }; + (stream, $name:ident, $collection:expr, $kind:ident, $with:expr) => { + #[test] + fn $name() { + run_search_tests($collection, |test| { + let buf = + io::BufReader::with_capacity(1, test.haystack.as_bytes()); + let mut builder = AhoCorasickBuilder::new(); + $with(&mut builder); + builder + .match_kind(MatchKind::$kind) + .build(test.patterns) + .stream_find_iter(buf) + .map(|result| result.unwrap()) + .collect() + }); + } + }; + ($name:ident, $collection:expr, $kind:ident, $with:expr) => { + #[test] + fn $name() { + run_search_tests($collection, |test| { + let mut builder = AhoCorasickBuilder::new(); + $with(&mut builder); + builder + .match_kind(MatchKind::$kind) + .build(test.patterns) + .find_iter(test.haystack) + .collect() + }); + } + }; +} + +macro_rules! testcombo { + ($name:ident, $collection:expr, $kind:ident) => { + mod $name { + use super::*; + + testconfig!(nfa_default, $collection, $kind, |_| ()); + testconfig!( + nfa_no_prefilter, + $collection, + $kind, + |b: &mut AhoCorasickBuilder| { + b.prefilter(false); + } + ); + testconfig!( + nfa_all_sparse, + $collection, + $kind, + |b: &mut AhoCorasickBuilder| { + b.dense_depth(0); + } + ); + testconfig!( + nfa_all_dense, + $collection, + $kind, + |b: &mut AhoCorasickBuilder| { + b.dense_depth(usize::MAX); + } + ); + testconfig!( + dfa_default, + $collection, + $kind, + |b: &mut AhoCorasickBuilder| { + b.dfa(true); + } + ); + testconfig!( + dfa_no_prefilter, + $collection, + $kind, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).prefilter(false); + } + ); + testconfig!( + dfa_all_sparse, + $collection, + $kind, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).dense_depth(0); + } + ); + testconfig!( + dfa_all_dense, + $collection, + $kind, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).dense_depth(usize::MAX); + } + ); + testconfig!( + dfa_no_byte_class, + $collection, + $kind, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).byte_classes(false); + } + ); + testconfig!( + dfa_no_premultiply, + $collection, + $kind, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).premultiply(false); + } + ); + testconfig!( + dfa_no_byte_class_no_premultiply, + $collection, + $kind, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).byte_classes(false).premultiply(false); + } + ); + } + }; +} + +// Write out the combinations. +testcombo!(search_leftmost_longest, AC_LEFTMOST_LONGEST, LeftmostLongest); +testcombo!(search_leftmost_first, AC_LEFTMOST_FIRST, LeftmostFirst); +testcombo!( + search_standard_nonoverlapping, + AC_STANDARD_NON_OVERLAPPING, + Standard +); + +// Write out the overlapping combo by hand since there is only one of them. +testconfig!( + overlapping, + search_standard_overlapping_nfa_default, + AC_STANDARD_OVERLAPPING, + Standard, + |_| () +); +testconfig!( + overlapping, + search_standard_overlapping_nfa_all_sparse, + AC_STANDARD_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.dense_depth(0); + } +); +testconfig!( + overlapping, + search_standard_overlapping_nfa_all_dense, + AC_STANDARD_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.dense_depth(usize::MAX); + } +); +testconfig!( + overlapping, + search_standard_overlapping_dfa_default, + AC_STANDARD_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.dfa(true); + } +); +testconfig!( + overlapping, + search_standard_overlapping_dfa_all_sparse, + AC_STANDARD_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).dense_depth(0); + } +); +testconfig!( + overlapping, + search_standard_overlapping_dfa_all_dense, + AC_STANDARD_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).dense_depth(usize::MAX); + } +); +testconfig!( + overlapping, + search_standard_overlapping_dfa_no_byte_class, + AC_STANDARD_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).byte_classes(false); + } +); +testconfig!( + overlapping, + search_standard_overlapping_dfa_no_premultiply, + AC_STANDARD_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).premultiply(false); + } +); +testconfig!( + overlapping, + search_standard_overlapping_dfa_no_byte_class_no_premultiply, + AC_STANDARD_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.dfa(true).byte_classes(false).premultiply(false); + } +); + +// Also write out tests manually for streams, since we only test the standard +// match semantics. We also don't bother testing different automaton +// configurations, since those are well covered by tests above. +testconfig!( + stream, + search_standard_stream_nfa_default, + AC_STANDARD_NON_OVERLAPPING, + Standard, + |_| () +); +testconfig!( + stream, + search_standard_stream_dfa_default, + AC_STANDARD_NON_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.dfa(true); + } +); + +// Same thing for anchored searches. Write them out manually. +testconfig!( + search_standard_anchored_nfa_default, + AC_STANDARD_ANCHORED_NON_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.anchored(true); + } +); +testconfig!( + search_standard_anchored_dfa_default, + AC_STANDARD_ANCHORED_NON_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.anchored(true).dfa(true); + } +); +testconfig!( + overlapping, + search_standard_anchored_overlapping_nfa_default, + AC_STANDARD_ANCHORED_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.anchored(true); + } +); +testconfig!( + overlapping, + search_standard_anchored_overlapping_dfa_default, + AC_STANDARD_ANCHORED_OVERLAPPING, + Standard, + |b: &mut AhoCorasickBuilder| { + b.anchored(true).dfa(true); + } +); +testconfig!( + search_leftmost_first_anchored_nfa_default, + AC_LEFTMOST_FIRST_ANCHORED, + LeftmostFirst, + |b: &mut AhoCorasickBuilder| { + b.anchored(true); + } +); +testconfig!( + search_leftmost_first_anchored_dfa_default, + AC_LEFTMOST_FIRST_ANCHORED, + LeftmostFirst, + |b: &mut AhoCorasickBuilder| { + b.anchored(true).dfa(true); + } +); +testconfig!( + search_leftmost_longest_anchored_nfa_default, + AC_LEFTMOST_LONGEST_ANCHORED, + LeftmostLongest, + |b: &mut AhoCorasickBuilder| { + b.anchored(true); + } +); +testconfig!( + search_leftmost_longest_anchored_dfa_default, + AC_LEFTMOST_LONGEST_ANCHORED, + LeftmostLongest, + |b: &mut AhoCorasickBuilder| { + b.anchored(true).dfa(true); + } +); + +#[test] +fn search_tests_have_unique_names() { + let assert = |constname, tests: &[SearchTest]| { + let mut seen = HashMap::new(); // map from test name to position + for (i, test) in tests.iter().enumerate() { + if !seen.contains_key(test.name) { + seen.insert(test.name, i); + } else { + let last = seen[test.name]; + panic!( + "{} tests have duplicate names at positions {} and {}", + constname, last, i + ); + } + } + }; + assert("BASICS", BASICS); + assert("STANDARD", STANDARD); + assert("LEFTMOST", LEFTMOST); + assert("LEFTMOST_FIRST", LEFTMOST_FIRST); + assert("LEFTMOST_LONGEST", LEFTMOST_LONGEST); + assert("NON_OVERLAPPING", NON_OVERLAPPING); + assert("OVERLAPPING", OVERLAPPING); + assert("REGRESSION", REGRESSION); +} + +#[test] +#[should_panic] +fn stream_not_allowed_leftmost_first() { + let fsm = AhoCorasickBuilder::new() + .match_kind(MatchKind::LeftmostFirst) + .build(None::); + assert_eq!(fsm.stream_find_iter(&b""[..]).count(), 0); +} + +#[test] +#[should_panic] +fn stream_not_allowed_leftmost_longest() { + let fsm = AhoCorasickBuilder::new() + .match_kind(MatchKind::LeftmostLongest) + .build(None::); + assert_eq!(fsm.stream_find_iter(&b""[..]).count(), 0); +} + +#[test] +#[should_panic] +fn overlapping_not_allowed_leftmost_first() { + let fsm = AhoCorasickBuilder::new() + .match_kind(MatchKind::LeftmostFirst) + .build(None::); + assert_eq!(fsm.find_overlapping_iter("").count(), 0); +} + +#[test] +#[should_panic] +fn overlapping_not_allowed_leftmost_longest() { + let fsm = AhoCorasickBuilder::new() + .match_kind(MatchKind::LeftmostLongest) + .build(None::); + assert_eq!(fsm.find_overlapping_iter("").count(), 0); +} + +#[test] +fn state_id_too_small() { + let mut patterns = vec![]; + for c1 in (b'a'..b'z').map(|b| b as char) { + for c2 in (b'a'..b'z').map(|b| b as char) { + for c3 in (b'a'..b'z').map(|b| b as char) { + patterns.push(format!("{}{}{}", c1, c2, c3)); + } + } + } + let result = + AhoCorasickBuilder::new().build_with_size::(&patterns); + assert!(result.is_err()); +} + +// See: https://github.com/BurntSushi/aho-corasick/issues/44 +// +// In short, this test ensures that enabling ASCII case insensitivity does not +// visit an exponential number of states when filling in failure transitions. +#[test] +fn regression_ascii_case_insensitive_no_exponential() { + let ac = AhoCorasickBuilder::new() + .ascii_case_insensitive(true) + .build(&["Tsubaki House-Triple Shot Vol01校花三姐妹"]); + assert!(ac.find("").is_none()); +} + +fn run_search_tests Vec>( + which: TestCollection, + mut f: F, +) { + let get_match_triples = + |matches: Vec| -> Vec<(usize, usize, usize)> { + matches + .into_iter() + .map(|m| (m.pattern(), m.start(), m.end())) + .collect() + }; + for &tests in which { + for test in tests { + assert_eq!( + test.matches, + get_match_triples(f(&test)).as_slice(), + "test: {}, patterns: {:?}, haystack: {:?}", + test.name, + test.patterns, + test.haystack + ); + } + } +} diff --git a/third_party/cargo/vendor/andrew-0.2.1/.cargo-checksum.json b/third_party/cargo/vendor/andrew-0.2.1/.cargo-checksum.json new file mode 100644 index 0000000..2be56f8 --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"4d03cdc2987a1fa1b86a2de5fa57714d83cbb9d3d3f400eadecd8e8a0a857621","Cargo.toml":"a9ec8b36707f907971b410719b85e9594cb96c9e4bca6f831e2cc78ba22c71da","LICENSE":"0dd39f89842df915b8ded7ac59e8a1372cf5be36133818866cca2ef3af1a2849","README.md":"132383b73044b1e91acb9e5d69afeb8f14239cfe712aca59152bfe0c420f7a33","examples/test.rs":"4e9e73dfe80573296e93f66c2c03681908c278a758dceb4913ecb65d20e9ed86","src/lib.rs":"7a0e852a4bbfbf72c7702527d7c6f7f8c717fca77bfd4b3e78ba7f6cebed4e6f","src/line.rs":"edbdc54503342733f8aa7a4aa72a7cb08d376d53ca2b85e00a77dd42bf04bb22","src/shapes/mod.rs":"071d6ea4080dc8f1e4299258d65c32bccc40e9eb6933f3b3600576d58e7917ae","src/shapes/rectangle.rs":"ad545b9d4a628b3a515deb9b087f881b253d3f3a16a60734da82896d51c93cc9","src/text/fontconfig.rs":"c673bfcf5df387479dd2027a733d8de85461731b448202f49a9f2d1bce54f465","src/text/mod.rs":"4afd25c6297d55cd5a3956e5ae6d3921403b306533a237fe2e5eab33e65a91ee"},"package":"9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e"} \ No newline at end of file diff --git a/third_party/cargo/vendor/andrew-0.2.1/BUILD b/third_party/cargo/vendor/andrew-0.2.1/BUILD new file mode 100644 index 0000000..1ef290e --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/BUILD @@ -0,0 +1,49 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "andrew", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/bitflags-1.2.1:bitflags", + "//third_party/cargo/vendor/line_drawing-0.7.0:line_drawing", + "//third_party/cargo/vendor/walkdir-2.3.1:walkdir", + "//third_party/cargo/vendor/xdg-2.2.0:xdg", + "//third_party/cargo/vendor/xml-rs-0.8.0:xml_rs", + "//third_party/cargo/vendor/rusttype-0.8.2:rusttype", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.2.1", + crate_features = [ + ], +) + +# Unsupported target "test" with type "example" omitted diff --git a/third_party/cargo/vendor/andrew-0.2.1/CHANGELOG.md b/third_party/cargo/vendor/andrew-0.2.1/CHANGELOG.md new file mode 100644 index 0000000..79dad8c --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/CHANGELOG.md @@ -0,0 +1,47 @@ +# Change Log + +## Unreleased + +## 0.2.1 -- 2019-03-29 + +- Fix `get_width()` for texts that start and end with spaces + +## 0.2.0 -- 2019-01-26 + +- **[Breaking]** Canvas is now endian aware and will draw to the buffer in the endianness of the `Endian` its created with + +## 0.1.6 -- 2019-01-24 + +- Faster drawing of horizontal and verticle lines by precomputing line boundaries +- Only calculate alpha overlay when drawing colors without a non-max alpha value for performance + +## 0.1.5 -- 2019-01-13 + +- Fix drawing of characters with negative bounding boxes +- Fix error in `get_width()` for text without any characters + +## 0.1.4 -- 2018-11-10 + +- Remove rusttype version restriction + +## 0.1.3 -- 2018-10-09 + +- Move from `quick-xml` to `xml-rs` dependency + +## 0.1.2 -- 2018-10-04 + +- Add basic/experimental support for fontconfig in `andrew::text::fontconfig` + +## 0.1.1 -- 2018-09-17 + +- Manage dependencies to maintain rust 1.22 compatibility +- Update rusttype to 0.7.1 + +## 0.1.0 -- 2018-08-17 + +Initial version, including: + +- canvas +- lines +- rectangles +- text diff --git a/third_party/cargo/vendor/andrew-0.2.1/Cargo.toml b/third_party/cargo/vendor/andrew-0.2.1/Cargo.toml new file mode 100644 index 0000000..2b8b020 --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/Cargo.toml @@ -0,0 +1,41 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "andrew" +version = "0.2.1" +authors = ["Lucas Timmins "] +description = "The andrew crate provides convenient drawing of objects such as shapes, lines and text to buffers" +readme = "README.md" +keywords = ["draw", "buffer", "shapes", "lines", "pixels"] +categories = ["rendering", "multimedia::images"] +license = "MIT" +repository = "https://github.com/trimental/andrew" +[dependencies.bitflags] +version = "1.0.3" + +[dependencies.line_drawing] +version = "0.7.0" + +[dependencies.rusttype] +version = "0.7.1" + +[dependencies.walkdir] +version = "2.0" + +[dependencies.xdg] +version = "2.1.0" + +[dependencies.xml-rs] +version = "0.8.0" +[dev-dependencies.smithay-client-toolkit] +version = "0.4.0" diff --git a/third_party/cargo/vendor/andrew-0.2.1/LICENSE b/third_party/cargo/vendor/andrew-0.2.1/LICENSE new file mode 100644 index 0000000..96fbb52 --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Lucas Timmins + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/andrew-0.2.1/README.md b/third_party/cargo/vendor/andrew-0.2.1/README.md new file mode 100644 index 0000000..3b93ff7 --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/README.md @@ -0,0 +1,3 @@ +# Andrew + +This crate provides convenient drawing of objects such as shapes, lines and text to buffers diff --git a/third_party/cargo/vendor/andrew-0.2.1/examples/test.rs b/third_party/cargo/vendor/andrew-0.2.1/examples/test.rs new file mode 100644 index 0000000..0d378e3 --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/examples/test.rs @@ -0,0 +1,210 @@ +extern crate andrew; +extern crate smithay_client_toolkit as sctk; + +use std::io::{Read, Seek, SeekFrom, Write}; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; + +use sctk::utils::{DoubleMemPool, MemPool}; +use sctk::window::{ConceptFrame, Event as WEvent, Window}; +use sctk::Environment; + +use sctk::reexports::client::protocol::wl_compositor::RequestsTrait as CompositorRequests; +use sctk::reexports::client::protocol::wl_surface::RequestsTrait as SurfaceRequests; +use sctk::reexports::client::protocol::{wl_shm, wl_surface}; +use sctk::reexports::client::{Display, Proxy}; + +use andrew::shapes::rectangle; +use andrew::text; +use andrew::text::fontconfig; + +fn main() { + let (display, mut event_queue) = + Display::connect_to_env().expect("Failed to connect to the wayland server."); + let env = Environment::from_display(&*display, &mut event_queue).unwrap(); + + let seat = env + .manager + .instantiate_auto(|seat| seat.implement(|_, _| {}, ())) + .unwrap(); + + let mut dimensions = (600, 400); + let surface = env + .compositor + .create_surface(|surface| surface.implement(|_, _| {}, ())) + .unwrap(); + + let next_action = Arc::new(Mutex::new(None::)); + + let waction = next_action.clone(); + let mut window = Window::::init_from_env(&env, surface, dimensions, move |evt| { + let mut next_action = waction.lock().unwrap(); + // Keep last event in priority order : Close > Configure > Refresh + let replace = match (&evt, &*next_action) { + (_, &None) + | (_, &Some(WEvent::Refresh)) + | (&WEvent::Configure { .. }, &Some(WEvent::Configure { .. })) + | (&WEvent::Close, _) => true, + _ => false, + }; + if replace { + *next_action = Some(evt); + } + }) + .expect("Failed to create a window !"); + + window.new_seat(&seat); + + let mut pools = DoubleMemPool::new(&env.shm, || {}).expect("Failed to create a memory pool !"); + + let mut font_data = Vec::new(); + ::std::fs::File::open( + &fontconfig::FontConfig::new() + .unwrap() + .get_regular_family_fonts("sans") + .unwrap()[0], + ) + .unwrap() + .read_to_end(&mut font_data) + .unwrap(); + + if !env.shell.needs_configure() { + if let Some(pool) = pools.pool() { + redraw(pool, window.surface(), dimensions, &font_data); + } + window.refresh(); + } + + loop { + match next_action.lock().unwrap().take() { + Some(WEvent::Close) => break, + Some(WEvent::Refresh) => { + window.refresh(); + window.surface().commit(); + } + Some(WEvent::Configure { new_size, .. }) => { + if let Some((w, h)) = new_size { + window.resize(w, h); + dimensions = (w, h) + } + window.refresh(); + if let Some(pool) = pools.pool() { + redraw(pool, window.surface(), dimensions, &font_data); + } + } + None => {} + } + + display.flush().unwrap(); + event_queue.dispatch().unwrap(); + } +} + +fn redraw( + pool: &mut MemPool, + surface: &Proxy, + dimensions: (u32, u32), + font_data: &[u8], +) { + let (buf_x, buf_y) = (dimensions.0 as usize, dimensions.1 as usize); + + pool.resize(4 * buf_x * buf_y) + .expect("Failed to resize the memory pool."); + + let mut buf: Vec = vec![255; 4 * buf_x * buf_y]; + let mut canvas = + andrew::Canvas::new(&mut buf, buf_x, buf_y, 4 * buf_x, andrew::Endian::native()); + + println!("______________"); + let mut total_dur = Duration::new(0, 0); + + // Draw background + let (block_w, block_h) = (buf_x / 20, buf_y / 20); + for block_y in 0..21 { + for block_x in 0..21 { + let color = if (block_x + (block_y % 2)) % 2 == 0 { + [255, 0, 0, 0] + } else { + [255, 255, 255, 255] + }; + + let block = rectangle::Rectangle::new( + (block_w * block_x, block_h * block_y), + (block_w, block_h), + None, + Some(color), + ); + let timer = Instant::now(); + canvas.draw(&block); + total_dur += timer.elapsed() + } + } + println!("Background draw time: {:?}", total_dur); + + let rectangle = rectangle::Rectangle::new( + (buf_x / 30, buf_y / 4), + (buf_x - (buf_x / 30) * 2, buf_y - buf_y / 2), + Some(( + 15, + [255, 170, 20, 45], + rectangle::Sides::TOP ^ rectangle::Sides::BOTTOM, + Some(10), + )), + Some([255, 170, 20, 45]), + ); + let mut timer = Instant::now(); + canvas.draw(&rectangle); + println!("Rectangle draw time: {:?}", timer.elapsed()); + total_dur += timer.elapsed(); + + let text_h = buf_x as f32 / 80.; + let text_hh = text_h / 2.; + let mut text = text::Text::new( + (63, 69), + [255, 255, 255, 255], + font_data, + text_h, + 2.0, + "“Life is the art of drawing without an eraser.” - John W. Gardner", + ); + text.pos = ( + buf_x / 2 - text.get_width() / 2, + buf_y / 2 - text_hh as usize, + ); + + let text_box = rectangle::Rectangle::new( + ( + buf_x / 2 - text.get_width() / 2 - 10, + buf_y / 2 - text_hh as usize - 10, + ), + (text.get_width() + 20, text_h as usize + 20), + Some((3, [255, 255, 255, 255], rectangle::Sides::ALL, Some(5))), + None, + ); + + timer = Instant::now(); + canvas.draw(&text_box); + println!("Text box draw time: {:?}", timer.elapsed()); + total_dur += timer.elapsed(); + + timer = Instant::now(); + canvas.draw(&text); + println!("Text draw time: {:?}", timer.elapsed()); + total_dur += timer.elapsed(); + + println!("Total draw time: {:?}", total_dur); + + pool.seek(SeekFrom::Start(0)).unwrap(); + pool.write_all(canvas.buffer).unwrap(); + pool.flush().unwrap(); + + let new_buffer = pool.buffer( + 0, + buf_x as i32, + buf_y as i32, + 4 * buf_x as i32, + wl_shm::Format::Argb8888, + ); + surface.attach(Some(&new_buffer), 0, 0); + surface.commit(); +} diff --git a/third_party/cargo/vendor/andrew-0.2.1/src/lib.rs b/third_party/cargo/vendor/andrew-0.2.1/src/lib.rs new file mode 100644 index 0000000..86f3e79 --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/src/lib.rs @@ -0,0 +1,134 @@ +//! Andrew is a crate for drawing objects +#![warn(missing_docs)] +extern crate line_drawing; +extern crate rusttype; +extern crate walkdir; +extern crate xdg; +extern crate xml; + +#[macro_use] +extern crate bitflags; + +/// A module that contains functions and objects relating to lines +pub mod line; +/// A module that contains functions and objects relating to shapes +pub mod shapes; +/// A module that contains functions and objects relating to text +pub mod text; + +/// The Drawable trait allows object to be drawn to a buffer or canvas +pub trait Drawable { + /// A function that draws the object to a canvas + fn draw(&self, canvas: &mut Canvas); +} + +/// Describes an endianness (aka byte order) +#[derive(Debug, PartialEq)] +pub enum Endian { + /// Little Endian + Little, + /// Big Endian + Big, +} + +impl Endian { + /// Returns the native endianness + pub fn native() -> Endian { + if cfg!(target_endian = "little") { + Endian::Little + } else { + Endian::Big + } + } +} + +/// The canvas object acts as a wrapper around a buffer, providing information and functions +/// for drawing +pub struct Canvas<'a> { + /// A buffer for the canvas to draw to + pub buffer: &'a mut [u8], + /// The width in pixels of the canvas + pub width: usize, + /// The height in pixels of the canvas + pub height: usize, + /// The number of bytes between each line of pixels on the canvas + pub stride: usize, + /// The number of bytes contained in each pixel + pub pixel_size: usize, + /// The endianness of the canvas + pub endianness: Endian, +} + +impl<'a> Canvas<'a> { + /// Creates a new canvas object + pub fn new( + buffer: &'a mut [u8], + width: usize, + height: usize, + stride: usize, + endianness: Endian, + ) -> Canvas<'a> { + assert!( + stride % width == 0, + "Incorrect Dimensions - Stride is not a multiple of width" + ); + assert!(buffer.len() == stride * height); + let pixel_size = stride / width; + Canvas { + buffer, + width, + height, + stride, + pixel_size, + endianness, + } + } + + /// Draws an object that implements the Drawable trait to the buffer + pub fn draw(&mut self, drawable: &D) { + drawable.draw(self); + } + + /// Draws a pixel at the x and y coordinate + pub fn draw_point(&mut self, x: usize, y: usize, color: [u8; 4]) { + let base = self.stride * y + self.pixel_size * x; + if self.endianness == Endian::Little { + if color[0] == 255 { + self.buffer[base + 3] = color[0]; + self.buffer[base + 2] = color[1]; + self.buffer[base + 1] = color[2]; + self.buffer[base] = color[3]; + } else { + for c in 0..3 { + let alpha = f32::from(color[0]) / 255.0; + let color_diff = + (color[3 - c] as isize - self.buffer[base + c] as isize) as f32 * alpha; + let new_color = (f32::from(self.buffer[base + c]) + color_diff) as u8; + self.buffer[base + c] = new_color as u8; + } + self.buffer[base + 3] = 255 as u8; + } + } else if color[0] == 255 { + self.buffer[base] = color[0]; + self.buffer[base + 1] = color[1]; + self.buffer[base + 2] = color[2]; + self.buffer[base + 3] = color[3]; + } else { + for c in 1..4 { + let alpha = f32::from(color[0]) / 255.0; + let color_diff = + (color[c] as isize - self.buffer[base + c] as isize) as f32 * alpha; + let new_color = (f32::from(self.buffer[base + c]) + color_diff) as u8; + self.buffer[base + c] = new_color as u8; + } + self.buffer[base] = 255 as u8; + } + } + + /// Clears the entire canvas buffer by zeroing it + pub fn clear(&mut self) { + for i in 0..self.width * self.height * 4 { + self.buffer[i] = 0x00; + } + } +} diff --git a/third_party/cargo/vendor/andrew-0.2.1/src/line.rs b/third_party/cargo/vendor/andrew-0.2.1/src/line.rs new file mode 100644 index 0000000..5179ae1 --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/src/line.rs @@ -0,0 +1,84 @@ +use std::cmp::min; + +use line_drawing::Bresenham; +use line_drawing::XiaolinWu; + +use Canvas; +use Drawable; + +/// A drawable object that represents a line +pub struct Line { + /// The first point of the line + pub pt1: (usize, usize), + /// The second point of the line + pub pt2: (usize, usize), + /// The color of the line + pub color: [u8; 4], + /// Decides whether the line will be antialiased + pub antialiased: bool, +} + +impl Line { + /// Creates a new Line object + pub fn new( + pt1: (usize, usize), + pt2: (usize, usize), + color: [u8; 4], + antialiased: bool, + ) -> Line { + Line { + pt1, + pt2, + color, + antialiased, + } + } +} + +impl Drawable for Line { + fn draw(&self, canvas: &mut Canvas) { + if !self.antialiased { + if self.pt1.0 == self.pt2.0 && self.pt1.0 < canvas.width { + let (min_y, max_y) = if self.pt1.1 > self.pt2.1 { + (self.pt2.1, self.pt1.1) + } else { + (self.pt1.1, self.pt2.1) + }; + for y in min_y..min(max_y, canvas.height - 1) + 1 { + canvas.draw_point(self.pt1.0, y, self.color) + } + } else if self.pt1.1 == self.pt2.1 && self.pt1.1 < canvas.height { + let (min_x, max_x) = if self.pt1.0 > self.pt2.0 { + (self.pt2.0, self.pt1.0) + } else { + (self.pt1.0, self.pt2.0) + }; + for x in min_x..min(max_x, canvas.width - 1) + 1 { + canvas.draw_point(x, self.pt1.1, self.color) + } + } else { + // Angled line without antialias + for (x, y) in Bresenham::new( + (self.pt1.0 as isize, self.pt1.1 as isize), + (self.pt2.0 as isize, self.pt2.1 as isize), + ) { + if x < canvas.width as isize && y < canvas.height as isize { + canvas.draw_point(x as usize, y as usize, self.color) + } + } + } + } else { + // Angled line with antialias + for ((x, y), coverage) in XiaolinWu::::new( + (self.pt1.0 as f32, self.pt1.1 as f32), + (self.pt2.0 as f32, self.pt2.1 as f32), + ) { + if x < canvas.width as isize && y < canvas.height as isize { + let mut color = self.color; + color[3] = (f32::from(color[3]) * coverage) as u8; + canvas.draw_point(x as usize, y as usize, color) + } + } + } + } +} diff --git a/third_party/cargo/vendor/andrew-0.2.1/src/shapes/mod.rs b/third_party/cargo/vendor/andrew-0.2.1/src/shapes/mod.rs new file mode 100644 index 0000000..17af111 --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/src/shapes/mod.rs @@ -0,0 +1,2 @@ +/// A module that contains functions and objects relating to rectangles +pub mod rectangle; diff --git a/third_party/cargo/vendor/andrew-0.2.1/src/shapes/rectangle.rs b/third_party/cargo/vendor/andrew-0.2.1/src/shapes/rectangle.rs new file mode 100644 index 0000000..d568fcf --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/src/shapes/rectangle.rs @@ -0,0 +1,153 @@ +use line::Line; +use Canvas; +use Drawable; + +bitflags! { + /// The Sides bitflag presents the sides of a rectangle + pub struct Sides: u32 { + /// The top side of the rectangle + const TOP = 0b0001; + /// The bottom side of the rectangle + const BOTTOM = 0b0010; + /// The left side of the rectangle + const LEFT = 0b0100; + /// The right side of the rectangle + const RIGHT = 0b1000; + /// All sides of the rectangle + const ALL = Self::TOP.bits | Self::BOTTOM.bits | Self::LEFT.bits | Self::RIGHT.bits; + } +} + +/// A drawable object that represents a rectangle +pub struct Rectangle { + /// Position of the top-left corner of rectangle + pub pos: (usize, usize), + /// The size of the rectangle to be drawn, the border will be contained within this size + pub size: (usize, usize), + /// The border that is drawn around the perimeter of the rectangle. It's arguments are + /// thickness of border, color of border, sides that the border is drawn around, rounding size + /// of the corners + pub border: Option<(usize, [u8; 4], Sides, Option)>, + /// The color of the fill (area) of the rectangle + pub fill: Option<[u8; 4]>, +} + +impl Rectangle { + /// Creates a new Rectangle object + pub fn new( + pos: (usize, usize), + size: (usize, usize), + border: Option<(usize, [u8; 4], Sides, Option)>, + fill: Option<[u8; 4]>, + ) -> Rectangle { + Rectangle { + pos, + size, + border, + fill, + } + } + + fn draw_borders(&self, canvas: &mut Canvas) { + if let Some(border) = self.border { + for i in 0..border.0 { + let rounding_space = if let Some(round_size) = border.3 { + if i < round_size { + round_size + - ((round_size as f32).powi(2) - ((round_size - i - 1) as f32).powi(2)) + .sqrt() + .round() as usize + } else { + 0 + } + } else { + 0 + }; + + // Top line + if border.2.contains(Sides::TOP) && canvas.width > rounding_space * 2 { + Line::new( + (self.pos.0 + rounding_space, self.pos.1 + i), + (self.pos.0 + self.size.0 - rounding_space, self.pos.1 + i), + border.1, + false, + ) + .draw(canvas); + } + // Bottom line + if border.2.contains(Sides::BOTTOM) && canvas.width > rounding_space * 2 { + Line::new( + (self.pos.0 + rounding_space, self.pos.1 + self.size.1 - i), + ( + self.pos.0 + self.size.0 - rounding_space, + self.pos.1 + self.size.1 - i, + ), + border.1, + false, + ) + .draw(canvas); + } + // Left line + if border.2.contains(Sides::LEFT) && canvas.height > rounding_space * 2 { + Line::new( + (self.pos.0 + i, self.pos.1 + rounding_space), + (self.pos.0 + i, self.pos.1 + self.size.1 - rounding_space), + border.1, + false, + ) + .draw(canvas); + } + // Right line + if border.2.contains(Sides::RIGHT) && canvas.height > rounding_space * 2 { + Line::new( + (self.pos.0 + self.size.0 - i, self.pos.1 + rounding_space), + ( + self.pos.0 + self.size.0 - i, + self.pos.1 + self.size.1 - rounding_space, + ), + border.1, + false, + ) + .draw(canvas); + } + } + } + } + + fn draw_area(&self, canvas: &mut Canvas) { + if let Some(fill) = self.fill { + let (area_pos, area_size) = self.measure_area(); + for y in area_pos.1..area_pos.1 + area_size.1 + 1 { + Line::new((area_pos.0, y), (area_pos.0 + area_size.0, y), fill, false).draw(canvas) + } + } + } + + fn measure_area(&self) -> ((usize, usize), (usize, usize)) { + let (mut area_pos, mut area_size) = (self.pos, self.size); + if let Some(border) = self.border { + if border.2.contains(Sides::TOP) { + area_pos.1 += border.0; + area_size.1 -= border.0; + } + if border.2.contains(Sides::BOTTOM) { + area_size.1 -= border.0; + } + if border.2.contains(Sides::LEFT) { + area_pos.0 += border.0; + area_size.0 -= border.0; + } + if border.2.contains(Sides::RIGHT) { + area_size.0 -= border.0; + } + } + (area_pos, area_size) + } +} + +impl Drawable for Rectangle { + fn draw(&self, canvas: &mut Canvas) { + self.draw_borders(canvas); + self.draw_area(canvas); + } +} diff --git a/third_party/cargo/vendor/andrew-0.2.1/src/text/fontconfig.rs b/third_party/cargo/vendor/andrew-0.2.1/src/text/fontconfig.rs new file mode 100644 index 0000000..0beca50 --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/src/text/fontconfig.rs @@ -0,0 +1,162 @@ +use std::fs::File; +use std::io::prelude::*; +use std::path::{Path, PathBuf}; + +use xdg::BaseDirectories; + +use xml::reader::{EventReader, XmlEvent}; + +use walkdir::WalkDir; + +/// Locates fontconfig config +fn get_config() -> Option { + let xdg_dirs = BaseDirectories::with_prefix("fontconfig").unwrap(); + xdg_dirs.find_config_file("fonts.conf").or_else(|| { + let config = Path::new("/etc/fonts/fonts.conf"); + if config.exists() { + Some(config.into()) + } else { + None + } + }) +} + +fn parse_config(path: &Path) -> Vec<(Vec, String)> { + let config_file = File::open(path).unwrap(); + let parser = EventReader::new(config_file); + let mut tracking_tags: Vec = Vec::new(); + let mut xml_data: Vec<(Vec, String)> = Vec::new(); + + for e in parser { + match e { + Ok(XmlEvent::StartElement { name, .. }) => { + tracking_tags.push(name.to_string()); + } + Ok(XmlEvent::CData(data)) => { + xml_data.push((tracking_tags.clone(), data)); + } + Ok(XmlEvent::Characters(data)) => { + xml_data.push((tracking_tags.clone(), data)); + } + Ok(XmlEvent::EndElement { .. }) => { + tracking_tags.pop(); + } + Err(e) => panic!(e), + _ => {} + } + } + xml_data +} + +/// Represents the main fontconfig config file +pub struct FontConfig { + location: PathBuf, + data: Vec<(Vec, String)>, +} + +impl FontConfig { + /// Creates a new FontConfig object by looking for the fontconfig config file + pub fn new() -> Result { + let location = get_config().ok_or(())?; + let data = parse_config(&location); + Ok(FontConfig { + location: location.to_path_buf(), + data, + }) + } + + /// Returns the location of the fontconfig config file being used + pub fn get_location(&self) -> &Path { + &self.location + } + + /// Get the directories that contain fonts + pub fn get_font_dirs(&self) -> Vec { + let mut dirs = Vec::new(); + for entry in &self.data { + if entry.0.last() == Some(&"dir".to_string()) { + let path = PathBuf::from(entry.1.clone()); + if path.exists() { + dirs.push(path); + } + } + } + dirs + } + + /// Return all fonts installed on the system + pub fn get_fonts(&self) -> Result, ::std::io::Error> { + let mut fonts = Vec::new(); + for dir in self.get_font_dirs() { + for file in WalkDir::new(dir) + .into_iter() + .filter_map(|e| e.ok()) + .filter(|p| p.file_type().is_file()) + { + let path = file.into_path(); + if let Some(extension) = path.extension() { + match extension.to_str() { + Some("ttf") | Some("otf") => fonts.push(path.clone()), + _ => {} + } + } + } + } + Ok(fonts) + } + + /// Return all 'fonts.dir' files in font directories + pub fn get_font_dir_files(&self) -> Result, ::std::io::Error> { + let mut fonts = Vec::new(); + for dir in self.get_font_dirs() { + for file in WalkDir::new(dir) + .into_iter() + .filter_map(|e| e.ok()) + .filter(|p| p.file_type().is_file()) + { + let path = file.into_path(); + if let Some(file_name) = path.clone().file_name() { + if file_name.to_str() == Some("fonts.dir") { + fonts.push(path); + } + } + } + } + Ok(fonts) + } + + /// Returns the paths of regular fonts belonging to a specific family installed on the system + pub fn get_regular_family_fonts(&self, family: &str) -> Result, ::std::io::Error> { + let fonts_dir_files = self.get_font_dir_files()?; + let mut fonts: Vec = Vec::new(); + for dir in fonts_dir_files { + let mut file = ::std::fs::File::open(dir.clone()).unwrap(); + let mut buf = String::new(); + file.read_to_string(&mut buf)?; + + for line in buf.lines().filter(|l| l.find("medium-r-normal").is_some()) { + if let Some(split) = line.find(' ') { + let name = line[..split].to_string(); + let settings = line[split..].to_string(); + let mut char_buf = String::new(); + for c in settings.chars() { + if c == ' ' || c == '-' { + char_buf.clear() + } else { + char_buf.push(c); + if char_buf == family { + let path = dir.with_file_name(name); + if !fonts.contains(&path) { + fonts.push(path); + } + break; + } + } + } + } + } + } + + Ok(fonts) + } +} diff --git a/third_party/cargo/vendor/andrew-0.2.1/src/text/mod.rs b/third_party/cargo/vendor/andrew-0.2.1/src/text/mod.rs new file mode 100644 index 0000000..7849fe8 --- /dev/null +++ b/third_party/cargo/vendor/andrew-0.2.1/src/text/mod.rs @@ -0,0 +1,121 @@ +/// A module that contains functions and objects relating to fontconfig +pub mod fontconfig; + +use rusttype::{point, Font, Scale, SharedBytes, VMetrics}; +use std::fs::File; +use std::io::Read; +use std::path::PathBuf; +use Canvas; +use Drawable; + +/// A drawable object that represents text +pub struct Text<'a> { + /// The position of the text on the canvas + pub pos: (usize, usize), + /// The color of the text + pub color: [u8; 4], + /// The text that is rendered to the canvas on draw + pub text: String, + /// The font used in rendering the text + pub font: Font<'a>, + /// The scale that is applied to the text + pub scale: Scale, + /// The vertical metrics of the text + pub v_metrics: VMetrics, +} + +/// Loads a font file into a `Vec` +pub fn load_font_file>(path: P) -> Vec { + let mut data: Vec = Vec::new(); + let mut file = File::open(path.into()).expect("Could not open font file"); + file.read_to_end(&mut data) + .expect("Could not read font file"); + data +} + +impl<'a> Text<'a> { + /// Creates a new Text object + pub fn new>, T: Into>( + pos: (usize, usize), + color: [u8; 4], + font_data: P, + height: f32, + width_scale: f32, + text: T, + ) -> Text<'a> { + let text = text.into(); + // Create font + let font = Font::from_bytes(font_data).expect("Error constructing Font"); + // Create scale + let scale = Scale { + x: height * width_scale, + y: height, + }; + // Create needed metrics + let v_metrics = font.v_metrics(scale); + Text { + pos, + color, + text: text.clone(), + scale, + v_metrics, + font, + } + } + + fn draw_text(&self, canvas: &mut Canvas) { + let glyphs: Vec<_> = self + .font + .layout(&self.text, self.scale, point(0.0, self.v_metrics.ascent)) + .collect(); + for glyph in glyphs { + if let Some(bounding_box) = glyph.pixel_bounding_box() { + glyph.draw(|x, y, v| { + let x = ((x as usize + self.pos.0) as i32 + bounding_box.min.x) as usize; + let y = ((y as usize + self.pos.1) as i32 + bounding_box.min.y) as usize; + + if x < canvas.width && y < canvas.height { + let mut color = self.color; + color[0] = (f32::from(color[0]) * v) as u8; + canvas.draw_point(x, y, color); + } + }); + } + } + } + + /// Calculates the width in pixels of the text + pub fn get_width(&self) -> usize { + let glyphs: Vec<_> = self + .font + .layout(&self.text, self.scale, point(0.0, self.v_metrics.ascent)) + .collect(); + let min_x = glyphs + .first() + .map(|g| { + if let Some(bb) = g.pixel_bounding_box() { + bb.min.x + } else { + g.position().x as i32 + } + }) + .unwrap_or(0); + let max_x = glyphs + .last() + .map(|g| { + if let Some(bb) = g.pixel_bounding_box() { + bb.max.x + } else { + (g.position().x + g.unpositioned().h_metrics().advance_width) as i32 + } + }) + .unwrap_or(0); + (max_x - min_x) as usize + } +} + +impl<'a> Drawable for Text<'a> { + fn draw(&self, canvas: &mut Canvas) { + self.draw_text(canvas); + } +} diff --git a/third_party/cargo/vendor/android_glue-0.2.3/.cargo-checksum.json b/third_party/cargo/vendor/android_glue-0.2.3/.cargo-checksum.json new file mode 100644 index 0000000..5cc98d3 --- /dev/null +++ b/third_party/cargo/vendor/android_glue-0.2.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"dbe01d8dfe2ea291ca94d56acfe3a401bbaf81d960be2d2afc5e916f755a9ab7","src/lib.rs":"d364185fd66b549a70b935fdfec041b55a10cdc0dd901fd95b38554f08cf0923"},"package":"000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407"} \ No newline at end of file diff --git a/third_party/cargo/vendor/android_glue-0.2.3/BUILD b/third_party/cargo/vendor/android_glue-0.2.3/BUILD new file mode 100644 index 0000000..1ee45d8 --- /dev/null +++ b/third_party/cargo/vendor/android_glue-0.2.3/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "android_glue", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.2.3", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/android_glue-0.2.3/Cargo.toml b/third_party/cargo/vendor/android_glue-0.2.3/Cargo.toml new file mode 100644 index 0000000..5e42c10 --- /dev/null +++ b/third_party/cargo/vendor/android_glue-0.2.3/Cargo.toml @@ -0,0 +1,8 @@ +[package] + +name = "android_glue" +version = "0.2.3" +authors = ["Pierre Krieger "] +license = "MIT" +description = "Glue for the Android JNI" +repository = "https://github.com/tomaka/android-rs-glue" diff --git a/third_party/cargo/vendor/android_glue-0.2.3/src/lib.rs b/third_party/cargo/vendor/android_glue-0.2.3/src/lib.rs new file mode 100644 index 0000000..bd1d891 --- /dev/null +++ b/third_party/cargo/vendor/android_glue-0.2.3/src/lib.rs @@ -0,0 +1,152 @@ +#![cfg(target_os = "android")] + +extern { + fn cargo_apk_injected_glue_get_native_window() -> *const c_void; + fn cargo_apk_injected_glue_add_sender(sender: *mut ()); + fn cargo_apk_injected_glue_add_sender_missing(sender: *mut ()); + fn cargo_apk_injected_glue_add_sync_event_handler(sender: *mut ()); + fn cargo_apk_injected_glue_remove_sync_event_handler(sender: *mut ()); + fn cargo_apk_injected_glue_set_multitouch(multitouch: bool); + fn cargo_apk_injected_glue_write_log(ptr: *const (), len: usize); + fn cargo_apk_injected_glue_load_asset(ptr: *const (), len: usize) -> *mut c_void; + fn cargo_apk_injected_glue_wake_event_loop(); +} + +use std::mem; +use std::os::raw::c_void; +use std::sync::mpsc::Sender; + +/// An event triggered by the Android environment. +#[derive(Clone, Copy, Debug)] +pub enum Event { + EventMotion(Motion), + EventKeyUp, + EventKeyDown, + InitWindow, + SaveState, + TermWindow, + GainedFocus, + LostFocus, + InputChanged, + WindowResized, + WindowRedrawNeeded, + ContentRectChanged, + ConfigChanged, + LowMemory, + Start, + Resume, + Pause, + Stop, + Destroy, + Wake +} + +/// Data about a motion event. +#[derive(Clone, Copy, Debug)] +pub struct Motion { + pub action: MotionAction, + pub pointer_id: i32, + pub x: f32, + pub y: f32, +} + +/// The type of pointer action in a motion event. +#[derive(Clone, Copy, Debug)] +pub enum MotionAction { + Down, + Move, + Up, + Cancel, +} + +pub enum AssetError { + AssetMissing, + EmptyBuffer, +} + +// Trait used to dispatch sync events from the polling loop thread. +pub trait SyncEventHandler { + fn handle(&mut self, event: &Event); +} + +/// Adds a sender where events will be sent to. +#[inline] +pub fn add_sender(sender: Sender) { + unsafe { + let sender = Box::into_raw(Box::new(sender)) as *mut _; + cargo_apk_injected_glue_add_sender(sender); + } +} + +/// Adds a SyncEventHandler which will receive sync events from the polling loop. +#[inline] +pub fn add_sync_event_handler(handler: Box) { + unsafe { + let handler = Box::into_raw(Box::new(handler)) as *mut _; + cargo_apk_injected_glue_add_sync_event_handler(handler); + } +} + +/// Removes a SyncEventHandler. +#[inline] +pub fn remove_sync_event_handler(handler: *const SyncEventHandler) { + unsafe { + let handler = Box::into_raw(Box::new(handler)) as *mut _; + cargo_apk_injected_glue_remove_sync_event_handler(handler); + } +} + +#[inline] +pub fn set_multitouch(multitouch: bool) { + unsafe { + cargo_apk_injected_glue_set_multitouch(multitouch); + } +} + +/// Adds a sender where events will be sent to, but also sends +/// any missing events to the sender object. +/// +/// The missing events happen when the application starts, but before +/// any senders are registered. Since these might be important to certain +/// applications, this function provides that support. +#[inline] +pub fn add_sender_missing(sender: Sender) { + unsafe { + let sender = Box::into_raw(Box::new(sender)) as *mut _; + cargo_apk_injected_glue_add_sender_missing(sender); + } +} + +/// Returns a handle to the native window. +#[inline] +pub unsafe fn get_native_window() -> *const c_void { + cargo_apk_injected_glue_get_native_window() +} + +/// +#[inline] +pub fn write_log(message: &str) { + unsafe { + let (message_ptr, message_len) = mem::transmute(message); + cargo_apk_injected_glue_write_log(message_ptr, message_len); + } +} + +#[inline] +pub fn load_asset(filename: &str) -> Result, AssetError> { + unsafe { + let (filename_ptr, filename_len) = mem::transmute(filename); + let data = cargo_apk_injected_glue_load_asset(filename_ptr, filename_len); + let data: Box, AssetError>> = Box::from_raw(data as *mut _); + *data + } +} + +// Wakes the event poll asynchronously and sends a Event::Wake event to the senders. +// This method can be called on any thread. This method returns immediately. +#[inline] +pub fn wake_event_loop() { + unsafe { + cargo_apk_injected_glue_wake_event_loop(); + } +} diff --git a/third_party/cargo/vendor/approx-0.3.2/.cargo-checksum.json b/third_party/cargo/vendor/approx-0.3.2/.cargo-checksum.json new file mode 100644 index 0000000..a795193 --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"bcd8107c8c85e92fb0b291014b8ba62bb1f076ec297028fd44e264765c303f2f","LICENSE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","README.md":"5e965438ec90b7ede0a5c93c482a91536759c147e215f7471d8534f121feb244","src/abs_diff_eq.rs":"b11c8128d1460ee9739abeedc49d8923fde2acb953481661f5adc94feef86761","src/lib.rs":"075aa97495af343ad128b59cdec0206eb06d30d153abe1c38226d9d0f55c0fc9","src/macros.rs":"a9b59cce0cdb3e154321e7ba6ed2d53c21eeb8a46840a761e36e0259b44a59c4","src/relative_eq.rs":"ff292f125853ff846adc29cfa260042bab5e329e7b47b732e863587b8946b9d2","src/ulps_eq.rs":"21ad336b9ed8762eb3b7b1dd1b47b001edc8497d85c8c385bf8b2964be5687e7","tests/abs_diff_eq.rs":"9df9b48842dbc61b04b0328b64f2ce48b6e66e9538178babd58a9e52adeaddaf","tests/macro_import.rs":"006d813c99217d251a30b2f248548e7ad385754f88f6d9838d1dee866ea4b7f4","tests/macros.rs":"697241db4db66633cb53324bb127c64fd3b544236055bfe1721abb64a1dfab23","tests/relative_eq.rs":"c114edb6af07a2ac126e167682dd5d677d5591217f48bfdba150f866dfe4fdaf","tests/ulps_eq.rs":"ef6d57b98394fc87e724e26de7a3461426444563ec962661f660875b0702aeb6"},"package":"f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3"} \ No newline at end of file diff --git a/third_party/cargo/vendor/approx-0.3.2/BUILD b/third_party/cargo/vendor/approx-0.3.2/BUILD new file mode 100644 index 0000000..8433b65 --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/BUILD @@ -0,0 +1,48 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "abs_diff_eq" with type "test" omitted + +rust_library( + name = "approx", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/num-traits-0.2.11:num_traits", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.3.2", + crate_features = [ + ], +) + +# Unsupported target "macro_import" with type "test" omitted +# Unsupported target "macros" with type "test" omitted +# Unsupported target "relative_eq" with type "test" omitted +# Unsupported target "ulps_eq" with type "test" omitted diff --git a/third_party/cargo/vendor/approx-0.3.2/Cargo.toml b/third_party/cargo/vendor/approx-0.3.2/Cargo.toml new file mode 100644 index 0000000..5fc4d2d --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/Cargo.toml @@ -0,0 +1,39 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "approx" +version = "0.3.2" +authors = ["Brendan Zabarauskas "] +description = "Approximate floating point equality comparisons and assertions." +homepage = "https://github.com/brendanzab/approx" +documentation = "https://docs.rs/approx" +readme = "README.md" +keywords = ["approximate", "assert", "comparison", "equality", "float"] +license = "Apache-2.0" +repository = "https://github.com/brendanzab/approx" +[package.metadata.docs.rs] +features = ["std", "num-complex"] + +[lib] +name = "approx" +[dependencies.num-complex] +version = "0.2.0" +optional = true + +[dependencies.num-traits] +version = "0.2.0" +default_features = false + +[features] +default = ["std"] +std = [] diff --git a/third_party/cargo/vendor/approx-0.3.2/LICENSE b/third_party/cargo/vendor/approx-0.3.2/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/third_party/cargo/vendor/approx-0.3.2/README.md b/third_party/cargo/vendor/approx-0.3.2/README.md new file mode 100644 index 0000000..601cc3c --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/README.md @@ -0,0 +1,20 @@ +# approx + +[![Build Status][travis_badge]][travis_url] +[![Version][version_badge]][crate_url] +[![Documentation][docs_badge]][docs_url] +[![Downloads][downloads_badge]][crate_url] +[![License][license_badge]][license_url] + +[travis_badge]: https://travis-ci.org/brendanzab/approx.svg?branch=master +[docs_badge]: https://docs.rs/approx/badge.svg +[version_badge]: https://img.shields.io/crates/v/approx.svg +[license_badge]: https://img.shields.io/crates/l/approx.svg +[downloads_badge]: https://img.shields.io/crates/d/approx.svg + +[travis_url]: https://travis-ci.org/brendanzab/approx +[docs_url]: https://docs.rs/approx +[crate_url]: https://crates.io/crates/approx +[license_url]: https://github.com/brendanzab/approx/blob/master/LICENSE + +Approximate floating point equality comparisons and assertions for the Rust Programming Language. diff --git a/third_party/cargo/vendor/approx-0.3.2/src/abs_diff_eq.rs b/third_party/cargo/vendor/approx-0.3.2/src/abs_diff_eq.rs new file mode 100644 index 0000000..67f59c7 --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/src/abs_diff_eq.rs @@ -0,0 +1,185 @@ +#[cfg(feature = "num-complex")] +use num_complex::Complex; +#[cfg(not(feature = "std"))] +use num_traits::float::FloatCore; +use std::{cell, f32, f64}; + +/// Equality that is defined using the absolute difference of two numbers. +pub trait AbsDiffEq: PartialEq +where + Rhs: ?Sized, +{ + /// Used for specifying relative comparisons. + type Epsilon; + + /// The default tolerance to use when testing values that are close together. + /// + /// This is used when no `epsilon` value is supplied to the `abs_diff_eq!`, `relative_eq!`, or + /// `ulps_eq!` macros. + fn default_epsilon() -> Self::Epsilon; + + /// A test for equality that uses the absolute difference to compute the approximate + /// equality of two numbers. + fn abs_diff_eq(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool; + + /// The inverse of `ApproxEq::abs_diff_eq`. + fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool { + !Self::abs_diff_eq(self, other, epsilon) + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Base implementations +/////////////////////////////////////////////////////////////////////////////////////////////////// + +macro_rules! impl_unsigned_abs_diff_eq { + ($T:ident, $default_epsilon:expr) => { + impl AbsDiffEq for $T { + type Epsilon = $T; + + #[inline] + fn default_epsilon() -> $T { + $default_epsilon + } + + #[inline] + fn abs_diff_eq(&self, other: &$T, epsilon: $T) -> bool { + (if self > other { + self - other + } else { + other - self + }) <= epsilon + } + } + }; +} + +impl_unsigned_abs_diff_eq!(u8, 0); +impl_unsigned_abs_diff_eq!(u16, 0); +impl_unsigned_abs_diff_eq!(u32, 0); +impl_unsigned_abs_diff_eq!(u64, 0); +impl_unsigned_abs_diff_eq!(usize, 0); + +macro_rules! impl_signed_abs_diff_eq { + ($T:ident, $default_epsilon:expr) => { + impl AbsDiffEq for $T { + type Epsilon = $T; + + #[inline] + fn default_epsilon() -> $T { + $default_epsilon + } + + #[inline] + fn abs_diff_eq(&self, other: &$T, epsilon: $T) -> bool { + $T::abs(self - other) <= epsilon + } + } + }; +} + +impl_signed_abs_diff_eq!(i8, 0); +impl_signed_abs_diff_eq!(i16, 0); +impl_signed_abs_diff_eq!(i32, 0); +impl_signed_abs_diff_eq!(i64, 0); +impl_signed_abs_diff_eq!(isize, 0); +impl_signed_abs_diff_eq!(f32, f32::EPSILON); +impl_signed_abs_diff_eq!(f64, f64::EPSILON); + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Derived implementations +/////////////////////////////////////////////////////////////////////////////////////////////////// + +impl<'a, T: AbsDiffEq + ?Sized> AbsDiffEq for &'a T { + type Epsilon = T::Epsilon; + + #[inline] + fn default_epsilon() -> T::Epsilon { + T::default_epsilon() + } + + #[inline] + fn abs_diff_eq(&self, other: &&'a T, epsilon: T::Epsilon) -> bool { + T::abs_diff_eq(*self, *other, epsilon) + } +} + +impl<'a, T: AbsDiffEq + ?Sized> AbsDiffEq for &'a mut T { + type Epsilon = T::Epsilon; + + #[inline] + fn default_epsilon() -> T::Epsilon { + T::default_epsilon() + } + + #[inline] + fn abs_diff_eq(&self, other: &&'a mut T, epsilon: T::Epsilon) -> bool { + T::abs_diff_eq(*self, *other, epsilon) + } +} + +impl AbsDiffEq for cell::Cell { + type Epsilon = T::Epsilon; + + #[inline] + fn default_epsilon() -> T::Epsilon { + T::default_epsilon() + } + + #[inline] + fn abs_diff_eq(&self, other: &cell::Cell, epsilon: T::Epsilon) -> bool { + T::abs_diff_eq(&self.get(), &other.get(), epsilon) + } +} + +impl AbsDiffEq for cell::RefCell { + type Epsilon = T::Epsilon; + + #[inline] + fn default_epsilon() -> T::Epsilon { + T::default_epsilon() + } + + #[inline] + fn abs_diff_eq(&self, other: &cell::RefCell, epsilon: T::Epsilon) -> bool { + T::abs_diff_eq(&self.borrow(), &other.borrow(), epsilon) + } +} + +impl AbsDiffEq<[B]> for [A] +where + A: AbsDiffEq, + A::Epsilon: Clone, +{ + type Epsilon = A::Epsilon; + + #[inline] + fn default_epsilon() -> A::Epsilon { + A::default_epsilon() + } + + #[inline] + fn abs_diff_eq(&self, other: &[B], epsilon: A::Epsilon) -> bool { + self.len() == other.len() + && Iterator::zip(self.iter(), other).all(|(x, y)| A::abs_diff_eq(x, y, epsilon.clone())) + } +} + +#[cfg(feature = "num-complex")] +impl AbsDiffEq for Complex +where + T::Epsilon: Clone, +{ + type Epsilon = T::Epsilon; + + #[inline] + fn default_epsilon() -> T::Epsilon { + T::default_epsilon() + } + + #[inline] + fn abs_diff_eq(&self, other: &Complex, epsilon: T::Epsilon) -> bool { + T::abs_diff_eq(&self.re, &other.re, epsilon.clone()) + && T::abs_diff_eq(&self.im, &other.im, epsilon.clone()) + } +} diff --git a/third_party/cargo/vendor/approx-0.3.2/src/lib.rs b/third_party/cargo/vendor/approx-0.3.2/src/lib.rs new file mode 100644 index 0000000..a857f47 --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/src/lib.rs @@ -0,0 +1,384 @@ +// Copyright 2015 Brendan Zabarauskas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! A crate that provides facilities for testing the approximate equality of floating-point +//! based types, using either relative difference, or units in the last place (ULPs) +//! comparisons. +//! +//! You can also use the `approx_{eq, ne}!` `assert_approx_{eq, ne}!` macros to test for equality +//! using a more positional style. +//! +//! ```rust +//! #[macro_use] +//! extern crate approx; +//! +//! use std::f64; +//! +//! # fn main() { +//! abs_diff_eq!(1.0, 1.0); +//! abs_diff_eq!(1.0, 1.0, epsilon = f64::EPSILON); +//! +//! relative_eq!(1.0, 1.0); +//! relative_eq!(1.0, 1.0, epsilon = f64::EPSILON); +//! relative_eq!(1.0, 1.0, max_relative = 1.0); +//! relative_eq!(1.0, 1.0, epsilon = f64::EPSILON, max_relative = 1.0); +//! relative_eq!(1.0, 1.0, max_relative = 1.0, epsilon = f64::EPSILON); +//! +//! ulps_eq!(1.0, 1.0); +//! ulps_eq!(1.0, 1.0, epsilon = f64::EPSILON); +//! ulps_eq!(1.0, 1.0, max_ulps = 4); +//! ulps_eq!(1.0, 1.0, epsilon = f64::EPSILON, max_ulps = 4); +//! ulps_eq!(1.0, 1.0, max_ulps = 4, epsilon = f64::EPSILON); +//! # } +//! ``` +//! +//! # Implementing approximate equality for custom types +//! +//! The `ApproxEq` trait allows approximate equalities to be implemented on types, based on the +//! fundamental floating point implementations. +//! +//! For example, we might want to be able to do approximate assertions on a complex number type: +//! +//! ```rust +//! #[macro_use] +//! extern crate approx; +//! # use approx::{AbsDiffEq, RelativeEq, UlpsEq}; +//! +//! #[derive(Debug, PartialEq)] +//! struct Complex { +//! x: T, +//! i: T, +//! } +//! # impl AbsDiffEq for Complex where T::Epsilon: Copy { +//! # type Epsilon = T::Epsilon; +//! # fn default_epsilon() -> T::Epsilon { T::default_epsilon() } +//! # fn abs_diff_eq(&self, other: &Self, epsilon: T::Epsilon) -> bool { +//! # T::abs_diff_eq(&self.x, &other.x, epsilon) && +//! # T::abs_diff_eq(&self.i, &other.i, epsilon) +//! # } +//! # } +//! # impl RelativeEq for Complex where T::Epsilon: Copy { +//! # fn default_max_relative() -> T::Epsilon { T::default_max_relative() } +//! # fn relative_eq(&self, other: &Self, epsilon: T::Epsilon, max_relative: T::Epsilon) +//! # -> bool { +//! # T::relative_eq(&self.x, &other.x, epsilon, max_relative) && +//! # T::relative_eq(&self.i, &other.i, epsilon, max_relative) +//! # } +//! # } +//! # impl UlpsEq for Complex where T::Epsilon: Copy { +//! # fn default_max_ulps() -> u32 { T::default_max_ulps() } +//! # fn ulps_eq(&self, other: &Self, epsilon: T::Epsilon, max_ulps: u32) -> bool { +//! # T::ulps_eq(&self.x, &other.x, epsilon, max_ulps) && +//! # T::ulps_eq(&self.i, &other.i, epsilon, max_ulps) +//! # } +//! # } +//! +//! # fn main() { +//! let x = Complex { x: 1.2, i: 2.3 }; +//! +//! assert_relative_eq!(x, x); +//! assert_ulps_eq!(x, x, max_ulps = 4); +//! # } +//! ``` +//! +//! To do this we can implement `AbsDiffEq`, `RelativeEq` and `UlpsEq` generically in terms of a +//! type parameter that also implements `ApproxEq`, `RelativeEq` and `UlpsEq` respectively. This +//! means that we can make comparisons for either `Complex` or `Complex`: +//! +//! ```rust +//! # use approx::{AbsDiffEq, RelativeEq, UlpsEq}; +//! # #[derive(Debug, PartialEq)] +//! # struct Complex { x: T, i: T, } +//! # +//! impl AbsDiffEq for Complex where +//! T::Epsilon: Copy, +//! { +//! type Epsilon = T::Epsilon; +//! +//! fn default_epsilon() -> T::Epsilon { +//! T::default_epsilon() +//! } +//! +//! fn abs_diff_eq(&self, other: &Self, epsilon: T::Epsilon) -> bool { +//! T::abs_diff_eq(&self.x, &other.x, epsilon) && +//! T::abs_diff_eq(&self.i, &other.i, epsilon) +//! } +//! } +//! +//! impl RelativeEq for Complex where +//! T::Epsilon: Copy, +//! { +//! fn default_max_relative() -> T::Epsilon { +//! T::default_max_relative() +//! } +//! +//! fn relative_eq(&self, other: &Self, epsilon: T::Epsilon, max_relative: T::Epsilon) -> bool { +//! T::relative_eq(&self.x, &other.x, epsilon, max_relative) && +//! T::relative_eq(&self.i, &other.i, epsilon, max_relative) +//! } +//! } +//! +//! impl UlpsEq for Complex where +//! T::Epsilon: Copy, +//! { +//! fn default_max_ulps() -> u32 { +//! T::default_max_ulps() +//! } +//! +//! fn ulps_eq(&self, other: &Self, epsilon: T::Epsilon, max_ulps: u32) -> bool { +//! T::ulps_eq(&self.x, &other.x, epsilon, max_ulps) && +//! T::ulps_eq(&self.i, &other.i, epsilon, max_ulps) +//! } +//! } +//! ``` +//! +//! # References +//! +//! Floating point is hard! Thanks goes to these links for helping to make things a _little_ +//! easier to understand: +//! +//! - [Comparing Floating Point Numbers, 2012 Edition] +//! (https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/) +//! - [The Floating Point Guide - Comparison](http://floating-point-gui.de/errors/comparison/) +//! - [What Every Computer Scientist Should Know About Floating-Point Arithmetic] +//! (https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html) + +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(feature = "num-complex")] +extern crate num_complex; +extern crate num_traits; + +#[cfg(not(feature = "std"))] +use core as std; + +mod abs_diff_eq; +mod relative_eq; +mod ulps_eq; + +mod macros; + +pub use abs_diff_eq::AbsDiffEq; +pub use relative_eq::RelativeEq; +pub use ulps_eq::UlpsEq; + +/// The requisite parameters for testing for approximate equality using a +/// absolute difference based comparison. +/// +/// This is not normally used directly, rather via the +/// `assert_abs_diff_{eq|ne}!` and `abs_diff_{eq|ne}!` macros. +/// +/// # Example +/// +/// ```rust +/// use std::f64; +/// use approx::AbsDiff; +/// +/// AbsDiff::default().eq(&1.0, &1.0); +/// AbsDiff::default().epsilon(f64::EPSILON).eq(&1.0, &1.0); +/// ``` +pub struct AbsDiff +where + A: AbsDiffEq + ?Sized, + B: ?Sized, +{ + /// The tolerance to use when testing values that are close together. + pub epsilon: A::Epsilon, +} + +impl Default for AbsDiff +where + A: AbsDiffEq + ?Sized, + B: ?Sized, +{ + #[inline] + fn default() -> AbsDiff { + AbsDiff { + epsilon: A::default_epsilon(), + } + } +} + +impl AbsDiff +where + A: AbsDiffEq + ?Sized, + B: ?Sized, +{ + /// Replace the epsilon value with the one specified. + #[inline] + pub fn epsilon(self, epsilon: A::Epsilon) -> AbsDiff { + AbsDiff { epsilon, ..self } + } + + /// Peform the equality comparison + #[inline] + pub fn eq(self, lhs: &A, rhs: &B) -> bool { + A::abs_diff_eq(lhs, rhs, self.epsilon) + } + + /// Peform the inequality comparison + #[inline] + pub fn ne(self, lhs: &A, rhs: &B) -> bool { + A::abs_diff_ne(lhs, rhs, self.epsilon) + } +} + +/// The requisite parameters for testing for approximate equality using a +/// relative based comparison. +/// +/// This is not normally used directly, rather via the +/// `assert_relative_{eq|ne}!` and `relative_{eq|ne}!` macros. +/// +/// # Example +/// +/// ```rust +/// use std::f64; +/// use approx::Relative; +/// +/// Relative::default().eq(&1.0, &1.0); +/// Relative::default().epsilon(f64::EPSILON).eq(&1.0, &1.0); +/// Relative::default().max_relative(1.0).eq(&1.0, &1.0); +/// Relative::default().epsilon(f64::EPSILON).max_relative(1.0).eq(&1.0, &1.0); +/// Relative::default().max_relative(1.0).epsilon(f64::EPSILON).eq(&1.0, &1.0); +/// ``` +pub struct Relative +where + A: RelativeEq + ?Sized, + B: ?Sized, +{ + /// The tolerance to use when testing values that are close together. + pub epsilon: A::Epsilon, + /// The relative tolerance for testing values that are far-apart. + pub max_relative: A::Epsilon, +} + +impl Default for Relative +where + A: RelativeEq + ?Sized, + B: ?Sized, +{ + #[inline] + fn default() -> Relative { + Relative { + epsilon: A::default_epsilon(), + max_relative: A::default_max_relative(), + } + } +} + +impl Relative +where + A: RelativeEq + ?Sized, + B: ?Sized, +{ + /// Replace the epsilon value with the one specified. + #[inline] + pub fn epsilon(self, epsilon: A::Epsilon) -> Relative { + Relative { epsilon, ..self } + } + + /// Replace the maximum relative value with the one specified. + #[inline] + pub fn max_relative(self, max_relative: A::Epsilon) -> Relative { + Relative { + max_relative, + ..self + } + } + + /// Peform the equality comparison + #[inline] + pub fn eq(self, lhs: &A, rhs: &B) -> bool { + A::relative_eq(lhs, rhs, self.epsilon, self.max_relative) + } + + /// Peform the inequality comparison + #[inline] + pub fn ne(self, lhs: &A, rhs: &B) -> bool { + A::relative_ne(lhs, rhs, self.epsilon, self.max_relative) + } +} + +/// The requisite parameters for testing for approximate equality using an ULPs +/// based comparison. +/// +/// This is not normally used directly, rather via the `assert_ulps_{eq|ne}!` +/// and `ulps_{eq|ne}!` macros. +/// +/// # Example +/// +/// ```rust +/// use std::f64; +/// use approx::Ulps; +/// +/// Ulps::default().eq(&1.0, &1.0); +/// Ulps::default().epsilon(f64::EPSILON).eq(&1.0, &1.0); +/// Ulps::default().max_ulps(4).eq(&1.0, &1.0); +/// Ulps::default().epsilon(f64::EPSILON).max_ulps(4).eq(&1.0, &1.0); +/// Ulps::default().max_ulps(4).epsilon(f64::EPSILON).eq(&1.0, &1.0); +/// ``` +pub struct Ulps +where + A: UlpsEq + ?Sized, + B: ?Sized, +{ + /// The tolerance to use when testing values that are close together. + pub epsilon: A::Epsilon, + /// The ULPs to tolerate when testing values that are far-apart. + pub max_ulps: u32, +} + +impl Default for Ulps +where + A: UlpsEq + ?Sized, + B: ?Sized, +{ + #[inline] + fn default() -> Ulps { + Ulps { + epsilon: A::default_epsilon(), + max_ulps: A::default_max_ulps(), + } + } +} + +impl Ulps +where + A: UlpsEq + ?Sized, + B: ?Sized, +{ + /// Replace the epsilon value with the one specified. + #[inline] + pub fn epsilon(self, epsilon: A::Epsilon) -> Ulps { + Ulps { epsilon, ..self } + } + + /// Replace the max ulps value with the one specified. + #[inline] + pub fn max_ulps(self, max_ulps: u32) -> Ulps { + Ulps { max_ulps, ..self } + } + + /// Peform the equality comparison + #[inline] + pub fn eq(self, lhs: &A, rhs: &B) -> bool { + A::ulps_eq(lhs, rhs, self.epsilon, self.max_ulps) + } + + /// Peform the inequality comparison + #[inline] + pub fn ne(self, lhs: &A, rhs: &B) -> bool { + A::ulps_ne(lhs, rhs, self.epsilon, self.max_ulps) + } +} diff --git a/third_party/cargo/vendor/approx-0.3.2/src/macros.rs b/third_party/cargo/vendor/approx-0.3.2/src/macros.rs new file mode 100644 index 0000000..6462fb2 --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/src/macros.rs @@ -0,0 +1,187 @@ +// Copyright 2015 Brendan Zabarauskas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/// Approximate equality of using the absolute difference. +#[macro_export] +macro_rules! abs_diff_eq { + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*) => { + $crate::AbsDiff::default()$(.$opt($val))*.eq(&$lhs, &$rhs) + }; + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*,) => { + $crate::AbsDiff::default()$(.$opt($val))*.eq(&$lhs, &$rhs) + }; +} + +/// Approximate inequality of using the absolute difference. +#[macro_export] +macro_rules! abs_diff_ne { + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*) => { + $crate::AbsDiff::default()$(.$opt($val))*.ne(&$lhs, &$rhs) + }; + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*,) => { + $crate::AbsDiff::default()$(.$opt($val))*.ne(&$lhs, &$rhs) + }; +} + +/// Approximate equality using both the absolute difference and relative based comparisons. +#[macro_export] +macro_rules! relative_eq { + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*) => { + $crate::Relative::default()$(.$opt($val))*.eq(&$lhs, &$rhs) + }; + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*,) => { + $crate::Relative::default()$(.$opt($val))*.eq(&$lhs, &$rhs) + }; +} + +/// Approximate inequality using both the absolute difference and relative based comparisons. +#[macro_export] +macro_rules! relative_ne { + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*) => { + $crate::Relative::default()$(.$opt($val))*.ne(&$lhs, &$rhs) + }; + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*,) => { + $crate::Relative::default()$(.$opt($val))*.ne(&$lhs, &$rhs) + }; +} + +/// Approximate equality using both the absolute difference and ULPs (Units in Last Place). +#[macro_export] +macro_rules! ulps_eq { + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*) => { + $crate::Ulps::default()$(.$opt($val))*.eq(&$lhs, &$rhs) + }; + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*,) => { + $crate::Ulps::default()$(.$opt($val))*.eq(&$lhs, &$rhs) + }; +} + +/// Approximate inequality using both the absolute difference and ULPs (Units in Last Place). +#[macro_export] +macro_rules! ulps_ne { + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*) => { + $crate::Ulps::default()$(.$opt($val))*.ne(&$lhs, &$rhs) + }; + ($lhs:expr, $rhs:expr $(, $opt:ident = $val:expr)*,) => { + $crate::Ulps::default()$(.$opt($val))*.ne(&$lhs, &$rhs) + }; +} + +#[doc(hidden)] +#[macro_export] +macro_rules! __assert_approx { + ($eq:ident, $given:expr, $expected:expr) => {{ + let (given, expected) = (&($given), &($expected)); + + if !$eq!(*given, *expected) { + panic!( +"assert_{}!({}, {}) + + left = {:?} + right = {:?} + +", + stringify!($eq), + stringify!($given), + stringify!($expected), + given, expected, + ); + } + }}; + ($eq:ident, $given:expr, $expected:expr, $($opt:ident = $val:expr),+) => {{ + let (given, expected) = (&($given), &($expected)); + + if !$eq!(*given, *expected, $($opt = $val),+) { + panic!( +"assert_{}!({}, {}, {}) + + left = {:?} + right = {:?} + +", + stringify!($eq), + stringify!($given), + stringify!($expected), + stringify!($($opt = $val),+), + given, expected, + ); + } + }}; +} + +/// An assertion that delegates to `abs_diff_eq!`, and panics with a helpful error on failure. +#[macro_export(local_inner_macros)] +macro_rules! assert_abs_diff_eq { + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => { + __assert_approx!(abs_diff_eq, $given, $expected $(, $opt = $val)*) + }; + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*,) => { + __assert_approx!(abs_diff_eq, $given, $expected $(, $opt = $val)*) + }; +} + +/// An assertion that delegates to `abs_diff_ne!`, and panics with a helpful error on failure. +#[macro_export(local_inner_macros)] +macro_rules! assert_abs_diff_ne { + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => { + __assert_approx!(abs_diff_ne, $given, $expected $(, $opt = $val)*) + }; + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*,) => { + __assert_approx!(abs_diff_ne, $given, $expected $(, $opt = $val)*) + }; +} + +/// An assertion that delegates to `relative_eq!`, and panics with a helpful error on failure. +#[macro_export(local_inner_macros)] +macro_rules! assert_relative_eq { + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => { + __assert_approx!(relative_eq, $given, $expected $(, $opt = $val)*) + }; + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*,) => { + __assert_approx!(relative_eq, $given, $expected $(, $opt = $val)*) + }; +} + +/// An assertion that delegates to `relative_ne!`, and panics with a helpful error on failure. +#[macro_export(local_inner_macros)] +macro_rules! assert_relative_ne { + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => { + __assert_approx!(relative_ne, $given, $expected $(, $opt = $val)*) + }; + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*,) => { + __assert_approx!(relative_ne, $given, $expected $(, $opt = $val)*) + }; +} + +/// An assertion that delegates to `ulps_eq!`, and panics with a helpful error on failure. +#[macro_export(local_inner_macros)] +macro_rules! assert_ulps_eq { + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => { + __assert_approx!(ulps_eq, $given, $expected $(, $opt = $val)*) + }; + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*,) => { + __assert_approx!(ulps_eq, $given, $expected $(, $opt = $val)*) + }; +} + +/// An assertion that delegates to `ulps_ne!`, and panics with a helpful error on failure. +#[macro_export(local_inner_macros)] +macro_rules! assert_ulps_ne { + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => { + __assert_approx!(ulps_ne, $given, $expected $(, $opt = $val)*) + }; + ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*,) => { + __assert_approx!(ulps_ne, $given, $expected $(, $opt = $val)*) + }; +} diff --git a/third_party/cargo/vendor/approx-0.3.2/src/relative_eq.rs b/third_party/cargo/vendor/approx-0.3.2/src/relative_eq.rs new file mode 100644 index 0000000..5498825 --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/src/relative_eq.rs @@ -0,0 +1,196 @@ +#[cfg(feature = "num-complex")] +use num_complex::Complex; +#[cfg(not(feature = "std"))] +use num_traits::float::FloatCore; +use std::{cell, f32, f64}; + +use AbsDiffEq; + +/// Equality comparisons between two numbers using both the absolute difference and +/// relative based comparisons. +pub trait RelativeEq: AbsDiffEq +where + Rhs: ?Sized, +{ + /// The default relative tolerance for testing values that are far-apart. + /// + /// This is used when no `max_relative` value is supplied to the `relative_eq` macro. + fn default_max_relative() -> Self::Epsilon; + + /// A test for equality that uses a relative comparison if the values are far apart. + fn relative_eq( + &self, + other: &Rhs, + epsilon: Self::Epsilon, + max_relative: Self::Epsilon, + ) -> bool; + + /// The inverse of `ApproxEq::relative_eq`. + fn relative_ne( + &self, + other: &Rhs, + epsilon: Self::Epsilon, + max_relative: Self::Epsilon, + ) -> bool { + !Self::relative_eq(self, other, epsilon, max_relative) + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Base implementations +/////////////////////////////////////////////////////////////////////////////////////////////////// + +// Implementation based on: [Comparing Floating Point Numbers, 2012 Edition] +// (https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/) +macro_rules! impl_relative_eq { + ($T:ident, $U:ident) => { + impl RelativeEq for $T { + #[inline] + fn default_max_relative() -> $T { + $T::EPSILON + } + + #[inline] + fn relative_eq(&self, other: &$T, epsilon: $T, max_relative: $T) -> bool { + // Handle same infinities + if self == other { + return true; + } + + // Handle remaining infinities + if $T::is_infinite(*self) || $T::is_infinite(*other) { + return false; + } + + let abs_diff = $T::abs(self - other); + + // For when the numbers are really close together + if abs_diff <= epsilon { + return true; + } + + let abs_self = $T::abs(*self); + let abs_other = $T::abs(*other); + + let largest = if abs_other > abs_self { + abs_other + } else { + abs_self + }; + + // Use a relative difference comparison + abs_diff <= largest * max_relative + } + } + }; +} + +impl_relative_eq!(f32, i32); +impl_relative_eq!(f64, i64); + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Derived implementations +/////////////////////////////////////////////////////////////////////////////////////////////////// + +impl<'a, T: RelativeEq + ?Sized> RelativeEq for &'a T { + #[inline] + fn default_max_relative() -> T::Epsilon { + T::default_max_relative() + } + + #[inline] + fn relative_eq(&self, other: &&'a T, epsilon: T::Epsilon, max_relative: T::Epsilon) -> bool { + T::relative_eq(*self, *other, epsilon, max_relative) + } +} + +impl<'a, T: RelativeEq + ?Sized> RelativeEq for &'a mut T { + #[inline] + fn default_max_relative() -> T::Epsilon { + T::default_max_relative() + } + + #[inline] + fn relative_eq( + &self, + other: &&'a mut T, + epsilon: T::Epsilon, + max_relative: T::Epsilon, + ) -> bool { + T::relative_eq(*self, *other, epsilon, max_relative) + } +} + +impl RelativeEq for cell::Cell { + #[inline] + fn default_max_relative() -> T::Epsilon { + T::default_max_relative() + } + + #[inline] + fn relative_eq( + &self, + other: &cell::Cell, + epsilon: T::Epsilon, + max_relative: T::Epsilon, + ) -> bool { + T::relative_eq(&self.get(), &other.get(), epsilon, max_relative) + } +} + +impl RelativeEq for cell::RefCell { + #[inline] + fn default_max_relative() -> T::Epsilon { + T::default_max_relative() + } + + #[inline] + fn relative_eq( + &self, + other: &cell::RefCell, + epsilon: T::Epsilon, + max_relative: T::Epsilon, + ) -> bool { + T::relative_eq(&self.borrow(), &other.borrow(), epsilon, max_relative) + } +} + +impl RelativeEq<[B]> for [A] +where + A: RelativeEq, + A::Epsilon: Clone, +{ + #[inline] + fn default_max_relative() -> A::Epsilon { + A::default_max_relative() + } + + #[inline] + fn relative_eq(&self, other: &[B], epsilon: A::Epsilon, max_relative: A::Epsilon) -> bool { + self.len() == other.len() + && Iterator::zip(self.iter(), other) + .all(|(x, y)| A::relative_eq(x, y, epsilon.clone(), max_relative.clone())) + } +} + +#[cfg(feature = "num-complex")] +impl RelativeEq for Complex +where + T::Epsilon: Clone, +{ + #[inline] + fn default_max_relative() -> T::Epsilon { + T::default_max_relative() + } + + #[inline] + fn relative_eq( + &self, + other: &Complex, + epsilon: T::Epsilon, + max_relative: T::Epsilon, + ) -> bool { + T::relative_eq(&self.re, &other.re, epsilon.clone(), max_relative.clone()) + && T::relative_eq(&self.im, &other.im, epsilon.clone(), max_relative.clone()) + } +} diff --git a/third_party/cargo/vendor/approx-0.3.2/src/ulps_eq.rs b/third_party/cargo/vendor/approx-0.3.2/src/ulps_eq.rs new file mode 100644 index 0000000..b177aaa --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/src/ulps_eq.rs @@ -0,0 +1,153 @@ +#[cfg(feature = "num-complex")] +use num_complex::Complex; +#[cfg(not(feature = "std"))] +use num_traits::float::FloatCore; +use std::{cell, mem}; + +use AbsDiffEq; + +/// Equality comparisons between two numbers using both the absolute difference and ULPs +/// (Units in Last Place) based comparisons. +pub trait UlpsEq: AbsDiffEq +where + Rhs: ?Sized, +{ + /// The default ULPs to tolerate when testing values that are far-apart. + /// + /// This is used when no `max_ulps` value is supplied to the `ulps_eq` macro. + fn default_max_ulps() -> u32; + + /// A test for equality that uses units in the last place (ULP) if the values are far apart. + fn ulps_eq(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool; + + /// The inverse of `ApproxEq::ulps_eq`. + fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool { + !Self::ulps_eq(self, other, epsilon, max_ulps) + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Base implementations +/////////////////////////////////////////////////////////////////////////////////////////////////// + +// Implementation based on: [Comparing Floating Point Numbers, 2012 Edition] +// (https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/) +macro_rules! impl_ulps_eq { + ($T:ident, $U:ident) => { + impl UlpsEq for $T { + #[inline] + fn default_max_ulps() -> u32 { + 4 + } + + #[inline] + fn ulps_eq(&self, other: &$T, epsilon: $T, max_ulps: u32) -> bool { + // For when the numbers are really close together + if $T::abs_diff_eq(self, other, epsilon) { + return true; + } + + // Trivial negative sign check + if self.signum() != other.signum() { + return false; + } + + // ULPS difference comparison + let int_self: $U = unsafe { mem::transmute(*self) }; + let int_other: $U = unsafe { mem::transmute(*other) }; + + $U::abs(int_self - int_other) <= max_ulps as $U + } + } + }; +} + +impl_ulps_eq!(f32, i32); +impl_ulps_eq!(f64, i64); + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Derived implementations +/////////////////////////////////////////////////////////////////////////////////////////////////// + +impl<'a, T: UlpsEq + ?Sized> UlpsEq for &'a T { + #[inline] + fn default_max_ulps() -> u32 { + T::default_max_ulps() + } + + #[inline] + fn ulps_eq(&self, other: &&'a T, epsilon: T::Epsilon, max_ulps: u32) -> bool { + T::ulps_eq(*self, *other, epsilon, max_ulps) + } +} + +impl<'a, T: UlpsEq + ?Sized> UlpsEq for &'a mut T { + #[inline] + fn default_max_ulps() -> u32 { + T::default_max_ulps() + } + + #[inline] + fn ulps_eq(&self, other: &&'a mut T, epsilon: T::Epsilon, max_ulps: u32) -> bool { + T::ulps_eq(*self, *other, epsilon, max_ulps) + } +} + +impl UlpsEq for cell::Cell { + #[inline] + fn default_max_ulps() -> u32 { + T::default_max_ulps() + } + + #[inline] + fn ulps_eq(&self, other: &cell::Cell, epsilon: T::Epsilon, max_ulps: u32) -> bool { + T::ulps_eq(&self.get(), &other.get(), epsilon, max_ulps) + } +} + +impl UlpsEq for cell::RefCell { + #[inline] + fn default_max_ulps() -> u32 { + T::default_max_ulps() + } + + #[inline] + fn ulps_eq(&self, other: &cell::RefCell, epsilon: T::Epsilon, max_ulps: u32) -> bool { + T::ulps_eq(&self.borrow(), &other.borrow(), epsilon, max_ulps) + } +} + +impl UlpsEq<[B]> for [A] +where + A: UlpsEq, + A::Epsilon: Clone, +{ + #[inline] + fn default_max_ulps() -> u32 { + A::default_max_ulps() + } + + #[inline] + fn ulps_eq(&self, other: &[B], epsilon: A::Epsilon, max_ulps: u32) -> bool { + self.len() == other.len() + && Iterator::zip(self.iter(), other) + .all(|(x, y)| A::ulps_eq(x, y, epsilon.clone(), max_ulps.clone())) + } +} + +#[cfg(feature = "num-complex")] +impl UlpsEq for Complex +where + T::Epsilon: Clone, +{ + #[inline] + fn default_max_ulps() -> u32 { + T::default_max_ulps() + } + + #[inline] + fn ulps_eq(&self, other: &Complex, epsilon: T::Epsilon, max_ulps: u32) -> bool { + T::ulps_eq(&self.re, &other.re, epsilon.clone(), max_ulps) + && T::ulps_eq(&self.im, &other.im, epsilon.clone(), max_ulps) + } +} diff --git a/third_party/cargo/vendor/approx-0.3.2/tests/abs_diff_eq.rs b/third_party/cargo/vendor/approx-0.3.2/tests/abs_diff_eq.rs new file mode 100644 index 0000000..defe599 --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/tests/abs_diff_eq.rs @@ -0,0 +1,442 @@ +// Copyright 2015 Brendan Zabarauskas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Test cases derived from: +// https://github.com/Pybonacci/puntoflotante.org/blob/master/content/errors/NearlyEqualsTest.java + +#[macro_use] +extern crate approx; + +mod test_f32 { + use std::f32; + + #[test] + fn test_basic() { + assert_abs_diff_eq!(1.0f32, 1.0f32); + assert_abs_diff_ne!(1.0f32, 2.0f32); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_abs_diff_eq!(1.0f32, 2.0f32); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_abs_diff_ne!(1.0f32, 1.0f32); + } + + #[test] + fn test_big() { + assert_abs_diff_eq!(100000000.0f32, 100000001.0f32); + assert_abs_diff_eq!(100000001.0f32, 100000000.0f32); + assert_abs_diff_ne!(10000.0f32, 10001.0f32); + assert_abs_diff_ne!(10001.0f32, 10000.0f32); + } + + #[test] + fn test_big_neg() { + assert_abs_diff_eq!(-100000000.0f32, -100000001.0f32); + assert_abs_diff_eq!(-100000001.0f32, -100000000.0f32); + assert_abs_diff_ne!(-10000.0f32, -10001.0f32); + assert_abs_diff_ne!(-10001.0f32, -10000.0f32); + } + + #[test] + fn test_mid() { + assert_abs_diff_eq!(1.0000001f32, 1.0000002f32); + assert_abs_diff_eq!(1.0000002f32, 1.0000001f32); + assert_abs_diff_ne!(1.000001f32, 1.000002f32); + assert_abs_diff_ne!(1.000002f32, 1.000001f32); + } + + #[test] + fn test_mid_neg() { + assert_abs_diff_eq!(-1.0000001f32, -1.0000002f32); + assert_abs_diff_eq!(-1.0000002f32, -1.0000001f32); + assert_abs_diff_ne!(-1.000001f32, -1.000002f32); + assert_abs_diff_ne!(-1.000002f32, -1.000001f32); + } + + #[test] + fn test_small() { + assert_abs_diff_eq!(0.000010001f32, 0.000010002f32); + assert_abs_diff_eq!(0.000010002f32, 0.000010001f32); + assert_abs_diff_ne!(0.000001002f32, 0.0000001001f32); + assert_abs_diff_ne!(0.000001001f32, 0.0000001002f32); + } + + #[test] + fn test_small_neg() { + assert_abs_diff_eq!(-0.000010001f32, -0.000010002f32); + assert_abs_diff_eq!(-0.000010002f32, -0.000010001f32); + assert_abs_diff_ne!(-0.000001002f32, -0.0000001001f32); + assert_abs_diff_ne!(-0.000001001f32, -0.0000001002f32); + } + + #[test] + fn test_zero() { + assert_abs_diff_eq!(0.0f32, 0.0f32); + assert_abs_diff_eq!(0.0f32, -0.0f32); + assert_abs_diff_eq!(-0.0f32, -0.0f32); + + assert_abs_diff_ne!(0.000001f32, 0.0f32); + assert_abs_diff_ne!(0.0f32, 0.000001f32); + assert_abs_diff_ne!(-0.000001f32, 0.0f32); + assert_abs_diff_ne!(0.0f32, -0.000001f32); + } + + #[test] + fn test_epsilon() { + assert_abs_diff_eq!(0.0f32, 1e-40f32, epsilon = 1e-40f32); + assert_abs_diff_eq!(1e-40f32, 0.0f32, epsilon = 1e-40f32); + assert_abs_diff_eq!(0.0f32, -1e-40f32, epsilon = 1e-40f32); + assert_abs_diff_eq!(-1e-40f32, 0.0f32, epsilon = 1e-40f32); + + assert_abs_diff_ne!(1e-40f32, 0.0f32, epsilon = 1e-41f32); + assert_abs_diff_ne!(0.0f32, 1e-40f32, epsilon = 1e-41f32); + assert_abs_diff_ne!(-1e-40f32, 0.0f32, epsilon = 1e-41f32); + assert_abs_diff_ne!(0.0f32, -1e-40f32, epsilon = 1e-41f32); + } + + #[test] + fn test_max() { + assert_abs_diff_eq!(f32::MAX, f32::MAX); + assert_abs_diff_ne!(f32::MAX, -f32::MAX); + assert_abs_diff_ne!(-f32::MAX, f32::MAX); + assert_abs_diff_ne!(f32::MAX, f32::MAX / 2.0); + assert_abs_diff_ne!(f32::MAX, -f32::MAX / 2.0); + assert_abs_diff_ne!(-f32::MAX, f32::MAX / 2.0); + } + + // NOTE: abs_diff_eq fails as numbers begin to get very large + + // #[test] + // fn test_infinity() { + // assert_abs_diff_eq!(f32::INFINITY, f32::INFINITY); + // assert_abs_diff_eq!(f32::NEG_INFINITY, f32::NEG_INFINITY); + // assert_abs_diff_ne!(f32::NEG_INFINITY, f32::INFINITY); + // assert_abs_diff_eq!(f32::INFINITY, f32::MAX); + // assert_abs_diff_eq!(f32::NEG_INFINITY, -f32::MAX); + // } + + #[test] + fn test_nan() { + assert_abs_diff_ne!(f32::NAN, f32::NAN); + + assert_abs_diff_ne!(f32::NAN, 0.0); + assert_abs_diff_ne!(-0.0, f32::NAN); + assert_abs_diff_ne!(f32::NAN, -0.0); + assert_abs_diff_ne!(0.0, f32::NAN); + + assert_abs_diff_ne!(f32::NAN, f32::INFINITY); + assert_abs_diff_ne!(f32::INFINITY, f32::NAN); + assert_abs_diff_ne!(f32::NAN, f32::NEG_INFINITY); + assert_abs_diff_ne!(f32::NEG_INFINITY, f32::NAN); + + assert_abs_diff_ne!(f32::NAN, f32::MAX); + assert_abs_diff_ne!(f32::MAX, f32::NAN); + assert_abs_diff_ne!(f32::NAN, -f32::MAX); + assert_abs_diff_ne!(-f32::MAX, f32::NAN); + + assert_abs_diff_ne!(f32::NAN, f32::MIN_POSITIVE); + assert_abs_diff_ne!(f32::MIN_POSITIVE, f32::NAN); + assert_abs_diff_ne!(f32::NAN, -f32::MIN_POSITIVE); + assert_abs_diff_ne!(-f32::MIN_POSITIVE, f32::NAN); + } + + #[test] + fn test_opposite_signs() { + assert_abs_diff_ne!(1.000000001f32, -1.0f32); + assert_abs_diff_ne!(-1.0f32, 1.000000001f32); + assert_abs_diff_ne!(-1.000000001f32, 1.0f32); + assert_abs_diff_ne!(1.0f32, -1.000000001f32); + + assert_abs_diff_eq!(10.0 * f32::MIN_POSITIVE, 10.0 * -f32::MIN_POSITIVE); + } + + #[test] + fn test_close_to_zero() { + assert_abs_diff_eq!(f32::MIN_POSITIVE, f32::MIN_POSITIVE); + assert_abs_diff_eq!(f32::MIN_POSITIVE, -f32::MIN_POSITIVE); + assert_abs_diff_eq!(-f32::MIN_POSITIVE, f32::MIN_POSITIVE); + + assert_abs_diff_eq!(f32::MIN_POSITIVE, 0.0f32); + assert_abs_diff_eq!(0.0f32, f32::MIN_POSITIVE); + assert_abs_diff_eq!(-f32::MIN_POSITIVE, 0.0f32); + assert_abs_diff_eq!(0.0f32, -f32::MIN_POSITIVE); + + assert_abs_diff_ne!(0.000001f32, -f32::MIN_POSITIVE); + assert_abs_diff_ne!(0.000001f32, f32::MIN_POSITIVE); + assert_abs_diff_ne!(f32::MIN_POSITIVE, 0.000001f32); + assert_abs_diff_ne!(-f32::MIN_POSITIVE, 0.000001f32); + } +} + +#[cfg(test)] +mod test_f64 { + use std::f64; + + #[test] + fn test_basic() { + assert_abs_diff_eq!(1.0f64, 1.0f64); + assert_abs_diff_ne!(1.0f64, 2.0f64); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_abs_diff_eq!(1.0f64, 2.0f64); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_abs_diff_ne!(1.0f64, 1.0f64); + } + + #[test] + fn test_big() { + assert_abs_diff_eq!(10000000000000000.0f64, 10000000000000001.0f64); + assert_abs_diff_eq!(10000000000000001.0f64, 10000000000000000.0f64); + assert_abs_diff_ne!(1000000000000000.0f64, 1000000000000001.0f64); + assert_abs_diff_ne!(1000000000000001.0f64, 1000000000000000.0f64); + } + + #[test] + fn test_big_neg() { + assert_abs_diff_eq!(-10000000000000000.0f64, -10000000000000001.0f64); + assert_abs_diff_eq!(-10000000000000001.0f64, -10000000000000000.0f64); + assert_abs_diff_ne!(-1000000000000000.0f64, -1000000000000001.0f64); + assert_abs_diff_ne!(-1000000000000001.0f64, -1000000000000000.0f64); + } + + #[test] + fn test_mid() { + assert_abs_diff_eq!(1.0000000000000001f64, 1.0000000000000002f64); + assert_abs_diff_eq!(1.0000000000000002f64, 1.0000000000000001f64); + assert_abs_diff_ne!(1.000000000000001f64, 1.000000000000002f64); + assert_abs_diff_ne!(1.000000000000002f64, 1.000000000000001f64); + } + + #[test] + fn test_mid_neg() { + assert_abs_diff_eq!(-1.0000000000000001f64, -1.0000000000000002f64); + assert_abs_diff_eq!(-1.0000000000000002f64, -1.0000000000000001f64); + assert_abs_diff_ne!(-1.000000000000001f64, -1.000000000000002f64); + assert_abs_diff_ne!(-1.000000000000002f64, -1.000000000000001f64); + } + + #[test] + fn test_small() { + assert_abs_diff_eq!(0.0000000100000001f64, 0.0000000100000002f64); + assert_abs_diff_eq!(0.0000000100000002f64, 0.0000000100000001f64); + assert_abs_diff_ne!(0.0000000100000001f64, 0.0000000010000002f64); + assert_abs_diff_ne!(0.0000000100000002f64, 0.0000000010000001f64); + } + + #[test] + fn test_small_neg() { + assert_abs_diff_eq!(-0.0000000100000001f64, -0.0000000100000002f64); + assert_abs_diff_eq!(-0.0000000100000002f64, -0.0000000100000001f64); + assert_abs_diff_ne!(-0.0000000100000001f64, -0.0000000010000002f64); + assert_abs_diff_ne!(-0.0000000100000002f64, -0.0000000010000001f64); + } + + #[test] + fn test_zero() { + assert_abs_diff_eq!(0.0f64, 0.0f64); + assert_abs_diff_eq!(0.0f64, -0.0f64); + assert_abs_diff_eq!(-0.0f64, -0.0f64); + + assert_abs_diff_ne!(0.000000000000001f64, 0.0f64); + assert_abs_diff_ne!(0.0f64, 0.000000000000001f64); + assert_abs_diff_ne!(-0.000000000000001f64, 0.0f64); + assert_abs_diff_ne!(0.0f64, -0.000000000000001f64); + } + + #[test] + fn test_epsilon() { + assert_abs_diff_eq!(0.0f64, 1e-40f64, epsilon = 1e-40f64); + assert_abs_diff_eq!(1e-40f64, 0.0f64, epsilon = 1e-40f64); + assert_abs_diff_eq!(0.0f64, -1e-40f64, epsilon = 1e-40f64); + assert_abs_diff_eq!(-1e-40f64, 0.0f64, epsilon = 1e-40f64); + + assert_abs_diff_ne!(1e-40f64, 0.0f64, epsilon = 1e-41f64); + assert_abs_diff_ne!(0.0f64, 1e-40f64, epsilon = 1e-41f64); + assert_abs_diff_ne!(-1e-40f64, 0.0f64, epsilon = 1e-41f64); + assert_abs_diff_ne!(0.0f64, -1e-40f64, epsilon = 1e-41f64); + } + + #[test] + fn test_max() { + assert_abs_diff_eq!(f64::MAX, f64::MAX); + assert_abs_diff_ne!(f64::MAX, -f64::MAX); + assert_abs_diff_ne!(-f64::MAX, f64::MAX); + assert_abs_diff_ne!(f64::MAX, f64::MAX / 2.0); + assert_abs_diff_ne!(f64::MAX, -f64::MAX / 2.0); + assert_abs_diff_ne!(-f64::MAX, f64::MAX / 2.0); + } + + // NOTE: abs_diff_eq fails as numbers begin to get very large + + // #[test] + // fn test_infinity() { + // assert_abs_diff_eq!(f64::INFINITY, f64::INFINITY); + // assert_abs_diff_eq!(f64::NEG_INFINITY, f64::NEG_INFINITY); + // assert_abs_diff_ne!(f64::NEG_INFINITY, f64::INFINITY); + // assert_abs_diff_eq!(f64::INFINITY, f64::MAX); + // assert_abs_diff_eq!(f64::NEG_INFINITY, -f64::MAX); + // } + + #[test] + fn test_nan() { + assert_abs_diff_ne!(f64::NAN, f64::NAN); + + assert_abs_diff_ne!(f64::NAN, 0.0); + assert_abs_diff_ne!(-0.0, f64::NAN); + assert_abs_diff_ne!(f64::NAN, -0.0); + assert_abs_diff_ne!(0.0, f64::NAN); + + assert_abs_diff_ne!(f64::NAN, f64::INFINITY); + assert_abs_diff_ne!(f64::INFINITY, f64::NAN); + assert_abs_diff_ne!(f64::NAN, f64::NEG_INFINITY); + assert_abs_diff_ne!(f64::NEG_INFINITY, f64::NAN); + + assert_abs_diff_ne!(f64::NAN, f64::MAX); + assert_abs_diff_ne!(f64::MAX, f64::NAN); + assert_abs_diff_ne!(f64::NAN, -f64::MAX); + assert_abs_diff_ne!(-f64::MAX, f64::NAN); + + assert_abs_diff_ne!(f64::NAN, f64::MIN_POSITIVE); + assert_abs_diff_ne!(f64::MIN_POSITIVE, f64::NAN); + assert_abs_diff_ne!(f64::NAN, -f64::MIN_POSITIVE); + assert_abs_diff_ne!(-f64::MIN_POSITIVE, f64::NAN); + } + + #[test] + fn test_opposite_signs() { + assert_abs_diff_ne!(1.000000001f64, -1.0f64); + assert_abs_diff_ne!(-1.0f64, 1.000000001f64); + assert_abs_diff_ne!(-1.000000001f64, 1.0f64); + assert_abs_diff_ne!(1.0f64, -1.000000001f64); + + assert_abs_diff_eq!(10.0 * f64::MIN_POSITIVE, 10.0 * -f64::MIN_POSITIVE); + } + + #[test] + fn test_close_to_zero() { + assert_abs_diff_eq!(f64::MIN_POSITIVE, f64::MIN_POSITIVE); + assert_abs_diff_eq!(f64::MIN_POSITIVE, -f64::MIN_POSITIVE); + assert_abs_diff_eq!(-f64::MIN_POSITIVE, f64::MIN_POSITIVE); + + assert_abs_diff_eq!(f64::MIN_POSITIVE, 0.0f64); + assert_abs_diff_eq!(0.0f64, f64::MIN_POSITIVE); + assert_abs_diff_eq!(-f64::MIN_POSITIVE, 0.0f64); + assert_abs_diff_eq!(0.0f64, -f64::MIN_POSITIVE); + + assert_abs_diff_ne!(0.000000000000001f64, -f64::MIN_POSITIVE); + assert_abs_diff_ne!(0.000000000000001f64, f64::MIN_POSITIVE); + assert_abs_diff_ne!(f64::MIN_POSITIVE, 0.000000000000001f64); + assert_abs_diff_ne!(-f64::MIN_POSITIVE, 0.000000000000001f64); + } +} + +mod test_ref { + mod test_f32 { + #[test] + fn test_basic() { + assert_abs_diff_eq!(&1.0f32, &1.0f32); + assert_abs_diff_ne!(&1.0f32, &2.0f32); + } + } + + mod test_f64 { + #[test] + fn test_basic() { + assert_abs_diff_eq!(&1.0f64, &1.0f64); + assert_abs_diff_ne!(&1.0f64, &2.0f64); + } + } +} + +mod test_slice { + mod test_f32 { + #[test] + fn test_basic() { + assert_abs_diff_eq!([1.0f32, 2.0f32][..], [1.0f32, 2.0f32][..]); + assert_abs_diff_ne!([1.0f32, 2.0f32][..], [2.0f32, 1.0f32][..]); + } + } + + mod test_f64 { + #[test] + fn test_basic() { + assert_abs_diff_eq!([1.0f64, 2.0f64][..], [1.0f64, 2.0f64][..]); + assert_abs_diff_ne!([1.0f64, 2.0f64][..], [2.0f64, 1.0f64][..]); + } + } +} + +#[cfg(feature = "num-complex")] +mod test_complex { + extern crate num_complex; + pub use self::num_complex::Complex; + + mod test_f32 { + use super::Complex; + + #[test] + fn test_basic() { + assert_abs_diff_eq!(Complex::new(1.0f32, 2.0f32), Complex::new(1.0f32, 2.0f32)); + assert_abs_diff_ne!(Complex::new(1.0f32, 2.0f32), Complex::new(2.0f32, 1.0f32)); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_abs_diff_eq!(Complex::new(1.0f32, 2.0f32), Complex::new(2.0f32, 1.0f32)); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_abs_diff_ne!(Complex::new(1.0f32, 2.0f32), Complex::new(1.0f32, 2.0f32)); + } + } + + mod test_f64 { + use super::Complex; + + #[test] + fn test_basic() { + assert_abs_diff_eq!(Complex::new(1.0f64, 2.0f64), Complex::new(1.0f64, 2.0f64)); + assert_abs_diff_ne!(Complex::new(1.0f64, 2.0f64), Complex::new(2.0f64, 1.0f64)); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_abs_diff_eq!(Complex::new(1.0f64, 2.0f64), Complex::new(2.0f64, 1.0f64)); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_abs_diff_ne!(Complex::new(1.0f64, 2.0f64), Complex::new(1.0f64, 2.0f64)); + } + } +} diff --git a/third_party/cargo/vendor/approx-0.3.2/tests/macro_import.rs b/third_party/cargo/vendor/approx-0.3.2/tests/macro_import.rs new file mode 100644 index 0000000..02b949d --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/tests/macro_import.rs @@ -0,0 +1,18 @@ +extern crate approx; + +mod test_macro_import { + use approx::{ + assert_abs_diff_eq, assert_abs_diff_ne, assert_relative_eq, assert_relative_ne, + assert_ulps_eq, assert_ulps_ne, + }; + + #[test] + fn test() { + assert_abs_diff_eq!(1.0f32, 1.0f32); + assert_abs_diff_ne!(1.0f32, 2.0f32); + assert_relative_eq!(1.0f32, 1.0f32); + assert_relative_ne!(1.0f32, 2.0f32); + assert_ulps_eq!(1.0f32, 1.0f32); + assert_ulps_ne!(1.0f32, 2.0f32); + } +} diff --git a/third_party/cargo/vendor/approx-0.3.2/tests/macros.rs b/third_party/cargo/vendor/approx-0.3.2/tests/macros.rs new file mode 100644 index 0000000..865da16 --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/tests/macros.rs @@ -0,0 +1,98 @@ +// Copyright 2015 Brendan Zabarauskas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Macro instantiation tests + +#[macro_use] +extern crate approx; + +#[test] +fn test_abs_diff_eq() { + let _: bool = abs_diff_eq!(1.0, 1.0); + let _: bool = abs_diff_eq!(1.0, 1.0, epsilon = 1.0); +} + +#[test] +fn test_abs_diff_eq_trailing_commas() { + let _: bool = abs_diff_eq!(1.0, 1.0,); + let _: bool = abs_diff_eq!(1.0, 1.0, epsilon = 1.0,); +} + +#[test] +fn test_abs_diff_ne() { + let _: bool = abs_diff_ne!(1.0, 1.0); + let _: bool = abs_diff_ne!(1.0, 1.0, epsilon = 1.0); +} + +#[test] +fn test_abs_diff_ne_trailing_commas() { + let _: bool = abs_diff_ne!(1.0, 1.0,); + let _: bool = abs_diff_ne!(1.0, 1.0, epsilon = 1.0,); +} + +#[test] +fn test_relative_eq() { + let _: bool = relative_eq!(1.0, 1.0); + let _: bool = relative_eq!(1.0, 1.0, epsilon = 1.0); + let _: bool = relative_eq!(1.0, 1.0, max_relative = 1.0); + let _: bool = relative_eq!(1.0, 1.0, epsilon = 1.0, max_relative = 1.0); +} + +#[test] +fn test_relative_eq_trailing_commas() { + let _: bool = relative_eq!(1.0, 1.0,); + let _: bool = relative_eq!(1.0, 1.0, epsilon = 1.0, max_relative = 1.0,); +} + +#[test] +fn test_relative_ne() { + let _: bool = relative_ne!(1.0, 1.0); + let _: bool = relative_ne!(1.0, 1.0, epsilon = 1.0); + let _: bool = relative_ne!(1.0, 1.0, max_relative = 1.0); + let _: bool = relative_ne!(1.0, 1.0, epsilon = 1.0, max_relative = 1.0); +} + +#[test] +fn test_relative_ne_trailing_commas() { + let _: bool = relative_ne!(1.0, 1.0,); + let _: bool = relative_ne!(1.0, 1.0, epsilon = 1.0, max_relative = 1.0,); +} + +#[test] +fn test_ulps_eq() { + let _: bool = ulps_eq!(1.0, 1.0); + let _: bool = ulps_eq!(1.0, 1.0, epsilon = 1.0); + let _: bool = ulps_eq!(1.0, 1.0, max_ulps = 1); + let _: bool = ulps_eq!(1.0, 1.0, epsilon = 1.0, max_ulps = 1); +} + +#[test] +fn test_ulps_eq_trailing_commas() { + let _: bool = ulps_eq!(1.0, 1.0,); + let _: bool = ulps_eq!(1.0, 1.0, epsilon = 1.0, max_ulps = 1,); +} + +#[test] +fn test_ulps_ne() { + let _: bool = ulps_ne!(1.0, 1.0); + let _: bool = ulps_ne!(1.0, 1.0, epsilon = 1.0); + let _: bool = ulps_ne!(1.0, 1.0, max_ulps = 1); + let _: bool = ulps_ne!(1.0, 1.0, epsilon = 1.0, max_ulps = 1); +} + +#[test] +fn test_ulps_ne_trailing_commas() { + let _: bool = ulps_ne!(1.0, 1.0,); + let _: bool = ulps_ne!(1.0, 1.0, epsilon = 1.0, max_ulps = 1,); +} diff --git a/third_party/cargo/vendor/approx-0.3.2/tests/relative_eq.rs b/third_party/cargo/vendor/approx-0.3.2/tests/relative_eq.rs new file mode 100644 index 0000000..c44c19c --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/tests/relative_eq.rs @@ -0,0 +1,440 @@ +// Copyright 2015 Brendan Zabarauskas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Test cases derived from: +// https://github.com/Pybonacci/puntoflotante.org/blob/master/content/errors/NearlyEqualsTest.java + +#[macro_use] +extern crate approx; + +mod test_f32 { + use std::f32; + + #[test] + fn test_basic() { + assert_relative_eq!(1.0f32, 1.0f32); + assert_relative_ne!(1.0f32, 2.0f32); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_relative_eq!(1.0f32, 2.0f32); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_relative_ne!(1.0f32, 1.0f32); + } + + #[test] + fn test_big() { + assert_relative_eq!(100000000.0f32, 100000001.0f32); + assert_relative_eq!(100000001.0f32, 100000000.0f32); + assert_relative_ne!(10000.0f32, 10001.0f32); + assert_relative_ne!(10001.0f32, 10000.0f32); + } + + #[test] + fn test_big_neg() { + assert_relative_eq!(-100000000.0f32, -100000001.0f32); + assert_relative_eq!(-100000001.0f32, -100000000.0f32); + assert_relative_ne!(-10000.0f32, -10001.0f32); + assert_relative_ne!(-10001.0f32, -10000.0f32); + } + + #[test] + fn test_mid() { + assert_relative_eq!(1.0000001f32, 1.0000002f32); + assert_relative_eq!(1.0000002f32, 1.0000001f32); + assert_relative_ne!(1.000001f32, 1.000002f32); + assert_relative_ne!(1.000002f32, 1.000001f32); + } + + #[test] + fn test_mid_neg() { + assert_relative_eq!(-1.0000001f32, -1.0000002f32); + assert_relative_eq!(-1.0000002f32, -1.0000001f32); + assert_relative_ne!(-1.000001f32, -1.000002f32); + assert_relative_ne!(-1.000002f32, -1.000001f32); + } + + #[test] + fn test_small() { + assert_relative_eq!(0.000010001f32, 0.000010002f32); + assert_relative_eq!(0.000010002f32, 0.000010001f32); + assert_relative_ne!(0.000001002f32, 0.0000001001f32); + assert_relative_ne!(0.000001001f32, 0.0000001002f32); + } + + #[test] + fn test_small_neg() { + assert_relative_eq!(-0.000010001f32, -0.000010002f32); + assert_relative_eq!(-0.000010002f32, -0.000010001f32); + assert_relative_ne!(-0.000001002f32, -0.0000001001f32); + assert_relative_ne!(-0.000001001f32, -0.0000001002f32); + } + + #[test] + fn test_zero() { + assert_relative_eq!(0.0f32, 0.0f32); + assert_relative_eq!(0.0f32, -0.0f32); + assert_relative_eq!(-0.0f32, -0.0f32); + + assert_relative_ne!(0.000001f32, 0.0f32); + assert_relative_ne!(0.0f32, 0.000001f32); + assert_relative_ne!(-0.000001f32, 0.0f32); + assert_relative_ne!(0.0f32, -0.000001f32); + } + + #[test] + fn test_epsilon() { + assert_relative_eq!(0.0f32, 1e-40f32, epsilon = 1e-40f32); + assert_relative_eq!(1e-40f32, 0.0f32, epsilon = 1e-40f32); + assert_relative_eq!(0.0f32, -1e-40f32, epsilon = 1e-40f32); + assert_relative_eq!(-1e-40f32, 0.0f32, epsilon = 1e-40f32); + + assert_relative_ne!(1e-40f32, 0.0f32, epsilon = 1e-41f32); + assert_relative_ne!(0.0f32, 1e-40f32, epsilon = 1e-41f32); + assert_relative_ne!(-1e-40f32, 0.0f32, epsilon = 1e-41f32); + assert_relative_ne!(0.0f32, -1e-40f32, epsilon = 1e-41f32); + } + + #[test] + fn test_max() { + assert_relative_eq!(f32::MAX, f32::MAX); + assert_relative_ne!(f32::MAX, -f32::MAX); + assert_relative_ne!(-f32::MAX, f32::MAX); + assert_relative_ne!(f32::MAX, f32::MAX / 2.0); + assert_relative_ne!(f32::MAX, -f32::MAX / 2.0); + assert_relative_ne!(-f32::MAX, f32::MAX / 2.0); + } + + #[test] + fn test_infinity() { + assert_relative_eq!(f32::INFINITY, f32::INFINITY); + assert_relative_eq!(f32::NEG_INFINITY, f32::NEG_INFINITY); + assert_relative_ne!(f32::NEG_INFINITY, f32::INFINITY); + } + + #[test] + fn test_zero_infinity() { + assert_relative_ne!(0f32, f32::INFINITY); + assert_relative_ne!(0f32, f32::NEG_INFINITY); + } + + #[test] + fn test_nan() { + assert_relative_ne!(f32::NAN, f32::NAN); + + assert_relative_ne!(f32::NAN, 0.0); + assert_relative_ne!(-0.0, f32::NAN); + assert_relative_ne!(f32::NAN, -0.0); + assert_relative_ne!(0.0, f32::NAN); + + assert_relative_ne!(f32::NAN, f32::INFINITY); + assert_relative_ne!(f32::INFINITY, f32::NAN); + assert_relative_ne!(f32::NAN, f32::NEG_INFINITY); + assert_relative_ne!(f32::NEG_INFINITY, f32::NAN); + + assert_relative_ne!(f32::NAN, f32::MAX); + assert_relative_ne!(f32::MAX, f32::NAN); + assert_relative_ne!(f32::NAN, -f32::MAX); + assert_relative_ne!(-f32::MAX, f32::NAN); + + assert_relative_ne!(f32::NAN, f32::MIN_POSITIVE); + assert_relative_ne!(f32::MIN_POSITIVE, f32::NAN); + assert_relative_ne!(f32::NAN, -f32::MIN_POSITIVE); + assert_relative_ne!(-f32::MIN_POSITIVE, f32::NAN); + } + + #[test] + fn test_opposite_signs() { + assert_relative_ne!(1.000000001f32, -1.0f32); + assert_relative_ne!(-1.0f32, 1.000000001f32); + assert_relative_ne!(-1.000000001f32, 1.0f32); + assert_relative_ne!(1.0f32, -1.000000001f32); + + assert_relative_eq!(10.0 * f32::MIN_POSITIVE, 10.0 * -f32::MIN_POSITIVE); + } + + #[test] + fn test_close_to_zero() { + assert_relative_eq!(f32::MIN_POSITIVE, f32::MIN_POSITIVE); + assert_relative_eq!(f32::MIN_POSITIVE, -f32::MIN_POSITIVE); + assert_relative_eq!(-f32::MIN_POSITIVE, f32::MIN_POSITIVE); + + assert_relative_eq!(f32::MIN_POSITIVE, 0.0f32); + assert_relative_eq!(0.0f32, f32::MIN_POSITIVE); + assert_relative_eq!(-f32::MIN_POSITIVE, 0.0f32); + assert_relative_eq!(0.0f32, -f32::MIN_POSITIVE); + + assert_relative_ne!(0.000001f32, -f32::MIN_POSITIVE); + assert_relative_ne!(0.000001f32, f32::MIN_POSITIVE); + assert_relative_ne!(f32::MIN_POSITIVE, 0.000001f32); + assert_relative_ne!(-f32::MIN_POSITIVE, 0.000001f32); + } +} + +#[cfg(test)] +mod test_f64 { + use std::f64; + + #[test] + fn test_basic() { + assert_relative_eq!(1.0f64, 1.0f64); + assert_relative_ne!(1.0f64, 2.0f64); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_relative_eq!(1.0f64, 2.0f64); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_relative_ne!(1.0f64, 1.0f64); + } + + #[test] + fn test_big() { + assert_relative_eq!(10000000000000000.0f64, 10000000000000001.0f64); + assert_relative_eq!(10000000000000001.0f64, 10000000000000000.0f64); + assert_relative_ne!(1000000000000000.0f64, 1000000000000001.0f64); + assert_relative_ne!(1000000000000001.0f64, 1000000000000000.0f64); + } + + #[test] + fn test_big_neg() { + assert_relative_eq!(-10000000000000000.0f64, -10000000000000001.0f64); + assert_relative_eq!(-10000000000000001.0f64, -10000000000000000.0f64); + assert_relative_ne!(-1000000000000000.0f64, -1000000000000001.0f64); + assert_relative_ne!(-1000000000000001.0f64, -1000000000000000.0f64); + } + + #[test] + fn test_mid() { + assert_relative_eq!(1.0000000000000001f64, 1.0000000000000002f64); + assert_relative_eq!(1.0000000000000002f64, 1.0000000000000001f64); + assert_relative_ne!(1.000000000000001f64, 1.000000000000002f64); + assert_relative_ne!(1.000000000000002f64, 1.000000000000001f64); + } + + #[test] + fn test_mid_neg() { + assert_relative_eq!(-1.0000000000000001f64, -1.0000000000000002f64); + assert_relative_eq!(-1.0000000000000002f64, -1.0000000000000001f64); + assert_relative_ne!(-1.000000000000001f64, -1.000000000000002f64); + assert_relative_ne!(-1.000000000000002f64, -1.000000000000001f64); + } + + #[test] + fn test_small() { + assert_relative_eq!(0.0000000100000001f64, 0.0000000100000002f64); + assert_relative_eq!(0.0000000100000002f64, 0.0000000100000001f64); + assert_relative_ne!(0.0000000100000001f64, 0.0000000010000002f64); + assert_relative_ne!(0.0000000100000002f64, 0.0000000010000001f64); + } + + #[test] + fn test_small_neg() { + assert_relative_eq!(-0.0000000100000001f64, -0.0000000100000002f64); + assert_relative_eq!(-0.0000000100000002f64, -0.0000000100000001f64); + assert_relative_ne!(-0.0000000100000001f64, -0.0000000010000002f64); + assert_relative_ne!(-0.0000000100000002f64, -0.0000000010000001f64); + } + + #[test] + fn test_zero() { + assert_relative_eq!(0.0f64, 0.0f64); + assert_relative_eq!(0.0f64, -0.0f64); + assert_relative_eq!(-0.0f64, -0.0f64); + + assert_relative_ne!(0.000000000000001f64, 0.0f64); + assert_relative_ne!(0.0f64, 0.000000000000001f64); + assert_relative_ne!(-0.000000000000001f64, 0.0f64); + assert_relative_ne!(0.0f64, -0.000000000000001f64); + } + + #[test] + fn test_epsilon() { + assert_relative_eq!(0.0f64, 1e-40f64, epsilon = 1e-40f64); + assert_relative_eq!(1e-40f64, 0.0f64, epsilon = 1e-40f64); + assert_relative_eq!(0.0f64, -1e-40f64, epsilon = 1e-40f64); + assert_relative_eq!(-1e-40f64, 0.0f64, epsilon = 1e-40f64); + + assert_relative_ne!(1e-40f64, 0.0f64, epsilon = 1e-41f64); + assert_relative_ne!(0.0f64, 1e-40f64, epsilon = 1e-41f64); + assert_relative_ne!(-1e-40f64, 0.0f64, epsilon = 1e-41f64); + assert_relative_ne!(0.0f64, -1e-40f64, epsilon = 1e-41f64); + } + + #[test] + fn test_max() { + assert_relative_eq!(f64::MAX, f64::MAX); + assert_relative_ne!(f64::MAX, -f64::MAX); + assert_relative_ne!(-f64::MAX, f64::MAX); + assert_relative_ne!(f64::MAX, f64::MAX / 2.0); + assert_relative_ne!(f64::MAX, -f64::MAX / 2.0); + assert_relative_ne!(-f64::MAX, f64::MAX / 2.0); + } + + #[test] + fn test_infinity() { + assert_relative_eq!(f64::INFINITY, f64::INFINITY); + assert_relative_eq!(f64::NEG_INFINITY, f64::NEG_INFINITY); + assert_relative_ne!(f64::NEG_INFINITY, f64::INFINITY); + } + + #[test] + fn test_nan() { + assert_relative_ne!(f64::NAN, f64::NAN); + + assert_relative_ne!(f64::NAN, 0.0); + assert_relative_ne!(-0.0, f64::NAN); + assert_relative_ne!(f64::NAN, -0.0); + assert_relative_ne!(0.0, f64::NAN); + + assert_relative_ne!(f64::NAN, f64::INFINITY); + assert_relative_ne!(f64::INFINITY, f64::NAN); + assert_relative_ne!(f64::NAN, f64::NEG_INFINITY); + assert_relative_ne!(f64::NEG_INFINITY, f64::NAN); + + assert_relative_ne!(f64::NAN, f64::MAX); + assert_relative_ne!(f64::MAX, f64::NAN); + assert_relative_ne!(f64::NAN, -f64::MAX); + assert_relative_ne!(-f64::MAX, f64::NAN); + + assert_relative_ne!(f64::NAN, f64::MIN_POSITIVE); + assert_relative_ne!(f64::MIN_POSITIVE, f64::NAN); + assert_relative_ne!(f64::NAN, -f64::MIN_POSITIVE); + assert_relative_ne!(-f64::MIN_POSITIVE, f64::NAN); + } + + #[test] + fn test_opposite_signs() { + assert_relative_ne!(1.000000001f64, -1.0f64); + assert_relative_ne!(-1.0f64, 1.000000001f64); + assert_relative_ne!(-1.000000001f64, 1.0f64); + assert_relative_ne!(1.0f64, -1.000000001f64); + + assert_relative_eq!(10.0 * f64::MIN_POSITIVE, 10.0 * -f64::MIN_POSITIVE); + } + + #[test] + fn test_close_to_zero() { + assert_relative_eq!(f64::MIN_POSITIVE, f64::MIN_POSITIVE); + assert_relative_eq!(f64::MIN_POSITIVE, -f64::MIN_POSITIVE); + assert_relative_eq!(-f64::MIN_POSITIVE, f64::MIN_POSITIVE); + + assert_relative_eq!(f64::MIN_POSITIVE, 0.0f64); + assert_relative_eq!(0.0f64, f64::MIN_POSITIVE); + assert_relative_eq!(-f64::MIN_POSITIVE, 0.0f64); + assert_relative_eq!(0.0f64, -f64::MIN_POSITIVE); + + assert_relative_ne!(0.000000000000001f64, -f64::MIN_POSITIVE); + assert_relative_ne!(0.000000000000001f64, f64::MIN_POSITIVE); + assert_relative_ne!(f64::MIN_POSITIVE, 0.000000000000001f64); + assert_relative_ne!(-f64::MIN_POSITIVE, 0.000000000000001f64); + } +} + +mod test_ref { + mod test_f32 { + #[test] + fn test_basic() { + assert_relative_eq!(&1.0f32, &1.0f32); + assert_relative_ne!(&1.0f32, &2.0f32); + } + } + + mod test_f64 { + #[test] + fn test_basic() { + assert_relative_eq!(&1.0f64, &1.0f64); + assert_relative_ne!(&1.0f64, &2.0f64); + } + } +} + +mod test_slice { + mod test_f32 { + #[test] + fn test_basic() { + assert_relative_eq!([1.0f32, 2.0f32][..], [1.0f32, 2.0f32][..]); + assert_relative_ne!([1.0f32, 2.0f32][..], [2.0f32, 1.0f32][..]); + } + } + + mod test_f64 { + #[test] + fn test_basic() { + assert_relative_eq!([1.0f64, 2.0f64][..], [1.0f64, 2.0f64][..]); + assert_relative_ne!([1.0f64, 2.0f64][..], [2.0f64, 1.0f64][..]); + } + } +} + +#[cfg(feature = "num-complex")] +mod test_complex { + extern crate num_complex; + pub use self::num_complex::Complex; + + mod test_f32 { + use super::Complex; + + #[test] + fn test_basic() { + assert_relative_eq!(Complex::new(1.0f32, 2.0f32), Complex::new(1.0f32, 2.0f32)); + assert_relative_ne!(Complex::new(1.0f32, 2.0f32), Complex::new(2.0f32, 1.0f32)); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_relative_eq!(Complex::new(1.0f32, 2.0f32), Complex::new(2.0f32, 1.0f32)); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_relative_ne!(Complex::new(1.0f32, 2.0f32), Complex::new(1.0f32, 2.0f32)); + } + } + + mod test_f64 { + use super::Complex; + + #[test] + fn test_basic() { + assert_relative_eq!(Complex::new(1.0f64, 2.0f64), Complex::new(1.0f64, 2.0f64)); + assert_relative_ne!(Complex::new(1.0f64, 2.0f64), Complex::new(2.0f64, 1.0f64)); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_relative_eq!(Complex::new(1.0f64, 2.0f64), Complex::new(2.0f64, 1.0f64)); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_relative_ne!(Complex::new(1.0f64, 2.0f64), Complex::new(1.0f64, 2.0f64)); + } + } +} diff --git a/third_party/cargo/vendor/approx-0.3.2/tests/ulps_eq.rs b/third_party/cargo/vendor/approx-0.3.2/tests/ulps_eq.rs new file mode 100644 index 0000000..31c92af --- /dev/null +++ b/third_party/cargo/vendor/approx-0.3.2/tests/ulps_eq.rs @@ -0,0 +1,438 @@ +// Copyright 2015 Brendan Zabarauskas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Test cases derived from: +// https://github.com/Pybonacci/puntoflotante.org/blob/master/content/errors/NearlyEqualsTest.java + +#[macro_use] +extern crate approx; + +mod test_f32 { + use std::f32; + + #[test] + fn test_basic() { + assert_ulps_eq!(1.0f32, 1.0f32); + assert_ulps_ne!(1.0f32, 2.0f32); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_ulps_eq!(1.0f32, 2.0f32); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_ulps_ne!(1.0f32, 1.0f32); + } + + #[test] + fn test_big() { + assert_ulps_eq!(100000000.0f32, 100000001.0f32); + assert_ulps_eq!(100000001.0f32, 100000000.0f32); + assert_ulps_ne!(10000.0f32, 10001.0f32); + assert_ulps_ne!(10001.0f32, 10000.0f32); + } + + #[test] + fn test_big_neg() { + assert_ulps_eq!(-100000000.0f32, -100000001.0f32); + assert_ulps_eq!(-100000001.0f32, -100000000.0f32); + assert_ulps_ne!(-10000.0f32, -10001.0f32); + assert_ulps_ne!(-10001.0f32, -10000.0f32); + } + + #[test] + fn test_mid() { + assert_ulps_eq!(1.0000001f32, 1.0000002f32); + assert_ulps_eq!(1.0000002f32, 1.0000001f32); + assert_ulps_ne!(1.000001f32, 1.000002f32); + assert_ulps_ne!(1.000002f32, 1.000001f32); + } + + #[test] + fn test_mid_neg() { + assert_ulps_eq!(-1.0000001f32, -1.0000002f32); + assert_ulps_eq!(-1.0000002f32, -1.0000001f32); + assert_ulps_ne!(-1.000001f32, -1.000002f32); + assert_ulps_ne!(-1.000002f32, -1.000001f32); + } + + #[test] + fn test_small() { + assert_ulps_eq!(0.000010001f32, 0.000010002f32); + assert_ulps_eq!(0.000010002f32, 0.000010001f32); + assert_ulps_ne!(0.000001002f32, 0.0000001001f32); + assert_ulps_ne!(0.000001001f32, 0.0000001002f32); + } + + #[test] + fn test_small_neg() { + assert_ulps_eq!(-0.000010001f32, -0.000010002f32); + assert_ulps_eq!(-0.000010002f32, -0.000010001f32); + assert_ulps_ne!(-0.000001002f32, -0.0000001001f32); + assert_ulps_ne!(-0.000001001f32, -0.0000001002f32); + } + + #[test] + fn test_zero() { + assert_ulps_eq!(0.0f32, 0.0f32); + assert_ulps_eq!(0.0f32, -0.0f32); + assert_ulps_eq!(-0.0f32, -0.0f32); + + assert_ulps_ne!(0.000001f32, 0.0f32); + assert_ulps_ne!(0.0f32, 0.000001f32); + assert_ulps_ne!(-0.000001f32, 0.0f32); + assert_ulps_ne!(0.0f32, -0.000001f32); + } + + #[test] + fn test_epsilon() { + assert_ulps_eq!(0.0f32, 1e-40f32, epsilon = 1e-40f32); + assert_ulps_eq!(1e-40f32, 0.0f32, epsilon = 1e-40f32); + assert_ulps_eq!(0.0f32, -1e-40f32, epsilon = 1e-40f32); + assert_ulps_eq!(-1e-40f32, 0.0f32, epsilon = 1e-40f32); + + assert_ulps_ne!(1e-40f32, 0.0f32, epsilon = 1e-41f32); + assert_ulps_ne!(0.0f32, 1e-40f32, epsilon = 1e-41f32); + assert_ulps_ne!(-1e-40f32, 0.0f32, epsilon = 1e-41f32); + assert_ulps_ne!(0.0f32, -1e-40f32, epsilon = 1e-41f32); + } + + #[test] + fn test_max() { + assert_ulps_eq!(f32::MAX, f32::MAX); + assert_ulps_ne!(f32::MAX, -f32::MAX); + assert_ulps_ne!(-f32::MAX, f32::MAX); + assert_ulps_ne!(f32::MAX, f32::MAX / 2.0); + assert_ulps_ne!(f32::MAX, -f32::MAX / 2.0); + assert_ulps_ne!(-f32::MAX, f32::MAX / 2.0); + } + + #[test] + fn test_infinity() { + assert_ulps_eq!(f32::INFINITY, f32::INFINITY); + assert_ulps_eq!(f32::NEG_INFINITY, f32::NEG_INFINITY); + assert_ulps_ne!(f32::NEG_INFINITY, f32::INFINITY); + assert_ulps_eq!(f32::INFINITY, f32::MAX); + assert_ulps_eq!(f32::NEG_INFINITY, -f32::MAX); + } + + #[test] + fn test_nan() { + assert_ulps_ne!(f32::NAN, f32::NAN); + + assert_ulps_ne!(f32::NAN, 0.0); + assert_ulps_ne!(-0.0, f32::NAN); + assert_ulps_ne!(f32::NAN, -0.0); + assert_ulps_ne!(0.0, f32::NAN); + + assert_ulps_ne!(f32::NAN, f32::INFINITY); + assert_ulps_ne!(f32::INFINITY, f32::NAN); + assert_ulps_ne!(f32::NAN, f32::NEG_INFINITY); + assert_ulps_ne!(f32::NEG_INFINITY, f32::NAN); + + assert_ulps_ne!(f32::NAN, f32::MAX); + assert_ulps_ne!(f32::MAX, f32::NAN); + assert_ulps_ne!(f32::NAN, -f32::MAX); + assert_ulps_ne!(-f32::MAX, f32::NAN); + + assert_ulps_ne!(f32::NAN, f32::MIN_POSITIVE); + assert_ulps_ne!(f32::MIN_POSITIVE, f32::NAN); + assert_ulps_ne!(f32::NAN, -f32::MIN_POSITIVE); + assert_ulps_ne!(-f32::MIN_POSITIVE, f32::NAN); + } + + #[test] + fn test_opposite_signs() { + assert_ulps_ne!(1.000000001f32, -1.0f32); + assert_ulps_ne!(-1.0f32, 1.000000001f32); + assert_ulps_ne!(-1.000000001f32, 1.0f32); + assert_ulps_ne!(1.0f32, -1.000000001f32); + + assert_ulps_eq!(10.0 * f32::MIN_POSITIVE, 10.0 * -f32::MIN_POSITIVE); + } + + #[test] + fn test_close_to_zero() { + assert_ulps_eq!(f32::MIN_POSITIVE, f32::MIN_POSITIVE); + assert_ulps_eq!(f32::MIN_POSITIVE, -f32::MIN_POSITIVE); + assert_ulps_eq!(-f32::MIN_POSITIVE, f32::MIN_POSITIVE); + + assert_ulps_eq!(f32::MIN_POSITIVE, 0.0f32); + assert_ulps_eq!(0.0f32, f32::MIN_POSITIVE); + assert_ulps_eq!(-f32::MIN_POSITIVE, 0.0f32); + assert_ulps_eq!(0.0f32, -f32::MIN_POSITIVE); + + assert_ulps_ne!(0.000001f32, -f32::MIN_POSITIVE); + assert_ulps_ne!(0.000001f32, f32::MIN_POSITIVE); + assert_ulps_ne!(f32::MIN_POSITIVE, 0.000001f32); + assert_ulps_ne!(-f32::MIN_POSITIVE, 0.000001f32); + } +} + +#[cfg(test)] +mod test_f64 { + use std::f64; + + #[test] + fn test_basic() { + assert_ulps_eq!(1.0f64, 1.0f64); + assert_ulps_ne!(1.0f64, 2.0f64); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_ulps_eq!(1.0f64, 2.0f64); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_ulps_ne!(1.0f64, 1.0f64); + } + + #[test] + fn test_big() { + assert_ulps_eq!(10000000000000000.0f64, 10000000000000001.0f64); + assert_ulps_eq!(10000000000000001.0f64, 10000000000000000.0f64); + assert_ulps_ne!(1000000000000000.0f64, 1000000000000001.0f64); + assert_ulps_ne!(1000000000000001.0f64, 1000000000000000.0f64); + } + + #[test] + fn test_big_neg() { + assert_ulps_eq!(-10000000000000000.0f64, -10000000000000001.0f64); + assert_ulps_eq!(-10000000000000001.0f64, -10000000000000000.0f64); + assert_ulps_ne!(-1000000000000000.0f64, -1000000000000001.0f64); + assert_ulps_ne!(-1000000000000001.0f64, -1000000000000000.0f64); + } + + #[test] + fn test_mid() { + assert_ulps_eq!(1.0000000000000001f64, 1.0000000000000002f64); + assert_ulps_eq!(1.0000000000000002f64, 1.0000000000000001f64); + assert_ulps_ne!(1.000000000000001f64, 1.0000000000000022f64); + assert_ulps_ne!(1.0000000000000022f64, 1.000000000000001f64); + } + + #[test] + fn test_mid_neg() { + assert_ulps_eq!(-1.0000000000000001f64, -1.0000000000000002f64); + assert_ulps_eq!(-1.0000000000000002f64, -1.0000000000000001f64); + assert_ulps_ne!(-1.000000000000001f64, -1.0000000000000022f64); + assert_ulps_ne!(-1.0000000000000022f64, -1.000000000000001f64); + } + + #[test] + fn test_small() { + assert_ulps_eq!(0.0000000100000001f64, 0.0000000100000002f64); + assert_ulps_eq!(0.0000000100000002f64, 0.0000000100000001f64); + assert_ulps_ne!(0.0000000100000001f64, 0.0000000010000002f64); + assert_ulps_ne!(0.0000000100000002f64, 0.0000000010000001f64); + } + + #[test] + fn test_small_neg() { + assert_ulps_eq!(-0.0000000100000001f64, -0.0000000100000002f64); + assert_ulps_eq!(-0.0000000100000002f64, -0.0000000100000001f64); + assert_ulps_ne!(-0.0000000100000001f64, -0.0000000010000002f64); + assert_ulps_ne!(-0.0000000100000002f64, -0.0000000010000001f64); + } + + #[test] + fn test_zero() { + assert_ulps_eq!(0.0f64, 0.0f64); + assert_ulps_eq!(0.0f64, -0.0f64); + assert_ulps_eq!(-0.0f64, -0.0f64); + + assert_ulps_ne!(0.000000000000001f64, 0.0f64); + assert_ulps_ne!(0.0f64, 0.000000000000001f64); + assert_ulps_ne!(-0.000000000000001f64, 0.0f64); + assert_ulps_ne!(0.0f64, -0.000000000000001f64); + } + + #[test] + fn test_epsilon() { + assert_ulps_eq!(0.0f64, 1e-40f64, epsilon = 1e-40f64); + assert_ulps_eq!(1e-40f64, 0.0f64, epsilon = 1e-40f64); + assert_ulps_eq!(0.0f64, -1e-40f64, epsilon = 1e-40f64); + assert_ulps_eq!(-1e-40f64, 0.0f64, epsilon = 1e-40f64); + + assert_ulps_ne!(1e-40f64, 0.0f64, epsilon = 1e-41f64); + assert_ulps_ne!(0.0f64, 1e-40f64, epsilon = 1e-41f64); + assert_ulps_ne!(-1e-40f64, 0.0f64, epsilon = 1e-41f64); + assert_ulps_ne!(0.0f64, -1e-40f64, epsilon = 1e-41f64); + } + + #[test] + fn test_max() { + assert_ulps_eq!(f64::MAX, f64::MAX); + assert_ulps_ne!(f64::MAX, -f64::MAX); + assert_ulps_ne!(-f64::MAX, f64::MAX); + assert_ulps_ne!(f64::MAX, f64::MAX / 2.0); + assert_ulps_ne!(f64::MAX, -f64::MAX / 2.0); + assert_ulps_ne!(-f64::MAX, f64::MAX / 2.0); + } + + #[test] + fn test_infinity() { + assert_ulps_eq!(f64::INFINITY, f64::INFINITY); + assert_ulps_eq!(f64::NEG_INFINITY, f64::NEG_INFINITY); + assert_ulps_ne!(f64::NEG_INFINITY, f64::INFINITY); + assert_ulps_eq!(f64::INFINITY, f64::MAX); + assert_ulps_eq!(f64::NEG_INFINITY, -f64::MAX); + } + + #[test] + fn test_nan() { + assert_ulps_ne!(f64::NAN, f64::NAN); + + assert_ulps_ne!(f64::NAN, 0.0); + assert_ulps_ne!(-0.0, f64::NAN); + assert_ulps_ne!(f64::NAN, -0.0); + assert_ulps_ne!(0.0, f64::NAN); + + assert_ulps_ne!(f64::NAN, f64::INFINITY); + assert_ulps_ne!(f64::INFINITY, f64::NAN); + assert_ulps_ne!(f64::NAN, f64::NEG_INFINITY); + assert_ulps_ne!(f64::NEG_INFINITY, f64::NAN); + + assert_ulps_ne!(f64::NAN, f64::MAX); + assert_ulps_ne!(f64::MAX, f64::NAN); + assert_ulps_ne!(f64::NAN, -f64::MAX); + assert_ulps_ne!(-f64::MAX, f64::NAN); + + assert_ulps_ne!(f64::NAN, f64::MIN_POSITIVE); + assert_ulps_ne!(f64::MIN_POSITIVE, f64::NAN); + assert_ulps_ne!(f64::NAN, -f64::MIN_POSITIVE); + assert_ulps_ne!(-f64::MIN_POSITIVE, f64::NAN); + } + + #[test] + fn test_opposite_signs() { + assert_ulps_ne!(1.000000001f64, -1.0f64); + assert_ulps_ne!(-1.0f64, 1.000000001f64); + assert_ulps_ne!(-1.000000001f64, 1.0f64); + assert_ulps_ne!(1.0f64, -1.000000001f64); + + assert_ulps_eq!(10.0 * f64::MIN_POSITIVE, 10.0 * -f64::MIN_POSITIVE); + } + + #[test] + fn test_close_to_zero() { + assert_ulps_eq!(f64::MIN_POSITIVE, f64::MIN_POSITIVE); + assert_ulps_eq!(f64::MIN_POSITIVE, -f64::MIN_POSITIVE); + assert_ulps_eq!(-f64::MIN_POSITIVE, f64::MIN_POSITIVE); + + assert_ulps_eq!(f64::MIN_POSITIVE, 0.0f64); + assert_ulps_eq!(0.0f64, f64::MIN_POSITIVE); + assert_ulps_eq!(-f64::MIN_POSITIVE, 0.0f64); + assert_ulps_eq!(0.0f64, -f64::MIN_POSITIVE); + + assert_ulps_ne!(0.000000000000001f64, -f64::MIN_POSITIVE); + assert_ulps_ne!(0.000000000000001f64, f64::MIN_POSITIVE); + assert_ulps_ne!(f64::MIN_POSITIVE, 0.000000000000001f64); + assert_ulps_ne!(-f64::MIN_POSITIVE, 0.000000000000001f64); + } +} + +mod test_ref { + mod test_f32 { + #[test] + fn test_basic() { + assert_ulps_eq!(&1.0f32, &1.0f32); + assert_ulps_ne!(&1.0f32, &2.0f32); + } + } + + mod test_f64 { + #[test] + fn test_basic() { + assert_ulps_eq!(&1.0f64, &1.0f64); + assert_ulps_ne!(&1.0f64, &2.0f64); + } + } +} + +mod test_slice { + mod test_f32 { + #[test] + fn test_basic() { + assert_ulps_eq!([1.0f32, 2.0f32][..], [1.0f32, 2.0f32][..]); + assert_ulps_ne!([1.0f32, 2.0f32][..], [2.0f32, 1.0f32][..]); + } + } + + mod test_f64 { + #[test] + fn test_basic() { + assert_ulps_eq!([1.0f64, 2.0f64][..], [1.0f64, 2.0f64][..]); + assert_ulps_ne!([1.0f64, 2.0f64][..], [2.0f64, 1.0f64][..]); + } + } +} + +#[cfg(feature = "num-complex")] +mod test_complex { + extern crate num_complex; + pub use self::num_complex::Complex; + + mod test_f32 { + use super::Complex; + + #[test] + fn test_basic() { + assert_ulps_eq!(Complex::new(1.0f32, 2.0f32), Complex::new(1.0f32, 2.0f32)); + assert_ulps_ne!(Complex::new(1.0f32, 2.0f32), Complex::new(2.0f32, 1.0f32)); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_ulps_eq!(Complex::new(1.0f32, 2.0f32), Complex::new(2.0f32, 1.0f32)); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_ulps_ne!(Complex::new(1.0f32, 2.0f32), Complex::new(1.0f32, 2.0f32)); + } + } + + mod test_f64 { + use super::Complex; + + #[test] + fn test_basic() { + assert_ulps_eq!(Complex::new(1.0f64, 2.0f64), Complex::new(1.0f64, 2.0f64)); + assert_ulps_ne!(Complex::new(1.0f64, 2.0f64), Complex::new(2.0f64, 1.0f64)); + } + + #[test] + #[should_panic] + fn test_basic_panic_eq() { + assert_ulps_eq!(Complex::new(1.0f64, 2.0f64), Complex::new(2.0f64, 1.0f64)); + } + + #[test] + #[should_panic] + fn test_basic_panic_ne() { + assert_ulps_ne!(Complex::new(1.0f64, 2.0f64), Complex::new(1.0f64, 2.0f64)); + } + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/.cargo-checksum.json b/third_party/cargo/vendor/arrayvec-0.4.12/.cargo-checksum.json new file mode 100644 index 0000000..bc4b933 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"adb58f911fb48a1a3828bda514c2da5ce5650e8e98eb7217f014b1720fe11d38","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0245ee104228a100ce5fceecf43e25faae450494d9173f43fd94c27d69fdac13","README.rst":"a3cff166a7b622233cd9ccfbe472f910267629f4b41e387ad8573fc06eac37d6","benches/arraystring.rs":"f12b890977117ebde4ca42bcd6b91f2a6a087f2b235aaca6d15e30d125ae9f67","benches/extend.rs":"8c8f78df7e90b62c7e160cf5ea6c61b90bc4035a9704b6a179a1e01d8fafe2e9","build.rs":"fc29930f06cb4dde58f43d2f30b28c366ca3bafcd7e44b41a1c250d60fa900fb","custom.css":"e6f2cd299392337b4e2959c52f422e5b7be11920ea98d10db44d10ddef5ed47c","src/array.rs":"67fb063ee515bfd4968ede219dff81091a5935ef93529ebd1bb2a716ea3ed3d3","src/array_string.rs":"8a1a4cfc1699e2373815e57dc676a87a30629f91a9e861c866ccc6cb1381eadf","src/char.rs":"64a08f6a743b67bf2c96483f91c2fdaea79f6e91df5cd752f770b16a6b1d5b1e","src/errors.rs":"dde99bffaddfd45396aab7e07642cc018ef5435fe60c4f26a2c05a36555be18c","src/lib.rs":"34167f35d9a5b887e6fb424500bb64764d68d029d0e374827886b05ad4d26bca","src/maybe_uninit.rs":"7cca39ffe0f122716baaa174b433ff5fe9c93560f8e54fc077a0083500eaa1dd","src/maybe_uninit_nodrop.rs":"7fb2e24bf815dd6e1d104056fa9be4a11de7e0f0e5474742af186c580a6b47cc","src/maybe_uninit_stable.rs":"3f7daba622cf5df86992b451b46636a491c9611292f59969eb6890a10a00476d","src/range.rs":"65744ab7def208a1ab155ea2448fe9ea7fc14f33211361b1041f540125b32efd","tests/serde.rs":"ef3986a82656b09f3fbb14358e767051ffabe09592c61e69ea695cb88760e8ba","tests/tests.rs":"8066a4aca7b40356525ed87f7658773e610ef4fce3522b0cc0f301384d880f00"},"package":"cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9"} \ No newline at end of file diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/BUILD b/third_party/cargo/vendor/arrayvec-0.4.12/BUILD new file mode 100644 index 0000000..e50ab68 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/BUILD @@ -0,0 +1,48 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "arraystring" with type "bench" omitted + +rust_library( + name = "arrayvec", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/nodrop-0.1.14:nodrop", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.12", + crate_features = [ + ], +) + +# Unsupported target "build-script-build" with type "custom-build" omitted +# Unsupported target "extend" with type "bench" omitted +# Unsupported target "serde" with type "test" omitted +# Unsupported target "tests" with type "test" omitted diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/Cargo.toml b/third_party/cargo/vendor/arrayvec-0.4.12/Cargo.toml new file mode 100644 index 0000000..f67c3c3 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/Cargo.toml @@ -0,0 +1,62 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "arrayvec" +version = "0.4.12" +authors = ["bluss"] +description = "A vector with fixed capacity, backed by an array (it can be stored on the stack too). Implements fixed capacity ArrayVec and ArrayString." +documentation = "https://docs.rs/arrayvec/" +keywords = ["stack", "vector", "array", "data-structure", "no_std"] +categories = ["data-structures", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/bluss/arrayvec" +[package.metadata.docs.rs] +features = ["serde-1"] + +[package.metadata.release] +no-dev-version = true +tag-name = "{{version}}" + +[[bench]] +name = "extend" +harness = false + +[[bench]] +name = "arraystring" +harness = false +[dependencies.nodrop] +version = "0.1.12" +default-features = false + +[dependencies.serde] +version = "1.0" +optional = true +default-features = false +[dev-dependencies.bencher] +version = "0.1.4" + +[dev-dependencies.matches] +version = "0.1" + +[dev-dependencies.serde_test] +version = "1.0" + +[build-dependencies] + +[features] +array-sizes-129-255 = [] +array-sizes-33-128 = [] +default = ["std"] +serde-1 = ["serde"] +std = [] +use_union = [] diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/LICENSE-APACHE b/third_party/cargo/vendor/arrayvec-0.4.12/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/LICENSE-MIT b/third_party/cargo/vendor/arrayvec-0.4.12/LICENSE-MIT new file mode 100644 index 0000000..2c8f27d --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) Ulrik Sverdrup "bluss" 2015-2017 + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/README.rst b/third_party/cargo/vendor/arrayvec-0.4.12/README.rst new file mode 100644 index 0000000..d20556a --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/README.rst @@ -0,0 +1,224 @@ + +arrayvec +======== + +A vector with fixed capacity. + +Please read the `API documentation here`__ + +__ https://docs.rs/arrayvec + +|build_status|_ |crates|_ |crates2|_ + +.. |build_status| image:: https://travis-ci.org/bluss/arrayvec.svg +.. _build_status: https://travis-ci.org/bluss/arrayvec + +.. |crates| image:: http://meritbadge.herokuapp.com/arrayvec +.. _crates: https://crates.io/crates/arrayvec + +.. |crates2| image:: http://meritbadge.herokuapp.com/nodrop +.. _crates2: https://crates.io/crates/nodrop + +Recent Changes (arrayvec) +------------------------- + +- 0.4.12 + + - Use raw pointers instead of ``get_unchecked_mut`` where the target may be + uninitialized a everywhere relevant in the ArrayVec implementation. + +- 0.4.11 + + - In Rust 1.36 or later, use newly stable MaybeUninit. This extends the + soundness work introduced in 0.4.9, we are finally able to use this in + stable. We use feature detection (build script) to enable this at build + time. + +- 0.4.10 + + - Use ``repr(C)`` in the ``union`` version that was introduced in 0.4.9, to + allay some soundness concerns. + +- 0.4.9 + + - Use ``union`` in the implementation on when this is detected to be supported + (nightly only for now). This is a better solution for treating uninitialized + regions correctly, and we'll use it in stable Rust as soon as we are able. + When this is enabled, the ``ArrayVec`` has no space overhead in its memory + layout, although the size of the vec should not be relied upon. (See `#114`_) + - ``ArrayString`` updated to not use uninitialized memory, it instead zeros its + backing array. This will be refined in the next version, since we + need to make changes to the user visible API. + - The ``use_union`` feature now does nothing (like its documentation foretold). + +.. _`#114`: https://github.com/bluss/arrayvec/pull/114 + +- 0.4.8 + + - Implement Clone and Debug for ``IntoIter`` by @clarcharr + - Add more array sizes under crate features. These cover all in the range + up to 128 and 129 to 255 respectively (we have a few of those by default): + + - ``array-size-33-128`` + - ``array-size-129-255`` + +- 0.4.7 + + - Fix future compat warning about raw pointer casts + - Use ``drop_in_place`` when dropping the arrayvec by-value iterator + - Decrease mininum Rust version (see docs) by @jeehoonkang + +- 0.3.25 + + - Fix future compat warning about raw pointer casts + +- 0.4.6 + + - Fix compilation on 16-bit targets. This means, the 65536 array size is not + included on these targets. + +- 0.3.24 + + - Fix compilation on 16-bit targets. This means, the 65536 array size is not + included on these targets. + - Fix license files so that they are both included (was fixed in 0.4 before) + +- 0.4.5 + + - Add methods to ``ArrayString`` by @DenialAdams: + + - ``.pop() -> Option`` + - ``.truncate(new_len)`` + - ``.remove(index) -> char`` + + - Remove dependency on crate odds + - Document debug assertions in unsafe methods better + +- 0.4.4 + + - Add method ``ArrayVec::truncate()`` by @niklasf + +- 0.4.3 + + - Improve performance for ``ArrayVec::extend`` with a lower level + implementation (#74) + - Small cleanup in dependencies (use no std for crates where we don't need more) + +- 0.4.2 + + - Add constructor method ``new`` to ``CapacityError``. + +- 0.4.1 + + - Add ``Default`` impl to ``ArrayString`` by @tbu- + +- 0.4.0 + + - Reformed signatures and error handling by @bluss and @tbu-: + + - ``ArrayVec``'s ``push, insert, remove, swap_remove`` now match ``Vec``'s + corresponding signature and panic on capacity errors where applicable. + - Add fallible methods ``try_push, insert`` and checked methods + ``pop_at, swap_pop``. + - Similar changes to ``ArrayString``'s push methods. + + - Use a local version of the ``RangeArgument`` trait + - Add array sizes 50, 150, 200 by @daboross + - Support serde 1.0 by @daboross + - New method ``.push_unchecked()`` by @niklasf + - ``ArrayString`` implements ``PartialOrd, Ord`` by @tbu- + - Require Rust 1.14 + - crate feature ``use_generic_array`` was dropped. + +- 0.3.23 + + - Implement ``PartialOrd, Ord`` as well as ``PartialOrd`` for + ``ArrayString``. + +- 0.3.22 + + - Implement ``Array`` for the 65536 size + +- 0.3.21 + + - Use ``encode_utf8`` from crate odds + - Add constructor ``ArrayString::from_byte_string`` + +- 0.3.20 + + - Simplify and speed up ``ArrayString``’s ``.push(char)``- + +- 0.3.19 + + - Add new crate feature ``use_generic_array`` which allows using their + ``GenericArray`` just like a regular fixed size array for the storage + of an ``ArrayVec``. + +- 0.3.18 + + - Fix bounds check in ``ArrayVec::insert``! + It would be buggy if ``self.len() < index < self.capacity()``. Take note of + the push out behavior specified in the docs. + +- 0.3.17 + + - Added crate feature ``use_union`` which forwards to the nodrop crate feature + - Added methods ``.is_full()`` to ``ArrayVec`` and ``ArrayString``. + +- 0.3.16 + + - Added method ``.retain()`` to ``ArrayVec``. + - Added methods ``.as_slice(), .as_mut_slice()`` to ``ArrayVec`` and ``.as_str()`` + to ``ArrayString``. + +- 0.3.15 + + - Add feature std, which you can opt out of to use ``no_std`` (requires Rust 1.6 + to opt out). + - Implement ``Clone::clone_from`` for ArrayVec and ArrayString + +- 0.3.14 + + - Add ``ArrayString::from(&str)`` + +- 0.3.13 + + - Added ``DerefMut`` impl for ``ArrayString``. + - Added method ``.simplify()`` to drop the element for ``CapacityError``. + - Added method ``.dispose()`` to ``ArrayVec`` + +- 0.3.12 + + - Added ArrayString, a fixed capacity analogy of String + +- 0.3.11 + + - Added trait impls Default, PartialOrd, Ord, Write for ArrayVec + +- 0.3.10 + + - Go back to using external NoDrop, fixing a panic safety bug (issue #3) + +- 0.3.8 + + - Inline the non-dropping logic to remove one drop flag in the + ArrayVec representation. + +- 0.3.7 + + - Added method .into_inner() + - Added unsafe method .set_len() + + +License +======= + +Dual-licensed to be compatible with the Rust project. + +Licensed under the Apache License, Version 2.0 +http://www.apache.org/licenses/LICENSE-2.0 or the MIT license +http://opensource.org/licenses/MIT, at your +option. This file may not be copied, modified, or distributed +except according to those terms. + + diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/benches/arraystring.rs b/third_party/cargo/vendor/arrayvec-0.4.12/benches/arraystring.rs new file mode 100644 index 0000000..9cff587 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/benches/arraystring.rs @@ -0,0 +1,90 @@ + +extern crate arrayvec; +#[macro_use] extern crate bencher; + +use arrayvec::ArrayString; + +use bencher::Bencher; + +fn try_push_c(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + b.iter(|| { + v.clear(); + while v.try_push('c').is_ok() { + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +fn try_push_alpha(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + b.iter(|| { + v.clear(); + while v.try_push('α').is_ok() { + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +// Yes, pushing a string char-by-char is slow. Use .push_str. +fn try_push_string(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + let input = "abcαβγ“”"; + b.iter(|| { + v.clear(); + for ch in input.chars().cycle() { + if !v.try_push(ch).is_ok() { + break; + } + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +fn push_c(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + b.iter(|| { + v.clear(); + while !v.is_full() { + v.push('c'); + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +fn push_alpha(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + b.iter(|| { + v.clear(); + while !v.is_full() { + v.push('α'); + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +fn push_string(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + let input = "abcαβγ“”"; + b.iter(|| { + v.clear(); + for ch in input.chars().cycle() { + if !v.is_full() { + v.push(ch); + } else { + break; + } + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +benchmark_group!(benches, try_push_c, try_push_alpha, try_push_string, push_c, + push_alpha, push_string); +benchmark_main!(benches); diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/benches/extend.rs b/third_party/cargo/vendor/arrayvec-0.4.12/benches/extend.rs new file mode 100644 index 0000000..d380a7e --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/benches/extend.rs @@ -0,0 +1,43 @@ + +extern crate arrayvec; +#[macro_use] extern crate bencher; + +use arrayvec::ArrayVec; + +use bencher::Bencher; + +fn extend_with_constant(b: &mut Bencher) { + let mut v = ArrayVec::<[u8; 512]>::new(); + let cap = v.capacity(); + b.iter(|| { + v.clear(); + v.extend((0..cap).map(|_| 1)); + v[0] + }); + b.bytes = v.capacity() as u64; +} + +fn extend_with_range(b: &mut Bencher) { + let mut v = ArrayVec::<[u8; 512]>::new(); + let cap = v.capacity(); + b.iter(|| { + v.clear(); + v.extend((0..cap).map(|x| x as _)); + v[0] + }); + b.bytes = v.capacity() as u64; +} + +fn extend_with_slice(b: &mut Bencher) { + let mut v = ArrayVec::<[u8; 512]>::new(); + let data = [1; 512]; + b.iter(|| { + v.clear(); + v.extend(data.iter().cloned()); + v[0] + }); + b.bytes = v.capacity() as u64; +} + +benchmark_group!(benches, extend_with_constant, extend_with_range, extend_with_slice); +benchmark_main!(benches); diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/build.rs b/third_party/cargo/vendor/arrayvec-0.4.12/build.rs new file mode 100644 index 0000000..a91c5f4 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/build.rs @@ -0,0 +1,90 @@ + +use std::env; +use std::io::Write; +use std::process::{Command, Stdio}; + +fn main() { + // we need to output *some* file to opt out of the default + println!("cargo:rerun-if-changed=build.rs"); + + detect_maybe_uninit(); +} + +fn detect_maybe_uninit() { + let has_stable_maybe_uninit = probe(&stable_maybe_uninit()); + if has_stable_maybe_uninit { + println!("cargo:rustc-cfg=has_stable_maybe_uninit"); + return; + } + let has_unstable_union_with_md = probe(&maybe_uninit_code(true)); + if has_unstable_union_with_md { + println!("cargo:rustc-cfg=has_manually_drop_in_union"); + println!("cargo:rustc-cfg=has_union_feature"); + } +} + +// To guard against changes in this currently unstable feature, use +// a detection tests instead of a Rustc version and/or date test. +fn stable_maybe_uninit() -> String { + let code = " + #![allow(warnings)] + use std::mem::MaybeUninit; + + fn main() { } + "; + code.to_string() +} + +// To guard against changes in this currently unstable feature, use +// a detection tests instead of a Rustc version and/or date test. +fn maybe_uninit_code(use_feature: bool) -> String { + let feature = if use_feature { "#![feature(untagged_unions)]" } else { "" }; + + let code = " + #![allow(warnings)] + use std::mem::ManuallyDrop; + + #[derive(Copy)] + pub union MaybeUninit { + empty: (), + value: ManuallyDrop, + } + + impl Clone for MaybeUninit where T: Copy + { + fn clone(&self) -> Self { *self } + } + + fn main() { + let value1 = MaybeUninit::<[i32; 3]> { empty: () }; + let value2 = MaybeUninit { value: ManuallyDrop::new([1, 2, 3]) }; + } + "; + + + [feature, code].concat() +} + +/// Test if a code snippet can be compiled +fn probe(code: &str) -> bool { + let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into()); + let out_dir = env::var_os("OUT_DIR").expect("environment variable OUT_DIR"); + + let mut child = Command::new(rustc) + .arg("--out-dir") + .arg(out_dir) + .arg("--emit=obj") + .arg("-") + .stdin(Stdio::piped()) + .spawn() + .expect("rustc probe"); + + child + .stdin + .as_mut() + .expect("rustc stdin") + .write_all(code.as_bytes()) + .expect("write rustc stdin"); + + child.wait().expect("rustc probe").success() +} diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/custom.css b/third_party/cargo/vendor/arrayvec-0.4.12/custom.css new file mode 100644 index 0000000..8e0b705 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/custom.css @@ -0,0 +1,25 @@ + +.docblock pre.rust { background: #eeeeff; } +pre.trait, pre.fn, pre.struct, pre.enum, pre.typedef { background: #fcfefc; } + +/* Small “example” label for doc examples */ +.docblock pre.rust::before { + content: "example"; + float: right; + font-style: italic; + font-size: 0.8em; + margin-top: -10px; + margin-right: -5px; +} + + +/* Fixup where display in trait listing */ +pre.trait .where::before { +content: '\a '; +} + +.docblock code { + background-color: inherit; + font-weight: bold; + padding: 0 0.1em; +} diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/src/array.rs b/third_party/cargo/vendor/arrayvec-0.4.12/src/array.rs new file mode 100644 index 0000000..4f099a6 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/src/array.rs @@ -0,0 +1,137 @@ + +/// Trait for fixed size arrays. +/// +/// This trait is implemented for some specific array sizes, see +/// the implementor list below. At the current state of Rust we can't +/// make this fully general for every array size. +/// +/// The following crate features add more array sizes (and they are not +/// enabled by default due to their impact on compliation speed). +/// +/// - `array-sizes-33-128`: All sizes 33 to 128 are implemented +/// (a few in this range are included by default). +/// - `array-sizes-129-255`: All sizes 129 to 255 are implemented +/// (a few in this range are included by default). +pub unsafe trait Array { + /// The array’s element type + type Item; + #[doc(hidden)] + /// The smallest index type that indexes the array. + type Index: Index; + #[doc(hidden)] + fn as_ptr(&self) -> *const Self::Item; + #[doc(hidden)] + fn as_mut_ptr(&mut self) -> *mut Self::Item; + #[doc(hidden)] + fn capacity() -> usize; +} + +pub trait Index : PartialEq + Copy { + fn to_usize(self) -> usize; + fn from(usize) -> Self; +} + +use std::slice::{from_raw_parts}; + +pub trait ArrayExt : Array { + #[inline(always)] + fn as_slice(&self) -> &[Self::Item] { + unsafe { + from_raw_parts(self.as_ptr(), Self::capacity()) + } + } +} + +impl ArrayExt for A where A: Array { } + +impl Index for u8 { + #[inline(always)] + fn to_usize(self) -> usize { self as usize } + #[inline(always)] + fn from(ix: usize) -> Self { ix as u8 } +} + +impl Index for u16 { + #[inline(always)] + fn to_usize(self) -> usize { self as usize } + #[inline(always)] + fn from(ix: usize) -> Self { ix as u16 } +} + +impl Index for u32 { + #[inline(always)] + fn to_usize(self) -> usize { self as usize } + #[inline(always)] + fn from(ix: usize) -> Self { ix as u32 } +} + +impl Index for usize { + #[inline(always)] + fn to_usize(self) -> usize { self } + #[inline(always)] + fn from(ix: usize) -> Self { ix } +} + +macro_rules! fix_array_impl { + ($index_type:ty, $len:expr ) => ( + unsafe impl Array for [T; $len] { + type Item = T; + type Index = $index_type; + #[doc(hidden)] + #[inline(always)] + fn as_ptr(&self) -> *const T { self as *const _ as *const _ } + #[doc(hidden)] + #[inline(always)] + fn as_mut_ptr(&mut self) -> *mut T { self as *mut _ as *mut _} + #[doc(hidden)] + #[inline(always)] + fn capacity() -> usize { $len } + } + ) +} + +macro_rules! fix_array_impl_recursive { + ($index_type:ty, ) => (); + ($index_type:ty, $($len:expr,)*) => ( + $(fix_array_impl!($index_type, $len);)* + ); +} + +fix_array_impl_recursive!(u8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, ); + +#[cfg(not(feature="array-sizes-33-128"))] +fix_array_impl_recursive!(u8, 32, 40, 48, 50, 56, 64, 72, 96, 100, 128, ); + +#[cfg(feature="array-sizes-33-128")] +fix_array_impl_recursive!(u8, +32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, +52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, +72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, +92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, +109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, +125, 126, 127, 128, +); + +#[cfg(not(feature="array-sizes-129-255"))] +fix_array_impl_recursive!(u8, 160, 192, 200, 224,); + +#[cfg(feature="array-sizes-129-255")] +fix_array_impl_recursive!(u8, +129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, +141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, +157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, +173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, +189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, +205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, +221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, +237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, +253, 254, 255, +); + +fix_array_impl_recursive!(u16, 256, 384, 512, 768, 1024, 2048, 4096, 8192, 16384, 32768,); +// This array size doesn't exist on 16-bit +#[cfg(any(target_pointer_width="32", target_pointer_width="64"))] +fix_array_impl_recursive!(u32, 1 << 16,); + diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/src/array_string.rs b/third_party/cargo/vendor/arrayvec-0.4.12/src/array_string.rs new file mode 100644 index 0000000..6cd1c65 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/src/array_string.rs @@ -0,0 +1,516 @@ +use std::borrow::Borrow; +use std::cmp; +use std::fmt; +use std::hash::{Hash, Hasher}; +use std::mem; +use std::ptr; +use std::ops::{Deref, DerefMut}; +use std::str; +use std::str::Utf8Error; +use std::slice; + +use array::{Array, ArrayExt}; +use array::Index; +use CapacityError; +use char::encode_utf8; + +#[cfg(feature="serde-1")] +use serde::{Serialize, Deserialize, Serializer, Deserializer}; + +/// A string with a fixed capacity. +/// +/// The `ArrayString` is a string backed by a fixed size array. It keeps track +/// of its length. +/// +/// The string is a contiguous value that you can store directly on the stack +/// if needed. +#[derive(Copy)] +pub struct ArrayString> { + // FIXME: Use Copyable union for xs when we can + xs: A, + len: A::Index, +} + +impl> Default for ArrayString { + /// Return an empty `ArrayString` + fn default() -> ArrayString { + ArrayString::new() + } +} + +impl> ArrayString { + /// Create a new empty `ArrayString`. + /// + /// Capacity is inferred from the type parameter. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 16]>::new(); + /// string.push_str("foo"); + /// assert_eq!(&string[..], "foo"); + /// assert_eq!(string.capacity(), 16); + /// ``` + pub fn new() -> ArrayString { + unsafe { + ArrayString { + // FIXME: Use Copyable union for xs when we can + xs: mem::zeroed(), + len: Index::from(0), + } + } + } + + /// Create a new `ArrayString` from a `str`. + /// + /// Capacity is inferred from the type parameter. + /// + /// **Errors** if the backing array is not large enough to fit the string. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 3]>::from("foo").unwrap(); + /// assert_eq!(&string[..], "foo"); + /// assert_eq!(string.len(), 3); + /// assert_eq!(string.capacity(), 3); + /// ``` + pub fn from(s: &str) -> Result> { + let mut arraystr = Self::new(); + arraystr.try_push_str(s)?; + Ok(arraystr) + } + + /// Create a new `ArrayString` from a byte string literal. + /// + /// **Errors** if the byte string literal is not valid UTF-8. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let string = ArrayString::from_byte_string(b"hello world").unwrap(); + /// ``` + pub fn from_byte_string(b: &A) -> Result { + let mut arraystr = Self::new(); + let s = try!(str::from_utf8(b.as_slice())); + let _result = arraystr.try_push_str(s); + debug_assert!(_result.is_ok()); + Ok(arraystr) + } + + /// Return the capacity of the `ArrayString`. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let string = ArrayString::<[_; 3]>::new(); + /// assert_eq!(string.capacity(), 3); + /// ``` + #[inline] + pub fn capacity(&self) -> usize { A::capacity() } + + /// Return if the `ArrayString` is completely filled. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 1]>::new(); + /// assert!(!string.is_full()); + /// string.push_str("A"); + /// assert!(string.is_full()); + /// ``` + pub fn is_full(&self) -> bool { self.len() == self.capacity() } + + /// Adds the given char to the end of the string. + /// + /// ***Panics*** if the backing array is not large enough to fit the additional char. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 2]>::new(); + /// + /// string.push('a'); + /// string.push('b'); + /// + /// assert_eq!(&string[..], "ab"); + /// ``` + pub fn push(&mut self, c: char) { + self.try_push(c).unwrap(); + } + + /// Adds the given char to the end of the string. + /// + /// Returns `Ok` if the push succeeds. + /// + /// **Errors** if the backing array is not large enough to fit the additional char. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 2]>::new(); + /// + /// string.try_push('a').unwrap(); + /// string.try_push('b').unwrap(); + /// let overflow = string.try_push('c'); + /// + /// assert_eq!(&string[..], "ab"); + /// assert_eq!(overflow.unwrap_err().element(), 'c'); + /// ``` + pub fn try_push(&mut self, c: char) -> Result<(), CapacityError> { + let len = self.len(); + unsafe { + match encode_utf8(c, &mut self.raw_mut_bytes()[len..]) { + Ok(n) => { + self.set_len(len + n); + Ok(()) + } + Err(_) => Err(CapacityError::new(c)), + } + } + } + + /// Adds the given string slice to the end of the string. + /// + /// ***Panics*** if the backing array is not large enough to fit the string. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 2]>::new(); + /// + /// string.push_str("a"); + /// string.push_str("d"); + /// + /// assert_eq!(&string[..], "ad"); + /// ``` + pub fn push_str(&mut self, s: &str) { + self.try_push_str(s).unwrap() + } + + /// Adds the given string slice to the end of the string. + /// + /// Returns `Ok` if the push succeeds. + /// + /// **Errors** if the backing array is not large enough to fit the string. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 2]>::new(); + /// + /// string.try_push_str("a").unwrap(); + /// let overflow1 = string.try_push_str("bc"); + /// string.try_push_str("d").unwrap(); + /// let overflow2 = string.try_push_str("ef"); + /// + /// assert_eq!(&string[..], "ad"); + /// assert_eq!(overflow1.unwrap_err().element(), "bc"); + /// assert_eq!(overflow2.unwrap_err().element(), "ef"); + /// ``` + pub fn try_push_str<'a>(&mut self, s: &'a str) -> Result<(), CapacityError<&'a str>> { + if s.len() > self.capacity() - self.len() { + return Err(CapacityError::new(s)); + } + unsafe { + let dst = self.xs.as_mut_ptr().offset(self.len() as isize); + let src = s.as_ptr(); + ptr::copy_nonoverlapping(src, dst, s.len()); + let newl = self.len() + s.len(); + self.set_len(newl); + } + Ok(()) + } + + /// Removes the last character from the string and returns it. + /// + /// Returns `None` if this `ArrayString` is empty. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut s = ArrayString::<[_; 3]>::from("foo").unwrap(); + /// + /// assert_eq!(s.pop(), Some('o')); + /// assert_eq!(s.pop(), Some('o')); + /// assert_eq!(s.pop(), Some('f')); + /// + /// assert_eq!(s.pop(), None); + /// ``` + #[inline] + pub fn pop(&mut self) -> Option { + let ch = match self.chars().rev().next() { + Some(ch) => ch, + None => return None, + }; + let new_len = self.len() - ch.len_utf8(); + unsafe { + self.set_len(new_len); + } + Some(ch) + } + + /// Shortens this `ArrayString` to the specified length. + /// + /// If `new_len` is greater than the string’s current length, this has no + /// effect. + /// + /// ***Panics*** if `new_len` does not lie on a `char` boundary. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 6]>::from("foobar").unwrap(); + /// string.truncate(3); + /// assert_eq!(&string[..], "foo"); + /// string.truncate(4); + /// assert_eq!(&string[..], "foo"); + /// ``` + #[inline] + pub fn truncate(&mut self, new_len: usize) { + if new_len <= self.len() { + assert!(self.is_char_boundary(new_len)); + unsafe { + // In libstd truncate is called on the underlying vector, + // which in turns drops each element. + // As we know we don't have to worry about Drop, + // we can just set the length (a la clear.) + self.set_len(new_len); + } + } + } + + /// Removes a `char` from this `ArrayString` at a byte position and returns it. + /// + /// This is an `O(n)` operation, as it requires copying every element in the + /// array. + /// + /// ***Panics*** if `idx` is larger than or equal to the `ArrayString`’s length, + /// or if it does not lie on a `char` boundary. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut s = ArrayString::<[_; 3]>::from("foo").unwrap(); + /// + /// assert_eq!(s.remove(0), 'f'); + /// assert_eq!(s.remove(1), 'o'); + /// assert_eq!(s.remove(0), 'o'); + /// ``` + #[inline] + pub fn remove(&mut self, idx: usize) -> char { + let ch = match self[idx..].chars().next() { + Some(ch) => ch, + None => panic!("cannot remove a char from the end of a string"), + }; + + let next = idx + ch.len_utf8(); + let len = self.len(); + unsafe { + ptr::copy(self.xs.as_ptr().offset(next as isize), + self.xs.as_mut_ptr().offset(idx as isize), + len - next); + self.set_len(len - (next - idx)); + } + ch + } + + /// Make the string empty. + pub fn clear(&mut self) { + unsafe { + self.set_len(0); + } + } + + /// Set the strings’s length. + /// + /// This function is `unsafe` because it changes the notion of the + /// number of “valid” bytes in the string. Use with care. + /// + /// This method uses *debug assertions* to check the validity of `length` + /// and may use other debug assertions. + #[inline] + pub unsafe fn set_len(&mut self, length: usize) { + debug_assert!(length <= self.capacity()); + self.len = Index::from(length); + } + + /// Return a string slice of the whole `ArrayString`. + pub fn as_str(&self) -> &str { + self + } + + /// Return a mutable slice of the whole string’s buffer + unsafe fn raw_mut_bytes(&mut self) -> &mut [u8] { + slice::from_raw_parts_mut(self.xs.as_mut_ptr(), self.capacity()) + } +} + +impl> Deref for ArrayString { + type Target = str; + #[inline] + fn deref(&self) -> &str { + unsafe { + let sl = slice::from_raw_parts(self.xs.as_ptr(), self.len.to_usize()); + str::from_utf8_unchecked(sl) + } + } +} + +impl> DerefMut for ArrayString { + #[inline] + fn deref_mut(&mut self) -> &mut str { + unsafe { + let sl = slice::from_raw_parts_mut(self.xs.as_mut_ptr(), self.len.to_usize()); + // FIXME: Nothing but transmute to do this right now + mem::transmute(sl) + } + } +} + +impl> PartialEq for ArrayString { + fn eq(&self, rhs: &Self) -> bool { + **self == **rhs + } +} + +impl> PartialEq for ArrayString { + fn eq(&self, rhs: &str) -> bool { + &**self == rhs + } +} + +impl> PartialEq> for str { + fn eq(&self, rhs: &ArrayString) -> bool { + self == &**rhs + } +} + +impl> Eq for ArrayString { } + +impl> Hash for ArrayString { + fn hash(&self, h: &mut H) { + (**self).hash(h) + } +} + +impl> Borrow for ArrayString { + fn borrow(&self) -> &str { self } +} + +impl> AsRef for ArrayString { + fn as_ref(&self) -> &str { self } +} + +impl> fmt::Debug for ArrayString { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } +} + +impl> fmt::Display for ArrayString { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } +} + +/// `Write` appends written data to the end of the string. +impl> fmt::Write for ArrayString { + fn write_char(&mut self, c: char) -> fmt::Result { + self.try_push(c).map_err(|_| fmt::Error) + } + + fn write_str(&mut self, s: &str) -> fmt::Result { + self.try_push_str(s).map_err(|_| fmt::Error) + } +} + +impl + Copy> Clone for ArrayString { + fn clone(&self) -> ArrayString { + *self + } + fn clone_from(&mut self, rhs: &Self) { + // guaranteed to fit due to types matching. + self.clear(); + self.try_push_str(rhs).ok(); + } +} + +impl> PartialOrd for ArrayString { + fn partial_cmp(&self, rhs: &Self) -> Option { + (**self).partial_cmp(&**rhs) + } + fn lt(&self, rhs: &Self) -> bool { **self < **rhs } + fn le(&self, rhs: &Self) -> bool { **self <= **rhs } + fn gt(&self, rhs: &Self) -> bool { **self > **rhs } + fn ge(&self, rhs: &Self) -> bool { **self >= **rhs } +} + +impl> PartialOrd for ArrayString { + fn partial_cmp(&self, rhs: &str) -> Option { + (**self).partial_cmp(rhs) + } + fn lt(&self, rhs: &str) -> bool { &**self < rhs } + fn le(&self, rhs: &str) -> bool { &**self <= rhs } + fn gt(&self, rhs: &str) -> bool { &**self > rhs } + fn ge(&self, rhs: &str) -> bool { &**self >= rhs } +} + +impl> PartialOrd> for str { + fn partial_cmp(&self, rhs: &ArrayString) -> Option { + self.partial_cmp(&**rhs) + } + fn lt(&self, rhs: &ArrayString) -> bool { self < &**rhs } + fn le(&self, rhs: &ArrayString) -> bool { self <= &**rhs } + fn gt(&self, rhs: &ArrayString) -> bool { self > &**rhs } + fn ge(&self, rhs: &ArrayString) -> bool { self >= &**rhs } +} + +impl> Ord for ArrayString { + fn cmp(&self, rhs: &Self) -> cmp::Ordering { + (**self).cmp(&**rhs) + } +} + +#[cfg(feature="serde-1")] +/// Requires crate feature `"serde-1"` +impl> Serialize for ArrayString { + fn serialize(&self, serializer: S) -> Result + where S: Serializer + { + serializer.serialize_str(&*self) + } +} + +#[cfg(feature="serde-1")] +/// Requires crate feature `"serde-1"` +impl<'de, A: Array> Deserialize<'de> for ArrayString { + fn deserialize(deserializer: D) -> Result + where D: Deserializer<'de> + { + use serde::de::{self, Visitor}; + use std::marker::PhantomData; + + struct ArrayStringVisitor>(PhantomData); + + impl<'de, A: Array> Visitor<'de> for ArrayStringVisitor { + type Value = ArrayString; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!(formatter, "a string no more than {} bytes long", A::capacity()) + } + + fn visit_str(self, v: &str) -> Result + where E: de::Error, + { + ArrayString::from(v).map_err(|_| E::invalid_length(v.len(), &self)) + } + + fn visit_bytes(self, v: &[u8]) -> Result + where E: de::Error, + { + let s = try!(str::from_utf8(v).map_err(|_| E::invalid_value(de::Unexpected::Bytes(v), &self))); + + ArrayString::from(s).map_err(|_| E::invalid_length(s.len(), &self)) + } + } + + deserializer.deserialize_str(ArrayStringVisitor::(PhantomData)) + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/src/char.rs b/third_party/cargo/vendor/arrayvec-0.4.12/src/char.rs new file mode 100644 index 0000000..8191dfb --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/src/char.rs @@ -0,0 +1,54 @@ +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// Original authors: alexchrichton, bluss + +// UTF-8 ranges and tags for encoding characters +const TAG_CONT: u8 = 0b1000_0000; +const TAG_TWO_B: u8 = 0b1100_0000; +const TAG_THREE_B: u8 = 0b1110_0000; +const TAG_FOUR_B: u8 = 0b1111_0000; +const MAX_ONE_B: u32 = 0x80; +const MAX_TWO_B: u32 = 0x800; +const MAX_THREE_B: u32 = 0x10000; + +/// Placeholder +pub struct EncodeUtf8Error; + +/// Encode a char into buf using UTF-8. +/// +/// On success, return the byte length of the encoding (1, 2, 3 or 4).
+/// On error, return `EncodeUtf8Error` if the buffer was too short for the char. +#[inline] +pub fn encode_utf8(ch: char, buf: &mut [u8]) -> Result +{ + let code = ch as u32; + if code < MAX_ONE_B && buf.len() >= 1 { + buf[0] = code as u8; + return Ok(1); + } else if code < MAX_TWO_B && buf.len() >= 2 { + buf[0] = (code >> 6 & 0x1F) as u8 | TAG_TWO_B; + buf[1] = (code & 0x3F) as u8 | TAG_CONT; + return Ok(2); + } else if code < MAX_THREE_B && buf.len() >= 3 { + buf[0] = (code >> 12 & 0x0F) as u8 | TAG_THREE_B; + buf[1] = (code >> 6 & 0x3F) as u8 | TAG_CONT; + buf[2] = (code & 0x3F) as u8 | TAG_CONT; + return Ok(3); + } else if buf.len() >= 4 { + buf[0] = (code >> 18 & 0x07) as u8 | TAG_FOUR_B; + buf[1] = (code >> 12 & 0x3F) as u8 | TAG_CONT; + buf[2] = (code >> 6 & 0x3F) as u8 | TAG_CONT; + buf[3] = (code & 0x3F) as u8 | TAG_CONT; + return Ok(4); + }; + Err(EncodeUtf8Error) +} + diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/src/errors.rs b/third_party/cargo/vendor/arrayvec-0.4.12/src/errors.rs new file mode 100644 index 0000000..5bea980 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/src/errors.rs @@ -0,0 +1,53 @@ +use std::fmt; +#[cfg(feature="std")] +use std::any::Any; +#[cfg(feature="std")] +use std::error::Error; + +/// Error value indicating insufficient capacity +#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] +pub struct CapacityError { + element: T, +} + +impl CapacityError { + /// Create a new `CapacityError` from `element`. + pub fn new(element: T) -> CapacityError { + CapacityError { + element: element, + } + } + + /// Extract the overflowing element + pub fn element(self) -> T { + self.element + } + + /// Convert into a `CapacityError` that does not carry an element. + pub fn simplify(self) -> CapacityError { + CapacityError { element: () } + } +} + +const CAPERROR: &'static str = "insufficient capacity"; + +#[cfg(feature="std")] +/// Requires `features="std"`. +impl Error for CapacityError { + fn description(&self) -> &str { + CAPERROR + } +} + +impl fmt::Display for CapacityError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", CAPERROR) + } +} + +impl fmt::Debug for CapacityError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}: {}", "CapacityError", CAPERROR) + } +} + diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/src/lib.rs b/third_party/cargo/vendor/arrayvec-0.4.12/src/lib.rs new file mode 100644 index 0000000..efd5ebd --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/src/lib.rs @@ -0,0 +1,1084 @@ +//! **arrayvec** provides the types `ArrayVec` and `ArrayString`: +//! array-backed vector and string types, which store their contents inline. +//! +//! The arrayvec package has the following cargo features: +//! +//! - `std` +//! - Optional, enabled by default +//! - Use libstd; disable to use `no_std` instead. +//! +//! - `serde-1` +//! - Optional +//! - Enable serialization for ArrayVec and ArrayString using serde 1.0 +//! - `array-sizes-33-128`, `array-sizes-129-255` +//! - Optional +//! - Enable more array sizes (see [Array] for more information) +//! +//! ## Rust Version +//! +//! This version of arrayvec requires Rust 1.13 or later. +//! +#![doc(html_root_url="https://docs.rs/arrayvec/0.4/")] +#![cfg_attr(not(feature="std"), no_std)] +#![cfg_attr(has_union_feature, feature(untagged_unions))] + +#[cfg(feature="serde-1")] +extern crate serde; + +#[cfg(not(feature="std"))] +extern crate core as std; + +#[cfg(not(has_manually_drop_in_union))] +extern crate nodrop; + +use std::cmp; +use std::iter; +use std::mem; +use std::ptr; +use std::ops::{ + Deref, + DerefMut, +}; +use std::slice; + +// extra traits +use std::borrow::{Borrow, BorrowMut}; +use std::hash::{Hash, Hasher}; +use std::fmt; + +#[cfg(feature="std")] +use std::io; + + +#[cfg(has_stable_maybe_uninit)] +#[path="maybe_uninit_stable.rs"] +mod maybe_uninit; +#[cfg(all(not(has_stable_maybe_uninit), has_manually_drop_in_union))] +mod maybe_uninit; +#[cfg(all(not(has_stable_maybe_uninit), not(has_manually_drop_in_union)))] +#[path="maybe_uninit_nodrop.rs"] +mod maybe_uninit; + +use maybe_uninit::MaybeUninit; + +#[cfg(feature="serde-1")] +use serde::{Serialize, Deserialize, Serializer, Deserializer}; + +mod array; +mod array_string; +mod char; +mod range; +mod errors; + +pub use array::Array; +pub use range::RangeArgument; +use array::Index; +pub use array_string::ArrayString; +pub use errors::CapacityError; + + +/// A vector with a fixed capacity. +/// +/// The `ArrayVec` is a vector backed by a fixed size array. It keeps track of +/// the number of initialized elements. +/// +/// The vector is a contiguous value that you can store directly on the stack +/// if needed. +/// +/// It offers a simple API but also dereferences to a slice, so +/// that the full slice API is available. +/// +/// ArrayVec can be converted into a by value iterator. +pub struct ArrayVec { + xs: MaybeUninit
, + len: A::Index, +} + +impl Drop for ArrayVec { + fn drop(&mut self) { + self.clear(); + + // NoDrop inhibits array's drop + // panic safety: NoDrop::drop will trigger on panic, so the inner + // array will not drop even after panic. + } +} + +macro_rules! panic_oob { + ($method_name:expr, $index:expr, $len:expr) => { + panic!(concat!("ArrayVec::", $method_name, ": index {} is out of bounds in vector of length {}"), + $index, $len) + } +} + +impl ArrayVec { + /// Create a new empty `ArrayVec`. + /// + /// Capacity is inferred from the type parameter. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 16]>::new(); + /// array.push(1); + /// array.push(2); + /// assert_eq!(&array[..], &[1, 2]); + /// assert_eq!(array.capacity(), 16); + /// ``` + pub fn new() -> ArrayVec { + unsafe { + ArrayVec { xs: MaybeUninit::uninitialized(), len: Index::from(0) } + } + } + + /// Return the number of elements in the `ArrayVec`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// array.pop(); + /// assert_eq!(array.len(), 2); + /// ``` + #[inline] + pub fn len(&self) -> usize { self.len.to_usize() } + + /// Return the capacity of the `ArrayVec`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let array = ArrayVec::from([1, 2, 3]); + /// assert_eq!(array.capacity(), 3); + /// ``` + #[inline] + pub fn capacity(&self) -> usize { A::capacity() } + + /// Return if the `ArrayVec` is completely filled. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 1]>::new(); + /// assert!(!array.is_full()); + /// array.push(1); + /// assert!(array.is_full()); + /// ``` + pub fn is_full(&self) -> bool { self.len() == self.capacity() } + + /// Push `element` to the end of the vector. + /// + /// ***Panics*** if the vector is already full. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// array.push(1); + /// array.push(2); + /// + /// assert_eq!(&array[..], &[1, 2]); + /// ``` + pub fn push(&mut self, element: A::Item) { + self.try_push(element).unwrap() + } + + /// Push `element` to the end of the vector. + /// + /// Return `Ok` if the push succeeds, or return an error if the vector + /// is already full. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// let push1 = array.try_push(1); + /// let push2 = array.try_push(2); + /// + /// assert!(push1.is_ok()); + /// assert!(push2.is_ok()); + /// + /// assert_eq!(&array[..], &[1, 2]); + /// + /// let overflow = array.try_push(3); + /// + /// assert!(overflow.is_err()); + /// ``` + pub fn try_push(&mut self, element: A::Item) -> Result<(), CapacityError> { + if self.len() < A::capacity() { + unsafe { + self.push_unchecked(element); + } + Ok(()) + } else { + Err(CapacityError::new(element)) + } + } + + + /// Push `element` to the end of the vector without checking the capacity. + /// + /// It is up to the caller to ensure the capacity of the vector is + /// sufficiently large. + /// + /// This method uses *debug assertions* to check that the arrayvec is not full. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// if array.len() + 2 <= array.capacity() { + /// unsafe { + /// array.push_unchecked(1); + /// array.push_unchecked(2); + /// } + /// } + /// + /// assert_eq!(&array[..], &[1, 2]); + /// ``` + #[inline] + pub unsafe fn push_unchecked(&mut self, element: A::Item) { + let len = self.len(); + debug_assert!(len < A::capacity()); + ptr::write(self.get_unchecked_ptr(len), element); + self.set_len(len + 1); + } + + /// Get pointer to where element at `index` would be + unsafe fn get_unchecked_ptr(&mut self, index: usize) -> *mut A::Item { + self.xs.ptr_mut().offset(index as isize) + } + + /// Insert `element` at position `index`. + /// + /// Shift up all elements after `index`. + /// + /// It is an error if the index is greater than the length or if the + /// arrayvec is full. + /// + /// ***Panics*** if the array is full or the `index` is out of bounds. See + /// `try_insert` for fallible version. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// array.insert(0, "x"); + /// array.insert(0, "y"); + /// assert_eq!(&array[..], &["y", "x"]); + /// + /// ``` + pub fn insert(&mut self, index: usize, element: A::Item) { + self.try_insert(index, element).unwrap() + } + + /// Insert `element` at position `index`. + /// + /// Shift up all elements after `index`; the `index` must be less than + /// or equal to the length. + /// + /// Returns an error if vector is already at full capacity. + /// + /// ***Panics*** `index` is out of bounds. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// assert!(array.try_insert(0, "x").is_ok()); + /// assert!(array.try_insert(0, "y").is_ok()); + /// assert!(array.try_insert(0, "z").is_err()); + /// assert_eq!(&array[..], &["y", "x"]); + /// + /// ``` + pub fn try_insert(&mut self, index: usize, element: A::Item) -> Result<(), CapacityError> { + if index > self.len() { + panic_oob!("try_insert", index, self.len()) + } + if self.len() == self.capacity() { + return Err(CapacityError::new(element)); + } + let len = self.len(); + + // follows is just like Vec + unsafe { // infallible + // The spot to put the new value + { + let p: *mut _ = self.get_unchecked_ptr(index); + // Shift everything over to make space. (Duplicating the + // `index`th element into two consecutive places.) + ptr::copy(p, p.offset(1), len - index); + // Write it in, overwriting the first copy of the `index`th + // element. + ptr::write(p, element); + } + self.set_len(len + 1); + } + Ok(()) + } + + /// Remove the last element in the vector and return it. + /// + /// Return `Some(` *element* `)` if the vector is non-empty, else `None`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// array.push(1); + /// + /// assert_eq!(array.pop(), Some(1)); + /// assert_eq!(array.pop(), None); + /// ``` + pub fn pop(&mut self) -> Option { + if self.len() == 0 { + return None + } + unsafe { + let new_len = self.len() - 1; + self.set_len(new_len); + Some(ptr::read(self.get_unchecked_ptr(new_len))) + } + } + + /// Remove the element at `index` and swap the last element into its place. + /// + /// This operation is O(1). + /// + /// Return the *element* if the index is in bounds, else panic. + /// + /// ***Panics*** if the `index` is out of bounds. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// + /// assert_eq!(array.swap_remove(0), 1); + /// assert_eq!(&array[..], &[3, 2]); + /// + /// assert_eq!(array.swap_remove(1), 2); + /// assert_eq!(&array[..], &[3]); + /// ``` + pub fn swap_remove(&mut self, index: usize) -> A::Item { + self.swap_pop(index) + .unwrap_or_else(|| { + panic_oob!("swap_remove", index, self.len()) + }) + } + + /// Remove the element at `index` and swap the last element into its place. + /// + /// This is a checked version of `.swap_remove`. + /// This operation is O(1). + /// + /// Return `Some(` *element* `)` if the index is in bounds, else `None`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// + /// assert_eq!(array.swap_pop(0), Some(1)); + /// assert_eq!(&array[..], &[3, 2]); + /// + /// assert_eq!(array.swap_pop(10), None); + /// ``` + pub fn swap_pop(&mut self, index: usize) -> Option { + let len = self.len(); + if index >= len { + return None; + } + self.swap(index, len - 1); + self.pop() + } + + /// Remove the element at `index` and shift down the following elements. + /// + /// The `index` must be strictly less than the length of the vector. + /// + /// ***Panics*** if the `index` is out of bounds. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// + /// let removed_elt = array.remove(0); + /// assert_eq!(removed_elt, 1); + /// assert_eq!(&array[..], &[2, 3]); + /// ``` + pub fn remove(&mut self, index: usize) -> A::Item { + self.pop_at(index) + .unwrap_or_else(|| { + panic_oob!("remove", index, self.len()) + }) + } + + /// Remove the element at `index` and shift down the following elements. + /// + /// This is a checked version of `.remove(index)`. Returns `None` if there + /// is no element at `index`. Otherwise, return the element inside `Some`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// + /// assert!(array.pop_at(0).is_some()); + /// assert_eq!(&array[..], &[2, 3]); + /// + /// assert!(array.pop_at(2).is_none()); + /// assert!(array.pop_at(10).is_none()); + /// ``` + pub fn pop_at(&mut self, index: usize) -> Option { + if index >= self.len() { + None + } else { + self.drain(index..index + 1).next() + } + } + + /// Shortens the vector, keeping the first `len` elements and dropping + /// the rest. + /// + /// If `len` is greater than the vector’s current length this has no + /// effect. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3, 4, 5]); + /// array.truncate(3); + /// assert_eq!(&array[..], &[1, 2, 3]); + /// array.truncate(4); + /// assert_eq!(&array[..], &[1, 2, 3]); + /// ``` + pub fn truncate(&mut self, len: usize) { + while self.len() > len { self.pop(); } + } + + /// Remove all elements in the vector. + pub fn clear(&mut self) { + while let Some(_) = self.pop() { } + } + + /// Retains only the elements specified by the predicate. + /// + /// In other words, remove all elements `e` such that `f(&mut e)` returns false. + /// This method operates in place and preserves the order of the retained + /// elements. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3, 4]); + /// array.retain(|x| *x & 1 != 0 ); + /// assert_eq!(&array[..], &[1, 3]); + /// ``` + pub fn retain(&mut self, mut f: F) + where F: FnMut(&mut A::Item) -> bool + { + let len = self.len(); + let mut del = 0; + { + let v = &mut **self; + + for i in 0..len { + if !f(&mut v[i]) { + del += 1; + } else if del > 0 { + v.swap(i - del, i); + } + } + } + if del > 0 { + self.drain(len - del..); + } + } + + /// Set the vector’s length without dropping or moving out elements + /// + /// This method is `unsafe` because it changes the notion of the + /// number of “valid” elements in the vector. Use with care. + /// + /// This method uses *debug assertions* to check that check that `length` is + /// not greater than the capacity. + #[inline] + pub unsafe fn set_len(&mut self, length: usize) { + debug_assert!(length <= self.capacity()); + self.len = Index::from(length); + } + + /// Create a draining iterator that removes the specified range in the vector + /// and yields the removed items from start to end. The element range is + /// removed even if the iterator is not consumed until the end. + /// + /// Note: It is unspecified how many elements are removed from the vector, + /// if the `Drain` value is leaked. + /// + /// **Panics** if the starting point is greater than the end point or if + /// the end point is greater than the length of the vector. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut v = ArrayVec::from([1, 2, 3]); + /// let u: ArrayVec<[_; 3]> = v.drain(0..2).collect(); + /// assert_eq!(&v[..], &[3]); + /// assert_eq!(&u[..], &[1, 2]); + /// ``` + pub fn drain(&mut self, range: R) -> Drain { + // Memory safety + // + // When the Drain is first created, it shortens the length of + // the source vector to make sure no uninitalized or moved-from elements + // are accessible at all if the Drain's destructor never gets to run. + // + // Drain will ptr::read out the values to remove. + // When finished, remaining tail of the vec is copied back to cover + // the hole, and the vector length is restored to the new length. + // + let len = self.len(); + let start = range.start().unwrap_or(0); + let end = range.end().unwrap_or(len); + // bounds check happens here + let range_slice: *const _ = &self[start..end]; + + unsafe { + // set self.vec length's to start, to be safe in case Drain is leaked + self.set_len(start); + Drain { + tail_start: end, + tail_len: len - end, + iter: (*range_slice).iter(), + vec: self as *mut _, + } + } + } + + /// Return the inner fixed size array, if it is full to its capacity. + /// + /// Return an `Ok` value with the array if length equals capacity, + /// return an `Err` with self otherwise. + /// + /// `Note:` This function may incur unproportionally large overhead + /// to move the array out, its performance is not optimal. + pub fn into_inner(self) -> Result { + if self.len() < self.capacity() { + Err(self) + } else { + unsafe { + let array = ptr::read(self.xs.ptr() as *const A); + mem::forget(self); + Ok(array) + } + } + } + + /// Dispose of `self` without the overwriting that is needed in Drop. + pub fn dispose(mut self) { + self.clear(); + mem::forget(self); + } + + /// Return a slice containing all elements of the vector. + pub fn as_slice(&self) -> &[A::Item] { + self + } + + /// Return a mutable slice containing all elements of the vector. + pub fn as_mut_slice(&mut self) -> &mut [A::Item] { + self + } +} + +impl Deref for ArrayVec { + type Target = [A::Item]; + #[inline] + fn deref(&self) -> &[A::Item] { + unsafe { + slice::from_raw_parts(self.xs.ptr(), self.len()) + } + } +} + +impl DerefMut for ArrayVec { + #[inline] + fn deref_mut(&mut self) -> &mut [A::Item] { + let len = self.len(); + unsafe { + slice::from_raw_parts_mut(self.xs.ptr_mut(), len) + } + } +} + +/// Create an `ArrayVec` from an array. +/// +/// ``` +/// use arrayvec::ArrayVec; +/// +/// let mut array = ArrayVec::from([1, 2, 3]); +/// assert_eq!(array.len(), 3); +/// assert_eq!(array.capacity(), 3); +/// ``` +impl From for ArrayVec { + fn from(array: A) -> Self { + ArrayVec { xs: MaybeUninit::from(array), len: Index::from(A::capacity()) } + } +} + + +/// Iterate the `ArrayVec` with references to each element. +/// +/// ``` +/// use arrayvec::ArrayVec; +/// +/// let array = ArrayVec::from([1, 2, 3]); +/// +/// for elt in &array { +/// // ... +/// } +/// ``` +impl<'a, A: Array> IntoIterator for &'a ArrayVec { + type Item = &'a A::Item; + type IntoIter = slice::Iter<'a, A::Item>; + fn into_iter(self) -> Self::IntoIter { self.iter() } +} + +/// Iterate the `ArrayVec` with mutable references to each element. +/// +/// ``` +/// use arrayvec::ArrayVec; +/// +/// let mut array = ArrayVec::from([1, 2, 3]); +/// +/// for elt in &mut array { +/// // ... +/// } +/// ``` +impl<'a, A: Array> IntoIterator for &'a mut ArrayVec { + type Item = &'a mut A::Item; + type IntoIter = slice::IterMut<'a, A::Item>; + fn into_iter(self) -> Self::IntoIter { self.iter_mut() } +} + +/// Iterate the `ArrayVec` with each element by value. +/// +/// The vector is consumed by this operation. +/// +/// ``` +/// use arrayvec::ArrayVec; +/// +/// for elt in ArrayVec::from([1, 2, 3]) { +/// // ... +/// } +/// ``` +impl IntoIterator for ArrayVec { + type Item = A::Item; + type IntoIter = IntoIter; + fn into_iter(self) -> IntoIter { + IntoIter { index: Index::from(0), v: self, } + } +} + + +/// By-value iterator for `ArrayVec`. +pub struct IntoIter { + index: A::Index, + v: ArrayVec, +} + +impl Iterator for IntoIter { + type Item = A::Item; + + #[inline] + fn next(&mut self) -> Option { + if self.index == self.v.len { + None + } else { + unsafe { + let index = self.index.to_usize(); + self.index = Index::from(index + 1); + Some(ptr::read(self.v.get_unchecked_ptr(index))) + } + } + } + + fn size_hint(&self) -> (usize, Option) { + let len = self.v.len() - self.index.to_usize(); + (len, Some(len)) + } +} + +impl DoubleEndedIterator for IntoIter { + #[inline] + fn next_back(&mut self) -> Option { + if self.index == self.v.len { + None + } else { + unsafe { + let new_len = self.v.len() - 1; + self.v.set_len(new_len); + Some(ptr::read(self.v.get_unchecked_ptr(new_len))) + } + } + } +} + +impl ExactSizeIterator for IntoIter { } + +impl Drop for IntoIter { + fn drop(&mut self) { + // panic safety: Set length to 0 before dropping elements. + let index = self.index.to_usize(); + let len = self.v.len(); + unsafe { + self.v.set_len(0); + let elements = slice::from_raw_parts_mut( + self.v.get_unchecked_ptr(index), + len - index); + ptr::drop_in_place(elements); + } + } +} + +impl Clone for IntoIter +where + A::Item: Clone, +{ + fn clone(&self) -> IntoIter { + self.v[self.index.to_usize()..] + .iter() + .cloned() + .collect::>() + .into_iter() + } +} + +impl fmt::Debug for IntoIter +where + A::Item: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_list() + .entries(&self.v[self.index.to_usize()..]) + .finish() + } +} + +/// A draining iterator for `ArrayVec`. +pub struct Drain<'a, A> + where A: Array, + A::Item: 'a, +{ + /// Index of tail to preserve + tail_start: usize, + /// Length of tail + tail_len: usize, + /// Current remaining range to remove + iter: slice::Iter<'a, A::Item>, + vec: *mut ArrayVec, +} + +unsafe impl<'a, A: Array + Sync> Sync for Drain<'a, A> {} +unsafe impl<'a, A: Array + Send> Send for Drain<'a, A> {} + +impl<'a, A: Array> Iterator for Drain<'a, A> + where A::Item: 'a, +{ + type Item = A::Item; + + #[inline] + fn next(&mut self) -> Option { + self.iter.next().map(|elt| + unsafe { + ptr::read(elt as *const _) + } + ) + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } +} + +impl<'a, A: Array> DoubleEndedIterator for Drain<'a, A> + where A::Item: 'a, +{ + #[inline] + fn next_back(&mut self) -> Option { + self.iter.next_back().map(|elt| + unsafe { + ptr::read(elt as *const _) + } + ) + } +} + +impl<'a, A: Array> ExactSizeIterator for Drain<'a, A> where A::Item: 'a {} + +impl<'a, A: Array> Drop for Drain<'a, A> + where A::Item: 'a +{ + fn drop(&mut self) { + // len is currently 0 so panicking while dropping will not cause a double drop. + + // exhaust self first + while let Some(_) = self.next() { } + + if self.tail_len > 0 { + unsafe { + let source_vec = &mut *self.vec; + // memmove back untouched tail, update to new length + let start = source_vec.len(); + let tail = self.tail_start; + let src = source_vec.as_ptr().offset(tail as isize); + let dst = source_vec.as_mut_ptr().offset(start as isize); + ptr::copy(src, dst, self.tail_len); + source_vec.set_len(start + self.tail_len); + } + } + } +} + +struct ScopeExitGuard + where F: FnMut(&Data, &mut T) +{ + value: T, + data: Data, + f: F, +} + +impl Drop for ScopeExitGuard + where F: FnMut(&Data, &mut T) +{ + fn drop(&mut self) { + (self.f)(&self.data, &mut self.value) + } +} + + + +/// Extend the `ArrayVec` with an iterator. +/// +/// Does not extract more items than there is space for. No error +/// occurs if there are more iterator elements. +impl Extend for ArrayVec { + fn extend>(&mut self, iter: T) { + let take = self.capacity() - self.len(); + unsafe { + let len = self.len(); + let mut ptr = self.as_mut_ptr().offset(len as isize); + // Keep the length in a separate variable, write it back on scope + // exit. To help the compiler with alias analysis and stuff. + // We update the length to handle panic in the iteration of the + // user's iterator, without dropping any elements on the floor. + let mut guard = ScopeExitGuard { + value: self, + data: len, + f: |&len, self_| { + self_.set_len(len) + } + }; + for elt in iter.into_iter().take(take) { + ptr::write(ptr, elt); + ptr = ptr.offset(1); + guard.data += 1; + } + } + } +} + +/// Create an `ArrayVec` from an iterator. +/// +/// Does not extract more items than there is space for. No error +/// occurs if there are more iterator elements. +impl iter::FromIterator for ArrayVec { + fn from_iter>(iter: T) -> Self { + let mut array = ArrayVec::new(); + array.extend(iter); + array + } +} + +impl Clone for ArrayVec + where A::Item: Clone +{ + fn clone(&self) -> Self { + self.iter().cloned().collect() + } + + fn clone_from(&mut self, rhs: &Self) { + // recursive case for the common prefix + let prefix = cmp::min(self.len(), rhs.len()); + self[..prefix].clone_from_slice(&rhs[..prefix]); + + if prefix < self.len() { + // rhs was shorter + for _ in 0..self.len() - prefix { + self.pop(); + } + } else { + let rhs_elems = rhs[self.len()..].iter().cloned(); + self.extend(rhs_elems); + } + } +} + +impl Hash for ArrayVec + where A::Item: Hash +{ + fn hash(&self, state: &mut H) { + Hash::hash(&**self, state) + } +} + +impl PartialEq for ArrayVec + where A::Item: PartialEq +{ + fn eq(&self, other: &Self) -> bool { + **self == **other + } +} + +impl PartialEq<[A::Item]> for ArrayVec + where A::Item: PartialEq +{ + fn eq(&self, other: &[A::Item]) -> bool { + **self == *other + } +} + +impl Eq for ArrayVec where A::Item: Eq { } + +impl Borrow<[A::Item]> for ArrayVec { + fn borrow(&self) -> &[A::Item] { self } +} + +impl BorrowMut<[A::Item]> for ArrayVec { + fn borrow_mut(&mut self) -> &mut [A::Item] { self } +} + +impl AsRef<[A::Item]> for ArrayVec { + fn as_ref(&self) -> &[A::Item] { self } +} + +impl AsMut<[A::Item]> for ArrayVec { + fn as_mut(&mut self) -> &mut [A::Item] { self } +} + +impl fmt::Debug for ArrayVec where A::Item: fmt::Debug { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } +} + +impl Default for ArrayVec { + /// Return an empty array + fn default() -> ArrayVec { + ArrayVec::new() + } +} + +impl PartialOrd for ArrayVec where A::Item: PartialOrd { + #[inline] + fn partial_cmp(&self, other: &ArrayVec) -> Option { + (**self).partial_cmp(other) + } + + #[inline] + fn lt(&self, other: &Self) -> bool { + (**self).lt(other) + } + + #[inline] + fn le(&self, other: &Self) -> bool { + (**self).le(other) + } + + #[inline] + fn ge(&self, other: &Self) -> bool { + (**self).ge(other) + } + + #[inline] + fn gt(&self, other: &Self) -> bool { + (**self).gt(other) + } +} + +impl Ord for ArrayVec where A::Item: Ord { + fn cmp(&self, other: &ArrayVec) -> cmp::Ordering { + (**self).cmp(other) + } +} + +#[cfg(feature="std")] +/// `Write` appends written data to the end of the vector. +/// +/// Requires `features="std"`. +impl> io::Write for ArrayVec { + fn write(&mut self, data: &[u8]) -> io::Result { + unsafe { + let len = self.len(); + let write_len = cmp::min(A::capacity() - len, data.len()); + ptr::copy_nonoverlapping(data.as_ptr(), self.get_unchecked_ptr(len), write_len); + self.set_len(len + write_len); + Ok(write_len) + } + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } +} + +#[cfg(feature="serde-1")] +/// Requires crate feature `"serde-1"` +impl> Serialize for ArrayVec { + fn serialize(&self, serializer: S) -> Result + where S: Serializer + { + serializer.collect_seq(self) + } +} + +#[cfg(feature="serde-1")] +/// Requires crate feature `"serde-1"` +impl<'de, T: Deserialize<'de>, A: Array> Deserialize<'de> for ArrayVec { + fn deserialize(deserializer: D) -> Result + where D: Deserializer<'de> + { + use serde::de::{Visitor, SeqAccess, Error}; + use std::marker::PhantomData; + + struct ArrayVecVisitor<'de, T: Deserialize<'de>, A: Array>(PhantomData<(&'de (), T, A)>); + + impl<'de, T: Deserialize<'de>, A: Array> Visitor<'de> for ArrayVecVisitor<'de, T, A> { + type Value = ArrayVec; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!(formatter, "an array with no more than {} items", A::capacity()) + } + + fn visit_seq(self, mut seq: SA) -> Result + where SA: SeqAccess<'de>, + { + let mut values = ArrayVec::::new(); + + while let Some(value) = try!(seq.next_element()) { + if let Err(_) = values.try_push(value) { + return Err(SA::Error::invalid_length(A::capacity() + 1, &self)); + } + } + + Ok(values) + } + } + + deserializer.deserialize_seq(ArrayVecVisitor::(PhantomData)) + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/src/maybe_uninit.rs b/third_party/cargo/vendor/arrayvec-0.4.12/src/maybe_uninit.rs new file mode 100644 index 0000000..9ed1f6a --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/src/maybe_uninit.rs @@ -0,0 +1,46 @@ + + +use array::Array; +use std::mem::ManuallyDrop; + +/// A combination of ManuallyDrop and “maybe uninitialized”; +/// this wraps a value that can be wholly or partially uninitialized; +/// it also has no drop regardless of the type of T. +#[repr(C)] // for cast from self ptr to value +pub union MaybeUninit { + empty: (), + value: ManuallyDrop, +} +// Why we don't use std's MaybeUninit on nightly? See the ptr method + +impl MaybeUninit { + /// Create a new MaybeUninit with uninitialized interior + pub unsafe fn uninitialized() -> Self { + MaybeUninit { empty: () } + } + + /// Create a new MaybeUninit from the value `v`. + pub fn from(v: T) -> Self { + MaybeUninit { value: ManuallyDrop::new(v) } + } + + // Raw pointer casts written so that we don't reference or access the + // uninitialized interior value + + /// Return a raw pointer to the start of the interior array + pub fn ptr(&self) -> *const T::Item + where T: Array + { + // std MaybeUninit creates a &self.value reference here which is + // not guaranteed to be sound in our case - we will partially + // initialize the value, not always wholly. + self as *const _ as *const T::Item + } + + /// Return a mut raw pointer to the start of the interior array + pub fn ptr_mut(&mut self) -> *mut T::Item + where T: Array + { + self as *mut _ as *mut T::Item + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/src/maybe_uninit_nodrop.rs b/third_party/cargo/vendor/arrayvec-0.4.12/src/maybe_uninit_nodrop.rs new file mode 100644 index 0000000..8213b97 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/src/maybe_uninit_nodrop.rs @@ -0,0 +1,41 @@ + +use array::Array; +use nodrop::NoDrop; +use std::mem::uninitialized; + +/// A combination of NoDrop and “maybe uninitialized”; +/// this wraps a value that can be wholly or partially uninitialized. +/// +/// NOTE: This is known to not be a good solution, but it's the one we have kept +/// working on stable Rust. Stable improvements are encouraged, in any form, +/// but of course we are waiting for a real, stable, MaybeUninit. +pub struct MaybeUninit(NoDrop); +// why don't we use ManuallyDrop here: It doesn't inhibit +// enum layout optimizations that depend on T, and we support older Rust. + +impl MaybeUninit { + /// Create a new MaybeUninit with uninitialized interior + pub unsafe fn uninitialized() -> Self { + Self::from(uninitialized()) + } + + /// Create a new MaybeUninit from the value `v`. + pub fn from(v: T) -> Self { + MaybeUninit(NoDrop::new(v)) + } + + /// Return a raw pointer to the start of the interior array + pub fn ptr(&self) -> *const T::Item + where T: Array + { + &*self.0 as *const T as *const _ + } + + /// Return a mut raw pointer to the start of the interior array + pub fn ptr_mut(&mut self) -> *mut T::Item + where T: Array + { + &mut *self.0 as *mut T as *mut _ + } +} + diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/src/maybe_uninit_stable.rs b/third_party/cargo/vendor/arrayvec-0.4.12/src/maybe_uninit_stable.rs new file mode 100644 index 0000000..cb631a9 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/src/maybe_uninit_stable.rs @@ -0,0 +1,40 @@ + + +use array::Array; +use std::mem::MaybeUninit as StdMaybeUninit; + +pub struct MaybeUninit { + inner: StdMaybeUninit, +} + +impl MaybeUninit { + /// Create a new MaybeUninit with uninitialized interior + pub unsafe fn uninitialized() -> Self { + MaybeUninit { inner: StdMaybeUninit::uninit() } + } + + /// Create a new MaybeUninit from the value `v`. + pub fn from(v: T) -> Self { + MaybeUninit { inner: StdMaybeUninit::new(v) } + } + + // Raw pointer casts written so that we don't reference or access the + // uninitialized interior value + + /// Return a raw pointer to the start of the interior array + pub fn ptr(&self) -> *const T::Item + where T: Array + { + // std MaybeUninit creates a &self.value reference here which is + // not guaranteed to be sound in our case - we will partially + // initialize the value, not always wholly. + self.inner.as_ptr() as *const T::Item + } + + /// Return a mut raw pointer to the start of the interior array + pub fn ptr_mut(&mut self) -> *mut T::Item + where T: Array + { + self.inner.as_mut_ptr() as *mut T::Item + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/src/range.rs b/third_party/cargo/vendor/arrayvec-0.4.12/src/range.rs new file mode 100644 index 0000000..f90f5af --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/src/range.rs @@ -0,0 +1,42 @@ + +use std::ops::{ + RangeFull, + RangeFrom, + RangeTo, + Range, +}; + +/// `RangeArgument` is implemented by Rust's built-in range types, produced +/// by range syntax like `..`, `a..`, `..b` or `c..d`. +/// +/// Note: This is arrayvec's provisional trait, waiting for stable Rust to +/// provide an equivalent. +pub trait RangeArgument { + #[inline] + /// Start index (inclusive) + fn start(&self) -> Option { None } + #[inline] + /// End index (exclusive) + fn end(&self) -> Option { None } +} + + +impl RangeArgument for RangeFull {} + +impl RangeArgument for RangeFrom { + #[inline] + fn start(&self) -> Option { Some(self.start) } +} + +impl RangeArgument for RangeTo { + #[inline] + fn end(&self) -> Option { Some(self.end) } +} + +impl RangeArgument for Range { + #[inline] + fn start(&self) -> Option { Some(self.start) } + #[inline] + fn end(&self) -> Option { Some(self.end) } +} + diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/tests/serde.rs b/third_party/cargo/vendor/arrayvec-0.4.12/tests/serde.rs new file mode 100644 index 0000000..62acf25 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/tests/serde.rs @@ -0,0 +1,79 @@ +#![cfg(feature = "serde-1")] +extern crate arrayvec; +extern crate serde_test; + +mod array_vec { + use arrayvec::ArrayVec; + + use serde_test::{Token, assert_tokens, assert_de_tokens_error}; + + #[test] + fn test_ser_de_empty() { + let vec = ArrayVec::<[u32; 0]>::new(); + + assert_tokens(&vec, &[ + Token::Seq { len: Some(0) }, + Token::SeqEnd, + ]); + } + + + #[test] + fn test_ser_de() { + let mut vec = ArrayVec::<[u32; 3]>::new(); + vec.push(20); + vec.push(55); + vec.push(123); + + assert_tokens(&vec, &[ + Token::Seq { len: Some(3) }, + Token::U32(20), + Token::U32(55), + Token::U32(123), + Token::SeqEnd, + ]); + } + + #[test] + fn test_de_too_large() { + assert_de_tokens_error::>(&[ + Token::Seq { len: Some(3) }, + Token::U32(13), + Token::U32(42), + Token::U32(68), + ], "invalid length 3, expected an array with no more than 2 items"); + } +} + +mod array_string { + use arrayvec::ArrayString; + + use serde_test::{Token, assert_tokens, assert_de_tokens_error}; + + #[test] + fn test_ser_de_empty() { + let string = ArrayString::<[u8; 0]>::new(); + + assert_tokens(&string, &[ + Token::Str(""), + ]); + } + + + #[test] + fn test_ser_de() { + let string = ArrayString::<[u8; 9]>::from("1234 abcd") + .expect("expected exact specified capacity to be enough"); + + assert_tokens(&string, &[ + Token::Str("1234 abcd"), + ]); + } + + #[test] + fn test_de_too_large() { + assert_de_tokens_error::>(&[ + Token::Str("afd") + ], "invalid length 3, expected a string no more than 2 bytes long"); + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.4.12/tests/tests.rs b/third_party/cargo/vendor/arrayvec-0.4.12/tests/tests.rs new file mode 100644 index 0000000..b8dbadb --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.4.12/tests/tests.rs @@ -0,0 +1,517 @@ +extern crate arrayvec; +#[macro_use] extern crate matches; + +use arrayvec::ArrayVec; +use arrayvec::ArrayString; +use std::mem; +use arrayvec::CapacityError; + +use std::collections::HashMap; + + +#[test] +fn test_simple() { + use std::ops::Add; + + let mut vec: ArrayVec<[Vec; 3]> = ArrayVec::new(); + + vec.push(vec![1, 2, 3, 4]); + vec.push(vec![10]); + vec.push(vec![-1, 13, -2]); + + for elt in &vec { + assert_eq!(elt.iter().fold(0, Add::add), 10); + } + + let sum_len = vec.into_iter().map(|x| x.len()).fold(0, Add::add); + assert_eq!(sum_len, 8); +} + +#[test] +fn test_u16_index() { + const N: usize = 4096; + let mut vec: ArrayVec<[_; N]> = ArrayVec::new(); + for _ in 0..N { + assert!(vec.try_push(1u8).is_ok()); + } + assert!(vec.try_push(0).is_err()); + assert_eq!(vec.len(), N); +} + +#[test] +fn test_iter() { + let mut iter = ArrayVec::from([1, 2, 3]).into_iter(); + assert_eq!(iter.size_hint(), (3, Some(3))); + assert_eq!(iter.next_back(), Some(3)); + assert_eq!(iter.next(), Some(1)); + assert_eq!(iter.next_back(), Some(2)); + assert_eq!(iter.size_hint(), (0, Some(0))); + assert_eq!(iter.next_back(), None); +} + +#[test] +fn test_drop() { + use std::cell::Cell; + + let flag = &Cell::new(0); + + #[derive(Clone)] + struct Bump<'a>(&'a Cell); + + impl<'a> Drop for Bump<'a> { + fn drop(&mut self) { + let n = self.0.get(); + self.0.set(n + 1); + } + } + + { + let mut array = ArrayVec::<[Bump; 128]>::new(); + array.push(Bump(flag)); + array.push(Bump(flag)); + } + assert_eq!(flag.get(), 2); + + // test something with the nullable pointer optimization + flag.set(0); + + { + let mut array = ArrayVec::<[_; 3]>::new(); + array.push(vec![Bump(flag)]); + array.push(vec![Bump(flag), Bump(flag)]); + array.push(vec![]); + let push4 = array.try_push(vec![Bump(flag)]); + assert_eq!(flag.get(), 0); + drop(push4); + assert_eq!(flag.get(), 1); + drop(array.pop()); + assert_eq!(flag.get(), 1); + drop(array.pop()); + assert_eq!(flag.get(), 3); + } + + assert_eq!(flag.get(), 4); + + // test into_inner + flag.set(0); + { + let mut array = ArrayVec::<[_; 3]>::new(); + array.push(Bump(flag)); + array.push(Bump(flag)); + array.push(Bump(flag)); + let inner = array.into_inner(); + assert!(inner.is_ok()); + assert_eq!(flag.get(), 0); + drop(inner); + assert_eq!(flag.get(), 3); + } + + // test cloning into_iter + flag.set(0); + { + let mut array = ArrayVec::<[_; 3]>::new(); + array.push(Bump(flag)); + array.push(Bump(flag)); + array.push(Bump(flag)); + let mut iter = array.into_iter(); + assert_eq!(flag.get(), 0); + iter.next(); + assert_eq!(flag.get(), 1); + let clone = iter.clone(); + assert_eq!(flag.get(), 1); + drop(clone); + assert_eq!(flag.get(), 3); + drop(iter); + assert_eq!(flag.get(), 5); + } +} + +#[test] +fn test_extend() { + let mut range = 0..10; + + let mut array: ArrayVec<[_; 5]> = range.by_ref().collect(); + assert_eq!(&array[..], &[0, 1, 2, 3, 4]); + assert_eq!(range.next(), Some(5)); + + array.extend(range.by_ref()); + assert_eq!(range.next(), Some(6)); + + let mut array: ArrayVec<[_; 10]> = (0..3).collect(); + assert_eq!(&array[..], &[0, 1, 2]); + array.extend(3..5); + assert_eq!(&array[..], &[0, 1, 2, 3, 4]); +} + +#[test] +fn test_is_send_sync() { + let data = ArrayVec::<[Vec; 5]>::new(); + &data as &Send; + &data as &Sync; +} + +#[test] +fn test_compact_size() { + // Future rust will kill these drop flags! + // 4 elements size + 1 len + 1 enum tag + [1 drop flag] + type ByteArray = ArrayVec<[u8; 4]>; + println!("{}", mem::size_of::()); + assert!(mem::size_of::() <= 8); + + // 12 element size + 1 enum tag + 3 padding + 1 len + 1 drop flag + 2 padding + type QuadArray = ArrayVec<[u32; 3]>; + println!("{}", mem::size_of::()); + assert!(mem::size_of::() <= 24); +} + +#[test] +fn test_still_works_with_option_arrayvec() { + type RefArray = ArrayVec<[&'static i32; 2]>; + let array = Some(RefArray::new()); + assert!(array.is_some()); + println!("{:?}", array); +} + +#[test] +fn test_drain() { + let mut v = ArrayVec::from([0; 8]); + v.pop(); + v.drain(0..7); + assert_eq!(&v[..], &[]); + + v.extend(0..); + v.drain(1..4); + assert_eq!(&v[..], &[0, 4, 5, 6, 7]); + let u: ArrayVec<[_; 3]> = v.drain(1..4).rev().collect(); + assert_eq!(&u[..], &[6, 5, 4]); + assert_eq!(&v[..], &[0, 7]); + v.drain(..); + assert_eq!(&v[..], &[]); +} + +#[test] +fn test_retain() { + let mut v = ArrayVec::from([0; 8]); + for (i, elt) in v.iter_mut().enumerate() { + *elt = i; + } + v.retain(|_| true); + assert_eq!(&v[..], &[0, 1, 2, 3, 4, 5, 6, 7]); + v.retain(|elt| { + *elt /= 2; + *elt % 2 == 0 + }); + assert_eq!(&v[..], &[0, 0, 2, 2]); + v.retain(|_| false); + assert_eq!(&v[..], &[]); +} + +#[test] +#[should_panic] +fn test_drain_oob() { + let mut v = ArrayVec::from([0; 8]); + v.pop(); + v.drain(0..8); +} + +#[test] +#[should_panic] +fn test_drop_panic() { + struct DropPanic; + + impl Drop for DropPanic { + fn drop(&mut self) { + panic!("drop"); + } + } + + let mut array = ArrayVec::<[DropPanic; 1]>::new(); + array.push(DropPanic); +} + +#[test] +#[should_panic] +fn test_drop_panic_into_iter() { + struct DropPanic; + + impl Drop for DropPanic { + fn drop(&mut self) { + panic!("drop"); + } + } + + let mut array = ArrayVec::<[DropPanic; 1]>::new(); + array.push(DropPanic); + array.into_iter(); +} + +#[test] +fn test_insert() { + let mut v = ArrayVec::from([]); + assert_matches!(v.try_push(1), Err(_)); + + let mut v = ArrayVec::<[_; 3]>::new(); + v.insert(0, 0); + v.insert(1, 1); + //let ret1 = v.try_insert(3, 3); + //assert_matches!(ret1, Err(InsertError::OutOfBounds(_))); + assert_eq!(&v[..], &[0, 1]); + v.insert(2, 2); + assert_eq!(&v[..], &[0, 1, 2]); + + let ret2 = v.try_insert(1, 9); + assert_eq!(&v[..], &[0, 1, 2]); + assert_matches!(ret2, Err(_)); + + let mut v = ArrayVec::from([2]); + assert_matches!(v.try_insert(0, 1), Err(CapacityError { .. })); + assert_matches!(v.try_insert(1, 1), Err(CapacityError { .. })); + //assert_matches!(v.try_insert(2, 1), Err(CapacityError { .. })); +} + +#[test] +fn test_into_inner_1() { + let mut v = ArrayVec::from([1, 2]); + v.pop(); + let u = v.clone(); + assert_eq!(v.into_inner(), Err(u)); +} + +#[test] +fn test_into_inner_2() { + let mut v = ArrayVec::<[String; 4]>::new(); + v.push("a".into()); + v.push("b".into()); + v.push("c".into()); + v.push("d".into()); + assert_eq!(v.into_inner().unwrap(), ["a", "b", "c", "d"]); +} + +#[test] +fn test_into_inner_3_() { + let mut v = ArrayVec::<[i32; 4]>::new(); + v.extend(1..); + assert_eq!(v.into_inner().unwrap(), [1, 2, 3, 4]); +} + +#[test] +fn test_write() { + use std::io::Write; + let mut v = ArrayVec::<[_; 8]>::new(); + write!(&mut v, "\x01\x02\x03").unwrap(); + assert_eq!(&v[..], &[1, 2, 3]); + let r = v.write(&[9; 16]).unwrap(); + assert_eq!(r, 5); + assert_eq!(&v[..], &[1, 2, 3, 9, 9, 9, 9, 9]); +} + +#[test] +fn array_clone_from() { + let mut v = ArrayVec::<[_; 4]>::new(); + v.push(vec![1, 2]); + v.push(vec![3, 4, 5]); + v.push(vec![6]); + let reference = v.to_vec(); + let mut u = ArrayVec::<[_; 4]>::new(); + u.clone_from(&v); + assert_eq!(&u, &reference[..]); + + let mut t = ArrayVec::<[_; 4]>::new(); + t.push(vec![97]); + t.push(vec![]); + t.push(vec![5, 6, 2]); + t.push(vec![2]); + t.clone_from(&v); + assert_eq!(&t, &reference[..]); + t.clear(); + t.clone_from(&v); + assert_eq!(&t, &reference[..]); +} + +#[test] +fn test_string() { + use std::error::Error; + + let text = "hello world"; + let mut s = ArrayString::<[_; 16]>::new(); + s.try_push_str(text).unwrap(); + assert_eq!(&s, text); + assert_eq!(text, &s); + + // Make sure Hash / Eq / Borrow match up so we can use HashMap + let mut map = HashMap::new(); + map.insert(s, 1); + assert_eq!(map[text], 1); + + let mut t = ArrayString::<[_; 2]>::new(); + assert!(t.try_push_str(text).is_err()); + assert_eq!(&t, ""); + + t.push_str("ab"); + // DerefMut + let tmut: &mut str = &mut t; + assert_eq!(tmut, "ab"); + + // Test Error trait / try + let t = || -> Result<(), Box> { + let mut t = ArrayString::<[_; 2]>::new(); + try!(t.try_push_str(text)); + Ok(()) + }(); + assert!(t.is_err()); +} + +#[test] +fn test_string_from() { + let text = "hello world"; + // Test `from` constructor + let u = ArrayString::<[_; 11]>::from(text).unwrap(); + assert_eq!(&u, text); + assert_eq!(u.len(), text.len()); +} + +#[test] +fn test_string_from_bytes() { + let text = "hello world"; + let u = ArrayString::from_byte_string(b"hello world").unwrap(); + assert_eq!(&u, text); + assert_eq!(u.len(), text.len()); +} + +#[test] +fn test_string_clone() { + let text = "hi"; + let mut s = ArrayString::<[_; 4]>::new(); + s.push_str("abcd"); + let t = ArrayString::<[_; 4]>::from(text).unwrap(); + s.clone_from(&t); + assert_eq!(&t, &s); +} + +#[test] +fn test_string_push() { + let text = "abcαβγ"; + let mut s = ArrayString::<[_; 8]>::new(); + for c in text.chars() { + if let Err(_) = s.try_push(c) { + break; + } + } + assert_eq!("abcαβ", &s[..]); + s.push('x'); + assert_eq!("abcαβx", &s[..]); + assert!(s.try_push('x').is_err()); +} + + +#[test] +fn test_insert_at_length() { + let mut v = ArrayVec::<[_; 8]>::new(); + let result1 = v.try_insert(0, "a"); + let result2 = v.try_insert(1, "b"); + assert!(result1.is_ok() && result2.is_ok()); + assert_eq!(&v[..], &["a", "b"]); +} + +#[should_panic] +#[test] +fn test_insert_out_of_bounds() { + let mut v = ArrayVec::<[_; 8]>::new(); + let _ = v.try_insert(1, "test"); +} + +/* + * insert that pushes out the last + let mut u = ArrayVec::from([1, 2, 3, 4]); + let ret = u.try_insert(3, 99); + assert_eq!(&u[..], &[1, 2, 3, 99]); + assert_matches!(ret, Err(_)); + let ret = u.try_insert(4, 77); + assert_eq!(&u[..], &[1, 2, 3, 99]); + assert_matches!(ret, Err(_)); +*/ + +#[test] +fn test_drop_in_insert() { + use std::cell::Cell; + + let flag = &Cell::new(0); + + struct Bump<'a>(&'a Cell); + + impl<'a> Drop for Bump<'a> { + fn drop(&mut self) { + let n = self.0.get(); + self.0.set(n + 1); + } + } + + flag.set(0); + + { + let mut array = ArrayVec::<[_; 2]>::new(); + array.push(Bump(flag)); + array.insert(0, Bump(flag)); + assert_eq!(flag.get(), 0); + let ret = array.try_insert(1, Bump(flag)); + assert_eq!(flag.get(), 0); + assert_matches!(ret, Err(_)); + drop(ret); + assert_eq!(flag.get(), 1); + } + assert_eq!(flag.get(), 3); +} + +#[test] +fn test_pop_at() { + let mut v = ArrayVec::<[String; 4]>::new(); + let s = String::from; + v.push(s("a")); + v.push(s("b")); + v.push(s("c")); + v.push(s("d")); + + assert_eq!(v.pop_at(4), None); + assert_eq!(v.pop_at(1), Some(s("b"))); + assert_eq!(v.pop_at(1), Some(s("c"))); + assert_eq!(v.pop_at(2), None); + assert_eq!(&v[..], &["a", "d"]); +} + +#[test] +fn test_sizes() { + let v = ArrayVec::from([0u8; 1 << 16]); + assert_eq!(vec![0u8; v.len()], &v[..]); +} + +#[test] +fn test_default() { + use std::net; + let s: ArrayString<[u8; 4]> = Default::default(); + // Something without `Default` implementation. + let v: ArrayVec<[net::TcpStream; 4]> = Default::default(); + assert_eq!(s.len(), 0); + assert_eq!(v.len(), 0); +} + +#[cfg(feature="array-sizes-33-128")] +#[test] +fn test_sizes_33_128() { + ArrayVec::from([0u8; 52]); + ArrayVec::from([0u8; 127]); +} + +#[cfg(feature="array-sizes-129-255")] +#[test] +fn test_sizes_129_255() { + ArrayVec::from([0u8; 237]); + ArrayVec::from([0u8; 255]); +} + + +#[test] +fn test_newish_stable_uses_maybe_uninit() { + if option_env!("ARRAYVECTEST_ENSURE_MAYBEUNINIT").map(|s| !s.is_empty()).unwrap_or(false) { + assert!(cfg!(has_stable_maybe_uninit)); + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/.cargo-checksum.json b/third_party/cargo/vendor/arrayvec-0.5.1/.cargo-checksum.json new file mode 100644 index 0000000..f8e8231 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"e7405a91fea075bb4fedb0e76e2039af27d6c380beaa31150f37655d79a7a3ab","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0245ee104228a100ce5fceecf43e25faae450494d9173f43fd94c27d69fdac13","README.rst":"8fab86c3c759d153a1a8a48e5f7f48546c898f0ec91433001c57fe0002af6455","benches/arraystring.rs":"f12b890977117ebde4ca42bcd6b91f2a6a087f2b235aaca6d15e30d125ae9f67","benches/extend.rs":"c3d69cc488ec5341b019cfed545ebbfea252f98718037b413f6a349da9489d1b","custom.css":"e6f2cd299392337b4e2959c52f422e5b7be11920ea98d10db44d10ddef5ed47c","src/array.rs":"8a42b3ff7a5a0713e8ee22462f303b0ce15bdc49a9fd5eb64f58e56855bdf944","src/array_string.rs":"fdcc24f0fd07e781b378f5d0190279e6d9c89b422f67e546ae443c602f967896","src/char.rs":"40af597d93895f206abcd33953b5d3d5a512d3b16ff5f96e492e659d9cca4209","src/errors.rs":"dde99bffaddfd45396aab7e07642cc018ef5435fe60c4f26a2c05a36555be18c","src/lib.rs":"4c00e50b532aec68b52fde4a737b7b5980b0cfb28f5c09ab8408d04896895a87","src/maybe_uninit.rs":"00659a86e8f84852d4355077a16beceaad0440ac0e81851fbac712fdb1850622","tests/serde.rs":"18c165cf6024f04a25b19aa139657d7c59f72d1541c9b24b44f9eaea01f507db","tests/tests.rs":"9633b92fe6c650b9b816cecac23b9c9e6a0365b1f67d4f0bfaad9e645e2bdc49"},"package":"cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"} \ No newline at end of file diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/BUILD b/third_party/cargo/vendor/arrayvec-0.5.1/BUILD new file mode 100644 index 0000000..5f25c07 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/BUILD @@ -0,0 +1,46 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "arraystring" with type "bench" omitted + +rust_library( + name = "arrayvec", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.5.1", + crate_features = [ + ], +) + +# Unsupported target "extend" with type "bench" omitted +# Unsupported target "serde" with type "test" omitted +# Unsupported target "tests" with type "test" omitted diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/Cargo.toml b/third_party/cargo/vendor/arrayvec-0.5.1/Cargo.toml new file mode 100644 index 0000000..2a42a3f --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/Cargo.toml @@ -0,0 +1,62 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "arrayvec" +version = "0.5.1" +authors = ["bluss"] +description = "A vector with fixed capacity, backed by an array (it can be stored on the stack too). Implements fixed capacity ArrayVec and ArrayString." +documentation = "https://docs.rs/arrayvec/" +keywords = ["stack", "vector", "array", "data-structure", "no_std"] +categories = ["data-structures", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/bluss/arrayvec" +[package.metadata.docs.rs] +features = ["serde"] + +[package.metadata.release] +no-dev-version = true +tag-name = "{{version}}" +[profile.bench] +debug = true + +[profile.release] +debug = true + +[[bench]] +name = "extend" +harness = false + +[[bench]] +name = "arraystring" +harness = false +[dependencies.serde] +version = "1.0" +optional = true +default-features = false +[dev-dependencies.bencher] +version = "0.1.4" + +[dev-dependencies.matches] +version = "0.1" + +[dev-dependencies.serde_test] +version = "1.0" + +[build-dependencies] + +[features] +array-sizes-129-255 = [] +array-sizes-33-128 = [] +default = ["std"] +std = [] diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/LICENSE-APACHE b/third_party/cargo/vendor/arrayvec-0.5.1/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/LICENSE-MIT b/third_party/cargo/vendor/arrayvec-0.5.1/LICENSE-MIT new file mode 100644 index 0000000..2c8f27d --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) Ulrik Sverdrup "bluss" 2015-2017 + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/README.rst b/third_party/cargo/vendor/arrayvec-0.5.1/README.rst new file mode 100644 index 0000000..a8bb1db --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/README.rst @@ -0,0 +1,259 @@ + +arrayvec +======== + +A vector with fixed capacity. + +Please read the `API documentation here`__ + +__ https://docs.rs/arrayvec + +|build_status|_ |crates|_ |crates2|_ + +.. |build_status| image:: https://travis-ci.org/bluss/arrayvec.svg +.. _build_status: https://travis-ci.org/bluss/arrayvec + +.. |crates| image:: http://meritbadge.herokuapp.com/arrayvec +.. _crates: https://crates.io/crates/arrayvec + +.. |crates2| image:: http://meritbadge.herokuapp.com/nodrop +.. _crates2: https://crates.io/crates/nodrop + +Recent Changes (arrayvec) +------------------------- + +- 0.5.1 + + - Add ``as_ptr``, ``as_mut_ptr`` accessors directly on the ``ArrayVec`` by @tbu- + (matches the same addition to ``Vec`` which happened in Rust 1.37). + - Add method ``ArrayString::len`` (now available directly, not just through deref to str). + - Use raw pointers instead of ``&mut [u8]`` for encoding chars into ``ArrayString`` + (uninit best practice fix). + - Use raw pointers instead of ``get_unchecked_mut`` where the target may be + uninitialized a everywhere relevant in the ArrayVec implementation + (uninit best practice fix). + - Changed inline hints on many methods, mainly removing inline hints + - ``ArrayVec::dispose`` is now deprecated (it has no purpose anymore) + +- 0.4.12 + + - Use raw pointers instead of ``get_unchecked_mut`` where the target may be + uninitialized a everywhere relevant in the ArrayVec implementation. + +- 0.5.0 + + - Use ``MaybeUninit`` (now unconditionally) in the implementation of + ``ArrayVec`` + - Use ``MaybeUninit`` (now unconditionally) in the implementation of + ``ArrayString`` + - The crate feature for serde serialization is now named ``serde``. + - Updated the ``Array`` trait interface, and it is now easier to use for + users outside the crate. + - Add ``FromStr`` impl for ``ArrayString`` by @despawnerer + - Add method ``try_extend_from_slice`` to ``ArrayVec``, which is always + effecient by @Thomasdezeeuw. + - Add method ``remaining_capacity`` by @Thomasdezeeuw + - Improve performance of the ``extend`` method. + - The index type of zero capacity vectors is now itself zero size, by + @clarfon + - Use ``drop_in_place`` for truncate and clear methods. This affects drop order + and resume from panic during drop. + - Use Rust 2018 edition for the implementation + - Require Rust 1.36 or later, for the unconditional ``MaybeUninit`` + improvements. + +- 0.4.11 + + - In Rust 1.36 or later, use newly stable MaybeUninit. This extends the + soundness work introduced in 0.4.9, we are finally able to use this in + stable. We use feature detection (build script) to enable this at build + time. + +- 0.4.10 + + - Use ``repr(C)`` in the ``union`` version that was introduced in 0.4.9, to + allay some soundness concerns. + +- 0.4.9 + + - Use ``union`` in the implementation on when this is detected to be supported + (nightly only for now). This is a better solution for treating uninitialized + regions correctly, and we'll use it in stable Rust as soon as we are able. + When this is enabled, the ``ArrayVec`` has no space overhead in its memory + layout, although the size of the vec should not be relied upon. (See `#114`_) + - ``ArrayString`` updated to not use uninitialized memory, it instead zeros its + backing array. This will be refined in the next version, since we + need to make changes to the user visible API. + - The ``use_union`` feature now does nothing (like its documentation foretold). + +.. _`#114`: https://github.com/bluss/arrayvec/pull/114 + +- 0.4.8 + + - Implement Clone and Debug for ``IntoIter`` by @clarcharr + - Add more array sizes under crate features. These cover all in the range + up to 128 and 129 to 255 respectively (we have a few of those by default): + + - ``array-size-33-128`` + - ``array-size-129-255`` + +- 0.4.7 + + - Fix future compat warning about raw pointer casts + - Use ``drop_in_place`` when dropping the arrayvec by-value iterator + - Decrease mininum Rust version (see docs) by @jeehoonkang + +- 0.3.25 + + - Fix future compat warning about raw pointer casts + +- 0.4.6 + + - Fix compilation on 16-bit targets. This means, the 65536 array size is not + included on these targets. + +- 0.3.24 + + - Fix compilation on 16-bit targets. This means, the 65536 array size is not + included on these targets. + - Fix license files so that they are both included (was fixed in 0.4 before) + +- 0.4.5 + + - Add methods to ``ArrayString`` by @DenialAdams: + + - ``.pop() -> Option`` + - ``.truncate(new_len)`` + - ``.remove(index) -> char`` + + - Remove dependency on crate odds + - Document debug assertions in unsafe methods better + +- 0.4.4 + + - Add method ``ArrayVec::truncate()`` by @niklasf + +- 0.4.3 + + - Improve performance for ``ArrayVec::extend`` with a lower level + implementation (#74) + - Small cleanup in dependencies (use no std for crates where we don't need more) + +- 0.4.2 + + - Add constructor method ``new`` to ``CapacityError``. + +- 0.4.1 + + - Add ``Default`` impl to ``ArrayString`` by @tbu- + +- 0.4.0 + + - Reformed signatures and error handling by @bluss and @tbu-: + + - ``ArrayVec``'s ``push, insert, remove, swap_remove`` now match ``Vec``'s + corresponding signature and panic on capacity errors where applicable. + - Add fallible methods ``try_push, insert`` and checked methods + ``pop_at, swap_pop``. + - Similar changes to ``ArrayString``'s push methods. + + - Use a local version of the ``RangeArgument`` trait + - Add array sizes 50, 150, 200 by @daboross + - Support serde 1.0 by @daboross + - New method ``.push_unchecked()`` by @niklasf + - ``ArrayString`` implements ``PartialOrd, Ord`` by @tbu- + - Require Rust 1.14 + - crate feature ``use_generic_array`` was dropped. + +- 0.3.23 + + - Implement ``PartialOrd, Ord`` as well as ``PartialOrd`` for + ``ArrayString``. + +- 0.3.22 + + - Implement ``Array`` for the 65536 size + +- 0.3.21 + + - Use ``encode_utf8`` from crate odds + - Add constructor ``ArrayString::from_byte_string`` + +- 0.3.20 + + - Simplify and speed up ``ArrayString``’s ``.push(char)``- + +- 0.3.19 + + - Add new crate feature ``use_generic_array`` which allows using their + ``GenericArray`` just like a regular fixed size array for the storage + of an ``ArrayVec``. + +- 0.3.18 + + - Fix bounds check in ``ArrayVec::insert``! + It would be buggy if ``self.len() < index < self.capacity()``. Take note of + the push out behavior specified in the docs. + +- 0.3.17 + + - Added crate feature ``use_union`` which forwards to the nodrop crate feature + - Added methods ``.is_full()`` to ``ArrayVec`` and ``ArrayString``. + +- 0.3.16 + + - Added method ``.retain()`` to ``ArrayVec``. + - Added methods ``.as_slice(), .as_mut_slice()`` to ``ArrayVec`` and ``.as_str()`` + to ``ArrayString``. + +- 0.3.15 + + - Add feature std, which you can opt out of to use ``no_std`` (requires Rust 1.6 + to opt out). + - Implement ``Clone::clone_from`` for ArrayVec and ArrayString + +- 0.3.14 + + - Add ``ArrayString::from(&str)`` + +- 0.3.13 + + - Added ``DerefMut`` impl for ``ArrayString``. + - Added method ``.simplify()`` to drop the element for ``CapacityError``. + - Added method ``.dispose()`` to ``ArrayVec`` + +- 0.3.12 + + - Added ArrayString, a fixed capacity analogy of String + +- 0.3.11 + + - Added trait impls Default, PartialOrd, Ord, Write for ArrayVec + +- 0.3.10 + + - Go back to using external NoDrop, fixing a panic safety bug (issue #3) + +- 0.3.8 + + - Inline the non-dropping logic to remove one drop flag in the + ArrayVec representation. + +- 0.3.7 + + - Added method .into_inner() + - Added unsafe method .set_len() + + +License +======= + +Dual-licensed to be compatible with the Rust project. + +Licensed under the Apache License, Version 2.0 +http://www.apache.org/licenses/LICENSE-2.0 or the MIT license +http://opensource.org/licenses/MIT, at your +option. This file may not be copied, modified, or distributed +except according to those terms. + + diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/benches/arraystring.rs b/third_party/cargo/vendor/arrayvec-0.5.1/benches/arraystring.rs new file mode 100644 index 0000000..9cff587 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/benches/arraystring.rs @@ -0,0 +1,90 @@ + +extern crate arrayvec; +#[macro_use] extern crate bencher; + +use arrayvec::ArrayString; + +use bencher::Bencher; + +fn try_push_c(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + b.iter(|| { + v.clear(); + while v.try_push('c').is_ok() { + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +fn try_push_alpha(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + b.iter(|| { + v.clear(); + while v.try_push('α').is_ok() { + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +// Yes, pushing a string char-by-char is slow. Use .push_str. +fn try_push_string(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + let input = "abcαβγ“”"; + b.iter(|| { + v.clear(); + for ch in input.chars().cycle() { + if !v.try_push(ch).is_ok() { + break; + } + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +fn push_c(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + b.iter(|| { + v.clear(); + while !v.is_full() { + v.push('c'); + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +fn push_alpha(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + b.iter(|| { + v.clear(); + while !v.is_full() { + v.push('α'); + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +fn push_string(b: &mut Bencher) { + let mut v = ArrayString::<[u8; 512]>::new(); + let input = "abcαβγ“”"; + b.iter(|| { + v.clear(); + for ch in input.chars().cycle() { + if !v.is_full() { + v.push(ch); + } else { + break; + } + } + v.len() + }); + b.bytes = v.capacity() as u64; +} + +benchmark_group!(benches, try_push_c, try_push_alpha, try_push_string, push_c, + push_alpha, push_string); +benchmark_main!(benches); diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/benches/extend.rs b/third_party/cargo/vendor/arrayvec-0.5.1/benches/extend.rs new file mode 100644 index 0000000..0579717 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/benches/extend.rs @@ -0,0 +1,78 @@ + +extern crate arrayvec; +#[macro_use] extern crate bencher; + +use std::io::Write; + +use arrayvec::ArrayVec; + +use bencher::Bencher; +use bencher::black_box; + +fn extend_with_constant(b: &mut Bencher) { + let mut v = ArrayVec::<[u8; 512]>::new(); + let cap = v.capacity(); + b.iter(|| { + v.clear(); + let constant = black_box(1); + v.extend((0..cap).map(move |_| constant)); + v[511] + }); + b.bytes = v.capacity() as u64; +} + +fn extend_with_range(b: &mut Bencher) { + let mut v = ArrayVec::<[u8; 512]>::new(); + let cap = v.capacity(); + b.iter(|| { + v.clear(); + let range = 0..cap; + v.extend(range.map(|x| black_box(x as _))); + v[511] + }); + b.bytes = v.capacity() as u64; +} + +fn extend_with_slice(b: &mut Bencher) { + let mut v = ArrayVec::<[u8; 512]>::new(); + let data = [1; 512]; + b.iter(|| { + v.clear(); + let iter = data.iter().map(|&x| x); + v.extend(iter); + v[511] + }); + b.bytes = v.capacity() as u64; +} + +fn extend_with_write(b: &mut Bencher) { + let mut v = ArrayVec::<[u8; 512]>::new(); + let data = [1; 512]; + b.iter(|| { + v.clear(); + v.write(&data[..]).ok(); + v[511] + }); + b.bytes = v.capacity() as u64; +} + +fn extend_from_slice(b: &mut Bencher) { + let mut v = ArrayVec::<[u8; 512]>::new(); + let data = [1; 512]; + b.iter(|| { + v.clear(); + v.try_extend_from_slice(&data).ok(); + v[511] + }); + b.bytes = v.capacity() as u64; +} + +benchmark_group!(benches, + extend_with_constant, + extend_with_range, + extend_with_slice, + extend_with_write, + extend_from_slice +); + +benchmark_main!(benches); diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/custom.css b/third_party/cargo/vendor/arrayvec-0.5.1/custom.css new file mode 100644 index 0000000..8e0b705 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/custom.css @@ -0,0 +1,25 @@ + +.docblock pre.rust { background: #eeeeff; } +pre.trait, pre.fn, pre.struct, pre.enum, pre.typedef { background: #fcfefc; } + +/* Small “example” label for doc examples */ +.docblock pre.rust::before { + content: "example"; + float: right; + font-style: italic; + font-size: 0.8em; + margin-top: -10px; + margin-right: -5px; +} + + +/* Fixup where display in trait listing */ +pre.trait .where::before { +content: '\a '; +} + +.docblock code { + background-color: inherit; + font-weight: bold; + padding: 0 0.1em; +} diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/src/array.rs b/third_party/cargo/vendor/arrayvec-0.5.1/src/array.rs new file mode 100644 index 0000000..96a8bfd --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/src/array.rs @@ -0,0 +1,144 @@ + +/// Trait for fixed size arrays. +/// +/// This trait is implemented for some specific array sizes, see +/// the implementor list below. At the current state of Rust we can't +/// make this fully general for every array size. +/// +/// The following crate features add more array sizes (and they are not +/// enabled by default due to their impact on compliation speed). +/// +/// - `array-sizes-33-128`: All sizes 33 to 128 are implemented +/// (a few in this range are included by default). +/// - `array-sizes-129-255`: All sizes 129 to 255 are implemented +/// (a few in this range are included by default). +/// +/// ## Safety +/// +/// This trait can *only* be implemented by fixed-size arrays or types with +/// *exactly* the representation of a fixed size array (of the right element +/// type and capacity). +/// +/// Normally this trait is an implementation detail of arrayvec and doesn’t +/// need implementing. +pub unsafe trait Array { + /// The array’s element type + type Item; + /// The smallest type that can index and tell the length of the array. + #[doc(hidden)] + type Index: Index; + /// The array's element capacity + const CAPACITY: usize; + fn as_slice(&self) -> &[Self::Item]; + fn as_mut_slice(&mut self) -> &mut [Self::Item]; +} + +pub trait Index : PartialEq + Copy { + fn to_usize(self) -> usize; + fn from(_: usize) -> Self; +} + +impl Index for () { + #[inline(always)] + fn to_usize(self) -> usize { 0 } + #[inline(always)] + fn from(_ix: usize) -> Self { () } +} + +impl Index for bool { + #[inline(always)] + fn to_usize(self) -> usize { self as usize } + #[inline(always)] + fn from(ix: usize) -> Self { ix != 0 } +} + +impl Index for u8 { + #[inline(always)] + fn to_usize(self) -> usize { self as usize } + #[inline(always)] + fn from(ix: usize) -> Self { ix as u8 } +} + +impl Index for u16 { + #[inline(always)] + fn to_usize(self) -> usize { self as usize } + #[inline(always)] + fn from(ix: usize) -> Self { ix as u16 } +} + +impl Index for u32 { + #[inline(always)] + fn to_usize(self) -> usize { self as usize } + #[inline(always)] + fn from(ix: usize) -> Self { ix as u32 } +} + +impl Index for usize { + #[inline(always)] + fn to_usize(self) -> usize { self } + #[inline(always)] + fn from(ix: usize) -> Self { ix } +} + +macro_rules! fix_array_impl { + ($index_type:ty, $len:expr ) => ( + unsafe impl Array for [T; $len] { + type Item = T; + type Index = $index_type; + const CAPACITY: usize = $len; + #[doc(hidden)] + fn as_slice(&self) -> &[Self::Item] { self } + #[doc(hidden)] + fn as_mut_slice(&mut self) -> &mut [Self::Item] { self } + } + ) +} + +macro_rules! fix_array_impl_recursive { + ($index_type:ty, ) => (); + ($index_type:ty, $($len:expr,)*) => ( + $(fix_array_impl!($index_type, $len);)* + ); +} + + +fix_array_impl_recursive!((), 0,); +fix_array_impl_recursive!(bool, 1,); +fix_array_impl_recursive!(u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, ); + +#[cfg(not(feature="array-sizes-33-128"))] +fix_array_impl_recursive!(u8, 32, 40, 48, 50, 56, 64, 72, 96, 100, 128, ); + +#[cfg(feature="array-sizes-33-128")] +fix_array_impl_recursive!(u8, +32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, +52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, +72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, +92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, +109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, +125, 126, 127, 128, +); + +#[cfg(not(feature="array-sizes-129-255"))] +fix_array_impl_recursive!(u8, 160, 192, 200, 224,); + +#[cfg(feature="array-sizes-129-255")] +fix_array_impl_recursive!(u8, +129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, +141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, +157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, +173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, +189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, +205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, +221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, +237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, +253, 254, 255, +); + +fix_array_impl_recursive!(u16, 256, 384, 512, 768, 1024, 2048, 4096, 8192, 16384, 32768,); +// This array size doesn't exist on 16-bit +#[cfg(any(target_pointer_width="32", target_pointer_width="64"))] +fix_array_impl_recursive!(u32, 1 << 16,); + diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/src/array_string.rs b/third_party/cargo/vendor/arrayvec-0.5.1/src/array_string.rs new file mode 100644 index 0000000..30aea4a --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/src/array_string.rs @@ -0,0 +1,567 @@ +use std::borrow::Borrow; +use std::cmp; +use std::fmt; +use std::hash::{Hash, Hasher}; +use std::ptr; +use std::ops::{Deref, DerefMut}; +use std::str; +use std::str::FromStr; +use std::str::Utf8Error; +use std::slice; + +use crate::array::Array; +use crate::array::Index; +use crate::CapacityError; +use crate::char::encode_utf8; + +#[cfg(feature="serde")] +use serde::{Serialize, Deserialize, Serializer, Deserializer}; + +use super::MaybeUninit as MaybeUninitCopy; + +/// A string with a fixed capacity. +/// +/// The `ArrayString` is a string backed by a fixed size array. It keeps track +/// of its length. +/// +/// The string is a contiguous value that you can store directly on the stack +/// if needed. +#[derive(Copy)] +pub struct ArrayString + where A: Array + Copy +{ + xs: MaybeUninitCopy, + len: A::Index, +} + +impl Default for ArrayString + where A: Array + Copy +{ + /// Return an empty `ArrayString` + fn default() -> ArrayString { + ArrayString::new() + } +} + +impl ArrayString + where A: Array + Copy +{ + /// Create a new empty `ArrayString`. + /// + /// Capacity is inferred from the type parameter. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 16]>::new(); + /// string.push_str("foo"); + /// assert_eq!(&string[..], "foo"); + /// assert_eq!(string.capacity(), 16); + /// ``` + pub fn new() -> ArrayString { + unsafe { + ArrayString { + xs: MaybeUninitCopy::uninitialized(), + len: Index::from(0), + } + } + } + + /// Return the length of the string. + #[inline] + pub fn len(&self) -> usize { self.len.to_usize() } + + /// Create a new `ArrayString` from a `str`. + /// + /// Capacity is inferred from the type parameter. + /// + /// **Errors** if the backing array is not large enough to fit the string. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 3]>::from("foo").unwrap(); + /// assert_eq!(&string[..], "foo"); + /// assert_eq!(string.len(), 3); + /// assert_eq!(string.capacity(), 3); + /// ``` + pub fn from(s: &str) -> Result> { + let mut arraystr = Self::new(); + arraystr.try_push_str(s)?; + Ok(arraystr) + } + + /// Create a new `ArrayString` from a byte string literal. + /// + /// **Errors** if the byte string literal is not valid UTF-8. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let string = ArrayString::from_byte_string(b"hello world").unwrap(); + /// ``` + pub fn from_byte_string(b: &A) -> Result { + let len = str::from_utf8(b.as_slice())?.len(); + debug_assert_eq!(len, A::CAPACITY); + Ok(ArrayString { + xs: MaybeUninitCopy::from(*b), + len: Index::from(A::CAPACITY), + }) + } + + /// Return the capacity of the `ArrayString`. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let string = ArrayString::<[_; 3]>::new(); + /// assert_eq!(string.capacity(), 3); + /// ``` + #[inline(always)] + pub fn capacity(&self) -> usize { A::CAPACITY } + + /// Return if the `ArrayString` is completely filled. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 1]>::new(); + /// assert!(!string.is_full()); + /// string.push_str("A"); + /// assert!(string.is_full()); + /// ``` + pub fn is_full(&self) -> bool { self.len() == self.capacity() } + + /// Adds the given char to the end of the string. + /// + /// ***Panics*** if the backing array is not large enough to fit the additional char. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 2]>::new(); + /// + /// string.push('a'); + /// string.push('b'); + /// + /// assert_eq!(&string[..], "ab"); + /// ``` + pub fn push(&mut self, c: char) { + self.try_push(c).unwrap(); + } + + /// Adds the given char to the end of the string. + /// + /// Returns `Ok` if the push succeeds. + /// + /// **Errors** if the backing array is not large enough to fit the additional char. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 2]>::new(); + /// + /// string.try_push('a').unwrap(); + /// string.try_push('b').unwrap(); + /// let overflow = string.try_push('c'); + /// + /// assert_eq!(&string[..], "ab"); + /// assert_eq!(overflow.unwrap_err().element(), 'c'); + /// ``` + pub fn try_push(&mut self, c: char) -> Result<(), CapacityError> { + let len = self.len(); + unsafe { + let ptr = self.xs.ptr_mut().add(len); + let remaining_cap = self.capacity() - len; + match encode_utf8(c, ptr, remaining_cap) { + Ok(n) => { + self.set_len(len + n); + Ok(()) + } + Err(_) => Err(CapacityError::new(c)), + } + } + } + + /// Adds the given string slice to the end of the string. + /// + /// ***Panics*** if the backing array is not large enough to fit the string. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 2]>::new(); + /// + /// string.push_str("a"); + /// string.push_str("d"); + /// + /// assert_eq!(&string[..], "ad"); + /// ``` + pub fn push_str(&mut self, s: &str) { + self.try_push_str(s).unwrap() + } + + /// Adds the given string slice to the end of the string. + /// + /// Returns `Ok` if the push succeeds. + /// + /// **Errors** if the backing array is not large enough to fit the string. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 2]>::new(); + /// + /// string.try_push_str("a").unwrap(); + /// let overflow1 = string.try_push_str("bc"); + /// string.try_push_str("d").unwrap(); + /// let overflow2 = string.try_push_str("ef"); + /// + /// assert_eq!(&string[..], "ad"); + /// assert_eq!(overflow1.unwrap_err().element(), "bc"); + /// assert_eq!(overflow2.unwrap_err().element(), "ef"); + /// ``` + pub fn try_push_str<'a>(&mut self, s: &'a str) -> Result<(), CapacityError<&'a str>> { + if s.len() > self.capacity() - self.len() { + return Err(CapacityError::new(s)); + } + unsafe { + let dst = self.xs.ptr_mut().offset(self.len() as isize); + let src = s.as_ptr(); + ptr::copy_nonoverlapping(src, dst, s.len()); + let newl = self.len() + s.len(); + self.set_len(newl); + } + Ok(()) + } + + /// Removes the last character from the string and returns it. + /// + /// Returns `None` if this `ArrayString` is empty. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut s = ArrayString::<[_; 3]>::from("foo").unwrap(); + /// + /// assert_eq!(s.pop(), Some('o')); + /// assert_eq!(s.pop(), Some('o')); + /// assert_eq!(s.pop(), Some('f')); + /// + /// assert_eq!(s.pop(), None); + /// ``` + pub fn pop(&mut self) -> Option { + let ch = match self.chars().rev().next() { + Some(ch) => ch, + None => return None, + }; + let new_len = self.len() - ch.len_utf8(); + unsafe { + self.set_len(new_len); + } + Some(ch) + } + + /// Shortens this `ArrayString` to the specified length. + /// + /// If `new_len` is greater than the string’s current length, this has no + /// effect. + /// + /// ***Panics*** if `new_len` does not lie on a `char` boundary. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut string = ArrayString::<[_; 6]>::from("foobar").unwrap(); + /// string.truncate(3); + /// assert_eq!(&string[..], "foo"); + /// string.truncate(4); + /// assert_eq!(&string[..], "foo"); + /// ``` + pub fn truncate(&mut self, new_len: usize) { + if new_len <= self.len() { + assert!(self.is_char_boundary(new_len)); + unsafe { + // In libstd truncate is called on the underlying vector, + // which in turns drops each element. + // As we know we don't have to worry about Drop, + // we can just set the length (a la clear.) + self.set_len(new_len); + } + } + } + + /// Removes a `char` from this `ArrayString` at a byte position and returns it. + /// + /// This is an `O(n)` operation, as it requires copying every element in the + /// array. + /// + /// ***Panics*** if `idx` is larger than or equal to the `ArrayString`’s length, + /// or if it does not lie on a `char` boundary. + /// + /// ``` + /// use arrayvec::ArrayString; + /// + /// let mut s = ArrayString::<[_; 3]>::from("foo").unwrap(); + /// + /// assert_eq!(s.remove(0), 'f'); + /// assert_eq!(s.remove(1), 'o'); + /// assert_eq!(s.remove(0), 'o'); + /// ``` + pub fn remove(&mut self, idx: usize) -> char { + let ch = match self[idx..].chars().next() { + Some(ch) => ch, + None => panic!("cannot remove a char from the end of a string"), + }; + + let next = idx + ch.len_utf8(); + let len = self.len(); + unsafe { + ptr::copy(self.xs.ptr().offset(next as isize), + self.xs.ptr_mut().offset(idx as isize), + len - next); + self.set_len(len - (next - idx)); + } + ch + } + + /// Make the string empty. + pub fn clear(&mut self) { + unsafe { + self.set_len(0); + } + } + + /// Set the strings’s length. + /// + /// This function is `unsafe` because it changes the notion of the + /// number of “valid” bytes in the string. Use with care. + /// + /// This method uses *debug assertions* to check the validity of `length` + /// and may use other debug assertions. + pub unsafe fn set_len(&mut self, length: usize) { + debug_assert!(length <= self.capacity()); + self.len = Index::from(length); + } + + /// Return a string slice of the whole `ArrayString`. + pub fn as_str(&self) -> &str { + self + } +} + +impl Deref for ArrayString + where A: Array + Copy +{ + type Target = str; + #[inline] + fn deref(&self) -> &str { + unsafe { + let sl = slice::from_raw_parts(self.xs.ptr(), self.len.to_usize()); + str::from_utf8_unchecked(sl) + } + } +} + +impl DerefMut for ArrayString + where A: Array + Copy +{ + #[inline] + fn deref_mut(&mut self) -> &mut str { + unsafe { + let sl = slice::from_raw_parts_mut(self.xs.ptr_mut(), self.len.to_usize()); + str::from_utf8_unchecked_mut(sl) + } + } +} + +impl PartialEq for ArrayString + where A: Array + Copy +{ + fn eq(&self, rhs: &Self) -> bool { + **self == **rhs + } +} + +impl PartialEq for ArrayString + where A: Array + Copy +{ + fn eq(&self, rhs: &str) -> bool { + &**self == rhs + } +} + +impl PartialEq> for str + where A: Array + Copy +{ + fn eq(&self, rhs: &ArrayString) -> bool { + self == &**rhs + } +} + +impl Eq for ArrayString + where A: Array + Copy +{ } + +impl Hash for ArrayString + where A: Array + Copy +{ + fn hash(&self, h: &mut H) { + (**self).hash(h) + } +} + +impl Borrow for ArrayString + where A: Array + Copy +{ + fn borrow(&self) -> &str { self } +} + +impl AsRef for ArrayString + where A: Array + Copy +{ + fn as_ref(&self) -> &str { self } +} + +impl fmt::Debug for ArrayString + where A: Array + Copy +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } +} + +impl fmt::Display for ArrayString + where A: Array + Copy +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } +} + +/// `Write` appends written data to the end of the string. +impl fmt::Write for ArrayString + where A: Array + Copy +{ + fn write_char(&mut self, c: char) -> fmt::Result { + self.try_push(c).map_err(|_| fmt::Error) + } + + fn write_str(&mut self, s: &str) -> fmt::Result { + self.try_push_str(s).map_err(|_| fmt::Error) + } +} + +impl Clone for ArrayString + where A: Array + Copy +{ + fn clone(&self) -> ArrayString { + *self + } + fn clone_from(&mut self, rhs: &Self) { + // guaranteed to fit due to types matching. + self.clear(); + self.try_push_str(rhs).ok(); + } +} + +impl PartialOrd for ArrayString + where A: Array + Copy +{ + fn partial_cmp(&self, rhs: &Self) -> Option { + (**self).partial_cmp(&**rhs) + } + fn lt(&self, rhs: &Self) -> bool { **self < **rhs } + fn le(&self, rhs: &Self) -> bool { **self <= **rhs } + fn gt(&self, rhs: &Self) -> bool { **self > **rhs } + fn ge(&self, rhs: &Self) -> bool { **self >= **rhs } +} + +impl PartialOrd for ArrayString + where A: Array + Copy +{ + fn partial_cmp(&self, rhs: &str) -> Option { + (**self).partial_cmp(rhs) + } + fn lt(&self, rhs: &str) -> bool { &**self < rhs } + fn le(&self, rhs: &str) -> bool { &**self <= rhs } + fn gt(&self, rhs: &str) -> bool { &**self > rhs } + fn ge(&self, rhs: &str) -> bool { &**self >= rhs } +} + +impl PartialOrd> for str + where A: Array + Copy +{ + fn partial_cmp(&self, rhs: &ArrayString) -> Option { + self.partial_cmp(&**rhs) + } + fn lt(&self, rhs: &ArrayString) -> bool { self < &**rhs } + fn le(&self, rhs: &ArrayString) -> bool { self <= &**rhs } + fn gt(&self, rhs: &ArrayString) -> bool { self > &**rhs } + fn ge(&self, rhs: &ArrayString) -> bool { self >= &**rhs } +} + +impl Ord for ArrayString + where A: Array + Copy +{ + fn cmp(&self, rhs: &Self) -> cmp::Ordering { + (**self).cmp(&**rhs) + } +} + +impl FromStr for ArrayString + where A: Array + Copy +{ + type Err = CapacityError; + + fn from_str(s: &str) -> Result { + Self::from(s).map_err(CapacityError::simplify) + } +} + +#[cfg(feature="serde")] +/// Requires crate feature `"serde"` +impl Serialize for ArrayString + where A: Array + Copy +{ + fn serialize(&self, serializer: S) -> Result + where S: Serializer + { + serializer.serialize_str(&*self) + } +} + +#[cfg(feature="serde")] +/// Requires crate feature `"serde"` +impl<'de, A> Deserialize<'de> for ArrayString + where A: Array + Copy +{ + fn deserialize(deserializer: D) -> Result + where D: Deserializer<'de> + { + use serde::de::{self, Visitor}; + use std::marker::PhantomData; + + struct ArrayStringVisitor>(PhantomData); + + impl<'de, A: Copy + Array> Visitor<'de> for ArrayStringVisitor { + type Value = ArrayString; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!(formatter, "a string no more than {} bytes long", A::CAPACITY) + } + + fn visit_str(self, v: &str) -> Result + where E: de::Error, + { + ArrayString::from(v).map_err(|_| E::invalid_length(v.len(), &self)) + } + + fn visit_bytes(self, v: &[u8]) -> Result + where E: de::Error, + { + let s = str::from_utf8(v).map_err(|_| E::invalid_value(de::Unexpected::Bytes(v), &self))?; + + ArrayString::from(s).map_err(|_| E::invalid_length(s.len(), &self)) + } + } + + deserializer.deserialize_str(ArrayStringVisitor::(PhantomData)) + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/src/char.rs b/third_party/cargo/vendor/arrayvec-0.5.1/src/char.rs new file mode 100644 index 0000000..c9b00ca --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/src/char.rs @@ -0,0 +1,98 @@ +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// Original authors: alexchrichton, bluss + +use std::ptr; + +// UTF-8 ranges and tags for encoding characters +const TAG_CONT: u8 = 0b1000_0000; +const TAG_TWO_B: u8 = 0b1100_0000; +const TAG_THREE_B: u8 = 0b1110_0000; +const TAG_FOUR_B: u8 = 0b1111_0000; +const MAX_ONE_B: u32 = 0x80; +const MAX_TWO_B: u32 = 0x800; +const MAX_THREE_B: u32 = 0x10000; + +/// Placeholder +pub struct EncodeUtf8Error; + +#[inline] +unsafe fn write(ptr: *mut u8, index: usize, byte: u8) { + ptr::write(ptr.add(index), byte) +} + +/// Encode a char into buf using UTF-8. +/// +/// On success, return the byte length of the encoding (1, 2, 3 or 4).
+/// On error, return `EncodeUtf8Error` if the buffer was too short for the char. +/// +/// Safety: `ptr` must be writable for `len` bytes. +#[inline] +pub unsafe fn encode_utf8(ch: char, ptr: *mut u8, len: usize) -> Result +{ + let code = ch as u32; + if code < MAX_ONE_B && len >= 1 { + write(ptr, 0, code as u8); + return Ok(1); + } else if code < MAX_TWO_B && len >= 2 { + write(ptr, 0, (code >> 6 & 0x1F) as u8 | TAG_TWO_B); + write(ptr, 1, (code & 0x3F) as u8 | TAG_CONT); + return Ok(2); + } else if code < MAX_THREE_B && len >= 3 { + write(ptr, 0, (code >> 12 & 0x0F) as u8 | TAG_THREE_B); + write(ptr, 1, (code >> 6 & 0x3F) as u8 | TAG_CONT); + write(ptr, 2, (code & 0x3F) as u8 | TAG_CONT); + return Ok(3); + } else if len >= 4 { + write(ptr, 0, (code >> 18 & 0x07) as u8 | TAG_FOUR_B); + write(ptr, 1, (code >> 12 & 0x3F) as u8 | TAG_CONT); + write(ptr, 2, (code >> 6 & 0x3F) as u8 | TAG_CONT); + write(ptr, 3, (code & 0x3F) as u8 | TAG_CONT); + return Ok(4); + }; + Err(EncodeUtf8Error) +} + + +#[test] +fn test_encode_utf8() { + // Test that all codepoints are encoded correctly + let mut data = [0u8; 16]; + for codepoint in 0..=(std::char::MAX as u32) { + if let Some(ch) = std::char::from_u32(codepoint) { + for elt in &mut data { *elt = 0; } + let ptr = data.as_mut_ptr(); + let len = data.len(); + unsafe { + let res = encode_utf8(ch, ptr, len).ok().unwrap(); + assert_eq!(res, ch.len_utf8()); + } + let string = std::str::from_utf8(&data).unwrap(); + assert_eq!(string.chars().next(), Some(ch)); + } + } +} + +#[test] +fn test_encode_utf8_oob() { + // test that we report oob if the buffer is too short + let mut data = [0u8; 16]; + let chars = ['a', 'α', '�', '𐍈']; + for (len, &ch) in (1..=4).zip(&chars) { + assert_eq!(len, ch.len_utf8(), "Len of ch={}", ch); + let ptr = data.as_mut_ptr(); + unsafe { + assert!(matches::matches!(encode_utf8(ch, ptr, len - 1), Err(_))); + assert!(matches::matches!(encode_utf8(ch, ptr, len), Ok(_))); + } + } +} + diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/src/errors.rs b/third_party/cargo/vendor/arrayvec-0.5.1/src/errors.rs new file mode 100644 index 0000000..5bea980 --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/src/errors.rs @@ -0,0 +1,53 @@ +use std::fmt; +#[cfg(feature="std")] +use std::any::Any; +#[cfg(feature="std")] +use std::error::Error; + +/// Error value indicating insufficient capacity +#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] +pub struct CapacityError { + element: T, +} + +impl CapacityError { + /// Create a new `CapacityError` from `element`. + pub fn new(element: T) -> CapacityError { + CapacityError { + element: element, + } + } + + /// Extract the overflowing element + pub fn element(self) -> T { + self.element + } + + /// Convert into a `CapacityError` that does not carry an element. + pub fn simplify(self) -> CapacityError { + CapacityError { element: () } + } +} + +const CAPERROR: &'static str = "insufficient capacity"; + +#[cfg(feature="std")] +/// Requires `features="std"`. +impl Error for CapacityError { + fn description(&self) -> &str { + CAPERROR + } +} + +impl fmt::Display for CapacityError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", CAPERROR) + } +} + +impl fmt::Debug for CapacityError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}: {}", "CapacityError", CAPERROR) + } +} + diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/src/lib.rs b/third_party/cargo/vendor/arrayvec-0.5.1/src/lib.rs new file mode 100644 index 0000000..0fea03f --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/src/lib.rs @@ -0,0 +1,1156 @@ +//! **arrayvec** provides the types `ArrayVec` and `ArrayString`: +//! array-backed vector and string types, which store their contents inline. +//! +//! The arrayvec package has the following cargo features: +//! +//! - `std` +//! - Optional, enabled by default +//! - Use libstd; disable to use `no_std` instead. +//! +//! - `serde` +//! - Optional +//! - Enable serialization for ArrayVec and ArrayString using serde 1.x +//! - `array-sizes-33-128`, `array-sizes-129-255` +//! - Optional +//! - Enable more array sizes (see [Array] for more information) +//! +//! ## Rust Version +//! +//! This version of arrayvec requires Rust 1.36 or later. +//! +#![doc(html_root_url="https://docs.rs/arrayvec/0.4/")] +#![cfg_attr(not(feature="std"), no_std)] + +#[cfg(feature="serde")] +extern crate serde; + +#[cfg(not(feature="std"))] +extern crate core as std; + +use std::cmp; +use std::iter; +use std::mem; +use std::ops::{Bound, Deref, DerefMut, RangeBounds}; +use std::ptr; +use std::slice; + +// extra traits +use std::borrow::{Borrow, BorrowMut}; +use std::hash::{Hash, Hasher}; +use std::fmt; + +#[cfg(feature="std")] +use std::io; + + +mod maybe_uninit; +use crate::maybe_uninit::MaybeUninit; + +#[cfg(feature="serde")] +use serde::{Serialize, Deserialize, Serializer, Deserializer}; + +mod array; +mod array_string; +mod char; +mod errors; + +pub use crate::array::Array; +use crate::array::Index; +pub use crate::array_string::ArrayString; +pub use crate::errors::CapacityError; + + +/// A vector with a fixed capacity. +/// +/// The `ArrayVec` is a vector backed by a fixed size array. It keeps track of +/// the number of initialized elements. +/// +/// The vector is a contiguous value that you can store directly on the stack +/// if needed. +/// +/// It offers a simple API but also dereferences to a slice, so +/// that the full slice API is available. +/// +/// ArrayVec can be converted into a by value iterator. +pub struct ArrayVec { + xs: MaybeUninit
, + len: A::Index, +} + +impl Drop for ArrayVec { + fn drop(&mut self) { + self.clear(); + + // NoDrop inhibits array's drop + // panic safety: NoDrop::drop will trigger on panic, so the inner + // array will not drop even after panic. + } +} + +macro_rules! panic_oob { + ($method_name:expr, $index:expr, $len:expr) => { + panic!(concat!("ArrayVec::", $method_name, ": index {} is out of bounds in vector of length {}"), + $index, $len) + } +} + +impl ArrayVec { + /// Create a new empty `ArrayVec`. + /// + /// Capacity is inferred from the type parameter. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 16]>::new(); + /// array.push(1); + /// array.push(2); + /// assert_eq!(&array[..], &[1, 2]); + /// assert_eq!(array.capacity(), 16); + /// ``` + pub fn new() -> ArrayVec { + unsafe { + ArrayVec { xs: MaybeUninit::uninitialized(), len: Index::from(0) } + } + } + + /// Return the number of elements in the `ArrayVec`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// array.pop(); + /// assert_eq!(array.len(), 2); + /// ``` + #[inline] + pub fn len(&self) -> usize { self.len.to_usize() } + + /// Return the capacity of the `ArrayVec`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let array = ArrayVec::from([1, 2, 3]); + /// assert_eq!(array.capacity(), 3); + /// ``` + #[inline(always)] + pub fn capacity(&self) -> usize { A::CAPACITY } + + /// Return if the `ArrayVec` is completely filled. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 1]>::new(); + /// assert!(!array.is_full()); + /// array.push(1); + /// assert!(array.is_full()); + /// ``` + pub fn is_full(&self) -> bool { self.len() == self.capacity() } + + /// Returns the capacity left in the `ArrayVec`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// array.pop(); + /// assert_eq!(array.remaining_capacity(), 1); + /// ``` + pub fn remaining_capacity(&self) -> usize { + self.capacity() - self.len() + } + + /// Push `element` to the end of the vector. + /// + /// ***Panics*** if the vector is already full. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// array.push(1); + /// array.push(2); + /// + /// assert_eq!(&array[..], &[1, 2]); + /// ``` + pub fn push(&mut self, element: A::Item) { + self.try_push(element).unwrap() + } + + /// Push `element` to the end of the vector. + /// + /// Return `Ok` if the push succeeds, or return an error if the vector + /// is already full. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// let push1 = array.try_push(1); + /// let push2 = array.try_push(2); + /// + /// assert!(push1.is_ok()); + /// assert!(push2.is_ok()); + /// + /// assert_eq!(&array[..], &[1, 2]); + /// + /// let overflow = array.try_push(3); + /// + /// assert!(overflow.is_err()); + /// ``` + pub fn try_push(&mut self, element: A::Item) -> Result<(), CapacityError> { + if self.len() < A::CAPACITY { + unsafe { + self.push_unchecked(element); + } + Ok(()) + } else { + Err(CapacityError::new(element)) + } + } + + + /// Push `element` to the end of the vector without checking the capacity. + /// + /// It is up to the caller to ensure the capacity of the vector is + /// sufficiently large. + /// + /// This method uses *debug assertions* to check that the arrayvec is not full. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// if array.len() + 2 <= array.capacity() { + /// unsafe { + /// array.push_unchecked(1); + /// array.push_unchecked(2); + /// } + /// } + /// + /// assert_eq!(&array[..], &[1, 2]); + /// ``` + pub unsafe fn push_unchecked(&mut self, element: A::Item) { + let len = self.len(); + debug_assert!(len < A::CAPACITY); + ptr::write(self.get_unchecked_ptr(len), element); + self.set_len(len + 1); + } + + /// Get pointer to where element at `index` would be + unsafe fn get_unchecked_ptr(&mut self, index: usize) -> *mut A::Item { + self.xs.ptr_mut().add(index) + } + + /// Insert `element` at position `index`. + /// + /// Shift up all elements after `index`. + /// + /// It is an error if the index is greater than the length or if the + /// arrayvec is full. + /// + /// ***Panics*** if the array is full or the `index` is out of bounds. See + /// `try_insert` for fallible version. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// array.insert(0, "x"); + /// array.insert(0, "y"); + /// assert_eq!(&array[..], &["y", "x"]); + /// + /// ``` + pub fn insert(&mut self, index: usize, element: A::Item) { + self.try_insert(index, element).unwrap() + } + + /// Insert `element` at position `index`. + /// + /// Shift up all elements after `index`; the `index` must be less than + /// or equal to the length. + /// + /// Returns an error if vector is already at full capacity. + /// + /// ***Panics*** `index` is out of bounds. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// assert!(array.try_insert(0, "x").is_ok()); + /// assert!(array.try_insert(0, "y").is_ok()); + /// assert!(array.try_insert(0, "z").is_err()); + /// assert_eq!(&array[..], &["y", "x"]); + /// + /// ``` + pub fn try_insert(&mut self, index: usize, element: A::Item) -> Result<(), CapacityError> { + if index > self.len() { + panic_oob!("try_insert", index, self.len()) + } + if self.len() == self.capacity() { + return Err(CapacityError::new(element)); + } + let len = self.len(); + + // follows is just like Vec + unsafe { // infallible + // The spot to put the new value + { + let p: *mut _ = self.get_unchecked_ptr(index); + // Shift everything over to make space. (Duplicating the + // `index`th element into two consecutive places.) + ptr::copy(p, p.offset(1), len - index); + // Write it in, overwriting the first copy of the `index`th + // element. + ptr::write(p, element); + } + self.set_len(len + 1); + } + Ok(()) + } + + /// Remove the last element in the vector and return it. + /// + /// Return `Some(` *element* `)` if the vector is non-empty, else `None`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::<[_; 2]>::new(); + /// + /// array.push(1); + /// + /// assert_eq!(array.pop(), Some(1)); + /// assert_eq!(array.pop(), None); + /// ``` + pub fn pop(&mut self) -> Option { + if self.len() == 0 { + return None; + } + unsafe { + let new_len = self.len() - 1; + self.set_len(new_len); + Some(ptr::read(self.get_unchecked_ptr(new_len))) + } + } + + /// Remove the element at `index` and swap the last element into its place. + /// + /// This operation is O(1). + /// + /// Return the *element* if the index is in bounds, else panic. + /// + /// ***Panics*** if the `index` is out of bounds. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// + /// assert_eq!(array.swap_remove(0), 1); + /// assert_eq!(&array[..], &[3, 2]); + /// + /// assert_eq!(array.swap_remove(1), 2); + /// assert_eq!(&array[..], &[3]); + /// ``` + pub fn swap_remove(&mut self, index: usize) -> A::Item { + self.swap_pop(index) + .unwrap_or_else(|| { + panic_oob!("swap_remove", index, self.len()) + }) + } + + /// Remove the element at `index` and swap the last element into its place. + /// + /// This is a checked version of `.swap_remove`. + /// This operation is O(1). + /// + /// Return `Some(` *element* `)` if the index is in bounds, else `None`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// + /// assert_eq!(array.swap_pop(0), Some(1)); + /// assert_eq!(&array[..], &[3, 2]); + /// + /// assert_eq!(array.swap_pop(10), None); + /// ``` + pub fn swap_pop(&mut self, index: usize) -> Option { + let len = self.len(); + if index >= len { + return None; + } + self.swap(index, len - 1); + self.pop() + } + + /// Remove the element at `index` and shift down the following elements. + /// + /// The `index` must be strictly less than the length of the vector. + /// + /// ***Panics*** if the `index` is out of bounds. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// + /// let removed_elt = array.remove(0); + /// assert_eq!(removed_elt, 1); + /// assert_eq!(&array[..], &[2, 3]); + /// ``` + pub fn remove(&mut self, index: usize) -> A::Item { + self.pop_at(index) + .unwrap_or_else(|| { + panic_oob!("remove", index, self.len()) + }) + } + + /// Remove the element at `index` and shift down the following elements. + /// + /// This is a checked version of `.remove(index)`. Returns `None` if there + /// is no element at `index`. Otherwise, return the element inside `Some`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3]); + /// + /// assert!(array.pop_at(0).is_some()); + /// assert_eq!(&array[..], &[2, 3]); + /// + /// assert!(array.pop_at(2).is_none()); + /// assert!(array.pop_at(10).is_none()); + /// ``` + pub fn pop_at(&mut self, index: usize) -> Option { + if index >= self.len() { + None + } else { + self.drain(index..index + 1).next() + } + } + + /// Shortens the vector, keeping the first `len` elements and dropping + /// the rest. + /// + /// If `len` is greater than the vector’s current length this has no + /// effect. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3, 4, 5]); + /// array.truncate(3); + /// assert_eq!(&array[..], &[1, 2, 3]); + /// array.truncate(4); + /// assert_eq!(&array[..], &[1, 2, 3]); + /// ``` + pub fn truncate(&mut self, new_len: usize) { + unsafe { + if new_len < self.len() { + let tail: *mut [_] = &mut self[new_len..]; + self.len = Index::from(new_len); + ptr::drop_in_place(tail); + } + } + } + + /// Remove all elements in the vector. + pub fn clear(&mut self) { + self.truncate(0) + } + + /// Retains only the elements specified by the predicate. + /// + /// In other words, remove all elements `e` such that `f(&mut e)` returns false. + /// This method operates in place and preserves the order of the retained + /// elements. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut array = ArrayVec::from([1, 2, 3, 4]); + /// array.retain(|x| *x & 1 != 0 ); + /// assert_eq!(&array[..], &[1, 3]); + /// ``` + pub fn retain(&mut self, mut f: F) + where F: FnMut(&mut A::Item) -> bool + { + let len = self.len(); + let mut del = 0; + { + let v = &mut **self; + + for i in 0..len { + if !f(&mut v[i]) { + del += 1; + } else if del > 0 { + v.swap(i - del, i); + } + } + } + if del > 0 { + self.drain(len - del..); + } + } + + /// Set the vector’s length without dropping or moving out elements + /// + /// This method is `unsafe` because it changes the notion of the + /// number of “valid” elements in the vector. Use with care. + /// + /// This method uses *debug assertions* to check that `length` is + /// not greater than the capacity. + pub unsafe fn set_len(&mut self, length: usize) { + debug_assert!(length <= self.capacity()); + self.len = Index::from(length); + } + + /// Copy and appends all elements in a slice to the `ArrayVec`. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut vec: ArrayVec<[usize; 10]> = ArrayVec::new(); + /// vec.push(1); + /// vec.try_extend_from_slice(&[2, 3]).unwrap(); + /// assert_eq!(&vec[..], &[1, 2, 3]); + /// ``` + /// + /// # Errors + /// + /// This method will return an error if the capacity left (see + /// [`remaining_capacity`]) is smaller then the length of the provided + /// slice. + /// + /// [`remaining_capacity`]: #method.remaining_capacity + pub fn try_extend_from_slice(&mut self, other: &[A::Item]) -> Result<(), CapacityError> + where A::Item: Copy, + { + if self.remaining_capacity() < other.len() { + return Err(CapacityError::new(())); + } + + let self_len = self.len(); + let other_len = other.len(); + + unsafe { + let dst = self.xs.ptr_mut().offset(self_len as isize); + ptr::copy_nonoverlapping(other.as_ptr(), dst, other_len); + self.set_len(self_len + other_len); + } + Ok(()) + } + + /// Create a draining iterator that removes the specified range in the vector + /// and yields the removed items from start to end. The element range is + /// removed even if the iterator is not consumed until the end. + /// + /// Note: It is unspecified how many elements are removed from the vector, + /// if the `Drain` value is leaked. + /// + /// **Panics** if the starting point is greater than the end point or if + /// the end point is greater than the length of the vector. + /// + /// ``` + /// use arrayvec::ArrayVec; + /// + /// let mut v = ArrayVec::from([1, 2, 3]); + /// let u: ArrayVec<[_; 3]> = v.drain(0..2).collect(); + /// assert_eq!(&v[..], &[3]); + /// assert_eq!(&u[..], &[1, 2]); + /// ``` + pub fn drain(&mut self, range: R) -> Drain + where R: RangeBounds + { + // Memory safety + // + // When the Drain is first created, it shortens the length of + // the source vector to make sure no uninitialized or moved-from elements + // are accessible at all if the Drain's destructor never gets to run. + // + // Drain will ptr::read out the values to remove. + // When finished, remaining tail of the vec is copied back to cover + // the hole, and the vector length is restored to the new length. + // + let len = self.len(); + let start = match range.start_bound() { + Bound::Unbounded => 0, + Bound::Included(&i) => i, + Bound::Excluded(&i) => i.saturating_add(1), + }; + let end = match range.end_bound() { + Bound::Excluded(&j) => j, + Bound::Included(&j) => j.saturating_add(1), + Bound::Unbounded => len, + }; + self.drain_range(start, end) + } + + fn drain_range(&mut self, start: usize, end: usize) -> Drain + { + let len = self.len(); + // bounds check happens here + let range_slice: *const _ = &self[start..end]; + + unsafe { + // set self.vec length's to start, to be safe in case Drain is leaked + self.set_len(start); + Drain { + tail_start: end, + tail_len: len - end, + iter: (*range_slice).iter(), + vec: self as *mut _, + } + } + } + + /// Return the inner fixed size array, if it is full to its capacity. + /// + /// Return an `Ok` value with the array if length equals capacity, + /// return an `Err` with self otherwise. + pub fn into_inner(self) -> Result { + if self.len() < self.capacity() { + Err(self) + } else { + unsafe { + let array = ptr::read(self.xs.ptr() as *const A); + mem::forget(self); + Ok(array) + } + } + } + + /// Dispose of `self` (same as drop) + #[deprecated="Use std::mem::drop instead, if at all needed."] + pub fn dispose(mut self) { + self.clear(); + mem::forget(self); + } + + /// Return a slice containing all elements of the vector. + pub fn as_slice(&self) -> &[A::Item] { + self + } + + /// Return a mutable slice containing all elements of the vector. + pub fn as_mut_slice(&mut self) -> &mut [A::Item] { + self + } + + /// Return a raw pointer to the vector's buffer. + pub fn as_ptr(&self) -> *const A::Item { + self.xs.ptr() + } + + /// Return a raw mutable pointer to the vector's buffer. + pub fn as_mut_ptr(&mut self) -> *mut A::Item { + self.xs.ptr_mut() + } +} + +impl Deref for ArrayVec { + type Target = [A::Item]; + #[inline] + fn deref(&self) -> &[A::Item] { + unsafe { + slice::from_raw_parts(self.xs.ptr(), self.len()) + } + } +} + +impl DerefMut for ArrayVec { + #[inline] + fn deref_mut(&mut self) -> &mut [A::Item] { + let len = self.len(); + unsafe { + slice::from_raw_parts_mut(self.xs.ptr_mut(), len) + } + } +} + +/// Create an `ArrayVec` from an array. +/// +/// ``` +/// use arrayvec::ArrayVec; +/// +/// let mut array = ArrayVec::from([1, 2, 3]); +/// assert_eq!(array.len(), 3); +/// assert_eq!(array.capacity(), 3); +/// ``` +impl From for ArrayVec { + fn from(array: A) -> Self { + ArrayVec { xs: MaybeUninit::from(array), len: Index::from(A::CAPACITY) } + } +} + + +/// Iterate the `ArrayVec` with references to each element. +/// +/// ``` +/// use arrayvec::ArrayVec; +/// +/// let array = ArrayVec::from([1, 2, 3]); +/// +/// for elt in &array { +/// // ... +/// } +/// ``` +impl<'a, A: Array> IntoIterator for &'a ArrayVec { + type Item = &'a A::Item; + type IntoIter = slice::Iter<'a, A::Item>; + fn into_iter(self) -> Self::IntoIter { self.iter() } +} + +/// Iterate the `ArrayVec` with mutable references to each element. +/// +/// ``` +/// use arrayvec::ArrayVec; +/// +/// let mut array = ArrayVec::from([1, 2, 3]); +/// +/// for elt in &mut array { +/// // ... +/// } +/// ``` +impl<'a, A: Array> IntoIterator for &'a mut ArrayVec { + type Item = &'a mut A::Item; + type IntoIter = slice::IterMut<'a, A::Item>; + fn into_iter(self) -> Self::IntoIter { self.iter_mut() } +} + +/// Iterate the `ArrayVec` with each element by value. +/// +/// The vector is consumed by this operation. +/// +/// ``` +/// use arrayvec::ArrayVec; +/// +/// for elt in ArrayVec::from([1, 2, 3]) { +/// // ... +/// } +/// ``` +impl IntoIterator for ArrayVec { + type Item = A::Item; + type IntoIter = IntoIter; + fn into_iter(self) -> IntoIter { + IntoIter { index: Index::from(0), v: self, } + } +} + + +/// By-value iterator for `ArrayVec`. +pub struct IntoIter { + index: A::Index, + v: ArrayVec, +} + +impl Iterator for IntoIter { + type Item = A::Item; + + fn next(&mut self) -> Option { + if self.index == self.v.len { + None + } else { + unsafe { + let index = self.index.to_usize(); + self.index = Index::from(index + 1); + Some(ptr::read(self.v.get_unchecked_ptr(index))) + } + } + } + + fn size_hint(&self) -> (usize, Option) { + let len = self.v.len() - self.index.to_usize(); + (len, Some(len)) + } +} + +impl DoubleEndedIterator for IntoIter { + fn next_back(&mut self) -> Option { + if self.index == self.v.len { + None + } else { + unsafe { + let new_len = self.v.len() - 1; + self.v.set_len(new_len); + Some(ptr::read(self.v.get_unchecked_ptr(new_len))) + } + } + } +} + +impl ExactSizeIterator for IntoIter { } + +impl Drop for IntoIter { + fn drop(&mut self) { + // panic safety: Set length to 0 before dropping elements. + let index = self.index.to_usize(); + let len = self.v.len(); + unsafe { + self.v.set_len(0); + let elements = slice::from_raw_parts_mut( + self.v.get_unchecked_ptr(index), + len - index); + ptr::drop_in_place(elements); + } + } +} + +impl Clone for IntoIter +where + A::Item: Clone, +{ + fn clone(&self) -> IntoIter { + self.v[self.index.to_usize()..] + .iter() + .cloned() + .collect::>() + .into_iter() + } +} + +impl fmt::Debug for IntoIter +where + A::Item: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_list() + .entries(&self.v[self.index.to_usize()..]) + .finish() + } +} + +/// A draining iterator for `ArrayVec`. +pub struct Drain<'a, A> + where A: Array, + A::Item: 'a, +{ + /// Index of tail to preserve + tail_start: usize, + /// Length of tail + tail_len: usize, + /// Current remaining range to remove + iter: slice::Iter<'a, A::Item>, + vec: *mut ArrayVec, +} + +unsafe impl<'a, A: Array + Sync> Sync for Drain<'a, A> {} +unsafe impl<'a, A: Array + Send> Send for Drain<'a, A> {} + +impl<'a, A: Array> Iterator for Drain<'a, A> + where A::Item: 'a, +{ + type Item = A::Item; + + fn next(&mut self) -> Option { + self.iter.next().map(|elt| + unsafe { + ptr::read(elt as *const _) + } + ) + } + + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } +} + +impl<'a, A: Array> DoubleEndedIterator for Drain<'a, A> + where A::Item: 'a, +{ + fn next_back(&mut self) -> Option { + self.iter.next_back().map(|elt| + unsafe { + ptr::read(elt as *const _) + } + ) + } +} + +impl<'a, A: Array> ExactSizeIterator for Drain<'a, A> where A::Item: 'a {} + +impl<'a, A: Array> Drop for Drain<'a, A> + where A::Item: 'a +{ + fn drop(&mut self) { + // len is currently 0 so panicking while dropping will not cause a double drop. + + // exhaust self first + while let Some(_) = self.next() { } + + if self.tail_len > 0 { + unsafe { + let source_vec = &mut *self.vec; + // memmove back untouched tail, update to new length + let start = source_vec.len(); + let tail = self.tail_start; + let src = source_vec.as_ptr().offset(tail as isize); + let dst = source_vec.as_mut_ptr().offset(start as isize); + ptr::copy(src, dst, self.tail_len); + source_vec.set_len(start + self.tail_len); + } + } + } +} + +struct ScopeExitGuard + where F: FnMut(&Data, &mut T) +{ + value: T, + data: Data, + f: F, +} + +impl Drop for ScopeExitGuard + where F: FnMut(&Data, &mut T) +{ + fn drop(&mut self) { + (self.f)(&self.data, &mut self.value) + } +} + + + +/// Extend the `ArrayVec` with an iterator. +/// +/// Does not extract more items than there is space for. No error +/// occurs if there are more iterator elements. +impl Extend for ArrayVec { + fn extend>(&mut self, iter: T) { + let take = self.capacity() - self.len(); + unsafe { + let len = self.len(); + let mut ptr = raw_ptr_add(self.as_mut_ptr(), len); + let end_ptr = raw_ptr_add(ptr, take); + // Keep the length in a separate variable, write it back on scope + // exit. To help the compiler with alias analysis and stuff. + // We update the length to handle panic in the iteration of the + // user's iterator, without dropping any elements on the floor. + let mut guard = ScopeExitGuard { + value: &mut self.len, + data: len, + f: move |&len, self_len| { + **self_len = Index::from(len); + } + }; + let mut iter = iter.into_iter(); + loop { + if ptr == end_ptr { break; } + if let Some(elt) = iter.next() { + raw_ptr_write(ptr, elt); + ptr = raw_ptr_add(ptr, 1); + guard.data += 1; + } else { + break; + } + } + } + } +} + +/// Rawptr add but uses arithmetic distance for ZST +unsafe fn raw_ptr_add(ptr: *mut T, offset: usize) -> *mut T { + if mem::size_of::() == 0 { + // Special case for ZST + (ptr as usize).wrapping_add(offset) as _ + } else { + ptr.offset(offset as isize) + } +} + +unsafe fn raw_ptr_write(ptr: *mut T, value: T) { + if mem::size_of::() == 0 { + /* nothing */ + } else { + ptr::write(ptr, value) + } +} + +/// Create an `ArrayVec` from an iterator. +/// +/// Does not extract more items than there is space for. No error +/// occurs if there are more iterator elements. +impl iter::FromIterator for ArrayVec { + fn from_iter>(iter: T) -> Self { + let mut array = ArrayVec::new(); + array.extend(iter); + array + } +} + +impl Clone for ArrayVec + where A::Item: Clone +{ + fn clone(&self) -> Self { + self.iter().cloned().collect() + } + + fn clone_from(&mut self, rhs: &Self) { + // recursive case for the common prefix + let prefix = cmp::min(self.len(), rhs.len()); + self[..prefix].clone_from_slice(&rhs[..prefix]); + + if prefix < self.len() { + // rhs was shorter + for _ in 0..self.len() - prefix { + self.pop(); + } + } else { + let rhs_elems = rhs[self.len()..].iter().cloned(); + self.extend(rhs_elems); + } + } +} + +impl Hash for ArrayVec + where A::Item: Hash +{ + fn hash(&self, state: &mut H) { + Hash::hash(&**self, state) + } +} + +impl PartialEq for ArrayVec + where A::Item: PartialEq +{ + fn eq(&self, other: &Self) -> bool { + **self == **other + } +} + +impl PartialEq<[A::Item]> for ArrayVec + where A::Item: PartialEq +{ + fn eq(&self, other: &[A::Item]) -> bool { + **self == *other + } +} + +impl Eq for ArrayVec where A::Item: Eq { } + +impl Borrow<[A::Item]> for ArrayVec { + fn borrow(&self) -> &[A::Item] { self } +} + +impl BorrowMut<[A::Item]> for ArrayVec { + fn borrow_mut(&mut self) -> &mut [A::Item] { self } +} + +impl AsRef<[A::Item]> for ArrayVec { + fn as_ref(&self) -> &[A::Item] { self } +} + +impl AsMut<[A::Item]> for ArrayVec { + fn as_mut(&mut self) -> &mut [A::Item] { self } +} + +impl fmt::Debug for ArrayVec where A::Item: fmt::Debug { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } +} + +impl Default for ArrayVec { + /// Return an empty array + fn default() -> ArrayVec { + ArrayVec::new() + } +} + +impl PartialOrd for ArrayVec where A::Item: PartialOrd { + fn partial_cmp(&self, other: &ArrayVec) -> Option { + (**self).partial_cmp(other) + } + + fn lt(&self, other: &Self) -> bool { + (**self).lt(other) + } + + fn le(&self, other: &Self) -> bool { + (**self).le(other) + } + + fn ge(&self, other: &Self) -> bool { + (**self).ge(other) + } + + fn gt(&self, other: &Self) -> bool { + (**self).gt(other) + } +} + +impl Ord for ArrayVec where A::Item: Ord { + fn cmp(&self, other: &ArrayVec) -> cmp::Ordering { + (**self).cmp(other) + } +} + +#[cfg(feature="std")] +/// `Write` appends written data to the end of the vector. +/// +/// Requires `features="std"`. +impl> io::Write for ArrayVec { + fn write(&mut self, data: &[u8]) -> io::Result { + let len = cmp::min(self.remaining_capacity(), data.len()); + let _result = self.try_extend_from_slice(&data[..len]); + debug_assert!(_result.is_ok()); + Ok(len) + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } +} + +#[cfg(feature="serde")] +/// Requires crate feature `"serde"` +impl> Serialize for ArrayVec { + fn serialize(&self, serializer: S) -> Result + where S: Serializer + { + serializer.collect_seq(self) + } +} + +#[cfg(feature="serde")] +/// Requires crate feature `"serde"` +impl<'de, T: Deserialize<'de>, A: Array> Deserialize<'de> for ArrayVec { + fn deserialize(deserializer: D) -> Result + where D: Deserializer<'de> + { + use serde::de::{Visitor, SeqAccess, Error}; + use std::marker::PhantomData; + + struct ArrayVecVisitor<'de, T: Deserialize<'de>, A: Array>(PhantomData<(&'de (), T, A)>); + + impl<'de, T: Deserialize<'de>, A: Array> Visitor<'de> for ArrayVecVisitor<'de, T, A> { + type Value = ArrayVec; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!(formatter, "an array with no more than {} items", A::CAPACITY) + } + + fn visit_seq(self, mut seq: SA) -> Result + where SA: SeqAccess<'de>, + { + let mut values = ArrayVec::::new(); + + while let Some(value) = seq.next_element()? { + if let Err(_) = values.try_push(value) { + return Err(SA::Error::invalid_length(A::CAPACITY + 1, &self)); + } + } + + Ok(values) + } + } + + deserializer.deserialize_seq(ArrayVecVisitor::(PhantomData)) + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/src/maybe_uninit.rs b/third_party/cargo/vendor/arrayvec-0.5.1/src/maybe_uninit.rs new file mode 100644 index 0000000..fc69a3f --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/src/maybe_uninit.rs @@ -0,0 +1,44 @@ + + +use crate::array::Array; +use std::mem::MaybeUninit as StdMaybeUninit; + +#[derive(Copy)] +pub struct MaybeUninit { + inner: StdMaybeUninit, +} + +impl Clone for MaybeUninit + where T: Copy +{ + fn clone(&self) -> Self { *self } +} + +impl MaybeUninit { + /// Create a new MaybeUninit with uninitialized interior + pub unsafe fn uninitialized() -> Self { + MaybeUninit { inner: StdMaybeUninit::uninit() } + } + + /// Create a new MaybeUninit from the value `v`. + pub fn from(v: T) -> Self { + MaybeUninit { inner: StdMaybeUninit::new(v) } + } + + // Raw pointer casts written so that we don't reference or access the + // uninitialized interior value + + /// Return a raw pointer to the start of the interior array + pub fn ptr(&self) -> *const T::Item + where T: Array + { + self.inner.as_ptr() as *const T::Item + } + + /// Return a mut raw pointer to the start of the interior array + pub fn ptr_mut(&mut self) -> *mut T::Item + where T: Array + { + self.inner.as_mut_ptr() as *mut T::Item + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/tests/serde.rs b/third_party/cargo/vendor/arrayvec-0.5.1/tests/serde.rs new file mode 100644 index 0000000..3876d2a --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/tests/serde.rs @@ -0,0 +1,79 @@ +#![cfg(feature = "serde")] +extern crate arrayvec; +extern crate serde_test; + +mod array_vec { + use arrayvec::ArrayVec; + + use serde_test::{Token, assert_tokens, assert_de_tokens_error}; + + #[test] + fn test_ser_de_empty() { + let vec = ArrayVec::<[u32; 0]>::new(); + + assert_tokens(&vec, &[ + Token::Seq { len: Some(0) }, + Token::SeqEnd, + ]); + } + + + #[test] + fn test_ser_de() { + let mut vec = ArrayVec::<[u32; 3]>::new(); + vec.push(20); + vec.push(55); + vec.push(123); + + assert_tokens(&vec, &[ + Token::Seq { len: Some(3) }, + Token::U32(20), + Token::U32(55), + Token::U32(123), + Token::SeqEnd, + ]); + } + + #[test] + fn test_de_too_large() { + assert_de_tokens_error::>(&[ + Token::Seq { len: Some(3) }, + Token::U32(13), + Token::U32(42), + Token::U32(68), + ], "invalid length 3, expected an array with no more than 2 items"); + } +} + +mod array_string { + use arrayvec::ArrayString; + + use serde_test::{Token, assert_tokens, assert_de_tokens_error}; + + #[test] + fn test_ser_de_empty() { + let string = ArrayString::<[u8; 0]>::new(); + + assert_tokens(&string, &[ + Token::Str(""), + ]); + } + + + #[test] + fn test_ser_de() { + let string = ArrayString::<[u8; 9]>::from("1234 abcd") + .expect("expected exact specified capacity to be enough"); + + assert_tokens(&string, &[ + Token::Str("1234 abcd"), + ]); + } + + #[test] + fn test_de_too_large() { + assert_de_tokens_error::>(&[ + Token::Str("afd") + ], "invalid length 3, expected a string no more than 2 bytes long"); + } +} diff --git a/third_party/cargo/vendor/arrayvec-0.5.1/tests/tests.rs b/third_party/cargo/vendor/arrayvec-0.5.1/tests/tests.rs new file mode 100644 index 0000000..1cf3aad --- /dev/null +++ b/third_party/cargo/vendor/arrayvec-0.5.1/tests/tests.rs @@ -0,0 +1,679 @@ +extern crate arrayvec; +#[macro_use] extern crate matches; + +use arrayvec::ArrayVec; +use arrayvec::ArrayString; +use std::mem; +use arrayvec::CapacityError; + +use std::collections::HashMap; + + +#[test] +fn test_simple() { + use std::ops::Add; + + let mut vec: ArrayVec<[Vec; 3]> = ArrayVec::new(); + + vec.push(vec![1, 2, 3, 4]); + vec.push(vec![10]); + vec.push(vec![-1, 13, -2]); + + for elt in &vec { + assert_eq!(elt.iter().fold(0, Add::add), 10); + } + + let sum_len = vec.into_iter().map(|x| x.len()).fold(0, Add::add); + assert_eq!(sum_len, 8); +} + +#[test] +fn test_capacity_left() { + let mut vec: ArrayVec<[usize; 4]> = ArrayVec::new(); + assert_eq!(vec.remaining_capacity(), 4); + vec.push(1); + assert_eq!(vec.remaining_capacity(), 3); + vec.push(2); + assert_eq!(vec.remaining_capacity(), 2); + vec.push(3); + assert_eq!(vec.remaining_capacity(), 1); + vec.push(4); + assert_eq!(vec.remaining_capacity(), 0); +} + +#[test] +fn test_extend_from_slice() { + let mut vec: ArrayVec<[usize; 10]> = ArrayVec::new(); + + vec.try_extend_from_slice(&[1, 2, 3]).unwrap(); + assert_eq!(vec.len(), 3); + assert_eq!(&vec[..], &[1, 2, 3]); + assert_eq!(vec.pop(), Some(3)); + assert_eq!(&vec[..], &[1, 2]); +} + +#[test] +fn test_extend_from_slice_error() { + let mut vec: ArrayVec<[usize; 10]> = ArrayVec::new(); + + vec.try_extend_from_slice(&[1, 2, 3]).unwrap(); + let res = vec.try_extend_from_slice(&[0; 8]); + assert_matches!(res, Err(_)); + + let mut vec: ArrayVec<[usize; 0]> = ArrayVec::new(); + let res = vec.try_extend_from_slice(&[0; 1]); + assert_matches!(res, Err(_)); +} + +#[test] +fn test_u16_index() { + const N: usize = 4096; + let mut vec: ArrayVec<[_; N]> = ArrayVec::new(); + for _ in 0..N { + assert!(vec.try_push(1u8).is_ok()); + } + assert!(vec.try_push(0).is_err()); + assert_eq!(vec.len(), N); +} + +#[test] +fn test_iter() { + let mut iter = ArrayVec::from([1, 2, 3]).into_iter(); + assert_eq!(iter.size_hint(), (3, Some(3))); + assert_eq!(iter.next_back(), Some(3)); + assert_eq!(iter.next(), Some(1)); + assert_eq!(iter.next_back(), Some(2)); + assert_eq!(iter.size_hint(), (0, Some(0))); + assert_eq!(iter.next_back(), None); +} + +#[test] +fn test_drop() { + use std::cell::Cell; + + let flag = &Cell::new(0); + + #[derive(Clone)] + struct Bump<'a>(&'a Cell); + + impl<'a> Drop for Bump<'a> { + fn drop(&mut self) { + let n = self.0.get(); + self.0.set(n + 1); + } + } + + { + let mut array = ArrayVec::<[Bump; 128]>::new(); + array.push(Bump(flag)); + array.push(Bump(flag)); + } + assert_eq!(flag.get(), 2); + + // test something with the nullable pointer optimization + flag.set(0); + + { + let mut array = ArrayVec::<[_; 3]>::new(); + array.push(vec![Bump(flag)]); + array.push(vec![Bump(flag), Bump(flag)]); + array.push(vec![]); + let push4 = array.try_push(vec![Bump(flag)]); + assert_eq!(flag.get(), 0); + drop(push4); + assert_eq!(flag.get(), 1); + drop(array.pop()); + assert_eq!(flag.get(), 1); + drop(array.pop()); + assert_eq!(flag.get(), 3); + } + + assert_eq!(flag.get(), 4); + + // test into_inner + flag.set(0); + { + let mut array = ArrayVec::<[_; 3]>::new(); + array.push(Bump(flag)); + array.push(Bump(flag)); + array.push(Bump(flag)); + let inner = array.into_inner(); + assert!(inner.is_ok()); + assert_eq!(flag.get(), 0); + drop(inner); + assert_eq!(flag.get(), 3); + } + + // test cloning into_iter + flag.set(0); + { + let mut array = ArrayVec::<[_; 3]>::new(); + array.push(Bump(flag)); + array.push(Bump(flag)); + array.push(Bump(flag)); + let mut iter = array.into_iter(); + assert_eq!(flag.get(), 0); + iter.next(); + assert_eq!(flag.get(), 1); + let clone = iter.clone(); + assert_eq!(flag.get(), 1); + drop(clone); + assert_eq!(flag.get(), 3); + drop(iter); + assert_eq!(flag.get(), 5); + } +} + +#[test] +fn test_drop_panics() { + use std::cell::Cell; + use std::panic::catch_unwind; + use std::panic::AssertUnwindSafe; + + let flag = &Cell::new(0); + + struct Bump<'a>(&'a Cell); + + // Panic in the first drop + impl<'a> Drop for Bump<'a> { + fn drop(&mut self) { + let n = self.0.get(); + self.0.set(n + 1); + if n == 0 { + panic!("Panic in Bump's drop"); + } + } + } + // check if rust is new enough + flag.set(0); + { + let array = vec![Bump(flag), Bump(flag)]; + let res = catch_unwind(AssertUnwindSafe(|| { + drop(array); + })); + assert!(res.is_err()); + } + + if flag.get() != 2 { + println!("test_drop_panics: skip, this version of Rust doesn't continue in drop_in_place"); + return; + } + + flag.set(0); + { + let mut array = ArrayVec::<[Bump; 128]>::new(); + array.push(Bump(flag)); + array.push(Bump(flag)); + array.push(Bump(flag)); + + let res = catch_unwind(AssertUnwindSafe(|| { + drop(array); + })); + assert!(res.is_err()); + } + // Check that all the elements drop, even if the first drop panics. + assert_eq!(flag.get(), 3); + + + flag.set(0); + { + let mut array = ArrayVec::<[Bump; 16]>::new(); + array.push(Bump(flag)); + array.push(Bump(flag)); + array.push(Bump(flag)); + array.push(Bump(flag)); + array.push(Bump(flag)); + + let i = 2; + let tail_len = array.len() - i; + + let res = catch_unwind(AssertUnwindSafe(|| { + array.truncate(i); + })); + assert!(res.is_err()); + // Check that all the tail elements drop, even if the first drop panics. + assert_eq!(flag.get(), tail_len as i32); + } + + +} + +#[test] +fn test_extend() { + let mut range = 0..10; + + let mut array: ArrayVec<[_; 5]> = range.by_ref().collect(); + assert_eq!(&array[..], &[0, 1, 2, 3, 4]); + assert_eq!(range.next(), Some(5)); + + array.extend(range.by_ref()); + assert_eq!(range.next(), Some(6)); + + let mut array: ArrayVec<[_; 10]> = (0..3).collect(); + assert_eq!(&array[..], &[0, 1, 2]); + array.extend(3..5); + assert_eq!(&array[..], &[0, 1, 2, 3, 4]); +} + +#[test] +fn test_is_send_sync() { + let data = ArrayVec::<[Vec; 5]>::new(); + &data as &dyn Send; + &data as &dyn Sync; +} + +#[test] +fn test_compact_size() { + // Future rust will kill these drop flags! + // 4 elements size + 1 len + 1 enum tag + [1 drop flag] + type ByteArray = ArrayVec<[u8; 4]>; + println!("{}", mem::size_of::()); + assert!(mem::size_of::() <= 8); + + // 1 enum tag + 1 drop flag + type EmptyArray = ArrayVec<[u8; 0]>; + println!("{}", mem::size_of::()); + assert!(mem::size_of::() <= 2); + + // 12 element size + 1 enum tag + 3 padding + 1 len + 1 drop flag + 2 padding + type QuadArray = ArrayVec<[u32; 3]>; + println!("{}", mem::size_of::()); + assert!(mem::size_of::() <= 24); +} + +#[test] +fn test_still_works_with_option_arrayvec() { + type RefArray = ArrayVec<[&'static i32; 2]>; + let array = Some(RefArray::new()); + assert!(array.is_some()); + println!("{:?}", array); +} + +#[test] +fn test_drain() { + let mut v = ArrayVec::from([0; 8]); + v.pop(); + v.drain(0..7); + assert_eq!(&v[..], &[]); + + v.extend(0..); + v.drain(1..4); + assert_eq!(&v[..], &[0, 4, 5, 6, 7]); + let u: ArrayVec<[_; 3]> = v.drain(1..4).rev().collect(); + assert_eq!(&u[..], &[6, 5, 4]); + assert_eq!(&v[..], &[0, 7]); + v.drain(..); + assert_eq!(&v[..], &[]); +} + +#[test] +fn test_drain_range_inclusive() { + let mut v = ArrayVec::from([0; 8]); + v.drain(0..=7); + assert_eq!(&v[..], &[]); + + v.extend(0..); + v.drain(1..=4); + assert_eq!(&v[..], &[0, 5, 6, 7]); + let u: ArrayVec<[_; 3]> = v.drain(1..=2).rev().collect(); + assert_eq!(&u[..], &[6, 5]); + assert_eq!(&v[..], &[0, 7]); + v.drain(..); + assert_eq!(&v[..], &[]); +} + +#[test] +#[should_panic] +fn test_drain_range_inclusive_oob() { + let mut v = ArrayVec::from([0; 0]); + v.drain(0..=0); +} + +#[test] +fn test_retain() { + let mut v = ArrayVec::from([0; 8]); + for (i, elt) in v.iter_mut().enumerate() { + *elt = i; + } + v.retain(|_| true); + assert_eq!(&v[..], &[0, 1, 2, 3, 4, 5, 6, 7]); + v.retain(|elt| { + *elt /= 2; + *elt % 2 == 0 + }); + assert_eq!(&v[..], &[0, 0, 2, 2]); + v.retain(|_| false); + assert_eq!(&v[..], &[]); +} + +#[test] +#[should_panic] +fn test_drain_oob() { + let mut v = ArrayVec::from([0; 8]); + v.pop(); + v.drain(0..8); +} + +#[test] +#[should_panic] +fn test_drop_panic() { + struct DropPanic; + + impl Drop for DropPanic { + fn drop(&mut self) { + panic!("drop"); + } + } + + let mut array = ArrayVec::<[DropPanic; 1]>::new(); + array.push(DropPanic); +} + +#[test] +#[should_panic] +fn test_drop_panic_into_iter() { + struct DropPanic; + + impl Drop for DropPanic { + fn drop(&mut self) { + panic!("drop"); + } + } + + let mut array = ArrayVec::<[DropPanic; 1]>::new(); + array.push(DropPanic); + array.into_iter(); +} + +#[test] +fn test_insert() { + let mut v = ArrayVec::from([]); + assert_matches!(v.try_push(1), Err(_)); + + let mut v = ArrayVec::<[_; 3]>::new(); + v.insert(0, 0); + v.insert(1, 1); + //let ret1 = v.try_insert(3, 3); + //assert_matches!(ret1, Err(InsertError::OutOfBounds(_))); + assert_eq!(&v[..], &[0, 1]); + v.insert(2, 2); + assert_eq!(&v[..], &[0, 1, 2]); + + let ret2 = v.try_insert(1, 9); + assert_eq!(&v[..], &[0, 1, 2]); + assert_matches!(ret2, Err(_)); + + let mut v = ArrayVec::from([2]); + assert_matches!(v.try_insert(0, 1), Err(CapacityError { .. })); + assert_matches!(v.try_insert(1, 1), Err(CapacityError { .. })); + //assert_matches!(v.try_insert(2, 1), Err(CapacityError { .. })); +} + +#[test] +fn test_into_inner_1() { + let mut v = ArrayVec::from([1, 2]); + v.pop(); + let u = v.clone(); + assert_eq!(v.into_inner(), Err(u)); +} + +#[test] +fn test_into_inner_2() { + let mut v = ArrayVec::<[String; 4]>::new(); + v.push("a".into()); + v.push("b".into()); + v.push("c".into()); + v.push("d".into()); + assert_eq!(v.into_inner().unwrap(), ["a", "b", "c", "d"]); +} + +#[test] +fn test_into_inner_3_() { + let mut v = ArrayVec::<[i32; 4]>::new(); + v.extend(1..); + assert_eq!(v.into_inner().unwrap(), [1, 2, 3, 4]); +} + +#[cfg(feature="std")] +#[test] +fn test_write() { + use std::io::Write; + let mut v = ArrayVec::<[_; 8]>::new(); + write!(&mut v, "\x01\x02\x03").unwrap(); + assert_eq!(&v[..], &[1, 2, 3]); + let r = v.write(&[9; 16]).unwrap(); + assert_eq!(r, 5); + assert_eq!(&v[..], &[1, 2, 3, 9, 9, 9, 9, 9]); +} + +#[test] +fn array_clone_from() { + let mut v = ArrayVec::<[_; 4]>::new(); + v.push(vec![1, 2]); + v.push(vec![3, 4, 5]); + v.push(vec![6]); + let reference = v.to_vec(); + let mut u = ArrayVec::<[_; 4]>::new(); + u.clone_from(&v); + assert_eq!(&u, &reference[..]); + + let mut t = ArrayVec::<[_; 4]>::new(); + t.push(vec![97]); + t.push(vec![]); + t.push(vec![5, 6, 2]); + t.push(vec![2]); + t.clone_from(&v); + assert_eq!(&t, &reference[..]); + t.clear(); + t.clone_from(&v); + assert_eq!(&t, &reference[..]); +} + +#[cfg(feature="std")] +#[test] +fn test_string() { + use std::error::Error; + + let text = "hello world"; + let mut s = ArrayString::<[_; 16]>::new(); + s.try_push_str(text).unwrap(); + assert_eq!(&s, text); + assert_eq!(text, &s); + + // Make sure Hash / Eq / Borrow match up so we can use HashMap + let mut map = HashMap::new(); + map.insert(s, 1); + assert_eq!(map[text], 1); + + let mut t = ArrayString::<[_; 2]>::new(); + assert!(t.try_push_str(text).is_err()); + assert_eq!(&t, ""); + + t.push_str("ab"); + // DerefMut + let tmut: &mut str = &mut t; + assert_eq!(tmut, "ab"); + + // Test Error trait / try + let t = || -> Result<(), Box> { + let mut t = ArrayString::<[_; 2]>::new(); + t.try_push_str(text)?; + Ok(()) + }(); + assert!(t.is_err()); +} + +#[test] +fn test_string_from() { + let text = "hello world"; + // Test `from` constructor + let u = ArrayString::<[_; 11]>::from(text).unwrap(); + assert_eq!(&u, text); + assert_eq!(u.len(), text.len()); +} + +#[test] +fn test_string_parse_from_str() { + let text = "hello world"; + let u: ArrayString<[_; 11]> = text.parse().unwrap(); + assert_eq!(&u, text); + assert_eq!(u.len(), text.len()); +} + +#[test] +fn test_string_from_bytes() { + let text = "hello world"; + let u = ArrayString::from_byte_string(b"hello world").unwrap(); + assert_eq!(&u, text); + assert_eq!(u.len(), text.len()); +} + +#[test] +fn test_string_clone() { + let text = "hi"; + let mut s = ArrayString::<[_; 4]>::new(); + s.push_str("abcd"); + let t = ArrayString::<[_; 4]>::from(text).unwrap(); + s.clone_from(&t); + assert_eq!(&t, &s); +} + +#[test] +fn test_string_push() { + let text = "abcαβγ"; + let mut s = ArrayString::<[_; 8]>::new(); + for c in text.chars() { + if let Err(_) = s.try_push(c) { + break; + } + } + assert_eq!("abcαβ", &s[..]); + s.push('x'); + assert_eq!("abcαβx", &s[..]); + assert!(s.try_push('x').is_err()); +} + + +#[test] +fn test_insert_at_length() { + let mut v = ArrayVec::<[_; 8]>::new(); + let result1 = v.try_insert(0, "a"); + let result2 = v.try_insert(1, "b"); + assert!(result1.is_ok() && result2.is_ok()); + assert_eq!(&v[..], &["a", "b"]); +} + +#[should_panic] +#[test] +fn test_insert_out_of_bounds() { + let mut v = ArrayVec::<[_; 8]>::new(); + let _ = v.try_insert(1, "test"); +} + +/* + * insert that pushes out the last + let mut u = ArrayVec::from([1, 2, 3, 4]); + let ret = u.try_insert(3, 99); + assert_eq!(&u[..], &[1, 2, 3, 99]); + assert_matches!(ret, Err(_)); + let ret = u.try_insert(4, 77); + assert_eq!(&u[..], &[1, 2, 3, 99]); + assert_matches!(ret, Err(_)); +*/ + +#[test] +fn test_drop_in_insert() { + use std::cell::Cell; + + let flag = &Cell::new(0); + + struct Bump<'a>(&'a Cell); + + impl<'a> Drop for Bump<'a> { + fn drop(&mut self) { + let n = self.0.get(); + self.0.set(n + 1); + } + } + + flag.set(0); + + { + let mut array = ArrayVec::<[_; 2]>::new(); + array.push(Bump(flag)); + array.insert(0, Bump(flag)); + assert_eq!(flag.get(), 0); + let ret = array.try_insert(1, Bump(flag)); + assert_eq!(flag.get(), 0); + assert_matches!(ret, Err(_)); + drop(ret); + assert_eq!(flag.get(), 1); + } + assert_eq!(flag.get(), 3); +} + +#[test] +fn test_pop_at() { + let mut v = ArrayVec::<[String; 4]>::new(); + let s = String::from; + v.push(s("a")); + v.push(s("b")); + v.push(s("c")); + v.push(s("d")); + + assert_eq!(v.pop_at(4), None); + assert_eq!(v.pop_at(1), Some(s("b"))); + assert_eq!(v.pop_at(1), Some(s("c"))); + assert_eq!(v.pop_at(2), None); + assert_eq!(&v[..], &["a", "d"]); +} + +#[test] +fn test_sizes() { + let v = ArrayVec::from([0u8; 1 << 16]); + assert_eq!(vec![0u8; v.len()], &v[..]); +} + +#[test] +fn test_default() { + use std::net; + let s: ArrayString<[u8; 4]> = Default::default(); + // Something without `Default` implementation. + let v: ArrayVec<[net::TcpStream; 4]> = Default::default(); + assert_eq!(s.len(), 0); + assert_eq!(v.len(), 0); +} + +#[cfg(feature="array-sizes-33-128")] +#[test] +fn test_sizes_33_128() { + ArrayVec::from([0u8; 52]); + ArrayVec::from([0u8; 127]); +} + +#[cfg(feature="array-sizes-129-255")] +#[test] +fn test_sizes_129_255() { + ArrayVec::from([0u8; 237]); + ArrayVec::from([0u8; 255]); +} + +#[test] +fn test_extend_zst() { + let mut range = 0..10; + #[derive(Copy, Clone, PartialEq, Debug)] + struct Z; // Zero sized type + + let mut array: ArrayVec<[_; 5]> = range.by_ref().map(|_| Z).collect(); + assert_eq!(&array[..], &[Z; 5]); + assert_eq!(range.next(), Some(5)); + + array.extend(range.by_ref().map(|_| Z)); + assert_eq!(range.next(), Some(6)); + + let mut array: ArrayVec<[_; 10]> = (0..3).map(|_| Z).collect(); + assert_eq!(&array[..], &[Z; 3]); + array.extend((3..5).map(|_| Z)); + assert_eq!(&array[..], &[Z; 5]); + assert_eq!(array.len(), 5); +} diff --git a/third_party/cargo/vendor/atty-0.2.14/.cargo-checksum.json b/third_party/cargo/vendor/atty-0.2.14/.cargo-checksum.json new file mode 100644 index 0000000..08e4991 --- /dev/null +++ b/third_party/cargo/vendor/atty-0.2.14/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"70db121262d72acc472ad1a90b78c42de570820e65b566c6b9339b62e636d572","Cargo.toml":"3af88a07af6a4adb84373fc3cd4920884b0b12b338cdb55ef598fd512ee1a790","LICENSE":"99fa95ba4e4cdaf71c27d73260ea069fc4515b3d02fde3020c5b562280006cbc","README.md":"e559a69c0b2bd20bffcede64fd548df6c671b0d1504613c5e3e5d884d759caea","examples/atty.rs":"1551387a71474d9ac1b5153231f884e9e05213badcfaa3494ad2cb7ea958374a","rustfmt.toml":"8e6ea1bcb79c505490034020c98e9b472f4ac4113f245bae90f5e1217b1ec65a","src/lib.rs":"d5abf6a54e8c496c486572bdc91eef10480f6ad126c4287f039df5feff7a9bbb"},"package":"d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"} \ No newline at end of file diff --git a/third_party/cargo/vendor/atty-0.2.14/BUILD b/third_party/cargo/vendor/atty-0.2.14/BUILD new file mode 100644 index 0000000..786caa4 --- /dev/null +++ b/third_party/cargo/vendor/atty-0.2.14/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "atty" with type "example" omitted + +rust_library( + name = "atty", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.2.14", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/atty-0.2.14/CHANGELOG.md b/third_party/cargo/vendor/atty-0.2.14/CHANGELOG.md new file mode 100644 index 0000000..4e9673f --- /dev/null +++ b/third_party/cargo/vendor/atty-0.2.14/CHANGELOG.md @@ -0,0 +1,73 @@ +# 0.2.14 + +* add support for [RustyHermit](https://github.com/hermitcore/libhermit-rs), a Rust-based unikernel [#41](https://github.com/softprops/atty/pull/41) + +# 0.2.13 + +* support older versions of rust that do now support 2018 edition + +# 0.2.12 + +* Redox is now in the unix family so redox cfg is no longer needed [#35](https://github.com/softprops/atty/pull/35) + +# 0.2.11 + +* fix msys detection with `winapi@0.3.5` [#28](https://github.com/softprops/atty/pull/28) + +# 0.2.10 + +* fix wasm regression [#27](https://github.com/softprops/atty/pull/27) + +# 0.2.9 + +* Fix fix pty detection [#25](https://github.com/softprops/atty/pull/25) + +# 0.2.8 + +* Fix an inverted condition on MinGW [#22](https://github.com/softprops/atty/pull/22) + +# 0.2.7 + +* Change `||` to `&&` for whether MSYS is a tty [#24](https://github.com/softprops/atty/pull/24/) + +# 0.2.6 + +* updated winapi dependency to [0.3](https://retep998.github.io/blog/winapi-0.3/) [#18](https://github.com/softprops/atty/pull/18) + +# 0.2.5 + +* added support for Wasm compile targets [#17](https://github.com/softprops/atty/pull/17) + +# 0.2.4 + +* added support for Wasm compile targets [#17](https://github.com/softprops/atty/pull/17) + +# 0.2.3 + +* added support for Redox OS [#14](https://github.com/softprops/atty/pull/14) + +# 0.2.2 + +* use target specific dependencies [#11](https://github.com/softprops/atty/pull/11) +* Add tty detection for MSYS terminals [#12](https://github.com/softprops/atty/pull/12) + +# 0.2.1 + +* fix windows bug + +# 0.2.0 + +* support for various stream types + +# 0.1.2 + +* windows support (with automated testing) +* automated code coverage + +# 0.1.1 + +* bumped libc dep from `0.1` to `0.2` + +# 0.1.0 + +* initial release diff --git a/third_party/cargo/vendor/atty-0.2.14/Cargo.toml b/third_party/cargo/vendor/atty-0.2.14/Cargo.toml new file mode 100644 index 0000000..d6bf2d0 --- /dev/null +++ b/third_party/cargo/vendor/atty-0.2.14/Cargo.toml @@ -0,0 +1,34 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "atty" +version = "0.2.14" +authors = ["softprops "] +exclude = ["/.travis.yml", "/appveyor.yml"] +description = "A simple interface for querying atty" +homepage = "https://github.com/softprops/atty" +documentation = "http://softprops.github.io/atty" +readme = "README.md" +keywords = ["terminal", "tty", "isatty"] +license = "MIT" +repository = "https://github.com/softprops/atty" +[target."cfg(target_os = \"hermit\")".dependencies.hermit-abi] +version = "0.1.6" +[target."cfg(unix)".dependencies.libc] +version = "0.2" +default-features = false +[target."cfg(windows)".dependencies.winapi] +version = "0.3" +features = ["consoleapi", "processenv", "minwinbase", "minwindef", "winbase"] +[badges.travis-ci] +repository = "softprops/atty" diff --git a/third_party/cargo/vendor/atty-0.2.14/LICENSE b/third_party/cargo/vendor/atty-0.2.14/LICENSE new file mode 100644 index 0000000..b9da76b --- /dev/null +++ b/third_party/cargo/vendor/atty-0.2.14/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2015-2019 Doug Tangren + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/atty-0.2.14/README.md b/third_party/cargo/vendor/atty-0.2.14/README.md new file mode 100644 index 0000000..cd85593 --- /dev/null +++ b/third_party/cargo/vendor/atty-0.2.14/README.md @@ -0,0 +1,74 @@ +# atty + +[![Build Status](https://travis-ci.org/softprops/atty.svg?branch=master)](https://travis-ci.org/softprops/atty) [![Build status](https://ci.appveyor.com/api/projects/status/geggrsnsjsuse8cv?svg=true)](https://ci.appveyor.com/project/softprops/atty) [![Coverage Status](https://coveralls.io/repos/softprops/atty/badge.svg?branch=master&service=github)](https://coveralls.io/github/softprops/atty?branch=master) [![crates.io](https://img.shields.io/crates/v/atty.svg)](https://crates.io/crates/atty) [![Released API docs](https://docs.rs/atty/badge.svg)](http://docs.rs/atty) [![Master API docs](https://img.shields.io/badge/docs-master-green.svg)](https://softprops.github.io/atty) + +> are you or are you not a tty? + + +## install + +Add the following to your `Cargo.toml` + +```toml +[dependencies] +atty = "0.2" +``` + +## usage + +```rust +use atty::Stream; + +fn main() { + if atty::is(Stream::Stdout) { + println!("I'm a terminal"); + } else { + println!("I'm not"); + } +} +``` + +## testing + +This library has been unit tested on both unix and windows platforms (via appveyor). + + +A simple example program is provided in this repo to test various tty's. By default. + +It prints + +```bash +$ cargo run --example atty +stdout? true +stderr? true +stdin? true +``` + +To test std in, pipe some text to the program + +```bash +$ echo "test" | cargo run --example atty +stdout? true +stderr? true +stdin? false +``` + +To test std out, pipe the program to something + +```bash +$ cargo run --example atty | grep std +stdout? false +stderr? true +stdin? true +``` + +To test std err, pipe the program to something redirecting std err + +```bash +$ cargo run --example atty 2>&1 | grep std +stdout? false +stderr? false +stdin? true +``` + +Doug Tangren (softprops) 2015-2019 diff --git a/third_party/cargo/vendor/atty-0.2.14/examples/atty.rs b/third_party/cargo/vendor/atty-0.2.14/examples/atty.rs new file mode 100644 index 0000000..3b3635e --- /dev/null +++ b/third_party/cargo/vendor/atty-0.2.14/examples/atty.rs @@ -0,0 +1,9 @@ +extern crate atty; + +use atty::{is, Stream}; + +fn main() { + println!("stdout? {}", is(Stream::Stdout)); + println!("stderr? {}", is(Stream::Stderr)); + println!("stdin? {}", is(Stream::Stdin)); +} diff --git a/third_party/cargo/vendor/atty-0.2.14/rustfmt.toml b/third_party/cargo/vendor/atty-0.2.14/rustfmt.toml new file mode 100644 index 0000000..899a094 --- /dev/null +++ b/third_party/cargo/vendor/atty-0.2.14/rustfmt.toml @@ -0,0 +1,4 @@ +# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#fn_args_layout +fn_args_layout = "Vertical" +# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#merge_imports +merge_imports = true \ No newline at end of file diff --git a/third_party/cargo/vendor/atty-0.2.14/src/lib.rs b/third_party/cargo/vendor/atty-0.2.14/src/lib.rs new file mode 100644 index 0000000..501cad6 --- /dev/null +++ b/third_party/cargo/vendor/atty-0.2.14/src/lib.rs @@ -0,0 +1,210 @@ +//! atty is a simple utility that answers one question +//! > is this a tty? +//! +//! usage is just as simple +//! +//! ``` +//! if atty::is(atty::Stream::Stdout) { +//! println!("i'm a tty") +//! } +//! ``` +//! +//! ``` +//! if atty::isnt(atty::Stream::Stdout) { +//! println!("i'm not a tty") +//! } +//! ``` + +#![cfg_attr(unix, no_std)] + +#[cfg(unix)] +extern crate libc; +#[cfg(windows)] +extern crate winapi; + +#[cfg(windows)] +use winapi::shared::minwindef::DWORD; +#[cfg(windows)] +use winapi::shared::ntdef::WCHAR; + +/// possible stream sources +#[derive(Clone, Copy, Debug)] +pub enum Stream { + Stdout, + Stderr, + Stdin, +} + +/// returns true if this is a tty +#[cfg(all(unix, not(target_arch = "wasm32")))] +pub fn is(stream: Stream) -> bool { + extern crate libc; + + let fd = match stream { + Stream::Stdout => libc::STDOUT_FILENO, + Stream::Stderr => libc::STDERR_FILENO, + Stream::Stdin => libc::STDIN_FILENO, + }; + unsafe { libc::isatty(fd) != 0 } +} + +/// returns true if this is a tty +#[cfg(target_os = "hermit")] +pub fn is(stream: Stream) -> bool { + extern crate hermit_abi; + + let fd = match stream { + Stream::Stdout => hermit_abi::STDOUT_FILENO, + Stream::Stderr => hermit_abi::STDERR_FILENO, + Stream::Stdin => hermit_abi::STDIN_FILENO, + }; + hermit_abi::isatty(fd) +} + +/// returns true if this is a tty +#[cfg(windows)] +pub fn is(stream: Stream) -> bool { + use winapi::um::winbase::{ + STD_ERROR_HANDLE as STD_ERROR, STD_INPUT_HANDLE as STD_INPUT, + STD_OUTPUT_HANDLE as STD_OUTPUT, + }; + + let (fd, others) = match stream { + Stream::Stdin => (STD_INPUT, [STD_ERROR, STD_OUTPUT]), + Stream::Stderr => (STD_ERROR, [STD_INPUT, STD_OUTPUT]), + Stream::Stdout => (STD_OUTPUT, [STD_INPUT, STD_ERROR]), + }; + if unsafe { console_on_any(&[fd]) } { + // False positives aren't possible. If we got a console then + // we definitely have a tty on stdin. + return true; + } + + // At this point, we *could* have a false negative. We can determine that + // this is true negative if we can detect the presence of a console on + // any of the other streams. If another stream has a console, then we know + // we're in a Windows console and can therefore trust the negative. + if unsafe { console_on_any(&others) } { + return false; + } + + // Otherwise, we fall back to a very strange msys hack to see if we can + // sneakily detect the presence of a tty. + unsafe { msys_tty_on(fd) } +} + +/// returns true if this is _not_ a tty +pub fn isnt(stream: Stream) -> bool { + !is(stream) +} + +/// Returns true if any of the given fds are on a console. +#[cfg(windows)] +unsafe fn console_on_any(fds: &[DWORD]) -> bool { + use winapi::um::{consoleapi::GetConsoleMode, processenv::GetStdHandle}; + + for &fd in fds { + let mut out = 0; + let handle = GetStdHandle(fd); + if GetConsoleMode(handle, &mut out) != 0 { + return true; + } + } + false +} + +/// Returns true if there is an MSYS tty on the given handle. +#[cfg(windows)] +unsafe fn msys_tty_on(fd: DWORD) -> bool { + use std::{mem, slice}; + + use winapi::{ + ctypes::c_void, + shared::minwindef::MAX_PATH, + um::{ + fileapi::FILE_NAME_INFO, minwinbase::FileNameInfo, processenv::GetStdHandle, + winbase::GetFileInformationByHandleEx, + }, + }; + + let size = mem::size_of::(); + let mut name_info_bytes = vec![0u8; size + MAX_PATH * mem::size_of::()]; + let res = GetFileInformationByHandleEx( + GetStdHandle(fd), + FileNameInfo, + &mut *name_info_bytes as *mut _ as *mut c_void, + name_info_bytes.len() as u32, + ); + if res == 0 { + return false; + } + let name_info: &FILE_NAME_INFO = &*(name_info_bytes.as_ptr() as *const FILE_NAME_INFO); + let s = slice::from_raw_parts( + name_info.FileName.as_ptr(), + name_info.FileNameLength as usize / 2, + ); + let name = String::from_utf16_lossy(s); + // This checks whether 'pty' exists in the file name, which indicates that + // a pseudo-terminal is attached. To mitigate against false positives + // (e.g., an actual file name that contains 'pty'), we also require that + // either the strings 'msys-' or 'cygwin-' are in the file name as well.) + let is_msys = name.contains("msys-") || name.contains("cygwin-"); + let is_pty = name.contains("-pty"); + is_msys && is_pty +} + +/// returns true if this is a tty +#[cfg(target_arch = "wasm32")] +pub fn is(_stream: Stream) -> bool { + false +} + +#[cfg(test)] +mod tests { + use super::{is, Stream}; + + #[test] + #[cfg(windows)] + fn is_err() { + // appveyor pipes its output + assert!(!is(Stream::Stderr)) + } + + #[test] + #[cfg(windows)] + fn is_out() { + // appveyor pipes its output + assert!(!is(Stream::Stdout)) + } + + #[test] + #[cfg(windows)] + fn is_in() { + assert!(is(Stream::Stdin)) + } + + #[test] + #[cfg(unix)] + fn is_err() { + assert!(is(Stream::Stderr)) + } + + #[test] + #[cfg(unix)] + fn is_out() { + assert!(is(Stream::Stdout)) + } + + #[test] + #[cfg(target_os = "macos")] + fn is_in() { + // macos on travis seems to pipe its input + assert!(is(Stream::Stdin)) + } + + #[test] + #[cfg(all(not(target_os = "macos"), unix))] + fn is_in() { + assert!(is(Stream::Stdin)) + } +} diff --git a/third_party/cargo/vendor/autocfg-0.1.7/.cargo-checksum.json b/third_party/cargo/vendor/autocfg-0.1.7/.cargo-checksum.json new file mode 100644 index 0000000..824ef78 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"4072e465bb2d1110644171c28d1a48a8cf5e9bb85c75d39409bb719348a131f6","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"0ff4942223d94c9686f846bb0b1de12221f06e7f39c1818ecbaaec402e89e770","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"12de7dafea4a35d1dc2f0fa79bfa038386bbbea72bf083979f4ddf227999eeda","src/lib.rs":"374704e933dc6263a334652144e4436a7e409f88069c2f4f8e8c4ef14f7aa76b","src/tests.rs":"0b1353344e832553d328c47f1639ced877b5dff70fd2024d84130bd1c33eee07","src/version.rs":"175727d5f02f2fe2271ddc9b041db2a5b9c6fe0f95afd17c73a4d982612764a3","tests/rustflags.rs":"a3788396e0b81a33406d06fef3bc31c5a328f323de6766570a345ebad885cbf9"},"package":"1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"} \ No newline at end of file diff --git a/third_party/cargo/vendor/autocfg-0.1.7/BUILD b/third_party/cargo/vendor/autocfg-0.1.7/BUILD new file mode 100644 index 0000000..634f9bc --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0,MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "autocfg", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.7", + crate_features = [ + ], +) + +# Unsupported target "integers" with type "example" omitted +# Unsupported target "paths" with type "example" omitted +# Unsupported target "rustflags" with type "test" omitted +# Unsupported target "traits" with type "example" omitted +# Unsupported target "versions" with type "example" omitted diff --git a/third_party/cargo/vendor/autocfg-0.1.7/Cargo.toml b/third_party/cargo/vendor/autocfg-0.1.7/Cargo.toml new file mode 100644 index 0000000..c077b3e --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/Cargo.toml @@ -0,0 +1,24 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "autocfg" +version = "0.1.7" +authors = ["Josh Stone "] +description = "Automatic cfg for Rust compiler features" +readme = "README.md" +keywords = ["rustc", "build", "autoconf"] +categories = ["development-tools::build-utils"] +license = "Apache-2.0/MIT" +repository = "https://github.com/cuviper/autocfg" + +[dependencies] diff --git a/third_party/cargo/vendor/autocfg-0.1.7/LICENSE-APACHE b/third_party/cargo/vendor/autocfg-0.1.7/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/autocfg-0.1.7/LICENSE-MIT b/third_party/cargo/vendor/autocfg-0.1.7/LICENSE-MIT new file mode 100644 index 0000000..44fbc4d --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2018 Josh Stone + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/autocfg-0.1.7/README.md b/third_party/cargo/vendor/autocfg-0.1.7/README.md new file mode 100644 index 0000000..680f11e --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/README.md @@ -0,0 +1,84 @@ +autocfg +======= + +[![autocfg crate](https://img.shields.io/crates/v/autocfg.svg)](https://crates.io/crates/autocfg) +[![autocfg documentation](https://docs.rs/autocfg/badge.svg)](https://docs.rs/autocfg) +![minimum rustc 1.0](https://img.shields.io/badge/rustc-1.0+-red.svg) +[![Travis Status](https://travis-ci.org/cuviper/autocfg.svg?branch=master)](https://travis-ci.org/cuviper/autocfg) + +A Rust library for build scripts to automatically configure code based on +compiler support. Code snippets are dynamically tested to see if the `rustc` +will accept them, rather than hard-coding specific version support. + + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[build-dependencies] +autocfg = "0.1" +``` + +Then use it in your `build.rs` script to detect compiler features. For +example, to test for 128-bit integer support, it might look like: + +```rust +extern crate autocfg; + +fn main() { + let ac = autocfg::new(); + ac.emit_has_type("i128"); + + // (optional) We don't need to rerun for anything external. + autocfg::rerun_path(file!()); +} +``` + +If the type test succeeds, this will write a `cargo:rustc-cfg=has_i128` line +for Cargo, which translates to Rust arguments `--cfg has_i128`. Then in the +rest of your Rust code, you can add `#[cfg(has_i128)]` conditions on code that +should only be used when the compiler supports it. + + +## Release Notes + +- 0.1.7 (2019-10-20) + - Apply `RUSTFLAGS` when probing `$TARGET != $HOST`, mainly for sysroot, by @roblabla. + +- 0.1.6 (2019-08-19) + - Add `probe`/`emit_sysroot_crate`, by @leo60228. + +- 0.1.5 (2019-07-16) + - Mask some warnings from newer rustc. + +- 0.1.4 (2019-05-22) + - Relax `std`/`no_std` probing to a warning instead of an error. + - Improve `rustc` bootstrap compatibility. + +- 0.1.3 (2019-05-21) + - Auto-detects if `#![no_std]` is needed for the `$TARGET`. + +- 0.1.2 (2019-01-16) + - Add `rerun_env(ENV)` to print `cargo:rerun-if-env-changed=ENV`. + - Add `rerun_path(PATH)` to print `cargo:rerun-if-changed=PATH`. + + +## Minimum Rust version policy + +This crate's minimum supported `rustc` version is `1.0.0`. Compatibility is +its entire reason for existence, so this crate will be extremely conservative +about raising this requirement. If this is ever deemed necessary, it will be +treated as a major breaking change for semver purposes. + + +## License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. diff --git a/third_party/cargo/vendor/autocfg-0.1.7/examples/integers.rs b/third_party/cargo/vendor/autocfg-0.1.7/examples/integers.rs new file mode 100644 index 0000000..23d4cba --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/examples/integers.rs @@ -0,0 +1,9 @@ +extern crate autocfg; + +fn main() { + // Normally, cargo will set `OUT_DIR` for build scripts. + let ac = autocfg::AutoCfg::with_dir("target").unwrap(); + for i in 3..8 { + ac.emit_has_type(&format!("i{}", 1 << i)); + } +} diff --git a/third_party/cargo/vendor/autocfg-0.1.7/examples/paths.rs b/third_party/cargo/vendor/autocfg-0.1.7/examples/paths.rs new file mode 100644 index 0000000..b7a6ca7 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/examples/paths.rs @@ -0,0 +1,22 @@ +extern crate autocfg; + +fn main() { + // Normally, cargo will set `OUT_DIR` for build scripts. + let ac = autocfg::AutoCfg::with_dir("target").unwrap(); + + // since ancient times... + ac.emit_has_path("std::vec::Vec"); + ac.emit_path_cfg("std::vec::Vec", "has_vec"); + + // rustc 1.10.0 + ac.emit_has_path("std::panic::PanicInfo"); + ac.emit_path_cfg("std::panic::PanicInfo", "has_panic_info"); + + // rustc 1.20.0 + ac.emit_has_path("std::mem::ManuallyDrop"); + ac.emit_path_cfg("std::mem::ManuallyDrop", "has_manually_drop"); + + // rustc 1.25.0 + ac.emit_has_path("std::ptr::NonNull"); + ac.emit_path_cfg("std::ptr::NonNull", "has_non_null"); +} diff --git a/third_party/cargo/vendor/autocfg-0.1.7/examples/traits.rs b/third_party/cargo/vendor/autocfg-0.1.7/examples/traits.rs new file mode 100644 index 0000000..c1ca003 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/examples/traits.rs @@ -0,0 +1,26 @@ +extern crate autocfg; + +fn main() { + // Normally, cargo will set `OUT_DIR` for build scripts. + let ac = autocfg::AutoCfg::with_dir("target").unwrap(); + + // since ancient times... + ac.emit_has_trait("std::ops::Add"); + ac.emit_trait_cfg("std::ops::Add", "has_ops"); + + // trait parameters have to be provided + ac.emit_has_trait("std::borrow::Borrow"); + ac.emit_trait_cfg("std::borrow::Borrow", "has_borrow"); + + // rustc 1.8.0 + ac.emit_has_trait("std::ops::AddAssign"); + ac.emit_trait_cfg("std::ops::AddAssign", "has_assign_ops"); + + // rustc 1.12.0 + ac.emit_has_trait("std::iter::Sum"); + ac.emit_trait_cfg("std::iter::Sum", "has_sum"); + + // rustc 1.28.0 + ac.emit_has_trait("std::alloc::GlobalAlloc"); + ac.emit_trait_cfg("std::alloc::GlobalAlloc", "has_global_alloc"); +} diff --git a/third_party/cargo/vendor/autocfg-0.1.7/examples/versions.rs b/third_party/cargo/vendor/autocfg-0.1.7/examples/versions.rs new file mode 100644 index 0000000..992919b --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/examples/versions.rs @@ -0,0 +1,9 @@ +extern crate autocfg; + +fn main() { + // Normally, cargo will set `OUT_DIR` for build scripts. + let ac = autocfg::AutoCfg::with_dir("target").unwrap(); + for i in 0..100 { + ac.emit_rustc_version(1, i); + } +} diff --git a/third_party/cargo/vendor/autocfg-0.1.7/src/error.rs b/third_party/cargo/vendor/autocfg-0.1.7/src/error.rs new file mode 100644 index 0000000..4624835 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/src/error.rs @@ -0,0 +1,69 @@ +use std::error; +use std::fmt; +use std::io; +use std::num; +use std::str; + +/// A common error type for the `autocfg` crate. +#[derive(Debug)] +pub struct Error { + kind: ErrorKind, +} + +impl error::Error for Error { + fn description(&self) -> &str { + "AutoCfg error" + } + + fn cause(&self) -> Option<&error::Error> { + match self.kind { + ErrorKind::Io(ref e) => Some(e), + ErrorKind::Num(ref e) => Some(e), + ErrorKind::Utf8(ref e) => Some(e), + ErrorKind::Other(_) => None, + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + match self.kind { + ErrorKind::Io(ref e) => e.fmt(f), + ErrorKind::Num(ref e) => e.fmt(f), + ErrorKind::Utf8(ref e) => e.fmt(f), + ErrorKind::Other(s) => s.fmt(f), + } + } +} + +#[derive(Debug)] +enum ErrorKind { + Io(io::Error), + Num(num::ParseIntError), + Utf8(str::Utf8Error), + Other(&'static str), +} + +pub fn from_io(e: io::Error) -> Error { + Error { + kind: ErrorKind::Io(e), + } +} + +pub fn from_num(e: num::ParseIntError) -> Error { + Error { + kind: ErrorKind::Num(e), + } +} + +pub fn from_utf8(e: str::Utf8Error) -> Error { + Error { + kind: ErrorKind::Utf8(e), + } +} + +pub fn from_str(s: &'static str) -> Error { + Error { + kind: ErrorKind::Other(s), + } +} diff --git a/third_party/cargo/vendor/autocfg-0.1.7/src/lib.rs b/third_party/cargo/vendor/autocfg-0.1.7/src/lib.rs new file mode 100644 index 0000000..d563700 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/src/lib.rs @@ -0,0 +1,366 @@ +//! A Rust library for build scripts to automatically configure code based on +//! compiler support. Code snippets are dynamically tested to see if the `rustc` +//! will accept them, rather than hard-coding specific version support. +//! +//! +//! ## Usage +//! +//! Add this to your `Cargo.toml`: +//! +//! ```toml +//! [build-dependencies] +//! autocfg = "0.1" +//! ``` +//! +//! Then use it in your `build.rs` script to detect compiler features. For +//! example, to test for 128-bit integer support, it might look like: +//! +//! ```rust +//! extern crate autocfg; +//! +//! fn main() { +//! # // Normally, cargo will set `OUT_DIR` for build scripts. +//! # std::env::set_var("OUT_DIR", "target"); +//! let ac = autocfg::new(); +//! ac.emit_has_type("i128"); +//! +//! // (optional) We don't need to rerun for anything external. +//! autocfg::rerun_path(file!()); +//! } +//! ``` +//! +//! If the type test succeeds, this will write a `cargo:rustc-cfg=has_i128` line +//! for Cargo, which translates to Rust arguments `--cfg has_i128`. Then in the +//! rest of your Rust code, you can add `#[cfg(has_i128)]` conditions on code that +//! should only be used when the compiler supports it. + +#![deny(missing_debug_implementations)] +#![deny(missing_docs)] +// allow future warnings that can't be fixed while keeping 1.0 compatibility +#![allow(unknown_lints)] +#![allow(bare_trait_objects)] +#![allow(ellipsis_inclusive_range_patterns)] + +/// Local macro to avoid `std::try!`, deprecated in Rust 1.39. +macro_rules! try { + ($result:expr) => { + match $result { + Ok(value) => value, + Err(error) => return Err(error), + } + }; +} + +use std::env; +use std::ffi::OsString; +use std::fs; +use std::io::{stderr, Write}; +use std::path::PathBuf; +use std::process::{Command, Stdio}; +#[allow(deprecated)] +use std::sync::atomic::ATOMIC_USIZE_INIT; +use std::sync::atomic::{AtomicUsize, Ordering}; + +mod error; +pub use error::Error; + +mod version; +use version::Version; + +#[cfg(test)] +mod tests; + +/// Helper to detect compiler features for `cfg` output in build scripts. +#[derive(Clone, Debug)] +pub struct AutoCfg { + out_dir: PathBuf, + rustc: PathBuf, + rustc_version: Version, + target: Option, + no_std: bool, + rustflags: Option>, +} + +/// Writes a config flag for rustc on standard out. +/// +/// This looks like: `cargo:rustc-cfg=CFG` +/// +/// Cargo will use this in arguments to rustc, like `--cfg CFG`. +pub fn emit(cfg: &str) { + println!("cargo:rustc-cfg={}", cfg); +} + +/// Writes a line telling Cargo to rerun the build script if `path` changes. +/// +/// This looks like: `cargo:rerun-if-changed=PATH` +/// +/// This requires at least cargo 0.7.0, corresponding to rustc 1.6.0. Earlier +/// versions of cargo will simply ignore the directive. +pub fn rerun_path(path: &str) { + println!("cargo:rerun-if-changed={}", path); +} + +/// Writes a line telling Cargo to rerun the build script if the environment +/// variable `var` changes. +/// +/// This looks like: `cargo:rerun-if-env-changed=VAR` +/// +/// This requires at least cargo 0.21.0, corresponding to rustc 1.20.0. Earlier +/// versions of cargo will simply ignore the directive. +pub fn rerun_env(var: &str) { + println!("cargo:rerun-if-env-changed={}", var); +} + +/// Create a new `AutoCfg` instance. +/// +/// # Panics +/// +/// Panics if `AutoCfg::new()` returns an error. +pub fn new() -> AutoCfg { + AutoCfg::new().unwrap() +} + +impl AutoCfg { + /// Create a new `AutoCfg` instance. + /// + /// # Common errors + /// + /// - `rustc` can't be executed, from `RUSTC` or in the `PATH`. + /// - The version output from `rustc` can't be parsed. + /// - `OUT_DIR` is not set in the environment, or is not a writable directory. + /// + pub fn new() -> Result { + match env::var_os("OUT_DIR") { + Some(d) => Self::with_dir(d), + None => Err(error::from_str("no OUT_DIR specified!")), + } + } + + /// Create a new `AutoCfg` instance with the specified output directory. + /// + /// # Common errors + /// + /// - `rustc` can't be executed, from `RUSTC` or in the `PATH`. + /// - The version output from `rustc` can't be parsed. + /// - `dir` is not a writable directory. + /// + pub fn with_dir>(dir: T) -> Result { + let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into()); + let rustc: PathBuf = rustc.into(); + let rustc_version = try!(Version::from_rustc(&rustc)); + + // Sanity check the output directory + let dir = dir.into(); + let meta = try!(fs::metadata(&dir).map_err(error::from_io)); + if !meta.is_dir() || meta.permissions().readonly() { + return Err(error::from_str("output path is not a writable directory")); + } + + // Cargo only applies RUSTFLAGS for building TARGET artifact in + // cross-compilation environment. Sadly, we don't have a way to detect + // when we're building HOST artifact in a cross-compilation environment, + // so for now we only apply RUSTFLAGS when cross-compiling an artifact. + // + // See https://github.com/cuviper/autocfg/pull/10#issuecomment-527575030. + let rustflags = if env::var_os("TARGET") != env::var_os("HOST") { + env::var("RUSTFLAGS").ok().map(|rustflags| { + // This is meant to match how cargo handles the RUSTFLAG environment + // variable. + // See https://github.com/rust-lang/cargo/blob/69aea5b6f69add7c51cca939a79644080c0b0ba0/src/cargo/core/compiler/build_context/target_info.rs#L434-L441 + rustflags + .split(' ') + .map(str::trim) + .filter(|s| !s.is_empty()) + .map(str::to_string) + .collect::>() + }) + } else { + None + }; + + let mut ac = AutoCfg { + out_dir: dir, + rustc: rustc, + rustc_version: rustc_version, + target: env::var_os("TARGET"), + no_std: false, + rustflags: rustflags, + }; + + // Sanity check with and without `std`. + if !ac.probe("").unwrap_or(false) { + ac.no_std = true; + if !ac.probe("").unwrap_or(false) { + // Neither worked, so assume nothing... + ac.no_std = false; + let warning = b"warning: autocfg could not probe for `std`\n"; + stderr().write_all(warning).ok(); + } + } + Ok(ac) + } + + /// Test whether the current `rustc` reports a version greater than + /// or equal to "`major`.`minor`". + pub fn probe_rustc_version(&self, major: usize, minor: usize) -> bool { + self.rustc_version >= Version::new(major, minor, 0) + } + + /// Sets a `cfg` value of the form `rustc_major_minor`, like `rustc_1_29`, + /// if the current `rustc` is at least that version. + pub fn emit_rustc_version(&self, major: usize, minor: usize) { + if self.probe_rustc_version(major, minor) { + emit(&format!("rustc_{}_{}", major, minor)); + } + } + + fn probe>(&self, code: T) -> Result { + #[allow(deprecated)] + static ID: AtomicUsize = ATOMIC_USIZE_INIT; + + let id = ID.fetch_add(1, Ordering::Relaxed); + let mut command = Command::new(&self.rustc); + command + .arg("--crate-name") + .arg(format!("probe{}", id)) + .arg("--crate-type=lib") + .arg("--out-dir") + .arg(&self.out_dir) + .arg("--emit=llvm-ir"); + + if let &Some(ref rustflags) = &self.rustflags { + command.args(rustflags); + } + + if let Some(target) = self.target.as_ref() { + command.arg("--target").arg(target); + } + + command.arg("-").stdin(Stdio::piped()); + let mut child = try!(command.spawn().map_err(error::from_io)); + let mut stdin = child.stdin.take().expect("rustc stdin"); + + if self.no_std { + try!(stdin.write_all(b"#![no_std]\n").map_err(error::from_io)); + } + try!(stdin.write_all(code.as_ref()).map_err(error::from_io)); + drop(stdin); + + let status = try!(child.wait().map_err(error::from_io)); + Ok(status.success()) + } + + /// Tests whether the given sysroot crate can be used. + /// + /// The test code is subject to change, but currently looks like: + /// + /// ```ignore + /// extern crate CRATE as probe; + /// ``` + pub fn probe_sysroot_crate(&self, name: &str) -> bool { + self.probe(format!("extern crate {} as probe;", name)) // `as _` wasn't stabilized until Rust 1.33 + .unwrap_or(false) + } + + /// Emits a config value `has_CRATE` if `probe_sysroot_crate` returns true. + pub fn emit_sysroot_crate(&self, name: &str) { + if self.probe_sysroot_crate(name) { + emit(&format!("has_{}", mangle(name))); + } + } + + /// Tests whether the given path can be used. + /// + /// The test code is subject to change, but currently looks like: + /// + /// ```ignore + /// pub use PATH; + /// ``` + pub fn probe_path(&self, path: &str) -> bool { + self.probe(format!("pub use {};", path)).unwrap_or(false) + } + + /// Emits a config value `has_PATH` if `probe_path` returns true. + /// + /// Any non-identifier characters in the `path` will be replaced with + /// `_` in the generated config value. + pub fn emit_has_path(&self, path: &str) { + if self.probe_path(path) { + emit(&format!("has_{}", mangle(path))); + } + } + + /// Emits the given `cfg` value if `probe_path` returns true. + pub fn emit_path_cfg(&self, path: &str, cfg: &str) { + if self.probe_path(path) { + emit(cfg); + } + } + + /// Tests whether the given trait can be used. + /// + /// The test code is subject to change, but currently looks like: + /// + /// ```ignore + /// pub trait Probe: TRAIT + Sized {} + /// ``` + pub fn probe_trait(&self, name: &str) -> bool { + self.probe(format!("pub trait Probe: {} + Sized {{}}", name)) + .unwrap_or(false) + } + + /// Emits a config value `has_TRAIT` if `probe_trait` returns true. + /// + /// Any non-identifier characters in the trait `name` will be replaced with + /// `_` in the generated config value. + pub fn emit_has_trait(&self, name: &str) { + if self.probe_trait(name) { + emit(&format!("has_{}", mangle(name))); + } + } + + /// Emits the given `cfg` value if `probe_trait` returns true. + pub fn emit_trait_cfg(&self, name: &str, cfg: &str) { + if self.probe_trait(name) { + emit(cfg); + } + } + + /// Tests whether the given type can be used. + /// + /// The test code is subject to change, but currently looks like: + /// + /// ```ignore + /// pub type Probe = TYPE; + /// ``` + pub fn probe_type(&self, name: &str) -> bool { + self.probe(format!("pub type Probe = {};", name)) + .unwrap_or(false) + } + + /// Emits a config value `has_TYPE` if `probe_type` returns true. + /// + /// Any non-identifier characters in the type `name` will be replaced with + /// `_` in the generated config value. + pub fn emit_has_type(&self, name: &str) { + if self.probe_type(name) { + emit(&format!("has_{}", mangle(name))); + } + } + + /// Emits the given `cfg` value if `probe_type` returns true. + pub fn emit_type_cfg(&self, name: &str, cfg: &str) { + if self.probe_type(name) { + emit(cfg); + } + } +} + +fn mangle(s: &str) -> String { + s.chars() + .map(|c| match c { + 'A'...'Z' | 'a'...'z' | '0'...'9' => c, + _ => '_', + }) + .collect() +} diff --git a/third_party/cargo/vendor/autocfg-0.1.7/src/tests.rs b/third_party/cargo/vendor/autocfg-0.1.7/src/tests.rs new file mode 100644 index 0000000..304d989 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/src/tests.rs @@ -0,0 +1,99 @@ +use super::AutoCfg; + +impl AutoCfg { + fn core_std(&self, path: &str) -> String { + let krate = if self.no_std { "core" } else { "std" }; + format!("{}::{}", krate, path) + } +} + +#[test] +fn autocfg_version() { + let ac = AutoCfg::with_dir("target").unwrap(); + println!("version: {:?}", ac.rustc_version); + assert!(ac.probe_rustc_version(1, 0)); +} + +#[test] +fn version_cmp() { + use super::version::Version; + let v123 = Version::new(1, 2, 3); + + assert!(Version::new(1, 0, 0) < v123); + assert!(Version::new(1, 2, 2) < v123); + assert!(Version::new(1, 2, 3) == v123); + assert!(Version::new(1, 2, 4) > v123); + assert!(Version::new(1, 10, 0) > v123); + assert!(Version::new(2, 0, 0) > v123); +} + +#[test] +fn probe_add() { + let ac = AutoCfg::with_dir("target").unwrap(); + let add = ac.core_std("ops::Add"); + let add_rhs = ac.core_std("ops::Add"); + let add_rhs_output = ac.core_std("ops::Add"); + assert!(ac.probe_path(&add)); + assert!(ac.probe_trait(&add)); + assert!(ac.probe_trait(&add_rhs)); + assert!(ac.probe_trait(&add_rhs_output)); + assert!(ac.probe_type(&add_rhs_output)); +} + +#[test] +fn probe_as_ref() { + let ac = AutoCfg::with_dir("target").unwrap(); + let as_ref = ac.core_std("convert::AsRef"); + let as_ref_str = ac.core_std("convert::AsRef"); + assert!(ac.probe_path(&as_ref)); + assert!(ac.probe_trait(&as_ref_str)); + assert!(ac.probe_type(&as_ref_str)); +} + +#[test] +fn probe_i128() { + let ac = AutoCfg::with_dir("target").unwrap(); + let missing = !ac.probe_rustc_version(1, 26); + let i128_path = ac.core_std("i128"); + assert!(missing ^ ac.probe_path(&i128_path)); + assert!(missing ^ ac.probe_type("i128")); +} + +#[test] +fn probe_sum() { + let ac = AutoCfg::with_dir("target").unwrap(); + let missing = !ac.probe_rustc_version(1, 12); + let sum = ac.core_std("iter::Sum"); + let sum_i32 = ac.core_std("iter::Sum"); + assert!(missing ^ ac.probe_path(&sum)); + assert!(missing ^ ac.probe_trait(&sum)); + assert!(missing ^ ac.probe_trait(&sum_i32)); + assert!(missing ^ ac.probe_type(&sum_i32)); +} + +#[test] +fn probe_std() { + let ac = AutoCfg::with_dir("target").unwrap(); + assert_eq!(ac.probe_sysroot_crate("std"), !ac.no_std); +} + +#[test] +fn probe_alloc() { + let ac = AutoCfg::with_dir("target").unwrap(); + let missing = !ac.probe_rustc_version(1, 36); + assert!(missing ^ ac.probe_sysroot_crate("alloc")); +} + +#[test] +fn probe_bad_sysroot_crate() { + let ac = AutoCfg::with_dir("target").unwrap(); + assert!(!ac.probe_sysroot_crate("doesnt_exist")); +} + +#[test] +fn probe_no_std() { + let ac = AutoCfg::with_dir("target").unwrap(); + assert!(ac.probe_type("i32")); + assert!(ac.probe_type("[i32]")); + assert_eq!(ac.probe_type("Vec"), !ac.no_std); +} diff --git a/third_party/cargo/vendor/autocfg-0.1.7/src/version.rs b/third_party/cargo/vendor/autocfg-0.1.7/src/version.rs new file mode 100644 index 0000000..378c21e --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/src/version.rs @@ -0,0 +1,60 @@ +use std::path::Path; +use std::process::Command; +use std::str; + +use super::{error, Error}; + +/// A version structure for making relative comparisons. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct Version { + major: usize, + minor: usize, + patch: usize, +} + +impl Version { + /// Creates a `Version` instance for a specific `major.minor.patch` version. + pub fn new(major: usize, minor: usize, patch: usize) -> Self { + Version { + major: major, + minor: minor, + patch: patch, + } + } + + pub fn from_rustc(rustc: &Path) -> Result { + // Get rustc's verbose version + let output = try!(Command::new(rustc) + .args(&["--version", "--verbose"]) + .output() + .map_err(error::from_io)); + if !output.status.success() { + return Err(error::from_str("could not execute rustc")); + } + let output = try!(str::from_utf8(&output.stdout).map_err(error::from_utf8)); + + // Find the release line in the verbose version output. + let release = match output.lines().find(|line| line.starts_with("release: ")) { + Some(line) => &line["release: ".len()..], + None => return Err(error::from_str("could not find rustc release")), + }; + + // Strip off any extra channel info, e.g. "-beta.N", "-nightly" + let version = match release.find('-') { + Some(i) => &release[..i], + None => release, + }; + + // Split the version into semver components. + let mut iter = version.splitn(3, '.'); + let major = try!(iter.next().ok_or(error::from_str("missing major version"))); + let minor = try!(iter.next().ok_or(error::from_str("missing minor version"))); + let patch = try!(iter.next().ok_or(error::from_str("missing patch version"))); + + Ok(Version::new( + try!(major.parse().map_err(error::from_num)), + try!(minor.parse().map_err(error::from_num)), + try!(patch.parse().map_err(error::from_num)), + )) + } +} diff --git a/third_party/cargo/vendor/autocfg-0.1.7/tests/rustflags.rs b/third_party/cargo/vendor/autocfg-0.1.7/tests/rustflags.rs new file mode 100644 index 0000000..bfa0f03 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-0.1.7/tests/rustflags.rs @@ -0,0 +1,13 @@ +extern crate autocfg; + +/// Tests that autocfg uses the RUSTFLAGS environment variable when running +/// rustc. +#[test] +fn test_with_sysroot() { + std::env::set_var("RUSTFLAGS", "-L target/debug/deps -L target/debug"); + std::env::set_var("OUT_DIR", "target"); + // Ensure HOST != TARGET. + std::env::set_var("HOST", "lol"); + let ac = autocfg::AutoCfg::new().unwrap(); + assert!(ac.probe_sysroot_crate("autocfg")); +} diff --git a/third_party/cargo/vendor/autocfg-1.0.0/.cargo-checksum.json b/third_party/cargo/vendor/autocfg-1.0.0/.cargo-checksum.json new file mode 100644 index 0000000..89b89d6 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"9a97fd6cdf41c7b507d2d8954f99dbbae3450e9e67934c87e5cabe8fa795f6c5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"f173253f205c245806e5dd16ad1906e1a1b3f89694890236298b2126e937324a","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"12de7dafea4a35d1dc2f0fa79bfa038386bbbea72bf083979f4ddf227999eeda","src/lib.rs":"4e80b48869f038be4e80e3356e4cce7e81713717ceeca095f9bb04cda2e4d224","src/tests.rs":"8197b5a6e91872d6c63731ed4b7b619068b6d13501d9aecb3652f20857edc9aa","src/version.rs":"175727d5f02f2fe2271ddc9b041db2a5b9c6fe0f95afd17c73a4d982612764a3","tests/rustflags.rs":"441fb0c6606e243c31d3817a5ae2240b65fcae0ea8ab583f80f8f6d6c267e614"},"package":"f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"} \ No newline at end of file diff --git a/third_party/cargo/vendor/autocfg-1.0.0/BUILD b/third_party/cargo/vendor/autocfg-1.0.0/BUILD new file mode 100644 index 0000000..20ed3a9 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "Apache-2.0 OR MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "autocfg", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.0.0", + crate_features = [ + ], +) + +# Unsupported target "integers" with type "example" omitted +# Unsupported target "paths" with type "example" omitted +# Unsupported target "rustflags" with type "test" omitted +# Unsupported target "traits" with type "example" omitted +# Unsupported target "versions" with type "example" omitted diff --git a/third_party/cargo/vendor/autocfg-1.0.0/Cargo.toml b/third_party/cargo/vendor/autocfg-1.0.0/Cargo.toml new file mode 100644 index 0000000..7ba9df6 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/Cargo.toml @@ -0,0 +1,24 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "autocfg" +version = "1.0.0" +authors = ["Josh Stone "] +description = "Automatic cfg for Rust compiler features" +readme = "README.md" +keywords = ["rustc", "build", "autoconf"] +categories = ["development-tools::build-utils"] +license = "Apache-2.0 OR MIT" +repository = "https://github.com/cuviper/autocfg" + +[dependencies] diff --git a/third_party/cargo/vendor/autocfg-1.0.0/LICENSE-APACHE b/third_party/cargo/vendor/autocfg-1.0.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/autocfg-1.0.0/LICENSE-MIT b/third_party/cargo/vendor/autocfg-1.0.0/LICENSE-MIT new file mode 100644 index 0000000..44fbc4d --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2018 Josh Stone + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/autocfg-1.0.0/README.md b/third_party/cargo/vendor/autocfg-1.0.0/README.md new file mode 100644 index 0000000..5698b0d --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/README.md @@ -0,0 +1,89 @@ +autocfg +======= + +[![autocfg crate](https://img.shields.io/crates/v/autocfg.svg)](https://crates.io/crates/autocfg) +[![autocfg documentation](https://docs.rs/autocfg/badge.svg)](https://docs.rs/autocfg) +![minimum rustc 1.0](https://img.shields.io/badge/rustc-1.0+-red.svg) +[![Travis Status](https://travis-ci.org/cuviper/autocfg.svg?branch=master)](https://travis-ci.org/cuviper/autocfg) + +A Rust library for build scripts to automatically configure code based on +compiler support. Code snippets are dynamically tested to see if the `rustc` +will accept them, rather than hard-coding specific version support. + + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[build-dependencies] +autocfg = "1" +``` + +Then use it in your `build.rs` script to detect compiler features. For +example, to test for 128-bit integer support, it might look like: + +```rust +extern crate autocfg; + +fn main() { + let ac = autocfg::new(); + ac.emit_has_type("i128"); + + // (optional) We don't need to rerun for anything external. + autocfg::rerun_path("build.rs"); +} +``` + +If the type test succeeds, this will write a `cargo:rustc-cfg=has_i128` line +for Cargo, which translates to Rust arguments `--cfg has_i128`. Then in the +rest of your Rust code, you can add `#[cfg(has_i128)]` conditions on code that +should only be used when the compiler supports it. + + +## Release Notes + +- 1.0.0 (2020-01-08) + - 🎉 Release 1.0! 🎉 (no breaking changes) + - Add `probe_expression` and `emit_expression_cfg` to test arbitrary expressions. + - Add `probe_constant` and `emit_constant_cfg` to test arbitrary constant expressions. + +- 0.1.7 (2019-10-20) + - Apply `RUSTFLAGS` when probing `$TARGET != $HOST`, mainly for sysroot, by @roblabla. + +- 0.1.6 (2019-08-19) + - Add `probe`/`emit_sysroot_crate`, by @leo60228. + +- 0.1.5 (2019-07-16) + - Mask some warnings from newer rustc. + +- 0.1.4 (2019-05-22) + - Relax `std`/`no_std` probing to a warning instead of an error. + - Improve `rustc` bootstrap compatibility. + +- 0.1.3 (2019-05-21) + - Auto-detects if `#![no_std]` is needed for the `$TARGET`. + +- 0.1.2 (2019-01-16) + - Add `rerun_env(ENV)` to print `cargo:rerun-if-env-changed=ENV`. + - Add `rerun_path(PATH)` to print `cargo:rerun-if-changed=PATH`. + + +## Minimum Rust version policy + +This crate's minimum supported `rustc` version is `1.0.0`. Compatibility is +its entire reason for existence, so this crate will be extremely conservative +about raising this requirement. If this is ever deemed necessary, it will be +treated as a major breaking change for semver purposes. + + +## License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. diff --git a/third_party/cargo/vendor/autocfg-1.0.0/examples/integers.rs b/third_party/cargo/vendor/autocfg-1.0.0/examples/integers.rs new file mode 100644 index 0000000..23d4cba --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/examples/integers.rs @@ -0,0 +1,9 @@ +extern crate autocfg; + +fn main() { + // Normally, cargo will set `OUT_DIR` for build scripts. + let ac = autocfg::AutoCfg::with_dir("target").unwrap(); + for i in 3..8 { + ac.emit_has_type(&format!("i{}", 1 << i)); + } +} diff --git a/third_party/cargo/vendor/autocfg-1.0.0/examples/paths.rs b/third_party/cargo/vendor/autocfg-1.0.0/examples/paths.rs new file mode 100644 index 0000000..b7a6ca7 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/examples/paths.rs @@ -0,0 +1,22 @@ +extern crate autocfg; + +fn main() { + // Normally, cargo will set `OUT_DIR` for build scripts. + let ac = autocfg::AutoCfg::with_dir("target").unwrap(); + + // since ancient times... + ac.emit_has_path("std::vec::Vec"); + ac.emit_path_cfg("std::vec::Vec", "has_vec"); + + // rustc 1.10.0 + ac.emit_has_path("std::panic::PanicInfo"); + ac.emit_path_cfg("std::panic::PanicInfo", "has_panic_info"); + + // rustc 1.20.0 + ac.emit_has_path("std::mem::ManuallyDrop"); + ac.emit_path_cfg("std::mem::ManuallyDrop", "has_manually_drop"); + + // rustc 1.25.0 + ac.emit_has_path("std::ptr::NonNull"); + ac.emit_path_cfg("std::ptr::NonNull", "has_non_null"); +} diff --git a/third_party/cargo/vendor/autocfg-1.0.0/examples/traits.rs b/third_party/cargo/vendor/autocfg-1.0.0/examples/traits.rs new file mode 100644 index 0000000..c1ca003 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/examples/traits.rs @@ -0,0 +1,26 @@ +extern crate autocfg; + +fn main() { + // Normally, cargo will set `OUT_DIR` for build scripts. + let ac = autocfg::AutoCfg::with_dir("target").unwrap(); + + // since ancient times... + ac.emit_has_trait("std::ops::Add"); + ac.emit_trait_cfg("std::ops::Add", "has_ops"); + + // trait parameters have to be provided + ac.emit_has_trait("std::borrow::Borrow"); + ac.emit_trait_cfg("std::borrow::Borrow", "has_borrow"); + + // rustc 1.8.0 + ac.emit_has_trait("std::ops::AddAssign"); + ac.emit_trait_cfg("std::ops::AddAssign", "has_assign_ops"); + + // rustc 1.12.0 + ac.emit_has_trait("std::iter::Sum"); + ac.emit_trait_cfg("std::iter::Sum", "has_sum"); + + // rustc 1.28.0 + ac.emit_has_trait("std::alloc::GlobalAlloc"); + ac.emit_trait_cfg("std::alloc::GlobalAlloc", "has_global_alloc"); +} diff --git a/third_party/cargo/vendor/autocfg-1.0.0/examples/versions.rs b/third_party/cargo/vendor/autocfg-1.0.0/examples/versions.rs new file mode 100644 index 0000000..992919b --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/examples/versions.rs @@ -0,0 +1,9 @@ +extern crate autocfg; + +fn main() { + // Normally, cargo will set `OUT_DIR` for build scripts. + let ac = autocfg::AutoCfg::with_dir("target").unwrap(); + for i in 0..100 { + ac.emit_rustc_version(1, i); + } +} diff --git a/third_party/cargo/vendor/autocfg-1.0.0/src/error.rs b/third_party/cargo/vendor/autocfg-1.0.0/src/error.rs new file mode 100644 index 0000000..4624835 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/src/error.rs @@ -0,0 +1,69 @@ +use std::error; +use std::fmt; +use std::io; +use std::num; +use std::str; + +/// A common error type for the `autocfg` crate. +#[derive(Debug)] +pub struct Error { + kind: ErrorKind, +} + +impl error::Error for Error { + fn description(&self) -> &str { + "AutoCfg error" + } + + fn cause(&self) -> Option<&error::Error> { + match self.kind { + ErrorKind::Io(ref e) => Some(e), + ErrorKind::Num(ref e) => Some(e), + ErrorKind::Utf8(ref e) => Some(e), + ErrorKind::Other(_) => None, + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + match self.kind { + ErrorKind::Io(ref e) => e.fmt(f), + ErrorKind::Num(ref e) => e.fmt(f), + ErrorKind::Utf8(ref e) => e.fmt(f), + ErrorKind::Other(s) => s.fmt(f), + } + } +} + +#[derive(Debug)] +enum ErrorKind { + Io(io::Error), + Num(num::ParseIntError), + Utf8(str::Utf8Error), + Other(&'static str), +} + +pub fn from_io(e: io::Error) -> Error { + Error { + kind: ErrorKind::Io(e), + } +} + +pub fn from_num(e: num::ParseIntError) -> Error { + Error { + kind: ErrorKind::Num(e), + } +} + +pub fn from_utf8(e: str::Utf8Error) -> Error { + Error { + kind: ErrorKind::Utf8(e), + } +} + +pub fn from_str(s: &'static str) -> Error { + Error { + kind: ErrorKind::Other(s), + } +} diff --git a/third_party/cargo/vendor/autocfg-1.0.0/src/lib.rs b/third_party/cargo/vendor/autocfg-1.0.0/src/lib.rs new file mode 100644 index 0000000..a478010 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/src/lib.rs @@ -0,0 +1,412 @@ +//! A Rust library for build scripts to automatically configure code based on +//! compiler support. Code snippets are dynamically tested to see if the `rustc` +//! will accept them, rather than hard-coding specific version support. +//! +//! +//! ## Usage +//! +//! Add this to your `Cargo.toml`: +//! +//! ```toml +//! [build-dependencies] +//! autocfg = "1" +//! ``` +//! +//! Then use it in your `build.rs` script to detect compiler features. For +//! example, to test for 128-bit integer support, it might look like: +//! +//! ```rust +//! extern crate autocfg; +//! +//! fn main() { +//! # // Normally, cargo will set `OUT_DIR` for build scripts. +//! # std::env::set_var("OUT_DIR", "target"); +//! let ac = autocfg::new(); +//! ac.emit_has_type("i128"); +//! +//! // (optional) We don't need to rerun for anything external. +//! autocfg::rerun_path("build.rs"); +//! } +//! ``` +//! +//! If the type test succeeds, this will write a `cargo:rustc-cfg=has_i128` line +//! for Cargo, which translates to Rust arguments `--cfg has_i128`. Then in the +//! rest of your Rust code, you can add `#[cfg(has_i128)]` conditions on code that +//! should only be used when the compiler supports it. +//! +//! ## Caution +//! +//! Many of the probing methods of `AutoCfg` document the particular template they +//! use, **subject to change**. The inputs are not validated to make sure they are +//! semantically correct for their expected use, so it's _possible_ to escape and +//! inject something unintended. However, such abuse is unsupported and will not +//! be considered when making changes to the templates. + +#![deny(missing_debug_implementations)] +#![deny(missing_docs)] +// allow future warnings that can't be fixed while keeping 1.0 compatibility +#![allow(unknown_lints)] +#![allow(bare_trait_objects)] +#![allow(ellipsis_inclusive_range_patterns)] + +/// Local macro to avoid `std::try!`, deprecated in Rust 1.39. +macro_rules! try { + ($result:expr) => { + match $result { + Ok(value) => value, + Err(error) => return Err(error), + } + }; +} + +use std::env; +use std::ffi::OsString; +use std::fs; +use std::io::{stderr, Write}; +use std::path::PathBuf; +use std::process::{Command, Stdio}; +#[allow(deprecated)] +use std::sync::atomic::ATOMIC_USIZE_INIT; +use std::sync::atomic::{AtomicUsize, Ordering}; + +mod error; +pub use error::Error; + +mod version; +use version::Version; + +#[cfg(test)] +mod tests; + +/// Helper to detect compiler features for `cfg` output in build scripts. +#[derive(Clone, Debug)] +pub struct AutoCfg { + out_dir: PathBuf, + rustc: PathBuf, + rustc_version: Version, + target: Option, + no_std: bool, + rustflags: Option>, +} + +/// Writes a config flag for rustc on standard out. +/// +/// This looks like: `cargo:rustc-cfg=CFG` +/// +/// Cargo will use this in arguments to rustc, like `--cfg CFG`. +pub fn emit(cfg: &str) { + println!("cargo:rustc-cfg={}", cfg); +} + +/// Writes a line telling Cargo to rerun the build script if `path` changes. +/// +/// This looks like: `cargo:rerun-if-changed=PATH` +/// +/// This requires at least cargo 0.7.0, corresponding to rustc 1.6.0. Earlier +/// versions of cargo will simply ignore the directive. +pub fn rerun_path(path: &str) { + println!("cargo:rerun-if-changed={}", path); +} + +/// Writes a line telling Cargo to rerun the build script if the environment +/// variable `var` changes. +/// +/// This looks like: `cargo:rerun-if-env-changed=VAR` +/// +/// This requires at least cargo 0.21.0, corresponding to rustc 1.20.0. Earlier +/// versions of cargo will simply ignore the directive. +pub fn rerun_env(var: &str) { + println!("cargo:rerun-if-env-changed={}", var); +} + +/// Create a new `AutoCfg` instance. +/// +/// # Panics +/// +/// Panics if `AutoCfg::new()` returns an error. +pub fn new() -> AutoCfg { + AutoCfg::new().unwrap() +} + +impl AutoCfg { + /// Create a new `AutoCfg` instance. + /// + /// # Common errors + /// + /// - `rustc` can't be executed, from `RUSTC` or in the `PATH`. + /// - The version output from `rustc` can't be parsed. + /// - `OUT_DIR` is not set in the environment, or is not a writable directory. + /// + pub fn new() -> Result { + match env::var_os("OUT_DIR") { + Some(d) => Self::with_dir(d), + None => Err(error::from_str("no OUT_DIR specified!")), + } + } + + /// Create a new `AutoCfg` instance with the specified output directory. + /// + /// # Common errors + /// + /// - `rustc` can't be executed, from `RUSTC` or in the `PATH`. + /// - The version output from `rustc` can't be parsed. + /// - `dir` is not a writable directory. + /// + pub fn with_dir>(dir: T) -> Result { + let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into()); + let rustc: PathBuf = rustc.into(); + let rustc_version = try!(Version::from_rustc(&rustc)); + + // Sanity check the output directory + let dir = dir.into(); + let meta = try!(fs::metadata(&dir).map_err(error::from_io)); + if !meta.is_dir() || meta.permissions().readonly() { + return Err(error::from_str("output path is not a writable directory")); + } + + // Cargo only applies RUSTFLAGS for building TARGET artifact in + // cross-compilation environment. Sadly, we don't have a way to detect + // when we're building HOST artifact in a cross-compilation environment, + // so for now we only apply RUSTFLAGS when cross-compiling an artifact. + // + // See https://github.com/cuviper/autocfg/pull/10#issuecomment-527575030. + let rustflags = if env::var_os("TARGET") != env::var_os("HOST") { + env::var("RUSTFLAGS").ok().map(|rustflags| { + // This is meant to match how cargo handles the RUSTFLAG environment + // variable. + // See https://github.com/rust-lang/cargo/blob/69aea5b6f69add7c51cca939a79644080c0b0ba0/src/cargo/core/compiler/build_context/target_info.rs#L434-L441 + rustflags + .split(' ') + .map(str::trim) + .filter(|s| !s.is_empty()) + .map(str::to_string) + .collect::>() + }) + } else { + None + }; + + let mut ac = AutoCfg { + out_dir: dir, + rustc: rustc, + rustc_version: rustc_version, + target: env::var_os("TARGET"), + no_std: false, + rustflags: rustflags, + }; + + // Sanity check with and without `std`. + if !ac.probe("").unwrap_or(false) { + ac.no_std = true; + if !ac.probe("").unwrap_or(false) { + // Neither worked, so assume nothing... + ac.no_std = false; + let warning = b"warning: autocfg could not probe for `std`\n"; + stderr().write_all(warning).ok(); + } + } + Ok(ac) + } + + /// Test whether the current `rustc` reports a version greater than + /// or equal to "`major`.`minor`". + pub fn probe_rustc_version(&self, major: usize, minor: usize) -> bool { + self.rustc_version >= Version::new(major, minor, 0) + } + + /// Sets a `cfg` value of the form `rustc_major_minor`, like `rustc_1_29`, + /// if the current `rustc` is at least that version. + pub fn emit_rustc_version(&self, major: usize, minor: usize) { + if self.probe_rustc_version(major, minor) { + emit(&format!("rustc_{}_{}", major, minor)); + } + } + + fn probe>(&self, code: T) -> Result { + #[allow(deprecated)] + static ID: AtomicUsize = ATOMIC_USIZE_INIT; + + let id = ID.fetch_add(1, Ordering::Relaxed); + let mut command = Command::new(&self.rustc); + command + .arg("--crate-name") + .arg(format!("probe{}", id)) + .arg("--crate-type=lib") + .arg("--out-dir") + .arg(&self.out_dir) + .arg("--emit=llvm-ir"); + + if let &Some(ref rustflags) = &self.rustflags { + command.args(rustflags); + } + + if let Some(target) = self.target.as_ref() { + command.arg("--target").arg(target); + } + + command.arg("-").stdin(Stdio::piped()); + let mut child = try!(command.spawn().map_err(error::from_io)); + let mut stdin = child.stdin.take().expect("rustc stdin"); + + if self.no_std { + try!(stdin.write_all(b"#![no_std]\n").map_err(error::from_io)); + } + try!(stdin.write_all(code.as_ref()).map_err(error::from_io)); + drop(stdin); + + let status = try!(child.wait().map_err(error::from_io)); + Ok(status.success()) + } + + /// Tests whether the given sysroot crate can be used. + /// + /// The test code is subject to change, but currently looks like: + /// + /// ```ignore + /// extern crate CRATE as probe; + /// ``` + pub fn probe_sysroot_crate(&self, name: &str) -> bool { + self.probe(format!("extern crate {} as probe;", name)) // `as _` wasn't stabilized until Rust 1.33 + .unwrap_or(false) + } + + /// Emits a config value `has_CRATE` if `probe_sysroot_crate` returns true. + pub fn emit_sysroot_crate(&self, name: &str) { + if self.probe_sysroot_crate(name) { + emit(&format!("has_{}", mangle(name))); + } + } + + /// Tests whether the given path can be used. + /// + /// The test code is subject to change, but currently looks like: + /// + /// ```ignore + /// pub use PATH; + /// ``` + pub fn probe_path(&self, path: &str) -> bool { + self.probe(format!("pub use {};", path)).unwrap_or(false) + } + + /// Emits a config value `has_PATH` if `probe_path` returns true. + /// + /// Any non-identifier characters in the `path` will be replaced with + /// `_` in the generated config value. + pub fn emit_has_path(&self, path: &str) { + if self.probe_path(path) { + emit(&format!("has_{}", mangle(path))); + } + } + + /// Emits the given `cfg` value if `probe_path` returns true. + pub fn emit_path_cfg(&self, path: &str, cfg: &str) { + if self.probe_path(path) { + emit(cfg); + } + } + + /// Tests whether the given trait can be used. + /// + /// The test code is subject to change, but currently looks like: + /// + /// ```ignore + /// pub trait Probe: TRAIT + Sized {} + /// ``` + pub fn probe_trait(&self, name: &str) -> bool { + self.probe(format!("pub trait Probe: {} + Sized {{}}", name)) + .unwrap_or(false) + } + + /// Emits a config value `has_TRAIT` if `probe_trait` returns true. + /// + /// Any non-identifier characters in the trait `name` will be replaced with + /// `_` in the generated config value. + pub fn emit_has_trait(&self, name: &str) { + if self.probe_trait(name) { + emit(&format!("has_{}", mangle(name))); + } + } + + /// Emits the given `cfg` value if `probe_trait` returns true. + pub fn emit_trait_cfg(&self, name: &str, cfg: &str) { + if self.probe_trait(name) { + emit(cfg); + } + } + + /// Tests whether the given type can be used. + /// + /// The test code is subject to change, but currently looks like: + /// + /// ```ignore + /// pub type Probe = TYPE; + /// ``` + pub fn probe_type(&self, name: &str) -> bool { + self.probe(format!("pub type Probe = {};", name)) + .unwrap_or(false) + } + + /// Emits a config value `has_TYPE` if `probe_type` returns true. + /// + /// Any non-identifier characters in the type `name` will be replaced with + /// `_` in the generated config value. + pub fn emit_has_type(&self, name: &str) { + if self.probe_type(name) { + emit(&format!("has_{}", mangle(name))); + } + } + + /// Emits the given `cfg` value if `probe_type` returns true. + pub fn emit_type_cfg(&self, name: &str, cfg: &str) { + if self.probe_type(name) { + emit(cfg); + } + } + + /// Tests whether the given expression can be used. + /// + /// The test code is subject to change, but currently looks like: + /// + /// ```ignore + /// pub fn probe() { let _ = EXPR; } + /// ``` + pub fn probe_expression(&self, expr: &str) -> bool { + self.probe(format!("pub fn probe() {{ let _ = {}; }}", expr)) + .unwrap_or(false) + } + + /// Emits the given `cfg` value if `probe_expression` returns true. + pub fn emit_expression_cfg(&self, expr: &str, cfg: &str) { + if self.probe_expression(expr) { + emit(cfg); + } + } + + /// Tests whether the given constant expression can be used. + /// + /// The test code is subject to change, but currently looks like: + /// + /// ```ignore + /// pub const PROBE: () = ((), EXPR).0; + /// ``` + pub fn probe_constant(&self, expr: &str) -> bool { + self.probe(format!("pub const PROBE: () = ((), {}).0;", expr)) + .unwrap_or(false) + } + + /// Emits the given `cfg` value if `probe_constant` returns true. + pub fn emit_constant_cfg(&self, expr: &str, cfg: &str) { + if self.probe_constant(expr) { + emit(cfg); + } + } +} + +fn mangle(s: &str) -> String { + s.chars() + .map(|c| match c { + 'A'...'Z' | 'a'...'z' | '0'...'9' => c, + _ => '_', + }) + .collect() +} diff --git a/third_party/cargo/vendor/autocfg-1.0.0/src/tests.rs b/third_party/cargo/vendor/autocfg-1.0.0/src/tests.rs new file mode 100644 index 0000000..f558e71 --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/src/tests.rs @@ -0,0 +1,125 @@ +use super::AutoCfg; + +impl AutoCfg { + fn core_std(&self, path: &str) -> String { + let krate = if self.no_std { "core" } else { "std" }; + format!("{}::{}", krate, path) + } + + fn assert_std(&self, probe_result: bool) { + assert_eq!(!self.no_std, probe_result); + } + + fn assert_min(&self, major: usize, minor: usize, probe_result: bool) { + assert_eq!(self.probe_rustc_version(major, minor), probe_result); + } +} + +#[test] +fn autocfg_version() { + let ac = AutoCfg::with_dir("target").unwrap(); + println!("version: {:?}", ac.rustc_version); + assert!(ac.probe_rustc_version(1, 0)); +} + +#[test] +fn version_cmp() { + use super::version::Version; + let v123 = Version::new(1, 2, 3); + + assert!(Version::new(1, 0, 0) < v123); + assert!(Version::new(1, 2, 2) < v123); + assert!(Version::new(1, 2, 3) == v123); + assert!(Version::new(1, 2, 4) > v123); + assert!(Version::new(1, 10, 0) > v123); + assert!(Version::new(2, 0, 0) > v123); +} + +#[test] +fn probe_add() { + let ac = AutoCfg::with_dir("target").unwrap(); + let add = ac.core_std("ops::Add"); + let add_rhs = add.clone() + ""; + let add_rhs_output = add.clone() + ""; + let dyn_add_rhs_output = "dyn ".to_string() + &*add_rhs_output; + assert!(ac.probe_path(&add)); + assert!(ac.probe_trait(&add)); + assert!(ac.probe_trait(&add_rhs)); + assert!(ac.probe_trait(&add_rhs_output)); + ac.assert_min(1, 27, ac.probe_type(&dyn_add_rhs_output)); +} + +#[test] +fn probe_as_ref() { + let ac = AutoCfg::with_dir("target").unwrap(); + let as_ref = ac.core_std("convert::AsRef"); + let as_ref_str = as_ref.clone() + ""; + let dyn_as_ref_str = "dyn ".to_string() + &*as_ref_str; + assert!(ac.probe_path(&as_ref)); + assert!(ac.probe_trait(&as_ref_str)); + assert!(ac.probe_type(&as_ref_str)); + ac.assert_min(1, 27, ac.probe_type(&dyn_as_ref_str)); +} + +#[test] +fn probe_i128() { + let ac = AutoCfg::with_dir("target").unwrap(); + let i128_path = ac.core_std("i128"); + ac.assert_min(1, 26, ac.probe_path(&i128_path)); + ac.assert_min(1, 26, ac.probe_type("i128")); +} + +#[test] +fn probe_sum() { + let ac = AutoCfg::with_dir("target").unwrap(); + let sum = ac.core_std("iter::Sum"); + let sum_i32 = sum.clone() + ""; + let dyn_sum_i32 = "dyn ".to_string() + &*sum_i32; + ac.assert_min(1, 12, ac.probe_path(&sum)); + ac.assert_min(1, 12, ac.probe_trait(&sum)); + ac.assert_min(1, 12, ac.probe_trait(&sum_i32)); + ac.assert_min(1, 12, ac.probe_type(&sum_i32)); + ac.assert_min(1, 27, ac.probe_type(&dyn_sum_i32)); +} + +#[test] +fn probe_std() { + let ac = AutoCfg::with_dir("target").unwrap(); + ac.assert_std(ac.probe_sysroot_crate("std")); +} + +#[test] +fn probe_alloc() { + let ac = AutoCfg::with_dir("target").unwrap(); + ac.assert_min(1, 36, ac.probe_sysroot_crate("alloc")); +} + +#[test] +fn probe_bad_sysroot_crate() { + let ac = AutoCfg::with_dir("target").unwrap(); + assert!(!ac.probe_sysroot_crate("doesnt_exist")); +} + +#[test] +fn probe_no_std() { + let ac = AutoCfg::with_dir("target").unwrap(); + assert!(ac.probe_type("i32")); + assert!(ac.probe_type("[i32]")); + ac.assert_std(ac.probe_type("Vec")); +} + +#[test] +fn probe_expression() { + let ac = AutoCfg::with_dir("target").unwrap(); + assert!(ac.probe_expression(r#""test".trim_left()"#)); + ac.assert_min(1, 30, ac.probe_expression(r#""test".trim_start()"#)); + ac.assert_std(ac.probe_expression("[1, 2, 3].to_vec()")); +} + +#[test] +fn probe_constant() { + let ac = AutoCfg::with_dir("target").unwrap(); + assert!(ac.probe_constant("1 + 2 + 3")); + ac.assert_min(1, 33, ac.probe_constant("{ let x = 1 + 2 + 3; x * x }")); + ac.assert_min(1, 39, ac.probe_constant(r#""test".len()"#)); +} diff --git a/third_party/cargo/vendor/autocfg-1.0.0/src/version.rs b/third_party/cargo/vendor/autocfg-1.0.0/src/version.rs new file mode 100644 index 0000000..378c21e --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/src/version.rs @@ -0,0 +1,60 @@ +use std::path::Path; +use std::process::Command; +use std::str; + +use super::{error, Error}; + +/// A version structure for making relative comparisons. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct Version { + major: usize, + minor: usize, + patch: usize, +} + +impl Version { + /// Creates a `Version` instance for a specific `major.minor.patch` version. + pub fn new(major: usize, minor: usize, patch: usize) -> Self { + Version { + major: major, + minor: minor, + patch: patch, + } + } + + pub fn from_rustc(rustc: &Path) -> Result { + // Get rustc's verbose version + let output = try!(Command::new(rustc) + .args(&["--version", "--verbose"]) + .output() + .map_err(error::from_io)); + if !output.status.success() { + return Err(error::from_str("could not execute rustc")); + } + let output = try!(str::from_utf8(&output.stdout).map_err(error::from_utf8)); + + // Find the release line in the verbose version output. + let release = match output.lines().find(|line| line.starts_with("release: ")) { + Some(line) => &line["release: ".len()..], + None => return Err(error::from_str("could not find rustc release")), + }; + + // Strip off any extra channel info, e.g. "-beta.N", "-nightly" + let version = match release.find('-') { + Some(i) => &release[..i], + None => release, + }; + + // Split the version into semver components. + let mut iter = version.splitn(3, '.'); + let major = try!(iter.next().ok_or(error::from_str("missing major version"))); + let minor = try!(iter.next().ok_or(error::from_str("missing minor version"))); + let patch = try!(iter.next().ok_or(error::from_str("missing patch version"))); + + Ok(Version::new( + try!(major.parse().map_err(error::from_num)), + try!(minor.parse().map_err(error::from_num)), + try!(patch.parse().map_err(error::from_num)), + )) + } +} diff --git a/third_party/cargo/vendor/autocfg-1.0.0/tests/rustflags.rs b/third_party/cargo/vendor/autocfg-1.0.0/tests/rustflags.rs new file mode 100644 index 0000000..119376c --- /dev/null +++ b/third_party/cargo/vendor/autocfg-1.0.0/tests/rustflags.rs @@ -0,0 +1,19 @@ +extern crate autocfg; + +use std::env; + +/// Tests that autocfg uses the RUSTFLAGS environment variable when running +/// rustc. +#[test] +fn test_with_sysroot() { + // Use the same path as this test binary. + let dir = env::current_exe().unwrap().parent().unwrap().to_path_buf(); + env::set_var("RUSTFLAGS", &format!("-L {}", dir.display())); + env::set_var("OUT_DIR", &format!("{}", dir.display())); + + // Ensure HOST != TARGET. + env::set_var("HOST", "lol"); + + let ac = autocfg::AutoCfg::new().unwrap(); + assert!(ac.probe_sysroot_crate("autocfg")); +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/.cargo-checksum.json b/third_party/cargo/vendor/backtrace-0.3.42/.cargo-checksum.json new file mode 100644 index 0000000..8b87f50 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"3982168ace9c9ef0bb836a0b8d7c3f873f878842ab8c2c7414a3a17bae17952d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"5038903e047ac0287b2a16218109171c99a8b67242bdeaff52db51bd60b68fb0","benches/benchmarks.rs":"ce5763576fa8aeb722d3b8bcdb294d8a31e80e3c5272da25525fdcc392ccc6cc","ci/android-ndk.sh":"89fafa41d08ff477f949bfc163d04d1eb34fdee370f7a695cfba4ef34c164a55","ci/android-sdk.sh":"3269ef90675e8d4c2031e542cd3a55d9e060b2a094105cde982b282185936dda","ci/docker/aarch64-linux-android/Dockerfile":"cb5c55f17fcb0d65713086b8796de070657440cbcb6c2eded34b61b957b7bce8","ci/docker/aarch64-unknown-linux-gnu/Dockerfile":"97fa8f20c6899ee36b47371d485b64a2e96b626a2746b5f434c01eae9168b2a1","ci/docker/arm-linux-androideabi/Dockerfile":"3fe712b0927fd8fb05c1f733f0bf0d8a139bfc5a0108ba5515bd6b499976f1ab","ci/docker/arm-unknown-linux-gnueabihf/Dockerfile":"41133d712ef13f05e67796857db86476b3ed9c6355d5eb56115575b06d739e04","ci/docker/armv7-linux-androideabi/Dockerfile":"10783c6d22e727c38b2483ed5d941aeb8f1099025e263183f1598c604924ffa6","ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile":"2a216244baad705491f249278083994bf68744a2759f51e768b2f92e0da7c360","ci/docker/i586-unknown-linux-gnu/Dockerfile":"ef898c914590d721488ca11e62f3d7c26852346e1612deb0f3e12ab011187109","ci/docker/i686-linux-android/Dockerfile":"1a2119c2119a2213cf22a825166cd7bb75386fa057c7fabb2f572fc1e65f1870","ci/docker/i686-unknown-linux-gnu/Dockerfile":"ef898c914590d721488ca11e62f3d7c26852346e1612deb0f3e12ab011187109","ci/docker/powerpc64-unknown-linux-gnu/Dockerfile":"7cd511302c4624f0ee3944a6f5e4f5f25bb727ba2623d1e6b8f288a4d8cec30c","ci/docker/x86_64-linux-android/Dockerfile":"37f0bdcfed3d9382e09056e1f32351cbf6a901810d58060a4384a42303f2f7a3","ci/docker/x86_64-pc-windows-gnu/Dockerfile":"cbde261d7bcea43059e341363d57a00a83d9ebe4501aca2c1c6ba834e0ea9eb9","ci/docker/x86_64-unknown-linux-gnu/Dockerfile":"e1c202a6831b17e017b4737e80d5b992905895b086bbc06285fc9c337cadbc23","ci/docker/x86_64-unknown-linux-musl/Dockerfile":"2efbba08cc8fff8d2431dde92517df7d122dc754c778820c668f1ac29a885290","ci/run-docker.sh":"c4efad39c65a38c89e90d61a9ef15136903dd4cf01a6ae8079aa005b882d751e","ci/run.sh":"30a3807c195cd86d8b8884e1228cd061aa112b26c54277beebf5108777a36fe9","ci/runtest-android.rs":"be2e49bb296b92a8e3643a6c0a70917fe7b130fa43b71a29c4e7514f45c00e7e","examples/backtrace.rs":"fd6e1cc6c3378ec7d41cd03b2bef187051298dceb01147e71f207dbb8a0c4867","examples/raw.rs":"81fb66bd0f71010f9a954f667d92bf792cfd1ac90fa3a09c362767d866dc8374","src/backtrace/dbghelp.rs":"d5f56dc97d1e7cf2bed05ac6e922ca5be96aaab2f1098601343affd22241fa38","src/backtrace/libunwind.rs":"d006cdb883919d9dd138132216c83398987016264f67c714d07abdbf3383362a","src/backtrace/mod.rs":"8d9c7f5ab5cacc00b766d811fb6a38c57c78b42894c2499cd02ec802bb593b4c","src/backtrace/noop.rs":"9d9a93a890cef988b691232d9d1e7d114768ada58e9591345826135cb380f01a","src/backtrace/unix_backtrace.rs":"293c6ac31e9eb8e32dc7d219f4cf5dbeb9b66bdc42dcc949d1de63233dea2666","src/capture.rs":"c7c9f0a55312c9687d43118b69d4416d9c8eac1f7eaeb542807bc5e23bc18ce0","src/dbghelp.rs":"c33788eeef29bb78a1cdd7cf7f3e034b82d3686ba87d76a920692db19b26212b","src/lib.rs":"881e140db1f7e19bf3eb139881f102801aa9c06344282417b9b1e2c67534466a","src/print.rs":"a74ba3a97c07045997c282b8066cd6b9ac3b755122cafb9dbe0e6479752065e0","src/print/fuchsia.rs":"4620968941adda90cec97d3cdfe06937327cdee5882f1b98bc933efaac68ef7a","src/symbolize/coresymbolication.rs":"f5442333d8c58188fe3c7749783336bd2e096ed9940d77c19ce4295dd592fb0b","src/symbolize/dbghelp.rs":"649d5ff1656e8fd84ab1088bb48054f6ea7cd0c50a09af09f72d562c17e52b6b","src/symbolize/dladdr.rs":"4b420b07f345f7c4e545c43f68d1b2d1f419a9228712097f35eae875b182b349","src/symbolize/dladdr_resolve.rs":"ec3bc5c8462cce48e97136e4867dd08a5f1b0c133e45d511745c1c3197e78405","src/symbolize/gimli.rs":"7232bc02c14af59db4296266965d4839c359a08679b9a7f02a55275ff87ac864","src/symbolize/libbacktrace.rs":"d3f18a85fd13c32f949226e2d5cde3c40f60d73d32c46e91bf670cb202cf5f3b","src/symbolize/mod.rs":"aec85aee8ff3e00a532f7d1ab8739802d6e2df369aecfe045fe6d8b6a4004c11","src/symbolize/noop.rs":"a8581b117e1065236c12f0a4a4c49f4c1929c4e6a3283f2253bb1fd0c77e4f7a","src/types.rs":"85dac420ee8791281f4cdec78e86be056c84ffecc0e5e5821d91862fc0e23444","src/windows.rs":"4a025bd064d22134185441859ab5337e31a33d39af212801fd7ada374595fd41","tests/accuracy/auxiliary.rs":"8bcf4a3a15ebed82f878c440910a07866efbc5eacea8b74f482dae297c779226","tests/accuracy/main.rs":"db2870e7fa51df01a5176e59bd87d205d83cad1599f374f273e11baf5efd41bb","tests/concurrent-panics.rs":"7c37df054c57c0c6694265bcaa596c1418a90cce65a569699e1b0c56bcd4bdfa","tests/long_fn_name.rs":"ca2480a72e8d2c02c678f047c202cdec7efafeb2fb32d94a327c669b7c81807a","tests/skip_inner_frames.rs":"b5c9137723c8648da46396c4c631e4b7d9933cac33397ae3da588a4692322212","tests/smoke.rs":"0330093fa76bd83851f2b8efb37330ce1c1c48d2be99313074d9c727491377f7"},"package":"b4b1549d804b6c73f4817df2ba073709e96e426f12987127c48e6745568c350b"} \ No newline at end of file diff --git a/third_party/cargo/vendor/backtrace-0.3.42/BUILD b/third_party/cargo/vendor/backtrace-0.3.42/BUILD new file mode 100644 index 0000000..2fe9693 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/BUILD @@ -0,0 +1,61 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "accuracy" with type "test" omitted +# Unsupported target "backtrace" with type "example" omitted + +rust_library( + name = "backtrace", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/backtrace-sys-0.1.32:backtrace_sys", + "//third_party/cargo/vendor/cfg-if-0.1.10:cfg_if", + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/rustc-demangle-0.1.16:rustc_demangle", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.3.42", + crate_features = [ + "backtrace-sys", + "dbghelp", + "default", + "dladdr", + "libbacktrace", + "libunwind", + "std", + ], +) + +# Unsupported target "benchmarks" with type "bench" omitted +# Unsupported target "concurrent-panics" with type "test" omitted +# Unsupported target "long_fn_name" with type "test" omitted +# Unsupported target "raw" with type "example" omitted +# Unsupported target "skip_inner_frames" with type "test" omitted +# Unsupported target "smoke" with type "test" omitted diff --git a/third_party/cargo/vendor/backtrace-0.3.42/Cargo.toml b/third_party/cargo/vendor/backtrace-0.3.42/Cargo.toml new file mode 100644 index 0000000..a9846d6 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/Cargo.toml @@ -0,0 +1,131 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "backtrace" +version = "0.3.42" +authors = ["The Rust Project Developers"] +autoexamples = true +autotests = true +description = "A library to acquire a stack trace (backtrace) at runtime in a Rust program.\n" +homepage = "https://github.com/rust-lang/backtrace-rs" +documentation = "https://docs.rs/backtrace" +readme = "README.md" +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-lang/backtrace-rs" + +[[example]] +name = "backtrace" +required-features = ["std"] + +[[example]] +name = "raw" +required-features = ["std"] + +[[test]] +name = "skip_inner_frames" +required-features = ["std"] + +[[test]] +name = "long_fn_name" +required-features = ["std"] + +[[test]] +name = "smoke" +required-features = ["std"] +edition = "2018" + +[[test]] +name = "accuracy" +required-features = ["std", "dbghelp", "libbacktrace", "libunwind"] +edition = "2018" + +[[test]] +name = "concurrent-panics" +harness = false +required-features = ["std"] +[dependencies.addr2line] +version = "0.11.0" +features = ["std"] +optional = true +default-features = false + +[dependencies.backtrace-sys] +version = "0.1.32" +optional = true + +[dependencies.cfg-if] +version = "0.1.6" + +[dependencies.compiler_builtins] +version = "0.1.2" +optional = true + +[dependencies.core] +version = "1.0.0" +optional = true +package = "rustc-std-workspace-core" + +[dependencies.cpp_demangle] +version = "0.2.3" +optional = true +default-features = false + +[dependencies.findshlibs] +version = "0.5.0" +optional = true + +[dependencies.goblin] +version = "0.1.3" +features = ["elf32", "elf64", "mach32", "mach64", "pe32", "pe64", "std"] +optional = true +default-features = false + +[dependencies.libc] +version = "0.2.45" +default-features = false + +[dependencies.memmap] +version = "0.7.0" +optional = true + +[dependencies.rustc-demangle] +version = "0.1.4" + +[dependencies.rustc-serialize] +version = "0.3" +optional = true + +[dependencies.serde] +version = "1.0" +features = ["derive"] +optional = true + +[features] +coresymbolication = [] +dbghelp = [] +default = ["std", "libunwind", "libbacktrace", "dladdr", "dbghelp"] +dladdr = [] +gimli-symbolize = ["addr2line", "findshlibs", "memmap", "goblin"] +kernel32 = [] +libbacktrace = ["backtrace-sys"] +libunwind = [] +rustc-dep-of-std = ["backtrace-sys/rustc-dep-of-std", "cfg-if/rustc-dep-of-std", "core", "compiler_builtins", "libc/rustc-dep-of-std", "rustc-demangle/rustc-dep-of-std"] +serialize-rustc = ["rustc-serialize"] +serialize-serde = ["serde"] +std = [] +unix-backtrace = [] +verify-winapi = ["winapi/dbghelp", "winapi/handleapi", "winapi/libloaderapi", "winapi/minwindef", "winapi/processthreadsapi", "winapi/synchapi", "winapi/winbase", "winapi/winnt"] +[target."cfg(windows)".dependencies.winapi] +version = "0.3.3" +optional = true diff --git a/third_party/cargo/vendor/backtrace-0.3.42/LICENSE-APACHE b/third_party/cargo/vendor/backtrace-0.3.42/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/backtrace-0.3.42/LICENSE-MIT b/third_party/cargo/vendor/backtrace-0.3.42/LICENSE-MIT new file mode 100644 index 0000000..39e0ed6 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/backtrace-0.3.42/README.md b/third_party/cargo/vendor/backtrace-0.3.42/README.md new file mode 100644 index 0000000..9713f0c --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/README.md @@ -0,0 +1,81 @@ +# backtrace-rs + +[Documentation](https://docs.rs/backtrace) + +A library for acquiring backtraces at runtime for Rust. This library aims to +enhance the support of the standard library by providing a programmatic +interface to work with, but it also supports simply easily printing the current +backtrace like libstd's panics. + +## Install + +```toml +[dependencies] +backtrace = "0.3" +``` + +Note that this crate requires `cc` and `ar` to be present on Unix systems when +`libbacktrace` is used (which is the default). For configuring C compilers see +the [`cc` crate documentation](https://github.com/alexcrichton/cc-rs). + +## Usage + +To simply capture a backtrace and defer dealing with it until a later time, +you can use the top-level `Backtrace` type. + +```rust +extern crate backtrace; + +use backtrace::Backtrace; + +fn main() { + let bt = Backtrace::new(); + + // do_some_work(); + + println!("{:?}", bt); +} +``` + +If, however, you'd like more raw access to the actual tracing functionality, you +can use the `trace` and `resolve` functions directly. + +```rust +extern crate backtrace; + +fn main() { + backtrace::trace(|frame| { + let ip = frame.ip(); + let symbol_address = frame.symbol_address(); + + // Resolve this instruction pointer to a symbol name + backtrace::resolve_frame(frame, |symbol| { + if let Some(name) = symbol.name() { + // ... + } + if let Some(filename) = symbol.filename() { + // ... + } + }); + + true // keep going to the next frame + }); +} +``` + +# License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in backtrace-rs by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/backtrace-0.3.42/benches/benchmarks.rs b/third_party/cargo/vendor/backtrace-0.3.42/benches/benchmarks.rs new file mode 100644 index 0000000..ad55788 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/benches/benchmarks.rs @@ -0,0 +1,94 @@ +#![feature(test)] + +extern crate test; + +extern crate backtrace; + +#[cfg(feature = "std")] +use backtrace::Backtrace; + +#[bench] +#[cfg(feature = "std")] +fn trace(b: &mut test::Bencher) { + #[inline(never)] + fn the_function() { + backtrace::trace(|frame| { + let ip = frame.ip(); + test::black_box(ip); + true + }); + } + b.iter(the_function); +} + +#[bench] +#[cfg(feature = "std")] +fn trace_and_resolve_callback(b: &mut test::Bencher) { + #[inline(never)] + fn the_function() { + backtrace::trace(|frame| { + backtrace::resolve(frame.ip(), |symbol| { + let addr = symbol.addr(); + test::black_box(addr); + }); + true + }); + } + b.iter(the_function); +} + +#[bench] +#[cfg(feature = "std")] +fn trace_and_resolve_separate(b: &mut test::Bencher) { + #[inline(never)] + fn the_function(frames: &mut Vec<*mut std::ffi::c_void>) { + backtrace::trace(|frame| { + frames.push(frame.ip()); + true + }); + frames.iter().for_each(|frame_ip| { + backtrace::resolve(*frame_ip, |symbol| { + test::black_box(symbol); + }); + }); + } + let mut frames = Vec::with_capacity(1024); + b.iter(|| { + the_function(&mut frames); + frames.clear(); + }); +} + +#[bench] +#[cfg(feature = "std")] +fn new_unresolved(b: &mut test::Bencher) { + #[inline(never)] + fn the_function() { + let bt = Backtrace::new_unresolved(); + test::black_box(bt); + } + b.iter(the_function); +} + +#[bench] +#[cfg(feature = "std")] +fn new(b: &mut test::Bencher) { + #[inline(never)] + fn the_function() { + let bt = Backtrace::new(); + test::black_box(bt); + } + b.iter(the_function); +} + +#[bench] +#[cfg(feature = "std")] +fn new_unresolved_and_resolve_separate(b: &mut test::Bencher) { + #[inline(never)] + fn the_function() { + let mut bt = Backtrace::new_unresolved(); + bt.resolve(); + test::black_box(bt); + } + b.iter(the_function); +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/android-ndk.sh b/third_party/cargo/vendor/backtrace-0.3.42/ci/android-ndk.sh new file mode 100755 index 0000000..b5df62b --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/android-ndk.sh @@ -0,0 +1,23 @@ +set -ex + +ANDROID_ARCH=$1 +ANDROID_SDK_VERSION=4333796 + +mkdir /tmp/android +cd /tmp/android + +curl -o android-sdk.zip \ + "https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_VERSION}.zip" +unzip -q android-sdk.zip + +yes | ./tools/bin/sdkmanager --licenses > /dev/null +./tools/bin/sdkmanager ndk-bundle > /dev/null + +./ndk-bundle/build/tools/make_standalone_toolchain.py \ + --arch $ANDROID_ARCH \ + --stl=libc++ \ + --api 21 \ + --install-dir /android-toolchain + +cd /tmp +rm -rf android diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/android-sdk.sh b/third_party/cargo/vendor/backtrace-0.3.42/ci/android-sdk.sh new file mode 100755 index 0000000..aee133e --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/android-sdk.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env sh +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +# Prep the SDK and emulator +# +# Note that the update process requires that we accept a bunch of licenses, and +# we can't just pipe `yes` into it for some reason, so we take the same strategy +# located in https://github.com/appunite/docker by just wrapping it in a script +# which apparently magically accepts the licenses. + +SDK=4333796 +mkdir sdk +curl --retry 20 https://dl.google.com/android/repository/sdk-tools-linux-${SDK}.zip -O +unzip -q -d sdk sdk-tools-linux-${SDK}.zip + +case "$1" in + arm | armv7) + api=24 + image="system-images;android-${api};google_apis;armeabi-v7a" + ;; + aarch64) + api=24 + image="system-images;android-${api};google_apis;arm64-v8a" + ;; + i686) + api=28 + image="system-images;android-${api};default;x86" + ;; + x86_64) + api=28 + image="system-images;android-${api};default;x86_64" + ;; + *) + echo "invalid arch: $1" + exit 1 + ;; +esac; + +# Try to fix warning about missing file. +# See https://askubuntu.com/a/1078784 +mkdir -p /root/.android/ +echo '### User Sources for Android SDK Manager' >> /root/.android/repositories.cfg +echo '#Fri Nov 03 10:11:27 CET 2017 count=0' >> /root/.android/repositories.cfg + +# Print all available packages +# yes | ./sdk/tools/bin/sdkmanager --list --verbose + +# --no_https avoids +# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found +# +# | grep -v = || true removes the progress bar output from the sdkmanager +# which produces an insane amount of output. +yes | ./sdk/tools/bin/sdkmanager --licenses --no_https | grep -v = || true +yes | ./sdk/tools/bin/sdkmanager --no_https \ + "emulator" \ + "platform-tools" \ + "platforms;android-${api}" \ + "${image}" | grep -v = || true + +echo "no" | + ./sdk/tools/bin/avdmanager create avd \ + --name "${1}" \ + --package "${image}" | grep -v = || true + diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/aarch64-linux-android/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/aarch64-linux-android/Dockerfile new file mode 100644 index 0000000..81c8208 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/aarch64-linux-android/Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + unzip \ + openjdk-8-jre \ + python \ + gcc \ + libc6-dev + +COPY android-ndk.sh / +RUN /android-ndk.sh arm64 +ENV PATH=$PATH:/android-toolchain/bin + +# TODO: run tests in an emulator eventually +ENV CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \ + CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER=echo diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/aarch64-unknown-linux-gnu/Dockerfile new file mode 100644 index 0000000..d691aa4 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + ca-certificates \ + libc6-dev \ + gcc-aarch64-linux-gnu \ + libc6-dev-arm64-cross \ + qemu-user + +ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/arm-linux-androideabi/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/arm-linux-androideabi/Dockerfile new file mode 100644 index 0000000..7cfdae6 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/arm-linux-androideabi/Dockerfile @@ -0,0 +1,37 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + unzip \ + openjdk-8-jre \ + python \ + gcc \ + libc6-dev + +COPY android-ndk.sh / +RUN /android-ndk.sh arm +WORKDIR /android +COPY android-sdk.sh /android/sdk.sh +RUN ./sdk.sh arm +RUN mv /root/.android /tmp +RUN chmod 777 -R /tmp/.android +RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/* +ENV PATH=$PATH:/android-toolchain/bin:/android/sdk/platform-tools + +# TODO: run tests in an emulator eventually +ENV CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \ + CARGO_TARGET_ARM_LINUX_ANDROIDEABI_RUNNER=/tmp/runtest \ + HOME=/tmp + +ADD runtest-android.rs /tmp/runtest.rs +ENTRYPOINT [ \ + "bash", \ + "-c", \ + # set SHELL so android can detect a 64bits system, see + # http://stackoverflow.com/a/41789144 + "SHELL=/bin/dash /android/sdk/emulator/emulator @arm -no-window & \ + /rust/bin/rustc /tmp/runtest.rs -o /tmp/runtest && \ + exec \"$@\"", \ + "--" \ +] diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile new file mode 100644 index 0000000..32095e9 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile @@ -0,0 +1,10 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + ca-certificates \ + libc6-dev \ + gcc-arm-linux-gnueabihf \ + libc6-dev-armhf-cross \ + qemu-user +ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ + CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/armv7-linux-androideabi/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/armv7-linux-androideabi/Dockerfile new file mode 100644 index 0000000..c738716 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/armv7-linux-androideabi/Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + unzip \ + openjdk-8-jre \ + python \ + gcc \ + libc6-dev + +COPY android-ndk.sh / +RUN /android-ndk.sh arm +ENV PATH=$PATH:/android-toolchain/bin + +# TODO: run tests in an emulator eventually +ENV CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \ + CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_RUNNER=echo diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile new file mode 100644 index 0000000..a55fb27 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile @@ -0,0 +1,10 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + ca-certificates \ + libc6-dev \ + gcc-arm-linux-gnueabihf \ + libc6-dev-armhf-cross \ + qemu-user +ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/i586-unknown-linux-gnu/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/i586-unknown-linux-gnu/Dockerfile new file mode 100644 index 0000000..d222092 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/i586-unknown-linux-gnu/Dockerfile @@ -0,0 +1,5 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc-multilib \ + libc6-dev \ + ca-certificates diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/i686-linux-android/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/i686-linux-android/Dockerfile new file mode 100644 index 0000000..ef4752c --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/i686-linux-android/Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + unzip \ + openjdk-8-jre \ + python \ + gcc \ + libc6-dev + +COPY android-ndk.sh / +RUN /android-ndk.sh x86 +ENV PATH=$PATH:/android-toolchain/bin + +# TODO: run tests in an emulator eventually +ENV CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \ + CARGO_TARGET_I686_LINUX_ANDROID_RUNNER=echo diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/i686-unknown-linux-gnu/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/i686-unknown-linux-gnu/Dockerfile new file mode 100644 index 0000000..d222092 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/i686-unknown-linux-gnu/Dockerfile @@ -0,0 +1,5 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc-multilib \ + libc6-dev \ + ca-certificates diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile new file mode 100644 index 0000000..b4f5d8a --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + ca-certificates \ + libc6-dev \ + gcc-powerpc64-linux-gnu \ + libc6-dev-ppc64-cross \ + qemu-user \ + qemu-system-ppc + +ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ + # TODO: should actually run these tests + #CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -L /usr/powerpc64-linux-gnu" \ + CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER=echo \ + CC=powerpc64-linux-gnu-gcc diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-linux-android/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-linux-android/Dockerfile new file mode 100644 index 0000000..7fea8a1 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-linux-android/Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + unzip \ + openjdk-8-jre \ + python \ + gcc \ + libc6-dev + +COPY android-ndk.sh / +RUN /android-ndk.sh x86_64 +ENV PATH=$PATH:/android-toolchain/bin + +# TODO: run tests in an emulator eventually +ENV CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-gcc \ + CARGO_TARGET_X86_64_LINUX_ANDROID_RUNNER=echo diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-pc-windows-gnu/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-pc-windows-gnu/Dockerfile new file mode 100644 index 0000000..7a8fbf4 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-pc-windows-gnu/Dockerfile @@ -0,0 +1,10 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + libc6-dev \ + ca-certificates \ + gcc-mingw-w64-x86-64 + +# No need to run tests, we're just testing that it compiles +ENV CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=echo \ + CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-unknown-linux-gnu/Dockerfile new file mode 100644 index 0000000..864d72e --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -0,0 +1,5 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + libc6-dev \ + ca-certificates diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-unknown-linux-musl/Dockerfile new file mode 100644 index 0000000..6984dc2 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -0,0 +1,6 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + libc6-dev \ + ca-certificates \ + musl-tools diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/run-docker.sh b/third_party/cargo/vendor/backtrace-0.3.42/ci/run-docker.sh new file mode 100755 index 0000000..5a9934b --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/run-docker.sh @@ -0,0 +1,32 @@ +# Small script to run tests for a target (or all targets) inside all the +# respective docker images. + +set -ex + +run() { + docker build -t backtrace -f ci/docker/$1/Dockerfile ci + mkdir -p target + docker run \ + --user `id -u`:`id -g` \ + --rm \ + --init \ + --volume $(dirname $(dirname `which cargo`)):/cargo \ + --env CARGO_HOME=/cargo \ + --volume `rustc --print sysroot`:/rust:ro \ + --env TARGET=$1 \ + --volume `pwd`:/checkout:ro \ + --volume `pwd`/target:/checkout/target \ + --workdir /checkout \ + --privileged \ + backtrace \ + bash \ + -c 'PATH=$PATH:/rust/bin exec ci/run.sh' +} + +if [ -z "$1" ]; then + for d in `ls ci/docker/`; do + run $d + done +else + run $1 +fi diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/run.sh b/third_party/cargo/vendor/backtrace-0.3.42/ci/run.sh new file mode 100755 index 0000000..5cc1515 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/run.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -ex + +cargo test --target $TARGET diff --git a/third_party/cargo/vendor/backtrace-0.3.42/ci/runtest-android.rs b/third_party/cargo/vendor/backtrace-0.3.42/ci/runtest-android.rs new file mode 100644 index 0000000..dc70121 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/ci/runtest-android.rs @@ -0,0 +1,50 @@ +use std::env; +use std::process::Command; +use std::path::{Path, PathBuf}; + +fn main() { + let args = env::args_os() + .skip(1) + .filter(|arg| arg != "--quiet") + .collect::>(); + assert_eq!(args.len(), 1); + let test = PathBuf::from(&args[0]); + let dst = Path::new("/data/local/tmp").join(test.file_name().unwrap()); + + println!("waiting for device to come online..."); + let status = Command::new("adb") + .arg("wait-for-device") + .status() + .expect("failed to run: adb wait-for-device"); + assert!(status.success()); + + println!("pushing executable..."); + let status = Command::new("adb") + .arg("push") + .arg(&test) + .arg(&dst) + .status() + .expect("failed to run: adb pushr"); + assert!(status.success()); + + println!("executing tests..."); + let output = Command::new("adb") + .arg("shell") + .arg(&dst) + .output() + .expect("failed to run: adb shell"); + assert!(status.success()); + + println!("status: {}\nstdout ---\n{}\nstderr ---\n{}", + output.status, + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr)); + + let stdout = String::from_utf8_lossy(&output.stdout); + stdout.lines().find(|l| + (l.starts_with("PASSED ") && l.contains(" tests")) || + l.starts_with("test result: ok") + ).unwrap_or_else(|| { + panic!("failed to find successful test run"); + }); +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/examples/backtrace.rs b/third_party/cargo/vendor/backtrace-0.3.42/examples/backtrace.rs new file mode 100644 index 0000000..7f9042e --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/examples/backtrace.rs @@ -0,0 +1,7 @@ +extern crate backtrace; + +use backtrace::Backtrace; + +fn main() { + println!("{:?}", Backtrace::new()); +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/examples/raw.rs b/third_party/cargo/vendor/backtrace-0.3.42/examples/raw.rs new file mode 100644 index 0000000..b43cab8 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/examples/raw.rs @@ -0,0 +1,54 @@ +extern crate backtrace; + +fn main() { + foo(); +} + +fn foo() { + bar() +} +fn bar() { + baz() +} +fn baz() { + print() +} + +#[cfg(target_pointer_width = "32")] +const HEX_WIDTH: usize = 10; +#[cfg(target_pointer_width = "64")] +const HEX_WIDTH: usize = 20; + +fn print() { + let mut cnt = 0; + backtrace::trace(|frame| { + let ip = frame.ip(); + print!("frame #{:<2} - {:#02$x}", cnt, ip as usize, HEX_WIDTH); + cnt += 1; + + let mut resolved = false; + backtrace::resolve(frame.ip(), |symbol| { + if !resolved { + resolved = true; + } else { + print!("{}", vec![" "; 7 + 2 + 3 + HEX_WIDTH].join("")); + } + + if let Some(name) = symbol.name() { + print!(" - {}", name); + } else { + print!(" - "); + } + if let Some(file) = symbol.filename() { + if let Some(l) = symbol.lineno() { + print!("\n{:13}{:4$}@ {}:{}", "", "", file.display(), l, HEX_WIDTH); + } + } + println!(""); + }); + if !resolved { + println!(" - "); + } + true // keep going + }); +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/dbghelp.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/dbghelp.rs new file mode 100644 index 0000000..40de143 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/dbghelp.rs @@ -0,0 +1,233 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Backtrace strategy for MSVC platforms. +//! +//! This module contains the ability to generate a backtrace on MSVC using one +//! of two possible methods. The `StackWalkEx` function is primarily used if +//! possible, but not all systems have that. Failing that the `StackWalk64` +//! function is used instead. Note that `StackWalkEx` is favored because it +//! handles debuginfo internally and returns inline frame information. +//! +//! Note that all dbghelp support is loaded dynamically, see `src/dbghelp.rs` +//! for more information about that. + +#![allow(bad_style)] + +use crate::dbghelp; +use crate::windows::*; +use core::ffi::c_void; +use core::mem; + +#[derive(Clone, Copy)] +pub enum Frame { + New(STACKFRAME_EX), + Old(STACKFRAME64), +} + +// we're just sending around raw pointers and reading them, never interpreting +// them so this should be safe to both send and share across threads. +unsafe impl Send for Frame {} +unsafe impl Sync for Frame {} + +impl Frame { + pub fn ip(&self) -> *mut c_void { + self.addr_pc().Offset as *mut _ + } + + pub fn symbol_address(&self) -> *mut c_void { + self.ip() + } + + fn addr_pc(&self) -> &ADDRESS64 { + match self { + Frame::New(new) => &new.AddrPC, + Frame::Old(old) => &old.AddrPC, + } + } + + fn addr_pc_mut(&mut self) -> &mut ADDRESS64 { + match self { + Frame::New(new) => &mut new.AddrPC, + Frame::Old(old) => &mut old.AddrPC, + } + } + + fn addr_frame_mut(&mut self) -> &mut ADDRESS64 { + match self { + Frame::New(new) => &mut new.AddrFrame, + Frame::Old(old) => &mut old.AddrFrame, + } + } + + fn addr_stack_mut(&mut self) -> &mut ADDRESS64 { + match self { + Frame::New(new) => &mut new.AddrStack, + Frame::Old(old) => &mut old.AddrStack, + } + } +} + +#[repr(C, align(16))] // required by `CONTEXT`, is a FIXME in winapi right now +struct MyContext(CONTEXT); + +#[inline(always)] +pub unsafe fn trace(cb: &mut FnMut(&super::Frame) -> bool) { + // Allocate necessary structures for doing the stack walk + let process = GetCurrentProcess(); + let thread = GetCurrentThread(); + + let mut context = mem::zeroed::(); + RtlCaptureContext(&mut context.0); + + // Ensure this process's symbols are initialized + let dbghelp = match dbghelp::init() { + Ok(dbghelp) => dbghelp, + Err(()) => return, // oh well... + }; + + // On x86_64 and ARM64 we opt to not use the default `Sym*` functions from + // dbghelp for getting the function table and module base. Instead we use + // the `RtlLookupFunctionEntry` function in kernel32 which will account for + // JIT compiler frames as well. These should be equivalent, but using + // `Rtl*` allows us to backtrace through JIT frames. + // + // Note that `RtlLookupFunctionEntry` only works for in-process backtraces, + // but that's all we support anyway, so it all lines up well. + cfg_if::cfg_if! { + if #[cfg(target_pointer_width = "64")] { + use core::ptr; + + unsafe extern "system" fn function_table_access(_process: HANDLE, addr: DWORD64) -> PVOID { + let mut base = 0; + RtlLookupFunctionEntry(addr, &mut base, ptr::null_mut()).cast() + } + + unsafe extern "system" fn get_module_base(_process: HANDLE, addr: DWORD64) -> DWORD64 { + let mut base = 0; + RtlLookupFunctionEntry(addr, &mut base, ptr::null_mut()); + base + } + } else { + let function_table_access = dbghelp.SymFunctionTableAccess64(); + let get_module_base = dbghelp.SymGetModuleBase64(); + } + } + + // Attempt to use `StackWalkEx` if we can, but fall back to `StackWalk64` + // since it's in theory supported on more systems. + match (*dbghelp.dbghelp()).StackWalkEx() { + Some(StackWalkEx) => { + let mut frame = super::Frame { + inner: Frame::New(mem::zeroed()), + }; + let image = init_frame(&mut frame.inner, &context.0); + let frame_ptr = match &mut frame.inner { + Frame::New(ptr) => ptr as *mut STACKFRAME_EX, + _ => unreachable!(), + }; + + while StackWalkEx( + image as DWORD, + process, + thread, + frame_ptr, + &mut context.0 as *mut CONTEXT as *mut _, + None, + Some(function_table_access), + Some(get_module_base), + None, + 0, + ) == TRUE + { + if !cb(&frame) { + break; + } + } + } + None => { + let mut frame = super::Frame { + inner: Frame::Old(mem::zeroed()), + }; + let image = init_frame(&mut frame.inner, &context.0); + let frame_ptr = match &mut frame.inner { + Frame::Old(ptr) => ptr as *mut STACKFRAME64, + _ => unreachable!(), + }; + + while dbghelp.StackWalk64()( + image as DWORD, + process, + thread, + frame_ptr, + &mut context.0 as *mut CONTEXT as *mut _, + None, + Some(function_table_access), + Some(get_module_base), + None, + ) == TRUE + { + if !cb(&frame) { + break; + } + } + } + } +} + +#[cfg(target_arch = "x86_64")] +fn init_frame(frame: &mut Frame, ctx: &CONTEXT) -> WORD { + frame.addr_pc_mut().Offset = ctx.Rip as u64; + frame.addr_pc_mut().Mode = AddrModeFlat; + frame.addr_stack_mut().Offset = ctx.Rsp as u64; + frame.addr_stack_mut().Mode = AddrModeFlat; + frame.addr_frame_mut().Offset = ctx.Rbp as u64; + frame.addr_frame_mut().Mode = AddrModeFlat; + + IMAGE_FILE_MACHINE_AMD64 +} + +#[cfg(target_arch = "x86")] +fn init_frame(frame: &mut Frame, ctx: &CONTEXT) -> WORD { + frame.addr_pc_mut().Offset = ctx.Eip as u64; + frame.addr_pc_mut().Mode = AddrModeFlat; + frame.addr_stack_mut().Offset = ctx.Esp as u64; + frame.addr_stack_mut().Mode = AddrModeFlat; + frame.addr_frame_mut().Offset = ctx.Ebp as u64; + frame.addr_frame_mut().Mode = AddrModeFlat; + + IMAGE_FILE_MACHINE_I386 +} + +#[cfg(target_arch = "aarch64")] +fn init_frame(frame: &mut Frame, ctx: &CONTEXT) -> WORD { + frame.addr_pc_mut().Offset = ctx.Pc as u64; + frame.addr_pc_mut().Mode = AddrModeFlat; + frame.addr_stack_mut().Offset = ctx.Sp as u64; + frame.addr_stack_mut().Mode = AddrModeFlat; + unsafe { + frame.addr_frame_mut().Offset = ctx.u.s().Fp as u64; + } + frame.addr_frame_mut().Mode = AddrModeFlat; + IMAGE_FILE_MACHINE_ARM64 +} + +#[cfg(target_arch = "arm")] +fn init_frame(frame: &mut Frame, ctx: &CONTEXT) -> WORD { + frame.addr_pc_mut().Offset = ctx.Pc as u64; + frame.addr_pc_mut().Mode = AddrModeFlat; + frame.addr_stack_mut().Offset = ctx.Sp as u64; + frame.addr_stack_mut().Mode = AddrModeFlat; + unsafe { + frame.addr_frame_mut().Offset = ctx.R11 as u64; + } + frame.addr_frame_mut().Mode = AddrModeFlat; + IMAGE_FILE_MACHINE_ARMNT +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/libunwind.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/libunwind.rs new file mode 100644 index 0000000..21af00c --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/libunwind.rs @@ -0,0 +1,231 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Backtrace support using libunwind/gcc_s/etc APIs. +//! +//! This module contains the ability to unwind the stack using libunwind-style +//! APIs. Note that there's a whole bunch of implementations of the +//! libunwind-like API, and this is just trying to be compatible with most of +//! them all at once instead of being picky. +//! +//! The libunwind API is powered by `_Unwind_Backtrace` and is in practice very +//! reliable at generating a backtrace. It's not entirely clear how it does it +//! (frame pointers? eh_frame info? both?) but it seems to work! +//! +//! Most of the complexity of this module is handling the various platform +//! differences across libunwind implementations. Otherwise this is a pretty +//! straightforward Rust binding to the libunwind APIs. +//! +//! This is the default unwinding API for all non-Windows platforms currently. + +use core::ffi::c_void; + +pub enum Frame { + Raw(*mut uw::_Unwind_Context), + Cloned { + ip: *mut c_void, + symbol_address: *mut c_void, + }, +} + +// With a raw libunwind pointer it should only ever be access in a readonly +// threadsafe fashion, so it's `Sync`. When sending to other threads via `Clone` +// we always switch to a version which doesn't retain interior pointers, so we +// should be `Send` as well. +unsafe impl Send for Frame {} +unsafe impl Sync for Frame {} + +impl Frame { + pub fn ip(&self) -> *mut c_void { + let ctx = match *self { + Frame::Raw(ctx) => ctx, + Frame::Cloned { ip, .. } => return ip, + }; + unsafe { uw::_Unwind_GetIP(ctx) as *mut c_void } + } + + pub fn symbol_address(&self) -> *mut c_void { + if let Frame::Cloned { symbol_address, .. } = *self { + return symbol_address; + } + + // It seems that on OSX `_Unwind_FindEnclosingFunction` returns a + // pointer to... something that's unclear. It's definitely not always + // the enclosing function for whatever reason. It's not entirely clear + // to me what's going on here, so pessimize this for now and just always + // return the ip. + // + // Note the `skip_inner_frames.rs` test is skipped on OSX due to this + // clause, and if this is fixed that test in theory can be run on OSX! + if cfg!(target_os = "macos") || cfg!(target_os = "ios") { + self.ip() + } else { + unsafe { uw::_Unwind_FindEnclosingFunction(self.ip()) } + } + } +} + +impl Clone for Frame { + fn clone(&self) -> Frame { + Frame::Cloned { + ip: self.ip(), + symbol_address: self.symbol_address(), + } + } +} + +#[inline(always)] +pub unsafe fn trace(mut cb: &mut FnMut(&super::Frame) -> bool) { + uw::_Unwind_Backtrace(trace_fn, &mut cb as *mut _ as *mut _); + + extern "C" fn trace_fn( + ctx: *mut uw::_Unwind_Context, + arg: *mut c_void, + ) -> uw::_Unwind_Reason_Code { + let cb = unsafe { &mut *(arg as *mut &mut FnMut(&super::Frame) -> bool) }; + let cx = super::Frame { + inner: Frame::Raw(ctx), + }; + + let mut bomb = crate::Bomb { enabled: true }; + let keep_going = cb(&cx); + bomb.enabled = false; + + if keep_going { + uw::_URC_NO_REASON + } else { + uw::_URC_FAILURE + } + } +} + +/// Unwind library interface used for backtraces +/// +/// Note that dead code is allowed as here are just bindings +/// iOS doesn't use all of them it but adding more +/// platform-specific configs pollutes the code too much +#[allow(non_camel_case_types)] +#[allow(non_snake_case)] +#[allow(dead_code)] +mod uw { + pub use self::_Unwind_Reason_Code::*; + + use core::ffi::c_void; + + #[repr(C)] + pub enum _Unwind_Reason_Code { + _URC_NO_REASON = 0, + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8, + _URC_FAILURE = 9, // used only by ARM EABI + } + + pub enum _Unwind_Context {} + + pub type _Unwind_Trace_Fn = + extern "C" fn(ctx: *mut _Unwind_Context, arg: *mut c_void) -> _Unwind_Reason_Code; + + extern "C" { + // No native _Unwind_Backtrace on iOS + #[cfg(not(all(target_os = "ios", target_arch = "arm")))] + pub fn _Unwind_Backtrace( + trace: _Unwind_Trace_Fn, + trace_argument: *mut c_void, + ) -> _Unwind_Reason_Code; + + // available since GCC 4.2.0, should be fine for our purpose + #[cfg(all( + not(all(target_os = "android", target_arch = "arm")), + not(all(target_os = "freebsd", target_arch = "arm")), + not(all(target_os = "linux", target_arch = "arm")) + ))] + pub fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t; + + #[cfg(all( + not(target_os = "android"), + not(all(target_os = "freebsd", target_arch = "arm")), + not(all(target_os = "linux", target_arch = "arm")) + ))] + pub fn _Unwind_FindEnclosingFunction(pc: *mut c_void) -> *mut c_void; + } + + // On android, the function _Unwind_GetIP is a macro, and this is the + // expansion of the macro. This is all copy/pasted directly from the + // header file with the definition of _Unwind_GetIP. + #[cfg(any( + all(target_os = "android", target_arch = "arm"), + all(target_os = "freebsd", target_arch = "arm"), + all(target_os = "linux", target_arch = "arm") + ))] + pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t { + #[repr(C)] + enum _Unwind_VRS_Result { + _UVRSR_OK = 0, + _UVRSR_NOT_IMPLEMENTED = 1, + _UVRSR_FAILED = 2, + } + #[repr(C)] + enum _Unwind_VRS_RegClass { + _UVRSC_CORE = 0, + _UVRSC_VFP = 1, + _UVRSC_FPA = 2, + _UVRSC_WMMXD = 3, + _UVRSC_WMMXC = 4, + } + #[repr(C)] + enum _Unwind_VRS_DataRepresentation { + _UVRSD_UINT32 = 0, + _UVRSD_VFPX = 1, + _UVRSD_FPAX = 2, + _UVRSD_UINT64 = 3, + _UVRSD_FLOAT = 4, + _UVRSD_DOUBLE = 5, + } + + type _Unwind_Word = libc::c_uint; + extern "C" { + fn _Unwind_VRS_Get( + ctx: *mut _Unwind_Context, + klass: _Unwind_VRS_RegClass, + word: _Unwind_Word, + repr: _Unwind_VRS_DataRepresentation, + data: *mut c_void, + ) -> _Unwind_VRS_Result; + } + + let mut val: _Unwind_Word = 0; + let ptr = &mut val as *mut _Unwind_Word; + let _ = _Unwind_VRS_Get( + ctx, + _Unwind_VRS_RegClass::_UVRSC_CORE, + 15, + _Unwind_VRS_DataRepresentation::_UVRSD_UINT32, + ptr as *mut c_void, + ); + (val & !1) as libc::uintptr_t + } + + // This function also doesn't exist on Android or ARM/Linux, so make it + // a no-op + #[cfg(any( + target_os = "android", + all(target_os = "freebsd", target_arch = "arm"), + all(target_os = "linux", target_arch = "arm") + ))] + pub unsafe fn _Unwind_FindEnclosingFunction(pc: *mut c_void) -> *mut c_void { + pc + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/mod.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/mod.rs new file mode 100644 index 0000000..204974e --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/mod.rs @@ -0,0 +1,152 @@ +use core::ffi::c_void; +use core::fmt; + +/// Inspects the current call-stack, passing all active frames into the closure +/// provided to calculate a stack trace. +/// +/// This function is the workhorse of this library in calculating the stack +/// traces for a program. The given closure `cb` is yielded instances of a +/// `Frame` which represent information about that call frame on the stack. The +/// closure is yielded frames in a top-down fashion (most recently called +/// functions first). +/// +/// The closure's return value is an indication of whether the backtrace should +/// continue. A return value of `false` will terminate the backtrace and return +/// immediately. +/// +/// Once a `Frame` is acquired you will likely want to call `backtrace::resolve` +/// to convert the `ip` (instruction pointer) or symbol address to a `Symbol` +/// through which the name and/or filename/line number can be learned. +/// +/// Note that this is a relatively low-level function and if you'd like to, for +/// example, capture a backtrace to be inspected later, then the `Backtrace` +/// type may be more appropriate. +/// +/// # Required features +/// +/// This function requires the `std` feature of the `backtrace` crate to be +/// enabled, and the `std` feature is enabled by default. +/// +/// # Panics +/// +/// This function strives to never panic, but if the `cb` provided panics then +/// some platforms will force a double panic to abort the process. Some +/// platforms use a C library which internally uses callbacks which cannot be +/// unwound through, so panicking from `cb` may trigger a process abort. +/// +/// # Example +/// +/// ``` +/// extern crate backtrace; +/// +/// fn main() { +/// backtrace::trace(|frame| { +/// // ... +/// +/// true // continue the backtrace +/// }); +/// } +/// ``` +#[cfg(feature = "std")] +pub fn trace bool>(cb: F) { + let _guard = crate::lock::lock(); + unsafe { trace_unsynchronized(cb) } +} + +/// Same as `trace`, only unsafe as it's unsynchronized. +/// +/// This function does not have synchronization guarentees but is available +/// when the `std` feature of this crate isn't compiled in. See the `trace` +/// function for more documentation and examples. +/// +/// # Panics +/// +/// See information on `trace` for caveats on `cb` panicking. +pub unsafe fn trace_unsynchronized bool>(mut cb: F) { + trace_imp(&mut cb) +} + +/// A trait representing one frame of a backtrace, yielded to the `trace` +/// function of this crate. +/// +/// The tracing function's closure will be yielded frames, and the frame is +/// virtually dispatched as the underlying implementation is not always known +/// until runtime. +#[derive(Clone)] +pub struct Frame { + pub(crate) inner: FrameImp, +} + +impl Frame { + /// Returns the current instruction pointer of this frame. + /// + /// This is normally the next instruction to execute in the frame, but not + /// all implementations list this with 100% accuracy (but it's generally + /// pretty close). + /// + /// It is recommended to pass this value to `backtrace::resolve` to turn it + /// into a symbol name. + pub fn ip(&self) -> *mut c_void { + self.inner.ip() + } + + /// Returns the starting symbol address of the frame of this function. + /// + /// This will attempt to rewind the instruction pointer returned by `ip` to + /// the start of the function, returning that value. In some cases, however, + /// backends will just return `ip` from this function. + /// + /// The returned value can sometimes be used if `backtrace::resolve` failed + /// on the `ip` given above. + pub fn symbol_address(&self) -> *mut c_void { + self.inner.symbol_address() + } +} + +impl fmt::Debug for Frame { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Frame") + .field("ip", &self.ip()) + .field("symbol_address", &self.symbol_address()) + .finish() + } +} + +cfg_if::cfg_if! { + if #[cfg( + any( + all( + unix, + not(target_os = "emscripten"), + not(all(target_os = "ios", target_arch = "arm")), + feature = "libunwind", + ), + all( + target_env = "sgx", + target_vendor = "fortanix", + ), + ) + )] { + mod libunwind; + use self::libunwind::trace as trace_imp; + pub(crate) use self::libunwind::Frame as FrameImp; + } else if #[cfg( + all( + unix, + not(target_os = "emscripten"), + feature = "unix-backtrace", + ) + )] { + mod unix_backtrace; + use self::unix_backtrace::trace as trace_imp; + pub(crate) use self::unix_backtrace::Frame as FrameImp; + } else if #[cfg(all(windows, feature = "dbghelp", not(target_vendor = "uwp")))] { + mod dbghelp; + use self::dbghelp::trace as trace_imp; + pub(crate) use self::dbghelp::Frame as FrameImp; + } else { + mod noop; + use self::noop::trace as trace_imp; + pub(crate) use self::noop::Frame as FrameImp; + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/noop.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/noop.rs new file mode 100644 index 0000000..bc2eb0d --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/noop.rs @@ -0,0 +1,20 @@ +//! Empty implementation of unwinding used when no other implementation is +//! appropriate. + +use core::ffi::c_void; + +#[inline(always)] +pub fn trace(_cb: &mut FnMut(&super::Frame) -> bool) {} + +#[derive(Clone)] +pub struct Frame; + +impl Frame { + pub fn ip(&self) -> *mut c_void { + 0 as *mut _ + } + + pub fn symbol_address(&self) -> *mut c_void { + 0 as *mut _ + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/unix_backtrace.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/unix_backtrace.rs new file mode 100644 index 0000000..7e3375a --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/backtrace/unix_backtrace.rs @@ -0,0 +1,61 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Unwinding through the `backtrace` function provided in Unix. +//! +//! This is an alternative unwinding strategy for Unix platforms which don't +//! have support for libunwind but do have support for `backtrace`. Currently +//! there's not a whole lot of those though. This module is a relatively +//! straightforward binding of the `backtrace` API to the `Frame` API that we'd +//! like to have. + +use core::ffi::c_void; +use core::mem; +use libc::c_int; + +#[derive(Clone)] +pub struct Frame { + addr: usize, +} + +impl Frame { + pub fn ip(&self) -> *mut c_void { + self.addr as *mut c_void + } + pub fn symbol_address(&self) -> *mut c_void { + self.ip() + } +} + +extern "C" { + fn backtrace(buf: *mut *mut c_void, sz: c_int) -> c_int; +} + +#[inline(always)] +pub unsafe fn trace(cb: &mut FnMut(&super::Frame) -> bool) { + const SIZE: usize = 100; + + let mut buf: [*mut c_void; SIZE]; + let cnt; + + buf = mem::zeroed(); + cnt = backtrace(buf.as_mut_ptr(), SIZE as c_int); + + for addr in buf[..cnt as usize].iter() { + let cx = super::Frame { + inner: Frame { + addr: *addr as usize, + }, + }; + if !cb(&cx) { + return; + } + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/capture.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/capture.rs new file mode 100644 index 0000000..7b37bd1 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/capture.rs @@ -0,0 +1,479 @@ +use crate::PrintFmt; +use crate::{resolve, resolve_frame, trace, BacktraceFmt, Symbol, SymbolName}; +use std::ffi::c_void; +use std::fmt; +use std::path::{Path, PathBuf}; +use std::prelude::v1::*; + +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + +/// Representation of an owned and self-contained backtrace. +/// +/// This structure can be used to capture a backtrace at various points in a +/// program and later used to inspect what the backtrace was at that time. +/// +/// `Backtrace` supports pretty-printing of backtraces through its `Debug` +/// implementation. +/// +/// # Required features +/// +/// This function requires the `std` feature of the `backtrace` crate to be +/// enabled, and the `std` feature is enabled by default. +#[derive(Clone)] +#[cfg_attr(feature = "serialize-rustc", derive(RustcDecodable, RustcEncodable))] +#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] +pub struct Backtrace { + // Frames here are listed from top-to-bottom of the stack + frames: Vec, + // The index we believe is the actual start of the backtrace, omitting + // frames like `Backtrace::new` and `backtrace::trace`. + actual_start_index: usize, +} + +fn _assert_send_sync() { + fn _assert() {} + _assert::(); +} + +/// Captured version of a frame in a backtrace. +/// +/// This type is returned as a list from `Backtrace::frames` and represents one +/// stack frame in a captured backtrace. +/// +/// # Required features +/// +/// This function requires the `std` feature of the `backtrace` crate to be +/// enabled, and the `std` feature is enabled by default. +#[derive(Clone)] +pub struct BacktraceFrame { + frame: Frame, + symbols: Option>, +} + +#[derive(Clone)] +enum Frame { + Raw(crate::Frame), + #[allow(dead_code)] + Deserialized { + ip: usize, + symbol_address: usize, + }, +} + +impl Frame { + fn ip(&self) -> *mut c_void { + match *self { + Frame::Raw(ref f) => f.ip(), + Frame::Deserialized { ip, .. } => ip as *mut c_void, + } + } + + fn symbol_address(&self) -> *mut c_void { + match *self { + Frame::Raw(ref f) => f.symbol_address(), + Frame::Deserialized { symbol_address, .. } => symbol_address as *mut c_void, + } + } +} + +/// Captured version of a symbol in a backtrace. +/// +/// This type is returned as a list from `BacktraceFrame::symbols` and +/// represents the metadata for a symbol in a backtrace. +/// +/// # Required features +/// +/// This function requires the `std` feature of the `backtrace` crate to be +/// enabled, and the `std` feature is enabled by default. +#[derive(Clone)] +#[cfg_attr(feature = "serialize-rustc", derive(RustcDecodable, RustcEncodable))] +#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] +pub struct BacktraceSymbol { + name: Option>, + addr: Option, + filename: Option, + lineno: Option, +} + +impl Backtrace { + /// Captures a backtrace at the callsite of this function, returning an + /// owned representation. + /// + /// This function is useful for representing a backtrace as an object in + /// Rust. This returned value can be sent across threads and printed + /// elsewhere, and the purpose of this value is to be entirely self + /// contained. + /// + /// Note that on some platforms acquiring a full backtrace and resolving it + /// can be extremely expensive. If the cost is too much for your application + /// it's recommended to instead use `Backtrace::new_unresolved()` which + /// avoids the symbol resolution step (which typically takes the longest) + /// and allows deferring that to a later date. + /// + /// # Examples + /// + /// ``` + /// use backtrace::Backtrace; + /// + /// let current_backtrace = Backtrace::new(); + /// ``` + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + #[inline(never)] // want to make sure there's a frame here to remove + pub fn new() -> Backtrace { + let mut bt = Self::create(Self::new as usize); + bt.resolve(); + bt + } + + /// Similar to `new` except that this does not resolve any symbols, this + /// simply captures the backtrace as a list of addresses. + /// + /// At a later time the `resolve` function can be called to resolve this + /// backtrace's symbols into readable names. This function exists because + /// the resolution process can sometimes take a significant amount of time + /// whereas any one backtrace may only be rarely printed. + /// + /// # Examples + /// + /// ``` + /// use backtrace::Backtrace; + /// + /// let mut current_backtrace = Backtrace::new_unresolved(); + /// println!("{:?}", current_backtrace); // no symbol names + /// current_backtrace.resolve(); + /// println!("{:?}", current_backtrace); // symbol names now present + /// ``` + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + #[inline(never)] // want to make sure there's a frame here to remove + pub fn new_unresolved() -> Backtrace { + Self::create(Self::new_unresolved as usize) + } + + fn create(ip: usize) -> Backtrace { + let mut frames = Vec::new(); + let mut actual_start_index = None; + trace(|frame| { + frames.push(BacktraceFrame { + frame: Frame::Raw(frame.clone()), + symbols: None, + }); + + if frame.symbol_address() as usize == ip && actual_start_index.is_none() { + actual_start_index = Some(frames.len()); + } + true + }); + + Backtrace { + frames, + actual_start_index: actual_start_index.unwrap_or(0), + } + } + + /// Returns the frames from when this backtrace was captured. + /// + /// The first entry of this slice is likely the function `Backtrace::new`, + /// and the last frame is likely something about how this thread or the main + /// function started. + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn frames(&self) -> &[BacktraceFrame] { + &self.frames[self.actual_start_index..] + } + + /// If this backtrace was created from `new_unresolved` then this function + /// will resolve all addresses in the backtrace to their symbolic names. + /// + /// If this backtrace has been previously resolved or was created through + /// `new`, this function does nothing. + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn resolve(&mut self) { + for frame in self.frames.iter_mut().filter(|f| f.symbols.is_none()) { + let mut symbols = Vec::new(); + { + let sym = |symbol: &Symbol| { + symbols.push(BacktraceSymbol { + name: symbol.name().map(|m| m.as_bytes().to_vec()), + addr: symbol.addr().map(|a| a as usize), + filename: symbol.filename().map(|m| m.to_owned()), + lineno: symbol.lineno(), + }); + }; + match frame.frame { + Frame::Raw(ref f) => resolve_frame(f, sym), + Frame::Deserialized { ip, .. } => { + resolve(ip as *mut c_void, sym); + } + } + } + frame.symbols = Some(symbols); + } + } +} + +impl From> for Backtrace { + fn from(frames: Vec) -> Self { + Backtrace { + frames, + actual_start_index: 0, + } + } +} + +impl Into> for Backtrace { + fn into(self) -> Vec { + self.frames + } +} + +impl BacktraceFrame { + /// Same as `Frame::ip` + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn ip(&self) -> *mut c_void { + self.frame.ip() as *mut c_void + } + + /// Same as `Frame::symbol_address` + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn symbol_address(&self) -> *mut c_void { + self.frame.symbol_address() as *mut c_void + } + + /// Returns the list of symbols that this frame corresponds to. + /// + /// Normally there is only one symbol per frame, but sometimes if a number + /// of functions are inlined into one frame then multiple symbols will be + /// returned. The first symbol listed is the "innermost function", whereas + /// the last symbol is the outermost (last caller). + /// + /// Note that if this frame came from an unresolved backtrace then this will + /// return an empty list. + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn symbols(&self) -> &[BacktraceSymbol] { + self.symbols.as_ref().map(|s| &s[..]).unwrap_or(&[]) + } +} + +impl BacktraceSymbol { + /// Same as `Symbol::name` + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn name(&self) -> Option { + self.name.as_ref().map(|s| SymbolName::new(s)) + } + + /// Same as `Symbol::addr` + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn addr(&self) -> Option<*mut c_void> { + self.addr.map(|s| s as *mut c_void) + } + + /// Same as `Symbol::filename` + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn filename(&self) -> Option<&Path> { + self.filename.as_ref().map(|p| &**p) + } + + /// Same as `Symbol::lineno` + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn lineno(&self) -> Option { + self.lineno + } +} + +impl fmt::Debug for Backtrace { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let full = fmt.alternate(); + let (frames, style) = if full { + (&self.frames[..], PrintFmt::Full) + } else { + (&self.frames[self.actual_start_index..], PrintFmt::Short) + }; + + // When printing paths we try to strip the cwd if it exists, otherwise + // we just print the path as-is. Note that we also only do this for the + // short format, because if it's full we presumably want to print + // everything. + let cwd = std::env::current_dir(); + let mut print_path = move |fmt: &mut fmt::Formatter, path: crate::BytesOrWideString| { + let path = path.into_path_buf(); + if !full { + if let Ok(cwd) = &cwd { + if let Ok(suffix) = path.strip_prefix(cwd) { + return fmt::Display::fmt(&suffix.display(), fmt); + } + } + } + fmt::Display::fmt(&path.display(), fmt) + }; + + let mut f = BacktraceFmt::new(fmt, style, &mut print_path); + f.add_context()?; + for frame in frames { + f.frame().backtrace_frame(frame)?; + } + f.finish()?; + Ok(()) + } +} + +impl Default for Backtrace { + fn default() -> Backtrace { + Backtrace::new() + } +} + +impl fmt::Debug for BacktraceFrame { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BacktraceFrame") + .field("ip", &self.ip()) + .field("symbol_address", &self.symbol_address()) + .finish() + } +} + +impl fmt::Debug for BacktraceSymbol { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BacktraceSymbol") + .field("name", &self.name()) + .field("addr", &self.addr()) + .field("filename", &self.filename()) + .field("lineno", &self.lineno()) + .finish() + } +} + +#[cfg(feature = "serialize-rustc")] +mod rustc_serialize_impls { + use super::*; + use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; + + #[derive(RustcEncodable, RustcDecodable)] + struct SerializedFrame { + ip: usize, + symbol_address: usize, + symbols: Option>, + } + + impl Decodable for BacktraceFrame { + fn decode(d: &mut D) -> Result + where + D: Decoder, + { + let frame: SerializedFrame = SerializedFrame::decode(d)?; + Ok(BacktraceFrame { + frame: Frame::Deserialized { + ip: frame.ip, + symbol_address: frame.symbol_address, + }, + symbols: frame.symbols, + }) + } + } + + impl Encodable for BacktraceFrame { + fn encode(&self, e: &mut E) -> Result<(), E::Error> + where + E: Encoder, + { + let BacktraceFrame { frame, symbols } = self; + SerializedFrame { + ip: frame.ip() as usize, + symbol_address: frame.symbol_address() as usize, + symbols: symbols.clone(), + } + .encode(e) + } + } +} + +#[cfg(feature = "serde")] +mod serde_impls { + extern crate serde; + + use self::serde::de::Deserializer; + use self::serde::ser::Serializer; + use self::serde::{Deserialize, Serialize}; + use super::*; + + #[derive(Serialize, Deserialize)] + struct SerializedFrame { + ip: usize, + symbol_address: usize, + symbols: Option>, + } + + impl Serialize for BacktraceFrame { + fn serialize(&self, s: S) -> Result + where + S: Serializer, + { + let BacktraceFrame { frame, symbols } = self; + SerializedFrame { + ip: frame.ip() as usize, + symbol_address: frame.symbol_address() as usize, + symbols: symbols.clone(), + } + .serialize(s) + } + } + + impl<'a> Deserialize<'a> for BacktraceFrame { + fn deserialize(d: D) -> Result + where + D: Deserializer<'a>, + { + let frame: SerializedFrame = SerializedFrame::deserialize(d)?; + Ok(BacktraceFrame { + frame: Frame::Deserialized { + ip: frame.ip, + symbol_address: frame.symbol_address, + }, + symbols: frame.symbols, + }) + } + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/dbghelp.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/dbghelp.rs new file mode 100644 index 0000000..05ffef2 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/dbghelp.rs @@ -0,0 +1,370 @@ +//! A module to assist in managing dbghelp bindings on Windows +//! +//! Backtraces on Windows (at least for MSVC) are largely powered through +//! `dbghelp.dll` and the various functions that it contains. These functions +//! are currently loaded *dynamically* rather than linking to `dbghelp.dll` +//! statically. This is currently done by the standard library (and is in theory +//! required there), but is an effort to help reduce the static dll dependencies +//! of a library since backtraces are typically pretty optional. That being +//! said, `dbghelp.dll` almost always successfully loads on Windows. +//! +//! Note though that since we're loading all this support dynamically we can't +//! actually use the raw definitions in `winapi`, but rather we need to define +//! the function pointer types ourselves and use that. We don't really want to +//! be in the business of duplicating winapi, so we have a Cargo feature +//! `verify-winapi` which asserts that all bindings match those in winapi and +//! this feature is enabled on CI. +//! +//! Finally, you'll note here that the dll for `dbghelp.dll` is never unloaded, +//! and that's currently intentional. The thinking is that we can globally cache +//! it and use it between calls to the API, avoiding expensive loads/unloads. If +//! this is a problem for leak detectors or something like that we can cross the +//! bridge when we get there. + +#![allow(non_snake_case)] + +use crate::windows::*; +use core::mem; +use core::ptr; + +// Work around `SymGetOptions` and `SymSetOptions` not being present in winapi +// itself. Otherwise this is only used when we're double-checking types against +// winapi. +#[cfg(feature = "verify-winapi")] +mod dbghelp { + use crate::windows::*; + pub use winapi::um::dbghelp::{ + StackWalk64, SymCleanup, SymFromAddrW, SymFunctionTableAccess64, SymGetLineFromAddrW64, + SymGetModuleBase64, SymInitializeW, + }; + + extern "system" { + // Not defined in winapi yet + pub fn SymGetOptions() -> u32; + pub fn SymSetOptions(_: u32); + + // This is defined in winapi, but it's incorrect (FIXME winapi-rs#768) + pub fn StackWalkEx( + MachineType: DWORD, + hProcess: HANDLE, + hThread: HANDLE, + StackFrame: LPSTACKFRAME_EX, + ContextRecord: PVOID, + ReadMemoryRoutine: PREAD_PROCESS_MEMORY_ROUTINE64, + FunctionTableAccessRoutine: PFUNCTION_TABLE_ACCESS_ROUTINE64, + GetModuleBaseRoutine: PGET_MODULE_BASE_ROUTINE64, + TranslateAddress: PTRANSLATE_ADDRESS_ROUTINE64, + Flags: DWORD, + ) -> BOOL; + + // Not defined in winapi yet + pub fn SymFromInlineContextW( + hProcess: HANDLE, + Address: DWORD64, + InlineContext: ULONG, + Displacement: PDWORD64, + Symbol: PSYMBOL_INFOW, + ) -> BOOL; + pub fn SymGetLineFromInlineContextW( + hProcess: HANDLE, + dwAddr: DWORD64, + InlineContext: ULONG, + qwModuleBaseAddress: DWORD64, + pdwDisplacement: PDWORD, + Line: PIMAGEHLP_LINEW64, + ) -> BOOL; + } + + pub fn assert_equal_types(a: T, _b: T) -> T { + a + } +} + +// This macro is used to define a `Dbghelp` structure which internally contains +// all the function pointers that we might load. +macro_rules! dbghelp { + (extern "system" { + $(fn $name:ident($($arg:ident: $argty:ty),*) -> $ret: ty;)* + }) => ( + pub struct Dbghelp { + /// The loaded DLL for `dbghelp.dll` + dll: HMODULE, + + // Each function pointer for each function we might use + $($name: usize,)* + } + + static mut DBGHELP: Dbghelp = Dbghelp { + // Initially we haven't loaded the DLL + dll: 0 as *mut _, + // Initiall all functions are set to zero to say they need to be + // dynamically loaded. + $($name: 0,)* + }; + + // Convenience typedef for each function type. + $(pub type $name = unsafe extern "system" fn($($argty),*) -> $ret;)* + + impl Dbghelp { + /// Attempts to open `dbghelp.dll`. Returns success if it works or + /// error if `LoadLibraryW` fails. + /// + /// Panics if library is already loaded. + fn ensure_open(&mut self) -> Result<(), ()> { + if !self.dll.is_null() { + return Ok(()) + } + let lib = b"dbghelp.dll\0"; + unsafe { + self.dll = LoadLibraryA(lib.as_ptr() as *const i8); + if self.dll.is_null() { + Err(()) + } else { + Ok(()) + } + } + } + + // Function for each method we'd like to use. When called it will + // either read the cached function pointer or load it and return the + // loaded value. Loads are asserted to succeed. + $(pub fn $name(&mut self) -> Option<$name> { + unsafe { + if self.$name == 0 { + let name = concat!(stringify!($name), "\0"); + self.$name = self.symbol(name.as_bytes())?; + } + let ret = mem::transmute::(self.$name); + #[cfg(feature = "verify-winapi")] + dbghelp::assert_equal_types(ret, dbghelp::$name); + Some(ret) + } + })* + + fn symbol(&self, symbol: &[u8]) -> Option { + unsafe { + match GetProcAddress(self.dll, symbol.as_ptr() as *const _) as usize { + 0 => None, + n => Some(n), + } + } + } + } + + // Convenience proxy to use the cleanup locks to reference dbghelp + // functions. + #[allow(dead_code)] + impl Init { + $(pub fn $name(&self) -> $name { + unsafe { + DBGHELP.$name().unwrap() + } + })* + + pub fn dbghelp(&self) -> *mut Dbghelp { + unsafe { + &mut DBGHELP + } + } + } + ) + +} + +const SYMOPT_DEFERRED_LOADS: DWORD = 0x00000004; + +dbghelp! { + extern "system" { + fn SymGetOptions() -> DWORD; + fn SymSetOptions(options: DWORD) -> (); + fn SymInitializeW( + handle: HANDLE, + path: PCWSTR, + invade: BOOL + ) -> BOOL; + fn SymCleanup(handle: HANDLE) -> BOOL; + fn StackWalk64( + MachineType: DWORD, + hProcess: HANDLE, + hThread: HANDLE, + StackFrame: LPSTACKFRAME64, + ContextRecord: PVOID, + ReadMemoryRoutine: PREAD_PROCESS_MEMORY_ROUTINE64, + FunctionTableAccessRoutine: PFUNCTION_TABLE_ACCESS_ROUTINE64, + GetModuleBaseRoutine: PGET_MODULE_BASE_ROUTINE64, + TranslateAddress: PTRANSLATE_ADDRESS_ROUTINE64 + ) -> BOOL; + fn SymFunctionTableAccess64( + hProcess: HANDLE, + AddrBase: DWORD64 + ) -> PVOID; + fn SymGetModuleBase64( + hProcess: HANDLE, + AddrBase: DWORD64 + ) -> DWORD64; + fn SymFromAddrW( + hProcess: HANDLE, + Address: DWORD64, + Displacement: PDWORD64, + Symbol: PSYMBOL_INFOW + ) -> BOOL; + fn SymGetLineFromAddrW64( + hProcess: HANDLE, + dwAddr: DWORD64, + pdwDisplacement: PDWORD, + Line: PIMAGEHLP_LINEW64 + ) -> BOOL; + fn StackWalkEx( + MachineType: DWORD, + hProcess: HANDLE, + hThread: HANDLE, + StackFrame: LPSTACKFRAME_EX, + ContextRecord: PVOID, + ReadMemoryRoutine: PREAD_PROCESS_MEMORY_ROUTINE64, + FunctionTableAccessRoutine: PFUNCTION_TABLE_ACCESS_ROUTINE64, + GetModuleBaseRoutine: PGET_MODULE_BASE_ROUTINE64, + TranslateAddress: PTRANSLATE_ADDRESS_ROUTINE64, + Flags: DWORD + ) -> BOOL; + fn SymFromInlineContextW( + hProcess: HANDLE, + Address: DWORD64, + InlineContext: ULONG, + Displacement: PDWORD64, + Symbol: PSYMBOL_INFOW + ) -> BOOL; + fn SymGetLineFromInlineContextW( + hProcess: HANDLE, + dwAddr: DWORD64, + InlineContext: ULONG, + qwModuleBaseAddress: DWORD64, + pdwDisplacement: PDWORD, + Line: PIMAGEHLP_LINEW64 + ) -> BOOL; + } +} + +pub struct Init { + lock: HANDLE, +} + +/// Initialize all support necessary to access `dbghelp` API functions from this +/// crate. +/// +/// Note that this function is **safe**, it internally has its own +/// synchronization. Also note that it is safe to call this function multiple +/// times recursively. +#[cfg(all(windows, feature = "dbghelp"))] +pub fn init() -> Result { + use core::sync::atomic::{AtomicUsize, Ordering::SeqCst}; + + unsafe { + // First thing we need to do is to synchronize this function. This can + // be called concurrently from other threads or recursively within one + // thread. Note that it's trickier than that though because what we're + // using here, `dbghelp`, *also* needs to be synchronized with all other + // callers to `dbghelp` in this process. + // + // Typically there aren't really that many calls to `dbghelp` within the + // same process and we can probably safely assume that we're the only + // ones accessing it. There is, however, one primary other user we have + // to worry about which is ironically ourselves, but in the standard + // library. The Rust standard library depends on this crate for + // backtrace support, and this crate also exists on crates.io. This + // means that if the standard library is printing a panic backtrace it + // may race with this crate coming from crates.io, causing segfaults. + // + // To help solve this synchronization problem we employ a + // Windows-specific trick here (it is, after all, a Windows-specific + // restriction about synchronization). We create a *session-local* named + // mutex to protect this call. The intention here is that the standard + // library and this crate don't have to share Rust-level APIs to + // synchronize here but can instead work behind the scenes to make sure + // they're synchronizing with one another. That way when this function + // is called through the standard library or through crates.io we can be + // sure that the same mutex is being acquired. + // + // So all of that is to say that the first thing we do here is we + // atomically create a `HANDLE` which is a named mutex on Windows. We + // synchronize a bit with other threads sharing this function + // specifically and ensure that only one handle is created per instance + // of this function. Note that the handle is never closed once it's + // stored in the global. + // + // After we've actually go the lock we simply acquire it, and our `Init` + // handle we hand out will be responsible for dropping it eventually. + static LOCK: AtomicUsize = AtomicUsize::new(0); + let mut lock = LOCK.load(SeqCst); + if lock == 0 { + lock = CreateMutexA( + ptr::null_mut(), + 0, + "Local\\RustBacktraceMutex\0".as_ptr() as _, + ) as usize; + if lock == 0 { + return Err(()); + } + if let Err(other) = LOCK.compare_exchange(0, lock, SeqCst, SeqCst) { + debug_assert!(other != 0); + CloseHandle(lock as HANDLE); + lock = other; + } + } + debug_assert!(lock != 0); + let lock = lock as HANDLE; + let r = WaitForSingleObjectEx(lock, INFINITE, FALSE); + debug_assert_eq!(r, 0); + let ret = Init { lock }; + + // Ok, phew! Now that we're all safely synchronized, let's actually + // start processing everything. First up we need to ensure that + // `dbghelp.dll` is actually loaded in this process. We do this + // dynamically to avoid a static dependency. This has historically been + // done to work around weird linking issues and is intended at making + // binaries a bit more portable since this is largely just a debugging + // utility. + // + // Once we've opened `dbghelp.dll` we need to call some initialization + // functions in it, and that's detailed more below. We only do this + // once, though, so we've got a global boolean indicating whether we're + // done yet or not. + DBGHELP.ensure_open()?; + + static mut INITIALIZED: bool = false; + if INITIALIZED { + return Ok(ret); + } + + let orig = DBGHELP.SymGetOptions().unwrap()(); + + // Ensure that the `SYMOPT_DEFERRED_LOADS` flag is set, because + // according to MSVC's own docs about this: "This is the fastest, most + // efficient way to use the symbol handler.", so let's do that! + DBGHELP.SymSetOptions().unwrap()(orig | SYMOPT_DEFERRED_LOADS); + + // Actually initialize symbols with MSVC. Note that this can fail, but we + // ignore it. There's not a ton of prior art for this per se, but LLVM + // internally seems to ignore the return value here and one of the + // sanitizer libraries in LLVM prints a scary warning if this fails but + // basically ignores it in the long run. + // + // One case this comes up a lot for Rust is that the standard library and + // this crate on crates.io both want to compete for `SymInitializeW`. The + // standard library historically wanted to initialize then cleanup most of + // the time, but now that it's using this crate it means that someone will + // get to initialization first and the other will pick up that + // initialization. + DBGHELP.SymInitializeW().unwrap()(GetCurrentProcess(), ptr::null_mut(), TRUE); + INITIALIZED = true; + Ok(ret) + } +} + +impl Drop for Init { + fn drop(&mut self) { + unsafe { + let r = ReleaseMutex(self.lock); + debug_assert!(r != 0); + } + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/lib.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/lib.rs new file mode 100644 index 0000000..69a283e --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/lib.rs @@ -0,0 +1,159 @@ +//! A library for acquiring a backtrace at runtime +//! +//! This library is meant to supplement the `RUST_BACKTRACE=1` support of the +//! standard library by allowing an acquisition of a backtrace at runtime +//! programmatically. The backtraces generated by this library do not need to be +//! parsed, for example, and expose the functionality of multiple backend +//! implementations. +//! +//! # Implementation +//! +//! This library makes use of a number of strategies for actually acquiring a +//! backtrace. For example unix uses libgcc's libunwind bindings by default to +//! acquire a backtrace, but coresymbolication or dladdr is used on OSX to +//! acquire symbol names while linux uses gcc's libbacktrace. +//! +//! When using the default feature set of this library the "most reasonable" set +//! of defaults is chosen for the current platform, but the features activated +//! can also be controlled at a finer granularity. +//! +//! # API Principles +//! +//! This library attempts to be as flexible as possible to accommodate different +//! backend implementations of acquiring a backtrace. Consequently the currently +//! exported functions are closure-based as opposed to the likely expected +//! iterator-based versions. This is done due to limitations of the underlying +//! APIs used from the system. +//! +//! # Usage +//! +//! First, add this to your Cargo.toml +//! +//! ```toml +//! [dependencies] +//! backtrace = "0.3" +//! ``` +//! +//! Next: +//! +//! ``` +//! extern crate backtrace; +//! +//! fn main() { +//! # // Unsafe here so test passes on no_std. +//! # #[cfg(feature = "std")] { +//! backtrace::trace(|frame| { +//! let ip = frame.ip(); +//! let symbol_address = frame.symbol_address(); +//! +//! // Resolve this instruction pointer to a symbol name +//! backtrace::resolve_frame(frame, |symbol| { +//! if let Some(name) = symbol.name() { +//! // ... +//! } +//! if let Some(filename) = symbol.filename() { +//! // ... +//! } +//! }); +//! +//! true // keep going to the next frame +//! }); +//! } +//! # } +//! ``` + +#![doc(html_root_url = "https://docs.rs/backtrace")] +#![deny(missing_docs)] +#![no_std] +#![cfg_attr( + all(feature = "std", target_env = "sgx", target_vendor = "fortanix"), + feature(sgx_platform) +)] +#![allow(bare_trait_objects)] // TODO: remove when updating to 2018 edition +#![allow(rust_2018_idioms)] // TODO: remove when updating to 2018 edition + +#[cfg(feature = "std")] +#[macro_use] +extern crate std; + +pub use crate::backtrace::{trace_unsynchronized, Frame}; +mod backtrace; + +pub use crate::symbolize::resolve_frame_unsynchronized; +pub use crate::symbolize::{resolve_unsynchronized, Symbol, SymbolName}; +mod symbolize; + +pub use crate::types::BytesOrWideString; +mod types; + +#[cfg(feature = "std")] +pub use crate::symbolize::clear_symbol_cache; + +mod print; +pub use print::{BacktraceFmt, BacktraceFrameFmt, PrintFmt}; + +cfg_if::cfg_if! { + if #[cfg(feature = "std")] { + pub use crate::backtrace::trace; + pub use crate::symbolize::{resolve, resolve_frame}; + pub use crate::capture::{Backtrace, BacktraceFrame, BacktraceSymbol}; + mod capture; + } +} + +#[allow(dead_code)] +struct Bomb { + enabled: bool, +} + +#[allow(dead_code)] +impl Drop for Bomb { + fn drop(&mut self) { + if self.enabled { + panic!("cannot panic during the backtrace function"); + } + } +} + +#[allow(dead_code)] +#[cfg(feature = "std")] +mod lock { + use std::boxed::Box; + use std::cell::Cell; + use std::sync::{Mutex, MutexGuard, Once}; + + pub struct LockGuard(Option>); + + static mut LOCK: *mut Mutex<()> = 0 as *mut _; + static INIT: Once = Once::new(); + thread_local!(static LOCK_HELD: Cell = Cell::new(false)); + + impl Drop for LockGuard { + fn drop(&mut self) { + if self.0.is_some() { + LOCK_HELD.with(|slot| { + assert!(slot.get()); + slot.set(false); + }); + } + } + } + + pub fn lock() -> LockGuard { + if LOCK_HELD.with(|l| l.get()) { + return LockGuard(None); + } + LOCK_HELD.with(|s| s.set(true)); + unsafe { + INIT.call_once(|| { + LOCK = Box::into_raw(Box::new(Mutex::new(()))); + }); + LockGuard(Some((*LOCK).lock().unwrap())) + } + } +} + +#[cfg(all(windows, feature = "dbghelp", not(target_vendor = "uwp")))] +mod dbghelp; +#[cfg(windows)] +mod windows; diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/print.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/print.rs new file mode 100644 index 0000000..ce26f96 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/print.rs @@ -0,0 +1,268 @@ +use crate::BytesOrWideString; +use core::ffi::c_void; +use core::fmt; + +const HEX_WIDTH: usize = 2 + 2 * core::mem::size_of::(); + +#[cfg(target_os = "fuchsia")] +mod fuchsia; + +/// A formatter for backtraces. +/// +/// This type can be used to print a backtrace regardless of where the backtrace +/// itself comes from. If you have a `Backtrace` type then its `Debug` +/// implementation already uses this printing format. +pub struct BacktraceFmt<'a, 'b> { + fmt: &'a mut fmt::Formatter<'b>, + frame_index: usize, + format: PrintFmt, + print_path: &'a mut (FnMut(&mut fmt::Formatter, BytesOrWideString) -> fmt::Result + 'b), +} + +/// The styles of printing that we can print +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PrintFmt { + /// Prints a terser backtrace which ideally only contains relevant information + Short, + /// Prints a backtrace that contains all possible information + Full, + #[doc(hidden)] + __Nonexhaustive, +} + +impl<'a, 'b> BacktraceFmt<'a, 'b> { + /// Create a new `BacktraceFmt` which will write output to the provided + /// `fmt`. + /// + /// The `format` argument will control the style in which the backtrace is + /// printed, and the `print_path` argument will be used to print the + /// `BytesOrWideString` instances of filenames. This type itself doesn't do + /// any printing of filenames, but this callback is required to do so. + pub fn new( + fmt: &'a mut fmt::Formatter<'b>, + format: PrintFmt, + print_path: &'a mut (FnMut(&mut fmt::Formatter, BytesOrWideString) -> fmt::Result + 'b), + ) -> Self { + BacktraceFmt { + fmt, + frame_index: 0, + format, + print_path, + } + } + + /// Prints a preamble for the backtrace about to be printed. + /// + /// This is required on some platforms for backtraces to be fully + /// sumbolicated later, and otherwise this should just be the first method + /// you call after creating a `BacktraceFmt`. + pub fn add_context(&mut self) -> fmt::Result { + self.fmt.write_str("stack backtrace:\n")?; + #[cfg(target_os = "fuchsia")] + fuchsia::print_dso_context(self.fmt)?; + Ok(()) + } + + /// Adds a frame to the backtrace output. + /// + /// This commit returns an RAII instance of a `BacktraceFrameFmt` which can be used + /// to actually print a frame, and on destruction it will increment the + /// frame counter. + pub fn frame(&mut self) -> BacktraceFrameFmt<'_, 'a, 'b> { + BacktraceFrameFmt { + fmt: self, + symbol_index: 0, + } + } + + /// Completes the backtrace output. + /// + /// This is currently a no-op but is added for future compatibility with + /// backtrace formats. + pub fn finish(&mut self) -> fmt::Result { + // Currently a no-op-- including this hook to allow for future additions. + Ok(()) + } +} + +/// A formatter for just one frame of a backtrace. +/// +/// This type is created by the `BacktraceFmt::frame` function. +pub struct BacktraceFrameFmt<'fmt, 'a, 'b> { + fmt: &'fmt mut BacktraceFmt<'a, 'b>, + symbol_index: usize, +} + +impl BacktraceFrameFmt<'_, '_, '_> { + /// Prints a `BacktraceFrame` with this frame formatter. + /// + /// This will recusrively print all `BacktraceSymbol` instances within the + /// `BacktraceFrame`. + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + #[cfg(feature = "std")] + pub fn backtrace_frame(&mut self, frame: &crate::BacktraceFrame) -> fmt::Result { + let symbols = frame.symbols(); + for symbol in symbols { + self.backtrace_symbol(frame, symbol)?; + } + if symbols.is_empty() { + self.print_raw(frame.ip(), None, None, None)?; + } + Ok(()) + } + + /// Prints a `BacktraceSymbol` within a `BacktraceFrame`. + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + #[cfg(feature = "std")] + pub fn backtrace_symbol( + &mut self, + frame: &crate::BacktraceFrame, + symbol: &crate::BacktraceSymbol, + ) -> fmt::Result { + self.print_raw( + frame.ip(), + symbol.name(), + // TODO: this isn't great that we don't end up printing anything + // with non-utf8 filenames. Thankfully almost everything is utf8 so + // this shouldn't be too too bad. + symbol + .filename() + .and_then(|p| Some(BytesOrWideString::Bytes(p.to_str()?.as_bytes()))), + symbol.lineno(), + )?; + Ok(()) + } + + /// Prints a raw traced `Frame` and `Symbol`, typically from within the raw + /// callbacks of this crate. + pub fn symbol(&mut self, frame: &crate::Frame, symbol: &crate::Symbol) -> fmt::Result { + self.print_raw( + frame.ip(), + symbol.name(), + symbol.filename_raw(), + symbol.lineno(), + )?; + Ok(()) + } + + /// Adds a raw frame to the backtrace output. + /// + /// This method, unlike the previous, takes the raw arguments in case + /// they're being source from different locations. Note that this may be + /// called multiple times for one frame. + pub fn print_raw( + &mut self, + frame_ip: *mut c_void, + symbol_name: Option, + filename: Option, + lineno: Option, + ) -> fmt::Result { + // Fuchsia is unable to symbolize within a process so it has a special + // format which can be used to symbolize later. Print that instead of + // printing addresses in our own format here. + if cfg!(target_os = "fuchsia") { + self.print_raw_fuchsia(frame_ip)?; + } else { + self.print_raw_generic(frame_ip, symbol_name, filename, lineno)?; + } + self.symbol_index += 1; + Ok(()) + } + + #[allow(unused_mut)] + fn print_raw_generic( + &mut self, + mut frame_ip: *mut c_void, + symbol_name: Option, + filename: Option, + lineno: Option, + ) -> fmt::Result { + // No need to print "null" frames, it basically just means that the + // system backtrace was a bit eager to trace back super far. + if let PrintFmt::Short = self.fmt.format { + if frame_ip.is_null() { + return Ok(()); + } + } + + // To reduce TCB size in Sgx enclave, we do not want to implement symbol + // resolution functionality. Rather, we can print the offset of the + // address here, which could be later mapped to correct function. + #[cfg(all(feature = "std", target_env = "sgx", target_vendor = "fortanix"))] + { + let image_base = std::os::fortanix_sgx::mem::image_base(); + frame_ip = usize::wrapping_sub(frame_ip as usize, image_base as _) as _; + } + + // Print the index of the frame as well as the optional instruction + // pointer of the frame. If we're beyond the first symbol of this frame + // though we just print appropriate whitespace. + if self.symbol_index == 0 { + write!(self.fmt.fmt, "{:4}: ", self.fmt.frame_index)?; + if let PrintFmt::Full = self.fmt.format { + write!(self.fmt.fmt, "{:1$?} - ", frame_ip, HEX_WIDTH)?; + } + } else { + write!(self.fmt.fmt, " ")?; + if let PrintFmt::Full = self.fmt.format { + write!(self.fmt.fmt, "{:1$}", "", HEX_WIDTH + 3)?; + } + } + + // Next up write out the symbol name, using the alternate formatting for + // more information if we're a full backtrace. Here we also handle + // symbols which don't have a name, + match (symbol_name, &self.fmt.format) { + (Some(name), PrintFmt::Short) => write!(self.fmt.fmt, "{:#}", name)?, + (Some(name), PrintFmt::Full) => write!(self.fmt.fmt, "{}", name)?, + (None, _) | (_, PrintFmt::__Nonexhaustive) => write!(self.fmt.fmt, "")?, + } + self.fmt.fmt.write_str("\n")?; + + // And last up, print out the filename/line number if they're available. + if let (Some(file), Some(line)) = (filename, lineno) { + self.print_fileline(file, line)?; + } + + Ok(()) + } + + fn print_fileline(&mut self, file: BytesOrWideString, line: u32) -> fmt::Result { + // Filename/line are printed on lines under the symbol name, so print + // some appropriate whitespace to sort of right-align ourselves. + if let PrintFmt::Full = self.fmt.format { + write!(self.fmt.fmt, "{:1$}", "", HEX_WIDTH)?; + } + write!(self.fmt.fmt, " at ")?; + + // Delegate to our internal callback to print the filename and then + // print out the line number. + (self.fmt.print_path)(self.fmt.fmt, file)?; + write!(self.fmt.fmt, ":{}\n", line)?; + Ok(()) + } + + fn print_raw_fuchsia(&mut self, frame_ip: *mut c_void) -> fmt::Result { + // We only care about the first symbol of a frame + if self.symbol_index == 0 { + self.fmt.fmt.write_str("{{{bt:")?; + write!(self.fmt.fmt, "{}:{:?}", self.fmt.frame_index, frame_ip)?; + self.fmt.fmt.write_str("}}}\n")?; + } + Ok(()) + } +} + +impl Drop for BacktraceFrameFmt<'_, '_, '_> { + fn drop(&mut self) { + self.fmt.frame_index += 1; + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/print/fuchsia.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/print/fuchsia.rs new file mode 100644 index 0000000..787954a --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/print/fuchsia.rs @@ -0,0 +1,432 @@ +use core::fmt::{self, Write}; +use core::mem::{size_of, transmute}; +use core::slice::from_raw_parts; +use libc::c_char; + +extern "C" { + // dl_iterate_phdr takes a callback that will receive a dl_phdr_info pointer + // for every DSO that has been linked into the process. dl_iterate_phdr also + // ensures that the dynamic linker is locked from start to finish of the + // iteration. If the callback returns a non-zero value the iteration is + // terminated early. 'data' will be passed as the third argument to the + // callback on each call. 'size' gives the size of the dl_phdr_info. + #[allow(improper_ctypes)] + fn dl_iterate_phdr( + f: extern "C" fn(info: &dl_phdr_info, size: usize, data: &mut DsoPrinter) -> i32, + data: &mut DsoPrinter, + ) -> i32; +} + +// We need to parse out the build ID and some basic program header data +// which means that we need a bit of stuff from the ELF spec as well. + +const PT_LOAD: u32 = 1; +const PT_NOTE: u32 = 4; + +// Now we have to replicate, bit for bit, the structure of the dl_phdr_info +// type used by fuchsia's current dynamic linker. Chromium also has this ABI +// boundary as well as crashpad. Eventully we'd like to move these cases to +// use elf-search but we'd need to provide that in the SDK and that has not +// yet been done. Thus we (and they) are stuck having to use this method +// which incurs a tight coupling with the fuchsia libc. + +#[allow(non_camel_case_types)] +#[repr(C)] +struct dl_phdr_info { + addr: *const u8, + name: *const c_char, + phdr: *const Elf_Phdr, + phnum: u16, + adds: u64, + subs: u64, + tls_modid: usize, + tls_data: *const u8, +} + +impl dl_phdr_info { + fn program_headers(&self) -> PhdrIter<'_> { + PhdrIter { + phdrs: self.phdr_slice(), + base: self.addr, + } + } + // We have no way of knowing of checking if e_phoff and e_phnum are valid. + // libc should ensure this for us however so it's safe to form a slice here. + fn phdr_slice(&self) -> &[Elf_Phdr] { + unsafe { from_raw_parts(self.phdr, self.phnum as usize) } + } +} + +struct PhdrIter<'a> { + phdrs: &'a [Elf_Phdr], + base: *const u8, +} + +impl<'a> Iterator for PhdrIter<'a> { + type Item = Phdr<'a>; + fn next(&mut self) -> Option { + self.phdrs.split_first().map(|(phdr, new_phdrs)| { + self.phdrs = new_phdrs; + Phdr { + phdr, + base: self.base, + } + }) + } +} + +// Elf_Phdr represents a 64-bit ELF program header in the endianness of the target +// architecture. +#[allow(non_camel_case_types)] +#[derive(Clone, Debug)] +#[repr(C)] +struct Elf_Phdr { + p_type: u32, + p_flags: u32, + p_offset: u64, + p_vaddr: u64, + p_paddr: u64, + p_filesz: u64, + p_memsz: u64, + p_align: u64, +} + +// Phdr represents a valid ELF program header and its contents. +struct Phdr<'a> { + phdr: &'a Elf_Phdr, + base: *const u8, +} + +impl<'a> Phdr<'a> { + // We have no way of checking if p_addr or p_memsz are valid. Fuchsia's libc + // parses the notes first however so by virtue of being here these headers + // must be valid. NoteIter does not require the underlying data to be valid + // but it does require the bounds to be valid. We trust that libc has ensured + // that this is the case for us here. + fn notes(&self) -> NoteIter<'a> { + unsafe { + NoteIter::new( + self.base.add(self.phdr.p_offset as usize), + self.phdr.p_memsz as usize, + ) + } + } +} + +// The note type for build IDs. +const NT_GNU_BUILD_ID: u32 = 3; + +// Elf_Nhdr represents an ELF note header in the endianness of the target. +#[allow(non_camel_case_types)] +#[repr(C)] +struct Elf_Nhdr { + n_namesz: u32, + n_descsz: u32, + n_type: u32, +} + +// Note represents an ELF note (header + contents). The name is left as a u8 +// slice because it is not always null terminated and rust makes it easy enough +// to check that the bytes match eitherway. +struct Note<'a> { + name: &'a [u8], + desc: &'a [u8], + tipe: u32, +} + +// NoteIter lets you safely iterate over a note segment. It terminates as soon +// as an error occurs or there are no more notes. If you iterate over invalid +// data it will function as though no notes were found. +struct NoteIter<'a> { + base: &'a [u8], + error: bool, +} + +impl<'a> NoteIter<'a> { + // It is an invariant of function that the pointer and size given denote a + // valid range of bytes that can all be read. The contents of these bytes + // can be anything but the range must be valid for this to be safe. + unsafe fn new(base: *const u8, size: usize) -> Self { + NoteIter { + base: from_raw_parts(base, size), + error: false, + } + } +} + +// align_to aligns 'x' to 'to'-byte alignment assuming 'to' is a power of 2. +// This follows a standard pattern in C/C++ ELF parsing code where +// (x + to - 1) & -to is used. Rust does not let you negate usize so I use +// 2's-complement conversion to recreate that. +fn align_to(x: usize, to: usize) -> usize { + (x + to - 1) & (!to + 1) +} + +// take_bytes_align4 consumes num bytes from the slice (if present) and +// additionally ensures that the final slice is properlly aligned. If an +// either the number of bytes requested is too large or the slice can't be +// realigned afterwards due to not enough remaining bytes existing, None is +// returned and the slice is not modified. +fn take_bytes_align4<'a>(num: usize, bytes: &mut &'a [u8]) -> Option<&'a [u8]> { + if bytes.len() < align_to(num, 4) { + return None; + } + let (out, bytes_new) = bytes.split_at(num); + *bytes = &bytes_new[align_to(num, 4) - num..]; + Some(out) +} + +// This function has no real invariants the caller must uphold other than +// perhaps that 'bytes' should be aligned for performance (and on some +// architectures correctness). The values in the Elf_Nhdr fields might +// be nonsense but this function ensures no such thing. +fn take_nhdr<'a>(bytes: &mut &'a [u8]) -> Option<&'a Elf_Nhdr> { + if size_of::() > bytes.len() { + return None; + } + // This is safe as long as there is enough space and we just confirmed that + // in the if statement above so this should not be unsafe. + let out = unsafe { transmute::<*const u8, &'a Elf_Nhdr>(bytes.as_ptr()) }; + // Note that sice_of::() is always 4-byte aligned. + *bytes = &bytes[size_of::()..]; + Some(out) +} + +impl<'a> Iterator for NoteIter<'a> { + type Item = Note<'a>; + fn next(&mut self) -> Option { + // Check if we've reached the end. + if self.base.len() == 0 || self.error { + return None; + } + // We transmute out an nhdr but we carefully consider the resulting + // struct. We don't trust the namesz or descsz and we make no unsafe + // decisions based on the type. So even if we get out complete garbage + // we should still be safe. + let nhdr = take_nhdr(&mut self.base)?; + let name = take_bytes_align4(nhdr.n_namesz as usize, &mut self.base)?; + let desc = take_bytes_align4(nhdr.n_descsz as usize, &mut self.base)?; + Some(Note { + name: name, + desc: desc, + tipe: nhdr.n_type, + }) + } +} + +struct Perm(u32); + +/// Indicates that a segment is executable. +const PERM_X: u32 = 0b00000001; +/// Indicates that a segment is writable. +const PERM_W: u32 = 0b00000010; +/// Indicates that a segment is readable. +const PERM_R: u32 = 0b00000100; + +impl core::fmt::Display for Perm { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let v = self.0; + if v & PERM_R != 0 { + f.write_char('r')? + } + if v & PERM_W != 0 { + f.write_char('w')? + } + if v & PERM_X != 0 { + f.write_char('x')? + } + Ok(()) + } +} + +/// Represents an ELF segment at runtime. +struct Segment { + /// Gives the runtime virtual address of this segment's contents. + addr: usize, + /// Gives the memory size of this segment's contents. + size: usize, + /// Gives the module virtual address of this segment with the ELF file. + mod_rel_addr: usize, + /// Gives the permissions found in the ELF file. These permissions are not + /// necessarily the permissions present at runtime however. + flags: Perm, +} + +/// Lets one iterate over Segments from a DSO. +struct SegmentIter<'a> { + phdrs: &'a [Elf_Phdr], + base: usize, +} + +impl Iterator for SegmentIter<'_> { + type Item = Segment; + + fn next(&mut self) -> Option { + self.phdrs.split_first().and_then(|(phdr, new_phdrs)| { + self.phdrs = new_phdrs; + if phdr.p_type != PT_LOAD { + self.next() + } else { + Some(Segment { + addr: phdr.p_vaddr as usize + self.base, + size: phdr.p_memsz as usize, + mod_rel_addr: phdr.p_vaddr as usize, + flags: Perm(phdr.p_flags), + }) + } + }) + } +} + +/// Represents an ELF DSO (Dynamic Shared Object). This type references +/// the data stored in the actual DSO rather than making its own copy. +struct Dso<'a> { + /// The dynamic linker always gives us a name, even if the name is empty. + /// In the case of the main executable this name will be empty. In the case + /// of a shared object it will be the soname (see DT_SONAME). + name: &'a str, + /// On Fuchsia virtually all binaries have build IDs but this is not a strict + /// requierment. There's no way to match up DSO information with a real ELF + /// file afterwards if there is no build_id so we require that every DSO + /// have one here. DSO's without a build_id are ignored. + build_id: &'a [u8], + + base: usize, + phdrs: &'a [Elf_Phdr], +} + +impl Dso<'_> { + /// Returns an iterator over Segments in this DSO. + fn segments(&self) -> SegmentIter<'_> { + SegmentIter { + phdrs: self.phdrs.as_ref(), + base: self.base, + } + } +} + +struct HexSlice<'a> { + bytes: &'a [u8], +} + +impl fmt::Display for HexSlice<'_> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + for byte in self.bytes { + write!(f, "{:02x}", byte)?; + } + Ok(()) + } +} + +fn get_build_id<'a>(info: &'a dl_phdr_info) -> Option<&'a [u8]> { + for phdr in info.program_headers() { + if phdr.phdr.p_type == PT_NOTE { + for note in phdr.notes() { + if note.tipe == NT_GNU_BUILD_ID && (note.name == b"GNU\0" || note.name == b"GNU") { + return Some(note.desc); + } + } + } + } + None +} + +/// These errors encode issues that arise while parsing information about +/// each DSO. +enum Error { + /// NameError means that an error occurred while converting a C style string + /// into a rust string. + NameError(core::str::Utf8Error), + /// BuildIDError means that we didn't find a build ID. This could either be + /// because the DSO had no build ID or because the segment containing the + /// build ID was malformed. + BuildIDError, +} + +/// Calls either 'dso' or 'error' for each DSO linked into the process by the +/// dynamic linker. +/// +/// # Arguments +/// +/// * `visitor` - A DsoPrinter that will have one of eats methods called foreach DSO. +fn for_each_dso(mut visitor: &mut DsoPrinter) { + extern "C" fn callback(info: &dl_phdr_info, _size: usize, visitor: &mut DsoPrinter) -> i32 { + // dl_iterate_phdr ensures that info.name will point to a valid + // location. + let name_len = unsafe { libc::strlen(info.name) }; + let name_slice: &[u8] = + unsafe { core::slice::from_raw_parts(info.name as *const u8, name_len) }; + let name = match core::str::from_utf8(name_slice) { + Ok(name) => name, + Err(err) => { + return visitor.error(Error::NameError(err)) as i32; + } + }; + let build_id = match get_build_id(info) { + Some(build_id) => build_id, + None => { + return visitor.error(Error::BuildIDError) as i32; + } + }; + visitor.dso(Dso { + name: name, + build_id: build_id, + phdrs: info.phdr_slice(), + base: info.addr as usize, + }) as i32 + } + unsafe { dl_iterate_phdr(callback, &mut visitor) }; +} + +struct DsoPrinter<'a, 'b> { + writer: &'a mut core::fmt::Formatter<'b>, + module_count: usize, + error: core::fmt::Result, +} + +impl DsoPrinter<'_, '_> { + fn dso(&mut self, dso: Dso<'_>) -> bool { + let mut write = || { + write!( + self.writer, + "{{{{{{module:{:#x}:{}:elf:{}}}}}}}\n", + self.module_count, + dso.name, + HexSlice { + bytes: dso.build_id.as_ref() + } + )?; + for seg in dso.segments() { + write!( + self.writer, + "{{{{{{mmap:{:#x}:{:#x}:load:{:#x}:{}:{:#x}}}}}}}\n", + seg.addr, seg.size, self.module_count, seg.flags, seg.mod_rel_addr + )?; + } + self.module_count += 1; + Ok(()) + }; + match write() { + Ok(()) => false, + Err(err) => { + self.error = Err(err); + true + } + } + } + fn error(&mut self, _error: Error) -> bool { + false + } +} + +/// This function prints the Fuchsia symbolizer markup for all information contained in a DSO. +pub fn print_dso_context(out: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + out.write_str("{{{reset}}}\n")?; + let mut visitor = DsoPrinter { + writer: out, + module_count: 0, + error: Ok(()), + }; + for_each_dso(&mut visitor); + visitor.error +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/coresymbolication.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/coresymbolication.rs new file mode 100644 index 0000000..24dc11a --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/coresymbolication.rs @@ -0,0 +1,277 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Symbolication strategy that's OSX-specific and uses the `CoreSymbolication` +//! framework, if possible. +//! +//! This strategy uses internal private APIs that are somewhat undocumented but +//! seem to be widely used on OSX. This is the default symbolication strategy +//! for OSX, but is turned off in release builds for iOS due to reports of apps +//! being rejected due to using these APIs. +//! +//! This would probably be good to get official one day and not using private +//! APIs, but for now it should largely suffice. +//! +//! Note that this module will dynamically load `CoreSymbolication` and its APIs +//! through dlopen/dlsym, and if the loading fails this falls back to `dladdr` +//! as a symbolication strategy. + +#![allow(bad_style)] + +use crate::symbolize::dladdr; +use crate::symbolize::ResolveWhat; +use crate::types::BytesOrWideString; +use crate::SymbolName; +use core::ffi::c_void; +use core::mem; +use core::ptr; +use core::slice; +use libc::{c_char, c_int}; + +#[repr(C)] +#[derive(Copy, Clone, PartialEq)] +pub struct CSTypeRef { + cpp_data: *const c_void, + cpp_obj: *const c_void, +} + +const CS_NOW: u64 = 0x80000000; +const CSREF_NULL: CSTypeRef = CSTypeRef { + cpp_data: 0 as *const c_void, + cpp_obj: 0 as *const c_void, +}; + +pub enum Symbol<'a> { + Core { + path: *const c_char, + lineno: u32, + name: *const c_char, + addr: *mut c_void, + }, + Dladdr(dladdr::Symbol<'a>), +} + +impl Symbol<'_> { + pub fn name(&self) -> Option { + let name = match *self { + Symbol::Core { name, .. } => name, + Symbol::Dladdr(ref info) => return info.name(), + }; + if name.is_null() { + None + } else { + Some(SymbolName::new(unsafe { + let len = libc::strlen(name); + slice::from_raw_parts(name as *const u8, len) + })) + } + } + + pub fn addr(&self) -> Option<*mut c_void> { + match *self { + Symbol::Core { addr, .. } => Some(addr), + Symbol::Dladdr(ref info) => info.addr(), + } + } + + fn filename_bytes(&self) -> Option<&[u8]> { + match *self { + Symbol::Core { path, .. } => { + if path.is_null() { + None + } else { + Some(unsafe { + let len = libc::strlen(path); + slice::from_raw_parts(path as *const u8, len) + }) + } + } + Symbol::Dladdr(_) => None, + } + } + + pub fn filename_raw(&self) -> Option { + self.filename_bytes().map(BytesOrWideString::Bytes) + } + + #[cfg(feature = "std")] + pub fn filename(&self) -> Option<&::std::path::Path> { + use std::ffi::OsStr; + use std::os::unix::prelude::*; + use std::path::Path; + + self.filename_bytes().map(OsStr::from_bytes).map(Path::new) + } + + pub fn lineno(&self) -> Option { + match *self { + Symbol::Core { lineno: 0, .. } => None, + Symbol::Core { lineno, .. } => Some(lineno), + Symbol::Dladdr(_) => None, + } + } +} + +macro_rules! coresymbolication { + (#[load_path = $path:tt] extern "C" { + $(fn $name:ident($($arg:ident: $argty:ty),*) -> $ret: ty;)* + }) => ( + pub struct CoreSymbolication { + // The loaded dynamic library + dll: *mut c_void, + + // Each function pointer for each function we might use + $($name: usize,)* + } + + static mut CORESYMBOLICATION: CoreSymbolication = CoreSymbolication { + // Initially we haven't loaded the dynamic library + dll: 0 as *mut _, + // Initiall all functions are set to zero to say they need to be + // dynamically loaded. + $($name: 0,)* + }; + + // Convenience typedef for each function type. + $(pub type $name = unsafe extern "C" fn($($argty),*) -> $ret;)* + + impl CoreSymbolication { + /// Attempts to open `dbghelp.dll`. Returns `true` if it works or + /// `false` if `dlopen` fails. + fn open(&mut self) -> bool { + if !self.dll.is_null() { + return true; + } + let lib = concat!($path, "\0").as_bytes(); + unsafe { + self.dll = libc::dlopen(lib.as_ptr() as *const _, libc::RTLD_LAZY); + !self.dll.is_null() + } + } + + // Function for each method we'd like to use. When called it will + // either read the cached function pointer or load it and return the + // loaded value. Loads are asserted to succeed. + $(pub fn $name(&mut self) -> $name { + unsafe { + if self.$name == 0 { + let name = concat!(stringify!($name), "\0"); + self.$name = self.symbol(name.as_bytes()) + .expect(concat!("symbol ", stringify!($name), " is missing")); + } + mem::transmute::(self.$name) + } + })* + + fn symbol(&self, symbol: &[u8]) -> Option { + unsafe { + match libc::dlsym(self.dll, symbol.as_ptr() as *const _) as usize { + 0 => None, + n => Some(n), + } + } + } + } + ) +} + +coresymbolication! { + #[load_path = "/System/Library/PrivateFrameworks/CoreSymbolication.framework\ + /Versions/A/CoreSymbolication"] + extern "C" { + fn CSSymbolicatorCreateWithPid(pid: c_int) -> CSTypeRef; + fn CSRelease(rf: CSTypeRef) -> (); + fn CSSymbolicatorGetSymbolWithAddressAtTime( + cs: CSTypeRef, addr: *const c_void, time: u64) -> CSTypeRef; + fn CSSymbolicatorGetSourceInfoWithAddressAtTime( + cs: CSTypeRef, addr: *const c_void, time: u64) -> CSTypeRef; + fn CSSourceInfoGetLineNumber(info: CSTypeRef) -> c_int; + fn CSSourceInfoGetPath(info: CSTypeRef) -> *const c_char; + fn CSSourceInfoGetSymbol(info: CSTypeRef) -> CSTypeRef; + fn CSSymbolGetMangledName(sym: CSTypeRef) -> *const c_char; + fn CSSymbolGetSymbolOwner(sym: CSTypeRef) -> CSTypeRef; + fn CSSymbolOwnerGetBaseAddress(symowner: CSTypeRef) -> *mut c_void; + } +} + +unsafe fn try_resolve(addr: *mut c_void, cb: &mut FnMut(&super::Symbol)) -> bool { + // Note that this is externally synchronized so there's no need for + // synchronization here, making this `static mut` safer. + let lib = &mut CORESYMBOLICATION; + if !lib.open() { + return false; + } + + let cs = lib.CSSymbolicatorCreateWithPid()(libc::getpid()); + if cs == CSREF_NULL { + return false; + } + let _dtor = OwnedCSTypeRef { + ptr: cs, + CSRelease: lib.CSRelease(), + }; + + let info = lib.CSSymbolicatorGetSourceInfoWithAddressAtTime()(cs, addr, CS_NOW); + let sym = if info == CSREF_NULL { + lib.CSSymbolicatorGetSymbolWithAddressAtTime()(cs, addr, CS_NOW) + } else { + lib.CSSourceInfoGetSymbol()(info) + }; + if sym == CSREF_NULL { + return false; + } + let owner = lib.CSSymbolGetSymbolOwner()(sym); + if owner == CSREF_NULL { + return false; + } + + cb(&super::Symbol { + inner: Symbol::Core { + path: if info != CSREF_NULL { + lib.CSSourceInfoGetPath()(info) + } else { + ptr::null() + }, + lineno: if info != CSREF_NULL { + lib.CSSourceInfoGetLineNumber()(info) as u32 + } else { + 0 + }, + name: lib.CSSymbolGetMangledName()(sym), + addr: lib.CSSymbolOwnerGetBaseAddress()(owner), + }, + }); + true +} + +struct OwnedCSTypeRef { + ptr: CSTypeRef, + CSRelease: unsafe extern "C" fn(CSTypeRef), +} + +impl Drop for OwnedCSTypeRef { + fn drop(&mut self) { + unsafe { + (self.CSRelease)(self.ptr); + } + } +} + +pub unsafe fn resolve(what: ResolveWhat, cb: &mut FnMut(&super::Symbol)) { + let addr = what.address_or_ip(); + if try_resolve(addr, cb) { + return; + } + dladdr::resolve(addr, &mut |sym| { + cb(&super::Symbol { + inner: Symbol::Dladdr(sym), + }) + }) +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/dbghelp.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/dbghelp.rs new file mode 100644 index 0000000..7afcee7 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/dbghelp.rs @@ -0,0 +1,226 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Symbolication strategy using `dbghelp.dll` on Windows, only used for MSVC +//! +//! This symbolication strategy, like with backtraces, uses dynamically loaded +//! information from `dbghelp.dll`. (see `src/dbghelp.rs` for info about why +//! it's dynamically loaded). +//! +//! This API selects its resolution strategy based on the frame provided or the +//! information we have at hand. If a frame from `StackWalkEx` is given to us +//! then we use similar APIs to generate correct information about inlined +//! functions. Otherwise if all we have is an address or an older stack frame +//! from `StackWalk64` we use the older APIs for symbolication. +//! +//! There's a good deal of support in this module, but a good chunk of it is +//! converting back and forth between Windows types and Rust types. For example +//! symbols come to us as wide strings which we then convert to utf-8 strings if +//! we can. + +#![allow(bad_style)] + +use crate::backtrace::FrameImp as Frame; +use crate::dbghelp; +use crate::symbolize::ResolveWhat; +use crate::types::BytesOrWideString; +use crate::windows::*; +use crate::SymbolName; +use core::char; +use core::ffi::c_void; +use core::marker; +use core::mem; +use core::slice; + +// Store an OsString on std so we can provide the symbol name and filename. +pub struct Symbol<'a> { + name: *const [u8], + addr: *mut c_void, + line: Option, + filename: Option<*const [u16]>, + #[cfg(feature = "std")] + _filename_cache: Option<::std::ffi::OsString>, + #[cfg(not(feature = "std"))] + _filename_cache: (), + _marker: marker::PhantomData<&'a i32>, +} + +impl Symbol<'_> { + pub fn name(&self) -> Option { + Some(SymbolName::new(unsafe { &*self.name })) + } + + pub fn addr(&self) -> Option<*mut c_void> { + Some(self.addr as *mut _) + } + + pub fn filename_raw(&self) -> Option { + self.filename + .map(|slice| unsafe { BytesOrWideString::Wide(&*slice) }) + } + + pub fn lineno(&self) -> Option { + self.line + } + + #[cfg(feature = "std")] + pub fn filename(&self) -> Option<&::std::path::Path> { + use std::path::Path; + + self._filename_cache.as_ref().map(Path::new) + } +} + +#[repr(C, align(8))] +struct Aligned8(T); + +pub unsafe fn resolve(what: ResolveWhat, cb: &mut FnMut(&super::Symbol)) { + // Ensure this process's symbols are initialized + let dbghelp = match dbghelp::init() { + Ok(dbghelp) => dbghelp, + Err(()) => return, // oh well... + }; + + match what { + ResolveWhat::Address(_) => resolve_without_inline(&dbghelp, what.address_or_ip(), cb), + ResolveWhat::Frame(frame) => match &frame.inner { + Frame::New(frame) => resolve_with_inline(&dbghelp, frame, cb), + Frame::Old(_) => resolve_without_inline(&dbghelp, frame.ip(), cb), + }, + } +} + +unsafe fn resolve_with_inline( + dbghelp: &dbghelp::Init, + frame: &STACKFRAME_EX, + cb: &mut FnMut(&super::Symbol), +) { + do_resolve( + |info| { + dbghelp.SymFromInlineContextW()( + GetCurrentProcess(), + super::adjust_ip(frame.AddrPC.Offset as *mut _) as u64, + frame.InlineFrameContext, + &mut 0, + info, + ) + }, + |line| { + dbghelp.SymGetLineFromInlineContextW()( + GetCurrentProcess(), + super::adjust_ip(frame.AddrPC.Offset as *mut _) as u64, + frame.InlineFrameContext, + 0, + &mut 0, + line, + ) + }, + cb, + ) +} + +unsafe fn resolve_without_inline( + dbghelp: &dbghelp::Init, + addr: *mut c_void, + cb: &mut FnMut(&super::Symbol), +) { + do_resolve( + |info| dbghelp.SymFromAddrW()(GetCurrentProcess(), addr as DWORD64, &mut 0, info), + |line| dbghelp.SymGetLineFromAddrW64()(GetCurrentProcess(), addr as DWORD64, &mut 0, line), + cb, + ) +} + +unsafe fn do_resolve( + sym_from_addr: impl FnOnce(*mut SYMBOL_INFOW) -> BOOL, + get_line_from_addr: impl FnOnce(&mut IMAGEHLP_LINEW64) -> BOOL, + cb: &mut FnMut(&super::Symbol), +) { + const SIZE: usize = 2 * MAX_SYM_NAME + mem::size_of::(); + let mut data = Aligned8([0u8; SIZE]); + let data = &mut data.0; + let info = &mut *(data.as_mut_ptr() as *mut SYMBOL_INFOW); + info.MaxNameLen = MAX_SYM_NAME as ULONG; + // the struct size in C. the value is different to + // `size_of::() - MAX_SYM_NAME + 1` (== 81) + // due to struct alignment. + info.SizeOfStruct = 88; + + if sym_from_addr(info) != TRUE { + return; + } + + // If the symbol name is greater than MaxNameLen, SymFromAddrW will + // give a buffer of (MaxNameLen - 1) characters and set NameLen to + // the real value. + let name_len = ::core::cmp::min(info.NameLen as usize, info.MaxNameLen as usize - 1); + let name_ptr = info.Name.as_ptr() as *const u16; + let name = slice::from_raw_parts(name_ptr, name_len); + + // Reencode the utf-16 symbol to utf-8 so we can use `SymbolName::new` like + // all other platforms + let mut name_len = 0; + let mut name_buffer = [0; 256]; + { + let mut remaining = &mut name_buffer[..]; + for c in char::decode_utf16(name.iter().cloned()) { + let c = c.unwrap_or(char::REPLACEMENT_CHARACTER); + let len = c.len_utf8(); + if len < remaining.len() { + c.encode_utf8(remaining); + let tmp = remaining; + remaining = &mut tmp[len..]; + name_len += len; + } else { + break; + } + } + } + let name = &name_buffer[..name_len] as *const [u8]; + + let mut line = mem::zeroed::(); + line.SizeOfStruct = mem::size_of::() as DWORD; + + let mut filename = None; + let mut lineno = None; + if get_line_from_addr(&mut line) == TRUE { + lineno = Some(line.LineNumber as u32); + + let base = line.FileName; + let mut len = 0; + while *base.offset(len) != 0 { + len += 1; + } + + let len = len as usize; + + filename = Some(slice::from_raw_parts(base, len) as *const [u16]); + } + + cb(&super::Symbol { + inner: Symbol { + name, + addr: info.Address as *mut _, + line: lineno, + filename, + _filename_cache: cache(filename), + _marker: marker::PhantomData, + }, + }) +} + +#[cfg(feature = "std")] +unsafe fn cache(filename: Option<*const [u16]>) -> Option<::std::ffi::OsString> { + use std::os::windows::ffi::OsStringExt; + filename.map(|f| ::std::ffi::OsString::from_wide(&*f)) +} + +#[cfg(not(feature = "std"))] +unsafe fn cache(_filename: Option<*const [u16]>) {} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/dladdr.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/dladdr.rs new file mode 100644 index 0000000..9509e99 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/dladdr.rs @@ -0,0 +1,112 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Common support for resolving with `dladdr`, often used as a fallback if +//! other strategies don't work. + +#![allow(dead_code)] + +cfg_if::cfg_if! { + if #[cfg(all(unix, not(target_os = "emscripten"), feature = "dladdr"))] { + use core::ffi::c_void; + use core::marker; + use core::{mem, slice}; + use crate::SymbolName; + use crate::types::BytesOrWideString; + use libc::{self, Dl_info}; + + pub struct Symbol<'a> { + inner: Dl_info, + _marker: marker::PhantomData<&'a i32>, + } + + impl Symbol<'_> { + pub fn name(&self) -> Option { + if self.inner.dli_sname.is_null() { + None + } else { + let ptr = self.inner.dli_sname as *const u8; + unsafe { + let len = libc::strlen(self.inner.dli_sname); + Some(SymbolName::new(slice::from_raw_parts(ptr, len))) + } + } + } + + pub fn addr(&self) -> Option<*mut c_void> { + Some(self.inner.dli_saddr as *mut _) + } + + pub fn filename_raw(&self) -> Option { + None + } + + #[cfg(feature = "std")] + pub fn filename(&self) -> Option<&::std::path::Path> { + None + } + + pub fn lineno(&self) -> Option { + None + } + } + + pub unsafe fn resolve(addr: *mut c_void, cb: &mut FnMut(Symbol<'static>)) { + let mut info = Symbol { + inner: mem::zeroed(), + _marker: marker::PhantomData, + }; + // Skip null addresses to avoid calling into libc and having it do + // things with the dynamic symbol table for no reason. + if !addr.is_null() && libc::dladdr(addr as *mut _, &mut info.inner) != 0 { + cb(info) + } + } + } else { + use core::ffi::c_void; + use core::marker; + use crate::symbolize::SymbolName; + use crate::types::BytesOrWideString; + + pub struct Symbol<'a> { + a: Void, + _b: marker::PhantomData<&'a i32>, + } + + enum Void {} + + impl Symbol<'_> { + pub fn name(&self) -> Option { + match self.a {} + } + + pub fn addr(&self) -> Option<*mut c_void> { + match self.a {} + } + + pub fn filename_raw(&self) -> Option { + match self.a {} + } + + #[cfg(feature = "std")] + pub fn filename(&self) -> Option<&::std::path::Path> { + match self.a {} + } + + pub fn lineno(&self) -> Option { + match self.a {} + } + } + + pub unsafe fn resolve(addr: *mut c_void, cb: &mut FnMut(Symbol<'static>)) { + drop((addr, cb)); + } + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/dladdr_resolve.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/dladdr_resolve.rs new file mode 100644 index 0000000..7790703 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/dladdr_resolve.rs @@ -0,0 +1,50 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Symbolication strategy using `dladdr` +//! +//! The `dladdr` API is available on most Unix implementations but it's quite +//! basic, not handling inline frame information at all. Since it's so prevalent +//! though we have an option to use it! + +use crate::symbolize::{dladdr, ResolveWhat, SymbolName}; +use crate::types::BytesOrWideString; +use core::ffi::c_void; + +pub struct Symbol<'a>(dladdr::Symbol<'a>); + +impl Symbol<'_> { + pub fn name(&self) -> Option { + self.0.name() + } + + pub fn addr(&self) -> Option<*mut c_void> { + self.0.addr() + } + + pub fn filename_raw(&self) -> Option { + self.0.filename_raw() + } + + #[cfg(feature = "std")] + pub fn filename(&self) -> Option<&::std::path::Path> { + self.0.filename() + } + + pub fn lineno(&self) -> Option { + self.0.lineno() + } +} + +pub unsafe fn resolve(what: ResolveWhat, cb: &mut FnMut(&super::Symbol)) { + dladdr::resolve(what.address_or_ip(), &mut |sym| { + cb(&super::Symbol { inner: Symbol(sym) }) + }); +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/gimli.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/gimli.rs new file mode 100644 index 0000000..1529a90 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/gimli.rs @@ -0,0 +1,665 @@ +//! Support for symbolication using the `gimli` crate on crates.io +//! +//! This implementation is largely a work in progress and is off by default for +//! all platforms, but it's hoped to be developed over time! Long-term this is +//! intended to wholesale replace the `libbacktrace.rs` implementation. + +use self::gimli::read::EndianSlice; +use self::gimli::LittleEndian as Endian; +use crate::symbolize::dladdr; +use crate::symbolize::ResolveWhat; +use crate::types::BytesOrWideString; +use crate::SymbolName; +use addr2line::gimli; +use core::mem; +use core::u32; +use findshlibs::{self, Segment, SharedLibrary}; +use libc::c_void; +use memmap::Mmap; +use std::env; +use std::ffi::OsString; +use std::fs::File; +use std::path::Path; +use std::prelude::v1::*; + +const MAPPINGS_CACHE_SIZE: usize = 4; + +struct Context<'a> { + dwarf: addr2line::Context>, + object: Object<'a>, +} + +struct Mapping { + // 'static lifetime is a lie to hack around lack of support for self-referential structs. + cx: Context<'static>, + _map: Mmap, +} + +fn cx<'data>(object: Object<'data>) -> Option> { + fn load_section<'data, S>(obj: &Object<'data>) -> S + where + S: gimli::Section>, + { + let data = obj.section(S::section_name()).unwrap_or(&[]); + S::from(EndianSlice::new(data, Endian)) + } + + let dwarf = addr2line::Context::from_sections( + load_section(&object), + load_section(&object), + load_section(&object), + load_section(&object), + load_section(&object), + load_section(&object), + load_section(&object), + load_section(&object), + load_section(&object), + gimli::EndianSlice::new(&[], Endian), + ) + .ok()?; + Some(Context { dwarf, object }) +} + +fn assert_lifetimes<'a>(_: &'a Mmap, _: &Context<'a>) {} + +macro_rules! mk { + (Mapping { $map:expr, $inner:expr }) => {{ + assert_lifetimes(&$map, &$inner); + Mapping { + // Convert to 'static lifetimes since the symbols should + // only borrow `map` and we're preserving `map` below. + cx: unsafe { mem::transmute::, Context<'static>>($inner) }, + _map: $map, + } + }}; +} + +fn mmap(path: &Path) -> Option { + let file = File::open(path).ok()?; + // TODO: not completely safe, see https://github.com/danburkert/memmap-rs/issues/25 + unsafe { Mmap::map(&file).ok() } +} + +cfg_if::cfg_if! { + if #[cfg(windows)] { + use goblin::pe::{self, PE}; + use goblin::strtab::Strtab; + use std::cmp; + use std::convert::TryFrom; + + struct Object<'a> { + pe: PE<'a>, + data: &'a [u8], + symbols: Vec<(usize, pe::symbol::Symbol)>, + strtab: Strtab<'a>, + } + + impl<'a> Object<'a> { + fn parse(data: &'a [u8]) -> Option> { + let pe = PE::parse(data).ok()?; + let syms = pe.header.coff_header.symbols(data).ok()?; + let strtab = pe.header.coff_header.strings(data).ok()?; + + // Collect all the symbols into a local vector which is sorted + // by address and contains enough data to learn about the symbol + // name. Note that we only look at function symbols and also + // note that the sections are 1-indexed because the zero section + // is special (apparently). + let mut symbols = Vec::new(); + for (_, _, sym) in syms.iter() { + if sym.derived_type() != pe::symbol::IMAGE_SYM_DTYPE_FUNCTION + || sym.section_number == 0 + { + continue; + } + let addr = usize::try_from(sym.value).ok()?; + let section = pe.sections.get(usize::try_from(sym.section_number).ok()? - 1)?; + let va = usize::try_from(section.virtual_address).ok()?; + symbols.push((addr + va + pe.image_base, sym)); + } + symbols.sort_unstable_by_key(|x| x.0); + Some(Object { pe, data, symbols, strtab }) + } + + fn section(&self, name: &str) -> Option<&'a [u8]> { + let section = self.pe + .sections + .iter() + .find(|section| section.name().ok() == Some(name)); + section + .and_then(|section| { + let offset = section.pointer_to_raw_data as usize; + let size = cmp::min(section.virtual_size, section.size_of_raw_data) as usize; + self.data.get(offset..).and_then(|data| data.get(..size)) + }) + } + + fn search_symtab<'b>(&'b self, addr: u64) -> Option<&'b [u8]> { + // Note that unlike other formats COFF doesn't embed the size of + // each symbol. As a last ditch effort search for the *closest* + // symbol to a particular address and return that one. This gets + // really wonky once symbols start getting removed because the + // symbols returned here can be totally incorrect, but we have + // no idea of knowing how to detect that. + let addr = usize::try_from(addr).ok()?; + let i = match self.symbols.binary_search_by_key(&addr, |p| p.0) { + Ok(i) => i, + // typically `addr` isn't in the array, but `i` is where + // we'd insert it, so the previous position must be the + // greatest less than `addr` + Err(i) => i.checked_sub(1)?, + }; + Some(self.symbols[i].1.name(&self.strtab).ok()?.as_bytes()) + } + } + } else if #[cfg(target_os = "macos")] { + use goblin::mach::MachO; + + struct Object<'a> { + macho: MachO<'a>, + dwarf: Option, + } + + impl<'a> Object<'a> { + fn parse(macho: MachO<'a>) -> Option> { + if !macho.little_endian { + return None; + } + let dwarf = macho + .segments + .iter() + .enumerate() + .find(|(_, segment)| segment.name().ok() == Some("__DWARF")) + .map(|p| p.0); + Some(Object { macho, dwarf }) + } + + fn section(&self, name: &str) -> Option<&'a [u8]> { + let dwarf = self.dwarf?; + let dwarf = &self.macho.segments[dwarf]; + dwarf + .into_iter() + .filter_map(|s| s.ok()) + .find(|(section, _data)| { + let section_name = match section.name() { + Ok(s) => s, + Err(_) => return false, + }; + §ion_name[..] == name || { + section_name.starts_with("__") + && name.starts_with(".") + && §ion_name[2..] == &name[1..] + } + }) + .map(|p| p.1) + } + + fn search_symtab<'b>(&'b self, _addr: u64) -> Option<&'b [u8]> { + // So far it seems that we don't need to implement this. Maybe + // `dladdr` on OSX has us covered? Maybe there's not much in the + // symbol table? In any case our relevant tests are passing + // without this being implemented, so let's skip it for now. + None + } + } + } else { + use goblin::elf::Elf; + + struct Object<'a> { + elf: Elf<'a>, + data: &'a [u8], + // List of pre-parsed and sorted symbols by base address. The + // boolean indicates whether it comes from the dynamic symbol table + // or the normal symbol table, affecting where it's symbolicated. + syms: Vec<(goblin::elf::Sym, bool)>, + } + + impl<'a> Object<'a> { + fn parse(data: &'a [u8]) -> Option> { + let elf = Elf::parse(data).ok()?; + if !elf.little_endian { + return None; + } + let mut syms = elf + .syms + .iter() + .map(|s| (s, false)) + .chain(elf.dynsyms.iter().map(|s| (s, true))) + // Only look at function/object symbols. This mirrors what + // libbacktrace does and in general we're only symbolicating + // function addresses in theory. Object symbols correspond + // to data, and maybe someone's crazy enough to have a + // function go into static data? + .filter(|(s, _)| { + s.is_function() || s.st_type() == goblin::elf::sym::STT_OBJECT + }) + // skip anything that's in an undefined section header, + // since it means it's an imported function and we're only + // symbolicating with locally defined functions. + .filter(|(s, _)| { + s.st_shndx != goblin::elf::section_header::SHN_UNDEF as usize + }) + .collect::>(); + syms.sort_unstable_by_key(|s| s.0.st_value); + Some(Object { + syms, + elf, + data, + }) + } + + fn section(&self, name: &str) -> Option<&'a [u8]> { + let section = self.elf.section_headers.iter().find(|section| { + match self.elf.shdr_strtab.get(section.sh_name) { + Some(Ok(section_name)) => section_name == name, + _ => false, + } + }); + section + .and_then(|section| { + self.data.get(section.sh_offset as usize..) + .and_then(|data| data.get(..section.sh_size as usize)) + }) + } + + fn search_symtab<'b>(&'b self, addr: u64) -> Option<&'b [u8]> { + // Same sort of binary search as Windows above + let i = match self.syms.binary_search_by_key(&addr, |s| s.0.st_value) { + Ok(i) => i, + Err(i) => i.checked_sub(1)?, + }; + let (sym, dynamic) = self.syms.get(i)?; + if sym.st_value <= addr && addr <= sym.st_value + sym.st_size { + let strtab = if *dynamic { + &self.elf.dynstrtab + } else { + &self.elf.strtab + }; + Some(strtab.get(sym.st_name)?.ok()?.as_bytes()) + } else { + None + } + } + } + } +} + +impl Mapping { + #[cfg(not(target_os = "macos"))] + fn new(path: &Path) -> Option { + let map = mmap(path)?; + let cx = cx(Object::parse(&map)?)?; + Some(mk!(Mapping { map, cx })) + } + + // The loading path for OSX is is so different we just have a completely + // different implementation of the function here. On OSX we need to go + // probing the filesystem for a bunch of files. + #[cfg(target_os = "macos")] + fn new(path: &Path) -> Option { + // First up we need to load the unique UUID which is stored in the macho + // header of the file we're reading, specified at `path`. + let map = mmap(path)?; + let macho = MachO::parse(&map, 0).ok()?; + let uuid = find_uuid(&macho)?; + + // Next we need to look for a `*.dSYM` file. For now we just probe the + // containing directory and look around for something that matches + // `*.dSYM`. Once it's found we root through the dwarf resources that it + // contains and try to find a macho file which has a matching UUID as + // the one of our own file. If we find a match that's the dwarf file we + // want to return. + let parent = path.parent()?; + for entry in parent.read_dir().ok()? { + let entry = entry.ok()?; + let filename = match entry.file_name().into_string() { + Ok(name) => name, + Err(_) => continue, + }; + if !filename.ends_with(".dSYM") { + continue; + } + let candidates = entry.path().join("Contents/Resources/DWARF"); + if let Some(mapping) = load_dsym(&candidates, &uuid) { + return Some(mapping); + } + } + + // Looks like nothing matched our UUID, so let's at least return our own + // file. This should have the symbol table for at least some + // symbolication purposes. + let inner = cx(Object::parse(macho)?)?; + return Some(mk!(Mapping { map, inner })); + + fn load_dsym(dir: &Path, uuid: &[u8; 16]) -> Option { + for entry in dir.read_dir().ok()? { + let entry = entry.ok()?; + let map = mmap(&entry.path())?; + let macho = MachO::parse(&map, 0).ok()?; + let entry_uuid = find_uuid(&macho)?; + if entry_uuid != uuid { + continue; + } + if let Some(cx) = Object::parse(macho).and_then(cx) { + return Some(mk!(Mapping { map, cx })); + } + } + + None + } + + fn find_uuid<'a>(object: &'a MachO) -> Option<&'a [u8; 16]> { + use goblin::mach::load_command::CommandVariant; + + object + .load_commands + .iter() + .filter_map(|cmd| match &cmd.command { + CommandVariant::Uuid(u) => Some(&u.uuid), + _ => None, + }) + .next() + } + } +} + +#[derive(Default)] +struct Cache { + /// All known shared libraries that have been loaded. + libraries: Vec, + + /// Mappings cache where we retain parsed dwarf information. + /// + /// This list has a fixed capacity for its entire liftime which never + /// increases. The `usize` element of each pair is an index into `libraries` + /// above where `usize::max_value()` represents the current executable. The + /// `Mapping` is corresponding parsed dwarf information. + /// + /// Note that this is basically an LRU cache and we'll be shifting things + /// around in here as we symbolize addresses. + mappings: Vec<(usize, Mapping)>, +} + +struct Library { + name: OsString, + segments: Vec, + bias: findshlibs::Bias, +} + +struct LibrarySegment { + len: usize, + stated_virtual_memory_address: findshlibs::Svma, +} + +// unsafe because this is required to be externally synchronized +pub unsafe fn clear_symbol_cache() { + Cache::with_global(|cache| cache.mappings.clear()); +} + +impl Cache { + fn new() -> Cache { + let mut libraries = Vec::new(); + // Iterate over all loaded shared libraries and cache information we + // learn about them. This way we only load information here once instead + // of once per symbol. + findshlibs::TargetSharedLibrary::each(|so| { + use findshlibs::IterationControl::*; + libraries.push(Library { + name: so.name().to_owned(), + segments: so + .segments() + .map(|s| LibrarySegment { + len: s.len(), + stated_virtual_memory_address: s.stated_virtual_memory_address(), + }) + .collect(), + bias: so.virtual_memory_bias(), + }); + Continue + }); + + Cache { + mappings: Vec::with_capacity(MAPPINGS_CACHE_SIZE), + libraries, + } + } + + // unsafe because this is required to be externally synchronized + unsafe fn with_global(f: impl FnOnce(&mut Self)) { + // A very small, very simple LRU cache for debug info mappings. + // + // The hit rate should be very high, since the typical stack doesn't cross + // between many shared libraries. + // + // The `addr2line::Context` structures are pretty expensive to create. Its + // cost is expected to be amortized by subsequent `locate` queries, which + // leverage the structures built when constructing `addr2line::Context`s to + // get nice speedups. If we didn't have this cache, that amortization would + // never happen, and symbolicating backtraces would be ssssllllooooowwww. + static mut MAPPINGS_CACHE: Option = None; + + f(MAPPINGS_CACHE.get_or_insert_with(|| Cache::new())) + } + + fn avma_to_svma(&self, addr: *const u8) -> Option<(usize, findshlibs::Svma)> { + // Note that for now `findshlibs` is unimplemented on Windows, so we + // just unhelpfully assume that the address is an SVMA. Surprisingly it + // seems to at least somewhat work on Wine on Linux though... + // + // This probably means ASLR on Windows is busted. + if cfg!(windows) { + let addr = findshlibs::Svma(addr); + return Some((usize::max_value(), addr)); + } + + self.libraries + .iter() + .enumerate() + .filter_map(|(i, lib)| { + // First up, test if this `lib` has any segment containing the + // `addr` (handling relocation). If this check passes then we + // can continue below and actually translate the address. + // + // Note that this is an inlining of `contains_avma` in the + // `findshlibs` crate here. + if !lib.segments.iter().any(|s| { + let svma = s.stated_virtual_memory_address; + let start = unsafe { svma.0.offset(lib.bias.0) as usize }; + let end = start + s.len; + let address = addr as usize; + start <= address && address < end + }) { + return None; + } + + // Now that we know `lib` contains `addr`, do the equiavlent of + // `avma_to_svma` in the `findshlibs` crate. + let reverse_bias = -lib.bias.0; + let svma = findshlibs::Svma(unsafe { addr.offset(reverse_bias) }); + Some((i, svma)) + }) + .next() + } + + fn mapping_for_lib<'a>(&'a mut self, lib: usize) -> Option<&'a Context<'a>> { + let idx = self.mappings.iter().position(|(idx, _)| *idx == lib); + + // Invariant: after this conditional completes without early returning + // from an error, the cache entry for this path is at index 0. + + if let Some(idx) = idx { + // When the mapping is already in the cache, move it to the front. + if idx != 0 { + let entry = self.mappings.remove(idx); + self.mappings.insert(0, entry); + } + } else { + // When the mapping is not in the cache, create a new mapping, + // insert it into the front of the cache, and evict the oldest cache + // entry if necessary. + let storage; + let path = match self.libraries.get(lib) { + Some(lib) => &lib.name, + None => { + storage = env::current_exe().ok()?.into(); + &storage + } + }; + let mapping = Mapping::new(path.as_ref())?; + + if self.mappings.len() == MAPPINGS_CACHE_SIZE { + self.mappings.pop(); + } + + self.mappings.insert(0, (lib, mapping)); + } + + let cx: &'a Context<'static> = &self.mappings[0].1.cx; + // don't leak the `'static` lifetime, make sure it's scoped to just + // ourselves + Some(unsafe { mem::transmute::<&'a Context<'static>, &'a Context<'a>>(cx) }) + } +} + +pub unsafe fn resolve(what: ResolveWhat, cb: &mut FnMut(&super::Symbol)) { + let addr = what.address_or_ip(); + let mut cb = DladdrFallback { + cb, + addr, + called: false, + }; + + Cache::with_global(|cache| { + let (lib, addr) = match cache.avma_to_svma(addr as *const u8) { + Some(pair) => pair, + None => return, + }; + + // Finally, get a cached mapping or create a new mapping for this file, and + // evaluate the DWARF info to find the file/line/name for this address. + let cx = match cache.mapping_for_lib(lib) { + Some(cx) => cx, + None => return, + }; + if let Ok(mut frames) = cx.dwarf.find_frames(addr.0 as u64) { + while let Ok(Some(frame)) = frames.next() { + cb.call(Symbol::Frame { + addr: addr.0 as *mut c_void, + location: frame.location, + name: frame.function.map(|f| f.name.slice()), + }); + } + } + + if !cb.called { + if let Some(name) = cx.object.search_symtab(addr.0 as u64) { + cb.call(Symbol::Symtab { + addr: addr.0 as *mut c_void, + name, + }); + } + } + }); + + drop(cb); +} + +struct DladdrFallback<'a, 'b> { + addr: *mut c_void, + called: bool, + cb: &'a mut (FnMut(&super::Symbol) + 'b), +} + +impl DladdrFallback<'_, '_> { + fn call(&mut self, sym: Symbol) { + self.called = true; + + // Extend the lifetime of `sym` to `'static` since we are unfortunately + // required to here, but it's ony ever going out as a reference so no + // reference to it should be persisted beyond this frame anyway. + let sym = unsafe { mem::transmute::>(sym) }; + (self.cb)(&super::Symbol { inner: sym }); + } +} + +impl Drop for DladdrFallback<'_, '_> { + fn drop(&mut self) { + if self.called { + return; + } + unsafe { + dladdr::resolve(self.addr, &mut |sym| { + (self.cb)(&super::Symbol { + inner: Symbol::Dladdr(sym), + }) + }); + } + } +} + +pub enum Symbol<'a> { + /// We were able to locate frame information for this symbol, and + /// `addr2line`'s frame internally has all the nitty gritty details. + Frame { + addr: *mut c_void, + location: Option>, + name: Option<&'a [u8]>, + }, + /// Couldn't find debug information, but we found it in the symbol table of + /// the elf executable. + Symtab { addr: *mut c_void, name: &'a [u8] }, + /// We weren't able to find anything in the original file, so we had to fall + /// back to using `dladdr` which had a hit. + Dladdr(dladdr::Symbol<'a>), +} + +impl Symbol<'_> { + pub fn name(&self) -> Option { + match self { + Symbol::Dladdr(s) => s.name(), + Symbol::Frame { name, .. } => { + let name = name.as_ref()?; + Some(SymbolName::new(name)) + } + Symbol::Symtab { name, .. } => Some(SymbolName::new(name)), + } + } + + pub fn addr(&self) -> Option<*mut c_void> { + match self { + Symbol::Dladdr(s) => s.addr(), + Symbol::Frame { addr, .. } => Some(*addr), + Symbol::Symtab { .. } => None, + } + } + + pub fn filename_raw(&self) -> Option { + match self { + Symbol::Dladdr(s) => return s.filename_raw(), + Symbol::Frame { location, .. } => { + let file = location.as_ref()?.file?; + Some(BytesOrWideString::Bytes(file.as_bytes())) + } + Symbol::Symtab { .. } => None, + } + } + + pub fn filename(&self) -> Option<&Path> { + match self { + Symbol::Dladdr(s) => return s.filename(), + Symbol::Frame { location, .. } => { + let file = location.as_ref()?.file?; + Some(Path::new(file)) + } + Symbol::Symtab { .. } => None, + } + } + + pub fn lineno(&self) -> Option { + match self { + Symbol::Dladdr(s) => return s.lineno(), + Symbol::Frame { location, .. } => location.as_ref()?.line, + Symbol::Symtab { .. } => None, + } + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/libbacktrace.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/libbacktrace.rs new file mode 100644 index 0000000..4318789 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/libbacktrace.rs @@ -0,0 +1,489 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Symbolication strategy using the DWARF-parsing code in libbacktrace. +//! +//! The libbacktrace C library, typically distributed with gcc, supports not +//! only generating a backtrace (which we don't actually use) but also +//! symbolicating the backtrace and handling dwarf debug information about +//! things like inlined frames and whatnot. +//! +//! This is relatively complicated due to lots of various concerns here, but the +//! basic idea is: +//! +//! * First we call `backtrace_syminfo`. This gets symbol information from the +//! dynamic symbol table if we can. +//! * Next we call `backtrace_pcinfo`. This will parse debuginfo tables if +//! they're available and allow us to recover information about inline frames, +//! filenames, line numbers, etc. +//! +//! There's lots of trickery about getting the dwarf tables into libbacktrace, +//! but hopefully it's not the end of the world and is clear enough when reading +//! below. +//! +//! This is the default symbolication strategy for non-MSVC and non-OSX +//! platforms. In libstd though this is the default strategy for OSX. + +#![allow(bad_style)] + +extern crate backtrace_sys as bt; + +use core::{ptr, slice}; +use libc::{self, c_char, c_int, c_void, uintptr_t}; + +use crate::symbolize::dladdr; +use crate::symbolize::{ResolveWhat, SymbolName}; +use crate::types::BytesOrWideString; + +pub enum Symbol<'a> { + Syminfo { + pc: uintptr_t, + symname: *const c_char, + }, + Pcinfo { + pc: uintptr_t, + filename: *const c_char, + lineno: c_int, + function: *const c_char, + symname: *const c_char, + }, + Dladdr(dladdr::Symbol<'a>), +} + +impl Symbol<'_> { + pub fn name(&self) -> Option { + let symbol = |ptr: *const c_char| unsafe { + if ptr.is_null() { + None + } else { + let len = libc::strlen(ptr); + Some(SymbolName::new(slice::from_raw_parts( + ptr as *const u8, + len, + ))) + } + }; + match *self { + Symbol::Syminfo { symname, .. } => symbol(symname), + Symbol::Pcinfo { + function, symname, .. + } => { + // If possible prefer the `function` name which comes from + // debuginfo and can typically be more accurate for inline + // frames for example. If that's not present though fall back to + // the symbol table name specified in `symname`. + // + // Note that sometimes `function` can feel somewhat less + // accurate, for example being listed as `try` + // isntead of `std::panicking::try::do_call`. It's not really + // clear why, but overall the `function` name seems more accurate. + if let Some(sym) = symbol(function) { + return Some(sym); + } + symbol(symname) + } + Symbol::Dladdr(ref s) => s.name(), + } + } + + pub fn addr(&self) -> Option<*mut c_void> { + let pc = match *self { + Symbol::Syminfo { pc, .. } => pc, + Symbol::Pcinfo { pc, .. } => pc, + Symbol::Dladdr(ref s) => return s.addr(), + }; + if pc == 0 { + None + } else { + Some(pc as *mut _) + } + } + + fn filename_bytes(&self) -> Option<&[u8]> { + match *self { + Symbol::Syminfo { .. } => None, + Symbol::Pcinfo { filename, .. } => { + let ptr = filename as *const u8; + unsafe { + let len = libc::strlen(filename); + Some(slice::from_raw_parts(ptr, len)) + } + } + Symbol::Dladdr(_) => None, + } + } + + pub fn filename_raw(&self) -> Option { + self.filename_bytes().map(BytesOrWideString::Bytes) + } + + #[cfg(feature = "std")] + pub fn filename(&self) -> Option<&::std::path::Path> { + use std::path::Path; + + #[cfg(unix)] + fn bytes2path(bytes: &[u8]) -> Option<&Path> { + use std::ffi::OsStr; + use std::os::unix::prelude::*; + Some(Path::new(OsStr::from_bytes(bytes))) + } + + #[cfg(windows)] + fn bytes2path(bytes: &[u8]) -> Option<&Path> { + use std::str; + str::from_utf8(bytes).ok().map(Path::new) + } + + self.filename_bytes().and_then(bytes2path) + } + + pub fn lineno(&self) -> Option { + match *self { + Symbol::Syminfo { .. } => None, + Symbol::Pcinfo { lineno, .. } => Some(lineno as u32), + Symbol::Dladdr(ref s) => s.lineno(), + } + } +} + +extern "C" fn error_cb(_data: *mut c_void, _msg: *const c_char, _errnum: c_int) { + // do nothing for now +} + +/// Type of the `data` pointer passed into `syminfo_cb` +struct SyminfoState<'a> { + cb: &'a mut (FnMut(&super::Symbol) + 'a), + pc: usize, +} + +extern "C" fn syminfo_cb( + data: *mut c_void, + pc: uintptr_t, + symname: *const c_char, + _symval: uintptr_t, + _symsize: uintptr_t, +) { + let mut bomb = crate::Bomb { enabled: true }; + + // Once this callback is invoked from `backtrace_syminfo` when we start + // resolving we go further to call `backtrace_pcinfo`. The + // `backtrace_pcinfo` function will consult debug information and attemp tto + // do things like recover file/line information as well as inlined frames. + // Note though that `backtrace_pcinfo` can fail or not do much if there's + // not debug info, so if that happens we're sure to call the callback with + // at least one symbol from the `syminfo_cb`. + unsafe { + let syminfo_state = &mut *(data as *mut SyminfoState); + let mut pcinfo_state = PcinfoState { + symname, + called: false, + cb: syminfo_state.cb, + }; + bt::backtrace_pcinfo( + init_state(), + syminfo_state.pc as uintptr_t, + pcinfo_cb, + error_cb, + &mut pcinfo_state as *mut _ as *mut _, + ); + if !pcinfo_state.called { + (pcinfo_state.cb)(&super::Symbol { + inner: Symbol::Syminfo { + pc: pc, + symname: symname, + }, + }); + } + } + + bomb.enabled = false; +} + +/// Type of the `data` pointer passed into `pcinfo_cb` +struct PcinfoState<'a> { + cb: &'a mut (FnMut(&super::Symbol) + 'a), + symname: *const c_char, + called: bool, +} + +extern "C" fn pcinfo_cb( + data: *mut c_void, + pc: uintptr_t, + filename: *const c_char, + lineno: c_int, + function: *const c_char, +) -> c_int { + if filename.is_null() || function.is_null() { + return -1; + } + let mut bomb = crate::Bomb { enabled: true }; + + unsafe { + let state = &mut *(data as *mut PcinfoState); + state.called = true; + (state.cb)(&super::Symbol { + inner: Symbol::Pcinfo { + pc: pc, + filename: filename, + lineno: lineno, + symname: state.symname, + function, + }, + }); + } + + bomb.enabled = false; + return 0; +} + +// The libbacktrace API supports creating a state, but it does not +// support destroying a state. I personally take this to mean that a +// state is meant to be created and then live forever. +// +// I would love to register an at_exit() handler which cleans up this +// state, but libbacktrace provides no way to do so. +// +// With these constraints, this function has a statically cached state +// that is calculated the first time this is requested. Remember that +// backtracing all happens serially (one global lock). +// +// Note the lack of synchronization here is due to the requirement that +// `resolve` is externally synchronized. +unsafe fn init_state() -> *mut bt::backtrace_state { + static mut STATE: *mut bt::backtrace_state = 0 as *mut _; + + if !STATE.is_null() { + return STATE; + } + + STATE = bt::backtrace_create_state( + load_filename(), + // Don't exercise threadsafe capabilities of libbacktrace since + // we're always calling it in a synchronized fashion. + 0, + error_cb, + ptr::null_mut(), // no extra data + ); + + return STATE; + + // Note that for libbacktrace to operate at all it needs to find the DWARF + // debug info for the current executable. It typically does that via a + // number of mechanisms including, but not limited to: + // + // * /proc/self/exe on supported platforms + // * The filename passed in explicitly when creating state + // + // The libbacktrace library is a big wad of C code. This naturally means + // it's got memory safety vulnerabilities, especially when handling + // malformed debuginfo. Libstd has run into plenty of these historically. + // + // If /proc/self/exe is used then we can typically ignore these as we + // assume that libbacktrace is "mostly correct" and otherwise doesn't do + // weird things with "attempted to be correct" dwarf debug info. + // + // If we pass in a filename, however, then it's possible on some platforms + // (like BSDs) where a malicious actor can cause an arbitrary file to be + // placed at that location. This means that if we tell libbacktrace about a + // filename it may be using an arbitrary file, possibly causing segfaults. + // If we don't tell libbacktrace anything though then it won't do anything + // on platforms that don't support paths like /proc/self/exe! + // + // Given all that we try as hard as possible to *not* pass in a filename, + // but we must on platforms that don't support /proc/self/exe at all. + cfg_if::cfg_if! { + if #[cfg(any(target_os = "macos", target_os = "ios"))] { + // Note that ideally we'd use `std::env::current_exe`, but we can't + // require `std` here. + // + // Use `_NSGetExecutablePath` to load the current executable path + // into a static area (which if it's too small just give up). + // + // Note that we're seriously trusting libbacktrace here to not die + // on corrupt executables, but it surely does... + unsafe fn load_filename() -> *const libc::c_char { + const N: usize = 256; + static mut BUF: [u8; N] = [0; N]; + extern { + fn _NSGetExecutablePath( + buf: *mut libc::c_char, + bufsize: *mut u32, + ) -> libc::c_int; + } + let mut sz: u32 = BUF.len() as u32; + let ptr = BUF.as_mut_ptr() as *mut libc::c_char; + if _NSGetExecutablePath(ptr, &mut sz) == 0 { + ptr + } else { + ptr::null() + } + } + } else if #[cfg(windows)] { + use crate::windows::*; + + // Windows has a mode of opening files where after it's opened it + // can't be deleted. That's in general what we want here because we + // want to ensure that our executable isn't changing out from under + // us after we hand it off to libbacktrace, hopefully mitigating the + // ability to pass in arbitrary data into libbacktrace (which may be + // mishandled). + // + // Given that we do a bit of a dance here to attempt to get a sort + // of lock on our own image: + // + // * Get a handle to the current process, load its filename. + // * Open a file to that filename with the right flags. + // * Reload the current process's filename, making sure it's the same + // + // If that all passes we in theory have indeed opened our process's + // file and we're guaranteed it won't change. FWIW a bunch of this + // is copied from libstd historically, so this is my best + // interpretation of what was happening. + unsafe fn load_filename() -> *const libc::c_char { + load_filename_opt().unwrap_or(ptr::null()) + } + + unsafe fn load_filename_opt() -> Result<*const libc::c_char, ()> { + const N: usize = 256; + // This lives in static memory so we can return it.. + static mut BUF: [i8; N] = [0; N]; + // ... and this lives on the stack since it's temporary + let mut stack_buf = [0; N]; + let name1 = query_full_name(&mut BUF)?; + + let handle = CreateFileA( + name1.as_ptr(), + GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE, + ptr::null_mut(), + OPEN_EXISTING, + 0, + ptr::null_mut(), + ); + if handle.is_null() { + return Err(()); + } + + let name2 = query_full_name(&mut stack_buf)?; + if name1 != name2 { + CloseHandle(handle); + return Err(()) + } + // intentionally leak `handle` here because having that open + // should preserve our lock on this file name. + Ok(name1.as_ptr()) + } + + unsafe fn query_full_name(buf: &mut [i8]) -> Result<&[i8], ()> { + let dll = GetModuleHandleA(b"kernel32.dll\0".as_ptr() as *const i8); + if dll.is_null() { + return Err(()) + } + let ptrQueryFullProcessImageNameA = + GetProcAddress(dll, b"QueryFullProcessImageNameA\0".as_ptr() as *const _) as usize; + if ptrQueryFullProcessImageNameA == 0 + { + return Err(()); + } + use core::mem; + let p1 = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId()); + let mut len = buf.len() as u32; + let pfnQueryFullProcessImageNameA : extern "system" fn( + hProcess: HANDLE, + dwFlags: DWORD, + lpExeName: LPSTR, + lpdwSize: PDWORD, + ) -> BOOL = mem::transmute(ptrQueryFullProcessImageNameA); + + let rc = pfnQueryFullProcessImageNameA(p1, 0, buf.as_mut_ptr(), &mut len); + CloseHandle(p1); + + // We want to return a slice that is nul-terminated, so if + // everything was filled in and it equals the total length + // then equate that to failure. + // + // Otherwise when returning success make sure the nul byte is + // included in the slice. + if rc == 0 || len == buf.len() as u32 { + Err(()) + } else { + assert_eq!(buf[len as usize], 0); + Ok(&buf[..(len + 1) as usize]) + } + } + } else if #[cfg(target_os = "vxworks")] { + unsafe fn load_filename() -> *const libc::c_char { + use libc; + use core::mem; + + const N: usize = libc::VX_RTP_NAME_LENGTH as usize + 1; + static mut BUF: [libc::c_char; N] = [0; N]; + + let mut rtp_desc : libc::RTP_DESC = mem::zeroed(); + if (libc::rtpInfoGet(0, &mut rtp_desc as *mut libc::RTP_DESC) == 0) { + BUF.copy_from_slice(&rtp_desc.pathName); + BUF.as_ptr() + } else { + ptr::null() + } + } + } else { + unsafe fn load_filename() -> *const libc::c_char { + ptr::null() + } + } + } +} + +pub unsafe fn resolve(what: ResolveWhat, cb: &mut FnMut(&super::Symbol)) { + let symaddr = what.address_or_ip() as usize; + + // backtrace errors are currently swept under the rug + let state = init_state(); + if state.is_null() { + return dladdr_fallback(what.address_or_ip(), cb); + } + + // Call the `backtrace_syminfo` API first. This is (from reading the code) + // guaranteed to call `syminfo_cb` exactly once (or fail with an error + // presumably). We then handle more within the `syminfo_cb`. + // + // Note that we do this since `syminfo` will consult the symbol table, + // finding symbol names even if there's no debug information in the binary. + let mut called = false; + { + let mut syminfo_state = SyminfoState { + pc: symaddr, + cb: &mut |sym| { + called = true; + cb(sym); + }, + }; + bt::backtrace_syminfo( + state, + symaddr as uintptr_t, + syminfo_cb, + error_cb, + &mut syminfo_state as *mut _ as *mut _, + ); + } + + if !called { + dladdr_fallback(what.address_or_ip(), cb); + } +} + +unsafe fn dladdr_fallback(addr: *mut c_void, cb: &mut FnMut(&super::Symbol)) { + dladdr::resolve(addr, &mut |sym| { + cb(&super::Symbol { + inner: Symbol::Dladdr(sym), + }) + }); +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/mod.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/mod.rs new file mode 100644 index 0000000..7f8919b --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/mod.rs @@ -0,0 +1,512 @@ +use core::{fmt, str}; + +cfg_if::cfg_if! { + if #[cfg(feature = "std")] { + use std::path::Path; + use std::prelude::v1::*; + } +} + +use crate::backtrace::Frame; +use crate::types::BytesOrWideString; +use core::ffi::c_void; +use rustc_demangle::{try_demangle, Demangle}; + +/// Resolve an address to a symbol, passing the symbol to the specified +/// closure. +/// +/// This function will look up the given address in areas such as the local +/// symbol table, dynamic symbol table, or DWARF debug info (depending on the +/// activated implementation) to find symbols to yield. +/// +/// The closure may not be called if resolution could not be performed, and it +/// also may be called more than once in the case of inlined functions. +/// +/// Symbols yielded represent the execution at the specified `addr`, returning +/// file/line pairs for that address (if available). +/// +/// Note that if you have a `Frame` then it's recommended to use the +/// `resolve_frame` function instead of this one. +/// +/// # Required features +/// +/// This function requires the `std` feature of the `backtrace` crate to be +/// enabled, and the `std` feature is enabled by default. +/// +/// # Panics +/// +/// This function strives to never panic, but if the `cb` provided panics then +/// some platforms will force a double panic to abort the process. Some +/// platforms use a C library which internally uses callbacks which cannot be +/// unwound through, so panicking from `cb` may trigger a process abort. +/// +/// # Example +/// +/// ``` +/// extern crate backtrace; +/// +/// fn main() { +/// backtrace::trace(|frame| { +/// let ip = frame.ip(); +/// +/// backtrace::resolve(ip, |symbol| { +/// // ... +/// }); +/// +/// false // only look at the top frame +/// }); +/// } +/// ``` +#[cfg(feature = "std")] +pub fn resolve(addr: *mut c_void, cb: F) { + let _guard = crate::lock::lock(); + unsafe { resolve_unsynchronized(addr, cb) } +} + +/// Resolve a previously capture frame to a symbol, passing the symbol to the +/// specified closure. +/// +/// This functin performs the same function as `resolve` except that it takes a +/// `Frame` as an argument instead of an address. This can allow some platform +/// implementations of backtracing to provide more accurate symbol information +/// or information about inline frames for example. It's recommended to use this +/// if you can. +/// +/// # Required features +/// +/// This function requires the `std` feature of the `backtrace` crate to be +/// enabled, and the `std` feature is enabled by default. +/// +/// # Panics +/// +/// This function strives to never panic, but if the `cb` provided panics then +/// some platforms will force a double panic to abort the process. Some +/// platforms use a C library which internally uses callbacks which cannot be +/// unwound through, so panicking from `cb` may trigger a process abort. +/// +/// # Example +/// +/// ``` +/// extern crate backtrace; +/// +/// fn main() { +/// backtrace::trace(|frame| { +/// backtrace::resolve_frame(frame, |symbol| { +/// // ... +/// }); +/// +/// false // only look at the top frame +/// }); +/// } +/// ``` +#[cfg(feature = "std")] +pub fn resolve_frame(frame: &Frame, cb: F) { + let _guard = crate::lock::lock(); + unsafe { resolve_frame_unsynchronized(frame, cb) } +} + +pub enum ResolveWhat<'a> { + Address(*mut c_void), + Frame(&'a Frame), +} + +impl<'a> ResolveWhat<'a> { + #[allow(dead_code)] + fn address_or_ip(&self) -> *mut c_void { + match self { + ResolveWhat::Address(a) => adjust_ip(*a), + ResolveWhat::Frame(f) => adjust_ip(f.ip()), + } + } +} + +// IP values from stack frames are typically (always?) the instruction +// *after* the call that's the actual stack trace. Symbolizing this on +// causes the filename/line number to be one ahead and perhaps into +// the void if it's near the end of the function. +// +// This appears to basically always be the case on all platforms, so we always +// subtract one from a resolved ip to resolve it to the previous call +// instruction instead of the instruction being returned to. +// +// Ideally we would not do this. Ideally we would require callers of the +// `resolve` APIs here to manually do the -1 and account that they want location +// information for the *previous* instruction, not the current. Ideally we'd +// also expose on `Frame` if we are indeed the address of the next instruction +// or the current. +// +// For now though this is a pretty niche concern so we just internally always +// subtract one. Consumers should keep working and getting pretty good results, +// so we should be good enough. +fn adjust_ip(a: *mut c_void) -> *mut c_void { + if a.is_null() { + a + } else { + (a as usize - 1) as *mut c_void + } +} + +/// Same as `resolve`, only unsafe as it's unsynchronized. +/// +/// This function does not have synchronization guarentees but is available when +/// the `std` feature of this crate isn't compiled in. See the `resolve` +/// function for more documentation and examples. +/// +/// # Panics +/// +/// See information on `resolve` for caveats on `cb` panicking. +pub unsafe fn resolve_unsynchronized(addr: *mut c_void, mut cb: F) +where + F: FnMut(&Symbol), +{ + resolve_imp(ResolveWhat::Address(addr), &mut cb) +} + +/// Same as `resolve_frame`, only unsafe as it's unsynchronized. +/// +/// This function does not have synchronization guarentees but is available +/// when the `std` feature of this crate isn't compiled in. See the +/// `resolve_frame` function for more documentation and examples. +/// +/// # Panics +/// +/// See information on `resolve_frame` for caveats on `cb` panicking. +pub unsafe fn resolve_frame_unsynchronized(frame: &Frame, mut cb: F) +where + F: FnMut(&Symbol), +{ + resolve_imp(ResolveWhat::Frame(frame), &mut cb) +} + +/// A trait representing the resolution of a symbol in a file. +/// +/// This trait is yielded as a trait object to the closure given to the +/// `backtrace::resolve` function, and it is virtually dispatched as it's +/// unknown which implementation is behind it. +/// +/// A symbol can give contextual information about a function, for example the +/// name, filename, line number, precise address, etc. Not all information is +/// always available in a symbol, however, so all methods return an `Option`. +pub struct Symbol { + // TODO: this lifetime bound needs to be persisted eventually to `Symbol`, + // but that's currently a breaking change. For now this is safe since + // `Symbol` is only ever handed out by reference and can't be cloned. + inner: SymbolImp<'static>, +} + +impl Symbol { + /// Returns the name of this function. + /// + /// The returned structure can be used to query various properties about the + /// symbol name: + /// + /// * The `Display` implementation will print out the demangled symbol. + /// * The raw `str` value of the symbol can be accessed (if it's valid + /// utf-8). + /// * The raw bytes for the symbol name can be accessed. + pub fn name(&self) -> Option { + self.inner.name() + } + + /// Returns the starting address of this function. + pub fn addr(&self) -> Option<*mut c_void> { + self.inner.addr().map(|p| p as *mut _) + } + + /// Returns the raw filename as a slice. This is mainly useful for `no_std` + /// environments. + pub fn filename_raw(&self) -> Option { + self.inner.filename_raw() + } + + /// Returns the line number for where this symbol is currently executing. + /// + /// This return value is typically `Some` if `filename` returns `Some`, and + /// is consequently subject to similar caveats. + pub fn lineno(&self) -> Option { + self.inner.lineno() + } + + /// Returns the file name where this function was defined. + /// + /// This is currently only available when libbacktrace is being used (e.g. + /// unix platforms other than OSX) and when a binary is compiled with + /// debuginfo. If neither of these conditions is met then this will likely + /// return `None`. + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + #[cfg(feature = "std")] + #[allow(unreachable_code)] + pub fn filename(&self) -> Option<&Path> { + self.inner.filename() + } +} + +impl fmt::Debug for Symbol { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut d = f.debug_struct("Symbol"); + if let Some(name) = self.name() { + d.field("name", &name); + } + if let Some(addr) = self.addr() { + d.field("addr", &addr); + } + + #[cfg(feature = "std")] + { + if let Some(filename) = self.filename() { + d.field("filename", &filename); + } + } + + if let Some(lineno) = self.lineno() { + d.field("lineno", &lineno); + } + d.finish() + } +} + +cfg_if::cfg_if! { + if #[cfg(feature = "cpp_demangle")] { + // Maybe a parsed C++ symbol, if parsing the mangled symbol as Rust + // failed. + struct OptionCppSymbol<'a>(Option<::cpp_demangle::BorrowedSymbol<'a>>); + + impl<'a> OptionCppSymbol<'a> { + fn parse(input: &'a [u8]) -> OptionCppSymbol<'a> { + OptionCppSymbol(::cpp_demangle::BorrowedSymbol::new(input).ok()) + } + + fn none() -> OptionCppSymbol<'a> { + OptionCppSymbol(None) + } + } + } else { + use core::marker::PhantomData; + + // Make sure to keep this zero-sized, so that the `cpp_demangle` feature + // has no cost when disabled. + struct OptionCppSymbol<'a>(PhantomData<&'a ()>); + + impl<'a> OptionCppSymbol<'a> { + fn parse(_: &'a [u8]) -> OptionCppSymbol<'a> { + OptionCppSymbol(PhantomData) + } + + fn none() -> OptionCppSymbol<'a> { + OptionCppSymbol(PhantomData) + } + } + } +} + +/// A wrapper around a symbol name to provide ergonomic accessors to the +/// demangled name, the raw bytes, the raw string, etc. +// Allow dead code for when the `cpp_demangle` feature is not enabled. +#[allow(dead_code)] +pub struct SymbolName<'a> { + bytes: &'a [u8], + demangled: Option>, + cpp_demangled: OptionCppSymbol<'a>, +} + +impl<'a> SymbolName<'a> { + /// Creates a new symbol name from the raw underlying bytes. + pub fn new(bytes: &'a [u8]) -> SymbolName<'a> { + let str_bytes = str::from_utf8(bytes).ok(); + let demangled = str_bytes.and_then(|s| try_demangle(s).ok()); + + let cpp = if demangled.is_none() { + OptionCppSymbol::parse(bytes) + } else { + OptionCppSymbol::none() + }; + + SymbolName { + bytes: bytes, + demangled: demangled, + cpp_demangled: cpp, + } + } + + /// Returns the raw (mangled) symbol name as a `str` if the symbol is valid utf-8. + /// + /// Use the `Display` implementation if you want the demangled version. + pub fn as_str(&self) -> Option<&'a str> { + self.demangled + .as_ref() + .map(|s| s.as_str()) + .or_else(|| str::from_utf8(self.bytes).ok()) + } + + /// Returns the raw symbol name as a list of bytes + pub fn as_bytes(&self) -> &'a [u8] { + self.bytes + } +} + +fn format_symbol_name( + fmt: fn(&str, &mut fmt::Formatter) -> fmt::Result, + mut bytes: &[u8], + f: &mut fmt::Formatter, +) -> fmt::Result { + while bytes.len() > 0 { + match str::from_utf8(bytes) { + Ok(name) => { + fmt(name, f)?; + break; + } + Err(err) => { + fmt("\u{FFFD}", f)?; + + match err.error_len() { + Some(len) => bytes = &bytes[err.valid_up_to() + len..], + None => break, + } + } + } + } + Ok(()) +} + +cfg_if::cfg_if! { + if #[cfg(feature = "cpp_demangle")] { + impl<'a> fmt::Display for SymbolName<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if let Some(ref s) = self.demangled { + s.fmt(f) + } else if let Some(ref cpp) = self.cpp_demangled.0 { + cpp.fmt(f) + } else { + format_symbol_name(fmt::Display::fmt, self.bytes, f) + } + } + } + } else { + impl<'a> fmt::Display for SymbolName<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if let Some(ref s) = self.demangled { + s.fmt(f) + } else { + format_symbol_name(fmt::Display::fmt, self.bytes, f) + } + } + } + } +} + +cfg_if::cfg_if! { + if #[cfg(all(feature = "std", feature = "cpp_demangle"))] { + impl<'a> fmt::Debug for SymbolName<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use std::fmt::Write; + + if let Some(ref s) = self.demangled { + return s.fmt(f) + } + + // This may to print if the demangled symbol isn't actually + // valid, so handle the error here gracefully by not propagating + // it outwards. + if let Some(ref cpp) = self.cpp_demangled.0 { + let mut s = String::new(); + if write!(s, "{}", cpp).is_ok() { + return s.fmt(f) + } + } + + format_symbol_name(fmt::Debug::fmt, self.bytes, f) + } + } + } else { + impl<'a> fmt::Debug for SymbolName<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if let Some(ref s) = self.demangled { + s.fmt(f) + } else { + format_symbol_name(fmt::Debug::fmt, self.bytes, f) + } + } + } + } +} + +/// Attempt to reclaim that cached memory used to symbolicate addresses. +/// +/// This method will attempt to release any global data structures that have +/// otherwise been cached globally or in the thread which typically represent +/// parsed DWARF information or similar. +/// +/// # Caveats +/// +/// While this function is always available it doesn't actually do anything on +/// most implementations. Libraries like dbghelp or libbacktrace do not provide +/// facilities to deallocate state and manage the allocated memory. For now the +/// `gimli-symbolize` feature of this crate is the only feature where this +/// function has any effect. +#[cfg(feature = "std")] +pub fn clear_symbol_cache() { + let _guard = crate::lock::lock(); + unsafe { + clear_symbol_cache_imp(); + } +} + +mod dladdr; + +cfg_if::cfg_if! { + if #[cfg(all(windows, target_env = "msvc", feature = "dbghelp", not(target_vendor = "uwp")))] { + mod dbghelp; + use self::dbghelp::resolve as resolve_imp; + use self::dbghelp::Symbol as SymbolImp; + unsafe fn clear_symbol_cache_imp() {} + } else if #[cfg(all( + feature = "std", + feature = "gimli-symbolize", + any( + target_os = "linux", + target_os = "macos", + windows, + ), + ))] { + mod gimli; + use self::gimli::resolve as resolve_imp; + use self::gimli::Symbol as SymbolImp; + use self::gimli::clear_symbol_cache as clear_symbol_cache_imp; + // Note that we only enable coresymbolication on iOS when debug assertions + // are enabled because it's helpful in debug mode but it looks like apps get + // rejected from the app store if they use this API, see #92 for more info + } else if #[cfg(all(feature = "coresymbolication", + any(target_os = "macos", + all(target_os = "ios", debug_assertions))))] { + mod coresymbolication; + use self::coresymbolication::resolve as resolve_imp; + use self::coresymbolication::Symbol as SymbolImp; + unsafe fn clear_symbol_cache_imp() {} + } else if #[cfg(all(feature = "libbacktrace", + any(unix, all(windows, not(target_vendor = "uwp"), target_env = "gnu")), + not(target_os = "fuchsia"), + not(target_os = "emscripten")))] { + mod libbacktrace; + use self::libbacktrace::resolve as resolve_imp; + use self::libbacktrace::Symbol as SymbolImp; + unsafe fn clear_symbol_cache_imp() {} + } else if #[cfg(all(unix, + not(target_os = "emscripten"), + not(target_os = "fuchsia"), + feature = "dladdr"))] { + mod dladdr_resolve; + use self::dladdr_resolve::resolve as resolve_imp; + use self::dladdr_resolve::Symbol as SymbolImp; + unsafe fn clear_symbol_cache_imp() {} + } else { + mod noop; + use self::noop::resolve as resolve_imp; + use self::noop::Symbol as SymbolImp; + #[allow(unused)] + unsafe fn clear_symbol_cache_imp() {} + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/noop.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/noop.rs new file mode 100644 index 0000000..5c115d5 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/symbolize/noop.rs @@ -0,0 +1,37 @@ +//! Empty symbolication strategy used to compile for platforms that have no +//! support. + +use crate::symbolize::ResolveWhat; +use crate::types::BytesOrWideString; +use crate::SymbolName; +use core::ffi::c_void; +use core::marker; + +pub unsafe fn resolve(_addr: ResolveWhat, _cb: &mut FnMut(&super::Symbol)) {} + +pub struct Symbol<'a> { + _marker: marker::PhantomData<&'a i32>, +} + +impl Symbol<'_> { + pub fn name(&self) -> Option { + None + } + + pub fn addr(&self) -> Option<*mut c_void> { + None + } + + pub fn filename_raw(&self) -> Option { + None + } + + #[cfg(feature = "std")] + pub fn filename(&self) -> Option<&::std::path::Path> { + None + } + + pub fn lineno(&self) -> Option { + None + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/types.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/types.rs new file mode 100644 index 0000000..f7bcb17 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/types.rs @@ -0,0 +1,83 @@ +//! Platform dependent types. + +cfg_if::cfg_if! { + if #[cfg(feature = "std")] { + use std::borrow::Cow; + use std::fmt; + use std::path::PathBuf; + use std::prelude::v1::*; + use std::str; + } +} + +/// A platform independent representation of a string. When working with `std` +/// enabled it is recommended to the convenience methods for providing +/// conversions to `std` types. +#[derive(Debug)] +pub enum BytesOrWideString<'a> { + /// A slice, typically provided on Unix platforms. + Bytes(&'a [u8]), + /// Wide strings typically from Windows. + Wide(&'a [u16]), +} + +#[cfg(feature = "std")] +impl<'a> BytesOrWideString<'a> { + /// Lossy converts to a `Cow`, will allocate if `Bytes` is not valid + /// UTF-8 or if `BytesOrWideString` is `Wide`. + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn to_str_lossy(&self) -> Cow<'a, str> { + use self::BytesOrWideString::*; + + match self { + &Bytes(slice) => String::from_utf8_lossy(slice), + &Wide(wide) => Cow::Owned(String::from_utf16_lossy(wide)), + } + } + + /// Provides a `Path` representation of `BytesOrWideString`. + /// + /// # Required features + /// + /// This function requires the `std` feature of the `backtrace` crate to be + /// enabled, and the `std` feature is enabled by default. + pub fn into_path_buf(self) -> PathBuf { + #[cfg(unix)] + { + use std::ffi::OsStr; + use std::os::unix::ffi::OsStrExt; + + if let BytesOrWideString::Bytes(slice) = self { + return PathBuf::from(OsStr::from_bytes(slice)); + } + } + + #[cfg(windows)] + { + use std::ffi::OsString; + use std::os::windows::ffi::OsStringExt; + + if let BytesOrWideString::Wide(slice) = self { + return PathBuf::from(OsString::from_wide(slice)); + } + } + + if let BytesOrWideString::Bytes(b) = self { + if let Ok(s) = str::from_utf8(b) { + return PathBuf::from(s); + } + } + unreachable!() + } +} + +#[cfg(feature = "std")] +impl<'a> fmt::Display for BytesOrWideString<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.to_str_lossy().fmt(f) + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/src/windows.rs b/third_party/cargo/vendor/backtrace-0.3.42/src/windows.rs new file mode 100644 index 0000000..9672af0 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/src/windows.rs @@ -0,0 +1,637 @@ +//! A module to define the FFI definitions we use on Windows for `dbghelp.dll` +//! +//! This module uses a custom macro, `ffi!`, to wrap all definitions to +//! automatically generate tests to assert that our definitions here are the +//! same as `winapi`. +//! +//! This module largely exists to integrate into libstd itself where winapi is +//! not currently available. + +#![allow(bad_style, dead_code)] + +cfg_if::cfg_if! { + if #[cfg(feature = "verify-winapi")] { + pub use self::winapi::c_void; + pub use self::winapi::HINSTANCE; + pub use self::winapi::FARPROC; + pub use self::winapi::LPSECURITY_ATTRIBUTES; + #[cfg(target_pointer_width = "64")] + pub use self::winapi::PUNWIND_HISTORY_TABLE; + #[cfg(target_pointer_width = "64")] + pub use self::winapi::PRUNTIME_FUNCTION; + + mod winapi { + pub use winapi::ctypes::*; + pub use winapi::shared::basetsd::*; + pub use winapi::shared::minwindef::*; + pub use winapi::um::dbghelp::*; + pub use winapi::um::handleapi::*; + pub use winapi::um::libloaderapi::*; + pub use winapi::um::processthreadsapi::*; + pub use winapi::um::winbase::*; + pub use winapi::um::winnt::*; + pub use winapi::um::fileapi::*; + pub use winapi::um::minwinbase::*; + pub use winapi::um::synchapi::*; + } + } else { + pub use core::ffi::c_void; + pub type HINSTANCE = *mut c_void; + pub type FARPROC = *mut c_void; + pub type LPSECURITY_ATTRIBUTES = *mut c_void; + #[cfg(target_pointer_width = "64")] + pub type PRUNTIME_FUNCTION = *mut c_void; + #[cfg(target_pointer_width = "64")] + pub type PUNWIND_HISTORY_TABLE = *mut c_void; + } +} + +macro_rules! ffi { + () => (); + + (#[repr($($r:tt)*)] pub struct $name:ident { $(pub $field:ident: $ty:ty,)* } $($rest:tt)*) => ( + #[repr($($r)*)] + #[cfg(not(feature = "verify-winapi"))] + #[derive(Copy, Clone)] + pub struct $name { + $(pub $field: $ty,)* + } + + #[cfg(feature = "verify-winapi")] + pub use self::winapi::$name; + + #[test] + #[cfg(feature = "verify-winapi")] + fn $name() { + use core::mem; + + #[repr($($r)*)] + pub struct $name { + $(pub $field: $ty,)* + } + + assert_eq!( + mem::size_of::<$name>(), + mem::size_of::(), + concat!("size of ", stringify!($name), " is wrong"), + ); + assert_eq!( + mem::align_of::<$name>(), + mem::align_of::(), + concat!("align of ", stringify!($name), " is wrong"), + ); + + type Winapi = winapi::$name; + + fn assert_same(_: T, _: T) {} + + unsafe { + let a = &*(mem::align_of::<$name>() as *const $name); + let b = &*(mem::align_of::() as *const Winapi); + + $( + ffi!(@test_fields a b $field $ty); + )* + } + } + + ffi!($($rest)*); + ); + + // Handling verification against unions in winapi requires some special care + (@test_fields $a:ident $b:ident FltSave $ty:ty) => ( + // Skip this field on x86_64 `CONTEXT` since it's a union and a bit funny + ); + (@test_fields $a:ident $b:ident D $ty:ty) => ({ + let a = &$a.D; + let b = $b.D(); + assert_same(a, b); + assert_eq!(a as *const $ty, b as *const $ty, "misplaced field D"); + }); + (@test_fields $a:ident $b:ident s $ty:ty) => ({ + let a = &$a.s; + let b = $b.s(); + assert_same(a, b); + assert_eq!(a as *const $ty, b as *const $ty, "misplaced field s"); + }); + + // Otherwise test all fields normally. + (@test_fields $a:ident $b:ident $field:ident $ty:ty) => ({ + let a = &$a.$field; + let b = &$b.$field; + assert_same(a, b); + assert_eq!(a as *const $ty, b as *const $ty, + concat!("misplaced field ", stringify!($field))); + }); + + (pub type $name:ident = $ty:ty; $($rest:tt)*) => ( + pub type $name = $ty; + + #[cfg(feature = "verify-winapi")] + #[allow(dead_code)] + const $name: () = { + fn _foo() { + trait SameType {} + impl SameType for (T, T) {} + fn assert_same() {} + + assert_same::<($name, winapi::$name)>(); + } + }; + + ffi!($($rest)*); + ); + + (pub const $name:ident: $ty:ty = $val:expr; $($rest:tt)*) => ( + pub const $name: $ty = $val; + + #[cfg(feature = "verify-winapi")] + #[allow(unused_imports)] + mod $name { + use super::*; + #[test] + fn assert_valid() { + let x: $ty = winapi::$name; + assert_eq!(x, $val); + } + } + + + ffi!($($rest)*); + ); + + (extern "system" { $(pub fn $name:ident($($args:tt)*) -> $ret:ty;)* } $($rest:tt)*) => ( + extern "system" { + $(pub fn $name($($args)*) -> $ret;)* + } + + $( + #[cfg(feature = "verify-winapi")] + mod $name { + #[test] + fn assert_same() { + use super::*; + + assert_eq!($name as usize, winapi::$name as usize); + let mut x: unsafe extern "system" fn($($args)*) -> $ret; + x = $name; + drop(x); + x = winapi::$name; + drop(x); + } + } + )* + + ffi!($($rest)*); + ); + + (impl $name:ident { $($i:tt)* } $($rest:tt)*) => ( + #[cfg(not(feature = "verify-winapi"))] + impl $name { + $($i)* + } + + ffi!($($rest)*); + ); +} + +ffi! { + #[repr(C)] + pub struct STACKFRAME64 { + pub AddrPC: ADDRESS64, + pub AddrReturn: ADDRESS64, + pub AddrFrame: ADDRESS64, + pub AddrStack: ADDRESS64, + pub AddrBStore: ADDRESS64, + pub FuncTableEntry: PVOID, + pub Params: [DWORD64; 4], + pub Far: BOOL, + pub Virtual: BOOL, + pub Reserved: [DWORD64; 3], + pub KdHelp: KDHELP64, + } + + pub type LPSTACKFRAME64 = *mut STACKFRAME64; + + #[repr(C)] + pub struct STACKFRAME_EX { + pub AddrPC: ADDRESS64, + pub AddrReturn: ADDRESS64, + pub AddrFrame: ADDRESS64, + pub AddrStack: ADDRESS64, + pub AddrBStore: ADDRESS64, + pub FuncTableEntry: PVOID, + pub Params: [DWORD64; 4], + pub Far: BOOL, + pub Virtual: BOOL, + pub Reserved: [DWORD64; 3], + pub KdHelp: KDHELP64, + pub StackFrameSize: DWORD, + pub InlineFrameContext: DWORD, + } + + pub type LPSTACKFRAME_EX = *mut STACKFRAME_EX; + + #[repr(C)] + pub struct IMAGEHLP_LINEW64 { + pub SizeOfStruct: DWORD, + pub Key: PVOID, + pub LineNumber: DWORD, + pub FileName: PWSTR, + pub Address: DWORD64, + } + + pub type PIMAGEHLP_LINEW64 = *mut IMAGEHLP_LINEW64; + + #[repr(C)] + pub struct SYMBOL_INFOW { + pub SizeOfStruct: ULONG, + pub TypeIndex: ULONG, + pub Reserved: [ULONG64; 2], + pub Index: ULONG, + pub Size: ULONG, + pub ModBase: ULONG64, + pub Flags: ULONG, + pub Value: ULONG64, + pub Address: ULONG64, + pub Register: ULONG, + pub Scope: ULONG, + pub Tag: ULONG, + pub NameLen: ULONG, + pub MaxNameLen: ULONG, + pub Name: [WCHAR; 1], + } + + pub type PSYMBOL_INFOW = *mut SYMBOL_INFOW; + + pub type PTRANSLATE_ADDRESS_ROUTINE64 = Option< + unsafe extern "system" fn(hProcess: HANDLE, hThread: HANDLE, lpaddr: LPADDRESS64) -> DWORD64, + >; + pub type PGET_MODULE_BASE_ROUTINE64 = + Option DWORD64>; + pub type PFUNCTION_TABLE_ACCESS_ROUTINE64 = + Option PVOID>; + pub type PREAD_PROCESS_MEMORY_ROUTINE64 = Option< + unsafe extern "system" fn( + hProcess: HANDLE, + qwBaseAddress: DWORD64, + lpBuffer: PVOID, + nSize: DWORD, + lpNumberOfBytesRead: LPDWORD, + ) -> BOOL, + >; + + #[repr(C)] + pub struct ADDRESS64 { + pub Offset: DWORD64, + pub Segment: WORD, + pub Mode: ADDRESS_MODE, + } + + pub type LPADDRESS64 = *mut ADDRESS64; + + pub type ADDRESS_MODE = u32; + + #[repr(C)] + pub struct KDHELP64 { + pub Thread: DWORD64, + pub ThCallbackStack: DWORD, + pub ThCallbackBStore: DWORD, + pub NextCallback: DWORD, + pub FramePointer: DWORD, + pub KiCallUserMode: DWORD64, + pub KeUserCallbackDispatcher: DWORD64, + pub SystemRangeStart: DWORD64, + pub KiUserExceptionDispatcher: DWORD64, + pub StackBase: DWORD64, + pub StackLimit: DWORD64, + pub BuildVersion: DWORD, + pub Reserved0: DWORD, + pub Reserved1: [DWORD64; 4], + } + + pub const MAX_SYM_NAME: usize = 2000; + pub const AddrModeFlat: ADDRESS_MODE = 3; + pub const TRUE: BOOL = 1; + pub const FALSE: BOOL = 0; + pub const PROCESS_QUERY_INFORMATION: DWORD = 0x400; + pub const IMAGE_FILE_MACHINE_ARM64: u16 = 43620; + pub const IMAGE_FILE_MACHINE_AMD64: u16 = 34404; + pub const IMAGE_FILE_MACHINE_I386: u16 = 332; + pub const IMAGE_FILE_MACHINE_ARMNT: u16 = 452; + pub const FILE_SHARE_READ: DWORD = 0x1; + pub const FILE_SHARE_WRITE: DWORD = 0x2; + pub const OPEN_EXISTING: DWORD = 0x3; + pub const GENERIC_READ: DWORD = 0x80000000; + pub const INFINITE: DWORD = !0; + + pub type DWORD = u32; + pub type PDWORD = *mut u32; + pub type BOOL = i32; + pub type DWORD64 = u64; + pub type PDWORD64 = *mut u64; + pub type HANDLE = *mut c_void; + pub type PVOID = HANDLE; + pub type PCWSTR = *const u16; + pub type LPSTR = *mut i8; + pub type LPCSTR = *const i8; + pub type PWSTR = *mut u16; + pub type WORD = u16; + pub type ULONG = u32; + pub type ULONG64 = u64; + pub type WCHAR = u16; + pub type PCONTEXT = *mut CONTEXT; + pub type LPDWORD = *mut DWORD; + pub type DWORDLONG = u64; + pub type HMODULE = HINSTANCE; + + extern "system" { + pub fn GetCurrentProcess() -> HANDLE; + pub fn GetCurrentThread() -> HANDLE; + pub fn RtlCaptureContext(ContextRecord: PCONTEXT) -> (); + pub fn LoadLibraryA(a: *const i8) -> HMODULE; + pub fn GetProcAddress(h: HMODULE, name: *const i8) -> FARPROC; + pub fn GetModuleHandleA(name: *const i8) -> HMODULE; + pub fn OpenProcess( + dwDesiredAccess: DWORD, + bInheitHandle: BOOL, + dwProcessId: DWORD, + ) -> HANDLE; + pub fn GetCurrentProcessId() -> DWORD; + pub fn CloseHandle(h: HANDLE) -> BOOL; + pub fn CreateFileA( + lpFileName: LPCSTR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, + hTemplateFile: HANDLE, + ) -> HANDLE; + pub fn CreateMutexA( + attrs: LPSECURITY_ATTRIBUTES, + initial: BOOL, + name: LPCSTR, + ) -> HANDLE; + pub fn ReleaseMutex(hMutex: HANDLE) -> BOOL; + pub fn WaitForSingleObjectEx( + hHandle: HANDLE, + dwMilliseconds: DWORD, + bAlertable: BOOL, + ) -> DWORD; + } +} + +#[cfg(target_pointer_width = "64")] +ffi! { + extern "system" { + pub fn RtlLookupFunctionEntry( + ControlPc: DWORD64, + ImageBase: PDWORD64, + HistoryTable: PUNWIND_HISTORY_TABLE, + ) -> PRUNTIME_FUNCTION; + } +} + +#[cfg(target_arch = "aarch64")] +ffi! { + #[repr(C, align(16))] + pub struct CONTEXT { + pub ContextFlags: DWORD, + pub Cpsr: DWORD, + pub u: CONTEXT_u, + pub Sp: u64, + pub Pc: u64, + pub V: [ARM64_NT_NEON128; 32], + pub Fpcr: DWORD, + pub Fpsr: DWORD, + pub Bcr: [DWORD; ARM64_MAX_BREAKPOINTS], + pub Bvr: [DWORD64; ARM64_MAX_BREAKPOINTS], + pub Wcr: [DWORD; ARM64_MAX_WATCHPOINTS], + pub Wvr: [DWORD64; ARM64_MAX_WATCHPOINTS], + } + + #[repr(C)] + pub struct CONTEXT_u { + pub s: CONTEXT_u_s, + } + + impl CONTEXT_u { + pub unsafe fn s(&self) -> &CONTEXT_u_s { + &self.s + } + } + + #[repr(C)] + pub struct CONTEXT_u_s { + pub X0: u64, + pub X1: u64, + pub X2: u64, + pub X3: u64, + pub X4: u64, + pub X5: u64, + pub X6: u64, + pub X7: u64, + pub X8: u64, + pub X9: u64, + pub X10: u64, + pub X11: u64, + pub X12: u64, + pub X13: u64, + pub X14: u64, + pub X15: u64, + pub X16: u64, + pub X17: u64, + pub X18: u64, + pub X19: u64, + pub X20: u64, + pub X21: u64, + pub X22: u64, + pub X23: u64, + pub X24: u64, + pub X25: u64, + pub X26: u64, + pub X27: u64, + pub X28: u64, + pub Fp: u64, + pub Lr: u64, + } + + pub const ARM64_MAX_BREAKPOINTS: usize = 8; + pub const ARM64_MAX_WATCHPOINTS: usize = 2; + + #[repr(C)] + pub struct ARM64_NT_NEON128 { + pub D: [f64; 2], + } +} + +#[cfg(target_arch = "x86")] +ffi! { + #[repr(C)] + pub struct CONTEXT { + pub ContextFlags: DWORD, + pub Dr0: DWORD, + pub Dr1: DWORD, + pub Dr2: DWORD, + pub Dr3: DWORD, + pub Dr6: DWORD, + pub Dr7: DWORD, + pub FloatSave: FLOATING_SAVE_AREA, + pub SegGs: DWORD, + pub SegFs: DWORD, + pub SegEs: DWORD, + pub SegDs: DWORD, + pub Edi: DWORD, + pub Esi: DWORD, + pub Ebx: DWORD, + pub Edx: DWORD, + pub Ecx: DWORD, + pub Eax: DWORD, + pub Ebp: DWORD, + pub Eip: DWORD, + pub SegCs: DWORD, + pub EFlags: DWORD, + pub Esp: DWORD, + pub SegSs: DWORD, + pub ExtendedRegisters: [u8; 512], + } + + #[repr(C)] + pub struct FLOATING_SAVE_AREA { + pub ControlWord: DWORD, + pub StatusWord: DWORD, + pub TagWord: DWORD, + pub ErrorOffset: DWORD, + pub ErrorSelector: DWORD, + pub DataOffset: DWORD, + pub DataSelector: DWORD, + pub RegisterArea: [u8; 80], + pub Spare0: DWORD, + } +} + +#[cfg(target_arch = "x86_64")] +ffi! { + #[repr(C, align(8))] + pub struct CONTEXT { + pub P1Home: DWORDLONG, + pub P2Home: DWORDLONG, + pub P3Home: DWORDLONG, + pub P4Home: DWORDLONG, + pub P5Home: DWORDLONG, + pub P6Home: DWORDLONG, + + pub ContextFlags: DWORD, + pub MxCsr: DWORD, + + pub SegCs: WORD, + pub SegDs: WORD, + pub SegEs: WORD, + pub SegFs: WORD, + pub SegGs: WORD, + pub SegSs: WORD, + pub EFlags: DWORD, + + pub Dr0: DWORDLONG, + pub Dr1: DWORDLONG, + pub Dr2: DWORDLONG, + pub Dr3: DWORDLONG, + pub Dr6: DWORDLONG, + pub Dr7: DWORDLONG, + + pub Rax: DWORDLONG, + pub Rcx: DWORDLONG, + pub Rdx: DWORDLONG, + pub Rbx: DWORDLONG, + pub Rsp: DWORDLONG, + pub Rbp: DWORDLONG, + pub Rsi: DWORDLONG, + pub Rdi: DWORDLONG, + pub R8: DWORDLONG, + pub R9: DWORDLONG, + pub R10: DWORDLONG, + pub R11: DWORDLONG, + pub R12: DWORDLONG, + pub R13: DWORDLONG, + pub R14: DWORDLONG, + pub R15: DWORDLONG, + + pub Rip: DWORDLONG, + + pub FltSave: FLOATING_SAVE_AREA, + + pub VectorRegister: [M128A; 26], + pub VectorControl: DWORDLONG, + + pub DebugControl: DWORDLONG, + pub LastBranchToRip: DWORDLONG, + pub LastBranchFromRip: DWORDLONG, + pub LastExceptionToRip: DWORDLONG, + pub LastExceptionFromRip: DWORDLONG, + } + + #[repr(C)] + pub struct M128A { + pub Low: u64, + pub High: i64, + } +} + +#[repr(C)] +#[cfg(target_arch = "x86_64")] +#[derive(Copy, Clone)] +pub struct FLOATING_SAVE_AREA { + _Dummy: [u8; 512], +} + +#[cfg(target_arch = "arm")] +ffi! { + // #[repr(C)] + // pub struct NEON128 { + // pub Low: ULONG64, + // pub High: LONG64, + // } + + // pub type PNEON128 = *mut NEON128; + + #[repr(C)] + pub struct CONTEXT_u { + // pub Q: [NEON128; 16], + pub D: [ULONG64; 32], + // pub S: [DWORD; 32], + } + + pub const ARM_MAX_BREAKPOINTS: usize = 8; + pub const ARM_MAX_WATCHPOINTS: usize = 1; + + #[repr(C)] + pub struct CONTEXT { + pub ContextFlags: DWORD, + pub R0: DWORD, + pub R1: DWORD, + pub R2: DWORD, + pub R3: DWORD, + pub R4: DWORD, + pub R5: DWORD, + pub R6: DWORD, + pub R7: DWORD, + pub R8: DWORD, + pub R9: DWORD, + pub R10: DWORD, + pub R11: DWORD, + pub R12: DWORD, + pub Sp: DWORD, + pub Lr: DWORD, + pub Pc: DWORD, + pub Cpsr: DWORD, + pub Fpsrc: DWORD, + pub Padding: DWORD, + pub u: CONTEXT_u, + pub Bvr: [DWORD; ARM_MAX_BREAKPOINTS], + pub Bcr: [DWORD; ARM_MAX_BREAKPOINTS], + pub Wvr: [DWORD; ARM_MAX_WATCHPOINTS], + pub Wcr: [DWORD; ARM_MAX_WATCHPOINTS], + pub Padding2: [DWORD; 2], + } +} // IFDEF(arm) diff --git a/third_party/cargo/vendor/backtrace-0.3.42/tests/accuracy/auxiliary.rs b/third_party/cargo/vendor/backtrace-0.3.42/tests/accuracy/auxiliary.rs new file mode 100644 index 0000000..7d04570 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/tests/accuracy/auxiliary.rs @@ -0,0 +1,16 @@ +#[inline(never)] +pub fn callback(f: F) +where + F: FnOnce((&'static str, u32)), +{ + f((file!(), line!())) +} + +#[inline(always)] +#[cfg_attr(feature = "coresymbolication", inline(never))] +pub fn callback_inlined(f: F) +where + F: FnOnce((&'static str, u32)), +{ + f((file!(), line!())) +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/tests/accuracy/main.rs b/third_party/cargo/vendor/backtrace-0.3.42/tests/accuracy/main.rs new file mode 100644 index 0000000..7c484a2 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/tests/accuracy/main.rs @@ -0,0 +1,92 @@ +mod auxiliary; + +macro_rules! pos { + () => { + (file!(), line!()) + }; +} + +macro_rules! check { + ($($pos:expr),*) => ({ + verify(&[$($pos,)* pos!()]); + }) +} + +type Pos = (&'static str, u32); + +#[test] +fn doit() { + outer(pos!()); +} + +#[inline(never)] +fn outer(main_pos: Pos) { + inner(main_pos, pos!()); + inner_inlined(main_pos, pos!()); +} + +#[inline(never)] +#[rustfmt::skip] +fn inner(main_pos: Pos, outer_pos: Pos) { + check!(main_pos, outer_pos); + check!(main_pos, outer_pos); + let inner_pos = pos!(); auxiliary::callback(|aux_pos| { + check!(main_pos, outer_pos, inner_pos, aux_pos); + }); + let inner_pos = pos!(); auxiliary::callback_inlined(|aux_pos| { + check!(main_pos, outer_pos, inner_pos, aux_pos); + }); +} + +#[inline(always)] +#[cfg_attr(feature = "coresymbolication", inline(never))] +#[rustfmt::skip] +fn inner_inlined(main_pos: Pos, outer_pos: Pos) { + check!(main_pos, outer_pos); + check!(main_pos, outer_pos); + + #[inline(always)] + #[cfg_attr(feature = "coresymbolication", inline(never))] + fn inner_further_inlined(main_pos: Pos, outer_pos: Pos, inner_pos: Pos) { + check!(main_pos, outer_pos, inner_pos); + } + inner_further_inlined(main_pos, outer_pos, pos!()); + + let inner_pos = pos!(); auxiliary::callback(|aux_pos| { + check!(main_pos, outer_pos, inner_pos, aux_pos); + }); + let inner_pos = pos!(); auxiliary::callback_inlined(|aux_pos| { + check!(main_pos, outer_pos, inner_pos, aux_pos); + }); + + // this tests a distinction between two independent calls to the inlined function. + // (un)fortunately, LLVM somehow merges two consecutive such calls into one node. + inner_further_inlined(main_pos, outer_pos, pos!()); +} + +fn verify(filelines: &[Pos]) { + let trace = backtrace::Backtrace::new(); + println!("-----------------------------------"); + println!("looking for:"); + for (file, line) in filelines.iter().rev() { + println!("\t{}:{}", file, line); + } + println!("found:\n{:?}", trace); + let mut symbols = trace.frames().iter().flat_map(|frame| frame.symbols()); + let mut iter = filelines.iter().rev(); + while let Some((file, line)) = iter.next() { + loop { + let sym = match symbols.next() { + Some(sym) => sym, + None => panic!("failed to find {}:{}", file, line), + }; + if let Some(filename) = sym.filename() { + if let Some(lineno) = sym.lineno() { + if filename.ends_with(file) && lineno == *line { + break; + } + } + } + } + } +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/tests/concurrent-panics.rs b/third_party/cargo/vendor/backtrace-0.3.42/tests/concurrent-panics.rs new file mode 100644 index 0000000..ac1d61d --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/tests/concurrent-panics.rs @@ -0,0 +1,72 @@ +use std::env; +use std::panic; +use std::process::Command; +use std::sync::atomic::{AtomicBool, Ordering::SeqCst}; +use std::sync::Arc; +use std::thread; + +const PANICS: usize = 100; +const THREADS: usize = 8; +const VAR: &str = "__THE_TEST_YOU_ARE_LUKE"; + +fn main() { + // These run in docker containers on CI where they can't re-exec the test, + // so just skip these for CI. No other reason this can't run on those + // platforms though. + if cfg!(unix) && (cfg!(target_arch = "arm") || cfg!(target_arch = "aarch64")) { + println!("test result: ok"); + return; + } + + if env::var(VAR).is_err() { + parent(); + } else { + child(); + } +} + +fn parent() { + let me = env::current_exe().unwrap(); + let result = Command::new(&me) + .env("RUST_BACKTRACE", "1") + .env(VAR, "1") + .output() + .unwrap(); + if result.status.success() { + println!("test result: ok"); + return; + } + println!("stdout:\n{}", String::from_utf8_lossy(&result.stdout)); + println!("stderr:\n{}", String::from_utf8_lossy(&result.stderr)); + println!("code: {}", result.status); + panic!(); +} + +fn child() { + let done = Arc::new(AtomicBool::new(false)); + let done2 = done.clone(); + let a = thread::spawn(move || { + while !done2.load(SeqCst) { + format!("{:?}", backtrace::Backtrace::new()); + } + }); + + let threads = (0..THREADS) + .map(|_| { + thread::spawn(|| { + for _ in 0..PANICS { + assert!(panic::catch_unwind(|| { + panic!(); + }) + .is_err()); + } + }) + }) + .collect::>(); + for thread in threads { + thread.join().unwrap(); + } + + done.store(true, SeqCst); + a.join().unwrap(); +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/tests/long_fn_name.rs b/third_party/cargo/vendor/backtrace-0.3.42/tests/long_fn_name.rs new file mode 100644 index 0000000..a565734 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/tests/long_fn_name.rs @@ -0,0 +1,50 @@ +extern crate backtrace; + +use backtrace::Backtrace; + +// 50-character module name +mod _234567890_234567890_234567890_234567890_234567890 { + // 50-character struct name + #[allow(non_camel_case_types)] + pub struct _234567890_234567890_234567890_234567890_234567890(T); + impl _234567890_234567890_234567890_234567890_234567890 { + #[allow(dead_code)] + pub fn new() -> crate::Backtrace { + crate::Backtrace::new() + } + } +} + +// Long function names must be truncated to (MAX_SYM_NAME - 1) characters. +// Only run this test for msvc, since gnu prints "" for all frames. +#[test] +#[cfg(all(windows, feature = "dbghelp", target_env = "msvc"))] +fn test_long_fn_name() { + use _234567890_234567890_234567890_234567890_234567890::_234567890_234567890_234567890_234567890_234567890 as S; + + // 10 repetitions of struct name, so fully qualified function name is + // atleast 10 * (50 + 50) * 2 = 2000 characters long. + // It's actually longer since it also includes `::`, `<>` and the + // name of the current module + let bt = S::>>>>>>>>>::new(); + println!("{:?}", bt); + + let mut found_long_name_frame = false; + + for frame in bt.frames() { + let symbols = frame.symbols(); + if symbols.is_empty() { + continue; + } + + if let Some(function_name) = symbols[0].name() { + let function_name = function_name.as_str().unwrap(); + if function_name.contains("::_234567890_234567890_234567890_234567890_234567890") { + found_long_name_frame = true; + assert!(function_name.len() > 200); + } + } + } + + assert!(found_long_name_frame); +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/tests/skip_inner_frames.rs b/third_party/cargo/vendor/backtrace-0.3.42/tests/skip_inner_frames.rs new file mode 100644 index 0000000..f5043ee --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/tests/skip_inner_frames.rs @@ -0,0 +1,49 @@ +extern crate backtrace; + +use backtrace::Backtrace; + +// This test only works on platforms which have a working `symbol_address` +// function for frames which reports the starting address of a symbol. As a +// result it's only enabled on a few platforms. +const ENABLED: bool = cfg!(all( + // Windows hasn't really been tested, and OSX doesn't support actually + // finding an enclosing frame, so disable this + target_os = "linux", + // This is the only method currently that supports accurate enough + // backtraces for this test to work. + feature = "libunwind", + // On ARM finding the enclosing function is simply returning the ip itself. + not(target_arch = "arm"), +)); + +#[test] +fn backtrace_new_unresolved_should_start_with_call_site_trace() { + if !ENABLED { + return; + } + let mut b = Backtrace::new_unresolved(); + b.resolve(); + println!("{:?}", b); + + assert!(!b.frames().is_empty()); + + let this_ip = backtrace_new_unresolved_should_start_with_call_site_trace as usize; + println!("this_ip: {:?}", this_ip as *const usize); + let frame_ip = b.frames().first().unwrap().symbol_address() as usize; + assert_eq!(this_ip, frame_ip); +} + +#[test] +fn backtrace_new_should_start_with_call_site_trace() { + if !ENABLED { + return; + } + let b = Backtrace::new(); + println!("{:?}", b); + + assert!(!b.frames().is_empty()); + + let this_ip = backtrace_new_should_start_with_call_site_trace as usize; + let frame_ip = b.frames().first().unwrap().symbol_address() as usize; + assert_eq!(this_ip, frame_ip); +} diff --git a/third_party/cargo/vendor/backtrace-0.3.42/tests/smoke.rs b/third_party/cargo/vendor/backtrace-0.3.42/tests/smoke.rs new file mode 100644 index 0000000..7f90d29 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-0.3.42/tests/smoke.rs @@ -0,0 +1,250 @@ +extern crate backtrace; + +use backtrace::Frame; +use std::thread; + +static LIBUNWIND: bool = cfg!(all(unix, feature = "libunwind")); +static UNIX_BACKTRACE: bool = cfg!(all(unix, feature = "unix-backtrace")); +static LIBBACKTRACE: bool = cfg!(feature = "libbacktrace") && !cfg!(target_os = "fuchsia"); +static CORESYMBOLICATION: bool = cfg!(all( + any(target_os = "macos", target_os = "ios"), + feature = "coresymbolication" +)); +static DLADDR: bool = cfg!(all(unix, feature = "dladdr")) && !cfg!(target_os = "fuchsia"); +static DBGHELP: bool = cfg!(all(windows, feature = "dbghelp")); +static MSVC: bool = cfg!(target_env = "msvc"); +static GIMLI_SYMBOLIZE: bool = cfg!(all(feature = "gimli-symbolize", unix, target_os = "linux")); + +#[test] +// FIXME: shouldn't ignore this test on i686-msvc, unsure why it's failing +#[cfg_attr(all(target_arch = "x86", target_env = "msvc"), ignore)] +#[rustfmt::skip] // we care about line numbers here +fn smoke_test_frames() { + frame_1(line!()); + #[inline(never)] fn frame_1(start_line: u32) { frame_2(start_line) } + #[inline(never)] fn frame_2(start_line: u32) { frame_3(start_line) } + #[inline(never)] fn frame_3(start_line: u32) { frame_4(start_line) } + #[inline(never)] fn frame_4(start_line: u32) { + let mut v = Vec::new(); + backtrace::trace(|cx| { + v.push(cx.clone()); + true + }); + + if v.len() < 5 { + assert!(!LIBUNWIND); + assert!(!UNIX_BACKTRACE); + assert!(!DBGHELP); + return; + } + + // Various platforms have various bits of weirdness about their + // backtraces. To find a good starting spot let's search through the + // frames + let target = frame_4 as usize; + let offset = v + .iter() + .map(|frame| frame.symbol_address() as usize) + .enumerate() + .filter_map(|(i, sym)| { + if sym >= target { + Some((sym, i)) + } else { + None + } + }) + .min() + .unwrap() + .1; + let mut frames = v[offset..].iter(); + + assert_frame( + frames.next().unwrap(), + frame_4 as usize, + "frame_4", + "tests/smoke.rs", + start_line + 6, + ); + assert_frame( + frames.next().unwrap(), + frame_3 as usize, + "frame_3", + "tests/smoke.rs", + start_line + 3, + ); + assert_frame( + frames.next().unwrap(), + frame_2 as usize, + "frame_2", + "tests/smoke.rs", + start_line + 2, + ); + assert_frame( + frames.next().unwrap(), + frame_1 as usize, + "frame_1", + "tests/smoke.rs", + start_line + 1, + ); + assert_frame( + frames.next().unwrap(), + smoke_test_frames as usize, + "smoke_test_frames", + "", + 0, + ); + } + + fn assert_frame( + frame: &Frame, + actual_fn_pointer: usize, + expected_name: &str, + expected_file: &str, + expected_line: u32, + ) { + backtrace::resolve_frame(frame, |sym| { + print!("symbol ip:{:?} address:{:?} ", frame.ip(), frame.symbol_address()); + if let Some(name) = sym.name() { + print!("name:{} ", name); + } + if let Some(file) = sym.filename() { + print!("file:{} ", file.display()); + } + if let Some(lineno) = sym.lineno() { + print!("lineno:{} ", lineno); + } + println!(); + }); + + let ip = frame.ip() as usize; + let sym = frame.symbol_address() as usize; + assert!(ip >= sym); + assert!( + sym >= actual_fn_pointer, + "{:?} < {:?} ({} {}:{})", + sym as *const usize, + actual_fn_pointer as *const usize, + expected_name, + expected_file, + expected_line, + ); + + // windows dbghelp is *quite* liberal (and wrong) in many of its reports + // right now... + // + // This assertion can also fail for release builds, so skip it there + if !DBGHELP && cfg!(debug_assertions) { + assert!(sym - actual_fn_pointer < 1024); + } + + let mut resolved = 0; + let can_resolve = DLADDR || LIBBACKTRACE || CORESYMBOLICATION || DBGHELP || GIMLI_SYMBOLIZE; + + let mut name = None; + let mut addr = None; + let mut line = None; + let mut file = None; + backtrace::resolve_frame(frame, |sym| { + resolved += 1; + name = sym.name().map(|v| v.to_string()); + addr = sym.addr(); + line = sym.lineno(); + file = sym.filename().map(|v| v.to_path_buf()); + }); + + // dbghelp doesn't always resolve symbols right now + match resolved { + 0 => return assert!(!can_resolve || DBGHELP), + _ => {} + } + + // * linux dladdr doesn't work (only consults local symbol table) + // * windows dbghelp isn't great for GNU + if can_resolve && !(cfg!(target_os = "linux") && DLADDR) && !(DBGHELP && !MSVC) { + let name = name.expect("didn't find a name"); + + // in release mode names get weird as functions can get merged + // together with `mergefunc`, so only assert this in debug mode + if cfg!(debug_assertions) { + assert!( + name.contains(expected_name), + "didn't find `{}` in `{}`", + expected_name, + name + ); + } + } + + if can_resolve { + addr.expect("didn't find a symbol"); + } + + if (LIBBACKTRACE || CORESYMBOLICATION || (DBGHELP && MSVC)) && cfg!(debug_assertions) { + let line = line.expect("didn't find a line number"); + let file = file.expect("didn't find a line number"); + if !expected_file.is_empty() { + assert!( + file.ends_with(expected_file), + "{:?} didn't end with {:?}", + file, + expected_file + ); + } + if expected_line != 0 { + assert!( + line == expected_line, + "bad line number on frame for `{}`: {} != {}", + expected_name, + line, + expected_line + ); + } + } + } +} + +#[test] +fn many_threads() { + let threads = (0..16) + .map(|_| { + thread::spawn(|| { + for _ in 0..16 { + backtrace::trace(|frame| { + backtrace::resolve(frame.ip(), |symbol| { + let _s = symbol.name().map(|s| s.to_string()); + }); + true + }); + } + }) + }) + .collect::>(); + + for t in threads { + t.join().unwrap() + } +} + +#[test] +#[cfg(feature = "rustc-serialize")] +fn is_rustc_serialize() { + extern crate rustc_serialize; + + fn is_encode() {} + fn is_decode() {} + + is_encode::(); + is_decode::(); +} + +#[test] +#[cfg(feature = "serde")] +fn is_serde() { + extern crate serde; + + fn is_serialize() {} + fn is_deserialize() {} + + is_serialize::(); + is_deserialize::(); +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/.cargo-checksum.json b/third_party/cargo/vendor/backtrace-sys-0.1.32/.cargo-checksum.json new file mode 100644 index 0000000..0402f21 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"df39822caf0fd2b9b001e5834db300fa9dc731060649195f10f34b0ffe912542","build.rs":"d0803fc2f1fa92b567df1188efceb7f9158b1422fc2227e7d0c779821a509e2e","src/android-api.c":"b75f16de578451464f49b83dc817b76aa9a0be0d86ea71d1659cc78f99e94fbd","src/lib.rs":"ccd15703f469cb10d620a30a1accd8834e8012abab5b626f925777275d6d2b02","src/libbacktrace/LICENSE":"ef8a9b3247488f8901ca60de9b17b745d7bd67e5ec1e622f80d62364572200d8","src/libbacktrace/Makefile.am":"5353e0ce3a4732b42ccf031c474f7234336992cb23ba76cbfda3aa5262e69988","src/libbacktrace/Makefile.in":"1802d55fa8ef616a407c69311b3fa4e579093d124a215c834149ab1c50b4f3ad","src/libbacktrace/Mark.Twain-Tom.Sawyer.txt":"461eb7cb2d57d293fc680c836464c9125e4382be3596f7d415093ae9db8fcb0e","src/libbacktrace/README.md":"3b27ca2f7ddaf464ad81366a278ed4d34ad513de3766b330a51464828fa3131f","src/libbacktrace/acinclude.m4":"7f1d64805039b0e41d4c4106265618a6f8921d3cf091d64ab31fa7b900dc892f","src/libbacktrace/aclocal.m4":"4899cfe70722ba1de2b42b4e9965c1db1b173b5d6d4522cdc785becd5a5c212c","src/libbacktrace/alloc.c":"33891bbaf755c050058f8fd7dd3708e6062ef65245a0717216af45b78bab0fd0","src/libbacktrace/atomic.c":"82fd23c7ee7154d1ce4fc823637ede9cfa0e469f4073f38fff4dd9081070f1aa","src/libbacktrace/backtrace-supported.h.in":"42277f3c383386b6cfa3d3d889336e92303fac0ae1a9fb8a6a56737245dfb8f3","src/libbacktrace/backtrace.c":"837ea7b781a737d1ed37e4d03c463bcbe1432b2dc3b79b37344b21013cdfcca4","src/libbacktrace/backtrace.h":"9f035b3830c1c6000259c8ecf0bf53144f7c2e6064dfc95975b89f7f612ebf0e","src/libbacktrace/btest.c":"41c774496d58177e408b1dc33d6a792d0940634885978eed73fb192f732cafc5","src/libbacktrace/config.guess":"9be3de218833c076786b919dc34aab691611f4cd73316e7705f2673e2c41921b","src/libbacktrace/config.h.in":"b5002d9f96f6a26f54317f9d23a5ffff71fa3ee520fd8993810891d43b9a9bf7","src/libbacktrace/config.sub":"c8e70ab53f04d2f2b0280aa0e8a5432e90a902bfa2af7b0854168eb1fb3a84c0","src/libbacktrace/config/libtool.m4":"644ce34d5e9fcc544f3ef5c707f4cb29add798bbfc24e29932b55fb251e50353","src/libbacktrace/config/ltoptions.m4":"9d294950c4d97e2c891d472933113f397d410ef2a8ed875d714f81761626bbd8","src/libbacktrace/config/ltsugar.m4":"2c6618a04aa6389a2a528cde2e69ed5de55acc6c50892b486ea3e56e4e5b2c3b","src/libbacktrace/config/ltversion.m4":"8d129a46367fadad9f202dac50e708696d4d628313d01745127388e9c736e996","src/libbacktrace/config/lt~obsolete.m4":"c6c668594337aafef7d59f585bce7010436153815fe341461d81301a2235b959","src/libbacktrace/configure":"59763fc255248b54fba5d0761d61093a73d51fa4cb400b0df1b5f339b9c2f48a","src/libbacktrace/configure.ac":"b9292548330eb4d2cb014e9d9e6cd4df656aed982917365896a8f2534e9732e5","src/libbacktrace/dwarf.c":"c2103af5f94dd135e5df2a98dfc28ef2cbe0f3d56783d21e1487b9f314bfcbbc","src/libbacktrace/edtest.c":"947b9878ae45f6ba95d3b949bb080e9feed4ffdb27536cf5602b81ce79556ccf","src/libbacktrace/edtest2.c":"964bb0bb510a19013fb1cb56552929ed15cf55787eba4369d5820b74be07d249","src/libbacktrace/elf.c":"fe3e10d33c0c0965f016381302128ce82d664071095ad5077932377e3a789679","src/libbacktrace/fileline.c":"7b3b92044648f45becc498d4ed41ddc8ec08f0d11f6491cc05cfccd8a4d7627a","src/libbacktrace/filenames.h":"2c23cde7dd12dd9e0343cb37b5066036112deca703b61178f07c01f3e01398c9","src/libbacktrace/filetype.awk":"aa38776487a77dc13c93efa2a861204b384c3c4333501ed9bdb4ccbde2a784c0","src/libbacktrace/install-sh":"e7064b5e01a8d173409749c337966698fa04661cde1e3ef1a93be250eec0d2c3","src/libbacktrace/internal.h":"88c63ad6acc7e68330df3028675be4d4e3374bd787255fe22dd3febbbbc438b6","src/libbacktrace/ltmain.sh":"873bdcbc8690bd90c0f3632aac40027e880fd95ea45fb5a02ed901fea4afa4fe","src/libbacktrace/macho.c":"9a8864901eede4c34305b05bb6e815b25b76f04b59caf74381ca9dfbe8f1a8c4","src/libbacktrace/missing":"300bea3fb273b763eca2e4bb1576c663605d9b49de385fd375f82be8d912f506","src/libbacktrace/mmap.c":"5be917f3e9eba1fe49eb1bb391e28609e8377b4ce4593cace6012bf17434a33c","src/libbacktrace/mmapio.c":"be5719c4f92e70045fe6014a0493a5b4adc165ecde42c20130ea6e9da1ce978f","src/libbacktrace/move-if-change":"689762b92d23003926ba729acf98b9a109abf46de0698c09ddfa0d20490d8af5","src/libbacktrace/nounwind.c":"5eee9cc7298b7d0d2aea68eef62175541f34f88acf17736e0612056c5bb7318d","src/libbacktrace/pecoff.c":"bb536ae71a1a1c4dad5508d26032e7e81860df6d8ddfc8d696378ebefbc513b1","src/libbacktrace/posix.c":"f5e0ff701a1a1e29a25462ea49f174b049dafc6c25e040ee0eb77dd189353277","src/libbacktrace/print.c":"2d446406c8e2d9a1258d46d119be1c563bd86b6a4039cbf773b6de09c541390d","src/libbacktrace/read.c":"d0d4007f681f265a6c31e27ded45f4007502c90464eefdb4e80b69e4ae2ede28","src/libbacktrace/simple.c":"b0f767d3740195015aeadaa67e84bf6eb255a730f258485ca86bdbe02b066eca","src/libbacktrace/sort.c":"a82f911fc826a353ea5616379748dfa318ad4e57e20791af7ead853f7e73583d","src/libbacktrace/state.c":"a45abbe4077a47d17fb9687057c40828e633df12d21b8ed40b71a78d86918100","src/libbacktrace/stest.c":"7443fe435f1ee5ce49a3e634faf81a4137d66a057577fe88a211cfa819ddb2e2","src/libbacktrace/testlib.c":"a7e096e895b36db7f997a6673ce48f92a032046876511e813a8a52de6079b29a","src/libbacktrace/testlib.h":"02e02404dc89dd4f3dd82635f794a927541dd78d490d777bedf8a5424e5033fc","src/libbacktrace/ttest.c":"380f3b2be164bd6770768181fa05f1778cee8f0322434896d19724ae7cd105df","src/libbacktrace/unknown.c":"d2d148ea045dcad96ba1c5528b7036b000eeb8439ae397bca01deb0d8b287972","src/libbacktrace/xcoff.c":"e70ed97743306f71ea6132a058d68f1bb7be1380a2d38725b5dc877f5e07905d","src/libbacktrace/ztest.c":"7ad8277664e596aecb6af25818b7671e199ef6002ec2c38d9288179c5cad2082"},"package":"5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491"} \ No newline at end of file diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/BUILD b/third_party/cargo/vendor/backtrace-sys-0.1.32/BUILD new file mode 100644 index 0000000..60b6fc1 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "backtrace_sys", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.32", + crate_features = [ + ], +) + +# Unsupported target "build-script-build" with type "custom-build" omitted diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/Cargo.toml b/third_party/cargo/vendor/backtrace-sys-0.1.32/Cargo.toml new file mode 100644 index 0000000..4e724a7 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/Cargo.toml @@ -0,0 +1,39 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "backtrace-sys" +version = "0.1.32" +authors = ["Alex Crichton "] +build = "build.rs" +description = "Bindings to the libbacktrace gcc library\n" +homepage = "https://github.com/alexcrichton/backtrace-rs" +documentation = "http://alexcrichton.com/backtrace-rs" +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/backtrace-rs" +[dependencies.compiler_builtins] +version = "0.1.2" +optional = true + +[dependencies.core] +version = "1.0.0" +optional = true +package = "rustc-std-workspace-core" + +[dependencies.libc] +version = "0.2" +default-features = false +[build-dependencies.cc] +version = "1.0.37" + +[features] +rustc-dep-of-std = ["core", "compiler_builtins"] diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/build.rs b/third_party/cargo/vendor/backtrace-sys-0.1.32/build.rs new file mode 100644 index 0000000..9e4dff5 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/build.rs @@ -0,0 +1,155 @@ +extern crate cc; + +use std::env; +use std::fs::File; +use std::path::PathBuf; + +fn main() { + let target = env::var("TARGET").unwrap(); + + if target.contains("msvc") || // libbacktrace isn't used on MSVC windows + target.contains("emscripten") || // no way this will ever compile for emscripten + target.contains("cloudabi") || + target.contains("wasm32") || + target.contains("fuchsia") + // fuchsia uses external out-of-process symbolization + { + println!("cargo:rustc-cfg=empty"); + return; + } + + let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + + let mut build = cc::Build::new(); + build + .include("src/libbacktrace") + .include(&out_dir) + .warnings(false) + .file("src/libbacktrace/alloc.c") + .file("src/libbacktrace/dwarf.c") + .file("src/libbacktrace/fileline.c") + .file("src/libbacktrace/posix.c") + .file("src/libbacktrace/read.c") + .file("src/libbacktrace/sort.c") + .file("src/libbacktrace/state.c"); + + // No need to have any symbols reexported form shared objects + build.flag("-fvisibility=hidden"); + + if target.contains("darwin") { + build.file("src/libbacktrace/macho.c"); + } else if target.contains("windows") { + build.file("src/libbacktrace/pecoff.c"); + } else { + build.file("src/libbacktrace/elf.c"); + + let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap(); + if pointer_width == "64" { + build.define("BACKTRACE_ELF_SIZE", "64"); + } else { + build.define("BACKTRACE_ELF_SIZE", "32"); + } + } + + File::create(out_dir.join("backtrace-supported.h")).unwrap(); + build.define("BACKTRACE_SUPPORTED", "1"); + build.define("BACKTRACE_USES_MALLOC", "1"); + build.define("BACKTRACE_SUPPORTS_THREADS", "0"); + build.define("BACKTRACE_SUPPORTS_DATA", "0"); + + File::create(out_dir.join("config.h")).unwrap(); + if target.contains("android") { + maybe_enable_dl_iterate_phdr_android(&mut build); + } else if !target.contains("apple-ios") + && !target.contains("solaris") + && !target.contains("redox") + && !target.contains("haiku") + && !target.contains("vxworks") + { + build.define("HAVE_DL_ITERATE_PHDR", "1"); + } + build.define("_GNU_SOURCE", "1"); + build.define("_LARGE_FILES", "1"); + + // When we're built as part of the Rust compiler, this is used to enable + // debug information in libbacktrace itself. + let any_debug = env::var("RUSTC_DEBUGINFO").unwrap_or_default() == "true" + || env::var("RUSTC_DEBUGINFO_LINES").unwrap_or_default() == "true"; + build.debug(any_debug); + + let syms = [ + "backtrace_full", + "backtrace_dwarf_add", + "backtrace_initialize", + "backtrace_pcinfo", + "backtrace_syminfo", + "backtrace_get_view", + "backtrace_release_view", + "backtrace_alloc", + "backtrace_free", + "backtrace_vector_finish", + "backtrace_vector_grow", + "backtrace_vector_release", + "backtrace_close", + "backtrace_open", + "backtrace_print", + "backtrace_simple", + "backtrace_qsort", + "backtrace_create_state", + "backtrace_uncompress_zdebug", + // These should be `static` in C, but they aren't... + "macho_get_view", + "macho_symbol_type_relevant", + "macho_get_commands", + "macho_try_dsym", + "macho_try_dwarf", + "macho_get_addr_range", + "macho_get_uuid", + "macho_add", + "macho_add_symtab", + "macho_file_to_host_u64", + "macho_file_to_host_u32", + "macho_file_to_host_u16", + ]; + let prefix = if cfg!(feature = "rustc-dep-of-std") { + println!("cargo:rustc-cfg=rdos"); + "__rdos_" + } else { + println!("cargo:rustc-cfg=rbt"); + "__rbt_" + }; + for sym in syms.iter() { + build.define(sym, &format!("{}{}", prefix, sym)[..]); + } + + build.compile("backtrace"); +} + +// The `dl_iterate_phdr` API was added in Android API 21+ (according to #227), +// so if we can dynamically detect an appropriately configured C compiler for +// that then let's enable the `dl_iterate_phdr` API, otherwise Android just +// won't have any information. +fn maybe_enable_dl_iterate_phdr_android(build: &mut cc::Build) { + let expansion = cc::Build::new().file("src/android-api.c").expand(); + let expansion = match std::str::from_utf8(&expansion) { + Ok(s) => s, + Err(_) => return, + }; + println!("expanded android version detection:\n{}", expansion); + let marker = "APIVERSION"; + let i = match expansion.find(marker) { + Some(i) => i, + None => return, + }; + let version = match expansion[i + marker.len() + 1..].split_whitespace().next() { + Some(s) => s, + None => return, + }; + let version = match version.parse::() { + Ok(n) => n, + Err(_) => return, + }; + if version >= 21 { + build.define("HAVE_DL_ITERATE_PHDR", "1"); + } +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/android-api.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/android-api.c new file mode 100644 index 0000000..1bfeadf --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/android-api.c @@ -0,0 +1,4 @@ +// Used from the build script to detect the value of the `__ANDROID_API__` +// builtin #define + +APIVERSION __ANDROID_API__ diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/lib.rs b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/lib.rs new file mode 100644 index 0000000..98a54c3 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/lib.rs @@ -0,0 +1,58 @@ +#![allow(bad_style)] +#![no_std] + +extern crate libc; + +#[cfg(not(empty))] +pub use self::bindings::*; +#[cfg(not(empty))] +mod bindings { + use libc::{c_char, c_int, c_void, uintptr_t}; + + pub type backtrace_syminfo_callback = extern "C" fn( + data: *mut c_void, + pc: uintptr_t, + symname: *const c_char, + symval: uintptr_t, + symsize: uintptr_t, + ); + pub type backtrace_full_callback = extern "C" fn( + data: *mut c_void, + pc: uintptr_t, + filename: *const c_char, + lineno: c_int, + function: *const c_char, + ) -> c_int; + pub type backtrace_error_callback = + extern "C" fn(data: *mut c_void, msg: *const c_char, errnum: c_int); + pub enum backtrace_state {} + + extern "C" { + #[cfg_attr(rdos, link_name = "__rdos_backtrace_create_state")] + #[cfg_attr(rbt, link_name = "__rbt_backtrace_create_state")] + pub fn backtrace_create_state( + filename: *const c_char, + threaded: c_int, + error: backtrace_error_callback, + data: *mut c_void, + ) -> *mut backtrace_state; + #[cfg_attr(rdos, link_name = "__rdos_backtrace_syminfo")] + #[cfg_attr(rbt, link_name = "__rbt_backtrace_syminfo")] + pub fn backtrace_syminfo( + state: *mut backtrace_state, + addr: uintptr_t, + cb: backtrace_syminfo_callback, + error: backtrace_error_callback, + data: *mut c_void, + ) -> c_int; + #[cfg_attr(rdos, link_name = "__rdos_backtrace_pcinfo")] + #[cfg_attr(rbt, link_name = "__rbt_backtrace_pcinfo")] + pub fn backtrace_pcinfo( + state: *mut backtrace_state, + addr: uintptr_t, + cb: backtrace_full_callback, + error: backtrace_error_callback, + data: *mut c_void, + ) -> c_int; + } +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/LICENSE b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/LICENSE new file mode 100644 index 0000000..097d277 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/LICENSE @@ -0,0 +1,29 @@ +# Copyright (C) 2012-2016 Free Software Foundation, Inc. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: + +# (1) Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. + +# (2) Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. + +# (3) The name of the author may not be used to +# endorse or promote products derived from this software without +# specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/Makefile.am b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/Makefile.am new file mode 100644 index 0000000..56a3d1b --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/Makefile.am @@ -0,0 +1,206 @@ +# Makefile.am -- Backtrace Makefile. +# Copyright (C) 2012-2018 Free Software Foundation, Inc. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: + +# (1) Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. + +# (2) Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. + +# (3) The name of the author may not be used to +# endorse or promote products derived from this software without +# specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +ACLOCAL_AMFLAGS = -I config + +AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG) + +include_HEADERS = backtrace.h backtrace-supported.h + +lib_LTLIBRARIES = libbacktrace.la + +libbacktrace_la_SOURCES = \ + backtrace.h \ + atomic.c \ + dwarf.c \ + fileline.c \ + internal.h \ + posix.c \ + print.c \ + sort.c \ + state.c + +BACKTRACE_FILES = \ + backtrace.c \ + simple.c \ + nounwind.c + +FORMAT_FILES = \ + elf.c \ + pecoff.c \ + unknown.c \ + xcoff.c + +VIEW_FILES = \ + read.c \ + mmapio.c + +ALLOC_FILES = \ + alloc.c \ + mmap.c + +EXTRA_libbacktrace_la_SOURCES = \ + $(BACKTRACE_FILES) \ + $(FORMAT_FILES) \ + $(VIEW_FILES) \ + $(ALLOC_FILES) + +libbacktrace_la_LIBADD = \ + $(BACKTRACE_FILE) \ + $(FORMAT_FILE) \ + $(VIEW_FILE) \ + $(ALLOC_FILE) + +libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD) + +# Testsuite. + +check_PROGRAMS = +CLEANFILES = + +TESTS = $(check_PROGRAMS) + +if NATIVE + +btest_SOURCES = btest.c testlib.c +btest_CFLAGS = $(AM_CFLAGS) -g -O +btest_LDADD = libbacktrace.la + +check_PROGRAMS += btest + +btest_static_SOURCES = btest.c testlib.c +btest_static_CFLAGS = $(AM_CFLAGS) -g -O +btest_static_LDADD = libbacktrace.la +btest_static_LDFLAGS = -static-libtool-libs + +check_PROGRAMS += btest_static + +stest_SOURCES = stest.c +stest_LDADD = libbacktrace.la + +check_PROGRAMS += stest + +ztest_SOURCES = ztest.c testlib.c +ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\" +ztest_LDADD = libbacktrace.la + +if HAVE_ZLIB +ztest_LDADD += -lz +endif +ztest_LDADD += $(CLOCK_GETTIME_LINK) + +check_PROGRAMS += ztest + +edtest_SOURCES = edtest.c edtest2_build.c testlib.c +edtest_LDADD = libbacktrace.la + +check_PROGRAMS += edtest + +edtest2_build.c: gen_edtest2_build; @true +gen_edtest2_build: $(srcdir)/edtest2.c + cat $(srcdir)/edtest2.c > tmp-edtest2_build.c + $(SHELL) $(srcdir)/move-if-change tmp-edtest2_build.c edtest2_build.c + echo timestamp > $@ + +CLEANFILES += edtest2_build.c gen_edtest2_build + +if HAVE_PTHREAD + +check_PROGRAMS += ttest + +ttest_SOURCES = ttest.c testlib.c +ttest_CFLAGS = $(AM_CFLAGS) -pthread +ttest_LDADD = libbacktrace.la + +endif HAVE_PTHREAD + +if HAVE_OBJCOPY_DEBUGLINK + +TESTS += dtest + +dtest: btest_static + $(OBJCOPY) --only-keep-debug btest_static btest.debug + $(OBJCOPY) --strip-debug --add-gnu-debuglink=btest.debug btest_static dtest + +CLEANFILES += dtest btest.debug + +endif HAVE_OBJCOPY_DEBUGLINK + +if HAVE_COMPRESSED_DEBUG + +ctestg_SOURCES = btest.c testlib.c +ctestg_CFLAGS = $(AM_CFLAGS) -g +ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu +ctestg_LDADD = libbacktrace.la + +ctesta_SOURCES = btest.c testlib.c +ctesta_CFLAGS = $(AM_CFLAGS) -g +ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi +ctesta_LDADD = libbacktrace.la + +check_PROGRAMS += ctestg ctesta + +endif + +endif NATIVE + +# We can't use automake's automatic dependency tracking, because it +# breaks when using bootstrap-lean. Automatic dependency tracking +# with GCC bootstrap will cause some of the objects to depend on +# header files in prev-gcc/include, e.g., stddef.h and stdarg.h. When +# using bootstrap-lean, prev-gcc is removed after each stage. When +# running "make install", those header files will be gone, causing the +# library to be rebuilt at install time. That may not succeed. + +# These manual dependencies do not include dependencies on unwind.h, +# even though that is part of GCC, because where to find it depends on +# whether we are being built as a host library or a target library. + +alloc.lo: config.h backtrace.h internal.h +backtrace.lo: config.h backtrace.h internal.h +btest.lo: backtrace.h backtrace-supported.h filenames.h +dwarf.lo: config.h filenames.h backtrace.h internal.h +elf.lo: config.h backtrace.h internal.h +fileline.lo: config.h backtrace.h internal.h +mmap.lo: config.h backtrace.h internal.h +mmapio.lo: config.h backtrace.h internal.h +nounwind.lo: config.h internal.h +pecoff.lo: config.h backtrace.h internal.h +posix.lo: config.h backtrace.h internal.h +print.lo: config.h backtrace.h internal.h +read.lo: config.h backtrace.h internal.h +simple.lo: config.h backtrace.h internal.h +sort.lo: config.h backtrace.h internal.h +stest.lo: config.h backtrace.h internal.h +state.lo: config.h backtrace.h backtrace-supported.h internal.h +unknown.lo: config.h backtrace.h internal.h +xcoff.lo: config.h backtrace.h internal.h + diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/Makefile.in b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/Makefile.in new file mode 100644 index 0000000..498f7fb --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/Makefile.in @@ -0,0 +1,1021 @@ +# Makefile.in generated by automake 1.11.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Makefile.am -- Backtrace Makefile. +# Copyright (C) 2012-2018 Free Software Foundation, Inc. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: + +# (1) Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. + +# (2) Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. + +# (3) The name of the author may not be used to +# endorse or promote products derived from this software without +# specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) +@NATIVE_TRUE@am__append_1 = btest btest_static stest ztest edtest +@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_2 = -lz +@NATIVE_TRUE@am__append_3 = edtest2_build.c gen_edtest2_build +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_4 = ttest +@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_5 = dtest +@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_6 = dtest btest.debug +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_7 = ctestg ctesta +subdir = . +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/configure $(am__configure_deps) \ + $(srcdir)/config.h.in $(srcdir)/backtrace-supported.h.in \ + $(include_HEADERS) +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/config/libtool.m4 \ + $(top_srcdir)/config/ltoptions.m4 \ + $(top_srcdir)/config/ltsugar.m4 \ + $(top_srcdir)/config/ltversion.m4 \ + $(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = backtrace-supported.h +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +am__DEPENDENCIES_1 = +am_libbacktrace_la_OBJECTS = atomic.lo dwarf.lo fileline.lo posix.lo \ + print.lo sort.lo state.lo +libbacktrace_la_OBJECTS = $(am_libbacktrace_la_OBJECTS) +@NATIVE_TRUE@am__EXEEXT_1 = btest$(EXEEXT) btest_static$(EXEEXT) \ +@NATIVE_TRUE@ stest$(EXEEXT) ztest$(EXEEXT) edtest$(EXEEXT) +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = ttest$(EXEEXT) +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_3 = \ +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctestg$(EXEEXT) \ +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctesta$(EXEEXT) +@NATIVE_TRUE@am_btest_OBJECTS = btest-btest.$(OBJEXT) \ +@NATIVE_TRUE@ btest-testlib.$(OBJEXT) +btest_OBJECTS = $(am_btest_OBJECTS) +@NATIVE_TRUE@btest_DEPENDENCIES = libbacktrace.la +btest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(btest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +@NATIVE_TRUE@am_btest_static_OBJECTS = btest_static-btest.$(OBJEXT) \ +@NATIVE_TRUE@ btest_static-testlib.$(OBJEXT) +btest_static_OBJECTS = $(am_btest_static_OBJECTS) +@NATIVE_TRUE@btest_static_DEPENDENCIES = libbacktrace.la +btest_static_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(btest_static_CFLAGS) \ + $(CFLAGS) $(btest_static_LDFLAGS) $(LDFLAGS) -o $@ +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am_ctesta_OBJECTS = ctesta-btest.$(OBJEXT) \ +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctesta-testlib.$(OBJEXT) +ctesta_OBJECTS = $(am_ctesta_OBJECTS) +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_DEPENDENCIES = \ +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ libbacktrace.la +ctesta_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(ctesta_CFLAGS) $(CFLAGS) \ + $(ctesta_LDFLAGS) $(LDFLAGS) -o $@ +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am_ctestg_OBJECTS = ctestg-btest.$(OBJEXT) \ +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctestg-testlib.$(OBJEXT) +ctestg_OBJECTS = $(am_ctestg_OBJECTS) +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_DEPENDENCIES = \ +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ libbacktrace.la +ctestg_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(ctestg_CFLAGS) $(CFLAGS) \ + $(ctestg_LDFLAGS) $(LDFLAGS) -o $@ +@NATIVE_TRUE@am_edtest_OBJECTS = edtest.$(OBJEXT) \ +@NATIVE_TRUE@ edtest2_build.$(OBJEXT) testlib.$(OBJEXT) +edtest_OBJECTS = $(am_edtest_OBJECTS) +@NATIVE_TRUE@edtest_DEPENDENCIES = libbacktrace.la +@NATIVE_TRUE@am_stest_OBJECTS = stest.$(OBJEXT) +stest_OBJECTS = $(am_stest_OBJECTS) +@NATIVE_TRUE@stest_DEPENDENCIES = libbacktrace.la +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am_ttest_OBJECTS = \ +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ ttest-ttest.$(OBJEXT) \ +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ ttest-testlib.$(OBJEXT) +ttest_OBJECTS = $(am_ttest_OBJECTS) +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_DEPENDENCIES = libbacktrace.la +ttest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(ttest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +@NATIVE_TRUE@am_ztest_OBJECTS = ztest-ztest.$(OBJEXT) \ +@NATIVE_TRUE@ ztest-testlib.$(OBJEXT) +ztest_OBJECTS = $(am_ztest_OBJECTS) +@NATIVE_TRUE@ztest_DEPENDENCIES = libbacktrace.la \ +@NATIVE_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +ztest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(ztest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = +am__depfiles_maybe = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \ + $(btest_SOURCES) $(btest_static_SOURCES) $(ctesta_SOURCES) \ + $(ctestg_SOURCES) $(edtest_SOURCES) $(stest_SOURCES) \ + $(ttest_SOURCES) $(ztest_SOURCES) +MULTISRCTOP = +MULTIBUILDTOP = +MULTIDIRS = +MULTISUBDIR = +MULTIDO = true +MULTICLEAN = true +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(include_HEADERS) +ETAGS = etags +CTAGS = ctags +am__tty_colors = \ +red=; grn=; lgn=; blu=; std= +ACLOCAL = @ACLOCAL@ +ALLOC_FILE = @ALLOC_FILE@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BACKTRACE_FILE = @BACKTRACE_FILE@ +BACKTRACE_SUPPORTED = @BACKTRACE_SUPPORTED@ +BACKTRACE_SUPPORTS_DATA = @BACKTRACE_SUPPORTS_DATA@ +BACKTRACE_SUPPORTS_THREADS = @BACKTRACE_SUPPORTS_THREADS@ +BACKTRACE_USES_MALLOC = @BACKTRACE_USES_MALLOC@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_FLAGS = @EXTRA_FLAGS@ +FGREP = @FGREP@ +FORMAT_FILE = @FORMAT_FILE@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJCOPY = @OBJCOPY@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PIC_FLAG = @PIC_FLAG@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +VIEW_FILE = @VIEW_FILE@ +WARN_FLAGS = @WARN_FLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +libtool_VERSION = @libtool_VERSION@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +multi_basedir = @multi_basedir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +ACLOCAL_AMFLAGS = -I config +AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG) +include_HEADERS = backtrace.h backtrace-supported.h +lib_LTLIBRARIES = libbacktrace.la +libbacktrace_la_SOURCES = \ + backtrace.h \ + atomic.c \ + dwarf.c \ + fileline.c \ + internal.h \ + posix.c \ + print.c \ + sort.c \ + state.c + +BACKTRACE_FILES = \ + backtrace.c \ + simple.c \ + nounwind.c + +FORMAT_FILES = \ + elf.c \ + pecoff.c \ + unknown.c \ + xcoff.c + +VIEW_FILES = \ + read.c \ + mmapio.c + +ALLOC_FILES = \ + alloc.c \ + mmap.c + +EXTRA_libbacktrace_la_SOURCES = \ + $(BACKTRACE_FILES) \ + $(FORMAT_FILES) \ + $(VIEW_FILES) \ + $(ALLOC_FILES) + +libbacktrace_la_LIBADD = \ + $(BACKTRACE_FILE) \ + $(FORMAT_FILE) \ + $(VIEW_FILE) \ + $(ALLOC_FILE) + +libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD) +CLEANFILES = $(am__append_3) $(am__append_6) +TESTS = $(check_PROGRAMS) $(am__append_5) +@NATIVE_TRUE@btest_SOURCES = btest.c testlib.c +@NATIVE_TRUE@btest_CFLAGS = $(AM_CFLAGS) -g -O +@NATIVE_TRUE@btest_LDADD = libbacktrace.la +@NATIVE_TRUE@btest_static_SOURCES = btest.c testlib.c +@NATIVE_TRUE@btest_static_CFLAGS = $(AM_CFLAGS) -g -O +@NATIVE_TRUE@btest_static_LDADD = libbacktrace.la +@NATIVE_TRUE@btest_static_LDFLAGS = -static-libtool-libs +@NATIVE_TRUE@stest_SOURCES = stest.c +@NATIVE_TRUE@stest_LDADD = libbacktrace.la +@NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c +@NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\" +@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_2) \ +@NATIVE_TRUE@ $(CLOCK_GETTIME_LINK) +@NATIVE_TRUE@edtest_SOURCES = edtest.c edtest2_build.c testlib.c +@NATIVE_TRUE@edtest_LDADD = libbacktrace.la +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_SOURCES = ttest.c testlib.c +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_CFLAGS = $(AM_CFLAGS) -pthread +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_LDADD = libbacktrace.la +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_SOURCES = btest.c testlib.c +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_CFLAGS = $(AM_CFLAGS) -g +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_LDADD = libbacktrace.la +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_SOURCES = btest.c testlib.c +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_CFLAGS = $(AM_CFLAGS) -g +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDADD = libbacktrace.la +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign --ignore-deps'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign --ignore-deps \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign --ignore-deps Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign --ignore-deps Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @if test ! -f $@; then rm -f stamp-h1; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +backtrace-supported.h: $(top_builddir)/config.status $(srcdir)/backtrace-supported.h.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES) $(EXTRA_libbacktrace_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libbacktrace_la_OBJECTS) $(libbacktrace_la_LIBADD) $(LIBS) + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES) $(EXTRA_btest_DEPENDENCIES) + @rm -f btest$(EXEEXT) + $(btest_LINK) $(btest_OBJECTS) $(btest_LDADD) $(LIBS) +btest_static$(EXEEXT): $(btest_static_OBJECTS) $(btest_static_DEPENDENCIES) $(EXTRA_btest_static_DEPENDENCIES) + @rm -f btest_static$(EXEEXT) + $(btest_static_LINK) $(btest_static_OBJECTS) $(btest_static_LDADD) $(LIBS) +ctesta$(EXEEXT): $(ctesta_OBJECTS) $(ctesta_DEPENDENCIES) $(EXTRA_ctesta_DEPENDENCIES) + @rm -f ctesta$(EXEEXT) + $(ctesta_LINK) $(ctesta_OBJECTS) $(ctesta_LDADD) $(LIBS) +ctestg$(EXEEXT): $(ctestg_OBJECTS) $(ctestg_DEPENDENCIES) $(EXTRA_ctestg_DEPENDENCIES) + @rm -f ctestg$(EXEEXT) + $(ctestg_LINK) $(ctestg_OBJECTS) $(ctestg_LDADD) $(LIBS) +edtest$(EXEEXT): $(edtest_OBJECTS) $(edtest_DEPENDENCIES) $(EXTRA_edtest_DEPENDENCIES) + @rm -f edtest$(EXEEXT) + $(LINK) $(edtest_OBJECTS) $(edtest_LDADD) $(LIBS) +stest$(EXEEXT): $(stest_OBJECTS) $(stest_DEPENDENCIES) $(EXTRA_stest_DEPENDENCIES) + @rm -f stest$(EXEEXT) + $(LINK) $(stest_OBJECTS) $(stest_LDADD) $(LIBS) +ttest$(EXEEXT): $(ttest_OBJECTS) $(ttest_DEPENDENCIES) $(EXTRA_ttest_DEPENDENCIES) + @rm -f ttest$(EXEEXT) + $(ttest_LINK) $(ttest_OBJECTS) $(ttest_LDADD) $(LIBS) +ztest$(EXEEXT): $(ztest_OBJECTS) $(ztest_DEPENDENCIES) $(EXTRA_ztest_DEPENDENCIES) + @rm -f ztest$(EXEEXT) + $(ztest_LINK) $(ztest_OBJECTS) $(ztest_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +.c.o: + $(COMPILE) -c $< + +.c.obj: + $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: + $(LTCOMPILE) -c -o $@ $< + +btest-btest.o: btest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_CFLAGS) $(CFLAGS) -c -o btest-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c + +btest-btest.obj: btest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_CFLAGS) $(CFLAGS) -c -o btest-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi` + +btest-testlib.o: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_CFLAGS) $(CFLAGS) -c -o btest-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c + +btest-testlib.obj: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_CFLAGS) $(CFLAGS) -c -o btest-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi` + +btest_static-btest.o: btest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_static_CFLAGS) $(CFLAGS) -c -o btest_static-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c + +btest_static-btest.obj: btest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_static_CFLAGS) $(CFLAGS) -c -o btest_static-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi` + +btest_static-testlib.o: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_static_CFLAGS) $(CFLAGS) -c -o btest_static-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c + +btest_static-testlib.obj: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_static_CFLAGS) $(CFLAGS) -c -o btest_static-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi` + +ctesta-btest.o: btest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctesta_CFLAGS) $(CFLAGS) -c -o ctesta-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c + +ctesta-btest.obj: btest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctesta_CFLAGS) $(CFLAGS) -c -o ctesta-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi` + +ctesta-testlib.o: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctesta_CFLAGS) $(CFLAGS) -c -o ctesta-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c + +ctesta-testlib.obj: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctesta_CFLAGS) $(CFLAGS) -c -o ctesta-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi` + +ctestg-btest.o: btest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestg_CFLAGS) $(CFLAGS) -c -o ctestg-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c + +ctestg-btest.obj: btest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestg_CFLAGS) $(CFLAGS) -c -o ctestg-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi` + +ctestg-testlib.o: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestg_CFLAGS) $(CFLAGS) -c -o ctestg-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c + +ctestg-testlib.obj: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestg_CFLAGS) $(CFLAGS) -c -o ctestg-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi` + +ttest-ttest.o: ttest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ttest_CFLAGS) $(CFLAGS) -c -o ttest-ttest.o `test -f 'ttest.c' || echo '$(srcdir)/'`ttest.c + +ttest-ttest.obj: ttest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ttest_CFLAGS) $(CFLAGS) -c -o ttest-ttest.obj `if test -f 'ttest.c'; then $(CYGPATH_W) 'ttest.c'; else $(CYGPATH_W) '$(srcdir)/ttest.c'; fi` + +ttest-testlib.o: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ttest_CFLAGS) $(CFLAGS) -c -o ttest-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c + +ttest-testlib.obj: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ttest_CFLAGS) $(CFLAGS) -c -o ttest-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi` + +ztest-ztest.o: ztest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ztest_CFLAGS) $(CFLAGS) -c -o ztest-ztest.o `test -f 'ztest.c' || echo '$(srcdir)/'`ztest.c + +ztest-ztest.obj: ztest.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ztest_CFLAGS) $(CFLAGS) -c -o ztest-ztest.obj `if test -f 'ztest.c'; then $(CYGPATH_W) 'ztest.c'; else $(CYGPATH_W) '$(srcdir)/ztest.c'; fi` + +ztest-testlib.o: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ztest_CFLAGS) $(CFLAGS) -c -o ztest-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c + +ztest-testlib.obj: testlib.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ztest_CFLAGS) $(CFLAGS) -c -o ztest-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool config.lt + +# GNU Make needs to see an explicit $(MAKE) variable in the command it +# runs to enable its job server during parallel builds. Hence the +# comments below. +all-multi: + $(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do # $(MAKE) +install-multi: + $(MULTIDO) $(AM_MAKEFLAGS) DO=install multi-do # $(MAKE) + +mostlyclean-multi: + $(MULTICLEAN) $(AM_MAKEFLAGS) DO=mostlyclean multi-clean # $(MAKE) +clean-multi: + $(MULTICLEAN) $(AM_MAKEFLAGS) DO=clean multi-clean # $(MAKE) +distclean-multi: + $(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean # $(MAKE) +maintainer-clean-multi: + $(MULTICLEAN) $(AM_MAKEFLAGS) DO=maintainer-clean multi-clean # $(MAKE) +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) all-multi $(HEADERS) config.h +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am clean-multi + +clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ + clean-libtool mostlyclean-am + +distclean: distclean-am distclean-multi + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-includeHEADERS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES install-multi + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am maintainer-clean-multi + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am mostlyclean-multi + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES + +.MAKE: all all-multi check-am clean-multi distclean-multi install-am \ + install-multi install-strip maintainer-clean-multi \ + mostlyclean-multi + +.PHONY: CTAGS GTAGS all all-am all-multi am--refresh check check-TESTS \ + check-am clean clean-checkPROGRAMS clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-multi ctags distclean \ + distclean-compile distclean-generic distclean-hdr \ + distclean-libtool distclean-multi distclean-tags dvi dvi-am \ + html html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am \ + install-includeHEADERS install-info install-info-am \ + install-libLTLIBRARIES install-man install-multi install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic maintainer-clean-multi mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + mostlyclean-multi pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-includeHEADERS uninstall-libLTLIBRARIES + + +@NATIVE_TRUE@edtest2_build.c: gen_edtest2_build; @true +@NATIVE_TRUE@gen_edtest2_build: $(srcdir)/edtest2.c +@NATIVE_TRUE@ cat $(srcdir)/edtest2.c > tmp-edtest2_build.c +@NATIVE_TRUE@ $(SHELL) $(srcdir)/move-if-change tmp-edtest2_build.c edtest2_build.c +@NATIVE_TRUE@ echo timestamp > $@ + +@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@dtest: btest_static +@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --only-keep-debug btest_static btest.debug +@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --strip-debug --add-gnu-debuglink=btest.debug btest_static dtest + +# We can't use automake's automatic dependency tracking, because it +# breaks when using bootstrap-lean. Automatic dependency tracking +# with GCC bootstrap will cause some of the objects to depend on +# header files in prev-gcc/include, e.g., stddef.h and stdarg.h. When +# using bootstrap-lean, prev-gcc is removed after each stage. When +# running "make install", those header files will be gone, causing the +# library to be rebuilt at install time. That may not succeed. + +# These manual dependencies do not include dependencies on unwind.h, +# even though that is part of GCC, because where to find it depends on +# whether we are being built as a host library or a target library. + +alloc.lo: config.h backtrace.h internal.h +backtrace.lo: config.h backtrace.h internal.h +btest.lo: backtrace.h backtrace-supported.h filenames.h +dwarf.lo: config.h filenames.h backtrace.h internal.h +elf.lo: config.h backtrace.h internal.h +fileline.lo: config.h backtrace.h internal.h +mmap.lo: config.h backtrace.h internal.h +mmapio.lo: config.h backtrace.h internal.h +nounwind.lo: config.h internal.h +pecoff.lo: config.h backtrace.h internal.h +posix.lo: config.h backtrace.h internal.h +print.lo: config.h backtrace.h internal.h +read.lo: config.h backtrace.h internal.h +simple.lo: config.h backtrace.h internal.h +sort.lo: config.h backtrace.h internal.h +stest.lo: config.h backtrace.h internal.h +state.lo: config.h backtrace.h backtrace-supported.h internal.h +unknown.lo: config.h backtrace.h internal.h +xcoff.lo: config.h backtrace.h internal.h + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/Mark.Twain-Tom.Sawyer.txt b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/Mark.Twain-Tom.Sawyer.txt new file mode 100644 index 0000000..c9106fd --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/Mark.Twain-Tom.Sawyer.txt @@ -0,0 +1,8465 @@ +Produced by David Widger. The previous edition was updated by Jose +Menendez. + + + + + + THE ADVENTURES OF TOM SAWYER + BY + MARK TWAIN + (Samuel Langhorne Clemens) + + + + + P R E F A C E + +MOST of the adventures recorded in this book really occurred; one or +two were experiences of my own, the rest those of boys who were +schoolmates of mine. Huck Finn is drawn from life; Tom Sawyer also, but +not from an individual--he is a combination of the characteristics of +three boys whom I knew, and therefore belongs to the composite order of +architecture. + +The odd superstitions touched upon were all prevalent among children +and slaves in the West at the period of this story--that is to say, +thirty or forty years ago. + +Although my book is intended mainly for the entertainment of boys and +girls, I hope it will not be shunned by men and women on that account, +for part of my plan has been to try to pleasantly remind adults of what +they once were themselves, and of how they felt and thought and talked, +and what queer enterprises they sometimes engaged in. + + THE AUTHOR. + +HARTFORD, 1876. + + + + T O M S A W Y E R + + + +CHAPTER I + +"TOM!" + +No answer. + +"TOM!" + +No answer. + +"What's gone with that boy, I wonder? You TOM!" + +No answer. + +The old lady pulled her spectacles down and looked over them about the +room; then she put them up and looked out under them. She seldom or +never looked THROUGH them for so small a thing as a boy; they were her +state pair, the pride of her heart, and were built for "style," not +service--she could have seen through a pair of stove-lids just as well. +She looked perplexed for a moment, and then said, not fiercely, but +still loud enough for the furniture to hear: + +"Well, I lay if I get hold of you I'll--" + +She did not finish, for by this time she was bending down and punching +under the bed with the broom, and so she needed breath to punctuate the +punches with. She resurrected nothing but the cat. + +"I never did see the beat of that boy!" + +She went to the open door and stood in it and looked out among the +tomato vines and "jimpson" weeds that constituted the garden. No Tom. +So she lifted up her voice at an angle calculated for distance and +shouted: + +"Y-o-u-u TOM!" + +There was a slight noise behind her and she turned just in time to +seize a small boy by the slack of his roundabout and arrest his flight. + +"There! I might 'a' thought of that closet. What you been doing in +there?" + +"Nothing." + +"Nothing! Look at your hands. And look at your mouth. What IS that +truck?" + +"I don't know, aunt." + +"Well, I know. It's jam--that's what it is. Forty times I've said if +you didn't let that jam alone I'd skin you. Hand me that switch." + +The switch hovered in the air--the peril was desperate-- + +"My! Look behind you, aunt!" + +The old lady whirled round, and snatched her skirts out of danger. The +lad fled on the instant, scrambled up the high board-fence, and +disappeared over it. + +His aunt Polly stood surprised a moment, and then broke into a gentle +laugh. + +"Hang the boy, can't I never learn anything? Ain't he played me tricks +enough like that for me to be looking out for him by this time? But old +fools is the biggest fools there is. Can't learn an old dog new tricks, +as the saying is. But my goodness, he never plays them alike, two days, +and how is a body to know what's coming? He 'pears to know just how +long he can torment me before I get my dander up, and he knows if he +can make out to put me off for a minute or make me laugh, it's all down +again and I can't hit him a lick. I ain't doing my duty by that boy, +and that's the Lord's truth, goodness knows. Spare the rod and spile +the child, as the Good Book says. I'm a laying up sin and suffering for +us both, I know. He's full of the Old Scratch, but laws-a-me! he's my +own dead sister's boy, poor thing, and I ain't got the heart to lash +him, somehow. Every time I let him off, my conscience does hurt me so, +and every time I hit him my old heart most breaks. Well-a-well, man +that is born of woman is of few days and full of trouble, as the +Scripture says, and I reckon it's so. He'll play hookey this evening, * +and [* Southwestern for "afternoon"] I'll just be obleeged to make him +work, to-morrow, to punish him. It's mighty hard to make him work +Saturdays, when all the boys is having holiday, but he hates work more +than he hates anything else, and I've GOT to do some of my duty by him, +or I'll be the ruination of the child." + +Tom did play hookey, and he had a very good time. He got back home +barely in season to help Jim, the small colored boy, saw next-day's +wood and split the kindlings before supper--at least he was there in +time to tell his adventures to Jim while Jim did three-fourths of the +work. Tom's younger brother (or rather half-brother) Sid was already +through with his part of the work (picking up chips), for he was a +quiet boy, and had no adventurous, troublesome ways. + +While Tom was eating his supper, and stealing sugar as opportunity +offered, Aunt Polly asked him questions that were full of guile, and +very deep--for she wanted to trap him into damaging revealments. Like +many other simple-hearted souls, it was her pet vanity to believe she +was endowed with a talent for dark and mysterious diplomacy, and she +loved to contemplate her most transparent devices as marvels of low +cunning. Said she: + +"Tom, it was middling warm in school, warn't it?" + +"Yes'm." + +"Powerful warm, warn't it?" + +"Yes'm." + +"Didn't you want to go in a-swimming, Tom?" + +A bit of a scare shot through Tom--a touch of uncomfortable suspicion. +He searched Aunt Polly's face, but it told him nothing. So he said: + +"No'm--well, not very much." + +The old lady reached out her hand and felt Tom's shirt, and said: + +"But you ain't too warm now, though." And it flattered her to reflect +that she had discovered that the shirt was dry without anybody knowing +that that was what she had in her mind. But in spite of her, Tom knew +where the wind lay, now. So he forestalled what might be the next move: + +"Some of us pumped on our heads--mine's damp yet. See?" + +Aunt Polly was vexed to think she had overlooked that bit of +circumstantial evidence, and missed a trick. Then she had a new +inspiration: + +"Tom, you didn't have to undo your shirt collar where I sewed it, to +pump on your head, did you? Unbutton your jacket!" + +The trouble vanished out of Tom's face. He opened his jacket. His +shirt collar was securely sewed. + +"Bother! Well, go 'long with you. I'd made sure you'd played hookey +and been a-swimming. But I forgive ye, Tom. I reckon you're a kind of a +singed cat, as the saying is--better'n you look. THIS time." + +She was half sorry her sagacity had miscarried, and half glad that Tom +had stumbled into obedient conduct for once. + +But Sidney said: + +"Well, now, if I didn't think you sewed his collar with white thread, +but it's black." + +"Why, I did sew it with white! Tom!" + +But Tom did not wait for the rest. As he went out at the door he said: + +"Siddy, I'll lick you for that." + +In a safe place Tom examined two large needles which were thrust into +the lapels of his jacket, and had thread bound about them--one needle +carried white thread and the other black. He said: + +"She'd never noticed if it hadn't been for Sid. Confound it! sometimes +she sews it with white, and sometimes she sews it with black. I wish to +geeminy she'd stick to one or t'other--I can't keep the run of 'em. But +I bet you I'll lam Sid for that. I'll learn him!" + +He was not the Model Boy of the village. He knew the model boy very +well though--and loathed him. + +Within two minutes, or even less, he had forgotten all his troubles. +Not because his troubles were one whit less heavy and bitter to him +than a man's are to a man, but because a new and powerful interest bore +them down and drove them out of his mind for the time--just as men's +misfortunes are forgotten in the excitement of new enterprises. This +new interest was a valued novelty in whistling, which he had just +acquired from a negro, and he was suffering to practise it undisturbed. +It consisted in a peculiar bird-like turn, a sort of liquid warble, +produced by touching the tongue to the roof of the mouth at short +intervals in the midst of the music--the reader probably remembers how +to do it, if he has ever been a boy. Diligence and attention soon gave +him the knack of it, and he strode down the street with his mouth full +of harmony and his soul full of gratitude. He felt much as an +astronomer feels who has discovered a new planet--no doubt, as far as +strong, deep, unalloyed pleasure is concerned, the advantage was with +the boy, not the astronomer. + +The summer evenings were long. It was not dark, yet. Presently Tom +checked his whistle. A stranger was before him--a boy a shade larger +than himself. A new-comer of any age or either sex was an impressive +curiosity in the poor little shabby village of St. Petersburg. This boy +was well dressed, too--well dressed on a week-day. This was simply +astounding. His cap was a dainty thing, his close-buttoned blue cloth +roundabout was new and natty, and so were his pantaloons. He had shoes +on--and it was only Friday. He even wore a necktie, a bright bit of +ribbon. He had a citified air about him that ate into Tom's vitals. The +more Tom stared at the splendid marvel, the higher he turned up his +nose at his finery and the shabbier and shabbier his own outfit seemed +to him to grow. Neither boy spoke. If one moved, the other moved--but +only sidewise, in a circle; they kept face to face and eye to eye all +the time. Finally Tom said: + +"I can lick you!" + +"I'd like to see you try it." + +"Well, I can do it." + +"No you can't, either." + +"Yes I can." + +"No you can't." + +"I can." + +"You can't." + +"Can!" + +"Can't!" + +An uncomfortable pause. Then Tom said: + +"What's your name?" + +"'Tisn't any of your business, maybe." + +"Well I 'low I'll MAKE it my business." + +"Well why don't you?" + +"If you say much, I will." + +"Much--much--MUCH. There now." + +"Oh, you think you're mighty smart, DON'T you? I could lick you with +one hand tied behind me, if I wanted to." + +"Well why don't you DO it? You SAY you can do it." + +"Well I WILL, if you fool with me." + +"Oh yes--I've seen whole families in the same fix." + +"Smarty! You think you're SOME, now, DON'T you? Oh, what a hat!" + +"You can lump that hat if you don't like it. I dare you to knock it +off--and anybody that'll take a dare will suck eggs." + +"You're a liar!" + +"You're another." + +"You're a fighting liar and dasn't take it up." + +"Aw--take a walk!" + +"Say--if you give me much more of your sass I'll take and bounce a +rock off'n your head." + +"Oh, of COURSE you will." + +"Well I WILL." + +"Well why don't you DO it then? What do you keep SAYING you will for? +Why don't you DO it? It's because you're afraid." + +"I AIN'T afraid." + +"You are." + +"I ain't." + +"You are." + +Another pause, and more eying and sidling around each other. Presently +they were shoulder to shoulder. Tom said: + +"Get away from here!" + +"Go away yourself!" + +"I won't." + +"I won't either." + +So they stood, each with a foot placed at an angle as a brace, and +both shoving with might and main, and glowering at each other with +hate. But neither could get an advantage. After struggling till both +were hot and flushed, each relaxed his strain with watchful caution, +and Tom said: + +"You're a coward and a pup. I'll tell my big brother on you, and he +can thrash you with his little finger, and I'll make him do it, too." + +"What do I care for your big brother? I've got a brother that's bigger +than he is--and what's more, he can throw him over that fence, too." +[Both brothers were imaginary.] + +"That's a lie." + +"YOUR saying so don't make it so." + +Tom drew a line in the dust with his big toe, and said: + +"I dare you to step over that, and I'll lick you till you can't stand +up. Anybody that'll take a dare will steal sheep." + +The new boy stepped over promptly, and said: + +"Now you said you'd do it, now let's see you do it." + +"Don't you crowd me now; you better look out." + +"Well, you SAID you'd do it--why don't you do it?" + +"By jingo! for two cents I WILL do it." + +The new boy took two broad coppers out of his pocket and held them out +with derision. Tom struck them to the ground. In an instant both boys +were rolling and tumbling in the dirt, gripped together like cats; and +for the space of a minute they tugged and tore at each other's hair and +clothes, punched and scratched each other's nose, and covered +themselves with dust and glory. Presently the confusion took form, and +through the fog of battle Tom appeared, seated astride the new boy, and +pounding him with his fists. "Holler 'nuff!" said he. + +The boy only struggled to free himself. He was crying--mainly from rage. + +"Holler 'nuff!"--and the pounding went on. + +At last the stranger got out a smothered "'Nuff!" and Tom let him up +and said: + +"Now that'll learn you. Better look out who you're fooling with next +time." + +The new boy went off brushing the dust from his clothes, sobbing, +snuffling, and occasionally looking back and shaking his head and +threatening what he would do to Tom the "next time he caught him out." +To which Tom responded with jeers, and started off in high feather, and +as soon as his back was turned the new boy snatched up a stone, threw +it and hit him between the shoulders and then turned tail and ran like +an antelope. Tom chased the traitor home, and thus found out where he +lived. He then held a position at the gate for some time, daring the +enemy to come outside, but the enemy only made faces at him through the +window and declined. At last the enemy's mother appeared, and called +Tom a bad, vicious, vulgar child, and ordered him away. So he went +away; but he said he "'lowed" to "lay" for that boy. + +He got home pretty late that night, and when he climbed cautiously in +at the window, he uncovered an ambuscade, in the person of his aunt; +and when she saw the state his clothes were in her resolution to turn +his Saturday holiday into captivity at hard labor became adamantine in +its firmness. + + + +CHAPTER II + +SATURDAY morning was come, and all the summer world was bright and +fresh, and brimming with life. There was a song in every heart; and if +the heart was young the music issued at the lips. There was cheer in +every face and a spring in every step. The locust-trees were in bloom +and the fragrance of the blossoms filled the air. Cardiff Hill, beyond +the village and above it, was green with vegetation and it lay just far +enough away to seem a Delectable Land, dreamy, reposeful, and inviting. + +Tom appeared on the sidewalk with a bucket of whitewash and a +long-handled brush. He surveyed the fence, and all gladness left him and +a deep melancholy settled down upon his spirit. Thirty yards of board +fence nine feet high. Life to him seemed hollow, and existence but a +burden. Sighing, he dipped his brush and passed it along the topmost +plank; repeated the operation; did it again; compared the insignificant +whitewashed streak with the far-reaching continent of unwhitewashed +fence, and sat down on a tree-box discouraged. Jim came skipping out at +the gate with a tin pail, and singing Buffalo Gals. Bringing water from +the town pump had always been hateful work in Tom's eyes, before, but +now it did not strike him so. He remembered that there was company at +the pump. White, mulatto, and negro boys and girls were always there +waiting their turns, resting, trading playthings, quarrelling, +fighting, skylarking. And he remembered that although the pump was only +a hundred and fifty yards off, Jim never got back with a bucket of +water under an hour--and even then somebody generally had to go after +him. Tom said: + +"Say, Jim, I'll fetch the water if you'll whitewash some." + +Jim shook his head and said: + +"Can't, Mars Tom. Ole missis, she tole me I got to go an' git dis +water an' not stop foolin' roun' wid anybody. She say she spec' Mars +Tom gwine to ax me to whitewash, an' so she tole me go 'long an' 'tend +to my own business--she 'lowed SHE'D 'tend to de whitewashin'." + +"Oh, never you mind what she said, Jim. That's the way she always +talks. Gimme the bucket--I won't be gone only a a minute. SHE won't +ever know." + +"Oh, I dasn't, Mars Tom. Ole missis she'd take an' tar de head off'n +me. 'Deed she would." + +"SHE! She never licks anybody--whacks 'em over the head with her +thimble--and who cares for that, I'd like to know. She talks awful, but +talk don't hurt--anyways it don't if she don't cry. Jim, I'll give you +a marvel. I'll give you a white alley!" + +Jim began to waver. + +"White alley, Jim! And it's a bully taw." + +"My! Dat's a mighty gay marvel, I tell you! But Mars Tom I's powerful +'fraid ole missis--" + +"And besides, if you will I'll show you my sore toe." + +Jim was only human--this attraction was too much for him. He put down +his pail, took the white alley, and bent over the toe with absorbing +interest while the bandage was being unwound. In another moment he was +flying down the street with his pail and a tingling rear, Tom was +whitewashing with vigor, and Aunt Polly was retiring from the field +with a slipper in her hand and triumph in her eye. + +But Tom's energy did not last. He began to think of the fun he had +planned for this day, and his sorrows multiplied. Soon the free boys +would come tripping along on all sorts of delicious expeditions, and +they would make a world of fun of him for having to work--the very +thought of it burnt him like fire. He got out his worldly wealth and +examined it--bits of toys, marbles, and trash; enough to buy an +exchange of WORK, maybe, but not half enough to buy so much as half an +hour of pure freedom. So he returned his straitened means to his +pocket, and gave up the idea of trying to buy the boys. At this dark +and hopeless moment an inspiration burst upon him! Nothing less than a +great, magnificent inspiration. + +He took up his brush and went tranquilly to work. Ben Rogers hove in +sight presently--the very boy, of all boys, whose ridicule he had been +dreading. Ben's gait was the hop-skip-and-jump--proof enough that his +heart was light and his anticipations high. He was eating an apple, and +giving a long, melodious whoop, at intervals, followed by a deep-toned +ding-dong-dong, ding-dong-dong, for he was personating a steamboat. As +he drew near, he slackened speed, took the middle of the street, leaned +far over to starboard and rounded to ponderously and with laborious +pomp and circumstance--for he was personating the Big Missouri, and +considered himself to be drawing nine feet of water. He was boat and +captain and engine-bells combined, so he had to imagine himself +standing on his own hurricane-deck giving the orders and executing them: + +"Stop her, sir! Ting-a-ling-ling!" The headway ran almost out, and he +drew up slowly toward the sidewalk. + +"Ship up to back! Ting-a-ling-ling!" His arms straightened and +stiffened down his sides. + +"Set her back on the stabboard! Ting-a-ling-ling! Chow! ch-chow-wow! +Chow!" His right hand, meantime, describing stately circles--for it was +representing a forty-foot wheel. + +"Let her go back on the labboard! Ting-a-lingling! Chow-ch-chow-chow!" +The left hand began to describe circles. + +"Stop the stabboard! Ting-a-ling-ling! Stop the labboard! Come ahead +on the stabboard! Stop her! Let your outside turn over slow! +Ting-a-ling-ling! Chow-ow-ow! Get out that head-line! LIVELY now! +Come--out with your spring-line--what're you about there! Take a turn +round that stump with the bight of it! Stand by that stage, now--let her +go! Done with the engines, sir! Ting-a-ling-ling! SH'T! S'H'T! SH'T!" +(trying the gauge-cocks). + +Tom went on whitewashing--paid no attention to the steamboat. Ben +stared a moment and then said: "Hi-YI! YOU'RE up a stump, ain't you!" + +No answer. Tom surveyed his last touch with the eye of an artist, then +he gave his brush another gentle sweep and surveyed the result, as +before. Ben ranged up alongside of him. Tom's mouth watered for the +apple, but he stuck to his work. Ben said: + +"Hello, old chap, you got to work, hey?" + +Tom wheeled suddenly and said: + +"Why, it's you, Ben! I warn't noticing." + +"Say--I'm going in a-swimming, I am. Don't you wish you could? But of +course you'd druther WORK--wouldn't you? Course you would!" + +Tom contemplated the boy a bit, and said: + +"What do you call work?" + +"Why, ain't THAT work?" + +Tom resumed his whitewashing, and answered carelessly: + +"Well, maybe it is, and maybe it ain't. All I know, is, it suits Tom +Sawyer." + +"Oh come, now, you don't mean to let on that you LIKE it?" + +The brush continued to move. + +"Like it? Well, I don't see why I oughtn't to like it. Does a boy get +a chance to whitewash a fence every day?" + +That put the thing in a new light. Ben stopped nibbling his apple. Tom +swept his brush daintily back and forth--stepped back to note the +effect--added a touch here and there--criticised the effect again--Ben +watching every move and getting more and more interested, more and more +absorbed. Presently he said: + +"Say, Tom, let ME whitewash a little." + +Tom considered, was about to consent; but he altered his mind: + +"No--no--I reckon it wouldn't hardly do, Ben. You see, Aunt Polly's +awful particular about this fence--right here on the street, you know +--but if it was the back fence I wouldn't mind and SHE wouldn't. Yes, +she's awful particular about this fence; it's got to be done very +careful; I reckon there ain't one boy in a thousand, maybe two +thousand, that can do it the way it's got to be done." + +"No--is that so? Oh come, now--lemme just try. Only just a little--I'd +let YOU, if you was me, Tom." + +"Ben, I'd like to, honest injun; but Aunt Polly--well, Jim wanted to +do it, but she wouldn't let him; Sid wanted to do it, and she wouldn't +let Sid. Now don't you see how I'm fixed? If you was to tackle this +fence and anything was to happen to it--" + +"Oh, shucks, I'll be just as careful. Now lemme try. Say--I'll give +you the core of my apple." + +"Well, here--No, Ben, now don't. I'm afeard--" + +"I'll give you ALL of it!" + +Tom gave up the brush with reluctance in his face, but alacrity in his +heart. And while the late steamer Big Missouri worked and sweated in +the sun, the retired artist sat on a barrel in the shade close by, +dangled his legs, munched his apple, and planned the slaughter of more +innocents. There was no lack of material; boys happened along every +little while; they came to jeer, but remained to whitewash. By the time +Ben was fagged out, Tom had traded the next chance to Billy Fisher for +a kite, in good repair; and when he played out, Johnny Miller bought in +for a dead rat and a string to swing it with--and so on, and so on, +hour after hour. And when the middle of the afternoon came, from being +a poor poverty-stricken boy in the morning, Tom was literally rolling +in wealth. He had besides the things before mentioned, twelve marbles, +part of a jews-harp, a piece of blue bottle-glass to look through, a +spool cannon, a key that wouldn't unlock anything, a fragment of chalk, +a glass stopper of a decanter, a tin soldier, a couple of tadpoles, six +fire-crackers, a kitten with only one eye, a brass doorknob, a +dog-collar--but no dog--the handle of a knife, four pieces of +orange-peel, and a dilapidated old window sash. + +He had had a nice, good, idle time all the while--plenty of company +--and the fence had three coats of whitewash on it! If he hadn't run out +of whitewash he would have bankrupted every boy in the village. + +Tom said to himself that it was not such a hollow world, after all. He +had discovered a great law of human action, without knowing it--namely, +that in order to make a man or a boy covet a thing, it is only +necessary to make the thing difficult to attain. If he had been a great +and wise philosopher, like the writer of this book, he would now have +comprehended that Work consists of whatever a body is OBLIGED to do, +and that Play consists of whatever a body is not obliged to do. And +this would help him to understand why constructing artificial flowers +or performing on a tread-mill is work, while rolling ten-pins or +climbing Mont Blanc is only amusement. There are wealthy gentlemen in +England who drive four-horse passenger-coaches twenty or thirty miles +on a daily line, in the summer, because the privilege costs them +considerable money; but if they were offered wages for the service, +that would turn it into work and then they would resign. + +The boy mused awhile over the substantial change which had taken place +in his worldly circumstances, and then wended toward headquarters to +report. + + + +CHAPTER III + +TOM presented himself before Aunt Polly, who was sitting by an open +window in a pleasant rearward apartment, which was bedroom, +breakfast-room, dining-room, and library, combined. The balmy summer +air, the restful quiet, the odor of the flowers, and the drowsing murmur +of the bees had had their effect, and she was nodding over her knitting +--for she had no company but the cat, and it was asleep in her lap. Her +spectacles were propped up on her gray head for safety. She had thought +that of course Tom had deserted long ago, and she wondered at seeing him +place himself in her power again in this intrepid way. He said: "Mayn't +I go and play now, aunt?" + +"What, a'ready? How much have you done?" + +"It's all done, aunt." + +"Tom, don't lie to me--I can't bear it." + +"I ain't, aunt; it IS all done." + +Aunt Polly placed small trust in such evidence. She went out to see +for herself; and she would have been content to find twenty per cent. +of Tom's statement true. When she found the entire fence whitewashed, +and not only whitewashed but elaborately coated and recoated, and even +a streak added to the ground, her astonishment was almost unspeakable. +She said: + +"Well, I never! There's no getting round it, you can work when you're +a mind to, Tom." And then she diluted the compliment by adding, "But +it's powerful seldom you're a mind to, I'm bound to say. Well, go 'long +and play; but mind you get back some time in a week, or I'll tan you." + +She was so overcome by the splendor of his achievement that she took +him into the closet and selected a choice apple and delivered it to +him, along with an improving lecture upon the added value and flavor a +treat took to itself when it came without sin through virtuous effort. +And while she closed with a happy Scriptural flourish, he "hooked" a +doughnut. + +Then he skipped out, and saw Sid just starting up the outside stairway +that led to the back rooms on the second floor. Clods were handy and +the air was full of them in a twinkling. They raged around Sid like a +hail-storm; and before Aunt Polly could collect her surprised faculties +and sally to the rescue, six or seven clods had taken personal effect, +and Tom was over the fence and gone. There was a gate, but as a general +thing he was too crowded for time to make use of it. His soul was at +peace, now that he had settled with Sid for calling attention to his +black thread and getting him into trouble. + +Tom skirted the block, and came round into a muddy alley that led by +the back of his aunt's cow-stable. He presently got safely beyond the +reach of capture and punishment, and hastened toward the public square +of the village, where two "military" companies of boys had met for +conflict, according to previous appointment. Tom was General of one of +these armies, Joe Harper (a bosom friend) General of the other. These +two great commanders did not condescend to fight in person--that being +better suited to the still smaller fry--but sat together on an eminence +and conducted the field operations by orders delivered through +aides-de-camp. Tom's army won a great victory, after a long and +hard-fought battle. Then the dead were counted, prisoners exchanged, +the terms of the next disagreement agreed upon, and the day for the +necessary battle appointed; after which the armies fell into line and +marched away, and Tom turned homeward alone. + +As he was passing by the house where Jeff Thatcher lived, he saw a new +girl in the garden--a lovely little blue-eyed creature with yellow hair +plaited into two long-tails, white summer frock and embroidered +pantalettes. The fresh-crowned hero fell without firing a shot. A +certain Amy Lawrence vanished out of his heart and left not even a +memory of herself behind. He had thought he loved her to distraction; +he had regarded his passion as adoration; and behold it was only a poor +little evanescent partiality. He had been months winning her; she had +confessed hardly a week ago; he had been the happiest and the proudest +boy in the world only seven short days, and here in one instant of time +she had gone out of his heart like a casual stranger whose visit is +done. + +He worshipped this new angel with furtive eye, till he saw that she +had discovered him; then he pretended he did not know she was present, +and began to "show off" in all sorts of absurd boyish ways, in order to +win her admiration. He kept up this grotesque foolishness for some +time; but by-and-by, while he was in the midst of some dangerous +gymnastic performances, he glanced aside and saw that the little girl +was wending her way toward the house. Tom came up to the fence and +leaned on it, grieving, and hoping she would tarry yet awhile longer. +She halted a moment on the steps and then moved toward the door. Tom +heaved a great sigh as she put her foot on the threshold. But his face +lit up, right away, for she tossed a pansy over the fence a moment +before she disappeared. + +The boy ran around and stopped within a foot or two of the flower, and +then shaded his eyes with his hand and began to look down street as if +he had discovered something of interest going on in that direction. +Presently he picked up a straw and began trying to balance it on his +nose, with his head tilted far back; and as he moved from side to side, +in his efforts, he edged nearer and nearer toward the pansy; finally +his bare foot rested upon it, his pliant toes closed upon it, and he +hopped away with the treasure and disappeared round the corner. But +only for a minute--only while he could button the flower inside his +jacket, next his heart--or next his stomach, possibly, for he was not +much posted in anatomy, and not hypercritical, anyway. + +He returned, now, and hung about the fence till nightfall, "showing +off," as before; but the girl never exhibited herself again, though Tom +comforted himself a little with the hope that she had been near some +window, meantime, and been aware of his attentions. Finally he strode +home reluctantly, with his poor head full of visions. + +All through supper his spirits were so high that his aunt wondered +"what had got into the child." He took a good scolding about clodding +Sid, and did not seem to mind it in the least. He tried to steal sugar +under his aunt's very nose, and got his knuckles rapped for it. He said: + +"Aunt, you don't whack Sid when he takes it." + +"Well, Sid don't torment a body the way you do. You'd be always into +that sugar if I warn't watching you." + +Presently she stepped into the kitchen, and Sid, happy in his +immunity, reached for the sugar-bowl--a sort of glorying over Tom which +was wellnigh unbearable. But Sid's fingers slipped and the bowl dropped +and broke. Tom was in ecstasies. In such ecstasies that he even +controlled his tongue and was silent. He said to himself that he would +not speak a word, even when his aunt came in, but would sit perfectly +still till she asked who did the mischief; and then he would tell, and +there would be nothing so good in the world as to see that pet model +"catch it." He was so brimful of exultation that he could hardly hold +himself when the old lady came back and stood above the wreck +discharging lightnings of wrath from over her spectacles. He said to +himself, "Now it's coming!" And the next instant he was sprawling on +the floor! The potent palm was uplifted to strike again when Tom cried +out: + +"Hold on, now, what 'er you belting ME for?--Sid broke it!" + +Aunt Polly paused, perplexed, and Tom looked for healing pity. But +when she got her tongue again, she only said: + +"Umf! Well, you didn't get a lick amiss, I reckon. You been into some +other audacious mischief when I wasn't around, like enough." + +Then her conscience reproached her, and she yearned to say something +kind and loving; but she judged that this would be construed into a +confession that she had been in the wrong, and discipline forbade that. +So she kept silence, and went about her affairs with a troubled heart. +Tom sulked in a corner and exalted his woes. He knew that in her heart +his aunt was on her knees to him, and he was morosely gratified by the +consciousness of it. He would hang out no signals, he would take notice +of none. He knew that a yearning glance fell upon him, now and then, +through a film of tears, but he refused recognition of it. He pictured +himself lying sick unto death and his aunt bending over him beseeching +one little forgiving word, but he would turn his face to the wall, and +die with that word unsaid. Ah, how would she feel then? And he pictured +himself brought home from the river, dead, with his curls all wet, and +his sore heart at rest. How she would throw herself upon him, and how +her tears would fall like rain, and her lips pray God to give her back +her boy and she would never, never abuse him any more! But he would lie +there cold and white and make no sign--a poor little sufferer, whose +griefs were at an end. He so worked upon his feelings with the pathos +of these dreams, that he had to keep swallowing, he was so like to +choke; and his eyes swam in a blur of water, which overflowed when he +winked, and ran down and trickled from the end of his nose. And such a +luxury to him was this petting of his sorrows, that he could not bear +to have any worldly cheeriness or any grating delight intrude upon it; +it was too sacred for such contact; and so, presently, when his cousin +Mary danced in, all alive with the joy of seeing home again after an +age-long visit of one week to the country, he got up and moved in +clouds and darkness out at one door as she brought song and sunshine in +at the other. + +He wandered far from the accustomed haunts of boys, and sought +desolate places that were in harmony with his spirit. A log raft in the +river invited him, and he seated himself on its outer edge and +contemplated the dreary vastness of the stream, wishing, the while, +that he could only be drowned, all at once and unconsciously, without +undergoing the uncomfortable routine devised by nature. Then he thought +of his flower. He got it out, rumpled and wilted, and it mightily +increased his dismal felicity. He wondered if she would pity him if she +knew? Would she cry, and wish that she had a right to put her arms +around his neck and comfort him? Or would she turn coldly away like all +the hollow world? This picture brought such an agony of pleasurable +suffering that he worked it over and over again in his mind and set it +up in new and varied lights, till he wore it threadbare. At last he +rose up sighing and departed in the darkness. + +About half-past nine or ten o'clock he came along the deserted street +to where the Adored Unknown lived; he paused a moment; no sound fell +upon his listening ear; a candle was casting a dull glow upon the +curtain of a second-story window. Was the sacred presence there? He +climbed the fence, threaded his stealthy way through the plants, till +he stood under that window; he looked up at it long, and with emotion; +then he laid him down on the ground under it, disposing himself upon +his back, with his hands clasped upon his breast and holding his poor +wilted flower. And thus he would die--out in the cold world, with no +shelter over his homeless head, no friendly hand to wipe the +death-damps from his brow, no loving face to bend pityingly over him +when the great agony came. And thus SHE would see him when she looked +out upon the glad morning, and oh! would she drop one little tear upon +his poor, lifeless form, would she heave one little sigh to see a bright +young life so rudely blighted, so untimely cut down? + +The window went up, a maid-servant's discordant voice profaned the +holy calm, and a deluge of water drenched the prone martyr's remains! + +The strangling hero sprang up with a relieving snort. There was a whiz +as of a missile in the air, mingled with the murmur of a curse, a sound +as of shivering glass followed, and a small, vague form went over the +fence and shot away in the gloom. + +Not long after, as Tom, all undressed for bed, was surveying his +drenched garments by the light of a tallow dip, Sid woke up; but if he +had any dim idea of making any "references to allusions," he thought +better of it and held his peace, for there was danger in Tom's eye. + +Tom turned in without the added vexation of prayers, and Sid made +mental note of the omission. + + + +CHAPTER IV + +THE sun rose upon a tranquil world, and beamed down upon the peaceful +village like a benediction. Breakfast over, Aunt Polly had family +worship: it began with a prayer built from the ground up of solid +courses of Scriptural quotations, welded together with a thin mortar of +originality; and from the summit of this she delivered a grim chapter +of the Mosaic Law, as from Sinai. + +Then Tom girded up his loins, so to speak, and went to work to "get +his verses." Sid had learned his lesson days before. Tom bent all his +energies to the memorizing of five verses, and he chose part of the +Sermon on the Mount, because he could find no verses that were shorter. +At the end of half an hour Tom had a vague general idea of his lesson, +but no more, for his mind was traversing the whole field of human +thought, and his hands were busy with distracting recreations. Mary +took his book to hear him recite, and he tried to find his way through +the fog: + +"Blessed are the--a--a--" + +"Poor"-- + +"Yes--poor; blessed are the poor--a--a--" + +"In spirit--" + +"In spirit; blessed are the poor in spirit, for they--they--" + +"THEIRS--" + +"For THEIRS. Blessed are the poor in spirit, for theirs is the kingdom +of heaven. Blessed are they that mourn, for they--they--" + +"Sh--" + +"For they--a--" + +"S, H, A--" + +"For they S, H--Oh, I don't know what it is!" + +"SHALL!" + +"Oh, SHALL! for they shall--for they shall--a--a--shall mourn--a--a-- +blessed are they that shall--they that--a--they that shall mourn, for +they shall--a--shall WHAT? Why don't you tell me, Mary?--what do you +want to be so mean for?" + +"Oh, Tom, you poor thick-headed thing, I'm not teasing you. I wouldn't +do that. You must go and learn it again. Don't you be discouraged, Tom, +you'll manage it--and if you do, I'll give you something ever so nice. +There, now, that's a good boy." + +"All right! What is it, Mary, tell me what it is." + +"Never you mind, Tom. You know if I say it's nice, it is nice." + +"You bet you that's so, Mary. All right, I'll tackle it again." + +And he did "tackle it again"--and under the double pressure of +curiosity and prospective gain he did it with such spirit that he +accomplished a shining success. Mary gave him a brand-new "Barlow" +knife worth twelve and a half cents; and the convulsion of delight that +swept his system shook him to his foundations. True, the knife would +not cut anything, but it was a "sure-enough" Barlow, and there was +inconceivable grandeur in that--though where the Western boys ever got +the idea that such a weapon could possibly be counterfeited to its +injury is an imposing mystery and will always remain so, perhaps. Tom +contrived to scarify the cupboard with it, and was arranging to begin +on the bureau, when he was called off to dress for Sunday-school. + +Mary gave him a tin basin of water and a piece of soap, and he went +outside the door and set the basin on a little bench there; then he +dipped the soap in the water and laid it down; turned up his sleeves; +poured out the water on the ground, gently, and then entered the +kitchen and began to wipe his face diligently on the towel behind the +door. But Mary removed the towel and said: + +"Now ain't you ashamed, Tom. You mustn't be so bad. Water won't hurt +you." + +Tom was a trifle disconcerted. The basin was refilled, and this time +he stood over it a little while, gathering resolution; took in a big +breath and began. When he entered the kitchen presently, with both eyes +shut and groping for the towel with his hands, an honorable testimony +of suds and water was dripping from his face. But when he emerged from +the towel, he was not yet satisfactory, for the clean territory stopped +short at his chin and his jaws, like a mask; below and beyond this line +there was a dark expanse of unirrigated soil that spread downward in +front and backward around his neck. Mary took him in hand, and when she +was done with him he was a man and a brother, without distinction of +color, and his saturated hair was neatly brushed, and its short curls +wrought into a dainty and symmetrical general effect. [He privately +smoothed out the curls, with labor and difficulty, and plastered his +hair close down to his head; for he held curls to be effeminate, and +his own filled his life with bitterness.] Then Mary got out a suit of +his clothing that had been used only on Sundays during two years--they +were simply called his "other clothes"--and so by that we know the +size of his wardrobe. The girl "put him to rights" after he had dressed +himself; she buttoned his neat roundabout up to his chin, turned his +vast shirt collar down over his shoulders, brushed him off and crowned +him with his speckled straw hat. He now looked exceedingly improved and +uncomfortable. He was fully as uncomfortable as he looked; for there +was a restraint about whole clothes and cleanliness that galled him. He +hoped that Mary would forget his shoes, but the hope was blighted; she +coated them thoroughly with tallow, as was the custom, and brought them +out. He lost his temper and said he was always being made to do +everything he didn't want to do. But Mary said, persuasively: + +"Please, Tom--that's a good boy." + +So he got into the shoes snarling. Mary was soon ready, and the three +children set out for Sunday-school--a place that Tom hated with his +whole heart; but Sid and Mary were fond of it. + +Sabbath-school hours were from nine to half-past ten; and then church +service. Two of the children always remained for the sermon +voluntarily, and the other always remained too--for stronger reasons. +The church's high-backed, uncushioned pews would seat about three +hundred persons; the edifice was but a small, plain affair, with a sort +of pine board tree-box on top of it for a steeple. At the door Tom +dropped back a step and accosted a Sunday-dressed comrade: + +"Say, Billy, got a yaller ticket?" + +"Yes." + +"What'll you take for her?" + +"What'll you give?" + +"Piece of lickrish and a fish-hook." + +"Less see 'em." + +Tom exhibited. They were satisfactory, and the property changed hands. +Then Tom traded a couple of white alleys for three red tickets, and +some small trifle or other for a couple of blue ones. He waylaid other +boys as they came, and went on buying tickets of various colors ten or +fifteen minutes longer. He entered the church, now, with a swarm of +clean and noisy boys and girls, proceeded to his seat and started a +quarrel with the first boy that came handy. The teacher, a grave, +elderly man, interfered; then turned his back a moment and Tom pulled a +boy's hair in the next bench, and was absorbed in his book when the boy +turned around; stuck a pin in another boy, presently, in order to hear +him say "Ouch!" and got a new reprimand from his teacher. Tom's whole +class were of a pattern--restless, noisy, and troublesome. When they +came to recite their lessons, not one of them knew his verses +perfectly, but had to be prompted all along. However, they worried +through, and each got his reward--in small blue tickets, each with a +passage of Scripture on it; each blue ticket was pay for two verses of +the recitation. Ten blue tickets equalled a red one, and could be +exchanged for it; ten red tickets equalled a yellow one; for ten yellow +tickets the superintendent gave a very plainly bound Bible (worth forty +cents in those easy times) to the pupil. How many of my readers would +have the industry and application to memorize two thousand verses, even +for a Dore Bible? And yet Mary had acquired two Bibles in this way--it +was the patient work of two years--and a boy of German parentage had +won four or five. He once recited three thousand verses without +stopping; but the strain upon his mental faculties was too great, and +he was little better than an idiot from that day forth--a grievous +misfortune for the school, for on great occasions, before company, the +superintendent (as Tom expressed it) had always made this boy come out +and "spread himself." Only the older pupils managed to keep their +tickets and stick to their tedious work long enough to get a Bible, and +so the delivery of one of these prizes was a rare and noteworthy +circumstance; the successful pupil was so great and conspicuous for +that day that on the spot every scholar's heart was fired with a fresh +ambition that often lasted a couple of weeks. It is possible that Tom's +mental stomach had never really hungered for one of those prizes, but +unquestionably his entire being had for many a day longed for the glory +and the eclat that came with it. + +In due course the superintendent stood up in front of the pulpit, with +a closed hymn-book in his hand and his forefinger inserted between its +leaves, and commanded attention. When a Sunday-school superintendent +makes his customary little speech, a hymn-book in the hand is as +necessary as is the inevitable sheet of music in the hand of a singer +who stands forward on the platform and sings a solo at a concert +--though why, is a mystery: for neither the hymn-book nor the sheet of +music is ever referred to by the sufferer. This superintendent was a +slim creature of thirty-five, with a sandy goatee and short sandy hair; +he wore a stiff standing-collar whose upper edge almost reached his +ears and whose sharp points curved forward abreast the corners of his +mouth--a fence that compelled a straight lookout ahead, and a turning +of the whole body when a side view was required; his chin was propped +on a spreading cravat which was as broad and as long as a bank-note, +and had fringed ends; his boot toes were turned sharply up, in the +fashion of the day, like sleigh-runners--an effect patiently and +laboriously produced by the young men by sitting with their toes +pressed against a wall for hours together. Mr. Walters was very earnest +of mien, and very sincere and honest at heart; and he held sacred +things and places in such reverence, and so separated them from worldly +matters, that unconsciously to himself his Sunday-school voice had +acquired a peculiar intonation which was wholly absent on week-days. He +began after this fashion: + +"Now, children, I want you all to sit up just as straight and pretty +as you can and give me all your attention for a minute or two. There +--that is it. That is the way good little boys and girls should do. I see +one little girl who is looking out of the window--I am afraid she +thinks I am out there somewhere--perhaps up in one of the trees making +a speech to the little birds. [Applausive titter.] I want to tell you +how good it makes me feel to see so many bright, clean little faces +assembled in a place like this, learning to do right and be good." And +so forth and so on. It is not necessary to set down the rest of the +oration. It was of a pattern which does not vary, and so it is familiar +to us all. + +The latter third of the speech was marred by the resumption of fights +and other recreations among certain of the bad boys, and by fidgetings +and whisperings that extended far and wide, washing even to the bases +of isolated and incorruptible rocks like Sid and Mary. But now every +sound ceased suddenly, with the subsidence of Mr. Walters' voice, and +the conclusion of the speech was received with a burst of silent +gratitude. + +A good part of the whispering had been occasioned by an event which +was more or less rare--the entrance of visitors: lawyer Thatcher, +accompanied by a very feeble and aged man; a fine, portly, middle-aged +gentleman with iron-gray hair; and a dignified lady who was doubtless +the latter's wife. The lady was leading a child. Tom had been restless +and full of chafings and repinings; conscience-smitten, too--he could +not meet Amy Lawrence's eye, he could not brook her loving gaze. But +when he saw this small new-comer his soul was all ablaze with bliss in +a moment. The next moment he was "showing off" with all his might +--cuffing boys, pulling hair, making faces--in a word, using every art +that seemed likely to fascinate a girl and win her applause. His +exaltation had but one alloy--the memory of his humiliation in this +angel's garden--and that record in sand was fast washing out, under +the waves of happiness that were sweeping over it now. + +The visitors were given the highest seat of honor, and as soon as Mr. +Walters' speech was finished, he introduced them to the school. The +middle-aged man turned out to be a prodigious personage--no less a one +than the county judge--altogether the most august creation these +children had ever looked upon--and they wondered what kind of material +he was made of--and they half wanted to hear him roar, and were half +afraid he might, too. He was from Constantinople, twelve miles away--so +he had travelled, and seen the world--these very eyes had looked upon +the county court-house--which was said to have a tin roof. The awe +which these reflections inspired was attested by the impressive silence +and the ranks of staring eyes. This was the great Judge Thatcher, +brother of their own lawyer. Jeff Thatcher immediately went forward, to +be familiar with the great man and be envied by the school. It would +have been music to his soul to hear the whisperings: + +"Look at him, Jim! He's a going up there. Say--look! he's a going to +shake hands with him--he IS shaking hands with him! By jings, don't you +wish you was Jeff?" + +Mr. Walters fell to "showing off," with all sorts of official +bustlings and activities, giving orders, delivering judgments, +discharging directions here, there, everywhere that he could find a +target. The librarian "showed off"--running hither and thither with his +arms full of books and making a deal of the splutter and fuss that +insect authority delights in. The young lady teachers "showed off" +--bending sweetly over pupils that were lately being boxed, lifting +pretty warning fingers at bad little boys and patting good ones +lovingly. The young gentlemen teachers "showed off" with small +scoldings and other little displays of authority and fine attention to +discipline--and most of the teachers, of both sexes, found business up +at the library, by the pulpit; and it was business that frequently had +to be done over again two or three times (with much seeming vexation). +The little girls "showed off" in various ways, and the little boys +"showed off" with such diligence that the air was thick with paper wads +and the murmur of scufflings. And above it all the great man sat and +beamed a majestic judicial smile upon all the house, and warmed himself +in the sun of his own grandeur--for he was "showing off," too. + +There was only one thing wanting to make Mr. Walters' ecstasy +complete, and that was a chance to deliver a Bible-prize and exhibit a +prodigy. Several pupils had a few yellow tickets, but none had enough +--he had been around among the star pupils inquiring. He would have given +worlds, now, to have that German lad back again with a sound mind. + +And now at this moment, when hope was dead, Tom Sawyer came forward +with nine yellow tickets, nine red tickets, and ten blue ones, and +demanded a Bible. This was a thunderbolt out of a clear sky. Walters +was not expecting an application from this source for the next ten +years. But there was no getting around it--here were the certified +checks, and they were good for their face. Tom was therefore elevated +to a place with the Judge and the other elect, and the great news was +announced from headquarters. It was the most stunning surprise of the +decade, and so profound was the sensation that it lifted the new hero +up to the judicial one's altitude, and the school had two marvels to +gaze upon in place of one. The boys were all eaten up with envy--but +those that suffered the bitterest pangs were those who perceived too +late that they themselves had contributed to this hated splendor by +trading tickets to Tom for the wealth he had amassed in selling +whitewashing privileges. These despised themselves, as being the dupes +of a wily fraud, a guileful snake in the grass. + +The prize was delivered to Tom with as much effusion as the +superintendent could pump up under the circumstances; but it lacked +somewhat of the true gush, for the poor fellow's instinct taught him +that there was a mystery here that could not well bear the light, +perhaps; it was simply preposterous that this boy had warehoused two +thousand sheaves of Scriptural wisdom on his premises--a dozen would +strain his capacity, without a doubt. + +Amy Lawrence was proud and glad, and she tried to make Tom see it in +her face--but he wouldn't look. She wondered; then she was just a grain +troubled; next a dim suspicion came and went--came again; she watched; +a furtive glance told her worlds--and then her heart broke, and she was +jealous, and angry, and the tears came and she hated everybody. Tom +most of all (she thought). + +Tom was introduced to the Judge; but his tongue was tied, his breath +would hardly come, his heart quaked--partly because of the awful +greatness of the man, but mainly because he was her parent. He would +have liked to fall down and worship him, if it were in the dark. The +Judge put his hand on Tom's head and called him a fine little man, and +asked him what his name was. The boy stammered, gasped, and got it out: + +"Tom." + +"Oh, no, not Tom--it is--" + +"Thomas." + +"Ah, that's it. I thought there was more to it, maybe. That's very +well. But you've another one I daresay, and you'll tell it to me, won't +you?" + +"Tell the gentleman your other name, Thomas," said Walters, "and say +sir. You mustn't forget your manners." + +"Thomas Sawyer--sir." + +"That's it! That's a good boy. Fine boy. Fine, manly little fellow. +Two thousand verses is a great many--very, very great many. And you +never can be sorry for the trouble you took to learn them; for +knowledge is worth more than anything there is in the world; it's what +makes great men and good men; you'll be a great man and a good man +yourself, some day, Thomas, and then you'll look back and say, It's all +owing to the precious Sunday-school privileges of my boyhood--it's all +owing to my dear teachers that taught me to learn--it's all owing to +the good superintendent, who encouraged me, and watched over me, and +gave me a beautiful Bible--a splendid elegant Bible--to keep and have +it all for my own, always--it's all owing to right bringing up! That is +what you will say, Thomas--and you wouldn't take any money for those +two thousand verses--no indeed you wouldn't. And now you wouldn't mind +telling me and this lady some of the things you've learned--no, I know +you wouldn't--for we are proud of little boys that learn. Now, no +doubt you know the names of all the twelve disciples. Won't you tell us +the names of the first two that were appointed?" + +Tom was tugging at a button-hole and looking sheepish. He blushed, +now, and his eyes fell. Mr. Walters' heart sank within him. He said to +himself, it is not possible that the boy can answer the simplest +question--why DID the Judge ask him? Yet he felt obliged to speak up +and say: + +"Answer the gentleman, Thomas--don't be afraid." + +Tom still hung fire. + +"Now I know you'll tell me," said the lady. "The names of the first +two disciples were--" + +"DAVID AND GOLIAH!" + +Let us draw the curtain of charity over the rest of the scene. + + + +CHAPTER V + +ABOUT half-past ten the cracked bell of the small church began to +ring, and presently the people began to gather for the morning sermon. +The Sunday-school children distributed themselves about the house and +occupied pews with their parents, so as to be under supervision. Aunt +Polly came, and Tom and Sid and Mary sat with her--Tom being placed +next the aisle, in order that he might be as far away from the open +window and the seductive outside summer scenes as possible. The crowd +filed up the aisles: the aged and needy postmaster, who had seen better +days; the mayor and his wife--for they had a mayor there, among other +unnecessaries; the justice of the peace; the widow Douglass, fair, +smart, and forty, a generous, good-hearted soul and well-to-do, her +hill mansion the only palace in the town, and the most hospitable and +much the most lavish in the matter of festivities that St. Petersburg +could boast; the bent and venerable Major and Mrs. Ward; lawyer +Riverson, the new notable from a distance; next the belle of the +village, followed by a troop of lawn-clad and ribbon-decked young +heart-breakers; then all the young clerks in town in a body--for they +had stood in the vestibule sucking their cane-heads, a circling wall of +oiled and simpering admirers, till the last girl had run their gantlet; +and last of all came the Model Boy, Willie Mufferson, taking as heedful +care of his mother as if she were cut glass. He always brought his +mother to church, and was the pride of all the matrons. The boys all +hated him, he was so good. And besides, he had been "thrown up to them" +so much. His white handkerchief was hanging out of his pocket behind, as +usual on Sundays--accidentally. Tom had no handkerchief, and he looked +upon boys who had as snobs. + +The congregation being fully assembled, now, the bell rang once more, +to warn laggards and stragglers, and then a solemn hush fell upon the +church which was only broken by the tittering and whispering of the +choir in the gallery. The choir always tittered and whispered all +through service. There was once a church choir that was not ill-bred, +but I have forgotten where it was, now. It was a great many years ago, +and I can scarcely remember anything about it, but I think it was in +some foreign country. + +The minister gave out the hymn, and read it through with a relish, in +a peculiar style which was much admired in that part of the country. +His voice began on a medium key and climbed steadily up till it reached +a certain point, where it bore with strong emphasis upon the topmost +word and then plunged down as if from a spring-board: + + Shall I be car-ri-ed toe the skies, on flow'ry BEDS of ease, + + Whilst others fight to win the prize, and sail thro' BLOODY seas? + +He was regarded as a wonderful reader. At church "sociables" he was +always called upon to read poetry; and when he was through, the ladies +would lift up their hands and let them fall helplessly in their laps, +and "wall" their eyes, and shake their heads, as much as to say, "Words +cannot express it; it is too beautiful, TOO beautiful for this mortal +earth." + +After the hymn had been sung, the Rev. Mr. Sprague turned himself into +a bulletin-board, and read off "notices" of meetings and societies and +things till it seemed that the list would stretch out to the crack of +doom--a queer custom which is still kept up in America, even in cities, +away here in this age of abundant newspapers. Often, the less there is +to justify a traditional custom, the harder it is to get rid of it. + +And now the minister prayed. A good, generous prayer it was, and went +into details: it pleaded for the church, and the little children of the +church; for the other churches of the village; for the village itself; +for the county; for the State; for the State officers; for the United +States; for the churches of the United States; for Congress; for the +President; for the officers of the Government; for poor sailors, tossed +by stormy seas; for the oppressed millions groaning under the heel of +European monarchies and Oriental despotisms; for such as have the light +and the good tidings, and yet have not eyes to see nor ears to hear +withal; for the heathen in the far islands of the sea; and closed with +a supplication that the words he was about to speak might find grace +and favor, and be as seed sown in fertile ground, yielding in time a +grateful harvest of good. Amen. + +There was a rustling of dresses, and the standing congregation sat +down. The boy whose history this book relates did not enjoy the prayer, +he only endured it--if he even did that much. He was restive all +through it; he kept tally of the details of the prayer, unconsciously +--for he was not listening, but he knew the ground of old, and the +clergyman's regular route over it--and when a little trifle of new +matter was interlarded, his ear detected it and his whole nature +resented it; he considered additions unfair, and scoundrelly. In the +midst of the prayer a fly had lit on the back of the pew in front of +him and tortured his spirit by calmly rubbing its hands together, +embracing its head with its arms, and polishing it so vigorously that +it seemed to almost part company with the body, and the slender thread +of a neck was exposed to view; scraping its wings with its hind legs +and smoothing them to its body as if they had been coat-tails; going +through its whole toilet as tranquilly as if it knew it was perfectly +safe. As indeed it was; for as sorely as Tom's hands itched to grab for +it they did not dare--he believed his soul would be instantly destroyed +if he did such a thing while the prayer was going on. But with the +closing sentence his hand began to curve and steal forward; and the +instant the "Amen" was out the fly was a prisoner of war. His aunt +detected the act and made him let it go. + +The minister gave out his text and droned along monotonously through +an argument that was so prosy that many a head by and by began to nod +--and yet it was an argument that dealt in limitless fire and brimstone +and thinned the predestined elect down to a company so small as to be +hardly worth the saving. Tom counted the pages of the sermon; after +church he always knew how many pages there had been, but he seldom knew +anything else about the discourse. However, this time he was really +interested for a little while. The minister made a grand and moving +picture of the assembling together of the world's hosts at the +millennium when the lion and the lamb should lie down together and a +little child should lead them. But the pathos, the lesson, the moral of +the great spectacle were lost upon the boy; he only thought of the +conspicuousness of the principal character before the on-looking +nations; his face lit with the thought, and he said to himself that he +wished he could be that child, if it was a tame lion. + +Now he lapsed into suffering again, as the dry argument was resumed. +Presently he bethought him of a treasure he had and got it out. It was +a large black beetle with formidable jaws--a "pinchbug," he called it. +It was in a percussion-cap box. The first thing the beetle did was to +take him by the finger. A natural fillip followed, the beetle went +floundering into the aisle and lit on its back, and the hurt finger +went into the boy's mouth. The beetle lay there working its helpless +legs, unable to turn over. Tom eyed it, and longed for it; but it was +safe out of his reach. Other people uninterested in the sermon found +relief in the beetle, and they eyed it too. Presently a vagrant poodle +dog came idling along, sad at heart, lazy with the summer softness and +the quiet, weary of captivity, sighing for change. He spied the beetle; +the drooping tail lifted and wagged. He surveyed the prize; walked +around it; smelt at it from a safe distance; walked around it again; +grew bolder, and took a closer smell; then lifted his lip and made a +gingerly snatch at it, just missing it; made another, and another; +began to enjoy the diversion; subsided to his stomach with the beetle +between his paws, and continued his experiments; grew weary at last, +and then indifferent and absent-minded. His head nodded, and little by +little his chin descended and touched the enemy, who seized it. There +was a sharp yelp, a flirt of the poodle's head, and the beetle fell a +couple of yards away, and lit on its back once more. The neighboring +spectators shook with a gentle inward joy, several faces went behind +fans and handkerchiefs, and Tom was entirely happy. The dog looked +foolish, and probably felt so; but there was resentment in his heart, +too, and a craving for revenge. So he went to the beetle and began a +wary attack on it again; jumping at it from every point of a circle, +lighting with his fore-paws within an inch of the creature, making even +closer snatches at it with his teeth, and jerking his head till his +ears flapped again. But he grew tired once more, after a while; tried +to amuse himself with a fly but found no relief; followed an ant +around, with his nose close to the floor, and quickly wearied of that; +yawned, sighed, forgot the beetle entirely, and sat down on it. Then +there was a wild yelp of agony and the poodle went sailing up the +aisle; the yelps continued, and so did the dog; he crossed the house in +front of the altar; he flew down the other aisle; he crossed before the +doors; he clamored up the home-stretch; his anguish grew with his +progress, till presently he was but a woolly comet moving in its orbit +with the gleam and the speed of light. At last the frantic sufferer +sheered from its course, and sprang into its master's lap; he flung it +out of the window, and the voice of distress quickly thinned away and +died in the distance. + +By this time the whole church was red-faced and suffocating with +suppressed laughter, and the sermon had come to a dead standstill. The +discourse was resumed presently, but it went lame and halting, all +possibility of impressiveness being at an end; for even the gravest +sentiments were constantly being received with a smothered burst of +unholy mirth, under cover of some remote pew-back, as if the poor +parson had said a rarely facetious thing. It was a genuine relief to +the whole congregation when the ordeal was over and the benediction +pronounced. + +Tom Sawyer went home quite cheerful, thinking to himself that there +was some satisfaction about divine service when there was a bit of +variety in it. He had but one marring thought; he was willing that the +dog should play with his pinchbug, but he did not think it was upright +in him to carry it off. + + + +CHAPTER VI + +MONDAY morning found Tom Sawyer miserable. Monday morning always found +him so--because it began another week's slow suffering in school. He +generally began that day with wishing he had had no intervening +holiday, it made the going into captivity and fetters again so much +more odious. + +Tom lay thinking. Presently it occurred to him that he wished he was +sick; then he could stay home from school. Here was a vague +possibility. He canvassed his system. No ailment was found, and he +investigated again. This time he thought he could detect colicky +symptoms, and he began to encourage them with considerable hope. But +they soon grew feeble, and presently died wholly away. He reflected +further. Suddenly he discovered something. One of his upper front teeth +was loose. This was lucky; he was about to begin to groan, as a +"starter," as he called it, when it occurred to him that if he came +into court with that argument, his aunt would pull it out, and that +would hurt. So he thought he would hold the tooth in reserve for the +present, and seek further. Nothing offered for some little time, and +then he remembered hearing the doctor tell about a certain thing that +laid up a patient for two or three weeks and threatened to make him +lose a finger. So the boy eagerly drew his sore toe from under the +sheet and held it up for inspection. But now he did not know the +necessary symptoms. However, it seemed well worth while to chance it, +so he fell to groaning with considerable spirit. + +But Sid slept on unconscious. + +Tom groaned louder, and fancied that he began to feel pain in the toe. + +No result from Sid. + +Tom was panting with his exertions by this time. He took a rest and +then swelled himself up and fetched a succession of admirable groans. + +Sid snored on. + +Tom was aggravated. He said, "Sid, Sid!" and shook him. This course +worked well, and Tom began to groan again. Sid yawned, stretched, then +brought himself up on his elbow with a snort, and began to stare at +Tom. Tom went on groaning. Sid said: + +"Tom! Say, Tom!" [No response.] "Here, Tom! TOM! What is the matter, +Tom?" And he shook him and looked in his face anxiously. + +Tom moaned out: + +"Oh, don't, Sid. Don't joggle me." + +"Why, what's the matter, Tom? I must call auntie." + +"No--never mind. It'll be over by and by, maybe. Don't call anybody." + +"But I must! DON'T groan so, Tom, it's awful. How long you been this +way?" + +"Hours. Ouch! Oh, don't stir so, Sid, you'll kill me." + +"Tom, why didn't you wake me sooner? Oh, Tom, DON'T! It makes my +flesh crawl to hear you. Tom, what is the matter?" + +"I forgive you everything, Sid. [Groan.] Everything you've ever done +to me. When I'm gone--" + +"Oh, Tom, you ain't dying, are you? Don't, Tom--oh, don't. Maybe--" + +"I forgive everybody, Sid. [Groan.] Tell 'em so, Sid. And Sid, you +give my window-sash and my cat with one eye to that new girl that's +come to town, and tell her--" + +But Sid had snatched his clothes and gone. Tom was suffering in +reality, now, so handsomely was his imagination working, and so his +groans had gathered quite a genuine tone. + +Sid flew down-stairs and said: + +"Oh, Aunt Polly, come! Tom's dying!" + +"Dying!" + +"Yes'm. Don't wait--come quick!" + +"Rubbage! I don't believe it!" + +But she fled up-stairs, nevertheless, with Sid and Mary at her heels. +And her face grew white, too, and her lip trembled. When she reached +the bedside she gasped out: + +"You, Tom! Tom, what's the matter with you?" + +"Oh, auntie, I'm--" + +"What's the matter with you--what is the matter with you, child?" + +"Oh, auntie, my sore toe's mortified!" + +The old lady sank down into a chair and laughed a little, then cried a +little, then did both together. This restored her and she said: + +"Tom, what a turn you did give me. Now you shut up that nonsense and +climb out of this." + +The groans ceased and the pain vanished from the toe. The boy felt a +little foolish, and he said: + +"Aunt Polly, it SEEMED mortified, and it hurt so I never minded my +tooth at all." + +"Your tooth, indeed! What's the matter with your tooth?" + +"One of them's loose, and it aches perfectly awful." + +"There, there, now, don't begin that groaning again. Open your mouth. +Well--your tooth IS loose, but you're not going to die about that. +Mary, get me a silk thread, and a chunk of fire out of the kitchen." + +Tom said: + +"Oh, please, auntie, don't pull it out. It don't hurt any more. I wish +I may never stir if it does. Please don't, auntie. I don't want to stay +home from school." + +"Oh, you don't, don't you? So all this row was because you thought +you'd get to stay home from school and go a-fishing? Tom, Tom, I love +you so, and you seem to try every way you can to break my old heart +with your outrageousness." By this time the dental instruments were +ready. The old lady made one end of the silk thread fast to Tom's tooth +with a loop and tied the other to the bedpost. Then she seized the +chunk of fire and suddenly thrust it almost into the boy's face. The +tooth hung dangling by the bedpost, now. + +But all trials bring their compensations. As Tom wended to school +after breakfast, he was the envy of every boy he met because the gap in +his upper row of teeth enabled him to expectorate in a new and +admirable way. He gathered quite a following of lads interested in the +exhibition; and one that had cut his finger and had been a centre of +fascination and homage up to this time, now found himself suddenly +without an adherent, and shorn of his glory. His heart was heavy, and +he said with a disdain which he did not feel that it wasn't anything to +spit like Tom Sawyer; but another boy said, "Sour grapes!" and he +wandered away a dismantled hero. + +Shortly Tom came upon the juvenile pariah of the village, Huckleberry +Finn, son of the town drunkard. Huckleberry was cordially hated and +dreaded by all the mothers of the town, because he was idle and lawless +and vulgar and bad--and because all their children admired him so, and +delighted in his forbidden society, and wished they dared to be like +him. Tom was like the rest of the respectable boys, in that he envied +Huckleberry his gaudy outcast condition, and was under strict orders +not to play with him. So he played with him every time he got a chance. +Huckleberry was always dressed in the cast-off clothes of full-grown +men, and they were in perennial bloom and fluttering with rags. His hat +was a vast ruin with a wide crescent lopped out of its brim; his coat, +when he wore one, hung nearly to his heels and had the rearward buttons +far down the back; but one suspender supported his trousers; the seat +of the trousers bagged low and contained nothing, the fringed legs +dragged in the dirt when not rolled up. + +Huckleberry came and went, at his own free will. He slept on doorsteps +in fine weather and in empty hogsheads in wet; he did not have to go to +school or to church, or call any being master or obey anybody; he could +go fishing or swimming when and where he chose, and stay as long as it +suited him; nobody forbade him to fight; he could sit up as late as he +pleased; he was always the first boy that went barefoot in the spring +and the last to resume leather in the fall; he never had to wash, nor +put on clean clothes; he could swear wonderfully. In a word, everything +that goes to make life precious that boy had. So thought every +harassed, hampered, respectable boy in St. Petersburg. + +Tom hailed the romantic outcast: + +"Hello, Huckleberry!" + +"Hello yourself, and see how you like it." + +"What's that you got?" + +"Dead cat." + +"Lemme see him, Huck. My, he's pretty stiff. Where'd you get him?" + +"Bought him off'n a boy." + +"What did you give?" + +"I give a blue ticket and a bladder that I got at the slaughter-house." + +"Where'd you get the blue ticket?" + +"Bought it off'n Ben Rogers two weeks ago for a hoop-stick." + +"Say--what is dead cats good for, Huck?" + +"Good for? Cure warts with." + +"No! Is that so? I know something that's better." + +"I bet you don't. What is it?" + +"Why, spunk-water." + +"Spunk-water! I wouldn't give a dern for spunk-water." + +"You wouldn't, wouldn't you? D'you ever try it?" + +"No, I hain't. But Bob Tanner did." + +"Who told you so!" + +"Why, he told Jeff Thatcher, and Jeff told Johnny Baker, and Johnny +told Jim Hollis, and Jim told Ben Rogers, and Ben told a nigger, and +the nigger told me. There now!" + +"Well, what of it? They'll all lie. Leastways all but the nigger. I +don't know HIM. But I never see a nigger that WOULDN'T lie. Shucks! Now +you tell me how Bob Tanner done it, Huck." + +"Why, he took and dipped his hand in a rotten stump where the +rain-water was." + +"In the daytime?" + +"Certainly." + +"With his face to the stump?" + +"Yes. Least I reckon so." + +"Did he say anything?" + +"I don't reckon he did. I don't know." + +"Aha! Talk about trying to cure warts with spunk-water such a blame +fool way as that! Why, that ain't a-going to do any good. You got to go +all by yourself, to the middle of the woods, where you know there's a +spunk-water stump, and just as it's midnight you back up against the +stump and jam your hand in and say: + + 'Barley-corn, barley-corn, injun-meal shorts, + Spunk-water, spunk-water, swaller these warts,' + +and then walk away quick, eleven steps, with your eyes shut, and then +turn around three times and walk home without speaking to anybody. +Because if you speak the charm's busted." + +"Well, that sounds like a good way; but that ain't the way Bob Tanner +done." + +"No, sir, you can bet he didn't, becuz he's the wartiest boy in this +town; and he wouldn't have a wart on him if he'd knowed how to work +spunk-water. I've took off thousands of warts off of my hands that way, +Huck. I play with frogs so much that I've always got considerable many +warts. Sometimes I take 'em off with a bean." + +"Yes, bean's good. I've done that." + +"Have you? What's your way?" + +"You take and split the bean, and cut the wart so as to get some +blood, and then you put the blood on one piece of the bean and take and +dig a hole and bury it 'bout midnight at the crossroads in the dark of +the moon, and then you burn up the rest of the bean. You see that piece +that's got the blood on it will keep drawing and drawing, trying to +fetch the other piece to it, and so that helps the blood to draw the +wart, and pretty soon off she comes." + +"Yes, that's it, Huck--that's it; though when you're burying it if you +say 'Down bean; off wart; come no more to bother me!' it's better. +That's the way Joe Harper does, and he's been nearly to Coonville and +most everywheres. But say--how do you cure 'em with dead cats?" + +"Why, you take your cat and go and get in the graveyard 'long about +midnight when somebody that was wicked has been buried; and when it's +midnight a devil will come, or maybe two or three, but you can't see +'em, you can only hear something like the wind, or maybe hear 'em talk; +and when they're taking that feller away, you heave your cat after 'em +and say, 'Devil follow corpse, cat follow devil, warts follow cat, I'm +done with ye!' That'll fetch ANY wart." + +"Sounds right. D'you ever try it, Huck?" + +"No, but old Mother Hopkins told me." + +"Well, I reckon it's so, then. Becuz they say she's a witch." + +"Say! Why, Tom, I KNOW she is. She witched pap. Pap says so his own +self. He come along one day, and he see she was a-witching him, so he +took up a rock, and if she hadn't dodged, he'd a got her. Well, that +very night he rolled off'n a shed wher' he was a layin drunk, and broke +his arm." + +"Why, that's awful. How did he know she was a-witching him?" + +"Lord, pap can tell, easy. Pap says when they keep looking at you +right stiddy, they're a-witching you. Specially if they mumble. Becuz +when they mumble they're saying the Lord's Prayer backards." + +"Say, Hucky, when you going to try the cat?" + +"To-night. I reckon they'll come after old Hoss Williams to-night." + +"But they buried him Saturday. Didn't they get him Saturday night?" + +"Why, how you talk! How could their charms work till midnight?--and +THEN it's Sunday. Devils don't slosh around much of a Sunday, I don't +reckon." + +"I never thought of that. That's so. Lemme go with you?" + +"Of course--if you ain't afeard." + +"Afeard! 'Tain't likely. Will you meow?" + +"Yes--and you meow back, if you get a chance. Last time, you kep' me +a-meowing around till old Hays went to throwing rocks at me and says +'Dern that cat!' and so I hove a brick through his window--but don't +you tell." + +"I won't. I couldn't meow that night, becuz auntie was watching me, +but I'll meow this time. Say--what's that?" + +"Nothing but a tick." + +"Where'd you get him?" + +"Out in the woods." + +"What'll you take for him?" + +"I don't know. I don't want to sell him." + +"All right. It's a mighty small tick, anyway." + +"Oh, anybody can run a tick down that don't belong to them. I'm +satisfied with it. It's a good enough tick for me." + +"Sho, there's ticks a plenty. I could have a thousand of 'em if I +wanted to." + +"Well, why don't you? Becuz you know mighty well you can't. This is a +pretty early tick, I reckon. It's the first one I've seen this year." + +"Say, Huck--I'll give you my tooth for him." + +"Less see it." + +Tom got out a bit of paper and carefully unrolled it. Huckleberry +viewed it wistfully. The temptation was very strong. At last he said: + +"Is it genuwyne?" + +Tom lifted his lip and showed the vacancy. + +"Well, all right," said Huckleberry, "it's a trade." + +Tom enclosed the tick in the percussion-cap box that had lately been +the pinchbug's prison, and the boys separated, each feeling wealthier +than before. + +When Tom reached the little isolated frame schoolhouse, he strode in +briskly, with the manner of one who had come with all honest speed. +He hung his hat on a peg and flung himself into his seat with +business-like alacrity. The master, throned on high in his great +splint-bottom arm-chair, was dozing, lulled by the drowsy hum of study. +The interruption roused him. + +"Thomas Sawyer!" + +Tom knew that when his name was pronounced in full, it meant trouble. + +"Sir!" + +"Come up here. Now, sir, why are you late again, as usual?" + +Tom was about to take refuge in a lie, when he saw two long tails of +yellow hair hanging down a back that he recognized by the electric +sympathy of love; and by that form was THE ONLY VACANT PLACE on the +girls' side of the schoolhouse. He instantly said: + +"I STOPPED TO TALK WITH HUCKLEBERRY FINN!" + +The master's pulse stood still, and he stared helplessly. The buzz of +study ceased. The pupils wondered if this foolhardy boy had lost his +mind. The master said: + +"You--you did what?" + +"Stopped to talk with Huckleberry Finn." + +There was no mistaking the words. + +"Thomas Sawyer, this is the most astounding confession I have ever +listened to. No mere ferule will answer for this offence. Take off your +jacket." + +The master's arm performed until it was tired and the stock of +switches notably diminished. Then the order followed: + +"Now, sir, go and sit with the girls! And let this be a warning to you." + +The titter that rippled around the room appeared to abash the boy, but +in reality that result was caused rather more by his worshipful awe of +his unknown idol and the dread pleasure that lay in his high good +fortune. He sat down upon the end of the pine bench and the girl +hitched herself away from him with a toss of her head. Nudges and winks +and whispers traversed the room, but Tom sat still, with his arms upon +the long, low desk before him, and seemed to study his book. + +By and by attention ceased from him, and the accustomed school murmur +rose upon the dull air once more. Presently the boy began to steal +furtive glances at the girl. She observed it, "made a mouth" at him and +gave him the back of her head for the space of a minute. When she +cautiously faced around again, a peach lay before her. She thrust it +away. Tom gently put it back. She thrust it away again, but with less +animosity. Tom patiently returned it to its place. Then she let it +remain. Tom scrawled on his slate, "Please take it--I got more." The +girl glanced at the words, but made no sign. Now the boy began to draw +something on the slate, hiding his work with his left hand. For a time +the girl refused to notice; but her human curiosity presently began to +manifest itself by hardly perceptible signs. The boy worked on, +apparently unconscious. The girl made a sort of noncommittal attempt to +see, but the boy did not betray that he was aware of it. At last she +gave in and hesitatingly whispered: + +"Let me see it." + +Tom partly uncovered a dismal caricature of a house with two gable +ends to it and a corkscrew of smoke issuing from the chimney. Then the +girl's interest began to fasten itself upon the work and she forgot +everything else. When it was finished, she gazed a moment, then +whispered: + +"It's nice--make a man." + +The artist erected a man in the front yard, that resembled a derrick. +He could have stepped over the house; but the girl was not +hypercritical; she was satisfied with the monster, and whispered: + +"It's a beautiful man--now make me coming along." + +Tom drew an hour-glass with a full moon and straw limbs to it and +armed the spreading fingers with a portentous fan. The girl said: + +"It's ever so nice--I wish I could draw." + +"It's easy," whispered Tom, "I'll learn you." + +"Oh, will you? When?" + +"At noon. Do you go home to dinner?" + +"I'll stay if you will." + +"Good--that's a whack. What's your name?" + +"Becky Thatcher. What's yours? Oh, I know. It's Thomas Sawyer." + +"That's the name they lick me by. I'm Tom when I'm good. You call me +Tom, will you?" + +"Yes." + +Now Tom began to scrawl something on the slate, hiding the words from +the girl. But she was not backward this time. She begged to see. Tom +said: + +"Oh, it ain't anything." + +"Yes it is." + +"No it ain't. You don't want to see." + +"Yes I do, indeed I do. Please let me." + +"You'll tell." + +"No I won't--deed and deed and double deed won't." + +"You won't tell anybody at all? Ever, as long as you live?" + +"No, I won't ever tell ANYbody. Now let me." + +"Oh, YOU don't want to see!" + +"Now that you treat me so, I WILL see." And she put her small hand +upon his and a little scuffle ensued, Tom pretending to resist in +earnest but letting his hand slip by degrees till these words were +revealed: "I LOVE YOU." + +"Oh, you bad thing!" And she hit his hand a smart rap, but reddened +and looked pleased, nevertheless. + +Just at this juncture the boy felt a slow, fateful grip closing on his +ear, and a steady lifting impulse. In that wise he was borne across the +house and deposited in his own seat, under a peppering fire of giggles +from the whole school. Then the master stood over him during a few +awful moments, and finally moved away to his throne without saying a +word. But although Tom's ear tingled, his heart was jubilant. + +As the school quieted down Tom made an honest effort to study, but the +turmoil within him was too great. In turn he took his place in the +reading class and made a botch of it; then in the geography class and +turned lakes into mountains, mountains into rivers, and rivers into +continents, till chaos was come again; then in the spelling class, and +got "turned down," by a succession of mere baby words, till he brought +up at the foot and yielded up the pewter medal which he had worn with +ostentation for months. + + + +CHAPTER VII + +THE harder Tom tried to fasten his mind on his book, the more his +ideas wandered. So at last, with a sigh and a yawn, he gave it up. It +seemed to him that the noon recess would never come. The air was +utterly dead. There was not a breath stirring. It was the sleepiest of +sleepy days. The drowsing murmur of the five and twenty studying +scholars soothed the soul like the spell that is in the murmur of bees. +Away off in the flaming sunshine, Cardiff Hill lifted its soft green +sides through a shimmering veil of heat, tinted with the purple of +distance; a few birds floated on lazy wing high in the air; no other +living thing was visible but some cows, and they were asleep. Tom's +heart ached to be free, or else to have something of interest to do to +pass the dreary time. His hand wandered into his pocket and his face +lit up with a glow of gratitude that was prayer, though he did not know +it. Then furtively the percussion-cap box came out. He released the +tick and put him on the long flat desk. The creature probably glowed +with a gratitude that amounted to prayer, too, at this moment, but it +was premature: for when he started thankfully to travel off, Tom turned +him aside with a pin and made him take a new direction. + +Tom's bosom friend sat next him, suffering just as Tom had been, and +now he was deeply and gratefully interested in this entertainment in an +instant. This bosom friend was Joe Harper. The two boys were sworn +friends all the week, and embattled enemies on Saturdays. Joe took a +pin out of his lapel and began to assist in exercising the prisoner. +The sport grew in interest momently. Soon Tom said that they were +interfering with each other, and neither getting the fullest benefit of +the tick. So he put Joe's slate on the desk and drew a line down the +middle of it from top to bottom. + +"Now," said he, "as long as he is on your side you can stir him up and +I'll let him alone; but if you let him get away and get on my side, +you're to leave him alone as long as I can keep him from crossing over." + +"All right, go ahead; start him up." + +The tick escaped from Tom, presently, and crossed the equator. Joe +harassed him awhile, and then he got away and crossed back again. This +change of base occurred often. While one boy was worrying the tick with +absorbing interest, the other would look on with interest as strong, +the two heads bowed together over the slate, and the two souls dead to +all things else. At last luck seemed to settle and abide with Joe. The +tick tried this, that, and the other course, and got as excited and as +anxious as the boys themselves, but time and again just as he would +have victory in his very grasp, so to speak, and Tom's fingers would be +twitching to begin, Joe's pin would deftly head him off, and keep +possession. At last Tom could stand it no longer. The temptation was +too strong. So he reached out and lent a hand with his pin. Joe was +angry in a moment. Said he: + +"Tom, you let him alone." + +"I only just want to stir him up a little, Joe." + +"No, sir, it ain't fair; you just let him alone." + +"Blame it, I ain't going to stir him much." + +"Let him alone, I tell you." + +"I won't!" + +"You shall--he's on my side of the line." + +"Look here, Joe Harper, whose is that tick?" + +"I don't care whose tick he is--he's on my side of the line, and you +sha'n't touch him." + +"Well, I'll just bet I will, though. He's my tick and I'll do what I +blame please with him, or die!" + +A tremendous whack came down on Tom's shoulders, and its duplicate on +Joe's; and for the space of two minutes the dust continued to fly from +the two jackets and the whole school to enjoy it. The boys had been too +absorbed to notice the hush that had stolen upon the school awhile +before when the master came tiptoeing down the room and stood over +them. He had contemplated a good part of the performance before he +contributed his bit of variety to it. + +When school broke up at noon, Tom flew to Becky Thatcher, and +whispered in her ear: + +"Put on your bonnet and let on you're going home; and when you get to +the corner, give the rest of 'em the slip, and turn down through the +lane and come back. I'll go the other way and come it over 'em the same +way." + +So the one went off with one group of scholars, and the other with +another. In a little while the two met at the bottom of the lane, and +when they reached the school they had it all to themselves. Then they +sat together, with a slate before them, and Tom gave Becky the pencil +and held her hand in his, guiding it, and so created another surprising +house. When the interest in art began to wane, the two fell to talking. +Tom was swimming in bliss. He said: + +"Do you love rats?" + +"No! I hate them!" + +"Well, I do, too--LIVE ones. But I mean dead ones, to swing round your +head with a string." + +"No, I don't care for rats much, anyway. What I like is chewing-gum." + +"Oh, I should say so! I wish I had some now." + +"Do you? I've got some. I'll let you chew it awhile, but you must give +it back to me." + +That was agreeable, so they chewed it turn about, and dangled their +legs against the bench in excess of contentment. + +"Was you ever at a circus?" said Tom. + +"Yes, and my pa's going to take me again some time, if I'm good." + +"I been to the circus three or four times--lots of times. Church ain't +shucks to a circus. There's things going on at a circus all the time. +I'm going to be a clown in a circus when I grow up." + +"Oh, are you! That will be nice. They're so lovely, all spotted up." + +"Yes, that's so. And they get slathers of money--most a dollar a day, +Ben Rogers says. Say, Becky, was you ever engaged?" + +"What's that?" + +"Why, engaged to be married." + +"No." + +"Would you like to?" + +"I reckon so. I don't know. What is it like?" + +"Like? Why it ain't like anything. You only just tell a boy you won't +ever have anybody but him, ever ever ever, and then you kiss and that's +all. Anybody can do it." + +"Kiss? What do you kiss for?" + +"Why, that, you know, is to--well, they always do that." + +"Everybody?" + +"Why, yes, everybody that's in love with each other. Do you remember +what I wrote on the slate?" + +"Ye--yes." + +"What was it?" + +"I sha'n't tell you." + +"Shall I tell YOU?" + +"Ye--yes--but some other time." + +"No, now." + +"No, not now--to-morrow." + +"Oh, no, NOW. Please, Becky--I'll whisper it, I'll whisper it ever so +easy." + +Becky hesitating, Tom took silence for consent, and passed his arm +about her waist and whispered the tale ever so softly, with his mouth +close to her ear. And then he added: + +"Now you whisper it to me--just the same." + +She resisted, for a while, and then said: + +"You turn your face away so you can't see, and then I will. But you +mustn't ever tell anybody--WILL you, Tom? Now you won't, WILL you?" + +"No, indeed, indeed I won't. Now, Becky." + +He turned his face away. She bent timidly around till her breath +stirred his curls and whispered, "I--love--you!" + +Then she sprang away and ran around and around the desks and benches, +with Tom after her, and took refuge in a corner at last, with her +little white apron to her face. Tom clasped her about her neck and +pleaded: + +"Now, Becky, it's all done--all over but the kiss. Don't you be afraid +of that--it ain't anything at all. Please, Becky." And he tugged at her +apron and the hands. + +By and by she gave up, and let her hands drop; her face, all glowing +with the struggle, came up and submitted. Tom kissed the red lips and +said: + +"Now it's all done, Becky. And always after this, you know, you ain't +ever to love anybody but me, and you ain't ever to marry anybody but +me, ever never and forever. Will you?" + +"No, I'll never love anybody but you, Tom, and I'll never marry +anybody but you--and you ain't to ever marry anybody but me, either." + +"Certainly. Of course. That's PART of it. And always coming to school +or when we're going home, you're to walk with me, when there ain't +anybody looking--and you choose me and I choose you at parties, because +that's the way you do when you're engaged." + +"It's so nice. I never heard of it before." + +"Oh, it's ever so gay! Why, me and Amy Lawrence--" + +The big eyes told Tom his blunder and he stopped, confused. + +"Oh, Tom! Then I ain't the first you've ever been engaged to!" + +The child began to cry. Tom said: + +"Oh, don't cry, Becky, I don't care for her any more." + +"Yes, you do, Tom--you know you do." + +Tom tried to put his arm about her neck, but she pushed him away and +turned her face to the wall, and went on crying. Tom tried again, with +soothing words in his mouth, and was repulsed again. Then his pride was +up, and he strode away and went outside. He stood about, restless and +uneasy, for a while, glancing at the door, every now and then, hoping +she would repent and come to find him. But she did not. Then he began +to feel badly and fear that he was in the wrong. It was a hard struggle +with him to make new advances, now, but he nerved himself to it and +entered. She was still standing back there in the corner, sobbing, with +her face to the wall. Tom's heart smote him. He went to her and stood a +moment, not knowing exactly how to proceed. Then he said hesitatingly: + +"Becky, I--I don't care for anybody but you." + +No reply--but sobs. + +"Becky"--pleadingly. "Becky, won't you say something?" + +More sobs. + +Tom got out his chiefest jewel, a brass knob from the top of an +andiron, and passed it around her so that she could see it, and said: + +"Please, Becky, won't you take it?" + +She struck it to the floor. Then Tom marched out of the house and over +the hills and far away, to return to school no more that day. Presently +Becky began to suspect. She ran to the door; he was not in sight; she +flew around to the play-yard; he was not there. Then she called: + +"Tom! Come back, Tom!" + +She listened intently, but there was no answer. She had no companions +but silence and loneliness. So she sat down to cry again and upbraid +herself; and by this time the scholars began to gather again, and she +had to hide her griefs and still her broken heart and take up the cross +of a long, dreary, aching afternoon, with none among the strangers +about her to exchange sorrows with. + + + +CHAPTER VIII + +TOM dodged hither and thither through lanes until he was well out of +the track of returning scholars, and then fell into a moody jog. He +crossed a small "branch" two or three times, because of a prevailing +juvenile superstition that to cross water baffled pursuit. Half an hour +later he was disappearing behind the Douglas mansion on the summit of +Cardiff Hill, and the schoolhouse was hardly distinguishable away off +in the valley behind him. He entered a dense wood, picked his pathless +way to the centre of it, and sat down on a mossy spot under a spreading +oak. There was not even a zephyr stirring; the dead noonday heat had +even stilled the songs of the birds; nature lay in a trance that was +broken by no sound but the occasional far-off hammering of a +woodpecker, and this seemed to render the pervading silence and sense +of loneliness the more profound. The boy's soul was steeped in +melancholy; his feelings were in happy accord with his surroundings. He +sat long with his elbows on his knees and his chin in his hands, +meditating. It seemed to him that life was but a trouble, at best, and +he more than half envied Jimmy Hodges, so lately released; it must be +very peaceful, he thought, to lie and slumber and dream forever and +ever, with the wind whispering through the trees and caressing the +grass and the flowers over the grave, and nothing to bother and grieve +about, ever any more. If he only had a clean Sunday-school record he +could be willing to go, and be done with it all. Now as to this girl. +What had he done? Nothing. He had meant the best in the world, and been +treated like a dog--like a very dog. She would be sorry some day--maybe +when it was too late. Ah, if he could only die TEMPORARILY! + +But the elastic heart of youth cannot be compressed into one +constrained shape long at a time. Tom presently began to drift +insensibly back into the concerns of this life again. What if he turned +his back, now, and disappeared mysteriously? What if he went away--ever +so far away, into unknown countries beyond the seas--and never came +back any more! How would she feel then! The idea of being a clown +recurred to him now, only to fill him with disgust. For frivolity and +jokes and spotted tights were an offense, when they intruded themselves +upon a spirit that was exalted into the vague august realm of the +romantic. No, he would be a soldier, and return after long years, all +war-worn and illustrious. No--better still, he would join the Indians, +and hunt buffaloes and go on the warpath in the mountain ranges and the +trackless great plains of the Far West, and away in the future come +back a great chief, bristling with feathers, hideous with paint, and +prance into Sunday-school, some drowsy summer morning, with a +bloodcurdling war-whoop, and sear the eyeballs of all his companions +with unappeasable envy. But no, there was something gaudier even than +this. He would be a pirate! That was it! NOW his future lay plain +before him, and glowing with unimaginable splendor. How his name would +fill the world, and make people shudder! How gloriously he would go +plowing the dancing seas, in his long, low, black-hulled racer, the +Spirit of the Storm, with his grisly flag flying at the fore! And at +the zenith of his fame, how he would suddenly appear at the old village +and stalk into church, brown and weather-beaten, in his black velvet +doublet and trunks, his great jack-boots, his crimson sash, his belt +bristling with horse-pistols, his crime-rusted cutlass at his side, his +slouch hat with waving plumes, his black flag unfurled, with the skull +and crossbones on it, and hear with swelling ecstasy the whisperings, +"It's Tom Sawyer the Pirate!--the Black Avenger of the Spanish Main!" + +Yes, it was settled; his career was determined. He would run away from +home and enter upon it. He would start the very next morning. Therefore +he must now begin to get ready. He would collect his resources +together. He went to a rotten log near at hand and began to dig under +one end of it with his Barlow knife. He soon struck wood that sounded +hollow. He put his hand there and uttered this incantation impressively: + +"What hasn't come here, come! What's here, stay here!" + +Then he scraped away the dirt, and exposed a pine shingle. He took it +up and disclosed a shapely little treasure-house whose bottom and sides +were of shingles. In it lay a marble. Tom's astonishment was boundless! +He scratched his head with a perplexed air, and said: + +"Well, that beats anything!" + +Then he tossed the marble away pettishly, and stood cogitating. The +truth was, that a superstition of his had failed, here, which he and +all his comrades had always looked upon as infallible. If you buried a +marble with certain necessary incantations, and left it alone a +fortnight, and then opened the place with the incantation he had just +used, you would find that all the marbles you had ever lost had +gathered themselves together there, meantime, no matter how widely they +had been separated. But now, this thing had actually and unquestionably +failed. Tom's whole structure of faith was shaken to its foundations. +He had many a time heard of this thing succeeding but never of its +failing before. It did not occur to him that he had tried it several +times before, himself, but could never find the hiding-places +afterward. He puzzled over the matter some time, and finally decided +that some witch had interfered and broken the charm. He thought he +would satisfy himself on that point; so he searched around till he +found a small sandy spot with a little funnel-shaped depression in it. +He laid himself down and put his mouth close to this depression and +called-- + +"Doodle-bug, doodle-bug, tell me what I want to know! Doodle-bug, +doodle-bug, tell me what I want to know!" + +The sand began to work, and presently a small black bug appeared for a +second and then darted under again in a fright. + +"He dasn't tell! So it WAS a witch that done it. I just knowed it." + +He well knew the futility of trying to contend against witches, so he +gave up discouraged. But it occurred to him that he might as well have +the marble he had just thrown away, and therefore he went and made a +patient search for it. But he could not find it. Now he went back to +his treasure-house and carefully placed himself just as he had been +standing when he tossed the marble away; then he took another marble +from his pocket and tossed it in the same way, saying: + +"Brother, go find your brother!" + +He watched where it stopped, and went there and looked. But it must +have fallen short or gone too far; so he tried twice more. The last +repetition was successful. The two marbles lay within a foot of each +other. + +Just here the blast of a toy tin trumpet came faintly down the green +aisles of the forest. Tom flung off his jacket and trousers, turned a +suspender into a belt, raked away some brush behind the rotten log, +disclosing a rude bow and arrow, a lath sword and a tin trumpet, and in +a moment had seized these things and bounded away, barelegged, with +fluttering shirt. He presently halted under a great elm, blew an +answering blast, and then began to tiptoe and look warily out, this way +and that. He said cautiously--to an imaginary company: + +"Hold, my merry men! Keep hid till I blow." + +Now appeared Joe Harper, as airily clad and elaborately armed as Tom. +Tom called: + +"Hold! Who comes here into Sherwood Forest without my pass?" + +"Guy of Guisborne wants no man's pass. Who art thou that--that--" + +"Dares to hold such language," said Tom, prompting--for they talked +"by the book," from memory. + +"Who art thou that dares to hold such language?" + +"I, indeed! I am Robin Hood, as thy caitiff carcase soon shall know." + +"Then art thou indeed that famous outlaw? Right gladly will I dispute +with thee the passes of the merry wood. Have at thee!" + +They took their lath swords, dumped their other traps on the ground, +struck a fencing attitude, foot to foot, and began a grave, careful +combat, "two up and two down." Presently Tom said: + +"Now, if you've got the hang, go it lively!" + +So they "went it lively," panting and perspiring with the work. By and +by Tom shouted: + +"Fall! fall! Why don't you fall?" + +"I sha'n't! Why don't you fall yourself? You're getting the worst of +it." + +"Why, that ain't anything. I can't fall; that ain't the way it is in +the book. The book says, 'Then with one back-handed stroke he slew poor +Guy of Guisborne.' You're to turn around and let me hit you in the +back." + +There was no getting around the authorities, so Joe turned, received +the whack and fell. + +"Now," said Joe, getting up, "you got to let me kill YOU. That's fair." + +"Why, I can't do that, it ain't in the book." + +"Well, it's blamed mean--that's all." + +"Well, say, Joe, you can be Friar Tuck or Much the miller's son, and +lam me with a quarter-staff; or I'll be the Sheriff of Nottingham and +you be Robin Hood a little while and kill me." + +This was satisfactory, and so these adventures were carried out. Then +Tom became Robin Hood again, and was allowed by the treacherous nun to +bleed his strength away through his neglected wound. And at last Joe, +representing a whole tribe of weeping outlaws, dragged him sadly forth, +gave his bow into his feeble hands, and Tom said, "Where this arrow +falls, there bury poor Robin Hood under the greenwood tree." Then he +shot the arrow and fell back and would have died, but he lit on a +nettle and sprang up too gaily for a corpse. + +The boys dressed themselves, hid their accoutrements, and went off +grieving that there were no outlaws any more, and wondering what modern +civilization could claim to have done to compensate for their loss. +They said they would rather be outlaws a year in Sherwood Forest than +President of the United States forever. + + + +CHAPTER IX + +AT half-past nine, that night, Tom and Sid were sent to bed, as usual. +They said their prayers, and Sid was soon asleep. Tom lay awake and +waited, in restless impatience. When it seemed to him that it must be +nearly daylight, he heard the clock strike ten! This was despair. He +would have tossed and fidgeted, as his nerves demanded, but he was +afraid he might wake Sid. So he lay still, and stared up into the dark. +Everything was dismally still. By and by, out of the stillness, little, +scarcely perceptible noises began to emphasize themselves. The ticking +of the clock began to bring itself into notice. Old beams began to +crack mysteriously. The stairs creaked faintly. Evidently spirits were +abroad. A measured, muffled snore issued from Aunt Polly's chamber. And +now the tiresome chirping of a cricket that no human ingenuity could +locate, began. Next the ghastly ticking of a deathwatch in the wall at +the bed's head made Tom shudder--it meant that somebody's days were +numbered. Then the howl of a far-off dog rose on the night air, and was +answered by a fainter howl from a remoter distance. Tom was in an +agony. At last he was satisfied that time had ceased and eternity +begun; he began to doze, in spite of himself; the clock chimed eleven, +but he did not hear it. And then there came, mingling with his +half-formed dreams, a most melancholy caterwauling. The raising of a +neighboring window disturbed him. A cry of "Scat! you devil!" and the +crash of an empty bottle against the back of his aunt's woodshed +brought him wide awake, and a single minute later he was dressed and +out of the window and creeping along the roof of the "ell" on all +fours. He "meow'd" with caution once or twice, as he went; then jumped +to the roof of the woodshed and thence to the ground. Huckleberry Finn +was there, with his dead cat. The boys moved off and disappeared in the +gloom. At the end of half an hour they were wading through the tall +grass of the graveyard. + +It was a graveyard of the old-fashioned Western kind. It was on a +hill, about a mile and a half from the village. It had a crazy board +fence around it, which leaned inward in places, and outward the rest of +the time, but stood upright nowhere. Grass and weeds grew rank over the +whole cemetery. All the old graves were sunken in, there was not a +tombstone on the place; round-topped, worm-eaten boards staggered over +the graves, leaning for support and finding none. "Sacred to the memory +of" So-and-So had been painted on them once, but it could no longer +have been read, on the most of them, now, even if there had been light. + +A faint wind moaned through the trees, and Tom feared it might be the +spirits of the dead, complaining at being disturbed. The boys talked +little, and only under their breath, for the time and the place and the +pervading solemnity and silence oppressed their spirits. They found the +sharp new heap they were seeking, and ensconced themselves within the +protection of three great elms that grew in a bunch within a few feet +of the grave. + +Then they waited in silence for what seemed a long time. The hooting +of a distant owl was all the sound that troubled the dead stillness. +Tom's reflections grew oppressive. He must force some talk. So he said +in a whisper: + +"Hucky, do you believe the dead people like it for us to be here?" + +Huckleberry whispered: + +"I wisht I knowed. It's awful solemn like, AIN'T it?" + +"I bet it is." + +There was a considerable pause, while the boys canvassed this matter +inwardly. Then Tom whispered: + +"Say, Hucky--do you reckon Hoss Williams hears us talking?" + +"O' course he does. Least his sperrit does." + +Tom, after a pause: + +"I wish I'd said Mister Williams. But I never meant any harm. +Everybody calls him Hoss." + +"A body can't be too partic'lar how they talk 'bout these-yer dead +people, Tom." + +This was a damper, and conversation died again. + +Presently Tom seized his comrade's arm and said: + +"Sh!" + +"What is it, Tom?" And the two clung together with beating hearts. + +"Sh! There 'tis again! Didn't you hear it?" + +"I--" + +"There! Now you hear it." + +"Lord, Tom, they're coming! They're coming, sure. What'll we do?" + +"I dono. Think they'll see us?" + +"Oh, Tom, they can see in the dark, same as cats. I wisht I hadn't +come." + +"Oh, don't be afeard. I don't believe they'll bother us. We ain't +doing any harm. If we keep perfectly still, maybe they won't notice us +at all." + +"I'll try to, Tom, but, Lord, I'm all of a shiver." + +"Listen!" + +The boys bent their heads together and scarcely breathed. A muffled +sound of voices floated up from the far end of the graveyard. + +"Look! See there!" whispered Tom. "What is it?" + +"It's devil-fire. Oh, Tom, this is awful." + +Some vague figures approached through the gloom, swinging an +old-fashioned tin lantern that freckled the ground with innumerable +little spangles of light. Presently Huckleberry whispered with a +shudder: + +"It's the devils sure enough. Three of 'em! Lordy, Tom, we're goners! +Can you pray?" + +"I'll try, but don't you be afeard. They ain't going to hurt us. 'Now +I lay me down to sleep, I--'" + +"Sh!" + +"What is it, Huck?" + +"They're HUMANS! One of 'em is, anyway. One of 'em's old Muff Potter's +voice." + +"No--'tain't so, is it?" + +"I bet I know it. Don't you stir nor budge. He ain't sharp enough to +notice us. Drunk, the same as usual, likely--blamed old rip!" + +"All right, I'll keep still. Now they're stuck. Can't find it. Here +they come again. Now they're hot. Cold again. Hot again. Red hot! +They're p'inted right, this time. Say, Huck, I know another o' them +voices; it's Injun Joe." + +"That's so--that murderin' half-breed! I'd druther they was devils a +dern sight. What kin they be up to?" + +The whisper died wholly out, now, for the three men had reached the +grave and stood within a few feet of the boys' hiding-place. + +"Here it is," said the third voice; and the owner of it held the +lantern up and revealed the face of young Doctor Robinson. + +Potter and Injun Joe were carrying a handbarrow with a rope and a +couple of shovels on it. They cast down their load and began to open +the grave. The doctor put the lantern at the head of the grave and came +and sat down with his back against one of the elm trees. He was so +close the boys could have touched him. + +"Hurry, men!" he said, in a low voice; "the moon might come out at any +moment." + +They growled a response and went on digging. For some time there was +no noise but the grating sound of the spades discharging their freight +of mould and gravel. It was very monotonous. Finally a spade struck +upon the coffin with a dull woody accent, and within another minute or +two the men had hoisted it out on the ground. They pried off the lid +with their shovels, got out the body and dumped it rudely on the +ground. The moon drifted from behind the clouds and exposed the pallid +face. The barrow was got ready and the corpse placed on it, covered +with a blanket, and bound to its place with the rope. Potter took out a +large spring-knife and cut off the dangling end of the rope and then +said: + +"Now the cussed thing's ready, Sawbones, and you'll just out with +another five, or here she stays." + +"That's the talk!" said Injun Joe. + +"Look here, what does this mean?" said the doctor. "You required your +pay in advance, and I've paid you." + +"Yes, and you done more than that," said Injun Joe, approaching the +doctor, who was now standing. "Five years ago you drove me away from +your father's kitchen one night, when I come to ask for something to +eat, and you said I warn't there for any good; and when I swore I'd get +even with you if it took a hundred years, your father had me jailed for +a vagrant. Did you think I'd forget? The Injun blood ain't in me for +nothing. And now I've GOT you, and you got to SETTLE, you know!" + +He was threatening the doctor, with his fist in his face, by this +time. The doctor struck out suddenly and stretched the ruffian on the +ground. Potter dropped his knife, and exclaimed: + +"Here, now, don't you hit my pard!" and the next moment he had +grappled with the doctor and the two were struggling with might and +main, trampling the grass and tearing the ground with their heels. +Injun Joe sprang to his feet, his eyes flaming with passion, snatched +up Potter's knife, and went creeping, catlike and stooping, round and +round about the combatants, seeking an opportunity. All at once the +doctor flung himself free, seized the heavy headboard of Williams' +grave and felled Potter to the earth with it--and in the same instant +the half-breed saw his chance and drove the knife to the hilt in the +young man's breast. He reeled and fell partly upon Potter, flooding him +with his blood, and in the same moment the clouds blotted out the +dreadful spectacle and the two frightened boys went speeding away in +the dark. + +Presently, when the moon emerged again, Injun Joe was standing over +the two forms, contemplating them. The doctor murmured inarticulately, +gave a long gasp or two and was still. The half-breed muttered: + +"THAT score is settled--damn you." + +Then he robbed the body. After which he put the fatal knife in +Potter's open right hand, and sat down on the dismantled coffin. Three +--four--five minutes passed, and then Potter began to stir and moan. His +hand closed upon the knife; he raised it, glanced at it, and let it +fall, with a shudder. Then he sat up, pushing the body from him, and +gazed at it, and then around him, confusedly. His eyes met Joe's. + +"Lord, how is this, Joe?" he said. + +"It's a dirty business," said Joe, without moving. + +"What did you do it for?" + +"I! I never done it!" + +"Look here! That kind of talk won't wash." + +Potter trembled and grew white. + +"I thought I'd got sober. I'd no business to drink to-night. But it's +in my head yet--worse'n when we started here. I'm all in a muddle; +can't recollect anything of it, hardly. Tell me, Joe--HONEST, now, old +feller--did I do it? Joe, I never meant to--'pon my soul and honor, I +never meant to, Joe. Tell me how it was, Joe. Oh, it's awful--and him +so young and promising." + +"Why, you two was scuffling, and he fetched you one with the headboard +and you fell flat; and then up you come, all reeling and staggering +like, and snatched the knife and jammed it into him, just as he fetched +you another awful clip--and here you've laid, as dead as a wedge til +now." + +"Oh, I didn't know what I was a-doing. I wish I may die this minute if +I did. It was all on account of the whiskey and the excitement, I +reckon. I never used a weepon in my life before, Joe. I've fought, but +never with weepons. They'll all say that. Joe, don't tell! Say you +won't tell, Joe--that's a good feller. I always liked you, Joe, and +stood up for you, too. Don't you remember? You WON'T tell, WILL you, +Joe?" And the poor creature dropped on his knees before the stolid +murderer, and clasped his appealing hands. + +"No, you've always been fair and square with me, Muff Potter, and I +won't go back on you. There, now, that's as fair as a man can say." + +"Oh, Joe, you're an angel. I'll bless you for this the longest day I +live." And Potter began to cry. + +"Come, now, that's enough of that. This ain't any time for blubbering. +You be off yonder way and I'll go this. Move, now, and don't leave any +tracks behind you." + +Potter started on a trot that quickly increased to a run. The +half-breed stood looking after him. He muttered: + +"If he's as much stunned with the lick and fuddled with the rum as he +had the look of being, he won't think of the knife till he's gone so +far he'll be afraid to come back after it to such a place by himself +--chicken-heart!" + +Two or three minutes later the murdered man, the blanketed corpse, the +lidless coffin, and the open grave were under no inspection but the +moon's. The stillness was complete again, too. + + + +CHAPTER X + +THE two boys flew on and on, toward the village, speechless with +horror. They glanced backward over their shoulders from time to time, +apprehensively, as if they feared they might be followed. Every stump +that started up in their path seemed a man and an enemy, and made them +catch their breath; and as they sped by some outlying cottages that lay +near the village, the barking of the aroused watch-dogs seemed to give +wings to their feet. + +"If we can only get to the old tannery before we break down!" +whispered Tom, in short catches between breaths. "I can't stand it much +longer." + +Huckleberry's hard pantings were his only reply, and the boys fixed +their eyes on the goal of their hopes and bent to their work to win it. +They gained steadily on it, and at last, breast to breast, they burst +through the open door and fell grateful and exhausted in the sheltering +shadows beyond. By and by their pulses slowed down, and Tom whispered: + +"Huckleberry, what do you reckon'll come of this?" + +"If Doctor Robinson dies, I reckon hanging'll come of it." + +"Do you though?" + +"Why, I KNOW it, Tom." + +Tom thought a while, then he said: + +"Who'll tell? We?" + +"What are you talking about? S'pose something happened and Injun Joe +DIDN'T hang? Why, he'd kill us some time or other, just as dead sure as +we're a laying here." + +"That's just what I was thinking to myself, Huck." + +"If anybody tells, let Muff Potter do it, if he's fool enough. He's +generally drunk enough." + +Tom said nothing--went on thinking. Presently he whispered: + +"Huck, Muff Potter don't know it. How can he tell?" + +"What's the reason he don't know it?" + +"Because he'd just got that whack when Injun Joe done it. D'you reckon +he could see anything? D'you reckon he knowed anything?" + +"By hokey, that's so, Tom!" + +"And besides, look-a-here--maybe that whack done for HIM!" + +"No, 'taint likely, Tom. He had liquor in him; I could see that; and +besides, he always has. Well, when pap's full, you might take and belt +him over the head with a church and you couldn't phase him. He says so, +his own self. So it's the same with Muff Potter, of course. But if a +man was dead sober, I reckon maybe that whack might fetch him; I dono." + +After another reflective silence, Tom said: + +"Hucky, you sure you can keep mum?" + +"Tom, we GOT to keep mum. You know that. That Injun devil wouldn't +make any more of drownding us than a couple of cats, if we was to +squeak 'bout this and they didn't hang him. Now, look-a-here, Tom, less +take and swear to one another--that's what we got to do--swear to keep +mum." + +"I'm agreed. It's the best thing. Would you just hold hands and swear +that we--" + +"Oh no, that wouldn't do for this. That's good enough for little +rubbishy common things--specially with gals, cuz THEY go back on you +anyway, and blab if they get in a huff--but there orter be writing +'bout a big thing like this. And blood." + +Tom's whole being applauded this idea. It was deep, and dark, and +awful; the hour, the circumstances, the surroundings, were in keeping +with it. He picked up a clean pine shingle that lay in the moonlight, +took a little fragment of "red keel" out of his pocket, got the moon on +his work, and painfully scrawled these lines, emphasizing each slow +down-stroke by clamping his tongue between his teeth, and letting up +the pressure on the up-strokes. [See next page.] + + "Huck Finn and + Tom Sawyer swears + they will keep mum + about This and They + wish They may Drop + down dead in Their + Tracks if They ever + Tell and Rot." + +Huckleberry was filled with admiration of Tom's facility in writing, +and the sublimity of his language. He at once took a pin from his lapel +and was going to prick his flesh, but Tom said: + +"Hold on! Don't do that. A pin's brass. It might have verdigrease on +it." + +"What's verdigrease?" + +"It's p'ison. That's what it is. You just swaller some of it once +--you'll see." + +So Tom unwound the thread from one of his needles, and each boy +pricked the ball of his thumb and squeezed out a drop of blood. In +time, after many squeezes, Tom managed to sign his initials, using the +ball of his little finger for a pen. Then he showed Huckleberry how to +make an H and an F, and the oath was complete. They buried the shingle +close to the wall, with some dismal ceremonies and incantations, and +the fetters that bound their tongues were considered to be locked and +the key thrown away. + +A figure crept stealthily through a break in the other end of the +ruined building, now, but they did not notice it. + +"Tom," whispered Huckleberry, "does this keep us from EVER telling +--ALWAYS?" + +"Of course it does. It don't make any difference WHAT happens, we got +to keep mum. We'd drop down dead--don't YOU know that?" + +"Yes, I reckon that's so." + +They continued to whisper for some little time. Presently a dog set up +a long, lugubrious howl just outside--within ten feet of them. The boys +clasped each other suddenly, in an agony of fright. + +"Which of us does he mean?" gasped Huckleberry. + +"I dono--peep through the crack. Quick!" + +"No, YOU, Tom!" + +"I can't--I can't DO it, Huck!" + +"Please, Tom. There 'tis again!" + +"Oh, lordy, I'm thankful!" whispered Tom. "I know his voice. It's Bull +Harbison." * + +[* If Mr. Harbison owned a slave named Bull, Tom would have spoken of +him as "Harbison's Bull," but a son or a dog of that name was "Bull +Harbison."] + +"Oh, that's good--I tell you, Tom, I was most scared to death; I'd a +bet anything it was a STRAY dog." + +The dog howled again. The boys' hearts sank once more. + +"Oh, my! that ain't no Bull Harbison!" whispered Huckleberry. "DO, Tom!" + +Tom, quaking with fear, yielded, and put his eye to the crack. His +whisper was hardly audible when he said: + +"Oh, Huck, IT S A STRAY DOG!" + +"Quick, Tom, quick! Who does he mean?" + +"Huck, he must mean us both--we're right together." + +"Oh, Tom, I reckon we're goners. I reckon there ain't no mistake 'bout +where I'LL go to. I been so wicked." + +"Dad fetch it! This comes of playing hookey and doing everything a +feller's told NOT to do. I might a been good, like Sid, if I'd a tried +--but no, I wouldn't, of course. But if ever I get off this time, I lay +I'll just WALLER in Sunday-schools!" And Tom began to snuffle a little. + +"YOU bad!" and Huckleberry began to snuffle too. "Consound it, Tom +Sawyer, you're just old pie, 'longside o' what I am. Oh, LORDY, lordy, +lordy, I wisht I only had half your chance." + +Tom choked off and whispered: + +"Look, Hucky, look! He's got his BACK to us!" + +Hucky looked, with joy in his heart. + +"Well, he has, by jingoes! Did he before?" + +"Yes, he did. But I, like a fool, never thought. Oh, this is bully, +you know. NOW who can he mean?" + +The howling stopped. Tom pricked up his ears. + +"Sh! What's that?" he whispered. + +"Sounds like--like hogs grunting. No--it's somebody snoring, Tom." + +"That IS it! Where 'bouts is it, Huck?" + +"I bleeve it's down at 'tother end. Sounds so, anyway. Pap used to +sleep there, sometimes, 'long with the hogs, but laws bless you, he +just lifts things when HE snores. Besides, I reckon he ain't ever +coming back to this town any more." + +The spirit of adventure rose in the boys' souls once more. + +"Hucky, do you das't to go if I lead?" + +"I don't like to, much. Tom, s'pose it's Injun Joe!" + +Tom quailed. But presently the temptation rose up strong again and the +boys agreed to try, with the understanding that they would take to +their heels if the snoring stopped. So they went tiptoeing stealthily +down, the one behind the other. When they had got to within five steps +of the snorer, Tom stepped on a stick, and it broke with a sharp snap. +The man moaned, writhed a little, and his face came into the moonlight. +It was Muff Potter. The boys' hearts had stood still, and their hopes +too, when the man moved, but their fears passed away now. They tiptoed +out, through the broken weather-boarding, and stopped at a little +distance to exchange a parting word. That long, lugubrious howl rose on +the night air again! They turned and saw the strange dog standing +within a few feet of where Potter was lying, and FACING Potter, with +his nose pointing heavenward. + +"Oh, geeminy, it's HIM!" exclaimed both boys, in a breath. + +"Say, Tom--they say a stray dog come howling around Johnny Miller's +house, 'bout midnight, as much as two weeks ago; and a whippoorwill +come in and lit on the banisters and sung, the very same evening; and +there ain't anybody dead there yet." + +"Well, I know that. And suppose there ain't. Didn't Gracie Miller fall +in the kitchen fire and burn herself terrible the very next Saturday?" + +"Yes, but she ain't DEAD. And what's more, she's getting better, too." + +"All right, you wait and see. She's a goner, just as dead sure as Muff +Potter's a goner. That's what the niggers say, and they know all about +these kind of things, Huck." + +Then they separated, cogitating. When Tom crept in at his bedroom +window the night was almost spent. He undressed with excessive caution, +and fell asleep congratulating himself that nobody knew of his +escapade. He was not aware that the gently-snoring Sid was awake, and +had been so for an hour. + +When Tom awoke, Sid was dressed and gone. There was a late look in the +light, a late sense in the atmosphere. He was startled. Why had he not +been called--persecuted till he was up, as usual? The thought filled +him with bodings. Within five minutes he was dressed and down-stairs, +feeling sore and drowsy. The family were still at table, but they had +finished breakfast. There was no voice of rebuke; but there were +averted eyes; there was a silence and an air of solemnity that struck a +chill to the culprit's heart. He sat down and tried to seem gay, but it +was up-hill work; it roused no smile, no response, and he lapsed into +silence and let his heart sink down to the depths. + +After breakfast his aunt took him aside, and Tom almost brightened in +the hope that he was going to be flogged; but it was not so. His aunt +wept over him and asked him how he could go and break her old heart so; +and finally told him to go on, and ruin himself and bring her gray +hairs with sorrow to the grave, for it was no use for her to try any +more. This was worse than a thousand whippings, and Tom's heart was +sorer now than his body. He cried, he pleaded for forgiveness, promised +to reform over and over again, and then received his dismissal, feeling +that he had won but an imperfect forgiveness and established but a +feeble confidence. + +He left the presence too miserable to even feel revengeful toward Sid; +and so the latter's prompt retreat through the back gate was +unnecessary. He moped to school gloomy and sad, and took his flogging, +along with Joe Harper, for playing hookey the day before, with the air +of one whose heart was busy with heavier woes and wholly dead to +trifles. Then he betook himself to his seat, rested his elbows on his +desk and his jaws in his hands, and stared at the wall with the stony +stare of suffering that has reached the limit and can no further go. +His elbow was pressing against some hard substance. After a long time +he slowly and sadly changed his position, and took up this object with +a sigh. It was in a paper. He unrolled it. A long, lingering, colossal +sigh followed, and his heart broke. It was his brass andiron knob! + +This final feather broke the camel's back. + + + +CHAPTER XI + +CLOSE upon the hour of noon the whole village was suddenly electrified +with the ghastly news. No need of the as yet undreamed-of telegraph; +the tale flew from man to man, from group to group, from house to +house, with little less than telegraphic speed. Of course the +schoolmaster gave holiday for that afternoon; the town would have +thought strangely of him if he had not. + +A gory knife had been found close to the murdered man, and it had been +recognized by somebody as belonging to Muff Potter--so the story ran. +And it was said that a belated citizen had come upon Potter washing +himself in the "branch" about one or two o'clock in the morning, and +that Potter had at once sneaked off--suspicious circumstances, +especially the washing which was not a habit with Potter. It was also +said that the town had been ransacked for this "murderer" (the public +are not slow in the matter of sifting evidence and arriving at a +verdict), but that he could not be found. Horsemen had departed down +all the roads in every direction, and the Sheriff "was confident" that +he would be captured before night. + +All the town was drifting toward the graveyard. Tom's heartbreak +vanished and he joined the procession, not because he would not a +thousand times rather go anywhere else, but because an awful, +unaccountable fascination drew him on. Arrived at the dreadful place, +he wormed his small body through the crowd and saw the dismal +spectacle. It seemed to him an age since he was there before. Somebody +pinched his arm. He turned, and his eyes met Huckleberry's. Then both +looked elsewhere at once, and wondered if anybody had noticed anything +in their mutual glance. But everybody was talking, and intent upon the +grisly spectacle before them. + +"Poor fellow!" "Poor young fellow!" "This ought to be a lesson to +grave robbers!" "Muff Potter'll hang for this if they catch him!" This +was the drift of remark; and the minister said, "It was a judgment; His +hand is here." + +Now Tom shivered from head to heel; for his eye fell upon the stolid +face of Injun Joe. At this moment the crowd began to sway and struggle, +and voices shouted, "It's him! it's him! he's coming himself!" + +"Who? Who?" from twenty voices. + +"Muff Potter!" + +"Hallo, he's stopped!--Look out, he's turning! Don't let him get away!" + +People in the branches of the trees over Tom's head said he wasn't +trying to get away--he only looked doubtful and perplexed. + +"Infernal impudence!" said a bystander; "wanted to come and take a +quiet look at his work, I reckon--didn't expect any company." + +The crowd fell apart, now, and the Sheriff came through, +ostentatiously leading Potter by the arm. The poor fellow's face was +haggard, and his eyes showed the fear that was upon him. When he stood +before the murdered man, he shook as with a palsy, and he put his face +in his hands and burst into tears. + +"I didn't do it, friends," he sobbed; "'pon my word and honor I never +done it." + +"Who's accused you?" shouted a voice. + +This shot seemed to carry home. Potter lifted his face and looked +around him with a pathetic hopelessness in his eyes. He saw Injun Joe, +and exclaimed: + +"Oh, Injun Joe, you promised me you'd never--" + +"Is that your knife?" and it was thrust before him by the Sheriff. + +Potter would have fallen if they had not caught him and eased him to +the ground. Then he said: + +"Something told me 't if I didn't come back and get--" He shuddered; +then waved his nerveless hand with a vanquished gesture and said, "Tell +'em, Joe, tell 'em--it ain't any use any more." + +Then Huckleberry and Tom stood dumb and staring, and heard the +stony-hearted liar reel off his serene statement, they expecting every +moment that the clear sky would deliver God's lightnings upon his head, +and wondering to see how long the stroke was delayed. And when he had +finished and still stood alive and whole, their wavering impulse to +break their oath and save the poor betrayed prisoner's life faded and +vanished away, for plainly this miscreant had sold himself to Satan and +it would be fatal to meddle with the property of such a power as that. + +"Why didn't you leave? What did you want to come here for?" somebody +said. + +"I couldn't help it--I couldn't help it," Potter moaned. "I wanted to +run away, but I couldn't seem to come anywhere but here." And he fell +to sobbing again. + +Injun Joe repeated his statement, just as calmly, a few minutes +afterward on the inquest, under oath; and the boys, seeing that the +lightnings were still withheld, were confirmed in their belief that Joe +had sold himself to the devil. He was now become, to them, the most +balefully interesting object they had ever looked upon, and they could +not take their fascinated eyes from his face. + +They inwardly resolved to watch him nights, when opportunity should +offer, in the hope of getting a glimpse of his dread master. + +Injun Joe helped to raise the body of the murdered man and put it in a +wagon for removal; and it was whispered through the shuddering crowd +that the wound bled a little! The boys thought that this happy +circumstance would turn suspicion in the right direction; but they were +disappointed, for more than one villager remarked: + +"It was within three feet of Muff Potter when it done it." + +Tom's fearful secret and gnawing conscience disturbed his sleep for as +much as a week after this; and at breakfast one morning Sid said: + +"Tom, you pitch around and talk in your sleep so much that you keep me +awake half the time." + +Tom blanched and dropped his eyes. + +"It's a bad sign," said Aunt Polly, gravely. "What you got on your +mind, Tom?" + +"Nothing. Nothing 't I know of." But the boy's hand shook so that he +spilled his coffee. + +"And you do talk such stuff," Sid said. "Last night you said, 'It's +blood, it's blood, that's what it is!' You said that over and over. And +you said, 'Don't torment me so--I'll tell!' Tell WHAT? What is it +you'll tell?" + +Everything was swimming before Tom. There is no telling what might +have happened, now, but luckily the concern passed out of Aunt Polly's +face and she came to Tom's relief without knowing it. She said: + +"Sho! It's that dreadful murder. I dream about it most every night +myself. Sometimes I dream it's me that done it." + +Mary said she had been affected much the same way. Sid seemed +satisfied. Tom got out of the presence as quick as he plausibly could, +and after that he complained of toothache for a week, and tied up his +jaws every night. He never knew that Sid lay nightly watching, and +frequently slipped the bandage free and then leaned on his elbow +listening a good while at a time, and afterward slipped the bandage +back to its place again. Tom's distress of mind wore off gradually and +the toothache grew irksome and was discarded. If Sid really managed to +make anything out of Tom's disjointed mutterings, he kept it to himself. + +It seemed to Tom that his schoolmates never would get done holding +inquests on dead cats, and thus keeping his trouble present to his +mind. Sid noticed that Tom never was coroner at one of these inquiries, +though it had been his habit to take the lead in all new enterprises; +he noticed, too, that Tom never acted as a witness--and that was +strange; and Sid did not overlook the fact that Tom even showed a +marked aversion to these inquests, and always avoided them when he +could. Sid marvelled, but said nothing. However, even inquests went out +of vogue at last, and ceased to torture Tom's conscience. + +Every day or two, during this time of sorrow, Tom watched his +opportunity and went to the little grated jail-window and smuggled such +small comforts through to the "murderer" as he could get hold of. The +jail was a trifling little brick den that stood in a marsh at the edge +of the village, and no guards were afforded for it; indeed, it was +seldom occupied. These offerings greatly helped to ease Tom's +conscience. + +The villagers had a strong desire to tar-and-feather Injun Joe and +ride him on a rail, for body-snatching, but so formidable was his +character that nobody could be found who was willing to take the lead +in the matter, so it was dropped. He had been careful to begin both of +his inquest-statements with the fight, without confessing the +grave-robbery that preceded it; therefore it was deemed wisest not +to try the case in the courts at present. + + + +CHAPTER XII + +ONE of the reasons why Tom's mind had drifted away from its secret +troubles was, that it had found a new and weighty matter to interest +itself about. Becky Thatcher had stopped coming to school. Tom had +struggled with his pride a few days, and tried to "whistle her down the +wind," but failed. He began to find himself hanging around her father's +house, nights, and feeling very miserable. She was ill. What if she +should die! There was distraction in the thought. He no longer took an +interest in war, nor even in piracy. The charm of life was gone; there +was nothing but dreariness left. He put his hoop away, and his bat; +there was no joy in them any more. His aunt was concerned. She began to +try all manner of remedies on him. She was one of those people who are +infatuated with patent medicines and all new-fangled methods of +producing health or mending it. She was an inveterate experimenter in +these things. When something fresh in this line came out she was in a +fever, right away, to try it; not on herself, for she was never ailing, +but on anybody else that came handy. She was a subscriber for all the +"Health" periodicals and phrenological frauds; and the solemn ignorance +they were inflated with was breath to her nostrils. All the "rot" they +contained about ventilation, and how to go to bed, and how to get up, +and what to eat, and what to drink, and how much exercise to take, and +what frame of mind to keep one's self in, and what sort of clothing to +wear, was all gospel to her, and she never observed that her +health-journals of the current month customarily upset everything they +had recommended the month before. She was as simple-hearted and honest +as the day was long, and so she was an easy victim. She gathered +together her quack periodicals and her quack medicines, and thus armed +with death, went about on her pale horse, metaphorically speaking, with +"hell following after." But she never suspected that she was not an +angel of healing and the balm of Gilead in disguise, to the suffering +neighbors. + +The water treatment was new, now, and Tom's low condition was a +windfall to her. She had him out at daylight every morning, stood him +up in the woodshed and drowned him with a deluge of cold water; then +she scrubbed him down with a towel like a file, and so brought him to; +then she rolled him up in a wet sheet and put him away under blankets +till she sweated his soul clean and "the yellow stains of it came +through his pores"--as Tom said. + +Yet notwithstanding all this, the boy grew more and more melancholy +and pale and dejected. She added hot baths, sitz baths, shower baths, +and plunges. The boy remained as dismal as a hearse. She began to +assist the water with a slim oatmeal diet and blister-plasters. She +calculated his capacity as she would a jug's, and filled him up every +day with quack cure-alls. + +Tom had become indifferent to persecution by this time. This phase +filled the old lady's heart with consternation. This indifference must +be broken up at any cost. Now she heard of Pain-killer for the first +time. She ordered a lot at once. She tasted it and was filled with +gratitude. It was simply fire in a liquid form. She dropped the water +treatment and everything else, and pinned her faith to Pain-killer. She +gave Tom a teaspoonful and watched with the deepest anxiety for the +result. Her troubles were instantly at rest, her soul at peace again; +for the "indifference" was broken up. The boy could not have shown a +wilder, heartier interest, if she had built a fire under him. + +Tom felt that it was time to wake up; this sort of life might be +romantic enough, in his blighted condition, but it was getting to have +too little sentiment and too much distracting variety about it. So he +thought over various plans for relief, and finally hit pon that of +professing to be fond of Pain-killer. He asked for it so often that he +became a nuisance, and his aunt ended by telling him to help himself +and quit bothering her. If it had been Sid, she would have had no +misgivings to alloy her delight; but since it was Tom, she watched the +bottle clandestinely. She found that the medicine did really diminish, +but it did not occur to her that the boy was mending the health of a +crack in the sitting-room floor with it. + +One day Tom was in the act of dosing the crack when his aunt's yellow +cat came along, purring, eying the teaspoon avariciously, and begging +for a taste. Tom said: + +"Don't ask for it unless you want it, Peter." + +But Peter signified that he did want it. + +"You better make sure." + +Peter was sure. + +"Now you've asked for it, and I'll give it to you, because there ain't +anything mean about me; but if you find you don't like it, you mustn't +blame anybody but your own self." + +Peter was agreeable. So Tom pried his mouth open and poured down the +Pain-killer. Peter sprang a couple of yards in the air, and then +delivered a war-whoop and set off round and round the room, banging +against furniture, upsetting flower-pots, and making general havoc. +Next he rose on his hind feet and pranced around, in a frenzy of +enjoyment, with his head over his shoulder and his voice proclaiming +his unappeasable happiness. Then he went tearing around the house again +spreading chaos and destruction in his path. Aunt Polly entered in time +to see him throw a few double summersets, deliver a final mighty +hurrah, and sail through the open window, carrying the rest of the +flower-pots with him. The old lady stood petrified with astonishment, +peering over her glasses; Tom lay on the floor expiring with laughter. + +"Tom, what on earth ails that cat?" + +"I don't know, aunt," gasped the boy. + +"Why, I never see anything like it. What did make him act so?" + +"Deed I don't know, Aunt Polly; cats always act so when they're having +a good time." + +"They do, do they?" There was something in the tone that made Tom +apprehensive. + +"Yes'm. That is, I believe they do." + +"You DO?" + +"Yes'm." + +The old lady was bending down, Tom watching, with interest emphasized +by anxiety. Too late he divined her "drift." The handle of the telltale +teaspoon was visible under the bed-valance. Aunt Polly took it, held it +up. Tom winced, and dropped his eyes. Aunt Polly raised him by the +usual handle--his ear--and cracked his head soundly with her thimble. + +"Now, sir, what did you want to treat that poor dumb beast so, for?" + +"I done it out of pity for him--because he hadn't any aunt." + +"Hadn't any aunt!--you numskull. What has that got to do with it?" + +"Heaps. Because if he'd had one she'd a burnt him out herself! She'd a +roasted his bowels out of him 'thout any more feeling than if he was a +human!" + +Aunt Polly felt a sudden pang of remorse. This was putting the thing +in a new light; what was cruelty to a cat MIGHT be cruelty to a boy, +too. She began to soften; she felt sorry. Her eyes watered a little, +and she put her hand on Tom's head and said gently: + +"I was meaning for the best, Tom. And, Tom, it DID do you good." + +Tom looked up in her face with just a perceptible twinkle peeping +through his gravity. + +"I know you was meaning for the best, aunty, and so was I with Peter. +It done HIM good, too. I never see him get around so since--" + +"Oh, go 'long with you, Tom, before you aggravate me again. And you +try and see if you can't be a good boy, for once, and you needn't take +any more medicine." + +Tom reached school ahead of time. It was noticed that this strange +thing had been occurring every day latterly. And now, as usual of late, +he hung about the gate of the schoolyard instead of playing with his +comrades. He was sick, he said, and he looked it. He tried to seem to +be looking everywhere but whither he really was looking--down the road. +Presently Jeff Thatcher hove in sight, and Tom's face lighted; he gazed +a moment, and then turned sorrowfully away. When Jeff arrived, Tom +accosted him; and "led up" warily to opportunities for remark about +Becky, but the giddy lad never could see the bait. Tom watched and +watched, hoping whenever a frisking frock came in sight, and hating the +owner of it as soon as he saw she was not the right one. At last frocks +ceased to appear, and he dropped hopelessly into the dumps; he entered +the empty schoolhouse and sat down to suffer. Then one more frock +passed in at the gate, and Tom's heart gave a great bound. The next +instant he was out, and "going on" like an Indian; yelling, laughing, +chasing boys, jumping over the fence at risk of life and limb, throwing +handsprings, standing on his head--doing all the heroic things he could +conceive of, and keeping a furtive eye out, all the while, to see if +Becky Thatcher was noticing. But she seemed to be unconscious of it +all; she never looked. Could it be possible that she was not aware that +he was there? He carried his exploits to her immediate vicinity; came +war-whooping around, snatched a boy's cap, hurled it to the roof of the +schoolhouse, broke through a group of boys, tumbling them in every +direction, and fell sprawling, himself, under Becky's nose, almost +upsetting her--and she turned, with her nose in the air, and he heard +her say: "Mf! some people think they're mighty smart--always showing +off!" + +Tom's cheeks burned. He gathered himself up and sneaked off, crushed +and crestfallen. + + + +CHAPTER XIII + +TOM'S mind was made up now. He was gloomy and desperate. He was a +forsaken, friendless boy, he said; nobody loved him; when they found +out what they had driven him to, perhaps they would be sorry; he had +tried to do right and get along, but they would not let him; since +nothing would do them but to be rid of him, let it be so; and let them +blame HIM for the consequences--why shouldn't they? What right had the +friendless to complain? Yes, they had forced him to it at last: he +would lead a life of crime. There was no choice. + +By this time he was far down Meadow Lane, and the bell for school to +"take up" tinkled faintly upon his ear. He sobbed, now, to think he +should never, never hear that old familiar sound any more--it was very +hard, but it was forced on him; since he was driven out into the cold +world, he must submit--but he forgave them. Then the sobs came thick +and fast. + +Just at this point he met his soul's sworn comrade, Joe Harper +--hard-eyed, and with evidently a great and dismal purpose in his heart. +Plainly here were "two souls with but a single thought." Tom, wiping +his eyes with his sleeve, began to blubber out something about a +resolution to escape from hard usage and lack of sympathy at home by +roaming abroad into the great world never to return; and ended by +hoping that Joe would not forget him. + +But it transpired that this was a request which Joe had just been +going to make of Tom, and had come to hunt him up for that purpose. His +mother had whipped him for drinking some cream which he had never +tasted and knew nothing about; it was plain that she was tired of him +and wished him to go; if she felt that way, there was nothing for him +to do but succumb; he hoped she would be happy, and never regret having +driven her poor boy out into the unfeeling world to suffer and die. + +As the two boys walked sorrowing along, they made a new compact to +stand by each other and be brothers and never separate till death +relieved them of their troubles. Then they began to lay their plans. +Joe was for being a hermit, and living on crusts in a remote cave, and +dying, some time, of cold and want and grief; but after listening to +Tom, he conceded that there were some conspicuous advantages about a +life of crime, and so he consented to be a pirate. + +Three miles below St. Petersburg, at a point where the Mississippi +River was a trifle over a mile wide, there was a long, narrow, wooded +island, with a shallow bar at the head of it, and this offered well as +a rendezvous. It was not inhabited; it lay far over toward the further +shore, abreast a dense and almost wholly unpeopled forest. So Jackson's +Island was chosen. Who were to be the subjects of their piracies was a +matter that did not occur to them. Then they hunted up Huckleberry +Finn, and he joined them promptly, for all careers were one to him; he +was indifferent. They presently separated to meet at a lonely spot on +the river-bank two miles above the village at the favorite hour--which +was midnight. There was a small log raft there which they meant to +capture. Each would bring hooks and lines, and such provision as he +could steal in the most dark and mysterious way--as became outlaws. And +before the afternoon was done, they had all managed to enjoy the sweet +glory of spreading the fact that pretty soon the town would "hear +something." All who got this vague hint were cautioned to "be mum and +wait." + +About midnight Tom arrived with a boiled ham and a few trifles, +and stopped in a dense undergrowth on a small bluff overlooking the +meeting-place. It was starlight, and very still. The mighty river lay +like an ocean at rest. Tom listened a moment, but no sound disturbed the +quiet. Then he gave a low, distinct whistle. It was answered from under +the bluff. Tom whistled twice more; these signals were answered in the +same way. Then a guarded voice said: + +"Who goes there?" + +"Tom Sawyer, the Black Avenger of the Spanish Main. Name your names." + +"Huck Finn the Red-Handed, and Joe Harper the Terror of the Seas." Tom +had furnished these titles, from his favorite literature. + +"'Tis well. Give the countersign." + +Two hoarse whispers delivered the same awful word simultaneously to +the brooding night: + +"BLOOD!" + +Then Tom tumbled his ham over the bluff and let himself down after it, +tearing both skin and clothes to some extent in the effort. There was +an easy, comfortable path along the shore under the bluff, but it +lacked the advantages of difficulty and danger so valued by a pirate. + +The Terror of the Seas had brought a side of bacon, and had about worn +himself out with getting it there. Finn the Red-Handed had stolen a +skillet and a quantity of half-cured leaf tobacco, and had also brought +a few corn-cobs to make pipes with. But none of the pirates smoked or +"chewed" but himself. The Black Avenger of the Spanish Main said it +would never do to start without some fire. That was a wise thought; +matches were hardly known there in that day. They saw a fire +smouldering upon a great raft a hundred yards above, and they went +stealthily thither and helped themselves to a chunk. They made an +imposing adventure of it, saying, "Hist!" every now and then, and +suddenly halting with finger on lip; moving with hands on imaginary +dagger-hilts; and giving orders in dismal whispers that if "the foe" +stirred, to "let him have it to the hilt," because "dead men tell no +tales." They knew well enough that the raftsmen were all down at the +village laying in stores or having a spree, but still that was no +excuse for their conducting this thing in an unpiratical way. + +They shoved off, presently, Tom in command, Huck at the after oar and +Joe at the forward. Tom stood amidships, gloomy-browed, and with folded +arms, and gave his orders in a low, stern whisper: + +"Luff, and bring her to the wind!" + +"Aye-aye, sir!" + +"Steady, steady-y-y-y!" + +"Steady it is, sir!" + +"Let her go off a point!" + +"Point it is, sir!" + +As the boys steadily and monotonously drove the raft toward mid-stream +it was no doubt understood that these orders were given only for +"style," and were not intended to mean anything in particular. + +"What sail's she carrying?" + +"Courses, tops'ls, and flying-jib, sir." + +"Send the r'yals up! Lay out aloft, there, half a dozen of ye +--foretopmaststuns'l! Lively, now!" + +"Aye-aye, sir!" + +"Shake out that maintogalans'l! Sheets and braces! NOW my hearties!" + +"Aye-aye, sir!" + +"Hellum-a-lee--hard a port! Stand by to meet her when she comes! Port, +port! NOW, men! With a will! Stead-y-y-y!" + +"Steady it is, sir!" + +The raft drew beyond the middle of the river; the boys pointed her +head right, and then lay on their oars. The river was not high, so +there was not more than a two or three mile current. Hardly a word was +said during the next three-quarters of an hour. Now the raft was +passing before the distant town. Two or three glimmering lights showed +where it lay, peacefully sleeping, beyond the vague vast sweep of +star-gemmed water, unconscious of the tremendous event that was happening. +The Black Avenger stood still with folded arms, "looking his last" upon +the scene of his former joys and his later sufferings, and wishing +"she" could see him now, abroad on the wild sea, facing peril and death +with dauntless heart, going to his doom with a grim smile on his lips. +It was but a small strain on his imagination to remove Jackson's Island +beyond eyeshot of the village, and so he "looked his last" with a +broken and satisfied heart. The other pirates were looking their last, +too; and they all looked so long that they came near letting the +current drift them out of the range of the island. But they discovered +the danger in time, and made shift to avert it. About two o'clock in +the morning the raft grounded on the bar two hundred yards above the +head of the island, and they waded back and forth until they had landed +their freight. Part of the little raft's belongings consisted of an old +sail, and this they spread over a nook in the bushes for a tent to +shelter their provisions; but they themselves would sleep in the open +air in good weather, as became outlaws. + +They built a fire against the side of a great log twenty or thirty +steps within the sombre depths of the forest, and then cooked some +bacon in the frying-pan for supper, and used up half of the corn "pone" +stock they had brought. It seemed glorious sport to be feasting in that +wild, free way in the virgin forest of an unexplored and uninhabited +island, far from the haunts of men, and they said they never would +return to civilization. The climbing fire lit up their faces and threw +its ruddy glare upon the pillared tree-trunks of their forest temple, +and upon the varnished foliage and festooning vines. + +When the last crisp slice of bacon was gone, and the last allowance of +corn pone devoured, the boys stretched themselves out on the grass, +filled with contentment. They could have found a cooler place, but they +would not deny themselves such a romantic feature as the roasting +camp-fire. + +"AIN'T it gay?" said Joe. + +"It's NUTS!" said Tom. "What would the boys say if they could see us?" + +"Say? Well, they'd just die to be here--hey, Hucky!" + +"I reckon so," said Huckleberry; "anyways, I'm suited. I don't want +nothing better'n this. I don't ever get enough to eat, gen'ally--and +here they can't come and pick at a feller and bullyrag him so." + +"It's just the life for me," said Tom. "You don't have to get up, +mornings, and you don't have to go to school, and wash, and all that +blame foolishness. You see a pirate don't have to do ANYTHING, Joe, +when he's ashore, but a hermit HE has to be praying considerable, and +then he don't have any fun, anyway, all by himself that way." + +"Oh yes, that's so," said Joe, "but I hadn't thought much about it, +you know. I'd a good deal rather be a pirate, now that I've tried it." + +"You see," said Tom, "people don't go much on hermits, nowadays, like +they used to in old times, but a pirate's always respected. And a +hermit's got to sleep on the hardest place he can find, and put +sackcloth and ashes on his head, and stand out in the rain, and--" + +"What does he put sackcloth and ashes on his head for?" inquired Huck. + +"I dono. But they've GOT to do it. Hermits always do. You'd have to do +that if you was a hermit." + +"Dern'd if I would," said Huck. + +"Well, what would you do?" + +"I dono. But I wouldn't do that." + +"Why, Huck, you'd HAVE to. How'd you get around it?" + +"Why, I just wouldn't stand it. I'd run away." + +"Run away! Well, you WOULD be a nice old slouch of a hermit. You'd be +a disgrace." + +The Red-Handed made no response, being better employed. He had +finished gouging out a cob, and now he fitted a weed stem to it, loaded +it with tobacco, and was pressing a coal to the charge and blowing a +cloud of fragrant smoke--he was in the full bloom of luxurious +contentment. The other pirates envied him this majestic vice, and +secretly resolved to acquire it shortly. Presently Huck said: + +"What does pirates have to do?" + +Tom said: + +"Oh, they have just a bully time--take ships and burn them, and get +the money and bury it in awful places in their island where there's +ghosts and things to watch it, and kill everybody in the ships--make +'em walk a plank." + +"And they carry the women to the island," said Joe; "they don't kill +the women." + +"No," assented Tom, "they don't kill the women--they're too noble. And +the women's always beautiful, too. + +"And don't they wear the bulliest clothes! Oh no! All gold and silver +and di'monds," said Joe, with enthusiasm. + +"Who?" said Huck. + +"Why, the pirates." + +Huck scanned his own clothing forlornly. + +"I reckon I ain't dressed fitten for a pirate," said he, with a +regretful pathos in his voice; "but I ain't got none but these." + +But the other boys told him the fine clothes would come fast enough, +after they should have begun their adventures. They made him understand +that his poor rags would do to begin with, though it was customary for +wealthy pirates to start with a proper wardrobe. + +Gradually their talk died out and drowsiness began to steal upon the +eyelids of the little waifs. The pipe dropped from the fingers of the +Red-Handed, and he slept the sleep of the conscience-free and the +weary. The Terror of the Seas and the Black Avenger of the Spanish Main +had more difficulty in getting to sleep. They said their prayers +inwardly, and lying down, since there was nobody there with authority +to make them kneel and recite aloud; in truth, they had a mind not to +say them at all, but they were afraid to proceed to such lengths as +that, lest they might call down a sudden and special thunderbolt from +heaven. Then at once they reached and hovered upon the imminent verge +of sleep--but an intruder came, now, that would not "down." It was +conscience. They began to feel a vague fear that they had been doing +wrong to run away; and next they thought of the stolen meat, and then +the real torture came. They tried to argue it away by reminding +conscience that they had purloined sweetmeats and apples scores of +times; but conscience was not to be appeased by such thin +plausibilities; it seemed to them, in the end, that there was no +getting around the stubborn fact that taking sweetmeats was only +"hooking," while taking bacon and hams and such valuables was plain +simple stealing--and there was a command against that in the Bible. So +they inwardly resolved that so long as they remained in the business, +their piracies should not again be sullied with the crime of stealing. +Then conscience granted a truce, and these curiously inconsistent +pirates fell peacefully to sleep. + + + +CHAPTER XIV + +WHEN Tom awoke in the morning, he wondered where he was. He sat up and +rubbed his eyes and looked around. Then he comprehended. It was the +cool gray dawn, and there was a delicious sense of repose and peace in +the deep pervading calm and silence of the woods. Not a leaf stirred; +not a sound obtruded upon great Nature's meditation. Beaded dewdrops +stood upon the leaves and grasses. A white layer of ashes covered the +fire, and a thin blue breath of smoke rose straight into the air. Joe +and Huck still slept. + +Now, far away in the woods a bird called; another answered; presently +the hammering of a woodpecker was heard. Gradually the cool dim gray of +the morning whitened, and as gradually sounds multiplied and life +manifested itself. The marvel of Nature shaking off sleep and going to +work unfolded itself to the musing boy. A little green worm came +crawling over a dewy leaf, lifting two-thirds of his body into the air +from time to time and "sniffing around," then proceeding again--for he +was measuring, Tom said; and when the worm approached him, of its own +accord, he sat as still as a stone, with his hopes rising and falling, +by turns, as the creature still came toward him or seemed inclined to +go elsewhere; and when at last it considered a painful moment with its +curved body in the air and then came decisively down upon Tom's leg and +began a journey over him, his whole heart was glad--for that meant that +he was going to have a new suit of clothes--without the shadow of a +doubt a gaudy piratical uniform. Now a procession of ants appeared, +from nowhere in particular, and went about their labors; one struggled +manfully by with a dead spider five times as big as itself in its arms, +and lugged it straight up a tree-trunk. A brown spotted lady-bug +climbed the dizzy height of a grass blade, and Tom bent down close to +it and said, "Lady-bug, lady-bug, fly away home, your house is on fire, +your children's alone," and she took wing and went off to see about it +--which did not surprise the boy, for he knew of old that this insect was +credulous about conflagrations, and he had practised upon its +simplicity more than once. A tumblebug came next, heaving sturdily at +its ball, and Tom touched the creature, to see it shut its legs against +its body and pretend to be dead. The birds were fairly rioting by this +time. A catbird, the Northern mocker, lit in a tree over Tom's head, +and trilled out her imitations of her neighbors in a rapture of +enjoyment; then a shrill jay swept down, a flash of blue flame, and +stopped on a twig almost within the boy's reach, cocked his head to one +side and eyed the strangers with a consuming curiosity; a gray squirrel +and a big fellow of the "fox" kind came skurrying along, sitting up at +intervals to inspect and chatter at the boys, for the wild things had +probably never seen a human being before and scarcely knew whether to +be afraid or not. All Nature was wide awake and stirring, now; long +lances of sunlight pierced down through the dense foliage far and near, +and a few butterflies came fluttering upon the scene. + +Tom stirred up the other pirates and they all clattered away with a +shout, and in a minute or two were stripped and chasing after and +tumbling over each other in the shallow limpid water of the white +sandbar. They felt no longing for the little village sleeping in the +distance beyond the majestic waste of water. A vagrant current or a +slight rise in the river had carried off their raft, but this only +gratified them, since its going was something like burning the bridge +between them and civilization. + +They came back to camp wonderfully refreshed, glad-hearted, and +ravenous; and they soon had the camp-fire blazing up again. Huck found +a spring of clear cold water close by, and the boys made cups of broad +oak or hickory leaves, and felt that water, sweetened with such a +wildwood charm as that, would be a good enough substitute for coffee. +While Joe was slicing bacon for breakfast, Tom and Huck asked him to +hold on a minute; they stepped to a promising nook in the river-bank +and threw in their lines; almost immediately they had reward. Joe had +not had time to get impatient before they were back again with some +handsome bass, a couple of sun-perch and a small catfish--provisions +enough for quite a family. They fried the fish with the bacon, and were +astonished; for no fish had ever seemed so delicious before. They did +not know that the quicker a fresh-water fish is on the fire after he is +caught the better he is; and they reflected little upon what a sauce +open-air sleeping, open-air exercise, bathing, and a large ingredient +of hunger make, too. + +They lay around in the shade, after breakfast, while Huck had a smoke, +and then went off through the woods on an exploring expedition. They +tramped gayly along, over decaying logs, through tangled underbrush, +among solemn monarchs of the forest, hung from their crowns to the +ground with a drooping regalia of grape-vines. Now and then they came +upon snug nooks carpeted with grass and jeweled with flowers. + +They found plenty of things to be delighted with, but nothing to be +astonished at. They discovered that the island was about three miles +long and a quarter of a mile wide, and that the shore it lay closest to +was only separated from it by a narrow channel hardly two hundred yards +wide. They took a swim about every hour, so it was close upon the +middle of the afternoon when they got back to camp. They were too +hungry to stop to fish, but they fared sumptuously upon cold ham, and +then threw themselves down in the shade to talk. But the talk soon +began to drag, and then died. The stillness, the solemnity that brooded +in the woods, and the sense of loneliness, began to tell upon the +spirits of the boys. They fell to thinking. A sort of undefined longing +crept upon them. This took dim shape, presently--it was budding +homesickness. Even Finn the Red-Handed was dreaming of his doorsteps +and empty hogsheads. But they were all ashamed of their weakness, and +none was brave enough to speak his thought. + +For some time, now, the boys had been dully conscious of a peculiar +sound in the distance, just as one sometimes is of the ticking of a +clock which he takes no distinct note of. But now this mysterious sound +became more pronounced, and forced a recognition. The boys started, +glanced at each other, and then each assumed a listening attitude. +There was a long silence, profound and unbroken; then a deep, sullen +boom came floating down out of the distance. + +"What is it!" exclaimed Joe, under his breath. + +"I wonder," said Tom in a whisper. + +"'Tain't thunder," said Huckleberry, in an awed tone, "becuz thunder--" + +"Hark!" said Tom. "Listen--don't talk." + +They waited a time that seemed an age, and then the same muffled boom +troubled the solemn hush. + +"Let's go and see." + +They sprang to their feet and hurried to the shore toward the town. +They parted the bushes on the bank and peered out over the water. The +little steam ferryboat was about a mile below the village, drifting +with the current. Her broad deck seemed crowded with people. There were +a great many skiffs rowing about or floating with the stream in the +neighborhood of the ferryboat, but the boys could not determine what +the men in them were doing. Presently a great jet of white smoke burst +from the ferryboat's side, and as it expanded and rose in a lazy cloud, +that same dull throb of sound was borne to the listeners again. + +"I know now!" exclaimed Tom; "somebody's drownded!" + +"That's it!" said Huck; "they done that last summer, when Bill Turner +got drownded; they shoot a cannon over the water, and that makes him +come up to the top. Yes, and they take loaves of bread and put +quicksilver in 'em and set 'em afloat, and wherever there's anybody +that's drownded, they'll float right there and stop." + +"Yes, I've heard about that," said Joe. "I wonder what makes the bread +do that." + +"Oh, it ain't the bread, so much," said Tom; "I reckon it's mostly +what they SAY over it before they start it out." + +"But they don't say anything over it," said Huck. "I've seen 'em and +they don't." + +"Well, that's funny," said Tom. "But maybe they say it to themselves. +Of COURSE they do. Anybody might know that." + +The other boys agreed that there was reason in what Tom said, because +an ignorant lump of bread, uninstructed by an incantation, could not be +expected to act very intelligently when set upon an errand of such +gravity. + +"By jings, I wish I was over there, now," said Joe. + +"I do too" said Huck "I'd give heaps to know who it is." + +The boys still listened and watched. Presently a revealing thought +flashed through Tom's mind, and he exclaimed: + +"Boys, I know who's drownded--it's us!" + +They felt like heroes in an instant. Here was a gorgeous triumph; they +were missed; they were mourned; hearts were breaking on their account; +tears were being shed; accusing memories of unkindness to these poor +lost lads were rising up, and unavailing regrets and remorse were being +indulged; and best of all, the departed were the talk of the whole +town, and the envy of all the boys, as far as this dazzling notoriety +was concerned. This was fine. It was worth while to be a pirate, after +all. + +As twilight drew on, the ferryboat went back to her accustomed +business and the skiffs disappeared. The pirates returned to camp. They +were jubilant with vanity over their new grandeur and the illustrious +trouble they were making. They caught fish, cooked supper and ate it, +and then fell to guessing at what the village was thinking and saying +about them; and the pictures they drew of the public distress on their +account were gratifying to look upon--from their point of view. But +when the shadows of night closed them in, they gradually ceased to +talk, and sat gazing into the fire, with their minds evidently +wandering elsewhere. The excitement was gone, now, and Tom and Joe +could not keep back thoughts of certain persons at home who were not +enjoying this fine frolic as much as they were. Misgivings came; they +grew troubled and unhappy; a sigh or two escaped, unawares. By and by +Joe timidly ventured upon a roundabout "feeler" as to how the others +might look upon a return to civilization--not right now, but-- + +Tom withered him with derision! Huck, being uncommitted as yet, joined +in with Tom, and the waverer quickly "explained," and was glad to get +out of the scrape with as little taint of chicken-hearted homesickness +clinging to his garments as he could. Mutiny was effectually laid to +rest for the moment. + +As the night deepened, Huck began to nod, and presently to snore. Joe +followed next. Tom lay upon his elbow motionless, for some time, +watching the two intently. At last he got up cautiously, on his knees, +and went searching among the grass and the flickering reflections flung +by the camp-fire. He picked up and inspected several large +semi-cylinders of the thin white bark of a sycamore, and finally chose +two which seemed to suit him. Then he knelt by the fire and painfully +wrote something upon each of these with his "red keel"; one he rolled up +and put in his jacket pocket, and the other he put in Joe's hat and +removed it to a little distance from the owner. And he also put into the +hat certain schoolboy treasures of almost inestimable value--among them +a lump of chalk, an India-rubber ball, three fishhooks, and one of that +kind of marbles known as a "sure 'nough crystal." Then he tiptoed his +way cautiously among the trees till he felt that he was out of hearing, +and straightway broke into a keen run in the direction of the sandbar. + + + +CHAPTER XV + +A FEW minutes later Tom was in the shoal water of the bar, wading +toward the Illinois shore. Before the depth reached his middle he was +half-way over; the current would permit no more wading, now, so he +struck out confidently to swim the remaining hundred yards. He swam +quartering upstream, but still was swept downward rather faster than he +had expected. However, he reached the shore finally, and drifted along +till he found a low place and drew himself out. He put his hand on his +jacket pocket, found his piece of bark safe, and then struck through +the woods, following the shore, with streaming garments. Shortly before +ten o'clock he came out into an open place opposite the village, and +saw the ferryboat lying in the shadow of the trees and the high bank. +Everything was quiet under the blinking stars. He crept down the bank, +watching with all his eyes, slipped into the water, swam three or four +strokes and climbed into the skiff that did "yawl" duty at the boat's +stern. He laid himself down under the thwarts and waited, panting. + +Presently the cracked bell tapped and a voice gave the order to "cast +off." A minute or two later the skiff's head was standing high up, +against the boat's swell, and the voyage was begun. Tom felt happy in +his success, for he knew it was the boat's last trip for the night. At +the end of a long twelve or fifteen minutes the wheels stopped, and Tom +slipped overboard and swam ashore in the dusk, landing fifty yards +downstream, out of danger of possible stragglers. + +He flew along unfrequented alleys, and shortly found himself at his +aunt's back fence. He climbed over, approached the "ell," and looked in +at the sitting-room window, for a light was burning there. There sat +Aunt Polly, Sid, Mary, and Joe Harper's mother, grouped together, +talking. They were by the bed, and the bed was between them and the +door. Tom went to the door and began to softly lift the latch; then he +pressed gently and the door yielded a crack; he continued pushing +cautiously, and quaking every time it creaked, till he judged he might +squeeze through on his knees; so he put his head through and began, +warily. + +"What makes the candle blow so?" said Aunt Polly. Tom hurried up. +"Why, that door's open, I believe. Why, of course it is. No end of +strange things now. Go 'long and shut it, Sid." + +Tom disappeared under the bed just in time. He lay and "breathed" +himself for a time, and then crept to where he could almost touch his +aunt's foot. + +"But as I was saying," said Aunt Polly, "he warn't BAD, so to say +--only mischEEvous. Only just giddy, and harum-scarum, you know. He +warn't any more responsible than a colt. HE never meant any harm, and +he was the best-hearted boy that ever was"--and she began to cry. + +"It was just so with my Joe--always full of his devilment, and up to +every kind of mischief, but he was just as unselfish and kind as he +could be--and laws bless me, to think I went and whipped him for taking +that cream, never once recollecting that I throwed it out myself +because it was sour, and I never to see him again in this world, never, +never, never, poor abused boy!" And Mrs. Harper sobbed as if her heart +would break. + +"I hope Tom's better off where he is," said Sid, "but if he'd been +better in some ways--" + +"SID!" Tom felt the glare of the old lady's eye, though he could not +see it. "Not a word against my Tom, now that he's gone! God'll take +care of HIM--never you trouble YOURself, sir! Oh, Mrs. Harper, I don't +know how to give him up! I don't know how to give him up! He was such a +comfort to me, although he tormented my old heart out of me, 'most." + +"The Lord giveth and the Lord hath taken away--Blessed be the name of +the Lord! But it's so hard--Oh, it's so hard! Only last Saturday my +Joe busted a firecracker right under my nose and I knocked him +sprawling. Little did I know then, how soon--Oh, if it was to do over +again I'd hug him and bless him for it." + +"Yes, yes, yes, I know just how you feel, Mrs. Harper, I know just +exactly how you feel. No longer ago than yesterday noon, my Tom took +and filled the cat full of Pain-killer, and I did think the cretur +would tear the house down. And God forgive me, I cracked Tom's head +with my thimble, poor boy, poor dead boy. But he's out of all his +troubles now. And the last words I ever heard him say was to reproach--" + +But this memory was too much for the old lady, and she broke entirely +down. Tom was snuffling, now, himself--and more in pity of himself than +anybody else. He could hear Mary crying, and putting in a kindly word +for him from time to time. He began to have a nobler opinion of himself +than ever before. Still, he was sufficiently touched by his aunt's +grief to long to rush out from under the bed and overwhelm her with +joy--and the theatrical gorgeousness of the thing appealed strongly to +his nature, too, but he resisted and lay still. + +He went on listening, and gathered by odds and ends that it was +conjectured at first that the boys had got drowned while taking a swim; +then the small raft had been missed; next, certain boys said the +missing lads had promised that the village should "hear something" +soon; the wise-heads had "put this and that together" and decided that +the lads had gone off on that raft and would turn up at the next town +below, presently; but toward noon the raft had been found, lodged +against the Missouri shore some five or six miles below the village +--and then hope perished; they must be drowned, else hunger would have +driven them home by nightfall if not sooner. It was believed that the +search for the bodies had been a fruitless effort merely because the +drowning must have occurred in mid-channel, since the boys, being good +swimmers, would otherwise have escaped to shore. This was Wednesday +night. If the bodies continued missing until Sunday, all hope would be +given over, and the funerals would be preached on that morning. Tom +shuddered. + +Mrs. Harper gave a sobbing good-night and turned to go. Then with a +mutual impulse the two bereaved women flung themselves into each +other's arms and had a good, consoling cry, and then parted. Aunt Polly +was tender far beyond her wont, in her good-night to Sid and Mary. Sid +snuffled a bit and Mary went off crying with all her heart. + +Aunt Polly knelt down and prayed for Tom so touchingly, so +appealingly, and with such measureless love in her words and her old +trembling voice, that he was weltering in tears again, long before she +was through. + +He had to keep still long after she went to bed, for she kept making +broken-hearted ejaculations from time to time, tossing unrestfully, and +turning over. But at last she was still, only moaning a little in her +sleep. Now the boy stole out, rose gradually by the bedside, shaded the +candle-light with his hand, and stood regarding her. His heart was full +of pity for her. He took out his sycamore scroll and placed it by the +candle. But something occurred to him, and he lingered considering. His +face lighted with a happy solution of his thought; he put the bark +hastily in his pocket. Then he bent over and kissed the faded lips, and +straightway made his stealthy exit, latching the door behind him. + +He threaded his way back to the ferry landing, found nobody at large +there, and walked boldly on board the boat, for he knew she was +tenantless except that there was a watchman, who always turned in and +slept like a graven image. He untied the skiff at the stern, slipped +into it, and was soon rowing cautiously upstream. When he had pulled a +mile above the village, he started quartering across and bent himself +stoutly to his work. He hit the landing on the other side neatly, for +this was a familiar bit of work to him. He was moved to capture the +skiff, arguing that it might be considered a ship and therefore +legitimate prey for a pirate, but he knew a thorough search would be +made for it and that might end in revelations. So he stepped ashore and +entered the woods. + +He sat down and took a long rest, torturing himself meanwhile to keep +awake, and then started warily down the home-stretch. The night was far +spent. It was broad daylight before he found himself fairly abreast the +island bar. He rested again until the sun was well up and gilding the +great river with its splendor, and then he plunged into the stream. A +little later he paused, dripping, upon the threshold of the camp, and +heard Joe say: + +"No, Tom's true-blue, Huck, and he'll come back. He won't desert. He +knows that would be a disgrace to a pirate, and Tom's too proud for +that sort of thing. He's up to something or other. Now I wonder what?" + +"Well, the things is ours, anyway, ain't they?" + +"Pretty near, but not yet, Huck. The writing says they are if he ain't +back here to breakfast." + +"Which he is!" exclaimed Tom, with fine dramatic effect, stepping +grandly into camp. + +A sumptuous breakfast of bacon and fish was shortly provided, and as +the boys set to work upon it, Tom recounted (and adorned) his +adventures. They were a vain and boastful company of heroes when the +tale was done. Then Tom hid himself away in a shady nook to sleep till +noon, and the other pirates got ready to fish and explore. + + + +CHAPTER XVI + +AFTER dinner all the gang turned out to hunt for turtle eggs on the +bar. They went about poking sticks into the sand, and when they found a +soft place they went down on their knees and dug with their hands. +Sometimes they would take fifty or sixty eggs out of one hole. They +were perfectly round white things a trifle smaller than an English +walnut. They had a famous fried-egg feast that night, and another on +Friday morning. + +After breakfast they went whooping and prancing out on the bar, and +chased each other round and round, shedding clothes as they went, until +they were naked, and then continued the frolic far away up the shoal +water of the bar, against the stiff current, which latter tripped their +legs from under them from time to time and greatly increased the fun. +And now and then they stooped in a group and splashed water in each +other's faces with their palms, gradually approaching each other, with +averted faces to avoid the strangling sprays, and finally gripping and +struggling till the best man ducked his neighbor, and then they all +went under in a tangle of white legs and arms and came up blowing, +sputtering, laughing, and gasping for breath at one and the same time. + +When they were well exhausted, they would run out and sprawl on the +dry, hot sand, and lie there and cover themselves up with it, and by +and by break for the water again and go through the original +performance once more. Finally it occurred to them that their naked +skin represented flesh-colored "tights" very fairly; so they drew a +ring in the sand and had a circus--with three clowns in it, for none +would yield this proudest post to his neighbor. + +Next they got their marbles and played "knucks" and "ring-taw" and +"keeps" till that amusement grew stale. Then Joe and Huck had another +swim, but Tom would not venture, because he found that in kicking off +his trousers he had kicked his string of rattlesnake rattles off his +ankle, and he wondered how he had escaped cramp so long without the +protection of this mysterious charm. He did not venture again until he +had found it, and by that time the other boys were tired and ready to +rest. They gradually wandered apart, dropped into the "dumps," and fell +to gazing longingly across the wide river to where the village lay +drowsing in the sun. Tom found himself writing "BECKY" in the sand with +his big toe; he scratched it out, and was angry with himself for his +weakness. But he wrote it again, nevertheless; he could not help it. He +erased it once more and then took himself out of temptation by driving +the other boys together and joining them. + +But Joe's spirits had gone down almost beyond resurrection. He was so +homesick that he could hardly endure the misery of it. The tears lay +very near the surface. Huck was melancholy, too. Tom was downhearted, +but tried hard not to show it. He had a secret which he was not ready +to tell, yet, but if this mutinous depression was not broken up soon, +he would have to bring it out. He said, with a great show of +cheerfulness: + +"I bet there's been pirates on this island before, boys. We'll explore +it again. They've hid treasures here somewhere. How'd you feel to light +on a rotten chest full of gold and silver--hey?" + +But it roused only faint enthusiasm, which faded out, with no reply. +Tom tried one or two other seductions; but they failed, too. It was +discouraging work. Joe sat poking up the sand with a stick and looking +very gloomy. Finally he said: + +"Oh, boys, let's give it up. I want to go home. It's so lonesome." + +"Oh no, Joe, you'll feel better by and by," said Tom. "Just think of +the fishing that's here." + +"I don't care for fishing. I want to go home." + +"But, Joe, there ain't such another swimming-place anywhere." + +"Swimming's no good. I don't seem to care for it, somehow, when there +ain't anybody to say I sha'n't go in. I mean to go home." + +"Oh, shucks! Baby! You want to see your mother, I reckon." + +"Yes, I DO want to see my mother--and you would, too, if you had one. +I ain't any more baby than you are." And Joe snuffled a little. + +"Well, we'll let the cry-baby go home to his mother, won't we, Huck? +Poor thing--does it want to see its mother? And so it shall. You like +it here, don't you, Huck? We'll stay, won't we?" + +Huck said, "Y-e-s"--without any heart in it. + +"I'll never speak to you again as long as I live," said Joe, rising. +"There now!" And he moved moodily away and began to dress himself. + +"Who cares!" said Tom. "Nobody wants you to. Go 'long home and get +laughed at. Oh, you're a nice pirate. Huck and me ain't cry-babies. +We'll stay, won't we, Huck? Let him go if he wants to. I reckon we can +get along without him, per'aps." + +But Tom was uneasy, nevertheless, and was alarmed to see Joe go +sullenly on with his dressing. And then it was discomforting to see +Huck eying Joe's preparations so wistfully, and keeping up such an +ominous silence. Presently, without a parting word, Joe began to wade +off toward the Illinois shore. Tom's heart began to sink. He glanced at +Huck. Huck could not bear the look, and dropped his eyes. Then he said: + +"I want to go, too, Tom. It was getting so lonesome anyway, and now +it'll be worse. Let's us go, too, Tom." + +"I won't! You can all go, if you want to. I mean to stay." + +"Tom, I better go." + +"Well, go 'long--who's hendering you." + +Huck began to pick up his scattered clothes. He said: + +"Tom, I wisht you'd come, too. Now you think it over. We'll wait for +you when we get to shore." + +"Well, you'll wait a blame long time, that's all." + +Huck started sorrowfully away, and Tom stood looking after him, with a +strong desire tugging at his heart to yield his pride and go along too. +He hoped the boys would stop, but they still waded slowly on. It +suddenly dawned on Tom that it was become very lonely and still. He +made one final struggle with his pride, and then darted after his +comrades, yelling: + +"Wait! Wait! I want to tell you something!" + +They presently stopped and turned around. When he got to where they +were, he began unfolding his secret, and they listened moodily till at +last they saw the "point" he was driving at, and then they set up a +war-whoop of applause and said it was "splendid!" and said if he had +told them at first, they wouldn't have started away. He made a plausible +excuse; but his real reason had been the fear that not even the secret +would keep them with him any very great length of time, and so he had +meant to hold it in reserve as a last seduction. + +The lads came gayly back and went at their sports again with a will, +chattering all the time about Tom's stupendous plan and admiring the +genius of it. After a dainty egg and fish dinner, Tom said he wanted to +learn to smoke, now. Joe caught at the idea and said he would like to +try, too. So Huck made pipes and filled them. These novices had never +smoked anything before but cigars made of grape-vine, and they "bit" +the tongue, and were not considered manly anyway. + +Now they stretched themselves out on their elbows and began to puff, +charily, and with slender confidence. The smoke had an unpleasant +taste, and they gagged a little, but Tom said: + +"Why, it's just as easy! If I'd a knowed this was all, I'd a learnt +long ago." + +"So would I," said Joe. "It's just nothing." + +"Why, many a time I've looked at people smoking, and thought well I +wish I could do that; but I never thought I could," said Tom. + +"That's just the way with me, hain't it, Huck? You've heard me talk +just that way--haven't you, Huck? I'll leave it to Huck if I haven't." + +"Yes--heaps of times," said Huck. + +"Well, I have too," said Tom; "oh, hundreds of times. Once down by the +slaughter-house. Don't you remember, Huck? Bob Tanner was there, and +Johnny Miller, and Jeff Thatcher, when I said it. Don't you remember, +Huck, 'bout me saying that?" + +"Yes, that's so," said Huck. "That was the day after I lost a white +alley. No, 'twas the day before." + +"There--I told you so," said Tom. "Huck recollects it." + +"I bleeve I could smoke this pipe all day," said Joe. "I don't feel +sick." + +"Neither do I," said Tom. "I could smoke it all day. But I bet you +Jeff Thatcher couldn't." + +"Jeff Thatcher! Why, he'd keel over just with two draws. Just let him +try it once. HE'D see!" + +"I bet he would. And Johnny Miller--I wish could see Johnny Miller +tackle it once." + +"Oh, don't I!" said Joe. "Why, I bet you Johnny Miller couldn't any +more do this than nothing. Just one little snifter would fetch HIM." + +"'Deed it would, Joe. Say--I wish the boys could see us now." + +"So do I." + +"Say--boys, don't say anything about it, and some time when they're +around, I'll come up to you and say, 'Joe, got a pipe? I want a smoke.' +And you'll say, kind of careless like, as if it warn't anything, you'll +say, 'Yes, I got my OLD pipe, and another one, but my tobacker ain't +very good.' And I'll say, 'Oh, that's all right, if it's STRONG +enough.' And then you'll out with the pipes, and we'll light up just as +ca'm, and then just see 'em look!" + +"By jings, that'll be gay, Tom! I wish it was NOW!" + +"So do I! And when we tell 'em we learned when we was off pirating, +won't they wish they'd been along?" + +"Oh, I reckon not! I'll just BET they will!" + +So the talk ran on. But presently it began to flag a trifle, and grow +disjointed. The silences widened; the expectoration marvellously +increased. Every pore inside the boys' cheeks became a spouting +fountain; they could scarcely bail out the cellars under their tongues +fast enough to prevent an inundation; little overflowings down their +throats occurred in spite of all they could do, and sudden retchings +followed every time. Both boys were looking very pale and miserable, +now. Joe's pipe dropped from his nerveless fingers. Tom's followed. +Both fountains were going furiously and both pumps bailing with might +and main. Joe said feebly: + +"I've lost my knife. I reckon I better go and find it." + +Tom said, with quivering lips and halting utterance: + +"I'll help you. You go over that way and I'll hunt around by the +spring. No, you needn't come, Huck--we can find it." + +So Huck sat down again, and waited an hour. Then he found it lonesome, +and went to find his comrades. They were wide apart in the woods, both +very pale, both fast asleep. But something informed him that if they +had had any trouble they had got rid of it. + +They were not talkative at supper that night. They had a humble look, +and when Huck prepared his pipe after the meal and was going to prepare +theirs, they said no, they were not feeling very well--something they +ate at dinner had disagreed with them. + +About midnight Joe awoke, and called the boys. There was a brooding +oppressiveness in the air that seemed to bode something. The boys +huddled themselves together and sought the friendly companionship of +the fire, though the dull dead heat of the breathless atmosphere was +stifling. They sat still, intent and waiting. The solemn hush +continued. Beyond the light of the fire everything was swallowed up in +the blackness of darkness. Presently there came a quivering glow that +vaguely revealed the foliage for a moment and then vanished. By and by +another came, a little stronger. Then another. Then a faint moan came +sighing through the branches of the forest and the boys felt a fleeting +breath upon their cheeks, and shuddered with the fancy that the Spirit +of the Night had gone by. There was a pause. Now a weird flash turned +night into day and showed every little grass-blade, separate and +distinct, that grew about their feet. And it showed three white, +startled faces, too. A deep peal of thunder went rolling and tumbling +down the heavens and lost itself in sullen rumblings in the distance. A +sweep of chilly air passed by, rustling all the leaves and snowing the +flaky ashes broadcast about the fire. Another fierce glare lit up the +forest and an instant crash followed that seemed to rend the tree-tops +right over the boys' heads. They clung together in terror, in the thick +gloom that followed. A few big rain-drops fell pattering upon the +leaves. + +"Quick! boys, go for the tent!" exclaimed Tom. + +They sprang away, stumbling over roots and among vines in the dark, no +two plunging in the same direction. A furious blast roared through the +trees, making everything sing as it went. One blinding flash after +another came, and peal on peal of deafening thunder. And now a +drenching rain poured down and the rising hurricane drove it in sheets +along the ground. The boys cried out to each other, but the roaring +wind and the booming thunder-blasts drowned their voices utterly. +However, one by one they straggled in at last and took shelter under +the tent, cold, scared, and streaming with water; but to have company +in misery seemed something to be grateful for. They could not talk, the +old sail flapped so furiously, even if the other noises would have +allowed them. The tempest rose higher and higher, and presently the +sail tore loose from its fastenings and went winging away on the blast. +The boys seized each others' hands and fled, with many tumblings and +bruises, to the shelter of a great oak that stood upon the river-bank. +Now the battle was at its highest. Under the ceaseless conflagration of +lightning that flamed in the skies, everything below stood out in +clean-cut and shadowless distinctness: the bending trees, the billowy +river, white with foam, the driving spray of spume-flakes, the dim +outlines of the high bluffs on the other side, glimpsed through the +drifting cloud-rack and the slanting veil of rain. Every little while +some giant tree yielded the fight and fell crashing through the younger +growth; and the unflagging thunder-peals came now in ear-splitting +explosive bursts, keen and sharp, and unspeakably appalling. The storm +culminated in one matchless effort that seemed likely to tear the island +to pieces, burn it up, drown it to the tree-tops, blow it away, and +deafen every creature in it, all at one and the same moment. It was a +wild night for homeless young heads to be out in. + +But at last the battle was done, and the forces retired with weaker +and weaker threatenings and grumblings, and peace resumed her sway. The +boys went back to camp, a good deal awed; but they found there was +still something to be thankful for, because the great sycamore, the +shelter of their beds, was a ruin, now, blasted by the lightnings, and +they were not under it when the catastrophe happened. + +Everything in camp was drenched, the camp-fire as well; for they were +but heedless lads, like their generation, and had made no provision +against rain. Here was matter for dismay, for they were soaked through +and chilled. They were eloquent in their distress; but they presently +discovered that the fire had eaten so far up under the great log it had +been built against (where it curved upward and separated itself from +the ground), that a handbreadth or so of it had escaped wetting; so +they patiently wrought until, with shreds and bark gathered from the +under sides of sheltered logs, they coaxed the fire to burn again. Then +they piled on great dead boughs till they had a roaring furnace, and +were glad-hearted once more. They dried their boiled ham and had a +feast, and after that they sat by the fire and expanded and glorified +their midnight adventure until morning, for there was not a dry spot to +sleep on, anywhere around. + +As the sun began to steal in upon the boys, drowsiness came over them, +and they went out on the sandbar and lay down to sleep. They got +scorched out by and by, and drearily set about getting breakfast. After +the meal they felt rusty, and stiff-jointed, and a little homesick once +more. Tom saw the signs, and fell to cheering up the pirates as well as +he could. But they cared nothing for marbles, or circus, or swimming, +or anything. He reminded them of the imposing secret, and raised a ray +of cheer. While it lasted, he got them interested in a new device. This +was to knock off being pirates, for a while, and be Indians for a +change. They were attracted by this idea; so it was not long before +they were stripped, and striped from head to heel with black mud, like +so many zebras--all of them chiefs, of course--and then they went +tearing through the woods to attack an English settlement. + +By and by they separated into three hostile tribes, and darted upon +each other from ambush with dreadful war-whoops, and killed and scalped +each other by thousands. It was a gory day. Consequently it was an +extremely satisfactory one. + +They assembled in camp toward supper-time, hungry and happy; but now a +difficulty arose--hostile Indians could not break the bread of +hospitality together without first making peace, and this was a simple +impossibility without smoking a pipe of peace. There was no other +process that ever they had heard of. Two of the savages almost wished +they had remained pirates. However, there was no other way; so with +such show of cheerfulness as they could muster they called for the pipe +and took their whiff as it passed, in due form. + +And behold, they were glad they had gone into savagery, for they had +gained something; they found that they could now smoke a little without +having to go and hunt for a lost knife; they did not get sick enough to +be seriously uncomfortable. They were not likely to fool away this high +promise for lack of effort. No, they practised cautiously, after +supper, with right fair success, and so they spent a jubilant evening. +They were prouder and happier in their new acquirement than they would +have been in the scalping and skinning of the Six Nations. We will +leave them to smoke and chatter and brag, since we have no further use +for them at present. + + + +CHAPTER XVII + +BUT there was no hilarity in the little town that same tranquil +Saturday afternoon. The Harpers, and Aunt Polly's family, were being +put into mourning, with great grief and many tears. An unusual quiet +possessed the village, although it was ordinarily quiet enough, in all +conscience. The villagers conducted their concerns with an absent air, +and talked little; but they sighed often. The Saturday holiday seemed a +burden to the children. They had no heart in their sports, and +gradually gave them up. + +In the afternoon Becky Thatcher found herself moping about the +deserted schoolhouse yard, and feeling very melancholy. But she found +nothing there to comfort her. She soliloquized: + +"Oh, if I only had a brass andiron-knob again! But I haven't got +anything now to remember him by." And she choked back a little sob. + +Presently she stopped, and said to herself: + +"It was right here. Oh, if it was to do over again, I wouldn't say +that--I wouldn't say it for the whole world. But he's gone now; I'll +never, never, never see him any more." + +This thought broke her down, and she wandered away, with tears rolling +down her cheeks. Then quite a group of boys and girls--playmates of +Tom's and Joe's--came by, and stood looking over the paling fence and +talking in reverent tones of how Tom did so-and-so the last time they +saw him, and how Joe said this and that small trifle (pregnant with +awful prophecy, as they could easily see now!)--and each speaker +pointed out the exact spot where the lost lads stood at the time, and +then added something like "and I was a-standing just so--just as I am +now, and as if you was him--I was as close as that--and he smiled, just +this way--and then something seemed to go all over me, like--awful, you +know--and I never thought what it meant, of course, but I can see now!" + +Then there was a dispute about who saw the dead boys last in life, and +many claimed that dismal distinction, and offered evidences, more or +less tampered with by the witness; and when it was ultimately decided +who DID see the departed last, and exchanged the last words with them, +the lucky parties took upon themselves a sort of sacred importance, and +were gaped at and envied by all the rest. One poor chap, who had no +other grandeur to offer, said with tolerably manifest pride in the +remembrance: + +"Well, Tom Sawyer he licked me once." + +But that bid for glory was a failure. Most of the boys could say that, +and so that cheapened the distinction too much. The group loitered +away, still recalling memories of the lost heroes, in awed voices. + +When the Sunday-school hour was finished, the next morning, the bell +began to toll, instead of ringing in the usual way. It was a very still +Sabbath, and the mournful sound seemed in keeping with the musing hush +that lay upon nature. The villagers began to gather, loitering a moment +in the vestibule to converse in whispers about the sad event. But there +was no whispering in the house; only the funereal rustling of dresses +as the women gathered to their seats disturbed the silence there. None +could remember when the little church had been so full before. There +was finally a waiting pause, an expectant dumbness, and then Aunt Polly +entered, followed by Sid and Mary, and they by the Harper family, all +in deep black, and the whole congregation, the old minister as well, +rose reverently and stood until the mourners were seated in the front +pew. There was another communing silence, broken at intervals by +muffled sobs, and then the minister spread his hands abroad and prayed. +A moving hymn was sung, and the text followed: "I am the Resurrection +and the Life." + +As the service proceeded, the clergyman drew such pictures of the +graces, the winning ways, and the rare promise of the lost lads that +every soul there, thinking he recognized these pictures, felt a pang in +remembering that he had persistently blinded himself to them always +before, and had as persistently seen only faults and flaws in the poor +boys. The minister related many a touching incident in the lives of the +departed, too, which illustrated their sweet, generous natures, and the +people could easily see, now, how noble and beautiful those episodes +were, and remembered with grief that at the time they occurred they had +seemed rank rascalities, well deserving of the cowhide. The +congregation became more and more moved, as the pathetic tale went on, +till at last the whole company broke down and joined the weeping +mourners in a chorus of anguished sobs, the preacher himself giving way +to his feelings, and crying in the pulpit. + +There was a rustle in the gallery, which nobody noticed; a moment +later the church door creaked; the minister raised his streaming eyes +above his handkerchief, and stood transfixed! First one and then +another pair of eyes followed the minister's, and then almost with one +impulse the congregation rose and stared while the three dead boys came +marching up the aisle, Tom in the lead, Joe next, and Huck, a ruin of +drooping rags, sneaking sheepishly in the rear! They had been hid in +the unused gallery listening to their own funeral sermon! + +Aunt Polly, Mary, and the Harpers threw themselves upon their restored +ones, smothered them with kisses and poured out thanksgivings, while +poor Huck stood abashed and uncomfortable, not knowing exactly what to +do or where to hide from so many unwelcoming eyes. He wavered, and +started to slink away, but Tom seized him and said: + +"Aunt Polly, it ain't fair. Somebody's got to be glad to see Huck." + +"And so they shall. I'm glad to see him, poor motherless thing!" And +the loving attentions Aunt Polly lavished upon him were the one thing +capable of making him more uncomfortable than he was before. + +Suddenly the minister shouted at the top of his voice: "Praise God +from whom all blessings flow--SING!--and put your hearts in it!" + +And they did. Old Hundred swelled up with a triumphant burst, and +while it shook the rafters Tom Sawyer the Pirate looked around upon the +envying juveniles about him and confessed in his heart that this was +the proudest moment of his life. + +As the "sold" congregation trooped out they said they would almost be +willing to be made ridiculous again to hear Old Hundred sung like that +once more. + +Tom got more cuffs and kisses that day--according to Aunt Polly's +varying moods--than he had earned before in a year; and he hardly knew +which expressed the most gratefulness to God and affection for himself. + + + +CHAPTER XVIII + +THAT was Tom's great secret--the scheme to return home with his +brother pirates and attend their own funerals. They had paddled over to +the Missouri shore on a log, at dusk on Saturday, landing five or six +miles below the village; they had slept in the woods at the edge of the +town till nearly daylight, and had then crept through back lanes and +alleys and finished their sleep in the gallery of the church among a +chaos of invalided benches. + +At breakfast, Monday morning, Aunt Polly and Mary were very loving to +Tom, and very attentive to his wants. There was an unusual amount of +talk. In the course of it Aunt Polly said: + +"Well, I don't say it wasn't a fine joke, Tom, to keep everybody +suffering 'most a week so you boys had a good time, but it is a pity +you could be so hard-hearted as to let me suffer so. If you could come +over on a log to go to your funeral, you could have come over and give +me a hint some way that you warn't dead, but only run off." + +"Yes, you could have done that, Tom," said Mary; "and I believe you +would if you had thought of it." + +"Would you, Tom?" said Aunt Polly, her face lighting wistfully. "Say, +now, would you, if you'd thought of it?" + +"I--well, I don't know. 'Twould 'a' spoiled everything." + +"Tom, I hoped you loved me that much," said Aunt Polly, with a grieved +tone that discomforted the boy. "It would have been something if you'd +cared enough to THINK of it, even if you didn't DO it." + +"Now, auntie, that ain't any harm," pleaded Mary; "it's only Tom's +giddy way--he is always in such a rush that he never thinks of +anything." + +"More's the pity. Sid would have thought. And Sid would have come and +DONE it, too. Tom, you'll look back, some day, when it's too late, and +wish you'd cared a little more for me when it would have cost you so +little." + +"Now, auntie, you know I do care for you," said Tom. + +"I'd know it better if you acted more like it." + +"I wish now I'd thought," said Tom, with a repentant tone; "but I +dreamt about you, anyway. That's something, ain't it?" + +"It ain't much--a cat does that much--but it's better than nothing. +What did you dream?" + +"Why, Wednesday night I dreamt that you was sitting over there by the +bed, and Sid was sitting by the woodbox, and Mary next to him." + +"Well, so we did. So we always do. I'm glad your dreams could take +even that much trouble about us." + +"And I dreamt that Joe Harper's mother was here." + +"Why, she was here! Did you dream any more?" + +"Oh, lots. But it's so dim, now." + +"Well, try to recollect--can't you?" + +"Somehow it seems to me that the wind--the wind blowed the--the--" + +"Try harder, Tom! The wind did blow something. Come!" + +Tom pressed his fingers on his forehead an anxious minute, and then +said: + +"I've got it now! I've got it now! It blowed the candle!" + +"Mercy on us! Go on, Tom--go on!" + +"And it seems to me that you said, 'Why, I believe that that door--'" + +"Go ON, Tom!" + +"Just let me study a moment--just a moment. Oh, yes--you said you +believed the door was open." + +"As I'm sitting here, I did! Didn't I, Mary! Go on!" + +"And then--and then--well I won't be certain, but it seems like as if +you made Sid go and--and--" + +"Well? Well? What did I make him do, Tom? What did I make him do?" + +"You made him--you--Oh, you made him shut it." + +"Well, for the land's sake! I never heard the beat of that in all my +days! Don't tell ME there ain't anything in dreams, any more. Sereny +Harper shall know of this before I'm an hour older. I'd like to see her +get around THIS with her rubbage 'bout superstition. Go on, Tom!" + +"Oh, it's all getting just as bright as day, now. Next you said I +warn't BAD, only mischeevous and harum-scarum, and not any more +responsible than--than--I think it was a colt, or something." + +"And so it was! Well, goodness gracious! Go on, Tom!" + +"And then you began to cry." + +"So I did. So I did. Not the first time, neither. And then--" + +"Then Mrs. Harper she began to cry, and said Joe was just the same, +and she wished she hadn't whipped him for taking cream when she'd +throwed it out her own self--" + +"Tom! The sperrit was upon you! You was a prophesying--that's what you +was doing! Land alive, go on, Tom!" + +"Then Sid he said--he said--" + +"I don't think I said anything," said Sid. + +"Yes you did, Sid," said Mary. + +"Shut your heads and let Tom go on! What did he say, Tom?" + +"He said--I THINK he said he hoped I was better off where I was gone +to, but if I'd been better sometimes--" + +"THERE, d'you hear that! It was his very words!" + +"And you shut him up sharp." + +"I lay I did! There must 'a' been an angel there. There WAS an angel +there, somewheres!" + +"And Mrs. Harper told about Joe scaring her with a firecracker, and +you told about Peter and the Painkiller--" + +"Just as true as I live!" + +"And then there was a whole lot of talk 'bout dragging the river for +us, and 'bout having the funeral Sunday, and then you and old Miss +Harper hugged and cried, and she went." + +"It happened just so! It happened just so, as sure as I'm a-sitting in +these very tracks. Tom, you couldn't told it more like if you'd 'a' +seen it! And then what? Go on, Tom!" + +"Then I thought you prayed for me--and I could see you and hear every +word you said. And you went to bed, and I was so sorry that I took and +wrote on a piece of sycamore bark, 'We ain't dead--we are only off +being pirates,' and put it on the table by the candle; and then you +looked so good, laying there asleep, that I thought I went and leaned +over and kissed you on the lips." + +"Did you, Tom, DID you! I just forgive you everything for that!" And +she seized the boy in a crushing embrace that made him feel like the +guiltiest of villains. + +"It was very kind, even though it was only a--dream," Sid soliloquized +just audibly. + +"Shut up, Sid! A body does just the same in a dream as he'd do if he +was awake. Here's a big Milum apple I've been saving for you, Tom, if +you was ever found again--now go 'long to school. I'm thankful to the +good God and Father of us all I've got you back, that's long-suffering +and merciful to them that believe on Him and keep His word, though +goodness knows I'm unworthy of it, but if only the worthy ones got His +blessings and had His hand to help them over the rough places, there's +few enough would smile here or ever enter into His rest when the long +night comes. Go 'long Sid, Mary, Tom--take yourselves off--you've +hendered me long enough." + +The children left for school, and the old lady to call on Mrs. Harper +and vanquish her realism with Tom's marvellous dream. Sid had better +judgment than to utter the thought that was in his mind as he left the +house. It was this: "Pretty thin--as long a dream as that, without any +mistakes in it!" + +What a hero Tom was become, now! He did not go skipping and prancing, +but moved with a dignified swagger as became a pirate who felt that the +public eye was on him. And indeed it was; he tried not to seem to see +the looks or hear the remarks as he passed along, but they were food +and drink to him. Smaller boys than himself flocked at his heels, as +proud to be seen with him, and tolerated by him, as if he had been the +drummer at the head of a procession or the elephant leading a menagerie +into town. Boys of his own size pretended not to know he had been away +at all; but they were consuming with envy, nevertheless. They would +have given anything to have that swarthy suntanned skin of his, and his +glittering notoriety; and Tom would not have parted with either for a +circus. + +At school the children made so much of him and of Joe, and delivered +such eloquent admiration from their eyes, that the two heroes were not +long in becoming insufferably "stuck-up." They began to tell their +adventures to hungry listeners--but they only began; it was not a thing +likely to have an end, with imaginations like theirs to furnish +material. And finally, when they got out their pipes and went serenely +puffing around, the very summit of glory was reached. + +Tom decided that he could be independent of Becky Thatcher now. Glory +was sufficient. He would live for glory. Now that he was distinguished, +maybe she would be wanting to "make up." Well, let her--she should see +that he could be as indifferent as some other people. Presently she +arrived. Tom pretended not to see her. He moved away and joined a group +of boys and girls and began to talk. Soon he observed that she was +tripping gayly back and forth with flushed face and dancing eyes, +pretending to be busy chasing schoolmates, and screaming with laughter +when she made a capture; but he noticed that she always made her +captures in his vicinity, and that she seemed to cast a conscious eye +in his direction at such times, too. It gratified all the vicious +vanity that was in him; and so, instead of winning him, it only "set +him up" the more and made him the more diligent to avoid betraying that +he knew she was about. Presently she gave over skylarking, and moved +irresolutely about, sighing once or twice and glancing furtively and +wistfully toward Tom. Then she observed that now Tom was talking more +particularly to Amy Lawrence than to any one else. She felt a sharp +pang and grew disturbed and uneasy at once. She tried to go away, but +her feet were treacherous, and carried her to the group instead. She +said to a girl almost at Tom's elbow--with sham vivacity: + +"Why, Mary Austin! you bad girl, why didn't you come to Sunday-school?" + +"I did come--didn't you see me?" + +"Why, no! Did you? Where did you sit?" + +"I was in Miss Peters' class, where I always go. I saw YOU." + +"Did you? Why, it's funny I didn't see you. I wanted to tell you about +the picnic." + +"Oh, that's jolly. Who's going to give it?" + +"My ma's going to let me have one." + +"Oh, goody; I hope she'll let ME come." + +"Well, she will. The picnic's for me. She'll let anybody come that I +want, and I want you." + +"That's ever so nice. When is it going to be?" + +"By and by. Maybe about vacation." + +"Oh, won't it be fun! You going to have all the girls and boys?" + +"Yes, every one that's friends to me--or wants to be"; and she glanced +ever so furtively at Tom, but he talked right along to Amy Lawrence +about the terrible storm on the island, and how the lightning tore the +great sycamore tree "all to flinders" while he was "standing within +three feet of it." + +"Oh, may I come?" said Grace Miller. + +"Yes." + +"And me?" said Sally Rogers. + +"Yes." + +"And me, too?" said Susy Harper. "And Joe?" + +"Yes." + +And so on, with clapping of joyful hands till all the group had begged +for invitations but Tom and Amy. Then Tom turned coolly away, still +talking, and took Amy with him. Becky's lips trembled and the tears +came to her eyes; she hid these signs with a forced gayety and went on +chattering, but the life had gone out of the picnic, now, and out of +everything else; she got away as soon as she could and hid herself and +had what her sex call "a good cry." Then she sat moody, with wounded +pride, till the bell rang. She roused up, now, with a vindictive cast +in her eye, and gave her plaited tails a shake and said she knew what +SHE'D do. + +At recess Tom continued his flirtation with Amy with jubilant +self-satisfaction. And he kept drifting about to find Becky and lacerate +her with the performance. At last he spied her, but there was a sudden +falling of his mercury. She was sitting cosily on a little bench behind +the schoolhouse looking at a picture-book with Alfred Temple--and so +absorbed were they, and their heads so close together over the book, +that they did not seem to be conscious of anything in the world besides. +Jealousy ran red-hot through Tom's veins. He began to hate himself for +throwing away the chance Becky had offered for a reconciliation. He +called himself a fool, and all the hard names he could think of. He +wanted to cry with vexation. Amy chatted happily along, as they walked, +for her heart was singing, but Tom's tongue had lost its function. He +did not hear what Amy was saying, and whenever she paused expectantly he +could only stammer an awkward assent, which was as often misplaced as +otherwise. He kept drifting to the rear of the schoolhouse, again and +again, to sear his eyeballs with the hateful spectacle there. He could +not help it. And it maddened him to see, as he thought he saw, that +Becky Thatcher never once suspected that he was even in the land of the +living. But she did see, nevertheless; and she knew she was winning her +fight, too, and was glad to see him suffer as she had suffered. + +Amy's happy prattle became intolerable. Tom hinted at things he had to +attend to; things that must be done; and time was fleeting. But in +vain--the girl chirped on. Tom thought, "Oh, hang her, ain't I ever +going to get rid of her?" At last he must be attending to those +things--and she said artlessly that she would be "around" when school +let out. And he hastened away, hating her for it. + +"Any other boy!" Tom thought, grating his teeth. "Any boy in the whole +town but that Saint Louis smarty that thinks he dresses so fine and is +aristocracy! Oh, all right, I licked you the first day you ever saw +this town, mister, and I'll lick you again! You just wait till I catch +you out! I'll just take and--" + +And he went through the motions of thrashing an imaginary boy +--pummelling the air, and kicking and gouging. "Oh, you do, do you? You +holler 'nough, do you? Now, then, let that learn you!" And so the +imaginary flogging was finished to his satisfaction. + +Tom fled home at noon. His conscience could not endure any more of +Amy's grateful happiness, and his jealousy could bear no more of the +other distress. Becky resumed her picture inspections with Alfred, but +as the minutes dragged along and no Tom came to suffer, her triumph +began to cloud and she lost interest; gravity and absent-mindedness +followed, and then melancholy; two or three times she pricked up her +ear at a footstep, but it was a false hope; no Tom came. At last she +grew entirely miserable and wished she hadn't carried it so far. When +poor Alfred, seeing that he was losing her, he did not know how, kept +exclaiming: "Oh, here's a jolly one! look at this!" she lost patience +at last, and said, "Oh, don't bother me! I don't care for them!" and +burst into tears, and got up and walked away. + +Alfred dropped alongside and was going to try to comfort her, but she +said: + +"Go away and leave me alone, can't you! I hate you!" + +So the boy halted, wondering what he could have done--for she had said +she would look at pictures all through the nooning--and she walked on, +crying. Then Alfred went musing into the deserted schoolhouse. He was +humiliated and angry. He easily guessed his way to the truth--the girl +had simply made a convenience of him to vent her spite upon Tom Sawyer. +He was far from hating Tom the less when this thought occurred to him. +He wished there was some way to get that boy into trouble without much +risk to himself. Tom's spelling-book fell under his eye. Here was his +opportunity. He gratefully opened to the lesson for the afternoon and +poured ink upon the page. + +Becky, glancing in at a window behind him at the moment, saw the act, +and moved on, without discovering herself. She started homeward, now, +intending to find Tom and tell him; Tom would be thankful and their +troubles would be healed. Before she was half way home, however, she +had changed her mind. The thought of Tom's treatment of her when she +was talking about her picnic came scorching back and filled her with +shame. She resolved to let him get whipped on the damaged +spelling-book's account, and to hate him forever, into the bargain. + + + +CHAPTER XIX + +TOM arrived at home in a dreary mood, and the first thing his aunt +said to him showed him that he had brought his sorrows to an +unpromising market: + +"Tom, I've a notion to skin you alive!" + +"Auntie, what have I done?" + +"Well, you've done enough. Here I go over to Sereny Harper, like an +old softy, expecting I'm going to make her believe all that rubbage +about that dream, when lo and behold you she'd found out from Joe that +you was over here and heard all the talk we had that night. Tom, I +don't know what is to become of a boy that will act like that. It makes +me feel so bad to think you could let me go to Sereny Harper and make +such a fool of myself and never say a word." + +This was a new aspect of the thing. His smartness of the morning had +seemed to Tom a good joke before, and very ingenious. It merely looked +mean and shabby now. He hung his head and could not think of anything +to say for a moment. Then he said: + +"Auntie, I wish I hadn't done it--but I didn't think." + +"Oh, child, you never think. You never think of anything but your own +selfishness. You could think to come all the way over here from +Jackson's Island in the night to laugh at our troubles, and you could +think to fool me with a lie about a dream; but you couldn't ever think +to pity us and save us from sorrow." + +"Auntie, I know now it was mean, but I didn't mean to be mean. I +didn't, honest. And besides, I didn't come over here to laugh at you +that night." + +"What did you come for, then?" + +"It was to tell you not to be uneasy about us, because we hadn't got +drownded." + +"Tom, Tom, I would be the thankfullest soul in this world if I could +believe you ever had as good a thought as that, but you know you never +did--and I know it, Tom." + +"Indeed and 'deed I did, auntie--I wish I may never stir if I didn't." + +"Oh, Tom, don't lie--don't do it. It only makes things a hundred times +worse." + +"It ain't a lie, auntie; it's the truth. I wanted to keep you from +grieving--that was all that made me come." + +"I'd give the whole world to believe that--it would cover up a power +of sins, Tom. I'd 'most be glad you'd run off and acted so bad. But it +ain't reasonable; because, why didn't you tell me, child?" + +"Why, you see, when you got to talking about the funeral, I just got +all full of the idea of our coming and hiding in the church, and I +couldn't somehow bear to spoil it. So I just put the bark back in my +pocket and kept mum." + +"What bark?" + +"The bark I had wrote on to tell you we'd gone pirating. I wish, now, +you'd waked up when I kissed you--I do, honest." + +The hard lines in his aunt's face relaxed and a sudden tenderness +dawned in her eyes. + +"DID you kiss me, Tom?" + +"Why, yes, I did." + +"Are you sure you did, Tom?" + +"Why, yes, I did, auntie--certain sure." + +"What did you kiss me for, Tom?" + +"Because I loved you so, and you laid there moaning and I was so sorry." + +The words sounded like truth. The old lady could not hide a tremor in +her voice when she said: + +"Kiss me again, Tom!--and be off with you to school, now, and don't +bother me any more." + +The moment he was gone, she ran to a closet and got out the ruin of a +jacket which Tom had gone pirating in. Then she stopped, with it in her +hand, and said to herself: + +"No, I don't dare. Poor boy, I reckon he's lied about it--but it's a +blessed, blessed lie, there's such a comfort come from it. I hope the +Lord--I KNOW the Lord will forgive him, because it was such +goodheartedness in him to tell it. But I don't want to find out it's a +lie. I won't look." + +She put the jacket away, and stood by musing a minute. Twice she put +out her hand to take the garment again, and twice she refrained. Once +more she ventured, and this time she fortified herself with the +thought: "It's a good lie--it's a good lie--I won't let it grieve me." +So she sought the jacket pocket. A moment later she was reading Tom's +piece of bark through flowing tears and saying: "I could forgive the +boy, now, if he'd committed a million sins!" + + + +CHAPTER XX + +THERE was something about Aunt Polly's manner, when she kissed Tom, +that swept away his low spirits and made him lighthearted and happy +again. He started to school and had the luck of coming upon Becky +Thatcher at the head of Meadow Lane. His mood always determined his +manner. Without a moment's hesitation he ran to her and said: + +"I acted mighty mean to-day, Becky, and I'm so sorry. I won't ever, +ever do that way again, as long as ever I live--please make up, won't +you?" + +The girl stopped and looked him scornfully in the face: + +"I'll thank you to keep yourself TO yourself, Mr. Thomas Sawyer. I'll +never speak to you again." + +She tossed her head and passed on. Tom was so stunned that he had not +even presence of mind enough to say "Who cares, Miss Smarty?" until the +right time to say it had gone by. So he said nothing. But he was in a +fine rage, nevertheless. He moped into the schoolyard wishing she were +a boy, and imagining how he would trounce her if she were. He presently +encountered her and delivered a stinging remark as he passed. She +hurled one in return, and the angry breach was complete. It seemed to +Becky, in her hot resentment, that she could hardly wait for school to +"take in," she was so impatient to see Tom flogged for the injured +spelling-book. If she had had any lingering notion of exposing Alfred +Temple, Tom's offensive fling had driven it entirely away. + +Poor girl, she did not know how fast she was nearing trouble herself. +The master, Mr. Dobbins, had reached middle age with an unsatisfied +ambition. The darling of his desires was, to be a doctor, but poverty +had decreed that he should be nothing higher than a village +schoolmaster. Every day he took a mysterious book out of his desk and +absorbed himself in it at times when no classes were reciting. He kept +that book under lock and key. There was not an urchin in school but was +perishing to have a glimpse of it, but the chance never came. Every boy +and girl had a theory about the nature of that book; but no two +theories were alike, and there was no way of getting at the facts in +the case. Now, as Becky was passing by the desk, which stood near the +door, she noticed that the key was in the lock! It was a precious +moment. She glanced around; found herself alone, and the next instant +she had the book in her hands. The title-page--Professor Somebody's +ANATOMY--carried no information to her mind; so she began to turn the +leaves. She came at once upon a handsomely engraved and colored +frontispiece--a human figure, stark naked. At that moment a shadow fell +on the page and Tom Sawyer stepped in at the door and caught a glimpse +of the picture. Becky snatched at the book to close it, and had the +hard luck to tear the pictured page half down the middle. She thrust +the volume into the desk, turned the key, and burst out crying with +shame and vexation. + +"Tom Sawyer, you are just as mean as you can be, to sneak up on a +person and look at what they're looking at." + +"How could I know you was looking at anything?" + +"You ought to be ashamed of yourself, Tom Sawyer; you know you're +going to tell on me, and oh, what shall I do, what shall I do! I'll be +whipped, and I never was whipped in school." + +Then she stamped her little foot and said: + +"BE so mean if you want to! I know something that's going to happen. +You just wait and you'll see! Hateful, hateful, hateful!"--and she +flung out of the house with a new explosion of crying. + +Tom stood still, rather flustered by this onslaught. Presently he said +to himself: + +"What a curious kind of a fool a girl is! Never been licked in school! +Shucks! What's a licking! That's just like a girl--they're so +thin-skinned and chicken-hearted. Well, of course I ain't going to tell +old Dobbins on this little fool, because there's other ways of getting +even on her, that ain't so mean; but what of it? Old Dobbins will ask +who it was tore his book. Nobody'll answer. Then he'll do just the way +he always does--ask first one and then t'other, and when he comes to the +right girl he'll know it, without any telling. Girls' faces always tell +on them. They ain't got any backbone. She'll get licked. Well, it's a +kind of a tight place for Becky Thatcher, because there ain't any way +out of it." Tom conned the thing a moment longer, and then added: "All +right, though; she'd like to see me in just such a fix--let her sweat it +out!" + +Tom joined the mob of skylarking scholars outside. In a few moments +the master arrived and school "took in." Tom did not feel a strong +interest in his studies. Every time he stole a glance at the girls' +side of the room Becky's face troubled him. Considering all things, he +did not want to pity her, and yet it was all he could do to help it. He +could get up no exultation that was really worthy the name. Presently +the spelling-book discovery was made, and Tom's mind was entirely full +of his own matters for a while after that. Becky roused up from her +lethargy of distress and showed good interest in the proceedings. She +did not expect that Tom could get out of his trouble by denying that he +spilt the ink on the book himself; and she was right. The denial only +seemed to make the thing worse for Tom. Becky supposed she would be +glad of that, and she tried to believe she was glad of it, but she +found she was not certain. When the worst came to the worst, she had an +impulse to get up and tell on Alfred Temple, but she made an effort and +forced herself to keep still--because, said she to herself, "he'll tell +about me tearing the picture sure. I wouldn't say a word, not to save +his life!" + +Tom took his whipping and went back to his seat not at all +broken-hearted, for he thought it was possible that he had unknowingly +upset the ink on the spelling-book himself, in some skylarking bout--he +had denied it for form's sake and because it was custom, and had stuck +to the denial from principle. + +A whole hour drifted by, the master sat nodding in his throne, the air +was drowsy with the hum of study. By and by, Mr. Dobbins straightened +himself up, yawned, then unlocked his desk, and reached for his book, +but seemed undecided whether to take it out or leave it. Most of the +pupils glanced up languidly, but there were two among them that watched +his movements with intent eyes. Mr. Dobbins fingered his book absently +for a while, then took it out and settled himself in his chair to read! +Tom shot a glance at Becky. He had seen a hunted and helpless rabbit +look as she did, with a gun levelled at its head. Instantly he forgot +his quarrel with her. Quick--something must be done! done in a flash, +too! But the very imminence of the emergency paralyzed his invention. +Good!--he had an inspiration! He would run and snatch the book, spring +through the door and fly. But his resolution shook for one little +instant, and the chance was lost--the master opened the volume. If Tom +only had the wasted opportunity back again! Too late. There was no help +for Becky now, he said. The next moment the master faced the school. +Every eye sank under his gaze. There was that in it which smote even +the innocent with fear. There was silence while one might count ten +--the master was gathering his wrath. Then he spoke: "Who tore this book?" + +There was not a sound. One could have heard a pin drop. The stillness +continued; the master searched face after face for signs of guilt. + +"Benjamin Rogers, did you tear this book?" + +A denial. Another pause. + +"Joseph Harper, did you?" + +Another denial. Tom's uneasiness grew more and more intense under the +slow torture of these proceedings. The master scanned the ranks of +boys--considered a while, then turned to the girls: + +"Amy Lawrence?" + +A shake of the head. + +"Gracie Miller?" + +The same sign. + +"Susan Harper, did you do this?" + +Another negative. The next girl was Becky Thatcher. Tom was trembling +from head to foot with excitement and a sense of the hopelessness of +the situation. + +"Rebecca Thatcher" [Tom glanced at her face--it was white with terror] +--"did you tear--no, look me in the face" [her hands rose in appeal] +--"did you tear this book?" + +A thought shot like lightning through Tom's brain. He sprang to his +feet and shouted--"I done it!" + +The school stared in perplexity at this incredible folly. Tom stood a +moment, to gather his dismembered faculties; and when he stepped +forward to go to his punishment the surprise, the gratitude, the +adoration that shone upon him out of poor Becky's eyes seemed pay +enough for a hundred floggings. Inspired by the splendor of his own +act, he took without an outcry the most merciless flaying that even Mr. +Dobbins had ever administered; and also received with indifference the +added cruelty of a command to remain two hours after school should be +dismissed--for he knew who would wait for him outside till his +captivity was done, and not count the tedious time as loss, either. + +Tom went to bed that night planning vengeance against Alfred Temple; +for with shame and repentance Becky had told him all, not forgetting +her own treachery; but even the longing for vengeance had to give way, +soon, to pleasanter musings, and he fell asleep at last with Becky's +latest words lingering dreamily in his ear-- + +"Tom, how COULD you be so noble!" + + + +CHAPTER XXI + +VACATION was approaching. The schoolmaster, always severe, grew +severer and more exacting than ever, for he wanted the school to make a +good showing on "Examination" day. His rod and his ferule were seldom +idle now--at least among the smaller pupils. Only the biggest boys, and +young ladies of eighteen and twenty, escaped lashing. Mr. Dobbins' +lashings were very vigorous ones, too; for although he carried, under +his wig, a perfectly bald and shiny head, he had only reached middle +age, and there was no sign of feebleness in his muscle. As the great +day approached, all the tyranny that was in him came to the surface; he +seemed to take a vindictive pleasure in punishing the least +shortcomings. The consequence was, that the smaller boys spent their +days in terror and suffering and their nights in plotting revenge. They +threw away no opportunity to do the master a mischief. But he kept +ahead all the time. The retribution that followed every vengeful +success was so sweeping and majestic that the boys always retired from +the field badly worsted. At last they conspired together and hit upon a +plan that promised a dazzling victory. They swore in the sign-painter's +boy, told him the scheme, and asked his help. He had his own reasons +for being delighted, for the master boarded in his father's family and +had given the boy ample cause to hate him. The master's wife would go +on a visit to the country in a few days, and there would be nothing to +interfere with the plan; the master always prepared himself for great +occasions by getting pretty well fuddled, and the sign-painter's boy +said that when the dominie had reached the proper condition on +Examination Evening he would "manage the thing" while he napped in his +chair; then he would have him awakened at the right time and hurried +away to school. + +In the fulness of time the interesting occasion arrived. At eight in +the evening the schoolhouse was brilliantly lighted, and adorned with +wreaths and festoons of foliage and flowers. The master sat throned in +his great chair upon a raised platform, with his blackboard behind him. +He was looking tolerably mellow. Three rows of benches on each side and +six rows in front of him were occupied by the dignitaries of the town +and by the parents of the pupils. To his left, back of the rows of +citizens, was a spacious temporary platform upon which were seated the +scholars who were to take part in the exercises of the evening; rows of +small boys, washed and dressed to an intolerable state of discomfort; +rows of gawky big boys; snowbanks of girls and young ladies clad in +lawn and muslin and conspicuously conscious of their bare arms, their +grandmothers' ancient trinkets, their bits of pink and blue ribbon and +the flowers in their hair. All the rest of the house was filled with +non-participating scholars. + +The exercises began. A very little boy stood up and sheepishly +recited, "You'd scarce expect one of my age to speak in public on the +stage," etc.--accompanying himself with the painfully exact and +spasmodic gestures which a machine might have used--supposing the +machine to be a trifle out of order. But he got through safely, though +cruelly scared, and got a fine round of applause when he made his +manufactured bow and retired. + +A little shamefaced girl lisped, "Mary had a little lamb," etc., +performed a compassion-inspiring curtsy, got her meed of applause, and +sat down flushed and happy. + +Tom Sawyer stepped forward with conceited confidence and soared into +the unquenchable and indestructible "Give me liberty or give me death" +speech, with fine fury and frantic gesticulation, and broke down in the +middle of it. A ghastly stage-fright seized him, his legs quaked under +him and he was like to choke. True, he had the manifest sympathy of the +house but he had the house's silence, too, which was even worse than +its sympathy. The master frowned, and this completed the disaster. Tom +struggled awhile and then retired, utterly defeated. There was a weak +attempt at applause, but it died early. + +"The Boy Stood on the Burning Deck" followed; also "The Assyrian Came +Down," and other declamatory gems. Then there were reading exercises, +and a spelling fight. The meagre Latin class recited with honor. The +prime feature of the evening was in order, now--original "compositions" +by the young ladies. Each in her turn stepped forward to the edge of +the platform, cleared her throat, held up her manuscript (tied with +dainty ribbon), and proceeded to read, with labored attention to +"expression" and punctuation. The themes were the same that had been +illuminated upon similar occasions by their mothers before them, their +grandmothers, and doubtless all their ancestors in the female line +clear back to the Crusades. "Friendship" was one; "Memories of Other +Days"; "Religion in History"; "Dream Land"; "The Advantages of +Culture"; "Forms of Political Government Compared and Contrasted"; +"Melancholy"; "Filial Love"; "Heart Longings," etc., etc. + +A prevalent feature in these compositions was a nursed and petted +melancholy; another was a wasteful and opulent gush of "fine language"; +another was a tendency to lug in by the ears particularly prized words +and phrases until they were worn entirely out; and a peculiarity that +conspicuously marked and marred them was the inveterate and intolerable +sermon that wagged its crippled tail at the end of each and every one +of them. No matter what the subject might be, a brain-racking effort +was made to squirm it into some aspect or other that the moral and +religious mind could contemplate with edification. The glaring +insincerity of these sermons was not sufficient to compass the +banishment of the fashion from the schools, and it is not sufficient +to-day; it never will be sufficient while the world stands, perhaps. +There is no school in all our land where the young ladies do not feel +obliged to close their compositions with a sermon; and you will find +that the sermon of the most frivolous and the least religious girl in +the school is always the longest and the most relentlessly pious. But +enough of this. Homely truth is unpalatable. + +Let us return to the "Examination." The first composition that was +read was one entitled "Is this, then, Life?" Perhaps the reader can +endure an extract from it: + + "In the common walks of life, with what delightful + emotions does the youthful mind look forward to some + anticipated scene of festivity! Imagination is busy + sketching rose-tinted pictures of joy. In fancy, the + voluptuous votary of fashion sees herself amid the + festive throng, 'the observed of all observers.' Her + graceful form, arrayed in snowy robes, is whirling + through the mazes of the joyous dance; her eye is + brightest, her step is lightest in the gay assembly. + + "In such delicious fancies time quickly glides by, + and the welcome hour arrives for her entrance into + the Elysian world, of which she has had such bright + dreams. How fairy-like does everything appear to + her enchanted vision! Each new scene is more charming + than the last. But after a while she finds that + beneath this goodly exterior, all is vanity, the + flattery which once charmed her soul, now grates + harshly upon her ear; the ball-room has lost its + charms; and with wasted health and imbittered heart, + she turns away with the conviction that earthly + pleasures cannot satisfy the longings of the soul!" + +And so forth and so on. There was a buzz of gratification from time to +time during the reading, accompanied by whispered ejaculations of "How +sweet!" "How eloquent!" "So true!" etc., and after the thing had closed +with a peculiarly afflicting sermon the applause was enthusiastic. + +Then arose a slim, melancholy girl, whose face had the "interesting" +paleness that comes of pills and indigestion, and read a "poem." Two +stanzas of it will do: + + "A MISSOURI MAIDEN'S FAREWELL TO ALABAMA + + "Alabama, good-bye! I love thee well! + But yet for a while do I leave thee now! + Sad, yes, sad thoughts of thee my heart doth swell, + And burning recollections throng my brow! + For I have wandered through thy flowery woods; + Have roamed and read near Tallapoosa's stream; + Have listened to Tallassee's warring floods, + And wooed on Coosa's side Aurora's beam. + + "Yet shame I not to bear an o'er-full heart, + Nor blush to turn behind my tearful eyes; + 'Tis from no stranger land I now must part, + 'Tis to no strangers left I yield these sighs. + Welcome and home were mine within this State, + Whose vales I leave--whose spires fade fast from me + And cold must be mine eyes, and heart, and tete, + When, dear Alabama! they turn cold on thee!" + +There were very few there who knew what "tete" meant, but the poem was +very satisfactory, nevertheless. + +Next appeared a dark-complexioned, black-eyed, black-haired young +lady, who paused an impressive moment, assumed a tragic expression, and +began to read in a measured, solemn tone: + + "A VISION + + "Dark and tempestuous was night. Around the + throne on high not a single star quivered; but + the deep intonations of the heavy thunder + constantly vibrated upon the ear; whilst the + terrific lightning revelled in angry mood + through the cloudy chambers of heaven, seeming + to scorn the power exerted over its terror by + the illustrious Franklin! Even the boisterous + winds unanimously came forth from their mystic + homes, and blustered about as if to enhance by + their aid the wildness of the scene. + + "At such a time, so dark, so dreary, for human + sympathy my very spirit sighed; but instead thereof, + + "'My dearest friend, my counsellor, my comforter + and guide--My joy in grief, my second bliss + in joy,' came to my side. She moved like one of + those bright beings pictured in the sunny walks + of fancy's Eden by the romantic and young, a + queen of beauty unadorned save by her own + transcendent loveliness. So soft was her step, it + failed to make even a sound, and but for the + magical thrill imparted by her genial touch, as + other unobtrusive beauties, she would have glided + away un-perceived--unsought. A strange sadness + rested upon her features, like icy tears upon + the robe of December, as she pointed to the + contending elements without, and bade me contemplate + the two beings presented." + +This nightmare occupied some ten pages of manuscript and wound up with +a sermon so destructive of all hope to non-Presbyterians that it took +the first prize. This composition was considered to be the very finest +effort of the evening. The mayor of the village, in delivering the +prize to the author of it, made a warm speech in which he said that it +was by far the most "eloquent" thing he had ever listened to, and that +Daniel Webster himself might well be proud of it. + +It may be remarked, in passing, that the number of compositions in +which the word "beauteous" was over-fondled, and human experience +referred to as "life's page," was up to the usual average. + +Now the master, mellow almost to the verge of geniality, put his chair +aside, turned his back to the audience, and began to draw a map of +America on the blackboard, to exercise the geography class upon. But he +made a sad business of it with his unsteady hand, and a smothered +titter rippled over the house. He knew what the matter was, and set +himself to right it. He sponged out lines and remade them; but he only +distorted them more than ever, and the tittering was more pronounced. +He threw his entire attention upon his work, now, as if determined not +to be put down by the mirth. He felt that all eyes were fastened upon +him; he imagined he was succeeding, and yet the tittering continued; it +even manifestly increased. And well it might. There was a garret above, +pierced with a scuttle over his head; and down through this scuttle +came a cat, suspended around the haunches by a string; she had a rag +tied about her head and jaws to keep her from mewing; as she slowly +descended she curved upward and clawed at the string, she swung +downward and clawed at the intangible air. The tittering rose higher +and higher--the cat was within six inches of the absorbed teacher's +head--down, down, a little lower, and she grabbed his wig with her +desperate claws, clung to it, and was snatched up into the garret in an +instant with her trophy still in her possession! And how the light did +blaze abroad from the master's bald pate--for the sign-painter's boy +had GILDED it! + +That broke up the meeting. The boys were avenged. Vacation had come. + + NOTE:--The pretended "compositions" quoted in + this chapter are taken without alteration from a + volume entitled "Prose and Poetry, by a Western + Lady"--but they are exactly and precisely after + the schoolgirl pattern, and hence are much + happier than any mere imitations could be. + + + +CHAPTER XXII + +TOM joined the new order of Cadets of Temperance, being attracted by +the showy character of their "regalia." He promised to abstain from +smoking, chewing, and profanity as long as he remained a member. Now he +found out a new thing--namely, that to promise not to do a thing is the +surest way in the world to make a body want to go and do that very +thing. Tom soon found himself tormented with a desire to drink and +swear; the desire grew to be so intense that nothing but the hope of a +chance to display himself in his red sash kept him from withdrawing +from the order. Fourth of July was coming; but he soon gave that up +--gave it up before he had worn his shackles over forty-eight hours--and +fixed his hopes upon old Judge Frazer, justice of the peace, who was +apparently on his deathbed and would have a big public funeral, since +he was so high an official. During three days Tom was deeply concerned +about the Judge's condition and hungry for news of it. Sometimes his +hopes ran high--so high that he would venture to get out his regalia +and practise before the looking-glass. But the Judge had a most +discouraging way of fluctuating. At last he was pronounced upon the +mend--and then convalescent. Tom was disgusted; and felt a sense of +injury, too. He handed in his resignation at once--and that night the +Judge suffered a relapse and died. Tom resolved that he would never +trust a man like that again. + +The funeral was a fine thing. The Cadets paraded in a style calculated +to kill the late member with envy. Tom was a free boy again, however +--there was something in that. He could drink and swear, now--but found +to his surprise that he did not want to. The simple fact that he could, +took the desire away, and the charm of it. + +Tom presently wondered to find that his coveted vacation was beginning +to hang a little heavily on his hands. + +He attempted a diary--but nothing happened during three days, and so +he abandoned it. + +The first of all the negro minstrel shows came to town, and made a +sensation. Tom and Joe Harper got up a band of performers and were +happy for two days. + +Even the Glorious Fourth was in some sense a failure, for it rained +hard, there was no procession in consequence, and the greatest man in +the world (as Tom supposed), Mr. Benton, an actual United States +Senator, proved an overwhelming disappointment--for he was not +twenty-five feet high, nor even anywhere in the neighborhood of it. + +A circus came. The boys played circus for three days afterward in +tents made of rag carpeting--admission, three pins for boys, two for +girls--and then circusing was abandoned. + +A phrenologist and a mesmerizer came--and went again and left the +village duller and drearier than ever. + +There were some boys-and-girls' parties, but they were so few and so +delightful that they only made the aching voids between ache the harder. + +Becky Thatcher was gone to her Constantinople home to stay with her +parents during vacation--so there was no bright side to life anywhere. + +The dreadful secret of the murder was a chronic misery. It was a very +cancer for permanency and pain. + +Then came the measles. + +During two long weeks Tom lay a prisoner, dead to the world and its +happenings. He was very ill, he was interested in nothing. When he got +upon his feet at last and moved feebly down-town, a melancholy change +had come over everything and every creature. There had been a +"revival," and everybody had "got religion," not only the adults, but +even the boys and girls. Tom went about, hoping against hope for the +sight of one blessed sinful face, but disappointment crossed him +everywhere. He found Joe Harper studying a Testament, and turned sadly +away from the depressing spectacle. He sought Ben Rogers, and found him +visiting the poor with a basket of tracts. He hunted up Jim Hollis, who +called his attention to the precious blessing of his late measles as a +warning. Every boy he encountered added another ton to his depression; +and when, in desperation, he flew for refuge at last to the bosom of +Huckleberry Finn and was received with a Scriptural quotation, his +heart broke and he crept home and to bed realizing that he alone of all +the town was lost, forever and forever. + +And that night there came on a terrific storm, with driving rain, +awful claps of thunder and blinding sheets of lightning. He covered his +head with the bedclothes and waited in a horror of suspense for his +doom; for he had not the shadow of a doubt that all this hubbub was +about him. He believed he had taxed the forbearance of the powers above +to the extremity of endurance and that this was the result. It might +have seemed to him a waste of pomp and ammunition to kill a bug with a +battery of artillery, but there seemed nothing incongruous about the +getting up such an expensive thunderstorm as this to knock the turf +from under an insect like himself. + +By and by the tempest spent itself and died without accomplishing its +object. The boy's first impulse was to be grateful, and reform. His +second was to wait--for there might not be any more storms. + +The next day the doctors were back; Tom had relapsed. The three weeks +he spent on his back this time seemed an entire age. When he got abroad +at last he was hardly grateful that he had been spared, remembering how +lonely was his estate, how companionless and forlorn he was. He drifted +listlessly down the street and found Jim Hollis acting as judge in a +juvenile court that was trying a cat for murder, in the presence of her +victim, a bird. He found Joe Harper and Huck Finn up an alley eating a +stolen melon. Poor lads! they--like Tom--had suffered a relapse. + + + +CHAPTER XXIII + +AT last the sleepy atmosphere was stirred--and vigorously: the murder +trial came on in the court. It became the absorbing topic of village +talk immediately. Tom could not get away from it. Every reference to +the murder sent a shudder to his heart, for his troubled conscience and +fears almost persuaded him that these remarks were put forth in his +hearing as "feelers"; he did not see how he could be suspected of +knowing anything about the murder, but still he could not be +comfortable in the midst of this gossip. It kept him in a cold shiver +all the time. He took Huck to a lonely place to have a talk with him. +It would be some relief to unseal his tongue for a little while; to +divide his burden of distress with another sufferer. Moreover, he +wanted to assure himself that Huck had remained discreet. + +"Huck, have you ever told anybody about--that?" + +"'Bout what?" + +"You know what." + +"Oh--'course I haven't." + +"Never a word?" + +"Never a solitary word, so help me. What makes you ask?" + +"Well, I was afeard." + +"Why, Tom Sawyer, we wouldn't be alive two days if that got found out. +YOU know that." + +Tom felt more comfortable. After a pause: + +"Huck, they couldn't anybody get you to tell, could they?" + +"Get me to tell? Why, if I wanted that half-breed devil to drownd me +they could get me to tell. They ain't no different way." + +"Well, that's all right, then. I reckon we're safe as long as we keep +mum. But let's swear again, anyway. It's more surer." + +"I'm agreed." + +So they swore again with dread solemnities. + +"What is the talk around, Huck? I've heard a power of it." + +"Talk? Well, it's just Muff Potter, Muff Potter, Muff Potter all the +time. It keeps me in a sweat, constant, so's I want to hide som'ers." + +"That's just the same way they go on round me. I reckon he's a goner. +Don't you feel sorry for him, sometimes?" + +"Most always--most always. He ain't no account; but then he hain't +ever done anything to hurt anybody. Just fishes a little, to get money +to get drunk on--and loafs around considerable; but lord, we all do +that--leastways most of us--preachers and such like. But he's kind of +good--he give me half a fish, once, when there warn't enough for two; +and lots of times he's kind of stood by me when I was out of luck." + +"Well, he's mended kites for me, Huck, and knitted hooks on to my +line. I wish we could get him out of there." + +"My! we couldn't get him out, Tom. And besides, 'twouldn't do any +good; they'd ketch him again." + +"Yes--so they would. But I hate to hear 'em abuse him so like the +dickens when he never done--that." + +"I do too, Tom. Lord, I hear 'em say he's the bloodiest looking +villain in this country, and they wonder he wasn't ever hung before." + +"Yes, they talk like that, all the time. I've heard 'em say that if he +was to get free they'd lynch him." + +"And they'd do it, too." + +The boys had a long talk, but it brought them little comfort. As the +twilight drew on, they found themselves hanging about the neighborhood +of the little isolated jail, perhaps with an undefined hope that +something would happen that might clear away their difficulties. But +nothing happened; there seemed to be no angels or fairies interested in +this luckless captive. + +The boys did as they had often done before--went to the cell grating +and gave Potter some tobacco and matches. He was on the ground floor +and there were no guards. + +His gratitude for their gifts had always smote their consciences +before--it cut deeper than ever, this time. They felt cowardly and +treacherous to the last degree when Potter said: + +"You've been mighty good to me, boys--better'n anybody else in this +town. And I don't forget it, I don't. Often I says to myself, says I, +'I used to mend all the boys' kites and things, and show 'em where the +good fishin' places was, and befriend 'em what I could, and now they've +all forgot old Muff when he's in trouble; but Tom don't, and Huck +don't--THEY don't forget him, says I, 'and I don't forget them.' Well, +boys, I done an awful thing--drunk and crazy at the time--that's the +only way I account for it--and now I got to swing for it, and it's +right. Right, and BEST, too, I reckon--hope so, anyway. Well, we won't +talk about that. I don't want to make YOU feel bad; you've befriended +me. But what I want to say, is, don't YOU ever get drunk--then you won't +ever get here. Stand a litter furder west--so--that's it; it's a prime +comfort to see faces that's friendly when a body's in such a muck of +trouble, and there don't none come here but yourn. Good friendly +faces--good friendly faces. Git up on one another's backs and let me +touch 'em. That's it. Shake hands--yourn'll come through the bars, but +mine's too big. Little hands, and weak--but they've helped Muff Potter +a power, and they'd help him more if they could." + +Tom went home miserable, and his dreams that night were full of +horrors. The next day and the day after, he hung about the court-room, +drawn by an almost irresistible impulse to go in, but forcing himself +to stay out. Huck was having the same experience. They studiously +avoided each other. Each wandered away, from time to time, but the same +dismal fascination always brought them back presently. Tom kept his +ears open when idlers sauntered out of the court-room, but invariably +heard distressing news--the toils were closing more and more +relentlessly around poor Potter. At the end of the second day the +village talk was to the effect that Injun Joe's evidence stood firm and +unshaken, and that there was not the slightest question as to what the +jury's verdict would be. + +Tom was out late, that night, and came to bed through the window. He +was in a tremendous state of excitement. It was hours before he got to +sleep. All the village flocked to the court-house the next morning, for +this was to be the great day. Both sexes were about equally represented +in the packed audience. After a long wait the jury filed in and took +their places; shortly afterward, Potter, pale and haggard, timid and +hopeless, was brought in, with chains upon him, and seated where all +the curious eyes could stare at him; no less conspicuous was Injun Joe, +stolid as ever. There was another pause, and then the judge arrived and +the sheriff proclaimed the opening of the court. The usual whisperings +among the lawyers and gathering together of papers followed. These +details and accompanying delays worked up an atmosphere of preparation +that was as impressive as it was fascinating. + +Now a witness was called who testified that he found Muff Potter +washing in the brook, at an early hour of the morning that the murder +was discovered, and that he immediately sneaked away. After some +further questioning, counsel for the prosecution said: + +"Take the witness." + +The prisoner raised his eyes for a moment, but dropped them again when +his own counsel said: + +"I have no questions to ask him." + +The next witness proved the finding of the knife near the corpse. +Counsel for the prosecution said: + +"Take the witness." + +"I have no questions to ask him," Potter's lawyer replied. + +A third witness swore he had often seen the knife in Potter's +possession. + +"Take the witness." + +Counsel for Potter declined to question him. The faces of the audience +began to betray annoyance. Did this attorney mean to throw away his +client's life without an effort? + +Several witnesses deposed concerning Potter's guilty behavior when +brought to the scene of the murder. They were allowed to leave the +stand without being cross-questioned. + +Every detail of the damaging circumstances that occurred in the +graveyard upon that morning which all present remembered so well was +brought out by credible witnesses, but none of them were cross-examined +by Potter's lawyer. The perplexity and dissatisfaction of the house +expressed itself in murmurs and provoked a reproof from the bench. +Counsel for the prosecution now said: + +"By the oaths of citizens whose simple word is above suspicion, we +have fastened this awful crime, beyond all possibility of question, +upon the unhappy prisoner at the bar. We rest our case here." + +A groan escaped from poor Potter, and he put his face in his hands and +rocked his body softly to and fro, while a painful silence reigned in +the court-room. Many men were moved, and many women's compassion +testified itself in tears. Counsel for the defence rose and said: + +"Your honor, in our remarks at the opening of this trial, we +foreshadowed our purpose to prove that our client did this fearful deed +while under the influence of a blind and irresponsible delirium +produced by drink. We have changed our mind. We shall not offer that +plea." [Then to the clerk:] "Call Thomas Sawyer!" + +A puzzled amazement awoke in every face in the house, not even +excepting Potter's. Every eye fastened itself with wondering interest +upon Tom as he rose and took his place upon the stand. The boy looked +wild enough, for he was badly scared. The oath was administered. + +"Thomas Sawyer, where were you on the seventeenth of June, about the +hour of midnight?" + +Tom glanced at Injun Joe's iron face and his tongue failed him. The +audience listened breathless, but the words refused to come. After a +few moments, however, the boy got a little of his strength back, and +managed to put enough of it into his voice to make part of the house +hear: + +"In the graveyard!" + +"A little bit louder, please. Don't be afraid. You were--" + +"In the graveyard." + +A contemptuous smile flitted across Injun Joe's face. + +"Were you anywhere near Horse Williams' grave?" + +"Yes, sir." + +"Speak up--just a trifle louder. How near were you?" + +"Near as I am to you." + +"Were you hidden, or not?" + +"I was hid." + +"Where?" + +"Behind the elms that's on the edge of the grave." + +Injun Joe gave a barely perceptible start. + +"Any one with you?" + +"Yes, sir. I went there with--" + +"Wait--wait a moment. Never mind mentioning your companion's name. We +will produce him at the proper time. Did you carry anything there with +you." + +Tom hesitated and looked confused. + +"Speak out, my boy--don't be diffident. The truth is always +respectable. What did you take there?" + +"Only a--a--dead cat." + +There was a ripple of mirth, which the court checked. + +"We will produce the skeleton of that cat. Now, my boy, tell us +everything that occurred--tell it in your own way--don't skip anything, +and don't be afraid." + +Tom began--hesitatingly at first, but as he warmed to his subject his +words flowed more and more easily; in a little while every sound ceased +but his own voice; every eye fixed itself upon him; with parted lips +and bated breath the audience hung upon his words, taking no note of +time, rapt in the ghastly fascinations of the tale. The strain upon +pent emotion reached its climax when the boy said: + +"--and as the doctor fetched the board around and Muff Potter fell, +Injun Joe jumped with the knife and--" + +Crash! Quick as lightning the half-breed sprang for a window, tore his +way through all opposers, and was gone! + + + +CHAPTER XXIV + +TOM was a glittering hero once more--the pet of the old, the envy of +the young. His name even went into immortal print, for the village +paper magnified him. There were some that believed he would be +President, yet, if he escaped hanging. + +As usual, the fickle, unreasoning world took Muff Potter to its bosom +and fondled him as lavishly as it had abused him before. But that sort +of conduct is to the world's credit; therefore it is not well to find +fault with it. + +Tom's days were days of splendor and exultation to him, but his nights +were seasons of horror. Injun Joe infested all his dreams, and always +with doom in his eye. Hardly any temptation could persuade the boy to +stir abroad after nightfall. Poor Huck was in the same state of +wretchedness and terror, for Tom had told the whole story to the lawyer +the night before the great day of the trial, and Huck was sore afraid +that his share in the business might leak out, yet, notwithstanding +Injun Joe's flight had saved him the suffering of testifying in court. +The poor fellow had got the attorney to promise secrecy, but what of +that? Since Tom's harassed conscience had managed to drive him to the +lawyer's house by night and wring a dread tale from lips that had been +sealed with the dismalest and most formidable of oaths, Huck's +confidence in the human race was well-nigh obliterated. + +Daily Muff Potter's gratitude made Tom glad he had spoken; but nightly +he wished he had sealed up his tongue. + +Half the time Tom was afraid Injun Joe would never be captured; the +other half he was afraid he would be. He felt sure he never could draw +a safe breath again until that man was dead and he had seen the corpse. + +Rewards had been offered, the country had been scoured, but no Injun +Joe was found. One of those omniscient and awe-inspiring marvels, a +detective, came up from St. Louis, moused around, shook his head, +looked wise, and made that sort of astounding success which members of +that craft usually achieve. That is to say, he "found a clew." But you +can't hang a "clew" for murder, and so after that detective had got +through and gone home, Tom felt just as insecure as he was before. + +The slow days drifted on, and each left behind it a slightly lightened +weight of apprehension. + + + +CHAPTER XXV + +THERE comes a time in every rightly-constructed boy's life when he has +a raging desire to go somewhere and dig for hidden treasure. This +desire suddenly came upon Tom one day. He sallied out to find Joe +Harper, but failed of success. Next he sought Ben Rogers; he had gone +fishing. Presently he stumbled upon Huck Finn the Red-Handed. Huck +would answer. Tom took him to a private place and opened the matter to +him confidentially. Huck was willing. Huck was always willing to take a +hand in any enterprise that offered entertainment and required no +capital, for he had a troublesome superabundance of that sort of time +which is not money. "Where'll we dig?" said Huck. + +"Oh, most anywhere." + +"Why, is it hid all around?" + +"No, indeed it ain't. It's hid in mighty particular places, Huck +--sometimes on islands, sometimes in rotten chests under the end of a +limb of an old dead tree, just where the shadow falls at midnight; but +mostly under the floor in ha'nted houses." + +"Who hides it?" + +"Why, robbers, of course--who'd you reckon? Sunday-school +sup'rintendents?" + +"I don't know. If 'twas mine I wouldn't hide it; I'd spend it and have +a good time." + +"So would I. But robbers don't do that way. They always hide it and +leave it there." + +"Don't they come after it any more?" + +"No, they think they will, but they generally forget the marks, or +else they die. Anyway, it lays there a long time and gets rusty; and by +and by somebody finds an old yellow paper that tells how to find the +marks--a paper that's got to be ciphered over about a week because it's +mostly signs and hy'roglyphics." + +"Hyro--which?" + +"Hy'roglyphics--pictures and things, you know, that don't seem to mean +anything." + +"Have you got one of them papers, Tom?" + +"No." + +"Well then, how you going to find the marks?" + +"I don't want any marks. They always bury it under a ha'nted house or +on an island, or under a dead tree that's got one limb sticking out. +Well, we've tried Jackson's Island a little, and we can try it again +some time; and there's the old ha'nted house up the Still-House branch, +and there's lots of dead-limb trees--dead loads of 'em." + +"Is it under all of them?" + +"How you talk! No!" + +"Then how you going to know which one to go for?" + +"Go for all of 'em!" + +"Why, Tom, it'll take all summer." + +"Well, what of that? Suppose you find a brass pot with a hundred +dollars in it, all rusty and gray, or rotten chest full of di'monds. +How's that?" + +Huck's eyes glowed. + +"That's bully. Plenty bully enough for me. Just you gimme the hundred +dollars and I don't want no di'monds." + +"All right. But I bet you I ain't going to throw off on di'monds. Some +of 'em's worth twenty dollars apiece--there ain't any, hardly, but's +worth six bits or a dollar." + +"No! Is that so?" + +"Cert'nly--anybody'll tell you so. Hain't you ever seen one, Huck?" + +"Not as I remember." + +"Oh, kings have slathers of them." + +"Well, I don' know no kings, Tom." + +"I reckon you don't. But if you was to go to Europe you'd see a raft +of 'em hopping around." + +"Do they hop?" + +"Hop?--your granny! No!" + +"Well, what did you say they did, for?" + +"Shucks, I only meant you'd SEE 'em--not hopping, of course--what do +they want to hop for?--but I mean you'd just see 'em--scattered around, +you know, in a kind of a general way. Like that old humpbacked Richard." + +"Richard? What's his other name?" + +"He didn't have any other name. Kings don't have any but a given name." + +"No?" + +"But they don't." + +"Well, if they like it, Tom, all right; but I don't want to be a king +and have only just a given name, like a nigger. But say--where you +going to dig first?" + +"Well, I don't know. S'pose we tackle that old dead-limb tree on the +hill t'other side of Still-House branch?" + +"I'm agreed." + +So they got a crippled pick and a shovel, and set out on their +three-mile tramp. They arrived hot and panting, and threw themselves +down in the shade of a neighboring elm to rest and have a smoke. + +"I like this," said Tom. + +"So do I." + +"Say, Huck, if we find a treasure here, what you going to do with your +share?" + +"Well, I'll have pie and a glass of soda every day, and I'll go to +every circus that comes along. I bet I'll have a gay time." + +"Well, ain't you going to save any of it?" + +"Save it? What for?" + +"Why, so as to have something to live on, by and by." + +"Oh, that ain't any use. Pap would come back to thish-yer town some +day and get his claws on it if I didn't hurry up, and I tell you he'd +clean it out pretty quick. What you going to do with yourn, Tom?" + +"I'm going to buy a new drum, and a sure-'nough sword, and a red +necktie and a bull pup, and get married." + +"Married!" + +"That's it." + +"Tom, you--why, you ain't in your right mind." + +"Wait--you'll see." + +"Well, that's the foolishest thing you could do. Look at pap and my +mother. Fight! Why, they used to fight all the time. I remember, mighty +well." + +"That ain't anything. The girl I'm going to marry won't fight." + +"Tom, I reckon they're all alike. They'll all comb a body. Now you +better think 'bout this awhile. I tell you you better. What's the name +of the gal?" + +"It ain't a gal at all--it's a girl." + +"It's all the same, I reckon; some says gal, some says girl--both's +right, like enough. Anyway, what's her name, Tom?" + +"I'll tell you some time--not now." + +"All right--that'll do. Only if you get married I'll be more lonesomer +than ever." + +"No you won't. You'll come and live with me. Now stir out of this and +we'll go to digging." + +They worked and sweated for half an hour. No result. They toiled +another half-hour. Still no result. Huck said: + +"Do they always bury it as deep as this?" + +"Sometimes--not always. Not generally. I reckon we haven't got the +right place." + +So they chose a new spot and began again. The labor dragged a little, +but still they made progress. They pegged away in silence for some +time. Finally Huck leaned on his shovel, swabbed the beaded drops from +his brow with his sleeve, and said: + +"Where you going to dig next, after we get this one?" + +"I reckon maybe we'll tackle the old tree that's over yonder on +Cardiff Hill back of the widow's." + +"I reckon that'll be a good one. But won't the widow take it away from +us, Tom? It's on her land." + +"SHE take it away! Maybe she'd like to try it once. Whoever finds one +of these hid treasures, it belongs to him. It don't make any difference +whose land it's on." + +That was satisfactory. The work went on. By and by Huck said: + +"Blame it, we must be in the wrong place again. What do you think?" + +"It is mighty curious, Huck. I don't understand it. Sometimes witches +interfere. I reckon maybe that's what's the trouble now." + +"Shucks! Witches ain't got no power in the daytime." + +"Well, that's so. I didn't think of that. Oh, I know what the matter +is! What a blamed lot of fools we are! You got to find out where the +shadow of the limb falls at midnight, and that's where you dig!" + +"Then consound it, we've fooled away all this work for nothing. Now +hang it all, we got to come back in the night. It's an awful long way. +Can you get out?" + +"I bet I will. We've got to do it to-night, too, because if somebody +sees these holes they'll know in a minute what's here and they'll go +for it." + +"Well, I'll come around and maow to-night." + +"All right. Let's hide the tools in the bushes." + +The boys were there that night, about the appointed time. They sat in +the shadow waiting. It was a lonely place, and an hour made solemn by +old traditions. Spirits whispered in the rustling leaves, ghosts lurked +in the murky nooks, the deep baying of a hound floated up out of the +distance, an owl answered with his sepulchral note. The boys were +subdued by these solemnities, and talked little. By and by they judged +that twelve had come; they marked where the shadow fell, and began to +dig. Their hopes commenced to rise. Their interest grew stronger, and +their industry kept pace with it. The hole deepened and still deepened, +but every time their hearts jumped to hear the pick strike upon +something, they only suffered a new disappointment. It was only a stone +or a chunk. At last Tom said: + +"It ain't any use, Huck, we're wrong again." + +"Well, but we CAN'T be wrong. We spotted the shadder to a dot." + +"I know it, but then there's another thing." + +"What's that?". + +"Why, we only guessed at the time. Like enough it was too late or too +early." + +Huck dropped his shovel. + +"That's it," said he. "That's the very trouble. We got to give this +one up. We can't ever tell the right time, and besides this kind of +thing's too awful, here this time of night with witches and ghosts +a-fluttering around so. I feel as if something's behind me all the time; +and I'm afeard to turn around, becuz maybe there's others in front +a-waiting for a chance. I been creeping all over, ever since I got here." + +"Well, I've been pretty much so, too, Huck. They most always put in a +dead man when they bury a treasure under a tree, to look out for it." + +"Lordy!" + +"Yes, they do. I've always heard that." + +"Tom, I don't like to fool around much where there's dead people. A +body's bound to get into trouble with 'em, sure." + +"I don't like to stir 'em up, either. S'pose this one here was to +stick his skull out and say something!" + +"Don't Tom! It's awful." + +"Well, it just is. Huck, I don't feel comfortable a bit." + +"Say, Tom, let's give this place up, and try somewheres else." + +"All right, I reckon we better." + +"What'll it be?" + +Tom considered awhile; and then said: + +"The ha'nted house. That's it!" + +"Blame it, I don't like ha'nted houses, Tom. Why, they're a dern sight +worse'n dead people. Dead people might talk, maybe, but they don't come +sliding around in a shroud, when you ain't noticing, and peep over your +shoulder all of a sudden and grit their teeth, the way a ghost does. I +couldn't stand such a thing as that, Tom--nobody could." + +"Yes, but, Huck, ghosts don't travel around only at night. They won't +hender us from digging there in the daytime." + +"Well, that's so. But you know mighty well people don't go about that +ha'nted house in the day nor the night." + +"Well, that's mostly because they don't like to go where a man's been +murdered, anyway--but nothing's ever been seen around that house except +in the night--just some blue lights slipping by the windows--no regular +ghosts." + +"Well, where you see one of them blue lights flickering around, Tom, +you can bet there's a ghost mighty close behind it. It stands to +reason. Becuz you know that they don't anybody but ghosts use 'em." + +"Yes, that's so. But anyway they don't come around in the daytime, so +what's the use of our being afeard?" + +"Well, all right. We'll tackle the ha'nted house if you say so--but I +reckon it's taking chances." + +They had started down the hill by this time. There in the middle of +the moonlit valley below them stood the "ha'nted" house, utterly +isolated, its fences gone long ago, rank weeds smothering the very +doorsteps, the chimney crumbled to ruin, the window-sashes vacant, a +corner of the roof caved in. The boys gazed awhile, half expecting to +see a blue light flit past a window; then talking in a low tone, as +befitted the time and the circumstances, they struck far off to the +right, to give the haunted house a wide berth, and took their way +homeward through the woods that adorned the rearward side of Cardiff +Hill. + + + +CHAPTER XXVI + +ABOUT noon the next day the boys arrived at the dead tree; they had +come for their tools. Tom was impatient to go to the haunted house; +Huck was measurably so, also--but suddenly said: + +"Lookyhere, Tom, do you know what day it is?" + +Tom mentally ran over the days of the week, and then quickly lifted +his eyes with a startled look in them-- + +"My! I never once thought of it, Huck!" + +"Well, I didn't neither, but all at once it popped onto me that it was +Friday." + +"Blame it, a body can't be too careful, Huck. We might 'a' got into an +awful scrape, tackling such a thing on a Friday." + +"MIGHT! Better say we WOULD! There's some lucky days, maybe, but +Friday ain't." + +"Any fool knows that. I don't reckon YOU was the first that found it +out, Huck." + +"Well, I never said I was, did I? And Friday ain't all, neither. I had +a rotten bad dream last night--dreampt about rats." + +"No! Sure sign of trouble. Did they fight?" + +"No." + +"Well, that's good, Huck. When they don't fight it's only a sign that +there's trouble around, you know. All we got to do is to look mighty +sharp and keep out of it. We'll drop this thing for to-day, and play. +Do you know Robin Hood, Huck?" + +"No. Who's Robin Hood?" + +"Why, he was one of the greatest men that was ever in England--and the +best. He was a robber." + +"Cracky, I wisht I was. Who did he rob?" + +"Only sheriffs and bishops and rich people and kings, and such like. +But he never bothered the poor. He loved 'em. He always divided up with +'em perfectly square." + +"Well, he must 'a' been a brick." + +"I bet you he was, Huck. Oh, he was the noblest man that ever was. +They ain't any such men now, I can tell you. He could lick any man in +England, with one hand tied behind him; and he could take his yew bow +and plug a ten-cent piece every time, a mile and a half." + +"What's a YEW bow?" + +"I don't know. It's some kind of a bow, of course. And if he hit that +dime only on the edge he would set down and cry--and curse. But we'll +play Robin Hood--it's nobby fun. I'll learn you." + +"I'm agreed." + +So they played Robin Hood all the afternoon, now and then casting a +yearning eye down upon the haunted house and passing a remark about the +morrow's prospects and possibilities there. As the sun began to sink +into the west they took their way homeward athwart the long shadows of +the trees and soon were buried from sight in the forests of Cardiff +Hill. + +On Saturday, shortly after noon, the boys were at the dead tree again. +They had a smoke and a chat in the shade, and then dug a little in +their last hole, not with great hope, but merely because Tom said there +were so many cases where people had given up a treasure after getting +down within six inches of it, and then somebody else had come along and +turned it up with a single thrust of a shovel. The thing failed this +time, however, so the boys shouldered their tools and went away feeling +that they had not trifled with fortune, but had fulfilled all the +requirements that belong to the business of treasure-hunting. + +When they reached the haunted house there was something so weird and +grisly about the dead silence that reigned there under the baking sun, +and something so depressing about the loneliness and desolation of the +place, that they were afraid, for a moment, to venture in. Then they +crept to the door and took a trembling peep. They saw a weed-grown, +floorless room, unplastered, an ancient fireplace, vacant windows, a +ruinous staircase; and here, there, and everywhere hung ragged and +abandoned cobwebs. They presently entered, softly, with quickened +pulses, talking in whispers, ears alert to catch the slightest sound, +and muscles tense and ready for instant retreat. + +In a little while familiarity modified their fears and they gave the +place a critical and interested examination, rather admiring their own +boldness, and wondering at it, too. Next they wanted to look up-stairs. +This was something like cutting off retreat, but they got to daring +each other, and of course there could be but one result--they threw +their tools into a corner and made the ascent. Up there were the same +signs of decay. In one corner they found a closet that promised +mystery, but the promise was a fraud--there was nothing in it. Their +courage was up now and well in hand. They were about to go down and +begin work when-- + +"Sh!" said Tom. + +"What is it?" whispered Huck, blanching with fright. + +"Sh!... There!... Hear it?" + +"Yes!... Oh, my! Let's run!" + +"Keep still! Don't you budge! They're coming right toward the door." + +The boys stretched themselves upon the floor with their eyes to +knot-holes in the planking, and lay waiting, in a misery of fear. + +"They've stopped.... No--coming.... Here they are. Don't whisper +another word, Huck. My goodness, I wish I was out of this!" + +Two men entered. Each boy said to himself: "There's the old deaf and +dumb Spaniard that's been about town once or twice lately--never saw +t'other man before." + +"T'other" was a ragged, unkempt creature, with nothing very pleasant +in his face. The Spaniard was wrapped in a serape; he had bushy white +whiskers; long white hair flowed from under his sombrero, and he wore +green goggles. When they came in, "t'other" was talking in a low voice; +they sat down on the ground, facing the door, with their backs to the +wall, and the speaker continued his remarks. His manner became less +guarded and his words more distinct as he proceeded: + +"No," said he, "I've thought it all over, and I don't like it. It's +dangerous." + +"Dangerous!" grunted the "deaf and dumb" Spaniard--to the vast +surprise of the boys. "Milksop!" + +This voice made the boys gasp and quake. It was Injun Joe's! There was +silence for some time. Then Joe said: + +"What's any more dangerous than that job up yonder--but nothing's come +of it." + +"That's different. Away up the river so, and not another house about. +'Twon't ever be known that we tried, anyway, long as we didn't succeed." + +"Well, what's more dangerous than coming here in the daytime!--anybody +would suspicion us that saw us." + +"I know that. But there warn't any other place as handy after that +fool of a job. I want to quit this shanty. I wanted to yesterday, only +it warn't any use trying to stir out of here, with those infernal boys +playing over there on the hill right in full view." + +"Those infernal boys" quaked again under the inspiration of this +remark, and thought how lucky it was that they had remembered it was +Friday and concluded to wait a day. They wished in their hearts they +had waited a year. + +The two men got out some food and made a luncheon. After a long and +thoughtful silence, Injun Joe said: + +"Look here, lad--you go back up the river where you belong. Wait there +till you hear from me. I'll take the chances on dropping into this town +just once more, for a look. We'll do that 'dangerous' job after I've +spied around a little and think things look well for it. Then for +Texas! We'll leg it together!" + +This was satisfactory. Both men presently fell to yawning, and Injun +Joe said: + +"I'm dead for sleep! It's your turn to watch." + +He curled down in the weeds and soon began to snore. His comrade +stirred him once or twice and he became quiet. Presently the watcher +began to nod; his head drooped lower and lower, both men began to snore +now. + +The boys drew a long, grateful breath. Tom whispered: + +"Now's our chance--come!" + +Huck said: + +"I can't--I'd die if they was to wake." + +Tom urged--Huck held back. At last Tom rose slowly and softly, and +started alone. But the first step he made wrung such a hideous creak +from the crazy floor that he sank down almost dead with fright. He +never made a second attempt. The boys lay there counting the dragging +moments till it seemed to them that time must be done and eternity +growing gray; and then they were grateful to note that at last the sun +was setting. + +Now one snore ceased. Injun Joe sat up, stared around--smiled grimly +upon his comrade, whose head was drooping upon his knees--stirred him +up with his foot and said: + +"Here! YOU'RE a watchman, ain't you! All right, though--nothing's +happened." + +"My! have I been asleep?" + +"Oh, partly, partly. Nearly time for us to be moving, pard. What'll we +do with what little swag we've got left?" + +"I don't know--leave it here as we've always done, I reckon. No use to +take it away till we start south. Six hundred and fifty in silver's +something to carry." + +"Well--all right--it won't matter to come here once more." + +"No--but I'd say come in the night as we used to do--it's better." + +"Yes: but look here; it may be a good while before I get the right +chance at that job; accidents might happen; 'tain't in such a very good +place; we'll just regularly bury it--and bury it deep." + +"Good idea," said the comrade, who walked across the room, knelt down, +raised one of the rearward hearth-stones and took out a bag that +jingled pleasantly. He subtracted from it twenty or thirty dollars for +himself and as much for Injun Joe, and passed the bag to the latter, +who was on his knees in the corner, now, digging with his bowie-knife. + +The boys forgot all their fears, all their miseries in an instant. +With gloating eyes they watched every movement. Luck!--the splendor of +it was beyond all imagination! Six hundred dollars was money enough to +make half a dozen boys rich! Here was treasure-hunting under the +happiest auspices--there would not be any bothersome uncertainty as to +where to dig. They nudged each other every moment--eloquent nudges and +easily understood, for they simply meant--"Oh, but ain't you glad NOW +we're here!" + +Joe's knife struck upon something. + +"Hello!" said he. + +"What is it?" said his comrade. + +"Half-rotten plank--no, it's a box, I believe. Here--bear a hand and +we'll see what it's here for. Never mind, I've broke a hole." + +He reached his hand in and drew it out-- + +"Man, it's money!" + +The two men examined the handful of coins. They were gold. The boys +above were as excited as themselves, and as delighted. + +Joe's comrade said: + +"We'll make quick work of this. There's an old rusty pick over amongst +the weeds in the corner the other side of the fireplace--I saw it a +minute ago." + +He ran and brought the boys' pick and shovel. Injun Joe took the pick, +looked it over critically, shook his head, muttered something to +himself, and then began to use it. The box was soon unearthed. It was +not very large; it was iron bound and had been very strong before the +slow years had injured it. The men contemplated the treasure awhile in +blissful silence. + +"Pard, there's thousands of dollars here," said Injun Joe. + +"'Twas always said that Murrel's gang used to be around here one +summer," the stranger observed. + +"I know it," said Injun Joe; "and this looks like it, I should say." + +"Now you won't need to do that job." + +The half-breed frowned. Said he: + +"You don't know me. Least you don't know all about that thing. 'Tain't +robbery altogether--it's REVENGE!" and a wicked light flamed in his +eyes. "I'll need your help in it. When it's finished--then Texas. Go +home to your Nance and your kids, and stand by till you hear from me." + +"Well--if you say so; what'll we do with this--bury it again?" + +"Yes. [Ravishing delight overhead.] NO! by the great Sachem, no! +[Profound distress overhead.] I'd nearly forgot. That pick had fresh +earth on it! [The boys were sick with terror in a moment.] What +business has a pick and a shovel here? What business with fresh earth +on them? Who brought them here--and where are they gone? Have you heard +anybody?--seen anybody? What! bury it again and leave them to come and +see the ground disturbed? Not exactly--not exactly. We'll take it to my +den." + +"Why, of course! Might have thought of that before. You mean Number +One?" + +"No--Number Two--under the cross. The other place is bad--too common." + +"All right. It's nearly dark enough to start." + +Injun Joe got up and went about from window to window cautiously +peeping out. Presently he said: + +"Who could have brought those tools here? Do you reckon they can be +up-stairs?" + +The boys' breath forsook them. Injun Joe put his hand on his knife, +halted a moment, undecided, and then turned toward the stairway. The +boys thought of the closet, but their strength was gone. The steps came +creaking up the stairs--the intolerable distress of the situation woke +the stricken resolution of the lads--they were about to spring for the +closet, when there was a crash of rotten timbers and Injun Joe landed +on the ground amid the debris of the ruined stairway. He gathered +himself up cursing, and his comrade said: + +"Now what's the use of all that? If it's anybody, and they're up +there, let them STAY there--who cares? If they want to jump down, now, +and get into trouble, who objects? It will be dark in fifteen minutes +--and then let them follow us if they want to. I'm willing. In my +opinion, whoever hove those things in here caught a sight of us and +took us for ghosts or devils or something. I'll bet they're running +yet." + +Joe grumbled awhile; then he agreed with his friend that what daylight +was left ought to be economized in getting things ready for leaving. +Shortly afterward they slipped out of the house in the deepening +twilight, and moved toward the river with their precious box. + +Tom and Huck rose up, weak but vastly relieved, and stared after them +through the chinks between the logs of the house. Follow? Not they. +They were content to reach ground again without broken necks, and take +the townward track over the hill. They did not talk much. They were too +much absorbed in hating themselves--hating the ill luck that made them +take the spade and the pick there. But for that, Injun Joe never would +have suspected. He would have hidden the silver with the gold to wait +there till his "revenge" was satisfied, and then he would have had the +misfortune to find that money turn up missing. Bitter, bitter luck that +the tools were ever brought there! + +They resolved to keep a lookout for that Spaniard when he should come +to town spying out for chances to do his revengeful job, and follow him +to "Number Two," wherever that might be. Then a ghastly thought +occurred to Tom. + +"Revenge? What if he means US, Huck!" + +"Oh, don't!" said Huck, nearly fainting. + +They talked it all over, and as they entered town they agreed to +believe that he might possibly mean somebody else--at least that he +might at least mean nobody but Tom, since only Tom had testified. + +Very, very small comfort it was to Tom to be alone in danger! Company +would be a palpable improvement, he thought. + + + +CHAPTER XXVII + +THE adventure of the day mightily tormented Tom's dreams that night. +Four times he had his hands on that rich treasure and four times it +wasted to nothingness in his fingers as sleep forsook him and +wakefulness brought back the hard reality of his misfortune. As he lay +in the early morning recalling the incidents of his great adventure, he +noticed that they seemed curiously subdued and far away--somewhat as if +they had happened in another world, or in a time long gone by. Then it +occurred to him that the great adventure itself must be a dream! There +was one very strong argument in favor of this idea--namely, that the +quantity of coin he had seen was too vast to be real. He had never seen +as much as fifty dollars in one mass before, and he was like all boys +of his age and station in life, in that he imagined that all references +to "hundreds" and "thousands" were mere fanciful forms of speech, and +that no such sums really existed in the world. He never had supposed +for a moment that so large a sum as a hundred dollars was to be found +in actual money in any one's possession. If his notions of hidden +treasure had been analyzed, they would have been found to consist of a +handful of real dimes and a bushel of vague, splendid, ungraspable +dollars. + +But the incidents of his adventure grew sensibly sharper and clearer +under the attrition of thinking them over, and so he presently found +himself leaning to the impression that the thing might not have been a +dream, after all. This uncertainty must be swept away. He would snatch +a hurried breakfast and go and find Huck. Huck was sitting on the +gunwale of a flatboat, listlessly dangling his feet in the water and +looking very melancholy. Tom concluded to let Huck lead up to the +subject. If he did not do it, then the adventure would be proved to +have been only a dream. + +"Hello, Huck!" + +"Hello, yourself." + +Silence, for a minute. + +"Tom, if we'd 'a' left the blame tools at the dead tree, we'd 'a' got +the money. Oh, ain't it awful!" + +"'Tain't a dream, then, 'tain't a dream! Somehow I most wish it was. +Dog'd if I don't, Huck." + +"What ain't a dream?" + +"Oh, that thing yesterday. I been half thinking it was." + +"Dream! If them stairs hadn't broke down you'd 'a' seen how much dream +it was! I've had dreams enough all night--with that patch-eyed Spanish +devil going for me all through 'em--rot him!" + +"No, not rot him. FIND him! Track the money!" + +"Tom, we'll never find him. A feller don't have only one chance for +such a pile--and that one's lost. I'd feel mighty shaky if I was to see +him, anyway." + +"Well, so'd I; but I'd like to see him, anyway--and track him out--to +his Number Two." + +"Number Two--yes, that's it. I been thinking 'bout that. But I can't +make nothing out of it. What do you reckon it is?" + +"I dono. It's too deep. Say, Huck--maybe it's the number of a house!" + +"Goody!... No, Tom, that ain't it. If it is, it ain't in this +one-horse town. They ain't no numbers here." + +"Well, that's so. Lemme think a minute. Here--it's the number of a +room--in a tavern, you know!" + +"Oh, that's the trick! They ain't only two taverns. We can find out +quick." + +"You stay here, Huck, till I come." + +Tom was off at once. He did not care to have Huck's company in public +places. He was gone half an hour. He found that in the best tavern, No. +2 had long been occupied by a young lawyer, and was still so occupied. +In the less ostentatious house, No. 2 was a mystery. The +tavern-keeper's young son said it was kept locked all the time, and he +never saw anybody go into it or come out of it except at night; he did +not know any particular reason for this state of things; had had some +little curiosity, but it was rather feeble; had made the most of the +mystery by entertaining himself with the idea that that room was +"ha'nted"; had noticed that there was a light in there the night before. + +"That's what I've found out, Huck. I reckon that's the very No. 2 +we're after." + +"I reckon it is, Tom. Now what you going to do?" + +"Lemme think." + +Tom thought a long time. Then he said: + +"I'll tell you. The back door of that No. 2 is the door that comes out +into that little close alley between the tavern and the old rattle trap +of a brick store. Now you get hold of all the door-keys you can find, +and I'll nip all of auntie's, and the first dark night we'll go there +and try 'em. And mind you, keep a lookout for Injun Joe, because he +said he was going to drop into town and spy around once more for a +chance to get his revenge. If you see him, you just follow him; and if +he don't go to that No. 2, that ain't the place." + +"Lordy, I don't want to foller him by myself!" + +"Why, it'll be night, sure. He mightn't ever see you--and if he did, +maybe he'd never think anything." + +"Well, if it's pretty dark I reckon I'll track him. I dono--I dono. +I'll try." + +"You bet I'll follow him, if it's dark, Huck. Why, he might 'a' found +out he couldn't get his revenge, and be going right after that money." + +"It's so, Tom, it's so. I'll foller him; I will, by jingoes!" + +"Now you're TALKING! Don't you ever weaken, Huck, and I won't." + + + +CHAPTER XXVIII + +THAT night Tom and Huck were ready for their adventure. They hung +about the neighborhood of the tavern until after nine, one watching the +alley at a distance and the other the tavern door. Nobody entered the +alley or left it; nobody resembling the Spaniard entered or left the +tavern door. The night promised to be a fair one; so Tom went home with +the understanding that if a considerable degree of darkness came on, +Huck was to come and "maow," whereupon he would slip out and try the +keys. But the night remained clear, and Huck closed his watch and +retired to bed in an empty sugar hogshead about twelve. + +Tuesday the boys had the same ill luck. Also Wednesday. But Thursday +night promised better. Tom slipped out in good season with his aunt's +old tin lantern, and a large towel to blindfold it with. He hid the +lantern in Huck's sugar hogshead and the watch began. An hour before +midnight the tavern closed up and its lights (the only ones +thereabouts) were put out. No Spaniard had been seen. Nobody had +entered or left the alley. Everything was auspicious. The blackness of +darkness reigned, the perfect stillness was interrupted only by +occasional mutterings of distant thunder. + +Tom got his lantern, lit it in the hogshead, wrapped it closely in the +towel, and the two adventurers crept in the gloom toward the tavern. +Huck stood sentry and Tom felt his way into the alley. Then there was a +season of waiting anxiety that weighed upon Huck's spirits like a +mountain. He began to wish he could see a flash from the lantern--it +would frighten him, but it would at least tell him that Tom was alive +yet. It seemed hours since Tom had disappeared. Surely he must have +fainted; maybe he was dead; maybe his heart had burst under terror and +excitement. In his uneasiness Huck found himself drawing closer and +closer to the alley; fearing all sorts of dreadful things, and +momentarily expecting some catastrophe to happen that would take away +his breath. There was not much to take away, for he seemed only able to +inhale it by thimblefuls, and his heart would soon wear itself out, the +way it was beating. Suddenly there was a flash of light and Tom came +tearing by him: "Run!" said he; "run, for your life!" + +He needn't have repeated it; once was enough; Huck was making thirty +or forty miles an hour before the repetition was uttered. The boys +never stopped till they reached the shed of a deserted slaughter-house +at the lower end of the village. Just as they got within its shelter +the storm burst and the rain poured down. As soon as Tom got his breath +he said: + +"Huck, it was awful! I tried two of the keys, just as soft as I could; +but they seemed to make such a power of racket that I couldn't hardly +get my breath I was so scared. They wouldn't turn in the lock, either. +Well, without noticing what I was doing, I took hold of the knob, and +open comes the door! It warn't locked! I hopped in, and shook off the +towel, and, GREAT CAESAR'S GHOST!" + +"What!--what'd you see, Tom?" + +"Huck, I most stepped onto Injun Joe's hand!" + +"No!" + +"Yes! He was lying there, sound asleep on the floor, with his old +patch on his eye and his arms spread out." + +"Lordy, what did you do? Did he wake up?" + +"No, never budged. Drunk, I reckon. I just grabbed that towel and +started!" + +"I'd never 'a' thought of the towel, I bet!" + +"Well, I would. My aunt would make me mighty sick if I lost it." + +"Say, Tom, did you see that box?" + +"Huck, I didn't wait to look around. I didn't see the box, I didn't +see the cross. I didn't see anything but a bottle and a tin cup on the +floor by Injun Joe; yes, I saw two barrels and lots more bottles in the +room. Don't you see, now, what's the matter with that ha'nted room?" + +"How?" + +"Why, it's ha'nted with whiskey! Maybe ALL the Temperance Taverns have +got a ha'nted room, hey, Huck?" + +"Well, I reckon maybe that's so. Who'd 'a' thought such a thing? But +say, Tom, now's a mighty good time to get that box, if Injun Joe's +drunk." + +"It is, that! You try it!" + +Huck shuddered. + +"Well, no--I reckon not." + +"And I reckon not, Huck. Only one bottle alongside of Injun Joe ain't +enough. If there'd been three, he'd be drunk enough and I'd do it." + +There was a long pause for reflection, and then Tom said: + +"Lookyhere, Huck, less not try that thing any more till we know Injun +Joe's not in there. It's too scary. Now, if we watch every night, we'll +be dead sure to see him go out, some time or other, and then we'll +snatch that box quicker'n lightning." + +"Well, I'm agreed. I'll watch the whole night long, and I'll do it +every night, too, if you'll do the other part of the job." + +"All right, I will. All you got to do is to trot up Hooper Street a +block and maow--and if I'm asleep, you throw some gravel at the window +and that'll fetch me." + +"Agreed, and good as wheat!" + +"Now, Huck, the storm's over, and I'll go home. It'll begin to be +daylight in a couple of hours. You go back and watch that long, will +you?" + +"I said I would, Tom, and I will. I'll ha'nt that tavern every night +for a year! I'll sleep all day and I'll stand watch all night." + +"That's all right. Now, where you going to sleep?" + +"In Ben Rogers' hayloft. He lets me, and so does his pap's nigger man, +Uncle Jake. I tote water for Uncle Jake whenever he wants me to, and +any time I ask him he gives me a little something to eat if he can +spare it. That's a mighty good nigger, Tom. He likes me, becuz I don't +ever act as if I was above him. Sometime I've set right down and eat +WITH him. But you needn't tell that. A body's got to do things when +he's awful hungry he wouldn't want to do as a steady thing." + +"Well, if I don't want you in the daytime, I'll let you sleep. I won't +come bothering around. Any time you see something's up, in the night, +just skip right around and maow." + + + +CHAPTER XXIX + +THE first thing Tom heard on Friday morning was a glad piece of news +--Judge Thatcher's family had come back to town the night before. Both +Injun Joe and the treasure sunk into secondary importance for a moment, +and Becky took the chief place in the boy's interest. He saw her and +they had an exhausting good time playing "hi-spy" and "gully-keeper" +with a crowd of their school-mates. The day was completed and crowned +in a peculiarly satisfactory way: Becky teased her mother to appoint +the next day for the long-promised and long-delayed picnic, and she +consented. The child's delight was boundless; and Tom's not more +moderate. The invitations were sent out before sunset, and straightway +the young folks of the village were thrown into a fever of preparation +and pleasurable anticipation. Tom's excitement enabled him to keep +awake until a pretty late hour, and he had good hopes of hearing Huck's +"maow," and of having his treasure to astonish Becky and the picnickers +with, next day; but he was disappointed. No signal came that night. + +Morning came, eventually, and by ten or eleven o'clock a giddy and +rollicking company were gathered at Judge Thatcher's, and everything +was ready for a start. It was not the custom for elderly people to mar +the picnics with their presence. The children were considered safe +enough under the wings of a few young ladies of eighteen and a few +young gentlemen of twenty-three or thereabouts. The old steam ferryboat +was chartered for the occasion; presently the gay throng filed up the +main street laden with provision-baskets. Sid was sick and had to miss +the fun; Mary remained at home to entertain him. The last thing Mrs. +Thatcher said to Becky, was: + +"You'll not get back till late. Perhaps you'd better stay all night +with some of the girls that live near the ferry-landing, child." + +"Then I'll stay with Susy Harper, mamma." + +"Very well. And mind and behave yourself and don't be any trouble." + +Presently, as they tripped along, Tom said to Becky: + +"Say--I'll tell you what we'll do. 'Stead of going to Joe Harper's +we'll climb right up the hill and stop at the Widow Douglas'. She'll +have ice-cream! She has it most every day--dead loads of it. And she'll +be awful glad to have us." + +"Oh, that will be fun!" + +Then Becky reflected a moment and said: + +"But what will mamma say?" + +"How'll she ever know?" + +The girl turned the idea over in her mind, and said reluctantly: + +"I reckon it's wrong--but--" + +"But shucks! Your mother won't know, and so what's the harm? All she +wants is that you'll be safe; and I bet you she'd 'a' said go there if +she'd 'a' thought of it. I know she would!" + +The Widow Douglas' splendid hospitality was a tempting bait. It and +Tom's persuasions presently carried the day. So it was decided to say +nothing anybody about the night's programme. Presently it occurred to +Tom that maybe Huck might come this very night and give the signal. The +thought took a deal of the spirit out of his anticipations. Still he +could not bear to give up the fun at Widow Douglas'. And why should he +give it up, he reasoned--the signal did not come the night before, so +why should it be any more likely to come to-night? The sure fun of the +evening outweighed the uncertain treasure; and, boy-like, he determined +to yield to the stronger inclination and not allow himself to think of +the box of money another time that day. + +Three miles below town the ferryboat stopped at the mouth of a woody +hollow and tied up. The crowd swarmed ashore and soon the forest +distances and craggy heights echoed far and near with shoutings and +laughter. All the different ways of getting hot and tired were gone +through with, and by-and-by the rovers straggled back to camp fortified +with responsible appetites, and then the destruction of the good things +began. After the feast there was a refreshing season of rest and chat +in the shade of spreading oaks. By-and-by somebody shouted: + +"Who's ready for the cave?" + +Everybody was. Bundles of candles were procured, and straightway there +was a general scamper up the hill. The mouth of the cave was up the +hillside--an opening shaped like a letter A. Its massive oaken door +stood unbarred. Within was a small chamber, chilly as an ice-house, and +walled by Nature with solid limestone that was dewy with a cold sweat. +It was romantic and mysterious to stand here in the deep gloom and look +out upon the green valley shining in the sun. But the impressiveness of +the situation quickly wore off, and the romping began again. The moment +a candle was lighted there was a general rush upon the owner of it; a +struggle and a gallant defence followed, but the candle was soon +knocked down or blown out, and then there was a glad clamor of laughter +and a new chase. But all things have an end. By-and-by the procession +went filing down the steep descent of the main avenue, the flickering +rank of lights dimly revealing the lofty walls of rock almost to their +point of junction sixty feet overhead. This main avenue was not more +than eight or ten feet wide. Every few steps other lofty and still +narrower crevices branched from it on either hand--for McDougal's cave +was but a vast labyrinth of crooked aisles that ran into each other and +out again and led nowhere. It was said that one might wander days and +nights together through its intricate tangle of rifts and chasms, and +never find the end of the cave; and that he might go down, and down, +and still down, into the earth, and it was just the same--labyrinth +under labyrinth, and no end to any of them. No man "knew" the cave. +That was an impossible thing. Most of the young men knew a portion of +it, and it was not customary to venture much beyond this known portion. +Tom Sawyer knew as much of the cave as any one. + +The procession moved along the main avenue some three-quarters of a +mile, and then groups and couples began to slip aside into branch +avenues, fly along the dismal corridors, and take each other by +surprise at points where the corridors joined again. Parties were able +to elude each other for the space of half an hour without going beyond +the "known" ground. + +By-and-by, one group after another came straggling back to the mouth +of the cave, panting, hilarious, smeared from head to foot with tallow +drippings, daubed with clay, and entirely delighted with the success of +the day. Then they were astonished to find that they had been taking no +note of time and that night was about at hand. The clanging bell had +been calling for half an hour. However, this sort of close to the day's +adventures was romantic and therefore satisfactory. When the ferryboat +with her wild freight pushed into the stream, nobody cared sixpence for +the wasted time but the captain of the craft. + +Huck was already upon his watch when the ferryboat's lights went +glinting past the wharf. He heard no noise on board, for the young +people were as subdued and still as people usually are who are nearly +tired to death. He wondered what boat it was, and why she did not stop +at the wharf--and then he dropped her out of his mind and put his +attention upon his business. The night was growing cloudy and dark. Ten +o'clock came, and the noise of vehicles ceased, scattered lights began +to wink out, all straggling foot-passengers disappeared, the village +betook itself to its slumbers and left the small watcher alone with the +silence and the ghosts. Eleven o'clock came, and the tavern lights were +put out; darkness everywhere, now. Huck waited what seemed a weary long +time, but nothing happened. His faith was weakening. Was there any use? +Was there really any use? Why not give it up and turn in? + +A noise fell upon his ear. He was all attention in an instant. The +alley door closed softly. He sprang to the corner of the brick store. +The next moment two men brushed by him, and one seemed to have +something under his arm. It must be that box! So they were going to +remove the treasure. Why call Tom now? It would be absurd--the men +would get away with the box and never be found again. No, he would +stick to their wake and follow them; he would trust to the darkness for +security from discovery. So communing with himself, Huck stepped out +and glided along behind the men, cat-like, with bare feet, allowing +them to keep just far enough ahead not to be invisible. + +They moved up the river street three blocks, then turned to the left +up a cross-street. They went straight ahead, then, until they came to +the path that led up Cardiff Hill; this they took. They passed by the +old Welshman's house, half-way up the hill, without hesitating, and +still climbed upward. Good, thought Huck, they will bury it in the old +quarry. But they never stopped at the quarry. They passed on, up the +summit. They plunged into the narrow path between the tall sumach +bushes, and were at once hidden in the gloom. Huck closed up and +shortened his distance, now, for they would never be able to see him. +He trotted along awhile; then slackened his pace, fearing he was +gaining too fast; moved on a piece, then stopped altogether; listened; +no sound; none, save that he seemed to hear the beating of his own +heart. The hooting of an owl came over the hill--ominous sound! But no +footsteps. Heavens, was everything lost! He was about to spring with +winged feet, when a man cleared his throat not four feet from him! +Huck's heart shot into his throat, but he swallowed it again; and then +he stood there shaking as if a dozen agues had taken charge of him at +once, and so weak that he thought he must surely fall to the ground. He +knew where he was. He knew he was within five steps of the stile +leading into Widow Douglas' grounds. Very well, he thought, let them +bury it there; it won't be hard to find. + +Now there was a voice--a very low voice--Injun Joe's: + +"Damn her, maybe she's got company--there's lights, late as it is." + +"I can't see any." + +This was that stranger's voice--the stranger of the haunted house. A +deadly chill went to Huck's heart--this, then, was the "revenge" job! +His thought was, to fly. Then he remembered that the Widow Douglas had +been kind to him more than once, and maybe these men were going to +murder her. He wished he dared venture to warn her; but he knew he +didn't dare--they might come and catch him. He thought all this and +more in the moment that elapsed between the stranger's remark and Injun +Joe's next--which was-- + +"Because the bush is in your way. Now--this way--now you see, don't +you?" + +"Yes. Well, there IS company there, I reckon. Better give it up." + +"Give it up, and I just leaving this country forever! Give it up and +maybe never have another chance. I tell you again, as I've told you +before, I don't care for her swag--you may have it. But her husband was +rough on me--many times he was rough on me--and mainly he was the +justice of the peace that jugged me for a vagrant. And that ain't all. +It ain't a millionth part of it! He had me HORSEWHIPPED!--horsewhipped +in front of the jail, like a nigger!--with all the town looking on! +HORSEWHIPPED!--do you understand? He took advantage of me and died. But +I'll take it out of HER." + +"Oh, don't kill her! Don't do that!" + +"Kill? Who said anything about killing? I would kill HIM if he was +here; but not her. When you want to get revenge on a woman you don't +kill her--bosh! you go for her looks. You slit her nostrils--you notch +her ears like a sow!" + +"By God, that's--" + +"Keep your opinion to yourself! It will be safest for you. I'll tie +her to the bed. If she bleeds to death, is that my fault? I'll not cry, +if she does. My friend, you'll help me in this thing--for MY sake +--that's why you're here--I mightn't be able alone. If you flinch, I'll +kill you. Do you understand that? And if I have to kill you, I'll kill +her--and then I reckon nobody'll ever know much about who done this +business." + +"Well, if it's got to be done, let's get at it. The quicker the +better--I'm all in a shiver." + +"Do it NOW? And company there? Look here--I'll get suspicious of you, +first thing you know. No--we'll wait till the lights are out--there's +no hurry." + +Huck felt that a silence was going to ensue--a thing still more awful +than any amount of murderous talk; so he held his breath and stepped +gingerly back; planted his foot carefully and firmly, after balancing, +one-legged, in a precarious way and almost toppling over, first on one +side and then on the other. He took another step back, with the same +elaboration and the same risks; then another and another, and--a twig +snapped under his foot! His breath stopped and he listened. There was +no sound--the stillness was perfect. His gratitude was measureless. Now +he turned in his tracks, between the walls of sumach bushes--turned +himself as carefully as if he were a ship--and then stepped quickly but +cautiously along. When he emerged at the quarry he felt secure, and so +he picked up his nimble heels and flew. Down, down he sped, till he +reached the Welshman's. He banged at the door, and presently the heads +of the old man and his two stalwart sons were thrust from windows. + +"What's the row there? Who's banging? What do you want?" + +"Let me in--quick! I'll tell everything." + +"Why, who are you?" + +"Huckleberry Finn--quick, let me in!" + +"Huckleberry Finn, indeed! It ain't a name to open many doors, I +judge! But let him in, lads, and let's see what's the trouble." + +"Please don't ever tell I told you," were Huck's first words when he +got in. "Please don't--I'd be killed, sure--but the widow's been good +friends to me sometimes, and I want to tell--I WILL tell if you'll +promise you won't ever say it was me." + +"By George, he HAS got something to tell, or he wouldn't act so!" +exclaimed the old man; "out with it and nobody here'll ever tell, lad." + +Three minutes later the old man and his sons, well armed, were up the +hill, and just entering the sumach path on tiptoe, their weapons in +their hands. Huck accompanied them no further. He hid behind a great +bowlder and fell to listening. There was a lagging, anxious silence, +and then all of a sudden there was an explosion of firearms and a cry. + +Huck waited for no particulars. He sprang away and sped down the hill +as fast as his legs could carry him. + + + +CHAPTER XXX + +AS the earliest suspicion of dawn appeared on Sunday morning, Huck +came groping up the hill and rapped gently at the old Welshman's door. +The inmates were asleep, but it was a sleep that was set on a +hair-trigger, on account of the exciting episode of the night. A call +came from a window: + +"Who's there!" + +Huck's scared voice answered in a low tone: + +"Please let me in! It's only Huck Finn!" + +"It's a name that can open this door night or day, lad!--and welcome!" + +These were strange words to the vagabond boy's ears, and the +pleasantest he had ever heard. He could not recollect that the closing +word had ever been applied in his case before. The door was quickly +unlocked, and he entered. Huck was given a seat and the old man and his +brace of tall sons speedily dressed themselves. + +"Now, my boy, I hope you're good and hungry, because breakfast will be +ready as soon as the sun's up, and we'll have a piping hot one, too +--make yourself easy about that! I and the boys hoped you'd turn up and +stop here last night." + +"I was awful scared," said Huck, "and I run. I took out when the +pistols went off, and I didn't stop for three mile. I've come now becuz +I wanted to know about it, you know; and I come before daylight becuz I +didn't want to run across them devils, even if they was dead." + +"Well, poor chap, you do look as if you'd had a hard night of it--but +there's a bed here for you when you've had your breakfast. No, they +ain't dead, lad--we are sorry enough for that. You see we knew right +where to put our hands on them, by your description; so we crept along +on tiptoe till we got within fifteen feet of them--dark as a cellar +that sumach path was--and just then I found I was going to sneeze. It +was the meanest kind of luck! I tried to keep it back, but no use +--'twas bound to come, and it did come! I was in the lead with my pistol +raised, and when the sneeze started those scoundrels a-rustling to get +out of the path, I sung out, 'Fire boys!' and blazed away at the place +where the rustling was. So did the boys. But they were off in a jiffy, +those villains, and we after them, down through the woods. I judge we +never touched them. They fired a shot apiece as they started, but their +bullets whizzed by and didn't do us any harm. As soon as we lost the +sound of their feet we quit chasing, and went down and stirred up the +constables. They got a posse together, and went off to guard the river +bank, and as soon as it is light the sheriff and a gang are going to +beat up the woods. My boys will be with them presently. I wish we had +some sort of description of those rascals--'twould help a good deal. +But you couldn't see what they were like, in the dark, lad, I suppose?" + +"Oh yes; I saw them down-town and follered them." + +"Splendid! Describe them--describe them, my boy!" + +"One's the old deaf and dumb Spaniard that's ben around here once or +twice, and t'other's a mean-looking, ragged--" + +"That's enough, lad, we know the men! Happened on them in the woods +back of the widow's one day, and they slunk away. Off with you, boys, +and tell the sheriff--get your breakfast to-morrow morning!" + +The Welshman's sons departed at once. As they were leaving the room +Huck sprang up and exclaimed: + +"Oh, please don't tell ANYbody it was me that blowed on them! Oh, +please!" + +"All right if you say it, Huck, but you ought to have the credit of +what you did." + +"Oh no, no! Please don't tell!" + +When the young men were gone, the old Welshman said: + +"They won't tell--and I won't. But why don't you want it known?" + +Huck would not explain, further than to say that he already knew too +much about one of those men and would not have the man know that he +knew anything against him for the whole world--he would be killed for +knowing it, sure. + +The old man promised secrecy once more, and said: + +"How did you come to follow these fellows, lad? Were they looking +suspicious?" + +Huck was silent while he framed a duly cautious reply. Then he said: + +"Well, you see, I'm a kind of a hard lot,--least everybody says so, +and I don't see nothing agin it--and sometimes I can't sleep much, on +account of thinking about it and sort of trying to strike out a new way +of doing. That was the way of it last night. I couldn't sleep, and so I +come along up-street 'bout midnight, a-turning it all over, and when I +got to that old shackly brick store by the Temperance Tavern, I backed +up agin the wall to have another think. Well, just then along comes +these two chaps slipping along close by me, with something under their +arm, and I reckoned they'd stole it. One was a-smoking, and t'other one +wanted a light; so they stopped right before me and the cigars lit up +their faces and I see that the big one was the deaf and dumb Spaniard, +by his white whiskers and the patch on his eye, and t'other one was a +rusty, ragged-looking devil." + +"Could you see the rags by the light of the cigars?" + +This staggered Huck for a moment. Then he said: + +"Well, I don't know--but somehow it seems as if I did." + +"Then they went on, and you--" + +"Follered 'em--yes. That was it. I wanted to see what was up--they +sneaked along so. I dogged 'em to the widder's stile, and stood in the +dark and heard the ragged one beg for the widder, and the Spaniard +swear he'd spile her looks just as I told you and your two--" + +"What! The DEAF AND DUMB man said all that!" + +Huck had made another terrible mistake! He was trying his best to keep +the old man from getting the faintest hint of who the Spaniard might +be, and yet his tongue seemed determined to get him into trouble in +spite of all he could do. He made several efforts to creep out of his +scrape, but the old man's eye was upon him and he made blunder after +blunder. Presently the Welshman said: + +"My boy, don't be afraid of me. I wouldn't hurt a hair of your head +for all the world. No--I'd protect you--I'd protect you. This Spaniard +is not deaf and dumb; you've let that slip without intending it; you +can't cover that up now. You know something about that Spaniard that +you want to keep dark. Now trust me--tell me what it is, and trust me +--I won't betray you." + +Huck looked into the old man's honest eyes a moment, then bent over +and whispered in his ear: + +"'Tain't a Spaniard--it's Injun Joe!" + +The Welshman almost jumped out of his chair. In a moment he said: + +"It's all plain enough, now. When you talked about notching ears and +slitting noses I judged that that was your own embellishment, because +white men don't take that sort of revenge. But an Injun! That's a +different matter altogether." + +During breakfast the talk went on, and in the course of it the old man +said that the last thing which he and his sons had done, before going +to bed, was to get a lantern and examine the stile and its vicinity for +marks of blood. They found none, but captured a bulky bundle of-- + +"Of WHAT?" + +If the words had been lightning they could not have leaped with a more +stunning suddenness from Huck's blanched lips. His eyes were staring +wide, now, and his breath suspended--waiting for the answer. The +Welshman started--stared in return--three seconds--five seconds--ten +--then replied: + +"Of burglar's tools. Why, what's the MATTER with you?" + +Huck sank back, panting gently, but deeply, unutterably grateful. The +Welshman eyed him gravely, curiously--and presently said: + +"Yes, burglar's tools. That appears to relieve you a good deal. But +what did give you that turn? What were YOU expecting we'd found?" + +Huck was in a close place--the inquiring eye was upon him--he would +have given anything for material for a plausible answer--nothing +suggested itself--the inquiring eye was boring deeper and deeper--a +senseless reply offered--there was no time to weigh it, so at a venture +he uttered it--feebly: + +"Sunday-school books, maybe." + +Poor Huck was too distressed to smile, but the old man laughed loud +and joyously, shook up the details of his anatomy from head to foot, +and ended by saying that such a laugh was money in a-man's pocket, +because it cut down the doctor's bill like everything. Then he added: + +"Poor old chap, you're white and jaded--you ain't well a bit--no +wonder you're a little flighty and off your balance. But you'll come +out of it. Rest and sleep will fetch you out all right, I hope." + +Huck was irritated to think he had been such a goose and betrayed such +a suspicious excitement, for he had dropped the idea that the parcel +brought from the tavern was the treasure, as soon as he had heard the +talk at the widow's stile. He had only thought it was not the treasure, +however--he had not known that it wasn't--and so the suggestion of a +captured bundle was too much for his self-possession. But on the whole +he felt glad the little episode had happened, for now he knew beyond +all question that that bundle was not THE bundle, and so his mind was +at rest and exceedingly comfortable. In fact, everything seemed to be +drifting just in the right direction, now; the treasure must be still +in No. 2, the men would be captured and jailed that day, and he and Tom +could seize the gold that night without any trouble or any fear of +interruption. + +Just as breakfast was completed there was a knock at the door. Huck +jumped for a hiding-place, for he had no mind to be connected even +remotely with the late event. The Welshman admitted several ladies and +gentlemen, among them the Widow Douglas, and noticed that groups of +citizens were climbing up the hill--to stare at the stile. So the news +had spread. The Welshman had to tell the story of the night to the +visitors. The widow's gratitude for her preservation was outspoken. + +"Don't say a word about it, madam. There's another that you're more +beholden to than you are to me and my boys, maybe, but he don't allow +me to tell his name. We wouldn't have been there but for him." + +Of course this excited a curiosity so vast that it almost belittled +the main matter--but the Welshman allowed it to eat into the vitals of +his visitors, and through them be transmitted to the whole town, for he +refused to part with his secret. When all else had been learned, the +widow said: + +"I went to sleep reading in bed and slept straight through all that +noise. Why didn't you come and wake me?" + +"We judged it warn't worth while. Those fellows warn't likely to come +again--they hadn't any tools left to work with, and what was the use of +waking you up and scaring you to death? My three negro men stood guard +at your house all the rest of the night. They've just come back." + +More visitors came, and the story had to be told and retold for a +couple of hours more. + +There was no Sabbath-school during day-school vacation, but everybody +was early at church. The stirring event was well canvassed. News came +that not a sign of the two villains had been yet discovered. When the +sermon was finished, Judge Thatcher's wife dropped alongside of Mrs. +Harper as she moved down the aisle with the crowd and said: + +"Is my Becky going to sleep all day? I just expected she would be +tired to death." + +"Your Becky?" + +"Yes," with a startled look--"didn't she stay with you last night?" + +"Why, no." + +Mrs. Thatcher turned pale, and sank into a pew, just as Aunt Polly, +talking briskly with a friend, passed by. Aunt Polly said: + +"Good-morning, Mrs. Thatcher. Good-morning, Mrs. Harper. I've got a +boy that's turned up missing. I reckon my Tom stayed at your house last +night--one of you. And now he's afraid to come to church. I've got to +settle with him." + +Mrs. Thatcher shook her head feebly and turned paler than ever. + +"He didn't stay with us," said Mrs. Harper, beginning to look uneasy. +A marked anxiety came into Aunt Polly's face. + +"Joe Harper, have you seen my Tom this morning?" + +"No'm." + +"When did you see him last?" + +Joe tried to remember, but was not sure he could say. The people had +stopped moving out of church. Whispers passed along, and a boding +uneasiness took possession of every countenance. Children were +anxiously questioned, and young teachers. They all said they had not +noticed whether Tom and Becky were on board the ferryboat on the +homeward trip; it was dark; no one thought of inquiring if any one was +missing. One young man finally blurted out his fear that they were +still in the cave! Mrs. Thatcher swooned away. Aunt Polly fell to +crying and wringing her hands. + +The alarm swept from lip to lip, from group to group, from street to +street, and within five minutes the bells were wildly clanging and the +whole town was up! The Cardiff Hill episode sank into instant +insignificance, the burglars were forgotten, horses were saddled, +skiffs were manned, the ferryboat ordered out, and before the horror +was half an hour old, two hundred men were pouring down highroad and +river toward the cave. + +All the long afternoon the village seemed empty and dead. Many women +visited Aunt Polly and Mrs. Thatcher and tried to comfort them. They +cried with them, too, and that was still better than words. All the +tedious night the town waited for news; but when the morning dawned at +last, all the word that came was, "Send more candles--and send food." +Mrs. Thatcher was almost crazed; and Aunt Polly, also. Judge Thatcher +sent messages of hope and encouragement from the cave, but they +conveyed no real cheer. + +The old Welshman came home toward daylight, spattered with +candle-grease, smeared with clay, and almost worn out. He found Huck +still in the bed that had been provided for him, and delirious with +fever. The physicians were all at the cave, so the Widow Douglas came +and took charge of the patient. She said she would do her best by him, +because, whether he was good, bad, or indifferent, he was the Lord's, +and nothing that was the Lord's was a thing to be neglected. The +Welshman said Huck had good spots in him, and the widow said: + +"You can depend on it. That's the Lord's mark. He don't leave it off. +He never does. Puts it somewhere on every creature that comes from his +hands." + +Early in the forenoon parties of jaded men began to straggle into the +village, but the strongest of the citizens continued searching. All the +news that could be gained was that remotenesses of the cavern were +being ransacked that had never been visited before; that every corner +and crevice was going to be thoroughly searched; that wherever one +wandered through the maze of passages, lights were to be seen flitting +hither and thither in the distance, and shoutings and pistol-shots sent +their hollow reverberations to the ear down the sombre aisles. In one +place, far from the section usually traversed by tourists, the names +"BECKY & TOM" had been found traced upon the rocky wall with +candle-smoke, and near at hand a grease-soiled bit of ribbon. Mrs. +Thatcher recognized the ribbon and cried over it. She said it was the +last relic she should ever have of her child; and that no other memorial +of her could ever be so precious, because this one parted latest from +the living body before the awful death came. Some said that now and +then, in the cave, a far-away speck of light would glimmer, and then a +glorious shout would burst forth and a score of men go trooping down the +echoing aisle--and then a sickening disappointment always followed; the +children were not there; it was only a searcher's light. + +Three dreadful days and nights dragged their tedious hours along, and +the village sank into a hopeless stupor. No one had heart for anything. +The accidental discovery, just made, that the proprietor of the +Temperance Tavern kept liquor on his premises, scarcely fluttered the +public pulse, tremendous as the fact was. In a lucid interval, Huck +feebly led up to the subject of taverns, and finally asked--dimly +dreading the worst--if anything had been discovered at the Temperance +Tavern since he had been ill. + +"Yes," said the widow. + +Huck started up in bed, wild-eyed: + +"What? What was it?" + +"Liquor!--and the place has been shut up. Lie down, child--what a turn +you did give me!" + +"Only tell me just one thing--only just one--please! Was it Tom Sawyer +that found it?" + +The widow burst into tears. "Hush, hush, child, hush! I've told you +before, you must NOT talk. You are very, very sick!" + +Then nothing but liquor had been found; there would have been a great +powwow if it had been the gold. So the treasure was gone forever--gone +forever! But what could she be crying about? Curious that she should +cry. + +These thoughts worked their dim way through Huck's mind, and under the +weariness they gave him he fell asleep. The widow said to herself: + +"There--he's asleep, poor wreck. Tom Sawyer find it! Pity but somebody +could find Tom Sawyer! Ah, there ain't many left, now, that's got hope +enough, or strength enough, either, to go on searching." + + + +CHAPTER XXXI + +NOW to return to Tom and Becky's share in the picnic. They tripped +along the murky aisles with the rest of the company, visiting the +familiar wonders of the cave--wonders dubbed with rather +over-descriptive names, such as "The Drawing-Room," "The Cathedral," +"Aladdin's Palace," and so on. Presently the hide-and-seek frolicking +began, and Tom and Becky engaged in it with zeal until the exertion +began to grow a trifle wearisome; then they wandered down a sinuous +avenue holding their candles aloft and reading the tangled web-work of +names, dates, post-office addresses, and mottoes with which the rocky +walls had been frescoed (in candle-smoke). Still drifting along and +talking, they scarcely noticed that they were now in a part of the cave +whose walls were not frescoed. They smoked their own names under an +overhanging shelf and moved on. Presently they came to a place where a +little stream of water, trickling over a ledge and carrying a limestone +sediment with it, had, in the slow-dragging ages, formed a laced and +ruffled Niagara in gleaming and imperishable stone. Tom squeezed his +small body behind it in order to illuminate it for Becky's +gratification. He found that it curtained a sort of steep natural +stairway which was enclosed between narrow walls, and at once the +ambition to be a discoverer seized him. Becky responded to his call, +and they made a smoke-mark for future guidance, and started upon their +quest. They wound this way and that, far down into the secret depths of +the cave, made another mark, and branched off in search of novelties to +tell the upper world about. In one place they found a spacious cavern, +from whose ceiling depended a multitude of shining stalactites of the +length and circumference of a man's leg; they walked all about it, +wondering and admiring, and presently left it by one of the numerous +passages that opened into it. This shortly brought them to a bewitching +spring, whose basin was incrusted with a frostwork of glittering +crystals; it was in the midst of a cavern whose walls were supported by +many fantastic pillars which had been formed by the joining of great +stalactites and stalagmites together, the result of the ceaseless +water-drip of centuries. Under the roof vast knots of bats had packed +themselves together, thousands in a bunch; the lights disturbed the +creatures and they came flocking down by hundreds, squeaking and +darting furiously at the candles. Tom knew their ways and the danger of +this sort of conduct. He seized Becky's hand and hurried her into the +first corridor that offered; and none too soon, for a bat struck +Becky's light out with its wing while she was passing out of the +cavern. The bats chased the children a good distance; but the fugitives +plunged into every new passage that offered, and at last got rid of the +perilous things. Tom found a subterranean lake, shortly, which +stretched its dim length away until its shape was lost in the shadows. +He wanted to explore its borders, but concluded that it would be best +to sit down and rest awhile, first. Now, for the first time, the deep +stillness of the place laid a clammy hand upon the spirits of the +children. Becky said: + +"Why, I didn't notice, but it seems ever so long since I heard any of +the others." + +"Come to think, Becky, we are away down below them--and I don't know +how far away north, or south, or east, or whichever it is. We couldn't +hear them here." + +Becky grew apprehensive. + +"I wonder how long we've been down here, Tom? We better start back." + +"Yes, I reckon we better. P'raps we better." + +"Can you find the way, Tom? It's all a mixed-up crookedness to me." + +"I reckon I could find it--but then the bats. If they put our candles +out it will be an awful fix. Let's try some other way, so as not to go +through there." + +"Well. But I hope we won't get lost. It would be so awful!" and the +girl shuddered at the thought of the dreadful possibilities. + +They started through a corridor, and traversed it in silence a long +way, glancing at each new opening, to see if there was anything +familiar about the look of it; but they were all strange. Every time +Tom made an examination, Becky would watch his face for an encouraging +sign, and he would say cheerily: + +"Oh, it's all right. This ain't the one, but we'll come to it right +away!" + +But he felt less and less hopeful with each failure, and presently +began to turn off into diverging avenues at sheer random, in desperate +hope of finding the one that was wanted. He still said it was "all +right," but there was such a leaden dread at his heart that the words +had lost their ring and sounded just as if he had said, "All is lost!" +Becky clung to his side in an anguish of fear, and tried hard to keep +back the tears, but they would come. At last she said: + +"Oh, Tom, never mind the bats, let's go back that way! We seem to get +worse and worse off all the time." + +"Listen!" said he. + +Profound silence; silence so deep that even their breathings were +conspicuous in the hush. Tom shouted. The call went echoing down the +empty aisles and died out in the distance in a faint sound that +resembled a ripple of mocking laughter. + +"Oh, don't do it again, Tom, it is too horrid," said Becky. + +"It is horrid, but I better, Becky; they might hear us, you know," and +he shouted again. + +The "might" was even a chillier horror than the ghostly laughter, it +so confessed a perishing hope. The children stood still and listened; +but there was no result. Tom turned upon the back track at once, and +hurried his steps. It was but a little while before a certain +indecision in his manner revealed another fearful fact to Becky--he +could not find his way back! + +"Oh, Tom, you didn't make any marks!" + +"Becky, I was such a fool! Such a fool! I never thought we might want +to come back! No--I can't find the way. It's all mixed up." + +"Tom, Tom, we're lost! we're lost! We never can get out of this awful +place! Oh, why DID we ever leave the others!" + +She sank to the ground and burst into such a frenzy of crying that Tom +was appalled with the idea that she might die, or lose her reason. He +sat down by her and put his arms around her; she buried her face in his +bosom, she clung to him, she poured out her terrors, her unavailing +regrets, and the far echoes turned them all to jeering laughter. Tom +begged her to pluck up hope again, and she said she could not. He fell +to blaming and abusing himself for getting her into this miserable +situation; this had a better effect. She said she would try to hope +again, she would get up and follow wherever he might lead if only he +would not talk like that any more. For he was no more to blame than +she, she said. + +So they moved on again--aimlessly--simply at random--all they could do +was to move, keep moving. For a little while, hope made a show of +reviving--not with any reason to back it, but only because it is its +nature to revive when the spring has not been taken out of it by age +and familiarity with failure. + +By-and-by Tom took Becky's candle and blew it out. This economy meant +so much! Words were not needed. Becky understood, and her hope died +again. She knew that Tom had a whole candle and three or four pieces in +his pockets--yet he must economize. + +By-and-by, fatigue began to assert its claims; the children tried to +pay attention, for it was dreadful to think of sitting down when time +was grown to be so precious, moving, in some direction, in any +direction, was at least progress and might bear fruit; but to sit down +was to invite death and shorten its pursuit. + +At last Becky's frail limbs refused to carry her farther. She sat +down. Tom rested with her, and they talked of home, and the friends +there, and the comfortable beds and, above all, the light! Becky cried, +and Tom tried to think of some way of comforting her, but all his +encouragements were grown threadbare with use, and sounded like +sarcasms. Fatigue bore so heavily upon Becky that she drowsed off to +sleep. Tom was grateful. He sat looking into her drawn face and saw it +grow smooth and natural under the influence of pleasant dreams; and +by-and-by a smile dawned and rested there. The peaceful face reflected +somewhat of peace and healing into his own spirit, and his thoughts +wandered away to bygone times and dreamy memories. While he was deep in +his musings, Becky woke up with a breezy little laugh--but it was +stricken dead upon her lips, and a groan followed it. + +"Oh, how COULD I sleep! I wish I never, never had waked! No! No, I +don't, Tom! Don't look so! I won't say it again." + +"I'm glad you've slept, Becky; you'll feel rested, now, and we'll find +the way out." + +"We can try, Tom; but I've seen such a beautiful country in my dream. +I reckon we are going there." + +"Maybe not, maybe not. Cheer up, Becky, and let's go on trying." + +They rose up and wandered along, hand in hand and hopeless. They tried +to estimate how long they had been in the cave, but all they knew was +that it seemed days and weeks, and yet it was plain that this could not +be, for their candles were not gone yet. A long time after this--they +could not tell how long--Tom said they must go softly and listen for +dripping water--they must find a spring. They found one presently, and +Tom said it was time to rest again. Both were cruelly tired, yet Becky +said she thought she could go a little farther. She was surprised to +hear Tom dissent. She could not understand it. They sat down, and Tom +fastened his candle to the wall in front of them with some clay. +Thought was soon busy; nothing was said for some time. Then Becky broke +the silence: + +"Tom, I am so hungry!" + +Tom took something out of his pocket. + +"Do you remember this?" said he. + +Becky almost smiled. + +"It's our wedding-cake, Tom." + +"Yes--I wish it was as big as a barrel, for it's all we've got." + +"I saved it from the picnic for us to dream on, Tom, the way grown-up +people do with wedding-cake--but it'll be our--" + +She dropped the sentence where it was. Tom divided the cake and Becky +ate with good appetite, while Tom nibbled at his moiety. There was +abundance of cold water to finish the feast with. By-and-by Becky +suggested that they move on again. Tom was silent a moment. Then he +said: + +"Becky, can you bear it if I tell you something?" + +Becky's face paled, but she thought she could. + +"Well, then, Becky, we must stay here, where there's water to drink. +That little piece is our last candle!" + +Becky gave loose to tears and wailings. Tom did what he could to +comfort her, but with little effect. At length Becky said: + +"Tom!" + +"Well, Becky?" + +"They'll miss us and hunt for us!" + +"Yes, they will! Certainly they will!" + +"Maybe they're hunting for us now, Tom." + +"Why, I reckon maybe they are. I hope they are." + +"When would they miss us, Tom?" + +"When they get back to the boat, I reckon." + +"Tom, it might be dark then--would they notice we hadn't come?" + +"I don't know. But anyway, your mother would miss you as soon as they +got home." + +A frightened look in Becky's face brought Tom to his senses and he saw +that he had made a blunder. Becky was not to have gone home that night! +The children became silent and thoughtful. In a moment a new burst of +grief from Becky showed Tom that the thing in his mind had struck hers +also--that the Sabbath morning might be half spent before Mrs. Thatcher +discovered that Becky was not at Mrs. Harper's. + +The children fastened their eyes upon their bit of candle and watched +it melt slowly and pitilessly away; saw the half inch of wick stand +alone at last; saw the feeble flame rise and fall, climb the thin +column of smoke, linger at its top a moment, and then--the horror of +utter darkness reigned! + +How long afterward it was that Becky came to a slow consciousness that +she was crying in Tom's arms, neither could tell. All that they knew +was, that after what seemed a mighty stretch of time, both awoke out of +a dead stupor of sleep and resumed their miseries once more. Tom said +it might be Sunday, now--maybe Monday. He tried to get Becky to talk, +but her sorrows were too oppressive, all her hopes were gone. Tom said +that they must have been missed long ago, and no doubt the search was +going on. He would shout and maybe some one would come. He tried it; +but in the darkness the distant echoes sounded so hideously that he +tried it no more. + +The hours wasted away, and hunger came to torment the captives again. +A portion of Tom's half of the cake was left; they divided and ate it. +But they seemed hungrier than before. The poor morsel of food only +whetted desire. + +By-and-by Tom said: + +"SH! Did you hear that?" + +Both held their breath and listened. There was a sound like the +faintest, far-off shout. Instantly Tom answered it, and leading Becky +by the hand, started groping down the corridor in its direction. +Presently he listened again; again the sound was heard, and apparently +a little nearer. + +"It's them!" said Tom; "they're coming! Come along, Becky--we're all +right now!" + +The joy of the prisoners was almost overwhelming. Their speed was +slow, however, because pitfalls were somewhat common, and had to be +guarded against. They shortly came to one and had to stop. It might be +three feet deep, it might be a hundred--there was no passing it at any +rate. Tom got down on his breast and reached as far down as he could. +No bottom. They must stay there and wait until the searchers came. They +listened; evidently the distant shoutings were growing more distant! a +moment or two more and they had gone altogether. The heart-sinking +misery of it! Tom whooped until he was hoarse, but it was of no use. He +talked hopefully to Becky; but an age of anxious waiting passed and no +sounds came again. + +The children groped their way back to the spring. The weary time +dragged on; they slept again, and awoke famished and woe-stricken. Tom +believed it must be Tuesday by this time. + +Now an idea struck him. There were some side passages near at hand. It +would be better to explore some of these than bear the weight of the +heavy time in idleness. He took a kite-line from his pocket, tied it to +a projection, and he and Becky started, Tom in the lead, unwinding the +line as he groped along. At the end of twenty steps the corridor ended +in a "jumping-off place." Tom got down on his knees and felt below, and +then as far around the corner as he could reach with his hands +conveniently; he made an effort to stretch yet a little farther to the +right, and at that moment, not twenty yards away, a human hand, holding +a candle, appeared from behind a rock! Tom lifted up a glorious shout, +and instantly that hand was followed by the body it belonged to--Injun +Joe's! Tom was paralyzed; he could not move. He was vastly gratified +the next moment, to see the "Spaniard" take to his heels and get +himself out of sight. Tom wondered that Joe had not recognized his +voice and come over and killed him for testifying in court. But the +echoes must have disguised the voice. Without doubt, that was it, he +reasoned. Tom's fright weakened every muscle in his body. He said to +himself that if he had strength enough to get back to the spring he +would stay there, and nothing should tempt him to run the risk of +meeting Injun Joe again. He was careful to keep from Becky what it was +he had seen. He told her he had only shouted "for luck." + +But hunger and wretchedness rise superior to fears in the long run. +Another tedious wait at the spring and another long sleep brought +changes. The children awoke tortured with a raging hunger. Tom believed +that it must be Wednesday or Thursday or even Friday or Saturday, now, +and that the search had been given over. He proposed to explore another +passage. He felt willing to risk Injun Joe and all other terrors. But +Becky was very weak. She had sunk into a dreary apathy and would not be +roused. She said she would wait, now, where she was, and die--it would +not be long. She told Tom to go with the kite-line and explore if he +chose; but she implored him to come back every little while and speak +to her; and she made him promise that when the awful time came, he +would stay by her and hold her hand until all was over. + +Tom kissed her, with a choking sensation in his throat, and made a +show of being confident of finding the searchers or an escape from the +cave; then he took the kite-line in his hand and went groping down one +of the passages on his hands and knees, distressed with hunger and sick +with bodings of coming doom. + + + +CHAPTER XXXII + +TUESDAY afternoon came, and waned to the twilight. The village of St. +Petersburg still mourned. The lost children had not been found. Public +prayers had been offered up for them, and many and many a private +prayer that had the petitioner's whole heart in it; but still no good +news came from the cave. The majority of the searchers had given up the +quest and gone back to their daily avocations, saying that it was plain +the children could never be found. Mrs. Thatcher was very ill, and a +great part of the time delirious. People said it was heartbreaking to +hear her call her child, and raise her head and listen a whole minute +at a time, then lay it wearily down again with a moan. Aunt Polly had +drooped into a settled melancholy, and her gray hair had grown almost +white. The village went to its rest on Tuesday night, sad and forlorn. + +Away in the middle of the night a wild peal burst from the village +bells, and in a moment the streets were swarming with frantic half-clad +people, who shouted, "Turn out! turn out! they're found! they're +found!" Tin pans and horns were added to the din, the population massed +itself and moved toward the river, met the children coming in an open +carriage drawn by shouting citizens, thronged around it, joined its +homeward march, and swept magnificently up the main street roaring +huzzah after huzzah! + +The village was illuminated; nobody went to bed again; it was the +greatest night the little town had ever seen. During the first half-hour +a procession of villagers filed through Judge Thatcher's house, seized +the saved ones and kissed them, squeezed Mrs. Thatcher's hand, tried to +speak but couldn't--and drifted out raining tears all over the place. + +Aunt Polly's happiness was complete, and Mrs. Thatcher's nearly so. It +would be complete, however, as soon as the messenger dispatched with +the great news to the cave should get the word to her husband. Tom lay +upon a sofa with an eager auditory about him and told the history of +the wonderful adventure, putting in many striking additions to adorn it +withal; and closed with a description of how he left Becky and went on +an exploring expedition; how he followed two avenues as far as his +kite-line would reach; how he followed a third to the fullest stretch of +the kite-line, and was about to turn back when he glimpsed a far-off +speck that looked like daylight; dropped the line and groped toward it, +pushed his head and shoulders through a small hole, and saw the broad +Mississippi rolling by! And if it had only happened to be night he would +not have seen that speck of daylight and would not have explored that +passage any more! He told how he went back for Becky and broke the good +news and she told him not to fret her with such stuff, for she was +tired, and knew she was going to die, and wanted to. He described how he +labored with her and convinced her; and how she almost died for joy when +she had groped to where she actually saw the blue speck of daylight; how +he pushed his way out at the hole and then helped her out; how they sat +there and cried for gladness; how some men came along in a skiff and Tom +hailed them and told them their situation and their famished condition; +how the men didn't believe the wild tale at first, "because," said they, +"you are five miles down the river below the valley the cave is in" +--then took them aboard, rowed to a house, gave them supper, made them +rest till two or three hours after dark and then brought them home. + +Before day-dawn, Judge Thatcher and the handful of searchers with him +were tracked out, in the cave, by the twine clews they had strung +behind them, and informed of the great news. + +Three days and nights of toil and hunger in the cave were not to be +shaken off at once, as Tom and Becky soon discovered. They were +bedridden all of Wednesday and Thursday, and seemed to grow more and +more tired and worn, all the time. Tom got about, a little, on +Thursday, was down-town Friday, and nearly as whole as ever Saturday; +but Becky did not leave her room until Sunday, and then she looked as +if she had passed through a wasting illness. + +Tom learned of Huck's sickness and went to see him on Friday, but +could not be admitted to the bedroom; neither could he on Saturday or +Sunday. He was admitted daily after that, but was warned to keep still +about his adventure and introduce no exciting topic. The Widow Douglas +stayed by to see that he obeyed. At home Tom learned of the Cardiff +Hill event; also that the "ragged man's" body had eventually been found +in the river near the ferry-landing; he had been drowned while trying +to escape, perhaps. + +About a fortnight after Tom's rescue from the cave, he started off to +visit Huck, who had grown plenty strong enough, now, to hear exciting +talk, and Tom had some that would interest him, he thought. Judge +Thatcher's house was on Tom's way, and he stopped to see Becky. The +Judge and some friends set Tom to talking, and some one asked him +ironically if he wouldn't like to go to the cave again. Tom said he +thought he wouldn't mind it. The Judge said: + +"Well, there are others just like you, Tom, I've not the least doubt. +But we have taken care of that. Nobody will get lost in that cave any +more." + +"Why?" + +"Because I had its big door sheathed with boiler iron two weeks ago, +and triple-locked--and I've got the keys." + +Tom turned as white as a sheet. + +"What's the matter, boy! Here, run, somebody! Fetch a glass of water!" + +The water was brought and thrown into Tom's face. + +"Ah, now you're all right. What was the matter with you, Tom?" + +"Oh, Judge, Injun Joe's in the cave!" + + + +CHAPTER XXXIII + +WITHIN a few minutes the news had spread, and a dozen skiff-loads of +men were on their way to McDougal's cave, and the ferryboat, well +filled with passengers, soon followed. Tom Sawyer was in the skiff that +bore Judge Thatcher. + +When the cave door was unlocked, a sorrowful sight presented itself in +the dim twilight of the place. Injun Joe lay stretched upon the ground, +dead, with his face close to the crack of the door, as if his longing +eyes had been fixed, to the latest moment, upon the light and the cheer +of the free world outside. Tom was touched, for he knew by his own +experience how this wretch had suffered. His pity was moved, but +nevertheless he felt an abounding sense of relief and security, now, +which revealed to him in a degree which he had not fully appreciated +before how vast a weight of dread had been lying upon him since the day +he lifted his voice against this bloody-minded outcast. + +Injun Joe's bowie-knife lay close by, its blade broken in two. The +great foundation-beam of the door had been chipped and hacked through, +with tedious labor; useless labor, too, it was, for the native rock +formed a sill outside it, and upon that stubborn material the knife had +wrought no effect; the only damage done was to the knife itself. But if +there had been no stony obstruction there the labor would have been +useless still, for if the beam had been wholly cut away Injun Joe could +not have squeezed his body under the door, and he knew it. So he had +only hacked that place in order to be doing something--in order to pass +the weary time--in order to employ his tortured faculties. Ordinarily +one could find half a dozen bits of candle stuck around in the crevices +of this vestibule, left there by tourists; but there were none now. The +prisoner had searched them out and eaten them. He had also contrived to +catch a few bats, and these, also, he had eaten, leaving only their +claws. The poor unfortunate had starved to death. In one place, near at +hand, a stalagmite had been slowly growing up from the ground for ages, +builded by the water-drip from a stalactite overhead. The captive had +broken off the stalagmite, and upon the stump had placed a stone, +wherein he had scooped a shallow hollow to catch the precious drop +that fell once in every three minutes with the dreary regularity of a +clock-tick--a dessertspoonful once in four and twenty hours. That drop +was falling when the Pyramids were new; when Troy fell; when the +foundations of Rome were laid; when Christ was crucified; when the +Conqueror created the British empire; when Columbus sailed; when the +massacre at Lexington was "news." It is falling now; it will still be +falling when all these things shall have sunk down the afternoon of +history, and the twilight of tradition, and been swallowed up in the +thick night of oblivion. Has everything a purpose and a mission? Did +this drop fall patiently during five thousand years to be ready for +this flitting human insect's need? and has it another important object +to accomplish ten thousand years to come? No matter. It is many and +many a year since the hapless half-breed scooped out the stone to catch +the priceless drops, but to this day the tourist stares longest at that +pathetic stone and that slow-dropping water when he comes to see the +wonders of McDougal's cave. Injun Joe's cup stands first in the list of +the cavern's marvels; even "Aladdin's Palace" cannot rival it. + +Injun Joe was buried near the mouth of the cave; and people flocked +there in boats and wagons from the towns and from all the farms and +hamlets for seven miles around; they brought their children, and all +sorts of provisions, and confessed that they had had almost as +satisfactory a time at the funeral as they could have had at the +hanging. + +This funeral stopped the further growth of one thing--the petition to +the governor for Injun Joe's pardon. The petition had been largely +signed; many tearful and eloquent meetings had been held, and a +committee of sappy women been appointed to go in deep mourning and wail +around the governor, and implore him to be a merciful ass and trample +his duty under foot. Injun Joe was believed to have killed five +citizens of the village, but what of that? If he had been Satan himself +there would have been plenty of weaklings ready to scribble their names +to a pardon-petition, and drip a tear on it from their permanently +impaired and leaky water-works. + +The morning after the funeral Tom took Huck to a private place to have +an important talk. Huck had learned all about Tom's adventure from the +Welshman and the Widow Douglas, by this time, but Tom said he reckoned +there was one thing they had not told him; that thing was what he +wanted to talk about now. Huck's face saddened. He said: + +"I know what it is. You got into No. 2 and never found anything but +whiskey. Nobody told me it was you; but I just knowed it must 'a' ben +you, soon as I heard 'bout that whiskey business; and I knowed you +hadn't got the money becuz you'd 'a' got at me some way or other and +told me even if you was mum to everybody else. Tom, something's always +told me we'd never get holt of that swag." + +"Why, Huck, I never told on that tavern-keeper. YOU know his tavern +was all right the Saturday I went to the picnic. Don't you remember you +was to watch there that night?" + +"Oh yes! Why, it seems 'bout a year ago. It was that very night that I +follered Injun Joe to the widder's." + +"YOU followed him?" + +"Yes--but you keep mum. I reckon Injun Joe's left friends behind him, +and I don't want 'em souring on me and doing me mean tricks. If it +hadn't ben for me he'd be down in Texas now, all right." + +Then Huck told his entire adventure in confidence to Tom, who had only +heard of the Welshman's part of it before. + +"Well," said Huck, presently, coming back to the main question, +"whoever nipped the whiskey in No. 2, nipped the money, too, I reckon +--anyways it's a goner for us, Tom." + +"Huck, that money wasn't ever in No. 2!" + +"What!" Huck searched his comrade's face keenly. "Tom, have you got on +the track of that money again?" + +"Huck, it's in the cave!" + +Huck's eyes blazed. + +"Say it again, Tom." + +"The money's in the cave!" + +"Tom--honest injun, now--is it fun, or earnest?" + +"Earnest, Huck--just as earnest as ever I was in my life. Will you go +in there with me and help get it out?" + +"I bet I will! I will if it's where we can blaze our way to it and not +get lost." + +"Huck, we can do that without the least little bit of trouble in the +world." + +"Good as wheat! What makes you think the money's--" + +"Huck, you just wait till we get in there. If we don't find it I'll +agree to give you my drum and every thing I've got in the world. I +will, by jings." + +"All right--it's a whiz. When do you say?" + +"Right now, if you say it. Are you strong enough?" + +"Is it far in the cave? I ben on my pins a little, three or four days, +now, but I can't walk more'n a mile, Tom--least I don't think I could." + +"It's about five mile into there the way anybody but me would go, +Huck, but there's a mighty short cut that they don't anybody but me +know about. Huck, I'll take you right to it in a skiff. I'll float the +skiff down there, and I'll pull it back again all by myself. You +needn't ever turn your hand over." + +"Less start right off, Tom." + +"All right. We want some bread and meat, and our pipes, and a little +bag or two, and two or three kite-strings, and some of these +new-fangled things they call lucifer matches. I tell you, many's +the time I wished I had some when I was in there before." + +A trifle after noon the boys borrowed a small skiff from a citizen who +was absent, and got under way at once. When they were several miles +below "Cave Hollow," Tom said: + +"Now you see this bluff here looks all alike all the way down from the +cave hollow--no houses, no wood-yards, bushes all alike. But do you see +that white place up yonder where there's been a landslide? Well, that's +one of my marks. We'll get ashore, now." + +They landed. + +"Now, Huck, where we're a-standing you could touch that hole I got out +of with a fishing-pole. See if you can find it." + +Huck searched all the place about, and found nothing. Tom proudly +marched into a thick clump of sumach bushes and said: + +"Here you are! Look at it, Huck; it's the snuggest hole in this +country. You just keep mum about it. All along I've been wanting to be +a robber, but I knew I'd got to have a thing like this, and where to +run across it was the bother. We've got it now, and we'll keep it +quiet, only we'll let Joe Harper and Ben Rogers in--because of course +there's got to be a Gang, or else there wouldn't be any style about it. +Tom Sawyer's Gang--it sounds splendid, don't it, Huck?" + +"Well, it just does, Tom. And who'll we rob?" + +"Oh, most anybody. Waylay people--that's mostly the way." + +"And kill them?" + +"No, not always. Hive them in the cave till they raise a ransom." + +"What's a ransom?" + +"Money. You make them raise all they can, off'n their friends; and +after you've kept them a year, if it ain't raised then you kill them. +That's the general way. Only you don't kill the women. You shut up the +women, but you don't kill them. They're always beautiful and rich, and +awfully scared. You take their watches and things, but you always take +your hat off and talk polite. They ain't anybody as polite as robbers +--you'll see that in any book. Well, the women get to loving you, and +after they've been in the cave a week or two weeks they stop crying and +after that you couldn't get them to leave. If you drove them out they'd +turn right around and come back. It's so in all the books." + +"Why, it's real bully, Tom. I believe it's better'n to be a pirate." + +"Yes, it's better in some ways, because it's close to home and +circuses and all that." + +By this time everything was ready and the boys entered the hole, Tom +in the lead. They toiled their way to the farther end of the tunnel, +then made their spliced kite-strings fast and moved on. A few steps +brought them to the spring, and Tom felt a shudder quiver all through +him. He showed Huck the fragment of candle-wick perched on a lump of +clay against the wall, and described how he and Becky had watched the +flame struggle and expire. + +The boys began to quiet down to whispers, now, for the stillness and +gloom of the place oppressed their spirits. They went on, and presently +entered and followed Tom's other corridor until they reached the +"jumping-off place." The candles revealed the fact that it was not +really a precipice, but only a steep clay hill twenty or thirty feet +high. Tom whispered: + +"Now I'll show you something, Huck." + +He held his candle aloft and said: + +"Look as far around the corner as you can. Do you see that? There--on +the big rock over yonder--done with candle-smoke." + +"Tom, it's a CROSS!" + +"NOW where's your Number Two? 'UNDER THE CROSS,' hey? Right yonder's +where I saw Injun Joe poke up his candle, Huck!" + +Huck stared at the mystic sign awhile, and then said with a shaky voice: + +"Tom, less git out of here!" + +"What! and leave the treasure?" + +"Yes--leave it. Injun Joe's ghost is round about there, certain." + +"No it ain't, Huck, no it ain't. It would ha'nt the place where he +died--away out at the mouth of the cave--five mile from here." + +"No, Tom, it wouldn't. It would hang round the money. I know the ways +of ghosts, and so do you." + +Tom began to fear that Huck was right. Misgivings gathered in his +mind. But presently an idea occurred to him-- + +"Lookyhere, Huck, what fools we're making of ourselves! Injun Joe's +ghost ain't a going to come around where there's a cross!" + +The point was well taken. It had its effect. + +"Tom, I didn't think of that. But that's so. It's luck for us, that +cross is. I reckon we'll climb down there and have a hunt for that box." + +Tom went first, cutting rude steps in the clay hill as he descended. +Huck followed. Four avenues opened out of the small cavern which the +great rock stood in. The boys examined three of them with no result. +They found a small recess in the one nearest the base of the rock, with +a pallet of blankets spread down in it; also an old suspender, some +bacon rind, and the well-gnawed bones of two or three fowls. But there +was no money-box. The lads searched and researched this place, but in +vain. Tom said: + +"He said UNDER the cross. Well, this comes nearest to being under the +cross. It can't be under the rock itself, because that sets solid on +the ground." + +They searched everywhere once more, and then sat down discouraged. +Huck could suggest nothing. By-and-by Tom said: + +"Lookyhere, Huck, there's footprints and some candle-grease on the +clay about one side of this rock, but not on the other sides. Now, +what's that for? I bet you the money IS under the rock. I'm going to +dig in the clay." + +"That ain't no bad notion, Tom!" said Huck with animation. + +Tom's "real Barlow" was out at once, and he had not dug four inches +before he struck wood. + +"Hey, Huck!--you hear that?" + +Huck began to dig and scratch now. Some boards were soon uncovered and +removed. They had concealed a natural chasm which led under the rock. +Tom got into this and held his candle as far under the rock as he +could, but said he could not see to the end of the rift. He proposed to +explore. He stooped and passed under; the narrow way descended +gradually. He followed its winding course, first to the right, then to +the left, Huck at his heels. Tom turned a short curve, by-and-by, and +exclaimed: + +"My goodness, Huck, lookyhere!" + +It was the treasure-box, sure enough, occupying a snug little cavern, +along with an empty powder-keg, a couple of guns in leather cases, two +or three pairs of old moccasins, a leather belt, and some other rubbish +well soaked with the water-drip. + +"Got it at last!" said Huck, ploughing among the tarnished coins with +his hand. "My, but we're rich, Tom!" + +"Huck, I always reckoned we'd get it. It's just too good to believe, +but we HAVE got it, sure! Say--let's not fool around here. Let's snake +it out. Lemme see if I can lift the box." + +It weighed about fifty pounds. Tom could lift it, after an awkward +fashion, but could not carry it conveniently. + +"I thought so," he said; "THEY carried it like it was heavy, that day +at the ha'nted house. I noticed that. I reckon I was right to think of +fetching the little bags along." + +The money was soon in the bags and the boys took it up to the cross +rock. + +"Now less fetch the guns and things," said Huck. + +"No, Huck--leave them there. They're just the tricks to have when we +go to robbing. We'll keep them there all the time, and we'll hold our +orgies there, too. It's an awful snug place for orgies." + +"What orgies?" + +"I dono. But robbers always have orgies, and of course we've got to +have them, too. Come along, Huck, we've been in here a long time. It's +getting late, I reckon. I'm hungry, too. We'll eat and smoke when we +get to the skiff." + +They presently emerged into the clump of sumach bushes, looked warily +out, found the coast clear, and were soon lunching and smoking in the +skiff. As the sun dipped toward the horizon they pushed out and got +under way. Tom skimmed up the shore through the long twilight, chatting +cheerily with Huck, and landed shortly after dark. + +"Now, Huck," said Tom, "we'll hide the money in the loft of the +widow's woodshed, and I'll come up in the morning and we'll count it +and divide, and then we'll hunt up a place out in the woods for it +where it will be safe. Just you lay quiet here and watch the stuff till +I run and hook Benny Taylor's little wagon; I won't be gone a minute." + +He disappeared, and presently returned with the wagon, put the two +small sacks into it, threw some old rags on top of them, and started +off, dragging his cargo behind him. When the boys reached the +Welshman's house, they stopped to rest. Just as they were about to move +on, the Welshman stepped out and said: + +"Hallo, who's that?" + +"Huck and Tom Sawyer." + +"Good! Come along with me, boys, you are keeping everybody waiting. +Here--hurry up, trot ahead--I'll haul the wagon for you. Why, it's not +as light as it might be. Got bricks in it?--or old metal?" + +"Old metal," said Tom. + +"I judged so; the boys in this town will take more trouble and fool +away more time hunting up six bits' worth of old iron to sell to the +foundry than they would to make twice the money at regular work. But +that's human nature--hurry along, hurry along!" + +The boys wanted to know what the hurry was about. + +"Never mind; you'll see, when we get to the Widow Douglas'." + +Huck said with some apprehension--for he was long used to being +falsely accused: + +"Mr. Jones, we haven't been doing nothing." + +The Welshman laughed. + +"Well, I don't know, Huck, my boy. I don't know about that. Ain't you +and the widow good friends?" + +"Yes. Well, she's ben good friends to me, anyway." + +"All right, then. What do you want to be afraid for?" + +This question was not entirely answered in Huck's slow mind before he +found himself pushed, along with Tom, into Mrs. Douglas' drawing-room. +Mr. Jones left the wagon near the door and followed. + +The place was grandly lighted, and everybody that was of any +consequence in the village was there. The Thatchers were there, the +Harpers, the Rogerses, Aunt Polly, Sid, Mary, the minister, the editor, +and a great many more, and all dressed in their best. The widow +received the boys as heartily as any one could well receive two such +looking beings. They were covered with clay and candle-grease. Aunt +Polly blushed crimson with humiliation, and frowned and shook her head +at Tom. Nobody suffered half as much as the two boys did, however. Mr. +Jones said: + +"Tom wasn't at home, yet, so I gave him up; but I stumbled on him and +Huck right at my door, and so I just brought them along in a hurry." + +"And you did just right," said the widow. "Come with me, boys." + +She took them to a bedchamber and said: + +"Now wash and dress yourselves. Here are two new suits of clothes +--shirts, socks, everything complete. They're Huck's--no, no thanks, +Huck--Mr. Jones bought one and I the other. But they'll fit both of you. +Get into them. We'll wait--come down when you are slicked up enough." + +Then she left. + + + +CHAPTER XXXIV + +HUCK said: "Tom, we can slope, if we can find a rope. The window ain't +high from the ground." + +"Shucks! what do you want to slope for?" + +"Well, I ain't used to that kind of a crowd. I can't stand it. I ain't +going down there, Tom." + +"Oh, bother! It ain't anything. I don't mind it a bit. I'll take care +of you." + +Sid appeared. + +"Tom," said he, "auntie has been waiting for you all the afternoon. +Mary got your Sunday clothes ready, and everybody's been fretting about +you. Say--ain't this grease and clay, on your clothes?" + +"Now, Mr. Siddy, you jist 'tend to your own business. What's all this +blow-out about, anyway?" + +"It's one of the widow's parties that she's always having. This time +it's for the Welshman and his sons, on account of that scrape they +helped her out of the other night. And say--I can tell you something, +if you want to know." + +"Well, what?" + +"Why, old Mr. Jones is going to try to spring something on the people +here to-night, but I overheard him tell auntie to-day about it, as a +secret, but I reckon it's not much of a secret now. Everybody knows +--the widow, too, for all she tries to let on she don't. Mr. Jones was +bound Huck should be here--couldn't get along with his grand secret +without Huck, you know!" + +"Secret about what, Sid?" + +"About Huck tracking the robbers to the widow's. I reckon Mr. Jones +was going to make a grand time over his surprise, but I bet you it will +drop pretty flat." + +Sid chuckled in a very contented and satisfied way. + +"Sid, was it you that told?" + +"Oh, never mind who it was. SOMEBODY told--that's enough." + +"Sid, there's only one person in this town mean enough to do that, and +that's you. If you had been in Huck's place you'd 'a' sneaked down the +hill and never told anybody on the robbers. You can't do any but mean +things, and you can't bear to see anybody praised for doing good ones. +There--no thanks, as the widow says"--and Tom cuffed Sid's ears and +helped him to the door with several kicks. "Now go and tell auntie if +you dare--and to-morrow you'll catch it!" + +Some minutes later the widow's guests were at the supper-table, and a +dozen children were propped up at little side-tables in the same room, +after the fashion of that country and that day. At the proper time Mr. +Jones made his little speech, in which he thanked the widow for the +honor she was doing himself and his sons, but said that there was +another person whose modesty-- + +And so forth and so on. He sprung his secret about Huck's share in the +adventure in the finest dramatic manner he was master of, but the +surprise it occasioned was largely counterfeit and not as clamorous and +effusive as it might have been under happier circumstances. However, +the widow made a pretty fair show of astonishment, and heaped so many +compliments and so much gratitude upon Huck that he almost forgot the +nearly intolerable discomfort of his new clothes in the entirely +intolerable discomfort of being set up as a target for everybody's gaze +and everybody's laudations. + +The widow said she meant to give Huck a home under her roof and have +him educated; and that when she could spare the money she would start +him in business in a modest way. Tom's chance was come. He said: + +"Huck don't need it. Huck's rich." + +Nothing but a heavy strain upon the good manners of the company kept +back the due and proper complimentary laugh at this pleasant joke. But +the silence was a little awkward. Tom broke it: + +"Huck's got money. Maybe you don't believe it, but he's got lots of +it. Oh, you needn't smile--I reckon I can show you. You just wait a +minute." + +Tom ran out of doors. The company looked at each other with a +perplexed interest--and inquiringly at Huck, who was tongue-tied. + +"Sid, what ails Tom?" said Aunt Polly. "He--well, there ain't ever any +making of that boy out. I never--" + +Tom entered, struggling with the weight of his sacks, and Aunt Polly +did not finish her sentence. Tom poured the mass of yellow coin upon +the table and said: + +"There--what did I tell you? Half of it's Huck's and half of it's mine!" + +The spectacle took the general breath away. All gazed, nobody spoke +for a moment. Then there was a unanimous call for an explanation. Tom +said he could furnish it, and he did. The tale was long, but brimful of +interest. There was scarcely an interruption from any one to break the +charm of its flow. When he had finished, Mr. Jones said: + +"I thought I had fixed up a little surprise for this occasion, but it +don't amount to anything now. This one makes it sing mighty small, I'm +willing to allow." + +The money was counted. The sum amounted to a little over twelve +thousand dollars. It was more than any one present had ever seen at one +time before, though several persons were there who were worth +considerably more than that in property. + + + +CHAPTER XXXV + +THE reader may rest satisfied that Tom's and Huck's windfall made a +mighty stir in the poor little village of St. Petersburg. So vast a +sum, all in actual cash, seemed next to incredible. It was talked +about, gloated over, glorified, until the reason of many of the +citizens tottered under the strain of the unhealthy excitement. Every +"haunted" house in St. Petersburg and the neighboring villages was +dissected, plank by plank, and its foundations dug up and ransacked for +hidden treasure--and not by boys, but men--pretty grave, unromantic +men, too, some of them. Wherever Tom and Huck appeared they were +courted, admired, stared at. The boys were not able to remember that +their remarks had possessed weight before; but now their sayings were +treasured and repeated; everything they did seemed somehow to be +regarded as remarkable; they had evidently lost the power of doing and +saying commonplace things; moreover, their past history was raked up +and discovered to bear marks of conspicuous originality. The village +paper published biographical sketches of the boys. + +The Widow Douglas put Huck's money out at six per cent., and Judge +Thatcher did the same with Tom's at Aunt Polly's request. Each lad had +an income, now, that was simply prodigious--a dollar for every week-day +in the year and half of the Sundays. It was just what the minister got +--no, it was what he was promised--he generally couldn't collect it. A +dollar and a quarter a week would board, lodge, and school a boy in +those old simple days--and clothe him and wash him, too, for that +matter. + +Judge Thatcher had conceived a great opinion of Tom. He said that no +commonplace boy would ever have got his daughter out of the cave. When +Becky told her father, in strict confidence, how Tom had taken her +whipping at school, the Judge was visibly moved; and when she pleaded +grace for the mighty lie which Tom had told in order to shift that +whipping from her shoulders to his own, the Judge said with a fine +outburst that it was a noble, a generous, a magnanimous lie--a lie that +was worthy to hold up its head and march down through history breast to +breast with George Washington's lauded Truth about the hatchet! Becky +thought her father had never looked so tall and so superb as when he +walked the floor and stamped his foot and said that. She went straight +off and told Tom about it. + +Judge Thatcher hoped to see Tom a great lawyer or a great soldier some +day. He said he meant to look to it that Tom should be admitted to the +National Military Academy and afterward trained in the best law school +in the country, in order that he might be ready for either career or +both. + +Huck Finn's wealth and the fact that he was now under the Widow +Douglas' protection introduced him into society--no, dragged him into +it, hurled him into it--and his sufferings were almost more than he +could bear. The widow's servants kept him clean and neat, combed and +brushed, and they bedded him nightly in unsympathetic sheets that had +not one little spot or stain which he could press to his heart and know +for a friend. He had to eat with a knife and fork; he had to use +napkin, cup, and plate; he had to learn his book, he had to go to +church; he had to talk so properly that speech was become insipid in +his mouth; whithersoever he turned, the bars and shackles of +civilization shut him in and bound him hand and foot. + +He bravely bore his miseries three weeks, and then one day turned up +missing. For forty-eight hours the widow hunted for him everywhere in +great distress. The public were profoundly concerned; they searched +high and low, they dragged the river for his body. Early the third +morning Tom Sawyer wisely went poking among some old empty hogsheads +down behind the abandoned slaughter-house, and in one of them he found +the refugee. Huck had slept there; he had just breakfasted upon some +stolen odds and ends of food, and was lying off, now, in comfort, with +his pipe. He was unkempt, uncombed, and clad in the same old ruin of +rags that had made him picturesque in the days when he was free and +happy. Tom routed him out, told him the trouble he had been causing, +and urged him to go home. Huck's face lost its tranquil content, and +took a melancholy cast. He said: + +"Don't talk about it, Tom. I've tried it, and it don't work; it don't +work, Tom. It ain't for me; I ain't used to it. The widder's good to +me, and friendly; but I can't stand them ways. She makes me get up just +at the same time every morning; she makes me wash, they comb me all to +thunder; she won't let me sleep in the woodshed; I got to wear them +blamed clothes that just smothers me, Tom; they don't seem to any air +git through 'em, somehow; and they're so rotten nice that I can't set +down, nor lay down, nor roll around anywher's; I hain't slid on a +cellar-door for--well, it 'pears to be years; I got to go to church and +sweat and sweat--I hate them ornery sermons! I can't ketch a fly in +there, I can't chaw. I got to wear shoes all Sunday. The widder eats by +a bell; she goes to bed by a bell; she gits up by a bell--everything's +so awful reg'lar a body can't stand it." + +"Well, everybody does that way, Huck." + +"Tom, it don't make no difference. I ain't everybody, and I can't +STAND it. It's awful to be tied up so. And grub comes too easy--I don't +take no interest in vittles, that way. I got to ask to go a-fishing; I +got to ask to go in a-swimming--dern'd if I hain't got to ask to do +everything. Well, I'd got to talk so nice it wasn't no comfort--I'd got +to go up in the attic and rip out awhile, every day, to git a taste in +my mouth, or I'd a died, Tom. The widder wouldn't let me smoke; she +wouldn't let me yell, she wouldn't let me gape, nor stretch, nor +scratch, before folks--" [Then with a spasm of special irritation and +injury]--"And dad fetch it, she prayed all the time! I never see such a +woman! I HAD to shove, Tom--I just had to. And besides, that school's +going to open, and I'd a had to go to it--well, I wouldn't stand THAT, +Tom. Looky here, Tom, being rich ain't what it's cracked up to be. It's +just worry and worry, and sweat and sweat, and a-wishing you was dead +all the time. Now these clothes suits me, and this bar'l suits me, and +I ain't ever going to shake 'em any more. Tom, I wouldn't ever got into +all this trouble if it hadn't 'a' ben for that money; now you just take +my sheer of it along with your'n, and gimme a ten-center sometimes--not +many times, becuz I don't give a dern for a thing 'thout it's tollable +hard to git--and you go and beg off for me with the widder." + +"Oh, Huck, you know I can't do that. 'Tain't fair; and besides if +you'll try this thing just a while longer you'll come to like it." + +"Like it! Yes--the way I'd like a hot stove if I was to set on it long +enough. No, Tom, I won't be rich, and I won't live in them cussed +smothery houses. I like the woods, and the river, and hogsheads, and +I'll stick to 'em, too. Blame it all! just as we'd got guns, and a +cave, and all just fixed to rob, here this dern foolishness has got to +come up and spile it all!" + +Tom saw his opportunity-- + +"Lookyhere, Huck, being rich ain't going to keep me back from turning +robber." + +"No! Oh, good-licks; are you in real dead-wood earnest, Tom?" + +"Just as dead earnest as I'm sitting here. But Huck, we can't let you +into the gang if you ain't respectable, you know." + +Huck's joy was quenched. + +"Can't let me in, Tom? Didn't you let me go for a pirate?" + +"Yes, but that's different. A robber is more high-toned than what a +pirate is--as a general thing. In most countries they're awful high up +in the nobility--dukes and such." + +"Now, Tom, hain't you always ben friendly to me? You wouldn't shet me +out, would you, Tom? You wouldn't do that, now, WOULD you, Tom?" + +"Huck, I wouldn't want to, and I DON'T want to--but what would people +say? Why, they'd say, 'Mph! Tom Sawyer's Gang! pretty low characters in +it!' They'd mean you, Huck. You wouldn't like that, and I wouldn't." + +Huck was silent for some time, engaged in a mental struggle. Finally +he said: + +"Well, I'll go back to the widder for a month and tackle it and see if +I can come to stand it, if you'll let me b'long to the gang, Tom." + +"All right, Huck, it's a whiz! Come along, old chap, and I'll ask the +widow to let up on you a little, Huck." + +"Will you, Tom--now will you? That's good. If she'll let up on some of +the roughest things, I'll smoke private and cuss private, and crowd +through or bust. When you going to start the gang and turn robbers?" + +"Oh, right off. We'll get the boys together and have the initiation +to-night, maybe." + +"Have the which?" + +"Have the initiation." + +"What's that?" + +"It's to swear to stand by one another, and never tell the gang's +secrets, even if you're chopped all to flinders, and kill anybody and +all his family that hurts one of the gang." + +"That's gay--that's mighty gay, Tom, I tell you." + +"Well, I bet it is. And all that swearing's got to be done at +midnight, in the lonesomest, awfulest place you can find--a ha'nted +house is the best, but they're all ripped up now." + +"Well, midnight's good, anyway, Tom." + +"Yes, so it is. And you've got to swear on a coffin, and sign it with +blood." + +"Now, that's something LIKE! Why, it's a million times bullier than +pirating. I'll stick to the widder till I rot, Tom; and if I git to be +a reg'lar ripper of a robber, and everybody talking 'bout it, I reckon +she'll be proud she snaked me in out of the wet." + + + +CONCLUSION + +SO endeth this chronicle. It being strictly a history of a BOY, it +must stop here; the story could not go much further without becoming +the history of a MAN. When one writes a novel about grown people, he +knows exactly where to stop--that is, with a marriage; but when he +writes of juveniles, he must stop where he best can. + +Most of the characters that perform in this book still live, and are +prosperous and happy. Some day it may seem worth while to take up the +story of the younger ones again and see what sort of men and women they +turned out to be; therefore it will be wisest not to reveal any of that +part of their lives at present. diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/README.md b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/README.md new file mode 100644 index 0000000..da6d966 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/README.md @@ -0,0 +1,33 @@ +# libbacktrace +A C library that may be linked into a C/C++ program to produce symbolic backtraces + +Initially written by Ian Lance Taylor . + +This is version 1.0. +It is likely that this will always be version 1.0. + +The libbacktrace library may be linked into a program or library and +used to produce symbolic backtraces. +Sample uses would be to print a detailed backtrace when an error +occurs or to gather detailed profiling information. + +The libbacktrace library is provided under a BSD license. +See the source files for the exact license text. + +The public functions are declared and documented in the header file +backtrace.h, which should be #include'd by a user of the library. + +Building libbacktrace will generate a file backtrace-supported.h, +which a user of the library may use to determine whether backtraces +will work. +See the source file backtrace-supported.h.in for the macros that it +defines. + +As of January 2018, libbacktrace only supports ELF, PE/COFF, and XCOFF +executables with DWARF debugging information. +The library is written to make it straightforward to add support for +other object file and debugging formats. + +The library relies on the C++ unwind API defined at +https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html +This API is provided by GCC. diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/acinclude.m4 b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/acinclude.m4 new file mode 100644 index 0000000..daa73af --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/acinclude.m4 @@ -0,0 +1,72 @@ +dnl +dnl Check whether _Unwind_GetIPInfo is available without doing a link +dnl test so we can use this with libstdc++-v3 and libjava. Need to +dnl use $target to set defaults because automatic checking is not possible +dnl without a link test (and maybe even with a link test). +dnl + +AC_DEFUN([GCC_CHECK_UNWIND_GETIPINFO], [ + AC_ARG_WITH(system-libunwind, + [ --with-system-libunwind use installed libunwind]) + # If system-libunwind was not specifically set, pick a default setting. + if test x$with_system_libunwind = x; then + case ${target} in + ia64-*-hpux*) with_system_libunwind=yes ;; + *) with_system_libunwind=no ;; + esac + fi + # Based on system-libunwind and target, do we have ipinfo? + if test x$with_system_libunwind = xyes; then + case ${target} in + ia64-*-*) have_unwind_getipinfo=no ;; + *) have_unwind_getipinfo=yes ;; + esac + else + # Darwin before version 9 does not have _Unwind_GetIPInfo. + changequote(,) + case ${target} in + *-*-darwin[3-8]|*-*-darwin[3-8].*) have_unwind_getipinfo=no ;; + *) have_unwind_getipinfo=yes ;; + esac + changequote([,]) + fi + + if test x$have_unwind_getipinfo = xyes; then + AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.]) + fi +]) + +# ACX_PROG_CC_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CFLAGS]) +# Sets @VARIABLE@ to the subset of the given options which the +# compiler accepts. +AC_DEFUN([ACX_PROG_CC_WARNING_OPTS], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_LANG_PUSH(C) +m4_pushdef([acx_Var], [m4_default([$2], [WARN_CFLAGS])])dnl +AC_SUBST(acx_Var)dnl +m4_expand_once([acx_Var= +],m4_quote(acx_Var=))dnl +save_CFLAGS="$CFLAGS" +for real_option in $1; do + # Do the check with the no- prefix removed since gcc silently + # accepts any -Wno-* option on purpose + case $real_option in + -Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;; + *) option=$real_option ;; + esac + AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option]) + AC_CACHE_CHECK([whether $CC supports $option], acx_Woption, + [CFLAGS="$option" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_VAR_SET(acx_Woption, yes)], + [AS_VAR_SET(acx_Woption, no)]) + ]) + AS_IF([test AS_VAR_GET(acx_Woption) = yes], + [acx_Var="$acx_Var${acx_Var:+ }$real_option"]) + AS_VAR_POPDEF([acx_Woption])dnl +done +CFLAGS="$save_CFLAGS" +m4_popdef([acx_Var])dnl +AC_LANG_POP(C) +])# ACX_PROG_CC_WARNING_OPTS + diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/aclocal.m4 b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/aclocal.m4 new file mode 100644 index 0000000..32a1811 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/aclocal.m4 @@ -0,0 +1,767 @@ +# generated automatically by aclocal 1.11.6 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, +# Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.64],, +[m4_warning([this file was generated for autoconf 2.64. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically `autoreconf'.])]) + +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software +# Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.11' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.11.6], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.11.6])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 9 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 16 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.62])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl +]) + +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, +# Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering + +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008, +# 2011 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_MAINTAINER_MODE([DEFAULT-MODE]) +# ---------------------------------- +# Control maintainer-specific portions of Makefiles. +# Default is to disable them, unless `enable' is passed literally. +# For symmetry, `disable' may be passed as well. Anyway, the user +# can override the default with the --enable/--disable switch. +AC_DEFUN([AM_MAINTAINER_MODE], +[m4_case(m4_default([$1], [disable]), + [enable], [m4_define([am_maintainer_other], [disable])], + [disable], [m4_define([am_maintainer_other], [enable])], + [m4_define([am_maintainer_other], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) +AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode's default is 'disable' unless 'enable' is passed + AC_ARG_ENABLE([maintainer-mode], +[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST([MAINT])dnl +] +) + +AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 6 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, +# Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2012 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 6 + +# AM_ENABLE_MULTILIB([MAKEFILE], [REL-TO-TOP-SRCDIR]) +# --------------------------------------------------- +# Add --enable-multilib to configure. +AC_DEFUN([AM_ENABLE_MULTILIB], +[m4_warn([obsolete], [$0 will be removed from Automake core soon. +Files implementing the "multilib" feature are (and will remain) available +to the 'contrib/' directory in the Automake distribution.])]dnl +[# Default to --enable-multilib +AC_ARG_ENABLE(multilib, +[ --enable-multilib build many library versions (default)], +[case "$enableval" in + yes) multilib=yes ;; + no) multilib=no ;; + *) AC_MSG_ERROR([bad value $enableval for multilib option]) ;; + esac], + [multilib=yes]) + +# We may get other options which we leave undocumented: +# --with-target-subdir, --with-multisrctop, --with-multisubdir +# See config-ml.in if you want the gory details. + +if test "$srcdir" = "."; then + if test "$with_target_subdir" != "."; then + multi_basedir="$srcdir/$with_multisrctop../$2" + else + multi_basedir="$srcdir/$with_multisrctop$2" + fi +else + multi_basedir="$srcdir/$2" +fi +AC_SUBST(multi_basedir) + +# Even if the default multilib is not a cross compilation, +# it may be that some of the other multilibs are. +if test $cross_compiling = no && test $multilib = yes \ + && test "x${with_multisubdir}" != x ; then + cross_compiling=maybe +fi + +AC_OUTPUT_COMMANDS([ +# Only add multilib support code if we just rebuilt the top-level +# Makefile. +case " $CONFIG_FILES " in + *" ]m4_default([$1],Makefile)[ "*) + ac_file=]m4_default([$1],Makefile)[ . ${multi_basedir}/config-ml.in + ;; +esac], + [ +srcdir="$srcdir" +host="$host" +target="$target" +with_multisubdir="$with_multisubdir" +with_multisrctop="$with_multisrctop" +with_target_subdir="$with_target_subdir" +ac_configure_args="${multilib_arg} ${ac_configure_args}" +multi_basedir="$multi_basedir" +CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} +CC="$CC"])])dnl + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software +# Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# -------------------- +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ------------------------ +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# -------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + +m4_include([config/libtool.m4]) +m4_include([config/ltoptions.m4]) +m4_include([config/ltsugar.m4]) +m4_include([config/ltversion.m4]) +m4_include([config/lt~obsolete.m4]) +m4_include([acinclude.m4]) diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/alloc.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/alloc.c new file mode 100644 index 0000000..7070afb --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/alloc.c @@ -0,0 +1,156 @@ +/* alloc.c -- Memory allocation without mmap. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +/* Allocation routines to use on systems that do not support anonymous + mmap. This implementation just uses malloc, which means that the + backtrace functions may not be safely invoked from a signal + handler. */ + +/* Allocate memory like malloc. If ERROR_CALLBACK is NULL, don't + report an error. */ + +void * +backtrace_alloc (struct backtrace_state *state ATTRIBUTE_UNUSED, + size_t size, backtrace_error_callback error_callback, + void *data) +{ + void *ret; + + ret = malloc (size); + if (ret == NULL) + { + if (error_callback) + error_callback (data, "malloc", errno); + } + return ret; +} + +/* Free memory. */ + +void +backtrace_free (struct backtrace_state *state ATTRIBUTE_UNUSED, + void *p, size_t size ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data ATTRIBUTE_UNUSED) +{ + free (p); +} + +/* Grow VEC by SIZE bytes. */ + +void * +backtrace_vector_grow (struct backtrace_state *state ATTRIBUTE_UNUSED, + size_t size, backtrace_error_callback error_callback, + void *data, struct backtrace_vector *vec) +{ + void *ret; + + if (size > vec->alc) + { + size_t alc; + void *base; + + if (vec->size == 0) + alc = 32 * size; + else if (vec->size >= 4096) + alc = vec->size + 4096; + else + alc = 2 * vec->size; + + if (alc < vec->size + size) + alc = vec->size + size; + + base = realloc (vec->base, alc); + if (base == NULL) + { + error_callback (data, "realloc", errno); + return NULL; + } + + vec->base = base; + vec->alc = alc - vec->size; + } + + ret = (char *) vec->base + vec->size; + vec->size += size; + vec->alc -= size; + return ret; +} + +/* Finish the current allocation on VEC. */ + +void * +backtrace_vector_finish (struct backtrace_state *state, + struct backtrace_vector *vec, + backtrace_error_callback error_callback, + void *data) +{ + void *ret; + + /* With this allocator we call realloc in backtrace_vector_grow, + which means we can't easily reuse the memory here. So just + release it. */ + if (!backtrace_vector_release (state, vec, error_callback, data)) + return NULL; + ret = vec->base; + vec->base = NULL; + vec->size = 0; + vec->alc = 0; + return ret; +} + +/* Release any extra space allocated for VEC. */ + +int +backtrace_vector_release (struct backtrace_state *state ATTRIBUTE_UNUSED, + struct backtrace_vector *vec, + backtrace_error_callback error_callback, + void *data) +{ + vec->base = realloc (vec->base, vec->size); + if (vec->base == NULL) + { + error_callback (data, "realloc", errno); + return 0; + } + vec->alc = 0; + return 1; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/atomic.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/atomic.c new file mode 100644 index 0000000..5ab1600 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/atomic.c @@ -0,0 +1,113 @@ +/* atomic.c -- Support for atomic functions if not present. + Copyright (C) 2013-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include + +#include "backtrace.h" +#include "backtrace-supported.h" +#include "internal.h" + +/* This file holds implementations of the atomic functions that are + used if the host compiler has the sync functions but not the atomic + functions, as is true of versions of GCC before 4.7. */ + +#if !defined (HAVE_ATOMIC_FUNCTIONS) && defined (HAVE_SYNC_FUNCTIONS) + +/* Do an atomic load of a pointer. */ + +void * +backtrace_atomic_load_pointer (void *arg) +{ + void **pp; + void *p; + + pp = (void **) arg; + p = *pp; + while (!__sync_bool_compare_and_swap (pp, p, p)) + p = *pp; + return p; +} + +/* Do an atomic load of an int. */ + +int +backtrace_atomic_load_int (int *p) +{ + int i; + + i = *p; + while (!__sync_bool_compare_and_swap (p, i, i)) + i = *p; + return i; +} + +/* Do an atomic store of a pointer. */ + +void +backtrace_atomic_store_pointer (void *arg, void *p) +{ + void **pp; + void *old; + + pp = (void **) arg; + old = *pp; + while (!__sync_bool_compare_and_swap (pp, old, p)) + old = *pp; +} + +/* Do an atomic store of a size_t value. */ + +void +backtrace_atomic_store_size_t (size_t *p, size_t v) +{ + size_t old; + + old = *p; + while (!__sync_bool_compare_and_swap (p, old, v)) + old = *p; +} + +/* Do an atomic store of a int value. */ + +void +backtrace_atomic_store_int (int *p, int v) +{ + size_t old; + + old = *p; + while (!__sync_bool_compare_and_swap (p, old, v)) + old = *p; +} + +#endif diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/backtrace-supported.h.in b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/backtrace-supported.h.in new file mode 100644 index 0000000..c2d03d2 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/backtrace-supported.h.in @@ -0,0 +1,66 @@ +/* backtrace-supported.h.in -- Whether stack backtrace is supported. + Copyright (C) 2012-2016 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +/* The file backtrace-supported.h.in is used by configure to generate + the file backtrace-supported.h. The file backtrace-supported.h may + be #include'd to see whether the backtrace library will be able to + get a backtrace and produce symbolic information. */ + + +/* BACKTRACE_SUPPORTED will be #define'd as 1 if the backtrace library + should work, 0 if it will not. Libraries may #include this to make + other arrangements. */ + +#define BACKTRACE_SUPPORTED @BACKTRACE_SUPPORTED@ + +/* BACKTRACE_USES_MALLOC will be #define'd as 1 if the backtrace + library will call malloc as it works, 0 if it will call mmap + instead. This may be used to determine whether it is safe to call + the backtrace functions from a signal handler. In general this + only applies to calls like backtrace and backtrace_pcinfo. It does + not apply to backtrace_simple, which never calls malloc. It does + not apply to backtrace_print, which always calls fprintf and + therefore malloc. */ + +#define BACKTRACE_USES_MALLOC @BACKTRACE_USES_MALLOC@ + +/* BACKTRACE_SUPPORTS_THREADS will be #define'd as 1 if the backtrace + library is configured with threading support, 0 if not. If this is + 0, the threaded parameter to backtrace_create_state must be passed + as 0. */ + +#define BACKTRACE_SUPPORTS_THREADS @BACKTRACE_SUPPORTS_THREADS@ + +/* BACKTRACE_SUPPORTS_DATA will be #defined'd as 1 if the backtrace_syminfo + will work for variables. It will always work for functions. */ + +#define BACKTRACE_SUPPORTS_DATA @BACKTRACE_SUPPORTS_DATA@ diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/backtrace.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/backtrace.c new file mode 100644 index 0000000..f8e3dc5 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/backtrace.c @@ -0,0 +1,129 @@ +/* backtrace.c -- Entry point for stack backtrace library. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include + +#include "unwind.h" +#include "backtrace.h" +#include "internal.h" + +/* The main backtrace_full routine. */ + +/* Data passed through _Unwind_Backtrace. */ + +struct backtrace_data +{ + /* Number of frames to skip. */ + int skip; + /* Library state. */ + struct backtrace_state *state; + /* Callback routine. */ + backtrace_full_callback callback; + /* Error callback routine. */ + backtrace_error_callback error_callback; + /* Data to pass to callback routines. */ + void *data; + /* Value to return from backtrace_full. */ + int ret; + /* Whether there is any memory available. */ + int can_alloc; +}; + +/* Unwind library callback routine. This is passed to + _Unwind_Backtrace. */ + +static _Unwind_Reason_Code +unwind (struct _Unwind_Context *context, void *vdata) +{ + struct backtrace_data *bdata = (struct backtrace_data *) vdata; + uintptr_t pc; + int ip_before_insn = 0; + +#ifdef HAVE_GETIPINFO + pc = _Unwind_GetIPInfo (context, &ip_before_insn); +#else + pc = _Unwind_GetIP (context); +#endif + + if (bdata->skip > 0) + { + --bdata->skip; + return _URC_NO_REASON; + } + + if (!ip_before_insn) + --pc; + + if (!bdata->can_alloc) + bdata->ret = bdata->callback (bdata->data, pc, NULL, 0, NULL); + else + bdata->ret = backtrace_pcinfo (bdata->state, pc, bdata->callback, + bdata->error_callback, bdata->data); + if (bdata->ret != 0) + return _URC_END_OF_STACK; + + return _URC_NO_REASON; +} + +/* Get a stack backtrace. */ + +int +backtrace_full (struct backtrace_state *state, int skip, + backtrace_full_callback callback, + backtrace_error_callback error_callback, void *data) +{ + struct backtrace_data bdata; + void *p; + + bdata.skip = skip + 1; + bdata.state = state; + bdata.callback = callback; + bdata.error_callback = error_callback; + bdata.data = data; + bdata.ret = 0; + + /* If we can't allocate any memory at all, don't try to produce + file/line information. */ + p = backtrace_alloc (state, 4096, NULL, NULL); + if (p == NULL) + bdata.can_alloc = 0; + else + { + backtrace_free (state, p, 4096, NULL, NULL); + bdata.can_alloc = 1; + } + + _Unwind_Backtrace (unwind, &bdata); + return bdata.ret; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/backtrace.h b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/backtrace.h new file mode 100644 index 0000000..17b1019 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/backtrace.h @@ -0,0 +1,182 @@ +/* backtrace.h -- Public header file for stack backtrace library. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#ifndef BACKTRACE_H +#define BACKTRACE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* The backtrace state. This struct is intentionally not defined in + the public interface. */ + +struct backtrace_state; + +/* The type of the error callback argument to backtrace functions. + This function, if not NULL, will be called for certain error cases. + The DATA argument is passed to the function that calls this one. + The MSG argument is an error message. The ERRNUM argument, if + greater than 0, holds an errno value. The MSG buffer may become + invalid after this function returns. + + As a special case, the ERRNUM argument will be passed as -1 if no + debug info can be found for the executable, but the function + requires debug info (e.g., backtrace_full, backtrace_pcinfo). The + MSG in this case will be something along the lines of "no debug + info". Similarly, ERRNUM will be passed as -1 if there is no + symbol table, but the function requires a symbol table (e.g., + backtrace_syminfo). This may be used as a signal that some other + approach should be tried. */ + +typedef void (*backtrace_error_callback) (void *data, const char *msg, + int errnum); + +/* Create state information for the backtrace routines. This must be + called before any of the other routines, and its return value must + be passed to all of the other routines. FILENAME is the path name + of the executable file; if it is NULL the library will try + system-specific path names. If not NULL, FILENAME must point to a + permanent buffer. If THREADED is non-zero the state may be + accessed by multiple threads simultaneously, and the library will + use appropriate atomic operations. If THREADED is zero the state + may only be accessed by one thread at a time. This returns a state + pointer on success, NULL on error. If an error occurs, this will + call the ERROR_CALLBACK routine. */ + +extern struct backtrace_state *backtrace_create_state ( + const char *filename, int threaded, + backtrace_error_callback error_callback, void *data); + +/* The type of the callback argument to the backtrace_full function. + DATA is the argument passed to backtrace_full. PC is the program + counter. FILENAME is the name of the file containing PC, or NULL + if not available. LINENO is the line number in FILENAME containing + PC, or 0 if not available. FUNCTION is the name of the function + containing PC, or NULL if not available. This should return 0 to + continuing tracing. The FILENAME and FUNCTION buffers may become + invalid after this function returns. */ + +typedef int (*backtrace_full_callback) (void *data, uintptr_t pc, + const char *filename, int lineno, + const char *function); + +/* Get a full stack backtrace. SKIP is the number of frames to skip; + passing 0 will start the trace with the function calling + backtrace_full. DATA is passed to the callback routine. If any + call to CALLBACK returns a non-zero value, the stack backtrace + stops, and backtrace returns that value; this may be used to limit + the number of stack frames desired. If all calls to CALLBACK + return 0, backtrace returns 0. The backtrace_full function will + make at least one call to either CALLBACK or ERROR_CALLBACK. This + function requires debug info for the executable. */ + +extern int backtrace_full (struct backtrace_state *state, int skip, + backtrace_full_callback callback, + backtrace_error_callback error_callback, + void *data); + +/* The type of the callback argument to the backtrace_simple function. + DATA is the argument passed to simple_backtrace. PC is the program + counter. This should return 0 to continue tracing. */ + +typedef int (*backtrace_simple_callback) (void *data, uintptr_t pc); + +/* Get a simple backtrace. SKIP is the number of frames to skip, as + in backtrace. DATA is passed to the callback routine. If any call + to CALLBACK returns a non-zero value, the stack backtrace stops, + and backtrace_simple returns that value. Otherwise + backtrace_simple returns 0. The backtrace_simple function will + make at least one call to either CALLBACK or ERROR_CALLBACK. This + function does not require any debug info for the executable. */ + +extern int backtrace_simple (struct backtrace_state *state, int skip, + backtrace_simple_callback callback, + backtrace_error_callback error_callback, + void *data); + +/* Print the current backtrace in a user readable format to a FILE. + SKIP is the number of frames to skip, as in backtrace_full. Any + error messages are printed to stderr. This function requires debug + info for the executable. */ + +extern void backtrace_print (struct backtrace_state *state, int skip, FILE *); + +/* Given PC, a program counter in the current program, call the + callback function with filename, line number, and function name + information. This will normally call the callback function exactly + once. However, if the PC happens to describe an inlined call, and + the debugging information contains the necessary information, then + this may call the callback function multiple times. This will make + at least one call to either CALLBACK or ERROR_CALLBACK. This + returns the first non-zero value returned by CALLBACK, or 0. */ + +extern int backtrace_pcinfo (struct backtrace_state *state, uintptr_t pc, + backtrace_full_callback callback, + backtrace_error_callback error_callback, + void *data); + +/* The type of the callback argument to backtrace_syminfo. DATA and + PC are the arguments passed to backtrace_syminfo. SYMNAME is the + name of the symbol for the corresponding code. SYMVAL is the + value and SYMSIZE is the size of the symbol. SYMNAME will be NULL + if no error occurred but the symbol could not be found. */ + +typedef void (*backtrace_syminfo_callback) (void *data, uintptr_t pc, + const char *symname, + uintptr_t symval, + uintptr_t symsize); + +/* Given ADDR, an address or program counter in the current program, + call the callback information with the symbol name and value + describing the function or variable in which ADDR may be found. + This will call either CALLBACK or ERROR_CALLBACK exactly once. + This returns 1 on success, 0 on failure. This function requires + the symbol table but does not require the debug info. Note that if + the symbol table is present but ADDR could not be found in the + table, CALLBACK will be called with a NULL SYMNAME argument. + Returns 1 on success, 0 on error. */ + +extern int backtrace_syminfo (struct backtrace_state *state, uintptr_t addr, + backtrace_syminfo_callback callback, + backtrace_error_callback error_callback, + void *data); + +#ifdef __cplusplus +} /* End extern "C". */ +#endif + +#endif diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/btest.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/btest.c new file mode 100644 index 0000000..1348d54 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/btest.c @@ -0,0 +1,500 @@ +/* btest.c -- Test for libbacktrace library + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +/* This program tests the externally visible interfaces of the + libbacktrace library. */ + +#include +#include +#include +#include +#include + +#include "filenames.h" + +#include "backtrace.h" +#include "backtrace-supported.h" + +#include "testlib.h" + +/* Test the backtrace function with non-inlined functions. */ + +static int test1 (void) __attribute__ ((noinline, unused)); +static int f2 (int) __attribute__ ((noinline)); +static int f3 (int, int) __attribute__ ((noinline)); + +static int +test1 (void) +{ + /* Returning a value here and elsewhere avoids a tailcall which + would mess up the backtrace. */ + return f2 (__LINE__) + 1; +} + +static int +f2 (int f1line) +{ + return f3 (f1line, __LINE__) + 2; +} + +static int +f3 (int f1line, int f2line) +{ + struct info all[20]; + struct bdata data; + int f3line; + int i; + + data.all = &all[0]; + data.index = 0; + data.max = 20; + data.failed = 0; + + f3line = __LINE__ + 1; + i = backtrace_full (state, 0, callback_one, error_callback_one, &data); + + if (i != 0) + { + fprintf (stderr, "test1: unexpected return value %d\n", i); + data.failed = 1; + } + + if (data.index < 3) + { + fprintf (stderr, + "test1: not enough frames; got %zu, expected at least 3\n", + data.index); + data.failed = 1; + } + + check ("test1", 0, all, f3line, "f3", "btest.c", &data.failed); + check ("test1", 1, all, f2line, "f2", "btest.c", &data.failed); + check ("test1", 2, all, f1line, "test1", "btest.c", &data.failed); + + printf ("%s: backtrace_full noinline\n", data.failed ? "FAIL" : "PASS"); + + if (data.failed) + ++failures; + + return failures; +} + +/* Test the backtrace function with inlined functions. */ + +static inline int test2 (void) __attribute__ ((always_inline, unused)); +static inline int f12 (int) __attribute__ ((always_inline)); +static inline int f13 (int, int) __attribute__ ((always_inline)); + +static inline int +test2 (void) +{ + return f12 (__LINE__) + 1; +} + +static inline int +f12 (int f1line) +{ + return f13 (f1line, __LINE__) + 2; +} + +static inline int +f13 (int f1line, int f2line) +{ + struct info all[20]; + struct bdata data; + int f3line; + int i; + + data.all = &all[0]; + data.index = 0; + data.max = 20; + data.failed = 0; + + f3line = __LINE__ + 1; + i = backtrace_full (state, 0, callback_one, error_callback_one, &data); + + if (i != 0) + { + fprintf (stderr, "test2: unexpected return value %d\n", i); + data.failed = 1; + } + + check ("test2", 0, all, f3line, "f13", "btest.c", &data.failed); + check ("test2", 1, all, f2line, "f12", "btest.c", &data.failed); + check ("test2", 2, all, f1line, "test2", "btest.c", &data.failed); + + printf ("%s: backtrace_full inline\n", data.failed ? "FAIL" : "PASS"); + + if (data.failed) + ++failures; + + return failures; +} + +/* Test the backtrace_simple function with non-inlined functions. */ + +static int test3 (void) __attribute__ ((noinline, unused)); +static int f22 (int) __attribute__ ((noinline)); +static int f23 (int, int) __attribute__ ((noinline)); + +static int +test3 (void) +{ + return f22 (__LINE__) + 1; +} + +static int +f22 (int f1line) +{ + return f23 (f1line, __LINE__) + 2; +} + +static int +f23 (int f1line, int f2line) +{ + uintptr_t addrs[20]; + struct sdata data; + int f3line; + int i; + + data.addrs = &addrs[0]; + data.index = 0; + data.max = 20; + data.failed = 0; + + f3line = __LINE__ + 1; + i = backtrace_simple (state, 0, callback_two, error_callback_two, &data); + + if (i != 0) + { + fprintf (stderr, "test3: unexpected return value %d\n", i); + data.failed = 1; + } + + if (!data.failed) + { + struct info all[20]; + struct bdata bdata; + int j; + + bdata.all = &all[0]; + bdata.index = 0; + bdata.max = 20; + bdata.failed = 0; + + for (j = 0; j < 3; ++j) + { + i = backtrace_pcinfo (state, addrs[j], callback_one, + error_callback_one, &bdata); + if (i != 0) + { + fprintf (stderr, + ("test3: unexpected return value " + "from backtrace_pcinfo %d\n"), + i); + bdata.failed = 1; + } + if (!bdata.failed && bdata.index != (size_t) (j + 1)) + { + fprintf (stderr, + ("wrong number of calls from backtrace_pcinfo " + "got %u expected %d\n"), + (unsigned int) bdata.index, j + 1); + bdata.failed = 1; + } + } + + check ("test3", 0, all, f3line, "f23", "btest.c", &bdata.failed); + check ("test3", 1, all, f2line, "f22", "btest.c", &bdata.failed); + check ("test3", 2, all, f1line, "test3", "btest.c", &bdata.failed); + + if (bdata.failed) + data.failed = 1; + + for (j = 0; j < 3; ++j) + { + struct symdata symdata; + + symdata.name = NULL; + symdata.val = 0; + symdata.size = 0; + symdata.failed = 0; + + i = backtrace_syminfo (state, addrs[j], callback_three, + error_callback_three, &symdata); + if (i == 0) + { + fprintf (stderr, + ("test3: [%d]: unexpected return value " + "from backtrace_syminfo %d\n"), + j, i); + symdata.failed = 1; + } + + if (!symdata.failed) + { + const char *expected; + + switch (j) + { + case 0: + expected = "f23"; + break; + case 1: + expected = "f22"; + break; + case 2: + expected = "test3"; + break; + default: + assert (0); + } + + if (symdata.name == NULL) + { + fprintf (stderr, "test3: [%d]: NULL syminfo name\n", j); + symdata.failed = 1; + } + /* Use strncmp, not strcmp, because GCC might create a + clone. */ + else if (strncmp (symdata.name, expected, strlen (expected)) + != 0) + { + fprintf (stderr, + ("test3: [%d]: unexpected syminfo name " + "got %s expected %s\n"), + j, symdata.name, expected); + symdata.failed = 1; + } + } + + if (symdata.failed) + data.failed = 1; + } + } + + printf ("%s: backtrace_simple noinline\n", data.failed ? "FAIL" : "PASS"); + + if (data.failed) + ++failures; + + return failures; +} + +/* Test the backtrace_simple function with inlined functions. */ + +static inline int test4 (void) __attribute__ ((always_inline, unused)); +static inline int f32 (int) __attribute__ ((always_inline)); +static inline int f33 (int, int) __attribute__ ((always_inline)); + +static inline int +test4 (void) +{ + return f32 (__LINE__) + 1; +} + +static inline int +f32 (int f1line) +{ + return f33 (f1line, __LINE__) + 2; +} + +static inline int +f33 (int f1line, int f2line) +{ + uintptr_t addrs[20]; + struct sdata data; + int f3line; + int i; + + data.addrs = &addrs[0]; + data.index = 0; + data.max = 20; + data.failed = 0; + + f3line = __LINE__ + 1; + i = backtrace_simple (state, 0, callback_two, error_callback_two, &data); + + if (i != 0) + { + fprintf (stderr, "test3: unexpected return value %d\n", i); + data.failed = 1; + } + + if (!data.failed) + { + struct info all[20]; + struct bdata bdata; + + bdata.all = &all[0]; + bdata.index = 0; + bdata.max = 20; + bdata.failed = 0; + + i = backtrace_pcinfo (state, addrs[0], callback_one, error_callback_one, + &bdata); + if (i != 0) + { + fprintf (stderr, + ("test4: unexpected return value " + "from backtrace_pcinfo %d\n"), + i); + bdata.failed = 1; + } + + check ("test4", 0, all, f3line, "f33", "btest.c", &bdata.failed); + check ("test4", 1, all, f2line, "f32", "btest.c", &bdata.failed); + check ("test4", 2, all, f1line, "test4", "btest.c", &bdata.failed); + + if (bdata.failed) + data.failed = 1; + } + + printf ("%s: backtrace_simple inline\n", data.failed ? "FAIL" : "PASS"); + + if (data.failed) + ++failures; + + return failures; +} + +static int test5 (void) __attribute__ ((unused)); + +int global = 1; + +static int +test5 (void) +{ + struct symdata symdata; + int i; + uintptr_t addr = (uintptr_t) &global; + + if (sizeof (global) > 1) + addr += 1; + + symdata.name = NULL; + symdata.val = 0; + symdata.size = 0; + symdata.failed = 0; + + i = backtrace_syminfo (state, addr, callback_three, + error_callback_three, &symdata); + if (i == 0) + { + fprintf (stderr, + "test5: unexpected return value from backtrace_syminfo %d\n", + i); + symdata.failed = 1; + } + + if (!symdata.failed) + { + if (symdata.name == NULL) + { + fprintf (stderr, "test5: NULL syminfo name\n"); + symdata.failed = 1; + } + else if (strcmp (symdata.name, "global") != 0) + { + fprintf (stderr, + "test5: unexpected syminfo name got %s expected %s\n", + symdata.name, "global"); + symdata.failed = 1; + } + else if (symdata.val != (uintptr_t) &global) + { + fprintf (stderr, + "test5: unexpected syminfo value got %lx expected %lx\n", + (unsigned long) symdata.val, + (unsigned long) (uintptr_t) &global); + symdata.failed = 1; + } + else if (symdata.size != sizeof (global)) + { + fprintf (stderr, + "test5: unexpected syminfo size got %lx expected %lx\n", + (unsigned long) symdata.size, + (unsigned long) sizeof (global)); + symdata.failed = 1; + } + } + + printf ("%s: backtrace_syminfo variable\n", + symdata.failed ? "FAIL" : "PASS"); + + if (symdata.failed) + ++failures; + + return failures; +} + +/* Check that are no files left open. */ + +static void +check_open_files (void) +{ + int i; + + for (i = 3; i < 10; i++) + { + if (close (i) == 0) + { + fprintf (stderr, + "ERROR: descriptor %d still open after tests complete\n", + i); + ++failures; + } + } +} + +/* Run all the tests. */ + +int +main (int argc ATTRIBUTE_UNUSED, char **argv) +{ + state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS, + error_callback_create, NULL); + +#if BACKTRACE_SUPPORTED + test1 (); + test2 (); + test3 (); + test4 (); +#if BACKTRACE_SUPPORTS_DATA + test5 (); +#endif +#endif + + check_open_files (); + + exit (failures ? EXIT_FAILURE : EXIT_SUCCESS); +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config.guess b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config.guess new file mode 100755 index 0000000..d622a44 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config.guess @@ -0,0 +1,1530 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012 Free Software Foundation, Inc. + +timestamp='2012-02-10' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner. Please send patches (context +# diff format) to and include a ChangeLog +# entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-gnu + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + LIBC=gnu + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-gnu + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + i386) + eval $set_cc_for_build + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + UNAME_PROCESSOR="x86_64" + fi + fi ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config.h.in b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config.h.in new file mode 100644 index 0000000..76baa09 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config.h.in @@ -0,0 +1,149 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* ELF size: 32 or 64 */ +#undef BACKTRACE_ELF_SIZE + +/* XCOFF size: 32 or 64 */ +#undef BACKTRACE_XCOFF_SIZE + +/* Define to 1 if you have the __atomic functions */ +#undef HAVE_ATOMIC_FUNCTIONS + +/* Define to 1 if you have the `clock_gettime' function. */ +#undef HAVE_CLOCK_GETTIME + +/* Define to 1 if you have the declaration of `strnlen', and to 0 if you + don't. */ +#undef HAVE_DECL_STRNLEN + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define if dl_iterate_phdr is available. */ +#undef HAVE_DL_ITERATE_PHDR + +/* Define to 1 if you have the fcntl function */ +#undef HAVE_FCNTL + +/* Define if getexecname is available. */ +#undef HAVE_GETEXECNAME + +/* Define if _Unwind_GetIPInfo is available. */ +#undef HAVE_GETIPINFO + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `z' library (-lz). */ +#undef HAVE_LIBZ + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINK_H + +/* Define if AIX loadquery is available. */ +#undef HAVE_LOADQUERY + +/* Define to 1 if you have the `lstat' function. */ +#undef HAVE_LSTAT + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `readlink' function. */ +#undef HAVE_READLINK + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the __sync functions */ +#undef HAVE_SYNC_FUNCTIONS + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_LDR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MMAN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if -lz is available. */ +#undef HAVE_ZLIB + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config.sub b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config.sub new file mode 100755 index 0000000..63634d9 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config.sub @@ -0,0 +1,1794 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012 Free Software Foundation, Inc. + +timestamp='2012-02-10' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted GNU ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | be32 | be64 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | epiphany \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 \ + | ns16k | ns32k \ + | open8 \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ + | pyramid \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | we32k \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ + | ip2k-* | iq2000-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ + | pyramid-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + os=$os"spe" + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze) + basic_machine=microblaze-xilinx + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i386-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + wasm32) + basic_machine=wasm32-unknown + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -ios) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + pru-*) + os=-elf + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/libtool.m4 b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/libtool.m4 new file mode 100644 index 0000000..4ceb7f1 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/libtool.m4 @@ -0,0 +1,7309 @@ +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +m4_define([_LT_COPYING], [dnl +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +]) + +# serial 56 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_CC_BASENAME(CC) +# ------------------- +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +m4_defun([_LT_CC_BASENAME], +[for cc_temp in $1""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl +_LT_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld="$lt_cv_prog_gnu_ld" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from `configure', and `config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# `config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain="$ac_aux_dir/ltmain.sh" +])# _LT_PROG_LTMAIN + + +## ------------------------------------- ## +## Accumulate code for creating libtool. ## +## ------------------------------------- ## + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the `libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + +## ------------------------ ## +## FIXME: Eliminate VARNAME ## +## ------------------------ ## + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_quote(m4_if([$2], [], + m4_quote(lt_decl_tag_varnames), + m4_quote(m4_shift($@)))), + m4_split(m4_normalize(m4_quote(_LT_TAGS))))]) +m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to `config.status' so that its +# declaration there will have the same value as in `configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags="_LT_TAGS"dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into `config.status', and then the shell code to quote escape them in +# for loops in `config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +_LT_CONFIG_STATUS_DECLARATIONS +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# Quote evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Fix-up fallback echo if it was mangled by the above quoting rules. +case \$lt_ECHO in +*'\\\[$]0 --fallback-echo"')dnl " + lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` + ;; +esac + +_LT_OUTPUT_LIBTOOL_INIT +]) + + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +cat >"$CONFIG_LT" <<_LTEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate a libtool stub with the current configuration. + +lt_cl_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AS_SHELL_SANITIZE +_AS_PREPARE + +exec AS_MESSAGE_FD>&1 +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +\`$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2008 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test $[#] != 0 +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try \`$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try \`$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +if test "$no_create" != yes; then + lt_cl_success=: + test "$silent" = yes && + lt_config_lt_args="$lt_config_lt_args --quiet" + exec AS_MESSAGE_LOG_FD>/dev/null + $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false + exec AS_MESSAGE_LOG_FD>>config.log + $lt_cl_success || AS_EXIT(1) +fi +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options which allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + + cfgfile="${ofile}T" + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL + +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +_LT_COPYING +_LT_LIBTOOL_TAGS + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### END LIBTOOL CONFIG + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + _LT_PROG_XSI_SHELLFNS + + sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[[012]]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES +# -------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + if test "$GCC" = "yes"; then + output_verbose_link_cmd=echo + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + m4_if([$1], [CXX], +[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + fi +],[]) + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX +# ----------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_SHELL_INIT + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[_LT_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$lt_ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +ECHO=${lt_ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<_LT_EOF +[$]* +_LT_EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$lt_ECHO"; then + if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if { echo_test_string=`eval $cmd`; } 2>/dev/null && + { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null + then + break + fi + done + fi + + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : + else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$ECHO" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + ECHO='print -r' + elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + ECHO='printf %s\n' + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + ECHO=echo + fi + fi + fi + fi + fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +lt_ECHO=$ECHO +if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(lt_ECHO) +]) +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], + [An echo program that does not interpret backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks="$enable_libtool_lock" +])# _LT_ENABLE_LOCK + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[AC_CHECK_TOOL(AR, ar, false) +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1]) + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $RM conftest* +]) + +if test x"[$]$2" = xyes; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8 ; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ + = "XX$teststring$teststring"; } >/dev/null 2>&1 && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +[#line __oline__ "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + exit (status); +}] +_LT_EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links="nottested" +if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", + [Define to the sub-directory in which libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || + test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[[4-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[123]]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[[3-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # Some binutils ld are patched to set DT_RUNPATH + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux + need_lib_prefix=no + need_version=no + library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[List of archive names. First name is the real one, the rest are links. + The last name is the one that the linker finds with -lNAME]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], + [Run-time system search path for libraries]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program which can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program which can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method == "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + : ${lt_cv_path_NM=no} +fi]) +if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" +else + # Didn't find any BSD compatible name lister, look for dumpbin. + AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) + AC_SUBST([DUMPBIN]) + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function + # and D for any global variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ +" {last_section=section; section=\$ 3};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx]" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + icpc* | ecpc* ) + # Intel C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC*) + # IBM XL 8.0 on PPC + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | cygwin* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + icc* | ecc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl*) + # IBM XL C 8.0/Fortran 10.1 on PPC + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac +AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw*) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu) + tmp_diet=no + if test "$host_os" = linux-dietlibc; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test "$tmp_diet" = no + then + tmp_addflag= + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + xlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + AC_LINK_IFELSE(int foo(void) {}, + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + ) + LDFLAGS="$save_LDFLAGS" + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], + [[If ld is used when linking, flag to hardcode $libdir into a binary + during linking. This must work even if $libdir does not exist]]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary and the resulting library dependency is + "absolute", i.e impossible to change by setting ${shlibpath_var} if the + library is relocated]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [fix_srcfile_path], [1], + [Fix the shell variable $srcfile for the compiler]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_TAG_COMPILER +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report which library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC="$lt_save_CC" +])# _LT_LANG_C_CONFIG + + +# _LT_PROG_CXX +# ------------ +# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ +# compiler, we have our own version here. +m4_defun([_LT_PROG_CXX], +[ +pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) +AC_PROG_CXX +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_CXX + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_CXX], []) + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[AC_REQUIRE([_LT_PROG_CXX])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_caught_CXX_error" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + LT_PATH_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GXX" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared + # libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd[[12]]*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + gnu*) + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' + fi + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' + _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ + $RANLIB $oldlib' + _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + *) # Version 6 will use weak symbols + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + xl*) + # IBM XL 8.0 on PPC, with GNU ld + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd2*) + # C++ shared libraries are fairly broken + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd=echo + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ + $RM $lib.exp' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + fi + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + + _LT_TAGVAR(GCC, $1)="$GXX" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + CC=$lt_save_CC + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test "$_lt_caught_CXX_error" != yes + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +]) +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" || + test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)="${prev}${p}" + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)="$p" + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)="$p" + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; + +linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; + +solaris*) + case $cc_basename in + CC*) + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_PROG_F77 +# ------------ +# Since AC_PROG_F77 is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_F77], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) +AC_PROG_F77 +if test -z "$F77" || test "X$F77" = "Xno"; then + _lt_disable_F77=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_F77 + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_F77], []) + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_REQUIRE([_LT_PROG_F77])dnl +AC_LANG_PUSH(Fortran 77) + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_F77" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + CC=${F77-"f77"} + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$G77" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" +fi # test "$_lt_disable_F77" != yes + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_PROG_FC +# ----------- +# Since AC_PROG_FC is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_FC], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) +AC_PROG_FC +if test -z "$FC" || test "X$FC" = "Xno"; then + _lt_disable_FC=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_FC + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_FC], []) + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_REQUIRE([_LT_PROG_FC])dnl +AC_LANG_PUSH(Fortran) + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_FC" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + CC=${FC-"f95"} + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" +fi # test "$_lt_disable_FC" != yes + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC="$lt_save_CC" +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC="$lt_save_CC" +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +AC_MSG_RESULT([$xsi_shell]) +_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) + +AC_MSG_CHECKING([whether the shell understands "+="]) +lt_shell_append=no +( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +AC_MSG_RESULT([$lt_shell_append]) +_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PROG_XSI_SHELLFNS +# --------------------- +# Bourne and XSI compatible variants of some useful shell functions. +m4_defun([_LT_PROG_XSI_SHELLFNS], +[case $xsi_shell in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $[*] )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + +_LT_EOF + ;; + *) # Bourne compatible functions. + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + +dnl func_dirname_and_basename +dnl A portable version of this function is already defined in general.m4sh +dnl so there is no need for it here. + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; + esac +} + +# sed scripts: +my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' +my_sed_long_arg='1s/^-[[^=]]*=//' + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` + func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` +} + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$[@]"` +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` +} + +_LT_EOF +esac + +case $lt_shell_append in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]+=\$[2]" +} +_LT_EOF + ;; + *) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]=\$$[1]\$[2]" +} + +_LT_EOF + ;; + esac +]) diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/ltoptions.m4 b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/ltoptions.m4 new file mode 100644 index 0000000..e970119 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/ltoptions.m4 @@ -0,0 +1,368 @@ +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option `$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl `shared' nor `disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + ]) +])# _LT_SET_OPTIONS + + +## --------------------------------- ## +## Macros to handle LT_INIT options. ## +## --------------------------------- ## + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [0], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the `shared' and +# `disable-shared' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the `static' and +# `disable-static' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the `fast-install' +# and `disable-fast-install' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the `pic-only' and `no-pic' +# LT_INIT options. +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) + +test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + +## ----------------- ## +## LTDL_INIT Options ## +## ----------------- ## + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/ltsugar.m4 b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/ltsugar.m4 new file mode 100644 index 0000000..0d258e0 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/ltsugar.m4 @@ -0,0 +1,123 @@ +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 5 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59 which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +m4_define([lt_combine], +[m4_if([$2], [], [], + [m4_if([$4], [], [], + [lt_join(m4_quote(m4_default([$1], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_prefix, [$2], + [m4_foreach(_Lt_suffix, lt_car([m4_shiftn(3, $@)]), + [_Lt_prefix[]$3[]_Lt_suffix ])])))))])])dnl +]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/ltversion.m4 b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/ltversion.m4 new file mode 100644 index 0000000..45cb155 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/ltversion.m4 @@ -0,0 +1,23 @@ +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# Generated from ltversion.in. + +# serial 2976 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.2.4]) +m4_define([LT_PACKAGE_REVISION], [1.2976]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.2.4' +macro_revision='1.2976' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/lt~obsolete.m4 b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/lt~obsolete.m4 new file mode 100644 index 0000000..637bb20 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/config/lt~obsolete.m4 @@ -0,0 +1,92 @@ +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 4 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/configure b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/configure new file mode 100755 index 0000000..b984f5f --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/configure @@ -0,0 +1,14361 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.64 for package-unused version-unused. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software +# Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$lt_ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','` + ;; +esac + +ECHO=${lt_ECHO-echo} +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<_LT_EOF +$* +_LT_EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$lt_ECHO"; then + if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if { echo_test_string=`eval $cmd`; } 2>/dev/null && + { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null + then + break + fi + done + fi + + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : + else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$ECHO" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + ECHO='print -r' + elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + ECHO='printf %s\n' + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + ECHO="$CONFIG_SHELL $0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + ECHO=echo + fi + fi + fi + fi + fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +lt_ECHO=$ECHO +if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then + lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" +fi + + + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='package-unused' +PACKAGE_TARNAME='libbacktrace' +PACKAGE_VERSION='version-unused' +PACKAGE_STRING='package-unused version-unused' +PACKAGE_BUGREPORT='' +PACKAGE_URL='' + +ac_unique_file="backtrace.h" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +LIBOBJS +NATIVE_FALSE +NATIVE_TRUE +HAVE_OBJCOPY_DEBUGLINK_FALSE +HAVE_OBJCOPY_DEBUGLINK_TRUE +OBJCOPY +HAVE_COMPRESSED_DEBUG_FALSE +HAVE_COMPRESSED_DEBUG_TRUE +HAVE_ZLIB_FALSE +HAVE_ZLIB_TRUE +HAVE_PTHREAD_FALSE +HAVE_PTHREAD_TRUE +PTHREAD_CFLAGS +CLOCK_GETTIME_LINK +BACKTRACE_USES_MALLOC +ALLOC_FILE +VIEW_FILE +BACKTRACE_SUPPORTS_DATA +BACKTRACE_SUPPORTED +FORMAT_FILE +BACKTRACE_SUPPORTS_THREADS +PIC_FLAG +WARN_FLAGS +EXTRA_FLAGS +BACKTRACE_FILE +OTOOL64 +OTOOL +LIPO +NMEDIT +DSYMUTIL +lt_ECHO +RANLIB +AR +LN_S +NM +ac_ct_DUMPBIN +DUMPBIN +LD +FGREP +SED +LIBTOOL +MAINT +MAINTAINER_MODE_FALSE +MAINTAINER_MODE_TRUE +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +libtool_VERSION +EGREP +GREP +CPP +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +target_os +target_vendor +target_cpu +target +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +multi_basedir +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_multilib +enable_maintainer_mode +with_target_subdir +enable_shared +enable_static +with_pic +enable_fast_install +with_gnu_ld +enable_libtool_lock +enable_largefile +with_system_libunwind +enable_host_shared +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +OBJCOPY' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information." + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures package-unused version-unused to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/libbacktrace] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of package-unused version-unused:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-multilib build many library versions (default) + --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer + --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-static[=PKGS] build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) + --disable-largefile omit support for large files + --enable-host-shared build host code as shared libraries + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-target-subdir=SUBDIR Configuring in a subdirectory for target + --with-pic try to use only PIC/non-PIC objects [default=use + both] + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-system-libunwind use installed libunwind + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + OBJCOPY location of objcopy + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +package-unused configure version-unused +generated by GNU Autoconf 2.64 + +Copyright (C) 2009 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_func + +# ac_fn_c_check_decl LINENO SYMBOL VAR +# ------------------------------------ +# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 +$as_echo_n "checking whether $2 is declared... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $2 + (void) $2; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_decl +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by package-unused $as_me version-unused, which was +generated by GNU Autoconf 2.64. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + ac_site_file1=$CONFIG_SITE +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_config_headers="$ac_config_headers config.h" + + + +# with_target_subdir is used when configured as part of a GCC tree. +if test -n "${with_target_subdir}"; then + # Default to --enable-multilib +# Check whether --enable-multilib was given. +if test "${enable_multilib+set}" = set; then : + enableval=$enable_multilib; case "$enableval" in + yes) multilib=yes ;; + no) multilib=no ;; + *) as_fn_error "bad value $enableval for multilib option" "$LINENO" 5 ;; + esac +else + multilib=yes +fi + + +# We may get other options which we leave undocumented: +# --with-target-subdir, --with-multisrctop, --with-multisubdir +# See config-ml.in if you want the gory details. + +if test "$srcdir" = "."; then + if test "$with_target_subdir" != "."; then + multi_basedir="$srcdir/$with_multisrctop../.." + else + multi_basedir="$srcdir/$with_multisrctop.." + fi +else + multi_basedir="$srcdir/.." +fi + + +# Even if the default multilib is not a cross compilation, +# it may be that some of the other multilibs are. +if test $cross_compiling = no && test $multilib = yes \ + && test "x${with_multisubdir}" != x ; then + cross_compiling=maybe +fi + +ac_config_commands="$ac_config_commands default-1" + +fi + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + for ac_t in install-sh install.sh shtool; do + if test -f "$ac_dir/$ac_t"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/$ac_t -c" + break 2 + fi + done +done +if test -z "$ac_aux_dir"; then + as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if test "${ac_cv_build+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if test "${ac_cv_host+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 +$as_echo_n "checking target system type... " >&6; } +if test "${ac_cv_target+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 +$as_echo "$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) as_fn_error "invalid value of canonical target" "$LINENO" 5;; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +target_alias=${target_alias-$host_alias} + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "no acceptable C compiler found in \$PATH +See \`config.log' for more details." "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + rm -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +if test -z "$ac_file"; then : + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ as_fn_set_status 77 +as_fn_error "C compiler cannot create executables +See \`config.log' for more details." "$LINENO" 5; }; } +fi +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." "$LINENO" 5; } +fi +rm -f conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot compute suffix of object files: cannot compile +See \`config.log' for more details." "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if test "${ac_cv_path_GREP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if test "${ac_cv_header_stdc+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" +if test "x$ac_cv_header_minix_config_h" = x""yes; then : + MINIX=yes +else + MINIX= +fi + + + if test "$MINIX" = yes; then + +$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h + + +$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h + + +$as_echo "#define _MINIX 1" >>confdefs.h + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 +$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } +if test "${ac_cv_safe_to_define___extensions__+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# define __EXTENSIONS__ 1 + $ac_includes_default +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_safe_to_define___extensions__=yes +else + ac_cv_safe_to_define___extensions__=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 +$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } + test $ac_cv_safe_to_define___extensions__ = yes && + $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h + + $as_echo "#define _ALL_SOURCE 1" >>confdefs.h + + $as_echo "#define _GNU_SOURCE 1" >>confdefs.h + + $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h + + $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h + + + +libtool_VERSION=1:0:0 + + +# 1.11.1: Require that version of automake. +# foreign: Don't require README, INSTALL, NEWS, etc. +# no-define: Don't define PACKAGE and VERSION. +# no-dependencies: Don't generate automatic dependencies. +# (because it breaks when using bootstrap-lean, since some of the +# headers are gone at "make install" time). +# -Wall: Issue all automake warnings. +# -Wno-portability: Don't warn about constructs supported by GNU make. +# (because GCC requires GNU make anyhow). +am__api_version='1.11' + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error "ls -t appears to fail. Make sure there is not a broken +alias in your environment" "$LINENO" 5 + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if test "${ac_cv_path_mkdir+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + test -d ./--version && rmdir ./--version + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='libbacktrace' + VERSION='version-unused' + + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' + +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 +$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } + # Check whether --enable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then : + enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 +$as_echo "$USE_MAINTAINER_MODE" >&6; } + if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + + MAINT=$MAINTAINER_MODE_TRUE + + + + +# Check whether --with-target-subdir was given. +if test "${with_target_subdir+set}" = set; then : + withval=$with_target_subdir; +fi + + +# We must force CC to /not/ be precious variables; otherwise +# the wrong, non-multilib-adjusted value will be used in multilibs. +# As a side effect, we have to subst CFLAGS ourselves. + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "no acceptable C compiler found in \$PATH +See \`config.log' for more details." "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + rm -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +case "$AWK" in +"") as_fn_error "can't build without awk" "$LINENO" 5 ;; +esac + +case `pwd` in + *\ * | *\ *) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 +$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; +esac + + + +macro_version='2.2.4' +macro_revision='1.2976' + + + + + + + + + + + + + +ltmain="$ac_aux_dir/ltmain.sh" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if test "${ac_cv_path_SED+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi +else + ac_cv_path_SED=$SED +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed + +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 +$as_echo_n "checking for fgrep... " >&6; } +if test "${ac_cv_path_FGREP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 + then ac_cv_path_FGREP="$GREP -F" + else + if test -z "$FGREP"; then + ac_path_FGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in fgrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue +# Check for GNU ac_path_FGREP and select it if it is found. + # Check for GNU $ac_path_FGREP +case `"$ac_path_FGREP" --version 2>&1` in +*GNU*) + ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'FGREP' >> "conftest.nl" + "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_FGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_FGREP="$ac_path_FGREP" + ac_path_FGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_FGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_FGREP"; then + as_fn_error "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_FGREP=$FGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 +$as_echo "$ac_cv_path_FGREP" >&6; } + FGREP="$ac_cv_path_FGREP" + + +test -z "$GREP" && GREP=grep + + + + + + + + + + + + + + + + + + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then : + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if test "${lt_cv_path_LD+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if test "${lt_cv_prog_gnu_ld+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 +$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } +if test "${lt_cv_path_NM+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + : ${lt_cv_path_NM=no} +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 +$as_echo "$lt_cv_path_NM" >&6; } +if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$ac_tool_prefix"; then + for ac_prog in "dumpbin -symbols" "link -dump -symbols" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_DUMPBIN+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DUMPBIN"; then + ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DUMPBIN=$ac_cv_prog_DUMPBIN +if test -n "$DUMPBIN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 +$as_echo "$DUMPBIN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$DUMPBIN" && break + done +fi +if test -z "$DUMPBIN"; then + ac_ct_DUMPBIN=$DUMPBIN + for ac_prog in "dumpbin -symbols" "link -dump -symbols" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DUMPBIN"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN +if test -n "$ac_ct_DUMPBIN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 +$as_echo "$ac_ct_DUMPBIN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_DUMPBIN" && break +done + + if test "x$ac_ct_DUMPBIN" = x; then + DUMPBIN=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DUMPBIN=$ac_ct_DUMPBIN + fi +fi + + + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 +$as_echo_n "checking the name lister ($NM) interface... " >&6; } +if test "${lt_cv_nm_interface+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:5363: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 + (eval echo "\"\$as_me:5366: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 + (eval echo "\"\$as_me:5369: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 +$as_echo "$lt_cv_nm_interface" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +# find the maximum length of command line arguments +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 +$as_echo_n "checking the maximum length of command line arguments... " >&6; } +if test "${lt_cv_sys_max_cmd_len+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly* | bitrig*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8 ; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ + = "XX$teststring$teststring"; } >/dev/null 2>&1 && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac + +fi + +if test -n $lt_cv_sys_max_cmd_len ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 +$as_echo "$lt_cv_sys_max_cmd_len" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 +$as_echo "none" >&6; } +fi +max_cmd_len=$lt_cv_sys_max_cmd_len + + + + + + +: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 +$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 +$as_echo "$xsi_shell" >&6; } + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 +$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } +lt_shell_append=no +( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 +$as_echo "$lt_shell_append" >&6; } + + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi + + + + + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 +$as_echo_n "checking for $LD option to reload object files... " >&6; } +if test "${lt_cv_ld_reload_flag+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_reload_flag='-r' +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 +$as_echo "$lt_cv_ld_reload_flag" >&6; } +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + darwin*) + if test "$GCC" = yes; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 +$as_echo_n "checking how to recognize dependent libraries... " >&6; } +if test "${lt_cv_deplibs_check_method+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given extended regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[4-9]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[3-9]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 +$as_echo "$lt_cv_deplibs_check_method" >&6; } +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AR+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_AR="ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +else + AR="$ac_cv_prog_AR" +fi + +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +test -z "$STRIP" && STRIP=: + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +test -z "$RANLIB" && RANLIB=: + + + + + + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 +$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } +if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32*) + symcode='[ABCDGISTW]' + ;; +hpux*) + if test "$host_cpu" = ia64; then + symcode='[ABCDEGRST]' + fi + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function + # and D for any global variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK '"\ +" {last_section=section; section=\$ 3};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5 + (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +$as_echo "failed" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } +fi + + + + + + + + + + + + + + + + + + + + + + +# Check whether --enable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then : + enableval=$enable_libtool_lock; +fi + +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 6467 "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 +$as_echo_n "checking whether the C compiler needs -belf... " >&6; } +if test "${lt_cv_cc_needs_belf+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_cc_needs_belf=yes +else + lt_cv_cc_needs_belf=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 +$as_echo "$lt_cv_cc_needs_belf" >&6; } + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks="$enable_libtool_lock" + + + case $host_os in + rhapsody* | darwin*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. +set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_DSYMUTIL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DSYMUTIL"; then + ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DSYMUTIL=$ac_cv_prog_DSYMUTIL +if test -n "$DSYMUTIL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 +$as_echo "$DSYMUTIL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DSYMUTIL"; then + ac_ct_DSYMUTIL=$DSYMUTIL + # Extract the first word of "dsymutil", so it can be a program name with args. +set dummy dsymutil; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DSYMUTIL"; then + ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL +if test -n "$ac_ct_DSYMUTIL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 +$as_echo "$ac_ct_DSYMUTIL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DSYMUTIL" = x; then + DSYMUTIL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DSYMUTIL=$ac_ct_DSYMUTIL + fi +else + DSYMUTIL="$ac_cv_prog_DSYMUTIL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. +set dummy ${ac_tool_prefix}nmedit; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_NMEDIT+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$NMEDIT"; then + ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +NMEDIT=$ac_cv_prog_NMEDIT +if test -n "$NMEDIT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 +$as_echo "$NMEDIT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_NMEDIT"; then + ac_ct_NMEDIT=$NMEDIT + # Extract the first word of "nmedit", so it can be a program name with args. +set dummy nmedit; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_NMEDIT"; then + ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_NMEDIT="nmedit" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT +if test -n "$ac_ct_NMEDIT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 +$as_echo "$ac_ct_NMEDIT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_NMEDIT" = x; then + NMEDIT=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + NMEDIT=$ac_ct_NMEDIT + fi +else + NMEDIT="$ac_cv_prog_NMEDIT" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. +set dummy ${ac_tool_prefix}lipo; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_LIPO+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$LIPO"; then + ac_cv_prog_LIPO="$LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_LIPO="${ac_tool_prefix}lipo" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +LIPO=$ac_cv_prog_LIPO +if test -n "$LIPO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 +$as_echo "$LIPO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_LIPO"; then + ac_ct_LIPO=$LIPO + # Extract the first word of "lipo", so it can be a program name with args. +set dummy lipo; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_LIPO"; then + ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_LIPO="lipo" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO +if test -n "$ac_ct_LIPO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 +$as_echo "$ac_ct_LIPO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_LIPO" = x; then + LIPO=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + LIPO=$ac_ct_LIPO + fi +else + LIPO="$ac_cv_prog_LIPO" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OTOOL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL"; then + ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OTOOL="${ac_tool_prefix}otool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL=$ac_cv_prog_OTOOL +if test -n "$OTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 +$as_echo "$OTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL"; then + ac_ct_OTOOL=$OTOOL + # Extract the first word of "otool", so it can be a program name with args. +set dummy otool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL"; then + ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OTOOL="otool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL +if test -n "$ac_ct_OTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 +$as_echo "$ac_ct_OTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OTOOL" = x; then + OTOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL=$ac_ct_OTOOL + fi +else + OTOOL="$ac_cv_prog_OTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool64; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OTOOL64+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL64"; then + ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL64=$ac_cv_prog_OTOOL64 +if test -n "$OTOOL64"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 +$as_echo "$OTOOL64" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL64"; then + ac_ct_OTOOL64=$OTOOL64 + # Extract the first word of "otool64", so it can be a program name with args. +set dummy otool64; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL64"; then + ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OTOOL64="otool64" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 +if test -n "$ac_ct_OTOOL64"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 +$as_echo "$ac_ct_OTOOL64" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OTOOL64" = x; then + OTOOL64=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL64=$ac_ct_OTOOL64 + fi +else + OTOOL64="$ac_cv_prog_OTOOL64" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 +$as_echo_n "checking for -single_module linker flag... " >&6; } +if test "${lt_cv_apple_cc_single_mod+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&5 + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 +$as_echo "$lt_cv_apple_cc_single_mod" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 +$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } +if test "${lt_cv_ld_exported_symbols_list+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_ld_exported_symbols_list=yes +else + lt_cv_ld_exported_symbols_list=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 +$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } + case $host_os in + rhapsody* | darwin1.[012]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[91]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[012]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac + +for ac_header in dlfcn.h +do : + ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default +" +if test "x$ac_cv_header_dlfcn_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DLFCN_H 1 +_ACEOF + +fi + +done + + + +# Set options + + + + enable_dlopen=no + + + enable_win32_dll=no + + + # Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then : + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_shared=yes +fi + + + + + + + + + + # Check whether --enable-static was given. +if test "${enable_static+set}" = set; then : + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_static=yes +fi + + + + + + + + + + +# Check whether --with-pic was given. +if test "${with_pic+set}" = set; then : + withval=$with_pic; pic_mode="$withval" +else + pic_mode=default +fi + + +test -z "$pic_mode" && pic_mode=default + + + + + + + + # Check whether --enable-fast-install was given. +if test "${enable_fast_install+set}" = set; then : + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_fast_install=yes +fi + + + + + + + + + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + + + + + + + + + + + + + + + + + + + + + + + + + +test -z "$LN_S" && LN_S="ln -s" + + + + + + + + + + + + + + +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 +$as_echo_n "checking for objdir... " >&6; } +if test "${lt_cv_objdir+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 +$as_echo "$lt_cv_objdir" >&6; } +objdir=$lt_cv_objdir + + + + + +cat >>confdefs.h <<_ACEOF +#define LT_OBJDIR "$lt_cv_objdir/" +_ACEOF + + + + + + + + + + + + + + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld="$lt_cv_prog_gnu_ld" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 +$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/${ac_tool_prefix}file; then + lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 +$as_echo_n "checking for file... " >&6; } +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/file; then + lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +# Use C for the default configuration in the libtool script + +lt_save_CC="$CC" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* + +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* + + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + +lt_prog_compiler_no_builtin_flag= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag=' -fno-builtin' + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:7729: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:7733: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + + + + + + + lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } + + if test "$GCC" = yes; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | cygwin* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + icc* | ecc* | ifort*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + xl*) + # IBM XL C 8.0/Fortran 10.1 on PPC + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-qpic' + lt_prog_compiler_static='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + esac + ;; + esac + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + rdos*) + lt_prog_compiler_static='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5 +$as_echo "$lt_prog_compiler_pic" >&6; } + + + + + + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if test "${lt_cv_prog_compiler_pic_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:8053: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:8057: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } + +if test x"$lt_cv_prog_compiler_pic_works" = xyes; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi + + + + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if test "${lt_cv_prog_compiler_static_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works=yes + fi + else + lt_cv_prog_compiler_static_works=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 +$as_echo "$lt_cv_prog_compiler_static_works" >&6; } + +if test x"$lt_cv_prog_compiler_static_works" = xyes; then + : +else + lt_prog_compiler_static= +fi + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test "${lt_cv_prog_compiler_c_o+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:8158: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:8162: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test "${lt_cv_prog_compiler_c_o+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:8213: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:8217: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } + if test "$hard_links" = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + runpath_var= + allow_undefined_flag= + always_export_symbols=no + archive_cmds= + archive_expsym_cmds= + compiler_needs_object=no + enable_shared_with_static_runtimes=no + export_dynamic_flag_spec= + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + hardcode_automatic=no + hardcode_direct=no + hardcode_direct_absolute=no + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld= + hardcode_libdir_separator= + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + inherit_rpath=no + link_all_deplibs=unknown + module_cmds= + module_expsym_cmds= + old_archive_from_new_cmds= + old_archive_from_expsyms_cmds= + thread_safe_flag_spec= + whole_archive_flag_spec= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi + ;; + + interix[3-9]*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu) + tmp_diet=no + if test "$host_os" = linux-dietlibc; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test "$tmp_diet" = no + then + tmp_addflag= + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + compiler_needs_object=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + xlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld='-rpath $libdir' + archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = no; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_direct_absolute=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + file_list_spec='${wl}-f,' + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' ${wl}-bernotok' + allow_undefined_flag=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + archive_cmds_need_lc=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes=yes + ;; + + darwin* | rhapsody*) + + + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + whole_archive_flag_spec='' + link_all_deplibs=yes + allow_undefined_flag="$_lt_dar_allow_undefined" + if test "$GCC" = "yes"; then + output_verbose_link_cmd=echo + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + + else + ld_shlibs=no + fi + + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly* | openbsd* | bitrig*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld='+b $libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo(void) {} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + inherit_rpath=yes + link_all_deplibs=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + hardcode_shlibpath_var=no + hardcode_direct_absolute=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + archive_cmds_need_lc='no' + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='${wl}' + archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' + fi + ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag='${wl}-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='${wl}-z,text' + allow_undefined_flag='${wl}-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-R,$libdir' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + export_dynamic_flag_spec='${wl}-Blargedynsym' + ;; + esac + fi + fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 +$as_echo "$ld_shlibs" >&6; } +test "$ld_shlibs" = no && can_build_shared=no + +with_gnu_ld=$with_gnu_ld + + + + + + + + + + + + + + + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + then + archive_cmds_need_lc=no + else + archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5 +$as_echo "$archive_cmds_need_lc" >&6; } + ;; + esac + fi + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } + +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[lt_foo]++; } + if (lt_freq[lt_foo] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[4-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[3-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # Some binutils ld are patched to set DT_RUNPATH + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : + shlibpath_overrides_runpath=yes +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux + need_lib_prefix=no + need_version=no + library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || + test -n "$runpath_var" || + test "X$hardcode_automatic" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 +$as_echo "$hardcode_action" >&6; } + +if test "$hardcode_action" = relink || + test "$inherit_rpath" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" +if test "x$ac_cv_func_shl_load" = x""yes; then : + lt_cv_dlopen="shl_load" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +$as_echo_n "checking for shl_load in -ldld... " >&6; } +if test "${ac_cv_lib_dld_shl_load+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_shl_load=yes +else + ac_cv_lib_dld_shl_load=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = x""yes; then : + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +else + ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" +if test "x$ac_cv_func_dlopen" = x""yes; then : + lt_cv_dlopen="dlopen" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 +$as_echo_n "checking for dlopen in -lsvld... " >&6; } +if test "${ac_cv_lib_svld_dlopen+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_svld_dlopen=yes +else + ac_cv_lib_svld_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 +$as_echo "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = x""yes; then : + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 +$as_echo_n "checking for dld_link in -ldld... " >&6; } +if test "${ac_cv_lib_dld_dld_link+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_dld_link=yes +else + ac_cv_lib_dld_dld_link=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 +$as_echo "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = x""yes; then : + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 +$as_echo_n "checking whether a program can dlopen itself... " >&6; } +if test "${lt_cv_dlopen_self+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line 10572 "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + exit (status); +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 +$as_echo "$lt_cv_dlopen_self" >&6; } + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 +$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } +if test "${lt_cv_dlopen_self_static+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line 10672 "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + exit (status); +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 +$as_echo "$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + + + + + + + + + + + + + + + + +striplib= +old_striplib= +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 +$as_echo_n "checking whether stripping libraries is possible... " >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; + esac +fi + + + + + + + + + + + + + # Report which library types will actually be built + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 +$as_echo_n "checking if libtool supports shared libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 +$as_echo "$can_build_shared" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 +$as_echo_n "checking whether to build shared libraries... " >&6; } + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[4-9]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 +$as_echo "$enable_shared" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 +$as_echo_n "checking whether to build static libraries... " >&6; } + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 +$as_echo "$enable_static" >&6; } + + + + +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + + + + + + + + + + + + + ac_config_commands="$ac_config_commands libtool" + + + + +# Only expand once: + + + + +# Check whether --enable-largefile was given. +if test "${enable_largefile+set}" = set; then : + enableval=$enable_largefile; +fi + +if test "$enable_largefile" != no; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 +$as_echo_n "checking for special C compiler options needed for large files... " >&6; } +if test "${ac_cv_sys_largefile_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF + if ac_fn_c_try_compile "$LINENO"; then : + break +fi +rm -f core conftest.err conftest.$ac_objext + CC="$CC -n32" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_largefile_CC=' -n32'; break +fi +rm -f core conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 +$as_echo "$ac_cv_sys_largefile_CC" >&6; } + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } +if test "${ac_cv_sys_file_offset_bits+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=64; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_file_offset_bits=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 +$as_echo "$ac_cv_sys_file_offset_bits" >&6; } +case $ac_cv_sys_file_offset_bits in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF +;; +esac +rm -rf conftest* + if test $ac_cv_sys_file_offset_bits = unknown; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 +$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } +if test "${ac_cv_sys_large_files+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=1; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_large_files=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 +$as_echo "$ac_cv_sys_large_files" >&6; } +case $ac_cv_sys_large_files in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF +;; +esac +rm -rf conftest* + fi +fi + + +backtrace_supported=yes + +if test -n "${with_target_subdir}"; then + # We are compiling a GCC library. We can assume that the unwind + # library exists. + BACKTRACE_FILE="backtrace.lo simple.lo" +else + ac_fn_c_check_header_mongrel "$LINENO" "unwind.h" "ac_cv_header_unwind_h" "$ac_includes_default" +if test "x$ac_cv_header_unwind_h" = x""yes; then : + ac_fn_c_check_func "$LINENO" "_Unwind_Backtrace" "ac_cv_func__Unwind_Backtrace" +if test "x$ac_cv_func__Unwind_Backtrace" = x""yes; then : + BACKTRACE_FILE="backtrace.lo simple.lo" +else + BACKTRACE_FILE="nounwind.lo" + backtrace_supported=no +fi + +else + BACKTRACE_FILE="nounwind.lo" + backtrace_supported=no +fi + + +fi + + +EXTRA_FLAGS= +if test -n "${with_target_subdir}"; then + EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -funwind-tables option" >&5 +$as_echo_n "checking for -funwind-tables option... " >&6; } +if test "${libbacktrace_cv_c_unwind_tables+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + CFLAGS_hold="$CFLAGS" + CFLAGS="$CFLAGS -funwind-tables" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +static int f() { return 0; } +int +main () +{ +return f(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libbacktrace_cv_c_unwind_tables=yes +else + libbacktrace_cv_c_unwind_tables=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$CFLAGS_hold" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_c_unwind_tables" >&5 +$as_echo "$libbacktrace_cv_c_unwind_tables" >&6; } + if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then + EXTRA_FLAGS=-funwind-tables + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -frandom-seed=string option" >&5 +$as_echo_n "checking for -frandom-seed=string option... " >&6; } +if test "${libbacktrace_cv_c_random_seed_string+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + CFLAGS_hold="$CFLAGS" + CFLAGS="$CFLAGS -frandom-seed=conftest.lo" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libbacktrace_cv_c_random_seed_string=yes +else + libbacktrace_cv_c_random_seed_string=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$CFLAGS_hold" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_c_random_seed_string" >&5 +$as_echo "$libbacktrace_cv_c_random_seed_string" >&6; } + if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then + EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +WARN_FLAGS= +save_CFLAGS="$CFLAGS" +for real_option in -W -Wall -Wwrite-strings -Wstrict-prototypes \ + -Wmissing-prototypes -Wold-style-definition \ + -Wmissing-format-attribute -Wcast-qual; do + # Do the check with the no- prefix removed since gcc silently + # accepts any -Wno-* option on purpose + case $real_option in + -Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;; + *) option=$real_option ;; + esac + as_acx_Woption=`$as_echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh` + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports $option" >&5 +$as_echo_n "checking whether $CC supports $option... " >&6; } +if { as_var=$as_acx_Woption; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + CFLAGS="$option" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$as_acx_Woption=yes" +else + eval "$as_acx_Woption=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +eval ac_res=\$$as_acx_Woption + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if test `eval 'as_val=${'$as_acx_Woption'};$as_echo "$as_val"'` = yes; then : + WARN_FLAGS="$WARN_FLAGS${WARN_FLAGS:+ }$real_option" +fi + done +CFLAGS="$save_CFLAGS" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +if test -n "${with_target_subdir}"; then + WARN_FLAGS="$WARN_FLAGS -Werror" +fi + + + +if test -n "${with_target_subdir}"; then + + +# Check whether --with-system-libunwind was given. +if test "${with_system_libunwind+set}" = set; then : + withval=$with_system_libunwind; +fi + + # If system-libunwind was not specifically set, pick a default setting. + if test x$with_system_libunwind = x; then + case ${target} in + ia64-*-hpux*) with_system_libunwind=yes ;; + *) with_system_libunwind=no ;; + esac + fi + # Based on system-libunwind and target, do we have ipinfo? + if test x$with_system_libunwind = xyes; then + case ${target} in + ia64-*-*) have_unwind_getipinfo=no ;; + *) have_unwind_getipinfo=yes ;; + esac + else + # Darwin before version 9 does not have _Unwind_GetIPInfo. + + case ${target} in + *-*-darwin[3-8]|*-*-darwin[3-8].*) have_unwind_getipinfo=no ;; + *) have_unwind_getipinfo=yes ;; + esac + + fi + + if test x$have_unwind_getipinfo = xyes; then + +$as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h + + fi + +else + ac_save_CFFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror-implicit-function-declaration" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _Unwind_GetIPInfo" >&5 +$as_echo_n "checking for _Unwind_GetIPInfo... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include "unwind.h" + struct _Unwind_Context *context; + int ip_before_insn = 0; +int +main () +{ +return _Unwind_GetIPInfo (context, &ip_before_insn); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + have_unwind_getipinfo=yes +else + have_unwind_getipinfo=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$ac_save_CFLAGS" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_unwind_getipinfo" >&5 +$as_echo "$have_unwind_getipinfo" >&6; } + if test "$have_unwind_getipinfo" = "yes"; then + +$as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h + + fi +fi + +# Enable --enable-host-shared. +# Check whether --enable-host-shared was given. +if test "${enable_host_shared+set}" = set; then : + enableval=$enable_host_shared; PIC_FLAG=-fPIC +else + PIC_FLAG= +fi + + + +# Test for __sync support. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking __sync extensions" >&5 +$as_echo_n "checking __sync extensions... " >&6; } +if test "${libbacktrace_cv_sys_sync+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "${with_target_subdir}"; then + case "${host}" in + hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;; + *) libbacktrace_cv_sys_sync=yes ;; + esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +int +main () +{ +__sync_bool_compare_and_swap (&i, i, i); + __sync_lock_test_and_set (&i, 1); + __sync_lock_release (&i); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + libbacktrace_cv_sys_sync=yes +else + libbacktrace_cv_sys_sync=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_sys_sync" >&5 +$as_echo "$libbacktrace_cv_sys_sync" >&6; } +BACKTRACE_SUPPORTS_THREADS=0 +if test "$libbacktrace_cv_sys_sync" = "yes"; then + BACKTRACE_SUPPORTS_THREADS=1 + +$as_echo "#define HAVE_SYNC_FUNCTIONS 1" >>confdefs.h + +fi + + +# Test for __atomic support. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking __atomic extensions" >&5 +$as_echo_n "checking __atomic extensions... " >&6; } +if test "${libbacktrace_cv_sys_atomic+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "${with_target_subdir}"; then + libbacktrace_cv_sys_atomic=yes + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +int +main () +{ +__atomic_load_n (&i, __ATOMIC_ACQUIRE); + __atomic_store_n (&i, 1, __ATOMIC_RELEASE); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + libbacktrace_cv_sys_atomic=yes +else + libbacktrace_cv_sys_atomic=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_sys_atomic" >&5 +$as_echo "$libbacktrace_cv_sys_atomic" >&6; } +if test "$libbacktrace_cv_sys_atomic" = "yes"; then + +$as_echo "#define HAVE_ATOMIC_FUNCTIONS 1" >>confdefs.h + +fi + +# The library needs to be able to read the executable itself. Compile +# a file to determine the executable format. The awk script +# filetype.awk prints out the file type. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking output filetype" >&5 +$as_echo_n "checking output filetype... " >&6; } +if test "${libbacktrace_cv_sys_filetype+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + filetype= +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +int +main () +{ +int j; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext` +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "compiler failed +See \`config.log' for more details." "$LINENO" 5; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +libbacktrace_cv_sys_filetype=$filetype +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_sys_filetype" >&5 +$as_echo "$libbacktrace_cv_sys_filetype" >&6; } + +# Match the file type to decide what files to compile. +FORMAT_FILE= +backtrace_supports_data=yes +case "$libbacktrace_cv_sys_filetype" in +elf*) FORMAT_FILE="elf.lo" ;; +pecoff) FORMAT_FILE="pecoff.lo" + backtrace_supports_data=no + ;; +xcoff*) FORMAT_FILE="xcoff.lo" + backtrace_supports_data=no + ;; +macho*) FORMAT_FILE="macho.lo" + backtrace_supports_data=no + ;; +*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not determine output file type" >&5 +$as_echo "$as_me: WARNING: could not determine output file type" >&2;} + FORMAT_FILE="unknown.lo" + backtrace_supported=no + ;; +esac + + +# ELF defines. +elfsize= +case "$libbacktrace_cv_sys_filetype" in +elf32) elfsize=32 ;; +elf64) elfsize=64 ;; +*) elfsize=unused +esac + +cat >>confdefs.h <<_ACEOF +#define BACKTRACE_ELF_SIZE $elfsize +_ACEOF + + +# XCOFF defines. +xcoffsize= +case "$libbacktrace_cv_sys_filetype" in +xcoff32) xcoffsize=32 ;; +xcoff64) xcoffsize=64 ;; +*) xcoffsize=unused +esac + +cat >>confdefs.h <<_ACEOF +#define BACKTRACE_XCOFF_SIZE $xcoffsize +_ACEOF + + +BACKTRACE_SUPPORTED=0 +if test "$backtrace_supported" = "yes"; then + BACKTRACE_SUPPORTED=1 +fi + + +BACKTRACE_SUPPORTS_DATA=0 +if test "$backtrace_supports_data" = "yes"; then + BACKTRACE_SUPPORTS_DATA=1 +fi + + +for ac_header in sys/mman.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_mman_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_MMAN_H 1 +_ACEOF + +fi + +done + +if test "$ac_cv_header_sys_mman_h" = "no"; then + have_mmap=no +else + if test -n "${with_target_subdir}"; then + # When built as a GCC target library, we can't do a link test. We + # simply assume that if we have mman.h, we have mmap. + have_mmap=yes + case "${host}" in + spu-*-*|*-*-msdosdjgpp) + # The SPU does not have mmap, but it has a sys/mman.h header file + # containing "mmap_eaddr" and the mmap flags, confusing the test. + # DJGPP also has sys/man.h, but no mmap + have_mmap=no ;; + esac + else + ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap" +if test "x$ac_cv_func_mmap" = x""yes; then : + have_mmap=yes +else + have_mmap=no +fi + + fi +fi + +case "${host_os}" in +darwin*) + have_mmap=no ;; +esac + +if test "$have_mmap" = "no"; then + VIEW_FILE=read.lo + ALLOC_FILE=alloc.lo +else + VIEW_FILE=mmapio.lo + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) + #error no MAP_ANONYMOUS +#endif + +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ALLOC_FILE=alloc.lo +else + ALLOC_FILE=alloc.lo +fi +rm -f conftest.err conftest.$ac_ext +fi + + + +BACKTRACE_USES_MALLOC=0 +if test "$ALLOC_FILE" = "alloc.lo"; then + BACKTRACE_USES_MALLOC=1 +fi + + +# Check for dl_iterate_phdr. +for ac_header in link.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "link.h" "ac_cv_header_link_h" "$ac_includes_default" +if test "x$ac_cv_header_link_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINK_H 1 +_ACEOF + +fi + +done + +if test "$ac_cv_header_link_h" = "no"; then + have_dl_iterate_phdr=no +else + if test -n "${with_target_subdir}"; then + # When built as a GCC target library, we can't do a link test. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "dl_iterate_phdr" >/dev/null 2>&1; then : + have_dl_iterate_phdr=yes +else + have_dl_iterate_phdr=no +fi +rm -f conftest* + + case "${host}" in + *-*-solaris2.10*) + # Avoid dl_iterate_phdr on Solaris 10, where it is in the + # header file but is only in -ldl. + have_dl_iterate_phdr=no ;; + esac + else + ac_fn_c_check_func "$LINENO" "dl_iterate_phdr" "ac_cv_func_dl_iterate_phdr" +if test "x$ac_cv_func_dl_iterate_phdr" = x""yes; then : + have_dl_iterate_phdr=yes +else + have_dl_iterate_phdr=no +fi + + fi +fi +if test "$have_dl_iterate_phdr" = "yes"; then + +$as_echo "#define HAVE_DL_ITERATE_PHDR 1" >>confdefs.h + +fi + +# Check for loadquery. +for ac_header in sys/ldr.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/ldr.h" "ac_cv_header_sys_ldr_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_ldr_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_LDR_H 1 +_ACEOF + +fi + +done + +if test "$ac_cv_header_sys_ldr_h" = "no"; then + have_loadquery=no +else + if test -n "${with_target_subdir}"; then + # When built as a GCC target library, we can't do a link test. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "loadquery" >/dev/null 2>&1; then : + have_loadquery=yes +else + have_loadquery=no +fi +rm -f conftest* + + else + ac_fn_c_check_func "$LINENO" "loadquery" "ac_cv_func_loadquery" +if test "x$ac_cv_func_loadquery" = x""yes; then : + have_loadquery=yes +else + have_loadquery=no +fi + + fi +fi +if test "$have_loadquery" = "yes"; then + +$as_echo "#define HAVE_LOADQUERY 1" >>confdefs.h + +fi + +# Check for the fcntl function. +if test -n "${with_target_subdir}"; then + case "${host}" in + *-*-mingw*) have_fcntl=no ;; + spu-*-*) have_fcntl=no ;; + *) have_fcntl=yes ;; + esac +else + ac_fn_c_check_func "$LINENO" "fcntl" "ac_cv_func_fcntl" +if test "x$ac_cv_func_fcntl" = x""yes; then : + have_fcntl=yes +else + have_fcntl=no +fi + +fi +if test "$have_fcntl" = "yes"; then + +$as_echo "#define HAVE_FCNTL 1" >>confdefs.h + +fi + +ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default" +if test "x$ac_cv_have_decl_strnlen" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRNLEN $ac_have_decl +_ACEOF + +for ac_func in lstat readlink +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +# Check for getexecname function. +if test -n "${with_target_subdir}"; then + case "${host}" in + *-*-solaris2*) have_getexecname=yes ;; + *) have_getexecname=no ;; + esac +else + ac_fn_c_check_func "$LINENO" "getexecname" "ac_cv_func_getexecname" +if test "x$ac_cv_func_getexecname" = x""yes; then : + have_getexecname=yes +else + have_getexecname=no +fi + +fi +if test "$have_getexecname" = "yes"; then + +$as_echo "#define HAVE_GETEXECNAME 1" >>confdefs.h + +fi + +# Check for the clock_gettime function. +for ac_func in clock_gettime +do : + ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime" +if test "x$ac_cv_func_clock_gettime" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_CLOCK_GETTIME 1 +_ACEOF + +fi +done + +clock_gettime_link= +# At least for glibc, clock_gettime is in librt. But don't +# pull that in if it still doesn't give us the function we want. This +# test is copied from libgomp, and modified to not link in -lrt as +# we're using this for test timing only. +if test "$ac_cv_func_clock_gettime" = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5 +$as_echo_n "checking for clock_gettime in -lrt... " >&6; } +if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lrt $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char clock_gettime (); +int +main () +{ +return clock_gettime (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_rt_clock_gettime=yes +else + ac_cv_lib_rt_clock_gettime=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5 +$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } +if test "x$ac_cv_lib_rt_clock_gettime" = x""yes; then : + CLOCK_GETTIME_LINK=-lrt + +$as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h + +fi + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is supported" >&5 +$as_echo_n "checking whether -pthread is supported... " >&6; } +if test "${libgo_cv_lib_pthread+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + CFLAGS_hold=$CFLAGS +CFLAGS="$CFLAGS -pthread" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libgo_cv_lib_pthread=yes +else + libgo_cv_lib_pthread=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$CFLAGS_hold +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgo_cv_lib_pthread" >&5 +$as_echo "$libgo_cv_lib_pthread" >&6; } +PTHREAD_CFLAGS= +if test "$libgo_cv_lib_pthread" = yes; then + PTHREAD_CFLAGS=-pthread +fi + + + if test "$libgo_cv_lib_pthread" = yes; then + HAVE_PTHREAD_TRUE= + HAVE_PTHREAD_FALSE='#' +else + HAVE_PTHREAD_TRUE='#' + HAVE_PTHREAD_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 +$as_echo_n "checking for compress in -lz... " >&6; } +if test "${ac_cv_lib_z_compress+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char compress (); +int +main () +{ +return compress (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_z_compress=yes +else + ac_cv_lib_z_compress=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 +$as_echo "$ac_cv_lib_z_compress" >&6; } +if test "x$ac_cv_lib_z_compress" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF + + LIBS="-lz $LIBS" + +fi + +if test $ac_cv_lib_z_compress = "yes"; then + +$as_echo "#define HAVE_ZLIB 1" >>confdefs.h + +fi + if test "$ac_cv_lib_z_compress" = yes; then + HAVE_ZLIB_TRUE= + HAVE_ZLIB_FALSE='#' +else + HAVE_ZLIB_TRUE='#' + HAVE_ZLIB_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether --compress-debug-sections is supported" >&5 +$as_echo_n "checking whether --compress-debug-sections is supported... " >&6; } +if test "${libgo_cv_ld_compress+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + LDFLAGS_hold=$LDFLAGS +LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + libgo_cv_ld_compress=yes +else + libgo_cv_ld_compress=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LDFLAGS=$LDFLAGS_hold +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgo_cv_ld_compress" >&5 +$as_echo "$libgo_cv_ld_compress" >&6; } + if test "$libgo_cv_ld_compress" = yes; then + HAVE_COMPRESSED_DEBUG_TRUE= + HAVE_COMPRESSED_DEBUG_FALSE='#' +else + HAVE_COMPRESSED_DEBUG_TRUE='#' + HAVE_COMPRESSED_DEBUG_FALSE= +fi + + + +# Extract the first word of "objcopy", so it can be a program name with args. +set dummy objcopy; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OBJCOPY+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJCOPY"; then + ac_cv_prog_OBJCOPY="$OBJCOPY" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OBJCOPY="objcopy" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJCOPY=$ac_cv_prog_OBJCOPY +if test -n "$OBJCOPY"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJCOPY" >&5 +$as_echo "$OBJCOPY" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether objcopy supports debuglink" >&5 +$as_echo_n "checking whether objcopy supports debuglink... " >&6; } +if test "${libbacktrace_cv_objcopy_debuglink+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "${with_target_subdir}"; then + libbacktrace_cv_objcopy_debuglink=no +elif ${OBJCOPY} --add-gnu-debuglink=x /bin/ls /tmp/ls$$; then + rm -f /tmp/ls$$ + libbacktrace_cv_objcopy_debuglink=yes +else + libbacktrace_cv_objcopy_debuglink=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_objcopy_debuglink" >&5 +$as_echo "$libbacktrace_cv_objcopy_debuglink" >&6; } + if test "$libbacktrace_cv_objcopy_debuglink" = yes; then + HAVE_OBJCOPY_DEBUGLINK_TRUE= + HAVE_OBJCOPY_DEBUGLINK_FALSE='#' +else + HAVE_OBJCOPY_DEBUGLINK_TRUE='#' + HAVE_OBJCOPY_DEBUGLINK_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether tests can run" >&5 +$as_echo_n "checking whether tests can run... " >&6; } +if test "${libbacktrace_cv_sys_native+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + libbacktrace_cv_sys_native=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + libbacktrace_cv_sys_native=yes +else + libbacktrace_cv_sys_native=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_sys_native" >&5 +$as_echo "$libbacktrace_cv_sys_native" >&6; } + if test "$libbacktrace_cv_sys_native" = "yes"; then + NATIVE_TRUE= + NATIVE_FALSE='#' +else + NATIVE_TRUE='#' + NATIVE_FALSE= +fi + + +if test "${multilib}" = "yes"; then + multilib_arg="--enable-multilib" +else + multilib_arg= +fi + +ac_config_files="$ac_config_files Makefile backtrace-supported.h" + + +# We need multilib support, but only if configuring for the target. +ac_config_commands="$ac_config_commands default" + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + +if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then + as_fn_error "conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_PTHREAD_TRUE}" && test -z "${HAVE_PTHREAD_FALSE}"; then + as_fn_error "conditional \"HAVE_PTHREAD\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_ZLIB_TRUE}" && test -z "${HAVE_ZLIB_FALSE}"; then + as_fn_error "conditional \"HAVE_ZLIB\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_COMPRESSED_DEBUG_TRUE}" && test -z "${HAVE_COMPRESSED_DEBUG_FALSE}"; then + as_fn_error "conditional \"HAVE_COMPRESSED_DEBUG\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_OBJCOPY_DEBUGLINK_TRUE}" && test -z "${HAVE_OBJCOPY_DEBUGLINK_FALSE}"; then + as_fn_error "conditional \"HAVE_OBJCOPY_DEBUGLINK\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${NATIVE_TRUE}" && test -z "${NATIVE_FALSE}"; then + as_fn_error "conditional \"NATIVE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + +: ${CONFIG_STATUS=./config.status} +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by package-unused $as_me version-unused, which was +generated by GNU Autoconf 2.64. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to the package provider." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_version="\\ +package-unused config.status version-unused +configured by $0, generated by GNU Autoconf 2.64, + with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2009 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# + +srcdir="$srcdir" +host="$host" +target="$target" +with_multisubdir="$with_multisubdir" +with_multisrctop="$with_multisrctop" +with_target_subdir="$with_target_subdir" +ac_configure_args="${multilib_arg} ${ac_configure_args}" +multi_basedir="$multi_basedir" +CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} +CC="$CC" + + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' +macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' +enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' +enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' +pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' +enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' +host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' +host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' +host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' +build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' +build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' +build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' +SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' +Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' +GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' +EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' +FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' +LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' +NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' +LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' +max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' +ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' +exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' +lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' +lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' +lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' +reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' +reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' +deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' +file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' +AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' +AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' +STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' +RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' +old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' +CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' +CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' +compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' +GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' +objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' +SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' +ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' +MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' +need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' +DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' +NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' +LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' +OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' +OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' +libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' +shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' +extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' +export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' +module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' +module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' +with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' +allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' +no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' +inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' +link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' +fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' +always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' +export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' +exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' +include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' +prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' +file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' +variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' +need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' +need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' +version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' +runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' +shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' +shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' +libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' +library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' +soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' +postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' +finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' +sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' +sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' +old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' +striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' + +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# Quote evaled strings. +for var in SED \ +GREP \ +EGREP \ +FGREP \ +LD \ +NM \ +LN_S \ +lt_SP2NL \ +lt_NL2SP \ +reload_flag \ +deplibs_check_method \ +file_magic_cmd \ +AR \ +AR_FLAGS \ +STRIP \ +RANLIB \ +CC \ +CFLAGS \ +compiler \ +lt_cv_sys_global_symbol_pipe \ +lt_cv_sys_global_symbol_to_cdecl \ +lt_cv_sys_global_symbol_to_c_name_address \ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +SHELL \ +ECHO \ +lt_prog_compiler_no_builtin_flag \ +lt_prog_compiler_wl \ +lt_prog_compiler_pic \ +lt_prog_compiler_static \ +lt_cv_prog_compiler_c_o \ +need_locks \ +DSYMUTIL \ +NMEDIT \ +LIPO \ +OTOOL \ +OTOOL64 \ +shrext_cmds \ +export_dynamic_flag_spec \ +whole_archive_flag_spec \ +compiler_needs_object \ +with_gnu_ld \ +allow_undefined_flag \ +no_undefined_flag \ +hardcode_libdir_flag_spec \ +hardcode_libdir_flag_spec_ld \ +hardcode_libdir_separator \ +fix_srcfile_path \ +exclude_expsyms \ +include_expsyms \ +file_list_spec \ +variables_saved_for_relink \ +libname_spec \ +library_names_spec \ +soname_spec \ +finish_eval \ +old_striplib \ +striplib; do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in reload_cmds \ +old_postinstall_cmds \ +old_postuninstall_cmds \ +old_archive_cmds \ +extract_expsyms_cmds \ +old_archive_from_new_cmds \ +old_archive_from_expsyms_cmds \ +archive_cmds \ +archive_expsym_cmds \ +module_cmds \ +module_expsym_cmds \ +export_symbols_cmds \ +prelink_cmds \ +postinstall_cmds \ +postuninstall_cmds \ +finish_cmds \ +sys_lib_search_path_spec \ +sys_lib_dlsearch_path_spec; do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Fix-up fallback echo if it was mangled by the above quoting rules. +case \$lt_ECHO in +*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` + ;; +esac + +ac_aux_dir='$ac_aux_dir' +xsi_shell='$xsi_shell' +lt_shell_append='$lt_shell_append' + +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + + + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile' + + + + +# Variables needed in config.status (file generation) which aren't already +# passed by autoconf. +SUBDIRS="$SUBDIRS" + + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "backtrace-supported.h") CONFIG_FILES="$CONFIG_FILES backtrace-supported.h" ;; + "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; + + *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\).*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\).*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || as_fn_error "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then + break + elif $ac_last_try; then + as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "default-1":C) +# Only add multilib support code if we just rebuilt the top-level +# Makefile. +case " $CONFIG_FILES " in + *" Makefile "*) + ac_file=Makefile . ${multi_basedir}/config-ml.in + ;; +esac ;; + "libtool":C) + + # See if we are running on zsh, and set the options which allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + + cfgfile="${ofile}T" + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL + +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +# The names of the tagged configurations supported by this script. +available_tags="" + +# ### BEGIN LIBTOOL CONFIG + +# Which release of libtool.m4 was used? +macro_version=$macro_version +macro_revision=$macro_revision + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# What type of objects to build. +pic_mode=$pic_mode + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="\$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP=$lt_GREP + +# An ERE matcher. +EGREP=$lt_EGREP + +# A literal string matcher. +FGREP=$lt_FGREP + +# A BSD- or MS-compatible name lister. +NM=$lt_NM + +# Whether we need soft or hard links. +LN_S=$lt_LN_S + +# What is the maximum length of a command? +max_cmd_len=$max_cmd_len + +# Object file suffix (normally "o"). +objext=$ac_objext + +# Executable file suffix (normally ""). +exeext=$exeext + +# whether the shell understands "unset". +lt_unset=$lt_unset + +# turn spaces into newlines. +SP2NL=$lt_lt_SP2NL + +# turn newlines into spaces. +NL2SP=$lt_lt_NL2SP + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == "file_magic". +file_magic_cmd=$lt_file_magic_cmd + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A symbol stripping program. +STRIP=$lt_STRIP + +# Commands used to install an old-style archive. +RANLIB=$lt_RANLIB +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# A C compiler. +LTCC=$lt_CC + +# LTCC compiler flags. +LTCFLAGS=$lt_CFLAGS + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that does not interpret backslashes. +ECHO=$lt_ECHO + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=$MAGIC_CMD + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL=$lt_DSYMUTIL + +# Tool to change global to local symbols on Mac OS X. +NMEDIT=$lt_NMEDIT + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO=$lt_LIPO + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL=$lt_OTOOL + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64=$lt_OTOOL64 + +# Old archive suffix (normally "a"). +libext=$libext + +# Shared library suffix (normally ".so"). +shrext_cmds=$lt_shrext_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink=$lt_variables_saved_for_relink + +# Do we need the "lib" prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Library versioning type. +version_type=$version_type + +# Shared library runtime path variable. +runpath_var=$runpath_var + +# Shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Command to use after installation of a shared archive. +postinstall_cmds=$lt_postinstall_cmds + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval=$lt_finish_eval + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Compile-time system search path for libraries. +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + + +# The linker used to build libraries. +LD=$lt_LD + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds + +# A language specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU compiler? +with_gcc=$GCC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# If ld is used when linking, flag to hardcode \$libdir into a binary +# during linking. This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct + +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \${shlibpath_var} if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path=$lt_fix_srcfile_path + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# ### END LIBTOOL CONFIG + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + +ltmain="$ac_aux_dir/ltmain.sh" + + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + case $xsi_shell in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $* )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + +_LT_EOF + ;; + *) # Bourne compatible functions. + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; + esac +} + +# sed scripts: +my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' +my_sed_long_arg='1s/^-[^=]*=//' + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` + func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` +} + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$@"` +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` +} + +_LT_EOF +esac + +case $lt_shell_append in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$1+=\$2" +} +_LT_EOF + ;; + *) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$1=\$$1\$2" +} + +_LT_EOF + ;; + esac + + + sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + ;; + "default":C) if test -n "$CONFIG_FILES"; then + if test -n "${with_target_subdir}"; then + # Multilibs need MULTISUBDIR defined correctly in certain makefiles so + # that multilib installs will end up installed in the correct place. + # The testsuite needs it for multilib-aware ABI baseline files. + # To work around this not being passed down from config-ml.in -> + # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually + # append it here. Only modify Makefiles that have just been created. + # + # Also, get rid of this simulated-VPATH thing that automake does. + cat > vpsed << \_EOF + s!`test -f '$<' || echo '$(srcdir)/'`!! +_EOF + for i in $SUBDIRS; do + case $CONFIG_FILES in + *${i}/Makefile*) + #echo "Adding MULTISUBDIR to $i/Makefile" + sed -f vpsed $i/Makefile > tmp + grep '^MULTISUBDIR =' Makefile >> tmp + mv tmp $i/Makefile + ;; + esac + done + rm vpsed + fi + fi + ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit $? +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/configure.ac b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/configure.ac new file mode 100644 index 0000000..b9056cc --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/configure.ac @@ -0,0 +1,512 @@ +# configure.ac -- Backtrace configure script. +# Copyright (C) 2012-2018 Free Software Foundation, Inc. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: + +# (1) Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. + +# (2) Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. + +# (3) The name of the author may not be used to +# endorse or promote products derived from this software without +# specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +AC_PREREQ(2.64) +AC_INIT(package-unused, version-unused,, libbacktrace) +AC_CONFIG_SRCDIR(backtrace.h) +AC_CONFIG_HEADER(config.h) +AC_CONFIG_MACRO_DIR(config) + +# with_target_subdir is used when configured as part of a GCC tree. +if test -n "${with_target_subdir}"; then + AM_ENABLE_MULTILIB(, ..) +fi + +AC_CANONICAL_SYSTEM +target_alias=${target_alias-$host_alias} + +AC_USE_SYSTEM_EXTENSIONS + +libtool_VERSION=1:0:0 +AC_SUBST(libtool_VERSION) + +# 1.11.1: Require that version of automake. +# foreign: Don't require README, INSTALL, NEWS, etc. +# no-define: Don't define PACKAGE and VERSION. +# no-dependencies: Don't generate automatic dependencies. +# (because it breaks when using bootstrap-lean, since some of the +# headers are gone at "make install" time). +# -Wall: Issue all automake warnings. +# -Wno-portability: Don't warn about constructs supported by GNU make. +# (because GCC requires GNU make anyhow). +AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability]) + +AM_MAINTAINER_MODE + +AC_ARG_WITH(target-subdir, +[ --with-target-subdir=SUBDIR Configuring in a subdirectory for target]) + +# We must force CC to /not/ be precious variables; otherwise +# the wrong, non-multilib-adjusted value will be used in multilibs. +# As a side effect, we have to subst CFLAGS ourselves. +m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS]) +m4_define([_AC_ARG_VAR_PRECIOUS],[]) +AC_PROG_CC +m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) + +AC_SUBST(CFLAGS) + +AC_PROG_AWK +case "$AWK" in +"") AC_MSG_ERROR([can't build without awk]) ;; +esac + +LT_INIT +AM_PROG_LIBTOOL + +AC_SYS_LARGEFILE + +backtrace_supported=yes + +if test -n "${with_target_subdir}"; then + # We are compiling a GCC library. We can assume that the unwind + # library exists. + BACKTRACE_FILE="backtrace.lo simple.lo" +else + AC_CHECK_HEADER([unwind.h], + [AC_CHECK_FUNC([_Unwind_Backtrace], + [BACKTRACE_FILE="backtrace.lo simple.lo"], + [BACKTRACE_FILE="nounwind.lo" + backtrace_supported=no])], + [BACKTRACE_FILE="nounwind.lo" + backtrace_supported=no]) +fi +AC_SUBST(BACKTRACE_FILE) + +EXTRA_FLAGS= +if test -n "${with_target_subdir}"; then + EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@" +else + AC_CACHE_CHECK([for -funwind-tables option], + [libbacktrace_cv_c_unwind_tables], + [CFLAGS_hold="$CFLAGS" + CFLAGS="$CFLAGS -funwind-tables" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([static int f() { return 0; }], [return f();])], + [libbacktrace_cv_c_unwind_tables=yes], + [libbacktrace_cv_c_unwind_tables=no]) + CFLAGS="$CFLAGS_hold"]) + if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then + EXTRA_FLAGS=-funwind-tables + fi + AC_CACHE_CHECK([for -frandom-seed=string option], + [libbacktrace_cv_c_random_seed_string], + [CFLAGS_hold="$CFLAGS" + CFLAGS="$CFLAGS -frandom-seed=conftest.lo" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [return 0;])], + [libbacktrace_cv_c_random_seed_string=yes], + [libbacktrace_cv_c_random_seed_string=no]) + CFLAGS="$CFLAGS_hold"]) + if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then + EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@" + fi +fi +AC_SUBST(EXTRA_FLAGS) + +ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \ + -Wmissing-prototypes -Wold-style-definition \ + -Wmissing-format-attribute -Wcast-qual], + [WARN_FLAGS]) + +if test -n "${with_target_subdir}"; then + WARN_FLAGS="$WARN_FLAGS -Werror" +fi + +AC_SUBST(WARN_FLAGS) + +if test -n "${with_target_subdir}"; then + GCC_CHECK_UNWIND_GETIPINFO +else + ac_save_CFFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror-implicit-function-declaration" + AC_MSG_CHECKING([for _Unwind_GetIPInfo]) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include "unwind.h" + struct _Unwind_Context *context; + int ip_before_insn = 0;], + [return _Unwind_GetIPInfo (context, &ip_before_insn);])], + [have_unwind_getipinfo=yes], [have_unwind_getipinfo=no]) + CFLAGS="$ac_save_CFLAGS" + AC_MSG_RESULT([$have_unwind_getipinfo]) + if test "$have_unwind_getipinfo" = "yes"; then + AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.]) + fi +fi + +# Enable --enable-host-shared. +AC_ARG_ENABLE(host-shared, +[AS_HELP_STRING([--enable-host-shared], + [build host code as shared libraries])], +[PIC_FLAG=-fPIC], [PIC_FLAG=]) +AC_SUBST(PIC_FLAG) + +# Test for __sync support. +AC_CACHE_CHECK([__sync extensions], +[libbacktrace_cv_sys_sync], +[if test -n "${with_target_subdir}"; then + case "${host}" in + hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;; + *) libbacktrace_cv_sys_sync=yes ;; + esac + else + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([int i;], + [__sync_bool_compare_and_swap (&i, i, i); + __sync_lock_test_and_set (&i, 1); + __sync_lock_release (&i);])], + [libbacktrace_cv_sys_sync=yes], + [libbacktrace_cv_sys_sync=no]) + fi]) +BACKTRACE_SUPPORTS_THREADS=0 +if test "$libbacktrace_cv_sys_sync" = "yes"; then + BACKTRACE_SUPPORTS_THREADS=1 + AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1, + [Define to 1 if you have the __sync functions]) +fi +AC_SUBST(BACKTRACE_SUPPORTS_THREADS) + +# Test for __atomic support. +AC_CACHE_CHECK([__atomic extensions], +[libbacktrace_cv_sys_atomic], +[if test -n "${with_target_subdir}"; then + libbacktrace_cv_sys_atomic=yes + else + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([int i;], + [__atomic_load_n (&i, __ATOMIC_ACQUIRE); + __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])], + [libbacktrace_cv_sys_atomic=yes], + [libbacktrace_cv_sys_atomic=no]) + fi]) +if test "$libbacktrace_cv_sys_atomic" = "yes"; then + AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1, + [Define to 1 if you have the __atomic functions]) +fi + +# The library needs to be able to read the executable itself. Compile +# a file to determine the executable format. The awk script +# filetype.awk prints out the file type. +AC_CACHE_CHECK([output filetype], +[libbacktrace_cv_sys_filetype], +[filetype= +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([int i;], [int j;])], + [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`], + [AC_MSG_FAILURE([compiler failed])]) +libbacktrace_cv_sys_filetype=$filetype]) + +# Match the file type to decide what files to compile. +FORMAT_FILE= +backtrace_supports_data=yes +case "$libbacktrace_cv_sys_filetype" in +elf*) FORMAT_FILE="elf.lo" ;; +pecoff) FORMAT_FILE="pecoff.lo" + backtrace_supports_data=no + ;; +xcoff*) FORMAT_FILE="xcoff.lo" + backtrace_supports_data=no + ;; +macho*) FORMAT_FILE="macho.lo" + backtrace_supports_data=no + ;; +*) AC_MSG_WARN([could not determine output file type]) + FORMAT_FILE="unknown.lo" + backtrace_supported=no + ;; +esac +AC_SUBST(FORMAT_FILE) + +# ELF defines. +elfsize= +case "$libbacktrace_cv_sys_filetype" in +elf32) elfsize=32 ;; +elf64) elfsize=64 ;; +*) elfsize=unused +esac +AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64]) + +# XCOFF defines. +xcoffsize= +case "$libbacktrace_cv_sys_filetype" in +xcoff32) xcoffsize=32 ;; +xcoff64) xcoffsize=64 ;; +*) xcoffsize=unused +esac +AC_DEFINE_UNQUOTED([BACKTRACE_XCOFF_SIZE], [$xcoffsize], [XCOFF size: 32 or 64]) + +BACKTRACE_SUPPORTED=0 +if test "$backtrace_supported" = "yes"; then + BACKTRACE_SUPPORTED=1 +fi +AC_SUBST(BACKTRACE_SUPPORTED) + +BACKTRACE_SUPPORTS_DATA=0 +if test "$backtrace_supports_data" = "yes"; then + BACKTRACE_SUPPORTS_DATA=1 +fi +AC_SUBST(BACKTRACE_SUPPORTS_DATA) + +AC_CHECK_HEADERS(sys/mman.h) +if test "$ac_cv_header_sys_mman_h" = "no"; then + have_mmap=no +else + if test -n "${with_target_subdir}"; then + # When built as a GCC target library, we can't do a link test. We + # simply assume that if we have mman.h, we have mmap. + have_mmap=yes + case "${host}" in + spu-*-*|*-*-msdosdjgpp) + # The SPU does not have mmap, but it has a sys/mman.h header file + # containing "mmap_eaddr" and the mmap flags, confusing the test. + # DJGPP also has sys/man.h, but no mmap + have_mmap=no ;; + esac + else + AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no]) + fi +fi + +case "${host_os}" in +darwin*) + have_mmap=no ;; +esac + +if test "$have_mmap" = "no"; then + VIEW_FILE=read.lo + ALLOC_FILE=alloc.lo +else + VIEW_FILE=mmapio.lo + AC_PREPROC_IFELSE([ +#include +#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) + #error no MAP_ANONYMOUS +#endif +], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo]) +fi +AC_SUBST(VIEW_FILE) +AC_SUBST(ALLOC_FILE) + +BACKTRACE_USES_MALLOC=0 +if test "$ALLOC_FILE" = "alloc.lo"; then + BACKTRACE_USES_MALLOC=1 +fi +AC_SUBST(BACKTRACE_USES_MALLOC) + +# Check for dl_iterate_phdr. +AC_CHECK_HEADERS(link.h) +if test "$ac_cv_header_link_h" = "no"; then + have_dl_iterate_phdr=no +else + if test -n "${with_target_subdir}"; then + # When built as a GCC target library, we can't do a link test. + AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes], + [have_dl_iterate_phdr=no]) + case "${host}" in + *-*-solaris2.10*) + # Avoid dl_iterate_phdr on Solaris 10, where it is in the + # header file but is only in -ldl. + have_dl_iterate_phdr=no ;; + esac + else + AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes], + [have_dl_iterate_phdr=no]) + fi +fi +if test "$have_dl_iterate_phdr" = "yes"; then + AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.]) +fi + +# Check for loadquery. +AC_CHECK_HEADERS(sys/ldr.h) +if test "$ac_cv_header_sys_ldr_h" = "no"; then + have_loadquery=no +else + if test -n "${with_target_subdir}"; then + # When built as a GCC target library, we can't do a link test. + AC_EGREP_HEADER([loadquery], [sys/ldr.h], [have_loadquery=yes], + [have_loadquery=no]) + else + AC_CHECK_FUNC([loadquery], [have_loadquery=yes], + [have_loadquery=no]) + fi +fi +if test "$have_loadquery" = "yes"; then + AC_DEFINE(HAVE_LOADQUERY, 1, [Define if AIX loadquery is available.]) +fi + +# Check for the fcntl function. +if test -n "${with_target_subdir}"; then + case "${host}" in + *-*-mingw*) have_fcntl=no ;; + spu-*-*) have_fcntl=no ;; + *) have_fcntl=yes ;; + esac +else + AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no]) +fi +if test "$have_fcntl" = "yes"; then + AC_DEFINE([HAVE_FCNTL], 1, + [Define to 1 if you have the fcntl function]) +fi + +AC_CHECK_DECLS(strnlen) +AC_CHECK_FUNCS(lstat readlink) + +# Check for getexecname function. +if test -n "${with_target_subdir}"; then + case "${host}" in + *-*-solaris2*) have_getexecname=yes ;; + *) have_getexecname=no ;; + esac +else + AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no]) +fi +if test "$have_getexecname" = "yes"; then + AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.]) +fi + +# Check for the clock_gettime function. +AC_CHECK_FUNCS(clock_gettime) +clock_gettime_link= +# At least for glibc, clock_gettime is in librt. But don't +# pull that in if it still doesn't give us the function we want. This +# test is copied from libgomp, and modified to not link in -lrt as +# we're using this for test timing only. +if test "$ac_cv_func_clock_gettime" = no; then + AC_CHECK_LIB(rt, clock_gettime, + [CLOCK_GETTIME_LINK=-lrt + AC_DEFINE(HAVE_CLOCK_GETTIME, 1, + [Define to 1 if you have the `clock_gettime' function.])]) +fi +AC_SUBST(CLOCK_GETTIME_LINK) + +dnl Test whether the compiler supports the -pthread option. +AC_CACHE_CHECK([whether -pthread is supported], +[libgo_cv_lib_pthread], +[CFLAGS_hold=$CFLAGS +CFLAGS="$CFLAGS -pthread" +AC_COMPILE_IFELSE([[int i;]], +[libgo_cv_lib_pthread=yes], +[libgo_cv_lib_pthread=no]) +CFLAGS=$CFLAGS_hold]) +PTHREAD_CFLAGS= +if test "$libgo_cv_lib_pthread" = yes; then + PTHREAD_CFLAGS=-pthread +fi +AC_SUBST(PTHREAD_CFLAGS) + +AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes) + +AC_CHECK_LIB([z], [compress], []) +if test $ac_cv_lib_z_compress = "yes"; then + AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.]) +fi +AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes) + +dnl Test whether the linker supports the --compress_debug_sections option. +AC_CACHE_CHECK([whether --compress-debug-sections is supported], +[libgo_cv_ld_compress], +[LDFLAGS_hold=$LDFLAGS +LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu" +AC_LINK_IFELSE([AC_LANG_PROGRAM(,)], +[libgo_cv_ld_compress=yes], +[libgo_cv_ld_compress=no]) +LDFLAGS=$LDFLAGS_hold]) +AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes) + +AC_ARG_VAR(OBJCOPY, [location of objcopy]) +AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,) +AC_CACHE_CHECK([whether objcopy supports debuglink], +[libbacktrace_cv_objcopy_debuglink], +[if test -n "${with_target_subdir}"; then + libbacktrace_cv_objcopy_debuglink=no +elif ${OBJCOPY} --add-gnu-debuglink=x /bin/ls /tmp/ls$$; then + rm -f /tmp/ls$$ + libbacktrace_cv_objcopy_debuglink=yes +else + libbacktrace_cv_objcopy_debuglink=no +fi]) +AM_CONDITIONAL(HAVE_OBJCOPY_DEBUGLINK, test "$libbacktrace_cv_objcopy_debuglink" = yes) + +AC_CACHE_CHECK([whether tests can run], + [libbacktrace_cv_sys_native], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])], + [libbacktrace_cv_sys_native=yes], + [libbacktrace_cv_sys_native=no], + [libbacktrace_cv_sys_native=no])]) +AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes") + +if test "${multilib}" = "yes"; then + multilib_arg="--enable-multilib" +else + multilib_arg= +fi + +AC_CONFIG_FILES(Makefile backtrace-supported.h) + +# We need multilib support, but only if configuring for the target. +AC_CONFIG_COMMANDS([default], +[if test -n "$CONFIG_FILES"; then + if test -n "${with_target_subdir}"; then + # Multilibs need MULTISUBDIR defined correctly in certain makefiles so + # that multilib installs will end up installed in the correct place. + # The testsuite needs it for multilib-aware ABI baseline files. + # To work around this not being passed down from config-ml.in -> + # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually + # append it here. Only modify Makefiles that have just been created. + # + # Also, get rid of this simulated-VPATH thing that automake does. + cat > vpsed << \_EOF + s!`test -f '$<' || echo '$(srcdir)/'`!! +_EOF + for i in $SUBDIRS; do + case $CONFIG_FILES in + *${i}/Makefile*) + #echo "Adding MULTISUBDIR to $i/Makefile" + sed -f vpsed $i/Makefile > tmp + grep '^MULTISUBDIR =' Makefile >> tmp + mv tmp $i/Makefile + ;; + esac + done + rm vpsed + fi + fi +], +[ +# Variables needed in config.status (file generation) which aren't already +# passed by autoconf. +SUBDIRS="$SUBDIRS" +]) + +AC_OUTPUT diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/dwarf.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/dwarf.c new file mode 100644 index 0000000..1bd1488 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/dwarf.c @@ -0,0 +1,3126 @@ +/* dwarf.c -- Get file/line information from DWARF for backtraces. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +/* DWARF constants. */ + +enum dwarf_tag { + DW_TAG_entry_point = 0x3, + DW_TAG_compile_unit = 0x11, + DW_TAG_inlined_subroutine = 0x1d, + DW_TAG_subprogram = 0x2e, +}; + +enum dwarf_form { + DW_FORM_addr = 0x1, + DW_FORM_block2 = 0x3, + DW_FORM_block4 = 0x4, + DW_FORM_data2 = 0x5, + DW_FORM_data4 = 0x6, + DW_FORM_data8 = 0x07, + DW_FORM_string = 0x08, + DW_FORM_block = 0x09, + DW_FORM_block1 = 0x0a, + DW_FORM_data1 = 0x0b, + DW_FORM_flag = 0x0c, + DW_FORM_sdata = 0x0d, + DW_FORM_strp = 0x0e, + DW_FORM_udata = 0x0f, + DW_FORM_ref_addr = 0x10, + DW_FORM_ref1 = 0x11, + DW_FORM_ref2 = 0x12, + DW_FORM_ref4 = 0x13, + DW_FORM_ref8 = 0x14, + DW_FORM_ref_udata = 0x15, + DW_FORM_indirect = 0x16, + DW_FORM_sec_offset = 0x17, + DW_FORM_exprloc = 0x18, + DW_FORM_flag_present = 0x19, + DW_FORM_ref_sig8 = 0x20, + DW_FORM_GNU_addr_index = 0x1f01, + DW_FORM_GNU_str_index = 0x1f02, + DW_FORM_GNU_ref_alt = 0x1f20, + DW_FORM_GNU_strp_alt = 0x1f21, +}; + +enum dwarf_attribute { + DW_AT_name = 0x3, + DW_AT_stmt_list = 0x10, + DW_AT_low_pc = 0x11, + DW_AT_high_pc = 0x12, + DW_AT_comp_dir = 0x1b, + DW_AT_abstract_origin = 0x31, + DW_AT_specification = 0x47, + DW_AT_ranges = 0x55, + DW_AT_call_file = 0x58, + DW_AT_call_line = 0x59, + DW_AT_linkage_name = 0x6e, + DW_AT_MIPS_linkage_name = 0x2007, +}; + +enum dwarf_line_number_op { + DW_LNS_extended_op = 0x0, + DW_LNS_copy = 0x1, + DW_LNS_advance_pc = 0x2, + DW_LNS_advance_line = 0x3, + DW_LNS_set_file = 0x4, + DW_LNS_set_column = 0x5, + DW_LNS_negate_stmt = 0x6, + DW_LNS_set_basic_block = 0x7, + DW_LNS_const_add_pc = 0x8, + DW_LNS_fixed_advance_pc = 0x9, + DW_LNS_set_prologue_end = 0xa, + DW_LNS_set_epilogue_begin = 0xb, + DW_LNS_set_isa = 0xc, +}; + +enum dwarf_extedned_line_number_op { + DW_LNE_end_sequence = 0x1, + DW_LNE_set_address = 0x2, + DW_LNE_define_file = 0x3, + DW_LNE_set_discriminator = 0x4, +}; + +#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__) +# define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\') +#define HAS_DRIVE_SPEC(f) ((f)[0] && (f)[1] == ':') +# define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR(f[0]) || HAS_DRIVE_SPEC(f)) +#else +# define IS_DIR_SEPARATOR(c) ((c) == '/') +# define IS_ABSOLUTE_PATH(f) IS_DIR_SEPARATOR(f[0]) +#endif + +#if !defined(HAVE_DECL_STRNLEN) || !HAVE_DECL_STRNLEN + +/* If strnlen is not declared, provide our own version. */ + +static size_t +xstrnlen (const char *s, size_t maxlen) +{ + size_t i; + + for (i = 0; i < maxlen; ++i) + if (s[i] == '\0') + break; + return i; +} + +#define strnlen xstrnlen + +#endif + +/* A buffer to read DWARF info. */ + +struct dwarf_buf +{ + /* Buffer name for error messages. */ + const char *name; + /* Start of the buffer. */ + const unsigned char *start; + /* Next byte to read. */ + const unsigned char *buf; + /* The number of bytes remaining. */ + size_t left; + /* Whether the data is big-endian. */ + int is_bigendian; + /* Error callback routine. */ + backtrace_error_callback error_callback; + /* Data for error_callback. */ + void *data; + /* Non-zero if we've reported an underflow error. */ + int reported_underflow; +}; + +/* A single attribute in a DWARF abbreviation. */ + +struct attr +{ + /* The attribute name. */ + enum dwarf_attribute name; + /* The attribute form. */ + enum dwarf_form form; +}; + +/* A single DWARF abbreviation. */ + +struct abbrev +{ + /* The abbrev code--the number used to refer to the abbrev. */ + uint64_t code; + /* The entry tag. */ + enum dwarf_tag tag; + /* Non-zero if this abbrev has child entries. */ + int has_children; + /* The number of attributes. */ + size_t num_attrs; + /* The attributes. */ + struct attr *attrs; +}; + +/* The DWARF abbreviations for a compilation unit. This structure + only exists while reading the compilation unit. Most DWARF readers + seem to a hash table to map abbrev ID's to abbrev entries. + However, we primarily care about GCC, and GCC simply issues ID's in + numerical order starting at 1. So we simply keep a sorted vector, + and try to just look up the code. */ + +struct abbrevs +{ + /* The number of abbrevs in the vector. */ + size_t num_abbrevs; + /* The abbrevs, sorted by the code field. */ + struct abbrev *abbrevs; +}; + +/* The different kinds of attribute values. */ + +enum attr_val_encoding +{ + /* An address. */ + ATTR_VAL_ADDRESS, + /* A unsigned integer. */ + ATTR_VAL_UINT, + /* A sigd integer. */ + ATTR_VAL_SINT, + /* A string. */ + ATTR_VAL_STRING, + /* An offset to other data in the containing unit. */ + ATTR_VAL_REF_UNIT, + /* An offset to other data within the .dwarf_info section. */ + ATTR_VAL_REF_INFO, + /* An offset to data in some other section. */ + ATTR_VAL_REF_SECTION, + /* A type signature. */ + ATTR_VAL_REF_TYPE, + /* A block of data (not represented). */ + ATTR_VAL_BLOCK, + /* An expression (not represented). */ + ATTR_VAL_EXPR, +}; + +/* An attribute value. */ + +struct attr_val +{ + /* How the value is stored in the field u. */ + enum attr_val_encoding encoding; + union + { + /* ATTR_VAL_ADDRESS, ATTR_VAL_UINT, ATTR_VAL_REF*. */ + uint64_t uint; + /* ATTR_VAL_SINT. */ + int64_t sint; + /* ATTR_VAL_STRING. */ + const char *string; + /* ATTR_VAL_BLOCK not stored. */ + } u; +}; + +/* The line number program header. */ + +struct line_header +{ + /* The version of the line number information. */ + int version; + /* The minimum instruction length. */ + unsigned int min_insn_len; + /* The maximum number of ops per instruction. */ + unsigned int max_ops_per_insn; + /* The line base for special opcodes. */ + int line_base; + /* The line range for special opcodes. */ + unsigned int line_range; + /* The opcode base--the first special opcode. */ + unsigned int opcode_base; + /* Opcode lengths, indexed by opcode - 1. */ + const unsigned char *opcode_lengths; + /* The number of directory entries. */ + size_t dirs_count; + /* The directory entries. */ + const char **dirs; + /* The number of filenames. */ + size_t filenames_count; + /* The filenames. */ + const char **filenames; +}; + +/* Map a single PC value to a file/line. We will keep a vector of + these sorted by PC value. Each file/line will be correct from the + PC up to the PC of the next entry if there is one. We allocate one + extra entry at the end so that we can use bsearch. */ + +struct line +{ + /* PC. */ + uintptr_t pc; + /* File name. Many entries in the array are expected to point to + the same file name. */ + const char *filename; + /* Line number. */ + int lineno; + /* Index of the object in the original array read from the DWARF + section, before it has been sorted. The index makes it possible + to use Quicksort and maintain stability. */ + int idx; +}; + +/* A growable vector of line number information. This is used while + reading the line numbers. */ + +struct line_vector +{ + /* Memory. This is an array of struct line. */ + struct backtrace_vector vec; + /* Number of valid mappings. */ + size_t count; +}; + +/* A function described in the debug info. */ + +struct function +{ + /* The name of the function. */ + const char *name; + /* If this is an inlined function, the filename of the call + site. */ + const char *caller_filename; + /* If this is an inlined function, the line number of the call + site. */ + int caller_lineno; + /* Map PC ranges to inlined functions. */ + struct function_addrs *function_addrs; + size_t function_addrs_count; +}; + +/* An address range for a function. This maps a PC value to a + specific function. */ + +struct function_addrs +{ + /* Range is LOW <= PC < HIGH. */ + uint64_t low; + uint64_t high; + /* Function for this address range. */ + struct function *function; +}; + +/* A growable vector of function address ranges. */ + +struct function_vector +{ + /* Memory. This is an array of struct function_addrs. */ + struct backtrace_vector vec; + /* Number of address ranges present. */ + size_t count; +}; + +/* A DWARF compilation unit. This only holds the information we need + to map a PC to a file and line. */ + +struct unit +{ + /* The first entry for this compilation unit. */ + const unsigned char *unit_data; + /* The length of the data for this compilation unit. */ + size_t unit_data_len; + /* The offset of UNIT_DATA from the start of the information for + this compilation unit. */ + size_t unit_data_offset; + /* DWARF version. */ + int version; + /* Whether unit is DWARF64. */ + int is_dwarf64; + /* Address size. */ + int addrsize; + /* Offset into line number information. */ + off_t lineoff; + /* Primary source file. */ + const char *filename; + /* Compilation command working directory. */ + const char *comp_dir; + /* Absolute file name, only set if needed. */ + const char *abs_filename; + /* The abbreviations for this unit. */ + struct abbrevs abbrevs; + + /* The fields above this point are read in during initialization and + may be accessed freely. The fields below this point are read in + as needed, and therefore require care, as different threads may + try to initialize them simultaneously. */ + + /* PC to line number mapping. This is NULL if the values have not + been read. This is (struct line *) -1 if there was an error + reading the values. */ + struct line *lines; + /* Number of entries in lines. */ + size_t lines_count; + /* PC ranges to function. */ + struct function_addrs *function_addrs; + size_t function_addrs_count; +}; + +/* An address range for a compilation unit. This maps a PC value to a + specific compilation unit. Note that we invert the representation + in DWARF: instead of listing the units and attaching a list of + ranges, we list the ranges and have each one point to the unit. + This lets us do a binary search to find the unit. */ + +struct unit_addrs +{ + /* Range is LOW <= PC < HIGH. */ + uint64_t low; + uint64_t high; + /* Compilation unit for this address range. */ + struct unit *u; +}; + +/* A growable vector of compilation unit address ranges. */ + +struct unit_addrs_vector +{ + /* Memory. This is an array of struct unit_addrs. */ + struct backtrace_vector vec; + /* Number of address ranges present. */ + size_t count; +}; + +/* The information we need to map a PC to a file and line. */ + +struct dwarf_data +{ + /* The data for the next file we know about. */ + struct dwarf_data *next; + /* The base address for this file. */ + uintptr_t base_address; + /* A sorted list of address ranges. */ + struct unit_addrs *addrs; + /* Number of address ranges in list. */ + size_t addrs_count; + /* The unparsed .debug_info section. */ + const unsigned char *dwarf_info; + size_t dwarf_info_size; + /* The unparsed .debug_line section. */ + const unsigned char *dwarf_line; + size_t dwarf_line_size; + /* The unparsed .debug_ranges section. */ + const unsigned char *dwarf_ranges; + size_t dwarf_ranges_size; + /* The unparsed .debug_str section. */ + const unsigned char *dwarf_str; + size_t dwarf_str_size; + /* Whether the data is big-endian or not. */ + int is_bigendian; + /* A vector used for function addresses. We keep this here so that + we can grow the vector as we read more functions. */ + struct function_vector fvec; +}; + +/* Report an error for a DWARF buffer. */ + +static void +dwarf_buf_error (struct dwarf_buf *buf, const char *msg) +{ + char b[200]; + + snprintf (b, sizeof b, "%s in %s at %d", + msg, buf->name, (int) (buf->buf - buf->start)); + buf->error_callback (buf->data, b, 0); +} + +/* Require at least COUNT bytes in BUF. Return 1 if all is well, 0 on + error. */ + +static int +require (struct dwarf_buf *buf, size_t count) +{ + if (buf->left >= count) + return 1; + + if (!buf->reported_underflow) + { + dwarf_buf_error (buf, "DWARF underflow"); + buf->reported_underflow = 1; + } + + return 0; +} + +/* Advance COUNT bytes in BUF. Return 1 if all is well, 0 on + error. */ + +static int +advance (struct dwarf_buf *buf, size_t count) +{ + if (!require (buf, count)) + return 0; + buf->buf += count; + buf->left -= count; + return 1; +} + +/* Read one byte from BUF and advance 1 byte. */ + +static unsigned char +read_byte (struct dwarf_buf *buf) +{ + const unsigned char *p = buf->buf; + + if (!advance (buf, 1)) + return 0; + return p[0]; +} + +/* Read a signed char from BUF and advance 1 byte. */ + +static signed char +read_sbyte (struct dwarf_buf *buf) +{ + const unsigned char *p = buf->buf; + + if (!advance (buf, 1)) + return 0; + return (*p ^ 0x80) - 0x80; +} + +/* Read a uint16 from BUF and advance 2 bytes. */ + +static uint16_t +read_uint16 (struct dwarf_buf *buf) +{ + const unsigned char *p = buf->buf; + + if (!advance (buf, 2)) + return 0; + if (buf->is_bigendian) + return ((uint16_t) p[0] << 8) | (uint16_t) p[1]; + else + return ((uint16_t) p[1] << 8) | (uint16_t) p[0]; +} + +/* Read a uint32 from BUF and advance 4 bytes. */ + +static uint32_t +read_uint32 (struct dwarf_buf *buf) +{ + const unsigned char *p = buf->buf; + + if (!advance (buf, 4)) + return 0; + if (buf->is_bigendian) + return (((uint32_t) p[0] << 24) | ((uint32_t) p[1] << 16) + | ((uint32_t) p[2] << 8) | (uint32_t) p[3]); + else + return (((uint32_t) p[3] << 24) | ((uint32_t) p[2] << 16) + | ((uint32_t) p[1] << 8) | (uint32_t) p[0]); +} + +/* Read a uint64 from BUF and advance 8 bytes. */ + +static uint64_t +read_uint64 (struct dwarf_buf *buf) +{ + const unsigned char *p = buf->buf; + + if (!advance (buf, 8)) + return 0; + if (buf->is_bigendian) + return (((uint64_t) p[0] << 56) | ((uint64_t) p[1] << 48) + | ((uint64_t) p[2] << 40) | ((uint64_t) p[3] << 32) + | ((uint64_t) p[4] << 24) | ((uint64_t) p[5] << 16) + | ((uint64_t) p[6] << 8) | (uint64_t) p[7]); + else + return (((uint64_t) p[7] << 56) | ((uint64_t) p[6] << 48) + | ((uint64_t) p[5] << 40) | ((uint64_t) p[4] << 32) + | ((uint64_t) p[3] << 24) | ((uint64_t) p[2] << 16) + | ((uint64_t) p[1] << 8) | (uint64_t) p[0]); +} + +/* Read an offset from BUF and advance the appropriate number of + bytes. */ + +static uint64_t +read_offset (struct dwarf_buf *buf, int is_dwarf64) +{ + if (is_dwarf64) + return read_uint64 (buf); + else + return read_uint32 (buf); +} + +/* Read an address from BUF and advance the appropriate number of + bytes. */ + +static uint64_t +read_address (struct dwarf_buf *buf, int addrsize) +{ + switch (addrsize) + { + case 1: + return read_byte (buf); + case 2: + return read_uint16 (buf); + case 4: + return read_uint32 (buf); + case 8: + return read_uint64 (buf); + default: + dwarf_buf_error (buf, "unrecognized address size"); + return 0; + } +} + +/* Return whether a value is the highest possible address, given the + address size. */ + +static int +is_highest_address (uint64_t address, int addrsize) +{ + switch (addrsize) + { + case 1: + return address == (unsigned char) -1; + case 2: + return address == (uint16_t) -1; + case 4: + return address == (uint32_t) -1; + case 8: + return address == (uint64_t) -1; + default: + return 0; + } +} + +/* Read an unsigned LEB128 number. */ + +static uint64_t +read_uleb128 (struct dwarf_buf *buf) +{ + uint64_t ret; + unsigned int shift; + int overflow; + unsigned char b; + + ret = 0; + shift = 0; + overflow = 0; + do + { + const unsigned char *p; + + p = buf->buf; + if (!advance (buf, 1)) + return 0; + b = *p; + if (shift < 64) + ret |= ((uint64_t) (b & 0x7f)) << shift; + else if (!overflow) + { + dwarf_buf_error (buf, "LEB128 overflows uint64_t"); + overflow = 1; + } + shift += 7; + } + while ((b & 0x80) != 0); + + return ret; +} + +/* Read a signed LEB128 number. */ + +static int64_t +read_sleb128 (struct dwarf_buf *buf) +{ + uint64_t val; + unsigned int shift; + int overflow; + unsigned char b; + + val = 0; + shift = 0; + overflow = 0; + do + { + const unsigned char *p; + + p = buf->buf; + if (!advance (buf, 1)) + return 0; + b = *p; + if (shift < 64) + val |= ((uint64_t) (b & 0x7f)) << shift; + else if (!overflow) + { + dwarf_buf_error (buf, "signed LEB128 overflows uint64_t"); + overflow = 1; + } + shift += 7; + } + while ((b & 0x80) != 0); + + if ((b & 0x40) != 0 && shift < 64) + val |= ((uint64_t) -1) << shift; + + return (int64_t) val; +} + +/* Return the length of an LEB128 number. */ + +static size_t +leb128_len (const unsigned char *p) +{ + size_t ret; + + ret = 1; + while ((*p & 0x80) != 0) + { + ++p; + ++ret; + } + return ret; +} + +/* Free an abbreviations structure. */ + +static void +free_abbrevs (struct backtrace_state *state, struct abbrevs *abbrevs, + backtrace_error_callback error_callback, void *data) +{ + size_t i; + + for (i = 0; i < abbrevs->num_abbrevs; ++i) + backtrace_free (state, abbrevs->abbrevs[i].attrs, + abbrevs->abbrevs[i].num_attrs * sizeof (struct attr), + error_callback, data); + backtrace_free (state, abbrevs->abbrevs, + abbrevs->num_abbrevs * sizeof (struct abbrev), + error_callback, data); + abbrevs->num_abbrevs = 0; + abbrevs->abbrevs = NULL; +} + +/* Read an attribute value. Returns 1 on success, 0 on failure. If + the value can be represented as a uint64_t, sets *VAL and sets + *IS_VALID to 1. We don't try to store the value of other attribute + forms, because we don't care about them. */ + +static int +read_attribute (enum dwarf_form form, struct dwarf_buf *buf, + int is_dwarf64, int version, int addrsize, + const unsigned char *dwarf_str, size_t dwarf_str_size, + struct attr_val *val) +{ + /* Avoid warnings about val.u.FIELD may be used uninitialized if + this function is inlined. The warnings aren't valid but can + occur because the different fields are set and used + conditionally. */ + memset (val, 0, sizeof *val); + + switch (form) + { + case DW_FORM_addr: + val->encoding = ATTR_VAL_ADDRESS; + val->u.uint = read_address (buf, addrsize); + return 1; + case DW_FORM_block2: + val->encoding = ATTR_VAL_BLOCK; + return advance (buf, read_uint16 (buf)); + case DW_FORM_block4: + val->encoding = ATTR_VAL_BLOCK; + return advance (buf, read_uint32 (buf)); + case DW_FORM_data2: + val->encoding = ATTR_VAL_UINT; + val->u.uint = read_uint16 (buf); + return 1; + case DW_FORM_data4: + val->encoding = ATTR_VAL_UINT; + val->u.uint = read_uint32 (buf); + return 1; + case DW_FORM_data8: + val->encoding = ATTR_VAL_UINT; + val->u.uint = read_uint64 (buf); + return 1; + case DW_FORM_string: + val->encoding = ATTR_VAL_STRING; + val->u.string = (const char *) buf->buf; + return advance (buf, strnlen ((const char *) buf->buf, buf->left) + 1); + case DW_FORM_block: + val->encoding = ATTR_VAL_BLOCK; + return advance (buf, read_uleb128 (buf)); + case DW_FORM_block1: + val->encoding = ATTR_VAL_BLOCK; + return advance (buf, read_byte (buf)); + case DW_FORM_data1: + val->encoding = ATTR_VAL_UINT; + val->u.uint = read_byte (buf); + return 1; + case DW_FORM_flag: + val->encoding = ATTR_VAL_UINT; + val->u.uint = read_byte (buf); + return 1; + case DW_FORM_sdata: + val->encoding = ATTR_VAL_SINT; + val->u.sint = read_sleb128 (buf); + return 1; + case DW_FORM_strp: + { + uint64_t offset; + + offset = read_offset (buf, is_dwarf64); + if (offset >= dwarf_str_size) + { + dwarf_buf_error (buf, "DW_FORM_strp out of range"); + return 0; + } + val->encoding = ATTR_VAL_STRING; + val->u.string = (const char *) dwarf_str + offset; + return 1; + } + case DW_FORM_udata: + val->encoding = ATTR_VAL_UINT; + val->u.uint = read_uleb128 (buf); + return 1; + case DW_FORM_ref_addr: + val->encoding = ATTR_VAL_REF_INFO; + if (version == 2) + val->u.uint = read_address (buf, addrsize); + else + val->u.uint = read_offset (buf, is_dwarf64); + return 1; + case DW_FORM_ref1: + val->encoding = ATTR_VAL_REF_UNIT; + val->u.uint = read_byte (buf); + return 1; + case DW_FORM_ref2: + val->encoding = ATTR_VAL_REF_UNIT; + val->u.uint = read_uint16 (buf); + return 1; + case DW_FORM_ref4: + val->encoding = ATTR_VAL_REF_UNIT; + val->u.uint = read_uint32 (buf); + return 1; + case DW_FORM_ref8: + val->encoding = ATTR_VAL_REF_UNIT; + val->u.uint = read_uint64 (buf); + return 1; + case DW_FORM_ref_udata: + val->encoding = ATTR_VAL_REF_UNIT; + val->u.uint = read_uleb128 (buf); + return 1; + case DW_FORM_indirect: + { + uint64_t form; + + form = read_uleb128 (buf); + return read_attribute ((enum dwarf_form) form, buf, is_dwarf64, + version, addrsize, dwarf_str, dwarf_str_size, + val); + } + case DW_FORM_sec_offset: + val->encoding = ATTR_VAL_REF_SECTION; + val->u.uint = read_offset (buf, is_dwarf64); + return 1; + case DW_FORM_exprloc: + val->encoding = ATTR_VAL_EXPR; + return advance (buf, read_uleb128 (buf)); + case DW_FORM_flag_present: + val->encoding = ATTR_VAL_UINT; + val->u.uint = 1; + return 1; + case DW_FORM_ref_sig8: + val->encoding = ATTR_VAL_REF_TYPE; + val->u.uint = read_uint64 (buf); + return 1; + case DW_FORM_GNU_addr_index: + val->encoding = ATTR_VAL_REF_SECTION; + val->u.uint = read_uleb128 (buf); + return 1; + case DW_FORM_GNU_str_index: + val->encoding = ATTR_VAL_REF_SECTION; + val->u.uint = read_uleb128 (buf); + return 1; + case DW_FORM_GNU_ref_alt: + val->encoding = ATTR_VAL_REF_SECTION; + val->u.uint = read_offset (buf, is_dwarf64); + return 1; + case DW_FORM_GNU_strp_alt: + val->encoding = ATTR_VAL_REF_SECTION; + val->u.uint = read_offset (buf, is_dwarf64); + return 1; + default: + dwarf_buf_error (buf, "unrecognized DWARF form"); + return 0; + } +} + +/* Compare function_addrs for qsort. When ranges are nested, make the + smallest one sort last. */ + +static int +function_addrs_compare (const void *v1, const void *v2) +{ + const struct function_addrs *a1 = (const struct function_addrs *) v1; + const struct function_addrs *a2 = (const struct function_addrs *) v2; + + if (a1->low < a2->low) + return -1; + if (a1->low > a2->low) + return 1; + if (a1->high < a2->high) + return 1; + if (a1->high > a2->high) + return -1; + return strcmp (a1->function->name, a2->function->name); +} + +/* Compare a PC against a function_addrs for bsearch. Note that if + there are multiple ranges containing PC, which one will be returned + is unpredictable. We compensate for that in dwarf_fileline. */ + +static int +function_addrs_search (const void *vkey, const void *ventry) +{ + const uintptr_t *key = (const uintptr_t *) vkey; + const struct function_addrs *entry = (const struct function_addrs *) ventry; + uintptr_t pc; + + pc = *key; + if (pc < entry->low) + return -1; + else if (pc >= entry->high) + return 1; + else + return 0; +} + +/* Add a new compilation unit address range to a vector. Returns 1 on + success, 0 on failure. */ + +static int +add_unit_addr (struct backtrace_state *state, uintptr_t base_address, + struct unit_addrs addrs, + backtrace_error_callback error_callback, void *data, + struct unit_addrs_vector *vec) +{ + struct unit_addrs *p; + + /* Add in the base address of the module here, so that we can look + up the PC directly. */ + addrs.low += base_address; + addrs.high += base_address; + + /* Try to merge with the last entry. */ + if (vec->count > 0) + { + p = (struct unit_addrs *) vec->vec.base + (vec->count - 1); + if ((addrs.low == p->high || addrs.low == p->high + 1) + && addrs.u == p->u) + { + if (addrs.high > p->high) + p->high = addrs.high; + return 1; + } + } + + p = ((struct unit_addrs *) + backtrace_vector_grow (state, sizeof (struct unit_addrs), + error_callback, data, &vec->vec)); + if (p == NULL) + return 0; + + *p = addrs; + ++vec->count; + return 1; +} + +/* Free a unit address vector. */ + +static void +free_unit_addrs_vector (struct backtrace_state *state, + struct unit_addrs_vector *vec, + backtrace_error_callback error_callback, void *data) +{ + struct unit_addrs *addrs; + size_t i; + + addrs = (struct unit_addrs *) vec->vec.base; + for (i = 0; i < vec->count; ++i) + free_abbrevs (state, &addrs[i].u->abbrevs, error_callback, data); +} + +/* Compare unit_addrs for qsort. When ranges are nested, make the + smallest one sort last. */ + +static int +unit_addrs_compare (const void *v1, const void *v2) +{ + const struct unit_addrs *a1 = (const struct unit_addrs *) v1; + const struct unit_addrs *a2 = (const struct unit_addrs *) v2; + + if (a1->low < a2->low) + return -1; + if (a1->low > a2->low) + return 1; + if (a1->high < a2->high) + return 1; + if (a1->high > a2->high) + return -1; + if (a1->u->lineoff < a2->u->lineoff) + return -1; + if (a1->u->lineoff > a2->u->lineoff) + return 1; + return 0; +} + +/* Compare a PC against a unit_addrs for bsearch. Note that if there + are multiple ranges containing PC, which one will be returned is + unpredictable. We compensate for that in dwarf_fileline. */ + +static int +unit_addrs_search (const void *vkey, const void *ventry) +{ + const uintptr_t *key = (const uintptr_t *) vkey; + const struct unit_addrs *entry = (const struct unit_addrs *) ventry; + uintptr_t pc; + + pc = *key; + if (pc < entry->low) + return -1; + else if (pc >= entry->high) + return 1; + else + return 0; +} + +/* Sort the line vector by PC. We want a stable sort here to maintain + the order of lines for the same PC values. Since the sequence is + being sorted in place, their addresses cannot be relied on to + maintain stability. That is the purpose of the index member. */ + +static int +line_compare (const void *v1, const void *v2) +{ + const struct line *ln1 = (const struct line *) v1; + const struct line *ln2 = (const struct line *) v2; + + if (ln1->pc < ln2->pc) + return -1; + else if (ln1->pc > ln2->pc) + return 1; + else if (ln1->idx < ln2->idx) + return -1; + else if (ln1->idx > ln2->idx) + return 1; + else + return 0; +} + +/* Find a PC in a line vector. We always allocate an extra entry at + the end of the lines vector, so that this routine can safely look + at the next entry. Note that when there are multiple mappings for + the same PC value, this will return the last one. */ + +static int +line_search (const void *vkey, const void *ventry) +{ + const uintptr_t *key = (const uintptr_t *) vkey; + const struct line *entry = (const struct line *) ventry; + uintptr_t pc; + + pc = *key; + if (pc < entry->pc) + return -1; + else if (pc >= (entry + 1)->pc) + return 1; + else + return 0; +} + +/* Sort the abbrevs by the abbrev code. This function is passed to + both qsort and bsearch. */ + +static int +abbrev_compare (const void *v1, const void *v2) +{ + const struct abbrev *a1 = (const struct abbrev *) v1; + const struct abbrev *a2 = (const struct abbrev *) v2; + + if (a1->code < a2->code) + return -1; + else if (a1->code > a2->code) + return 1; + else + { + /* This really shouldn't happen. It means there are two + different abbrevs with the same code, and that means we don't + know which one lookup_abbrev should return. */ + return 0; + } +} + +/* Read the abbreviation table for a compilation unit. Returns 1 on + success, 0 on failure. */ + +static int +read_abbrevs (struct backtrace_state *state, uint64_t abbrev_offset, + const unsigned char *dwarf_abbrev, size_t dwarf_abbrev_size, + int is_bigendian, backtrace_error_callback error_callback, + void *data, struct abbrevs *abbrevs) +{ + struct dwarf_buf abbrev_buf; + struct dwarf_buf count_buf; + size_t num_abbrevs; + + abbrevs->num_abbrevs = 0; + abbrevs->abbrevs = NULL; + + if (abbrev_offset >= dwarf_abbrev_size) + { + error_callback (data, "abbrev offset out of range", 0); + return 0; + } + + abbrev_buf.name = ".debug_abbrev"; + abbrev_buf.start = dwarf_abbrev; + abbrev_buf.buf = dwarf_abbrev + abbrev_offset; + abbrev_buf.left = dwarf_abbrev_size - abbrev_offset; + abbrev_buf.is_bigendian = is_bigendian; + abbrev_buf.error_callback = error_callback; + abbrev_buf.data = data; + abbrev_buf.reported_underflow = 0; + + /* Count the number of abbrevs in this list. */ + + count_buf = abbrev_buf; + num_abbrevs = 0; + while (read_uleb128 (&count_buf) != 0) + { + if (count_buf.reported_underflow) + return 0; + ++num_abbrevs; + // Skip tag. + read_uleb128 (&count_buf); + // Skip has_children. + read_byte (&count_buf); + // Skip attributes. + while (read_uleb128 (&count_buf) != 0) + read_uleb128 (&count_buf); + // Skip form of last attribute. + read_uleb128 (&count_buf); + } + + if (count_buf.reported_underflow) + return 0; + + if (num_abbrevs == 0) + return 1; + + abbrevs->num_abbrevs = num_abbrevs; + abbrevs->abbrevs = ((struct abbrev *) + backtrace_alloc (state, + num_abbrevs * sizeof (struct abbrev), + error_callback, data)); + if (abbrevs->abbrevs == NULL) + return 0; + memset (abbrevs->abbrevs, 0, num_abbrevs * sizeof (struct abbrev)); + + num_abbrevs = 0; + while (1) + { + uint64_t code; + struct abbrev a; + size_t num_attrs; + struct attr *attrs; + + if (abbrev_buf.reported_underflow) + goto fail; + + code = read_uleb128 (&abbrev_buf); + if (code == 0) + break; + + a.code = code; + a.tag = (enum dwarf_tag) read_uleb128 (&abbrev_buf); + a.has_children = read_byte (&abbrev_buf); + + count_buf = abbrev_buf; + num_attrs = 0; + while (read_uleb128 (&count_buf) != 0) + { + ++num_attrs; + read_uleb128 (&count_buf); + } + + if (num_attrs == 0) + { + attrs = NULL; + read_uleb128 (&abbrev_buf); + read_uleb128 (&abbrev_buf); + } + else + { + attrs = ((struct attr *) + backtrace_alloc (state, num_attrs * sizeof *attrs, + error_callback, data)); + if (attrs == NULL) + goto fail; + num_attrs = 0; + while (1) + { + uint64_t name; + uint64_t form; + + name = read_uleb128 (&abbrev_buf); + form = read_uleb128 (&abbrev_buf); + if (name == 0) + break; + attrs[num_attrs].name = (enum dwarf_attribute) name; + attrs[num_attrs].form = (enum dwarf_form) form; + ++num_attrs; + } + } + + a.num_attrs = num_attrs; + a.attrs = attrs; + + abbrevs->abbrevs[num_abbrevs] = a; + ++num_abbrevs; + } + + backtrace_qsort (abbrevs->abbrevs, abbrevs->num_abbrevs, + sizeof (struct abbrev), abbrev_compare); + + return 1; + + fail: + free_abbrevs (state, abbrevs, error_callback, data); + return 0; +} + +/* Return the abbrev information for an abbrev code. */ + +static const struct abbrev * +lookup_abbrev (struct abbrevs *abbrevs, uint64_t code, + backtrace_error_callback error_callback, void *data) +{ + struct abbrev key; + void *p; + + /* With GCC, where abbrevs are simply numbered in order, we should + be able to just look up the entry. */ + if (code - 1 < abbrevs->num_abbrevs + && abbrevs->abbrevs[code - 1].code == code) + return &abbrevs->abbrevs[code - 1]; + + /* Otherwise we have to search. */ + memset (&key, 0, sizeof key); + key.code = code; + p = bsearch (&key, abbrevs->abbrevs, abbrevs->num_abbrevs, + sizeof (struct abbrev), abbrev_compare); + if (p == NULL) + { + error_callback (data, "invalid abbreviation code", 0); + return NULL; + } + return (const struct abbrev *) p; +} + +/* Add non-contiguous address ranges for a compilation unit. Returns + 1 on success, 0 on failure. */ + +static int +add_unit_ranges (struct backtrace_state *state, uintptr_t base_address, + struct unit *u, uint64_t ranges, uint64_t base, + int is_bigendian, const unsigned char *dwarf_ranges, + size_t dwarf_ranges_size, + backtrace_error_callback error_callback, void *data, + struct unit_addrs_vector *addrs) +{ + struct dwarf_buf ranges_buf; + + if (ranges >= dwarf_ranges_size) + { + error_callback (data, "ranges offset out of range", 0); + return 0; + } + + ranges_buf.name = ".debug_ranges"; + ranges_buf.start = dwarf_ranges; + ranges_buf.buf = dwarf_ranges + ranges; + ranges_buf.left = dwarf_ranges_size - ranges; + ranges_buf.is_bigendian = is_bigendian; + ranges_buf.error_callback = error_callback; + ranges_buf.data = data; + ranges_buf.reported_underflow = 0; + + while (1) + { + uint64_t low; + uint64_t high; + + if (ranges_buf.reported_underflow) + return 0; + + low = read_address (&ranges_buf, u->addrsize); + high = read_address (&ranges_buf, u->addrsize); + + if (low == 0 && high == 0) + break; + + if (is_highest_address (low, u->addrsize)) + base = high; + else + { + struct unit_addrs a; + + a.low = low + base; + a.high = high + base; + a.u = u; + if (!add_unit_addr (state, base_address, a, error_callback, data, + addrs)) + return 0; + } + } + + if (ranges_buf.reported_underflow) + return 0; + + return 1; +} + +/* Find the address range covered by a compilation unit, reading from + UNIT_BUF and adding values to U. Returns 1 if all data could be + read, 0 if there is some error. */ + +static int +find_address_ranges (struct backtrace_state *state, uintptr_t base_address, + struct dwarf_buf *unit_buf, + const unsigned char *dwarf_str, size_t dwarf_str_size, + const unsigned char *dwarf_ranges, + size_t dwarf_ranges_size, + int is_bigendian, backtrace_error_callback error_callback, + void *data, struct unit *u, + struct unit_addrs_vector *addrs) +{ + while (unit_buf->left > 0) + { + uint64_t code; + const struct abbrev *abbrev; + uint64_t lowpc; + int have_lowpc; + uint64_t highpc; + int have_highpc; + int highpc_is_relative; + uint64_t ranges; + int have_ranges; + size_t i; + + code = read_uleb128 (unit_buf); + if (code == 0) + return 1; + + abbrev = lookup_abbrev (&u->abbrevs, code, error_callback, data); + if (abbrev == NULL) + return 0; + + lowpc = 0; + have_lowpc = 0; + highpc = 0; + have_highpc = 0; + highpc_is_relative = 0; + ranges = 0; + have_ranges = 0; + for (i = 0; i < abbrev->num_attrs; ++i) + { + struct attr_val val; + + if (!read_attribute (abbrev->attrs[i].form, unit_buf, + u->is_dwarf64, u->version, u->addrsize, + dwarf_str, dwarf_str_size, &val)) + return 0; + + switch (abbrev->attrs[i].name) + { + case DW_AT_low_pc: + if (val.encoding == ATTR_VAL_ADDRESS) + { + lowpc = val.u.uint; + have_lowpc = 1; + } + break; + + case DW_AT_high_pc: + if (val.encoding == ATTR_VAL_ADDRESS) + { + highpc = val.u.uint; + have_highpc = 1; + } + else if (val.encoding == ATTR_VAL_UINT) + { + highpc = val.u.uint; + have_highpc = 1; + highpc_is_relative = 1; + } + break; + + case DW_AT_ranges: + if (val.encoding == ATTR_VAL_UINT + || val.encoding == ATTR_VAL_REF_SECTION) + { + ranges = val.u.uint; + have_ranges = 1; + } + break; + + case DW_AT_stmt_list: + if (abbrev->tag == DW_TAG_compile_unit + && (val.encoding == ATTR_VAL_UINT + || val.encoding == ATTR_VAL_REF_SECTION)) + u->lineoff = val.u.uint; + break; + + case DW_AT_name: + if (abbrev->tag == DW_TAG_compile_unit + && val.encoding == ATTR_VAL_STRING) + u->filename = val.u.string; + break; + + case DW_AT_comp_dir: + if (abbrev->tag == DW_TAG_compile_unit + && val.encoding == ATTR_VAL_STRING) + u->comp_dir = val.u.string; + break; + + default: + break; + } + } + + if (abbrev->tag == DW_TAG_compile_unit + || abbrev->tag == DW_TAG_subprogram) + { + if (have_ranges) + { + if (!add_unit_ranges (state, base_address, u, ranges, lowpc, + is_bigendian, dwarf_ranges, + dwarf_ranges_size, error_callback, + data, addrs)) + return 0; + } + else if (have_lowpc && have_highpc) + { + struct unit_addrs a; + + if (highpc_is_relative) + highpc += lowpc; + a.low = lowpc; + a.high = highpc; + a.u = u; + + if (!add_unit_addr (state, base_address, a, error_callback, data, + addrs)) + return 0; + } + + /* If we found the PC range in the DW_TAG_compile_unit, we + can stop now. */ + if (abbrev->tag == DW_TAG_compile_unit + && (have_ranges || (have_lowpc && have_highpc))) + return 1; + } + + if (abbrev->has_children) + { + if (!find_address_ranges (state, base_address, unit_buf, + dwarf_str, dwarf_str_size, + dwarf_ranges, dwarf_ranges_size, + is_bigendian, error_callback, data, + u, addrs)) + return 0; + } + } + + return 1; +} + +/* Build a mapping from address ranges to the compilation units where + the line number information for that range can be found. Returns 1 + on success, 0 on failure. */ + +static int +build_address_map (struct backtrace_state *state, uintptr_t base_address, + const unsigned char *dwarf_info, size_t dwarf_info_size, + const unsigned char *dwarf_abbrev, size_t dwarf_abbrev_size, + const unsigned char *dwarf_ranges, size_t dwarf_ranges_size, + const unsigned char *dwarf_str, size_t dwarf_str_size, + int is_bigendian, backtrace_error_callback error_callback, + void *data, struct unit_addrs_vector *addrs) +{ + struct dwarf_buf info; + struct abbrevs abbrevs; + + memset (&addrs->vec, 0, sizeof addrs->vec); + addrs->count = 0; + + /* Read through the .debug_info section. FIXME: Should we use the + .debug_aranges section? gdb and addr2line don't use it, but I'm + not sure why. */ + + info.name = ".debug_info"; + info.start = dwarf_info; + info.buf = dwarf_info; + info.left = dwarf_info_size; + info.is_bigendian = is_bigendian; + info.error_callback = error_callback; + info.data = data; + info.reported_underflow = 0; + + memset (&abbrevs, 0, sizeof abbrevs); + while (info.left > 0) + { + const unsigned char *unit_data_start; + uint64_t len; + int is_dwarf64; + struct dwarf_buf unit_buf; + int version; + uint64_t abbrev_offset; + int addrsize; + struct unit *u; + + if (info.reported_underflow) + goto fail; + + unit_data_start = info.buf; + + is_dwarf64 = 0; + len = read_uint32 (&info); + if (len == 0xffffffff) + { + len = read_uint64 (&info); + is_dwarf64 = 1; + } + + unit_buf = info; + unit_buf.left = len; + + if (!advance (&info, len)) + goto fail; + + version = read_uint16 (&unit_buf); + if (version < 2 || version > 4) + { + dwarf_buf_error (&unit_buf, "unrecognized DWARF version"); + goto fail; + } + + abbrev_offset = read_offset (&unit_buf, is_dwarf64); + if (!read_abbrevs (state, abbrev_offset, dwarf_abbrev, dwarf_abbrev_size, + is_bigendian, error_callback, data, &abbrevs)) + goto fail; + + addrsize = read_byte (&unit_buf); + + u = ((struct unit *) + backtrace_alloc (state, sizeof *u, error_callback, data)); + if (u == NULL) + goto fail; + u->unit_data = unit_buf.buf; + u->unit_data_len = unit_buf.left; + u->unit_data_offset = unit_buf.buf - unit_data_start; + u->version = version; + u->is_dwarf64 = is_dwarf64; + u->addrsize = addrsize; + u->filename = NULL; + u->comp_dir = NULL; + u->abs_filename = NULL; + u->lineoff = 0; + u->abbrevs = abbrevs; + memset (&abbrevs, 0, sizeof abbrevs); + + /* The actual line number mappings will be read as needed. */ + u->lines = NULL; + u->lines_count = 0; + u->function_addrs = NULL; + u->function_addrs_count = 0; + + if (!find_address_ranges (state, base_address, &unit_buf, + dwarf_str, dwarf_str_size, + dwarf_ranges, dwarf_ranges_size, + is_bigendian, error_callback, data, + u, addrs)) + { + free_abbrevs (state, &u->abbrevs, error_callback, data); + backtrace_free (state, u, sizeof *u, error_callback, data); + goto fail; + } + + if (unit_buf.reported_underflow) + { + free_abbrevs (state, &u->abbrevs, error_callback, data); + backtrace_free (state, u, sizeof *u, error_callback, data); + goto fail; + } + } + if (info.reported_underflow) + goto fail; + + return 1; + + fail: + free_abbrevs (state, &abbrevs, error_callback, data); + free_unit_addrs_vector (state, addrs, error_callback, data); + return 0; +} + +/* Add a new mapping to the vector of line mappings that we are + building. Returns 1 on success, 0 on failure. */ + +static int +add_line (struct backtrace_state *state, struct dwarf_data *ddata, + uintptr_t pc, const char *filename, int lineno, + backtrace_error_callback error_callback, void *data, + struct line_vector *vec) +{ + struct line *ln; + + /* If we are adding the same mapping, ignore it. This can happen + when using discriminators. */ + if (vec->count > 0) + { + ln = (struct line *) vec->vec.base + (vec->count - 1); + if (pc == ln->pc && filename == ln->filename && lineno == ln->lineno) + return 1; + } + + ln = ((struct line *) + backtrace_vector_grow (state, sizeof (struct line), error_callback, + data, &vec->vec)); + if (ln == NULL) + return 0; + + /* Add in the base address here, so that we can look up the PC + directly. */ + ln->pc = pc + ddata->base_address; + + ln->filename = filename; + ln->lineno = lineno; + ln->idx = vec->count; + + ++vec->count; + + return 1; +} + +/* Free the line header information. */ + +static void +free_line_header (struct backtrace_state *state, struct line_header *hdr, + backtrace_error_callback error_callback, void *data) +{ + if (hdr->dirs_count != 0) + backtrace_free (state, hdr->dirs, hdr->dirs_count * sizeof (const char *), + error_callback, data); + backtrace_free (state, hdr->filenames, + hdr->filenames_count * sizeof (char *), + error_callback, data); +} + +/* Read the line header. Return 1 on success, 0 on failure. */ + +static int +read_line_header (struct backtrace_state *state, struct unit *u, + int is_dwarf64, struct dwarf_buf *line_buf, + struct line_header *hdr) +{ + uint64_t hdrlen; + struct dwarf_buf hdr_buf; + const unsigned char *p; + const unsigned char *pend; + size_t i; + + hdr->version = read_uint16 (line_buf); + if (hdr->version < 2 || hdr->version > 4) + { + dwarf_buf_error (line_buf, "unsupported line number version"); + return 0; + } + + hdrlen = read_offset (line_buf, is_dwarf64); + + hdr_buf = *line_buf; + hdr_buf.left = hdrlen; + + if (!advance (line_buf, hdrlen)) + return 0; + + hdr->min_insn_len = read_byte (&hdr_buf); + if (hdr->version < 4) + hdr->max_ops_per_insn = 1; + else + hdr->max_ops_per_insn = read_byte (&hdr_buf); + + /* We don't care about default_is_stmt. */ + read_byte (&hdr_buf); + + hdr->line_base = read_sbyte (&hdr_buf); + hdr->line_range = read_byte (&hdr_buf); + + hdr->opcode_base = read_byte (&hdr_buf); + hdr->opcode_lengths = hdr_buf.buf; + if (!advance (&hdr_buf, hdr->opcode_base - 1)) + return 0; + + /* Count the number of directory entries. */ + hdr->dirs_count = 0; + p = hdr_buf.buf; + pend = p + hdr_buf.left; + while (p < pend && *p != '\0') + { + p += strnlen((const char *) p, pend - p) + 1; + ++hdr->dirs_count; + } + + hdr->dirs = NULL; + if (hdr->dirs_count != 0) + { + hdr->dirs = ((const char **) + backtrace_alloc (state, + hdr->dirs_count * sizeof (const char *), + line_buf->error_callback, line_buf->data)); + if (hdr->dirs == NULL) + return 0; + } + + i = 0; + while (*hdr_buf.buf != '\0') + { + if (hdr_buf.reported_underflow) + return 0; + + hdr->dirs[i] = (const char *) hdr_buf.buf; + ++i; + if (!advance (&hdr_buf, + strnlen ((const char *) hdr_buf.buf, hdr_buf.left) + 1)) + return 0; + } + if (!advance (&hdr_buf, 1)) + return 0; + + /* Count the number of file entries. */ + hdr->filenames_count = 0; + p = hdr_buf.buf; + pend = p + hdr_buf.left; + while (p < pend && *p != '\0') + { + p += strnlen ((const char *) p, pend - p) + 1; + p += leb128_len (p); + p += leb128_len (p); + p += leb128_len (p); + ++hdr->filenames_count; + } + + hdr->filenames = ((const char **) + backtrace_alloc (state, + hdr->filenames_count * sizeof (char *), + line_buf->error_callback, + line_buf->data)); + if (hdr->filenames == NULL) + return 0; + i = 0; + while (*hdr_buf.buf != '\0') + { + const char *filename; + uint64_t dir_index; + + if (hdr_buf.reported_underflow) + return 0; + + filename = (const char *) hdr_buf.buf; + if (!advance (&hdr_buf, + strnlen ((const char *) hdr_buf.buf, hdr_buf.left) + 1)) + return 0; + dir_index = read_uleb128 (&hdr_buf); + if (IS_ABSOLUTE_PATH (filename) + || (dir_index == 0 && u->comp_dir == NULL)) + hdr->filenames[i] = filename; + else + { + const char *dir; + size_t dir_len; + size_t filename_len; + char *s; + + if (dir_index == 0) + dir = u->comp_dir; + else if (dir_index - 1 < hdr->dirs_count) + dir = hdr->dirs[dir_index - 1]; + else + { + dwarf_buf_error (line_buf, + ("invalid directory index in " + "line number program header")); + return 0; + } + dir_len = strlen (dir); + filename_len = strlen (filename); + s = ((char *) + backtrace_alloc (state, dir_len + filename_len + 2, + line_buf->error_callback, line_buf->data)); + if (s == NULL) + return 0; + memcpy (s, dir, dir_len); + /* FIXME: If we are on a DOS-based file system, and the + directory or the file name use backslashes, then we + should use a backslash here. */ + s[dir_len] = '/'; + memcpy (s + dir_len + 1, filename, filename_len + 1); + hdr->filenames[i] = s; + } + + /* Ignore the modification time and size. */ + read_uleb128 (&hdr_buf); + read_uleb128 (&hdr_buf); + + ++i; + } + + if (hdr_buf.reported_underflow) + return 0; + + return 1; +} + +/* Read the line program, adding line mappings to VEC. Return 1 on + success, 0 on failure. */ + +static int +read_line_program (struct backtrace_state *state, struct dwarf_data *ddata, + struct unit *u, const struct line_header *hdr, + struct dwarf_buf *line_buf, struct line_vector *vec) +{ + uint64_t address; + unsigned int op_index; + const char *reset_filename; + const char *filename; + int lineno; + + address = 0; + op_index = 0; + if (hdr->filenames_count > 0) + reset_filename = hdr->filenames[0]; + else + reset_filename = ""; + filename = reset_filename; + lineno = 1; + while (line_buf->left > 0) + { + unsigned int op; + + op = read_byte (line_buf); + if (op >= hdr->opcode_base) + { + unsigned int advance; + + /* Special opcode. */ + op -= hdr->opcode_base; + advance = op / hdr->line_range; + address += (hdr->min_insn_len * (op_index + advance) + / hdr->max_ops_per_insn); + op_index = (op_index + advance) % hdr->max_ops_per_insn; + lineno += hdr->line_base + (int) (op % hdr->line_range); + add_line (state, ddata, address, filename, lineno, + line_buf->error_callback, line_buf->data, vec); + } + else if (op == DW_LNS_extended_op) + { + uint64_t len; + + len = read_uleb128 (line_buf); + op = read_byte (line_buf); + switch (op) + { + case DW_LNE_end_sequence: + /* FIXME: Should we mark the high PC here? It seems + that we already have that information from the + compilation unit. */ + address = 0; + op_index = 0; + filename = reset_filename; + lineno = 1; + break; + case DW_LNE_set_address: + address = read_address (line_buf, u->addrsize); + break; + case DW_LNE_define_file: + { + const char *f; + unsigned int dir_index; + + f = (const char *) line_buf->buf; + if (!advance (line_buf, strnlen (f, line_buf->left) + 1)) + return 0; + dir_index = read_uleb128 (line_buf); + /* Ignore that time and length. */ + read_uleb128 (line_buf); + read_uleb128 (line_buf); + if (IS_ABSOLUTE_PATH (f)) + filename = f; + else + { + const char *dir; + size_t dir_len; + size_t f_len; + char *p; + + if (dir_index == 0) + dir = u->comp_dir; + else if (dir_index - 1 < hdr->dirs_count) + dir = hdr->dirs[dir_index - 1]; + else + { + dwarf_buf_error (line_buf, + ("invalid directory index " + "in line number program")); + return 0; + } + dir_len = strlen (dir); + f_len = strlen (f); + p = ((char *) + backtrace_alloc (state, dir_len + f_len + 2, + line_buf->error_callback, + line_buf->data)); + if (p == NULL) + return 0; + memcpy (p, dir, dir_len); + /* FIXME: If we are on a DOS-based file system, + and the directory or the file name use + backslashes, then we should use a backslash + here. */ + p[dir_len] = '/'; + memcpy (p + dir_len + 1, f, f_len + 1); + filename = p; + } + } + break; + case DW_LNE_set_discriminator: + /* We don't care about discriminators. */ + read_uleb128 (line_buf); + break; + default: + if (!advance (line_buf, len - 1)) + return 0; + break; + } + } + else + { + switch (op) + { + case DW_LNS_copy: + add_line (state, ddata, address, filename, lineno, + line_buf->error_callback, line_buf->data, vec); + break; + case DW_LNS_advance_pc: + { + uint64_t advance; + + advance = read_uleb128 (line_buf); + address += (hdr->min_insn_len * (op_index + advance) + / hdr->max_ops_per_insn); + op_index = (op_index + advance) % hdr->max_ops_per_insn; + } + break; + case DW_LNS_advance_line: + lineno += (int) read_sleb128 (line_buf); + break; + case DW_LNS_set_file: + { + uint64_t fileno; + + fileno = read_uleb128 (line_buf); + if (fileno == 0) + filename = ""; + else + { + if (fileno - 1 >= hdr->filenames_count) + { + dwarf_buf_error (line_buf, + ("invalid file number in " + "line number program")); + return 0; + } + filename = hdr->filenames[fileno - 1]; + } + } + break; + case DW_LNS_set_column: + read_uleb128 (line_buf); + break; + case DW_LNS_negate_stmt: + break; + case DW_LNS_set_basic_block: + break; + case DW_LNS_const_add_pc: + { + unsigned int advance; + + op = 255 - hdr->opcode_base; + advance = op / hdr->line_range; + address += (hdr->min_insn_len * (op_index + advance) + / hdr->max_ops_per_insn); + op_index = (op_index + advance) % hdr->max_ops_per_insn; + } + break; + case DW_LNS_fixed_advance_pc: + address += read_uint16 (line_buf); + op_index = 0; + break; + case DW_LNS_set_prologue_end: + break; + case DW_LNS_set_epilogue_begin: + break; + case DW_LNS_set_isa: + read_uleb128 (line_buf); + break; + default: + { + unsigned int i; + + for (i = hdr->opcode_lengths[op - 1]; i > 0; --i) + read_uleb128 (line_buf); + } + break; + } + } + } + + return 1; +} + +/* Read the line number information for a compilation unit. Returns 1 + on success, 0 on failure. */ + +static int +read_line_info (struct backtrace_state *state, struct dwarf_data *ddata, + backtrace_error_callback error_callback, void *data, + struct unit *u, struct line_header *hdr, struct line **lines, + size_t *lines_count) +{ + struct line_vector vec; + struct dwarf_buf line_buf; + uint64_t len; + int is_dwarf64; + struct line *ln; + + memset (&vec.vec, 0, sizeof vec.vec); + vec.count = 0; + + memset (hdr, 0, sizeof *hdr); + + if (u->lineoff != (off_t) (size_t) u->lineoff + || (size_t) u->lineoff >= ddata->dwarf_line_size) + { + error_callback (data, "unit line offset out of range", 0); + goto fail; + } + + line_buf.name = ".debug_line"; + line_buf.start = ddata->dwarf_line; + line_buf.buf = ddata->dwarf_line + u->lineoff; + line_buf.left = ddata->dwarf_line_size - u->lineoff; + line_buf.is_bigendian = ddata->is_bigendian; + line_buf.error_callback = error_callback; + line_buf.data = data; + line_buf.reported_underflow = 0; + + is_dwarf64 = 0; + len = read_uint32 (&line_buf); + if (len == 0xffffffff) + { + len = read_uint64 (&line_buf); + is_dwarf64 = 1; + } + line_buf.left = len; + + if (!read_line_header (state, u, is_dwarf64, &line_buf, hdr)) + goto fail; + + if (!read_line_program (state, ddata, u, hdr, &line_buf, &vec)) + goto fail; + + if (line_buf.reported_underflow) + goto fail; + + if (vec.count == 0) + { + /* This is not a failure in the sense of a generating an error, + but it is a failure in that sense that we have no useful + information. */ + goto fail; + } + + /* Allocate one extra entry at the end. */ + ln = ((struct line *) + backtrace_vector_grow (state, sizeof (struct line), error_callback, + data, &vec.vec)); + if (ln == NULL) + goto fail; + ln->pc = (uintptr_t) -1; + ln->filename = NULL; + ln->lineno = 0; + ln->idx = 0; + + if (!backtrace_vector_release (state, &vec.vec, error_callback, data)) + goto fail; + + ln = (struct line *) vec.vec.base; + backtrace_qsort (ln, vec.count, sizeof (struct line), line_compare); + + *lines = ln; + *lines_count = vec.count; + + return 1; + + fail: + vec.vec.alc += vec.vec.size; + vec.vec.size = 0; + backtrace_vector_release (state, &vec.vec, error_callback, data); + free_line_header (state, hdr, error_callback, data); + *lines = (struct line *) (uintptr_t) -1; + *lines_count = 0; + return 0; +} + +/* Read the name of a function from a DIE referenced by a + DW_AT_abstract_origin or DW_AT_specification tag. OFFSET is within + the same compilation unit. */ + +static const char * +read_referenced_name (struct dwarf_data *ddata, struct unit *u, + uint64_t offset, backtrace_error_callback error_callback, + void *data) +{ + struct dwarf_buf unit_buf; + uint64_t code; + const struct abbrev *abbrev; + const char *ret; + size_t i; + + /* OFFSET is from the start of the data for this compilation unit. + U->unit_data is the data, but it starts U->unit_data_offset bytes + from the beginning. */ + + if (offset < u->unit_data_offset + || offset - u->unit_data_offset >= u->unit_data_len) + { + error_callback (data, + "abstract origin or specification out of range", + 0); + return NULL; + } + + offset -= u->unit_data_offset; + + unit_buf.name = ".debug_info"; + unit_buf.start = ddata->dwarf_info; + unit_buf.buf = u->unit_data + offset; + unit_buf.left = u->unit_data_len - offset; + unit_buf.is_bigendian = ddata->is_bigendian; + unit_buf.error_callback = error_callback; + unit_buf.data = data; + unit_buf.reported_underflow = 0; + + code = read_uleb128 (&unit_buf); + if (code == 0) + { + dwarf_buf_error (&unit_buf, "invalid abstract origin or specification"); + return NULL; + } + + abbrev = lookup_abbrev (&u->abbrevs, code, error_callback, data); + if (abbrev == NULL) + return NULL; + + ret = NULL; + for (i = 0; i < abbrev->num_attrs; ++i) + { + struct attr_val val; + + if (!read_attribute (abbrev->attrs[i].form, &unit_buf, + u->is_dwarf64, u->version, u->addrsize, + ddata->dwarf_str, ddata->dwarf_str_size, + &val)) + return NULL; + + switch (abbrev->attrs[i].name) + { + case DW_AT_name: + /* We prefer the linkage name if get one. */ + if (val.encoding == ATTR_VAL_STRING) + ret = val.u.string; + break; + + case DW_AT_linkage_name: + case DW_AT_MIPS_linkage_name: + if (val.encoding == ATTR_VAL_STRING) + return val.u.string; + break; + + case DW_AT_specification: + if (abbrev->attrs[i].form == DW_FORM_ref_addr + || abbrev->attrs[i].form == DW_FORM_ref_sig8) + { + /* This refers to a specification defined in some other + compilation unit. We can handle this case if we + must, but it's harder. */ + break; + } + if (val.encoding == ATTR_VAL_UINT + || val.encoding == ATTR_VAL_REF_UNIT) + { + const char *name; + + name = read_referenced_name (ddata, u, val.u.uint, + error_callback, data); + if (name != NULL) + ret = name; + } + break; + + default: + break; + } + } + + return ret; +} + +/* Add a single range to U that maps to function. Returns 1 on + success, 0 on error. */ + +static int +add_function_range (struct backtrace_state *state, struct dwarf_data *ddata, + struct function *function, uint64_t lowpc, uint64_t highpc, + backtrace_error_callback error_callback, + void *data, struct function_vector *vec) +{ + struct function_addrs *p; + + /* Add in the base address here, so that we can look up the PC + directly. */ + lowpc += ddata->base_address; + highpc += ddata->base_address; + + if (vec->count > 0) + { + p = (struct function_addrs *) vec->vec.base + vec->count - 1; + if ((lowpc == p->high || lowpc == p->high + 1) + && function == p->function) + { + if (highpc > p->high) + p->high = highpc; + return 1; + } + } + + p = ((struct function_addrs *) + backtrace_vector_grow (state, sizeof (struct function_addrs), + error_callback, data, &vec->vec)); + if (p == NULL) + return 0; + + p->low = lowpc; + p->high = highpc; + p->function = function; + ++vec->count; + return 1; +} + +/* Add PC ranges to U that map to FUNCTION. Returns 1 on success, 0 + on error. */ + +static int +add_function_ranges (struct backtrace_state *state, struct dwarf_data *ddata, + struct unit *u, struct function *function, + uint64_t ranges, uint64_t base, + backtrace_error_callback error_callback, void *data, + struct function_vector *vec) +{ + struct dwarf_buf ranges_buf; + + if (ranges >= ddata->dwarf_ranges_size) + { + error_callback (data, "function ranges offset out of range", 0); + return 0; + } + + ranges_buf.name = ".debug_ranges"; + ranges_buf.start = ddata->dwarf_ranges; + ranges_buf.buf = ddata->dwarf_ranges + ranges; + ranges_buf.left = ddata->dwarf_ranges_size - ranges; + ranges_buf.is_bigendian = ddata->is_bigendian; + ranges_buf.error_callback = error_callback; + ranges_buf.data = data; + ranges_buf.reported_underflow = 0; + + while (1) + { + uint64_t low; + uint64_t high; + + if (ranges_buf.reported_underflow) + return 0; + + low = read_address (&ranges_buf, u->addrsize); + high = read_address (&ranges_buf, u->addrsize); + + if (low == 0 && high == 0) + break; + + if (is_highest_address (low, u->addrsize)) + base = high; + else + { + if (!add_function_range (state, ddata, function, low + base, + high + base, error_callback, data, vec)) + return 0; + } + } + + if (ranges_buf.reported_underflow) + return 0; + + return 1; +} + +/* Read one entry plus all its children. Add function addresses to + VEC. Returns 1 on success, 0 on error. */ + +static int +read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata, + struct unit *u, uint64_t base, struct dwarf_buf *unit_buf, + const struct line_header *lhdr, + backtrace_error_callback error_callback, void *data, + struct function_vector *vec_function, + struct function_vector *vec_inlined) +{ + while (unit_buf->left > 0) + { + uint64_t code; + const struct abbrev *abbrev; + int is_function; + struct function *function; + struct function_vector *vec; + size_t i; + uint64_t lowpc; + int have_lowpc; + uint64_t highpc; + int have_highpc; + int highpc_is_relative; + uint64_t ranges; + int have_ranges; + + code = read_uleb128 (unit_buf); + if (code == 0) + return 1; + + abbrev = lookup_abbrev (&u->abbrevs, code, error_callback, data); + if (abbrev == NULL) + return 0; + + is_function = (abbrev->tag == DW_TAG_subprogram + || abbrev->tag == DW_TAG_entry_point + || abbrev->tag == DW_TAG_inlined_subroutine); + + if (abbrev->tag == DW_TAG_inlined_subroutine) + vec = vec_inlined; + else + vec = vec_function; + + function = NULL; + if (is_function) + { + function = ((struct function *) + backtrace_alloc (state, sizeof *function, + error_callback, data)); + if (function == NULL) + return 0; + memset (function, 0, sizeof *function); + } + + lowpc = 0; + have_lowpc = 0; + highpc = 0; + have_highpc = 0; + highpc_is_relative = 0; + ranges = 0; + have_ranges = 0; + for (i = 0; i < abbrev->num_attrs; ++i) + { + struct attr_val val; + + if (!read_attribute (abbrev->attrs[i].form, unit_buf, + u->is_dwarf64, u->version, u->addrsize, + ddata->dwarf_str, ddata->dwarf_str_size, + &val)) + return 0; + + /* The compile unit sets the base address for any address + ranges in the function entries. */ + if (abbrev->tag == DW_TAG_compile_unit + && abbrev->attrs[i].name == DW_AT_low_pc + && val.encoding == ATTR_VAL_ADDRESS) + base = val.u.uint; + + if (is_function) + { + switch (abbrev->attrs[i].name) + { + case DW_AT_call_file: + if (val.encoding == ATTR_VAL_UINT) + { + if (val.u.uint == 0) + function->caller_filename = ""; + else + { + if (val.u.uint - 1 >= lhdr->filenames_count) + { + dwarf_buf_error (unit_buf, + ("invalid file number in " + "DW_AT_call_file attribute")); + return 0; + } + function->caller_filename = + lhdr->filenames[val.u.uint - 1]; + } + } + break; + + case DW_AT_call_line: + if (val.encoding == ATTR_VAL_UINT) + function->caller_lineno = val.u.uint; + break; + + case DW_AT_abstract_origin: + case DW_AT_specification: + if (abbrev->attrs[i].form == DW_FORM_ref_addr + || abbrev->attrs[i].form == DW_FORM_ref_sig8) + { + /* This refers to an abstract origin defined in + some other compilation unit. We can handle + this case if we must, but it's harder. */ + break; + } + if (val.encoding == ATTR_VAL_UINT + || val.encoding == ATTR_VAL_REF_UNIT) + { + const char *name; + + name = read_referenced_name (ddata, u, val.u.uint, + error_callback, data); + if (name != NULL) + function->name = name; + } + break; + + case DW_AT_name: + if (val.encoding == ATTR_VAL_STRING) + { + /* Don't override a name we found in some other + way, as it will normally be more + useful--e.g., this name is normally not + mangled. */ + if (function->name == NULL) + function->name = val.u.string; + } + break; + + case DW_AT_linkage_name: + case DW_AT_MIPS_linkage_name: + if (val.encoding == ATTR_VAL_STRING) + function->name = val.u.string; + break; + + case DW_AT_low_pc: + if (val.encoding == ATTR_VAL_ADDRESS) + { + lowpc = val.u.uint; + have_lowpc = 1; + } + break; + + case DW_AT_high_pc: + if (val.encoding == ATTR_VAL_ADDRESS) + { + highpc = val.u.uint; + have_highpc = 1; + } + else if (val.encoding == ATTR_VAL_UINT) + { + highpc = val.u.uint; + have_highpc = 1; + highpc_is_relative = 1; + } + break; + + case DW_AT_ranges: + if (val.encoding == ATTR_VAL_UINT + || val.encoding == ATTR_VAL_REF_SECTION) + { + ranges = val.u.uint; + have_ranges = 1; + } + break; + + default: + break; + } + } + } + + /* If we couldn't find a name for the function, we have no use + for it. */ + if (is_function && function->name == NULL) + { + backtrace_free (state, function, sizeof *function, + error_callback, data); + is_function = 0; + } + + if (is_function) + { + if (have_ranges) + { + if (!add_function_ranges (state, ddata, u, function, ranges, + base, error_callback, data, vec)) + return 0; + } + else if (have_lowpc && have_highpc) + { + if (highpc_is_relative) + highpc += lowpc; + if (!add_function_range (state, ddata, function, lowpc, highpc, + error_callback, data, vec)) + return 0; + } + else + { + backtrace_free (state, function, sizeof *function, + error_callback, data); + is_function = 0; + } + } + + if (abbrev->has_children) + { + if (!is_function) + { + if (!read_function_entry (state, ddata, u, base, unit_buf, lhdr, + error_callback, data, vec_function, + vec_inlined)) + return 0; + } + else + { + struct function_vector fvec; + + /* Gather any information for inlined functions in + FVEC. */ + + memset (&fvec, 0, sizeof fvec); + + if (!read_function_entry (state, ddata, u, base, unit_buf, lhdr, + error_callback, data, vec_function, + &fvec)) + return 0; + + if (fvec.count > 0) + { + struct function_addrs *faddrs; + + if (!backtrace_vector_release (state, &fvec.vec, + error_callback, data)) + return 0; + + faddrs = (struct function_addrs *) fvec.vec.base; + backtrace_qsort (faddrs, fvec.count, + sizeof (struct function_addrs), + function_addrs_compare); + + function->function_addrs = faddrs; + function->function_addrs_count = fvec.count; + } + } + } + } + + return 1; +} + +/* Read function name information for a compilation unit. We look + through the whole unit looking for function tags. */ + +static void +read_function_info (struct backtrace_state *state, struct dwarf_data *ddata, + const struct line_header *lhdr, + backtrace_error_callback error_callback, void *data, + struct unit *u, struct function_vector *fvec, + struct function_addrs **ret_addrs, + size_t *ret_addrs_count) +{ + struct function_vector lvec; + struct function_vector *pfvec; + struct dwarf_buf unit_buf; + struct function_addrs *addrs; + size_t addrs_count; + + /* Use FVEC if it is not NULL. Otherwise use our own vector. */ + if (fvec != NULL) + pfvec = fvec; + else + { + memset (&lvec, 0, sizeof lvec); + pfvec = &lvec; + } + + unit_buf.name = ".debug_info"; + unit_buf.start = ddata->dwarf_info; + unit_buf.buf = u->unit_data; + unit_buf.left = u->unit_data_len; + unit_buf.is_bigendian = ddata->is_bigendian; + unit_buf.error_callback = error_callback; + unit_buf.data = data; + unit_buf.reported_underflow = 0; + + while (unit_buf.left > 0) + { + if (!read_function_entry (state, ddata, u, 0, &unit_buf, lhdr, + error_callback, data, pfvec, pfvec)) + return; + } + + if (pfvec->count == 0) + return; + + addrs_count = pfvec->count; + + if (fvec == NULL) + { + if (!backtrace_vector_release (state, &lvec.vec, error_callback, data)) + return; + addrs = (struct function_addrs *) pfvec->vec.base; + } + else + { + /* Finish this list of addresses, but leave the remaining space in + the vector available for the next function unit. */ + addrs = ((struct function_addrs *) + backtrace_vector_finish (state, &fvec->vec, + error_callback, data)); + if (addrs == NULL) + return; + fvec->count = 0; + } + + backtrace_qsort (addrs, addrs_count, sizeof (struct function_addrs), + function_addrs_compare); + + *ret_addrs = addrs; + *ret_addrs_count = addrs_count; +} + +/* See if PC is inlined in FUNCTION. If it is, print out the inlined + information, and update FILENAME and LINENO for the caller. + Returns whatever CALLBACK returns, or 0 to keep going. */ + +static int +report_inlined_functions (uintptr_t pc, struct function *function, + backtrace_full_callback callback, void *data, + const char **filename, int *lineno) +{ + struct function_addrs *function_addrs; + struct function *inlined; + int ret; + + if (function->function_addrs_count == 0) + return 0; + + function_addrs = ((struct function_addrs *) + bsearch (&pc, function->function_addrs, + function->function_addrs_count, + sizeof (struct function_addrs), + function_addrs_search)); + if (function_addrs == NULL) + return 0; + + while (((size_t) (function_addrs - function->function_addrs) + 1 + < function->function_addrs_count) + && pc >= (function_addrs + 1)->low + && pc < (function_addrs + 1)->high) + ++function_addrs; + + /* We found an inlined call. */ + + inlined = function_addrs->function; + + /* Report any calls inlined into this one. */ + ret = report_inlined_functions (pc, inlined, callback, data, + filename, lineno); + if (ret != 0) + return ret; + + /* Report this inlined call. */ + ret = callback (data, pc, *filename, *lineno, inlined->name); + if (ret != 0) + return ret; + + /* Our caller will report the caller of the inlined function; tell + it the appropriate filename and line number. */ + *filename = inlined->caller_filename; + *lineno = inlined->caller_lineno; + + return 0; +} + +/* Look for a PC in the DWARF mapping for one module. On success, + call CALLBACK and return whatever it returns. On error, call + ERROR_CALLBACK and return 0. Sets *FOUND to 1 if the PC is found, + 0 if not. */ + +static int +dwarf_lookup_pc (struct backtrace_state *state, struct dwarf_data *ddata, + uintptr_t pc, backtrace_full_callback callback, + backtrace_error_callback error_callback, void *data, + int *found) +{ + struct unit_addrs *entry; + struct unit *u; + int new_data; + struct line *lines; + struct line *ln; + struct function_addrs *function_addrs; + struct function *function; + const char *filename; + int lineno; + int ret; + + *found = 1; + + /* Find an address range that includes PC. */ + entry = bsearch (&pc, ddata->addrs, ddata->addrs_count, + sizeof (struct unit_addrs), unit_addrs_search); + + if (entry == NULL) + { + *found = 0; + return 0; + } + + /* If there are multiple ranges that contain PC, use the last one, + in order to produce predictable results. If we assume that all + ranges are properly nested, then the last range will be the + smallest one. */ + while ((size_t) (entry - ddata->addrs) + 1 < ddata->addrs_count + && pc >= (entry + 1)->low + && pc < (entry + 1)->high) + ++entry; + + /* We need the lines, lines_count, function_addrs, + function_addrs_count fields of u. If they are not set, we need + to set them. When running in threaded mode, we need to allow for + the possibility that some other thread is setting them + simultaneously. */ + + u = entry->u; + lines = u->lines; + + /* Skip units with no useful line number information by walking + backward. Useless line number information is marked by setting + lines == -1. */ + while (entry > ddata->addrs + && pc >= (entry - 1)->low + && pc < (entry - 1)->high) + { + if (state->threaded) + lines = (struct line *) backtrace_atomic_load_pointer (&u->lines); + + if (lines != (struct line *) (uintptr_t) -1) + break; + + --entry; + + u = entry->u; + lines = u->lines; + } + + if (state->threaded) + lines = backtrace_atomic_load_pointer (&u->lines); + + new_data = 0; + if (lines == NULL) + { + size_t function_addrs_count; + struct line_header lhdr; + size_t count; + + /* We have never read the line information for this unit. Read + it now. */ + + function_addrs = NULL; + function_addrs_count = 0; + if (read_line_info (state, ddata, error_callback, data, entry->u, &lhdr, + &lines, &count)) + { + struct function_vector *pfvec; + + /* If not threaded, reuse DDATA->FVEC for better memory + consumption. */ + if (state->threaded) + pfvec = NULL; + else + pfvec = &ddata->fvec; + read_function_info (state, ddata, &lhdr, error_callback, data, + entry->u, pfvec, &function_addrs, + &function_addrs_count); + free_line_header (state, &lhdr, error_callback, data); + new_data = 1; + } + + /* Atomically store the information we just read into the unit. + If another thread is simultaneously writing, it presumably + read the same information, and we don't care which one we + wind up with; we just leak the other one. We do have to + write the lines field last, so that the acquire-loads above + ensure that the other fields are set. */ + + if (!state->threaded) + { + u->lines_count = count; + u->function_addrs = function_addrs; + u->function_addrs_count = function_addrs_count; + u->lines = lines; + } + else + { + backtrace_atomic_store_size_t (&u->lines_count, count); + backtrace_atomic_store_pointer (&u->function_addrs, function_addrs); + backtrace_atomic_store_size_t (&u->function_addrs_count, + function_addrs_count); + backtrace_atomic_store_pointer (&u->lines, lines); + } + } + + /* Now all fields of U have been initialized. */ + + if (lines == (struct line *) (uintptr_t) -1) + { + /* If reading the line number information failed in some way, + try again to see if there is a better compilation unit for + this PC. */ + if (new_data) + return dwarf_lookup_pc (state, ddata, pc, callback, error_callback, + data, found); + return callback (data, pc, NULL, 0, NULL); + } + + /* Search for PC within this unit. */ + + ln = (struct line *) bsearch (&pc, lines, entry->u->lines_count, + sizeof (struct line), line_search); + if (ln == NULL) + { + /* The PC is between the low_pc and high_pc attributes of the + compilation unit, but no entry in the line table covers it. + This implies that the start of the compilation unit has no + line number information. */ + + if (entry->u->abs_filename == NULL) + { + const char *filename; + + filename = entry->u->filename; + if (filename != NULL + && !IS_ABSOLUTE_PATH (filename) + && entry->u->comp_dir != NULL) + { + size_t filename_len; + const char *dir; + size_t dir_len; + char *s; + + filename_len = strlen (filename); + dir = entry->u->comp_dir; + dir_len = strlen (dir); + s = (char *) backtrace_alloc (state, dir_len + filename_len + 2, + error_callback, data); + if (s == NULL) + { + *found = 0; + return 0; + } + memcpy (s, dir, dir_len); + /* FIXME: Should use backslash if DOS file system. */ + s[dir_len] = '/'; + memcpy (s + dir_len + 1, filename, filename_len + 1); + filename = s; + } + entry->u->abs_filename = filename; + } + + return callback (data, pc, entry->u->abs_filename, 0, NULL); + } + + /* Search for function name within this unit. */ + + if (entry->u->function_addrs_count == 0) + return callback (data, pc, ln->filename, ln->lineno, NULL); + + function_addrs = ((struct function_addrs *) + bsearch (&pc, entry->u->function_addrs, + entry->u->function_addrs_count, + sizeof (struct function_addrs), + function_addrs_search)); + if (function_addrs == NULL) + return callback (data, pc, ln->filename, ln->lineno, NULL); + + /* If there are multiple function ranges that contain PC, use the + last one, in order to produce predictable results. */ + + while (((size_t) (function_addrs - entry->u->function_addrs + 1) + < entry->u->function_addrs_count) + && pc >= (function_addrs + 1)->low + && pc < (function_addrs + 1)->high) + ++function_addrs; + + function = function_addrs->function; + + filename = ln->filename; + lineno = ln->lineno; + + ret = report_inlined_functions (pc, function, callback, data, + &filename, &lineno); + if (ret != 0) + return ret; + + return callback (data, pc, filename, lineno, function->name); +} + + +/* Return the file/line information for a PC using the DWARF mapping + we built earlier. */ + +static int +dwarf_fileline (struct backtrace_state *state, uintptr_t pc, + backtrace_full_callback callback, + backtrace_error_callback error_callback, void *data) +{ + struct dwarf_data *ddata; + int found; + int ret; + + if (!state->threaded) + { + for (ddata = (struct dwarf_data *) state->fileline_data; + ddata != NULL; + ddata = ddata->next) + { + ret = dwarf_lookup_pc (state, ddata, pc, callback, error_callback, + data, &found); + if (ret != 0 || found) + return ret; + } + } + else + { + struct dwarf_data **pp; + + pp = (struct dwarf_data **) (void *) &state->fileline_data; + while (1) + { + ddata = backtrace_atomic_load_pointer (pp); + if (ddata == NULL) + break; + + ret = dwarf_lookup_pc (state, ddata, pc, callback, error_callback, + data, &found); + if (ret != 0 || found) + return ret; + + pp = &ddata->next; + } + } + + /* FIXME: See if any libraries have been dlopen'ed. */ + + return callback (data, pc, NULL, 0, NULL); +} + +/* Initialize our data structures from the DWARF debug info for a + file. Return NULL on failure. */ + +static struct dwarf_data * +build_dwarf_data (struct backtrace_state *state, + uintptr_t base_address, + const unsigned char *dwarf_info, + size_t dwarf_info_size, + const unsigned char *dwarf_line, + size_t dwarf_line_size, + const unsigned char *dwarf_abbrev, + size_t dwarf_abbrev_size, + const unsigned char *dwarf_ranges, + size_t dwarf_ranges_size, + const unsigned char *dwarf_str, + size_t dwarf_str_size, + int is_bigendian, + backtrace_error_callback error_callback, + void *data) +{ + struct unit_addrs_vector addrs_vec; + struct unit_addrs *addrs; + size_t addrs_count; + struct dwarf_data *fdata; + + if (!build_address_map (state, base_address, dwarf_info, dwarf_info_size, + dwarf_abbrev, dwarf_abbrev_size, dwarf_ranges, + dwarf_ranges_size, dwarf_str, dwarf_str_size, + is_bigendian, error_callback, data, &addrs_vec)) + return NULL; + + if (!backtrace_vector_release (state, &addrs_vec.vec, error_callback, data)) + return NULL; + addrs = (struct unit_addrs *) addrs_vec.vec.base; + addrs_count = addrs_vec.count; + backtrace_qsort (addrs, addrs_count, sizeof (struct unit_addrs), + unit_addrs_compare); + + fdata = ((struct dwarf_data *) + backtrace_alloc (state, sizeof (struct dwarf_data), + error_callback, data)); + if (fdata == NULL) + return NULL; + + fdata->next = NULL; + fdata->base_address = base_address; + fdata->addrs = addrs; + fdata->addrs_count = addrs_count; + fdata->dwarf_info = dwarf_info; + fdata->dwarf_info_size = dwarf_info_size; + fdata->dwarf_line = dwarf_line; + fdata->dwarf_line_size = dwarf_line_size; + fdata->dwarf_ranges = dwarf_ranges; + fdata->dwarf_ranges_size = dwarf_ranges_size; + fdata->dwarf_str = dwarf_str; + fdata->dwarf_str_size = dwarf_str_size; + fdata->is_bigendian = is_bigendian; + memset (&fdata->fvec, 0, sizeof fdata->fvec); + + return fdata; +} + +/* Build our data structures from the DWARF sections for a module. + Set FILELINE_FN and STATE->FILELINE_DATA. Return 1 on success, 0 + on failure. */ + +int +backtrace_dwarf_add (struct backtrace_state *state, + uintptr_t base_address, + const unsigned char *dwarf_info, + size_t dwarf_info_size, + const unsigned char *dwarf_line, + size_t dwarf_line_size, + const unsigned char *dwarf_abbrev, + size_t dwarf_abbrev_size, + const unsigned char *dwarf_ranges, + size_t dwarf_ranges_size, + const unsigned char *dwarf_str, + size_t dwarf_str_size, + int is_bigendian, + backtrace_error_callback error_callback, + void *data, fileline *fileline_fn) +{ + struct dwarf_data *fdata; + + fdata = build_dwarf_data (state, base_address, dwarf_info, dwarf_info_size, + dwarf_line, dwarf_line_size, dwarf_abbrev, + dwarf_abbrev_size, dwarf_ranges, dwarf_ranges_size, + dwarf_str, dwarf_str_size, is_bigendian, + error_callback, data); + if (fdata == NULL) + return 0; + + if (!state->threaded) + { + struct dwarf_data **pp; + + for (pp = (struct dwarf_data **) (void *) &state->fileline_data; + *pp != NULL; + pp = &(*pp)->next) + ; + *pp = fdata; + } + else + { + while (1) + { + struct dwarf_data **pp; + + pp = (struct dwarf_data **) (void *) &state->fileline_data; + + while (1) + { + struct dwarf_data *p; + + p = backtrace_atomic_load_pointer (pp); + + if (p == NULL) + break; + + pp = &p->next; + } + + if (__sync_bool_compare_and_swap (pp, NULL, fdata)) + break; + } + } + + *fileline_fn = dwarf_fileline; + + return 1; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/edtest.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/edtest.c new file mode 100644 index 0000000..3a2cac4 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/edtest.c @@ -0,0 +1,121 @@ +/* edtest.c -- Test for libbacktrace storage allocation stress handling + Copyright (C) 2017-2018 Free Software Foundation, Inc. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include +#include + +#include "backtrace.h" +#include "backtrace-supported.h" +#include "internal.h" + +#include "testlib.h" + +static int test1 (void) __attribute__ ((noinline, unused)); +static int test1 (void) __attribute__ ((noinline, unused)); +extern int f2 (int); +extern int f3 (int, int); + +static int +test1 (void) +{ + /* Returning a value here and elsewhere avoids a tailcall which + would mess up the backtrace. */ + return f2 (__LINE__) + 1; +} + +int +f3 (int f1line, int f2line) +{ + struct info all[20]; + struct bdata data; + int f3line; + int i; + + data.all = &all[0]; + data.index = 0; + data.max = 20; + data.failed = 0; + + f3line = __LINE__ + 1; + i = backtrace_full (state, 0, callback_one, error_callback_one, &data); + + if (i != 0) + { + fprintf (stderr, "test1: unexpected return value %d\n", i); + data.failed = 1; + } + + if (data.index < 3) + { + fprintf (stderr, + "test1: not enough frames; got %zu, expected at least 3\n", + data.index); + data.failed = 1; + } + + check ("test1", 0, all, f3line, "f3", "edtest.c", &data.failed); + check ("test1", 1, all, f2line, "f2", "edtest2_build.c", &data.failed); + check ("test1", 2, all, f1line, "test1", "edtest.c", &data.failed); + + printf ("%s: backtrace_full alloc stress\n", data.failed ? "FAIL" : "PASS"); + + if (data.failed) + ++failures; + + return failures; +} + +int +main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) +{ + state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS, + error_callback_create, NULL); + + // Grab the storage allocation lock prior to doing anything interesting. + // The intent here is to insure that the backtrace_alloc code is forced + // to always call mmap() for new memory as opposed to reusing previously + // allocated memory from the free list. Doing things this way helps + // simulate what you might see in a multithreaded program in which there + // are racing calls to the allocator. + struct backtrace_state *state_internal = + (struct backtrace_state *) state; + state_internal->lock_alloc = 1; + + // Kick off the test + test1(); + + exit (failures > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/edtest2.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/edtest2.c new file mode 100644 index 0000000..e0c0470 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/edtest2.c @@ -0,0 +1,43 @@ +/* edtest2.c -- Test for libbacktrace storage allocation stress handling (p2) + Copyright (C) 2017-2018 Free Software Foundation, Inc. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +/* This file intentionally written without any #include's + */ + +extern int f3(int, int); +extern int f2(int); + +int f2(int x) +{ + /* Returning a value here and elsewhere avoids a tailcall which + would mess up the backtrace. */ + return f3(x, __LINE__) + 3; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/elf.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/elf.c new file mode 100644 index 0000000..0fd5e6f --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/elf.c @@ -0,0 +1,3340 @@ +/* elf.c -- Get debug data from an ELF file for backtraces. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_DL_ITERATE_PHDR +#include +#endif + +#include "backtrace.h" +#include "internal.h" + +#ifndef S_ISLNK + #ifndef S_IFLNK + #define S_IFLNK 0120000 + #endif + #ifndef S_IFMT + #define S_IFMT 0170000 + #endif + #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#endif + +#ifndef __GNUC__ +#define __builtin_prefetch(p, r, l) +#define unlikely(x) (x) +#else +#define unlikely(x) __builtin_expect(!!(x), 0) +#endif + +#if !defined(HAVE_DECL_STRNLEN) || !HAVE_DECL_STRNLEN + +/* If strnlen is not declared, provide our own version. */ + +static size_t +xstrnlen (const char *s, size_t maxlen) +{ + size_t i; + + for (i = 0; i < maxlen; ++i) + if (s[i] == '\0') + break; + return i; +} + +#define strnlen xstrnlen + +#endif + +#ifndef HAVE_LSTAT + +/* Dummy version of lstat for systems that don't have it. */ + +static int +xlstat (const char *path ATTRIBUTE_UNUSED, struct stat *st ATTRIBUTE_UNUSED) +{ + return -1; +} + +#define lstat xlstat + +#endif + +#ifndef HAVE_READLINK + +/* Dummy version of readlink for systems that don't have it. */ + +static ssize_t +xreadlink (const char *path ATTRIBUTE_UNUSED, char *buf ATTRIBUTE_UNUSED, + size_t bufsz ATTRIBUTE_UNUSED) +{ + return -1; +} + +#define readlink xreadlink + +#endif + +#ifndef HAVE_DL_ITERATE_PHDR + +/* Dummy version of dl_iterate_phdr for systems that don't have it. */ + +#define dl_phdr_info x_dl_phdr_info +#define dl_iterate_phdr x_dl_iterate_phdr + +struct dl_phdr_info +{ + uintptr_t dlpi_addr; + const char *dlpi_name; +}; + +static int +dl_iterate_phdr (int (*callback) (struct dl_phdr_info *, + size_t, void *) ATTRIBUTE_UNUSED, + void *data ATTRIBUTE_UNUSED) +{ + return 0; +} + +#endif /* ! defined (HAVE_DL_ITERATE_PHDR) */ + +/* The configure script must tell us whether we are 32-bit or 64-bit + ELF. We could make this code test and support either possibility, + but there is no point. This code only works for the currently + running executable, which means that we know the ELF mode at + configure time. */ + +#if BACKTRACE_ELF_SIZE != 32 && BACKTRACE_ELF_SIZE != 64 +#error "Unknown BACKTRACE_ELF_SIZE" +#endif + +/* might #include which might define our constants + with slightly different values. Undefine them to be safe. */ + +#undef EI_NIDENT +#undef EI_MAG0 +#undef EI_MAG1 +#undef EI_MAG2 +#undef EI_MAG3 +#undef EI_CLASS +#undef EI_DATA +#undef EI_VERSION +#undef ELF_MAG0 +#undef ELF_MAG1 +#undef ELF_MAG2 +#undef ELF_MAG3 +#undef ELFCLASS32 +#undef ELFCLASS64 +#undef ELFDATA2LSB +#undef ELFDATA2MSB +#undef EV_CURRENT +#undef ET_DYN +#undef EM_PPC64 +#undef EF_PPC64_ABI +#undef SHN_LORESERVE +#undef SHN_XINDEX +#undef SHN_UNDEF +#undef SHT_PROGBITS +#undef SHT_SYMTAB +#undef SHT_STRTAB +#undef SHT_DYNSYM +#undef SHF_COMPRESSED +#undef STT_OBJECT +#undef STT_FUNC +#undef NT_GNU_BUILD_ID +#undef ELFCOMPRESS_ZLIB + +/* Basic types. */ + +typedef uint16_t b_elf_half; /* Elf_Half. */ +typedef uint32_t b_elf_word; /* Elf_Word. */ +typedef int32_t b_elf_sword; /* Elf_Sword. */ + +#if BACKTRACE_ELF_SIZE == 32 + +typedef uint32_t b_elf_addr; /* Elf_Addr. */ +typedef uint32_t b_elf_off; /* Elf_Off. */ + +typedef uint32_t b_elf_wxword; /* 32-bit Elf_Word, 64-bit ELF_Xword. */ + +#else + +typedef uint64_t b_elf_addr; /* Elf_Addr. */ +typedef uint64_t b_elf_off; /* Elf_Off. */ +typedef uint64_t b_elf_xword; /* Elf_Xword. */ +typedef int64_t b_elf_sxword; /* Elf_Sxword. */ + +typedef uint64_t b_elf_wxword; /* 32-bit Elf_Word, 64-bit ELF_Xword. */ + +#endif + +/* Data structures and associated constants. */ + +#define EI_NIDENT 16 + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */ + b_elf_half e_type; /* Identifies object file type */ + b_elf_half e_machine; /* Specifies required architecture */ + b_elf_word e_version; /* Identifies object file version */ + b_elf_addr e_entry; /* Entry point virtual address */ + b_elf_off e_phoff; /* Program header table file offset */ + b_elf_off e_shoff; /* Section header table file offset */ + b_elf_word e_flags; /* Processor-specific flags */ + b_elf_half e_ehsize; /* ELF header size in bytes */ + b_elf_half e_phentsize; /* Program header table entry size */ + b_elf_half e_phnum; /* Program header table entry count */ + b_elf_half e_shentsize; /* Section header table entry size */ + b_elf_half e_shnum; /* Section header table entry count */ + b_elf_half e_shstrndx; /* Section header string table index */ +} b_elf_ehdr; /* Elf_Ehdr. */ + +#define EI_MAG0 0 +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 +#define EI_DATA 5 +#define EI_VERSION 6 + +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' + +#define ELFCLASS32 1 +#define ELFCLASS64 2 + +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 + +#define EV_CURRENT 1 + +#define ET_DYN 3 + +#define EM_PPC64 21 +#define EF_PPC64_ABI 3 + +typedef struct { + b_elf_word sh_name; /* Section name, index in string tbl */ + b_elf_word sh_type; /* Type of section */ + b_elf_wxword sh_flags; /* Miscellaneous section attributes */ + b_elf_addr sh_addr; /* Section virtual addr at execution */ + b_elf_off sh_offset; /* Section file offset */ + b_elf_wxword sh_size; /* Size of section in bytes */ + b_elf_word sh_link; /* Index of another section */ + b_elf_word sh_info; /* Additional section information */ + b_elf_wxword sh_addralign; /* Section alignment */ + b_elf_wxword sh_entsize; /* Entry size if section holds table */ +} b_elf_shdr; /* Elf_Shdr. */ + +#define SHN_UNDEF 0x0000 /* Undefined section */ +#define SHN_LORESERVE 0xFF00 /* Begin range of reserved indices */ +#define SHN_XINDEX 0xFFFF /* Section index is held elsewhere */ + +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_DYNSYM 11 + +#define SHF_COMPRESSED 0x800 + +#if BACKTRACE_ELF_SIZE == 32 + +typedef struct +{ + b_elf_word st_name; /* Symbol name, index in string tbl */ + b_elf_addr st_value; /* Symbol value */ + b_elf_word st_size; /* Symbol size */ + unsigned char st_info; /* Symbol binding and type */ + unsigned char st_other; /* Visibility and other data */ + b_elf_half st_shndx; /* Symbol section index */ +} b_elf_sym; /* Elf_Sym. */ + +#else /* BACKTRACE_ELF_SIZE != 32 */ + +typedef struct +{ + b_elf_word st_name; /* Symbol name, index in string tbl */ + unsigned char st_info; /* Symbol binding and type */ + unsigned char st_other; /* Visibility and other data */ + b_elf_half st_shndx; /* Symbol section index */ + b_elf_addr st_value; /* Symbol value */ + b_elf_xword st_size; /* Symbol size */ +} b_elf_sym; /* Elf_Sym. */ + +#endif /* BACKTRACE_ELF_SIZE != 32 */ + +#define STT_OBJECT 1 +#define STT_FUNC 2 + +typedef struct +{ + uint32_t namesz; + uint32_t descsz; + uint32_t type; + char name[1]; +} b_elf_note; + +#define NT_GNU_BUILD_ID 3 + +#if BACKTRACE_ELF_SIZE == 32 + +typedef struct +{ + b_elf_word ch_type; /* Compresstion algorithm */ + b_elf_word ch_size; /* Uncompressed size */ + b_elf_word ch_addralign; /* Alignment for uncompressed data */ +} b_elf_chdr; /* Elf_Chdr */ + +#else /* BACKTRACE_ELF_SIZE != 32 */ + +typedef struct +{ + b_elf_word ch_type; /* Compression algorithm */ + b_elf_word ch_reserved; /* Reserved */ + b_elf_xword ch_size; /* Uncompressed size */ + b_elf_xword ch_addralign; /* Alignment for uncompressed data */ +} b_elf_chdr; /* Elf_Chdr */ + +#endif /* BACKTRACE_ELF_SIZE != 32 */ + +#define ELFCOMPRESS_ZLIB 1 + +/* An index of ELF sections we care about. */ + +enum debug_section +{ + DEBUG_INFO, + DEBUG_LINE, + DEBUG_ABBREV, + DEBUG_RANGES, + DEBUG_STR, + + /* The old style compressed sections. This list must correspond to + the list of normal debug sections. */ + ZDEBUG_INFO, + ZDEBUG_LINE, + ZDEBUG_ABBREV, + ZDEBUG_RANGES, + ZDEBUG_STR, + + DEBUG_MAX +}; + +/* Names of sections, indexed by enum elf_section. */ + +static const char * const debug_section_names[DEBUG_MAX] = +{ + ".debug_info", + ".debug_line", + ".debug_abbrev", + ".debug_ranges", + ".debug_str", + ".zdebug_info", + ".zdebug_line", + ".zdebug_abbrev", + ".zdebug_ranges", + ".zdebug_str" +}; + +/* Information we gather for the sections we care about. */ + +struct debug_section_info +{ + /* Section file offset. */ + off_t offset; + /* Section size. */ + size_t size; + /* Section contents, after read from file. */ + const unsigned char *data; + /* Whether the SHF_COMPRESSED flag is set for the section. */ + int compressed; +}; + +/* Information we keep for an ELF symbol. */ + +struct elf_symbol +{ + /* The name of the symbol. */ + const char *name; + /* The address of the symbol. */ + uintptr_t address; + /* The size of the symbol. */ + size_t size; +}; + +/* Information to pass to elf_syminfo. */ + +struct elf_syminfo_data +{ + /* Symbols for the next module. */ + struct elf_syminfo_data *next; + /* The ELF symbols, sorted by address. */ + struct elf_symbol *symbols; + /* The number of symbols. */ + size_t count; +}; + +/* Information about PowerPC64 ELFv1 .opd section. */ + +struct elf_ppc64_opd_data +{ + /* Address of the .opd section. */ + b_elf_addr addr; + /* Section data. */ + const char *data; + /* Size of the .opd section. */ + size_t size; + /* Corresponding section view. */ + struct backtrace_view view; +}; + +/* Compute the CRC-32 of BUF/LEN. This uses the CRC used for + .gnu_debuglink files. */ + +static uint32_t +elf_crc32 (uint32_t crc, const unsigned char *buf, size_t len) +{ + static const uint32_t crc32_table[256] = + { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d + }; + const unsigned char *end; + + crc = ~crc; + for (end = buf + len; buf < end; ++ buf) + crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8); + return ~crc; +} + +/* Return the CRC-32 of the entire file open at DESCRIPTOR. */ + +static uint32_t +elf_crc32_file (struct backtrace_state *state, int descriptor, + backtrace_error_callback error_callback, void *data) +{ + struct stat st; + struct backtrace_view file_view; + uint32_t ret; + + if (fstat (descriptor, &st) < 0) + { + error_callback (data, "fstat", errno); + return 0; + } + + if (!backtrace_get_view (state, descriptor, 0, st.st_size, error_callback, + data, &file_view)) + return 0; + + ret = elf_crc32 (0, (const unsigned char *) file_view.data, st.st_size); + + backtrace_release_view (state, &file_view, error_callback, data); + + return ret; +} + +/* A dummy callback function used when we can't find any debug info. */ + +static int +elf_nodebug (struct backtrace_state *state ATTRIBUTE_UNUSED, + uintptr_t pc ATTRIBUTE_UNUSED, + backtrace_full_callback callback ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, void *data) +{ + error_callback (data, "no debug info in ELF executable", -1); + return 0; +} + +/* A dummy callback function used when we can't find a symbol + table. */ + +static void +elf_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED, + uintptr_t addr ATTRIBUTE_UNUSED, + backtrace_syminfo_callback callback ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, void *data) +{ + error_callback (data, "no symbol table in ELF executable", -1); +} + +/* Compare struct elf_symbol for qsort. */ + +static int +elf_symbol_compare (const void *v1, const void *v2) +{ + const struct elf_symbol *e1 = (const struct elf_symbol *) v1; + const struct elf_symbol *e2 = (const struct elf_symbol *) v2; + + if (e1->address < e2->address) + return -1; + else if (e1->address > e2->address) + return 1; + else + return 0; +} + +/* Compare an ADDR against an elf_symbol for bsearch. We allocate one + extra entry in the array so that this can look safely at the next + entry. */ + +static int +elf_symbol_search (const void *vkey, const void *ventry) +{ + const uintptr_t *key = (const uintptr_t *) vkey; + const struct elf_symbol *entry = (const struct elf_symbol *) ventry; + uintptr_t addr; + + addr = *key; + if (addr < entry->address) + return -1; + else if (addr >= entry->address + entry->size) + return 1; + else + return 0; +} + +/* Initialize the symbol table info for elf_syminfo. */ + +static int +elf_initialize_syminfo (struct backtrace_state *state, + uintptr_t base_address, + const unsigned char *symtab_data, size_t symtab_size, + const unsigned char *strtab, size_t strtab_size, + backtrace_error_callback error_callback, + void *data, struct elf_syminfo_data *sdata, + struct elf_ppc64_opd_data *opd) +{ + size_t sym_count; + const b_elf_sym *sym; + size_t elf_symbol_count; + size_t elf_symbol_size; + struct elf_symbol *elf_symbols; + size_t i; + unsigned int j; + + sym_count = symtab_size / sizeof (b_elf_sym); + + /* We only care about function symbols. Count them. */ + sym = (const b_elf_sym *) symtab_data; + elf_symbol_count = 0; + for (i = 0; i < sym_count; ++i, ++sym) + { + int info; + + info = sym->st_info & 0xf; + if ((info == STT_FUNC || info == STT_OBJECT) + && sym->st_shndx != SHN_UNDEF) + ++elf_symbol_count; + } + + elf_symbol_size = elf_symbol_count * sizeof (struct elf_symbol); + elf_symbols = ((struct elf_symbol *) + backtrace_alloc (state, elf_symbol_size, error_callback, + data)); + if (elf_symbols == NULL) + return 0; + + sym = (const b_elf_sym *) symtab_data; + j = 0; + for (i = 0; i < sym_count; ++i, ++sym) + { + int info; + + info = sym->st_info & 0xf; + if (info != STT_FUNC && info != STT_OBJECT) + continue; + if (sym->st_shndx == SHN_UNDEF) + continue; + if (sym->st_name >= strtab_size) + { + error_callback (data, "symbol string index out of range", 0); + backtrace_free (state, elf_symbols, elf_symbol_size, error_callback, + data); + return 0; + } + elf_symbols[j].name = (const char *) strtab + sym->st_name; + /* Special case PowerPC64 ELFv1 symbols in .opd section, if the symbol + is a function descriptor, read the actual code address from the + descriptor. */ + if (opd + && sym->st_value >= opd->addr + && sym->st_value < opd->addr + opd->size) + elf_symbols[j].address + = *(const b_elf_addr *) (opd->data + (sym->st_value - opd->addr)); + else + elf_symbols[j].address = sym->st_value; + elf_symbols[j].address += base_address; + elf_symbols[j].size = sym->st_size; + ++j; + } + + backtrace_qsort (elf_symbols, elf_symbol_count, sizeof (struct elf_symbol), + elf_symbol_compare); + + sdata->next = NULL; + sdata->symbols = elf_symbols; + sdata->count = elf_symbol_count; + + return 1; +} + +/* Add EDATA to the list in STATE. */ + +static void +elf_add_syminfo_data (struct backtrace_state *state, + struct elf_syminfo_data *edata) +{ + if (!state->threaded) + { + struct elf_syminfo_data **pp; + + for (pp = (struct elf_syminfo_data **) (void *) &state->syminfo_data; + *pp != NULL; + pp = &(*pp)->next) + ; + *pp = edata; + } + else + { + while (1) + { + struct elf_syminfo_data **pp; + + pp = (struct elf_syminfo_data **) (void *) &state->syminfo_data; + + while (1) + { + struct elf_syminfo_data *p; + + p = backtrace_atomic_load_pointer (pp); + + if (p == NULL) + break; + + pp = &p->next; + } + + if (__sync_bool_compare_and_swap (pp, NULL, edata)) + break; + } + } +} + +/* Return the symbol name and value for an ADDR. */ + +static void +elf_syminfo (struct backtrace_state *state, uintptr_t addr, + backtrace_syminfo_callback callback, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data) +{ + struct elf_syminfo_data *edata; + struct elf_symbol *sym = NULL; + + if (!state->threaded) + { + for (edata = (struct elf_syminfo_data *) state->syminfo_data; + edata != NULL; + edata = edata->next) + { + sym = ((struct elf_symbol *) + bsearch (&addr, edata->symbols, edata->count, + sizeof (struct elf_symbol), elf_symbol_search)); + if (sym != NULL) + break; + } + } + else + { + struct elf_syminfo_data **pp; + + pp = (struct elf_syminfo_data **) (void *) &state->syminfo_data; + while (1) + { + edata = backtrace_atomic_load_pointer (pp); + if (edata == NULL) + break; + + sym = ((struct elf_symbol *) + bsearch (&addr, edata->symbols, edata->count, + sizeof (struct elf_symbol), elf_symbol_search)); + if (sym != NULL) + break; + + pp = &edata->next; + } + } + + if (sym == NULL) + callback (data, addr, NULL, 0, 0); + else + callback (data, addr, sym->name, sym->address, sym->size); +} + +/* Return whether FILENAME is a symlink. */ + +static int +elf_is_symlink (const char *filename) +{ + struct stat st; + + if (lstat (filename, &st) < 0) + return 0; + return S_ISLNK (st.st_mode); +} + +/* Return the results of reading the symlink FILENAME in a buffer + allocated by backtrace_alloc. Return the length of the buffer in + *LEN. */ + +static char * +elf_readlink (struct backtrace_state *state, const char *filename, + backtrace_error_callback error_callback, void *data, + size_t *plen) +{ + size_t len; + char *buf; + + len = 128; + while (1) + { + ssize_t rl; + + buf = backtrace_alloc (state, len, error_callback, data); + if (buf == NULL) + return NULL; + rl = readlink (filename, buf, len); + if (rl < 0) + { + backtrace_free (state, buf, len, error_callback, data); + return NULL; + } + if ((size_t) rl < len - 1) + { + buf[rl] = '\0'; + *plen = len; + return buf; + } + backtrace_free (state, buf, len, error_callback, data); + len *= 2; + } +} + +/* Open a separate debug info file, using the build ID to find it. + Returns an open file descriptor, or -1. + + The GDB manual says that the only place gdb looks for a debug file + when the build ID is known is in /usr/lib/debug/.build-id. */ + +static int +elf_open_debugfile_by_buildid (struct backtrace_state *state, + const char *buildid_data, size_t buildid_size, + backtrace_error_callback error_callback, + void *data) +{ + const char * const prefix = "/usr/lib/debug/.build-id/"; + const size_t prefix_len = strlen (prefix); + const char * const suffix = ".debug"; + const size_t suffix_len = strlen (suffix); + size_t len; + char *bd_filename; + char *t; + size_t i; + int ret; + int does_not_exist; + + len = prefix_len + buildid_size * 2 + suffix_len + 2; + bd_filename = backtrace_alloc (state, len, error_callback, data); + if (bd_filename == NULL) + return -1; + + t = bd_filename; + memcpy (t, prefix, prefix_len); + t += prefix_len; + for (i = 0; i < buildid_size; i++) + { + unsigned char b; + unsigned char nib; + + b = (unsigned char) buildid_data[i]; + nib = (b & 0xf0) >> 4; + *t++ = nib < 10 ? '0' + nib : 'a' + nib - 10; + nib = b & 0x0f; + *t++ = nib < 10 ? '0' + nib : 'a' + nib - 10; + if (i == 0) + *t++ = '/'; + } + memcpy (t, suffix, suffix_len); + t[suffix_len] = '\0'; + + ret = backtrace_open (bd_filename, error_callback, data, &does_not_exist); + + backtrace_free (state, bd_filename, len, error_callback, data); + + /* gdb checks that the debuginfo file has the same build ID note. + That seems kind of pointless to me--why would it have the right + name but not the right build ID?--so skipping the check. */ + + return ret; +} + +/* Try to open a file whose name is PREFIX (length PREFIX_LEN) + concatenated with PREFIX2 (length PREFIX2_LEN) concatenated with + DEBUGLINK_NAME. Returns an open file descriptor, or -1. */ + +static int +elf_try_debugfile (struct backtrace_state *state, const char *prefix, + size_t prefix_len, const char *prefix2, size_t prefix2_len, + const char *debuglink_name, + backtrace_error_callback error_callback, void *data) +{ + size_t debuglink_len; + size_t try_len; + char *try; + int does_not_exist; + int ret; + + debuglink_len = strlen (debuglink_name); + try_len = prefix_len + prefix2_len + debuglink_len + 1; + try = backtrace_alloc (state, try_len, error_callback, data); + if (try == NULL) + return -1; + + memcpy (try, prefix, prefix_len); + memcpy (try + prefix_len, prefix2, prefix2_len); + memcpy (try + prefix_len + prefix2_len, debuglink_name, debuglink_len); + try[prefix_len + prefix2_len + debuglink_len] = '\0'; + + ret = backtrace_open (try, error_callback, data, &does_not_exist); + + backtrace_free (state, try, try_len, error_callback, data); + + return ret; +} + +/* Find a separate debug info file, using the debuglink section data + to find it. Returns an open file descriptor, or -1. */ + +static int +elf_find_debugfile_by_debuglink (struct backtrace_state *state, + const char *filename, + const char *debuglink_name, + backtrace_error_callback error_callback, + void *data) +{ + int ret; + char *alc; + size_t alc_len; + const char *slash; + int ddescriptor; + const char *prefix; + size_t prefix_len; + + /* Resolve symlinks in FILENAME. Since FILENAME is fairly likely to + be /proc/self/exe, symlinks are common. We don't try to resolve + the whole path name, just the base name. */ + ret = -1; + alc = NULL; + alc_len = 0; + while (elf_is_symlink (filename)) + { + char *new_buf; + size_t new_len; + + new_buf = elf_readlink (state, filename, error_callback, data, &new_len); + if (new_buf == NULL) + break; + + if (new_buf[0] == '/') + filename = new_buf; + else + { + slash = strrchr (filename, '/'); + if (slash == NULL) + filename = new_buf; + else + { + size_t clen; + char *c; + + slash++; + clen = slash - filename + strlen (new_buf) + 1; + c = backtrace_alloc (state, clen, error_callback, data); + if (c == NULL) + goto done; + + memcpy (c, filename, slash - filename); + memcpy (c + (slash - filename), new_buf, strlen (new_buf)); + c[slash - filename + strlen (new_buf)] = '\0'; + backtrace_free (state, new_buf, new_len, error_callback, data); + filename = c; + new_buf = c; + new_len = clen; + } + } + + if (alc != NULL) + backtrace_free (state, alc, alc_len, error_callback, data); + alc = new_buf; + alc_len = new_len; + } + + /* Look for DEBUGLINK_NAME in the same directory as FILENAME. */ + + slash = strrchr (filename, '/'); + if (slash == NULL) + { + prefix = ""; + prefix_len = 0; + } + else + { + slash++; + prefix = filename; + prefix_len = slash - filename; + } + + ddescriptor = elf_try_debugfile (state, prefix, prefix_len, "", 0, + debuglink_name, error_callback, data); + if (ddescriptor >= 0) + { + ret = ddescriptor; + goto done; + } + + /* Look for DEBUGLINK_NAME in a .debug subdirectory of FILENAME. */ + + ddescriptor = elf_try_debugfile (state, prefix, prefix_len, ".debug/", + strlen (".debug/"), debuglink_name, + error_callback, data); + if (ddescriptor >= 0) + { + ret = ddescriptor; + goto done; + } + + /* Look for DEBUGLINK_NAME in /usr/lib/debug. */ + + ddescriptor = elf_try_debugfile (state, "/usr/lib/debug/", + strlen ("/usr/lib/debug/"), prefix, + prefix_len, debuglink_name, + error_callback, data); + if (ddescriptor >= 0) + ret = ddescriptor; + + done: + if (alc != NULL && alc_len > 0) + backtrace_free (state, alc, alc_len, error_callback, data); + return ret; +} + +/* Open a separate debug info file, using the debuglink section data + to find it. Returns an open file descriptor, or -1. */ + +static int +elf_open_debugfile_by_debuglink (struct backtrace_state *state, + const char *filename, + const char *debuglink_name, + uint32_t debuglink_crc, + backtrace_error_callback error_callback, + void *data) +{ + int ddescriptor; + + ddescriptor = elf_find_debugfile_by_debuglink (state, filename, + debuglink_name, + error_callback, data); + if (ddescriptor < 0) + return -1; + + if (debuglink_crc != 0) + { + uint32_t got_crc; + + got_crc = elf_crc32_file (state, ddescriptor, error_callback, data); + if (got_crc != debuglink_crc) + { + backtrace_close (ddescriptor, error_callback, data); + return -1; + } + } + + return ddescriptor; +} + +/* A function useful for setting a breakpoint for an inflation failure + when this code is compiled with -g. */ + +static void +elf_zlib_failed(void) +{ +} + +/* *PVAL is the current value being read from the stream, and *PBITS + is the number of valid bits. Ensure that *PVAL holds at least 15 + bits by reading additional bits from *PPIN, up to PINEND, as + needed. Updates *PPIN, *PVAL and *PBITS. Returns 1 on success, 0 + on error. */ + +static int +elf_zlib_fetch (const unsigned char **ppin, const unsigned char *pinend, + uint64_t *pval, unsigned int *pbits) +{ + unsigned int bits; + const unsigned char *pin; + uint64_t val; + uint32_t next; + + bits = *pbits; + if (bits >= 15) + return 1; + pin = *ppin; + val = *pval; + + if (unlikely (pinend - pin < 4)) + { + elf_zlib_failed (); + return 0; + } + +#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) \ + && defined(__ORDER_BIG_ENDIAN__) \ + && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ \ + || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + /* We've ensured that PIN is aligned. */ + next = *(const uint32_t *)pin; + +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + next = __builtin_bswap32 (next); +#endif +#else + next = pin[0] | (pin[1] << 8) | (pin[2] << 16) | (pin[3] << 24); +#endif + + val |= (uint64_t)next << bits; + bits += 32; + pin += 4; + + /* We will need the next four bytes soon. */ + __builtin_prefetch (pin, 0, 0); + + *ppin = pin; + *pval = val; + *pbits = bits; + return 1; +} + +/* Huffman code tables, like the rest of the zlib format, are defined + by RFC 1951. We store a Huffman code table as a series of tables + stored sequentially in memory. Each entry in a table is 16 bits. + The first, main, table has 256 entries. It is followed by a set of + secondary tables of length 2 to 128 entries. The maximum length of + a code sequence in the deflate format is 15 bits, so that is all we + need. Each secondary table has an index, which is the offset of + the table in the overall memory storage. + + The deflate format says that all codes of a given bit length are + lexicographically consecutive. Perhaps we could have 130 values + that require a 15-bit code, perhaps requiring three secondary + tables of size 128. I don't know if this is actually possible, but + it suggests that the maximum size required for secondary tables is + 3 * 128 + 3 * 64 ... == 768. The zlib enough program reports 660 + as the maximum. We permit 768, since in addition to the 256 for + the primary table, with two bytes per entry, and with the two + tables we need, that gives us a page. + + A single table entry needs to store a value or (for the main table + only) the index and size of a secondary table. Values range from 0 + to 285, inclusive. Secondary table indexes, per above, range from + 0 to 510. For a value we need to store the number of bits we need + to determine that value (one value may appear multiple times in the + table), which is 1 to 8. For a secondary table we need to store + the number of bits used to index into the table, which is 1 to 7. + And of course we need 1 bit to decide whether we have a value or a + secondary table index. So each entry needs 9 bits for value/table + index, 3 bits for size, 1 bit what it is. For simplicity we use 16 + bits per entry. */ + +/* Number of entries we allocate to for one code table. We get a page + for the two code tables we need. */ + +#define HUFFMAN_TABLE_SIZE (1024) + +/* Bit masks and shifts for the values in the table. */ + +#define HUFFMAN_VALUE_MASK 0x01ff +#define HUFFMAN_BITS_SHIFT 9 +#define HUFFMAN_BITS_MASK 0x7 +#define HUFFMAN_SECONDARY_SHIFT 12 + +/* For working memory while inflating we need two code tables, we need + an array of code lengths (max value 15, so we use unsigned char), + and an array of unsigned shorts used while building a table. The + latter two arrays must be large enough to hold the maximum number + of code lengths, which RFC 1951 defines as 286 + 30. */ + +#define ZDEBUG_TABLE_SIZE \ + (2 * HUFFMAN_TABLE_SIZE * sizeof (uint16_t) \ + + (286 + 30) * sizeof (uint16_t) \ + + (286 + 30) * sizeof (unsigned char)) + +#define ZDEBUG_TABLE_CODELEN_OFFSET \ + (2 * HUFFMAN_TABLE_SIZE * sizeof (uint16_t) \ + + (286 + 30) * sizeof (uint16_t)) + +#define ZDEBUG_TABLE_WORK_OFFSET \ + (2 * HUFFMAN_TABLE_SIZE * sizeof (uint16_t)) + +#ifdef BACKTRACE_GENERATE_FIXED_HUFFMAN_TABLE + +/* Used by the main function that generates the fixed table to learn + the table size. */ +static size_t final_next_secondary; + +#endif + +/* Build a Huffman code table from an array of lengths in CODES of + length CODES_LEN. The table is stored into *TABLE. ZDEBUG_TABLE + is the same as for elf_zlib_inflate, used to find some work space. + Returns 1 on success, 0 on error. */ + +static int +elf_zlib_inflate_table (unsigned char *codes, size_t codes_len, + uint16_t *zdebug_table, uint16_t *table) +{ + uint16_t count[16]; + uint16_t start[16]; + uint16_t prev[16]; + uint16_t firstcode[7]; + uint16_t *next; + size_t i; + size_t j; + unsigned int code; + size_t next_secondary; + + /* Count the number of code of each length. Set NEXT[val] to be the + next value after VAL with the same bit length. */ + + next = (uint16_t *) (((unsigned char *) zdebug_table) + + ZDEBUG_TABLE_WORK_OFFSET); + + memset (&count[0], 0, 16 * sizeof (uint16_t)); + for (i = 0; i < codes_len; ++i) + { + if (unlikely (codes[i] >= 16)) + { + elf_zlib_failed (); + return 0; + } + + if (count[codes[i]] == 0) + { + start[codes[i]] = i; + prev[codes[i]] = i; + } + else + { + next[prev[codes[i]]] = i; + prev[codes[i]] = i; + } + + ++count[codes[i]]; + } + + /* For each length, fill in the table for the codes of that + length. */ + + memset (table, 0, HUFFMAN_TABLE_SIZE * sizeof (uint16_t)); + + /* Handle the values that do not require a secondary table. */ + + code = 0; + for (j = 1; j <= 8; ++j) + { + unsigned int jcnt; + unsigned int val; + + jcnt = count[j]; + if (jcnt == 0) + continue; + + if (unlikely (jcnt > (1U << j))) + { + elf_zlib_failed (); + return 0; + } + + /* There are JCNT values that have this length, the values + starting from START[j] continuing through NEXT[VAL]. Those + values are assigned consecutive values starting at CODE. */ + + val = start[j]; + for (i = 0; i < jcnt; ++i) + { + uint16_t tval; + size_t ind; + unsigned int incr; + + /* In the compressed bit stream, the value VAL is encoded as + J bits with the value C. */ + + if (unlikely ((val & ~HUFFMAN_VALUE_MASK) != 0)) + { + elf_zlib_failed (); + return 0; + } + + tval = val | ((j - 1) << HUFFMAN_BITS_SHIFT); + + /* The table lookup uses 8 bits. If J is less than 8, we + don't know what the other bits will be. We need to fill + in all possibilities in the table. Since the Huffman + code is unambiguous, those entries can't be used for any + other code. */ + + for (ind = code; ind < 0x100; ind += 1 << j) + { + if (unlikely (table[ind] != 0)) + { + elf_zlib_failed (); + return 0; + } + table[ind] = tval; + } + + /* Advance to the next value with this length. */ + if (i + 1 < jcnt) + val = next[val]; + + /* The Huffman codes are stored in the bitstream with the + most significant bit first, as is required to make them + unambiguous. The effect is that when we read them from + the bitstream we see the bit sequence in reverse order: + the most significant bit of the Huffman code is the least + significant bit of the value we read from the bitstream. + That means that to make our table lookups work, we need + to reverse the bits of CODE. Since reversing bits is + tedious and in general requires using a table, we instead + increment CODE in reverse order. That is, if the number + of bits we are currently using, here named J, is 3, we + count as 000, 100, 010, 110, 001, 101, 011, 111, which is + to say the numbers from 0 to 7 but with the bits + reversed. Going to more bits, aka incrementing J, + effectively just adds more zero bits as the beginning, + and as such does not change the numeric value of CODE. + + To increment CODE of length J in reverse order, find the + most significant zero bit and set it to one while + clearing all higher bits. In other words, add 1 modulo + 2^J, only reversed. */ + + incr = 1U << (j - 1); + while ((code & incr) != 0) + incr >>= 1; + if (incr == 0) + code = 0; + else + { + code &= incr - 1; + code += incr; + } + } + } + + /* Handle the values that require a secondary table. */ + + /* Set FIRSTCODE, the number at which the codes start, for each + length. */ + + for (j = 9; j < 16; j++) + { + unsigned int jcnt; + unsigned int k; + + jcnt = count[j]; + if (jcnt == 0) + continue; + + /* There are JCNT values that have this length, the values + starting from START[j]. Those values are assigned + consecutive values starting at CODE. */ + + firstcode[j - 9] = code; + + /* Reverse add JCNT to CODE modulo 2^J. */ + for (k = 0; k < j; ++k) + { + if ((jcnt & (1U << k)) != 0) + { + unsigned int m; + unsigned int bit; + + bit = 1U << (j - k - 1); + for (m = 0; m < j - k; ++m, bit >>= 1) + { + if ((code & bit) == 0) + { + code += bit; + break; + } + code &= ~bit; + } + jcnt &= ~(1U << k); + } + } + if (unlikely (jcnt != 0)) + { + elf_zlib_failed (); + return 0; + } + } + + /* For J from 9 to 15, inclusive, we store COUNT[J] consecutive + values starting at START[J] with consecutive codes starting at + FIRSTCODE[J - 9]. In the primary table we need to point to the + secondary table, and the secondary table will be indexed by J - 9 + bits. We count down from 15 so that we install the larger + secondary tables first, as the smaller ones may be embedded in + the larger ones. */ + + next_secondary = 0; /* Index of next secondary table (after primary). */ + for (j = 15; j >= 9; j--) + { + unsigned int jcnt; + unsigned int val; + size_t primary; /* Current primary index. */ + size_t secondary; /* Offset to current secondary table. */ + size_t secondary_bits; /* Bit size of current secondary table. */ + + jcnt = count[j]; + if (jcnt == 0) + continue; + + val = start[j]; + code = firstcode[j - 9]; + primary = 0x100; + secondary = 0; + secondary_bits = 0; + for (i = 0; i < jcnt; ++i) + { + uint16_t tval; + size_t ind; + unsigned int incr; + + if ((code & 0xff) != primary) + { + uint16_t tprimary; + + /* Fill in a new primary table entry. */ + + primary = code & 0xff; + + tprimary = table[primary]; + if (tprimary == 0) + { + /* Start a new secondary table. */ + + if (unlikely ((next_secondary & HUFFMAN_VALUE_MASK) + != next_secondary)) + { + elf_zlib_failed (); + return 0; + } + + secondary = next_secondary; + secondary_bits = j - 8; + next_secondary += 1 << secondary_bits; + table[primary] = (secondary + + ((j - 8) << HUFFMAN_BITS_SHIFT) + + (1U << HUFFMAN_SECONDARY_SHIFT)); + } + else + { + /* There is an existing entry. It had better be a + secondary table with enough bits. */ + if (unlikely ((tprimary & (1U << HUFFMAN_SECONDARY_SHIFT)) + == 0)) + { + elf_zlib_failed (); + return 0; + } + secondary = tprimary & HUFFMAN_VALUE_MASK; + secondary_bits = ((tprimary >> HUFFMAN_BITS_SHIFT) + & HUFFMAN_BITS_MASK); + if (unlikely (secondary_bits < j - 8)) + { + elf_zlib_failed (); + return 0; + } + } + } + + /* Fill in secondary table entries. */ + + tval = val | ((j - 8) << HUFFMAN_BITS_SHIFT); + + for (ind = code >> 8; + ind < (1U << secondary_bits); + ind += 1U << (j - 8)) + { + if (unlikely (table[secondary + 0x100 + ind] != 0)) + { + elf_zlib_failed (); + return 0; + } + table[secondary + 0x100 + ind] = tval; + } + + if (i + 1 < jcnt) + val = next[val]; + + incr = 1U << (j - 1); + while ((code & incr) != 0) + incr >>= 1; + if (incr == 0) + code = 0; + else + { + code &= incr - 1; + code += incr; + } + } + } + +#ifdef BACKTRACE_GENERATE_FIXED_HUFFMAN_TABLE + final_next_secondary = next_secondary; +#endif + + return 1; +} + +#ifdef BACKTRACE_GENERATE_FIXED_HUFFMAN_TABLE + +/* Used to generate the fixed Huffman table for block type 1. */ + +#include + +static uint16_t table[ZDEBUG_TABLE_SIZE]; +static unsigned char codes[288]; + +int +main () +{ + size_t i; + + for (i = 0; i <= 143; ++i) + codes[i] = 8; + for (i = 144; i <= 255; ++i) + codes[i] = 9; + for (i = 256; i <= 279; ++i) + codes[i] = 7; + for (i = 280; i <= 287; ++i) + codes[i] = 8; + if (!elf_zlib_inflate_table (&codes[0], 288, &table[0], &table[0])) + { + fprintf (stderr, "elf_zlib_inflate_table failed\n"); + exit (EXIT_FAILURE); + } + + printf ("static const uint16_t elf_zlib_default_table[%#zx] =\n", + final_next_secondary + 0x100); + printf ("{\n"); + for (i = 0; i < final_next_secondary + 0x100; i += 8) + { + size_t j; + + printf (" "); + for (j = i; j < final_next_secondary + 0x100 && j < i + 8; ++j) + printf (" %#x,", table[j]); + printf ("\n"); + } + printf ("};\n"); + printf ("\n"); + + for (i = 0; i < 32; ++i) + codes[i] = 5; + if (!elf_zlib_inflate_table (&codes[0], 32, &table[0], &table[0])) + { + fprintf (stderr, "elf_zlib_inflate_table failed\n"); + exit (EXIT_FAILURE); + } + + printf ("static const uint16_t elf_zlib_default_dist_table[%#zx] =\n", + final_next_secondary + 0x100); + printf ("{\n"); + for (i = 0; i < final_next_secondary + 0x100; i += 8) + { + size_t j; + + printf (" "); + for (j = i; j < final_next_secondary + 0x100 && j < i + 8; ++j) + printf (" %#x,", table[j]); + printf ("\n"); + } + printf ("};\n"); + + return 0; +} + +#endif + +/* The fixed tables generated by the #ifdef'ed out main function + above. */ + +static const uint16_t elf_zlib_default_table[0x170] = +{ + 0xd00, 0xe50, 0xe10, 0xf18, 0xd10, 0xe70, 0xe30, 0x1230, + 0xd08, 0xe60, 0xe20, 0x1210, 0xe00, 0xe80, 0xe40, 0x1250, + 0xd04, 0xe58, 0xe18, 0x1200, 0xd14, 0xe78, 0xe38, 0x1240, + 0xd0c, 0xe68, 0xe28, 0x1220, 0xe08, 0xe88, 0xe48, 0x1260, + 0xd02, 0xe54, 0xe14, 0xf1c, 0xd12, 0xe74, 0xe34, 0x1238, + 0xd0a, 0xe64, 0xe24, 0x1218, 0xe04, 0xe84, 0xe44, 0x1258, + 0xd06, 0xe5c, 0xe1c, 0x1208, 0xd16, 0xe7c, 0xe3c, 0x1248, + 0xd0e, 0xe6c, 0xe2c, 0x1228, 0xe0c, 0xe8c, 0xe4c, 0x1268, + 0xd01, 0xe52, 0xe12, 0xf1a, 0xd11, 0xe72, 0xe32, 0x1234, + 0xd09, 0xe62, 0xe22, 0x1214, 0xe02, 0xe82, 0xe42, 0x1254, + 0xd05, 0xe5a, 0xe1a, 0x1204, 0xd15, 0xe7a, 0xe3a, 0x1244, + 0xd0d, 0xe6a, 0xe2a, 0x1224, 0xe0a, 0xe8a, 0xe4a, 0x1264, + 0xd03, 0xe56, 0xe16, 0xf1e, 0xd13, 0xe76, 0xe36, 0x123c, + 0xd0b, 0xe66, 0xe26, 0x121c, 0xe06, 0xe86, 0xe46, 0x125c, + 0xd07, 0xe5e, 0xe1e, 0x120c, 0xd17, 0xe7e, 0xe3e, 0x124c, + 0xd0f, 0xe6e, 0xe2e, 0x122c, 0xe0e, 0xe8e, 0xe4e, 0x126c, + 0xd00, 0xe51, 0xe11, 0xf19, 0xd10, 0xe71, 0xe31, 0x1232, + 0xd08, 0xe61, 0xe21, 0x1212, 0xe01, 0xe81, 0xe41, 0x1252, + 0xd04, 0xe59, 0xe19, 0x1202, 0xd14, 0xe79, 0xe39, 0x1242, + 0xd0c, 0xe69, 0xe29, 0x1222, 0xe09, 0xe89, 0xe49, 0x1262, + 0xd02, 0xe55, 0xe15, 0xf1d, 0xd12, 0xe75, 0xe35, 0x123a, + 0xd0a, 0xe65, 0xe25, 0x121a, 0xe05, 0xe85, 0xe45, 0x125a, + 0xd06, 0xe5d, 0xe1d, 0x120a, 0xd16, 0xe7d, 0xe3d, 0x124a, + 0xd0e, 0xe6d, 0xe2d, 0x122a, 0xe0d, 0xe8d, 0xe4d, 0x126a, + 0xd01, 0xe53, 0xe13, 0xf1b, 0xd11, 0xe73, 0xe33, 0x1236, + 0xd09, 0xe63, 0xe23, 0x1216, 0xe03, 0xe83, 0xe43, 0x1256, + 0xd05, 0xe5b, 0xe1b, 0x1206, 0xd15, 0xe7b, 0xe3b, 0x1246, + 0xd0d, 0xe6b, 0xe2b, 0x1226, 0xe0b, 0xe8b, 0xe4b, 0x1266, + 0xd03, 0xe57, 0xe17, 0xf1f, 0xd13, 0xe77, 0xe37, 0x123e, + 0xd0b, 0xe67, 0xe27, 0x121e, 0xe07, 0xe87, 0xe47, 0x125e, + 0xd07, 0xe5f, 0xe1f, 0x120e, 0xd17, 0xe7f, 0xe3f, 0x124e, + 0xd0f, 0xe6f, 0xe2f, 0x122e, 0xe0f, 0xe8f, 0xe4f, 0x126e, + 0x290, 0x291, 0x292, 0x293, 0x294, 0x295, 0x296, 0x297, + 0x298, 0x299, 0x29a, 0x29b, 0x29c, 0x29d, 0x29e, 0x29f, + 0x2a0, 0x2a1, 0x2a2, 0x2a3, 0x2a4, 0x2a5, 0x2a6, 0x2a7, + 0x2a8, 0x2a9, 0x2aa, 0x2ab, 0x2ac, 0x2ad, 0x2ae, 0x2af, + 0x2b0, 0x2b1, 0x2b2, 0x2b3, 0x2b4, 0x2b5, 0x2b6, 0x2b7, + 0x2b8, 0x2b9, 0x2ba, 0x2bb, 0x2bc, 0x2bd, 0x2be, 0x2bf, + 0x2c0, 0x2c1, 0x2c2, 0x2c3, 0x2c4, 0x2c5, 0x2c6, 0x2c7, + 0x2c8, 0x2c9, 0x2ca, 0x2cb, 0x2cc, 0x2cd, 0x2ce, 0x2cf, + 0x2d0, 0x2d1, 0x2d2, 0x2d3, 0x2d4, 0x2d5, 0x2d6, 0x2d7, + 0x2d8, 0x2d9, 0x2da, 0x2db, 0x2dc, 0x2dd, 0x2de, 0x2df, + 0x2e0, 0x2e1, 0x2e2, 0x2e3, 0x2e4, 0x2e5, 0x2e6, 0x2e7, + 0x2e8, 0x2e9, 0x2ea, 0x2eb, 0x2ec, 0x2ed, 0x2ee, 0x2ef, + 0x2f0, 0x2f1, 0x2f2, 0x2f3, 0x2f4, 0x2f5, 0x2f6, 0x2f7, + 0x2f8, 0x2f9, 0x2fa, 0x2fb, 0x2fc, 0x2fd, 0x2fe, 0x2ff, +}; + +static const uint16_t elf_zlib_default_dist_table[0x100] = +{ + 0x800, 0x810, 0x808, 0x818, 0x804, 0x814, 0x80c, 0x81c, + 0x802, 0x812, 0x80a, 0x81a, 0x806, 0x816, 0x80e, 0x81e, + 0x801, 0x811, 0x809, 0x819, 0x805, 0x815, 0x80d, 0x81d, + 0x803, 0x813, 0x80b, 0x81b, 0x807, 0x817, 0x80f, 0x81f, + 0x800, 0x810, 0x808, 0x818, 0x804, 0x814, 0x80c, 0x81c, + 0x802, 0x812, 0x80a, 0x81a, 0x806, 0x816, 0x80e, 0x81e, + 0x801, 0x811, 0x809, 0x819, 0x805, 0x815, 0x80d, 0x81d, + 0x803, 0x813, 0x80b, 0x81b, 0x807, 0x817, 0x80f, 0x81f, + 0x800, 0x810, 0x808, 0x818, 0x804, 0x814, 0x80c, 0x81c, + 0x802, 0x812, 0x80a, 0x81a, 0x806, 0x816, 0x80e, 0x81e, + 0x801, 0x811, 0x809, 0x819, 0x805, 0x815, 0x80d, 0x81d, + 0x803, 0x813, 0x80b, 0x81b, 0x807, 0x817, 0x80f, 0x81f, + 0x800, 0x810, 0x808, 0x818, 0x804, 0x814, 0x80c, 0x81c, + 0x802, 0x812, 0x80a, 0x81a, 0x806, 0x816, 0x80e, 0x81e, + 0x801, 0x811, 0x809, 0x819, 0x805, 0x815, 0x80d, 0x81d, + 0x803, 0x813, 0x80b, 0x81b, 0x807, 0x817, 0x80f, 0x81f, + 0x800, 0x810, 0x808, 0x818, 0x804, 0x814, 0x80c, 0x81c, + 0x802, 0x812, 0x80a, 0x81a, 0x806, 0x816, 0x80e, 0x81e, + 0x801, 0x811, 0x809, 0x819, 0x805, 0x815, 0x80d, 0x81d, + 0x803, 0x813, 0x80b, 0x81b, 0x807, 0x817, 0x80f, 0x81f, + 0x800, 0x810, 0x808, 0x818, 0x804, 0x814, 0x80c, 0x81c, + 0x802, 0x812, 0x80a, 0x81a, 0x806, 0x816, 0x80e, 0x81e, + 0x801, 0x811, 0x809, 0x819, 0x805, 0x815, 0x80d, 0x81d, + 0x803, 0x813, 0x80b, 0x81b, 0x807, 0x817, 0x80f, 0x81f, + 0x800, 0x810, 0x808, 0x818, 0x804, 0x814, 0x80c, 0x81c, + 0x802, 0x812, 0x80a, 0x81a, 0x806, 0x816, 0x80e, 0x81e, + 0x801, 0x811, 0x809, 0x819, 0x805, 0x815, 0x80d, 0x81d, + 0x803, 0x813, 0x80b, 0x81b, 0x807, 0x817, 0x80f, 0x81f, + 0x800, 0x810, 0x808, 0x818, 0x804, 0x814, 0x80c, 0x81c, + 0x802, 0x812, 0x80a, 0x81a, 0x806, 0x816, 0x80e, 0x81e, + 0x801, 0x811, 0x809, 0x819, 0x805, 0x815, 0x80d, 0x81d, + 0x803, 0x813, 0x80b, 0x81b, 0x807, 0x817, 0x80f, 0x81f, +}; + +/* Inflate a zlib stream from PIN/SIN to POUT/SOUT. Return 1 on + success, 0 on some error parsing the stream. */ + +static int +elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table, + unsigned char *pout, size_t sout) +{ + unsigned char *porigout; + const unsigned char *pinend; + unsigned char *poutend; + + /* We can apparently see multiple zlib streams concatenated + together, so keep going as long as there is something to read. + The last 4 bytes are the checksum. */ + porigout = pout; + pinend = pin + sin; + poutend = pout + sout; + while ((pinend - pin) > 4) + { + uint64_t val; + unsigned int bits; + int last; + + /* Read the two byte zlib header. */ + + if (unlikely ((pin[0] & 0xf) != 8)) /* 8 is zlib encoding. */ + { + /* Unknown compression method. */ + elf_zlib_failed (); + return 0; + } + if (unlikely ((pin[0] >> 4) > 7)) + { + /* Window size too large. Other than this check, we don't + care about the window size. */ + elf_zlib_failed (); + return 0; + } + if (unlikely ((pin[1] & 0x20) != 0)) + { + /* Stream expects a predefined dictionary, but we have no + dictionary. */ + elf_zlib_failed (); + return 0; + } + val = (pin[0] << 8) | pin[1]; + if (unlikely (val % 31 != 0)) + { + /* Header check failure. */ + elf_zlib_failed (); + return 0; + } + pin += 2; + + /* Align PIN to a 32-bit boundary. */ + + val = 0; + bits = 0; + while ((((uintptr_t) pin) & 3) != 0) + { + val |= (uint64_t)*pin << bits; + bits += 8; + ++pin; + } + + /* Read blocks until one is marked last. */ + + last = 0; + + while (!last) + { + unsigned int type; + const uint16_t *tlit; + const uint16_t *tdist; + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + last = val & 1; + type = (val >> 1) & 3; + val >>= 3; + bits -= 3; + + if (unlikely (type == 3)) + { + /* Invalid block type. */ + elf_zlib_failed (); + return 0; + } + + if (type == 0) + { + uint16_t len; + uint16_t lenc; + + /* An uncompressed block. */ + + /* If we've read ahead more than a byte, back up. */ + while (bits > 8) + { + --pin; + bits -= 8; + } + + val = 0; + bits = 0; + if (unlikely ((pinend - pin) < 4)) + { + /* Missing length. */ + elf_zlib_failed (); + return 0; + } + len = pin[0] | (pin[1] << 8); + lenc = pin[2] | (pin[3] << 8); + pin += 4; + lenc = ~lenc; + if (unlikely (len != lenc)) + { + /* Corrupt data. */ + elf_zlib_failed (); + return 0; + } + if (unlikely (len > (unsigned int) (pinend - pin) + || len > (unsigned int) (poutend - pout))) + { + /* Not enough space in buffers. */ + elf_zlib_failed (); + return 0; + } + memcpy (pout, pin, len); + pout += len; + pin += len; + + /* Align PIN. */ + while ((((uintptr_t) pin) & 3) != 0) + { + val |= (uint64_t)*pin << bits; + bits += 8; + ++pin; + } + + /* Go around to read the next block. */ + continue; + } + + if (type == 1) + { + tlit = elf_zlib_default_table; + tdist = elf_zlib_default_dist_table; + } + else + { + unsigned int nlit; + unsigned int ndist; + unsigned int nclen; + unsigned char codebits[19]; + unsigned char *plenbase; + unsigned char *plen; + unsigned char *plenend; + + /* Read a Huffman encoding table. The various magic + numbers here are from RFC 1951. */ + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + nlit = (val & 0x1f) + 257; + val >>= 5; + ndist = (val & 0x1f) + 1; + val >>= 5; + nclen = (val & 0xf) + 4; + val >>= 4; + bits -= 14; + if (unlikely (nlit > 286 || ndist > 30)) + { + /* Values out of range. */ + elf_zlib_failed (); + return 0; + } + + /* Read and build the table used to compress the + literal, length, and distance codes. */ + + memset(&codebits[0], 0, 19); + + /* There are always at least 4 elements in the + table. */ + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + codebits[16] = val & 7; + codebits[17] = (val >> 3) & 7; + codebits[18] = (val >> 6) & 7; + codebits[0] = (val >> 9) & 7; + val >>= 12; + bits -= 12; + + if (nclen == 4) + goto codebitsdone; + + codebits[8] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 5) + goto codebitsdone; + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + codebits[7] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 6) + goto codebitsdone; + + codebits[9] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 7) + goto codebitsdone; + + codebits[6] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 8) + goto codebitsdone; + + codebits[10] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 9) + goto codebitsdone; + + codebits[5] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 10) + goto codebitsdone; + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + codebits[11] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 11) + goto codebitsdone; + + codebits[4] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 12) + goto codebitsdone; + + codebits[12] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 13) + goto codebitsdone; + + codebits[3] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 14) + goto codebitsdone; + + codebits[13] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 15) + goto codebitsdone; + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + codebits[2] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 16) + goto codebitsdone; + + codebits[14] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 17) + goto codebitsdone; + + codebits[1] = val & 7; + val >>= 3; + bits -= 3; + + if (nclen == 18) + goto codebitsdone; + + codebits[15] = val & 7; + val >>= 3; + bits -= 3; + + codebitsdone: + + if (!elf_zlib_inflate_table (codebits, 19, zdebug_table, + zdebug_table)) + return 0; + + /* Read the compressed bit lengths of the literal, + length, and distance codes. We have allocated space + at the end of zdebug_table to hold them. */ + + plenbase = (((unsigned char *) zdebug_table) + + ZDEBUG_TABLE_CODELEN_OFFSET); + plen = plenbase; + plenend = plen + nlit + ndist; + while (plen < plenend) + { + uint16_t t; + unsigned int b; + uint16_t v; + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + t = zdebug_table[val & 0xff]; + + /* The compression here uses bit lengths up to 7, so + a secondary table is never necessary. */ + if (unlikely ((t & (1U << HUFFMAN_SECONDARY_SHIFT)) != 0)) + { + elf_zlib_failed (); + return 0; + } + + b = (t >> HUFFMAN_BITS_SHIFT) & HUFFMAN_BITS_MASK; + val >>= b + 1; + bits -= b + 1; + + v = t & HUFFMAN_VALUE_MASK; + if (v < 16) + *plen++ = v; + else if (v == 16) + { + unsigned int c; + unsigned int prev; + + /* Copy previous entry 3 to 6 times. */ + + if (unlikely (plen == plenbase)) + { + elf_zlib_failed (); + return 0; + } + + /* We used up to 7 bits since the last + elf_zlib_fetch, so we have at least 8 bits + available here. */ + + c = 3 + (val & 0x3); + val >>= 2; + bits -= 2; + if (unlikely ((unsigned int) (plenend - plen) < c)) + { + elf_zlib_failed (); + return 0; + } + + prev = plen[-1]; + switch (c) + { + case 6: + *plen++ = prev; + /* fallthrough */ + case 5: + *plen++ = prev; + /* fallthrough */ + case 4: + *plen++ = prev; + } + *plen++ = prev; + *plen++ = prev; + *plen++ = prev; + } + else if (v == 17) + { + unsigned int c; + + /* Store zero 3 to 10 times. */ + + /* We used up to 7 bits since the last + elf_zlib_fetch, so we have at least 8 bits + available here. */ + + c = 3 + (val & 0x7); + val >>= 3; + bits -= 3; + if (unlikely ((unsigned int) (plenend - plen) < c)) + { + elf_zlib_failed (); + return 0; + } + + switch (c) + { + case 10: + *plen++ = 0; + /* fallthrough */ + case 9: + *plen++ = 0; + /* fallthrough */ + case 8: + *plen++ = 0; + /* fallthrough */ + case 7: + *plen++ = 0; + /* fallthrough */ + case 6: + *plen++ = 0; + /* fallthrough */ + case 5: + *plen++ = 0; + /* fallthrough */ + case 4: + *plen++ = 0; + } + *plen++ = 0; + *plen++ = 0; + *plen++ = 0; + } + else if (v == 18) + { + unsigned int c; + + /* Store zero 11 to 138 times. */ + + /* We used up to 7 bits since the last + elf_zlib_fetch, so we have at least 8 bits + available here. */ + + c = 11 + (val & 0x7f); + val >>= 7; + bits -= 7; + if (unlikely ((unsigned int) (plenend - plen) < c)) + { + elf_zlib_failed (); + return 0; + } + + memset (plen, 0, c); + plen += c; + } + else + { + elf_zlib_failed (); + return 0; + } + } + + /* Make sure that the stop code can appear. */ + + plen = plenbase; + if (unlikely (plen[256] == 0)) + { + elf_zlib_failed (); + return 0; + } + + /* Build the decompression tables. */ + + if (!elf_zlib_inflate_table (plen, nlit, zdebug_table, + zdebug_table)) + return 0; + if (!elf_zlib_inflate_table (plen + nlit, ndist, zdebug_table, + zdebug_table + HUFFMAN_TABLE_SIZE)) + return 0; + tlit = zdebug_table; + tdist = zdebug_table + HUFFMAN_TABLE_SIZE; + } + + /* Inflate values until the end of the block. This is the + main loop of the inflation code. */ + + while (1) + { + uint16_t t; + unsigned int b; + uint16_t v; + unsigned int lit; + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + t = tlit[val & 0xff]; + b = (t >> HUFFMAN_BITS_SHIFT) & HUFFMAN_BITS_MASK; + v = t & HUFFMAN_VALUE_MASK; + + if ((t & (1U << HUFFMAN_SECONDARY_SHIFT)) == 0) + { + lit = v; + val >>= b + 1; + bits -= b + 1; + } + else + { + t = tlit[v + 0x100 + ((val >> 8) & ((1U << b) - 1))]; + b = (t >> HUFFMAN_BITS_SHIFT) & HUFFMAN_BITS_MASK; + lit = t & HUFFMAN_VALUE_MASK; + val >>= b + 8; + bits -= b + 8; + } + + if (lit < 256) + { + if (unlikely (pout == poutend)) + { + elf_zlib_failed (); + return 0; + } + + *pout++ = lit; + + /* We will need to write the next byte soon. We ask + for high temporal locality because we will write + to the whole cache line soon. */ + __builtin_prefetch (pout, 1, 3); + } + else if (lit == 256) + { + /* The end of the block. */ + break; + } + else + { + unsigned int dist; + unsigned int len; + + /* Convert lit into a length. */ + + if (lit < 265) + len = lit - 257 + 3; + else if (lit == 285) + len = 258; + else if (unlikely (lit > 285)) + { + elf_zlib_failed (); + return 0; + } + else + { + unsigned int extra; + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + /* This is an expression for the table of length + codes in RFC 1951 3.2.5. */ + lit -= 265; + extra = (lit >> 2) + 1; + len = (lit & 3) << extra; + len += 11; + len += ((1U << (extra - 1)) - 1) << 3; + len += val & ((1U << extra) - 1); + val >>= extra; + bits -= extra; + } + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + t = tdist[val & 0xff]; + b = (t >> HUFFMAN_BITS_SHIFT) & HUFFMAN_BITS_MASK; + v = t & HUFFMAN_VALUE_MASK; + + if ((t & (1U << HUFFMAN_SECONDARY_SHIFT)) == 0) + { + dist = v; + val >>= b + 1; + bits -= b + 1; + } + else + { + t = tdist[v + 0x100 + ((val >> 8) & ((1U << b) - 1))]; + b = (t >> HUFFMAN_BITS_SHIFT) & HUFFMAN_BITS_MASK; + dist = t & HUFFMAN_VALUE_MASK; + val >>= b + 8; + bits -= b + 8; + } + + /* Convert dist to a distance. */ + + if (dist == 0) + { + /* A distance of 1. A common case, meaning + repeat the last character LEN times. */ + + if (unlikely (pout == porigout)) + { + elf_zlib_failed (); + return 0; + } + + if (unlikely ((unsigned int) (poutend - pout) < len)) + { + elf_zlib_failed (); + return 0; + } + + memset (pout, pout[-1], len); + pout += len; + } + else if (unlikely (dist > 29)) + { + elf_zlib_failed (); + return 0; + } + else + { + if (dist < 4) + dist = dist + 1; + else + { + unsigned int extra; + + if (!elf_zlib_fetch (&pin, pinend, &val, &bits)) + return 0; + + /* This is an expression for the table of + distance codes in RFC 1951 3.2.5. */ + dist -= 4; + extra = (dist >> 1) + 1; + dist = (dist & 1) << extra; + dist += 5; + dist += ((1U << (extra - 1)) - 1) << 2; + dist += val & ((1U << extra) - 1); + val >>= extra; + bits -= extra; + } + + /* Go back dist bytes, and copy len bytes from + there. */ + + if (unlikely ((unsigned int) (pout - porigout) < dist)) + { + elf_zlib_failed (); + return 0; + } + + if (unlikely ((unsigned int) (poutend - pout) < len)) + { + elf_zlib_failed (); + return 0; + } + + if (dist >= len) + { + memcpy (pout, pout - dist, len); + pout += len; + } + else + { + while (len > 0) + { + unsigned int copy; + + copy = len < dist ? len : dist; + memcpy (pout, pout - dist, copy); + len -= copy; + pout += copy; + } + } + } + } + } + } + } + + /* We should have filled the output buffer. */ + if (unlikely (pout != poutend)) + { + elf_zlib_failed (); + return 0; + } + + return 1; +} + +/* Verify the zlib checksum. The checksum is in the 4 bytes at + CHECKBYTES, and the uncompressed data is at UNCOMPRESSED / + UNCOMPRESSED_SIZE. Returns 1 on success, 0 on failure. */ + +static int +elf_zlib_verify_checksum (const unsigned char *checkbytes, + const unsigned char *uncompressed, + size_t uncompressed_size) +{ + unsigned int i; + unsigned int cksum; + const unsigned char *p; + uint32_t s1; + uint32_t s2; + size_t hsz; + + cksum = 0; + for (i = 0; i < 4; i++) + cksum = (cksum << 8) | checkbytes[i]; + + s1 = 1; + s2 = 0; + + /* Minimize modulo operations. */ + + p = uncompressed; + hsz = uncompressed_size; + while (hsz >= 5552) + { + for (i = 0; i < 5552; i += 16) + { + /* Manually unroll loop 16 times. */ + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + } + hsz -= 5552; + s1 %= 65521; + s2 %= 65521; + } + + while (hsz >= 16) + { + /* Manually unroll loop 16 times. */ + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + s1 = s1 + *p++; + s2 = s2 + s1; + + hsz -= 16; + } + + for (i = 0; i < hsz; ++i) + { + s1 = s1 + *p++; + s2 = s2 + s1; + } + + s1 %= 65521; + s2 %= 65521; + + if (unlikely ((s2 << 16) + s1 != cksum)) + { + elf_zlib_failed (); + return 0; + } + + return 1; +} + +/* Inflate a zlib stream from PIN/SIN to POUT/SOUT, and verify the + checksum. Return 1 on success, 0 on error. */ + +static int +elf_zlib_inflate_and_verify (const unsigned char *pin, size_t sin, + uint16_t *zdebug_table, unsigned char *pout, + size_t sout) +{ + if (!elf_zlib_inflate (pin, sin, zdebug_table, pout, sout)) + return 0; + if (!elf_zlib_verify_checksum (pin + sin - 4, pout, sout)) + return 0; + return 1; +} + +/* Uncompress the old compressed debug format, the one emitted by + --compress-debug-sections=zlib-gnu. The compressed data is in + COMPRESSED / COMPRESSED_SIZE, and the function writes to + *UNCOMPRESSED / *UNCOMPRESSED_SIZE. ZDEBUG_TABLE is work space to + hold Huffman tables. Returns 0 on error, 1 on successful + decompression or if something goes wrong. In general we try to + carry on, by returning 1, even if we can't decompress. */ + +static int +elf_uncompress_zdebug (struct backtrace_state *state, + const unsigned char *compressed, size_t compressed_size, + uint16_t *zdebug_table, + backtrace_error_callback error_callback, void *data, + unsigned char **uncompressed, size_t *uncompressed_size) +{ + size_t sz; + size_t i; + unsigned char *po; + + *uncompressed = NULL; + *uncompressed_size = 0; + + /* The format starts with the four bytes ZLIB, followed by the 8 + byte length of the uncompressed data in big-endian order, + followed by a zlib stream. */ + + if (compressed_size < 12 || memcmp (compressed, "ZLIB", 4) != 0) + return 1; + + sz = 0; + for (i = 0; i < 8; i++) + sz = (sz << 8) | compressed[i + 4]; + + if (*uncompressed != NULL && *uncompressed_size >= sz) + po = *uncompressed; + else + { + po = (unsigned char *) backtrace_alloc (state, sz, error_callback, data); + if (po == NULL) + return 0; + } + + if (!elf_zlib_inflate_and_verify (compressed + 12, compressed_size - 12, + zdebug_table, po, sz)) + return 1; + + *uncompressed = po; + *uncompressed_size = sz; + + return 1; +} + +/* Uncompress the new compressed debug format, the official standard + ELF approach emitted by --compress-debug-sections=zlib-gabi. The + compressed data is in COMPRESSED / COMPRESSED_SIZE, and the + function writes to *UNCOMPRESSED / *UNCOMPRESSED_SIZE. + ZDEBUG_TABLE is work space as for elf_uncompress_zdebug. Returns 0 + on error, 1 on successful decompression or if something goes wrong. + In general we try to carry on, by returning 1, even if we can't + decompress. */ + +static int +elf_uncompress_chdr (struct backtrace_state *state, + const unsigned char *compressed, size_t compressed_size, + uint16_t *zdebug_table, + backtrace_error_callback error_callback, void *data, + unsigned char **uncompressed, size_t *uncompressed_size) +{ + const b_elf_chdr *chdr; + unsigned char *po; + + *uncompressed = NULL; + *uncompressed_size = 0; + + /* The format starts with an ELF compression header. */ + if (compressed_size < sizeof (b_elf_chdr)) + return 1; + + chdr = (const b_elf_chdr *) compressed; + + if (chdr->ch_type != ELFCOMPRESS_ZLIB) + { + /* Unsupported compression algorithm. */ + return 1; + } + + if (*uncompressed != NULL && *uncompressed_size >= chdr->ch_size) + po = *uncompressed; + else + { + po = (unsigned char *) backtrace_alloc (state, chdr->ch_size, + error_callback, data); + if (po == NULL) + return 0; + } + + if (!elf_zlib_inflate_and_verify (compressed + sizeof (b_elf_chdr), + compressed_size - sizeof (b_elf_chdr), + zdebug_table, po, chdr->ch_size)) + return 1; + + *uncompressed = po; + *uncompressed_size = chdr->ch_size; + + return 1; +} + +/* This function is a hook for testing the zlib support. It is only + used by tests. */ + +int +backtrace_uncompress_zdebug (struct backtrace_state *state, + const unsigned char *compressed, + size_t compressed_size, + backtrace_error_callback error_callback, + void *data, unsigned char **uncompressed, + size_t *uncompressed_size) +{ + uint16_t *zdebug_table; + int ret; + + zdebug_table = ((uint16_t *) backtrace_alloc (state, ZDEBUG_TABLE_SIZE, + error_callback, data)); + if (zdebug_table == NULL) + return 0; + ret = elf_uncompress_zdebug (state, compressed, compressed_size, + zdebug_table, error_callback, data, + uncompressed, uncompressed_size); + backtrace_free (state, zdebug_table, ZDEBUG_TABLE_SIZE, + error_callback, data); + return ret; +} + +/* Add the backtrace data for one ELF file. Returns 1 on success, + 0 on failure (in both cases descriptor is closed) or -1 if exe + is non-zero and the ELF file is ET_DYN, which tells the caller that + elf_add will need to be called on the descriptor again after + base_address is determined. */ + +static int +elf_add (struct backtrace_state *state, const char *filename, int descriptor, + uintptr_t base_address, backtrace_error_callback error_callback, + void *data, fileline *fileline_fn, int *found_sym, int *found_dwarf, + int exe, int debuginfo) +{ + struct backtrace_view ehdr_view; + b_elf_ehdr ehdr; + off_t shoff; + unsigned int shnum; + unsigned int shstrndx; + struct backtrace_view shdrs_view; + int shdrs_view_valid; + const b_elf_shdr *shdrs; + const b_elf_shdr *shstrhdr; + size_t shstr_size; + off_t shstr_off; + struct backtrace_view names_view; + int names_view_valid; + const char *names; + unsigned int symtab_shndx; + unsigned int dynsym_shndx; + unsigned int i; + struct debug_section_info sections[DEBUG_MAX]; + struct backtrace_view symtab_view; + int symtab_view_valid; + struct backtrace_view strtab_view; + int strtab_view_valid; + struct backtrace_view buildid_view; + int buildid_view_valid; + const char *buildid_data; + uint32_t buildid_size; + struct backtrace_view debuglink_view; + int debuglink_view_valid; + const char *debuglink_name; + uint32_t debuglink_crc; + off_t min_offset; + off_t max_offset; + struct backtrace_view debug_view; + int debug_view_valid; + unsigned int using_debug_view; + uint16_t *zdebug_table; + struct elf_ppc64_opd_data opd_data, *opd; + + if (!debuginfo) + { + *found_sym = 0; + *found_dwarf = 0; + } + + shdrs_view_valid = 0; + names_view_valid = 0; + symtab_view_valid = 0; + strtab_view_valid = 0; + buildid_view_valid = 0; + buildid_data = NULL; + buildid_size = 0; + debuglink_view_valid = 0; + debuglink_name = NULL; + debuglink_crc = 0; + debug_view_valid = 0; + opd = NULL; + + if (!backtrace_get_view (state, descriptor, 0, sizeof ehdr, error_callback, + data, &ehdr_view)) + goto fail; + + memcpy (&ehdr, ehdr_view.data, sizeof ehdr); + + backtrace_release_view (state, &ehdr_view, error_callback, data); + + if (ehdr.e_ident[EI_MAG0] != ELFMAG0 + || ehdr.e_ident[EI_MAG1] != ELFMAG1 + || ehdr.e_ident[EI_MAG2] != ELFMAG2 + || ehdr.e_ident[EI_MAG3] != ELFMAG3) + { + error_callback (data, "executable file is not ELF", 0); + goto fail; + } + if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) + { + error_callback (data, "executable file is unrecognized ELF version", 0); + goto fail; + } + +#if BACKTRACE_ELF_SIZE == 32 +#define BACKTRACE_ELFCLASS ELFCLASS32 +#else +#define BACKTRACE_ELFCLASS ELFCLASS64 +#endif + + if (ehdr.e_ident[EI_CLASS] != BACKTRACE_ELFCLASS) + { + error_callback (data, "executable file is unexpected ELF class", 0); + goto fail; + } + + if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB + && ehdr.e_ident[EI_DATA] != ELFDATA2MSB) + { + error_callback (data, "executable file has unknown endianness", 0); + goto fail; + } + + /* If the executable is ET_DYN, it is either a PIE, or we are running + directly a shared library with .interp. We need to wait for + dl_iterate_phdr in that case to determine the actual base_address. */ + if (exe && ehdr.e_type == ET_DYN) + return -1; + + shoff = ehdr.e_shoff; + shnum = ehdr.e_shnum; + shstrndx = ehdr.e_shstrndx; + + if ((shnum == 0 || shstrndx == SHN_XINDEX) + && shoff != 0) + { + struct backtrace_view shdr_view; + const b_elf_shdr *shdr; + + if (!backtrace_get_view (state, descriptor, shoff, sizeof shdr, + error_callback, data, &shdr_view)) + goto fail; + + shdr = (const b_elf_shdr *) shdr_view.data; + + if (shnum == 0) + shnum = shdr->sh_size; + + if (shstrndx == SHN_XINDEX) + { + shstrndx = shdr->sh_link; + + /* Versions of the GNU binutils between 2.12 and 2.18 did + not handle objects with more than SHN_LORESERVE sections + correctly. All large section indexes were offset by + 0x100. There is more information at + http://sourceware.org/bugzilla/show_bug.cgi?id-5900 . + Fortunately these object files are easy to detect, as the + GNU binutils always put the section header string table + near the end of the list of sections. Thus if the + section header string table index is larger than the + number of sections, then we know we have to subtract + 0x100 to get the real section index. */ + if (shstrndx >= shnum && shstrndx >= SHN_LORESERVE + 0x100) + shstrndx -= 0x100; + } + + backtrace_release_view (state, &shdr_view, error_callback, data); + } + + /* To translate PC to file/line when using DWARF, we need to find + the .debug_info and .debug_line sections. */ + + /* Read the section headers, skipping the first one. */ + + if (!backtrace_get_view (state, descriptor, shoff + sizeof (b_elf_shdr), + (shnum - 1) * sizeof (b_elf_shdr), + error_callback, data, &shdrs_view)) + goto fail; + shdrs_view_valid = 1; + shdrs = (const b_elf_shdr *) shdrs_view.data; + + /* Read the section names. */ + + shstrhdr = &shdrs[shstrndx - 1]; + shstr_size = shstrhdr->sh_size; + shstr_off = shstrhdr->sh_offset; + + if (!backtrace_get_view (state, descriptor, shstr_off, shstr_size, + error_callback, data, &names_view)) + goto fail; + names_view_valid = 1; + names = (const char *) names_view.data; + + symtab_shndx = 0; + dynsym_shndx = 0; + + memset (sections, 0, sizeof sections); + + /* Look for the symbol table. */ + for (i = 1; i < shnum; ++i) + { + const b_elf_shdr *shdr; + unsigned int sh_name; + const char *name; + int j; + + shdr = &shdrs[i - 1]; + + if (shdr->sh_type == SHT_SYMTAB) + symtab_shndx = i; + else if (shdr->sh_type == SHT_DYNSYM) + dynsym_shndx = i; + + sh_name = shdr->sh_name; + if (sh_name >= shstr_size) + { + error_callback (data, "ELF section name out of range", 0); + goto fail; + } + + name = names + sh_name; + + for (j = 0; j < (int) DEBUG_MAX; ++j) + { + if (strcmp (name, debug_section_names[j]) == 0) + { + sections[j].offset = shdr->sh_offset; + sections[j].size = shdr->sh_size; + sections[j].compressed = (shdr->sh_flags & SHF_COMPRESSED) != 0; + break; + } + } + + /* Read the build ID if present. This could check for any + SHT_NOTE section with the right note name and type, but gdb + looks for a specific section name. */ + if (!debuginfo + && !buildid_view_valid + && strcmp (name, ".note.gnu.build-id") == 0) + { + const b_elf_note *note; + + if (!backtrace_get_view (state, descriptor, shdr->sh_offset, + shdr->sh_size, error_callback, data, + &buildid_view)) + goto fail; + + buildid_view_valid = 1; + note = (const b_elf_note *) buildid_view.data; + if (note->type == NT_GNU_BUILD_ID + && note->namesz == 4 + && strncmp (note->name, "GNU", 4) == 0 + && shdr->sh_size < 12 + ((note->namesz + 3) & ~ 3) + note->descsz) + { + buildid_data = ¬e->name[0] + ((note->namesz + 3) & ~ 3); + buildid_size = note->descsz; + } + } + + /* Read the debuglink file if present. */ + if (!debuginfo + && !debuglink_view_valid + && strcmp (name, ".gnu_debuglink") == 0) + { + const char *debuglink_data; + size_t crc_offset; + + if (!backtrace_get_view (state, descriptor, shdr->sh_offset, + shdr->sh_size, error_callback, data, + &debuglink_view)) + goto fail; + + debuglink_view_valid = 1; + debuglink_data = (const char *) debuglink_view.data; + crc_offset = strnlen (debuglink_data, shdr->sh_size); + crc_offset = (crc_offset + 3) & ~3; + if (crc_offset + 4 <= shdr->sh_size) + { + debuglink_name = debuglink_data; + debuglink_crc = *(const uint32_t*)(debuglink_data + crc_offset); + } + } + + /* Read the .opd section on PowerPC64 ELFv1. */ + if (ehdr.e_machine == EM_PPC64 + && (ehdr.e_flags & EF_PPC64_ABI) < 2 + && shdr->sh_type == SHT_PROGBITS + && strcmp (name, ".opd") == 0) + { + if (!backtrace_get_view (state, descriptor, shdr->sh_offset, + shdr->sh_size, error_callback, data, + &opd_data.view)) + goto fail; + + opd = &opd_data; + opd->addr = shdr->sh_addr; + opd->data = (const char *) opd_data.view.data; + opd->size = shdr->sh_size; + } + } + + if (symtab_shndx == 0) + symtab_shndx = dynsym_shndx; + if (symtab_shndx != 0 && !debuginfo) + { + const b_elf_shdr *symtab_shdr; + unsigned int strtab_shndx; + const b_elf_shdr *strtab_shdr; + struct elf_syminfo_data *sdata; + + symtab_shdr = &shdrs[symtab_shndx - 1]; + strtab_shndx = symtab_shdr->sh_link; + if (strtab_shndx >= shnum) + { + error_callback (data, + "ELF symbol table strtab link out of range", 0); + goto fail; + } + strtab_shdr = &shdrs[strtab_shndx - 1]; + + if (!backtrace_get_view (state, descriptor, symtab_shdr->sh_offset, + symtab_shdr->sh_size, error_callback, data, + &symtab_view)) + goto fail; + symtab_view_valid = 1; + + if (!backtrace_get_view (state, descriptor, strtab_shdr->sh_offset, + strtab_shdr->sh_size, error_callback, data, + &strtab_view)) + goto fail; + strtab_view_valid = 1; + + sdata = ((struct elf_syminfo_data *) + backtrace_alloc (state, sizeof *sdata, error_callback, data)); + if (sdata == NULL) + goto fail; + + if (!elf_initialize_syminfo (state, base_address, + symtab_view.data, symtab_shdr->sh_size, + strtab_view.data, strtab_shdr->sh_size, + error_callback, data, sdata, opd)) + { + backtrace_free (state, sdata, sizeof *sdata, error_callback, data); + goto fail; + } + + /* We no longer need the symbol table, but we hold on to the + string table permanently. */ + backtrace_release_view (state, &symtab_view, error_callback, data); + symtab_view_valid = 0; + + *found_sym = 1; + + elf_add_syminfo_data (state, sdata); + } + + backtrace_release_view (state, &shdrs_view, error_callback, data); + shdrs_view_valid = 0; + backtrace_release_view (state, &names_view, error_callback, data); + names_view_valid = 0; + + /* If the debug info is in a separate file, read that one instead. */ + + if (buildid_data != NULL) + { + int d; + + d = elf_open_debugfile_by_buildid (state, buildid_data, buildid_size, + error_callback, data); + if (d >= 0) + { + int ret; + + backtrace_release_view (state, &buildid_view, error_callback, data); + if (debuglink_view_valid) + backtrace_release_view (state, &debuglink_view, error_callback, + data); + ret = elf_add (state, NULL, d, base_address, error_callback, data, + fileline_fn, found_sym, found_dwarf, 0, 1); + if (ret < 0) + backtrace_close (d, error_callback, data); + else + backtrace_close (descriptor, error_callback, data); + return ret; + } + } + + if (buildid_view_valid) + { + backtrace_release_view (state, &buildid_view, error_callback, data); + buildid_view_valid = 0; + } + + if (opd) + { + backtrace_release_view (state, &opd->view, error_callback, data); + opd = NULL; + } + + if (debuglink_name != NULL) + { + int d; + + d = elf_open_debugfile_by_debuglink (state, filename, debuglink_name, + debuglink_crc, error_callback, + data); + if (d >= 0) + { + int ret; + + backtrace_release_view (state, &debuglink_view, error_callback, + data); + ret = elf_add (state, NULL, d, base_address, error_callback, data, + fileline_fn, found_sym, found_dwarf, 0, 1); + if (ret < 0) + backtrace_close (d, error_callback, data); + else + backtrace_close(descriptor, error_callback, data); + return ret; + } + } + + if (debuglink_view_valid) + { + backtrace_release_view (state, &debuglink_view, error_callback, data); + debuglink_view_valid = 0; + } + + /* Read all the debug sections in a single view, since they are + probably adjacent in the file. We never release this view. */ + + min_offset = 0; + max_offset = 0; + for (i = 0; i < (int) DEBUG_MAX; ++i) + { + off_t end; + + if (sections[i].size == 0) + continue; + if (min_offset == 0 || sections[i].offset < min_offset) + min_offset = sections[i].offset; + end = sections[i].offset + sections[i].size; + if (end > max_offset) + max_offset = end; + } + if (min_offset == 0 || max_offset == 0) + { + if (!backtrace_close (descriptor, error_callback, data)) + goto fail; + return 1; + } + + if (!backtrace_get_view (state, descriptor, min_offset, + max_offset - min_offset, + error_callback, data, &debug_view)) + goto fail; + debug_view_valid = 1; + + /* We've read all we need from the executable. */ + if (!backtrace_close (descriptor, error_callback, data)) + goto fail; + descriptor = -1; + + using_debug_view = 0; + for (i = 0; i < (int) DEBUG_MAX; ++i) + { + if (sections[i].size == 0) + sections[i].data = NULL; + else + { + sections[i].data = ((const unsigned char *) debug_view.data + + (sections[i].offset - min_offset)); + if (i < ZDEBUG_INFO) + ++using_debug_view; + } + } + + /* Uncompress the old format (--compress-debug-sections=zlib-gnu). */ + + zdebug_table = NULL; + for (i = 0; i < ZDEBUG_INFO; ++i) + { + struct debug_section_info *pz; + + pz = §ions[i + ZDEBUG_INFO - DEBUG_INFO]; + if (sections[i].size == 0 && pz->size > 0) + { + unsigned char *uncompressed_data; + size_t uncompressed_size; + + if (zdebug_table == NULL) + { + zdebug_table = ((uint16_t *) + backtrace_alloc (state, ZDEBUG_TABLE_SIZE, + error_callback, data)); + if (zdebug_table == NULL) + goto fail; + } + + uncompressed_data = NULL; + uncompressed_size = 0; + if (!elf_uncompress_zdebug (state, pz->data, pz->size, zdebug_table, + error_callback, data, + &uncompressed_data, &uncompressed_size)) + goto fail; + sections[i].data = uncompressed_data; + sections[i].size = uncompressed_size; + sections[i].compressed = 0; + } + } + + /* Uncompress the official ELF format + (--compress-debug-sections=zlib-gabi). */ + for (i = 0; i < ZDEBUG_INFO; ++i) + { + unsigned char *uncompressed_data; + size_t uncompressed_size; + + if (sections[i].size == 0 || !sections[i].compressed) + continue; + + if (zdebug_table == NULL) + { + zdebug_table = ((uint16_t *) + backtrace_alloc (state, ZDEBUG_TABLE_SIZE, + error_callback, data)); + if (zdebug_table == NULL) + goto fail; + } + + uncompressed_data = NULL; + uncompressed_size = 0; + if (!elf_uncompress_chdr (state, sections[i].data, sections[i].size, + zdebug_table, error_callback, data, + &uncompressed_data, &uncompressed_size)) + goto fail; + sections[i].data = uncompressed_data; + sections[i].size = uncompressed_size; + sections[i].compressed = 0; + + --using_debug_view; + } + + if (zdebug_table != NULL) + backtrace_free (state, zdebug_table, ZDEBUG_TABLE_SIZE, + error_callback, data); + + if (debug_view_valid && using_debug_view == 0) + { + backtrace_release_view (state, &debug_view, error_callback, data); + debug_view_valid = 0; + } + + if (!backtrace_dwarf_add (state, base_address, + sections[DEBUG_INFO].data, + sections[DEBUG_INFO].size, + sections[DEBUG_LINE].data, + sections[DEBUG_LINE].size, + sections[DEBUG_ABBREV].data, + sections[DEBUG_ABBREV].size, + sections[DEBUG_RANGES].data, + sections[DEBUG_RANGES].size, + sections[DEBUG_STR].data, + sections[DEBUG_STR].size, + ehdr.e_ident[EI_DATA] == ELFDATA2MSB, + error_callback, data, fileline_fn)) + goto fail; + + *found_dwarf = 1; + + return 1; + + fail: + if (shdrs_view_valid) + backtrace_release_view (state, &shdrs_view, error_callback, data); + if (names_view_valid) + backtrace_release_view (state, &names_view, error_callback, data); + if (symtab_view_valid) + backtrace_release_view (state, &symtab_view, error_callback, data); + if (strtab_view_valid) + backtrace_release_view (state, &strtab_view, error_callback, data); + if (debuglink_view_valid) + backtrace_release_view (state, &debuglink_view, error_callback, data); + if (buildid_view_valid) + backtrace_release_view (state, &buildid_view, error_callback, data); + if (debug_view_valid) + backtrace_release_view (state, &debug_view, error_callback, data); + if (opd) + backtrace_release_view (state, &opd->view, error_callback, data); + if (descriptor != -1) + backtrace_close (descriptor, error_callback, data); + return 0; +} + +/* Data passed to phdr_callback. */ + +struct phdr_data +{ + struct backtrace_state *state; + backtrace_error_callback error_callback; + void *data; + fileline *fileline_fn; + int *found_sym; + int *found_dwarf; + const char *exe_filename; + int exe_descriptor; +}; + +/* Callback passed to dl_iterate_phdr. Load debug info from shared + libraries. */ + +static int +#ifdef __i386__ +__attribute__ ((__force_align_arg_pointer__)) +#endif +phdr_callback (struct dl_phdr_info *info, size_t size ATTRIBUTE_UNUSED, + void *pdata) +{ + struct phdr_data *pd = (struct phdr_data *) pdata; + const char *filename; + int descriptor; + int does_not_exist; + fileline elf_fileline_fn; + int found_dwarf; + + /* There is not much we can do if we don't have the module name, + unless executable is ET_DYN, where we expect the very first + phdr_callback to be for the PIE. */ + if (info->dlpi_name == NULL || info->dlpi_name[0] == '\0') + { + if (pd->exe_descriptor == -1) + return 0; + filename = pd->exe_filename; + descriptor = pd->exe_descriptor; + pd->exe_descriptor = -1; + } + else + { + if (pd->exe_descriptor != -1) + { + backtrace_close (pd->exe_descriptor, pd->error_callback, pd->data); + pd->exe_descriptor = -1; + } + + filename = info->dlpi_name; + descriptor = backtrace_open (info->dlpi_name, pd->error_callback, + pd->data, &does_not_exist); + if (descriptor < 0) + return 0; + } + + if (elf_add (pd->state, filename, descriptor, info->dlpi_addr, + pd->error_callback, pd->data, &elf_fileline_fn, pd->found_sym, + &found_dwarf, 0, 0)) + { + if (found_dwarf) + { + *pd->found_dwarf = 1; + *pd->fileline_fn = elf_fileline_fn; + } + } + + return 0; +} + +/* Initialize the backtrace data we need from an ELF executable. At + the ELF level, all we need to do is find the debug info + sections. */ + +int +backtrace_initialize (struct backtrace_state *state, const char *filename, + int descriptor, backtrace_error_callback error_callback, + void *data, fileline *fileline_fn) +{ + int ret; + int found_sym; + int found_dwarf; + fileline elf_fileline_fn = elf_nodebug; + struct phdr_data pd; + + ret = elf_add (state, filename, descriptor, 0, error_callback, data, + &elf_fileline_fn, &found_sym, &found_dwarf, 1, 0); + if (!ret) + return 0; + + pd.state = state; + pd.error_callback = error_callback; + pd.data = data; + pd.fileline_fn = &elf_fileline_fn; + pd.found_sym = &found_sym; + pd.found_dwarf = &found_dwarf; + pd.exe_filename = filename; + pd.exe_descriptor = ret < 0 ? descriptor : -1; + + dl_iterate_phdr (phdr_callback, (void *) &pd); + + if (!state->threaded) + { + if (found_sym) + state->syminfo_fn = elf_syminfo; + else if (state->syminfo_fn == NULL) + state->syminfo_fn = elf_nosyms; + } + else + { + if (found_sym) + backtrace_atomic_store_pointer (&state->syminfo_fn, elf_syminfo); + else + (void) __sync_bool_compare_and_swap (&state->syminfo_fn, NULL, + elf_nosyms); + } + + if (!state->threaded) + *fileline_fn = state->fileline_fn; + else + *fileline_fn = backtrace_atomic_load_pointer (&state->fileline_fn); + + if (*fileline_fn == NULL || *fileline_fn == elf_nodebug) + *fileline_fn = elf_fileline_fn; + + return 1; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/fileline.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/fileline.c new file mode 100644 index 0000000..e567306 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/fileline.c @@ -0,0 +1,201 @@ +/* fileline.c -- Get file and line number information in a backtrace. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +#ifndef HAVE_GETEXECNAME +#define getexecname() NULL +#endif + +/* Initialize the fileline information from the executable. Returns 1 + on success, 0 on failure. */ + +static int +fileline_initialize (struct backtrace_state *state, + backtrace_error_callback error_callback, void *data) +{ + int failed; + fileline fileline_fn; + int pass; + int called_error_callback; + int descriptor; + const char *filename; + char buf[64]; + + if (!state->threaded) + failed = state->fileline_initialization_failed; + else + failed = backtrace_atomic_load_int (&state->fileline_initialization_failed); + + if (failed) + { + error_callback (data, "failed to read executable information", -1); + return 0; + } + + if (!state->threaded) + fileline_fn = state->fileline_fn; + else + fileline_fn = backtrace_atomic_load_pointer (&state->fileline_fn); + if (fileline_fn != NULL) + return 1; + + /* We have not initialized the information. Do it now. */ + + descriptor = -1; + called_error_callback = 0; + for (pass = 0; pass < 5; ++pass) + { + int does_not_exist; + + switch (pass) + { + case 0: + filename = state->filename; + break; + case 1: + filename = getexecname (); + break; + case 2: + filename = "/proc/self/exe"; + break; + case 3: + filename = "/proc/curproc/file"; + break; + case 4: + snprintf (buf, sizeof (buf), "/proc/%ld/object/a.out", + (long) getpid ()); + filename = buf; + break; + default: + abort (); + } + + if (filename == NULL) + continue; + + descriptor = backtrace_open (filename, error_callback, data, + &does_not_exist); + if (descriptor < 0 && !does_not_exist) + { + called_error_callback = 1; + break; + } + if (descriptor >= 0) + break; + } + + if (descriptor < 0) + { + if (!called_error_callback) + { + if (state->filename != NULL) + error_callback (data, state->filename, ENOENT); + else + error_callback (data, + "libbacktrace could not find executable to open", + 0); + } + failed = 1; + } + + if (!failed) + { + if (!backtrace_initialize (state, filename, descriptor, error_callback, + data, &fileline_fn)) + failed = 1; + } + + if (failed) + { + if (!state->threaded) + state->fileline_initialization_failed = 1; + else + backtrace_atomic_store_int (&state->fileline_initialization_failed, 1); + return 0; + } + + if (!state->threaded) + state->fileline_fn = fileline_fn; + else + { + backtrace_atomic_store_pointer (&state->fileline_fn, fileline_fn); + + /* Note that if two threads initialize at once, one of the data + sets may be leaked. */ + } + + return 1; +} + +/* Given a PC, find the file name, line number, and function name. */ + +int +backtrace_pcinfo (struct backtrace_state *state, uintptr_t pc, + backtrace_full_callback callback, + backtrace_error_callback error_callback, void *data) +{ + if (!fileline_initialize (state, error_callback, data)) + return 0; + + if (state->fileline_initialization_failed) + return 0; + + return state->fileline_fn (state, pc, callback, error_callback, data); +} + +/* Given a PC, find the symbol for it, and its value. */ + +int +backtrace_syminfo (struct backtrace_state *state, uintptr_t pc, + backtrace_syminfo_callback callback, + backtrace_error_callback error_callback, void *data) +{ + if (!fileline_initialize (state, error_callback, data)) + return 0; + + if (state->fileline_initialization_failed) + return 0; + + state->syminfo_fn (state, pc, callback, error_callback, data); + return 1; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/filenames.h b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/filenames.h new file mode 100644 index 0000000..2dcd664 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/filenames.h @@ -0,0 +1,49 @@ +/* btest.c -- Filename header for libbacktrace library + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#ifndef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) +#endif + +#if (GCC_VERSION < 2007) +# define __attribute__(x) +#endif + +#ifndef ATTRIBUTE_UNUSED +# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif + +#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__) +# define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\') +#else +# define IS_DIR_SEPARATOR(c) ((c) == '/') +#endif diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/filetype.awk b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/filetype.awk new file mode 100644 index 0000000..a5f6c8c --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/filetype.awk @@ -0,0 +1,11 @@ +# An awk script to determine the type of a file. +/\177ELF\001/ { if (NR == 1) { print "elf32"; exit } } +/\177ELF\002/ { if (NR == 1) { print "elf64"; exit } } +/\114\001/ { if (NR == 1) { print "pecoff"; exit } } +/\144\206/ { if (NR == 1) { print "pecoff"; exit } } +/\xFE\xED\xFA\xCE/ { if (NR == 1) { print "macho32"; exit } } +/\xCE\xFA\xED\xFE/ { if (NR == 1) { print "macho32"; exit } } +/\xFE\xED\xFA\xCF/ { if (NR == 1) { print "macho64"; exit } } +/\xCF\xFA\xED\xFE/ { if (NR == 1) { print "macho64"; exit } } +/\xCA\xFE\xBA\xBE/ { if (NR == 1) { print "macho-fat"; exit } } +/\xBE\xBA\xFE\xCA/ { if (NR == 1) { print "macho-fat"; exit } } diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/install-sh b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/install-sh new file mode 100755 index 0000000..a9244eb --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/install-sh @@ -0,0 +1,527 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2011-01-19.21; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + # Protect names problematic for `test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for `test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names problematic for `test' and other utilities. + case $src in + -* | [=\(\)!]) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + dst=$dst_arg + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/internal.h b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/internal.h new file mode 100644 index 0000000..bff8ed4 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/internal.h @@ -0,0 +1,304 @@ +/* internal.h -- Internal header file for stack backtrace library. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#ifndef BACKTRACE_INTERNAL_H +#define BACKTRACE_INTERNAL_H + +/* We assume that and "backtrace.h" have already been + included. */ + +#ifndef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) +#endif + +#if (GCC_VERSION < 2007) +# define __attribute__(x) +#endif + +#ifndef ATTRIBUTE_UNUSED +# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif + +#ifndef ATTRIBUTE_MALLOC +# if (GCC_VERSION >= 2096) +# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define ATTRIBUTE_MALLOC +# endif +#endif + +#ifndef HAVE_SYNC_FUNCTIONS + +/* Define out the sync functions. These should never be called if + they are not available. */ + +#define __sync_bool_compare_and_swap(A, B, C) (abort(), 1) +#define __sync_lock_test_and_set(A, B) (abort(), 0) +#define __sync_lock_release(A) abort() + +#endif /* !defined (HAVE_SYNC_FUNCTIONS) */ + +#ifdef HAVE_ATOMIC_FUNCTIONS + +/* We have the atomic builtin functions. */ + +#define backtrace_atomic_load_pointer(p) \ + __atomic_load_n ((p), __ATOMIC_ACQUIRE) +#define backtrace_atomic_load_int(p) \ + __atomic_load_n ((p), __ATOMIC_ACQUIRE) +#define backtrace_atomic_store_pointer(p, v) \ + __atomic_store_n ((p), (v), __ATOMIC_RELEASE) +#define backtrace_atomic_store_size_t(p, v) \ + __atomic_store_n ((p), (v), __ATOMIC_RELEASE) +#define backtrace_atomic_store_int(p, v) \ + __atomic_store_n ((p), (v), __ATOMIC_RELEASE) + +#else /* !defined (HAVE_ATOMIC_FUNCTIONS) */ +#ifdef HAVE_SYNC_FUNCTIONS + +/* We have the sync functions but not the atomic functions. Define + the atomic ones in terms of the sync ones. */ + +extern void *backtrace_atomic_load_pointer (void *); +extern int backtrace_atomic_load_int (int *); +extern void backtrace_atomic_store_pointer (void *, void *); +extern void backtrace_atomic_store_size_t (size_t *, size_t); +extern void backtrace_atomic_store_int (int *, int); + +#else /* !defined (HAVE_SYNC_FUNCTIONS) */ + +/* We have neither the sync nor the atomic functions. These will + never be called. */ + +#define backtrace_atomic_load_pointer(p) (abort(), (void *) NULL) +#define backtrace_atomic_load_int(p) (abort(), 0) +#define backtrace_atomic_store_pointer(p, v) abort() +#define backtrace_atomic_store_size_t(p, v) abort() +#define backtrace_atomic_store_int(p, v) abort() + +#endif /* !defined (HAVE_SYNC_FUNCTIONS) */ +#endif /* !defined (HAVE_ATOMIC_FUNCTIONS) */ + +/* The type of the function that collects file/line information. This + is like backtrace_pcinfo. */ + +typedef int (*fileline) (struct backtrace_state *state, uintptr_t pc, + backtrace_full_callback callback, + backtrace_error_callback error_callback, void *data); + +/* The type of the function that collects symbol information. This is + like backtrace_syminfo. */ + +typedef void (*syminfo) (struct backtrace_state *state, uintptr_t pc, + backtrace_syminfo_callback callback, + backtrace_error_callback error_callback, void *data); + +/* What the backtrace state pointer points to. */ + +struct backtrace_state +{ + /* The name of the executable. */ + const char *filename; + /* Non-zero if threaded. */ + int threaded; + /* The master lock for fileline_fn, fileline_data, syminfo_fn, + syminfo_data, fileline_initialization_failed and everything the + data pointers point to. */ + void *lock; + /* The function that returns file/line information. */ + fileline fileline_fn; + /* The data to pass to FILELINE_FN. */ + void *fileline_data; + /* The function that returns symbol information. */ + syminfo syminfo_fn; + /* The data to pass to SYMINFO_FN. */ + void *syminfo_data; + /* Whether initializing the file/line information failed. */ + int fileline_initialization_failed; + /* The lock for the freelist. */ + int lock_alloc; + /* The freelist when using mmap. */ + struct backtrace_freelist_struct *freelist; +}; + +/* Open a file for reading. Returns -1 on error. If DOES_NOT_EXIST + is not NULL, *DOES_NOT_EXIST will be set to 0 normally and set to 1 + if the file does not exist. If the file does not exist and + DOES_NOT_EXIST is not NULL, the function will return -1 and will + not call ERROR_CALLBACK. On other errors, or if DOES_NOT_EXIST is + NULL, the function will call ERROR_CALLBACK before returning. */ +extern int backtrace_open (const char *filename, + backtrace_error_callback error_callback, + void *data, + int *does_not_exist); + +/* A view of the contents of a file. This supports mmap when + available. A view will remain in memory even after backtrace_close + is called on the file descriptor from which the view was + obtained. */ + +struct backtrace_view +{ + /* The data that the caller requested. */ + const void *data; + /* The base of the view. */ + void *base; + /* The total length of the view. */ + size_t len; +}; + +/* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. Store the + result in *VIEW. Returns 1 on success, 0 on error. */ +extern int backtrace_get_view (struct backtrace_state *state, int descriptor, + off_t offset, size_t size, + backtrace_error_callback error_callback, + void *data, struct backtrace_view *view); + +/* Release a view created by backtrace_get_view. */ +extern void backtrace_release_view (struct backtrace_state *state, + struct backtrace_view *view, + backtrace_error_callback error_callback, + void *data); + +/* Close a file opened by backtrace_open. Returns 1 on success, 0 on + error. */ + +extern int backtrace_close (int descriptor, + backtrace_error_callback error_callback, + void *data); + +/* Sort without using memory. */ + +extern void backtrace_qsort (void *base, size_t count, size_t size, + int (*compar) (const void *, const void *)); + +/* Allocate memory. This is like malloc. If ERROR_CALLBACK is NULL, + this does not report an error, it just returns NULL. */ + +extern void *backtrace_alloc (struct backtrace_state *state, size_t size, + backtrace_error_callback error_callback, + void *data) ATTRIBUTE_MALLOC; + +/* Free memory allocated by backtrace_alloc. If ERROR_CALLBACK is + NULL, this does not report an error. */ + +extern void backtrace_free (struct backtrace_state *state, void *mem, + size_t size, + backtrace_error_callback error_callback, + void *data); + +/* A growable vector of some struct. This is used for more efficient + allocation when we don't know the final size of some group of data + that we want to represent as an array. */ + +struct backtrace_vector +{ + /* The base of the vector. */ + void *base; + /* The number of bytes in the vector. */ + size_t size; + /* The number of bytes available at the current allocation. */ + size_t alc; +}; + +/* Grow VEC by SIZE bytes. Return a pointer to the newly allocated + bytes. Note that this may move the entire vector to a new memory + location. Returns NULL on failure. */ + +extern void *backtrace_vector_grow (struct backtrace_state *state, size_t size, + backtrace_error_callback error_callback, + void *data, + struct backtrace_vector *vec); + +/* Finish the current allocation on VEC. Prepare to start a new + allocation. The finished allocation will never be freed. Returns + a pointer to the base of the finished entries, or NULL on + failure. */ + +extern void* backtrace_vector_finish (struct backtrace_state *state, + struct backtrace_vector *vec, + backtrace_error_callback error_callback, + void *data); + +/* Release any extra space allocated for VEC. This may change + VEC->base. Returns 1 on success, 0 on failure. */ + +extern int backtrace_vector_release (struct backtrace_state *state, + struct backtrace_vector *vec, + backtrace_error_callback error_callback, + void *data); + +/* Read initial debug data from a descriptor, and set the + fileline_data, syminfo_fn, and syminfo_data fields of STATE. + Return the fileln_fn field in *FILELN_FN--this is done this way so + that the synchronization code is only implemented once. This is + called after the descriptor has first been opened. It will close + the descriptor if it is no longer needed. Returns 1 on success, 0 + on error. There will be multiple implementations of this function, + for different file formats. Each system will compile the + appropriate one. */ + +extern int backtrace_initialize (struct backtrace_state *state, + const char *filename, + int descriptor, + backtrace_error_callback error_callback, + void *data, + fileline *fileline_fn); + +/* Add file/line information for a DWARF module. */ + +extern int backtrace_dwarf_add (struct backtrace_state *state, + uintptr_t base_address, + const unsigned char* dwarf_info, + size_t dwarf_info_size, + const unsigned char *dwarf_line, + size_t dwarf_line_size, + const unsigned char *dwarf_abbrev, + size_t dwarf_abbrev_size, + const unsigned char *dwarf_ranges, + size_t dwarf_range_size, + const unsigned char *dwarf_str, + size_t dwarf_str_size, + int is_bigendian, + backtrace_error_callback error_callback, + void *data, fileline *fileline_fn); + +/* A test-only hook for elf_uncompress_zdebug. */ + +extern int backtrace_uncompress_zdebug (struct backtrace_state *, + const unsigned char *compressed, + size_t compressed_size, + backtrace_error_callback, void *data, + unsigned char **uncompressed, + size_t *uncompressed_size); + +#endif diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/ltmain.sh b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/ltmain.sh new file mode 100755 index 0000000..93793bf --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/ltmain.sh @@ -0,0 +1,7874 @@ +# Generated from ltmain.m4sh. + +# ltmain.sh (GNU libtool) 2.2.4 +# Written by Gordon Matzigkeit , 1996 + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, +# or obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Usage: $progname [OPTION]... [MODE-ARG]... +# +# Provide generalized library-building support services. +# +# --config show all configuration variables +# --debug enable verbose shell tracing +# -n, --dry-run display commands without modifying any files +# --features display basic configuration information and exit +# --mode=MODE use operation mode MODE +# --preserve-dup-deps don't remove duplicate dependency libraries +# --quiet, --silent don't print informational messages +# --tag=TAG use configuration variables from tag TAG +# -v, --verbose print informational messages (default) +# --version print version information +# -h, --help print short or long help message +# +# MODE must be one of the following: +# +# clean remove files from the build directory +# compile compile a source file into a libtool object +# execute automatically set library path, then run a program +# finish complete the installation of libtool libraries +# install install libraries or executables +# link create a library or an executable +# uninstall remove libraries from an installed directory +# +# MODE-ARGS vary depending on the MODE. +# Try `$progname --help --mode=MODE' for a more detailed description of MODE. +# +# When reporting a bug, please describe a test case to reproduce it and +# include the following information: +# +# host-triplet: $host +# shell: $SHELL +# compiler: $LTCC +# compiler flags: $LTCFLAGS +# linker: $LD (gnu? $with_gnu_ld) +# $progname: (GNU libtool) 2.2.4 +# automake: $automake_version +# autoconf: $autoconf_version +# +# Report bugs to . + +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=2.2.4 +TIMESTAMP="" +package_revision=1.2976 + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# NLS nuisances: We save the old values to restore during execute mode. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +lt_user_locale= +lt_safe_locale= +for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +do + eval "if test \"\${$lt_var+set}\" = set; then + save_$lt_var=\$$lt_var + $lt_var=C + export $lt_var + lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" + lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" + fi" +done + +$lt_unset CDPATH + + + + + +: ${CP="cp -f"} +: ${ECHO="echo"} +: ${EGREP="/usr/bin/grep -E"} +: ${FGREP="/usr/bin/grep -F"} +: ${GREP="/usr/bin/grep"} +: ${LN_S="ln -s"} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${SED="/opt/local/bin/gsed"} +: ${SHELL="${CONFIG_SHELL-/bin/sh}"} +: ${Xsed="$SED -e 1s/^X//"} + +# Global variables: +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. +EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. + +exit_status=$EXIT_SUCCESS + +# Make sure IFS has a sensible default +lt_nl=' +' +IFS=" $lt_nl" + +dirname="s,/[^/]*$,," +basename="s,^.*/,," + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + +# Generated shell functions inserted here. + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath="$0" + +# The name of this program: +# In the unlikely event $progname began with a '-', it would play havoc with +# func_echo (imagine progname=-n), so we prepend ./ in that case: +func_dirname_and_basename "$progpath" +progname=$func_basename_result +case $progname in + -*) progname=./$progname ;; +esac + +# Make sure we have an absolute path for reexecution: +case $progpath in + [\\/]*|[A-Za-z]:\\*) ;; + *[\\/]*) + progdir=$func_dirname_result + progdir=`cd "$progdir" && pwd` + progpath="$progdir/$progname" + ;; + *) + save_IFS="$IFS" + IFS=: + for progdir in $PATH; do + IFS="$save_IFS" + test -x "$progdir/$progname" && break + done + IFS="$save_IFS" + test -n "$progdir" || progdir=`pwd` + progpath="$progdir/$progname" + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed="${SED}"' -e 1s/^X//' +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Re-`\' parameter expansions in output of double_quote_subst that were +# `\'-ed in input to the same. If an odd number of `\' preceded a '$' +# in input to double_quote_subst, that '$' was protected from expansion. +# Since each input `\' is now two `\'s, look for any number of runs of +# four `\'s followed by two `\'s and then a '$'. `\' that '$'. +bs='\\' +bs2='\\\\' +bs4='\\\\\\\\' +dollar='\$' +sed_double_backslash="\ + s/$bs4/&\\ +/g + s/^$bs2$dollar/$bs&/ + s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g + s/\n//g" + +# Standard options: +opt_dry_run=false +opt_help=false +opt_quiet=false +opt_verbose=false +opt_warning=: + +# func_echo arg... +# Echo program name prefixed message, along with the current mode +# name if it has been set yet. +func_echo () +{ + $ECHO "$progname${mode+: }$mode: $*" +} + +# func_verbose arg... +# Echo program name prefixed message in verbose mode only. +func_verbose () +{ + $opt_verbose && func_echo ${1+"$@"} + + # A bug in bash halts the script if the last line of a function + # fails when set -e is in force, so we need another command to + # work around that: + : +} + +# func_error arg... +# Echo program name prefixed message to standard error. +func_error () +{ + $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 +} + +# func_warning arg... +# Echo program name prefixed warning message to standard error. +func_warning () +{ + $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 + + # bash bug again: + : +} + +# func_fatal_error arg... +# Echo program name prefixed message to standard error, and exit. +func_fatal_error () +{ + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + +# func_fatal_help arg... +# Echo program name prefixed message to standard error, followed by +# a help hint, and exit. +func_fatal_help () +{ + func_error ${1+"$@"} + func_fatal_error "$help" +} +help="Try \`$progname --help' for more information." ## default + + +# func_grep expression filename +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + $GREP "$1" "$2" >/dev/null 2>&1 +} + + +# func_mkdir_p directory-path +# Make sure the entire path to DIRECTORY-PATH is available. +func_mkdir_p () +{ + my_directory_path="$1" + my_dir_list= + + if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then + + # Protect directory names starting with `-' + case $my_directory_path in + -*) my_directory_path="./$my_directory_path" ;; + esac + + # While some portion of DIR does not yet exist... + while test ! -d "$my_directory_path"; do + # ...make a list in topmost first order. Use a colon delimited + # list incase some portion of path contains whitespace. + my_dir_list="$my_directory_path:$my_dir_list" + + # If the last portion added has no slash in it, the list is done + case $my_directory_path in */*) ;; *) break ;; esac + + # ...otherwise throw away the child directory and loop + my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"` + done + my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'` + + save_mkdir_p_IFS="$IFS"; IFS=':' + for my_dir in $my_dir_list; do + IFS="$save_mkdir_p_IFS" + # mkdir can fail with a `File exist' error if two processes + # try to create one of the directories concurrently. Don't + # stop in that case! + $MKDIR "$my_dir" 2>/dev/null || : + done + IFS="$save_mkdir_p_IFS" + + # Bail out if we (or some other process) failed to create a directory. + test -d "$my_directory_path" || \ + func_fatal_error "Failed to create \`$1'" + fi +} + + +# func_mktempdir [string] +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, STRING is the basename for that directory. +func_mktempdir () +{ + my_template="${TMPDIR-/tmp}/${1-$progname}" + + if test "$opt_dry_run" = ":"; then + # Return a directory name, but don't create it in dry-run mode + my_tmpdir="${my_template}-$$" + else + + # If mktemp works, use that first and foremost + my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` + + if test ! -d "$my_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + my_tmpdir="${my_template}-${RANDOM-0}$$" + + save_mktempdir_umask=`umask` + umask 0077 + $MKDIR "$my_tmpdir" + umask $save_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$my_tmpdir" || \ + func_fatal_error "cannot create temporary directory \`$my_tmpdir'" + fi + + $ECHO "X$my_tmpdir" | $Xsed +} + + +# func_quote_for_eval arg +# Aesthetically quote ARG to be evaled later. +# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT +# is double-quoted, suitable for a subsequent eval, whereas +# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters +# which are still active within double quotes backslashified. +func_quote_for_eval () +{ + case $1 in + *[\\\`\"\$]*) + func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;; + *) + func_quote_for_eval_unquoted_result="$1" ;; + esac + + case $func_quote_for_eval_unquoted_result in + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and and variable + # expansion for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" + ;; + *) + func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" + esac +} + + +# func_quote_for_expand arg +# Aesthetically quote ARG to be evaled later; same as above, +# but do not quote variable references. +func_quote_for_expand () +{ + case $1 in + *[\\\`\"]*) + my_arg=`$ECHO "X$1" | $Xsed \ + -e "$double_quote_subst" -e "$sed_double_backslash"` ;; + *) + my_arg="$1" ;; + esac + + case $my_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting and command substitution for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + my_arg="\"$my_arg\"" + ;; + esac + + func_quote_for_expand_result="$my_arg" +} + + +# func_show_eval cmd [fail_exp] +# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. +func_show_eval () +{ + my_cmd="$1" + my_fail_exp="${2-:}" + + ${opt_silent-false} || { + func_quote_for_expand "$my_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + if ${opt_dry_run-false}; then :; else + eval "$my_cmd" + my_status=$? + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + fi +} + + +# func_show_eval_locale cmd [fail_exp] +# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. Use the saved locale for evaluation. +func_show_eval_locale () +{ + my_cmd="$1" + my_fail_exp="${2-:}" + + ${opt_silent-false} || { + func_quote_for_expand "$my_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + if ${opt_dry_run-false}; then :; else + eval "$lt_user_locale + $my_cmd" + my_status=$? + eval "$lt_safe_locale" + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + fi +} + + + + + +# func_version +# Echo version message to standard output and exit. +func_version () +{ + $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / { + s/^# // + s/^# *$// + s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ + p + }' < "$progpath" + exit $? +} + +# func_usage +# Echo short help message to standard output and exit. +func_usage () +{ + $SED -n '/^# Usage:/,/# -h/ { + s/^# // + s/^# *$// + s/\$progname/'$progname'/ + p + }' < "$progpath" + $ECHO + $ECHO "run \`$progname --help | more' for full usage" + exit $? +} + +# func_help +# Echo long help message to standard output and exit. +func_help () +{ + $SED -n '/^# Usage:/,/# Report bugs to/ { + s/^# // + s/^# *$// + s*\$progname*'$progname'* + s*\$host*'"$host"'* + s*\$SHELL*'"$SHELL"'* + s*\$LTCC*'"$LTCC"'* + s*\$LTCFLAGS*'"$LTCFLAGS"'* + s*\$LD*'"$LD"'* + s/\$with_gnu_ld/'"$with_gnu_ld"'/ + s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ + s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ + p + }' < "$progpath" + exit $? +} + +# func_missing_arg argname +# Echo program name prefixed message to standard error and set global +# exit_cmd. +func_missing_arg () +{ + func_error "missing argument for $1" + exit_cmd=exit +} + +exit_cmd=: + + + + + +# Check that we have a working $ECHO. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell, and then maybe $ECHO will work. + exec $SHELL "$progpath" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null 2>&1; then + taglist="$taglist $tagname" + + # Evaluate the configuration. Be careful to quote the path + # and the sed script, to avoid splitting on whitespace, but + # also don't use non-portable quotes within backquotes within + # quotes we have to do it in 2 steps: + extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` + eval "$extractedcf" + else + func_error "ignoring unknown tag $tagname" + fi + ;; + esac +} + +# Parse options once, thoroughly. This comes as soon as possible in +# the script to make things like `libtool --version' happen quickly. +{ + + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; + compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; + execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; + finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; + install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; + link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; + uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift + ;; + esac + + # Parse non-mode specific arguments: + while test "$#" -gt 0; do + opt="$1" + shift + + case $opt in + --config) func_config ;; + + --debug) preserve_args="$preserve_args $opt" + func_echo "enabling shell trace mode" + opt_debug='set -x' + $opt_debug + ;; + + -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break + execute_dlfiles="$execute_dlfiles $1" + shift + ;; + + --dry-run | -n) opt_dry_run=: ;; + --features) func_features ;; + --finish) mode="finish" ;; + + --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break + case $1 in + # Valid mode arguments: + clean) ;; + compile) ;; + execute) ;; + finish) ;; + install) ;; + link) ;; + relink) ;; + uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $opt" + exit_cmd=exit + break + ;; + esac + + mode="$1" + shift + ;; + + --preserve-dup-deps) + opt_duplicate_deps=: ;; + + --quiet|--silent) preserve_args="$preserve_args $opt" + opt_silent=: + ;; + + --verbose| -v) preserve_args="$preserve_args $opt" + opt_silent=false + ;; + + --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break + preserve_args="$preserve_args $opt $1" + func_enable_tag "$1" # tagname is set here + shift + ;; + + # Separate optargs to long options: + -dlopen=*|--mode=*|--tag=*) + func_opt_split "$opt" + set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} + shift + ;; + + -\?|-h) func_usage ;; + --help) opt_help=: ;; + --version) func_version ;; + + -*) func_fatal_help "unrecognized option \`$opt'" ;; + + *) nonopt="$opt" + break + ;; + esac + done + + + case $host in + *cygwin* | *mingw* | *pw32*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; + *) + opt_duplicate_compiler_generated_deps=$opt_duplicate_deps + ;; + esac + + # Having warned about all mis-specified options, bail out if + # anything was wrong. + $exit_cmd $EXIT_FAILURE +} + +# func_check_version_match +# Ensure that we are using m4 macros, and libtool script from the same +# release of libtool. +func_check_version_match () +{ + if test "$package_revision" != "$macro_revision"; then + if test "$VERSION" != "$macro_version"; then + if test -z "$macro_version"; then + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from an older release. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + fi + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, +$progname: but the definition of this LT_INIT comes from revision $macro_revision. +$progname: You should recreate aclocal.m4 with macros from revision $package_revision +$progname: of $PACKAGE $VERSION and run autoconf again. +_LT_EOF + fi + + exit $EXIT_MISMATCH + fi +} + + +## ----------- ## +## Main. ## +## ----------- ## + +$opt_help || { + # Sanity checks first: + func_check_version_match + + if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + func_fatal_configuration "not configured to build any kind of library" + fi + + test -z "$mode" && func_fatal_error "error: you must specify a MODE." + + + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + func_error "unrecognized option \`-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$progname --help --mode=$mode' for more information." +} + + +# func_lalib_p file +# True iff FILE is a libtool `.la' library or `.lo' object file. +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_lalib_p () +{ + $SED -e 4q "$1" 2>/dev/null \ + | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 +} + +# func_lalib_unsafe_p file +# True iff FILE is a libtool `.la' library or `.lo' object file. +# This function implements the same check as func_lalib_p without +# resorting to external programs. To this end, it redirects stdin and +# closes it afterwards, without saving the original file descriptor. +# As a safety measure, use it only where a negative result would be +# fatal anyway. Works if `file' does not exist. +func_lalib_unsafe_p () +{ + lalib_p=no + if test -r "$1" && exec 5<&0 <"$1"; then + for lalib_p_l in 1 2 3 4 + do + read lalib_p_line + case "$lalib_p_line" in + \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; + esac + done + exec 0<&5 5<&- + fi + test "$lalib_p" = yes +} + +# func_ltwrapper_script_p file +# True iff FILE is a libtool wrapper script +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_script_p () +{ + func_lalib_p "$1" +} + +# func_ltwrapper_executable_p file +# True iff FILE is a libtool wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_executable_p () +{ + func_ltwrapper_exec_suffix= + case $1 in + *.exe) ;; + *) func_ltwrapper_exec_suffix=.exe ;; + esac + $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 +} + +# func_ltwrapper_scriptname file +# Assumes file is an ltwrapper_executable +# uses $file to determine the appropriate filename for a +# temporary ltwrapper_script. +func_ltwrapper_scriptname () +{ + func_ltwrapper_scriptname_result="" + if func_ltwrapper_executable_p "$1"; then + func_dirname_and_basename "$1" "" "." + func_stripname '' '.exe' "$func_basename_result" + func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" + fi +} + +# func_ltwrapper_p file +# True iff FILE is a libtool wrapper script or wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_p () +{ + func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" +} + + +# func_execute_cmds commands fail_cmd +# Execute tilde-delimited COMMANDS. +# If FAIL_CMD is given, eval that upon failure. +# FAIL_CMD may read-access the current command in variable CMD! +func_execute_cmds () +{ + $opt_debug + save_ifs=$IFS; IFS='~' + for cmd in $1; do + IFS=$save_ifs + eval cmd=\"$cmd\" + func_show_eval "$cmd" "${2-:}" + done + IFS=$save_ifs +} + + +# func_source file +# Source FILE, adding directory component if necessary. +# Note that it is not necessary on cygwin/mingw to append a dot to +# FILE even if both FILE and FILE.exe exist: automatic-append-.exe +# behavior happens only for exec(3), not for open(2)! Also, sourcing +# `FILE.' does not work on cygwin managed mounts. +func_source () +{ + $opt_debug + case $1 in + */* | *\\*) . "$1" ;; + *) . "./$1" ;; + esac +} + + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () +{ + $opt_debug + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + func_quote_for_eval "$arg" + CC_quoted="$CC_quoted $func_quote_for_eval_result" + done + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + func_quote_for_eval "$arg" + CC_quoted="$CC_quoted $func_quote_for_eval_result" + done + case "$@ " in + " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + func_echo "unable to infer tagged configuration" + func_fatal_error "specify a tag with \`--tag'" +# else +# func_verbose "using $tagname tagged configuration" + fi + ;; + esac + fi +} + + + +# func_write_libtool_object output_name pic_name nonpic_name +# Create a libtool object file (analogous to a ".la" file), +# but don't create it if we're doing a dry run. +func_write_libtool_object () +{ + write_libobj=${1} + if test "$build_libtool_libs" = yes; then + write_lobj=\'${2}\' + else + write_lobj=none + fi + + if test "$build_old_libs" = yes; then + write_oldobj=\'${3}\' + else + write_oldobj=none + fi + + $opt_dry_run || { + cat >${write_libobj}T <?"'"'"' &()|`$[]' \ + && func_warning "libobj name \`$libobj' may not contain shell special characters." + func_dirname_and_basename "$obj" "/" "" + objname="$func_basename_result" + xdir="$func_dirname_result" + lobj=${xdir}$objdir/$objname + + test -z "$base_compile" && \ + func_fatal_help "you must specify a compilation command" + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2*) + pic_mode=default + ;; + esac + if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + $ECHO "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + removelist="$removelist $output_obj" + $ECHO "$srcfile" > "$lockfile" + fi + + $opt_dry_run || $RM $removelist + removelist="$removelist $lockfile" + trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + func_quote_for_eval "$srcfile" + qsrcfile=$func_quote_for_eval_result + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test "$pic_mode" != no; then + command="$base_compile $qsrcfile $pic_flag" + else + # Don't build PIC code + command="$base_compile $qsrcfile" + fi + + func_mkdir_p "$xdir$objdir" + + if test -z "$output_obj"; then + # Place PIC objects in $objdir + command="$command -o $lobj" + fi + + func_show_eval_locale "$command" \ + 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + func_show_eval '$MV "$output_obj" "$lobj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + + # Allow error messages only from the first compilation. + if test "$suppress_opt" = yes; then + suppress_output=' >/dev/null 2>&1' + fi + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + if test "$pic_mode" != yes; then + # Don't build PIC code + command="$base_compile $qsrcfile$pie_flag" + else + command="$base_compile $qsrcfile $pic_flag" + fi + if test "$compiler_c_o" = yes; then + command="$command -o $obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + func_show_eval_locale "$command" \ + '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + func_show_eval '$MV "$output_obj" "$obj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + fi + + $opt_dry_run || { + func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + removelist=$lockfile + $RM "$lockfile" + fi + } + + exit $EXIT_SUCCESS +} + +$opt_help || { +test "$mode" = compile && func_mode_compile ${1+"$@"} +} + +func_mode_help () +{ + # We need to display help for each of the modes. + case $mode in + "") + # Generic help is extracted from the usage comments + # at the start of this file. + func_help + ;; + + clean) + $ECHO \ +"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + + compile) + $ECHO \ +"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -no-suppress do not suppress compiler output for multiple passes + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -shared do not build a \`.o' file suitable for static linking + -static only build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + + execute) + $ECHO \ +"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + + finish) + $ECHO \ +"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + + install) + $ECHO \ +"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The following components of INSTALL-COMMAND are treated specially: + + -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + + link) + $ECHO \ +"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE Use a list of object files found in FILE to specify objects + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -shared only do dynamic linking of libtool libraries + -shrext SUFFIX override the standard shared library file extension + -static do not do any dynamic linking of uninstalled libtool libraries + -static-libtool-libs + do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + -weak LIBNAME declare that the target provides the LIBNAME interface + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + + uninstall) + $ECHO \ +"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + + *) + func_fatal_help "invalid operation mode \`$mode'" + ;; + esac + + $ECHO + $ECHO "Try \`$progname --help' for more information about other modes." + + exit $? +} + + # Now that we've collected a possible --mode arg, show help if necessary + $opt_help && func_mode_help + + +# func_mode_execute arg... +func_mode_execute () +{ + $opt_debug + # The first argument is the command name. + cmd="$nonopt" + test -z "$cmd" && \ + func_fatal_help "you must specify a COMMAND" + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + test -f "$file" \ + || func_fatal_help "\`$file' is not a file" + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "\`$lib' is not a valid libtool archive" + + # Read the libtool library. + dlname= + library_names= + func_source "$file" + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && \ + func_warning "\`$file' was not linked with \`-export-dynamic'" + continue + fi + + func_dirname "$file" "" "." + dir="$func_dirname_result" + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + if test ! -f "$dir/$dlname"; then + func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" + fi + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + func_dirname "$file" "" "." + dir="$func_dirname_result" + ;; + + *) + func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if func_ltwrapper_script_p "$file"; then + func_source "$file" + # Transform arg to wrapped name. + file="$progdir/$program" + elif func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + func_source "$func_ltwrapper_scriptname_result" + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + func_quote_for_eval "$file" + args="$args $func_quote_for_eval_result" + done + + if test "X$opt_dry_run" = Xfalse; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES + do + eval "if test \"\${save_$lt_var+set}\" = set; then + $lt_var=\$save_$lt_var; export $lt_var + else + $lt_unset $lt_var + fi" + done + + # Now prepare to actually exec the command. + exec_cmd="\$cmd$args" + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" + $ECHO "export $shlibpath_var" + fi + $ECHO "$cmd$args" + exit $EXIT_SUCCESS + fi +} + +test "$mode" = execute && func_mode_execute ${1+"$@"} + + +# func_mode_finish arg... +func_mode_finish () +{ + $opt_debug + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + func_execute_cmds "$finish_cmds" 'admincmds="$admincmds +'"$cmd"'"' + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $opt_dry_run || eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + $opt_silent && exit $EXIT_SUCCESS + + $ECHO "X----------------------------------------------------------------------" | $Xsed + $ECHO "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + $ECHO + $ECHO "If you ever happen to want to link against installed libraries" + $ECHO "in a given directory, LIBDIR, you must either use libtool, and" + $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'" + $ECHO "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable" + $ECHO " during execution" + fi + if test -n "$runpath_var"; then + $ECHO " - add LIBDIR to the \`$runpath_var' environment variable" + $ECHO " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $ECHO " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + $ECHO + + $ECHO "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual" + $ECHO "pages." + ;; + *) + $ECHO "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + $ECHO "X----------------------------------------------------------------------" | $Xsed + exit $EXIT_SUCCESS +} + +test "$mode" = finish && func_mode_finish ${1+"$@"} + + +# func_mode_install arg... +func_mode_install () +{ + $opt_debug + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # Allow the use of GNU shtool's install command. + $ECHO "X$nonopt" | $GREP shtool >/dev/null; then + # Aesthetically quote it. + func_quote_for_eval "$nonopt" + install_prog="$func_quote_for_eval_result " + arg=$1 + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + func_quote_for_eval "$arg" + install_prog="$install_prog$func_quote_for_eval_result" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) + case " $install_prog " in + *[\\\ /]cp\ *) ;; + *) prev=$arg ;; + esac + ;; + -g | -m | -o) + prev=$arg + ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + func_quote_for_eval "$arg" + install_prog="$install_prog $func_quote_for_eval_result" + done + + test -z "$install_prog" && \ + func_fatal_help "you must specify an install program" + + test -n "$prev" && \ + func_fatal_help "the \`$prev' option requires an argument" + + if test -z "$files"; then + if test -z "$dest"; then + func_fatal_help "no file or destination specified" + else + func_fatal_help "you must specify a destination" + fi + fi + + # Strip any trailing slash from the destination. + func_stripname '' '/' "$dest" + dest=$func_stripname_result + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + func_dirname_and_basename "$dest" "" "." + destdir="$func_dirname_result" + destname="$func_basename_result" + + # Not a directory, so check to see that there is only one file specified. + set dummy $files; shift + test "$#" -gt 1 && \ + func_fatal_help "\`$dest' is not a directory" + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + func_fatal_help "\`$destdir' must be an absolute directory name" + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "\`$file' is not a valid libtool archive" + + library_names= + old_library= + relink_command= + func_source "$file" + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + func_dirname "$file" "/" "" + dir="$func_dirname_result" + dir="$dir$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + test "$inst_prefix_dir" = "$destdir" && \ + func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"` + fi + + func_warning "relinking \`$file'" + func_show_eval "$relink_command" \ + 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' + fi + + # See the names of the shared library. + set dummy $library_names; shift + if test -n "$1"; then + realname="$1" + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \ + 'exit $?' + tstripme="$stripme" + case $host_os in + cygwin* | mingw* | pw32*) + case $realname in + *.dll.a) + tstripme="" + ;; + esac + ;; + esac + if test -n "$tstripme" && test -n "$striplib"; then + func_show_eval "$striplib $destdir/$realname" 'exit $?' + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + # Try `ln -sf' first, because the `ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. + for linkname + do + test "$linkname" != "$realname" \ + && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + func_execute_cmds "$postinstall_cmds" 'exit $?' + fi + + # Install the pseudo-library for information purposes. + func_basename "$file" + name="$func_basename_result" + instname="$dir/$name"i + func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + func_basename "$file" + destfile="$func_basename_result" + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + func_lo2o "$destfile" + staticdest=$func_lo2o_result + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + func_fatal_help "cannot copy a libtool object to \`$destfile'" + ;; + esac + + # Install the libtool object if requested. + test -n "$destfile" && \ + func_show_eval "$install_prog $file $destfile" 'exit $?' + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + func_lo2o "$file" + staticobj=$func_lo2o_result + func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + func_basename "$file" + destfile="$func_basename_result" + destfile="$destdir/$destfile" + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext="" + case $file in + *.exe) + if test ! -f "$file"; then + func_stripname '' '.exe' "$file" + file=$func_stripname_result + stripped_ext=".exe" + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin*|*mingw*) + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result + else + func_stripname '' '.exe' "$file" + wrapper=$func_stripname_result + fi + ;; + *) + wrapper=$file + ;; + esac + if func_ltwrapper_script_p "$wrapper"; then + notinst_deplibs= + relink_command= + + func_source "$wrapper" + + # Check the variables that should have been set. + test -z "$generated_by_libtool_version" && \ + func_fatal_error "invalid libtool wrapper script \`$wrapper'" + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + func_source "$lib" + fi + libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + func_warning "\`$lib' has not been installed in \`$libdir'" + finalize=no + fi + done + + relink_command= + func_source "$wrapper" + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + $opt_dry_run || { + if test "$finalize" = yes; then + tmpdir=`func_mktempdir` + func_basename "$file$stripped_ext" + file="$func_basename_result" + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $opt_silent || { + func_quote_for_expand "$relink_command" + eval "func_echo $func_quote_for_expand_result" + } + if eval "$relink_command"; then : + else + func_error "error: relink \`$file' with the above command before installing it" + $opt_dry_run || ${RM}r "$tmpdir" + continue + fi + file="$outputname" + else + func_warning "cannot relink \`$file'" + fi + } + else + # Install the binary that we compiled earlier. + file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + func_stripname '' '.exe' "$destfile" + destfile=$func_stripname_result + ;; + esac + ;; + esac + func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' + $opt_dry_run || if test -n "$outputname"; then + ${RM}r "$tmpdir" + fi + ;; + esac + done + + for file in $staticlibs; do + func_basename "$file" + name="$func_basename_result" + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + func_show_eval "$install_prog \$file \$oldlib" 'exit $?' + + if test -n "$stripme" && test -n "$old_striplib"; then + func_show_eval "$old_striplib $oldlib" 'exit $?' + fi + + # Do each command in the postinstall commands. + func_execute_cmds "$old_postinstall_cmds" 'exit $?' + done + + test -n "$future_libdirs" && \ + func_warning "remember to run \`$progname --finish$future_libdirs'" + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + $opt_dry_run && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi +} + +test "$mode" = install && func_mode_install ${1+"$@"} + + +# func_generate_dlsyms outputname originator pic_p +# Extract symbols from dlprefiles and create ${outputname}S.o with +# a dlpreopen symbol table. +func_generate_dlsyms () +{ + $opt_debug + my_outputname="$1" + my_originator="$2" + my_pic_p="${3-no}" + my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` + my_dlsyms= + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + my_dlsyms="${my_outputname}S.c" + else + func_error "not configured to extract global symbols from dlpreopened files" + fi + fi + + if test -n "$my_dlsyms"; then + case $my_dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${my_outputname}.nm" + + func_show_eval "$RM $nlist ${nlist}S ${nlist}T" + + # Parse the name list into a source file. + func_verbose "creating $output_objdir/$my_dlsyms" + + $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ +/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ +/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + func_verbose "generating symbol list for \`$output'" + + $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for progfile in $progfiles; do + func_verbose "extracting global C symbols from \`$progfile'" + $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $opt_dry_run || { + eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + if test -n "$export_symbols_regex"; then + $opt_dry_run || { + eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$outputname.exp" + $opt_dry_run || { + $RM $export_symbols + eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac + } + else + $opt_dry_run || { + eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + case $host in + *cygwin | *mingw* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac + } + fi + fi + + for dlprefile in $dlprefiles; do + func_verbose "extracting global C symbols from \`$dlprefile'" + func_basename "$dlprefile" + name="$func_basename_result" + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + done + + $opt_dry_run || { + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if $GREP -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + $GREP -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' + else + $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms" + fi + + $ECHO >> "$output_objdir/$my_dlsyms" "\ + +/* The mapping between symbol names and symbols. */ +typedef struct { + const char *name; + void *address; +} lt_dlsymlist; +" + case $host in + *cygwin* | *mingw* ) + $ECHO >> "$output_objdir/$my_dlsyms" "\ +/* DATA imports from DLLs on WIN32 con't be const, because + runtime relocations are performed -- see ld's documentation + on pseudo-relocs. */" + lt_dlsym_const= ;; + *osf5*) + echo >> "$output_objdir/$my_dlsyms" "\ +/* This system does not cope well with relocations in const data */" + lt_dlsym_const= ;; + *) + lt_dlsym_const=const ;; + esac + + $ECHO >> "$output_objdir/$my_dlsyms" "\ +extern $lt_dlsym_const lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[]; +$lt_dlsym_const lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[] = +{\ + { \"$my_originator\", (void *) 0 }," + + case $need_lib_prefix in + no) + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + *) + eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + esac + $ECHO >> "$output_objdir/$my_dlsyms" "\ + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_${my_prefix}_LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + } # !$opt_dry_run + + pic_flag_for_symtable= + case "$compile_command " in + *" -static "*) ;; + *) + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; + *-*-hpux*) + pic_flag_for_symtable=" $pic_flag" ;; + *) + if test "X$my_pic_p" != Xno; then + pic_flag_for_symtable=" $pic_flag" + fi + ;; + esac + ;; + esac + symtab_cflags= + for arg in $LTCFLAGS; do + case $arg in + -pie | -fpie | -fPIE) ;; + *) symtab_cflags="$symtab_cflags $arg" ;; + esac + done + + # Now compile the dynamic symbol file. + func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' + + # Clean up the generated files. + func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' + + # Transform the symbol file into the correct name. + symfileobj="$output_objdir/${my_outputname}S.$objext" + case $host in + *cygwin* | *mingw* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + else + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + fi + ;; + *) + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + ;; + esac + ;; + *) + func_fatal_error "unknown suffix for \`$my_dlsyms'" + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi +} + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +func_win32_libid () +{ + $opt_debug + win32_libid_type="unknown" + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | + $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $NM -f posix -A $1 | + $SED -n -e ' + 1,100{ + / I /{ + s,.*,import, + p + q + } + }'` + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $ECHO "$win32_libid_type" +} + + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + $opt_debug + f_ex_an_ar_dir="$1"; shift + f_ex_an_ar_oldlib="$1" + func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?' + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" + fi +} + + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + $opt_debug + my_gentop="$1"; shift + my_oldlibs=${1+"$@"} + my_oldobjs="" + my_xlib="" + my_xabs="" + my_xdir="" + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + func_basename "$my_xlib" + my_xlib="$func_basename_result" + my_xlib_u=$my_xlib + while :; do + case " $extracted_archives " in + *" $my_xlib_u "*) + func_arith $extracted_serial + 1 + extracted_serial=$func_arith_result + my_xlib_u=lt$extracted_serial-$my_xlib ;; + *) break ;; + esac + done + extracted_archives="$extracted_archives $my_xlib_u" + my_xdir="$my_gentop/$my_xlib_u" + + func_mkdir_p "$my_xdir" + + case $host in + *-darwin*) + func_verbose "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + $opt_dry_run || { + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + darwin_base_archive=`basename "$darwin_archive"` + darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` + if test -n "$darwin_arches"; then + darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches ; do + func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" + $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" + cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" + func_extract_an_archive "`pwd`" "${darwin_base_archive}" + cd "$darwin_curdir" + $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" + done # $darwin_arches + ## Okay now we've a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` + $LIPO -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + $RM -rf unfat-$$ + cd "$darwin_orig_dir" + else + cd $darwin_orig_dir + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + } # !$opt_dry_run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + + func_extract_archives_result="$my_oldobjs" +} + + + +# func_emit_wrapper arg +# +# emit a libtool wrapper script on stdout +# don't directly open a file because we may want to +# incorporate the script contents within a cygwin/mingw +# wrapper executable. Must ONLY be called from within +# func_mode_link because it depends on a number of variable +# set therein. +# +# arg is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR +# variable will take. If 'yes', then the emitted script +# will assume that the directory in which it is stored is +# the '.lib' directory. This is a cygwin/mingw-specific +# behavior. +func_emit_wrapper () +{ + func_emit_wrapper_arg1=no + if test -n "$1" ; then + func_emit_wrapper_arg1=$1 + fi + + $ECHO "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='${SED} -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variables: + generated_by_libtool_version='$macro_version' + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$ECHO are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + ECHO=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$ECHO works! + : + else + # Restart under the correct shell, and then maybe \$ECHO will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $ECHO "\ + + # Find the directory that this script lives in. + thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 + if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then + # special case for '.' + if test \"\$thisdir\" = \".\"; then + thisdir=\`pwd\` + fi + # remove .libs from thisdir + case \"\$thisdir\" in + *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;; + $objdir ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $ECHO "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $MKDIR \"\$progdir\" + else + $RM \"\$progdir/\$file\" + fi" + + $ECHO "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + $ECHO \"\$relink_command_output\" >&2 + $RM \"\$progdir/\$file\" + exit 1 + fi + fi + + $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $RM \"\$progdir/\$program\"; + $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $RM \"\$progdir/\$file\" + fi" + else + $ECHO "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $ECHO "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $ECHO "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $ECHO "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $ECHO "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $ECHO "\ + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $ECHO "\ + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $ECHO "\ + \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 + exit 1 + fi + else + # The program doesn't exist. + \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 + \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 + $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" +} +# end: func_emit_wrapper + +# func_emit_cwrapperexe_src +# emit the source code for a wrapper executable on stdout +# Must ONLY be called from within func_mode_link because +# it depends on a number of variable set therein. +func_emit_cwrapperexe_src () +{ + cat < +#include +#ifdef _MSC_VER +# include +# include +# include +# define setmode _setmode +#else +# include +# include +# ifdef __CYGWIN__ +# include +# endif +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef S_IXOTH +# define S_IXOTH 0 +#endif +#ifndef S_IXGRP +# define S_IXGRP 0 +#endif + +#ifdef _MSC_VER +# define S_IXUSR _S_IEXEC +# define stat _stat +# ifndef _INTPTR_T_DEFINED +# define intptr_t int +# endif +#endif + +#ifndef DIR_SEPARATOR +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +# define HAVE_DOS_BASED_FILE_SYSTEM +# define FOPEN_WB "wb" +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + +#ifdef __CYGWIN__ +# define FOPEN_WB "wb" +#endif + +#ifndef FOPEN_WB +# define FOPEN_WB "w" +#endif +#ifndef _O_BINARY +# define _O_BINARY 0 +#endif + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +#undef LTWRAPPER_DEBUGPRINTF +#if defined DEBUGWRAPPER +# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args +static void +ltwrapper_debugprintf (const char *fmt, ...) +{ + va_list args; + va_start (args, fmt); + (void) vfprintf (stderr, fmt, args); + va_end (args); +} +#else +# define LTWRAPPER_DEBUGPRINTF(args) +#endif + +const char *program_name = NULL; + +void *xmalloc (size_t num); +char *xstrdup (const char *string); +const char *base_name (const char *name); +char *find_executable (const char *wrapper); +char *chase_symlinks (const char *pathspec); +int make_executable (const char *path); +int check_executable (const char *path); +char *strendzap (char *str, const char *pat); +void lt_fatal (const char *message, ...); + +static const char *script_text = +EOF + + func_emit_wrapper yes | + $SED -e 's/\([\\"]\)/\\\1/g' \ + -e 's/^/ "/' -e 's/$/\\n"/' + echo ";" + + cat </dev/null || echo $SHELL` + case $lt_newargv0 in + *.exe | *.EXE) ;; + *) lt_newargv0=$lt_newargv0.exe ;; + esac + ;; + * ) lt_newargv0=$SHELL ;; + esac + fi + + cat <= 0) + && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + return 1; + else + return 0; +} + +int +make_executable (const char *path) +{ + int rval = 0; + struct stat st; + + LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", + path ? (*path ? path : "EMPTY!") : "NULL!")); + if ((!path) || (!*path)) + return 0; + + if (stat (path, &st) >= 0) + { + rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); + } + return rval; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise + Does not chase symlinks, even on platforms that support them. +*/ +char * +find_executable (const char *wrapper) +{ + int has_slash = 0; + const char *p; + const char *p_next; + /* static buffer for getcwd */ + char tmp[LT_PATHMAX + 1]; + int tmp_len; + char *concat_name; + + LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", + wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); + + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + } +#endif + + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char *path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char *q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR (*q)) + break; + p_len = q - p; + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen (tmp); + concat_name = + XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = + XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen (tmp); + concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + return NULL; +} + +char * +chase_symlinks (const char *pathspec) +{ +#ifndef S_ISLNK + return xstrdup (pathspec); +#else + char buf[LT_PATHMAX]; + struct stat s; + char *tmp_pathspec = xstrdup (pathspec); + char *p; + int has_symlinks = 0; + while (strlen (tmp_pathspec) && !has_symlinks) + { + LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n", + tmp_pathspec)); + if (lstat (tmp_pathspec, &s) == 0) + { + if (S_ISLNK (s.st_mode) != 0) + { + has_symlinks = 1; + break; + } + + /* search backwards for last DIR_SEPARATOR */ + p = tmp_pathspec + strlen (tmp_pathspec) - 1; + while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + p--; + if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + { + /* no more DIR_SEPARATORS left */ + break; + } + *p = '\0'; + } + else + { + char *errstr = strerror (errno); + lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); + } + } + XFREE (tmp_pathspec); + + if (!has_symlinks) + { + return xstrdup (pathspec); + } + + tmp_pathspec = realpath (pathspec, buf); + if (tmp_pathspec == 0) + { + lt_fatal ("Could not follow symlinks for %s", pathspec); + } + return xstrdup (tmp_pathspec); +#endif +} + +char * +strendzap (char *str, const char *pat) +{ + size_t len, patlen; + + assert (str != NULL); + assert (pat != NULL); + + len = strlen (str); + patlen = strlen (pat); + + if (patlen <= len) + { + str += len - patlen; + if (strcmp (str, pat) == 0) + *str = '\0'; + } + return str; +} + +static void +lt_error_core (int exit_status, const char *mode, + const char *message, va_list ap) +{ + fprintf (stderr, "%s: %s: ", program_name, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); + va_end (ap); +} +EOF +} +# end: func_emit_cwrapperexe_src + +# func_mode_link arg... +func_mode_link () +{ + $opt_debug + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invocation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args=$nonopt + base_compile="$nonopt $@" + compile_command=$nonopt + finalize_command=$nonopt + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + inst_prefix_dir= + new_inherited_linker_flags= + + avoid_version=no + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + non_pic_objects= + precious_files_regex= + prefer_static_libs=no + preload=no + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + vinfo_number=no + weak_libs= + single_module="${wl}-single_module" + func_infer_tag $base_compile + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -shared) + test "$build_libtool_libs" != yes && \ + func_fatal_configuration "can not build a shared library" + build_old_libs=no + break + ;; + -all-static | -static | -static-libtool-libs) + case $arg in + -all-static) + if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + -static) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + esac + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg="$1" + shift + func_quote_for_eval "$arg" + qarg=$func_quote_for_eval_unquoted_result + func_append libtool_args " $func_quote_for_eval_result" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + func_append compile_command " @OUTPUT@" + func_append finalize_command " @OUTPUT@" + ;; + esac + + case $prev in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + func_append compile_command " @SYMFILE@" + func_append finalize_command " @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols="$arg" + test -f "$arg" \ + || func_fatal_error "symbol file \`$arg' does not exist" + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + framework) + case $host in + *-*-darwin*) + case "$deplibs " in + *" $qarg.ltframework "*) ;; + *) deplibs="$deplibs $qarg.ltframework" # this is fixed later + ;; + esac + ;; + esac + prev= + continue + ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat "$save_arg"` + do +# moreargs="$moreargs $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test "$pic_object" = none && + test "$non_pic_object" = none; then + func_fatal_error "cannot find name of object for \`$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "\`$arg' is not a valid libtool object" + fi + fi + done + else + func_fatal_error "link input file \`$arg' does not exist" + fi + arg=$save_arg + prev= + continue + ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + shrext) + shrext_cmds="$arg" + prev= + continue + ;; + weak) + weak_libs="$weak_libs $arg" + prev= + continue + ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + func_append compile_command " $wl$qarg" + func_append finalize_command " $wl$qarg" + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg="$arg" + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" + func_append finalize_command " $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + func_fatal_error "\`-allow-undefined' must not be used because it is the default" + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + func_fatal_error "more than one -exported-symbols argument is not allowed" + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework) + prev=framework + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + func_append compile_command " $arg" + func_append finalize_command " $arg" + ;; + esac + continue + ;; + + -L*) + func_stripname '-L' '' "$arg" + dir=$func_stripname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + test -z "$absdir" && \ + func_fatal_error "cannot determine absolute directory name of \`$dir'" + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + deplibs="$deplibs System.ltframework" + continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test "X$arg" = "X-lc" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test "X$arg" = "X-lc" && continue + ;; + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + # Darwin uses the -arch flag to determine output architecture. + -model|-arch|-isysroot) + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case "$new_inherited_linker_flags " in + *" $arg "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; + esac + continue + ;; + + -multi_module) + single_module="${wl}-multi_module" + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + func_warning "\`-no-install' is ignored for $host" + func_warning "assuming \`-no-fast-install' instead" + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + func_stripname '-R' '' "$arg" + dir=$func_stripname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -shared) + # The effects of -shared are defined in a previous loop. + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -static | -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -weak) + prev=weak + continue + ;; + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + func_quote_for_eval "$flag" + arg="$arg $wl$func_quote_for_eval_result" + compiler_flags="$compiler_flags $func_quote_for_eval_result" + done + IFS="$save_ifs" + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Wl,*) + func_stripname '-Wl,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + func_quote_for_eval "$flag" + arg="$arg $wl$func_quote_for_eval_result" + compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" + linker_flags="$linker_flags $func_quote_for_eval_result" + done + IFS="$save_ifs" + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # -msg_* for osf cc + -msg_*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + + # -64, -mips[0-9] enable 64-bit mode on the SGI compiler + # -r[0-9][0-9]* specifies the processor on the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler + # +DA*, +DD* enable 64-bit mode on the HP compiler + # -q* pass through compiler args for the IBM compiler + # -m*, -t[45]*, -txscale* pass through architecture-specific + # compiler args for GCC + # -F/path gives path to uninstalled frameworks, gcc on darwin + # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC + # @file GCC response files + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + func_append compile_command " $arg" + func_append finalize_command " $arg" + compiler_flags="$compiler_flags $arg" + continue + ;; + + # Some other compiler flag. + -* | +*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + + *.$objext) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test "$pic_object" = none && + test "$non_pic_object" = none; then + func_fatal_error "cannot find name of object for \`$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "\`$arg' is not a valid libtool object" + fi + fi + ;; + + *.$libext) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + if test "$prev" = dlfiles; then + # This library was specified with -dlopen. + dlfiles="$dlfiles $arg" + prev= + elif test "$prev" = dlprefiles; then + # The library was specified with -dlpreopen. + dlprefiles="$dlprefiles $arg" + prev= + else + deplibs="$deplibs $arg" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + done # argument parsing loop + + test -n "$prev" && \ + func_fatal_help "the \`$prevarg' option requires an argument" + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + func_basename "$output" + outputname="$func_basename_result" + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + func_dirname "$output" "/" "" + output_objdir="$func_dirname_result$objdir" + # Create the object directory. + func_mkdir_p "$output_objdir" + + # Determine the type of output + case $output in + "") + func_fatal_help "you must specify an output file" + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if $opt_duplicate_deps ; then + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + libs="$libs $deplib" + done + + if test "$linkmode" = lib; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if $opt_duplicate_compiler_generated_deps; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; + esac + pre_post_deps="$pre_post_deps $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + + case $linkmode in + lib) + passes="conv dlpreopen link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=no + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + + for pass in $passes; do + # The preopen pass in lib mode reverses $deplibs; put it back here + # so that -L comes before libs that need it for instance... + if test "$linkmode,$pass" = "lib,link"; then + ## FIXME: Find the place where the list is rebuilt in the wrong + ## order, and fix it there properly + tmp_deplibs= + for deplib in $deplibs; do + tmp_deplibs="$deplib $tmp_deplibs" + done + deplibs="$tmp_deplibs" + fi + + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then + case $pass in + dlopen) libs="$dlfiles" ;; + dlpreopen) libs="$dlprefiles" ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test "$linkmode,$pass" = "lib,dlpreopen"; then + # Collect and forward deplibs of preopened libtool libs + for lib in $dlprefiles; do + # Ignore non-libtool-libs + dependency_libs= + case $lib in + *.la) func_source "$lib" ;; + esac + + # Collect preopened libtool deplibs, except any this library + # has declared as weak libs + for deplib in $dependency_libs; do + deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"` + case " $weak_libs " in + *" $deplib_base "*) ;; + *) deplibs="$deplibs $deplib" ;; + esac + done + done + libs="$dlprefiles" + fi + if test "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi + + for deplib in $libs; do + lib= + found=no + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + compiler_flags="$compiler_flags $deplib" + if test "$linkmode" = lib ; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; + esac + fi + fi + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + func_warning "\`-l' is ignored for archives/objects" + continue + fi + func_stripname '-l' '' "$deplib" + name=$func_stripname_result + if test "$linkmode" = lib; then + searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" + else + searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" + fi + for searchdir in $searchdirs; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib="$searchdir/lib${name}${search_ext}" + if test -f "$lib"; then + if test "$search_ext" = ".la"; then + found=yes + else + found=no + fi + break 2 + fi + done + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if func_lalib_p "$lib"; then + library_names= + old_library= + func_source "$lib" + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + func_dirname "$lib" "" "." + ladir="$func_dirname_result" + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + fi + ;; # -l + *.ltframework) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + if test "$linkmode" = lib ; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; + esac + fi + fi + continue + ;; + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + prog) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test "$pass" = scan; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + *) + func_warning "\`-L' is ignored for archives/objects" + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test "$pass" = link; then + func_stripname '-R' '' "$deplib" + dir=$func_stripname_result + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) lib="$deplib" ;; + *.$libext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + # Linking convenience modules into shared libraries is allowed, + # but linking other static libraries is non-portable. + case " $dlpreconveniencelibs " in + *" $deplib "*) ;; + *) + valid_a_lib=no + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=yes + fi + ;; + pass_all) + valid_a_lib=yes + ;; + esac + if test "$valid_a_lib" != yes; then + $ECHO + $ECHO "*** Warning: Trying to link with static lib archive $deplib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because the file extensions .$libext of this argument makes me believe" + $ECHO "*** that it is just a static archive that I should not use here." + else + $ECHO + $ECHO "*** Warning: Linking the shared library $output against the" + $ECHO "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + ;; + esac + continue + ;; + prog) + if test "$pass" != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=yes + continue + ;; + esac # case $deplib + + if test "$found" = yes || test -f "$lib"; then : + else + func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" + fi + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$lib" \ + || func_fatal_error "\`$lib' is not a valid libtool archive" + + func_dirname "$lib" "" "." + ladir="$func_dirname_result" + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + inherited_linker_flags= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + avoidtemprpath= + + + # Read the .la file + func_source "$lib" + + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'` + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; + *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; + esac + done + fi + dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test "$linkmode" != prog && test "$linkmode" != lib; }; then + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" + fi + + if test "$pass" = conv; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + func_fatal_error "cannot find name of link library for \`$lib'" + fi + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + elif test "$linkmode" != prog && test "$linkmode" != lib; then + func_fatal_error "\`$lib' is not a convenience library" + fi + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + if test -z "$linklib"; then + func_fatal_error "cannot find name of link library for \`$lib'" + fi + + # This library was specified with -dlopen. + if test "$pass" = dlopen; then + if test -z "$libdir"; then + func_fatal_error "cannot -dlopen a convenience library: \`$lib'" + fi + if test -z "$dlname" || + test "$dlopen_support" != yes || + test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + dlprefiles="$dlprefiles $lib $dependency_libs" + else + newdlfiles="$newdlfiles $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + func_warning "cannot determine absolute directory name of \`$ladir'" + func_warning "passing it literally to the linker, although it might fail" + abs_ladir="$ladir" + fi + ;; + esac + func_basename "$lib" + laname="$func_basename_result" + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + func_warning "library \`$lib' was moved." + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir="$ladir" + absdir="$abs_ladir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi + fi # $installed = yes + func_stripname 'lib' '.la' "$laname" + name=$func_stripname_result + + # This library was specified with -dlpreopen. + if test "$pass" = dlpreopen; then + if test -z "$libdir" && test "$linkmode" = prog; then + func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" + fi + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test "$linkmode" = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test "$linkmode" = prog && test "$pass" != link; then + newlib_search_path="$newlib_search_path $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + esac + # Need to link against all dependency_libs? + if test "$linkalldeplibs" = yes; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { { test "$prefer_static_libs" = no || + test "$prefer_static_libs,$installed" = "built,yes"; } || + test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath:" in + *"$absdir:"*) ;; + *) temp_rpath="$temp_rpath$absdir:" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test "$use_static_libs" = built && test "$installed" = yes; then + use_static_libs=no + fi + if test -n "$library_names" && + { test "$use_static_libs" = no || test -z "$old_library"; }; then + case $host in + *cygwin* | *mingw*) + # No point in relinking DLLs because paths are not encoded + notinst_deplibs="$notinst_deplibs $lib" + need_relink=no + ;; + *) + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + ;; + esac + # This is a shared library + + # Warn about portability, can't link against -module's on some + # systems (darwin). Don't bleat about dlopened modules though! + dlopenmodule="" + for dlpremoduletest in $dlprefiles; do + if test "X$dlpremoduletest" = "X$lib"; then + dlopenmodule="$dlpremoduletest" + break + fi + done + if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then + $ECHO + if test "$linkmode" = prog; then + $ECHO "*** Warning: Linking the executable $output against the loadable module" + else + $ECHO "*** Warning: Linking the shared library $output against the loadable module" + fi + $ECHO "*** $linklib is not portable!" + fi + if test "$linkmode" = lib && + test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + shift + realname="$1" + shift + libname=`eval "\\$ECHO \"$libname_spec\""` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname="$dlname" + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw*) + func_arith $current - $age + major=$func_arith_result + versuffix="-$major" + ;; + esac + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + func_basename "$soroot" + soname="$func_basename_result" + func_stripname 'lib' '.dll' "$soname" + newlib=libimp-$func_stripname_result.a + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + func_verbose "extracting exported symbol list from \`$soname'" + func_execute_cmds "$extract_expsyms_cmds" 'exit $?' + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + func_verbose "generating import library for \`$soname'" + func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test "$linkmode" = prog || test "$mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; then + add="$dir/$linklib" + case $host in + *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; + *-*-sysv4*uw2*) add_dir="-L$dir" ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir="-L$dir" ;; + *-*-darwin* ) + # if the lib is a (non-dlopened) module then we can not + # link against it, someone is ignoring the earlier warnings + if /usr/bin/file -L $add 2> /dev/null | + $GREP ": [^:]* bundle" >/dev/null ; then + if test "X$dlopenmodule" != "X$lib"; then + $ECHO "*** Warning: lib $linklib is a module, not a shared library" + if test -z "$old_library" ; then + $ECHO + $ECHO "*** And there doesn't seem to be a static archive available" + $ECHO "*** The link will probably fail, sorry" + else + add="$dir/$old_library" + fi + elif test -n "$old_library"; then + add="$dir/$old_library" + fi + fi + esac + elif test "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes && + test "$hardcode_direct_absolute" = no; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + func_fatal_configuration "unsupported hardcode properties" + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + if test "$linkmode" = prog; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test "$hardcode_direct" != yes && + test "$hardcode_minus_L" != yes && + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + fi + fi + + if test "$linkmode" = prog || test "$mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes && + test "$hardcode_direct_absolute" = no; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add="-l$name" + elif test "$hardcode_automatic" = yes; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib" ; then + add="$inst_prefix_dir$libdir/$linklib" + else + add="$libdir/$linklib" + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + fi + + if test "$linkmode" = prog; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test "$linkmode" = prog; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + $ECHO + $ECHO "*** Warning: This system can not link to static lib archive $lib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + $ECHO "*** But as you try to build a module library, libtool will still create " + $ECHO "*** a static module, that should work as long as the dlopening application" + $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + $ECHO + $ECHO "*** However, this would only work if libtool was able to extract symbol" + $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" + $ECHO "*** not find such a program. So, this module is probably useless." + $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test "$linkmode" = lib; then + if test -n "$dependency_libs" && + { test "$hardcode_into_libs" != yes || + test "$build_old_libs" = yes || + test "$link_static" = yes; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) func_stripname '-R' '' "$libdir" + temp_xrpath=$func_stripname_result + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + newlib_search_path="$newlib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + + if test "$link_all_deplibs" != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + case $deplib in + -L*) path="$deplib" ;; + *.la) + func_dirname "$deplib" "" "." + dir="$func_dirname_result" + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + func_warning "cannot determine absolute directory name of \`$dir'" + absdir="$dir" + fi + ;; + esac + if $GREP "^installed=no" $deplib > /dev/null; then + case $host in + *-*-darwin*) + depdepl= + eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names" ; then + for tmp in $deplibrary_names ; do + depdepl=$tmp + done + if test -f "$absdir/$objdir/$depdepl" ; then + depdepl="$absdir/$objdir/$depdepl" + darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + if test -z "$darwin_install_name"; then + darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + fi + compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" + linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" + path= + fi + fi + ;; + *) + path="-L$absdir/$objdir" + ;; + esac + else + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "\`$deplib' is not a valid libtool archive" + test "$absdir" != "$libdir" && \ + func_warning "\`$deplib' seems to be moved" + + path="-L$absdir" + fi + ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + if test "$pass" = link; then + if test "$linkmode" = "prog"; then + compile_deplibs="$new_inherited_linker_flags $compile_deplibs" + finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" + else + compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + fi + fi + dependency_libs="$newdependency_libs" + if test "$pass" = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test "$pass" != dlopen; then + if test "$pass" != conv; then + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + newlib_search_path= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_deplibs" + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test "$linkmode" = prog; then + dlfiles="$newdlfiles" + fi + if test "$linkmode" = prog || test "$linkmode" = lib; then + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + func_warning "\`-dlopen' is ignored for archives" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "\`-l' and \`-L' are ignored for archives" ;; + esac + + test -n "$rpath" && \ + func_warning "\`-rpath' is ignored for archives" + + test -n "$xrpath" && \ + func_warning "\`-R' is ignored for archives" + + test -n "$vinfo" && \ + func_warning "\`-version-info/-version-number' is ignored for archives" + + test -n "$release" && \ + func_warning "\`-release' is ignored for archives" + + test -n "$export_symbols$export_symbols_regex" && \ + func_warning "\`-export-symbols' is ignored for archives" + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case $outputname in + lib*) + func_stripname 'lib' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + test "$module" = no && \ + func_fatal_help "libtool library \`$output' must begin with \`lib'" + + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + func_stripname '' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + func_stripname '' '.la' "$outputname" + libname=$func_stripname_result + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" + else + $ECHO + $ECHO "*** Warning: Linking the shared library $output against the non-libtool" + $ECHO "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + test "$dlself" != no && \ + func_warning "\`-dlopen self' is ignored for libtool libraries" + + set dummy $rpath + shift + test "$#" -gt 1 && \ + func_warning "ignoring multiple \`-rpath's for a libtool library" + + install_libdir="$1" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + # Some compilers have problems with a `.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + test -n "$vinfo" && \ + func_warning "\`-version-info/-version-number' is ignored for convenience libraries" + + test -n "$release" && \ + func_warning "\`-release' is ignored for convenience libraries" + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + shift + IFS="$save_ifs" + + test -n "$7" && \ + func_fatal_help "too many parameters to \`-version-info'" + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major="$1" + number_minor="$2" + number_revision="$3" + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # which has an extra 1 added just for fun + # + case $version_type in + darwin|linux|osf|windows|none) + func_arith $number_major + $number_minor + current=$func_arith_result + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + func_arith $number_major + $number_minor + current=$func_arith_result + age="$number_minor" + revision="$number_minor" + lt_irix_increment=no + ;; + esac + ;; + no) + current="$1" + revision="$2" + age="$3" + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "CURRENT \`$current' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + case $revision in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "REVISION \`$revision' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + case $age in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "AGE \`$age' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + if test "$age" -gt "$current"; then + func_error "AGE \`$age' is greater than the current interface number \`$current'" + func_fatal_error "\`$vinfo' is not valid version information" + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + func_arith $current - $age + major=.$func_arith_result + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + func_arith $current + 1 + minor_current=$func_arith_result + xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current" + ;; + + irix | nonstopux) + if test "X$lt_irix_increment" = "Xno"; then + func_arith $current - $age + else + func_arith $current - $age + 1 + fi + major=$func_arith_result + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring="$verstring_prefix$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test "$loop" -ne 0; do + func_arith $revision - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring="$verstring_prefix$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + func_arith $current - $age + major=.$func_arith_result + versuffix="$major.$age.$revision" + ;; + + osf) + func_arith $current - $age + major=.$func_arith_result + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test "$loop" -ne 0; do + func_arith $current - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + qnx) + major=".$current" + versuffix=".$current" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + func_arith $current - $age + major=$func_arith_result + versuffix="-$major" + ;; + + *) + func_fatal_configuration "unknown library version type \`$version_type'" + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring="0.0" + ;; + esac + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + func_warning "undefined symbols not allowed in $host shared libraries" + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + + fi + + func_generate_dlsyms "$libname" "$libname" "yes" + libobjs="$libobjs $symfileobj" + test "X$libobjs" = "X " && libobjs= + + if test "$mode" != relink; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$ECHO "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + if test "X$precious_files_regex" != "X"; then + if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + removelist="$removelist $p" + ;; + *) ;; + esac + done + test -n "$removelist" && \ + func_show_eval "${RM}r \$removelist" + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + #for path in $notinst_path; do + # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"` + # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"` + # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"` + #done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles="$dlfiles" + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) dlfiles="$dlfiles $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles="$dlprefiles" + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) dlprefiles="$dlprefiles $lib" ;; + esac + done + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs System.ltframework" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test "$build_libtool_need_lc" = "yes"; then + deplibs="$deplibs -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $opt_dry_run || $RM conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null | + $GREP " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | + $SED -e 10q | + $EGREP "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $ECHO + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $ECHO "*** with $libname but no candidates were found. (...for file magic test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a file magic. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + for a_deplib in $deplibs; do + case $a_deplib in + -l*) + func_stripname -l '' "$a_deplib" + name=$func_stripname_result + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval "\\$ECHO \"$libname_spec\""` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \ + $EGREP "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $ECHO + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a regex pattern. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \ + -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"` + done + fi + if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' | + $GREP . >/dev/null; then + $ECHO + if test "X$deplibs_check_method" = "Xnone"; then + $ECHO "*** Warning: inter-library dependencies are not supported in this platform." + else + $ECHO "*** Warning: inter-library dependencies are not known to be supported." + fi + $ECHO "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library with the System framework + newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'` + ;; + esac + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + $ECHO + $ECHO "*** Warning: libtool could not satisfy all declared inter-library" + $ECHO "*** dependencies of module $libname. Therefore, libtool will create" + $ECHO "*** a static module, that should work as long as the dlopening" + $ECHO "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + $ECHO + $ECHO "*** However, this would only work if libtool was able to extract symbol" + $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" + $ECHO "*** not find such a program. So, this module is probably useless." + $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + $ECHO "*** The inter-library dependencies that have been dropped here will be" + $ECHO "*** automatically added whenever a program is linked with this library" + $ECHO "*** or is declared to -dlopen it." + + if test "$allow_undefined" = no; then + $ECHO + $ECHO "*** Since this library must not contain undefined symbols," + $ECHO "*** because either the platform does not support them or" + $ECHO "*** it was explicitly requested with -no-undefined," + $ECHO "*** libtool will only create a static version of it." + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + case $host in + *-*-darwin*) + newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + deplibs="$new_libs" + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + if test -n "$hardcode_libdir_flag_spec_ld"; then + eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" + else + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + shift + realname="$1" + shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib="$output_objdir/$realname" + linknames= + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + test "X$libobjs" = "X " && libobjs= + + delfiles= + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" + export_symbols="$output_objdir/$libname.uexp" + delfiles="$delfiles $export_symbols" + fi + + orig_export_symbols= + case $host_os in + cygwin* | mingw*) + if test -n "$export_symbols" && test -z "$export_symbols_regex"; then + # exporting using user supplied symfile + if test "x`$SED 1q $export_symbols`" != xEXPORTS; then + # and it's NOT already a .def file. Must figure out + # which of the given symbols are data symbols and tag + # them as such. So, trigger use of export_symbols_cmds. + # export_symbols gets reassigned inside the "prepare + # the list of exported symbols" if statement, so the + # include_expsyms logic still works. + orig_export_symbols="$export_symbols" + export_symbols= + always_export_symbols=yes + fi + fi + ;; + esac + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + func_verbose "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $opt_dry_run || $RM $export_symbols + cmds=$export_symbols_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + func_len " $cmd" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + func_show_eval "$cmd" 'exit $?' + skipped_export=false + else + # The command line is too long to execute in one step. + func_verbose "using reloadable object file for export list..." + skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break + fi + done + IFS="$save_ifs" + if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols="$export_symbols" + test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" + $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' + fi + + if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + tmp_deplibs="$tmp_deplibs $test_deplib" + ;; + esac + done + deplibs="$tmp_deplibs" + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec" && + test "$compiler_needs_object" = yes && + test -z "$libobjs"; then + # extract the archives, so we have objects to list. + # TODO: could optimize this to just extract one archive. + whole_archive_flag_spec= + fi + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + else + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + libobjs="$libobjs $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$mode" = relink; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test "X$skipped_export" != "X:" && + func_len " $test_cmds" && + len=$func_len_result && + test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise + # or, if using GNU ld and skipped_export is not :, use a linker + # script. + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + output_la=`$ECHO "X$output" | $Xsed -e "$basename"` + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + last_robj= + k=1 + + if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then + output=${output_objdir}/${output_la}.lnkscript + func_verbose "creating GNU ld script: $output" + $ECHO 'INPUT (' > $output + for obj in $save_libobjs + do + $ECHO "$obj" >> $output + done + $ECHO ')' >> $output + delfiles="$delfiles $output" + elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then + output=${output_objdir}/${output_la}.lnk + func_verbose "creating linker input file list: $output" + : > $output + set x $save_libobjs + shift + firstobj= + if test "$compiler_needs_object" = yes; then + firstobj="$1 " + shift + fi + for obj + do + $ECHO "$obj" >> $output + done + delfiles="$delfiles $output" + output=$firstobj\"$file_list_spec$output\" + else + if test -n "$save_libobjs"; then + func_verbose "creating reloadable object files..." + output=$output_objdir/$output_la-${k}.$objext + eval test_cmds=\"$reload_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + if test "X$objlist" = X || + test "$len" -lt "$max_cmd_len"; then + func_append objlist " $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test "$k" -eq 1 ; then + # The first file doesn't have a previous command to add. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\" + fi + last_robj=$output_objdir/$output_la-${k}.$objext + func_arith $k + 1 + k=$func_arith_result + output=$output_objdir/$output_la-${k}.$objext + objlist=$obj + func_len " $last_robj" + func_arith $len0 + $func_len_result + len=$func_arith_result + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + if test -n "$last_robj"; then + eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" + fi + delfiles="$delfiles $output" + + else + output= + fi + + if ${skipped_export-false}; then + func_verbose "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $opt_dry_run || $RM $export_symbols + libobjs=$output + # Append the command to create the export file. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + fi + + test -n "$save_libobjs" && + func_verbose "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + $opt_silent || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + + if test -n "$export_symbols_regex" && ${skipped_export-false}; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + + if ${skipped_export-false}; then + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols="$export_symbols" + test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" + $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' + fi + + if test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + fi + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + fi + + if test -n "$delfiles"; then + # Append the command to remove temporary files to $cmds. + eval cmds=\"\$cmds~\$RM $delfiles\" + fi + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $dlprefiles + libobjs="$libobjs $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $opt_silent || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + func_show_eval '${RM}r "$gentop"' + fi + fi + + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + func_warning "\`-dlopen' is ignored for objects" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "\`-l' and \`-L' are ignored for objects" ;; + esac + + test -n "$rpath" && \ + func_warning "\`-rpath' is ignored for objects" + + test -n "$xrpath" && \ + func_warning "\`-R' is ignored for objects" + + test -n "$vinfo" && \ + func_warning "\`-version-info' is ignored for objects" + + test -n "$release" && \ + func_warning "\`-release' is ignored for objects" + + case $output in + *.lo) + test -n "$objs$old_deplibs" && \ + func_fatal_error "cannot build library object \`$output' from non-libtool objects" + + libobj=$output + func_lo2o "$libobj" + obj=$func_lo2o_result + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $opt_dry_run || $RM $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec and hope we can get by with + # turning comma into space.. + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" + reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` + else + gentop="$output_objdir/${obj}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + func_execute_cmds "$reload_cmds" 'exit $?' + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + func_execute_cmds "$reload_cmds" 'exit $?' + fi + + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) func_stripname '' '.exe' "$output" + output=$func_stripname_result.exe;; + esac + test -n "$vinfo" && \ + func_warning "\`-version-info' is ignored for programs" + + test -n "$release" && \ + func_warning "\`-release' is ignored for programs" + + test "$preload" = yes \ + && test "$dlopen_support" = unknown \ + && test "$dlopen_self" = unknown \ + && test "$dlopen_self_static" = unknown && \ + func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` + finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` + ;; + esac + + case $host in + *-*-darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + # But is supposedly fixed on 10.4 or later (yay!). + if test "$tagname" = CXX ; then + case ${MACOSX_DEPLOYMENT_TARGET-10.0} in + 10.[0123]) + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + ;; + esac + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + compile_deplibs="$new_libs" + + + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + func_generate_dlsyms "$outputname" "@PROGRAM@" "no" + + # template prelinking step + if test -n "$prelink_cmds"; then + func_execute_cmds "$prelink_cmds" 'exit $?' + fi + + wrappers_required=yes + case $host in + *cygwin* | *mingw* ) + if test "$build_libtool_libs" != yes; then + wrappers_required=no + fi + ;; + *) + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + wrappers_required=no + fi + ;; + esac + if test "$wrappers_required" = no; then + # Replace the output file specification. + compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + exit_status=0 + func_show_eval "$link_command" 'exit_status=$?' + + # Delete the generated files. + if test -f "$output_objdir/${outputname}S.${objext}"; then + func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' + fi + + exit $exit_status + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$no_install" = yes; then + # We don't need to create a wrapper script. + link_command="$compile_var$compile_command$compile_rpath" + # Replace the output file specification. + link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $opt_dry_run || $RM $output + # Link the executable and exit + func_show_eval "$link_command" 'exit $?' + exit $EXIT_SUCCESS + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + func_warning "this platform does not like uninstalled shared libraries" + func_warning "\`$output' will be relinked during installation" + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname + + func_show_eval "$link_command" 'exit $?' + + # Now create the wrapper script. + func_verbose "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $ECHO for shipping. + if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then + case $progpath in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; + *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; + esac + qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if not in dry run mode. + $opt_dry_run || { + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) func_stripname '' '.exe' "$output" + output=$func_stripname_result ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + func_stripname '' '.exe' "$outputname" + outputname=$func_stripname_result ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + func_dirname_and_basename "$output" "" "." + output_name=$func_basename_result + output_path=$func_dirname_result + cwrappersource="$output_path/$objdir/lt-$output_name.c" + cwrapper="$output_path/$output_name.exe" + $RM $cwrappersource $cwrapper + trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + func_emit_cwrapperexe_src > $cwrappersource + + # we should really use a build-platform specific compiler + # here, but OTOH, the wrappers (shell script and this C one) + # are only useful if you want to execute the "real" binary. + # Since the "real" binary is built for $host, then this + # wrapper might as well be built for $host, too. + $opt_dry_run || { + $LTCC $LTCFLAGS -o $cwrapper $cwrappersource + $STRIP $cwrapper + } + + # Now, create the wrapper script for func_source use: + func_ltwrapper_scriptname $cwrapper + $RM $func_ltwrapper_scriptname_result + trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 + $opt_dry_run || { + # note: this script will not be executed, so do not chmod. + if test "x$build" = "x$host" ; then + $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result + else + func_emit_wrapper no > $func_ltwrapper_scriptname_result + fi + } + ;; + * ) + $RM $output + trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 + + func_emit_wrapper no > $output + chmod +x $output + ;; + esac + } + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save $symfileobj" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$old_deplibs $non_pic_objects" + if test "$preload" = yes && test -f "$symfileobj"; then + oldobjs="$oldobjs $symfileobj" + fi + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $addlibs + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + cmds=$old_archive_from_new_cmds + else + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $dlprefiles + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + func_basename "$obj" + $ECHO "$func_basename_result" + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $ECHO "copying selected object files to avoid basename conflicts..." + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + func_mkdir_p "$gentop" + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + func_basename "$obj" + objbase="$func_basename_result" + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + func_arith $counter + 1 + counter=$func_arith_result + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + oldobjs="$oldobjs $gentop/$newobj" + ;; + *) oldobjs="$oldobjs $obj" ;; + esac + done + fi + eval cmds=\"$old_archive_cmds\" + + func_len " $cmds" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + func_verbose "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + oldobjs= + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + eval test_cmds=\"$old_archive_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + for obj in $save_oldobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + func_append objlist " $obj" + if test "$len" -lt "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj" ; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" + objlist= + len=$len0 + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test "X$oldobjs" = "X" ; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + func_execute_cmds "$cmds" 'exit $?' + done + + test -n "$generated" && \ + func_show_eval "${RM}r$generated" + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + func_verbose "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` + if test "$hardcode_automatic" = yes ; then + relink_command= + fi + + # Only create the output if not a dry run. + $opt_dry_run || { + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + func_basename "$deplib" + name="$func_basename_result" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "\`$deplib' is not a valid libtool archive" + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + + for lib in $dlfiles; do + case $lib in + *.la) + func_basename "$lib" + name="$func_basename_result" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "\`$lib' is not a valid libtool archive" + newdlfiles="$newdlfiles $libdir/$name" + ;; + *) newdlfiles="$newdlfiles $lib" ;; + esac + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + *.la) + # Only pass preopened files to the pseudo-archive (for + # eventual linking with the app. that links it) if we + # didn't already link the preopened objects directly into + # the library: + func_basename "$lib" + name="$func_basename_result" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "\`$lib' is not a valid libtool archive" + newdlprefiles="$newdlprefiles $libdir/$name" + ;; + esac + done + dlprefiles="$newdlprefiles" + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlfiles="$newdlfiles $abs" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlprefiles="$newdlprefiles $abs" + done + dlprefiles="$newdlprefiles" + fi + $RM $output + # place dlname in correct position for cygwin + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + esac + $ECHO > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Linker flags that can not go in dependency_libs. +inherited_linker_flags='$new_inherited_linker_flags' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Names of additional weak libraries provided by this library +weak_library_names='$weak_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no && test "$need_relink" = yes; then + $ECHO >> $output "\ +relink_command=\"$relink_command\"" + fi + done + } + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' + ;; + esac + exit $EXIT_SUCCESS +} + +{ test "$mode" = link || test "$mode" = relink; } && + func_mode_link ${1+"$@"} + + +# func_mode_uninstall arg... +func_mode_uninstall () +{ + $opt_debug + RM="$nonopt" + files= + rmforce= + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case $arg in + -f) RM="$RM $arg"; rmforce=yes ;; + -*) RM="$RM $arg" ;; + *) files="$files $arg" ;; + esac + done + + test -z "$RM" && \ + func_fatal_help "you must specify an RM program" + + rmdirs= + + origobjdir="$objdir" + for file in $files; do + func_dirname "$file" "" "." + dir="$func_dirname_result" + if test "X$dir" = X.; then + objdir="$origobjdir" + else + objdir="$dir/$origobjdir" + fi + func_basename "$file" + name="$func_basename_result" + test "$mode" = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test "$mode" = clean; then + case " $rmdirs " in + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if { test -L "$file"; } >/dev/null 2>&1 || + { test -h "$file"; } >/dev/null 2>&1 || + test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif test "$rmforce" = yes; then + continue + fi + + rmfiles="$file" + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if func_lalib_p "$file"; then + func_source $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + + case "$mode" in + clean) + case " $library_names " in + # " " in the beginning catches empty $dlname + *" $dlname "*) ;; + *) rmfiles="$rmfiles $objdir/$dlname" ;; + esac + test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + ;; + uninstall) + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if func_lalib_p "$file"; then + + # Read the .lo file + func_source $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" && + test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" && + test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi + fi + ;; + + *) + if test "$mode" = clean ; then + noexename=$name + case $file in + *.exe) + func_stripname '' '.exe' "$file" + file=$func_stripname_result + func_stripname '' '.exe' "$name" + noexename=$func_stripname_result + # $file with .exe has already been added to rmfiles, + # add $file without .exe + rmfiles="$rmfiles $file" + ;; + esac + # Do a test to see if this is a libtool program. + if func_ltwrapper_p "$file"; then + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + relink_command= + func_source $func_ltwrapper_scriptname_result + rmfiles="$rmfiles $func_ltwrapper_scriptname_result" + else + relink_command= + func_source $dir/$noexename + fi + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + if test "X$noexename" != "X$name" ; then + rmfiles="$rmfiles $objdir/lt-${noexename}.c" + fi + fi + fi + ;; + esac + func_show_eval "$RM $rmfiles" 'exit_status=1' + done + objdir="$origobjdir" + + # Try to remove the ${objdir}s in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + func_show_eval "rmdir $dir >/dev/null 2>&1" + fi + done + + exit $exit_status +} + +{ test "$mode" = uninstall || test "$mode" = clean; } && + func_mode_uninstall ${1+"$@"} + +test -z "$mode" && { + help="$generic_help" + func_fatal_help "you must specify a MODE" +} + +test -z "$exec_cmd" && \ + func_fatal_help "invalid operation mode \`$mode'" + +if test -n "$exec_cmd"; then + eval exec "$exec_cmd" + exit $EXIT_FAILURE +fi + +exit $exit_status + + +# The TAGs below are defined such that we never get into a situation +# in which we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: +# vi:sw=2 + diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/macho.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/macho.c new file mode 100644 index 0000000..b43ea22 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/macho.c @@ -0,0 +1,1418 @@ +/* macho.c -- Get debug data from an Mach-O file for backtraces. + Copyright (C) 2012-2016 Free Software Foundation, Inc. + Written by John Colanduoni. + + Pending upstream pull request: + https://github.com/ianlancetaylor/libbacktrace/pull/2 + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +/* We can't use autotools to detect the pointer width of our program because + we may be building a fat Mach-O file containing both 32-bit and 64-bit + variants. However Mach-O runs a limited set of platforms so detection + via preprocessor is not difficult. */ + +#if defined(__MACH__) +#if defined(__LP64__) +#define BACKTRACE_BITS 64 +#else +#define BACKTRACE_BITS 32 +#endif +#else +#error Attempting to build Mach-O support on incorrect platform +#endif + +#if defined(__x86_64__) +#define NATIVE_CPU_TYPE CPU_TYPE_X86_64 +#elif defined(__i386__) +#define NATIVE_CPU_TYPE CPU_TYPE_X86 +#elif defined(__aarch64__) +#define NATIVE_CPU_TYPE CPU_TYPE_ARM64 +#elif defined(__arm__) +#define NATIVE_CPU_TYPE CPU_TYPE_ARM +#else +#error Could not detect native Mach-O cpu_type_t +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +struct macho_commands_view +{ + struct backtrace_view view; + uint32_t commands_count; + uint32_t commands_total_size; + int bytes_swapped; + size_t base_offset; +}; + +enum debug_section +{ + DEBUG_INFO, + DEBUG_LINE, + DEBUG_ABBREV, + DEBUG_RANGES, + DEBUG_STR, + DEBUG_MAX +}; + +static const char *const debug_section_names[DEBUG_MAX] = + { + "__debug_info", + "__debug_line", + "__debug_abbrev", + "__debug_ranges", + "__debug_str" + }; + +struct found_dwarf_section +{ + uint32_t file_offset; + uintptr_t file_size; + const unsigned char *data; +}; + +/* Mach-O symbols don't have a length. As a result we have to infer it + by sorting the symbol addresses for each image and recording the + memory range attributed to each image. */ +struct macho_symbol +{ + uintptr_t addr; + size_t size; + const char *name; +}; + +struct macho_syminfo_data +{ + struct macho_syminfo_data *next; + struct macho_symbol *symbols; + size_t symbol_count; + uintptr_t min_addr; + uintptr_t max_addr; +}; + +uint16_t +macho_file_to_host_u16 (int file_bytes_swapped, uint16_t input) +{ + if (file_bytes_swapped) + return (input >> 8) | (input << 8); + else + return input; +} + +uint32_t +macho_file_to_host_u32 (int file_bytes_swapped, uint32_t input) +{ + if (file_bytes_swapped) + { + return ((input >> 24) & 0x000000FF) + | ((input >> 8) & 0x0000FF00) + | ((input << 8) & 0x00FF0000) + | ((input << 24) & 0xFF000000); + } + else + { + return input; + } +} + +uint64_t +macho_file_to_host_u64 (int file_bytes_swapped, uint64_t input) +{ + if (file_bytes_swapped) + { + return macho_file_to_host_u32 (file_bytes_swapped, + (uint32_t) (input >> 32)) + | (((uint64_t) macho_file_to_host_u32 (file_bytes_swapped, + (uint32_t) input)) << 32); + } + else + { + return input; + } +} + +#if BACKTRACE_BITS == 64 +#define macho_file_to_host_usize macho_file_to_host_u64 +typedef struct mach_header_64 mach_header_native_t; +#define LC_SEGMENT_NATIVE LC_SEGMENT_64 +typedef struct segment_command_64 segment_command_native_t; +typedef struct nlist_64 nlist_native_t; +typedef struct section_64 section_native_t; +#else /* BACKTRACE_BITS == 32 */ +#define macho_file_to_host_usize macho_file_to_host_u32 +typedef struct mach_header mach_header_native_t; +#define LC_SEGMENT_NATIVE LC_SEGMENT +typedef struct segment_command segment_command_native_t; +typedef struct nlist nlist_native_t; +typedef struct section section_native_t; +#endif + +// Gets a view into a Mach-O image, taking any slice offset into account +int +macho_get_view (struct backtrace_state *state, int descriptor, + off_t offset, size_t size, + backtrace_error_callback error_callback, + void *data, struct macho_commands_view *commands_view, + struct backtrace_view *view) +{ + return backtrace_get_view (state, descriptor, + commands_view->base_offset + offset, size, + error_callback, data, view); +} + +int +macho_get_commands (struct backtrace_state *state, int descriptor, + backtrace_error_callback error_callback, + void *data, struct macho_commands_view *commands_view, + int *incompatible) +{ + int ret = 0; + int is_fat = 0; + struct backtrace_view file_header_view; + int file_header_view_valid = 0; + struct backtrace_view fat_archs_view; + int fat_archs_view_valid = 0; + const mach_header_native_t *file_header; + uint64_t commands_offset; + + *incompatible = 0; + + if (!backtrace_get_view (state, descriptor, 0, sizeof (mach_header_native_t), + error_callback, data, &file_header_view)) + goto end; + file_header_view_valid = 1; + + switch (*(uint32_t *) file_header_view.data) + { + case MH_MAGIC: + if (BACKTRACE_BITS == 32) + commands_view->bytes_swapped = 0; + else + { + *incompatible = 1; + goto end; + } + break; + case MH_CIGAM: + if (BACKTRACE_BITS == 32) + commands_view->bytes_swapped = 1; + else + { + *incompatible = 1; + goto end; + } + break; + case MH_MAGIC_64: + if (BACKTRACE_BITS == 64) + commands_view->bytes_swapped = 0; + else + { + *incompatible = 1; + goto end; + } + break; + case MH_CIGAM_64: + if (BACKTRACE_BITS == 64) + commands_view->bytes_swapped = 1; + else + { + *incompatible = 1; + goto end; + } + break; + case FAT_MAGIC: + is_fat = 1; + commands_view->bytes_swapped = 0; + break; + case FAT_CIGAM: + is_fat = 1; + commands_view->bytes_swapped = 1; + break; + default: + goto end; + } + + if (is_fat) + { + uint32_t native_slice_offset; + size_t archs_total_size; + uint32_t arch_count; + const struct fat_header *fat_header; + const struct fat_arch *archs; + uint32_t i; + + fat_header = file_header_view.data; + arch_count = + macho_file_to_host_u32 (commands_view->bytes_swapped, + fat_header->nfat_arch); + + archs_total_size = arch_count * sizeof (struct fat_arch); + + if (!backtrace_get_view (state, descriptor, sizeof (struct fat_header), + archs_total_size, error_callback, + data, &fat_archs_view)) + goto end; + fat_archs_view_valid = 1; + + native_slice_offset = 0; + archs = fat_archs_view.data; + for (i = 0; i < arch_count; i++) + { + const struct fat_arch *raw_arch = archs + i; + int cpu_type = + (int) macho_file_to_host_u32 (commands_view->bytes_swapped, + (uint32_t) raw_arch->cputype); + + if (cpu_type == NATIVE_CPU_TYPE) + { + native_slice_offset = + macho_file_to_host_u32 (commands_view->bytes_swapped, + raw_arch->offset); + + break; + } + } + + if (native_slice_offset == 0) + { + *incompatible = 1; + goto end; + } + + backtrace_release_view (state, &file_header_view, error_callback, data); + file_header_view_valid = 0; + if (!backtrace_get_view (state, descriptor, native_slice_offset, + sizeof (mach_header_native_t), error_callback, + data, &file_header_view)) + goto end; + file_header_view_valid = 1; + + // The endianess of the slice may be different than the fat image + switch (*(uint32_t *) file_header_view.data) + { + case MH_MAGIC: + if (BACKTRACE_BITS == 32) + commands_view->bytes_swapped = 0; + else + goto end; + break; + case MH_CIGAM: + if (BACKTRACE_BITS == 32) + commands_view->bytes_swapped = 1; + else + goto end; + break; + case MH_MAGIC_64: + if (BACKTRACE_BITS == 64) + commands_view->bytes_swapped = 0; + else + goto end; + break; + case MH_CIGAM_64: + if (BACKTRACE_BITS == 64) + commands_view->bytes_swapped = 1; + else + goto end; + break; + default: + goto end; + } + + commands_view->base_offset = native_slice_offset; + } + else + commands_view->base_offset = 0; + + file_header = file_header_view.data; + commands_view->commands_count = + macho_file_to_host_u32 (commands_view->bytes_swapped, + file_header->ncmds); + commands_view->commands_total_size = + macho_file_to_host_u32 (commands_view->bytes_swapped, + file_header->sizeofcmds); + commands_offset = + commands_view->base_offset + sizeof (mach_header_native_t); + + if (!backtrace_get_view (state, descriptor, commands_offset, + commands_view->commands_total_size, error_callback, + data, &commands_view->view)) + goto end; + + ret = 1; + +end: + if (file_header_view_valid) + backtrace_release_view (state, &file_header_view, error_callback, data); + if (fat_archs_view_valid) + backtrace_release_view (state, &fat_archs_view, error_callback, data); + return ret; +} + +int +macho_get_uuid (struct backtrace_state *state ATTRIBUTE_UNUSED, + int descriptor ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, + void *data, struct macho_commands_view *commands_view, + uuid_t *uuid) +{ + size_t offset = 0; + uint32_t i = 0; + + for (i = 0; i < commands_view->commands_count; i++) + { + const struct load_command *raw_command; + struct load_command command; + + if (offset + sizeof (struct load_command) + > commands_view->commands_total_size) + { + error_callback (data, + "executable file contains out of range command offset", + 0); + return 0; + } + + raw_command = + commands_view->view.data + offset; + command.cmd = macho_file_to_host_u32 (commands_view->bytes_swapped, + raw_command->cmd); + command.cmdsize = macho_file_to_host_u32 (commands_view->bytes_swapped, + raw_command->cmdsize); + + if (command.cmd == LC_UUID) + { + const struct uuid_command *uuid_command; + + if (offset + sizeof (struct uuid_command) + > commands_view->commands_total_size) + { + error_callback (data, + "executable file contains out of range command offset", + 0); + return 0; + } + + uuid_command = + (struct uuid_command *) raw_command; + memcpy (uuid, uuid_command->uuid, sizeof (uuid_t)); + return 1; + } + + offset += command.cmdsize; + } + + error_callback (data, "executable file is missing an identifying UUID", 0); + return 0; +} + +/* Returns the base address of a Mach-O image, as encoded in the file header. + * WARNING: This does not take ASLR into account, which is ubiquitous on recent + * Darwin platforms. + */ +int +macho_get_addr_range (struct backtrace_state *state ATTRIBUTE_UNUSED, + int descriptor ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, + void *data, struct macho_commands_view *commands_view, + uintptr_t *base_address, uintptr_t *max_address) +{ + size_t offset = 0; + int found_text = 0; + uint32_t i = 0; + + *max_address = 0; + + for (i = 0; i < commands_view->commands_count; i++) + { + const struct load_command *raw_command; + struct load_command command; + + if (offset + sizeof (struct load_command) + > commands_view->commands_total_size) + { + error_callback (data, + "executable file contains out of range command offset", + 0); + return 0; + } + + raw_command = commands_view->view.data + offset; + command.cmd = macho_file_to_host_u32 (commands_view->bytes_swapped, + raw_command->cmd); + command.cmdsize = macho_file_to_host_u32 (commands_view->bytes_swapped, + raw_command->cmdsize); + + if (command.cmd == LC_SEGMENT_NATIVE) + { + const segment_command_native_t *raw_segment; + uintptr_t segment_vmaddr; + uintptr_t segment_vmsize; + uintptr_t segment_maxaddr; + uintptr_t text_fileoff; + + if (offset + sizeof (segment_command_native_t) + > commands_view->commands_total_size) + { + error_callback (data, + "executable file contains out of range command offset", + 0); + return 0; + } + + raw_segment = (segment_command_native_t *) raw_command; + + segment_vmaddr = macho_file_to_host_usize ( + commands_view->bytes_swapped, raw_segment->vmaddr); + segment_vmsize = macho_file_to_host_usize ( + commands_view->bytes_swapped, raw_segment->vmsize); + segment_maxaddr = segment_vmaddr + segment_vmsize; + + if (strncmp (raw_segment->segname, "__TEXT", + sizeof (raw_segment->segname)) == 0) + { + text_fileoff = macho_file_to_host_usize ( + commands_view->bytes_swapped, raw_segment->fileoff); + *base_address = segment_vmaddr - text_fileoff; + + found_text = 1; + } + + if (segment_maxaddr > *max_address) + *max_address = segment_maxaddr; + } + + offset += command.cmdsize; + } + + if (found_text) + return 1; + else + { + error_callback (data, "executable is missing __TEXT segment", 0); + return 0; + } +} + +static int +macho_symbol_compare_addr (const void *left_raw, const void *right_raw) +{ + const struct macho_symbol *left = left_raw; + const struct macho_symbol *right = right_raw; + + if (left->addr > right->addr) + return 1; + else if (left->addr < right->addr) + return -1; + else + return 0; +} + +int +macho_symbol_type_relevant (uint8_t type) +{ + uint8_t type_field = (uint8_t) (type & N_TYPE); + + return !(type & N_EXT) && + (type_field == N_ABS || type_field == N_SECT); +} + +int +macho_add_symtab (struct backtrace_state *state, + backtrace_error_callback error_callback, + void *data, int descriptor, + struct macho_commands_view *commands_view, + uintptr_t base_address, uintptr_t max_image_address, + intptr_t vmslide, int *found_sym) +{ + struct macho_syminfo_data *syminfo_data; + + int ret = 0; + size_t offset = 0; + struct backtrace_view symtab_view; + int symtab_view_valid = 0; + struct backtrace_view strtab_view; + int strtab_view_valid = 0; + size_t syminfo_index = 0; + size_t function_count = 0; + uint32_t i = 0; + uint32_t j = 0; + uint32_t symtab_index = 0; + + *found_sym = 0; + + for (i = 0; i < commands_view->commands_count; i++) + { + const struct load_command *raw_command; + struct load_command command; + + if (offset + sizeof (struct load_command) + > commands_view->commands_total_size) + { + error_callback (data, + "executable file contains out of range command offset", + 0); + return 0; + } + + raw_command = commands_view->view.data + offset; + command.cmd = macho_file_to_host_u32 (commands_view->bytes_swapped, + raw_command->cmd); + command.cmdsize = macho_file_to_host_u32 (commands_view->bytes_swapped, + raw_command->cmdsize); + + if (command.cmd == LC_SYMTAB) + { + const struct symtab_command *symtab_command; + uint32_t symbol_table_offset; + uint32_t symbol_count; + uint32_t string_table_offset; + uint32_t string_table_size; + + if (offset + sizeof (struct symtab_command) + > commands_view->commands_total_size) + { + error_callback (data, + "executable file contains out of range command offset", + 0); + return 0; + } + + symtab_command = (struct symtab_command *) raw_command; + + symbol_table_offset = macho_file_to_host_u32 ( + commands_view->bytes_swapped, symtab_command->symoff); + symbol_count = macho_file_to_host_u32 ( + commands_view->bytes_swapped, symtab_command->nsyms); + string_table_offset = macho_file_to_host_u32 ( + commands_view->bytes_swapped, symtab_command->stroff); + string_table_size = macho_file_to_host_u32 ( + commands_view->bytes_swapped, symtab_command->strsize); + + + if (!macho_get_view (state, descriptor, symbol_table_offset, + symbol_count * sizeof (nlist_native_t), + error_callback, data, commands_view, + &symtab_view)) + goto end; + symtab_view_valid = 1; + + if (!macho_get_view (state, descriptor, string_table_offset, + string_table_size, error_callback, data, + commands_view, &strtab_view)) + goto end; + strtab_view_valid = 1; + + // Count functions first + for (j = 0; j < symbol_count; j++) + { + const nlist_native_t *raw_sym = + ((const nlist_native_t *) symtab_view.data) + j; + + if (macho_symbol_type_relevant (raw_sym->n_type)) + { + function_count += 1; + } + } + + // Allocate space for the: + // (a) macho_syminfo_data for this image + // (b) macho_symbol entries + syminfo_data = + backtrace_alloc (state, + sizeof (struct macho_syminfo_data), + error_callback, data); + if (syminfo_data == NULL) + goto end; + + syminfo_data->symbols = backtrace_alloc ( + state, function_count * sizeof (struct macho_symbol), + error_callback, data); + if (syminfo_data->symbols == NULL) + goto end; + + syminfo_data->symbol_count = function_count; + syminfo_data->next = NULL; + syminfo_data->min_addr = base_address; + syminfo_data->max_addr = max_image_address; + + for (symtab_index = 0; + symtab_index < symbol_count; symtab_index++) + { + const nlist_native_t *raw_sym = + ((const nlist_native_t *) symtab_view.data) + + symtab_index; + + if (macho_symbol_type_relevant (raw_sym->n_type)) + { + size_t strtab_index; + const char *name; + size_t max_len_plus_one; + + syminfo_data->symbols[syminfo_index].addr = + macho_file_to_host_usize (commands_view->bytes_swapped, + raw_sym->n_value) + vmslide; + + strtab_index = macho_file_to_host_u32 ( + commands_view->bytes_swapped, + raw_sym->n_un.n_strx); + + // Check the range of the supposed "string" we've been + // given + if (strtab_index >= string_table_size) + { + error_callback ( + data, + "dSYM file contains out of range string table index", + 0); + goto end; + } + + name = strtab_view.data + strtab_index; + max_len_plus_one = string_table_size - strtab_index; + + if (strnlen (name, max_len_plus_one) >= max_len_plus_one) + { + error_callback ( + data, + "dSYM file contains unterminated string", + 0); + goto end; + } + + // Remove underscore prefixes + if (name[0] == '_') + { + name = name + 1; + } + + syminfo_data->symbols[syminfo_index].name = name; + + syminfo_index += 1; + } + } + + backtrace_qsort (syminfo_data->symbols, + syminfo_data->symbol_count, + sizeof (struct macho_symbol), + macho_symbol_compare_addr); + + // Calculate symbol sizes + for (syminfo_index = 0; + syminfo_index < syminfo_data->symbol_count; syminfo_index++) + { + if (syminfo_index + 1 < syminfo_data->symbol_count) + { + syminfo_data->symbols[syminfo_index].size = + syminfo_data->symbols[syminfo_index + 1].addr - + syminfo_data->symbols[syminfo_index].addr; + } + else + { + syminfo_data->symbols[syminfo_index].size = + max_image_address - + syminfo_data->symbols[syminfo_index].addr; + } + } + + if (!state->threaded) + { + struct macho_syminfo_data **pp; + + for (pp = (struct macho_syminfo_data **) (void *) &state->syminfo_data; + *pp != NULL; + pp = &(*pp)->next); + *pp = syminfo_data; + } + else + { + while (1) + { + struct macho_syminfo_data **pp; + + pp = (struct macho_syminfo_data **) (void *) &state->syminfo_data; + + while (1) + { + struct macho_syminfo_data *p; + + p = backtrace_atomic_load_pointer (pp); + + if (p == NULL) + break; + + pp = &p->next; + } + + if (__sync_bool_compare_and_swap (pp, NULL, syminfo_data)) + break; + } + } + + strtab_view_valid = 0; // We need to keep string table around + *found_sym = 1; + ret = 1; + goto end; + } + + offset += command.cmdsize; + } + + // No symbol table here + ret = 1; + goto end; + +end: + if (symtab_view_valid) + backtrace_release_view (state, &symtab_view, error_callback, data); + if (strtab_view_valid) + backtrace_release_view (state, &strtab_view, error_callback, data); + return ret; +} + +int +macho_try_dwarf (struct backtrace_state *state, + backtrace_error_callback error_callback, + void *data, fileline *fileline_fn, uuid_t *executable_uuid, + uintptr_t base_address, uintptr_t max_image_address, + intptr_t vmslide, char *dwarf_filename, int *matched, + int *found_sym, int *found_dwarf) +{ + uuid_t dwarf_uuid; + + int ret = 0; + int dwarf_descriptor; + int dwarf_descriptor_valid = 0; + struct macho_commands_view commands_view; + int commands_view_valid = 0; + struct backtrace_view dwarf_view; + int dwarf_view_valid = 0; + size_t offset = 0; + struct found_dwarf_section dwarf_sections[DEBUG_MAX]; + uintptr_t min_dwarf_offset = 0; + uintptr_t max_dwarf_offset = 0; + uint32_t i = 0; + uint32_t j = 0; + int k = 0; + + *matched = 0; + *found_sym = 0; + *found_dwarf = 0; + + if ((dwarf_descriptor = backtrace_open (dwarf_filename, error_callback, + data, NULL)) == 0) + goto end; + dwarf_descriptor_valid = 1; + + int incompatible; + if (!macho_get_commands (state, dwarf_descriptor, error_callback, data, + &commands_view, &incompatible)) + { + // Failing to read the header here is fine, because this dSYM may be + // for a different architecture + if (incompatible) + { + ret = 1; + } + goto end; + } + commands_view_valid = 1; + + // Get dSYM UUID and compare + if (!macho_get_uuid (state, dwarf_descriptor, error_callback, data, + &commands_view, &dwarf_uuid)) + { + error_callback (data, "dSYM file is missing an identifying uuid", 0); + goto end; + } + if (memcmp (executable_uuid, &dwarf_uuid, sizeof (uuid_t)) != 0) + { + // DWARF doesn't belong to desired executable + ret = 1; + goto end; + } + + *matched = 1; + + // Read symbol table + if (!macho_add_symtab (state, error_callback, data, dwarf_descriptor, + &commands_view, base_address, max_image_address, + vmslide, found_sym)) + goto end; + + // Get DWARF sections + + memset (dwarf_sections, 0, sizeof (dwarf_sections)); + offset = 0; + for (i = 0; i < commands_view.commands_count; i++) + { + const struct load_command *raw_command; + struct load_command command; + + if (offset + sizeof (struct load_command) + > commands_view.commands_total_size) + { + error_callback (data, + "dSYM file contains out of range command offset", 0); + goto end; + } + + raw_command = commands_view.view.data + offset; + command.cmd = macho_file_to_host_u32 (commands_view.bytes_swapped, + raw_command->cmd); + command.cmdsize = macho_file_to_host_u32 (commands_view.bytes_swapped, + raw_command->cmdsize); + + if (command.cmd == LC_SEGMENT_NATIVE) + { + uint32_t section_count; + size_t section_offset; + const segment_command_native_t *raw_segment; + + if (offset + sizeof (segment_command_native_t) + > commands_view.commands_total_size) + { + error_callback (data, + "dSYM file contains out of range command offset", + 0); + goto end; + } + + raw_segment = (const segment_command_native_t *) raw_command; + + if (strncmp (raw_segment->segname, "__DWARF", + sizeof (raw_segment->segname)) == 0) + { + section_count = macho_file_to_host_u32 ( + commands_view.bytes_swapped, + raw_segment->nsects); + + section_offset = offset + sizeof (segment_command_native_t); + + // Search sections for relevant DWARF section names + for (j = 0; j < section_count; j++) + { + const section_native_t *raw_section; + + if (section_offset + sizeof (section_native_t) > + commands_view.commands_total_size) + { + error_callback (data, + "dSYM file contains out of range command offset", + 0); + goto end; + } + + raw_section = commands_view.view.data + section_offset; + + for (k = 0; k < DEBUG_MAX; k++) + { + uintptr_t dwarf_section_end; + + if (strncmp (raw_section->sectname, + debug_section_names[k], + sizeof (raw_section->sectname)) == 0) + { + *found_dwarf = 1; + + dwarf_sections[k].file_offset = + macho_file_to_host_u32 ( + commands_view.bytes_swapped, + raw_section->offset); + dwarf_sections[k].file_size = + macho_file_to_host_usize ( + commands_view.bytes_swapped, + raw_section->size); + + if (min_dwarf_offset == 0 || + dwarf_sections[k].file_offset < + min_dwarf_offset) + min_dwarf_offset = dwarf_sections[k].file_offset; + + dwarf_section_end = + dwarf_sections[k].file_offset + + dwarf_sections[k].file_size; + if (dwarf_section_end > max_dwarf_offset) + max_dwarf_offset = dwarf_section_end; + + break; + } + } + + section_offset += sizeof (section_native_t); + } + + break; + } + } + + offset += command.cmdsize; + } + + if (!*found_dwarf) + { + // No DWARF in this file + ret = 1; + goto end; + } + + if (!macho_get_view (state, dwarf_descriptor, (off_t) min_dwarf_offset, + max_dwarf_offset - min_dwarf_offset, error_callback, + data, &commands_view, &dwarf_view)) + goto end; + dwarf_view_valid = 1; + + for (i = 0; i < DEBUG_MAX; i++) + { + if (dwarf_sections[i].file_offset == 0) + dwarf_sections[i].data = NULL; + else + dwarf_sections[i].data = + dwarf_view.data + dwarf_sections[i].file_offset - min_dwarf_offset; + } + + if (!backtrace_dwarf_add (state, vmslide, + dwarf_sections[DEBUG_INFO].data, + dwarf_sections[DEBUG_INFO].file_size, + dwarf_sections[DEBUG_LINE].data, + dwarf_sections[DEBUG_LINE].file_size, + dwarf_sections[DEBUG_ABBREV].data, + dwarf_sections[DEBUG_ABBREV].file_size, + dwarf_sections[DEBUG_RANGES].data, + dwarf_sections[DEBUG_RANGES].file_size, + dwarf_sections[DEBUG_STR].data, + dwarf_sections[DEBUG_STR].file_size, + ((__DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN) + ^ commands_view.bytes_swapped), + error_callback, data, fileline_fn)) + goto end; + + // Don't release the DWARF view because it is still in use + dwarf_descriptor_valid = 0; + dwarf_view_valid = 0; + ret = 1; + +end: + if (dwarf_descriptor_valid) + backtrace_close (dwarf_descriptor, error_callback, data); + if (commands_view_valid) + backtrace_release_view (state, &commands_view.view, error_callback, data); + if (dwarf_view_valid) + backtrace_release_view (state, &dwarf_view, error_callback, data); + return ret; +} + +int +macho_try_dsym (struct backtrace_state *state, + backtrace_error_callback error_callback, + void *data, fileline *fileline_fn, uuid_t *executable_uuid, + uintptr_t base_address, uintptr_t max_image_address, + intptr_t vmslide, char *dsym_filename, int *matched, + int *found_sym, int *found_dwarf) +{ + int ret = 0; + char dwarf_image_dir_path[PATH_MAX]; + DIR *dwarf_image_dir; + int dwarf_image_dir_valid = 0; + struct dirent *directory_entry; + char dwarf_filename[PATH_MAX]; + int dwarf_matched; + int dwarf_had_sym; + int dwarf_had_dwarf; + + *matched = 0; + *found_sym = 0; + *found_dwarf = 0; + + strncpy (dwarf_image_dir_path, dsym_filename, PATH_MAX); + strncat (dwarf_image_dir_path, "/Contents/Resources/DWARF", PATH_MAX); + + if (!(dwarf_image_dir = opendir (dwarf_image_dir_path))) + { + error_callback (data, "could not open DWARF directory in dSYM", + 0); + goto end; + } + dwarf_image_dir_valid = 1; + + while ((directory_entry = readdir (dwarf_image_dir))) + { + if (directory_entry->d_type != DT_REG) + continue; + + strncpy (dwarf_filename, dwarf_image_dir_path, PATH_MAX); + strncat (dwarf_filename, "/", PATH_MAX); + strncat (dwarf_filename, directory_entry->d_name, PATH_MAX); + + if (!macho_try_dwarf (state, error_callback, data, fileline_fn, + executable_uuid, base_address, max_image_address, + vmslide, dwarf_filename, + &dwarf_matched, &dwarf_had_sym, &dwarf_had_dwarf)) + goto end; + + if (dwarf_matched) + { + *matched = 1; + *found_sym = dwarf_had_sym; + *found_dwarf = dwarf_had_dwarf; + ret = 1; + goto end; + } + } + + // No matching DWARF in this dSYM + ret = 1; + goto end; + +end: + if (dwarf_image_dir_valid) + closedir (dwarf_image_dir); + return ret; +} + +int +macho_add (struct backtrace_state *state, + backtrace_error_callback error_callback, void *data, int descriptor, + const char *filename, fileline *fileline_fn, intptr_t vmslide, + int *found_sym, int *found_dwarf) +{ + uuid_t image_uuid; + uintptr_t image_file_base_address; + uintptr_t image_file_max_address; + uintptr_t image_actual_base_address = 0; + uintptr_t image_actual_max_address = 0; + + int ret = 0; + struct macho_commands_view commands_view; + int commands_view_valid = 0; + char executable_dirname[PATH_MAX]; + size_t filename_len; + DIR *executable_dir = NULL; + int executable_dir_valid = 0; + struct dirent *directory_entry; + char dsym_full_path[PATH_MAX]; + static const char *extension; + size_t extension_len; + ssize_t i; + + *found_sym = 0; + *found_dwarf = 0; + + // Find Mach-O commands list + int incompatible; + if (!macho_get_commands (state, descriptor, error_callback, data, + &commands_view, &incompatible)) + goto end; + commands_view_valid = 1; + + // First we need to get the uuid of our file so we can hunt down the correct + // dSYM + if (!macho_get_uuid (state, descriptor, error_callback, data, &commands_view, + &image_uuid)) + goto end; + + // Now we need to find the in memory base address. Step one is to find out + // what the executable thinks the base address is + if (!macho_get_addr_range (state, descriptor, error_callback, data, + &commands_view, + &image_file_base_address, + &image_file_max_address)) + goto end; + + image_actual_base_address = + image_file_base_address + vmslide; + image_actual_max_address = + image_file_max_address + vmslide; + + if (image_actual_base_address == 0) + { + error_callback (data, "executable file is not loaded", 0); + goto end; + } + + // Look for dSYM in our executable's directory + strncpy (executable_dirname, filename, PATH_MAX); + filename_len = strlen (executable_dirname); + for (i = filename_len - 1; i >= 0; i--) + { + if (executable_dirname[i] == '/') + { + executable_dirname[i] = '\0'; + break; + } + else if (i == 0) + { + executable_dirname[0] = '.'; + executable_dirname[1] = '\0'; + break; + } + } + + if (!(executable_dir = opendir (executable_dirname))) + { + error_callback (data, "could not open directory containing executable", + 0); + goto end; + } + executable_dir_valid = 1; + + extension = ".dSYM"; + extension_len = strlen (extension); + while ((directory_entry = readdir (executable_dir))) + { + if (directory_entry->d_namlen < extension_len) + continue; + if (strncasecmp (directory_entry->d_name + directory_entry->d_namlen + - extension_len, extension, extension_len) == 0) + { + int matched; + int dsym_had_sym; + int dsym_had_dwarf; + + // Found a dSYM + strncpy (dsym_full_path, executable_dirname, PATH_MAX); + strncat (dsym_full_path, "/", PATH_MAX); + strncat (dsym_full_path, directory_entry->d_name, PATH_MAX); + + if (!macho_try_dsym (state, error_callback, data, + fileline_fn, &image_uuid, + image_actual_base_address, + image_actual_max_address, vmslide, + dsym_full_path, + &matched, &dsym_had_sym, &dsym_had_dwarf)) + goto end; + + if (matched) + { + *found_sym = dsym_had_sym; + *found_dwarf = dsym_had_dwarf; + ret = 1; + goto end; + } + } + } + + // No matching dSYM + ret = 1; + goto end; + +end: + if (commands_view_valid) + backtrace_release_view (state, &commands_view.view, error_callback, + data); + if (executable_dir_valid) + closedir (executable_dir); + return ret; +} + +static int +macho_symbol_search (const void *vkey, const void *ventry) +{ + const uintptr_t *key = (const uintptr_t *) vkey; + const struct macho_symbol *entry = (const struct macho_symbol *) ventry; + uintptr_t addr; + + addr = *key; + if (addr < entry->addr) + return -1; + else if (addr >= entry->addr + entry->size) + return 1; + else + return 0; +} + +static void +macho_syminfo (struct backtrace_state *state, + uintptr_t addr, + backtrace_syminfo_callback callback, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data) +{ + struct macho_syminfo_data *edata; + struct macho_symbol *sym = NULL; + + if (!state->threaded) + { + for (edata = (struct macho_syminfo_data *) state->syminfo_data; + edata != NULL; + edata = edata->next) + { + if (addr >= edata->min_addr && addr <= edata->max_addr) + { + sym = ((struct macho_symbol *) + bsearch (&addr, edata->symbols, edata->symbol_count, + sizeof (struct macho_symbol), macho_symbol_search)); + if (sym != NULL) + break; + } + } + } + else + { + struct macho_syminfo_data **pp; + + pp = (struct macho_syminfo_data **) (void *) &state->syminfo_data; + while (1) + { + edata = backtrace_atomic_load_pointer (pp); + if (edata == NULL) + break; + + if (addr >= edata->min_addr && addr <= edata->max_addr) + { + sym = ((struct macho_symbol *) + bsearch (&addr, edata->symbols, edata->symbol_count, + sizeof (struct macho_symbol), macho_symbol_search)); + if (sym != NULL) + break; + } + + pp = &edata->next; + } + } + + if (sym == NULL) + callback (data, addr, NULL, 0, 0); + else + callback (data, addr, sym->name, sym->addr, sym->size); +} + + +static int +macho_nodebug (struct backtrace_state *state ATTRIBUTE_UNUSED, + uintptr_t pc ATTRIBUTE_UNUSED, + backtrace_full_callback callback ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, void *data) +{ + error_callback (data, "no debug info in Mach-O executable", -1); + return 0; +} + +static void +macho_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED, + uintptr_t addr ATTRIBUTE_UNUSED, + backtrace_syminfo_callback callback ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, void *data) +{ + error_callback (data, "no symbol table in Mach-O executable", -1); +} + +int +backtrace_initialize (struct backtrace_state *state, + const char *filename, + int descriptor, + backtrace_error_callback error_callback, + void *data, fileline *fileline_fn) +{ + int ret; + fileline macho_fileline_fn = macho_nodebug; + int found_sym = 0; + int found_dwarf = 0; + uint32_t i = 0; + uint32_t loaded_image_count; + + // Add all loaded images + loaded_image_count = _dyld_image_count (); + for (i = 0; i < loaded_image_count; i++) + { + int current_found_sym; + int current_found_dwarf; + int current_descriptor; + intptr_t current_vmslide; + const char *current_name; + + current_vmslide = _dyld_get_image_vmaddr_slide (i); + current_name = _dyld_get_image_name (i); + + if (current_name == NULL || (i != 0 && current_vmslide == 0)) + continue; + + if (!(current_descriptor = + backtrace_open (current_name, error_callback, data, NULL))) + { + continue; + } + + if (macho_add (state, error_callback, data, current_descriptor, + current_name, &macho_fileline_fn, current_vmslide, + ¤t_found_sym, ¤t_found_dwarf)) + { + found_sym = found_sym || current_found_sym; + found_dwarf = found_dwarf || current_found_dwarf; + } + + backtrace_close (current_descriptor, error_callback, data); + } + + if (!state->threaded) + { + if (found_sym) + state->syminfo_fn = macho_syminfo; + else if (state->syminfo_fn == NULL) + state->syminfo_fn = macho_nosyms; + } + else + { + if (found_sym) + backtrace_atomic_store_pointer (&state->syminfo_fn, macho_syminfo); + else + (void) __sync_bool_compare_and_swap (&state->syminfo_fn, NULL, + macho_nosyms); + } + + if (!state->threaded) + { + if (state->fileline_fn == NULL || state->fileline_fn == macho_nodebug) + *fileline_fn = macho_fileline_fn; + } + else + { + fileline current_fn; + + current_fn = backtrace_atomic_load_pointer (&state->fileline_fn); + if (current_fn == NULL || current_fn == macho_nodebug) + *fileline_fn = macho_fileline_fn; + } + + return 1; +} + diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/missing b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/missing new file mode 100755 index 0000000..86a8fc3 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/missing @@ -0,0 +1,331 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2012-01-06.13; # UTC + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, +# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case $1 in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and +\`g' are ignored when checking the name. + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# normalize program name to check for. +program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). This is about non-GNU programs, so use $1 not +# $program. +case $1 in + lex*|yacc*) + # Not GNU programs, they don't have --version. + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case $program in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case $f in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te*) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison*|yacc*) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if test $# -ne 1; then + eval LASTARG=\${$#} + case $LASTARG in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if test ! -f y.tab.h; then + echo >y.tab.h + fi + if test ! -f y.tab.c; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex*|flex*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if test $# -ne 1; then + eval LASTARG=\${$#} + case $LASTARG in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if test ! -f lex.yy.c; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit $? + fi + ;; + + makeinfo*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/mmap.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/mmap.c new file mode 100644 index 0000000..32fcba6 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/mmap.c @@ -0,0 +1,325 @@ +/* mmap.c -- Memory allocation with mmap. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +/* Memory allocation on systems that provide anonymous mmap. This + permits the backtrace functions to be invoked from a signal + handler, assuming that mmap is async-signal safe. */ + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +/* A list of free memory blocks. */ + +struct backtrace_freelist_struct +{ + /* Next on list. */ + struct backtrace_freelist_struct *next; + /* Size of this block, including this structure. */ + size_t size; +}; + +/* Free memory allocated by backtrace_alloc. */ + +static void +backtrace_free_locked (struct backtrace_state *state, void *addr, size_t size) +{ + /* Just leak small blocks. We don't have to be perfect. Don't put + more than 16 entries on the free list, to avoid wasting time + searching when allocating a block. If we have more than 16 + entries, leak the smallest entry. */ + + if (size >= sizeof (struct backtrace_freelist_struct)) + { + size_t c; + struct backtrace_freelist_struct **ppsmall; + struct backtrace_freelist_struct **pp; + struct backtrace_freelist_struct *p; + + c = 0; + ppsmall = NULL; + for (pp = &state->freelist; *pp != NULL; pp = &(*pp)->next) + { + if (ppsmall == NULL || (*pp)->size < (*ppsmall)->size) + ppsmall = pp; + ++c; + } + if (c >= 16) + { + if (size <= (*ppsmall)->size) + return; + *ppsmall = (*ppsmall)->next; + } + + p = (struct backtrace_freelist_struct *) addr; + p->next = state->freelist; + p->size = size; + state->freelist = p; + } +} + +/* Allocate memory like malloc. If ERROR_CALLBACK is NULL, don't + report an error. */ + +void * +backtrace_alloc (struct backtrace_state *state, + size_t size, backtrace_error_callback error_callback, + void *data) +{ + void *ret; + int locked; + struct backtrace_freelist_struct **pp; + size_t pagesize; + size_t asksize; + void *page; + + ret = NULL; + + /* If we can acquire the lock, then see if there is space on the + free list. If we can't acquire the lock, drop straight into + using mmap. __sync_lock_test_and_set returns the old state of + the lock, so we have acquired it if it returns 0. */ + + if (!state->threaded) + locked = 1; + else + locked = __sync_lock_test_and_set (&state->lock_alloc, 1) == 0; + + if (locked) + { + for (pp = &state->freelist; *pp != NULL; pp = &(*pp)->next) + { + if ((*pp)->size >= size) + { + struct backtrace_freelist_struct *p; + + p = *pp; + *pp = p->next; + + /* Round for alignment; we assume that no type we care about + is more than 8 bytes. */ + size = (size + 7) & ~ (size_t) 7; + if (size < p->size) + backtrace_free_locked (state, (char *) p + size, + p->size - size); + + ret = (void *) p; + + break; + } + } + + if (state->threaded) + __sync_lock_release (&state->lock_alloc); + } + + if (ret == NULL) + { + /* Allocate a new page. */ + + pagesize = getpagesize (); + asksize = (size + pagesize - 1) & ~ (pagesize - 1); + page = mmap (NULL, asksize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (page == MAP_FAILED) + { + if (error_callback) + error_callback (data, "mmap", errno); + } + else + { + size = (size + 7) & ~ (size_t) 7; + if (size < asksize) + backtrace_free (state, (char *) page + size, asksize - size, + error_callback, data); + + ret = page; + } + } + + return ret; +} + +/* Free memory allocated by backtrace_alloc. */ + +void +backtrace_free (struct backtrace_state *state, void *addr, size_t size, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data ATTRIBUTE_UNUSED) +{ + int locked; + + /* If we are freeing a large aligned block, just release it back to + the system. This case arises when growing a vector for a large + binary with lots of debug info. Calling munmap here may cause us + to call mmap again if there is also a large shared library; we + just live with that. */ + if (size >= 16 * 4096) + { + size_t pagesize; + + pagesize = getpagesize (); + if (((uintptr_t) addr & (pagesize - 1)) == 0 + && (size & (pagesize - 1)) == 0) + { + /* If munmap fails for some reason, just add the block to + the freelist. */ + if (munmap (addr, size) == 0) + return; + } + } + + /* If we can acquire the lock, add the new space to the free list. + If we can't acquire the lock, just leak the memory. + __sync_lock_test_and_set returns the old state of the lock, so we + have acquired it if it returns 0. */ + + if (!state->threaded) + locked = 1; + else + locked = __sync_lock_test_and_set (&state->lock_alloc, 1) == 0; + + if (locked) + { + backtrace_free_locked (state, addr, size); + + if (state->threaded) + __sync_lock_release (&state->lock_alloc); + } +} + +/* Grow VEC by SIZE bytes. */ + +void * +backtrace_vector_grow (struct backtrace_state *state,size_t size, + backtrace_error_callback error_callback, + void *data, struct backtrace_vector *vec) +{ + void *ret; + + if (size > vec->alc) + { + size_t pagesize; + size_t alc; + void *base; + + pagesize = getpagesize (); + alc = vec->size + size; + if (vec->size == 0) + alc = 16 * size; + else if (alc < pagesize) + { + alc *= 2; + if (alc > pagesize) + alc = pagesize; + } + else + { + alc *= 2; + alc = (alc + pagesize - 1) & ~ (pagesize - 1); + } + base = backtrace_alloc (state, alc, error_callback, data); + if (base == NULL) + return NULL; + if (vec->base != NULL) + { + memcpy (base, vec->base, vec->size); + backtrace_free (state, vec->base, vec->size + vec->alc, + error_callback, data); + } + vec->base = base; + vec->alc = alc - vec->size; + } + + ret = (char *) vec->base + vec->size; + vec->size += size; + vec->alc -= size; + return ret; +} + +/* Finish the current allocation on VEC. */ + +void * +backtrace_vector_finish ( + struct backtrace_state *state ATTRIBUTE_UNUSED, + struct backtrace_vector *vec, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data ATTRIBUTE_UNUSED) +{ + void *ret; + + ret = vec->base; + vec->base = (char *) vec->base + vec->size; + vec->size = 0; + return ret; +} + +/* Release any extra space allocated for VEC. */ + +int +backtrace_vector_release (struct backtrace_state *state, + struct backtrace_vector *vec, + backtrace_error_callback error_callback, + void *data) +{ + size_t size; + size_t alc; + size_t aligned; + + /* Make sure that the block that we free is aligned on an 8-byte + boundary. */ + size = vec->size; + alc = vec->alc; + aligned = (size + 7) & ~ (size_t) 7; + alc -= aligned - size; + + backtrace_free (state, (char *) vec->base + aligned, alc, + error_callback, data); + vec->alc = 0; + return 1; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/mmapio.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/mmapio.c new file mode 100644 index 0000000..94e8c93 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/mmapio.c @@ -0,0 +1,100 @@ +/* mmapio.c -- File views using mmap. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +/* This file implements file views and memory allocation when mmap is + available. */ + +/* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. */ + +int +backtrace_get_view (struct backtrace_state *state ATTRIBUTE_UNUSED, + int descriptor, off_t offset, size_t size, + backtrace_error_callback error_callback, + void *data, struct backtrace_view *view) +{ + size_t pagesize; + unsigned int inpage; + off_t pageoff; + void *map; + + pagesize = getpagesize (); + inpage = offset % pagesize; + pageoff = offset - inpage; + + size += inpage; + size = (size + (pagesize - 1)) & ~ (pagesize - 1); + + map = mmap (NULL, size, PROT_READ, MAP_PRIVATE, descriptor, pageoff); + if (map == MAP_FAILED) + { + error_callback (data, "mmap", errno); + return 0; + } + + view->data = (char *) map + inpage; + view->base = map; + view->len = size; + + return 1; +} + +/* Release a view read by backtrace_get_view. */ + +void +backtrace_release_view (struct backtrace_state *state ATTRIBUTE_UNUSED, + struct backtrace_view *view, + backtrace_error_callback error_callback, + void *data) +{ + union { + const void *cv; + void *v; + } const_cast; + + const_cast.cv = view->base; + if (munmap (const_cast.v, view->len) < 0) + error_callback (data, "munmap", errno); +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/move-if-change b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/move-if-change new file mode 100644 index 0000000..88d9574 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/move-if-change @@ -0,0 +1,83 @@ +#!/bin/sh +# Like mv $1 $2, but if the files are the same, just delete $1. +# Status is zero if successful, nonzero otherwise. + +VERSION='2012-01-06 07:23'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +# Copyright (C) 2002-2014 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +usage="usage: $0 SOURCE DEST" + +help="$usage + or: $0 OPTION +If SOURCE is different than DEST, then move it to DEST; else remove SOURCE. + + --help display this help and exit + --version output version information and exit + +The variable CMPPROG can be used to specify an alternative to 'cmp'. + +Report bugs to ." + +version=`expr "$VERSION" : '\([^ ]*\)'` +version="move-if-change (gnulib) $version +Copyright (C) 2011 Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law." + +cmpprog=${CMPPROG-cmp} + +for arg +do + case $arg in + --help | --hel | --he | --h) + exec echo "$help" ;; + --version | --versio | --versi | --vers | --ver | --ve | --v) + exec echo "$version" ;; + --) + shift + break ;; + -*) + echo "$0: invalid option: $arg" >&2 + exit 1 ;; + *) + break ;; + esac +done + +test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; } + +if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then + rm -f -- "$1" +else + if mv -f -- "$1" "$2"; then :; else + # Ignore failure due to a concurrent move-if-change. + test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1" + fi +fi + +## Local Variables: +## eval: (add-hook 'write-file-hooks 'time-stamp) +## time-stamp-start: "VERSION='" +## time-stamp-format: "%:y-%02m-%02d %02H:%02M" +## time-stamp-time-zone: "UTC" +## time-stamp-end: "'; # UTC" +## End: diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/nounwind.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/nounwind.c new file mode 100644 index 0000000..0a046cc --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/nounwind.c @@ -0,0 +1,66 @@ +/* backtrace.c -- Entry point for stack backtrace library. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include + +#include "backtrace.h" + +#include "internal.h" + +/* This source file is compiled if the unwind library is not + available. */ + +int +backtrace_full (struct backtrace_state *state ATTRIBUTE_UNUSED, + int skip ATTRIBUTE_UNUSED, + backtrace_full_callback callback ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, void *data) +{ + error_callback (data, + "no stack trace because unwind library not available", + 0); + return 0; +} + +int +backtrace_simple (struct backtrace_state *state ATTRIBUTE_UNUSED, + int skip ATTRIBUTE_UNUSED, + backtrace_simple_callback callback ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, void *data) +{ + error_callback (data, + "no stack trace because unwind library not available", + 0); + return 0; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/pecoff.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/pecoff.c new file mode 100644 index 0000000..049d7e3 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/pecoff.c @@ -0,0 +1,943 @@ +/* pecoff.c -- Get debug data from a PE/COFFF file for backtraces. + Copyright (C) 2015-2018 Free Software Foundation, Inc. + Adapted from elf.c by Tristan Gingold, AdaCore. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +/* Coff file header. */ + +typedef struct { + uint16_t machine; + uint16_t number_of_sections; + uint32_t time_date_stamp; + uint32_t pointer_to_symbol_table; + uint32_t number_of_symbols; + uint16_t size_of_optional_header; + uint16_t characteristics; +} b_coff_file_header; + +/* Coff optional header. */ + +typedef struct { + uint16_t magic; + uint8_t major_linker_version; + uint8_t minor_linker_version; + uint32_t size_of_code; + uint32_t size_of_initialized_data; + uint32_t size_of_uninitialized_data; + uint32_t address_of_entry_point; + uint32_t base_of_code; + union { + struct { + uint32_t base_of_data; + uint32_t image_base; + } pe; + struct { + uint64_t image_base; + } pep; + } u; +} b_coff_optional_header; + +/* Values of magic in optional header. */ + +#define PE_MAGIC 0x10b /* PE32 executable. */ +#define PEP_MAGIC 0x20b /* PE32+ executable (for 64bit targets). */ + +/* Coff section header. */ + +typedef struct { + char name[8]; + uint32_t virtual_size; + uint32_t virtual_address; + uint32_t size_of_raw_data; + uint32_t pointer_to_raw_data; + uint32_t pointer_to_relocations; + uint32_t pointer_to_line_numbers; + uint16_t number_of_relocations; + uint16_t number_of_line_numbers; + uint32_t characteristics; +} b_coff_section_header; + +/* Coff symbol name. */ + +typedef union { + char short_name[8]; + struct { + unsigned char zeroes[4]; + unsigned char off[4]; + } long_name; +} b_coff_name; + +/* Coff symbol (external representation which is unaligned). */ + +typedef struct { + b_coff_name name; + unsigned char value[4]; + unsigned char section_number[2]; + unsigned char type[2]; + unsigned char storage_class; + unsigned char number_of_aux_symbols; +} b_coff_external_symbol; + +/* Symbol types. */ + +#define N_TBSHFT 4 /* Shift for the derived type. */ +#define IMAGE_SYM_DTYPE_FUNCTION 2 /* Function derived type. */ + +/* Size of a coff symbol. */ + +#define SYM_SZ 18 + +/* Coff symbol, internal representation (aligned). */ + +typedef struct { + const char *name; + uint32_t value; + int16_t sec; + uint16_t type; + uint16_t sc; +} b_coff_internal_symbol; + +/* An index of sections we care about. */ + +enum debug_section +{ + DEBUG_INFO, + DEBUG_LINE, + DEBUG_ABBREV, + DEBUG_RANGES, + DEBUG_STR, + DEBUG_MAX +}; + +/* Names of sections, indexed by enum debug_section. */ + +static const char * const debug_section_names[DEBUG_MAX] = +{ + ".debug_info", + ".debug_line", + ".debug_abbrev", + ".debug_ranges", + ".debug_str" +}; + +/* Information we gather for the sections we care about. */ + +struct debug_section_info +{ + /* Section file offset. */ + off_t offset; + /* Section size. */ + size_t size; + /* Section contents, after read from file. */ + const unsigned char *data; +}; + +/* Information we keep for an coff symbol. */ + +struct coff_symbol +{ + /* The name of the symbol. */ + const char *name; + /* The address of the symbol. */ + uintptr_t address; +}; + +/* Information to pass to coff_syminfo. */ + +struct coff_syminfo_data +{ + /* Symbols for the next module. */ + struct coff_syminfo_data *next; + /* The COFF symbols, sorted by address. */ + struct coff_symbol *symbols; + /* The number of symbols. */ + size_t count; +}; + +/* A dummy callback function used when we can't find any debug info. */ + +static int +coff_nodebug (struct backtrace_state *state ATTRIBUTE_UNUSED, + uintptr_t pc ATTRIBUTE_UNUSED, + backtrace_full_callback callback ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, void *data) +{ + error_callback (data, "no debug info in PE/COFF executable", -1); + return 0; +} + +/* A dummy callback function used when we can't find a symbol + table. */ + +static void +coff_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED, + uintptr_t addr ATTRIBUTE_UNUSED, + backtrace_syminfo_callback callback ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, void *data) +{ + error_callback (data, "no symbol table in PE/COFF executable", -1); +} + +/* Read a potentially unaligned 4 byte word at P, using native endianness. */ + +static uint32_t +coff_read4 (const unsigned char *p) +{ + uint32_t res; + + memcpy (&res, p, 4); + return res; +} + +/* Read a potentially unaligned 2 byte word at P, using native endianness. + All 2 byte word in symbols are always aligned, but for coherency all + fields are declared as char arrays. */ + +static uint16_t +coff_read2 (const unsigned char *p) +{ + uint16_t res; + + memcpy (&res, p, sizeof (res)); + return res; +} + +/* Return the length (without the trailing 0) of a COFF short name. */ + +static size_t +coff_short_name_len (const char *name) +{ + int i; + + for (i = 0; i < 8; i++) + if (name[i] == 0) + return i; + return 8; +} + +/* Return true iff COFF short name CNAME is the same as NAME (a NUL-terminated + string). */ + +static int +coff_short_name_eq (const char *name, const char *cname) +{ + int i; + + for (i = 0; i < 8; i++) + { + if (name[i] != cname[i]) + return 0; + if (name[i] == 0) + return 1; + } + return name[8] == 0; +} + +/* Return true iff NAME is the same as string at offset OFF. */ + +static int +coff_long_name_eq (const char *name, unsigned int off, + struct backtrace_view *str_view) +{ + if (off >= str_view->len) + return 0; + return strcmp (name, (const char *)str_view->data + off) == 0; +} + +/* Compare struct coff_symbol for qsort. */ + +static int +coff_symbol_compare (const void *v1, const void *v2) +{ + const struct coff_symbol *e1 = (const struct coff_symbol *) v1; + const struct coff_symbol *e2 = (const struct coff_symbol *) v2; + + if (e1->address < e2->address) + return -1; + else if (e1->address > e2->address) + return 1; + else + return 0; +} + +/* Convert SYM to internal (and aligned) format ISYM, using string table + from STRTAB and STRTAB_SIZE, and number of sections SECTS_NUM. + Return -1 in case of error (invalid section number or string index). */ + +static int +coff_expand_symbol (b_coff_internal_symbol *isym, + const b_coff_external_symbol *sym, + uint16_t sects_num, + const unsigned char *strtab, size_t strtab_size) +{ + isym->type = coff_read2 (sym->type); + isym->sec = coff_read2 (sym->section_number); + isym->sc = sym->storage_class; + + if (isym->sec > 0 && (uint16_t) isym->sec > sects_num) + return -1; + if (sym->name.short_name[0] != 0) + isym->name = sym->name.short_name; + else + { + uint32_t off = coff_read4 (sym->name.long_name.off); + + if (off >= strtab_size) + return -1; + isym->name = (const char *) strtab + off; + } + return 0; +} + +/* Return true iff SYM is a defined symbol for a function. Data symbols + aren't considered because they aren't easily identified (same type as + section names, presence of symbols defined by the linker script). */ + +static int +coff_is_function_symbol (const b_coff_internal_symbol *isym) +{ + return (isym->type >> N_TBSHFT) == IMAGE_SYM_DTYPE_FUNCTION + && isym->sec > 0; +} + +/* Initialize the symbol table info for coff_syminfo. */ + +static int +coff_initialize_syminfo (struct backtrace_state *state, + uintptr_t base_address, + const b_coff_section_header *sects, size_t sects_num, + const b_coff_external_symbol *syms, size_t syms_size, + const unsigned char *strtab, size_t strtab_size, + backtrace_error_callback error_callback, + void *data, struct coff_syminfo_data *sdata) +{ + size_t syms_count; + char *coff_symstr; + size_t coff_symstr_len; + size_t coff_symbol_count; + size_t coff_symbol_size; + struct coff_symbol *coff_symbols; + struct coff_symbol *coff_sym; + char *coff_str; + size_t i; + + syms_count = syms_size / SYM_SZ; + + /* We only care about function symbols. Count them. Also count size of + strings for in-symbol names. */ + coff_symbol_count = 0; + coff_symstr_len = 0; + for (i = 0; i < syms_count; ++i) + { + const b_coff_external_symbol *asym = &syms[i]; + b_coff_internal_symbol isym; + + if (coff_expand_symbol (&isym, asym, sects_num, strtab, strtab_size) < 0) + { + error_callback (data, "invalid section or offset in coff symbol", 0); + return 0; + } + if (coff_is_function_symbol (&isym)) + { + ++coff_symbol_count; + if (asym->name.short_name[0] != 0) + coff_symstr_len += coff_short_name_len (asym->name.short_name) + 1; + } + + i += asym->number_of_aux_symbols; + } + + coff_symbol_size = (coff_symbol_count + 1) * sizeof (struct coff_symbol); + coff_symbols = ((struct coff_symbol *) + backtrace_alloc (state, coff_symbol_size, error_callback, + data)); + if (coff_symbols == NULL) + return 0; + + /* Allocate memory for symbols strings. */ + if (coff_symstr_len > 0) + { + coff_symstr = ((char *) + backtrace_alloc (state, coff_symstr_len, error_callback, + data)); + if (coff_symstr == NULL) + { + backtrace_free (state, coff_symbols, coff_symbol_size, + error_callback, data); + return 0; + } + } + else + coff_symstr = NULL; + + /* Copy symbols. */ + coff_sym = coff_symbols; + coff_str = coff_symstr; + for (i = 0; i < syms_count; ++i) + { + const b_coff_external_symbol *asym = &syms[i]; + b_coff_internal_symbol isym; + + if (coff_expand_symbol (&isym, asym, sects_num, strtab, strtab_size)) + { + /* Should not fail, as it was already tested in the previous + loop. */ + abort (); + } + if (coff_is_function_symbol (&isym)) + { + const char *name; + int16_t secnum; + + if (asym->name.short_name[0] != 0) + { + size_t len = coff_short_name_len (isym.name); + name = coff_str; + memcpy (coff_str, isym.name, len); + coff_str[len] = 0; + coff_str += len + 1; + } + else + name = isym.name; + + /* Strip leading '_'. */ + if (name[0] == '_') + name++; + + /* Symbol value is section relative, so we need to read the address + of its section. */ + secnum = coff_read2 (asym->section_number); + + coff_sym->name = name; + coff_sym->address = (coff_read4 (asym->value) + + sects[secnum - 1].virtual_address + + base_address); + coff_sym++; + } + + i += asym->number_of_aux_symbols; + } + + /* End of symbols marker. */ + coff_sym->name = NULL; + coff_sym->address = -1; + + backtrace_qsort (coff_symbols, coff_symbol_count, + sizeof (struct coff_symbol), coff_symbol_compare); + + sdata->next = NULL; + sdata->symbols = coff_symbols; + sdata->count = coff_symbol_count; + + return 1; +} + +/* Add EDATA to the list in STATE. */ + +static void +coff_add_syminfo_data (struct backtrace_state *state, + struct coff_syminfo_data *sdata) +{ + if (!state->threaded) + { + struct coff_syminfo_data **pp; + + for (pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data; + *pp != NULL; + pp = &(*pp)->next) + ; + *pp = sdata; + } + else + { + while (1) + { + struct coff_syminfo_data **pp; + + pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data; + + while (1) + { + struct coff_syminfo_data *p; + + p = backtrace_atomic_load_pointer (pp); + + if (p == NULL) + break; + + pp = &p->next; + } + + if (__sync_bool_compare_and_swap (pp, NULL, sdata)) + break; + } + } +} + +/* Compare an ADDR against an elf_symbol for bsearch. We allocate one + extra entry in the array so that this can look safely at the next + entry. */ + +static int +coff_symbol_search (const void *vkey, const void *ventry) +{ + const uintptr_t *key = (const uintptr_t *) vkey; + const struct coff_symbol *entry = (const struct coff_symbol *) ventry; + uintptr_t addr; + + addr = *key; + if (addr < entry->address) + return -1; + else if (addr >= entry[1].address) + return 1; + else + return 0; +} + +/* Return the symbol name and value for an ADDR. */ + +static void +coff_syminfo (struct backtrace_state *state, uintptr_t addr, + backtrace_syminfo_callback callback, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data) +{ + struct coff_syminfo_data *sdata; + struct coff_symbol *sym = NULL; + + if (!state->threaded) + { + for (sdata = (struct coff_syminfo_data *) state->syminfo_data; + sdata != NULL; + sdata = sdata->next) + { + sym = ((struct coff_symbol *) + bsearch (&addr, sdata->symbols, sdata->count, + sizeof (struct coff_symbol), coff_symbol_search)); + if (sym != NULL) + break; + } + } + else + { + struct coff_syminfo_data **pp; + + pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data; + while (1) + { + sdata = backtrace_atomic_load_pointer (pp); + if (sdata == NULL) + break; + + sym = ((struct coff_symbol *) + bsearch (&addr, sdata->symbols, sdata->count, + sizeof (struct coff_symbol), coff_symbol_search)); + if (sym != NULL) + break; + + pp = &sdata->next; + } + } + + if (sym == NULL) + callback (data, addr, NULL, 0, 0); + else + callback (data, addr, sym->name, sym->address, 0); +} + +/* Add the backtrace data for one PE/COFF file. Returns 1 on success, + 0 on failure (in both cases descriptor is closed). */ + +static int +coff_add (struct backtrace_state *state, int descriptor, + backtrace_error_callback error_callback, void *data, + fileline *fileline_fn, int *found_sym, int *found_dwarf) +{ + struct backtrace_view fhdr_view; + off_t fhdr_off; + int magic_ok; + b_coff_file_header fhdr; + off_t opt_sects_off; + size_t opt_sects_size; + unsigned int sects_num; + struct backtrace_view sects_view; + int sects_view_valid; + const b_coff_optional_header *opt_hdr; + const b_coff_section_header *sects; + struct backtrace_view str_view; + int str_view_valid; + uint32_t str_size; + off_t str_off; + // NOTE: upstream doesn't have `{0}`, this is a fix for Rust issue #39468. + // If syms_view is not initialized, then `free(syms_view.base)` may segfault later. + struct backtrace_view syms_view = {0}; + off_t syms_off; + size_t syms_size; + int syms_view_valid; + unsigned int syms_num; + unsigned int i; + struct debug_section_info sections[DEBUG_MAX]; + off_t min_offset; + off_t max_offset; + struct backtrace_view debug_view; + int debug_view_valid; + uintptr_t image_base; + + *found_sym = 0; + *found_dwarf = 0; + + sects_view_valid = 0; + syms_view_valid = 0; + str_view_valid = 0; + debug_view_valid = 0; + + /* Map the MS-DOS stub (if any) and extract file header offset. */ + if (!backtrace_get_view (state, descriptor, 0, 0x40, error_callback, + data, &fhdr_view)) + goto fail; + + { + const unsigned char *vptr = fhdr_view.data; + + if (vptr[0] == 'M' && vptr[1] == 'Z') + fhdr_off = coff_read4 (vptr + 0x3c); + else + fhdr_off = 0; + } + + backtrace_release_view (state, &fhdr_view, error_callback, data); + + /* Map the coff file header. */ + if (!backtrace_get_view (state, descriptor, fhdr_off, + sizeof (b_coff_file_header) + 4, + error_callback, data, &fhdr_view)) + goto fail; + + if (fhdr_off != 0) + { + const char *magic = (const char *) fhdr_view.data; + magic_ok = memcmp (magic, "PE\0", 4) == 0; + fhdr_off += 4; + + memcpy (&fhdr, fhdr_view.data + 4, sizeof fhdr); + } + else + { + memcpy (&fhdr, fhdr_view.data, sizeof fhdr); + /* TODO: test fhdr.machine for coff but non-PE platforms. */ + magic_ok = 0; + } + backtrace_release_view (state, &fhdr_view, error_callback, data); + + if (!magic_ok) + { + error_callback (data, "executable file is not COFF", 0); + goto fail; + } + + sects_num = fhdr.number_of_sections; + syms_num = fhdr.number_of_symbols; + + opt_sects_off = fhdr_off + sizeof (fhdr); + opt_sects_size = (fhdr.size_of_optional_header + + sects_num * sizeof (b_coff_section_header)); + + /* To translate PC to file/line when using DWARF, we need to find + the .debug_info and .debug_line sections. */ + + /* Read the optional header and the section headers. */ + + if (!backtrace_get_view (state, descriptor, opt_sects_off, opt_sects_size, + error_callback, data, §s_view)) + goto fail; + sects_view_valid = 1; + opt_hdr = (const b_coff_optional_header *) sects_view.data; + sects = (const b_coff_section_header *) + (sects_view.data + fhdr.size_of_optional_header); + + if (fhdr.size_of_optional_header > sizeof (*opt_hdr)) + { + if (opt_hdr->magic == PE_MAGIC) + image_base = opt_hdr->u.pe.image_base; + else if (opt_hdr->magic == PEP_MAGIC) + image_base = opt_hdr->u.pep.image_base; + else + { + error_callback (data, "bad magic in PE optional header", 0); + goto fail; + } + } + else + image_base = 0; + + /* Read the symbol table and the string table. */ + + if (fhdr.pointer_to_symbol_table == 0) + { + /* No symbol table, no string table. */ + str_off = 0; + str_size = 0; + syms_num = 0; + syms_size = 0; + } + else + { + /* Symbol table is followed by the string table. The string table + starts with its length (on 4 bytes). + Map the symbol table and the length of the string table. */ + syms_off = fhdr.pointer_to_symbol_table; + syms_size = syms_num * SYM_SZ; + + if (!backtrace_get_view (state, descriptor, syms_off, syms_size + 4, + error_callback, data, &syms_view)) + goto fail; + syms_view_valid = 1; + + str_size = coff_read4 (syms_view.data + syms_size); + + str_off = syms_off + syms_size; + + if (str_size > 4) + { + /* Map string table (including the length word). */ + + if (!backtrace_get_view (state, descriptor, str_off, str_size, + error_callback, data, &str_view)) + goto fail; + str_view_valid = 1; + } + } + + memset (sections, 0, sizeof sections); + + /* Look for the symbol table. */ + for (i = 0; i < sects_num; ++i) + { + const b_coff_section_header *s = sects + i; + unsigned int str_off; + int j; + + if (s->name[0] == '/') + { + /* Extended section name. */ + str_off = atoi (s->name + 1); + } + else + str_off = 0; + + for (j = 0; j < (int) DEBUG_MAX; ++j) + { + const char *dbg_name = debug_section_names[j]; + int match; + + if (str_off != 0) + match = coff_long_name_eq (dbg_name, str_off, &str_view); + else + match = coff_short_name_eq (dbg_name, s->name); + if (match) + { + sections[j].offset = s->pointer_to_raw_data; + sections[j].size = s->virtual_size <= s->size_of_raw_data ? + s->virtual_size : s->size_of_raw_data; + break; + } + } + } + + if (syms_num != 0) + { + struct coff_syminfo_data *sdata; + + sdata = ((struct coff_syminfo_data *) + backtrace_alloc (state, sizeof *sdata, error_callback, data)); + if (sdata == NULL) + goto fail; + + if (!coff_initialize_syminfo (state, image_base, + sects, sects_num, + syms_view.data, syms_size, + str_view.data, str_size, + error_callback, data, sdata)) + { + backtrace_free (state, sdata, sizeof *sdata, error_callback, data); + goto fail; + } + + *found_sym = 1; + + coff_add_syminfo_data (state, sdata); + } + + backtrace_release_view (state, §s_view, error_callback, data); + sects_view_valid = 0; + if (syms_view_valid) + { + backtrace_release_view (state, &syms_view, error_callback, data); + syms_view_valid = 0; + } + + /* Read all the debug sections in a single view, since they are + probably adjacent in the file. We never release this view. */ + + min_offset = 0; + max_offset = 0; + for (i = 0; i < (int) DEBUG_MAX; ++i) + { + off_t end; + + if (sections[i].size == 0) + continue; + if (min_offset == 0 || sections[i].offset < min_offset) + min_offset = sections[i].offset; + end = sections[i].offset + sections[i].size; + if (end > max_offset) + max_offset = end; + } + if (min_offset == 0 || max_offset == 0) + { + if (!backtrace_close (descriptor, error_callback, data)) + goto fail; + *fileline_fn = coff_nodebug; + return 1; + } + + if (!backtrace_get_view (state, descriptor, min_offset, + max_offset - min_offset, + error_callback, data, &debug_view)) + goto fail; + debug_view_valid = 1; + + /* We've read all we need from the executable. */ + if (!backtrace_close (descriptor, error_callback, data)) + goto fail; + descriptor = -1; + + for (i = 0; i < (int) DEBUG_MAX; ++i) + { + if (sections[i].size == 0) + sections[i].data = NULL; + else + sections[i].data = ((const unsigned char *) debug_view.data + + (sections[i].offset - min_offset)); + } + + if (!backtrace_dwarf_add (state, /* base_address */ 0, + sections[DEBUG_INFO].data, + sections[DEBUG_INFO].size, + sections[DEBUG_LINE].data, + sections[DEBUG_LINE].size, + sections[DEBUG_ABBREV].data, + sections[DEBUG_ABBREV].size, + sections[DEBUG_RANGES].data, + sections[DEBUG_RANGES].size, + sections[DEBUG_STR].data, + sections[DEBUG_STR].size, + 0, /* FIXME */ + error_callback, data, fileline_fn)) + goto fail; + + *found_dwarf = 1; + + return 1; + + fail: + if (sects_view_valid) + backtrace_release_view (state, §s_view, error_callback, data); + if (str_view_valid) + backtrace_release_view (state, &str_view, error_callback, data); + if (syms_view_valid) + backtrace_release_view (state, &syms_view, error_callback, data); + if (debug_view_valid) + backtrace_release_view (state, &debug_view, error_callback, data); + if (descriptor != -1) + backtrace_close (descriptor, error_callback, data); + return 0; +} + +/* Initialize the backtrace data we need from an ELF executable. At + the ELF level, all we need to do is find the debug info + sections. */ + +int +backtrace_initialize (struct backtrace_state *state, + const char *filename ATTRIBUTE_UNUSED, int descriptor, + backtrace_error_callback error_callback, + void *data, fileline *fileline_fn) +{ + int ret; + int found_sym; + int found_dwarf; + fileline coff_fileline_fn; + + ret = coff_add (state, descriptor, error_callback, data, + &coff_fileline_fn, &found_sym, &found_dwarf); + if (!ret) + return 0; + + if (!state->threaded) + { + if (found_sym) + state->syminfo_fn = coff_syminfo; + else if (state->syminfo_fn == NULL) + state->syminfo_fn = coff_nosyms; + } + else + { + if (found_sym) + backtrace_atomic_store_pointer (&state->syminfo_fn, coff_syminfo); + else + __sync_bool_compare_and_swap (&state->syminfo_fn, NULL, coff_nosyms); + } + + if (!state->threaded) + { + if (state->fileline_fn == NULL || state->fileline_fn == coff_nodebug) + *fileline_fn = coff_fileline_fn; + } + else + { + fileline current_fn; + + current_fn = backtrace_atomic_load_pointer (&state->fileline_fn); + if (current_fn == NULL || current_fn == coff_nodebug) + *fileline_fn = coff_fileline_fn; + } + + return 1; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/posix.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/posix.c new file mode 100644 index 0000000..ce441d9 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/posix.c @@ -0,0 +1,100 @@ +/* posix.c -- POSIX file I/O routines for the backtrace library. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + +#ifndef FD_CLOEXEC +#define FD_CLOEXEC 1 +#endif + +/* Open a file for reading. */ + +int +backtrace_open (const char *filename, backtrace_error_callback error_callback, + void *data, int *does_not_exist) +{ + int descriptor; + + if (does_not_exist != NULL) + *does_not_exist = 0; + + descriptor = open (filename, (int) (O_RDONLY | O_BINARY | O_CLOEXEC)); + if (descriptor < 0) + { + if (does_not_exist != NULL && errno == ENOENT) + *does_not_exist = 1; + else + error_callback (data, filename, errno); + return -1; + } + +#ifdef HAVE_FCNTL + /* Set FD_CLOEXEC just in case the kernel does not support + O_CLOEXEC. It doesn't matter if this fails for some reason. + FIXME: At some point it should be safe to only do this if + O_CLOEXEC == 0. */ + fcntl (descriptor, F_SETFD, FD_CLOEXEC); +#endif + + return descriptor; +} + +/* Close DESCRIPTOR. */ + +int +backtrace_close (int descriptor, backtrace_error_callback error_callback, + void *data) +{ + if (close (descriptor) < 0) + { + error_callback (data, "close", errno); + return 0; + } + return 1; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/print.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/print.c new file mode 100644 index 0000000..3c6bad2 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/print.c @@ -0,0 +1,92 @@ +/* print.c -- Print the current backtrace. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +/* Passed to callbacks. */ + +struct print_data +{ + struct backtrace_state *state; + FILE *f; +}; + +/* Print one level of a backtrace. */ + +static int +print_callback (void *data, uintptr_t pc, const char *filename, int lineno, + const char *function) +{ + struct print_data *pdata = (struct print_data *) data; + + fprintf (pdata->f, "0x%lx %s\n\t%s:%d\n", + (unsigned long) pc, + function == NULL ? "???" : function, + filename == NULL ? "???" : filename, + lineno); + return 0; +} + +/* Print errors to stderr. */ + +static void +error_callback (void *data, const char *msg, int errnum) +{ + struct print_data *pdata = (struct print_data *) data; + + if (pdata->state->filename != NULL) + fprintf (stderr, "%s: ", pdata->state->filename); + fprintf (stderr, "libbacktrace: %s", msg); + if (errnum > 0) + fprintf (stderr, ": %s", strerror (errnum)); + fputc ('\n', stderr); +} + +/* Print a backtrace. */ + +void +backtrace_print (struct backtrace_state *state, int skip, FILE *f) +{ + struct print_data data; + + data.state = state; + data.f = f; + backtrace_full (state, skip + 1, print_callback, error_callback, + (void *) &data); +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/read.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/read.c new file mode 100644 index 0000000..211d645 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/read.c @@ -0,0 +1,96 @@ +/* read.c -- File views without mmap. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +/* This file implements file views when mmap is not available. */ + +/* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. */ + +int +backtrace_get_view (struct backtrace_state *state, int descriptor, + off_t offset, size_t size, + backtrace_error_callback error_callback, + void *data, struct backtrace_view *view) +{ + ssize_t got; + + if (lseek (descriptor, offset, SEEK_SET) < 0) + { + error_callback (data, "lseek", errno); + return 0; + } + + view->base = backtrace_alloc (state, size, error_callback, data); + if (view->base == NULL) + return 0; + view->data = view->base; + view->len = size; + + got = read (descriptor, view->base, size); + if (got < 0) + { + error_callback (data, "read", errno); + free (view->base); + return 0; + } + + if ((size_t) got < size) + { + error_callback (data, "file too short", 0); + free (view->base); + return 0; + } + + return 1; +} + +/* Release a view read by backtrace_get_view. */ + +void +backtrace_release_view (struct backtrace_state *state, + struct backtrace_view *view, + backtrace_error_callback error_callback, + void *data) +{ + backtrace_free (state, view->base, view->len, error_callback, data); + view->data = NULL; + view->base = NULL; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/simple.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/simple.c new file mode 100644 index 0000000..510877c --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/simple.c @@ -0,0 +1,108 @@ +/* simple.c -- The backtrace_simple function. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include "unwind.h" +#include "backtrace.h" + +/* The simple_backtrace routine. */ + +/* Data passed through _Unwind_Backtrace. */ + +struct backtrace_simple_data +{ + /* Number of frames to skip. */ + int skip; + /* Library state. */ + struct backtrace_state *state; + /* Callback routine. */ + backtrace_simple_callback callback; + /* Error callback routine. */ + backtrace_error_callback error_callback; + /* Data to pass to callback routine. */ + void *data; + /* Value to return from backtrace. */ + int ret; +}; + +/* Unwind library callback routine. This is passd to + _Unwind_Backtrace. */ + +static _Unwind_Reason_Code +simple_unwind (struct _Unwind_Context *context, void *vdata) +{ + struct backtrace_simple_data *bdata = (struct backtrace_simple_data *) vdata; + uintptr_t pc; + int ip_before_insn = 0; + +#ifdef HAVE_GETIPINFO + pc = _Unwind_GetIPInfo (context, &ip_before_insn); +#else + pc = _Unwind_GetIP (context); +#endif + + if (bdata->skip > 0) + { + --bdata->skip; + return _URC_NO_REASON; + } + + if (!ip_before_insn) + --pc; + + bdata->ret = bdata->callback (bdata->data, pc); + + if (bdata->ret != 0) + return _URC_END_OF_STACK; + + return _URC_NO_REASON; +} + +/* Get a simple stack backtrace. */ + +int +backtrace_simple (struct backtrace_state *state, int skip, + backtrace_simple_callback callback, + backtrace_error_callback error_callback, void *data) +{ + struct backtrace_simple_data bdata; + + bdata.skip = skip + 1; + bdata.state = state; + bdata.callback = callback; + bdata.error_callback = error_callback; + bdata.data = data; + bdata.ret = 0; + _Unwind_Backtrace (simple_unwind, &bdata); + return bdata.ret; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/sort.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/sort.c new file mode 100644 index 0000000..9121bcb --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/sort.c @@ -0,0 +1,108 @@ +/* sort.c -- Sort without allocating memory + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include + +#include "backtrace.h" +#include "internal.h" + +/* The GNU glibc version of qsort allocates memory, which we must not + do if we are invoked by a signal handler. So provide our own + sort. */ + +static void +swap (char *a, char *b, size_t size) +{ + size_t i; + + for (i = 0; i < size; i++, a++, b++) + { + char t; + + t = *a; + *a = *b; + *b = t; + } +} + +void +backtrace_qsort (void *basearg, size_t count, size_t size, + int (*compar) (const void *, const void *)) +{ + char *base = (char *) basearg; + size_t i; + size_t mid; + + tail_recurse: + if (count < 2) + return; + + /* The symbol table and DWARF tables, which is all we use this + routine for, tend to be roughly sorted. Pick the middle element + in the array as our pivot point, so that we are more likely to + cut the array in half for each recursion step. */ + swap (base, base + (count / 2) * size, size); + + mid = 0; + for (i = 1; i < count; i++) + { + if ((*compar) (base, base + i * size) > 0) + { + ++mid; + if (i != mid) + swap (base + mid * size, base + i * size, size); + } + } + + if (mid > 0) + swap (base, base + mid * size, size); + + /* Recurse with the smaller array, loop with the larger one. That + ensures that our maximum stack depth is log count. */ + if (2 * mid < count) + { + backtrace_qsort (base, mid, size, compar); + base += (mid + 1) * size; + count -= mid + 1; + goto tail_recurse; + } + else + { + backtrace_qsort (base + (mid + 1) * size, count - (mid + 1), + size, compar); + count = mid; + goto tail_recurse; + } +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/state.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/state.c new file mode 100644 index 0000000..ad360a6 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/state.c @@ -0,0 +1,72 @@ +/* state.c -- Create the backtrace state. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include + +#include "backtrace.h" +#include "backtrace-supported.h" +#include "internal.h" + +/* Create the backtrace state. This will then be passed to all the + other routines. */ + +struct backtrace_state * +backtrace_create_state (const char *filename, int threaded, + backtrace_error_callback error_callback, + void *data) +{ + struct backtrace_state init_state; + struct backtrace_state *state; + +#ifndef HAVE_SYNC_FUNCTIONS + if (threaded) + { + error_callback (data, "backtrace library does not support threads", 0); + return NULL; + } +#endif + + memset (&init_state, 0, sizeof init_state); + init_state.filename = filename; + init_state.threaded = threaded; + + state = ((struct backtrace_state *) + backtrace_alloc (&init_state, sizeof *state, error_callback, data)); + if (state == NULL) + return NULL; + *state = init_state; + + return state; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/stest.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/stest.c new file mode 100644 index 0000000..2eb9880 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/stest.c @@ -0,0 +1,137 @@ +/* stest.c -- Test for libbacktrace internal sort function + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include + +#include "backtrace.h" +#include "internal.h" + +/* Test the local qsort implementation. */ + +#define MAX 10 + +struct test +{ + size_t count; + int input[MAX]; + int output[MAX]; +}; + +static struct test tests[] = + { + { + 10, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } + }, + { + 9, + { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9 } + }, + { + 10, + { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, + }, + { + 9, + { 9, 8, 7, 6, 5, 4, 3, 2, 1 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, + }, + { + 10, + { 2, 4, 6, 8, 10, 1, 3, 5, 7, 9 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, + }, + { + 5, + { 4, 5, 3, 1, 2 }, + { 1, 2, 3, 4, 5 }, + }, + { + 5, + { 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1 }, + }, + { + 5, + { 1, 1, 2, 1, 1 }, + { 1, 1, 1, 1, 2 }, + }, + { + 5, + { 2, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 2 }, + }, + }; + +static int +compare (const void *a, const void *b) +{ + const int *ai = (const int *) a; + const int *bi = (const int *) b; + + return *ai - *bi; +} + +int +main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) +{ + int failures; + size_t i; + int a[MAX]; + + failures = 0; + for (i = 0; i < sizeof tests / sizeof tests[0]; i++) + { + memcpy (a, tests[i].input, tests[i].count * sizeof (int)); + backtrace_qsort (a, tests[i].count, sizeof (int), compare); + if (memcmp (a, tests[i].output, tests[i].count * sizeof (int)) != 0) + { + size_t j; + + fprintf (stderr, "test %d failed:", (int) i); + for (j = 0; j < tests[i].count; j++) + fprintf (stderr, " %d", a[j]); + fprintf (stderr, "\n"); + ++failures; + } + } + + exit (failures > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/testlib.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/testlib.c new file mode 100644 index 0000000..6dbef7c --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/testlib.c @@ -0,0 +1,234 @@ +/* testlib.c -- test functions for libbacktrace library + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include +#include +#include +#include + +#include "filenames.h" + +#include "backtrace.h" + +#include "testlib.h" + +/* The backtrace state. */ + +void *state; + +/* The number of failures. */ + +int failures; + +/* Return the base name in a path. */ + +const char * +base (const char *p) +{ + const char *last; + const char *s; + + last = NULL; + for (s = p; *s != '\0'; ++s) + { + if (IS_DIR_SEPARATOR (*s)) + last = s + 1; + } + return last != NULL ? last : p; +} + +/* Check an entry in a struct info array. */ + +void +check (const char *name, int index, const struct info *all, int want_lineno, + const char *want_function, const char *want_file, int *failed) +{ + if (*failed) + return; + if (all[index].filename == NULL || all[index].function == NULL) + { + fprintf (stderr, "%s: [%d]: missing file name or function name\n", + name, index); + *failed = 1; + return; + } + if (strcmp (base (all[index].filename), want_file) != 0) + { + fprintf (stderr, "%s: [%d]: got %s expected %s\n", name, index, + all[index].filename, want_file); + *failed = 1; + } + if (all[index].lineno != want_lineno) + { + fprintf (stderr, "%s: [%d]: got %d expected %d\n", name, index, + all[index].lineno, want_lineno); + *failed = 1; + } + if (strcmp (all[index].function, want_function) != 0) + { + fprintf (stderr, "%s: [%d]: got %s expected %s\n", name, index, + all[index].function, want_function); + *failed = 1; + } +} + +/* The backtrace callback function. */ + +int +callback_one (void *vdata, uintptr_t pc ATTRIBUTE_UNUSED, + const char *filename, int lineno, const char *function) +{ + struct bdata *data = (struct bdata *) vdata; + struct info *p; + + if (data->index >= data->max) + { + fprintf (stderr, "callback_one: callback called too many times\n"); + data->failed = 1; + return 1; + } + + p = &data->all[data->index]; + if (filename == NULL) + p->filename = NULL; + else + { + p->filename = strdup (filename); + assert (p->filename != NULL); + } + p->lineno = lineno; + if (function == NULL) + p->function = NULL; + else + { + p->function = strdup (function); + assert (p->function != NULL); + } + ++data->index; + + return 0; +} + +/* An error callback passed to backtrace. */ + +void +error_callback_one (void *vdata, const char *msg, int errnum) +{ + struct bdata *data = (struct bdata *) vdata; + + fprintf (stderr, "%s", msg); + if (errnum > 0) + fprintf (stderr, ": %s", strerror (errnum)); + fprintf (stderr, "\n"); + data->failed = 1; +} + +/* The backtrace_simple callback function. */ + +int +callback_two (void *vdata, uintptr_t pc) +{ + struct sdata *data = (struct sdata *) vdata; + + if (data->index >= data->max) + { + fprintf (stderr, "callback_two: callback called too many times\n"); + data->failed = 1; + return 1; + } + + data->addrs[data->index] = pc; + ++data->index; + + return 0; +} + +/* An error callback passed to backtrace_simple. */ + +void +error_callback_two (void *vdata, const char *msg, int errnum) +{ + struct sdata *data = (struct sdata *) vdata; + + fprintf (stderr, "%s", msg); + if (errnum > 0) + fprintf (stderr, ": %s", strerror (errnum)); + fprintf (stderr, "\n"); + data->failed = 1; +} + +/* The backtrace_syminfo callback function. */ + +void +callback_three (void *vdata, uintptr_t pc ATTRIBUTE_UNUSED, + const char *symname, uintptr_t symval, + uintptr_t symsize) +{ + struct symdata *data = (struct symdata *) vdata; + + if (symname == NULL) + data->name = NULL; + else + { + data->name = strdup (symname); + assert (data->name != NULL); + } + data->val = symval; + data->size = symsize; +} + +/* The backtrace_syminfo error callback function. */ + +void +error_callback_three (void *vdata, const char *msg, int errnum) +{ + struct symdata *data = (struct symdata *) vdata; + + fprintf (stderr, "%s", msg); + if (errnum > 0) + fprintf (stderr, ": %s", strerror (errnum)); + fprintf (stderr, "\n"); + data->failed = 1; +} + +/* The backtrace_create_state error callback function. */ + +void +error_callback_create (void *data ATTRIBUTE_UNUSED, const char *msg, + int errnum) +{ + fprintf (stderr, "%s", msg); + if (errnum > 0) + fprintf (stderr, ": %s", strerror (errnum)); + fprintf (stderr, "\n"); + exit (EXIT_FAILURE); +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/testlib.h b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/testlib.h new file mode 100644 index 0000000..5094656 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/testlib.h @@ -0,0 +1,110 @@ +/* testlib.h -- Header for test functions for libbacktrace library + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#ifndef LIBBACKTRACE_TESTLIB_H +#define LIBBACKTRACE_TESTLIB_H + +/* Portable attribute syntax. Actually some of these tests probably + won't work if the attributes are not recognized. */ + +#ifndef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) +#endif + +#if (GCC_VERSION < 2007) +# define __attribute__(x) +#endif + +#ifndef ATTRIBUTE_UNUSED +# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif + +/* Used to collect backtrace info. */ + +struct info +{ + char *filename; + int lineno; + char *function; +}; + +/* Passed to backtrace callback function. */ + +struct bdata +{ + struct info *all; + size_t index; + size_t max; + int failed; +}; + +/* Passed to backtrace_simple callback function. */ + +struct sdata +{ + uintptr_t *addrs; + size_t index; + size_t max; + int failed; +}; + +/* Passed to backtrace_syminfo callback function. */ + +struct symdata +{ + const char *name; + uintptr_t val, size; + int failed; +}; + +/* The backtrace state. */ + +extern void *state; + +/* The number of failures. */ + +extern int failures; + +extern const char *base (const char *p); +extern void check (const char *name, int index, const struct info *all, + int want_lineno, const char *want_function, + const char *want_file, int *failed); +extern int callback_one (void *, uintptr_t, const char *, int, const char *); +extern void error_callback_one (void *, const char *, int); +extern int callback_two (void *, uintptr_t); +extern void error_callback_two (void *, const char *, int); +extern void callback_three (void *, uintptr_t, const char *, uintptr_t, + uintptr_t); +extern void error_callback_three (void *, const char *, int); +extern void error_callback_create (void *, const char *, int); + +#endif /* !defined(LIBBACKTRACE_TESTLIB_H) */ diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/ttest.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/ttest.c new file mode 100644 index 0000000..ca55e9b --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/ttest.c @@ -0,0 +1,161 @@ +/* ttest.c -- Test for libbacktrace library + Copyright (C) 2017-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +/* Test using the libbacktrace library from multiple threads. */ + +#include +#include +#include +#include + +#include + +#include "filenames.h" + +#include "backtrace.h" +#include "backtrace-supported.h" + +#include "testlib.h" + +static int f2 (int) __attribute__ ((noinline)); +static int f3 (int, int) __attribute__ ((noinline)); + +/* Test that a simple backtrace works. This is called via + pthread_create. It returns the number of failures, as void *. */ + +static void * +test1_thread (void *arg ATTRIBUTE_UNUSED) +{ + /* Returning a value here and elsewhere avoids a tailcall which + would mess up the backtrace. */ + return (void *) (uintptr_t) (f2 (__LINE__) - 2); +} + +static int +f2 (int f1line) +{ + return f3 (f1line, __LINE__) + 2; +} + +static int +f3 (int f1line, int f2line) +{ + struct info all[20]; + struct bdata data; + int f3line; + int i; + + data.all = &all[0]; + data.index = 0; + data.max = 20; + data.failed = 0; + + f3line = __LINE__ + 1; + i = backtrace_full (state, 0, callback_one, error_callback_one, &data); + + if (i != 0) + { + fprintf (stderr, "test1: unexpected return value %d\n", i); + data.failed = 1; + } + + if (data.index < 3) + { + fprintf (stderr, + "test1: not enough frames; got %zu, expected at least 3\n", + data.index); + data.failed = 1; + } + + check ("test1", 0, all, f3line, "f3", "ttest.c", &data.failed); + check ("test1", 1, all, f2line, "f2", "ttest.c", &data.failed); + check ("test1", 2, all, f1line, "test1_thread", "ttest.c", &data.failed); + + return data.failed; +} + +/* Run the test with 10 threads simultaneously. */ + +#define THREAD_COUNT 10 + +static void test1 (void) __attribute__ ((unused)); + +static void +test1 (void) +{ + pthread_t atid[THREAD_COUNT]; + int i; + int errnum; + int this_fail; + void *ret; + + for (i = 0; i < THREAD_COUNT; i++) + { + errnum = pthread_create (&atid[i], NULL, test1_thread, NULL); + if (errnum != 0) + { + fprintf (stderr, "pthread_create %d: %s\n", i, strerror (errnum)); + exit (EXIT_FAILURE); + } + } + + this_fail = 0; + for (i = 0; i < THREAD_COUNT; i++) + { + errnum = pthread_join (atid[i], &ret); + if (errnum != 0) + { + fprintf (stderr, "pthread_join %d: %s\n", i, strerror (errnum)); + exit (EXIT_FAILURE); + } + this_fail += (int) (uintptr_t) ret; + } + + printf ("%s: threaded backtrace_full noinline\n", this_fail > 0 ? "FAIL" : "PASS"); + + failures += this_fail; +} + +int +main (int argc ATTRIBUTE_UNUSED, char **argv) +{ + state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS, + error_callback_create, NULL); + +#if BACKTRACE_SUPPORTED +#if BACKTRACE_SUPPORTS_THREADS + test1 (); +#endif +#endif + + exit (failures ? EXIT_FAILURE : EXIT_SUCCESS); +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/unknown.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/unknown.c new file mode 100644 index 0000000..be521a8 --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/unknown.c @@ -0,0 +1,65 @@ +/* unknown.c -- used when backtrace configury does not know file format. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include + +#include "backtrace.h" +#include "internal.h" + +/* A trivial routine that always fails to find fileline data. */ + +static int +unknown_fileline (struct backtrace_state *state ATTRIBUTE_UNUSED, + uintptr_t pc, backtrace_full_callback callback, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data) + +{ + return callback (data, pc, NULL, 0, NULL); +} + +/* Initialize the backtrace data when we don't know how to read the + debug info. */ + +int +backtrace_initialize (struct backtrace_state *state ATTRIBUTE_UNUSED, + const char *filename ATTRIBUTE_UNUSED, + int descriptor ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data ATTRIBUTE_UNUSED, fileline *fileline_fn) +{ + state->fileline_data = NULL; + *fileline_fn = unknown_fileline; + return 1; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/xcoff.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/xcoff.c new file mode 100644 index 0000000..1ae001d --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/xcoff.c @@ -0,0 +1,1642 @@ +/* xcoff.c -- Get debug data from an XCOFF file for backtraces. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + Adapted from elf.c. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include + +#ifdef HAVE_LOADQUERY +#include +#endif + +#include "backtrace.h" +#include "internal.h" + +/* The configure script must tell us whether we are 32-bit or 64-bit + XCOFF. We could make this code test and support either possibility, + but there is no point. This code only works for the currently + running executable, which means that we know the XCOFF mode at + configure time. */ + +#if BACKTRACE_XCOFF_SIZE != 32 && BACKTRACE_XCOFF_SIZE != 64 +#error "Unknown BACKTRACE_XCOFF_SIZE" +#endif + +/* XCOFF file header. */ + +#if BACKTRACE_XCOFF_SIZE == 32 + +typedef struct { + uint16_t f_magic; + uint16_t f_nscns; + uint32_t f_timdat; + uint32_t f_symptr; + uint32_t f_nsyms; + uint16_t f_opthdr; + uint16_t f_flags; +} b_xcoff_filhdr; + +#define XCOFF_MAGIC 0737 + +#else /* BACKTRACE_XCOFF_SIZE != 32 */ + +typedef struct { + uint16_t f_magic; + uint16_t f_nscns; + uint32_t f_timdat; + uint64_t f_symptr; + uint16_t f_opthdr; + uint16_t f_flags; + uint32_t f_nsyms; +} b_xcoff_filhdr; + +#define XCOFF_MAGIC 0767 + +#endif /* BACKTRACE_XCOFF_SIZE != 32 */ + +#define F_SHROBJ 0x2000 /* File is a shared object. */ + +/* XCOFF section header. */ + +#if BACKTRACE_XCOFF_SIZE == 32 + +typedef struct { + char s_name[8]; + uint32_t s_paddr; + uint32_t s_vaddr; + uint32_t s_size; + uint32_t s_scnptr; + uint32_t s_relptr; + uint32_t s_lnnoptr; + uint16_t s_nreloc; + uint16_t s_nlnno; + uint32_t s_flags; +} b_xcoff_scnhdr; + +#define _OVERFLOW_MARKER 65535 + +#else /* BACKTRACE_XCOFF_SIZE != 32 */ + +typedef struct { + char name[8]; + uint64_t s_paddr; + uint64_t s_vaddr; + uint64_t s_size; + uint64_t s_scnptr; + uint64_t s_relptr; + uint64_t s_lnnoptr; + uint32_t s_nreloc; + uint32_t s_nlnno; + uint32_t s_flags; +} b_xcoff_scnhdr; + +#endif /* BACKTRACE_XCOFF_SIZE != 32 */ + +#define STYP_DWARF 0x10 /* DWARF debugging section. */ +#define STYP_TEXT 0x20 /* Executable text (code) section. */ +#define STYP_OVRFLO 0x8000 /* Line-number field overflow section. */ + +#define SSUBTYP_DWINFO 0x10000 /* DWARF info section. */ +#define SSUBTYP_DWLINE 0x20000 /* DWARF line-number section. */ +#define SSUBTYP_DWARNGE 0x50000 /* DWARF aranges section. */ +#define SSUBTYP_DWABREV 0x60000 /* DWARF abbreviation section. */ +#define SSUBTYP_DWSTR 0x70000 /* DWARF strings section. */ + +/* XCOFF symbol. */ + +#define SYMNMLEN 8 + +#if BACKTRACE_XCOFF_SIZE == 32 + +typedef struct { + union { + char _name[SYMNMLEN]; + struct { + uint32_t _zeroes; + uint32_t _offset; + } _s; + } _u; +#define n_name _u._name +#define n_zeroes _u._s._zeroes +#define n_offset_ _u._s._offset + + uint32_t n_value; + int16_t n_scnum; + uint16_t n_type; + uint8_t n_sclass; + uint8_t n_numaux; +} __attribute__ ((packed)) b_xcoff_syment; + +#else /* BACKTRACE_XCOFF_SIZE != 32 */ + +typedef struct { + uint64_t n_value; + uint32_t n_offset_; + int16_t n_scnum; + uint16_t n_type; + uint8_t n_sclass; + uint8_t n_numaux; +} __attribute__ ((packed)) b_xcoff_syment; + +#endif /* BACKTRACE_XCOFF_SIZE != 32 */ + +#define SYMESZ 18 + +#define C_EXT 2 /* External symbol. */ +#define C_FCN 101 /* Beginning or end of function. */ +#define C_FILE 103 /* Source file name. */ +#define C_HIDEXT 107 /* Unnamed external symbol. */ +#define C_BINCL 108 /* Beginning of include file. */ +#define C_EINCL 109 /* End of include file. */ +#define C_WEAKEXT 111 /* Weak external symbol. */ + +#define ISFCN(x) ((x) & 0x0020) + +/* XCOFF AUX entry. */ + +#define AUXESZ 18 +#define FILNMLEN 14 + +typedef union { +#if BACKTRACE_XCOFF_SIZE == 32 + struct { + uint16_t pad; + uint16_t x_lnnohi; + uint16_t x_lnno; + } x_block; +#else + struct { + uint32_t x_lnno; + } x_block; +#endif + union { + char x_fname[FILNMLEN]; + struct { + uint32_t x_zeroes; + uint32_t x_offset; + char pad[FILNMLEN-8]; + uint8_t x_ftype; + } _x; + } x_file; +#if BACKTRACE_XCOFF_SIZE == 32 + struct { + uint32_t x_exptr; + uint32_t x_fsize; + uint32_t x_lnnoptr; + uint32_t x_endndx; + } x_fcn; +#else + struct { + uint64_t x_lnnoptr; + uint32_t x_fsize; + uint32_t x_endndx; + } x_fcn; +#endif + struct { + uint8_t pad[AUXESZ-1]; + uint8_t x_auxtype; + } x_auxtype; +} __attribute__ ((packed)) b_xcoff_auxent; + +/* XCOFF line number entry. */ + +#if BACKTRACE_XCOFF_SIZE == 32 + +typedef struct { + union { + uint32_t l_symndx; + uint32_t l_paddr; + } l_addr; + uint16_t l_lnno; +} b_xcoff_lineno; + +#define LINESZ 6 + +#else /* BACKTRACE_XCOFF_SIZE != 32 */ + +typedef struct { + union { + uint32_t l_symndx; + uint64_t l_paddr; + } l_addr; + uint32_t l_lnno; +} b_xcoff_lineno; + +#define LINESZ 12 + +#endif /* BACKTRACE_XCOFF_SIZE != 32 */ + +#if BACKTRACE_XCOFF_SIZE == 32 +#define XCOFF_AIX_TEXTBASE 0x10000000u +#else +#define XCOFF_AIX_TEXTBASE 0x100000000ul +#endif + +/* AIX big archive fixed-length header. */ + +#define AIAMAGBIG "\n" + +typedef struct { + char fl_magic[8]; /* Archive magic string. */ + char fl_memoff[20]; /* Offset to member table. */ + char fl_gstoff[20]; /* Offset to global symbol table. */ + char fl_gst64off[20]; /* Offset to global symbol table for 64-bit objects. */ + char fl_fstmoff[20]; /* Offset to first archive member. */ + char fl_freeoff[20]; /* Offset to first member on free list. */ +} b_ar_fl_hdr; + +/* AIX big archive file member header. */ + +typedef struct { + char ar_size[20]; /* File member size - decimal. */ + char ar_nxtmem[20]; /* Next member offset - decimal. */ + char ar_prvmem[20]; /* Previous member offset - decimal. */ + char ar_date[12]; /* File member date - decimal. */ + char ar_uid[12]; /* File member userid - decimal. */ + char ar_gid[12]; /* File member group id - decimal. */ + char ar_mode[12]; /* File member mode - octal. */ + char ar_namlen[4]; /* File member name length - decimal. */ + char ar_name[2]; /* Start of member name. */ +} b_ar_hdr; + + +/* Information we keep for an XCOFF symbol. */ + +struct xcoff_symbol +{ + /* The name of the symbol. */ + const char *name; + /* The address of the symbol. */ + uintptr_t address; + /* The size of the symbol. */ + size_t size; +}; + +/* Information to pass to xcoff_syminfo. */ + +struct xcoff_syminfo_data +{ + /* Symbols for the next module. */ + struct xcoff_syminfo_data *next; + /* The XCOFF symbols, sorted by address. */ + struct xcoff_symbol *symbols; + /* The number of symbols. */ + size_t count; +}; + +/* Information about an include file. */ + +struct xcoff_incl +{ + /* File name. */ + const char *filename; + /* Offset to first line number from the include file. */ + uintptr_t begin; + /* Offset to last line number from the include file. */ + uintptr_t end; +}; + +/* A growable vector of include files information. */ + +struct xcoff_incl_vector +{ + /* Memory. This is an array of struct xcoff_incl. */ + struct backtrace_vector vec; + /* Number of include files. */ + size_t count; +}; + +/* Map a single PC value to a file/function/line. */ + +struct xcoff_line +{ + /* PC. */ + uintptr_t pc; + /* File name. Many entries in the array are expected to point to + the same file name. */ + const char *filename; + /* Function name. */ + const char *function; + /* Line number. */ + int lineno; +}; + +/* A growable vector of line number information. This is used while + reading the line numbers. */ + +struct xcoff_line_vector +{ + /* Memory. This is an array of struct xcoff_line. */ + struct backtrace_vector vec; + /* Number of valid mappings. */ + size_t count; +}; + +/* The information we need to map a PC to a file and line. */ + +struct xcoff_fileline_data +{ + /* The data for the next file we know about. */ + struct xcoff_fileline_data *next; + /* Line number information. */ + struct xcoff_line_vector vec; +}; + +/* An index of DWARF sections we care about. */ + +enum dwarf_section +{ + DWSECT_INFO, + DWSECT_LINE, + DWSECT_ABBREV, + DWSECT_RANGES, + DWSECT_STR, + DWSECT_MAX +}; + +/* Information we gather for the DWARF sections we care about. */ + +struct dwsect_info +{ + /* Section file offset. */ + off_t offset; + /* Section size. */ + size_t size; + /* Section contents, after read from file. */ + const unsigned char *data; +}; + +/* A dummy callback function used when we can't find any debug info. */ + +static int +xcoff_nodebug (struct backtrace_state *state ATTRIBUTE_UNUSED, + uintptr_t pc ATTRIBUTE_UNUSED, + backtrace_full_callback callback ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, void *data) +{ + error_callback (data, "no debug info in XCOFF executable", -1); + return 0; +} + +/* A dummy callback function used when we can't find a symbol + table. */ + +static void +xcoff_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED, + uintptr_t addr ATTRIBUTE_UNUSED, + backtrace_syminfo_callback callback ATTRIBUTE_UNUSED, + backtrace_error_callback error_callback, void *data) +{ + error_callback (data, "no symbol table in XCOFF executable", -1); +} + +/* Compare struct xcoff_symbol for qsort. */ + +static int +xcoff_symbol_compare (const void *v1, const void *v2) +{ + const struct xcoff_symbol *e1 = (const struct xcoff_symbol *) v1; + const struct xcoff_symbol *e2 = (const struct xcoff_symbol *) v2; + + if (e1->address < e2->address) + return -1; + else if (e1->address > e2->address) + return 1; + else + return 0; +} + +/* Compare an ADDR against an xcoff_symbol for bsearch. */ + +static int +xcoff_symbol_search (const void *vkey, const void *ventry) +{ + const uintptr_t *key = (const uintptr_t *) vkey; + const struct xcoff_symbol *entry = (const struct xcoff_symbol *) ventry; + uintptr_t addr; + + addr = *key; + if (addr < entry->address) + return -1; + else if ((entry->size == 0 && addr > entry->address) + || (entry->size > 0 && addr >= entry->address + entry->size)) + return 1; + else + return 0; +} + +/* Add XDATA to the list in STATE. */ + +static void +xcoff_add_syminfo_data (struct backtrace_state *state, + struct xcoff_syminfo_data *xdata) +{ + if (!state->threaded) + { + struct xcoff_syminfo_data **pp; + + for (pp = (struct xcoff_syminfo_data **) (void *) &state->syminfo_data; + *pp != NULL; + pp = &(*pp)->next) + ; + *pp = xdata; + } + else + { + while (1) + { + struct xcoff_syminfo_data **pp; + + pp = (struct xcoff_syminfo_data **) (void *) &state->syminfo_data; + + while (1) + { + struct xcoff_syminfo_data *p; + + p = backtrace_atomic_load_pointer (pp); + + if (p == NULL) + break; + + pp = &p->next; + } + + if (__sync_bool_compare_and_swap (pp, NULL, xdata)) + break; + } + } +} + +/* Return the symbol name and value for an ADDR. */ + +static void +xcoff_syminfo (struct backtrace_state *state ATTRIBUTE_UNUSED, uintptr_t addr, + backtrace_syminfo_callback callback, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data) +{ + struct xcoff_syminfo_data *edata; + struct xcoff_symbol *sym = NULL; + + if (!state->threaded) + { + for (edata = (struct xcoff_syminfo_data *) state->syminfo_data; + edata != NULL; + edata = edata->next) + { + sym = ((struct xcoff_symbol *) + bsearch (&addr, edata->symbols, edata->count, + sizeof (struct xcoff_symbol), xcoff_symbol_search)); + if (sym != NULL) + break; + } + } + else + { + struct xcoff_syminfo_data **pp; + + pp = (struct xcoff_syminfo_data **) (void *) &state->syminfo_data; + while (1) + { + edata = backtrace_atomic_load_pointer (pp); + if (edata == NULL) + break; + + sym = ((struct xcoff_symbol *) + bsearch (&addr, edata->symbols, edata->count, + sizeof (struct xcoff_symbol), xcoff_symbol_search)); + if (sym != NULL) + break; + + pp = &edata->next; + } + } + + if (sym == NULL) + callback (data, addr, NULL, 0, 0); + else + callback (data, addr, sym->name, sym->address, sym->size); +} + +/* Return the name of an XCOFF symbol. */ + +static const char * +xcoff_symname (const b_xcoff_syment *asym, + const unsigned char *strtab, size_t strtab_size) +{ +#if BACKTRACE_XCOFF_SIZE == 32 + if (asym->n_zeroes != 0) + { + /* Make a copy as we will release the symtab view. */ + char name[SYMNMLEN+1]; + strncpy (name, asym->n_name, SYMNMLEN); + name[SYMNMLEN] = '\0'; + return strdup (name); + } +#endif + if (asym->n_sclass & 0x80) + return NULL; /* .debug */ + if (asym->n_offset_ >= strtab_size) + return NULL; + return (const char *) strtab + asym->n_offset_; +} + +/* Initialize the symbol table info for xcoff_syminfo. */ + +static int +xcoff_initialize_syminfo (struct backtrace_state *state, + uintptr_t base_address, + const b_xcoff_scnhdr *sects, + const b_xcoff_syment *syms, size_t nsyms, + const unsigned char *strtab, size_t strtab_size, + backtrace_error_callback error_callback, void *data, + struct xcoff_syminfo_data *sdata) +{ + size_t xcoff_symbol_count; + size_t xcoff_symbol_size; + struct xcoff_symbol *xcoff_symbols; + size_t i; + unsigned int j; + + /* We only care about function symbols. Count them. */ + xcoff_symbol_count = 0; + for (i = 0; i < nsyms; ++i) + { + const b_xcoff_syment *asym = &syms[i]; + if ((asym->n_sclass == C_EXT || asym->n_sclass == C_HIDEXT + || asym->n_sclass == C_WEAKEXT) + && ISFCN (asym->n_type) && asym->n_numaux > 0 && asym->n_scnum > 0) + ++xcoff_symbol_count; + + i += asym->n_numaux; + } + + xcoff_symbol_size = xcoff_symbol_count * sizeof (struct xcoff_symbol); + xcoff_symbols = ((struct xcoff_symbol *) + backtrace_alloc (state, xcoff_symbol_size, error_callback, + data)); + if (xcoff_symbols == NULL) + return 0; + + j = 0; + for (i = 0; i < nsyms; ++i) + { + const b_xcoff_syment *asym = &syms[i]; + if ((asym->n_sclass == C_EXT || asym->n_sclass == C_HIDEXT + || asym->n_sclass == C_WEAKEXT) + && ISFCN (asym->n_type) && asym->n_numaux > 0 && asym->n_scnum > 0) + { + const b_xcoff_auxent *aux = (const b_xcoff_auxent *) (asym + 1); + xcoff_symbols[j].name = xcoff_symname (asym, strtab, strtab_size); + xcoff_symbols[j].address = base_address + asym->n_value + - sects[asym->n_scnum - 1].s_paddr; + /* x_fsize will be 0 if there is no debug information. */ + xcoff_symbols[j].size = aux->x_fcn.x_fsize; + ++j; + } + + i += asym->n_numaux; + } + + backtrace_qsort (xcoff_symbols, xcoff_symbol_count, + sizeof (struct xcoff_symbol), xcoff_symbol_compare); + + sdata->next = NULL; + sdata->symbols = xcoff_symbols; + sdata->count = xcoff_symbol_count; + + return 1; +} + +/* Compare struct xcoff_line for qsort. */ + +static int +xcoff_line_compare (const void *v1, const void *v2) +{ + const struct xcoff_line *ln1 = (const struct xcoff_line *) v1; + const struct xcoff_line *ln2 = (const struct xcoff_line *) v2; + + if (ln1->pc < ln2->pc) + return -1; + else if (ln1->pc > ln2->pc) + return 1; + else + return 0; +} + +/* Find a PC in a line vector. We always allocate an extra entry at + the end of the lines vector, so that this routine can safely look + at the next entry. */ + +static int +xcoff_line_search (const void *vkey, const void *ventry) +{ + const uintptr_t *key = (const uintptr_t *) vkey; + const struct xcoff_line *entry = (const struct xcoff_line *) ventry; + uintptr_t pc; + + pc = *key; + if (pc < entry->pc) + return -1; + else if ((entry + 1)->pc == (uintptr_t) -1 || pc >= (entry + 1)->pc) + return 1; + else + return 0; +} + +/* Look for a PC in the line vector for one module. On success, + call CALLBACK and return whatever it returns. On error, call + ERROR_CALLBACK and return 0. Sets *FOUND to 1 if the PC is found, + 0 if not. */ + +static int +xcoff_lookup_pc (struct backtrace_state *state ATTRIBUTE_UNUSED, + struct xcoff_fileline_data *fdata, uintptr_t pc, + backtrace_full_callback callback, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data, int *found) +{ + const struct xcoff_line *ln; + const char *function; + + *found = 1; + + ln = (struct xcoff_line *) bsearch (&pc, fdata->vec.vec.base, + fdata->vec.count, + sizeof (struct xcoff_line), + xcoff_line_search); + if (ln == NULL) + { + *found = 0; + return 0; + } + + function = ln->function; + /* AIX prepends a '.' to function entry points, remove it. */ + if (*function == '.') + ++function; + return callback (data, pc, ln->filename, ln->lineno, function); +} + +/* Return the file/line information for a PC using the XCOFF lineno + mapping we built earlier. */ + +static int +xcoff_fileline (struct backtrace_state *state, uintptr_t pc, + backtrace_full_callback callback, + backtrace_error_callback error_callback, void *data) + +{ + struct xcoff_fileline_data *fdata; + int found; + int ret; + + if (!state->threaded) + { + for (fdata = (struct xcoff_fileline_data *) state->fileline_data; + fdata != NULL; + fdata = fdata->next) + { + ret = xcoff_lookup_pc (state, fdata, pc, callback, error_callback, + data, &found); + if (ret != 0 || found) + return ret; + } + } + else + { + struct xcoff_fileline_data **pp; + + pp = (struct xcoff_fileline_data **) (void *) &state->fileline_data; + while (1) + { + fdata = backtrace_atomic_load_pointer (pp); + if (fdata == NULL) + break; + + ret = xcoff_lookup_pc (state, fdata, pc, callback, error_callback, + data, &found); + if (ret != 0 || found) + return ret; + + pp = &fdata->next; + } + } + + /* FIXME: See if any libraries have been dlopen'ed. */ + + return callback (data, pc, NULL, 0, NULL); +} + +/* Compare struct xcoff_incl for qsort. */ + +static int +xcoff_incl_compare (const void *v1, const void *v2) +{ + const struct xcoff_incl *in1 = (const struct xcoff_incl *) v1; + const struct xcoff_incl *in2 = (const struct xcoff_incl *) v2; + + if (in1->begin < in2->begin) + return -1; + else if (in1->begin > in2->begin) + return 1; + else + return 0; +} + +/* Find a lnnoptr in an include file. */ + +static int +xcoff_incl_search (const void *vkey, const void *ventry) +{ + const uintptr_t *key = (const uintptr_t *) vkey; + const struct xcoff_incl *entry = (const struct xcoff_incl *) ventry; + uintptr_t lnno; + + lnno = *key; + if (lnno < entry->begin) + return -1; + else if (lnno > entry->end) + return 1; + else + return 0; +} + +/* Add a new mapping to the vector of line mappings that we are + building. Returns 1 on success, 0 on failure. */ + +static int +xcoff_add_line (struct backtrace_state *state, uintptr_t pc, + const char *filename, const char *function, uint32_t lnno, + backtrace_error_callback error_callback, void *data, + struct xcoff_line_vector *vec) +{ + struct xcoff_line *ln; + + ln = ((struct xcoff_line *) + backtrace_vector_grow (state, sizeof (struct xcoff_line), + error_callback, data, &vec->vec)); + if (ln == NULL) + return 0; + + ln->pc = pc; + ln->filename = filename; + ln->function = function; + ln->lineno = lnno; + + ++vec->count; + + return 1; +} + +/* Add the line number entries for a function to the line vector. */ + +static int +xcoff_process_linenos (struct backtrace_state *state, uintptr_t base_address, + const b_xcoff_syment *fsym, const char *filename, + const b_xcoff_scnhdr *sects, + const unsigned char *strtab, size_t strtab_size, + uint32_t fcn_lnno, struct xcoff_incl_vector *vec, + struct xcoff_line_vector *lvec, + const unsigned char *linenos, size_t linenos_size, + uintptr_t lnnoptr0, + backtrace_error_callback error_callback, void *data) +{ + const b_xcoff_auxent *aux; + const b_xcoff_lineno *lineno; + const unsigned char *lineptr; + const char *function; + struct xcoff_incl *incl = NULL; + uintptr_t lnnoptr; + uintptr_t pc; + uint32_t lnno; + int begincl; + + aux = (const b_xcoff_auxent *) (fsym + 1); + lnnoptr = aux->x_fcn.x_lnnoptr; + + if (lnnoptr < lnnoptr0 || lnnoptr + LINESZ > lnnoptr0 + linenos_size) + return 0; + + function = xcoff_symname (fsym, strtab, strtab_size); + if (function == NULL) + return 0; + + /* Skip first entry that points to symtab. */ + + lnnoptr += LINESZ; + + lineptr = linenos + (lnnoptr - lnnoptr0); + + begincl = -1; + while (lineptr + LINESZ <= linenos + linenos_size) + { + lineno = (const b_xcoff_lineno *) lineptr; + + lnno = lineno->l_lnno; + if (lnno == 0) + break; + + /* If part of a function other than the beginning comes from an + include file, the line numbers are absolute, rather than + relative to the beginning of the function. */ + incl = (struct xcoff_incl *) bsearch (&lnnoptr, vec->vec.base, + vec->count, + sizeof (struct xcoff_incl), + xcoff_incl_search); + if (begincl == -1) + begincl = incl != NULL; + if (incl != NULL) + { + filename = incl->filename; + if (begincl == 1) + lnno += fcn_lnno - 1; + } + else + lnno += fcn_lnno - 1; + + pc = base_address + lineno->l_addr.l_paddr + - sects[fsym->n_scnum - 1].s_paddr; + xcoff_add_line (state, pc, filename, function, lnno, error_callback, + data, lvec); + + lnnoptr += LINESZ; + lineptr += LINESZ; + } + + return 1; +} + +/* Initialize the line vector info for xcoff_fileline. */ + +static int +xcoff_initialize_fileline (struct backtrace_state *state, + uintptr_t base_address, + const b_xcoff_scnhdr *sects, + const b_xcoff_syment *syms, size_t nsyms, + const unsigned char *strtab, size_t strtab_size, + const unsigned char *linenos, size_t linenos_size, + uint64_t lnnoptr0, + backtrace_error_callback error_callback, void *data) +{ + struct xcoff_fileline_data *fdata; + struct xcoff_incl_vector vec; + struct xcoff_line *ln; + const b_xcoff_syment *fsym; + const b_xcoff_auxent *aux; + const char *filename; + const char *name; + struct xcoff_incl *incl; + uintptr_t begin, end; + uintptr_t lnno; + size_t i; + + fdata = ((struct xcoff_fileline_data *) + backtrace_alloc (state, sizeof (struct xcoff_fileline_data), + error_callback, data)); + if (fdata == NULL) + return 0; + + memset (fdata, 0, sizeof *fdata); + memset (&vec, 0, sizeof vec); + + /* Process include files first. */ + + begin = 0; + for (i = 0; i < nsyms; ++i) + { + const b_xcoff_syment *asym = &syms[i]; + + switch (asym->n_sclass) + { + case C_BINCL: + begin = asym->n_value; + break; + + case C_EINCL: + if (begin == 0) + break; + end = asym->n_value; + incl = ((struct xcoff_incl *) + backtrace_vector_grow (state, sizeof (struct xcoff_incl), + error_callback, data, &vec.vec)); + if (incl != NULL) + { + incl->filename = xcoff_symname (asym, strtab, strtab_size); + incl->begin = begin; + incl->end = end; + ++vec.count; + } + begin = 0; + break; + } + + i += asym->n_numaux; + } + + backtrace_qsort (vec.vec.base, vec.count, + sizeof (struct xcoff_incl), xcoff_incl_compare); + + filename = NULL; + fsym = NULL; + for (i = 0; i < nsyms; ++i) + { + const b_xcoff_syment *asym = &syms[i]; + + switch (asym->n_sclass) + { + case C_FILE: + filename = xcoff_symname (asym, strtab, strtab_size); + if (filename == NULL) + break; + + /* If the file auxiliary entry is not used, the symbol name is + the name of the source file. If the file auxiliary entry is + used, then the symbol name should be .file, and the first + file auxiliary entry (by convention) contains the source + file name. */ + + if (asym->n_numaux > 0 && !strcmp (filename, ".file")) + { + aux = (const b_xcoff_auxent *) (asym + 1); + if (aux->x_file._x.x_zeroes != 0) + { + /* Make a copy as we will release the symtab view. */ + char name[FILNMLEN+1]; + strncpy (name, aux->x_file.x_fname, FILNMLEN); + name[FILNMLEN] = '\0'; + filename = strdup (name); + } + else if (aux->x_file._x.x_offset < strtab_size) + filename = (const char *) strtab + aux->x_file._x.x_offset; + else + filename = NULL; + } + break; + + case C_EXT: + case C_HIDEXT: + case C_WEAKEXT: + fsym = NULL; + if (!ISFCN (asym->n_type) || asym->n_numaux == 0) + break; + if (filename == NULL) + break; + fsym = asym; + break; + + case C_FCN: + if (asym->n_numaux == 0) + break; + if (fsym == NULL) + break; + name = xcoff_symname (asym, strtab, strtab_size); + if (name == NULL) + break; + aux = (const b_xcoff_auxent *) (asym + 1); +#if BACKTRACE_XCOFF_SIZE == 32 + lnno = (uint32_t) aux->x_block.x_lnnohi << 16 + | aux->x_block.x_lnno; +#else + lnno = aux->x_block.x_lnno; +#endif + if (!strcmp (name, ".bf")) + { + xcoff_process_linenos (state, base_address, fsym, filename, + sects, strtab, strtab_size, lnno, &vec, + &fdata->vec, linenos, linenos_size, + lnnoptr0, error_callback, data); + } + else if (!strcmp (name, ".ef")) + { + fsym = NULL; + } + break; + } + + i += asym->n_numaux; + } + + /* Allocate one extra entry at the end. */ + ln = ((struct xcoff_line *) + backtrace_vector_grow (state, sizeof (struct xcoff_line), + error_callback, data, &fdata->vec.vec)); + if (ln == NULL) + goto fail; + ln->pc = (uintptr_t) -1; + ln->filename = NULL; + ln->function = NULL; + ln->lineno = 0; + + if (!backtrace_vector_release (state, &fdata->vec.vec, error_callback, data)) + goto fail; + + backtrace_qsort (fdata->vec.vec.base, fdata->vec.count, + sizeof (struct xcoff_line), xcoff_line_compare); + + if (!state->threaded) + { + struct xcoff_fileline_data **pp; + + for (pp = (struct xcoff_fileline_data **) (void *) &state->fileline_data; + *pp != NULL; + pp = &(*pp)->next) + ; + *pp = fdata; + } + else + { + while (1) + { + struct xcoff_fileline_data **pp; + + pp = (struct xcoff_fileline_data **) (void *) &state->fileline_data; + + while (1) + { + struct xcoff_fileline_data *p; + + p = backtrace_atomic_load_pointer (pp); + + if (p == NULL) + break; + + pp = &p->next; + } + + if (__sync_bool_compare_and_swap (pp, NULL, fdata)) + break; + } + } + + return 1; + +fail: + return 0; +} + +/* Add the backtrace data for one XCOFF file. Returns 1 on success, + 0 on failure (in both cases descriptor is closed). */ + +static int +xcoff_add (struct backtrace_state *state, int descriptor, off_t offset, + uintptr_t base_address, backtrace_error_callback error_callback, + void *data, fileline *fileline_fn, int *found_sym, int exe) +{ + struct backtrace_view fhdr_view; + struct backtrace_view sects_view; + struct backtrace_view linenos_view; + struct backtrace_view syms_view; + struct backtrace_view str_view; + struct backtrace_view dwarf_view; + b_xcoff_filhdr fhdr; + const b_xcoff_scnhdr *sects; + const b_xcoff_scnhdr *stext; + uint64_t lnnoptr; + uint32_t nlnno; + off_t str_off; + off_t min_offset; + off_t max_offset; + struct dwsect_info dwsect[DWSECT_MAX]; + size_t sects_size; + size_t syms_size; + int32_t str_size; + int sects_view_valid; + int linenos_view_valid; + int syms_view_valid; + int str_view_valid; + int dwarf_view_valid; + int magic_ok; + int i; + + *found_sym = 0; + + sects_view_valid = 0; + linenos_view_valid = 0; + syms_view_valid = 0; + str_view_valid = 0; + dwarf_view_valid = 0; + + str_size = 0; + + /* Map the XCOFF file header. */ + if (!backtrace_get_view (state, descriptor, offset, sizeof (b_xcoff_filhdr), + error_callback, data, &fhdr_view)) + goto fail; + + memcpy (&fhdr, fhdr_view.data, sizeof fhdr); + magic_ok = (fhdr.f_magic == XCOFF_MAGIC); + + backtrace_release_view (state, &fhdr_view, error_callback, data); + + if (!magic_ok) + { + if (exe) + error_callback (data, "executable file is not XCOFF", 0); + goto fail; + } + + /* Verify object is of expected type. */ + if ((exe && (fhdr.f_flags & F_SHROBJ)) + || (!exe && !(fhdr.f_flags & F_SHROBJ))) + goto fail; + + /* Read the section headers. */ + + sects_size = fhdr.f_nscns * sizeof (b_xcoff_scnhdr); + + if (!backtrace_get_view (state, descriptor, + offset + sizeof (fhdr) + fhdr.f_opthdr, + sects_size, error_callback, data, §s_view)) + goto fail; + sects_view_valid = 1; + sects = (const b_xcoff_scnhdr *) sects_view.data; + + /* FIXME: assumes only one .text section. */ + for (i = 0; i < fhdr.f_nscns; ++i) + if ((sects[i].s_flags & 0xffff) == STYP_TEXT) + break; + if (i == fhdr.f_nscns) + goto fail; + + stext = §s[i]; + + /* AIX ldinfo_textorg includes the XCOFF headers. */ + base_address = (exe ? XCOFF_AIX_TEXTBASE : base_address) + stext->s_scnptr; + + lnnoptr = stext->s_lnnoptr; + nlnno = stext->s_nlnno; + +#if BACKTRACE_XCOFF_SIZE == 32 + if (nlnno == _OVERFLOW_MARKER) + { + int sntext = i + 1; + /* Find the matching .ovrflo section. */ + for (i = 0; i < fhdr.f_nscns; ++i) + { + if (((sects[i].s_flags & 0xffff) == STYP_OVRFLO) + && sects[i].s_nlnno == sntext) + { + nlnno = sects[i].s_vaddr; + break; + } + } + } +#endif + + /* Read the symbol table and the string table. */ + + if (fhdr.f_symptr != 0) + { + struct xcoff_syminfo_data *sdata; + + /* Symbol table is followed by the string table. The string table + starts with its length (on 4 bytes). + Map the symbol table and the length of the string table. */ + syms_size = fhdr.f_nsyms * sizeof (b_xcoff_syment); + + if (!backtrace_get_view (state, descriptor, offset + fhdr.f_symptr, + syms_size + 4, error_callback, data, + &syms_view)) + goto fail; + syms_view_valid = 1; + + memcpy (&str_size, syms_view.data + syms_size, 4); + + str_off = fhdr.f_symptr + syms_size; + + if (str_size > 4) + { + /* Map string table (including the length word). */ + + if (!backtrace_get_view (state, descriptor, offset + str_off, + str_size, error_callback, data, &str_view)) + goto fail; + str_view_valid = 1; + } + + sdata = ((struct xcoff_syminfo_data *) + backtrace_alloc (state, sizeof *sdata, error_callback, data)); + if (sdata == NULL) + goto fail; + + if (!xcoff_initialize_syminfo (state, base_address, sects, + syms_view.data, fhdr.f_nsyms, + str_view.data, str_size, + error_callback, data, sdata)) + { + backtrace_free (state, sdata, sizeof *sdata, error_callback, data); + goto fail; + } + + *found_sym = 1; + + xcoff_add_syminfo_data (state, sdata); + } + + /* Read all the DWARF sections in a single view, since they are + probably adjacent in the file. We never release this view. */ + + min_offset = 0; + max_offset = 0; + memset (dwsect, 0, sizeof dwsect); + for (i = 0; i < fhdr.f_nscns; ++i) + { + off_t end; + int idx; + + if ((sects[i].s_flags & 0xffff) != STYP_DWARF + || sects[i].s_size == 0) + continue; + /* Map DWARF section to array index. */ + switch (sects[i].s_flags & 0xffff0000) + { + case SSUBTYP_DWINFO: + idx = DWSECT_INFO; + break; + case SSUBTYP_DWLINE: + idx = DWSECT_LINE; + break; + case SSUBTYP_DWABREV: + idx = DWSECT_ABBREV; + break; + case SSUBTYP_DWARNGE: + idx = DWSECT_RANGES; + break; + case SSUBTYP_DWSTR: + idx = DWSECT_STR; + break; + default: + continue; + } + if (min_offset == 0 || (off_t) sects[i].s_scnptr < min_offset) + min_offset = sects[i].s_scnptr; + end = sects[i].s_scnptr + sects[i].s_size; + if (end > max_offset) + max_offset = end; + dwsect[idx].offset = sects[i].s_scnptr; + dwsect[idx].size = sects[i].s_size; + } + if (min_offset != 0 && max_offset != 0) + { + if (!backtrace_get_view (state, descriptor, offset + min_offset, + max_offset - min_offset, + error_callback, data, &dwarf_view)) + goto fail; + dwarf_view_valid = 1; + + for (i = 0; i < (int) DWSECT_MAX; ++i) + { + if (dwsect[i].offset == 0) + dwsect[i].data = NULL; + else + dwsect[i].data = ((const unsigned char *) dwarf_view.data + + (dwsect[i].offset - min_offset)); + } + + if (!backtrace_dwarf_add (state, 0, + dwsect[DWSECT_INFO].data, + dwsect[DWSECT_INFO].size, +#if BACKTRACE_XCOFF_SIZE == 32 + /* XXX workaround for broken lineoff */ + dwsect[DWSECT_LINE].data - 4, +#else + /* XXX workaround for broken lineoff */ + dwsect[DWSECT_LINE].data - 12, +#endif + dwsect[DWSECT_LINE].size, + dwsect[DWSECT_ABBREV].data, + dwsect[DWSECT_ABBREV].size, + dwsect[DWSECT_RANGES].data, + dwsect[DWSECT_RANGES].size, + dwsect[DWSECT_STR].data, + dwsect[DWSECT_STR].size, + 1, /* big endian */ + error_callback, data, fileline_fn)) + goto fail; + } + + /* Read the XCOFF line number entries if DWARF sections not found. */ + + if (!dwarf_view_valid && fhdr.f_symptr != 0 && lnnoptr != 0) + { + size_t linenos_size = (size_t) nlnno * LINESZ; + + if (!backtrace_get_view (state, descriptor, offset + lnnoptr, + linenos_size, + error_callback, data, &linenos_view)) + goto fail; + linenos_view_valid = 1; + + if (xcoff_initialize_fileline (state, base_address, sects, + syms_view.data, fhdr.f_nsyms, + str_view.data, str_size, + linenos_view.data, linenos_size, + lnnoptr, error_callback, data)) + *fileline_fn = xcoff_fileline; + + backtrace_release_view (state, &linenos_view, error_callback, data); + linenos_view_valid = 0; + } + + backtrace_release_view (state, §s_view, error_callback, data); + sects_view_valid = 0; + if (syms_view_valid) + backtrace_release_view (state, &syms_view, error_callback, data); + syms_view_valid = 0; + + /* We've read all we need from the executable. */ + if (!backtrace_close (descriptor, error_callback, data)) + goto fail; + descriptor = -1; + + return 1; + + fail: + if (sects_view_valid) + backtrace_release_view (state, §s_view, error_callback, data); + if (str_view_valid) + backtrace_release_view (state, &str_view, error_callback, data); + if (syms_view_valid) + backtrace_release_view (state, &syms_view, error_callback, data); + if (linenos_view_valid) + backtrace_release_view (state, &linenos_view, error_callback, data); + if (dwarf_view_valid) + backtrace_release_view (state, &dwarf_view, error_callback, data); + if (descriptor != -1 && offset == 0) + backtrace_close (descriptor, error_callback, data); + return 0; +} + +#ifdef HAVE_LOADQUERY + +/* Read an integer value in human-readable format from an AIX + big archive fixed-length or member header. */ + +static int +xcoff_parse_decimal (const char *buf, size_t size, off_t *off) +{ + char str[32]; + char *end; + + if (size >= sizeof str) + return 0; + memcpy (str, buf, size); + str[size] = '\0'; + *off = strtol (str, &end, 10); + if (*end != '\0' && *end != ' ') + return 0; + + return 1; +} + +/* Add the backtrace data for a member of an AIX big archive. + Returns 1 on success, 0 on failure. */ + +static int +xcoff_armem_add (struct backtrace_state *state, int descriptor, + uintptr_t base_address, const char *member, + backtrace_error_callback error_callback, void *data, + fileline *fileline_fn, int *found_sym) +{ + struct backtrace_view view; + b_ar_fl_hdr fl_hdr; + const b_ar_hdr *ar_hdr; + off_t off; + off_t len; + int memlen; + + *found_sym = 0; + + /* Map archive fixed-length header. */ + + if (!backtrace_get_view (state, descriptor, 0, sizeof (b_ar_fl_hdr), + error_callback, data, &view)) + goto fail; + + memcpy (&fl_hdr, view.data, sizeof (b_ar_fl_hdr)); + + backtrace_release_view (state, &view, error_callback, data); + + if (memcmp (fl_hdr.fl_magic, AIAMAGBIG, 8) != 0) + goto fail; + + memlen = strlen (member); + + /* Read offset of first archive member. */ + if (!xcoff_parse_decimal (fl_hdr.fl_fstmoff, sizeof fl_hdr.fl_fstmoff, &off)) + goto fail; + while (off != 0) + { + /* Map archive member header and member name. */ + + if (!backtrace_get_view (state, descriptor, off, + sizeof (b_ar_hdr) + memlen, + error_callback, data, &view)) + break; + + ar_hdr = (const b_ar_hdr *) view.data; + + /* Read archive member name length. */ + if (!xcoff_parse_decimal (ar_hdr->ar_namlen, sizeof ar_hdr->ar_namlen, + &len)) + { + backtrace_release_view (state, &view, error_callback, data); + break; + } + if (len == memlen && !memcmp (ar_hdr->ar_name, member, memlen)) + { + off = (off + sizeof (b_ar_hdr) + memlen + 1) & ~1; + + /* The archive can contain several members with the same name + (e.g. 32-bit and 64-bit), so continue if not ok. */ + + if (xcoff_add (state, descriptor, off, base_address, error_callback, + data, fileline_fn, found_sym, 0)) + { + backtrace_release_view (state, &view, error_callback, data); + return 1; + } + } + + /* Read offset of next archive member. */ + if (!xcoff_parse_decimal (ar_hdr->ar_nxtmem, sizeof ar_hdr->ar_nxtmem, + &off)) + { + backtrace_release_view (state, &view, error_callback, data); + break; + } + backtrace_release_view (state, &view, error_callback, data); + } + + fail: + /* No matching member found. */ + backtrace_close (descriptor, error_callback, data); + return 0; +} + +/* Add the backtrace data for dynamically loaded libraries. */ + +static void +xcoff_add_shared_libs (struct backtrace_state *state, + backtrace_error_callback error_callback, + void *data, fileline *fileline_fn, int *found_sym) +{ + const struct ld_info *ldinfo; + void *buf; + unsigned int buflen; + const char *member; + int descriptor; + int does_not_exist; + int lib_found_sym; + int ret; + + /* Retrieve the list of loaded libraries. */ + + buf = NULL; + buflen = 512; + do + { + buf = realloc (buf, buflen); + if (buf == NULL) + { + ret = -1; + break; + } + ret = loadquery (L_GETINFO, buf, buflen); + if (ret == 0) + break; + buflen *= 2; + } + while (ret == -1 && errno == ENOMEM); + if (ret != 0) + { + free (buf); + return; + } + + ldinfo = (const struct ld_info *) buf; + while ((const char *) ldinfo < (const char *) buf + buflen) + { + if (*ldinfo->ldinfo_filename != '/') + goto next; + + descriptor = backtrace_open (ldinfo->ldinfo_filename, error_callback, + data, &does_not_exist); + if (descriptor < 0) + goto next; + + /* Check if it is an archive (member name not empty). */ + + member = ldinfo->ldinfo_filename + strlen (ldinfo->ldinfo_filename) + 1; + if (*member) + { + xcoff_armem_add (state, descriptor, + (uintptr_t) ldinfo->ldinfo_textorg, member, + error_callback, data, fileline_fn, &lib_found_sym); + } + else + { + xcoff_add (state, descriptor, 0, (uintptr_t) ldinfo->ldinfo_textorg, + error_callback, data, fileline_fn, &lib_found_sym, 0); + } + if (lib_found_sym) + *found_sym = 1; + + next: + if (ldinfo->ldinfo_next == 0) + break; + ldinfo = (const struct ld_info *) ((const char *) ldinfo + + ldinfo->ldinfo_next); + } + + free (buf); +} +#endif /* HAVE_LOADQUERY */ + +/* Initialize the backtrace data we need from an XCOFF executable. + Returns 1 on success, 0 on failure. */ + +int +backtrace_initialize (struct backtrace_state *state, + const char *filename ATTRIBUTE_UNUSED, int descriptor, + backtrace_error_callback error_callback, + void *data, fileline *fileline_fn) +{ + int ret; + int found_sym; + fileline xcoff_fileline_fn = xcoff_nodebug; + + ret = xcoff_add (state, descriptor, 0, 0, error_callback, data, + &xcoff_fileline_fn, &found_sym, 1); + if (!ret) + return 0; + +#ifdef HAVE_LOADQUERY + xcoff_add_shared_libs (state, error_callback, data, &xcoff_fileline_fn, + &found_sym); +#endif + + if (!state->threaded) + { + if (found_sym) + state->syminfo_fn = xcoff_syminfo; + else if (state->syminfo_fn == NULL) + state->syminfo_fn = xcoff_nosyms; + } + else + { + if (found_sym) + backtrace_atomic_store_pointer (&state->syminfo_fn, xcoff_syminfo); + else + __sync_bool_compare_and_swap (&state->syminfo_fn, NULL, xcoff_nosyms); + } + + if (!state->threaded) + { + if (state->fileline_fn == NULL || state->fileline_fn == xcoff_nodebug) + *fileline_fn = xcoff_fileline_fn; + } + else + { + fileline current_fn; + + current_fn = backtrace_atomic_load_pointer (&state->fileline_fn); + if (current_fn == NULL || current_fn == xcoff_nodebug) + *fileline_fn = xcoff_fileline_fn; + } + + return 1; +} diff --git a/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/ztest.c b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/ztest.c new file mode 100644 index 0000000..9cd712a --- /dev/null +++ b/third_party/cargo/vendor/backtrace-sys-0.1.32/src/libbacktrace/ztest.c @@ -0,0 +1,537 @@ +/* ztest.c -- Test for libbacktrace inflate code. + Copyright (C) 2017-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + (2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_ZLIB +#include +#endif + +#include "backtrace.h" +#include "backtrace-supported.h" + +#include "internal.h" +#include "testlib.h" + +#ifndef HAVE_CLOCK_GETTIME + +typedef int xclockid_t; + +static int +xclock_gettime (xclockid_t id ATTRIBUTE_UNUSED, + struct timespec *ts ATTRIBUTE_UNUSED) +{ + errno = EINVAL; + return -1; +} + +#define clockid_t xclockid_t +#define clock_gettime xclock_gettime +#undef CLOCK_REALTIME +#define CLOCK_REALTIME 0 + +#endif /* !defined(HAVE_CLOCK_GETTIME) */ + +#ifdef CLOCK_PROCESS_CPUTIME_ID +#define ZLIB_CLOCK_GETTIME_ARG CLOCK_PROCESS_CPUTIME_ID +#else +#define ZLIB_CLOCK_GETTIME_ARG CLOCK_REALTIME +#endif + +/* Some tests for the local zlib inflation code. */ + +struct zlib_test +{ + const char *name; + const char *uncompressed; + size_t uncompressed_len; + const char *compressed; + size_t compressed_len; +}; + +/* Error callback. */ + +static void +error_callback_compress (void *vdata, const char *msg, int errnum) +{ + fprintf (stderr, "%s", msg); + if (errnum > 0) + fprintf (stderr, ": %s", strerror (errnum)); + fprintf (stderr, "\n"); + exit (EXIT_FAILURE); +} + +static const struct zlib_test tests[] = +{ + { + "empty", + "", + 0, + "\x78\x9c\x03\x00\x00\x00\x00\x01", + 8, + }, + { + "hello", + "hello, world\n", + 0, + ("\x78\x9c\xca\x48\xcd\xc9\xc9\xd7\x51\x28\xcf" + "\x2f\xca\x49\xe1\x02\x04\x00\x00\xff\xff\x21\xe7\x04\x93"), + 25, + }, + { + "goodbye", + "goodbye, world", + 0, + ("\x78\x9c\x4b\xcf\xcf\x4f\x49\xaa" + "\x4c\xd5\x51\x28\xcf\x2f\xca\x49" + "\x01\x00\x28\xa5\x05\x5e"), + 22, + }, + { + "ranges", + ("\xcc\x11\x00\x00\x00\x00\x00\x00\xd5\x13\x00\x00\x00\x00\x00\x00" + "\x1c\x14\x00\x00\x00\x00\x00\x00\x72\x14\x00\x00\x00\x00\x00\x00" + "\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\xfb\x12\x00\x00\x00\x00\x00\x00\x09\x13\x00\x00\x00\x00\x00\x00" + "\x0c\x13\x00\x00\x00\x00\x00\x00\xcb\x13\x00\x00\x00\x00\x00\x00" + "\x29\x14\x00\x00\x00\x00\x00\x00\x4e\x14\x00\x00\x00\x00\x00\x00" + "\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\xfb\x12\x00\x00\x00\x00\x00\x00\x09\x13\x00\x00\x00\x00\x00\x00" + "\x67\x13\x00\x00\x00\x00\x00\x00\xcb\x13\x00\x00\x00\x00\x00\x00" + "\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\x5f\x0b\x00\x00\x00\x00\x00\x00\x6c\x0b\x00\x00\x00\x00\x00\x00" + "\x7d\x0b\x00\x00\x00\x00\x00\x00\x7e\x0c\x00\x00\x00\x00\x00\x00" + "\x38\x0f\x00\x00\x00\x00\x00\x00\x5c\x0f\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\x83\x0c\x00\x00\x00\x00\x00\x00\xfa\x0c\x00\x00\x00\x00\x00\x00" + "\xfd\x0d\x00\x00\x00\x00\x00\x00\xef\x0e\x00\x00\x00\x00\x00\x00" + "\x14\x0f\x00\x00\x00\x00\x00\x00\x38\x0f\x00\x00\x00\x00\x00\x00" + "\x9f\x0f\x00\x00\x00\x00\x00\x00\xac\x0f\x00\x00\x00\x00\x00\x00" + "\xdb\x0f\x00\x00\x00\x00\x00\x00\xff\x0f\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\xfd\x0d\x00\x00\x00\x00\x00\x00\xd8\x0e\x00\x00\x00\x00\x00\x00" + "\x9f\x0f\x00\x00\x00\x00\x00\x00\xac\x0f\x00\x00\x00\x00\x00\x00" + "\xdb\x0f\x00\x00\x00\x00\x00\x00\xff\x0f\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\xfa\x0c\x00\x00\x00\x00\x00\x00\xea\x0d\x00\x00\x00\x00\x00\x00" + "\xef\x0e\x00\x00\x00\x00\x00\x00\x14\x0f\x00\x00\x00\x00\x00\x00" + "\x5c\x0f\x00\x00\x00\x00\x00\x00\x9f\x0f\x00\x00\x00\x00\x00\x00" + "\xac\x0f\x00\x00\x00\x00\x00\x00\xdb\x0f\x00\x00\x00\x00\x00\x00" + "\xff\x0f\x00\x00\x00\x00\x00\x00\x2c\x10\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\x60\x11\x00\x00\x00\x00\x00\x00\xd1\x16\x00\x00\x00\x00\x00\x00" + "\x40\x0b\x00\x00\x00\x00\x00\x00\x2c\x10\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\x7a\x00\x00\x00\x00\x00\x00\x00\xb6\x00\x00\x00\x00\x00\x00\x00" + "\x9f\x01\x00\x00\x00\x00\x00\x00\xa7\x01\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\x7a\x00\x00\x00\x00\x00\x00\x00\xa9\x00\x00\x00\x00\x00\x00\x00" + "\x9f\x01\x00\x00\x00\x00\x00\x00\xa7\x01\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), + 672, + ("\x78\x9c\x3b\x23\xc8\x00\x06\x57\x85\x21\xb4\x8c\x08\x84\x2e\x82" + "\xd2\x73\xa1\xf4\x55\x28\x8d\x0e\x7e\x0b\x41\x68\x4e\xa8\x7e\x1e" + "\x28\x7d\x1a\x4a\x6b\x42\xf5\xf9\x91\x69\x5e\x3a\x9a\x79\x84\xf4" + "\xc7\x73\x43\xe8\x1c\x28\x5d\x0b\xa5\xeb\x78\x20\xb4\x05\x3f\x84" + "\x8e\xe1\xc7\xae\xbf\x19\xaa\xee\x17\x94\xfe\xcb\x0b\xa1\xdf\xf3" + "\x41\x68\x11\x7e\x54\x73\xe6\x43\xe9\x35\x50\xfa\x36\x94\xfe\x8f" + "\xc3\x7c\x98\x79\x37\xf8\xc8\xd3\x0f\x73\xd7\x2b\x1c\xee\x8a\x21" + "\xd2\x5d\x3a\x02\xd8\xcd\x4f\x80\xa6\x87\x8b\x62\x10\xda\x81\x1b" + "\xbf\xfa\x2a\x28\xbd\x0d\x4a\xcf\x67\x84\xd0\xcb\x19\xf1\xab\x5f" + "\x49\xa4\x7a\x00\x48\x97\x29\xd4"), + 152, + } +}; + +/* Test the hand coded samples. */ + +static void +test_samples (struct backtrace_state *state) +{ + size_t i; + + for (i = 0; i < sizeof tests / sizeof tests[0]; ++i) + { + char *p; + size_t v; + size_t j; + unsigned char *uncompressed; + size_t uncompressed_len; + + p = malloc (12 + tests[i].compressed_len); + memcpy (p, "ZLIB", 4); + v = tests[i].uncompressed_len; + if (v == 0) + v = strlen (tests[i].uncompressed); + for (j = 0; j < 8; ++j) + p[j + 4] = (v >> ((7 - j) * 8)) & 0xff; + memcpy (p + 12, tests[i].compressed, tests[i].compressed_len); + uncompressed = NULL; + uncompressed_len = 0; + if (!backtrace_uncompress_zdebug (state, (unsigned char *) p, + tests[i].compressed_len + 12, + error_callback_compress, NULL, + &uncompressed, &uncompressed_len)) + { + fprintf (stderr, "test %s: uncompress failed\n", tests[i].name); + ++failures; + } + else + { + if (uncompressed_len != v) + { + fprintf (stderr, + "test %s: got uncompressed length %zu, want %zu\n", + tests[i].name, uncompressed_len, v); + ++failures; + } + else if (memcmp (tests[i].uncompressed, uncompressed, v) != 0) + { + size_t j; + + fprintf (stderr, "test %s: uncompressed data mismatch\n", + tests[i].name); + for (j = 0; j < v; ++j) + if (tests[i].uncompressed[j] != uncompressed[j]) + fprintf (stderr, " %zu: got %#x want %#x\n", j, + uncompressed[j], tests[i].uncompressed[j]); + ++failures; + } + else + printf ("PASS: inflate %s\n", tests[i].name); + + backtrace_free (state, uncompressed, uncompressed_len, + error_callback_compress, NULL); + } + } +} + +#ifdef HAVE_ZLIB + +/* Given a set of TRIALS timings, discard the lowest and highest + values and return the mean average of the rest. */ + +static size_t +average_time (const size_t *times, size_t trials) +{ + size_t imax; + size_t max; + size_t imin; + size_t min; + size_t i; + size_t sum; + + imin = 0; + imax = 0; + min = times[0]; + max = times[0]; + for (i = 1; i < trials; ++i) + { + if (times[i] < min) + { + imin = i; + min = times[i]; + } + if (times[i] > max) + { + imax = i; + max = times[i]; + } + } + + sum = 0; + for (i = 0; i < trials; ++i) + { + if (i != imax && i != imin) + sum += times[i]; + } + return sum / (trials - 2); +} + +#endif + +/* Test a larger text, if available. */ + +static void +test_large (struct backtrace_state *state) +{ +#ifdef HAVE_ZLIB + unsigned char *orig_buf; + size_t orig_bufsize; + size_t i; + char *compressed_buf; + size_t compressed_bufsize; + unsigned long compress_sizearg; + unsigned char *uncompressed_buf; + size_t uncompressed_bufsize; + int r; + clockid_t cid; + struct timespec ts1; + struct timespec ts2; + size_t ctime; + size_t ztime; + const size_t trials = 16; + size_t ctimes[16]; + size_t ztimes[16]; + static const char * const names[] = { + "Mark.Twain-Tom.Sawyer.txt", + "../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt" + }; + + orig_buf = NULL; + orig_bufsize = 0; + uncompressed_buf = NULL; + compressed_buf = NULL; + + for (i = 0; i < sizeof names / sizeof names[0]; ++i) + { + size_t len; + char *namebuf; + FILE *e; + struct stat st; + char *rbuf; + size_t got; + + len = strlen (SRCDIR) + strlen (names[i]) + 2; + namebuf = malloc (len); + if (namebuf == NULL) + { + perror ("malloc"); + goto fail; + } + snprintf (namebuf, len, "%s/%s", SRCDIR, names[i]); + e = fopen (namebuf, "r"); + free (namebuf); + if (e == NULL) + continue; + if (fstat (fileno (e), &st) < 0) + { + perror ("fstat"); + fclose (e); + continue; + } + rbuf = malloc (st.st_size); + if (rbuf == NULL) + { + perror ("malloc"); + goto fail; + } + got = fread (rbuf, 1, st.st_size, e); + fclose (e); + if (got > 0) + { + orig_buf = rbuf; + orig_bufsize = got; + break; + } + free (rbuf); + } + + if (orig_buf == NULL) + { + /* We couldn't find an input file. */ + printf ("UNSUPPORTED: inflate large\n"); + return; + } + + compressed_bufsize = compressBound (orig_bufsize) + 12; + compressed_buf = malloc (compressed_bufsize); + if (compressed_buf == NULL) + { + perror ("malloc"); + goto fail; + } + + compress_sizearg = compressed_bufsize - 12; + r = compress (compressed_buf + 12, &compress_sizearg, + orig_buf, orig_bufsize); + if (r != Z_OK) + { + fprintf (stderr, "zlib compress failed: %d\n", r); + goto fail; + } + + compressed_bufsize = compress_sizearg + 12; + + /* Prepare the header that our library expects. */ + memcpy (compressed_buf, "ZLIB", 4); + for (i = 0; i < 8; ++i) + compressed_buf[i + 4] = (orig_bufsize >> ((7 - i) * 8)) & 0xff; + + uncompressed_buf = malloc (orig_bufsize); + if (uncompressed_buf == NULL) + { + perror ("malloc"); + goto fail; + } + uncompressed_bufsize = orig_bufsize; + + if (!backtrace_uncompress_zdebug (state, compressed_buf, compressed_bufsize, + error_callback_compress, NULL, + &uncompressed_buf, &uncompressed_bufsize)) + { + fprintf (stderr, "inflate large: backtrace_uncompress_zdebug failed\n"); + goto fail; + } + + if (uncompressed_bufsize != orig_bufsize) + { + fprintf (stderr, + "inflate large: got uncompressed length %zu, want %zu\n", + uncompressed_bufsize, orig_bufsize); + goto fail; + } + + if (memcmp (uncompressed_buf, orig_buf, uncompressed_bufsize) != 0) + { + fprintf (stderr, "inflate large: uncompressed data mismatch\n"); + goto fail; + } + + printf ("PASS: inflate large\n"); + + for (i = 0; i < trials; ++i) + { + unsigned long uncompress_sizearg; + + cid = ZLIB_CLOCK_GETTIME_ARG; + if (clock_gettime (cid, &ts1) < 0) + { + if (errno == EINVAL) + return; + perror ("clock_gettime"); + return; + } + + if (!backtrace_uncompress_zdebug (state, compressed_buf, + compressed_bufsize, + error_callback_compress, NULL, + &uncompressed_buf, + &uncompressed_bufsize)) + { + fprintf (stderr, + ("inflate large: " + "benchmark backtrace_uncompress_zdebug failed\n")); + return; + } + + if (clock_gettime (cid, &ts2) < 0) + { + perror ("clock_gettime"); + return; + } + + ctime = (ts2.tv_sec - ts1.tv_sec) * 1000000000; + ctime += ts2.tv_nsec - ts1.tv_nsec; + ctimes[i] = ctime; + + if (clock_gettime (cid, &ts1) < 0) + { + perror("clock_gettime"); + return; + } + + uncompress_sizearg = uncompressed_bufsize; + r = uncompress (uncompressed_buf, &uncompress_sizearg, + compressed_buf + 12, compressed_bufsize - 12); + + if (clock_gettime (cid, &ts2) < 0) + { + perror ("clock_gettime"); + return; + } + + if (r != Z_OK) + { + fprintf (stderr, + "inflate large: benchmark zlib uncompress failed: %d\n", + r); + return; + } + + ztime = (ts2.tv_sec - ts1.tv_sec) * 1000000000; + ztime += ts2.tv_nsec - ts1.tv_nsec; + ztimes[i] = ztime; + } + + /* Toss the highest and lowest times and average the rest. */ + ctime = average_time (ctimes, trials); + ztime = average_time (ztimes, trials); + + printf ("backtrace: %zu ns\n", ctime); + printf ("zlib : %zu ns\n", ztime); + printf ("ratio : %g\n", (double) ztime / (double) ctime); + + return; + + fail: + printf ("FAIL: inflate large\n"); + ++failures; + + if (orig_buf != NULL) + free (orig_buf); + if (compressed_buf != NULL) + free (compressed_buf); + if (uncompressed_buf != NULL) + free (uncompressed_buf); + +#else /* !HAVE_ZLIB */ + + printf ("UNSUPPORTED: inflate large\n"); + +#endif /* !HAVE_ZLIB */ +} + +int +main (int argc ATTRIBUTE_UNUSED, char **argv) +{ + struct backtrace_state *state; + + state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS, + error_callback_create, NULL); + + test_samples (state); + test_large (state); + + exit (failures != 0 ? EXIT_FAILURE : EXIT_SUCCESS); +} diff --git a/third_party/cargo/vendor/bitflags-1.2.1/.cargo-checksum.json b/third_party/cargo/vendor/bitflags-1.2.1/.cargo-checksum.json new file mode 100644 index 0000000..a8b031c --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"00224cc8d292567bdd212c36db66a1f662cd2e6c58e947900680234937e288a9","CODE_OF_CONDUCT.md":"42634d0f6d922f49857175af991802822f7f920487aefa2ee250a50d12251a66","Cargo.toml":"abacd42e33056c16008ab8eefd16eb2403cbc3393f8a6ed352a9a39d945ad3a5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"6b236f8b62c82f189fabce0756e01a2c0ab1f32cb84cad9ff3c96b2ce5282bda","build.rs":"8923f38056f859b30aa9022980bb517755cbef57e1b09c34b33b27eb03b0626c","src/example_generated.rs":"e43eb59e90f317f38d436670a6067d2fd9eb35fb319fe716184e4a04e24ed1b2","src/lib.rs":"bd4e44ac35831c75af8815ba3a11ee1659afe0f72ce9c5f638a66bf50aa23d2a"},"package":"cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"} \ No newline at end of file diff --git a/third_party/cargo/vendor/bitflags-1.2.1/BUILD b/third_party/cargo/vendor/bitflags-1.2.1/BUILD new file mode 100644 index 0000000..b414039 --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "bitflags", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.2.1", + crate_features = [ + "default", + ], +) + +# Unsupported target "build-script-build" with type "custom-build" omitted diff --git a/third_party/cargo/vendor/bitflags-1.2.1/CHANGELOG.md b/third_party/cargo/vendor/bitflags-1.2.1/CHANGELOG.md new file mode 100644 index 0000000..0d49101 --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/CHANGELOG.md @@ -0,0 +1,149 @@ +# 1.2.1 + +- Remove extraneous `#[inline]` attributes ([#194]) + +[#194]: https://github.com/bitflags/bitflags/pull/194 + +# 1.2.0 + +- Fix typo: {Lower, Upper}Exp - {Lower, Upper}Hex ([#183]) + +- Add support for "unknown" bits ([#188]) + +[#183]: https://github.com/rust-lang-nursery/bitflags/pull/183 +[#188]: https://github.com/rust-lang-nursery/bitflags/pull/188 + +# 1.1.0 + +This is a re-release of `1.0.5`, which was yanked due to a bug in the RLS. + +# 1.0.5 + +- Use compiletest_rs flags supported by stable toolchain ([#171]) + +- Put the user provided attributes first ([#173]) + +- Make bitflags methods `const` on newer compilers ([#175]) + +[#171]: https://github.com/rust-lang-nursery/bitflags/pull/171 +[#173]: https://github.com/rust-lang-nursery/bitflags/pull/173 +[#175]: https://github.com/rust-lang-nursery/bitflags/pull/175 + +# 1.0.4 + +- Support Rust 2018 style macro imports ([#165]) + + ```rust + use bitflags::bitflags; + ``` + +[#165]: https://github.com/rust-lang-nursery/bitflags/pull/165 + +# 1.0.3 + +- Improve zero value flag handling and documentation ([#157]) + +[#157]: https://github.com/rust-lang-nursery/bitflags/pull/157 + +# 1.0.2 + +- 30% improvement in compile time of bitflags crate ([#156]) + +- Documentation improvements ([#153]) + +- Implementation cleanup ([#149]) + +[#156]: https://github.com/rust-lang-nursery/bitflags/pull/156 +[#153]: https://github.com/rust-lang-nursery/bitflags/pull/153 +[#149]: https://github.com/rust-lang-nursery/bitflags/pull/149 + +# 1.0.1 +- Add support for `pub(restricted)` specifier on the bitflags struct ([#135]) +- Optimize performance of `all()` when called from a separate crate ([#136]) + +[#135]: https://github.com/rust-lang-nursery/bitflags/pull/135 +[#136]: https://github.com/rust-lang-nursery/bitflags/pull/136 + +# 1.0.0 +- **[breaking change]** Macro now generates [associated constants](https://doc.rust-lang.org/reference/items.html#associated-constants) ([#24]) + +- **[breaking change]** Minimum supported version is Rust **1.20**, due to usage of associated constants + +- After being broken in 0.9, the `#[deprecated]` attribute is now supported again ([#112]) + +- Other improvements to unit tests and documentation ([#106] and [#115]) + +[#24]: https://github.com/rust-lang-nursery/bitflags/pull/24 +[#106]: https://github.com/rust-lang-nursery/bitflags/pull/106 +[#112]: https://github.com/rust-lang-nursery/bitflags/pull/112 +[#115]: https://github.com/rust-lang-nursery/bitflags/pull/115 + +## How to update your code to use associated constants +Assuming the following structure definition: +```rust +bitflags! { + struct Something: u8 { + const FOO = 0b01, + const BAR = 0b10 + } +} +``` +In 0.9 and older you could do: +```rust +let x = FOO.bits | BAR.bits; +``` +Now you must use: +```rust +let x = Something::FOO.bits | Something::BAR.bits; +``` + +# 0.9.1 +- Fix the implementation of `Formatting` traits when other formatting traits were present in scope ([#105]) + +[#105]: https://github.com/rust-lang-nursery/bitflags/pull/105 + +# 0.9.0 +- **[breaking change]** Use struct keyword instead of flags to define bitflag types ([#84]) + +- **[breaking change]** Terminate const items with semicolons instead of commas ([#87]) + +- Implement the `Hex`, `Octal`, and `Binary` formatting traits ([#86]) + +- Printing an empty flag value with the `Debug` trait now prints "(empty)" instead of nothing ([#85]) + +- The `bitflags!` macro can now be used inside of a fn body, to define a type local to that function ([#74]) + +[#74]: https://github.com/rust-lang-nursery/bitflags/pull/74 +[#84]: https://github.com/rust-lang-nursery/bitflags/pull/84 +[#85]: https://github.com/rust-lang-nursery/bitflags/pull/85 +[#86]: https://github.com/rust-lang-nursery/bitflags/pull/86 +[#87]: https://github.com/rust-lang-nursery/bitflags/pull/87 + +# 0.8.2 +- Update feature flag used when building bitflags as a dependency of the Rust toolchain + +# 0.8.1 +- Allow bitflags to be used as a dependency of the Rust toolchain + +# 0.8.0 +- Add support for the experimental `i128` and `u128` integer types ([#57]) +- Add set method: `flags.set(SOME_FLAG, true)` or `flags.set(SOME_FLAG, false)` ([#55]) + This may break code that defines its own set method + +[#55]: https://github.com/rust-lang-nursery/bitflags/pull/55 +[#57]: https://github.com/rust-lang-nursery/bitflags/pull/57 + +# 0.7.1 +*(yanked)* + +# 0.7.0 +- Implement the Extend trait ([#49]) +- Allow definitions inside the `bitflags!` macro to refer to items imported from other modules ([#51]) + +[#49]: https://github.com/rust-lang-nursery/bitflags/pull/49 +[#51]: https://github.com/rust-lang-nursery/bitflags/pull/51 + +# 0.6.0 +- The `no_std` feature was removed as it is now the default +- The `assignment_operators` feature was remove as it is now enabled by default +- Some clippy suggestions have been applied diff --git a/third_party/cargo/vendor/bitflags-1.2.1/CODE_OF_CONDUCT.md b/third_party/cargo/vendor/bitflags-1.2.1/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..f7add90 --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/CODE_OF_CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, race, +religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at coc@senaite.org. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org \ No newline at end of file diff --git a/third_party/cargo/vendor/bitflags-1.2.1/Cargo.toml b/third_party/cargo/vendor/bitflags-1.2.1/Cargo.toml new file mode 100644 index 0000000..b803644 --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/Cargo.toml @@ -0,0 +1,34 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "bitflags" +version = "1.2.1" +authors = ["The Rust Project Developers"] +build = "build.rs" +exclude = [".travis.yml", "appveyor.yml", "bors.toml"] +description = "A macro to generate structures which behave like bitflags.\n" +homepage = "https://github.com/bitflags/bitflags" +documentation = "https://docs.rs/bitflags" +readme = "README.md" +keywords = ["bit", "bitmask", "bitflags", "flags"] +categories = ["no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/bitflags/bitflags" +[package.metadata.docs.rs] +features = ["example_generated"] + +[features] +default = [] +example_generated = [] +[badges.travis-ci] +repository = "bitflags/bitflags" diff --git a/third_party/cargo/vendor/bitflags-1.2.1/LICENSE-APACHE b/third_party/cargo/vendor/bitflags-1.2.1/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/bitflags-1.2.1/LICENSE-MIT b/third_party/cargo/vendor/bitflags-1.2.1/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/bitflags-1.2.1/README.md b/third_party/cargo/vendor/bitflags-1.2.1/README.md new file mode 100644 index 0000000..df12934 --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/README.md @@ -0,0 +1,34 @@ +bitflags +======== + +[![Build Status](https://travis-ci.com/bitflags/bitflags.svg?branch=master)](https://travis-ci.com/bitflags/bitflags) +[![Join the chat at https://gitter.im/bitflags/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bitflags/Lobby?utm_source=badge&utm_medium=badge&utm_content=badge) +[![Latest version](https://img.shields.io/crates/v/bitflags.svg)](https://crates.io/crates/bitflags) +[![Documentation](https://docs.rs/bitflags/badge.svg)](https://docs.rs/bitflags) +![Minimum rustc version](https://img.shields.io/badge/rustc-1.20+-yellow.svg) +![License](https://img.shields.io/crates/l/bitflags.svg) + +A Rust macro to generate structures which behave like a set of bitflags + +- [Documentation](https://docs.rs/bitflags) +- [Release notes](https://github.com/bitflags/bitflags/releases) + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +bitflags = "1.0" +``` + +and this to your crate root: + +```rust +#[macro_use] +extern crate bitflags; +``` + +## Rust Version Support + +The minimum supported Rust version is 1.20 due to use of associated constants. diff --git a/third_party/cargo/vendor/bitflags-1.2.1/build.rs b/third_party/cargo/vendor/bitflags-1.2.1/build.rs new file mode 100644 index 0000000..985757a --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/build.rs @@ -0,0 +1,44 @@ +use std::env; +use std::process::Command; +use std::str::{self, FromStr}; + +fn main(){ + let minor = match rustc_minor_version() { + Some(minor) => minor, + None => return, + }; + + // const fn stabilized in Rust 1.31: + if minor >= 31 { + println!("cargo:rustc-cfg=bitflags_const_fn"); + } +} + +fn rustc_minor_version() -> Option { + let rustc = match env::var_os("RUSTC") { + Some(rustc) => rustc, + None => return None, + }; + + let output = match Command::new(rustc).arg("--version").output() { + Ok(output) => output, + Err(_) => return None, + }; + + let version = match str::from_utf8(&output.stdout) { + Ok(version) => version, + Err(_) => return None, + }; + + let mut pieces = version.split('.'); + if pieces.next() != Some("rustc 1") { + return None; + } + + let next = match pieces.next() { + Some(next) => next, + None => return None, + }; + + u32::from_str(next).ok() +} \ No newline at end of file diff --git a/third_party/cargo/vendor/bitflags-1.2.1/src/example_generated.rs b/third_party/cargo/vendor/bitflags-1.2.1/src/example_generated.rs new file mode 100644 index 0000000..cf188d9 --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/src/example_generated.rs @@ -0,0 +1,14 @@ +//! This module shows an example of code generated by the macro. **IT MUST NOT BE USED OUTSIDE THIS +//! CRATE**. + +bitflags! { + /// This is the same `Flags` struct defined in the [crate level example](../index.html#example). + /// Note that this struct is just for documentation purposes only, it must not be used outside + /// this crate. + pub struct Flags: u32 { + const A = 0b00000001; + const B = 0b00000010; + const C = 0b00000100; + const ABC = Self::A.bits | Self::B.bits | Self::C.bits; + } +} diff --git a/third_party/cargo/vendor/bitflags-1.2.1/src/lib.rs b/third_party/cargo/vendor/bitflags-1.2.1/src/lib.rs new file mode 100644 index 0000000..3929b02 --- /dev/null +++ b/third_party/cargo/vendor/bitflags-1.2.1/src/lib.rs @@ -0,0 +1,1430 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A typesafe bitmask flag generator useful for sets of C-style bitmask flags. +//! It can be used for creating typesafe wrappers around C APIs. +//! +//! The `bitflags!` macro generates a `struct` that manages a set of flags. The +//! flags should only be defined for integer types, otherwise unexpected type +//! errors may occur at compile time. +//! +//! # Example +//! +//! ``` +//! #[macro_use] +//! extern crate bitflags; +//! +//! bitflags! { +//! struct Flags: u32 { +//! const A = 0b00000001; +//! const B = 0b00000010; +//! const C = 0b00000100; +//! const ABC = Self::A.bits | Self::B.bits | Self::C.bits; +//! } +//! } +//! +//! fn main() { +//! let e1 = Flags::A | Flags::C; +//! let e2 = Flags::B | Flags::C; +//! assert_eq!((e1 | e2), Flags::ABC); // union +//! assert_eq!((e1 & e2), Flags::C); // intersection +//! assert_eq!((e1 - e2), Flags::A); // set difference +//! assert_eq!(!e2, Flags::A); // set complement +//! } +//! ``` +//! +//! See [`example_generated::Flags`](./example_generated/struct.Flags.html) for documentation of code +//! generated by the above `bitflags!` expansion. +//! +//! The generated `struct`s can also be extended with type and trait +//! implementations: +//! +//! ``` +//! #[macro_use] +//! extern crate bitflags; +//! +//! use std::fmt; +//! +//! bitflags! { +//! struct Flags: u32 { +//! const A = 0b00000001; +//! const B = 0b00000010; +//! } +//! } +//! +//! impl Flags { +//! pub fn clear(&mut self) { +//! self.bits = 0; // The `bits` field can be accessed from within the +//! // same module where the `bitflags!` macro was invoked. +//! } +//! } +//! +//! impl fmt::Display for Flags { +//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +//! write!(f, "hi!") +//! } +//! } +//! +//! fn main() { +//! let mut flags = Flags::A | Flags::B; +//! flags.clear(); +//! assert!(flags.is_empty()); +//! assert_eq!(format!("{}", flags), "hi!"); +//! assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B"); +//! assert_eq!(format!("{:?}", Flags::B), "B"); +//! } +//! ``` +//! +//! # Visibility +//! +//! The generated struct and its associated flag constants are not exported +//! out of the current module by default. A definition can be exported out of +//! the current module by adding `pub` before `flags`: +//! +//! ``` +//! #[macro_use] +//! extern crate bitflags; +//! +//! mod example { +//! bitflags! { +//! pub struct Flags1: u32 { +//! const A = 0b00000001; +//! } +//! } +//! bitflags! { +//! # pub +//! struct Flags2: u32 { +//! const B = 0b00000010; +//! } +//! } +//! } +//! +//! fn main() { +//! let flag1 = example::Flags1::A; +//! let flag2 = example::Flags2::B; // error: const `B` is private +//! } +//! ``` +//! +//! # Attributes +//! +//! Attributes can be attached to the generated `struct` by placing them +//! before the `flags` keyword. +//! +//! # Trait implementations +//! +//! The `Copy`, `Clone`, `PartialEq`, `Eq`, `PartialOrd`, `Ord` and `Hash` +//! traits automatically derived for the `struct` using the `derive` attribute. +//! Additional traits can be derived by providing an explicit `derive` +//! attribute on `flags`. +//! +//! The `Extend` and `FromIterator` traits are implemented for the `struct`, +//! too: `Extend` adds the union of the instances of the `struct` iterated over, +//! while `FromIterator` calculates the union. +//! +//! The `Binary`, `Debug`, `LowerHex`, `Octal` and `UpperHex` trait is also +//! implemented by displaying the bits value of the internal struct. +//! +//! ## Operators +//! +//! The following operator traits are implemented for the generated `struct`: +//! +//! - `BitOr` and `BitOrAssign`: union +//! - `BitAnd` and `BitAndAssign`: intersection +//! - `BitXor` and `BitXorAssign`: toggle +//! - `Sub` and `SubAssign`: set difference +//! - `Not`: set complement +//! +//! # Methods +//! +//! The following methods are defined for the generated `struct`: +//! +//! - `empty`: an empty set of flags +//! - `all`: the set of all defined flags +//! - `bits`: the raw value of the flags currently stored +//! - `from_bits`: convert from underlying bit representation, unless that +//! representation contains bits that do not correspond to a +//! defined flag +//! - `from_bits_truncate`: convert from underlying bit representation, dropping +//! any bits that do not correspond to defined flags +//! - `from_bits_unchecked`: convert from underlying bit representation, keeping +//! all bits (even those not corresponding to defined +//! flags) +//! - `is_empty`: `true` if no flags are currently stored +//! - `is_all`: `true` if currently set flags exactly equal all defined flags +//! - `intersects`: `true` if there are flags common to both `self` and `other` +//! - `contains`: `true` all of the flags in `other` are contained within `self` +//! - `insert`: inserts the specified flags in-place +//! - `remove`: removes the specified flags in-place +//! - `toggle`: the specified flags will be inserted if not present, and removed +//! if they are. +//! - `set`: inserts or removes the specified flags depending on the passed value +//! +//! ## Default +//! +//! The `Default` trait is not automatically implemented for the generated struct. +//! +//! If your default value is equal to `0` (which is the same value as calling `empty()` +//! on the generated struct), you can simply derive `Default`: +//! +//! ``` +//! #[macro_use] +//! extern crate bitflags; +//! +//! bitflags! { +//! // Results in default value with bits: 0 +//! #[derive(Default)] +//! struct Flags: u32 { +//! const A = 0b00000001; +//! const B = 0b00000010; +//! const C = 0b00000100; +//! } +//! } +//! +//! fn main() { +//! let derived_default: Flags = Default::default(); +//! assert_eq!(derived_default.bits(), 0); +//! } +//! ``` +//! +//! If your default value is not equal to `0` you need to implement `Default` yourself: +//! +//! ``` +//! #[macro_use] +//! extern crate bitflags; +//! +//! bitflags! { +//! struct Flags: u32 { +//! const A = 0b00000001; +//! const B = 0b00000010; +//! const C = 0b00000100; +//! } +//! } +//! +//! // explicit `Default` implementation +//! impl Default for Flags { +//! fn default() -> Flags { +//! Flags::A | Flags::C +//! } +//! } +//! +//! fn main() { +//! let implemented_default: Flags = Default::default(); +//! assert_eq!(implemented_default, (Flags::A | Flags::C)); +//! } +//! ``` +//! +//! # Zero Flags +//! +//! Flags with a value equal to zero will have some strange behavior that one should be aware of. +//! +//! ``` +//! #[macro_use] +//! extern crate bitflags; +//! +//! bitflags! { +//! struct Flags: u32 { +//! const NONE = 0b00000000; +//! const SOME = 0b00000001; +//! } +//! } +//! +//! fn main() { +//! let empty = Flags::empty(); +//! let none = Flags::NONE; +//! let some = Flags::SOME; +//! +//! // Zero flags are treated as always present +//! assert!(empty.contains(Flags::NONE)); +//! assert!(none.contains(Flags::NONE)); +//! assert!(some.contains(Flags::NONE)); +//! +//! // Zero flags will be ignored when testing for emptiness +//! assert!(none.is_empty()); +//! } +//! ``` + +#![no_std] +#![doc(html_root_url = "https://docs.rs/bitflags/1.2.1")] + +#[cfg(test)] +#[macro_use] +extern crate std; + +// Re-export libcore using an alias so that the macros can work without +// requiring `extern crate core` downstream. +#[doc(hidden)] +pub extern crate core as _core; + +/// The macro used to generate the flag structure. +/// +/// See the [crate level docs](../bitflags/index.html) for complete documentation. +/// +/// # Example +/// +/// ``` +/// #[macro_use] +/// extern crate bitflags; +/// +/// bitflags! { +/// struct Flags: u32 { +/// const A = 0b00000001; +/// const B = 0b00000010; +/// const C = 0b00000100; +/// const ABC = Self::A.bits | Self::B.bits | Self::C.bits; +/// } +/// } +/// +/// fn main() { +/// let e1 = Flags::A | Flags::C; +/// let e2 = Flags::B | Flags::C; +/// assert_eq!((e1 | e2), Flags::ABC); // union +/// assert_eq!((e1 & e2), Flags::C); // intersection +/// assert_eq!((e1 - e2), Flags::A); // set difference +/// assert_eq!(!e2, Flags::A); // set complement +/// } +/// ``` +/// +/// The generated `struct`s can also be extended with type and trait +/// implementations: +/// +/// ``` +/// #[macro_use] +/// extern crate bitflags; +/// +/// use std::fmt; +/// +/// bitflags! { +/// struct Flags: u32 { +/// const A = 0b00000001; +/// const B = 0b00000010; +/// } +/// } +/// +/// impl Flags { +/// pub fn clear(&mut self) { +/// self.bits = 0; // The `bits` field can be accessed from within the +/// // same module where the `bitflags!` macro was invoked. +/// } +/// } +/// +/// impl fmt::Display for Flags { +/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// write!(f, "hi!") +/// } +/// } +/// +/// fn main() { +/// let mut flags = Flags::A | Flags::B; +/// flags.clear(); +/// assert!(flags.is_empty()); +/// assert_eq!(format!("{}", flags), "hi!"); +/// assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B"); +/// assert_eq!(format!("{:?}", Flags::B), "B"); +/// } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! bitflags { + ( + $(#[$outer:meta])* + pub struct $BitFlags:ident: $T:ty { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:ident = $value:expr; + )+ + } + ) => { + __bitflags! { + $(#[$outer])* + (pub) $BitFlags: $T { + $( + $(#[$inner $($args)*])* + $Flag = $value; + )+ + } + } + }; + ( + $(#[$outer:meta])* + struct $BitFlags:ident: $T:ty { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:ident = $value:expr; + )+ + } + ) => { + __bitflags! { + $(#[$outer])* + () $BitFlags: $T { + $( + $(#[$inner $($args)*])* + $Flag = $value; + )+ + } + } + }; + ( + $(#[$outer:meta])* + pub ($($vis:tt)+) struct $BitFlags:ident: $T:ty { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:ident = $value:expr; + )+ + } + ) => { + __bitflags! { + $(#[$outer])* + (pub ($($vis)+)) $BitFlags: $T { + $( + $(#[$inner $($args)*])* + $Flag = $value; + )+ + } + } + }; +} + +#[macro_export(local_inner_macros)] +#[doc(hidden)] +macro_rules! __bitflags { + ( + $(#[$outer:meta])* + ($($vis:tt)*) $BitFlags:ident: $T:ty { + $( + $(#[$inner:ident $($args:tt)*])* + $Flag:ident = $value:expr; + )+ + } + ) => { + $(#[$outer])* + #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] + $($vis)* struct $BitFlags { + bits: $T, + } + + __impl_bitflags! { + $BitFlags: $T { + $( + $(#[$inner $($args)*])* + $Flag = $value; + )+ + } + } + }; +} + +#[macro_export(local_inner_macros)] +#[doc(hidden)] +#[cfg(bitflags_const_fn)] +macro_rules! __fn_bitflags { + ( + $(# $attr_args:tt)* + const fn $($item:tt)* + ) => { + $(# $attr_args)* + const fn $($item)* + }; + ( + $(# $attr_args:tt)* + pub const fn $($item:tt)* + ) => { + $(# $attr_args)* + pub const fn $($item)* + }; + ( + $(# $attr_args:tt)* + pub const unsafe fn $($item:tt)* + ) => { + $(# $attr_args)* + pub const unsafe fn $($item)* + }; +} + +#[macro_export(local_inner_macros)] +#[doc(hidden)] +#[cfg(not(bitflags_const_fn))] +macro_rules! __fn_bitflags { + ( + $(# $attr_args:tt)* + const fn $($item:tt)* + ) => { + $(# $attr_args)* + fn $($item)* + }; + ( + $(# $attr_args:tt)* + pub const fn $($item:tt)* + ) => { + $(# $attr_args)* + pub fn $($item)* + }; + ( + $(# $attr_args:tt)* + pub const unsafe fn $($item:tt)* + ) => { + $(# $attr_args)* + pub unsafe fn $($item)* + }; +} + +#[macro_export(local_inner_macros)] +#[doc(hidden)] +macro_rules! __impl_bitflags { + ( + $BitFlags:ident: $T:ty { + $( + $(#[$attr:ident $($args:tt)*])* + $Flag:ident = $value:expr; + )+ + } + ) => { + impl $crate::_core::fmt::Debug for $BitFlags { + fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { + // This convoluted approach is to handle #[cfg]-based flag + // omission correctly. For example it needs to support: + // + // #[cfg(unix)] const A: Flag = /* ... */; + // #[cfg(windows)] const B: Flag = /* ... */; + + // Unconditionally define a check for every flag, even disabled + // ones. + #[allow(non_snake_case)] + trait __BitFlags { + $( + #[inline] + fn $Flag(&self) -> bool { false } + )+ + } + + // Conditionally override the check for just those flags that + // are not #[cfg]ed away. + impl __BitFlags for $BitFlags { + $( + __impl_bitflags! { + #[allow(deprecated)] + #[inline] + $(? #[$attr $($args)*])* + fn $Flag(&self) -> bool { + if Self::$Flag.bits == 0 && self.bits != 0 { + false + } else { + self.bits & Self::$Flag.bits == Self::$Flag.bits + } + } + } + )+ + } + + let mut first = true; + $( + if <$BitFlags as __BitFlags>::$Flag(self) { + if !first { + f.write_str(" | ")?; + } + first = false; + f.write_str(__bitflags_stringify!($Flag))?; + } + )+ + let extra_bits = self.bits & !$BitFlags::all().bits(); + if extra_bits != 0 { + if !first { + f.write_str(" | ")?; + } + first = false; + f.write_str("0x")?; + $crate::_core::fmt::LowerHex::fmt(&extra_bits, f)?; + } + if first { + f.write_str("(empty)")?; + } + Ok(()) + } + } + impl $crate::_core::fmt::Binary for $BitFlags { + fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { + $crate::_core::fmt::Binary::fmt(&self.bits, f) + } + } + impl $crate::_core::fmt::Octal for $BitFlags { + fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { + $crate::_core::fmt::Octal::fmt(&self.bits, f) + } + } + impl $crate::_core::fmt::LowerHex for $BitFlags { + fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { + $crate::_core::fmt::LowerHex::fmt(&self.bits, f) + } + } + impl $crate::_core::fmt::UpperHex for $BitFlags { + fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { + $crate::_core::fmt::UpperHex::fmt(&self.bits, f) + } + } + + #[allow(dead_code)] + impl $BitFlags { + $( + $(#[$attr $($args)*])* + pub const $Flag: $BitFlags = $BitFlags { bits: $value }; + )+ + + __fn_bitflags! { + /// Returns an empty set of flags + #[inline] + pub const fn empty() -> $BitFlags { + $BitFlags { bits: 0 } + } + } + + __fn_bitflags! { + /// Returns the set containing all flags. + #[inline] + pub const fn all() -> $BitFlags { + // See `Debug::fmt` for why this approach is taken. + #[allow(non_snake_case)] + trait __BitFlags { + $( + const $Flag: $T = 0; + )+ + } + impl __BitFlags for $BitFlags { + $( + __impl_bitflags! { + #[allow(deprecated)] + $(? #[$attr $($args)*])* + const $Flag: $T = Self::$Flag.bits; + } + )+ + } + $BitFlags { bits: $(<$BitFlags as __BitFlags>::$Flag)|+ } + } + } + + __fn_bitflags! { + /// Returns the raw value of the flags currently stored. + #[inline] + pub const fn bits(&self) -> $T { + self.bits + } + } + + /// Convert from underlying bit representation, unless that + /// representation contains bits that do not correspond to a flag. + #[inline] + pub fn from_bits(bits: $T) -> $crate::_core::option::Option<$BitFlags> { + if (bits & !$BitFlags::all().bits()) == 0 { + $crate::_core::option::Option::Some($BitFlags { bits }) + } else { + $crate::_core::option::Option::None + } + } + + __fn_bitflags! { + /// Convert from underlying bit representation, dropping any bits + /// that do not correspond to flags. + #[inline] + pub const fn from_bits_truncate(bits: $T) -> $BitFlags { + $BitFlags { bits: bits & $BitFlags::all().bits } + } + } + + __fn_bitflags! { + /// Convert from underlying bit representation, preserving all + /// bits (even those not corresponding to a defined flag). + #[inline] + pub const unsafe fn from_bits_unchecked(bits: $T) -> $BitFlags { + $BitFlags { bits } + } + } + + __fn_bitflags! { + /// Returns `true` if no flags are currently stored. + #[inline] + pub const fn is_empty(&self) -> bool { + self.bits() == $BitFlags::empty().bits() + } + } + + __fn_bitflags! { + /// Returns `true` if all flags are currently set. + #[inline] + pub const fn is_all(&self) -> bool { + self.bits == $BitFlags::all().bits + } + } + + __fn_bitflags! { + /// Returns `true` if there are flags common to both `self` and `other`. + #[inline] + pub const fn intersects(&self, other: $BitFlags) -> bool { + !$BitFlags{ bits: self.bits & other.bits}.is_empty() + } + } + + __fn_bitflags! { + /// Returns `true` all of the flags in `other` are contained within `self`. + #[inline] + pub const fn contains(&self, other: $BitFlags) -> bool { + (self.bits & other.bits) == other.bits + } + } + + /// Inserts the specified flags in-place. + #[inline] + pub fn insert(&mut self, other: $BitFlags) { + self.bits |= other.bits; + } + + /// Removes the specified flags in-place. + #[inline] + pub fn remove(&mut self, other: $BitFlags) { + self.bits &= !other.bits; + } + + /// Toggles the specified flags in-place. + #[inline] + pub fn toggle(&mut self, other: $BitFlags) { + self.bits ^= other.bits; + } + + /// Inserts or removes the specified flags depending on the passed value. + #[inline] + pub fn set(&mut self, other: $BitFlags, value: bool) { + if value { + self.insert(other); + } else { + self.remove(other); + } + } + } + + impl $crate::_core::ops::BitOr for $BitFlags { + type Output = $BitFlags; + + /// Returns the union of the two sets of flags. + #[inline] + fn bitor(self, other: $BitFlags) -> $BitFlags { + $BitFlags { bits: self.bits | other.bits } + } + } + + impl $crate::_core::ops::BitOrAssign for $BitFlags { + + /// Adds the set of flags. + #[inline] + fn bitor_assign(&mut self, other: $BitFlags) { + self.bits |= other.bits; + } + } + + impl $crate::_core::ops::BitXor for $BitFlags { + type Output = $BitFlags; + + /// Returns the left flags, but with all the right flags toggled. + #[inline] + fn bitxor(self, other: $BitFlags) -> $BitFlags { + $BitFlags { bits: self.bits ^ other.bits } + } + } + + impl $crate::_core::ops::BitXorAssign for $BitFlags { + + /// Toggles the set of flags. + #[inline] + fn bitxor_assign(&mut self, other: $BitFlags) { + self.bits ^= other.bits; + } + } + + impl $crate::_core::ops::BitAnd for $BitFlags { + type Output = $BitFlags; + + /// Returns the intersection between the two sets of flags. + #[inline] + fn bitand(self, other: $BitFlags) -> $BitFlags { + $BitFlags { bits: self.bits & other.bits } + } + } + + impl $crate::_core::ops::BitAndAssign for $BitFlags { + + /// Disables all flags disabled in the set. + #[inline] + fn bitand_assign(&mut self, other: $BitFlags) { + self.bits &= other.bits; + } + } + + impl $crate::_core::ops::Sub for $BitFlags { + type Output = $BitFlags; + + /// Returns the set difference of the two sets of flags. + #[inline] + fn sub(self, other: $BitFlags) -> $BitFlags { + $BitFlags { bits: self.bits & !other.bits } + } + } + + impl $crate::_core::ops::SubAssign for $BitFlags { + + /// Disables all flags enabled in the set. + #[inline] + fn sub_assign(&mut self, other: $BitFlags) { + self.bits &= !other.bits; + } + } + + impl $crate::_core::ops::Not for $BitFlags { + type Output = $BitFlags; + + /// Returns the complement of this set of flags. + #[inline] + fn not(self) -> $BitFlags { + $BitFlags { bits: !self.bits } & $BitFlags::all() + } + } + + impl $crate::_core::iter::Extend<$BitFlags> for $BitFlags { + fn extend>(&mut self, iterator: T) { + for item in iterator { + self.insert(item) + } + } + } + + impl $crate::_core::iter::FromIterator<$BitFlags> for $BitFlags { + fn from_iter>(iterator: T) -> $BitFlags { + let mut result = Self::empty(); + result.extend(iterator); + result + } + } + }; + + // Every attribute that the user writes on a const is applied to the + // corresponding const that we generate, but within the implementation of + // Debug and all() we want to ignore everything but #[cfg] attributes. In + // particular, including a #[deprecated] attribute on those items would fail + // to compile. + // https://github.com/bitflags/bitflags/issues/109 + // + // Input: + // + // ? #[cfg(feature = "advanced")] + // ? #[deprecated(note = "Use somthing else.")] + // ? #[doc = r"High quality documentation."] + // fn f() -> i32 { /* ... */ } + // + // Output: + // + // #[cfg(feature = "advanced")] + // fn f() -> i32 { /* ... */ } + ( + $(#[$filtered:meta])* + ? #[cfg $($cfgargs:tt)*] + $(? #[$rest:ident $($restargs:tt)*])* + fn $($item:tt)* + ) => { + __impl_bitflags! { + $(#[$filtered])* + #[cfg $($cfgargs)*] + $(? #[$rest $($restargs)*])* + fn $($item)* + } + }; + ( + $(#[$filtered:meta])* + // $next != `cfg` + ? #[$next:ident $($nextargs:tt)*] + $(? #[$rest:ident $($restargs:tt)*])* + fn $($item:tt)* + ) => { + __impl_bitflags! { + $(#[$filtered])* + // $next filtered out + $(? #[$rest $($restargs)*])* + fn $($item)* + } + }; + ( + $(#[$filtered:meta])* + fn $($item:tt)* + ) => { + $(#[$filtered])* + fn $($item)* + }; + + // Every attribute that the user writes on a const is applied to the + // corresponding const that we generate, but within the implementation of + // Debug and all() we want to ignore everything but #[cfg] attributes. In + // particular, including a #[deprecated] attribute on those items would fail + // to compile. + // https://github.com/bitflags/bitflags/issues/109 + // + // const version + // + // Input: + // + // ? #[cfg(feature = "advanced")] + // ? #[deprecated(note = "Use somthing else.")] + // ? #[doc = r"High quality documentation."] + // const f: i32 { /* ... */ } + // + // Output: + // + // #[cfg(feature = "advanced")] + // const f: i32 { /* ... */ } + ( + $(#[$filtered:meta])* + ? #[cfg $($cfgargs:tt)*] + $(? #[$rest:ident $($restargs:tt)*])* + const $($item:tt)* + ) => { + __impl_bitflags! { + $(#[$filtered])* + #[cfg $($cfgargs)*] + $(? #[$rest $($restargs)*])* + const $($item)* + } + }; + ( + $(#[$filtered:meta])* + // $next != `cfg` + ? #[$next:ident $($nextargs:tt)*] + $(? #[$rest:ident $($restargs:tt)*])* + const $($item:tt)* + ) => { + __impl_bitflags! { + $(#[$filtered])* + // $next filtered out + $(? #[$rest $($restargs)*])* + const $($item)* + } + }; + ( + $(#[$filtered:meta])* + const $($item:tt)* + ) => { + $(#[$filtered])* + const $($item)* + }; +} + +// Same as std::stringify but callable from __impl_bitflags, which needs to use +// local_inner_macros so can only directly call macros from this crate. +#[macro_export] +#[doc(hidden)] +macro_rules! __bitflags_stringify { + ($s:ident) => { + stringify!($s) + }; +} + +#[cfg(feature = "example_generated")] +pub mod example_generated; + +#[cfg(test)] +mod tests { + use std::collections::hash_map::DefaultHasher; + use std::hash::{Hash, Hasher}; + + bitflags! { + #[doc = "> The first principle is that you must not fool yourself — and"] + #[doc = "> you are the easiest person to fool."] + #[doc = "> "] + #[doc = "> - Richard Feynman"] + struct Flags: u32 { + const A = 0b00000001; + #[doc = " macros are way better at generating code than trans is"] + const B = 0b00000010; + const C = 0b00000100; + #[doc = "* cmr bed"] + #[doc = "* strcat table"] + #[doc = " wait what?"] + const ABC = Self::A.bits | Self::B.bits | Self::C.bits; + } + } + + bitflags! { + struct _CfgFlags: u32 { + #[cfg(unix)] + const _CFG_A = 0b01; + #[cfg(windows)] + const _CFG_B = 0b01; + #[cfg(unix)] + const _CFG_C = Self::_CFG_A.bits | 0b10; + } + } + + bitflags! { + struct AnotherSetOfFlags: i8 { + const ANOTHER_FLAG = -1_i8; + } + } + + bitflags! { + struct LongFlags: u32 { + const LONG_A = 0b1111111111111111; + } + } + + #[test] + fn test_bits() { + assert_eq!(Flags::empty().bits(), 0b00000000); + assert_eq!(Flags::A.bits(), 0b00000001); + assert_eq!(Flags::ABC.bits(), 0b00000111); + + assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00); + assert_eq!(AnotherSetOfFlags::ANOTHER_FLAG.bits(), !0_i8); + } + + #[test] + fn test_from_bits() { + assert_eq!(Flags::from_bits(0), Some(Flags::empty())); + assert_eq!(Flags::from_bits(0b1), Some(Flags::A)); + assert_eq!(Flags::from_bits(0b10), Some(Flags::B)); + assert_eq!(Flags::from_bits(0b11), Some(Flags::A | Flags::B)); + assert_eq!(Flags::from_bits(0b1000), None); + + assert_eq!( + AnotherSetOfFlags::from_bits(!0_i8), + Some(AnotherSetOfFlags::ANOTHER_FLAG) + ); + } + + #[test] + fn test_from_bits_truncate() { + assert_eq!(Flags::from_bits_truncate(0), Flags::empty()); + assert_eq!(Flags::from_bits_truncate(0b1), Flags::A); + assert_eq!(Flags::from_bits_truncate(0b10), Flags::B); + assert_eq!(Flags::from_bits_truncate(0b11), (Flags::A | Flags::B)); + assert_eq!(Flags::from_bits_truncate(0b1000), Flags::empty()); + assert_eq!(Flags::from_bits_truncate(0b1001), Flags::A); + + assert_eq!( + AnotherSetOfFlags::from_bits_truncate(0_i8), + AnotherSetOfFlags::empty() + ); + } + + #[test] + fn test_from_bits_unchecked() { + let extra = unsafe { Flags::from_bits_unchecked(0b1000) }; + assert_eq!(unsafe { Flags::from_bits_unchecked(0) }, Flags::empty()); + assert_eq!(unsafe { Flags::from_bits_unchecked(0b1) }, Flags::A); + assert_eq!(unsafe { Flags::from_bits_unchecked(0b10) }, Flags::B); + assert_eq!(unsafe { Flags::from_bits_unchecked(0b11) }, (Flags::A | Flags::B)); + assert_eq!(unsafe { Flags::from_bits_unchecked(0b1000) }, (extra | Flags::empty())); + assert_eq!(unsafe { Flags::from_bits_unchecked(0b1001) }, (extra | Flags::A)); + } + + #[test] + fn test_is_empty() { + assert!(Flags::empty().is_empty()); + assert!(!Flags::A.is_empty()); + assert!(!Flags::ABC.is_empty()); + + assert!(!AnotherSetOfFlags::ANOTHER_FLAG.is_empty()); + } + + #[test] + fn test_is_all() { + assert!(Flags::all().is_all()); + assert!(!Flags::A.is_all()); + assert!(Flags::ABC.is_all()); + + assert!(AnotherSetOfFlags::ANOTHER_FLAG.is_all()); + } + + #[test] + fn test_two_empties_do_not_intersect() { + let e1 = Flags::empty(); + let e2 = Flags::empty(); + assert!(!e1.intersects(e2)); + + assert!(AnotherSetOfFlags::ANOTHER_FLAG.intersects(AnotherSetOfFlags::ANOTHER_FLAG)); + } + + #[test] + fn test_empty_does_not_intersect_with_full() { + let e1 = Flags::empty(); + let e2 = Flags::ABC; + assert!(!e1.intersects(e2)); + } + + #[test] + fn test_disjoint_intersects() { + let e1 = Flags::A; + let e2 = Flags::B; + assert!(!e1.intersects(e2)); + } + + #[test] + fn test_overlapping_intersects() { + let e1 = Flags::A; + let e2 = Flags::A | Flags::B; + assert!(e1.intersects(e2)); + } + + #[test] + fn test_contains() { + let e1 = Flags::A; + let e2 = Flags::A | Flags::B; + assert!(!e1.contains(e2)); + assert!(e2.contains(e1)); + assert!(Flags::ABC.contains(e2)); + + assert!(AnotherSetOfFlags::ANOTHER_FLAG.contains(AnotherSetOfFlags::ANOTHER_FLAG)); + } + + #[test] + fn test_insert() { + let mut e1 = Flags::A; + let e2 = Flags::A | Flags::B; + e1.insert(e2); + assert_eq!(e1, e2); + + let mut e3 = AnotherSetOfFlags::empty(); + e3.insert(AnotherSetOfFlags::ANOTHER_FLAG); + assert_eq!(e3, AnotherSetOfFlags::ANOTHER_FLAG); + } + + #[test] + fn test_remove() { + let mut e1 = Flags::A | Flags::B; + let e2 = Flags::A | Flags::C; + e1.remove(e2); + assert_eq!(e1, Flags::B); + + let mut e3 = AnotherSetOfFlags::ANOTHER_FLAG; + e3.remove(AnotherSetOfFlags::ANOTHER_FLAG); + assert_eq!(e3, AnotherSetOfFlags::empty()); + } + + #[test] + fn test_operators() { + let e1 = Flags::A | Flags::C; + let e2 = Flags::B | Flags::C; + assert_eq!((e1 | e2), Flags::ABC); // union + assert_eq!((e1 & e2), Flags::C); // intersection + assert_eq!((e1 - e2), Flags::A); // set difference + assert_eq!(!e2, Flags::A); // set complement + assert_eq!(e1 ^ e2, Flags::A | Flags::B); // toggle + let mut e3 = e1; + e3.toggle(e2); + assert_eq!(e3, Flags::A | Flags::B); + + let mut m4 = AnotherSetOfFlags::empty(); + m4.toggle(AnotherSetOfFlags::empty()); + assert_eq!(m4, AnotherSetOfFlags::empty()); + } + + #[test] + fn test_operators_unchecked() { + let extra = unsafe { Flags::from_bits_unchecked(0b1000) }; + let e1 = Flags::A | Flags::C | extra; + let e2 = Flags::B | Flags::C; + assert_eq!((e1 | e2), (Flags::ABC | extra)); // union + assert_eq!((e1 & e2), Flags::C); // intersection + assert_eq!((e1 - e2), (Flags::A | extra)); // set difference + assert_eq!(!e2, Flags::A); // set complement + assert_eq!(!e1, Flags::B); // set complement + assert_eq!(e1 ^ e2, Flags::A | Flags::B | extra); // toggle + let mut e3 = e1; + e3.toggle(e2); + assert_eq!(e3, Flags::A | Flags::B | extra); + } + + #[test] + fn test_set() { + let mut e1 = Flags::A | Flags::C; + e1.set(Flags::B, true); + e1.set(Flags::C, false); + + assert_eq!(e1, Flags::A | Flags::B); + } + + #[test] + fn test_assignment_operators() { + let mut m1 = Flags::empty(); + let e1 = Flags::A | Flags::C; + // union + m1 |= Flags::A; + assert_eq!(m1, Flags::A); + // intersection + m1 &= e1; + assert_eq!(m1, Flags::A); + // set difference + m1 -= m1; + assert_eq!(m1, Flags::empty()); + // toggle + m1 ^= e1; + assert_eq!(m1, e1); + } + + + #[cfg(bitflags_const_fn)] + #[test] + fn test_const_fn() { + const _M1: Flags = Flags::empty(); + + const M2: Flags = Flags::A; + assert_eq!(M2, Flags::A); + + const M3: Flags = Flags::C; + assert_eq!(M3, Flags::C); + } + + #[test] + fn test_extend() { + let mut flags; + + flags = Flags::empty(); + flags.extend([].iter().cloned()); + assert_eq!(flags, Flags::empty()); + + flags = Flags::empty(); + flags.extend([Flags::A, Flags::B].iter().cloned()); + assert_eq!(flags, Flags::A | Flags::B); + + flags = Flags::A; + flags.extend([Flags::A, Flags::B].iter().cloned()); + assert_eq!(flags, Flags::A | Flags::B); + + flags = Flags::B; + flags.extend([Flags::A, Flags::ABC].iter().cloned()); + assert_eq!(flags, Flags::ABC); + } + + #[test] + fn test_from_iterator() { + assert_eq!([].iter().cloned().collect::(), Flags::empty()); + assert_eq!( + [Flags::A, Flags::B].iter().cloned().collect::(), + Flags::A | Flags::B + ); + assert_eq!( + [Flags::A, Flags::ABC].iter().cloned().collect::(), + Flags::ABC + ); + } + + #[test] + fn test_lt() { + let mut a = Flags::empty(); + let mut b = Flags::empty(); + + assert!(!(a < b) && !(b < a)); + b = Flags::B; + assert!(a < b); + a = Flags::C; + assert!(!(a < b) && b < a); + b = Flags::C | Flags::B; + assert!(a < b); + } + + #[test] + fn test_ord() { + let mut a = Flags::empty(); + let mut b = Flags::empty(); + + assert!(a <= b && a >= b); + a = Flags::A; + assert!(a > b && a >= b); + assert!(b < a && b <= a); + b = Flags::B; + assert!(b > a && b >= a); + assert!(a < b && a <= b); + } + + fn hash(t: &T) -> u64 { + let mut s = DefaultHasher::new(); + t.hash(&mut s); + s.finish() + } + + #[test] + fn test_hash() { + let mut x = Flags::empty(); + let mut y = Flags::empty(); + assert_eq!(hash(&x), hash(&y)); + x = Flags::all(); + y = Flags::ABC; + assert_eq!(hash(&x), hash(&y)); + } + + #[test] + fn test_debug() { + assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B"); + assert_eq!(format!("{:?}", Flags::empty()), "(empty)"); + assert_eq!(format!("{:?}", Flags::ABC), "A | B | C | ABC"); + let extra = unsafe { Flags::from_bits_unchecked(0xb8) }; + assert_eq!(format!("{:?}", extra), "0xb8"); + assert_eq!(format!("{:?}", Flags::A | extra), "A | 0xb8"); + assert_eq!(format!("{:?}", Flags::ABC | extra), "A | B | C | ABC | 0xb8"); + } + + #[test] + fn test_binary() { + assert_eq!(format!("{:b}", Flags::ABC), "111"); + assert_eq!(format!("{:#b}", Flags::ABC), "0b111"); + let extra = unsafe { Flags::from_bits_unchecked(0b1010000) }; + assert_eq!(format!("{:b}", Flags::ABC | extra), "1010111"); + assert_eq!(format!("{:#b}", Flags::ABC | extra), "0b1010111"); + } + + #[test] + fn test_octal() { + assert_eq!(format!("{:o}", LongFlags::LONG_A), "177777"); + assert_eq!(format!("{:#o}", LongFlags::LONG_A), "0o177777"); + let extra = unsafe { LongFlags::from_bits_unchecked(0o5000000) }; + assert_eq!(format!("{:o}", LongFlags::LONG_A | extra), "5177777"); + assert_eq!(format!("{:#o}", LongFlags::LONG_A | extra), "0o5177777"); + } + + #[test] + fn test_lowerhex() { + assert_eq!(format!("{:x}", LongFlags::LONG_A), "ffff"); + assert_eq!(format!("{:#x}", LongFlags::LONG_A), "0xffff"); + let extra = unsafe { LongFlags::from_bits_unchecked(0xe00000) }; + assert_eq!(format!("{:x}", LongFlags::LONG_A | extra), "e0ffff"); + assert_eq!(format!("{:#x}", LongFlags::LONG_A | extra), "0xe0ffff"); + } + + #[test] + fn test_upperhex() { + assert_eq!(format!("{:X}", LongFlags::LONG_A), "FFFF"); + assert_eq!(format!("{:#X}", LongFlags::LONG_A), "0xFFFF"); + let extra = unsafe { LongFlags::from_bits_unchecked(0xe00000) }; + assert_eq!(format!("{:X}", LongFlags::LONG_A | extra), "E0FFFF"); + assert_eq!(format!("{:#X}", LongFlags::LONG_A | extra), "0xE0FFFF"); + } + + mod submodule { + bitflags! { + pub struct PublicFlags: i8 { + const X = 0; + } + } + bitflags! { + struct PrivateFlags: i8 { + const Y = 0; + } + } + + #[test] + fn test_private() { + let _ = PrivateFlags::Y; + } + } + + #[test] + fn test_public() { + let _ = submodule::PublicFlags::X; + } + + mod t1 { + mod foo { + pub type Bar = i32; + } + + bitflags! { + /// baz + struct Flags: foo::Bar { + const A = 0b00000001; + #[cfg(foo)] + const B = 0b00000010; + #[cfg(foo)] + const C = 0b00000010; + } + } + } + + #[test] + fn test_in_function() { + bitflags! { + struct Flags: u8 { + const A = 1; + #[cfg(any())] // false + const B = 2; + } + } + assert_eq!(Flags::all(), Flags::A); + assert_eq!(format!("{:?}", Flags::A), "A"); + } + + #[test] + fn test_deprecated() { + bitflags! { + pub struct TestFlags: u32 { + #[deprecated(note = "Use something else.")] + const ONE = 1; + } + } + } + + #[test] + fn test_pub_crate() { + mod module { + bitflags! { + pub (crate) struct Test: u8 { + const FOO = 1; + } + } + } + + assert_eq!(module::Test::FOO.bits(), 1); + } + + #[test] + fn test_pub_in_module() { + mod module { + mod submodule { + bitflags! { + // `pub (in super)` means only the module `module` will + // be able to access this. + pub (in super) struct Test: u8 { + const FOO = 1; + } + } + } + + mod test { + // Note: due to `pub (in super)`, + // this cannot be accessed directly by the testing code. + pub(super) fn value() -> u8 { + super::submodule::Test::FOO.bits() + } + } + + pub fn value() -> u8 { + test::value() + } + } + + assert_eq!(module::value(), 1) + } + + #[test] + fn test_zero_value_flags() { + bitflags! { + struct Flags: u32 { + const NONE = 0b0; + const SOME = 0b1; + } + } + + assert!(Flags::empty().contains(Flags::NONE)); + assert!(Flags::SOME.contains(Flags::NONE)); + assert!(Flags::NONE.is_empty()); + + assert_eq!(format!("{:?}", Flags::empty()), "NONE"); + assert_eq!(format!("{:?}", Flags::SOME), "SOME"); + } +} diff --git a/third_party/cargo/vendor/block-0.1.6/.cargo-checksum.json b/third_party/cargo/vendor/block-0.1.6/.cargo-checksum.json new file mode 100644 index 0000000..91c6a11 --- /dev/null +++ b/third_party/cargo/vendor/block-0.1.6/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"24df2f33b48c9e756a4f864f882c1ab07a159b6c2b790f45af2e8162499b6719","README.md":"01c56329fa14f48ea1c9c7986c3660c41beeff2477f61c2d36bd8e666b9fc562","src/lib.rs":"eb31678adf63b53109d9b94eba23699fd5f9ebfdb950f6e1a57ad51bb6a146fa","src/test_utils.rs":"271bd579b67e2440134227cf8ee52c1b8c22854eb0c7923b46306b51810c2cf1"},"package":"0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"} \ No newline at end of file diff --git a/third_party/cargo/vendor/block-0.1.6/BUILD b/third_party/cargo/vendor/block-0.1.6/BUILD new file mode 100644 index 0000000..f32dbbb --- /dev/null +++ b/third_party/cargo/vendor/block-0.1.6/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "block", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.6", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/block-0.1.6/Cargo.toml b/third_party/cargo/vendor/block-0.1.6/Cargo.toml new file mode 100644 index 0000000..f414e7e --- /dev/null +++ b/third_party/cargo/vendor/block-0.1.6/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "block" +version = "0.1.6" +authors = ["Steven Sheldon"] + +description = "Rust interface for Apple's C language extension of blocks." +keywords = ["blocks", "osx", "ios", "objective-c"] +readme = "README.md" +repository = "http://github.com/SSheldon/rust-block" +documentation = "http://ssheldon.github.io/rust-objc/block/" +license = "MIT" + +exclude = [ + ".gitignore", + ".travis.yml", + "travis_install.sh", + "travis_test.sh", + "tests-ios/**", +] + +[dev-dependencies.objc_test_utils] +version = "0.0" +path = "test_utils" diff --git a/third_party/cargo/vendor/block-0.1.6/README.md b/third_party/cargo/vendor/block-0.1.6/README.md new file mode 100644 index 0000000..78c65d0 --- /dev/null +++ b/third_party/cargo/vendor/block-0.1.6/README.md @@ -0,0 +1,42 @@ +Rust interface for Apple's C language extension of blocks. + +For more information on the specifics of the block implementation, see +Clang's documentation: http://clang.llvm.org/docs/Block-ABI-Apple.html + +## Invoking blocks + +The `Block` struct is used for invoking blocks from Objective-C. For example, +consider this Objective-C function: + +``` objc +int32_t sum(int32_t (^block)(int32_t, int32_t)) { + return block(5, 8); +} +``` + +We could write it in Rust as the following: + +``` rust +unsafe fn sum(block: &Block<(i32, i32), i32>) -> i32 { + block.call((5, 8)) +} +``` + +Note the extra parentheses in the `call` method, since the arguments must be +passed as a tuple. + +## Creating blocks + +Creating a block to pass to Objective-C can be done with the `ConcreteBlock` +struct. For example, to create a block that adds two `i32`s, we could write: + +``` rust +let block = ConcreteBlock::new(|a: i32, b: i32| a + b); +let block = block.copy(); +assert!(unsafe { block.call((5, 8)) } == 13); +``` + +It is important to copy your block to the heap (with the `copy` method) before +passing it to Objective-C; this is because our `ConcreteBlock` is only meant +to be copied once, and we can enforce this in Rust, but if Objective-C code +were to copy it twice we could have a double free. diff --git a/third_party/cargo/vendor/block-0.1.6/src/lib.rs b/third_party/cargo/vendor/block-0.1.6/src/lib.rs new file mode 100644 index 0000000..b9c5d1d --- /dev/null +++ b/third_party/cargo/vendor/block-0.1.6/src/lib.rs @@ -0,0 +1,396 @@ +/*! +A Rust interface for Objective-C blocks. + +For more information on the specifics of the block implementation, see +Clang's documentation: http://clang.llvm.org/docs/Block-ABI-Apple.html + +# Invoking blocks + +The `Block` struct is used for invoking blocks from Objective-C. For example, +consider this Objective-C function: + +``` objc +int32_t sum(int32_t (^block)(int32_t, int32_t)) { + return block(5, 8); +} +``` + +We could write it in Rust as the following: + +``` +# use block::Block; +unsafe fn sum(block: &Block<(i32, i32), i32>) -> i32 { + block.call((5, 8)) +} +``` + +Note the extra parentheses in the `call` method, since the arguments must be +passed as a tuple. + +# Creating blocks + +Creating a block to pass to Objective-C can be done with the `ConcreteBlock` +struct. For example, to create a block that adds two `i32`s, we could write: + +``` +# use block::ConcreteBlock; +let block = ConcreteBlock::new(|a: i32, b: i32| a + b); +let block = block.copy(); +assert!(unsafe { block.call((5, 8)) } == 13); +``` + +It is important to copy your block to the heap (with the `copy` method) before +passing it to Objective-C; this is because our `ConcreteBlock` is only meant +to be copied once, and we can enforce this in Rust, but if Objective-C code +were to copy it twice we could have a double free. +*/ + +#[cfg(test)] +mod test_utils; + +use std::marker::PhantomData; +use std::mem; +use std::ops::{Deref, DerefMut}; +use std::os::raw::{c_int, c_ulong, c_void}; +use std::ptr; + +enum Class { } + +#[cfg_attr(any(target_os = "macos", target_os = "ios"), + link(name = "System", kind = "dylib"))] +#[cfg_attr(not(any(target_os = "macos", target_os = "ios")), + link(name = "BlocksRuntime", kind = "dylib"))] +extern { + static _NSConcreteStackBlock: Class; + + fn _Block_copy(block: *const c_void) -> *mut c_void; + fn _Block_release(block: *const c_void); +} + +/// Types that may be used as the arguments to an Objective-C block. +pub trait BlockArguments: Sized { + /// Calls the given `Block` with self as the arguments. + /// + /// Unsafe because `block` must point to a valid `Block` and this invokes + /// foreign code whose safety the compiler cannot verify. + unsafe fn call_block(self, block: *mut Block) -> R; +} + +macro_rules! block_args_impl { + ($($a:ident : $t:ident),*) => ( + impl<$($t),*> BlockArguments for ($($t,)*) { + unsafe fn call_block(self, block: *mut Block) -> R { + let invoke: unsafe extern fn(*mut Block $(, $t)*) -> R = { + let base = block as *mut BlockBase; + mem::transmute((*base).invoke) + }; + let ($($a,)*) = self; + invoke(block $(, $a)*) + } + } + ); +} + +block_args_impl!(); +block_args_impl!(a: A); +block_args_impl!(a: A, b: B); +block_args_impl!(a: A, b: B, c: C); +block_args_impl!(a: A, b: B, c: C, d: D); +block_args_impl!(a: A, b: B, c: C, d: D, e: E); +block_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F); +block_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G); +block_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H); +block_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I); +block_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J); +block_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K); +block_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L); + +#[repr(C)] +struct BlockBase { + isa: *const Class, + flags: c_int, + _reserved: c_int, + invoke: unsafe extern fn(*mut Block, ...) -> R, +} + +/// An Objective-C block that takes arguments of `A` when called and +/// returns a value of `R`. +#[repr(C)] +pub struct Block { + _base: PhantomData>, +} + +impl Block where A: BlockArguments { + /// Call self with the given arguments. + /// + /// Unsafe because this invokes foreign code that the caller must verify + /// doesn't violate any of Rust's safety rules. For example, if this block + /// is shared with multiple references, the caller must ensure that calling + /// it will not cause a data race. + pub unsafe fn call(&self, args: A) -> R { + args.call_block(self as *const _ as *mut _) + } +} + +/// A reference-counted Objective-C block. +pub struct RcBlock { + ptr: *mut Block, +} + +impl RcBlock { + /// Construct an `RcBlock` for the given block without copying it. + /// The caller must ensure the block has a +1 reference count. + /// + /// Unsafe because `ptr` must point to a valid `Block` and must have a +1 + /// reference count or it will be overreleased when the `RcBlock` is + /// dropped. + pub unsafe fn new(ptr: *mut Block) -> Self { + RcBlock { ptr: ptr } + } + + /// Constructs an `RcBlock` by copying the given block. + /// + /// Unsafe because `ptr` must point to a valid `Block`. + pub unsafe fn copy(ptr: *mut Block) -> Self { + let ptr = _Block_copy(ptr as *const c_void) as *mut Block; + RcBlock { ptr: ptr } + } +} + +impl Clone for RcBlock { + fn clone(&self) -> RcBlock { + unsafe { + RcBlock::copy(self.ptr) + } + } +} + +impl Deref for RcBlock { + type Target = Block; + + fn deref(&self) -> &Block { + unsafe { &*self.ptr } + } +} + +impl Drop for RcBlock { + fn drop(&mut self) { + unsafe { + _Block_release(self.ptr as *const c_void); + } + } +} + +/// Types that may be converted into a `ConcreteBlock`. +pub trait IntoConcreteBlock: Sized where A: BlockArguments { + /// The return type of the resulting `ConcreteBlock`. + type Ret; + + /// Consumes self to create a `ConcreteBlock`. + fn into_concrete_block(self) -> ConcreteBlock; +} + +macro_rules! concrete_block_impl { + ($f:ident) => ( + concrete_block_impl!($f,); + ); + ($f:ident, $($a:ident : $t:ident),*) => ( + impl<$($t,)* R, X> IntoConcreteBlock<($($t,)*)> for X + where X: Fn($($t,)*) -> R { + type Ret = R; + + fn into_concrete_block(self) -> ConcreteBlock<($($t,)*), R, X> { + unsafe extern fn $f<$($t,)* R, X>( + block_ptr: *mut ConcreteBlock<($($t,)*), R, X> + $(, $a: $t)*) -> R + where X: Fn($($t,)*) -> R { + let block = &*block_ptr; + (block.closure)($($a),*) + } + + let f: unsafe extern fn(*mut ConcreteBlock<($($t,)*), R, X> $(, $a: $t)*) -> R = $f; + unsafe { + ConcreteBlock::with_invoke(mem::transmute(f), self) + } + } + } + ); +} + +concrete_block_impl!(concrete_block_invoke_args0); +concrete_block_impl!(concrete_block_invoke_args1, a: A); +concrete_block_impl!(concrete_block_invoke_args2, a: A, b: B); +concrete_block_impl!(concrete_block_invoke_args3, a: A, b: B, c: C); +concrete_block_impl!(concrete_block_invoke_args4, a: A, b: B, c: C, d: D); +concrete_block_impl!(concrete_block_invoke_args5, a: A, b: B, c: C, d: D, e: E); +concrete_block_impl!(concrete_block_invoke_args6, a: A, b: B, c: C, d: D, e: E, f: F); +concrete_block_impl!(concrete_block_invoke_args7, a: A, b: B, c: C, d: D, e: E, f: F, g: G); +concrete_block_impl!(concrete_block_invoke_args8, a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H); +concrete_block_impl!(concrete_block_invoke_args9, a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I); +concrete_block_impl!(concrete_block_invoke_args10, a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J); +concrete_block_impl!(concrete_block_invoke_args11, a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K); +concrete_block_impl!(concrete_block_invoke_args12, a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L); + +/// An Objective-C block whose size is known at compile time and may be +/// constructed on the stack. +#[repr(C)] +pub struct ConcreteBlock { + base: BlockBase, + descriptor: Box>>, + closure: F, +} + +impl ConcreteBlock + where A: BlockArguments, F: IntoConcreteBlock { + /// Constructs a `ConcreteBlock` with the given closure. + /// When the block is called, it will return the value that results from + /// calling the closure. + pub fn new(closure: F) -> Self { + closure.into_concrete_block() + } +} + +impl ConcreteBlock { + /// Constructs a `ConcreteBlock` with the given invoke function and closure. + /// Unsafe because the caller must ensure the invoke function takes the + /// correct arguments. + unsafe fn with_invoke(invoke: unsafe extern fn(*mut Self, ...) -> R, + closure: F) -> Self { + ConcreteBlock { + base: BlockBase { + isa: &_NSConcreteStackBlock, + // 1 << 25 = BLOCK_HAS_COPY_DISPOSE + flags: 1 << 25, + _reserved: 0, + invoke: mem::transmute(invoke), + }, + descriptor: Box::new(BlockDescriptor::new()), + closure: closure, + } + } +} + +impl ConcreteBlock where F: 'static { + /// Copy self onto the heap as an `RcBlock`. + pub fn copy(self) -> RcBlock { + unsafe { + let mut block = self; + let copied = RcBlock::copy(&mut *block); + // At this point, our copy helper has been run so the block will + // be moved to the heap and we can forget the original block + // because the heap block will drop in our dispose helper. + mem::forget(block); + copied + } + } +} + +impl Clone for ConcreteBlock where F: Clone { + fn clone(&self) -> Self { + unsafe { + ConcreteBlock::with_invoke(mem::transmute(self.base.invoke), + self.closure.clone()) + } + } +} + +impl Deref for ConcreteBlock { + type Target = Block; + + fn deref(&self) -> &Block { + unsafe { &*(&self.base as *const _ as *const Block) } + } +} + +impl DerefMut for ConcreteBlock { + fn deref_mut(&mut self) -> &mut Block { + unsafe { &mut *(&mut self.base as *mut _ as *mut Block) } + } +} + +unsafe extern fn block_context_dispose(block: &mut B) { + // Read the block onto the stack and let it drop + ptr::read(block); +} + +unsafe extern fn block_context_copy(_dst: &mut B, _src: &B) { + // The runtime memmoves the src block into the dst block, nothing to do +} + +#[repr(C)] +struct BlockDescriptor { + _reserved: c_ulong, + block_size: c_ulong, + copy_helper: unsafe extern fn(&mut B, &B), + dispose_helper: unsafe extern fn(&mut B), +} + +impl BlockDescriptor { + fn new() -> BlockDescriptor { + BlockDescriptor { + _reserved: 0, + block_size: mem::size_of::() as c_ulong, + copy_helper: block_context_copy::, + dispose_helper: block_context_dispose::, + } + } +} + +#[cfg(test)] +mod tests { + use test_utils::*; + use super::{ConcreteBlock, RcBlock}; + + #[test] + fn test_call_block() { + let block = get_int_block_with(13); + unsafe { + assert!(block.call(()) == 13); + } + } + + #[test] + fn test_call_block_args() { + let block = get_add_block_with(13); + unsafe { + assert!(block.call((2,)) == 15); + } + } + + #[test] + fn test_create_block() { + let block = ConcreteBlock::new(|| 13); + let result = invoke_int_block(&block); + assert!(result == 13); + } + + #[test] + fn test_create_block_args() { + let block = ConcreteBlock::new(|a: i32| a + 5); + let result = invoke_add_block(&block, 6); + assert!(result == 11); + } + + #[test] + fn test_concrete_block_copy() { + let s = "Hello!".to_string(); + let expected_len = s.len() as i32; + let block = ConcreteBlock::new(move || s.len() as i32); + assert!(invoke_int_block(&block) == expected_len); + + let copied = block.copy(); + assert!(invoke_int_block(&copied) == expected_len); + } + + #[test] + fn test_concrete_block_stack_copy() { + fn make_block() -> RcBlock<(), i32> { + let x = 7; + let block = ConcreteBlock::new(move || x); + block.copy() + } + + let block = make_block(); + assert!(invoke_int_block(&block) == 7); + } +} diff --git a/third_party/cargo/vendor/block-0.1.6/src/test_utils.rs b/third_party/cargo/vendor/block-0.1.6/src/test_utils.rs new file mode 100644 index 0000000..940a3d2 --- /dev/null +++ b/third_party/cargo/vendor/block-0.1.6/src/test_utils.rs @@ -0,0 +1,31 @@ +extern crate objc_test_utils; + +use {Block, RcBlock}; + +pub fn get_int_block_with(i: i32) -> RcBlock<(), i32> { + unsafe { + let ptr = objc_test_utils::get_int_block_with(i); + RcBlock::new(ptr as *mut _) + } +} + +pub fn get_add_block_with(i: i32) -> RcBlock<(i32,), i32> { + unsafe { + let ptr = objc_test_utils::get_add_block_with(i); + RcBlock::new(ptr as *mut _) + } +} + +pub fn invoke_int_block(block: &Block<(), i32>) -> i32 { + let ptr = block as *const _; + unsafe { + objc_test_utils::invoke_int_block(ptr as *mut _) + } +} + +pub fn invoke_add_block(block: &Block<(i32,), i32>, a: i32) -> i32 { + let ptr = block as *const _; + unsafe { + objc_test_utils::invoke_add_block(ptr as *mut _, a) + } +} diff --git a/third_party/cargo/vendor/byteorder-1.3.2/.cargo-checksum.json b/third_party/cargo/vendor/byteorder-1.3.2/.cargo-checksum.json new file mode 100644 index 0000000..28e4e34 --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"51f0eb3b6139fc1a908d41a7b3cba7d58d684700986b3518f82e5af254c39e8e","COPYING":"01c266bced4a434da0051174d6bee16a4c82cf634e2679b6155d40d75012390f","Cargo.toml":"51bf020d4e355a8548f1e1bbcb35828f457bb96874fb4124317c6485d74d00c6","LICENSE-MIT":"0f96a83840e146e43c0ec96a22ec1f392e0680e6c1226e6f3ba87e0740af850f","README.md":"b2dd89866b56f619661b90e8b3b7d3f741b0a8d5710e229df86843ae0881284f","UNLICENSE":"7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c","benches/bench.rs":"80e43e07f34bc6d3ebe4f37cea79ba02cafce6cf30b737a1db65de55f2c38ca5","build.rs":"088c35c11be1e443c4462c7fe2863bcf885805e7b0f3dc7d83e6091ff197e779","src/io.rs":"8f22d1b0e01fa4ce9c7c5cd727dbc40ca35c22d9c82fe8d324d9d83d37cdcc4a","src/lib.rs":"7ee13d5784c7d8e79a8bd8810868584b8780d96fddcd3d727b69f8c861fd7cb1"},"package":"a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"} \ No newline at end of file diff --git a/third_party/cargo/vendor/byteorder-1.3.2/BUILD b/third_party/cargo/vendor/byteorder-1.3.2/BUILD new file mode 100644 index 0000000..f1b9117 --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "Unlicense OR MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "bench" with type "bench" omitted +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "byteorder", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.3.2", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/byteorder-1.3.2/CHANGELOG.md b/third_party/cargo/vendor/byteorder-1.3.2/CHANGELOG.md new file mode 100644 index 0000000..020beb4 --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/CHANGELOG.md @@ -0,0 +1,114 @@ +1.3.0 +===== +This new minor release now enables `i128` support automatically on Rust +compilers that support 128-bit integers. The `i128` feature is now a no-op, but +continues to exist for backward compatibility purposes. The crate continues to +maintain compatibility with Rust 1.12.0. + +This release also deprecates the `ByteOrder` trait methods +`read_f32_into_unchecked` and `read_f64_into_unchecked` in favor of +`read_f32_into` and `read_f64_into`. This was an oversight from the 1.2 release +where the corresponding methods on `ReadBytesExt` were deprecated. + +`quickcheck` and `rand` were bumped to `0.8` and `0.6`, respectively. + +A few small documentation related bugs have been fixed. + + +1.2.7 +===== +This patch release excludes some CI files from the crate release and updates +the license field to use `OR` instead of `/`. + + +1.2.6 +===== +This patch release fixes some test compilation errors introduced by an +over-eager release of 1.2.5. + + +1.2.5 +===== +This patch release fixes some typos in the docs, adds doc tests to methods on +`WriteByteExt` and bumps the quickcheck dependency to `0.7`. + + +1.2.4 +===== +This patch release adds support for 48-bit integers by adding the following +methods to the `ByteOrder` trait: `read_u48`, `read_i48`, `write_u48` and +`write_i48`. Corresponding methods have been added to the `ReadBytesExt` and +`WriteBytesExt` traits as well. + + +1.2.3 +===== +This patch release removes the use of `feature(i128_type)` from byteorder, +since it has been stabilized. We leave byteorder's `i128` feature in place +in order to continue supporting compilation on older versions of Rust. + + +1.2.2 +===== +This patch release only consists of internal improvements and refactorings. +Notably, this removes all uses of `transmute` and instead uses pointer casts. + + +1.2.1 +===== +This patch release removes more unnecessary uses of `unsafe` that +were overlooked in the prior `1.2.0` release. In particular, the +`ReadBytesExt::read_{f32,f64}_into_checked` methods have been deprecated and +replaced by more appropriately named `read_{f32,f64}_into` methods. + + +1.2.0 +===== +The most prominent change in this release of `byteorder` is the removal of +unnecessary signaling NaN masking, and in turn, the `unsafe` annotations +associated with methods that didn't do masking. See +[#103](https://github.com/BurntSushi/byteorder/issues/103) +for more details. + +* [BUG #102](https://github.com/BurntSushi/byteorder/issues/102): + Fix big endian tests. +* [BUG #103](https://github.com/BurntSushi/byteorder/issues/103): + Remove sNaN masking. + + +1.1.0 +===== +This release of `byteorder` features a number of fixes and improvements, mostly +as a result of the +[Litz Blitz evaluation](https://public.etherpad-mozilla.org/p/rust-crate-eval-byteorder). + +Feature enhancements: + +* [FEATURE #63](https://github.com/BurntSushi/byteorder/issues/63): + Add methods for reading/writing slices of numbers for a specific + endianness. +* [FEATURE #65](https://github.com/BurntSushi/byteorder/issues/65): + Add support for `u128`/`i128` types. (Behind the nightly only `i128` + feature.) +* [FEATURE #72](https://github.com/BurntSushi/byteorder/issues/72): + Add "panics" and "errors" sections for each relevant public API item. +* [FEATURE #74](https://github.com/BurntSushi/byteorder/issues/74): + Add CI badges to Cargo.toml. +* [FEATURE #75](https://github.com/BurntSushi/byteorder/issues/75): + Add more examples to public API items. +* Add 24-bit read/write methods. +* Add `BE` and `LE` type aliases for `BigEndian` and `LittleEndian`, + respectively. + +Bug fixes: + +* [BUG #68](https://github.com/BurntSushi/byteorder/issues/68): + Panic in {BigEndian,LittleEndian}::default. +* [BUG #69](https://github.com/BurntSushi/byteorder/issues/69): + Seal the `ByteOrder` trait to prevent out-of-crate implementations. +* [BUG #71](https://github.com/BurntSushi/byteorder/issues/71): + Guarantee that the results of `read_f32`/`read_f64` are always defined. +* [BUG #73](https://github.com/BurntSushi/byteorder/issues/73): + Add crates.io categories. +* [BUG #77](https://github.com/BurntSushi/byteorder/issues/77): + Add `html_root` doc attribute. diff --git a/third_party/cargo/vendor/byteorder-1.3.2/COPYING b/third_party/cargo/vendor/byteorder-1.3.2/COPYING new file mode 100644 index 0000000..bb9c20a --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/third_party/cargo/vendor/byteorder-1.3.2/Cargo.toml b/third_party/cargo/vendor/byteorder-1.3.2/Cargo.toml new file mode 100644 index 0000000..fb2acad --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/Cargo.toml @@ -0,0 +1,48 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "byteorder" +version = "1.3.2" +authors = ["Andrew Gallant "] +build = "build.rs" +exclude = ["/ci/*"] +description = "Library for reading/writing numbers in big-endian and little-endian." +homepage = "https://github.com/BurntSushi/byteorder" +documentation = "https://docs.rs/byteorder" +readme = "README.md" +keywords = ["byte", "endian", "big-endian", "little-endian", "binary"] +categories = ["encoding", "parsing"] +license = "Unlicense OR MIT" +repository = "https://github.com/BurntSushi/byteorder" +[profile.bench] +opt-level = 3 + +[lib] +name = "byteorder" +bench = false +[dev-dependencies.doc-comment] +version = "0.3" + +[dev-dependencies.quickcheck] +version = "0.8" +default-features = false + +[dev-dependencies.rand] +version = "0.6" + +[features] +default = ["std"] +i128 = [] +std = [] +[badges.travis-ci] +repository = "BurntSushi/byteorder" diff --git a/third_party/cargo/vendor/byteorder-1.3.2/LICENSE-MIT b/third_party/cargo/vendor/byteorder-1.3.2/LICENSE-MIT new file mode 100644 index 0000000..3b0a5dc --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/third_party/cargo/vendor/byteorder-1.3.2/README.md b/third_party/cargo/vendor/byteorder-1.3.2/README.md new file mode 100644 index 0000000..8940b29 --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/README.md @@ -0,0 +1,63 @@ +This crate provides convenience methods for encoding and decoding +numbers in either big-endian or little-endian order. + +[![Build status](https://api.travis-ci.org/BurntSushi/byteorder.svg)](https://travis-ci.org/BurntSushi/byteorder) +[![](http://meritbadge.herokuapp.com/byteorder)](https://crates.io/crates/byteorder) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + + +### Documentation + +https://docs.rs/byteorder + + +### Installation + +This crate works with Cargo and is on +[crates.io](https://crates.io/crates/byteorder). Add it to your `Cargo.toml` +like so: + +```toml +[dependencies] +byteorder = "1" +``` + +If you want to augment existing `Read` and `Write` traits, then import the +extension methods like so: + +```rust +extern crate byteorder; + +use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian, LittleEndian}; +``` + +For example: + +```rust +use std::io::Cursor; +use byteorder::{BigEndian, ReadBytesExt}; + +let mut rdr = Cursor::new(vec![2, 5, 3, 0]); +// Note that we use type parameters to indicate which kind of byte order +// we want! +assert_eq!(517, rdr.read_u16::().unwrap()); +assert_eq!(768, rdr.read_u16::().unwrap()); +``` + +### `no_std` crates + +This crate has a feature, `std`, that is enabled by default. To use this crate +in a `no_std` context, add the following to your `Cargo.toml`: + +```toml +[dependencies] +byteorder = { version = "1", default-features = false } +``` + + +### Alternatives + +Note that as of Rust 1.32, the standard numeric types provide built-in methods +like `to_le_bytes` and `from_le_bytes`, which support some of the same use +cases. diff --git a/third_party/cargo/vendor/byteorder-1.3.2/UNLICENSE b/third_party/cargo/vendor/byteorder-1.3.2/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/third_party/cargo/vendor/byteorder-1.3.2/benches/bench.rs b/third_party/cargo/vendor/byteorder-1.3.2/benches/bench.rs new file mode 100644 index 0000000..d53d25e --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/benches/bench.rs @@ -0,0 +1,328 @@ +#![feature(test)] + +extern crate byteorder; +extern crate rand; +extern crate test; + +macro_rules! bench_num { + ($name:ident, $read:ident, $bytes:expr, $data:expr) => ( + mod $name { + use byteorder::{ByteOrder, BigEndian, NativeEndian, LittleEndian}; + use super::test::Bencher; + use super::test::black_box as bb; + + const NITER: usize = 100_000; + + #[bench] + fn read_big_endian(b: &mut Bencher) { + let buf = $data; + b.iter(|| { + for _ in 0..NITER { + bb(BigEndian::$read(&buf, $bytes)); + } + }); + } + + #[bench] + fn read_little_endian(b: &mut Bencher) { + let buf = $data; + b.iter(|| { + for _ in 0..NITER { + bb(LittleEndian::$read(&buf, $bytes)); + } + }); + } + + #[bench] + fn read_native_endian(b: &mut Bencher) { + let buf = $data; + b.iter(|| { + for _ in 0..NITER { + bb(NativeEndian::$read(&buf, $bytes)); + } + }); + } + } + ); + ($ty:ident, $max:ident, + $read:ident, $write:ident, $size:expr, $data:expr) => ( + mod $ty { + use std::$ty; + use byteorder::{ByteOrder, BigEndian, NativeEndian, LittleEndian}; + use super::test::Bencher; + use super::test::black_box as bb; + + const NITER: usize = 100_000; + + #[bench] + fn read_big_endian(b: &mut Bencher) { + let buf = $data; + b.iter(|| { + for _ in 0..NITER { + bb(BigEndian::$read(&buf)); + } + }); + } + + #[bench] + fn read_little_endian(b: &mut Bencher) { + let buf = $data; + b.iter(|| { + for _ in 0..NITER { + bb(LittleEndian::$read(&buf)); + } + }); + } + + #[bench] + fn read_native_endian(b: &mut Bencher) { + let buf = $data; + b.iter(|| { + for _ in 0..NITER { + bb(NativeEndian::$read(&buf)); + } + }); + } + + #[bench] + fn write_big_endian(b: &mut Bencher) { + let mut buf = $data; + let n = $ty::$max; + b.iter(|| { + for _ in 0..NITER { + bb(BigEndian::$write(&mut buf, n)); + } + }); + } + + #[bench] + fn write_little_endian(b: &mut Bencher) { + let mut buf = $data; + let n = $ty::$max; + b.iter(|| { + for _ in 0..NITER { + bb(LittleEndian::$write(&mut buf, n)); + } + }); + } + + #[bench] + fn write_native_endian(b: &mut Bencher) { + let mut buf = $data; + let n = $ty::$max; + b.iter(|| { + for _ in 0..NITER { + bb(NativeEndian::$write(&mut buf, n)); + } + }); + } + } + ); +} + +bench_num!(u16, MAX, read_u16, write_u16, 2, [1, 2]); +bench_num!(i16, MAX, read_i16, write_i16, 2, [1, 2]); +bench_num!(u32, MAX, read_u32, write_u32, 4, [1, 2, 3, 4]); +bench_num!(i32, MAX, read_i32, write_i32, 4, [1, 2, 3, 4]); +bench_num!(u64, MAX, read_u64, write_u64, 8, [1, 2, 3, 4, 5, 6, 7, 8]); +bench_num!(i64, MAX, read_i64, write_i64, 8, [1, 2, 3, 4, 5, 6, 7, 8]); +bench_num!(f32, MAX, read_f32, write_f32, 4, [1, 2, 3, 4]); +bench_num!(f64, MAX, read_f64, write_f64, 8, + [1, 2, 3, 4, 5, 6, 7, 8]); + +bench_num!(uint_1, read_uint, 1, [1]); +bench_num!(uint_2, read_uint, 2, [1, 2]); +bench_num!(uint_3, read_uint, 3, [1, 2, 3]); +bench_num!(uint_4, read_uint, 4, [1, 2, 3, 4]); +bench_num!(uint_5, read_uint, 5, [1, 2, 3, 4, 5]); +bench_num!(uint_6, read_uint, 6, [1, 2, 3, 4, 5, 6]); +bench_num!(uint_7, read_uint, 7, [1, 2, 3, 4, 5, 6, 7]); +bench_num!(uint_8, read_uint, 8, [1, 2, 3, 4, 5, 6, 7, 8]); + +bench_num!(int_1, read_int, 1, [1]); +bench_num!(int_2, read_int, 2, [1, 2]); +bench_num!(int_3, read_int, 3, [1, 2, 3]); +bench_num!(int_4, read_int, 4, [1, 2, 3, 4]); +bench_num!(int_5, read_int, 5, [1, 2, 3, 4, 5]); +bench_num!(int_6, read_int, 6, [1, 2, 3, 4, 5, 6]); +bench_num!(int_7, read_int, 7, [1, 2, 3, 4, 5, 6, 7]); +bench_num!(int_8, read_int, 8, [1, 2, 3, 4, 5, 6, 7, 8]); + +#[cfg(byteorder_i128)] +bench_num!(u128, MAX, read_u128, write_u128, + 16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); +#[cfg(byteorder_i128)] +bench_num!(i128, MAX, read_i128, write_i128, + 16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + +#[cfg(byteorder_i128)] +bench_num!(uint128_1, read_uint128, + 1, [1]); +#[cfg(byteorder_i128)] +bench_num!(uint128_2, read_uint128, + 2, [1, 2]); +#[cfg(byteorder_i128)] +bench_num!(uint128_3, read_uint128, + 3, [1, 2, 3]); +#[cfg(byteorder_i128)] +bench_num!(uint128_4, read_uint128, + 4, [1, 2, 3, 4]); +#[cfg(byteorder_i128)] +bench_num!(uint128_5, read_uint128, + 5, [1, 2, 3, 4, 5]); +#[cfg(byteorder_i128)] +bench_num!(uint128_6, read_uint128, + 6, [1, 2, 3, 4, 5, 6]); +#[cfg(byteorder_i128)] +bench_num!(uint128_7, read_uint128, + 7, [1, 2, 3, 4, 5, 6, 7]); +#[cfg(byteorder_i128)] +bench_num!(uint128_8, read_uint128, + 8, [1, 2, 3, 4, 5, 6, 7, 8]); +#[cfg(byteorder_i128)] +bench_num!(uint128_9, read_uint128, + 9, [1, 2, 3, 4, 5, 6, 7, 8, 9]); +#[cfg(byteorder_i128)] +bench_num!(uint128_10, read_uint128, + 10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); +#[cfg(byteorder_i128)] +bench_num!(uint128_11, read_uint128, + 11, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); +#[cfg(byteorder_i128)] +bench_num!(uint128_12, read_uint128, + 12, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); +#[cfg(byteorder_i128)] +bench_num!(uint128_13, read_uint128, + 13, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]); +#[cfg(byteorder_i128)] +bench_num!(uint128_14, read_uint128, + 14, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]); +#[cfg(byteorder_i128)] +bench_num!(uint128_15, read_uint128, + 15, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); +#[cfg(byteorder_i128)] +bench_num!(uint128_16, read_uint128, + 16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + +#[cfg(byteorder_i128)] +bench_num!(int128_1, read_int128, + 1, [1]); +#[cfg(byteorder_i128)] +bench_num!(int128_2, read_int128, + 2, [1, 2]); +#[cfg(byteorder_i128)] +bench_num!(int128_3, read_int128, + 3, [1, 2, 3]); +#[cfg(byteorder_i128)] +bench_num!(int128_4, read_int128, + 4, [1, 2, 3, 4]); +#[cfg(byteorder_i128)] +bench_num!(int128_5, read_int128, + 5, [1, 2, 3, 4, 5]); +#[cfg(byteorder_i128)] +bench_num!(int128_6, read_int128, + 6, [1, 2, 3, 4, 5, 6]); +#[cfg(byteorder_i128)] +bench_num!(int128_7, read_int128, + 7, [1, 2, 3, 4, 5, 6, 7]); +#[cfg(byteorder_i128)] +bench_num!(int128_8, read_int128, + 8, [1, 2, 3, 4, 5, 6, 7, 8]); +#[cfg(byteorder_i128)] +bench_num!(int128_9, read_int128, + 9, [1, 2, 3, 4, 5, 6, 7, 8, 9]); +#[cfg(byteorder_i128)] +bench_num!(int128_10, read_int128, + 10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); +#[cfg(byteorder_i128)] +bench_num!(int128_11, read_int128, + 11, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); +#[cfg(byteorder_i128)] +bench_num!(int128_12, read_int128, + 12, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); +#[cfg(byteorder_i128)] +bench_num!(int128_13, read_int128, + 13, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]); +#[cfg(byteorder_i128)] +bench_num!(int128_14, read_int128, + 14, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]); +#[cfg(byteorder_i128)] +bench_num!(int128_15, read_int128, + 15, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); +#[cfg(byteorder_i128)] +bench_num!(int128_16, read_int128, + 16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + + +macro_rules! bench_slice { + ($name:ident, $numty:ty, $read:ident, $write:ident) => { + mod $name { + use std::mem::size_of; + + use byteorder::{ByteOrder, BigEndian, LittleEndian}; + use rand::{self, Rng}; + use rand::distributions; + use test::Bencher; + + #[bench] + fn read_big_endian(b: &mut Bencher) { + let mut numbers: Vec<$numty> = rand::thread_rng() + .sample_iter(&distributions::Standard) + .take(100000) + .collect(); + let mut bytes = vec![0; numbers.len() * size_of::<$numty>()]; + BigEndian::$write(&numbers, &mut bytes); + + b.bytes = bytes.len() as u64; + b.iter(|| { + BigEndian::$read(&bytes, &mut numbers); + }); + } + + #[bench] + fn read_little_endian(b: &mut Bencher) { + let mut numbers: Vec<$numty> = rand::thread_rng() + .sample_iter(&distributions::Standard) + .take(100000) + .collect(); + let mut bytes = vec![0; numbers.len() * size_of::<$numty>()]; + LittleEndian::$write(&numbers, &mut bytes); + + b.bytes = bytes.len() as u64; + b.iter(|| { + LittleEndian::$read(&bytes, &mut numbers); + }); + } + + #[bench] + fn write_big_endian(b: &mut Bencher) { + let numbers: Vec<$numty> = rand::thread_rng() + .sample_iter(&distributions::Standard) + .take(100000) + .collect(); + let mut bytes = vec![0; numbers.len() * size_of::<$numty>()]; + + b.bytes = bytes.len() as u64; + b.iter(|| { + BigEndian::$write(&numbers, &mut bytes); + }); + } + + #[bench] + fn write_little_endian(b: &mut Bencher) { + let numbers: Vec<$numty> = rand::thread_rng() + .sample_iter(&distributions::Standard) + .take(100000) + .collect(); + let mut bytes = vec![0; numbers.len() * size_of::<$numty>()]; + + b.bytes = bytes.len() as u64; + b.iter(|| { + LittleEndian::$write(&numbers, &mut bytes); + }); + } + } + } +} + +bench_slice!(slice_u64, u64, read_u64_into, write_u64_into); diff --git a/third_party/cargo/vendor/byteorder-1.3.2/build.rs b/third_party/cargo/vendor/byteorder-1.3.2/build.rs new file mode 100644 index 0000000..002135b --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/build.rs @@ -0,0 +1,87 @@ +use std::env; +use std::ffi::OsString; +use std::io::{self, Write}; +use std::process::Command; + +fn main() { + let version = match Version::read() { + Ok(version) => version, + Err(err) => { + writeln!( + &mut io::stderr(), + "failed to parse `rustc --version`: {}", + err + ).unwrap(); + return; + } + }; + enable_i128(version); +} + +fn enable_i128(version: Version) { + if version < (Version { major: 1, minor: 26, patch: 0 }) { + return; + } + + println!("cargo:rustc-cfg=byteorder_i128"); +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)] +struct Version { + major: u32, + minor: u32, + patch: u32, +} + +impl Version { + fn read() -> Result { + let rustc = env::var_os("RUSTC").unwrap_or(OsString::from("rustc")); + let output = Command::new(&rustc) + .arg("--version") + .output() + .unwrap() + .stdout; + Version::parse(&String::from_utf8(output).unwrap()) + } + + fn parse(mut s: &str) -> Result { + if !s.starts_with("rustc ") { + return Err(format!("unrecognized version string: {}", s)); + } + s = &s["rustc ".len()..]; + + let parts: Vec<&str> = s.split(".").collect(); + if parts.len() < 3 { + return Err(format!("not enough version parts: {:?}", parts)); + } + + let mut num = String::new(); + for c in parts[0].chars() { + if !c.is_digit(10) { + break; + } + num.push(c); + } + let major = try!(num.parse::().map_err(|e| e.to_string())); + + num.clear(); + for c in parts[1].chars() { + if !c.is_digit(10) { + break; + } + num.push(c); + } + let minor = try!(num.parse::().map_err(|e| e.to_string())); + + num.clear(); + for c in parts[2].chars() { + if !c.is_digit(10) { + break; + } + num.push(c); + } + let patch = try!(num.parse::().map_err(|e| e.to_string())); + + Ok(Version { major: major, minor: minor, patch: patch }) + } +} diff --git a/third_party/cargo/vendor/byteorder-1.3.2/src/io.rs b/third_party/cargo/vendor/byteorder-1.3.2/src/io.rs new file mode 100644 index 0000000..ed6a848 --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/src/io.rs @@ -0,0 +1,1605 @@ +use std::io::{self, Result}; +use std::slice; + +use ByteOrder; + +/// Extends [`Read`] with methods for reading numbers. (For `std::io`.) +/// +/// Most of the methods defined here have an unconstrained type parameter that +/// must be explicitly instantiated. Typically, it is instantiated with either +/// the [`BigEndian`] or [`LittleEndian`] types defined in this crate. +/// +/// # Examples +/// +/// Read unsigned 16 bit big-endian integers from a [`Read`]: +/// +/// ```rust +/// use std::io::Cursor; +/// use byteorder::{BigEndian, ReadBytesExt}; +/// +/// let mut rdr = Cursor::new(vec![2, 5, 3, 0]); +/// assert_eq!(517, rdr.read_u16::().unwrap()); +/// assert_eq!(768, rdr.read_u16::().unwrap()); +/// ``` +/// +/// [`BigEndian`]: enum.BigEndian.html +/// [`LittleEndian`]: enum.LittleEndian.html +/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html +pub trait ReadBytesExt: io::Read { + /// Reads an unsigned 8 bit integer from the underlying reader. + /// + /// Note that since this reads a single byte, no byte order conversions + /// are used. It is included for completeness. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read unsigned 8 bit integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::ReadBytesExt; + /// + /// let mut rdr = Cursor::new(vec![2, 5]); + /// assert_eq!(2, rdr.read_u8().unwrap()); + /// assert_eq!(5, rdr.read_u8().unwrap()); + /// ``` + #[inline] + fn read_u8(&mut self) -> Result { + let mut buf = [0; 1]; + try!(self.read_exact(&mut buf)); + Ok(buf[0]) + } + + /// Reads a signed 8 bit integer from the underlying reader. + /// + /// Note that since this reads a single byte, no byte order conversions + /// are used. It is included for completeness. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read signed 8 bit integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::ReadBytesExt; + /// + /// let mut rdr = Cursor::new(vec![0x02, 0xfb]); + /// assert_eq!(2, rdr.read_i8().unwrap()); + /// assert_eq!(-5, rdr.read_i8().unwrap()); + /// ``` + #[inline] + fn read_i8(&mut self) -> Result { + let mut buf = [0; 1]; + try!(self.read_exact(&mut buf)); + Ok(buf[0] as i8) + } + + /// Reads an unsigned 16 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read unsigned 16 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![2, 5, 3, 0]); + /// assert_eq!(517, rdr.read_u16::().unwrap()); + /// assert_eq!(768, rdr.read_u16::().unwrap()); + /// ``` + #[inline] + fn read_u16(&mut self) -> Result { + let mut buf = [0; 2]; + try!(self.read_exact(&mut buf)); + Ok(T::read_u16(&buf)) + } + + /// Reads a signed 16 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read signed 16 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0x00, 0xc1, 0xff, 0x7c]); + /// assert_eq!(193, rdr.read_i16::().unwrap()); + /// assert_eq!(-132, rdr.read_i16::().unwrap()); + /// ``` + #[inline] + fn read_i16(&mut self) -> Result { + let mut buf = [0; 2]; + try!(self.read_exact(&mut buf)); + Ok(T::read_i16(&buf)) + } + + /// Reads an unsigned 24 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read unsigned 24 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0x00, 0x01, 0x0b]); + /// assert_eq!(267, rdr.read_u24::().unwrap()); + /// ``` + #[inline] + fn read_u24(&mut self) -> Result { + let mut buf = [0; 3]; + try!(self.read_exact(&mut buf)); + Ok(T::read_u24(&buf)) + } + + /// Reads a signed 24 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read signed 24 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0xff, 0x7a, 0x33]); + /// assert_eq!(-34253, rdr.read_i24::().unwrap()); + /// ``` + #[inline] + fn read_i24(&mut self) -> Result { + let mut buf = [0; 3]; + try!(self.read_exact(&mut buf)); + Ok(T::read_i24(&buf)) + } + + /// Reads an unsigned 32 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read unsigned 32 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0x00, 0x00, 0x01, 0x0b]); + /// assert_eq!(267, rdr.read_u32::().unwrap()); + /// ``` + #[inline] + fn read_u32(&mut self) -> Result { + let mut buf = [0; 4]; + try!(self.read_exact(&mut buf)); + Ok(T::read_u32(&buf)) + } + + /// Reads a signed 32 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read signed 32 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0xff, 0xff, 0x7a, 0x33]); + /// assert_eq!(-34253, rdr.read_i32::().unwrap()); + /// ``` + #[inline] + fn read_i32(&mut self) -> Result { + let mut buf = [0; 4]; + try!(self.read_exact(&mut buf)); + Ok(T::read_i32(&buf)) + } + + /// Reads an unsigned 48 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read unsigned 48 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0xb6, 0x71, 0x6b, 0xdc, 0x2b, 0x31]); + /// assert_eq!(200598257150769, rdr.read_u48::().unwrap()); + /// ``` + #[inline] + fn read_u48(&mut self) -> Result { + let mut buf = [0; 6]; + try!(self.read_exact(&mut buf)); + Ok(T::read_u48(&buf)) + } + + /// Reads a signed 48 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read signed 48 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0x9d, 0x71, 0xab, 0xe7, 0x97, 0x8f]); + /// assert_eq!(-108363435763825, rdr.read_i48::().unwrap()); + /// ``` + #[inline] + fn read_i48(&mut self) -> Result { + let mut buf = [0; 6]; + try!(self.read_exact(&mut buf)); + Ok(T::read_i48(&buf)) + } + + /// Reads an unsigned 64 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read an unsigned 64 bit big-endian integer from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0x00, 0x03, 0x43, 0x95, 0x4d, 0x60, 0x86, 0x83]); + /// assert_eq!(918733457491587, rdr.read_u64::().unwrap()); + /// ``` + #[inline] + fn read_u64(&mut self) -> Result { + let mut buf = [0; 8]; + try!(self.read_exact(&mut buf)); + Ok(T::read_u64(&buf)) + } + + /// Reads a signed 64 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a signed 64 bit big-endian integer from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0x80, 0, 0, 0, 0, 0, 0, 0]); + /// assert_eq!(i64::min_value(), rdr.read_i64::().unwrap()); + /// ``` + #[inline] + fn read_i64(&mut self) -> Result { + let mut buf = [0; 8]; + try!(self.read_exact(&mut buf)); + Ok(T::read_i64(&buf)) + } + + /// Reads an unsigned 128 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read an unsigned 128 bit big-endian integer from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0x00, 0x03, 0x43, 0x95, 0x4d, 0x60, 0x86, 0x83, + /// 0x00, 0x03, 0x43, 0x95, 0x4d, 0x60, 0x86, 0x83 + /// ]); + /// assert_eq!(16947640962301618749969007319746179, rdr.read_u128::().unwrap()); + /// ``` + #[cfg(byteorder_i128)] + #[inline] + fn read_u128(&mut self) -> Result { + let mut buf = [0; 16]; + try!(self.read_exact(&mut buf)); + Ok(T::read_u128(&buf)) + } + + /// Reads a signed 128 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a signed 128 bit big-endian integer from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + /// assert_eq!(i128::min_value(), rdr.read_i128::().unwrap()); + /// ``` + #[cfg(byteorder_i128)] + #[inline] + fn read_i128(&mut self) -> Result { + let mut buf = [0; 16]; + try!(self.read_exact(&mut buf)); + Ok(T::read_i128(&buf)) + } + + /// Reads an unsigned n-bytes integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read an unsigned n-byte big-endian integer from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0x80, 0x74, 0xfa]); + /// assert_eq!(8418554, rdr.read_uint::(3).unwrap()); + #[inline] + fn read_uint(&mut self, nbytes: usize) -> Result { + let mut buf = [0; 8]; + try!(self.read_exact(&mut buf[..nbytes])); + Ok(T::read_uint(&buf[..nbytes], nbytes)) + } + + /// Reads a signed n-bytes integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read an unsigned n-byte big-endian integer from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0xc1, 0xff, 0x7c]); + /// assert_eq!(-4063364, rdr.read_int::(3).unwrap()); + #[inline] + fn read_int(&mut self, nbytes: usize) -> Result { + let mut buf = [0; 8]; + try!(self.read_exact(&mut buf[..nbytes])); + Ok(T::read_int(&buf[..nbytes], nbytes)) + } + + /// Reads an unsigned n-bytes integer from the underlying reader. + #[cfg(byteorder_i128)] + #[inline] + fn read_uint128(&mut self, nbytes: usize) -> Result { + let mut buf = [0; 16]; + try!(self.read_exact(&mut buf[..nbytes])); + Ok(T::read_uint128(&buf[..nbytes], nbytes)) + } + + /// Reads a signed n-bytes integer from the underlying reader. + #[cfg(byteorder_i128)] + #[inline] + fn read_int128(&mut self, nbytes: usize) -> Result { + let mut buf = [0; 16]; + try!(self.read_exact(&mut buf[..nbytes])); + Ok(T::read_int128(&buf[..nbytes], nbytes)) + } + + /// Reads a IEEE754 single-precision (4 bytes) floating point number from + /// the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a big-endian single-precision floating point number from a `Read`: + /// + /// ```rust + /// use std::f32; + /// use std::io::Cursor; + /// + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0x40, 0x49, 0x0f, 0xdb, + /// ]); + /// assert_eq!(f32::consts::PI, rdr.read_f32::().unwrap()); + /// ``` + #[inline] + fn read_f32(&mut self) -> Result { + let mut buf = [0; 4]; + try!(self.read_exact(&mut buf)); + Ok(T::read_f32(&buf)) + } + + /// Reads a IEEE754 double-precision (8 bytes) floating point number from + /// the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a big-endian double-precision floating point number from a `Read`: + /// + /// ```rust + /// use std::f64; + /// use std::io::Cursor; + /// + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18, + /// ]); + /// assert_eq!(f64::consts::PI, rdr.read_f64::().unwrap()); + /// ``` + #[inline] + fn read_f64(&mut self) -> Result { + let mut buf = [0; 8]; + try!(self.read_exact(&mut buf)); + Ok(T::read_f64(&buf)) + } + + /// Reads a sequence of unsigned 16 bit integers from the underlying + /// reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of unsigned 16 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![2, 5, 3, 0]); + /// let mut dst = [0; 2]; + /// rdr.read_u16_into::(&mut dst).unwrap(); + /// assert_eq!([517, 768], dst); + /// ``` + #[inline] + fn read_u16_into(&mut self, dst: &mut [u16]) -> Result<()> { + { + let buf = unsafe { slice_to_u8_mut(dst) }; + try!(self.read_exact(buf)); + } + T::from_slice_u16(dst); + Ok(()) + } + + /// Reads a sequence of unsigned 32 bit integers from the underlying + /// reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of unsigned 32 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0, 0, 2, 5, 0, 0, 3, 0]); + /// let mut dst = [0; 2]; + /// rdr.read_u32_into::(&mut dst).unwrap(); + /// assert_eq!([517, 768], dst); + /// ``` + #[inline] + fn read_u32_into(&mut self, dst: &mut [u32]) -> Result<()> { + { + let buf = unsafe { slice_to_u8_mut(dst) }; + try!(self.read_exact(buf)); + } + T::from_slice_u32(dst); + Ok(()) + } + + /// Reads a sequence of unsigned 64 bit integers from the underlying + /// reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of unsigned 64 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0, 0, 0, 0, 0, 0, 2, 5, + /// 0, 0, 0, 0, 0, 0, 3, 0, + /// ]); + /// let mut dst = [0; 2]; + /// rdr.read_u64_into::(&mut dst).unwrap(); + /// assert_eq!([517, 768], dst); + /// ``` + #[inline] + fn read_u64_into(&mut self, dst: &mut [u64]) -> Result<()> { + { + let buf = unsafe { slice_to_u8_mut(dst) }; + try!(self.read_exact(buf)); + } + T::from_slice_u64(dst); + Ok(()) + } + + /// Reads a sequence of unsigned 128 bit integers from the underlying + /// reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of unsigned 128 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, + /// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + /// ]); + /// let mut dst = [0; 2]; + /// rdr.read_u128_into::(&mut dst).unwrap(); + /// assert_eq!([517, 768], dst); + /// ``` + #[cfg(byteorder_i128)] + #[inline] + fn read_u128_into( + &mut self, + dst: &mut [u128], + ) -> Result<()> { + { + let buf = unsafe { slice_to_u8_mut(dst) }; + try!(self.read_exact(buf)); + } + T::from_slice_u128(dst); + Ok(()) + } + + /// Reads a sequence of signed 8 bit integers from the underlying reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// Note that since each `i8` is a single byte, no byte order conversions + /// are used. This method is included because it provides a safe, simple + /// way for the caller to read into a `&mut [i8]` buffer. (Without this + /// method, the caller would have to either use `unsafe` code or convert + /// each byte to `i8` individually.) + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of signed 8 bit integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![2, 251, 3]); + /// let mut dst = [0; 3]; + /// rdr.read_i8_into(&mut dst).unwrap(); + /// assert_eq!([2, -5, 3], dst); + /// ``` + #[inline] + fn read_i8_into(&mut self, dst: &mut [i8]) -> Result<()> { + let buf = unsafe { slice_to_u8_mut(dst) }; + self.read_exact(buf) + } + + /// Reads a sequence of signed 16 bit integers from the underlying + /// reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of signed 16 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![2, 5, 3, 0]); + /// let mut dst = [0; 2]; + /// rdr.read_i16_into::(&mut dst).unwrap(); + /// assert_eq!([517, 768], dst); + /// ``` + #[inline] + fn read_i16_into(&mut self, dst: &mut [i16]) -> Result<()> { + { + let buf = unsafe { slice_to_u8_mut(dst) }; + try!(self.read_exact(buf)); + } + T::from_slice_i16(dst); + Ok(()) + } + + /// Reads a sequence of signed 32 bit integers from the underlying + /// reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of signed 32 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![0, 0, 2, 5, 0, 0, 3, 0]); + /// let mut dst = [0; 2]; + /// rdr.read_i32_into::(&mut dst).unwrap(); + /// assert_eq!([517, 768], dst); + /// ``` + #[inline] + fn read_i32_into(&mut self, dst: &mut [i32]) -> Result<()> { + { + let buf = unsafe { slice_to_u8_mut(dst) }; + try!(self.read_exact(buf)); + } + T::from_slice_i32(dst); + Ok(()) + } + + /// Reads a sequence of signed 64 bit integers from the underlying + /// reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of signed 64 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0, 0, 0, 0, 0, 0, 2, 5, + /// 0, 0, 0, 0, 0, 0, 3, 0, + /// ]); + /// let mut dst = [0; 2]; + /// rdr.read_i64_into::(&mut dst).unwrap(); + /// assert_eq!([517, 768], dst); + /// ``` + #[inline] + fn read_i64_into(&mut self, dst: &mut [i64]) -> Result<()> { + { + let buf = unsafe { slice_to_u8_mut(dst) }; + try!(self.read_exact(buf)); + } + T::from_slice_i64(dst); + Ok(()) + } + + /// Reads a sequence of signed 128 bit integers from the underlying + /// reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of signed 128 bit big-endian integers from a `Read`: + /// + /// ```rust + /// use std::io::Cursor; + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, + /// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + /// ]); + /// let mut dst = [0; 2]; + /// rdr.read_i128_into::(&mut dst).unwrap(); + /// assert_eq!([517, 768], dst); + /// ``` + #[cfg(byteorder_i128)] + #[inline] + fn read_i128_into( + &mut self, + dst: &mut [i128], + ) -> Result<()> { + { + let buf = unsafe { slice_to_u8_mut(dst) }; + try!(self.read_exact(buf)); + } + T::from_slice_i128(dst); + Ok(()) + } + + /// Reads a sequence of IEEE754 single-precision (4 bytes) floating + /// point numbers from the underlying reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of big-endian single-precision floating point number + /// from a `Read`: + /// + /// ```rust + /// use std::f32; + /// use std::io::Cursor; + /// + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0x40, 0x49, 0x0f, 0xdb, + /// 0x3f, 0x80, 0x00, 0x00, + /// ]); + /// let mut dst = [0.0; 2]; + /// rdr.read_f32_into::(&mut dst).unwrap(); + /// assert_eq!([f32::consts::PI, 1.0], dst); + /// ``` + #[inline] + fn read_f32_into( + &mut self, + dst: &mut [f32], + ) -> Result<()> { + { + let buf = unsafe { slice_to_u8_mut(dst) }; + try!(self.read_exact(buf)); + } + T::from_slice_f32(dst); + Ok(()) + } + + /// **DEPRECATED**. + /// + /// This method is deprecated. Use `read_f32_into` instead. + /// + /// Reads a sequence of IEEE754 single-precision (4 bytes) floating + /// point numbers from the underlying reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of big-endian single-precision floating point number + /// from a `Read`: + /// + /// ```rust + /// use std::f32; + /// use std::io::Cursor; + /// + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0x40, 0x49, 0x0f, 0xdb, + /// 0x3f, 0x80, 0x00, 0x00, + /// ]); + /// let mut dst = [0.0; 2]; + /// rdr.read_f32_into_unchecked::(&mut dst).unwrap(); + /// assert_eq!([f32::consts::PI, 1.0], dst); + /// ``` + #[inline] + #[deprecated(since="1.2.0", note="please use `read_f32_into` instead")] + fn read_f32_into_unchecked( + &mut self, + dst: &mut [f32], + ) -> Result<()> { + self.read_f32_into::(dst) + } + + /// Reads a sequence of IEEE754 double-precision (8 bytes) floating + /// point numbers from the underlying reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of big-endian single-precision floating point number + /// from a `Read`: + /// + /// ```rust + /// use std::f64; + /// use std::io::Cursor; + /// + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18, + /// 0x3f, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /// ]); + /// let mut dst = [0.0; 2]; + /// rdr.read_f64_into::(&mut dst).unwrap(); + /// assert_eq!([f64::consts::PI, 1.0], dst); + /// ``` + #[inline] + fn read_f64_into( + &mut self, + dst: &mut [f64], + ) -> Result<()> { + { + let buf = unsafe { slice_to_u8_mut(dst) }; + try!(self.read_exact(buf)); + } + T::from_slice_f64(dst); + Ok(()) + } + + /// **DEPRECATED**. + /// + /// This method is deprecated. Use `read_f64_into` instead. + /// + /// Reads a sequence of IEEE754 double-precision (8 bytes) floating + /// point numbers from the underlying reader. + /// + /// The given buffer is either filled completely or an error is returned. + /// If an error is returned, the contents of `dst` are unspecified. + /// + /// # Safety + /// + /// This method is unsafe because there are no guarantees made about the + /// floating point values. In particular, this method does not check for + /// signaling NaNs, which may result in undefined behavior. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact + /// + /// # Examples + /// + /// Read a sequence of big-endian single-precision floating point number + /// from a `Read`: + /// + /// ```rust + /// use std::f64; + /// use std::io::Cursor; + /// + /// use byteorder::{BigEndian, ReadBytesExt}; + /// + /// let mut rdr = Cursor::new(vec![ + /// 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18, + /// 0x3f, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /// ]); + /// let mut dst = [0.0; 2]; + /// rdr.read_f64_into_unchecked::(&mut dst).unwrap(); + /// assert_eq!([f64::consts::PI, 1.0], dst); + /// ``` + #[inline] + #[deprecated(since="1.2.0", note="please use `read_f64_into` instead")] + fn read_f64_into_unchecked( + &mut self, + dst: &mut [f64], + ) -> Result<()> { + self.read_f64_into::(dst) + } +} + +/// All types that implement `Read` get methods defined in `ReadBytesExt` +/// for free. +impl ReadBytesExt for R {} + +/// Extends [`Write`] with methods for writing numbers. (For `std::io`.) +/// +/// Most of the methods defined here have an unconstrained type parameter that +/// must be explicitly instantiated. Typically, it is instantiated with either +/// the [`BigEndian`] or [`LittleEndian`] types defined in this crate. +/// +/// # Examples +/// +/// Write unsigned 16 bit big-endian integers to a [`Write`]: +/// +/// ```rust +/// use byteorder::{BigEndian, WriteBytesExt}; +/// +/// let mut wtr = vec![]; +/// wtr.write_u16::(517).unwrap(); +/// wtr.write_u16::(768).unwrap(); +/// assert_eq!(wtr, vec![2, 5, 3, 0]); +/// ``` +/// +/// [`BigEndian`]: enum.BigEndian.html +/// [`LittleEndian`]: enum.LittleEndian.html +/// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html +pub trait WriteBytesExt: io::Write { + /// Writes an unsigned 8 bit integer to the underlying writer. + /// + /// Note that since this writes a single byte, no byte order conversions + /// are used. It is included for completeness. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write unsigned 8 bit integers to a `Write`: + /// + /// ```rust + /// use byteorder::WriteBytesExt; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_u8(2).unwrap(); + /// wtr.write_u8(5).unwrap(); + /// assert_eq!(wtr, b"\x02\x05"); + /// ``` + #[inline] + fn write_u8(&mut self, n: u8) -> Result<()> { + self.write_all(&[n]) + } + + /// Writes a signed 8 bit integer to the underlying writer. + /// + /// Note that since this writes a single byte, no byte order conversions + /// are used. It is included for completeness. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write signed 8 bit integers to a `Write`: + /// + /// ```rust + /// use byteorder::WriteBytesExt; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_i8(2).unwrap(); + /// wtr.write_i8(-5).unwrap(); + /// assert_eq!(wtr, b"\x02\xfb"); + /// ``` + #[inline] + fn write_i8(&mut self, n: i8) -> Result<()> { + self.write_all(&[n as u8]) + } + + /// Writes an unsigned 16 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write unsigned 16 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_u16::(517).unwrap(); + /// wtr.write_u16::(768).unwrap(); + /// assert_eq!(wtr, b"\x02\x05\x03\x00"); + /// ``` + #[inline] + fn write_u16(&mut self, n: u16) -> Result<()> { + let mut buf = [0; 2]; + T::write_u16(&mut buf, n); + self.write_all(&buf) + } + + /// Writes a signed 16 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write signed 16 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_i16::(193).unwrap(); + /// wtr.write_i16::(-132).unwrap(); + /// assert_eq!(wtr, b"\x00\xc1\xff\x7c"); + /// ``` + #[inline] + fn write_i16(&mut self, n: i16) -> Result<()> { + let mut buf = [0; 2]; + T::write_i16(&mut buf, n); + self.write_all(&buf) + } + + /// Writes an unsigned 24 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write unsigned 24 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_u24::(267).unwrap(); + /// wtr.write_u24::(120111).unwrap(); + /// assert_eq!(wtr, b"\x00\x01\x0b\x01\xd5\x2f"); + /// ``` + #[inline] + fn write_u24(&mut self, n: u32) -> Result<()> { + let mut buf = [0; 3]; + T::write_u24(&mut buf, n); + self.write_all(&buf) + } + + /// Writes a signed 24 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write signed 24 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_i24::(-34253).unwrap(); + /// wtr.write_i24::(120111).unwrap(); + /// assert_eq!(wtr, b"\xff\x7a\x33\x01\xd5\x2f"); + /// ``` + #[inline] + fn write_i24(&mut self, n: i32) -> Result<()> { + let mut buf = [0; 3]; + T::write_i24(&mut buf, n); + self.write_all(&buf) + } + + /// Writes an unsigned 32 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write unsigned 32 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_u32::(267).unwrap(); + /// wtr.write_u32::(1205419366).unwrap(); + /// assert_eq!(wtr, b"\x00\x00\x01\x0b\x47\xd9\x3d\x66"); + /// ``` + #[inline] + fn write_u32(&mut self, n: u32) -> Result<()> { + let mut buf = [0; 4]; + T::write_u32(&mut buf, n); + self.write_all(&buf) + } + + /// Writes a signed 32 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write signed 32 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_i32::(-34253).unwrap(); + /// wtr.write_i32::(1205419366).unwrap(); + /// assert_eq!(wtr, b"\xff\xff\x7a\x33\x47\xd9\x3d\x66"); + /// ``` + #[inline] + fn write_i32(&mut self, n: i32) -> Result<()> { + let mut buf = [0; 4]; + T::write_i32(&mut buf, n); + self.write_all(&buf) + } + + /// Writes an unsigned 48 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write unsigned 48 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_u48::(52360336390828).unwrap(); + /// wtr.write_u48::(541).unwrap(); + /// assert_eq!(wtr, b"\x2f\x9f\x17\x40\x3a\xac\x00\x00\x00\x00\x02\x1d"); + /// ``` + #[inline] + fn write_u48(&mut self, n: u64) -> Result<()> { + let mut buf = [0; 6]; + T::write_u48(&mut buf, n); + self.write_all(&buf) + } + + /// Writes a signed 48 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write signed 48 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_i48::(-108363435763825).unwrap(); + /// wtr.write_i48::(77).unwrap(); + /// assert_eq!(wtr, b"\x9d\x71\xab\xe7\x97\x8f\x00\x00\x00\x00\x00\x4d"); + /// ``` + #[inline] + fn write_i48(&mut self, n: i64) -> Result<()> { + let mut buf = [0; 6]; + T::write_i48(&mut buf, n); + self.write_all(&buf) + } + + /// Writes an unsigned 64 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write unsigned 64 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_u64::(918733457491587).unwrap(); + /// wtr.write_u64::(143).unwrap(); + /// assert_eq!(wtr, b"\x00\x03\x43\x95\x4d\x60\x86\x83\x00\x00\x00\x00\x00\x00\x00\x8f"); + /// ``` + #[inline] + fn write_u64(&mut self, n: u64) -> Result<()> { + let mut buf = [0; 8]; + T::write_u64(&mut buf, n); + self.write_all(&buf) + } + + /// Writes a signed 64 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write signed 64 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_i64::(i64::min_value()).unwrap(); + /// wtr.write_i64::(i64::max_value()).unwrap(); + /// assert_eq!(wtr, b"\x80\x00\x00\x00\x00\x00\x00\x00\x7f\xff\xff\xff\xff\xff\xff\xff"); + /// ``` + #[inline] + fn write_i64(&mut self, n: i64) -> Result<()> { + let mut buf = [0; 8]; + T::write_i64(&mut buf, n); + self.write_all(&buf) + } + + /// Writes an unsigned 128 bit integer to the underlying writer. + #[cfg(byteorder_i128)] + #[inline] + fn write_u128(&mut self, n: u128) -> Result<()> { + let mut buf = [0; 16]; + T::write_u128(&mut buf, n); + self.write_all(&buf) + } + + /// Writes a signed 128 bit integer to the underlying writer. + #[cfg(byteorder_i128)] + #[inline] + fn write_i128(&mut self, n: i128) -> Result<()> { + let mut buf = [0; 16]; + T::write_i128(&mut buf, n); + self.write_all(&buf) + } + + /// Writes an unsigned n-bytes integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Panics + /// + /// If the given integer is not representable in the given number of bytes, + /// this method panics. If `nbytes > 8`, this method panics. + /// + /// # Examples + /// + /// Write unsigned 40 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_uint::(312550384361, 5).unwrap(); + /// wtr.write_uint::(43, 5).unwrap(); + /// assert_eq!(wtr, b"\x48\xc5\x74\x62\xe9\x00\x00\x00\x00\x2b"); + /// ``` + #[inline] + fn write_uint( + &mut self, + n: u64, + nbytes: usize, + ) -> Result<()> { + let mut buf = [0; 8]; + T::write_uint(&mut buf, n, nbytes); + self.write_all(&buf[0..nbytes]) + } + + /// Writes a signed n-bytes integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Panics + /// + /// If the given integer is not representable in the given number of bytes, + /// this method panics. If `nbytes > 8`, this method panics. + /// + /// # Examples + /// + /// Write signed 56 bit big-endian integers to a `Write`: + /// + /// ```rust + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_int::(-3548172039376767, 7).unwrap(); + /// wtr.write_int::(43, 7).unwrap(); + /// assert_eq!(wtr, b"\xf3\x64\xf4\xd1\xfd\xb0\x81\x00\x00\x00\x00\x00\x00\x2b"); + /// ``` + #[inline] + fn write_int( + &mut self, + n: i64, + nbytes: usize, + ) -> Result<()> { + let mut buf = [0; 8]; + T::write_int(&mut buf, n, nbytes); + self.write_all(&buf[0..nbytes]) + } + + /// Writes an unsigned n-bytes integer to the underlying writer. + /// + /// If the given integer is not representable in the given number of bytes, + /// this method panics. If `nbytes > 16`, this method panics. + #[cfg(byteorder_i128)] + #[inline] + fn write_uint128( + &mut self, + n: u128, + nbytes: usize, + ) -> Result<()> { + let mut buf = [0; 16]; + T::write_uint128(&mut buf, n, nbytes); + self.write_all(&buf[0..nbytes]) + } + + /// Writes a signed n-bytes integer to the underlying writer. + /// + /// If the given integer is not representable in the given number of bytes, + /// this method panics. If `nbytes > 16`, this method panics. + #[cfg(byteorder_i128)] + #[inline] + fn write_int128( + &mut self, + n: i128, + nbytes: usize, + ) -> Result<()> { + let mut buf = [0; 16]; + T::write_int128(&mut buf, n, nbytes); + self.write_all(&buf[0..nbytes]) + } + + /// Writes a IEEE754 single-precision (4 bytes) floating point number to + /// the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write a big-endian single-precision floating point number to a `Write`: + /// + /// ```rust + /// use std::f32; + /// + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_f32::(f32::consts::PI).unwrap(); + /// assert_eq!(wtr, b"\x40\x49\x0f\xdb"); + /// ``` + #[inline] + fn write_f32(&mut self, n: f32) -> Result<()> { + let mut buf = [0; 4]; + T::write_f32(&mut buf, n); + self.write_all(&buf) + } + + /// Writes a IEEE754 double-precision (8 bytes) floating point number to + /// the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// + /// # Examples + /// + /// Write a big-endian double-precision floating point number to a `Write`: + /// + /// ```rust + /// use std::f64; + /// + /// use byteorder::{BigEndian, WriteBytesExt}; + /// + /// let mut wtr = Vec::new(); + /// wtr.write_f64::(f64::consts::PI).unwrap(); + /// assert_eq!(wtr, b"\x40\x09\x21\xfb\x54\x44\x2d\x18"); + /// ``` + #[inline] + fn write_f64(&mut self, n: f64) -> Result<()> { + let mut buf = [0; 8]; + T::write_f64(&mut buf, n); + self.write_all(&buf) + } +} + +/// All types that implement `Write` get methods defined in `WriteBytesExt` +/// for free. +impl WriteBytesExt for W {} + +/// Convert a slice of T (where T is plain old data) to its mutable binary +/// representation. +/// +/// This function is wildly unsafe because it permits arbitrary modification of +/// the binary representation of any `Copy` type. Use with care. +unsafe fn slice_to_u8_mut(slice: &mut [T]) -> &mut [u8] { + use std::mem::size_of; + + let len = size_of::() * slice.len(); + slice::from_raw_parts_mut(slice.as_mut_ptr() as *mut u8, len) +} diff --git a/third_party/cargo/vendor/byteorder-1.3.2/src/lib.rs b/third_party/cargo/vendor/byteorder-1.3.2/src/lib.rs new file mode 100644 index 0000000..db4d24d --- /dev/null +++ b/third_party/cargo/vendor/byteorder-1.3.2/src/lib.rs @@ -0,0 +1,3328 @@ +/*! +This crate provides convenience methods for encoding and decoding numbers in +either [big-endian or little-endian order]. + +The organization of the crate is pretty simple. A trait, [`ByteOrder`], specifies +byte conversion methods for each type of number in Rust (sans numbers that have +a platform dependent size like `usize` and `isize`). Two types, [`BigEndian`] +and [`LittleEndian`] implement these methods. Finally, [`ReadBytesExt`] and +[`WriteBytesExt`] provide convenience methods available to all types that +implement [`Read`] and [`Write`]. + +An alias, [`NetworkEndian`], for [`BigEndian`] is provided to help improve +code clarity. + +An additional alias, [`NativeEndian`], is provided for the endianness of the +local platform. This is convenient when serializing data for use and +conversions are not desired. + +# Examples + +Read unsigned 16 bit big-endian integers from a [`Read`] type: + +```rust +use std::io::Cursor; +use byteorder::{BigEndian, ReadBytesExt}; + +let mut rdr = Cursor::new(vec![2, 5, 3, 0]); +// Note that we use type parameters to indicate which kind of byte order +// we want! +assert_eq!(517, rdr.read_u16::().unwrap()); +assert_eq!(768, rdr.read_u16::().unwrap()); +``` + +Write unsigned 16 bit little-endian integers to a [`Write`] type: + +```rust +use byteorder::{LittleEndian, WriteBytesExt}; + +let mut wtr = vec![]; +wtr.write_u16::(517).unwrap(); +wtr.write_u16::(768).unwrap(); +assert_eq!(wtr, vec![5, 2, 0, 3]); +``` + +# Optional Features + +This crate optionally provides support for 128 bit values (`i128` and `u128`) +when built with the `i128` feature enabled. + +This crate can also be used without the standard library. + +# Alternatives + +Note that as of Rust 1.32, the standard numeric types provide built-in methods +like `to_le_bytes` and `from_le_bytes`, which support some of the same use +cases. + +[big-endian or little-endian order]: https://en.wikipedia.org/wiki/Endianness +[`ByteOrder`]: trait.ByteOrder.html +[`BigEndian`]: enum.BigEndian.html +[`LittleEndian`]: enum.LittleEndian.html +[`ReadBytesExt`]: trait.ReadBytesExt.html +[`WriteBytesExt`]: trait.WriteBytesExt.html +[`NetworkEndian`]: type.NetworkEndian.html +[`NativeEndian`]: type.NativeEndian.html +[`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html +[`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html +*/ + +#![deny(missing_docs)] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(feature = "std")] +extern crate core; + +#[cfg(test)] +#[macro_use] +extern crate doc_comment; + +#[cfg(test)] +doctest!("../README.md"); + +use core::fmt::Debug; +use core::hash::Hash; +use core::ptr::copy_nonoverlapping; +use core::slice; + +#[cfg(feature = "std")] +pub use io::{ReadBytesExt, WriteBytesExt}; + +#[cfg(feature = "std")] +mod io; + +#[inline] +fn extend_sign(val: u64, nbytes: usize) -> i64 { + let shift = (8 - nbytes) * 8; + (val << shift) as i64 >> shift +} + +#[cfg(byteorder_i128)] +#[inline] +fn extend_sign128(val: u128, nbytes: usize) -> i128 { + let shift = (16 - nbytes) * 8; + (val << shift) as i128 >> shift +} + +#[inline] +fn unextend_sign(val: i64, nbytes: usize) -> u64 { + let shift = (8 - nbytes) * 8; + (val << shift) as u64 >> shift +} + +#[cfg(byteorder_i128)] +#[inline] +fn unextend_sign128(val: i128, nbytes: usize) -> u128 { + let shift = (16 - nbytes) * 8; + (val << shift) as u128 >> shift +} + +#[inline] +fn pack_size(n: u64) -> usize { + if n < 1 << 8 { + 1 + } else if n < 1 << 16 { + 2 + } else if n < 1 << 24 { + 3 + } else if n < 1 << 32 { + 4 + } else if n < 1 << 40 { + 5 + } else if n < 1 << 48 { + 6 + } else if n < 1 << 56 { + 7 + } else { + 8 + } +} + +#[cfg(byteorder_i128)] +#[inline] +fn pack_size128(n: u128) -> usize { + if n < 1 << 8 { + 1 + } else if n < 1 << 16 { + 2 + } else if n < 1 << 24 { + 3 + } else if n < 1 << 32 { + 4 + } else if n < 1 << 40 { + 5 + } else if n < 1 << 48 { + 6 + } else if n < 1 << 56 { + 7 + } else if n < 1 << 64 { + 8 + } else if n < 1 << 72 { + 9 + } else if n < 1 << 80 { + 10 + } else if n < 1 << 88 { + 11 + } else if n < 1 << 96 { + 12 + } else if n < 1 << 104 { + 13 + } else if n < 1 << 112 { + 14 + } else if n < 1 << 120 { + 15 + } else { + 16 + } +} + +mod private { + /// Sealed stops crates other than byteorder from implementing any traits + /// that use it. + pub trait Sealed{} + impl Sealed for super::LittleEndian {} + impl Sealed for super::BigEndian {} +} + +/// `ByteOrder` describes types that can serialize integers as bytes. +/// +/// Note that `Self` does not appear anywhere in this trait's definition! +/// Therefore, in order to use it, you'll need to use syntax like +/// `T::read_u16(&[0, 1])` where `T` implements `ByteOrder`. +/// +/// This crate provides two types that implement `ByteOrder`: [`BigEndian`] +/// and [`LittleEndian`]. +/// This trait is sealed and cannot be implemented for callers to avoid +/// breaking backwards compatibility when adding new derived traits. +/// +/// # Examples +/// +/// Write and read `u32` numbers in little endian order: +/// +/// ```rust +/// use byteorder::{ByteOrder, LittleEndian}; +/// +/// let mut buf = [0; 4]; +/// LittleEndian::write_u32(&mut buf, 1_000_000); +/// assert_eq!(1_000_000, LittleEndian::read_u32(&buf)); +/// ``` +/// +/// Write and read `i16` numbers in big endian order: +/// +/// ```rust +/// use byteorder::{ByteOrder, BigEndian}; +/// +/// let mut buf = [0; 2]; +/// BigEndian::write_i16(&mut buf, -5_000); +/// assert_eq!(-5_000, BigEndian::read_i16(&buf)); +/// ``` +/// +/// [`BigEndian`]: enum.BigEndian.html +/// [`LittleEndian`]: enum.LittleEndian.html +pub trait ByteOrder + : Clone + Copy + Debug + Default + Eq + Hash + Ord + PartialEq + PartialOrd + + private::Sealed +{ + /// Reads an unsigned 16 bit integer from `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 2`. + fn read_u16(buf: &[u8]) -> u16; + + /// Reads an unsigned 24 bit integer from `buf`, stored in u32. + /// + /// # Panics + /// + /// Panics when `buf.len() < 3`. + /// + /// # Examples + /// + /// Write and read 24 bit `u32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_u24(&mut buf, 1_000_000); + /// assert_eq!(1_000_000, LittleEndian::read_u24(&buf)); + /// ``` + fn read_u24(buf: &[u8]) -> u32 { + Self::read_uint(buf, 3) as u32 + } + + /// Reads an unsigned 32 bit integer from `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 4`. + /// + /// # Examples + /// + /// Write and read `u32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 4]; + /// LittleEndian::write_u32(&mut buf, 1_000_000); + /// assert_eq!(1_000_000, LittleEndian::read_u32(&buf)); + /// ``` + fn read_u32(buf: &[u8]) -> u32; + + /// Reads an unsigned 48 bit integer from `buf`, stored in u64. + /// + /// # Panics + /// + /// Panics when `buf.len() < 6`. + /// + /// # Examples + /// + /// Write and read 48 bit `u64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 6]; + /// LittleEndian::write_u48(&mut buf, 1_000_000_000_000); + /// assert_eq!(1_000_000_000_000, LittleEndian::read_u48(&buf)); + /// ``` + fn read_u48(buf: &[u8]) -> u64 { + Self::read_uint(buf, 6) as u64 + } + + /// Reads an unsigned 64 bit integer from `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 8`. + /// + /// # Examples + /// + /// Write and read `u64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 8]; + /// LittleEndian::write_u64(&mut buf, 1_000_000); + /// assert_eq!(1_000_000, LittleEndian::read_u64(&buf)); + /// ``` + fn read_u64(buf: &[u8]) -> u64; + + /// Reads an unsigned 128 bit integer from `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 16`. + /// + /// # Examples + /// + /// Write and read `u128` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 16]; + /// LittleEndian::write_u128(&mut buf, 1_000_000); + /// assert_eq!(1_000_000, LittleEndian::read_u128(&buf)); + /// ``` + #[cfg(byteorder_i128)] + fn read_u128(buf: &[u8]) -> u128; + + /// Reads an unsigned n-bytes integer from `buf`. + /// + /// # Panics + /// + /// Panics when `nbytes < 1` or `nbytes > 8` or + /// `buf.len() < nbytes` + /// + /// # Examples + /// + /// Write and read an n-byte number in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_uint(&mut buf, 1_000_000, 3); + /// assert_eq!(1_000_000, LittleEndian::read_uint(&buf, 3)); + /// ``` + fn read_uint(buf: &[u8], nbytes: usize) -> u64; + + /// Reads an unsigned n-bytes integer from `buf`. + /// + /// # Panics + /// + /// Panics when `nbytes < 1` or `nbytes > 16` or + /// `buf.len() < nbytes` + /// + /// # Examples + /// + /// Write and read an n-byte number in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_uint128(&mut buf, 1_000_000, 3); + /// assert_eq!(1_000_000, LittleEndian::read_uint128(&buf, 3)); + /// ``` + #[cfg(byteorder_i128)] + fn read_uint128(buf: &[u8], nbytes: usize) -> u128; + + /// Writes an unsigned 16 bit integer `n` to `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 2`. + /// + /// # Examples + /// + /// Write and read `u16` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 2]; + /// LittleEndian::write_u16(&mut buf, 1_000); + /// assert_eq!(1_000, LittleEndian::read_u16(&buf)); + /// ``` + fn write_u16(buf: &mut [u8], n: u16); + + /// Writes an unsigned 24 bit integer `n` to `buf`, stored in u32. + /// + /// # Panics + /// + /// Panics when `buf.len() < 3`. + /// + /// # Examples + /// + /// Write and read 24 bit `u32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_u24(&mut buf, 1_000_000); + /// assert_eq!(1_000_000, LittleEndian::read_u24(&buf)); + /// ``` + fn write_u24(buf: &mut [u8], n: u32) { + Self::write_uint(buf, n as u64, 3) + } + + /// Writes an unsigned 32 bit integer `n` to `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 4`. + /// + /// # Examples + /// + /// Write and read `u32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 4]; + /// LittleEndian::write_u32(&mut buf, 1_000_000); + /// assert_eq!(1_000_000, LittleEndian::read_u32(&buf)); + /// ``` + fn write_u32(buf: &mut [u8], n: u32); + + /// Writes an unsigned 48 bit integer `n` to `buf`, stored in u64. + /// + /// # Panics + /// + /// Panics when `buf.len() < 6`. + /// + /// # Examples + /// + /// Write and read 48 bit `u64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 6]; + /// LittleEndian::write_u48(&mut buf, 1_000_000_000_000); + /// assert_eq!(1_000_000_000_000, LittleEndian::read_u48(&buf)); + /// ``` + fn write_u48(buf: &mut [u8], n: u64) { + Self::write_uint(buf, n as u64, 6) + } + + /// Writes an unsigned 64 bit integer `n` to `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 8`. + /// + /// # Examples + /// + /// Write and read `u64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 8]; + /// LittleEndian::write_u64(&mut buf, 1_000_000); + /// assert_eq!(1_000_000, LittleEndian::read_u64(&buf)); + /// ``` + fn write_u64(buf: &mut [u8], n: u64); + + /// Writes an unsigned 128 bit integer `n` to `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 16`. + /// + /// # Examples + /// + /// Write and read `u128` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 16]; + /// LittleEndian::write_u128(&mut buf, 1_000_000); + /// assert_eq!(1_000_000, LittleEndian::read_u128(&buf)); + /// ``` + #[cfg(byteorder_i128)] + fn write_u128(buf: &mut [u8], n: u128); + + /// Writes an unsigned integer `n` to `buf` using only `nbytes`. + /// + /// # Panics + /// + /// If `n` is not representable in `nbytes`, or if `nbytes` is `> 8`, then + /// this method panics. + /// + /// # Examples + /// + /// Write and read an n-byte number in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_uint(&mut buf, 1_000_000, 3); + /// assert_eq!(1_000_000, LittleEndian::read_uint(&buf, 3)); + /// ``` + fn write_uint(buf: &mut [u8], n: u64, nbytes: usize); + + /// Writes an unsigned integer `n` to `buf` using only `nbytes`. + /// + /// # Panics + /// + /// If `n` is not representable in `nbytes`, or if `nbytes` is `> 16`, then + /// this method panics. + /// + /// # Examples + /// + /// Write and read an n-byte number in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_uint128(&mut buf, 1_000_000, 3); + /// assert_eq!(1_000_000, LittleEndian::read_uint128(&buf, 3)); + /// ``` + #[cfg(byteorder_i128)] + fn write_uint128(buf: &mut [u8], n: u128, nbytes: usize); + + /// Reads a signed 16 bit integer from `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 2`. + /// + /// # Examples + /// + /// Write and read `i16` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 2]; + /// LittleEndian::write_i16(&mut buf, -1_000); + /// assert_eq!(-1_000, LittleEndian::read_i16(&buf)); + /// ``` + #[inline] + fn read_i16(buf: &[u8]) -> i16 { + Self::read_u16(buf) as i16 + } + + /// Reads a signed 24 bit integer from `buf`, stored in i32. + /// + /// # Panics + /// + /// Panics when `buf.len() < 3`. + /// + /// # Examples + /// + /// Write and read 24 bit `i32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_i24(&mut buf, -1_000_000); + /// assert_eq!(-1_000_000, LittleEndian::read_i24(&buf)); + /// ``` + #[inline] + fn read_i24(buf: &[u8]) -> i32 { + Self::read_int(buf, 3) as i32 + } + + /// Reads a signed 32 bit integer from `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 4`. + /// + /// # Examples + /// + /// Write and read `i32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 4]; + /// LittleEndian::write_i32(&mut buf, -1_000_000); + /// assert_eq!(-1_000_000, LittleEndian::read_i32(&buf)); + /// ``` + #[inline] + fn read_i32(buf: &[u8]) -> i32 { + Self::read_u32(buf) as i32 + } + + /// Reads a signed 48 bit integer from `buf`, stored in i64. + /// + /// # Panics + /// + /// Panics when `buf.len() < 6`. + /// + /// # Examples + /// + /// Write and read 48 bit `i64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 6]; + /// LittleEndian::write_i48(&mut buf, -1_000_000_000_000); + /// assert_eq!(-1_000_000_000_000, LittleEndian::read_i48(&buf)); + /// ``` + #[inline] + fn read_i48(buf: &[u8]) -> i64 { + Self::read_int(buf, 6) as i64 + } + + /// Reads a signed 64 bit integer from `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 8`. + /// + /// # Examples + /// + /// Write and read `i64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 8]; + /// LittleEndian::write_i64(&mut buf, -1_000_000_000); + /// assert_eq!(-1_000_000_000, LittleEndian::read_i64(&buf)); + /// ``` + #[inline] + fn read_i64(buf: &[u8]) -> i64 { + Self::read_u64(buf) as i64 + } + + /// Reads a signed 128 bit integer from `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 16`. + /// + /// # Examples + /// + /// Write and read `i128` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 16]; + /// LittleEndian::write_i128(&mut buf, -1_000_000_000); + /// assert_eq!(-1_000_000_000, LittleEndian::read_i128(&buf)); + /// ``` + #[cfg(byteorder_i128)] + #[inline] + fn read_i128(buf: &[u8]) -> i128 { + Self::read_u128(buf) as i128 + } + + /// Reads a signed n-bytes integer from `buf`. + /// + /// # Panics + /// + /// Panics when `nbytes < 1` or `nbytes > 8` or + /// `buf.len() < nbytes` + /// + /// # Examples + /// + /// Write and read n-length signed numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_int(&mut buf, -1_000, 3); + /// assert_eq!(-1_000, LittleEndian::read_int(&buf, 3)); + /// ``` + #[inline] + fn read_int(buf: &[u8], nbytes: usize) -> i64 { + extend_sign(Self::read_uint(buf, nbytes), nbytes) + } + + /// Reads a signed n-bytes integer from `buf`. + /// + /// # Panics + /// + /// Panics when `nbytes < 1` or `nbytes > 16` or + /// `buf.len() < nbytes` + /// + /// # Examples + /// + /// Write and read n-length signed numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_int128(&mut buf, -1_000, 3); + /// assert_eq!(-1_000, LittleEndian::read_int128(&buf, 3)); + /// ``` + #[cfg(byteorder_i128)] + #[inline] + fn read_int128(buf: &[u8], nbytes: usize) -> i128 { + extend_sign128(Self::read_uint128(buf, nbytes), nbytes) + } + + /// Reads a IEEE754 single-precision (4 bytes) floating point number. + /// + /// # Panics + /// + /// Panics when `buf.len() < 4`. + /// + /// # Examples + /// + /// Write and read `f32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let e = 2.71828; + /// let mut buf = [0; 4]; + /// LittleEndian::write_f32(&mut buf, e); + /// assert_eq!(e, LittleEndian::read_f32(&buf)); + /// ``` + #[inline] + fn read_f32(buf: &[u8]) -> f32 { + unsafe { *(&Self::read_u32(buf) as *const u32 as *const f32) } + } + + /// Reads a IEEE754 double-precision (8 bytes) floating point number. + /// + /// # Panics + /// + /// Panics when `buf.len() < 8`. + /// + /// # Examples + /// + /// Write and read `f64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let phi = 1.6180339887; + /// let mut buf = [0; 8]; + /// LittleEndian::write_f64(&mut buf, phi); + /// assert_eq!(phi, LittleEndian::read_f64(&buf)); + /// ``` + #[inline] + fn read_f64(buf: &[u8]) -> f64 { + unsafe { *(&Self::read_u64(buf) as *const u64 as *const f64) } + } + + /// Writes a signed 16 bit integer `n` to `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 2`. + /// + /// # Examples + /// + /// Write and read `i16` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 2]; + /// LittleEndian::write_i16(&mut buf, -1_000); + /// assert_eq!(-1_000, LittleEndian::read_i16(&buf)); + /// ``` + #[inline] + fn write_i16(buf: &mut [u8], n: i16) { + Self::write_u16(buf, n as u16) + } + + /// Writes a signed 24 bit integer `n` to `buf`, stored in i32. + /// + /// # Panics + /// + /// Panics when `buf.len() < 3`. + /// + /// # Examples + /// + /// Write and read 24 bit `i32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_i24(&mut buf, -1_000_000); + /// assert_eq!(-1_000_000, LittleEndian::read_i24(&buf)); + /// ``` + #[inline] + fn write_i24(buf: &mut [u8], n: i32) { + Self::write_int(buf, n as i64, 3) + } + + /// Writes a signed 32 bit integer `n` to `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 4`. + /// + /// # Examples + /// + /// Write and read `i32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 4]; + /// LittleEndian::write_i32(&mut buf, -1_000_000); + /// assert_eq!(-1_000_000, LittleEndian::read_i32(&buf)); + /// ``` + #[inline] + fn write_i32(buf: &mut [u8], n: i32) { + Self::write_u32(buf, n as u32) + } + + /// Writes a signed 48 bit integer `n` to `buf`, stored in i64. + /// + /// # Panics + /// + /// Panics when `buf.len() < 6`. + /// + /// # Examples + /// + /// Write and read 48 bit `i64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 6]; + /// LittleEndian::write_i48(&mut buf, -1_000_000_000_000); + /// assert_eq!(-1_000_000_000_000, LittleEndian::read_i48(&buf)); + /// ``` + #[inline] + fn write_i48(buf: &mut [u8], n: i64) { + Self::write_int(buf, n as i64, 6) + } + + /// Writes a signed 64 bit integer `n` to `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 8`. + /// + /// # Examples + /// + /// Write and read `i64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 8]; + /// LittleEndian::write_i64(&mut buf, -1_000_000_000); + /// assert_eq!(-1_000_000_000, LittleEndian::read_i64(&buf)); + /// ``` + #[inline] + fn write_i64(buf: &mut [u8], n: i64) { + Self::write_u64(buf, n as u64) + } + + /// Writes a signed 128 bit integer `n` to `buf`. + /// + /// # Panics + /// + /// Panics when `buf.len() < 16`. + /// + /// # Examples + /// + /// Write and read n-byte `i128` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 16]; + /// LittleEndian::write_i128(&mut buf, -1_000_000_000); + /// assert_eq!(-1_000_000_000, LittleEndian::read_i128(&buf)); + /// ``` + #[cfg(byteorder_i128)] + #[inline] + fn write_i128(buf: &mut [u8], n: i128) { + Self::write_u128(buf, n as u128) + } + + /// Writes a signed integer `n` to `buf` using only `nbytes`. + /// + /// # Panics + /// + /// If `n` is not representable in `nbytes`, or if `nbytes` is `> 8`, then + /// this method panics. + /// + /// # Examples + /// + /// Write and read an n-byte number in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_int(&mut buf, -1_000, 3); + /// assert_eq!(-1_000, LittleEndian::read_int(&buf, 3)); + /// ``` + #[inline] + fn write_int(buf: &mut [u8], n: i64, nbytes: usize) { + Self::write_uint(buf, unextend_sign(n, nbytes), nbytes) + } + + /// Writes a signed integer `n` to `buf` using only `nbytes`. + /// + /// # Panics + /// + /// If `n` is not representable in `nbytes`, or if `nbytes` is `> 16`, then + /// this method panics. + /// + /// # Examples + /// + /// Write and read n-length signed numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_int128(&mut buf, -1_000, 3); + /// assert_eq!(-1_000, LittleEndian::read_int128(&buf, 3)); + /// ``` + #[cfg(byteorder_i128)] + #[inline] + fn write_int128(buf: &mut [u8], n: i128, nbytes: usize) { + Self::write_uint128(buf, unextend_sign128(n, nbytes), nbytes) + } + + /// Writes a IEEE754 single-precision (4 bytes) floating point number. + /// + /// # Panics + /// + /// Panics when `buf.len() < 4`. + /// + /// # Examples + /// + /// Write and read `f32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let e = 2.71828; + /// let mut buf = [0; 4]; + /// LittleEndian::write_f32(&mut buf, e); + /// assert_eq!(e, LittleEndian::read_f32(&buf)); + /// ``` + #[inline] + fn write_f32(buf: &mut [u8], n: f32) { + let n = unsafe { *(&n as *const f32 as *const u32) }; + Self::write_u32(buf, n) + } + + /// Writes a IEEE754 double-precision (8 bytes) floating point number. + /// + /// # Panics + /// + /// Panics when `buf.len() < 8`. + /// + /// # Examples + /// + /// Write and read `f64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let phi = 1.6180339887; + /// let mut buf = [0; 8]; + /// LittleEndian::write_f64(&mut buf, phi); + /// assert_eq!(phi, LittleEndian::read_f64(&buf)); + /// ``` + #[inline] + fn write_f64(buf: &mut [u8], n: f64) { + let n = unsafe { *(&n as *const f64 as *const u64) }; + Self::write_u64(buf, n) + } + + /// Reads unsigned 16 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 2*dst.len()`. + /// + /// # Examples + /// + /// Write and read `u16` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 8]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_u16_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_u16_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn read_u16_into(src: &[u8], dst: &mut [u16]); + + /// Reads unsigned 32 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 4*dst.len()`. + /// + /// # Examples + /// + /// Write and read `u32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 16]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_u32_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_u32_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn read_u32_into(src: &[u8], dst: &mut [u32]); + + /// Reads unsigned 64 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 8*dst.len()`. + /// + /// # Examples + /// + /// Write and read `u64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 32]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_u64_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_u64_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn read_u64_into(src: &[u8], dst: &mut [u64]); + + /// Reads unsigned 128 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 16*dst.len()`. + /// + /// # Examples + /// + /// Write and read `u128` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 64]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_u128_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_u128_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[cfg(byteorder_i128)] + fn read_u128_into(src: &[u8], dst: &mut [u128]); + + /// Reads signed 16 bit integers from `src` to `dst`. + /// + /// # Panics + /// + /// Panics when `buf.len() != 2*dst.len()`. + /// + /// # Examples + /// + /// Write and read `i16` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 8]; + /// let numbers_given = [1, 2, 0x0f, 0xee]; + /// LittleEndian::write_i16_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_i16_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[inline] + fn read_i16_into(src: &[u8], dst: &mut [i16]) { + let dst = unsafe { + slice::from_raw_parts_mut(dst.as_mut_ptr() as *mut u16, dst.len()) + }; + Self::read_u16_into(src, dst) + } + + /// Reads signed 32 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 4*dst.len()`. + /// + /// # Examples + /// + /// Write and read `i32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 16]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_i32_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_i32_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[inline] + fn read_i32_into(src: &[u8], dst: &mut [i32]) { + let dst = unsafe { + slice::from_raw_parts_mut(dst.as_mut_ptr() as *mut u32, dst.len()) + }; + Self::read_u32_into(src, dst); + } + + /// Reads signed 64 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 8*dst.len()`. + /// + /// # Examples + /// + /// Write and read `i64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 32]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_i64_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_i64_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[inline] + fn read_i64_into(src: &[u8], dst: &mut [i64]) { + let dst = unsafe { + slice::from_raw_parts_mut(dst.as_mut_ptr() as *mut u64, dst.len()) + }; + Self::read_u64_into(src, dst); + } + + /// Reads signed 128 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 16*dst.len()`. + /// + /// # Examples + /// + /// Write and read `i128` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 64]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_i128_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_i128_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[cfg(byteorder_i128)] + #[inline] + fn read_i128_into(src: &[u8], dst: &mut [i128]) { + let dst = unsafe { + slice::from_raw_parts_mut(dst.as_mut_ptr() as *mut u128, dst.len()) + }; + Self::read_u128_into(src, dst); + } + + /// Reads IEEE754 single-precision (4 bytes) floating point numbers from + /// `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 4*dst.len()`. + /// + /// # Examples + /// + /// Write and read `f32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 16]; + /// let numbers_given = [1.0, 2.0, 31.312e31, -11.32e19]; + /// LittleEndian::write_f32_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0.0; 4]; + /// LittleEndian::read_f32_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[inline] + fn read_f32_into(src: &[u8], dst: &mut [f32]) { + let dst = unsafe { + slice::from_raw_parts_mut(dst.as_mut_ptr() as *mut u32, dst.len()) + }; + Self::read_u32_into(src, dst); + } + + /// **DEPRECATED**. + /// + /// This method is deprecated. Use `read_f32_into` instead. + /// Reads IEEE754 single-precision (4 bytes) floating point numbers from + /// `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 4*dst.len()`. + /// + /// # Examples + /// + /// Write and read `f32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 16]; + /// let numbers_given = [1.0, 2.0, 31.312e31, -11.32e19]; + /// LittleEndian::write_f32_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0.0; 4]; + /// LittleEndian::read_f32_into_unchecked(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[inline] + #[deprecated(since="1.3.0", note="please use `read_f32_into` instead")] + fn read_f32_into_unchecked(src: &[u8], dst: &mut [f32]) { + Self::read_f32_into(src, dst); + } + + /// Reads IEEE754 single-precision (4 bytes) floating point numbers from + /// `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 8*dst.len()`. + /// + /// # Examples + /// + /// Write and read `f64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 32]; + /// let numbers_given = [1.0, 2.0, 31.312e211, -11.32e91]; + /// LittleEndian::write_f64_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0.0; 4]; + /// LittleEndian::read_f64_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[inline] + fn read_f64_into(src: &[u8], dst: &mut [f64]) { + let dst = unsafe { + slice::from_raw_parts_mut(dst.as_mut_ptr() as *mut u64, dst.len()) + }; + Self::read_u64_into(src, dst); + } + + /// **DEPRECATED**. + /// + /// This method is deprecated. Use `read_f64_into` instead. + /// + /// Reads IEEE754 single-precision (4 bytes) floating point numbers from + /// `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 8*dst.len()`. + /// + /// # Examples + /// + /// Write and read `f64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 32]; + /// let numbers_given = [1.0, 2.0, 31.312e211, -11.32e91]; + /// LittleEndian::write_f64_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0.0; 4]; + /// LittleEndian::read_f64_into_unchecked(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[inline] + #[deprecated(since="1.3.0", note="please use `read_f64_into` instead")] + fn read_f64_into_unchecked(src: &[u8], dst: &mut [f64]) { + Self::read_f64_into(src, dst); + } + + /// Writes unsigned 16 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `dst.len() != 2*src.len()`. + /// + /// # Examples + /// + /// Write and read `u16` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 8]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_u16_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_u16_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn write_u16_into(src: &[u16], dst: &mut [u8]); + + /// Writes unsigned 32 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `dst.len() != 4*src.len()`. + /// + /// # Examples + /// + /// Write and read `u32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 16]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_u32_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_u32_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn write_u32_into(src: &[u32], dst: &mut [u8]); + + /// Writes unsigned 64 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `dst.len() != 8*src.len()`. + /// + /// # Examples + /// + /// Write and read `u64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 32]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_u64_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_u64_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn write_u64_into(src: &[u64], dst: &mut [u8]); + + /// Writes unsigned 128 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `dst.len() != 16*src.len()`. + /// + /// # Examples + /// + /// Write and read `u128` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 64]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_u128_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_u128_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[cfg(byteorder_i128)] + fn write_u128_into(src: &[u128], dst: &mut [u8]); + + /// Writes signed 16 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `buf.len() != 2*src.len()`. + /// + /// # Examples + /// + /// Write and read `i16` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 8]; + /// let numbers_given = [1, 2, 0x0f, 0xee]; + /// LittleEndian::write_i16_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_i16_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn write_i16_into(src: &[i16], dst: &mut [u8]) { + let src = unsafe { + slice::from_raw_parts(src.as_ptr() as *const u16, src.len()) + }; + Self::write_u16_into(src, dst); + } + + /// Writes signed 32 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `dst.len() != 4*src.len()`. + /// + /// # Examples + /// + /// Write and read `i32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 16]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_i32_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_i32_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn write_i32_into(src: &[i32], dst: &mut [u8]) { + let src = unsafe { + slice::from_raw_parts(src.as_ptr() as *const u32, src.len()) + }; + Self::write_u32_into(src, dst); + } + + /// Writes signed 64 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `dst.len() != 8*src.len()`. + /// + /// # Examples + /// + /// Write and read `i64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 32]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_i64_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_i64_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn write_i64_into(src: &[i64], dst: &mut [u8]) { + let src = unsafe { + slice::from_raw_parts(src.as_ptr() as *const u64, src.len()) + }; + Self::write_u64_into(src, dst); + } + + /// Writes signed 128 bit integers from `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `dst.len() != 16*src.len()`. + /// + /// # Examples + /// + /// Write and read `i128` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 64]; + /// let numbers_given = [1, 2, 0xf00f, 0xffee]; + /// LittleEndian::write_i128_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0; 4]; + /// LittleEndian::read_i128_into(&bytes, &mut numbers_got); + /// assert_eq!(numbers_given, numbers_got); + /// ``` + #[cfg(byteorder_i128)] + fn write_i128_into(src: &[i128], dst: &mut [u8]) { + let src = unsafe { + slice::from_raw_parts(src.as_ptr() as *const u128, src.len()) + }; + Self::write_u128_into(src, dst); + } + + /// Writes IEEE754 single-precision (4 bytes) floating point numbers from + /// `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 4*dst.len()`. + /// + /// # Examples + /// + /// Write and read `f32` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 16]; + /// let numbers_given = [1.0, 2.0, 31.312e31, -11.32e19]; + /// LittleEndian::write_f32_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0.0; 4]; + /// unsafe { + /// LittleEndian::read_f32_into(&bytes, &mut numbers_got); + /// } + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn write_f32_into(src: &[f32], dst: &mut [u8]) { + let src = unsafe { + slice::from_raw_parts(src.as_ptr() as *const u32, src.len()) + }; + Self::write_u32_into(src, dst); + } + + /// Writes IEEE754 double-precision (8 bytes) floating point numbers from + /// `src` into `dst`. + /// + /// # Panics + /// + /// Panics when `src.len() != 8*dst.len()`. + /// + /// # Examples + /// + /// Write and read `f64` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut bytes = [0; 32]; + /// let numbers_given = [1.0, 2.0, 31.312e211, -11.32e91]; + /// LittleEndian::write_f64_into(&numbers_given, &mut bytes); + /// + /// let mut numbers_got = [0.0; 4]; + /// unsafe { + /// LittleEndian::read_f64_into(&bytes, &mut numbers_got); + /// } + /// assert_eq!(numbers_given, numbers_got); + /// ``` + fn write_f64_into(src: &[f64], dst: &mut [u8]) { + let src = unsafe { + slice::from_raw_parts(src.as_ptr() as *const u64, src.len()) + }; + Self::write_u64_into(src, dst); + } + + /// Converts the given slice of unsigned 16 bit integers to a particular + /// endianness. + /// + /// If the endianness matches the endianness of the host platform, then + /// this is a no-op. + /// + /// # Examples + /// + /// Convert the host platform's endianness to big-endian: + /// + /// ```rust + /// use byteorder::{ByteOrder, BigEndian}; + /// + /// let mut numbers = [5, 65000]; + /// BigEndian::from_slice_u16(&mut numbers); + /// assert_eq!(numbers, [5u16.to_be(), 65000u16.to_be()]); + /// ``` + fn from_slice_u16(numbers: &mut [u16]); + + /// Converts the given slice of unsigned 32 bit integers to a particular + /// endianness. + /// + /// If the endianness matches the endianness of the host platform, then + /// this is a no-op. + /// + /// # Examples + /// + /// Convert the host platform's endianness to big-endian: + /// + /// ```rust + /// use byteorder::{ByteOrder, BigEndian}; + /// + /// let mut numbers = [5, 65000]; + /// BigEndian::from_slice_u32(&mut numbers); + /// assert_eq!(numbers, [5u32.to_be(), 65000u32.to_be()]); + /// ``` + fn from_slice_u32(numbers: &mut [u32]); + + /// Converts the given slice of unsigned 64 bit integers to a particular + /// endianness. + /// + /// If the endianness matches the endianness of the host platform, then + /// this is a no-op. + /// + /// # Examples + /// + /// Convert the host platform's endianness to big-endian: + /// + /// ```rust + /// use byteorder::{ByteOrder, BigEndian}; + /// + /// let mut numbers = [5, 65000]; + /// BigEndian::from_slice_u64(&mut numbers); + /// assert_eq!(numbers, [5u64.to_be(), 65000u64.to_be()]); + /// ``` + fn from_slice_u64(numbers: &mut [u64]); + + /// Converts the given slice of unsigned 128 bit integers to a particular + /// endianness. + /// + /// If the endianness matches the endianness of the host platform, then + /// this is a no-op. + /// + /// # Examples + /// + /// Convert the host platform's endianness to big-endian: + /// + /// ```rust + /// use byteorder::{ByteOrder, BigEndian}; + /// + /// let mut numbers = [5, 65000]; + /// BigEndian::from_slice_u128(&mut numbers); + /// assert_eq!(numbers, [5u128.to_be(), 65000u128.to_be()]); + /// ``` + #[cfg(byteorder_i128)] + fn from_slice_u128(numbers: &mut [u128]); + + /// Converts the given slice of signed 16 bit integers to a particular + /// endianness. + /// + /// If the endianness matches the endianness of the host platform, then + /// this is a no-op. + /// + /// # Examples + /// + /// Convert the host platform's endianness to big-endian: + /// + /// ```rust + /// use byteorder::{ByteOrder, BigEndian}; + /// + /// let mut numbers = [5, 6500]; + /// BigEndian::from_slice_i16(&mut numbers); + /// assert_eq!(numbers, [5i16.to_be(), 6500i16.to_be()]); + /// ``` + #[inline] + fn from_slice_i16(src: &mut [i16]) { + let src = unsafe { + slice::from_raw_parts_mut(src.as_ptr() as *mut u16, src.len()) + }; + Self::from_slice_u16(src); + } + + /// Converts the given slice of signed 32 bit integers to a particular + /// endianness. + /// + /// If the endianness matches the endianness of the host platform, then + /// this is a no-op. + /// + /// # Examples + /// + /// Convert the host platform's endianness to big-endian: + /// + /// ```rust + /// use byteorder::{ByteOrder, BigEndian}; + /// + /// let mut numbers = [5, 65000]; + /// BigEndian::from_slice_i32(&mut numbers); + /// assert_eq!(numbers, [5i32.to_be(), 65000i32.to_be()]); + /// ``` + #[inline] + fn from_slice_i32(src: &mut [i32]) { + let src = unsafe { + slice::from_raw_parts_mut(src.as_ptr() as *mut u32, src.len()) + }; + Self::from_slice_u32(src); + } + + /// Converts the given slice of signed 64 bit integers to a particular + /// endianness. + /// + /// If the endianness matches the endianness of the host platform, then + /// this is a no-op. + /// + /// # Examples + /// + /// Convert the host platform's endianness to big-endian: + /// + /// ```rust + /// use byteorder::{ByteOrder, BigEndian}; + /// + /// let mut numbers = [5, 65000]; + /// BigEndian::from_slice_i64(&mut numbers); + /// assert_eq!(numbers, [5i64.to_be(), 65000i64.to_be()]); + /// ``` + #[inline] + fn from_slice_i64(src: &mut [i64]) { + let src = unsafe { + slice::from_raw_parts_mut(src.as_ptr() as *mut u64, src.len()) + }; + Self::from_slice_u64(src); + } + + /// Converts the given slice of signed 128 bit integers to a particular + /// endianness. + /// + /// If the endianness matches the endianness of the host platform, then + /// this is a no-op. + /// + /// # Examples + /// + /// Convert the host platform's endianness to big-endian: + /// + /// ```rust + /// use byteorder::{ByteOrder, BigEndian}; + /// + /// let mut numbers = [5, 65000]; + /// BigEndian::from_slice_i128(&mut numbers); + /// assert_eq!(numbers, [5i128.to_be(), 65000i128.to_be()]); + /// ``` + #[cfg(byteorder_i128)] + #[inline] + fn from_slice_i128(src: &mut [i128]) { + let src = unsafe { + slice::from_raw_parts_mut(src.as_ptr() as *mut u128, src.len()) + }; + Self::from_slice_u128(src); + } + + /// Converts the given slice of IEEE754 single-precision (4 bytes) floating + /// point numbers to a particular endianness. + /// + /// If the endianness matches the endianness of the host platform, then + /// this is a no-op. + fn from_slice_f32(numbers: &mut [f32]); + + /// Converts the given slice of IEEE754 double-precision (8 bytes) floating + /// point numbers to a particular endianness. + /// + /// If the endianness matches the endianness of the host platform, then + /// this is a no-op. + fn from_slice_f64(numbers: &mut [f64]); +} + +/// Defines big-endian serialization. +/// +/// Note that this type has no value constructor. It is used purely at the +/// type level. +/// +/// # Examples +/// +/// Write and read `u32` numbers in big endian order: +/// +/// ```rust +/// use byteorder::{ByteOrder, BigEndian}; +/// +/// let mut buf = [0; 4]; +/// BigEndian::write_u32(&mut buf, 1_000_000); +/// assert_eq!(1_000_000, BigEndian::read_u32(&buf)); +/// ``` +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum BigEndian {} + +impl Default for BigEndian { + fn default() -> BigEndian { + panic!("BigEndian default") + } +} + +/// A type alias for [`BigEndian`]. +/// +/// [`BigEndian`]: enum.BigEndian.html +pub type BE = BigEndian; + +/// Defines little-endian serialization. +/// +/// Note that this type has no value constructor. It is used purely at the +/// type level. +/// +/// # Examples +/// +/// Write and read `u32` numbers in little endian order: +/// +/// ```rust +/// use byteorder::{ByteOrder, LittleEndian}; +/// +/// let mut buf = [0; 4]; +/// LittleEndian::write_u32(&mut buf, 1_000_000); +/// assert_eq!(1_000_000, LittleEndian::read_u32(&buf)); +/// ``` +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum LittleEndian {} + +impl Default for LittleEndian { + fn default() -> LittleEndian { + panic!("LittleEndian default") + } +} + +/// A type alias for [`LittleEndian`]. +/// +/// [`LittleEndian`]: enum.LittleEndian.html +pub type LE = LittleEndian; + +/// Defines network byte order serialization. +/// +/// Network byte order is defined by [RFC 1700][1] to be big-endian, and is +/// referred to in several protocol specifications. This type is an alias of +/// [`BigEndian`]. +/// +/// [1]: https://tools.ietf.org/html/rfc1700 +/// +/// Note that this type has no value constructor. It is used purely at the +/// type level. +/// +/// # Examples +/// +/// Write and read `i16` numbers in big endian order: +/// +/// ```rust +/// use byteorder::{ByteOrder, NetworkEndian, BigEndian}; +/// +/// let mut buf = [0; 2]; +/// BigEndian::write_i16(&mut buf, -5_000); +/// assert_eq!(-5_000, NetworkEndian::read_i16(&buf)); +/// ``` +/// +/// [`BigEndian`]: enum.BigEndian.html +pub type NetworkEndian = BigEndian; + +/// Defines system native-endian serialization. +/// +/// Note that this type has no value constructor. It is used purely at the +/// type level. +/// +/// On this platform, this is an alias for [`LittleEndian`]. +/// +/// [`LittleEndian`]: enum.LittleEndian.html +#[cfg(target_endian = "little")] +pub type NativeEndian = LittleEndian; + +/// Defines system native-endian serialization. +/// +/// Note that this type has no value constructor. It is used purely at the +/// type level. +/// +/// On this platform, this is an alias for [`BigEndian`]. +/// +/// [`BigEndian`]: enum.BigEndian.html +#[cfg(target_endian = "big")] +pub type NativeEndian = BigEndian; + +macro_rules! read_num_bytes { + ($ty:ty, $size:expr, $src:expr, $which:ident) => ({ + assert!($size == ::core::mem::size_of::<$ty>()); + assert!($size <= $src.len()); + let mut data: $ty = 0; + unsafe { + copy_nonoverlapping( + $src.as_ptr(), + &mut data as *mut $ty as *mut u8, + $size); + } + data.$which() + }); +} + +macro_rules! write_num_bytes { + ($ty:ty, $size:expr, $n:expr, $dst:expr, $which:ident) => ({ + assert!($size <= $dst.len()); + unsafe { + // N.B. https://github.com/rust-lang/rust/issues/22776 + let bytes = *(&$n.$which() as *const _ as *const [u8; $size]); + copy_nonoverlapping((&bytes).as_ptr(), $dst.as_mut_ptr(), $size); + } + }); +} + +macro_rules! read_slice { + ($src:expr, $dst:expr, $size:expr, $which:ident) => {{ + assert_eq!($src.len(), $size * $dst.len()); + + unsafe { + copy_nonoverlapping( + $src.as_ptr(), + $dst.as_mut_ptr() as *mut u8, + $src.len()); + } + for v in $dst.iter_mut() { + *v = v.$which(); + } + }}; +} + +macro_rules! write_slice_native { + ($src:expr, $dst:expr, $ty:ty, $size:expr) => {{ + assert!($size == ::core::mem::size_of::<$ty>()); + assert_eq!($size * $src.len(), $dst.len()); + + unsafe { + copy_nonoverlapping( + $src.as_ptr() as *const u8, + $dst.as_mut_ptr(), + $dst.len()); + } + }}; +} + +macro_rules! write_slice { + ($src:expr, $dst:expr, $ty:ty, $size:expr, $write:expr) => ({ + assert!($size == ::core::mem::size_of::<$ty>()); + assert_eq!($size * $src.len(), $dst.len()); + + for (&n, chunk) in $src.iter().zip($dst.chunks_mut($size)) { + $write(chunk, n); + } + }); +} + +impl ByteOrder for BigEndian { + #[inline] + fn read_u16(buf: &[u8]) -> u16 { + read_num_bytes!(u16, 2, buf, to_be) + } + + #[inline] + fn read_u32(buf: &[u8]) -> u32 { + read_num_bytes!(u32, 4, buf, to_be) + } + + #[inline] + fn read_u64(buf: &[u8]) -> u64 { + read_num_bytes!(u64, 8, buf, to_be) + } + + #[cfg(byteorder_i128)] + #[inline] + fn read_u128(buf: &[u8]) -> u128 { + read_num_bytes!(u128, 16, buf, to_be) + } + + #[inline] + fn read_uint(buf: &[u8], nbytes: usize) -> u64 { + assert!(1 <= nbytes && nbytes <= 8 && nbytes <= buf.len()); + let mut out = [0u8; 8]; + let ptr_out = out.as_mut_ptr(); + unsafe { + copy_nonoverlapping( + buf.as_ptr(), ptr_out.offset((8 - nbytes) as isize), nbytes); + (*(ptr_out as *const u64)).to_be() + } + } + + #[cfg(byteorder_i128)] + #[inline] + fn read_uint128(buf: &[u8], nbytes: usize) -> u128 { + assert!(1 <= nbytes && nbytes <= 16 && nbytes <= buf.len()); + let mut out = [0u8; 16]; + let ptr_out = out.as_mut_ptr(); + unsafe { + copy_nonoverlapping( + buf.as_ptr(), ptr_out.offset((16 - nbytes) as isize), nbytes); + (*(ptr_out as *const u128)).to_be() + } + } + + #[inline] + fn write_u16(buf: &mut [u8], n: u16) { + write_num_bytes!(u16, 2, n, buf, to_be); + } + + #[inline] + fn write_u32(buf: &mut [u8], n: u32) { + write_num_bytes!(u32, 4, n, buf, to_be); + } + + #[inline] + fn write_u64(buf: &mut [u8], n: u64) { + write_num_bytes!(u64, 8, n, buf, to_be); + } + + #[cfg(byteorder_i128)] + #[inline] + fn write_u128(buf: &mut [u8], n: u128) { + write_num_bytes!(u128, 16, n, buf, to_be); + } + + #[inline] + fn write_uint(buf: &mut [u8], n: u64, nbytes: usize) { + assert!(pack_size(n) <= nbytes && nbytes <= 8); + assert!(nbytes <= buf.len()); + unsafe { + let bytes = *(&n.to_be() as *const u64 as *const [u8; 8]); + copy_nonoverlapping( + bytes.as_ptr().offset((8 - nbytes) as isize), + buf.as_mut_ptr(), + nbytes); + } + } + + #[cfg(byteorder_i128)] + #[inline] + fn write_uint128(buf: &mut [u8], n: u128, nbytes: usize) { + assert!(pack_size128(n) <= nbytes && nbytes <= 16); + assert!(nbytes <= buf.len()); + unsafe { + let bytes = *(&n.to_be() as *const u128 as *const [u8; 16]); + copy_nonoverlapping( + bytes.as_ptr().offset((16 - nbytes) as isize), + buf.as_mut_ptr(), + nbytes); + } + } + + #[inline] + fn read_u16_into(src: &[u8], dst: &mut [u16]) { + read_slice!(src, dst, 2, to_be); + } + + #[inline] + fn read_u32_into(src: &[u8], dst: &mut [u32]) { + read_slice!(src, dst, 4, to_be); + } + + #[inline] + fn read_u64_into(src: &[u8], dst: &mut [u64]) { + read_slice!(src, dst, 8, to_be); + } + + #[cfg(byteorder_i128)] + #[inline] + fn read_u128_into(src: &[u8], dst: &mut [u128]) { + read_slice!(src, dst, 16, to_be); + } + + #[inline] + fn write_u16_into(src: &[u16], dst: &mut [u8]) { + if cfg!(target_endian = "big") { + write_slice_native!(src, dst, u16, 2); + } else { + write_slice!(src, dst, u16, 2, Self::write_u16); + } + } + + #[inline] + fn write_u32_into(src: &[u32], dst: &mut [u8]) { + if cfg!(target_endian = "big") { + write_slice_native!(src, dst, u32, 4); + } else { + write_slice!(src, dst, u32, 4, Self::write_u32); + } + } + + #[inline] + fn write_u64_into(src: &[u64], dst: &mut [u8]) { + if cfg!(target_endian = "big") { + write_slice_native!(src, dst, u64, 8); + } else { + write_slice!(src, dst, u64, 8, Self::write_u64); + } + } + + #[cfg(byteorder_i128)] + #[inline] + fn write_u128_into(src: &[u128], dst: &mut [u8]) { + if cfg!(target_endian = "big") { + write_slice_native!(src, dst, u128, 16); + } else { + write_slice!(src, dst, u128, 16, Self::write_u128); + } + } + + #[inline] + fn from_slice_u16(numbers: &mut [u16]) { + if cfg!(target_endian = "little") { + for n in numbers { + *n = n.to_be(); + } + } + } + + #[inline] + fn from_slice_u32(numbers: &mut [u32]) { + if cfg!(target_endian = "little") { + for n in numbers { + *n = n.to_be(); + } + } + } + + #[inline] + fn from_slice_u64(numbers: &mut [u64]) { + if cfg!(target_endian = "little") { + for n in numbers { + *n = n.to_be(); + } + } + } + + #[cfg(byteorder_i128)] + #[inline] + fn from_slice_u128(numbers: &mut [u128]) { + if cfg!(target_endian = "little") { + for n in numbers { + *n = n.to_be(); + } + } + } + + #[inline] + fn from_slice_f32(numbers: &mut [f32]) { + if cfg!(target_endian = "little") { + for n in numbers { + unsafe { + let int = *(n as *const f32 as *const u32); + *n = *(&int.to_be() as *const u32 as *const f32); + } + } + } + } + + #[inline] + fn from_slice_f64(numbers: &mut [f64]) { + if cfg!(target_endian = "little") { + for n in numbers { + unsafe { + let int = *(n as *const f64 as *const u64); + *n = *(&int.to_be() as *const u64 as *const f64); + } + } + } + } +} + +impl ByteOrder for LittleEndian { + #[inline] + fn read_u16(buf: &[u8]) -> u16 { + read_num_bytes!(u16, 2, buf, to_le) + } + + #[inline] + fn read_u32(buf: &[u8]) -> u32 { + read_num_bytes!(u32, 4, buf, to_le) + } + + #[inline] + fn read_u64(buf: &[u8]) -> u64 { + read_num_bytes!(u64, 8, buf, to_le) + } + + #[cfg(byteorder_i128)] + #[inline] + fn read_u128(buf: &[u8]) -> u128 { + read_num_bytes!(u128, 16, buf, to_le) + } + + #[inline] + fn read_uint(buf: &[u8], nbytes: usize) -> u64 { + assert!(1 <= nbytes && nbytes <= 8 && nbytes <= buf.len()); + let mut out = [0u8; 8]; + let ptr_out = out.as_mut_ptr(); + unsafe { + copy_nonoverlapping(buf.as_ptr(), ptr_out, nbytes); + (*(ptr_out as *const u64)).to_le() + } + } + + #[cfg(byteorder_i128)] + #[inline] + fn read_uint128(buf: &[u8], nbytes: usize) -> u128 { + assert!(1 <= nbytes && nbytes <= 16 && nbytes <= buf.len()); + let mut out = [0u8; 16]; + let ptr_out = out.as_mut_ptr(); + unsafe { + copy_nonoverlapping(buf.as_ptr(), ptr_out, nbytes); + (*(ptr_out as *const u128)).to_le() + } + } + + #[inline] + fn write_u16(buf: &mut [u8], n: u16) { + write_num_bytes!(u16, 2, n, buf, to_le); + } + + #[inline] + fn write_u32(buf: &mut [u8], n: u32) { + write_num_bytes!(u32, 4, n, buf, to_le); + } + + #[inline] + fn write_u64(buf: &mut [u8], n: u64) { + write_num_bytes!(u64, 8, n, buf, to_le); + } + + #[cfg(byteorder_i128)] + #[inline] + fn write_u128(buf: &mut [u8], n: u128) { + write_num_bytes!(u128, 16, n, buf, to_le); + } + + #[inline] + fn write_uint(buf: &mut [u8], n: u64, nbytes: usize) { + assert!(pack_size(n as u64) <= nbytes && nbytes <= 8); + assert!(nbytes <= buf.len()); + unsafe { + let bytes = *(&n.to_le() as *const u64 as *const [u8; 8]); + copy_nonoverlapping(bytes.as_ptr(), buf.as_mut_ptr(), nbytes); + } + } + + #[cfg(byteorder_i128)] + #[inline] + fn write_uint128(buf: &mut [u8], n: u128, nbytes: usize) { + assert!(pack_size128(n as u128) <= nbytes && nbytes <= 16); + assert!(nbytes <= buf.len()); + unsafe { + let bytes = *(&n.to_le() as *const u128 as *const [u8; 16]); + copy_nonoverlapping(bytes.as_ptr(), buf.as_mut_ptr(), nbytes); + } + } + + #[inline] + fn read_u16_into(src: &[u8], dst: &mut [u16]) { + read_slice!(src, dst, 2, to_le); + } + + #[inline] + fn read_u32_into(src: &[u8], dst: &mut [u32]) { + read_slice!(src, dst, 4, to_le); + } + + #[inline] + fn read_u64_into(src: &[u8], dst: &mut [u64]) { + read_slice!(src, dst, 8, to_le); + } + + #[cfg(byteorder_i128)] + #[inline] + fn read_u128_into(src: &[u8], dst: &mut [u128]) { + read_slice!(src, dst, 16, to_le); + } + + #[inline] + fn write_u16_into(src: &[u16], dst: &mut [u8]) { + if cfg!(target_endian = "little") { + write_slice_native!(src, dst, u16, 2); + } else { + write_slice!(src, dst, u16, 2, Self::write_u16); + } + } + + #[inline] + fn write_u32_into(src: &[u32], dst: &mut [u8]) { + if cfg!(target_endian = "little") { + write_slice_native!(src, dst, u32, 4); + } else { + write_slice!(src, dst, u32, 4, Self::write_u32); + } + } + + #[inline] + fn write_u64_into(src: &[u64], dst: &mut [u8]) { + if cfg!(target_endian = "little") { + write_slice_native!(src, dst, u64, 8); + } else { + write_slice!(src, dst, u64, 8, Self::write_u64); + } + } + + #[cfg(byteorder_i128)] + #[inline] + fn write_u128_into(src: &[u128], dst: &mut [u8]) { + if cfg!(target_endian = "little") { + write_slice_native!(src, dst, u128, 16); + } else { + write_slice!(src, dst, u128, 16, Self::write_u128); + } + } + + #[inline] + fn from_slice_u16(numbers: &mut [u16]) { + if cfg!(target_endian = "big") { + for n in numbers { + *n = n.to_le(); + } + } + } + + #[inline] + fn from_slice_u32(numbers: &mut [u32]) { + if cfg!(target_endian = "big") { + for n in numbers { + *n = n.to_le(); + } + } + } + + #[inline] + fn from_slice_u64(numbers: &mut [u64]) { + if cfg!(target_endian = "big") { + for n in numbers { + *n = n.to_le(); + } + } + } + + #[cfg(byteorder_i128)] + #[inline] + fn from_slice_u128(numbers: &mut [u128]) { + if cfg!(target_endian = "big") { + for n in numbers { + *n = n.to_le(); + } + } + } + + #[inline] + fn from_slice_f32(numbers: &mut [f32]) { + if cfg!(target_endian = "big") { + for n in numbers { + unsafe { + let int = *(n as *const f32 as *const u32); + *n = *(&int.to_le() as *const u32 as *const f32); + } + } + } + } + + #[inline] + fn from_slice_f64(numbers: &mut [f64]) { + if cfg!(target_endian = "big") { + for n in numbers { + unsafe { + let int = *(n as *const f64 as *const u64); + *n = *(&int.to_le() as *const u64 as *const f64); + } + } + } + } +} + +#[cfg(test)] +mod test { + extern crate quickcheck; + extern crate rand; + + use self::quickcheck::{QuickCheck, StdGen, Testable}; + use self::rand::thread_rng; + #[cfg(byteorder_i128)] + use self::rand::Rng; + #[cfg(byteorder_i128)] + use self::quickcheck::{Arbitrary, Gen}; + + pub const U24_MAX: u32 = 16_777_215; + pub const I24_MAX: i32 = 8_388_607; + pub const U48_MAX: u64 = 281_474_976_710_655; + pub const I48_MAX: i64 = 140_737_488_355_327; + + pub const U64_MAX: u64 = ::core::u64::MAX; + pub const I64_MAX: u64 = ::core::i64::MAX as u64; + + macro_rules! calc_max { + ($max:expr, $bytes:expr) => { calc_max!($max, $bytes, 8) }; + ($max:expr, $bytes:expr, $maxbytes:expr) => { + ($max - 1) >> (8 * ($maxbytes - $bytes)) + }; + } + + #[derive(Clone, Debug)] + pub struct Wi128(pub T); + + #[cfg(byteorder_i128)] + impl Wi128 { + pub fn clone(&self) -> T { + self.0.clone() + } + } + + impl PartialEq for Wi128 { + fn eq(&self, other: &T) -> bool { + self.0.eq(other) + } + } + + #[cfg(byteorder_i128)] + impl Arbitrary for Wi128 { + fn arbitrary(gen: &mut G) -> Wi128 { + let max = calc_max!(::core::u128::MAX, gen.size(), 16); + let output = + (gen.gen::() as u128) | + ((gen.gen::() as u128) << 64); + Wi128(output & (max - 1)) + } + } + + #[cfg(byteorder_i128)] + impl Arbitrary for Wi128 { + fn arbitrary(gen: &mut G) -> Wi128 { + let max = calc_max!(::core::i128::MAX, gen.size(), 16); + let output = + (gen.gen::() as i128) | + ((gen.gen::() as i128) << 64); + Wi128(output & (max - 1)) + } + } + + pub fn qc_sized(f: A, size: u64) { + QuickCheck::new() + .gen(StdGen::new(thread_rng(), size as usize)) + .tests(1_00) + .max_tests(10_000) + .quickcheck(f); + } + + macro_rules! qc_byte_order { + ($name:ident, $ty_int:ty, $max:expr, + $bytes:expr, $read:ident, $write:ident) => ( + mod $name { + use {BigEndian, ByteOrder, NativeEndian, LittleEndian}; + #[allow(unused_imports)] use super::{ qc_sized, Wi128 }; + + #[test] + fn big_endian() { + fn prop(n: $ty_int) -> bool { + let mut buf = [0; 16]; + BigEndian::$write(&mut buf, n.clone(), $bytes); + n == BigEndian::$read(&mut buf[..$bytes], $bytes) + } + qc_sized(prop as fn($ty_int) -> bool, $max); + } + + #[test] + fn little_endian() { + fn prop(n: $ty_int) -> bool { + let mut buf = [0; 16]; + LittleEndian::$write(&mut buf, n.clone(), $bytes); + n == LittleEndian::$read(&mut buf[..$bytes], $bytes) + } + qc_sized(prop as fn($ty_int) -> bool, $max); + } + + #[test] + fn native_endian() { + fn prop(n: $ty_int) -> bool { + let mut buf = [0; 16]; + NativeEndian::$write(&mut buf, n.clone(), $bytes); + n == NativeEndian::$read(&mut buf[..$bytes], $bytes) + } + qc_sized(prop as fn($ty_int) -> bool, $max); + } + } + ); + ($name:ident, $ty_int:ty, $max:expr, + $read:ident, $write:ident) => ( + mod $name { + use core::mem::size_of; + use {BigEndian, ByteOrder, NativeEndian, LittleEndian}; + #[allow(unused_imports)] use super::{ qc_sized, Wi128 }; + + #[test] + fn big_endian() { + fn prop(n: $ty_int) -> bool { + let bytes = size_of::<$ty_int>(); + let mut buf = [0; 16]; + BigEndian::$write(&mut buf[16 - bytes..], n.clone()); + n == BigEndian::$read(&mut buf[16 - bytes..]) + } + qc_sized(prop as fn($ty_int) -> bool, $max - 1); + } + + #[test] + fn little_endian() { + fn prop(n: $ty_int) -> bool { + let bytes = size_of::<$ty_int>(); + let mut buf = [0; 16]; + LittleEndian::$write(&mut buf[..bytes], n.clone()); + n == LittleEndian::$read(&mut buf[..bytes]) + } + qc_sized(prop as fn($ty_int) -> bool, $max - 1); + } + + #[test] + fn native_endian() { + fn prop(n: $ty_int) -> bool { + let bytes = size_of::<$ty_int>(); + let mut buf = [0; 16]; + NativeEndian::$write(&mut buf[..bytes], n.clone()); + n == NativeEndian::$read(&mut buf[..bytes]) + } + qc_sized(prop as fn($ty_int) -> bool, $max - 1); + } + } + ); + } + + qc_byte_order!(prop_u16, u16, ::core::u16::MAX as u64, read_u16, write_u16); + qc_byte_order!(prop_i16, i16, ::core::i16::MAX as u64, read_i16, write_i16); + qc_byte_order!(prop_u24, u32, ::test::U24_MAX as u64, read_u24, write_u24); + qc_byte_order!(prop_i24, i32, ::test::I24_MAX as u64, read_i24, write_i24); + qc_byte_order!(prop_u32, u32, ::core::u32::MAX as u64, read_u32, write_u32); + qc_byte_order!(prop_i32, i32, ::core::i32::MAX as u64, read_i32, write_i32); + qc_byte_order!(prop_u48, u64, ::test::U48_MAX as u64, read_u48, write_u48); + qc_byte_order!(prop_i48, i64, ::test::I48_MAX as u64, read_i48, write_i48); + qc_byte_order!(prop_u64, u64, ::core::u64::MAX as u64, read_u64, write_u64); + qc_byte_order!(prop_i64, i64, ::core::i64::MAX as u64, read_i64, write_i64); + qc_byte_order!(prop_f32, f32, ::core::u64::MAX as u64, read_f32, write_f32); + qc_byte_order!(prop_f64, f64, ::core::i64::MAX as u64, read_f64, write_f64); + + #[cfg(byteorder_i128)] + qc_byte_order!(prop_u128, Wi128, 16 + 1, read_u128, write_u128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_i128, Wi128, 16 + 1, read_i128, write_i128); + + qc_byte_order!(prop_uint_1, + u64, calc_max!(super::U64_MAX, 1), 1, read_uint, write_uint); + qc_byte_order!(prop_uint_2, + u64, calc_max!(super::U64_MAX, 2), 2, read_uint, write_uint); + qc_byte_order!(prop_uint_3, + u64, calc_max!(super::U64_MAX, 3), 3, read_uint, write_uint); + qc_byte_order!(prop_uint_4, + u64, calc_max!(super::U64_MAX, 4), 4, read_uint, write_uint); + qc_byte_order!(prop_uint_5, + u64, calc_max!(super::U64_MAX, 5), 5, read_uint, write_uint); + qc_byte_order!(prop_uint_6, + u64, calc_max!(super::U64_MAX, 6), 6, read_uint, write_uint); + qc_byte_order!(prop_uint_7, + u64, calc_max!(super::U64_MAX, 7), 7, read_uint, write_uint); + qc_byte_order!(prop_uint_8, + u64, calc_max!(super::U64_MAX, 8), 8, read_uint, write_uint); + + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_1, + Wi128, 1, 1, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_2, + Wi128, 2, 2, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_3, + Wi128, 3, 3, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_4, + Wi128, 4, 4, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_5, + Wi128, 5, 5, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_6, + Wi128, 6, 6, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_7, + Wi128, 7, 7, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_8, + Wi128, 8, 8, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_9, + Wi128, 9, 9, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_10, + Wi128, 10, 10, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_11, + Wi128, 11, 11, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_12, + Wi128, 12, 12, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_13, + Wi128, 13, 13, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_14, + Wi128, 14, 14, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_15, + Wi128, 15, 15, read_uint128, write_uint128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_uint128_16, + Wi128, 16, 16, read_uint128, write_uint128); + + qc_byte_order!(prop_int_1, + i64, calc_max!(super::I64_MAX, 1), 1, read_int, write_int); + qc_byte_order!(prop_int_2, + i64, calc_max!(super::I64_MAX, 2), 2, read_int, write_int); + qc_byte_order!(prop_int_3, + i64, calc_max!(super::I64_MAX, 3), 3, read_int, write_int); + qc_byte_order!(prop_int_4, + i64, calc_max!(super::I64_MAX, 4), 4, read_int, write_int); + qc_byte_order!(prop_int_5, + i64, calc_max!(super::I64_MAX, 5), 5, read_int, write_int); + qc_byte_order!(prop_int_6, + i64, calc_max!(super::I64_MAX, 6), 6, read_int, write_int); + qc_byte_order!(prop_int_7, + i64, calc_max!(super::I64_MAX, 7), 7, read_int, write_int); + qc_byte_order!(prop_int_8, + i64, calc_max!(super::I64_MAX, 8), 8, read_int, write_int); + + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_1, + Wi128, 1, 1, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_2, + Wi128, 2, 2, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_3, + Wi128, 3, 3, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_4, + Wi128, 4, 4, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_5, + Wi128, 5, 5, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_6, + Wi128, 6, 6, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_7, + Wi128, 7, 7, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_8, + Wi128, 8, 8, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_9, + Wi128, 9, 9, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_10, + Wi128, 10, 10, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_11, + Wi128, 11, 11, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_12, + Wi128, 12, 12, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_13, + Wi128, 13, 13, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_14, + Wi128, 14, 14, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_15, + Wi128, 15, 15, read_int128, write_int128); + #[cfg(byteorder_i128)] + qc_byte_order!(prop_int128_16, + Wi128, 16, 16, read_int128, write_int128); + + + // Test that all of the byte conversion functions panic when given a + // buffer that is too small. + // + // These tests are critical to ensure safety, otherwise we might end up + // with a buffer overflow. + macro_rules! too_small { + ($name:ident, $maximally_small:expr, $zero:expr, + $read:ident, $write:ident) => ( + mod $name { + use {BigEndian, ByteOrder, NativeEndian, LittleEndian}; + + #[test] + #[should_panic] + fn read_big_endian() { + let buf = [0; $maximally_small]; + BigEndian::$read(&buf); + } + + #[test] + #[should_panic] + fn read_little_endian() { + let buf = [0; $maximally_small]; + LittleEndian::$read(&buf); + } + + #[test] + #[should_panic] + fn read_native_endian() { + let buf = [0; $maximally_small]; + NativeEndian::$read(&buf); + } + + #[test] + #[should_panic] + fn write_big_endian() { + let mut buf = [0; $maximally_small]; + BigEndian::$write(&mut buf, $zero); + } + + #[test] + #[should_panic] + fn write_little_endian() { + let mut buf = [0; $maximally_small]; + LittleEndian::$write(&mut buf, $zero); + } + + #[test] + #[should_panic] + fn write_native_endian() { + let mut buf = [0; $maximally_small]; + NativeEndian::$write(&mut buf, $zero); + } + } + ); + ($name:ident, $maximally_small:expr, $read:ident) => ( + mod $name { + use {BigEndian, ByteOrder, NativeEndian, LittleEndian}; + + #[test] + #[should_panic] + fn read_big_endian() { + let buf = [0; $maximally_small]; + BigEndian::$read(&buf, $maximally_small + 1); + } + + #[test] + #[should_panic] + fn read_little_endian() { + let buf = [0; $maximally_small]; + LittleEndian::$read(&buf, $maximally_small + 1); + } + + #[test] + #[should_panic] + fn read_native_endian() { + let buf = [0; $maximally_small]; + NativeEndian::$read(&buf, $maximally_small + 1); + } + } + ); + } + + too_small!(small_u16, 1, 0, read_u16, write_u16); + too_small!(small_i16, 1, 0, read_i16, write_i16); + too_small!(small_u32, 3, 0, read_u32, write_u32); + too_small!(small_i32, 3, 0, read_i32, write_i32); + too_small!(small_u64, 7, 0, read_u64, write_u64); + too_small!(small_i64, 7, 0, read_i64, write_i64); + too_small!(small_f32, 3, 0.0, read_f32, write_f32); + too_small!(small_f64, 7, 0.0, read_f64, write_f64); + #[cfg(byteorder_i128)] + too_small!(small_u128, 15, 0, read_u128, write_u128); + #[cfg(byteorder_i128)] + too_small!(small_i128, 15, 0, read_i128, write_i128); + + too_small!(small_uint_1, 1, read_uint); + too_small!(small_uint_2, 2, read_uint); + too_small!(small_uint_3, 3, read_uint); + too_small!(small_uint_4, 4, read_uint); + too_small!(small_uint_5, 5, read_uint); + too_small!(small_uint_6, 6, read_uint); + too_small!(small_uint_7, 7, read_uint); + + #[cfg(byteorder_i128)] + too_small!(small_uint128_1, 1, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_2, 2, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_3, 3, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_4, 4, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_5, 5, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_6, 6, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_7, 7, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_8, 8, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_9, 9, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_10, 10, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_11, 11, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_12, 12, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_13, 13, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_14, 14, read_uint128); + #[cfg(byteorder_i128)] + too_small!(small_uint128_15, 15, read_uint128); + + too_small!(small_int_1, 1, read_int); + too_small!(small_int_2, 2, read_int); + too_small!(small_int_3, 3, read_int); + too_small!(small_int_4, 4, read_int); + too_small!(small_int_5, 5, read_int); + too_small!(small_int_6, 6, read_int); + too_small!(small_int_7, 7, read_int); + + #[cfg(byteorder_i128)] + too_small!(small_int128_1, 1, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_2, 2, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_3, 3, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_4, 4, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_5, 5, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_6, 6, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_7, 7, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_8, 8, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_9, 9, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_10, 10, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_11, 11, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_12, 12, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_13, 13, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_14, 14, read_int128); + #[cfg(byteorder_i128)] + too_small!(small_int128_15, 15, read_int128); + + // Test that reading/writing slices enforces the correct lengths. + macro_rules! slice_lengths { + ($name:ident, $read:ident, $write:ident, + $num_bytes:expr, $numbers:expr) => { + mod $name { + use {ByteOrder, BigEndian, NativeEndian, LittleEndian}; + + #[test] + #[should_panic] + fn read_big_endian() { + let bytes = [0; $num_bytes]; + let mut numbers = $numbers; + BigEndian::$read(&bytes, &mut numbers); + } + + #[test] + #[should_panic] + fn read_little_endian() { + let bytes = [0; $num_bytes]; + let mut numbers = $numbers; + LittleEndian::$read(&bytes, &mut numbers); + } + + #[test] + #[should_panic] + fn read_native_endian() { + let bytes = [0; $num_bytes]; + let mut numbers = $numbers; + NativeEndian::$read(&bytes, &mut numbers); + } + + #[test] + #[should_panic] + fn write_big_endian() { + let mut bytes = [0; $num_bytes]; + let numbers = $numbers; + BigEndian::$write(&numbers, &mut bytes); + } + + #[test] + #[should_panic] + fn write_little_endian() { + let mut bytes = [0; $num_bytes]; + let numbers = $numbers; + LittleEndian::$write(&numbers, &mut bytes); + } + + #[test] + #[should_panic] + fn write_native_endian() { + let mut bytes = [0; $num_bytes]; + let numbers = $numbers; + NativeEndian::$write(&numbers, &mut bytes); + } + } + } + } + + slice_lengths!( + slice_len_too_small_u16, read_u16_into, write_u16_into, 3, [0, 0]); + slice_lengths!( + slice_len_too_big_u16, read_u16_into, write_u16_into, 5, [0, 0]); + slice_lengths!( + slice_len_too_small_i16, read_i16_into, write_i16_into, 3, [0, 0]); + slice_lengths!( + slice_len_too_big_i16, read_i16_into, write_i16_into, 5, [0, 0]); + + slice_lengths!( + slice_len_too_small_u32, read_u32_into, write_u32_into, 7, [0, 0]); + slice_lengths!( + slice_len_too_big_u32, read_u32_into, write_u32_into, 9, [0, 0]); + slice_lengths!( + slice_len_too_small_i32, read_i32_into, write_i32_into, 7, [0, 0]); + slice_lengths!( + slice_len_too_big_i32, read_i32_into, write_i32_into, 9, [0, 0]); + + slice_lengths!( + slice_len_too_small_u64, read_u64_into, write_u64_into, 15, [0, 0]); + slice_lengths!( + slice_len_too_big_u64, read_u64_into, write_u64_into, 17, [0, 0]); + slice_lengths!( + slice_len_too_small_i64, read_i64_into, write_i64_into, 15, [0, 0]); + slice_lengths!( + slice_len_too_big_i64, read_i64_into, write_i64_into, 17, [0, 0]); + + #[cfg(byteorder_i128)] + slice_lengths!( + slice_len_too_small_u128, read_u128_into, write_u128_into, 31, [0, 0]); + #[cfg(byteorder_i128)] + slice_lengths!( + slice_len_too_big_u128, read_u128_into, write_u128_into, 33, [0, 0]); + #[cfg(byteorder_i128)] + slice_lengths!( + slice_len_too_small_i128, read_i128_into, write_i128_into, 31, [0, 0]); + #[cfg(byteorder_i128)] + slice_lengths!( + slice_len_too_big_i128, read_i128_into, write_i128_into, 33, [0, 0]); + + #[test] + fn uint_bigger_buffer() { + use {ByteOrder, LittleEndian}; + let n = LittleEndian::read_uint(&[1, 2, 3, 4, 5, 6, 7, 8], 5); + assert_eq!(n, 0x0504030201); + } +} + +#[cfg(test)] +#[cfg(feature = "std")] +mod stdtests { + extern crate quickcheck; + extern crate rand; + + use self::quickcheck::{QuickCheck, StdGen, Testable}; + use self::rand::thread_rng; + + fn qc_unsized(f: A) { + + QuickCheck::new() + .gen(StdGen::new(thread_rng(), 16)) + .tests(1_00) + .max_tests(10_000) + .quickcheck(f); + } + + macro_rules! calc_max { + ($max:expr, $bytes:expr) => { ($max - 1) >> (8 * (8 - $bytes)) }; + } + + macro_rules! qc_bytes_ext { + ($name:ident, $ty_int:ty, $max:expr, + $bytes:expr, $read:ident, $write:ident) => ( + mod $name { + use std::io::Cursor; + use { + ReadBytesExt, WriteBytesExt, + BigEndian, NativeEndian, LittleEndian, + }; + #[allow(unused_imports)] use test::{qc_sized, Wi128}; + + #[test] + fn big_endian() { + fn prop(n: $ty_int) -> bool { + let mut wtr = vec![]; + wtr.$write::(n.clone()).unwrap(); + let offset = wtr.len() - $bytes; + let mut rdr = Cursor::new(&mut wtr[offset..]); + n == rdr.$read::($bytes).unwrap() + } + qc_sized(prop as fn($ty_int) -> bool, $max); + } + + #[test] + fn little_endian() { + fn prop(n: $ty_int) -> bool { + let mut wtr = vec![]; + wtr.$write::(n.clone()).unwrap(); + let mut rdr = Cursor::new(wtr); + n == rdr.$read::($bytes).unwrap() + } + qc_sized(prop as fn($ty_int) -> bool, $max); + } + + #[test] + fn native_endian() { + fn prop(n: $ty_int) -> bool { + let mut wtr = vec![]; + wtr.$write::(n.clone()).unwrap(); + let offset = if cfg!(target_endian = "big") { + wtr.len() - $bytes + } else { + 0 + }; + let mut rdr = Cursor::new(&mut wtr[offset..]); + n == rdr.$read::($bytes).unwrap() + } + qc_sized(prop as fn($ty_int) -> bool, $max); + } + } + ); + ($name:ident, $ty_int:ty, $max:expr, $read:ident, $write:ident) => ( + mod $name { + use std::io::Cursor; + use { + ReadBytesExt, WriteBytesExt, + BigEndian, NativeEndian, LittleEndian, + }; + #[allow(unused_imports)] use test::{qc_sized, Wi128}; + + #[test] + fn big_endian() { + fn prop(n: $ty_int) -> bool { + let mut wtr = vec![]; + wtr.$write::(n.clone()).unwrap(); + let mut rdr = Cursor::new(wtr); + n == rdr.$read::().unwrap() + } + qc_sized(prop as fn($ty_int) -> bool, $max - 1); + } + + #[test] + fn little_endian() { + fn prop(n: $ty_int) -> bool { + let mut wtr = vec![]; + wtr.$write::(n.clone()).unwrap(); + let mut rdr = Cursor::new(wtr); + n == rdr.$read::().unwrap() + } + qc_sized(prop as fn($ty_int) -> bool, $max - 1); + } + + #[test] + fn native_endian() { + fn prop(n: $ty_int) -> bool { + let mut wtr = vec![]; + wtr.$write::(n.clone()).unwrap(); + let mut rdr = Cursor::new(wtr); + n == rdr.$read::().unwrap() + } + qc_sized(prop as fn($ty_int) -> bool, $max - 1); + } + } + ); + } + + qc_bytes_ext!(prop_ext_u16, + u16, ::std::u16::MAX as u64, read_u16, write_u16); + qc_bytes_ext!(prop_ext_i16, + i16, ::std::i16::MAX as u64, read_i16, write_i16); + qc_bytes_ext!(prop_ext_u32, + u32, ::std::u32::MAX as u64, read_u32, write_u32); + qc_bytes_ext!(prop_ext_i32, + i32, ::std::i32::MAX as u64, read_i32, write_i32); + qc_bytes_ext!(prop_ext_u64, + u64, ::std::u64::MAX as u64, read_u64, write_u64); + qc_bytes_ext!(prop_ext_i64, + i64, ::std::i64::MAX as u64, read_i64, write_i64); + qc_bytes_ext!(prop_ext_f32, + f32, ::std::u64::MAX as u64, read_f32, write_f32); + qc_bytes_ext!(prop_ext_f64, + f64, ::std::i64::MAX as u64, read_f64, write_f64); + + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_u128, Wi128, 16 + 1, read_u128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_i128, Wi128, 16 + 1, read_i128, write_i128); + + qc_bytes_ext!(prop_ext_uint_1, + u64, calc_max!(::test::U64_MAX, 1), 1, read_uint, write_u64); + qc_bytes_ext!(prop_ext_uint_2, + u64, calc_max!(::test::U64_MAX, 2), 2, read_uint, write_u64); + qc_bytes_ext!(prop_ext_uint_3, + u64, calc_max!(::test::U64_MAX, 3), 3, read_uint, write_u64); + qc_bytes_ext!(prop_ext_uint_4, + u64, calc_max!(::test::U64_MAX, 4), 4, read_uint, write_u64); + qc_bytes_ext!(prop_ext_uint_5, + u64, calc_max!(::test::U64_MAX, 5), 5, read_uint, write_u64); + qc_bytes_ext!(prop_ext_uint_6, + u64, calc_max!(::test::U64_MAX, 6), 6, read_uint, write_u64); + qc_bytes_ext!(prop_ext_uint_7, + u64, calc_max!(::test::U64_MAX, 7), 7, read_uint, write_u64); + qc_bytes_ext!(prop_ext_uint_8, + u64, calc_max!(::test::U64_MAX, 8), 8, read_uint, write_u64); + + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_1, + Wi128, 1, 1, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_2, + Wi128, 2, 2, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_3, + Wi128, 3, 3, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_4, + Wi128, 4, 4, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_5, + Wi128, 5, 5, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_6, + Wi128, 6, 6, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_7, + Wi128, 7, 7, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_8, + Wi128, 8, 8, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_9, + Wi128, 9, 9, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_10, + Wi128, 10, 10, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_11, + Wi128, 11, 11, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_12, + Wi128, 12, 12, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_13, + Wi128, 13, 13, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_14, + Wi128, 14, 14, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_15, + Wi128, 15, 15, read_uint128, write_u128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_uint128_16, + Wi128, 16, 16, read_uint128, write_u128); + + qc_bytes_ext!(prop_ext_int_1, + i64, calc_max!(::test::I64_MAX, 1), 1, read_int, write_i64); + qc_bytes_ext!(prop_ext_int_2, + i64, calc_max!(::test::I64_MAX, 2), 2, read_int, write_i64); + qc_bytes_ext!(prop_ext_int_3, + i64, calc_max!(::test::I64_MAX, 3), 3, read_int, write_i64); + qc_bytes_ext!(prop_ext_int_4, + i64, calc_max!(::test::I64_MAX, 4), 4, read_int, write_i64); + qc_bytes_ext!(prop_ext_int_5, + i64, calc_max!(::test::I64_MAX, 5), 5, read_int, write_i64); + qc_bytes_ext!(prop_ext_int_6, + i64, calc_max!(::test::I64_MAX, 6), 6, read_int, write_i64); + qc_bytes_ext!(prop_ext_int_7, + i64, calc_max!(::test::I64_MAX, 1), 7, read_int, write_i64); + qc_bytes_ext!(prop_ext_int_8, + i64, calc_max!(::test::I64_MAX, 8), 8, read_int, write_i64); + + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_1, + Wi128, 1, 1, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_2, + Wi128, 2, 2, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_3, + Wi128, 3, 3, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_4, + Wi128, 4, 4, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_5, + Wi128, 5, 5, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_6, + Wi128, 6, 6, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_7, + Wi128, 7, 7, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_8, + Wi128, 8, 8, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_9, + Wi128, 9, 9, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_10, + Wi128, 10, 10, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_11, + Wi128, 11, 11, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_12, + Wi128, 12, 12, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_13, + Wi128, 13, 13, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_14, + Wi128, 14, 14, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_15, + Wi128, 15, 15, read_int128, write_i128); + #[cfg(byteorder_i128)] + qc_bytes_ext!(prop_ext_int128_16, + Wi128, 16, 16, read_int128, write_i128); + + // Test slice serialization/deserialization. + macro_rules! qc_slice { + ($name:ident, $ty_int:ty, $read:ident, $write:ident, $zero:expr) => { + mod $name { + use core::mem::size_of; + use {ByteOrder, BigEndian, NativeEndian, LittleEndian}; + use super::qc_unsized; + #[allow(unused_imports)] + use test::Wi128; + + #[test] + fn big_endian() { + #[allow(unused_unsafe)] + fn prop(numbers: Vec<$ty_int>) -> bool { + let numbers: Vec<_> = numbers + .into_iter() + .map(|x| x.clone()) + .collect(); + let num_bytes = size_of::<$ty_int>() * numbers.len(); + let mut bytes = vec![0; num_bytes]; + + BigEndian::$write(&numbers, &mut bytes); + + let mut got = vec![$zero; numbers.len()]; + unsafe { BigEndian::$read(&bytes, &mut got); } + + numbers == got + } + qc_unsized(prop as fn(_) -> bool); + } + + #[test] + fn little_endian() { + #[allow(unused_unsafe)] + fn prop(numbers: Vec<$ty_int>) -> bool { + let numbers: Vec<_> = numbers + .into_iter() + .map(|x| x.clone()) + .collect(); + let num_bytes = size_of::<$ty_int>() * numbers.len(); + let mut bytes = vec![0; num_bytes]; + + LittleEndian::$write(&numbers, &mut bytes); + + let mut got = vec![$zero; numbers.len()]; + unsafe { LittleEndian::$read(&bytes, &mut got); } + + numbers == got + } + qc_unsized(prop as fn(_) -> bool); + } + + #[test] + fn native_endian() { + #[allow(unused_unsafe)] + fn prop(numbers: Vec<$ty_int>) -> bool { + let numbers: Vec<_> = numbers + .into_iter() + .map(|x| x.clone()) + .collect(); + let num_bytes = size_of::<$ty_int>() * numbers.len(); + let mut bytes = vec![0; num_bytes]; + + NativeEndian::$write(&numbers, &mut bytes); + + let mut got = vec![$zero; numbers.len()]; + unsafe { NativeEndian::$read(&bytes, &mut got); } + + numbers == got + } + qc_unsized(prop as fn(_) -> bool); + } + } + } + } + + qc_slice!(prop_slice_u16, u16, read_u16_into, write_u16_into, 0); + qc_slice!(prop_slice_i16, i16, read_i16_into, write_i16_into, 0); + qc_slice!(prop_slice_u32, u32, read_u32_into, write_u32_into, 0); + qc_slice!(prop_slice_i32, i32, read_i32_into, write_i32_into, 0); + qc_slice!(prop_slice_u64, u64, read_u64_into, write_u64_into, 0); + qc_slice!(prop_slice_i64, i64, read_i64_into, write_i64_into, 0); + #[cfg(byteorder_i128)] + qc_slice!( + prop_slice_u128, Wi128, read_u128_into, write_u128_into, 0); + #[cfg(byteorder_i128)] + qc_slice!( + prop_slice_i128, Wi128, read_i128_into, write_i128_into, 0); + + qc_slice!( + prop_slice_f32, f32, read_f32_into, write_f32_into, 0.0); + qc_slice!( + prop_slice_f64, f64, read_f64_into, write_f64_into, 0.0); +} diff --git a/third_party/cargo/vendor/cc-1.0.50/.cargo-checksum.json b/third_party/cargo/vendor/cc-1.0.50/.cargo-checksum.json new file mode 100644 index 0000000..dc902d5 --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"a5de831059d43ce5a823420eae1a8b4d4ab167408c5f4d0db53ba526fa7a9303","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"7184fbdf375a057e673257348f6d7584c0dd11b66318d98f3647f69eb610b097","src/bin/gcc-shim.rs":"b77907875029494b6288841c3aed2e4939ed40708c7f597fca5c9e2570490ca6","src/com.rs":"bcdaf1c28b71e6ef889c6b08d1ce9d7c0761344a677f523bc4c3cd297957f804","src/lib.rs":"081f51f4ab13b32654ae6d674fed4b423c170c5db8cfdab319e9a80db724e0c3","src/registry.rs":"3cc1b5a50879fa751572878ae1d0afbfc960c11665258492754b2c8bccb0ff5d","src/setup_config.rs":"7014103587d3382eac599cb76f016e2609b8140970861b2237982d1db24af265","src/winapi.rs":"ea8b7edbb9ff87957254f465c2334e714c5d6b3b19a8d757c48ea7ca0881c50c","src/windows_registry.rs":"388e79dcf3e84078ae0b086c6cdee9cf9eb7e3ffafdcbf3e2df26163661f5856","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"0a83e858abc4793d9f243fdc211b653a4dc7b909ac00b577acda6a677d23ed47","tests/test.rs":"1605640c9b94a77f48fc92e1dc0485bdf1960da5626e2e00279e4703691656bc"},"package":"95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"} \ No newline at end of file diff --git a/third_party/cargo/vendor/cc-1.0.50/BUILD b/third_party/cargo/vendor/cc-1.0.50/BUILD new file mode 100644 index 0000000..e95b18d --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/BUILD @@ -0,0 +1,65 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "cc", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.0.50", + crate_features = [ + ], +) + +# Unsupported target "cc_env" with type "test" omitted +# Unsupported target "cflags" with type "test" omitted +# Unsupported target "cxxflags" with type "test" omitted +rust_binary( + # Prefix bin name to disambiguate from (probable) collision with lib name + # N.B.: The exact form of this is subject to change. + name = "cargo_bin_gcc_shim", + crate_root = "src/bin/gcc-shim.rs", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + # Binaries get an implicit dependency on their crate's lib + ":cc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.0.50", + crate_features = [ + ], +) + +# Unsupported target "test" with type "test" omitted diff --git a/third_party/cargo/vendor/cc-1.0.50/Cargo.toml b/third_party/cargo/vendor/cc-1.0.50/Cargo.toml new file mode 100644 index 0000000..130ddd3 --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/Cargo.toml @@ -0,0 +1,34 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "cc" +version = "1.0.50" +authors = ["Alex Crichton "] +exclude = ["/.travis.yml", "/appveyor.yml"] +description = "A build-time dependency for Cargo build scripts to assist in invoking the native\nC compiler to compile native C code into a static archive to be linked into Rust\ncode.\n" +homepage = "https://github.com/alexcrichton/cc-rs" +documentation = "https://docs.rs/cc" +readme = "README.md" +keywords = ["build-dependencies"] +categories = ["development-tools::build-utils"] +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/cc-rs" +[dependencies.jobserver] +version = "0.1.16" +optional = true +[dev-dependencies.tempfile] +version = "3" + +[features] +parallel = ["jobserver"] diff --git a/third_party/cargo/vendor/cc-1.0.50/LICENSE-APACHE b/third_party/cargo/vendor/cc-1.0.50/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/cc-1.0.50/LICENSE-MIT b/third_party/cargo/vendor/cc-1.0.50/LICENSE-MIT new file mode 100644 index 0000000..39e0ed6 --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/cc-1.0.50/README.md b/third_party/cargo/vendor/cc-1.0.50/README.md new file mode 100644 index 0000000..68448ac --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/README.md @@ -0,0 +1,194 @@ +# cc-rs + +A library to compile C/C++/assembly into a Rust library/application. + +[Documentation](https://docs.rs/cc) + +A simple library meant to be used as a build dependency with Cargo packages in +order to build a set of C/C++ files into a static archive. This crate calls out +to the most relevant compiler for a platform, for example using `cl` on MSVC. + +> **Note**: this crate was recently renamed from the `gcc` crate, so if you're +> looking for the `gcc` crate you're in the right spot! + +## Using cc-rs + +First, you'll want to both add a build script for your crate (`build.rs`) and +also add this crate to your `Cargo.toml` via: + +```toml +[build-dependencies] +cc = "1.0" +``` + +Next up, you'll want to write a build script like so: + +```rust,no_run +// build.rs + +fn main() { + cc::Build::new() + .file("foo.c") + .file("bar.c") + .compile("foo"); +} +``` + +And that's it! Running `cargo build` should take care of the rest and your Rust +application will now have the C files `foo.c` and `bar.c` compiled into a file +named libfoo.a. You can call the functions in Rust by declaring functions in +your Rust code like so: + +``` +extern { + fn foo_function(); + fn bar_function(); +} + +pub fn call() { + unsafe { + foo_function(); + bar_function(); + } +} + +fn main() { + // ... +} +``` + +## External configuration via environment variables + +To control the programs and flags used for building, the builder can set a +number of different environment variables. + +* `CFLAGS` - a series of space separated flags passed to compilers. Note that + individual flags cannot currently contain spaces, so doing + something like: "-L=foo\ bar" is not possible. +* `CC` - the actual C compiler used. Note that this is used as an exact + executable name, so (for example) no extra flags can be passed inside + this variable, and the builder must ensure that there aren't any + trailing spaces. This compiler must understand the `-c` flag. For + certain `TARGET`s, it also is assumed to know about other flags (most + common is `-fPIC`). +* `AR` - the `ar` (archiver) executable to use to build the static library. +* `CRATE_CC_NO_DEFAULTS` - the default compiler flags may cause conflicts in some cross compiling scenarios. Setting this variable will disable the generation of default compiler flags. + +Each of these variables can also be supplied with certain prefixes and suffixes, +in the following prioritized order: + +1. `_` - for example, `CC_x86_64-unknown-linux-gnu` +2. `_` - for example, `CC_x86_64_unknown_linux_gnu` +3. `_` - for example, `HOST_CC` or `TARGET_CFLAGS` +4. `` - a plain `CC`, `AR` as above. + +If none of these variables exist, cc-rs uses built-in defaults + +In addition to the above optional environment variables, `cc-rs` has some +functions with hard requirements on some variables supplied by [cargo's +build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`, +and `HOST` variables. + +[cargo]: http://doc.crates.io/build-script.html#inputs-to-the-build-script + +## Optional features + +### Parallel + +Currently cc-rs supports parallel compilation (think `make -jN`) but this +feature is turned off by default. To enable cc-rs to compile C/C++ in parallel, +you can change your dependency to: + +```toml +[build-dependencies] +cc = { version = "1.0", features = ["parallel"] } +``` + +By default cc-rs will limit parallelism to `$NUM_JOBS`, or if not present it +will limit it to the number of cpus on the machine. If you are using cargo, +use `-jN` option of `build`, `test` and `run` commands as `$NUM_JOBS` +is supplied by cargo. + +## Compile-time Requirements + +To work properly this crate needs access to a C compiler when the build script +is being run. This crate does not ship a C compiler with it. The compiler +required varies per platform, but there are three broad categories: + +* Unix platforms require `cc` to be the C compiler. This can be found by + installing cc/clang on Linux distributions and Xcode on OSX, for example. +* Windows platforms targeting MSVC (e.g. your target triple ends in `-msvc`) + require `cl.exe` to be available and in `PATH`. This is typically found in + standard Visual Studio installations and the `PATH` can be set up by running + the appropriate developer tools shell. +* Windows platforms targeting MinGW (e.g. your target triple ends in `-gnu`) + require `cc` to be available in `PATH`. We recommend the + [MinGW-w64](http://mingw-w64.org) distribution, which is using the + [Win-builds](http://win-builds.org) installation system. + You may also acquire it via + [MSYS2](http://msys2.github.io), as explained [here][msys2-help]. Make sure + to install the appropriate architecture corresponding to your installation of + rustc. GCC from older [MinGW](http://www.mingw.org) project is compatible + only with 32-bit rust compiler. + +[msys2-help]: http://github.com/rust-lang/rust#building-on-windows + +## C++ support + +`cc-rs` supports C++ libraries compilation by using the `cpp` method on +`Build`: + +```rust,no_run +fn main() { + cc::Build::new() + .cpp(true) // Switch to C++ library compilation. + .file("foo.cpp") + .compile("libfoo.a"); +} +``` + +When using C++ library compilation switch, the `CXX` and `CXXFLAGS` env +variables are used instead of `CC` and `CFLAGS` and the C++ standard library is +linked to the crate target. + +## CUDA C++ support + +`cc-rs` also supports compiling CUDA C++ libraries by using the `cuda` method +on `Build` (currently for GNU/Clang toolchains only): + +```rust,no_run +fn main() { + cc::Build::new() + // Switch to CUDA C++ library compilation using NVCC. + .cuda(true) + // Generate code for Maxwell (GTX 970, 980, 980 Ti, Titan X). + .flag("-gencode").flag("arch=compute_52,code=sm_52") + // Generate code for Maxwell (Jetson TX1). + .flag("-gencode").flag("arch=compute_53,code=sm_53") + // Generate code for Pascal (GTX 1070, 1080, 1080 Ti, Titan Xp). + .flag("-gencode").flag("arch=compute_61,code=sm_61") + // Generate code for Pascal (Tesla P100). + .flag("-gencode").flag("arch=compute_60,code=sm_60") + // Generate code for Pascal (Jetson TX2). + .flag("-gencode").flag("arch=compute_62,code=sm_62") + .file("bar.cu") + .compile("libbar.a"); +} +``` + +## License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in cc-rs by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/cc-1.0.50/src/bin/gcc-shim.rs b/third_party/cargo/vendor/cc-1.0.50/src/bin/gcc-shim.rs new file mode 100644 index 0000000..1731df8 --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/src/bin/gcc-shim.rs @@ -0,0 +1,48 @@ +#![cfg_attr(test, allow(dead_code))] + +use std::env; +use std::fs::File; +use std::io::prelude::*; +use std::path::PathBuf; + +fn main() { + let mut args = env::args(); + let program = args.next().expect("Unexpected empty args"); + + let out_dir = PathBuf::from( + env::var_os("GCCTEST_OUT_DIR").expect(&format!("{}: GCCTEST_OUT_DIR not found", program)), + ); + + // Find the first nonexistent candidate file to which the program's args can be written. + for i in 0.. { + let candidate = &out_dir.join(format!("out{}", i)); + + // If the file exists, commands have already run. Try again. + if candidate.exists() { + continue; + } + + // Create a file and record the args passed to the command. + let mut f = File::create(candidate).expect(&format!( + "{}: can't create candidate: {}", + program, + candidate.to_string_lossy() + )); + for arg in args { + writeln!(f, "{}", arg).expect(&format!( + "{}: can't write to candidate: {}", + program, + candidate.to_string_lossy() + )); + } + break; + } + + // Create a file used by some tests. + let path = &out_dir.join("libfoo.a"); + File::create(path).expect(&format!( + "{}: can't create libfoo.a: {}", + program, + path.to_string_lossy() + )); +} diff --git a/third_party/cargo/vendor/cc-1.0.50/src/com.rs b/third_party/cargo/vendor/cc-1.0.50/src/com.rs new file mode 100644 index 0000000..a5f2afe --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/src/com.rs @@ -0,0 +1,155 @@ +// Copyright © 2017 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] + +use crate::winapi::CoInitializeEx; +use crate::winapi::IUnknown; +use crate::winapi::Interface; +use crate::winapi::BSTR; +use crate::winapi::COINIT_MULTITHREADED; +use crate::winapi::{SysFreeString, SysStringLen}; +use crate::winapi::{HRESULT, S_FALSE, S_OK}; +use std::ffi::{OsStr, OsString}; +use std::mem::forget; +use std::ops::Deref; +use std::os::windows::ffi::{OsStrExt, OsStringExt}; +use std::ptr::null_mut; +use std::slice::from_raw_parts; + +pub fn initialize() -> Result<(), HRESULT> { + let err = unsafe { CoInitializeEx(null_mut(), COINIT_MULTITHREADED) }; + if err != S_OK && err != S_FALSE { + // S_FALSE just means COM is already initialized + return Err(err); + } + Ok(()) +} + +pub struct ComPtr(*mut T) +where + T: Interface; +impl ComPtr +where + T: Interface, +{ + /// Creates a `ComPtr` to wrap a raw pointer. + /// It takes ownership over the pointer which means it does __not__ call `AddRef`. + /// `T` __must__ be a COM interface that inherits from `IUnknown`. + pub unsafe fn from_raw(ptr: *mut T) -> ComPtr { + assert!(!ptr.is_null()); + ComPtr(ptr) + } + /// Casts up the inheritance chain + pub fn up(self) -> ComPtr + where + T: Deref, + U: Interface, + { + ComPtr(self.into_raw() as *mut U) + } + /// Extracts the raw pointer. + /// You are now responsible for releasing it yourself. + pub fn into_raw(self) -> *mut T { + let p = self.0; + forget(self); + p + } + /// For internal use only. + fn as_unknown(&self) -> &IUnknown { + unsafe { &*(self.0 as *mut IUnknown) } + } + /// Performs QueryInterface fun. + pub fn cast(&self) -> Result, i32> + where + U: Interface, + { + let mut obj = null_mut(); + let err = unsafe { self.as_unknown().QueryInterface(&U::uuidof(), &mut obj) }; + if err < 0 { + return Err(err); + } + Ok(unsafe { ComPtr::from_raw(obj as *mut U) }) + } +} +impl Deref for ComPtr +where + T: Interface, +{ + type Target = T; + fn deref(&self) -> &T { + unsafe { &*self.0 } + } +} +impl Clone for ComPtr +where + T: Interface, +{ + fn clone(&self) -> Self { + unsafe { + self.as_unknown().AddRef(); + ComPtr::from_raw(self.0) + } + } +} +impl Drop for ComPtr +where + T: Interface, +{ + fn drop(&mut self) { + unsafe { + self.as_unknown().Release(); + } + } +} +pub struct BStr(BSTR); +impl BStr { + pub unsafe fn from_raw(s: BSTR) -> BStr { + BStr(s) + } + pub fn to_osstring(&self) -> OsString { + let len = unsafe { SysStringLen(self.0) }; + let slice = unsafe { from_raw_parts(self.0, len as usize) }; + OsStringExt::from_wide(slice) + } +} +impl Drop for BStr { + fn drop(&mut self) { + unsafe { SysFreeString(self.0) }; + } +} + +pub trait ToWide { + fn to_wide(&self) -> Vec; + fn to_wide_null(&self) -> Vec; +} +impl ToWide for T +where + T: AsRef, +{ + fn to_wide(&self) -> Vec { + self.as_ref().encode_wide().collect() + } + fn to_wide_null(&self) -> Vec { + self.as_ref().encode_wide().chain(Some(0)).collect() + } +} +pub trait FromWide +where + Self: Sized, +{ + fn from_wide(wide: &[u16]) -> Self; + fn from_wide_null(wide: &[u16]) -> Self { + let len = wide.iter().take_while(|&&c| c != 0).count(); + Self::from_wide(&wide[..len]) + } +} +impl FromWide for OsString { + fn from_wide(wide: &[u16]) -> OsString { + OsStringExt::from_wide(wide) + } +} diff --git a/third_party/cargo/vendor/cc-1.0.50/src/lib.rs b/third_party/cargo/vendor/cc-1.0.50/src/lib.rs new file mode 100644 index 0000000..cc1d58c --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/src/lib.rs @@ -0,0 +1,2673 @@ +//! A library for build scripts to compile custom C code +//! +//! This library is intended to be used as a `build-dependencies` entry in +//! `Cargo.toml`: +//! +//! ```toml +//! [build-dependencies] +//! cc = "1.0" +//! ``` +//! +//! The purpose of this crate is to provide the utility functions necessary to +//! compile C code into a static archive which is then linked into a Rust crate. +//! Configuration is available through the `Build` struct. +//! +//! This crate will automatically detect situations such as cross compilation or +//! other environment variables set by Cargo and will build code appropriately. +//! +//! The crate is not limited to C code, it can accept any source code that can +//! be passed to a C or C++ compiler. As such, assembly files with extensions +//! `.s` (gcc/clang) and `.asm` (MSVC) can also be compiled. +//! +//! [`Build`]: struct.Build.html +//! +//! # Parallelism +//! +//! To parallelize computation, enable the `parallel` feature for the crate. +//! +//! ```toml +//! [build-dependencies] +//! cc = { version = "1.0", features = ["parallel"] } +//! ``` +//! To specify the max number of concurrent compilation jobs, set the `NUM_JOBS` +//! environment variable to the desired amount. +//! +//! Cargo will also set this environment variable when executed with the `-jN` flag. +//! +//! If `NUM_JOBS` is not set, the `RAYON_NUM_THREADS` environment variable can +//! also specify the build parallelism. +//! +//! # Examples +//! +//! Use the `Build` struct to compile `src/foo.c`: +//! +//! ```no_run +//! fn main() { +//! cc::Build::new() +//! .file("src/foo.c") +//! .define("FOO", Some("bar")) +//! .include("src") +//! .compile("foo"); +//! } +//! ``` + +#![doc(html_root_url = "https://docs.rs/cc/1.0")] +#![cfg_attr(test, deny(warnings))] +#![allow(deprecated)] +#![deny(missing_docs)] + +use std::collections::HashMap; +use std::env; +use std::ffi::{OsStr, OsString}; +use std::fmt::{self, Display}; +use std::fs; +use std::io::{self, BufRead, BufReader, Read, Write}; +use std::path::{Path, PathBuf}; +use std::process::{Child, Command, Stdio}; +use std::sync::{Arc, Mutex}; +use std::thread::{self, JoinHandle}; + +// These modules are all glue to support reading the MSVC version from +// the registry and from COM interfaces +#[cfg(windows)] +mod registry; +#[cfg(windows)] +#[macro_use] +mod winapi; +#[cfg(windows)] +mod com; +#[cfg(windows)] +mod setup_config; + +pub mod windows_registry; + +/// A builder for compilation of a native static library. +/// +/// A `Build` is the main type of the `cc` crate and is used to control all the +/// various configuration options and such of a compile. You'll find more +/// documentation on each method itself. +#[derive(Clone, Debug)] +pub struct Build { + include_directories: Vec, + definitions: Vec<(String, Option)>, + objects: Vec, + flags: Vec, + flags_supported: Vec, + known_flag_support_status: Arc>>, + ar_flags: Vec, + no_default_flags: bool, + files: Vec, + cpp: bool, + cpp_link_stdlib: Option>, + cpp_set_stdlib: Option, + cuda: bool, + target: Option, + host: Option, + out_dir: Option, + opt_level: Option, + debug: Option, + force_frame_pointer: Option, + env: Vec<(OsString, OsString)>, + compiler: Option, + archiver: Option, + cargo_metadata: bool, + pic: Option, + use_plt: Option, + static_crt: Option, + shared_flag: Option, + static_flag: Option, + warnings_into_errors: bool, + warnings: Option, + extra_warnings: Option, + env_cache: Arc>>>, +} + +/// Represents the types of errors that may occur while using cc-rs. +#[derive(Clone, Debug)] +enum ErrorKind { + /// Error occurred while performing I/O. + IOError, + /// Invalid architecture supplied. + ArchitectureInvalid, + /// Environment variable not found, with the var in question as extra info. + EnvVarNotFound, + /// Error occurred while using external tools (ie: invocation of compiler). + ToolExecError, + /// Error occurred due to missing external tools. + ToolNotFound, +} + +/// Represents an internal error that occurred, with an explanation. +#[derive(Clone, Debug)] +pub struct Error { + /// Describes the kind of error that occurred. + kind: ErrorKind, + /// More explanation of error that occurred. + message: String, +} + +impl Error { + fn new(kind: ErrorKind, message: &str) -> Error { + Error { + kind: kind, + message: message.to_owned(), + } + } +} + +impl From for Error { + fn from(e: io::Error) -> Error { + Error::new(ErrorKind::IOError, &format!("{}", e)) + } +} + +impl Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}: {}", self.kind, self.message) + } +} + +impl std::error::Error for Error {} + +/// Configuration used to represent an invocation of a C compiler. +/// +/// This can be used to figure out what compiler is in use, what the arguments +/// to it are, and what the environment variables look like for the compiler. +/// This can be used to further configure other build systems (e.g. forward +/// along CC and/or CFLAGS) or the `to_command` method can be used to run the +/// compiler itself. +#[derive(Clone, Debug)] +pub struct Tool { + path: PathBuf, + cc_wrapper_path: Option, + cc_wrapper_args: Vec, + args: Vec, + env: Vec<(OsString, OsString)>, + family: ToolFamily, + cuda: bool, + removed_args: Vec, +} + +/// Represents the family of tools this tool belongs to. +/// +/// Each family of tools differs in how and what arguments they accept. +/// +/// Detection of a family is done on best-effort basis and may not accurately reflect the tool. +#[derive(Copy, Clone, Debug, PartialEq)] +enum ToolFamily { + /// Tool is GNU Compiler Collection-like. + Gnu, + /// Tool is Clang-like. It differs from the GCC in a sense that it accepts superset of flags + /// and its cross-compilation approach is different. + Clang, + /// Tool is the MSVC cl.exe. + Msvc { clang_cl: bool }, +} + +impl ToolFamily { + /// What the flag to request debug info for this family of tools look like + fn add_debug_flags(&self, cmd: &mut Tool) { + match *self { + ToolFamily::Msvc { .. } => { + cmd.push_cc_arg("-Z7".into()); + } + ToolFamily::Gnu | ToolFamily::Clang => { + cmd.push_cc_arg("-g".into()); + } + } + } + + /// What the flag to force frame pointers. + fn add_force_frame_pointer(&self, cmd: &mut Tool) { + match *self { + ToolFamily::Gnu | ToolFamily::Clang => { + cmd.push_cc_arg("-fno-omit-frame-pointer".into()); + } + _ => (), + } + } + + /// What the flags to enable all warnings + fn warnings_flags(&self) -> &'static str { + match *self { + ToolFamily::Msvc { .. } => "-W4", + ToolFamily::Gnu | ToolFamily::Clang => "-Wall", + } + } + + /// What the flags to enable extra warnings + fn extra_warnings_flags(&self) -> Option<&'static str> { + match *self { + ToolFamily::Msvc { .. } => None, + ToolFamily::Gnu | ToolFamily::Clang => Some("-Wextra"), + } + } + + /// What the flag to turn warning into errors + fn warnings_to_errors_flag(&self) -> &'static str { + match *self { + ToolFamily::Msvc { .. } => "-WX", + ToolFamily::Gnu | ToolFamily::Clang => "-Werror", + } + } + + fn verbose_stderr(&self) -> bool { + *self == ToolFamily::Clang + } +} + +/// Represents an object. +/// +/// This is a source file -> object file pair. +#[derive(Clone, Debug)] +struct Object { + src: PathBuf, + dst: PathBuf, +} + +impl Object { + /// Create a new source file -> object file pair. + fn new(src: PathBuf, dst: PathBuf) -> Object { + Object { src: src, dst: dst } + } +} + +impl Build { + /// Construct a new instance of a blank set of configuration. + /// + /// This builder is finished with the [`compile`] function. + /// + /// [`compile`]: struct.Build.html#method.compile + pub fn new() -> Build { + Build { + include_directories: Vec::new(), + definitions: Vec::new(), + objects: Vec::new(), + flags: Vec::new(), + flags_supported: Vec::new(), + known_flag_support_status: Arc::new(Mutex::new(HashMap::new())), + ar_flags: Vec::new(), + no_default_flags: false, + files: Vec::new(), + shared_flag: None, + static_flag: None, + cpp: false, + cpp_link_stdlib: None, + cpp_set_stdlib: None, + cuda: false, + target: None, + host: None, + out_dir: None, + opt_level: None, + debug: None, + force_frame_pointer: None, + env: Vec::new(), + compiler: None, + archiver: None, + cargo_metadata: true, + pic: None, + use_plt: None, + static_crt: None, + warnings: None, + extra_warnings: None, + warnings_into_errors: false, + env_cache: Arc::new(Mutex::new(HashMap::new())), + } + } + + /// Add a directory to the `-I` or include path for headers + /// + /// # Example + /// + /// ```no_run + /// use std::path::Path; + /// + /// let library_path = Path::new("/path/to/library"); + /// + /// cc::Build::new() + /// .file("src/foo.c") + /// .include(library_path) + /// .include("src") + /// .compile("foo"); + /// ``` + pub fn include>(&mut self, dir: P) -> &mut Build { + self.include_directories.push(dir.as_ref().to_path_buf()); + self + } + + /// Specify a `-D` variable with an optional value. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .define("FOO", "BAR") + /// .define("BAZ", None) + /// .compile("foo"); + /// ``` + pub fn define<'a, V: Into>>(&mut self, var: &str, val: V) -> &mut Build { + self.definitions + .push((var.to_string(), val.into().map(|s| s.to_string()))); + self + } + + /// Add an arbitrary object file to link in + pub fn object>(&mut self, obj: P) -> &mut Build { + self.objects.push(obj.as_ref().to_path_buf()); + self + } + + /// Add an arbitrary flag to the invocation of the compiler + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .flag("-ffunction-sections") + /// .compile("foo"); + /// ``` + pub fn flag(&mut self, flag: &str) -> &mut Build { + self.flags.push(flag.to_string()); + self + } + + /// Add an arbitrary flag to the invocation of the compiler + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .file("src/bar.c") + /// .ar_flag("/NODEFAULTLIB:libc.dll") + /// .compile("foo"); + /// ``` + + pub fn ar_flag(&mut self, flag: &str) -> &mut Build { + self.ar_flags.push(flag.to_string()); + self + } + + fn ensure_check_file(&self) -> Result { + let out_dir = self.get_out_dir()?; + let src = if self.cuda { + assert!(self.cpp); + out_dir.join("flag_check.cu") + } else if self.cpp { + out_dir.join("flag_check.cpp") + } else { + out_dir.join("flag_check.c") + }; + + if !src.exists() { + let mut f = fs::File::create(&src)?; + write!(f, "int main(void) {{ return 0; }}")?; + } + + Ok(src) + } + + /// Run the compiler to test if it accepts the given flag. + /// + /// For a convenience method for setting flags conditionally, + /// see `flag_if_supported()`. + /// + /// It may return error if it's unable to run the compilier with a test file + /// (e.g. the compiler is missing or a write to the `out_dir` failed). + /// + /// Note: Once computed, the result of this call is stored in the + /// `known_flag_support` field. If `is_flag_supported(flag)` + /// is called again, the result will be read from the hash table. + pub fn is_flag_supported(&self, flag: &str) -> Result { + let mut known_status = self.known_flag_support_status.lock().unwrap(); + if let Some(is_supported) = known_status.get(flag).cloned() { + return Ok(is_supported); + } + + let out_dir = self.get_out_dir()?; + let src = self.ensure_check_file()?; + let obj = out_dir.join("flag_check"); + let target = self.get_target()?; + let host = self.get_host()?; + let mut cfg = Build::new(); + cfg.flag(flag) + .target(&target) + .opt_level(0) + .host(&host) + .debug(false) + .cpp(self.cpp) + .cuda(self.cuda); + let mut compiler = cfg.try_get_compiler()?; + + // Clang uses stderr for verbose output, which yields a false positive + // result if the CFLAGS/CXXFLAGS include -v to aid in debugging. + if compiler.family.verbose_stderr() { + compiler.remove_arg("-v".into()); + } + + let mut cmd = compiler.to_command(); + let is_arm = target.contains("aarch64") || target.contains("arm"); + command_add_output_file( + &mut cmd, + &obj, + self.cuda, + target.contains("msvc"), + false, + is_arm, + ); + + // We need to explicitly tell msvc not to link and create an exe + // in the root directory of the crate + if target.contains("msvc") && !self.cuda { + cmd.arg("-c"); + } + + cmd.arg(&src); + + let output = cmd.output()?; + let is_supported = output.stderr.is_empty(); + + known_status.insert(flag.to_owned(), is_supported); + Ok(is_supported) + } + + /// Add an arbitrary flag to the invocation of the compiler if it supports it + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .flag_if_supported("-Wlogical-op") // only supported by GCC + /// .flag_if_supported("-Wunreachable-code") // only supported by clang + /// .compile("foo"); + /// ``` + pub fn flag_if_supported(&mut self, flag: &str) -> &mut Build { + self.flags_supported.push(flag.to_string()); + self + } + + /// Set the `-shared` flag. + /// + /// When enabled, the compiler will produce a shared object which can + /// then be linked with other objects to form an executable. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .shared_flag(true) + /// .compile("libfoo.so"); + /// ``` + pub fn shared_flag(&mut self, shared_flag: bool) -> &mut Build { + self.shared_flag = Some(shared_flag); + self + } + + /// Set the `-static` flag. + /// + /// When enabled on systems that support dynamic linking, this prevents + /// linking with the shared libraries. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .shared_flag(true) + /// .static_flag(true) + /// .compile("foo"); + /// ``` + pub fn static_flag(&mut self, static_flag: bool) -> &mut Build { + self.static_flag = Some(static_flag); + self + } + + /// Disables the generation of default compiler flags. The default compiler + /// flags may cause conflicts in some cross compiling scenarios. + /// + /// Setting the `CRATE_CC_NO_DEFAULTS` environment variable has the same + /// effect as setting this to `true`. The presence of the environment + /// variable and the value of `no_default_flags` will be OR'd together. + pub fn no_default_flags(&mut self, no_default_flags: bool) -> &mut Build { + self.no_default_flags = no_default_flags; + self + } + + /// Add a file which will be compiled + pub fn file>(&mut self, p: P) -> &mut Build { + self.files.push(p.as_ref().to_path_buf()); + self + } + + /// Add files which will be compiled + pub fn files
+ +## License + +This project is licensed under either of + +* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) + ([LICENSE-APACHE](LICENSE-APACHE)) + +* [MIT License](https://opensource.org/licenses/MIT) + ([LICENSE-MIT](LICENSE-MIT)) + +at your option. + +## Contributing + +We welcome all people who want to contribute. Please see the [contributing +instructions] for more information. + +[contributing instructions]: CONTRIBUTING.md + +Contributions in any form (issues, pull requests, etc.) to this project +must adhere to Rust's [Code of Conduct]. + +[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. + +[Azure Status]: https://dev.azure.com/rust-lang2/libc/_apis/build/status/rust-lang.libc?branchName=master +[Azure]: https://dev.azure.com/rust-lang2/libc/_build/latest?definitionId=1&branchName=master +[Cirrus CI]: https://cirrus-ci.com/github/rust-lang/libc +[Cirrus CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg +[crates.io]: https://crates.io/crates/libc +[Latest Version]: https://img.shields.io/crates/v/libc.svg +[Documentation]: https://docs.rs/libc/badge.svg +[docs.rs]: https://docs.rs/libc +[License]: https://img.shields.io/crates/l/libc.svg +[docs.master]: https://rust-lang.github.io/libc/#platform-specific-documentation diff --git a/third_party/cargo/vendor/libc-0.2.66/build.rs b/third_party/cargo/vendor/libc-0.2.66/build.rs new file mode 100644 index 0000000..f447c0e --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/build.rs @@ -0,0 +1,144 @@ +use std::env; +use std::process::Command; +use std::str; + +fn main() { + let (rustc_minor_ver, is_nightly) = + rustc_minor_nightly().expect("Failed to get rustc version"); + let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); + let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); + let const_extern_fn_cargo_feature = + env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); + let libc_ci = env::var("LIBC_CI").is_ok(); + + if env::var("CARGO_FEATURE_USE_STD").is_ok() { + println!( + "cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \ + please consider using the `std` cargo feature instead\"" + ); + } + + // The ABI of libc used by libstd is backward compatible with FreeBSD 10. + // The ABI of libc from crates.io is backward compatible with FreeBSD 11. + // + // On CI, we detect the actual FreeBSD version and match its ABI exactly, + // running tests to ensure that the ABI is correct. + match which_freebsd() { + Some(10) if libc_ci || rustc_dep_of_std => { + println!("cargo:rustc-cfg=freebsd10") + } + Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"), + Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"), + Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"), + Some(_) | None => println!("cargo:rustc-cfg=freebsd11"), + } + + // On CI: deny all warnings + if libc_ci { + println!("cargo:rustc-cfg=libc_deny_warnings"); + } + + // Rust >= 1.15 supports private module use: + if rustc_minor_ver >= 15 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_priv_mod_use"); + } + + // Rust >= 1.19 supports unions: + if rustc_minor_ver >= 19 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_union"); + } + + // Rust >= 1.24 supports const mem::size_of: + if rustc_minor_ver >= 24 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_const_size_of"); + } + + // Rust >= 1.25 supports repr(align): + if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature { + println!("cargo:rustc-cfg=libc_align"); + } + + // Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it. + // Otherwise, it defines an incompatible type to retaining + // backwards-compatibility. + if rustc_minor_ver >= 30 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_core_cvoid"); + } + + // Rust >= 1.33 supports repr(packed(N)) + if rustc_minor_ver >= 33 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_packedN"); + } + + // #[thread_local] is currently unstable + if rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_thread_local"); + } + + if const_extern_fn_cargo_feature { + if !is_nightly || rustc_minor_ver < 40 { + panic!("const-extern-fn requires a nightly compiler >= 1.40") + } + println!("cargo:rustc-cfg=libc_const_extern_fn"); + } +} + +fn rustc_minor_nightly() -> Option<(u32, bool)> { + macro_rules! otry { + ($e:expr) => { + match $e { + Some(e) => e, + None => return None, + } + }; + } + + let rustc = otry!(env::var_os("RUSTC")); + let output = otry!(Command::new(rustc).arg("--version").output().ok()); + let version = otry!(str::from_utf8(&output.stdout).ok()); + let mut pieces = version.split('.'); + + if pieces.next() != Some("rustc 1") { + return None; + } + + let minor = pieces.next(); + + // If `rustc` was built from a tarball, its version string + // will have neither a git hash nor a commit date + // (e.g. "rustc 1.39.0"). Treat this case as non-nightly, + // since a nightly build should either come from CI + // or a git checkout + let nightly_raw = otry!(pieces.next()).split('-').nth(1); + let nightly = nightly_raw + .map(|raw| raw.starts_with("dev") || raw.starts_with("nightly")) + .unwrap_or(false); + let minor = otry!(otry!(minor).parse().ok()); + + Some((minor, nightly)) +} + +fn which_freebsd() -> Option { + let output = std::process::Command::new("freebsd-version").output().ok(); + if output.is_none() { + return None; + } + let output = output.unwrap(); + if !output.status.success() { + return None; + } + + let stdout = String::from_utf8(output.stdout).ok(); + if stdout.is_none() { + return None; + } + let stdout = stdout.unwrap(); + + match &stdout { + s if s.starts_with("10") => Some(10), + s if s.starts_with("11") => Some(11), + s if s.starts_with("12") => Some(12), + s if s.starts_with("13") => Some(13), + _ => None, + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/rustfmt.toml b/third_party/cargo/vendor/libc-0.2.66/rustfmt.toml new file mode 100644 index 0000000..7ecc610 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/rustfmt.toml @@ -0,0 +1,3 @@ +max_width = 79 +comment_width = 79 +error_on_line_overflow = true \ No newline at end of file diff --git a/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/aarch64.rs b/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/aarch64.rs new file mode 100644 index 0000000..4caa6d7 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/aarch64.rs @@ -0,0 +1,4 @@ +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type wchar_t = u32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/arm.rs b/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/arm.rs new file mode 100644 index 0000000..eca5360 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/arm.rs @@ -0,0 +1,4 @@ +pub type c_char = u8; +pub type c_long = i32; +pub type c_ulong = u32; +pub type wchar_t = u32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/mod.rs new file mode 100644 index 0000000..b3065d7 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/mod.rs @@ -0,0 +1,374 @@ +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type in_addr_t = u32; +pub type in_port_t = u16; +pub type pthread_key_t = usize; +pub type pthread_t = usize; +pub type sa_family_t = u8; +pub type socklen_t = usize; +pub type time_t = i64; + +s! { + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: ::socklen_t, + pub ai_addr: *mut ::sockaddr, + pub ai_canonname: *mut ::c_char, + pub ai_next: *mut addrinfo, + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct in6_addr { + pub s6_addr: [u8; 16], + } + + pub struct pthread_attr_t { + __detachstate: ::c_int, + __stacksize: usize, + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [::c_char; 0], + } + + pub struct sockaddr_in { + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_storage { + pub ss_family: ::sa_family_t, + __ss_data: [u8; 32], + } +} + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +pub const _SC_NPROCESSORS_ONLN: ::c_int = 52; +pub const _SC_PAGESIZE: ::c_int = 54; + +pub const AF_INET: ::c_int = 1; +pub const AF_INET6: ::c_int = 2; + +pub const EACCES: ::c_int = 2; +pub const EADDRINUSE: ::c_int = 3; +pub const EADDRNOTAVAIL: ::c_int = 4; +pub const EAGAIN: ::c_int = 6; +pub const ECONNABORTED: ::c_int = 13; +pub const ECONNREFUSED: ::c_int = 14; +pub const ECONNRESET: ::c_int = 15; +pub const EEXIST: ::c_int = 20; +pub const EINTR: ::c_int = 27; +pub const EINVAL: ::c_int = 28; +pub const ENOENT: ::c_int = 44; +pub const ENOTCONN: ::c_int = 53; +pub const EPERM: ::c_int = 63; +pub const EPIPE: ::c_int = 64; +pub const ETIMEDOUT: ::c_int = 73; +pub const EWOULDBLOCK: ::c_int = EAGAIN; + +pub const EAI_SYSTEM: ::c_int = 9; + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; + +pub const PTHREAD_STACK_MIN: ::size_t = 1024; + +pub const SOCK_DGRAM: ::c_int = 128; +pub const SOCK_STREAM: ::c_int = 130; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum FILE {} +impl ::Copy for FILE {} +impl ::Clone for FILE { + fn clone(&self) -> FILE { + *self + } +} +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum fpos_t {} // TODO: fill this out with a struct +impl ::Copy for fpos_t {} +impl ::Clone for fpos_t { + fn clone(&self) -> fpos_t { + *self + } +} + +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen( + filename: *const c_char, + mode: *const c_char, + file: *mut FILE, + ) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf( + stream: *mut FILE, + buffer: *mut c_char, + mode: c_int, + size: size_t, + ) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) + -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread( + ptr: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE, + ) -> size_t; + pub fn fwrite( + ptr: *const c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE, + ) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atoi(s: *const c_char) -> c_int; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_long; + pub fn strtoul( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern "C" fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + pub fn getline( + lineptr: *mut *mut c_char, + n: *mut size_t, + stream: *mut FILE, + ) -> ssize_t; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy( + dst: *mut c_char, + src: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat( + s: *mut c_char, + ct: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp( + s1: *const c_char, + s2: *const c_char, + n: size_t, + ) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs( + dest: *mut c_char, + src: *const wchar_t, + n: size_t, + ) -> ::size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memmove( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn abs(i: c_int) -> c_int; + pub fn atof(s: *const c_char) -> c_double; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn arc4random_buf(buf: *const ::c_void, len: ::size_t); + pub fn freeaddrinfo(res: *mut addrinfo); + pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; + pub fn getaddrinfo( + node: *const c_char, + service: *const c_char, + hints: *const addrinfo, + res: *mut *mut addrinfo, + ) -> ::c_int; + pub fn getsockopt( + sockfd: ::c_int, + level: ::c_int, + optname: ::c_int, + optval: *mut ::c_void, + optlen: *mut ::socklen_t, + ) -> ::c_int; + pub fn posix_memalign( + memptr: *mut *mut ::c_void, + align: ::size_t, + size: ::size_t, + ) -> ::c_int; + pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_setstacksize( + attr: *mut ::pthread_attr_t, + stack_size: ::size_t, + ) -> ::c_int; + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; + pub fn pthread_join( + native: ::pthread_t, + value: *mut *mut ::c_void, + ) -> ::c_int; + pub fn pthread_key_create( + key: *mut pthread_key_t, + dtor: ::Option, + ) -> ::c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int; + pub fn pthread_setspecific( + key: pthread_key_t, + value: *const ::c_void, + ) -> ::c_int; + pub fn send( + socket: ::c_int, + buf: *const ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + pub fn sysconf(name: ::c_int) -> ::c_long; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(any(target_arch = "arm"))] { + mod arm; + pub use self::arm::*; + } else if #[cfg(any(target_arch = "x86"))] { + mod x86; + pub use self::x86::*; + } else if #[cfg(any(target_arch = "x86_64"))] { + mod x86_64; + pub use self::x86_64::*; + } else { + // Unknown target_arch + } +} + +cfg_if! { + if #[cfg(libc_core_cvoid)] { + pub use ::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/x86.rs b/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/x86.rs new file mode 100644 index 0000000..2f9f39c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/x86.rs @@ -0,0 +1,4 @@ +pub type c_char = i8; +pub type c_long = i32; +pub type c_ulong = u32; +pub type wchar_t = i32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/x86_64.rs b/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/x86_64.rs new file mode 100644 index 0000000..bb17624 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/cloudabi/x86_64.rs @@ -0,0 +1,4 @@ +pub type c_char = i8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type wchar_t = i32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/fixed_width_ints.rs b/third_party/cargo/vendor/libc-0.2.66/src/fixed_width_ints.rs new file mode 100644 index 0000000..0146408 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/fixed_width_ints.rs @@ -0,0 +1,20 @@ +//! This module contains type aliases for C's fixed-width integer types . +//! +//! These aliases are deprecated: use the Rust types instead. + +#[deprecated(since = "0.2.55", note = "Use i8 instead.")] +pub type int8_t = i8; +#[deprecated(since = "0.2.55", note = "Use i16 instead.")] +pub type int16_t = i16; +#[deprecated(since = "0.2.55", note = "Use i32 instead.")] +pub type int32_t = i32; +#[deprecated(since = "0.2.55", note = "Use i64 instead.")] +pub type int64_t = i64; +#[deprecated(since = "0.2.55", note = "Use u8 instead.")] +pub type uint8_t = u8; +#[deprecated(since = "0.2.55", note = "Use u16 instead.")] +pub type uint16_t = u16; +#[deprecated(since = "0.2.55", note = "Use u32 instead.")] +pub type uint32_t = u32; +#[deprecated(since = "0.2.55", note = "Use u64 instead.")] +pub type uint64_t = u64; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/aarch64.rs b/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/aarch64.rs new file mode 100644 index 0000000..259893c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/aarch64.rs @@ -0,0 +1,66 @@ +pub type c_char = u8; +pub type __u64 = ::c_ulonglong; +pub type wchar_t = u32; +pub type nlink_t = ::c_ulong; +pub type blksize_t = ::c_long; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad0: ::c_ulong, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + __pad1: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_uint; 2], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad0: ::c_ulong, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + __pad1: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_uint; 2], + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong, + } +} + +pub const MINSIGSTKSZ: ::size_t = 6144; +pub const SIGSTKSZ: ::size_t = 12288; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/align.rs new file mode 100644 index 0000000..3409bf0 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/align.rs @@ -0,0 +1,142 @@ +macro_rules! expand_align { + () => { + s! { + #[cfg_attr( + any( + target_pointer_width = "32", + target_arch = "x86_64" + ), + repr(align(4)))] + #[cfg_attr( + not(any( + target_pointer_width = "32", + target_arch = "x86_64" + )), + repr(align(8)))] + pub struct pthread_mutexattr_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct pthread_rwlockattr_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + + s_no_extra_traits! { + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64"))), + repr(align(8)))] + pub struct pthread_mutex_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64"))), + repr(align(8)))] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + #[cfg_attr(target_arch = "x86", + repr(align(4)))] + #[cfg_attr(not(target_arch = "x86"), + repr(align(8)))] + pub struct pthread_cond_t { + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + } + + cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.size + .iter() + .zip(other.size.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_cond_t {} + impl ::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_cond_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + impl ::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + + impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + self.size + .iter() + .zip(other.size.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_mutex_t {} + impl ::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_mutex_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + impl ::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + + impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + self.size + .iter() + .zip(other.size.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_rwlock_t {} + impl ::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_rwlock_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + impl ::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + } + } + }; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/mod.rs new file mode 100644 index 0000000..7d23e67 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/mod.rs @@ -0,0 +1,4571 @@ +//! Definitions found commonly among almost all Unix derivatives +//! +//! More functions and definitions can be found in the more specific modules +//! according to the platform in question. + +// PUB_TYPE + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type locale_t = *mut ::c_void; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type in_addr_t = u32; +pub type in_port_t = u16; +pub type sighandler_t = ::size_t; +pub type cc_t = ::c_uchar; +pub type sa_family_t = u16; +pub type pthread_key_t = ::c_uint; +pub type speed_t = ::c_uint; +pub type tcflag_t = ::c_uint; +pub type clockid_t = ::c_int; +pub type key_t = ::c_int; +pub type id_t = ::c_uint; +pub type useconds_t = u32; +pub type dev_t = u64; +pub type socklen_t = u32; +pub type pthread_t = c_ulong; +pub type mode_t = u32; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; +pub type rlim64_t = u64; +pub type mqd_t = ::c_int; +pub type nfds_t = ::c_ulong; +pub type nl_item = ::c_int; +pub type idtype_t = ::c_uint; +pub type loff_t = ::c_longlong; + +pub type __u8 = ::c_uchar; +pub type __u16 = ::c_ushort; +pub type __s16 = ::c_short; +pub type __u32 = ::c_uint; +pub type __s32 = ::c_int; + +pub type Elf32_Half = u16; +pub type Elf32_Word = u32; +pub type Elf32_Off = u32; +pub type Elf32_Addr = u32; + +pub type Elf64_Half = u16; +pub type Elf64_Word = u32; +pub type Elf64_Off = u64; +pub type Elf64_Addr = u64; +pub type Elf64_Xword = u64; + +pub type clock_t = c_long; +pub type time_t = c_long; +pub type suseconds_t = c_long; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i64; + +pub type shmatt_t = ::c_ulong; +pub type msgqnum_t = ::c_ulong; +pub type msglen_t = ::c_ulong; +pub type fsblkcnt_t = ::c_ulonglong; +pub type fsfilcnt_t = ::c_ulonglong; +pub type rlim_t = ::c_ulonglong; + +pub type c_long = i64; +pub type c_ulong = u64; + +// FIXME: why are these uninhabited types? that seems... wrong? +// Presumably these should be `()` or an `extern type` (when that stabilizes). +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum timezone {} +impl ::Copy for timezone {} +impl ::Clone for timezone { + fn clone(&self) -> timezone { + *self + } +} +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum DIR {} +impl ::Copy for DIR {} +impl ::Clone for DIR { + fn clone(&self) -> DIR { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum fpos64_t {} // TODO: fill this out with a struct +impl ::Copy for fpos64_t {} +impl ::Clone for fpos64_t { + fn clone(&self) -> fpos64_t { + *self + } +} + +// PUB_STRUCT + +s! { + pub struct group { + pub gr_name: *mut ::c_char, + pub gr_passwd: *mut ::c_char, + pub gr_gid: ::gid_t, + pub gr_mem: *mut *mut ::c_char, + } + + pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: ::c_long, + } + + // FIXME: the rlimit and rusage related functions and types don't exist + // within zircon. Are there reasons for keeping them around? + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad1: u32, + pub ru_ixrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad2: u32, + pub ru_idrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad3: u32, + pub ru_isrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad4: u32, + pub ru_minflt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad5: u32, + pub ru_majflt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad6: u32, + pub ru_nswap: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad7: u32, + pub ru_inblock: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad8: u32, + pub ru_oublock: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad9: u32, + pub ru_msgsnd: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad10: u32, + pub ru_msgrcv: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad11: u32, + pub ru_nsignals: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad12: u32, + pub ru_nvcsw: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad13: u32, + pub ru_nivcsw: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad14: u32, + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct in6_addr { + pub s6_addr: [u8; 16], + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: ::c_uint, + } + + pub struct hostent { + pub h_name: *mut ::c_char, + pub h_aliases: *mut *mut ::c_char, + pub h_addrtype: ::c_int, + pub h_length: ::c_int, + pub h_addr_list: *mut *mut ::c_char, + } + + pub struct iovec { + pub iov_base: *mut ::c_void, + pub iov_len: ::size_t, + } + + pub struct pollfd { + pub fd: ::c_int, + pub events: ::c_short, + pub revents: ::c_short, + } + + pub struct winsize { + pub ws_row: ::c_ushort, + pub ws_col: ::c_ushort, + pub ws_xpixel: ::c_ushort, + pub ws_ypixel: ::c_ushort, + } + + pub struct linger { + pub l_onoff: ::c_int, + pub l_linger: ::c_int, + } + + pub struct sigval { + // Actually a union of an int and a void* + pub sival_ptr: *mut ::c_void + } + + // + pub struct itimerval { + pub it_interval: ::timeval, + pub it_value: ::timeval, + } + + // + pub struct tms { + pub tms_utime: ::clock_t, + pub tms_stime: ::clock_t, + pub tms_cutime: ::clock_t, + pub tms_cstime: ::clock_t, + } + + pub struct servent { + pub s_name: *mut ::c_char, + pub s_aliases: *mut *mut ::c_char, + pub s_port: ::c_int, + pub s_proto: *mut ::c_char, + } + + pub struct protoent { + pub p_name: *mut ::c_char, + pub p_aliases: *mut *mut ::c_char, + pub p_proto: ::c_int, + } + + pub struct aiocb { + pub aio_fildes: ::c_int, + pub aio_lio_opcode: ::c_int, + pub aio_reqprio: ::c_int, + pub aio_buf: *mut ::c_void, + pub aio_nbytes: ::size_t, + pub aio_sigevent: ::sigevent, + __td: *mut ::c_void, + __lock: [::c_int; 2], + __err: ::c_int, + __ret: ::ssize_t, + pub aio_offset: off_t, + __next: *mut ::c_void, + __prev: *mut ::c_void, + #[cfg(target_pointer_width = "32")] + __dummy4: [::c_char; 24], + #[cfg(target_pointer_width = "64")] + __dummy4: [::c_char; 16], + } + + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + pub __c_ispeed: ::speed_t, + pub __c_ospeed: ::speed_t, + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct ucred { + pub pid: ::pid_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: socklen_t, + + pub ai_addr: *mut ::sockaddr, + + pub ai_canonname: *mut c_char, + + pub ai_next: *mut addrinfo, + } + + pub struct sockaddr_ll { + pub sll_family: ::c_ushort, + pub sll_protocol: ::c_ushort, + pub sll_ifindex: ::c_int, + pub sll_hatype: ::c_ushort, + pub sll_pkttype: ::c_uchar, + pub sll_halen: ::c_uchar, + pub sll_addr: [::c_uchar; 8] + } + + pub struct fd_set { + fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], + } + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + pub tm_gmtoff: ::c_long, + pub tm_zone: *const ::c_char, + } + + pub struct sched_param { + pub sched_priority: ::c_int, + pub sched_ss_low_priority: ::c_int, + pub sched_ss_repl_period: ::timespec, + pub sched_ss_init_budget: ::timespec, + pub sched_ss_max_repl: ::c_int, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct epoll_event { + pub events: u32, + pub u64: u64, + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct rlimit64 { + pub rlim_cur: rlim64_t, + pub rlim_max: rlim64_t, + } + + pub struct glob_t { + pub gl_pathc: ::size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: ::c_uint, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union + pub ifa_data: *mut ::c_void + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct spwd { + pub sp_namp: *mut ::c_char, + pub sp_pwdp: *mut ::c_char, + pub sp_lstchg: ::c_long, + pub sp_min: ::c_long, + pub sp_max: ::c_long, + pub sp_warn: ::c_long, + pub sp_inact: ::c_long, + pub sp_expire: ::c_long, + pub sp_flag: ::c_ulong, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + #[cfg(target_endian = "little")] + pub f_fsid: ::c_ulong, + #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] + __f_unused: ::c_int, + #[cfg(target_endian = "big")] + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct dqblk { + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curspace: u64, + pub dqb_ihardlimit: u64, + pub dqb_isoftlimit: u64, + pub dqb_curinodes: u64, + pub dqb_btime: u64, + pub dqb_itime: u64, + pub dqb_valid: u32, + } + + pub struct signalfd_siginfo { + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: u16, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: [u8; 28], + } + + pub struct itimerspec { + pub it_interval: ::timespec, + pub it_value: ::timespec, + } + + pub struct fsid_t { + __val: [::c_int; 2], + } + + pub struct cpu_set_t { + #[cfg(all(target_pointer_width = "32", + not(target_arch = "x86_64")))] + bits: [u32; 32], + #[cfg(not(all(target_pointer_width = "32", + not(target_arch = "x86_64"))))] + bits: [u64; 16], + } + + pub struct if_nameindex { + pub if_index: ::c_uint, + pub if_name: *mut ::c_char, + } + + // System V IPC + pub struct msginfo { + pub msgpool: ::c_int, + pub msgmap: ::c_int, + pub msgmax: ::c_int, + pub msgmnb: ::c_int, + pub msgmni: ::c_int, + pub msgssz: ::c_int, + pub msgtql: ::c_int, + pub msgseg: ::c_ushort, + } + + pub struct mmsghdr { + pub msg_hdr: ::msghdr, + pub msg_len: ::c_uint, + } + + pub struct sembuf { + pub sem_num: ::c_ushort, + pub sem_op: ::c_short, + pub sem_flg: ::c_short, + } + + pub struct input_event { + pub time: ::timeval, + pub type_: ::__u16, + pub code: ::__u16, + pub value: ::__s32, + } + + pub struct input_id { + pub bustype: ::__u16, + pub vendor: ::__u16, + pub product: ::__u16, + pub version: ::__u16, + } + + pub struct input_absinfo { + pub value: ::__s32, + pub minimum: ::__s32, + pub maximum: ::__s32, + pub fuzz: ::__s32, + pub flat: ::__s32, + pub resolution: ::__s32, + } + + pub struct input_keymap_entry { + pub flags: ::__u8, + pub len: ::__u8, + pub index: ::__u16, + pub keycode: ::__u32, + pub scancode: [::__u8; 32], + } + + pub struct input_mask { + pub type_: ::__u32, + pub codes_size: ::__u32, + pub codes_ptr: ::__u64, + } + + pub struct ff_replay { + pub length: ::__u16, + pub delay: ::__u16, + } + + pub struct ff_trigger { + pub button: ::__u16, + pub interval: ::__u16, + } + + pub struct ff_envelope { + pub attack_length: ::__u16, + pub attack_level: ::__u16, + pub fade_length: ::__u16, + pub fade_level: ::__u16, + } + + pub struct ff_constant_effect { + pub level: ::__s16, + pub envelope: ff_envelope, + } + + pub struct ff_ramp_effect { + pub start_level: ::__s16, + pub end_level: ::__s16, + pub envelope: ff_envelope, + } + + pub struct ff_condition_effect { + pub right_saturation: ::__u16, + pub left_saturation: ::__u16, + + pub right_coeff: ::__s16, + pub left_coeff: ::__s16, + + pub deadband: ::__u16, + pub center: ::__s16, + } + + pub struct ff_periodic_effect { + pub waveform: ::__u16, + pub period: ::__u16, + pub magnitude: ::__s16, + pub offset: ::__s16, + pub phase: ::__u16, + + pub envelope: ff_envelope, + + pub custom_len: ::__u32, + pub custom_data: *mut ::__s16, + } + + pub struct ff_rumble_effect { + pub strong_magnitude: ::__u16, + pub weak_magnitude: ::__u16, + } + + pub struct ff_effect { + pub type_: ::__u16, + pub id: ::__s16, + pub direction: ::__u16, + pub trigger: ff_trigger, + pub replay: ff_replay, + // FIXME this is actually a union + #[cfg(target_pointer_width = "64")] + pub u: [u64; 4], + #[cfg(target_pointer_width = "32")] + pub u: [u32; 7], + } + + pub struct dl_phdr_info { + #[cfg(target_pointer_width = "64")] + pub dlpi_addr: Elf64_Addr, + #[cfg(target_pointer_width = "32")] + pub dlpi_addr: Elf32_Addr, + + pub dlpi_name: *const ::c_char, + + #[cfg(target_pointer_width = "64")] + pub dlpi_phdr: *const Elf64_Phdr, + #[cfg(target_pointer_width = "32")] + pub dlpi_phdr: *const Elf32_Phdr, + + #[cfg(target_pointer_width = "64")] + pub dlpi_phnum: Elf64_Half, + #[cfg(target_pointer_width = "32")] + pub dlpi_phnum: Elf32_Half, + + pub dlpi_adds: ::c_ulonglong, + pub dlpi_subs: ::c_ulonglong, + pub dlpi_tls_modid: ::size_t, + pub dlpi_tls_data: *mut ::c_void, + } + + pub struct Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, + } + + pub struct Elf64_Phdr { + pub p_type: Elf64_Word, + pub p_flags: Elf64_Word, + pub p_offset: Elf64_Off, + pub p_vaddr: Elf64_Addr, + pub p_paddr: Elf64_Addr, + pub p_filesz: Elf64_Xword, + pub p_memsz: Elf64_Xword, + pub p_align: Elf64_Xword, + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct pthread_attr_t { + __size: [u64; 7] + } + + pub struct sigset_t { + __val: [::c_ulong; 16], + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::c_ulong, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + pub msg_rtime: ::time_t, + pub msg_ctime: ::time_t, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + __pad1: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::socklen_t, + __pad2: ::socklen_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::socklen_t, + pub __pad1: ::c_int, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct sem_t { + __val: [::c_int; 8], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + +s_no_extra_traits! { + pub struct sysinfo { + pub uptime: ::c_ulong, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub __reserved: [::c_char; 256], + } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 108] + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + __ss_align: ::size_t, + __ss_pad2: [u8; 128 - 2 * 8], + } + + pub struct utsname { + pub sysname: [::c_char; 65], + pub nodename: [::c_char; 65], + pub release: [::c_char; 65], + pub version: [::c_char; 65], + pub machine: [::c_char; 65], + pub domainname: [::c_char; 65] + } + + pub struct dirent { + pub d_ino: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct dirent64 { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + // x32 compatibility + // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 + pub struct mq_attr { + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_flags: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_maxmsg: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_msgsize: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_curmsgs: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pad: [i64; 4], + + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_flags: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_maxmsg: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_msgsize: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_curmsgs: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pad: [::c_long; 4], + } + + pub struct sockaddr_nl { + pub nl_family: ::sa_family_t, + nl_pad: ::c_ushort, + pub nl_pid: u32, + pub nl_groups: u32 + } + + pub struct sigevent { + pub sigev_value: ::sigval, + pub sigev_signo: ::c_int, + pub sigev_notify: ::c_int, + pub sigev_notify_function: fn(::sigval), + pub sigev_notify_attributes: *mut pthread_attr_t, + pub __pad: [::c_char; 56 - 3 * 8 /* 8 == sizeof(long) */], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sysinfo { + fn eq(&self, other: &sysinfo) -> bool { + self.uptime == other.uptime + && self.loads == other.loads + && self.totalram == other.totalram + && self.freeram == other.freeram + && self.sharedram == other.sharedram + && self.bufferram == other.bufferram + && self.totalswap == other.totalswap + && self.freeswap == other.freeswap + && self.procs == other.procs + && self.pad == other.pad + && self.totalhigh == other.totalhigh + && self.freehigh == other.freehigh + && self.mem_unit == other.mem_unit + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sysinfo {} + impl ::fmt::Debug for sysinfo { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sysinfo") + .field("uptime", &self.uptime) + .field("loads", &self.loads) + .field("totalram", &self.totalram) + .field("freeram", &self.freeram) + .field("sharedram", &self.sharedram) + .field("bufferram", &self.bufferram) + .field("totalswap", &self.totalswap) + .field("freeswap", &self.freeswap) + .field("procs", &self.procs) + .field("pad", &self.pad) + .field("totalhigh", &self.totalhigh) + .field("freehigh", &self.freehigh) + .field("mem_unit", &self.mem_unit) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } + } + impl ::hash::Hash for sysinfo { + fn hash(&self, state: &mut H) { + self.uptime.hash(state); + self.loads.hash(state); + self.totalram.hash(state); + self.freeram.hash(state); + self.sharedram.hash(state); + self.bufferram.hash(state); + self.totalswap.hash(state); + self.freeswap.hash(state); + self.procs.hash(state); + self.pad.hash(state); + self.totalhigh.hash(state); + self.freehigh.hash(state); + self.mem_unit.hash(state); + self.__reserved.hash(state); + } + } + + impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sockaddr_un {} + impl ::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } + } + impl ::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_family.hash(state); + self.sun_path.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_family == other.ss_family + && self.__ss_align == other.__ss_align + && self + .__ss_pad2 + .iter() + .zip(other.__ss_pad2.iter()) + .all(|(a, b)| a == b) + } + } + impl Eq for sockaddr_storage {} + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_family", &self.ss_family) + .field("__ss_align", &self.__ss_align) + // FIXME: .field("__ss_pad2", &self.__ss_pad2) + .finish() + } + } + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_family.hash(state); + self.__ss_align.hash(state); + self.__ss_pad2.hash(state); + } + } + + impl PartialEq for utsname { + fn eq(&self, other: &utsname) -> bool { + self.sysname + .iter() + .zip(other.sysname.iter()) + .all(|(a,b)| a == b) + && self + .nodename + .iter() + .zip(other.nodename.iter()) + .all(|(a,b)| a == b) + && self + .release + .iter() + .zip(other.release.iter()) + .all(|(a,b)| a == b) + && self + .version + .iter() + .zip(other.version.iter()) + .all(|(a,b)| a == b) + && self + .machine + .iter() + .zip(other.machine.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for utsname {} + impl ::fmt::Debug for utsname { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utsname") + // FIXME: .field("sysname", &self.sysname) + // FIXME: .field("nodename", &self.nodename) + // FIXME: .field("release", &self.release) + // FIXME: .field("version", &self.version) + // FIXME: .field("machine", &self.machine) + .finish() + } + } + impl ::hash::Hash for utsname { + fn hash(&self, state: &mut H) { + self.sysname.hash(state); + self.nodename.hash(state); + self.release.hash(state); + self.version.hash(state); + self.machine.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for dirent64 { + fn eq(&self, other: &dirent64) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent64 {} + impl ::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent64") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + impl ::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for mq_attr { + fn eq(&self, other: &mq_attr) -> bool { + self.mq_flags == other.mq_flags && + self.mq_maxmsg == other.mq_maxmsg && + self.mq_msgsize == other.mq_msgsize && + self.mq_curmsgs == other.mq_curmsgs + } + } + impl Eq for mq_attr {} + impl ::fmt::Debug for mq_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mq_attr") + .field("mq_flags", &self.mq_flags) + .field("mq_maxmsg", &self.mq_maxmsg) + .field("mq_msgsize", &self.mq_msgsize) + .field("mq_curmsgs", &self.mq_curmsgs) + .finish() + } + } + impl ::hash::Hash for mq_attr { + fn hash(&self, state: &mut H) { + self.mq_flags.hash(state); + self.mq_maxmsg.hash(state); + self.mq_msgsize.hash(state); + self.mq_curmsgs.hash(state); + } + } + + impl PartialEq for sockaddr_nl { + fn eq(&self, other: &sockaddr_nl) -> bool { + self.nl_family == other.nl_family && + self.nl_pid == other.nl_pid && + self.nl_groups == other.nl_groups + } + } + impl Eq for sockaddr_nl {} + impl ::fmt::Debug for sockaddr_nl { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_nl") + .field("nl_family", &self.nl_family) + .field("nl_pid", &self.nl_pid) + .field("nl_groups", &self.nl_groups) + .finish() + } + } + impl ::hash::Hash for sockaddr_nl { + fn hash(&self, state: &mut H) { + self.nl_family.hash(state); + self.nl_pid.hash(state); + self.nl_groups.hash(state); + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_value == other.sigev_value + && self.sigev_signo == other.sigev_signo + && self.sigev_notify == other.sigev_notify + && self.sigev_notify_function + == other.sigev_notify_function + && self.sigev_notify_attributes + == other.sigev_notify_attributes + } + } + impl Eq for sigevent {} + impl ::fmt::Debug for sigevent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sigevent") + .field("sigev_value", &self.sigev_value) + .field("sigev_signo", &self.sigev_signo) + .field("sigev_notify", &self.sigev_notify) + .field("sigev_notify_function", &self.sigev_notify_function) + .field("sigev_notify_attributes", + &self.sigev_notify_attributes) + .finish() + } + } + impl ::hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_value.hash(state); + self.sigev_signo.hash(state); + self.sigev_notify.hash(state); + self.sigev_notify_function.hash(state); + self.sigev_notify_attributes.hash(state); + } + } + } +} + +// PUB_CONST + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +pub const SIG_DFL: sighandler_t = 0 as sighandler_t; +pub const SIG_IGN: sighandler_t = 1 as sighandler_t; +pub const SIG_ERR: sighandler_t = !0 as sighandler_t; + +pub const DT_FIFO: u8 = 1; +pub const DT_CHR: u8 = 2; +pub const DT_DIR: u8 = 4; +pub const DT_BLK: u8 = 6; +pub const DT_REG: u8 = 8; +pub const DT_LNK: u8 = 10; +pub const DT_SOCK: u8 = 12; + +pub const FD_CLOEXEC: ::c_int = 0x1; + +pub const USRQUOTA: ::c_int = 0; +pub const GRPQUOTA: ::c_int = 1; + +pub const SIGIOT: ::c_int = 6; + +pub const S_ISUID: ::c_int = 0x800; +pub const S_ISGID: ::c_int = 0x400; +pub const S_ISVTX: ::c_int = 0x200; + +pub const IF_NAMESIZE: ::size_t = 16; + +pub const LOG_EMERG: ::c_int = 0; +pub const LOG_ALERT: ::c_int = 1; +pub const LOG_CRIT: ::c_int = 2; +pub const LOG_ERR: ::c_int = 3; +pub const LOG_WARNING: ::c_int = 4; +pub const LOG_NOTICE: ::c_int = 5; +pub const LOG_INFO: ::c_int = 6; +pub const LOG_DEBUG: ::c_int = 7; + +pub const LOG_KERN: ::c_int = 0; +pub const LOG_USER: ::c_int = 1 << 3; +pub const LOG_MAIL: ::c_int = 2 << 3; +pub const LOG_DAEMON: ::c_int = 3 << 3; +pub const LOG_AUTH: ::c_int = 4 << 3; +pub const LOG_SYSLOG: ::c_int = 5 << 3; +pub const LOG_LPR: ::c_int = 6 << 3; +pub const LOG_NEWS: ::c_int = 7 << 3; +pub const LOG_UUCP: ::c_int = 8 << 3; +pub const LOG_LOCAL0: ::c_int = 16 << 3; +pub const LOG_LOCAL1: ::c_int = 17 << 3; +pub const LOG_LOCAL2: ::c_int = 18 << 3; +pub const LOG_LOCAL3: ::c_int = 19 << 3; +pub const LOG_LOCAL4: ::c_int = 20 << 3; +pub const LOG_LOCAL5: ::c_int = 21 << 3; +pub const LOG_LOCAL6: ::c_int = 22 << 3; +pub const LOG_LOCAL7: ::c_int = 23 << 3; + +pub const LOG_PID: ::c_int = 0x01; +pub const LOG_CONS: ::c_int = 0x02; +pub const LOG_ODELAY: ::c_int = 0x04; +pub const LOG_NDELAY: ::c_int = 0x08; +pub const LOG_NOWAIT: ::c_int = 0x10; + +pub const LOG_PRIMASK: ::c_int = 7; +pub const LOG_FACMASK: ::c_int = 0x3f8; + +pub const PRIO_PROCESS: ::c_int = 0; +pub const PRIO_PGRP: ::c_int = 1; +pub const PRIO_USER: ::c_int = 2; + +pub const PRIO_MIN: ::c_int = -20; +pub const PRIO_MAX: ::c_int = 20; + +pub const IPPROTO_ICMP: ::c_int = 1; +pub const IPPROTO_ICMPV6: ::c_int = 58; +pub const IPPROTO_TCP: ::c_int = 6; +pub const IPPROTO_UDP: ::c_int = 17; +pub const IPPROTO_IP: ::c_int = 0; +pub const IPPROTO_IPV6: ::c_int = 41; + +pub const INADDR_LOOPBACK: in_addr_t = 2130706433; +pub const INADDR_ANY: in_addr_t = 0; +pub const INADDR_BROADCAST: in_addr_t = 4294967295; +pub const INADDR_NONE: in_addr_t = 4294967295; + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 2147483647; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 2; +pub const _IOLBF: ::c_int = 1; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; + +// Linux-specific fcntls +pub const F_SETLEASE: ::c_int = 1024; +pub const F_GETLEASE: ::c_int = 1025; +pub const F_NOTIFY: ::c_int = 1026; +pub const F_CANCELLK: ::c_int = 1029; +pub const F_DUPFD_CLOEXEC: ::c_int = 1030; +pub const F_SETPIPE_SZ: ::c_int = 1031; +pub const F_GETPIPE_SZ: ::c_int = 1032; +pub const F_ADD_SEALS: ::c_int = 1033; +pub const F_GET_SEALS: ::c_int = 1034; + +pub const F_SEAL_SEAL: ::c_int = 0x0001; +pub const F_SEAL_SHRINK: ::c_int = 0x0002; +pub const F_SEAL_GROW: ::c_int = 0x0004; +pub const F_SEAL_WRITE: ::c_int = 0x0008; + +// TODO(#235): Include file sealing fcntls once we have a way to verify them. + +pub const SIGTRAP: ::c_int = 5; + +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; + +pub const CLOCK_REALTIME: ::clockid_t = 0; +pub const CLOCK_MONOTONIC: ::clockid_t = 1; +pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3; +pub const CLOCK_MONOTONIC_RAW: ::clockid_t = 4; +pub const CLOCK_REALTIME_COARSE: ::clockid_t = 5; +pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = 6; +pub const CLOCK_BOOTTIME: ::clockid_t = 7; +pub const CLOCK_REALTIME_ALARM: ::clockid_t = 8; +pub const CLOCK_BOOTTIME_ALARM: ::clockid_t = 9; +// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep +// 2014.) See also musl/mod.rs +// pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; +// pub const CLOCK_TAI: ::clockid_t = 11; +pub const TIMER_ABSTIME: ::c_int = 1; + +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_LOCKS: ::c_int = 10; +pub const RLIMIT_SIGPENDING: ::c_int = 11; +pub const RLIMIT_MSGQUEUE: ::c_int = 12; +pub const RLIMIT_NICE: ::c_int = 13; +pub const RLIMIT_RTPRIO: ::c_int = 14; + +pub const RUSAGE_SELF: ::c_int = 0; + +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; + +pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; + +pub const S_IFIFO: ::mode_t = 4096; +pub const S_IFCHR: ::mode_t = 8192; +pub const S_IFBLK: ::mode_t = 24576; +pub const S_IFDIR: ::mode_t = 16384; +pub const S_IFREG: ::mode_t = 32768; +pub const S_IFLNK: ::mode_t = 40960; +pub const S_IFSOCK: ::mode_t = 49152; +pub const S_IFMT: ::mode_t = 61440; +pub const S_IRWXU: ::mode_t = 448; +pub const S_IXUSR: ::mode_t = 64; +pub const S_IWUSR: ::mode_t = 128; +pub const S_IRUSR: ::mode_t = 256; +pub const S_IRWXG: ::mode_t = 56; +pub const S_IXGRP: ::mode_t = 8; +pub const S_IWGRP: ::mode_t = 16; +pub const S_IRGRP: ::mode_t = 32; +pub const S_IRWXO: ::mode_t = 7; +pub const S_IXOTH: ::mode_t = 1; +pub const S_IWOTH: ::mode_t = 2; +pub const S_IROTH: ::mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const LC_CTYPE: ::c_int = 0; +pub const LC_NUMERIC: ::c_int = 1; +pub const LC_TIME: ::c_int = 2; +pub const LC_COLLATE: ::c_int = 3; +pub const LC_MONETARY: ::c_int = 4; +pub const LC_MESSAGES: ::c_int = 5; +pub const LC_ALL: ::c_int = 6; +pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE); +pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC); +pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME); +pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE); +pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY); +pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES); +// LC_ALL_MASK defined per platform + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +// MS_ flags for msync(2) +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MS_SYNC: ::c_int = 0x0004; + +// MS_ flags for mount(2) +pub const MS_RDONLY: ::c_ulong = 0x01; +pub const MS_NOSUID: ::c_ulong = 0x02; +pub const MS_NODEV: ::c_ulong = 0x04; +pub const MS_NOEXEC: ::c_ulong = 0x08; +pub const MS_SYNCHRONOUS: ::c_ulong = 0x10; +pub const MS_REMOUNT: ::c_ulong = 0x20; +pub const MS_MANDLOCK: ::c_ulong = 0x40; +pub const MS_DIRSYNC: ::c_ulong = 0x80; +pub const MS_NOATIME: ::c_ulong = 0x0400; +pub const MS_NODIRATIME: ::c_ulong = 0x0800; +pub const MS_BIND: ::c_ulong = 0x1000; +pub const MS_MOVE: ::c_ulong = 0x2000; +pub const MS_REC: ::c_ulong = 0x4000; +pub const MS_SILENT: ::c_ulong = 0x8000; +pub const MS_POSIXACL: ::c_ulong = 0x010000; +pub const MS_UNBINDABLE: ::c_ulong = 0x020000; +pub const MS_PRIVATE: ::c_ulong = 0x040000; +pub const MS_SLAVE: ::c_ulong = 0x080000; +pub const MS_SHARED: ::c_ulong = 0x100000; +pub const MS_RELATIME: ::c_ulong = 0x200000; +pub const MS_KERNMOUNT: ::c_ulong = 0x400000; +pub const MS_I_VERSION: ::c_ulong = 0x800000; +pub const MS_STRICTATIME: ::c_ulong = 0x1000000; +pub const MS_ACTIVE: ::c_ulong = 0x40000000; +pub const MS_NOUSER: ::c_ulong = 0x80000000; +pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000; +pub const MS_MGC_MSK: ::c_ulong = 0xffff0000; +pub const MS_RMT_MASK: ::c_ulong = 0x800051; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const EWOULDBLOCK: ::c_int = EAGAIN; + +pub const SCM_RIGHTS: ::c_int = 0x01; +pub const SCM_CREDENTIALS: ::c_int = 0x02; + +pub const PROT_GROWSDOWN: ::c_int = 0x1000000; +pub const PROT_GROWSUP: ::c_int = 0x2000000; + +pub const MAP_TYPE: ::c_int = 0x000f; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_FREE: ::c_int = 8; +pub const MADV_REMOVE: ::c_int = 9; +pub const MADV_DONTFORK: ::c_int = 10; +pub const MADV_DOFORK: ::c_int = 11; +pub const MADV_MERGEABLE: ::c_int = 12; +pub const MADV_UNMERGEABLE: ::c_int = 13; +pub const MADV_HUGEPAGE: ::c_int = 14; +pub const MADV_NOHUGEPAGE: ::c_int = 15; +pub const MADV_DONTDUMP: ::c_int = 16; +pub const MADV_DODUMP: ::c_int = 17; +pub const MADV_HWPOISON: ::c_int = 100; +pub const MADV_SOFT_OFFLINE: ::c_int = 101; + +pub const IFF_UP: ::c_int = 0x1; +pub const IFF_BROADCAST: ::c_int = 0x2; +pub const IFF_DEBUG: ::c_int = 0x4; +pub const IFF_LOOPBACK: ::c_int = 0x8; +pub const IFF_POINTOPOINT: ::c_int = 0x10; +pub const IFF_NOTRAILERS: ::c_int = 0x20; +pub const IFF_RUNNING: ::c_int = 0x40; +pub const IFF_NOARP: ::c_int = 0x80; +pub const IFF_PROMISC: ::c_int = 0x100; +pub const IFF_ALLMULTI: ::c_int = 0x200; +pub const IFF_MASTER: ::c_int = 0x400; +pub const IFF_SLAVE: ::c_int = 0x800; +pub const IFF_MULTICAST: ::c_int = 0x1000; +pub const IFF_PORTSEL: ::c_int = 0x2000; +pub const IFF_AUTOMEDIA: ::c_int = 0x4000; +pub const IFF_DYNAMIC: ::c_int = 0x8000; +pub const IFF_TUN: ::c_int = 0x0001; +pub const IFF_TAP: ::c_int = 0x0002; +pub const IFF_NO_PI: ::c_int = 0x1000; + +pub const SOL_IP: ::c_int = 0; +pub const SOL_TCP: ::c_int = 6; +pub const SOL_UDP: ::c_int = 17; +pub const SOL_IPV6: ::c_int = 41; +pub const SOL_ICMPV6: ::c_int = 58; +pub const SOL_RAW: ::c_int = 255; +pub const SOL_DECNET: ::c_int = 261; +pub const SOL_X25: ::c_int = 262; +pub const SOL_PACKET: ::c_int = 263; +pub const SOL_ATM: ::c_int = 264; +pub const SOL_AAL: ::c_int = 265; +pub const SOL_IRDA: ::c_int = 266; +pub const SOL_NETBEUI: ::c_int = 267; +pub const SOL_LLC: ::c_int = 268; +pub const SOL_DCCP: ::c_int = 269; +pub const SOL_NETLINK: ::c_int = 270; +pub const SOL_TIPC: ::c_int = 271; + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_UNIX: ::c_int = 1; +pub const AF_LOCAL: ::c_int = 1; +pub const AF_INET: ::c_int = 2; +pub const AF_AX25: ::c_int = 3; +pub const AF_IPX: ::c_int = 4; +pub const AF_APPLETALK: ::c_int = 5; +pub const AF_NETROM: ::c_int = 6; +pub const AF_BRIDGE: ::c_int = 7; +pub const AF_ATMPVC: ::c_int = 8; +pub const AF_X25: ::c_int = 9; +pub const AF_INET6: ::c_int = 10; +pub const AF_ROSE: ::c_int = 11; +pub const AF_DECnet: ::c_int = 12; +pub const AF_NETBEUI: ::c_int = 13; +pub const AF_SECURITY: ::c_int = 14; +pub const AF_KEY: ::c_int = 15; +pub const AF_NETLINK: ::c_int = 16; +pub const AF_ROUTE: ::c_int = AF_NETLINK; +pub const AF_PACKET: ::c_int = 17; +pub const AF_ASH: ::c_int = 18; +pub const AF_ECONET: ::c_int = 19; +pub const AF_ATMSVC: ::c_int = 20; +pub const AF_RDS: ::c_int = 21; +pub const AF_SNA: ::c_int = 22; +pub const AF_IRDA: ::c_int = 23; +pub const AF_PPPOX: ::c_int = 24; +pub const AF_WANPIPE: ::c_int = 25; +pub const AF_LLC: ::c_int = 26; +pub const AF_CAN: ::c_int = 29; +pub const AF_TIPC: ::c_int = 30; +pub const AF_BLUETOOTH: ::c_int = 31; +pub const AF_IUCV: ::c_int = 32; +pub const AF_RXRPC: ::c_int = 33; +pub const AF_ISDN: ::c_int = 34; +pub const AF_PHONET: ::c_int = 35; +pub const AF_IEEE802154: ::c_int = 36; +pub const AF_CAIF: ::c_int = 37; +pub const AF_ALG: ::c_int = 38; + +pub const PF_UNSPEC: ::c_int = AF_UNSPEC; +pub const PF_UNIX: ::c_int = AF_UNIX; +pub const PF_LOCAL: ::c_int = AF_LOCAL; +pub const PF_INET: ::c_int = AF_INET; +pub const PF_AX25: ::c_int = AF_AX25; +pub const PF_IPX: ::c_int = AF_IPX; +pub const PF_APPLETALK: ::c_int = AF_APPLETALK; +pub const PF_NETROM: ::c_int = AF_NETROM; +pub const PF_BRIDGE: ::c_int = AF_BRIDGE; +pub const PF_ATMPVC: ::c_int = AF_ATMPVC; +pub const PF_X25: ::c_int = AF_X25; +pub const PF_INET6: ::c_int = AF_INET6; +pub const PF_ROSE: ::c_int = AF_ROSE; +pub const PF_DECnet: ::c_int = AF_DECnet; +pub const PF_NETBEUI: ::c_int = AF_NETBEUI; +pub const PF_SECURITY: ::c_int = AF_SECURITY; +pub const PF_KEY: ::c_int = AF_KEY; +pub const PF_NETLINK: ::c_int = AF_NETLINK; +pub const PF_ROUTE: ::c_int = AF_ROUTE; +pub const PF_PACKET: ::c_int = AF_PACKET; +pub const PF_ASH: ::c_int = AF_ASH; +pub const PF_ECONET: ::c_int = AF_ECONET; +pub const PF_ATMSVC: ::c_int = AF_ATMSVC; +pub const PF_RDS: ::c_int = AF_RDS; +pub const PF_SNA: ::c_int = AF_SNA; +pub const PF_IRDA: ::c_int = AF_IRDA; +pub const PF_PPPOX: ::c_int = AF_PPPOX; +pub const PF_WANPIPE: ::c_int = AF_WANPIPE; +pub const PF_LLC: ::c_int = AF_LLC; +pub const PF_CAN: ::c_int = AF_CAN; +pub const PF_TIPC: ::c_int = AF_TIPC; +pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; +pub const PF_IUCV: ::c_int = AF_IUCV; +pub const PF_RXRPC: ::c_int = AF_RXRPC; +pub const PF_ISDN: ::c_int = AF_ISDN; +pub const PF_PHONET: ::c_int = AF_PHONET; +pub const PF_IEEE802154: ::c_int = AF_IEEE802154; +pub const PF_CAIF: ::c_int = AF_CAIF; +pub const PF_ALG: ::c_int = AF_ALG; + +pub const SOMAXCONN: ::c_int = 128; + +pub const MSG_OOB: ::c_int = 1; +pub const MSG_PEEK: ::c_int = 2; +pub const MSG_DONTROUTE: ::c_int = 4; +pub const MSG_CTRUNC: ::c_int = 8; +pub const MSG_TRUNC: ::c_int = 0x20; +pub const MSG_DONTWAIT: ::c_int = 0x40; +pub const MSG_EOR: ::c_int = 0x80; +pub const MSG_WAITALL: ::c_int = 0x100; +pub const MSG_FIN: ::c_int = 0x200; +pub const MSG_SYN: ::c_int = 0x400; +pub const MSG_CONFIRM: ::c_int = 0x800; +pub const MSG_RST: ::c_int = 0x1000; +pub const MSG_ERRQUEUE: ::c_int = 0x2000; +pub const MSG_NOSIGNAL: ::c_int = 0x4000; +pub const MSG_MORE: ::c_int = 0x8000; +pub const MSG_WAITFORONE: ::c_int = 0x10000; +pub const MSG_FASTOPEN: ::c_int = 0x20000000; +pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000; + +pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; + +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_RDM: ::c_int = 4; +pub const IP_MULTICAST_IF: ::c_int = 32; +pub const IP_MULTICAST_TTL: ::c_int = 33; +pub const IP_MULTICAST_LOOP: ::c_int = 34; +pub const IP_TTL: ::c_int = 2; +pub const IP_HDRINCL: ::c_int = 3; +pub const IP_ADD_MEMBERSHIP: ::c_int = 35; +pub const IP_DROP_MEMBERSHIP: ::c_int = 36; +pub const IP_TRANSPARENT: ::c_int = 19; +pub const IPV6_UNICAST_HOPS: ::c_int = 16; +pub const IPV6_MULTICAST_IF: ::c_int = 17; +pub const IPV6_MULTICAST_HOPS: ::c_int = 18; +pub const IPV6_MULTICAST_LOOP: ::c_int = 19; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; +pub const IPV6_V6ONLY: ::c_int = 26; + +pub const TCP_NODELAY: ::c_int = 1; +pub const TCP_MAXSEG: ::c_int = 2; +pub const TCP_CORK: ::c_int = 3; +pub const TCP_KEEPIDLE: ::c_int = 4; +pub const TCP_KEEPINTVL: ::c_int = 5; +pub const TCP_KEEPCNT: ::c_int = 6; +pub const TCP_SYNCNT: ::c_int = 7; +pub const TCP_LINGER2: ::c_int = 8; +pub const TCP_DEFER_ACCEPT: ::c_int = 9; +pub const TCP_WINDOW_CLAMP: ::c_int = 10; +pub const TCP_INFO: ::c_int = 11; +pub const TCP_QUICKACK: ::c_int = 12; +pub const TCP_CONGESTION: ::c_int = 13; + +pub const SO_DEBUG: ::c_int = 1; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; + +pub const SS_ONSTACK: ::c_int = 1; +pub const SS_DISABLE: ::c_int = 2; + +pub const PATH_MAX: ::c_int = 4096; + +pub const FD_SETSIZE: usize = 1024; + +pub const EPOLLIN: ::c_int = 0x1; +pub const EPOLLPRI: ::c_int = 0x2; +pub const EPOLLOUT: ::c_int = 0x4; +pub const EPOLLRDNORM: ::c_int = 0x40; +pub const EPOLLRDBAND: ::c_int = 0x80; +pub const EPOLLWRNORM: ::c_int = 0x100; +pub const EPOLLWRBAND: ::c_int = 0x200; +pub const EPOLLMSG: ::c_int = 0x400; +pub const EPOLLERR: ::c_int = 0x8; +pub const EPOLLHUP: ::c_int = 0x10; +pub const EPOLLET: ::c_int = 0x80000000; + +pub const EPOLL_CTL_ADD: ::c_int = 1; +pub const EPOLL_CTL_MOD: ::c_int = 3; +pub const EPOLL_CTL_DEL: ::c_int = 2; + +pub const MNT_DETACH: ::c_int = 0x2; +pub const MNT_EXPIRE: ::c_int = 0x4; + +pub const Q_GETFMT: ::c_int = 0x800004; +pub const Q_GETINFO: ::c_int = 0x800005; +pub const Q_SETINFO: ::c_int = 0x800006; +pub const QIF_BLIMITS: u32 = 1; +pub const QIF_SPACE: u32 = 2; +pub const QIF_ILIMITS: u32 = 4; +pub const QIF_INODES: u32 = 8; +pub const QIF_BTIME: u32 = 16; +pub const QIF_ITIME: u32 = 32; +pub const QIF_LIMITS: u32 = 5; +pub const QIF_USAGE: u32 = 10; +pub const QIF_TIMES: u32 = 48; +pub const QIF_ALL: u32 = 63; + +pub const MNT_FORCE: ::c_int = 0x1; + +pub const Q_SYNC: ::c_int = 0x800001; +pub const Q_QUOTAON: ::c_int = 0x800002; +pub const Q_QUOTAOFF: ::c_int = 0x800003; +pub const Q_GETQUOTA: ::c_int = 0x800007; +pub const Q_SETQUOTA: ::c_int = 0x800008; + +pub const TCIOFF: ::c_int = 2; +pub const TCION: ::c_int = 3; +pub const TCOOFF: ::c_int = 0; +pub const TCOON: ::c_int = 1; +pub const TCIFLUSH: ::c_int = 0; +pub const TCOFLUSH: ::c_int = 1; +pub const TCIOFLUSH: ::c_int = 2; +pub const NL0: ::c_int = 0x00000000; +pub const NL1: ::c_int = 0x00000100; +pub const TAB0: ::c_int = 0x00000000; +pub const CR0: ::c_int = 0x00000000; +pub const FF0: ::c_int = 0x00000000; +pub const BS0: ::c_int = 0x00000000; +pub const VT0: ::c_int = 0x00000000; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VLNEXT: usize = 15; +pub const IGNBRK: ::tcflag_t = 0x00000001; +pub const BRKINT: ::tcflag_t = 0x00000002; +pub const IGNPAR: ::tcflag_t = 0x00000004; +pub const PARMRK: ::tcflag_t = 0x00000008; +pub const INPCK: ::tcflag_t = 0x00000010; +pub const ISTRIP: ::tcflag_t = 0x00000020; +pub const INLCR: ::tcflag_t = 0x00000040; +pub const IGNCR: ::tcflag_t = 0x00000080; +pub const ICRNL: ::tcflag_t = 0x00000100; +pub const IXANY: ::tcflag_t = 0x00000800; +pub const IMAXBEL: ::tcflag_t = 0x00002000; +pub const OPOST: ::tcflag_t = 0x1; +pub const CS5: ::tcflag_t = 0x00000000; +pub const CRTSCTS: ::tcflag_t = 0x80000000; +pub const ECHO: ::tcflag_t = 0x00000008; +pub const OCRNL: ::tcflag_t = 0o000010; +pub const ONOCR: ::tcflag_t = 0o000020; +pub const ONLRET: ::tcflag_t = 0o000040; +pub const OFILL: ::tcflag_t = 0o000100; +pub const OFDEL: ::tcflag_t = 0o000200; + +pub const CLONE_VM: ::c_int = 0x100; +pub const CLONE_FS: ::c_int = 0x200; +pub const CLONE_FILES: ::c_int = 0x400; +pub const CLONE_SIGHAND: ::c_int = 0x800; +pub const CLONE_PTRACE: ::c_int = 0x2000; +pub const CLONE_VFORK: ::c_int = 0x4000; +pub const CLONE_PARENT: ::c_int = 0x8000; +pub const CLONE_THREAD: ::c_int = 0x10000; +pub const CLONE_NEWNS: ::c_int = 0x20000; +pub const CLONE_SYSVSEM: ::c_int = 0x40000; +pub const CLONE_SETTLS: ::c_int = 0x80000; +pub const CLONE_PARENT_SETTID: ::c_int = 0x100000; +pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000; +pub const CLONE_DETACHED: ::c_int = 0x400000; +pub const CLONE_UNTRACED: ::c_int = 0x800000; +pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000; +pub const CLONE_NEWUTS: ::c_int = 0x04000000; +pub const CLONE_NEWIPC: ::c_int = 0x08000000; +pub const CLONE_NEWUSER: ::c_int = 0x10000000; +pub const CLONE_NEWPID: ::c_int = 0x20000000; +pub const CLONE_NEWNET: ::c_int = 0x40000000; +pub const CLONE_IO: ::c_int = 0x80000000; +pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; + +pub const WNOHANG: ::c_int = 0x00000001; +pub const WUNTRACED: ::c_int = 0x00000002; +pub const WSTOPPED: ::c_int = WUNTRACED; +pub const WEXITED: ::c_int = 0x00000004; +pub const WCONTINUED: ::c_int = 0x00000008; +pub const WNOWAIT: ::c_int = 0x01000000; + +// ::Options set using PTRACE_SETOPTIONS. +pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001; +pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002; +pub const PTRACE_O_TRACEVFORK: ::c_int = 0x00000004; +pub const PTRACE_O_TRACECLONE: ::c_int = 0x00000008; +pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010; +pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020; +pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040; +pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080; +pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000; +pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000; +pub const PTRACE_O_MASK: ::c_int = 0x003000ff; + +// Wait extended result codes for the above trace options. +pub const PTRACE_EVENT_FORK: ::c_int = 1; +pub const PTRACE_EVENT_VFORK: ::c_int = 2; +pub const PTRACE_EVENT_CLONE: ::c_int = 3; +pub const PTRACE_EVENT_EXEC: ::c_int = 4; +pub const PTRACE_EVENT_VFORK_DONE: ::c_int = 5; +pub const PTRACE_EVENT_EXIT: ::c_int = 6; +pub const PTRACE_EVENT_SECCOMP: ::c_int = 7; +// PTRACE_EVENT_STOP was added to glibc in 2.26 +// pub const PTRACE_EVENT_STOP: ::c_int = 128; + +pub const __WNOTHREAD: ::c_int = 0x20000000; +pub const __WALL: ::c_int = 0x40000000; +pub const __WCLONE: ::c_int = 0x80000000; + +pub const SPLICE_F_MOVE: ::c_uint = 0x01; +pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02; +pub const SPLICE_F_MORE: ::c_uint = 0x04; +pub const SPLICE_F_GIFT: ::c_uint = 0x08; + +pub const RTLD_LOCAL: ::c_int = 0; +pub const RTLD_LAZY: ::c_int = 1; + +pub const POSIX_FADV_NORMAL: ::c_int = 0; +pub const POSIX_FADV_RANDOM: ::c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_FADV_WILLNEED: ::c_int = 3; + +pub const AT_FDCWD: ::c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100; +pub const AT_REMOVEDIR: ::c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; +pub const AT_NO_AUTOMOUNT: ::c_int = 0x800; +pub const AT_EMPTY_PATH: ::c_int = 0x1000; + +pub const LOG_CRON: ::c_int = 9 << 3; +pub const LOG_AUTHPRIV: ::c_int = 10 << 3; +pub const LOG_FTP: ::c_int = 11 << 3; +pub const LOG_PERROR: ::c_int = 0x20; + +pub const PIPE_BUF: usize = 4096; + +pub const SI_LOAD_SHIFT: ::c_uint = 16; + +pub const SIGEV_SIGNAL: ::c_int = 0; +pub const SIGEV_NONE: ::c_int = 1; +pub const SIGEV_THREAD: ::c_int = 2; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + +pub const UTIME_OMIT: c_long = 1073741822; +pub const UTIME_NOW: c_long = 1073741823; + +pub const POLLIN: ::c_short = 0x1; +pub const POLLPRI: ::c_short = 0x2; +pub const POLLOUT: ::c_short = 0x4; +pub const POLLERR: ::c_short = 0x8; +pub const POLLHUP: ::c_short = 0x10; +pub const POLLNVAL: ::c_short = 0x20; +pub const POLLRDNORM: ::c_short = 0x040; +pub const POLLRDBAND: ::c_short = 0x080; + +pub const ABDAY_1: ::nl_item = 0x20000; +pub const ABDAY_2: ::nl_item = 0x20001; +pub const ABDAY_3: ::nl_item = 0x20002; +pub const ABDAY_4: ::nl_item = 0x20003; +pub const ABDAY_5: ::nl_item = 0x20004; +pub const ABDAY_6: ::nl_item = 0x20005; +pub const ABDAY_7: ::nl_item = 0x20006; + +pub const DAY_1: ::nl_item = 0x20007; +pub const DAY_2: ::nl_item = 0x20008; +pub const DAY_3: ::nl_item = 0x20009; +pub const DAY_4: ::nl_item = 0x2000A; +pub const DAY_5: ::nl_item = 0x2000B; +pub const DAY_6: ::nl_item = 0x2000C; +pub const DAY_7: ::nl_item = 0x2000D; + +pub const ABMON_1: ::nl_item = 0x2000E; +pub const ABMON_2: ::nl_item = 0x2000F; +pub const ABMON_3: ::nl_item = 0x20010; +pub const ABMON_4: ::nl_item = 0x20011; +pub const ABMON_5: ::nl_item = 0x20012; +pub const ABMON_6: ::nl_item = 0x20013; +pub const ABMON_7: ::nl_item = 0x20014; +pub const ABMON_8: ::nl_item = 0x20015; +pub const ABMON_9: ::nl_item = 0x20016; +pub const ABMON_10: ::nl_item = 0x20017; +pub const ABMON_11: ::nl_item = 0x20018; +pub const ABMON_12: ::nl_item = 0x20019; + +pub const MON_1: ::nl_item = 0x2001A; +pub const MON_2: ::nl_item = 0x2001B; +pub const MON_3: ::nl_item = 0x2001C; +pub const MON_4: ::nl_item = 0x2001D; +pub const MON_5: ::nl_item = 0x2001E; +pub const MON_6: ::nl_item = 0x2001F; +pub const MON_7: ::nl_item = 0x20020; +pub const MON_8: ::nl_item = 0x20021; +pub const MON_9: ::nl_item = 0x20022; +pub const MON_10: ::nl_item = 0x20023; +pub const MON_11: ::nl_item = 0x20024; +pub const MON_12: ::nl_item = 0x20025; + +pub const AM_STR: ::nl_item = 0x20026; +pub const PM_STR: ::nl_item = 0x20027; + +pub const D_T_FMT: ::nl_item = 0x20028; +pub const D_FMT: ::nl_item = 0x20029; +pub const T_FMT: ::nl_item = 0x2002A; +pub const T_FMT_AMPM: ::nl_item = 0x2002B; + +pub const ERA: ::nl_item = 0x2002C; +pub const ERA_D_FMT: ::nl_item = 0x2002E; +pub const ALT_DIGITS: ::nl_item = 0x2002F; +pub const ERA_D_T_FMT: ::nl_item = 0x20030; +pub const ERA_T_FMT: ::nl_item = 0x20031; + +pub const CODESET: ::nl_item = 14; + +pub const CRNCYSTR: ::nl_item = 0x4000F; + +pub const RUSAGE_THREAD: ::c_int = 1; +pub const RUSAGE_CHILDREN: ::c_int = -1; + +pub const RADIXCHAR: ::nl_item = 0x10000; +pub const THOUSEP: ::nl_item = 0x10001; + +pub const YESEXPR: ::nl_item = 0x50000; +pub const NOEXPR: ::nl_item = 0x50001; +pub const YESSTR: ::nl_item = 0x50002; +pub const NOSTR: ::nl_item = 0x50003; + +pub const FILENAME_MAX: ::c_uint = 4096; +pub const L_tmpnam: ::c_uint = 20; +pub const _PC_LINK_MAX: ::c_int = 0; +pub const _PC_MAX_CANON: ::c_int = 1; +pub const _PC_MAX_INPUT: ::c_int = 2; +pub const _PC_NAME_MAX: ::c_int = 3; +pub const _PC_PATH_MAX: ::c_int = 4; +pub const _PC_PIPE_BUF: ::c_int = 5; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 6; +pub const _PC_NO_TRUNC: ::c_int = 7; +pub const _PC_VDISABLE: ::c_int = 8; +pub const _PC_SYNC_IO: ::c_int = 9; +pub const _PC_ASYNC_IO: ::c_int = 10; +pub const _PC_PRIO_IO: ::c_int = 11; +pub const _PC_SOCK_MAXBUF: ::c_int = 12; +pub const _PC_FILESIZEBITS: ::c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16; +pub const _PC_REC_XFER_ALIGN: ::c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18; +pub const _PC_SYMLINK_MAX: ::c_int = 19; +pub const _PC_2_SYMLINKS: ::c_int = 20; + +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_CHILD_MAX: ::c_int = 1; +pub const _SC_CLK_TCK: ::c_int = 2; +pub const _SC_NGROUPS_MAX: ::c_int = 3; +pub const _SC_OPEN_MAX: ::c_int = 4; +pub const _SC_STREAM_MAX: ::c_int = 5; +pub const _SC_TZNAME_MAX: ::c_int = 6; +pub const _SC_JOB_CONTROL: ::c_int = 7; +pub const _SC_SAVED_IDS: ::c_int = 8; +pub const _SC_REALTIME_SIGNALS: ::c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; +pub const _SC_TIMERS: ::c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; +pub const _SC_PRIORITIZED_IO: ::c_int = 13; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; +pub const _SC_FSYNC: ::c_int = 15; +pub const _SC_MAPPED_FILES: ::c_int = 16; +pub const _SC_MEMLOCK: ::c_int = 17; +pub const _SC_MEMLOCK_RANGE: ::c_int = 18; +pub const _SC_MEMORY_PROTECTION: ::c_int = 19; +pub const _SC_MESSAGE_PASSING: ::c_int = 20; +pub const _SC_SEMAPHORES: ::c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; +pub const _SC_AIO_MAX: ::c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; +pub const _SC_DELAYTIMER_MAX: ::c_int = 26; +pub const _SC_MQ_OPEN_MAX: ::c_int = 27; +pub const _SC_MQ_PRIO_MAX: ::c_int = 28; +pub const _SC_VERSION: ::c_int = 29; +pub const _SC_PAGESIZE: ::c_int = 30; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: ::c_int = 31; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; +pub const _SC_SEM_VALUE_MAX: ::c_int = 33; +pub const _SC_SIGQUEUE_MAX: ::c_int = 34; +pub const _SC_TIMER_MAX: ::c_int = 35; +pub const _SC_BC_BASE_MAX: ::c_int = 36; +pub const _SC_BC_DIM_MAX: ::c_int = 37; +pub const _SC_BC_SCALE_MAX: ::c_int = 38; +pub const _SC_BC_STRING_MAX: ::c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; +pub const _SC_EXPR_NEST_MAX: ::c_int = 42; +pub const _SC_LINE_MAX: ::c_int = 43; +pub const _SC_RE_DUP_MAX: ::c_int = 44; +pub const _SC_2_VERSION: ::c_int = 46; +pub const _SC_2_C_BIND: ::c_int = 47; +pub const _SC_2_C_DEV: ::c_int = 48; +pub const _SC_2_FORT_DEV: ::c_int = 49; +pub const _SC_2_FORT_RUN: ::c_int = 50; +pub const _SC_2_SW_DEV: ::c_int = 51; +pub const _SC_2_LOCALEDEF: ::c_int = 52; +pub const _SC_UIO_MAXIOV: ::c_int = 60; +pub const _SC_IOV_MAX: ::c_int = 60; +pub const _SC_THREADS: ::c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; +pub const _SC_TTY_NAME_MAX: ::c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; +pub const _SC_THREAD_STACK_MIN: ::c_int = 75; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82; +pub const _SC_NPROCESSORS_CONF: ::c_int = 83; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; +pub const _SC_PHYS_PAGES: ::c_int = 85; +pub const _SC_AVPHYS_PAGES: ::c_int = 86; +pub const _SC_ATEXIT_MAX: ::c_int = 87; +pub const _SC_PASS_MAX: ::c_int = 88; +pub const _SC_XOPEN_VERSION: ::c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; +pub const _SC_XOPEN_UNIX: ::c_int = 91; +pub const _SC_XOPEN_CRYPT: ::c_int = 92; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; +pub const _SC_XOPEN_SHM: ::c_int = 94; +pub const _SC_2_CHAR_TERM: ::c_int = 95; +pub const _SC_2_UPE: ::c_int = 97; +pub const _SC_XOPEN_XPG2: ::c_int = 98; +pub const _SC_XOPEN_XPG3: ::c_int = 99; +pub const _SC_XOPEN_XPG4: ::c_int = 100; +pub const _SC_NZERO: ::c_int = 109; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; +pub const _SC_XBS5_LP64_OFF64: ::c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; +pub const _SC_XOPEN_LEGACY: ::c_int = 129; +pub const _SC_XOPEN_REALTIME: ::c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; +pub const _SC_ADVISORY_INFO: ::c_int = 132; +pub const _SC_BARRIERS: ::c_int = 133; +pub const _SC_CLOCK_SELECTION: ::c_int = 137; +pub const _SC_CPUTIME: ::c_int = 138; +pub const _SC_THREAD_CPUTIME: ::c_int = 139; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 149; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 153; +pub const _SC_SPIN_LOCKS: ::c_int = 154; +pub const _SC_REGEXP: ::c_int = 155; +pub const _SC_SHELL: ::c_int = 157; +pub const _SC_SPAWN: ::c_int = 159; +pub const _SC_SPORADIC_SERVER: ::c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161; +pub const _SC_TIMEOUTS: ::c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165; +pub const _SC_2_PBS: ::c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169; +pub const _SC_2_PBS_LOCATE: ::c_int = 170; +pub const _SC_2_PBS_MESSAGE: ::c_int = 171; +pub const _SC_2_PBS_TRACK: ::c_int = 172; +pub const _SC_SYMLOOP_MAX: ::c_int = 173; +pub const _SC_STREAMS: ::c_int = 174; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175; +pub const _SC_V6_ILP32_OFF32: ::c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177; +pub const _SC_V6_LP64_OFF64: ::c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179; +pub const _SC_HOST_NAME_MAX: ::c_int = 180; +pub const _SC_TRACE: ::c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182; +pub const _SC_TRACE_INHERIT: ::c_int = 183; +pub const _SC_TRACE_LOG: ::c_int = 184; +pub const _SC_IPV6: ::c_int = 235; +pub const _SC_RAW_SOCKETS: ::c_int = 236; +pub const _SC_V7_ILP32_OFF32: ::c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238; +pub const _SC_V7_LP64_OFF64: ::c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240; +pub const _SC_SS_REPL_MAX: ::c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242; +pub const _SC_TRACE_NAME_MAX: ::c_int = 243; +pub const _SC_TRACE_SYS_MAX: ::c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245; +pub const _SC_XOPEN_STREAMS: ::c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248; + +pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; + +pub const GLOB_ERR: ::c_int = 1 << 0; +pub const GLOB_MARK: ::c_int = 1 << 1; +pub const GLOB_NOSORT: ::c_int = 1 << 2; +pub const GLOB_DOOFFS: ::c_int = 1 << 3; +pub const GLOB_NOCHECK: ::c_int = 1 << 4; +pub const GLOB_APPEND: ::c_int = 1 << 5; +pub const GLOB_NOESCAPE: ::c_int = 1 << 6; + +pub const GLOB_NOSPACE: ::c_int = 1; +pub const GLOB_ABORTED: ::c_int = 2; +pub const GLOB_NOMATCH: ::c_int = 3; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; + +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; + +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; + +pub const IFF_LOWER_UP: ::c_int = 0x10000; +pub const IFF_DORMANT: ::c_int = 0x20000; +pub const IFF_ECHO: ::c_int = 0x40000; + +pub const ST_RDONLY: ::c_ulong = 1; +pub const ST_NOSUID: ::c_ulong = 2; +pub const ST_NODEV: ::c_ulong = 4; +pub const ST_NOEXEC: ::c_ulong = 8; +pub const ST_SYNCHRONOUS: ::c_ulong = 16; +pub const ST_MANDLOCK: ::c_ulong = 64; +pub const ST_WRITE: ::c_ulong = 128; +pub const ST_APPEND: ::c_ulong = 256; +pub const ST_IMMUTABLE: ::c_ulong = 512; +pub const ST_NOATIME: ::c_ulong = 1024; +pub const ST_NODIRATIME: ::c_ulong = 2048; + +pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void; +pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; +pub const RTLD_NODELETE: ::c_int = 0x1000; +pub const RTLD_NOW: ::c_int = 0x2; + +pub const TCP_MD5SIG: ::c_int = 14; + +align_const! { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], + }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], + }; + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + }; +} +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0; +pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; + +pub const RENAME_NOREPLACE: ::c_int = 1; +pub const RENAME_EXCHANGE: ::c_int = 2; +pub const RENAME_WHITEOUT: ::c_int = 4; + +pub const SCHED_OTHER: ::c_int = 0; +pub const SCHED_FIFO: ::c_int = 1; +pub const SCHED_RR: ::c_int = 2; +pub const SCHED_BATCH: ::c_int = 3; +pub const SCHED_IDLE: ::c_int = 5; + +// netinet/in.h +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// Hop-by-hop option header +pub const IPPROTO_HOPOPTS: ::c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: ::c_int = 2; +/// for compatibility +pub const IPPROTO_IPIP: ::c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// exterior gateway protocol +pub const IPPROTO_EGP: ::c_int = 8; +/// pup +pub const IPPROTO_PUP: ::c_int = 12; +// IPPROTO_UDP defined in src/unix/mod.rs +/// xns idp +pub const IPPROTO_IDP: ::c_int = 22; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: ::c_int = 29; +/// DCCP +pub const IPPROTO_DCCP: ::c_int = 33; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// IP6 routing header +pub const IPPROTO_ROUTING: ::c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: ::c_int = 44; +/// resource reservation +pub const IPPROTO_RSVP: ::c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: ::c_int = 47; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: ::c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: ::c_int = 51; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: ::c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: ::c_int = 60; +pub const IPPROTO_MTP: ::c_int = 92; +pub const IPPROTO_BEETPH: ::c_int = 94; +/// encapsulation header +pub const IPPROTO_ENCAP: ::c_int = 98; +/// Protocol indep. multicast +pub const IPPROTO_PIM: ::c_int = 103; +/// IP Payload Comp. Protocol +pub const IPPROTO_COMP: ::c_int = 108; +/// SCTP +pub const IPPROTO_SCTP: ::c_int = 132; +pub const IPPROTO_MH: ::c_int = 135; +pub const IPPROTO_UDPLITE: ::c_int = 136; +pub const IPPROTO_MPLS: ::c_int = 137; +/// raw IP packet +pub const IPPROTO_RAW: ::c_int = 255; +pub const IPPROTO_MAX: ::c_int = 256; + +pub const AF_IB: ::c_int = 27; +pub const AF_MPLS: ::c_int = 28; +pub const AF_NFC: ::c_int = 39; +pub const AF_VSOCK: ::c_int = 40; +pub const PF_IB: ::c_int = AF_IB; +pub const PF_MPLS: ::c_int = AF_MPLS; +pub const PF_NFC: ::c_int = AF_NFC; +pub const PF_VSOCK: ::c_int = AF_VSOCK; + +// System V IPC +pub const IPC_PRIVATE: ::key_t = 0; + +pub const IPC_CREAT: ::c_int = 0o1000; +pub const IPC_EXCL: ::c_int = 0o2000; +pub const IPC_NOWAIT: ::c_int = 0o4000; + +pub const IPC_RMID: ::c_int = 0; +pub const IPC_SET: ::c_int = 1; +pub const IPC_STAT: ::c_int = 2; +pub const IPC_INFO: ::c_int = 3; +pub const MSG_STAT: ::c_int = 11; +pub const MSG_INFO: ::c_int = 12; + +pub const MSG_NOERROR: ::c_int = 0o10000; +pub const MSG_EXCEPT: ::c_int = 0o20000; +pub const MSG_COPY: ::c_int = 0o40000; + +pub const SHM_R: ::c_int = 0o400; +pub const SHM_W: ::c_int = 0o200; + +pub const SHM_RDONLY: ::c_int = 0o10000; +pub const SHM_RND: ::c_int = 0o20000; +pub const SHM_REMAP: ::c_int = 0o40000; +pub const SHM_EXEC: ::c_int = 0o100000; + +pub const SHM_LOCK: ::c_int = 11; +pub const SHM_UNLOCK: ::c_int = 12; + +pub const SHM_HUGETLB: ::c_int = 0o4000; +pub const SHM_NORESERVE: ::c_int = 0o10000; + +pub const EPOLLRDHUP: ::c_int = 0x2000; +pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; +pub const EPOLLONESHOT: ::c_int = 0x40000000; + +pub const QFMT_VFS_OLD: ::c_int = 1; +pub const QFMT_VFS_V0: ::c_int = 2; +pub const QFMT_VFS_V1: ::c_int = 4; + +pub const EFD_SEMAPHORE: ::c_int = 0x1; + +pub const LOG_NFACILITIES: ::c_int = 24; + +pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t; + +pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32; +pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32; +pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32; +pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32; +pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32; +pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32; +pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32; + +pub const AI_PASSIVE: ::c_int = 0x0001; +pub const AI_CANONNAME: ::c_int = 0x0002; +pub const AI_NUMERICHOST: ::c_int = 0x0004; +pub const AI_V4MAPPED: ::c_int = 0x0008; +pub const AI_ALL: ::c_int = 0x0010; +pub const AI_ADDRCONFIG: ::c_int = 0x0020; + +pub const AI_NUMERICSERV: ::c_int = 0x0400; + +pub const EAI_BADFLAGS: ::c_int = -1; +pub const EAI_NONAME: ::c_int = -2; +pub const EAI_AGAIN: ::c_int = -3; +pub const EAI_FAIL: ::c_int = -4; +pub const EAI_FAMILY: ::c_int = -6; +pub const EAI_SOCKTYPE: ::c_int = -7; +pub const EAI_SERVICE: ::c_int = -8; +pub const EAI_MEMORY: ::c_int = -10; +pub const EAI_OVERFLOW: ::c_int = -12; + +pub const NI_NUMERICHOST: ::c_int = 1; +pub const NI_NUMERICSERV: ::c_int = 2; +pub const NI_NOFQDN: ::c_int = 4; +pub const NI_NAMEREQD: ::c_int = 8; +pub const NI_DGRAM: ::c_int = 16; + +pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1; +pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2; +pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4; + +pub const EAI_SYSTEM: ::c_int = -11; + +pub const AIO_CANCELED: ::c_int = 0; +pub const AIO_NOTCANCELED: ::c_int = 1; +pub const AIO_ALLDONE: ::c_int = 2; +pub const LIO_READ: ::c_int = 0; +pub const LIO_WRITE: ::c_int = 1; +pub const LIO_NOP: ::c_int = 2; +pub const LIO_WAIT: ::c_int = 0; +pub const LIO_NOWAIT: ::c_int = 1; + +pub const MREMAP_MAYMOVE: ::c_int = 1; +pub const MREMAP_FIXED: ::c_int = 2; + +pub const PR_SET_PDEATHSIG: ::c_int = 1; +pub const PR_GET_PDEATHSIG: ::c_int = 2; + +pub const PR_GET_DUMPABLE: ::c_int = 3; +pub const PR_SET_DUMPABLE: ::c_int = 4; + +pub const PR_GET_UNALIGN: ::c_int = 5; +pub const PR_SET_UNALIGN: ::c_int = 6; +pub const PR_UNALIGN_NOPRINT: ::c_int = 1; +pub const PR_UNALIGN_SIGBUS: ::c_int = 2; + +pub const PR_GET_KEEPCAPS: ::c_int = 7; +pub const PR_SET_KEEPCAPS: ::c_int = 8; + +pub const PR_GET_FPEMU: ::c_int = 9; +pub const PR_SET_FPEMU: ::c_int = 10; +pub const PR_FPEMU_NOPRINT: ::c_int = 1; +pub const PR_FPEMU_SIGFPE: ::c_int = 2; + +pub const PR_GET_FPEXC: ::c_int = 11; +pub const PR_SET_FPEXC: ::c_int = 12; +pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80; +pub const PR_FP_EXC_DIV: ::c_int = 0x010000; +pub const PR_FP_EXC_OVF: ::c_int = 0x020000; +pub const PR_FP_EXC_UND: ::c_int = 0x040000; +pub const PR_FP_EXC_RES: ::c_int = 0x080000; +pub const PR_FP_EXC_INV: ::c_int = 0x100000; +pub const PR_FP_EXC_DISABLED: ::c_int = 0; +pub const PR_FP_EXC_NONRECOV: ::c_int = 1; +pub const PR_FP_EXC_ASYNC: ::c_int = 2; +pub const PR_FP_EXC_PRECISE: ::c_int = 3; + +pub const PR_GET_TIMING: ::c_int = 13; +pub const PR_SET_TIMING: ::c_int = 14; +pub const PR_TIMING_STATISTICAL: ::c_int = 0; +pub const PR_TIMING_TIMESTAMP: ::c_int = 1; + +pub const PR_SET_NAME: ::c_int = 15; +pub const PR_GET_NAME: ::c_int = 16; + +pub const PR_GET_ENDIAN: ::c_int = 19; +pub const PR_SET_ENDIAN: ::c_int = 20; +pub const PR_ENDIAN_BIG: ::c_int = 0; +pub const PR_ENDIAN_LITTLE: ::c_int = 1; +pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2; + +pub const PR_GET_SECCOMP: ::c_int = 21; +pub const PR_SET_SECCOMP: ::c_int = 22; + +pub const PR_CAPBSET_READ: ::c_int = 23; +pub const PR_CAPBSET_DROP: ::c_int = 24; + +pub const PR_GET_TSC: ::c_int = 25; +pub const PR_SET_TSC: ::c_int = 26; +pub const PR_TSC_ENABLE: ::c_int = 1; +pub const PR_TSC_SIGSEGV: ::c_int = 2; + +pub const PR_GET_SECUREBITS: ::c_int = 27; +pub const PR_SET_SECUREBITS: ::c_int = 28; + +pub const PR_SET_TIMERSLACK: ::c_int = 29; +pub const PR_GET_TIMERSLACK: ::c_int = 30; + +pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31; +pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32; + +pub const PR_MCE_KILL: ::c_int = 33; +pub const PR_MCE_KILL_CLEAR: ::c_int = 0; +pub const PR_MCE_KILL_SET: ::c_int = 1; + +pub const PR_MCE_KILL_LATE: ::c_int = 0; +pub const PR_MCE_KILL_EARLY: ::c_int = 1; +pub const PR_MCE_KILL_DEFAULT: ::c_int = 2; + +pub const PR_MCE_KILL_GET: ::c_int = 34; + +pub const PR_SET_MM: ::c_int = 35; +pub const PR_SET_MM_START_CODE: ::c_int = 1; +pub const PR_SET_MM_END_CODE: ::c_int = 2; +pub const PR_SET_MM_START_DATA: ::c_int = 3; +pub const PR_SET_MM_END_DATA: ::c_int = 4; +pub const PR_SET_MM_START_STACK: ::c_int = 5; +pub const PR_SET_MM_START_BRK: ::c_int = 6; +pub const PR_SET_MM_BRK: ::c_int = 7; +pub const PR_SET_MM_ARG_START: ::c_int = 8; +pub const PR_SET_MM_ARG_END: ::c_int = 9; +pub const PR_SET_MM_ENV_START: ::c_int = 10; +pub const PR_SET_MM_ENV_END: ::c_int = 11; +pub const PR_SET_MM_AUXV: ::c_int = 12; +pub const PR_SET_MM_EXE_FILE: ::c_int = 13; +pub const PR_SET_MM_MAP: ::c_int = 14; +pub const PR_SET_MM_MAP_SIZE: ::c_int = 15; + +pub const PR_SET_PTRACER: ::c_int = 0x59616d61; + +pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36; +pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37; + +pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38; +pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39; + +pub const PR_GET_TID_ADDRESS: ::c_int = 40; + +pub const PR_SET_THP_DISABLE: ::c_int = 41; +pub const PR_GET_THP_DISABLE: ::c_int = 42; + +pub const PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43; +pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44; + +pub const PR_SET_FP_MODE: ::c_int = 45; +pub const PR_GET_FP_MODE: ::c_int = 46; +pub const PR_FP_MODE_FR: ::c_int = 1 << 0; +pub const PR_FP_MODE_FRE: ::c_int = 1 << 1; + +pub const PR_CAP_AMBIENT: ::c_int = 47; +pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1; +pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2; +pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3; +pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4; + +pub const ITIMER_REAL: ::c_int = 0; +pub const ITIMER_VIRTUAL: ::c_int = 1; +pub const ITIMER_PROF: ::c_int = 2; + +pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC; +pub const TFD_NONBLOCK: ::c_int = O_NONBLOCK; +pub const TFD_TIMER_ABSTIME: ::c_int = 1; + +pub const XATTR_CREATE: ::c_int = 0x1; +pub const XATTR_REPLACE: ::c_int = 0x2; + +pub const _POSIX_VDISABLE: ::cc_t = 0; + +pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; +pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; +pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08; +pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10; +pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20; +pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40; + +// On Linux, libc doesn't define this constant, libattr does instead. +// We still define it for Linux as it's defined by libc on other platforms, +// and it's mentioned in the man pages for getxattr and setxattr. +pub const ENOATTR: ::c_int = ::ENODATA; + +pub const SO_ORIGINAL_DST: ::c_int = 80; +pub const IUTF8: ::tcflag_t = 0x00004000; +pub const CMSPAR: ::tcflag_t = 0o10000000000; + +pub const MFD_CLOEXEC: ::c_uint = 0x0001; +pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002; + +// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has +// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32 +// so we can use that type here to avoid having to cast. +pub const PT_NULL: u32 = 0; +pub const PT_LOAD: u32 = 1; +pub const PT_DYNAMIC: u32 = 2; +pub const PT_INTERP: u32 = 3; +pub const PT_NOTE: u32 = 4; +pub const PT_SHLIB: u32 = 5; +pub const PT_PHDR: u32 = 6; +pub const PT_TLS: u32 = 7; +pub const PT_NUM: u32 = 8; +pub const PT_LOOS: u32 = 0x60000000; +pub const PT_GNU_EH_FRAME: u32 = 0x6474e550; +pub const PT_GNU_STACK: u32 = 0x6474e551; +pub const PT_GNU_RELRO: u32 = 0x6474e552; + +pub const SFD_CLOEXEC: ::c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: ::c_int = 0x00040000; +pub const O_NOATIME: ::c_int = 0x00002000; +pub const O_CLOEXEC: ::c_int = 0x00000100; +pub const O_TMPFILE: ::c_int = 0x00004000; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const BUFSIZ: ::c_uint = 1024; +pub const TMP_MAX: ::c_uint = 10000; +pub const FOPEN_MAX: ::c_uint = 1000; +pub const O_PATH: ::c_int = 0x00400000; +pub const O_EXEC: ::c_int = O_PATH; +pub const O_SEARCH: ::c_int = O_PATH; +pub const O_ACCMODE: ::c_int = (03 | O_SEARCH); +pub const O_NDELAY: ::c_int = O_NONBLOCK; +pub const NI_MAXHOST: ::socklen_t = 255; +pub const PTHREAD_STACK_MIN: ::size_t = 2048; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + +pub const RLIM_INFINITY: ::rlim_t = !0; +pub const RLIMIT_RTTIME: ::c_int = 15; +pub const RLIMIT_NLIMITS: ::c_int = 16; + +pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; + +pub const SOCK_DCCP: ::c_int = 6; +pub const SOCK_PACKET: ::c_int = 10; + +pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; +pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; +pub const TCP_THIN_DUPACK: ::c_int = 17; +pub const TCP_USER_TIMEOUT: ::c_int = 18; +pub const TCP_REPAIR: ::c_int = 19; +pub const TCP_REPAIR_QUEUE: ::c_int = 20; +pub const TCP_QUEUE_SEQ: ::c_int = 21; +pub const TCP_REPAIR_OPTIONS: ::c_int = 22; +pub const TCP_FASTOPEN: ::c_int = 23; +pub const TCP_TIMESTAMP: ::c_int = 24; + +pub const SIGUNUSED: ::c_int = ::SIGSYS; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + +pub const CPU_SETSIZE: ::c_int = 128; + +pub const PTRACE_TRACEME: ::c_int = 0; +pub const PTRACE_PEEKTEXT: ::c_int = 1; +pub const PTRACE_PEEKDATA: ::c_int = 2; +pub const PTRACE_PEEKUSER: ::c_int = 3; +pub const PTRACE_POKETEXT: ::c_int = 4; +pub const PTRACE_POKEDATA: ::c_int = 5; +pub const PTRACE_POKEUSER: ::c_int = 6; +pub const PTRACE_CONT: ::c_int = 7; +pub const PTRACE_KILL: ::c_int = 8; +pub const PTRACE_SINGLESTEP: ::c_int = 9; +pub const PTRACE_GETREGS: ::c_int = 12; +pub const PTRACE_SETREGS: ::c_int = 13; +pub const PTRACE_GETFPREGS: ::c_int = 14; +pub const PTRACE_SETFPREGS: ::c_int = 15; +pub const PTRACE_ATTACH: ::c_int = 16; +pub const PTRACE_DETACH: ::c_int = 17; +pub const PTRACE_GETFPXREGS: ::c_int = 18; +pub const PTRACE_SETFPXREGS: ::c_int = 19; +pub const PTRACE_SYSCALL: ::c_int = 24; +pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; +pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; +pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; +pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; +pub const PTRACE_GETREGSET: ::c_int = 0x4204; +pub const PTRACE_SETREGSET: ::c_int = 0x4205; +pub const PTRACE_SEIZE: ::c_int = 0x4206; +pub const PTRACE_INTERRUPT: ::c_int = 0x4207; +pub const PTRACE_LISTEN: ::c_int = 0x4208; +pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; + +pub const EPOLLWAKEUP: ::c_int = 0x20000000; + +pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK; + +pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCINQ: ::c_int = ::FIONREAD; + +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; + +// TODO(#247) Temporarily musl-specific (available since musl 0.9.12 / Linux +// kernel 3.10). See also notbsd/mod.rs +pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; +pub const CLOCK_TAI: ::clockid_t = 11; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_MARK: ::c_int = 36; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_BUSY_POLL: ::c_int = 46; + +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; + +pub const O_ASYNC: ::c_int = 0x00000400; + +pub const FIOCLEX: ::c_int = 0x5451; +pub const FIONBIO: ::c_int = 0x5421; + +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_MEMLOCK: ::c_int = 8; + +pub const O_APPEND: ::c_int = 0x00100000; +pub const O_CREAT: ::c_int = 0x00010000; +pub const O_EXCL: ::c_int = 0x00020000; +pub const O_NOCTTY: ::c_int = 0x00000200; +pub const O_NONBLOCK: ::c_int = 0x00000010; +pub const O_SYNC: ::c_int = (0x00000040 | O_DSYNC); +pub const O_RSYNC: ::c_int = O_SYNC; +pub const O_DSYNC: ::c_int = 0x00000020; + +pub const SOCK_NONBLOCK: ::c_int = 2048; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_SEQPACKET: ::c_int = 5; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const EMULTIHOP: ::c_int = 72; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const EXTPROC: ::tcflag_t = 0x00010000; + +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_SETOWN: ::c_int = 8; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; + +pub const TCGETS: ::c_int = 0x5401; +pub const TCSETS: ::c_int = 0x5402; +pub const TCSETSW: ::c_int = 0x5403; +pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETA: ::c_int = 0x5405; +pub const TCSETA: ::c_int = 0x5406; +pub const TCSETAW: ::c_int = 0x5407; +pub const TCSETAF: ::c_int = 0x5408; +pub const TCSBRK: ::c_int = 0x5409; +pub const TCXONC: ::c_int = 0x540A; +pub const TCFLSH: ::c_int = 0x540B; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x540F; +pub const TIOCSPGRP: ::c_int = 0x5410; +pub const TIOCOUTQ: ::c_int = 0x5411; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x5413; +pub const TIOCSWINSZ: ::c_int = 0x5414; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x541B; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +pub const O_DIRECTORY: ::c_int = 0x00080000; +pub const O_DIRECT: ::c_int = 0x00000800; +pub const O_LARGEFILE: ::c_int = 0x00001000; +pub const O_NOFOLLOW: ::c_int = 0x00000080; + +// intentionally not public, only used for fd_set +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + const ULONG_SIZE: usize = 32; + } else if #[cfg(target_pointer_width = "64")] { + const ULONG_SIZE: usize = 64; + } else { + // Unknown target_pointer_width + } +} + +// END_PUB_CONST + +f! { + pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return + } + + pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 + } + + pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WIFCONTINUED(status: ::c_int) -> bool { + status == 0xffff + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0x7f + } + + pub fn WIFEXITED(status: ::c_int) -> bool { + (status & 0x7f) == 0 + } + + pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WCOREDUMP(status: ::c_int) -> bool { + (status & 0x80) != 0 + } + + pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { + (cmd << 8) | (type_ & 0x00ff) + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits + = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] |= 1 << offset; + () + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits + = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] &= !(1 << offset); + () + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]); + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + 0 != (cpuset.bits[idx] & (1 << offset)) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.bits == set2.bits + } + + pub fn major(dev: ::dev_t) -> ::c_uint { + let mut major = 0; + major |= (dev & 0x00000000000fff00) >> 8; + major |= (dev & 0xfffff00000000000) >> 32; + major as ::c_uint + } + + pub fn minor(dev: ::dev_t) -> ::c_uint { + let mut minor = 0; + minor |= (dev & 0x00000000000000ff) >> 0; + minor |= (dev & 0x00000ffffff00000) >> 12; + minor as ::c_uint + } + + pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t { + let major = major as ::dev_t; + let minor = minor as ::dev_t; + let mut dev = 0; + dev |= (major & 0x00000fff) << 8; + dev |= (major & 0xfffff000) << 32; + dev |= (minor & 0x000000ff) << 0; + dev |= (minor & 0xffffff00) << 12; + dev + } +} + +// EXTERN_FN + +#[link(name = "c")] +#[link(name = "fdio")] +extern "C" {} + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum FILE {} +impl ::Copy for FILE {} +impl ::Clone for FILE { + fn clone(&self) -> FILE { + *self + } +} +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum fpos_t {} // TODO: fill this out with a struct +impl ::Copy for fpos_t {} +impl ::Clone for fpos_t { + fn clone(&self) -> fpos_t { + *self + } +} + +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen( + filename: *const c_char, + mode: *const c_char, + file: *mut FILE, + ) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf( + stream: *mut FILE, + buffer: *mut c_char, + mode: c_int, + size: size_t, + ) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) + -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread( + ptr: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE, + ) -> size_t; + pub fn fwrite( + ptr: *const c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE, + ) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atoi(s: *const c_char) -> c_int; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_long; + pub fn strtoul( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern "C" fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy( + dst: *mut c_char, + src: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat( + s: *mut c_char, + ct: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs( + dest: *mut c_char, + src: *const wchar_t, + n: size_t, + ) -> ::size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memmove( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn abs(i: c_int) -> c_int; + pub fn atof(s: *const c_char) -> c_double; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn getpwnam(name: *const ::c_char) -> *mut passwd; + pub fn getpwuid(uid: ::uid_t) -> *mut passwd; + + pub fn fprintf( + stream: *mut ::FILE, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn printf(format: *const ::c_char, ...) -> ::c_int; + pub fn snprintf( + s: *mut ::c_char, + n: ::size_t, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int; + pub fn fscanf( + stream: *mut ::FILE, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn scanf(format: *const ::c_char, ...) -> ::c_int; + pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) + -> ::c_int; + pub fn getchar_unlocked() -> ::c_int; + pub fn putchar_unlocked(c: ::c_int) -> ::c_int; + + pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; + pub fn connect( + socket: ::c_int, + address: *const sockaddr, + len: socklen_t, + ) -> ::c_int; + pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; + pub fn accept( + socket: ::c_int, + address: *mut sockaddr, + address_len: *mut socklen_t, + ) -> ::c_int; + pub fn getpeername( + socket: ::c_int, + address: *mut sockaddr, + address_len: *mut socklen_t, + ) -> ::c_int; + pub fn getsockname( + socket: ::c_int, + address: *mut sockaddr, + address_len: *mut socklen_t, + ) -> ::c_int; + pub fn setsockopt( + socket: ::c_int, + level: ::c_int, + name: ::c_int, + value: *const ::c_void, + option_len: socklen_t, + ) -> ::c_int; + pub fn socketpair( + domain: ::c_int, + type_: ::c_int, + protocol: ::c_int, + socket_vector: *mut ::c_int, + ) -> ::c_int; + pub fn sendto( + socket: ::c_int, + buf: *const ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *const sockaddr, + addrlen: socklen_t, + ) -> ::ssize_t; + pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int; + + pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int; + pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int; + + pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; + + pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int; + + pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; + + pub fn pclose(stream: *mut ::FILE) -> ::c_int; + pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; + pub fn fileno(stream: *mut ::FILE) -> ::c_int; + + pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; + pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; + + pub fn opendir(dirname: *const c_char) -> *mut ::DIR; + pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent; + pub fn readdir_r( + dirp: *mut ::DIR, + entry: *mut ::dirent, + result: *mut *mut ::dirent, + ) -> ::c_int; + pub fn closedir(dirp: *mut ::DIR) -> ::c_int; + pub fn rewinddir(dirp: *mut ::DIR); + + pub fn openat( + dirfd: ::c_int, + pathname: *const ::c_char, + flags: ::c_int, + ... + ) -> ::c_int; + pub fn fchmodat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + flags: ::c_int, + ) -> ::c_int; + pub fn fchown(fd: ::c_int, owner: ::uid_t, group: ::gid_t) -> ::c_int; + pub fn fchownat( + dirfd: ::c_int, + pathname: *const ::c_char, + owner: ::uid_t, + group: ::gid_t, + flags: ::c_int, + ) -> ::c_int; + pub fn fstatat( + dirfd: ::c_int, + pathname: *const ::c_char, + buf: *mut stat, + flags: ::c_int, + ) -> ::c_int; + pub fn linkat( + olddirfd: ::c_int, + oldpath: *const ::c_char, + newdirfd: ::c_int, + newpath: *const ::c_char, + flags: ::c_int, + ) -> ::c_int; + pub fn mkdirat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + ) -> ::c_int; + pub fn readlinkat( + dirfd: ::c_int, + pathname: *const ::c_char, + buf: *mut ::c_char, + bufsiz: ::size_t, + ) -> ::ssize_t; + pub fn renameat( + olddirfd: ::c_int, + oldpath: *const ::c_char, + newdirfd: ::c_int, + newpath: *const ::c_char, + ) -> ::c_int; + pub fn symlinkat( + target: *const ::c_char, + newdirfd: ::c_int, + linkpath: *const ::c_char, + ) -> ::c_int; + pub fn unlinkat( + dirfd: ::c_int, + pathname: *const ::c_char, + flags: ::c_int, + ) -> ::c_int; + + pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; + pub fn alarm(seconds: ::c_uint) -> ::c_uint; + pub fn chdir(dir: *const c_char) -> ::c_int; + pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int; + pub fn lchown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int; + pub fn close(fd: ::c_int) -> ::c_int; + pub fn dup(fd: ::c_int) -> ::c_int; + pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; + pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> ::c_int; + pub fn execle( + path: *const ::c_char, + arg0: *const ::c_char, + ... + ) -> ::c_int; + pub fn execlp( + file: *const ::c_char, + arg0: *const ::c_char, + ... + ) -> ::c_int; + pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::c_int; + pub fn execve( + prog: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> ::c_int; + pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; + pub fn fork() -> pid_t; + pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; + pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgid() -> gid_t; + pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) -> ::c_int; + pub fn getlogin() -> *mut c_char; + pub fn getopt( + argc: ::c_int, + argv: *const *mut c_char, + optstr: *const c_char, + ) -> ::c_int; + pub fn getpgid(pid: pid_t) -> pid_t; + pub fn getpgrp() -> pid_t; + pub fn getpid() -> pid_t; + pub fn getppid() -> pid_t; + pub fn getuid() -> uid_t; + pub fn isatty(fd: ::c_int) -> ::c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int; + pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t; + pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long; + pub fn pause() -> ::c_int; + pub fn pipe(fds: *mut ::c_int) -> ::c_int; + pub fn posix_memalign( + memptr: *mut *mut ::c_void, + align: ::size_t, + size: ::size_t, + ) -> ::c_int; + pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) + -> ::ssize_t; + pub fn rmdir(path: *const c_char) -> ::c_int; + pub fn seteuid(uid: uid_t) -> ::c_int; + pub fn setegid(gid: gid_t) -> ::c_int; + pub fn setgid(gid: gid_t) -> ::c_int; + pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int; + pub fn setsid() -> pid_t; + pub fn setuid(uid: uid_t) -> ::c_int; + pub fn sleep(secs: ::c_uint) -> ::c_uint; + pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> ::c_int; + pub fn tcgetpgrp(fd: ::c_int) -> pid_t; + pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int; + pub fn ttyname(fd: ::c_int) -> *mut c_char; + pub fn unlink(c: *const c_char) -> ::c_int; + pub fn wait(status: *mut ::c_int) -> pid_t; + pub fn waitpid( + pid: pid_t, + status: *mut ::c_int, + options: ::c_int, + ) -> pid_t; + pub fn write( + fd: ::c_int, + buf: *const ::c_void, + count: ::size_t, + ) -> ::ssize_t; + pub fn pread( + fd: ::c_int, + buf: *mut ::c_void, + count: ::size_t, + offset: off_t, + ) -> ::ssize_t; + pub fn pwrite( + fd: ::c_int, + buf: *const ::c_void, + count: ::size_t, + offset: off_t, + ) -> ::ssize_t; + pub fn umask(mask: mode_t) -> mode_t; + + pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int; + + pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int; + + pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn mlockall(flags: ::c_int) -> ::c_int; + pub fn munlockall() -> ::c_int; + + pub fn mmap( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + flags: ::c_int, + fd: ::c_int, + offset: off_t, + ) -> *mut ::c_void; + pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; + + pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint; + pub fn if_indextoname( + ifindex: ::c_uint, + ifname: *mut ::c_char, + ) -> *mut ::c_char; + + pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; + + pub fn fsync(fd: ::c_int) -> ::c_int; + + pub fn setenv( + name: *const c_char, + val: *const c_char, + overwrite: ::c_int, + ) -> ::c_int; + pub fn unsetenv(name: *const c_char) -> ::c_int; + + pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int; + + pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int; + + pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t; + + pub fn realpath( + pathname: *const ::c_char, + resolved: *mut ::c_char, + ) -> *mut ::c_char; + + pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int; + + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + pub fn times(buf: *mut ::tms) -> ::clock_t; + + pub fn pthread_self() -> ::pthread_t; + pub fn pthread_join( + native: ::pthread_t, + value: *mut *mut ::c_void, + ) -> ::c_int; + pub fn pthread_exit(value: *mut ::c_void) -> !; + pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_setstacksize( + attr: *mut ::pthread_attr_t, + stack_size: ::size_t, + ) -> ::c_int; + pub fn pthread_attr_setdetachstate( + attr: *mut ::pthread_attr_t, + state: ::c_int, + ) -> ::c_int; + pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; + pub fn sched_yield() -> ::c_int; + pub fn pthread_key_create( + key: *mut pthread_key_t, + dtor: ::Option, + ) -> ::c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; + pub fn pthread_setspecific( + key: pthread_key_t, + value: *const ::c_void, + ) -> ::c_int; + pub fn pthread_mutex_init( + lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> ::c_int; + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int; + pub fn pthread_mutexattr_destroy( + attr: *mut pthread_mutexattr_t, + ) -> ::c_int; + pub fn pthread_mutexattr_settype( + attr: *mut pthread_mutexattr_t, + _type: ::c_int, + ) -> ::c_int; + + pub fn pthread_cond_init( + cond: *mut pthread_cond_t, + attr: *const pthread_condattr_t, + ) -> ::c_int; + pub fn pthread_cond_wait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + ) -> ::c_int; + pub fn pthread_cond_timedwait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int; + pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int; + pub fn pthread_rwlock_init( + lock: *mut pthread_rwlock_t, + attr: *const pthread_rwlockattr_t, + ) -> ::c_int; + pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) + -> ::c_int; + pub fn pthread_rwlockattr_destroy( + attr: *mut pthread_rwlockattr_t, + ) -> ::c_int; + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + pub fn getsockopt( + sockfd: ::c_int, + level: ::c_int, + optname: ::c_int, + optval: *mut ::c_void, + optlen: *mut ::socklen_t, + ) -> ::c_int; + pub fn raise(signum: ::c_int) -> ::c_int; + pub fn sigaction( + signum: ::c_int, + act: *const sigaction, + oldact: *mut sigaction, + ) -> ::c_int; + + pub fn utimes( + filename: *const ::c_char, + times: *const ::timeval, + ) -> ::c_int; + pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void; + pub fn dlerror() -> *mut ::c_char; + pub fn dlsym( + handle: *mut ::c_void, + symbol: *const ::c_char, + ) -> *mut ::c_void; + pub fn dlclose(handle: *mut ::c_void) -> ::c_int; + pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int; + + pub fn getaddrinfo( + node: *const c_char, + service: *const c_char, + hints: *const addrinfo, + res: *mut *mut addrinfo, + ) -> ::c_int; + pub fn freeaddrinfo(res: *mut addrinfo); + pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; + pub fn res_init() -> ::c_int; + + pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + pub fn mktime(tm: *mut tm) -> time_t; + pub fn time(time: *mut time_t) -> time_t; + pub fn gmtime(time_p: *const time_t) -> *mut tm; + pub fn localtime(time_p: *const time_t) -> *mut tm; + + pub fn mknod( + pathname: *const ::c_char, + mode: ::mode_t, + dev: ::dev_t, + ) -> ::c_int; + pub fn uname(buf: *mut ::utsname) -> ::c_int; + pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn getservbyname( + name: *const ::c_char, + proto: *const ::c_char, + ) -> *mut servent; + pub fn getprotobyname(name: *const ::c_char) -> *mut protoent; + pub fn getprotobynumber(proto: ::c_int) -> *mut protoent; + pub fn usleep(secs: ::c_uint) -> ::c_int; + pub fn send( + socket: ::c_int, + buf: *const ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + pub fn recv( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + pub fn putenv(string: *mut c_char) -> ::c_int; + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; + pub fn select( + nfds: ::c_int, + readfs: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *mut timeval, + ) -> ::c_int; + pub fn setlocale( + category: ::c_int, + locale: *const ::c_char, + ) -> *mut ::c_char; + pub fn localeconv() -> *mut lconv; + + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + pub fn sem_wait(sem: *mut sem_t) -> ::c_int; + pub fn sem_trywait(sem: *mut sem_t) -> ::c_int; + pub fn sem_post(sem: *mut sem_t) -> ::c_int; + pub fn sem_init( + sem: *mut sem_t, + pshared: ::c_int, + value: ::c_uint, + ) -> ::c_int; + pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int; + pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int; + + pub fn readlink( + path: *const c_char, + buf: *mut c_char, + bufsz: ::size_t, + ) -> ::ssize_t; + + pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; + pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; + pub fn sigfillset(set: *mut sigset_t) -> ::c_int; + pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; + pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int; + + pub fn sigprocmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + pub fn sigpending(set: *mut sigset_t) -> ::c_int; + + pub fn timegm(tm: *mut ::tm) -> time_t; + + pub fn getsid(pid: pid_t) -> pid_t; + + pub fn sysconf(name: ::c_int) -> ::c_long; + + pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int; + + pub fn pselect( + nfds: ::c_int, + readfs: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *const timespec, + sigmask: *const sigset_t, + ) -> ::c_int; + pub fn fseeko( + stream: *mut ::FILE, + offset: ::off_t, + whence: ::c_int, + ) -> ::c_int; + pub fn ftello(stream: *mut ::FILE) -> ::off_t; + pub fn tcdrain(fd: ::c_int) -> ::c_int; + pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t; + pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t; + pub fn cfmakeraw(termios: *mut ::termios); + pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; + pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; + pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; + pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int; + pub fn tcsetattr( + fd: ::c_int, + optional_actions: ::c_int, + termios: *const ::termios, + ) -> ::c_int; + pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int; + pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int; + pub fn tcgetsid(fd: ::c_int) -> ::pid_t; + pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int; + pub fn mkstemp(template: *mut ::c_char) -> ::c_int; + pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char; + + pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char; + + pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int); + pub fn closelog(); + pub fn setlogmask(maskpri: ::c_int) -> ::c_int; + pub fn syslog(priority: ::c_int, message: *const ::c_char, ...); + + pub fn grantpt(fd: ::c_int) -> ::c_int; + pub fn posix_openpt(flags: ::c_int) -> ::c_int; + pub fn ptsname(fd: ::c_int) -> *mut ::c_char; + pub fn unlockpt(fd: ::c_int) -> ::c_int; + + pub fn fdatasync(fd: ::c_int) -> ::c_int; + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_settime( + clk_id: ::clockid_t, + tp: *const ::timespec, + ) -> ::c_int; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + + pub fn pthread_getattr_np( + native: ::pthread_t, + attr: *mut ::pthread_attr_t, + ) -> ::c_int; + pub fn pthread_attr_getstack( + attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t, + ) -> ::c_int; + pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; + pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int; + pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + pub fn memrchr( + cx: *const ::c_void, + c: ::c_int, + n: ::size_t, + ) -> *mut ::c_void; + + pub fn posix_fadvise( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + advise: ::c_int, + ) -> ::c_int; + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn utimensat( + dirfd: ::c_int, + path: *const ::c_char, + times: *const ::timespec, + flag: ::c_int, + ) -> ::c_int; + pub fn duplocale(base: ::locale_t) -> ::locale_t; + pub fn freelocale(loc: ::locale_t); + pub fn newlocale( + mask: ::c_int, + locale: *const ::c_char, + base: ::locale_t, + ) -> ::locale_t; + pub fn uselocale(loc: ::locale_t) -> ::locale_t; + + pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; + + pub fn mknodat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + dev: dev_t, + ) -> ::c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> ::c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + pub fn accept4( + fd: ::c_int, + addr: *mut ::sockaddr, + len: *mut ::socklen_t, + flg: ::c_int, + ) -> ::c_int; + pub fn ptsname_r( + fd: ::c_int, + buf: *mut ::c_char, + buflen: ::size_t, + ) -> ::c_int; + pub fn clearenv() -> ::c_int; + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut ::siginfo_t, + options: ::c_int, + ) -> ::c_int; + pub fn setreuid(ruid: ::uid_t, euid: ::uid_t) -> ::c_int; + pub fn setregid(rgid: ::gid_t, egid: ::gid_t) -> ::c_int; + pub fn getresuid( + ruid: *mut ::uid_t, + euid: *mut ::uid_t, + suid: *mut ::uid_t, + ) -> ::c_int; + pub fn getresgid( + rgid: *mut ::gid_t, + egid: *mut ::gid_t, + sgid: *mut ::gid_t, + ) -> ::c_int; + pub fn acct(filename: *const ::c_char) -> ::c_int; + pub fn brk(addr: *mut ::c_void) -> ::c_int; + pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; + pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; + pub fn openpty( + amaster: *mut ::c_int, + aslave: *mut ::c_int, + name: *mut ::c_char, + termp: *const termios, + winp: *const ::winsize, + ) -> ::c_int; + pub fn execvpe( + file: *const ::c_char, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + pub fn fexecve( + fd: ::c_int, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; + + pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + + pub fn shm_open( + name: *const c_char, + oflag: ::c_int, + mode: mode_t, + ) -> ::c_int; + + // System V IPC + pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; + pub fn shmat( + shmid: ::c_int, + shmaddr: *const ::c_void, + shmflg: ::c_int, + ) -> *mut ::c_void; + pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; + pub fn shmctl( + shmid: ::c_int, + cmd: ::c_int, + buf: *mut ::shmid_ds, + ) -> ::c_int; + pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t; + pub fn semget(key: ::key_t, nsems: ::c_int, semflag: ::c_int) -> ::c_int; + pub fn semop( + semid: ::c_int, + sops: *mut ::sembuf, + nsops: ::size_t, + ) -> ::c_int; + pub fn semctl( + semid: ::c_int, + semnum: ::c_int, + cmd: ::c_int, + ... + ) -> ::c_int; + pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) + -> ::c_int; + pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; + pub fn msgrcv( + msqid: ::c_int, + msgp: *mut ::c_void, + msgsz: ::size_t, + msgtyp: ::c_long, + msgflg: ::c_int, + ) -> ::ssize_t; + pub fn msgsnd( + msqid: ::c_int, + msgp: *const ::c_void, + msgsz: ::size_t, + msgflg: ::c_int, + ) -> ::c_int; + + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn __errno_location() -> *mut ::c_int; + + pub fn fallocate( + fd: ::c_int, + mode: ::c_int, + offset: ::off_t, + len: ::off_t, + ) -> ::c_int; + pub fn posix_fallocate( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + ) -> ::c_int; + pub fn readahead( + fd: ::c_int, + offset: ::off64_t, + count: ::size_t, + ) -> ::ssize_t; + pub fn signalfd( + fd: ::c_int, + mask: *const ::sigset_t, + flags: ::c_int, + ) -> ::c_int; + pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int; + pub fn timerfd_gettime( + fd: ::c_int, + curr_value: *mut itimerspec, + ) -> ::c_int; + pub fn timerfd_settime( + fd: ::c_int, + flags: ::c_int, + new_value: *const itimerspec, + old_value: *mut itimerspec, + ) -> ::c_int; + pub fn pwritev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn preadv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn quotactl( + cmd: ::c_int, + special: *const ::c_char, + id: ::c_int, + data: *mut ::c_char, + ) -> ::c_int; + pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int; + pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; + pub fn mkostemps( + template: *mut ::c_char, + suffixlen: ::c_int, + flags: ::c_int, + ) -> ::c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int; + pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) + -> *mut ::c_char; + pub fn getnameinfo( + sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::socklen_t, + serv: *mut ::c_char, + sevlen: ::socklen_t, + flags: ::c_int, + ) -> ::c_int; + pub fn reboot(how_to: ::c_int) -> ::c_int; + pub fn setfsgid(gid: ::gid_t) -> ::c_int; + pub fn setfsuid(uid: ::uid_t) -> ::c_int; + + // Not available now on Android + pub fn mkfifoat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + ) -> ::c_int; + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + pub fn sync_file_range( + fd: ::c_int, + offset: ::off64_t, + nbytes: ::off64_t, + flags: ::c_uint, + ) -> ::c_int; + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; + pub fn freeifaddrs(ifa: *mut ::ifaddrs); + + pub fn glob( + pattern: *const c_char, + flags: ::c_int, + errfunc: ::Option< + extern "C" fn(epath: *const c_char, errno: ::c_int) -> ::c_int, + >, + pglob: *mut ::glob_t, + ) -> ::c_int; + pub fn globfree(pglob: *mut ::glob_t); + + pub fn posix_madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); + + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; + pub fn madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn msync( + addr: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::c_int; + + pub fn recvfrom( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + ) -> ::ssize_t; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + pub fn bind( + socket: ::c_int, + address: *const ::sockaddr, + address_len: ::socklen_t, + ) -> ::c_int; + + pub fn writev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + pub fn readv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + + pub fn sendmsg( + fd: ::c_int, + msg: *const ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + pub fn recvmsg( + fd: ::c_int, + msg: *mut ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn vhangup() -> ::c_int; + pub fn sendmmsg( + sockfd: ::c_int, + msgvec: *mut mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + ) -> ::c_int; + pub fn recvmmsg( + sockfd: ::c_int, + msgvec: *mut mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + timeout: *mut ::timespec, + ) -> ::c_int; + pub fn sync(); + pub fn syscall(num: ::c_long, ...) -> ::c_long; + pub fn sched_getaffinity( + pid: ::pid_t, + cpusetsize: ::size_t, + cpuset: *mut cpu_set_t, + ) -> ::c_int; + pub fn sched_setaffinity( + pid: ::pid_t, + cpusetsize: ::size_t, + cpuset: *const cpu_set_t, + ) -> ::c_int; + pub fn umount(target: *const ::c_char) -> ::c_int; + pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; + pub fn tee( + fd_in: ::c_int, + fd_out: ::c_int, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn settimeofday( + tv: *const ::timeval, + tz: *const ::timezone, + ) -> ::c_int; + pub fn splice( + fd_in: ::c_int, + off_in: *mut ::loff_t, + fd_out: ::c_int, + off_out: *mut ::loff_t, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; + pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) + -> ::c_int; + pub fn sem_timedwait( + sem: *mut sem_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int; + pub fn sched_setparam( + pid: ::pid_t, + param: *const ::sched_param, + ) -> ::c_int; + pub fn swapoff(puath: *const ::c_char) -> ::c_int; + pub fn vmsplice( + fd: ::c_int, + iov: *const ::iovec, + nr_segs: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn mount( + src: *const ::c_char, + target: *const ::c_char, + fstype: *const ::c_char, + flags: ::c_ulong, + data: *const ::c_void, + ) -> ::c_int; + pub fn personality(persona: ::c_ulong) -> ::c_int; + pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int; + pub fn ppoll( + fds: *mut ::pollfd, + nfds: nfds_t, + timeout: *const ::timespec, + sigmask: *const sigset_t, + ) -> ::c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn clone( + cb: extern "C" fn(*mut ::c_void) -> ::c_int, + child_stack: *mut ::c_void, + flags: ::c_int, + arg: *mut ::c_void, + ... + ) -> ::c_int; + pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; + pub fn clock_nanosleep( + clk_id: ::clockid_t, + flags: ::c_int, + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + pub fn pthread_attr_getguardsize( + attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t, + ) -> ::c_int; + pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; + pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; + pub fn swapon(path: *const ::c_char, swapflags: ::c_int) -> ::c_int; + pub fn sched_setscheduler( + pid: ::pid_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int; + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sem_close(sem: *mut sem_t) -> ::c_int; + pub fn getdtablesize() -> ::c_int; + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; + pub fn pthread_sigmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const ::c_char) -> *mut ::group; + pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int; + pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; + pub fn sem_unlink(name: *const ::c_char) -> ::c_int; + pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; + pub fn pthread_atfork( + prepare: ::Option, + parent: ::Option, + child: ::Option, + ) -> ::c_int; + pub fn getgrgid(gid: ::gid_t) -> *mut ::group; + pub fn getgrouplist( + user: *const ::c_char, + group: ::gid_t, + groups: *mut ::gid_t, + ngroups: *mut ::c_int, + ) -> ::c_int; + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + pub fn faccessat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::c_int, + flags: ::c_int, + ) -> ::c_int; + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + pub fn dl_iterate_phdr( + callback: ::Option< + unsafe extern "C" fn( + info: *mut ::dl_phdr_info, + size: ::size_t, + data: *mut ::c_void, + ) -> ::c_int, + >, + data: *mut ::c_void, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(any(target_arch = "x86_64"))] { + mod x86_64; + pub use self::x86_64::*; + } else { + // Unknown target_arch + } +} + +cfg_if! { + if #[cfg(libc_align)] { + #[macro_use] + mod align; + } else { + #[macro_use] + mod no_align; + } +} +expand_align!(); + +cfg_if! { + if #[cfg(libc_core_cvoid)] { + pub use ::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/no_align.rs new file mode 100644 index 0000000..7ca90e0 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/no_align.rs @@ -0,0 +1,129 @@ +macro_rules! expand_align { + () => { + s! { + pub struct pthread_mutexattr_t { + #[cfg(target_arch = "x86_64")] + __align: [::c_int; 0], + #[cfg(not(target_arch = "x86_64"))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_rwlockattr_t { + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + + s_no_extra_traits! { + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32")))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { + __align: [::c_long; 0], + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + pub struct pthread_cond_t { + __align: [*const ::c_void; 0], + #[cfg(not(target_env = "musl"))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + } + + cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + // Ignore __align field + self.size + .iter() + .zip(other.size.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_cond_t {} + impl ::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_cond_t") + // Ignore __align field + // FIXME: .field("size", &self.size) + .finish() + } + } + impl ::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + // Ignore __align field + self.size.hash(state); + } + } + + impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + // Ignore __align field + self.size + .iter() + .zip(other.size.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_mutex_t {} + impl ::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_mutex_t") + // Ignore __align field + // FIXME: .field("size", &self.size) + .finish() + } + } + impl ::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + // Ignore __align field + self.size.hash(state); + } + } + + impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + // Ignore __align field + self.size + .iter() + .zip(other.size.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_rwlock_t {} + impl ::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_rwlock_t") + // Ignore __align field + // FIXME: .field("size", &self.size) + .finish() + } + } + impl ::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + // Ignore __align field + self.size.hash(state); + } + } + } + } + }; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/x86_64.rs b/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/x86_64.rs new file mode 100644 index 0000000..dca3c24 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/fuchsia/x86_64.rs @@ -0,0 +1,152 @@ +pub type c_char = i8; +pub type wchar_t = i32; +pub type nlink_t = u64; +pub type blksize_t = ::c_long; +pub type __u64 = ::c_ulonglong; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 3], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __reserved: [::c_long; 3], + } + + pub struct mcontext_t { + __private: [u64; 32], + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_int, + __unused1: ::c_long, + __unused2: ::c_long + } +} + +s_no_extra_traits! { + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + __private: [u8; 512], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + && self + .__private + .iter() + .zip(other.__private.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for ucontext_t {} + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // FIXME: .field("__private", &self.__private) + .finish() + } + } + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + self.__private.hash(state); + } + } + } +} + +// offsets in user_regs_structs, from sys/reg.h +pub const R15: ::c_int = 0; +pub const R14: ::c_int = 1; +pub const R13: ::c_int = 2; +pub const R12: ::c_int = 3; +pub const RBP: ::c_int = 4; +pub const RBX: ::c_int = 5; +pub const R11: ::c_int = 6; +pub const R10: ::c_int = 7; +pub const R9: ::c_int = 8; +pub const R8: ::c_int = 9; +pub const RAX: ::c_int = 10; +pub const RCX: ::c_int = 11; +pub const RDX: ::c_int = 12; +pub const RSI: ::c_int = 13; +pub const RDI: ::c_int = 14; +pub const ORIG_RAX: ::c_int = 15; +pub const RIP: ::c_int = 16; +pub const CS: ::c_int = 17; +pub const EFLAGS: ::c_int = 18; +pub const RSP: ::c_int = 19; +pub const SS: ::c_int = 20; +pub const FS_BASE: ::c_int = 21; +pub const GS_BASE: ::c_int = 22; +pub const DS: ::c_int = 23; +pub const ES: ::c_int = 24; +pub const FS: ::c_int = 25; +pub const GS: ::c_int = 26; + +pub const MAP_32BIT: ::c_int = 0x0040; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/hermit/aarch64.rs b/third_party/cargo/vendor/libc-0.2.66/src/hermit/aarch64.rs new file mode 100644 index 0000000..1a92e3b --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/hermit/aarch64.rs @@ -0,0 +1,2 @@ +pub type c_char = u8; +pub type wchar_t = u32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/hermit/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/hermit/mod.rs new file mode 100644 index 0000000..9880b50 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/hermit/mod.rs @@ -0,0 +1,74 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// libc port for HermitCore (https://hermitcore.org) +// +// Ported by Colin Fink +// and Stefan Lankes + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type c_long = i64; +pub type c_ulong = u64; + +pub type wint_t = u32; +pub type wctype_t = i64; + +pub type regoff_t = size_t; +pub type off_t = c_long; + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else { + // Unknown target_arch + } +} + +cfg_if! { + if #[cfg(libc_core_cvoid)] { + pub use ::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/hermit/x86_64.rs b/third_party/cargo/vendor/libc-0.2.66/src/hermit/x86_64.rs new file mode 100644 index 0000000..76ec3ce --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/hermit/x86_64.rs @@ -0,0 +1,2 @@ +pub type c_char = i8; +pub type wchar_t = i32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/lib.rs b/third_party/cargo/vendor/libc-0.2.66/src/lib.rs new file mode 100644 index 0000000..0b1496a --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/lib.rs @@ -0,0 +1,157 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +//! libc - Raw FFI bindings to platforms' system libraries +//! +//! [Documentation for other platforms][pd]. +//! +//! [pd]: https://rust-lang.github.io/libc/#platform-specific-documentation +#![crate_name = "libc"] +#![crate_type = "rlib"] +#![cfg_attr(libc_deny_warnings, deny(warnings))] +#![allow( + bad_style, + overflowing_literals, + improper_ctypes, + unknown_lints, + redundant_semicolon +)] +// Attributes needed when building as part of the standard library +#![cfg_attr( + feature = "rustc-dep-of-std", + feature(cfg_target_vendor, link_cfg, no_core) +)] +#![cfg_attr(libc_thread_local, feature(thread_local))] +// Enable extra lints: +#![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] +#![deny(missing_copy_implementations, safe_packed_borrows)] +#![no_std] +#![cfg_attr(feature = "rustc-dep-of-std", no_core)] +#![cfg_attr(target_os = "redox", feature(static_nobundle))] +#![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))] + +#[macro_use] +mod macros; + +cfg_if! { + if #[cfg(feature = "rustc-dep-of-std")] { + extern crate rustc_std_workspace_core as core; + #[allow(unused_imports)] + use core::iter; + #[allow(unused_imports)] + use core::option; + } +} + +cfg_if! { + if #[cfg(libc_priv_mod_use)] { + #[cfg(libc_core_cvoid)] + #[allow(unused_imports)] + use core::ffi; + #[allow(unused_imports)] + use core::fmt; + #[allow(unused_imports)] + use core::hash; + #[allow(unused_imports)] + use core::num; + #[allow(unused_imports)] + use core::mem; + #[doc(hidden)] + #[allow(unused_imports)] + use core::clone::Clone; + #[doc(hidden)] + #[allow(unused_imports)] + use core::marker::Copy; + #[doc(hidden)] + #[allow(unused_imports)] + use core::option::Option; + } else { + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::fmt; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::hash; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::num; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::mem; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::clone::Clone; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::marker::Copy; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::option::Option; + } +} + +cfg_if! { + if #[cfg(windows)] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod windows; + pub use windows::*; + } else if #[cfg(target_os = "cloudabi")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod cloudabi; + pub use cloudabi::*; + } else if #[cfg(target_os = "fuchsia")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod fuchsia; + pub use fuchsia::*; + } else if #[cfg(target_os = "switch")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod switch; + pub use switch::*; + } else if #[cfg(target_os = "vxworks")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod vxworks; + pub use vxworks::*; + } else if #[cfg(unix)] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod unix; + pub use unix::*; + } else if #[cfg(target_os = "hermit")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod hermit; + pub use hermit::*; + } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod sgx; + pub use sgx::*; + } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod wasi; + pub use wasi::*; + } else { + // non-supported targets: empty... + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/macros.rs b/third_party/cargo/vendor/libc-0.2.66/src/macros.rs new file mode 100644 index 0000000..f14bbf5 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/macros.rs @@ -0,0 +1,275 @@ +/// A macro for defining #[cfg] if-else statements. +/// +/// This is similar to the `if/elif` C preprocessor macro by allowing definition +/// of a cascade of `#[cfg]` cases, emitting the implementation which matches +/// first. +/// +/// This allows you to conveniently provide a long list #[cfg]'d blocks of code +/// without having to rewrite each clause multiple times. +#[allow(unused_macros)] +macro_rules! cfg_if { + // match if/else chains with a final `else` + ($( + if #[cfg($($meta:meta),*)] { $($it:item)* } + ) else * else { + $($it2:item)* + }) => { + cfg_if! { + @__items + () ; + $( ( ($($meta),*) ($($it)*) ), )* + ( () ($($it2)*) ), + } + }; + + // match if/else chains lacking a final `else` + ( + if #[cfg($($i_met:meta),*)] { $($i_it:item)* } + $( + else if #[cfg($($e_met:meta),*)] { $($e_it:item)* } + )* + ) => { + cfg_if! { + @__items + () ; + ( ($($i_met),*) ($($i_it)*) ), + $( ( ($($e_met),*) ($($e_it)*) ), )* + ( () () ), + } + }; + + // Internal and recursive macro to emit all the items + // + // Collects all the negated cfgs in a list at the beginning and after the + // semicolon is all the remaining items + (@__items ($($not:meta,)*) ; ) => {}; + (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), + $($rest:tt)*) => { + // Emit all items within one block, applying an approprate #[cfg]. The + // #[cfg] will require all `$m` matchers specified and must also negate + // all previous matchers. + cfg_if! { @__apply cfg(all($($m,)* not(any($($not),*)))), $($it)* } + + // Recurse to emit all other items in `$rest`, and when we do so add all + // our `$m` matchers to the list of `$not` matchers as future emissions + // will have to negate everything we just matched as well. + cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* } + }; + + // Internal macro to Apply a cfg attribute to a list of items + (@__apply $m:meta, $($it:item)*) => { + $(#[$m] $it)* + }; +} + +#[allow(unused_macros)] +macro_rules! s { + ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($( + s!(it: $(#[$attr])* pub $t $i { $($field)* }); + )*); + (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( + compile_error!("unions cannot derive extra traits, use s_no_extra_traits instead"); + ); + (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( + __item! { + #[repr(C)] + #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] + #[allow(deprecated)] + $(#[$attr])* + pub struct $i { $($field)* } + } + #[allow(deprecated)] + impl ::Copy for $i {} + #[allow(deprecated)] + impl ::Clone for $i { + fn clone(&self) -> $i { *self } + } + ); +} + +#[allow(unused_macros)] +macro_rules! s_no_extra_traits { + ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($( + s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* }); + )*); + (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( + cfg_if! { + if #[cfg(libc_union)] { + __item! { + #[repr(C)] + $(#[$attr])* + pub union $i { $($field)* } + } + + impl ::Copy for $i {} + impl ::Clone for $i { + fn clone(&self) -> $i { *self } + } + } + } + ); + (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( + __item! { + #[repr(C)] + $(#[$attr])* + pub struct $i { $($field)* } + } + impl ::Copy for $i {} + impl ::Clone for $i { + fn clone(&self) -> $i { *self } + } + ); +} + +// This is a pretty horrible hack to allow us to conditionally mark +// some functions as 'const', without requiring users of this macro +// to care about the "const-extern-fn" feature. +// +// When 'const-extern-fn' is enabled, we emit the captured 'const' keyword +// in the expanded function. +// +// When 'const-extern-fn' is disabled, we always emit a plain 'pub unsafe extern fn'. +// Note that the expression matched by the macro is exactly the same - this allows +// users of this macro to work whether or not 'const-extern-fn' is enabled +// +// Unfortunately, we need to duplicate most of this macro between the 'cfg_if' blocks. +// This is because 'const unsafe extern fn' won't even parse on older compilers, +// so we need to avoid emitting it at all of 'const-extern-fn'. +// +// Specifically, moving the 'cfg_if' into the macro body will *not* work. +// Doing so would cause the '#[cfg(feature = "const-extern-fn")]' to be emiited +// into user code. The 'cfg' gate will not stop Rust from trying to parse the +// 'pub const unsafe extern fn', so users would get a compiler error even when +// the 'const-extern-fn' feature is disabled +// +// Note that users of this macro need to place 'const' in a weird position +// (after the closing ')' for the arguments, but before the return type). +// This was the only way I could satisfy the following two requirements: +// 1. Avoid ambuguity errors from 'macro_rules!' (which happen when writing '$foo:ident fn' +// 2. Allow users of this macro to mix 'pub fn foo' and 'pub const fn bar' within the same +// 'f!' block +cfg_if! { + if #[cfg(libc_const_extern_fn)] { + #[allow(unused_macros)] + macro_rules! f { + ($(pub $({$constness:ident})* fn $i:ident( + $($arg:ident: $argty:ty),* + ) -> $ret:ty { + $($body:stmt);* + })*) => ($( + #[inline] + pub $($constness)* unsafe extern fn $i($($arg: $argty),* + ) -> $ret { + $($body);* + } + )*) + } + + #[allow(unused_macros)] + macro_rules! const_fn { + ($($({$constness:ident})* fn $i:ident( + $($arg:ident: $argty:ty),* + ) -> $ret:ty { + $($body:stmt);* + })*) => ($( + #[inline] + $($constness)* fn $i($($arg: $argty),* + ) -> $ret { + $($body);* + } + )*) + } + + } else { + #[allow(unused_macros)] + macro_rules! f { + ($(pub $({$constness:ident})* fn $i:ident( + $($arg:ident: $argty:ty),* + ) -> $ret:ty { + $($body:stmt);* + })*) => ($( + #[inline] + pub unsafe extern fn $i($($arg: $argty),* + ) -> $ret { + $($body);* + } + )*) + } + + #[allow(unused_macros)] + macro_rules! const_fn { + ($($({$constness:ident})* fn $i:ident( + $($arg:ident: $argty:ty),* + ) -> $ret:ty { + $($body:stmt);* + })*) => ($( + #[inline] + fn $i($($arg: $argty),* + ) -> $ret { + $($body);* + } + )*) + } + } +} + +#[allow(unused_macros)] +macro_rules! __item { + ($i:item) => { + $i + }; +} + +#[allow(unused_macros)] +macro_rules! align_const { + ($($(#[$attr:meta])* + pub const $name:ident : $t1:ty + = $t2:ident { $($field:tt)* };)*) => ($( + #[cfg(libc_align)] + $(#[$attr])* + pub const $name : $t1 = $t2 { + $($field)* + }; + #[cfg(not(libc_align))] + $(#[$attr])* + pub const $name : $t1 = $t2 { + $($field)* + __align: [], + }; + )*) +} + +// This macro is used to deprecate items that should be accessed via the mach crate +#[allow(unused_macros)] +macro_rules! deprecated_mach { + (pub const $id:ident: $ty:ty = $expr:expr;) => { + #[deprecated( + since = "0.2.55", + note = "Use the `mach` crate instead", + )] + #[allow(deprecated)] + pub const $id: $ty = $expr; + }; + ($(pub const $id:ident: $ty:ty = $expr:expr;)*) => { + $( + deprecated_mach!( + pub const $id: $ty = $expr; + ); + )* + }; + (pub type $id:ident = $ty:ty;) => { + #[deprecated( + since = "0.2.55", + note = "Use the `mach` crate instead", + )] + #[allow(deprecated)] + pub type $id = $ty; + }; + ($(pub type $id:ident = $ty:ty;)*) => { + $( + deprecated_mach!( + pub type $id = $ty; + ); + )* + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/sgx.rs b/third_party/cargo/vendor/libc-0.2.66/src/sgx.rs new file mode 100644 index 0000000..7da6269 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/sgx.rs @@ -0,0 +1,47 @@ +//! SGX C types definition + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type c_char = i8; +pub type c_long = i64; +pub type c_ulong = u64; + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +cfg_if! { + if #[cfg(libc_core_cvoid)] { + pub use ::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/switch.rs b/third_party/cargo/vendor/libc-0.2.66/src/switch.rs new file mode 100644 index 0000000..030ab20 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/switch.rs @@ -0,0 +1,49 @@ +//! Switch C type definitions + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type off_t = i64; +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type wchar_t = u32; + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +cfg_if! { + if #[cfg(libc_core_cvoid)] { + pub use ::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/align.rs new file mode 100644 index 0000000..4fdba9a --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/align.rs @@ -0,0 +1,6 @@ +s! { + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [u8; 16], + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b32/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b32/align.rs new file mode 100644 index 0000000..ca1fe1c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b32/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 2] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b32/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b32/mod.rs new file mode 100644 index 0000000..9248e3a --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b32/mod.rs @@ -0,0 +1,115 @@ +//! 32-bit specific Apple (ios/darwin) definitions + +pub type c_long = i32; +pub type c_ulong = u32; +pub type boolean_t = ::c_int; + +s! { + pub struct if_data { + pub ifi_type: ::c_uchar, + pub ifi_typelen: ::c_uchar, + pub ifi_physical: ::c_uchar, + pub ifi_addrlen: ::c_uchar, + pub ifi_hdrlen: ::c_uchar, + pub ifi_recvquota: ::c_uchar, + pub ifi_xmitquota: ::c_uchar, + pub ifi_unused1: ::c_uchar, + pub ifi_mtu: u32, + pub ifi_metric: u32, + pub ifi_baudrate: u32, + pub ifi_ipackets: u32, + pub ifi_ierrors: u32, + pub ifi_opackets: u32, + pub ifi_oerrors: u32, + pub ifi_collisions: u32, + pub ifi_ibytes: u32, + pub ifi_obytes: u32, + pub ifi_imcasts: u32, + pub ifi_omcasts: u32, + pub ifi_iqdrops: u32, + pub ifi_noproto: u32, + pub ifi_recvtiming: u32, + pub ifi_xmittiming: u32, + pub ifi_lastchange: ::timeval, + pub ifi_unused2: u32, + pub ifi_hwassist: u32, + pub ifi_reserved1: u32, + pub ifi_reserved2: u32, + } + + pub struct bpf_hdr { + pub bh_tstamp: ::timeval, + pub bh_caplen: u32, + pub bh_datalen: u32, + pub bh_hdrlen: ::c_ushort, + } +} + +s_no_extra_traits! { + pub struct pthread_attr_t { + __sig: c_long, + __opaque: [::c_char; 36] + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for pthread_attr_t { + fn eq(&self, other: &pthread_attr_t) -> bool { + self.__sig == other.__sig + && self.__opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_attr_t {} + impl ::fmt::Debug for pthread_attr_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_attr_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } + } + impl ::hash::Hash for pthread_attr_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } + } +} + +#[doc(hidden)] +#[deprecated(since = "0.2.55")] +pub const NET_RT_MAXID: ::c_int = 10; + +pub const __PTHREAD_MUTEX_SIZE__: usize = 40; +pub const __PTHREAD_COND_SIZE__: usize = 24; +pub const __PTHREAD_CONDATTR_SIZE__: usize = 4; +pub const __PTHREAD_RWLOCK_SIZE__: usize = 124; +pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12; + +pub const TIOCTIMESTAMP: ::c_ulong = 0x40087459; +pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40087458; + +pub const BIOCSETF: ::c_ulong = 0x80084267; +pub const BIOCSRTIMEOUT: ::c_ulong = 0x8008426d; +pub const BIOCGRTIMEOUT: ::c_ulong = 0x4008426e; +pub const BIOCSETFNR: ::c_ulong = 0x8008427e; + +extern "C" { + pub fn exchangedata( + path1: *const ::c_char, + path2: *const ::c_char, + options: ::c_ulong, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b64/align.rs new file mode 100644 index 0000000..ca1fe1c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 2] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b64/mod.rs new file mode 100644 index 0000000..7f70083 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/b64/mod.rs @@ -0,0 +1,120 @@ +//! 64-bit specific Apple (ios/darwin) definitions + +pub type c_long = i64; +pub type c_ulong = u64; +pub type boolean_t = ::c_uint; + +s! { + pub struct timeval32 { + pub tv_sec: i32, + pub tv_usec: i32, + } + + pub struct if_data { + pub ifi_type: ::c_uchar, + pub ifi_typelen: ::c_uchar, + pub ifi_physical: ::c_uchar, + pub ifi_addrlen: ::c_uchar, + pub ifi_hdrlen: ::c_uchar, + pub ifi_recvquota: ::c_uchar, + pub ifi_xmitquota: ::c_uchar, + pub ifi_unused1: ::c_uchar, + pub ifi_mtu: u32, + pub ifi_metric: u32, + pub ifi_baudrate: u32, + pub ifi_ipackets: u32, + pub ifi_ierrors: u32, + pub ifi_opackets: u32, + pub ifi_oerrors: u32, + pub ifi_collisions: u32, + pub ifi_ibytes: u32, + pub ifi_obytes: u32, + pub ifi_imcasts: u32, + pub ifi_omcasts: u32, + pub ifi_iqdrops: u32, + pub ifi_noproto: u32, + pub ifi_recvtiming: u32, + pub ifi_xmittiming: u32, + pub ifi_lastchange: timeval32, + pub ifi_unused2: u32, + pub ifi_hwassist: u32, + pub ifi_reserved1: u32, + pub ifi_reserved2: u32, + } + + pub struct bpf_hdr { + pub bh_tstamp: ::timeval32, + pub bh_caplen: u32, + pub bh_datalen: u32, + pub bh_hdrlen: ::c_ushort, + } +} + +s_no_extra_traits! { + pub struct pthread_attr_t { + __sig: c_long, + __opaque: [::c_char; 56] + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for pthread_attr_t { + fn eq(&self, other: &pthread_attr_t) -> bool { + self.__sig == other.__sig + && self.__opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_attr_t {} + impl ::fmt::Debug for pthread_attr_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_attr_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } + } + impl ::hash::Hash for pthread_attr_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } + } +} + +#[doc(hidden)] +#[deprecated(since = "0.2.55")] +pub const NET_RT_MAXID: ::c_int = 11; + +pub const __PTHREAD_MUTEX_SIZE__: usize = 56; +pub const __PTHREAD_COND_SIZE__: usize = 40; +pub const __PTHREAD_CONDATTR_SIZE__: usize = 8; +pub const __PTHREAD_RWLOCK_SIZE__: usize = 192; +pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16; + +pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; +pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40107458; + +pub const BIOCSETF: ::c_ulong = 0x80104267; +pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; +pub const BIOCSETFNR: ::c_ulong = 0x8010427e; + +extern "C" { + pub fn exchangedata( + path1: *const ::c_char, + path2: *const ::c_char, + options: ::c_uint, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/mod.rs new file mode 100644 index 0000000..aa3cc1c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/apple/mod.rs @@ -0,0 +1,3543 @@ +//! Apple (ios/darwin)-specific definitions +//! +//! This covers *-apple-* triples currently +pub type c_char = i8; +pub type clock_t = c_ulong; +pub type time_t = c_long; +pub type suseconds_t = i32; +pub type dev_t = i32; +pub type ino_t = u64; +pub type mode_t = u16; +pub type nlink_t = u16; +pub type blksize_t = i32; +pub type rlim_t = u64; +pub type pthread_key_t = c_ulong; +pub type sigset_t = u32; +pub type clockid_t = ::c_uint; +pub type fsblkcnt_t = ::c_uint; +pub type fsfilcnt_t = ::c_uint; +pub type speed_t = ::c_ulong; +pub type tcflag_t = ::c_ulong; +pub type nl_item = ::c_int; +pub type id_t = ::c_uint; +pub type sem_t = ::c_int; +pub type idtype_t = ::c_uint; +pub type integer_t = ::c_int; +pub type cpu_type_t = integer_t; +pub type cpu_subtype_t = integer_t; + +pub type posix_spawnattr_t = *mut ::c_void; +pub type posix_spawn_file_actions_t = *mut ::c_void; +pub type key_t = ::c_int; +pub type shmatt_t = ::c_ushort; + +deprecated_mach! { + pub type vm_prot_t = ::c_int; + pub type vm_size_t = ::uintptr_t; + pub type mach_timebase_info_data_t = mach_timebase_info; +} + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum timezone {} +impl ::Copy for timezone {} +impl ::Clone for timezone { + fn clone(&self) -> timezone { + *self + } +} + +s! { + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct aiocb { + pub aio_fildes: ::c_int, + pub aio_offset: ::off_t, + pub aio_buf: *mut ::c_void, + pub aio_nbytes: ::size_t, + pub aio_reqprio: ::c_int, + pub aio_sigevent: sigevent, + pub aio_lio_opcode: ::c_int + } + + pub struct glob_t { + pub gl_pathc: ::size_t, + __unused1: ::c_int, + pub gl_offs: ::size_t, + __unused2: ::c_int, + pub gl_pathv: *mut *mut ::c_char, + + __unused3: *mut ::c_void, + + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + __unused6: *mut ::c_void, + __unused7: *mut ::c_void, + __unused8: *mut ::c_void, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: ::socklen_t, + pub ai_canonname: *mut ::c_char, + pub ai_addr: *mut ::sockaddr, + pub ai_next: *mut addrinfo, + } + + #[deprecated( + since = "0.2.55", + note = "Use the `mach` crate instead", + )] + pub struct mach_timebase_info { + pub numer: u32, + pub denom: u32, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_ino: ino_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: u32, + pub st_gen: u32, + pub st_lspare: i32, + pub st_qspare: [i64; 2], + } + + pub struct pthread_mutexattr_t { + __sig: ::c_long, + __opaque: [u8; 8], + } + + pub struct pthread_condattr_t { + __sig: ::c_long, + __opaque: [u8; __PTHREAD_CONDATTR_SIZE__], + } + + pub struct pthread_rwlockattr_t { + __sig: ::c_long, + __opaque: [u8; __PTHREAD_RWLOCKATTR_SIZE__], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub si_pid: ::pid_t, + pub si_uid: ::uid_t, + pub si_status: ::c_int, + pub si_addr: *mut ::c_void, + //Requires it to be union for tests + //pub si_value: ::sigval, + _pad: [usize; 9], + } + + pub struct sigaction { + // FIXME: this field is actually a union + pub sa_sigaction: ::sighandler_t, + pub sa_mask: sigset_t, + pub sa_flags: ::c_int, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct fstore_t { + pub fst_flags: ::c_uint, + pub fst_posmode: ::c_int, + pub fst_offset: ::off_t, + pub fst_length: ::off_t, + pub fst_bytesalloc: ::off_t, + } + + pub struct radvisory { + pub ra_offset: ::off_t, + pub ra_count: ::c_int, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [::c_char; 8], + } + + pub struct kevent64_s { + pub ident: u64, + pub filter: i16, + pub flags: u16, + pub fflags: u32, + pub data: i64, + pub udata: u64, + pub ext: [u64; 2], + } + + pub struct dqblk { + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curbytes: u64, + pub dqb_ihardlimit: u32, + pub dqb_isoftlimit: u32, + pub dqb_curinodes: u32, + pub dqb_btime: u32, + pub dqb_itime: u32, + pub dqb_id: u32, + pub dqb_spare: [u32; 4], + } + + pub struct if_msghdr { + pub ifm_msglen: ::c_ushort, + pub ifm_version: ::c_uchar, + pub ifm_type: ::c_uchar, + pub ifm_addrs: ::c_int, + pub ifm_flags: ::c_int, + pub ifm_index: ::c_ushort, + pub ifm_data: if_data, + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_cc: [::cc_t; ::NCCS], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } + + pub struct flock { + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + pub l_type: ::c_short, + pub l_whence: ::c_short, + } + + pub struct sf_hdtr { + pub headers: *mut ::iovec, + pub hdr_cnt: ::c_int, + pub trailers: *mut ::iovec, + pub trl_cnt: ::c_int, + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct proc_taskinfo { + pub pti_virtual_size: u64, + pub pti_resident_size: u64, + pub pti_total_user: u64, + pub pti_total_system: u64, + pub pti_threads_user: u64, + pub pti_threads_system: u64, + pub pti_policy: i32, + pub pti_faults: i32, + pub pti_pageins: i32, + pub pti_cow_faults: i32, + pub pti_messages_sent: i32, + pub pti_messages_received: i32, + pub pti_syscalls_mach: i32, + pub pti_syscalls_unix: i32, + pub pti_csw: i32, + pub pti_threadnum: i32, + pub pti_numrunning: i32, + pub pti_priority: i32, + } + + pub struct proc_bsdinfo { + pub pbi_flags: u32, + pub pbi_status: u32, + pub pbi_xstatus: u32, + pub pbi_pid: u32, + pub pbi_ppid: u32, + pub pbi_uid: ::uid_t, + pub pbi_gid: ::gid_t, + pub pbi_ruid: ::uid_t, + pub pbi_rgid: ::gid_t, + pub pbi_svuid: ::uid_t, + pub pbi_svgid: ::gid_t, + pub rfu_1: u32, + pub pbi_comm: [::c_char; MAXCOMLEN], + pub pbi_name: [::c_char; 32], // MAXCOMLEN * 2, but macro isn't happy... + pub pbi_nfiles: u32, + pub pbi_pgid: u32, + pub pbi_pjobc: u32, + pub e_tdev: u32, + pub e_tpgid: u32, + pub pbi_nice: i32, + pub pbi_start_tvsec: u64, + pub pbi_start_tvusec: u64, + } + + pub struct proc_taskallinfo { + pub pbsd: proc_bsdinfo, + pub ptinfo: proc_taskinfo, + } + + pub struct xsw_usage { + pub xsu_total: u64, + pub xsu_avail: u64, + pub xsu_used: u64, + pub xsu_pagesize: u32, + pub xsu_encrypted: ::boolean_t, + } + + pub struct xucred { + pub cr_version: ::c_uint, + pub cr_uid: ::uid_t, + pub cr_ngroups: ::c_short, + pub cr_groups: [::gid_t;16] + } + + #[deprecated( + since = "0.2.55", + note = "Use the `mach` crate instead", + )] + pub struct mach_header { + pub magic: u32, + pub cputype: cpu_type_t, + pub cpusubtype: cpu_subtype_t, + pub filetype: u32, + pub ncmds: u32, + pub sizeofcmds: u32, + pub flags: u32, + } + + #[deprecated( + since = "0.2.55", + note = "Use the `mach` crate instead", + )] + pub struct mach_header_64 { + pub magic: u32, + pub cputype: cpu_type_t, + pub cpusubtype: cpu_subtype_t, + pub filetype: u32, + pub ncmds: u32, + pub sizeofcmds: u32, + pub flags: u32, + pub reserved: u32, + } + + pub struct segment_command { + pub cmd: u32, + pub cmdsize: u32, + pub segname: [::c_char; 16], + pub vmaddr: u32, + pub vmsize: u32, + pub fileoff: u32, + pub filesize: u32, + pub maxprot: vm_prot_t, + pub initprot: vm_prot_t, + pub nsects: u32, + pub flags: u32, + } + + pub struct segment_command_64 { + pub cmd: u32, + pub cmdsize: u32, + pub segname: [::c_char; 16], + pub vmaddr: u64, + pub vmsize: u64, + pub fileoff: u64, + pub filesize: u64, + pub maxprot: vm_prot_t, + pub initprot: vm_prot_t, + pub nsects: u32, + pub flags: u32, + } + + pub struct load_command { + pub cmd: u32, + pub cmdsize: u32, + } + + pub struct sockaddr_dl { + pub sdl_len: ::c_uchar, + pub sdl_family: ::c_uchar, + pub sdl_index: ::c_ushort, + pub sdl_type: ::c_uchar, + pub sdl_nlen: ::c_uchar, + pub sdl_alen: ::c_uchar, + pub sdl_slen: ::c_uchar, + pub sdl_data: [::c_char; 12], + } + + pub struct sockaddr_inarp { + pub sin_len: ::c_uchar, + pub sin_family: ::c_uchar, + pub sin_port: ::c_ushort, + pub sin_addr: ::in_addr, + pub sin_srcaddr: ::in_addr, + pub sin_tos: ::c_ushort, + pub sin_other: ::c_ushort, + } + + pub struct sockaddr_ctl { + pub sc_len: ::c_uchar, + pub sc_family: ::c_uchar, + pub ss_sysaddr: u16, + pub sc_id: u32, + pub sc_unit: u32, + pub sc_reserved: [u32; 5], + } + + pub struct in_pktinfo { + pub ipi_ifindex: ::c_uint, + pub ipi_spec_dst: ::in_addr, + pub ipi_addr: ::in_addr, + } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_uint, + } + + // sys/ipc.h: + + pub struct ipc_perm { + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub _seq: ::c_ushort, + pub _key: ::key_t, + } + + // sys/sem.h + + pub struct sembuf { + pub sem_num: ::c_ushort, + pub sem_op: ::c_short, + pub sem_flg: ::c_short, + } + + // sys/shm.h + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + pub struct in_addr { + pub s_addr: ::in_addr_t, + } +} + +s_no_extra_traits! { + #[cfg_attr(libc_packedN, repr(packed(4)))] + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: i16, + pub flags: u16, + pub fflags: u32, + pub data: ::intptr_t, + pub udata: *mut ::c_void, + } + + #[cfg_attr(libc_packedN, repr(packed(4)))] + pub struct semid_ds { + // Note the manpage shows different types than the system header. + pub sem_perm: ipc_perm, + pub sem_base: i32, + pub sem_nsems: ::c_ushort, + pub sem_otime: ::time_t, + pub sem_pad1: i32, + pub sem_ctime: ::time_t, + pub sem_pad2: i32, + pub sem_pad3: [i32; 4], + } + + #[cfg_attr(libc_packedN, repr(packed(4)))] + pub struct shmid_ds { + pub shm_perm: ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_atime: ::time_t, // FIXME: 64-bit wrong align => wrong offset + pub shm_dtime: ::time_t, // FIXME: 64-bit wrong align => wrong offset + pub shm_ctime: ::time_t, // FIXME: 64-bit wrong align => wrong offset + // FIXME: 64-bit wrong align => wrong offset: + pub shm_internal: *mut ::c_void, + } + + pub struct proc_threadinfo { + pub pth_user_time: u64, + pub pth_system_time: u64, + pub pth_cpu_usage: i32, + pub pth_policy: i32, + pub pth_run_state: i32, + pub pth_flags: i32, + pub pth_sleep_time: i32, + pub pth_curpri: i32, + pub pth_priority: i32, + pub pth_maxpriority: i32, + pub pth_name: [::c_char; MAXTHREADNAMESIZE], + } + + pub struct statfs { + pub f_bsize: u32, + pub f_iosize: i32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_owner: ::uid_t, + pub f_type: u32, + pub f_flags: u32, + pub f_fssubtype: u32, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 1024], + pub f_mntfromname: [::c_char; 1024], + pub f_reserved: [u32; 8], + } + + pub struct dirent { + pub d_ino: u64, + pub d_seekoff: u64, + pub d_reclen: u16, + pub d_namlen: u16, + pub d_type: u8, + pub d_name: [::c_char; 1024], + } + + pub struct pthread_rwlock_t { + __sig: ::c_long, + __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], + } + + pub struct pthread_mutex_t { + __sig: ::c_long, + __opaque: [u8; __PTHREAD_MUTEX_SIZE__], + } + + pub struct pthread_cond_t { + __sig: ::c_long, + __opaque: [u8; __PTHREAD_COND_SIZE__], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: ::sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } + + pub struct utmpx { + pub ut_user: [::c_char; _UTX_USERSIZE], + pub ut_id: [::c_char; _UTX_IDSIZE], + pub ut_line: [::c_char; _UTX_LINESIZE], + pub ut_pid: ::pid_t, + pub ut_type: ::c_short, + pub ut_tv: ::timeval, + pub ut_host: [::c_char; _UTX_HOSTSIZE], + ut_pad: [u32; 16], + } + + pub struct sigevent { + pub sigev_notify: ::c_int, + pub sigev_signo: ::c_int, + pub sigev_value: ::sigval, + __unused1: *mut ::c_void, //actually a function pointer + pub sigev_notify_attributes: *mut ::pthread_attr_t + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut ::c_void { + self.si_addr + } + + pub unsafe fn si_value(&self) -> ::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + _si_pid: ::pid_t, + _si_uid: ::uid_t, + _si_status: ::c_int, + _si_addr: *mut ::c_void, + si_value: ::sigval, + } + + (*(self as *const siginfo_t as *const siginfo_timer)).si_value + } +} + +cfg_if! { + if #[cfg(libc_union)] { + s_no_extra_traits! { + pub union semun { + pub val: ::c_int, + pub buf: *mut semid_ds, + pub array: *mut ::c_ushort, + } + } + + cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for semun { + fn eq(&self, other: &semun) -> bool { + unsafe { self.val == other.val } + } + } + impl Eq for semun {} + impl ::fmt::Debug for semun { + fn fmt(&self, f: &mut ::fmt::Formatter) + -> ::fmt::Result { + f.debug_struct("semun") + .field("val", unsafe { &self.val }) + .finish() + } + } + impl ::hash::Hash for semun { + fn hash(&self, state: &mut H) { + unsafe { self.val.hash(state) }; + } + } + } + } + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for kevent { + fn eq(&self, other: &kevent) -> bool { + self.ident == other.ident + && self.filter == other.filter + && self.flags == other.flags + && self.fflags == other.fflags + && self.data == other.data + && self.udata == other.udata + } + } + impl Eq for kevent {} + impl ::fmt::Debug for kevent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let ident = self.ident; + let filter = self.filter; + let flags = self.flags; + let fflags = self.fflags; + let data = self.data; + let udata = self.udata; + f.debug_struct("kevent") + .field("ident", &ident) + .field("filter", &filter) + .field("flags", &flags) + .field("fflags", &fflags) + .field("data", &data) + .field("udata", &udata) + .finish() + } + } + impl ::hash::Hash for kevent { + fn hash(&self, state: &mut H) { + let ident = self.ident; + let filter = self.filter; + let flags = self.flags; + let fflags = self.fflags; + let data = self.data; + let udata = self.udata; + ident.hash(state); + filter.hash(state); + flags.hash(state); + fflags.hash(state); + data.hash(state); + udata.hash(state); + } + } + + impl PartialEq for semid_ds { + fn eq(&self, other: &semid_ds) -> bool { + let sem_perm = self.sem_perm; + let sem_pad3 = self.sem_pad3; + let other_sem_perm = other.sem_perm; + let other_sem_pad3 = other.sem_pad3; + sem_perm == other_sem_perm + && self.sem_base == other.sem_base + && self.sem_nsems == other.sem_nsems + && self.sem_otime == other.sem_otime + && self.sem_pad1 == other.sem_pad1 + && self.sem_ctime == other.sem_ctime + && self.sem_pad2 == other.sem_pad2 + && sem_pad3 == other_sem_pad3 + } + } + impl Eq for semid_ds {} + impl ::fmt::Debug for semid_ds { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let sem_perm = self.sem_perm; + let sem_base = self.sem_base; + let sem_nsems = self.sem_nsems; + let sem_otime = self.sem_otime; + let sem_pad1 = self.sem_pad1; + let sem_ctime = self.sem_ctime; + let sem_pad2 = self.sem_pad2; + let sem_pad3 = self.sem_pad3; + f.debug_struct("semid_ds") + .field("sem_perm", &sem_perm) + .field("sem_base", &sem_base) + .field("sem_nsems", &sem_nsems) + .field("sem_otime", &sem_otime) + .field("sem_pad1", &sem_pad1) + .field("sem_ctime", &sem_ctime) + .field("sem_pad2", &sem_pad2) + .field("sem_pad3", &sem_pad3) + .finish() + } + } + impl ::hash::Hash for semid_ds { + fn hash(&self, state: &mut H) { + let sem_perm = self.sem_perm; + let sem_base = self.sem_base; + let sem_nsems = self.sem_nsems; + let sem_otime = self.sem_otime; + let sem_pad1 = self.sem_pad1; + let sem_ctime = self.sem_ctime; + let sem_pad2 = self.sem_pad2; + let sem_pad3 = self.sem_pad3; + sem_perm.hash(state); + sem_base.hash(state); + sem_nsems.hash(state); + sem_otime.hash(state); + sem_pad1.hash(state); + sem_ctime.hash(state); + sem_pad2.hash(state); + sem_pad3.hash(state); + } + } + + impl PartialEq for shmid_ds { + fn eq(&self, other: &shmid_ds) -> bool { + let shm_perm = self.shm_perm; + let other_shm_perm = other.shm_perm; + shm_perm == other_shm_perm + && self.shm_segsz == other.shm_segsz + && self.shm_lpid == other.shm_lpid + && self.shm_cpid == other.shm_cpid + && self.shm_nattch == other.shm_nattch + && self.shm_atime == other.shm_atime + && self.shm_dtime == other.shm_dtime + && self.shm_ctime == other.shm_ctime + && self.shm_internal == other.shm_internal + } + } + impl Eq for shmid_ds {} + impl ::fmt::Debug for shmid_ds { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let shm_perm = self.shm_perm; + let shm_segsz = self.shm_segsz; + let shm_lpid = self.shm_lpid; + let shm_cpid = self.shm_cpid; + let shm_nattch = self.shm_nattch; + let shm_atime = self.shm_atime; + let shm_dtime = self.shm_dtime; + let shm_ctime = self.shm_ctime; + let shm_internal = self.shm_internal; + f.debug_struct("shmid_ds") + .field("shm_perm", &shm_perm) + .field("shm_segsz", &shm_segsz) + .field("shm_lpid", &shm_lpid) + .field("shm_cpid", &shm_cpid) + .field("shm_nattch", &shm_nattch) + .field("shm_atime", &shm_atime) + .field("shm_dtime", &shm_dtime) + .field("shm_ctime", &shm_ctime) + .field("shm_internal", &shm_internal) + .finish() + } + } + impl ::hash::Hash for shmid_ds { + fn hash(&self, state: &mut H) { + let shm_perm = self.shm_perm; + let shm_segsz = self.shm_segsz; + let shm_lpid = self.shm_lpid; + let shm_cpid = self.shm_cpid; + let shm_nattch = self.shm_nattch; + let shm_atime = self.shm_atime; + let shm_dtime = self.shm_dtime; + let shm_ctime = self.shm_ctime; + let shm_internal = self.shm_internal; + shm_perm.hash(state); + shm_segsz.hash(state); + shm_lpid.hash(state); + shm_cpid.hash(state); + shm_nattch.hash(state); + shm_atime.hash(state); + shm_dtime.hash(state); + shm_ctime.hash(state); + shm_internal.hash(state); + } + } + + impl PartialEq for proc_threadinfo { + fn eq(&self, other: &proc_threadinfo) -> bool { + self.pth_user_time == other.pth_user_time + && self.pth_system_time == other.pth_system_time + && self.pth_cpu_usage == other.pth_cpu_usage + && self.pth_policy == other.pth_policy + && self.pth_run_state == other.pth_run_state + && self.pth_flags == other.pth_flags + && self.pth_sleep_time == other.pth_sleep_time + && self.pth_curpri == other.pth_curpri + && self.pth_priority == other.pth_priority + && self.pth_maxpriority == other.pth_maxpriority + && self.pth_name + .iter() + .zip(other.pth_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for proc_threadinfo {} + impl ::fmt::Debug for proc_threadinfo { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("proc_threadinfo") + .field("pth_user_time", &self.pth_user_time) + .field("pth_system_time", &self.pth_system_time) + .field("pth_cpu_usage", &self.pth_cpu_usage) + .field("pth_policy", &self.pth_policy) + .field("pth_run_state", &self.pth_run_state) + .field("pth_flags", &self.pth_flags) + .field("pth_sleep_time", &self.pth_sleep_time) + .field("pth_curpri", &self.pth_curpri) + .field("pth_priority", &self.pth_priority) + .field("pth_maxpriority", &self.pth_maxpriority) + // FIXME: .field("pth_name", &self.pth_name) + .finish() + } + } + impl ::hash::Hash for proc_threadinfo { + fn hash(&self, state: &mut H) { + self.pth_user_time.hash(state); + self.pth_system_time.hash(state); + self.pth_cpu_usage.hash(state); + self.pth_policy.hash(state); + self.pth_run_state.hash(state); + self.pth_flags.hash(state); + self.pth_sleep_time.hash(state); + self.pth_curpri.hash(state); + self.pth_priority.hash(state); + self.pth_maxpriority.hash(state); + self.pth_name.hash(state); + } + } + + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_fsid == other.f_fsid + && self.f_owner == other.f_owner + && self.f_flags == other.f_flags + && self.f_fssubtype == other.f_fssubtype + && self.f_fstypename == other.f_fstypename + && self.f_type == other.f_type + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self.f_reserved == other.f_reserved + } + } + + impl Eq for statfs {} + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_fsid", &self.f_fsid) + .field("f_owner", &self.f_owner) + .field("f_flags", &self.f_flags) + .field("f_fssubtype", &self.f_fssubtype) + .field("f_fstypename", &self.f_fstypename) + .field("f_type", &self.f_type) + // FIXME: .field("f_mntonname", &self.f_mntonname) + // FIXME: .field("f_mntfromname", &self.f_mntfromname) + .field("f_reserved", &self.f_reserved) + .finish() + } + } + + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_fsid.hash(state); + self.f_owner.hash(state); + self.f_flags.hash(state); + self.f_fssubtype.hash(state); + self.f_fstypename.hash(state); + self.f_type.hash(state); + self.f_mntonname.hash(state); + self.f_mntfromname.hash(state); + self.f_reserved.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_seekoff == other.d_seekoff + && self.d_reclen == other.d_reclen + && self.d_namlen == other.d_namlen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_seekoff", &self.d_seekoff) + .field("d_reclen", &self.d_reclen) + .field("d_namlen", &self.d_namlen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_seekoff.hash(state); + self.d_reclen.hash(state); + self.d_namlen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + self.__sig == other.__sig + && self. + __opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_rwlock_t {} + impl ::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_rwlock_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } + } + impl ::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } + + impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + self.__sig == other.__sig + && self. + __opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for pthread_mutex_t {} + + impl ::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_mutex_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } + } + + impl ::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } + + impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.__sig == other.__sig + && self. + __opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for pthread_cond_t {} + + impl ::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_cond_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } + } + + impl ::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_len == other.ss_len + && self.ss_family == other.ss_family + && self + .__ss_pad1 + .iter() + .zip(other.__ss_pad1.iter()) + .all(|(a, b)| a == b) + && self.__ss_align == other.__ss_align + && self + .__ss_pad2 + .iter() + .zip(other.__ss_pad2.iter()) + .all(|(a, b)| a == b) + } + } + + impl Eq for sockaddr_storage {} + + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_len", &self.ss_len) + .field("ss_family", &self.ss_family) + .field("__ss_pad1", &self.__ss_pad1) + .field("__ss_align", &self.__ss_align) + // FIXME: .field("__ss_pad2", &self.__ss_pad2) + .finish() + } + } + + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_len.hash(state); + self.ss_family.hash(state); + self.__ss_pad1.hash(state); + self.__ss_align.hash(state); + self.__ss_pad2.hash(state); + } + } + + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_user + .iter() + .zip(other.ut_user.iter()) + .all(|(a,b)| a == b) + && self.ut_id == other.ut_id + && self.ut_line == other.ut_line + && self.ut_pid == other.ut_pid + && self.ut_type == other.ut_type + && self.ut_tv == other.ut_tv + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self.ut_pad == other.ut_pad + } + } + + impl Eq for utmpx {} + + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmpx") + // FIXME: .field("ut_user", &self.ut_user) + .field("ut_id", &self.ut_id) + .field("ut_line", &self.ut_line) + .field("ut_pid", &self.ut_pid) + .field("ut_type", &self.ut_type) + .field("ut_tv", &self.ut_tv) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_pad", &self.ut_pad) + .finish() + } + } + + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_user.hash(state); + self.ut_id.hash(state); + self.ut_line.hash(state); + self.ut_pid.hash(state); + self.ut_type.hash(state); + self.ut_tv.hash(state); + self.ut_host.hash(state); + self.ut_pad.hash(state); + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_notify == other.sigev_notify + && self.sigev_signo == other.sigev_signo + && self.sigev_value == other.sigev_value + && self.sigev_notify_attributes + == other.sigev_notify_attributes + } + } + + impl Eq for sigevent {} + + impl ::fmt::Debug for sigevent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sigevent") + .field("sigev_notify", &self.sigev_notify) + .field("sigev_signo", &self.sigev_signo) + .field("sigev_value", &self.sigev_value) + .field("sigev_notify_attributes", + &self.sigev_notify_attributes) + .finish() + } + } + + impl ::hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_notify.hash(state); + self.sigev_signo.hash(state); + self.sigev_value.hash(state); + self.sigev_notify_attributes.hash(state); + } + } + } +} + +pub const _UTX_USERSIZE: usize = 256; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 256; + +pub const EMPTY: ::c_short = 0; +pub const RUN_LVL: ::c_short = 1; +pub const BOOT_TIME: ::c_short = 2; +pub const OLD_TIME: ::c_short = 3; +pub const NEW_TIME: ::c_short = 4; +pub const INIT_PROCESS: ::c_short = 5; +pub const LOGIN_PROCESS: ::c_short = 6; +pub const USER_PROCESS: ::c_short = 7; +pub const DEAD_PROCESS: ::c_short = 8; +pub const ACCOUNTING: ::c_short = 9; +pub const SIGNATURE: ::c_short = 10; +pub const SHUTDOWN_TIME: ::c_short = 11; + +pub const LC_COLLATE_MASK: ::c_int = (1 << 0); +pub const LC_CTYPE_MASK: ::c_int = (1 << 1); +pub const LC_MESSAGES_MASK: ::c_int = (1 << 2); +pub const LC_MONETARY_MASK: ::c_int = (1 << 3); +pub const LC_NUMERIC_MASK: ::c_int = (1 << 4); +pub const LC_TIME_MASK: ::c_int = (1 << 5); +pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK + | LC_CTYPE_MASK + | LC_MESSAGES_MASK + | LC_MONETARY_MASK + | LC_NUMERIC_MASK + | LC_TIME_MASK; + +pub const CODESET: ::nl_item = 0; +pub const D_T_FMT: ::nl_item = 1; +pub const D_FMT: ::nl_item = 2; +pub const T_FMT: ::nl_item = 3; +pub const T_FMT_AMPM: ::nl_item = 4; +pub const AM_STR: ::nl_item = 5; +pub const PM_STR: ::nl_item = 6; + +pub const DAY_1: ::nl_item = 7; +pub const DAY_2: ::nl_item = 8; +pub const DAY_3: ::nl_item = 9; +pub const DAY_4: ::nl_item = 10; +pub const DAY_5: ::nl_item = 11; +pub const DAY_6: ::nl_item = 12; +pub const DAY_7: ::nl_item = 13; + +pub const ABDAY_1: ::nl_item = 14; +pub const ABDAY_2: ::nl_item = 15; +pub const ABDAY_3: ::nl_item = 16; +pub const ABDAY_4: ::nl_item = 17; +pub const ABDAY_5: ::nl_item = 18; +pub const ABDAY_6: ::nl_item = 19; +pub const ABDAY_7: ::nl_item = 20; + +pub const MON_1: ::nl_item = 21; +pub const MON_2: ::nl_item = 22; +pub const MON_3: ::nl_item = 23; +pub const MON_4: ::nl_item = 24; +pub const MON_5: ::nl_item = 25; +pub const MON_6: ::nl_item = 26; +pub const MON_7: ::nl_item = 27; +pub const MON_8: ::nl_item = 28; +pub const MON_9: ::nl_item = 29; +pub const MON_10: ::nl_item = 30; +pub const MON_11: ::nl_item = 31; +pub const MON_12: ::nl_item = 32; + +pub const ABMON_1: ::nl_item = 33; +pub const ABMON_2: ::nl_item = 34; +pub const ABMON_3: ::nl_item = 35; +pub const ABMON_4: ::nl_item = 36; +pub const ABMON_5: ::nl_item = 37; +pub const ABMON_6: ::nl_item = 38; +pub const ABMON_7: ::nl_item = 39; +pub const ABMON_8: ::nl_item = 40; +pub const ABMON_9: ::nl_item = 41; +pub const ABMON_10: ::nl_item = 42; +pub const ABMON_11: ::nl_item = 43; +pub const ABMON_12: ::nl_item = 44; + +pub const CLOCK_REALTIME: ::clockid_t = 0; +pub const CLOCK_MONOTONIC: ::clockid_t = 6; +pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 12; +pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 16; + +pub const ERA: ::nl_item = 45; +pub const ERA_D_FMT: ::nl_item = 46; +pub const ERA_D_T_FMT: ::nl_item = 47; +pub const ERA_T_FMT: ::nl_item = 48; +pub const ALT_DIGITS: ::nl_item = 49; + +pub const RADIXCHAR: ::nl_item = 50; +pub const THOUSEP: ::nl_item = 51; + +pub const YESEXPR: ::nl_item = 52; +pub const NOEXPR: ::nl_item = 53; + +pub const YESSTR: ::nl_item = 54; +pub const NOSTR: ::nl_item = 55; + +pub const CRNCYSTR: ::nl_item = 56; + +pub const D_MD_ORDER: ::nl_item = 57; + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 2147483647; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 2; +pub const _IOLBF: ::c_int = 1; +pub const BUFSIZ: ::c_uint = 1024; +pub const FOPEN_MAX: ::c_uint = 20; +pub const FILENAME_MAX: ::c_uint = 1024; +pub const L_tmpnam: ::c_uint = 1024; +pub const TMP_MAX: ::c_uint = 308915776; +pub const _PC_LINK_MAX: ::c_int = 1; +pub const _PC_MAX_CANON: ::c_int = 2; +pub const _PC_MAX_INPUT: ::c_int = 3; +pub const _PC_NAME_MAX: ::c_int = 4; +pub const _PC_PATH_MAX: ::c_int = 5; +pub const _PC_PIPE_BUF: ::c_int = 6; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 7; +pub const _PC_NO_TRUNC: ::c_int = 8; +pub const _PC_VDISABLE: ::c_int = 9; +pub const O_DSYNC: ::c_int = 0x400000; +pub const O_NOCTTY: ::c_int = 0x20000; +pub const O_CLOEXEC: ::c_int = 0x1000000; +pub const O_DIRECTORY: ::c_int = 0x100000; +pub const S_IFIFO: mode_t = 4096; +pub const S_IFCHR: mode_t = 8192; +pub const S_IFBLK: mode_t = 24576; +pub const S_IFDIR: mode_t = 16384; +pub const S_IFREG: mode_t = 32768; +pub const S_IFLNK: mode_t = 40960; +pub const S_IFSOCK: mode_t = 49152; +pub const S_IFMT: mode_t = 61440; +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; +pub const S_IRWXU: mode_t = 448; +pub const S_IXUSR: mode_t = 64; +pub const S_IWUSR: mode_t = 128; +pub const S_IRUSR: mode_t = 256; +pub const S_IRWXG: mode_t = 56; +pub const S_IXGRP: mode_t = 8; +pub const S_IWGRP: mode_t = 16; +pub const S_IRGRP: mode_t = 32; +pub const S_IRWXO: mode_t = 7; +pub const S_IXOTH: mode_t = 1; +pub const S_IWOTH: mode_t = 2; +pub const S_IROTH: mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; +pub const F_GETLK: ::c_int = 7; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGEMT: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const PT_TRACE_ME: ::c_int = 0; +pub const PT_READ_I: ::c_int = 1; +pub const PT_READ_D: ::c_int = 2; +pub const PT_READ_U: ::c_int = 3; +pub const PT_WRITE_I: ::c_int = 4; +pub const PT_WRITE_D: ::c_int = 5; +pub const PT_WRITE_U: ::c_int = 6; +pub const PT_CONTINUE: ::c_int = 7; +pub const PT_KILL: ::c_int = 8; +pub const PT_STEP: ::c_int = 9; +pub const PT_ATTACH: ::c_int = 10; +pub const PT_DETACH: ::c_int = 11; +pub const PT_SIGEXC: ::c_int = 12; +pub const PT_THUPDATE: ::c_int = 13; +pub const PT_ATTACHEXC: ::c_int = 14; + +pub const PT_FORCEQUOTA: ::c_int = 30; +pub const PT_DENY_ATTACH: ::c_int = 31; +pub const PT_FIRSTMACH: ::c_int = 32; + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_ANON: ::c_int = 0x1000; +pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; + +deprecated_mach! { + pub const VM_FLAGS_FIXED: ::c_int = 0x0000; + pub const VM_FLAGS_ANYWHERE: ::c_int = 0x0001; + pub const VM_FLAGS_PURGABLE: ::c_int = 0x0002; + pub const VM_FLAGS_RANDOM_ADDR: ::c_int = 0x0008; + pub const VM_FLAGS_NO_CACHE: ::c_int = 0x0010; + pub const VM_FLAGS_RESILIENT_CODESIGN: ::c_int = 0x0020; + pub const VM_FLAGS_RESILIENT_MEDIA: ::c_int = 0x0040; + pub const VM_FLAGS_OVERWRITE: ::c_int = 0x4000; + pub const VM_FLAGS_SUPERPAGE_MASK: ::c_int = 0x70000; + pub const VM_FLAGS_RETURN_DATA_ADDR: ::c_int = 0x100000; + pub const VM_FLAGS_RETURN_4K_DATA_ADDR: ::c_int = 0x800000; + pub const VM_FLAGS_ALIAS_MASK: ::c_int = 0xFF000000; + pub const VM_FLAGS_USER_ALLOCATE: ::c_int = 0xff07401f; + pub const VM_FLAGS_USER_MAP: ::c_int = 0xff97401f; + pub const VM_FLAGS_USER_REMAP: ::c_int = VM_FLAGS_FIXED | + VM_FLAGS_ANYWHERE | + VM_FLAGS_RANDOM_ADDR | + VM_FLAGS_OVERWRITE | + VM_FLAGS_RETURN_DATA_ADDR | + VM_FLAGS_RESILIENT_CODESIGN; + + pub const VM_FLAGS_SUPERPAGE_SHIFT: ::c_int = 16; + pub const SUPERPAGE_NONE: ::c_int = 0; + pub const SUPERPAGE_SIZE_ANY: ::c_int = 1; + pub const VM_FLAGS_SUPERPAGE_NONE: ::c_int = SUPERPAGE_NONE << + VM_FLAGS_SUPERPAGE_SHIFT; + pub const VM_FLAGS_SUPERPAGE_SIZE_ANY: ::c_int = SUPERPAGE_SIZE_ANY << + VM_FLAGS_SUPERPAGE_SHIFT; + pub const SUPERPAGE_SIZE_2MB: ::c_int = 2; + pub const VM_FLAGS_SUPERPAGE_SIZE_2MB: ::c_int = SUPERPAGE_SIZE_2MB << + VM_FLAGS_SUPERPAGE_SHIFT; + + pub const VM_MEMORY_MALLOC: ::c_int = 1; + pub const VM_MEMORY_MALLOC_SMALL: ::c_int = 2; + pub const VM_MEMORY_MALLOC_LARGE: ::c_int = 3; + pub const VM_MEMORY_MALLOC_HUGE: ::c_int = 4; + pub const VM_MEMORY_SBRK: ::c_int = 5; + pub const VM_MEMORY_REALLOC: ::c_int = 6; + pub const VM_MEMORY_MALLOC_TINY: ::c_int = 7; + pub const VM_MEMORY_MALLOC_LARGE_REUSABLE: ::c_int = 8; + pub const VM_MEMORY_MALLOC_LARGE_REUSED: ::c_int = 9; + pub const VM_MEMORY_ANALYSIS_TOOL: ::c_int = 10; + pub const VM_MEMORY_MALLOC_NANO: ::c_int = 11; + pub const VM_MEMORY_MACH_MSG: ::c_int = 20; + pub const VM_MEMORY_IOKIT: ::c_int = 21; + pub const VM_MEMORY_STACK: ::c_int = 30; + pub const VM_MEMORY_GUARD: ::c_int = 31; + pub const VM_MEMORY_SHARED_PMAP: ::c_int = 32; + pub const VM_MEMORY_DYLIB: ::c_int = 33; + pub const VM_MEMORY_OBJC_DISPATCHERS: ::c_int = 34; + pub const VM_MEMORY_UNSHARED_PMAP: ::c_int = 35; + pub const VM_MEMORY_APPKIT: ::c_int = 40; + pub const VM_MEMORY_FOUNDATION: ::c_int = 41; + pub const VM_MEMORY_COREGRAPHICS: ::c_int = 42; + pub const VM_MEMORY_CORESERVICES: ::c_int = 43; + pub const VM_MEMORY_CARBON: ::c_int = VM_MEMORY_CORESERVICES; + pub const VM_MEMORY_JAVA: ::c_int = 44; + pub const VM_MEMORY_COREDATA: ::c_int = 45; + pub const VM_MEMORY_COREDATA_OBJECTIDS: ::c_int = 46; + pub const VM_MEMORY_ATS: ::c_int = 50; + pub const VM_MEMORY_LAYERKIT: ::c_int = 51; + pub const VM_MEMORY_CGIMAGE: ::c_int = 52; + pub const VM_MEMORY_TCMALLOC: ::c_int = 53; + pub const VM_MEMORY_COREGRAPHICS_DATA: ::c_int = 54; + pub const VM_MEMORY_COREGRAPHICS_SHARED: ::c_int = 55; + pub const VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS: ::c_int = 56; + pub const VM_MEMORY_COREGRAPHICS_BACKINGSTORES: ::c_int = 57; + pub const VM_MEMORY_COREGRAPHICS_XALLOC: ::c_int = 58; + pub const VM_MEMORY_COREGRAPHICS_MISC: ::c_int = VM_MEMORY_COREGRAPHICS; + pub const VM_MEMORY_DYLD: ::c_int = 60; + pub const VM_MEMORY_DYLD_MALLOC: ::c_int = 61; + pub const VM_MEMORY_SQLITE: ::c_int = 62; + pub const VM_MEMORY_JAVASCRIPT_CORE: ::c_int = 63; + pub const VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR: ::c_int = 64; + pub const VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE: ::c_int = 65; + pub const VM_MEMORY_GLSL: ::c_int = 66; + pub const VM_MEMORY_OPENCL: ::c_int = 67; + pub const VM_MEMORY_COREIMAGE: ::c_int = 68; + pub const VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS: ::c_int = 69; + pub const VM_MEMORY_IMAGEIO: ::c_int = 70; + pub const VM_MEMORY_COREPROFILE: ::c_int = 71; + pub const VM_MEMORY_ASSETSD: ::c_int = 72; + pub const VM_MEMORY_OS_ALLOC_ONCE: ::c_int = 73; + pub const VM_MEMORY_LIBDISPATCH: ::c_int = 74; + pub const VM_MEMORY_ACCELERATE: ::c_int = 75; + pub const VM_MEMORY_COREUI: ::c_int = 76; + pub const VM_MEMORY_COREUIFILE: ::c_int = 77; + pub const VM_MEMORY_GENEALOGY: ::c_int = 78; + pub const VM_MEMORY_RAWCAMERA: ::c_int = 79; + pub const VM_MEMORY_CORPSEINFO: ::c_int = 80; + pub const VM_MEMORY_ASL: ::c_int = 81; + pub const VM_MEMORY_SWIFT_RUNTIME: ::c_int = 82; + pub const VM_MEMORY_SWIFT_METADATA: ::c_int = 83; + pub const VM_MEMORY_DHMM: ::c_int = 84; + pub const VM_MEMORY_SCENEKIT: ::c_int = 86; + pub const VM_MEMORY_SKYWALK: ::c_int = 87; + pub const VM_MEMORY_APPLICATION_SPECIFIC_1: ::c_int = 240; + pub const VM_MEMORY_APPLICATION_SPECIFIC_16: ::c_int = 255; +} + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MS_SYNC: ::c_int = 0x0010; + +pub const MS_KILLPAGES: ::c_int = 0x0004; +pub const MS_DEACTIVATE: ::c_int = 0x0008; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EDEADLK: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const EAGAIN: ::c_int = 35; +pub const EWOULDBLOCK: ::c_int = EAGAIN; +pub const EINPROGRESS: ::c_int = 36; +pub const EALREADY: ::c_int = 37; +pub const ENOTSOCK: ::c_int = 38; +pub const EDESTADDRREQ: ::c_int = 39; +pub const EMSGSIZE: ::c_int = 40; +pub const EPROTOTYPE: ::c_int = 41; +pub const ENOPROTOOPT: ::c_int = 42; +pub const EPROTONOSUPPORT: ::c_int = 43; +pub const ESOCKTNOSUPPORT: ::c_int = 44; +pub const ENOTSUP: ::c_int = 45; +pub const EPFNOSUPPORT: ::c_int = 46; +pub const EAFNOSUPPORT: ::c_int = 47; +pub const EADDRINUSE: ::c_int = 48; +pub const EADDRNOTAVAIL: ::c_int = 49; +pub const ENETDOWN: ::c_int = 50; +pub const ENETUNREACH: ::c_int = 51; +pub const ENETRESET: ::c_int = 52; +pub const ECONNABORTED: ::c_int = 53; +pub const ECONNRESET: ::c_int = 54; +pub const ENOBUFS: ::c_int = 55; +pub const EISCONN: ::c_int = 56; +pub const ENOTCONN: ::c_int = 57; +pub const ESHUTDOWN: ::c_int = 58; +pub const ETOOMANYREFS: ::c_int = 59; +pub const ETIMEDOUT: ::c_int = 60; +pub const ECONNREFUSED: ::c_int = 61; +pub const ELOOP: ::c_int = 62; +pub const ENAMETOOLONG: ::c_int = 63; +pub const EHOSTDOWN: ::c_int = 64; +pub const EHOSTUNREACH: ::c_int = 65; +pub const ENOTEMPTY: ::c_int = 66; +pub const EPROCLIM: ::c_int = 67; +pub const EUSERS: ::c_int = 68; +pub const EDQUOT: ::c_int = 69; +pub const ESTALE: ::c_int = 70; +pub const EREMOTE: ::c_int = 71; +pub const EBADRPC: ::c_int = 72; +pub const ERPCMISMATCH: ::c_int = 73; +pub const EPROGUNAVAIL: ::c_int = 74; +pub const EPROGMISMATCH: ::c_int = 75; +pub const EPROCUNAVAIL: ::c_int = 76; +pub const ENOLCK: ::c_int = 77; +pub const ENOSYS: ::c_int = 78; +pub const EFTYPE: ::c_int = 79; +pub const EAUTH: ::c_int = 80; +pub const ENEEDAUTH: ::c_int = 81; +pub const EPWROFF: ::c_int = 82; +pub const EDEVERR: ::c_int = 83; +pub const EOVERFLOW: ::c_int = 84; +pub const EBADEXEC: ::c_int = 85; +pub const EBADARCH: ::c_int = 86; +pub const ESHLIBVERS: ::c_int = 87; +pub const EBADMACHO: ::c_int = 88; +pub const ECANCELED: ::c_int = 89; +pub const EIDRM: ::c_int = 90; +pub const ENOMSG: ::c_int = 91; +pub const EILSEQ: ::c_int = 92; +pub const ENOATTR: ::c_int = 93; +pub const EBADMSG: ::c_int = 94; +pub const EMULTIHOP: ::c_int = 95; +pub const ENODATA: ::c_int = 96; +pub const ENOLINK: ::c_int = 97; +pub const ENOSR: ::c_int = 98; +pub const ENOSTR: ::c_int = 99; +pub const EPROTO: ::c_int = 100; +pub const ETIME: ::c_int = 101; +pub const EOPNOTSUPP: ::c_int = 102; +pub const ENOPOLICY: ::c_int = 103; +pub const ENOTRECOVERABLE: ::c_int = 104; +pub const EOWNERDEAD: ::c_int = 105; +pub const EQFULL: ::c_int = 106; +pub const ELAST: ::c_int = 106; + +pub const EAI_AGAIN: ::c_int = 2; +pub const EAI_BADFLAGS: ::c_int = 3; +pub const EAI_FAIL: ::c_int = 4; +pub const EAI_FAMILY: ::c_int = 5; +pub const EAI_MEMORY: ::c_int = 6; +pub const EAI_NODATA: ::c_int = 7; +pub const EAI_NONAME: ::c_int = 8; +pub const EAI_SERVICE: ::c_int = 9; +pub const EAI_SOCKTYPE: ::c_int = 10; +pub const EAI_SYSTEM: ::c_int = 11; +pub const EAI_OVERFLOW: ::c_int = 14; + +pub const F_DUPFD: ::c_int = 0; +pub const F_DUPFD_CLOEXEC: ::c_int = 67; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; +pub const F_PREALLOCATE: ::c_int = 42; +pub const F_RDADVISE: ::c_int = 44; +pub const F_RDAHEAD: ::c_int = 45; +pub const F_NOCACHE: ::c_int = 48; +pub const F_GETPATH: ::c_int = 50; +pub const F_FULLFSYNC: ::c_int = 51; +pub const F_FREEZE_FS: ::c_int = 53; +pub const F_THAW_FS: ::c_int = 54; +pub const F_GLOBAL_NOCACHE: ::c_int = 55; +pub const F_NODIRECT: ::c_int = 62; + +pub const F_ALLOCATECONTIG: ::c_uint = 0x02; +pub const F_ALLOCATEALL: ::c_uint = 0x04; + +pub const F_PEOFPOSMODE: ::c_int = 3; +pub const F_VOLPOSMODE: ::c_int = 4; + +pub const AT_FDCWD: ::c_int = -2; +pub const AT_EACCESS: ::c_int = 0x0010; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x0020; +pub const AT_SYMLINK_FOLLOW: ::c_int = 0x0040; +pub const AT_REMOVEDIR: ::c_int = 0x0080; + +pub const TIOCMODG: ::c_ulong = 0x40047403; +pub const TIOCMODS: ::c_ulong = 0x80047404; +pub const TIOCM_LE: ::c_int = 0x1; +pub const TIOCM_DTR: ::c_int = 0x2; +pub const TIOCM_RTS: ::c_int = 0x4; +pub const TIOCM_ST: ::c_int = 0x8; +pub const TIOCM_SR: ::c_int = 0x10; +pub const TIOCM_CTS: ::c_int = 0x20; +pub const TIOCM_CAR: ::c_int = 0x40; +pub const TIOCM_CD: ::c_int = 0x40; +pub const TIOCM_RNG: ::c_int = 0x80; +pub const TIOCM_RI: ::c_int = 0x80; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCEXCL: ::c_int = 0x2000740d; +pub const TIOCNXCL: ::c_int = 0x2000740e; +pub const TIOCFLUSH: ::c_ulong = 0x80047410; +pub const TIOCGETD: ::c_ulong = 0x4004741a; +pub const TIOCSETD: ::c_ulong = 0x8004741b; +pub const TIOCIXON: ::c_uint = 0x20007481; +pub const TIOCIXOFF: ::c_uint = 0x20007480; +pub const TIOCSBRK: ::c_uint = 0x2000747b; +pub const TIOCCBRK: ::c_uint = 0x2000747a; +pub const TIOCSDTR: ::c_uint = 0x20007479; +pub const TIOCCDTR: ::c_uint = 0x20007478; +pub const TIOCGPGRP: ::c_ulong = 0x40047477; +pub const TIOCSPGRP: ::c_ulong = 0x80047476; +pub const TIOCOUTQ: ::c_ulong = 0x40047473; +pub const TIOCSTI: ::c_ulong = 0x80017472; +pub const TIOCNOTTY: ::c_uint = 0x20007471; +pub const TIOCPKT: ::c_ulong = 0x80047470; +pub const TIOCPKT_DATA: ::c_int = 0x0; +pub const TIOCPKT_FLUSHREAD: ::c_int = 0x1; +pub const TIOCPKT_FLUSHWRITE: ::c_int = 0x2; +pub const TIOCPKT_STOP: ::c_int = 0x4; +pub const TIOCPKT_START: ::c_int = 0x8; +pub const TIOCPKT_NOSTOP: ::c_int = 0x10; +pub const TIOCPKT_DOSTOP: ::c_int = 0x20; +pub const TIOCPKT_IOCTL: ::c_int = 0x40; +pub const TIOCSTOP: ::c_uint = 0x2000746f; +pub const TIOCSTART: ::c_uint = 0x2000746e; +pub const TIOCMSET: ::c_ulong = 0x8004746d; +pub const TIOCMBIS: ::c_ulong = 0x8004746c; +pub const TIOCMBIC: ::c_ulong = 0x8004746b; +pub const TIOCMGET: ::c_ulong = 0x4004746a; +pub const TIOCREMOTE: ::c_ulong = 0x80047469; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const TIOCUCNTL: ::c_ulong = 0x80047466; +pub const TIOCSTAT: ::c_uint = 0x20007465; +pub const TIOCSCONS: ::c_uint = 0x20007463; +pub const TIOCCONS: ::c_ulong = 0x80047462; +pub const TIOCSCTTY: ::c_uint = 0x20007461; +pub const TIOCEXT: ::c_ulong = 0x80047460; +pub const TIOCSIG: ::c_uint = 0x2000745f; +pub const TIOCDRAIN: ::c_uint = 0x2000745e; +pub const TIOCMSDTRWAIT: ::c_ulong = 0x8004745b; +pub const TIOCMGDTRWAIT: ::c_ulong = 0x4004745a; +pub const TIOCSDRAINWAIT: ::c_ulong = 0x80047457; +pub const TIOCGDRAINWAIT: ::c_ulong = 0x40047456; +pub const TIOCDSIMICROCODE: ::c_uint = 0x20007455; +pub const TIOCPTYGRANT: ::c_uint = 0x20007454; +pub const TIOCPTYGNAME: ::c_uint = 0x40807453; +pub const TIOCPTYUNLK: ::c_uint = 0x20007452; + +pub const BIOCGRSIG: ::c_ulong = 0x40044272; +pub const BIOCSRSIG: ::c_ulong = 0x80044273; +pub const BIOCSDLT: ::c_ulong = 0x80044278; +pub const BIOCGSEESENT: ::c_ulong = 0x40044276; +pub const BIOCSSEESENT: ::c_ulong = 0x80044277; +pub const BIOCGDLTLIST: ::c_ulong = 0xc00c4279; + +pub const FIODTYPE: ::c_ulong = 0x4004667a; + +pub const B0: speed_t = 0; +pub const B50: speed_t = 50; +pub const B75: speed_t = 75; +pub const B110: speed_t = 110; +pub const B134: speed_t = 134; +pub const B150: speed_t = 150; +pub const B200: speed_t = 200; +pub const B300: speed_t = 300; +pub const B600: speed_t = 600; +pub const B1200: speed_t = 1200; +pub const B1800: speed_t = 1800; +pub const B2400: speed_t = 2400; +pub const B4800: speed_t = 4800; +pub const B9600: speed_t = 9600; +pub const B19200: speed_t = 19200; +pub const B38400: speed_t = 38400; +pub const B7200: speed_t = 7200; +pub const B14400: speed_t = 14400; +pub const B28800: speed_t = 28800; +pub const B57600: speed_t = 57600; +pub const B76800: speed_t = 76800; +pub const B115200: speed_t = 115200; +pub const B230400: speed_t = 230400; +pub const EXTA: speed_t = 19200; +pub const EXTB: speed_t = 38400; + +pub const SIGTRAP: ::c_int = 5; + +pub const GLOB_APPEND: ::c_int = 0x0001; +pub const GLOB_DOOFFS: ::c_int = 0x0002; +pub const GLOB_ERR: ::c_int = 0x0004; +pub const GLOB_MARK: ::c_int = 0x0008; +pub const GLOB_NOCHECK: ::c_int = 0x0010; +pub const GLOB_NOSORT: ::c_int = 0x0020; +pub const GLOB_NOESCAPE: ::c_int = 0x2000; + +pub const GLOB_NOSPACE: ::c_int = -1; +pub const GLOB_ABORTED: ::c_int = -2; +pub const GLOB_NOMATCH: ::c_int = -3; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + +pub const _SC_IOV_MAX: ::c_int = 56; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; +pub const _SC_MQ_PRIO_MAX: ::c_int = 75; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 82; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 83; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 85; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 86; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 87; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 88; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 89; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 90; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 91; +pub const _SC_THREAD_STACK_MIN: ::c_int = 93; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 94; +pub const _SC_THREADS: ::c_int = 96; +pub const _SC_TTY_NAME_MAX: ::c_int = 101; +pub const _SC_ATEXIT_MAX: ::c_int = 107; +pub const _SC_XOPEN_CRYPT: ::c_int = 108; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 109; +pub const _SC_XOPEN_LEGACY: ::c_int = 110; +pub const _SC_XOPEN_REALTIME: ::c_int = 111; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 112; +pub const _SC_XOPEN_SHM: ::c_int = 113; +pub const _SC_XOPEN_UNIX: ::c_int = 115; +pub const _SC_XOPEN_VERSION: ::c_int = 116; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 121; +pub const _SC_PHYS_PAGES: ::c_int = 200; + +pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 2; +pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 1; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 2; +pub const PTHREAD_STACK_MIN: ::size_t = 8192; + +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_AS: ::c_int = 5; +pub const RLIMIT_RSS: ::c_int = RLIMIT_AS; +pub const RLIMIT_MEMLOCK: ::c_int = 6; +pub const RLIMIT_NPROC: ::c_int = 7; +pub const RLIMIT_NOFILE: ::c_int = 8; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: ::c_int = 9; +pub const _RLIMIT_POSIX_FLAG: ::c_int = 0x1000; + +pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + +pub const RUSAGE_SELF: ::c_int = 0; +pub const RUSAGE_CHILDREN: ::c_int = -1; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_FREE: ::c_int = 5; +pub const MADV_ZERO_WIRED_PAGES: ::c_int = 6; +pub const MADV_FREE_REUSABLE: ::c_int = 7; +pub const MADV_FREE_REUSE: ::c_int = 8; +pub const MADV_CAN_REUSE: ::c_int = 9; + +pub const MINCORE_INCORE: ::c_int = 0x1; +pub const MINCORE_REFERENCED: ::c_int = 0x2; +pub const MINCORE_MODIFIED: ::c_int = 0x4; +pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; +pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; + +// +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// IP6 hop-by-hop options +pub const IPPROTO_HOPOPTS: ::c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: ::c_int = 2; +/// gateway2 (deprecated) +pub const IPPROTO_GGP: ::c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: ::c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// Stream protocol II. +pub const IPPROTO_ST: ::c_int = 7; +/// exterior gateway protocol +pub const IPPROTO_EGP: ::c_int = 8; +/// private interior gateway +pub const IPPROTO_PIGP: ::c_int = 9; +/// BBN RCC Monitoring +pub const IPPROTO_RCCMON: ::c_int = 10; +/// network voice protocol +pub const IPPROTO_NVPII: ::c_int = 11; +/// pup +pub const IPPROTO_PUP: ::c_int = 12; +/// Argus +pub const IPPROTO_ARGUS: ::c_int = 13; +/// EMCON +pub const IPPROTO_EMCON: ::c_int = 14; +/// Cross Net Debugger +pub const IPPROTO_XNET: ::c_int = 15; +/// Chaos +pub const IPPROTO_CHAOS: ::c_int = 16; +// IPPROTO_UDP defined in src/unix/mod.rs +/// Multiplexing +pub const IPPROTO_MUX: ::c_int = 18; +/// DCN Measurement Subsystems +pub const IPPROTO_MEAS: ::c_int = 19; +/// Host Monitoring +pub const IPPROTO_HMP: ::c_int = 20; +/// Packet Radio Measurement +pub const IPPROTO_PRM: ::c_int = 21; +/// xns idp +pub const IPPROTO_IDP: ::c_int = 22; +/// Trunk-1 +pub const IPPROTO_TRUNK1: ::c_int = 23; +/// Trunk-2 +pub const IPPROTO_TRUNK2: ::c_int = 24; +/// Leaf-1 +pub const IPPROTO_LEAF1: ::c_int = 25; +/// Leaf-2 +pub const IPPROTO_LEAF2: ::c_int = 26; +/// Reliable Data +pub const IPPROTO_RDP: ::c_int = 27; +/// Reliable Transaction +pub const IPPROTO_IRTP: ::c_int = 28; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: ::c_int = 29; +/// Bulk Data Transfer +pub const IPPROTO_BLT: ::c_int = 30; +/// Network Services +pub const IPPROTO_NSP: ::c_int = 31; +/// Merit Internodal +pub const IPPROTO_INP: ::c_int = 32; +/// Sequential Exchange +pub const IPPROTO_SEP: ::c_int = 33; +/// Third Party Connect +pub const IPPROTO_3PC: ::c_int = 34; +/// InterDomain Policy Routing +pub const IPPROTO_IDPR: ::c_int = 35; +/// XTP +pub const IPPROTO_XTP: ::c_int = 36; +/// Datagram Delivery +pub const IPPROTO_DDP: ::c_int = 37; +/// Control Message Transport +pub const IPPROTO_CMTP: ::c_int = 38; +/// TP++ Transport +pub const IPPROTO_TPXX: ::c_int = 39; +/// IL transport protocol +pub const IPPROTO_IL: ::c_int = 40; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// Source Demand Routing +pub const IPPROTO_SDRP: ::c_int = 42; +/// IP6 routing header +pub const IPPROTO_ROUTING: ::c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: ::c_int = 44; +/// InterDomain Routing +pub const IPPROTO_IDRP: ::c_int = 45; +/// resource reservation +pub const IPPROTO_RSVP: ::c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: ::c_int = 47; +/// Mobile Host Routing +pub const IPPROTO_MHRP: ::c_int = 48; +/// BHA +pub const IPPROTO_BHA: ::c_int = 49; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: ::c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: ::c_int = 51; +/// Integ. Net Layer Security +pub const IPPROTO_INLSP: ::c_int = 52; +/// IP with encryption +pub const IPPROTO_SWIPE: ::c_int = 53; +/// Next Hop Resolution +pub const IPPROTO_NHRP: ::c_int = 54; +/* 55-57: Unassigned */ +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: ::c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: ::c_int = 60; +/// any host internal protocol +pub const IPPROTO_AHIP: ::c_int = 61; +/// CFTP +pub const IPPROTO_CFTP: ::c_int = 62; +/// "hello" routing protocol +pub const IPPROTO_HELLO: ::c_int = 63; +/// SATNET/Backroom EXPAK +pub const IPPROTO_SATEXPAK: ::c_int = 64; +/// Kryptolan +pub const IPPROTO_KRYPTOLAN: ::c_int = 65; +/// Remote Virtual Disk +pub const IPPROTO_RVD: ::c_int = 66; +/// Pluribus Packet Core +pub const IPPROTO_IPPC: ::c_int = 67; +/// Any distributed FS +pub const IPPROTO_ADFS: ::c_int = 68; +/// Satnet Monitoring +pub const IPPROTO_SATMON: ::c_int = 69; +/// VISA Protocol +pub const IPPROTO_VISA: ::c_int = 70; +/// Packet Core Utility +pub const IPPROTO_IPCV: ::c_int = 71; +/// Comp. Prot. Net. Executive +pub const IPPROTO_CPNX: ::c_int = 72; +/// Comp. Prot. HeartBeat +pub const IPPROTO_CPHB: ::c_int = 73; +/// Wang Span Network +pub const IPPROTO_WSN: ::c_int = 74; +/// Packet Video Protocol +pub const IPPROTO_PVP: ::c_int = 75; +/// BackRoom SATNET Monitoring +pub const IPPROTO_BRSATMON: ::c_int = 76; +/// Sun net disk proto (temp.) +pub const IPPROTO_ND: ::c_int = 77; +/// WIDEBAND Monitoring +pub const IPPROTO_WBMON: ::c_int = 78; +/// WIDEBAND EXPAK +pub const IPPROTO_WBEXPAK: ::c_int = 79; +/// ISO cnlp +pub const IPPROTO_EON: ::c_int = 80; +/// VMTP +pub const IPPROTO_VMTP: ::c_int = 81; +/// Secure VMTP +pub const IPPROTO_SVMTP: ::c_int = 82; +/// Banyon VINES +pub const IPPROTO_VINES: ::c_int = 83; +/// TTP +pub const IPPROTO_TTP: ::c_int = 84; +/// NSFNET-IGP +pub const IPPROTO_IGP: ::c_int = 85; +/// dissimilar gateway prot. +pub const IPPROTO_DGP: ::c_int = 86; +/// TCF +pub const IPPROTO_TCF: ::c_int = 87; +/// Cisco/GXS IGRP +pub const IPPROTO_IGRP: ::c_int = 88; +/// OSPFIGP +pub const IPPROTO_OSPFIGP: ::c_int = 89; +/// Strite RPC protocol +pub const IPPROTO_SRPC: ::c_int = 90; +/// Locus Address Resoloution +pub const IPPROTO_LARP: ::c_int = 91; +/// Multicast Transport +pub const IPPROTO_MTP: ::c_int = 92; +/// AX.25 Frames +pub const IPPROTO_AX25: ::c_int = 93; +/// IP encapsulated in IP +pub const IPPROTO_IPEIP: ::c_int = 94; +/// Mobile Int.ing control +pub const IPPROTO_MICP: ::c_int = 95; +/// Semaphore Comm. security +pub const IPPROTO_SCCSP: ::c_int = 96; +/// Ethernet IP encapsulation +pub const IPPROTO_ETHERIP: ::c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: ::c_int = 98; +/// any private encr. scheme +pub const IPPROTO_APES: ::c_int = 99; +/// GMTP +pub const IPPROTO_GMTP: ::c_int = 100; + +/* 101-254: Partly Unassigned */ +/// Protocol Independent Mcast +pub const IPPROTO_PIM: ::c_int = 103; +/// payload compression (IPComp) +pub const IPPROTO_IPCOMP: ::c_int = 108; +/// PGM +pub const IPPROTO_PGM: ::c_int = 113; +/// SCTP +pub const IPPROTO_SCTP: ::c_int = 132; + +/* 255: Reserved */ +/* BSD Private, local use, namespace incursion */ +/// divert pseudo-protocol +pub const IPPROTO_DIVERT: ::c_int = 254; +/// raw IP packet +pub const IPPROTO_RAW: ::c_int = 255; +pub const IPPROTO_MAX: ::c_int = 256; +/// last return value of *_input(), meaning "all job for this pkt is done". +pub const IPPROTO_DONE: ::c_int = 257; + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_LOCAL: ::c_int = 1; +pub const AF_UNIX: ::c_int = AF_LOCAL; +pub const AF_INET: ::c_int = 2; +pub const AF_IMPLINK: ::c_int = 3; +pub const AF_PUP: ::c_int = 4; +pub const AF_CHAOS: ::c_int = 5; +pub const AF_NS: ::c_int = 6; +pub const AF_ISO: ::c_int = 7; +pub const AF_OSI: ::c_int = AF_ISO; +pub const AF_ECMA: ::c_int = 8; +pub const AF_DATAKIT: ::c_int = 9; +pub const AF_CCITT: ::c_int = 10; +pub const AF_SNA: ::c_int = 11; +pub const AF_DECnet: ::c_int = 12; +pub const AF_DLI: ::c_int = 13; +pub const AF_LAT: ::c_int = 14; +pub const AF_HYLINK: ::c_int = 15; +pub const AF_APPLETALK: ::c_int = 16; +pub const AF_ROUTE: ::c_int = 17; +pub const AF_LINK: ::c_int = 18; +pub const pseudo_AF_XTP: ::c_int = 19; +pub const AF_COIP: ::c_int = 20; +pub const AF_CNT: ::c_int = 21; +pub const pseudo_AF_RTIP: ::c_int = 22; +pub const AF_IPX: ::c_int = 23; +pub const AF_SIP: ::c_int = 24; +pub const pseudo_AF_PIP: ::c_int = 25; +pub const AF_ISDN: ::c_int = 28; +pub const AF_E164: ::c_int = AF_ISDN; +pub const pseudo_AF_KEY: ::c_int = 29; +pub const AF_INET6: ::c_int = 30; +pub const AF_NATM: ::c_int = 31; +pub const AF_SYSTEM: ::c_int = 32; +pub const AF_NETBIOS: ::c_int = 33; +pub const AF_PPP: ::c_int = 34; +pub const pseudo_AF_HDRCMPLT: ::c_int = 35; +pub const AF_SYS_CONTROL: ::c_int = 2; + +pub const SYSPROTO_EVENT: ::c_int = 1; +pub const SYSPROTO_CONTROL: ::c_int = 2; + +pub const PF_UNSPEC: ::c_int = AF_UNSPEC; +pub const PF_LOCAL: ::c_int = AF_LOCAL; +pub const PF_UNIX: ::c_int = PF_LOCAL; +pub const PF_INET: ::c_int = AF_INET; +pub const PF_IMPLINK: ::c_int = AF_IMPLINK; +pub const PF_PUP: ::c_int = AF_PUP; +pub const PF_CHAOS: ::c_int = AF_CHAOS; +pub const PF_NS: ::c_int = AF_NS; +pub const PF_ISO: ::c_int = AF_ISO; +pub const PF_OSI: ::c_int = AF_ISO; +pub const PF_ECMA: ::c_int = AF_ECMA; +pub const PF_DATAKIT: ::c_int = AF_DATAKIT; +pub const PF_CCITT: ::c_int = AF_CCITT; +pub const PF_SNA: ::c_int = AF_SNA; +pub const PF_DECnet: ::c_int = AF_DECnet; +pub const PF_DLI: ::c_int = AF_DLI; +pub const PF_LAT: ::c_int = AF_LAT; +pub const PF_HYLINK: ::c_int = AF_HYLINK; +pub const PF_APPLETALK: ::c_int = AF_APPLETALK; +pub const PF_ROUTE: ::c_int = AF_ROUTE; +pub const PF_LINK: ::c_int = AF_LINK; +pub const PF_XTP: ::c_int = pseudo_AF_XTP; +pub const PF_COIP: ::c_int = AF_COIP; +pub const PF_CNT: ::c_int = AF_CNT; +pub const PF_SIP: ::c_int = AF_SIP; +pub const PF_IPX: ::c_int = AF_IPX; +pub const PF_RTIP: ::c_int = pseudo_AF_RTIP; +pub const PF_PIP: ::c_int = pseudo_AF_PIP; +pub const PF_ISDN: ::c_int = AF_ISDN; +pub const PF_KEY: ::c_int = pseudo_AF_KEY; +pub const PF_INET6: ::c_int = AF_INET6; +pub const PF_NATM: ::c_int = AF_NATM; +pub const PF_SYSTEM: ::c_int = AF_SYSTEM; +pub const PF_NETBIOS: ::c_int = AF_NETBIOS; +pub const PF_PPP: ::c_int = AF_PPP; + +pub const NET_RT_DUMP: ::c_int = 1; +pub const NET_RT_FLAGS: ::c_int = 2; +pub const NET_RT_IFLIST: ::c_int = 3; + +pub const SOMAXCONN: ::c_int = 128; + +pub const SOCK_MAXADDRLEN: ::c_int = 255; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_RDM: ::c_int = 4; +pub const SOCK_SEQPACKET: ::c_int = 5; +pub const IP_TTL: ::c_int = 4; +pub const IP_HDRINCL: ::c_int = 2; +pub const IP_RECVDSTADDR: ::c_int = 7; +pub const IP_ADD_MEMBERSHIP: ::c_int = 12; +pub const IP_DROP_MEMBERSHIP: ::c_int = 13; +pub const IP_RECVIF: ::c_int = 20; +pub const IP_PKTINFO: ::c_int = 26; +pub const IP_RECVTOS: ::c_int = 27; +pub const IPV6_JOIN_GROUP: ::c_int = 12; +pub const IPV6_LEAVE_GROUP: ::c_int = 13; +pub const IPV6_RECVTCLASS: ::c_int = 35; +pub const IPV6_TCLASS: ::c_int = 36; +pub const IPV6_PKTINFO: ::c_int = 46; +pub const IPV6_RECVPKTINFO: ::c_int = 61; + +pub const TCP_NOPUSH: ::c_int = 4; +pub const TCP_NOOPT: ::c_int = 8; +pub const TCP_KEEPALIVE: ::c_int = 0x10; + +pub const SOL_LOCAL: ::c_int = 0; + +pub const LOCAL_PEERCRED: ::c_int = 0x001; +pub const LOCAL_PEERPID: ::c_int = 0x002; +pub const LOCAL_PEEREPID: ::c_int = 0x003; +pub const LOCAL_PEERUUID: ::c_int = 0x004; +pub const LOCAL_PEEREUUID: ::c_int = 0x005; + +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_DEBUG: ::c_int = 0x01; +pub const SO_ACCEPTCONN: ::c_int = 0x0002; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_TIMESTAMP: ::c_int = 0x0400; +pub const SO_TIMESTAMP_MONOTONIC: ::c_int = 0x0800; +pub const SO_DONTTRUNC: ::c_int = 0x2000; +pub const SO_WANTMORE: ::c_int = 0x4000; +pub const SO_WANTOOBFLAG: ::c_int = 0x8000; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_LABEL: ::c_int = 0x1010; +pub const SO_PEERLABEL: ::c_int = 0x1011; +pub const SO_NREAD: ::c_int = 0x1020; +pub const SO_NKE: ::c_int = 0x1021; +pub const SO_NOSIGPIPE: ::c_int = 0x1022; +pub const SO_NOADDRERR: ::c_int = 0x1023; +pub const SO_NWRITE: ::c_int = 0x1024; +pub const SO_REUSESHAREUID: ::c_int = 0x1025; +pub const SO_NOTIFYCONFLICT: ::c_int = 0x1026; +pub const SO_RANDOMPORT: ::c_int = 0x1082; +pub const SO_NP_EXTENSIONS: ::c_int = 0x1083; + +pub const MSG_OOB: ::c_int = 0x1; +pub const MSG_PEEK: ::c_int = 0x2; +pub const MSG_DONTROUTE: ::c_int = 0x4; +pub const MSG_EOR: ::c_int = 0x8; +pub const MSG_TRUNC: ::c_int = 0x10; +pub const MSG_CTRUNC: ::c_int = 0x20; +pub const MSG_WAITALL: ::c_int = 0x40; +pub const MSG_DONTWAIT: ::c_int = 0x80; +pub const MSG_EOF: ::c_int = 0x100; +pub const MSG_FLUSH: ::c_int = 0x400; +pub const MSG_HOLD: ::c_int = 0x800; +pub const MSG_SEND: ::c_int = 0x1000; +pub const MSG_HAVEMORE: ::c_int = 0x2000; +pub const MSG_RCVMORE: ::c_int = 0x4000; +// pub const MSG_COMPAT: ::c_int = 0x8000; + +pub const SCM_TIMESTAMP: ::c_int = 0x02; +pub const SCM_CREDS: ::c_int = 0x03; + +// https://github.com/aosm/xnu/blob/master/bsd/net/if.h#L140-L156 +pub const IFF_UP: ::c_int = 0x1; // interface is up +pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid +pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging +pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link +pub const IFF_NOTRAILERS: ::c_int = 0x20; // obsolete: avoid use of trailers +pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated +pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress +pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit +pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection +pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; + +pub const MAP_COPY: ::c_int = 0x0002; +pub const MAP_RENAME: ::c_int = 0x0020; +pub const MAP_NORESERVE: ::c_int = 0x0040; +pub const MAP_NOEXTEND: ::c_int = 0x0100; +pub const MAP_HASSEMAPHORE: ::c_int = 0x0200; +pub const MAP_NOCACHE: ::c_int = 0x0400; +pub const MAP_JIT: ::c_int = 0x0800; + +pub const _SC_ARG_MAX: ::c_int = 1; +pub const _SC_CHILD_MAX: ::c_int = 2; +pub const _SC_CLK_TCK: ::c_int = 3; +pub const _SC_NGROUPS_MAX: ::c_int = 4; +pub const _SC_OPEN_MAX: ::c_int = 5; +pub const _SC_JOB_CONTROL: ::c_int = 6; +pub const _SC_SAVED_IDS: ::c_int = 7; +pub const _SC_VERSION: ::c_int = 8; +pub const _SC_BC_BASE_MAX: ::c_int = 9; +pub const _SC_BC_DIM_MAX: ::c_int = 10; +pub const _SC_BC_SCALE_MAX: ::c_int = 11; +pub const _SC_BC_STRING_MAX: ::c_int = 12; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13; +pub const _SC_EXPR_NEST_MAX: ::c_int = 14; +pub const _SC_LINE_MAX: ::c_int = 15; +pub const _SC_RE_DUP_MAX: ::c_int = 16; +pub const _SC_2_VERSION: ::c_int = 17; +pub const _SC_2_C_BIND: ::c_int = 18; +pub const _SC_2_C_DEV: ::c_int = 19; +pub const _SC_2_CHAR_TERM: ::c_int = 20; +pub const _SC_2_FORT_DEV: ::c_int = 21; +pub const _SC_2_FORT_RUN: ::c_int = 22; +pub const _SC_2_LOCALEDEF: ::c_int = 23; +pub const _SC_2_SW_DEV: ::c_int = 24; +pub const _SC_2_UPE: ::c_int = 25; +pub const _SC_STREAM_MAX: ::c_int = 26; +pub const _SC_TZNAME_MAX: ::c_int = 27; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 28; +pub const _SC_PAGESIZE: ::c_int = 29; +pub const _SC_MEMLOCK: ::c_int = 30; +pub const _SC_MEMLOCK_RANGE: ::c_int = 31; +pub const _SC_MEMORY_PROTECTION: ::c_int = 32; +pub const _SC_MESSAGE_PASSING: ::c_int = 33; +pub const _SC_PRIORITIZED_IO: ::c_int = 34; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 35; +pub const _SC_REALTIME_SIGNALS: ::c_int = 36; +pub const _SC_SEMAPHORES: ::c_int = 37; +pub const _SC_FSYNC: ::c_int = 38; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 39; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 40; +pub const _SC_TIMERS: ::c_int = 41; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 42; +pub const _SC_AIO_MAX: ::c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44; +pub const _SC_DELAYTIMER_MAX: ::c_int = 45; +pub const _SC_MQ_OPEN_MAX: ::c_int = 46; +pub const _SC_MAPPED_FILES: ::c_int = 47; +pub const _SC_RTSIG_MAX: ::c_int = 48; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 49; +pub const _SC_SEM_VALUE_MAX: ::c_int = 50; +pub const _SC_SIGQUEUE_MAX: ::c_int = 51; +pub const _SC_TIMER_MAX: ::c_int = 52; +pub const _SC_NPROCESSORS_CONF: ::c_int = 57; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 58; +pub const _SC_2_PBS: ::c_int = 59; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 60; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 61; +pub const _SC_2_PBS_LOCATE: ::c_int = 62; +pub const _SC_2_PBS_MESSAGE: ::c_int = 63; +pub const _SC_2_PBS_TRACK: ::c_int = 64; +pub const _SC_ADVISORY_INFO: ::c_int = 65; +pub const _SC_BARRIERS: ::c_int = 66; +pub const _SC_CLOCK_SELECTION: ::c_int = 67; +pub const _SC_CPUTIME: ::c_int = 68; +pub const _SC_FILE_LOCKING: ::c_int = 69; +pub const _SC_HOST_NAME_MAX: ::c_int = 72; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 74; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 76; +pub const _SC_REGEXP: ::c_int = 77; +pub const _SC_SHELL: ::c_int = 78; +pub const _SC_SPAWN: ::c_int = 79; +pub const _SC_SPIN_LOCKS: ::c_int = 80; +pub const _SC_SPORADIC_SERVER: ::c_int = 81; +pub const _SC_THREAD_CPUTIME: ::c_int = 84; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 92; +pub const _SC_TIMEOUTS: ::c_int = 95; +pub const _SC_TRACE: ::c_int = 97; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 98; +pub const _SC_TRACE_INHERIT: ::c_int = 99; +pub const _SC_TRACE_LOG: ::c_int = 100; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 102; +pub const _SC_V6_ILP32_OFF32: ::c_int = 103; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = 104; +pub const _SC_V6_LP64_OFF64: ::c_int = 105; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 106; +pub const _SC_IPV6: ::c_int = 118; +pub const _SC_RAW_SOCKETS: ::c_int = 119; +pub const _SC_SYMLOOP_MAX: ::c_int = 120; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_XOPEN_STREAMS: ::c_int = 114; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 122; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 123; +pub const _SC_XBS5_LP64_OFF64: ::c_int = 124; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 125; +pub const _SC_SS_REPL_MAX: ::c_int = 126; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 127; +pub const _SC_TRACE_NAME_MAX: ::c_int = 128; +pub const _SC_TRACE_SYS_MAX: ::c_int = 129; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 130; +pub const _SC_PASS_MAX: ::c_int = 131; + +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; +pub const _PTHREAD_MUTEX_SIG_init: ::c_long = 0x32AAABA7; +pub const _PTHREAD_COND_SIG_init: ::c_long = 0x3CB0B1BB; +pub const _PTHREAD_RWLOCK_SIG_init: ::c_long = 0x2DA8B3B4; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __sig: _PTHREAD_MUTEX_SIG_init, + __opaque: [0; __PTHREAD_MUTEX_SIZE__], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __sig: _PTHREAD_COND_SIG_init, + __opaque: [0; __PTHREAD_COND_SIZE__], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __sig: _PTHREAD_RWLOCK_SIG_init, + __opaque: [0; __PTHREAD_RWLOCK_SIZE__], +}; + +pub const SIGSTKSZ: ::size_t = 131072; + +pub const FD_SETSIZE: usize = 1024; + +pub const ST_NOSUID: ::c_ulong = 2; + +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_MACHPORT: i16 = -8; +pub const EVFILT_FS: i16 = -9; +pub const EVFILT_USER: i16 = -10; +pub const EVFILT_VM: i16 = -12; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_FLAG0: u16 = 0x1000; +pub const EV_POLL: u16 = 0x1000; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_OOBAND: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; +pub const EV_SYSFLAGS: u16 = 0xf000; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_NONE: u32 = 0x00000080; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +#[doc(hidden)] +#[deprecated(since = "0.2.49", note = "Deprecated since MacOSX 10.9")] +pub const NOTE_REAP: u32 = 0x10000000; +pub const NOTE_SIGNAL: u32 = 0x08000000; +pub const NOTE_EXITSTATUS: u32 = 0x04000000; +pub const NOTE_EXIT_DETAIL: u32 = 0x02000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xfff00000; +#[doc(hidden)] +#[deprecated(since = "0.2.49", note = "Deprecated since MacOSX 10.9")] +pub const NOTE_EXIT_REPARENTED: u32 = 0x00080000; +pub const NOTE_EXIT_DETAIL_MASK: u32 = 0x00070000; +pub const NOTE_EXIT_DECRYPTFAIL: u32 = 0x00010000; +pub const NOTE_EXIT_MEMORY: u32 = 0x00020000; +pub const NOTE_EXIT_CSERROR: u32 = 0x00040000; +pub const NOTE_VM_PRESSURE: u32 = 0x80000000; +pub const NOTE_VM_PRESSURE_TERMINATE: u32 = 0x40000000; +pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE: u32 = 0x20000000; +pub const NOTE_VM_ERROR: u32 = 0x10000000; +pub const NOTE_SECONDS: u32 = 0x00000001; +pub const NOTE_USECONDS: u32 = 0x00000002; +pub const NOTE_NSECONDS: u32 = 0x00000004; +pub const NOTE_ABSOLUTE: u32 = 0x00000008; +pub const NOTE_LEEWAY: u32 = 0x00000010; +pub const NOTE_CRITICAL: u32 = 0x00000020; +pub const NOTE_BACKGROUND: u32 = 0x00000040; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; + +pub const OCRNL: ::tcflag_t = 0x00000010; +pub const ONOCR: ::tcflag_t = 0x00000020; +pub const ONLRET: ::tcflag_t = 0x00000040; +pub const OFILL: ::tcflag_t = 0x00000080; +pub const NLDLY: ::tcflag_t = 0x00000300; +pub const TABDLY: ::tcflag_t = 0x00000c04; +pub const CRDLY: ::tcflag_t = 0x00003000; +pub const FFDLY: ::tcflag_t = 0x00004000; +pub const BSDLY: ::tcflag_t = 0x00008000; +pub const VTDLY: ::tcflag_t = 0x00010000; +pub const OFDEL: ::tcflag_t = 0x00020000; + +pub const NL0: ::tcflag_t = 0x00000000; +pub const NL1: ::tcflag_t = 0x00000100; +pub const TAB0: ::tcflag_t = 0x00000000; +pub const TAB1: ::tcflag_t = 0x00000400; +pub const TAB2: ::tcflag_t = 0x00000800; +pub const CR0: ::tcflag_t = 0x00000000; +pub const CR1: ::tcflag_t = 0x00001000; +pub const CR2: ::tcflag_t = 0x00002000; +pub const CR3: ::tcflag_t = 0x00003000; +pub const FF0: ::tcflag_t = 0x00000000; +pub const FF1: ::tcflag_t = 0x00004000; +pub const BS0: ::tcflag_t = 0x00000000; +pub const BS1: ::tcflag_t = 0x00008000; +pub const TAB3: ::tcflag_t = 0x00000004; +pub const VT0: ::tcflag_t = 0x00000000; +pub const VT1: ::tcflag_t = 0x00010000; +pub const IUTF8: ::tcflag_t = 0x00004000; +pub const CRTSCTS: ::tcflag_t = 0x00030000; + +pub const NI_MAXHOST: ::socklen_t = 1025; +pub const NI_MAXSERV: ::socklen_t = 32; +pub const NI_NOFQDN: ::c_int = 0x00000001; +pub const NI_NUMERICHOST: ::c_int = 0x00000002; +pub const NI_NAMEREQD: ::c_int = 0x00000004; +pub const NI_NUMERICSERV: ::c_int = 0x00000008; +pub const NI_NUMERICSCOPE: ::c_int = 0x00000100; +pub const NI_DGRAM: ::c_int = 0x00000010; + +pub const Q_GETQUOTA: ::c_int = 0x300; +pub const Q_SETQUOTA: ::c_int = 0x400; + +pub const RENAME_SWAP: ::c_uint = 0x00000002; +pub const RENAME_EXCL: ::c_uint = 0x00000004; + +pub const RTLD_LOCAL: ::c_int = 0x4; +pub const RTLD_FIRST: ::c_int = 0x100; +pub const RTLD_NODELETE: ::c_int = 0x80; +pub const RTLD_NOLOAD: ::c_int = 0x10; +pub const RTLD_GLOBAL: ::c_int = 0x8; + +pub const _WSTOPPED: ::c_int = 0o177; + +pub const LOG_NETINFO: ::c_int = 12 << 3; +pub const LOG_REMOTEAUTH: ::c_int = 13 << 3; +pub const LOG_INSTALL: ::c_int = 14 << 3; +pub const LOG_RAS: ::c_int = 15 << 3; +pub const LOG_LAUNCHD: ::c_int = 24 << 3; +pub const LOG_NFACILITIES: ::c_int = 25; + +pub const CTLTYPE: ::c_int = 0xf; +pub const CTLTYPE_NODE: ::c_int = 1; +pub const CTLTYPE_INT: ::c_int = 2; +pub const CTLTYPE_STRING: ::c_int = 3; +pub const CTLTYPE_QUAD: ::c_int = 4; +pub const CTLTYPE_OPAQUE: ::c_int = 5; +pub const CTLTYPE_STRUCT: ::c_int = CTLTYPE_OPAQUE; +pub const CTLFLAG_RD: ::c_int = 0x80000000; +pub const CTLFLAG_WR: ::c_int = 0x40000000; +pub const CTLFLAG_RW: ::c_int = CTLFLAG_RD | CTLFLAG_WR; +pub const CTLFLAG_NOLOCK: ::c_int = 0x20000000; +pub const CTLFLAG_ANYBODY: ::c_int = 0x10000000; +pub const CTLFLAG_SECURE: ::c_int = 0x08000000; +pub const CTLFLAG_MASKED: ::c_int = 0x04000000; +pub const CTLFLAG_NOAUTO: ::c_int = 0x02000000; +pub const CTLFLAG_KERN: ::c_int = 0x01000000; +pub const CTLFLAG_LOCKED: ::c_int = 0x00800000; +pub const CTLFLAG_OID2: ::c_int = 0x00400000; +pub const CTL_UNSPEC: ::c_int = 0; +pub const CTL_KERN: ::c_int = 1; +pub const CTL_VM: ::c_int = 2; +pub const CTL_VFS: ::c_int = 3; +pub const CTL_NET: ::c_int = 4; +pub const CTL_DEBUG: ::c_int = 5; +pub const CTL_HW: ::c_int = 6; +pub const CTL_MACHDEP: ::c_int = 7; +pub const CTL_USER: ::c_int = 8; +pub const CTL_MAXID: ::c_int = 9; +pub const KERN_OSTYPE: ::c_int = 1; +pub const KERN_OSRELEASE: ::c_int = 2; +pub const KERN_OSREV: ::c_int = 3; +pub const KERN_VERSION: ::c_int = 4; +pub const KERN_MAXVNODES: ::c_int = 5; +pub const KERN_MAXPROC: ::c_int = 6; +pub const KERN_MAXFILES: ::c_int = 7; +pub const KERN_ARGMAX: ::c_int = 8; +pub const KERN_SECURELVL: ::c_int = 9; +pub const KERN_HOSTNAME: ::c_int = 10; +pub const KERN_HOSTID: ::c_int = 11; +pub const KERN_CLOCKRATE: ::c_int = 12; +pub const KERN_VNODE: ::c_int = 13; +pub const KERN_PROC: ::c_int = 14; +pub const KERN_FILE: ::c_int = 15; +pub const KERN_PROF: ::c_int = 16; +pub const KERN_POSIX1: ::c_int = 17; +pub const KERN_NGROUPS: ::c_int = 18; +pub const KERN_JOB_CONTROL: ::c_int = 19; +pub const KERN_SAVED_IDS: ::c_int = 20; +pub const KERN_BOOTTIME: ::c_int = 21; +pub const KERN_NISDOMAINNAME: ::c_int = 22; +pub const KERN_DOMAINNAME: ::c_int = KERN_NISDOMAINNAME; +pub const KERN_MAXPARTITIONS: ::c_int = 23; +pub const KERN_KDEBUG: ::c_int = 24; +pub const KERN_UPDATEINTERVAL: ::c_int = 25; +pub const KERN_OSRELDATE: ::c_int = 26; +pub const KERN_NTP_PLL: ::c_int = 27; +pub const KERN_BOOTFILE: ::c_int = 28; +pub const KERN_MAXFILESPERPROC: ::c_int = 29; +pub const KERN_MAXPROCPERUID: ::c_int = 30; +pub const KERN_DUMPDEV: ::c_int = 31; +pub const KERN_IPC: ::c_int = 32; +pub const KERN_DUMMY: ::c_int = 33; +pub const KERN_PS_STRINGS: ::c_int = 34; +pub const KERN_USRSTACK32: ::c_int = 35; +pub const KERN_LOGSIGEXIT: ::c_int = 36; +pub const KERN_SYMFILE: ::c_int = 37; +pub const KERN_PROCARGS: ::c_int = 38; +pub const KERN_NETBOOT: ::c_int = 40; +pub const KERN_SYSV: ::c_int = 42; +pub const KERN_AFFINITY: ::c_int = 43; +pub const KERN_TRANSLATE: ::c_int = 44; +pub const KERN_CLASSIC: ::c_int = KERN_TRANSLATE; +pub const KERN_EXEC: ::c_int = 45; +pub const KERN_CLASSICHANDLER: ::c_int = KERN_EXEC; +pub const KERN_AIOMAX: ::c_int = 46; +pub const KERN_AIOPROCMAX: ::c_int = 47; +pub const KERN_AIOTHREADS: ::c_int = 48; +pub const KERN_COREFILE: ::c_int = 50; +pub const KERN_COREDUMP: ::c_int = 51; +pub const KERN_SUGID_COREDUMP: ::c_int = 52; +pub const KERN_PROCDELAYTERM: ::c_int = 53; +pub const KERN_SHREG_PRIVATIZABLE: ::c_int = 54; +pub const KERN_LOW_PRI_WINDOW: ::c_int = 56; +pub const KERN_LOW_PRI_DELAY: ::c_int = 57; +pub const KERN_POSIX: ::c_int = 58; +pub const KERN_USRSTACK64: ::c_int = 59; +pub const KERN_NX_PROTECTION: ::c_int = 60; +pub const KERN_TFP: ::c_int = 61; +pub const KERN_PROCNAME: ::c_int = 62; +pub const KERN_THALTSTACK: ::c_int = 63; +pub const KERN_SPECULATIVE_READS: ::c_int = 64; +pub const KERN_OSVERSION: ::c_int = 65; +pub const KERN_SAFEBOOT: ::c_int = 66; +pub const KERN_RAGEVNODE: ::c_int = 68; +pub const KERN_TTY: ::c_int = 69; +pub const KERN_CHECKOPENEVT: ::c_int = 70; +pub const KERN_THREADNAME: ::c_int = 71; +pub const KERN_MAXID: ::c_int = 72; +pub const KERN_RAGE_PROC: ::c_int = 1; +pub const KERN_RAGE_THREAD: ::c_int = 2; +pub const KERN_UNRAGE_PROC: ::c_int = 3; +pub const KERN_UNRAGE_THREAD: ::c_int = 4; +pub const KERN_OPENEVT_PROC: ::c_int = 1; +pub const KERN_UNOPENEVT_PROC: ::c_int = 2; +pub const KERN_TFP_POLICY: ::c_int = 1; +pub const KERN_TFP_POLICY_DENY: ::c_int = 0; +pub const KERN_TFP_POLICY_DEFAULT: ::c_int = 2; +pub const KERN_KDEFLAGS: ::c_int = 1; +pub const KERN_KDDFLAGS: ::c_int = 2; +pub const KERN_KDENABLE: ::c_int = 3; +pub const KERN_KDSETBUF: ::c_int = 4; +pub const KERN_KDGETBUF: ::c_int = 5; +pub const KERN_KDSETUP: ::c_int = 6; +pub const KERN_KDREMOVE: ::c_int = 7; +pub const KERN_KDSETREG: ::c_int = 8; +pub const KERN_KDGETREG: ::c_int = 9; +pub const KERN_KDREADTR: ::c_int = 10; +pub const KERN_KDPIDTR: ::c_int = 11; +pub const KERN_KDTHRMAP: ::c_int = 12; +pub const KERN_KDPIDEX: ::c_int = 14; +pub const KERN_KDSETRTCDEC: ::c_int = 15; +pub const KERN_KDGETENTROPY: ::c_int = 16; +pub const KERN_KDWRITETR: ::c_int = 17; +pub const KERN_KDWRITEMAP: ::c_int = 18; +#[doc(hidden)] +#[deprecated(since = "0.2.49", note = "Removed in MacOSX 10.12")] +pub const KERN_KDENABLE_BG_TRACE: ::c_int = 19; +#[doc(hidden)] +#[deprecated(since = "0.2.49", note = "Removed in MacOSX 10.12")] +pub const KERN_KDDISABLE_BG_TRACE: ::c_int = 20; +pub const KERN_KDREADCURTHRMAP: ::c_int = 21; +pub const KERN_KDSET_TYPEFILTER: ::c_int = 22; +pub const KERN_KDBUFWAIT: ::c_int = 23; +pub const KERN_KDCPUMAP: ::c_int = 24; +pub const KERN_PROC_ALL: ::c_int = 0; +pub const KERN_PROC_PID: ::c_int = 1; +pub const KERN_PROC_PGRP: ::c_int = 2; +pub const KERN_PROC_SESSION: ::c_int = 3; +pub const KERN_PROC_TTY: ::c_int = 4; +pub const KERN_PROC_UID: ::c_int = 5; +pub const KERN_PROC_RUID: ::c_int = 6; +pub const KERN_PROC_LCID: ::c_int = 7; +pub const KIPC_MAXSOCKBUF: ::c_int = 1; +pub const KIPC_SOCKBUF_WASTE: ::c_int = 2; +pub const KIPC_SOMAXCONN: ::c_int = 3; +pub const KIPC_MAX_LINKHDR: ::c_int = 4; +pub const KIPC_MAX_PROTOHDR: ::c_int = 5; +pub const KIPC_MAX_HDR: ::c_int = 6; +pub const KIPC_MAX_DATALEN: ::c_int = 7; +pub const KIPC_MBSTAT: ::c_int = 8; +pub const KIPC_NMBCLUSTERS: ::c_int = 9; +pub const KIPC_SOQLIMITCOMPAT: ::c_int = 10; +pub const VM_METER: ::c_int = 1; +pub const VM_LOADAVG: ::c_int = 2; +pub const VM_MACHFACTOR: ::c_int = 4; +pub const VM_SWAPUSAGE: ::c_int = 5; +pub const VM_MAXID: ::c_int = 6; +pub const HW_MACHINE: ::c_int = 1; +pub const HW_MODEL: ::c_int = 2; +pub const HW_NCPU: ::c_int = 3; +pub const HW_BYTEORDER: ::c_int = 4; +pub const HW_PHYSMEM: ::c_int = 5; +pub const HW_USERMEM: ::c_int = 6; +pub const HW_PAGESIZE: ::c_int = 7; +pub const HW_DISKNAMES: ::c_int = 8; +pub const HW_DISKSTATS: ::c_int = 9; +pub const HW_EPOCH: ::c_int = 10; +pub const HW_FLOATINGPT: ::c_int = 11; +pub const HW_MACHINE_ARCH: ::c_int = 12; +pub const HW_VECTORUNIT: ::c_int = 13; +pub const HW_BUS_FREQ: ::c_int = 14; +pub const HW_CPU_FREQ: ::c_int = 15; +pub const HW_CACHELINE: ::c_int = 16; +pub const HW_L1ICACHESIZE: ::c_int = 17; +pub const HW_L1DCACHESIZE: ::c_int = 18; +pub const HW_L2SETTINGS: ::c_int = 19; +pub const HW_L2CACHESIZE: ::c_int = 20; +pub const HW_L3SETTINGS: ::c_int = 21; +pub const HW_L3CACHESIZE: ::c_int = 22; +pub const HW_TB_FREQ: ::c_int = 23; +pub const HW_MEMSIZE: ::c_int = 24; +pub const HW_AVAILCPU: ::c_int = 25; +pub const HW_MAXID: ::c_int = 26; +pub const USER_CS_PATH: ::c_int = 1; +pub const USER_BC_BASE_MAX: ::c_int = 2; +pub const USER_BC_DIM_MAX: ::c_int = 3; +pub const USER_BC_SCALE_MAX: ::c_int = 4; +pub const USER_BC_STRING_MAX: ::c_int = 5; +pub const USER_COLL_WEIGHTS_MAX: ::c_int = 6; +pub const USER_EXPR_NEST_MAX: ::c_int = 7; +pub const USER_LINE_MAX: ::c_int = 8; +pub const USER_RE_DUP_MAX: ::c_int = 9; +pub const USER_POSIX2_VERSION: ::c_int = 10; +pub const USER_POSIX2_C_BIND: ::c_int = 11; +pub const USER_POSIX2_C_DEV: ::c_int = 12; +pub const USER_POSIX2_CHAR_TERM: ::c_int = 13; +pub const USER_POSIX2_FORT_DEV: ::c_int = 14; +pub const USER_POSIX2_FORT_RUN: ::c_int = 15; +pub const USER_POSIX2_LOCALEDEF: ::c_int = 16; +pub const USER_POSIX2_SW_DEV: ::c_int = 17; +pub const USER_POSIX2_UPE: ::c_int = 18; +pub const USER_STREAM_MAX: ::c_int = 19; +pub const USER_TZNAME_MAX: ::c_int = 20; +pub const USER_MAXID: ::c_int = 21; +pub const CTL_DEBUG_NAME: ::c_int = 0; +pub const CTL_DEBUG_VALUE: ::c_int = 1; +pub const CTL_DEBUG_MAXID: ::c_int = 20; + +pub const PRIO_DARWIN_THREAD: ::c_int = 3; +pub const PRIO_DARWIN_PROCESS: ::c_int = 4; +pub const PRIO_DARWIN_BG: ::c_int = 0x1000; +pub const PRIO_DARWIN_NONUI: ::c_int = 0x1001; + +pub const SEM_FAILED: *mut sem_t = -1isize as *mut ::sem_t; + +pub const AI_PASSIVE: ::c_int = 0x00000001; +pub const AI_CANONNAME: ::c_int = 0x00000002; +pub const AI_NUMERICHOST: ::c_int = 0x00000004; +pub const AI_NUMERICSERV: ::c_int = 0x00001000; +pub const AI_MASK: ::c_int = AI_PASSIVE + | AI_CANONNAME + | AI_NUMERICHOST + | AI_NUMERICSERV + | AI_ADDRCONFIG; +pub const AI_ALL: ::c_int = 0x00000100; +pub const AI_V4MAPPED_CFG: ::c_int = 0x00000200; +pub const AI_ADDRCONFIG: ::c_int = 0x00000400; +pub const AI_V4MAPPED: ::c_int = 0x00000800; +pub const AI_DEFAULT: ::c_int = AI_V4MAPPED_CFG | AI_ADDRCONFIG; +pub const AI_UNUSABLE: ::c_int = 0x10000000; + +pub const SIGEV_NONE: ::c_int = 0; +pub const SIGEV_SIGNAL: ::c_int = 1; +pub const SIGEV_THREAD: ::c_int = 3; + +pub const AIO_CANCELED: ::c_int = 2; +pub const AIO_NOTCANCELED: ::c_int = 4; +pub const AIO_ALLDONE: ::c_int = 1; +#[deprecated( + since = "0.2.64", + note = "Can vary at runtime. Use sysconf(3) instead" +)] +pub const AIO_LISTIO_MAX: ::c_int = 16; +pub const LIO_NOP: ::c_int = 0; +pub const LIO_WRITE: ::c_int = 2; +pub const LIO_READ: ::c_int = 1; +pub const LIO_WAIT: ::c_int = 2; +pub const LIO_NOWAIT: ::c_int = 1; + +pub const WEXITED: ::c_int = 0x00000004; +pub const WSTOPPED: ::c_int = 0x00000008; +pub const WCONTINUED: ::c_int = 0x00000010; +pub const WNOWAIT: ::c_int = 0x00000020; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + +pub const UTIME_OMIT: c_long = -2; +pub const UTIME_NOW: c_long = -1; + +pub const XATTR_NOFOLLOW: ::c_int = 0x0001; +pub const XATTR_CREATE: ::c_int = 0x0002; +pub const XATTR_REPLACE: ::c_int = 0x0004; +pub const XATTR_NOSECURITY: ::c_int = 0x0008; +pub const XATTR_NODEFAULT: ::c_int = 0x0010; +pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020; + +pub const NET_RT_IFLIST2: ::c_int = 0x0006; + +// net/route.h +pub const RTF_UP: ::c_int = 0x1; +pub const RTF_GATEWAY: ::c_int = 0x2; +pub const RTF_HOST: ::c_int = 0x4; +pub const RTF_REJECT: ::c_int = 0x8; +pub const RTF_DYNAMIC: ::c_int = 0x10; +pub const RTF_MODIFIED: ::c_int = 0x20; +pub const RTF_DONE: ::c_int = 0x40; +pub const RTF_DELCLONE: ::c_int = 0x80; +pub const RTF_CLONING: ::c_int = 0x100; +pub const RTF_XRESOLVE: ::c_int = 0x200; +pub const RTF_LLINFO: ::c_int = 0x400; +pub const RTF_STATIC: ::c_int = 0x800; +pub const RTF_BLACKHOLE: ::c_int = 0x1000; +pub const RTF_NOIFREF: ::c_int = 0x2000; +pub const RTF_PROTO2: ::c_int = 0x4000; +pub const RTF_PROTO1: ::c_int = 0x8000; +pub const RTF_PRCLONING: ::c_int = 0x10000; +pub const RTF_WASCLONED: ::c_int = 0x20000; +pub const RTF_PROTO3: ::c_int = 0x40000; +pub const RTF_PINNED: ::c_int = 0x100000; +pub const RTF_LOCAL: ::c_int = 0x200000; +pub const RTF_BROADCAST: ::c_int = 0x400000; +pub const RTF_MULTICAST: ::c_int = 0x800000; +pub const RTF_IFSCOPE: ::c_int = 0x1000000; +pub const RTF_CONDEMNED: ::c_int = 0x2000000; +pub const RTF_IFREF: ::c_int = 0x4000000; +pub const RTF_PROXY: ::c_int = 0x8000000; +pub const RTF_ROUTER: ::c_int = 0x10000000; + +pub const RTM_VERSION: ::c_int = 5; + +// Message types +pub const RTM_ADD: ::c_int = 0x1; +pub const RTM_DELETE: ::c_int = 0x2; +pub const RTM_CHANGE: ::c_int = 0x3; +pub const RTM_GET: ::c_int = 0x4; +pub const RTM_LOSING: ::c_int = 0x5; +pub const RTM_REDIRECT: ::c_int = 0x6; +pub const RTM_MISS: ::c_int = 0x7; +pub const RTM_LOCK: ::c_int = 0x8; +pub const RTM_OLDADD: ::c_int = 0x9; +pub const RTM_OLDDEL: ::c_int = 0xa; +pub const RTM_RESOLVE: ::c_int = 0xb; +pub const RTM_NEWADDR: ::c_int = 0xc; +pub const RTM_DELADDR: ::c_int = 0xd; +pub const RTM_IFINFO: ::c_int = 0xe; +pub const RTM_NEWMADDR: ::c_int = 0xf; +pub const RTM_DELMADDR: ::c_int = 0x10; +pub const RTM_IFINFO2: ::c_int = 0x12; +pub const RTM_NEWMADDR2: ::c_int = 0x13; +pub const RTM_GET2: ::c_int = 0x14; + +// Bitmask values for rtm_inits and rmx_locks. +pub const RTV_MTU: ::c_int = 0x1; +pub const RTV_HOPCOUNT: ::c_int = 0x2; +pub const RTV_EXPIRE: ::c_int = 0x4; +pub const RTV_RPIPE: ::c_int = 0x8; +pub const RTV_SPIPE: ::c_int = 0x10; +pub const RTV_SSTHRESH: ::c_int = 0x20; +pub const RTV_RTT: ::c_int = 0x40; +pub const RTV_RTTVAR: ::c_int = 0x80; + +// Bitmask values for rtm_addrs. +pub const RTA_DST: ::c_int = 0x1; +pub const RTA_GATEWAY: ::c_int = 0x2; +pub const RTA_NETMASK: ::c_int = 0x4; +pub const RTA_GENMASK: ::c_int = 0x8; +pub const RTA_IFP: ::c_int = 0x10; +pub const RTA_IFA: ::c_int = 0x20; +pub const RTA_AUTHOR: ::c_int = 0x40; +pub const RTA_BRD: ::c_int = 0x80; + +// Index offsets for sockaddr array for alternate internal encoding. +pub const RTAX_DST: ::c_int = 0; +pub const RTAX_GATEWAY: ::c_int = 1; +pub const RTAX_NETMASK: ::c_int = 2; +pub const RTAX_GENMASK: ::c_int = 3; +pub const RTAX_IFP: ::c_int = 4; +pub const RTAX_IFA: ::c_int = 5; +pub const RTAX_AUTHOR: ::c_int = 6; +pub const RTAX_BRD: ::c_int = 7; +pub const RTAX_MAX: ::c_int = 8; + +pub const KERN_PROCARGS2: ::c_int = 49; + +pub const PROC_PIDTASKALLINFO: ::c_int = 2; +pub const PROC_PIDTASKINFO: ::c_int = 4; +pub const PROC_PIDTHREADINFO: ::c_int = 5; +pub const MAXCOMLEN: usize = 16; +pub const MAXTHREADNAMESIZE: usize = 64; + +pub const XUCRED_VERSION: ::c_uint = 0; + +pub const LC_SEGMENT: u32 = 0x1; +pub const LC_SEGMENT_64: u32 = 0x19; + +pub const MH_MAGIC: u32 = 0xfeedface; +pub const MH_MAGIC_64: u32 = 0xfeedfacf; + +// net/if_utun.h +pub const UTUN_OPT_FLAGS: ::c_int = 1; +pub const UTUN_OPT_IFNAME: ::c_int = 2; + +// net/bpf.h +pub const DLT_NULL: ::c_uint = 0; // no link-layer encapsulation +pub const DLT_EN10MB: ::c_uint = 1; // Ethernet (10Mb) +pub const DLT_EN3MB: ::c_uint = 2; // Experimental Ethernet (3Mb) +pub const DLT_AX25: ::c_uint = 3; // Amateur Radio AX.25 +pub const DLT_PRONET: ::c_uint = 4; // Proteon ProNET Token Ring +pub const DLT_CHAOS: ::c_uint = 5; // Chaos +pub const DLT_IEEE802: ::c_uint = 6; // IEEE 802 Networks +pub const DLT_ARCNET: ::c_uint = 7; // ARCNET +pub const DLT_SLIP: ::c_uint = 8; // Serial Line IP +pub const DLT_PPP: ::c_uint = 9; // Point-to-point Protocol +pub const DLT_FDDI: ::c_uint = 10; // FDDI +pub const DLT_ATM_RFC1483: ::c_uint = 11; // LLC/SNAP encapsulated atm +pub const DLT_RAW: ::c_uint = 12; // raw IP +pub const DLT_LOOP: ::c_uint = 108; + +// https://github.com/apple/darwin-xnu/blob/master/bsd/net/bpf.h#L100 +// sizeof(i32) +pub const BPF_ALIGNMENT: ::c_int = 4; + +// sys/spawn.h: +pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; +pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04; +pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08; +pub const POSIX_SPAWN_SETEXEC: ::c_int = 0x40; +pub const POSIX_SPAWN_START_SUSPENDED: ::c_int = 0x80; +pub const POSIX_SPAWN_CLOEXEC_DEFAULT: ::c_int = 0x4000; + +// sys/ipc.h: +pub const IPC_CREAT: ::c_int = 0x200; +pub const IPC_EXCL: ::c_int = 0x400; +pub const IPC_NOWAIT: ::c_int = 0x800; +pub const IPC_PRIVATE: key_t = 0; + +pub const IPC_RMID: ::c_int = 0; +pub const IPC_SET: ::c_int = 1; +pub const IPC_STAT: ::c_int = 2; + +pub const IPC_R: ::c_int = 0x100; +pub const IPC_W: ::c_int = 0x80; +pub const IPC_M: ::c_int = 0x1000; + +// sys/sem.h +pub const SEM_UNDO: ::c_int = 0o10000; + +pub const GETNCNT: ::c_int = 3; +pub const GETPID: ::c_int = 4; +pub const GETVAL: ::c_int = 5; +pub const GETALL: ::c_int = 6; +pub const GETZCNT: ::c_int = 7; +pub const SETVAL: ::c_int = 8; +pub const SETALL: ::c_int = 9; + +// sys/shm.h +pub const SHM_RDONLY: ::c_int = 0x1000; +pub const SHM_RND: ::c_int = 0x2000; +pub const SHMLBA: ::c_int = 4096; +pub const SHM_R: ::c_int = IPC_R; +pub const SHM_W: ::c_int = IPC_W; + +// Flags for chflags(2) +pub const UF_SETTABLE: ::c_uint = 0x0000ffff; +pub const UF_NODUMP: ::c_uint = 0x00000001; +pub const UF_IMMUTABLE: ::c_uint = 0x00000002; +pub const UF_APPEND: ::c_uint = 0x00000004; +pub const UF_OPAQUE: ::c_uint = 0x00000008; +pub const UF_COMPRESSED: ::c_uint = 0x00000020; +pub const UF_TRACKED: ::c_uint = 0x00000040; +pub const SF_SETTABLE: ::c_uint = 0xffff0000; +pub const SF_ARCHIVED: ::c_uint = 0x00010000; +pub const SF_IMMUTABLE: ::c_uint = 0x00020000; +pub const SF_APPEND: ::c_uint = 0x00040000; +pub const UF_HIDDEN: ::c_uint = 0x00008000; + +cfg_if! { + if #[cfg(libc_const_size_of)] { + fn __DARWIN_ALIGN32(p: usize) -> usize { + const __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::() - 1; + p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 + } + } else { + fn __DARWIN_ALIGN32(p: usize) -> usize { + let __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::() - 1; + p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 + } + } +} + +f! { + pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, + cmsg: *const ::cmsghdr) -> *mut ::cmsghdr { + if cmsg.is_null() { + return ::CMSG_FIRSTHDR(mhdr); + }; + let cmsg_len = (*cmsg).cmsg_len as usize; + let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len as usize); + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next + __DARWIN_ALIGN32(::mem::size_of::<::cmsghdr>()) > max { + 0 as *mut ::cmsghdr + } else { + next as *mut ::cmsghdr + } + } + + pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { + (cmsg as *mut ::c_uchar) + .offset(__DARWIN_ALIGN32(::mem::size_of::<::cmsghdr>()) as isize) + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (__DARWIN_ALIGN32(::mem::size_of::<::cmsghdr>()) + + __DARWIN_ALIGN32(length as usize)) + as ::c_uint + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + (__DARWIN_ALIGN32(::mem::size_of::<::cmsghdr>()) + length as usize) + as ::c_uint + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub fn _WSTATUS(status: ::c_int) -> ::c_int { + status & 0x7f + } + + pub fn WIFCONTINUED(status: ::c_int) -> bool { + _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) == 0x13 + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + _WSTATUS(status) != _WSTOPPED && _WSTATUS(status) != 0 + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) != 0x13 + } +} + +extern "C" { + pub fn setgrent(); + #[doc(hidden)] + #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.5")] + #[link_name = "daemon$1050"] + pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + #[doc(hidden)] + #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.10")] + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + #[doc(hidden)] + #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.10")] + pub fn sem_init( + sem: *mut sem_t, + pshared: ::c_int, + value: ::c_uint, + ) -> ::c_int; + pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "aio_suspend$UNIX2003" + )] + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: ::c_int, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; + pub fn chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int; + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn lio_listio( + mode: ::c_int, + aiocb_list: *const *mut aiocb, + nitems: ::c_int, + sevp: *mut sigevent, + ) -> ::c_int; + + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + + pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + pub fn utmpxname(file: *const ::c_char) -> ::c_int; + + pub fn getnameinfo( + sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::socklen_t, + serv: *mut ::c_char, + sevlen: ::socklen_t, + flags: ::c_int, + ) -> ::c_int; + pub fn mincore( + addr: *const ::c_void, + len: ::size_t, + vec: *mut ::c_char, + ) -> ::c_int; + pub fn sysctlnametomib( + name: *const ::c_char, + mibp: *mut ::c_int, + sizep: *mut ::size_t, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "mprotect$UNIX2003" + )] + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn semget(key: key_t, nsems: ::c_int, semflg: ::c_int) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "semctl$UNIX2003" + )] + pub fn semctl( + semid: ::c_int, + semnum: ::c_int, + cmd: ::c_int, + ... + ) -> ::c_int; + pub fn semop( + semid: ::c_int, + sops: *mut sembuf, + nsops: ::size_t, + ) -> ::c_int; + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn ftok(pathname: *const c_char, proj_id: ::c_int) -> key_t; + pub fn shmat( + shmid: ::c_int, + shmaddr: *const ::c_void, + shmflg: ::c_int, + ) -> *mut ::c_void; + pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "shmctl$UNIX2003" + )] + pub fn shmctl( + shmid: ::c_int, + cmd: ::c_int, + buf: *mut ::shmid_ds, + ) -> ::c_int; + pub fn shmget(key: key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_uint, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; + pub fn sysctlbyname( + name: *const ::c_char, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] + pub fn mach_absolute_time() -> u64; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[allow(deprecated)] + pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; + pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; + pub fn pthread_getname_np( + thread: ::pthread_t, + name: *mut ::c_char, + len: ::size_t, + ) -> ::c_int; + pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void; + pub fn pthread_get_stacksize_np(thread: ::pthread_t) -> ::size_t; + pub fn pthread_condattr_setpshared( + attr: *mut pthread_condattr_t, + pshared: ::c_int, + ) -> ::c_int; + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_mutexattr_setpshared( + attr: *mut pthread_mutexattr_t, + pshared: ::c_int, + ) -> ::c_int; + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_getpshared( + attr: *const pthread_rwlockattr_t, + val: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_setpshared( + attr: *mut pthread_rwlockattr_t, + val: ::c_int, + ) -> ::c_int; + pub fn __error() -> *mut ::c_int; + pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "macos", link_name = "statfs$INODE64")] + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + #[cfg_attr(target_os = "macos", link_name = "fstatfs$INODE64")] + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + pub fn kevent( + kq: ::c_int, + changelist: *const ::kevent, + nchanges: ::c_int, + eventlist: *mut ::kevent, + nevents: ::c_int, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn kevent64( + kq: ::c_int, + changelist: *const ::kevent64_s, + nchanges: ::c_int, + eventlist: *mut ::kevent64_s, + nevents: ::c_int, + flags: ::c_uint, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn mount( + src: *const ::c_char, + target: *const ::c_char, + flags: ::c_int, + data: *mut ::c_void, + ) -> ::c_int; + pub fn ptrace( + request: ::c_int, + pid: ::pid_t, + addr: *mut ::c_char, + data: ::c_int, + ) -> ::c_int; + pub fn quotactl( + special: *const ::c_char, + cmd: ::c_int, + id: ::c_int, + data: *mut ::c_char, + ) -> ::c_int; + pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; + pub fn sendfile( + fd: ::c_int, + s: ::c_int, + offset: ::off_t, + len: *mut ::off_t, + hdtr: *mut ::sf_hdtr, + flags: ::c_int, + ) -> ::c_int; + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn utimensat( + dirfd: ::c_int, + path: *const ::c_char, + times: *const ::timespec, + flag: ::c_int, + ) -> ::c_int; + pub fn openpty( + amaster: *mut ::c_int, + aslave: *mut ::c_int, + name: *mut ::c_char, + termp: *mut termios, + winp: *mut ::winsize, + ) -> ::c_int; + pub fn forkpty( + amaster: *mut ::c_int, + name: *mut ::c_char, + termp: *mut termios, + winp: *mut ::winsize, + ) -> ::pid_t; + pub fn login_tty(fd: ::c_int) -> ::c_int; + pub fn duplocale(base: ::locale_t) -> ::locale_t; + pub fn freelocale(loc: ::locale_t) -> ::c_int; + pub fn localeconv_l(loc: ::locale_t) -> *mut lconv; + pub fn newlocale( + mask: ::c_int, + locale: *const ::c_char, + base: ::locale_t, + ) -> ::locale_t; + pub fn uselocale(loc: ::locale_t) -> ::locale_t; + pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; + pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; + pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; + pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::c_int) -> ::c_int; + pub fn getxattr( + path: *const ::c_char, + name: *const ::c_char, + value: *mut ::c_void, + size: ::size_t, + position: u32, + flags: ::c_int, + ) -> ::ssize_t; + pub fn fgetxattr( + filedes: ::c_int, + name: *const ::c_char, + value: *mut ::c_void, + size: ::size_t, + position: u32, + flags: ::c_int, + ) -> ::ssize_t; + pub fn setxattr( + path: *const ::c_char, + name: *const ::c_char, + value: *const ::c_void, + size: ::size_t, + position: u32, + flags: ::c_int, + ) -> ::c_int; + pub fn fsetxattr( + filedes: ::c_int, + name: *const ::c_char, + value: *const ::c_void, + size: ::size_t, + position: u32, + flags: ::c_int, + ) -> ::c_int; + pub fn listxattr( + path: *const ::c_char, + list: *mut ::c_char, + size: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + pub fn flistxattr( + filedes: ::c_int, + list: *mut ::c_char, + size: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + pub fn removexattr( + path: *const ::c_char, + name: *const ::c_char, + flags: ::c_int, + ) -> ::c_int; + pub fn renamex_np( + from: *const ::c_char, + to: *const ::c_char, + flags: ::c_uint, + ) -> ::c_int; + pub fn renameatx_np( + fromfd: ::c_int, + from: *const ::c_char, + tofd: ::c_int, + to: *const ::c_char, + flags: ::c_uint, + ) -> ::c_int; + pub fn fremovexattr( + filedes: ::c_int, + name: *const ::c_char, + flags: ::c_int, + ) -> ::c_int; + + pub fn getgrouplist( + name: *const ::c_char, + basegid: ::c_int, + groups: *mut ::c_int, + ngroups: *mut ::c_int, + ) -> ::c_int; + pub fn initgroups(user: *const ::c_char, basegroup: ::c_int) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "waitid$UNIX2003" + )] + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut ::siginfo_t, + options: ::c_int, + ) -> ::c_int; + pub fn brk(addr: *const ::c_void) -> *mut ::c_void; + pub fn sbrk(increment: ::c_int) -> *mut ::c_void; + pub fn settimeofday( + tv: *const ::timeval, + tz: *const ::timezone, + ) -> ::c_int; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] + pub fn _dyld_image_count() -> u32; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[allow(deprecated)] + pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] + pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> ::intptr_t; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] + pub fn _dyld_get_image_name(image_index: u32) -> *const ::c_char; + + pub fn posix_spawn( + pid: *mut ::pid_t, + path: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnp( + pid: *mut ::pid_t, + file: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getflags( + attr: *const posix_spawnattr_t, + flags: *mut ::c_short, + ) -> ::c_int; + pub fn posix_spawnattr_setflags( + attr: *mut posix_spawnattr_t, + flags: ::c_short, + ) -> ::c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut ::pid_t, + ) -> ::c_int; + pub fn posix_spawnattr_setpgroup( + attr: *mut posix_spawnattr_t, + flags: ::pid_t, + ) -> ::c_int; + + pub fn posix_spawn_file_actions_init( + actions: *mut posix_spawn_file_actions_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_destroy( + actions: *mut posix_spawn_file_actions_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + path: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + ) -> ::c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + newfd: ::c_int, + ) -> ::c_int; + pub fn uname(buf: *mut ::utsname) -> ::c_int; +} + +cfg_if! { + if #[cfg(any(target_arch = "arm", target_arch = "x86"))] { + mod b32; + pub use self::b32::*; + } else if #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] { + mod b64; + pub use self::b64::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/dragonfly/errno.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/dragonfly/errno.rs new file mode 100644 index 0000000..e9ad63b --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/dragonfly/errno.rs @@ -0,0 +1,12 @@ +// DragonFlyBSD's __error function is declared with "static inline", so it must +// be implemented in the libc crate, as a pointer to a static thread_local. +f! { + pub fn __error() -> *mut ::c_int { + &mut errno + } +} + +extern "C" { + #[thread_local] + pub static mut errno: ::c_int; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/dragonfly/mod.rs new file mode 100644 index 0000000..63ca4db --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -0,0 +1,1096 @@ +pub type dev_t = u32; +pub type c_char = i8; +pub type clock_t = u64; +pub type ino_t = u64; +pub type lwpid_t = i32; +pub type nlink_t = u32; +pub type blksize_t = i64; +pub type clockid_t = ::c_ulong; + +pub type c_long = i64; +pub type c_ulong = u64; +pub type time_t = i64; +pub type suseconds_t = i64; + +pub type uuid_t = ::uuid; + +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; + +pub type mqd_t = ::c_int; +pub type sem_t = *mut sem; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum sem {} +impl ::Copy for sem {} +impl ::Clone for sem { + fn clone(&self) -> sem { + *self + } +} + +s! { + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::c_short, + pub flags: ::c_ushort, + pub fflags: ::c_uint, + pub data: ::intptr_t, + pub udata: *mut ::c_void, + } + + pub struct exit_status { + pub e_termination: u16, + pub e_exit: u16 + } + + pub struct aiocb { + pub aio_fildes: ::c_int, + pub aio_offset: ::off_t, + pub aio_buf: *mut ::c_void, + pub aio_nbytes: ::size_t, + pub aio_sigevent: sigevent, + pub aio_lio_opcode: ::c_int, + pub aio_reqprio: ::c_int, + _aio_val: ::c_int, + _aio_err: ::c_int + } + + pub struct uuid { + pub time_low: u32, + pub time_mid: u16, + pub time_hi_and_version: u16, + pub clock_seq_hi_and_reserved: u8, + pub clock_seq_low: u8, + pub node: [u8; 6], + } + + pub struct mq_attr { + pub mq_flags: ::c_long, + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_curmsgs: ::c_long, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub f_owner: ::uid_t, + pub f_type: ::c_uint, + pub f_syncreads: u64, + pub f_syncwrites: u64, + pub f_asyncreads: u64, + pub f_asyncwrites: u64, + pub f_fsid_uuid: ::uuid_t, + pub f_uid_uuid: ::uuid_t, + } + + pub struct stat { + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_dev: ::dev_t, + pub st_mode: ::mode_t, + pub st_padding1: u16, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: i64, + pub st_blksize: u32, + pub st_flags: u32, + pub st_gen: u32, + pub st_lspare: i32, + pub st_qspare1: i64, + pub st_qspare2: i64, + } + + pub struct if_data { + pub ifi_type: ::c_uchar, + pub ifi_physical: ::c_uchar, + pub ifi_addrlen: ::c_uchar, + pub ifi_hdrlen: ::c_uchar, + pub ifi_recvquota: ::c_uchar, + pub ifi_xmitquota: ::c_uchar, + pub ifi_mtu: ::c_ulong, + pub ifi_metric: ::c_ulong, + pub ifi_link_state: ::c_ulong, + pub ifi_baudrate: u64, + pub ifi_ipackets: ::c_ulong, + pub ifi_ierrors: ::c_ulong, + pub ifi_opackets: ::c_ulong, + pub ifi_oerrors: ::c_ulong, + pub ifi_collisions: ::c_ulong, + pub ifi_ibytes: ::c_ulong, + pub ifi_obytes: ::c_ulong, + pub ifi_imcasts: ::c_ulong, + pub ifi_omcasts: ::c_ulong, + pub ifi_iqdrops: ::c_ulong, + pub ifi_noproto: ::c_ulong, + pub ifi_hwassist: ::c_ulong, + pub ifi_oqdrops: ::c_ulong, + pub ifi_lastchange: ::timeval, + } + + pub struct if_msghdr { + pub ifm_msglen: ::c_ushort, + pub ifm_version: ::c_uchar, + pub ifm_type: ::c_uchar, + pub ifm_addrs: ::c_int, + pub ifm_flags: ::c_int, + pub ifm_index: ::c_ushort, + pub ifm_data: if_data, + } + + pub struct sockaddr_dl { + pub sdl_len: ::c_uchar, + pub sdl_family: ::c_uchar, + pub sdl_index: ::c_ushort, + pub sdl_type: ::c_uchar, + pub sdl_nlen: ::c_uchar, + pub sdl_alen: ::c_uchar, + pub sdl_slen: ::c_uchar, + pub sdl_data: [::c_char; 12], + pub sdl_rcf: ::c_ushort, + pub sdl_route: [::c_ushort; 16], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_char, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } +} + +s_no_extra_traits! { + pub struct utmpx { + pub ut_name: [::c_char; 32], + pub ut_id: [::c_char; 4], + + pub ut_line: [::c_char; 32], + pub ut_host: [::c_char; 256], + + pub ut_unused: [u8; 16], + pub ut_session: u16, + pub ut_type: u16, + pub ut_pid: ::pid_t, + ut_exit: exit_status, + ut_ss: ::sockaddr_storage, + pub ut_tv: ::timeval, + pub ut_unused2: [u8; 16], + } + + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_namlen: u16, + pub d_type: u8, + __unused1: u8, + __unused2: u32, + pub d_name: [::c_char; 256], + } + + pub struct statfs { + pub f_bsize: ::c_long, + pub f_iosize: ::c_long, + pub f_blocks: ::c_long, + pub f_bfree: ::c_long, + pub f_bavail: ::c_long, + pub f_files: ::c_long, + pub f_ffree: ::c_long, + pub f_fsid: ::fsid_t, + pub f_owner: ::uid_t, + pub f_type: i32, + pub f_flags: i32, + pub f_syncwrites: ::c_long, + pub f_asyncwrites: ::c_long, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 90], + pub f_syncreads: ::c_long, + pub f_asyncreads: ::c_long, + pub f_mntfromname: [::c_char; 90], + } + + pub struct sigevent { + pub sigev_notify: ::c_int, + // The union is 8-byte in size, so it is aligned at a 8-byte offset. + #[cfg(target_pointer_width = "64")] + __unused1: ::c_int, + pub sigev_signo: ::c_int, //actually a union + // pad the union + #[cfg(target_pointer_width = "64")] + __unused2: ::c_int, + pub sigev_value: ::sigval, + __unused3: *mut ::c_void //actually a function pointer + } + +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_name == other.ut_name + && self.ut_id == other.ut_id + && self.ut_line == other.ut_line + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self.ut_unused == other.ut_unused + && self.ut_session == other.ut_session + && self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self.ut_exit == other.ut_exit + && self.ut_ss == other.ut_ss + && self.ut_tv == other.ut_tv + && self.ut_unused2 == other.ut_unused2 + } + } + impl Eq for utmpx {} + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmpx") + .field("ut_name", &self.ut_name) + .field("ut_id", &self.ut_id) + .field("ut_line", &self.ut_line) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_unused", &self.ut_unused) + .field("ut_session", &self.ut_session) + .field("ut_type", &self.ut_type) + .field("ut_pid", &self.ut_pid) + .field("ut_exit", &self.ut_exit) + .field("ut_ss", &self.ut_ss) + .field("ut_tv", &self.ut_tv) + .field("ut_unused2", &self.ut_unused2) + .finish() + } + } + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_name.hash(state); + self.ut_id.hash(state); + self.ut_line.hash(state); + self.ut_host.hash(state); + self.ut_unused.hash(state); + self.ut_session.hash(state); + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_exit.hash(state); + self.ut_ss.hash(state); + self.ut_tv.hash(state); + self.ut_unused2.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_fileno == other.d_fileno + && self.d_namlen == other.d_namlen + && self.d_type == other.d_type + // Ignore __unused1 + // Ignore __unused2 + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_fileno", &self.d_fileno) + .field("d_namlen", &self.d_namlen) + .field("d_type", &self.d_type) + // Ignore __unused1 + // Ignore __unused2 + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_fileno.hash(state); + self.d_namlen.hash(state); + self.d_type.hash(state); + // Ignore __unused1 + // Ignore __unused2 + self.d_name.hash(state); + } + } + + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_fsid == other.f_fsid + && self.f_owner == other.f_owner + && self.f_type == other.f_type + && self.f_flags == other.f_flags + && self.f_syncwrites == other.f_syncwrites + && self.f_asyncwrites == other.f_asyncwrites + && self.f_fstypename == other.f_fstypename + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + && self.f_syncreads == other.f_syncreads + && self.f_asyncreads == other.f_asyncreads + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for statfs {} + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_fsid", &self.f_fsid) + .field("f_owner", &self.f_owner) + .field("f_type", &self.f_type) + .field("f_flags", &self.f_flags) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_asyncwrites", &self.f_asyncwrites) + // FIXME: .field("f_mntonname", &self.f_mntonname) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncreads", &self.f_asyncreads) + // FIXME: .field("f_mntfromname", &self.f_mntfromname) + .finish() + } + } + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_fsid.hash(state); + self.f_owner.hash(state); + self.f_type.hash(state); + self.f_flags.hash(state); + self.f_syncwrites.hash(state); + self.f_asyncwrites.hash(state); + self.f_fstypename.hash(state); + self.f_mntonname.hash(state); + self.f_syncreads.hash(state); + self.f_asyncreads.hash(state); + self.f_mntfromname.hash(state); + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_notify == other.sigev_notify + && self.sigev_signo == other.sigev_signo + && self.sigev_value == other.sigev_value + } + } + impl Eq for sigevent {} + impl ::fmt::Debug for sigevent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sigevent") + .field("sigev_notify", &self.sigev_notify) + .field("sigev_signo", &self.sigev_signo) + .field("sigev_value", &self.sigev_value) + .finish() + } + } + impl ::hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_notify.hash(state); + self.sigev_signo.hash(state); + self.sigev_value.hash(state); + } + } + } +} + +pub const RAND_MAX: ::c_int = 0x7fff_ffff; +pub const PTHREAD_STACK_MIN: ::size_t = 16384; +pub const SIGSTKSZ: ::size_t = 40960; +pub const MADV_INVAL: ::c_int = 10; +pub const MADV_SETMAP: ::c_int = 11; +pub const O_CLOEXEC: ::c_int = 0x00020000; +pub const O_DIRECTORY: ::c_int = 0x08000000; +pub const F_GETLK: ::c_int = 7; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; +pub const ENOMEDIUM: ::c_int = 93; +pub const EASYNC: ::c_int = 99; +pub const ELAST: ::c_int = 99; +pub const RLIMIT_POSIXLOCKS: ::c_int = 11; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: ::rlim_t = 12; + +pub const Q_GETQUOTA: ::c_int = 0x300; +pub const Q_SETQUOTA: ::c_int = 0x400; + +pub const CLOCK_REALTIME: ::clockid_t = 0; +pub const CLOCK_VIRTUAL: ::clockid_t = 1; +pub const CLOCK_PROF: ::clockid_t = 2; +pub const CLOCK_MONOTONIC: ::clockid_t = 4; +pub const CLOCK_UPTIME: ::clockid_t = 5; +pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7; +pub const CLOCK_UPTIME_FAST: ::clockid_t = 8; +pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9; +pub const CLOCK_REALTIME_FAST: ::clockid_t = 10; +pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11; +pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12; +pub const CLOCK_SECOND: ::clockid_t = 13; +pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14; +pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15; + +pub const CTL_UNSPEC: ::c_int = 0; +pub const CTL_KERN: ::c_int = 1; +pub const CTL_VM: ::c_int = 2; +pub const CTL_VFS: ::c_int = 3; +pub const CTL_NET: ::c_int = 4; +pub const CTL_DEBUG: ::c_int = 5; +pub const CTL_HW: ::c_int = 6; +pub const CTL_MACHDEP: ::c_int = 7; +pub const CTL_USER: ::c_int = 8; +pub const CTL_P1003_1B: ::c_int = 9; +pub const CTL_LWKT: ::c_int = 10; +pub const CTL_MAXID: ::c_int = 11; +pub const KERN_OSTYPE: ::c_int = 1; +pub const KERN_OSRELEASE: ::c_int = 2; +pub const KERN_OSREV: ::c_int = 3; +pub const KERN_VERSION: ::c_int = 4; +pub const KERN_MAXVNODES: ::c_int = 5; +pub const KERN_MAXPROC: ::c_int = 6; +pub const KERN_MAXFILES: ::c_int = 7; +pub const KERN_ARGMAX: ::c_int = 8; +pub const KERN_SECURELVL: ::c_int = 9; +pub const KERN_HOSTNAME: ::c_int = 10; +pub const KERN_HOSTID: ::c_int = 11; +pub const KERN_CLOCKRATE: ::c_int = 12; +pub const KERN_VNODE: ::c_int = 13; +pub const KERN_PROC: ::c_int = 14; +pub const KERN_FILE: ::c_int = 15; +pub const KERN_PROF: ::c_int = 16; +pub const KERN_POSIX1: ::c_int = 17; +pub const KERN_NGROUPS: ::c_int = 18; +pub const KERN_JOB_CONTROL: ::c_int = 19; +pub const KERN_SAVED_IDS: ::c_int = 20; +pub const KERN_BOOTTIME: ::c_int = 21; +pub const KERN_NISDOMAINNAME: ::c_int = 22; +pub const KERN_UPDATEINTERVAL: ::c_int = 23; +pub const KERN_OSRELDATE: ::c_int = 24; +pub const KERN_NTP_PLL: ::c_int = 25; +pub const KERN_BOOTFILE: ::c_int = 26; +pub const KERN_MAXFILESPERPROC: ::c_int = 27; +pub const KERN_MAXPROCPERUID: ::c_int = 28; +pub const KERN_DUMPDEV: ::c_int = 29; +pub const KERN_IPC: ::c_int = 30; +pub const KERN_DUMMY: ::c_int = 31; +pub const KERN_PS_STRINGS: ::c_int = 32; +pub const KERN_USRSTACK: ::c_int = 33; +pub const KERN_LOGSIGEXIT: ::c_int = 34; +pub const KERN_IOV_MAX: ::c_int = 35; +pub const KERN_MAXPOSIXLOCKSPERUID: ::c_int = 36; +pub const KERN_MAXID: ::c_int = 37; +pub const KERN_PROC_ALL: ::c_int = 0; +pub const KERN_PROC_PID: ::c_int = 1; +pub const KERN_PROC_PGRP: ::c_int = 2; +pub const KERN_PROC_SESSION: ::c_int = 3; +pub const KERN_PROC_TTY: ::c_int = 4; +pub const KERN_PROC_UID: ::c_int = 5; +pub const KERN_PROC_RUID: ::c_int = 6; +pub const KERN_PROC_ARGS: ::c_int = 7; +pub const KERN_PROC_CWD: ::c_int = 8; +pub const KERN_PROC_PATHNAME: ::c_int = 9; +pub const KERN_PROC_FLAGMASK: ::c_int = 0x10; +pub const KERN_PROC_FLAG_LWP: ::c_int = 0x10; +pub const KIPC_MAXSOCKBUF: ::c_int = 1; +pub const KIPC_SOCKBUF_WASTE: ::c_int = 2; +pub const KIPC_SOMAXCONN: ::c_int = 3; +pub const KIPC_MAX_LINKHDR: ::c_int = 4; +pub const KIPC_MAX_PROTOHDR: ::c_int = 5; +pub const KIPC_MAX_HDR: ::c_int = 6; +pub const KIPC_MAX_DATALEN: ::c_int = 7; +pub const KIPC_MBSTAT: ::c_int = 8; +pub const KIPC_NMBCLUSTERS: ::c_int = 9; +pub const HW_MACHINE: ::c_int = 1; +pub const HW_MODEL: ::c_int = 2; +pub const HW_NCPU: ::c_int = 3; +pub const HW_BYTEORDER: ::c_int = 4; +pub const HW_PHYSMEM: ::c_int = 5; +pub const HW_USERMEM: ::c_int = 6; +pub const HW_PAGESIZE: ::c_int = 7; +pub const HW_DISKNAMES: ::c_int = 8; +pub const HW_DISKSTATS: ::c_int = 9; +pub const HW_FLOATINGPT: ::c_int = 10; +pub const HW_MACHINE_ARCH: ::c_int = 11; +pub const HW_MACHINE_PLATFORM: ::c_int = 12; +pub const HW_SENSORS: ::c_int = 13; +pub const HW_MAXID: ::c_int = 14; +pub const USER_CS_PATH: ::c_int = 1; +pub const USER_BC_BASE_MAX: ::c_int = 2; +pub const USER_BC_DIM_MAX: ::c_int = 3; +pub const USER_BC_SCALE_MAX: ::c_int = 4; +pub const USER_BC_STRING_MAX: ::c_int = 5; +pub const USER_COLL_WEIGHTS_MAX: ::c_int = 6; +pub const USER_EXPR_NEST_MAX: ::c_int = 7; +pub const USER_LINE_MAX: ::c_int = 8; +pub const USER_RE_DUP_MAX: ::c_int = 9; +pub const USER_POSIX2_VERSION: ::c_int = 10; +pub const USER_POSIX2_C_BIND: ::c_int = 11; +pub const USER_POSIX2_C_DEV: ::c_int = 12; +pub const USER_POSIX2_CHAR_TERM: ::c_int = 13; +pub const USER_POSIX2_FORT_DEV: ::c_int = 14; +pub const USER_POSIX2_FORT_RUN: ::c_int = 15; +pub const USER_POSIX2_LOCALEDEF: ::c_int = 16; +pub const USER_POSIX2_SW_DEV: ::c_int = 17; +pub const USER_POSIX2_UPE: ::c_int = 18; +pub const USER_STREAM_MAX: ::c_int = 19; +pub const USER_TZNAME_MAX: ::c_int = 20; +pub const USER_MAXID: ::c_int = 21; +pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1; +pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2; +pub const CTL_P1003_1B_MEMLOCK: ::c_int = 3; +pub const CTL_P1003_1B_MEMLOCK_RANGE: ::c_int = 4; +pub const CTL_P1003_1B_MEMORY_PROTECTION: ::c_int = 5; +pub const CTL_P1003_1B_MESSAGE_PASSING: ::c_int = 6; +pub const CTL_P1003_1B_PRIORITIZED_IO: ::c_int = 7; +pub const CTL_P1003_1B_PRIORITY_SCHEDULING: ::c_int = 8; +pub const CTL_P1003_1B_REALTIME_SIGNALS: ::c_int = 9; +pub const CTL_P1003_1B_SEMAPHORES: ::c_int = 10; +pub const CTL_P1003_1B_FSYNC: ::c_int = 11; +pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: ::c_int = 12; +pub const CTL_P1003_1B_SYNCHRONIZED_IO: ::c_int = 13; +pub const CTL_P1003_1B_TIMERS: ::c_int = 14; +pub const CTL_P1003_1B_AIO_LISTIO_MAX: ::c_int = 15; +pub const CTL_P1003_1B_AIO_MAX: ::c_int = 16; +pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: ::c_int = 17; +pub const CTL_P1003_1B_DELAYTIMER_MAX: ::c_int = 18; +pub const CTL_P1003_1B_UNUSED1: ::c_int = 19; +pub const CTL_P1003_1B_PAGESIZE: ::c_int = 20; +pub const CTL_P1003_1B_RTSIG_MAX: ::c_int = 21; +pub const CTL_P1003_1B_SEM_NSEMS_MAX: ::c_int = 22; +pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23; +pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24; +pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25; +pub const CTL_P1003_1B_MAXID: ::c_int = 26; + +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_EXCEPT: i16 = -8; +pub const EVFILT_USER: i16 = -9; +pub const EVFILT_FS: i16 = -10; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_NODATA: u16 = 0x1000; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; +pub const EV_SYSFLAGS: u16 = 0xf000; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_OOB: u32 = 0x00000002; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; + +pub const SO_SNDSPACE: ::c_int = 0x100a; +pub const SO_CPUHINT: ::c_int = 0x1030; + +pub const PT_FIRSTMACH: ::c_int = 32; + +// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/net/if.h#L101 +pub const IFF_UP: ::c_int = 0x1; // interface is up +pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid +pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging +pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link +pub const IFF_SMART: ::c_int = 0x20; // interface manages own routes +pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated +pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE_COMPAT: ::c_int = 0x400; // was transmission in progress +pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit +pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection +pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast + // was interface is in polling mode +pub const IFF_POLLING_COMPAT: ::c_int = 0x10000; +pub const IFF_PPROMISC: ::c_int = 0x20000; // user-requested promisc mode +pub const IFF_MONITOR: ::c_int = 0x40000; // user-requested monitor mode +pub const IFF_STATICARP: ::c_int = 0x80000; // static ARP +pub const IFF_NPOLLING: ::c_int = 0x100000; // interface is in polling mode +pub const IFF_IDIRECT: ::c_int = 0x200000; // direct input + +// +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// IP6 hop-by-hop options +pub const IPPROTO_HOPOPTS: ::c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: ::c_int = 2; +/// gateway^2 (deprecated) +pub const IPPROTO_GGP: ::c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: ::c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// Stream protocol II. +pub const IPPROTO_ST: ::c_int = 7; +/// exterior gateway protocol +pub const IPPROTO_EGP: ::c_int = 8; +/// private interior gateway +pub const IPPROTO_PIGP: ::c_int = 9; +/// BBN RCC Monitoring +pub const IPPROTO_RCCMON: ::c_int = 10; +/// network voice protocol +pub const IPPROTO_NVPII: ::c_int = 11; +/// pup +pub const IPPROTO_PUP: ::c_int = 12; +/// Argus +pub const IPPROTO_ARGUS: ::c_int = 13; +/// EMCON +pub const IPPROTO_EMCON: ::c_int = 14; +/// Cross Net Debugger +pub const IPPROTO_XNET: ::c_int = 15; +/// Chaos +pub const IPPROTO_CHAOS: ::c_int = 16; +// IPPROTO_UDP defined in src/unix/mod.rs +/// Multiplexing +pub const IPPROTO_MUX: ::c_int = 18; +/// DCN Measurement Subsystems +pub const IPPROTO_MEAS: ::c_int = 19; +/// Host Monitoring +pub const IPPROTO_HMP: ::c_int = 20; +/// Packet Radio Measurement +pub const IPPROTO_PRM: ::c_int = 21; +/// xns idp +pub const IPPROTO_IDP: ::c_int = 22; +/// Trunk-1 +pub const IPPROTO_TRUNK1: ::c_int = 23; +/// Trunk-2 +pub const IPPROTO_TRUNK2: ::c_int = 24; +/// Leaf-1 +pub const IPPROTO_LEAF1: ::c_int = 25; +/// Leaf-2 +pub const IPPROTO_LEAF2: ::c_int = 26; +/// Reliable Data +pub const IPPROTO_RDP: ::c_int = 27; +/// Reliable Transaction +pub const IPPROTO_IRTP: ::c_int = 28; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: ::c_int = 29; +/// Bulk Data Transfer +pub const IPPROTO_BLT: ::c_int = 30; +/// Network Services +pub const IPPROTO_NSP: ::c_int = 31; +/// Merit Internodal +pub const IPPROTO_INP: ::c_int = 32; +/// Sequential Exchange +pub const IPPROTO_SEP: ::c_int = 33; +/// Third Party Connect +pub const IPPROTO_3PC: ::c_int = 34; +/// InterDomain Policy Routing +pub const IPPROTO_IDPR: ::c_int = 35; +/// XTP +pub const IPPROTO_XTP: ::c_int = 36; +/// Datagram Delivery +pub const IPPROTO_DDP: ::c_int = 37; +/// Control Message Transport +pub const IPPROTO_CMTP: ::c_int = 38; +/// TP++ Transport +pub const IPPROTO_TPXX: ::c_int = 39; +/// IL transport protocol +pub const IPPROTO_IL: ::c_int = 40; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// Source Demand Routing +pub const IPPROTO_SDRP: ::c_int = 42; +/// IP6 routing header +pub const IPPROTO_ROUTING: ::c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: ::c_int = 44; +/// InterDomain Routing +pub const IPPROTO_IDRP: ::c_int = 45; +/// resource reservation +pub const IPPROTO_RSVP: ::c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: ::c_int = 47; +/// Mobile Host Routing +pub const IPPROTO_MHRP: ::c_int = 48; +/// BHA +pub const IPPROTO_BHA: ::c_int = 49; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: ::c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: ::c_int = 51; +/// Integ. Net Layer Security +pub const IPPROTO_INLSP: ::c_int = 52; +/// IP with encryption +pub const IPPROTO_SWIPE: ::c_int = 53; +/// Next Hop Resolution +pub const IPPROTO_NHRP: ::c_int = 54; +/// IP Mobility +pub const IPPROTO_MOBILE: ::c_int = 55; +/// Transport Layer Security +pub const IPPROTO_TLSP: ::c_int = 56; +/// SKIP +pub const IPPROTO_SKIP: ::c_int = 57; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: ::c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: ::c_int = 60; +/// any host internal protocol +pub const IPPROTO_AHIP: ::c_int = 61; +/// CFTP +pub const IPPROTO_CFTP: ::c_int = 62; +/// "hello" routing protocol +pub const IPPROTO_HELLO: ::c_int = 63; +/// SATNET/Backroom EXPAK +pub const IPPROTO_SATEXPAK: ::c_int = 64; +/// Kryptolan +pub const IPPROTO_KRYPTOLAN: ::c_int = 65; +/// Remote Virtual Disk +pub const IPPROTO_RVD: ::c_int = 66; +/// Pluribus Packet Core +pub const IPPROTO_IPPC: ::c_int = 67; +/// Any distributed FS +pub const IPPROTO_ADFS: ::c_int = 68; +/// Satnet Monitoring +pub const IPPROTO_SATMON: ::c_int = 69; +/// VISA Protocol +pub const IPPROTO_VISA: ::c_int = 70; +/// Packet Core Utility +pub const IPPROTO_IPCV: ::c_int = 71; +/// Comp. Prot. Net. Executive +pub const IPPROTO_CPNX: ::c_int = 72; +/// Comp. Prot. HeartBeat +pub const IPPROTO_CPHB: ::c_int = 73; +/// Wang Span Network +pub const IPPROTO_WSN: ::c_int = 74; +/// Packet Video Protocol +pub const IPPROTO_PVP: ::c_int = 75; +/// BackRoom SATNET Monitoring +pub const IPPROTO_BRSATMON: ::c_int = 76; +/// Sun net disk proto (temp.) +pub const IPPROTO_ND: ::c_int = 77; +/// WIDEBAND Monitoring +pub const IPPROTO_WBMON: ::c_int = 78; +/// WIDEBAND EXPAK +pub const IPPROTO_WBEXPAK: ::c_int = 79; +/// ISO cnlp +pub const IPPROTO_EON: ::c_int = 80; +/// VMTP +pub const IPPROTO_VMTP: ::c_int = 81; +/// Secure VMTP +pub const IPPROTO_SVMTP: ::c_int = 82; +/// Banyon VINES +pub const IPPROTO_VINES: ::c_int = 83; +/// TTP +pub const IPPROTO_TTP: ::c_int = 84; +/// NSFNET-IGP +pub const IPPROTO_IGP: ::c_int = 85; +/// dissimilar gateway prot. +pub const IPPROTO_DGP: ::c_int = 86; +/// TCF +pub const IPPROTO_TCF: ::c_int = 87; +/// Cisco/GXS IGRP +pub const IPPROTO_IGRP: ::c_int = 88; +/// OSPFIGP +pub const IPPROTO_OSPFIGP: ::c_int = 89; +/// Strite RPC protocol +pub const IPPROTO_SRPC: ::c_int = 90; +/// Locus Address Resoloution +pub const IPPROTO_LARP: ::c_int = 91; +/// Multicast Transport +pub const IPPROTO_MTP: ::c_int = 92; +/// AX.25 Frames +pub const IPPROTO_AX25: ::c_int = 93; +/// IP encapsulated in IP +pub const IPPROTO_IPEIP: ::c_int = 94; +/// Mobile Int.ing control +pub const IPPROTO_MICP: ::c_int = 95; +/// Semaphore Comm. security +pub const IPPROTO_SCCSP: ::c_int = 96; +/// Ethernet IP encapsulation +pub const IPPROTO_ETHERIP: ::c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: ::c_int = 98; +/// any private encr. scheme +pub const IPPROTO_APES: ::c_int = 99; +/// GMTP +pub const IPPROTO_GMTP: ::c_int = 100; +/// payload compression (IPComp) +pub const IPPROTO_IPCOMP: ::c_int = 108; + +/* 101-254: Partly Unassigned */ +/// Protocol Independent Mcast +pub const IPPROTO_PIM: ::c_int = 103; +/// CARP +pub const IPPROTO_CARP: ::c_int = 112; +/// PGM +pub const IPPROTO_PGM: ::c_int = 113; +/// PFSYNC +pub const IPPROTO_PFSYNC: ::c_int = 240; + +/* 255: Reserved */ +/* BSD Private, local use, namespace incursion, no longer used */ +/// divert pseudo-protocol +pub const IPPROTO_DIVERT: ::c_int = 254; +pub const IPPROTO_MAX: ::c_int = 256; +/// last return value of *_input(), meaning "all job for this pkt is done". +pub const IPPROTO_DONE: ::c_int = 257; + +/// Used by RSS: the layer3 protocol is unknown +pub const IPPROTO_UNKNOWN: ::c_int = 258; + +// sys/netinet/tcp.h +pub const TCP_SIGNATURE_ENABLE: ::c_int = 16; +pub const TCP_KEEPINIT: ::c_int = 32; +pub const TCP_FASTKEEP: ::c_int = 128; + +pub const AF_BLUETOOTH: ::c_int = 33; +pub const AF_MPLS: ::c_int = 34; +pub const AF_IEEE80211: ::c_int = 35; + +pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; + +pub const NET_RT_DUMP: ::c_int = 1; +pub const NET_RT_FLAGS: ::c_int = 2; +pub const NET_RT_IFLIST: ::c_int = 3; +pub const NET_RT_MAXID: ::c_int = 4; + +pub const SOMAXOPT_SIZE: ::c_int = 65536; + +pub const MSG_UNUSED09: ::c_int = 0x00000200; +pub const MSG_NOSIGNAL: ::c_int = 0x00000400; +pub const MSG_SYNC: ::c_int = 0x00000800; +pub const MSG_CMSG_CLOEXEC: ::c_int = 0x00001000; +pub const MSG_FBLOCKING: ::c_int = 0x00010000; +pub const MSG_FNONBLOCKING: ::c_int = 0x00020000; +pub const MSG_FMASK: ::c_int = 0xFFFF0000; + +// utmpx entry types +pub const EMPTY: ::c_short = 0; +pub const RUN_LVL: ::c_short = 1; +pub const BOOT_TIME: ::c_short = 2; +pub const OLD_TIME: ::c_short = 3; +pub const NEW_TIME: ::c_short = 4; +pub const INIT_PROCESS: ::c_short = 5; +pub const LOGIN_PROCESS: ::c_short = 6; +pub const USER_PROCESS: ::c_short = 7; +pub const DEAD_PROCESS: ::c_short = 8; +pub const ACCOUNTING: ::c_short = 9; +pub const SIGNATURE: ::c_short = 10; +pub const DOWNTIME: ::c_short = 11; +// utmpx database types +pub const UTX_DB_UTMPX: ::c_uint = 0; +pub const UTX_DB_WTMPX: ::c_uint = 1; +pub const UTX_DB_LASTLOG: ::c_uint = 2; + +pub const LC_COLLATE_MASK: ::c_int = (1 << 0); +pub const LC_CTYPE_MASK: ::c_int = (1 << 1); +pub const LC_MONETARY_MASK: ::c_int = (1 << 2); +pub const LC_NUMERIC_MASK: ::c_int = (1 << 3); +pub const LC_TIME_MASK: ::c_int = (1 << 4); +pub const LC_MESSAGES_MASK: ::c_int = (1 << 5); +pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK + | LC_CTYPE_MASK + | LC_MESSAGES_MASK + | LC_MONETARY_MASK + | LC_NUMERIC_MASK + | LC_TIME_MASK; + +pub const TIOCSIG: ::c_uint = 0x2000745f; +pub const BTUARTDISC: ::c_int = 0x7; +pub const TIOCDCDTIMESTAMP: ::c_uint = 0x40107458; +pub const TIOCISPTMASTER: ::c_uint = 0x20007455; +pub const TIOCMODG: ::c_uint = 0x40047403; +pub const TIOCMODS: ::c_ulong = 0x80047404; +pub const TIOCREMOTE: ::c_ulong = 0x80047469; + +// Constants used by "at" family of system calls. +pub const AT_FDCWD: ::c_int = 0xFFFAFDCD; // invalid file descriptor +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 1; +pub const AT_REMOVEDIR: ::c_int = 2; +pub const AT_EACCESS: ::c_int = 4; +pub const AT_SYMLINK_FOLLOW: ::c_int = 8; + +pub const VCHECKPT: usize = 19; + +pub const _PC_2_SYMLINKS: ::c_int = 22; +pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 23; + +pub const _SC_V7_ILP32_OFF32: ::c_int = 122; +pub const _SC_V7_ILP32_OFFBIG: ::c_int = 123; +pub const _SC_V7_LP64_OFF64: ::c_int = 124; +pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 125; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 126; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 127; + +pub const WCONTINUED: ::c_int = 4; +pub const WSTOPPED: ::c_int = 0o177; + +// Values for struct rtprio (type_ field) +pub const RTP_PRIO_REALTIME: ::c_ushort = 0; +pub const RTP_PRIO_NORMAL: ::c_ushort = 1; +pub const RTP_PRIO_IDLE: ::c_ushort = 2; +pub const RTP_PRIO_THREAD: ::c_ushort = 3; + +// Flags for chflags(2) +pub const UF_NOHISTORY: ::c_ulong = 0x00000040; +pub const UF_CACHE: ::c_ulong = 0x00000080; +pub const UF_XLINK: ::c_ulong = 0x00000100; +pub const SF_NOHISTORY: ::c_ulong = 0x00400000; +pub const SF_CACHE: ::c_ulong = 0x00800000; +pub const SF_XLINK: ::c_ulong = 0x01000000; + +// timespec constants +pub const UTIME_OMIT: c_long = -2; +pub const UTIME_NOW: c_long = -1; + +fn _CMSG_ALIGN(n: usize) -> usize { + (n + 3) & !3 +} + +f! { + pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { + (cmsg as *mut ::c_uchar) + .offset(_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + length as usize) + as ::c_uint + } + + pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) + -> *mut ::cmsghdr + { + let next = cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize) + + _CMSG_ALIGN(::mem::size_of::<::cmsghdr>()); + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next <= max { + (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)) + as *mut ::cmsghdr + } else { + 0 as *mut ::cmsghdr + } + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + + _CMSG_ALIGN(length as usize)) as ::c_uint + } +} + +extern "C" { + pub fn setgrent(); + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_settime( + clk_id: ::clockid_t, + tp: *const ::timespec, + ) -> ::c_int; + + pub fn setutxdb(_type: ::c_uint, file: *mut ::c_char) -> ::c_int; + + pub fn aio_waitcomplete( + iocbp: *mut *mut aiocb, + timeout: *mut ::timespec, + ) -> ::c_int; + + pub fn freelocale(loc: ::locale_t); + + pub fn lwp_rtprio( + function: ::c_int, + pid: ::pid_t, + lwpid: lwpid_t, + rtp: *mut super::rtprio, + ) -> ::c_int; + + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + pub fn uname(buf: *mut ::utsname) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_thread_local)] { + mod errno; + pub use self::errno::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/aarch64.rs new file mode 100644 index 0000000..22fd2b8 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -0,0 +1,44 @@ +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type time_t = i64; +pub type suseconds_t = i64; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + } +} + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const MAP_32BIT: ::c_int = 0x00080000; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/arm.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/arm.rs new file mode 100644 index 0000000..b7480aa --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -0,0 +1,47 @@ +pub type c_char = u8; +pub type c_long = i32; +pub type c_ulong = u32; +pub type time_t = i64; +pub type suseconds_t = i32; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_atime_pad: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_mtime_pad: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_ctime_pad: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + pub st_birthtime_pad: ::c_long, + } +} + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 4 - 1; + } +} +pub const MAP_32BIT: ::c_int = 0x00080000; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs new file mode 100644 index 0000000..79a152f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -0,0 +1,224 @@ +// APIs that had breaking changes after FreeBSD 11 + +// The type of `nlink_t` changed from `u16` to `u64` in FreeBSD 12: +pub type nlink_t = u16; +// Type of `dev_t` changed from `u32` to `u64` in FreeBSD 12: +pub type dev_t = u32; +// Type of `ino_t` changed from `unsigned int` to `unsigned long` in FreeBSD 12: +pub type ino_t = u32; + +s! { + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::c_short, + pub flags: ::c_ushort, + pub fflags: ::c_uint, + pub data: ::intptr_t, + pub udata: *mut ::c_void, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + // Type of shm_nattc changed from `int` to `shmatt_t` (aka `unsigned + // int`) in FreeBSD 12: + pub shm_nattch: ::c_int, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + } +} + +s_no_extra_traits! { + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_reclen: u16, + pub d_type: u8, + // Type of `d_namlen` changed from `char` to `u16` in FreeBSD 12: + pub d_namlen: u8, + pub d_name: [::c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: ::uid_t, + pub f_fsid: ::fsid_t, + f_charspare: [::c_char; 80], + pub f_fstypename: [::c_char; 16], + // Array length changed from 88 to 1024 in FreeBSD 12: + pub f_mntfromname: [::c_char; 88], + // Array length changed from 88 to 1024 in FreeBSD 12: + pub f_mntonname: [::c_char; 88], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_version == other.f_version + && self.f_type == other.f_type + && self.f_flags == other.f_flags + && self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_syncwrites == other.f_syncwrites + && self.f_asyncwrites == other.f_asyncwrites + && self.f_syncreads == other.f_syncreads + && self.f_asyncreads == other.f_asyncreads + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_fsid == other.f_fsid + && self.f_fstypename == other.f_fstypename + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for statfs {} + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_fsid", &self.f_fsid) + .field("f_fstypename", &self.f_fstypename) + .field("f_mntfromname", &&self.f_mntfromname[..]) + .field("f_mntonname", &&self.f_mntonname[..]) + .finish() + } + } + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_version.hash(state); + self.f_type.hash(state); + self.f_flags.hash(state); + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_syncwrites.hash(state); + self.f_asyncwrites.hash(state); + self.f_syncreads.hash(state); + self.f_asyncreads.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_fsid.hash(state); + self.f_fstypename.hash(state); + self.f_mntfromname.hash(state); + self.f_mntonname.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_fileno == other.d_fileno + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self.d_namlen == other.d_namlen + && self + .d_name[..self.d_namlen as _] + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_fileno", &self.d_fileno) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + .field("d_namlen", &self.d_namlen) + .field("d_name", &&self.d_name[..self.d_namlen as _]) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_fileno.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_namlen.hash(state); + self.d_name[..self.d_namlen as _].hash(state); + } + } + } +} + +pub const ELAST: ::c_int = 96; + +extern "C" { + // Return type ::c_int was removed in FreeBSD 12 + pub fn setgrent() -> ::c_int; + + // Type of `addr` argument changed from `const void*` to `void*` + // in FreeBSD 12 + pub fn mprotect( + addr: *const ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + + // Return type ::c_int was removed in FreeBSD 12 + pub fn freelocale(loc: ::locale_t) -> ::c_int; + + // Return type ::c_int changed to ::ssize_t in FreeBSD 12: + pub fn msgrcv( + msqid: ::c_int, + msgp: *mut ::c_void, + msgsz: ::size_t, + msgtyp: ::c_long, + msgflg: ::c_int, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs new file mode 100644 index 0000000..f32128f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs @@ -0,0 +1,32 @@ +#[repr(C)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] +pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, +} + +impl ::Copy for ::stat {} +impl ::Clone for ::stat { + fn clone(&self) -> ::stat { + *self + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs new file mode 100644 index 0000000..6bf7f95 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -0,0 +1,224 @@ +// APIs that changed in FreeBSD12 + +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = ::c_ulong; +pub type shmatt_t = ::c_uint; + +s! { + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + } + + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::c_short, + pub flags: ::c_ushort, + pub fflags: ::c_uint, + pub data: ::intptr_t, + pub udata: *mut ::c_void, + pub ext: [u64; 4], + } +} + +s_no_extra_traits! { + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: u16, + pub d_type: u8, + d_pad0: u8, + pub d_namlen: u16, + d_pad1: u16, + pub d_name: [::c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: ::uid_t, + pub f_fsid: ::fsid_t, + f_charspare: [::c_char; 80], + pub f_fstypename: [::c_char; 16], + pub f_mntfromname: [::c_char; 1024], + pub f_mntonname: [::c_char; 1024], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_version == other.f_version + && self.f_type == other.f_type + && self.f_flags == other.f_flags + && self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_syncwrites == other.f_syncwrites + && self.f_asyncwrites == other.f_asyncwrites + && self.f_syncreads == other.f_syncreads + && self.f_asyncreads == other.f_asyncreads + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_fsid == other.f_fsid + && self.f_fstypename == other.f_fstypename + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for statfs {} + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_fsid", &self.f_fsid) + .field("f_fstypename", &self.f_fstypename) + .field("f_mntfromname", &&self.f_mntfromname[..]) + .field("f_mntonname", &&self.f_mntonname[..]) + .finish() + } + } + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_version.hash(state); + self.f_type.hash(state); + self.f_flags.hash(state); + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_syncwrites.hash(state); + self.f_asyncwrites.hash(state); + self.f_syncreads.hash(state); + self.f_asyncreads.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_fsid.hash(state); + self.f_charspare.hash(state); + self.f_fstypename.hash(state); + self.f_mntfromname.hash(state); + self.f_mntonname.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_fileno == other.d_fileno + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self.d_namlen == other.d_namlen + && self + .d_name[..self.d_namlen as _] + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_fileno", &self.d_fileno) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + .field("d_namlen", &self.d_namlen) + .field("d_name", &&self.d_name[..self.d_namlen as _]) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_fileno.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_namlen.hash(state); + self.d_name[..self.d_namlen as _].hash(state); + } + } + } +} + +cfg_if! { + if #[cfg(not(freebsd13))] { + pub const ELAST: ::c_int = 96; + } else { + pub const EINTEGRITY: ::c_int = 97; + pub const ELAST: ::c_int = 97; + } +} + +extern "C" { + pub fn setgrent(); + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn freelocale(loc: ::locale_t); + pub fn msgrcv( + msqid: ::c_int, + msgp: *mut ::c_void, + msgsz: ::size_t, + msgtyp: ::c_long, + msgflg: ::c_int, + ) -> ::ssize_t; +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs new file mode 100644 index 0000000..80c6fa1 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs @@ -0,0 +1,34 @@ +#[repr(C)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] +pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + st_padding0: i16, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_padding1: i32, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], +} + +impl ::Copy for ::stat {} +impl ::Clone for ::stat { + fn clone(&self) -> ::stat { + *self + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/mod.rs new file mode 100644 index 0000000..980caf2 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -0,0 +1,1486 @@ +pub type fflags_t = u32; +pub type clock_t = i32; + +pub type lwpid_t = i32; +pub type blksize_t = i32; +pub type clockid_t = ::c_int; +pub type sem_t = _sem; + +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type idtype_t = ::c_uint; + +pub type key_t = ::c_long; +pub type msglen_t = ::c_ulong; +pub type msgqnum_t = ::c_ulong; + +pub type mqd_t = *mut ::c_void; +pub type posix_spawnattr_t = *mut ::c_void; +pub type posix_spawn_file_actions_t = *mut ::c_void; + +s! { + pub struct aiocb { + pub aio_fildes: ::c_int, + pub aio_offset: ::off_t, + pub aio_buf: *mut ::c_void, + pub aio_nbytes: ::size_t, + __unused1: [::c_int; 2], + __unused2: *mut ::c_void, + pub aio_lio_opcode: ::c_int, + pub aio_reqprio: ::c_int, + // unused 3 through 5 are the __aiocb_private structure + __unused3: ::c_long, + __unused4: ::c_long, + __unused5: *mut ::c_void, + pub aio_sigevent: sigevent + } + + pub struct jail { + pub version: u32, + pub path: *mut ::c_char, + pub hostname: *mut ::c_char, + pub jailname: *mut ::c_char, + pub ip4s: ::c_uint, + pub ip6s: ::c_uint, + pub ip4: *mut ::in_addr, + pub ip6: *mut ::in6_addr, + } + + pub struct statvfs { + pub f_bavail: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_blocks: ::fsblkcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_bsize: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_fsid: ::c_ulong, + pub f_namemax: ::c_ulong, + } + + // internal structure has changed over time + pub struct _sem { + data: [u32; 4], + } + + pub struct ipc_perm { + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub mode: ::mode_t, + pub seq: ::c_ushort, + pub key: ::key_t, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + pub msg_cbytes: ::msglen_t, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + pub msg_stime: ::time_t, + pub msg_rtime: ::time_t, + pub msg_ctime: ::time_t, + } + + pub struct xucred { + pub cr_version: ::c_uint, + pub cr_uid: ::uid_t, + pub cr_ngroups: ::c_short, + pub cr_groups: [::gid_t;16], + __cr_unused1: *mut ::c_void, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct mmsghdr { + pub msg_hdr: ::msghdr, + pub msg_len: ::ssize_t, + } +} + +s_no_extra_traits! { + pub struct utmpx { + pub ut_type: ::c_short, + pub ut_tv: ::timeval, + pub ut_id: [::c_char; 8], + pub ut_pid: ::pid_t, + pub ut_user: [::c_char; 32], + pub ut_line: [::c_char; 16], + pub ut_host: [::c_char; 128], + pub __ut_spare: [::c_char; 64], + } + + pub struct sockaddr_dl { + pub sdl_len: ::c_uchar, + pub sdl_family: ::c_uchar, + pub sdl_index: ::c_ushort, + pub sdl_type: ::c_uchar, + pub sdl_nlen: ::c_uchar, + pub sdl_alen: ::c_uchar, + pub sdl_slen: ::c_uchar, + pub sdl_data: [::c_char; 46], + } + + pub struct mq_attr { + pub mq_flags: ::c_long, + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_curmsgs: ::c_long, + __reserved: [::c_long; 4] + } + + pub struct sigevent { + pub sigev_notify: ::c_int, + pub sigev_signo: ::c_int, + pub sigev_value: ::sigval, + //The rest of the structure is actually a union. We expose only + //sigev_notify_thread_id because it's the most useful union member. + pub sigev_notify_thread_id: ::lwpid_t, + #[cfg(target_pointer_width = "64")] + __unused1: ::c_int, + __unused2: [::c_long; 7] + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_type == other.ut_type + && self.ut_tv == other.ut_tv + && self.ut_id == other.ut_id + && self.ut_pid == other.ut_pid + && self.ut_user == other.ut_user + && self.ut_line == other.ut_line + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self + .__ut_spare + .iter() + .zip(other.__ut_spare.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for utmpx {} + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmpx") + .field("ut_type", &self.ut_type) + .field("ut_tv", &self.ut_tv) + .field("ut_id", &self.ut_id) + .field("ut_pid", &self.ut_pid) + .field("ut_user", &self.ut_user) + .field("ut_line", &self.ut_line) + // FIXME: .field("ut_host", &self.ut_host) + // FIXME: .field("__ut_spare", &self.__ut_spare) + .finish() + } + } + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_type.hash(state); + self.ut_tv.hash(state); + self.ut_id.hash(state); + self.ut_pid.hash(state); + self.ut_user.hash(state); + self.ut_line.hash(state); + self.ut_host.hash(state); + self.__ut_spare.hash(state); + } + } + + impl PartialEq for sockaddr_dl { + fn eq(&self, other: &sockaddr_dl) -> bool { + self.sdl_len == other.sdl_len + && self.sdl_family == other.sdl_family + && self.sdl_index == other.sdl_index + && self.sdl_type == other.sdl_type + && self.sdl_nlen == other.sdl_nlen + && self.sdl_alen == other.sdl_alen + && self.sdl_slen == other.sdl_slen + && self + .sdl_data + .iter() + .zip(other.sdl_data.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sockaddr_dl {} + impl ::fmt::Debug for sockaddr_dl { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_dl") + .field("sdl_len", &self.sdl_len) + .field("sdl_family", &self.sdl_family) + .field("sdl_index", &self.sdl_index) + .field("sdl_type", &self.sdl_type) + .field("sdl_nlen", &self.sdl_nlen) + .field("sdl_alen", &self.sdl_alen) + .field("sdl_slen", &self.sdl_slen) + // FIXME: .field("sdl_data", &self.sdl_data) + .finish() + } + } + impl ::hash::Hash for sockaddr_dl { + fn hash(&self, state: &mut H) { + self.sdl_len.hash(state); + self.sdl_family.hash(state); + self.sdl_index.hash(state); + self.sdl_type.hash(state); + self.sdl_nlen.hash(state); + self.sdl_alen.hash(state); + self.sdl_slen.hash(state); + self.sdl_data.hash(state); + } + } + + impl PartialEq for mq_attr { + fn eq(&self, other: &mq_attr) -> bool { + self.mq_flags == other.mq_flags && + self.mq_maxmsg == other.mq_maxmsg && + self.mq_msgsize == other.mq_msgsize && + self.mq_curmsgs == other.mq_curmsgs + } + } + impl Eq for mq_attr {} + impl ::fmt::Debug for mq_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mq_attr") + .field("mq_flags", &self.mq_flags) + .field("mq_maxmsg", &self.mq_maxmsg) + .field("mq_msgsize", &self.mq_msgsize) + .field("mq_curmsgs", &self.mq_curmsgs) + .finish() + } + } + impl ::hash::Hash for mq_attr { + fn hash(&self, state: &mut H) { + self.mq_flags.hash(state); + self.mq_maxmsg.hash(state); + self.mq_msgsize.hash(state); + self.mq_curmsgs.hash(state); + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_notify == other.sigev_notify + && self.sigev_signo == other.sigev_signo + && self.sigev_value == other.sigev_value + && self.sigev_notify_thread_id + == other.sigev_notify_thread_id + } + } + impl Eq for sigevent {} + impl ::fmt::Debug for sigevent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sigevent") + .field("sigev_notify", &self.sigev_notify) + .field("sigev_signo", &self.sigev_signo) + .field("sigev_value", &self.sigev_value) + .field("sigev_notify_thread_id", + &self.sigev_notify_thread_id) + .finish() + } + } + impl ::hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_notify.hash(state); + self.sigev_signo.hash(state); + self.sigev_value.hash(state); + self.sigev_notify_thread_id.hash(state); + } + } + } +} + +pub const SIGEV_THREAD_ID: ::c_int = 4; + +pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0; +pub const EXTATTR_NAMESPACE_USER: ::c_int = 1; +pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2; + +pub const RAND_MAX: ::c_int = 0x7fff_fffd; +pub const PTHREAD_STACK_MIN: ::size_t = 2048; +pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4; +pub const SIGSTKSZ: ::size_t = 34816; +pub const SF_NODISKIO: ::c_int = 0x00000001; +pub const SF_MNOWAIT: ::c_int = 0x00000002; +pub const SF_SYNC: ::c_int = 0x00000004; +pub const SF_USER_READAHEAD: ::c_int = 0x00000008; +pub const SF_NOCACHE: ::c_int = 0x00000010; +pub const O_CLOEXEC: ::c_int = 0x00100000; +pub const O_DIRECTORY: ::c_int = 0x00020000; +pub const O_EXEC: ::c_int = 0x00040000; +pub const O_TTY_INIT: ::c_int = 0x00080000; +pub const F_GETLK: ::c_int = 11; +pub const F_SETLK: ::c_int = 12; +pub const F_SETLKW: ::c_int = 13; +pub const ENOTCAPABLE: ::c_int = 93; +pub const ECAPMODE: ::c_int = 94; +pub const ENOTRECOVERABLE: ::c_int = 95; +pub const EOWNERDEAD: ::c_int = 96; +pub const RLIMIT_NPTS: ::c_int = 11; +pub const RLIMIT_SWAP: ::c_int = 12; +pub const RLIMIT_KQUEUES: ::c_int = 13; +pub const RLIMIT_UMTXP: ::c_int = 14; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: ::rlim_t = 15; + +pub const Q_GETQUOTA: ::c_int = 0x700; +pub const Q_SETQUOTA: ::c_int = 0x800; + +pub const POSIX_FADV_NORMAL: ::c_int = 0; +pub const POSIX_FADV_RANDOM: ::c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_FADV_WILLNEED: ::c_int = 3; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const POLLINIGNEOF: ::c_short = 0x2000; + +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_PROCDESC: i16 = -8; +pub const EVFILT_FS: i16 = -9; +pub const EVFILT_LIO: i16 = -10; +pub const EVFILT_USER: i16 = -11; +pub const EVFILT_SENDFILE: i16 = -12; +pub const EVFILT_EMPTY: i16 = -13; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_DROP: u16 = 0x1000; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; +pub const EV_SYSFLAGS: u16 = 0xf000; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; +pub const NOTE_SECONDS: u32 = 0x00000001; +pub const NOTE_MSECONDS: u32 = 0x00000002; +pub const NOTE_USECONDS: u32 = 0x00000004; +pub const NOTE_NSECONDS: u32 = 0x00000008; + +pub const MADV_PROTECT: ::c_int = 10; +pub const RUSAGE_THREAD: ::c_int = 1; + +pub const CLOCK_REALTIME: ::clockid_t = 0; +pub const CLOCK_VIRTUAL: ::clockid_t = 1; +pub const CLOCK_PROF: ::clockid_t = 2; +pub const CLOCK_MONOTONIC: ::clockid_t = 4; +pub const CLOCK_UPTIME: ::clockid_t = 5; +pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7; +pub const CLOCK_UPTIME_FAST: ::clockid_t = 8; +pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9; +pub const CLOCK_REALTIME_FAST: ::clockid_t = 10; +pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11; +pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12; +pub const CLOCK_SECOND: ::clockid_t = 13; +pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14; +pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15; + +pub const CTL_UNSPEC: ::c_int = 0; +pub const CTL_KERN: ::c_int = 1; +pub const CTL_VM: ::c_int = 2; +pub const CTL_VFS: ::c_int = 3; +pub const CTL_NET: ::c_int = 4; +pub const CTL_DEBUG: ::c_int = 5; +pub const CTL_HW: ::c_int = 6; +pub const CTL_MACHDEP: ::c_int = 7; +pub const CTL_USER: ::c_int = 8; +pub const CTL_P1003_1B: ::c_int = 9; +pub const KERN_OSTYPE: ::c_int = 1; +pub const KERN_OSRELEASE: ::c_int = 2; +pub const KERN_OSREV: ::c_int = 3; +pub const KERN_VERSION: ::c_int = 4; +pub const KERN_MAXVNODES: ::c_int = 5; +pub const KERN_MAXPROC: ::c_int = 6; +pub const KERN_MAXFILES: ::c_int = 7; +pub const KERN_ARGMAX: ::c_int = 8; +pub const KERN_SECURELVL: ::c_int = 9; +pub const KERN_HOSTNAME: ::c_int = 10; +pub const KERN_HOSTID: ::c_int = 11; +pub const KERN_CLOCKRATE: ::c_int = 12; +pub const KERN_VNODE: ::c_int = 13; +pub const KERN_PROC: ::c_int = 14; +pub const KERN_FILE: ::c_int = 15; +pub const KERN_PROF: ::c_int = 16; +pub const KERN_POSIX1: ::c_int = 17; +pub const KERN_NGROUPS: ::c_int = 18; +pub const KERN_JOB_CONTROL: ::c_int = 19; +pub const KERN_SAVED_IDS: ::c_int = 20; +pub const KERN_BOOTTIME: ::c_int = 21; +pub const KERN_NISDOMAINNAME: ::c_int = 22; +pub const KERN_UPDATEINTERVAL: ::c_int = 23; +pub const KERN_OSRELDATE: ::c_int = 24; +pub const KERN_NTP_PLL: ::c_int = 25; +pub const KERN_BOOTFILE: ::c_int = 26; +pub const KERN_MAXFILESPERPROC: ::c_int = 27; +pub const KERN_MAXPROCPERUID: ::c_int = 28; +pub const KERN_DUMPDEV: ::c_int = 29; +pub const KERN_IPC: ::c_int = 30; +pub const KERN_DUMMY: ::c_int = 31; +pub const KERN_PS_STRINGS: ::c_int = 32; +pub const KERN_USRSTACK: ::c_int = 33; +pub const KERN_LOGSIGEXIT: ::c_int = 34; +pub const KERN_IOV_MAX: ::c_int = 35; +pub const KERN_HOSTUUID: ::c_int = 36; +pub const KERN_ARND: ::c_int = 37; +pub const KERN_PROC_ALL: ::c_int = 0; +pub const KERN_PROC_PID: ::c_int = 1; +pub const KERN_PROC_PGRP: ::c_int = 2; +pub const KERN_PROC_SESSION: ::c_int = 3; +pub const KERN_PROC_TTY: ::c_int = 4; +pub const KERN_PROC_UID: ::c_int = 5; +pub const KERN_PROC_RUID: ::c_int = 6; +pub const KERN_PROC_ARGS: ::c_int = 7; +pub const KERN_PROC_PROC: ::c_int = 8; +pub const KERN_PROC_SV_NAME: ::c_int = 9; +pub const KERN_PROC_RGID: ::c_int = 10; +pub const KERN_PROC_GID: ::c_int = 11; +pub const KERN_PROC_PATHNAME: ::c_int = 12; +pub const KERN_PROC_OVMMAP: ::c_int = 13; +pub const KERN_PROC_OFILEDESC: ::c_int = 14; +pub const KERN_PROC_KSTACK: ::c_int = 15; +pub const KERN_PROC_INC_THREAD: ::c_int = 0x10; +pub const KERN_PROC_VMMAP: ::c_int = 32; +pub const KERN_PROC_FILEDESC: ::c_int = 33; +pub const KERN_PROC_GROUPS: ::c_int = 34; +pub const KERN_PROC_ENV: ::c_int = 35; +pub const KERN_PROC_AUXV: ::c_int = 36; +pub const KERN_PROC_RLIMIT: ::c_int = 37; +pub const KERN_PROC_PS_STRINGS: ::c_int = 38; +pub const KERN_PROC_UMASK: ::c_int = 39; +pub const KERN_PROC_OSREL: ::c_int = 40; +pub const KERN_PROC_SIGTRAMP: ::c_int = 41; +pub const KIPC_MAXSOCKBUF: ::c_int = 1; +pub const KIPC_SOCKBUF_WASTE: ::c_int = 2; +pub const KIPC_SOMAXCONN: ::c_int = 3; +pub const KIPC_MAX_LINKHDR: ::c_int = 4; +pub const KIPC_MAX_PROTOHDR: ::c_int = 5; +pub const KIPC_MAX_HDR: ::c_int = 6; +pub const KIPC_MAX_DATALEN: ::c_int = 7; +pub const HW_MACHINE: ::c_int = 1; +pub const HW_MODEL: ::c_int = 2; +pub const HW_NCPU: ::c_int = 3; +pub const HW_BYTEORDER: ::c_int = 4; +pub const HW_PHYSMEM: ::c_int = 5; +pub const HW_USERMEM: ::c_int = 6; +pub const HW_PAGESIZE: ::c_int = 7; +pub const HW_DISKNAMES: ::c_int = 8; +pub const HW_DISKSTATS: ::c_int = 9; +pub const HW_FLOATINGPT: ::c_int = 10; +pub const HW_MACHINE_ARCH: ::c_int = 11; +pub const HW_REALMEM: ::c_int = 12; +pub const USER_CS_PATH: ::c_int = 1; +pub const USER_BC_BASE_MAX: ::c_int = 2; +pub const USER_BC_DIM_MAX: ::c_int = 3; +pub const USER_BC_SCALE_MAX: ::c_int = 4; +pub const USER_BC_STRING_MAX: ::c_int = 5; +pub const USER_COLL_WEIGHTS_MAX: ::c_int = 6; +pub const USER_EXPR_NEST_MAX: ::c_int = 7; +pub const USER_LINE_MAX: ::c_int = 8; +pub const USER_RE_DUP_MAX: ::c_int = 9; +pub const USER_POSIX2_VERSION: ::c_int = 10; +pub const USER_POSIX2_C_BIND: ::c_int = 11; +pub const USER_POSIX2_C_DEV: ::c_int = 12; +pub const USER_POSIX2_CHAR_TERM: ::c_int = 13; +pub const USER_POSIX2_FORT_DEV: ::c_int = 14; +pub const USER_POSIX2_FORT_RUN: ::c_int = 15; +pub const USER_POSIX2_LOCALEDEF: ::c_int = 16; +pub const USER_POSIX2_SW_DEV: ::c_int = 17; +pub const USER_POSIX2_UPE: ::c_int = 18; +pub const USER_STREAM_MAX: ::c_int = 19; +pub const USER_TZNAME_MAX: ::c_int = 20; +pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1; +pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2; +pub const CTL_P1003_1B_MEMLOCK: ::c_int = 3; +pub const CTL_P1003_1B_MEMLOCK_RANGE: ::c_int = 4; +pub const CTL_P1003_1B_MEMORY_PROTECTION: ::c_int = 5; +pub const CTL_P1003_1B_MESSAGE_PASSING: ::c_int = 6; +pub const CTL_P1003_1B_PRIORITIZED_IO: ::c_int = 7; +pub const CTL_P1003_1B_PRIORITY_SCHEDULING: ::c_int = 8; +pub const CTL_P1003_1B_REALTIME_SIGNALS: ::c_int = 9; +pub const CTL_P1003_1B_SEMAPHORES: ::c_int = 10; +pub const CTL_P1003_1B_FSYNC: ::c_int = 11; +pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: ::c_int = 12; +pub const CTL_P1003_1B_SYNCHRONIZED_IO: ::c_int = 13; +pub const CTL_P1003_1B_TIMERS: ::c_int = 14; +pub const CTL_P1003_1B_AIO_LISTIO_MAX: ::c_int = 15; +pub const CTL_P1003_1B_AIO_MAX: ::c_int = 16; +pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: ::c_int = 17; +pub const CTL_P1003_1B_DELAYTIMER_MAX: ::c_int = 18; +pub const CTL_P1003_1B_MQ_OPEN_MAX: ::c_int = 19; +pub const CTL_P1003_1B_PAGESIZE: ::c_int = 20; +pub const CTL_P1003_1B_RTSIG_MAX: ::c_int = 21; +pub const CTL_P1003_1B_SEM_NSEMS_MAX: ::c_int = 22; +pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23; +pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24; +pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25; +pub const TIOCGPTN: ::c_uint = 0x4004740f; +pub const TIOCPTMASTER: ::c_uint = 0x2000741c; +pub const TIOCSIG: ::c_uint = 0x2004745f; +pub const TIOCM_DCD: ::c_int = 0x40; +pub const H4DISC: ::c_int = 0x7; + +pub const BIOCSETFNR: ::c_ulong = 0x80104282; + +pub const FIONWRITE: ::c_ulong = 0x40046677; +pub const FIONSPACE: ::c_ulong = 0x40046676; +pub const FIOSEEKDATA: ::c_ulong = 0xc0086661; +pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662; + +pub const JAIL_API_VERSION: u32 = 2; +pub const JAIL_CREATE: ::c_int = 0x01; +pub const JAIL_UPDATE: ::c_int = 0x02; +pub const JAIL_ATTACH: ::c_int = 0x04; +pub const JAIL_DYING: ::c_int = 0x08; +pub const JAIL_SET_MASK: ::c_int = 0x0f; +pub const JAIL_GET_MASK: ::c_int = 0x08; +pub const JAIL_SYS_DISABLE: ::c_int = 0; +pub const JAIL_SYS_NEW: ::c_int = 1; +pub const JAIL_SYS_INHERIT: ::c_int = 2; + +pub const SO_BINTIME: ::c_int = 0x2000; +pub const SO_NO_OFFLOAD: ::c_int = 0x4000; +pub const SO_NO_DDP: ::c_int = 0x8000; +pub const SO_REUSEPORT_LB: ::c_int = 0x10000; +pub const SO_LABEL: ::c_int = 0x1009; +pub const SO_PEERLABEL: ::c_int = 0x1010; +pub const SO_LISTENQLIMIT: ::c_int = 0x1011; +pub const SO_LISTENQLEN: ::c_int = 0x1012; +pub const SO_LISTENINCQLEN: ::c_int = 0x1013; +pub const SO_SETFIB: ::c_int = 0x1014; +pub const SO_USER_COOKIE: ::c_int = 0x1015; +pub const SO_PROTOCOL: ::c_int = 0x1016; +pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL; +pub const SO_VENDOR: ::c_int = 0x80000000; + +pub const LOCAL_PEERCRED: ::c_int = 1; +pub const LOCAL_CREDS: ::c_int = 2; +pub const LOCAL_CONNWAIT: ::c_int = 4; +pub const LOCAL_VENDOR: ::c_int = SO_VENDOR; + +pub const PT_LWPINFO: ::c_int = 13; +pub const PT_GETNUMLWPS: ::c_int = 14; +pub const PT_GETLWPLIST: ::c_int = 15; +pub const PT_CLEARSTEP: ::c_int = 16; +pub const PT_SETSTEP: ::c_int = 17; +pub const PT_SUSPEND: ::c_int = 18; +pub const PT_RESUME: ::c_int = 19; +pub const PT_TO_SCE: ::c_int = 20; +pub const PT_TO_SCX: ::c_int = 21; +pub const PT_SYSCALL: ::c_int = 22; +pub const PT_FOLLOW_FORK: ::c_int = 23; +pub const PT_LWP_EVENTS: ::c_int = 24; +pub const PT_GET_EVENT_MASK: ::c_int = 25; +pub const PT_SET_EVENT_MASK: ::c_int = 26; +pub const PT_GETREGS: ::c_int = 33; +pub const PT_SETREGS: ::c_int = 34; +pub const PT_GETFPREGS: ::c_int = 35; +pub const PT_SETFPREGS: ::c_int = 36; +pub const PT_GETDBREGS: ::c_int = 37; +pub const PT_SETDBREGS: ::c_int = 38; +pub const PT_VM_TIMESTAMP: ::c_int = 40; +pub const PT_VM_ENTRY: ::c_int = 41; +pub const PT_FIRSTMACH: ::c_int = 64; + +pub const PTRACE_EXEC: ::c_int = 0x0001; +pub const PTRACE_SCE: ::c_int = 0x0002; +pub const PTRACE_SCX: ::c_int = 0x0004; +pub const PTRACE_SYSCALL: ::c_int = PTRACE_SCE | PTRACE_SCX; +pub const PTRACE_FORK: ::c_int = 0x0008; +pub const PTRACE_LWP: ::c_int = 0x0010; +pub const PTRACE_VFORK: ::c_int = 0x0020; +pub const PTRACE_DEFAULT: ::c_int = PTRACE_EXEC; + +pub const AF_SLOW: ::c_int = 33; +pub const AF_SCLUSTER: ::c_int = 34; +pub const AF_ARP: ::c_int = 35; +pub const AF_BLUETOOTH: ::c_int = 36; +pub const AF_IEEE80211: ::c_int = 37; +pub const AF_INET_SDP: ::c_int = 40; +pub const AF_INET6_SDP: ::c_int = 42; + +// https://github.com/freebsd/freebsd/blob/master/sys/net/if.h#L140 +pub const IFF_UP: ::c_int = 0x1; // (n) interface is up +pub const IFF_BROADCAST: ::c_int = 0x2; // (i) broadcast address valid +pub const IFF_DEBUG: ::c_int = 0x4; // (n) turn on debugging +pub const IFF_LOOPBACK: ::c_int = 0x8; // (i) is a loopback net +pub const IFF_POINTOPOINT: ::c_int = 0x10; // (i) is a point-to-point link + // 0x20 was IFF_SMART +pub const IFF_RUNNING: ::c_int = 0x40; // (d) resources allocated +#[doc(hidden)] +#[deprecated( + since = "0.2.54", + note = "IFF_DRV_RUNNING is deprecated. Use the portable IFF_RUNNING instead" +)] +pub const IFF_DRV_RUNNING: ::c_int = 0x40; +pub const IFF_NOARP: ::c_int = 0x80; // (n) no address resolution protocol +pub const IFF_PROMISC: ::c_int = 0x100; // (n) receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x200; // (n) receive all multicast packets +pub const IFF_OACTIVE: ::c_int = 0x400; // (d) tx hardware queue is full +#[doc(hidden)] +#[deprecated( + since = "0.2.54", + note = "Use the portable `IFF_OACTIVE` instead" +)] +pub const IFF_DRV_OACTIVE: ::c_int = 0x400; +pub const IFF_SIMPLEX: ::c_int = 0x800; // (i) can't hear own transmissions +pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit +pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection +pub const IFF_MULTICAST: ::c_int = 0x8000; // (i) supports multicast + // (i) unconfigurable using ioctl(2) +pub const IFF_CANTCONFIG: ::c_int = 0x10000; +pub const IFF_PPROMISC: ::c_int = 0x20000; // (n) user-requested promisc mode +pub const IFF_MONITOR: ::c_int = 0x40000; // (n) user-requested monitor mode +pub const IFF_STATICARP: ::c_int = 0x80000; // (n) static ARP +pub const IFF_DYING: ::c_int = 0x200000; // (n) interface is winding down +pub const IFF_RENAMING: ::c_int = 0x400000; // (n) interface is being renamed + +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// IP6 hop-by-hop options +pub const IPPROTO_HOPOPTS: ::c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: ::c_int = 2; +/// gateway^2 (deprecated) +pub const IPPROTO_GGP: ::c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: ::c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// Stream protocol II. +pub const IPPROTO_ST: ::c_int = 7; +/// exterior gateway protocol +pub const IPPROTO_EGP: ::c_int = 8; +/// private interior gateway +pub const IPPROTO_PIGP: ::c_int = 9; +/// BBN RCC Monitoring +pub const IPPROTO_RCCMON: ::c_int = 10; +/// network voice protocol +pub const IPPROTO_NVPII: ::c_int = 11; +/// pup +pub const IPPROTO_PUP: ::c_int = 12; +/// Argus +pub const IPPROTO_ARGUS: ::c_int = 13; +/// EMCON +pub const IPPROTO_EMCON: ::c_int = 14; +/// Cross Net Debugger +pub const IPPROTO_XNET: ::c_int = 15; +/// Chaos +pub const IPPROTO_CHAOS: ::c_int = 16; +// IPPROTO_UDP defined in src/unix/mod.rs +/// Multiplexing +pub const IPPROTO_MUX: ::c_int = 18; +/// DCN Measurement Subsystems +pub const IPPROTO_MEAS: ::c_int = 19; +/// Host Monitoring +pub const IPPROTO_HMP: ::c_int = 20; +/// Packet Radio Measurement +pub const IPPROTO_PRM: ::c_int = 21; +/// xns idp +pub const IPPROTO_IDP: ::c_int = 22; +/// Trunk-1 +pub const IPPROTO_TRUNK1: ::c_int = 23; +/// Trunk-2 +pub const IPPROTO_TRUNK2: ::c_int = 24; +/// Leaf-1 +pub const IPPROTO_LEAF1: ::c_int = 25; +/// Leaf-2 +pub const IPPROTO_LEAF2: ::c_int = 26; +/// Reliable Data +pub const IPPROTO_RDP: ::c_int = 27; +/// Reliable Transaction +pub const IPPROTO_IRTP: ::c_int = 28; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: ::c_int = 29; +/// Bulk Data Transfer +pub const IPPROTO_BLT: ::c_int = 30; +/// Network Services +pub const IPPROTO_NSP: ::c_int = 31; +/// Merit Internodal +pub const IPPROTO_INP: ::c_int = 32; +/// Sequential Exchange +pub const IPPROTO_SEP: ::c_int = 33; +/// Third Party Connect +pub const IPPROTO_3PC: ::c_int = 34; +/// InterDomain Policy Routing +pub const IPPROTO_IDPR: ::c_int = 35; +/// XTP +pub const IPPROTO_XTP: ::c_int = 36; +/// Datagram Delivery +pub const IPPROTO_DDP: ::c_int = 37; +/// Control Message Transport +pub const IPPROTO_CMTP: ::c_int = 38; +/// TP++ Transport +pub const IPPROTO_TPXX: ::c_int = 39; +/// IL transport protocol +pub const IPPROTO_IL: ::c_int = 40; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// Source Demand Routing +pub const IPPROTO_SDRP: ::c_int = 42; +/// IP6 routing header +pub const IPPROTO_ROUTING: ::c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: ::c_int = 44; +/// InterDomain Routing +pub const IPPROTO_IDRP: ::c_int = 45; +/// resource reservation +pub const IPPROTO_RSVP: ::c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: ::c_int = 47; +/// Mobile Host Routing +pub const IPPROTO_MHRP: ::c_int = 48; +/// BHA +pub const IPPROTO_BHA: ::c_int = 49; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: ::c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: ::c_int = 51; +/// Integ. Net Layer Security +pub const IPPROTO_INLSP: ::c_int = 52; +/// IP with encryption +pub const IPPROTO_SWIPE: ::c_int = 53; +/// Next Hop Resolution +pub const IPPROTO_NHRP: ::c_int = 54; +/// IP Mobility +pub const IPPROTO_MOBILE: ::c_int = 55; +/// Transport Layer Security +pub const IPPROTO_TLSP: ::c_int = 56; +/// SKIP +pub const IPPROTO_SKIP: ::c_int = 57; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: ::c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: ::c_int = 60; +/// any host internal protocol +pub const IPPROTO_AHIP: ::c_int = 61; +/// CFTP +pub const IPPROTO_CFTP: ::c_int = 62; +/// "hello" routing protocol +pub const IPPROTO_HELLO: ::c_int = 63; +/// SATNET/Backroom EXPAK +pub const IPPROTO_SATEXPAK: ::c_int = 64; +/// Kryptolan +pub const IPPROTO_KRYPTOLAN: ::c_int = 65; +/// Remote Virtual Disk +pub const IPPROTO_RVD: ::c_int = 66; +/// Pluribus Packet Core +pub const IPPROTO_IPPC: ::c_int = 67; +/// Any distributed FS +pub const IPPROTO_ADFS: ::c_int = 68; +/// Satnet Monitoring +pub const IPPROTO_SATMON: ::c_int = 69; +/// VISA Protocol +pub const IPPROTO_VISA: ::c_int = 70; +/// Packet Core Utility +pub const IPPROTO_IPCV: ::c_int = 71; +/// Comp. Prot. Net. Executive +pub const IPPROTO_CPNX: ::c_int = 72; +/// Comp. Prot. HeartBeat +pub const IPPROTO_CPHB: ::c_int = 73; +/// Wang Span Network +pub const IPPROTO_WSN: ::c_int = 74; +/// Packet Video Protocol +pub const IPPROTO_PVP: ::c_int = 75; +/// BackRoom SATNET Monitoring +pub const IPPROTO_BRSATMON: ::c_int = 76; +/// Sun net disk proto (temp.) +pub const IPPROTO_ND: ::c_int = 77; +/// WIDEBAND Monitoring +pub const IPPROTO_WBMON: ::c_int = 78; +/// WIDEBAND EXPAK +pub const IPPROTO_WBEXPAK: ::c_int = 79; +/// ISO cnlp +pub const IPPROTO_EON: ::c_int = 80; +/// VMTP +pub const IPPROTO_VMTP: ::c_int = 81; +/// Secure VMTP +pub const IPPROTO_SVMTP: ::c_int = 82; +/// Banyon VINES +pub const IPPROTO_VINES: ::c_int = 83; +/// TTP +pub const IPPROTO_TTP: ::c_int = 84; +/// NSFNET-IGP +pub const IPPROTO_IGP: ::c_int = 85; +/// dissimilar gateway prot. +pub const IPPROTO_DGP: ::c_int = 86; +/// TCF +pub const IPPROTO_TCF: ::c_int = 87; +/// Cisco/GXS IGRP +pub const IPPROTO_IGRP: ::c_int = 88; +/// OSPFIGP +pub const IPPROTO_OSPFIGP: ::c_int = 89; +/// Strite RPC protocol +pub const IPPROTO_SRPC: ::c_int = 90; +/// Locus Address Resoloution +pub const IPPROTO_LARP: ::c_int = 91; +/// Multicast Transport +pub const IPPROTO_MTP: ::c_int = 92; +/// AX.25 Frames +pub const IPPROTO_AX25: ::c_int = 93; +/// IP encapsulated in IP +pub const IPPROTO_IPEIP: ::c_int = 94; +/// Mobile Int.ing control +pub const IPPROTO_MICP: ::c_int = 95; +/// Semaphore Comm. security +pub const IPPROTO_SCCSP: ::c_int = 96; +/// Ethernet IP encapsulation +pub const IPPROTO_ETHERIP: ::c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: ::c_int = 98; +/// any private encr. scheme +pub const IPPROTO_APES: ::c_int = 99; +/// GMTP +pub const IPPROTO_GMTP: ::c_int = 100; +/// payload compression (IPComp) +pub const IPPROTO_IPCOMP: ::c_int = 108; +/// SCTP +pub const IPPROTO_SCTP: ::c_int = 132; +/// IPv6 Mobility Header +pub const IPPROTO_MH: ::c_int = 135; +/// UDP-Lite +pub const IPPROTO_UDPLITE: ::c_int = 136; +/// IP6 Host Identity Protocol +pub const IPPROTO_HIP: ::c_int = 139; +/// IP6 Shim6 Protocol +pub const IPPROTO_SHIM6: ::c_int = 140; + +/* 101-254: Partly Unassigned */ +/// Protocol Independent Mcast +pub const IPPROTO_PIM: ::c_int = 103; +/// CARP +pub const IPPROTO_CARP: ::c_int = 112; +/// PGM +pub const IPPROTO_PGM: ::c_int = 113; +/// MPLS-in-IP +pub const IPPROTO_MPLS: ::c_int = 137; +/// PFSYNC +pub const IPPROTO_PFSYNC: ::c_int = 240; + +/* 255: Reserved */ +/* BSD Private, local use, namespace incursion, no longer used */ +/// OLD divert pseudo-proto +pub const IPPROTO_OLD_DIVERT: ::c_int = 254; +pub const IPPROTO_MAX: ::c_int = 256; +/// last return value of *_input(), meaning "all job for this pkt is done". +pub const IPPROTO_DONE: ::c_int = 257; + +/* Only used internally, so can be outside the range of valid IP protocols. */ +/// divert pseudo-protocol +pub const IPPROTO_DIVERT: ::c_int = 258; +/// SeND pseudo-protocol +pub const IPPROTO_SEND: ::c_int = 259; + +// sys/netinet/TCP.h +pub const TCP_MD5SIG: ::c_int = 16; +pub const TCP_INFO: ::c_int = 32; +pub const TCP_CONGESTION: ::c_int = 64; +pub const TCP_CCALGOOPT: ::c_int = 65; +pub const TCP_KEEPINIT: ::c_int = 128; +pub const TCP_FASTOPEN: ::c_int = 1025; +pub const TCP_PCAP_OUT: ::c_int = 2048; +pub const TCP_PCAP_IN: ::c_int = 4096; + +pub const IP_BINDANY: ::c_int = 24; +pub const IP_BINDMULTI: ::c_int = 25; +pub const IP_RSS_LISTEN_BUCKET: ::c_int = 26; +pub const IP_ORIGDSTADDR: ::c_int = 27; +pub const IP_RECVORIGDSTADDR: ::c_int = IP_ORIGDSTADDR; + +pub const IP_RECVTOS: ::c_int = 68; + +pub const IPV6_ORIGDSTADDR: ::c_int = 72; +pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR; + +pub const PF_SLOW: ::c_int = AF_SLOW; +pub const PF_SCLUSTER: ::c_int = AF_SCLUSTER; +pub const PF_ARP: ::c_int = AF_ARP; +pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; +pub const PF_IEEE80211: ::c_int = AF_IEEE80211; +pub const PF_INET_SDP: ::c_int = AF_INET_SDP; +pub const PF_INET6_SDP: ::c_int = AF_INET6_SDP; + +pub const NET_RT_DUMP: ::c_int = 1; +pub const NET_RT_FLAGS: ::c_int = 2; +pub const NET_RT_IFLIST: ::c_int = 3; +pub const NET_RT_IFMALIST: ::c_int = 4; +pub const NET_RT_IFLISTL: ::c_int = 5; + +// System V IPC +pub const IPC_PRIVATE: ::key_t = 0; +pub const IPC_CREAT: ::c_int = 0o1000; +pub const IPC_EXCL: ::c_int = 0o2000; +pub const IPC_NOWAIT: ::c_int = 0o4000; +pub const IPC_RMID: ::c_int = 0; +pub const IPC_SET: ::c_int = 1; +pub const IPC_STAT: ::c_int = 2; +pub const IPC_INFO: ::c_int = 3; +pub const IPC_R: ::c_int = 0o400; +pub const IPC_W: ::c_int = 0o200; +pub const IPC_M: ::c_int = 0o10000; +pub const MSG_NOERROR: ::c_int = 0o10000; +pub const SHM_RDONLY: ::c_int = 0o10000; +pub const SHM_RND: ::c_int = 0o20000; +pub const SHM_R: ::c_int = 0o400; +pub const SHM_W: ::c_int = 0o200; +pub const SHM_LOCK: ::c_int = 11; +pub const SHM_UNLOCK: ::c_int = 12; +pub const SHM_STAT: ::c_int = 13; +pub const SHM_INFO: ::c_int = 14; +pub const SHM_ANON: *mut ::c_char = 1 as *mut ::c_char; + +// The *_MAXID constants never should've been used outside of the +// FreeBSD base system. And with the exception of CTL_P1003_1B_MAXID, +// they were all removed in svn r262489. They remain here for backwards +// compatibility only, and are scheduled to be removed in libc 1.0.0. +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] +pub const CTL_MAXID: ::c_int = 10; +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] +pub const KERN_MAXID: ::c_int = 38; +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] +pub const HW_MAXID: ::c_int = 13; +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] +pub const USER_MAXID: ::c_int = 21; +#[doc(hidden)] +pub const CTL_P1003_1B_MAXID: ::c_int = 26; + +pub const MSG_NOTIFICATION: ::c_int = 0x00002000; +pub const MSG_NBIO: ::c_int = 0x00004000; +pub const MSG_COMPAT: ::c_int = 0x00008000; +pub const MSG_CMSG_CLOEXEC: ::c_int = 0x00040000; +pub const MSG_NOSIGNAL: ::c_int = 0x20000; + +// utmpx entry types +pub const EMPTY: ::c_short = 0; +pub const BOOT_TIME: ::c_short = 1; +pub const OLD_TIME: ::c_short = 2; +pub const NEW_TIME: ::c_short = 3; +pub const USER_PROCESS: ::c_short = 4; +pub const INIT_PROCESS: ::c_short = 5; +pub const LOGIN_PROCESS: ::c_short = 6; +pub const DEAD_PROCESS: ::c_short = 7; +pub const SHUTDOWN_TIME: ::c_short = 8; +// utmp database types +pub const UTXDB_ACTIVE: ::c_int = 0; +pub const UTXDB_LASTLOGIN: ::c_int = 1; +pub const UTXDB_LOG: ::c_int = 2; + +pub const LC_COLLATE_MASK: ::c_int = (1 << 0); +pub const LC_CTYPE_MASK: ::c_int = (1 << 1); +pub const LC_MONETARY_MASK: ::c_int = (1 << 2); +pub const LC_NUMERIC_MASK: ::c_int = (1 << 3); +pub const LC_TIME_MASK: ::c_int = (1 << 4); +pub const LC_MESSAGES_MASK: ::c_int = (1 << 5); +pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK + | LC_CTYPE_MASK + | LC_MESSAGES_MASK + | LC_MONETARY_MASK + | LC_NUMERIC_MASK + | LC_TIME_MASK; + +pub const WSTOPPED: ::c_int = 2; // same as WUNTRACED +pub const WCONTINUED: ::c_int = 4; +pub const WNOWAIT: ::c_int = 8; +pub const WEXITED: ::c_int = 16; +pub const WTRAPPED: ::c_int = 32; + +// FreeBSD defines a great many more of these, we only expose the +// standardized ones. +pub const P_PID: idtype_t = 0; +pub const P_PGID: idtype_t = 2; +pub const P_ALL: idtype_t = 7; + +pub const UTIME_OMIT: c_long = -2; +pub const UTIME_NOW: c_long = -1; + +pub const B460800: ::speed_t = 460800; +pub const B921600: ::speed_t = 921600; + +pub const AT_FDCWD: ::c_int = -100; +pub const AT_EACCESS: ::c_int = 0x100; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; +pub const AT_REMOVEDIR: ::c_int = 0x800; + +pub const TABDLY: ::tcflag_t = 0x00000004; +pub const TAB0: ::tcflag_t = 0x00000000; +pub const TAB3: ::tcflag_t = 0x00000004; + +pub const _PC_ACL_NFS4: ::c_int = 64; + +pub const _SC_CPUSET_SIZE: ::c_int = 122; + +pub const XU_NGROUPS: ::c_int = 16; +pub const XUCRED_VERSION: ::c_uint = 0; + +// Flags which can be passed to pdfork(2) +pub const PD_DAEMON: ::c_int = 0x00000001; +pub const PD_CLOEXEC: ::c_int = 0x00000002; +pub const PD_ALLOWED_AT_FORK: ::c_int = PD_DAEMON | PD_CLOEXEC; + +// Values for struct rtprio (type_ field) +pub const RTP_PRIO_REALTIME: ::c_ushort = 2; +pub const RTP_PRIO_NORMAL: ::c_ushort = 3; +pub const RTP_PRIO_IDLE: ::c_ushort = 4; + +pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20; + +// Flags for chflags(2) +pub const UF_SYSTEM: ::c_ulong = 0x00000080; +pub const UF_SPARSE: ::c_ulong = 0x00000100; +pub const UF_OFFLINE: ::c_ulong = 0x00000200; +pub const UF_REPARSE: ::c_ulong = 0x00000400; +pub const UF_ARCHIVE: ::c_ulong = 0x00000800; +pub const UF_READONLY: ::c_ulong = 0x00001000; +pub const UF_HIDDEN: ::c_ulong = 0x00008000; +pub const SF_SNAPSHOT: ::c_ulong = 0x00200000; + +fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES +} + +f! { + pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { + (cmsg as *mut ::c_uchar) + .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) + -> *mut ::cmsghdr + { + if cmsg.is_null() { + return ::CMSG_FIRSTHDR(mhdr); + }; + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + + _ALIGN(::mem::size_of::<::cmsghdr>()); + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next > max { + 0 as *mut ::cmsghdr + } else { + (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) + as *mut ::cmsghdr + } + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize)) + as ::c_uint + } + + pub fn uname(buf: *mut ::utsname) -> ::c_int { + __xuname(256, buf as *mut ::c_void) + } +} + +extern "C" { + pub fn __error() -> *mut ::c_int; + + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_settime( + clk_id: ::clockid_t, + tp: *const ::timespec, + ) -> ::c_int; + + pub fn extattr_delete_fd( + fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + ) -> ::c_int; + pub fn extattr_delete_file( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + ) -> ::c_int; + pub fn extattr_delete_link( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + ) -> ::c_int; + pub fn extattr_get_fd( + fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_get_file( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_get_link( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_list_fd( + fd: ::c_int, + attrnamespace: ::c_int, + data: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_list_file( + path: *const ::c_char, + attrnamespace: ::c_int, + data: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_list_link( + path: *const ::c_char, + attrnamespace: ::c_int, + data: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_set_fd( + fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_set_file( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_set_link( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + + pub fn jail(jail: *mut ::jail) -> ::c_int; + pub fn jail_attach(jid: ::c_int) -> ::c_int; + pub fn jail_remove(jid: ::c_int) -> ::c_int; + pub fn jail_get( + iov: *mut ::iovec, + niov: ::c_uint, + flags: ::c_int, + ) -> ::c_int; + pub fn jail_set( + iov: *mut ::iovec, + niov: ::c_uint, + flags: ::c_int, + ) -> ::c_int; + + pub fn fdatasync(fd: ::c_int) -> ::c_int; + pub fn posix_fallocate( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + ) -> ::c_int; + pub fn posix_fadvise( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + advise: ::c_int, + ) -> ::c_int; + pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; + pub fn mkostemps( + template: *mut ::c_char, + suffixlen: ::c_int, + flags: ::c_int, + ) -> ::c_int; + + pub fn getutxuser(user: *const ::c_char) -> *mut utmpx; + pub fn setutxdb(_type: ::c_int, file: *const ::c_char) -> ::c_int; + + pub fn aio_waitcomplete( + iocbp: *mut *mut aiocb, + timeout: *mut ::timespec, + ) -> ::ssize_t; + pub fn mq_getfd_np(mqd: ::mqd_t) -> ::c_int; + + pub fn waitid( + idtype: idtype_t, + id: ::id_t, + infop: *mut ::siginfo_t, + options: ::c_int, + ) -> ::c_int; + + pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t; + pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; + pub fn shmat( + shmid: ::c_int, + shmaddr: *const ::c_void, + shmflg: ::c_int, + ) -> *mut ::c_void; + pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; + pub fn shmctl( + shmid: ::c_int, + cmd: ::c_int, + buf: *mut ::shmid_ds, + ) -> ::c_int; + pub fn msgctl( + msqid: ::c_int, + cmd: ::c_int, + buf: *mut ::msqid_ds, + ) -> ::c_int; + pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; + pub fn msgsnd( + msqid: ::c_int, + msgp: *const ::c_void, + msgsz: ::size_t, + msgflg: ::c_int, + ) -> ::c_int; + pub fn cfmakesane(termios: *mut ::termios); + pub fn fexecve( + fd: ::c_int, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + + pub fn pdfork(fdp: *mut ::c_int, flags: ::c_int) -> ::pid_t; + pub fn pdgetpid(fd: ::c_int, pidp: *mut ::pid_t) -> ::c_int; + pub fn pdkill(fd: ::c_int, signum: ::c_int) -> ::c_int; + + pub fn rtprio_thread( + function: ::c_int, + lwpid: ::lwpid_t, + rtp: *mut super::rtprio, + ) -> ::c_int; + + pub fn posix_spawn( + pid: *mut ::pid_t, + path: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnp( + pid: *mut ::pid_t, + file: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getflags( + attr: *const posix_spawnattr_t, + flags: *mut ::c_short, + ) -> ::c_int; + pub fn posix_spawnattr_setflags( + attr: *mut posix_spawnattr_t, + flags: ::c_short, + ) -> ::c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut ::pid_t, + ) -> ::c_int; + pub fn posix_spawnattr_setpgroup( + attr: *mut posix_spawnattr_t, + flags: ::pid_t, + ) -> ::c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut ::c_int, + ) -> ::c_int; + pub fn posix_spawnattr_setschedpolicy( + attr: *mut posix_spawnattr_t, + flags: ::c_int, + ) -> ::c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut ::sched_param, + ) -> ::c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const ::sched_param, + ) -> ::c_int; + + pub fn posix_spawn_file_actions_init( + actions: *mut posix_spawn_file_actions_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_destroy( + actions: *mut posix_spawn_file_actions_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + path: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + ) -> ::c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + newfd: ::c_int, + ) -> ::c_int; + + #[cfg_attr( + all(target_os = "freebsd", freebsd11), + link_name = "statfs@FBSD_1.0" + )] + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + #[cfg_attr( + all(target_os = "freebsd", freebsd11), + link_name = "fstatfs@FBSD_1.0" + )] + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + + pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; + pub fn __xuname(nmln: ::c_int, buf: *mut ::c_void) -> ::c_int; + + pub fn sendmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + pub fn recvmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::size_t, + flags: ::c_int, + timeout: *const ::timespec, + ) -> ::ssize_t; +} + +#[link(name = "util")] +extern "C" { + pub fn extattr_namespace_to_string( + attrnamespace: ::c_int, + string: *mut *mut ::c_char, + ) -> ::c_int; + pub fn extattr_string_to_namespace( + string: *const ::c_char, + attrnamespace: *mut ::c_int, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(freebsd12)] { + mod freebsd12; + pub use self::freebsd12::*; + } else if #[cfg(freebsd13)] { + mod freebsd12; + pub use self::freebsd12::*; + } else if #[cfg(any(freebsd10, freebsd11))] { + mod freebsd11; + pub use self::freebsd11::*; + } else { + // Unknown freebsd version + } +} + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "powerpc64")] { + mod powerpc64; + pub use self::powerpc64::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs new file mode 100644 index 0000000..5c0c6e7 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -0,0 +1,44 @@ +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type time_t = i64; +pub type suseconds_t = i64; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + } +} + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const MAP_32BIT: ::c_int = 0x00080000; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/x86.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/x86.rs new file mode 100644 index 0000000..adec88c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -0,0 +1,43 @@ +pub type c_char = i8; +pub type c_long = i32; +pub type c_ulong = u32; +pub type time_t = i32; +pub type suseconds_t = i32; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + __unused: [u8; 8], + } +} + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs new file mode 100644 index 0000000..7ca870f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs new file mode 100644 index 0000000..0769a22 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -0,0 +1,24 @@ +pub type c_char = i8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type time_t = i64; +pub type suseconds_t = i64; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} +pub const MAP_32BIT: ::c_int = 0x00080000; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/mod.rs new file mode 100644 index 0000000..1b7804c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/freebsdlike/mod.rs @@ -0,0 +1,1466 @@ +pub type mode_t = u16; +pub type pthread_attr_t = *mut ::c_void; +pub type rlim_t = i64; +pub type pthread_mutex_t = *mut ::c_void; +pub type pthread_mutexattr_t = *mut ::c_void; +pub type pthread_cond_t = *mut ::c_void; +pub type pthread_condattr_t = *mut ::c_void; +pub type pthread_rwlock_t = *mut ::c_void; +pub type pthread_rwlockattr_t = *mut ::c_void; +pub type pthread_key_t = ::c_int; +pub type tcflag_t = ::c_uint; +pub type speed_t = ::c_uint; +pub type nl_item = ::c_int; +pub type id_t = i64; +pub type vm_size_t = ::uintptr_t; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum timezone {} +impl ::Copy for timezone {} +impl ::Clone for timezone { + fn clone(&self) -> timezone { + *self + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut ::c_void { + self.si_addr + } + + pub unsafe fn si_value(&self) -> ::sigval { + self.si_value + } +} + +s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct glob_t { + pub gl_pathc: ::size_t, + pub gl_matchc: ::size_t, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + pub gl_pathv: *mut *mut ::c_char, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + __unused6: *mut ::c_void, + __unused7: *mut ::c_void, + __unused8: *mut ::c_void, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: ::socklen_t, + pub ai_canonname: *mut ::c_char, + pub ai_addr: *mut ::sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct sigset_t { + bits: [u32; 4], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub si_pid: ::pid_t, + pub si_uid: ::uid_t, + pub si_status: ::c_int, + pub si_addr: *mut ::c_void, + pub si_value: ::sigval, + _pad1: ::c_long, + _pad2: [::c_int; 7], + } + + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_flags: ::c_int, + pub sa_mask: sigset_t, + } + + pub struct sched_param { + pub sched_priority: ::c_int, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [::c_char; 8], + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_cc: [::cc_t; ::NCCS], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } + + pub struct flock { + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + pub l_type: ::c_short, + pub l_whence: ::c_short, + #[cfg(not(target_os = "dragonfly"))] + pub l_sysid: ::c_int, + } + + pub struct sf_hdtr { + pub headers: *mut ::iovec, + pub hdr_cnt: ::c_int, + pub trailers: *mut ::iovec, + pub trl_cnt: ::c_int, + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct cmsgcred { + pub cmcred_pid: ::pid_t, + pub cmcred_uid: ::uid_t, + pub cmcred_euid: ::uid_t, + pub cmcred_gid: ::gid_t, + pub cmcred_ngroups: ::c_short, + pub cmcred_groups: [::gid_t; CMGROUP_MAX], + } + + pub struct rtprio { + pub type_: ::c_ushort, + pub prio: ::c_ushort, + } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_uint, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } +} + +s_no_extra_traits! { + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: ::sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_len == other.ss_len + && self.ss_family == other.ss_family + && self.__ss_pad1 == other.__ss_pad1 + && self.__ss_align == other.__ss_align + && self + .__ss_pad2 + .iter() + .zip(other.__ss_pad2.iter()) + .all(|(a, b)| a == b) + } + } + impl Eq for sockaddr_storage {} + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_len", &self.ss_len) + .field("ss_family", &self.ss_family) + .field("__ss_pad1", &self.__ss_pad1) + .field("__ss_align", &self.__ss_align) + // FIXME: .field("__ss_pad2", &self.__ss_pad2) + .finish() + } + } + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_len.hash(state); + self.ss_family.hash(state); + self.__ss_pad1.hash(state); + self.__ss_align.hash(state); + self.__ss_pad2.hash(state); + } + } + } +} + +#[deprecated( + since = "0.2.64", + note = "Can vary at runtime. Use sysconf(3) instead" +)] +pub const AIO_LISTIO_MAX: ::c_int = 16; +pub const AIO_CANCELED: ::c_int = 1; +pub const AIO_NOTCANCELED: ::c_int = 2; +pub const AIO_ALLDONE: ::c_int = 3; +pub const LIO_NOP: ::c_int = 0; +pub const LIO_WRITE: ::c_int = 1; +pub const LIO_READ: ::c_int = 2; +pub const LIO_WAIT: ::c_int = 1; +pub const LIO_NOWAIT: ::c_int = 0; + +pub const SIGEV_NONE: ::c_int = 0; +pub const SIGEV_SIGNAL: ::c_int = 1; +pub const SIGEV_THREAD: ::c_int = 2; +pub const SIGEV_KEVENT: ::c_int = 3; + +pub const CODESET: ::nl_item = 0; +pub const D_T_FMT: ::nl_item = 1; +pub const D_FMT: ::nl_item = 2; +pub const T_FMT: ::nl_item = 3; +pub const T_FMT_AMPM: ::nl_item = 4; +pub const AM_STR: ::nl_item = 5; +pub const PM_STR: ::nl_item = 6; + +pub const DAY_1: ::nl_item = 7; +pub const DAY_2: ::nl_item = 8; +pub const DAY_3: ::nl_item = 9; +pub const DAY_4: ::nl_item = 10; +pub const DAY_5: ::nl_item = 11; +pub const DAY_6: ::nl_item = 12; +pub const DAY_7: ::nl_item = 13; + +pub const ABDAY_1: ::nl_item = 14; +pub const ABDAY_2: ::nl_item = 15; +pub const ABDAY_3: ::nl_item = 16; +pub const ABDAY_4: ::nl_item = 17; +pub const ABDAY_5: ::nl_item = 18; +pub const ABDAY_6: ::nl_item = 19; +pub const ABDAY_7: ::nl_item = 20; + +pub const MON_1: ::nl_item = 21; +pub const MON_2: ::nl_item = 22; +pub const MON_3: ::nl_item = 23; +pub const MON_4: ::nl_item = 24; +pub const MON_5: ::nl_item = 25; +pub const MON_6: ::nl_item = 26; +pub const MON_7: ::nl_item = 27; +pub const MON_8: ::nl_item = 28; +pub const MON_9: ::nl_item = 29; +pub const MON_10: ::nl_item = 30; +pub const MON_11: ::nl_item = 31; +pub const MON_12: ::nl_item = 32; + +pub const ABMON_1: ::nl_item = 33; +pub const ABMON_2: ::nl_item = 34; +pub const ABMON_3: ::nl_item = 35; +pub const ABMON_4: ::nl_item = 36; +pub const ABMON_5: ::nl_item = 37; +pub const ABMON_6: ::nl_item = 38; +pub const ABMON_7: ::nl_item = 39; +pub const ABMON_8: ::nl_item = 40; +pub const ABMON_9: ::nl_item = 41; +pub const ABMON_10: ::nl_item = 42; +pub const ABMON_11: ::nl_item = 43; +pub const ABMON_12: ::nl_item = 44; + +pub const ERA: ::nl_item = 45; +pub const ERA_D_FMT: ::nl_item = 46; +pub const ERA_D_T_FMT: ::nl_item = 47; +pub const ERA_T_FMT: ::nl_item = 48; +pub const ALT_DIGITS: ::nl_item = 49; + +pub const RADIXCHAR: ::nl_item = 50; +pub const THOUSEP: ::nl_item = 51; + +pub const YESEXPR: ::nl_item = 52; +pub const NOEXPR: ::nl_item = 53; + +pub const YESSTR: ::nl_item = 54; +pub const NOSTR: ::nl_item = 55; + +pub const CRNCYSTR: ::nl_item = 56; + +pub const D_MD_ORDER: ::nl_item = 57; + +pub const ALTMON_1: ::nl_item = 58; +pub const ALTMON_2: ::nl_item = 59; +pub const ALTMON_3: ::nl_item = 60; +pub const ALTMON_4: ::nl_item = 61; +pub const ALTMON_5: ::nl_item = 62; +pub const ALTMON_6: ::nl_item = 63; +pub const ALTMON_7: ::nl_item = 64; +pub const ALTMON_8: ::nl_item = 65; +pub const ALTMON_9: ::nl_item = 66; +pub const ALTMON_10: ::nl_item = 67; +pub const ALTMON_11: ::nl_item = 68; +pub const ALTMON_12: ::nl_item = 69; + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const SEEK_DATA: ::c_int = 3; +pub const SEEK_HOLE: ::c_int = 4; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 2; +pub const _IOLBF: ::c_int = 1; +pub const BUFSIZ: ::c_uint = 1024; +pub const FOPEN_MAX: ::c_uint = 20; +pub const FILENAME_MAX: ::c_uint = 1024; +pub const L_tmpnam: ::c_uint = 1024; +pub const TMP_MAX: ::c_uint = 308915776; + +pub const O_NOCTTY: ::c_int = 32768; +pub const O_DIRECT: ::c_int = 0x00010000; + +pub const S_IFIFO: mode_t = 4096; +pub const S_IFCHR: mode_t = 8192; +pub const S_IFBLK: mode_t = 24576; +pub const S_IFDIR: mode_t = 16384; +pub const S_IFREG: mode_t = 32768; +pub const S_IFLNK: mode_t = 40960; +pub const S_IFSOCK: mode_t = 49152; +pub const S_IFMT: mode_t = 61440; +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; +pub const S_IRWXU: mode_t = 448; +pub const S_IXUSR: mode_t = 64; +pub const S_IWUSR: mode_t = 128; +pub const S_IRUSR: mode_t = 256; +pub const S_IRWXG: mode_t = 56; +pub const S_IXGRP: mode_t = 8; +pub const S_IWGRP: mode_t = 16; +pub const S_IRGRP: mode_t = 32; +pub const S_IRWXO: mode_t = 7; +pub const S_IXOTH: mode_t = 1; +pub const S_IWOTH: mode_t = 2; +pub const S_IROTH: mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; +pub const F_DUPFD_CLOEXEC: ::c_int = 17; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGEMT: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_ANON: ::c_int = 0x1000; +pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const MS_SYNC: ::c_int = 0x0000; +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EDEADLK: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const EAGAIN: ::c_int = 35; +pub const EWOULDBLOCK: ::c_int = 35; +pub const EINPROGRESS: ::c_int = 36; +pub const EALREADY: ::c_int = 37; +pub const ENOTSOCK: ::c_int = 38; +pub const EDESTADDRREQ: ::c_int = 39; +pub const EMSGSIZE: ::c_int = 40; +pub const EPROTOTYPE: ::c_int = 41; +pub const ENOPROTOOPT: ::c_int = 42; +pub const EPROTONOSUPPORT: ::c_int = 43; +pub const ESOCKTNOSUPPORT: ::c_int = 44; +pub const EOPNOTSUPP: ::c_int = 45; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 46; +pub const EAFNOSUPPORT: ::c_int = 47; +pub const EADDRINUSE: ::c_int = 48; +pub const EADDRNOTAVAIL: ::c_int = 49; +pub const ENETDOWN: ::c_int = 50; +pub const ENETUNREACH: ::c_int = 51; +pub const ENETRESET: ::c_int = 52; +pub const ECONNABORTED: ::c_int = 53; +pub const ECONNRESET: ::c_int = 54; +pub const ENOBUFS: ::c_int = 55; +pub const EISCONN: ::c_int = 56; +pub const ENOTCONN: ::c_int = 57; +pub const ESHUTDOWN: ::c_int = 58; +pub const ETOOMANYREFS: ::c_int = 59; +pub const ETIMEDOUT: ::c_int = 60; +pub const ECONNREFUSED: ::c_int = 61; +pub const ELOOP: ::c_int = 62; +pub const ENAMETOOLONG: ::c_int = 63; +pub const EHOSTDOWN: ::c_int = 64; +pub const EHOSTUNREACH: ::c_int = 65; +pub const ENOTEMPTY: ::c_int = 66; +pub const EPROCLIM: ::c_int = 67; +pub const EUSERS: ::c_int = 68; +pub const EDQUOT: ::c_int = 69; +pub const ESTALE: ::c_int = 70; +pub const EREMOTE: ::c_int = 71; +pub const EBADRPC: ::c_int = 72; +pub const ERPCMISMATCH: ::c_int = 73; +pub const EPROGUNAVAIL: ::c_int = 74; +pub const EPROGMISMATCH: ::c_int = 75; +pub const EPROCUNAVAIL: ::c_int = 76; +pub const ENOLCK: ::c_int = 77; +pub const ENOSYS: ::c_int = 78; +pub const EFTYPE: ::c_int = 79; +pub const EAUTH: ::c_int = 80; +pub const ENEEDAUTH: ::c_int = 81; +pub const EIDRM: ::c_int = 82; +pub const ENOMSG: ::c_int = 83; +pub const EOVERFLOW: ::c_int = 84; +pub const ECANCELED: ::c_int = 85; +pub const EILSEQ: ::c_int = 86; +pub const ENOATTR: ::c_int = 87; +pub const EDOOFUS: ::c_int = 88; +pub const EBADMSG: ::c_int = 89; +pub const EMULTIHOP: ::c_int = 90; +pub const ENOLINK: ::c_int = 91; +pub const EPROTO: ::c_int = 92; + +pub const POLLSTANDARD: ::c_short = ::POLLIN + | ::POLLPRI + | ::POLLOUT + | ::POLLRDNORM + | ::POLLRDBAND + | ::POLLWRBAND + | ::POLLERR + | ::POLLHUP + | ::POLLNVAL; + +pub const EAI_AGAIN: ::c_int = 2; +pub const EAI_BADFLAGS: ::c_int = 3; +pub const EAI_FAIL: ::c_int = 4; +pub const EAI_FAMILY: ::c_int = 5; +pub const EAI_MEMORY: ::c_int = 6; +pub const EAI_NONAME: ::c_int = 8; +pub const EAI_SERVICE: ::c_int = 9; +pub const EAI_SOCKTYPE: ::c_int = 10; +pub const EAI_SYSTEM: ::c_int = 11; +pub const EAI_OVERFLOW: ::c_int = 14; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; + +pub const SIGTRAP: ::c_int = 5; + +pub const GLOB_APPEND: ::c_int = 0x0001; +pub const GLOB_DOOFFS: ::c_int = 0x0002; +pub const GLOB_ERR: ::c_int = 0x0004; +pub const GLOB_MARK: ::c_int = 0x0008; +pub const GLOB_NOCHECK: ::c_int = 0x0010; +pub const GLOB_NOSORT: ::c_int = 0x0020; +pub const GLOB_NOESCAPE: ::c_int = 0x2000; + +pub const GLOB_NOSPACE: ::c_int = -1; +pub const GLOB_ABORTED: ::c_int = -2; +pub const GLOB_NOMATCH: ::c_int = -3; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + +pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0; +pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; + +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_MEMLOCK: ::c_int = 6; +pub const RLIMIT_NPROC: ::c_int = 7; +pub const RLIMIT_NOFILE: ::c_int = 8; +pub const RLIMIT_SBSIZE: ::c_int = 9; +pub const RLIMIT_VMEM: ::c_int = 10; +pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM; +pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + +pub const RUSAGE_SELF: ::c_int = 0; +pub const RUSAGE_CHILDREN: ::c_int = -1; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_FREE: ::c_int = 5; +pub const MADV_NOSYNC: ::c_int = 6; +pub const MADV_AUTOSYNC: ::c_int = 7; +pub const MADV_NOCORE: ::c_int = 8; +pub const MADV_CORE: ::c_int = 9; + +pub const MINCORE_INCORE: ::c_int = 0x1; +pub const MINCORE_REFERENCED: ::c_int = 0x2; +pub const MINCORE_MODIFIED: ::c_int = 0x4; +pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; +pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; +pub const MINCORE_SUPER: ::c_int = 0x20; + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_LOCAL: ::c_int = 1; +pub const AF_UNIX: ::c_int = AF_LOCAL; +pub const AF_INET: ::c_int = 2; +pub const AF_IMPLINK: ::c_int = 3; +pub const AF_PUP: ::c_int = 4; +pub const AF_CHAOS: ::c_int = 5; +pub const AF_NETBIOS: ::c_int = 6; +pub const AF_ISO: ::c_int = 7; +pub const AF_OSI: ::c_int = AF_ISO; +pub const AF_ECMA: ::c_int = 8; +pub const AF_DATAKIT: ::c_int = 9; +pub const AF_CCITT: ::c_int = 10; +pub const AF_SNA: ::c_int = 11; +pub const AF_DECnet: ::c_int = 12; +pub const AF_DLI: ::c_int = 13; +pub const AF_LAT: ::c_int = 14; +pub const AF_HYLINK: ::c_int = 15; +pub const AF_APPLETALK: ::c_int = 16; +pub const AF_ROUTE: ::c_int = 17; +pub const AF_LINK: ::c_int = 18; +pub const pseudo_AF_XTP: ::c_int = 19; +pub const AF_COIP: ::c_int = 20; +pub const AF_CNT: ::c_int = 21; +pub const pseudo_AF_RTIP: ::c_int = 22; +pub const AF_IPX: ::c_int = 23; +pub const AF_SIP: ::c_int = 24; +pub const pseudo_AF_PIP: ::c_int = 25; +pub const AF_ISDN: ::c_int = 26; +pub const AF_E164: ::c_int = AF_ISDN; +pub const pseudo_AF_KEY: ::c_int = 27; +pub const AF_INET6: ::c_int = 28; +pub const AF_NATM: ::c_int = 29; +pub const AF_ATM: ::c_int = 30; +pub const pseudo_AF_HDRCMPLT: ::c_int = 31; +pub const AF_NETGRAPH: ::c_int = 32; + +pub const PF_UNSPEC: ::c_int = AF_UNSPEC; +pub const PF_LOCAL: ::c_int = AF_LOCAL; +pub const PF_UNIX: ::c_int = PF_LOCAL; +pub const PF_INET: ::c_int = AF_INET; +pub const PF_IMPLINK: ::c_int = AF_IMPLINK; +pub const PF_PUP: ::c_int = AF_PUP; +pub const PF_CHAOS: ::c_int = AF_CHAOS; +pub const PF_NETBIOS: ::c_int = AF_NETBIOS; +pub const PF_ISO: ::c_int = AF_ISO; +pub const PF_OSI: ::c_int = AF_ISO; +pub const PF_ECMA: ::c_int = AF_ECMA; +pub const PF_DATAKIT: ::c_int = AF_DATAKIT; +pub const PF_CCITT: ::c_int = AF_CCITT; +pub const PF_SNA: ::c_int = AF_SNA; +pub const PF_DECnet: ::c_int = AF_DECnet; +pub const PF_DLI: ::c_int = AF_DLI; +pub const PF_LAT: ::c_int = AF_LAT; +pub const PF_HYLINK: ::c_int = AF_HYLINK; +pub const PF_APPLETALK: ::c_int = AF_APPLETALK; +pub const PF_ROUTE: ::c_int = AF_ROUTE; +pub const PF_LINK: ::c_int = AF_LINK; +pub const PF_XTP: ::c_int = pseudo_AF_XTP; +pub const PF_COIP: ::c_int = AF_COIP; +pub const PF_CNT: ::c_int = AF_CNT; +pub const PF_SIP: ::c_int = AF_SIP; +pub const PF_IPX: ::c_int = AF_IPX; +pub const PF_RTIP: ::c_int = pseudo_AF_RTIP; +pub const PF_PIP: ::c_int = pseudo_AF_PIP; +pub const PF_ISDN: ::c_int = AF_ISDN; +pub const PF_KEY: ::c_int = pseudo_AF_KEY; +pub const PF_INET6: ::c_int = AF_INET6; +pub const PF_NATM: ::c_int = AF_NATM; +pub const PF_ATM: ::c_int = AF_ATM; +pub const PF_NETGRAPH: ::c_int = AF_NETGRAPH; + +pub const PT_TRACE_ME: ::c_int = 0; +pub const PT_READ_I: ::c_int = 1; +pub const PT_READ_D: ::c_int = 2; +pub const PT_WRITE_I: ::c_int = 4; +pub const PT_WRITE_D: ::c_int = 5; +pub const PT_CONTINUE: ::c_int = 7; +pub const PT_KILL: ::c_int = 8; +pub const PT_STEP: ::c_int = 9; +pub const PT_ATTACH: ::c_int = 10; +pub const PT_DETACH: ::c_int = 11; +pub const PT_IO: ::c_int = 12; + +pub const SOMAXCONN: ::c_int = 128; + +pub const MSG_OOB: ::c_int = 0x00000001; +pub const MSG_PEEK: ::c_int = 0x00000002; +pub const MSG_DONTROUTE: ::c_int = 0x00000004; +pub const MSG_EOR: ::c_int = 0x00000008; +pub const MSG_TRUNC: ::c_int = 0x00000010; +pub const MSG_CTRUNC: ::c_int = 0x00000020; +pub const MSG_WAITALL: ::c_int = 0x00000040; +pub const MSG_DONTWAIT: ::c_int = 0x00000080; +pub const MSG_EOF: ::c_int = 0x00000100; + +pub const SCM_TIMESTAMP: ::c_int = 0x02; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_RDM: ::c_int = 4; +pub const SOCK_SEQPACKET: ::c_int = 5; +pub const SOCK_CLOEXEC: ::c_int = 0x10000000; +pub const SOCK_NONBLOCK: ::c_int = 0x20000000; +pub const SOCK_MAXADDRLEN: ::c_int = 255; +pub const IP_TTL: ::c_int = 4; +pub const IP_HDRINCL: ::c_int = 2; +pub const IP_RECVDSTADDR: ::c_int = 7; +pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR; +pub const IP_ADD_MEMBERSHIP: ::c_int = 12; +pub const IP_DROP_MEMBERSHIP: ::c_int = 13; +pub const IP_RECVIF: ::c_int = 20; +pub const IPV6_JOIN_GROUP: ::c_int = 12; +pub const IPV6_LEAVE_GROUP: ::c_int = 13; +pub const IPV6_RECVPKTINFO: ::c_int = 36; +pub const IPV6_PKTINFO: ::c_int = 46; +pub const IPV6_RECVTCLASS: ::c_int = 57; +pub const IPV6_TCLASS: ::c_int = 61; + +pub const TCP_NOPUSH: ::c_int = 4; +pub const TCP_NOOPT: ::c_int = 8; +pub const TCP_KEEPIDLE: ::c_int = 256; +pub const TCP_KEEPINTVL: ::c_int = 512; +pub const TCP_KEEPCNT: ::c_int = 1024; + +pub const SOL_SOCKET: ::c_int = 0xffff; +pub const SO_DEBUG: ::c_int = 0x01; +pub const SO_ACCEPTCONN: ::c_int = 0x0002; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_TIMESTAMP: ::c_int = 0x0400; +pub const SO_NOSIGPIPE: ::c_int = 0x0800; +pub const SO_ACCEPTFILTER: ::c_int = 0x1000; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; + +pub const MAP_COPY: ::c_int = 0x0002; +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] +pub const MAP_RENAME: ::c_int = 0x0020; +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] +pub const MAP_NORESERVE: ::c_int = 0x0040; +pub const MAP_HASSEMAPHORE: ::c_int = 0x0200; +pub const MAP_STACK: ::c_int = 0x0400; +pub const MAP_NOSYNC: ::c_int = 0x0800; +pub const MAP_NOCORE: ::c_int = 0x020000; + +pub const IPPROTO_RAW: ::c_int = 255; + +pub const _PC_LINK_MAX: ::c_int = 1; +pub const _PC_MAX_CANON: ::c_int = 2; +pub const _PC_MAX_INPUT: ::c_int = 3; +pub const _PC_NAME_MAX: ::c_int = 4; +pub const _PC_PATH_MAX: ::c_int = 5; +pub const _PC_PIPE_BUF: ::c_int = 6; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 7; +pub const _PC_NO_TRUNC: ::c_int = 8; +pub const _PC_VDISABLE: ::c_int = 9; +pub const _PC_ALLOC_SIZE_MIN: ::c_int = 10; +pub const _PC_FILESIZEBITS: ::c_int = 12; +pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16; +pub const _PC_REC_XFER_ALIGN: ::c_int = 17; +pub const _PC_SYMLINK_MAX: ::c_int = 18; +pub const _PC_MIN_HOLE_SIZE: ::c_int = 21; +pub const _PC_ASYNC_IO: ::c_int = 53; +pub const _PC_PRIO_IO: ::c_int = 54; +pub const _PC_SYNC_IO: ::c_int = 55; +pub const _PC_ACL_EXTENDED: ::c_int = 59; +pub const _PC_ACL_PATH_MAX: ::c_int = 60; +pub const _PC_CAP_PRESENT: ::c_int = 61; +pub const _PC_INF_PRESENT: ::c_int = 62; +pub const _PC_MAC_PRESENT: ::c_int = 63; + +pub const _SC_ARG_MAX: ::c_int = 1; +pub const _SC_CHILD_MAX: ::c_int = 2; +pub const _SC_CLK_TCK: ::c_int = 3; +pub const _SC_NGROUPS_MAX: ::c_int = 4; +pub const _SC_OPEN_MAX: ::c_int = 5; +pub const _SC_JOB_CONTROL: ::c_int = 6; +pub const _SC_SAVED_IDS: ::c_int = 7; +pub const _SC_VERSION: ::c_int = 8; +pub const _SC_BC_BASE_MAX: ::c_int = 9; +pub const _SC_BC_DIM_MAX: ::c_int = 10; +pub const _SC_BC_SCALE_MAX: ::c_int = 11; +pub const _SC_BC_STRING_MAX: ::c_int = 12; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13; +pub const _SC_EXPR_NEST_MAX: ::c_int = 14; +pub const _SC_LINE_MAX: ::c_int = 15; +pub const _SC_RE_DUP_MAX: ::c_int = 16; +pub const _SC_2_VERSION: ::c_int = 17; +pub const _SC_2_C_BIND: ::c_int = 18; +pub const _SC_2_C_DEV: ::c_int = 19; +pub const _SC_2_CHAR_TERM: ::c_int = 20; +pub const _SC_2_FORT_DEV: ::c_int = 21; +pub const _SC_2_FORT_RUN: ::c_int = 22; +pub const _SC_2_LOCALEDEF: ::c_int = 23; +pub const _SC_2_SW_DEV: ::c_int = 24; +pub const _SC_2_UPE: ::c_int = 25; +pub const _SC_STREAM_MAX: ::c_int = 26; +pub const _SC_TZNAME_MAX: ::c_int = 27; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 28; +pub const _SC_MAPPED_FILES: ::c_int = 29; +pub const _SC_MEMLOCK: ::c_int = 30; +pub const _SC_MEMLOCK_RANGE: ::c_int = 31; +pub const _SC_MEMORY_PROTECTION: ::c_int = 32; +pub const _SC_MESSAGE_PASSING: ::c_int = 33; +pub const _SC_PRIORITIZED_IO: ::c_int = 34; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 35; +pub const _SC_REALTIME_SIGNALS: ::c_int = 36; +pub const _SC_SEMAPHORES: ::c_int = 37; +pub const _SC_FSYNC: ::c_int = 38; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 39; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 40; +pub const _SC_TIMERS: ::c_int = 41; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 42; +pub const _SC_AIO_MAX: ::c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44; +pub const _SC_DELAYTIMER_MAX: ::c_int = 45; +pub const _SC_MQ_OPEN_MAX: ::c_int = 46; +pub const _SC_PAGESIZE: ::c_int = 47; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: ::c_int = 48; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 49; +pub const _SC_SEM_VALUE_MAX: ::c_int = 50; +pub const _SC_SIGQUEUE_MAX: ::c_int = 51; +pub const _SC_TIMER_MAX: ::c_int = 52; +pub const _SC_IOV_MAX: ::c_int = 56; +pub const _SC_NPROCESSORS_CONF: ::c_int = 57; +pub const _SC_2_PBS: ::c_int = 59; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 60; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 61; +pub const _SC_2_PBS_LOCATE: ::c_int = 62; +pub const _SC_2_PBS_MESSAGE: ::c_int = 63; +pub const _SC_2_PBS_TRACK: ::c_int = 64; +pub const _SC_ADVISORY_INFO: ::c_int = 65; +pub const _SC_BARRIERS: ::c_int = 66; +pub const _SC_CLOCK_SELECTION: ::c_int = 67; +pub const _SC_CPUTIME: ::c_int = 68; +pub const _SC_FILE_LOCKING: ::c_int = 69; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 58; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71; +pub const _SC_HOST_NAME_MAX: ::c_int = 72; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 74; +pub const _SC_MQ_PRIO_MAX: ::c_int = 75; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 76; +pub const _SC_REGEXP: ::c_int = 77; +pub const _SC_SHELL: ::c_int = 78; +pub const _SC_SPAWN: ::c_int = 79; +pub const _SC_SPIN_LOCKS: ::c_int = 80; +pub const _SC_SPORADIC_SERVER: ::c_int = 81; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 82; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 83; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 85; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 86; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 87; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 88; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 89; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 90; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 91; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 92; +pub const _SC_THREAD_STACK_MIN: ::c_int = 93; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 94; +pub const _SC_TIMEOUTS: ::c_int = 95; +pub const _SC_THREADS: ::c_int = 96; +pub const _SC_TRACE: ::c_int = 97; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 98; +pub const _SC_TRACE_INHERIT: ::c_int = 99; +pub const _SC_TRACE_LOG: ::c_int = 100; +pub const _SC_TTY_NAME_MAX: ::c_int = 101; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 102; +pub const _SC_V6_ILP32_OFF32: ::c_int = 103; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = 104; +pub const _SC_V6_LP64_OFF64: ::c_int = 105; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 106; +pub const _SC_ATEXIT_MAX: ::c_int = 107; +pub const _SC_XOPEN_CRYPT: ::c_int = 108; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 109; +pub const _SC_XOPEN_LEGACY: ::c_int = 110; +pub const _SC_XOPEN_REALTIME: ::c_int = 111; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 112; +pub const _SC_XOPEN_SHM: ::c_int = 113; +pub const _SC_XOPEN_STREAMS: ::c_int = 114; +pub const _SC_XOPEN_UNIX: ::c_int = 115; +pub const _SC_XOPEN_VERSION: ::c_int = 116; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 117; +pub const _SC_IPV6: ::c_int = 118; +pub const _SC_RAW_SOCKETS: ::c_int = 119; +pub const _SC_SYMLOOP_MAX: ::c_int = 120; +pub const _SC_PHYS_PAGES: ::c_int = 121; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_ERRORCHECK; + +pub const SCHED_FIFO: ::c_int = 1; +pub const SCHED_OTHER: ::c_int = 2; +pub const SCHED_RR: ::c_int = 3; + +pub const FD_SETSIZE: usize = 1024; + +pub const ST_NOSUID: ::c_ulong = 2; + +pub const NI_MAXHOST: ::size_t = 1025; + +pub const RTLD_LOCAL: ::c_int = 0; +pub const RTLD_NODELETE: ::c_int = 0x1000; +pub const RTLD_NOLOAD: ::c_int = 0x2000; +pub const RTLD_GLOBAL: ::c_int = 0x100; + +pub const LOG_NTP: ::c_int = 12 << 3; +pub const LOG_SECURITY: ::c_int = 13 << 3; +pub const LOG_CONSOLE: ::c_int = 14 << 3; +pub const LOG_NFACILITIES: ::c_int = 24; + +pub const TIOCEXCL: ::c_uint = 0x2000740d; +pub const TIOCNXCL: ::c_uint = 0x2000740e; +pub const TIOCFLUSH: ::c_ulong = 0x80047410; +pub const TIOCGETA: ::c_uint = 0x402c7413; +pub const TIOCSETA: ::c_ulong = 0x802c7414; +pub const TIOCSETAW: ::c_ulong = 0x802c7415; +pub const TIOCSETAF: ::c_ulong = 0x802c7416; +pub const TIOCGETD: ::c_uint = 0x4004741a; +pub const TIOCSETD: ::c_ulong = 0x8004741b; +pub const TIOCGDRAINWAIT: ::c_uint = 0x40047456; +pub const TIOCSDRAINWAIT: ::c_ulong = 0x80047457; +pub const TIOCTIMESTAMP: ::c_uint = 0x40107459; +pub const TIOCMGDTRWAIT: ::c_uint = 0x4004745a; +pub const TIOCMSDTRWAIT: ::c_ulong = 0x8004745b; +pub const TIOCDRAIN: ::c_uint = 0x2000745e; +pub const TIOCEXT: ::c_ulong = 0x80047460; +pub const TIOCSCTTY: ::c_uint = 0x20007461; +pub const TIOCCONS: ::c_ulong = 0x80047462; +pub const TIOCGSID: ::c_uint = 0x40047463; +pub const TIOCSTAT: ::c_uint = 0x20007465; +pub const TIOCUCNTL: ::c_ulong = 0x80047466; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const TIOCGWINSZ: ::c_uint = 0x40087468; +pub const TIOCMGET: ::c_uint = 0x4004746a; +pub const TIOCM_LE: ::c_int = 0x1; +pub const TIOCM_DTR: ::c_int = 0x2; +pub const TIOCM_RTS: ::c_int = 0x4; +pub const TIOCM_ST: ::c_int = 0x8; +pub const TIOCM_SR: ::c_int = 0x10; +pub const TIOCM_CTS: ::c_int = 0x20; +pub const TIOCM_RI: ::c_int = 0x80; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = 0x40; +pub const TIOCM_CAR: ::c_int = 0x40; +pub const TIOCM_RNG: ::c_int = 0x80; +pub const TIOCMBIC: ::c_ulong = 0x8004746b; +pub const TIOCMBIS: ::c_ulong = 0x8004746c; +pub const TIOCMSET: ::c_ulong = 0x8004746d; +pub const TIOCSTART: ::c_uint = 0x2000746e; +pub const TIOCSTOP: ::c_uint = 0x2000746f; +pub const TIOCPKT: ::c_ulong = 0x80047470; +pub const TIOCPKT_DATA: ::c_int = 0x0; +pub const TIOCPKT_FLUSHREAD: ::c_int = 0x1; +pub const TIOCPKT_FLUSHWRITE: ::c_int = 0x2; +pub const TIOCPKT_STOP: ::c_int = 0x4; +pub const TIOCPKT_START: ::c_int = 0x8; +pub const TIOCPKT_NOSTOP: ::c_int = 0x10; +pub const TIOCPKT_DOSTOP: ::c_int = 0x20; +pub const TIOCPKT_IOCTL: ::c_int = 0x40; +pub const TIOCNOTTY: ::c_uint = 0x20007471; +pub const TIOCSTI: ::c_ulong = 0x80017472; +pub const TIOCOUTQ: ::c_uint = 0x40047473; +pub const TIOCSPGRP: ::c_ulong = 0x80047476; +pub const TIOCGPGRP: ::c_uint = 0x40047477; +pub const TIOCCDTR: ::c_uint = 0x20007478; +pub const TIOCSDTR: ::c_uint = 0x20007479; +pub const TIOCCBRK: ::c_uint = 0x2000747a; +pub const TIOCSBRK: ::c_uint = 0x2000747b; +pub const TTYDISC: ::c_int = 0x0; +pub const SLIPDISC: ::c_int = 0x4; +pub const PPPDISC: ::c_int = 0x5; +pub const NETGRAPHDISC: ::c_int = 0x6; + +pub const BIOCGRSIG: ::c_ulong = 0x40044272; +pub const BIOCSRSIG: ::c_ulong = 0x80044273; +pub const BIOCSDLT: ::c_ulong = 0x80044278; +pub const BIOCGSEESENT: ::c_ulong = 0x40044276; +pub const BIOCSSEESENT: ::c_ulong = 0x80044277; +pub const BIOCSETF: ::c_ulong = 0x80104267; +pub const BIOCGDLTLIST: ::c_ulong = 0xc0104279; +pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; + +pub const FIODTYPE: ::c_ulong = 0x4004667a; +pub const FIOGETLBA: ::c_ulong = 0x40046679; +pub const FIODGNAME: ::c_ulong = 0x80106678; + +pub const B0: speed_t = 0; +pub const B50: speed_t = 50; +pub const B75: speed_t = 75; +pub const B110: speed_t = 110; +pub const B134: speed_t = 134; +pub const B150: speed_t = 150; +pub const B200: speed_t = 200; +pub const B300: speed_t = 300; +pub const B600: speed_t = 600; +pub const B1200: speed_t = 1200; +pub const B1800: speed_t = 1800; +pub const B2400: speed_t = 2400; +pub const B4800: speed_t = 4800; +pub const B9600: speed_t = 9600; +pub const B19200: speed_t = 19200; +pub const B38400: speed_t = 38400; +pub const B7200: speed_t = 7200; +pub const B14400: speed_t = 14400; +pub const B28800: speed_t = 28800; +pub const B57600: speed_t = 57600; +pub const B76800: speed_t = 76800; +pub const B115200: speed_t = 115200; +pub const B230400: speed_t = 230400; +pub const EXTA: speed_t = 19200; +pub const EXTB: speed_t = 38400; + +pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; + +pub const CRTSCTS: ::tcflag_t = 0x00030000; +pub const CCTS_OFLOW: ::tcflag_t = 0x00010000; +pub const CRTS_IFLOW: ::tcflag_t = 0x00020000; +pub const CDTR_IFLOW: ::tcflag_t = 0x00040000; +pub const CDSR_OFLOW: ::tcflag_t = 0x00080000; +pub const CCAR_OFLOW: ::tcflag_t = 0x00100000; +pub const VERASE2: usize = 7; +pub const OCRNL: ::tcflag_t = 0x10; +pub const ONOCR: ::tcflag_t = 0x20; +pub const ONLRET: ::tcflag_t = 0x40; + +pub const CMGROUP_MAX: usize = 16; + +// https://github.com/freebsd/freebsd/blob/master/sys/net/bpf.h +// sizeof(long) +pub const BPF_ALIGNMENT: ::c_int = 8; + +// Values for rtprio struct (prio field) and syscall (function argument) +pub const RTP_PRIO_MIN: ::c_ushort = 0; +pub const RTP_PRIO_MAX: ::c_ushort = 31; +pub const RTP_LOOKUP: ::c_int = 0; +pub const RTP_SET: ::c_int = 1; + +// Flags for chflags(2) +pub const UF_SETTABLE: ::c_ulong = 0x0000ffff; +pub const UF_NODUMP: ::c_ulong = 0x00000001; +pub const UF_IMMUTABLE: ::c_ulong = 0x00000002; +pub const UF_APPEND: ::c_ulong = 0x00000004; +pub const UF_OPAQUE: ::c_ulong = 0x00000008; +pub const UF_NOUNLINK: ::c_ulong = 0x00000010; +pub const SF_SETTABLE: ::c_ulong = 0xffff0000; +pub const SF_ARCHIVED: ::c_ulong = 0x00010000; +pub const SF_IMMUTABLE: ::c_ulong = 0x00020000; +pub const SF_APPEND: ::c_ulong = 0x00040000; +pub const SF_NOUNLINK: ::c_ulong = 0x00100000; + +pub const TIMER_ABSTIME: ::c_int = 1; + +f! { + pub fn WIFCONTINUED(status: ::c_int) -> bool { + status == 0x13 + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0o177) == 0o177 + } +} + +extern "C" { + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + pub fn sem_init( + sem: *mut sem_t, + pshared: ::c_int, + value: ::c_uint, + ) -> ::c_int; + + pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; + pub fn accept4( + s: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + flags: ::c_int, + ) -> ::c_int; + pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: ::c_int, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; + pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; + pub fn chflagsat( + fd: ::c_int, + path: *const ::c_char, + flags: ::c_ulong, + atflag: ::c_int, + ) -> ::c_int; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + pub fn duplocale(base: ::locale_t) -> ::locale_t; + pub fn endutxent(); + pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int; + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int; + pub fn getgrent_r( + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + pub fn getpwent_r( + pwd: *mut ::passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::passwd, + ) -> ::c_int; + pub fn getgrouplist( + name: *const ::c_char, + basegid: ::gid_t, + groups: *mut ::gid_t, + ngroups: *mut ::c_int, + ) -> ::c_int; + pub fn getnameinfo( + sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::size_t, + serv: *mut ::c_char, + servlen: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "kevent@FBSD_1.0" + )] + pub fn kevent( + kq: ::c_int, + changelist: *const ::kevent, + nchanges: ::c_int, + eventlist: *mut ::kevent, + nevents: ::c_int, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; + pub fn lio_listio( + mode: ::c_int, + aiocb_list: *const *mut aiocb, + nitems: ::c_int, + sevp: *mut sigevent, + ) -> ::c_int; + pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + pub fn memrchr( + cx: *const ::c_void, + c: ::c_int, + n: ::size_t, + ) -> *mut ::c_void; + pub fn mkfifoat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "mknodat@FBSD_1.1" + )] + pub fn mknodat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + dev: dev_t, + ) -> ::c_int; + pub fn mq_close(mqd: ::mqd_t) -> ::c_int; + pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; + pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) + -> ::c_int; + pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; + pub fn mq_receive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + ) -> ::ssize_t; + pub fn mq_send( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + ) -> ::c_int; + pub fn mq_setattr( + mqd: ::mqd_t, + newattr: *const ::mq_attr, + oldattr: *mut ::mq_attr, + ) -> ::c_int; + pub fn mq_timedreceive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::ssize_t; + pub fn mq_timedsend( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::c_int; + pub fn mq_unlink(name: *const ::c_char) -> ::c_int; + pub fn mincore( + addr: *const ::c_void, + len: ::size_t, + vec: *mut ::c_char, + ) -> ::c_int; + pub fn newlocale( + mask: ::c_int, + locale: *const ::c_char, + base: ::locale_t, + ) -> ::locale_t; + pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) + -> *mut ::c_char; + pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + pub fn ppoll( + fds: *mut ::pollfd, + nfds: ::nfds_t, + timeout: *const ::timespec, + sigmask: *const sigset_t, + ) -> ::c_int; + pub fn preadv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn pthread_attr_get_np( + tid: ::pthread_t, + attr: *mut ::pthread_attr_t, + ) -> ::c_int; + pub fn pthread_attr_getguardsize( + attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t, + ) -> ::c_int; + pub fn pthread_attr_getstack( + attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t, + ) -> ::c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> ::c_int; + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + pub fn pthread_condattr_setpshared( + attr: *mut pthread_condattr_t, + pshared: ::c_int, + ) -> ::c_int; + pub fn pthread_main_np() -> ::c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_mutexattr_setpshared( + attr: *mut pthread_mutexattr_t, + pshared: ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_getpshared( + attr: *const pthread_rwlockattr_t, + val: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_setpshared( + attr: *mut pthread_rwlockattr_t, + val: ::c_int, + ) -> ::c_int; + pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); + pub fn ptrace( + request: ::c_int, + pid: ::pid_t, + addr: *mut ::c_char, + data: ::c_int, + ) -> ::c_int; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn pwritev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; + pub fn rtprio( + function: ::c_int, + pid: ::pid_t, + rtp: *mut rtprio, + ) -> ::c_int; + pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; + pub fn sched_setscheduler( + pid: ::pid_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int; + pub fn sem_timedwait( + sem: *mut sem_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn sendfile( + fd: ::c_int, + s: ::c_int, + offset: ::off_t, + nbytes: ::size_t, + hdtr: *mut ::sf_hdtr, + sbytes: *mut ::off_t, + flags: ::c_int, + ) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::c_int) -> ::c_int; + pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; + pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) + -> ::c_int; + pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; + pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; + pub fn settimeofday( + tv: *const ::timeval, + tz: *const ::timezone, + ) -> ::c_int; + pub fn setutxent(); + pub fn shm_open( + name: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int; + pub fn sysctl( + name: *const ::c_int, + namelen: ::c_uint, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *const ::c_void, + newlen: ::size_t, + ) -> ::c_int; + pub fn sysctlbyname( + name: *const ::c_char, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *const ::c_void, + newlen: ::size_t, + ) -> ::c_int; + pub fn sysctlnametomib( + name: *const ::c_char, + mibp: *mut ::c_int, + sizep: *mut ::size_t, + ) -> ::c_int; + pub fn uselocale(loc: ::locale_t) -> ::locale_t; + pub fn utimensat( + dirfd: ::c_int, + path: *const ::c_char, + times: *const ::timespec, + flag: ::c_int, + ) -> ::c_int; +} + +#[link(name = "util")] +extern "C" { + pub fn openpty( + amaster: *mut ::c_int, + aslave: *mut ::c_int, + name: *mut ::c_char, + termp: *mut termios, + winp: *mut ::winsize, + ) -> ::c_int; + pub fn forkpty( + amaster: *mut ::c_int, + name: *mut ::c_char, + termp: *mut termios, + winp: *mut ::winsize, + ) -> ::pid_t; + pub fn login_tty(fd: ::c_int) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_os = "freebsd")] { + mod freebsd; + pub use self::freebsd::*; + } else if #[cfg(target_os = "dragonfly")] { + mod dragonfly; + pub use self::dragonfly::*; + } else { + // ... + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/mod.rs new file mode 100644 index 0000000..cf9f59e --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/mod.rs @@ -0,0 +1,794 @@ +pub type wchar_t = i32; +pub type off_t = i64; +pub type useconds_t = u32; +pub type blkcnt_t = i64; +pub type socklen_t = u32; +pub type sa_family_t = u8; +pub type pthread_t = ::uintptr_t; +pub type nfds_t = ::c_uint; + +s! { + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_change: ::time_t, + pub pw_class: *mut ::c_char, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + pub pw_expire: ::time_t, + + #[cfg(not(any(target_os = "macos", + target_os = "ios", + target_os = "netbsd", + target_os = "openbsd")))] + pub pw_fields: ::c_int, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut ::c_char, + pub ifa_flags: ::c_uint, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_dstaddr: *mut ::sockaddr, + pub ifa_data: *mut ::c_void, + #[cfg(target_os = "netbsd")] + pub ifa_addrflags: ::c_uint + } + + pub struct fd_set { + #[cfg(all(target_pointer_width = "64", + any(target_os = "freebsd", target_os = "dragonfly")))] + fds_bits: [i64; FD_SETSIZE / 64], + #[cfg(not(all(target_pointer_width = "64", + any(target_os = "freebsd", target_os = "dragonfly"))))] + fds_bits: [i32; FD_SETSIZE / 32], + } + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + pub tm_gmtoff: ::c_long, + pub tm_zone: *mut ::c_char, + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::socklen_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::socklen_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct fsid_t { + __fsid_val: [i32; 2], + } + + pub struct if_nameindex { + pub if_index: ::c_uint, + pub if_name: *mut ::c_char, + } +} + +s_no_extra_traits! { + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + + pub struct utsname { + #[cfg(not(target_os = "dragonfly"))] + pub sysname: [::c_char; 256], + #[cfg(target_os = "dragonfly")] + pub sysname: [::c_char; 32], + #[cfg(not(target_os = "dragonfly"))] + pub nodename: [::c_char; 256], + #[cfg(target_os = "dragonfly")] + pub nodename: [::c_char; 32], + #[cfg(not(target_os = "dragonfly"))] + pub release: [::c_char; 256], + #[cfg(target_os = "dragonfly")] + pub release: [::c_char; 32], + #[cfg(not(target_os = "dragonfly"))] + pub version: [::c_char; 256], + #[cfg(target_os = "dragonfly")] + pub version: [::c_char; 32], + #[cfg(not(target_os = "dragonfly"))] + pub machine: [::c_char; 256], + #[cfg(target_os = "dragonfly")] + pub machine: [::c_char; 32], + } + +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_len == other.sun_len + && self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for sockaddr_un {} + + impl ::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_len", &self.sun_len) + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } + } + + impl ::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_len.hash(state); + self.sun_family.hash(state); + self.sun_path.hash(state); + } + } + + impl PartialEq for utsname { + fn eq(&self, other: &utsname) -> bool { + self.sysname + .iter() + .zip(other.sysname.iter()) + .all(|(a,b)| a == b) + && self + .nodename + .iter() + .zip(other.nodename.iter()) + .all(|(a,b)| a == b) + && self + .release + .iter() + .zip(other.release.iter()) + .all(|(a,b)| a == b) + && self + .version + .iter() + .zip(other.version.iter()) + .all(|(a,b)| a == b) + && self + .machine + .iter() + .zip(other.machine.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for utsname {} + + impl ::fmt::Debug for utsname { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utsname") + // FIXME: .field("sysname", &self.sysname) + // FIXME: .field("nodename", &self.nodename) + // FIXME: .field("release", &self.release) + // FIXME: .field("version", &self.version) + // FIXME: .field("machine", &self.machine) + .finish() + } + } + + impl ::hash::Hash for utsname { + fn hash(&self, state: &mut H) { + self.sysname.hash(state); + self.nodename.hash(state); + self.release.hash(state); + self.version.hash(state); + self.machine.hash(state); + } + } + } +} + +pub const LC_ALL: ::c_int = 0; +pub const LC_COLLATE: ::c_int = 1; +pub const LC_CTYPE: ::c_int = 2; +pub const LC_MONETARY: ::c_int = 3; +pub const LC_NUMERIC: ::c_int = 4; +pub const LC_TIME: ::c_int = 5; +pub const LC_MESSAGES: ::c_int = 6; + +pub const FIOCLEX: ::c_ulong = 0x20006601; +pub const FIONCLEX: ::c_ulong = 0x20006602; +pub const FIONREAD: ::c_ulong = 0x4004667f; +pub const FIONBIO: ::c_ulong = 0x8004667e; +pub const FIOASYNC: ::c_ulong = 0x8004667d; +pub const FIOSETOWN: ::c_ulong = 0x8004667c; +pub const FIOGETOWN: ::c_ulong = 0x4004667b; + +pub const PATH_MAX: ::c_int = 1024; + +pub const SA_ONSTACK: ::c_int = 0x0001; +pub const SA_SIGINFO: ::c_int = 0x0040; +pub const SA_RESTART: ::c_int = 0x0002; +pub const SA_RESETHAND: ::c_int = 0x0004; +pub const SA_NOCLDSTOP: ::c_int = 0x0008; +pub const SA_NODEFER: ::c_int = 0x0010; +pub const SA_NOCLDWAIT: ::c_int = 0x0020; + +pub const SS_ONSTACK: ::c_int = 1; +pub const SS_DISABLE: ::c_int = 4; + +pub const SIGCHLD: ::c_int = 20; +pub const SIGBUS: ::c_int = 10; +pub const SIGUSR1: ::c_int = 30; +pub const SIGUSR2: ::c_int = 31; +pub const SIGCONT: ::c_int = 19; +pub const SIGSTOP: ::c_int = 17; +pub const SIGTSTP: ::c_int = 18; +pub const SIGURG: ::c_int = 16; +pub const SIGIO: ::c_int = 23; +pub const SIGSYS: ::c_int = 12; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGINFO: ::c_int = 29; + +pub const SIG_SETMASK: ::c_int = 3; +pub const SIG_BLOCK: ::c_int = 0x1; +pub const SIG_UNBLOCK: ::c_int = 0x2; + +pub const IP_TOS: ::c_int = 3; +pub const IP_MULTICAST_IF: ::c_int = 9; +pub const IP_MULTICAST_TTL: ::c_int = 10; +pub const IP_MULTICAST_LOOP: ::c_int = 11; + +pub const IPV6_UNICAST_HOPS: ::c_int = 4; +pub const IPV6_MULTICAST_IF: ::c_int = 9; +pub const IPV6_MULTICAST_HOPS: ::c_int = 10; +pub const IPV6_MULTICAST_LOOP: ::c_int = 11; +pub const IPV6_V6ONLY: ::c_int = 27; + +pub const IPTOS_ECN_NOTECT: u8 = 0x00; +pub const IPTOS_ECN_MASK: u8 = 0x03; +pub const IPTOS_ECN_ECT1: u8 = 0x01; +pub const IPTOS_ECN_ECT0: u8 = 0x02; +pub const IPTOS_ECN_CE: u8 = 0x03; + +pub const ST_RDONLY: ::c_ulong = 1; + +pub const SCM_RIGHTS: ::c_int = 0x01; + +pub const NCCS: usize = 20; + +pub const O_ACCMODE: ::c_int = 0x3; +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 512; +pub const O_TRUNC: ::c_int = 1024; +pub const O_EXCL: ::c_int = 2048; +pub const O_ASYNC: ::c_int = 0x40; +pub const O_SYNC: ::c_int = 0x80; +pub const O_NONBLOCK: ::c_int = 0x4; +pub const O_NOFOLLOW: ::c_int = 0x100; +pub const O_SHLOCK: ::c_int = 0x10; +pub const O_EXLOCK: ::c_int = 0x20; +pub const O_FSYNC: ::c_int = O_SYNC; +pub const O_NDELAY: ::c_int = O_NONBLOCK; + +pub const F_GETOWN: ::c_int = 5; +pub const F_SETOWN: ::c_int = 6; + +pub const F_RDLCK: ::c_short = 1; +pub const F_UNLCK: ::c_short = 2; +pub const F_WRLCK: ::c_short = 3; + +pub const MNT_FORCE: ::c_int = 0x80000; + +pub const Q_SYNC: ::c_int = 0x600; +pub const Q_QUOTAON: ::c_int = 0x100; +pub const Q_QUOTAOFF: ::c_int = 0x200; + +pub const TCIOFF: ::c_int = 3; +pub const TCION: ::c_int = 4; +pub const TCOOFF: ::c_int = 1; +pub const TCOON: ::c_int = 2; +pub const TCIFLUSH: ::c_int = 1; +pub const TCOFLUSH: ::c_int = 2; +pub const TCIOFLUSH: ::c_int = 3; +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; +pub const VEOF: usize = 0; +pub const VEOL: usize = 1; +pub const VEOL2: usize = 2; +pub const VERASE: usize = 3; +pub const VWERASE: usize = 4; +pub const VKILL: usize = 5; +pub const VREPRINT: usize = 6; +pub const VINTR: usize = 8; +pub const VQUIT: usize = 9; +pub const VSUSP: usize = 10; +pub const VDSUSP: usize = 11; +pub const VSTART: usize = 12; +pub const VSTOP: usize = 13; +pub const VLNEXT: usize = 14; +pub const VDISCARD: usize = 15; +pub const VMIN: usize = 16; +pub const VTIME: usize = 17; +pub const VSTATUS: usize = 18; +pub const _POSIX_VDISABLE: ::cc_t = 0xff; +pub const IGNBRK: ::tcflag_t = 0x00000001; +pub const BRKINT: ::tcflag_t = 0x00000002; +pub const IGNPAR: ::tcflag_t = 0x00000004; +pub const PARMRK: ::tcflag_t = 0x00000008; +pub const INPCK: ::tcflag_t = 0x00000010; +pub const ISTRIP: ::tcflag_t = 0x00000020; +pub const INLCR: ::tcflag_t = 0x00000040; +pub const IGNCR: ::tcflag_t = 0x00000080; +pub const ICRNL: ::tcflag_t = 0x00000100; +pub const IXON: ::tcflag_t = 0x00000200; +pub const IXOFF: ::tcflag_t = 0x00000400; +pub const IXANY: ::tcflag_t = 0x00000800; +pub const IMAXBEL: ::tcflag_t = 0x00002000; +pub const OPOST: ::tcflag_t = 0x1; +pub const ONLCR: ::tcflag_t = 0x2; +pub const OXTABS: ::tcflag_t = 0x4; +pub const ONOEOT: ::tcflag_t = 0x8; +pub const CIGNORE: ::tcflag_t = 0x00000001; +pub const CSIZE: ::tcflag_t = 0x00000300; +pub const CS5: ::tcflag_t = 0x00000000; +pub const CS6: ::tcflag_t = 0x00000100; +pub const CS7: ::tcflag_t = 0x00000200; +pub const CS8: ::tcflag_t = 0x00000300; +pub const CSTOPB: ::tcflag_t = 0x00000400; +pub const CREAD: ::tcflag_t = 0x00000800; +pub const PARENB: ::tcflag_t = 0x00001000; +pub const PARODD: ::tcflag_t = 0x00002000; +pub const HUPCL: ::tcflag_t = 0x00004000; +pub const CLOCAL: ::tcflag_t = 0x00008000; +pub const ECHOKE: ::tcflag_t = 0x00000001; +pub const ECHOE: ::tcflag_t = 0x00000002; +pub const ECHOK: ::tcflag_t = 0x00000004; +pub const ECHO: ::tcflag_t = 0x00000008; +pub const ECHONL: ::tcflag_t = 0x00000010; +pub const ECHOPRT: ::tcflag_t = 0x00000020; +pub const ECHOCTL: ::tcflag_t = 0x00000040; +pub const ISIG: ::tcflag_t = 0x00000080; +pub const ICANON: ::tcflag_t = 0x00000100; +pub const ALTWERASE: ::tcflag_t = 0x00000200; +pub const IEXTEN: ::tcflag_t = 0x00000400; +pub const EXTPROC: ::tcflag_t = 0x00000800; +pub const TOSTOP: ::tcflag_t = 0x00400000; +pub const FLUSHO: ::tcflag_t = 0x00800000; +pub const NOKERNINFO: ::tcflag_t = 0x02000000; +pub const PENDIN: ::tcflag_t = 0x20000000; +pub const NOFLSH: ::tcflag_t = 0x80000000; +pub const MDMBUF: ::tcflag_t = 0x00100000; + +pub const WNOHANG: ::c_int = 0x00000001; +pub const WUNTRACED: ::c_int = 0x00000002; + +pub const RTLD_LAZY: ::c_int = 0x1; +pub const RTLD_NOW: ::c_int = 0x2; +pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void; +pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void; +pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void; + +pub const LOG_CRON: ::c_int = 9 << 3; +pub const LOG_AUTHPRIV: ::c_int = 10 << 3; +pub const LOG_FTP: ::c_int = 11 << 3; +pub const LOG_PERROR: ::c_int = 0x20; + +pub const TCP_NODELAY: ::c_int = 1; +pub const TCP_MAXSEG: ::c_int = 2; + +pub const PIPE_BUF: usize = 512; + +pub const POLLIN: ::c_short = 0x1; +pub const POLLPRI: ::c_short = 0x2; +pub const POLLOUT: ::c_short = 0x4; +pub const POLLERR: ::c_short = 0x8; +pub const POLLHUP: ::c_short = 0x10; +pub const POLLNVAL: ::c_short = 0x20; +pub const POLLRDNORM: ::c_short = 0x040; +pub const POLLWRNORM: ::c_short = 0x004; +pub const POLLRDBAND: ::c_short = 0x080; +pub const POLLWRBAND: ::c_short = 0x100; + +pub const BIOCGBLEN: ::c_ulong = 0x40044266; +pub const BIOCSBLEN: ::c_ulong = 0xc0044266; +pub const BIOCFLUSH: ::c_uint = 0x20004268; +pub const BIOCPROMISC: ::c_uint = 0x20004269; +pub const BIOCGDLT: ::c_ulong = 0x4004426a; +pub const BIOCGETIF: ::c_ulong = 0x4020426b; +pub const BIOCSETIF: ::c_ulong = 0x8020426c; +pub const BIOCGSTATS: ::c_ulong = 0x4008426f; +pub const BIOCIMMEDIATE: ::c_ulong = 0x80044270; +pub const BIOCVERSION: ::c_ulong = 0x40044271; +pub const BIOCGHDRCMPLT: ::c_ulong = 0x40044274; +pub const BIOCSHDRCMPLT: ::c_ulong = 0x80044275; +pub const SIOCGIFADDR: ::c_ulong = 0xc0206921; + +f! { + pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr { + if (*mhdr).msg_controllen as usize >= ::mem::size_of::<::cmsghdr>() { + (*mhdr).msg_control as *mut ::cmsghdr + } else { + 0 as *mut ::cmsghdr + } + } + + pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { + let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); + return + } + + pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0 + } + + pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { + let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] |= 1 << (fd % bits); + return + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } + + pub fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0o177 + } + + pub fn WIFEXITED(status: ::c_int) -> bool { + (status & 0o177) == 0 + } + + pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub fn WCOREDUMP(status: ::c_int) -> bool { + (status & 0o200) != 0 + } + + pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { + (cmd << 8) | (type_ & 0x00ff) + } +} + +extern "C" { + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "getrlimit$UNIX2003" + )] + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "setrlimit$UNIX2003" + )] + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; + pub fn freeifaddrs(ifa: *mut ::ifaddrs); + pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + pub fn kqueue() -> ::c_int; + pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int; + pub fn syscall(num: ::c_int, ...) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")] + pub fn getpwent() -> *mut passwd; + pub fn setpwent(); + pub fn endpwent(); + pub fn endgrent(); + pub fn getgrent() -> *mut ::group; + + pub fn getprogname() -> *const ::c_char; + pub fn setprogname(name: *const ::c_char); + pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + + pub fn getpeereid( + socket: ::c_int, + euid: *mut ::uid_t, + egid: *mut ::gid_t, + ) -> ::c_int; + + #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] + #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "glob@FBSD_1.0" + )] + pub fn glob( + pattern: *const ::c_char, + flags: ::c_int, + errfunc: ::Option< + extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int, + >, + pglob: *mut ::glob_t, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "globfree@FBSD_1.0" + )] + pub fn globfree(pglob: *mut ::glob_t); + + pub fn posix_madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "seekdir$INODE64" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "seekdir$INODE64$UNIX2003" + )] + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "telldir$INODE64" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "telldir$INODE64$UNIX2003" + )] + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; + pub fn madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "msync$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__msync13")] + pub fn msync( + addr: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "recvfrom$UNIX2003" + )] + pub fn recvfrom( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + ) -> ::ssize_t; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__futimes50")] + pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "bind$UNIX2003" + )] + pub fn bind( + socket: ::c_int, + address: *const ::sockaddr, + address_len: ::socklen_t, + ) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "writev$UNIX2003" + )] + pub fn writev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "readv$UNIX2003" + )] + pub fn readv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sendmsg$UNIX2003" + )] + pub fn sendmsg( + fd: ::c_int, + msg: *const ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "recvmsg$UNIX2003" + )] + pub fn recvmsg( + fd: ::c_int, + msg: *mut ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + + pub fn sync(); + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigaltstack$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sem_close(sem: *mut sem_t) -> ::c_int; + pub fn getdtablesize() -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_sigmask$UNIX2003" + )] + pub fn pthread_sigmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const ::c_char) -> *mut ::group; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_cancel$UNIX2003" + )] + pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int; + pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; + pub fn sem_unlink(name: *const ::c_char) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigwait$UNIX2003" + )] + #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] + pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; + pub fn pthread_atfork( + prepare: ::Option, + parent: ::Option, + child: ::Option, + ) -> ::c_int; + pub fn getgrgid(gid: ::gid_t) -> *mut ::group; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "popen$UNIX2003" + )] + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + pub fn faccessat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::c_int, + flags: ::c_int, + ) -> ::c_int; + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + pub fn acct(filename: *const ::c_char) -> ::c_int; +} + +cfg_if! { + if #[cfg(any(target_os = "macos", target_os = "ios"))] { + mod apple; + pub use self::apple::*; + } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] { + mod netbsdlike; + pub use self::netbsdlike::*; + } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] { + mod freebsdlike; + pub use self::freebsdlike::*; + } else { + // Unknown target_os + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/mod.rs new file mode 100644 index 0000000..970cb23 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/mod.rs @@ -0,0 +1,765 @@ +pub type time_t = i64; +pub type mode_t = u32; +pub type nlink_t = u32; +pub type ino_t = u64; +pub type pthread_key_t = ::c_int; +pub type rlim_t = u64; +pub type speed_t = ::c_uint; +pub type tcflag_t = ::c_uint; +pub type nl_item = c_long; +pub type clockid_t = ::c_int; +pub type id_t = u32; +pub type sem_t = *mut sem; +pub type key_t = c_long; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum timezone {} +impl ::Copy for timezone {} +impl ::Clone for timezone { + fn clone(&self) -> timezone { + *self + } +} +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum sem {} +impl ::Copy for sem {} +impl ::Clone for sem { + fn clone(&self) -> sem { + *self + } +} + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_uint, + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_cc: [::cc_t; ::NCCS], + pub c_ispeed: ::c_int, + pub c_ospeed: ::c_int, + } + + pub struct flock { + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + pub l_type: ::c_short, + pub l_whence: ::c_short, + } + + pub struct ipc_perm { + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub mode: ::mode_t, + pub seq: ::c_ushort, + pub key: ::key_t, + } +} + +pub const D_T_FMT: ::nl_item = 0; +pub const D_FMT: ::nl_item = 1; +pub const T_FMT: ::nl_item = 2; +pub const T_FMT_AMPM: ::nl_item = 3; +pub const AM_STR: ::nl_item = 4; +pub const PM_STR: ::nl_item = 5; + +pub const DAY_1: ::nl_item = 6; +pub const DAY_2: ::nl_item = 7; +pub const DAY_3: ::nl_item = 8; +pub const DAY_4: ::nl_item = 9; +pub const DAY_5: ::nl_item = 10; +pub const DAY_6: ::nl_item = 11; +pub const DAY_7: ::nl_item = 12; + +pub const ABDAY_1: ::nl_item = 13; +pub const ABDAY_2: ::nl_item = 14; +pub const ABDAY_3: ::nl_item = 15; +pub const ABDAY_4: ::nl_item = 16; +pub const ABDAY_5: ::nl_item = 17; +pub const ABDAY_6: ::nl_item = 18; +pub const ABDAY_7: ::nl_item = 19; + +pub const MON_1: ::nl_item = 20; +pub const MON_2: ::nl_item = 21; +pub const MON_3: ::nl_item = 22; +pub const MON_4: ::nl_item = 23; +pub const MON_5: ::nl_item = 24; +pub const MON_6: ::nl_item = 25; +pub const MON_7: ::nl_item = 26; +pub const MON_8: ::nl_item = 27; +pub const MON_9: ::nl_item = 28; +pub const MON_10: ::nl_item = 29; +pub const MON_11: ::nl_item = 30; +pub const MON_12: ::nl_item = 31; + +pub const ABMON_1: ::nl_item = 32; +pub const ABMON_2: ::nl_item = 33; +pub const ABMON_3: ::nl_item = 34; +pub const ABMON_4: ::nl_item = 35; +pub const ABMON_5: ::nl_item = 36; +pub const ABMON_6: ::nl_item = 37; +pub const ABMON_7: ::nl_item = 38; +pub const ABMON_8: ::nl_item = 39; +pub const ABMON_9: ::nl_item = 40; +pub const ABMON_10: ::nl_item = 41; +pub const ABMON_11: ::nl_item = 42; +pub const ABMON_12: ::nl_item = 43; + +pub const RADIXCHAR: ::nl_item = 44; +pub const THOUSEP: ::nl_item = 45; +pub const YESSTR: ::nl_item = 46; +pub const YESEXPR: ::nl_item = 47; +pub const NOSTR: ::nl_item = 48; +pub const NOEXPR: ::nl_item = 49; +pub const CRNCYSTR: ::nl_item = 50; + +pub const CODESET: ::nl_item = 51; + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 2147483647; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 2; +pub const _IOLBF: ::c_int = 1; +pub const BUFSIZ: ::c_uint = 1024; +pub const FOPEN_MAX: ::c_uint = 20; +pub const FILENAME_MAX: ::c_uint = 1024; +pub const L_tmpnam: ::c_uint = 1024; +pub const O_NOCTTY: ::c_int = 32768; +pub const S_IFIFO: mode_t = 4096; +pub const S_IFCHR: mode_t = 8192; +pub const S_IFBLK: mode_t = 24576; +pub const S_IFDIR: mode_t = 16384; +pub const S_IFREG: mode_t = 32768; +pub const S_IFLNK: mode_t = 40960; +pub const S_IFSOCK: mode_t = 49152; +pub const S_IFMT: mode_t = 61440; +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; +pub const S_IRWXU: mode_t = 448; +pub const S_IXUSR: mode_t = 64; +pub const S_IWUSR: mode_t = 128; +pub const S_IRUSR: mode_t = 256; +pub const S_IRWXG: mode_t = 56; +pub const S_IXGRP: mode_t = 8; +pub const S_IWGRP: mode_t = 16; +pub const S_IRGRP: mode_t = 32; +pub const S_IRWXO: mode_t = 7; +pub const S_IXOTH: mode_t = 1; +pub const S_IWOTH: mode_t = 2; +pub const S_IROTH: mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; +pub const F_GETLK: ::c_int = 7; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGEMT: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_ANON: ::c_int = 0x1000; +pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +pub const IPC_CREAT: ::c_int = 0o001000; +pub const IPC_EXCL: ::c_int = 0o002000; +pub const IPC_NOWAIT: ::c_int = 0o004000; + +pub const IPC_PRIVATE: ::key_t = 0; + +pub const IPC_RMID: ::c_int = 0; +pub const IPC_SET: ::c_int = 1; +pub const IPC_STAT: ::c_int = 2; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const MS_ASYNC: ::c_int = 0x0001; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EDEADLK: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const EAGAIN: ::c_int = 35; +pub const EWOULDBLOCK: ::c_int = 35; +pub const EINPROGRESS: ::c_int = 36; +pub const EALREADY: ::c_int = 37; +pub const ENOTSOCK: ::c_int = 38; +pub const EDESTADDRREQ: ::c_int = 39; +pub const EMSGSIZE: ::c_int = 40; +pub const EPROTOTYPE: ::c_int = 41; +pub const ENOPROTOOPT: ::c_int = 42; +pub const EPROTONOSUPPORT: ::c_int = 43; +pub const ESOCKTNOSUPPORT: ::c_int = 44; +pub const EOPNOTSUPP: ::c_int = 45; +pub const EPFNOSUPPORT: ::c_int = 46; +pub const EAFNOSUPPORT: ::c_int = 47; +pub const EADDRINUSE: ::c_int = 48; +pub const EADDRNOTAVAIL: ::c_int = 49; +pub const ENETDOWN: ::c_int = 50; +pub const ENETUNREACH: ::c_int = 51; +pub const ENETRESET: ::c_int = 52; +pub const ECONNABORTED: ::c_int = 53; +pub const ECONNRESET: ::c_int = 54; +pub const ENOBUFS: ::c_int = 55; +pub const EISCONN: ::c_int = 56; +pub const ENOTCONN: ::c_int = 57; +pub const ESHUTDOWN: ::c_int = 58; +pub const ETOOMANYREFS: ::c_int = 59; +pub const ETIMEDOUT: ::c_int = 60; +pub const ECONNREFUSED: ::c_int = 61; +pub const ELOOP: ::c_int = 62; +pub const ENAMETOOLONG: ::c_int = 63; +pub const EHOSTDOWN: ::c_int = 64; +pub const EHOSTUNREACH: ::c_int = 65; +pub const ENOTEMPTY: ::c_int = 66; +pub const EPROCLIM: ::c_int = 67; +pub const EUSERS: ::c_int = 68; +pub const EDQUOT: ::c_int = 69; +pub const ESTALE: ::c_int = 70; +pub const EREMOTE: ::c_int = 71; +pub const EBADRPC: ::c_int = 72; +pub const ERPCMISMATCH: ::c_int = 73; +pub const EPROGUNAVAIL: ::c_int = 74; +pub const EPROGMISMATCH: ::c_int = 75; +pub const EPROCUNAVAIL: ::c_int = 76; +pub const ENOLCK: ::c_int = 77; +pub const ENOSYS: ::c_int = 78; +pub const EFTYPE: ::c_int = 79; +pub const EAUTH: ::c_int = 80; +pub const ENEEDAUTH: ::c_int = 81; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; + +pub const SIGTRAP: ::c_int = 5; + +pub const GLOB_APPEND: ::c_int = 0x0001; +pub const GLOB_DOOFFS: ::c_int = 0x0002; +pub const GLOB_ERR: ::c_int = 0x0004; +pub const GLOB_MARK: ::c_int = 0x0008; +pub const GLOB_NOCHECK: ::c_int = 0x0010; +pub const GLOB_NOSORT: ::c_int = 0x0020; +pub const GLOB_NOESCAPE: ::c_int = 0x1000; + +pub const GLOB_NOSPACE: ::c_int = -1; +pub const GLOB_ABORTED: ::c_int = -2; +pub const GLOB_NOMATCH: ::c_int = -3; +pub const GLOB_NOSYS: ::c_int = -4; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; + +pub const PT_TRACE_ME: ::c_int = 0; +pub const PT_READ_I: ::c_int = 1; +pub const PT_READ_D: ::c_int = 2; +pub const PT_WRITE_I: ::c_int = 4; +pub const PT_WRITE_D: ::c_int = 5; +pub const PT_CONTINUE: ::c_int = 7; +pub const PT_KILL: ::c_int = 8; +pub const PT_ATTACH: ::c_int = 9; +pub const PT_DETACH: ::c_int = 10; +pub const PT_IO: ::c_int = 11; + +// http://man.openbsd.org/OpenBSD-current/man2/clock_getres.2 +// The man page says clock_gettime(3) can accept various values as clockid_t but +// http://fxr.watson.org/fxr/source/kern/kern_time.c?v=OPENBSD;im=excerpts#L161 +// the implementation rejects anything other than the below two +// +// http://netbsd.gw.com/cgi-bin/man-cgi?clock_gettime +// https://github.com/jsonn/src/blob/HEAD/sys/kern/subr_time.c#L222 +// Basically the same goes for NetBSD +pub const CLOCK_REALTIME: ::clockid_t = 0; +pub const CLOCK_MONOTONIC: ::clockid_t = 3; + +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_MEMLOCK: ::c_int = 6; +pub const RLIMIT_NPROC: ::c_int = 7; +pub const RLIMIT_NOFILE: ::c_int = 8; + +pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; +pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + +pub const RUSAGE_SELF: ::c_int = 0; +pub const RUSAGE_CHILDREN: ::c_int = -1; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_FREE: ::c_int = 6; + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_LOCAL: ::c_int = 1; +pub const AF_UNIX: ::c_int = AF_LOCAL; +pub const AF_INET: ::c_int = 2; +pub const AF_IMPLINK: ::c_int = 3; +pub const AF_PUP: ::c_int = 4; +pub const AF_CHAOS: ::c_int = 5; +pub const AF_NS: ::c_int = 6; +pub const AF_ISO: ::c_int = 7; +pub const AF_OSI: ::c_int = AF_ISO; +pub const AF_DATAKIT: ::c_int = 9; +pub const AF_CCITT: ::c_int = 10; +pub const AF_SNA: ::c_int = 11; +pub const AF_DECnet: ::c_int = 12; +pub const AF_DLI: ::c_int = 13; +pub const AF_LAT: ::c_int = 14; +pub const AF_HYLINK: ::c_int = 15; +pub const AF_APPLETALK: ::c_int = 16; +pub const AF_LINK: ::c_int = 18; +pub const pseudo_AF_XTP: ::c_int = 19; +pub const AF_COIP: ::c_int = 20; +pub const AF_CNT: ::c_int = 21; +pub const pseudo_AF_RTIP: ::c_int = 22; +pub const AF_IPX: ::c_int = 23; +pub const AF_INET6: ::c_int = 24; +pub const pseudo_AF_PIP: ::c_int = 25; +pub const AF_ISDN: ::c_int = 26; +pub const AF_E164: ::c_int = AF_ISDN; +pub const AF_NATM: ::c_int = 27; + +pub const PF_UNSPEC: ::c_int = AF_UNSPEC; +pub const PF_LOCAL: ::c_int = AF_LOCAL; +pub const PF_UNIX: ::c_int = PF_LOCAL; +pub const PF_INET: ::c_int = AF_INET; +pub const PF_IMPLINK: ::c_int = AF_IMPLINK; +pub const PF_PUP: ::c_int = AF_PUP; +pub const PF_CHAOS: ::c_int = AF_CHAOS; +pub const PF_NS: ::c_int = AF_NS; +pub const PF_ISO: ::c_int = AF_ISO; +pub const PF_OSI: ::c_int = AF_ISO; +pub const PF_DATAKIT: ::c_int = AF_DATAKIT; +pub const PF_CCITT: ::c_int = AF_CCITT; +pub const PF_SNA: ::c_int = AF_SNA; +pub const PF_DECnet: ::c_int = AF_DECnet; +pub const PF_DLI: ::c_int = AF_DLI; +pub const PF_LAT: ::c_int = AF_LAT; +pub const PF_HYLINK: ::c_int = AF_HYLINK; +pub const PF_APPLETALK: ::c_int = AF_APPLETALK; +pub const PF_LINK: ::c_int = AF_LINK; +pub const PF_XTP: ::c_int = pseudo_AF_XTP; +pub const PF_COIP: ::c_int = AF_COIP; +pub const PF_CNT: ::c_int = AF_CNT; +pub const PF_IPX: ::c_int = AF_IPX; +pub const PF_INET6: ::c_int = AF_INET6; +pub const PF_RTIP: ::c_int = pseudo_AF_RTIP; +pub const PF_PIP: ::c_int = pseudo_AF_PIP; +pub const PF_ISDN: ::c_int = AF_ISDN; +pub const PF_NATM: ::c_int = AF_NATM; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_RDM: ::c_int = 4; +pub const SOCK_SEQPACKET: ::c_int = 5; +pub const IP_TTL: ::c_int = 4; +pub const IP_HDRINCL: ::c_int = 2; +pub const IP_ADD_MEMBERSHIP: ::c_int = 12; +pub const IP_DROP_MEMBERSHIP: ::c_int = 13; +pub const IPV6_RECVPKTINFO: ::c_int = 36; +pub const IPV6_PKTINFO: ::c_int = 46; +pub const IPV6_RECVTCLASS: ::c_int = 57; +pub const IPV6_TCLASS: ::c_int = 61; + +pub const SOL_SOCKET: ::c_int = 0xffff; +pub const SO_DEBUG: ::c_int = 0x01; +pub const SO_ACCEPTCONN: ::c_int = 0x0002; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; + +pub const SOMAXCONN: ::c_int = 128; + +pub const MSG_OOB: ::c_int = 0x1; +pub const MSG_PEEK: ::c_int = 0x2; +pub const MSG_DONTROUTE: ::c_int = 0x4; +pub const MSG_EOR: ::c_int = 0x8; +pub const MSG_TRUNC: ::c_int = 0x10; +pub const MSG_CTRUNC: ::c_int = 0x20; +pub const MSG_WAITALL: ::c_int = 0x40; +pub const MSG_DONTWAIT: ::c_int = 0x80; +pub const MSG_BCAST: ::c_int = 0x100; +pub const MSG_MCAST: ::c_int = 0x200; +pub const MSG_NOSIGNAL: ::c_int = 0x400; +pub const MSG_CMSG_CLOEXEC: ::c_int = 0x800; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; + +pub const IPPROTO_RAW: ::c_int = 255; + +pub const _SC_ARG_MAX: ::c_int = 1; +pub const _SC_CHILD_MAX: ::c_int = 2; +pub const _SC_NGROUPS_MAX: ::c_int = 4; +pub const _SC_OPEN_MAX: ::c_int = 5; +pub const _SC_JOB_CONTROL: ::c_int = 6; +pub const _SC_SAVED_IDS: ::c_int = 7; +pub const _SC_VERSION: ::c_int = 8; +pub const _SC_BC_BASE_MAX: ::c_int = 9; +pub const _SC_BC_DIM_MAX: ::c_int = 10; +pub const _SC_BC_SCALE_MAX: ::c_int = 11; +pub const _SC_BC_STRING_MAX: ::c_int = 12; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13; +pub const _SC_EXPR_NEST_MAX: ::c_int = 14; +pub const _SC_LINE_MAX: ::c_int = 15; +pub const _SC_RE_DUP_MAX: ::c_int = 16; +pub const _SC_2_VERSION: ::c_int = 17; +pub const _SC_2_C_BIND: ::c_int = 18; +pub const _SC_2_C_DEV: ::c_int = 19; +pub const _SC_2_CHAR_TERM: ::c_int = 20; +pub const _SC_2_FORT_DEV: ::c_int = 21; +pub const _SC_2_FORT_RUN: ::c_int = 22; +pub const _SC_2_LOCALEDEF: ::c_int = 23; +pub const _SC_2_SW_DEV: ::c_int = 24; +pub const _SC_2_UPE: ::c_int = 25; +pub const _SC_STREAM_MAX: ::c_int = 26; +pub const _SC_TZNAME_MAX: ::c_int = 27; +pub const _SC_PAGESIZE: ::c_int = 28; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_FSYNC: ::c_int = 29; +pub const _SC_XOPEN_SHM: ::c_int = 30; + +pub const Q_GETQUOTA: ::c_int = 0x300; +pub const Q_SETQUOTA: ::c_int = 0x400; + +pub const RTLD_GLOBAL: ::c_int = 0x100; + +pub const LOG_NFACILITIES: ::c_int = 24; + +pub const HW_NCPU: ::c_int = 3; + +pub const B0: speed_t = 0; +pub const B50: speed_t = 50; +pub const B75: speed_t = 75; +pub const B110: speed_t = 110; +pub const B134: speed_t = 134; +pub const B150: speed_t = 150; +pub const B200: speed_t = 200; +pub const B300: speed_t = 300; +pub const B600: speed_t = 600; +pub const B1200: speed_t = 1200; +pub const B1800: speed_t = 1800; +pub const B2400: speed_t = 2400; +pub const B4800: speed_t = 4800; +pub const B9600: speed_t = 9600; +pub const B19200: speed_t = 19200; +pub const B38400: speed_t = 38400; +pub const B7200: speed_t = 7200; +pub const B14400: speed_t = 14400; +pub const B28800: speed_t = 28800; +pub const B57600: speed_t = 57600; +pub const B76800: speed_t = 76800; +pub const B115200: speed_t = 115200; +pub const B230400: speed_t = 230400; +pub const EXTA: speed_t = 19200; +pub const EXTB: speed_t = 38400; + +pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; + +pub const CRTSCTS: ::tcflag_t = 0x00010000; +pub const CRTS_IFLOW: ::tcflag_t = CRTSCTS; +pub const CCTS_OFLOW: ::tcflag_t = CRTSCTS; +pub const OCRNL: ::tcflag_t = 0x10; + +pub const TIOCEXCL: ::c_ulong = 0x2000740d; +pub const TIOCNXCL: ::c_ulong = 0x2000740e; +pub const TIOCFLUSH: ::c_ulong = 0x80047410; +pub const TIOCGETA: ::c_ulong = 0x402c7413; +pub const TIOCSETA: ::c_ulong = 0x802c7414; +pub const TIOCSETAW: ::c_ulong = 0x802c7415; +pub const TIOCSETAF: ::c_ulong = 0x802c7416; +pub const TIOCGETD: ::c_ulong = 0x4004741a; +pub const TIOCSETD: ::c_ulong = 0x8004741b; +pub const TIOCMGET: ::c_ulong = 0x4004746a; +pub const TIOCMBIC: ::c_ulong = 0x8004746b; +pub const TIOCMBIS: ::c_ulong = 0x8004746c; +pub const TIOCMSET: ::c_ulong = 0x8004746d; +pub const TIOCSTART: ::c_ulong = 0x2000746e; +pub const TIOCSTOP: ::c_ulong = 0x2000746f; +pub const TIOCSCTTY: ::c_ulong = 0x20007461; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const TIOCM_LE: ::c_int = 0o0001; +pub const TIOCM_DTR: ::c_int = 0o0002; +pub const TIOCM_RTS: ::c_int = 0o0004; +pub const TIOCM_ST: ::c_int = 0o0010; +pub const TIOCM_SR: ::c_int = 0o0020; +pub const TIOCM_CTS: ::c_int = 0o0040; +pub const TIOCM_CAR: ::c_int = 0o0100; +pub const TIOCM_RNG: ::c_int = 0o0200; +pub const TIOCM_DSR: ::c_int = 0o0400; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +// Flags for chflags(2) +pub const UF_SETTABLE: ::c_ulong = 0x0000ffff; +pub const UF_NODUMP: ::c_ulong = 0x00000001; +pub const UF_IMMUTABLE: ::c_ulong = 0x00000002; +pub const UF_APPEND: ::c_ulong = 0x00000004; +pub const UF_OPAQUE: ::c_ulong = 0x00000008; +pub const SF_SETTABLE: ::c_ulong = 0xffff0000; +pub const SF_ARCHIVED: ::c_ulong = 0x00010000; +pub const SF_IMMUTABLE: ::c_ulong = 0x00020000; +pub const SF_APPEND: ::c_ulong = 0x00040000; + +pub const TIMER_ABSTIME: ::c_int = 1; + +#[link(name = "util")] +extern "C" { + pub fn setgrent(); + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + pub fn sem_init( + sem: *mut sem_t, + pshared: ::c_int, + value: ::c_uint, + ) -> ::c_int; + + pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + pub fn mincore( + addr: *mut ::c_void, + len: ::size_t, + vec: *mut ::c_char, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__clock_getres50")] + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__clock_gettime50")] + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__clock_settime50")] + pub fn clock_settime( + clk_id: ::clockid_t, + tp: *const ::timespec, + ) -> ::c_int; + pub fn __errno() -> *mut ::c_int; + pub fn shm_open( + name: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn memrchr( + cx: *const ::c_void, + c: ::c_int, + n: ::size_t, + ) -> *mut ::c_void; + pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; + pub fn mkostemps( + template: *mut ::c_char, + suffixlen: ::c_int, + flags: ::c_int, + ) -> ::c_int; + pub fn pwritev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn preadv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn utimensat( + dirfd: ::c_int, + path: *const ::c_char, + times: *const ::timespec, + flag: ::c_int, + ) -> ::c_int; + pub fn fdatasync(fd: ::c_int) -> ::c_int; + pub fn openpty( + amaster: *mut ::c_int, + aslave: *mut ::c_int, + name: *mut ::c_char, + termp: *mut termios, + winp: *mut ::winsize, + ) -> ::c_int; + pub fn forkpty( + amaster: *mut ::c_int, + name: *mut ::c_char, + termp: *mut termios, + winp: *mut ::winsize, + ) -> ::pid_t; + pub fn login_tty(fd: ::c_int) -> ::c_int; + pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; + pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; + + pub fn mknodat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + dev: dev_t, + ) -> ::c_int; + pub fn mkfifoat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + ) -> ::c_int; + pub fn sem_timedwait( + sem: *mut sem_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + + pub fn getgrouplist( + name: *const ::c_char, + basegid: ::gid_t, + groups: *mut ::gid_t, + ngroups: *mut ::c_int, + ) -> ::c_int; + pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; + pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn uname(buf: *mut ::utsname) -> ::c_int; + + pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; + pub fn shmat( + shmid: ::c_int, + shmaddr: *const ::c_void, + shmflg: ::c_int, + ) -> *mut ::c_void; + pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; + pub fn shmctl( + shmid: ::c_int, + cmd: ::c_int, + buf: *mut ::shmid_ds, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_os = "netbsd")] { + mod netbsd; + pub use self::netbsd::*; + } else if #[cfg(target_os = "openbsd")] { + mod openbsd; + pub use self::openbsd::*; + } else { + // Unknown target_os + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/aarch64.rs new file mode 100644 index 0000000..58c4cf7 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -0,0 +1,22 @@ +use PT_FIRSTMACH; + +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = u8; +pub type __cpu_simple_lock_nv_t = ::c_uchar; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 4 - 1; + } +} + +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 2; +pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 3; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/arm.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/arm.rs new file mode 100644 index 0000000..4bf3ccd --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -0,0 +1,22 @@ +use PT_FIRSTMACH; + +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = u8; +pub type __cpu_simple_lock_nv_t = ::c_int; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/mod.rs new file mode 100644 index 0000000..422539a --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -0,0 +1,1965 @@ +pub type clock_t = ::c_uint; +pub type suseconds_t = ::c_int; +pub type dev_t = u64; +pub type blksize_t = i32; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type idtype_t = ::c_int; +pub type mqd_t = ::c_int; +type __pthread_spin_t = __cpu_simple_lock_nv_t; +pub type vm_size_t = ::uintptr_t; +pub type lwpid_t = ::c_uint; +pub type shmatt_t = ::c_uint; + +impl siginfo_t { + pub unsafe fn si_value(&self) -> ::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + __pad1: ::c_int, + _pid: ::pid_t, + _uid: ::uid_t, + value: ::sigval, + } + (*(self as *const siginfo_t as *const siginfo_timer)).value + } +} + +s! { + pub struct aiocb { + pub aio_offset: ::off_t, + pub aio_buf: *mut ::c_void, + pub aio_nbytes: ::size_t, + pub aio_fildes: ::c_int, + pub aio_lio_opcode: ::c_int, + pub aio_reqprio: ::c_int, + pub aio_sigevent: ::sigevent, + _state: ::c_int, + _errno: ::c_int, + _retval: ::ssize_t + } + + pub struct glob_t { + pub gl_pathc: ::size_t, + pub gl_matchc: ::size_t, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + pub gl_pathv: *mut *mut ::c_char, + + __unused3: *mut ::c_void, + + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + __unused6: *mut ::c_void, + __unused7: *mut ::c_void, + __unused8: *mut ::c_void, + } + + pub struct mq_attr { + pub mq_flags: ::c_long, + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_curmsgs: ::c_long, + } + + pub struct sigset_t { + __bits: [u32; 4], + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_mode: ::mode_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atimensec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtimensec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctimensec: ::c_long, + pub st_birthtime: ::time_t, + pub st_birthtimensec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: u32, + pub st_gen: u32, + pub st_spare: [u32; 2], + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: ::socklen_t, + pub ai_canonname: *mut ::c_char, + pub ai_addr: *mut ::sockaddr, + pub ai_next: *mut ::addrinfo, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + __pad1: ::c_int, + pub si_addr: *mut ::c_void, + __pad2: [u64; 13], + } + + pub struct pthread_attr_t { + pta_magic: ::c_uint, + pta_flags: ::c_int, + pta_private: *mut ::c_void, + } + + pub struct pthread_mutex_t { + ptm_magic: ::c_uint, + ptm_errorcheck: __pthread_spin_t, + #[cfg(any(target_arch = "sparc", target_arch = "sparc64", + target_arch = "x86", target_arch = "x86_64"))] + ptm_pad1: [u8; 3], + // actually a union with a non-unused, 0-initialized field + ptm_unused: __pthread_spin_t, + #[cfg(any(target_arch = "sparc", target_arch = "sparc64", + target_arch = "x86", target_arch = "x86_64"))] + ptm_pad2: [u8; 3], + ptm_owner: ::pthread_t, + ptm_waiters: *mut u8, + ptm_recursed: ::c_uint, + ptm_spare2: *mut ::c_void, + } + + pub struct pthread_mutexattr_t { + ptma_magic: ::c_uint, + ptma_private: *mut ::c_void, + } + + pub struct pthread_rwlockattr_t { + ptra_magic: ::c_uint, + ptra_private: *mut ::c_void, + } + + pub struct pthread_cond_t { + ptc_magic: ::c_uint, + ptc_lock: __pthread_spin_t, + ptc_waiters_first: *mut u8, + ptc_waiters_last: *mut u8, + ptc_mutex: *mut ::pthread_mutex_t, + ptc_private: *mut ::c_void, + } + + pub struct pthread_condattr_t { + ptca_magic: ::c_uint, + ptca_private: *mut ::c_void, + } + + pub struct pthread_rwlock_t { + ptr_magic: ::c_uint, + ptr_interlock: __pthread_spin_t, + ptr_rblocked_first: *mut u8, + ptr_rblocked_last: *mut u8, + ptr_wblocked_first: *mut u8, + ptr_wblocked_last: *mut u8, + ptr_nreaders: ::c_uint, + ptr_owner: ::pthread_t, + ptr_private: *mut ::c_void, + } + + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: u32, + pub flags: u32, + pub fflags: u32, + pub data: i64, + pub udata: ::intptr_t, + } + + pub struct dqblk { + pub dqb_bhardlimit: u32, + pub dqb_bsoftlimit: u32, + pub dqb_curblocks: u32, + pub dqb_ihardlimit: u32, + pub dqb_isoftlimit: u32, + pub dqb_curinodes: u32, + pub dqb_btime: i32, + pub dqb_itime: i32, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *const ::c_void, + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct if_data { + pub ifi_type: ::c_uchar, + pub ifi_addrlen: ::c_uchar, + pub ifi_hdrlen: ::c_uchar, + pub ifi_link_state: ::c_int, + pub ifi_mtu: u64, + pub ifi_metric: u64, + pub ifi_baudrate: u64, + pub ifi_ipackets: u64, + pub ifi_ierrors: u64, + pub ifi_opackets: u64, + pub ifi_oerrors: u64, + pub ifi_collisions: u64, + pub ifi_ibytes: u64, + pub ifi_obytes: u64, + pub ifi_imcasts: u64, + pub ifi_omcasts: u64, + pub ifi_iqdrops: u64, + pub ifi_noproto: u64, + pub ifi_lastchange: ::timespec, + } + + pub struct if_msghdr { + pub ifm_msglen: ::c_ushort, + pub ifm_version: ::c_uchar, + pub ifm_type: ::c_uchar, + pub ifm_addrs: ::c_int, + pub ifm_flags: ::c_int, + pub ifm_index: ::c_ushort, + pub ifm_data: if_data, + } + + pub struct sockcred { + pub sc_pid: ::pid_t, + pub sc_uid: ::uid_t, + pub sc_euid: ::uid_t, + pub sc_gid: ::gid_t, + pub sc_egid: ::gid_t, + pub sc_ngroups: ::c_int, + pub sc_groups: [::gid_t; 1], + } + + pub struct sockaddr_dl { + pub sdl_len: ::c_uchar, + pub sdl_family: ::c_uchar, + pub sdl_index: ::c_ushort, + pub sdl_type: u8, + pub sdl_nlen: u8, + pub sdl_alen: u8, + pub sdl_slen: u8, + pub sdl_data: [::c_char; 12], + } + + pub struct mmsghdr { + pub msg_hdr: ::msghdr, + pub msg_len: ::c_uint, + } + + pub struct __exit_status { + pub e_termination: u16, + pub e_exit: u16, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + _shm_internal: *mut ::c_void, + } + + pub struct utmp { + pub ut_line: [::c_char; UT_LINESIZE], + pub ut_name: [::c_char; UT_NAMESIZE], + pub ut_host: [::c_char; UT_HOSTSIZE], + pub ut_time: ::time_t + } + + pub struct lastlog { + pub ll_line: [::c_char; UT_LINESIZE], + pub ll_host: [::c_char; UT_HOSTSIZE], + pub ll_time: ::time_t + } +} + +s_no_extra_traits! { + + pub struct utmpx { + pub ut_name: [::c_char; _UTX_USERSIZE], + pub ut_id: [::c_char; _UTX_IDSIZE], + pub ut_line: [::c_char; _UTX_LINESIZE], + pub ut_host: [::c_char; _UTX_HOSTSIZE], + pub ut_session: u16, + pub ut_type: u16, + pub ut_pid: ::pid_t, + pub ut_exit: __exit_status, + pub ut_ss: sockaddr_storage, + pub ut_tv: ::timeval, + pub ut_pad: [u8; _UTX_PADSIZE], + } + + pub struct lastlogx { + pub ll_tv: ::timeval, + pub ll_line: [::c_char; _UTX_LINESIZE], + pub ll_host: [::c_char; _UTX_HOSTSIZE], + pub ll_ss: sockaddr_storage, + } + + pub struct in_pktinfo { + pub ipi_addr: ::in_addr, + pub ipi_ifindex: ::c_uint, + } + + #[repr(packed)] + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + #[repr(packed)] + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [i8; 8], + } + + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_reclen: u16, + pub d_namlen: u16, + pub d_type: u8, + pub d_name: [::c_char; 512], + } + + pub struct statvfs { + pub f_flag: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_iosize: ::c_ulong, + + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_bresvd: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fresvd: ::fsfilcnt_t, + + pub f_syncreads: u64, + pub f_syncwrites: u64, + + pub f_asyncreads: u64, + pub f_asyncwrites: u64, + + pub f_fsidx: ::fsid_t, + pub f_fsid: ::c_ulong, + pub f_namemax: ::c_ulong, + pub f_owner: ::uid_t, + + pub f_spare: [u32; 4], + + pub f_fstypename: [::c_char; 32], + pub f_mntonname: [::c_char; 1024], + pub f_mntfromname: [::c_char; 1024], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: ::sa_family_t, + __ss_pad1: [u8; 6], + __ss_pad2: i64, + __ss_pad3: [u8; 112], + } + + pub struct sigevent { + pub sigev_notify: ::c_int, + pub sigev_signo: ::c_int, + pub sigev_value: ::sigval, + __unused1: *mut ::c_void, //actually a function pointer + pub sigev_notify_attributes: *mut ::c_void + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self.ut_name == other.ut_name + && self.ut_line == other.ut_line + && self.ut_id == other.ut_id + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_ss == other.ut_ss + && self + .ut_pad + .iter() + .zip(other.ut_pad.iter()) + .all(|(a,b)| a == b) + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for utmpx {} + + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmpx") + .field("ut_name", &self.ut_name) + .field("ut_id", &self.ut_id) + .field("ut_line", &self.ut_line) + // FIXME .field("ut_host", &self.ut_host) + .field("ut_session", &self.ut_session) + .field("ut_type", &self.ut_type) + .field("ut_pid", &self.ut_pid) + .field("ut_exit", &self.ut_exit) + .field("ut_ss", &self.ut_ss) + .field("ut_tv", &self.ut_tv) + // FIXME .field("ut_pad", &self.ut_pad) + .finish() + } + } + + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_name.hash(state); + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_ss.hash(state); + self.ut_pad.hash(state); + } + } + + impl PartialEq for lastlogx { + fn eq(&self, other: &lastlogx) -> bool { + self.ll_tv == other.ll_tv + && self.ll_line == other.ll_line + && self.ll_ss == other.ll_ss + && self + .ll_host + .iter() + .zip(other.ll_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for lastlogx {} + + impl ::fmt::Debug for lastlogx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("lastlogx") + .field("ll_tv", &self.ll_tv) + .field("ll_line", &self.ll_line) + // FIXME.field("ll_host", &self.ll_host) + .field("ll_ss", &self.ll_ss) + .finish() + } + } + + impl ::hash::Hash for lastlogx { + fn hash(&self, state: &mut H) { + self.ll_tv.hash(state); + self.ll_line.hash(state); + self.ll_host.hash(state); + self.ll_ss.hash(state); + } + } + + impl PartialEq for in_pktinfo { + fn eq(&self, other: &in_pktinfo) -> bool { + self.ipi_addr == other.ipi_addr + && self.ipi_ifindex == other.ipi_ifindex + } + } + impl Eq for in_pktinfo {} + impl ::fmt::Debug for in_pktinfo { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("in_pktinfo") + .field("ipi_addr", &self.ipi_addr) + .field("ipi_ifindex", &self.ipi_ifindex) + .finish() + } + } + impl ::hash::Hash for in_pktinfo { + fn hash(&self, state: &mut H) { + self.ipi_addr.hash(state); + self.ipi_ifindex.hash(state); + } + } + + impl PartialEq for arphdr { + fn eq(&self, other: &arphdr) -> bool { + self.ar_hrd == other.ar_hrd + && self.ar_pro == other.ar_pro + && self.ar_hln == other.ar_hln + && self.ar_pln == other.ar_pln + && self.ar_op == other.ar_op + } + } + impl Eq for arphdr {} + impl ::fmt::Debug for arphdr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let ar_hrd = self.ar_hrd; + let ar_pro = self.ar_pro; + let ar_op = self.ar_op; + f.debug_struct("arphdr") + .field("ar_hrd", &ar_hrd) + .field("ar_pro", &ar_pro) + .field("ar_hln", &self.ar_hln) + .field("ar_pln", &self.ar_pln) + .field("ar_op", &ar_op) + .finish() + } + } + impl ::hash::Hash for arphdr { + fn hash(&self, state: &mut H) { + let ar_hrd = self.ar_hrd; + let ar_pro = self.ar_pro; + let ar_op = self.ar_op; + ar_hrd.hash(state); + ar_pro.hash(state); + self.ar_hln.hash(state); + self.ar_pln.hash(state); + ar_op.hash(state); + } + } + + impl PartialEq for in_addr { + fn eq(&self, other: &in_addr) -> bool { + self.s_addr == other.s_addr + } + } + impl Eq for in_addr {} + impl ::fmt::Debug for in_addr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let s_addr = self.s_addr; + f.debug_struct("in_addr") + .field("s_addr", &s_addr) + .finish() + } + } + impl ::hash::Hash for in_addr { + fn hash(&self, state: &mut H) { + let s_addr = self.s_addr; + s_addr.hash(state); + } + } + + impl PartialEq for ip_mreq { + fn eq(&self, other: &ip_mreq) -> bool { + self.imr_multiaddr == other.imr_multiaddr + && self.imr_interface == other.imr_interface + } + } + impl Eq for ip_mreq {} + impl ::fmt::Debug for ip_mreq { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ip_mreq") + .field("imr_multiaddr", &self.imr_multiaddr) + .field("imr_interface", &self.imr_interface) + .finish() + } + } + impl ::hash::Hash for ip_mreq { + fn hash(&self, state: &mut H) { + self.imr_multiaddr.hash(state); + self.imr_interface.hash(state); + } + } + + impl PartialEq for sockaddr_in { + fn eq(&self, other: &sockaddr_in) -> bool { + self.sin_len == other.sin_len + && self.sin_family == other.sin_family + && self.sin_port == other.sin_port + && self.sin_addr == other.sin_addr + && self.sin_zero == other.sin_zero + } + } + impl Eq for sockaddr_in {} + impl ::fmt::Debug for sockaddr_in { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_in") + .field("sin_len", &self.sin_len) + .field("sin_family", &self.sin_family) + .field("sin_port", &self.sin_port) + .field("sin_addr", &self.sin_addr) + .field("sin_zero", &self.sin_zero) + .finish() + } + } + impl ::hash::Hash for sockaddr_in { + fn hash(&self, state: &mut H) { + self.sin_len.hash(state); + self.sin_family.hash(state); + self.sin_port.hash(state); + self.sin_addr.hash(state); + self.sin_zero.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_fileno == other.d_fileno + && self.d_reclen == other.d_reclen + && self.d_namlen == other.d_namlen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_fileno", &self.d_fileno) + .field("d_reclen", &self.d_reclen) + .field("d_namlen", &self.d_namlen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_fileno.hash(state); + self.d_reclen.hash(state); + self.d_namlen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for statvfs { + fn eq(&self, other: &statvfs) -> bool { + self.f_flag == other.f_flag + && self.f_bsize == other.f_bsize + && self.f_frsize == other.f_frsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_bresvd == other.f_bresvd + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_favail == other.f_favail + && self.f_fresvd == other.f_fresvd + && self.f_syncreads == other.f_syncreads + && self.f_syncwrites == other.f_syncwrites + && self.f_asyncreads == other.f_asyncreads + && self.f_asyncwrites == other.f_asyncwrites + && self.f_fsidx == other.f_fsidx + && self.f_fsid == other.f_fsid + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_spare == other.f_spare + && self.f_fstypename == other.f_fstypename + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for statvfs {} + impl ::fmt::Debug for statvfs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("statvfs") + .field("f_flag", &self.f_flag) + .field("f_bsize", &self.f_bsize) + .field("f_frsize", &self.f_frsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_bresvd", &self.f_bresvd) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_favail", &self.f_favail) + .field("f_fresvd", &self.f_fresvd) + .field("f_syncreads", &self.f_syncreads) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_fsidx", &self.f_fsidx) + .field("f_fsid", &self.f_fsid) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_spare", &self.f_spare) + .field("f_fstypename", &self.f_fstypename) + // FIXME: .field("f_mntonname", &self.f_mntonname) + // FIXME: .field("f_mntfromname", &self.f_mntfromname) + .finish() + } + } + impl ::hash::Hash for statvfs { + fn hash(&self, state: &mut H) { + self.f_flag.hash(state); + self.f_bsize.hash(state); + self.f_frsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_bresvd.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_favail.hash(state); + self.f_fresvd.hash(state); + self.f_syncreads.hash(state); + self.f_syncwrites.hash(state); + self.f_asyncreads.hash(state); + self.f_asyncwrites.hash(state); + self.f_fsidx.hash(state); + self.f_fsid.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_spare.hash(state); + self.f_fstypename.hash(state); + self.f_mntonname.hash(state); + self.f_mntfromname.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_len == other.ss_len + && self.ss_family == other.ss_family + && self.__ss_pad1 == other.__ss_pad1 + && self.__ss_pad2 == other.__ss_pad2 + && self + .__ss_pad3 + .iter() + .zip(other.__ss_pad3.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sockaddr_storage {} + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_len", &self.ss_len) + .field("ss_family", &self.ss_family) + .field("__ss_pad1", &self.__ss_pad1) + .field("__ss_pad2", &self.__ss_pad2) + // FIXME: .field("__ss_pad3", &self.__ss_pad3) + .finish() + } + } + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_len.hash(state); + self.ss_family.hash(state); + self.__ss_pad1.hash(state); + self.__ss_pad2.hash(state); + self.__ss_pad3.hash(state); + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_notify == other.sigev_notify + && self.sigev_signo == other.sigev_signo + && self.sigev_value == other.sigev_value + && self.sigev_notify_attributes + == other.sigev_notify_attributes + } + } + impl Eq for sigevent {} + impl ::fmt::Debug for sigevent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sigevent") + .field("sigev_notify", &self.sigev_notify) + .field("sigev_signo", &self.sigev_signo) + .field("sigev_value", &self.sigev_value) + .field("sigev_notify_attributes", + &self.sigev_notify_attributes) + .finish() + } + } + impl ::hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_notify.hash(state); + self.sigev_signo.hash(state); + self.sigev_value.hash(state); + self.sigev_notify_attributes.hash(state); + } + } + } +} + +pub const AT_FDCWD: ::c_int = -100; +pub const AT_EACCESS: ::c_int = 0x100; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; +pub const AT_REMOVEDIR: ::c_int = 0x800; + +pub const EXTATTR_NAMESPACE_USER: ::c_int = 1; +pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2; + +pub const LC_COLLATE_MASK: ::c_int = (1 << ::LC_COLLATE); +pub const LC_CTYPE_MASK: ::c_int = (1 << ::LC_CTYPE); +pub const LC_MONETARY_MASK: ::c_int = (1 << ::LC_MONETARY); +pub const LC_NUMERIC_MASK: ::c_int = (1 << ::LC_NUMERIC); +pub const LC_TIME_MASK: ::c_int = (1 << ::LC_TIME); +pub const LC_MESSAGES_MASK: ::c_int = (1 << ::LC_MESSAGES); +pub const LC_ALL_MASK: ::c_int = !0; + +pub const ERA: ::nl_item = 52; +pub const ERA_D_FMT: ::nl_item = 53; +pub const ERA_D_T_FMT: ::nl_item = 54; +pub const ERA_T_FMT: ::nl_item = 55; +pub const ALT_DIGITS: ::nl_item = 56; + +pub const O_CLOEXEC: ::c_int = 0x400000; +pub const O_ALT_IO: ::c_int = 0x40000; +pub const O_NOSIGPIPE: ::c_int = 0x1000000; +pub const O_SEARCH: ::c_int = 0x800000; +pub const O_DIRECTORY: ::c_int = 0x200000; +pub const O_DIRECT: ::c_int = 0x00080000; +pub const O_RSYNC: ::c_int = 0x00020000; + +pub const MS_SYNC: ::c_int = 0x4; +pub const MS_INVALIDATE: ::c_int = 0x2; + +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: ::c_int = 12; + +pub const EIDRM: ::c_int = 82; +pub const ENOMSG: ::c_int = 83; +pub const EOVERFLOW: ::c_int = 84; +pub const EILSEQ: ::c_int = 85; +pub const ENOTSUP: ::c_int = 86; +pub const ECANCELED: ::c_int = 87; +pub const EBADMSG: ::c_int = 88; +pub const ENODATA: ::c_int = 89; +pub const ENOSR: ::c_int = 90; +pub const ENOSTR: ::c_int = 91; +pub const ETIME: ::c_int = 92; +pub const ENOATTR: ::c_int = 93; +pub const EMULTIHOP: ::c_int = 94; +pub const ENOLINK: ::c_int = 95; +pub const EPROTO: ::c_int = 96; +pub const ELAST: ::c_int = 96; + +pub const F_DUPFD_CLOEXEC: ::c_int = 12; +pub const F_CLOSEM: ::c_int = 10; +pub const F_GETNOSIGPIPE: ::c_int = 13; +pub const F_SETNOSIGPIPE: ::c_int = 14; +pub const F_MAXFD: ::c_int = 11; + +pub const IP_RECVDSTADDR: ::c_int = 7; +pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR; +pub const IP_RECVIF: ::c_int = 20; +pub const IP_PKTINFO: ::c_int = 25; +pub const IP_RECVPKTINFO: ::c_int = 26; +pub const IPV6_JOIN_GROUP: ::c_int = 12; +pub const IPV6_LEAVE_GROUP: ::c_int = 13; + +pub const TCP_KEEPIDLE: ::c_int = 3; +pub const TCP_KEEPINTVL: ::c_int = 5; +pub const TCP_KEEPCNT: ::c_int = 6; +pub const TCP_KEEPINIT: ::c_int = 7; +pub const TCP_INFO: ::c_int = 9; +pub const TCP_MD5SIG: ::c_int = 0x10; +pub const TCP_CONGCTL: ::c_int = 0x20; + +pub const SOCK_CONN_DGRAM: ::c_int = 6; +pub const SOCK_DCCP: ::c_int = SOCK_CONN_DGRAM; +pub const SOCK_NOSIGPIPE: ::c_int = 0x40000000; +pub const SOCK_FLAGS_MASK: ::c_int = 0xf0000000; + +pub const SO_SNDTIMEO: ::c_int = 0x100b; +pub const SO_RCVTIMEO: ::c_int = 0x100c; +pub const SO_ACCEPTFILTER: ::c_int = 0x1000; +pub const SO_TIMESTAMP: ::c_int = 0x2000; +pub const SO_OVERFLOWED: ::c_int = 0x1009; +pub const SO_NOHEADER: ::c_int = 0x100a; + +// https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373 +pub const IFF_UP: ::c_int = 0x0001; // interface is up +pub const IFF_BROADCAST: ::c_int = 0x0002; // broadcast address valid +pub const IFF_DEBUG: ::c_int = 0x0004; // turn on debugging +pub const IFF_LOOPBACK: ::c_int = 0x0008; // is a loopback net +pub const IFF_POINTOPOINT: ::c_int = 0x0010; // interface is point-to-point link +pub const IFF_NOTRAILERS: ::c_int = 0x0020; // avoid use of trailers +pub const IFF_RUNNING: ::c_int = 0x0040; // resources allocated +pub const IFF_NOARP: ::c_int = 0x0080; // no address resolution protocol +pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets +pub const IFF_OACTIVE: ::c_int = 0x0400; // transmission in progress +pub const IFF_SIMPLEX: ::c_int = 0x0800; // can't hear own transmissions +pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit +pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast + +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// Hop-by-hop option header +pub const IPPROTO_HOPOPTS: ::c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: ::c_int = 2; +/// gateway^2 (deprecated) +pub const IPPROTO_GGP: ::c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: ::c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// exterior gateway protocol +pub const IPPROTO_EGP: ::c_int = 8; +/// pup +pub const IPPROTO_PUP: ::c_int = 12; +// IPPROTO_UDP defined in src/unix/mod.rs +/// xns idp +pub const IPPROTO_IDP: ::c_int = 22; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: ::c_int = 29; +/// DCCP +pub const IPPROTO_DCCP: ::c_int = 33; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// IP6 routing header +pub const IPPROTO_ROUTING: ::c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: ::c_int = 44; +/// resource reservation +pub const IPPROTO_RSVP: ::c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: ::c_int = 47; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: ::c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: ::c_int = 51; +/// IP Mobility RFC 2004 +pub const IPPROTO_MOBILE: ::c_int = 55; +/// IPv6 ICMP +pub const IPPROTO_IPV6_ICMP: ::c_int = 58; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: ::c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: ::c_int = 60; +/// ISO cnlp +pub const IPPROTO_EON: ::c_int = 80; +/// Ethernet-in-IP +pub const IPPROTO_ETHERIP: ::c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: ::c_int = 98; +/// Protocol indep. multicast +pub const IPPROTO_PIM: ::c_int = 103; +/// IP Payload Comp. Protocol +pub const IPPROTO_IPCOMP: ::c_int = 108; +/// VRRP RFC 2338 +pub const IPPROTO_VRRP: ::c_int = 112; +/// Common Address Resolution Protocol +pub const IPPROTO_CARP: ::c_int = 112; +/// L2TPv3 +// TEMP: Disabled for now; this constant was added to NetBSD on 2017-02-16, +// but isn't yet supported by the NetBSD rumprun kernel image used for +// libc testing. +//pub const IPPROTO_L2TP: ::c_int = 115; +/// SCTP +pub const IPPROTO_SCTP: ::c_int = 132; +/// PFSYNC +pub const IPPROTO_PFSYNC: ::c_int = 240; +pub const IPPROTO_MAX: ::c_int = 256; + +/// last return value of *_input(), meaning "all job for this pkt is done". +pub const IPPROTO_DONE: ::c_int = 257; + +/// sysctl placeholder for (FAST_)IPSEC +pub const CTL_IPPROTO_IPSEC: ::c_int = 258; + +pub const AF_OROUTE: ::c_int = 17; +pub const AF_ARP: ::c_int = 28; +pub const pseudo_AF_KEY: ::c_int = 29; +pub const pseudo_AF_HDRCMPLT: ::c_int = 30; +pub const AF_BLUETOOTH: ::c_int = 31; +pub const AF_IEEE80211: ::c_int = 32; +pub const AF_MPLS: ::c_int = 33; +pub const AF_ROUTE: ::c_int = 34; +pub const NET_RT_DUMP: ::c_int = 1; +pub const NET_RT_FLAGS: ::c_int = 2; +pub const NET_RT_OOOIFLIST: ::c_int = 3; +pub const NET_RT_OOIFLIST: ::c_int = 4; +pub const NET_RT_OIFLIST: ::c_int = 5; +pub const NET_RT_IFLIST: ::c_int = 6; +pub const NET_RT_MAXID: ::c_int = 7; + +pub const PF_OROUTE: ::c_int = AF_OROUTE; +pub const PF_ARP: ::c_int = AF_ARP; +pub const PF_KEY: ::c_int = pseudo_AF_KEY; +pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; +pub const PF_MPLS: ::c_int = AF_MPLS; +pub const PF_ROUTE: ::c_int = AF_ROUTE; + +pub const MSG_NBIO: ::c_int = 0x1000; +pub const MSG_WAITFORONE: ::c_int = 0x2000; +pub const MSG_NOTIFICATION: ::c_int = 0x4000; + +pub const SCM_TIMESTAMP: ::c_int = 0x08; +pub const SCM_CREDS: ::c_int = 0x10; + +pub const O_DSYNC: ::c_int = 0x10000; + +pub const MAP_RENAME: ::c_int = 0x20; +pub const MAP_NORESERVE: ::c_int = 0x40; +pub const MAP_HASSEMAPHORE: ::c_int = 0x200; +pub const MAP_WIRED: ::c_int = 0x800; + +pub const DCCP_TYPE_REQUEST: ::c_int = 0; +pub const DCCP_TYPE_RESPONSE: ::c_int = 1; +pub const DCCP_TYPE_DATA: ::c_int = 2; +pub const DCCP_TYPE_ACK: ::c_int = 3; +pub const DCCP_TYPE_DATAACK: ::c_int = 4; +pub const DCCP_TYPE_CLOSEREQ: ::c_int = 5; +pub const DCCP_TYPE_CLOSE: ::c_int = 6; +pub const DCCP_TYPE_RESET: ::c_int = 7; +pub const DCCP_TYPE_MOVE: ::c_int = 8; + +pub const DCCP_FEATURE_CC: ::c_int = 1; +pub const DCCP_FEATURE_ECN: ::c_int = 2; +pub const DCCP_FEATURE_ACKRATIO: ::c_int = 3; +pub const DCCP_FEATURE_ACKVECTOR: ::c_int = 4; +pub const DCCP_FEATURE_MOBILITY: ::c_int = 5; +pub const DCCP_FEATURE_LOSSWINDOW: ::c_int = 6; +pub const DCCP_FEATURE_CONN_NONCE: ::c_int = 8; +pub const DCCP_FEATURE_IDENTREG: ::c_int = 7; + +pub const DCCP_OPT_PADDING: ::c_int = 0; +pub const DCCP_OPT_DATA_DISCARD: ::c_int = 1; +pub const DCCP_OPT_SLOW_RECV: ::c_int = 2; +pub const DCCP_OPT_BUF_CLOSED: ::c_int = 3; +pub const DCCP_OPT_CHANGE_L: ::c_int = 32; +pub const DCCP_OPT_CONFIRM_L: ::c_int = 33; +pub const DCCP_OPT_CHANGE_R: ::c_int = 34; +pub const DCCP_OPT_CONFIRM_R: ::c_int = 35; +pub const DCCP_OPT_INIT_COOKIE: ::c_int = 36; +pub const DCCP_OPT_NDP_COUNT: ::c_int = 37; +pub const DCCP_OPT_ACK_VECTOR0: ::c_int = 38; +pub const DCCP_OPT_ACK_VECTOR1: ::c_int = 39; +pub const DCCP_OPT_RECV_BUF_DROPS: ::c_int = 40; +pub const DCCP_OPT_TIMESTAMP: ::c_int = 41; +pub const DCCP_OPT_TIMESTAMP_ECHO: ::c_int = 42; +pub const DCCP_OPT_ELAPSEDTIME: ::c_int = 43; +pub const DCCP_OPT_DATACHECKSUM: ::c_int = 44; + +pub const DCCP_REASON_UNSPEC: ::c_int = 0; +pub const DCCP_REASON_CLOSED: ::c_int = 1; +pub const DCCP_REASON_INVALID: ::c_int = 2; +pub const DCCP_REASON_OPTION_ERR: ::c_int = 3; +pub const DCCP_REASON_FEA_ERR: ::c_int = 4; +pub const DCCP_REASON_CONN_REF: ::c_int = 5; +pub const DCCP_REASON_BAD_SNAME: ::c_int = 6; +pub const DCCP_REASON_BAD_COOKIE: ::c_int = 7; +pub const DCCP_REASON_INV_MOVE: ::c_int = 8; +pub const DCCP_REASON_UNANSW_CH: ::c_int = 10; +pub const DCCP_REASON_FRUITLESS_NEG: ::c_int = 11; + +pub const DCCP_CCID: ::c_int = 1; +pub const DCCP_CSLEN: ::c_int = 2; +pub const DCCP_MAXSEG: ::c_int = 4; +pub const DCCP_SERVICE: ::c_int = 8; + +pub const DCCP_NDP_LIMIT: ::c_int = 16; +pub const DCCP_SEQ_NUM_LIMIT: ::c_int = 16777216; +pub const DCCP_MAX_OPTIONS: ::c_int = 32; +pub const DCCP_MAX_PKTS: ::c_int = 100; + +pub const _PC_LINK_MAX: ::c_int = 1; +pub const _PC_MAX_CANON: ::c_int = 2; +pub const _PC_MAX_INPUT: ::c_int = 3; +pub const _PC_NAME_MAX: ::c_int = 4; +pub const _PC_PATH_MAX: ::c_int = 5; +pub const _PC_PIPE_BUF: ::c_int = 6; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 7; +pub const _PC_NO_TRUNC: ::c_int = 8; +pub const _PC_VDISABLE: ::c_int = 9; +pub const _PC_SYNC_IO: ::c_int = 10; +pub const _PC_FILESIZEBITS: ::c_int = 11; +pub const _PC_SYMLINK_MAX: ::c_int = 12; +pub const _PC_2_SYMLINKS: ::c_int = 13; +pub const _PC_ACL_EXTENDED: ::c_int = 14; +pub const _PC_MIN_HOLE_SIZE: ::c_int = 15; + +pub const _SC_SYNCHRONIZED_IO: ::c_int = 31; +pub const _SC_IOV_MAX: ::c_int = 32; +pub const _SC_MAPPED_FILES: ::c_int = 33; +pub const _SC_MEMLOCK: ::c_int = 34; +pub const _SC_MEMLOCK_RANGE: ::c_int = 35; +pub const _SC_MEMORY_PROTECTION: ::c_int = 36; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 37; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 38; +pub const _SC_CLK_TCK: ::c_int = 39; +pub const _SC_ATEXIT_MAX: ::c_int = 40; +pub const _SC_THREADS: ::c_int = 41; +pub const _SC_SEMAPHORES: ::c_int = 42; +pub const _SC_BARRIERS: ::c_int = 43; +pub const _SC_TIMERS: ::c_int = 44; +pub const _SC_SPIN_LOCKS: ::c_int = 45; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 46; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 47; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 48; +pub const _SC_CLOCK_SELECTION: ::c_int = 49; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 50; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 51; +pub const _SC_AIO_MAX: ::c_int = 52; +pub const _SC_MESSAGE_PASSING: ::c_int = 53; +pub const _SC_MQ_OPEN_MAX: ::c_int = 54; +pub const _SC_MQ_PRIO_MAX: ::c_int = 55; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 56; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 57; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 58; +pub const _SC_THREAD_STACK_MIN: ::c_int = 59; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 60; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 61; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 62; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 63; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 64; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 65; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 66; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 67; +pub const _SC_TTY_NAME_MAX: ::c_int = 68; +pub const _SC_HOST_NAME_MAX: ::c_int = 69; +pub const _SC_PASS_MAX: ::c_int = 70; +pub const _SC_REGEXP: ::c_int = 71; +pub const _SC_SHELL: ::c_int = 72; +pub const _SC_SYMLOOP_MAX: ::c_int = 73; +pub const _SC_V6_ILP32_OFF32: ::c_int = 74; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = 75; +pub const _SC_V6_LP64_OFF64: ::c_int = 76; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 77; +pub const _SC_2_PBS: ::c_int = 80; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 81; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 82; +pub const _SC_2_PBS_LOCATE: ::c_int = 83; +pub const _SC_2_PBS_MESSAGE: ::c_int = 84; +pub const _SC_2_PBS_TRACK: ::c_int = 85; +pub const _SC_SPAWN: ::c_int = 86; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 87; +pub const _SC_TIMER_MAX: ::c_int = 88; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 89; +pub const _SC_CPUTIME: ::c_int = 90; +pub const _SC_THREAD_CPUTIME: ::c_int = 91; +pub const _SC_DELAYTIMER_MAX: ::c_int = 92; +// These two variables will be supported in NetBSD 8.0 +// pub const _SC_SIGQUEUE_MAX : ::c_int = 93; +// pub const _SC_REALTIME_SIGNALS : ::c_int = 94; +pub const _SC_PHYS_PAGES: ::c_int = 121; +pub const _SC_NPROCESSORS_CONF: ::c_int = 1001; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 1002; +pub const _SC_SCHED_RT_TS: ::c_int = 2001; +pub const _SC_SCHED_PRI_MIN: ::c_int = 2002; +pub const _SC_SCHED_PRI_MAX: ::c_int = 2003; + +pub const FD_SETSIZE: usize = 0x100; + +pub const ST_NOSUID: ::c_ulong = 8; + +pub const BIOCGRSIG: ::c_ulong = 0x40044272; +pub const BIOCSRSIG: ::c_ulong = 0x80044273; +pub const BIOCSDLT: ::c_ulong = 0x80044278; +pub const BIOCGSEESENT: ::c_ulong = 0x40044276; +pub const BIOCSSEESENT: ::c_ulong = 0x80044277; + +cfg_if! { + if #[cfg(any(target_arch = "sparc", target_arch = "sparc64", + target_arch = "x86", target_arch = "x86_64"))] { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t + = pthread_mutex_t { + ptm_magic: 0x33330003, + ptm_errorcheck: 0, + ptm_pad1: [0; 3], + ptm_unused: 0, + ptm_pad2: [0; 3], + ptm_waiters: 0 as *mut _, + ptm_owner: 0, + ptm_recursed: 0, + ptm_spare2: 0 as *mut _, + }; + } else { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t + = pthread_mutex_t { + ptm_magic: 0x33330003, + ptm_errorcheck: 0, + ptm_unused: 0, + ptm_waiters: 0 as *mut _, + ptm_owner: 0, + ptm_recursed: 0, + ptm_spare2: 0 as *mut _, + }; + } +} + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + ptc_magic: 0x55550005, + ptc_lock: 0, + ptc_waiters_first: 0 as *mut _, + ptc_waiters_last: 0 as *mut _, + ptc_mutex: 0 as *mut _, + ptc_private: 0 as *mut _, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + ptr_magic: 0x99990009, + ptr_interlock: 0, + ptr_rblocked_first: 0 as *mut _, + ptr_rblocked_last: 0 as *mut _, + ptr_wblocked_first: 0 as *mut _, + ptr_wblocked_last: 0 as *mut _, + ptr_nreaders: 0, + ptr_owner: 0, + ptr_private: 0 as *mut _, +}; +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; + +pub const EVFILT_AIO: u32 = 2; +pub const EVFILT_PROC: u32 = 4; +pub const EVFILT_READ: u32 = 0; +pub const EVFILT_SIGNAL: u32 = 5; +pub const EVFILT_TIMER: u32 = 6; +pub const EVFILT_VNODE: u32 = 3; +pub const EVFILT_WRITE: u32 = 1; + +pub const EV_ADD: u32 = 0x1; +pub const EV_DELETE: u32 = 0x2; +pub const EV_ENABLE: u32 = 0x4; +pub const EV_DISABLE: u32 = 0x8; +pub const EV_ONESHOT: u32 = 0x10; +pub const EV_CLEAR: u32 = 0x20; +pub const EV_RECEIPT: u32 = 0x40; +pub const EV_DISPATCH: u32 = 0x80; +pub const EV_FLAG1: u32 = 0x2000; +pub const EV_ERROR: u32 = 0x4000; +pub const EV_EOF: u32 = 0x8000; +pub const EV_SYSFLAGS: u32 = 0xf000; + +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; + +pub const TMP_MAX: ::c_uint = 308915776; + +pub const NI_MAXHOST: ::socklen_t = 1025; + +pub const RTLD_NOLOAD: ::c_int = 0x2000; +pub const RTLD_LOCAL: ::c_int = 0x200; + +pub const CTL_MAXNAME: ::c_int = 12; +pub const SYSCTL_NAMELEN: ::c_int = 32; +pub const SYSCTL_DEFSIZE: ::c_int = 8; +pub const CTLTYPE_NODE: ::c_int = 1; +pub const CTLTYPE_INT: ::c_int = 2; +pub const CTLTYPE_STRING: ::c_int = 3; +pub const CTLTYPE_QUAD: ::c_int = 4; +pub const CTLTYPE_STRUCT: ::c_int = 5; +pub const CTLTYPE_BOOL: ::c_int = 6; +pub const CTLFLAG_READONLY: ::c_int = 0x00000000; +pub const CTLFLAG_READWRITE: ::c_int = 0x00000070; +pub const CTLFLAG_ANYWRITE: ::c_int = 0x00000080; +pub const CTLFLAG_PRIVATE: ::c_int = 0x00000100; +pub const CTLFLAG_PERMANENT: ::c_int = 0x00000200; +pub const CTLFLAG_OWNDATA: ::c_int = 0x00000400; +pub const CTLFLAG_IMMEDIATE: ::c_int = 0x00000800; +pub const CTLFLAG_HEX: ::c_int = 0x00001000; +pub const CTLFLAG_ROOT: ::c_int = 0x00002000; +pub const CTLFLAG_ANYNUMBER: ::c_int = 0x00004000; +pub const CTLFLAG_HIDDEN: ::c_int = 0x00008000; +pub const CTLFLAG_ALIAS: ::c_int = 0x00010000; +pub const CTLFLAG_MMAP: ::c_int = 0x00020000; +pub const CTLFLAG_OWNDESC: ::c_int = 0x00040000; +pub const CTLFLAG_UNSIGNED: ::c_int = 0x00080000; +pub const SYSCTL_VERS_MASK: ::c_int = 0xff000000; +pub const SYSCTL_VERS_0: ::c_int = 0x00000000; +pub const SYSCTL_VERS_1: ::c_int = 0x01000000; +pub const SYSCTL_VERSION: ::c_int = SYSCTL_VERS_1; +pub const CTL_EOL: ::c_int = -1; +pub const CTL_QUERY: ::c_int = -2; +pub const CTL_CREATE: ::c_int = -3; +pub const CTL_CREATESYM: ::c_int = -4; +pub const CTL_DESTROY: ::c_int = -5; +pub const CTL_MMAP: ::c_int = -6; +pub const CTL_DESCRIBE: ::c_int = -7; +pub const CTL_UNSPEC: ::c_int = 0; +pub const CTL_KERN: ::c_int = 1; +pub const CTL_VM: ::c_int = 2; +pub const CTL_VFS: ::c_int = 3; +pub const CTL_NET: ::c_int = 4; +pub const CTL_DEBUG: ::c_int = 5; +pub const CTL_HW: ::c_int = 6; +pub const CTL_MACHDEP: ::c_int = 7; +pub const CTL_USER: ::c_int = 8; +pub const CTL_DDB: ::c_int = 9; +pub const CTL_PROC: ::c_int = 10; +pub const CTL_VENDOR: ::c_int = 11; +pub const CTL_EMUL: ::c_int = 12; +pub const CTL_SECURITY: ::c_int = 13; +pub const CTL_MAXID: ::c_int = 14; +pub const KERN_OSTYPE: ::c_int = 1; +pub const KERN_OSRELEASE: ::c_int = 2; +pub const KERN_OSREV: ::c_int = 3; +pub const KERN_VERSION: ::c_int = 4; +pub const KERN_MAXVNODES: ::c_int = 5; +pub const KERN_MAXPROC: ::c_int = 6; +pub const KERN_MAXFILES: ::c_int = 7; +pub const KERN_ARGMAX: ::c_int = 8; +pub const KERN_SECURELVL: ::c_int = 9; +pub const KERN_HOSTNAME: ::c_int = 10; +pub const KERN_HOSTID: ::c_int = 11; +pub const KERN_CLOCKRATE: ::c_int = 12; +pub const KERN_VNODE: ::c_int = 13; +pub const KERN_PROC: ::c_int = 14; +pub const KERN_FILE: ::c_int = 15; +pub const KERN_PROF: ::c_int = 16; +pub const KERN_POSIX1: ::c_int = 17; +pub const KERN_NGROUPS: ::c_int = 18; +pub const KERN_JOB_CONTROL: ::c_int = 19; +pub const KERN_SAVED_IDS: ::c_int = 20; +pub const KERN_OBOOTTIME: ::c_int = 21; +pub const KERN_DOMAINNAME: ::c_int = 22; +pub const KERN_MAXPARTITIONS: ::c_int = 23; +pub const KERN_RAWPARTITION: ::c_int = 24; +pub const KERN_NTPTIME: ::c_int = 25; +pub const KERN_TIMEX: ::c_int = 26; +pub const KERN_AUTONICETIME: ::c_int = 27; +pub const KERN_AUTONICEVAL: ::c_int = 28; +pub const KERN_RTC_OFFSET: ::c_int = 29; +pub const KERN_ROOT_DEVICE: ::c_int = 30; +pub const KERN_MSGBUFSIZE: ::c_int = 31; +pub const KERN_FSYNC: ::c_int = 32; +pub const KERN_OLDSYSVMSG: ::c_int = 33; +pub const KERN_OLDSYSVSEM: ::c_int = 34; +pub const KERN_OLDSYSVSHM: ::c_int = 35; +pub const KERN_OLDSHORTCORENAME: ::c_int = 36; +pub const KERN_SYNCHRONIZED_IO: ::c_int = 37; +pub const KERN_IOV_MAX: ::c_int = 38; +pub const KERN_MBUF: ::c_int = 39; +pub const KERN_MAPPED_FILES: ::c_int = 40; +pub const KERN_MEMLOCK: ::c_int = 41; +pub const KERN_MEMLOCK_RANGE: ::c_int = 42; +pub const KERN_MEMORY_PROTECTION: ::c_int = 43; +pub const KERN_LOGIN_NAME_MAX: ::c_int = 44; +pub const KERN_DEFCORENAME: ::c_int = 45; +pub const KERN_LOGSIGEXIT: ::c_int = 46; +pub const KERN_PROC2: ::c_int = 47; +pub const KERN_PROC_ARGS: ::c_int = 48; +pub const KERN_FSCALE: ::c_int = 49; +pub const KERN_CCPU: ::c_int = 50; +pub const KERN_CP_TIME: ::c_int = 51; +pub const KERN_OLDSYSVIPC_INFO: ::c_int = 52; +pub const KERN_MSGBUF: ::c_int = 53; +pub const KERN_CONSDEV: ::c_int = 54; +pub const KERN_MAXPTYS: ::c_int = 55; +pub const KERN_PIPE: ::c_int = 56; +pub const KERN_MAXPHYS: ::c_int = 57; +pub const KERN_SBMAX: ::c_int = 58; +pub const KERN_TKSTAT: ::c_int = 59; +pub const KERN_MONOTONIC_CLOCK: ::c_int = 60; +pub const KERN_URND: ::c_int = 61; +pub const KERN_LABELSECTOR: ::c_int = 62; +pub const KERN_LABELOFFSET: ::c_int = 63; +pub const KERN_LWP: ::c_int = 64; +pub const KERN_FORKFSLEEP: ::c_int = 65; +pub const KERN_POSIX_THREADS: ::c_int = 66; +pub const KERN_POSIX_SEMAPHORES: ::c_int = 67; +pub const KERN_POSIX_BARRIERS: ::c_int = 68; +pub const KERN_POSIX_TIMERS: ::c_int = 69; +pub const KERN_POSIX_SPIN_LOCKS: ::c_int = 70; +pub const KERN_POSIX_READER_WRITER_LOCKS: ::c_int = 71; +pub const KERN_DUMP_ON_PANIC: ::c_int = 72; +pub const KERN_SOMAXKVA: ::c_int = 73; +pub const KERN_ROOT_PARTITION: ::c_int = 74; +pub const KERN_DRIVERS: ::c_int = 75; +pub const KERN_BUF: ::c_int = 76; +pub const KERN_FILE2: ::c_int = 77; +pub const KERN_VERIEXEC: ::c_int = 78; +pub const KERN_CP_ID: ::c_int = 79; +pub const KERN_HARDCLOCK_TICKS: ::c_int = 80; +pub const KERN_ARND: ::c_int = 81; +pub const KERN_SYSVIPC: ::c_int = 82; +pub const KERN_BOOTTIME: ::c_int = 83; +pub const KERN_EVCNT: ::c_int = 84; +pub const KERN_MAXID: ::c_int = 85; +pub const KERN_PROC_ALL: ::c_int = 0; +pub const KERN_PROC_PID: ::c_int = 1; +pub const KERN_PROC_PGRP: ::c_int = 2; +pub const KERN_PROC_SESSION: ::c_int = 3; +pub const KERN_PROC_TTY: ::c_int = 4; +pub const KERN_PROC_UID: ::c_int = 5; +pub const KERN_PROC_RUID: ::c_int = 6; +pub const KERN_PROC_GID: ::c_int = 7; +pub const KERN_PROC_RGID: ::c_int = 8; +pub const KERN_PROC_ARGV: ::c_int = 1; +pub const KERN_PROC_NARGV: ::c_int = 2; +pub const KERN_PROC_ENV: ::c_int = 3; +pub const KERN_PROC_NENV: ::c_int = 4; +pub const KERN_PROC_PATHNAME: ::c_int = 5; + +pub const EAI_AGAIN: ::c_int = 2; +pub const EAI_BADFLAGS: ::c_int = 3; +pub const EAI_FAIL: ::c_int = 4; +pub const EAI_FAMILY: ::c_int = 5; +pub const EAI_MEMORY: ::c_int = 6; +pub const EAI_NODATA: ::c_int = 7; +pub const EAI_NONAME: ::c_int = 8; +pub const EAI_SERVICE: ::c_int = 9; +pub const EAI_SOCKTYPE: ::c_int = 10; +pub const EAI_SYSTEM: ::c_int = 11; +pub const EAI_OVERFLOW: ::c_int = 14; + +pub const AIO_CANCELED: ::c_int = 1; +pub const AIO_NOTCANCELED: ::c_int = 2; +pub const AIO_ALLDONE: ::c_int = 3; +pub const LIO_NOP: ::c_int = 0; +pub const LIO_WRITE: ::c_int = 1; +pub const LIO_READ: ::c_int = 2; +pub const LIO_WAIT: ::c_int = 1; +pub const LIO_NOWAIT: ::c_int = 0; + +pub const SIGEV_NONE: ::c_int = 0; +pub const SIGEV_SIGNAL: ::c_int = 1; +pub const SIGEV_THREAD: ::c_int = 2; + +pub const WSTOPPED: ::c_int = 0x00000002; // same as WUNTRACED +pub const WCONTINUED: ::c_int = 0x00000010; +pub const WEXITED: ::c_int = 0x000000020; +pub const WNOWAIT: ::c_int = 0x00010000; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 4; + +pub const UTIME_OMIT: c_long = 1073741822; +pub const UTIME_NOW: c_long = 1073741823; + +pub const B460800: ::speed_t = 460800; +pub const B921600: ::speed_t = 921600; + +pub const ONOCR: ::tcflag_t = 0x20; +pub const ONLRET: ::tcflag_t = 0x40; +pub const CDTRCTS: ::tcflag_t = 0x00020000; +pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS; + +// pub const _PATH_UTMPX: &[::c_char; 14] = b"/var/run/utmpx"; +// pub const _PATH_WTMPX: &[::c_char; 14] = b"/var/log/wtmpx"; +// pub const _PATH_LASTLOGX: &[::c_char; 17] = b"/var/log/lastlogx"; +// pub const _PATH_UTMP_UPDATE: &[::c_char; 24] = b"/usr/libexec/utmp_update"; +pub const UT_NAMESIZE: usize = 8; +pub const UT_LINESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 16; +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_PADSIZE: usize = 40; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 256; +pub const EMPTY: u16 = 0; +pub const RUN_LVL: u16 = 1; +pub const BOOT_TIME: u16 = 2; +pub const OLD_TIME: u16 = 3; +pub const NEW_TIME: u16 = 4; +pub const INIT_PROCESS: u16 = 5; +pub const LOGIN_PROCESS: u16 = 6; +pub const USER_PROCESS: u16 = 7; +pub const DEAD_PROCESS: u16 = 8; +pub const ACCOUNTING: u16 = 9; +pub const SIGNATURE: u16 = 10; +pub const DOWN_TIME: u16 = 11; + +pub const SOCK_CLOEXEC: ::c_int = 0x10000000; +pub const SOCK_NONBLOCK: ::c_int = 0x20000000; + +// Uncomment on next NetBSD release +// pub const FIOSEEKDATA: ::c_ulong = 0xc0086661; +// pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662; +pub const OFIOGETBMAP: ::c_ulong = 0xc004667a; +pub const FIOGETBMAP: ::c_ulong = 0xc008667a; +pub const FIONWRITE: ::c_ulong = 0x40046679; +pub const FIONSPACE: ::c_ulong = 0x40046678; +pub const FIBMAP: ::c_ulong = 0xc008667a; + +pub const SIGSTKSZ: ::size_t = 40960; + +pub const PT_DUMPCORE: ::c_int = 12; +pub const PT_LWPINFO: ::c_int = 13; +pub const PT_SYSCALL: ::c_int = 14; +pub const PT_SYSCALLEMU: ::c_int = 15; +pub const PT_SET_EVENT_MASK: ::c_int = 16; +pub const PT_GET_EVENT_MASK: ::c_int = 17; +pub const PT_GET_PROCESS_STATE: ::c_int = 18; +pub const PT_FIRSTMACH: ::c_int = 32; + +// Flags for chflags(2) +pub const SF_SNAPSHOT: ::c_ulong = 0x00200000; +pub const SF_LOG: ::c_ulong = 0x00400000; +pub const SF_SNAPINVAL: ::c_ulong = 0x00800000; + +fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES +} + +f! { + pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { + (cmsg as *mut ::c_uchar) + .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) + -> *mut ::cmsghdr + { + if cmsg.is_null() { + return ::CMSG_FIRSTHDR(mhdr); + }; + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + + _ALIGN(::mem::size_of::<::cmsghdr>()); + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next > max { + 0 as *mut ::cmsghdr + } else { + (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) + as *mut ::cmsghdr + } + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize)) + as ::c_uint + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0o177) == 0o177 + } + + // dirfd() is a macro on netbsd to access + // the first field of the struct where dirp points to: + // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36 + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int { + *(dirp as *const ::c_int) + } + + pub fn WIFCONTINUED(status: ::c_int) -> bool { + status == 0xffff + } + + pub fn SOCKCREDSIZE(ngrps: usize) -> usize { + let ngrps = if ngrps > 0 { + ngrps - 1 + } else { + 0 + }; + ::mem::size_of::() + ::mem::size_of::<::gid_t>() * ngrps + } +} + +#[link(name = "rt")] +extern "C" { + pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; + #[link_name = "__aio_suspend50"] + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: ::c_int, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; + pub fn lio_listio( + mode: ::c_int, + aiocb_list: *const *mut aiocb, + nitems: ::c_int, + sevp: *mut sigevent, + ) -> ::c_int; +} + +extern "C" { + pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; + pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int; + pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; + + pub fn extattr_delete_fd( + fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + ) -> ::c_int; + pub fn extattr_delete_file( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + ) -> ::c_int; + pub fn extattr_delete_link( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + ) -> ::c_int; + pub fn extattr_get_fd( + fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_get_file( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_get_link( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn extattr_namespace_to_string( + attrnamespace: ::c_int, + string: *mut *mut ::c_char, + ) -> ::c_int; + pub fn extattr_set_fd( + fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t, + ) -> ::c_int; + pub fn extattr_set_file( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t, + ) -> ::c_int; + pub fn extattr_set_link( + path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t, + ) -> ::c_int; + pub fn extattr_string_to_namespace( + string: *const ::c_char, + attrnamespace: *mut ::c_int, + ) -> ::c_int; + + #[link_name = "__lutimes50"] + pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + #[link_name = "__gettimeofday50"] + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + pub fn getnameinfo( + sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::socklen_t, + serv: *mut ::c_char, + sevlen: ::socklen_t, + flags: ::c_int, + ) -> ::c_int; + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn sysctl( + name: *const ::c_int, + namelen: ::c_uint, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *const ::c_void, + newlen: ::size_t, + ) -> ::c_int; + pub fn sysctlbyname( + name: *const ::c_char, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *const ::c_void, + newlen: ::size_t, + ) -> ::c_int; + #[link_name = "__kevent50"] + pub fn kevent( + kq: ::c_int, + changelist: *const ::kevent, + nchanges: ::size_t, + eventlist: *mut ::kevent, + nevents: ::size_t, + timeout: *const ::timespec, + ) -> ::c_int; + #[link_name = "__mount50"] + pub fn mount( + src: *const ::c_char, + target: *const ::c_char, + flags: ::c_int, + data: *mut ::c_void, + size: ::size_t, + ) -> ::c_int; + pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; + pub fn mq_close(mqd: ::mqd_t) -> ::c_int; + pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; + pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) + -> ::c_int; + pub fn mq_receive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + ) -> ::ssize_t; + pub fn mq_send( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + ) -> ::c_int; + pub fn mq_setattr( + mqd: ::mqd_t, + newattr: *const ::mq_attr, + oldattr: *mut ::mq_attr, + ) -> ::c_int; + #[link_name = "__mq_timedreceive50"] + pub fn mq_timedreceive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::ssize_t; + #[link_name = "__mq_timedsend50"] + pub fn mq_timedsend( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::c_int; + pub fn mq_unlink(name: *const ::c_char) -> ::c_int; + pub fn ptrace( + request: ::c_int, + pid: ::pid_t, + addr: *mut ::c_void, + data: ::c_int, + ) -> ::c_int; + pub fn pthread_setname_np( + t: ::pthread_t, + name: *const ::c_char, + arg: *const ::c_void, + ) -> ::c_int; + pub fn pthread_attr_get_np( + thread: ::pthread_t, + attr: *mut ::pthread_attr_t, + ) -> ::c_int; + pub fn pthread_getattr_np( + native: ::pthread_t, + attr: *mut ::pthread_attr_t, + ) -> ::c_int; + pub fn pthread_attr_getguardsize( + attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t, + ) -> ::c_int; + pub fn pthread_attr_getstack( + attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t, + ) -> ::c_int; + #[link_name = "__sigtimedwait50"] + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int; + pub fn duplocale(base: ::locale_t) -> ::locale_t; + pub fn freelocale(loc: ::locale_t); + pub fn localeconv_l(loc: ::locale_t) -> *mut lconv; + pub fn newlocale( + mask: ::c_int, + locale: *const ::c_char, + base: ::locale_t, + ) -> ::locale_t; + #[link_name = "__settimeofday50"] + pub fn settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int; + + pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; + + pub fn sendmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + ) -> ::c_int; + pub fn recvmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + timeout: *mut ::timespec, + ) -> ::c_int; + + pub fn _lwp_self() -> lwpid_t; +} + +#[link(name = "util")] +extern "C" { + #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + pub fn getpwent_r( + pwd: *mut ::passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::passwd, + ) -> ::c_int; + pub fn getgrent_r( + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + + pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int; + pub fn getlastlogx( + fname: *const ::c_char, + uid: ::uid_t, + ll: *mut lastlogx, + ) -> *mut lastlogx; + pub fn updlastlogx( + fname: *const ::c_char, + uid: ::uid_t, + ll: *mut lastlogx, + ) -> ::c_int; + pub fn utmpxname(file: *const ::c_char) -> ::c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + + pub fn getutmp(ux: *const utmpx, u: *mut utmp); + pub fn getutmpx(u: *const utmp, ux: *mut utmpx); + + pub fn utpname(file: *const ::c_char) -> ::c_int; + pub fn setutent(); + pub fn endutent(); + pub fn getutent() -> *mut utmp; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(target_arch = "sparc64")] { + mod sparc64; + pub use self::sparc64::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/powerpc.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/powerpc.rs new file mode 100644 index 0000000..e12fd5e --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -0,0 +1,21 @@ +use PT_FIRSTMACH; + +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = u8; +pub type __cpu_simple_lock_nv_t = ::c_int; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/sparc64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/sparc64.rs new file mode 100644 index 0000000..6a86759 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/sparc64.rs @@ -0,0 +1,8 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = i8; +pub type __cpu_simple_lock_nv_t = ::c_uchar; + +// should be pub(crate), but that requires Rust 1.18.0 +#[doc(hidden)] +pub const _ALIGNBYTES: usize = 0xf; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/x86.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/x86.rs new file mode 100644 index 0000000..daa89a1 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -0,0 +1,15 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = i8; +pub type __cpu_simple_lock_nv_t = ::c_uchar; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 4 - 1; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/x86_64.rs new file mode 100644 index 0000000..0860d4f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -0,0 +1,23 @@ +use PT_FIRSTMACH; + +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = i8; +pub type __cpu_simple_lock_nv_t = ::c_uchar; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/aarch64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/aarch64.rs new file mode 100644 index 0000000..99350ec --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/aarch64.rs @@ -0,0 +1,16 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = u8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/mod.rs new file mode 100644 index 0000000..89a3354 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -0,0 +1,1509 @@ +use unix::bsd::O_SYNC; + +pub type clock_t = i64; +pub type suseconds_t = ::c_long; +pub type dev_t = i32; +pub type sigset_t = ::c_uint; +pub type blksize_t = i32; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type pthread_attr_t = *mut ::c_void; +pub type pthread_mutex_t = *mut ::c_void; +pub type pthread_mutexattr_t = *mut ::c_void; +pub type pthread_cond_t = *mut ::c_void; +pub type pthread_condattr_t = *mut ::c_void; +pub type pthread_rwlock_t = *mut ::c_void; +pub type pthread_rwlockattr_t = *mut ::c_void; +pub type caddr_t = *mut ::c_char; + +s! { + pub struct glob_t { + pub gl_pathc: ::size_t, + pub gl_matchc: ::size_t, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + pub gl_pathv: *mut *mut ::c_char, + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + __unused6: *mut ::c_void, + __unused7: *mut ::c_void, + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct ufs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + } + + pub struct mfs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + // https://github.com/openbsd/src/blob/master/sys/sys/types.h#L134 + pub base: *mut ::c_char, + pub size: ::c_ulong, + } + + pub struct iso_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + pub flags: ::c_int, + pub sess: ::c_int, + } + + pub struct nfs_args { + pub version: ::c_int, + pub addr: *mut ::sockaddr, + pub addrlen: ::c_int, + pub sotype: ::c_int, + pub proto: ::c_int, + pub fh: *mut ::c_uchar, + pub fhsize: ::c_int, + pub flags: ::c_int, + pub wsize: ::c_int, + pub rsize: ::c_int, + pub readdirsize: ::c_int, + pub timeo: ::c_int, + pub retrans: ::c_int, + pub maxgrouplist: ::c_int, + pub readahead: ::c_int, + pub leaseterm: ::c_int, + pub deadthresh: ::c_int, + pub hostname: *mut ::c_char, + pub acregmin: ::c_int, + pub acregmax: ::c_int, + pub acdirmin: ::c_int, + pub acdirmax: ::c_int, + } + + pub struct msdosfs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub mask: ::mode_t, + pub flags: ::c_int, + } + + pub struct ntfs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub mode: ::mode_t, + pub flag: ::c_ulong, + } + + pub struct udf_args { + pub fspec: *mut ::c_char, + pub lastblock: u32, + } + + pub struct tmpfs_args { + pub ta_version: ::c_int, + pub ta_nodes_max: ::ino_t, + pub ta_size_max: ::off_t, + pub ta_root_uid: ::uid_t, + pub ta_root_gid: ::gid_t, + pub ta_root_mode: ::mode_t, + } + + pub struct fusefs_args { + pub name: *mut ::c_char, + pub fd: ::c_int, + pub max_read: ::c_int, + pub allow_other: ::c_int, + } + + pub struct xucred { + pub cr_uid: ::uid_t, + pub cr_gid: ::gid_t, + pub cr_ngroups: ::c_short, + //https://github.com/openbsd/src/blob/master/sys/sys/syslimits.h#L44 + pub cr_groups: [::gid_t; 16], + } + + pub struct export_args { + pub ex_flags: ::c_int, + pub ex_root: ::uid_t, + pub ex_anon: xucred, + pub ex_addr: *mut ::sockaddr, + pub ex_addrlen: ::c_int, + pub ex_mask: *mut ::sockaddr, + pub ex_masklen: ::c_int, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [i8; 8], + } + + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::c_short, + pub flags: ::c_ushort, + pub fflags: ::c_uint, + pub data: i64, + pub udata: *mut ::c_void, + } + + pub struct stat { + pub st_mode: ::mode_t, + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: u32, + pub st_gen: u32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: ::socklen_t, + pub ai_addr: *mut ::sockaddr, + pub ai_canonname: *mut ::c_char, + pub ai_next: *mut ::addrinfo, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct if_data { + pub ifi_type: ::c_uchar, + pub ifi_addrlen: ::c_uchar, + pub ifi_hdrlen: ::c_uchar, + pub ifi_link_state: ::c_uchar, + pub ifi_mtu: u32, + pub ifi_metric: u32, + pub ifi_rdomain: u32, + pub ifi_baudrate: u64, + pub ifi_ipackets: u64, + pub ifi_ierrors: u64, + pub ifi_opackets: u64, + pub ifi_oerrors: u64, + pub ifi_collisions: u64, + pub ifi_ibytes: u64, + pub ifi_obytes: u64, + pub ifi_imcasts: u64, + pub ifi_omcasts: u64, + pub ifi_iqdrops: u64, + pub ifi_oqdrops: u64, + pub ifi_noproto: u64, + pub ifi_capabilities: u32, + pub ifi_lastchange: ::timeval, + } + + pub struct if_msghdr { + pub ifm_msglen: ::c_ushort, + pub ifm_version: ::c_uchar, + pub ifm_type: ::c_uchar, + pub ifm_hdrlen: ::c_ushort, + pub ifm_index: ::c_ushort, + pub ifm_tableid: ::c_ushort, + pub ifm_pad1: ::c_uchar, + pub ifm_pad2: ::c_uchar, + pub ifm_addrs: ::c_int, + pub ifm_flags: ::c_int, + pub ifm_xflags: ::c_int, + pub ifm_data: if_data, + } + + pub struct sockaddr_dl { + pub sdl_len: ::c_uchar, + pub sdl_family: ::c_uchar, + pub sdl_index: ::c_ushort, + pub sdl_type: ::c_uchar, + pub sdl_nlen: ::c_uchar, + pub sdl_alen: ::c_uchar, + pub sdl_slen: ::c_uchar, + pub sdl_data: [::c_char; 24], + } + + pub struct sockpeercred { + pub uid: ::uid_t, + pub gid: ::gid_t, + pub pid: ::pid_t, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::c_int, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::c_short, + pub shm_atime: ::time_t, + __shm_atimensec: c_long, + pub shm_dtime: ::time_t, + __shm_dtimensec: c_long, + pub shm_ctime: ::time_t, + __shm_ctimensec: c_long, + pub shm_internal: *mut ::c_void, + } +} + +impl siginfo_t { + pub unsafe fn si_value(&self) -> ::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + _pid: ::pid_t, + _uid: ::uid_t, + value: ::sigval, + } + (*(self as *const siginfo_t as *const siginfo_timer)).value + } +} + +s_no_extra_traits! { + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: u16, + pub d_type: u8, + pub d_namlen: u8, + __d_padding: [u8; 4], + pub d_name: [::c_char; 256], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: ::sa_family_t, + __ss_pad1: [u8; 6], + __ss_pad2: i64, + __ss_pad3: [u8; 240], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub si_addr: *mut ::c_char, + #[cfg(target_pointer_width = "32")] + __pad: [u8; 112], + #[cfg(target_pointer_width = "64")] + __pad: [u8; 108], + } + + pub struct lastlog { + ll_time: ::time_t, + ll_line: [::c_char; UT_LINESIZE], + ll_host: [::c_char; UT_HOSTSIZE], + } + + pub struct utmp { + pub ut_line: [::c_char; UT_LINESIZE], + pub ut_name: [::c_char; UT_NAMESIZE], + pub ut_host: [::c_char; UT_HOSTSIZE], + pub ut_time: ::time_t, + } + + pub union mount_info { + pub ufs_args: ufs_args, + pub mfs_args: mfs_args, + pub nfs_args: nfs_args, + pub iso_args: iso_args, + pub msdosfs_args: msdosfs_args, + pub ntfs_args: ntfs_args, + pub tmpfs_args: tmpfs_args, + align: [::c_char; 160], + } + +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_fileno == other.d_fileno + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self.d_namlen == other.d_namlen + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for dirent {} + + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_fileno", &self.d_fileno) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + .field("d_namlen", &self.d_namlen) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_fileno.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_namlen.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_len == other.ss_len + && self.ss_family == other.ss_family + } + } + + impl Eq for sockaddr_storage {} + + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_len", &self.ss_len) + .field("ss_family", &self.ss_family) + .finish() + } + } + + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_len.hash(state); + self.ss_family.hash(state); + } + } + + impl PartialEq for siginfo_t { + fn eq(&self, other: &siginfo_t) -> bool { + self.si_signo == other.si_signo + && self.si_code == other.si_code + && self.si_errno == other.si_errno + && self.si_addr == other.si_addr + } + } + + impl Eq for siginfo_t {} + + impl ::fmt::Debug for siginfo_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("siginfo_t") + .field("si_signo", &self.si_signo) + .field("si_code", &self.si_code) + .field("si_errno", &self.si_errno) + .field("si_addr", &self.si_addr) + .finish() + } + } + + impl ::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_code.hash(state); + self.si_errno.hash(state); + self.si_addr.hash(state); + } + } + + impl PartialEq for lastlog { + fn eq(&self, other: &lastlog) -> bool { + self.ll_time == other.ll_time + && self + .ll_line + .iter() + .zip(other.ll_line.iter()) + .all(|(a,b)| a == b) + && self + .ll_host + .iter() + .zip(other.ll_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for lastlog {} + + impl ::fmt::Debug for lastlog { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("lastlog") + .field("ll_time", &self.ll_time) + // FIXME: .field("ll_line", &self.ll_line) + // FIXME: .field("ll_host", &self.ll_host) + .finish() + } + } + + impl ::hash::Hash for lastlog { + fn hash(&self, state: &mut H) { + self.ll_time.hash(state); + self.ll_line.hash(state); + self.ll_host.hash(state); + } + } + + impl PartialEq for utmp { + fn eq(&self, other: &utmp) -> bool { + self.ut_time == other.ut_time + && self + .ut_line + .iter() + .zip(other.ut_line.iter()) + .all(|(a,b)| a == b) + && self + .ut_name + .iter() + .zip(other.ut_name.iter()) + .all(|(a,b)| a == b) + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for utmp {} + + impl ::fmt::Debug for utmp { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmp") + // FIXME: .field("ut_line", &self.ut_line) + // FIXME: .field("ut_name", &self.ut_name) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_time", &self.ut_time) + .finish() + } + } + + impl ::hash::Hash for utmp { + fn hash(&self, state: &mut H) { + self.ut_line.hash(state); + self.ut_name.hash(state); + self.ut_host.hash(state); + self.ut_time.hash(state); + } + } + + impl PartialEq for mount_info { + fn eq(&self, other: &mount_info) -> bool { + unsafe { + self.align + .iter() + .zip(other.align.iter()) + .all(|(a,b)| a == b) + } + } + } + + impl Eq for mount_info { } + + impl ::fmt::Debug for mount_info { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mount_info") + // FIXME: .field("align", &self.align) + .finish() + } + } + + impl ::hash::Hash for mount_info { + fn hash(&self, state: &mut H) { + unsafe { self.align.hash(state) }; + } + } + } +} + +cfg_if! { + if #[cfg(libc_union)] { + s_no_extra_traits! { + // This type uses the union mount_info: + pub struct statfs { + pub f_flags: u32, + pub f_bsize: u32, + pub f_iosize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: i64, + pub f_syncwrites: u64, + pub f_syncreads: u64, + pub f_asyncwrites: u64, + pub f_asyncreads: u64, + pub f_fsid: ::fsid_t, + pub f_namemax: u32, + pub f_owner: ::uid_t, + pub f_ctime: u64, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 90], + pub f_mntfromname: [::c_char; 90], + pub f_mntfromspec: [::c_char; 90], + pub mount_info: mount_info, + } + } + + cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_flags == other.f_flags + && self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_favail == other.f_favail + && self.f_syncwrites == other.f_syncwrites + && self.f_syncreads == other.f_syncreads + && self.f_asyncwrites == other.f_asyncwrites + && self.f_asyncreads == other.f_asyncreads + && self.f_fsid == other.f_fsid + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_ctime == other.f_ctime + && self.f_fstypename + .iter() + .zip(other.f_fstypename.iter()) + .all(|(a,b)| a == b) + && self.f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + && self.f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self.f_mntfromspec + .iter() + .zip(other.f_mntfromspec.iter()) + .all(|(a,b)| a == b) + && self.mount_info == other.mount_info + } + } + + impl Eq for statfs { } + + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) + -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_flags", &self.f_flags) + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_favail", &self.f_favail) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_fsid", &self.f_fsid) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_ctime", &self.f_ctime) + // FIXME: .field("f_fstypename", &self.f_fstypename) + // FIXME: .field("f_mntonname", &self.f_mntonname) + // FIXME: .field("f_mntfromname", &self.f_mntfromname) + // FIXME: .field("f_mntfromspec", &self.f_mntfromspec) + .field("mount_info", &self.mount_info) + .finish() + } + } + + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_flags.hash(state); + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_favail.hash(state); + self.f_syncwrites.hash(state); + self.f_syncreads.hash(state); + self.f_asyncwrites.hash(state); + self.f_asyncreads.hash(state); + self.f_fsid.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_ctime.hash(state); + self.f_fstypename.hash(state); + self.f_mntonname.hash(state); + self.f_mntfromname.hash(state); + self.f_mntfromspec.hash(state); + self.mount_info.hash(state); + } + } + } + } + } +} + +pub const UT_NAMESIZE: usize = 32; +pub const UT_LINESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 256; + +pub const O_CLOEXEC: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x20000; +pub const O_RSYNC: ::c_int = O_SYNC; + +pub const MS_SYNC: ::c_int = 0x0002; +pub const MS_INVALIDATE: ::c_int = 0x0004; + +pub const POLLNORM: ::c_short = ::POLLRDNORM; + +pub const ENOATTR: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const EOVERFLOW: ::c_int = 87; +pub const ECANCELED: ::c_int = 88; +pub const EIDRM: ::c_int = 89; +pub const ENOMSG: ::c_int = 90; +pub const ENOTSUP: ::c_int = 91; +pub const EBADMSG: ::c_int = 92; +pub const ENOTRECOVERABLE: ::c_int = 93; +pub const EOWNERDEAD: ::c_int = 94; +pub const EPROTO: ::c_int = 95; +pub const ELAST: ::c_int = 95; + +pub const F_DUPFD_CLOEXEC: ::c_int = 10; + +pub const UTIME_OMIT: c_long = -1; +pub const UTIME_NOW: c_long = -2; + +pub const AT_FDCWD: ::c_int = -100; +pub const AT_EACCESS: ::c_int = 0x01; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x02; +pub const AT_SYMLINK_FOLLOW: ::c_int = 0x04; +pub const AT_REMOVEDIR: ::c_int = 0x08; + +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: ::c_int = 9; + +pub const SO_TIMESTAMP: ::c_int = 0x0800; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_BINDANY: ::c_int = 0x1000; +pub const SO_NETPROC: ::c_int = 0x1020; +pub const SO_RTABLE: ::c_int = 0x1021; +pub const SO_PEERCRED: ::c_int = 0x1022; +pub const SO_SPLICE: ::c_int = 0x1023; + +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// Hop-by-hop option header +pub const IPPROTO_HOPOPTS: ::c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: ::c_int = 2; +/// gateway^2 (deprecated) +pub const IPPROTO_GGP: ::c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: ::c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// exterior gateway protocol +pub const IPPROTO_EGP: ::c_int = 8; +/// pup +pub const IPPROTO_PUP: ::c_int = 12; +// IPPROTO_UDP defined in src/unix/mod.rs +/// xns idp +pub const IPPROTO_IDP: ::c_int = 22; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: ::c_int = 29; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// IP6 routing header +pub const IPPROTO_ROUTING: ::c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: ::c_int = 44; +/// resource reservation +pub const IPPROTO_RSVP: ::c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: ::c_int = 47; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: ::c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: ::c_int = 51; +/// IP Mobility RFC 2004 +pub const IPPROTO_MOBILE: ::c_int = 55; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: ::c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: ::c_int = 60; +/// ISO cnlp +pub const IPPROTO_EON: ::c_int = 80; +/// Ethernet-in-IP +pub const IPPROTO_ETHERIP: ::c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: ::c_int = 98; +/// Protocol indep. multicast +pub const IPPROTO_PIM: ::c_int = 103; +/// IP Payload Comp. Protocol +pub const IPPROTO_IPCOMP: ::c_int = 108; +/// CARP +pub const IPPROTO_CARP: ::c_int = 112; +/// unicast MPLS packet +pub const IPPROTO_MPLS: ::c_int = 137; +/// PFSYNC +pub const IPPROTO_PFSYNC: ::c_int = 240; +pub const IPPROTO_MAX: ::c_int = 256; + +// Only used internally, so it can be outside the range of valid IP protocols +pub const IPPROTO_DIVERT: ::c_int = 258; + +pub const IP_RECVDSTADDR: ::c_int = 7; +pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR; +pub const IP_RECVIF: ::c_int = 30; + +// sys/netinet/in.h +pub const TCP_MD5SIG: ::c_int = 0x04; +pub const TCP_NOPUSH: ::c_int = 0x10; + +pub const AF_ECMA: ::c_int = 8; +pub const AF_ROUTE: ::c_int = 17; +pub const AF_ENCAP: ::c_int = 28; +pub const AF_SIP: ::c_int = 29; +pub const AF_KEY: ::c_int = 30; +pub const pseudo_AF_HDRCMPLT: ::c_int = 31; +pub const AF_BLUETOOTH: ::c_int = 32; +pub const AF_MPLS: ::c_int = 33; +pub const pseudo_AF_PFLOW: ::c_int = 34; +pub const pseudo_AF_PIPEX: ::c_int = 35; +pub const NET_RT_DUMP: ::c_int = 1; +pub const NET_RT_FLAGS: ::c_int = 2; +pub const NET_RT_IFLIST: ::c_int = 3; +pub const NET_RT_STATS: ::c_int = 4; +pub const NET_RT_TABLE: ::c_int = 5; +pub const NET_RT_IFNAMES: ::c_int = 6; +#[doc(hidden)] +pub const NET_RT_MAXID: ::c_int = 7; + +pub const IPV6_JOIN_GROUP: ::c_int = 12; +pub const IPV6_LEAVE_GROUP: ::c_int = 13; + +pub const PF_ROUTE: ::c_int = AF_ROUTE; +pub const PF_ECMA: ::c_int = AF_ECMA; +pub const PF_ENCAP: ::c_int = AF_ENCAP; +pub const PF_SIP: ::c_int = AF_SIP; +pub const PF_KEY: ::c_int = AF_KEY; +pub const PF_BPF: ::c_int = pseudo_AF_HDRCMPLT; +pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; +pub const PF_MPLS: ::c_int = AF_MPLS; +pub const PF_PFLOW: ::c_int = pseudo_AF_PFLOW; +pub const PF_PIPEX: ::c_int = pseudo_AF_PIPEX; + +pub const SCM_TIMESTAMP: ::c_int = 0x04; + +pub const O_DSYNC: ::c_int = 128; + +pub const MAP_RENAME: ::c_int = 0x0000; +pub const MAP_NORESERVE: ::c_int = 0x0000; +pub const MAP_HASSEMAPHORE: ::c_int = 0x0000; + +pub const EIPSEC: ::c_int = 82; +pub const ENOMEDIUM: ::c_int = 85; +pub const EMEDIUMTYPE: ::c_int = 86; + +pub const EAI_BADFLAGS: ::c_int = -1; +pub const EAI_NONAME: ::c_int = -2; +pub const EAI_AGAIN: ::c_int = -3; +pub const EAI_FAIL: ::c_int = -4; +pub const EAI_NODATA: ::c_int = -5; +pub const EAI_FAMILY: ::c_int = -6; +pub const EAI_SOCKTYPE: ::c_int = -7; +pub const EAI_SERVICE: ::c_int = -8; +pub const EAI_MEMORY: ::c_int = -10; +pub const EAI_SYSTEM: ::c_int = -11; +pub const EAI_OVERFLOW: ::c_int = -14; + +pub const RUSAGE_THREAD: ::c_int = 1; + +pub const MAP_COPY: ::c_int = 0x0002; +pub const MAP_NOEXTEND: ::c_int = 0x0000; + +pub const _PC_LINK_MAX: ::c_int = 1; +pub const _PC_MAX_CANON: ::c_int = 2; +pub const _PC_MAX_INPUT: ::c_int = 3; +pub const _PC_NAME_MAX: ::c_int = 4; +pub const _PC_PATH_MAX: ::c_int = 5; +pub const _PC_PIPE_BUF: ::c_int = 6; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 7; +pub const _PC_NO_TRUNC: ::c_int = 8; +pub const _PC_VDISABLE: ::c_int = 9; +pub const _PC_2_SYMLINKS: ::c_int = 10; +pub const _PC_ALLOC_SIZE_MIN: ::c_int = 11; +pub const _PC_ASYNC_IO: ::c_int = 12; +pub const _PC_FILESIZEBITS: ::c_int = 13; +pub const _PC_PRIO_IO: ::c_int = 14; +pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 15; +pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 16; +pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 17; +pub const _PC_REC_XFER_ALIGN: ::c_int = 18; +pub const _PC_SYMLINK_MAX: ::c_int = 19; +pub const _PC_SYNC_IO: ::c_int = 20; +pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 21; + +pub const _SC_CLK_TCK: ::c_int = 3; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 31; +pub const _SC_SEM_VALUE_MAX: ::c_int = 32; +pub const _SC_HOST_NAME_MAX: ::c_int = 33; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 34; +pub const _SC_2_PBS: ::c_int = 35; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 36; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 37; +pub const _SC_2_PBS_LOCATE: ::c_int = 38; +pub const _SC_2_PBS_MESSAGE: ::c_int = 39; +pub const _SC_2_PBS_TRACK: ::c_int = 40; +pub const _SC_ADVISORY_INFO: ::c_int = 41; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 42; +pub const _SC_AIO_MAX: ::c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 45; +pub const _SC_ATEXIT_MAX: ::c_int = 46; +pub const _SC_BARRIERS: ::c_int = 47; +pub const _SC_CLOCK_SELECTION: ::c_int = 48; +pub const _SC_CPUTIME: ::c_int = 49; +pub const _SC_DELAYTIMER_MAX: ::c_int = 50; +pub const _SC_IOV_MAX: ::c_int = 51; +pub const _SC_IPV6: ::c_int = 52; +pub const _SC_MAPPED_FILES: ::c_int = 53; +pub const _SC_MEMLOCK: ::c_int = 54; +pub const _SC_MEMLOCK_RANGE: ::c_int = 55; +pub const _SC_MEMORY_PROTECTION: ::c_int = 56; +pub const _SC_MESSAGE_PASSING: ::c_int = 57; +pub const _SC_MQ_OPEN_MAX: ::c_int = 58; +pub const _SC_MQ_PRIO_MAX: ::c_int = 59; +pub const _SC_PRIORITIZED_IO: ::c_int = 60; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 61; +pub const _SC_RAW_SOCKETS: ::c_int = 62; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 63; +pub const _SC_REALTIME_SIGNALS: ::c_int = 64; +pub const _SC_REGEXP: ::c_int = 65; +pub const _SC_RTSIG_MAX: ::c_int = 66; +pub const _SC_SEMAPHORES: ::c_int = 67; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 68; +pub const _SC_SHELL: ::c_int = 69; +pub const _SC_SIGQUEUE_MAX: ::c_int = 70; +pub const _SC_SPAWN: ::c_int = 71; +pub const _SC_SPIN_LOCKS: ::c_int = 72; +pub const _SC_SPORADIC_SERVER: ::c_int = 73; +pub const _SC_SS_REPL_MAX: ::c_int = 74; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 75; +pub const _SC_SYMLOOP_MAX: ::c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; +pub const _SC_THREAD_CPUTIME: ::c_int = 79; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 80; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 81; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 82; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 83; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 84; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 85; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 86; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 87; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 88; +pub const _SC_THREAD_STACK_MIN: ::c_int = 89; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 90; +pub const _SC_THREADS: ::c_int = 91; +pub const _SC_TIMEOUTS: ::c_int = 92; +pub const _SC_TIMER_MAX: ::c_int = 93; +pub const _SC_TIMERS: ::c_int = 94; +pub const _SC_TRACE: ::c_int = 95; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 96; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 97; +pub const _SC_TRACE_INHERIT: ::c_int = 98; +pub const _SC_TRACE_LOG: ::c_int = 99; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 100; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 101; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 102; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 103; +pub const _SC_TRACE_NAME_MAX: ::c_int = 104; +pub const _SC_TRACE_SYS_MAX: ::c_int = 105; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 106; +pub const _SC_TTY_NAME_MAX: ::c_int = 107; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 108; +pub const _SC_V6_ILP32_OFF32: ::c_int = 109; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = 110; +pub const _SC_V6_LP64_OFF64: ::c_int = 111; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 112; +pub const _SC_V7_ILP32_OFF32: ::c_int = 113; +pub const _SC_V7_ILP32_OFFBIG: ::c_int = 114; +pub const _SC_V7_LP64_OFF64: ::c_int = 115; +pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 116; +pub const _SC_XOPEN_CRYPT: ::c_int = 117; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 118; +pub const _SC_XOPEN_LEGACY: ::c_int = 119; +pub const _SC_XOPEN_REALTIME: ::c_int = 120; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 121; +pub const _SC_XOPEN_STREAMS: ::c_int = 122; +pub const _SC_XOPEN_UNIX: ::c_int = 123; +pub const _SC_XOPEN_UUCP: ::c_int = 124; +pub const _SC_XOPEN_VERSION: ::c_int = 125; +pub const _SC_PHYS_PAGES: ::c_int = 500; +pub const _SC_AVPHYS_PAGES: ::c_int = 501; +pub const _SC_NPROCESSORS_CONF: ::c_int = 502; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 503; + +pub const FD_SETSIZE: usize = 1024; + +pub const ST_NOSUID: ::c_ulong = 2; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; + +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3; +pub const PTHREAD_MUTEX_STRICT_NP: ::c_int = 4; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_STRICT_NP; + +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_WRITE: i16 = -2; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; +pub const EV_SYSFLAGS: u16 = 0xf000; + +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_EOF: u32 = 0x00000002; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_TRUNCATE: u32 = 0x00000080; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; + +pub const TMP_MAX: ::c_uint = 0x7fffffff; + +pub const NI_MAXHOST: ::size_t = 256; + +pub const RTLD_LOCAL: ::c_int = 0; + +pub const CTL_MAXNAME: ::c_int = 12; + +pub const CTLTYPE_NODE: ::c_int = 1; +pub const CTLTYPE_INT: ::c_int = 2; +pub const CTLTYPE_STRING: ::c_int = 3; +pub const CTLTYPE_QUAD: ::c_int = 4; +pub const CTLTYPE_STRUCT: ::c_int = 5; + +pub const CTL_UNSPEC: ::c_int = 0; +pub const CTL_KERN: ::c_int = 1; +pub const CTL_VM: ::c_int = 2; +pub const CTL_FS: ::c_int = 3; +pub const CTL_NET: ::c_int = 4; +pub const CTL_DEBUG: ::c_int = 5; +pub const CTL_HW: ::c_int = 6; +pub const CTL_MACHDEP: ::c_int = 7; +pub const CTL_DDB: ::c_int = 9; +pub const CTL_VFS: ::c_int = 10; +pub const CTL_MAXID: ::c_int = 11; + +pub const HW_NCPUONLINE: ::c_int = 25; + +pub const KERN_OSTYPE: ::c_int = 1; +pub const KERN_OSRELEASE: ::c_int = 2; +pub const KERN_OSREV: ::c_int = 3; +pub const KERN_VERSION: ::c_int = 4; +pub const KERN_MAXVNODES: ::c_int = 5; +pub const KERN_MAXPROC: ::c_int = 6; +pub const KERN_MAXFILES: ::c_int = 7; +pub const KERN_ARGMAX: ::c_int = 8; +pub const KERN_SECURELVL: ::c_int = 9; +pub const KERN_HOSTNAME: ::c_int = 10; +pub const KERN_HOSTID: ::c_int = 11; +pub const KERN_CLOCKRATE: ::c_int = 12; +pub const KERN_PROF: ::c_int = 16; +pub const KERN_POSIX1: ::c_int = 17; +pub const KERN_NGROUPS: ::c_int = 18; +pub const KERN_JOB_CONTROL: ::c_int = 19; +pub const KERN_SAVED_IDS: ::c_int = 20; +pub const KERN_BOOTTIME: ::c_int = 21; +pub const KERN_DOMAINNAME: ::c_int = 22; +pub const KERN_MAXPARTITIONS: ::c_int = 23; +pub const KERN_RAWPARTITION: ::c_int = 24; +pub const KERN_MAXTHREAD: ::c_int = 25; +pub const KERN_NTHREADS: ::c_int = 26; +pub const KERN_OSVERSION: ::c_int = 27; +pub const KERN_SOMAXCONN: ::c_int = 28; +pub const KERN_SOMINCONN: ::c_int = 29; +pub const KERN_USERMOUNT: ::c_int = 30; +pub const KERN_NOSUIDCOREDUMP: ::c_int = 32; +pub const KERN_FSYNC: ::c_int = 33; +pub const KERN_SYSVMSG: ::c_int = 34; +pub const KERN_SYSVSEM: ::c_int = 35; +pub const KERN_SYSVSHM: ::c_int = 36; +pub const KERN_ARND: ::c_int = 37; +pub const KERN_MSGBUFSIZE: ::c_int = 38; +pub const KERN_MALLOCSTATS: ::c_int = 39; +pub const KERN_CPTIME: ::c_int = 40; +pub const KERN_NCHSTATS: ::c_int = 41; +pub const KERN_FORKSTAT: ::c_int = 42; +pub const KERN_NSELCOLL: ::c_int = 43; +pub const KERN_TTY: ::c_int = 44; +pub const KERN_CCPU: ::c_int = 45; +pub const KERN_FSCALE: ::c_int = 46; +pub const KERN_NPROCS: ::c_int = 47; +pub const KERN_MSGBUF: ::c_int = 48; +pub const KERN_POOL: ::c_int = 49; +pub const KERN_STACKGAPRANDOM: ::c_int = 50; +pub const KERN_SYSVIPC_INFO: ::c_int = 51; +pub const KERN_SPLASSERT: ::c_int = 54; +pub const KERN_PROC_ARGS: ::c_int = 55; +pub const KERN_NFILES: ::c_int = 56; +pub const KERN_TTYCOUNT: ::c_int = 57; +pub const KERN_NUMVNODES: ::c_int = 58; +pub const KERN_MBSTAT: ::c_int = 59; +pub const KERN_SEMINFO: ::c_int = 61; +pub const KERN_SHMINFO: ::c_int = 62; +pub const KERN_INTRCNT: ::c_int = 63; +pub const KERN_WATCHDOG: ::c_int = 64; +pub const KERN_PROC: ::c_int = 66; +pub const KERN_MAXCLUSTERS: ::c_int = 67; +pub const KERN_EVCOUNT: ::c_int = 68; +pub const KERN_TIMECOUNTER: ::c_int = 69; +pub const KERN_MAXLOCKSPERUID: ::c_int = 70; +pub const KERN_CPTIME2: ::c_int = 71; +pub const KERN_CACHEPCT: ::c_int = 72; +pub const KERN_FILE: ::c_int = 73; +pub const KERN_CONSDEV: ::c_int = 75; +pub const KERN_NETLIVELOCKS: ::c_int = 76; +pub const KERN_POOL_DEBUG: ::c_int = 77; +pub const KERN_PROC_CWD: ::c_int = 78; +pub const KERN_PROC_NOBROADCASTKILL: ::c_int = 79; +pub const KERN_PROC_VMMAP: ::c_int = 80; +pub const KERN_GLOBAL_PTRACE: ::c_int = 81; +pub const KERN_CONSBUFSIZE: ::c_int = 82; +pub const KERN_CONSBUF: ::c_int = 83; +pub const KERN_AUDIO: ::c_int = 84; +pub const KERN_CPUSTATS: ::c_int = 85; +pub const KERN_PFSTATUS: ::c_int = 86; +pub const KERN_TIMEOUT_STATS: ::c_int = 87; +pub const KERN_MAXID: ::c_int = 88; + +pub const KERN_PROC_ALL: ::c_int = 0; +pub const KERN_PROC_PID: ::c_int = 1; +pub const KERN_PROC_PGRP: ::c_int = 2; +pub const KERN_PROC_SESSION: ::c_int = 3; +pub const KERN_PROC_TTY: ::c_int = 4; +pub const KERN_PROC_UID: ::c_int = 5; +pub const KERN_PROC_RUID: ::c_int = 6; +pub const KERN_PROC_KTHREAD: ::c_int = 7; +pub const KERN_PROC_SHOW_THREADS: ::c_int = 0x40000000; + +pub const KERN_SYSVIPC_MSG_INFO: ::c_int = 1; +pub const KERN_SYSVIPC_SEM_INFO: ::c_int = 2; +pub const KERN_SYSVIPC_SHM_INFO: ::c_int = 3; + +pub const KERN_PROC_ARGV: ::c_int = 1; +pub const KERN_PROC_NARGV: ::c_int = 2; +pub const KERN_PROC_ENV: ::c_int = 3; +pub const KERN_PROC_NENV: ::c_int = 4; + +pub const KI_NGROUPS: ::c_int = 16; +pub const KI_MAXCOMLEN: ::c_int = 24; +pub const KI_WMESGLEN: ::c_int = 8; +pub const KI_MAXLOGNAME: ::c_int = 32; +pub const KI_EMULNAMELEN: ::c_int = 8; + +pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS; +pub const OLCUC: ::tcflag_t = 0x20; +pub const ONOCR: ::tcflag_t = 0x40; +pub const ONLRET: ::tcflag_t = 0x80; + +//https://github.com/openbsd/src/blob/master/sys/sys/mount.h +pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext +pub const ISOFSMNT_GENS: ::c_int = 0x2; // enable generation numbers +pub const ISOFSMNT_EXTATT: ::c_int = 0x4; // enable extended attr +pub const ISOFSMNT_NOJOLIET: ::c_int = 0x8; // disable Joliet Ext +pub const ISOFSMNT_SESS: ::c_int = 0x10; // use iso_args.sess + +pub const NFS_ARGSVERSION: ::c_int = 4; // change when nfs_args changes + +pub const NFSMNT_RESVPORT: ::c_int = 0; // always use reserved ports +pub const NFSMNT_SOFT: ::c_int = 0x1; // soft mount (hard is default) +pub const NFSMNT_WSIZE: ::c_int = 0x2; // set write size +pub const NFSMNT_RSIZE: ::c_int = 0x4; // set read size +pub const NFSMNT_TIMEO: ::c_int = 0x8; // set initial timeout +pub const NFSMNT_RETRANS: ::c_int = 0x10; // set number of request retries +pub const NFSMNT_MAXGRPS: ::c_int = 0x20; // set maximum grouplist size +pub const NFSMNT_INT: ::c_int = 0x40; // allow interrupts on hard mount +pub const NFSMNT_NOCONN: ::c_int = 0x80; // Don't Connect the socket +pub const NFSMNT_NQNFS: ::c_int = 0x100; // Use Nqnfs protocol +pub const NFSMNT_NFSV3: ::c_int = 0x200; // Use NFS Version 3 protocol +pub const NFSMNT_KERB: ::c_int = 0x400; // Use Kerberos authentication +pub const NFSMNT_DUMBTIMR: ::c_int = 0x800; // Don't estimate rtt dynamically +pub const NFSMNT_LEASETERM: ::c_int = 0x1000; // set lease term (nqnfs) +pub const NFSMNT_READAHEAD: ::c_int = 0x2000; // set read ahead +pub const NFSMNT_DEADTHRESH: ::c_int = 0x4000; // set dead server retry thresh +pub const NFSMNT_NOAC: ::c_int = 0x8000; // disable attribute cache +pub const NFSMNT_RDIRPLUS: ::c_int = 0x10000; // Use Readdirplus for V3 +pub const NFSMNT_READDIRSIZE: ::c_int = 0x20000; // Set readdir size + +/* Flags valid only in mount syscall arguments */ +pub const NFSMNT_ACREGMIN: ::c_int = 0x40000; // acregmin field valid +pub const NFSMNT_ACREGMAX: ::c_int = 0x80000; // acregmax field valid +pub const NFSMNT_ACDIRMIN: ::c_int = 0x100000; // acdirmin field valid +pub const NFSMNT_ACDIRMAX: ::c_int = 0x200000; // acdirmax field valid + +/* Flags valid only in kernel */ +pub const NFSMNT_INTERNAL: ::c_int = 0xfffc0000; // Bits set internally +pub const NFSMNT_HASWRITEVERF: ::c_int = 0x40000; // Has write verifier for V3 +pub const NFSMNT_GOTPATHCONF: ::c_int = 0x80000; // Got the V3 pathconf info +pub const NFSMNT_GOTFSINFO: ::c_int = 0x100000; // Got the V3 fsinfo +pub const NFSMNT_MNTD: ::c_int = 0x200000; // Mnt server for mnt point +pub const NFSMNT_DISMINPROG: ::c_int = 0x400000; // Dismount in progress +pub const NFSMNT_DISMNT: ::c_int = 0x800000; // Dismounted +pub const NFSMNT_SNDLOCK: ::c_int = 0x1000000; // Send socket lock +pub const NFSMNT_WANTSND: ::c_int = 0x2000000; // Want above +pub const NFSMNT_RCVLOCK: ::c_int = 0x4000000; // Rcv socket lock +pub const NFSMNT_WANTRCV: ::c_int = 0x8000000; // Want above +pub const NFSMNT_WAITAUTH: ::c_int = 0x10000000; // Wait for authentication +pub const NFSMNT_HASAUTH: ::c_int = 0x20000000; // Has authenticator +pub const NFSMNT_WANTAUTH: ::c_int = 0x40000000; // Wants an authenticator +pub const NFSMNT_AUTHERR: ::c_int = 0x80000000; // Authentication error + +pub const MSDOSFSMNT_SHORTNAME: ::c_int = 0x1; // Force old DOS short names only +pub const MSDOSFSMNT_LONGNAME: ::c_int = 0x2; // Force Win'95 long names +pub const MSDOSFSMNT_NOWIN95: ::c_int = 0x4; // Completely ignore Win95 entries + +pub const NTFS_MFLAG_CASEINS: ::c_int = 0x1; +pub const NTFS_MFLAG_ALLNAMES: ::c_int = 0x2; + +pub const TMPFS_ARGS_VERSION: ::c_int = 1; + +pub const MAP_STACK: ::c_int = 0x4000; + +// https://github.com/openbsd/src/blob/master/sys/net/if.h#L187 +pub const IFF_UP: ::c_int = 0x1; // interface is up +pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid +pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging +pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link +pub const IFF_STATICARP: ::c_int = 0x20; // only static ARP +pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated +pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress +pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit +pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast + +pub const PTHREAD_STACK_MIN: ::size_t = (1_usize << _MAX_PAGE_SHIFT); +pub const MINSIGSTKSZ: ::size_t = (3_usize << _MAX_PAGE_SHIFT); +pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + (1_usize << _MAX_PAGE_SHIFT) * 4; + +pub const PT_FIRSTMACH: ::c_int = 32; + +pub const SOCK_CLOEXEC: ::c_int = 0x8000; +pub const SOCK_NONBLOCK: ::c_int = 0x4000; +pub const SOCK_DNS: ::c_int = 0x1000; + +pub const BIOCGRSIG: ::c_ulong = 0x40044273; +pub const BIOCSRSIG: ::c_ulong = 0x80044272; +pub const BIOCSDLT: ::c_ulong = 0x8004427a; + +pub const PTRACE_FORK: ::c_int = 0x0002; + +pub const WCONTINUED: ::c_int = 8; + +fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES +} + +f! { + pub fn WIFCONTINUED(status: ::c_int) -> bool { + status & 0o177777 == 0o177777 + } + + pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { + (cmsg as *mut ::c_uchar) + .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) + -> *mut ::cmsghdr + { + if cmsg.is_null() { + return ::CMSG_FIRSTHDR(mhdr); + }; + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + + _ALIGN(::mem::size_of::<::cmsghdr>()); + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next > max { + 0 as *mut ::cmsghdr + } else { + (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) + as *mut ::cmsghdr + } + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize)) + as ::c_uint + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0o177) == 0o177 + } +} + +extern "C" { + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; + pub fn settimeofday( + tp: *const ::timeval, + tz: *const ::timezone, + ) -> ::c_int; + pub fn accept4( + s: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + flags: ::c_int, + ) -> ::c_int; + pub fn execvpe( + file: *const ::c_char, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + pub fn pledge( + promises: *const ::c_char, + execpromises: *const ::c_char, + ) -> ::c_int; + pub fn strtonum( + nptr: *const ::c_char, + minval: ::c_longlong, + maxval: ::c_longlong, + errstr: *mut *const ::c_char, + ) -> ::c_longlong; + pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; + pub fn chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int; + pub fn chflagsat( + fd: ::c_int, + path: *const ::c_char, + flags: ::c_uint, + atflag: ::c_int, + ) -> ::c_int; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + pub fn getnameinfo( + sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::size_t, + serv: *mut ::c_char, + servlen: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn kevent( + kq: ::c_int, + changelist: *const ::kevent, + nchanges: ::c_int, + eventlist: *mut ::kevent, + nevents: ::c_int, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn pthread_attr_getguardsize( + attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t, + ) -> ::c_int; + pub fn pthread_attr_getstack( + attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t, + ) -> ::c_int; + pub fn pthread_main_np() -> ::c_int; + pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); + pub fn pthread_stackseg_np( + thread: ::pthread_t, + sinfo: *mut ::stack_t, + ) -> ::c_int; + pub fn sysctl( + name: *const ::c_int, + namelen: ::c_uint, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; + pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; + pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; + pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; + pub fn ptrace( + request: ::c_int, + pid: ::pid_t, + addr: caddr_t, + data: ::c_int, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_union)] { + extern { + // these functions use statfs which uses the union mount_info: + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + } + } +} + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "sparc64")] { + mod sparc64; + pub use self::sparc64::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/sparc64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/sparc64.rs new file mode 100644 index 0000000..070fc93 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/sparc64.rs @@ -0,0 +1,8 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = i8; + +#[doc(hidden)] +pub const _ALIGNBYTES: usize = 0xf; + +pub const _MAX_PAGE_SHIFT: u32 = 13; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/x86.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/x86.rs new file mode 100644 index 0000000..e87d0ff --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/x86.rs @@ -0,0 +1,16 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = i8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 4 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/x86_64.rs new file mode 100644 index 0000000..263b6e1 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -0,0 +1,24 @@ +use PT_FIRSTMACH; + +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = i8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; + +pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/haiku/b32.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/haiku/b32.rs new file mode 100644 index 0000000..cce8864 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/haiku/b32.rs @@ -0,0 +1,3 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type time_t = i32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/haiku/b64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/haiku/b64.rs new file mode 100644 index 0000000..3e66f14 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/haiku/b64.rs @@ -0,0 +1,3 @@ +pub type c_ulong = u64; +pub type c_long = i64; +pub type time_t = i64; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/haiku/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/haiku/mod.rs new file mode 100644 index 0000000..d704a0b --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/haiku/mod.rs @@ -0,0 +1,1531 @@ +pub type rlim_t = ::uintptr_t; +pub type sa_family_t = u8; +pub type pthread_key_t = ::c_int; +pub type nfds_t = ::c_long; +pub type tcflag_t = ::c_uint; +pub type speed_t = ::c_uint; +pub type c_char = i8; +pub type clock_t = i32; +pub type clockid_t = i32; +pub type suseconds_t = i32; +pub type wchar_t = i32; +pub type off_t = i64; +pub type ino_t = i64; +pub type blkcnt_t = i64; +pub type blksize_t = i32; +pub type dev_t = i32; +pub type mode_t = u32; +pub type nlink_t = i32; +pub type useconds_t = u32; +pub type socklen_t = u32; +pub type pthread_t = ::uintptr_t; +pub type pthread_mutexattr_t = ::uintptr_t; +pub type pthread_rwlockattr_t = ::uintptr_t; +pub type sigset_t = u64; +pub type fsblkcnt_t = i64; +pub type fsfilcnt_t = i64; +pub type pthread_attr_t = *mut ::c_void; +pub type nl_item = ::c_int; +pub type id_t = i32; +pub type idtype_t = ::c_uint; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum timezone {} +impl ::Copy for timezone {} +impl ::Clone for timezone { + fn clone(&self) -> timezone { + *self + } +} + +s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [::c_char; 30], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [u8; 24], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut ::sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct fd_set { + fds_bits: [c_ulong; FD_SETSIZE / ULONG_SIZE], + } + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + pub tm_gmtoff: ::c_long, + pub tm_zone: *const ::c_char, + } + + pub struct utsname { + pub sysname: [::c_char; 32], + pub nodename: [::c_char; 32], + pub release: [::c_char; 32], + pub version: [::c_char; 32], + pub machine: [::c_char; 32], + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::socklen_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::size_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::c_char, + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + pub c_cc: [::cc_t; ::NCCS], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_size: off_t, + pub st_rdev: dev_t, + pub st_blksize: blksize_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_crtime: time_t, + pub st_crtime_nsec: c_long, + pub st_type: u32, + pub st_blocks: blkcnt_t, + } + + pub struct glob_t { + pub gl_pathc: ::size_t, + __unused1: ::size_t, + pub gl_offs: ::size_t, + __unused2: ::size_t, + pub gl_pathv: *mut *mut c_char, + + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + __unused6: *mut ::c_void, + __unused7: *mut ::c_void, + __unused8: *mut ::c_void, + } + + pub struct pthread_mutex_t { + flags: u32, + lock: i32, + unused: i32, + owner: i32, + owner_count: i32, + } + + pub struct pthread_cond_t { + flags: u32, + unused: i32, + mutex: *mut ::c_void, + waiter_count: i32, + lock: i32, + } + + pub struct pthread_rwlock_t { + flags: u32, + owner: i32, + lock_sem: i32, // this is actually a union + lock_count: i32, + reader_count: i32, + writer_count: i32, + waiters: [*mut ::c_void; 2], + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + pub pw_gecos: *mut ::c_char, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub si_pid: ::pid_t, + pub si_uid: ::uid_t, + pub si_addr: *mut ::c_void, + pub si_status: ::c_int, + pub si_band: c_long, + pub sigval: *mut ::c_void, + } + + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + sa_userdata: *mut ::c_void, + } + + pub struct sem_t { + pub se_type: i32, + pub se_named_id: i32, // this is actually a union + pub se_unnamed: i32, + pub se_padding: [i32; 4], + } + + pub struct pthread_condattr_t { + pub process_shared: bool, + pub clock_id: i32, + } +} + +s_no_extra_traits! { + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 126] + } + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: [u8; 6], + __ss_pad2: u64, + __ss_pad3: [u8; 112], + } + pub struct dirent { + pub d_dev: dev_t, + pub d_pdev: dev_t, + pub d_ino: ino_t, + pub d_pino: i64, + pub d_reclen: ::c_ushort, + pub d_name: [::c_char; 1024], // Max length is _POSIX_PATH_MAX + } + + pub struct sigevent { + pub sigev_notify: ::c_int, + pub sigev_signo: ::c_int, + pub sigev_value: ::sigval, + __unused1: *mut ::c_void, // actually a function pointer + pub sigev_notify_attributes: *mut ::pthread_attr_t, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_len == other.sun_len + && self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sockaddr_un {} + impl ::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_len", &self.sun_len) + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } + } + impl ::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_len.hash(state); + self.sun_family.hash(state); + self.sun_path.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_len == other.ss_len + && self.ss_family == other.ss_family + && self + .__ss_pad1 + .iter() + .zip(other.__ss_pad1.iter()) + .all(|(a, b)| a == b) + && self.__ss_pad2 == other.__ss_pad2 + && self + .__ss_pad3 + .iter() + .zip(other.__ss_pad3.iter()) + .all(|(a, b)| a == b) + } + } + impl Eq for sockaddr_storage {} + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_len", &self.ss_len) + .field("ss_family", &self.ss_family) + .field("__ss_pad1", &self.__ss_pad1) + .field("__ss_pad2", &self.__ss_pad2) + // FIXME: .field("__ss_pad3", &self.__ss_pad3) + .finish() + } + } + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_len.hash(state); + self.ss_family.hash(state); + self.__ss_pad1.hash(state); + self.__ss_pad2.hash(state); + self.__ss_pad3.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_dev == other.d_dev + && self.d_pdev == other.d_pdev + && self.d_ino == other.d_ino + && self.d_pino == other.d_pino + && self.d_reclen == other.d_reclen + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_dev", &self.d_dev) + .field("d_pdev", &self.d_pdev) + .field("d_ino", &self.d_ino) + .field("d_pino", &self.d_pino) + .field("d_reclen", &self.d_reclen) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_dev.hash(state); + self.d_pdev.hash(state); + self.d_ino.hash(state); + self.d_pino.hash(state); + self.d_reclen.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_notify == other.sigev_notify + && self.sigev_signo == other.sigev_signo + && self.sigev_value == other.sigev_value + && self.sigev_notify_attributes + == other.sigev_notify_attributes + } + } + impl Eq for sigevent {} + impl ::fmt::Debug for sigevent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sigevent") + .field("sigev_notify", &self.sigev_notify) + .field("sigev_signo", &self.sigev_signo) + .field("sigev_value", &self.sigev_value) + .field("sigev_notify_attributes", + &self.sigev_notify_attributes) + .finish() + } + } + impl ::hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_notify.hash(state); + self.sigev_signo.hash(state); + self.sigev_value.hash(state); + self.sigev_notify_attributes.hash(state); + } + } + } +} + +// intentionally not public, only used for fd_set +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + const ULONG_SIZE: usize = 32; + } else if #[cfg(target_pointer_width = "64")] { + const ULONG_SIZE: usize = 64; + } else { + // Unknown target_pointer_width + } +} + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 2147483647; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 2; +pub const _IOLBF: ::c_int = 1; + +pub const F_DUPFD: ::c_int = 0x0001; +pub const F_GETFD: ::c_int = 0x0002; +pub const F_SETFD: ::c_int = 0x0004; +pub const F_GETFL: ::c_int = 0x0008; +pub const F_SETFL: ::c_int = 0x0010; +pub const F_GETLK: ::c_int = 0x0020; +pub const F_SETLK: ::c_int = 0x0080; +pub const F_SETLKW: ::c_int = 0x0100; +pub const F_DUPFD_CLOEXEC: ::c_int = 0x0200; + +pub const F_RDLCK: ::c_int = 0x0040; +pub const F_UNLCK: ::c_int = 0x0200; +pub const F_WRLCK: ::c_int = 0x0400; + +pub const AT_FDCWD: ::c_int = -1; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x01; +pub const AT_SYMLINK_FOLLOW: ::c_int = 0x02; +pub const AT_REMOVEDIR: ::c_int = 0x04; +pub const AT_EACCESS: ::c_int = 0x08; + +pub const POLLIN: ::c_short = 0x0001; +pub const POLLOUT: ::c_short = 0x0002; +pub const POLLRDNORM: ::c_short = POLLIN; +pub const POLLWRNORM: ::c_short = POLLOUT; +pub const POLLRDBAND: ::c_short = 0x0008; +pub const POLLWRBAND: ::c_short = 0x0010; +pub const POLLPRI: ::c_short = 0x0020; +pub const POLLERR: ::c_short = 0x0004; +pub const POLLHUP: ::c_short = 0x0080; +pub const POLLNVAL: ::c_short = 0x1000; + +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; + +pub const CLOCK_REALTIME: ::c_int = -1; +pub const CLOCK_MONOTONIC: ::c_int = 0; + +pub const RLIMIT_CORE: ::c_int = 0; +pub const RLIMIT_CPU: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_FSIZE: ::c_int = 3; +pub const RLIMIT_NOFILE: ::c_int = 4; +pub const RLIMIT_STACK: ::c_int = 5; +pub const RLIMIT_AS: ::c_int = 6; +// Haiku specific +pub const RLIMIT_NOVMON: ::c_int = 7; +pub const RLIMIT_NLIMITS: ::c_int = 8; + +pub const RUSAGE_SELF: ::c_int = 0; + +pub const RTLD_LAZY: ::c_int = 0; + +pub const NCCS: usize = 11; + +pub const O_RDONLY: ::c_int = 0x0000; +pub const O_WRONLY: ::c_int = 0x0001; +pub const O_RDWR: ::c_int = 0x0002; +pub const O_ACCMODE: ::c_int = 0x0003; + +pub const O_EXCL: ::c_int = 0x0100; +pub const O_CREAT: ::c_int = 0x0200; +pub const O_TRUNC: ::c_int = 0x0400; +pub const O_NOCTTY: ::c_int = 0x1000; +pub const O_NOTRAVERSE: ::c_int = 0x2000; + +pub const O_CLOEXEC: ::c_int = 0x00000040; +pub const O_NONBLOCK: ::c_int = 0x00000080; +pub const O_APPEND: ::c_int = 0x00000800; +pub const O_SYNC: ::c_int = 0x00010000; +pub const O_RSYNC: ::c_int = 0x00020000; +pub const O_DSYNC: ::c_int = 0x00040000; +pub const O_NOFOLLOW: ::c_int = 0x00080000; +pub const O_NOCACHE: ::c_int = 0x00100000; +pub const O_DIRECTORY: ::c_int = 0x00200000; + +pub const S_IFIFO: ::mode_t = 4096; +pub const S_IFCHR: ::mode_t = 8192; +pub const S_IFBLK: ::mode_t = 24576; +pub const S_IFDIR: ::mode_t = 16384; +pub const S_IFREG: ::mode_t = 32768; +pub const S_IFLNK: ::mode_t = 40960; +pub const S_IFSOCK: ::mode_t = 49152; +pub const S_IFMT: ::mode_t = 61440; +pub const S_IRWXU: ::mode_t = 448; +pub const S_IXUSR: ::mode_t = 64; +pub const S_IWUSR: ::mode_t = 128; +pub const S_IRUSR: ::mode_t = 256; +pub const S_IRWXG: ::mode_t = 70; +pub const S_IXGRP: ::mode_t = 10; +pub const S_IWGRP: ::mode_t = 20; +pub const S_IRGRP: ::mode_t = 40; +pub const S_IRWXO: ::mode_t = 7; +pub const S_IXOTH: ::mode_t = 1; +pub const S_IWOTH: ::mode_t = 2; +pub const S_IROTH: ::mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; + +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGCHLD: ::c_int = 5; +pub const SIGABRT: ::c_int = 6; +pub const SIGPIPE: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSTOP: ::c_int = 10; +pub const SIGSEGV: ::c_int = 11; +pub const SIGCONT: ::c_int = 12; +pub const SIGTSTP: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; +pub const SIGTTIN: ::c_int = 16; +pub const SIGTTOU: ::c_int = 17; +pub const SIGUSR1: ::c_int = 18; +pub const SIGUSR2: ::c_int = 19; +pub const SIGWINCH: ::c_int = 20; +pub const SIGKILLTHR: ::c_int = 21; +pub const SIGTRAP: ::c_int = 22; +pub const SIGPOLL: ::c_int = 23; +pub const SIGPROF: ::c_int = 24; +pub const SIGSYS: ::c_int = 25; +pub const SIGURG: ::c_int = 26; +pub const SIGVTALRM: ::c_int = 27; +pub const SIGXCPU: ::c_int = 28; +pub const SIGXFSZ: ::c_int = 29; +pub const SIGBUS: ::c_int = 30; + +pub const SIG_BLOCK: ::c_int = 1; +pub const SIG_UNBLOCK: ::c_int = 2; +pub const SIG_SETMASK: ::c_int = 3; + +pub const SIGEV_NONE: ::c_int = 0; +pub const SIGEV_SIGNAL: ::c_int = 1; +pub const SIGEV_THREAD: ::c_int = 2; + +pub const EAI_AGAIN: ::c_int = 2; +pub const EAI_BADFLAGS: ::c_int = 3; +pub const EAI_FAIL: ::c_int = 4; +pub const EAI_FAMILY: ::c_int = 5; +pub const EAI_MEMORY: ::c_int = 6; +pub const EAI_NODATA: ::c_int = 7; +pub const EAI_NONAME: ::c_int = 8; +pub const EAI_SERVICE: ::c_int = 9; +pub const EAI_SOCKTYPE: ::c_int = 10; +pub const EAI_SYSTEM: ::c_int = 11; +pub const EAI_OVERFLOW: ::c_int = 14; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const LC_ALL: ::c_int = 0; +pub const LC_COLLATE: ::c_int = 1; +pub const LC_CTYPE: ::c_int = 2; +pub const LC_MONETARY: ::c_int = 3; +pub const LC_NUMERIC: ::c_int = 4; +pub const LC_TIME: ::c_int = 5; +pub const LC_MESSAGES: ::c_int = 6; + +// TODO: Haiku does not have MAP_FILE, but libstd/os.rs requires it +pub const MAP_FILE: ::c_int = 0x00; +pub const MAP_SHARED: ::c_int = 0x01; +pub const MAP_PRIVATE: ::c_int = 0x02; +pub const MAP_FIXED: ::c_int = 0x04; +pub const MAP_ANONYMOUS: ::c_int = 0x08; +pub const MAP_ANON: ::c_int = MAP_ANONYMOUS; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +pub const MS_ASYNC: ::c_int = 0x01; +pub const MS_INVALIDATE: ::c_int = 0x04; +pub const MS_SYNC: ::c_int = 0x02; + +pub const E2BIG: ::c_int = -2147454975; +pub const ECHILD: ::c_int = -2147454974; +pub const EDEADLK: ::c_int = -2147454973; +pub const EFBIG: ::c_int = -2147454972; +pub const EMLINK: ::c_int = -2147454971; +pub const ENFILE: ::c_int = -2147454970; +pub const ENODEV: ::c_int = -2147454969; +pub const ENOLCK: ::c_int = -2147454968; +pub const ENOSYS: ::c_int = -2147454967; +pub const ENOTTY: ::c_int = -2147454966; +pub const ENXIO: ::c_int = -2147454965; +pub const ESPIPE: ::c_int = -2147454964; +pub const ESRCH: ::c_int = -2147454963; +pub const EFPOS: ::c_int = -2147457962; +pub const ESIGPARM: ::c_int = -2147457961; +pub const EDOM: ::c_int = -2147454960; +pub const ERANGE: ::c_int = -2147454959; +pub const EPROTOTYPE: ::c_int = -2147454958; +pub const EPROTONOSUPPORT: ::c_int = -2147454957; +pub const EPFNOSUPPORT: ::c_int = -2147454956; +pub const EAFNOSUPPORT: ::c_int = -2147454955; +pub const EADDRINUSE: ::c_int = -2147454954; +pub const EADDRNOTAVAIL: ::c_int = -2147454953; +pub const ENETDOWN: ::c_int = -2147454952; +pub const ENETUNREACH: ::c_int = -2147454951; +pub const ENETRESET: ::c_int = -2147454950; +pub const ECONNABORTED: ::c_int = -2147454949; +pub const ECONNRESET: ::c_int = -2147454948; +pub const EISCONN: ::c_int = -2147454947; +pub const ENOTCONN: ::c_int = -2147454946; +pub const ESHUTDOWN: ::c_int = -2147454945; +pub const ECONNREFUSED: ::c_int = -2147454944; +pub const EHOSTUNREACH: ::c_int = -2147454943; +pub const ENOPROTOOPT: ::c_int = -2147454942; +pub const ENOBUFS: ::c_int = -2147454941; +pub const EINPROGRESS: ::c_int = -2147454940; +pub const EALREADY: ::c_int = -2147454939; +pub const EILSEQ: ::c_int = -2147454938; +pub const ENOMSG: ::c_int = -2147454937; +pub const ESTALE: ::c_int = -2147454936; +pub const EOVERFLOW: ::c_int = -2147454935; +pub const EMSGSIZE: ::c_int = -2147454934; +pub const EOPNOTSUPP: ::c_int = -2147454933; +pub const ENOTSOCK: ::c_int = -2147454932; +pub const EHOSTDOWN: ::c_int = -2147454931; +pub const EBADMSG: ::c_int = -2147454930; +pub const ECANCELED: ::c_int = -2147454929; +pub const EDESTADDRREQ: ::c_int = -2147454928; +pub const EDQUOT: ::c_int = -2147454927; +pub const EIDRM: ::c_int = -2147454926; +pub const EMULTIHOP: ::c_int = -2147454925; +pub const ENODATA: ::c_int = -2147454924; +pub const ENOLINK: ::c_int = -2147454923; +pub const ENOSR: ::c_int = -2147454922; +pub const ENOSTR: ::c_int = -2147454921; +pub const ENOTSUP: ::c_int = -2147454920; +pub const EPROTO: ::c_int = -2147454919; +pub const ETIME: ::c_int = -2147454918; +pub const ETXTBSY: ::c_int = -2147454917; +pub const ENOATTR: ::c_int = -2147454916; + +// INT_MIN +pub const ENOMEM: ::c_int = -2147454976; + +// POSIX errors that can be mapped to BeOS error codes +pub const EACCES: ::c_int = -2147483646; +pub const EINTR: ::c_int = -2147483638; +pub const EIO: ::c_int = -2147483647; +pub const EBUSY: ::c_int = -2147483634; +pub const EFAULT: ::c_int = -2147478783; +pub const ETIMEDOUT: ::c_int = -2147483639; +pub const EAGAIN: ::c_int = -2147483637; +pub const EWOULDBLOCK: ::c_int = -2147483637; +pub const EBADF: ::c_int = -2147459072; +pub const EEXIST: ::c_int = -2147459070; +pub const EINVAL: ::c_int = -2147483643; +pub const ENAMETOOLONG: ::c_int = -2147459068; +pub const ENOENT: ::c_int = -2147459069; +pub const EPERM: ::c_int = -2147483633; +pub const ENOTDIR: ::c_int = -2147459067; +pub const EISDIR: ::c_int = -2147459063; +pub const ENOTEMPTY: ::c_int = -2147459066; +pub const ENOSPC: ::c_int = -2147459065; +pub const EROFS: ::c_int = -2147459064; +pub const EMFILE: ::c_int = -2147459062; +pub const EXDEV: ::c_int = -2147459061; +pub const ELOOP: ::c_int = -2147459060; +pub const ENOEXEC: ::c_int = -2147478782; +pub const EPIPE: ::c_int = -2147459059; + +pub const IPPROTO_RAW: ::c_int = 255; + +// These are prefixed with POSIX_ on Haiku +pub const MADV_NORMAL: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_RANDOM: ::c_int = 3; +pub const MADV_WILLNEED: ::c_int = 4; +pub const MADV_DONTNEED: ::c_int = 5; + +// https://github.com/haiku/haiku/blob/master/headers/posix/net/if.h#L80 +pub const IFF_UP: ::c_int = 0x0001; +pub const IFF_BROADCAST: ::c_int = 0x0002; // valid broadcast address +pub const IFF_LOOPBACK: ::c_int = 0x0008; +pub const IFF_POINTOPOINT: ::c_int = 0x0010; // point-to-point link +pub const IFF_NOARP: ::c_int = 0x0040; // no address resolution +pub const IFF_AUTOUP: ::c_int = 0x0080; // auto dial +pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets +pub const IFF_SIMPLEX: ::c_int = 0x0800; // doesn't receive own transmissions +pub const IFF_LINK: ::c_int = 0x1000; // has link +pub const IFF_AUTO_CONFIGURED: ::c_int = 0x2000; +pub const IFF_CONFIGURING: ::c_int = 0x4000; +pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast + +pub const AF_UNSEC: ::c_int = 0; +pub const AF_INET: ::c_int = 1; +pub const AF_APPLETALK: ::c_int = 2; +pub const AF_ROUTE: ::c_int = 3; +pub const AF_LINK: ::c_int = 4; +pub const AF_INET6: ::c_int = 5; +pub const AF_DLI: ::c_int = 6; +pub const AF_IPX: ::c_int = 7; +pub const AF_NOTIFY: ::c_int = 8; +pub const AF_LOCAL: ::c_int = 9; +pub const AF_UNIX: ::c_int = AF_LOCAL; +pub const AF_BLUETOOTH: ::c_int = 10; + +pub const IP_OPTIONS: ::c_int = 1; +pub const IP_HDRINCL: ::c_int = 2; +pub const IP_TOS: ::c_int = 3; +pub const IP_TTL: ::c_int = 4; +pub const IP_RECVOPTS: ::c_int = 5; +pub const IP_RECVRETOPTS: ::c_int = 6; +pub const IP_RECVDSTADDR: ::c_int = 7; +pub const IP_RETOPTS: ::c_int = 8; +pub const IP_MULTICAST_IF: ::c_int = 9; +pub const IP_MULTICAST_TTL: ::c_int = 10; +pub const IP_MULTICAST_LOOP: ::c_int = 11; +pub const IP_ADD_MEMBERSHIP: ::c_int = 12; +pub const IP_DROP_MEMBERSHIP: ::c_int = 13; +pub const IP_BLOCK_SOURCE: ::c_int = 14; +pub const IP_UNBLOCK_SOURCE: ::c_int = 15; +pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 16; +pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 17; + +pub const TCP_NODELAY: ::c_int = 0x01; +pub const TCP_MAXSEG: ::c_int = 0x02; +pub const TCP_NOPUSH: ::c_int = 0x04; +pub const TCP_NOOPT: ::c_int = 0x08; + +pub const IPV6_MULTICAST_IF: ::c_int = 24; +pub const IPV6_MULTICAST_HOPS: ::c_int = 25; +pub const IPV6_MULTICAST_LOOP: ::c_int = 26; +pub const IPV6_UNICAST_HOPS: ::c_int = 27; +pub const IPV6_JOIN_GROUP: ::c_int = 28; +pub const IPV6_LEAVE_GROUP: ::c_int = 29; +pub const IPV6_V6ONLY: ::c_int = 30; +pub const IPV6_PKTINFO: ::c_int = 31; +pub const IPV6_RECVPKTINFO: ::c_int = 32; +pub const IPV6_HOPLIMIT: ::c_int = 33; +pub const IPV6_REVCHOPLIMIT: ::c_int = 34; +pub const IPV6_HOPOPTS: ::c_int = 35; +pub const IPV6_DSTOPTS: ::c_int = 36; +pub const IPV6_RTHDR: ::c_int = 37; + +pub const MSG_OOB: ::c_int = 0x0001; +pub const MSG_PEEK: ::c_int = 0x0002; +pub const MSG_DONTROUTE: ::c_int = 0x0004; +pub const MSG_EOR: ::c_int = 0x0008; +pub const MSG_TRUNC: ::c_int = 0x0010; +pub const MSG_CTRUNC: ::c_int = 0x0020; +pub const MSG_WAITALL: ::c_int = 0x0040; +pub const MSG_DONTWAIT: ::c_int = 0x0080; +pub const MSG_BCAST: ::c_int = 0x0100; +pub const MSG_MCAST: ::c_int = 0x0200; +pub const MSG_EOF: ::c_int = 0x0400; +pub const MSG_NOSIGNAL: ::c_int = 0x0800; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 0x01; +pub const LOCK_EX: ::c_int = 0x02; +pub const LOCK_NB: ::c_int = 0x04; +pub const LOCK_UN: ::c_int = 0x08; + +pub const SIGSTKSZ: ::size_t = 16384; + +pub const PATH_MAX: ::c_int = 1024; + +pub const SA_NOCLDSTOP: ::c_int = 0x01; +pub const SA_NOCLDWAIT: ::c_int = 0x02; +pub const SA_RESETHAND: ::c_int = 0x04; +pub const SA_NODEFER: ::c_int = 0x08; +pub const SA_RESTART: ::c_int = 0x10; +pub const SA_ONSTACK: ::c_int = 0x20; +pub const SA_SIGINFO: ::c_int = 0x40; +pub const SA_NOMASK: ::c_int = SA_NODEFER; +pub const SA_STACK: ::c_int = SA_ONSTACK; +pub const SA_ONESHOT: ::c_int = SA_RESETHAND; + +pub const FD_SETSIZE: usize = 1024; + +pub const RTLD_LOCAL: ::c_int = 0x0; +pub const RTLD_NOW: ::c_int = 0x1; +pub const RTLD_GLOBAL: ::c_int = 0x2; +pub const RTLD_DEFAULT: *mut ::c_void = 0isize as *mut ::c_void; + +pub const BUFSIZ: ::c_uint = 8192; +pub const FILENAME_MAX: ::c_uint = 256; +pub const FOPEN_MAX: ::c_uint = 128; +pub const L_tmpnam: ::c_uint = 512; +pub const TMP_MAX: ::c_uint = 32768; + +pub const _PC_CHOWN_RESTRICTED: ::c_int = 1; +pub const _PC_MAX_CANON: ::c_int = 2; +pub const _PC_MAX_INPUT: ::c_int = 3; +pub const _PC_NAME_MAX: ::c_int = 4; +pub const _PC_NO_TRUNC: ::c_int = 5; +pub const _PC_PATH_MAX: ::c_int = 6; +pub const _PC_PIPE_BUF: ::c_int = 7; +pub const _PC_VDISABLE: ::c_int = 8; +pub const _PC_LINK_MAX: ::c_int = 25; +pub const _PC_SYNC_IO: ::c_int = 26; +pub const _PC_ASYNC_IO: ::c_int = 27; +pub const _PC_PRIO_IO: ::c_int = 28; +pub const _PC_SOCK_MAXBUF: ::c_int = 29; +pub const _PC_FILESIZEBITS: ::c_int = 30; +pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 31; +pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 32; +pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 33; +pub const _PC_REC_XFER_ALIGN: ::c_int = 34; +pub const _PC_ALLOC_SIZE_MIN: ::c_int = 35; +pub const _PC_SYMLINK_MAX: ::c_int = 36; +pub const _PC_2_SYMLINKS: ::c_int = 37; +pub const _PC_XATTR_EXISTS: ::c_int = 38; +pub const _PC_XATTR_ENABLED: ::c_int = 39; + +pub const FIONBIO: ::c_int = 0xbe000000; + +pub const _SC_ARG_MAX: ::c_int = 15; +pub const _SC_CHILD_MAX: ::c_int = 16; +pub const _SC_CLK_TCK: ::c_int = 17; +pub const _SC_JOB_CONTROL: ::c_int = 18; +pub const _SC_NGROUPS_MAX: ::c_int = 19; +pub const _SC_OPEN_MAX: ::c_int = 20; +pub const _SC_SAVED_IDS: ::c_int = 21; +pub const _SC_STREAM_MAX: ::c_int = 22; +pub const _SC_TZNAME_MAX: ::c_int = 23; +pub const _SC_VERSION: ::c_int = 24; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 25; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 26; +pub const _SC_PAGESIZE: ::c_int = 27; +pub const _SC_PAGE_SIZE: ::c_int = 27; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 28; +pub const _SC_SEM_VALUE_MAX: ::c_int = 29; +pub const _SC_SEMAPHORES: ::c_int = 30; +pub const _SC_THREADS: ::c_int = 31; +pub const _SC_IOV_MAX: ::c_int = 32; +pub const _SC_UIO_MAXIOV: ::c_int = 32; +pub const _SC_NPROCESSORS_CONF: ::c_int = 34; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 35; +pub const _SC_ATEXIT_MAX: ::c_int = 37; +pub const _SC_PASS_MAX: ::c_int = 39; +pub const _SC_PHYS_PAGES: ::c_int = 40; +pub const _SC_AVPHYS_PAGES: ::c_int = 41; +pub const _SC_PIPE: ::c_int = 42; +pub const _SC_SELECT: ::c_int = 43; +pub const _SC_POLL: ::c_int = 44; +pub const _SC_MAPPED_FILES: ::c_int = 45; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 46; +pub const _SC_THREAD_STACK_MIN: ::c_int = 47; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 48; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 49; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 50; +pub const _SC_REALTIME_SIGNALS: ::c_int = 51; +pub const _SC_MEMORY_PROTECTION: ::c_int = 52; +pub const _SC_SIGQUEUE_MAX: ::c_int = 53; +pub const _SC_RTSIG_MAX: ::c_int = 54; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 55; +pub const _SC_DELAYTIMER_MAX: ::c_int = 56; +pub const _SC_TIMER_MAX: ::c_int = 57; +pub const _SC_TIMERS: ::c_int = 58; +pub const _SC_CPUTIME: ::c_int = 59; +pub const _SC_THREAD_CPUTIME: ::c_int = 60; + +pub const PTHREAD_STACK_MIN: ::size_t = 8192; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + flags: 0, + lock: 0, + unused: -42, + owner: -1, + owner_count: 0, +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + flags: 0, + unused: -42, + mutex: 0 as *mut _, + waiter_count: 0, + lock: 0, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + flags: 0, + owner: -1, + lock_sem: 0, + lock_count: 0, + reader_count: 0, + writer_count: 0, + waiters: [0 as *mut _; 2], +}; + +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = 0; +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 3; + +pub const FIOCLEX: c_ulong = 0; // TODO: does not exist on Haiku! + +pub const RUSAGE_CHILDREN: ::c_int = -1; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_SEQPACKET: ::c_int = 5; + +pub const SOL_SOCKET: ::c_int = -1; +pub const SO_ACCEPTCONN: ::c_int = 0x00000001; +pub const SO_BROADCAST: ::c_int = 0x00000002; +pub const SO_DEBUG: ::c_int = 0x00000004; +pub const SO_DONTROUTE: ::c_int = 0x00000008; +pub const SO_KEEPALIVE: ::c_int = 0x00000010; +pub const SO_OOBINLINE: ::c_int = 0x00000020; +pub const SO_REUSEADDR: ::c_int = 0x00000040; +pub const SO_REUSEPORT: ::c_int = 0x00000080; +pub const SO_USELOOPBACK: ::c_int = 0x00000100; +pub const SO_LINGER: ::c_int = 0x00000200; +pub const SO_SNDBUF: ::c_int = 0x40000001; +pub const SO_SNDLOWAT: ::c_int = 0x40000002; +pub const SO_SNDTIMEO: ::c_int = 0x40000003; +pub const SO_RCVBUF: ::c_int = 0x40000004; +pub const SO_RCVLOWAT: ::c_int = 0x40000005; +pub const SO_RCVTIMEO: ::c_int = 0x40000006; +pub const SO_ERROR: ::c_int = 0x40000007; +pub const SO_TYPE: ::c_int = 0x40000008; +pub const SO_NONBLOCK: ::c_int = 0x40000009; +pub const SO_BINDTODEVICE: ::c_int = 0x4000000a; +pub const SO_PEERCRED: ::c_int = 0x4000000b; + +pub const SCM_RIGHTS: ::c_int = 0x01; + +pub const NI_MAXHOST: ::size_t = 1025; + +pub const WNOHANG: ::c_int = 0x01; +pub const WUNTRACED: ::c_int = 0x02; +pub const WCONTINUED: ::c_int = 0x04; +pub const WEXITED: ::c_int = 0x08; +pub const WSTOPPED: ::c_int = 0x10; +pub const WNOWAIT: ::c_int = 0x20; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + +pub const UTIME_OMIT: c_long = 1000000001; +pub const UTIME_NOW: c_long = 1000000000; + +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VEOF: usize = 4; +pub const VEOL: usize = 5; +pub const VMIN: usize = 4; +pub const VTIME: usize = 5; +pub const VEOL2: usize = 6; +pub const VSWTCH: usize = 7; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; + +pub const IGNBRK: ::tcflag_t = 0x01; +pub const BRKINT: ::tcflag_t = 0x02; +pub const IGNPAR: ::tcflag_t = 0x04; +pub const PARMRK: ::tcflag_t = 0x08; +pub const INPCK: ::tcflag_t = 0x10; +pub const ISTRIP: ::tcflag_t = 0x20; +pub const INLCR: ::tcflag_t = 0x40; +pub const IGNCR: ::tcflag_t = 0x80; +pub const ICRNL: ::tcflag_t = 0x100; +pub const IUCLC: ::tcflag_t = 0x200; +pub const IXON: ::tcflag_t = 0x400; +pub const IXANY: ::tcflag_t = 0x800; +pub const IXOFF: ::tcflag_t = 0x1000; + +pub const OPOST: ::tcflag_t = 0x00000001; +pub const OLCUC: ::tcflag_t = 0x00000002; +pub const ONLCR: ::tcflag_t = 0x00000004; +pub const OCRNL: ::tcflag_t = 0x00000008; +pub const ONOCR: ::tcflag_t = 0x00000010; +pub const ONLRET: ::tcflag_t = 0x00000020; +pub const OFILL: ::tcflag_t = 0x00000040; +pub const OFDEL: ::tcflag_t = 0x00000080; +pub const NLDLY: ::tcflag_t = 0x00000100; +pub const NL0: ::tcflag_t = 0x00000000; +pub const NL1: ::tcflag_t = 0x00000100; +pub const CRDLY: ::tcflag_t = 0x00000600; +pub const CR0: ::tcflag_t = 0x00000000; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const TABDLY: ::tcflag_t = 0x00001800; +pub const TAB0: ::tcflag_t = 0x00000000; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const BSDLY: ::tcflag_t = 0x00002000; +pub const BS0: ::tcflag_t = 0x00000000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VTDLY: ::tcflag_t = 0x00004000; +pub const VT0: ::tcflag_t = 0x00000000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const FFDLY: ::tcflag_t = 0x00008000; +pub const FF0: ::tcflag_t = 0x00000000; +pub const FF1: ::tcflag_t = 0x00008000; + +pub const CSIZE: ::tcflag_t = 0x00000020; +pub const CS5: ::tcflag_t = 0x00000000; +pub const CS6: ::tcflag_t = 0x00000000; +pub const CS7: ::tcflag_t = 0x00000000; +pub const CS8: ::tcflag_t = 0x00000020; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const XLOBLK: ::tcflag_t = 0x00001000; +pub const CTSFLOW: ::tcflag_t = 0x00002000; +pub const RTSFLOW: ::tcflag_t = 0x00004000; +pub const CRTSCTS: ::tcflag_t = RTSFLOW | CTSFLOW; + +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const XCASE: ::tcflag_t = 0x00000004; +pub const ECHO: ::tcflag_t = 0x00000008; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const IEXTEN: ::tcflag_t = 0x00000200; +pub const ECHOCTL: ::tcflag_t = 0x00000400; +pub const ECHOPRT: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00001000; +pub const FLUSHO: ::tcflag_t = 0x00002000; +pub const PENDIN: ::tcflag_t = 0x00004000; + +pub const TCGB_CTS: ::c_int = 0x01; +pub const TCGB_DSR: ::c_int = 0x02; +pub const TCGB_RI: ::c_int = 0x04; +pub const TCGB_DCD: ::c_int = 0x08; +pub const TIOCM_CTS: ::c_int = TCGB_CTS; +pub const TIOCM_CD: ::c_int = TCGB_DCD; +pub const TIOCM_CAR: ::c_int = TIOCM_CD; +pub const TIOCM_RI: ::c_int = TCGB_RI; +pub const TIOCM_DSR: ::c_int = TCGB_DSR; +pub const TIOCM_DTR: ::c_int = 0x10; +pub const TIOCM_RTS: ::c_int = 0x20; + +pub const B0: speed_t = 0x00; +pub const B50: speed_t = 0x01; +pub const B75: speed_t = 0x02; +pub const B110: speed_t = 0x03; +pub const B134: speed_t = 0x04; +pub const B150: speed_t = 0x05; +pub const B200: speed_t = 0x06; +pub const B300: speed_t = 0x07; +pub const B600: speed_t = 0x08; +pub const B1200: speed_t = 0x09; +pub const B1800: speed_t = 0x0A; +pub const B2400: speed_t = 0x0B; +pub const B4800: speed_t = 0x0C; +pub const B9600: speed_t = 0x0D; +pub const B19200: speed_t = 0x0E; +pub const B38400: speed_t = 0x0F; +pub const B57600: speed_t = 0x10; +pub const B115200: speed_t = 0x11; +pub const B230400: speed_t = 0x12; +pub const B31250: speed_t = 0x13; + +pub const TCSANOW: ::c_int = 0x01; +pub const TCSADRAIN: ::c_int = 0x02; +pub const TCSAFLUSH: ::c_int = 0x04; + +pub const TCOOFF: ::c_int = 0x01; +pub const TCOON: ::c_int = 0x02; +pub const TCIOFF: ::c_int = 0x04; +pub const TCION: ::c_int = 0x08; + +pub const TCIFLUSH: ::c_int = 0x01; +pub const TCOFLUSH: ::c_int = 0x02; +pub const TCIOFLUSH: ::c_int = 0x03; + +pub const TCGETA: ::c_int = 0x8000; +pub const TCSETA: ::c_int = TCGETA + 1; +pub const TCSETAF: ::c_int = TCGETA + 2; +pub const TCSETAW: ::c_int = TCGETA + 3; +pub const TCWAITEVENT: ::c_int = TCGETA + 4; +pub const TCSBRK: ::c_int = TCGETA + 5; +pub const TCFLSH: ::c_int = TCGETA + 6; +pub const TCXONC: ::c_int = TCGETA + 7; +pub const TCQUERYCONNECTED: ::c_int = TCGETA + 8; +pub const TCGETBITS: ::c_int = TCGETA + 9; +pub const TCSETDTR: ::c_int = TCGETA + 10; +pub const TCSETRTS: ::c_int = TCGETA + 11; +pub const TIOCGWINSZ: ::c_int = TCGETA + 12; +pub const TIOCSWINSZ: ::c_int = TCGETA + 13; +pub const TCVTIME: ::c_int = TCGETA + 14; +pub const TIOCGPGRP: ::c_int = TCGETA + 15; +pub const TIOCSPGRP: ::c_int = TCGETA + 16; +pub const TIOCSCTTY: ::c_int = TCGETA + 17; +pub const TIOCMGET: ::c_int = TCGETA + 18; +pub const TIOCMSET: ::c_int = TCGETA + 19; +pub const TIOCSBRK: ::c_int = TCGETA + 20; +pub const TIOCCBRK: ::c_int = TCGETA + 21; +pub const TIOCMBIS: ::c_int = TCGETA + 22; +pub const TIOCMBIC: ::c_int = TCGETA + 23; + +f! { + pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return + } + + pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 + } + + pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } + + pub fn WIFEXITED(status: ::c_int) -> bool { + (status & !0xff) == 0 + } + + pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status & 0xff) + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + ((status >> 8) & 0xff) != 0 + } + + pub fn WTERMSIG(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + ((status >> 16) & 0xff) != 0 + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + (status >> 16) & 0xff + } + + // actually WIFCORED, but this is used everywhere else + pub fn WCOREDUMP(status: ::c_int) -> bool { + (status & 0x10000) != 0 + } + + pub fn WIFCONTINUED(status: ::c_int) -> bool { + (status & 0x20000) != 0 + } +} + +extern "C" { + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + pub fn _errnop() -> *mut ::c_int; + + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); +} + +#[link(name = "bsd")] +extern "C" { + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + pub fn sem_init( + sem: *mut sem_t, + pshared: ::c_int, + value: ::c_uint, + ) -> ::c_int; + + pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; + pub fn clock_settime(clk_id: ::c_int, tp: *const ::timespec) -> ::c_int; + pub fn pthread_create( + thread: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + pub fn pthread_attr_getguardsize( + attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t, + ) -> ::c_int; + pub fn pthread_attr_getstack( + attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t, + ) -> ::c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> ::c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; + pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; + pub fn mprotect( + addr: *const ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + pub fn getnameinfo( + sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::size_t, + serv: *mut ::c_char, + sevlen: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut ::siginfo_t, + options: ::c_int, + ) -> ::c_int; + + pub fn glob( + pattern: *const ::c_char, + flags: ::c_int, + errfunc: ::Option< + extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int, + >, + pglob: *mut ::glob_t, + ) -> ::c_int; + pub fn globfree(pglob: *mut ::glob_t); + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + pub fn posix_madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn shm_open( + name: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); + + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; + pub fn madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn msync( + addr: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::c_int; + + pub fn recvfrom( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + ) -> ::ssize_t; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; + pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + pub fn bind( + socket: ::c_int, + address: *const ::sockaddr, + address_len: ::socklen_t, + ) -> ::c_int; + + pub fn writev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + pub fn readv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + + pub fn sendmsg( + fd: ::c_int, + msg: *const ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + pub fn recvmsg( + fd: ::c_int, + msg: *mut ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + pub fn execvpe( + file: *const ::c_char, + argv: *const *const ::c_char, + environment: *const *const ::c_char, + ) -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigaltstack$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sem_close(sem: *mut sem_t) -> ::c_int; + pub fn getdtablesize() -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_sigmask$UNIX2003" + )] + pub fn pthread_sigmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const ::c_char) -> *mut ::group; + pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; + pub fn sem_unlink(name: *const ::c_char) -> ::c_int; + pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigwait$UNIX2003" + )] + #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] + pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; + pub fn pthread_atfork( + prepare: ::Option, + parent: ::Option, + child: ::Option, + ) -> ::c_int; + pub fn getgrgid(gid: ::gid_t) -> *mut ::group; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "popen$UNIX2003" + )] + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + pub fn openpty( + amaster: *mut ::c_int, + aslave: *mut ::c_int, + name: *mut ::c_char, + termp: *mut termios, + winp: *mut ::winsize, + ) -> ::c_int; + pub fn forkpty( + amaster: *mut ::c_int, + name: *mut ::c_char, + termp: *mut termios, + winp: *mut ::winsize, + ) -> ::pid_t; + pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn uname(buf: *mut ::utsname) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + mod b64; + pub use self::b64::*; + } else { + mod b32; + pub use self::b32::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/hermit/aarch64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/hermit/aarch64.rs new file mode 100644 index 0000000..1a92e3b --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/hermit/aarch64.rs @@ -0,0 +1,2 @@ +pub type c_char = u8; +pub type wchar_t = u32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/hermit/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/hermit/mod.rs new file mode 100644 index 0000000..83e064e --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/hermit/mod.rs @@ -0,0 +1,1049 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// liblibc port for HermitCore (https://hermitcore.org) +// HermitCore is a unikernel based on lwIP, newlib, and +// pthread-embedded. +// Consider these definitions when porting liblibc to another +// lwIP/newlib/pte-based target. +// +// Ported by Colin Finck + +pub type c_long = i64; +pub type c_ulong = u64; + +pub type speed_t = ::c_uint; +pub type mode_t = u32; +pub type dev_t = i16; +pub type nfds_t = ::c_ulong; +pub type socklen_t = u32; +pub type sa_family_t = u8; +pub type clock_t = c_ulong; +pub type time_t = c_long; +pub type suseconds_t = c_long; +pub type off_t = i64; +pub type rlim_t = ::c_ulonglong; +pub type sigset_t = ::c_ulong; +pub type ino_t = u16; +pub type nlink_t = u16; +pub type blksize_t = c_long; +pub type blkcnt_t = c_long; +pub type stat64 = stat; +pub type clockid_t = c_ulong; +pub type pthread_t = pte_handle_t; +pub type pthread_attr_t = usize; +pub type pthread_cond_t = usize; +pub type pthread_condattr_t = usize; +pub type pthread_key_t = usize; +pub type pthread_mutex_t = usize; +pub type pthread_mutexattr_t = usize; +pub type pthread_rwlock_t = usize; +pub type pthread_rwlockattr_t = usize; + +s_no_extra_traits! { + pub struct dirent { + pub d_ino: ::c_long, + pub d_off: off_t, + pub d_reclen: u16, + pub d_name: [::c_char; 256], + } + + // Dummy + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 108], + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [::c_char; 8], + } + + pub struct fd_set { + fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], + } + + pub struct sockaddr_storage { + pub s2_len: u8, + pub ss_family: sa_family_t, + pub s2_data1: [::c_char; 2], + pub s2_data2: [u32; 3], + pub s2_data3: [u32; 3], + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_atime: time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_spare4: [::c_long; 2], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sockaddr_un {} + impl ::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } + } + impl ::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_family.hash(state); + self.sun_path.hash(state); + } + } + + impl PartialEq for sockaddr { + fn eq(&self, other: &sockaddr) -> bool { + self.sa_len == other.sa_len + && self.sa_family == other.sa_family + && self + .sa_data + .iter() + .zip(other.sa_data.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sockaddr {} + impl ::fmt::Debug for sockaddr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr") + .field("sa_len", &self.sa_len) + .field("sa_family", &self.sa_family) + // FIXME: .field("sa_data", &self.sa_data) + .finish() + } + } + impl ::hash::Hash for sockaddr { + fn hash(&self, state: &mut H) { + self.sa_len.hash(state); + self.sa_family.hash(state); + self.sa_data.hash(state); + } + } + + impl PartialEq for sockaddr_in { + fn eq(&self, other: &sockaddr_in) -> bool { + self.sin_len == other.sin_len + && self.sin_family == other.sin_family + && self.sin_port == other.sin_port + && self.sin_addr == other.sin_addr + && self + .sin_zero + .iter() + .zip(other.sin_zero.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sockaddr_in {} + impl ::fmt::Debug for sockaddr_in { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_in") + .field("sin_len", &self.sin_len) + .field("sin_family", &self.sin_family) + .field("sin_port", &self.sin_port) + .field("sin_addr", &self.sin_addr) + // FIXME: .field("sin_zero", &self.sin_zero) + .finish() + } + } + impl ::hash::Hash for sockaddr_in { + fn hash(&self, state: &mut H) { + self.sin_len.hash(state); + self.sin_family.hash(state); + self.sin_port.hash(state); + self.sin_addr.hash(state); + self.sin_zero.hash(state); + } + } + + impl PartialEq for fd_set { + fn eq(&self, other: &fd_set) -> bool { + self.fds_bits + .iter() + .zip(other.fds_bits.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for fd_set {} + impl ::fmt::Debug for fd_set { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("fd_set") + // FIXME: .field("fds_bits", &self.fds_bits) + .finish() + } + } + impl ::hash::Hash for fd_set { + fn hash(&self, state: &mut H) { + self.fds_bits.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.s2_len == other.s2_len + && self.ss_family == other.ss_family + && self.s2_data1 + .iter() + .zip(other.s2_data1.iter()) + .all(|(a,b)| a == b) + && self.s2_data2 + .iter() + .zip(other.s2_data2.iter()) + .all(|(a,b)| a == b) + && self.s2_data3 + .iter() + .zip(other.s2_data3.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sockaddr_storage {} + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("s2_len", &self.s2_len) + .field("ss_family", &self.ss_family) + // FIXME: .field("s2_data1", &self.s2_data1) + // FIXME: .field("s2_data2", &self.s2_data2) + // FIXME: .field("s2_data3", &self.s2_data3) + .finish() + } + } + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.s2_len.hash(state); + self.ss_family.hash(state); + self.s2_data1.hash(state); + self.s2_data2.hash(state); + self.s2_data3.hash(state); + } + } + + impl PartialEq for stat { + fn eq(&self, other: &stat) -> bool { + self.st_dev == other.st_dev + && self.st_ino == other.st_ino + && self.st_mode == other.st_mode + && self.st_nlink == other.st_nlink + && self.st_uid == other.st_uid + && self.st_gid == other.st_gid + && self.st_rdev == other.st_rdev + && self.st_size == other.st_size + && self.st_atime == other.st_atime + && self.st_atime_nsec == other.st_atime_nsec + && self.st_mtime == other.st_mtime + && self.st_mtime_nsec == other.st_mtime_nsec + && self.st_ctime == other.st_ctime + && self.st_ctime_nsec == other.st_ctime_nsec + && self.st_blksize == other.st_blksize + && self.st_blocks == other.st_blocks + && self + .st_spare4 + .iter() + .zip(other.st_spare4.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for stat {} + impl ::fmt::Debug for stat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("stat") + .field("st_dev", &self.st_dev) + .field("st_ino", &self.st_ino) + .field("st_mode", &self.st_mode) + .field("st_nlink", &self.st_nlink) + .field("st_uid", &self.st_uid) + .field("st_gid", &self.st_gid) + .field("st_rdev", &self.st_rdev) + .field("st_size", &self.st_size) + .field("st_atime", &self.st_atime) + .field("st_atime_nsec", &self.st_atime_nsec) + .field("st_mtime", &self.st_mtime) + .field("st_mtime_nsec", &self.st_mtime_nsec) + .field("st_ctime", &self.st_ctime) + .field("st_ctime_nsec", &self.st_ctime_nsec) + .field("st_blksize", &self.st_blksize) + .field("st_blocks", &self.st_blocks) + // FIXME: .field("st_spare4", &self.st_spare4) + .finish() + } + } + impl ::hash::Hash for stat { + fn hash(&self, state: &mut H) { + self.st_dev.hash(state); + self.st_ino.hash(state); + self.st_mode.hash(state); + self.st_nlink.hash(state); + self.st_uid.hash(state); + self.st_gid.hash(state); + self.st_rdev.hash(state); + self.st_size.hash(state); + self.st_atime.hash(state); + self.st_atime_nsec.hash(state); + self.st_mtime.hash(state); + self.st_mtime_nsec.hash(state); + self.st_ctime.hash(state); + self.st_ctime_nsec.hash(state); + self.st_blksize.hash(state); + self.st_blocks.hash(state); + self.st_spare4.hash(state); + } + } + } +} + +s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: socklen_t, + pub ai_addr: *mut ::sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut addrinfo, + } + + pub struct Dl_info {} + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct passwd { // Unverified + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct pte_handle_t { + pub p: usize, + pub x: ::c_uint, + } + + pub struct sched_param { + pub sched_priority: ::c_int, + } + + pub struct sem_t { + pub value: i32, + pub lock: usize, + pub sem: usize, + } + + pub struct sigaction { + pub sa_flags: ::c_int, + pub sa_mask: sigset_t, + pub sa_handler: usize, + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct statvfs {} + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + } + + pub struct tms { + pub tms_utime: ::clock_t, + pub tms_stime: ::clock_t, + pub tms_cutime: ::clock_t, + pub tms_cstime: ::clock_t, + } + + pub struct termios {} + + pub struct utsname {} +} + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_INET: ::c_int = 2; +pub const AF_INET6: ::c_int = 10; + +// Dummy +pub const AF_UNIX: ::c_int = 1; + +pub const CLOCK_REALTIME: ::clockid_t = 1; +pub const CLOCK_MONOTONIC: ::clockid_t = 4; + +// Dummy +pub const EAI_SYSTEM: ::c_int = -11; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const EWOULDBLOCK: ::c_int = EAGAIN; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EMULTIHOP: ::c_int = 72; +pub const EDOTDOT: ::c_int = 73; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; +pub const F_GETOWN: ::c_int = 5; +pub const F_SETOWN: ::c_int = 6; +pub const F_GETLK: ::c_int = 7; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; +pub const F_RGETLK: ::c_int = 10; +pub const F_RSETLK: ::c_int = 11; +pub const F_CNVT: ::c_int = 12; +pub const F_RSETLKW: ::c_int = 13; +pub const F_DUPFD_CLOEXEC: ::c_int = 14; + +pub const FD_SETSIZE: usize = 1024; + +// Dummy +pub const FIOCLEX: ::c_int = 0x5451; + +pub const FIONBIO: ::c_int = 0x8004667e; +pub const FIONREAD: ::c_int = 0x4004667f; + +pub const IP_ADD_MEMBERSHIP: ::c_int = 3; +pub const IP_DROP_MEMBERSHIP: ::c_int = 4; + +pub const IP_TOS: ::c_int = 1; +pub const IP_TTL: ::c_int = 2; + +pub const IP_MULTICAST_TTL: ::c_int = 5; +pub const IP_MULTICAST_IF: ::c_int = 6; +pub const IP_MULTICAST_LOOP: ::c_int = 7; + +pub const IPV6_JOIN_GROUP: ::c_int = 12; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; +pub const IPV6_LEAVE_GROUP: ::c_int = 13; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; +pub const IPV6_V6ONLY: ::c_int = 27; + +// Dummy +pub const IPV6_MULTICAST_LOOP: ::c_int = 7; + +pub const MSG_PEEK: ::c_int = 0x01; +pub const MSG_WAITALL: ::c_int = 0x02; +pub const MSG_OOB: ::c_int = 0x04; +pub const MSG_DONTWAIT: ::c_int = 0x08; +pub const MSG_MORE: ::c_int = 0x10; + +pub const O_ACCMODE: ::c_int = 3; +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_TRUNC: ::c_int = 512; +pub const O_CLOEXEC: ::c_int = 524288; + +pub const POLLIN: ::c_short = 0x1; +pub const POLLPRI: ::c_short = 0x2; +pub const POLLOUT: ::c_short = 0x4; +pub const POLLERR: ::c_short = 0x8; +pub const POLLHUP: ::c_short = 0x10; +pub const POLLNVAL: ::c_short = 0x20; + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = usize::max_value(); +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = usize::max_value(); +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = usize::max_value(); + +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const PTHREAD_STACK_MIN: ::size_t = 0; + +// Dummy +pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; + +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_CHILD_MAX: ::c_int = 1; +pub const _SC_CLK_TCK: ::c_int = 2; +pub const _SC_NGROUPS_MAX: ::c_int = 3; +pub const _SC_OPEN_MAX: ::c_int = 4; +pub const _SC_JOB_CONTROL: ::c_int = 5; +pub const _SC_SAVED_IDS: ::c_int = 6; +pub const _SC_VERSION: ::c_int = 7; +pub const _SC_PAGESIZE: ::c_int = 8; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_NPROCESSORS_CONF: ::c_int = 9; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 10; +pub const _SC_PHYS_PAGES: ::c_int = 11; +pub const _SC_AVPHYS_PAGES: ::c_int = 12; +pub const _SC_MQ_OPEN_MAX: ::c_int = 13; +pub const _SC_MQ_PRIO_MAX: ::c_int = 14; +pub const _SC_RTSIG_MAX: ::c_int = 15; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 16; +pub const _SC_SEM_VALUE_MAX: ::c_int = 17; +pub const _SC_SIGQUEUE_MAX: ::c_int = 18; +pub const _SC_TIMER_MAX: ::c_int = 19; +pub const _SC_TZNAME_MAX: ::c_int = 20; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 21; +pub const _SC_FSYNC: ::c_int = 22; +pub const _SC_MAPPED_FILES: ::c_int = 23; +pub const _SC_MEMLOCK: ::c_int = 24; +pub const _SC_MEMLOCK_RANGE: ::c_int = 25; +pub const _SC_MEMORY_PROTECTION: ::c_int = 26; +pub const _SC_MESSAGE_PASSING: ::c_int = 27; +pub const _SC_PRIORITIZED_IO: ::c_int = 28; +pub const _SC_REALTIME_SIGNALS: ::c_int = 29; +pub const _SC_SEMAPHORES: ::c_int = 30; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 31; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 32; +pub const _SC_TIMERS: ::c_int = 33; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 34; +pub const _SC_AIO_MAX: ::c_int = 35; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 36; +pub const _SC_DELAYTIMER_MAX: ::c_int = 37; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 38; +pub const _SC_THREAD_STACK_MIN: ::c_int = 39; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 40; +pub const _SC_TTY_NAME_MAX: ::c_int = 41; +pub const _SC_THREADS: ::c_int = 42; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 43; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 44; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 45; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 46; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 47; +pub const _SC_THREAD_PRIO_CEILING: ::c_int = _SC_THREAD_PRIO_PROTECT; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 48; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 49; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 50; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 52; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 53; +pub const _SC_ADVISORY_INFO: ::c_int = 54; +pub const _SC_ATEXIT_MAX: ::c_int = 55; +pub const _SC_BARRIERS: ::c_int = 56; +pub const _SC_BC_BASE_MAX: ::c_int = 57; +pub const _SC_BC_DIM_MAX: ::c_int = 58; +pub const _SC_BC_SCALE_MAX: ::c_int = 59; +pub const _SC_BC_STRING_MAX: ::c_int = 60; +pub const _SC_CLOCK_SELECTION: ::c_int = 61; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 62; +pub const _SC_CPUTIME: ::c_int = 63; +pub const _SC_EXPR_NEST_MAX: ::c_int = 64; +pub const _SC_HOST_NAME_MAX: ::c_int = 65; +pub const _SC_IOV_MAX: ::c_int = 66; +pub const _SC_IPV6: ::c_int = 67; +pub const _SC_LINE_MAX: ::c_int = 68; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 69; +pub const _SC_RAW_SOCKETS: ::c_int = 70; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 71; +pub const _SC_REGEXP: ::c_int = 72; +pub const _SC_RE_DUP_MAX: ::c_int = 73; +pub const _SC_SHELL: ::c_int = 74; +pub const _SC_SPAWN: ::c_int = 75; +pub const _SC_SPIN_LOCKS: ::c_int = 76; +pub const _SC_SPORADIC_SERVER: ::c_int = 77; +pub const _SC_SS_REPL_MAX: ::c_int = 78; +pub const _SC_SYMLOOP_MAX: ::c_int = 79; +pub const _SC_THREAD_CPUTIME: ::c_int = 80; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 81; +pub const _SC_TIMEOUTS: ::c_int = 82; +pub const _SC_TRACE: ::c_int = 83; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 84; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 85; +pub const _SC_TRACE_INHERIT: ::c_int = 86; +pub const _SC_TRACE_LOG: ::c_int = 87; +pub const _SC_TRACE_NAME_MAX: ::c_int = 88; +pub const _SC_TRACE_SYS_MAX: ::c_int = 89; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 90; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 91; +pub const _SC_V7_ILP32_OFF32: ::c_int = 92; +pub const _SC_V6_ILP32_OFF32: ::c_int = _SC_V7_ILP32_OFF32; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = _SC_V7_ILP32_OFF32; +pub const _SC_V7_ILP32_OFFBIG: ::c_int = 93; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_V7_LP64_OFF64: ::c_int = 94; +pub const _SC_V6_LP64_OFF64: ::c_int = _SC_V7_LP64_OFF64; +pub const _SC_XBS5_LP64_OFF64: ::c_int = _SC_V7_LP64_OFF64; +pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 95; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XOPEN_CRYPT: ::c_int = 96; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 97; +pub const _SC_XOPEN_LEGACY: ::c_int = 98; +pub const _SC_XOPEN_REALTIME: ::c_int = 99; +pub const _SC_STREAM_MAX: ::c_int = 100; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 101; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 102; +pub const _SC_XOPEN_SHM: ::c_int = 103; +pub const _SC_XOPEN_STREAMS: ::c_int = 104; +pub const _SC_XOPEN_UNIX: ::c_int = 105; +pub const _SC_XOPEN_VERSION: ::c_int = 106; +pub const _SC_2_CHAR_TERM: ::c_int = 107; +pub const _SC_2_C_BIND: ::c_int = 108; +pub const _SC_2_C_DEV: ::c_int = 109; +pub const _SC_2_FORT_DEV: ::c_int = 110; +pub const _SC_2_FORT_RUN: ::c_int = 111; +pub const _SC_2_LOCALEDEF: ::c_int = 112; +pub const _SC_2_PBS: ::c_int = 113; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 114; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 115; +pub const _SC_2_PBS_LOCATE: ::c_int = 116; +pub const _SC_2_PBS_MESSAGE: ::c_int = 117; +pub const _SC_2_PBS_TRACK: ::c_int = 118; +pub const _SC_2_SW_DEV: ::c_int = 119; +pub const _SC_2_UPE: ::c_int = 120; +pub const _SC_2_VERSION: ::c_int = 121; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 122; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 123; +pub const _SC_XOPEN_UUCP: ::c_int = 124; +pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 125; +pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 126; +pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 127; +pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 128; +pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 129; +pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 130; +pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 131; +pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 132; +pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 133; +pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 134; +pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 135; +pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 136; +pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 137; +pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 138; +pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 139; + +pub const S_BLKSIZE: ::mode_t = 1024; +pub const S_IREAD: ::mode_t = 256; +pub const S_IWRITE: ::mode_t = 128; +pub const S_IEXEC: ::mode_t = 64; +pub const S_ENFMT: ::mode_t = 1024; +pub const S_IFMT: ::mode_t = 61440; +pub const S_IFDIR: ::mode_t = 16384; +pub const S_IFCHR: ::mode_t = 8192; +pub const S_IFBLK: ::mode_t = 24576; +pub const S_IFREG: ::mode_t = 32768; +pub const S_IFLNK: ::mode_t = 40960; +pub const S_IFSOCK: ::mode_t = 49152; +pub const S_IFIFO: ::mode_t = 4096; +pub const S_IRUSR: ::mode_t = 256; +pub const S_IWUSR: ::mode_t = 128; +pub const S_IXUSR: ::mode_t = 64; +pub const S_IRGRP: ::mode_t = 32; +pub const S_IWGRP: ::mode_t = 16; +pub const S_IXGRP: ::mode_t = 8; +pub const S_IROTH: ::mode_t = 4; +pub const S_IWOTH: ::mode_t = 2; +pub const S_IXOTH: ::mode_t = 1; + +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const SIG_SETMASK: ::c_int = 0; + +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGEMT: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const SO_DEBUG: ::c_int = 0x0001; +pub const SO_ACCEPTCONN: ::c_int = 0x0002; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_CONTIMEO: ::c_int = 0x1009; +pub const SO_NO_CHECK: ::c_int = 0x100a; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; + +pub const SOL_SOCKET: ::c_int = 0xfff; + +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; + +pub const TCP_NODELAY: ::c_int = 0x01; +pub const TCP_KEEPALIVE: ::c_int = 0x02; +pub const TCP_KEEPIDLE: ::c_int = 0x03; +pub const TCP_KEEPINTVL: ::c_int = 0x04; +pub const TCP_KEEPCNT: ::c_int = 0x05; + +const ULONG_SIZE: usize = 64; + +pub const WNOHANG: ::c_int = 0x00000001; + +f! { + pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WIFEXITED(status: ::c_int) -> bool { + (status & 0xff) == 0 + } + + pub fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0x7f + } +} + +extern "C" { + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + pub fn sem_init( + sem: *mut sem_t, + pshared: ::c_int, + value: ::c_uint, + ) -> ::c_int; + + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + + pub fn bind( + s: ::c_int, + name: *const ::sockaddr, + namelen: ::socklen_t, + ) -> ::c_int; + + pub fn clock_gettime( + clock_id: ::clockid_t, + tp: *mut ::timespec, + ) -> ::c_int; + + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + + // Dummy + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; + + pub fn memalign(align: ::size_t, nbytes: ::size_t) -> *mut ::c_void; + + pub fn pthread_create( + tid: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + start: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + arg: *mut ::c_void, + ) -> ::c_int; + + pub fn pthread_sigmask( + how: ::c_int, + set: *const ::sigset_t, + oset: *mut ::sigset_t, + ) -> ::c_int; + + pub fn recvfrom( + s: ::c_int, + mem: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + from: *mut ::sockaddr, + fromlen: *mut ::socklen_t, + ) -> ::c_int; + + pub fn setgroups(ngroups: ::c_int, grouplist: *const ::gid_t) -> ::c_int; + pub fn uname(buf: *mut ::utsname) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/hermit/x86_64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/hermit/x86_64.rs new file mode 100644 index 0000000..76ec3ce --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/hermit/x86_64.rs @@ -0,0 +1,2 @@ +pub type c_char = i8; +pub type wchar_t = i32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/arm.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/arm.rs new file mode 100644 index 0000000..1320b16 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/arm.rs @@ -0,0 +1,357 @@ +pub type c_char = u8; +pub type wchar_t = u32; + +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_LARGEFILE: ::c_int = 0o400000; + +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_pause: ::c_long = 29; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS_getdents: ::c_long = 141; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_poll: ::c_long = 168; +pub const SYS_nfsservctl: ::c_long = 169; +pub const SYS_setresgid: ::c_long = 170; +pub const SYS_getresgid: ::c_long = 171; +pub const SYS_prctl: ::c_long = 172; +pub const SYS_rt_sigreturn: ::c_long = 173; +pub const SYS_rt_sigaction: ::c_long = 174; +pub const SYS_rt_sigprocmask: ::c_long = 175; +pub const SYS_rt_sigpending: ::c_long = 176; +pub const SYS_rt_sigtimedwait: ::c_long = 177; +pub const SYS_rt_sigqueueinfo: ::c_long = 178; +pub const SYS_rt_sigsuspend: ::c_long = 179; +pub const SYS_pread64: ::c_long = 180; +pub const SYS_pwrite64: ::c_long = 181; +pub const SYS_chown: ::c_long = 182; +pub const SYS_getcwd: ::c_long = 183; +pub const SYS_capget: ::c_long = 184; +pub const SYS_capset: ::c_long = 185; +pub const SYS_sigaltstack: ::c_long = 186; +pub const SYS_sendfile: ::c_long = 187; +pub const SYS_vfork: ::c_long = 190; +pub const SYS_ugetrlimit: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_lchown32: ::c_long = 198; +pub const SYS_getuid32: ::c_long = 199; +pub const SYS_getgid32: ::c_long = 200; +pub const SYS_geteuid32: ::c_long = 201; +pub const SYS_getegid32: ::c_long = 202; +pub const SYS_setreuid32: ::c_long = 203; +pub const SYS_setregid32: ::c_long = 204; +pub const SYS_getgroups32: ::c_long = 205; +pub const SYS_setgroups32: ::c_long = 206; +pub const SYS_fchown32: ::c_long = 207; +pub const SYS_setresuid32: ::c_long = 208; +pub const SYS_getresuid32: ::c_long = 209; +pub const SYS_setresgid32: ::c_long = 210; +pub const SYS_getresgid32: ::c_long = 211; +pub const SYS_chown32: ::c_long = 212; +pub const SYS_setuid32: ::c_long = 213; +pub const SYS_setgid32: ::c_long = 214; +pub const SYS_setfsuid32: ::c_long = 215; +pub const SYS_setfsgid32: ::c_long = 216; +pub const SYS_getdents64: ::c_long = 217; +pub const SYS_pivot_root: ::c_long = 218; +pub const SYS_mincore: ::c_long = 219; +pub const SYS_madvise: ::c_long = 220; +pub const SYS_fcntl64: ::c_long = 221; +pub const SYS_gettid: ::c_long = 224; +pub const SYS_readahead: ::c_long = 225; +pub const SYS_setxattr: ::c_long = 226; +pub const SYS_lsetxattr: ::c_long = 227; +pub const SYS_fsetxattr: ::c_long = 228; +pub const SYS_getxattr: ::c_long = 229; +pub const SYS_lgetxattr: ::c_long = 230; +pub const SYS_fgetxattr: ::c_long = 231; +pub const SYS_listxattr: ::c_long = 232; +pub const SYS_llistxattr: ::c_long = 233; +pub const SYS_flistxattr: ::c_long = 234; +pub const SYS_removexattr: ::c_long = 235; +pub const SYS_lremovexattr: ::c_long = 236; +pub const SYS_fremovexattr: ::c_long = 237; +pub const SYS_tkill: ::c_long = 238; +pub const SYS_sendfile64: ::c_long = 239; +pub const SYS_futex: ::c_long = 240; +pub const SYS_sched_setaffinity: ::c_long = 241; +pub const SYS_sched_getaffinity: ::c_long = 242; +pub const SYS_io_setup: ::c_long = 243; +pub const SYS_io_destroy: ::c_long = 244; +pub const SYS_io_getevents: ::c_long = 245; +pub const SYS_io_submit: ::c_long = 246; +pub const SYS_io_cancel: ::c_long = 247; +pub const SYS_exit_group: ::c_long = 248; +pub const SYS_lookup_dcookie: ::c_long = 249; +pub const SYS_epoll_create: ::c_long = 250; +pub const SYS_epoll_ctl: ::c_long = 251; +pub const SYS_epoll_wait: ::c_long = 252; +pub const SYS_remap_file_pages: ::c_long = 253; +pub const SYS_set_tid_address: ::c_long = 256; +pub const SYS_timer_create: ::c_long = 257; +pub const SYS_timer_settime: ::c_long = 258; +pub const SYS_timer_gettime: ::c_long = 259; +pub const SYS_timer_getoverrun: ::c_long = 260; +pub const SYS_timer_delete: ::c_long = 261; +pub const SYS_clock_settime: ::c_long = 262; +pub const SYS_clock_gettime: ::c_long = 263; +pub const SYS_clock_getres: ::c_long = 264; +pub const SYS_clock_nanosleep: ::c_long = 265; +pub const SYS_statfs64: ::c_long = 266; +pub const SYS_fstatfs64: ::c_long = 267; +pub const SYS_tgkill: ::c_long = 268; +pub const SYS_utimes: ::c_long = 269; +pub const SYS_arm_fadvise64_64: ::c_long = 270; +pub const SYS_pciconfig_iobase: ::c_long = 271; +pub const SYS_pciconfig_read: ::c_long = 272; +pub const SYS_pciconfig_write: ::c_long = 273; +pub const SYS_mq_open: ::c_long = 274; +pub const SYS_mq_unlink: ::c_long = 275; +pub const SYS_mq_timedsend: ::c_long = 276; +pub const SYS_mq_timedreceive: ::c_long = 277; +pub const SYS_mq_notify: ::c_long = 278; +pub const SYS_mq_getsetattr: ::c_long = 279; +pub const SYS_waitid: ::c_long = 280; +pub const SYS_socket: ::c_long = 281; +pub const SYS_bind: ::c_long = 282; +pub const SYS_connect: ::c_long = 283; +pub const SYS_listen: ::c_long = 284; +pub const SYS_accept: ::c_long = 285; +pub const SYS_getsockname: ::c_long = 286; +pub const SYS_getpeername: ::c_long = 287; +pub const SYS_socketpair: ::c_long = 288; +pub const SYS_send: ::c_long = 289; +pub const SYS_sendto: ::c_long = 290; +pub const SYS_recv: ::c_long = 291; +pub const SYS_recvfrom: ::c_long = 292; +pub const SYS_shutdown: ::c_long = 293; +pub const SYS_setsockopt: ::c_long = 294; +pub const SYS_getsockopt: ::c_long = 295; +pub const SYS_sendmsg: ::c_long = 296; +pub const SYS_recvmsg: ::c_long = 297; +pub const SYS_semop: ::c_long = 298; +pub const SYS_semget: ::c_long = 299; +pub const SYS_semctl: ::c_long = 300; +pub const SYS_msgsnd: ::c_long = 301; +pub const SYS_msgrcv: ::c_long = 302; +pub const SYS_msgget: ::c_long = 303; +pub const SYS_msgctl: ::c_long = 304; +pub const SYS_shmat: ::c_long = 305; +pub const SYS_shmdt: ::c_long = 306; +pub const SYS_shmget: ::c_long = 307; +pub const SYS_shmctl: ::c_long = 308; +pub const SYS_add_key: ::c_long = 309; +pub const SYS_request_key: ::c_long = 310; +pub const SYS_keyctl: ::c_long = 311; +pub const SYS_semtimedop: ::c_long = 312; +pub const SYS_vserver: ::c_long = 313; +pub const SYS_ioprio_set: ::c_long = 314; +pub const SYS_ioprio_get: ::c_long = 315; +pub const SYS_inotify_init: ::c_long = 316; +pub const SYS_inotify_add_watch: ::c_long = 317; +pub const SYS_inotify_rm_watch: ::c_long = 318; +pub const SYS_mbind: ::c_long = 319; +pub const SYS_get_mempolicy: ::c_long = 320; +pub const SYS_set_mempolicy: ::c_long = 321; +pub const SYS_openat: ::c_long = 322; +pub const SYS_mkdirat: ::c_long = 323; +pub const SYS_mknodat: ::c_long = 324; +pub const SYS_fchownat: ::c_long = 325; +pub const SYS_futimesat: ::c_long = 326; +pub const SYS_fstatat64: ::c_long = 327; +pub const SYS_unlinkat: ::c_long = 328; +pub const SYS_renameat: ::c_long = 329; +pub const SYS_linkat: ::c_long = 330; +pub const SYS_symlinkat: ::c_long = 331; +pub const SYS_readlinkat: ::c_long = 332; +pub const SYS_fchmodat: ::c_long = 333; +pub const SYS_faccessat: ::c_long = 334; +pub const SYS_pselect6: ::c_long = 335; +pub const SYS_ppoll: ::c_long = 336; +pub const SYS_unshare: ::c_long = 337; +pub const SYS_set_robust_list: ::c_long = 338; +pub const SYS_get_robust_list: ::c_long = 339; +pub const SYS_splice: ::c_long = 340; +pub const SYS_arm_sync_file_range: ::c_long = 341; +pub const SYS_tee: ::c_long = 342; +pub const SYS_vmsplice: ::c_long = 343; +pub const SYS_move_pages: ::c_long = 344; +pub const SYS_getcpu: ::c_long = 345; +pub const SYS_epoll_pwait: ::c_long = 346; +pub const SYS_kexec_load: ::c_long = 347; +pub const SYS_utimensat: ::c_long = 348; +pub const SYS_signalfd: ::c_long = 349; +pub const SYS_timerfd_create: ::c_long = 350; +pub const SYS_eventfd: ::c_long = 351; +pub const SYS_fallocate: ::c_long = 352; +pub const SYS_timerfd_settime: ::c_long = 353; +pub const SYS_timerfd_gettime: ::c_long = 354; +pub const SYS_signalfd4: ::c_long = 355; +pub const SYS_eventfd2: ::c_long = 356; +pub const SYS_epoll_create1: ::c_long = 357; +pub const SYS_dup3: ::c_long = 358; +pub const SYS_pipe2: ::c_long = 359; +pub const SYS_inotify_init1: ::c_long = 360; +pub const SYS_preadv: ::c_long = 361; +pub const SYS_pwritev: ::c_long = 362; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 363; +pub const SYS_perf_event_open: ::c_long = 364; +pub const SYS_recvmmsg: ::c_long = 365; +pub const SYS_accept4: ::c_long = 366; +pub const SYS_fanotify_init: ::c_long = 367; +pub const SYS_fanotify_mark: ::c_long = 368; +pub const SYS_prlimit64: ::c_long = 369; +pub const SYS_name_to_handle_at: ::c_long = 370; +pub const SYS_open_by_handle_at: ::c_long = 371; +pub const SYS_clock_adjtime: ::c_long = 372; +pub const SYS_syncfs: ::c_long = 373; +pub const SYS_sendmmsg: ::c_long = 374; +pub const SYS_setns: ::c_long = 375; +pub const SYS_process_vm_readv: ::c_long = 376; +pub const SYS_process_vm_writev: ::c_long = 377; +pub const SYS_kcmp: ::c_long = 378; +pub const SYS_finit_module: ::c_long = 379; +pub const SYS_sched_setattr: ::c_long = 380; +pub const SYS_sched_getattr: ::c_long = 381; +pub const SYS_renameat2: ::c_long = 382; +pub const SYS_seccomp: ::c_long = 383; +pub const SYS_getrandom: ::c_long = 384; +pub const SYS_memfd_create: ::c_long = 385; +pub const SYS_bpf: ::c_long = 386; +pub const SYS_execveat: ::c_long = 387; +pub const SYS_userfaultfd: ::c_long = 388; +pub const SYS_membarrier: ::c_long = 389; +pub const SYS_mlock2: ::c_long = 390; +pub const SYS_copy_file_range: ::c_long = 391; +pub const SYS_preadv2: ::c_long = 392; +pub const SYS_pwritev2: ::c_long = 393; +pub const SYS_pkey_mprotect: ::c_long = 394; +pub const SYS_pkey_alloc: ::c_long = 395; +pub const SYS_pkey_free: ::c_long = 396; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/mod.rs new file mode 100644 index 0000000..e5c97e9 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/mod.rs @@ -0,0 +1,221 @@ +// The following definitions are correct for arm and i686, +// but may be wrong for mips + +pub type c_long = i32; +pub type c_ulong = u32; +pub type mode_t = u16; +pub type off64_t = ::c_longlong; +pub type sigset_t = ::c_ulong; +pub type socklen_t = i32; +pub type time64_t = i64; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct rlimit64 { + pub rlim_cur: u64, + pub rlim_max: u64, + } + + pub struct stat { + pub st_dev: ::c_ulonglong, + __pad0: [::c_uchar; 4], + __st_ino: ::ino_t, + pub st_mode: ::c_uint, + pub st_nlink: ::c_uint, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulonglong, + __pad3: [::c_uchar; 4], + pub st_size: ::c_longlong, + pub st_blksize: ::blksize_t, + pub st_blocks: ::c_ulonglong, + pub st_atime: ::c_long, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::c_long, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::c_long, + pub st_ctime_nsec: ::c_long, + pub st_ino: ::c_ulonglong, + } + + pub struct stat64 { + pub st_dev: ::c_ulonglong, + __pad0: [::c_uchar; 4], + __st_ino: ::ino_t, + pub st_mode: ::c_uint, + pub st_nlink: ::c_uint, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulonglong, + __pad3: [::c_uchar; 4], + pub st_size: ::c_longlong, + pub st_blksize: ::blksize_t, + pub st_blocks: ::c_ulonglong, + pub st_atime: ::c_long, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::c_long, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::c_long, + pub st_ctime_nsec: ::c_long, + pub st_ino: ::c_ulonglong, + } + + pub struct statfs64 { + pub f_type: u32, + pub f_bsize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + f_fsid: [u32; 2], + pub f_namelen: u32, + pub f_frsize: u32, + pub f_flags: u32, + pub f_spare: [u32; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::c_ulong, + pub f_bfree: ::c_ulong, + pub f_bavail: ::c_ulong, + pub f_files: ::c_ulong, + pub f_ffree: ::c_ulong, + pub f_favail: ::c_ulong, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + } + + pub struct pthread_attr_t { + pub flags: u32, + pub stack_base: *mut ::c_void, + pub stack_size: ::size_t, + pub guard_size: ::size_t, + pub sched_policy: i32, + pub sched_priority: i32, + } + + pub struct pthread_mutex_t { value: ::c_int } + + pub struct pthread_cond_t { value: ::c_int } + + pub struct pthread_rwlock_t { + lock: pthread_mutex_t, + cond: pthread_cond_t, + numLocks: ::c_int, + writerThreadId: ::c_int, + pendingReaders: ::c_int, + pendingWriters: ::c_int, + attr: i32, + __reserved: [::c_char; 12], + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct statfs { + pub f_type: u32, + pub f_bsize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::__fsid_t, + pub f_namelen: u32, + pub f_frsize: u32, + pub f_flags: u32, + pub f_spare: [u32; 4], + } + + pub struct sysinfo { + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 8], + } +} + +// These constants must be of the same type of sigaction.sa_flags +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; + +pub const RTLD_GLOBAL: ::c_int = 2; +pub const RTLD_NOW: ::c_int = 0; +pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void; + +pub const PTRACE_GETFPREGS: ::c_int = 14; +pub const PTRACE_SETFPREGS: ::c_int = 15; +pub const PTRACE_GETREGS: ::c_int = 12; +pub const PTRACE_SETREGS: ::c_int = 13; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = + pthread_mutex_t { value: 0 }; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = + pthread_cond_t { value: 0 }; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + lock: PTHREAD_MUTEX_INITIALIZER, + cond: PTHREAD_COND_INITIALIZER, + numLocks: 0, + writerThreadId: 0, + pendingReaders: 0, + pendingWriters: 0, + attr: 0, + __reserved: [0; 12], +}; +pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2; +pub const CPU_SETSIZE: ::size_t = 32; +pub const __CPU_BITS: ::size_t = 32; + +pub const UT_LINESIZE: usize = 8; +pub const UT_NAMESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 16; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + +extern "C" { + pub fn timegm64(tm: *const ::tm) -> ::time64_t; +} + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/x86/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/x86/align.rs new file mode 100644 index 0000000..04df4a0 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/x86/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f64; 2] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/x86/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/x86/mod.rs new file mode 100644 index 0000000..101bf2d --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b32/x86/mod.rs @@ -0,0 +1,422 @@ +pub type c_char = i8; +pub type wchar_t = i32; + +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_LARGEFILE: ::c_int = 0o0100000; + +pub const MAP_32BIT: ::c_int = 0x40; + +// Syscall table +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_break: ::c_long = 17; +pub const SYS_oldstat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_umount: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_stime: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_oldfstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_stty: ::c_long = 31; +pub const SYS_gtty: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_ftime: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_prof: ::c_long = 44; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_lock: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_mpx: ::c_long = 56; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_ulimit: ::c_long = 58; +pub const SYS_oldolduname: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_oldlstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_readdir: ::c_long = 89; +pub const SYS_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_profil: ::c_long = 98; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_ioperm: ::c_long = 101; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_olduname: ::c_long = 109; +pub const SYS_iopl: ::c_long = 110; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_idle: ::c_long = 112; +pub const SYS_vm86old: ::c_long = 113; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_modify_ldt: ::c_long = 123; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_afs_syscall: ::c_long = 137; +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +// FIXME: SYS__llseek is in the NDK sources but for some reason is +// not available in the tests +// pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +// FIXME: SYS__newselect is in the NDK sources but for some reason is +// not available in the tests +// pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +// FIXME: SYS__llseek is in the NDK sources but for some reason is +// not available in the tests +// pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_vm86: ::c_long = 166; +pub const SYS_query_module: ::c_long = 167; +pub const SYS_poll: ::c_long = 168; +pub const SYS_nfsservctl: ::c_long = 169; +pub const SYS_setresgid: ::c_long = 170; +pub const SYS_getresgid: ::c_long = 171; +pub const SYS_prctl: ::c_long = 172; +pub const SYS_rt_sigreturn: ::c_long = 173; +pub const SYS_rt_sigaction: ::c_long = 174; +pub const SYS_rt_sigprocmask: ::c_long = 175; +pub const SYS_rt_sigpending: ::c_long = 176; +pub const SYS_rt_sigtimedwait: ::c_long = 177; +pub const SYS_rt_sigqueueinfo: ::c_long = 178; +pub const SYS_rt_sigsuspend: ::c_long = 179; +pub const SYS_pread64: ::c_long = 180; +pub const SYS_pwrite64: ::c_long = 181; +pub const SYS_chown: ::c_long = 182; +pub const SYS_getcwd: ::c_long = 183; +pub const SYS_capget: ::c_long = 184; +pub const SYS_capset: ::c_long = 185; +pub const SYS_sigaltstack: ::c_long = 186; +pub const SYS_sendfile: ::c_long = 187; +pub const SYS_getpmsg: ::c_long = 188; +pub const SYS_putpmsg: ::c_long = 189; +pub const SYS_vfork: ::c_long = 190; +pub const SYS_ugetrlimit: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_lchown32: ::c_long = 198; +pub const SYS_getuid32: ::c_long = 199; +pub const SYS_getgid32: ::c_long = 200; +pub const SYS_geteuid32: ::c_long = 201; +pub const SYS_getegid32: ::c_long = 202; +pub const SYS_setreuid32: ::c_long = 203; +pub const SYS_setregid32: ::c_long = 204; +pub const SYS_getgroups32: ::c_long = 205; +pub const SYS_setgroups32: ::c_long = 206; +pub const SYS_fchown32: ::c_long = 207; +pub const SYS_setresuid32: ::c_long = 208; +pub const SYS_getresuid32: ::c_long = 209; +pub const SYS_setresgid32: ::c_long = 210; +pub const SYS_getresgid32: ::c_long = 211; +pub const SYS_chown32: ::c_long = 212; +pub const SYS_setuid32: ::c_long = 213; +pub const SYS_setgid32: ::c_long = 214; +pub const SYS_setfsuid32: ::c_long = 215; +pub const SYS_setfsgid32: ::c_long = 216; +pub const SYS_pivot_root: ::c_long = 217; +pub const SYS_mincore: ::c_long = 218; +pub const SYS_madvise: ::c_long = 219; +pub const SYS_getdents64: ::c_long = 220; +pub const SYS_fcntl64: ::c_long = 221; +pub const SYS_gettid: ::c_long = 224; +pub const SYS_readahead: ::c_long = 225; +pub const SYS_setxattr: ::c_long = 226; +pub const SYS_lsetxattr: ::c_long = 227; +pub const SYS_fsetxattr: ::c_long = 228; +pub const SYS_getxattr: ::c_long = 229; +pub const SYS_lgetxattr: ::c_long = 230; +pub const SYS_fgetxattr: ::c_long = 231; +pub const SYS_listxattr: ::c_long = 232; +pub const SYS_llistxattr: ::c_long = 233; +pub const SYS_flistxattr: ::c_long = 234; +pub const SYS_removexattr: ::c_long = 235; +pub const SYS_lremovexattr: ::c_long = 236; +pub const SYS_fremovexattr: ::c_long = 237; +pub const SYS_tkill: ::c_long = 238; +pub const SYS_sendfile64: ::c_long = 239; +pub const SYS_futex: ::c_long = 240; +pub const SYS_sched_setaffinity: ::c_long = 241; +pub const SYS_sched_getaffinity: ::c_long = 242; +pub const SYS_set_thread_area: ::c_long = 243; +pub const SYS_get_thread_area: ::c_long = 244; +pub const SYS_io_setup: ::c_long = 245; +pub const SYS_io_destroy: ::c_long = 246; +pub const SYS_io_getevents: ::c_long = 247; +pub const SYS_io_submit: ::c_long = 248; +pub const SYS_io_cancel: ::c_long = 249; +pub const SYS_fadvise64: ::c_long = 250; +pub const SYS_exit_group: ::c_long = 252; +pub const SYS_lookup_dcookie: ::c_long = 253; +pub const SYS_epoll_create: ::c_long = 254; +pub const SYS_epoll_ctl: ::c_long = 255; +pub const SYS_epoll_wait: ::c_long = 256; +pub const SYS_remap_file_pages: ::c_long = 257; +pub const SYS_set_tid_address: ::c_long = 258; +pub const SYS_timer_create: ::c_long = 259; +pub const SYS_timer_settime: ::c_long = 260; +pub const SYS_timer_gettime: ::c_long = 261; +pub const SYS_timer_getoverrun: ::c_long = 262; +pub const SYS_timer_delete: ::c_long = 263; +pub const SYS_clock_settime: ::c_long = 264; +pub const SYS_clock_gettime: ::c_long = 265; +pub const SYS_clock_getres: ::c_long = 266; +pub const SYS_clock_nanosleep: ::c_long = 267; +pub const SYS_statfs64: ::c_long = 268; +pub const SYS_fstatfs64: ::c_long = 269; +pub const SYS_tgkill: ::c_long = 270; +pub const SYS_utimes: ::c_long = 271; +pub const SYS_fadvise64_64: ::c_long = 272; +pub const SYS_vserver: ::c_long = 273; +pub const SYS_mbind: ::c_long = 274; +pub const SYS_get_mempolicy: ::c_long = 275; +pub const SYS_set_mempolicy: ::c_long = 276; +pub const SYS_mq_open: ::c_long = 277; +pub const SYS_mq_unlink: ::c_long = 278; +pub const SYS_mq_timedsend: ::c_long = 279; +pub const SYS_mq_timedreceive: ::c_long = 280; +pub const SYS_mq_notify: ::c_long = 281; +pub const SYS_mq_getsetattr: ::c_long = 282; +pub const SYS_kexec_load: ::c_long = 283; +pub const SYS_waitid: ::c_long = 284; +pub const SYS_add_key: ::c_long = 286; +pub const SYS_request_key: ::c_long = 287; +pub const SYS_keyctl: ::c_long = 288; +pub const SYS_ioprio_set: ::c_long = 289; +pub const SYS_ioprio_get: ::c_long = 290; +pub const SYS_inotify_init: ::c_long = 291; +pub const SYS_inotify_add_watch: ::c_long = 292; +pub const SYS_inotify_rm_watch: ::c_long = 293; +pub const SYS_migrate_pages: ::c_long = 294; +pub const SYS_openat: ::c_long = 295; +pub const SYS_mkdirat: ::c_long = 296; +pub const SYS_mknodat: ::c_long = 297; +pub const SYS_fchownat: ::c_long = 298; +pub const SYS_futimesat: ::c_long = 299; +pub const SYS_fstatat64: ::c_long = 300; +pub const SYS_unlinkat: ::c_long = 301; +pub const SYS_renameat: ::c_long = 302; +pub const SYS_linkat: ::c_long = 303; +pub const SYS_symlinkat: ::c_long = 304; +pub const SYS_readlinkat: ::c_long = 305; +pub const SYS_fchmodat: ::c_long = 306; +pub const SYS_faccessat: ::c_long = 307; +pub const SYS_pselect6: ::c_long = 308; +pub const SYS_ppoll: ::c_long = 309; +pub const SYS_unshare: ::c_long = 310; +pub const SYS_set_robust_list: ::c_long = 311; +pub const SYS_get_robust_list: ::c_long = 312; +pub const SYS_splice: ::c_long = 313; +pub const SYS_sync_file_range: ::c_long = 314; +pub const SYS_tee: ::c_long = 315; +pub const SYS_vmsplice: ::c_long = 316; +pub const SYS_move_pages: ::c_long = 317; +pub const SYS_getcpu: ::c_long = 318; +pub const SYS_epoll_pwait: ::c_long = 319; +pub const SYS_utimensat: ::c_long = 320; +pub const SYS_signalfd: ::c_long = 321; +pub const SYS_timerfd_create: ::c_long = 322; +pub const SYS_eventfd: ::c_long = 323; +pub const SYS_fallocate: ::c_long = 324; +pub const SYS_timerfd_settime: ::c_long = 325; +pub const SYS_timerfd_gettime: ::c_long = 326; +pub const SYS_signalfd4: ::c_long = 327; +pub const SYS_eventfd2: ::c_long = 328; +pub const SYS_epoll_create1: ::c_long = 329; +pub const SYS_dup3: ::c_long = 330; +pub const SYS_pipe2: ::c_long = 331; +pub const SYS_inotify_init1: ::c_long = 332; +pub const SYS_preadv: ::c_long = 333; +pub const SYS_pwritev: ::c_long = 334; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 335; +pub const SYS_perf_event_open: ::c_long = 336; +pub const SYS_recvmmsg: ::c_long = 337; +pub const SYS_fanotify_init: ::c_long = 338; +pub const SYS_fanotify_mark: ::c_long = 339; +pub const SYS_prlimit64: ::c_long = 340; +pub const SYS_name_to_handle_at: ::c_long = 341; +pub const SYS_open_by_handle_at: ::c_long = 342; +pub const SYS_clock_adjtime: ::c_long = 343; +pub const SYS_syncfs: ::c_long = 344; +pub const SYS_sendmmsg: ::c_long = 345; +pub const SYS_setns: ::c_long = 346; +pub const SYS_process_vm_readv: ::c_long = 347; +pub const SYS_process_vm_writev: ::c_long = 348; +pub const SYS_kcmp: ::c_long = 349; +pub const SYS_finit_module: ::c_long = 350; +pub const SYS_sched_setattr: ::c_long = 351; +pub const SYS_sched_getattr: ::c_long = 352; +pub const SYS_renameat2: ::c_long = 353; +pub const SYS_seccomp: ::c_long = 354; +pub const SYS_getrandom: ::c_long = 355; +pub const SYS_memfd_create: ::c_long = 356; +pub const SYS_bpf: ::c_long = 357; +pub const SYS_execveat: ::c_long = 358; +pub const SYS_socket: ::c_long = 359; +pub const SYS_socketpair: ::c_long = 360; +pub const SYS_bind: ::c_long = 361; +pub const SYS_connect: ::c_long = 362; +pub const SYS_listen: ::c_long = 363; +pub const SYS_accept4: ::c_long = 364; +pub const SYS_getsockopt: ::c_long = 365; +pub const SYS_setsockopt: ::c_long = 366; +pub const SYS_getsockname: ::c_long = 367; +pub const SYS_getpeername: ::c_long = 368; +pub const SYS_sendto: ::c_long = 369; +pub const SYS_sendmsg: ::c_long = 370; +pub const SYS_recvfrom: ::c_long = 371; +pub const SYS_recvmsg: ::c_long = 372; +pub const SYS_shutdown: ::c_long = 373; +pub const SYS_userfaultfd: ::c_long = 374; +pub const SYS_membarrier: ::c_long = 375; +pub const SYS_mlock2: ::c_long = 376; +pub const SYS_copy_file_range: ::c_long = 377; +pub const SYS_preadv2: ::c_long = 378; +pub const SYS_pwritev2: ::c_long = 379; +pub const SYS_pkey_mprotect: ::c_long = 380; +pub const SYS_pkey_alloc: ::c_long = 381; +pub const SYS_pkey_free: ::c_long = 382; + +// offsets in user_regs_structs, from sys/reg.h +pub const EBX: ::c_int = 0; +pub const ECX: ::c_int = 1; +pub const EDX: ::c_int = 2; +pub const ESI: ::c_int = 3; +pub const EDI: ::c_int = 4; +pub const EBP: ::c_int = 5; +pub const EAX: ::c_int = 6; +pub const DS: ::c_int = 7; +pub const ES: ::c_int = 8; +pub const FS: ::c_int = 9; +pub const GS: ::c_int = 10; +pub const ORIG_EAX: ::c_int = 11; +pub const EIP: ::c_int = 12; +pub const CS: ::c_int = 13; +pub const EFL: ::c_int = 14; +pub const UESP: ::c_int = 15; +pub const SS: ::c_int = 16; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/aarch64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/aarch64/align.rs new file mode 100644 index 0000000..8e94996 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/aarch64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/aarch64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/aarch64/mod.rs new file mode 100644 index 0000000..b2b9188 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -0,0 +1,332 @@ +pub type c_char = u8; +pub type wchar_t = u32; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::c_uint, + pub st_nlink: ::c_uint, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad1: ::c_ulong, + pub st_size: ::off64_t, + pub st_blksize: ::c_int, + __pad2: ::c_int, + pub st_blocks: ::c_long, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused4: ::c_uint, + __unused5: ::c_uint, + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::c_uint, + pub st_nlink: ::c_uint, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad1: ::c_ulong, + pub st_size: ::off64_t, + pub st_blksize: ::c_int, + __pad2: ::c_int, + pub st_blocks: ::c_long, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused4: ::c_uint, + __unused5: ::c_uint, + } +} + +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_LARGEFILE: ::c_int = 0o400000; + +pub const SIGSTKSZ: ::size_t = 16384; +pub const MINSIGSTKSZ: ::size_t = 5120; + +pub const SYS_io_setup: ::c_long = 0; +pub const SYS_io_destroy: ::c_long = 1; +pub const SYS_io_submit: ::c_long = 2; +pub const SYS_io_cancel: ::c_long = 3; +pub const SYS_io_getevents: ::c_long = 4; +pub const SYS_setxattr: ::c_long = 5; +pub const SYS_lsetxattr: ::c_long = 6; +pub const SYS_fsetxattr: ::c_long = 7; +pub const SYS_getxattr: ::c_long = 8; +pub const SYS_lgetxattr: ::c_long = 9; +pub const SYS_fgetxattr: ::c_long = 10; +pub const SYS_listxattr: ::c_long = 11; +pub const SYS_llistxattr: ::c_long = 12; +pub const SYS_flistxattr: ::c_long = 13; +pub const SYS_removexattr: ::c_long = 14; +pub const SYS_lremovexattr: ::c_long = 15; +pub const SYS_fremovexattr: ::c_long = 16; +pub const SYS_getcwd: ::c_long = 17; +pub const SYS_lookup_dcookie: ::c_long = 18; +pub const SYS_eventfd2: ::c_long = 19; +pub const SYS_epoll_create1: ::c_long = 20; +pub const SYS_epoll_ctl: ::c_long = 21; +pub const SYS_epoll_pwait: ::c_long = 22; +pub const SYS_dup: ::c_long = 23; +pub const SYS_dup3: ::c_long = 24; +pub const SYS_inotify_init1: ::c_long = 26; +pub const SYS_inotify_add_watch: ::c_long = 27; +pub const SYS_inotify_rm_watch: ::c_long = 28; +pub const SYS_ioctl: ::c_long = 29; +pub const SYS_ioprio_set: ::c_long = 30; +pub const SYS_ioprio_get: ::c_long = 31; +pub const SYS_flock: ::c_long = 32; +pub const SYS_mknodat: ::c_long = 33; +pub const SYS_mkdirat: ::c_long = 34; +pub const SYS_unlinkat: ::c_long = 35; +pub const SYS_symlinkat: ::c_long = 36; +pub const SYS_linkat: ::c_long = 37; +pub const SYS_renameat: ::c_long = 38; +pub const SYS_umount2: ::c_long = 39; +pub const SYS_mount: ::c_long = 40; +pub const SYS_pivot_root: ::c_long = 41; +pub const SYS_nfsservctl: ::c_long = 42; +pub const SYS_fallocate: ::c_long = 47; +pub const SYS_faccessat: ::c_long = 48; +pub const SYS_chdir: ::c_long = 49; +pub const SYS_fchdir: ::c_long = 50; +pub const SYS_chroot: ::c_long = 51; +pub const SYS_fchmod: ::c_long = 52; +pub const SYS_fchmodat: ::c_long = 53; +pub const SYS_fchownat: ::c_long = 54; +pub const SYS_fchown: ::c_long = 55; +pub const SYS_openat: ::c_long = 56; +pub const SYS_close: ::c_long = 57; +pub const SYS_vhangup: ::c_long = 58; +pub const SYS_pipe2: ::c_long = 59; +pub const SYS_quotactl: ::c_long = 60; +pub const SYS_getdents64: ::c_long = 61; +pub const SYS_read: ::c_long = 63; +pub const SYS_write: ::c_long = 64; +pub const SYS_readv: ::c_long = 65; +pub const SYS_writev: ::c_long = 66; +pub const SYS_pread64: ::c_long = 67; +pub const SYS_pwrite64: ::c_long = 68; +pub const SYS_preadv: ::c_long = 69; +pub const SYS_pwritev: ::c_long = 70; +pub const SYS_pselect6: ::c_long = 72; +pub const SYS_ppoll: ::c_long = 73; +pub const SYS_signalfd4: ::c_long = 74; +pub const SYS_vmsplice: ::c_long = 75; +pub const SYS_splice: ::c_long = 76; +pub const SYS_tee: ::c_long = 77; +pub const SYS_readlinkat: ::c_long = 78; +pub const SYS_sync: ::c_long = 81; +pub const SYS_fsync: ::c_long = 82; +pub const SYS_fdatasync: ::c_long = 83; +pub const SYS_sync_file_range: ::c_long = 84; +pub const SYS_timerfd_create: ::c_long = 85; +pub const SYS_timerfd_settime: ::c_long = 86; +pub const SYS_timerfd_gettime: ::c_long = 87; +pub const SYS_utimensat: ::c_long = 88; +pub const SYS_acct: ::c_long = 89; +pub const SYS_capget: ::c_long = 90; +pub const SYS_capset: ::c_long = 91; +pub const SYS_personality: ::c_long = 92; +pub const SYS_exit: ::c_long = 93; +pub const SYS_exit_group: ::c_long = 94; +pub const SYS_waitid: ::c_long = 95; +pub const SYS_set_tid_address: ::c_long = 96; +pub const SYS_unshare: ::c_long = 97; +pub const SYS_futex: ::c_long = 98; +pub const SYS_set_robust_list: ::c_long = 99; +pub const SYS_get_robust_list: ::c_long = 100; +pub const SYS_nanosleep: ::c_long = 101; +pub const SYS_getitimer: ::c_long = 102; +pub const SYS_setitimer: ::c_long = 103; +pub const SYS_kexec_load: ::c_long = 104; +pub const SYS_init_module: ::c_long = 105; +pub const SYS_delete_module: ::c_long = 106; +pub const SYS_timer_create: ::c_long = 107; +pub const SYS_timer_gettime: ::c_long = 108; +pub const SYS_timer_getoverrun: ::c_long = 109; +pub const SYS_timer_settime: ::c_long = 110; +pub const SYS_timer_delete: ::c_long = 111; +pub const SYS_clock_settime: ::c_long = 112; +pub const SYS_clock_gettime: ::c_long = 113; +pub const SYS_clock_getres: ::c_long = 114; +pub const SYS_clock_nanosleep: ::c_long = 115; +pub const SYS_syslog: ::c_long = 116; +pub const SYS_ptrace: ::c_long = 117; +pub const SYS_sched_setparam: ::c_long = 118; +pub const SYS_sched_setscheduler: ::c_long = 119; +pub const SYS_sched_getscheduler: ::c_long = 120; +pub const SYS_sched_getparam: ::c_long = 121; +pub const SYS_sched_setaffinity: ::c_long = 122; +pub const SYS_sched_getaffinity: ::c_long = 123; +pub const SYS_sched_yield: ::c_long = 124; +pub const SYS_sched_get_priority_max: ::c_long = 125; +pub const SYS_sched_get_priority_min: ::c_long = 126; +pub const SYS_sched_rr_get_interval: ::c_long = 127; +pub const SYS_restart_syscall: ::c_long = 128; +pub const SYS_kill: ::c_long = 129; +pub const SYS_tkill: ::c_long = 130; +pub const SYS_tgkill: ::c_long = 131; +pub const SYS_sigaltstack: ::c_long = 132; +pub const SYS_rt_sigsuspend: ::c_long = 133; +pub const SYS_rt_sigaction: ::c_long = 134; +pub const SYS_rt_sigprocmask: ::c_long = 135; +pub const SYS_rt_sigpending: ::c_long = 136; +pub const SYS_rt_sigtimedwait: ::c_long = 137; +pub const SYS_rt_sigqueueinfo: ::c_long = 138; +pub const SYS_rt_sigreturn: ::c_long = 139; +pub const SYS_setpriority: ::c_long = 140; +pub const SYS_getpriority: ::c_long = 141; +pub const SYS_reboot: ::c_long = 142; +pub const SYS_setregid: ::c_long = 143; +pub const SYS_setgid: ::c_long = 144; +pub const SYS_setreuid: ::c_long = 145; +pub const SYS_setuid: ::c_long = 146; +pub const SYS_setresuid: ::c_long = 147; +pub const SYS_getresuid: ::c_long = 148; +pub const SYS_setresgid: ::c_long = 149; +pub const SYS_getresgid: ::c_long = 150; +pub const SYS_setfsuid: ::c_long = 151; +pub const SYS_setfsgid: ::c_long = 152; +pub const SYS_times: ::c_long = 153; +pub const SYS_setpgid: ::c_long = 154; +pub const SYS_getpgid: ::c_long = 155; +pub const SYS_getsid: ::c_long = 156; +pub const SYS_setsid: ::c_long = 157; +pub const SYS_getgroups: ::c_long = 158; +pub const SYS_setgroups: ::c_long = 159; +pub const SYS_uname: ::c_long = 160; +pub const SYS_sethostname: ::c_long = 161; +pub const SYS_setdomainname: ::c_long = 162; +pub const SYS_getrlimit: ::c_long = 163; +pub const SYS_setrlimit: ::c_long = 164; +pub const SYS_getrusage: ::c_long = 165; +pub const SYS_umask: ::c_long = 166; +pub const SYS_prctl: ::c_long = 167; +pub const SYS_getcpu: ::c_long = 168; +pub const SYS_gettimeofday: ::c_long = 169; +pub const SYS_settimeofday: ::c_long = 170; +pub const SYS_adjtimex: ::c_long = 171; +pub const SYS_getpid: ::c_long = 172; +pub const SYS_getppid: ::c_long = 173; +pub const SYS_getuid: ::c_long = 174; +pub const SYS_geteuid: ::c_long = 175; +pub const SYS_getgid: ::c_long = 176; +pub const SYS_getegid: ::c_long = 177; +pub const SYS_gettid: ::c_long = 178; +pub const SYS_sysinfo: ::c_long = 179; +pub const SYS_mq_open: ::c_long = 180; +pub const SYS_mq_unlink: ::c_long = 181; +pub const SYS_mq_timedsend: ::c_long = 182; +pub const SYS_mq_timedreceive: ::c_long = 183; +pub const SYS_mq_notify: ::c_long = 184; +pub const SYS_mq_getsetattr: ::c_long = 185; +pub const SYS_msgget: ::c_long = 186; +pub const SYS_msgctl: ::c_long = 187; +pub const SYS_msgrcv: ::c_long = 188; +pub const SYS_msgsnd: ::c_long = 189; +pub const SYS_semget: ::c_long = 190; +pub const SYS_semctl: ::c_long = 191; +pub const SYS_semtimedop: ::c_long = 192; +pub const SYS_semop: ::c_long = 193; +pub const SYS_shmget: ::c_long = 194; +pub const SYS_shmctl: ::c_long = 195; +pub const SYS_shmat: ::c_long = 196; +pub const SYS_shmdt: ::c_long = 197; +pub const SYS_socket: ::c_long = 198; +pub const SYS_socketpair: ::c_long = 199; +pub const SYS_bind: ::c_long = 200; +pub const SYS_listen: ::c_long = 201; +pub const SYS_accept: ::c_long = 202; +pub const SYS_connect: ::c_long = 203; +pub const SYS_getsockname: ::c_long = 204; +pub const SYS_getpeername: ::c_long = 205; +pub const SYS_sendto: ::c_long = 206; +pub const SYS_recvfrom: ::c_long = 207; +pub const SYS_setsockopt: ::c_long = 208; +pub const SYS_getsockopt: ::c_long = 209; +pub const SYS_shutdown: ::c_long = 210; +pub const SYS_sendmsg: ::c_long = 211; +pub const SYS_recvmsg: ::c_long = 212; +pub const SYS_readahead: ::c_long = 213; +pub const SYS_brk: ::c_long = 214; +pub const SYS_munmap: ::c_long = 215; +pub const SYS_mremap: ::c_long = 216; +pub const SYS_add_key: ::c_long = 217; +pub const SYS_request_key: ::c_long = 218; +pub const SYS_keyctl: ::c_long = 219; +pub const SYS_clone: ::c_long = 220; +pub const SYS_execve: ::c_long = 221; +pub const SYS_swapon: ::c_long = 224; +pub const SYS_swapoff: ::c_long = 225; +pub const SYS_mprotect: ::c_long = 226; +pub const SYS_msync: ::c_long = 227; +pub const SYS_mlock: ::c_long = 228; +pub const SYS_munlock: ::c_long = 229; +pub const SYS_mlockall: ::c_long = 230; +pub const SYS_munlockall: ::c_long = 231; +pub const SYS_mincore: ::c_long = 232; +pub const SYS_madvise: ::c_long = 233; +pub const SYS_remap_file_pages: ::c_long = 234; +pub const SYS_mbind: ::c_long = 235; +pub const SYS_get_mempolicy: ::c_long = 236; +pub const SYS_set_mempolicy: ::c_long = 237; +pub const SYS_migrate_pages: ::c_long = 238; +pub const SYS_move_pages: ::c_long = 239; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 240; +pub const SYS_perf_event_open: ::c_long = 241; +pub const SYS_accept4: ::c_long = 242; +pub const SYS_recvmmsg: ::c_long = 243; +pub const SYS_arch_specific_syscall: ::c_long = 244; +pub const SYS_wait4: ::c_long = 260; +pub const SYS_prlimit64: ::c_long = 261; +pub const SYS_fanotify_init: ::c_long = 262; +pub const SYS_fanotify_mark: ::c_long = 263; +pub const SYS_name_to_handle_at: ::c_long = 264; +pub const SYS_open_by_handle_at: ::c_long = 265; +pub const SYS_clock_adjtime: ::c_long = 266; +pub const SYS_syncfs: ::c_long = 267; +pub const SYS_setns: ::c_long = 268; +pub const SYS_sendmmsg: ::c_long = 269; +pub const SYS_process_vm_readv: ::c_long = 270; +pub const SYS_process_vm_writev: ::c_long = 271; +pub const SYS_kcmp: ::c_long = 272; +pub const SYS_finit_module: ::c_long = 273; +pub const SYS_sched_setattr: ::c_long = 274; +pub const SYS_sched_getattr: ::c_long = 275; +pub const SYS_renameat2: ::c_long = 276; +pub const SYS_seccomp: ::c_long = 277; +pub const SYS_getrandom: ::c_long = 278; +pub const SYS_memfd_create: ::c_long = 279; +pub const SYS_bpf: ::c_long = 280; +pub const SYS_execveat: ::c_long = 281; +pub const SYS_userfaultfd: ::c_long = 282; +pub const SYS_membarrier: ::c_long = 283; +pub const SYS_mlock2: ::c_long = 284; +pub const SYS_copy_file_range: ::c_long = 285; +pub const SYS_preadv2: ::c_long = 286; +pub const SYS_pwritev2: ::c_long = 287; +pub const SYS_pkey_mprotect: ::c_long = 288; +pub const SYS_pkey_alloc: ::c_long = 289; +pub const SYS_pkey_free: ::c_long = 290; +pub const SYS_syscalls: ::c_long = 292; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/mod.rs new file mode 100644 index 0000000..9826bb9 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/mod.rs @@ -0,0 +1,281 @@ +// The following definitions are correct for aarch64 and x86_64, +// but may be wrong for mips64 + +pub type c_long = i64; +pub type c_ulong = u64; +pub type mode_t = u32; +pub type off64_t = i64; +pub type socklen_t = u32; + +s! { + pub struct sigset_t { + __val: [::c_ulong; 1], + } + + pub struct sigaction { + pub sa_flags: ::c_int, + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_restorer: ::Option, + } + + pub struct rlimit64 { + pub rlim_cur: ::c_ulonglong, + pub rlim_max: ::c_ulonglong, + } + + pub struct pthread_attr_t { + pub flags: u32, + pub stack_base: *mut ::c_void, + pub stack_size: ::size_t, + pub guard_size: ::size_t, + pub sched_policy: i32, + pub sched_priority: i32, + __reserved: [::c_char; 16], + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct statfs { + pub f_type: u64, + pub f_bsize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::__fsid_t, + pub f_namelen: u64, + pub f_frsize: u64, + pub f_flags: u64, + pub f_spare: [u64; 4], + } + + pub struct sysinfo { + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 0], + } + + pub struct statfs64 { + pub f_type: u64, + pub f_bsize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + f_fsid: [u32; 2], + pub f_namelen: u64, + pub f_frsize: u64, + pub f_flags: u64, + pub f_spare: [u64; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } +} + +s_no_extra_traits! { + pub struct pthread_mutex_t { + value: ::c_int, + __reserved: [::c_char; 36], + } + + pub struct pthread_cond_t { + value: ::c_int, + __reserved: [::c_char; 44], + } + + pub struct pthread_rwlock_t { + numLocks: ::c_int, + writerThreadId: ::c_int, + pendingReaders: ::c_int, + pendingWriters: ::c_int, + attr: i32, + __reserved: [::c_char; 36], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + self.value == other.value + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for pthread_mutex_t {} + + impl ::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_mutex_t") + .field("value", &self.value) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } + } + + impl ::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.value.hash(state); + self.__reserved.hash(state); + } + } + + impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.value == other.value + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for pthread_cond_t {} + + impl ::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_cond_t") + .field("value", &self.value) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } + } + + impl ::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.value.hash(state); + self.__reserved.hash(state); + } + } + + impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + self.numLocks == other.numLocks + && self.writerThreadId == other.writerThreadId + && self.pendingReaders == other.pendingReaders + && self.pendingWriters == other.pendingWriters + && self.attr == other.attr + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for pthread_rwlock_t {} + + impl ::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_rwlock_t") + .field("numLocks", &self.numLocks) + .field("writerThreadId", &self.writerThreadId) + .field("pendingReaders", &self.pendingReaders) + .field("pendingWriters", &self.pendingWriters) + .field("attr", &self.attr) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } + } + + impl ::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.numLocks.hash(state); + self.writerThreadId.hash(state); + self.pendingReaders.hash(state); + self.pendingWriters.hash(state); + self.attr.hash(state); + self.__reserved.hash(state); + } + } + } +} + +// These constants must be of the same type of sigaction.sa_flags +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; + +pub const RTLD_GLOBAL: ::c_int = 0x00100; +pub const RTLD_NOW: ::c_int = 2; +pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + value: 0, + __reserved: [0; 36], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + value: 0, + __reserved: [0; 44], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + numLocks: 0, + writerThreadId: 0, + pendingReaders: 0, + pendingWriters: 0, + attr: 0, + __reserved: [0; 36], +}; +pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 4; +pub const CPU_SETSIZE: ::size_t = 1024; +pub const __CPU_BITS: ::size_t = 64; + +pub const UT_LINESIZE: usize = 32; +pub const UT_NAMESIZE: usize = 32; +pub const UT_HOSTSIZE: usize = 256; + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/x86_64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/x86_64/align.rs new file mode 100644 index 0000000..7ca870f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/x86_64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/x86_64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/x86_64/mod.rs new file mode 100644 index 0000000..f5b8b16 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -0,0 +1,427 @@ +pub type c_char = i8; +pub type wchar_t = i32; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::c_ulong, + pub st_mode: ::c_uint, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_size: ::off64_t, + pub st_blksize: ::c_long, + pub st_blocks: ::c_long, + pub st_atime: ::c_long, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::c_long, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::c_long, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 3], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::c_ulong, + pub st_mode: ::c_uint, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_size: ::off64_t, + pub st_blksize: ::c_long, + pub st_blocks: ::c_long, + pub st_atime: ::c_long, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::c_long, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::c_long, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 3], + } +} + +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_LARGEFILE: ::c_int = 0o0100000; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + +pub const MAP_32BIT: ::c_int = 0x40; + +// Syscall table + +pub const SYS_read: ::c_long = 0; +pub const SYS_write: ::c_long = 1; +pub const SYS_open: ::c_long = 2; +pub const SYS_close: ::c_long = 3; +pub const SYS_stat: ::c_long = 4; +pub const SYS_fstat: ::c_long = 5; +pub const SYS_lstat: ::c_long = 6; +pub const SYS_poll: ::c_long = 7; +pub const SYS_lseek: ::c_long = 8; +pub const SYS_mmap: ::c_long = 9; +pub const SYS_mprotect: ::c_long = 10; +pub const SYS_munmap: ::c_long = 11; +pub const SYS_brk: ::c_long = 12; +pub const SYS_rt_sigaction: ::c_long = 13; +pub const SYS_rt_sigprocmask: ::c_long = 14; +pub const SYS_rt_sigreturn: ::c_long = 15; +pub const SYS_ioctl: ::c_long = 16; +pub const SYS_pread64: ::c_long = 17; +pub const SYS_pwrite64: ::c_long = 18; +pub const SYS_readv: ::c_long = 19; +pub const SYS_writev: ::c_long = 20; +pub const SYS_access: ::c_long = 21; +pub const SYS_pipe: ::c_long = 22; +pub const SYS_select: ::c_long = 23; +pub const SYS_sched_yield: ::c_long = 24; +pub const SYS_mremap: ::c_long = 25; +pub const SYS_msync: ::c_long = 26; +pub const SYS_mincore: ::c_long = 27; +pub const SYS_madvise: ::c_long = 28; +pub const SYS_shmget: ::c_long = 29; +pub const SYS_shmat: ::c_long = 30; +pub const SYS_shmctl: ::c_long = 31; +pub const SYS_dup: ::c_long = 32; +pub const SYS_dup2: ::c_long = 33; +pub const SYS_pause: ::c_long = 34; +pub const SYS_nanosleep: ::c_long = 35; +pub const SYS_getitimer: ::c_long = 36; +pub const SYS_alarm: ::c_long = 37; +pub const SYS_setitimer: ::c_long = 38; +pub const SYS_getpid: ::c_long = 39; +pub const SYS_sendfile: ::c_long = 40; +pub const SYS_socket: ::c_long = 41; +pub const SYS_connect: ::c_long = 42; +pub const SYS_accept: ::c_long = 43; +pub const SYS_sendto: ::c_long = 44; +pub const SYS_recvfrom: ::c_long = 45; +pub const SYS_sendmsg: ::c_long = 46; +pub const SYS_recvmsg: ::c_long = 47; +pub const SYS_shutdown: ::c_long = 48; +pub const SYS_bind: ::c_long = 49; +pub const SYS_listen: ::c_long = 50; +pub const SYS_getsockname: ::c_long = 51; +pub const SYS_getpeername: ::c_long = 52; +pub const SYS_socketpair: ::c_long = 53; +pub const SYS_setsockopt: ::c_long = 54; +pub const SYS_getsockopt: ::c_long = 55; +pub const SYS_clone: ::c_long = 56; +pub const SYS_fork: ::c_long = 57; +pub const SYS_vfork: ::c_long = 58; +pub const SYS_execve: ::c_long = 59; +pub const SYS_exit: ::c_long = 60; +pub const SYS_wait4: ::c_long = 61; +pub const SYS_kill: ::c_long = 62; +pub const SYS_uname: ::c_long = 63; +pub const SYS_semget: ::c_long = 64; +pub const SYS_semop: ::c_long = 65; +pub const SYS_semctl: ::c_long = 66; +pub const SYS_shmdt: ::c_long = 67; +pub const SYS_msgget: ::c_long = 68; +pub const SYS_msgsnd: ::c_long = 69; +pub const SYS_msgrcv: ::c_long = 70; +pub const SYS_msgctl: ::c_long = 71; +pub const SYS_fcntl: ::c_long = 72; +pub const SYS_flock: ::c_long = 73; +pub const SYS_fsync: ::c_long = 74; +pub const SYS_fdatasync: ::c_long = 75; +pub const SYS_truncate: ::c_long = 76; +pub const SYS_ftruncate: ::c_long = 77; +pub const SYS_getdents: ::c_long = 78; +pub const SYS_getcwd: ::c_long = 79; +pub const SYS_chdir: ::c_long = 80; +pub const SYS_fchdir: ::c_long = 81; +pub const SYS_rename: ::c_long = 82; +pub const SYS_mkdir: ::c_long = 83; +pub const SYS_rmdir: ::c_long = 84; +pub const SYS_creat: ::c_long = 85; +pub const SYS_link: ::c_long = 86; +pub const SYS_unlink: ::c_long = 87; +pub const SYS_symlink: ::c_long = 88; +pub const SYS_readlink: ::c_long = 89; +pub const SYS_chmod: ::c_long = 90; +pub const SYS_fchmod: ::c_long = 91; +pub const SYS_chown: ::c_long = 92; +pub const SYS_fchown: ::c_long = 93; +pub const SYS_lchown: ::c_long = 94; +pub const SYS_umask: ::c_long = 95; +pub const SYS_gettimeofday: ::c_long = 96; +pub const SYS_getrlimit: ::c_long = 97; +pub const SYS_getrusage: ::c_long = 98; +pub const SYS_sysinfo: ::c_long = 99; +pub const SYS_times: ::c_long = 100; +pub const SYS_ptrace: ::c_long = 101; +pub const SYS_getuid: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_getgid: ::c_long = 104; +pub const SYS_setuid: ::c_long = 105; +pub const SYS_setgid: ::c_long = 106; +pub const SYS_geteuid: ::c_long = 107; +pub const SYS_getegid: ::c_long = 108; +pub const SYS_setpgid: ::c_long = 109; +pub const SYS_getppid: ::c_long = 110; +pub const SYS_getpgrp: ::c_long = 111; +pub const SYS_setsid: ::c_long = 112; +pub const SYS_setreuid: ::c_long = 113; +pub const SYS_setregid: ::c_long = 114; +pub const SYS_getgroups: ::c_long = 115; +pub const SYS_setgroups: ::c_long = 116; +pub const SYS_setresuid: ::c_long = 117; +pub const SYS_getresuid: ::c_long = 118; +pub const SYS_setresgid: ::c_long = 119; +pub const SYS_getresgid: ::c_long = 120; +pub const SYS_getpgid: ::c_long = 121; +pub const SYS_setfsuid: ::c_long = 122; +pub const SYS_setfsgid: ::c_long = 123; +pub const SYS_getsid: ::c_long = 124; +pub const SYS_capget: ::c_long = 125; +pub const SYS_capset: ::c_long = 126; +pub const SYS_rt_sigpending: ::c_long = 127; +pub const SYS_rt_sigtimedwait: ::c_long = 128; +pub const SYS_rt_sigqueueinfo: ::c_long = 129; +pub const SYS_rt_sigsuspend: ::c_long = 130; +pub const SYS_sigaltstack: ::c_long = 131; +pub const SYS_utime: ::c_long = 132; +pub const SYS_mknod: ::c_long = 133; +pub const SYS_uselib: ::c_long = 134; +pub const SYS_personality: ::c_long = 135; +pub const SYS_ustat: ::c_long = 136; +pub const SYS_statfs: ::c_long = 137; +pub const SYS_fstatfs: ::c_long = 138; +pub const SYS_sysfs: ::c_long = 139; +pub const SYS_getpriority: ::c_long = 140; +pub const SYS_setpriority: ::c_long = 141; +pub const SYS_sched_setparam: ::c_long = 142; +pub const SYS_sched_getparam: ::c_long = 143; +pub const SYS_sched_setscheduler: ::c_long = 144; +pub const SYS_sched_getscheduler: ::c_long = 145; +pub const SYS_sched_get_priority_max: ::c_long = 146; +pub const SYS_sched_get_priority_min: ::c_long = 147; +pub const SYS_sched_rr_get_interval: ::c_long = 148; +pub const SYS_mlock: ::c_long = 149; +pub const SYS_munlock: ::c_long = 150; +pub const SYS_mlockall: ::c_long = 151; +pub const SYS_munlockall: ::c_long = 152; +pub const SYS_vhangup: ::c_long = 153; +pub const SYS_modify_ldt: ::c_long = 154; +pub const SYS_pivot_root: ::c_long = 155; +// FIXME: SYS__sysctl is in the NDK sources but for some reason is +// not available in the tests +// pub const SYS__sysctl: ::c_long = 156; +pub const SYS_prctl: ::c_long = 157; +pub const SYS_arch_prctl: ::c_long = 158; +pub const SYS_adjtimex: ::c_long = 159; +pub const SYS_setrlimit: ::c_long = 160; +pub const SYS_chroot: ::c_long = 161; +pub const SYS_sync: ::c_long = 162; +pub const SYS_acct: ::c_long = 163; +pub const SYS_settimeofday: ::c_long = 164; +pub const SYS_mount: ::c_long = 165; +pub const SYS_umount2: ::c_long = 166; +pub const SYS_swapon: ::c_long = 167; +pub const SYS_swapoff: ::c_long = 168; +pub const SYS_reboot: ::c_long = 169; +pub const SYS_sethostname: ::c_long = 170; +pub const SYS_setdomainname: ::c_long = 171; +pub const SYS_iopl: ::c_long = 172; +pub const SYS_ioperm: ::c_long = 173; +pub const SYS_create_module: ::c_long = 174; +pub const SYS_init_module: ::c_long = 175; +pub const SYS_delete_module: ::c_long = 176; +pub const SYS_get_kernel_syms: ::c_long = 177; +pub const SYS_query_module: ::c_long = 178; +pub const SYS_quotactl: ::c_long = 179; +pub const SYS_nfsservctl: ::c_long = 180; +pub const SYS_getpmsg: ::c_long = 181; +pub const SYS_putpmsg: ::c_long = 182; +pub const SYS_afs_syscall: ::c_long = 183; +pub const SYS_tuxcall: ::c_long = 184; +pub const SYS_security: ::c_long = 185; +pub const SYS_gettid: ::c_long = 186; +pub const SYS_readahead: ::c_long = 187; +pub const SYS_setxattr: ::c_long = 188; +pub const SYS_lsetxattr: ::c_long = 189; +pub const SYS_fsetxattr: ::c_long = 190; +pub const SYS_getxattr: ::c_long = 191; +pub const SYS_lgetxattr: ::c_long = 192; +pub const SYS_fgetxattr: ::c_long = 193; +pub const SYS_listxattr: ::c_long = 194; +pub const SYS_llistxattr: ::c_long = 195; +pub const SYS_flistxattr: ::c_long = 196; +pub const SYS_removexattr: ::c_long = 197; +pub const SYS_lremovexattr: ::c_long = 198; +pub const SYS_fremovexattr: ::c_long = 199; +pub const SYS_tkill: ::c_long = 200; +pub const SYS_time: ::c_long = 201; +pub const SYS_futex: ::c_long = 202; +pub const SYS_sched_setaffinity: ::c_long = 203; +pub const SYS_sched_getaffinity: ::c_long = 204; +pub const SYS_set_thread_area: ::c_long = 205; +pub const SYS_io_setup: ::c_long = 206; +pub const SYS_io_destroy: ::c_long = 207; +pub const SYS_io_getevents: ::c_long = 208; +pub const SYS_io_submit: ::c_long = 209; +pub const SYS_io_cancel: ::c_long = 210; +pub const SYS_get_thread_area: ::c_long = 211; +pub const SYS_lookup_dcookie: ::c_long = 212; +pub const SYS_epoll_create: ::c_long = 213; +pub const SYS_epoll_ctl_old: ::c_long = 214; +pub const SYS_epoll_wait_old: ::c_long = 215; +pub const SYS_remap_file_pages: ::c_long = 216; +pub const SYS_getdents64: ::c_long = 217; +pub const SYS_set_tid_address: ::c_long = 218; +pub const SYS_restart_syscall: ::c_long = 219; +pub const SYS_semtimedop: ::c_long = 220; +pub const SYS_fadvise64: ::c_long = 221; +pub const SYS_timer_create: ::c_long = 222; +pub const SYS_timer_settime: ::c_long = 223; +pub const SYS_timer_gettime: ::c_long = 224; +pub const SYS_timer_getoverrun: ::c_long = 225; +pub const SYS_timer_delete: ::c_long = 226; +pub const SYS_clock_settime: ::c_long = 227; +pub const SYS_clock_gettime: ::c_long = 228; +pub const SYS_clock_getres: ::c_long = 229; +pub const SYS_clock_nanosleep: ::c_long = 230; +pub const SYS_exit_group: ::c_long = 231; +pub const SYS_epoll_wait: ::c_long = 232; +pub const SYS_epoll_ctl: ::c_long = 233; +pub const SYS_tgkill: ::c_long = 234; +pub const SYS_utimes: ::c_long = 235; +pub const SYS_vserver: ::c_long = 236; +pub const SYS_mbind: ::c_long = 237; +pub const SYS_set_mempolicy: ::c_long = 238; +pub const SYS_get_mempolicy: ::c_long = 239; +pub const SYS_mq_open: ::c_long = 240; +pub const SYS_mq_unlink: ::c_long = 241; +pub const SYS_mq_timedsend: ::c_long = 242; +pub const SYS_mq_timedreceive: ::c_long = 243; +pub const SYS_mq_notify: ::c_long = 244; +pub const SYS_mq_getsetattr: ::c_long = 245; +pub const SYS_kexec_load: ::c_long = 246; +pub const SYS_waitid: ::c_long = 247; +pub const SYS_add_key: ::c_long = 248; +pub const SYS_request_key: ::c_long = 249; +pub const SYS_keyctl: ::c_long = 250; +pub const SYS_ioprio_set: ::c_long = 251; +pub const SYS_ioprio_get: ::c_long = 252; +pub const SYS_inotify_init: ::c_long = 253; +pub const SYS_inotify_add_watch: ::c_long = 254; +pub const SYS_inotify_rm_watch: ::c_long = 255; +pub const SYS_migrate_pages: ::c_long = 256; +pub const SYS_openat: ::c_long = 257; +pub const SYS_mkdirat: ::c_long = 258; +pub const SYS_mknodat: ::c_long = 259; +pub const SYS_fchownat: ::c_long = 260; +pub const SYS_futimesat: ::c_long = 261; +pub const SYS_newfstatat: ::c_long = 262; +pub const SYS_unlinkat: ::c_long = 263; +pub const SYS_renameat: ::c_long = 264; +pub const SYS_linkat: ::c_long = 265; +pub const SYS_symlinkat: ::c_long = 266; +pub const SYS_readlinkat: ::c_long = 267; +pub const SYS_fchmodat: ::c_long = 268; +pub const SYS_faccessat: ::c_long = 269; +pub const SYS_pselect6: ::c_long = 270; +pub const SYS_ppoll: ::c_long = 271; +pub const SYS_unshare: ::c_long = 272; +pub const SYS_set_robust_list: ::c_long = 273; +pub const SYS_get_robust_list: ::c_long = 274; +pub const SYS_splice: ::c_long = 275; +pub const SYS_tee: ::c_long = 276; +pub const SYS_sync_file_range: ::c_long = 277; +pub const SYS_vmsplice: ::c_long = 278; +pub const SYS_move_pages: ::c_long = 279; +pub const SYS_utimensat: ::c_long = 280; +pub const SYS_epoll_pwait: ::c_long = 281; +pub const SYS_signalfd: ::c_long = 282; +pub const SYS_timerfd_create: ::c_long = 283; +pub const SYS_eventfd: ::c_long = 284; +pub const SYS_fallocate: ::c_long = 285; +pub const SYS_timerfd_settime: ::c_long = 286; +pub const SYS_timerfd_gettime: ::c_long = 287; +pub const SYS_accept4: ::c_long = 288; +pub const SYS_signalfd4: ::c_long = 289; +pub const SYS_eventfd2: ::c_long = 290; +pub const SYS_epoll_create1: ::c_long = 291; +pub const SYS_dup3: ::c_long = 292; +pub const SYS_pipe2: ::c_long = 293; +pub const SYS_inotify_init1: ::c_long = 294; +pub const SYS_preadv: ::c_long = 295; +pub const SYS_pwritev: ::c_long = 296; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 297; +pub const SYS_perf_event_open: ::c_long = 298; +pub const SYS_recvmmsg: ::c_long = 299; +pub const SYS_fanotify_init: ::c_long = 300; +pub const SYS_fanotify_mark: ::c_long = 301; +pub const SYS_prlimit64: ::c_long = 302; +pub const SYS_name_to_handle_at: ::c_long = 303; +pub const SYS_open_by_handle_at: ::c_long = 304; +pub const SYS_clock_adjtime: ::c_long = 305; +pub const SYS_syncfs: ::c_long = 306; +pub const SYS_sendmmsg: ::c_long = 307; +pub const SYS_setns: ::c_long = 308; +pub const SYS_getcpu: ::c_long = 309; +pub const SYS_process_vm_readv: ::c_long = 310; +pub const SYS_process_vm_writev: ::c_long = 311; +pub const SYS_kcmp: ::c_long = 312; +pub const SYS_finit_module: ::c_long = 313; +pub const SYS_sched_setattr: ::c_long = 314; +pub const SYS_sched_getattr: ::c_long = 315; +pub const SYS_renameat2: ::c_long = 316; +pub const SYS_seccomp: ::c_long = 317; +pub const SYS_getrandom: ::c_long = 318; +pub const SYS_memfd_create: ::c_long = 319; +pub const SYS_kexec_file_load: ::c_long = 320; +pub const SYS_bpf: ::c_long = 321; +pub const SYS_execveat: ::c_long = 322; +pub const SYS_userfaultfd: ::c_long = 323; +pub const SYS_membarrier: ::c_long = 324; +pub const SYS_mlock2: ::c_long = 325; +pub const SYS_copy_file_range: ::c_long = 326; +pub const SYS_preadv2: ::c_long = 327; +pub const SYS_pwritev2: ::c_long = 328; +pub const SYS_pkey_mprotect: ::c_long = 329; +pub const SYS_pkey_alloc: ::c_long = 330; +pub const SYS_pkey_free: ::c_long = 331; + +// offsets in user_regs_structs, from sys/reg.h +pub const R15: ::c_int = 0; +pub const R14: ::c_int = 1; +pub const R13: ::c_int = 2; +pub const R12: ::c_int = 3; +pub const RBP: ::c_int = 4; +pub const RBX: ::c_int = 5; +pub const R11: ::c_int = 6; +pub const R10: ::c_int = 7; +pub const R9: ::c_int = 8; +pub const R8: ::c_int = 9; +pub const RAX: ::c_int = 10; +pub const RCX: ::c_int = 11; +pub const RDX: ::c_int = 12; +pub const RSI: ::c_int = 13; +pub const RDI: ::c_int = 14; +pub const ORIG_RAX: ::c_int = 15; +pub const RIP: ::c_int = 16; +pub const CS: ::c_int = 17; +pub const EFLAGS: ::c_int = 18; +pub const RSP: ::c_int = 19; +pub const SS: ::c_int = 20; +pub const FS_BASE: ::c_int = 21; +pub const GS_BASE: ::c_int = 22; +pub const DS: ::c_int = 23; +pub const ES: ::c_int = 24; +pub const FS: ::c_int = 25; +pub const GS: ::c_int = 26; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/mod.rs new file mode 100644 index 0000000..a40b77e --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/android/mod.rs @@ -0,0 +1,2409 @@ +//! Android-specific definitions for linux-like values + +pub type clock_t = ::c_long; +pub type time_t = ::c_long; +pub type suseconds_t = ::c_long; +pub type off_t = ::c_long; +pub type blkcnt_t = ::c_ulong; +pub type blksize_t = ::c_ulong; +pub type nlink_t = u32; +pub type useconds_t = u32; +pub type pthread_t = ::c_long; +pub type pthread_mutexattr_t = ::c_long; +pub type pthread_rwlockattr_t = ::c_long; +pub type pthread_condattr_t = ::c_long; +pub type pthread_key_t = ::c_int; +pub type fsfilcnt_t = ::c_ulong; +pub type fsblkcnt_t = ::c_ulong; +pub type nfds_t = ::c_uint; +pub type rlim_t = ::c_ulong; +pub type dev_t = ::c_ulong; +pub type ino_t = ::c_ulong; +pub type __CPU_BITTYPE = ::c_ulong; +pub type idtype_t = ::c_int; +pub type loff_t = ::c_longlong; +pub type __kernel_loff_t = ::c_longlong; +pub type __kernel_pid_t = ::c_int; + +s! { + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct __fsid_t { + __val: [::c_int; 2], + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::size_t, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::size_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::size_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::__kernel_loff_t, + pub l_len: ::__kernel_loff_t, + pub l_pid: ::__kernel_pid_t, + } + + pub struct cpu_set_t { + #[cfg(target_pointer_width = "64")] + __bits: [__CPU_BITTYPE; 16], + #[cfg(target_pointer_width = "32")] + __bits: [__CPU_BITTYPE; 1], + } + + pub struct sem_t { + count: ::c_uint, + #[cfg(target_pointer_width = "64")] + __reserved: [::c_int; 3], + } + + pub struct exit_status { + pub e_termination: ::c_short, + pub e_exit: ::c_short, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + #[cfg(target_pointer_width = "64")] + __f_reserved: [u32; 6], + } + + pub struct signalfd_siginfo { + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: ::c_ulonglong, + pub ssi_utime: ::c_ulonglong, + pub ssi_stime: ::c_ulonglong, + pub ssi_addr: ::c_ulonglong, + pub ssi_addr_lsb: u16, + _pad2: u16, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: [u8; 28], + } + + pub struct ucred { + pub pid: ::pid_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + } + + pub struct genlmsghdr { + pub cmd: u8, + pub version: u8, + pub reserved: u16, + } + + pub struct nlmsghdr { + pub nlmsg_len: u32, + pub nlmsg_type: u16, + pub nlmsg_flags: u16, + pub nlmsg_seq: u32, + pub nlmsg_pid: u32, + } + + pub struct nlmsgerr { + pub error: ::c_int, + pub msg: nlmsghdr, + } + + pub struct nl_pktinfo { + pub group: u32, + } + + pub struct nl_mmap_req { + pub nm_block_size: ::c_uint, + pub nm_block_nr: ::c_uint, + pub nm_frame_size: ::c_uint, + pub nm_frame_nr: ::c_uint, + } + + pub struct nl_mmap_hdr { + pub nm_status: ::c_uint, + pub nm_len: ::c_uint, + pub nm_group: u32, + pub nm_pid: u32, + pub nm_uid: u32, + pub nm_gid: u32, + } + + pub struct nlattr { + pub nla_len: u16, + pub nla_type: u16, + } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_int, + } + + pub struct inotify_event { + pub wd: ::c_int, + pub mask: u32, + pub cookie: u32, + pub len: u32 + } +} + +s_no_extra_traits! { + pub struct sockaddr_nl { + pub nl_family: ::sa_family_t, + nl_pad: ::c_ushort, + pub nl_pid: u32, + pub nl_groups: u32 + } + + pub struct dirent { + pub d_ino: u64, + pub d_off: i64, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct dirent64 { + pub d_ino: u64, + pub d_off: i64, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct lastlog { + ll_time: ::time_t, + ll_line: [::c_char; UT_LINESIZE], + ll_host: [::c_char; UT_HOSTSIZE], + } + + pub struct utmp { + pub ut_type: ::c_short, + pub ut_pid: ::pid_t, + pub ut_line: [::c_char; UT_LINESIZE], + pub ut_id: [::c_char; 4], + pub ut_user: [::c_char; UT_NAMESIZE], + pub ut_host: [::c_char; UT_HOSTSIZE], + pub ut_exit: exit_status, + pub ut_session: ::c_long, + pub ut_tv: ::timeval, + pub ut_addr_v6: [i32; 4], + unused: [::c_char; 20], + } + + pub struct sockaddr_alg { + pub salg_family: ::sa_family_t, + pub salg_type: [::c_uchar; 14], + pub salg_feat: u32, + pub salg_mask: u32, + pub salg_name: [::c_uchar; 64], + } + + pub struct af_alg_iv { + pub ivlen: u32, + pub iv: [::c_uchar; 0], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sockaddr_nl { + fn eq(&self, other: &sockaddr_nl) -> bool { + self.nl_family == other.nl_family && + self.nl_pid == other.nl_pid && + self.nl_groups == other.nl_groups + } + } + impl Eq for sockaddr_nl {} + impl ::fmt::Debug for sockaddr_nl { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_nl") + .field("nl_family", &self.nl_family) + .field("nl_pid", &self.nl_pid) + .field("nl_groups", &self.nl_groups) + .finish() + } + } + impl ::hash::Hash for sockaddr_nl { + fn hash(&self, state: &mut H) { + self.nl_family.hash(state); + self.nl_pid.hash(state); + self.nl_groups.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for dirent {} + + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for dirent64 { + fn eq(&self, other: &dirent64) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for dirent64 {} + + impl ::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent64") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + + impl ::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for siginfo_t { + fn eq(&self, other: &siginfo_t) -> bool { + self.si_signo == other.si_signo + && self.si_errno == other.si_errno + && self.si_code == other.si_code + // Ignore _pad + // Ignore _align + } + } + + impl Eq for siginfo_t {} + + impl ::fmt::Debug for siginfo_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("siginfo_t") + .field("si_signo", &self.si_signo) + .field("si_errno", &self.si_errno) + .field("si_code", &self.si_code) + // Ignore _pad + // Ignore _align + .finish() + } + } + + impl ::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_errno.hash(state); + self.si_code.hash(state); + // Ignore _pad + // Ignore _align + } + } + + impl PartialEq for lastlog { + fn eq(&self, other: &lastlog) -> bool { + self.ll_time == other.ll_time + && self + .ll_line + .iter() + .zip(other.ll_line.iter()) + .all(|(a,b)| a == b) + && self + .ll_host + .iter() + .zip(other.ll_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for lastlog {} + + impl ::fmt::Debug for lastlog { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("lastlog") + .field("ll_time", &self.ll_time) + .field("ll_line", &self.ll_line) + // FIXME: .field("ll_host", &self.ll_host) + .finish() + } + } + + impl ::hash::Hash for lastlog { + fn hash(&self, state: &mut H) { + self.ll_time.hash(state); + self.ll_line.hash(state); + self.ll_host.hash(state); + } + } + + impl PartialEq for utmp { + fn eq(&self, other: &utmp) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self + .ut_line + .iter() + .zip(other.ut_line.iter()) + .all(|(a,b)| a == b) + && self.ut_id == other.ut_id + && self + .ut_user + .iter() + .zip(other.ut_user.iter()) + .all(|(a,b)| a == b) + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_addr_v6 == other.ut_addr_v6 + && self.unused == other.unused + } + } + + impl Eq for utmp {} + + impl ::fmt::Debug for utmp { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmp") + .field("ut_type", &self.ut_type) + .field("ut_pid", &self.ut_pid) + .field("ut_line", &self.ut_line) + .field("ut_id", &self.ut_id) + .field("ut_user", &self.ut_user) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_exit", &self.ut_exit) + .field("ut_session", &self.ut_session) + .field("ut_tv", &self.ut_tv) + .field("ut_addr_v6", &self.ut_addr_v6) + .field("unused", &self.unused) + .finish() + } + } + + impl ::hash::Hash for utmp { + fn hash(&self, state: &mut H) { + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_user.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_addr_v6.hash(state); + self.unused.hash(state); + } + } + + impl PartialEq for sockaddr_alg { + fn eq(&self, other: &sockaddr_alg) -> bool { + self.salg_family == other.salg_family + && self + .salg_type + .iter() + .zip(other.salg_type.iter()) + .all(|(a, b)| a == b) + && self.salg_feat == other.salg_feat + && self.salg_mask == other.salg_mask + && self + .salg_name + .iter() + .zip(other.salg_name.iter()) + .all(|(a, b)| a == b) + } + } + + impl Eq for sockaddr_alg {} + + impl ::fmt::Debug for sockaddr_alg { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_alg") + .field("salg_family", &self.salg_family) + .field("salg_type", &self.salg_type) + .field("salg_feat", &self.salg_feat) + .field("salg_mask", &self.salg_mask) + .field("salg_name", &&self.salg_name[..]) + .finish() + } + } + + impl ::hash::Hash for sockaddr_alg { + fn hash(&self, state: &mut H) { + self.salg_family.hash(state); + self.salg_type.hash(state); + self.salg_feat.hash(state); + self.salg_mask.hash(state); + self.salg_name.hash(state); + } + } + + impl af_alg_iv { + fn as_slice(&self) -> &[u8] { + unsafe { + ::core::slice::from_raw_parts( + self.iv.as_ptr(), + self.ivlen as usize + ) + } + } + } + + impl PartialEq for af_alg_iv { + fn eq(&self, other: &af_alg_iv) -> bool { + *self.as_slice() == *other.as_slice() + } + } + + impl Eq for af_alg_iv {} + + impl ::fmt::Debug for af_alg_iv { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("af_alg_iv") + .field("iv", &self.as_slice()) + .finish() + } + } + + impl ::hash::Hash for af_alg_iv { + fn hash(&self, state: &mut H) { + self.as_slice().hash(state); + } + } + } +} + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MS_NOUSER: ::c_ulong = 0xffffffff80000000; +pub const MS_RMT_MASK: ::c_ulong = 0x02800051; + +pub const O_TRUNC: ::c_int = 512; +pub const O_CLOEXEC: ::c_int = 0x80000; +pub const O_PATH: ::c_int = 0o10000000; +pub const O_NOATIME: ::c_int = 0o1000000; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; +pub const EPOLLONESHOT: ::c_int = 0x40000000; +pub const EPOLLRDHUP: ::c_int = 0x00002000; +pub const EPOLLWAKEUP: ::c_int = 0x20000000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const USER_PROCESS: ::c_short = 7; + +pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08; + +pub const BUFSIZ: ::c_uint = 1024; +pub const FILENAME_MAX: ::c_uint = 4096; +pub const FOPEN_MAX: ::c_uint = 20; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; +pub const L_tmpnam: ::c_uint = 4096; +pub const TMP_MAX: ::c_uint = 308915776; +pub const _PC_LINK_MAX: ::c_int = 1; +pub const _PC_MAX_CANON: ::c_int = 2; +pub const _PC_MAX_INPUT: ::c_int = 3; +pub const _PC_NAME_MAX: ::c_int = 4; +pub const _PC_PATH_MAX: ::c_int = 5; +pub const _PC_PIPE_BUF: ::c_int = 6; +pub const _PC_2_SYMLINKS: ::c_int = 7; +pub const _PC_ALLOC_SIZE_MIN: ::c_int = 8; +pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 9; +pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 10; +pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 11; +pub const _PC_REC_XFER_ALIGN: ::c_int = 12; +pub const _PC_SYMLINK_MAX: ::c_int = 13; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 14; +pub const _PC_NO_TRUNC: ::c_int = 15; +pub const _PC_VDISABLE: ::c_int = 16; +pub const _PC_ASYNC_IO: ::c_int = 17; +pub const _PC_PRIO_IO: ::c_int = 18; +pub const _PC_SYNC_IO: ::c_int = 19; + +pub const FIONBIO: ::c_int = 0x5421; + +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_BC_BASE_MAX: ::c_int = 1; +pub const _SC_BC_DIM_MAX: ::c_int = 2; +pub const _SC_BC_SCALE_MAX: ::c_int = 3; +pub const _SC_BC_STRING_MAX: ::c_int = 4; +pub const _SC_CHILD_MAX: ::c_int = 5; +pub const _SC_CLK_TCK: ::c_int = 6; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 7; +pub const _SC_EXPR_NEST_MAX: ::c_int = 8; +pub const _SC_LINE_MAX: ::c_int = 9; +pub const _SC_NGROUPS_MAX: ::c_int = 10; +pub const _SC_OPEN_MAX: ::c_int = 11; +pub const _SC_PASS_MAX: ::c_int = 12; +pub const _SC_2_C_BIND: ::c_int = 13; +pub const _SC_2_C_DEV: ::c_int = 14; +pub const _SC_2_C_VERSION: ::c_int = 15; +pub const _SC_2_CHAR_TERM: ::c_int = 16; +pub const _SC_2_FORT_DEV: ::c_int = 17; +pub const _SC_2_FORT_RUN: ::c_int = 18; +pub const _SC_2_LOCALEDEF: ::c_int = 19; +pub const _SC_2_SW_DEV: ::c_int = 20; +pub const _SC_2_UPE: ::c_int = 21; +pub const _SC_2_VERSION: ::c_int = 22; +pub const _SC_JOB_CONTROL: ::c_int = 23; +pub const _SC_SAVED_IDS: ::c_int = 24; +pub const _SC_VERSION: ::c_int = 25; +pub const _SC_RE_DUP_MAX: ::c_int = 26; +pub const _SC_STREAM_MAX: ::c_int = 27; +pub const _SC_TZNAME_MAX: ::c_int = 28; +pub const _SC_XOPEN_CRYPT: ::c_int = 29; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 30; +pub const _SC_XOPEN_SHM: ::c_int = 31; +pub const _SC_XOPEN_VERSION: ::c_int = 32; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 33; +pub const _SC_XOPEN_REALTIME: ::c_int = 34; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 35; +pub const _SC_XOPEN_LEGACY: ::c_int = 36; +pub const _SC_ATEXIT_MAX: ::c_int = 37; +pub const _SC_IOV_MAX: ::c_int = 38; +pub const _SC_PAGESIZE: ::c_int = 39; +pub const _SC_PAGE_SIZE: ::c_int = 40; +pub const _SC_XOPEN_UNIX: ::c_int = 41; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 42; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 43; +pub const _SC_XBS5_LP64_OFF64: ::c_int = 44; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 45; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 46; +pub const _SC_AIO_MAX: ::c_int = 47; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 48; +pub const _SC_DELAYTIMER_MAX: ::c_int = 49; +pub const _SC_MQ_OPEN_MAX: ::c_int = 50; +pub const _SC_MQ_PRIO_MAX: ::c_int = 51; +pub const _SC_RTSIG_MAX: ::c_int = 52; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 53; +pub const _SC_SEM_VALUE_MAX: ::c_int = 54; +pub const _SC_SIGQUEUE_MAX: ::c_int = 55; +pub const _SC_TIMER_MAX: ::c_int = 56; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 57; +pub const _SC_FSYNC: ::c_int = 58; +pub const _SC_MAPPED_FILES: ::c_int = 59; +pub const _SC_MEMLOCK: ::c_int = 60; +pub const _SC_MEMLOCK_RANGE: ::c_int = 61; +pub const _SC_MEMORY_PROTECTION: ::c_int = 62; +pub const _SC_MESSAGE_PASSING: ::c_int = 63; +pub const _SC_PRIORITIZED_IO: ::c_int = 64; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 65; +pub const _SC_REALTIME_SIGNALS: ::c_int = 66; +pub const _SC_SEMAPHORES: ::c_int = 67; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 68; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 69; +pub const _SC_TIMERS: ::c_int = 70; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 71; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 72; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 74; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 75; +pub const _SC_THREAD_STACK_MIN: ::c_int = 76; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 77; +pub const _SC_TTY_NAME_MAX: ::c_int = 78; +pub const _SC_THREADS: ::c_int = 79; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 80; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 81; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 82; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 83; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85; +pub const _SC_NPROCESSORS_CONF: ::c_int = 96; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 97; +pub const _SC_PHYS_PAGES: ::c_int = 98; +pub const _SC_AVPHYS_PAGES: ::c_int = 99; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 100; + +pub const _SC_2_PBS: ::c_int = 101; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 102; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 103; +pub const _SC_2_PBS_LOCATE: ::c_int = 104; +pub const _SC_2_PBS_MESSAGE: ::c_int = 105; +pub const _SC_2_PBS_TRACK: ::c_int = 106; +pub const _SC_ADVISORY_INFO: ::c_int = 107; +pub const _SC_BARRIERS: ::c_int = 108; +pub const _SC_CLOCK_SELECTION: ::c_int = 109; +pub const _SC_CPUTIME: ::c_int = 110; +pub const _SC_HOST_NAME_MAX: ::c_int = 111; +pub const _SC_IPV6: ::c_int = 112; +pub const _SC_RAW_SOCKETS: ::c_int = 113; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 114; +pub const _SC_REGEXP: ::c_int = 115; +pub const _SC_SHELL: ::c_int = 116; +pub const _SC_SPAWN: ::c_int = 117; +pub const _SC_SPIN_LOCKS: ::c_int = 118; +pub const _SC_SPORADIC_SERVER: ::c_int = 119; +pub const _SC_SS_REPL_MAX: ::c_int = 120; +pub const _SC_SYMLOOP_MAX: ::c_int = 121; +pub const _SC_THREAD_CPUTIME: ::c_int = 122; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 123; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 124; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 125; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 126; +pub const _SC_TIMEOUTS: ::c_int = 127; +pub const _SC_TRACE: ::c_int = 128; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 129; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 130; +pub const _SC_TRACE_INHERIT: ::c_int = 131; +pub const _SC_TRACE_LOG: ::c_int = 132; +pub const _SC_TRACE_NAME_MAX: ::c_int = 133; +pub const _SC_TRACE_SYS_MAX: ::c_int = 134; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 135; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 136; +pub const _SC_V7_ILP32_OFF32: ::c_int = 137; +pub const _SC_V7_ILP32_OFFBIG: ::c_int = 138; +pub const _SC_V7_LP64_OFF64: ::c_int = 139; +pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 140; +pub const _SC_XOPEN_STREAMS: ::c_int = 141; +pub const _SC_XOPEN_UUCP: ::c_int = 142; + +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; + +pub const FIOCLEX: ::c_int = 0x5451; +pub const FIONCLEX: ::c_int = 0x5450; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = 31; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const RUSAGE_CHILDREN: ::c_int = -1; + +pub const LC_PAPER: ::c_int = 7; +pub const LC_NAME: ::c_int = 8; +pub const LC_ADDRESS: ::c_int = 9; +pub const LC_TELEPHONE: ::c_int = 10; +pub const LC_MEASUREMENT: ::c_int = 11; +pub const LC_IDENTIFICATION: ::c_int = 12; +pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER); +pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME); +pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS); +pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE); +pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT); +pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION); +pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK + | ::LC_NUMERIC_MASK + | ::LC_TIME_MASK + | ::LC_COLLATE_MASK + | ::LC_MONETARY_MASK + | ::LC_MESSAGES_MASK + | LC_PAPER_MASK + | LC_NAME_MASK + | LC_ADDRESS_MASK + | LC_TELEPHONE_MASK + | LC_MEASUREMENT_MASK + | LC_IDENTIFICATION_MASK; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; + +pub const EMULTIHOP: ::c_int = 72; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_SEQPACKET: ::c_int = 5; +pub const SOCK_DCCP: ::c_int = 6; +pub const SOCK_PACKET: ::c_int = 10; + +pub const SOL_SOCKET: ::c_int = 1; +pub const SOL_SCTP: ::c_int = 132; +pub const SOL_IPX: ::c_int = 256; +pub const SOL_AX25: ::c_int = 257; +pub const SOL_ATALK: ::c_int = 258; +pub const SOL_NETROM: ::c_int = 259; +pub const SOL_ROSE: ::c_int = 260; + +/* DCCP socket options */ +pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1; +pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2; +pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3; +pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4; +pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5; +pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6; +pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10; +pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11; +pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12; +pub const DCCP_SOCKOPT_CCID: ::c_int = 13; +pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14; +pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15; +pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16; +pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17; +pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128; +pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192; + +/// maximum number of services provided on the same listening port +pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_MARK: ::c_int = 36; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_BUSY_POLL: ::c_int = 46; + +pub const IPTOS_ECN_NOTECT: u8 = 0x00; + +pub const O_ACCMODE: ::c_int = 3; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 0x101000; +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_NDELAY: ::c_int = 0x800; +pub const O_DSYNC: ::c_int = 4096; + +pub const NI_MAXHOST: ::size_t = 1025; + +pub const NCCS: usize = 19; +pub const TCSBRKP: ::c_int = 0x5425; +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 0x1; +pub const TCSAFLUSH: ::c_int = 0x2; +pub const VEOF: usize = 4; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; +pub const EXTPROC: ::tcflag_t = 0o200000; + +pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; +pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; +pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; +pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; +pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; +pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; +pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; +pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; +pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; +pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; +pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; +pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; +pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; +pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; +pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; +pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; +pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; +pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; +pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; +pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; +pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; +pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; +pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; +pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; +pub const TMPFS_MAGIC: ::c_long = 0x01021994; +pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; + +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const PTRACE_TRACEME: ::c_int = 0; +pub const PTRACE_PEEKTEXT: ::c_int = 1; +pub const PTRACE_PEEKDATA: ::c_int = 2; +pub const PTRACE_PEEKUSER: ::c_int = 3; +pub const PTRACE_POKETEXT: ::c_int = 4; +pub const PTRACE_POKEDATA: ::c_int = 5; +pub const PTRACE_POKEUSER: ::c_int = 6; +pub const PTRACE_CONT: ::c_int = 7; +pub const PTRACE_KILL: ::c_int = 8; +pub const PTRACE_SINGLESTEP: ::c_int = 9; +pub const PTRACE_ATTACH: ::c_int = 16; +pub const PTRACE_DETACH: ::c_int = 17; +pub const PTRACE_SYSCALL: ::c_int = 24; +pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; +pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; +pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; +pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; + +pub const EFD_NONBLOCK: ::c_int = 0x800; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_LOCKS: ::c_int = 10; +pub const RLIMIT_SIGPENDING: ::c_int = 11; +pub const RLIMIT_MSGQUEUE: ::c_int = 12; +pub const RLIMIT_NICE: ::c_int = 13; +pub const RLIMIT_RTPRIO: ::c_int = 14; + +pub const RLIM_INFINITY: ::rlim_t = !0; + +pub const TCGETS: ::c_int = 0x5401; +pub const TCSETS: ::c_int = 0x5402; +pub const TCSETSW: ::c_int = 0x5403; +pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETA: ::c_int = 0x5405; +pub const TCSETA: ::c_int = 0x5406; +pub const TCSETAW: ::c_int = 0x5407; +pub const TCSETAF: ::c_int = 0x5408; +pub const TCSBRK: ::c_int = 0x5409; +pub const TCXONC: ::c_int = 0x540A; +pub const TCFLSH: ::c_int = 0x540B; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCINQ: ::c_int = 0x541B; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x540F; +pub const TIOCSPGRP: ::c_int = 0x5410; +pub const TIOCOUTQ: ::c_int = 0x5411; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x5413; +pub const TIOCSWINSZ: ::c_int = 0x5414; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x541B; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const ST_RDONLY: ::c_ulong = 1; +pub const ST_NOSUID: ::c_ulong = 2; +pub const ST_NODEV: ::c_ulong = 4; +pub const ST_NOEXEC: ::c_ulong = 8; +pub const ST_SYNCHRONOUS: ::c_ulong = 16; +pub const ST_MANDLOCK: ::c_ulong = 64; +pub const ST_NOATIME: ::c_ulong = 1024; +pub const ST_NODIRATIME: ::c_ulong = 2048; +pub const ST_RELATIME: ::c_ulong = 4096; + +pub const RTLD_NOLOAD: ::c_int = 0x4; + +pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; + +pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; +pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793; +pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278; +pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448; +pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216; + +pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567; +pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123; +pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF; +pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000; +pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC; +pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4; +pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2; +pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const BOTHER: ::speed_t = 0o010000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const EAI_AGAIN: ::c_int = 2; +pub const EAI_BADFLAGS: ::c_int = 3; +pub const EAI_FAIL: ::c_int = 4; +pub const EAI_FAMILY: ::c_int = 5; +pub const EAI_MEMORY: ::c_int = 6; +pub const EAI_NODATA: ::c_int = 7; +pub const EAI_NONAME: ::c_int = 8; +pub const EAI_SERVICE: ::c_int = 9; +pub const EAI_SOCKTYPE: ::c_int = 10; +pub const EAI_SYSTEM: ::c_int = 11; +pub const EAI_OVERFLOW: ::c_int = 14; + +pub const NETLINK_ROUTE: ::c_int = 0; +pub const NETLINK_UNUSED: ::c_int = 1; +pub const NETLINK_USERSOCK: ::c_int = 2; +pub const NETLINK_FIREWALL: ::c_int = 3; +pub const NETLINK_SOCK_DIAG: ::c_int = 4; +pub const NETLINK_NFLOG: ::c_int = 5; +pub const NETLINK_XFRM: ::c_int = 6; +pub const NETLINK_SELINUX: ::c_int = 7; +pub const NETLINK_ISCSI: ::c_int = 8; +pub const NETLINK_AUDIT: ::c_int = 9; +pub const NETLINK_FIB_LOOKUP: ::c_int = 10; +pub const NETLINK_CONNECTOR: ::c_int = 11; +pub const NETLINK_NETFILTER: ::c_int = 12; +pub const NETLINK_IP6_FW: ::c_int = 13; +pub const NETLINK_DNRTMSG: ::c_int = 14; +pub const NETLINK_KOBJECT_UEVENT: ::c_int = 15; +pub const NETLINK_GENERIC: ::c_int = 16; +pub const NETLINK_SCSITRANSPORT: ::c_int = 18; +pub const NETLINK_ECRYPTFS: ::c_int = 19; +pub const NETLINK_RDMA: ::c_int = 20; +pub const NETLINK_CRYPTO: ::c_int = 21; +pub const NETLINK_INET_DIAG: ::c_int = NETLINK_SOCK_DIAG; + +pub const MAX_LINKS: ::c_int = 32; + +pub const NLM_F_REQUEST: ::c_int = 1; +pub const NLM_F_MULTI: ::c_int = 2; +pub const NLM_F_ACK: ::c_int = 4; +pub const NLM_F_ECHO: ::c_int = 8; +pub const NLM_F_DUMP_INTR: ::c_int = 16; + +pub const NLM_F_ROOT: ::c_int = 0x100; +pub const NLM_F_MATCH: ::c_int = 0x200; +pub const NLM_F_ATOMIC: ::c_int = 0x400; +pub const NLM_F_DUMP: ::c_int = NLM_F_ROOT | NLM_F_MATCH; + +pub const NLM_F_REPLACE: ::c_int = 0x100; +pub const NLM_F_EXCL: ::c_int = 0x200; +pub const NLM_F_CREATE: ::c_int = 0x400; +pub const NLM_F_APPEND: ::c_int = 0x800; + +pub const NLMSG_NOOP: ::c_int = 0x1; +pub const NLMSG_ERROR: ::c_int = 0x2; +pub const NLMSG_DONE: ::c_int = 0x3; +pub const NLMSG_OVERRUN: ::c_int = 0x4; +pub const NLMSG_MIN_TYPE: ::c_int = 0x10; + +// linux/netfilter/nfnetlink.h +pub const NFNLGRP_NONE: ::c_int = 0; +pub const NFNLGRP_CONNTRACK_NEW: ::c_int = 1; +pub const NFNLGRP_CONNTRACK_UPDATE: ::c_int = 2; +pub const NFNLGRP_CONNTRACK_DESTROY: ::c_int = 3; +pub const NFNLGRP_CONNTRACK_EXP_NEW: ::c_int = 4; +pub const NFNLGRP_CONNTRACK_EXP_UPDATE: ::c_int = 5; +pub const NFNLGRP_CONNTRACK_EXP_DESTROY: ::c_int = 6; +pub const NFNLGRP_NFTABLES: ::c_int = 7; +pub const NFNLGRP_ACCT_QUOTA: ::c_int = 8; + +pub const NFNETLINK_V0: ::c_int = 0; + +pub const NFNL_SUBSYS_NONE: ::c_int = 0; +pub const NFNL_SUBSYS_CTNETLINK: ::c_int = 1; +pub const NFNL_SUBSYS_CTNETLINK_EXP: ::c_int = 2; +pub const NFNL_SUBSYS_QUEUE: ::c_int = 3; +pub const NFNL_SUBSYS_ULOG: ::c_int = 4; +pub const NFNL_SUBSYS_OSF: ::c_int = 5; +pub const NFNL_SUBSYS_IPSET: ::c_int = 6; +pub const NFNL_SUBSYS_ACCT: ::c_int = 7; +pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: ::c_int = 8; +pub const NFNL_SUBSYS_CTHELPER: ::c_int = 9; +pub const NFNL_SUBSYS_NFTABLES: ::c_int = 10; +pub const NFNL_SUBSYS_NFT_COMPAT: ::c_int = 11; +pub const NFNL_SUBSYS_COUNT: ::c_int = 12; + +pub const NFNL_MSG_BATCH_BEGIN: ::c_int = NLMSG_MIN_TYPE; +pub const NFNL_MSG_BATCH_END: ::c_int = NLMSG_MIN_TYPE + 1; + +// linux/netfilter/nfnetlink_log.h +pub const NFULNL_MSG_PACKET: ::c_int = 0; +pub const NFULNL_MSG_CONFIG: ::c_int = 1; + +pub const NFULA_UNSPEC: ::c_int = 0; +pub const NFULA_PACKET_HDR: ::c_int = 1; +pub const NFULA_MARK: ::c_int = 2; +pub const NFULA_TIMESTAMP: ::c_int = 3; +pub const NFULA_IFINDEX_INDEV: ::c_int = 4; +pub const NFULA_IFINDEX_OUTDEV: ::c_int = 5; +pub const NFULA_IFINDEX_PHYSINDEV: ::c_int = 6; +pub const NFULA_IFINDEX_PHYSOUTDEV: ::c_int = 7; +pub const NFULA_HWADDR: ::c_int = 8; +pub const NFULA_PAYLOAD: ::c_int = 9; +pub const NFULA_PREFIX: ::c_int = 10; +pub const NFULA_UID: ::c_int = 11; +pub const NFULA_SEQ: ::c_int = 12; +pub const NFULA_SEQ_GLOBAL: ::c_int = 13; +pub const NFULA_GID: ::c_int = 14; +pub const NFULA_HWTYPE: ::c_int = 15; +pub const NFULA_HWHEADER: ::c_int = 16; +pub const NFULA_HWLEN: ::c_int = 17; +pub const NFULA_CT: ::c_int = 18; +pub const NFULA_CT_INFO: ::c_int = 19; + +pub const NFULNL_CFG_CMD_NONE: ::c_int = 0; +pub const NFULNL_CFG_CMD_BIND: ::c_int = 1; +pub const NFULNL_CFG_CMD_UNBIND: ::c_int = 2; +pub const NFULNL_CFG_CMD_PF_BIND: ::c_int = 3; +pub const NFULNL_CFG_CMD_PF_UNBIND: ::c_int = 4; + +pub const NFULA_CFG_UNSPEC: ::c_int = 0; +pub const NFULA_CFG_CMD: ::c_int = 1; +pub const NFULA_CFG_MODE: ::c_int = 2; +pub const NFULA_CFG_NLBUFSIZ: ::c_int = 3; +pub const NFULA_CFG_TIMEOUT: ::c_int = 4; +pub const NFULA_CFG_QTHRESH: ::c_int = 5; +pub const NFULA_CFG_FLAGS: ::c_int = 6; + +pub const NFULNL_COPY_NONE: ::c_int = 0x00; +pub const NFULNL_COPY_META: ::c_int = 0x01; +pub const NFULNL_COPY_PACKET: ::c_int = 0x02; + +pub const NFULNL_CFG_F_SEQ: ::c_int = 0x0001; +pub const NFULNL_CFG_F_SEQ_GLOBAL: ::c_int = 0x0002; +pub const NFULNL_CFG_F_CONNTRACK: ::c_int = 0x0004; + +pub const GENL_NAMSIZ: ::c_int = 16; + +pub const GENL_MIN_ID: ::c_int = NLMSG_MIN_TYPE; +pub const GENL_MAX_ID: ::c_int = 1023; + +pub const GENL_ADMIN_PERM: ::c_int = 0x01; +pub const GENL_CMD_CAP_DO: ::c_int = 0x02; +pub const GENL_CMD_CAP_DUMP: ::c_int = 0x04; +pub const GENL_CMD_CAP_HASPOL: ::c_int = 0x08; +pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10; + +pub const GENL_ID_CTRL: ::c_int = NLMSG_MIN_TYPE; +pub const GENL_ID_VFS_DQUOT: ::c_int = NLMSG_MIN_TYPE + 1; +pub const GENL_ID_PMCRAID: ::c_int = NLMSG_MIN_TYPE + 2; + +pub const CTRL_CMD_UNSPEC: ::c_int = 0; +pub const CTRL_CMD_NEWFAMILY: ::c_int = 1; +pub const CTRL_CMD_DELFAMILY: ::c_int = 2; +pub const CTRL_CMD_GETFAMILY: ::c_int = 3; +pub const CTRL_CMD_NEWOPS: ::c_int = 4; +pub const CTRL_CMD_DELOPS: ::c_int = 5; +pub const CTRL_CMD_GETOPS: ::c_int = 6; +pub const CTRL_CMD_NEWMCAST_GRP: ::c_int = 7; +pub const CTRL_CMD_DELMCAST_GRP: ::c_int = 8; +pub const CTRL_CMD_GETMCAST_GRP: ::c_int = 9; + +pub const CTRL_ATTR_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_FAMILY_ID: ::c_int = 1; +pub const CTRL_ATTR_FAMILY_NAME: ::c_int = 2; +pub const CTRL_ATTR_VERSION: ::c_int = 3; +pub const CTRL_ATTR_HDRSIZE: ::c_int = 4; +pub const CTRL_ATTR_MAXATTR: ::c_int = 5; +pub const CTRL_ATTR_OPS: ::c_int = 6; +pub const CTRL_ATTR_MCAST_GROUPS: ::c_int = 7; + +pub const CTRL_ATTR_OP_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_OP_ID: ::c_int = 1; +pub const CTRL_ATTR_OP_FLAGS: ::c_int = 2; + +pub const CTRL_ATTR_MCAST_GRP_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_MCAST_GRP_NAME: ::c_int = 1; +pub const CTRL_ATTR_MCAST_GRP_ID: ::c_int = 2; + +pub const NETLINK_ADD_MEMBERSHIP: ::c_int = 1; +pub const NETLINK_DROP_MEMBERSHIP: ::c_int = 2; +pub const NETLINK_PKTINFO: ::c_int = 3; +pub const NETLINK_BROADCAST_ERROR: ::c_int = 4; +pub const NETLINK_NO_ENOBUFS: ::c_int = 5; +pub const NETLINK_RX_RING: ::c_int = 6; +pub const NETLINK_TX_RING: ::c_int = 7; + +pub const GRND_NONBLOCK: ::c_uint = 0x0001; +pub const GRND_RANDOM: ::c_uint = 0x0002; + +pub const SECCOMP_MODE_DISABLED: ::c_uint = 0; +pub const SECCOMP_MODE_STRICT: ::c_uint = 1; +pub const SECCOMP_MODE_FILTER: ::c_uint = 2; + +pub const NLA_F_NESTED: ::c_int = 1 << 15; +pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14; +pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); + +pub const NLA_ALIGNTO: ::c_int = 4; + +pub const SIGEV_THREAD_ID: ::c_int = 4; + +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const SFD_CLOEXEC: ::c_int = O_CLOEXEC; +pub const SFD_NONBLOCK: ::c_int = O_NONBLOCK; + +pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; + +pub const SO_ORIGINAL_DST: ::c_int = 80; +pub const IP_ORIGDSTADDR: ::c_int = 20; +pub const IP_RECVORIGDSTADDR: ::c_int = IP_ORIGDSTADDR; +pub const IPV6_ORIGDSTADDR: ::c_int = 74; +pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR; +pub const IPV6_FLOWLABEL_MGR: ::c_int = 32; +pub const IPV6_FLOWINFO_SEND: ::c_int = 33; +pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff; +pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000; + +pub const IUTF8: ::tcflag_t = 0x00004000; +pub const CMSPAR: ::tcflag_t = 0o10000000000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; + +pub const MFD_CLOEXEC: ::c_uint = 0x0001; +pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002; +pub const MFD_HUGETLB: ::c_uint = 0x0004; + +// linux/netfilter.h +pub const NF_DROP: ::c_int = 0; +pub const NF_ACCEPT: ::c_int = 1; +pub const NF_STOLEN: ::c_int = 2; +pub const NF_QUEUE: ::c_int = 3; +pub const NF_REPEAT: ::c_int = 4; +pub const NF_STOP: ::c_int = 5; +pub const NF_MAX_VERDICT: ::c_int = NF_STOP; + +pub const NF_VERDICT_MASK: ::c_int = 0x000000ff; +pub const NF_VERDICT_FLAG_QUEUE_BYPASS: ::c_int = 0x00008000; + +pub const NF_VERDICT_QMASK: ::c_int = 0xffff0000; +pub const NF_VERDICT_QBITS: ::c_int = 16; + +pub const NF_VERDICT_BITS: ::c_int = 16; + +pub const NF_INET_PRE_ROUTING: ::c_int = 0; +pub const NF_INET_LOCAL_IN: ::c_int = 1; +pub const NF_INET_FORWARD: ::c_int = 2; +pub const NF_INET_LOCAL_OUT: ::c_int = 3; +pub const NF_INET_POST_ROUTING: ::c_int = 4; +pub const NF_INET_NUMHOOKS: ::c_int = 5; + +pub const NF_NETDEV_INGRESS: ::c_int = 0; +pub const NF_NETDEV_NUMHOOKS: ::c_int = 1; + +pub const NFPROTO_UNSPEC: ::c_int = 0; +pub const NFPROTO_INET: ::c_int = 1; +pub const NFPROTO_IPV4: ::c_int = 2; +pub const NFPROTO_ARP: ::c_int = 3; +pub const NFPROTO_NETDEV: ::c_int = 5; +pub const NFPROTO_BRIDGE: ::c_int = 7; +pub const NFPROTO_IPV6: ::c_int = 10; +pub const NFPROTO_DECNET: ::c_int = 12; +pub const NFPROTO_NUMPROTO: ::c_int = 13; + +// linux/netfilter_ipv4.h +pub const NF_IP_PRE_ROUTING: ::c_int = 0; +pub const NF_IP_LOCAL_IN: ::c_int = 1; +pub const NF_IP_FORWARD: ::c_int = 2; +pub const NF_IP_LOCAL_OUT: ::c_int = 3; +pub const NF_IP_POST_ROUTING: ::c_int = 4; +pub const NF_IP_NUMHOOKS: ::c_int = 5; + +pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400; +pub const NF_IP_PRI_RAW: ::c_int = -300; +pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225; +pub const NF_IP_PRI_CONNTRACK: ::c_int = -200; +pub const NF_IP_PRI_MANGLE: ::c_int = -150; +pub const NF_IP_PRI_NAT_DST: ::c_int = -100; +pub const NF_IP_PRI_FILTER: ::c_int = 0; +pub const NF_IP_PRI_SECURITY: ::c_int = 50; +pub const NF_IP_PRI_NAT_SRC: ::c_int = 100; +pub const NF_IP_PRI_SELINUX_LAST: ::c_int = 225; +pub const NF_IP_PRI_CONNTRACK_HELPER: ::c_int = 300; +pub const NF_IP_PRI_CONNTRACK_CONFIRM: ::c_int = ::INT_MAX; +pub const NF_IP_PRI_LAST: ::c_int = ::INT_MAX; + +// linux/netfilter_ipv6.h +pub const NF_IP6_PRE_ROUTING: ::c_int = 0; +pub const NF_IP6_LOCAL_IN: ::c_int = 1; +pub const NF_IP6_FORWARD: ::c_int = 2; +pub const NF_IP6_LOCAL_OUT: ::c_int = 3; +pub const NF_IP6_POST_ROUTING: ::c_int = 4; +pub const NF_IP6_NUMHOOKS: ::c_int = 5; + +pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400; +pub const NF_IP6_PRI_RAW: ::c_int = -300; +pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225; +pub const NF_IP6_PRI_CONNTRACK: ::c_int = -200; +pub const NF_IP6_PRI_MANGLE: ::c_int = -150; +pub const NF_IP6_PRI_NAT_DST: ::c_int = -100; +pub const NF_IP6_PRI_FILTER: ::c_int = 0; +pub const NF_IP6_PRI_SECURITY: ::c_int = 50; +pub const NF_IP6_PRI_NAT_SRC: ::c_int = 100; +pub const NF_IP6_PRI_SELINUX_LAST: ::c_int = 225; +pub const NF_IP6_PRI_CONNTRACK_HELPER: ::c_int = 300; +pub const NF_IP6_PRI_LAST: ::c_int = ::INT_MAX; + +// linux/netfilter/nf_tables.h +pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256; +pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256; +pub const NFT_SET_MAXNAMELEN: ::c_int = 256; +pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256; +pub const NFT_USERDATA_MAXLEN: ::c_int = 256; + +pub const NFT_REG_VERDICT: ::c_int = 0; +pub const NFT_REG_1: ::c_int = 1; +pub const NFT_REG_2: ::c_int = 2; +pub const NFT_REG_3: ::c_int = 3; +pub const NFT_REG_4: ::c_int = 4; +pub const __NFT_REG_MAX: ::c_int = 5; +pub const NFT_REG32_00: ::c_int = 8; +pub const NFT_REG32_01: ::c_int = 9; +pub const NFT_REG32_02: ::c_int = 10; +pub const NFT_REG32_03: ::c_int = 11; +pub const NFT_REG32_04: ::c_int = 12; +pub const NFT_REG32_05: ::c_int = 13; +pub const NFT_REG32_06: ::c_int = 14; +pub const NFT_REG32_07: ::c_int = 15; +pub const NFT_REG32_08: ::c_int = 16; +pub const NFT_REG32_09: ::c_int = 17; +pub const NFT_REG32_10: ::c_int = 18; +pub const NFT_REG32_11: ::c_int = 19; +pub const NFT_REG32_12: ::c_int = 20; +pub const NFT_REG32_13: ::c_int = 21; +pub const NFT_REG32_14: ::c_int = 22; +pub const NFT_REG32_15: ::c_int = 23; + +pub const NFT_REG_SIZE: ::c_int = 16; +pub const NFT_REG32_SIZE: ::c_int = 4; + +pub const NFT_CONTINUE: ::c_int = -1; +pub const NFT_BREAK: ::c_int = -2; +pub const NFT_JUMP: ::c_int = -3; +pub const NFT_GOTO: ::c_int = -4; +pub const NFT_RETURN: ::c_int = -5; + +pub const NFT_MSG_NEWTABLE: ::c_int = 0; +pub const NFT_MSG_GETTABLE: ::c_int = 1; +pub const NFT_MSG_DELTABLE: ::c_int = 2; +pub const NFT_MSG_NEWCHAIN: ::c_int = 3; +pub const NFT_MSG_GETCHAIN: ::c_int = 4; +pub const NFT_MSG_DELCHAIN: ::c_int = 5; +pub const NFT_MSG_NEWRULE: ::c_int = 6; +pub const NFT_MSG_GETRULE: ::c_int = 7; +pub const NFT_MSG_DELRULE: ::c_int = 8; +pub const NFT_MSG_NEWSET: ::c_int = 9; +pub const NFT_MSG_GETSET: ::c_int = 10; +pub const NFT_MSG_DELSET: ::c_int = 11; +pub const NFT_MSG_NEWSETELEM: ::c_int = 12; +pub const NFT_MSG_GETSETELEM: ::c_int = 13; +pub const NFT_MSG_DELSETELEM: ::c_int = 14; +pub const NFT_MSG_NEWGEN: ::c_int = 15; +pub const NFT_MSG_GETGEN: ::c_int = 16; +pub const NFT_MSG_TRACE: ::c_int = 17; +pub const NFT_MSG_NEWOBJ: ::c_int = 18; +pub const NFT_MSG_GETOBJ: ::c_int = 19; +pub const NFT_MSG_DELOBJ: ::c_int = 20; +pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21; +pub const NFT_MSG_MAX: ::c_int = 25; + +pub const NFT_SET_ANONYMOUS: ::c_int = 0x1; +pub const NFT_SET_CONSTANT: ::c_int = 0x2; +pub const NFT_SET_INTERVAL: ::c_int = 0x4; +pub const NFT_SET_MAP: ::c_int = 0x8; +pub const NFT_SET_TIMEOUT: ::c_int = 0x10; +pub const NFT_SET_EVAL: ::c_int = 0x20; + +pub const NFT_SET_POL_PERFORMANCE: ::c_int = 0; +pub const NFT_SET_POL_MEMORY: ::c_int = 1; + +pub const NFT_SET_ELEM_INTERVAL_END: ::c_int = 0x1; + +pub const NFT_DATA_VALUE: ::c_uint = 0; +pub const NFT_DATA_VERDICT: ::c_uint = 0xffffff00; + +pub const NFT_DATA_RESERVED_MASK: ::c_uint = 0xffffff00; + +pub const NFT_DATA_VALUE_MAXLEN: ::c_int = 64; + +pub const NFT_BYTEORDER_NTOH: ::c_int = 0; +pub const NFT_BYTEORDER_HTON: ::c_int = 1; + +pub const NFT_CMP_EQ: ::c_int = 0; +pub const NFT_CMP_NEQ: ::c_int = 1; +pub const NFT_CMP_LT: ::c_int = 2; +pub const NFT_CMP_LTE: ::c_int = 3; +pub const NFT_CMP_GT: ::c_int = 4; +pub const NFT_CMP_GTE: ::c_int = 5; + +pub const NFT_RANGE_EQ: ::c_int = 0; +pub const NFT_RANGE_NEQ: ::c_int = 1; + +pub const NFT_LOOKUP_F_INV: ::c_int = (1 << 0); + +pub const NFT_DYNSET_OP_ADD: ::c_int = 0; +pub const NFT_DYNSET_OP_UPDATE: ::c_int = 1; + +pub const NFT_DYNSET_F_INV: ::c_int = (1 << 0); + +pub const NFT_PAYLOAD_LL_HEADER: ::c_int = 0; +pub const NFT_PAYLOAD_NETWORK_HEADER: ::c_int = 1; +pub const NFT_PAYLOAD_TRANSPORT_HEADER: ::c_int = 2; + +pub const NFT_PAYLOAD_CSUM_NONE: ::c_int = 0; +pub const NFT_PAYLOAD_CSUM_INET: ::c_int = 1; + +pub const NFT_META_LEN: ::c_int = 0; +pub const NFT_META_PROTOCOL: ::c_int = 1; +pub const NFT_META_PRIORITY: ::c_int = 2; +pub const NFT_META_MARK: ::c_int = 3; +pub const NFT_META_IIF: ::c_int = 4; +pub const NFT_META_OIF: ::c_int = 5; +pub const NFT_META_IIFNAME: ::c_int = 6; +pub const NFT_META_OIFNAME: ::c_int = 7; +pub const NFT_META_IIFTYPE: ::c_int = 8; +pub const NFT_META_OIFTYPE: ::c_int = 9; +pub const NFT_META_SKUID: ::c_int = 10; +pub const NFT_META_SKGID: ::c_int = 11; +pub const NFT_META_NFTRACE: ::c_int = 12; +pub const NFT_META_RTCLASSID: ::c_int = 13; +pub const NFT_META_SECMARK: ::c_int = 14; +pub const NFT_META_NFPROTO: ::c_int = 15; +pub const NFT_META_L4PROTO: ::c_int = 16; +pub const NFT_META_BRI_IIFNAME: ::c_int = 17; +pub const NFT_META_BRI_OIFNAME: ::c_int = 18; +pub const NFT_META_PKTTYPE: ::c_int = 19; +pub const NFT_META_CPU: ::c_int = 20; +pub const NFT_META_IIFGROUP: ::c_int = 21; +pub const NFT_META_OIFGROUP: ::c_int = 22; +pub const NFT_META_CGROUP: ::c_int = 23; +pub const NFT_META_PRANDOM: ::c_int = 24; + +pub const NFT_CT_STATE: ::c_int = 0; +pub const NFT_CT_DIRECTION: ::c_int = 1; +pub const NFT_CT_STATUS: ::c_int = 2; +pub const NFT_CT_MARK: ::c_int = 3; +pub const NFT_CT_SECMARK: ::c_int = 4; +pub const NFT_CT_EXPIRATION: ::c_int = 5; +pub const NFT_CT_HELPER: ::c_int = 6; +pub const NFT_CT_L3PROTOCOL: ::c_int = 7; +pub const NFT_CT_SRC: ::c_int = 8; +pub const NFT_CT_DST: ::c_int = 9; +pub const NFT_CT_PROTOCOL: ::c_int = 10; +pub const NFT_CT_PROTO_SRC: ::c_int = 11; +pub const NFT_CT_PROTO_DST: ::c_int = 12; +pub const NFT_CT_LABELS: ::c_int = 13; +pub const NFT_CT_PKTS: ::c_int = 14; +pub const NFT_CT_BYTES: ::c_int = 15; + +pub const NFT_LIMIT_PKTS: ::c_int = 0; +pub const NFT_LIMIT_PKT_BYTES: ::c_int = 1; + +pub const NFT_LIMIT_F_INV: ::c_int = (1 << 0); + +pub const NFT_QUEUE_FLAG_BYPASS: ::c_int = 0x01; +pub const NFT_QUEUE_FLAG_CPU_FANOUT: ::c_int = 0x02; +pub const NFT_QUEUE_FLAG_MASK: ::c_int = 0x03; + +pub const NFT_QUOTA_F_INV: ::c_int = (1 << 0); + +pub const NFT_REJECT_ICMP_UNREACH: ::c_int = 0; +pub const NFT_REJECT_TCP_RST: ::c_int = 1; +pub const NFT_REJECT_ICMPX_UNREACH: ::c_int = 2; + +pub const NFT_REJECT_ICMPX_NO_ROUTE: ::c_int = 0; +pub const NFT_REJECT_ICMPX_PORT_UNREACH: ::c_int = 1; +pub const NFT_REJECT_ICMPX_HOST_UNREACH: ::c_int = 2; +pub const NFT_REJECT_ICMPX_ADMIN_PROHIBITED: ::c_int = 3; + +pub const NFT_NAT_SNAT: ::c_int = 0; +pub const NFT_NAT_DNAT: ::c_int = 1; + +pub const NFT_TRACETYPE_UNSPEC: ::c_int = 0; +pub const NFT_TRACETYPE_POLICY: ::c_int = 1; +pub const NFT_TRACETYPE_RETURN: ::c_int = 2; +pub const NFT_TRACETYPE_RULE: ::c_int = 3; + +pub const NFT_NG_INCREMENTAL: ::c_int = 0; +pub const NFT_NG_RANDOM: ::c_int = 1; + +pub const IFF_TUN: ::c_int = 0x0001; +pub const IFF_TAP: ::c_int = 0x0002; +pub const IFF_NO_PI: ::c_int = 0x1000; + +// start android/platform/bionic/libc/kernel/uapi/linux/if_ether.h +// from https://android.googlesource.com/ +// platform/bionic/+/master/libc/kernel/uapi/linux/if_ether.h +pub const ETH_ALEN: ::c_int = 6; +pub const ETH_HLEN: ::c_int = 14; +pub const ETH_ZLEN: ::c_int = 60; +pub const ETH_DATA_LEN: ::c_int = 1500; +pub const ETH_FRAME_LEN: ::c_int = 1514; +pub const ETH_FCS_LEN: ::c_int = 4; +pub const ETH_MIN_MTU: ::c_int = 68; +pub const ETH_MAX_MTU: ::c_int = 0xFFFF; +pub const ETH_P_LOOP: ::c_int = 0x0060; +pub const ETH_P_PUP: ::c_int = 0x0200; +pub const ETH_P_PUPAT: ::c_int = 0x0201; +pub const ETH_P_TSN: ::c_int = 0x22F0; +pub const ETH_P_IP: ::c_int = 0x0800; +pub const ETH_P_X25: ::c_int = 0x0805; +pub const ETH_P_ARP: ::c_int = 0x0806; +pub const ETH_P_BPQ: ::c_int = 0x08FF; +pub const ETH_P_IEEEPUP: ::c_int = 0x0a00; +pub const ETH_P_IEEEPUPAT: ::c_int = 0x0a01; +pub const ETH_P_BATMAN: ::c_int = 0x4305; +pub const ETH_P_DEC: ::c_int = 0x6000; +pub const ETH_P_DNA_DL: ::c_int = 0x6001; +pub const ETH_P_DNA_RC: ::c_int = 0x6002; +pub const ETH_P_DNA_RT: ::c_int = 0x6003; +pub const ETH_P_LAT: ::c_int = 0x6004; +pub const ETH_P_DIAG: ::c_int = 0x6005; +pub const ETH_P_CUST: ::c_int = 0x6006; +pub const ETH_P_SCA: ::c_int = 0x6007; +pub const ETH_P_TEB: ::c_int = 0x6558; +pub const ETH_P_RARP: ::c_int = 0x8035; +pub const ETH_P_ATALK: ::c_int = 0x809B; +pub const ETH_P_AARP: ::c_int = 0x80F3; +pub const ETH_P_8021Q: ::c_int = 0x8100; +/* see rust-lang/libc#924 pub const ETH_P_ERSPAN: ::c_int = 0x88BE;*/ +pub const ETH_P_IPX: ::c_int = 0x8137; +pub const ETH_P_IPV6: ::c_int = 0x86DD; +pub const ETH_P_PAUSE: ::c_int = 0x8808; +pub const ETH_P_SLOW: ::c_int = 0x8809; +pub const ETH_P_WCCP: ::c_int = 0x883E; +pub const ETH_P_MPLS_UC: ::c_int = 0x8847; +pub const ETH_P_MPLS_MC: ::c_int = 0x8848; +pub const ETH_P_ATMMPOA: ::c_int = 0x884c; +pub const ETH_P_PPP_DISC: ::c_int = 0x8863; +pub const ETH_P_PPP_SES: ::c_int = 0x8864; +pub const ETH_P_LINK_CTL: ::c_int = 0x886c; +pub const ETH_P_ATMFATE: ::c_int = 0x8884; +pub const ETH_P_PAE: ::c_int = 0x888E; +pub const ETH_P_AOE: ::c_int = 0x88A2; +pub const ETH_P_8021AD: ::c_int = 0x88A8; +pub const ETH_P_802_EX1: ::c_int = 0x88B5; +pub const ETH_P_TIPC: ::c_int = 0x88CA; +pub const ETH_P_MACSEC: ::c_int = 0x88E5; +pub const ETH_P_8021AH: ::c_int = 0x88E7; +pub const ETH_P_MVRP: ::c_int = 0x88F5; +pub const ETH_P_1588: ::c_int = 0x88F7; +pub const ETH_P_NCSI: ::c_int = 0x88F8; +pub const ETH_P_PRP: ::c_int = 0x88FB; +pub const ETH_P_FCOE: ::c_int = 0x8906; +/* see rust-lang/libc#924 pub const ETH_P_IBOE: ::c_int = 0x8915;*/ +pub const ETH_P_TDLS: ::c_int = 0x890D; +pub const ETH_P_FIP: ::c_int = 0x8914; +pub const ETH_P_80221: ::c_int = 0x8917; +pub const ETH_P_HSR: ::c_int = 0x892F; +/* see rust-lang/libc#924 pub const ETH_P_NSH: ::c_int = 0x894F;*/ +pub const ETH_P_LOOPBACK: ::c_int = 0x9000; +pub const ETH_P_QINQ1: ::c_int = 0x9100; +pub const ETH_P_QINQ2: ::c_int = 0x9200; +pub const ETH_P_QINQ3: ::c_int = 0x9300; +pub const ETH_P_EDSA: ::c_int = 0xDADA; +/* see rust-lang/libc#924 pub const ETH_P_IFE: ::c_int = 0xED3E;*/ +pub const ETH_P_AF_IUCV: ::c_int = 0xFBFB; +pub const ETH_P_802_3_MIN: ::c_int = 0x0600; +pub const ETH_P_802_3: ::c_int = 0x0001; +pub const ETH_P_AX25: ::c_int = 0x0002; +pub const ETH_P_ALL: ::c_int = 0x0003; +pub const ETH_P_802_2: ::c_int = 0x0004; +pub const ETH_P_SNAP: ::c_int = 0x0005; +pub const ETH_P_DDCMP: ::c_int = 0x0006; +pub const ETH_P_WAN_PPP: ::c_int = 0x0007; +pub const ETH_P_PPP_MP: ::c_int = 0x0008; +pub const ETH_P_LOCALTALK: ::c_int = 0x0009; +pub const ETH_P_CAN: ::c_int = 0x000C; +pub const ETH_P_CANFD: ::c_int = 0x000D; +pub const ETH_P_PPPTALK: ::c_int = 0x0010; +pub const ETH_P_TR_802_2: ::c_int = 0x0011; +pub const ETH_P_MOBITEX: ::c_int = 0x0015; +pub const ETH_P_CONTROL: ::c_int = 0x0016; +pub const ETH_P_IRDA: ::c_int = 0x0017; +pub const ETH_P_ECONET: ::c_int = 0x0018; +pub const ETH_P_HDLC: ::c_int = 0x0019; +pub const ETH_P_ARCNET: ::c_int = 0x001A; +pub const ETH_P_DSA: ::c_int = 0x001B; +pub const ETH_P_TRAILER: ::c_int = 0x001C; +pub const ETH_P_PHONET: ::c_int = 0x00F5; +pub const ETH_P_IEEE802154: ::c_int = 0x00F6; +pub const ETH_P_CAIF: ::c_int = 0x00F7; +pub const ETH_P_XDSA: ::c_int = 0x00F8; +/* see rust-lang/libc#924 pub const ETH_P_MAP: ::c_int = 0x00F9;*/ +// end android/platform/bionic/libc/kernel/uapi/linux/if_ether.h + +pub const SIOCADDRT: ::c_ulong = 0x0000890B; +pub const SIOCDELRT: ::c_ulong = 0x0000890C; +pub const SIOCGIFNAME: ::c_ulong = 0x00008910; +pub const SIOCSIFLINK: ::c_ulong = 0x00008911; +pub const SIOCGIFCONF: ::c_ulong = 0x00008912; +pub const SIOCGIFFLAGS: ::c_ulong = 0x00008913; +pub const SIOCSIFFLAGS: ::c_ulong = 0x00008914; +pub const SIOCGIFADDR: ::c_ulong = 0x00008915; +pub const SIOCSIFADDR: ::c_ulong = 0x00008916; +pub const SIOCGIFDSTADDR: ::c_ulong = 0x00008917; +pub const SIOCSIFDSTADDR: ::c_ulong = 0x00008918; +pub const SIOCGIFBRDADDR: ::c_ulong = 0x00008919; +pub const SIOCSIFBRDADDR: ::c_ulong = 0x0000891A; +pub const SIOCGIFNETMASK: ::c_ulong = 0x0000891B; +pub const SIOCSIFNETMASK: ::c_ulong = 0x0000891C; +pub const SIOCGIFMETRIC: ::c_ulong = 0x0000891D; +pub const SIOCSIFMETRIC: ::c_ulong = 0x0000891E; +pub const SIOCGIFMEM: ::c_ulong = 0x0000891F; +pub const SIOCSIFMEM: ::c_ulong = 0x00008920; +pub const SIOCGIFMTU: ::c_ulong = 0x00008921; +pub const SIOCSIFMTU: ::c_ulong = 0x00008922; +pub const SIOCSIFHWADDR: ::c_ulong = 0x00008924; +pub const SIOCGIFENCAP: ::c_ulong = 0x00008925; +pub const SIOCSIFENCAP: ::c_ulong = 0x00008926; +pub const SIOCGIFHWADDR: ::c_ulong = 0x00008927; +pub const SIOCGIFSLAVE: ::c_ulong = 0x00008929; +pub const SIOCSIFSLAVE: ::c_ulong = 0x00008930; +pub const SIOCADDMULTI: ::c_ulong = 0x00008931; +pub const SIOCDELMULTI: ::c_ulong = 0x00008932; +pub const SIOCDARP: ::c_ulong = 0x00008953; +pub const SIOCGARP: ::c_ulong = 0x00008954; +pub const SIOCSARP: ::c_ulong = 0x00008955; +pub const SIOCDRARP: ::c_ulong = 0x00008960; +pub const SIOCGRARP: ::c_ulong = 0x00008961; +pub const SIOCSRARP: ::c_ulong = 0x00008962; +pub const SIOCGIFMAP: ::c_ulong = 0x00008970; +pub const SIOCSIFMAP: ::c_ulong = 0x00008971; + +// linux/module.h +pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001; +pub const MODULE_INIT_IGNORE_VERMAGIC: ::c_uint = 0x0002; + +#[deprecated( + since = "0.2.55", + note = "ENOATTR is not available on Android; use ENODATA instead" +)] +pub const ENOATTR: ::c_int = ::ENODATA; + +// linux/if_alg.h +pub const ALG_SET_KEY: ::c_int = 1; +pub const ALG_SET_IV: ::c_int = 2; +pub const ALG_SET_OP: ::c_int = 3; +pub const ALG_SET_AEAD_ASSOCLEN: ::c_int = 4; +pub const ALG_SET_AEAD_AUTHSIZE: ::c_int = 5; + +pub const ALG_OP_DECRYPT: ::c_int = 0; +pub const ALG_OP_ENCRYPT: ::c_int = 1; + +// uapi/linux/inotify.h +pub const IN_ACCESS: u32 = 0x0000_0001; +pub const IN_MODIFY: u32 = 0x0000_0002; +pub const IN_ATTRIB: u32 = 0x0000_0004; +pub const IN_CLOSE_WRITE: u32 = 0x0000_0008; +pub const IN_CLOSE_NOWRITE: u32 = 0x0000_0010; +pub const IN_CLOSE: u32 = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE); +pub const IN_OPEN: u32 = 0x0000_0020; +pub const IN_MOVED_FROM: u32 = 0x0000_0040; +pub const IN_MOVED_TO: u32 = 0x0000_0080; +pub const IN_MOVE: u32 = (IN_MOVED_FROM | IN_MOVED_TO); +pub const IN_CREATE: u32 = 0x0000_0100; +pub const IN_DELETE: u32 = 0x0000_0200; +pub const IN_DELETE_SELF: u32 = 0x0000_0400; +pub const IN_MOVE_SELF: u32 = 0x0000_0800; +pub const IN_UNMOUNT: u32 = 0x0000_2000; +pub const IN_Q_OVERFLOW: u32 = 0x0000_4000; +pub const IN_IGNORED: u32 = 0x0000_8000; +pub const IN_ONLYDIR: u32 = 0x0100_0000; +pub const IN_DONT_FOLLOW: u32 = 0x0200_0000; +// pub const IN_EXCL_UNLINK: u32 = 0x0400_0000; + +// pub const IN_MASK_CREATE: u32 = 0x1000_0000; +// pub const IN_MASK_ADD: u32 = 0x2000_0000; +pub const IN_ISDIR: u32 = 0x4000_0000; +pub const IN_ONESHOT: u32 = 0x8000_0000; + +pub const IN_ALL_EVENTS: u32 = (IN_ACCESS + | IN_MODIFY + | IN_ATTRIB + | IN_CLOSE_WRITE + | IN_CLOSE_NOWRITE + | IN_OPEN + | IN_MOVED_FROM + | IN_MOVED_TO + | IN_DELETE + | IN_CREATE + | IN_DELETE_SELF + | IN_MOVE_SELF); + +pub const IN_CLOEXEC: ::c_int = O_CLOEXEC; +pub const IN_NONBLOCK: ::c_int = O_NONBLOCK; + +pub const FUTEX_WAIT: ::c_int = 0; +pub const FUTEX_WAKE: ::c_int = 1; +pub const FUTEX_FD: ::c_int = 2; +pub const FUTEX_REQUEUE: ::c_int = 3; +pub const FUTEX_CMP_REQUEUE: ::c_int = 4; +pub const FUTEX_WAKE_OP: ::c_int = 5; +pub const FUTEX_LOCK_PI: ::c_int = 6; +pub const FUTEX_UNLOCK_PI: ::c_int = 7; +pub const FUTEX_TRYLOCK_PI: ::c_int = 8; +pub const FUTEX_WAIT_BITSET: ::c_int = 9; +pub const FUTEX_WAKE_BITSET: ::c_int = 10; +pub const FUTEX_WAIT_REQUEUE_PI: ::c_int = 11; +pub const FUTEX_CMP_REQUEUE_PI: ::c_int = 12; + +pub const FUTEX_PRIVATE_FLAG: ::c_int = 128; +pub const FUTEX_CLOCK_REALTIME: ::c_int = 256; +pub const FUTEX_CMD_MASK: ::c_int = + !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME); + +f! { + pub fn CMSG_NXTHDR(mhdr: *const msghdr, + cmsg: *const cmsghdr) -> *mut cmsghdr { + let next = (cmsg as usize + + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) + as *mut cmsghdr; + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if (next.offset(1)) as usize > max { + 0 as *mut cmsghdr + } else { + next as *mut cmsghdr + } + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.__bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]); + let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits); + cpuset.__bits[idx] |= 1 << offset; + () + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]); + let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits); + cpuset.__bits[idx] &= !(1 << offset); + () + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]); + let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits); + 0 != (cpuset.__bits[idx] & (1 << offset)) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.__bits == set2.__bits + } + pub fn major(dev: ::dev_t) -> ::c_int { + ((dev >> 8) & 0xfff) as ::c_int + } + pub fn minor(dev: ::dev_t) -> ::c_int { + ((dev & 0xff) | ((dev >> 12) & 0xfff00)) as ::c_int + } + pub fn makedev(ma: ::c_int, mi: ::c_int) -> ::dev_t { + let ma = ma as ::dev_t; + let mi = mi as ::dev_t; + ((ma & 0xfff) << 8) | (mi & 0xff) | ((mi & 0xfff00) << 12) + } + + pub fn NLA_ALIGN(len: ::c_int) -> ::c_int { + return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1) + } +} + +extern "C" { + pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; + pub fn madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; + pub fn msync( + addr: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn recvfrom( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + ) -> ::ssize_t; + pub fn getnameinfo( + sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::size_t, + serv: *mut ::c_char, + sevlen: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn ptrace(request: ::c_int, ...) -> ::c_long; + pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; + pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; + pub fn __sched_cpualloc(count: ::size_t) -> *mut ::cpu_set_t; + pub fn __sched_cpufree(set: *mut ::cpu_set_t); + pub fn __sched_cpucount( + setsize: ::size_t, + set: *const cpu_set_t, + ) -> ::c_int; + pub fn sched_getcpu() -> ::c_int; + + pub fn utmpname(name: *const ::c_char) -> ::c_int; + pub fn setutent(); + pub fn getutent() -> *mut utmp; + + pub fn posix_fallocate( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + ) -> ::c_int; + pub fn signalfd( + fd: ::c_int, + mask: *const ::sigset_t, + flags: ::c_int, + ) -> ::c_int; + pub fn syscall(num: ::c_long, ...) -> ::c_long; + pub fn sched_getaffinity( + pid: ::pid_t, + cpusetsize: ::size_t, + cpuset: *mut cpu_set_t, + ) -> ::c_int; + pub fn sched_setaffinity( + pid: ::pid_t, + cpusetsize: ::size_t, + cpuset: *const cpu_set_t, + ) -> ::c_int; + pub fn epoll_create(size: ::c_int) -> ::c_int; + pub fn epoll_create1(flags: ::c_int) -> ::c_int; + pub fn epoll_wait( + epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: ::c_int, + ) -> ::c_int; + pub fn epoll_ctl( + epfd: ::c_int, + op: ::c_int, + fd: ::c_int, + event: *mut ::epoll_event, + ) -> ::c_int; + pub fn pthread_getschedparam( + native: ::pthread_t, + policy: *mut ::c_int, + param: *mut ::sched_param, + ) -> ::c_int; + pub fn unshare(flags: ::c_int) -> ::c_int; + pub fn umount(target: *const ::c_char) -> ::c_int; + pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; + pub fn tee( + fd_in: ::c_int, + fd_out: ::c_int, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn settimeofday( + tv: *const ::timeval, + tz: *const ::timezone, + ) -> ::c_int; + pub fn splice( + fd_in: ::c_int, + off_in: *mut ::loff_t, + fd_out: ::c_int, + off_out: *mut ::loff_t, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; + pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) + -> ::c_int; + pub fn sem_timedwait( + sem: *mut sem_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int; + pub fn sched_setparam( + pid: ::pid_t, + param: *const ::sched_param, + ) -> ::c_int; + pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; + pub fn swapoff(puath: *const ::c_char) -> ::c_int; + pub fn vmsplice( + fd: ::c_int, + iov: *const ::iovec, + nr_segs: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn mount( + src: *const ::c_char, + target: *const ::c_char, + fstype: *const ::c_char, + flags: ::c_ulong, + data: *const ::c_void, + ) -> ::c_int; + pub fn personality(persona: ::c_uint) -> ::c_int; + pub fn prctl(option: ::c_int, ...) -> ::c_int; + pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int; + pub fn ppoll( + fds: *mut ::pollfd, + nfds: nfds_t, + timeout: *const ::timespec, + sigmask: *const sigset_t, + ) -> ::c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn clone( + cb: extern "C" fn(*mut ::c_void) -> ::c_int, + child_stack: *mut ::c_void, + flags: ::c_int, + arg: *mut ::c_void, + ... + ) -> ::c_int; + pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; + pub fn clock_nanosleep( + clk_id: ::clockid_t, + flags: ::c_int, + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + pub fn pthread_attr_getguardsize( + attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t, + ) -> ::c_int; + pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut ::c_int, + ) -> ::c_int; + pub fn sysinfo(info: *mut ::sysinfo) -> ::c_int; + pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; + pub fn pthread_setschedparam( + native: ::pthread_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + pub fn swapon(path: *const ::c_char, swapflags: ::c_int) -> ::c_int; + pub fn sched_setscheduler( + pid: ::pid_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + pub fn sendfile( + out_fd: ::c_int, + in_fd: ::c_int, + offset: *mut off_t, + count: ::size_t, + ) -> ::ssize_t; + pub fn setfsgid(gid: ::gid_t) -> ::c_int; + pub fn setfsuid(uid: ::uid_t) -> ::c_int; + pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigaltstack$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sem_close(sem: *mut sem_t) -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_sigmask$UNIX2003" + )] + pub fn pthread_sigmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const ::c_char) -> *mut ::group; + pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; + pub fn sem_unlink(name: *const ::c_char) -> ::c_int; + pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigwait$UNIX2003" + )] + #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] + pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; + pub fn pthread_atfork( + prepare: ::Option, + parent: ::Option, + child: ::Option, + ) -> ::c_int; + pub fn getgrgid(gid: ::gid_t) -> *mut ::group; + pub fn getgrouplist( + user: *const ::c_char, + group: ::gid_t, + groups: *mut ::gid_t, + ngroups: *mut ::c_int, + ) -> ::c_int; + pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut ::c_int, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "popen$UNIX2003" + )] + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + pub fn faccessat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::c_int, + flags: ::c_int, + ) -> ::c_int; + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + pub fn __errno() -> *mut ::c_int; + pub fn inotify_rm_watch(fd: ::c_int, wd: u32) -> ::c_int; + pub fn sendmmsg( + sockfd: ::c_int, + msgvec: *const ::mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + ) -> ::c_int; + pub fn recvmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn inotify_init() -> ::c_int; + pub fn inotify_init1(flags: ::c_int) -> ::c_int; + pub fn inotify_add_watch( + fd: ::c_int, + path: *const ::c_char, + mask: u32, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + mod b32; + pub use self::b32::*; + } else if #[cfg(target_pointer_width = "64")] { + mod b64; + pub use self::b64::*; + } else { + // Unknown target_pointer_width + } +} + +impl siginfo_t { + pub unsafe fn si_value(&self) -> ::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + _si_tid: ::c_int, + _si_overrun: ::c_int, + si_sigval: ::sigval, + } + (*(self as *const siginfo_t as *const siginfo_timer)).si_sigval + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/emscripten/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/emscripten/align.rs new file mode 100644 index 0000000..141570f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/emscripten/align.rs @@ -0,0 +1,74 @@ +macro_rules! expand_align { + () => { + s! { + #[allow(missing_debug_implementations)] + #[repr(align(4))] + pub struct pthread_mutex_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[repr(align(4))] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + #[repr(align(4))] + pub struct pthread_mutexattr_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(4))] + pub struct pthread_rwlockattr_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + + s_no_extra_traits! { + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct pthread_cond_t { + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f64; 2] + } + + } + + cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.size + .iter() + .zip(other.size.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_cond_t {} + impl ::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_cond_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + impl ::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + } + } + }; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/emscripten/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/emscripten/mod.rs new file mode 100644 index 0000000..3fc47bb --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/emscripten/mod.rs @@ -0,0 +1,1917 @@ +pub type c_char = i8; +pub type wchar_t = i32; +pub type useconds_t = u32; +pub type dev_t = u32; +pub type socklen_t = u32; +pub type pthread_t = c_ulong; +pub type mode_t = u32; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i32; +pub type rlim64_t = u64; +pub type shmatt_t = ::c_ulong; +pub type mqd_t = ::c_int; +pub type msgqnum_t = ::c_ulong; +pub type msglen_t = ::c_ulong; +pub type nfds_t = ::c_ulong; +pub type nl_item = ::c_int; +pub type idtype_t = ::c_uint; +pub type loff_t = i64; +pub type pthread_key_t = ::c_uint; + +pub type clock_t = c_long; +pub type time_t = c_long; +pub type suseconds_t = c_long; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i32; + +pub type blksize_t = c_long; +pub type fsblkcnt_t = u32; +pub type fsfilcnt_t = u32; +pub type rlim_t = ::c_ulonglong; +pub type c_long = i32; +pub type c_ulong = u32; +pub type nlink_t = u32; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum fpos64_t {} // TODO: fill this out with a struct +impl ::Copy for fpos64_t {} +impl ::Clone for fpos64_t { + fn clone(&self) -> fpos64_t { + *self + } +} + +s! { + pub struct rlimit64 { + pub rlim_cur: rlim64_t, + pub rlim_max: rlim64_t, + } + + pub struct glob_t { + pub gl_pathc: ::size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct spwd { + pub sp_namp: *mut ::c_char, + pub sp_pwdp: *mut ::c_char, + pub sp_lstchg: ::c_long, + pub sp_min: ::c_long, + pub sp_max: ::c_long, + pub sp_warn: ::c_long, + pub sp_inact: ::c_long, + pub sp_expire: ::c_long, + pub sp_flag: ::c_ulong, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct dqblk { + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curspace: u64, + pub dqb_ihardlimit: u64, + pub dqb_isoftlimit: u64, + pub dqb_curinodes: u64, + pub dqb_btime: u64, + pub dqb_itime: u64, + pub dqb_valid: u32, + } + + pub struct signalfd_siginfo { + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: u16, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: [u8; 28], + } + + pub struct fsid_t { + __val: [::c_int; 2], + } + + pub struct cpu_set_t { + bits: [u32; 32], + } + + pub struct if_nameindex { + pub if_index: ::c_uint, + pub if_name: *mut ::c_char, + } + + // System V IPC + pub struct msginfo { + pub msgpool: ::c_int, + pub msgmap: ::c_int, + pub msgmax: ::c_int, + pub msgmnb: ::c_int, + pub msgmni: ::c_int, + pub msgssz: ::c_int, + pub msgtql: ::c_int, + pub msgseg: ::c_ushort, + } + + pub struct sembuf { + pub sem_num: ::c_ushort, + pub sem_op: ::c_short, + pub sem_flg: ::c_short, + } + + pub struct aiocb { + pub aio_fildes: ::c_int, + pub aio_lio_opcode: ::c_int, + pub aio_reqprio: ::c_int, + pub aio_buf: *mut ::c_void, + pub aio_nbytes: ::size_t, + pub aio_sigevent: ::sigevent, + __td: *mut ::c_void, + __lock: [::c_int; 2], + __err: ::c_int, + __ret: ::ssize_t, + pub aio_offset: off_t, + __next: *mut ::c_void, + __prev: *mut ::c_void, + __dummy4: [::c_char; 24], + } + + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_int, + __unused1: ::c_long, + __unused2: ::c_long + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + pub __c_ispeed: ::speed_t, + pub __c_ospeed: ::speed_t, + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct pthread_attr_t { + __size: [u32; 11] + } + + pub struct sigset_t { + __val: [::c_ulong; 32], + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::socklen_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::socklen_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct sem_t { + __val: [::c_int; 4], + } + pub struct stat { + pub st_dev: ::dev_t, + __st_dev_padding: ::c_int, + __st_ino_truncated: ::c_long, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_rdev_padding: ::c_int, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_ino: ::ino_t, + } + + pub struct stat64 { + pub st_dev: ::dev_t, + __st_dev_padding: ::c_int, + __st_ino_truncated: ::c_long, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_rdev_padding: ::c_int, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_ino: ::ino_t, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + __unused1: ::c_int, + pub shm_dtime: ::time_t, + __unused2: ::c_int, + pub shm_ctime: ::time_t, + __unused3: ::c_int, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::c_ulong, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + __unused1: ::c_int, + pub msg_rtime: ::time_t, + __unused2: ::c_int, + pub msg_ctime: ::time_t, + __unused3: ::c_int, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u32, + pub f_bfree: u32, + pub f_bavail: u32, + pub f_files: u32, + pub f_ffree: u32, + pub f_favail: u32, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct arpd_request { + pub req: ::c_ushort, + pub ip: u32, + pub dev: ::c_ulong, + pub stamp: ::c_ulong, + pub updated: ::c_ulong, + pub ha: [::c_uchar; ::MAX_ADDR_LEN], + } +} + +s_no_extra_traits! { + pub struct dirent { + pub d_ino: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct dirent64 { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct sysinfo { + pub uptime: ::c_ulong, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub __reserved: [::c_char; 256], + } + + pub struct mq_attr { + pub mq_flags: ::c_long, + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_curmsgs: ::c_long, + pad: [::c_long; 4] + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for dirent64 { + fn eq(&self, other: &dirent64) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent64 {} + impl ::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent64") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + impl ::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for sysinfo { + fn eq(&self, other: &sysinfo) -> bool { + self.uptime == other.uptime + && self.loads == other.loads + && self.totalram == other.totalram + && self.freeram == other.freeram + && self.sharedram == other.sharedram + && self.bufferram == other.bufferram + && self.totalswap == other.totalswap + && self.freeswap == other.freeswap + && self.procs == other.procs + && self.pad == other.pad + && self.totalhigh == other.totalhigh + && self.freehigh == other.freehigh + && self.mem_unit == other.mem_unit + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sysinfo {} + impl ::fmt::Debug for sysinfo { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sysinfo") + .field("uptime", &self.uptime) + .field("loads", &self.loads) + .field("totalram", &self.totalram) + .field("freeram", &self.freeram) + .field("sharedram", &self.sharedram) + .field("bufferram", &self.bufferram) + .field("totalswap", &self.totalswap) + .field("freeswap", &self.freeswap) + .field("procs", &self.procs) + .field("pad", &self.pad) + .field("totalhigh", &self.totalhigh) + .field("freehigh", &self.freehigh) + .field("mem_unit", &self.mem_unit) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } + } + impl ::hash::Hash for sysinfo { + fn hash(&self, state: &mut H) { + self.uptime.hash(state); + self.loads.hash(state); + self.totalram.hash(state); + self.freeram.hash(state); + self.sharedram.hash(state); + self.bufferram.hash(state); + self.totalswap.hash(state); + self.freeswap.hash(state); + self.procs.hash(state); + self.pad.hash(state); + self.totalhigh.hash(state); + self.freehigh.hash(state); + self.mem_unit.hash(state); + self.__reserved.hash(state); + } + } + + impl PartialEq for mq_attr { + fn eq(&self, other: &mq_attr) -> bool { + self.mq_flags == other.mq_flags && + self.mq_maxmsg == other.mq_maxmsg && + self.mq_msgsize == other.mq_msgsize && + self.mq_curmsgs == other.mq_curmsgs + } + } + impl Eq for mq_attr {} + impl ::fmt::Debug for mq_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mq_attr") + .field("mq_flags", &self.mq_flags) + .field("mq_maxmsg", &self.mq_maxmsg) + .field("mq_msgsize", &self.mq_msgsize) + .field("mq_curmsgs", &self.mq_curmsgs) + .finish() + } + } + impl ::hash::Hash for mq_attr { + fn hash(&self, state: &mut H) { + self.mq_flags.hash(state); + self.mq_maxmsg.hash(state); + self.mq_msgsize.hash(state); + self.mq_curmsgs.hash(state); + } + } + } +} + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MS_NOUSER: ::c_ulong = 0x80000000; +pub const MS_RMT_MASK: ::c_ulong = 0x02800051; + +pub const ABDAY_1: ::nl_item = 0x20000; +pub const ABDAY_2: ::nl_item = 0x20001; +pub const ABDAY_3: ::nl_item = 0x20002; +pub const ABDAY_4: ::nl_item = 0x20003; +pub const ABDAY_5: ::nl_item = 0x20004; +pub const ABDAY_6: ::nl_item = 0x20005; +pub const ABDAY_7: ::nl_item = 0x20006; + +pub const DAY_1: ::nl_item = 0x20007; +pub const DAY_2: ::nl_item = 0x20008; +pub const DAY_3: ::nl_item = 0x20009; +pub const DAY_4: ::nl_item = 0x2000A; +pub const DAY_5: ::nl_item = 0x2000B; +pub const DAY_6: ::nl_item = 0x2000C; +pub const DAY_7: ::nl_item = 0x2000D; + +pub const ABMON_1: ::nl_item = 0x2000E; +pub const ABMON_2: ::nl_item = 0x2000F; +pub const ABMON_3: ::nl_item = 0x20010; +pub const ABMON_4: ::nl_item = 0x20011; +pub const ABMON_5: ::nl_item = 0x20012; +pub const ABMON_6: ::nl_item = 0x20013; +pub const ABMON_7: ::nl_item = 0x20014; +pub const ABMON_8: ::nl_item = 0x20015; +pub const ABMON_9: ::nl_item = 0x20016; +pub const ABMON_10: ::nl_item = 0x20017; +pub const ABMON_11: ::nl_item = 0x20018; +pub const ABMON_12: ::nl_item = 0x20019; + +pub const MON_1: ::nl_item = 0x2001A; +pub const MON_2: ::nl_item = 0x2001B; +pub const MON_3: ::nl_item = 0x2001C; +pub const MON_4: ::nl_item = 0x2001D; +pub const MON_5: ::nl_item = 0x2001E; +pub const MON_6: ::nl_item = 0x2001F; +pub const MON_7: ::nl_item = 0x20020; +pub const MON_8: ::nl_item = 0x20021; +pub const MON_9: ::nl_item = 0x20022; +pub const MON_10: ::nl_item = 0x20023; +pub const MON_11: ::nl_item = 0x20024; +pub const MON_12: ::nl_item = 0x20025; + +pub const AM_STR: ::nl_item = 0x20026; +pub const PM_STR: ::nl_item = 0x20027; + +pub const D_T_FMT: ::nl_item = 0x20028; +pub const D_FMT: ::nl_item = 0x20029; +pub const T_FMT: ::nl_item = 0x2002A; +pub const T_FMT_AMPM: ::nl_item = 0x2002B; + +pub const ERA: ::nl_item = 0x2002C; +pub const ERA_D_FMT: ::nl_item = 0x2002E; +pub const ALT_DIGITS: ::nl_item = 0x2002F; +pub const ERA_D_T_FMT: ::nl_item = 0x20030; +pub const ERA_T_FMT: ::nl_item = 0x20031; + +pub const CODESET: ::nl_item = 14; + +pub const CRNCYSTR: ::nl_item = 0x4000F; + +pub const RUSAGE_THREAD: ::c_int = 1; +pub const RUSAGE_CHILDREN: ::c_int = -1; + +pub const RADIXCHAR: ::nl_item = 0x10000; +pub const THOUSEP: ::nl_item = 0x10001; + +pub const YESEXPR: ::nl_item = 0x50000; +pub const NOEXPR: ::nl_item = 0x50001; +pub const YESSTR: ::nl_item = 0x50002; +pub const NOSTR: ::nl_item = 0x50003; + +pub const FILENAME_MAX: ::c_uint = 4096; +pub const L_tmpnam: ::c_uint = 20; +pub const _PC_LINK_MAX: ::c_int = 0; +pub const _PC_MAX_CANON: ::c_int = 1; +pub const _PC_MAX_INPUT: ::c_int = 2; +pub const _PC_NAME_MAX: ::c_int = 3; +pub const _PC_PATH_MAX: ::c_int = 4; +pub const _PC_PIPE_BUF: ::c_int = 5; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 6; +pub const _PC_NO_TRUNC: ::c_int = 7; +pub const _PC_VDISABLE: ::c_int = 8; +pub const _PC_SYNC_IO: ::c_int = 9; +pub const _PC_ASYNC_IO: ::c_int = 10; +pub const _PC_PRIO_IO: ::c_int = 11; +pub const _PC_SOCK_MAXBUF: ::c_int = 12; +pub const _PC_FILESIZEBITS: ::c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16; +pub const _PC_REC_XFER_ALIGN: ::c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18; +pub const _PC_SYMLINK_MAX: ::c_int = 19; +pub const _PC_2_SYMLINKS: ::c_int = 20; + +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_CHILD_MAX: ::c_int = 1; +pub const _SC_CLK_TCK: ::c_int = 2; +pub const _SC_NGROUPS_MAX: ::c_int = 3; +pub const _SC_OPEN_MAX: ::c_int = 4; +pub const _SC_STREAM_MAX: ::c_int = 5; +pub const _SC_TZNAME_MAX: ::c_int = 6; +pub const _SC_JOB_CONTROL: ::c_int = 7; +pub const _SC_SAVED_IDS: ::c_int = 8; +pub const _SC_REALTIME_SIGNALS: ::c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; +pub const _SC_TIMERS: ::c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; +pub const _SC_PRIORITIZED_IO: ::c_int = 13; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; +pub const _SC_FSYNC: ::c_int = 15; +pub const _SC_MAPPED_FILES: ::c_int = 16; +pub const _SC_MEMLOCK: ::c_int = 17; +pub const _SC_MEMLOCK_RANGE: ::c_int = 18; +pub const _SC_MEMORY_PROTECTION: ::c_int = 19; +pub const _SC_MESSAGE_PASSING: ::c_int = 20; +pub const _SC_SEMAPHORES: ::c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; +pub const _SC_AIO_MAX: ::c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; +pub const _SC_DELAYTIMER_MAX: ::c_int = 26; +pub const _SC_MQ_OPEN_MAX: ::c_int = 27; +pub const _SC_MQ_PRIO_MAX: ::c_int = 28; +pub const _SC_VERSION: ::c_int = 29; +pub const _SC_PAGESIZE: ::c_int = 30; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: ::c_int = 31; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; +pub const _SC_SEM_VALUE_MAX: ::c_int = 33; +pub const _SC_SIGQUEUE_MAX: ::c_int = 34; +pub const _SC_TIMER_MAX: ::c_int = 35; +pub const _SC_BC_BASE_MAX: ::c_int = 36; +pub const _SC_BC_DIM_MAX: ::c_int = 37; +pub const _SC_BC_SCALE_MAX: ::c_int = 38; +pub const _SC_BC_STRING_MAX: ::c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; +pub const _SC_EXPR_NEST_MAX: ::c_int = 42; +pub const _SC_LINE_MAX: ::c_int = 43; +pub const _SC_RE_DUP_MAX: ::c_int = 44; +pub const _SC_2_VERSION: ::c_int = 46; +pub const _SC_2_C_BIND: ::c_int = 47; +pub const _SC_2_C_DEV: ::c_int = 48; +pub const _SC_2_FORT_DEV: ::c_int = 49; +pub const _SC_2_FORT_RUN: ::c_int = 50; +pub const _SC_2_SW_DEV: ::c_int = 51; +pub const _SC_2_LOCALEDEF: ::c_int = 52; +pub const _SC_UIO_MAXIOV: ::c_int = 60; +pub const _SC_IOV_MAX: ::c_int = 60; +pub const _SC_THREADS: ::c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; +pub const _SC_TTY_NAME_MAX: ::c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; +pub const _SC_THREAD_STACK_MIN: ::c_int = 75; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82; +pub const _SC_NPROCESSORS_CONF: ::c_int = 83; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; +pub const _SC_PHYS_PAGES: ::c_int = 85; +pub const _SC_AVPHYS_PAGES: ::c_int = 86; +pub const _SC_ATEXIT_MAX: ::c_int = 87; +pub const _SC_PASS_MAX: ::c_int = 88; +pub const _SC_XOPEN_VERSION: ::c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; +pub const _SC_XOPEN_UNIX: ::c_int = 91; +pub const _SC_XOPEN_CRYPT: ::c_int = 92; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; +pub const _SC_XOPEN_SHM: ::c_int = 94; +pub const _SC_2_CHAR_TERM: ::c_int = 95; +pub const _SC_2_UPE: ::c_int = 97; +pub const _SC_XOPEN_XPG2: ::c_int = 98; +pub const _SC_XOPEN_XPG3: ::c_int = 99; +pub const _SC_XOPEN_XPG4: ::c_int = 100; +pub const _SC_NZERO: ::c_int = 109; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; +pub const _SC_XBS5_LP64_OFF64: ::c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; +pub const _SC_XOPEN_LEGACY: ::c_int = 129; +pub const _SC_XOPEN_REALTIME: ::c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; +pub const _SC_ADVISORY_INFO: ::c_int = 132; +pub const _SC_BARRIERS: ::c_int = 133; +pub const _SC_CLOCK_SELECTION: ::c_int = 137; +pub const _SC_CPUTIME: ::c_int = 138; +pub const _SC_THREAD_CPUTIME: ::c_int = 139; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 149; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 153; +pub const _SC_SPIN_LOCKS: ::c_int = 154; +pub const _SC_REGEXP: ::c_int = 155; +pub const _SC_SHELL: ::c_int = 157; +pub const _SC_SPAWN: ::c_int = 159; +pub const _SC_SPORADIC_SERVER: ::c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161; +pub const _SC_TIMEOUTS: ::c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165; +pub const _SC_2_PBS: ::c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169; +pub const _SC_2_PBS_LOCATE: ::c_int = 170; +pub const _SC_2_PBS_MESSAGE: ::c_int = 171; +pub const _SC_2_PBS_TRACK: ::c_int = 172; +pub const _SC_SYMLOOP_MAX: ::c_int = 173; +pub const _SC_STREAMS: ::c_int = 174; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175; +pub const _SC_V6_ILP32_OFF32: ::c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177; +pub const _SC_V6_LP64_OFF64: ::c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179; +pub const _SC_HOST_NAME_MAX: ::c_int = 180; +pub const _SC_TRACE: ::c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182; +pub const _SC_TRACE_INHERIT: ::c_int = 183; +pub const _SC_TRACE_LOG: ::c_int = 184; +pub const _SC_IPV6: ::c_int = 235; +pub const _SC_RAW_SOCKETS: ::c_int = 236; +pub const _SC_V7_ILP32_OFF32: ::c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238; +pub const _SC_V7_LP64_OFF64: ::c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240; +pub const _SC_SS_REPL_MAX: ::c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242; +pub const _SC_TRACE_NAME_MAX: ::c_int = 243; +pub const _SC_TRACE_SYS_MAX: ::c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245; +pub const _SC_XOPEN_STREAMS: ::c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248; + +pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; + +pub const GLOB_ERR: ::c_int = 1 << 0; +pub const GLOB_MARK: ::c_int = 1 << 1; +pub const GLOB_NOSORT: ::c_int = 1 << 2; +pub const GLOB_DOOFFS: ::c_int = 1 << 3; +pub const GLOB_NOCHECK: ::c_int = 1 << 4; +pub const GLOB_APPEND: ::c_int = 1 << 5; +pub const GLOB_NOESCAPE: ::c_int = 1 << 6; + +pub const GLOB_NOSPACE: ::c_int = 1; +pub const GLOB_ABORTED: ::c_int = 2; +pub const GLOB_NOMATCH: ::c_int = 3; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; + +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; + +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; + +pub const ST_RDONLY: ::c_ulong = 1; +pub const ST_NOSUID: ::c_ulong = 2; +pub const ST_NODEV: ::c_ulong = 4; +pub const ST_NOEXEC: ::c_ulong = 8; +pub const ST_SYNCHRONOUS: ::c_ulong = 16; +pub const ST_MANDLOCK: ::c_ulong = 64; +pub const ST_WRITE: ::c_ulong = 128; +pub const ST_APPEND: ::c_ulong = 256; +pub const ST_IMMUTABLE: ::c_ulong = 512; +pub const ST_NOATIME: ::c_ulong = 1024; +pub const ST_NODIRATIME: ::c_ulong = 2048; + +pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void; +pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; +pub const RTLD_NODELETE: ::c_int = 0x1000; +pub const RTLD_NOW: ::c_int = 0x2; + +pub const TCP_MD5SIG: ::c_int = 14; + +align_const! { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], + }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], + }; + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + }; +} + +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0; +pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; + +pub const SCHED_OTHER: ::c_int = 0; +pub const SCHED_FIFO: ::c_int = 1; +pub const SCHED_RR: ::c_int = 2; +pub const SCHED_BATCH: ::c_int = 3; +pub const SCHED_IDLE: ::c_int = 5; + +pub const AF_IB: ::c_int = 27; +pub const AF_MPLS: ::c_int = 28; +pub const AF_NFC: ::c_int = 39; +pub const AF_VSOCK: ::c_int = 40; +pub const PF_IB: ::c_int = AF_IB; +pub const PF_MPLS: ::c_int = AF_MPLS; +pub const PF_NFC: ::c_int = AF_NFC; +pub const PF_VSOCK: ::c_int = AF_VSOCK; + +// System V IPC +pub const IPC_PRIVATE: ::key_t = 0; + +pub const IPC_CREAT: ::c_int = 0o1000; +pub const IPC_EXCL: ::c_int = 0o2000; +pub const IPC_NOWAIT: ::c_int = 0o4000; + +pub const IPC_RMID: ::c_int = 0; +pub const IPC_SET: ::c_int = 1; +pub const IPC_STAT: ::c_int = 2; +pub const IPC_INFO: ::c_int = 3; +pub const MSG_STAT: ::c_int = 11; +pub const MSG_INFO: ::c_int = 12; + +pub const MSG_NOERROR: ::c_int = 0o10000; +pub const MSG_EXCEPT: ::c_int = 0o20000; + +pub const SHM_R: ::c_int = 0o400; +pub const SHM_W: ::c_int = 0o200; + +pub const SHM_RDONLY: ::c_int = 0o10000; +pub const SHM_RND: ::c_int = 0o20000; +pub const SHM_REMAP: ::c_int = 0o40000; +pub const SHM_EXEC: ::c_int = 0o100000; + +pub const SHM_LOCK: ::c_int = 11; +pub const SHM_UNLOCK: ::c_int = 12; + +pub const SHM_HUGETLB: ::c_int = 0o4000; +pub const SHM_NORESERVE: ::c_int = 0o10000; + +pub const EPOLLRDHUP: ::c_int = 0x2000; +pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; +pub const EPOLLONESHOT: ::c_int = 0x40000000; + +pub const QFMT_VFS_OLD: ::c_int = 1; +pub const QFMT_VFS_V0: ::c_int = 2; + +pub const EFD_SEMAPHORE: ::c_int = 0x1; + +pub const LOG_NFACILITIES: ::c_int = 24; + +pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t; + +pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32; +pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32; +pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32; +pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32; +pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32; +pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32; +pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32; + +pub const AI_PASSIVE: ::c_int = 0x0001; +pub const AI_CANONNAME: ::c_int = 0x0002; +pub const AI_NUMERICHOST: ::c_int = 0x0004; +pub const AI_V4MAPPED: ::c_int = 0x0008; +pub const AI_ALL: ::c_int = 0x0010; +pub const AI_ADDRCONFIG: ::c_int = 0x0020; + +pub const AI_NUMERICSERV: ::c_int = 0x0400; + +pub const EAI_BADFLAGS: ::c_int = -1; +pub const EAI_NONAME: ::c_int = -2; +pub const EAI_AGAIN: ::c_int = -3; +pub const EAI_FAIL: ::c_int = -4; +pub const EAI_FAMILY: ::c_int = -6; +pub const EAI_SOCKTYPE: ::c_int = -7; +pub const EAI_SERVICE: ::c_int = -8; +pub const EAI_MEMORY: ::c_int = -10; +pub const EAI_OVERFLOW: ::c_int = -12; + +pub const NI_NUMERICHOST: ::c_int = 1; +pub const NI_NUMERICSERV: ::c_int = 2; +pub const NI_NOFQDN: ::c_int = 4; +pub const NI_NAMEREQD: ::c_int = 8; +pub const NI_DGRAM: ::c_int = 16; + +pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1; +pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2; +pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4; + +pub const EAI_SYSTEM: ::c_int = -11; + +pub const AIO_CANCELED: ::c_int = 0; +pub const AIO_NOTCANCELED: ::c_int = 1; +pub const AIO_ALLDONE: ::c_int = 2; +pub const LIO_READ: ::c_int = 0; +pub const LIO_WRITE: ::c_int = 1; +pub const LIO_NOP: ::c_int = 2; +pub const LIO_WAIT: ::c_int = 0; +pub const LIO_NOWAIT: ::c_int = 1; + +pub const MREMAP_MAYMOVE: ::c_int = 1; +pub const MREMAP_FIXED: ::c_int = 2; + +pub const PR_SET_PDEATHSIG: ::c_int = 1; +pub const PR_GET_PDEATHSIG: ::c_int = 2; + +pub const PR_GET_DUMPABLE: ::c_int = 3; +pub const PR_SET_DUMPABLE: ::c_int = 4; + +pub const PR_GET_UNALIGN: ::c_int = 5; +pub const PR_SET_UNALIGN: ::c_int = 6; +pub const PR_UNALIGN_NOPRINT: ::c_int = 1; +pub const PR_UNALIGN_SIGBUS: ::c_int = 2; + +pub const PR_GET_KEEPCAPS: ::c_int = 7; +pub const PR_SET_KEEPCAPS: ::c_int = 8; + +pub const PR_GET_FPEMU: ::c_int = 9; +pub const PR_SET_FPEMU: ::c_int = 10; +pub const PR_FPEMU_NOPRINT: ::c_int = 1; +pub const PR_FPEMU_SIGFPE: ::c_int = 2; + +pub const PR_GET_FPEXC: ::c_int = 11; +pub const PR_SET_FPEXC: ::c_int = 12; +pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80; +pub const PR_FP_EXC_DIV: ::c_int = 0x010000; +pub const PR_FP_EXC_OVF: ::c_int = 0x020000; +pub const PR_FP_EXC_UND: ::c_int = 0x040000; +pub const PR_FP_EXC_RES: ::c_int = 0x080000; +pub const PR_FP_EXC_INV: ::c_int = 0x100000; +pub const PR_FP_EXC_DISABLED: ::c_int = 0; +pub const PR_FP_EXC_NONRECOV: ::c_int = 1; +pub const PR_FP_EXC_ASYNC: ::c_int = 2; +pub const PR_FP_EXC_PRECISE: ::c_int = 3; + +pub const PR_GET_TIMING: ::c_int = 13; +pub const PR_SET_TIMING: ::c_int = 14; +pub const PR_TIMING_STATISTICAL: ::c_int = 0; +pub const PR_TIMING_TIMESTAMP: ::c_int = 1; + +pub const PR_SET_NAME: ::c_int = 15; +pub const PR_GET_NAME: ::c_int = 16; + +pub const PR_GET_ENDIAN: ::c_int = 19; +pub const PR_SET_ENDIAN: ::c_int = 20; +pub const PR_ENDIAN_BIG: ::c_int = 0; +pub const PR_ENDIAN_LITTLE: ::c_int = 1; +pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2; + +pub const PR_GET_SECCOMP: ::c_int = 21; +pub const PR_SET_SECCOMP: ::c_int = 22; + +pub const PR_CAPBSET_READ: ::c_int = 23; +pub const PR_CAPBSET_DROP: ::c_int = 24; + +pub const PR_GET_TSC: ::c_int = 25; +pub const PR_SET_TSC: ::c_int = 26; +pub const PR_TSC_ENABLE: ::c_int = 1; +pub const PR_TSC_SIGSEGV: ::c_int = 2; + +pub const PR_GET_SECUREBITS: ::c_int = 27; +pub const PR_SET_SECUREBITS: ::c_int = 28; + +pub const PR_SET_TIMERSLACK: ::c_int = 29; +pub const PR_GET_TIMERSLACK: ::c_int = 30; + +pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31; +pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32; + +pub const PR_MCE_KILL: ::c_int = 33; +pub const PR_MCE_KILL_CLEAR: ::c_int = 0; +pub const PR_MCE_KILL_SET: ::c_int = 1; + +pub const PR_MCE_KILL_LATE: ::c_int = 0; +pub const PR_MCE_KILL_EARLY: ::c_int = 1; +pub const PR_MCE_KILL_DEFAULT: ::c_int = 2; + +pub const PR_MCE_KILL_GET: ::c_int = 34; + +pub const PR_SET_MM: ::c_int = 35; +pub const PR_SET_MM_START_CODE: ::c_int = 1; +pub const PR_SET_MM_END_CODE: ::c_int = 2; +pub const PR_SET_MM_START_DATA: ::c_int = 3; +pub const PR_SET_MM_END_DATA: ::c_int = 4; +pub const PR_SET_MM_START_STACK: ::c_int = 5; +pub const PR_SET_MM_START_BRK: ::c_int = 6; +pub const PR_SET_MM_BRK: ::c_int = 7; +pub const PR_SET_MM_ARG_START: ::c_int = 8; +pub const PR_SET_MM_ARG_END: ::c_int = 9; +pub const PR_SET_MM_ENV_START: ::c_int = 10; +pub const PR_SET_MM_ENV_END: ::c_int = 11; +pub const PR_SET_MM_AUXV: ::c_int = 12; +pub const PR_SET_MM_EXE_FILE: ::c_int = 13; +pub const PR_SET_MM_MAP: ::c_int = 14; +pub const PR_SET_MM_MAP_SIZE: ::c_int = 15; + +pub const PR_SET_PTRACER: ::c_int = 0x59616d61; + +pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36; +pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37; + +pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38; +pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39; + +pub const PR_GET_TID_ADDRESS: ::c_int = 40; + +pub const PR_SET_THP_DISABLE: ::c_int = 41; +pub const PR_GET_THP_DISABLE: ::c_int = 42; + +pub const PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43; +pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44; + +pub const PR_SET_FP_MODE: ::c_int = 45; +pub const PR_GET_FP_MODE: ::c_int = 46; +pub const PR_FP_MODE_FR: ::c_int = 1 << 0; +pub const PR_FP_MODE_FRE: ::c_int = 1 << 1; + +pub const PR_CAP_AMBIENT: ::c_int = 47; +pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1; +pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2; +pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3; +pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4; + +pub const ITIMER_REAL: ::c_int = 0; +pub const ITIMER_VIRTUAL: ::c_int = 1; +pub const ITIMER_PROF: ::c_int = 2; + +pub const XATTR_CREATE: ::c_int = 0x1; +pub const XATTR_REPLACE: ::c_int = 0x2; + +pub const _POSIX_VDISABLE: ::cc_t = 0; + +pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; +pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; + +// On Linux, libc doesn't define this constant, libattr does instead. +// We still define it for Linux as it's defined by libc on other platforms, +// and it's mentioned in the man pages for getxattr and setxattr. +pub const SFD_CLOEXEC: ::c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: ::c_int = 512; +pub const O_NOATIME: ::c_int = 0o1000000; +pub const O_CLOEXEC: ::c_int = 0x80000; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const BUFSIZ: ::c_uint = 1024; +pub const TMP_MAX: ::c_uint = 10000; +pub const FOPEN_MAX: ::c_uint = 1000; +pub const O_PATH: ::c_int = 0o10000000; +pub const O_EXEC: ::c_int = 0o10000000; +pub const O_SEARCH: ::c_int = 0o10000000; +pub const O_ACCMODE: ::c_int = 0o10000003; +pub const O_NDELAY: ::c_int = O_NONBLOCK; +pub const NI_MAXHOST: ::socklen_t = 255; +pub const PTHREAD_STACK_MIN: ::size_t = 2048; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const POSIX_MADV_DONTNEED: ::c_int = 0; + +pub const RLIM_INFINITY: ::rlim_t = !0; +pub const RLIMIT_NLIMITS: ::c_int = 15; + +pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; + +pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; +pub const TCP_THIN_DUPACK: ::c_int = 17; +pub const TCP_USER_TIMEOUT: ::c_int = 18; +pub const TCP_REPAIR: ::c_int = 19; +pub const TCP_REPAIR_QUEUE: ::c_int = 20; +pub const TCP_QUEUE_SEQ: ::c_int = 21; +pub const TCP_REPAIR_OPTIONS: ::c_int = 22; +pub const TCP_FASTOPEN: ::c_int = 23; +pub const TCP_TIMESTAMP: ::c_int = 24; + +#[doc(hidden)] +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = ::SIGSYS; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + +pub const CPU_SETSIZE: ::c_int = 128; + +pub const QFMT_VFS_V1: ::c_int = 4; + +pub const PTRACE_TRACEME: ::c_int = 0; +pub const PTRACE_PEEKTEXT: ::c_int = 1; +pub const PTRACE_PEEKDATA: ::c_int = 2; +pub const PTRACE_PEEKUSER: ::c_int = 3; +pub const PTRACE_POKETEXT: ::c_int = 4; +pub const PTRACE_POKEDATA: ::c_int = 5; +pub const PTRACE_POKEUSER: ::c_int = 6; +pub const PTRACE_CONT: ::c_int = 7; +pub const PTRACE_KILL: ::c_int = 8; +pub const PTRACE_SINGLESTEP: ::c_int = 9; +pub const PTRACE_ATTACH: ::c_int = 16; +pub const PTRACE_DETACH: ::c_int = 17; +pub const PTRACE_SYSCALL: ::c_int = 24; +pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; +pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; +pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; +pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; +pub const PTRACE_GETREGSET: ::c_int = 0x4204; +pub const PTRACE_SETREGSET: ::c_int = 0x4205; +pub const PTRACE_SEIZE: ::c_int = 0x4206; +pub const PTRACE_INTERRUPT: ::c_int = 0x4207; +pub const PTRACE_LISTEN: ::c_int = 0x4208; +pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; + +pub const EPOLLWAKEUP: ::c_int = 0x20000000; + +pub const PTRACE_GETFPREGS: ::c_uint = 14; +pub const PTRACE_SETFPREGS: ::c_uint = 15; +pub const PTRACE_GETFPXREGS: ::c_uint = 18; +pub const PTRACE_SETFPXREGS: ::c_uint = 19; +pub const PTRACE_GETREGS: ::c_uint = 12; +pub const PTRACE_SETREGS: ::c_uint = 13; + +pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK; + +pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCINQ: ::c_int = ::FIONREAD; + +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; + +// TODO(#247) Temporarily musl-specific (available since musl 0.9.12 / Linux +// kernel 3.10). See also linux_like/mod.rs +pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; +pub const CLOCK_TAI: ::clockid_t = 11; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_MARK: ::c_int = 36; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_BUSY_POLL: ::c_int = 46; + +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 28; + +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_ASYNC: ::c_int = 0x2000; + +pub const FIOCLEX: ::c_int = 0x5451; +pub const FIONBIO: ::c_int = 0x5421; + +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_LOCKS: ::c_int = 10; +pub const RLIMIT_SIGPENDING: ::c_int = 11; +pub const RLIMIT_MSGQUEUE: ::c_int = 12; +pub const RLIMIT_NICE: ::c_int = 13; +pub const RLIMIT_RTPRIO: ::c_int = 14; + +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; + +pub const SOCK_NONBLOCK: ::c_int = 2048; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_SEQPACKET: ::c_int = 5; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const EMULTIHOP: ::c_int = 72; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_LINGER: ::c_int = 13; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_ACCEPTCONN: ::c_int = 30; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const EXTPROC: ::tcflag_t = 0x00010000; + +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const F_GETLK: ::c_int = 12; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 13; +pub const F_SETLKW: ::c_int = 14; +pub const F_SETOWN: ::c_int = 8; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; + +pub const TCGETS: ::c_int = 0x5401; +pub const TCSETS: ::c_int = 0x5402; +pub const TCSETSW: ::c_int = 0x5403; +pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETA: ::c_int = 0x5405; +pub const TCSETA: ::c_int = 0x5406; +pub const TCSETAW: ::c_int = 0x5407; +pub const TCSETAF: ::c_int = 0x5408; +pub const TCSBRK: ::c_int = 0x5409; +pub const TCXONC: ::c_int = 0x540A; +pub const TCFLSH: ::c_int = 0x540B; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x540F; +pub const TIOCSPGRP: ::c_int = 0x5410; +pub const TIOCOUTQ: ::c_int = 0x5411; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x5413; +pub const TIOCSWINSZ: ::c_int = 0x5414; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x541B; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const SYS_gettid: ::c_long = 224; // Valid for arm (32-bit) and x86 (32-bit) + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const O_TMPFILE: ::c_int = 0x400000; + +pub const MAX_ADDR_LEN: usize = 7; +pub const ARPD_UPDATE: ::c_ushort = 0x01; +pub const ARPD_LOOKUP: ::c_ushort = 0x02; +pub const ARPD_FLUSH: ::c_ushort = 0x03; +pub const ATF_MAGIC: ::c_int = 0x80; + +f! { + pub fn CMSG_NXTHDR(mhdr: *const msghdr, + cmsg: *const cmsghdr) -> *mut cmsghdr { + if ((*cmsg).cmsg_len as usize) < ::mem::size_of::() { + return 0 as *mut cmsghdr; + }; + let next = (cmsg as usize + + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) + as *mut cmsghdr; + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if (next.offset(1)) as usize > max { + 0 as *mut cmsghdr + } else { + next as *mut cmsghdr + } + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits + = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] |= 1 << offset; + () + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits + = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] &= !(1 << offset); + () + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]); + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + 0 != (cpuset.bits[idx] & (1 << offset)) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.bits == set2.bits + } + + pub fn major(dev: ::dev_t) -> ::c_uint { + // see + // https://github.com/kripken/emscripten/blob/ + // master/system/include/libc/sys/sysmacros.h + let mut major = 0; + major |= (dev & 0x00000fff) >> 8; + major |= (dev & 0xfffff000) >> 31 >> 1; + major as ::c_uint + } + + pub fn minor(dev: ::dev_t) -> ::c_uint { + // see + // https://github.com/kripken/emscripten/blob/ + // master/system/include/libc/sys/sysmacros.h + let mut minor = 0; + minor |= (dev & 0x000000ff) >> 0; + minor |= (dev & 0xffffff00) >> 12; + minor as ::c_uint + } + + pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t { + let major = major as ::dev_t; + let minor = minor as ::dev_t; + let mut dev = 0; + dev |= (major & 0x00000fff) << 8; + dev |= (major & 0xfffff000) << 31 << 1; + dev |= (minor & 0x000000ff) << 0; + dev |= (minor & 0xffffff00) << 12; + dev + } +} + +extern "C" { + pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + + pub fn shm_open( + name: *const c_char, + oflag: ::c_int, + mode: mode_t, + ) -> ::c_int; + + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn __errno_location() -> *mut ::c_int; + + pub fn fopen64( + filename: *const c_char, + mode: *const c_char, + ) -> *mut ::FILE; + pub fn freopen64( + filename: *const c_char, + mode: *const c_char, + file: *mut ::FILE, + ) -> *mut ::FILE; + pub fn tmpfile64() -> *mut ::FILE; + pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int; + pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int; + pub fn fseeko64( + stream: *mut ::FILE, + offset: ::off64_t, + whence: ::c_int, + ) -> ::c_int; + pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; + pub fn posix_fallocate( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + ) -> ::c_int; + pub fn pwritev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn preadv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int; + pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; + pub fn mkostemps( + template: *mut ::c_char, + suffixlen: ::c_int, + flags: ::c_int, + ) -> ::c_int; + pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) + -> *mut ::c_char; + pub fn getnameinfo( + sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::socklen_t, + serv: *mut ::c_char, + sevlen: ::socklen_t, + flags: ::c_int, + ) -> ::c_int; + pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; + + // Not available now on Android + pub fn mkfifoat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + ) -> ::c_int; + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + + pub fn mremap( + addr: *mut ::c_void, + len: ::size_t, + new_len: ::size_t, + flags: ::c_int, + ... + ) -> *mut ::c_void; + + pub fn glob( + pattern: *const c_char, + flags: ::c_int, + errfunc: ::Option< + extern "C" fn(epath: *const c_char, errno: ::c_int) -> ::c_int, + >, + pglob: *mut ::glob_t, + ) -> ::c_int; + pub fn globfree(pglob: *mut ::glob_t); + + pub fn posix_madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); + + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; + pub fn madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn msync( + addr: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::c_int; + + pub fn recvfrom( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + ) -> ::ssize_t; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn sendmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_uint, + ) -> ::c_int; + pub fn recvmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_uint, + timeout: *mut ::timespec, + ) -> ::c_int; + pub fn sync(); + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; + pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; + pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + #[macro_use] + mod align; + } else { + #[macro_use] + mod no_align; + } +} +expand_align!(); diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/emscripten/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/emscripten/no_align.rs new file mode 100644 index 0000000..768dc73 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/emscripten/no_align.rs @@ -0,0 +1,63 @@ +macro_rules! expand_align { + () => { + s! { + pub struct pthread_mutex_t { + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + pub struct pthread_mutexattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_rwlockattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + + s_no_extra_traits! { + pub struct pthread_cond_t { + __align: [*const ::c_void; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + } + + cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.size + .iter() + .zip(other.size.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_cond_t {} + impl ::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_cond_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + impl ::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + } + } + }; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/align.rs new file mode 100644 index 0000000..6000b41 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/align.rs @@ -0,0 +1,106 @@ +macro_rules! expand_align { + () => { + s! { + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + target_arch = "aarch64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + target_arch = "aarch64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(not(target_env = "musl"), + target_pointer_width = "64"), + repr(align(8)))] + pub struct pthread_rwlockattr_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + + s_no_extra_traits! { + #[cfg_attr(all(target_env = "musl", + target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(target_env = "musl", + target_pointer_width = "64"), + repr(align(8)))] + #[cfg_attr(all(not(target_env = "musl"), + target_arch = "x86"), + repr(align(4)))] + #[cfg_attr(all(not(target_env = "musl"), + not(target_arch = "x86")), + repr(align(8)))] + pub struct pthread_cond_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86"))), + repr(align(8)))] + pub struct pthread_mutex_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86"))), + repr(align(8)))] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + } + }; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/align.rs new file mode 100644 index 0000000..4a0e074 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/align.rs @@ -0,0 +1,13 @@ +s! { + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/arm/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/arm/align.rs new file mode 100644 index 0000000..825546b --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/arm/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 2] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/arm/mod.rs new file mode 100644 index 0000000..0a5fc85 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -0,0 +1,876 @@ +pub type c_char = u8; +pub type wchar_t = u32; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + f_spare: [::__fsword_t; 5], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_ushort, + __pad1: ::c_ushort, + pub __seq: ::c_ushort, + __pad2: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } + + pub struct stat64 { + pub st_dev: ::dev_t, + __pad1: ::c_uint, + __st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_uint, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_ino: ::ino64_t, + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + __unused1: ::c_ulong, + pub shm_dtime: ::time_t, + __unused2: ::c_ulong, + pub shm_ctime: ::time_t, + __unused3: ::c_ulong, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused4: ::c_ulong, + __unused5: ::c_ulong + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + __glibc_reserved1: ::c_ulong, + pub msg_rtime: ::time_t, + __glibc_reserved2: ::c_ulong, + pub msg_ctime: ::time_t, + __glibc_reserved3: ::c_ulong, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved4: ::c_ulong, + __glibc_reserved5: ::c_ulong, + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } +} + +pub const RLIM_INFINITY: ::rlim_t = !0; +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_LARGEFILE: ::c_int = 0o400000; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 0x101000; +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_NDELAY: ::c_int = 0x800; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const EDEADLOCK: ::c_int = 35; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_LINGER: ::c_int = 13; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; + +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const FIOCLEX: ::c_ulong = 0x5451; +pub const FIONCLEX: ::c_ulong = 0x5450; +pub const FIONBIO: ::c_ulong = 0x5421; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +pub const EFD_NONBLOCK: ::c_int = 0x800; +pub const SFD_NONBLOCK: ::c_int = 0x0800; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = 31; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const BOTHER: ::speed_t = 0o010000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; +pub const EXTPROC: ::tcflag_t = 0x00010000; +pub const TCGETS: ::c_ulong = 0x5401; +pub const TCSETS: ::c_ulong = 0x5402; +pub const TCSETSW: ::c_ulong = 0x5403; +pub const TCSETSF: ::c_ulong = 0x5404; +pub const TCGETA: ::c_ulong = 0x5405; +pub const TCSETA: ::c_ulong = 0x5406; +pub const TCSETAW: ::c_ulong = 0x5407; +pub const TCSETAF: ::c_ulong = 0x5408; +pub const TCSBRK: ::c_ulong = 0x5409; +pub const TCXONC: ::c_ulong = 0x540A; +pub const TCFLSH: ::c_ulong = 0x540B; +pub const TIOCINQ: ::c_ulong = 0x541B; +pub const TIOCGPGRP: ::c_ulong = 0x540F; +pub const TIOCSPGRP: ::c_ulong = 0x5410; +pub const TIOCOUTQ: ::c_ulong = 0x5411; +pub const TIOCGWINSZ: ::c_ulong = 0x5413; +pub const TIOCSWINSZ: ::c_ulong = 0x5414; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; +pub const FIONREAD: ::c_ulong = 0x541B; + +pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; +pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; +pub const TIOCEXCL: ::c_ulong = 0x540C; +pub const TIOCNXCL: ::c_ulong = 0x540D; +pub const TIOCSCTTY: ::c_ulong = 0x540E; +pub const TIOCSTI: ::c_ulong = 0x5412; +pub const TIOCMGET: ::c_ulong = 0x5415; +pub const TIOCMBIS: ::c_ulong = 0x5416; +pub const TIOCMBIC: ::c_ulong = 0x5417; +pub const TIOCMSET: ::c_ulong = 0x5418; +pub const TIOCCONS: ::c_ulong = 0x541D; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCLINUX: ::c_ulong = 0x541C; +pub const TIOCGSERIAL: ::c_ulong = 0x541E; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; + +// Syscall table +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_pause: ::c_long = 29; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_poll: ::c_long = 168; +pub const SYS_nfsservctl: ::c_long = 169; +pub const SYS_setresgid: ::c_long = 170; +pub const SYS_getresgid: ::c_long = 171; +pub const SYS_prctl: ::c_long = 172; +pub const SYS_rt_sigreturn: ::c_long = 173; +pub const SYS_rt_sigaction: ::c_long = 174; +pub const SYS_rt_sigprocmask: ::c_long = 175; +pub const SYS_rt_sigpending: ::c_long = 176; +pub const SYS_rt_sigtimedwait: ::c_long = 177; +pub const SYS_rt_sigqueueinfo: ::c_long = 178; +pub const SYS_rt_sigsuspend: ::c_long = 179; +pub const SYS_pread64: ::c_long = 180; +pub const SYS_pwrite64: ::c_long = 181; +pub const SYS_chown: ::c_long = 182; +pub const SYS_getcwd: ::c_long = 183; +pub const SYS_capget: ::c_long = 184; +pub const SYS_capset: ::c_long = 185; +pub const SYS_sigaltstack: ::c_long = 186; +pub const SYS_sendfile: ::c_long = 187; +pub const SYS_vfork: ::c_long = 190; +pub const SYS_ugetrlimit: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_lchown32: ::c_long = 198; +pub const SYS_getuid32: ::c_long = 199; +pub const SYS_getgid32: ::c_long = 200; +pub const SYS_geteuid32: ::c_long = 201; +pub const SYS_getegid32: ::c_long = 202; +pub const SYS_setreuid32: ::c_long = 203; +pub const SYS_setregid32: ::c_long = 204; +pub const SYS_getgroups32: ::c_long = 205; +pub const SYS_setgroups32: ::c_long = 206; +pub const SYS_fchown32: ::c_long = 207; +pub const SYS_setresuid32: ::c_long = 208; +pub const SYS_getresuid32: ::c_long = 209; +pub const SYS_setresgid32: ::c_long = 210; +pub const SYS_getresgid32: ::c_long = 211; +pub const SYS_chown32: ::c_long = 212; +pub const SYS_setuid32: ::c_long = 213; +pub const SYS_setgid32: ::c_long = 214; +pub const SYS_setfsuid32: ::c_long = 215; +pub const SYS_setfsgid32: ::c_long = 216; +pub const SYS_getdents64: ::c_long = 217; +pub const SYS_pivot_root: ::c_long = 218; +pub const SYS_mincore: ::c_long = 219; +pub const SYS_madvise: ::c_long = 220; +pub const SYS_fcntl64: ::c_long = 221; +pub const SYS_gettid: ::c_long = 224; +pub const SYS_readahead: ::c_long = 225; +pub const SYS_setxattr: ::c_long = 226; +pub const SYS_lsetxattr: ::c_long = 227; +pub const SYS_fsetxattr: ::c_long = 228; +pub const SYS_getxattr: ::c_long = 229; +pub const SYS_lgetxattr: ::c_long = 230; +pub const SYS_fgetxattr: ::c_long = 231; +pub const SYS_listxattr: ::c_long = 232; +pub const SYS_llistxattr: ::c_long = 233; +pub const SYS_flistxattr: ::c_long = 234; +pub const SYS_removexattr: ::c_long = 235; +pub const SYS_lremovexattr: ::c_long = 236; +pub const SYS_fremovexattr: ::c_long = 237; +pub const SYS_tkill: ::c_long = 238; +pub const SYS_sendfile64: ::c_long = 239; +pub const SYS_futex: ::c_long = 240; +pub const SYS_sched_setaffinity: ::c_long = 241; +pub const SYS_sched_getaffinity: ::c_long = 242; +pub const SYS_io_setup: ::c_long = 243; +pub const SYS_io_destroy: ::c_long = 244; +pub const SYS_io_getevents: ::c_long = 245; +pub const SYS_io_submit: ::c_long = 246; +pub const SYS_io_cancel: ::c_long = 247; +pub const SYS_exit_group: ::c_long = 248; +pub const SYS_lookup_dcookie: ::c_long = 249; +pub const SYS_epoll_create: ::c_long = 250; +pub const SYS_epoll_ctl: ::c_long = 251; +pub const SYS_epoll_wait: ::c_long = 252; +pub const SYS_remap_file_pages: ::c_long = 253; +pub const SYS_set_tid_address: ::c_long = 256; +pub const SYS_timer_create: ::c_long = 257; +pub const SYS_timer_settime: ::c_long = 258; +pub const SYS_timer_gettime: ::c_long = 259; +pub const SYS_timer_getoverrun: ::c_long = 260; +pub const SYS_timer_delete: ::c_long = 261; +pub const SYS_clock_settime: ::c_long = 262; +pub const SYS_clock_gettime: ::c_long = 263; +pub const SYS_clock_getres: ::c_long = 264; +pub const SYS_clock_nanosleep: ::c_long = 265; +pub const SYS_statfs64: ::c_long = 266; +pub const SYS_fstatfs64: ::c_long = 267; +pub const SYS_tgkill: ::c_long = 268; +pub const SYS_utimes: ::c_long = 269; +pub const SYS_arm_fadvise64_64: ::c_long = 270; +pub const SYS_pciconfig_iobase: ::c_long = 271; +pub const SYS_pciconfig_read: ::c_long = 272; +pub const SYS_pciconfig_write: ::c_long = 273; +pub const SYS_mq_open: ::c_long = 274; +pub const SYS_mq_unlink: ::c_long = 275; +pub const SYS_mq_timedsend: ::c_long = 276; +pub const SYS_mq_timedreceive: ::c_long = 277; +pub const SYS_mq_notify: ::c_long = 278; +pub const SYS_mq_getsetattr: ::c_long = 279; +pub const SYS_waitid: ::c_long = 280; +pub const SYS_socket: ::c_long = 281; +pub const SYS_bind: ::c_long = 282; +pub const SYS_connect: ::c_long = 283; +pub const SYS_listen: ::c_long = 284; +pub const SYS_accept: ::c_long = 285; +pub const SYS_getsockname: ::c_long = 286; +pub const SYS_getpeername: ::c_long = 287; +pub const SYS_socketpair: ::c_long = 288; +pub const SYS_send: ::c_long = 289; +pub const SYS_sendto: ::c_long = 290; +pub const SYS_recv: ::c_long = 291; +pub const SYS_recvfrom: ::c_long = 292; +pub const SYS_shutdown: ::c_long = 293; +pub const SYS_setsockopt: ::c_long = 294; +pub const SYS_getsockopt: ::c_long = 295; +pub const SYS_sendmsg: ::c_long = 296; +pub const SYS_recvmsg: ::c_long = 297; +pub const SYS_semop: ::c_long = 298; +pub const SYS_semget: ::c_long = 299; +pub const SYS_semctl: ::c_long = 300; +pub const SYS_msgsnd: ::c_long = 301; +pub const SYS_msgrcv: ::c_long = 302; +pub const SYS_msgget: ::c_long = 303; +pub const SYS_msgctl: ::c_long = 304; +pub const SYS_shmat: ::c_long = 305; +pub const SYS_shmdt: ::c_long = 306; +pub const SYS_shmget: ::c_long = 307; +pub const SYS_shmctl: ::c_long = 308; +pub const SYS_add_key: ::c_long = 309; +pub const SYS_request_key: ::c_long = 310; +pub const SYS_keyctl: ::c_long = 311; +pub const SYS_semtimedop: ::c_long = 312; +pub const SYS_vserver: ::c_long = 313; +pub const SYS_ioprio_set: ::c_long = 314; +pub const SYS_ioprio_get: ::c_long = 315; +pub const SYS_inotify_init: ::c_long = 316; +pub const SYS_inotify_add_watch: ::c_long = 317; +pub const SYS_inotify_rm_watch: ::c_long = 318; +pub const SYS_mbind: ::c_long = 319; +pub const SYS_get_mempolicy: ::c_long = 320; +pub const SYS_set_mempolicy: ::c_long = 321; +pub const SYS_openat: ::c_long = 322; +pub const SYS_mkdirat: ::c_long = 323; +pub const SYS_mknodat: ::c_long = 324; +pub const SYS_fchownat: ::c_long = 325; +pub const SYS_futimesat: ::c_long = 326; +pub const SYS_fstatat64: ::c_long = 327; +pub const SYS_unlinkat: ::c_long = 328; +pub const SYS_renameat: ::c_long = 329; +pub const SYS_linkat: ::c_long = 330; +pub const SYS_symlinkat: ::c_long = 331; +pub const SYS_readlinkat: ::c_long = 332; +pub const SYS_fchmodat: ::c_long = 333; +pub const SYS_faccessat: ::c_long = 334; +pub const SYS_pselect6: ::c_long = 335; +pub const SYS_ppoll: ::c_long = 336; +pub const SYS_unshare: ::c_long = 337; +pub const SYS_set_robust_list: ::c_long = 338; +pub const SYS_get_robust_list: ::c_long = 339; +pub const SYS_splice: ::c_long = 340; +pub const SYS_arm_sync_file_range: ::c_long = 341; +pub const SYS_tee: ::c_long = 342; +pub const SYS_vmsplice: ::c_long = 343; +pub const SYS_move_pages: ::c_long = 344; +pub const SYS_getcpu: ::c_long = 345; +pub const SYS_epoll_pwait: ::c_long = 346; +pub const SYS_kexec_load: ::c_long = 347; +pub const SYS_utimensat: ::c_long = 348; +pub const SYS_signalfd: ::c_long = 349; +pub const SYS_timerfd_create: ::c_long = 350; +pub const SYS_eventfd: ::c_long = 351; +pub const SYS_fallocate: ::c_long = 352; +pub const SYS_timerfd_settime: ::c_long = 353; +pub const SYS_timerfd_gettime: ::c_long = 354; +pub const SYS_signalfd4: ::c_long = 355; +pub const SYS_eventfd2: ::c_long = 356; +pub const SYS_epoll_create1: ::c_long = 357; +pub const SYS_dup3: ::c_long = 358; +pub const SYS_pipe2: ::c_long = 359; +pub const SYS_inotify_init1: ::c_long = 360; +pub const SYS_preadv: ::c_long = 361; +pub const SYS_pwritev: ::c_long = 362; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 363; +pub const SYS_perf_event_open: ::c_long = 364; +pub const SYS_recvmmsg: ::c_long = 365; +pub const SYS_accept4: ::c_long = 366; +pub const SYS_fanotify_init: ::c_long = 367; +pub const SYS_fanotify_mark: ::c_long = 368; +pub const SYS_prlimit64: ::c_long = 369; +pub const SYS_name_to_handle_at: ::c_long = 370; +pub const SYS_open_by_handle_at: ::c_long = 371; +pub const SYS_clock_adjtime: ::c_long = 372; +pub const SYS_syncfs: ::c_long = 373; +pub const SYS_sendmmsg: ::c_long = 374; +pub const SYS_setns: ::c_long = 375; +pub const SYS_process_vm_readv: ::c_long = 376; +pub const SYS_process_vm_writev: ::c_long = 377; +pub const SYS_kcmp: ::c_long = 378; +pub const SYS_finit_module: ::c_long = 379; +pub const SYS_sched_setattr: ::c_long = 380; +pub const SYS_sched_getattr: ::c_long = 381; +pub const SYS_renameat2: ::c_long = 382; +pub const SYS_seccomp: ::c_long = 383; +pub const SYS_getrandom: ::c_long = 384; +pub const SYS_memfd_create: ::c_long = 385; +pub const SYS_bpf: ::c_long = 386; +pub const SYS_execveat: ::c_long = 387; +pub const SYS_userfaultfd: ::c_long = 388; +pub const SYS_membarrier: ::c_long = 389; +pub const SYS_mlock2: ::c_long = 390; +pub const SYS_copy_file_range: ::c_long = 391; +pub const SYS_preadv2: ::c_long = 392; +pub const SYS_pwritev2: ::c_long = 393; +pub const SYS_pkey_mprotect: ::c_long = 394; +pub const SYS_pkey_alloc: ::c_long = 395; +pub const SYS_pkey_free: ::c_long = 396; +pub const SYS_statx: ::c_long = 397; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/mips/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/mips/align.rs new file mode 100644 index 0000000..8c228eb --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/mips/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f32; 4] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/mips/mod.rs new file mode 100644 index 0000000..4a3b600 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -0,0 +1,901 @@ +pub type c_char = i8; +pub type wchar_t = i32; + +s! { + pub struct stat64 { + pub st_dev: ::c_ulong, + st_pad1: [::c_long; 3], + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulong, + st_pad2: [::c_long; 2], + pub st_size: ::off64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + st_pad3: ::c_long, + pub st_blocks: ::blkcnt64_t, + st_pad5: [::c_long; 14], + } + + pub struct statfs { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_frsize: ::c_long, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_files: ::fsblkcnt_t, + pub f_ffree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::c_long, + f_spare: [::c_long; 6], + } + + pub struct statfs64 { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_frsize: ::c_long, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_bavail: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_long, + pub f_flags: ::c_long, + pub f_spare: [::c_long; 5], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct sigaction { + pub sa_flags: ::c_int, + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_restorer: ::Option, + _resv: [::c_int; 1], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub _pad: [::c_int; 29], + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_uint, + pub __seq: ::c_ushort, + __pad1: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused4: ::c_ulong, + __unused5: ::c_ulong + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + #[cfg(target_endian = "big")] + __glibc_reserved1: ::c_ulong, + pub msg_stime: ::time_t, + #[cfg(target_endian = "little")] + __glibc_reserved1: ::c_ulong, + #[cfg(target_endian = "big")] + __glibc_reserved2: ::c_ulong, + pub msg_rtime: ::time_t, + #[cfg(target_endian = "little")] + __glibc_reserved2: ::c_ulong, + #[cfg(target_endian = "big")] + __glibc_reserved3: ::c_ulong, + pub msg_ctime: ::time_t, + #[cfg(target_endian = "little")] + __glibc_reserved3: ::c_ulong, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved4: ::c_ulong, + __glibc_reserved5: ::c_ulong, + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_sysid: ::c_long, + pub l_pid: ::pid_t, + pad: [::c_long; 4], + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 23], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + +pub const O_LARGEFILE: ::c_int = 0x2000; + +pub const SYS_syscall: ::c_long = 4000 + 0; +pub const SYS_exit: ::c_long = 4000 + 1; +pub const SYS_fork: ::c_long = 4000 + 2; +pub const SYS_read: ::c_long = 4000 + 3; +pub const SYS_write: ::c_long = 4000 + 4; +pub const SYS_open: ::c_long = 4000 + 5; +pub const SYS_close: ::c_long = 4000 + 6; +pub const SYS_waitpid: ::c_long = 4000 + 7; +pub const SYS_creat: ::c_long = 4000 + 8; +pub const SYS_link: ::c_long = 4000 + 9; +pub const SYS_unlink: ::c_long = 4000 + 10; +pub const SYS_execve: ::c_long = 4000 + 11; +pub const SYS_chdir: ::c_long = 4000 + 12; +pub const SYS_time: ::c_long = 4000 + 13; +pub const SYS_mknod: ::c_long = 4000 + 14; +pub const SYS_chmod: ::c_long = 4000 + 15; +pub const SYS_lchown: ::c_long = 4000 + 16; +pub const SYS_break: ::c_long = 4000 + 17; +pub const SYS_lseek: ::c_long = 4000 + 19; +pub const SYS_getpid: ::c_long = 4000 + 20; +pub const SYS_mount: ::c_long = 4000 + 21; +pub const SYS_umount: ::c_long = 4000 + 22; +pub const SYS_setuid: ::c_long = 4000 + 23; +pub const SYS_getuid: ::c_long = 4000 + 24; +pub const SYS_stime: ::c_long = 4000 + 25; +pub const SYS_ptrace: ::c_long = 4000 + 26; +pub const SYS_alarm: ::c_long = 4000 + 27; +pub const SYS_pause: ::c_long = 4000 + 29; +pub const SYS_utime: ::c_long = 4000 + 30; +pub const SYS_stty: ::c_long = 4000 + 31; +pub const SYS_gtty: ::c_long = 4000 + 32; +pub const SYS_access: ::c_long = 4000 + 33; +pub const SYS_nice: ::c_long = 4000 + 34; +pub const SYS_ftime: ::c_long = 4000 + 35; +pub const SYS_sync: ::c_long = 4000 + 36; +pub const SYS_kill: ::c_long = 4000 + 37; +pub const SYS_rename: ::c_long = 4000 + 38; +pub const SYS_mkdir: ::c_long = 4000 + 39; +pub const SYS_rmdir: ::c_long = 4000 + 40; +pub const SYS_dup: ::c_long = 4000 + 41; +pub const SYS_pipe: ::c_long = 4000 + 42; +pub const SYS_times: ::c_long = 4000 + 43; +pub const SYS_prof: ::c_long = 4000 + 44; +pub const SYS_brk: ::c_long = 4000 + 45; +pub const SYS_setgid: ::c_long = 4000 + 46; +pub const SYS_getgid: ::c_long = 4000 + 47; +pub const SYS_signal: ::c_long = 4000 + 48; +pub const SYS_geteuid: ::c_long = 4000 + 49; +pub const SYS_getegid: ::c_long = 4000 + 50; +pub const SYS_acct: ::c_long = 4000 + 51; +pub const SYS_umount2: ::c_long = 4000 + 52; +pub const SYS_lock: ::c_long = 4000 + 53; +pub const SYS_ioctl: ::c_long = 4000 + 54; +pub const SYS_fcntl: ::c_long = 4000 + 55; +pub const SYS_mpx: ::c_long = 4000 + 56; +pub const SYS_setpgid: ::c_long = 4000 + 57; +pub const SYS_ulimit: ::c_long = 4000 + 58; +pub const SYS_umask: ::c_long = 4000 + 60; +pub const SYS_chroot: ::c_long = 4000 + 61; +pub const SYS_ustat: ::c_long = 4000 + 62; +pub const SYS_dup2: ::c_long = 4000 + 63; +pub const SYS_getppid: ::c_long = 4000 + 64; +pub const SYS_getpgrp: ::c_long = 4000 + 65; +pub const SYS_setsid: ::c_long = 4000 + 66; +pub const SYS_sigaction: ::c_long = 4000 + 67; +pub const SYS_sgetmask: ::c_long = 4000 + 68; +pub const SYS_ssetmask: ::c_long = 4000 + 69; +pub const SYS_setreuid: ::c_long = 4000 + 70; +pub const SYS_setregid: ::c_long = 4000 + 71; +pub const SYS_sigsuspend: ::c_long = 4000 + 72; +pub const SYS_sigpending: ::c_long = 4000 + 73; +pub const SYS_sethostname: ::c_long = 4000 + 74; +pub const SYS_setrlimit: ::c_long = 4000 + 75; +pub const SYS_getrlimit: ::c_long = 4000 + 76; +pub const SYS_getrusage: ::c_long = 4000 + 77; +pub const SYS_gettimeofday: ::c_long = 4000 + 78; +pub const SYS_settimeofday: ::c_long = 4000 + 79; +pub const SYS_getgroups: ::c_long = 4000 + 80; +pub const SYS_setgroups: ::c_long = 4000 + 81; +pub const SYS_symlink: ::c_long = 4000 + 83; +pub const SYS_readlink: ::c_long = 4000 + 85; +pub const SYS_uselib: ::c_long = 4000 + 86; +pub const SYS_swapon: ::c_long = 4000 + 87; +pub const SYS_reboot: ::c_long = 4000 + 88; +pub const SYS_readdir: ::c_long = 4000 + 89; +pub const SYS_mmap: ::c_long = 4000 + 90; +pub const SYS_munmap: ::c_long = 4000 + 91; +pub const SYS_truncate: ::c_long = 4000 + 92; +pub const SYS_ftruncate: ::c_long = 4000 + 93; +pub const SYS_fchmod: ::c_long = 4000 + 94; +pub const SYS_fchown: ::c_long = 4000 + 95; +pub const SYS_getpriority: ::c_long = 4000 + 96; +pub const SYS_setpriority: ::c_long = 4000 + 97; +pub const SYS_profil: ::c_long = 4000 + 98; +pub const SYS_statfs: ::c_long = 4000 + 99; +pub const SYS_fstatfs: ::c_long = 4000 + 100; +pub const SYS_ioperm: ::c_long = 4000 + 101; +pub const SYS_socketcall: ::c_long = 4000 + 102; +pub const SYS_syslog: ::c_long = 4000 + 103; +pub const SYS_setitimer: ::c_long = 4000 + 104; +pub const SYS_getitimer: ::c_long = 4000 + 105; +pub const SYS_stat: ::c_long = 4000 + 106; +pub const SYS_lstat: ::c_long = 4000 + 107; +pub const SYS_fstat: ::c_long = 4000 + 108; +pub const SYS_iopl: ::c_long = 4000 + 110; +pub const SYS_vhangup: ::c_long = 4000 + 111; +pub const SYS_idle: ::c_long = 4000 + 112; +pub const SYS_vm86: ::c_long = 4000 + 113; +pub const SYS_wait4: ::c_long = 4000 + 114; +pub const SYS_swapoff: ::c_long = 4000 + 115; +pub const SYS_sysinfo: ::c_long = 4000 + 116; +pub const SYS_ipc: ::c_long = 4000 + 117; +pub const SYS_fsync: ::c_long = 4000 + 118; +pub const SYS_sigreturn: ::c_long = 4000 + 119; +pub const SYS_clone: ::c_long = 4000 + 120; +pub const SYS_setdomainname: ::c_long = 4000 + 121; +pub const SYS_uname: ::c_long = 4000 + 122; +pub const SYS_modify_ldt: ::c_long = 4000 + 123; +pub const SYS_adjtimex: ::c_long = 4000 + 124; +pub const SYS_mprotect: ::c_long = 4000 + 125; +pub const SYS_sigprocmask: ::c_long = 4000 + 126; +pub const SYS_create_module: ::c_long = 4000 + 127; +pub const SYS_init_module: ::c_long = 4000 + 128; +pub const SYS_delete_module: ::c_long = 4000 + 129; +pub const SYS_get_kernel_syms: ::c_long = 4000 + 130; +pub const SYS_quotactl: ::c_long = 4000 + 131; +pub const SYS_getpgid: ::c_long = 4000 + 132; +pub const SYS_fchdir: ::c_long = 4000 + 133; +pub const SYS_bdflush: ::c_long = 4000 + 134; +pub const SYS_sysfs: ::c_long = 4000 + 135; +pub const SYS_personality: ::c_long = 4000 + 136; +pub const SYS_afs_syscall: ::c_long = 4000 + 137; +pub const SYS_setfsuid: ::c_long = 4000 + 138; +pub const SYS_setfsgid: ::c_long = 4000 + 139; +pub const SYS__llseek: ::c_long = 4000 + 140; +pub const SYS_getdents: ::c_long = 4000 + 141; +pub const SYS__newselect: ::c_long = 4000 + 142; +pub const SYS_flock: ::c_long = 4000 + 143; +pub const SYS_msync: ::c_long = 4000 + 144; +pub const SYS_readv: ::c_long = 4000 + 145; +pub const SYS_writev: ::c_long = 4000 + 146; +pub const SYS_cacheflush: ::c_long = 4000 + 147; +pub const SYS_cachectl: ::c_long = 4000 + 148; +pub const SYS_sysmips: ::c_long = 4000 + 149; +pub const SYS_getsid: ::c_long = 4000 + 151; +pub const SYS_fdatasync: ::c_long = 4000 + 152; +pub const SYS__sysctl: ::c_long = 4000 + 153; +pub const SYS_mlock: ::c_long = 4000 + 154; +pub const SYS_munlock: ::c_long = 4000 + 155; +pub const SYS_mlockall: ::c_long = 4000 + 156; +pub const SYS_munlockall: ::c_long = 4000 + 157; +pub const SYS_sched_setparam: ::c_long = 4000 + 158; +pub const SYS_sched_getparam: ::c_long = 4000 + 159; +pub const SYS_sched_setscheduler: ::c_long = 4000 + 160; +pub const SYS_sched_getscheduler: ::c_long = 4000 + 161; +pub const SYS_sched_yield: ::c_long = 4000 + 162; +pub const SYS_sched_get_priority_max: ::c_long = 4000 + 163; +pub const SYS_sched_get_priority_min: ::c_long = 4000 + 164; +pub const SYS_sched_rr_get_interval: ::c_long = 4000 + 165; +pub const SYS_nanosleep: ::c_long = 4000 + 166; +pub const SYS_mremap: ::c_long = 4000 + 167; +pub const SYS_accept: ::c_long = 4000 + 168; +pub const SYS_bind: ::c_long = 4000 + 169; +pub const SYS_connect: ::c_long = 4000 + 170; +pub const SYS_getpeername: ::c_long = 4000 + 171; +pub const SYS_getsockname: ::c_long = 4000 + 172; +pub const SYS_getsockopt: ::c_long = 4000 + 173; +pub const SYS_listen: ::c_long = 4000 + 174; +pub const SYS_recv: ::c_long = 4000 + 175; +pub const SYS_recvfrom: ::c_long = 4000 + 176; +pub const SYS_recvmsg: ::c_long = 4000 + 177; +pub const SYS_send: ::c_long = 4000 + 178; +pub const SYS_sendmsg: ::c_long = 4000 + 179; +pub const SYS_sendto: ::c_long = 4000 + 180; +pub const SYS_setsockopt: ::c_long = 4000 + 181; +pub const SYS_shutdown: ::c_long = 4000 + 182; +pub const SYS_socket: ::c_long = 4000 + 183; +pub const SYS_socketpair: ::c_long = 4000 + 184; +pub const SYS_setresuid: ::c_long = 4000 + 185; +pub const SYS_getresuid: ::c_long = 4000 + 186; +pub const SYS_query_module: ::c_long = 4000 + 187; +pub const SYS_poll: ::c_long = 4000 + 188; +pub const SYS_nfsservctl: ::c_long = 4000 + 189; +pub const SYS_setresgid: ::c_long = 4000 + 190; +pub const SYS_getresgid: ::c_long = 4000 + 191; +pub const SYS_prctl: ::c_long = 4000 + 192; +pub const SYS_rt_sigreturn: ::c_long = 4000 + 193; +pub const SYS_rt_sigaction: ::c_long = 4000 + 194; +pub const SYS_rt_sigprocmask: ::c_long = 4000 + 195; +pub const SYS_rt_sigpending: ::c_long = 4000 + 196; +pub const SYS_rt_sigtimedwait: ::c_long = 4000 + 197; +pub const SYS_rt_sigqueueinfo: ::c_long = 4000 + 198; +pub const SYS_rt_sigsuspend: ::c_long = 4000 + 199; +pub const SYS_pread64: ::c_long = 4000 + 200; +pub const SYS_pwrite64: ::c_long = 4000 + 201; +pub const SYS_chown: ::c_long = 4000 + 202; +pub const SYS_getcwd: ::c_long = 4000 + 203; +pub const SYS_capget: ::c_long = 4000 + 204; +pub const SYS_capset: ::c_long = 4000 + 205; +pub const SYS_sigaltstack: ::c_long = 4000 + 206; +pub const SYS_sendfile: ::c_long = 4000 + 207; +pub const SYS_getpmsg: ::c_long = 4000 + 208; +pub const SYS_putpmsg: ::c_long = 4000 + 209; +pub const SYS_mmap2: ::c_long = 4000 + 210; +pub const SYS_truncate64: ::c_long = 4000 + 211; +pub const SYS_ftruncate64: ::c_long = 4000 + 212; +pub const SYS_stat64: ::c_long = 4000 + 213; +pub const SYS_lstat64: ::c_long = 4000 + 214; +pub const SYS_fstat64: ::c_long = 4000 + 215; +pub const SYS_pivot_root: ::c_long = 4000 + 216; +pub const SYS_mincore: ::c_long = 4000 + 217; +pub const SYS_madvise: ::c_long = 4000 + 218; +pub const SYS_getdents64: ::c_long = 4000 + 219; +pub const SYS_fcntl64: ::c_long = 4000 + 220; +pub const SYS_gettid: ::c_long = 4000 + 222; +pub const SYS_readahead: ::c_long = 4000 + 223; +pub const SYS_setxattr: ::c_long = 4000 + 224; +pub const SYS_lsetxattr: ::c_long = 4000 + 225; +pub const SYS_fsetxattr: ::c_long = 4000 + 226; +pub const SYS_getxattr: ::c_long = 4000 + 227; +pub const SYS_lgetxattr: ::c_long = 4000 + 228; +pub const SYS_fgetxattr: ::c_long = 4000 + 229; +pub const SYS_listxattr: ::c_long = 4000 + 230; +pub const SYS_llistxattr: ::c_long = 4000 + 231; +pub const SYS_flistxattr: ::c_long = 4000 + 232; +pub const SYS_removexattr: ::c_long = 4000 + 233; +pub const SYS_lremovexattr: ::c_long = 4000 + 234; +pub const SYS_fremovexattr: ::c_long = 4000 + 235; +pub const SYS_tkill: ::c_long = 4000 + 236; +pub const SYS_sendfile64: ::c_long = 4000 + 237; +pub const SYS_futex: ::c_long = 4000 + 238; +pub const SYS_sched_setaffinity: ::c_long = 4000 + 239; +pub const SYS_sched_getaffinity: ::c_long = 4000 + 240; +pub const SYS_io_setup: ::c_long = 4000 + 241; +pub const SYS_io_destroy: ::c_long = 4000 + 242; +pub const SYS_io_getevents: ::c_long = 4000 + 243; +pub const SYS_io_submit: ::c_long = 4000 + 244; +pub const SYS_io_cancel: ::c_long = 4000 + 245; +pub const SYS_exit_group: ::c_long = 4000 + 246; +pub const SYS_lookup_dcookie: ::c_long = 4000 + 247; +pub const SYS_epoll_create: ::c_long = 4000 + 248; +pub const SYS_epoll_ctl: ::c_long = 4000 + 249; +pub const SYS_epoll_wait: ::c_long = 4000 + 250; +pub const SYS_remap_file_pages: ::c_long = 4000 + 251; +pub const SYS_set_tid_address: ::c_long = 4000 + 252; +pub const SYS_restart_syscall: ::c_long = 4000 + 253; +pub const SYS_fadvise64: ::c_long = 4000 + 254; +pub const SYS_statfs64: ::c_long = 4000 + 255; +pub const SYS_fstatfs64: ::c_long = 4000 + 256; +pub const SYS_timer_create: ::c_long = 4000 + 257; +pub const SYS_timer_settime: ::c_long = 4000 + 258; +pub const SYS_timer_gettime: ::c_long = 4000 + 259; +pub const SYS_timer_getoverrun: ::c_long = 4000 + 260; +pub const SYS_timer_delete: ::c_long = 4000 + 261; +pub const SYS_clock_settime: ::c_long = 4000 + 262; +pub const SYS_clock_gettime: ::c_long = 4000 + 263; +pub const SYS_clock_getres: ::c_long = 4000 + 264; +pub const SYS_clock_nanosleep: ::c_long = 4000 + 265; +pub const SYS_tgkill: ::c_long = 4000 + 266; +pub const SYS_utimes: ::c_long = 4000 + 267; +pub const SYS_mbind: ::c_long = 4000 + 268; +pub const SYS_get_mempolicy: ::c_long = 4000 + 269; +pub const SYS_set_mempolicy: ::c_long = 4000 + 270; +pub const SYS_mq_open: ::c_long = 4000 + 271; +pub const SYS_mq_unlink: ::c_long = 4000 + 272; +pub const SYS_mq_timedsend: ::c_long = 4000 + 273; +pub const SYS_mq_timedreceive: ::c_long = 4000 + 274; +pub const SYS_mq_notify: ::c_long = 4000 + 275; +pub const SYS_mq_getsetattr: ::c_long = 4000 + 276; +pub const SYS_vserver: ::c_long = 4000 + 277; +pub const SYS_waitid: ::c_long = 4000 + 278; +/* pub const SYS_sys_setaltroot: ::c_long = 4000 + 279; */ +pub const SYS_add_key: ::c_long = 4000 + 280; +pub const SYS_request_key: ::c_long = 4000 + 281; +pub const SYS_keyctl: ::c_long = 4000 + 282; +pub const SYS_set_thread_area: ::c_long = 4000 + 283; +pub const SYS_inotify_init: ::c_long = 4000 + 284; +pub const SYS_inotify_add_watch: ::c_long = 4000 + 285; +pub const SYS_inotify_rm_watch: ::c_long = 4000 + 286; +pub const SYS_migrate_pages: ::c_long = 4000 + 287; +pub const SYS_openat: ::c_long = 4000 + 288; +pub const SYS_mkdirat: ::c_long = 4000 + 289; +pub const SYS_mknodat: ::c_long = 4000 + 290; +pub const SYS_fchownat: ::c_long = 4000 + 291; +pub const SYS_futimesat: ::c_long = 4000 + 292; +pub const SYS_fstatat64: ::c_long = 4000 + 293; +pub const SYS_unlinkat: ::c_long = 4000 + 294; +pub const SYS_renameat: ::c_long = 4000 + 295; +pub const SYS_linkat: ::c_long = 4000 + 296; +pub const SYS_symlinkat: ::c_long = 4000 + 297; +pub const SYS_readlinkat: ::c_long = 4000 + 298; +pub const SYS_fchmodat: ::c_long = 4000 + 299; +pub const SYS_faccessat: ::c_long = 4000 + 300; +pub const SYS_pselect6: ::c_long = 4000 + 301; +pub const SYS_ppoll: ::c_long = 4000 + 302; +pub const SYS_unshare: ::c_long = 4000 + 303; +pub const SYS_splice: ::c_long = 4000 + 304; +pub const SYS_sync_file_range: ::c_long = 4000 + 305; +pub const SYS_tee: ::c_long = 4000 + 306; +pub const SYS_vmsplice: ::c_long = 4000 + 307; +pub const SYS_move_pages: ::c_long = 4000 + 308; +pub const SYS_set_robust_list: ::c_long = 4000 + 309; +pub const SYS_get_robust_list: ::c_long = 4000 + 310; +pub const SYS_kexec_load: ::c_long = 4000 + 311; +pub const SYS_getcpu: ::c_long = 4000 + 312; +pub const SYS_epoll_pwait: ::c_long = 4000 + 313; +pub const SYS_ioprio_set: ::c_long = 4000 + 314; +pub const SYS_ioprio_get: ::c_long = 4000 + 315; +pub const SYS_utimensat: ::c_long = 4000 + 316; +pub const SYS_signalfd: ::c_long = 4000 + 317; +pub const SYS_timerfd: ::c_long = 4000 + 318; +pub const SYS_eventfd: ::c_long = 4000 + 319; +pub const SYS_fallocate: ::c_long = 4000 + 320; +pub const SYS_timerfd_create: ::c_long = 4000 + 321; +pub const SYS_timerfd_gettime: ::c_long = 4000 + 322; +pub const SYS_timerfd_settime: ::c_long = 4000 + 323; +pub const SYS_signalfd4: ::c_long = 4000 + 324; +pub const SYS_eventfd2: ::c_long = 4000 + 325; +pub const SYS_epoll_create1: ::c_long = 4000 + 326; +pub const SYS_dup3: ::c_long = 4000 + 327; +pub const SYS_pipe2: ::c_long = 4000 + 328; +pub const SYS_inotify_init1: ::c_long = 4000 + 329; +pub const SYS_preadv: ::c_long = 4000 + 330; +pub const SYS_pwritev: ::c_long = 4000 + 331; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 4000 + 332; +pub const SYS_perf_event_open: ::c_long = 4000 + 333; +pub const SYS_accept4: ::c_long = 4000 + 334; +pub const SYS_recvmmsg: ::c_long = 4000 + 335; +pub const SYS_fanotify_init: ::c_long = 4000 + 336; +pub const SYS_fanotify_mark: ::c_long = 4000 + 337; +pub const SYS_prlimit64: ::c_long = 4000 + 338; +pub const SYS_name_to_handle_at: ::c_long = 4000 + 339; +pub const SYS_open_by_handle_at: ::c_long = 4000 + 340; +pub const SYS_clock_adjtime: ::c_long = 4000 + 341; +pub const SYS_syncfs: ::c_long = 4000 + 342; +pub const SYS_sendmmsg: ::c_long = 4000 + 343; +pub const SYS_setns: ::c_long = 4000 + 344; +pub const SYS_process_vm_readv: ::c_long = 4000 + 345; +pub const SYS_process_vm_writev: ::c_long = 4000 + 346; +pub const SYS_kcmp: ::c_long = 4000 + 347; +pub const SYS_finit_module: ::c_long = 4000 + 348; +pub const SYS_sched_setattr: ::c_long = 4000 + 349; +pub const SYS_sched_getattr: ::c_long = 4000 + 350; +pub const SYS_renameat2: ::c_long = 4000 + 351; +pub const SYS_seccomp: ::c_long = 4000 + 352; +pub const SYS_getrandom: ::c_long = 4000 + 353; +pub const SYS_memfd_create: ::c_long = 4000 + 354; +pub const SYS_bpf: ::c_long = 4000 + 355; +pub const SYS_execveat: ::c_long = 4000 + 356; +pub const SYS_userfaultfd: ::c_long = 4000 + 357; +pub const SYS_membarrier: ::c_long = 4000 + 358; +pub const SYS_mlock2: ::c_long = 4000 + 359; +pub const SYS_copy_file_range: ::c_long = 4000 + 360; +pub const SYS_preadv2: ::c_long = 4000 + 361; +pub const SYS_pwritev2: ::c_long = 4000 + 362; +pub const SYS_pkey_mprotect: ::c_long = 4000 + 363; +pub const SYS_pkey_alloc: ::c_long = 4000 + 364; +pub const SYS_pkey_free: ::c_long = 4000 + 365; +pub const SYS_statx: ::c_long = 4000 + 366; + +pub const O_DIRECT: ::c_int = 0x8000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; + +pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 6; +pub const RLIMIT_RSS: ::__rlimit_resource_t = 7; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 8; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 9; + +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 256; +pub const O_EXCL: ::c_int = 1024; +pub const O_NOCTTY: ::c_int = 2048; +pub const O_NONBLOCK: ::c_int = 128; +pub const O_SYNC: ::c_int = 0x4010; +pub const O_RSYNC: ::c_int = 0x4010; +pub const O_DSYNC: ::c_int = 0x10; +pub const O_FSYNC: ::c_int = 0x4010; +pub const O_ASYNC: ::c_int = 0x1000; +pub const O_NDELAY: ::c_int = 0x80; + +pub const EDEADLK: ::c_int = 45; +pub const ENAMETOOLONG: ::c_int = 78; +pub const ENOLCK: ::c_int = 46; +pub const ENOSYS: ::c_int = 89; +pub const ENOTEMPTY: ::c_int = 93; +pub const ELOOP: ::c_int = 90; +pub const ENOMSG: ::c_int = 35; +pub const EIDRM: ::c_int = 36; +pub const ECHRNG: ::c_int = 37; +pub const EL2NSYNC: ::c_int = 38; +pub const EL3HLT: ::c_int = 39; +pub const EL3RST: ::c_int = 40; +pub const ELNRNG: ::c_int = 41; +pub const EUNATCH: ::c_int = 42; +pub const ENOCSI: ::c_int = 43; +pub const EL2HLT: ::c_int = 44; +pub const EBADE: ::c_int = 50; +pub const EBADR: ::c_int = 51; +pub const EXFULL: ::c_int = 52; +pub const ENOANO: ::c_int = 53; +pub const EBADRQC: ::c_int = 54; +pub const EBADSLT: ::c_int = 55; +pub const EDEADLOCK: ::c_int = 56; +pub const EMULTIHOP: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 79; +pub const ENOTUNIQ: ::c_int = 80; +pub const EBADFD: ::c_int = 81; +pub const EBADMSG: ::c_int = 77; +pub const EREMCHG: ::c_int = 82; +pub const ELIBACC: ::c_int = 83; +pub const ELIBBAD: ::c_int = 84; +pub const ELIBSCN: ::c_int = 85; +pub const ELIBMAX: ::c_int = 86; +pub const ELIBEXEC: ::c_int = 87; +pub const EILSEQ: ::c_int = 88; +pub const ERESTART: ::c_int = 91; +pub const ESTRPIPE: ::c_int = 92; +pub const EUSERS: ::c_int = 94; +pub const ENOTSOCK: ::c_int = 95; +pub const EDESTADDRREQ: ::c_int = 96; +pub const EMSGSIZE: ::c_int = 97; +pub const EPROTOTYPE: ::c_int = 98; +pub const ENOPROTOOPT: ::c_int = 99; +pub const EPROTONOSUPPORT: ::c_int = 120; +pub const ESOCKTNOSUPPORT: ::c_int = 121; +pub const EOPNOTSUPP: ::c_int = 122; +pub const EPFNOSUPPORT: ::c_int = 123; +pub const EAFNOSUPPORT: ::c_int = 124; +pub const EADDRINUSE: ::c_int = 125; +pub const EADDRNOTAVAIL: ::c_int = 126; +pub const ENETDOWN: ::c_int = 127; +pub const ENETUNREACH: ::c_int = 128; +pub const ENETRESET: ::c_int = 129; +pub const ECONNABORTED: ::c_int = 130; +pub const ECONNRESET: ::c_int = 131; +pub const ENOBUFS: ::c_int = 132; +pub const EISCONN: ::c_int = 133; +pub const ENOTCONN: ::c_int = 134; +pub const ESHUTDOWN: ::c_int = 143; +pub const ETOOMANYREFS: ::c_int = 144; +pub const ETIMEDOUT: ::c_int = 145; +pub const ECONNREFUSED: ::c_int = 146; +pub const EHOSTDOWN: ::c_int = 147; +pub const EHOSTUNREACH: ::c_int = 148; +pub const EALREADY: ::c_int = 149; +pub const EINPROGRESS: ::c_int = 150; +pub const ESTALE: ::c_int = 151; +pub const EUCLEAN: ::c_int = 135; +pub const ENOTNAM: ::c_int = 137; +pub const ENAVAIL: ::c_int = 138; +pub const EISNAM: ::c_int = 139; +pub const EREMOTEIO: ::c_int = 140; +pub const EDQUOT: ::c_int = 1133; +pub const ENOMEDIUM: ::c_int = 159; +pub const EMEDIUMTYPE: ::c_int = 160; +pub const ECANCELED: ::c_int = 158; +pub const ENOKEY: ::c_int = 161; +pub const EKEYEXPIRED: ::c_int = 162; +pub const EKEYREVOKED: ::c_int = 163; +pub const EKEYREJECTED: ::c_int = 164; +pub const EOWNERDEAD: ::c_int = 165; +pub const ENOTRECOVERABLE: ::c_int = 166; +pub const ERFKILL: ::c_int = 167; + +pub const MAP_NORESERVE: ::c_int = 0x400; +pub const MAP_ANON: ::c_int = 0x800; +pub const MAP_ANONYMOUS: ::c_int = 0x800; +pub const MAP_GROWSDOWN: ::c_int = 0x1000; +pub const MAP_DENYWRITE: ::c_int = 0x2000; +pub const MAP_EXECUTABLE: ::c_int = 0x4000; +pub const MAP_LOCKED: ::c_int = 0x8000; +pub const MAP_POPULATE: ::c_int = 0x10000; +pub const MAP_NONBLOCK: ::c_int = 0x20000; +pub const MAP_STACK: ::c_int = 0x40000; + +pub const SOCK_STREAM: ::c_int = 2; +pub const SOCK_DGRAM: ::c_int = 1; + +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_STYLE: ::c_int = SO_TYPE; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ACCEPTCONN: ::c_int = 0x1009; +pub const SO_PROTOCOL: ::c_int = 0x1028; +pub const SO_DOMAIN: ::c_int = 0x1029; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PASSCRED: ::c_int = 17; +pub const SO_PEERCRED: ::c_int = 18; +pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: ::c_int = 28; +pub const SO_PEERSEC: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 31; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PASSSEC: ::c_int = 34; +pub const SO_TIMESTAMPNS: ::c_int = 35; +pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; + +pub const SO_WIFI_STATUS: ::c_int = 41; +pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; +pub const SO_NOFCS: ::c_int = 43; +pub const SO_LOCK_FILTER: ::c_int = 44; +pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; +pub const SO_MAX_PACING_RATE: ::c_int = 47; +pub const SO_BPF_EXTENSIONS: ::c_int = 48; +pub const SO_INCOMING_CPU: ::c_int = 49; +pub const SO_ATTACH_BPF: ::c_int = 50; +pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER; + +pub const FIOCLEX: ::c_ulong = 0x6601; +pub const FIONCLEX: ::c_ulong = 0x6602; +pub const FIONBIO: ::c_ulong = 0x667e; + +pub const SA_SIGINFO: ::c_int = 0x00000008; +pub const SA_NOCLDWAIT: ::c_int = 0x00010000; + +pub const SIGCHLD: ::c_int = 18; +pub const SIGBUS: ::c_int = 10; +pub const SIGTTIN: ::c_int = 26; +pub const SIGTTOU: ::c_int = 27; +pub const SIGXCPU: ::c_int = 30; +pub const SIGXFSZ: ::c_int = 31; +pub const SIGVTALRM: ::c_int = 28; +pub const SIGPROF: ::c_int = 29; +pub const SIGWINCH: ::c_int = 20; +pub const SIGUSR1: ::c_int = 16; +pub const SIGUSR2: ::c_int = 17; +pub const SIGCONT: ::c_int = 25; +pub const SIGSTOP: ::c_int = 23; +pub const SIGTSTP: ::c_int = 24; +pub const SIGURG: ::c_int = 21; +pub const SIGIO: ::c_int = 22; +pub const SIGSYS: ::c_int = 12; +pub const SIGPOLL: ::c_int = 22; +pub const SIGPWR: ::c_int = 19; +pub const SIG_SETMASK: ::c_int = 3; +pub const SIG_BLOCK: ::c_int = 0x1; +pub const SIG_UNBLOCK: ::c_int = 0x2; + +pub const POLLWRNORM: ::c_short = 0x004; +pub const POLLWRBAND: ::c_short = 0x100; + +pub const VEOF: usize = 16; +pub const VEOL: usize = 17; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: ::tcflag_t = 0x00000100; +pub const TOSTOP: ::tcflag_t = 0x00008000; +pub const FLUSHO: ::tcflag_t = 0x00002000; +pub const EXTPROC: ::tcflag_t = 0o200000; +pub const TCSANOW: ::c_int = 0x540e; +pub const TCSADRAIN: ::c_int = 0x540f; +pub const TCSAFLUSH: ::c_int = 0x5410; + +pub const PTRACE_GETFPXREGS: ::c_uint = 18; +pub const PTRACE_SETFPXREGS: ::c_uint = 19; + +pub const MAP_HUGETLB: ::c_int = 0x080000; + +pub const EFD_NONBLOCK: ::c_int = 0x80; + +pub const F_GETLK: ::c_int = 14; +pub const F_GETOWN: ::c_int = 23; +pub const F_SETOWN: ::c_int = 24; + +pub const SFD_NONBLOCK: ::c_int = 0x80; + +pub const TCGETS: ::c_ulong = 0x540d; +pub const TCSETS: ::c_ulong = 0x540e; +pub const TCSETSW: ::c_ulong = 0x540f; +pub const TCSETSF: ::c_ulong = 0x5410; +pub const TCGETA: ::c_ulong = 0x5401; +pub const TCSETA: ::c_ulong = 0x5402; +pub const TCSETAW: ::c_ulong = 0x5403; +pub const TCSETAF: ::c_ulong = 0x5404; +pub const TCSBRK: ::c_ulong = 0x5405; +pub const TCXONC: ::c_ulong = 0x5406; +pub const TCFLSH: ::c_ulong = 0x5407; +pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; +pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; +pub const TIOCINQ: ::c_ulong = 0x467f; +pub const TIOCLINUX: ::c_ulong = 0x5483; +pub const TIOCGSERIAL: ::c_ulong = 0x5484; +pub const TIOCEXCL: ::c_ulong = 0x740d; +pub const TIOCNXCL: ::c_ulong = 0x740e; +pub const TIOCSCTTY: ::c_ulong = 0x5480; +pub const TIOCGPGRP: ::c_ulong = 0x40047477; +pub const TIOCSPGRP: ::c_ulong = 0x80047476; +pub const TIOCOUTQ: ::c_ulong = 0x7472; +pub const TIOCSTI: ::c_ulong = 0x5472; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const TIOCMGET: ::c_ulong = 0x741d; +pub const TIOCMBIS: ::c_ulong = 0x741b; +pub const TIOCMBIC: ::c_ulong = 0x741c; +pub const TIOCMSET: ::c_ulong = 0x741a; +pub const FIONREAD: ::c_ulong = 0x467f; +pub const TIOCCONS: ::c_ulong = 0x80047478; + +pub const RTLD_DEEPBIND: ::c_int = 0x10; +pub const RTLD_GLOBAL: ::c_int = 0x4; +pub const RTLD_NOLOAD: ::c_int = 0x8; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const BOTHER: ::speed_t = 0o010000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const TIOCM_ST: ::c_int = 0x010; +pub const TIOCM_SR: ::c_int = 0x020; +pub const TIOCM_CTS: ::c_int = 0x040; +pub const TIOCM_CAR: ::c_int = 0x100; +pub const TIOCM_RNG: ::c_int = 0x200; +pub const TIOCM_DSR: ::c_int = 0x400; + +pub const EHWPOISON: ::c_int = 168; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/mod.rs new file mode 100644 index 0000000..cc6b636 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -0,0 +1,271 @@ +//! 32-bit specific definitions for linux-like values + +use pthread_mutex_t; + +pub type c_long = i32; +pub type c_ulong = u32; +pub type clock_t = i32; +pub type time_t = i32; +pub type suseconds_t = i32; +pub type ino_t = u32; +pub type off_t = i32; +pub type blkcnt_t = i32; + +pub type fsblkcnt_t = ::c_ulong; +pub type fsfilcnt_t = ::c_ulong; +pub type rlim_t = c_ulong; +pub type shmatt_t = ::c_ulong; +pub type msgqnum_t = ::c_ulong; +pub type msglen_t = ::c_ulong; +pub type blksize_t = i32; +pub type nlink_t = u32; +pub type __u64 = ::c_ulonglong; +pub type __fsword_t = i32; + +s! { + pub struct stat { + #[cfg(not(target_arch = "mips"))] + pub st_dev: ::dev_t, + #[cfg(target_arch = "mips")] + pub st_dev: ::c_ulong, + + #[cfg(not(target_arch = "mips"))] + __pad1: ::c_short, + #[cfg(target_arch = "mips")] + st_pad1: [::c_long; 3], + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + #[cfg(not(target_arch = "mips"))] + pub st_rdev: ::dev_t, + #[cfg(target_arch = "mips")] + pub st_rdev: ::c_ulong, + #[cfg(not(target_arch = "mips"))] + __pad2: ::c_short, + #[cfg(target_arch = "mips")] + st_pad2: [::c_long; 2], + pub st_size: ::off_t, + #[cfg(target_arch = "mips")] + st_pad3: ::c_long, + #[cfg(not(target_arch = "mips"))] + pub st_blksize: ::blksize_t, + #[cfg(not(target_arch = "mips"))] + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + #[cfg(not(target_arch = "mips"))] + __unused4: ::c_long, + #[cfg(not(target_arch = "mips"))] + __unused5: ::c_long, + #[cfg(target_arch = "mips")] + pub st_blksize: ::blksize_t, + #[cfg(target_arch = "mips")] + pub st_blocks: ::blkcnt_t, + #[cfg(target_arch = "mips")] + st_pad5: [::c_long; 14], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct pthread_attr_t { + __size: [u32; 9] + } + + pub struct sigset_t { + __val: [::c_ulong; 32], + } + + pub struct sysinfo { + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + #[deprecated( + since = "0.2.58", + note = "This padding field might become private in the future" + )] + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 8], + } +} + +pub const O_NOATIME: ::c_int = 0o1000000; +pub const O_PATH: ::c_int = 0o10000000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; + +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_MARK: ::c_int = 36; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_BUSY_POLL: ::c_int = 46; + +pub const SA_ONSTACK: ::c_int = 0x08000000; + +pub const PTRACE_DETACH: ::c_uint = 17; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; + +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + +pub const SFD_CLOEXEC: ::c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: ::c_int = 512; + +pub const O_CLOEXEC: ::c_int = 0x80000; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + +align_const! { + #[cfg(target_endian = "little")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; +} + +pub const PTRACE_GETFPREGS: ::c_uint = 14; +pub const PTRACE_SETFPREGS: ::c_uint = 15; +pub const PTRACE_GETREGS: ::c_uint = 12; +pub const PTRACE_SETREGS: ::c_uint = 13; + +#[link(name = "util")] +extern "C" { + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "mips")] { + mod mips; + pub use self::mips::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(target_arch = "sparc")] { + mod sparc; + pub use self::sparc::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/powerpc.rs new file mode 100644 index 0000000..7644428 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -0,0 +1,873 @@ +pub type c_char = u8; +pub type wchar_t = i32; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + f_spare: [::__fsword_t; 5], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct ipc_perm { + __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + __seq: u32, + __pad1: u32, + __glibc_reserved1: u64, + __glibc_reserved2: u64, + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_ushort, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __glibc_reserved4: ::c_ulong, + __glibc_reserved5: ::c_ulong, + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + __glibc_reserved1: ::c_uint, + pub shm_atime: ::time_t, + __glibc_reserved2: ::c_uint, + pub shm_dtime: ::time_t, + __glibc_reserved3: ::c_uint, + pub shm_ctime: ::time_t, + __glibc_reserved4: ::c_uint, + pub shm_segsz: ::size_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __glibc_reserved5: ::c_ulong, + __glibc_reserved6: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + __glibc_reserved1: ::c_uint, + pub msg_stime: ::time_t, + __glibc_reserved2: ::c_uint, + pub msg_rtime: ::time_t, + __glibc_reserved3: ::c_uint, + pub msg_ctime: ::time_t, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved4: ::c_ulong, + __glibc_reserved5: ::c_ulong, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } +} + +pub const RLIM_INFINITY: ::rlim_t = !0; +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const O_DIRECT: ::c_int = 0x20000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_LARGEFILE: ::c_int = 0o200000; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 0x101000; +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_NDELAY: ::c_int = 0x800; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCLINUX: ::c_ulong = 0x541C; +pub const TIOCGSERIAL: ::c_ulong = 0x541E; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_LOCKED: ::c_int = 0x00080; +pub const MAP_NORESERVE: ::c_int = 0x00040; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const EDEADLOCK: ::c_int = 58; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_LINGER: ::c_int = 13; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_RCVLOWAT: ::c_int = 16; +pub const SO_SNDLOWAT: ::c_int = 17; +pub const SO_RCVTIMEO: ::c_int = 18; +pub const SO_SNDTIMEO: ::c_int = 19; +pub const SO_PASSCRED: ::c_int = 20; +pub const SO_PEERCRED: ::c_int = 21; + +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const FIOCLEX: ::c_ulong = 0x20006601; +pub const FIONCLEX: ::c_ulong = 0x20006602; +pub const FIONBIO: ::c_ulong = 0x8004667e; + +pub const MCL_CURRENT: ::c_int = 0x2000; +pub const MCL_FUTURE: ::c_int = 0x4000; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +pub const EFD_NONBLOCK: ::c_int = 0x800; +pub const SFD_NONBLOCK: ::c_int = 0x0800; + +pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; +pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; +pub const TIOCEXCL: ::c_ulong = 0x540C; +pub const TIOCNXCL: ::c_ulong = 0x540D; +pub const TIOCSCTTY: ::c_ulong = 0x540E; +pub const TIOCSTI: ::c_ulong = 0x5412; +pub const TIOCMGET: ::c_ulong = 0x5415; +pub const TIOCMBIS: ::c_ulong = 0x5416; +pub const TIOCMBIC: ::c_ulong = 0x5417; +pub const TIOCMSET: ::c_ulong = 0x5418; +pub const TIOCCONS: ::c_ulong = 0x541D; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = 31; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGSTKSZ: ::size_t = 0x4000; +pub const MINSIGSTKSZ: ::size_t = 4096; +pub const CBAUD: ::tcflag_t = 0xff; +pub const TAB1: ::tcflag_t = 0x400; +pub const TAB2: ::tcflag_t = 0x800; +pub const TAB3: ::tcflag_t = 0xc00; +pub const CR1: ::tcflag_t = 0x1000; +pub const CR2: ::tcflag_t = 0x2000; +pub const CR3: ::tcflag_t = 0x3000; +pub const FF1: ::tcflag_t = 0x4000; +pub const BS1: ::tcflag_t = 0x8000; +pub const VT1: ::tcflag_t = 0x10000; +pub const VWERASE: usize = 0xa; +pub const VREPRINT: usize = 0xb; +pub const VSUSP: usize = 0xc; +pub const VSTART: usize = 0xd; +pub const VSTOP: usize = 0xe; +pub const VDISCARD: usize = 0x10; +pub const VTIME: usize = 0x7; +pub const IXON: ::tcflag_t = 0x200; +pub const IXOFF: ::tcflag_t = 0x400; +pub const ONLCR: ::tcflag_t = 0x2; +pub const CSIZE: ::tcflag_t = 0x300; +pub const CS6: ::tcflag_t = 0x100; +pub const CS7: ::tcflag_t = 0x200; +pub const CS8: ::tcflag_t = 0x300; +pub const CSTOPB: ::tcflag_t = 0x400; +pub const CREAD: ::tcflag_t = 0x800; +pub const PARENB: ::tcflag_t = 0x1000; +pub const PARODD: ::tcflag_t = 0x2000; +pub const HUPCL: ::tcflag_t = 0x4000; +pub const CLOCAL: ::tcflag_t = 0x8000; +pub const ECHOKE: ::tcflag_t = 0x1; +pub const ECHOE: ::tcflag_t = 0x2; +pub const ECHOK: ::tcflag_t = 0x4; +pub const ECHONL: ::tcflag_t = 0x10; +pub const ECHOPRT: ::tcflag_t = 0x20; +pub const ECHOCTL: ::tcflag_t = 0x40; +pub const ISIG: ::tcflag_t = 0x80; +pub const ICANON: ::tcflag_t = 0x100; +pub const PENDIN: ::tcflag_t = 0x20000000; +pub const NOFLSH: ::tcflag_t = 0x80000000; +pub const VSWTC: usize = 9; +pub const OLCUC: ::tcflag_t = 0o000004; +pub const NLDLY: ::tcflag_t = 0o001400; +pub const CRDLY: ::tcflag_t = 0o030000; +pub const TABDLY: ::tcflag_t = 0o006000; +pub const BSDLY: ::tcflag_t = 0o100000; +pub const FFDLY: ::tcflag_t = 0o040000; +pub const VTDLY: ::tcflag_t = 0o200000; +pub const XTABS: ::tcflag_t = 0o006000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const CBAUDEX: ::speed_t = 0o000020; +pub const B57600: ::speed_t = 0o0020; +pub const B115200: ::speed_t = 0o0021; +pub const B230400: ::speed_t = 0o0022; +pub const B460800: ::speed_t = 0o0023; +pub const B500000: ::speed_t = 0o0024; +pub const B576000: ::speed_t = 0o0025; +pub const B921600: ::speed_t = 0o0026; +pub const B1000000: ::speed_t = 0o0027; +pub const B1152000: ::speed_t = 0o0030; +pub const B1500000: ::speed_t = 0o0031; +pub const B2000000: ::speed_t = 0o0032; +pub const B2500000: ::speed_t = 0o0033; +pub const B3000000: ::speed_t = 0o0034; +pub const B3500000: ::speed_t = 0o0035; +pub const B4000000: ::speed_t = 0o0036; +pub const BOTHER: ::speed_t = 0o0037; + +pub const VEOL: usize = 6; +pub const VEOL2: usize = 8; +pub const VMIN: usize = 5; +pub const IEXTEN: ::tcflag_t = 0x400; +pub const TOSTOP: ::tcflag_t = 0x400000; +pub const FLUSHO: ::tcflag_t = 0x800000; +pub const EXTPROC: ::tcflag_t = 0x10000000; +pub const TCGETS: ::c_ulong = 0x403c7413; +pub const TCSETS: ::c_ulong = 0x803c7414; +pub const TCSETSW: ::c_ulong = 0x803c7415; +pub const TCSETSF: ::c_ulong = 0x803c7416; +pub const TCGETA: ::c_ulong = 0x40147417; +pub const TCSETA: ::c_ulong = 0x80147418; +pub const TCSETAW: ::c_ulong = 0x80147419; +pub const TCSETAF: ::c_ulong = 0x8014741c; +pub const TCSBRK: ::c_ulong = 0x2000741d; +pub const TCXONC: ::c_ulong = 0x2000741e; +pub const TCFLSH: ::c_ulong = 0x2000741f; +pub const TIOCINQ: ::c_ulong = 0x4004667f; +pub const TIOCGPGRP: ::c_ulong = 0x40047477; +pub const TIOCSPGRP: ::c_ulong = 0x80047476; +pub const TIOCOUTQ: ::c_ulong = 0x40047473; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const TIOCGRS485: ::c_int = 0x542e; +pub const TIOCSRS485: ::c_int = 0x542f; +pub const FIONREAD: ::c_ulong = 0x4004667f; + +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_break: ::c_long = 17; +pub const SYS_oldstat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_umount: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_stime: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_oldfstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_stty: ::c_long = 31; +pub const SYS_gtty: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_ftime: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_prof: ::c_long = 44; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_lock: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_mpx: ::c_long = 56; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_ulimit: ::c_long = 58; +pub const SYS_oldolduname: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_oldlstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_readdir: ::c_long = 89; +pub const SYS_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_profil: ::c_long = 98; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_ioperm: ::c_long = 101; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_olduname: ::c_long = 109; +pub const SYS_iopl: ::c_long = 110; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_idle: ::c_long = 112; +pub const SYS_vm86: ::c_long = 113; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_modify_ldt: ::c_long = 123; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_afs_syscall: ::c_long = 137; /* Syscall for Andrew File System */ +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_query_module: ::c_long = 166; +pub const SYS_poll: ::c_long = 167; +pub const SYS_nfsservctl: ::c_long = 168; +pub const SYS_setresgid: ::c_long = 169; +pub const SYS_getresgid: ::c_long = 170; +pub const SYS_prctl: ::c_long = 171; +pub const SYS_rt_sigreturn: ::c_long = 172; +pub const SYS_rt_sigaction: ::c_long = 173; +pub const SYS_rt_sigprocmask: ::c_long = 174; +pub const SYS_rt_sigpending: ::c_long = 175; +pub const SYS_rt_sigtimedwait: ::c_long = 176; +pub const SYS_rt_sigqueueinfo: ::c_long = 177; +pub const SYS_rt_sigsuspend: ::c_long = 178; +pub const SYS_pread64: ::c_long = 179; +pub const SYS_pwrite64: ::c_long = 180; +pub const SYS_chown: ::c_long = 181; +pub const SYS_getcwd: ::c_long = 182; +pub const SYS_capget: ::c_long = 183; +pub const SYS_capset: ::c_long = 184; +pub const SYS_sigaltstack: ::c_long = 185; +pub const SYS_sendfile: ::c_long = 186; +pub const SYS_getpmsg: ::c_long = 187; /* some people actually want streams */ +pub const SYS_putpmsg: ::c_long = 188; /* some people actually want streams */ +pub const SYS_vfork: ::c_long = 189; +pub const SYS_ugetrlimit: ::c_long = 190; /* SuS compliant getrlimit */ +pub const SYS_readahead: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_pciconfig_read: ::c_long = 198; +pub const SYS_pciconfig_write: ::c_long = 199; +pub const SYS_pciconfig_iobase: ::c_long = 200; +pub const SYS_multiplexer: ::c_long = 201; +pub const SYS_getdents64: ::c_long = 202; +pub const SYS_pivot_root: ::c_long = 203; +pub const SYS_fcntl64: ::c_long = 204; +pub const SYS_madvise: ::c_long = 205; +pub const SYS_mincore: ::c_long = 206; +pub const SYS_gettid: ::c_long = 207; +pub const SYS_tkill: ::c_long = 208; +pub const SYS_setxattr: ::c_long = 209; +pub const SYS_lsetxattr: ::c_long = 210; +pub const SYS_fsetxattr: ::c_long = 211; +pub const SYS_getxattr: ::c_long = 212; +pub const SYS_lgetxattr: ::c_long = 213; +pub const SYS_fgetxattr: ::c_long = 214; +pub const SYS_listxattr: ::c_long = 215; +pub const SYS_llistxattr: ::c_long = 216; +pub const SYS_flistxattr: ::c_long = 217; +pub const SYS_removexattr: ::c_long = 218; +pub const SYS_lremovexattr: ::c_long = 219; +pub const SYS_fremovexattr: ::c_long = 220; +pub const SYS_futex: ::c_long = 221; +pub const SYS_sched_setaffinity: ::c_long = 222; +pub const SYS_sched_getaffinity: ::c_long = 223; +pub const SYS_tuxcall: ::c_long = 225; +pub const SYS_sendfile64: ::c_long = 226; +pub const SYS_io_setup: ::c_long = 227; +pub const SYS_io_destroy: ::c_long = 228; +pub const SYS_io_getevents: ::c_long = 229; +pub const SYS_io_submit: ::c_long = 230; +pub const SYS_io_cancel: ::c_long = 231; +pub const SYS_set_tid_address: ::c_long = 232; +pub const SYS_fadvise64: ::c_long = 233; +pub const SYS_exit_group: ::c_long = 234; +pub const SYS_lookup_dcookie: ::c_long = 235; +pub const SYS_epoll_create: ::c_long = 236; +pub const SYS_epoll_ctl: ::c_long = 237; +pub const SYS_epoll_wait: ::c_long = 238; +pub const SYS_remap_file_pages: ::c_long = 239; +pub const SYS_timer_create: ::c_long = 240; +pub const SYS_timer_settime: ::c_long = 241; +pub const SYS_timer_gettime: ::c_long = 242; +pub const SYS_timer_getoverrun: ::c_long = 243; +pub const SYS_timer_delete: ::c_long = 244; +pub const SYS_clock_settime: ::c_long = 245; +pub const SYS_clock_gettime: ::c_long = 246; +pub const SYS_clock_getres: ::c_long = 247; +pub const SYS_clock_nanosleep: ::c_long = 248; +pub const SYS_swapcontext: ::c_long = 249; +pub const SYS_tgkill: ::c_long = 250; +pub const SYS_utimes: ::c_long = 251; +pub const SYS_statfs64: ::c_long = 252; +pub const SYS_fstatfs64: ::c_long = 253; +pub const SYS_fadvise64_64: ::c_long = 254; +pub const SYS_rtas: ::c_long = 255; +pub const SYS_sys_debug_setcontext: ::c_long = 256; +pub const SYS_migrate_pages: ::c_long = 258; +pub const SYS_mbind: ::c_long = 259; +pub const SYS_get_mempolicy: ::c_long = 260; +pub const SYS_set_mempolicy: ::c_long = 261; +pub const SYS_mq_open: ::c_long = 262; +pub const SYS_mq_unlink: ::c_long = 263; +pub const SYS_mq_timedsend: ::c_long = 264; +pub const SYS_mq_timedreceive: ::c_long = 265; +pub const SYS_mq_notify: ::c_long = 266; +pub const SYS_mq_getsetattr: ::c_long = 267; +pub const SYS_kexec_load: ::c_long = 268; +pub const SYS_add_key: ::c_long = 269; +pub const SYS_request_key: ::c_long = 270; +pub const SYS_keyctl: ::c_long = 271; +pub const SYS_waitid: ::c_long = 272; +pub const SYS_ioprio_set: ::c_long = 273; +pub const SYS_ioprio_get: ::c_long = 274; +pub const SYS_inotify_init: ::c_long = 275; +pub const SYS_inotify_add_watch: ::c_long = 276; +pub const SYS_inotify_rm_watch: ::c_long = 277; +pub const SYS_spu_run: ::c_long = 278; +pub const SYS_spu_create: ::c_long = 279; +pub const SYS_pselect6: ::c_long = 280; +pub const SYS_ppoll: ::c_long = 281; +pub const SYS_unshare: ::c_long = 282; +pub const SYS_splice: ::c_long = 283; +pub const SYS_tee: ::c_long = 284; +pub const SYS_vmsplice: ::c_long = 285; +pub const SYS_openat: ::c_long = 286; +pub const SYS_mkdirat: ::c_long = 287; +pub const SYS_mknodat: ::c_long = 288; +pub const SYS_fchownat: ::c_long = 289; +pub const SYS_futimesat: ::c_long = 290; +pub const SYS_fstatat64: ::c_long = 291; +pub const SYS_unlinkat: ::c_long = 292; +pub const SYS_renameat: ::c_long = 293; +pub const SYS_linkat: ::c_long = 294; +pub const SYS_symlinkat: ::c_long = 295; +pub const SYS_readlinkat: ::c_long = 296; +pub const SYS_fchmodat: ::c_long = 297; +pub const SYS_faccessat: ::c_long = 298; +pub const SYS_get_robust_list: ::c_long = 299; +pub const SYS_set_robust_list: ::c_long = 300; +pub const SYS_move_pages: ::c_long = 301; +pub const SYS_getcpu: ::c_long = 302; +pub const SYS_epoll_pwait: ::c_long = 303; +pub const SYS_utimensat: ::c_long = 304; +pub const SYS_signalfd: ::c_long = 305; +pub const SYS_timerfd_create: ::c_long = 306; +pub const SYS_eventfd: ::c_long = 307; +pub const SYS_sync_file_range2: ::c_long = 308; +pub const SYS_fallocate: ::c_long = 309; +pub const SYS_subpage_prot: ::c_long = 310; +pub const SYS_timerfd_settime: ::c_long = 311; +pub const SYS_timerfd_gettime: ::c_long = 312; +pub const SYS_signalfd4: ::c_long = 313; +pub const SYS_eventfd2: ::c_long = 314; +pub const SYS_epoll_create1: ::c_long = 315; +pub const SYS_dup3: ::c_long = 316; +pub const SYS_pipe2: ::c_long = 317; +pub const SYS_inotify_init1: ::c_long = 318; +pub const SYS_perf_event_open: ::c_long = 319; +pub const SYS_preadv: ::c_long = 320; +pub const SYS_pwritev: ::c_long = 321; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 322; +pub const SYS_fanotify_init: ::c_long = 323; +pub const SYS_fanotify_mark: ::c_long = 324; +pub const SYS_prlimit64: ::c_long = 325; +pub const SYS_socket: ::c_long = 326; +pub const SYS_bind: ::c_long = 327; +pub const SYS_connect: ::c_long = 328; +pub const SYS_listen: ::c_long = 329; +pub const SYS_accept: ::c_long = 330; +pub const SYS_getsockname: ::c_long = 331; +pub const SYS_getpeername: ::c_long = 332; +pub const SYS_socketpair: ::c_long = 333; +pub const SYS_send: ::c_long = 334; +pub const SYS_sendto: ::c_long = 335; +pub const SYS_recv: ::c_long = 336; +pub const SYS_recvfrom: ::c_long = 337; +pub const SYS_shutdown: ::c_long = 338; +pub const SYS_setsockopt: ::c_long = 339; +pub const SYS_getsockopt: ::c_long = 340; +pub const SYS_sendmsg: ::c_long = 341; +pub const SYS_recvmsg: ::c_long = 342; +pub const SYS_recvmmsg: ::c_long = 343; +pub const SYS_accept4: ::c_long = 344; +pub const SYS_name_to_handle_at: ::c_long = 345; +pub const SYS_open_by_handle_at: ::c_long = 346; +pub const SYS_clock_adjtime: ::c_long = 347; +pub const SYS_syncfs: ::c_long = 348; +pub const SYS_sendmmsg: ::c_long = 349; +pub const SYS_setns: ::c_long = 350; +pub const SYS_process_vm_readv: ::c_long = 351; +pub const SYS_process_vm_writev: ::c_long = 352; +pub const SYS_finit_module: ::c_long = 353; +pub const SYS_kcmp: ::c_long = 354; +pub const SYS_sched_setattr: ::c_long = 355; +pub const SYS_sched_getattr: ::c_long = 356; +pub const SYS_renameat2: ::c_long = 357; +pub const SYS_seccomp: ::c_long = 358; +pub const SYS_getrandom: ::c_long = 359; +pub const SYS_memfd_create: ::c_long = 360; +pub const SYS_bpf: ::c_long = 361; +pub const SYS_execveat: ::c_long = 362; +pub const SYS_switch_endian: ::c_long = 363; +pub const SYS_userfaultfd: ::c_long = 364; +pub const SYS_membarrier: ::c_long = 365; +pub const SYS_mlock2: ::c_long = 378; +pub const SYS_copy_file_range: ::c_long = 379; +pub const SYS_preadv2: ::c_long = 380; +pub const SYS_pwritev2: ::c_long = 381; +pub const SYS_kexec_file_load: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/sparc/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/sparc/align.rs new file mode 100644 index 0000000..98fda88 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/sparc/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 3] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs new file mode 100644 index 0000000..f670b34 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -0,0 +1,978 @@ +//! SPARC-specific definitions for 32-bit linux-like values + +pub type c_char = u8; +pub type wchar_t = i32; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + f_spare: [::__fsword_t; 5], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + __reserved: ::c_short, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_ushort, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 2], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_ushort, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __reserved: [::c_long; 2], + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + __pad1: ::c_ushort, + pub mode: ::c_ushort, + __pad2: ::c_ushort, + pub __seq: ::c_ushort, + __unused1: ::c_ulonglong, + __unused2: ::c_ulonglong, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + __pad1: ::c_uint, + pub shm_atime: ::time_t, + __pad2: ::c_uint, + pub shm_dtime: ::time_t, + __pad3: ::c_uint, + pub shm_ctime: ::time_t, + pub shm_segsz: ::size_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __reserved1: ::c_ulong, + __reserved2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + __pad1: ::c_uint, + pub msg_stime: ::time_t, + __pad2: ::c_uint, + pub msg_rtime: ::time_t, + __pad3: ::c_uint, + pub msg_ctime: ::time_t, + __msg_cbytes: ::c_ushort, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved1: ::c_ulong, + __glibc_reserved2: ::c_ulong, + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const RLIM_INFINITY: ::rlim_t = !0; +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; + +pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464; +pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465; + +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 6; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 7; + +pub const O_APPEND: ::c_int = 0x8; +pub const O_CREAT: ::c_int = 0x200; +pub const O_EXCL: ::c_int = 0x800; +pub const O_NOCTTY: ::c_int = 0x8000; +pub const O_NONBLOCK: ::c_int = 0x4000; +pub const O_SYNC: ::c_int = 0x802000; +pub const O_RSYNC: ::c_int = 0x802000; +pub const O_DSYNC: ::c_int = 0x2000; +pub const O_FSYNC: ::c_int = 0x802000; +pub const O_NOATIME: ::c_int = 0x200000; +pub const O_PATH: ::c_int = 0x1000000; +pub const O_TMPFILE: ::c_int = 0x2000000 | O_DIRECTORY; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_GROWSDOWN: ::c_int = 0x0200; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const EDEADLK: ::c_int = 78; +pub const ENAMETOOLONG: ::c_int = 63; +pub const ENOLCK: ::c_int = 79; +pub const ENOSYS: ::c_int = 90; +pub const ENOTEMPTY: ::c_int = 66; +pub const ELOOP: ::c_int = 62; +pub const ENOMSG: ::c_int = 75; +pub const EIDRM: ::c_int = 77; +pub const ECHRNG: ::c_int = 94; +pub const EL2NSYNC: ::c_int = 95; +pub const EL3HLT: ::c_int = 96; +pub const EL3RST: ::c_int = 97; +pub const ELNRNG: ::c_int = 98; +pub const EUNATCH: ::c_int = 99; +pub const ENOCSI: ::c_int = 100; +pub const EL2HLT: ::c_int = 101; +pub const EBADE: ::c_int = 102; +pub const EBADR: ::c_int = 103; +pub const EXFULL: ::c_int = 104; +pub const ENOANO: ::c_int = 105; +pub const EBADRQC: ::c_int = 106; +pub const EBADSLT: ::c_int = 107; +pub const EMULTIHOP: ::c_int = 87; +pub const EOVERFLOW: ::c_int = 92; +pub const ENOTUNIQ: ::c_int = 115; +pub const EBADFD: ::c_int = 93; +pub const EBADMSG: ::c_int = 76; +pub const EREMCHG: ::c_int = 89; +pub const ELIBACC: ::c_int = 114; +pub const ELIBBAD: ::c_int = 112; +pub const ELIBSCN: ::c_int = 124; +pub const ELIBMAX: ::c_int = 123; +pub const ELIBEXEC: ::c_int = 110; +pub const EILSEQ: ::c_int = 122; +pub const ERESTART: ::c_int = 116; +pub const ESTRPIPE: ::c_int = 91; +pub const EUSERS: ::c_int = 68; +pub const ENOTSOCK: ::c_int = 38; +pub const EDESTADDRREQ: ::c_int = 39; +pub const EMSGSIZE: ::c_int = 40; +pub const EPROTOTYPE: ::c_int = 41; +pub const ENOPROTOOPT: ::c_int = 42; +pub const EPROTONOSUPPORT: ::c_int = 43; +pub const ESOCKTNOSUPPORT: ::c_int = 44; +pub const EOPNOTSUPP: ::c_int = 45; +pub const EPFNOSUPPORT: ::c_int = 46; +pub const EAFNOSUPPORT: ::c_int = 47; +pub const EADDRINUSE: ::c_int = 48; +pub const EADDRNOTAVAIL: ::c_int = 49; +pub const ENETDOWN: ::c_int = 50; +pub const ENETUNREACH: ::c_int = 51; +pub const ENETRESET: ::c_int = 52; +pub const ECONNABORTED: ::c_int = 53; +pub const ECONNRESET: ::c_int = 54; +pub const ENOBUFS: ::c_int = 55; +pub const EISCONN: ::c_int = 56; +pub const ENOTCONN: ::c_int = 57; +pub const ESHUTDOWN: ::c_int = 58; +pub const ETOOMANYREFS: ::c_int = 59; +pub const ETIMEDOUT: ::c_int = 60; +pub const ECONNREFUSED: ::c_int = 61; +pub const EHOSTDOWN: ::c_int = 64; +pub const EHOSTUNREACH: ::c_int = 65; +pub const EALREADY: ::c_int = 37; +pub const EINPROGRESS: ::c_int = 36; +pub const ESTALE: ::c_int = 70; +pub const EDQUOT: ::c_int = 69; +pub const ENOMEDIUM: ::c_int = 125; +pub const EMEDIUMTYPE: ::c_int = 126; +pub const ECANCELED: ::c_int = 127; +pub const ENOKEY: ::c_int = 128; +pub const EKEYEXPIRED: ::c_int = 129; +pub const EKEYREVOKED: ::c_int = 130; +pub const EKEYREJECTED: ::c_int = 131; +pub const EOWNERDEAD: ::c_int = 132; +pub const ENOTRECOVERABLE: ::c_int = 133; +pub const EHWPOISON: ::c_int = 135; +pub const ERFKILL: ::c_int = 134; + +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_PASSCRED: ::c_int = 2; +pub const SO_REUSEADDR: ::c_int = 4; +pub const SO_BINDTODEVICE: ::c_int = 0x000d; +pub const SO_TIMESTAMP: ::c_int = 0x001d; +pub const SO_MARK: ::c_int = 0x0022; +pub const SO_RXQ_OVFL: ::c_int = 0x0024; +pub const SO_PEEK_OFF: ::c_int = 0x0026; +pub const SO_BUSY_POLL: ::c_int = 0x0030; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_DONTROUTE: ::c_int = 16; +pub const SO_BROADCAST: ::c_int = 32; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDBUFFORCE: ::c_int = 0x100a; +pub const SO_RCVBUFFORCE: ::c_int = 0x100b; +pub const SO_DOMAIN: ::c_int = 0x1029; +pub const SO_KEEPALIVE: ::c_int = 8; +pub const SO_OOBINLINE: ::c_int = 0x100; +pub const SO_LINGER: ::c_int = 128; +pub const SO_REUSEPORT: ::c_int = 0x200; +pub const SO_ACCEPTCONN: ::c_int = 0x8000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const SA_ONSTACK: ::c_int = 1; +pub const SA_SIGINFO: ::c_int = 0x200; +pub const SA_NOCLDWAIT: ::c_int = 0x100; + +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGCHLD: ::c_int = 20; +pub const SIGBUS: ::c_int = 10; +pub const SIGUSR1: ::c_int = 30; +pub const SIGUSR2: ::c_int = 31; +pub const SIGCONT: ::c_int = 19; +pub const SIGSTOP: ::c_int = 17; +pub const SIGTSTP: ::c_int = 18; +pub const SIGURG: ::c_int = 16; +pub const SIGIO: ::c_int = 23; +pub const SIGSYS: ::c_int = 12; +pub const SIGPOLL: ::c_int = 23; +pub const SIGPWR: ::c_int = 29; +pub const SIG_SETMASK: ::c_int = 4; +pub const SIG_BLOCK: ::c_int = 1; +pub const SIG_UNBLOCK: ::c_int = 2; + +pub const POLLWRNORM: ::c_short = 4; +pub const POLLWRBAND: ::c_short = 0x100; + +pub const O_ASYNC: ::c_int = 0x40; +pub const O_NDELAY: ::c_int = 0x4004; + +pub const PTRACE_DETACH: ::c_uint = 11; + +pub const EFD_NONBLOCK: ::c_int = 0x4000; + +pub const F_GETLK: ::c_int = 7; +pub const F_GETOWN: ::c_int = 5; +pub const F_SETOWN: ::c_int = 6; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; + +pub const F_RDLCK: ::c_int = 1; +pub const F_WRLCK: ::c_int = 2; +pub const F_UNLCK: ::c_int = 3; + +pub const SFD_NONBLOCK: ::c_int = 0x4000; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCLINUX: ::c_ulong = 0x541C; +pub const TIOCGSERIAL: ::c_ulong = 0x541E; +pub const TIOCEXCL: ::c_ulong = 0x2000740d; +pub const TIOCNXCL: ::c_ulong = 0x2000740e; +pub const TIOCSCTTY: ::c_ulong = 0x20007484; +pub const TIOCSTI: ::c_ulong = 0x80017472; +pub const TIOCMGET: ::c_ulong = 0x4004746a; +pub const TIOCMBIS: ::c_ulong = 0x8004746c; +pub const TIOCMBIC: ::c_ulong = 0x8004746b; +pub const TIOCMSET: ::c_ulong = 0x8004746d; +pub const TIOCCONS: ::c_ulong = 0x20007424; + +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const SFD_CLOEXEC: ::c_int = 0x400000; + +pub const NCCS: usize = 17; +pub const O_TRUNC: ::c_int = 0x400; + +pub const O_CLOEXEC: ::c_int = 0x400000; + +pub const EBFONT: ::c_int = 109; +pub const ENOSTR: ::c_int = 72; +pub const ENODATA: ::c_int = 111; +pub const ETIME: ::c_int = 73; +pub const ENOSR: ::c_int = 74; +pub const ENONET: ::c_int = 80; +pub const ENOPKG: ::c_int = 113; +pub const EREMOTE: ::c_int = 71; +pub const ENOLINK: ::c_int = 82; +pub const EADV: ::c_int = 83; +pub const ESRMNT: ::c_int = 84; +pub const ECOMM: ::c_int = 85; +pub const EPROTO: ::c_int = 86; +pub const EDOTDOT: ::c_int = 88; + +pub const SA_NODEFER: ::c_int = 0x20; +pub const SA_RESETHAND: ::c_int = 0x4; +pub const SA_RESTART: ::c_int = 0x2; +pub const SA_NOCLDSTOP: ::c_int = 0x00000008; + +pub const EPOLL_CLOEXEC: ::c_int = 0x400000; + +pub const EFD_CLOEXEC: ::c_int = 0x400000; + +pub const O_DIRECTORY: ::c_int = 0o200000; +pub const O_NOFOLLOW: ::c_int = 0o400000; +pub const O_LARGEFILE: ::c_int = 0x40000; +pub const O_DIRECT: ::c_int = 0x100000; + +pub const MAP_LOCKED: ::c_int = 0x0100; +pub const MAP_NORESERVE: ::c_int = 0x00040; + +pub const EDEADLOCK: ::c_int = 108; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; + +pub const SO_PEERCRED: ::c_int = 0x40; +pub const SO_RCVLOWAT: ::c_int = 0x800; +pub const SO_SNDLOWAT: ::c_int = 0x1000; +pub const SO_RCVTIMEO: ::c_int = 0x2000; +pub const SO_SNDTIMEO: ::c_int = 0x4000; + +pub const FIOCLEX: ::c_ulong = 0x20006601; +pub const FIONCLEX: ::c_ulong = 0x20006602; +pub const FIONBIO: ::c_ulong = 0x8004667e; + +pub const MCL_CURRENT: ::c_int = 0x2000; +pub const MCL_FUTURE: ::c_int = 0x4000; + +pub const SIGSTKSZ: ::size_t = 16384; +pub const MINSIGSTKSZ: ::size_t = 4096; +pub const CBAUD: ::tcflag_t = 0x0000100f; +pub const TAB1: ::tcflag_t = 0x800; +pub const TAB2: ::tcflag_t = 0x1000; +pub const TAB3: ::tcflag_t = 0x1800; +pub const CR1: ::tcflag_t = 0x200; +pub const CR2: ::tcflag_t = 0x400; +pub const CR3: ::tcflag_t = 0x600; +pub const FF1: ::tcflag_t = 0x8000; +pub const BS1: ::tcflag_t = 0x2000; +pub const VT1: ::tcflag_t = 0x4000; +pub const VWERASE: usize = 0xe; +pub const VREPRINT: usize = 0xc; +pub const VSUSP: usize = 0xa; +pub const VSTART: usize = 0x8; +pub const VSTOP: usize = 0x9; +pub const VDISCARD: usize = 0xd; +pub const VTIME: usize = 0x5; +pub const IXON: ::tcflag_t = 0x400; +pub const IXOFF: ::tcflag_t = 0x1000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x30; +pub const CS6: ::tcflag_t = 0x10; +pub const CS7: ::tcflag_t = 0x20; +pub const CS8: ::tcflag_t = 0x30; +pub const CSTOPB: ::tcflag_t = 0x40; +pub const CREAD: ::tcflag_t = 0x80; +pub const PARENB: ::tcflag_t = 0x100; +pub const PARODD: ::tcflag_t = 0x200; +pub const HUPCL: ::tcflag_t = 0x400; +pub const CLOCAL: ::tcflag_t = 0x800; +pub const ECHOKE: ::tcflag_t = 0x800; +pub const ECHOE: ::tcflag_t = 0x10; +pub const ECHOK: ::tcflag_t = 0x20; +pub const ECHONL: ::tcflag_t = 0x40; +pub const ECHOPRT: ::tcflag_t = 0x400; +pub const ECHOCTL: ::tcflag_t = 0x200; +pub const ISIG: ::tcflag_t = 0x1; +pub const ICANON: ::tcflag_t = 0x2; +pub const PENDIN: ::tcflag_t = 0x4000; +pub const NOFLSH: ::tcflag_t = 0x80; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0x00001000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const BOTHER: ::speed_t = 0x1000; +pub const B57600: ::speed_t = 0x1001; +pub const B115200: ::speed_t = 0x1002; +pub const B230400: ::speed_t = 0x1003; +pub const B460800: ::speed_t = 0x1004; +pub const B76800: ::speed_t = 0x1005; +pub const B153600: ::speed_t = 0x1006; +pub const B307200: ::speed_t = 0x1007; +pub const B614400: ::speed_t = 0x1008; +pub const B921600: ::speed_t = 0x1009; +pub const B500000: ::speed_t = 0x100a; +pub const B576000: ::speed_t = 0x100b; +pub const B1000000: ::speed_t = 0x100c; +pub const B1152000: ::speed_t = 0x100d; +pub const B1500000: ::speed_t = 0x100e; +pub const B2000000: ::speed_t = 0x100f; + +pub const VEOL: usize = 5; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: ::tcflag_t = 0x8000; +pub const TOSTOP: ::tcflag_t = 0x100; +pub const FLUSHO: ::tcflag_t = 0x1000; +pub const EXTPROC: ::tcflag_t = 0x10000; +pub const TCGETS: ::c_ulong = 0x40245408; +pub const TCSETS: ::c_ulong = 0x80245409; +pub const TCSETSW: ::c_ulong = 0x8024540a; +pub const TCSETSF: ::c_ulong = 0x8024540b; +pub const TCGETA: ::c_ulong = 0x40125401; +pub const TCSETA: ::c_ulong = 0x80125402; +pub const TCSETAW: ::c_ulong = 0x80125403; +pub const TCSETAF: ::c_ulong = 0x80125404; +pub const TCSBRK: ::c_ulong = 0x20005405; +pub const TCXONC: ::c_ulong = 0x20005406; +pub const TCFLSH: ::c_ulong = 0x20005407; +pub const TIOCINQ: ::c_ulong = 0x4004667f; +pub const TIOCGPGRP: ::c_ulong = 0x40047483; +pub const TIOCSPGRP: ::c_ulong = 0x80047482; +pub const TIOCOUTQ: ::c_ulong = 0x40047473; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const FIONREAD: ::c_ulong = 0x4004667f; + +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_wait4: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execv: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_chown: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_brk: ::c_long = 17; +pub const SYS_perfctr: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_capget: ::c_long = 21; +pub const SYS_capset: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_vmsplice: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_sigaltstack: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_lchown32: ::c_long = 31; +pub const SYS_fchown32: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_chown32: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_stat: ::c_long = 38; +pub const SYS_sendfile: ::c_long = 39; +pub const SYS_lstat: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_getuid32: ::c_long = 44; +pub const SYS_umount2: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_getgid32: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_reboot: ::c_long = 55; +pub const SYS_mmap2: ::c_long = 56; +pub const SYS_symlink: ::c_long = 57; +pub const SYS_readlink: ::c_long = 58; +pub const SYS_execve: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_fstat: ::c_long = 62; +pub const SYS_fstat64: ::c_long = 63; +pub const SYS_getpagesize: ::c_long = 64; +pub const SYS_msync: ::c_long = 65; +pub const SYS_vfork: ::c_long = 66; +pub const SYS_pread64: ::c_long = 67; +pub const SYS_pwrite64: ::c_long = 68; +pub const SYS_geteuid32: ::c_long = 69; +pub const SYS_getegid32: ::c_long = 70; +pub const SYS_mmap: ::c_long = 71; +pub const SYS_setreuid32: ::c_long = 72; +pub const SYS_munmap: ::c_long = 73; +pub const SYS_mprotect: ::c_long = 74; +pub const SYS_madvise: ::c_long = 75; +pub const SYS_vhangup: ::c_long = 76; +pub const SYS_truncate64: ::c_long = 77; +pub const SYS_mincore: ::c_long = 78; +pub const SYS_getgroups: ::c_long = 79; +pub const SYS_setgroups: ::c_long = 80; +pub const SYS_getpgrp: ::c_long = 81; +pub const SYS_setgroups32: ::c_long = 82; +pub const SYS_setitimer: ::c_long = 83; +pub const SYS_ftruncate64: ::c_long = 84; +pub const SYS_swapon: ::c_long = 85; +pub const SYS_getitimer: ::c_long = 86; +pub const SYS_setuid32: ::c_long = 87; +pub const SYS_sethostname: ::c_long = 88; +pub const SYS_setgid32: ::c_long = 89; +pub const SYS_dup2: ::c_long = 90; +pub const SYS_setfsuid32: ::c_long = 91; +pub const SYS_fcntl: ::c_long = 92; +pub const SYS_select: ::c_long = 93; +pub const SYS_setfsgid32: ::c_long = 94; +pub const SYS_fsync: ::c_long = 95; +pub const SYS_setpriority: ::c_long = 96; +pub const SYS_socket: ::c_long = 97; +pub const SYS_connect: ::c_long = 98; +pub const SYS_accept: ::c_long = 99; +pub const SYS_getpriority: ::c_long = 100; +pub const SYS_rt_sigreturn: ::c_long = 101; +pub const SYS_rt_sigaction: ::c_long = 102; +pub const SYS_rt_sigprocmask: ::c_long = 103; +pub const SYS_rt_sigpending: ::c_long = 104; +pub const SYS_rt_sigtimedwait: ::c_long = 105; +pub const SYS_rt_sigqueueinfo: ::c_long = 106; +pub const SYS_rt_sigsuspend: ::c_long = 107; +pub const SYS_setresuid32: ::c_long = 108; +pub const SYS_getresuid32: ::c_long = 109; +pub const SYS_setresgid32: ::c_long = 110; +pub const SYS_getresgid32: ::c_long = 111; +pub const SYS_setregid32: ::c_long = 112; +pub const SYS_recvmsg: ::c_long = 113; +pub const SYS_sendmsg: ::c_long = 114; +pub const SYS_getgroups32: ::c_long = 115; +pub const SYS_gettimeofday: ::c_long = 116; +pub const SYS_getrusage: ::c_long = 117; +pub const SYS_getsockopt: ::c_long = 118; +pub const SYS_getcwd: ::c_long = 119; +pub const SYS_readv: ::c_long = 120; +pub const SYS_writev: ::c_long = 121; +pub const SYS_settimeofday: ::c_long = 122; +pub const SYS_fchown: ::c_long = 123; +pub const SYS_fchmod: ::c_long = 124; +pub const SYS_recvfrom: ::c_long = 125; +pub const SYS_setreuid: ::c_long = 126; +pub const SYS_setregid: ::c_long = 127; +pub const SYS_rename: ::c_long = 128; +pub const SYS_truncate: ::c_long = 129; +pub const SYS_ftruncate: ::c_long = 130; +pub const SYS_flock: ::c_long = 131; +pub const SYS_lstat64: ::c_long = 132; +pub const SYS_sendto: ::c_long = 133; +pub const SYS_shutdown: ::c_long = 134; +pub const SYS_socketpair: ::c_long = 135; +pub const SYS_mkdir: ::c_long = 136; +pub const SYS_rmdir: ::c_long = 137; +pub const SYS_utimes: ::c_long = 138; +pub const SYS_stat64: ::c_long = 139; +pub const SYS_sendfile64: ::c_long = 140; +pub const SYS_getpeername: ::c_long = 141; +pub const SYS_futex: ::c_long = 142; +pub const SYS_gettid: ::c_long = 143; +pub const SYS_getrlimit: ::c_long = 144; +pub const SYS_setrlimit: ::c_long = 145; +pub const SYS_pivot_root: ::c_long = 146; +pub const SYS_prctl: ::c_long = 147; +pub const SYS_pciconfig_read: ::c_long = 148; +pub const SYS_pciconfig_write: ::c_long = 149; +pub const SYS_getsockname: ::c_long = 150; +pub const SYS_inotify_init: ::c_long = 151; +pub const SYS_inotify_add_watch: ::c_long = 152; +pub const SYS_poll: ::c_long = 153; +pub const SYS_getdents64: ::c_long = 154; +pub const SYS_fcntl64: ::c_long = 155; +pub const SYS_inotify_rm_watch: ::c_long = 156; +pub const SYS_statfs: ::c_long = 157; +pub const SYS_fstatfs: ::c_long = 158; +pub const SYS_umount: ::c_long = 159; +pub const SYS_sched_set_affinity: ::c_long = 160; +pub const SYS_sched_get_affinity: ::c_long = 161; +pub const SYS_getdomainname: ::c_long = 162; +pub const SYS_setdomainname: ::c_long = 163; +pub const SYS_quotactl: ::c_long = 165; +pub const SYS_set_tid_address: ::c_long = 166; +pub const SYS_mount: ::c_long = 167; +pub const SYS_ustat: ::c_long = 168; +pub const SYS_setxattr: ::c_long = 169; +pub const SYS_lsetxattr: ::c_long = 170; +pub const SYS_fsetxattr: ::c_long = 171; +pub const SYS_getxattr: ::c_long = 172; +pub const SYS_lgetxattr: ::c_long = 173; +pub const SYS_getdents: ::c_long = 174; +pub const SYS_setsid: ::c_long = 175; +pub const SYS_fchdir: ::c_long = 176; +pub const SYS_fgetxattr: ::c_long = 177; +pub const SYS_listxattr: ::c_long = 178; +pub const SYS_llistxattr: ::c_long = 179; +pub const SYS_flistxattr: ::c_long = 180; +pub const SYS_removexattr: ::c_long = 181; +pub const SYS_lremovexattr: ::c_long = 182; +pub const SYS_sigpending: ::c_long = 183; +pub const SYS_query_module: ::c_long = 184; +pub const SYS_setpgid: ::c_long = 185; +pub const SYS_fremovexattr: ::c_long = 186; +pub const SYS_tkill: ::c_long = 187; +pub const SYS_exit_group: ::c_long = 188; +pub const SYS_uname: ::c_long = 189; +pub const SYS_init_module: ::c_long = 190; +pub const SYS_personality: ::c_long = 191; +pub const SYS_remap_file_pages: ::c_long = 192; +pub const SYS_epoll_create: ::c_long = 193; +pub const SYS_epoll_ctl: ::c_long = 194; +pub const SYS_epoll_wait: ::c_long = 195; +pub const SYS_ioprio_set: ::c_long = 196; +pub const SYS_getppid: ::c_long = 197; +pub const SYS_sigaction: ::c_long = 198; +pub const SYS_sgetmask: ::c_long = 199; +pub const SYS_ssetmask: ::c_long = 200; +pub const SYS_sigsuspend: ::c_long = 201; +pub const SYS_oldlstat: ::c_long = 202; +pub const SYS_uselib: ::c_long = 203; +pub const SYS_readdir: ::c_long = 204; +pub const SYS_readahead: ::c_long = 205; +pub const SYS_socketcall: ::c_long = 206; +pub const SYS_syslog: ::c_long = 207; +pub const SYS_lookup_dcookie: ::c_long = 208; +pub const SYS_fadvise64: ::c_long = 209; +pub const SYS_fadvise64_64: ::c_long = 210; +pub const SYS_tgkill: ::c_long = 211; +pub const SYS_waitpid: ::c_long = 212; +pub const SYS_swapoff: ::c_long = 213; +pub const SYS_sysinfo: ::c_long = 214; +pub const SYS_ipc: ::c_long = 215; +pub const SYS_sigreturn: ::c_long = 216; +pub const SYS_clone: ::c_long = 217; +pub const SYS_ioprio_get: ::c_long = 218; +pub const SYS_adjtimex: ::c_long = 219; +pub const SYS_sigprocmask: ::c_long = 220; +pub const SYS_create_module: ::c_long = 221; +pub const SYS_delete_module: ::c_long = 222; +pub const SYS_get_kernel_syms: ::c_long = 223; +pub const SYS_getpgid: ::c_long = 224; +pub const SYS_bdflush: ::c_long = 225; +pub const SYS_sysfs: ::c_long = 226; +pub const SYS_afs_syscall: ::c_long = 227; +pub const SYS_setfsuid: ::c_long = 228; +pub const SYS_setfsgid: ::c_long = 229; +pub const SYS__newselect: ::c_long = 230; +pub const SYS_time: ::c_long = 231; +pub const SYS_splice: ::c_long = 232; +pub const SYS_stime: ::c_long = 233; +pub const SYS_statfs64: ::c_long = 234; +pub const SYS_fstatfs64: ::c_long = 235; +pub const SYS__llseek: ::c_long = 236; +pub const SYS_mlock: ::c_long = 237; +pub const SYS_munlock: ::c_long = 238; +pub const SYS_mlockall: ::c_long = 239; +pub const SYS_munlockall: ::c_long = 240; +pub const SYS_sched_setparam: ::c_long = 241; +pub const SYS_sched_getparam: ::c_long = 242; +pub const SYS_sched_setscheduler: ::c_long = 243; +pub const SYS_sched_getscheduler: ::c_long = 244; +pub const SYS_sched_yield: ::c_long = 245; +pub const SYS_sched_get_priority_max: ::c_long = 246; +pub const SYS_sched_get_priority_min: ::c_long = 247; +pub const SYS_sched_rr_get_interval: ::c_long = 248; +pub const SYS_nanosleep: ::c_long = 249; +pub const SYS_mremap: ::c_long = 250; +pub const SYS__sysctl: ::c_long = 251; +pub const SYS_getsid: ::c_long = 252; +pub const SYS_fdatasync: ::c_long = 253; +pub const SYS_nfsservctl: ::c_long = 254; +pub const SYS_sync_file_range: ::c_long = 255; +pub const SYS_clock_settime: ::c_long = 256; +pub const SYS_clock_gettime: ::c_long = 257; +pub const SYS_clock_getres: ::c_long = 258; +pub const SYS_clock_nanosleep: ::c_long = 259; +pub const SYS_sched_getaffinity: ::c_long = 260; +pub const SYS_sched_setaffinity: ::c_long = 261; +pub const SYS_timer_settime: ::c_long = 262; +pub const SYS_timer_gettime: ::c_long = 263; +pub const SYS_timer_getoverrun: ::c_long = 264; +pub const SYS_timer_delete: ::c_long = 265; +pub const SYS_timer_create: ::c_long = 266; +pub const SYS_io_setup: ::c_long = 268; +pub const SYS_io_destroy: ::c_long = 269; +pub const SYS_io_submit: ::c_long = 270; +pub const SYS_io_cancel: ::c_long = 271; +pub const SYS_io_getevents: ::c_long = 272; +pub const SYS_mq_open: ::c_long = 273; +pub const SYS_mq_unlink: ::c_long = 274; +pub const SYS_mq_timedsend: ::c_long = 275; +pub const SYS_mq_timedreceive: ::c_long = 276; +pub const SYS_mq_notify: ::c_long = 277; +pub const SYS_mq_getsetattr: ::c_long = 278; +pub const SYS_waitid: ::c_long = 279; +pub const SYS_tee: ::c_long = 280; +pub const SYS_add_key: ::c_long = 281; +pub const SYS_request_key: ::c_long = 282; +pub const SYS_keyctl: ::c_long = 283; +pub const SYS_openat: ::c_long = 284; +pub const SYS_mkdirat: ::c_long = 285; +pub const SYS_mknodat: ::c_long = 286; +pub const SYS_fchownat: ::c_long = 287; +pub const SYS_futimesat: ::c_long = 288; +pub const SYS_fstatat64: ::c_long = 289; +pub const SYS_unlinkat: ::c_long = 290; +pub const SYS_renameat: ::c_long = 291; +pub const SYS_linkat: ::c_long = 292; +pub const SYS_symlinkat: ::c_long = 293; +pub const SYS_readlinkat: ::c_long = 294; +pub const SYS_fchmodat: ::c_long = 295; +pub const SYS_faccessat: ::c_long = 296; +pub const SYS_pselect6: ::c_long = 297; +pub const SYS_ppoll: ::c_long = 298; +pub const SYS_unshare: ::c_long = 299; +pub const SYS_set_robust_list: ::c_long = 300; +pub const SYS_get_robust_list: ::c_long = 301; +pub const SYS_migrate_pages: ::c_long = 302; +pub const SYS_mbind: ::c_long = 303; +pub const SYS_get_mempolicy: ::c_long = 304; +pub const SYS_set_mempolicy: ::c_long = 305; +pub const SYS_kexec_load: ::c_long = 306; +pub const SYS_move_pages: ::c_long = 307; +pub const SYS_getcpu: ::c_long = 308; +pub const SYS_epoll_pwait: ::c_long = 309; +pub const SYS_utimensat: ::c_long = 310; +pub const SYS_signalfd: ::c_long = 311; +pub const SYS_timerfd_create: ::c_long = 312; +pub const SYS_eventfd: ::c_long = 313; +pub const SYS_fallocate: ::c_long = 314; +pub const SYS_timerfd_settime: ::c_long = 315; +pub const SYS_timerfd_gettime: ::c_long = 316; +pub const SYS_signalfd4: ::c_long = 317; +pub const SYS_eventfd2: ::c_long = 318; +pub const SYS_epoll_create1: ::c_long = 319; +pub const SYS_dup3: ::c_long = 320; +pub const SYS_pipe2: ::c_long = 321; +pub const SYS_inotify_init1: ::c_long = 322; +pub const SYS_accept4: ::c_long = 323; +pub const SYS_preadv: ::c_long = 324; +pub const SYS_pwritev: ::c_long = 325; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 326; +pub const SYS_perf_event_open: ::c_long = 327; +pub const SYS_recvmmsg: ::c_long = 328; +pub const SYS_fanotify_init: ::c_long = 329; +pub const SYS_fanotify_mark: ::c_long = 330; +pub const SYS_prlimit64: ::c_long = 331; +pub const SYS_name_to_handle_at: ::c_long = 332; +pub const SYS_open_by_handle_at: ::c_long = 333; +pub const SYS_clock_adjtime: ::c_long = 334; +pub const SYS_syncfs: ::c_long = 335; +pub const SYS_sendmmsg: ::c_long = 336; +pub const SYS_setns: ::c_long = 337; +pub const SYS_process_vm_readv: ::c_long = 338; +pub const SYS_process_vm_writev: ::c_long = 339; +pub const SYS_kern_features: ::c_long = 340; +pub const SYS_kcmp: ::c_long = 341; +pub const SYS_finit_module: ::c_long = 342; +pub const SYS_sched_setattr: ::c_long = 343; +pub const SYS_sched_getattr: ::c_long = 344; +pub const SYS_renameat2: ::c_long = 345; +pub const SYS_seccomp: ::c_long = 346; +pub const SYS_getrandom: ::c_long = 347; +pub const SYS_memfd_create: ::c_long = 348; +pub const SYS_bpf: ::c_long = 349; +pub const SYS_execveat: ::c_long = 350; +pub const SYS_membarrier: ::c_long = 351; +pub const SYS_userfaultfd: ::c_long = 352; +pub const SYS_bind: ::c_long = 353; +pub const SYS_listen: ::c_long = 354; +pub const SYS_setsockopt: ::c_long = 355; +pub const SYS_mlock2: ::c_long = 356; +pub const SYS_copy_file_range: ::c_long = 357; +pub const SYS_preadv2: ::c_long = 358; +pub const SYS_pwritev2: ::c_long = 359; +pub const SYS_statx: ::c_long = 360; + +#[link(name = "util")] +extern "C" { + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/x86/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/x86/align.rs new file mode 100644 index 0000000..9663474 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/x86/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 6] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/x86/mod.rs new file mode 100644 index 0000000..f5f7cac --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -0,0 +1,1164 @@ +pub type c_char = i8; +pub type wchar_t = i32; +pub type greg_t = i32; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + f_spare: [::__fsword_t; 5], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct _libc_fpreg { + pub significand: [u16; 4], + pub exponent: u16, + } + + pub struct _libc_fpstate { + pub cw: ::c_ulong, + pub sw: ::c_ulong, + pub tag: ::c_ulong, + pub ipoff: ::c_ulong, + pub cssel: ::c_ulong, + pub dataoff: ::c_ulong, + pub datasel: ::c_ulong, + pub _st: [_libc_fpreg; 8], + pub status: ::c_ulong, + } + + pub struct user_fpregs_struct { + pub cwd: ::c_long, + pub swd: ::c_long, + pub twd: ::c_long, + pub fip: ::c_long, + pub fcs: ::c_long, + pub foo: ::c_long, + pub fos: ::c_long, + pub st_space: [::c_long; 20], + } + + pub struct user_regs_struct { + pub ebx: ::c_long, + pub ecx: ::c_long, + pub edx: ::c_long, + pub esi: ::c_long, + pub edi: ::c_long, + pub ebp: ::c_long, + pub eax: ::c_long, + pub xds: ::c_long, + pub xes: ::c_long, + pub xfs: ::c_long, + pub xgs: ::c_long, + pub orig_eax: ::c_long, + pub eip: ::c_long, + pub xcs: ::c_long, + pub eflags: ::c_long, + pub esp: ::c_long, + pub xss: ::c_long, + } + + pub struct user { + pub regs: user_regs_struct, + pub u_fpvalid: ::c_int, + pub i387: user_fpregs_struct, + pub u_tsize: ::c_ulong, + pub u_dsize: ::c_ulong, + pub u_ssize: ::c_ulong, + pub start_code: ::c_ulong, + pub start_stack: ::c_ulong, + pub signal: ::c_long, + __reserved: ::c_int, + pub u_ar0: *mut user_regs_struct, + pub u_fpstate: *mut user_fpregs_struct, + pub magic: ::c_ulong, + pub u_comm: [c_char; 32], + pub u_debugreg: [::c_int; 8], + } + + pub struct mcontext_t { + pub gregs: [greg_t; 19], + pub fpregs: *mut _libc_fpstate, + pub oldmask: ::c_ulong, + pub cr2: ::c_ulong, + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_ushort, + __pad1: ::c_ushort, + pub __seq: ::c_ushort, + __pad2: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } + + pub struct stat64 { + pub st_dev: ::dev_t, + __pad1: ::c_uint, + __st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_uint, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_ino: ::ino64_t, + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + __unused1: ::c_ulong, + pub shm_dtime: ::time_t, + __unused2: ::c_ulong, + pub shm_ctime: ::time_t, + __unused3: ::c_ulong, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused4: ::c_ulong, + __unused5: ::c_ulong + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + __glibc_reserved1: ::c_ulong, + pub msg_rtime: ::time_t, + __glibc_reserved2: ::c_ulong, + pub msg_ctime: ::time_t, + __glibc_reserved3: ::c_ulong, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved4: ::c_ulong, + __glibc_reserved5: ::c_ulong, + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } +} + +s_no_extra_traits! { + pub struct user_fpxregs_struct { + pub cwd: ::c_ushort, + pub swd: ::c_ushort, + pub twd: ::c_ushort, + pub fop: ::c_ushort, + pub fip: ::c_long, + pub fcs: ::c_long, + pub foo: ::c_long, + pub fos: ::c_long, + pub mxcsr: ::c_long, + __reserved: ::c_long, + pub st_space: [::c_long; 32], + pub xmm_space: [::c_long; 32], + padding: [::c_long; 56], + } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + __private: [u8; 112], + __ssp: [::c_ulong; 4], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for user_fpxregs_struct { + fn eq(&self, other: &user_fpxregs_struct) -> bool { + self.cwd == other.cwd + && self.swd == other.swd + && self.twd == other.twd + && self.fop == other.fop + && self.fip == other.fip + && self.fcs == other.fcs + && self.foo == other.foo + && self.fos == other.fos + && self.mxcsr == other.mxcsr + // Ignore __reserved field + && self.st_space == other.st_space + && self.xmm_space == other.xmm_space + // Ignore padding field + } + } + + impl Eq for user_fpxregs_struct {} + + impl ::fmt::Debug for user_fpxregs_struct { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("user_fpxregs_struct") + .field("cwd", &self.cwd) + .field("swd", &self.swd) + .field("twd", &self.twd) + .field("fop", &self.fop) + .field("fip", &self.fip) + .field("fcs", &self.fcs) + .field("foo", &self.foo) + .field("fos", &self.fos) + .field("mxcsr", &self.mxcsr) + // Ignore __reserved field + .field("st_space", &self.st_space) + .field("xmm_space", &self.xmm_space) + // Ignore padding field + .finish() + } + } + + impl ::hash::Hash for user_fpxregs_struct { + fn hash(&self, state: &mut H) { + self.cwd.hash(state); + self.swd.hash(state); + self.twd.hash(state); + self.fop.hash(state); + self.fip.hash(state); + self.fcs.hash(state); + self.foo.hash(state); + self.fos.hash(state); + self.mxcsr.hash(state); + // Ignore __reserved field + self.st_space.hash(state); + self.xmm_space.hash(state); + // Ignore padding field + } + } + + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + // Ignore __private field + } + } + + impl Eq for ucontext_t {} + + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } + } + + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + // Ignore __private field + } + } + } +} + +pub const RLIM_INFINITY: ::rlim_t = !0; +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_LARGEFILE: ::c_int = 0o0100000; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 0x101000; +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_NDELAY: ::c_int = 0x800; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_32BIT: ::c_int = 0x0040; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; + +pub const EDEADLOCK: ::c_int = 35; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_LINGER: ::c_int = 13; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; + +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +pub const FIOCLEX: ::c_ulong = 0x5451; +pub const FIONCLEX: ::c_ulong = 0x5450; +pub const FIONBIO: ::c_ulong = 0x5421; + +pub const PTRACE_GETFPXREGS: ::c_uint = 18; +pub const PTRACE_SETFPXREGS: ::c_uint = 19; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const EFD_NONBLOCK: ::c_int = 0x800; +pub const SFD_NONBLOCK: ::c_int = 0x0800; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = 31; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; +pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; +pub const TIOCEXCL: ::c_ulong = 0x540C; +pub const TIOCNXCL: ::c_ulong = 0x540D; +pub const TIOCSCTTY: ::c_ulong = 0x540E; +pub const TIOCSTI: ::c_ulong = 0x5412; +pub const TIOCMGET: ::c_ulong = 0x5415; +pub const TIOCMBIS: ::c_ulong = 0x5416; +pub const TIOCMBIC: ::c_ulong = 0x5417; +pub const TIOCMSET: ::c_ulong = 0x5418; +pub const TIOCCONS: ::c_ulong = 0x541D; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const BOTHER: ::speed_t = 0o010000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; +pub const EXTPROC: ::tcflag_t = 0x00010000; +pub const TCGETS: ::c_ulong = 0x5401; +pub const TCSETS: ::c_ulong = 0x5402; +pub const TCSETSW: ::c_ulong = 0x5403; +pub const TCSETSF: ::c_ulong = 0x5404; +pub const TCGETA: ::c_ulong = 0x5405; +pub const TCSETA: ::c_ulong = 0x5406; +pub const TCSETAW: ::c_ulong = 0x5407; +pub const TCSETAF: ::c_ulong = 0x5408; +pub const TCSBRK: ::c_ulong = 0x5409; +pub const TCXONC: ::c_ulong = 0x540A; +pub const TCFLSH: ::c_ulong = 0x540B; +pub const TIOCINQ: ::c_ulong = 0x541B; +pub const TIOCGPGRP: ::c_ulong = 0x540F; +pub const TIOCSPGRP: ::c_ulong = 0x5410; +pub const TIOCOUTQ: ::c_ulong = 0x5411; +pub const TIOCGWINSZ: ::c_ulong = 0x5413; +pub const TIOCSWINSZ: ::c_ulong = 0x5414; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; +pub const FIONREAD: ::c_ulong = 0x541B; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCLINUX: ::c_ulong = 0x541C; +pub const TIOCGSERIAL: ::c_ulong = 0x541E; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; + +// Syscall table +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_break: ::c_long = 17; +pub const SYS_oldstat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_umount: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_stime: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_oldfstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_stty: ::c_long = 31; +pub const SYS_gtty: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_ftime: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_prof: ::c_long = 44; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_lock: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_mpx: ::c_long = 56; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_ulimit: ::c_long = 58; +pub const SYS_oldolduname: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_oldlstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_readdir: ::c_long = 89; +pub const SYS_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_profil: ::c_long = 98; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_ioperm: ::c_long = 101; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_olduname: ::c_long = 109; +pub const SYS_iopl: ::c_long = 110; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_idle: ::c_long = 112; +pub const SYS_vm86old: ::c_long = 113; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_modify_ldt: ::c_long = 123; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_afs_syscall: ::c_long = 137; +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_vm86: ::c_long = 166; +pub const SYS_query_module: ::c_long = 167; +pub const SYS_poll: ::c_long = 168; +pub const SYS_nfsservctl: ::c_long = 169; +pub const SYS_setresgid: ::c_long = 170; +pub const SYS_getresgid: ::c_long = 171; +pub const SYS_prctl: ::c_long = 172; +pub const SYS_rt_sigreturn: ::c_long = 173; +pub const SYS_rt_sigaction: ::c_long = 174; +pub const SYS_rt_sigprocmask: ::c_long = 175; +pub const SYS_rt_sigpending: ::c_long = 176; +pub const SYS_rt_sigtimedwait: ::c_long = 177; +pub const SYS_rt_sigqueueinfo: ::c_long = 178; +pub const SYS_rt_sigsuspend: ::c_long = 179; +pub const SYS_pread64: ::c_long = 180; +pub const SYS_pwrite64: ::c_long = 181; +pub const SYS_chown: ::c_long = 182; +pub const SYS_getcwd: ::c_long = 183; +pub const SYS_capget: ::c_long = 184; +pub const SYS_capset: ::c_long = 185; +pub const SYS_sigaltstack: ::c_long = 186; +pub const SYS_sendfile: ::c_long = 187; +pub const SYS_getpmsg: ::c_long = 188; +pub const SYS_putpmsg: ::c_long = 189; +pub const SYS_vfork: ::c_long = 190; +pub const SYS_ugetrlimit: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_lchown32: ::c_long = 198; +pub const SYS_getuid32: ::c_long = 199; +pub const SYS_getgid32: ::c_long = 200; +pub const SYS_geteuid32: ::c_long = 201; +pub const SYS_getegid32: ::c_long = 202; +pub const SYS_setreuid32: ::c_long = 203; +pub const SYS_setregid32: ::c_long = 204; +pub const SYS_getgroups32: ::c_long = 205; +pub const SYS_setgroups32: ::c_long = 206; +pub const SYS_fchown32: ::c_long = 207; +pub const SYS_setresuid32: ::c_long = 208; +pub const SYS_getresuid32: ::c_long = 209; +pub const SYS_setresgid32: ::c_long = 210; +pub const SYS_getresgid32: ::c_long = 211; +pub const SYS_chown32: ::c_long = 212; +pub const SYS_setuid32: ::c_long = 213; +pub const SYS_setgid32: ::c_long = 214; +pub const SYS_setfsuid32: ::c_long = 215; +pub const SYS_setfsgid32: ::c_long = 216; +pub const SYS_pivot_root: ::c_long = 217; +pub const SYS_mincore: ::c_long = 218; +pub const SYS_madvise: ::c_long = 219; +pub const SYS_getdents64: ::c_long = 220; +pub const SYS_fcntl64: ::c_long = 221; +pub const SYS_gettid: ::c_long = 224; +pub const SYS_readahead: ::c_long = 225; +pub const SYS_setxattr: ::c_long = 226; +pub const SYS_lsetxattr: ::c_long = 227; +pub const SYS_fsetxattr: ::c_long = 228; +pub const SYS_getxattr: ::c_long = 229; +pub const SYS_lgetxattr: ::c_long = 230; +pub const SYS_fgetxattr: ::c_long = 231; +pub const SYS_listxattr: ::c_long = 232; +pub const SYS_llistxattr: ::c_long = 233; +pub const SYS_flistxattr: ::c_long = 234; +pub const SYS_removexattr: ::c_long = 235; +pub const SYS_lremovexattr: ::c_long = 236; +pub const SYS_fremovexattr: ::c_long = 237; +pub const SYS_tkill: ::c_long = 238; +pub const SYS_sendfile64: ::c_long = 239; +pub const SYS_futex: ::c_long = 240; +pub const SYS_sched_setaffinity: ::c_long = 241; +pub const SYS_sched_getaffinity: ::c_long = 242; +pub const SYS_set_thread_area: ::c_long = 243; +pub const SYS_get_thread_area: ::c_long = 244; +pub const SYS_io_setup: ::c_long = 245; +pub const SYS_io_destroy: ::c_long = 246; +pub const SYS_io_getevents: ::c_long = 247; +pub const SYS_io_submit: ::c_long = 248; +pub const SYS_io_cancel: ::c_long = 249; +pub const SYS_fadvise64: ::c_long = 250; +pub const SYS_exit_group: ::c_long = 252; +pub const SYS_lookup_dcookie: ::c_long = 253; +pub const SYS_epoll_create: ::c_long = 254; +pub const SYS_epoll_ctl: ::c_long = 255; +pub const SYS_epoll_wait: ::c_long = 256; +pub const SYS_remap_file_pages: ::c_long = 257; +pub const SYS_set_tid_address: ::c_long = 258; +pub const SYS_timer_create: ::c_long = 259; +pub const SYS_timer_settime: ::c_long = 260; +pub const SYS_timer_gettime: ::c_long = 261; +pub const SYS_timer_getoverrun: ::c_long = 262; +pub const SYS_timer_delete: ::c_long = 263; +pub const SYS_clock_settime: ::c_long = 264; +pub const SYS_clock_gettime: ::c_long = 265; +pub const SYS_clock_getres: ::c_long = 266; +pub const SYS_clock_nanosleep: ::c_long = 267; +pub const SYS_statfs64: ::c_long = 268; +pub const SYS_fstatfs64: ::c_long = 269; +pub const SYS_tgkill: ::c_long = 270; +pub const SYS_utimes: ::c_long = 271; +pub const SYS_fadvise64_64: ::c_long = 272; +pub const SYS_vserver: ::c_long = 273; +pub const SYS_mbind: ::c_long = 274; +pub const SYS_get_mempolicy: ::c_long = 275; +pub const SYS_set_mempolicy: ::c_long = 276; +pub const SYS_mq_open: ::c_long = 277; +pub const SYS_mq_unlink: ::c_long = 278; +pub const SYS_mq_timedsend: ::c_long = 279; +pub const SYS_mq_timedreceive: ::c_long = 280; +pub const SYS_mq_notify: ::c_long = 281; +pub const SYS_mq_getsetattr: ::c_long = 282; +pub const SYS_kexec_load: ::c_long = 283; +pub const SYS_waitid: ::c_long = 284; +pub const SYS_add_key: ::c_long = 286; +pub const SYS_request_key: ::c_long = 287; +pub const SYS_keyctl: ::c_long = 288; +pub const SYS_ioprio_set: ::c_long = 289; +pub const SYS_ioprio_get: ::c_long = 290; +pub const SYS_inotify_init: ::c_long = 291; +pub const SYS_inotify_add_watch: ::c_long = 292; +pub const SYS_inotify_rm_watch: ::c_long = 293; +pub const SYS_migrate_pages: ::c_long = 294; +pub const SYS_openat: ::c_long = 295; +pub const SYS_mkdirat: ::c_long = 296; +pub const SYS_mknodat: ::c_long = 297; +pub const SYS_fchownat: ::c_long = 298; +pub const SYS_futimesat: ::c_long = 299; +pub const SYS_fstatat64: ::c_long = 300; +pub const SYS_unlinkat: ::c_long = 301; +pub const SYS_renameat: ::c_long = 302; +pub const SYS_linkat: ::c_long = 303; +pub const SYS_symlinkat: ::c_long = 304; +pub const SYS_readlinkat: ::c_long = 305; +pub const SYS_fchmodat: ::c_long = 306; +pub const SYS_faccessat: ::c_long = 307; +pub const SYS_pselect6: ::c_long = 308; +pub const SYS_ppoll: ::c_long = 309; +pub const SYS_unshare: ::c_long = 310; +pub const SYS_set_robust_list: ::c_long = 311; +pub const SYS_get_robust_list: ::c_long = 312; +pub const SYS_splice: ::c_long = 313; +pub const SYS_sync_file_range: ::c_long = 314; +pub const SYS_tee: ::c_long = 315; +pub const SYS_vmsplice: ::c_long = 316; +pub const SYS_move_pages: ::c_long = 317; +pub const SYS_getcpu: ::c_long = 318; +pub const SYS_epoll_pwait: ::c_long = 319; +pub const SYS_utimensat: ::c_long = 320; +pub const SYS_signalfd: ::c_long = 321; +pub const SYS_timerfd_create: ::c_long = 322; +pub const SYS_eventfd: ::c_long = 323; +pub const SYS_fallocate: ::c_long = 324; +pub const SYS_timerfd_settime: ::c_long = 325; +pub const SYS_timerfd_gettime: ::c_long = 326; +pub const SYS_signalfd4: ::c_long = 327; +pub const SYS_eventfd2: ::c_long = 328; +pub const SYS_epoll_create1: ::c_long = 329; +pub const SYS_dup3: ::c_long = 330; +pub const SYS_pipe2: ::c_long = 331; +pub const SYS_inotify_init1: ::c_long = 332; +pub const SYS_preadv: ::c_long = 333; +pub const SYS_pwritev: ::c_long = 334; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 335; +pub const SYS_perf_event_open: ::c_long = 336; +pub const SYS_recvmmsg: ::c_long = 337; +pub const SYS_fanotify_init: ::c_long = 338; +pub const SYS_fanotify_mark: ::c_long = 339; +pub const SYS_prlimit64: ::c_long = 340; +pub const SYS_name_to_handle_at: ::c_long = 341; +pub const SYS_open_by_handle_at: ::c_long = 342; +pub const SYS_clock_adjtime: ::c_long = 343; +pub const SYS_syncfs: ::c_long = 344; +pub const SYS_sendmmsg: ::c_long = 345; +pub const SYS_setns: ::c_long = 346; +pub const SYS_process_vm_readv: ::c_long = 347; +pub const SYS_process_vm_writev: ::c_long = 348; +pub const SYS_kcmp: ::c_long = 349; +pub const SYS_finit_module: ::c_long = 350; +pub const SYS_sched_setattr: ::c_long = 351; +pub const SYS_sched_getattr: ::c_long = 352; +pub const SYS_renameat2: ::c_long = 353; +pub const SYS_seccomp: ::c_long = 354; +pub const SYS_getrandom: ::c_long = 355; +pub const SYS_memfd_create: ::c_long = 356; +pub const SYS_bpf: ::c_long = 357; +pub const SYS_execveat: ::c_long = 358; +pub const SYS_socket: ::c_long = 359; +pub const SYS_socketpair: ::c_long = 360; +pub const SYS_bind: ::c_long = 361; +pub const SYS_connect: ::c_long = 362; +pub const SYS_listen: ::c_long = 363; +pub const SYS_accept4: ::c_long = 364; +pub const SYS_getsockopt: ::c_long = 365; +pub const SYS_setsockopt: ::c_long = 366; +pub const SYS_getsockname: ::c_long = 367; +pub const SYS_getpeername: ::c_long = 368; +pub const SYS_sendto: ::c_long = 369; +pub const SYS_sendmsg: ::c_long = 370; +pub const SYS_recvfrom: ::c_long = 371; +pub const SYS_recvmsg: ::c_long = 372; +pub const SYS_shutdown: ::c_long = 373; +pub const SYS_userfaultfd: ::c_long = 374; +pub const SYS_membarrier: ::c_long = 375; +pub const SYS_mlock2: ::c_long = 376; +pub const SYS_copy_file_range: ::c_long = 377; +pub const SYS_preadv2: ::c_long = 378; +pub const SYS_pwritev2: ::c_long = 379; +pub const SYS_pkey_mprotect: ::c_long = 380; +pub const SYS_pkey_alloc: ::c_long = 381; +pub const SYS_pkey_free: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; + +// offsets in user_regs_structs, from sys/reg.h +pub const EBX: ::c_int = 0; +pub const ECX: ::c_int = 1; +pub const EDX: ::c_int = 2; +pub const ESI: ::c_int = 3; +pub const EDI: ::c_int = 4; +pub const EBP: ::c_int = 5; +pub const EAX: ::c_int = 6; +pub const DS: ::c_int = 7; +pub const ES: ::c_int = 8; +pub const FS: ::c_int = 9; +pub const GS: ::c_int = 10; +pub const ORIG_EAX: ::c_int = 11; +pub const EIP: ::c_int = 12; +pub const CS: ::c_int = 13; +pub const EFL: ::c_int = 14; +pub const UESP: ::c_int = 15; +pub const SS: ::c_int = 16; + +// offsets in mcontext_t.gregs from sys/ucontext.h +pub const REG_GS: ::c_int = 0; +pub const REG_FS: ::c_int = 1; +pub const REG_ES: ::c_int = 2; +pub const REG_DS: ::c_int = 3; +pub const REG_EDI: ::c_int = 4; +pub const REG_ESI: ::c_int = 5; +pub const REG_EBP: ::c_int = 6; +pub const REG_ESP: ::c_int = 7; +pub const REG_EBX: ::c_int = 8; +pub const REG_EDX: ::c_int = 9; +pub const REG_ECX: ::c_int = 10; +pub const REG_EAX: ::c_int = 11; +pub const REG_TRAPNO: ::c_int = 12; +pub const REG_ERR: ::c_int = 13; +pub const REG_EIP: ::c_int = 14; +pub const REG_CS: ::c_int = 15; +pub const REG_EFL: ::c_int = 16; +pub const REG_UESP: ::c_int = 17; +pub const REG_SS: ::c_int = 18; + +extern "C" { + pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; + pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; + pub fn makecontext( + ucp: *mut ucontext_t, + func: extern "C" fn(), + argc: ::c_int, + ... + ); + pub fn swapcontext( + uocp: *mut ucontext_t, + ucp: *const ucontext_t, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs new file mode 100644 index 0000000..8e94996 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs new file mode 100644 index 0000000..93f0f2b --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -0,0 +1,954 @@ +//! AArch64-specific definitions for 64-bit linux-like values + +use pthread_mutex_t; + +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = u8; +pub type wchar_t = u32; +pub type nlink_t = u32; +pub type blksize_t = i32; +pub type suseconds_t = i64; +pub type __u64 = ::c_ulonglong; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + #[cfg(target_arch = "sparc64")] + __reserved0: ::c_int, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + f_spare: [::__fsword_t; 5], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad1: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + __pad2: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_int; 2], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad1: ::dev_t, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + __pad2: ::c_int, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_int; 2], + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct pthread_attr_t { + __size: [u64; 8] + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_uint, + pub __seq: ::c_ushort, + __pad1: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused4: ::c_ulong, + __unused5: ::c_ulong + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } +} + +pub const VEOF: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; + +pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; +pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; + +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 0x101000; +pub const O_NOATIME: ::c_int = 0o1000000; +pub const O_PATH: ::c_int = 0o10000000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; + +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: ::c_int = 28; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_PEERSEC: ::c_int = 31; +pub const SO_PASSSEC: ::c_int = 34; +pub const SO_TIMESTAMPNS: ::c_int = 35; +pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; +pub const SO_MARK: ::c_int = 36; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_WIFI_STATUS: ::c_int = 41; +pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_NOFCS: ::c_int = 43; +pub const SO_LOCK_FILTER: ::c_int = 44; +pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; +pub const SO_BUSY_POLL: ::c_int = 46; +pub const SO_MAX_PACING_RATE: ::c_int = 47; +pub const SO_BPF_EXTENSIONS: ::c_int = 48; +pub const SO_INCOMING_CPU: ::c_int = 49; +pub const SO_ATTACH_BPF: ::c_int = 50; +pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = 31; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_NDELAY: ::c_int = 0x800; + +pub const PTRACE_DETACH: ::c_uint = 17; + +pub const EFD_NONBLOCK: ::c_int = 0x800; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; + +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + +pub const SFD_NONBLOCK: ::c_int = 0x0800; + +pub const TIOCEXCL: ::c_ulong = 0x540C; +pub const TIOCNXCL: ::c_ulong = 0x540D; +pub const TIOCSCTTY: ::c_ulong = 0x540E; +pub const TIOCSTI: ::c_ulong = 0x5412; +pub const TIOCMGET: ::c_ulong = 0x5415; +pub const TIOCMBIS: ::c_ulong = 0x5416; +pub const TIOCMBIC: ::c_ulong = 0x5417; +pub const TIOCMSET: ::c_ulong = 0x5418; +pub const TIOCCONS: ::c_ulong = 0x541D; + +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const SFD_CLOEXEC: ::c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: ::c_int = 512; + +pub const O_CLOEXEC: ::c_int = 0x80000; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; + +align_const! { + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + ], + }; +} + +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; + +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const EDEADLOCK: ::c_int = 35; + +pub const FIOCLEX: ::c_ulong = 0x5451; +pub const FIONCLEX: ::c_ulong = 0x5450; +pub const FIONBIO: ::c_ulong = 0x5421; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const SIGSTKSZ: ::size_t = 16384; +pub const MINSIGSTKSZ: ::size_t = 5120; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const BOTHER: ::speed_t = 0o010000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; +pub const EXTPROC: ::tcflag_t = 0x00010000; +pub const TCGETS: ::c_ulong = 0x5401; +pub const TCSETS: ::c_ulong = 0x5402; +pub const TCSETSW: ::c_ulong = 0x5403; +pub const TCSETSF: ::c_ulong = 0x5404; +pub const TCGETA: ::c_ulong = 0x5405; +pub const TCSETA: ::c_ulong = 0x5406; +pub const TCSETAW: ::c_ulong = 0x5407; +pub const TCSETAF: ::c_ulong = 0x5408; +pub const TCSBRK: ::c_ulong = 0x5409; +pub const TCXONC: ::c_ulong = 0x540A; +pub const TCFLSH: ::c_ulong = 0x540B; +pub const TIOCINQ: ::c_ulong = 0x541B; +pub const TIOCGPGRP: ::c_ulong = 0x540F; +pub const TIOCSPGRP: ::c_ulong = 0x5410; +pub const TIOCOUTQ: ::c_ulong = 0x5411; +pub const TIOCGWINSZ: ::c_ulong = 0x5413; +pub const TIOCSWINSZ: ::c_ulong = 0x5414; +pub const FIONREAD: ::c_ulong = 0x541B; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCLINUX: ::c_ulong = 0x541C; +pub const TIOCGSERIAL: ::c_ulong = 0x541E; + +// Syscall table +pub const SYS_io_setup: ::c_long = 0; +pub const SYS_io_destroy: ::c_long = 1; +pub const SYS_io_submit: ::c_long = 2; +pub const SYS_io_cancel: ::c_long = 3; +pub const SYS_io_getevents: ::c_long = 4; +pub const SYS_setxattr: ::c_long = 5; +pub const SYS_lsetxattr: ::c_long = 6; +pub const SYS_fsetxattr: ::c_long = 7; +pub const SYS_getxattr: ::c_long = 8; +pub const SYS_lgetxattr: ::c_long = 9; +pub const SYS_fgetxattr: ::c_long = 10; +pub const SYS_listxattr: ::c_long = 11; +pub const SYS_llistxattr: ::c_long = 12; +pub const SYS_flistxattr: ::c_long = 13; +pub const SYS_removexattr: ::c_long = 14; +pub const SYS_lremovexattr: ::c_long = 15; +pub const SYS_fremovexattr: ::c_long = 16; +pub const SYS_getcwd: ::c_long = 17; +pub const SYS_lookup_dcookie: ::c_long = 18; +pub const SYS_eventfd2: ::c_long = 19; +pub const SYS_epoll_create1: ::c_long = 20; +pub const SYS_epoll_ctl: ::c_long = 21; +pub const SYS_epoll_pwait: ::c_long = 22; +pub const SYS_dup: ::c_long = 23; +pub const SYS_dup3: ::c_long = 24; +pub const SYS_fcntl: ::c_long = 25; +pub const SYS_inotify_init1: ::c_long = 26; +pub const SYS_inotify_add_watch: ::c_long = 27; +pub const SYS_inotify_rm_watch: ::c_long = 28; +pub const SYS_ioctl: ::c_long = 29; +pub const SYS_ioprio_set: ::c_long = 30; +pub const SYS_ioprio_get: ::c_long = 31; +pub const SYS_flock: ::c_long = 32; +pub const SYS_mknodat: ::c_long = 33; +pub const SYS_mkdirat: ::c_long = 34; +pub const SYS_unlinkat: ::c_long = 35; +pub const SYS_symlinkat: ::c_long = 36; +pub const SYS_linkat: ::c_long = 37; +pub const SYS_renameat: ::c_long = 38; +pub const SYS_umount2: ::c_long = 39; +pub const SYS_mount: ::c_long = 40; +pub const SYS_pivot_root: ::c_long = 41; +pub const SYS_nfsservctl: ::c_long = 42; +pub const SYS_fallocate: ::c_long = 47; +pub const SYS_faccessat: ::c_long = 48; +pub const SYS_chdir: ::c_long = 49; +pub const SYS_fchdir: ::c_long = 50; +pub const SYS_chroot: ::c_long = 51; +pub const SYS_fchmod: ::c_long = 52; +pub const SYS_fchmodat: ::c_long = 53; +pub const SYS_fchownat: ::c_long = 54; +pub const SYS_fchown: ::c_long = 55; +pub const SYS_openat: ::c_long = 56; +pub const SYS_close: ::c_long = 57; +pub const SYS_vhangup: ::c_long = 58; +pub const SYS_pipe2: ::c_long = 59; +pub const SYS_quotactl: ::c_long = 60; +pub const SYS_getdents64: ::c_long = 61; +pub const SYS_lseek: ::c_long = 62; +pub const SYS_read: ::c_long = 63; +pub const SYS_write: ::c_long = 64; +pub const SYS_readv: ::c_long = 65; +pub const SYS_writev: ::c_long = 66; +pub const SYS_pread64: ::c_long = 67; +pub const SYS_pwrite64: ::c_long = 68; +pub const SYS_preadv: ::c_long = 69; +pub const SYS_pwritev: ::c_long = 70; +pub const SYS_pselect6: ::c_long = 72; +pub const SYS_ppoll: ::c_long = 73; +pub const SYS_signalfd4: ::c_long = 74; +pub const SYS_vmsplice: ::c_long = 75; +pub const SYS_splice: ::c_long = 76; +pub const SYS_tee: ::c_long = 77; +pub const SYS_readlinkat: ::c_long = 78; +pub const SYS_newfstatat: ::c_long = 79; +pub const SYS_fstat: ::c_long = 80; +pub const SYS_sync: ::c_long = 81; +pub const SYS_fsync: ::c_long = 82; +pub const SYS_fdatasync: ::c_long = 83; +pub const SYS_sync_file_range: ::c_long = 84; +pub const SYS_timerfd_create: ::c_long = 85; +pub const SYS_timerfd_settime: ::c_long = 86; +pub const SYS_timerfd_gettime: ::c_long = 87; +pub const SYS_utimensat: ::c_long = 88; +pub const SYS_acct: ::c_long = 89; +pub const SYS_capget: ::c_long = 90; +pub const SYS_capset: ::c_long = 91; +pub const SYS_personality: ::c_long = 92; +pub const SYS_exit: ::c_long = 93; +pub const SYS_exit_group: ::c_long = 94; +pub const SYS_waitid: ::c_long = 95; +pub const SYS_set_tid_address: ::c_long = 96; +pub const SYS_unshare: ::c_long = 97; +pub const SYS_futex: ::c_long = 98; +pub const SYS_set_robust_list: ::c_long = 99; +pub const SYS_get_robust_list: ::c_long = 100; +pub const SYS_nanosleep: ::c_long = 101; +pub const SYS_getitimer: ::c_long = 102; +pub const SYS_setitimer: ::c_long = 103; +pub const SYS_kexec_load: ::c_long = 104; +pub const SYS_init_module: ::c_long = 105; +pub const SYS_delete_module: ::c_long = 106; +pub const SYS_timer_create: ::c_long = 107; +pub const SYS_timer_gettime: ::c_long = 108; +pub const SYS_timer_getoverrun: ::c_long = 109; +pub const SYS_timer_settime: ::c_long = 110; +pub const SYS_timer_delete: ::c_long = 111; +pub const SYS_clock_settime: ::c_long = 112; +pub const SYS_clock_gettime: ::c_long = 113; +pub const SYS_clock_getres: ::c_long = 114; +pub const SYS_clock_nanosleep: ::c_long = 115; +pub const SYS_syslog: ::c_long = 116; +pub const SYS_ptrace: ::c_long = 117; +pub const SYS_sched_setparam: ::c_long = 118; +pub const SYS_sched_setscheduler: ::c_long = 119; +pub const SYS_sched_getscheduler: ::c_long = 120; +pub const SYS_sched_getparam: ::c_long = 121; +pub const SYS_sched_setaffinity: ::c_long = 122; +pub const SYS_sched_getaffinity: ::c_long = 123; +pub const SYS_sched_yield: ::c_long = 124; +pub const SYS_sched_get_priority_max: ::c_long = 125; +pub const SYS_sched_get_priority_min: ::c_long = 126; +pub const SYS_sched_rr_get_interval: ::c_long = 127; +pub const SYS_restart_syscall: ::c_long = 128; +pub const SYS_kill: ::c_long = 129; +pub const SYS_tkill: ::c_long = 130; +pub const SYS_tgkill: ::c_long = 131; +pub const SYS_sigaltstack: ::c_long = 132; +pub const SYS_rt_sigsuspend: ::c_long = 133; +pub const SYS_rt_sigaction: ::c_long = 134; +pub const SYS_rt_sigprocmask: ::c_long = 135; +pub const SYS_rt_sigpending: ::c_long = 136; +pub const SYS_rt_sigtimedwait: ::c_long = 137; +pub const SYS_rt_sigqueueinfo: ::c_long = 138; +pub const SYS_rt_sigreturn: ::c_long = 139; +pub const SYS_setpriority: ::c_long = 140; +pub const SYS_getpriority: ::c_long = 141; +pub const SYS_reboot: ::c_long = 142; +pub const SYS_setregid: ::c_long = 143; +pub const SYS_setgid: ::c_long = 144; +pub const SYS_setreuid: ::c_long = 145; +pub const SYS_setuid: ::c_long = 146; +pub const SYS_setresuid: ::c_long = 147; +pub const SYS_getresuid: ::c_long = 148; +pub const SYS_setresgid: ::c_long = 149; +pub const SYS_getresgid: ::c_long = 150; +pub const SYS_setfsuid: ::c_long = 151; +pub const SYS_setfsgid: ::c_long = 152; +pub const SYS_times: ::c_long = 153; +pub const SYS_setpgid: ::c_long = 154; +pub const SYS_getpgid: ::c_long = 155; +pub const SYS_getsid: ::c_long = 156; +pub const SYS_setsid: ::c_long = 157; +pub const SYS_getgroups: ::c_long = 158; +pub const SYS_setgroups: ::c_long = 159; +pub const SYS_uname: ::c_long = 160; +pub const SYS_sethostname: ::c_long = 161; +pub const SYS_setdomainname: ::c_long = 162; +pub const SYS_getrlimit: ::c_long = 163; +pub const SYS_setrlimit: ::c_long = 164; +pub const SYS_getrusage: ::c_long = 165; +pub const SYS_umask: ::c_long = 166; +pub const SYS_prctl: ::c_long = 167; +pub const SYS_getcpu: ::c_long = 168; +pub const SYS_gettimeofday: ::c_long = 169; +pub const SYS_settimeofday: ::c_long = 170; +pub const SYS_adjtimex: ::c_long = 171; +pub const SYS_getpid: ::c_long = 172; +pub const SYS_getppid: ::c_long = 173; +pub const SYS_getuid: ::c_long = 174; +pub const SYS_geteuid: ::c_long = 175; +pub const SYS_getgid: ::c_long = 176; +pub const SYS_getegid: ::c_long = 177; +pub const SYS_gettid: ::c_long = 178; +pub const SYS_sysinfo: ::c_long = 179; +pub const SYS_mq_open: ::c_long = 180; +pub const SYS_mq_unlink: ::c_long = 181; +pub const SYS_mq_timedsend: ::c_long = 182; +pub const SYS_mq_timedreceive: ::c_long = 183; +pub const SYS_mq_notify: ::c_long = 184; +pub const SYS_mq_getsetattr: ::c_long = 185; +pub const SYS_msgget: ::c_long = 186; +pub const SYS_msgctl: ::c_long = 187; +pub const SYS_msgrcv: ::c_long = 188; +pub const SYS_msgsnd: ::c_long = 189; +pub const SYS_semget: ::c_long = 190; +pub const SYS_semctl: ::c_long = 191; +pub const SYS_semtimedop: ::c_long = 192; +pub const SYS_semop: ::c_long = 193; +pub const SYS_shmget: ::c_long = 194; +pub const SYS_shmctl: ::c_long = 195; +pub const SYS_shmat: ::c_long = 196; +pub const SYS_shmdt: ::c_long = 197; +pub const SYS_socket: ::c_long = 198; +pub const SYS_socketpair: ::c_long = 199; +pub const SYS_bind: ::c_long = 200; +pub const SYS_listen: ::c_long = 201; +pub const SYS_accept: ::c_long = 202; +pub const SYS_connect: ::c_long = 203; +pub const SYS_getsockname: ::c_long = 204; +pub const SYS_getpeername: ::c_long = 205; +pub const SYS_sendto: ::c_long = 206; +pub const SYS_recvfrom: ::c_long = 207; +pub const SYS_setsockopt: ::c_long = 208; +pub const SYS_getsockopt: ::c_long = 209; +pub const SYS_shutdown: ::c_long = 210; +pub const SYS_sendmsg: ::c_long = 211; +pub const SYS_recvmsg: ::c_long = 212; +pub const SYS_readahead: ::c_long = 213; +pub const SYS_brk: ::c_long = 214; +pub const SYS_munmap: ::c_long = 215; +pub const SYS_mremap: ::c_long = 216; +pub const SYS_add_key: ::c_long = 217; +pub const SYS_request_key: ::c_long = 218; +pub const SYS_keyctl: ::c_long = 219; +pub const SYS_clone: ::c_long = 220; +pub const SYS_execve: ::c_long = 221; +pub const SYS_mmap: ::c_long = 222; +pub const SYS_swapon: ::c_long = 224; +pub const SYS_swapoff: ::c_long = 225; +pub const SYS_mprotect: ::c_long = 226; +pub const SYS_msync: ::c_long = 227; +pub const SYS_mlock: ::c_long = 228; +pub const SYS_munlock: ::c_long = 229; +pub const SYS_mlockall: ::c_long = 230; +pub const SYS_munlockall: ::c_long = 231; +pub const SYS_mincore: ::c_long = 232; +pub const SYS_madvise: ::c_long = 233; +pub const SYS_remap_file_pages: ::c_long = 234; +pub const SYS_mbind: ::c_long = 235; +pub const SYS_get_mempolicy: ::c_long = 236; +pub const SYS_set_mempolicy: ::c_long = 237; +pub const SYS_migrate_pages: ::c_long = 238; +pub const SYS_move_pages: ::c_long = 239; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 240; +pub const SYS_perf_event_open: ::c_long = 241; +pub const SYS_accept4: ::c_long = 242; +pub const SYS_recvmmsg: ::c_long = 243; +pub const SYS_wait4: ::c_long = 260; +pub const SYS_prlimit64: ::c_long = 261; +pub const SYS_fanotify_init: ::c_long = 262; +pub const SYS_fanotify_mark: ::c_long = 263; +pub const SYS_name_to_handle_at: ::c_long = 264; +pub const SYS_open_by_handle_at: ::c_long = 265; +pub const SYS_clock_adjtime: ::c_long = 266; +pub const SYS_syncfs: ::c_long = 267; +pub const SYS_setns: ::c_long = 268; +pub const SYS_sendmmsg: ::c_long = 269; +pub const SYS_process_vm_readv: ::c_long = 270; +pub const SYS_process_vm_writev: ::c_long = 271; +pub const SYS_kcmp: ::c_long = 272; +pub const SYS_finit_module: ::c_long = 273; +pub const SYS_sched_setattr: ::c_long = 274; +pub const SYS_sched_getattr: ::c_long = 275; +pub const SYS_renameat2: ::c_long = 276; +pub const SYS_seccomp: ::c_long = 277; +pub const SYS_getrandom: ::c_long = 278; +pub const SYS_memfd_create: ::c_long = 279; +pub const SYS_bpf: ::c_long = 280; +pub const SYS_execveat: ::c_long = 281; +pub const SYS_userfaultfd: ::c_long = 282; +pub const SYS_membarrier: ::c_long = 283; +pub const SYS_mlock2: ::c_long = 284; +pub const SYS_copy_file_range: ::c_long = 285; +pub const SYS_preadv2: ::c_long = 286; +pub const SYS_pwritev2: ::c_long = 287; +pub const SYS_pkey_mprotect: ::c_long = 288; +pub const SYS_pkey_alloc: ::c_long = 289; +pub const SYS_pkey_free: ::c_long = 290; +pub const SYS_statx: ::c_long = 291; + +#[link(name = "util")] +extern "C" { + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/mips64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/mips64/align.rs new file mode 100644 index 0000000..7ca870f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/mips64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs new file mode 100644 index 0000000..a59554b --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -0,0 +1,1017 @@ +use pthread_mutex_t; + +pub type blksize_t = i64; +pub type c_char = i8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type nlink_t = u64; +pub type suseconds_t = i64; +pub type wchar_t = i32; +pub type __u64 = ::c_ulong; + +s! { + pub struct stat { + pub st_dev: ::c_ulong, + st_pad1: [::c_long; 2], + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulong, + st_pad2: [::c_ulong; 1], + pub st_size: ::off_t, + st_pad3: ::c_long, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + st_pad4: ::c_long, + pub st_blocks: ::blkcnt_t, + st_pad5: [::c_long; 7], + } + + pub struct statfs { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_frsize: ::c_long, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_files: ::fsblkcnt_t, + pub f_ffree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::c_long, + f_spare: [::c_long; 6], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct stat64 { + pub st_dev: ::c_ulong, + st_pad1: [::c_long; 2], + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulong, + st_pad2: [::c_long; 2], + pub st_size: ::off64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + st_pad3: ::c_long, + pub st_blocks: ::blkcnt64_t, + st_pad5: [::c_long; 7], + } + + pub struct statfs64 { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_frsize: ::c_long, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_bavail: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_long, + pub f_flags: ::c_long, + pub f_spare: [::c_long; 5], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct pthread_attr_t { + __size: [::c_ulong; 7] + } + + pub struct sigaction { + pub sa_flags: ::c_int, + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_restorer: ::Option, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + _pad: ::c_int, + _pad2: [::c_long; 14], + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_uint, + pub __seq: ::c_ushort, + __pad1: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused4: ::c_ulong, + __unused5: ::c_ulong + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 23], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + +align_const! { + #[cfg(target_endian = "little")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + +pub const SYS_read: ::c_long = 5000 + 0; +pub const SYS_write: ::c_long = 5000 + 1; +pub const SYS_open: ::c_long = 5000 + 2; +pub const SYS_close: ::c_long = 5000 + 3; +pub const SYS_stat: ::c_long = 5000 + 4; +pub const SYS_fstat: ::c_long = 5000 + 5; +pub const SYS_lstat: ::c_long = 5000 + 6; +pub const SYS_poll: ::c_long = 5000 + 7; +pub const SYS_lseek: ::c_long = 5000 + 8; +pub const SYS_mmap: ::c_long = 5000 + 9; +pub const SYS_mprotect: ::c_long = 5000 + 10; +pub const SYS_munmap: ::c_long = 5000 + 11; +pub const SYS_brk: ::c_long = 5000 + 12; +pub const SYS_rt_sigaction: ::c_long = 5000 + 13; +pub const SYS_rt_sigprocmask: ::c_long = 5000 + 14; +pub const SYS_ioctl: ::c_long = 5000 + 15; +pub const SYS_pread64: ::c_long = 5000 + 16; +pub const SYS_pwrite64: ::c_long = 5000 + 17; +pub const SYS_readv: ::c_long = 5000 + 18; +pub const SYS_writev: ::c_long = 5000 + 19; +pub const SYS_access: ::c_long = 5000 + 20; +pub const SYS_pipe: ::c_long = 5000 + 21; +pub const SYS__newselect: ::c_long = 5000 + 22; +pub const SYS_sched_yield: ::c_long = 5000 + 23; +pub const SYS_mremap: ::c_long = 5000 + 24; +pub const SYS_msync: ::c_long = 5000 + 25; +pub const SYS_mincore: ::c_long = 5000 + 26; +pub const SYS_madvise: ::c_long = 5000 + 27; +pub const SYS_shmget: ::c_long = 5000 + 28; +pub const SYS_shmat: ::c_long = 5000 + 29; +pub const SYS_shmctl: ::c_long = 5000 + 30; +pub const SYS_dup: ::c_long = 5000 + 31; +pub const SYS_dup2: ::c_long = 5000 + 32; +pub const SYS_pause: ::c_long = 5000 + 33; +pub const SYS_nanosleep: ::c_long = 5000 + 34; +pub const SYS_getitimer: ::c_long = 5000 + 35; +pub const SYS_setitimer: ::c_long = 5000 + 36; +pub const SYS_alarm: ::c_long = 5000 + 37; +pub const SYS_getpid: ::c_long = 5000 + 38; +pub const SYS_sendfile: ::c_long = 5000 + 39; +pub const SYS_socket: ::c_long = 5000 + 40; +pub const SYS_connect: ::c_long = 5000 + 41; +pub const SYS_accept: ::c_long = 5000 + 42; +pub const SYS_sendto: ::c_long = 5000 + 43; +pub const SYS_recvfrom: ::c_long = 5000 + 44; +pub const SYS_sendmsg: ::c_long = 5000 + 45; +pub const SYS_recvmsg: ::c_long = 5000 + 46; +pub const SYS_shutdown: ::c_long = 5000 + 47; +pub const SYS_bind: ::c_long = 5000 + 48; +pub const SYS_listen: ::c_long = 5000 + 49; +pub const SYS_getsockname: ::c_long = 5000 + 50; +pub const SYS_getpeername: ::c_long = 5000 + 51; +pub const SYS_socketpair: ::c_long = 5000 + 52; +pub const SYS_setsockopt: ::c_long = 5000 + 53; +pub const SYS_getsockopt: ::c_long = 5000 + 54; +pub const SYS_clone: ::c_long = 5000 + 55; +pub const SYS_fork: ::c_long = 5000 + 56; +pub const SYS_execve: ::c_long = 5000 + 57; +pub const SYS_exit: ::c_long = 5000 + 58; +pub const SYS_wait4: ::c_long = 5000 + 59; +pub const SYS_kill: ::c_long = 5000 + 60; +pub const SYS_uname: ::c_long = 5000 + 61; +pub const SYS_semget: ::c_long = 5000 + 62; +pub const SYS_semop: ::c_long = 5000 + 63; +pub const SYS_semctl: ::c_long = 5000 + 64; +pub const SYS_shmdt: ::c_long = 5000 + 65; +pub const SYS_msgget: ::c_long = 5000 + 66; +pub const SYS_msgsnd: ::c_long = 5000 + 67; +pub const SYS_msgrcv: ::c_long = 5000 + 68; +pub const SYS_msgctl: ::c_long = 5000 + 69; +pub const SYS_fcntl: ::c_long = 5000 + 70; +pub const SYS_flock: ::c_long = 5000 + 71; +pub const SYS_fsync: ::c_long = 5000 + 72; +pub const SYS_fdatasync: ::c_long = 5000 + 73; +pub const SYS_truncate: ::c_long = 5000 + 74; +pub const SYS_ftruncate: ::c_long = 5000 + 75; +pub const SYS_getdents: ::c_long = 5000 + 76; +pub const SYS_getcwd: ::c_long = 5000 + 77; +pub const SYS_chdir: ::c_long = 5000 + 78; +pub const SYS_fchdir: ::c_long = 5000 + 79; +pub const SYS_rename: ::c_long = 5000 + 80; +pub const SYS_mkdir: ::c_long = 5000 + 81; +pub const SYS_rmdir: ::c_long = 5000 + 82; +pub const SYS_creat: ::c_long = 5000 + 83; +pub const SYS_link: ::c_long = 5000 + 84; +pub const SYS_unlink: ::c_long = 5000 + 85; +pub const SYS_symlink: ::c_long = 5000 + 86; +pub const SYS_readlink: ::c_long = 5000 + 87; +pub const SYS_chmod: ::c_long = 5000 + 88; +pub const SYS_fchmod: ::c_long = 5000 + 89; +pub const SYS_chown: ::c_long = 5000 + 90; +pub const SYS_fchown: ::c_long = 5000 + 91; +pub const SYS_lchown: ::c_long = 5000 + 92; +pub const SYS_umask: ::c_long = 5000 + 93; +pub const SYS_gettimeofday: ::c_long = 5000 + 94; +pub const SYS_getrlimit: ::c_long = 5000 + 95; +pub const SYS_getrusage: ::c_long = 5000 + 96; +pub const SYS_sysinfo: ::c_long = 5000 + 97; +pub const SYS_times: ::c_long = 5000 + 98; +pub const SYS_ptrace: ::c_long = 5000 + 99; +pub const SYS_getuid: ::c_long = 5000 + 100; +pub const SYS_syslog: ::c_long = 5000 + 101; +pub const SYS_getgid: ::c_long = 5000 + 102; +pub const SYS_setuid: ::c_long = 5000 + 103; +pub const SYS_setgid: ::c_long = 5000 + 104; +pub const SYS_geteuid: ::c_long = 5000 + 105; +pub const SYS_getegid: ::c_long = 5000 + 106; +pub const SYS_setpgid: ::c_long = 5000 + 107; +pub const SYS_getppid: ::c_long = 5000 + 108; +pub const SYS_getpgrp: ::c_long = 5000 + 109; +pub const SYS_setsid: ::c_long = 5000 + 110; +pub const SYS_setreuid: ::c_long = 5000 + 111; +pub const SYS_setregid: ::c_long = 5000 + 112; +pub const SYS_getgroups: ::c_long = 5000 + 113; +pub const SYS_setgroups: ::c_long = 5000 + 114; +pub const SYS_setresuid: ::c_long = 5000 + 115; +pub const SYS_getresuid: ::c_long = 5000 + 116; +pub const SYS_setresgid: ::c_long = 5000 + 117; +pub const SYS_getresgid: ::c_long = 5000 + 118; +pub const SYS_getpgid: ::c_long = 5000 + 119; +pub const SYS_setfsuid: ::c_long = 5000 + 120; +pub const SYS_setfsgid: ::c_long = 5000 + 121; +pub const SYS_getsid: ::c_long = 5000 + 122; +pub const SYS_capget: ::c_long = 5000 + 123; +pub const SYS_capset: ::c_long = 5000 + 124; +pub const SYS_rt_sigpending: ::c_long = 5000 + 125; +pub const SYS_rt_sigtimedwait: ::c_long = 5000 + 126; +pub const SYS_rt_sigqueueinfo: ::c_long = 5000 + 127; +pub const SYS_rt_sigsuspend: ::c_long = 5000 + 128; +pub const SYS_sigaltstack: ::c_long = 5000 + 129; +pub const SYS_utime: ::c_long = 5000 + 130; +pub const SYS_mknod: ::c_long = 5000 + 131; +pub const SYS_personality: ::c_long = 5000 + 132; +pub const SYS_ustat: ::c_long = 5000 + 133; +pub const SYS_statfs: ::c_long = 5000 + 134; +pub const SYS_fstatfs: ::c_long = 5000 + 135; +pub const SYS_sysfs: ::c_long = 5000 + 136; +pub const SYS_getpriority: ::c_long = 5000 + 137; +pub const SYS_setpriority: ::c_long = 5000 + 138; +pub const SYS_sched_setparam: ::c_long = 5000 + 139; +pub const SYS_sched_getparam: ::c_long = 5000 + 140; +pub const SYS_sched_setscheduler: ::c_long = 5000 + 141; +pub const SYS_sched_getscheduler: ::c_long = 5000 + 142; +pub const SYS_sched_get_priority_max: ::c_long = 5000 + 143; +pub const SYS_sched_get_priority_min: ::c_long = 5000 + 144; +pub const SYS_sched_rr_get_interval: ::c_long = 5000 + 145; +pub const SYS_mlock: ::c_long = 5000 + 146; +pub const SYS_munlock: ::c_long = 5000 + 147; +pub const SYS_mlockall: ::c_long = 5000 + 148; +pub const SYS_munlockall: ::c_long = 5000 + 149; +pub const SYS_vhangup: ::c_long = 5000 + 150; +pub const SYS_pivot_root: ::c_long = 5000 + 151; +pub const SYS__sysctl: ::c_long = 5000 + 152; +pub const SYS_prctl: ::c_long = 5000 + 153; +pub const SYS_adjtimex: ::c_long = 5000 + 154; +pub const SYS_setrlimit: ::c_long = 5000 + 155; +pub const SYS_chroot: ::c_long = 5000 + 156; +pub const SYS_sync: ::c_long = 5000 + 157; +pub const SYS_acct: ::c_long = 5000 + 158; +pub const SYS_settimeofday: ::c_long = 5000 + 159; +pub const SYS_mount: ::c_long = 5000 + 160; +pub const SYS_umount2: ::c_long = 5000 + 161; +pub const SYS_swapon: ::c_long = 5000 + 162; +pub const SYS_swapoff: ::c_long = 5000 + 163; +pub const SYS_reboot: ::c_long = 5000 + 164; +pub const SYS_sethostname: ::c_long = 5000 + 165; +pub const SYS_setdomainname: ::c_long = 5000 + 166; +pub const SYS_create_module: ::c_long = 5000 + 167; +pub const SYS_init_module: ::c_long = 5000 + 168; +pub const SYS_delete_module: ::c_long = 5000 + 169; +pub const SYS_get_kernel_syms: ::c_long = 5000 + 170; +pub const SYS_query_module: ::c_long = 5000 + 171; +pub const SYS_quotactl: ::c_long = 5000 + 172; +pub const SYS_nfsservctl: ::c_long = 5000 + 173; +pub const SYS_getpmsg: ::c_long = 5000 + 174; +pub const SYS_putpmsg: ::c_long = 5000 + 175; +pub const SYS_afs_syscall: ::c_long = 5000 + 176; +pub const SYS_gettid: ::c_long = 5000 + 178; +pub const SYS_readahead: ::c_long = 5000 + 179; +pub const SYS_setxattr: ::c_long = 5000 + 180; +pub const SYS_lsetxattr: ::c_long = 5000 + 181; +pub const SYS_fsetxattr: ::c_long = 5000 + 182; +pub const SYS_getxattr: ::c_long = 5000 + 183; +pub const SYS_lgetxattr: ::c_long = 5000 + 184; +pub const SYS_fgetxattr: ::c_long = 5000 + 185; +pub const SYS_listxattr: ::c_long = 5000 + 186; +pub const SYS_llistxattr: ::c_long = 5000 + 187; +pub const SYS_flistxattr: ::c_long = 5000 + 188; +pub const SYS_removexattr: ::c_long = 5000 + 189; +pub const SYS_lremovexattr: ::c_long = 5000 + 190; +pub const SYS_fremovexattr: ::c_long = 5000 + 191; +pub const SYS_tkill: ::c_long = 5000 + 192; +pub const SYS_futex: ::c_long = 5000 + 194; +pub const SYS_sched_setaffinity: ::c_long = 5000 + 195; +pub const SYS_sched_getaffinity: ::c_long = 5000 + 196; +pub const SYS_cacheflush: ::c_long = 5000 + 197; +pub const SYS_cachectl: ::c_long = 5000 + 198; +pub const SYS_sysmips: ::c_long = 5000 + 199; +pub const SYS_io_setup: ::c_long = 5000 + 200; +pub const SYS_io_destroy: ::c_long = 5000 + 201; +pub const SYS_io_getevents: ::c_long = 5000 + 202; +pub const SYS_io_submit: ::c_long = 5000 + 203; +pub const SYS_io_cancel: ::c_long = 5000 + 204; +pub const SYS_exit_group: ::c_long = 5000 + 205; +pub const SYS_lookup_dcookie: ::c_long = 5000 + 206; +pub const SYS_epoll_create: ::c_long = 5000 + 207; +pub const SYS_epoll_ctl: ::c_long = 5000 + 208; +pub const SYS_epoll_wait: ::c_long = 5000 + 209; +pub const SYS_remap_file_pages: ::c_long = 5000 + 210; +pub const SYS_rt_sigreturn: ::c_long = 5000 + 211; +pub const SYS_set_tid_address: ::c_long = 5000 + 212; +pub const SYS_restart_syscall: ::c_long = 5000 + 213; +pub const SYS_semtimedop: ::c_long = 5000 + 214; +pub const SYS_fadvise64: ::c_long = 5000 + 215; +pub const SYS_timer_create: ::c_long = 5000 + 216; +pub const SYS_timer_settime: ::c_long = 5000 + 217; +pub const SYS_timer_gettime: ::c_long = 5000 + 218; +pub const SYS_timer_getoverrun: ::c_long = 5000 + 219; +pub const SYS_timer_delete: ::c_long = 5000 + 220; +pub const SYS_clock_settime: ::c_long = 5000 + 221; +pub const SYS_clock_gettime: ::c_long = 5000 + 222; +pub const SYS_clock_getres: ::c_long = 5000 + 223; +pub const SYS_clock_nanosleep: ::c_long = 5000 + 224; +pub const SYS_tgkill: ::c_long = 5000 + 225; +pub const SYS_utimes: ::c_long = 5000 + 226; +pub const SYS_mbind: ::c_long = 5000 + 227; +pub const SYS_get_mempolicy: ::c_long = 5000 + 228; +pub const SYS_set_mempolicy: ::c_long = 5000 + 229; +pub const SYS_mq_open: ::c_long = 5000 + 230; +pub const SYS_mq_unlink: ::c_long = 5000 + 231; +pub const SYS_mq_timedsend: ::c_long = 5000 + 232; +pub const SYS_mq_timedreceive: ::c_long = 5000 + 233; +pub const SYS_mq_notify: ::c_long = 5000 + 234; +pub const SYS_mq_getsetattr: ::c_long = 5000 + 235; +pub const SYS_vserver: ::c_long = 5000 + 236; +pub const SYS_waitid: ::c_long = 5000 + 237; +/* pub const SYS_sys_setaltroot: ::c_long = 5000 + 238; */ +pub const SYS_add_key: ::c_long = 5000 + 239; +pub const SYS_request_key: ::c_long = 5000 + 240; +pub const SYS_keyctl: ::c_long = 5000 + 241; +pub const SYS_set_thread_area: ::c_long = 5000 + 242; +pub const SYS_inotify_init: ::c_long = 5000 + 243; +pub const SYS_inotify_add_watch: ::c_long = 5000 + 244; +pub const SYS_inotify_rm_watch: ::c_long = 5000 + 245; +pub const SYS_migrate_pages: ::c_long = 5000 + 246; +pub const SYS_openat: ::c_long = 5000 + 247; +pub const SYS_mkdirat: ::c_long = 5000 + 248; +pub const SYS_mknodat: ::c_long = 5000 + 249; +pub const SYS_fchownat: ::c_long = 5000 + 250; +pub const SYS_futimesat: ::c_long = 5000 + 251; +pub const SYS_newfstatat: ::c_long = 5000 + 252; +pub const SYS_unlinkat: ::c_long = 5000 + 253; +pub const SYS_renameat: ::c_long = 5000 + 254; +pub const SYS_linkat: ::c_long = 5000 + 255; +pub const SYS_symlinkat: ::c_long = 5000 + 256; +pub const SYS_readlinkat: ::c_long = 5000 + 257; +pub const SYS_fchmodat: ::c_long = 5000 + 258; +pub const SYS_faccessat: ::c_long = 5000 + 259; +pub const SYS_pselect6: ::c_long = 5000 + 260; +pub const SYS_ppoll: ::c_long = 5000 + 261; +pub const SYS_unshare: ::c_long = 5000 + 262; +pub const SYS_splice: ::c_long = 5000 + 263; +pub const SYS_sync_file_range: ::c_long = 5000 + 264; +pub const SYS_tee: ::c_long = 5000 + 265; +pub const SYS_vmsplice: ::c_long = 5000 + 266; +pub const SYS_move_pages: ::c_long = 5000 + 267; +pub const SYS_set_robust_list: ::c_long = 5000 + 268; +pub const SYS_get_robust_list: ::c_long = 5000 + 269; +pub const SYS_kexec_load: ::c_long = 5000 + 270; +pub const SYS_getcpu: ::c_long = 5000 + 271; +pub const SYS_epoll_pwait: ::c_long = 5000 + 272; +pub const SYS_ioprio_set: ::c_long = 5000 + 273; +pub const SYS_ioprio_get: ::c_long = 5000 + 274; +pub const SYS_utimensat: ::c_long = 5000 + 275; +pub const SYS_signalfd: ::c_long = 5000 + 276; +pub const SYS_timerfd: ::c_long = 5000 + 277; +pub const SYS_eventfd: ::c_long = 5000 + 278; +pub const SYS_fallocate: ::c_long = 5000 + 279; +pub const SYS_timerfd_create: ::c_long = 5000 + 280; +pub const SYS_timerfd_gettime: ::c_long = 5000 + 281; +pub const SYS_timerfd_settime: ::c_long = 5000 + 282; +pub const SYS_signalfd4: ::c_long = 5000 + 283; +pub const SYS_eventfd2: ::c_long = 5000 + 284; +pub const SYS_epoll_create1: ::c_long = 5000 + 285; +pub const SYS_dup3: ::c_long = 5000 + 286; +pub const SYS_pipe2: ::c_long = 5000 + 287; +pub const SYS_inotify_init1: ::c_long = 5000 + 288; +pub const SYS_preadv: ::c_long = 5000 + 289; +pub const SYS_pwritev: ::c_long = 5000 + 290; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 5000 + 291; +pub const SYS_perf_event_open: ::c_long = 5000 + 292; +pub const SYS_accept4: ::c_long = 5000 + 293; +pub const SYS_recvmmsg: ::c_long = 5000 + 294; +pub const SYS_fanotify_init: ::c_long = 5000 + 295; +pub const SYS_fanotify_mark: ::c_long = 5000 + 296; +pub const SYS_prlimit64: ::c_long = 5000 + 297; +pub const SYS_name_to_handle_at: ::c_long = 5000 + 298; +pub const SYS_open_by_handle_at: ::c_long = 5000 + 299; +pub const SYS_clock_adjtime: ::c_long = 5000 + 300; +pub const SYS_syncfs: ::c_long = 5000 + 301; +pub const SYS_sendmmsg: ::c_long = 5000 + 302; +pub const SYS_setns: ::c_long = 5000 + 303; +pub const SYS_process_vm_readv: ::c_long = 5000 + 304; +pub const SYS_process_vm_writev: ::c_long = 5000 + 305; +pub const SYS_kcmp: ::c_long = 5000 + 306; +pub const SYS_finit_module: ::c_long = 5000 + 307; +pub const SYS_getdents64: ::c_long = 5000 + 308; +pub const SYS_sched_setattr: ::c_long = 5000 + 309; +pub const SYS_sched_getattr: ::c_long = 5000 + 310; +pub const SYS_renameat2: ::c_long = 5000 + 311; +pub const SYS_seccomp: ::c_long = 5000 + 312; +pub const SYS_getrandom: ::c_long = 5000 + 313; +pub const SYS_memfd_create: ::c_long = 5000 + 314; +pub const SYS_bpf: ::c_long = 5000 + 315; +pub const SYS_execveat: ::c_long = 5000 + 316; +pub const SYS_userfaultfd: ::c_long = 5000 + 317; +pub const SYS_membarrier: ::c_long = 5000 + 318; +pub const SYS_mlock2: ::c_long = 5000 + 319; +pub const SYS_copy_file_range: ::c_long = 5000 + 320; +pub const SYS_preadv2: ::c_long = 5000 + 321; +pub const SYS_pwritev2: ::c_long = 5000 + 322; +pub const SYS_pkey_mprotect: ::c_long = 5000 + 323; +pub const SYS_pkey_alloc: ::c_long = 5000 + 324; +pub const SYS_pkey_free: ::c_long = 5000 + 325; +pub const SYS_statx: ::c_long = 5000 + 326; + +pub const SFD_CLOEXEC: ::c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: ::c_int = 512; + +pub const O_NOATIME: ::c_int = 0o1000000; +pub const O_CLOEXEC: ::c_int = 0x80000; +pub const O_PATH: ::c_int = 0o10000000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; + +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const O_DIRECT: ::c_int = 0x8000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; + +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 6; +pub const RLIMIT_RSS: ::__rlimit_resource_t = 7; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 8; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 9; + +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 256; +pub const O_EXCL: ::c_int = 1024; +pub const O_NOCTTY: ::c_int = 2048; +pub const O_NONBLOCK: ::c_int = 128; +pub const O_SYNC: ::c_int = 0x4010; +pub const O_RSYNC: ::c_int = 0x4010; +pub const O_DSYNC: ::c_int = 0x10; +pub const O_FSYNC: ::c_int = 0x4010; +pub const O_ASYNC: ::c_int = 0x1000; +pub const O_NDELAY: ::c_int = 0x80; + +pub const EDEADLK: ::c_int = 45; +pub const ENAMETOOLONG: ::c_int = 78; +pub const ENOLCK: ::c_int = 46; +pub const ENOSYS: ::c_int = 89; +pub const ENOTEMPTY: ::c_int = 93; +pub const ELOOP: ::c_int = 90; +pub const ENOMSG: ::c_int = 35; +pub const EIDRM: ::c_int = 36; +pub const ECHRNG: ::c_int = 37; +pub const EL2NSYNC: ::c_int = 38; +pub const EL3HLT: ::c_int = 39; +pub const EL3RST: ::c_int = 40; +pub const ELNRNG: ::c_int = 41; +pub const EUNATCH: ::c_int = 42; +pub const ENOCSI: ::c_int = 43; +pub const EL2HLT: ::c_int = 44; +pub const EBADE: ::c_int = 50; +pub const EBADR: ::c_int = 51; +pub const EXFULL: ::c_int = 52; +pub const ENOANO: ::c_int = 53; +pub const EBADRQC: ::c_int = 54; +pub const EBADSLT: ::c_int = 55; +pub const EDEADLOCK: ::c_int = 56; +pub const EMULTIHOP: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 79; +pub const ENOTUNIQ: ::c_int = 80; +pub const EBADFD: ::c_int = 81; +pub const EBADMSG: ::c_int = 77; +pub const EREMCHG: ::c_int = 82; +pub const ELIBACC: ::c_int = 83; +pub const ELIBBAD: ::c_int = 84; +pub const ELIBSCN: ::c_int = 85; +pub const ELIBMAX: ::c_int = 86; +pub const ELIBEXEC: ::c_int = 87; +pub const EILSEQ: ::c_int = 88; +pub const ERESTART: ::c_int = 91; +pub const ESTRPIPE: ::c_int = 92; +pub const EUSERS: ::c_int = 94; +pub const ENOTSOCK: ::c_int = 95; +pub const EDESTADDRREQ: ::c_int = 96; +pub const EMSGSIZE: ::c_int = 97; +pub const EPROTOTYPE: ::c_int = 98; +pub const ENOPROTOOPT: ::c_int = 99; +pub const EPROTONOSUPPORT: ::c_int = 120; +pub const ESOCKTNOSUPPORT: ::c_int = 121; +pub const EOPNOTSUPP: ::c_int = 122; +pub const EPFNOSUPPORT: ::c_int = 123; +pub const EAFNOSUPPORT: ::c_int = 124; +pub const EADDRINUSE: ::c_int = 125; +pub const EADDRNOTAVAIL: ::c_int = 126; +pub const ENETDOWN: ::c_int = 127; +pub const ENETUNREACH: ::c_int = 128; +pub const ENETRESET: ::c_int = 129; +pub const ECONNABORTED: ::c_int = 130; +pub const ECONNRESET: ::c_int = 131; +pub const ENOBUFS: ::c_int = 132; +pub const EISCONN: ::c_int = 133; +pub const ENOTCONN: ::c_int = 134; +pub const ESHUTDOWN: ::c_int = 143; +pub const ETOOMANYREFS: ::c_int = 144; +pub const ETIMEDOUT: ::c_int = 145; +pub const ECONNREFUSED: ::c_int = 146; +pub const EHOSTDOWN: ::c_int = 147; +pub const EHOSTUNREACH: ::c_int = 148; +pub const EALREADY: ::c_int = 149; +pub const EINPROGRESS: ::c_int = 150; +pub const ESTALE: ::c_int = 151; +pub const EUCLEAN: ::c_int = 135; +pub const ENOTNAM: ::c_int = 137; +pub const ENAVAIL: ::c_int = 138; +pub const EISNAM: ::c_int = 139; +pub const EREMOTEIO: ::c_int = 140; +pub const EDQUOT: ::c_int = 1133; +pub const ENOMEDIUM: ::c_int = 159; +pub const EMEDIUMTYPE: ::c_int = 160; +pub const ECANCELED: ::c_int = 158; +pub const ENOKEY: ::c_int = 161; +pub const EKEYEXPIRED: ::c_int = 162; +pub const EKEYREVOKED: ::c_int = 163; +pub const EKEYREJECTED: ::c_int = 164; +pub const EOWNERDEAD: ::c_int = 165; +pub const ENOTRECOVERABLE: ::c_int = 166; +pub const ERFKILL: ::c_int = 167; + +pub const MAP_NORESERVE: ::c_int = 0x400; +pub const MAP_ANON: ::c_int = 0x800; +pub const MAP_ANONYMOUS: ::c_int = 0x800; +pub const MAP_GROWSDOWN: ::c_int = 0x1000; +pub const MAP_DENYWRITE: ::c_int = 0x2000; +pub const MAP_EXECUTABLE: ::c_int = 0x4000; +pub const MAP_LOCKED: ::c_int = 0x8000; +pub const MAP_POPULATE: ::c_int = 0x10000; +pub const MAP_NONBLOCK: ::c_int = 0x20000; +pub const MAP_STACK: ::c_int = 0x40000; +pub const MAP_HUGETLB: ::c_int = 0x080000; + +pub const SOCK_STREAM: ::c_int = 2; +pub const SOCK_DGRAM: ::c_int = 1; + +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_STYLE: ::c_int = SO_TYPE; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ACCEPTCONN: ::c_int = 0x1009; +pub const SO_PROTOCOL: ::c_int = 0x1028; +pub const SO_DOMAIN: ::c_int = 0x1029; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_PASSCRED: ::c_int = 17; +pub const SO_PEERCRED: ::c_int = 18; +pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: ::c_int = 28; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_PEERSEC: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 31; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PASSSEC: ::c_int = 34; +pub const SO_TIMESTAMPNS: ::c_int = 35; +pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; +pub const SO_MARK: ::c_int = 36; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_WIFI_STATUS: ::c_int = 41; +pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_NOFCS: ::c_int = 43; +pub const SO_LOCK_FILTER: ::c_int = 44; +pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; +pub const SO_BUSY_POLL: ::c_int = 46; +pub const SO_MAX_PACING_RATE: ::c_int = 47; +pub const SO_BPF_EXTENSIONS: ::c_int = 48; +pub const SO_INCOMING_CPU: ::c_int = 49; +pub const SO_ATTACH_BPF: ::c_int = 50; +pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER; + +pub const FIOCLEX: ::c_ulong = 0x6601; +pub const FIONCLEX: ::c_ulong = 0x6602; +pub const FIONBIO: ::c_ulong = 0x667e; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000008; +pub const SA_NOCLDWAIT: ::c_int = 0x00010000; + +pub const SIGCHLD: ::c_int = 18; +pub const SIGBUS: ::c_int = 10; +pub const SIGTTIN: ::c_int = 26; +pub const SIGTTOU: ::c_int = 27; +pub const SIGXCPU: ::c_int = 30; +pub const SIGXFSZ: ::c_int = 31; +pub const SIGVTALRM: ::c_int = 28; +pub const SIGPROF: ::c_int = 29; +pub const SIGWINCH: ::c_int = 20; +pub const SIGUSR1: ::c_int = 16; +pub const SIGUSR2: ::c_int = 17; +pub const SIGCONT: ::c_int = 25; +pub const SIGSTOP: ::c_int = 23; +pub const SIGTSTP: ::c_int = 24; +pub const SIGURG: ::c_int = 21; +pub const SIGIO: ::c_int = 22; +pub const SIGSYS: ::c_int = 12; +pub const SIGPOLL: ::c_int = 22; +pub const SIGPWR: ::c_int = 19; +pub const SIG_SETMASK: ::c_int = 3; +pub const SIG_BLOCK: ::c_int = 0x1; +pub const SIG_UNBLOCK: ::c_int = 0x2; + +pub const POLLWRNORM: ::c_short = 0x004; +pub const POLLWRBAND: ::c_short = 0x100; + +pub const VEOF: usize = 16; +pub const VEOL: usize = 17; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: ::tcflag_t = 0x00000100; +pub const TOSTOP: ::tcflag_t = 0x00008000; +pub const FLUSHO: ::tcflag_t = 0x00002000; +pub const EXTPROC: ::tcflag_t = 0o200000; +pub const TCSANOW: ::c_int = 0x540e; +pub const TCSADRAIN: ::c_int = 0x540f; +pub const TCSAFLUSH: ::c_int = 0x5410; + +pub const PTRACE_GETFPREGS: ::c_uint = 14; +pub const PTRACE_SETFPREGS: ::c_uint = 15; +pub const PTRACE_DETACH: ::c_uint = 17; +pub const PTRACE_GETFPXREGS: ::c_uint = 18; +pub const PTRACE_SETFPXREGS: ::c_uint = 19; +pub const PTRACE_GETREGS: ::c_uint = 12; +pub const PTRACE_SETREGS: ::c_uint = 13; + +pub const EFD_NONBLOCK: ::c_int = 0x80; + +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; +pub const F_GETLK: ::c_int = 14; +pub const F_GETOWN: ::c_int = 23; +pub const F_SETOWN: ::c_int = 24; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; + +pub const SFD_NONBLOCK: ::c_int = 0x80; + +pub const TCGETS: ::c_ulong = 0x540d; +pub const TCSETS: ::c_ulong = 0x540e; +pub const TCSETSW: ::c_ulong = 0x540f; +pub const TCSETSF: ::c_ulong = 0x5410; +pub const TCGETA: ::c_ulong = 0x5401; +pub const TCSETA: ::c_ulong = 0x5402; +pub const TCSETAW: ::c_ulong = 0x5403; +pub const TCSETAF: ::c_ulong = 0x5404; +pub const TCSBRK: ::c_ulong = 0x5405; +pub const TCXONC: ::c_ulong = 0x5406; +pub const TCFLSH: ::c_ulong = 0x5407; +pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; +pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; +pub const TIOCINQ: ::c_ulong = 0x467f; +pub const TIOCLINUX: ::c_ulong = 0x5483; +pub const TIOCGSERIAL: ::c_ulong = 0x5484; +pub const TIOCEXCL: ::c_ulong = 0x740d; +pub const TIOCNXCL: ::c_ulong = 0x740e; +pub const TIOCSCTTY: ::c_ulong = 0x5480; +pub const TIOCGPGRP: ::c_ulong = 0x40047477; +pub const TIOCSPGRP: ::c_ulong = 0x80047476; +pub const TIOCOUTQ: ::c_ulong = 0x7472; +pub const TIOCSTI: ::c_ulong = 0x5472; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const TIOCMGET: ::c_ulong = 0x741d; +pub const TIOCMBIS: ::c_ulong = 0x741b; +pub const TIOCMBIC: ::c_ulong = 0x741c; +pub const TIOCMSET: ::c_ulong = 0x741a; +pub const FIONREAD: ::c_ulong = 0x467f; +pub const TIOCCONS: ::c_ulong = 0x80047478; + +pub const RTLD_DEEPBIND: ::c_int = 0x10; +pub const RTLD_GLOBAL: ::c_int = 0x4; +pub const RTLD_NOLOAD: ::c_int = 0x8; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const BOTHER: ::speed_t = 0o010000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const TIOCM_ST: ::c_int = 0x010; +pub const TIOCM_SR: ::c_int = 0x020; +pub const TIOCM_CTS: ::c_int = 0x040; +pub const TIOCM_CAR: ::c_int = 0x100; +pub const TIOCM_RNG: ::c_int = 0x200; +pub const TIOCM_DSR: ::c_int = 0x400; + +pub const EHWPOISON: ::c_int = 168; + +#[link(name = "util")] +extern "C" { + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/mod.rs new file mode 100644 index 0000000..40ce844 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/mod.rs @@ -0,0 +1,87 @@ +//! 64-bit specific definitions for linux-like values + +pub type clock_t = i64; +pub type time_t = i64; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i64; +pub type shmatt_t = u64; +pub type msgqnum_t = u64; +pub type msglen_t = u64; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type rlim_t = u64; +pub type __fsword_t = i64; + +s! { + pub struct sigset_t { + #[cfg(target_pointer_width = "32")] + __val: [u32; 32], + #[cfg(target_pointer_width = "64")] + __val: [u64; 16], + } + + pub struct sysinfo { + pub uptime: i64, + pub loads: [u64; 3], + pub totalram: u64, + pub freeram: u64, + pub sharedram: u64, + pub bufferram: u64, + pub totalswap: u64, + pub freeswap: u64, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: u64, + pub freehigh: u64, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 0], + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + pub msg_rtime: ::time_t, + pub msg_ctime: ::time_t, + __msg_cbytes: u64, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved4: u64, + __glibc_reserved5: u64, + } + +} + +pub const RLIM_INFINITY: ::rlim_t = !0; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + +pub const O_LARGEFILE: ::c_int = 0; + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(any(target_arch = "powerpc64"))] { + mod powerpc64; + pub use self::powerpc64::*; + } else if #[cfg(any(target_arch = "sparc64"))] { + mod sparc64; + pub use self::sparc64::*; + } else if #[cfg(any(target_arch = "mips64"))] { + mod mips64; + pub use self::mips64::*; + } else if #[cfg(any(target_arch = "s390x"))] { + mod s390x; + pub use self::s390x::*; + } else if #[cfg(any(target_arch = "x86_64"))] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(any(target_arch = "riscv64"))] { + mod riscv64; + pub use self::riscv64::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs new file mode 100644 index 0000000..29d1e1c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [i64; 4] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs new file mode 100644 index 0000000..22507d7 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -0,0 +1,1052 @@ +//! PowerPC64-specific definitions for 64-bit linux-like values + +use pthread_mutex_t; + +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = u8; +pub type wchar_t = i32; +pub type nlink_t = u64; +pub type blksize_t = i64; +pub type suseconds_t = i64; +pub type __u64 = ::c_ulong; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + #[cfg(target_arch = "sparc64")] + __reserved0: ::c_int, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + f_spare: [::__fsword_t; 5], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 3], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __reserved: [::c_long; 3], + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct pthread_attr_t { + __size: [u64; 7] + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: u32, + __pad1: u32, + __unused1: u64, + __unused2: ::c_ulong, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_segsz: ::size_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused4: ::c_ulong, + __unused5: ::c_ulong + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } +} + +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const VEOF: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + +pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; +pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; + +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; + +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 0x101000; +pub const O_NOATIME: ::c_int = 0o1000000; +pub const O_PATH: ::c_int = 0o10000000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_PASSCRED: ::c_int = 20; +pub const SO_PEERCRED: ::c_int = 21; +pub const SO_RCVLOWAT: ::c_int = 16; +pub const SO_SNDLOWAT: ::c_int = 17; +pub const SO_RCVTIMEO: ::c_int = 18; +pub const SO_SNDTIMEO: ::c_int = 19; +pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: ::c_int = 28; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_PEERSEC: ::c_int = 31; +pub const SO_PASSSEC: ::c_int = 34; +pub const SO_TIMESTAMPNS: ::c_int = 35; +pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; +pub const SO_MARK: ::c_int = 36; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_WIFI_STATUS: ::c_int = 41; +pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_NOFCS: ::c_int = 43; +pub const SO_LOCK_FILTER: ::c_int = 44; +pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; +pub const SO_BUSY_POLL: ::c_int = 46; +pub const SO_MAX_PACING_RATE: ::c_int = 47; +pub const SO_BPF_EXTENSIONS: ::c_int = 48; +pub const SO_INCOMING_CPU: ::c_int = 49; +pub const SO_ATTACH_BPF: ::c_int = 50; +pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = 31; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_NDELAY: ::c_int = 0x800; + +pub const PTRACE_DETACH: ::c_uint = 17; + +pub const EFD_NONBLOCK: ::c_int = 0x800; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; + +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + +pub const SFD_NONBLOCK: ::c_int = 0x0800; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCLINUX: ::c_ulong = 0x541C; +pub const TIOCGSERIAL: ::c_ulong = 0x541E; +pub const TIOCEXCL: ::c_ulong = 0x540C; +pub const TIOCNXCL: ::c_ulong = 0x540D; +pub const TIOCSCTTY: ::c_ulong = 0x540E; +pub const TIOCSTI: ::c_ulong = 0x5412; +pub const TIOCMGET: ::c_ulong = 0x5415; +pub const TIOCMBIS: ::c_ulong = 0x5416; +pub const TIOCMBIC: ::c_ulong = 0x5417; +pub const TIOCMSET: ::c_ulong = 0x5418; +pub const TIOCCONS: ::c_ulong = 0x541D; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const SFD_CLOEXEC: ::c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: ::c_int = 512; + +pub const O_CLOEXEC: ::c_int = 0x80000; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + +align_const! { + #[cfg(target_endian = "little")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_DIRECT: ::c_int = 0x20000; + +pub const MAP_LOCKED: ::c_int = 0x00080; +pub const MAP_NORESERVE: ::c_int = 0x00040; + +pub const EDEADLOCK: ::c_int = 58; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; + +pub const FIOCLEX: ::c_ulong = 0x20006601; +pub const FIONCLEX: ::c_ulong = 0x20006602; +pub const FIONBIO: ::c_ulong = 0x8004667e; + +pub const MCL_CURRENT: ::c_int = 0x2000; +pub const MCL_FUTURE: ::c_int = 0x4000; + +pub const SIGSTKSZ: ::size_t = 0x4000; +pub const MINSIGSTKSZ: ::size_t = 4096; +pub const CBAUD: ::tcflag_t = 0xff; +pub const TAB1: ::tcflag_t = 0x400; +pub const TAB2: ::tcflag_t = 0x800; +pub const TAB3: ::tcflag_t = 0xc00; +pub const CR1: ::tcflag_t = 0x1000; +pub const CR2: ::tcflag_t = 0x2000; +pub const CR3: ::tcflag_t = 0x3000; +pub const FF1: ::tcflag_t = 0x4000; +pub const BS1: ::tcflag_t = 0x8000; +pub const VT1: ::tcflag_t = 0x10000; +pub const VWERASE: usize = 0xa; +pub const VREPRINT: usize = 0xb; +pub const VSUSP: usize = 0xc; +pub const VSTART: usize = 0xd; +pub const VSTOP: usize = 0xe; +pub const VDISCARD: usize = 0x10; +pub const VTIME: usize = 0x7; +pub const IXON: ::tcflag_t = 0x200; +pub const IXOFF: ::tcflag_t = 0x400; +pub const ONLCR: ::tcflag_t = 0x2; +pub const CSIZE: ::tcflag_t = 0x300; +pub const CS6: ::tcflag_t = 0x100; +pub const CS7: ::tcflag_t = 0x200; +pub const CS8: ::tcflag_t = 0x300; +pub const CSTOPB: ::tcflag_t = 0x400; +pub const CREAD: ::tcflag_t = 0x800; +pub const PARENB: ::tcflag_t = 0x1000; +pub const PARODD: ::tcflag_t = 0x2000; +pub const HUPCL: ::tcflag_t = 0x4000; +pub const CLOCAL: ::tcflag_t = 0x8000; +pub const ECHOKE: ::tcflag_t = 0x1; +pub const ECHOE: ::tcflag_t = 0x2; +pub const ECHOK: ::tcflag_t = 0x4; +pub const ECHONL: ::tcflag_t = 0x10; +pub const ECHOPRT: ::tcflag_t = 0x20; +pub const ECHOCTL: ::tcflag_t = 0x40; +pub const ISIG: ::tcflag_t = 0x80; +pub const ICANON: ::tcflag_t = 0x100; +pub const PENDIN: ::tcflag_t = 0x20000000; +pub const NOFLSH: ::tcflag_t = 0x80000000; +pub const VSWTC: usize = 9; +pub const OLCUC: ::tcflag_t = 0o000004; +pub const NLDLY: ::tcflag_t = 0o001400; +pub const CRDLY: ::tcflag_t = 0o030000; +pub const TABDLY: ::tcflag_t = 0o006000; +pub const BSDLY: ::tcflag_t = 0o100000; +pub const FFDLY: ::tcflag_t = 0o040000; +pub const VTDLY: ::tcflag_t = 0o200000; +pub const XTABS: ::tcflag_t = 0o006000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const CBAUDEX: ::speed_t = 0o000020; +pub const B57600: ::speed_t = 0o0020; +pub const B115200: ::speed_t = 0o0021; +pub const B230400: ::speed_t = 0o0022; +pub const B460800: ::speed_t = 0o0023; +pub const B500000: ::speed_t = 0o0024; +pub const B576000: ::speed_t = 0o0025; +pub const B921600: ::speed_t = 0o0026; +pub const B1000000: ::speed_t = 0o0027; +pub const B1152000: ::speed_t = 0o0030; +pub const B1500000: ::speed_t = 0o0031; +pub const B2000000: ::speed_t = 0o0032; +pub const B2500000: ::speed_t = 0o0033; +pub const B3000000: ::speed_t = 0o0034; +pub const B3500000: ::speed_t = 0o0035; +pub const B4000000: ::speed_t = 0o0036; +pub const BOTHER: ::speed_t = 0o0037; + +pub const VEOL: usize = 6; +pub const VEOL2: usize = 8; +pub const VMIN: usize = 5; +pub const IEXTEN: ::tcflag_t = 0x400; +pub const TOSTOP: ::tcflag_t = 0x400000; +pub const FLUSHO: ::tcflag_t = 0x800000; +pub const EXTPROC: ::tcflag_t = 0x10000000; +pub const TCGETS: ::c_ulong = 0x403c7413; +pub const TCSETS: ::c_ulong = 0x803c7414; +pub const TCSETSW: ::c_ulong = 0x803c7415; +pub const TCSETSF: ::c_ulong = 0x803c7416; +pub const TCGETA: ::c_ulong = 0x40147417; +pub const TCSETA: ::c_ulong = 0x80147418; +pub const TCSETAW: ::c_ulong = 0x80147419; +pub const TCSETAF: ::c_ulong = 0x8014741c; +pub const TCSBRK: ::c_ulong = 0x2000741d; +pub const TCXONC: ::c_ulong = 0x2000741e; +pub const TCFLSH: ::c_ulong = 0x2000741f; +pub const TIOCINQ: ::c_ulong = 0x4004667f; +pub const TIOCGPGRP: ::c_ulong = 0x40047477; +pub const TIOCSPGRP: ::c_ulong = 0x80047476; +pub const TIOCOUTQ: ::c_ulong = 0x40047473; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const FIONREAD: ::c_ulong = 0x4004667f; + +// Syscall table +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_break: ::c_long = 17; +pub const SYS_oldstat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_umount: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_stime: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_oldfstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_stty: ::c_long = 31; +pub const SYS_gtty: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_ftime: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_prof: ::c_long = 44; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_lock: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_mpx: ::c_long = 56; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_ulimit: ::c_long = 58; +pub const SYS_oldolduname: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_oldlstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_readdir: ::c_long = 89; +pub const SYS_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_profil: ::c_long = 98; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_ioperm: ::c_long = 101; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_olduname: ::c_long = 109; +pub const SYS_iopl: ::c_long = 110; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_idle: ::c_long = 112; +pub const SYS_vm86: ::c_long = 113; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_modify_ldt: ::c_long = 123; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_afs_syscall: ::c_long = 137; /* Syscall for Andrew File System */ +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_query_module: ::c_long = 166; +pub const SYS_poll: ::c_long = 167; +pub const SYS_nfsservctl: ::c_long = 168; +pub const SYS_setresgid: ::c_long = 169; +pub const SYS_getresgid: ::c_long = 170; +pub const SYS_prctl: ::c_long = 171; +pub const SYS_rt_sigreturn: ::c_long = 172; +pub const SYS_rt_sigaction: ::c_long = 173; +pub const SYS_rt_sigprocmask: ::c_long = 174; +pub const SYS_rt_sigpending: ::c_long = 175; +pub const SYS_rt_sigtimedwait: ::c_long = 176; +pub const SYS_rt_sigqueueinfo: ::c_long = 177; +pub const SYS_rt_sigsuspend: ::c_long = 178; +pub const SYS_pread64: ::c_long = 179; +pub const SYS_pwrite64: ::c_long = 180; +pub const SYS_chown: ::c_long = 181; +pub const SYS_getcwd: ::c_long = 182; +pub const SYS_capget: ::c_long = 183; +pub const SYS_capset: ::c_long = 184; +pub const SYS_sigaltstack: ::c_long = 185; +pub const SYS_sendfile: ::c_long = 186; +pub const SYS_getpmsg: ::c_long = 187; /* some people actually want streams */ +pub const SYS_putpmsg: ::c_long = 188; /* some people actually want streams */ +pub const SYS_vfork: ::c_long = 189; +pub const SYS_ugetrlimit: ::c_long = 190; /* SuS compliant getrlimit */ +pub const SYS_readahead: ::c_long = 191; +pub const SYS_pciconfig_read: ::c_long = 198; +pub const SYS_pciconfig_write: ::c_long = 199; +pub const SYS_pciconfig_iobase: ::c_long = 200; +pub const SYS_multiplexer: ::c_long = 201; +pub const SYS_getdents64: ::c_long = 202; +pub const SYS_pivot_root: ::c_long = 203; +pub const SYS_madvise: ::c_long = 205; +pub const SYS_mincore: ::c_long = 206; +pub const SYS_gettid: ::c_long = 207; +pub const SYS_tkill: ::c_long = 208; +pub const SYS_setxattr: ::c_long = 209; +pub const SYS_lsetxattr: ::c_long = 210; +pub const SYS_fsetxattr: ::c_long = 211; +pub const SYS_getxattr: ::c_long = 212; +pub const SYS_lgetxattr: ::c_long = 213; +pub const SYS_fgetxattr: ::c_long = 214; +pub const SYS_listxattr: ::c_long = 215; +pub const SYS_llistxattr: ::c_long = 216; +pub const SYS_flistxattr: ::c_long = 217; +pub const SYS_removexattr: ::c_long = 218; +pub const SYS_lremovexattr: ::c_long = 219; +pub const SYS_fremovexattr: ::c_long = 220; +pub const SYS_futex: ::c_long = 221; +pub const SYS_sched_setaffinity: ::c_long = 222; +pub const SYS_sched_getaffinity: ::c_long = 223; +pub const SYS_tuxcall: ::c_long = 225; +pub const SYS_io_setup: ::c_long = 227; +pub const SYS_io_destroy: ::c_long = 228; +pub const SYS_io_getevents: ::c_long = 229; +pub const SYS_io_submit: ::c_long = 230; +pub const SYS_io_cancel: ::c_long = 231; +pub const SYS_set_tid_address: ::c_long = 232; +pub const SYS_exit_group: ::c_long = 234; +pub const SYS_lookup_dcookie: ::c_long = 235; +pub const SYS_epoll_create: ::c_long = 236; +pub const SYS_epoll_ctl: ::c_long = 237; +pub const SYS_epoll_wait: ::c_long = 238; +pub const SYS_remap_file_pages: ::c_long = 239; +pub const SYS_timer_create: ::c_long = 240; +pub const SYS_timer_settime: ::c_long = 241; +pub const SYS_timer_gettime: ::c_long = 242; +pub const SYS_timer_getoverrun: ::c_long = 243; +pub const SYS_timer_delete: ::c_long = 244; +pub const SYS_clock_settime: ::c_long = 245; +pub const SYS_clock_gettime: ::c_long = 246; +pub const SYS_clock_getres: ::c_long = 247; +pub const SYS_clock_nanosleep: ::c_long = 248; +pub const SYS_swapcontext: ::c_long = 249; +pub const SYS_tgkill: ::c_long = 250; +pub const SYS_utimes: ::c_long = 251; +pub const SYS_statfs64: ::c_long = 252; +pub const SYS_fstatfs64: ::c_long = 253; +pub const SYS_rtas: ::c_long = 255; +pub const SYS_sys_debug_setcontext: ::c_long = 256; +pub const SYS_migrate_pages: ::c_long = 258; +pub const SYS_mbind: ::c_long = 259; +pub const SYS_get_mempolicy: ::c_long = 260; +pub const SYS_set_mempolicy: ::c_long = 261; +pub const SYS_mq_open: ::c_long = 262; +pub const SYS_mq_unlink: ::c_long = 263; +pub const SYS_mq_timedsend: ::c_long = 264; +pub const SYS_mq_timedreceive: ::c_long = 265; +pub const SYS_mq_notify: ::c_long = 266; +pub const SYS_mq_getsetattr: ::c_long = 267; +pub const SYS_kexec_load: ::c_long = 268; +pub const SYS_add_key: ::c_long = 269; +pub const SYS_request_key: ::c_long = 270; +pub const SYS_keyctl: ::c_long = 271; +pub const SYS_waitid: ::c_long = 272; +pub const SYS_ioprio_set: ::c_long = 273; +pub const SYS_ioprio_get: ::c_long = 274; +pub const SYS_inotify_init: ::c_long = 275; +pub const SYS_inotify_add_watch: ::c_long = 276; +pub const SYS_inotify_rm_watch: ::c_long = 277; +pub const SYS_spu_run: ::c_long = 278; +pub const SYS_spu_create: ::c_long = 279; +pub const SYS_pselect6: ::c_long = 280; +pub const SYS_ppoll: ::c_long = 281; +pub const SYS_unshare: ::c_long = 282; +pub const SYS_splice: ::c_long = 283; +pub const SYS_tee: ::c_long = 284; +pub const SYS_vmsplice: ::c_long = 285; +pub const SYS_openat: ::c_long = 286; +pub const SYS_mkdirat: ::c_long = 287; +pub const SYS_mknodat: ::c_long = 288; +pub const SYS_fchownat: ::c_long = 289; +pub const SYS_futimesat: ::c_long = 290; +pub const SYS_newfstatat: ::c_long = 291; +pub const SYS_unlinkat: ::c_long = 292; +pub const SYS_renameat: ::c_long = 293; +pub const SYS_linkat: ::c_long = 294; +pub const SYS_symlinkat: ::c_long = 295; +pub const SYS_readlinkat: ::c_long = 296; +pub const SYS_fchmodat: ::c_long = 297; +pub const SYS_faccessat: ::c_long = 298; +pub const SYS_get_robust_list: ::c_long = 299; +pub const SYS_set_robust_list: ::c_long = 300; +pub const SYS_move_pages: ::c_long = 301; +pub const SYS_getcpu: ::c_long = 302; +pub const SYS_epoll_pwait: ::c_long = 303; +pub const SYS_utimensat: ::c_long = 304; +pub const SYS_signalfd: ::c_long = 305; +pub const SYS_timerfd_create: ::c_long = 306; +pub const SYS_eventfd: ::c_long = 307; +pub const SYS_sync_file_range2: ::c_long = 308; +pub const SYS_fallocate: ::c_long = 309; +pub const SYS_subpage_prot: ::c_long = 310; +pub const SYS_timerfd_settime: ::c_long = 311; +pub const SYS_timerfd_gettime: ::c_long = 312; +pub const SYS_signalfd4: ::c_long = 313; +pub const SYS_eventfd2: ::c_long = 314; +pub const SYS_epoll_create1: ::c_long = 315; +pub const SYS_dup3: ::c_long = 316; +pub const SYS_pipe2: ::c_long = 317; +pub const SYS_inotify_init1: ::c_long = 318; +pub const SYS_perf_event_open: ::c_long = 319; +pub const SYS_preadv: ::c_long = 320; +pub const SYS_pwritev: ::c_long = 321; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 322; +pub const SYS_fanotify_init: ::c_long = 323; +pub const SYS_fanotify_mark: ::c_long = 324; +pub const SYS_prlimit64: ::c_long = 325; +pub const SYS_socket: ::c_long = 326; +pub const SYS_bind: ::c_long = 327; +pub const SYS_connect: ::c_long = 328; +pub const SYS_listen: ::c_long = 329; +pub const SYS_accept: ::c_long = 330; +pub const SYS_getsockname: ::c_long = 331; +pub const SYS_getpeername: ::c_long = 332; +pub const SYS_socketpair: ::c_long = 333; +pub const SYS_send: ::c_long = 334; +pub const SYS_sendto: ::c_long = 335; +pub const SYS_recv: ::c_long = 336; +pub const SYS_recvfrom: ::c_long = 337; +pub const SYS_shutdown: ::c_long = 338; +pub const SYS_setsockopt: ::c_long = 339; +pub const SYS_getsockopt: ::c_long = 340; +pub const SYS_sendmsg: ::c_long = 341; +pub const SYS_recvmsg: ::c_long = 342; +pub const SYS_recvmmsg: ::c_long = 343; +pub const SYS_accept4: ::c_long = 344; +pub const SYS_name_to_handle_at: ::c_long = 345; +pub const SYS_open_by_handle_at: ::c_long = 346; +pub const SYS_clock_adjtime: ::c_long = 347; +pub const SYS_syncfs: ::c_long = 348; +pub const SYS_sendmmsg: ::c_long = 349; +pub const SYS_setns: ::c_long = 350; +pub const SYS_process_vm_readv: ::c_long = 351; +pub const SYS_process_vm_writev: ::c_long = 352; +pub const SYS_finit_module: ::c_long = 353; +pub const SYS_kcmp: ::c_long = 354; +pub const SYS_sched_setattr: ::c_long = 355; +pub const SYS_sched_getattr: ::c_long = 356; +pub const SYS_renameat2: ::c_long = 357; +pub const SYS_seccomp: ::c_long = 358; +pub const SYS_getrandom: ::c_long = 359; +pub const SYS_memfd_create: ::c_long = 360; +pub const SYS_bpf: ::c_long = 361; +pub const SYS_execveat: ::c_long = 362; +pub const SYS_switch_endian: ::c_long = 363; +pub const SYS_userfaultfd: ::c_long = 364; +pub const SYS_membarrier: ::c_long = 365; +pub const SYS_mlock2: ::c_long = 378; +pub const SYS_copy_file_range: ::c_long = 379; +pub const SYS_preadv2: ::c_long = 380; +pub const SYS_pwritev2: ::c_long = 381; +pub const SYS_kexec_file_load: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; + +#[link(name = "util")] +extern "C" { + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs new file mode 100644 index 0000000..c45c5b2 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -0,0 +1,861 @@ +//! RISC-V-specific definitions for 64-bit linux-like values + +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type wchar_t = ::c_int; +pub type time_t = ::c_long; + +pub type dev_t = ::c_ulong; +pub type uid_t = ::c_uint; +pub type gid_t = ::c_uint; +pub type ino_t = ::c_ulong; +pub type ino64_t = ::c_ulong; +pub type mode_t = ::c_uint; +pub type nlink_t = ::c_uint; +pub type off_t = ::c_long; +pub type off64_t = ::c_long; +pub type pid_t = ::c_int; +pub type blksize_t = ::c_int; +pub type blkcnt_t = ::c_long; +pub type fsblkcnt_t = ::c_ulong; +pub type fsblkcnt64_t = ::c_ulong; +pub type fsfilcnt_t = ::c_ulong; +pub type fsfilcnt64_t = ::c_ulong; +pub type suseconds_t = i64; +pub type __u64 = ::c_ulonglong; + +s! { + pub struct pthread_attr_t { + __size: [::c_ulong; 7], + } + + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: ::c_long, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub __pad1: dev_t, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub __pad2: ::c_int, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: ::c_long, + pub __unused: [::c_int; 2usize], + } + + pub struct stat64 { + pub st_dev: dev_t, + pub st_ino: ino64_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub __pad1: dev_t, + pub st_size: off64_t, + pub st_blksize: blksize_t, + pub __pad2: ::c_int, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: ::c_long, + pub __unused: [::c_int; 2], + } + + pub struct statfs { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsfilcnt_t, + pub f_ffree: fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_long, + pub f_frsize: ::c_long, + pub f_flags: ::c_long, + pub f_spare: [::c_long; 4], + } + + pub struct statfs64 { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_blocks: fsblkcnt64_t, + pub f_bfree: fsblkcnt64_t, + pub f_bavail: fsblkcnt64_t, + pub f_files: fsfilcnt64_t, + pub f_ffree: fsfilcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_long, + pub f_frsize: ::c_long, + pub f_flags: ::c_long, + pub f_spare: [::c_long; 4], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsfilcnt_t, + pub f_ffree: fsfilcnt_t, + pub f_favail: fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub __f_spare: [::c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: fsblkcnt64_t, + pub f_bfree: fsblkcnt64_t, + pub f_bavail: fsblkcnt64_t, + pub f_files: fsfilcnt64_t, + pub f_ffree: fsfilcnt64_t, + pub f_favail: fsfilcnt64_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub __f_spare: [::c_int; 6], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [u64; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t, + } + + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct sigset_t { + pub __val: [::c_ulong; 16], + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: uid_t, + pub gid: gid_t, + pub cuid: uid_t, + pub cgid: gid_t, + pub mode: ::c_ushort, + pub __pad1: ::c_ushort, + pub __seq: ::c_ushort, + pub __pad2: ::c_ushort, + pub __unused1: ::c_ulong, + pub __unused2: ::c_ulong, + } + + pub struct shmid_ds { + pub shm_perm: ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: time_t, + pub shm_dtime: time_t, + pub shm_ctime: time_t, + pub shm_cpid: pid_t, + pub shm_lpid: pid_t, + pub shm_nattch: ::shmatt_t, + pub __unused5: ::c_ulong, + pub __unused6: ::c_ulong, + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } +} + +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; +pub const VEOF: usize = 4; +pub const TIOCGSOFTCAR: ::c_ulong = 21529; +pub const TIOCSSOFTCAR: ::c_ulong = 21530; +pub const TIOCGRS485: ::c_int = 21550; +pub const TIOCSRS485: ::c_int = 21551; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 1052672; +pub const O_NOATIME: ::c_int = 262144; +pub const O_PATH: ::c_int = 2097152; +pub const O_TMPFILE: ::c_int = 4259840; +pub const MAP_GROWSDOWN: ::c_int = 256; +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; +pub const SOL_SOCKET: ::c_int = 1; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = 26; +pub const SO_PEERNAME: ::c_int = 28; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_PEERSEC: ::c_int = 31; +pub const SO_PASSSEC: ::c_int = 34; +pub const SO_TIMESTAMPNS: ::c_int = 35; +pub const SCM_TIMESTAMPNS: ::c_int = 35; +pub const SO_MARK: ::c_int = 36; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_WIFI_STATUS: ::c_int = 41; +pub const SCM_WIFI_STATUS: ::c_int = 41; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_NOFCS: ::c_int = 43; +pub const SO_LOCK_FILTER: ::c_int = 44; +pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; +pub const SO_BUSY_POLL: ::c_int = 46; +pub const SO_MAX_PACING_RATE: ::c_int = 47; +pub const SO_BPF_EXTENSIONS: ::c_int = 48; +pub const SO_INCOMING_CPU: ::c_int = 49; +pub const SO_ATTACH_BPF: ::c_int = 50; +pub const SO_DETACH_BPF: ::c_int = 27; +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SA_ONSTACK: ::c_int = 134217728; +pub const SA_SIGINFO: ::c_int = 4; +pub const SA_NOCLDWAIT: ::c_int = 2; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0; +pub const SIG_UNBLOCK: ::c_int = 1; +pub const POLLWRNORM: ::c_short = 256; +pub const POLLWRBAND: ::c_short = 512; +pub const O_ASYNC: ::c_int = 8192; +pub const O_NDELAY: ::c_int = 2048; +pub const PTRACE_DETACH: ::c_uint = 17; +pub const EFD_NONBLOCK: ::c_int = 2048; +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; +pub const SFD_NONBLOCK: ::c_int = 2048; +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; +pub const TIOCLINUX: ::c_ulong = 21532; +pub const TIOCGSERIAL: ::c_ulong = 21534; +pub const TIOCEXCL: ::c_ulong = 21516; +pub const TIOCNXCL: ::c_ulong = 21517; +pub const TIOCSCTTY: ::c_ulong = 21518; +pub const TIOCSTI: ::c_ulong = 21522; +pub const TIOCMGET: ::c_ulong = 21525; +pub const TIOCMBIS: ::c_ulong = 21526; +pub const TIOCMBIC: ::c_ulong = 21527; +pub const TIOCMSET: ::c_ulong = 21528; +pub const TIOCCONS: ::c_ulong = 21533; +pub const TIOCM_ST: ::c_int = 8; +pub const TIOCM_SR: ::c_int = 16; +pub const TIOCM_CTS: ::c_int = 32; +pub const TIOCM_CAR: ::c_int = 64; +pub const TIOCM_RNG: ::c_int = 128; +pub const TIOCM_DSR: ::c_int = 256; +pub const SFD_CLOEXEC: ::c_int = 524288; +pub const NCCS: usize = 32; +pub const O_TRUNC: ::c_int = 512; +pub const O_CLOEXEC: ::c_int = 524288; +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; +pub const SA_NODEFER: ::c_int = 1073741824; +pub const SA_RESETHAND: ::c_int = -2147483648; +pub const SA_RESTART: ::c_int = 268435456; +pub const SA_NOCLDSTOP: ::c_int = 1; +pub const EPOLL_CLOEXEC: ::c_int = 524288; +pub const EFD_CLOEXEC: ::c_int = 524288; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const O_DIRECT: ::c_int = 16384; +pub const O_DIRECTORY: ::c_int = 65536; +pub const O_NOFOLLOW: ::c_int = 131072; +pub const MAP_HUGETLB: ::c_int = 262144; +pub const MAP_LOCKED: ::c_int = 8192; +pub const MAP_NORESERVE: ::c_int = 16384; +pub const MAP_ANON: ::c_int = 32; +pub const MAP_ANONYMOUS: ::c_int = 32; +pub const MAP_DENYWRITE: ::c_int = 2048; +pub const MAP_EXECUTABLE: ::c_int = 4096; +pub const MAP_POPULATE: ::c_int = 32768; +pub const MAP_NONBLOCK: ::c_int = 65536; +pub const MAP_STACK: ::c_int = 131072; +pub const EDEADLOCK: ::c_int = 35; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const FIOCLEX: ::c_ulong = 21585; +pub const FIONCLEX: ::c_ulong = 21584; +pub const FIONBIO: ::c_ulong = 21537; +pub const MCL_CURRENT: ::c_int = 1; +pub const MCL_FUTURE: ::c_int = 2; +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const CBAUD: ::tcflag_t = 4111; +pub const TAB1: ::tcflag_t = 2048; +pub const TAB2: ::tcflag_t = 4096; +pub const TAB3: ::tcflag_t = 6144; +pub const CR1: ::tcflag_t = 512; +pub const CR2: ::tcflag_t = 1024; +pub const CR3: ::tcflag_t = 1536; +pub const FF1: ::tcflag_t = 32768; +pub const BS1: ::tcflag_t = 8192; +pub const VT1: ::tcflag_t = 16384; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 1024; +pub const IXOFF: ::tcflag_t = 4096; +pub const ONLCR: ::tcflag_t = 4; +pub const CSIZE: ::tcflag_t = 48; +pub const CS6: ::tcflag_t = 16; +pub const CS7: ::tcflag_t = 32; +pub const CS8: ::tcflag_t = 48; +pub const CSTOPB: ::tcflag_t = 64; +pub const CREAD: ::tcflag_t = 128; +pub const PARENB: ::tcflag_t = 256; +pub const PARODD: ::tcflag_t = 512; +pub const HUPCL: ::tcflag_t = 1024; +pub const CLOCAL: ::tcflag_t = 2048; +pub const ECHOKE: ::tcflag_t = 2048; +pub const ECHOE: ::tcflag_t = 16; +pub const ECHOK: ::tcflag_t = 32; +pub const ECHONL: ::tcflag_t = 64; +pub const ECHOPRT: ::tcflag_t = 1024; +pub const ECHOCTL: ::tcflag_t = 512; +pub const ISIG: ::tcflag_t = 1; +pub const ICANON: ::tcflag_t = 2; +pub const PENDIN: ::tcflag_t = 16384; +pub const NOFLSH: ::tcflag_t = 128; +pub const CIBAUD: ::tcflag_t = 269418496; +pub const CBAUDEX: ::tcflag_t = 4096; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 2; +pub const NLDLY: ::tcflag_t = 256; +pub const CRDLY: ::tcflag_t = 1536; +pub const TABDLY: ::tcflag_t = 6144; +pub const BSDLY: ::tcflag_t = 8192; +pub const FFDLY: ::tcflag_t = 32768; +pub const VTDLY: ::tcflag_t = 16384; +pub const XTABS: ::tcflag_t = 6144; +pub const B0: ::speed_t = 0; +pub const B50: ::speed_t = 1; +pub const B75: ::speed_t = 2; +pub const B110: ::speed_t = 3; +pub const B134: ::speed_t = 4; +pub const B150: ::speed_t = 5; +pub const B200: ::speed_t = 6; +pub const B300: ::speed_t = 7; +pub const B600: ::speed_t = 8; +pub const B1200: ::speed_t = 9; +pub const B1800: ::speed_t = 10; +pub const B2400: ::speed_t = 11; +pub const B4800: ::speed_t = 12; +pub const B9600: ::speed_t = 13; +pub const B19200: ::speed_t = 14; +pub const B38400: ::speed_t = 15; +pub const EXTA: ::speed_t = 14; +pub const EXTB: ::speed_t = 15; +pub const B57600: ::speed_t = 4097; +pub const B115200: ::speed_t = 4098; +pub const B230400: ::speed_t = 4099; +pub const B460800: ::speed_t = 4100; +pub const B500000: ::speed_t = 4101; +pub const B576000: ::speed_t = 4102; +pub const B921600: ::speed_t = 4103; +pub const B1000000: ::speed_t = 4104; +pub const B1152000: ::speed_t = 4105; +pub const B1500000: ::speed_t = 4106; +pub const B2000000: ::speed_t = 4107; +pub const B2500000: ::speed_t = 4108; +pub const B3000000: ::speed_t = 4109; +pub const B3500000: ::speed_t = 4110; +pub const B4000000: ::speed_t = 4111; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 32768; +pub const TOSTOP: ::tcflag_t = 256; +pub const FLUSHO: ::tcflag_t = 4096; +pub const EXTPROC: ::tcflag_t = 65536; +pub const TCGETS: ::c_ulong = 21505; +pub const TCSETS: ::c_ulong = 21506; +pub const TCSETSW: ::c_ulong = 21507; +pub const TCSETSF: ::c_ulong = 21508; +pub const TCGETA: ::c_ulong = 21509; +pub const TCSETA: ::c_ulong = 21510; +pub const TCSETAW: ::c_ulong = 21511; +pub const TCSETAF: ::c_ulong = 21512; +pub const TCSBRK: ::c_ulong = 21513; +pub const TCXONC: ::c_ulong = 21514; +pub const TCFLSH: ::c_ulong = 21515; +pub const TIOCINQ: ::c_ulong = 21531; +pub const TIOCGPGRP: ::c_ulong = 21519; +pub const TIOCSPGRP: ::c_ulong = 21520; +pub const TIOCOUTQ: ::c_ulong = 21521; +pub const TIOCGWINSZ: ::c_ulong = 21523; +pub const TIOCSWINSZ: ::c_ulong = 21524; +pub const FIONREAD: ::c_ulong = 21531; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const SYS_read: ::c_long = 63; +pub const SYS_write: ::c_long = 64; +pub const SYS_close: ::c_long = 57; +pub const SYS_fstat: ::c_long = 80; +pub const SYS_lseek: ::c_long = 62; +pub const SYS_mmap: ::c_long = 222; +pub const SYS_mprotect: ::c_long = 226; +pub const SYS_munmap: ::c_long = 215; +pub const SYS_brk: ::c_long = 214; +pub const SYS_rt_sigaction: ::c_long = 134; +pub const SYS_rt_sigprocmask: ::c_long = 135; +pub const SYS_rt_sigreturn: ::c_long = 139; +pub const SYS_ioctl: ::c_long = 29; +pub const SYS_pread64: ::c_long = 67; +pub const SYS_pwrite64: ::c_long = 68; +pub const SYS_readv: ::c_long = 65; +pub const SYS_writev: ::c_long = 66; +pub const SYS_sched_yield: ::c_long = 124; +pub const SYS_mremap: ::c_long = 216; +pub const SYS_msync: ::c_long = 227; +pub const SYS_mincore: ::c_long = 232; +pub const SYS_madvise: ::c_long = 233; +pub const SYS_shmget: ::c_long = 194; +pub const SYS_shmat: ::c_long = 196; +pub const SYS_shmctl: ::c_long = 195; +pub const SYS_dup: ::c_long = 23; +pub const SYS_nanosleep: ::c_long = 101; +pub const SYS_getitimer: ::c_long = 102; +pub const SYS_setitimer: ::c_long = 103; +pub const SYS_getpid: ::c_long = 172; +pub const SYS_sendfile: ::c_long = 71; +pub const SYS_socket: ::c_long = 198; +pub const SYS_connect: ::c_long = 203; +pub const SYS_accept: ::c_long = 202; +pub const SYS_sendto: ::c_long = 206; +pub const SYS_recvfrom: ::c_long = 207; +pub const SYS_sendmsg: ::c_long = 211; +pub const SYS_recvmsg: ::c_long = 212; +pub const SYS_shutdown: ::c_long = 210; +pub const SYS_bind: ::c_long = 200; +pub const SYS_listen: ::c_long = 201; +pub const SYS_getsockname: ::c_long = 204; +pub const SYS_getpeername: ::c_long = 205; +pub const SYS_socketpair: ::c_long = 199; +pub const SYS_setsockopt: ::c_long = 208; +pub const SYS_getsockopt: ::c_long = 209; +pub const SYS_clone: ::c_long = 220; +pub const SYS_execve: ::c_long = 221; +pub const SYS_exit: ::c_long = 93; +pub const SYS_wait4: ::c_long = 260; +pub const SYS_kill: ::c_long = 129; +pub const SYS_uname: ::c_long = 160; +pub const SYS_semget: ::c_long = 190; +pub const SYS_semop: ::c_long = 193; +pub const SYS_semctl: ::c_long = 191; +pub const SYS_shmdt: ::c_long = 197; +pub const SYS_msgget: ::c_long = 186; +pub const SYS_msgsnd: ::c_long = 189; +pub const SYS_msgrcv: ::c_long = 188; +pub const SYS_msgctl: ::c_long = 187; +pub const SYS_fcntl: ::c_long = 25; +pub const SYS_flock: ::c_long = 32; +pub const SYS_fsync: ::c_long = 82; +pub const SYS_fdatasync: ::c_long = 83; +pub const SYS_truncate: ::c_long = 45; +pub const SYS_ftruncate: ::c_long = 46; +pub const SYS_getcwd: ::c_long = 17; +pub const SYS_chdir: ::c_long = 49; +pub const SYS_fchdir: ::c_long = 50; +pub const SYS_fchmod: ::c_long = 52; +pub const SYS_fchown: ::c_long = 55; +pub const SYS_umask: ::c_long = 166; +pub const SYS_gettimeofday: ::c_long = 169; +pub const SYS_getrlimit: ::c_long = 163; +pub const SYS_getrusage: ::c_long = 165; +pub const SYS_sysinfo: ::c_long = 179; +pub const SYS_times: ::c_long = 153; +pub const SYS_ptrace: ::c_long = 117; +pub const SYS_getuid: ::c_long = 174; +pub const SYS_syslog: ::c_long = 116; +pub const SYS_getgid: ::c_long = 176; +pub const SYS_setuid: ::c_long = 146; +pub const SYS_setgid: ::c_long = 144; +pub const SYS_geteuid: ::c_long = 175; +pub const SYS_getegid: ::c_long = 177; +pub const SYS_setpgid: ::c_long = 154; +pub const SYS_getppid: ::c_long = 173; +pub const SYS_setsid: ::c_long = 157; +pub const SYS_setreuid: ::c_long = 145; +pub const SYS_setregid: ::c_long = 143; +pub const SYS_getgroups: ::c_long = 158; +pub const SYS_setgroups: ::c_long = 159; +pub const SYS_setresuid: ::c_long = 147; +pub const SYS_getresuid: ::c_long = 148; +pub const SYS_setresgid: ::c_long = 149; +pub const SYS_getresgid: ::c_long = 150; +pub const SYS_getpgid: ::c_long = 155; +pub const SYS_setfsuid: ::c_long = 151; +pub const SYS_setfsgid: ::c_long = 152; +pub const SYS_getsid: ::c_long = 156; +pub const SYS_capget: ::c_long = 90; +pub const SYS_capset: ::c_long = 91; +pub const SYS_rt_sigpending: ::c_long = 136; +pub const SYS_rt_sigtimedwait: ::c_long = 137; +pub const SYS_rt_sigqueueinfo: ::c_long = 138; +pub const SYS_rt_sigsuspend: ::c_long = 133; +pub const SYS_sigaltstack: ::c_long = 132; +pub const SYS_personality: ::c_long = 92; +pub const SYS_statfs: ::c_long = 43; +pub const SYS_fstatfs: ::c_long = 44; +pub const SYS_getpriority: ::c_long = 141; +pub const SYS_setpriority: ::c_long = 140; +pub const SYS_sched_setparam: ::c_long = 118; +pub const SYS_sched_getparam: ::c_long = 121; +pub const SYS_sched_setscheduler: ::c_long = 119; +pub const SYS_sched_getscheduler: ::c_long = 120; +pub const SYS_sched_get_priority_max: ::c_long = 125; +pub const SYS_sched_get_priority_min: ::c_long = 126; +pub const SYS_sched_rr_get_interval: ::c_long = 127; +pub const SYS_mlock: ::c_long = 228; +pub const SYS_munlock: ::c_long = 229; +pub const SYS_mlockall: ::c_long = 230; +pub const SYS_munlockall: ::c_long = 231; +pub const SYS_vhangup: ::c_long = 58; +pub const SYS_pivot_root: ::c_long = 41; +pub const SYS_prctl: ::c_long = 167; +pub const SYS_adjtimex: ::c_long = 171; +pub const SYS_setrlimit: ::c_long = 164; +pub const SYS_chroot: ::c_long = 51; +pub const SYS_sync: ::c_long = 81; +pub const SYS_acct: ::c_long = 89; +pub const SYS_settimeofday: ::c_long = 170; +pub const SYS_mount: ::c_long = 40; +pub const SYS_umount2: ::c_long = 39; +pub const SYS_swapon: ::c_long = 224; +pub const SYS_swapoff: ::c_long = 225; +pub const SYS_reboot: ::c_long = 142; +pub const SYS_sethostname: ::c_long = 161; +pub const SYS_setdomainname: ::c_long = 162; +pub const SYS_init_module: ::c_long = 105; +pub const SYS_delete_module: ::c_long = 106; +pub const SYS_quotactl: ::c_long = 60; +pub const SYS_nfsservctl: ::c_long = 42; +pub const SYS_gettid: ::c_long = 178; +pub const SYS_readahead: ::c_long = 213; +pub const SYS_setxattr: ::c_long = 5; +pub const SYS_lsetxattr: ::c_long = 6; +pub const SYS_fsetxattr: ::c_long = 7; +pub const SYS_getxattr: ::c_long = 8; +pub const SYS_lgetxattr: ::c_long = 9; +pub const SYS_fgetxattr: ::c_long = 10; +pub const SYS_listxattr: ::c_long = 11; +pub const SYS_llistxattr: ::c_long = 12; +pub const SYS_flistxattr: ::c_long = 13; +pub const SYS_removexattr: ::c_long = 14; +pub const SYS_lremovexattr: ::c_long = 15; +pub const SYS_fremovexattr: ::c_long = 16; +pub const SYS_tkill: ::c_long = 130; +pub const SYS_futex: ::c_long = 98; +pub const SYS_sched_setaffinity: ::c_long = 122; +pub const SYS_sched_getaffinity: ::c_long = 123; +pub const SYS_io_setup: ::c_long = 0; +pub const SYS_io_destroy: ::c_long = 1; +pub const SYS_io_getevents: ::c_long = 4; +pub const SYS_io_submit: ::c_long = 2; +pub const SYS_io_cancel: ::c_long = 3; +pub const SYS_lookup_dcookie: ::c_long = 18; +pub const SYS_remap_file_pages: ::c_long = 234; +pub const SYS_getdents64: ::c_long = 61; +pub const SYS_set_tid_address: ::c_long = 96; +pub const SYS_restart_syscall: ::c_long = 128; +pub const SYS_semtimedop: ::c_long = 192; +pub const SYS_fadvise64: ::c_long = 223; +pub const SYS_timer_create: ::c_long = 107; +pub const SYS_timer_settime: ::c_long = 110; +pub const SYS_timer_gettime: ::c_long = 108; +pub const SYS_timer_getoverrun: ::c_long = 109; +pub const SYS_timer_delete: ::c_long = 111; +pub const SYS_clock_settime: ::c_long = 112; +pub const SYS_clock_gettime: ::c_long = 113; +pub const SYS_clock_getres: ::c_long = 114; +pub const SYS_clock_nanosleep: ::c_long = 115; +pub const SYS_exit_group: ::c_long = 94; +pub const SYS_epoll_ctl: ::c_long = 21; +pub const SYS_tgkill: ::c_long = 131; +pub const SYS_mbind: ::c_long = 235; +pub const SYS_set_mempolicy: ::c_long = 237; +pub const SYS_get_mempolicy: ::c_long = 236; +pub const SYS_mq_open: ::c_long = 180; +pub const SYS_mq_unlink: ::c_long = 181; +pub const SYS_mq_timedsend: ::c_long = 182; +pub const SYS_mq_timedreceive: ::c_long = 183; +pub const SYS_mq_notify: ::c_long = 184; +pub const SYS_mq_getsetattr: ::c_long = 185; +pub const SYS_kexec_load: ::c_long = 104; +pub const SYS_waitid: ::c_long = 95; +pub const SYS_add_key: ::c_long = 217; +pub const SYS_request_key: ::c_long = 218; +pub const SYS_keyctl: ::c_long = 219; +pub const SYS_ioprio_set: ::c_long = 30; +pub const SYS_ioprio_get: ::c_long = 31; +pub const SYS_inotify_add_watch: ::c_long = 27; +pub const SYS_inotify_rm_watch: ::c_long = 28; +pub const SYS_migrate_pages: ::c_long = 238; +pub const SYS_openat: ::c_long = 56; +pub const SYS_mkdirat: ::c_long = 34; +pub const SYS_mknodat: ::c_long = 33; +pub const SYS_fchownat: ::c_long = 54; +pub const SYS_newfstatat: ::c_long = 79; +pub const SYS_unlinkat: ::c_long = 35; +pub const SYS_linkat: ::c_long = 37; +pub const SYS_symlinkat: ::c_long = 36; +pub const SYS_readlinkat: ::c_long = 78; +pub const SYS_fchmodat: ::c_long = 53; +pub const SYS_faccessat: ::c_long = 48; +pub const SYS_pselect6: ::c_long = 72; +pub const SYS_ppoll: ::c_long = 73; +pub const SYS_unshare: ::c_long = 97; +pub const SYS_set_robust_list: ::c_long = 99; +pub const SYS_get_robust_list: ::c_long = 100; +pub const SYS_splice: ::c_long = 76; +pub const SYS_tee: ::c_long = 77; +pub const SYS_sync_file_range: ::c_long = 84; +pub const SYS_vmsplice: ::c_long = 75; +pub const SYS_move_pages: ::c_long = 239; +pub const SYS_utimensat: ::c_long = 88; +pub const SYS_epoll_pwait: ::c_long = 22; +pub const SYS_timerfd_create: ::c_long = 85; +pub const SYS_fallocate: ::c_long = 47; +pub const SYS_timerfd_settime: ::c_long = 86; +pub const SYS_timerfd_gettime: ::c_long = 87; +pub const SYS_accept4: ::c_long = 242; +pub const SYS_signalfd4: ::c_long = 74; +pub const SYS_eventfd2: ::c_long = 19; +pub const SYS_epoll_create1: ::c_long = 20; +pub const SYS_dup3: ::c_long = 24; +pub const SYS_pipe2: ::c_long = 59; +pub const SYS_inotify_init1: ::c_long = 26; +pub const SYS_preadv: ::c_long = 69; +pub const SYS_pwritev: ::c_long = 70; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 240; +pub const SYS_perf_event_open: ::c_long = 241; +pub const SYS_recvmmsg: ::c_long = 243; +pub const SYS_fanotify_init: ::c_long = 262; +pub const SYS_fanotify_mark: ::c_long = 263; +pub const SYS_prlimit64: ::c_long = 261; +pub const SYS_name_to_handle_at: ::c_long = 264; +pub const SYS_open_by_handle_at: ::c_long = 265; +pub const SYS_clock_adjtime: ::c_long = 266; +pub const SYS_syncfs: ::c_long = 267; +pub const SYS_sendmmsg: ::c_long = 269; +pub const SYS_setns: ::c_long = 268; +pub const SYS_getcpu: ::c_long = 168; +pub const SYS_process_vm_readv: ::c_long = 270; +pub const SYS_process_vm_writev: ::c_long = 271; +pub const SYS_kcmp: ::c_long = 272; +pub const SYS_finit_module: ::c_long = 273; +pub const SYS_sched_setattr: ::c_long = 274; +pub const SYS_sched_getattr: ::c_long = 275; +pub const SYS_renameat2: ::c_long = 276; +pub const SYS_seccomp: ::c_long = 277; +pub const SYS_getrandom: ::c_long = 278; +pub const SYS_memfd_create: ::c_long = 279; +pub const SYS_bpf: ::c_long = 280; +pub const SYS_execveat: ::c_long = 281; +pub const SYS_userfaultfd: ::c_long = 282; +pub const SYS_membarrier: ::c_long = 283; +pub const SYS_mlock2: ::c_long = 284; +pub const SYS_copy_file_range: ::c_long = 285; +pub const SYS_preadv2: ::c_long = 286; +pub const SYS_pwritev2: ::c_long = 287; +pub const SYS_pkey_mprotect: ::c_long = 288; +pub const SYS_pkey_alloc: ::c_long = 289; +pub const SYS_pkey_free: ::c_long = 290; +pub const SYS_statx: ::c_long = 291; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/s390x.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/s390x.rs new file mode 100644 index 0000000..cf0612a --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -0,0 +1,1029 @@ +//! s390x + +use pthread_mutex_t; + +pub type blksize_t = i64; +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type nlink_t = u64; +pub type suseconds_t = i64; +pub type wchar_t = i32; +pub type greg_t = u64; +pub type __u64 = u64; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + __glibc_reserved0: ::c_int, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + pub sa_mask: ::sigset_t, + } + + pub struct statfs { + pub f_type: ::c_uint, + pub f_bsize: ::c_uint, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_uint, + pub f_frsize: ::c_uint, + pub f_flags: ::c_uint, + f_spare: [::c_uint; 4], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + _pad: ::c_int, + _pad2: [::c_long; 14], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + __glibc_reserved: [::c_long; 3], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + __glibc_reserved: [::c_long; 3], + } + + pub struct pthread_attr_t { + __size: [::c_ulong; 7] + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_ushort, + __pad1: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused4: ::c_ulong, + __unused5: ::c_ulong + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } + + pub struct __psw_t { + pub mask: u64, + pub addr: u64, + } + + pub struct fpregset_t { + pub fpc: u32, + __pad: u32, + pub fprs: [fpreg_t; 16], + } + + pub struct mcontext_t { + pub psw: __psw_t, + pub gregs: [u64; 16], + pub aregs: [u32; 16], + pub fpregs: fpregset_t, + } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + } + + pub struct statfs64 { + pub f_type: ::c_uint, + pub f_bsize: ::c_uint, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_uint, + pub f_frsize: ::c_uint, + pub f_flags: ::c_uint, + pub f_spare: [::c_uint; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } +} + +s_no_extra_traits! { + // FIXME: This is actually a union. + pub struct fpreg_t { + pub d: ::c_double, + // f: ::c_float, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for fpreg_t { + fn eq(&self, other: &fpreg_t) -> bool { + self.d == other.d + } + } + + impl Eq for fpreg_t {} + + impl ::fmt::Debug for fpreg_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("fpreg_t") + .field("d", &self.d) + .finish() + } + } + + impl ::hash::Hash for fpreg_t { + fn hash(&self, state: &mut H) { + let d: u64 = unsafe { ::mem::transmute(self.d) }; + d.hash(state); + } + } + } +} + +pub const POSIX_FADV_DONTNEED: ::c_int = 6; +pub const POSIX_FADV_NOREUSE: ::c_int = 7; + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const SFD_CLOEXEC: ::c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: ::c_int = 512; +pub const O_NOATIME: ::c_int = 0o1000000; +pub const O_CLOEXEC: ::c_int = 0x80000; +pub const O_PATH: ::c_int = 0o10000000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + +align_const! { + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNREFUSED: ::c_int = 111; +pub const ECONNRESET: ::c_int = 104; +pub const EDEADLK: ::c_int = 35; +pub const ENOSYS: ::c_int = 38; +pub const ENOTCONN: ::c_int = 107; +pub const ETIMEDOUT: ::c_int = 110; +pub const FIOCLEX: ::c_ulong = 0x5451; +pub const FIONCLEX: ::c_ulong = 0x5450; +pub const FIONBIO: ::c_ulong = 0x5421; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NONBLOCK: ::c_int = 2048; +pub const SA_NOCLDWAIT: ::c_int = 2; +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 4; +pub const SIGBUS: ::c_int = 7; +pub const SIGSTKSZ: ::size_t = 0x2000; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const SIG_SETMASK: ::c_int = 2; +pub const SOL_SOCKET: ::c_int = 1; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_ERROR: ::c_int = 4; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_MARK: ::c_int = 36; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_BUSY_POLL: ::c_int = 46; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; + +pub const O_NOCTTY: ::c_int = 256; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 0x101000; +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const EDEADLOCK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SO_TYPE: ::c_int = 3; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; + +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGCHLD: ::c_int = 17; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = 31; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_NDELAY: ::c_int = 0x800; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; + +pub const EXTPROC: ::tcflag_t = 0x00010000; + +pub const PTRACE_DETACH: ::c_uint = 17; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const EFD_NONBLOCK: ::c_int = 0x800; + +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; + +pub const SFD_NONBLOCK: ::c_int = 0x0800; + +pub const TCGETS: ::c_ulong = 0x5401; +pub const TCSETS: ::c_ulong = 0x5402; +pub const TCSETSW: ::c_ulong = 0x5403; +pub const TCSETSF: ::c_ulong = 0x5404; +pub const TCGETA: ::c_ulong = 0x5405; +pub const TCSETA: ::c_ulong = 0x5406; +pub const TCSETAW: ::c_ulong = 0x5407; +pub const TCSETAF: ::c_ulong = 0x5408; +pub const TCSBRK: ::c_ulong = 0x5409; +pub const TCXONC: ::c_ulong = 0x540A; +pub const TCFLSH: ::c_ulong = 0x540B; +pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; +pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; +pub const TIOCINQ: ::c_ulong = 0x541B; +pub const TIOCEXCL: ::c_ulong = 0x540C; +pub const TIOCNXCL: ::c_ulong = 0x540D; +pub const TIOCSCTTY: ::c_ulong = 0x540E; +pub const TIOCGPGRP: ::c_ulong = 0x540F; +pub const TIOCSPGRP: ::c_ulong = 0x5410; +pub const TIOCOUTQ: ::c_ulong = 0x5411; +pub const TIOCSTI: ::c_ulong = 0x5412; +pub const TIOCGWINSZ: ::c_ulong = 0x5413; +pub const TIOCSWINSZ: ::c_ulong = 0x5414; +pub const TIOCMGET: ::c_ulong = 0x5415; +pub const TIOCMBIS: ::c_ulong = 0x5416; +pub const TIOCMBIC: ::c_ulong = 0x5417; +pub const TIOCMSET: ::c_ulong = 0x5418; +pub const FIONREAD: ::c_ulong = 0x541B; +pub const TIOCCONS: ::c_ulong = 0x541D; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCLINUX: ::c_ulong = 0x541C; +pub const TIOCGSERIAL: ::c_ulong = 0x541E; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const VTIME: usize = 5; +pub const VSWTC: usize = 7; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; +pub const VREPRINT: usize = 12; +pub const VDISCARD: usize = 13; +pub const VWERASE: usize = 14; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const ONLCR: ::tcflag_t = 0o000004; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const FF1: ::tcflag_t = 0x00008000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const CBAUD: ::speed_t = 0o010017; +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const CSIZE: ::tcflag_t = 0o000060; +pub const CS6: ::tcflag_t = 0o000020; +pub const CS7: ::tcflag_t = 0o000040; +pub const CS8: ::tcflag_t = 0o000060; +pub const CSTOPB: ::tcflag_t = 0o000100; +pub const CREAD: ::tcflag_t = 0o000200; +pub const PARENB: ::tcflag_t = 0o000400; +pub const PARODD: ::tcflag_t = 0o001000; +pub const HUPCL: ::tcflag_t = 0o002000; +pub const CLOCAL: ::tcflag_t = 0o004000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const BOTHER: ::speed_t = 0o010000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; +pub const CIBAUD: ::tcflag_t = 0o02003600000; + +pub const ISIG: ::tcflag_t = 0o000001; +pub const ICANON: ::tcflag_t = 0o000002; +pub const XCASE: ::tcflag_t = 0o000004; +pub const ECHOE: ::tcflag_t = 0o000020; +pub const ECHOK: ::tcflag_t = 0o000040; +pub const ECHONL: ::tcflag_t = 0o000100; +pub const NOFLSH: ::tcflag_t = 0o000200; +pub const ECHOCTL: ::tcflag_t = 0o001000; +pub const ECHOPRT: ::tcflag_t = 0o002000; +pub const ECHOKE: ::tcflag_t = 0o004000; +pub const PENDIN: ::tcflag_t = 0o040000; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const IXON: ::tcflag_t = 0o002000; +pub const IXOFF: ::tcflag_t = 0o010000; + +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_restart_syscall: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_umount: ::c_long = 22; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_brk: ::c_long = 45; +pub const SYS_signal: ::c_long = 48; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_readdir: ::c_long = 89; +pub const SYS_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_lookup_dcookie: ::c_long = 110; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_idle: ::c_long = 112; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_afs_syscall: ::c_long = 137; /* Syscall for Andrew File System */ +pub const SYS_getdents: ::c_long = 141; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_query_module: ::c_long = 167; +pub const SYS_poll: ::c_long = 168; +pub const SYS_nfsservctl: ::c_long = 169; +pub const SYS_prctl: ::c_long = 172; +pub const SYS_rt_sigreturn: ::c_long = 173; +pub const SYS_rt_sigaction: ::c_long = 174; +pub const SYS_rt_sigprocmask: ::c_long = 175; +pub const SYS_rt_sigpending: ::c_long = 176; +pub const SYS_rt_sigtimedwait: ::c_long = 177; +pub const SYS_rt_sigqueueinfo: ::c_long = 178; +pub const SYS_rt_sigsuspend: ::c_long = 179; +pub const SYS_pread64: ::c_long = 180; +pub const SYS_pwrite64: ::c_long = 181; +pub const SYS_getcwd: ::c_long = 183; +pub const SYS_capget: ::c_long = 184; +pub const SYS_capset: ::c_long = 185; +pub const SYS_sigaltstack: ::c_long = 186; +pub const SYS_sendfile: ::c_long = 187; +pub const SYS_getpmsg: ::c_long = 188; +pub const SYS_putpmsg: ::c_long = 189; +pub const SYS_vfork: ::c_long = 190; +pub const SYS_pivot_root: ::c_long = 217; +pub const SYS_mincore: ::c_long = 218; +pub const SYS_madvise: ::c_long = 219; +pub const SYS_getdents64: ::c_long = 220; +pub const SYS_readahead: ::c_long = 222; +pub const SYS_setxattr: ::c_long = 224; +pub const SYS_lsetxattr: ::c_long = 225; +pub const SYS_fsetxattr: ::c_long = 226; +pub const SYS_getxattr: ::c_long = 227; +pub const SYS_lgetxattr: ::c_long = 228; +pub const SYS_fgetxattr: ::c_long = 229; +pub const SYS_listxattr: ::c_long = 230; +pub const SYS_llistxattr: ::c_long = 231; +pub const SYS_flistxattr: ::c_long = 232; +pub const SYS_removexattr: ::c_long = 233; +pub const SYS_lremovexattr: ::c_long = 234; +pub const SYS_fremovexattr: ::c_long = 235; +pub const SYS_gettid: ::c_long = 236; +pub const SYS_tkill: ::c_long = 237; +pub const SYS_futex: ::c_long = 238; +pub const SYS_sched_setaffinity: ::c_long = 239; +pub const SYS_sched_getaffinity: ::c_long = 240; +pub const SYS_tgkill: ::c_long = 241; +pub const SYS_io_setup: ::c_long = 243; +pub const SYS_io_destroy: ::c_long = 244; +pub const SYS_io_getevents: ::c_long = 245; +pub const SYS_io_submit: ::c_long = 246; +pub const SYS_io_cancel: ::c_long = 247; +pub const SYS_exit_group: ::c_long = 248; +pub const SYS_epoll_create: ::c_long = 249; +pub const SYS_epoll_ctl: ::c_long = 250; +pub const SYS_epoll_wait: ::c_long = 251; +pub const SYS_set_tid_address: ::c_long = 252; +pub const SYS_fadvise64: ::c_long = 253; +pub const SYS_timer_create: ::c_long = 254; +pub const SYS_timer_settime: ::c_long = 255; +pub const SYS_timer_gettime: ::c_long = 256; +pub const SYS_timer_getoverrun: ::c_long = 257; +pub const SYS_timer_delete: ::c_long = 258; +pub const SYS_clock_settime: ::c_long = 259; +pub const SYS_clock_gettime: ::c_long = 260; +pub const SYS_clock_getres: ::c_long = 261; +pub const SYS_clock_nanosleep: ::c_long = 262; +pub const SYS_statfs64: ::c_long = 265; +pub const SYS_fstatfs64: ::c_long = 266; +pub const SYS_remap_file_pages: ::c_long = 267; +pub const SYS_mbind: ::c_long = 268; +pub const SYS_get_mempolicy: ::c_long = 269; +pub const SYS_set_mempolicy: ::c_long = 270; +pub const SYS_mq_open: ::c_long = 271; +pub const SYS_mq_unlink: ::c_long = 272; +pub const SYS_mq_timedsend: ::c_long = 273; +pub const SYS_mq_timedreceive: ::c_long = 274; +pub const SYS_mq_notify: ::c_long = 275; +pub const SYS_mq_getsetattr: ::c_long = 276; +pub const SYS_kexec_load: ::c_long = 277; +pub const SYS_add_key: ::c_long = 278; +pub const SYS_request_key: ::c_long = 279; +pub const SYS_keyctl: ::c_long = 280; +pub const SYS_waitid: ::c_long = 281; +pub const SYS_ioprio_set: ::c_long = 282; +pub const SYS_ioprio_get: ::c_long = 283; +pub const SYS_inotify_init: ::c_long = 284; +pub const SYS_inotify_add_watch: ::c_long = 285; +pub const SYS_inotify_rm_watch: ::c_long = 286; +pub const SYS_migrate_pages: ::c_long = 287; +pub const SYS_openat: ::c_long = 288; +pub const SYS_mkdirat: ::c_long = 289; +pub const SYS_mknodat: ::c_long = 290; +pub const SYS_fchownat: ::c_long = 291; +pub const SYS_futimesat: ::c_long = 292; +pub const SYS_unlinkat: ::c_long = 294; +pub const SYS_renameat: ::c_long = 295; +pub const SYS_linkat: ::c_long = 296; +pub const SYS_symlinkat: ::c_long = 297; +pub const SYS_readlinkat: ::c_long = 298; +pub const SYS_fchmodat: ::c_long = 299; +pub const SYS_faccessat: ::c_long = 300; +pub const SYS_pselect6: ::c_long = 301; +pub const SYS_ppoll: ::c_long = 302; +pub const SYS_unshare: ::c_long = 303; +pub const SYS_set_robust_list: ::c_long = 304; +pub const SYS_get_robust_list: ::c_long = 305; +pub const SYS_splice: ::c_long = 306; +pub const SYS_sync_file_range: ::c_long = 307; +pub const SYS_tee: ::c_long = 308; +pub const SYS_vmsplice: ::c_long = 309; +pub const SYS_move_pages: ::c_long = 310; +pub const SYS_getcpu: ::c_long = 311; +pub const SYS_epoll_pwait: ::c_long = 312; +pub const SYS_utimes: ::c_long = 313; +pub const SYS_fallocate: ::c_long = 314; +pub const SYS_utimensat: ::c_long = 315; +pub const SYS_signalfd: ::c_long = 316; +pub const SYS_timerfd: ::c_long = 317; +pub const SYS_eventfd: ::c_long = 318; +pub const SYS_timerfd_create: ::c_long = 319; +pub const SYS_timerfd_settime: ::c_long = 320; +pub const SYS_timerfd_gettime: ::c_long = 321; +pub const SYS_signalfd4: ::c_long = 322; +pub const SYS_eventfd2: ::c_long = 323; +pub const SYS_inotify_init1: ::c_long = 324; +pub const SYS_pipe2: ::c_long = 325; +pub const SYS_dup3: ::c_long = 326; +pub const SYS_epoll_create1: ::c_long = 327; +pub const SYS_preadv: ::c_long = 328; +pub const SYS_pwritev: ::c_long = 329; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 330; +pub const SYS_perf_event_open: ::c_long = 331; +pub const SYS_fanotify_init: ::c_long = 332; +pub const SYS_fanotify_mark: ::c_long = 333; +pub const SYS_prlimit64: ::c_long = 334; +pub const SYS_name_to_handle_at: ::c_long = 335; +pub const SYS_open_by_handle_at: ::c_long = 336; +pub const SYS_clock_adjtime: ::c_long = 337; +pub const SYS_syncfs: ::c_long = 338; +pub const SYS_setns: ::c_long = 339; +pub const SYS_process_vm_readv: ::c_long = 340; +pub const SYS_process_vm_writev: ::c_long = 341; +pub const SYS_s390_runtime_instr: ::c_long = 342; +pub const SYS_kcmp: ::c_long = 343; +pub const SYS_finit_module: ::c_long = 344; +pub const SYS_sched_setattr: ::c_long = 345; +pub const SYS_sched_getattr: ::c_long = 346; +pub const SYS_renameat2: ::c_long = 347; +pub const SYS_seccomp: ::c_long = 348; +pub const SYS_getrandom: ::c_long = 349; +pub const SYS_memfd_create: ::c_long = 350; +pub const SYS_bpf: ::c_long = 351; +pub const SYS_s390_pci_mmio_write: ::c_long = 352; +pub const SYS_s390_pci_mmio_read: ::c_long = 353; +pub const SYS_execveat: ::c_long = 354; +pub const SYS_userfaultfd: ::c_long = 355; +pub const SYS_membarrier: ::c_long = 356; +pub const SYS_recvmmsg: ::c_long = 357; +pub const SYS_sendmmsg: ::c_long = 358; +pub const SYS_socket: ::c_long = 359; +pub const SYS_socketpair: ::c_long = 360; +pub const SYS_bind: ::c_long = 361; +pub const SYS_connect: ::c_long = 362; +pub const SYS_listen: ::c_long = 363; +pub const SYS_accept4: ::c_long = 364; +pub const SYS_getsockopt: ::c_long = 365; +pub const SYS_setsockopt: ::c_long = 366; +pub const SYS_getsockname: ::c_long = 367; +pub const SYS_getpeername: ::c_long = 368; +pub const SYS_sendto: ::c_long = 369; +pub const SYS_sendmsg: ::c_long = 370; +pub const SYS_recvfrom: ::c_long = 371; +pub const SYS_recvmsg: ::c_long = 372; +pub const SYS_shutdown: ::c_long = 373; +pub const SYS_mlock2: ::c_long = 374; +pub const SYS_copy_file_range: ::c_long = 375; +pub const SYS_preadv2: ::c_long = 376; +pub const SYS_pwritev2: ::c_long = 377; +pub const SYS_lchown: ::c_long = 198; +pub const SYS_setuid: ::c_long = 213; +pub const SYS_getuid: ::c_long = 199; +pub const SYS_setgid: ::c_long = 214; +pub const SYS_getgid: ::c_long = 200; +pub const SYS_geteuid: ::c_long = 201; +pub const SYS_setreuid: ::c_long = 203; +pub const SYS_setregid: ::c_long = 204; +pub const SYS_getrlimit: ::c_long = 191; +pub const SYS_getgroups: ::c_long = 205; +pub const SYS_fchown: ::c_long = 207; +pub const SYS_setresuid: ::c_long = 208; +pub const SYS_setresgid: ::c_long = 210; +pub const SYS_getresgid: ::c_long = 211; +pub const SYS_select: ::c_long = 142; +pub const SYS_getegid: ::c_long = 202; +pub const SYS_setgroups: ::c_long = 206; +pub const SYS_getresuid: ::c_long = 209; +pub const SYS_chown: ::c_long = 212; +pub const SYS_setfsuid: ::c_long = 215; +pub const SYS_setfsgid: ::c_long = 216; +pub const SYS_newfstatat: ::c_long = 293; +pub const SYS_statx: ::c_long = 379; + +#[link(name = "util")] +extern "C" { + + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; + pub fn getcontext(ucp: *mut ::ucontext_t) -> ::c_int; + pub fn setcontext(ucp: *const ::ucontext_t) -> ::c_int; + pub fn makecontext( + ucp: *mut ::ucontext_t, + func: extern "C" fn(), + argc: ::c_int, + ... + ); + pub fn swapcontext( + uocp: *mut ::ucontext_t, + ucp: *const ::ucontext_t, + ) -> ::c_int; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs new file mode 100644 index 0000000..29d1e1c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [i64; 4] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs new file mode 100644 index 0000000..651ada3 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -0,0 +1,988 @@ +//! SPARC64-specific definitions for 64-bit linux-like values + +use pthread_mutex_t; + +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = i8; +pub type wchar_t = i32; +pub type nlink_t = u32; +pub type blksize_t = i64; +pub type suseconds_t = i32; +pub type __u64 = ::c_ulonglong; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + #[cfg(target_arch = "sparc64")] + __reserved0: ::c_int, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + f_spare: [::__fsword_t; 5], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + __reserved: ::c_short, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct stat { + pub st_dev: ::dev_t, + __pad0: u64, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad1: u64, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 2], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + __pad0: u64, + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_int, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __reserved: [::c_long; 2], + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct pthread_attr_t { + __size: [u64; 7] + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + __pad0: u16, + pub __seq: ::c_ushort, + __unused1: ::c_ulonglong, + __unused2: ::c_ulonglong, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_segsz: ::size_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __reserved1: ::c_ulong, + __reserved2: ::c_ulong + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + +pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464; +pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465; + +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 6; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 7; + +pub const O_APPEND: ::c_int = 0x8; +pub const O_CREAT: ::c_int = 0x200; +pub const O_EXCL: ::c_int = 0x800; +pub const O_NOCTTY: ::c_int = 0x8000; +pub const O_NONBLOCK: ::c_int = 0x4000; +pub const O_SYNC: ::c_int = 0x802000; +pub const O_RSYNC: ::c_int = 0x802000; +pub const O_DSYNC: ::c_int = 0x2000; +pub const O_FSYNC: ::c_int = 0x802000; +pub const O_NOATIME: ::c_int = 0x200000; +pub const O_PATH: ::c_int = 0x1000000; +pub const O_TMPFILE: ::c_int = 0x2000000 | O_DIRECTORY; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_GROWSDOWN: ::c_int = 0x0200; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const EDEADLK: ::c_int = 78; +pub const ENAMETOOLONG: ::c_int = 63; +pub const ENOLCK: ::c_int = 79; +pub const ENOSYS: ::c_int = 90; +pub const ENOTEMPTY: ::c_int = 66; +pub const ELOOP: ::c_int = 62; +pub const ENOMSG: ::c_int = 75; +pub const EIDRM: ::c_int = 77; +pub const ECHRNG: ::c_int = 94; +pub const EL2NSYNC: ::c_int = 95; +pub const EL3HLT: ::c_int = 96; +pub const EL3RST: ::c_int = 97; +pub const ELNRNG: ::c_int = 98; +pub const EUNATCH: ::c_int = 99; +pub const ENOCSI: ::c_int = 100; +pub const EL2HLT: ::c_int = 101; +pub const EBADE: ::c_int = 102; +pub const EBADR: ::c_int = 103; +pub const EXFULL: ::c_int = 104; +pub const ENOANO: ::c_int = 105; +pub const EBADRQC: ::c_int = 106; +pub const EBADSLT: ::c_int = 107; +pub const EMULTIHOP: ::c_int = 87; +pub const EOVERFLOW: ::c_int = 92; +pub const ENOTUNIQ: ::c_int = 115; +pub const EBADFD: ::c_int = 93; +pub const EBADMSG: ::c_int = 76; +pub const EREMCHG: ::c_int = 89; +pub const ELIBACC: ::c_int = 114; +pub const ELIBBAD: ::c_int = 112; +pub const ELIBSCN: ::c_int = 124; +pub const ELIBMAX: ::c_int = 123; +pub const ELIBEXEC: ::c_int = 110; +pub const EILSEQ: ::c_int = 122; +pub const ERESTART: ::c_int = 116; +pub const ESTRPIPE: ::c_int = 91; +pub const EUSERS: ::c_int = 68; +pub const ENOTSOCK: ::c_int = 38; +pub const EDESTADDRREQ: ::c_int = 39; +pub const EMSGSIZE: ::c_int = 40; +pub const EPROTOTYPE: ::c_int = 41; +pub const ENOPROTOOPT: ::c_int = 42; +pub const EPROTONOSUPPORT: ::c_int = 43; +pub const ESOCKTNOSUPPORT: ::c_int = 44; +pub const EOPNOTSUPP: ::c_int = 45; +pub const EPFNOSUPPORT: ::c_int = 46; +pub const EAFNOSUPPORT: ::c_int = 47; +pub const EADDRINUSE: ::c_int = 48; +pub const EADDRNOTAVAIL: ::c_int = 49; +pub const ENETDOWN: ::c_int = 50; +pub const ENETUNREACH: ::c_int = 51; +pub const ENETRESET: ::c_int = 52; +pub const ECONNABORTED: ::c_int = 53; +pub const ECONNRESET: ::c_int = 54; +pub const ENOBUFS: ::c_int = 55; +pub const EISCONN: ::c_int = 56; +pub const ENOTCONN: ::c_int = 57; +pub const ESHUTDOWN: ::c_int = 58; +pub const ETOOMANYREFS: ::c_int = 59; +pub const ETIMEDOUT: ::c_int = 60; +pub const ECONNREFUSED: ::c_int = 61; +pub const EHOSTDOWN: ::c_int = 64; +pub const EHOSTUNREACH: ::c_int = 65; +pub const EALREADY: ::c_int = 37; +pub const EINPROGRESS: ::c_int = 36; +pub const ESTALE: ::c_int = 70; +pub const EDQUOT: ::c_int = 69; +pub const ENOMEDIUM: ::c_int = 125; +pub const EMEDIUMTYPE: ::c_int = 126; +pub const ECANCELED: ::c_int = 127; +pub const ENOKEY: ::c_int = 128; +pub const EKEYEXPIRED: ::c_int = 129; +pub const EKEYREVOKED: ::c_int = 130; +pub const EKEYREJECTED: ::c_int = 131; +pub const EOWNERDEAD: ::c_int = 132; +pub const ENOTRECOVERABLE: ::c_int = 133; +pub const EHWPOISON: ::c_int = 135; +pub const ERFKILL: ::c_int = 134; + +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_PASSCRED: ::c_int = 2; +pub const SO_REUSEADDR: ::c_int = 4; +pub const SO_BINDTODEVICE: ::c_int = 0x000d; +pub const SO_TIMESTAMP: ::c_int = 0x001d; +pub const SO_MARK: ::c_int = 0x0022; +pub const SO_RXQ_OVFL: ::c_int = 0x0024; +pub const SO_PEEK_OFF: ::c_int = 0x0026; +pub const SO_BUSY_POLL: ::c_int = 0x0030; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_DONTROUTE: ::c_int = 16; +pub const SO_BROADCAST: ::c_int = 32; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDBUFFORCE: ::c_int = 0x100a; +pub const SO_RCVBUFFORCE: ::c_int = 0x100b; +pub const SO_DOMAIN: ::c_int = 0x1029; +pub const SO_KEEPALIVE: ::c_int = 8; +pub const SO_OOBINLINE: ::c_int = 0x100; +pub const SO_LINGER: ::c_int = 128; +pub const SO_REUSEPORT: ::c_int = 0x200; +pub const SO_ACCEPTCONN: ::c_int = 0x8000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const SA_ONSTACK: ::c_int = 1; +pub const SA_SIGINFO: ::c_int = 0x200; +pub const SA_NOCLDWAIT: ::c_int = 0x100; + +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGCHLD: ::c_int = 20; +pub const SIGBUS: ::c_int = 10; +pub const SIGUSR1: ::c_int = 30; +pub const SIGUSR2: ::c_int = 31; +pub const SIGCONT: ::c_int = 19; +pub const SIGSTOP: ::c_int = 17; +pub const SIGTSTP: ::c_int = 18; +pub const SIGURG: ::c_int = 16; +pub const SIGIO: ::c_int = 23; +pub const SIGSYS: ::c_int = 12; +pub const SIGPOLL: ::c_int = 23; +pub const SIGPWR: ::c_int = 29; +pub const SIG_SETMASK: ::c_int = 4; +pub const SIG_BLOCK: ::c_int = 1; +pub const SIG_UNBLOCK: ::c_int = 2; + +pub const POLLWRNORM: ::c_short = 4; +pub const POLLWRBAND: ::c_short = 0x100; + +pub const O_ASYNC: ::c_int = 0x40; +pub const O_NDELAY: ::c_int = 0x4004; + +pub const PTRACE_DETACH: ::c_uint = 11; + +pub const EFD_NONBLOCK: ::c_int = 0x4000; + +pub const F_GETLK: ::c_int = 7; +pub const F_GETOWN: ::c_int = 5; +pub const F_SETOWN: ::c_int = 6; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; + +pub const F_RDLCK: ::c_int = 1; +pub const F_WRLCK: ::c_int = 2; +pub const F_UNLCK: ::c_int = 3; + +pub const SFD_NONBLOCK: ::c_int = 0x4000; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCLINUX: ::c_ulong = 0x541C; +pub const TIOCGSERIAL: ::c_ulong = 0x541E; +pub const TIOCEXCL: ::c_ulong = 0x2000740d; +pub const TIOCNXCL: ::c_ulong = 0x2000740e; +pub const TIOCSCTTY: ::c_ulong = 0x20007484; +pub const TIOCSTI: ::c_ulong = 0x80017472; +pub const TIOCMGET: ::c_ulong = 0x4004746a; +pub const TIOCMBIS: ::c_ulong = 0x8004746c; +pub const TIOCMBIC: ::c_ulong = 0x8004746b; +pub const TIOCMSET: ::c_ulong = 0x8004746d; +pub const TIOCCONS: ::c_ulong = 0x20007424; + +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const SFD_CLOEXEC: ::c_int = 0x400000; + +pub const NCCS: usize = 17; +pub const O_TRUNC: ::c_int = 0x400; + +pub const O_CLOEXEC: ::c_int = 0x400000; + +pub const EBFONT: ::c_int = 109; +pub const ENOSTR: ::c_int = 72; +pub const ENODATA: ::c_int = 111; +pub const ETIME: ::c_int = 73; +pub const ENOSR: ::c_int = 74; +pub const ENONET: ::c_int = 80; +pub const ENOPKG: ::c_int = 113; +pub const EREMOTE: ::c_int = 71; +pub const ENOLINK: ::c_int = 82; +pub const EADV: ::c_int = 83; +pub const ESRMNT: ::c_int = 84; +pub const ECOMM: ::c_int = 85; +pub const EPROTO: ::c_int = 86; +pub const EDOTDOT: ::c_int = 88; + +pub const SA_NODEFER: ::c_int = 0x20; +pub const SA_RESETHAND: ::c_int = 0x4; +pub const SA_RESTART: ::c_int = 0x2; +pub const SA_NOCLDSTOP: ::c_int = 0x00000008; + +pub const EPOLL_CLOEXEC: ::c_int = 0x400000; + +pub const EFD_CLOEXEC: ::c_int = 0x400000; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + +align_const! { + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + +pub const O_DIRECTORY: ::c_int = 0o200000; +pub const O_NOFOLLOW: ::c_int = 0o400000; +pub const O_DIRECT: ::c_int = 0x100000; + +pub const MAP_LOCKED: ::c_int = 0x0100; +pub const MAP_NORESERVE: ::c_int = 0x00040; + +pub const EDEADLOCK: ::c_int = 108; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; + +pub const SO_PEERCRED: ::c_int = 0x40; +pub const SO_RCVLOWAT: ::c_int = 0x800; +pub const SO_SNDLOWAT: ::c_int = 0x1000; +pub const SO_RCVTIMEO: ::c_int = 0x2000; +pub const SO_SNDTIMEO: ::c_int = 0x4000; + +pub const FIOCLEX: ::c_ulong = 0x20006601; +pub const FIONCLEX: ::c_ulong = 0x20006602; +pub const FIONBIO: ::c_ulong = 0x8004667e; + +pub const MCL_CURRENT: ::c_int = 0x2000; +pub const MCL_FUTURE: ::c_int = 0x4000; + +pub const SIGSTKSZ: ::size_t = 16384; +pub const MINSIGSTKSZ: ::size_t = 4096; +pub const CBAUD: ::tcflag_t = 0x0000100f; +pub const TAB1: ::tcflag_t = 0x800; +pub const TAB2: ::tcflag_t = 0x1000; +pub const TAB3: ::tcflag_t = 0x1800; +pub const CR1: ::tcflag_t = 0x200; +pub const CR2: ::tcflag_t = 0x400; +pub const CR3: ::tcflag_t = 0x600; +pub const FF1: ::tcflag_t = 0x8000; +pub const BS1: ::tcflag_t = 0x2000; +pub const VT1: ::tcflag_t = 0x4000; +pub const VWERASE: usize = 0xe; +pub const VREPRINT: usize = 0xc; +pub const VSUSP: usize = 0xa; +pub const VSTART: usize = 0x8; +pub const VSTOP: usize = 0x9; +pub const VDISCARD: usize = 0xd; +pub const VTIME: usize = 0x5; +pub const IXON: ::tcflag_t = 0x400; +pub const IXOFF: ::tcflag_t = 0x1000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x30; +pub const CS6: ::tcflag_t = 0x10; +pub const CS7: ::tcflag_t = 0x20; +pub const CS8: ::tcflag_t = 0x30; +pub const CSTOPB: ::tcflag_t = 0x40; +pub const CREAD: ::tcflag_t = 0x80; +pub const PARENB: ::tcflag_t = 0x100; +pub const PARODD: ::tcflag_t = 0x200; +pub const HUPCL: ::tcflag_t = 0x400; +pub const CLOCAL: ::tcflag_t = 0x800; +pub const ECHOKE: ::tcflag_t = 0x800; +pub const ECHOE: ::tcflag_t = 0x10; +pub const ECHOK: ::tcflag_t = 0x20; +pub const ECHONL: ::tcflag_t = 0x40; +pub const ECHOPRT: ::tcflag_t = 0x400; +pub const ECHOCTL: ::tcflag_t = 0x200; +pub const ISIG: ::tcflag_t = 0x1; +pub const ICANON: ::tcflag_t = 0x2; +pub const PENDIN: ::tcflag_t = 0x4000; +pub const NOFLSH: ::tcflag_t = 0x80; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0x00001000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const BOTHER: ::speed_t = 0x1000; +pub const B57600: ::speed_t = 0x1001; +pub const B115200: ::speed_t = 0x1002; +pub const B230400: ::speed_t = 0x1003; +pub const B460800: ::speed_t = 0x1004; +pub const B76800: ::speed_t = 0x1005; +pub const B153600: ::speed_t = 0x1006; +pub const B307200: ::speed_t = 0x1007; +pub const B614400: ::speed_t = 0x1008; +pub const B921600: ::speed_t = 0x1009; +pub const B500000: ::speed_t = 0x100a; +pub const B576000: ::speed_t = 0x100b; +pub const B1000000: ::speed_t = 0x100c; +pub const B1152000: ::speed_t = 0x100d; +pub const B1500000: ::speed_t = 0x100e; +pub const B2000000: ::speed_t = 0x100f; + +pub const VEOL: usize = 5; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: ::tcflag_t = 0x8000; +pub const TOSTOP: ::tcflag_t = 0x100; +pub const FLUSHO: ::tcflag_t = 0x1000; +pub const EXTPROC: ::tcflag_t = 0x10000; +pub const TCGETS: ::c_ulong = 0x40245408; +pub const TCSETS: ::c_ulong = 0x80245409; +pub const TCSETSW: ::c_ulong = 0x8024540a; +pub const TCSETSF: ::c_ulong = 0x8024540b; +pub const TCGETA: ::c_ulong = 0x40125401; +pub const TCSETA: ::c_ulong = 0x80125402; +pub const TCSETAW: ::c_ulong = 0x80125403; +pub const TCSETAF: ::c_ulong = 0x80125404; +pub const TCSBRK: ::c_ulong = 0x20005405; +pub const TCXONC: ::c_ulong = 0x20005406; +pub const TCFLSH: ::c_ulong = 0x20005407; +pub const TIOCINQ: ::c_ulong = 0x4004667f; +pub const TIOCGPGRP: ::c_ulong = 0x40047483; +pub const TIOCSPGRP: ::c_ulong = 0x80047482; +pub const TIOCOUTQ: ::c_ulong = 0x40047473; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const FIONREAD: ::c_ulong = 0x4004667f; + +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_wait4: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execv: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_chown: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_brk: ::c_long = 17; +pub const SYS_perfctr: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_capget: ::c_long = 21; +pub const SYS_capset: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_vmsplice: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_sigaltstack: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_stat: ::c_long = 38; +pub const SYS_sendfile: ::c_long = 39; +pub const SYS_lstat: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_umount2: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_memory_ordering: ::c_long = 52; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_reboot: ::c_long = 55; +pub const SYS_symlink: ::c_long = 57; +pub const SYS_readlink: ::c_long = 58; +pub const SYS_execve: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_fstat: ::c_long = 62; +pub const SYS_fstat64: ::c_long = 63; +pub const SYS_getpagesize: ::c_long = 64; +pub const SYS_msync: ::c_long = 65; +pub const SYS_vfork: ::c_long = 66; +pub const SYS_pread64: ::c_long = 67; +pub const SYS_pwrite64: ::c_long = 68; +pub const SYS_mmap: ::c_long = 71; +pub const SYS_munmap: ::c_long = 73; +pub const SYS_mprotect: ::c_long = 74; +pub const SYS_madvise: ::c_long = 75; +pub const SYS_vhangup: ::c_long = 76; +pub const SYS_mincore: ::c_long = 78; +pub const SYS_getgroups: ::c_long = 79; +pub const SYS_setgroups: ::c_long = 80; +pub const SYS_getpgrp: ::c_long = 81; +pub const SYS_setitimer: ::c_long = 83; +pub const SYS_swapon: ::c_long = 85; +pub const SYS_getitimer: ::c_long = 86; +pub const SYS_sethostname: ::c_long = 88; +pub const SYS_dup2: ::c_long = 90; +pub const SYS_fcntl: ::c_long = 92; +pub const SYS_select: ::c_long = 93; +pub const SYS_fsync: ::c_long = 95; +pub const SYS_setpriority: ::c_long = 96; +pub const SYS_socket: ::c_long = 97; +pub const SYS_connect: ::c_long = 98; +pub const SYS_accept: ::c_long = 99; +pub const SYS_getpriority: ::c_long = 100; +pub const SYS_rt_sigreturn: ::c_long = 101; +pub const SYS_rt_sigaction: ::c_long = 102; +pub const SYS_rt_sigprocmask: ::c_long = 103; +pub const SYS_rt_sigpending: ::c_long = 104; +pub const SYS_rt_sigtimedwait: ::c_long = 105; +pub const SYS_rt_sigqueueinfo: ::c_long = 106; +pub const SYS_rt_sigsuspend: ::c_long = 107; +pub const SYS_setresuid: ::c_long = 108; +pub const SYS_getresuid: ::c_long = 109; +pub const SYS_setresgid: ::c_long = 110; +pub const SYS_getresgid: ::c_long = 111; +pub const SYS_recvmsg: ::c_long = 113; +pub const SYS_sendmsg: ::c_long = 114; +pub const SYS_gettimeofday: ::c_long = 116; +pub const SYS_getrusage: ::c_long = 117; +pub const SYS_getsockopt: ::c_long = 118; +pub const SYS_getcwd: ::c_long = 119; +pub const SYS_readv: ::c_long = 120; +pub const SYS_writev: ::c_long = 121; +pub const SYS_settimeofday: ::c_long = 122; +pub const SYS_fchown: ::c_long = 123; +pub const SYS_fchmod: ::c_long = 124; +pub const SYS_recvfrom: ::c_long = 125; +pub const SYS_setreuid: ::c_long = 126; +pub const SYS_setregid: ::c_long = 127; +pub const SYS_rename: ::c_long = 128; +pub const SYS_truncate: ::c_long = 129; +pub const SYS_ftruncate: ::c_long = 130; +pub const SYS_flock: ::c_long = 131; +pub const SYS_lstat64: ::c_long = 132; +pub const SYS_sendto: ::c_long = 133; +pub const SYS_shutdown: ::c_long = 134; +pub const SYS_socketpair: ::c_long = 135; +pub const SYS_mkdir: ::c_long = 136; +pub const SYS_rmdir: ::c_long = 137; +pub const SYS_utimes: ::c_long = 138; +pub const SYS_stat64: ::c_long = 139; +pub const SYS_sendfile64: ::c_long = 140; +pub const SYS_getpeername: ::c_long = 141; +pub const SYS_futex: ::c_long = 142; +pub const SYS_gettid: ::c_long = 143; +pub const SYS_getrlimit: ::c_long = 144; +pub const SYS_setrlimit: ::c_long = 145; +pub const SYS_pivot_root: ::c_long = 146; +pub const SYS_prctl: ::c_long = 147; +pub const SYS_pciconfig_read: ::c_long = 148; +pub const SYS_pciconfig_write: ::c_long = 149; +pub const SYS_getsockname: ::c_long = 150; +pub const SYS_inotify_init: ::c_long = 151; +pub const SYS_inotify_add_watch: ::c_long = 152; +pub const SYS_poll: ::c_long = 153; +pub const SYS_getdents64: ::c_long = 154; +pub const SYS_inotify_rm_watch: ::c_long = 156; +pub const SYS_statfs: ::c_long = 157; +pub const SYS_fstatfs: ::c_long = 158; +pub const SYS_umount: ::c_long = 159; +pub const SYS_sched_set_affinity: ::c_long = 160; +pub const SYS_sched_get_affinity: ::c_long = 161; +pub const SYS_getdomainname: ::c_long = 162; +pub const SYS_setdomainname: ::c_long = 163; +pub const SYS_utrap_install: ::c_long = 164; +pub const SYS_quotactl: ::c_long = 165; +pub const SYS_set_tid_address: ::c_long = 166; +pub const SYS_mount: ::c_long = 167; +pub const SYS_ustat: ::c_long = 168; +pub const SYS_setxattr: ::c_long = 169; +pub const SYS_lsetxattr: ::c_long = 170; +pub const SYS_fsetxattr: ::c_long = 171; +pub const SYS_getxattr: ::c_long = 172; +pub const SYS_lgetxattr: ::c_long = 173; +pub const SYS_getdents: ::c_long = 174; +pub const SYS_setsid: ::c_long = 175; +pub const SYS_fchdir: ::c_long = 176; +pub const SYS_fgetxattr: ::c_long = 177; +pub const SYS_listxattr: ::c_long = 178; +pub const SYS_llistxattr: ::c_long = 179; +pub const SYS_flistxattr: ::c_long = 180; +pub const SYS_removexattr: ::c_long = 181; +pub const SYS_lremovexattr: ::c_long = 182; +pub const SYS_sigpending: ::c_long = 183; +pub const SYS_query_module: ::c_long = 184; +pub const SYS_setpgid: ::c_long = 185; +pub const SYS_fremovexattr: ::c_long = 186; +pub const SYS_tkill: ::c_long = 187; +pub const SYS_exit_group: ::c_long = 188; +pub const SYS_uname: ::c_long = 189; +pub const SYS_init_module: ::c_long = 190; +pub const SYS_personality: ::c_long = 191; +pub const SYS_remap_file_pages: ::c_long = 192; +pub const SYS_epoll_create: ::c_long = 193; +pub const SYS_epoll_ctl: ::c_long = 194; +pub const SYS_epoll_wait: ::c_long = 195; +pub const SYS_ioprio_set: ::c_long = 196; +pub const SYS_getppid: ::c_long = 197; +pub const SYS_sigaction: ::c_long = 198; +pub const SYS_sgetmask: ::c_long = 199; +pub const SYS_ssetmask: ::c_long = 200; +pub const SYS_sigsuspend: ::c_long = 201; +pub const SYS_oldlstat: ::c_long = 202; +pub const SYS_uselib: ::c_long = 203; +pub const SYS_readdir: ::c_long = 204; +pub const SYS_readahead: ::c_long = 205; +pub const SYS_socketcall: ::c_long = 206; +pub const SYS_syslog: ::c_long = 207; +pub const SYS_lookup_dcookie: ::c_long = 208; +pub const SYS_fadvise64: ::c_long = 209; +pub const SYS_fadvise64_64: ::c_long = 210; +pub const SYS_tgkill: ::c_long = 211; +pub const SYS_waitpid: ::c_long = 212; +pub const SYS_swapoff: ::c_long = 213; +pub const SYS_sysinfo: ::c_long = 214; +pub const SYS_ipc: ::c_long = 215; +pub const SYS_sigreturn: ::c_long = 216; +pub const SYS_clone: ::c_long = 217; +pub const SYS_ioprio_get: ::c_long = 218; +pub const SYS_adjtimex: ::c_long = 219; +pub const SYS_sigprocmask: ::c_long = 220; +pub const SYS_create_module: ::c_long = 221; +pub const SYS_delete_module: ::c_long = 222; +pub const SYS_get_kernel_syms: ::c_long = 223; +pub const SYS_getpgid: ::c_long = 224; +pub const SYS_bdflush: ::c_long = 225; +pub const SYS_sysfs: ::c_long = 226; +pub const SYS_afs_syscall: ::c_long = 227; +pub const SYS_setfsuid: ::c_long = 228; +pub const SYS_setfsgid: ::c_long = 229; +pub const SYS__newselect: ::c_long = 230; +pub const SYS_splice: ::c_long = 232; +pub const SYS_stime: ::c_long = 233; +pub const SYS_statfs64: ::c_long = 234; +pub const SYS_fstatfs64: ::c_long = 235; +pub const SYS__llseek: ::c_long = 236; +pub const SYS_mlock: ::c_long = 237; +pub const SYS_munlock: ::c_long = 238; +pub const SYS_mlockall: ::c_long = 239; +pub const SYS_munlockall: ::c_long = 240; +pub const SYS_sched_setparam: ::c_long = 241; +pub const SYS_sched_getparam: ::c_long = 242; +pub const SYS_sched_setscheduler: ::c_long = 243; +pub const SYS_sched_getscheduler: ::c_long = 244; +pub const SYS_sched_yield: ::c_long = 245; +pub const SYS_sched_get_priority_max: ::c_long = 246; +pub const SYS_sched_get_priority_min: ::c_long = 247; +pub const SYS_sched_rr_get_interval: ::c_long = 248; +pub const SYS_nanosleep: ::c_long = 249; +pub const SYS_mremap: ::c_long = 250; +pub const SYS__sysctl: ::c_long = 251; +pub const SYS_getsid: ::c_long = 252; +pub const SYS_fdatasync: ::c_long = 253; +pub const SYS_nfsservctl: ::c_long = 254; +pub const SYS_sync_file_range: ::c_long = 255; +pub const SYS_clock_settime: ::c_long = 256; +pub const SYS_clock_gettime: ::c_long = 257; +pub const SYS_clock_getres: ::c_long = 258; +pub const SYS_clock_nanosleep: ::c_long = 259; +pub const SYS_sched_getaffinity: ::c_long = 260; +pub const SYS_sched_setaffinity: ::c_long = 261; +pub const SYS_timer_settime: ::c_long = 262; +pub const SYS_timer_gettime: ::c_long = 263; +pub const SYS_timer_getoverrun: ::c_long = 264; +pub const SYS_timer_delete: ::c_long = 265; +pub const SYS_timer_create: ::c_long = 266; +pub const SYS_io_setup: ::c_long = 268; +pub const SYS_io_destroy: ::c_long = 269; +pub const SYS_io_submit: ::c_long = 270; +pub const SYS_io_cancel: ::c_long = 271; +pub const SYS_io_getevents: ::c_long = 272; +pub const SYS_mq_open: ::c_long = 273; +pub const SYS_mq_unlink: ::c_long = 274; +pub const SYS_mq_timedsend: ::c_long = 275; +pub const SYS_mq_timedreceive: ::c_long = 276; +pub const SYS_mq_notify: ::c_long = 277; +pub const SYS_mq_getsetattr: ::c_long = 278; +pub const SYS_waitid: ::c_long = 279; +pub const SYS_tee: ::c_long = 280; +pub const SYS_add_key: ::c_long = 281; +pub const SYS_request_key: ::c_long = 282; +pub const SYS_keyctl: ::c_long = 283; +pub const SYS_openat: ::c_long = 284; +pub const SYS_mkdirat: ::c_long = 285; +pub const SYS_mknodat: ::c_long = 286; +pub const SYS_fchownat: ::c_long = 287; +pub const SYS_futimesat: ::c_long = 288; +pub const SYS_fstatat64: ::c_long = 289; +pub const SYS_unlinkat: ::c_long = 290; +pub const SYS_renameat: ::c_long = 291; +pub const SYS_linkat: ::c_long = 292; +pub const SYS_symlinkat: ::c_long = 293; +pub const SYS_readlinkat: ::c_long = 294; +pub const SYS_fchmodat: ::c_long = 295; +pub const SYS_faccessat: ::c_long = 296; +pub const SYS_pselect6: ::c_long = 297; +pub const SYS_ppoll: ::c_long = 298; +pub const SYS_unshare: ::c_long = 299; +pub const SYS_set_robust_list: ::c_long = 300; +pub const SYS_get_robust_list: ::c_long = 301; +pub const SYS_migrate_pages: ::c_long = 302; +pub const SYS_mbind: ::c_long = 303; +pub const SYS_get_mempolicy: ::c_long = 304; +pub const SYS_set_mempolicy: ::c_long = 305; +pub const SYS_kexec_load: ::c_long = 306; +pub const SYS_move_pages: ::c_long = 307; +pub const SYS_getcpu: ::c_long = 308; +pub const SYS_epoll_pwait: ::c_long = 309; +pub const SYS_utimensat: ::c_long = 310; +pub const SYS_signalfd: ::c_long = 311; +pub const SYS_timerfd_create: ::c_long = 312; +pub const SYS_eventfd: ::c_long = 313; +pub const SYS_fallocate: ::c_long = 314; +pub const SYS_timerfd_settime: ::c_long = 315; +pub const SYS_timerfd_gettime: ::c_long = 316; +pub const SYS_signalfd4: ::c_long = 317; +pub const SYS_eventfd2: ::c_long = 318; +pub const SYS_epoll_create1: ::c_long = 319; +pub const SYS_dup3: ::c_long = 320; +pub const SYS_pipe2: ::c_long = 321; +pub const SYS_inotify_init1: ::c_long = 322; +pub const SYS_accept4: ::c_long = 323; +pub const SYS_preadv: ::c_long = 324; +pub const SYS_pwritev: ::c_long = 325; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 326; +pub const SYS_perf_event_open: ::c_long = 327; +pub const SYS_recvmmsg: ::c_long = 328; +pub const SYS_fanotify_init: ::c_long = 329; +pub const SYS_fanotify_mark: ::c_long = 330; +pub const SYS_prlimit64: ::c_long = 331; +pub const SYS_name_to_handle_at: ::c_long = 332; +pub const SYS_open_by_handle_at: ::c_long = 333; +pub const SYS_clock_adjtime: ::c_long = 334; +pub const SYS_syncfs: ::c_long = 335; +pub const SYS_sendmmsg: ::c_long = 336; +pub const SYS_setns: ::c_long = 337; +pub const SYS_process_vm_readv: ::c_long = 338; +pub const SYS_process_vm_writev: ::c_long = 339; +pub const SYS_kern_features: ::c_long = 340; +pub const SYS_kcmp: ::c_long = 341; +pub const SYS_finit_module: ::c_long = 342; +pub const SYS_sched_setattr: ::c_long = 343; +pub const SYS_sched_getattr: ::c_long = 344; +pub const SYS_renameat2: ::c_long = 345; +pub const SYS_seccomp: ::c_long = 346; +pub const SYS_getrandom: ::c_long = 347; +pub const SYS_memfd_create: ::c_long = 348; +pub const SYS_bpf: ::c_long = 349; +pub const SYS_execveat: ::c_long = 350; +pub const SYS_membarrier: ::c_long = 351; +pub const SYS_userfaultfd: ::c_long = 352; +pub const SYS_bind: ::c_long = 353; +pub const SYS_listen: ::c_long = 354; +pub const SYS_setsockopt: ::c_long = 355; +pub const SYS_mlock2: ::c_long = 356; +pub const SYS_copy_file_range: ::c_long = 357; +pub const SYS_preadv2: ::c_long = 358; +pub const SYS_pwritev2: ::c_long = 359; +pub const SYS_statx: ::c_long = 360; + +#[link(name = "util")] +extern "C" { + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs new file mode 100644 index 0000000..7ca870f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs new file mode 100644 index 0000000..34e4da8 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -0,0 +1,929 @@ +//! x86_64-specific definitions for 64-bit linux-like values + +pub type c_char = i8; +pub type wchar_t = i32; +pub type nlink_t = u64; +pub type blksize_t = i64; +pub type greg_t = i64; +pub type suseconds_t = i64; +pub type __u64 = ::c_ulonglong; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + #[cfg(target_arch = "sparc64")] + __reserved0: ::c_int, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + f_spare: [::__fsword_t; 5], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [u64; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: i64, + pub st_mtime: ::time_t, + pub st_mtime_nsec: i64, + pub st_ctime: ::time_t, + pub st_ctime_nsec: i64, + __unused: [i64; 3], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: i64, + pub st_mtime: ::time_t, + pub st_mtime_nsec: i64, + pub st_ctime: ::time_t, + pub st_ctime_nsec: i64, + __reserved: [i64; 3], + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct pthread_attr_t { + #[cfg(target_pointer_width = "32")] + __size: [u32; 8], + #[cfg(target_pointer_width = "64")] + __size: [u64; 7] + } + + pub struct _libc_fpxreg { + pub significand: [u16; 4], + pub exponent: u16, + __private: [u16; 3], + } + + pub struct _libc_xmmreg { + pub element: [u32; 4], + } + + pub struct _libc_fpstate { + pub cwd: u16, + pub swd: u16, + pub ftw: u16, + pub fop: u16, + pub rip: u64, + pub rdp: u64, + pub mxcsr: u32, + pub mxcr_mask: u32, + pub _st: [_libc_fpxreg; 8], + pub _xmm: [_libc_xmmreg; 16], + __private: [u64; 12], + } + + pub struct user_regs_struct { + pub r15: ::c_ulonglong, + pub r14: ::c_ulonglong, + pub r13: ::c_ulonglong, + pub r12: ::c_ulonglong, + pub rbp: ::c_ulonglong, + pub rbx: ::c_ulonglong, + pub r11: ::c_ulonglong, + pub r10: ::c_ulonglong, + pub r9: ::c_ulonglong, + pub r8: ::c_ulonglong, + pub rax: ::c_ulonglong, + pub rcx: ::c_ulonglong, + pub rdx: ::c_ulonglong, + pub rsi: ::c_ulonglong, + pub rdi: ::c_ulonglong, + pub orig_rax: ::c_ulonglong, + pub rip: ::c_ulonglong, + pub cs: ::c_ulonglong, + pub eflags: ::c_ulonglong, + pub rsp: ::c_ulonglong, + pub ss: ::c_ulonglong, + pub fs_base: ::c_ulonglong, + pub gs_base: ::c_ulonglong, + pub ds: ::c_ulonglong, + pub es: ::c_ulonglong, + pub fs: ::c_ulonglong, + pub gs: ::c_ulonglong, + } + + pub struct user { + pub regs: user_regs_struct, + pub u_fpvalid: ::c_int, + pub i387: user_fpregs_struct, + pub u_tsize: ::c_ulonglong, + pub u_dsize: ::c_ulonglong, + pub u_ssize: ::c_ulonglong, + pub start_code: ::c_ulonglong, + pub start_stack: ::c_ulonglong, + pub signal: ::c_longlong, + __reserved: ::c_int, + #[cfg(target_pointer_width = "32")] + __pad1: u32, + pub u_ar0: *mut user_regs_struct, + #[cfg(target_pointer_width = "32")] + __pad2: u32, + pub u_fpstate: *mut user_fpregs_struct, + pub magic: ::c_ulonglong, + pub u_comm: [::c_char; 32], + pub u_debugreg: [::c_ulonglong; 8], + } + + pub struct mcontext_t { + pub gregs: [greg_t; 23], + pub fpregs: *mut _libc_fpstate, + __private: [u64; 8], + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_ushort, + __pad1: ::c_ushort, + pub __seq: ::c_ushort, + __pad2: ::c_ushort, + __unused1: u64, + __unused2: u64 + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused4: u64, + __unused5: u64 + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } + + pub struct ip_mreqn { + pub imr_multiaddr: ::in_addr, + pub imr_address: ::in_addr, + pub imr_ifindex: ::c_int, + } +} + +s_no_extra_traits! { + pub struct user_fpregs_struct { + pub cwd: ::c_ushort, + pub swd: ::c_ushort, + pub ftw: ::c_ushort, + pub fop: ::c_ushort, + pub rip: ::c_ulonglong, + pub rdp: ::c_ulonglong, + pub mxcsr: ::c_uint, + pub mxcr_mask: ::c_uint, + pub st_space: [::c_uint; 32], + pub xmm_space: [::c_uint; 64], + padding: [::c_uint; 24], + } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + __private: [u8; 512], + // FIXME: the shadow stack field requires glibc >= 2.28. + // Re-add once we drop compatibility with glibc versions older than + // 2.28. + // + // __ssp: [::c_ulonglong; 4], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for user_fpregs_struct { + fn eq(&self, other: &user_fpregs_struct) -> bool { + self.cwd == other.cwd + && self.swd == other.swd + && self.ftw == other.ftw + && self.fop == other.fop + && self.rip == other.rip + && self.rdp == other.rdp + && self.mxcsr == other.mxcsr + && self.mxcr_mask == other.mxcr_mask + && self.st_space == other.st_space + && self + .xmm_space + .iter() + .zip(other.xmm_space.iter()) + .all(|(a,b)| a == b) + // Ignore padding field + } + } + + impl Eq for user_fpregs_struct {} + + impl ::fmt::Debug for user_fpregs_struct { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("user_fpregs_struct") + .field("cwd", &self.cwd) + .field("ftw", &self.ftw) + .field("fop", &self.fop) + .field("rip", &self.rip) + .field("rdp", &self.rdp) + .field("mxcsr", &self.mxcsr) + .field("mxcr_mask", &self.mxcr_mask) + .field("st_space", &self.st_space) + // FIXME: .field("xmm_space", &self.xmm_space) + // Ignore padding field + .finish() + } + } + + impl ::hash::Hash for user_fpregs_struct { + fn hash(&self, state: &mut H) { + self.cwd.hash(state); + self.ftw.hash(state); + self.fop.hash(state); + self.rip.hash(state); + self.rdp.hash(state); + self.mxcsr.hash(state); + self.mxcr_mask.hash(state); + self.st_space.hash(state); + self.xmm_space.hash(state); + // Ignore padding field + } + } + + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + // Ignore __private field + } + } + + impl Eq for ucontext_t {} + + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } + } + + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + // Ignore __private field + } + } + } +} + +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; +pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; + +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 0x101000; +pub const O_NOATIME: ::c_int = 0o1000000; +pub const O_PATH: ::c_int = 0o10000000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: ::c_int = 28; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_PEERSEC: ::c_int = 31; +pub const SO_PASSSEC: ::c_int = 34; +pub const SO_TIMESTAMPNS: ::c_int = 35; +pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; +pub const SO_MARK: ::c_int = 36; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_WIFI_STATUS: ::c_int = 41; +pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_NOFCS: ::c_int = 43; +pub const SO_LOCK_FILTER: ::c_int = 44; +pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; +pub const SO_BUSY_POLL: ::c_int = 46; +pub const SO_MAX_PACING_RATE: ::c_int = 47; +pub const SO_BPF_EXTENSIONS: ::c_int = 48; +pub const SO_INCOMING_CPU: ::c_int = 49; +pub const SO_ATTACH_BPF: ::c_int = 50; +pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = 31; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_NDELAY: ::c_int = 0x800; + +pub const PTRACE_DETACH: ::c_uint = 17; + +pub const EFD_NONBLOCK: ::c_int = 0x800; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; + +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + +pub const SFD_NONBLOCK: ::c_int = 0x0800; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCLINUX: ::c_ulong = 0x541C; +pub const TIOCGSERIAL: ::c_ulong = 0x541E; +pub const TIOCEXCL: ::c_ulong = 0x540C; +pub const TIOCNXCL: ::c_ulong = 0x540D; +pub const TIOCSCTTY: ::c_ulong = 0x540E; +pub const TIOCSTI: ::c_ulong = 0x5412; +pub const TIOCMGET: ::c_ulong = 0x5415; +pub const TIOCMBIS: ::c_ulong = 0x5416; +pub const TIOCMBIC: ::c_ulong = 0x5417; +pub const TIOCMSET: ::c_ulong = 0x5418; +pub const TIOCCONS: ::c_ulong = 0x541D; + +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const SFD_CLOEXEC: ::c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: ::c_int = 512; + +pub const O_CLOEXEC: ::c_int = 0x80000; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; + +pub const MAP_HUGETLB: ::c_int = 0x040000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_32BIT: ::c_int = 0x0040; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const EDEADLOCK: ::c_int = 35; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; + +pub const FIOCLEX: ::c_ulong = 0x5451; +pub const FIONCLEX: ::c_ulong = 0x5450; +pub const FIONBIO: ::c_ulong = 0x5421; + +pub const PTRACE_GETFPREGS: ::c_uint = 14; +pub const PTRACE_SETFPREGS: ::c_uint = 15; +pub const PTRACE_GETFPXREGS: ::c_uint = 18; +pub const PTRACE_SETFPXREGS: ::c_uint = 19; +pub const PTRACE_GETREGS: ::c_uint = 12; +pub const PTRACE_SETREGS: ::c_uint = 13; +pub const PTRACE_PEEKSIGINFO_SHARED: ::c_uint = 1; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const BOTHER: ::speed_t = 0o010000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; +pub const EXTPROC: ::tcflag_t = 0x00010000; +pub const TCGETS: ::c_ulong = 0x5401; +pub const TCSETS: ::c_ulong = 0x5402; +pub const TCSETSW: ::c_ulong = 0x5403; +pub const TCSETSF: ::c_ulong = 0x5404; +pub const TCGETA: ::c_ulong = 0x5405; +pub const TCSETA: ::c_ulong = 0x5406; +pub const TCSETAW: ::c_ulong = 0x5407; +pub const TCSETAF: ::c_ulong = 0x5408; +pub const TCSBRK: ::c_ulong = 0x5409; +pub const TCXONC: ::c_ulong = 0x540A; +pub const TCFLSH: ::c_ulong = 0x540B; +pub const TIOCINQ: ::c_ulong = 0x541B; +pub const TIOCGPGRP: ::c_ulong = 0x540F; +pub const TIOCSPGRP: ::c_ulong = 0x5410; +pub const TIOCOUTQ: ::c_ulong = 0x5411; +pub const TIOCGWINSZ: ::c_ulong = 0x5413; +pub const TIOCSWINSZ: ::c_ulong = 0x5414; +pub const FIONREAD: ::c_ulong = 0x541B; + +// offsets in user_regs_structs, from sys/reg.h +pub const R15: ::c_int = 0; +pub const R14: ::c_int = 1; +pub const R13: ::c_int = 2; +pub const R12: ::c_int = 3; +pub const RBP: ::c_int = 4; +pub const RBX: ::c_int = 5; +pub const R11: ::c_int = 6; +pub const R10: ::c_int = 7; +pub const R9: ::c_int = 8; +pub const R8: ::c_int = 9; +pub const RAX: ::c_int = 10; +pub const RCX: ::c_int = 11; +pub const RDX: ::c_int = 12; +pub const RSI: ::c_int = 13; +pub const RDI: ::c_int = 14; +pub const ORIG_RAX: ::c_int = 15; +pub const RIP: ::c_int = 16; +pub const CS: ::c_int = 17; +pub const EFLAGS: ::c_int = 18; +pub const RSP: ::c_int = 19; +pub const SS: ::c_int = 20; +pub const FS_BASE: ::c_int = 21; +pub const GS_BASE: ::c_int = 22; +pub const DS: ::c_int = 23; +pub const ES: ::c_int = 24; +pub const FS: ::c_int = 25; +pub const GS: ::c_int = 26; + +// offsets in mcontext_t.gregs from sys/ucontext.h +pub const REG_R8: ::c_int = 0; +pub const REG_R9: ::c_int = 1; +pub const REG_R10: ::c_int = 2; +pub const REG_R11: ::c_int = 3; +pub const REG_R12: ::c_int = 4; +pub const REG_R13: ::c_int = 5; +pub const REG_R14: ::c_int = 6; +pub const REG_R15: ::c_int = 7; +pub const REG_RDI: ::c_int = 8; +pub const REG_RSI: ::c_int = 9; +pub const REG_RBP: ::c_int = 10; +pub const REG_RBX: ::c_int = 11; +pub const REG_RDX: ::c_int = 12; +pub const REG_RAX: ::c_int = 13; +pub const REG_RCX: ::c_int = 14; +pub const REG_RSP: ::c_int = 15; +pub const REG_RIP: ::c_int = 16; +pub const REG_EFL: ::c_int = 17; +pub const REG_CSGSFS: ::c_int = 18; +pub const REG_ERR: ::c_int = 19; +pub const REG_TRAPNO: ::c_int = 20; +pub const REG_OLDMASK: ::c_int = 21; +pub const REG_CR2: ::c_int = 22; + +extern "C" { + pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; + pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; + pub fn makecontext( + ucp: *mut ucontext_t, + func: extern "C" fn(), + argc: ::c_int, + ... + ); + pub fn swapcontext( + uocp: *mut ucontext_t, + ucp: *const ucontext_t, + ) -> ::c_int; + pub fn iopl(level: ::c_int) -> ::c_int; + pub fn ioperm( + from: ::c_ulong, + num: ::c_ulong, + turn_on: ::c_int, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + mod x32; + pub use self::x32::*; + } else { + mod not_x32; + pub use self::not_x32::*; + } +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs new file mode 100644 index 0000000..64a6de9 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs @@ -0,0 +1,423 @@ +use pthread_mutex_t; + +pub type c_long = i64; +pub type c_ulong = u64; + +s! { + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } +} + +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + +align_const! { + #[cfg(target_endian = "little")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + +// Syscall table + +pub const SYS_read: ::c_long = 0; +pub const SYS_write: ::c_long = 1; +pub const SYS_open: ::c_long = 2; +pub const SYS_close: ::c_long = 3; +pub const SYS_stat: ::c_long = 4; +pub const SYS_fstat: ::c_long = 5; +pub const SYS_lstat: ::c_long = 6; +pub const SYS_poll: ::c_long = 7; +pub const SYS_lseek: ::c_long = 8; +pub const SYS_mmap: ::c_long = 9; +pub const SYS_mprotect: ::c_long = 10; +pub const SYS_munmap: ::c_long = 11; +pub const SYS_brk: ::c_long = 12; +pub const SYS_rt_sigaction: ::c_long = 13; +pub const SYS_rt_sigprocmask: ::c_long = 14; +pub const SYS_rt_sigreturn: ::c_long = 15; +pub const SYS_ioctl: ::c_long = 16; +pub const SYS_pread64: ::c_long = 17; +pub const SYS_pwrite64: ::c_long = 18; +pub const SYS_readv: ::c_long = 19; +pub const SYS_writev: ::c_long = 20; +pub const SYS_access: ::c_long = 21; +pub const SYS_pipe: ::c_long = 22; +pub const SYS_select: ::c_long = 23; +pub const SYS_sched_yield: ::c_long = 24; +pub const SYS_mremap: ::c_long = 25; +pub const SYS_msync: ::c_long = 26; +pub const SYS_mincore: ::c_long = 27; +pub const SYS_madvise: ::c_long = 28; +pub const SYS_shmget: ::c_long = 29; +pub const SYS_shmat: ::c_long = 30; +pub const SYS_shmctl: ::c_long = 31; +pub const SYS_dup: ::c_long = 32; +pub const SYS_dup2: ::c_long = 33; +pub const SYS_pause: ::c_long = 34; +pub const SYS_nanosleep: ::c_long = 35; +pub const SYS_getitimer: ::c_long = 36; +pub const SYS_alarm: ::c_long = 37; +pub const SYS_setitimer: ::c_long = 38; +pub const SYS_getpid: ::c_long = 39; +pub const SYS_sendfile: ::c_long = 40; +pub const SYS_socket: ::c_long = 41; +pub const SYS_connect: ::c_long = 42; +pub const SYS_accept: ::c_long = 43; +pub const SYS_sendto: ::c_long = 44; +pub const SYS_recvfrom: ::c_long = 45; +pub const SYS_sendmsg: ::c_long = 46; +pub const SYS_recvmsg: ::c_long = 47; +pub const SYS_shutdown: ::c_long = 48; +pub const SYS_bind: ::c_long = 49; +pub const SYS_listen: ::c_long = 50; +pub const SYS_getsockname: ::c_long = 51; +pub const SYS_getpeername: ::c_long = 52; +pub const SYS_socketpair: ::c_long = 53; +pub const SYS_setsockopt: ::c_long = 54; +pub const SYS_getsockopt: ::c_long = 55; +pub const SYS_clone: ::c_long = 56; +pub const SYS_fork: ::c_long = 57; +pub const SYS_vfork: ::c_long = 58; +pub const SYS_execve: ::c_long = 59; +pub const SYS_exit: ::c_long = 60; +pub const SYS_wait4: ::c_long = 61; +pub const SYS_kill: ::c_long = 62; +pub const SYS_uname: ::c_long = 63; +pub const SYS_semget: ::c_long = 64; +pub const SYS_semop: ::c_long = 65; +pub const SYS_semctl: ::c_long = 66; +pub const SYS_shmdt: ::c_long = 67; +pub const SYS_msgget: ::c_long = 68; +pub const SYS_msgsnd: ::c_long = 69; +pub const SYS_msgrcv: ::c_long = 70; +pub const SYS_msgctl: ::c_long = 71; +pub const SYS_fcntl: ::c_long = 72; +pub const SYS_flock: ::c_long = 73; +pub const SYS_fsync: ::c_long = 74; +pub const SYS_fdatasync: ::c_long = 75; +pub const SYS_truncate: ::c_long = 76; +pub const SYS_ftruncate: ::c_long = 77; +pub const SYS_getdents: ::c_long = 78; +pub const SYS_getcwd: ::c_long = 79; +pub const SYS_chdir: ::c_long = 80; +pub const SYS_fchdir: ::c_long = 81; +pub const SYS_rename: ::c_long = 82; +pub const SYS_mkdir: ::c_long = 83; +pub const SYS_rmdir: ::c_long = 84; +pub const SYS_creat: ::c_long = 85; +pub const SYS_link: ::c_long = 86; +pub const SYS_unlink: ::c_long = 87; +pub const SYS_symlink: ::c_long = 88; +pub const SYS_readlink: ::c_long = 89; +pub const SYS_chmod: ::c_long = 90; +pub const SYS_fchmod: ::c_long = 91; +pub const SYS_chown: ::c_long = 92; +pub const SYS_fchown: ::c_long = 93; +pub const SYS_lchown: ::c_long = 94; +pub const SYS_umask: ::c_long = 95; +pub const SYS_gettimeofday: ::c_long = 96; +pub const SYS_getrlimit: ::c_long = 97; +pub const SYS_getrusage: ::c_long = 98; +pub const SYS_sysinfo: ::c_long = 99; +pub const SYS_times: ::c_long = 100; +pub const SYS_ptrace: ::c_long = 101; +pub const SYS_getuid: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_getgid: ::c_long = 104; +pub const SYS_setuid: ::c_long = 105; +pub const SYS_setgid: ::c_long = 106; +pub const SYS_geteuid: ::c_long = 107; +pub const SYS_getegid: ::c_long = 108; +pub const SYS_setpgid: ::c_long = 109; +pub const SYS_getppid: ::c_long = 110; +pub const SYS_getpgrp: ::c_long = 111; +pub const SYS_setsid: ::c_long = 112; +pub const SYS_setreuid: ::c_long = 113; +pub const SYS_setregid: ::c_long = 114; +pub const SYS_getgroups: ::c_long = 115; +pub const SYS_setgroups: ::c_long = 116; +pub const SYS_setresuid: ::c_long = 117; +pub const SYS_getresuid: ::c_long = 118; +pub const SYS_setresgid: ::c_long = 119; +pub const SYS_getresgid: ::c_long = 120; +pub const SYS_getpgid: ::c_long = 121; +pub const SYS_setfsuid: ::c_long = 122; +pub const SYS_setfsgid: ::c_long = 123; +pub const SYS_getsid: ::c_long = 124; +pub const SYS_capget: ::c_long = 125; +pub const SYS_capset: ::c_long = 126; +pub const SYS_rt_sigpending: ::c_long = 127; +pub const SYS_rt_sigtimedwait: ::c_long = 128; +pub const SYS_rt_sigqueueinfo: ::c_long = 129; +pub const SYS_rt_sigsuspend: ::c_long = 130; +pub const SYS_sigaltstack: ::c_long = 131; +pub const SYS_utime: ::c_long = 132; +pub const SYS_mknod: ::c_long = 133; +pub const SYS_uselib: ::c_long = 134; +pub const SYS_personality: ::c_long = 135; +pub const SYS_ustat: ::c_long = 136; +pub const SYS_statfs: ::c_long = 137; +pub const SYS_fstatfs: ::c_long = 138; +pub const SYS_sysfs: ::c_long = 139; +pub const SYS_getpriority: ::c_long = 140; +pub const SYS_setpriority: ::c_long = 141; +pub const SYS_sched_setparam: ::c_long = 142; +pub const SYS_sched_getparam: ::c_long = 143; +pub const SYS_sched_setscheduler: ::c_long = 144; +pub const SYS_sched_getscheduler: ::c_long = 145; +pub const SYS_sched_get_priority_max: ::c_long = 146; +pub const SYS_sched_get_priority_min: ::c_long = 147; +pub const SYS_sched_rr_get_interval: ::c_long = 148; +pub const SYS_mlock: ::c_long = 149; +pub const SYS_munlock: ::c_long = 150; +pub const SYS_mlockall: ::c_long = 151; +pub const SYS_munlockall: ::c_long = 152; +pub const SYS_vhangup: ::c_long = 153; +pub const SYS_modify_ldt: ::c_long = 154; +pub const SYS_pivot_root: ::c_long = 155; +pub const SYS__sysctl: ::c_long = 156; +pub const SYS_prctl: ::c_long = 157; +pub const SYS_arch_prctl: ::c_long = 158; +pub const SYS_adjtimex: ::c_long = 159; +pub const SYS_setrlimit: ::c_long = 160; +pub const SYS_chroot: ::c_long = 161; +pub const SYS_sync: ::c_long = 162; +pub const SYS_acct: ::c_long = 163; +pub const SYS_settimeofday: ::c_long = 164; +pub const SYS_mount: ::c_long = 165; +pub const SYS_umount2: ::c_long = 166; +pub const SYS_swapon: ::c_long = 167; +pub const SYS_swapoff: ::c_long = 168; +pub const SYS_reboot: ::c_long = 169; +pub const SYS_sethostname: ::c_long = 170; +pub const SYS_setdomainname: ::c_long = 171; +pub const SYS_iopl: ::c_long = 172; +pub const SYS_ioperm: ::c_long = 173; +pub const SYS_create_module: ::c_long = 174; +pub const SYS_init_module: ::c_long = 175; +pub const SYS_delete_module: ::c_long = 176; +pub const SYS_get_kernel_syms: ::c_long = 177; +pub const SYS_query_module: ::c_long = 178; +pub const SYS_quotactl: ::c_long = 179; +pub const SYS_nfsservctl: ::c_long = 180; +pub const SYS_getpmsg: ::c_long = 181; +pub const SYS_putpmsg: ::c_long = 182; +pub const SYS_afs_syscall: ::c_long = 183; +pub const SYS_tuxcall: ::c_long = 184; +pub const SYS_security: ::c_long = 185; +pub const SYS_gettid: ::c_long = 186; +pub const SYS_readahead: ::c_long = 187; +pub const SYS_setxattr: ::c_long = 188; +pub const SYS_lsetxattr: ::c_long = 189; +pub const SYS_fsetxattr: ::c_long = 190; +pub const SYS_getxattr: ::c_long = 191; +pub const SYS_lgetxattr: ::c_long = 192; +pub const SYS_fgetxattr: ::c_long = 193; +pub const SYS_listxattr: ::c_long = 194; +pub const SYS_llistxattr: ::c_long = 195; +pub const SYS_flistxattr: ::c_long = 196; +pub const SYS_removexattr: ::c_long = 197; +pub const SYS_lremovexattr: ::c_long = 198; +pub const SYS_fremovexattr: ::c_long = 199; +pub const SYS_tkill: ::c_long = 200; +pub const SYS_time: ::c_long = 201; +pub const SYS_futex: ::c_long = 202; +pub const SYS_sched_setaffinity: ::c_long = 203; +pub const SYS_sched_getaffinity: ::c_long = 204; +pub const SYS_set_thread_area: ::c_long = 205; +pub const SYS_io_setup: ::c_long = 206; +pub const SYS_io_destroy: ::c_long = 207; +pub const SYS_io_getevents: ::c_long = 208; +pub const SYS_io_submit: ::c_long = 209; +pub const SYS_io_cancel: ::c_long = 210; +pub const SYS_get_thread_area: ::c_long = 211; +pub const SYS_lookup_dcookie: ::c_long = 212; +pub const SYS_epoll_create: ::c_long = 213; +pub const SYS_epoll_ctl_old: ::c_long = 214; +pub const SYS_epoll_wait_old: ::c_long = 215; +pub const SYS_remap_file_pages: ::c_long = 216; +pub const SYS_getdents64: ::c_long = 217; +pub const SYS_set_tid_address: ::c_long = 218; +pub const SYS_restart_syscall: ::c_long = 219; +pub const SYS_semtimedop: ::c_long = 220; +pub const SYS_fadvise64: ::c_long = 221; +pub const SYS_timer_create: ::c_long = 222; +pub const SYS_timer_settime: ::c_long = 223; +pub const SYS_timer_gettime: ::c_long = 224; +pub const SYS_timer_getoverrun: ::c_long = 225; +pub const SYS_timer_delete: ::c_long = 226; +pub const SYS_clock_settime: ::c_long = 227; +pub const SYS_clock_gettime: ::c_long = 228; +pub const SYS_clock_getres: ::c_long = 229; +pub const SYS_clock_nanosleep: ::c_long = 230; +pub const SYS_exit_group: ::c_long = 231; +pub const SYS_epoll_wait: ::c_long = 232; +pub const SYS_epoll_ctl: ::c_long = 233; +pub const SYS_tgkill: ::c_long = 234; +pub const SYS_utimes: ::c_long = 235; +pub const SYS_vserver: ::c_long = 236; +pub const SYS_mbind: ::c_long = 237; +pub const SYS_set_mempolicy: ::c_long = 238; +pub const SYS_get_mempolicy: ::c_long = 239; +pub const SYS_mq_open: ::c_long = 240; +pub const SYS_mq_unlink: ::c_long = 241; +pub const SYS_mq_timedsend: ::c_long = 242; +pub const SYS_mq_timedreceive: ::c_long = 243; +pub const SYS_mq_notify: ::c_long = 244; +pub const SYS_mq_getsetattr: ::c_long = 245; +pub const SYS_kexec_load: ::c_long = 246; +pub const SYS_waitid: ::c_long = 247; +pub const SYS_add_key: ::c_long = 248; +pub const SYS_request_key: ::c_long = 249; +pub const SYS_keyctl: ::c_long = 250; +pub const SYS_ioprio_set: ::c_long = 251; +pub const SYS_ioprio_get: ::c_long = 252; +pub const SYS_inotify_init: ::c_long = 253; +pub const SYS_inotify_add_watch: ::c_long = 254; +pub const SYS_inotify_rm_watch: ::c_long = 255; +pub const SYS_migrate_pages: ::c_long = 256; +pub const SYS_openat: ::c_long = 257; +pub const SYS_mkdirat: ::c_long = 258; +pub const SYS_mknodat: ::c_long = 259; +pub const SYS_fchownat: ::c_long = 260; +pub const SYS_futimesat: ::c_long = 261; +pub const SYS_newfstatat: ::c_long = 262; +pub const SYS_unlinkat: ::c_long = 263; +pub const SYS_renameat: ::c_long = 264; +pub const SYS_linkat: ::c_long = 265; +pub const SYS_symlinkat: ::c_long = 266; +pub const SYS_readlinkat: ::c_long = 267; +pub const SYS_fchmodat: ::c_long = 268; +pub const SYS_faccessat: ::c_long = 269; +pub const SYS_pselect6: ::c_long = 270; +pub const SYS_ppoll: ::c_long = 271; +pub const SYS_unshare: ::c_long = 272; +pub const SYS_set_robust_list: ::c_long = 273; +pub const SYS_get_robust_list: ::c_long = 274; +pub const SYS_splice: ::c_long = 275; +pub const SYS_tee: ::c_long = 276; +pub const SYS_sync_file_range: ::c_long = 277; +pub const SYS_vmsplice: ::c_long = 278; +pub const SYS_move_pages: ::c_long = 279; +pub const SYS_utimensat: ::c_long = 280; +pub const SYS_epoll_pwait: ::c_long = 281; +pub const SYS_signalfd: ::c_long = 282; +pub const SYS_timerfd_create: ::c_long = 283; +pub const SYS_eventfd: ::c_long = 284; +pub const SYS_fallocate: ::c_long = 285; +pub const SYS_timerfd_settime: ::c_long = 286; +pub const SYS_timerfd_gettime: ::c_long = 287; +pub const SYS_accept4: ::c_long = 288; +pub const SYS_signalfd4: ::c_long = 289; +pub const SYS_eventfd2: ::c_long = 290; +pub const SYS_epoll_create1: ::c_long = 291; +pub const SYS_dup3: ::c_long = 292; +pub const SYS_pipe2: ::c_long = 293; +pub const SYS_inotify_init1: ::c_long = 294; +pub const SYS_preadv: ::c_long = 295; +pub const SYS_pwritev: ::c_long = 296; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 297; +pub const SYS_perf_event_open: ::c_long = 298; +pub const SYS_recvmmsg: ::c_long = 299; +pub const SYS_fanotify_init: ::c_long = 300; +pub const SYS_fanotify_mark: ::c_long = 301; +pub const SYS_prlimit64: ::c_long = 302; +pub const SYS_name_to_handle_at: ::c_long = 303; +pub const SYS_open_by_handle_at: ::c_long = 304; +pub const SYS_clock_adjtime: ::c_long = 305; +pub const SYS_syncfs: ::c_long = 306; +pub const SYS_sendmmsg: ::c_long = 307; +pub const SYS_setns: ::c_long = 308; +pub const SYS_getcpu: ::c_long = 309; +pub const SYS_process_vm_readv: ::c_long = 310; +pub const SYS_process_vm_writev: ::c_long = 311; +pub const SYS_kcmp: ::c_long = 312; +pub const SYS_finit_module: ::c_long = 313; +pub const SYS_sched_setattr: ::c_long = 314; +pub const SYS_sched_getattr: ::c_long = 315; +pub const SYS_renameat2: ::c_long = 316; +pub const SYS_seccomp: ::c_long = 317; +pub const SYS_getrandom: ::c_long = 318; +pub const SYS_memfd_create: ::c_long = 319; +pub const SYS_kexec_file_load: ::c_long = 320; +pub const SYS_bpf: ::c_long = 321; +pub const SYS_execveat: ::c_long = 322; +pub const SYS_userfaultfd: ::c_long = 323; +pub const SYS_membarrier: ::c_long = 324; +pub const SYS_mlock2: ::c_long = 325; +pub const SYS_copy_file_range: ::c_long = 326; +pub const SYS_preadv2: ::c_long = 327; +pub const SYS_pwritev2: ::c_long = 328; +pub const SYS_pkey_mprotect: ::c_long = 329; +pub const SYS_pkey_alloc: ::c_long = 330; +pub const SYS_pkey_free: ::c_long = 331; +pub const SYS_statx: ::c_long = 332; + +#[link(name = "util")] +extern "C" { + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs new file mode 100644 index 0000000..3746881 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs @@ -0,0 +1,375 @@ +use pthread_mutex_t; + +pub type c_long = i32; +pub type c_ulong = u32; + +s! { + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } +} + +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 44; + +align_const! { + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + +// Syscall table + +pub const __X32_SYSCALL_BIT: ::c_long = 0x40000000; + +pub const SYS_read: ::c_long = __X32_SYSCALL_BIT + 0; +pub const SYS_write: ::c_long = __X32_SYSCALL_BIT + 1; +pub const SYS_open: ::c_long = __X32_SYSCALL_BIT + 2; +pub const SYS_close: ::c_long = __X32_SYSCALL_BIT + 3; +pub const SYS_stat: ::c_long = __X32_SYSCALL_BIT + 4; +pub const SYS_fstat: ::c_long = __X32_SYSCALL_BIT + 5; +pub const SYS_lstat: ::c_long = __X32_SYSCALL_BIT + 6; +pub const SYS_poll: ::c_long = __X32_SYSCALL_BIT + 7; +pub const SYS_lseek: ::c_long = __X32_SYSCALL_BIT + 8; +pub const SYS_mmap: ::c_long = __X32_SYSCALL_BIT + 9; +pub const SYS_mprotect: ::c_long = __X32_SYSCALL_BIT + 10; +pub const SYS_munmap: ::c_long = __X32_SYSCALL_BIT + 11; +pub const SYS_brk: ::c_long = __X32_SYSCALL_BIT + 12; +pub const SYS_rt_sigprocmask: ::c_long = __X32_SYSCALL_BIT + 14; +pub const SYS_pread64: ::c_long = __X32_SYSCALL_BIT + 17; +pub const SYS_pwrite64: ::c_long = __X32_SYSCALL_BIT + 18; +pub const SYS_access: ::c_long = __X32_SYSCALL_BIT + 21; +pub const SYS_pipe: ::c_long = __X32_SYSCALL_BIT + 22; +pub const SYS_select: ::c_long = __X32_SYSCALL_BIT + 23; +pub const SYS_sched_yield: ::c_long = __X32_SYSCALL_BIT + 24; +pub const SYS_mremap: ::c_long = __X32_SYSCALL_BIT + 25; +pub const SYS_msync: ::c_long = __X32_SYSCALL_BIT + 26; +pub const SYS_mincore: ::c_long = __X32_SYSCALL_BIT + 27; +pub const SYS_madvise: ::c_long = __X32_SYSCALL_BIT + 28; +pub const SYS_shmget: ::c_long = __X32_SYSCALL_BIT + 29; +pub const SYS_shmat: ::c_long = __X32_SYSCALL_BIT + 30; +pub const SYS_shmctl: ::c_long = __X32_SYSCALL_BIT + 31; +pub const SYS_dup: ::c_long = __X32_SYSCALL_BIT + 32; +pub const SYS_dup2: ::c_long = __X32_SYSCALL_BIT + 33; +pub const SYS_pause: ::c_long = __X32_SYSCALL_BIT + 34; +pub const SYS_nanosleep: ::c_long = __X32_SYSCALL_BIT + 35; +pub const SYS_getitimer: ::c_long = __X32_SYSCALL_BIT + 36; +pub const SYS_alarm: ::c_long = __X32_SYSCALL_BIT + 37; +pub const SYS_setitimer: ::c_long = __X32_SYSCALL_BIT + 38; +pub const SYS_getpid: ::c_long = __X32_SYSCALL_BIT + 39; +pub const SYS_sendfile: ::c_long = __X32_SYSCALL_BIT + 40; +pub const SYS_socket: ::c_long = __X32_SYSCALL_BIT + 41; +pub const SYS_connect: ::c_long = __X32_SYSCALL_BIT + 42; +pub const SYS_accept: ::c_long = __X32_SYSCALL_BIT + 43; +pub const SYS_sendto: ::c_long = __X32_SYSCALL_BIT + 44; +pub const SYS_shutdown: ::c_long = __X32_SYSCALL_BIT + 48; +pub const SYS_bind: ::c_long = __X32_SYSCALL_BIT + 49; +pub const SYS_listen: ::c_long = __X32_SYSCALL_BIT + 50; +pub const SYS_getsockname: ::c_long = __X32_SYSCALL_BIT + 51; +pub const SYS_getpeername: ::c_long = __X32_SYSCALL_BIT + 52; +pub const SYS_socketpair: ::c_long = __X32_SYSCALL_BIT + 53; +pub const SYS_clone: ::c_long = __X32_SYSCALL_BIT + 56; +pub const SYS_fork: ::c_long = __X32_SYSCALL_BIT + 57; +pub const SYS_vfork: ::c_long = __X32_SYSCALL_BIT + 58; +pub const SYS_exit: ::c_long = __X32_SYSCALL_BIT + 60; +pub const SYS_wait4: ::c_long = __X32_SYSCALL_BIT + 61; +pub const SYS_kill: ::c_long = __X32_SYSCALL_BIT + 62; +pub const SYS_uname: ::c_long = __X32_SYSCALL_BIT + 63; +pub const SYS_semget: ::c_long = __X32_SYSCALL_BIT + 64; +pub const SYS_semop: ::c_long = __X32_SYSCALL_BIT + 65; +pub const SYS_semctl: ::c_long = __X32_SYSCALL_BIT + 66; +pub const SYS_shmdt: ::c_long = __X32_SYSCALL_BIT + 67; +pub const SYS_msgget: ::c_long = __X32_SYSCALL_BIT + 68; +pub const SYS_msgsnd: ::c_long = __X32_SYSCALL_BIT + 69; +pub const SYS_msgrcv: ::c_long = __X32_SYSCALL_BIT + 70; +pub const SYS_msgctl: ::c_long = __X32_SYSCALL_BIT + 71; +pub const SYS_fcntl: ::c_long = __X32_SYSCALL_BIT + 72; +pub const SYS_flock: ::c_long = __X32_SYSCALL_BIT + 73; +pub const SYS_fsync: ::c_long = __X32_SYSCALL_BIT + 74; +pub const SYS_fdatasync: ::c_long = __X32_SYSCALL_BIT + 75; +pub const SYS_truncate: ::c_long = __X32_SYSCALL_BIT + 76; +pub const SYS_ftruncate: ::c_long = __X32_SYSCALL_BIT + 77; +pub const SYS_getdents: ::c_long = __X32_SYSCALL_BIT + 78; +pub const SYS_getcwd: ::c_long = __X32_SYSCALL_BIT + 79; +pub const SYS_chdir: ::c_long = __X32_SYSCALL_BIT + 80; +pub const SYS_fchdir: ::c_long = __X32_SYSCALL_BIT + 81; +pub const SYS_rename: ::c_long = __X32_SYSCALL_BIT + 82; +pub const SYS_mkdir: ::c_long = __X32_SYSCALL_BIT + 83; +pub const SYS_rmdir: ::c_long = __X32_SYSCALL_BIT + 84; +pub const SYS_creat: ::c_long = __X32_SYSCALL_BIT + 85; +pub const SYS_link: ::c_long = __X32_SYSCALL_BIT + 86; +pub const SYS_unlink: ::c_long = __X32_SYSCALL_BIT + 87; +pub const SYS_symlink: ::c_long = __X32_SYSCALL_BIT + 88; +pub const SYS_readlink: ::c_long = __X32_SYSCALL_BIT + 89; +pub const SYS_chmod: ::c_long = __X32_SYSCALL_BIT + 90; +pub const SYS_fchmod: ::c_long = __X32_SYSCALL_BIT + 91; +pub const SYS_chown: ::c_long = __X32_SYSCALL_BIT + 92; +pub const SYS_fchown: ::c_long = __X32_SYSCALL_BIT + 93; +pub const SYS_lchown: ::c_long = __X32_SYSCALL_BIT + 94; +pub const SYS_umask: ::c_long = __X32_SYSCALL_BIT + 95; +pub const SYS_gettimeofday: ::c_long = __X32_SYSCALL_BIT + 96; +pub const SYS_getrlimit: ::c_long = __X32_SYSCALL_BIT + 97; +pub const SYS_getrusage: ::c_long = __X32_SYSCALL_BIT + 98; +pub const SYS_sysinfo: ::c_long = __X32_SYSCALL_BIT + 99; +pub const SYS_times: ::c_long = __X32_SYSCALL_BIT + 100; +pub const SYS_getuid: ::c_long = __X32_SYSCALL_BIT + 102; +pub const SYS_syslog: ::c_long = __X32_SYSCALL_BIT + 103; +pub const SYS_getgid: ::c_long = __X32_SYSCALL_BIT + 104; +pub const SYS_setuid: ::c_long = __X32_SYSCALL_BIT + 105; +pub const SYS_setgid: ::c_long = __X32_SYSCALL_BIT + 106; +pub const SYS_geteuid: ::c_long = __X32_SYSCALL_BIT + 107; +pub const SYS_getegid: ::c_long = __X32_SYSCALL_BIT + 108; +pub const SYS_setpgid: ::c_long = __X32_SYSCALL_BIT + 109; +pub const SYS_getppid: ::c_long = __X32_SYSCALL_BIT + 110; +pub const SYS_getpgrp: ::c_long = __X32_SYSCALL_BIT + 111; +pub const SYS_setsid: ::c_long = __X32_SYSCALL_BIT + 112; +pub const SYS_setreuid: ::c_long = __X32_SYSCALL_BIT + 113; +pub const SYS_setregid: ::c_long = __X32_SYSCALL_BIT + 114; +pub const SYS_getgroups: ::c_long = __X32_SYSCALL_BIT + 115; +pub const SYS_setgroups: ::c_long = __X32_SYSCALL_BIT + 116; +pub const SYS_setresuid: ::c_long = __X32_SYSCALL_BIT + 117; +pub const SYS_getresuid: ::c_long = __X32_SYSCALL_BIT + 118; +pub const SYS_setresgid: ::c_long = __X32_SYSCALL_BIT + 119; +pub const SYS_getresgid: ::c_long = __X32_SYSCALL_BIT + 120; +pub const SYS_getpgid: ::c_long = __X32_SYSCALL_BIT + 121; +pub const SYS_setfsuid: ::c_long = __X32_SYSCALL_BIT + 122; +pub const SYS_setfsgid: ::c_long = __X32_SYSCALL_BIT + 123; +pub const SYS_getsid: ::c_long = __X32_SYSCALL_BIT + 124; +pub const SYS_capget: ::c_long = __X32_SYSCALL_BIT + 125; +pub const SYS_capset: ::c_long = __X32_SYSCALL_BIT + 126; +pub const SYS_rt_sigsuspend: ::c_long = __X32_SYSCALL_BIT + 130; +pub const SYS_utime: ::c_long = __X32_SYSCALL_BIT + 132; +pub const SYS_mknod: ::c_long = __X32_SYSCALL_BIT + 133; +pub const SYS_personality: ::c_long = __X32_SYSCALL_BIT + 135; +pub const SYS_ustat: ::c_long = __X32_SYSCALL_BIT + 136; +pub const SYS_statfs: ::c_long = __X32_SYSCALL_BIT + 137; +pub const SYS_fstatfs: ::c_long = __X32_SYSCALL_BIT + 138; +pub const SYS_sysfs: ::c_long = __X32_SYSCALL_BIT + 139; +pub const SYS_getpriority: ::c_long = __X32_SYSCALL_BIT + 140; +pub const SYS_setpriority: ::c_long = __X32_SYSCALL_BIT + 141; +pub const SYS_sched_setparam: ::c_long = __X32_SYSCALL_BIT + 142; +pub const SYS_sched_getparam: ::c_long = __X32_SYSCALL_BIT + 143; +pub const SYS_sched_setscheduler: ::c_long = __X32_SYSCALL_BIT + 144; +pub const SYS_sched_getscheduler: ::c_long = __X32_SYSCALL_BIT + 145; +pub const SYS_sched_get_priority_max: ::c_long = __X32_SYSCALL_BIT + 146; +pub const SYS_sched_get_priority_min: ::c_long = __X32_SYSCALL_BIT + 147; +pub const SYS_sched_rr_get_interval: ::c_long = __X32_SYSCALL_BIT + 148; +pub const SYS_mlock: ::c_long = __X32_SYSCALL_BIT + 149; +pub const SYS_munlock: ::c_long = __X32_SYSCALL_BIT + 150; +pub const SYS_mlockall: ::c_long = __X32_SYSCALL_BIT + 151; +pub const SYS_munlockall: ::c_long = __X32_SYSCALL_BIT + 152; +pub const SYS_vhangup: ::c_long = __X32_SYSCALL_BIT + 153; +pub const SYS_modify_ldt: ::c_long = __X32_SYSCALL_BIT + 154; +pub const SYS_pivot_root: ::c_long = __X32_SYSCALL_BIT + 155; +pub const SYS_prctl: ::c_long = __X32_SYSCALL_BIT + 157; +pub const SYS_arch_prctl: ::c_long = __X32_SYSCALL_BIT + 158; +pub const SYS_adjtimex: ::c_long = __X32_SYSCALL_BIT + 159; +pub const SYS_setrlimit: ::c_long = __X32_SYSCALL_BIT + 160; +pub const SYS_chroot: ::c_long = __X32_SYSCALL_BIT + 161; +pub const SYS_sync: ::c_long = __X32_SYSCALL_BIT + 162; +pub const SYS_acct: ::c_long = __X32_SYSCALL_BIT + 163; +pub const SYS_settimeofday: ::c_long = __X32_SYSCALL_BIT + 164; +pub const SYS_mount: ::c_long = __X32_SYSCALL_BIT + 165; +pub const SYS_umount2: ::c_long = __X32_SYSCALL_BIT + 166; +pub const SYS_swapon: ::c_long = __X32_SYSCALL_BIT + 167; +pub const SYS_swapoff: ::c_long = __X32_SYSCALL_BIT + 168; +pub const SYS_reboot: ::c_long = __X32_SYSCALL_BIT + 169; +pub const SYS_sethostname: ::c_long = __X32_SYSCALL_BIT + 170; +pub const SYS_setdomainname: ::c_long = __X32_SYSCALL_BIT + 171; +pub const SYS_iopl: ::c_long = __X32_SYSCALL_BIT + 172; +pub const SYS_ioperm: ::c_long = __X32_SYSCALL_BIT + 173; +pub const SYS_init_module: ::c_long = __X32_SYSCALL_BIT + 175; +pub const SYS_delete_module: ::c_long = __X32_SYSCALL_BIT + 176; +pub const SYS_quotactl: ::c_long = __X32_SYSCALL_BIT + 179; +pub const SYS_getpmsg: ::c_long = __X32_SYSCALL_BIT + 181; +pub const SYS_putpmsg: ::c_long = __X32_SYSCALL_BIT + 182; +pub const SYS_afs_syscall: ::c_long = __X32_SYSCALL_BIT + 183; +pub const SYS_tuxcall: ::c_long = __X32_SYSCALL_BIT + 184; +pub const SYS_security: ::c_long = __X32_SYSCALL_BIT + 185; +pub const SYS_gettid: ::c_long = __X32_SYSCALL_BIT + 186; +pub const SYS_readahead: ::c_long = __X32_SYSCALL_BIT + 187; +pub const SYS_setxattr: ::c_long = __X32_SYSCALL_BIT + 188; +pub const SYS_lsetxattr: ::c_long = __X32_SYSCALL_BIT + 189; +pub const SYS_fsetxattr: ::c_long = __X32_SYSCALL_BIT + 190; +pub const SYS_getxattr: ::c_long = __X32_SYSCALL_BIT + 191; +pub const SYS_lgetxattr: ::c_long = __X32_SYSCALL_BIT + 192; +pub const SYS_fgetxattr: ::c_long = __X32_SYSCALL_BIT + 193; +pub const SYS_listxattr: ::c_long = __X32_SYSCALL_BIT + 194; +pub const SYS_llistxattr: ::c_long = __X32_SYSCALL_BIT + 195; +pub const SYS_flistxattr: ::c_long = __X32_SYSCALL_BIT + 196; +pub const SYS_removexattr: ::c_long = __X32_SYSCALL_BIT + 197; +pub const SYS_lremovexattr: ::c_long = __X32_SYSCALL_BIT + 198; +pub const SYS_fremovexattr: ::c_long = __X32_SYSCALL_BIT + 199; +pub const SYS_tkill: ::c_long = __X32_SYSCALL_BIT + 200; +pub const SYS_time: ::c_long = __X32_SYSCALL_BIT + 201; +pub const SYS_futex: ::c_long = __X32_SYSCALL_BIT + 202; +pub const SYS_sched_setaffinity: ::c_long = __X32_SYSCALL_BIT + 203; +pub const SYS_sched_getaffinity: ::c_long = __X32_SYSCALL_BIT + 204; +pub const SYS_io_destroy: ::c_long = __X32_SYSCALL_BIT + 207; +pub const SYS_io_getevents: ::c_long = __X32_SYSCALL_BIT + 208; +pub const SYS_io_cancel: ::c_long = __X32_SYSCALL_BIT + 210; +pub const SYS_lookup_dcookie: ::c_long = __X32_SYSCALL_BIT + 212; +pub const SYS_epoll_create: ::c_long = __X32_SYSCALL_BIT + 213; +pub const SYS_remap_file_pages: ::c_long = __X32_SYSCALL_BIT + 216; +pub const SYS_getdents64: ::c_long = __X32_SYSCALL_BIT + 217; +pub const SYS_set_tid_address: ::c_long = __X32_SYSCALL_BIT + 218; +pub const SYS_restart_syscall: ::c_long = __X32_SYSCALL_BIT + 219; +pub const SYS_semtimedop: ::c_long = __X32_SYSCALL_BIT + 220; +pub const SYS_fadvise64: ::c_long = __X32_SYSCALL_BIT + 221; +pub const SYS_timer_settime: ::c_long = __X32_SYSCALL_BIT + 223; +pub const SYS_timer_gettime: ::c_long = __X32_SYSCALL_BIT + 224; +pub const SYS_timer_getoverrun: ::c_long = __X32_SYSCALL_BIT + 225; +pub const SYS_timer_delete: ::c_long = __X32_SYSCALL_BIT + 226; +pub const SYS_clock_settime: ::c_long = __X32_SYSCALL_BIT + 227; +pub const SYS_clock_gettime: ::c_long = __X32_SYSCALL_BIT + 228; +pub const SYS_clock_getres: ::c_long = __X32_SYSCALL_BIT + 229; +pub const SYS_clock_nanosleep: ::c_long = __X32_SYSCALL_BIT + 230; +pub const SYS_exit_group: ::c_long = __X32_SYSCALL_BIT + 231; +pub const SYS_epoll_wait: ::c_long = __X32_SYSCALL_BIT + 232; +pub const SYS_epoll_ctl: ::c_long = __X32_SYSCALL_BIT + 233; +pub const SYS_tgkill: ::c_long = __X32_SYSCALL_BIT + 234; +pub const SYS_utimes: ::c_long = __X32_SYSCALL_BIT + 235; +pub const SYS_mbind: ::c_long = __X32_SYSCALL_BIT + 237; +pub const SYS_set_mempolicy: ::c_long = __X32_SYSCALL_BIT + 238; +pub const SYS_get_mempolicy: ::c_long = __X32_SYSCALL_BIT + 239; +pub const SYS_mq_open: ::c_long = __X32_SYSCALL_BIT + 240; +pub const SYS_mq_unlink: ::c_long = __X32_SYSCALL_BIT + 241; +pub const SYS_mq_timedsend: ::c_long = __X32_SYSCALL_BIT + 242; +pub const SYS_mq_timedreceive: ::c_long = __X32_SYSCALL_BIT + 243; +pub const SYS_mq_getsetattr: ::c_long = __X32_SYSCALL_BIT + 245; +pub const SYS_add_key: ::c_long = __X32_SYSCALL_BIT + 248; +pub const SYS_request_key: ::c_long = __X32_SYSCALL_BIT + 249; +pub const SYS_keyctl: ::c_long = __X32_SYSCALL_BIT + 250; +pub const SYS_ioprio_set: ::c_long = __X32_SYSCALL_BIT + 251; +pub const SYS_ioprio_get: ::c_long = __X32_SYSCALL_BIT + 252; +pub const SYS_inotify_init: ::c_long = __X32_SYSCALL_BIT + 253; +pub const SYS_inotify_add_watch: ::c_long = __X32_SYSCALL_BIT + 254; +pub const SYS_inotify_rm_watch: ::c_long = __X32_SYSCALL_BIT + 255; +pub const SYS_migrate_pages: ::c_long = __X32_SYSCALL_BIT + 256; +pub const SYS_openat: ::c_long = __X32_SYSCALL_BIT + 257; +pub const SYS_mkdirat: ::c_long = __X32_SYSCALL_BIT + 258; +pub const SYS_mknodat: ::c_long = __X32_SYSCALL_BIT + 259; +pub const SYS_fchownat: ::c_long = __X32_SYSCALL_BIT + 260; +pub const SYS_futimesat: ::c_long = __X32_SYSCALL_BIT + 261; +pub const SYS_newfstatat: ::c_long = __X32_SYSCALL_BIT + 262; +pub const SYS_unlinkat: ::c_long = __X32_SYSCALL_BIT + 263; +pub const SYS_renameat: ::c_long = __X32_SYSCALL_BIT + 264; +pub const SYS_linkat: ::c_long = __X32_SYSCALL_BIT + 265; +pub const SYS_symlinkat: ::c_long = __X32_SYSCALL_BIT + 266; +pub const SYS_readlinkat: ::c_long = __X32_SYSCALL_BIT + 267; +pub const SYS_fchmodat: ::c_long = __X32_SYSCALL_BIT + 268; +pub const SYS_faccessat: ::c_long = __X32_SYSCALL_BIT + 269; +pub const SYS_pselect6: ::c_long = __X32_SYSCALL_BIT + 270; +pub const SYS_ppoll: ::c_long = __X32_SYSCALL_BIT + 271; +pub const SYS_unshare: ::c_long = __X32_SYSCALL_BIT + 272; +pub const SYS_splice: ::c_long = __X32_SYSCALL_BIT + 275; +pub const SYS_tee: ::c_long = __X32_SYSCALL_BIT + 276; +pub const SYS_sync_file_range: ::c_long = __X32_SYSCALL_BIT + 277; +pub const SYS_utimensat: ::c_long = __X32_SYSCALL_BIT + 280; +pub const SYS_epoll_pwait: ::c_long = __X32_SYSCALL_BIT + 281; +pub const SYS_signalfd: ::c_long = __X32_SYSCALL_BIT + 282; +pub const SYS_timerfd_create: ::c_long = __X32_SYSCALL_BIT + 283; +pub const SYS_eventfd: ::c_long = __X32_SYSCALL_BIT + 284; +pub const SYS_fallocate: ::c_long = __X32_SYSCALL_BIT + 285; +pub const SYS_timerfd_settime: ::c_long = __X32_SYSCALL_BIT + 286; +pub const SYS_timerfd_gettime: ::c_long = __X32_SYSCALL_BIT + 287; +pub const SYS_accept4: ::c_long = __X32_SYSCALL_BIT + 288; +pub const SYS_signalfd4: ::c_long = __X32_SYSCALL_BIT + 289; +pub const SYS_eventfd2: ::c_long = __X32_SYSCALL_BIT + 290; +pub const SYS_epoll_create1: ::c_long = __X32_SYSCALL_BIT + 291; +pub const SYS_dup3: ::c_long = __X32_SYSCALL_BIT + 292; +pub const SYS_pipe2: ::c_long = __X32_SYSCALL_BIT + 293; +pub const SYS_inotify_init1: ::c_long = __X32_SYSCALL_BIT + 294; +pub const SYS_perf_event_open: ::c_long = __X32_SYSCALL_BIT + 298; +pub const SYS_fanotify_init: ::c_long = __X32_SYSCALL_BIT + 300; +pub const SYS_fanotify_mark: ::c_long = __X32_SYSCALL_BIT + 301; +pub const SYS_prlimit64: ::c_long = __X32_SYSCALL_BIT + 302; +pub const SYS_name_to_handle_at: ::c_long = __X32_SYSCALL_BIT + 303; +pub const SYS_open_by_handle_at: ::c_long = __X32_SYSCALL_BIT + 304; +pub const SYS_clock_adjtime: ::c_long = __X32_SYSCALL_BIT + 305; +pub const SYS_syncfs: ::c_long = __X32_SYSCALL_BIT + 306; +pub const SYS_setns: ::c_long = __X32_SYSCALL_BIT + 308; +pub const SYS_getcpu: ::c_long = __X32_SYSCALL_BIT + 309; +pub const SYS_kcmp: ::c_long = __X32_SYSCALL_BIT + 312; +pub const SYS_finit_module: ::c_long = __X32_SYSCALL_BIT + 313; +pub const SYS_sched_setattr: ::c_long = __X32_SYSCALL_BIT + 314; +pub const SYS_sched_getattr: ::c_long = __X32_SYSCALL_BIT + 315; +pub const SYS_renameat2: ::c_long = __X32_SYSCALL_BIT + 316; +pub const SYS_seccomp: ::c_long = __X32_SYSCALL_BIT + 317; +pub const SYS_getrandom: ::c_long = __X32_SYSCALL_BIT + 318; +pub const SYS_memfd_create: ::c_long = __X32_SYSCALL_BIT + 319; +pub const SYS_kexec_file_load: ::c_long = __X32_SYSCALL_BIT + 320; +pub const SYS_bpf: ::c_long = __X32_SYSCALL_BIT + 321; +pub const SYS_userfaultfd: ::c_long = __X32_SYSCALL_BIT + 323; +pub const SYS_membarrier: ::c_long = __X32_SYSCALL_BIT + 324; +pub const SYS_mlock2: ::c_long = __X32_SYSCALL_BIT + 325; +pub const SYS_copy_file_range: ::c_long = __X32_SYSCALL_BIT + 326; +pub const SYS_pkey_mprotect: ::c_long = __X32_SYSCALL_BIT + 329; +pub const SYS_pkey_alloc: ::c_long = __X32_SYSCALL_BIT + 330; +pub const SYS_pkey_free: ::c_long = __X32_SYSCALL_BIT + 331; +pub const SYS_statx: ::c_long = __X32_SYSCALL_BIT + 332; +pub const SYS_rt_sigaction: ::c_long = __X32_SYSCALL_BIT + 512; +pub const SYS_rt_sigreturn: ::c_long = __X32_SYSCALL_BIT + 513; +pub const SYS_ioctl: ::c_long = __X32_SYSCALL_BIT + 514; +pub const SYS_readv: ::c_long = __X32_SYSCALL_BIT + 515; +pub const SYS_writev: ::c_long = __X32_SYSCALL_BIT + 516; +pub const SYS_recvfrom: ::c_long = __X32_SYSCALL_BIT + 517; +pub const SYS_sendmsg: ::c_long = __X32_SYSCALL_BIT + 518; +pub const SYS_recvmsg: ::c_long = __X32_SYSCALL_BIT + 519; +pub const SYS_execve: ::c_long = __X32_SYSCALL_BIT + 520; +pub const SYS_ptrace: ::c_long = __X32_SYSCALL_BIT + 521; +pub const SYS_rt_sigpending: ::c_long = __X32_SYSCALL_BIT + 522; +pub const SYS_rt_sigtimedwait: ::c_long = __X32_SYSCALL_BIT + 523; +pub const SYS_rt_sigqueueinfo: ::c_long = __X32_SYSCALL_BIT + 524; +pub const SYS_sigaltstack: ::c_long = __X32_SYSCALL_BIT + 525; +pub const SYS_timer_create: ::c_long = __X32_SYSCALL_BIT + 526; +pub const SYS_mq_notify: ::c_long = __X32_SYSCALL_BIT + 527; +pub const SYS_kexec_load: ::c_long = __X32_SYSCALL_BIT + 528; +pub const SYS_waitid: ::c_long = __X32_SYSCALL_BIT + 529; +pub const SYS_set_robust_list: ::c_long = __X32_SYSCALL_BIT + 530; +pub const SYS_get_robust_list: ::c_long = __X32_SYSCALL_BIT + 531; +pub const SYS_vmsplice: ::c_long = __X32_SYSCALL_BIT + 532; +pub const SYS_move_pages: ::c_long = __X32_SYSCALL_BIT + 533; +pub const SYS_preadv: ::c_long = __X32_SYSCALL_BIT + 534; +pub const SYS_pwritev: ::c_long = __X32_SYSCALL_BIT + 535; +pub const SYS_rt_tgsigqueueinfo: ::c_long = __X32_SYSCALL_BIT + 536; +pub const SYS_recvmmsg: ::c_long = __X32_SYSCALL_BIT + 537; +pub const SYS_sendmmsg: ::c_long = __X32_SYSCALL_BIT + 538; +pub const SYS_process_vm_readv: ::c_long = __X32_SYSCALL_BIT + 539; +pub const SYS_process_vm_writev: ::c_long = __X32_SYSCALL_BIT + 540; +pub const SYS_setsockopt: ::c_long = __X32_SYSCALL_BIT + 541; +pub const SYS_getsockopt: ::c_long = __X32_SYSCALL_BIT + 542; +pub const SYS_io_setup: ::c_long = __X32_SYSCALL_BIT + 543; +pub const SYS_io_submit: ::c_long = __X32_SYSCALL_BIT + 544; +pub const SYS_execveat: ::c_long = __X32_SYSCALL_BIT + 545; +pub const SYS_preadv2: ::c_long = __X32_SYSCALL_BIT + 546; +pub const SYS_pwritev2: ::c_long = __X32_SYSCALL_BIT + 547; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/mod.rs new file mode 100644 index 0000000..1d3e0ab --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/mod.rs @@ -0,0 +1,1057 @@ +pub type pthread_t = c_ulong; +pub type __priority_which_t = ::c_uint; +pub type __rlimit_resource_t = ::c_uint; + +s! { + pub struct statx { + pub stx_mask: u32, + pub stx_blksize: u32, + pub stx_attributes: u64, + pub stx_nlink: u32, + pub stx_uid: u32, + pub stx_gid: u32, + pub stx_mode: u16, + pub __statx_pad1: [u16; 1], + pub stx_ino: u64, + pub stx_size: u64, + pub stx_blocks: u64, + pub stx_attributes_mask: u64, + pub stx_atime: ::statx_timestamp, + pub stx_btime: ::statx_timestamp, + pub stx_ctime: ::statx_timestamp, + pub stx_mtime: ::statx_timestamp, + pub stx_rdev_major: u32, + pub stx_rdev_minor: u32, + pub stx_dev_major: u32, + pub stx_dev_minor: u32, + pub __statx_pad2: [u64; 14], + } + + pub struct statx_timestamp { + pub tv_sec: i64, + pub tv_nsec: u32, + pub __statx_timestamp_pad1: [i32; 1], + } + + pub struct aiocb { + pub aio_fildes: ::c_int, + pub aio_lio_opcode: ::c_int, + pub aio_reqprio: ::c_int, + pub aio_buf: *mut ::c_void, + pub aio_nbytes: ::size_t, + pub aio_sigevent: ::sigevent, + __next_prio: *mut aiocb, + __abs_prio: ::c_int, + __policy: ::c_int, + __error_code: ::c_int, + __return_value: ::ssize_t, + pub aio_offset: off_t, + #[cfg(all(not(target_arch = "x86_64"), target_pointer_width = "32"))] + __unused1: [::c_char; 4], + __glibc_reserved: [::c_char; 32] + } + + pub struct __exit_status { + pub e_termination: ::c_short, + pub e_exit: ::c_short, + } + + pub struct __timeval { + pub tv_sec: i32, + pub tv_usec: i32, + } + + pub struct glob64_t { + pub gl_pathc: ::size_t, + pub gl_pathv: *mut *mut ::c_char, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::size_t, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::size_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::size_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + #[cfg(not(any( + target_arch = "sparc", + target_arch = "sparc64", + target_arch = "mips", + target_arch = "mips64")))] + pub c_ispeed: ::speed_t, + #[cfg(not(any( + target_arch = "sparc", + target_arch = "sparc64", + target_arch = "mips", + target_arch = "mips64")))] + pub c_ospeed: ::speed_t, + } + + pub struct mallinfo { + pub arena: ::c_int, + pub ordblks: ::c_int, + pub smblks: ::c_int, + pub hblks: ::c_int, + pub hblkhd: ::c_int, + pub usmblks: ::c_int, + pub fsmblks: ::c_int, + pub uordblks: ::c_int, + pub fordblks: ::c_int, + pub keepcost: ::c_int, + } + + pub struct nlmsghdr { + pub nlmsg_len: u32, + pub nlmsg_type: u16, + pub nlmsg_flags: u16, + pub nlmsg_seq: u32, + pub nlmsg_pid: u32, + } + + pub struct nlmsgerr { + pub error: ::c_int, + pub msg: nlmsghdr, + } + + pub struct nl_pktinfo { + pub group: u32, + } + + pub struct nl_mmap_req { + pub nm_block_size: ::c_uint, + pub nm_block_nr: ::c_uint, + pub nm_frame_size: ::c_uint, + pub nm_frame_nr: ::c_uint, + } + + pub struct nl_mmap_hdr { + pub nm_status: ::c_uint, + pub nm_len: ::c_uint, + pub nm_group: u32, + pub nm_pid: u32, + pub nm_uid: u32, + pub nm_gid: u32, + } + + pub struct nlattr { + pub nla_len: u16, + pub nla_type: u16, + } + + pub struct rtentry { + pub rt_pad1: ::c_ulong, + pub rt_dst: ::sockaddr, + pub rt_gateway: ::sockaddr, + pub rt_genmask: ::sockaddr, + pub rt_flags: ::c_ushort, + pub rt_pad2: ::c_short, + pub rt_pad3: ::c_ulong, + pub rt_tos: ::c_uchar, + pub rt_class: ::c_uchar, + #[cfg(target_pointer_width = "64")] + pub rt_pad4: [::c_short; 3usize], + #[cfg(not(target_pointer_width = "64"))] + pub rt_pad4: ::c_short, + pub rt_metric: ::c_short, + pub rt_dev: *mut ::c_char, + pub rt_mtu: ::c_ulong, + pub rt_window: ::c_ulong, + pub rt_irtt: ::c_ushort, + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut ::c_void { + #[repr(C)] + struct siginfo_sigfault { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + si_addr: *mut ::c_void, + } + (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + } + + pub unsafe fn si_value(&self) -> ::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + _si_tid: ::c_int, + _si_overrun: ::c_int, + si_sigval: ::sigval, + } + (*(self as *const siginfo_t as *const siginfo_timer)).si_sigval + } +} + +s_no_extra_traits! { + pub struct utmpx { + pub ut_type: ::c_short, + pub ut_pid: ::pid_t, + pub ut_line: [::c_char; __UT_LINESIZE], + pub ut_id: [::c_char; 4], + + pub ut_user: [::c_char; __UT_NAMESIZE], + pub ut_host: [::c_char; __UT_HOSTSIZE], + pub ut_exit: __exit_status, + + #[cfg(any(target_arch = "aarch64", + target_arch = "s390x", + all(target_pointer_width = "32", + not(target_arch = "x86_64"))))] + pub ut_session: ::c_long, + #[cfg(any(target_arch = "aarch64", + target_arch = "s390x", + all(target_pointer_width = "32", + not(target_arch = "x86_64"))))] + pub ut_tv: ::timeval, + + #[cfg(not(any(target_arch = "aarch64", + target_arch = "s390x", + all(target_pointer_width = "32", + not(target_arch = "x86_64")))))] + pub ut_session: i32, + #[cfg(not(any(target_arch = "aarch64", + target_arch = "s390x", + all(target_pointer_width = "32", + not(target_arch = "x86_64")))))] + pub ut_tv: __timeval, + + pub ut_addr_v6: [i32; 4], + __glibc_reserved: [::c_char; 20], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self.ut_line == other.ut_line + && self.ut_id == other.ut_id + && self.ut_user == other.ut_user + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_addr_v6 == other.ut_addr_v6 + && self.__glibc_reserved == other.__glibc_reserved + } + } + + impl Eq for utmpx {} + + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmpx") + .field("ut_type", &self.ut_type) + .field("ut_pid", &self.ut_pid) + .field("ut_line", &self.ut_line) + .field("ut_id", &self.ut_id) + .field("ut_user", &self.ut_user) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_exit", &self.ut_exit) + .field("ut_session", &self.ut_session) + .field("ut_tv", &self.ut_tv) + .field("ut_addr_v6", &self.ut_addr_v6) + .field("__glibc_reserved", &self.__glibc_reserved) + .finish() + } + } + + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_user.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_addr_v6.hash(state); + self.__glibc_reserved.hash(state); + } + } + } +} + +pub const RLIMIT_CPU: ::__rlimit_resource_t = 0; +pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1; +pub const RLIMIT_DATA: ::__rlimit_resource_t = 2; +pub const RLIMIT_STACK: ::__rlimit_resource_t = 3; +pub const RLIMIT_CORE: ::__rlimit_resource_t = 4; +pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10; +pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11; +pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12; +pub const RLIMIT_NICE: ::__rlimit_resource_t = 13; +pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14; +pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15; +pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = 16; + +pub const MS_RMT_MASK: ::c_ulong = 0x02800051; + +pub const __UT_LINESIZE: usize = 32; +pub const __UT_NAMESIZE: usize = 32; +pub const __UT_HOSTSIZE: usize = 256; +pub const EMPTY: ::c_short = 0; +pub const RUN_LVL: ::c_short = 1; +pub const BOOT_TIME: ::c_short = 2; +pub const NEW_TIME: ::c_short = 3; +pub const OLD_TIME: ::c_short = 4; +pub const INIT_PROCESS: ::c_short = 5; +pub const LOGIN_PROCESS: ::c_short = 6; +pub const USER_PROCESS: ::c_short = 7; +pub const DEAD_PROCESS: ::c_short = 8; +pub const ACCOUNTING: ::c_short = 9; + +pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; + +pub const SOL_RXRPC: ::c_int = 272; +pub const SOL_PPPOL2TP: ::c_int = 273; +pub const SOL_PNPIPE: ::c_int = 275; +pub const SOL_RDS: ::c_int = 276; +pub const SOL_IUCV: ::c_int = 277; +pub const SOL_CAIF: ::c_int = 278; +pub const SOL_NFC: ::c_int = 280; +pub const SOL_XDP: ::c_int = 283; + +pub const MSG_TRYHARD: ::c_int = 4; + +pub const LC_PAPER: ::c_int = 7; +pub const LC_NAME: ::c_int = 8; +pub const LC_ADDRESS: ::c_int = 9; +pub const LC_TELEPHONE: ::c_int = 10; +pub const LC_MEASUREMENT: ::c_int = 11; +pub const LC_IDENTIFICATION: ::c_int = 12; +pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER); +pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME); +pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS); +pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE); +pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT); +pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION); +pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK + | ::LC_NUMERIC_MASK + | ::LC_TIME_MASK + | ::LC_COLLATE_MASK + | ::LC_MONETARY_MASK + | ::LC_MESSAGES_MASK + | LC_PAPER_MASK + | LC_NAME_MASK + | LC_ADDRESS_MASK + | LC_TELEPHONE_MASK + | LC_MEASUREMENT_MASK + | LC_IDENTIFICATION_MASK; + +pub const MAP_SHARED_VALIDATE: ::c_int = 0x3; +pub const MAP_FIXED_NOREPLACE: ::c_int = 0x100000; + +pub const ENOTSUP: ::c_int = EOPNOTSUPP; + +pub const SOCK_SEQPACKET: ::c_int = 5; +pub const SOCK_DCCP: ::c_int = 6; +pub const SOCK_PACKET: ::c_int = 10; + +pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; +pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; +pub const TCP_THIN_DUPACK: ::c_int = 17; +pub const TCP_USER_TIMEOUT: ::c_int = 18; +pub const TCP_REPAIR: ::c_int = 19; +pub const TCP_REPAIR_QUEUE: ::c_int = 20; +pub const TCP_QUEUE_SEQ: ::c_int = 21; +pub const TCP_REPAIR_OPTIONS: ::c_int = 22; +pub const TCP_FASTOPEN: ::c_int = 23; +pub const TCP_TIMESTAMP: ::c_int = 24; + +/* DCCP socket options */ +pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1; +pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2; +pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3; +pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4; +pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5; +pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6; +pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10; +pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11; +pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12; +pub const DCCP_SOCKOPT_CCID: ::c_int = 13; +pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14; +pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15; +pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16; +pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17; +pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128; +pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192; + +/// maximum number of services provided on the same listening port +pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32; + +pub const SIGEV_THREAD_ID: ::c_int = 4; + +pub const BUFSIZ: ::c_uint = 8192; +pub const TMP_MAX: ::c_uint = 238328; +pub const FOPEN_MAX: ::c_uint = 16; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; +pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41; +pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45; +pub const _SC_PII: ::c_int = 53; +pub const _SC_PII_XTI: ::c_int = 54; +pub const _SC_PII_SOCKET: ::c_int = 55; +pub const _SC_PII_INTERNET: ::c_int = 56; +pub const _SC_PII_OSI: ::c_int = 57; +pub const _SC_POLL: ::c_int = 58; +pub const _SC_SELECT: ::c_int = 59; +pub const _SC_PII_INTERNET_STREAM: ::c_int = 61; +pub const _SC_PII_INTERNET_DGRAM: ::c_int = 62; +pub const _SC_PII_OSI_COTS: ::c_int = 63; +pub const _SC_PII_OSI_CLTS: ::c_int = 64; +pub const _SC_PII_OSI_M: ::c_int = 65; +pub const _SC_T_IOV_MAX: ::c_int = 66; +pub const _SC_2_C_VERSION: ::c_int = 96; +pub const _SC_CHAR_BIT: ::c_int = 101; +pub const _SC_CHAR_MAX: ::c_int = 102; +pub const _SC_CHAR_MIN: ::c_int = 103; +pub const _SC_INT_MAX: ::c_int = 104; +pub const _SC_INT_MIN: ::c_int = 105; +pub const _SC_LONG_BIT: ::c_int = 106; +pub const _SC_WORD_BIT: ::c_int = 107; +pub const _SC_MB_LEN_MAX: ::c_int = 108; +pub const _SC_SSIZE_MAX: ::c_int = 110; +pub const _SC_SCHAR_MAX: ::c_int = 111; +pub const _SC_SCHAR_MIN: ::c_int = 112; +pub const _SC_SHRT_MAX: ::c_int = 113; +pub const _SC_SHRT_MIN: ::c_int = 114; +pub const _SC_UCHAR_MAX: ::c_int = 115; +pub const _SC_UINT_MAX: ::c_int = 116; +pub const _SC_ULONG_MAX: ::c_int = 117; +pub const _SC_USHRT_MAX: ::c_int = 118; +pub const _SC_NL_ARGMAX: ::c_int = 119; +pub const _SC_NL_LANGMAX: ::c_int = 120; +pub const _SC_NL_MSGMAX: ::c_int = 121; +pub const _SC_NL_NMAX: ::c_int = 122; +pub const _SC_NL_SETMAX: ::c_int = 123; +pub const _SC_NL_TEXTMAX: ::c_int = 124; +pub const _SC_BASE: ::c_int = 134; +pub const _SC_C_LANG_SUPPORT: ::c_int = 135; +pub const _SC_C_LANG_SUPPORT_R: ::c_int = 136; +pub const _SC_DEVICE_IO: ::c_int = 140; +pub const _SC_DEVICE_SPECIFIC: ::c_int = 141; +pub const _SC_DEVICE_SPECIFIC_R: ::c_int = 142; +pub const _SC_FD_MGMT: ::c_int = 143; +pub const _SC_FIFO: ::c_int = 144; +pub const _SC_PIPE: ::c_int = 145; +pub const _SC_FILE_ATTRIBUTES: ::c_int = 146; +pub const _SC_FILE_LOCKING: ::c_int = 147; +pub const _SC_FILE_SYSTEM: ::c_int = 148; +pub const _SC_MULTI_PROCESS: ::c_int = 150; +pub const _SC_SINGLE_PROCESS: ::c_int = 151; +pub const _SC_NETWORKING: ::c_int = 152; +pub const _SC_REGEX_VERSION: ::c_int = 156; +pub const _SC_SIGNALS: ::c_int = 158; +pub const _SC_SYSTEM_DATABASE: ::c_int = 162; +pub const _SC_SYSTEM_DATABASE_R: ::c_int = 163; +pub const _SC_USER_GROUPS: ::c_int = 166; +pub const _SC_USER_GROUPS_R: ::c_int = 167; +pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 185; +pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 186; +pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 187; +pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 188; +pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 189; +pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 190; +pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 191; +pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 192; +pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 193; +pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 194; +pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 195; +pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 196; +pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 197; +pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 198; +pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 199; +pub const O_ACCMODE: ::c_int = 3; +pub const ST_RELATIME: ::c_ulong = 4096; +pub const NI_MAXHOST: ::socklen_t = 1025; + +pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; +pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; +pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; +pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; +pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; +pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; +pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; +pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; +pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; +pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; +pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; +pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; +pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; +pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; +pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; +pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; +pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; +pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; +pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; +pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; +pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; +pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; +pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; +pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; +pub const TMPFS_MAGIC: ::c_long = 0x01021994; +pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; + +pub const CPU_SETSIZE: ::c_int = 0x400; + +pub const PTRACE_TRACEME: ::c_uint = 0; +pub const PTRACE_PEEKTEXT: ::c_uint = 1; +pub const PTRACE_PEEKDATA: ::c_uint = 2; +pub const PTRACE_PEEKUSER: ::c_uint = 3; +pub const PTRACE_POKETEXT: ::c_uint = 4; +pub const PTRACE_POKEDATA: ::c_uint = 5; +pub const PTRACE_POKEUSER: ::c_uint = 6; +pub const PTRACE_CONT: ::c_uint = 7; +pub const PTRACE_KILL: ::c_uint = 8; +pub const PTRACE_SINGLESTEP: ::c_uint = 9; +pub const PTRACE_ATTACH: ::c_uint = 16; +pub const PTRACE_SYSCALL: ::c_uint = 24; +pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; +pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; +pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; +pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; +pub const PTRACE_GETREGSET: ::c_uint = 0x4204; +pub const PTRACE_SETREGSET: ::c_uint = 0x4205; +pub const PTRACE_SEIZE: ::c_uint = 0x4206; +pub const PTRACE_INTERRUPT: ::c_uint = 0x4207; +pub const PTRACE_LISTEN: ::c_uint = 0x4208; +pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209; + +pub const EPOLLWAKEUP: ::c_int = 0x20000000; + +pub const SEEK_DATA: ::c_int = 3; +pub const SEEK_HOLE: ::c_int = 4; + +pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; +pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793; +pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278; +pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448; +pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216; + +pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567; +pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123; +pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF; +pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000; +pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC; +pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4; +pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2; +pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543; + +// linux/rtnetlink.h +pub const TCA_PAD: ::c_ushort = 9; +pub const TCA_DUMP_INVISIBLE: ::c_ushort = 10; +pub const TCA_CHAIN: ::c_ushort = 11; +pub const TCA_HW_OFFLOAD: ::c_ushort = 12; + +pub const RTM_DELNETCONF: u16 = 81; +pub const RTM_NEWSTATS: u16 = 92; +pub const RTM_GETSTATS: u16 = 94; +pub const RTM_NEWCACHEREPORT: u16 = 96; + +pub const RTM_F_LOOKUP_TABLE: ::c_uint = 0x1000; +pub const RTM_F_FIB_MATCH: ::c_uint = 0x2000; + +pub const RTA_VIA: ::c_ushort = 18; +pub const RTA_NEWDST: ::c_ushort = 19; +pub const RTA_PREF: ::c_ushort = 20; +pub const RTA_ENCAP_TYPE: ::c_ushort = 21; +pub const RTA_ENCAP: ::c_ushort = 22; +pub const RTA_EXPIRES: ::c_ushort = 23; +pub const RTA_PAD: ::c_ushort = 24; +pub const RTA_UID: ::c_ushort = 25; +pub const RTA_TTL_PROPAGATE: ::c_ushort = 26; + +// linux/neighbor.h +pub const NTF_EXT_LEARNED: u8 = 0x10; +pub const NTF_OFFLOADED: u8 = 0x20; + +pub const NDA_MASTER: ::c_ushort = 9; +pub const NDA_LINK_NETNSID: ::c_ushort = 10; +pub const NDA_SRC_VNI: ::c_ushort = 11; + +// linux/if_addr.h +pub const IFA_FLAGS: ::c_ushort = 8; + +pub const IFA_F_MANAGETEMPADDR: u32 = 0x100; +pub const IFA_F_NOPREFIXROUTE: u32 = 0x200; +pub const IFA_F_MCAUTOJOIN: u32 = 0x400; +pub const IFA_F_STABLE_PRIVACY: u32 = 0x800; + +pub const MAX_LINKS: ::c_int = 32; + +pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10; + +pub const GENL_ID_VFS_DQUOT: ::c_int = ::NLMSG_MIN_TYPE + 1; +pub const GENL_ID_PMCRAID: ::c_int = ::NLMSG_MIN_TYPE + 2; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +pub const NF_NETDEV_INGRESS: ::c_int = 0; +pub const NF_NETDEV_NUMHOOKS: ::c_int = 1; + +pub const NFPROTO_INET: ::c_int = 1; +pub const NFPROTO_NETDEV: ::c_int = 5; + +// linux/netfilter/nf_tables.h +pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256; +pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256; +pub const NFT_SET_MAXNAMELEN: ::c_int = 256; +pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256; +pub const NFT_USERDATA_MAXLEN: ::c_int = 256; + +pub const NFT_REG_VERDICT: ::c_int = 0; +pub const NFT_REG_1: ::c_int = 1; +pub const NFT_REG_2: ::c_int = 2; +pub const NFT_REG_3: ::c_int = 3; +pub const NFT_REG_4: ::c_int = 4; +pub const __NFT_REG_MAX: ::c_int = 5; +pub const NFT_REG32_00: ::c_int = 8; +pub const NFT_REG32_01: ::c_int = 9; +pub const NFT_REG32_02: ::c_int = 10; +pub const NFT_REG32_03: ::c_int = 11; +pub const NFT_REG32_04: ::c_int = 12; +pub const NFT_REG32_05: ::c_int = 13; +pub const NFT_REG32_06: ::c_int = 14; +pub const NFT_REG32_07: ::c_int = 15; +pub const NFT_REG32_08: ::c_int = 16; +pub const NFT_REG32_09: ::c_int = 17; +pub const NFT_REG32_10: ::c_int = 18; +pub const NFT_REG32_11: ::c_int = 19; +pub const NFT_REG32_12: ::c_int = 20; +pub const NFT_REG32_13: ::c_int = 21; +pub const NFT_REG32_14: ::c_int = 22; +pub const NFT_REG32_15: ::c_int = 23; + +pub const NFT_REG_SIZE: ::c_int = 16; +pub const NFT_REG32_SIZE: ::c_int = 4; + +pub const NFT_CONTINUE: ::c_int = -1; +pub const NFT_BREAK: ::c_int = -2; +pub const NFT_JUMP: ::c_int = -3; +pub const NFT_GOTO: ::c_int = -4; +pub const NFT_RETURN: ::c_int = -5; + +pub const NFT_MSG_NEWTABLE: ::c_int = 0; +pub const NFT_MSG_GETTABLE: ::c_int = 1; +pub const NFT_MSG_DELTABLE: ::c_int = 2; +pub const NFT_MSG_NEWCHAIN: ::c_int = 3; +pub const NFT_MSG_GETCHAIN: ::c_int = 4; +pub const NFT_MSG_DELCHAIN: ::c_int = 5; +pub const NFT_MSG_NEWRULE: ::c_int = 6; +pub const NFT_MSG_GETRULE: ::c_int = 7; +pub const NFT_MSG_DELRULE: ::c_int = 8; +pub const NFT_MSG_NEWSET: ::c_int = 9; +pub const NFT_MSG_GETSET: ::c_int = 10; +pub const NFT_MSG_DELSET: ::c_int = 11; +pub const NFT_MSG_NEWSETELEM: ::c_int = 12; +pub const NFT_MSG_GETSETELEM: ::c_int = 13; +pub const NFT_MSG_DELSETELEM: ::c_int = 14; +pub const NFT_MSG_NEWGEN: ::c_int = 15; +pub const NFT_MSG_GETGEN: ::c_int = 16; +pub const NFT_MSG_TRACE: ::c_int = 17; +cfg_if! { + if #[cfg(not(target_arch = "sparc64"))] { + pub const NFT_MSG_NEWOBJ: ::c_int = 18; + pub const NFT_MSG_GETOBJ: ::c_int = 19; + pub const NFT_MSG_DELOBJ: ::c_int = 20; + pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21; + } +} +pub const NFT_MSG_MAX: ::c_int = 25; + +pub const NFT_SET_ANONYMOUS: ::c_int = 0x1; +pub const NFT_SET_CONSTANT: ::c_int = 0x2; +pub const NFT_SET_INTERVAL: ::c_int = 0x4; +pub const NFT_SET_MAP: ::c_int = 0x8; +pub const NFT_SET_TIMEOUT: ::c_int = 0x10; +pub const NFT_SET_EVAL: ::c_int = 0x20; + +pub const NFT_SET_POL_PERFORMANCE: ::c_int = 0; +pub const NFT_SET_POL_MEMORY: ::c_int = 1; + +pub const NFT_SET_ELEM_INTERVAL_END: ::c_int = 0x1; + +pub const NFT_DATA_VALUE: ::c_uint = 0; +pub const NFT_DATA_VERDICT: ::c_uint = 0xffffff00; + +pub const NFT_DATA_RESERVED_MASK: ::c_uint = 0xffffff00; + +pub const NFT_DATA_VALUE_MAXLEN: ::c_int = 64; + +pub const NFT_BYTEORDER_NTOH: ::c_int = 0; +pub const NFT_BYTEORDER_HTON: ::c_int = 1; + +pub const NFT_CMP_EQ: ::c_int = 0; +pub const NFT_CMP_NEQ: ::c_int = 1; +pub const NFT_CMP_LT: ::c_int = 2; +pub const NFT_CMP_LTE: ::c_int = 3; +pub const NFT_CMP_GT: ::c_int = 4; +pub const NFT_CMP_GTE: ::c_int = 5; + +pub const NFT_RANGE_EQ: ::c_int = 0; +pub const NFT_RANGE_NEQ: ::c_int = 1; + +pub const NFT_LOOKUP_F_INV: ::c_int = (1 << 0); + +pub const NFT_DYNSET_OP_ADD: ::c_int = 0; +pub const NFT_DYNSET_OP_UPDATE: ::c_int = 1; + +pub const NFT_DYNSET_F_INV: ::c_int = (1 << 0); + +pub const NFT_PAYLOAD_LL_HEADER: ::c_int = 0; +pub const NFT_PAYLOAD_NETWORK_HEADER: ::c_int = 1; +pub const NFT_PAYLOAD_TRANSPORT_HEADER: ::c_int = 2; + +pub const NFT_PAYLOAD_CSUM_NONE: ::c_int = 0; +pub const NFT_PAYLOAD_CSUM_INET: ::c_int = 1; + +pub const NFT_META_LEN: ::c_int = 0; +pub const NFT_META_PROTOCOL: ::c_int = 1; +pub const NFT_META_PRIORITY: ::c_int = 2; +pub const NFT_META_MARK: ::c_int = 3; +pub const NFT_META_IIF: ::c_int = 4; +pub const NFT_META_OIF: ::c_int = 5; +pub const NFT_META_IIFNAME: ::c_int = 6; +pub const NFT_META_OIFNAME: ::c_int = 7; +pub const NFT_META_IIFTYPE: ::c_int = 8; +pub const NFT_META_OIFTYPE: ::c_int = 9; +pub const NFT_META_SKUID: ::c_int = 10; +pub const NFT_META_SKGID: ::c_int = 11; +pub const NFT_META_NFTRACE: ::c_int = 12; +pub const NFT_META_RTCLASSID: ::c_int = 13; +pub const NFT_META_SECMARK: ::c_int = 14; +pub const NFT_META_NFPROTO: ::c_int = 15; +pub const NFT_META_L4PROTO: ::c_int = 16; +pub const NFT_META_BRI_IIFNAME: ::c_int = 17; +pub const NFT_META_BRI_OIFNAME: ::c_int = 18; +pub const NFT_META_PKTTYPE: ::c_int = 19; +pub const NFT_META_CPU: ::c_int = 20; +pub const NFT_META_IIFGROUP: ::c_int = 21; +pub const NFT_META_OIFGROUP: ::c_int = 22; +pub const NFT_META_CGROUP: ::c_int = 23; +pub const NFT_META_PRANDOM: ::c_int = 24; + +pub const NFT_CT_STATE: ::c_int = 0; +pub const NFT_CT_DIRECTION: ::c_int = 1; +pub const NFT_CT_STATUS: ::c_int = 2; +pub const NFT_CT_MARK: ::c_int = 3; +pub const NFT_CT_SECMARK: ::c_int = 4; +pub const NFT_CT_EXPIRATION: ::c_int = 5; +pub const NFT_CT_HELPER: ::c_int = 6; +pub const NFT_CT_L3PROTOCOL: ::c_int = 7; +pub const NFT_CT_SRC: ::c_int = 8; +pub const NFT_CT_DST: ::c_int = 9; +pub const NFT_CT_PROTOCOL: ::c_int = 10; +pub const NFT_CT_PROTO_SRC: ::c_int = 11; +pub const NFT_CT_PROTO_DST: ::c_int = 12; +pub const NFT_CT_LABELS: ::c_int = 13; +pub const NFT_CT_PKTS: ::c_int = 14; +pub const NFT_CT_BYTES: ::c_int = 15; + +pub const NFT_LIMIT_PKTS: ::c_int = 0; +pub const NFT_LIMIT_PKT_BYTES: ::c_int = 1; + +pub const NFT_LIMIT_F_INV: ::c_int = (1 << 0); + +pub const NFT_QUEUE_FLAG_BYPASS: ::c_int = 0x01; +pub const NFT_QUEUE_FLAG_CPU_FANOUT: ::c_int = 0x02; +pub const NFT_QUEUE_FLAG_MASK: ::c_int = 0x03; + +pub const NFT_QUOTA_F_INV: ::c_int = (1 << 0); + +pub const NFT_REJECT_ICMP_UNREACH: ::c_int = 0; +pub const NFT_REJECT_TCP_RST: ::c_int = 1; +pub const NFT_REJECT_ICMPX_UNREACH: ::c_int = 2; + +pub const NFT_REJECT_ICMPX_NO_ROUTE: ::c_int = 0; +pub const NFT_REJECT_ICMPX_PORT_UNREACH: ::c_int = 1; +pub const NFT_REJECT_ICMPX_HOST_UNREACH: ::c_int = 2; +pub const NFT_REJECT_ICMPX_ADMIN_PROHIBITED: ::c_int = 3; + +pub const NFT_NAT_SNAT: ::c_int = 0; +pub const NFT_NAT_DNAT: ::c_int = 1; + +pub const NFT_TRACETYPE_UNSPEC: ::c_int = 0; +pub const NFT_TRACETYPE_POLICY: ::c_int = 1; +pub const NFT_TRACETYPE_RETURN: ::c_int = 2; +pub const NFT_TRACETYPE_RULE: ::c_int = 3; + +pub const NFT_NG_INCREMENTAL: ::c_int = 0; +pub const NFT_NG_RANDOM: ::c_int = 1; + +pub const M_MXFAST: ::c_int = 1; +pub const M_NLBLKS: ::c_int = 2; +pub const M_GRAIN: ::c_int = 3; +pub const M_KEEP: ::c_int = 4; +pub const M_TRIM_THRESHOLD: ::c_int = -1; +pub const M_TOP_PAD: ::c_int = -2; +pub const M_MMAP_THRESHOLD: ::c_int = -3; +pub const M_MMAP_MAX: ::c_int = -4; +pub const M_CHECK_ACTION: ::c_int = -5; +pub const M_PERTURB: ::c_int = -6; +pub const M_ARENA_TEST: ::c_int = -7; +pub const M_ARENA_MAX: ::c_int = -8; + +pub const AT_STATX_SYNC_TYPE: ::c_int = 0x6000; +pub const AT_STATX_SYNC_AS_STAT: ::c_int = 0x0000; +pub const AT_STATX_FORCE_SYNC: ::c_int = 0x2000; +pub const AT_STATX_DONT_SYNC: ::c_int = 0x4000; +pub const STATX_TYPE: ::c_uint = 0x0001; +pub const STATX_MODE: ::c_uint = 0x0002; +pub const STATX_NLINK: ::c_uint = 0x0004; +pub const STATX_UID: ::c_uint = 0x0008; +pub const STATX_GID: ::c_uint = 0x0010; +pub const STATX_ATIME: ::c_uint = 0x0020; +pub const STATX_MTIME: ::c_uint = 0x0040; +pub const STATX_CTIME: ::c_uint = 0x0080; +pub const STATX_INO: ::c_uint = 0x0100; +pub const STATX_SIZE: ::c_uint = 0x0200; +pub const STATX_BLOCKS: ::c_uint = 0x0400; +pub const STATX_BASIC_STATS: ::c_uint = 0x07ff; +pub const STATX_BTIME: ::c_uint = 0x0800; +pub const STATX_ALL: ::c_uint = 0x0fff; +pub const STATX__RESERVED: ::c_int = 0x80000000; +pub const STATX_ATTR_COMPRESSED: ::c_int = 0x0004; +pub const STATX_ATTR_IMMUTABLE: ::c_int = 0x0010; +pub const STATX_ATTR_APPEND: ::c_int = 0x0020; +pub const STATX_ATTR_NODUMP: ::c_int = 0x0040; +pub const STATX_ATTR_ENCRYPTED: ::c_int = 0x0800; +pub const STATX_ATTR_AUTOMOUNT: ::c_int = 0x1000; + +cfg_if! { + if #[cfg(any( + target_arch = "arm", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "s390x" + ))] { + pub const PTHREAD_STACK_MIN: ::size_t = 16384; + } else if #[cfg(any( + target_arch = "sparc", + target_arch = "sparc64" + ))] { + pub const PTHREAD_STACK_MIN: ::size_t = 0x6000; + } else { + pub const PTHREAD_STACK_MIN: ::size_t = 131072; + } +} +pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 3; + +extern "C" { + pub fn sendmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + ) -> ::c_int; + pub fn recvmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + timeout: *mut ::timespec, + ) -> ::c_int; + + pub fn getrlimit64( + resource: ::__rlimit_resource_t, + rlim: *mut ::rlimit64, + ) -> ::c_int; + pub fn setrlimit64( + resource: ::__rlimit_resource_t, + rlim: *const ::rlimit64, + ) -> ::c_int; + pub fn getrlimit( + resource: ::__rlimit_resource_t, + rlim: *mut ::rlimit, + ) -> ::c_int; + pub fn setrlimit( + resource: ::__rlimit_resource_t, + rlim: *const ::rlimit, + ) -> ::c_int; + pub fn prlimit( + pid: ::pid_t, + resource: ::__rlimit_resource_t, + new_limit: *const ::rlimit, + old_limit: *mut ::rlimit, + ) -> ::c_int; + pub fn prlimit64( + pid: ::pid_t, + resource: ::__rlimit_resource_t, + new_limit: *const ::rlimit64, + old_limit: *mut ::rlimit64, + ) -> ::c_int; + pub fn utmpname(file: *const ::c_char) -> ::c_int; + pub fn utmpxname(file: *const ::c_char) -> ::c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + pub fn getpt() -> ::c_int; + pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int; + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; + pub fn statx( + dirfd: ::c_int, + pathname: *const c_char, + flags: ::c_int, + mask: ::c_uint, + statxbuf: *mut statx, + ) -> ::c_int; + pub fn getrandom( + buf: *mut ::c_void, + buflen: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; +} + +#[link(name = "util")] +extern "C" { + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; + pub fn glob64( + pattern: *const ::c_char, + flags: ::c_int, + errfunc: ::Option< + extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int, + >, + pglob: *mut glob64_t, + ) -> ::c_int; + pub fn globfree64(pglob: *mut glob64_t); + pub fn ptrace(request: ::c_uint, ...) -> ::c_long; + pub fn pthread_attr_getaffinity_np( + attr: *const ::pthread_attr_t, + cpusetsize: ::size_t, + cpuset: *mut ::cpu_set_t, + ) -> ::c_int; + pub fn pthread_attr_setaffinity_np( + attr: *mut ::pthread_attr_t, + cpusetsize: ::size_t, + cpuset: *const ::cpu_set_t, + ) -> ::c_int; + pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int; + pub fn setpriority( + which: ::__priority_which_t, + who: ::id_t, + prio: ::c_int, + ) -> ::c_int; + pub fn pthread_getaffinity_np( + thread: ::pthread_t, + cpusetsize: ::size_t, + cpuset: *mut ::cpu_set_t, + ) -> ::c_int; + pub fn pthread_setaffinity_np( + thread: ::pthread_t, + cpusetsize: ::size_t, + cpuset: *const ::cpu_set_t, + ) -> ::c_int; + pub fn pthread_rwlockattr_getkind_np( + attr: *const ::pthread_rwlockattr_t, + val: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_setkind_np( + attr: *mut ::pthread_rwlockattr_t, + val: ::c_int, + ) -> ::c_int; + pub fn sched_getcpu() -> ::c_int; + pub fn mallinfo() -> ::mallinfo; + pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t; + pub fn getauxval(type_: ::c_ulong) -> ::c_ulong; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwent_r")] + pub fn getpwent_r( + pwd: *mut ::passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::passwd, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getgrent_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrent_r")] + pub fn getgrent_r( + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + pub fn pthread_getname_np( + thread: ::pthread_t, + name: *mut ::c_char, + len: ::size_t, + ) -> ::c_int; + pub fn pthread_setname_np( + thread: ::pthread_t, + name: *const ::c_char, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(any(target_arch = "x86", + target_arch = "arm", + target_arch = "mips", + target_arch = "powerpc", + target_arch = "sparc"))] { + mod b32; + pub use self::b32::*; + } else if #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + target_arch = "riscv64"))] { + mod b64; + pub use self::b64::*; + } else { + // Unknown target_arch + } +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/no_align.rs new file mode 100644 index 0000000..e32bf67 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/gnu/no_align.rs @@ -0,0 +1,10 @@ +s! { + // FIXME this is actually a union + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + __align: [::c_long; 0], + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/mod.rs new file mode 100644 index 0000000..80505ff --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/mod.rs @@ -0,0 +1,3194 @@ +//! Linux-specific definitions for linux-like values + +pub type useconds_t = u32; +pub type dev_t = u64; +pub type socklen_t = u32; +pub type mode_t = u32; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; +pub type rlim64_t = u64; +pub type mqd_t = ::c_int; +pub type nfds_t = ::c_ulong; +pub type nl_item = ::c_int; +pub type idtype_t = ::c_uint; +pub type loff_t = ::c_longlong; +pub type pthread_key_t = ::c_uint; + +pub type __u8 = ::c_uchar; +pub type __u16 = ::c_ushort; +pub type __s16 = ::c_short; +pub type __u32 = ::c_uint; +pub type __s32 = ::c_int; + +pub type Elf32_Half = u16; +pub type Elf32_Word = u32; +pub type Elf32_Off = u32; +pub type Elf32_Addr = u32; + +pub type Elf64_Half = u16; +pub type Elf64_Word = u32; +pub type Elf64_Off = u64; +pub type Elf64_Addr = u64; +pub type Elf64_Xword = u64; +pub type Elf64_Sxword = i64; + +pub type Elf32_Section = u16; +pub type Elf64_Section = u16; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum fpos64_t {} // TODO: fill this out with a struct +impl ::Copy for fpos64_t {} +impl ::Clone for fpos64_t { + fn clone(&self) -> fpos64_t { + *self + } +} + +s! { + pub struct rlimit64 { + pub rlim_cur: rlim64_t, + pub rlim_max: rlim64_t, + } + + pub struct glob_t { + pub gl_pathc: ::size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct spwd { + pub sp_namp: *mut ::c_char, + pub sp_pwdp: *mut ::c_char, + pub sp_lstchg: ::c_long, + pub sp_min: ::c_long, + pub sp_max: ::c_long, + pub sp_warn: ::c_long, + pub sp_inact: ::c_long, + pub sp_expire: ::c_long, + pub sp_flag: ::c_ulong, + } + + pub struct dqblk { + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curspace: u64, + pub dqb_ihardlimit: u64, + pub dqb_isoftlimit: u64, + pub dqb_curinodes: u64, + pub dqb_btime: u64, + pub dqb_itime: u64, + pub dqb_valid: u32, + } + + pub struct signalfd_siginfo { + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: u16, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: [u8; 28], + } + + pub struct itimerspec { + pub it_interval: ::timespec, + pub it_value: ::timespec, + } + + pub struct fsid_t { + __val: [::c_int; 2], + } + + pub struct packet_mreq { + pub mr_ifindex: ::c_int, + pub mr_type: ::c_ushort, + pub mr_alen: ::c_ushort, + pub mr_address: [::c_uchar; 8], + } + + pub struct cpu_set_t { + #[cfg(all(target_pointer_width = "32", + not(target_arch = "x86_64")))] + bits: [u32; 32], + #[cfg(not(all(target_pointer_width = "32", + not(target_arch = "x86_64"))))] + bits: [u64; 16], + } + + pub struct if_nameindex { + pub if_index: ::c_uint, + pub if_name: *mut ::c_char, + } + + // System V IPC + pub struct msginfo { + pub msgpool: ::c_int, + pub msgmap: ::c_int, + pub msgmax: ::c_int, + pub msgmnb: ::c_int, + pub msgmni: ::c_int, + pub msgssz: ::c_int, + pub msgtql: ::c_int, + pub msgseg: ::c_ushort, + } + + pub struct sembuf { + pub sem_num: ::c_ushort, + pub sem_op: ::c_short, + pub sem_flg: ::c_short, + } + + pub struct input_event { + pub time: ::timeval, + pub type_: ::__u16, + pub code: ::__u16, + pub value: ::__s32, + } + + pub struct input_id { + pub bustype: ::__u16, + pub vendor: ::__u16, + pub product: ::__u16, + pub version: ::__u16, + } + + pub struct input_absinfo { + pub value: ::__s32, + pub minimum: ::__s32, + pub maximum: ::__s32, + pub fuzz: ::__s32, + pub flat: ::__s32, + pub resolution: ::__s32, + } + + pub struct input_keymap_entry { + pub flags: ::__u8, + pub len: ::__u8, + pub index: ::__u16, + pub keycode: ::__u32, + pub scancode: [::__u8; 32], + } + + pub struct input_mask { + pub type_: ::__u32, + pub codes_size: ::__u32, + pub codes_ptr: ::__u64, + } + + pub struct ff_replay { + pub length: ::__u16, + pub delay: ::__u16, + } + + pub struct ff_trigger { + pub button: ::__u16, + pub interval: ::__u16, + } + + pub struct ff_envelope { + pub attack_length: ::__u16, + pub attack_level: ::__u16, + pub fade_length: ::__u16, + pub fade_level: ::__u16, + } + + pub struct ff_constant_effect { + pub level: ::__s16, + pub envelope: ff_envelope, + } + + pub struct ff_ramp_effect { + pub start_level: ::__s16, + pub end_level: ::__s16, + pub envelope: ff_envelope, + } + + pub struct ff_condition_effect { + pub right_saturation: ::__u16, + pub left_saturation: ::__u16, + + pub right_coeff: ::__s16, + pub left_coeff: ::__s16, + + pub deadband: ::__u16, + pub center: ::__s16, + } + + pub struct ff_periodic_effect { + pub waveform: ::__u16, + pub period: ::__u16, + pub magnitude: ::__s16, + pub offset: ::__s16, + pub phase: ::__u16, + + pub envelope: ff_envelope, + + pub custom_len: ::__u32, + pub custom_data: *mut ::__s16, + } + + pub struct ff_rumble_effect { + pub strong_magnitude: ::__u16, + pub weak_magnitude: ::__u16, + } + + pub struct ff_effect { + pub type_: ::__u16, + pub id: ::__s16, + pub direction: ::__u16, + pub trigger: ff_trigger, + pub replay: ff_replay, + // FIXME this is actually a union + #[cfg(target_pointer_width = "64")] + pub u: [u64; 4], + #[cfg(target_pointer_width = "32")] + pub u: [u32; 7], + } + + pub struct dl_phdr_info { + #[cfg(target_pointer_width = "64")] + pub dlpi_addr: Elf64_Addr, + #[cfg(target_pointer_width = "32")] + pub dlpi_addr: Elf32_Addr, + + pub dlpi_name: *const ::c_char, + + #[cfg(target_pointer_width = "64")] + pub dlpi_phdr: *const Elf64_Phdr, + #[cfg(target_pointer_width = "32")] + pub dlpi_phdr: *const Elf32_Phdr, + + #[cfg(target_pointer_width = "64")] + pub dlpi_phnum: Elf64_Half, + #[cfg(target_pointer_width = "32")] + pub dlpi_phnum: Elf32_Half, + + pub dlpi_adds: ::c_ulonglong, + pub dlpi_subs: ::c_ulonglong, + pub dlpi_tls_modid: ::size_t, + pub dlpi_tls_data: *mut ::c_void, + } + + pub struct Elf32_Ehdr { + pub e_ident: [::c_uchar; 16], + pub e_type: Elf32_Half, + pub e_machine: Elf32_Half, + pub e_version: Elf32_Word, + pub e_entry: Elf32_Addr, + pub e_phoff: Elf32_Off, + pub e_shoff: Elf32_Off, + pub e_flags: Elf32_Word, + pub e_ehsize: Elf32_Half, + pub e_phentsize: Elf32_Half, + pub e_phnum: Elf32_Half, + pub e_shentsize: Elf32_Half, + pub e_shnum: Elf32_Half, + pub e_shstrndx: Elf32_Half, + } + + pub struct Elf64_Ehdr { + pub e_ident: [::c_uchar; 16], + pub e_type: Elf64_Half, + pub e_machine: Elf64_Half, + pub e_version: Elf64_Word, + pub e_entry: Elf64_Addr, + pub e_phoff: Elf64_Off, + pub e_shoff: Elf64_Off, + pub e_flags: Elf64_Word, + pub e_ehsize: Elf64_Half, + pub e_phentsize: Elf64_Half, + pub e_phnum: Elf64_Half, + pub e_shentsize: Elf64_Half, + pub e_shnum: Elf64_Half, + pub e_shstrndx: Elf64_Half, + } + + pub struct Elf32_Sym { + pub st_name: Elf32_Word, + pub st_value: Elf32_Addr, + pub st_size: Elf32_Word, + pub st_info: ::c_uchar, + pub st_other: ::c_uchar, + pub st_shndx: Elf32_Section, + } + + pub struct Elf64_Sym { + pub st_name: Elf64_Word, + pub st_info: ::c_uchar, + pub st_other: ::c_uchar, + pub st_shndx: Elf64_Section, + pub st_value: Elf64_Addr, + pub st_size: Elf64_Xword, + } + + pub struct Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, + } + + pub struct Elf64_Phdr { + pub p_type: Elf64_Word, + pub p_flags: Elf64_Word, + pub p_offset: Elf64_Off, + pub p_vaddr: Elf64_Addr, + pub p_paddr: Elf64_Addr, + pub p_filesz: Elf64_Xword, + pub p_memsz: Elf64_Xword, + pub p_align: Elf64_Xword, + } + + pub struct Elf32_Shdr { + pub sh_name: Elf32_Word, + pub sh_type: Elf32_Word, + pub sh_flags: Elf32_Word, + pub sh_addr: Elf32_Addr, + pub sh_offset: Elf32_Off, + pub sh_size: Elf32_Word, + pub sh_link: Elf32_Word, + pub sh_info: Elf32_Word, + pub sh_addralign: Elf32_Word, + pub sh_entsize: Elf32_Word, + } + + pub struct Elf64_Shdr { + pub sh_name: Elf64_Word, + pub sh_type: Elf64_Word, + pub sh_flags: Elf64_Xword, + pub sh_addr: Elf64_Addr, + pub sh_offset: Elf64_Off, + pub sh_size: Elf64_Xword, + pub sh_link: Elf64_Word, + pub sh_info: Elf64_Word, + pub sh_addralign: Elf64_Xword, + pub sh_entsize: Elf64_Xword, + } + + pub struct Elf32_Chdr { + pub ch_type: Elf32_Word, + pub ch_size: Elf32_Word, + pub ch_addralign: Elf32_Word, + } + + pub struct Elf64_Chdr { + pub ch_type: Elf64_Word, + pub ch_reserved: Elf64_Word, + pub ch_size: Elf64_Xword, + pub ch_addralign: Elf64_Xword, + } + + pub struct ucred { + pub pid: ::pid_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + } + + pub struct mntent { + pub mnt_fsname: *mut ::c_char, + pub mnt_dir: *mut ::c_char, + pub mnt_type: *mut ::c_char, + pub mnt_opts: *mut ::c_char, + pub mnt_freq: ::c_int, + pub mnt_passno: ::c_int, + } + + pub struct posix_spawn_file_actions_t { + __allocated: ::c_int, + __used: ::c_int, + __actions: *mut ::c_int, + __pad: [::c_int; 16], + } + + pub struct posix_spawnattr_t { + __flags: ::c_short, + __pgrp: ::pid_t, + __sd: ::sigset_t, + __ss: ::sigset_t, + #[cfg(target_env = "musl")] + __prio: ::c_int, + #[cfg(not(target_env = "musl"))] + __sp: ::sched_param, + __policy: ::c_int, + __pad: [::c_int; 16], + } + + pub struct genlmsghdr { + pub cmd: u8, + pub version: u8, + pub reserved: u16, + } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_uint, + } + + pub struct arpd_request { + pub req: ::c_ushort, + pub ip: u32, + pub dev: ::c_ulong, + pub stamp: ::c_ulong, + pub updated: ::c_ulong, + pub ha: [::c_uchar; ::MAX_ADDR_LEN], + } + + pub struct inotify_event { + pub wd: ::c_int, + pub mask: u32, + pub cookie: u32, + pub len: u32 + } + + pub struct sockaddr_vm { + pub svm_family: ::sa_family_t, + pub svm_reserved1: ::c_ushort, + pub svm_port: ::c_uint, + pub svm_cid: ::c_uint, + pub svm_zero: [u8; 4] + } +} + +s_no_extra_traits! { + pub struct sockaddr_nl { + pub nl_family: ::sa_family_t, + nl_pad: ::c_ushort, + pub nl_pid: u32, + pub nl_groups: u32 + } + + pub struct dirent { + pub d_ino: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct dirent64 { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct sockaddr_alg { + pub salg_family: ::sa_family_t, + pub salg_type: [::c_uchar; 14], + pub salg_feat: u32, + pub salg_mask: u32, + pub salg_name: [::c_uchar; 64], + } + + pub struct af_alg_iv { + pub ivlen: u32, + pub iv: [::c_uchar; 0], + } + + // x32 compatibility + // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 + pub struct mq_attr { + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_flags: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_maxmsg: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_msgsize: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_curmsgs: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pad: [i64; 4], + + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_flags: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_maxmsg: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_msgsize: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_curmsgs: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pad: [::c_long; 4], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sockaddr_nl { + fn eq(&self, other: &sockaddr_nl) -> bool { + self.nl_family == other.nl_family && + self.nl_pid == other.nl_pid && + self.nl_groups == other.nl_groups + } + } + impl Eq for sockaddr_nl {} + impl ::fmt::Debug for sockaddr_nl { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_nl") + .field("nl_family", &self.nl_family) + .field("nl_pid", &self.nl_pid) + .field("nl_groups", &self.nl_groups) + .finish() + } + } + impl ::hash::Hash for sockaddr_nl { + fn hash(&self, state: &mut H) { + self.nl_family.hash(state); + self.nl_pid.hash(state); + self.nl_groups.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for dirent {} + + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for dirent64 { + fn eq(&self, other: &dirent64) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for dirent64 {} + + impl ::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent64") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + + impl ::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) + } + } + + impl Eq for pthread_cond_t {} + + impl ::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_cond_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + + impl ::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + + impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) + } + } + + impl Eq for pthread_mutex_t {} + + impl ::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_mutex_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + + impl ::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + + impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) + } + } + + impl Eq for pthread_rwlock_t {} + + impl ::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_rwlock_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + + impl ::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + + impl PartialEq for sockaddr_alg { + fn eq(&self, other: &sockaddr_alg) -> bool { + self.salg_family == other.salg_family + && self + .salg_type + .iter() + .zip(other.salg_type.iter()) + .all(|(a, b)| a == b) + && self.salg_feat == other.salg_feat + && self.salg_mask == other.salg_mask + && self + .salg_name + .iter() + .zip(other.salg_name.iter()) + .all(|(a, b)| a == b) + } + } + + impl Eq for sockaddr_alg {} + + impl ::fmt::Debug for sockaddr_alg { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_alg") + .field("salg_family", &self.salg_family) + .field("salg_type", &self.salg_type) + .field("salg_feat", &self.salg_feat) + .field("salg_mask", &self.salg_mask) + .field("salg_name", &&self.salg_name[..]) + .finish() + } + } + + impl ::hash::Hash for sockaddr_alg { + fn hash(&self, state: &mut H) { + self.salg_family.hash(state); + self.salg_type.hash(state); + self.salg_feat.hash(state); + self.salg_mask.hash(state); + self.salg_name.hash(state); + } + } + + impl af_alg_iv { + fn as_slice(&self) -> &[u8] { + unsafe { + ::core::slice::from_raw_parts( + self.iv.as_ptr(), + self.ivlen as usize + ) + } + } + } + + impl PartialEq for af_alg_iv { + fn eq(&self, other: &af_alg_iv) -> bool { + *self.as_slice() == *other.as_slice() + } + } + + impl Eq for af_alg_iv {} + + impl ::fmt::Debug for af_alg_iv { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("af_alg_iv") + .field("iv", &self.as_slice()) + .finish() + } + } + + impl ::hash::Hash for af_alg_iv { + fn hash(&self, state: &mut H) { + self.as_slice().hash(state); + } + } + + impl PartialEq for mq_attr { + fn eq(&self, other: &mq_attr) -> bool { + self.mq_flags == other.mq_flags && + self.mq_maxmsg == other.mq_maxmsg && + self.mq_msgsize == other.mq_msgsize && + self.mq_curmsgs == other.mq_curmsgs + } + } + impl Eq for mq_attr {} + impl ::fmt::Debug for mq_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mq_attr") + .field("mq_flags", &self.mq_flags) + .field("mq_maxmsg", &self.mq_maxmsg) + .field("mq_msgsize", &self.mq_msgsize) + .field("mq_curmsgs", &self.mq_curmsgs) + .finish() + } + } + impl ::hash::Hash for mq_attr { + fn hash(&self, state: &mut H) { + self.mq_flags.hash(state); + self.mq_maxmsg.hash(state); + self.mq_msgsize.hash(state); + self.mq_curmsgs.hash(state); + } + } + } +} + +pub const ABDAY_1: ::nl_item = 0x20000; +pub const ABDAY_2: ::nl_item = 0x20001; +pub const ABDAY_3: ::nl_item = 0x20002; +pub const ABDAY_4: ::nl_item = 0x20003; +pub const ABDAY_5: ::nl_item = 0x20004; +pub const ABDAY_6: ::nl_item = 0x20005; +pub const ABDAY_7: ::nl_item = 0x20006; + +pub const DAY_1: ::nl_item = 0x20007; +pub const DAY_2: ::nl_item = 0x20008; +pub const DAY_3: ::nl_item = 0x20009; +pub const DAY_4: ::nl_item = 0x2000A; +pub const DAY_5: ::nl_item = 0x2000B; +pub const DAY_6: ::nl_item = 0x2000C; +pub const DAY_7: ::nl_item = 0x2000D; + +pub const ABMON_1: ::nl_item = 0x2000E; +pub const ABMON_2: ::nl_item = 0x2000F; +pub const ABMON_3: ::nl_item = 0x20010; +pub const ABMON_4: ::nl_item = 0x20011; +pub const ABMON_5: ::nl_item = 0x20012; +pub const ABMON_6: ::nl_item = 0x20013; +pub const ABMON_7: ::nl_item = 0x20014; +pub const ABMON_8: ::nl_item = 0x20015; +pub const ABMON_9: ::nl_item = 0x20016; +pub const ABMON_10: ::nl_item = 0x20017; +pub const ABMON_11: ::nl_item = 0x20018; +pub const ABMON_12: ::nl_item = 0x20019; + +pub const MON_1: ::nl_item = 0x2001A; +pub const MON_2: ::nl_item = 0x2001B; +pub const MON_3: ::nl_item = 0x2001C; +pub const MON_4: ::nl_item = 0x2001D; +pub const MON_5: ::nl_item = 0x2001E; +pub const MON_6: ::nl_item = 0x2001F; +pub const MON_7: ::nl_item = 0x20020; +pub const MON_8: ::nl_item = 0x20021; +pub const MON_9: ::nl_item = 0x20022; +pub const MON_10: ::nl_item = 0x20023; +pub const MON_11: ::nl_item = 0x20024; +pub const MON_12: ::nl_item = 0x20025; + +pub const AM_STR: ::nl_item = 0x20026; +pub const PM_STR: ::nl_item = 0x20027; + +pub const D_T_FMT: ::nl_item = 0x20028; +pub const D_FMT: ::nl_item = 0x20029; +pub const T_FMT: ::nl_item = 0x2002A; +pub const T_FMT_AMPM: ::nl_item = 0x2002B; + +pub const ERA: ::nl_item = 0x2002C; +pub const ERA_D_FMT: ::nl_item = 0x2002E; +pub const ALT_DIGITS: ::nl_item = 0x2002F; +pub const ERA_D_T_FMT: ::nl_item = 0x20030; +pub const ERA_T_FMT: ::nl_item = 0x20031; + +pub const CODESET: ::nl_item = 14; + +pub const CRNCYSTR: ::nl_item = 0x4000F; + +pub const RUSAGE_THREAD: ::c_int = 1; +pub const RUSAGE_CHILDREN: ::c_int = -1; + +pub const RADIXCHAR: ::nl_item = 0x10000; +pub const THOUSEP: ::nl_item = 0x10001; + +pub const YESEXPR: ::nl_item = 0x50000; +pub const NOEXPR: ::nl_item = 0x50001; +pub const YESSTR: ::nl_item = 0x50002; +pub const NOSTR: ::nl_item = 0x50003; + +pub const FILENAME_MAX: ::c_uint = 4096; +pub const L_tmpnam: ::c_uint = 20; +pub const _PC_LINK_MAX: ::c_int = 0; +pub const _PC_MAX_CANON: ::c_int = 1; +pub const _PC_MAX_INPUT: ::c_int = 2; +pub const _PC_NAME_MAX: ::c_int = 3; +pub const _PC_PATH_MAX: ::c_int = 4; +pub const _PC_PIPE_BUF: ::c_int = 5; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 6; +pub const _PC_NO_TRUNC: ::c_int = 7; +pub const _PC_VDISABLE: ::c_int = 8; +pub const _PC_SYNC_IO: ::c_int = 9; +pub const _PC_ASYNC_IO: ::c_int = 10; +pub const _PC_PRIO_IO: ::c_int = 11; +pub const _PC_SOCK_MAXBUF: ::c_int = 12; +pub const _PC_FILESIZEBITS: ::c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16; +pub const _PC_REC_XFER_ALIGN: ::c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18; +pub const _PC_SYMLINK_MAX: ::c_int = 19; +pub const _PC_2_SYMLINKS: ::c_int = 20; + +pub const MS_NOUSER: ::c_ulong = 0xffffffff80000000; + +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_CHILD_MAX: ::c_int = 1; +pub const _SC_CLK_TCK: ::c_int = 2; +pub const _SC_NGROUPS_MAX: ::c_int = 3; +pub const _SC_OPEN_MAX: ::c_int = 4; +pub const _SC_STREAM_MAX: ::c_int = 5; +pub const _SC_TZNAME_MAX: ::c_int = 6; +pub const _SC_JOB_CONTROL: ::c_int = 7; +pub const _SC_SAVED_IDS: ::c_int = 8; +pub const _SC_REALTIME_SIGNALS: ::c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; +pub const _SC_TIMERS: ::c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; +pub const _SC_PRIORITIZED_IO: ::c_int = 13; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; +pub const _SC_FSYNC: ::c_int = 15; +pub const _SC_MAPPED_FILES: ::c_int = 16; +pub const _SC_MEMLOCK: ::c_int = 17; +pub const _SC_MEMLOCK_RANGE: ::c_int = 18; +pub const _SC_MEMORY_PROTECTION: ::c_int = 19; +pub const _SC_MESSAGE_PASSING: ::c_int = 20; +pub const _SC_SEMAPHORES: ::c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; +pub const _SC_AIO_MAX: ::c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; +pub const _SC_DELAYTIMER_MAX: ::c_int = 26; +pub const _SC_MQ_OPEN_MAX: ::c_int = 27; +pub const _SC_MQ_PRIO_MAX: ::c_int = 28; +pub const _SC_VERSION: ::c_int = 29; +pub const _SC_PAGESIZE: ::c_int = 30; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: ::c_int = 31; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; +pub const _SC_SEM_VALUE_MAX: ::c_int = 33; +pub const _SC_SIGQUEUE_MAX: ::c_int = 34; +pub const _SC_TIMER_MAX: ::c_int = 35; +pub const _SC_BC_BASE_MAX: ::c_int = 36; +pub const _SC_BC_DIM_MAX: ::c_int = 37; +pub const _SC_BC_SCALE_MAX: ::c_int = 38; +pub const _SC_BC_STRING_MAX: ::c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; +pub const _SC_EXPR_NEST_MAX: ::c_int = 42; +pub const _SC_LINE_MAX: ::c_int = 43; +pub const _SC_RE_DUP_MAX: ::c_int = 44; +pub const _SC_2_VERSION: ::c_int = 46; +pub const _SC_2_C_BIND: ::c_int = 47; +pub const _SC_2_C_DEV: ::c_int = 48; +pub const _SC_2_FORT_DEV: ::c_int = 49; +pub const _SC_2_FORT_RUN: ::c_int = 50; +pub const _SC_2_SW_DEV: ::c_int = 51; +pub const _SC_2_LOCALEDEF: ::c_int = 52; +pub const _SC_UIO_MAXIOV: ::c_int = 60; +pub const _SC_IOV_MAX: ::c_int = 60; +pub const _SC_THREADS: ::c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; +pub const _SC_TTY_NAME_MAX: ::c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; +pub const _SC_THREAD_STACK_MIN: ::c_int = 75; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82; +pub const _SC_NPROCESSORS_CONF: ::c_int = 83; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; +pub const _SC_PHYS_PAGES: ::c_int = 85; +pub const _SC_AVPHYS_PAGES: ::c_int = 86; +pub const _SC_ATEXIT_MAX: ::c_int = 87; +pub const _SC_PASS_MAX: ::c_int = 88; +pub const _SC_XOPEN_VERSION: ::c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; +pub const _SC_XOPEN_UNIX: ::c_int = 91; +pub const _SC_XOPEN_CRYPT: ::c_int = 92; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; +pub const _SC_XOPEN_SHM: ::c_int = 94; +pub const _SC_2_CHAR_TERM: ::c_int = 95; +pub const _SC_2_UPE: ::c_int = 97; +pub const _SC_XOPEN_XPG2: ::c_int = 98; +pub const _SC_XOPEN_XPG3: ::c_int = 99; +pub const _SC_XOPEN_XPG4: ::c_int = 100; +pub const _SC_NZERO: ::c_int = 109; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; +pub const _SC_XBS5_LP64_OFF64: ::c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; +pub const _SC_XOPEN_LEGACY: ::c_int = 129; +pub const _SC_XOPEN_REALTIME: ::c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; +pub const _SC_ADVISORY_INFO: ::c_int = 132; +pub const _SC_BARRIERS: ::c_int = 133; +pub const _SC_CLOCK_SELECTION: ::c_int = 137; +pub const _SC_CPUTIME: ::c_int = 138; +pub const _SC_THREAD_CPUTIME: ::c_int = 139; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 149; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 153; +pub const _SC_SPIN_LOCKS: ::c_int = 154; +pub const _SC_REGEXP: ::c_int = 155; +pub const _SC_SHELL: ::c_int = 157; +pub const _SC_SPAWN: ::c_int = 159; +pub const _SC_SPORADIC_SERVER: ::c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161; +pub const _SC_TIMEOUTS: ::c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165; +pub const _SC_2_PBS: ::c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169; +pub const _SC_2_PBS_LOCATE: ::c_int = 170; +pub const _SC_2_PBS_MESSAGE: ::c_int = 171; +pub const _SC_2_PBS_TRACK: ::c_int = 172; +pub const _SC_SYMLOOP_MAX: ::c_int = 173; +pub const _SC_STREAMS: ::c_int = 174; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175; +pub const _SC_V6_ILP32_OFF32: ::c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177; +pub const _SC_V6_LP64_OFF64: ::c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179; +pub const _SC_HOST_NAME_MAX: ::c_int = 180; +pub const _SC_TRACE: ::c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182; +pub const _SC_TRACE_INHERIT: ::c_int = 183; +pub const _SC_TRACE_LOG: ::c_int = 184; +pub const _SC_IPV6: ::c_int = 235; +pub const _SC_RAW_SOCKETS: ::c_int = 236; +pub const _SC_V7_ILP32_OFF32: ::c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238; +pub const _SC_V7_LP64_OFF64: ::c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240; +pub const _SC_SS_REPL_MAX: ::c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242; +pub const _SC_TRACE_NAME_MAX: ::c_int = 243; +pub const _SC_TRACE_SYS_MAX: ::c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245; +pub const _SC_XOPEN_STREAMS: ::c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248; + +pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; + +pub const GLOB_ERR: ::c_int = 1 << 0; +pub const GLOB_MARK: ::c_int = 1 << 1; +pub const GLOB_NOSORT: ::c_int = 1 << 2; +pub const GLOB_DOOFFS: ::c_int = 1 << 3; +pub const GLOB_NOCHECK: ::c_int = 1 << 4; +pub const GLOB_APPEND: ::c_int = 1 << 5; +pub const GLOB_NOESCAPE: ::c_int = 1 << 6; + +pub const GLOB_NOSPACE: ::c_int = 1; +pub const GLOB_ABORTED: ::c_int = 2; +pub const GLOB_NOMATCH: ::c_int = 3; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; + +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; + +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; + +pub const F_SEAL_FUTURE_WRITE: ::c_int = 0x0010; + +pub const IFF_LOWER_UP: ::c_int = 0x10000; +pub const IFF_DORMANT: ::c_int = 0x20000; +pub const IFF_ECHO: ::c_int = 0x40000; + +// linux/if_addr.h +pub const IFA_UNSPEC: ::c_ushort = 0; +pub const IFA_ADDRESS: ::c_ushort = 1; +pub const IFA_LOCAL: ::c_ushort = 2; +pub const IFA_LABEL: ::c_ushort = 3; +pub const IFA_BROADCAST: ::c_ushort = 4; +pub const IFA_ANYCAST: ::c_ushort = 5; +pub const IFA_CACHEINFO: ::c_ushort = 6; +pub const IFA_MULTICAST: ::c_ushort = 7; + +pub const IFA_F_SECONDARY: u32 = 0x01; +pub const IFA_F_TEMPORARY: u32 = 0x01; +pub const IFA_F_NODAD: u32 = 0x02; +pub const IFA_F_OPTIMISTIC: u32 = 0x04; +pub const IFA_F_DADFAILED: u32 = 0x08; +pub const IFA_F_HOMEADDRESS: u32 = 0x10; +pub const IFA_F_DEPRECATED: u32 = 0x20; +pub const IFA_F_TENTATIVE: u32 = 0x40; +pub const IFA_F_PERMANENT: u32 = 0x80; + +// linux/if_link.h +pub const IFLA_UNSPEC: ::c_ushort = 0; +pub const IFLA_ADDRESS: ::c_ushort = 1; +pub const IFLA_BROADCAST: ::c_ushort = 2; +pub const IFLA_IFNAME: ::c_ushort = 3; +pub const IFLA_MTU: ::c_ushort = 4; +pub const IFLA_LINK: ::c_ushort = 5; +pub const IFLA_QDISC: ::c_ushort = 6; +pub const IFLA_STATS: ::c_ushort = 7; +pub const IFLA_COST: ::c_ushort = 8; +pub const IFLA_PRIORITY: ::c_ushort = 9; +pub const IFLA_MASTER: ::c_ushort = 10; +pub const IFLA_WIRELESS: ::c_ushort = 11; +pub const IFLA_PROTINFO: ::c_ushort = 12; +pub const IFLA_TXQLEN: ::c_ushort = 13; +pub const IFLA_MAP: ::c_ushort = 14; +pub const IFLA_WEIGHT: ::c_ushort = 15; +pub const IFLA_OPERSTATE: ::c_ushort = 16; +pub const IFLA_LINKMODE: ::c_ushort = 17; +pub const IFLA_LINKINFO: ::c_ushort = 18; +pub const IFLA_NET_NS_PID: ::c_ushort = 19; +pub const IFLA_IFALIAS: ::c_ushort = 20; +pub const IFLA_NUM_VF: ::c_ushort = 21; +pub const IFLA_VFINFO_LIST: ::c_ushort = 22; +pub const IFLA_STATS64: ::c_ushort = 23; +pub const IFLA_VF_PORTS: ::c_ushort = 24; +pub const IFLA_PORT_SELF: ::c_ushort = 25; +pub const IFLA_AF_SPEC: ::c_ushort = 26; +pub const IFLA_GROUP: ::c_ushort = 27; +pub const IFLA_NET_NS_FD: ::c_ushort = 28; +pub const IFLA_EXT_MASK: ::c_ushort = 29; +pub const IFLA_PROMISCUITY: ::c_ushort = 30; +pub const IFLA_NUM_TX_QUEUES: ::c_ushort = 31; +pub const IFLA_NUM_RX_QUEUES: ::c_ushort = 32; +pub const IFLA_CARRIER: ::c_ushort = 33; +pub const IFLA_PHYS_PORT_ID: ::c_ushort = 34; +pub const IFLA_CARRIER_CHANGES: ::c_ushort = 35; +pub const IFLA_PHYS_SWITCH_ID: ::c_ushort = 36; +pub const IFLA_LINK_NETNSID: ::c_ushort = 37; +pub const IFLA_PHYS_PORT_NAME: ::c_ushort = 38; +pub const IFLA_PROTO_DOWN: ::c_ushort = 39; + +pub const IFLA_INFO_UNSPEC: ::c_ushort = 0; +pub const IFLA_INFO_KIND: ::c_ushort = 1; +pub const IFLA_INFO_DATA: ::c_ushort = 2; +pub const IFLA_INFO_XSTATS: ::c_ushort = 3; +pub const IFLA_INFO_SLAVE_KIND: ::c_ushort = 4; +pub const IFLA_INFO_SLAVE_DATA: ::c_ushort = 5; + +// linux/if_tun.h +pub const IFF_TUN: ::c_int = 0x0001; +pub const IFF_TAP: ::c_int = 0x0002; +pub const IFF_NO_PI: ::c_int = 0x1000; +// Read queue size +pub const TUN_READQ_SIZE: ::c_short = 500; +// TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. +pub const TUN_TUN_DEV: ::c_short = ::IFF_TUN as ::c_short; +pub const TUN_TAP_DEV: ::c_short = ::IFF_TAP as ::c_short; +pub const TUN_TYPE_MASK: ::c_short = 0x000f; +// This flag has no real effect +pub const IFF_ONE_QUEUE: ::c_int = 0x2000; +pub const IFF_VNET_HDR: ::c_int = 0x4000; +pub const IFF_TUN_EXCL: ::c_int = 0x8000; +pub const IFF_MULTI_QUEUE: ::c_int = 0x0100; +pub const IFF_ATTACH_QUEUE: ::c_int = 0x0200; +pub const IFF_DETACH_QUEUE: ::c_int = 0x0400; +// read-only flag +pub const IFF_PERSIST: ::c_int = 0x0800; +pub const IFF_NOFILTER: ::c_int = 0x1000; + +pub const ST_RDONLY: ::c_ulong = 1; +pub const ST_NOSUID: ::c_ulong = 2; +pub const ST_NODEV: ::c_ulong = 4; +pub const ST_NOEXEC: ::c_ulong = 8; +pub const ST_SYNCHRONOUS: ::c_ulong = 16; +pub const ST_MANDLOCK: ::c_ulong = 64; +pub const ST_WRITE: ::c_ulong = 128; +pub const ST_APPEND: ::c_ulong = 256; +pub const ST_IMMUTABLE: ::c_ulong = 512; +pub const ST_NOATIME: ::c_ulong = 1024; +pub const ST_NODIRATIME: ::c_ulong = 2048; + +pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void; +pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; +pub const RTLD_NODELETE: ::c_int = 0x1000; +pub const RTLD_NOW: ::c_int = 0x2; + +pub const TCP_MD5SIG: ::c_int = 14; + +align_const! { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], + }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], + }; + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + }; +} +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0; +pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; + +pub const RENAME_NOREPLACE: ::c_int = 1; +pub const RENAME_EXCHANGE: ::c_int = 2; +pub const RENAME_WHITEOUT: ::c_int = 4; + +pub const SCHED_OTHER: ::c_int = 0; +pub const SCHED_FIFO: ::c_int = 1; +pub const SCHED_RR: ::c_int = 2; +pub const SCHED_BATCH: ::c_int = 3; +pub const SCHED_IDLE: ::c_int = 5; + +pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000; + +// netinet/in.h +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// Hop-by-hop option header +pub const IPPROTO_HOPOPTS: ::c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: ::c_int = 2; +/// for compatibility +pub const IPPROTO_IPIP: ::c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// exterior gateway protocol +pub const IPPROTO_EGP: ::c_int = 8; +/// pup +pub const IPPROTO_PUP: ::c_int = 12; +// IPPROTO_UDP defined in src/unix/mod.rs +/// xns idp +pub const IPPROTO_IDP: ::c_int = 22; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: ::c_int = 29; +/// DCCP +pub const IPPROTO_DCCP: ::c_int = 33; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// IP6 routing header +pub const IPPROTO_ROUTING: ::c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: ::c_int = 44; +/// resource reservation +pub const IPPROTO_RSVP: ::c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: ::c_int = 47; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: ::c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: ::c_int = 51; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: ::c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: ::c_int = 60; +pub const IPPROTO_MTP: ::c_int = 92; +pub const IPPROTO_BEETPH: ::c_int = 94; +/// encapsulation header +pub const IPPROTO_ENCAP: ::c_int = 98; +/// Protocol indep. multicast +pub const IPPROTO_PIM: ::c_int = 103; +/// IP Payload Comp. Protocol +pub const IPPROTO_COMP: ::c_int = 108; +/// SCTP +pub const IPPROTO_SCTP: ::c_int = 132; +pub const IPPROTO_MH: ::c_int = 135; +pub const IPPROTO_UDPLITE: ::c_int = 136; +pub const IPPROTO_MPLS: ::c_int = 137; +/// raw IP packet +pub const IPPROTO_RAW: ::c_int = 255; +pub const IPPROTO_MAX: ::c_int = 256; + +pub const AF_IB: ::c_int = 27; +pub const AF_MPLS: ::c_int = 28; +pub const AF_NFC: ::c_int = 39; +pub const AF_VSOCK: ::c_int = 40; +pub const AF_XDP: ::c_int = 44; +pub const PF_IB: ::c_int = AF_IB; +pub const PF_MPLS: ::c_int = AF_MPLS; +pub const PF_NFC: ::c_int = AF_NFC; +pub const PF_VSOCK: ::c_int = AF_VSOCK; +pub const PF_XDP: ::c_int = AF_XDP; + +// System V IPC +pub const IPC_PRIVATE: ::key_t = 0; + +pub const IPC_CREAT: ::c_int = 0o1000; +pub const IPC_EXCL: ::c_int = 0o2000; +pub const IPC_NOWAIT: ::c_int = 0o4000; + +pub const IPC_RMID: ::c_int = 0; +pub const IPC_SET: ::c_int = 1; +pub const IPC_STAT: ::c_int = 2; +pub const IPC_INFO: ::c_int = 3; +pub const MSG_STAT: ::c_int = 11; +pub const MSG_INFO: ::c_int = 12; + +pub const MSG_NOERROR: ::c_int = 0o10000; +pub const MSG_EXCEPT: ::c_int = 0o20000; +pub const MSG_COPY: ::c_int = 0o40000; + +pub const SHM_R: ::c_int = 0o400; +pub const SHM_W: ::c_int = 0o200; + +pub const SHM_RDONLY: ::c_int = 0o10000; +pub const SHM_RND: ::c_int = 0o20000; +pub const SHM_REMAP: ::c_int = 0o40000; +pub const SHM_EXEC: ::c_int = 0o100000; + +pub const SHM_LOCK: ::c_int = 11; +pub const SHM_UNLOCK: ::c_int = 12; + +pub const SHM_HUGETLB: ::c_int = 0o4000; +pub const SHM_NORESERVE: ::c_int = 0o10000; + +pub const EPOLLRDHUP: ::c_int = 0x2000; +pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; +pub const EPOLLONESHOT: ::c_int = 0x40000000; + +pub const QFMT_VFS_OLD: ::c_int = 1; +pub const QFMT_VFS_V0: ::c_int = 2; +pub const QFMT_VFS_V1: ::c_int = 4; + +pub const EFD_SEMAPHORE: ::c_int = 0x1; + +pub const LOG_NFACILITIES: ::c_int = 24; + +pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t; + +pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32; +pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32; +pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32; +pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32; +pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32; +pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32; +pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32; + +pub const AI_PASSIVE: ::c_int = 0x0001; +pub const AI_CANONNAME: ::c_int = 0x0002; +pub const AI_NUMERICHOST: ::c_int = 0x0004; +pub const AI_V4MAPPED: ::c_int = 0x0008; +pub const AI_ALL: ::c_int = 0x0010; +pub const AI_ADDRCONFIG: ::c_int = 0x0020; + +pub const AI_NUMERICSERV: ::c_int = 0x0400; + +pub const EAI_BADFLAGS: ::c_int = -1; +pub const EAI_NONAME: ::c_int = -2; +pub const EAI_AGAIN: ::c_int = -3; +pub const EAI_FAIL: ::c_int = -4; +pub const EAI_NODATA: ::c_int = -5; +pub const EAI_FAMILY: ::c_int = -6; +pub const EAI_SOCKTYPE: ::c_int = -7; +pub const EAI_SERVICE: ::c_int = -8; +pub const EAI_MEMORY: ::c_int = -10; +pub const EAI_SYSTEM: ::c_int = -11; +pub const EAI_OVERFLOW: ::c_int = -12; + +pub const NI_NUMERICHOST: ::c_int = 1; +pub const NI_NUMERICSERV: ::c_int = 2; +pub const NI_NOFQDN: ::c_int = 4; +pub const NI_NAMEREQD: ::c_int = 8; +pub const NI_DGRAM: ::c_int = 16; + +pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1; +pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2; +pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4; + +pub const AIO_CANCELED: ::c_int = 0; +pub const AIO_NOTCANCELED: ::c_int = 1; +pub const AIO_ALLDONE: ::c_int = 2; +pub const LIO_READ: ::c_int = 0; +pub const LIO_WRITE: ::c_int = 1; +pub const LIO_NOP: ::c_int = 2; +pub const LIO_WAIT: ::c_int = 0; +pub const LIO_NOWAIT: ::c_int = 1; + +pub const MREMAP_MAYMOVE: ::c_int = 1; +pub const MREMAP_FIXED: ::c_int = 2; + +pub const PR_SET_PDEATHSIG: ::c_int = 1; +pub const PR_GET_PDEATHSIG: ::c_int = 2; + +pub const PR_GET_DUMPABLE: ::c_int = 3; +pub const PR_SET_DUMPABLE: ::c_int = 4; + +pub const PR_GET_UNALIGN: ::c_int = 5; +pub const PR_SET_UNALIGN: ::c_int = 6; +pub const PR_UNALIGN_NOPRINT: ::c_int = 1; +pub const PR_UNALIGN_SIGBUS: ::c_int = 2; + +pub const PR_GET_KEEPCAPS: ::c_int = 7; +pub const PR_SET_KEEPCAPS: ::c_int = 8; + +pub const PR_GET_FPEMU: ::c_int = 9; +pub const PR_SET_FPEMU: ::c_int = 10; +pub const PR_FPEMU_NOPRINT: ::c_int = 1; +pub const PR_FPEMU_SIGFPE: ::c_int = 2; + +pub const PR_GET_FPEXC: ::c_int = 11; +pub const PR_SET_FPEXC: ::c_int = 12; +pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80; +pub const PR_FP_EXC_DIV: ::c_int = 0x010000; +pub const PR_FP_EXC_OVF: ::c_int = 0x020000; +pub const PR_FP_EXC_UND: ::c_int = 0x040000; +pub const PR_FP_EXC_RES: ::c_int = 0x080000; +pub const PR_FP_EXC_INV: ::c_int = 0x100000; +pub const PR_FP_EXC_DISABLED: ::c_int = 0; +pub const PR_FP_EXC_NONRECOV: ::c_int = 1; +pub const PR_FP_EXC_ASYNC: ::c_int = 2; +pub const PR_FP_EXC_PRECISE: ::c_int = 3; + +pub const PR_GET_TIMING: ::c_int = 13; +pub const PR_SET_TIMING: ::c_int = 14; +pub const PR_TIMING_STATISTICAL: ::c_int = 0; +pub const PR_TIMING_TIMESTAMP: ::c_int = 1; + +pub const PR_SET_NAME: ::c_int = 15; +pub const PR_GET_NAME: ::c_int = 16; + +pub const PR_GET_ENDIAN: ::c_int = 19; +pub const PR_SET_ENDIAN: ::c_int = 20; +pub const PR_ENDIAN_BIG: ::c_int = 0; +pub const PR_ENDIAN_LITTLE: ::c_int = 1; +pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2; + +pub const PR_GET_SECCOMP: ::c_int = 21; +pub const PR_SET_SECCOMP: ::c_int = 22; + +pub const PR_CAPBSET_READ: ::c_int = 23; +pub const PR_CAPBSET_DROP: ::c_int = 24; + +pub const PR_GET_TSC: ::c_int = 25; +pub const PR_SET_TSC: ::c_int = 26; +pub const PR_TSC_ENABLE: ::c_int = 1; +pub const PR_TSC_SIGSEGV: ::c_int = 2; + +pub const PR_GET_SECUREBITS: ::c_int = 27; +pub const PR_SET_SECUREBITS: ::c_int = 28; + +pub const PR_SET_TIMERSLACK: ::c_int = 29; +pub const PR_GET_TIMERSLACK: ::c_int = 30; + +pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31; +pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32; + +pub const PR_MCE_KILL: ::c_int = 33; +pub const PR_MCE_KILL_CLEAR: ::c_int = 0; +pub const PR_MCE_KILL_SET: ::c_int = 1; + +pub const PR_MCE_KILL_LATE: ::c_int = 0; +pub const PR_MCE_KILL_EARLY: ::c_int = 1; +pub const PR_MCE_KILL_DEFAULT: ::c_int = 2; + +pub const PR_MCE_KILL_GET: ::c_int = 34; + +pub const PR_SET_MM: ::c_int = 35; +pub const PR_SET_MM_START_CODE: ::c_int = 1; +pub const PR_SET_MM_END_CODE: ::c_int = 2; +pub const PR_SET_MM_START_DATA: ::c_int = 3; +pub const PR_SET_MM_END_DATA: ::c_int = 4; +pub const PR_SET_MM_START_STACK: ::c_int = 5; +pub const PR_SET_MM_START_BRK: ::c_int = 6; +pub const PR_SET_MM_BRK: ::c_int = 7; +pub const PR_SET_MM_ARG_START: ::c_int = 8; +pub const PR_SET_MM_ARG_END: ::c_int = 9; +pub const PR_SET_MM_ENV_START: ::c_int = 10; +pub const PR_SET_MM_ENV_END: ::c_int = 11; +pub const PR_SET_MM_AUXV: ::c_int = 12; +pub const PR_SET_MM_EXE_FILE: ::c_int = 13; +pub const PR_SET_MM_MAP: ::c_int = 14; +pub const PR_SET_MM_MAP_SIZE: ::c_int = 15; + +pub const PR_SET_PTRACER: ::c_int = 0x59616d61; + +pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36; +pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37; + +pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38; +pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39; + +pub const PR_GET_TID_ADDRESS: ::c_int = 40; + +pub const PR_SET_THP_DISABLE: ::c_int = 41; +pub const PR_GET_THP_DISABLE: ::c_int = 42; + +pub const PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43; +pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44; + +pub const PR_SET_FP_MODE: ::c_int = 45; +pub const PR_GET_FP_MODE: ::c_int = 46; +pub const PR_FP_MODE_FR: ::c_int = 1 << 0; +pub const PR_FP_MODE_FRE: ::c_int = 1 << 1; + +pub const PR_CAP_AMBIENT: ::c_int = 47; +pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1; +pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2; +pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3; +pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4; + +pub const GRND_NONBLOCK: ::c_uint = 0x0001; +pub const GRND_RANDOM: ::c_uint = 0x0002; + +pub const SECCOMP_MODE_DISABLED: ::c_uint = 0; +pub const SECCOMP_MODE_STRICT: ::c_uint = 1; +pub const SECCOMP_MODE_FILTER: ::c_uint = 2; + +pub const ITIMER_REAL: ::c_int = 0; +pub const ITIMER_VIRTUAL: ::c_int = 1; +pub const ITIMER_PROF: ::c_int = 2; + +pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC; +pub const TFD_NONBLOCK: ::c_int = O_NONBLOCK; +pub const TFD_TIMER_ABSTIME: ::c_int = 1; + +pub const XATTR_CREATE: ::c_int = 0x1; +pub const XATTR_REPLACE: ::c_int = 0x2; + +pub const _POSIX_VDISABLE: ::cc_t = 0; + +pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; +pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; +pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08; +pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10; +pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20; +pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40; + +#[deprecated( + since = "0.2.55", + note = "ENOATTR is not available on Linux; use ENODATA instead" +)] +pub const ENOATTR: ::c_int = ::ENODATA; + +pub const SO_ORIGINAL_DST: ::c_int = 80; +pub const IP_ORIGDSTADDR: ::c_int = 20; +pub const IP_RECVORIGDSTADDR: ::c_int = IP_ORIGDSTADDR; +pub const IPV6_ORIGDSTADDR: ::c_int = 74; +pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR; +pub const IPV6_FLOWLABEL_MGR: ::c_int = 32; +pub const IPV6_FLOWINFO_SEND: ::c_int = 33; +pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff; +pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000; + +pub const IUTF8: ::tcflag_t = 0x00004000; +pub const CMSPAR: ::tcflag_t = 0o10000000000; + +pub const MFD_CLOEXEC: ::c_uint = 0x0001; +pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002; +pub const MFD_HUGETLB: ::c_uint = 0x0004; + +// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has +// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32 +// so we can use that type here to avoid having to cast. +pub const PT_NULL: u32 = 0; +pub const PT_LOAD: u32 = 1; +pub const PT_DYNAMIC: u32 = 2; +pub const PT_INTERP: u32 = 3; +pub const PT_NOTE: u32 = 4; +pub const PT_SHLIB: u32 = 5; +pub const PT_PHDR: u32 = 6; +pub const PT_TLS: u32 = 7; +pub const PT_NUM: u32 = 8; +pub const PT_LOOS: u32 = 0x60000000; +pub const PT_GNU_EH_FRAME: u32 = 0x6474e550; +pub const PT_GNU_STACK: u32 = 0x6474e551; +pub const PT_GNU_RELRO: u32 = 0x6474e552; + +// linux/if_ether.h +pub const ETH_ALEN: ::c_int = 6; +pub const ETH_HLEN: ::c_int = 14; +pub const ETH_ZLEN: ::c_int = 60; +pub const ETH_DATA_LEN: ::c_int = 1500; +pub const ETH_FRAME_LEN: ::c_int = 1514; +pub const ETH_FCS_LEN: ::c_int = 4; + +// These are the defined Ethernet Protocol ID's. +pub const ETH_P_LOOP: ::c_int = 0x0060; +pub const ETH_P_PUP: ::c_int = 0x0200; +pub const ETH_P_PUPAT: ::c_int = 0x0201; +pub const ETH_P_IP: ::c_int = 0x0800; +pub const ETH_P_X25: ::c_int = 0x0805; +pub const ETH_P_ARP: ::c_int = 0x0806; +pub const ETH_P_BPQ: ::c_int = 0x08FF; +pub const ETH_P_IEEEPUP: ::c_int = 0x0a00; +pub const ETH_P_IEEEPUPAT: ::c_int = 0x0a01; +pub const ETH_P_BATMAN: ::c_int = 0x4305; +pub const ETH_P_DEC: ::c_int = 0x6000; +pub const ETH_P_DNA_DL: ::c_int = 0x6001; +pub const ETH_P_DNA_RC: ::c_int = 0x6002; +pub const ETH_P_DNA_RT: ::c_int = 0x6003; +pub const ETH_P_LAT: ::c_int = 0x6004; +pub const ETH_P_DIAG: ::c_int = 0x6005; +pub const ETH_P_CUST: ::c_int = 0x6006; +pub const ETH_P_SCA: ::c_int = 0x6007; +pub const ETH_P_TEB: ::c_int = 0x6558; +pub const ETH_P_RARP: ::c_int = 0x8035; +pub const ETH_P_ATALK: ::c_int = 0x809B; +pub const ETH_P_AARP: ::c_int = 0x80F3; +pub const ETH_P_8021Q: ::c_int = 0x8100; +pub const ETH_P_IPX: ::c_int = 0x8137; +pub const ETH_P_IPV6: ::c_int = 0x86DD; +pub const ETH_P_PAUSE: ::c_int = 0x8808; +pub const ETH_P_SLOW: ::c_int = 0x8809; +pub const ETH_P_WCCP: ::c_int = 0x883E; +pub const ETH_P_MPLS_UC: ::c_int = 0x8847; +pub const ETH_P_MPLS_MC: ::c_int = 0x8848; +pub const ETH_P_ATMMPOA: ::c_int = 0x884c; +pub const ETH_P_PPP_DISC: ::c_int = 0x8863; +pub const ETH_P_PPP_SES: ::c_int = 0x8864; +pub const ETH_P_LINK_CTL: ::c_int = 0x886c; +pub const ETH_P_ATMFATE: ::c_int = 0x8884; +pub const ETH_P_PAE: ::c_int = 0x888E; +pub const ETH_P_AOE: ::c_int = 0x88A2; +pub const ETH_P_8021AD: ::c_int = 0x88A8; +pub const ETH_P_802_EX1: ::c_int = 0x88B5; +pub const ETH_P_TIPC: ::c_int = 0x88CA; +pub const ETH_P_MACSEC: ::c_int = 0x88E5; +pub const ETH_P_8021AH: ::c_int = 0x88E7; +pub const ETH_P_MVRP: ::c_int = 0x88F5; +pub const ETH_P_1588: ::c_int = 0x88F7; +pub const ETH_P_PRP: ::c_int = 0x88FB; +pub const ETH_P_FCOE: ::c_int = 0x8906; +pub const ETH_P_TDLS: ::c_int = 0x890D; +pub const ETH_P_FIP: ::c_int = 0x8914; +pub const ETH_P_80221: ::c_int = 0x8917; +pub const ETH_P_LOOPBACK: ::c_int = 0x9000; +pub const ETH_P_QINQ1: ::c_int = 0x9100; +pub const ETH_P_QINQ2: ::c_int = 0x9200; +pub const ETH_P_QINQ3: ::c_int = 0x9300; +pub const ETH_P_EDSA: ::c_int = 0xDADA; +pub const ETH_P_AF_IUCV: ::c_int = 0xFBFB; + +pub const ETH_P_802_3_MIN: ::c_int = 0x0600; + +// Non DIX types. Won't clash for 1500 types. +pub const ETH_P_802_3: ::c_int = 0x0001; +pub const ETH_P_AX25: ::c_int = 0x0002; +pub const ETH_P_ALL: ::c_int = 0x0003; +pub const ETH_P_802_2: ::c_int = 0x0004; +pub const ETH_P_SNAP: ::c_int = 0x0005; +pub const ETH_P_DDCMP: ::c_int = 0x0006; +pub const ETH_P_WAN_PPP: ::c_int = 0x0007; +pub const ETH_P_PPP_MP: ::c_int = 0x0008; +pub const ETH_P_LOCALTALK: ::c_int = 0x0009; +pub const ETH_P_CANFD: ::c_int = 0x000D; +pub const ETH_P_PPPTALK: ::c_int = 0x0010; +pub const ETH_P_TR_802_2: ::c_int = 0x0011; +pub const ETH_P_MOBITEX: ::c_int = 0x0015; +pub const ETH_P_CONTROL: ::c_int = 0x0016; +pub const ETH_P_IRDA: ::c_int = 0x0017; +pub const ETH_P_ECONET: ::c_int = 0x0018; +pub const ETH_P_HDLC: ::c_int = 0x0019; +pub const ETH_P_ARCNET: ::c_int = 0x001A; +pub const ETH_P_DSA: ::c_int = 0x001B; +pub const ETH_P_TRAILER: ::c_int = 0x001C; +pub const ETH_P_PHONET: ::c_int = 0x00F5; +pub const ETH_P_IEEE802154: ::c_int = 0x00F6; +pub const ETH_P_CAIF: ::c_int = 0x00F7; + +pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; +pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04; +pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x10; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x20; + +pub const NLMSG_NOOP: ::c_int = 0x1; +pub const NLMSG_ERROR: ::c_int = 0x2; +pub const NLMSG_DONE: ::c_int = 0x3; +pub const NLMSG_OVERRUN: ::c_int = 0x4; +pub const NLMSG_MIN_TYPE: ::c_int = 0x10; + +// linux/netfilter/nfnetlink.h +pub const NFNLGRP_NONE: ::c_int = 0; +pub const NFNLGRP_CONNTRACK_NEW: ::c_int = 1; +pub const NFNLGRP_CONNTRACK_UPDATE: ::c_int = 2; +pub const NFNLGRP_CONNTRACK_DESTROY: ::c_int = 3; +pub const NFNLGRP_CONNTRACK_EXP_NEW: ::c_int = 4; +pub const NFNLGRP_CONNTRACK_EXP_UPDATE: ::c_int = 5; +pub const NFNLGRP_CONNTRACK_EXP_DESTROY: ::c_int = 6; +pub const NFNLGRP_NFTABLES: ::c_int = 7; +pub const NFNLGRP_ACCT_QUOTA: ::c_int = 8; + +pub const NFNETLINK_V0: ::c_int = 0; + +pub const NFNL_SUBSYS_NONE: ::c_int = 0; +pub const NFNL_SUBSYS_CTNETLINK: ::c_int = 1; +pub const NFNL_SUBSYS_CTNETLINK_EXP: ::c_int = 2; +pub const NFNL_SUBSYS_QUEUE: ::c_int = 3; +pub const NFNL_SUBSYS_ULOG: ::c_int = 4; +pub const NFNL_SUBSYS_OSF: ::c_int = 5; +pub const NFNL_SUBSYS_IPSET: ::c_int = 6; +pub const NFNL_SUBSYS_ACCT: ::c_int = 7; +pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: ::c_int = 8; +pub const NFNL_SUBSYS_CTHELPER: ::c_int = 9; +pub const NFNL_SUBSYS_NFTABLES: ::c_int = 10; +pub const NFNL_SUBSYS_NFT_COMPAT: ::c_int = 11; +pub const NFNL_SUBSYS_COUNT: ::c_int = 12; + +pub const NFNL_MSG_BATCH_BEGIN: ::c_int = NLMSG_MIN_TYPE; +pub const NFNL_MSG_BATCH_END: ::c_int = NLMSG_MIN_TYPE + 1; + +// linux/netfilter/nfnetlink_log.h +pub const NFULNL_MSG_PACKET: ::c_int = 0; +pub const NFULNL_MSG_CONFIG: ::c_int = 1; + +pub const NFULA_UNSPEC: ::c_int = 0; +pub const NFULA_PACKET_HDR: ::c_int = 1; +pub const NFULA_MARK: ::c_int = 2; +pub const NFULA_TIMESTAMP: ::c_int = 3; +pub const NFULA_IFINDEX_INDEV: ::c_int = 4; +pub const NFULA_IFINDEX_OUTDEV: ::c_int = 5; +pub const NFULA_IFINDEX_PHYSINDEV: ::c_int = 6; +pub const NFULA_IFINDEX_PHYSOUTDEV: ::c_int = 7; +pub const NFULA_HWADDR: ::c_int = 8; +pub const NFULA_PAYLOAD: ::c_int = 9; +pub const NFULA_PREFIX: ::c_int = 10; +pub const NFULA_UID: ::c_int = 11; +pub const NFULA_SEQ: ::c_int = 12; +pub const NFULA_SEQ_GLOBAL: ::c_int = 13; +pub const NFULA_GID: ::c_int = 14; +pub const NFULA_HWTYPE: ::c_int = 15; +pub const NFULA_HWHEADER: ::c_int = 16; +pub const NFULA_HWLEN: ::c_int = 17; +pub const NFULA_CT: ::c_int = 18; +pub const NFULA_CT_INFO: ::c_int = 19; + +pub const NFULNL_CFG_CMD_NONE: ::c_int = 0; +pub const NFULNL_CFG_CMD_BIND: ::c_int = 1; +pub const NFULNL_CFG_CMD_UNBIND: ::c_int = 2; +pub const NFULNL_CFG_CMD_PF_BIND: ::c_int = 3; +pub const NFULNL_CFG_CMD_PF_UNBIND: ::c_int = 4; + +pub const NFULA_CFG_UNSPEC: ::c_int = 0; +pub const NFULA_CFG_CMD: ::c_int = 1; +pub const NFULA_CFG_MODE: ::c_int = 2; +pub const NFULA_CFG_NLBUFSIZ: ::c_int = 3; +pub const NFULA_CFG_TIMEOUT: ::c_int = 4; +pub const NFULA_CFG_QTHRESH: ::c_int = 5; +pub const NFULA_CFG_FLAGS: ::c_int = 6; + +pub const NFULNL_COPY_NONE: ::c_int = 0x00; +pub const NFULNL_COPY_META: ::c_int = 0x01; +pub const NFULNL_COPY_PACKET: ::c_int = 0x02; + +pub const NFULNL_CFG_F_SEQ: ::c_int = 0x0001; +pub const NFULNL_CFG_F_SEQ_GLOBAL: ::c_int = 0x0002; +pub const NFULNL_CFG_F_CONNTRACK: ::c_int = 0x0004; + +pub const GENL_NAMSIZ: ::c_int = 16; + +pub const GENL_MIN_ID: ::c_int = NLMSG_MIN_TYPE; +pub const GENL_MAX_ID: ::c_int = 1023; + +pub const GENL_ADMIN_PERM: ::c_int = 0x01; +pub const GENL_CMD_CAP_DO: ::c_int = 0x02; +pub const GENL_CMD_CAP_DUMP: ::c_int = 0x04; +pub const GENL_CMD_CAP_HASPOL: ::c_int = 0x08; + +pub const GENL_ID_CTRL: ::c_int = NLMSG_MIN_TYPE; + +pub const CTRL_CMD_UNSPEC: ::c_int = 0; +pub const CTRL_CMD_NEWFAMILY: ::c_int = 1; +pub const CTRL_CMD_DELFAMILY: ::c_int = 2; +pub const CTRL_CMD_GETFAMILY: ::c_int = 3; +pub const CTRL_CMD_NEWOPS: ::c_int = 4; +pub const CTRL_CMD_DELOPS: ::c_int = 5; +pub const CTRL_CMD_GETOPS: ::c_int = 6; +pub const CTRL_CMD_NEWMCAST_GRP: ::c_int = 7; +pub const CTRL_CMD_DELMCAST_GRP: ::c_int = 8; +pub const CTRL_CMD_GETMCAST_GRP: ::c_int = 9; + +pub const CTRL_ATTR_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_FAMILY_ID: ::c_int = 1; +pub const CTRL_ATTR_FAMILY_NAME: ::c_int = 2; +pub const CTRL_ATTR_VERSION: ::c_int = 3; +pub const CTRL_ATTR_HDRSIZE: ::c_int = 4; +pub const CTRL_ATTR_MAXATTR: ::c_int = 5; +pub const CTRL_ATTR_OPS: ::c_int = 6; +pub const CTRL_ATTR_MCAST_GROUPS: ::c_int = 7; + +pub const CTRL_ATTR_OP_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_OP_ID: ::c_int = 1; +pub const CTRL_ATTR_OP_FLAGS: ::c_int = 2; + +pub const CTRL_ATTR_MCAST_GRP_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_MCAST_GRP_NAME: ::c_int = 1; +pub const CTRL_ATTR_MCAST_GRP_ID: ::c_int = 2; + +// linux/if_packet.h +pub const PACKET_ADD_MEMBERSHIP: ::c_int = 1; +pub const PACKET_DROP_MEMBERSHIP: ::c_int = 2; + +pub const PACKET_MR_MULTICAST: ::c_int = 0; +pub const PACKET_MR_PROMISC: ::c_int = 1; +pub const PACKET_MR_ALLMULTI: ::c_int = 2; +pub const PACKET_MR_UNICAST: ::c_int = 3; + +// linux/netfilter.h +pub const NF_DROP: ::c_int = 0; +pub const NF_ACCEPT: ::c_int = 1; +pub const NF_STOLEN: ::c_int = 2; +pub const NF_QUEUE: ::c_int = 3; +pub const NF_REPEAT: ::c_int = 4; +pub const NF_STOP: ::c_int = 5; +pub const NF_MAX_VERDICT: ::c_int = NF_STOP; + +pub const NF_VERDICT_MASK: ::c_int = 0x000000ff; +pub const NF_VERDICT_FLAG_QUEUE_BYPASS: ::c_int = 0x00008000; + +pub const NF_VERDICT_QMASK: ::c_int = 0xffff0000; +pub const NF_VERDICT_QBITS: ::c_int = 16; + +pub const NF_VERDICT_BITS: ::c_int = 16; + +pub const NF_INET_PRE_ROUTING: ::c_int = 0; +pub const NF_INET_LOCAL_IN: ::c_int = 1; +pub const NF_INET_FORWARD: ::c_int = 2; +pub const NF_INET_LOCAL_OUT: ::c_int = 3; +pub const NF_INET_POST_ROUTING: ::c_int = 4; +pub const NF_INET_NUMHOOKS: ::c_int = 5; + +// Some NFPROTO are not compatible with musl and are defined in submodules. +pub const NFPROTO_UNSPEC: ::c_int = 0; +pub const NFPROTO_IPV4: ::c_int = 2; +pub const NFPROTO_ARP: ::c_int = 3; +pub const NFPROTO_BRIDGE: ::c_int = 7; +pub const NFPROTO_IPV6: ::c_int = 10; +pub const NFPROTO_DECNET: ::c_int = 12; +pub const NFPROTO_NUMPROTO: ::c_int = 13; + +// linux/netfilter_ipv4.h +pub const NF_IP_PRE_ROUTING: ::c_int = 0; +pub const NF_IP_LOCAL_IN: ::c_int = 1; +pub const NF_IP_FORWARD: ::c_int = 2; +pub const NF_IP_LOCAL_OUT: ::c_int = 3; +pub const NF_IP_POST_ROUTING: ::c_int = 4; +pub const NF_IP_NUMHOOKS: ::c_int = 5; + +pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400; +pub const NF_IP_PRI_RAW: ::c_int = -300; +pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225; +pub const NF_IP_PRI_CONNTRACK: ::c_int = -200; +pub const NF_IP_PRI_MANGLE: ::c_int = -150; +pub const NF_IP_PRI_NAT_DST: ::c_int = -100; +pub const NF_IP_PRI_FILTER: ::c_int = 0; +pub const NF_IP_PRI_SECURITY: ::c_int = 50; +pub const NF_IP_PRI_NAT_SRC: ::c_int = 100; +pub const NF_IP_PRI_SELINUX_LAST: ::c_int = 225; +pub const NF_IP_PRI_CONNTRACK_HELPER: ::c_int = 300; +pub const NF_IP_PRI_CONNTRACK_CONFIRM: ::c_int = ::INT_MAX; +pub const NF_IP_PRI_LAST: ::c_int = ::INT_MAX; + +// linux/netfilter_ipv6.h +pub const NF_IP6_PRE_ROUTING: ::c_int = 0; +pub const NF_IP6_LOCAL_IN: ::c_int = 1; +pub const NF_IP6_FORWARD: ::c_int = 2; +pub const NF_IP6_LOCAL_OUT: ::c_int = 3; +pub const NF_IP6_POST_ROUTING: ::c_int = 4; +pub const NF_IP6_NUMHOOKS: ::c_int = 5; + +pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400; +pub const NF_IP6_PRI_RAW: ::c_int = -300; +pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225; +pub const NF_IP6_PRI_CONNTRACK: ::c_int = -200; +pub const NF_IP6_PRI_MANGLE: ::c_int = -150; +pub const NF_IP6_PRI_NAT_DST: ::c_int = -100; +pub const NF_IP6_PRI_FILTER: ::c_int = 0; +pub const NF_IP6_PRI_SECURITY: ::c_int = 50; +pub const NF_IP6_PRI_NAT_SRC: ::c_int = 100; +pub const NF_IP6_PRI_SELINUX_LAST: ::c_int = 225; +pub const NF_IP6_PRI_CONNTRACK_HELPER: ::c_int = 300; +pub const NF_IP6_PRI_LAST: ::c_int = ::INT_MAX; + +pub const SIOCADDRT: ::c_ulong = 0x0000890B; +pub const SIOCDELRT: ::c_ulong = 0x0000890C; +pub const SIOCGIFNAME: ::c_ulong = 0x00008910; +pub const SIOCSIFLINK: ::c_ulong = 0x00008911; +pub const SIOCGIFCONF: ::c_ulong = 0x00008912; +pub const SIOCGIFFLAGS: ::c_ulong = 0x00008913; +pub const SIOCSIFFLAGS: ::c_ulong = 0x00008914; +pub const SIOCGIFADDR: ::c_ulong = 0x00008915; +pub const SIOCSIFADDR: ::c_ulong = 0x00008916; +pub const SIOCGIFDSTADDR: ::c_ulong = 0x00008917; +pub const SIOCSIFDSTADDR: ::c_ulong = 0x00008918; +pub const SIOCGIFBRDADDR: ::c_ulong = 0x00008919; +pub const SIOCSIFBRDADDR: ::c_ulong = 0x0000891A; +pub const SIOCGIFNETMASK: ::c_ulong = 0x0000891B; +pub const SIOCSIFNETMASK: ::c_ulong = 0x0000891C; +pub const SIOCGIFMETRIC: ::c_ulong = 0x0000891D; +pub const SIOCSIFMETRIC: ::c_ulong = 0x0000891E; +pub const SIOCGIFMEM: ::c_ulong = 0x0000891F; +pub const SIOCSIFMEM: ::c_ulong = 0x00008920; +pub const SIOCGIFMTU: ::c_ulong = 0x00008921; +pub const SIOCSIFMTU: ::c_ulong = 0x00008922; +pub const SIOCSIFHWADDR: ::c_ulong = 0x00008924; +pub const SIOCGIFENCAP: ::c_ulong = 0x00008925; +pub const SIOCSIFENCAP: ::c_ulong = 0x00008926; +pub const SIOCGIFHWADDR: ::c_ulong = 0x00008927; +pub const SIOCGIFSLAVE: ::c_ulong = 0x00008929; +pub const SIOCSIFSLAVE: ::c_ulong = 0x00008930; +pub const SIOCADDMULTI: ::c_ulong = 0x00008931; +pub const SIOCDELMULTI: ::c_ulong = 0x00008932; +pub const SIOCDARP: ::c_ulong = 0x00008953; +pub const SIOCGARP: ::c_ulong = 0x00008954; +pub const SIOCSARP: ::c_ulong = 0x00008955; +pub const SIOCDRARP: ::c_ulong = 0x00008960; +pub const SIOCGRARP: ::c_ulong = 0x00008961; +pub const SIOCSRARP: ::c_ulong = 0x00008962; +pub const SIOCGIFMAP: ::c_ulong = 0x00008970; +pub const SIOCSIFMAP: ::c_ulong = 0x00008971; + +pub const IPTOS_TOS_MASK: u8 = 0x1E; +pub const IPTOS_PREC_MASK: u8 = 0xE0; + +pub const IPTOS_ECN_NOT_ECT: u8 = 0x00; + +pub const RTF_UP: ::c_ushort = 0x0001; +pub const RTF_GATEWAY: ::c_ushort = 0x0002; + +pub const RTF_HOST: ::c_ushort = 0x0004; +pub const RTF_REINSTATE: ::c_ushort = 0x0008; +pub const RTF_DYNAMIC: ::c_ushort = 0x0010; +pub const RTF_MODIFIED: ::c_ushort = 0x0020; +pub const RTF_MTU: ::c_ushort = 0x0040; +pub const RTF_MSS: ::c_ushort = RTF_MTU; +pub const RTF_WINDOW: ::c_ushort = 0x0080; +pub const RTF_IRTT: ::c_ushort = 0x0100; +pub const RTF_REJECT: ::c_ushort = 0x0200; +pub const RTF_STATIC: ::c_ushort = 0x0400; +pub const RTF_XRESOLVE: ::c_ushort = 0x0800; +pub const RTF_NOFORWARD: ::c_ushort = 0x1000; +pub const RTF_THROW: ::c_ushort = 0x2000; +pub const RTF_NOPMTUDISC: ::c_ushort = 0x4000; + +pub const RTF_DEFAULT: u32 = 0x00010000; +pub const RTF_ALLONLINK: u32 = 0x00020000; +pub const RTF_ADDRCONF: u32 = 0x00040000; +pub const RTF_LINKRT: u32 = 0x00100000; +pub const RTF_NONEXTHOP: u32 = 0x00200000; +pub const RTF_CACHE: u32 = 0x01000000; +pub const RTF_FLOW: u32 = 0x02000000; +pub const RTF_POLICY: u32 = 0x04000000; + +pub const RTCF_VALVE: u32 = 0x00200000; +pub const RTCF_MASQ: u32 = 0x00400000; +pub const RTCF_NAT: u32 = 0x00800000; +pub const RTCF_DOREDIRECT: u32 = 0x01000000; +pub const RTCF_LOG: u32 = 0x02000000; +pub const RTCF_DIRECTSRC: u32 = 0x04000000; + +pub const RTF_LOCAL: u32 = 0x80000000; +pub const RTF_INTERFACE: u32 = 0x40000000; +pub const RTF_MULTICAST: u32 = 0x20000000; +pub const RTF_BROADCAST: u32 = 0x10000000; +pub const RTF_NAT: u32 = 0x08000000; +pub const RTF_ADDRCLASSMASK: u32 = 0xF8000000; + +pub const RT_CLASS_UNSPEC: u8 = 0; +pub const RT_CLASS_DEFAULT: u8 = 253; +pub const RT_CLASS_MAIN: u8 = 254; +pub const RT_CLASS_LOCAL: u8 = 255; +pub const RT_CLASS_MAX: u8 = 255; + +// linux/neighbor.h +pub const NUD_NONE: u16 = 0x00; +pub const NUD_INCOMPLETE: u16 = 0x01; +pub const NUD_REACHABLE: u16 = 0x02; +pub const NUD_STALE: u16 = 0x04; +pub const NUD_DELAY: u16 = 0x08; +pub const NUD_PROBE: u16 = 0x10; +pub const NUD_FAILED: u16 = 0x20; +pub const NUD_NOARP: u16 = 0x40; +pub const NUD_PERMANENT: u16 = 0x80; + +pub const NTF_USE: u8 = 0x01; +pub const NTF_SELF: u8 = 0x02; +pub const NTF_MASTER: u8 = 0x04; +pub const NTF_PROXY: u8 = 0x08; +pub const NTF_ROUTER: u8 = 0x80; + +pub const NDA_UNSPEC: ::c_ushort = 0; +pub const NDA_DST: ::c_ushort = 1; +pub const NDA_LLADDR: ::c_ushort = 2; +pub const NDA_CACHEINFO: ::c_ushort = 3; +pub const NDA_PROBES: ::c_ushort = 4; +pub const NDA_VLAN: ::c_ushort = 5; +pub const NDA_PORT: ::c_ushort = 6; +pub const NDA_VNI: ::c_ushort = 7; +pub const NDA_IFINDEX: ::c_ushort = 8; + +// linux/netlink.h +pub const NLA_ALIGNTO: ::c_int = 4; + +pub const NETLINK_ROUTE: ::c_int = 0; +pub const NETLINK_UNUSED: ::c_int = 1; +pub const NETLINK_USERSOCK: ::c_int = 2; +pub const NETLINK_FIREWALL: ::c_int = 3; +pub const NETLINK_SOCK_DIAG: ::c_int = 4; +pub const NETLINK_NFLOG: ::c_int = 5; +pub const NETLINK_XFRM: ::c_int = 6; +pub const NETLINK_SELINUX: ::c_int = 7; +pub const NETLINK_ISCSI: ::c_int = 8; +pub const NETLINK_AUDIT: ::c_int = 9; +pub const NETLINK_FIB_LOOKUP: ::c_int = 10; +pub const NETLINK_CONNECTOR: ::c_int = 11; +pub const NETLINK_NETFILTER: ::c_int = 12; +pub const NETLINK_IP6_FW: ::c_int = 13; +pub const NETLINK_DNRTMSG: ::c_int = 14; +pub const NETLINK_KOBJECT_UEVENT: ::c_int = 15; +pub const NETLINK_GENERIC: ::c_int = 16; +pub const NETLINK_SCSITRANSPORT: ::c_int = 18; +pub const NETLINK_ECRYPTFS: ::c_int = 19; +pub const NETLINK_RDMA: ::c_int = 20; +pub const NETLINK_CRYPTO: ::c_int = 21; +pub const NETLINK_INET_DIAG: ::c_int = NETLINK_SOCK_DIAG; + +pub const NLM_F_REQUEST: ::c_int = 1; +pub const NLM_F_MULTI: ::c_int = 2; +pub const NLM_F_ACK: ::c_int = 4; +pub const NLM_F_ECHO: ::c_int = 8; +pub const NLM_F_DUMP_INTR: ::c_int = 16; +pub const NLM_F_DUMP_FILTERED: ::c_int = 32; + +pub const NLM_F_ROOT: ::c_int = 0x100; +pub const NLM_F_MATCH: ::c_int = 0x200; +pub const NLM_F_ATOMIC: ::c_int = 0x400; +pub const NLM_F_DUMP: ::c_int = NLM_F_ROOT | NLM_F_MATCH; + +pub const NLM_F_REPLACE: ::c_int = 0x100; +pub const NLM_F_EXCL: ::c_int = 0x200; +pub const NLM_F_CREATE: ::c_int = 0x400; +pub const NLM_F_APPEND: ::c_int = 0x800; + +pub const NETLINK_ADD_MEMBERSHIP: ::c_int = 1; +pub const NETLINK_DROP_MEMBERSHIP: ::c_int = 2; +pub const NETLINK_PKTINFO: ::c_int = 3; +pub const NETLINK_BROADCAST_ERROR: ::c_int = 4; +pub const NETLINK_NO_ENOBUFS: ::c_int = 5; +pub const NETLINK_RX_RING: ::c_int = 6; +pub const NETLINK_TX_RING: ::c_int = 7; +pub const NETLINK_LISTEN_ALL_NSID: ::c_int = 8; +pub const NETLINK_LIST_MEMBERSHIPS: ::c_int = 9; +pub const NETLINK_CAP_ACK: ::c_int = 10; + +pub const NLA_F_NESTED: ::c_int = 1 << 15; +pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14; +pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); + +// linux/rtnetlink.h +pub const TCA_UNSPEC: ::c_ushort = 0; +pub const TCA_KIND: ::c_ushort = 1; +pub const TCA_OPTIONS: ::c_ushort = 2; +pub const TCA_STATS: ::c_ushort = 3; +pub const TCA_XSTATS: ::c_ushort = 4; +pub const TCA_RATE: ::c_ushort = 5; +pub const TCA_FCNT: ::c_ushort = 6; +pub const TCA_STATS2: ::c_ushort = 7; +pub const TCA_STAB: ::c_ushort = 8; + +pub const RTM_NEWLINK: u16 = 16; +pub const RTM_DELLINK: u16 = 17; +pub const RTM_GETLINK: u16 = 18; +pub const RTM_SETLINK: u16 = 19; +pub const RTM_NEWADDR: u16 = 20; +pub const RTM_DELADDR: u16 = 21; +pub const RTM_GETADDR: u16 = 22; +pub const RTM_NEWROUTE: u16 = 24; +pub const RTM_DELROUTE: u16 = 25; +pub const RTM_GETROUTE: u16 = 26; +pub const RTM_NEWNEIGH: u16 = 28; +pub const RTM_DELNEIGH: u16 = 29; +pub const RTM_GETNEIGH: u16 = 30; +pub const RTM_NEWRULE: u16 = 32; +pub const RTM_DELRULE: u16 = 33; +pub const RTM_GETRULE: u16 = 34; +pub const RTM_NEWQDISC: u16 = 36; +pub const RTM_DELQDISC: u16 = 37; +pub const RTM_GETQDISC: u16 = 38; +pub const RTM_NEWTCLASS: u16 = 40; +pub const RTM_DELTCLASS: u16 = 41; +pub const RTM_GETTCLASS: u16 = 42; +pub const RTM_NEWTFILTER: u16 = 44; +pub const RTM_DELTFILTER: u16 = 45; +pub const RTM_GETTFILTER: u16 = 46; +pub const RTM_NEWACTION: u16 = 48; +pub const RTM_DELACTION: u16 = 49; +pub const RTM_GETACTION: u16 = 50; +pub const RTM_NEWPREFIX: u16 = 52; +pub const RTM_GETMULTICAST: u16 = 58; +pub const RTM_GETANYCAST: u16 = 62; +pub const RTM_NEWNEIGHTBL: u16 = 64; +pub const RTM_GETNEIGHTBL: u16 = 66; +pub const RTM_SETNEIGHTBL: u16 = 67; +pub const RTM_NEWNDUSEROPT: u16 = 68; +pub const RTM_NEWADDRLABEL: u16 = 72; +pub const RTM_DELADDRLABEL: u16 = 73; +pub const RTM_GETADDRLABEL: u16 = 74; +pub const RTM_GETDCB: u16 = 78; +pub const RTM_SETDCB: u16 = 79; +pub const RTM_NEWNETCONF: u16 = 80; +pub const RTM_GETNETCONF: u16 = 82; +pub const RTM_NEWMDB: u16 = 84; +pub const RTM_DELMDB: u16 = 85; +pub const RTM_GETMDB: u16 = 86; +pub const RTM_NEWNSID: u16 = 88; +pub const RTM_DELNSID: u16 = 89; +pub const RTM_GETNSID: u16 = 90; + +pub const RTM_F_NOTIFY: ::c_uint = 0x100; +pub const RTM_F_CLONED: ::c_uint = 0x200; +pub const RTM_F_EQUALIZE: ::c_uint = 0x400; +pub const RTM_F_PREFIX: ::c_uint = 0x800; + +pub const RTA_UNSPEC: ::c_ushort = 0; +pub const RTA_DST: ::c_ushort = 1; +pub const RTA_SRC: ::c_ushort = 2; +pub const RTA_IIF: ::c_ushort = 3; +pub const RTA_OIF: ::c_ushort = 4; +pub const RTA_GATEWAY: ::c_ushort = 5; +pub const RTA_PRIORITY: ::c_ushort = 6; +pub const RTA_PREFSRC: ::c_ushort = 7; +pub const RTA_METRICS: ::c_ushort = 8; +pub const RTA_MULTIPATH: ::c_ushort = 9; +pub const RTA_PROTOINFO: ::c_ushort = 10; // No longer used +pub const RTA_FLOW: ::c_ushort = 11; +pub const RTA_CACHEINFO: ::c_ushort = 12; +pub const RTA_SESSION: ::c_ushort = 13; // No longer used +pub const RTA_MP_ALGO: ::c_ushort = 14; // No longer used +pub const RTA_TABLE: ::c_ushort = 15; +pub const RTA_MARK: ::c_ushort = 16; +pub const RTA_MFC_STATS: ::c_ushort = 17; + +pub const RTN_UNSPEC: ::c_uchar = 0; +pub const RTN_UNICAST: ::c_uchar = 1; +pub const RTN_LOCAL: ::c_uchar = 2; +pub const RTN_BROADCAST: ::c_uchar = 3; +pub const RTN_ANYCAST: ::c_uchar = 4; +pub const RTN_MULTICAST: ::c_uchar = 5; +pub const RTN_BLACKHOLE: ::c_uchar = 6; +pub const RTN_UNREACHABLE: ::c_uchar = 7; +pub const RTN_PROHIBIT: ::c_uchar = 8; +pub const RTN_THROW: ::c_uchar = 9; +pub const RTN_NAT: ::c_uchar = 10; +pub const RTN_XRESOLVE: ::c_uchar = 11; + +pub const RTPROT_UNSPEC: ::c_uchar = 0; +pub const RTPROT_REDIRECT: ::c_uchar = 1; +pub const RTPROT_KERNEL: ::c_uchar = 2; +pub const RTPROT_BOOT: ::c_uchar = 3; +pub const RTPROT_STATIC: ::c_uchar = 4; + +pub const RT_SCOPE_UNIVERSE: ::c_uchar = 0; +pub const RT_SCOPE_SITE: ::c_uchar = 200; +pub const RT_SCOPE_LINK: ::c_uchar = 253; +pub const RT_SCOPE_HOST: ::c_uchar = 254; +pub const RT_SCOPE_NOWHERE: ::c_uchar = 255; + +pub const RT_TABLE_UNSPEC: ::c_uchar = 0; +pub const RT_TABLE_COMPAT: ::c_uchar = 252; +pub const RT_TABLE_DEFAULT: ::c_uchar = 253; +pub const RT_TABLE_MAIN: ::c_uchar = 254; +pub const RT_TABLE_LOCAL: ::c_uchar = 255; + +pub const RTMSG_OVERRUN: u32 = ::NLMSG_OVERRUN as u32; +pub const RTMSG_NEWDEVICE: u32 = 0x11; +pub const RTMSG_DELDEVICE: u32 = 0x12; +pub const RTMSG_NEWROUTE: u32 = 0x21; +pub const RTMSG_DELROUTE: u32 = 0x22; +pub const RTMSG_NEWRULE: u32 = 0x31; +pub const RTMSG_DELRULE: u32 = 0x32; +pub const RTMSG_CONTROL: u32 = 0x40; +pub const RTMSG_AR_FAILED: u32 = 0x51; + +pub const MAX_ADDR_LEN: usize = 7; +pub const ARPD_UPDATE: ::c_ushort = 0x01; +pub const ARPD_LOOKUP: ::c_ushort = 0x02; +pub const ARPD_FLUSH: ::c_ushort = 0x03; +pub const ATF_MAGIC: ::c_int = 0x80; + +#[cfg(not(target_arch = "sparc64"))] +pub const SO_TIMESTAMPING: ::c_int = 37; +#[cfg(target_arch = "sparc64")] +pub const SO_TIMESTAMPING: ::c_int = 35; +pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + +// linux/module.h +pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001; +pub const MODULE_INIT_IGNORE_VERMAGIC: ::c_uint = 0x0002; + +// linux/net_tstamp.h +pub const SOF_TIMESTAMPING_TX_HARDWARE: ::c_uint = 1 << 0; +pub const SOF_TIMESTAMPING_TX_SOFTWARE: ::c_uint = 1 << 1; +pub const SOF_TIMESTAMPING_RX_HARDWARE: ::c_uint = 1 << 2; +pub const SOF_TIMESTAMPING_RX_SOFTWARE: ::c_uint = 1 << 3; +pub const SOF_TIMESTAMPING_SOFTWARE: ::c_uint = 1 << 4; +pub const SOF_TIMESTAMPING_SYS_HARDWARE: ::c_uint = 1 << 5; +pub const SOF_TIMESTAMPING_RAW_HARDWARE: ::c_uint = 1 << 6; + +// linux/if_alg.h +pub const ALG_SET_KEY: ::c_int = 1; +pub const ALG_SET_IV: ::c_int = 2; +pub const ALG_SET_OP: ::c_int = 3; +pub const ALG_SET_AEAD_ASSOCLEN: ::c_int = 4; +pub const ALG_SET_AEAD_AUTHSIZE: ::c_int = 5; + +pub const ALG_OP_DECRYPT: ::c_int = 0; +pub const ALG_OP_ENCRYPT: ::c_int = 1; + +// uapi/linux/vm_sockets.h +pub const VMADDR_CID_ANY: ::c_uint = 0xFFFFFFFF; +pub const VMADDR_CID_HYPERVISOR: ::c_uint = 0; +pub const VMADDR_CID_RESERVED: ::c_uint = 1; +pub const VMADDR_CID_HOST: ::c_uint = 2; +pub const VMADDR_PORT_ANY: ::c_uint = 0xFFFFFFFF; + +// uapi/linux/inotify.h +pub const IN_ACCESS: u32 = 0x0000_0001; +pub const IN_MODIFY: u32 = 0x0000_0002; +pub const IN_ATTRIB: u32 = 0x0000_0004; +pub const IN_CLOSE_WRITE: u32 = 0x0000_0008; +pub const IN_CLOSE_NOWRITE: u32 = 0x0000_0010; +pub const IN_CLOSE: u32 = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE); +pub const IN_OPEN: u32 = 0x0000_0020; +pub const IN_MOVED_FROM: u32 = 0x0000_0040; +pub const IN_MOVED_TO: u32 = 0x0000_0080; +pub const IN_MOVE: u32 = (IN_MOVED_FROM | IN_MOVED_TO); +pub const IN_CREATE: u32 = 0x0000_0100; +pub const IN_DELETE: u32 = 0x0000_0200; +pub const IN_DELETE_SELF: u32 = 0x0000_0400; +pub const IN_MOVE_SELF: u32 = 0x0000_0800; +pub const IN_UNMOUNT: u32 = 0x0000_2000; +pub const IN_Q_OVERFLOW: u32 = 0x0000_4000; +pub const IN_IGNORED: u32 = 0x0000_8000; +pub const IN_ONLYDIR: u32 = 0x0100_0000; +pub const IN_DONT_FOLLOW: u32 = 0x0200_0000; +// pub const IN_EXCL_UNLINK: u32 = 0x0400_0000; + +// pub const IN_MASK_CREATE: u32 = 0x1000_0000; +// pub const IN_MASK_ADD: u32 = 0x2000_0000; +pub const IN_ISDIR: u32 = 0x4000_0000; +pub const IN_ONESHOT: u32 = 0x8000_0000; + +pub const IN_ALL_EVENTS: u32 = (IN_ACCESS + | IN_MODIFY + | IN_ATTRIB + | IN_CLOSE_WRITE + | IN_CLOSE_NOWRITE + | IN_OPEN + | IN_MOVED_FROM + | IN_MOVED_TO + | IN_DELETE + | IN_CREATE + | IN_DELETE_SELF + | IN_MOVE_SELF); + +pub const IN_CLOEXEC: ::c_int = O_CLOEXEC; +pub const IN_NONBLOCK: ::c_int = O_NONBLOCK; + +pub const FUTEX_WAIT: ::c_int = 0; +pub const FUTEX_WAKE: ::c_int = 1; +pub const FUTEX_FD: ::c_int = 2; +pub const FUTEX_REQUEUE: ::c_int = 3; +pub const FUTEX_CMP_REQUEUE: ::c_int = 4; +pub const FUTEX_WAKE_OP: ::c_int = 5; +pub const FUTEX_LOCK_PI: ::c_int = 6; +pub const FUTEX_UNLOCK_PI: ::c_int = 7; +pub const FUTEX_TRYLOCK_PI: ::c_int = 8; +pub const FUTEX_WAIT_BITSET: ::c_int = 9; +pub const FUTEX_WAKE_BITSET: ::c_int = 10; +pub const FUTEX_WAIT_REQUEUE_PI: ::c_int = 11; +pub const FUTEX_CMP_REQUEUE_PI: ::c_int = 12; + +pub const FUTEX_PRIVATE_FLAG: ::c_int = 128; +pub const FUTEX_CLOCK_REALTIME: ::c_int = 256; +pub const FUTEX_CMD_MASK: ::c_int = + !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME); + +f! { + pub fn NLA_ALIGN(len: ::c_int) -> ::c_int { + return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1) + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, + cmsg: *const cmsghdr) -> *mut cmsghdr { + if ((*cmsg).cmsg_len as usize) < ::mem::size_of::() { + return 0 as *mut cmsghdr; + }; + let next = (cmsg as usize + + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) + as *mut cmsghdr; + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if (next.offset(1)) as usize > max || + next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max + { + 0 as *mut cmsghdr + } else { + next as *mut cmsghdr + } + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits + = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] |= 1 << offset; + () + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits + = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] &= !(1 << offset); + () + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]); + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + 0 != (cpuset.bits[idx] & (1 << offset)) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.bits == set2.bits + } + + pub fn major(dev: ::dev_t) -> ::c_uint { + let mut major = 0; + major |= (dev & 0x00000000000fff00) >> 8; + major |= (dev & 0xfffff00000000000) >> 32; + major as ::c_uint + } + + pub fn minor(dev: ::dev_t) -> ::c_uint { + let mut minor = 0; + minor |= (dev & 0x00000000000000ff) >> 0; + minor |= (dev & 0x00000ffffff00000) >> 12; + minor as ::c_uint + } + + pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t { + let major = major as ::dev_t; + let minor = minor as ::dev_t; + let mut dev = 0; + dev |= (major & 0x00000fff) << 8; + dev |= (major & 0xfffff000) << 32; + dev |= (minor & 0x000000ff) << 0; + dev |= (minor & 0xffffff00) << 12; + dev + } + + pub fn IPTOS_TOS(tos: u8) -> u8 { + tos & IPTOS_TOS_MASK + } + + pub fn IPTOS_PREC(tos: u8) -> u8 { + tos & IPTOS_PREC_MASK + } + + pub fn RT_TOS(tos: u8) -> u8 { + tos & ::IPTOS_TOS_MASK + } + + pub fn RT_ADDRCLASS(flags: u32) -> u32 { + flags >> 23 + } + + pub fn RT_LOCALADDR(flags: u32) -> bool { + (flags & RTF_ADDRCLASSMASK) == (RTF_LOCAL | RTF_INTERFACE) + } +} + +extern "C" { + #[cfg_attr(not(target_env = "musl"), link_name = "__xpg_strerror_r")] + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + + pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: ::c_int, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; + pub fn lio_listio( + mode: ::c_int, + aiocb_list: *const *mut aiocb, + nitems: ::c_int, + sevp: *mut ::sigevent, + ) -> ::c_int; + + pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut ::group; + pub fn setspent(); + pub fn endspent(); + pub fn getspent() -> *mut spwd; + + pub fn getspnam(__name: *const ::c_char) -> *mut spwd; + + pub fn shm_open( + name: *const c_char, + oflag: ::c_int, + mode: mode_t, + ) -> ::c_int; + + // System V IPC + pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; + pub fn shmat( + shmid: ::c_int, + shmaddr: *const ::c_void, + shmflg: ::c_int, + ) -> *mut ::c_void; + pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; + pub fn shmctl( + shmid: ::c_int, + cmd: ::c_int, + buf: *mut ::shmid_ds, + ) -> ::c_int; + pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t; + pub fn semget(key: ::key_t, nsems: ::c_int, semflag: ::c_int) -> ::c_int; + pub fn semop( + semid: ::c_int, + sops: *mut ::sembuf, + nsops: ::size_t, + ) -> ::c_int; + pub fn semctl( + semid: ::c_int, + semnum: ::c_int, + cmd: ::c_int, + ... + ) -> ::c_int; + pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) + -> ::c_int; + pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; + pub fn msgrcv( + msqid: ::c_int, + msgp: *mut ::c_void, + msgsz: ::size_t, + msgtyp: ::c_long, + msgflg: ::c_int, + ) -> ::ssize_t; + pub fn msgsnd( + msqid: ::c_int, + msgp: *const ::c_void, + msgsz: ::size_t, + msgflg: ::c_int, + ) -> ::c_int; + + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn __errno_location() -> *mut ::c_int; + + pub fn fopen64( + filename: *const c_char, + mode: *const c_char, + ) -> *mut ::FILE; + pub fn freopen64( + filename: *const c_char, + mode: *const c_char, + file: *mut ::FILE, + ) -> *mut ::FILE; + pub fn tmpfile64() -> *mut ::FILE; + pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int; + pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int; + pub fn fseeko64( + stream: *mut ::FILE, + offset: ::off64_t, + whence: ::c_int, + ) -> ::c_int; + pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; + pub fn fallocate( + fd: ::c_int, + mode: ::c_int, + offset: ::off_t, + len: ::off_t, + ) -> ::c_int; + pub fn fallocate64( + fd: ::c_int, + mode: ::c_int, + offset: ::off64_t, + len: ::off64_t, + ) -> ::c_int; + pub fn posix_fallocate( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + ) -> ::c_int; + pub fn posix_fallocate64( + fd: ::c_int, + offset: ::off64_t, + len: ::off64_t, + ) -> ::c_int; + pub fn readahead( + fd: ::c_int, + offset: ::off64_t, + count: ::size_t, + ) -> ::ssize_t; + pub fn getxattr( + path: *const c_char, + name: *const c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn lgetxattr( + path: *const c_char, + name: *const c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn fgetxattr( + filedes: ::c_int, + name: *const c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn setxattr( + path: *const c_char, + name: *const c_char, + value: *const ::c_void, + size: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn lsetxattr( + path: *const c_char, + name: *const c_char, + value: *const ::c_void, + size: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn fsetxattr( + filedes: ::c_int, + name: *const c_char, + value: *const ::c_void, + size: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn listxattr( + path: *const c_char, + list: *mut c_char, + size: ::size_t, + ) -> ::ssize_t; + pub fn llistxattr( + path: *const c_char, + list: *mut c_char, + size: ::size_t, + ) -> ::ssize_t; + pub fn flistxattr( + filedes: ::c_int, + list: *mut c_char, + size: ::size_t, + ) -> ::ssize_t; + pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int; + pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int; + pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int; + pub fn signalfd( + fd: ::c_int, + mask: *const ::sigset_t, + flags: ::c_int, + ) -> ::c_int; + pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int; + pub fn timerfd_gettime( + fd: ::c_int, + curr_value: *mut itimerspec, + ) -> ::c_int; + pub fn timerfd_settime( + fd: ::c_int, + flags: ::c_int, + new_value: *const itimerspec, + old_value: *mut itimerspec, + ) -> ::c_int; + pub fn pwritev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn preadv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn quotactl( + cmd: ::c_int, + special: *const ::c_char, + id: ::c_int, + data: *mut ::c_char, + ) -> ::c_int; + pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; + pub fn mq_close(mqd: ::mqd_t) -> ::c_int; + pub fn mq_unlink(name: *const ::c_char) -> ::c_int; + pub fn mq_receive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + ) -> ::ssize_t; + pub fn mq_timedreceive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::ssize_t; + pub fn mq_send( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + ) -> ::c_int; + pub fn mq_timedsend( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::c_int; + pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; + pub fn mq_setattr( + mqd: ::mqd_t, + newattr: *const ::mq_attr, + oldattr: *mut ::mq_attr, + ) -> ::c_int; + pub fn epoll_pwait( + epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: ::c_int, + sigmask: *const ::sigset_t, + ) -> ::c_int; + pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int; + pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; + pub fn mkostemps( + template: *mut ::c_char, + suffixlen: ::c_int, + flags: ::c_int, + ) -> ::c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int; + pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) + -> *mut ::c_char; + pub fn getnameinfo( + sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::socklen_t, + serv: *mut ::c_char, + sevlen: ::socklen_t, + flags: ::c_int, + ) -> ::c_int; + pub fn pthread_setschedprio( + native: ::pthread_t, + priority: ::c_int, + ) -> ::c_int; + pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; + pub fn process_vm_readv( + pid: ::pid_t, + local_iov: *const ::iovec, + liovcnt: ::c_ulong, + remote_iov: *const ::iovec, + riovcnt: ::c_ulong, + flags: ::c_ulong, + ) -> isize; + pub fn process_vm_writev( + pid: ::pid_t, + local_iov: *const ::iovec, + liovcnt: ::c_ulong, + remote_iov: *const ::iovec, + riovcnt: ::c_ulong, + flags: ::c_ulong, + ) -> isize; + pub fn reboot(how_to: ::c_int) -> ::c_int; + pub fn setfsgid(gid: ::gid_t) -> ::c_int; + pub fn setfsuid(uid: ::uid_t) -> ::c_int; + + // Not available now on Android + pub fn mkfifoat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + ) -> ::c_int; + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + pub fn sync_file_range( + fd: ::c_int, + offset: ::off64_t, + nbytes: ::off64_t, + flags: ::c_uint, + ) -> ::c_int; + pub fn mremap( + addr: *mut ::c_void, + len: ::size_t, + new_len: ::size_t, + flags: ::c_int, + ... + ) -> *mut ::c_void; + + pub fn glob( + pattern: *const c_char, + flags: ::c_int, + errfunc: ::Option< + extern "C" fn(epath: *const c_char, errno: ::c_int) -> ::c_int, + >, + pglob: *mut ::glob_t, + ) -> ::c_int; + pub fn globfree(pglob: *mut ::glob_t); + + pub fn posix_madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); + + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; + pub fn madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn msync( + addr: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn remap_file_pages( + addr: *mut ::c_void, + size: ::size_t, + prot: ::c_int, + pgoff: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn recvfrom( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + ) -> ::ssize_t; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn vhangup() -> ::c_int; + pub fn sync(); + pub fn syscall(num: ::c_long, ...) -> ::c_long; + pub fn sched_getaffinity( + pid: ::pid_t, + cpusetsize: ::size_t, + cpuset: *mut cpu_set_t, + ) -> ::c_int; + pub fn sched_setaffinity( + pid: ::pid_t, + cpusetsize: ::size_t, + cpuset: *const cpu_set_t, + ) -> ::c_int; + pub fn epoll_create(size: ::c_int) -> ::c_int; + pub fn epoll_create1(flags: ::c_int) -> ::c_int; + pub fn epoll_wait( + epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: ::c_int, + ) -> ::c_int; + pub fn epoll_ctl( + epfd: ::c_int, + op: ::c_int, + fd: ::c_int, + event: *mut ::epoll_event, + ) -> ::c_int; + pub fn pthread_getschedparam( + native: ::pthread_t, + policy: *mut ::c_int, + param: *mut ::sched_param, + ) -> ::c_int; + pub fn unshare(flags: ::c_int) -> ::c_int; + pub fn umount(target: *const ::c_char) -> ::c_int; + pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; + pub fn tee( + fd_in: ::c_int, + fd_out: ::c_int, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn settimeofday( + tv: *const ::timeval, + tz: *const ::timezone, + ) -> ::c_int; + pub fn splice( + fd_in: ::c_int, + off_in: *mut ::loff_t, + fd_out: ::c_int, + off_out: *mut ::loff_t, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; + pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) + -> ::c_int; + pub fn sem_timedwait( + sem: *mut sem_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int; + pub fn sched_setparam( + pid: ::pid_t, + param: *const ::sched_param, + ) -> ::c_int; + pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; + pub fn swapoff(puath: *const ::c_char) -> ::c_int; + pub fn vmsplice( + fd: ::c_int, + iov: *const ::iovec, + nr_segs: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn mount( + src: *const ::c_char, + target: *const ::c_char, + fstype: *const ::c_char, + flags: ::c_ulong, + data: *const ::c_void, + ) -> ::c_int; + pub fn personality(persona: ::c_ulong) -> ::c_int; + pub fn prctl(option: ::c_int, ...) -> ::c_int; + pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int; + pub fn ppoll( + fds: *mut ::pollfd, + nfds: nfds_t, + timeout: *const ::timespec, + sigmask: *const sigset_t, + ) -> ::c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn clone( + cb: extern "C" fn(*mut ::c_void) -> ::c_int, + child_stack: *mut ::c_void, + flags: ::c_int, + arg: *mut ::c_void, + ... + ) -> ::c_int; + pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; + pub fn clock_nanosleep( + clk_id: ::clockid_t, + flags: ::c_int, + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + pub fn pthread_attr_getguardsize( + attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t, + ) -> ::c_int; + pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut ::c_int, + ) -> ::c_int; + pub fn sysinfo(info: *mut ::sysinfo) -> ::c_int; + pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; + pub fn pthread_setschedparam( + native: ::pthread_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + pub fn swapon(path: *const ::c_char, swapflags: ::c_int) -> ::c_int; + pub fn sched_setscheduler( + pid: ::pid_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + pub fn sendfile( + out_fd: ::c_int, + in_fd: ::c_int, + offset: *mut off_t, + count: ::size_t, + ) -> ::ssize_t; + pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigaltstack$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sem_close(sem: *mut sem_t) -> ::c_int; + pub fn getdtablesize() -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_sigmask$UNIX2003" + )] + pub fn pthread_sigmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const ::c_char) -> *mut ::group; + pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int; + pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; + pub fn sem_unlink(name: *const ::c_char) -> ::c_int; + pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigwait$UNIX2003" + )] + #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] + pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; + pub fn pthread_atfork( + prepare: ::Option, + parent: ::Option, + child: ::Option, + ) -> ::c_int; + pub fn getgrgid(gid: ::gid_t) -> *mut ::group; + pub fn getgrouplist( + user: *const ::c_char, + group: ::gid_t, + groups: *mut ::gid_t, + ngroups: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut ::c_int, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "popen$UNIX2003" + )] + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + pub fn faccessat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::c_int, + flags: ::c_int, + ) -> ::c_int; + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + pub fn dl_iterate_phdr( + callback: ::Option< + unsafe extern "C" fn( + info: *mut ::dl_phdr_info, + size: ::size_t, + data: *mut ::c_void, + ) -> ::c_int, + >, + data: *mut ::c_void, + ) -> ::c_int; + + pub fn setmntent( + filename: *const ::c_char, + ty: *const ::c_char, + ) -> *mut ::FILE; + pub fn getmntent(stream: *mut ::FILE) -> *mut ::mntent; + pub fn addmntent(stream: *mut ::FILE, mnt: *const ::mntent) -> ::c_int; + pub fn endmntent(streamp: *mut ::FILE) -> ::c_int; + pub fn hasmntopt( + mnt: *const ::mntent, + opt: *const ::c_char, + ) -> *mut ::c_char; + + pub fn posix_spawn( + pid: *mut ::pid_t, + path: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnp( + pid: *mut ::pid_t, + file: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getflags( + attr: *const posix_spawnattr_t, + flags: *mut ::c_short, + ) -> ::c_int; + pub fn posix_spawnattr_setflags( + attr: *mut posix_spawnattr_t, + flags: ::c_short, + ) -> ::c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut ::pid_t, + ) -> ::c_int; + pub fn posix_spawnattr_setpgroup( + attr: *mut posix_spawnattr_t, + flags: ::pid_t, + ) -> ::c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut ::c_int, + ) -> ::c_int; + pub fn posix_spawnattr_setschedpolicy( + attr: *mut posix_spawnattr_t, + flags: ::c_int, + ) -> ::c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut ::sched_param, + ) -> ::c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const ::sched_param, + ) -> ::c_int; + + pub fn posix_spawn_file_actions_init( + actions: *mut posix_spawn_file_actions_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_destroy( + actions: *mut posix_spawn_file_actions_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + path: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + ) -> ::c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + newfd: ::c_int, + ) -> ::c_int; + pub fn fread_unlocked( + ptr: *mut ::c_void, + size: ::size_t, + nobj: ::size_t, + stream: *mut ::FILE, + ) -> ::size_t; + pub fn inotify_rm_watch(fd: ::c_int, wd: ::c_int) -> ::c_int; + pub fn inotify_init() -> ::c_int; + pub fn inotify_init1(flags: ::c_int) -> ::c_int; + pub fn inotify_add_watch( + fd: ::c_int, + path: *const ::c_char, + mask: u32, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_env = "musl")] { + mod musl; + pub use self::musl::*; + } else if #[cfg(target_env = "gnu")] { + mod gnu; + pub use self::gnu::*; + } +} + +cfg_if! { + if #[cfg(libc_align)] { + #[macro_use] + mod align; + } else { + #[macro_use] + mod no_align; + } +} +expand_align!(); diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/arm/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/arm/align.rs new file mode 100644 index 0000000..aedbf7a --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/arm/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: (i64, i64) + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/arm/mod.rs new file mode 100644 index 0000000..ff23688 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -0,0 +1,845 @@ +pub type c_char = u8; +pub type wchar_t = u32; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + __st_dev_padding: ::c_int, + __st_ino_truncated: ::c_long, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_rdev_padding: ::c_int, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_ino: ::ino_t, + } + + pub struct stat64 { + pub st_dev: ::dev_t, + __st_dev_padding: ::c_int, + __st_ino_truncated: ::c_long, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_rdev_padding: ::c_int, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_ino: ::ino_t, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_int, + __unused1: ::c_long, + __unused2: ::c_long + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + __unused1: ::c_int, + pub shm_dtime: ::time_t, + __unused2: ::c_int, + pub shm_ctime: ::time_t, + __unused3: ::c_int, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::c_ulong, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + __unused1: ::c_int, + pub msg_rtime: ::time_t, + __unused2: ::c_int, + pub msg_ctime: ::time_t, + __unused3: ::c_int, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } +} + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_LARGEFILE: ::c_int = 0o400000; + +pub const FIOCLEX: ::c_int = 0x5451; +pub const FIONCLEX: ::c_int = 0x5450; +pub const FIONBIO: ::c_int = 0x5421; + +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_NLIMITS: ::c_int = 15; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; + +pub const SOCK_NONBLOCK: ::c_int = 2048; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_SEQPACKET: ::c_int = 5; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const EMULTIHOP: ::c_int = 72; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const EXTPROC: ::tcflag_t = 0x00010000; + +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const F_GETLK: ::c_int = 12; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 13; +pub const F_SETLKW: ::c_int = 14; +pub const F_SETOWN: ::c_int = 8; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; + +pub const TCGETS: ::c_int = 0x5401; +pub const TCSETS: ::c_int = 0x5402; +pub const TCSETSW: ::c_int = 0x5403; +pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETA: ::c_int = 0x5405; +pub const TCSETA: ::c_int = 0x5406; +pub const TCSETAW: ::c_int = 0x5407; +pub const TCSETAF: ::c_int = 0x5408; +pub const TCSBRK: ::c_int = 0x5409; +pub const TCXONC: ::c_int = 0x540A; +pub const TCFLSH: ::c_int = 0x540B; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x540F; +pub const TIOCSPGRP: ::c_int = 0x5410; +pub const TIOCOUTQ: ::c_int = 0x5411; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x5413; +pub const TIOCSWINSZ: ::c_int = 0x5414; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x541B; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +// Syscall table +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_pause: ::c_long = 29; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_poll: ::c_long = 168; +pub const SYS_nfsservctl: ::c_long = 169; +pub const SYS_setresgid: ::c_long = 170; +pub const SYS_getresgid: ::c_long = 171; +pub const SYS_prctl: ::c_long = 172; +pub const SYS_rt_sigreturn: ::c_long = 173; +pub const SYS_rt_sigaction: ::c_long = 174; +pub const SYS_rt_sigprocmask: ::c_long = 175; +pub const SYS_rt_sigpending: ::c_long = 176; +pub const SYS_rt_sigtimedwait: ::c_long = 177; +pub const SYS_rt_sigqueueinfo: ::c_long = 178; +pub const SYS_rt_sigsuspend: ::c_long = 179; +pub const SYS_pread64: ::c_long = 180; +pub const SYS_pwrite64: ::c_long = 181; +pub const SYS_chown: ::c_long = 182; +pub const SYS_getcwd: ::c_long = 183; +pub const SYS_capget: ::c_long = 184; +pub const SYS_capset: ::c_long = 185; +pub const SYS_sigaltstack: ::c_long = 186; +pub const SYS_sendfile: ::c_long = 187; +pub const SYS_vfork: ::c_long = 190; +pub const SYS_ugetrlimit: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_lchown32: ::c_long = 198; +pub const SYS_getuid32: ::c_long = 199; +pub const SYS_getgid32: ::c_long = 200; +pub const SYS_geteuid32: ::c_long = 201; +pub const SYS_getegid32: ::c_long = 202; +pub const SYS_setreuid32: ::c_long = 203; +pub const SYS_setregid32: ::c_long = 204; +pub const SYS_getgroups32: ::c_long = 205; +pub const SYS_setgroups32: ::c_long = 206; +pub const SYS_fchown32: ::c_long = 207; +pub const SYS_setresuid32: ::c_long = 208; +pub const SYS_getresuid32: ::c_long = 209; +pub const SYS_setresgid32: ::c_long = 210; +pub const SYS_getresgid32: ::c_long = 211; +pub const SYS_chown32: ::c_long = 212; +pub const SYS_setuid32: ::c_long = 213; +pub const SYS_setgid32: ::c_long = 214; +pub const SYS_setfsuid32: ::c_long = 215; +pub const SYS_setfsgid32: ::c_long = 216; +pub const SYS_getdents64: ::c_long = 217; +pub const SYS_pivot_root: ::c_long = 218; +pub const SYS_mincore: ::c_long = 219; +pub const SYS_madvise: ::c_long = 220; +pub const SYS_fcntl64: ::c_long = 221; +pub const SYS_gettid: ::c_long = 224; +pub const SYS_readahead: ::c_long = 225; +pub const SYS_setxattr: ::c_long = 226; +pub const SYS_lsetxattr: ::c_long = 227; +pub const SYS_fsetxattr: ::c_long = 228; +pub const SYS_getxattr: ::c_long = 229; +pub const SYS_lgetxattr: ::c_long = 230; +pub const SYS_fgetxattr: ::c_long = 231; +pub const SYS_listxattr: ::c_long = 232; +pub const SYS_llistxattr: ::c_long = 233; +pub const SYS_flistxattr: ::c_long = 234; +pub const SYS_removexattr: ::c_long = 235; +pub const SYS_lremovexattr: ::c_long = 236; +pub const SYS_fremovexattr: ::c_long = 237; +pub const SYS_tkill: ::c_long = 238; +pub const SYS_sendfile64: ::c_long = 239; +pub const SYS_futex: ::c_long = 240; +pub const SYS_sched_setaffinity: ::c_long = 241; +pub const SYS_sched_getaffinity: ::c_long = 242; +pub const SYS_io_setup: ::c_long = 243; +pub const SYS_io_destroy: ::c_long = 244; +pub const SYS_io_getevents: ::c_long = 245; +pub const SYS_io_submit: ::c_long = 246; +pub const SYS_io_cancel: ::c_long = 247; +pub const SYS_exit_group: ::c_long = 248; +pub const SYS_lookup_dcookie: ::c_long = 249; +pub const SYS_epoll_create: ::c_long = 250; +pub const SYS_epoll_ctl: ::c_long = 251; +pub const SYS_epoll_wait: ::c_long = 252; +pub const SYS_remap_file_pages: ::c_long = 253; +pub const SYS_set_tid_address: ::c_long = 256; +pub const SYS_timer_create: ::c_long = 257; +pub const SYS_timer_settime: ::c_long = 258; +pub const SYS_timer_gettime: ::c_long = 259; +pub const SYS_timer_getoverrun: ::c_long = 260; +pub const SYS_timer_delete: ::c_long = 261; +pub const SYS_clock_settime: ::c_long = 262; +pub const SYS_clock_gettime: ::c_long = 263; +pub const SYS_clock_getres: ::c_long = 264; +pub const SYS_clock_nanosleep: ::c_long = 265; +pub const SYS_statfs64: ::c_long = 266; +pub const SYS_fstatfs64: ::c_long = 267; +pub const SYS_tgkill: ::c_long = 268; +pub const SYS_utimes: ::c_long = 269; +pub const SYS_pciconfig_iobase: ::c_long = 271; +pub const SYS_pciconfig_read: ::c_long = 272; +pub const SYS_pciconfig_write: ::c_long = 273; +pub const SYS_mq_open: ::c_long = 274; +pub const SYS_mq_unlink: ::c_long = 275; +pub const SYS_mq_timedsend: ::c_long = 276; +pub const SYS_mq_timedreceive: ::c_long = 277; +pub const SYS_mq_notify: ::c_long = 278; +pub const SYS_mq_getsetattr: ::c_long = 279; +pub const SYS_waitid: ::c_long = 280; +pub const SYS_socket: ::c_long = 281; +pub const SYS_bind: ::c_long = 282; +pub const SYS_connect: ::c_long = 283; +pub const SYS_listen: ::c_long = 284; +pub const SYS_accept: ::c_long = 285; +pub const SYS_getsockname: ::c_long = 286; +pub const SYS_getpeername: ::c_long = 287; +pub const SYS_socketpair: ::c_long = 288; +pub const SYS_send: ::c_long = 289; +pub const SYS_sendto: ::c_long = 290; +pub const SYS_recv: ::c_long = 291; +pub const SYS_recvfrom: ::c_long = 292; +pub const SYS_shutdown: ::c_long = 293; +pub const SYS_setsockopt: ::c_long = 294; +pub const SYS_getsockopt: ::c_long = 295; +pub const SYS_sendmsg: ::c_long = 296; +pub const SYS_recvmsg: ::c_long = 297; +pub const SYS_semop: ::c_long = 298; +pub const SYS_semget: ::c_long = 299; +pub const SYS_semctl: ::c_long = 300; +pub const SYS_msgsnd: ::c_long = 301; +pub const SYS_msgrcv: ::c_long = 302; +pub const SYS_msgget: ::c_long = 303; +pub const SYS_msgctl: ::c_long = 304; +pub const SYS_shmat: ::c_long = 305; +pub const SYS_shmdt: ::c_long = 306; +pub const SYS_shmget: ::c_long = 307; +pub const SYS_shmctl: ::c_long = 308; +pub const SYS_add_key: ::c_long = 309; +pub const SYS_request_key: ::c_long = 310; +pub const SYS_keyctl: ::c_long = 311; +pub const SYS_semtimedop: ::c_long = 312; +pub const SYS_vserver: ::c_long = 313; +pub const SYS_ioprio_set: ::c_long = 314; +pub const SYS_ioprio_get: ::c_long = 315; +pub const SYS_inotify_init: ::c_long = 316; +pub const SYS_inotify_add_watch: ::c_long = 317; +pub const SYS_inotify_rm_watch: ::c_long = 318; +pub const SYS_mbind: ::c_long = 319; +pub const SYS_get_mempolicy: ::c_long = 320; +pub const SYS_set_mempolicy: ::c_long = 321; +pub const SYS_openat: ::c_long = 322; +pub const SYS_mkdirat: ::c_long = 323; +pub const SYS_mknodat: ::c_long = 324; +pub const SYS_fchownat: ::c_long = 325; +pub const SYS_futimesat: ::c_long = 326; +pub const SYS_fstatat64: ::c_long = 327; +pub const SYS_unlinkat: ::c_long = 328; +pub const SYS_renameat: ::c_long = 329; +pub const SYS_linkat: ::c_long = 330; +pub const SYS_symlinkat: ::c_long = 331; +pub const SYS_readlinkat: ::c_long = 332; +pub const SYS_fchmodat: ::c_long = 333; +pub const SYS_faccessat: ::c_long = 334; +pub const SYS_pselect6: ::c_long = 335; +pub const SYS_ppoll: ::c_long = 336; +pub const SYS_unshare: ::c_long = 337; +pub const SYS_set_robust_list: ::c_long = 338; +pub const SYS_get_robust_list: ::c_long = 339; +pub const SYS_splice: ::c_long = 340; +pub const SYS_tee: ::c_long = 342; +pub const SYS_vmsplice: ::c_long = 343; +pub const SYS_move_pages: ::c_long = 344; +pub const SYS_getcpu: ::c_long = 345; +pub const SYS_epoll_pwait: ::c_long = 346; +pub const SYS_kexec_load: ::c_long = 347; +pub const SYS_utimensat: ::c_long = 348; +pub const SYS_signalfd: ::c_long = 349; +pub const SYS_timerfd_create: ::c_long = 350; +pub const SYS_eventfd: ::c_long = 351; +pub const SYS_fallocate: ::c_long = 352; +pub const SYS_timerfd_settime: ::c_long = 353; +pub const SYS_timerfd_gettime: ::c_long = 354; +pub const SYS_signalfd4: ::c_long = 355; +pub const SYS_eventfd2: ::c_long = 356; +pub const SYS_epoll_create1: ::c_long = 357; +pub const SYS_dup3: ::c_long = 358; +pub const SYS_pipe2: ::c_long = 359; +pub const SYS_inotify_init1: ::c_long = 360; +pub const SYS_preadv: ::c_long = 361; +pub const SYS_pwritev: ::c_long = 362; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 363; +pub const SYS_perf_event_open: ::c_long = 364; +pub const SYS_recvmmsg: ::c_long = 365; +pub const SYS_accept4: ::c_long = 366; +pub const SYS_fanotify_init: ::c_long = 367; +pub const SYS_fanotify_mark: ::c_long = 368; +pub const SYS_prlimit64: ::c_long = 369; +pub const SYS_name_to_handle_at: ::c_long = 370; +pub const SYS_open_by_handle_at: ::c_long = 371; +pub const SYS_clock_adjtime: ::c_long = 372; +pub const SYS_syncfs: ::c_long = 373; +pub const SYS_sendmmsg: ::c_long = 374; +pub const SYS_setns: ::c_long = 375; +pub const SYS_process_vm_readv: ::c_long = 376; +pub const SYS_process_vm_writev: ::c_long = 377; +pub const SYS_kcmp: ::c_long = 378; +pub const SYS_finit_module: ::c_long = 379; +pub const SYS_sched_setattr: ::c_long = 380; +pub const SYS_sched_getattr: ::c_long = 381; +pub const SYS_renameat2: ::c_long = 382; +pub const SYS_seccomp: ::c_long = 383; +pub const SYS_getrandom: ::c_long = 384; +pub const SYS_memfd_create: ::c_long = 385; +pub const SYS_bpf: ::c_long = 386; +pub const SYS_execveat: ::c_long = 387; +pub const SYS_userfaultfd: ::c_long = 388; +pub const SYS_membarrier: ::c_long = 389; +pub const SYS_mlock2: ::c_long = 390; +pub const SYS_copy_file_range: ::c_long = 391; +pub const SYS_preadv2: ::c_long = 392; +pub const SYS_pwritev2: ::c_long = 393; +pub const SYS_pkey_mprotect: ::c_long = 394; +pub const SYS_pkey_alloc: ::c_long = 395; +pub const SYS_pkey_free: ::c_long = 396; +pub const SYS_statx: ::c_long = 397; + +extern "C" { + pub fn getrandom( + buf: *mut ::c_void, + buflen: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/hexagon.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/hexagon.rs new file mode 100644 index 0000000..2340695 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -0,0 +1,797 @@ +pub type c_char = u8; +pub type wchar_t = u32; +pub type stat64 = ::stat; + +s! { + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::c_ulonglong, + pub st_mode: ::c_uint, + pub st_nlink: ::c_uint, + pub st_uid: ::c_uint, + pub st_gid: ::c_uint, + pub st_rdev: ::c_ulonglong, + __st_rdev_padding: ::c_ulong, + pub st_size: ::c_longlong, + pub st_blksize: ::blksize_t, + __st_blksize_padding: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + + __unused: [::c_int;2], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_ushort, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + __unused1: ::c_int, + pub shm_dtime: ::time_t, + __unused2: ::c_int, + pub shm_ctime: ::time_t, + __unused3: ::c_int, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::c_ulong, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + __unused1: ::c_int, + pub msg_rtime: ::time_t, + __unused2: ::c_int, + pub msg_ctime: ::time_t, + __unused3: ::c_int, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + +pub const AF_FILE: ::c_int = 1; +pub const AF_KCM: ::c_int = 41; +pub const AF_MAX: ::c_int = 43; +pub const AF_QIPCRTR: ::c_int = 42; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EALREADY: ::c_int = 114; +pub const EBADE: ::c_int = 52; +pub const EBADMSG: ::c_int = 74; +pub const EBADR: ::c_int = 53; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const ECANCELED: ::c_int = 125; +pub const ECHRNG: ::c_int = 44; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNREFUSED: ::c_int = 111; +pub const ECONNRESET: ::c_int = 104; +pub const EDEADLK: ::c_int = 35; +pub const EDEADLOCK: ::c_int = 35; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EDQUOT: ::c_int = 122; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EHWPOISON: ::c_int = 133; +pub const EIDRM: ::c_int = 43; +pub const EILSEQ: ::c_int = 84; +pub const EINPROGRESS: ::c_int = 115; +pub const EISCONN: ::c_int = 106; +pub const EISNAM: ::c_int = 120; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREJECTED: ::c_int = 129; +pub const EKEYREVOKED: ::c_int = 128; +pub const EL2HLT: ::c_int = 51; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBEXEC: ::c_int = 83; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBSCN: ::c_int = 81; +pub const ELNRNG: ::c_int = 48; +pub const ELOOP: ::c_int = 40; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const EMSGSIZE: ::c_int = 90; +pub const EMULTIHOP: ::c_int = 72; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENAVAIL: ::c_int = 119; +pub const ENETDOWN: ::c_int = 100; +pub const ENETRESET: ::c_int = 102; +pub const ENETUNREACH: ::c_int = 101; +pub const ENOANO: ::c_int = 55; +pub const ENOBUFS: ::c_int = 105; +pub const ENOCSI: ::c_int = 50; +pub const ENOKEY: ::c_int = 126; +pub const ENOLCK: ::c_int = 37; +pub const ENOMEDIUM: ::c_int = 123; +pub const ENOMSG: ::c_int = 42; +pub const ENOPROTOOPT: ::c_int = 92; +pub const ENOSYS: ::c_int = 38; +pub const ENOTCONN: ::c_int = 107; +pub const ENOTEMPTY: ::c_int = 39; +pub const ENOTNAM: ::c_int = 118; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ENOTSOCK: ::c_int = 88; +pub const ENOTSUP: ::c_int = 95; +pub const ENOTUNIQ: ::c_int = 76; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EOVERFLOW: ::c_int = 75; +pub const EOWNERDEAD: ::c_int = 130; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EREMCHG: ::c_int = 78; +pub const ERESTART: ::c_int = 85; +pub const ERFKILL: ::c_int = 132; +pub const ESHUTDOWN: ::c_int = 108; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const ESTALE: ::c_int = 116; +pub const ESTRPIPE: ::c_int = 86; +pub const ETOOMANYREFS: ::c_int = 109; +pub const EUCLEAN: ::c_int = 117; +pub const EUNATCH: ::c_int = 49; +pub const EUSERS: ::c_int = 87; +pub const EXFULL: ::c_int = 54; +pub const EXTPROC: ::c_int = 65536; +pub const F_EXLCK: ::c_int = 4; +pub const F_GETLK: ::c_int = 12; +pub const F_GETOWN: ::c_int = 9; +pub const F_GETOWNER_UIDS: ::c_int = 17; +pub const F_GETOWN_EX: ::c_int = 16; +pub const F_GETSIG: ::c_int = 11; +pub const FIOASYNC: ::c_int = 21586; +pub const FIOCLEX: ::c_int = 21585; +pub const FIONBIO: ::c_int = 21537; +pub const FIONCLEX: ::c_int = 21584; +pub const FIONREAD: ::c_int = 21531; +pub const FIOQSIZE: ::c_int = 21600; +pub const F_LINUX_SPECIFIC_BASE: ::c_int = 1024; +pub const FLUSHO: ::c_int = 4096; +pub const F_OFD_GETLK: ::c_int = 36; +pub const F_OFD_SETLK: ::c_int = 37; +pub const F_OFD_SETLKW: ::c_int = 38; +pub const F_OWNER_PGRP: ::c_int = 2; +pub const F_OWNER_PID: ::c_int = 1; +pub const F_OWNER_TID: ::c_int = 0; +pub const F_SETLK: ::c_int = 13; +pub const F_SETLKW: ::c_int = 14; +pub const F_SETOWN: ::c_int = 8; +pub const F_SETOWN_EX: ::c_int = 15; +pub const F_SETSIG: ::c_int = 10; +pub const F_SHLCK: ::c_int = 8; +pub const IEXTEN: ::c_int = 32768; +pub const MAP_ANON: ::c_int = 32; +pub const MAP_DENYWRITE: ::c_int = 2048; +pub const MAP_EXECUTABLE: ::c_int = 4096; +pub const MAP_GROWSDOWN: ::c_int = 256; +pub const MAP_HUGE_MASK: ::c_int = 63; +pub const MAP_HUGE_SHIFT: ::c_int = 26; +pub const MAP_HUGETLB: ::c_int = 262144; +pub const MAP_LOCKED: ::c_int = 8192; +pub const MAP_NONBLOCK: ::c_int = 65536; +pub const MAP_NORESERVE: ::c_int = 16384; +pub const MAP_POPULATE: ::c_int = 32768; +pub const MAP_STACK: ::c_int = 131072; +pub const MAP_UNINITIALIZED: ::c_int = 0; +pub const O_APPEND: ::c_int = 1024; +pub const O_ASYNC: ::c_int = 8192; +pub const O_CREAT: ::c_int = 64; +pub const O_DIRECT: ::c_int = 16384; +pub const O_DIRECTORY: ::c_int = 65536; +pub const O_DSYNC: ::c_int = 4096; +pub const O_EXCL: ::c_int = 128; +pub const O_LARGEFILE: ::c_int = 32768; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NOFOLLOW: ::c_int = 131072; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const PF_FILE: ::c_int = 1; +pub const PF_KCM: ::c_int = 41; +pub const PF_MAX: ::c_int = 43; +pub const PF_QIPCRTR: ::c_int = 42; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_RSS: ::c_int = 5; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: ::c_int = 16; +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; +pub const SIGBUS: ::c_int = 7; +pub const SIGCHLD: ::c_int = 17; +pub const SIGCONT: ::c_int = 18; +pub const SIGIO: ::c_int = 29; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPROF: ::c_int = 27; +pub const SIGPWR: ::c_int = 30; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGSTOP: ::c_int = 19; +pub const SIGSYS: ::c_int = 31; +pub const SIGTSTP: ::c_int = 20; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGURG: ::c_int = 23; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGWINCH: ::c_int = 28; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIG_SETMASK: ::c_int = 2; // FIXME check these +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_ATTACH_BPF: ::c_int = 50; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_ATTACH_REUSEPORT_CBPF: ::c_int = 51; +pub const SO_ATTACH_REUSEPORT_EBPF: ::c_int = 52; +pub const SO_BPF_EXTENSIONS: ::c_int = 48; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_NONBLOCK: ::c_int = 2048; +pub const SOCK_SEQPACKET: ::c_int = 5; +pub const SOCK_STREAM: ::c_int = 1; +pub const SO_CNX_ADVICE: ::c_int = 53; +pub const SO_DETACH_BPF: ::c_int = 27; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_ERROR: ::c_int = 4; +pub const SO_GET_FILTER: ::c_int = 26; +pub const SO_INCOMING_CPU: ::c_int = 49; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SOL_CAIF: ::c_int = 278; +pub const SO_LINGER: ::c_int = 13; +pub const SOL_IUCV: ::c_int = 277; +pub const SOL_KCM: ::c_int = 281; +pub const SOL_NFC: ::c_int = 280; +pub const SO_LOCK_FILTER: ::c_int = 44; +pub const SOL_PNPIPE: ::c_int = 275; +pub const SOL_PPPOL2TP: ::c_int = 273; +pub const SOL_RDS: ::c_int = 276; +pub const SOL_RXRPC: ::c_int = 272; +pub const SOL_SOCKET: ::c_int = 1; +pub const SO_MAX_PACING_RATE: ::c_int = 47; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_NOFCS: ::c_int = 43; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PASSSEC: ::c_int = 34; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_PEERNAME: ::c_int = 28; +pub const SO_PEERSEC: ::c_int = 31; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; +pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; +pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_TYPE: ::c_int = 3; +pub const SO_WIFI_STATUS: ::c_int = 41; +pub const SYS3264_fadvise64: ::c_int = 223; +pub const SYS3264_fcntl: ::c_int = 25; +pub const SYS3264_fstatat: ::c_int = 79; +pub const SYS3264_fstat: ::c_int = 80; +pub const SYS3264_fstatfs: ::c_int = 44; +pub const SYS3264_ftruncate: ::c_int = 46; +pub const SYS3264_lseek: ::c_int = 62; +pub const SYS3264_lstat: ::c_int = 1039; +pub const SYS3264_mmap: ::c_int = 222; +pub const SYS3264_sendfile: ::c_int = 71; +pub const SYS3264_stat: ::c_int = 1038; +pub const SYS3264_statfs: ::c_int = 43; +pub const SYS3264_truncate: ::c_int = 45; +pub const SYS_accept4: ::c_int = 242; +pub const SYS_accept: ::c_int = 202; +pub const SYS_access: ::c_int = 1033; +pub const SYS_acct: ::c_int = 89; +pub const SYS_add_key: ::c_int = 217; +pub const SYS_adjtimex: ::c_int = 171; +pub const SYS_alarm: ::c_int = 1059; +pub const SYS_arch_specific_syscall: ::c_int = 244; +pub const SYS_bdflush: ::c_int = 1075; +pub const SYS_bind: ::c_int = 200; +pub const SYS_bpf: ::c_int = 280; +pub const SYS_brk: ::c_int = 214; +pub const SYS_capget: ::c_int = 90; +pub const SYS_capset: ::c_int = 91; +pub const SYS_chdir: ::c_int = 49; +pub const SYS_chmod: ::c_int = 1028; +pub const SYS_chown: ::c_int = 1029; +pub const SYS_chroot: ::c_int = 51; +pub const SYS_clock_adjtime: ::c_int = 266; +pub const SYS_clock_getres: ::c_int = 114; +pub const SYS_clock_gettime: ::c_int = 113; +pub const SYS_clock_nanosleep: ::c_int = 115; +pub const SYS_clock_settime: ::c_int = 112; +pub const SYS_clone: ::c_int = 220; +pub const SYS_close: ::c_int = 57; +pub const SYS_connect: ::c_int = 203; +pub const SYS_copy_file_range: ::c_int = -1; // FIXME +pub const SYS_creat: ::c_int = 1064; +pub const SYS_delete_module: ::c_int = 106; +pub const SYS_dup2: ::c_int = 1041; +pub const SYS_dup3: ::c_int = 24; +pub const SYS_dup: ::c_int = 23; +pub const SYS_epoll_create1: ::c_int = 20; +pub const SYS_epoll_create: ::c_int = 1042; +pub const SYS_epoll_ctl: ::c_int = 21; +pub const SYS_epoll_pwait: ::c_int = 22; +pub const SYS_epoll_wait: ::c_int = 1069; +pub const SYS_eventfd2: ::c_int = 19; +pub const SYS_eventfd: ::c_int = 1044; +pub const SYS_execveat: ::c_int = 281; +pub const SYS_execve: ::c_int = 221; +pub const SYS_exit: ::c_int = 93; +pub const SYS_exit_group: ::c_int = 94; +pub const SYS_faccessat: ::c_int = 48; +pub const SYS_fadvise64_64: ::c_int = 223; +pub const SYS_fallocate: ::c_int = 47; +pub const SYS_fanotify_init: ::c_int = 262; +pub const SYS_fanotify_mark: ::c_int = 263; +pub const SYS_fchdir: ::c_int = 50; +pub const SYS_fchmodat: ::c_int = 53; +pub const SYS_fchmod: ::c_int = 52; +pub const SYS_fchownat: ::c_int = 54; +pub const SYS_fchown: ::c_int = 55; +pub const SYS_fcntl64: ::c_int = 25; +pub const SYS_fcntl: ::c_int = 25; +pub const SYS_fdatasync: ::c_int = 83; +pub const SYS_fgetxattr: ::c_int = 10; +pub const SYS_finit_module: ::c_int = 273; +pub const SYS_flistxattr: ::c_int = 13; +pub const SYS_flock: ::c_int = 32; +pub const SYS_fork: ::c_int = 1079; +pub const SYS_fremovexattr: ::c_int = 16; +pub const SYS_fsetxattr: ::c_int = 7; +pub const SYS_fstat64: ::c_int = 80; +pub const SYS_fstatat64: ::c_int = 79; +pub const SYS_fstatfs64: ::c_int = 44; +pub const SYS_fstatfs: ::c_int = 44; +pub const SYS_fsync: ::c_int = 82; +pub const SYS_ftruncate64: ::c_int = 46; +pub const SYS_ftruncate: ::c_int = 46; +pub const SYS_futex: ::c_int = 98; +pub const SYS_futimesat: ::c_int = 1066; +pub const SYS_getcpu: ::c_int = 168; +pub const SYS_getcwd: ::c_int = 17; +pub const SYS_getdents64: ::c_int = 61; +pub const SYS_getdents: ::c_int = 1065; +pub const SYS_getegid: ::c_int = 177; +pub const SYS_geteuid: ::c_int = 175; +pub const SYS_getgid: ::c_int = 176; +pub const SYS_getgroups: ::c_int = 158; +pub const SYS_getitimer: ::c_int = 102; +pub const SYS_get_mempolicy: ::c_int = 236; +pub const SYS_getpeername: ::c_int = 205; +pub const SYS_getpgid: ::c_int = 155; +pub const SYS_getpgrp: ::c_int = 1060; +pub const SYS_getpid: ::c_int = 172; +pub const SYS_getppid: ::c_int = 173; +pub const SYS_getpriority: ::c_int = 141; +pub const SYS_getrandom: ::c_int = 278; +pub const SYS_getresgid: ::c_int = 150; +pub const SYS_getresuid: ::c_int = 148; +pub const SYS_getrlimit: ::c_int = 163; +pub const SYS_get_robust_list: ::c_int = 100; +pub const SYS_getrusage: ::c_int = 165; +pub const SYS_getsid: ::c_int = 156; +pub const SYS_getsockname: ::c_int = 204; +pub const SYS_getsockopt: ::c_int = 209; +pub const SYS_gettid: ::c_int = 178; +pub const SYS_gettimeofday: ::c_int = 169; +pub const SYS_getuid: ::c_int = 174; +pub const SYS_getxattr: ::c_int = 8; +pub const SYS_init_module: ::c_int = 105; +pub const SYS_inotify_add_watch: ::c_int = 27; +pub const SYS_inotify_init1: ::c_int = 26; +pub const SYS_inotify_init: ::c_int = 1043; +pub const SYS_inotify_rm_watch: ::c_int = 28; +pub const SYS_io_cancel: ::c_int = 3; +pub const SYS_ioctl: ::c_int = 29; +pub const SYS_io_destroy: ::c_int = 1; +pub const SYS_io_getevents: ::c_int = 4; +pub const SYS_ioprio_get: ::c_int = 31; +pub const SYS_ioprio_set: ::c_int = 30; +pub const SYS_io_setup: ::c_int = 0; +pub const SYS_io_submit: ::c_int = 2; +pub const SYS_kcmp: ::c_int = 272; +pub const SYS_kexec_load: ::c_int = 104; +pub const SYS_keyctl: ::c_int = 219; +pub const SYS_kill: ::c_int = 129; +pub const SYS_lchown: ::c_int = 1032; +pub const SYS_lgetxattr: ::c_int = 9; +pub const SYS_linkat: ::c_int = 37; +pub const SYS_link: ::c_int = 1025; +pub const SYS_listen: ::c_int = 201; +pub const SYS_listxattr: ::c_int = 11; +pub const SYS_llistxattr: ::c_int = 12; +pub const SYS__llseek: ::c_int = 62; +pub const SYS_lookup_dcookie: ::c_int = 18; +pub const SYS_lremovexattr: ::c_int = 15; +pub const SYS_lseek: ::c_int = 62; +pub const SYS_lsetxattr: ::c_int = 6; +pub const SYS_lstat64: ::c_int = 1039; +pub const SYS_lstat: ::c_int = 1039; +pub const SYS_madvise: ::c_int = 233; +pub const SYS_mbind: ::c_int = 235; +pub const SYS_memfd_create: ::c_int = 279; +pub const SYS_migrate_pages: ::c_int = 238; +pub const SYS_mincore: ::c_int = 232; +pub const SYS_mkdirat: ::c_int = 34; +pub const SYS_mkdir: ::c_int = 1030; +pub const SYS_mknodat: ::c_int = 33; +pub const SYS_mknod: ::c_int = 1027; +pub const SYS_mlockall: ::c_int = 230; +pub const SYS_mlock: ::c_int = 228; +pub const SYS_mmap2: ::c_int = 222; +pub const SYS_mount: ::c_int = 40; +pub const SYS_move_pages: ::c_int = 239; +pub const SYS_mprotect: ::c_int = 226; +pub const SYS_mq_getsetattr: ::c_int = 185; +pub const SYS_mq_notify: ::c_int = 184; +pub const SYS_mq_open: ::c_int = 180; +pub const SYS_mq_timedreceive: ::c_int = 183; +pub const SYS_mq_timedsend: ::c_int = 182; +pub const SYS_mq_unlink: ::c_int = 181; +pub const SYS_mremap: ::c_int = 216; +pub const SYS_msgctl: ::c_int = 187; +pub const SYS_msgget: ::c_int = 186; +pub const SYS_msgrcv: ::c_int = 188; +pub const SYS_msgsnd: ::c_int = 189; +pub const SYS_msync: ::c_int = 227; +pub const SYS_munlockall: ::c_int = 231; +pub const SYS_munlock: ::c_int = 229; +pub const SYS_munmap: ::c_int = 215; +pub const SYS_name_to_handle_at: ::c_int = 264; +pub const SYS_nanosleep: ::c_int = 101; +pub const SYS_newfstatat: ::c_int = 79; +pub const SYS_nfsservctl: ::c_int = 42; +pub const SYS_oldwait4: ::c_int = 1072; +pub const SYS_openat: ::c_int = 56; +pub const SYS_open_by_handle_at: ::c_int = 265; +pub const SYS_open: ::c_int = 1024; +pub const SYS_pause: ::c_int = 1061; +pub const SYS_perf_event_open: ::c_int = 241; +pub const SYS_personality: ::c_int = 92; +pub const SYS_pipe2: ::c_int = 59; +pub const SYS_pipe: ::c_int = 1040; +pub const SYS_pivot_root: ::c_int = 41; +pub const SYS_poll: ::c_int = 1068; +pub const SYS_ppoll: ::c_int = 73; +pub const SYS_prctl: ::c_int = 167; +pub const SYS_pread64: ::c_int = 67; +pub const SYS_preadv: ::c_int = 69; +pub const SYS_prlimit64: ::c_int = 261; +pub const SYS_process_vm_readv: ::c_int = 270; +pub const SYS_process_vm_writev: ::c_int = 271; +pub const SYS_pselect6: ::c_int = 72; +pub const SYS_ptrace: ::c_int = 117; +pub const SYS_pwrite64: ::c_int = 68; +pub const SYS_pwritev: ::c_int = 70; +pub const SYS_quotactl: ::c_int = 60; +pub const SYS_readahead: ::c_int = 213; +pub const SYS_read: ::c_int = 63; +pub const SYS_readlinkat: ::c_int = 78; +pub const SYS_readlink: ::c_int = 1035; +pub const SYS_readv: ::c_int = 65; +pub const SYS_reboot: ::c_int = 142; +pub const SYS_recv: ::c_int = 1073; +pub const SYS_recvfrom: ::c_int = 207; +pub const SYS_recvmmsg: ::c_int = 243; +pub const SYS_recvmsg: ::c_int = 212; +pub const SYS_remap_file_pages: ::c_int = 234; +pub const SYS_removexattr: ::c_int = 14; +pub const SYS_renameat2: ::c_int = 276; +pub const SYS_renameat: ::c_int = 38; +pub const SYS_rename: ::c_int = 1034; +pub const SYS_request_key: ::c_int = 218; +pub const SYS_restart_syscall: ::c_int = 128; +pub const SYS_rmdir: ::c_int = 1031; +pub const SYS_rt_sigaction: ::c_int = 134; +pub const SYS_rt_sigpending: ::c_int = 136; +pub const SYS_rt_sigprocmask: ::c_int = 135; +pub const SYS_rt_sigqueueinfo: ::c_int = 138; +pub const SYS_rt_sigreturn: ::c_int = 139; +pub const SYS_rt_sigsuspend: ::c_int = 133; +pub const SYS_rt_sigtimedwait: ::c_int = 137; +pub const SYS_rt_tgsigqueueinfo: ::c_int = 240; +pub const SYS_sched_getaffinity: ::c_int = 123; +pub const SYS_sched_getattr: ::c_int = 275; +pub const SYS_sched_getparam: ::c_int = 121; +pub const SYS_sched_get_priority_max: ::c_int = 125; +pub const SYS_sched_get_priority_min: ::c_int = 126; +pub const SYS_sched_getscheduler: ::c_int = 120; +pub const SYS_sched_rr_get_interval: ::c_int = 127; +pub const SYS_sched_setaffinity: ::c_int = 122; +pub const SYS_sched_setattr: ::c_int = 274; +pub const SYS_sched_setparam: ::c_int = 118; +pub const SYS_sched_setscheduler: ::c_int = 119; +pub const SYS_sched_yield: ::c_int = 124; +pub const SYS_seccomp: ::c_int = 277; +pub const SYS_select: ::c_int = 1067; +pub const SYS_semctl: ::c_int = 191; +pub const SYS_semget: ::c_int = 190; +pub const SYS_semop: ::c_int = 193; +pub const SYS_semtimedop: ::c_int = 192; +pub const SYS_send: ::c_int = 1074; +pub const SYS_sendfile64: ::c_int = 71; +pub const SYS_sendfile: ::c_int = 71; +pub const SYS_sendmmsg: ::c_int = 269; +pub const SYS_sendmsg: ::c_int = 211; +pub const SYS_sendto: ::c_int = 206; +pub const SYS_setdomainname: ::c_int = 162; +pub const SYS_setfsgid: ::c_int = 152; +pub const SYS_setfsuid: ::c_int = 151; +pub const SYS_setgid: ::c_int = 144; +pub const SYS_setgroups: ::c_int = 159; +pub const SYS_sethostname: ::c_int = 161; +pub const SYS_setitimer: ::c_int = 103; +pub const SYS_set_mempolicy: ::c_int = 237; +pub const SYS_setns: ::c_int = 268; +pub const SYS_setpgid: ::c_int = 154; +pub const SYS_setpriority: ::c_int = 140; +pub const SYS_setregid: ::c_int = 143; +pub const SYS_setresgid: ::c_int = 149; +pub const SYS_setresuid: ::c_int = 147; +pub const SYS_setreuid: ::c_int = 145; +pub const SYS_setrlimit: ::c_int = 164; +pub const SYS_set_robust_list: ::c_int = 99; +pub const SYS_setsid: ::c_int = 157; +pub const SYS_setsockopt: ::c_int = 208; +pub const SYS_set_tid_address: ::c_int = 96; +pub const SYS_settimeofday: ::c_int = 170; +pub const SYS_setuid: ::c_int = 146; +pub const SYS_setxattr: ::c_int = 5; +pub const SYS_shmat: ::c_int = 196; +pub const SYS_shmctl: ::c_int = 195; +pub const SYS_shmdt: ::c_int = 197; +pub const SYS_shmget: ::c_int = 194; +pub const SYS_shutdown: ::c_int = 210; +pub const SYS_sigaltstack: ::c_int = 132; +pub const SYS_signalfd4: ::c_int = 74; +pub const SYS_signalfd: ::c_int = 1045; +pub const SYS_socket: ::c_int = 198; +pub const SYS_socketpair: ::c_int = 199; +pub const SYS_splice: ::c_int = 76; +pub const SYS_stat64: ::c_int = 1038; +pub const SYS_stat: ::c_int = 1038; +pub const SYS_statfs64: ::c_int = 43; +pub const SYS_swapoff: ::c_int = 225; +pub const SYS_swapon: ::c_int = 224; +pub const SYS_symlinkat: ::c_int = 36; +pub const SYS_symlink: ::c_int = 1036; +pub const SYS_sync: ::c_int = 81; +pub const SYS_sync_file_range2: ::c_int = 84; +pub const SYS_sync_file_range: ::c_int = 84; +pub const SYS_syncfs: ::c_int = 267; +pub const SYS_syscalls: ::c_int = 1080; +pub const SYS__sysctl: ::c_int = 1078; +pub const SYS_sysinfo: ::c_int = 179; +pub const SYS_syslog: ::c_int = 116; +pub const SYS_tee: ::c_int = 77; +pub const SYS_tgkill: ::c_int = 131; +pub const SYS_time: ::c_int = 1062; +pub const SYS_timer_create: ::c_int = 107; +pub const SYS_timer_delete: ::c_int = 111; +pub const SYS_timerfd_create: ::c_int = 85; +pub const SYS_timerfd_gettime: ::c_int = 87; +pub const SYS_timerfd_settime: ::c_int = 86; +pub const SYS_timer_getoverrun: ::c_int = 109; +pub const SYS_timer_gettime: ::c_int = 108; +pub const SYS_timer_settime: ::c_int = 110; +pub const SYS_times: ::c_int = 153; +pub const SYS_tkill: ::c_int = 130; +pub const SYS_truncate64: ::c_int = 45; +pub const SYS_truncate: ::c_int = 45; +pub const SYS_umask: ::c_int = 166; +pub const SYS_umount2: ::c_int = 39; +pub const SYS_umount: ::c_int = 1076; +pub const SYS_uname: ::c_int = 160; +pub const SYS_unlinkat: ::c_int = 35; +pub const SYS_unlink: ::c_int = 1026; +pub const SYS_unshare: ::c_int = 97; +pub const SYS_uselib: ::c_int = 1077; +pub const SYS_ustat: ::c_int = 1070; +pub const SYS_utime: ::c_int = 1063; +pub const SYS_utimensat: ::c_int = 88; +pub const SYS_utimes: ::c_int = 1037; +pub const SYS_vfork: ::c_int = 1071; +pub const SYS_vhangup: ::c_int = 58; +pub const SYS_vmsplice: ::c_int = 75; +pub const SYS_wait4: ::c_int = 260; +pub const SYS_waitid: ::c_int = 95; +pub const SYS_write: ::c_int = 64; +pub const SYS_writev: ::c_int = 66; +pub const SYS_statx: ::c_int = 291; +pub const TCFLSH: ::c_int = 21515; +pub const TCGETA: ::c_int = 21509; +pub const TCGETS: ::c_int = 21505; +pub const TCGETX: ::c_int = 21554; +pub const TCSBRK: ::c_int = 21513; +pub const TCSBRKP: ::c_int = 21541; +pub const TCSETA: ::c_int = 21510; +pub const TCSETAF: ::c_int = 21512; +pub const TCSETAW: ::c_int = 21511; +pub const TCSETS: ::c_int = 21506; +pub const TCSETSF: ::c_int = 21508; +pub const TCSETSW: ::c_int = 21507; +pub const TCSETX: ::c_int = 21555; +pub const TCSETXF: ::c_int = 21556; +pub const TCSETXW: ::c_int = 21557; +pub const TCXONC: ::c_int = 21514; +pub const TIOCCBRK: ::c_int = 21544; +pub const TIOCCONS: ::c_int = 21533; +pub const TIOCEXCL: ::c_int = 21516; +pub const TIOCGETD: ::c_int = 21540; +pub const TIOCGICOUNT: ::c_int = 21597; +pub const TIOCGLCKTRMIOS: ::c_int = 21590; +pub const TIOCGPGRP: ::c_int = 21519; +pub const TIOCGRS485: ::c_int = 21550; +pub const TIOCGSERIAL: ::c_int = 21534; +pub const TIOCGSID: ::c_int = 21545; +pub const TIOCGSOFTCAR: ::c_int = 21529; +pub const TIOCGWINSZ: ::c_int = 21523; +pub const TIOCLINUX: ::c_int = 21532; +pub const TIOCMBIC: ::c_int = 21527; +pub const TIOCMBIS: ::c_int = 21526; +pub const TIOCM_CAR: ::c_int = 64; +pub const TIOCM_CD: ::c_int = 64; +pub const TIOCM_CTS: ::c_int = 32; +pub const TIOCM_DSR: ::c_int = 256; +pub const TIOCM_DTR: ::c_int = 2; +pub const TIOCMGET: ::c_int = 21525; +pub const TIOCMIWAIT: ::c_int = 21596; +pub const TIOCM_LE: ::c_int = 1; +pub const TIOCM_LOOP: ::c_int = 32768; +pub const TIOCM_OUT1: ::c_int = 8192; +pub const TIOCM_OUT2: ::c_int = 16384; +pub const TIOCM_RI: ::c_int = 128; +pub const TIOCM_RNG: ::c_int = 128; +pub const TIOCM_RTS: ::c_int = 4; +pub const TIOCMSET: ::c_int = 21528; +pub const TIOCM_SR: ::c_int = 16; +pub const TIOCM_ST: ::c_int = 8; +pub const TIOCNOTTY: ::c_int = 21538; +pub const TIOCNXCL: ::c_int = 21517; +pub const TIOCOUTQ: ::c_int = 21521; +pub const TIOCPKT: ::c_int = 21536; +pub const TIOCPKT_DATA: ::c_int = 0; +pub const TIOCPKT_DOSTOP: ::c_int = 32; +pub const TIOCPKT_FLUSHREAD: ::c_int = 1; +pub const TIOCPKT_FLUSHWRITE: ::c_int = 2; +pub const TIOCPKT_IOCTL: ::c_int = 64; +pub const TIOCPKT_NOSTOP: ::c_int = 16; +pub const TIOCPKT_START: ::c_int = 8; +pub const TIOCPKT_STOP: ::c_int = 4; +pub const TIOCSBRK: ::c_int = 21543; +pub const TIOCSCTTY: ::c_int = 21518; +pub const TIOCSERCONFIG: ::c_int = 21587; +pub const TIOCSERGETLSR: ::c_int = 21593; +pub const TIOCSERGETMULTI: ::c_int = 21594; +pub const TIOCSERGSTRUCT: ::c_int = 21592; +pub const TIOCSERGWILD: ::c_int = 21588; +pub const TIOCSERSETMULTI: ::c_int = 21595; +pub const TIOCSERSWILD: ::c_int = 21589; +pub const TIOCSER_TEMT: ::c_int = 1; +pub const TIOCSETD: ::c_int = 21539; +pub const TIOCSLCKTRMIOS: ::c_int = 21591; +pub const TIOCSPGRP: ::c_int = 21520; +pub const TIOCSRS485: ::c_int = 21551; +pub const TIOCSSERIAL: ::c_int = 21535; +pub const TIOCSSOFTCAR: ::c_int = 21530; +pub const TIOCSTI: ::c_int = 21522; +pub const TIOCSWINSZ: ::c_int = 21524; +pub const TIOCVHANGUP: ::c_int = 21559; +pub const TOSTOP: ::c_int = 256; +pub const VEOF: ::c_int = 4; +pub const VEOL2: ::c_int = 16; +pub const VEOL: ::c_int = 11; +pub const VMIN: ::c_int = 6; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/mips/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/mips/align.rs new file mode 100644 index 0000000..8c228eb --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/mips/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f32; 4] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/mips/mod.rs new file mode 100644 index 0000000..be11341 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -0,0 +1,849 @@ +pub type c_char = i8; +pub type wchar_t = ::c_int; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + __st_padding1: [::c_long; 2], + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_padding2: [::c_long; 2], + pub st_size: ::off_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + __st_padding3: ::c_long, + pub st_blocks: ::blkcnt_t, + __st_padding4: [::c_long; 14], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + __st_padding1: [::c_long; 2], + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_padding2: [::c_long; 2], + pub st_size: ::off_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + __st_padding3: ::c_long, + pub st_blocks: ::blkcnt64_t, + __st_padding4: [::c_long; 14], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_int, + __unused1: ::c_long, + __unused2: ::c_long + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::c_ulong, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + #[cfg(target_endian = "big")] + __unused1: ::c_int, + pub msg_stime: ::time_t, + #[cfg(target_endian = "little")] + __unused1: ::c_int, + #[cfg(target_endian = "big")] + __unused2: ::c_int, + pub msg_rtime: ::time_t, + #[cfg(target_endian = "little")] + __unused2: ::c_int, + #[cfg(target_endian = "big")] + __unused3: ::c_int, + pub msg_ctime: ::time_t, + #[cfg(target_endian = "little")] + __unused3: ::c_int, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 5], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 5], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + #[cfg(target_endian = "little")] + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + #[cfg(target_endian = "big")] + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } +} + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + +pub const O_DIRECT: ::c_int = 0o100000; +pub const O_DIRECTORY: ::c_int = 0o200000; +pub const O_NOFOLLOW: ::c_int = 0o400000; +pub const O_ASYNC: ::c_int = 0o10000; +pub const O_LARGEFILE: ::c_int = 0x2000; + +pub const FIOCLEX: ::c_int = 0x6601; +pub const FIONCLEX: ::c_int = 0x6602; +pub const FIONBIO: ::c_int = 0x667E; + +pub const RLIMIT_RSS: ::c_int = 7; +pub const RLIMIT_NOFILE: ::c_int = 5; +pub const RLIMIT_AS: ::c_int = 6; +pub const RLIMIT_NPROC: ::c_int = 8; +pub const RLIMIT_MEMLOCK: ::c_int = 9; +pub const RLIMIT_NLIMITS: ::c_int = 15; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const O_APPEND: ::c_int = 0o010; +pub const O_CREAT: ::c_int = 0o400; +pub const O_EXCL: ::c_int = 0o2000; +pub const O_NOCTTY: ::c_int = 0o4000; +pub const O_NONBLOCK: ::c_int = 0o200; +pub const O_SYNC: ::c_int = 0o40020; +pub const O_RSYNC: ::c_int = 0o40020; +pub const O_DSYNC: ::c_int = 0o020; + +pub const SOCK_NONBLOCK: ::c_int = 0o200; + +pub const MAP_ANON: ::c_int = 0x800; +pub const MAP_GROWSDOWN: ::c_int = 0x1000; +pub const MAP_DENYWRITE: ::c_int = 0x2000; +pub const MAP_EXECUTABLE: ::c_int = 0x4000; +pub const MAP_LOCKED: ::c_int = 0x8000; +pub const MAP_NORESERVE: ::c_int = 0x0400; +pub const MAP_POPULATE: ::c_int = 0x10000; +pub const MAP_NONBLOCK: ::c_int = 0x20000; +pub const MAP_STACK: ::c_int = 0x40000; + +pub const EDEADLK: ::c_int = 45; +pub const ENAMETOOLONG: ::c_int = 78; +pub const ENOLCK: ::c_int = 46; +pub const ENOSYS: ::c_int = 89; +pub const ENOTEMPTY: ::c_int = 93; +pub const ELOOP: ::c_int = 90; +pub const ENOMSG: ::c_int = 35; +pub const EIDRM: ::c_int = 36; +pub const ECHRNG: ::c_int = 37; +pub const EL2NSYNC: ::c_int = 38; +pub const EL3HLT: ::c_int = 39; +pub const EL3RST: ::c_int = 40; +pub const ELNRNG: ::c_int = 41; +pub const EUNATCH: ::c_int = 42; +pub const ENOCSI: ::c_int = 43; +pub const EL2HLT: ::c_int = 44; +pub const EBADE: ::c_int = 50; +pub const EBADR: ::c_int = 51; +pub const EXFULL: ::c_int = 52; +pub const ENOANO: ::c_int = 53; +pub const EBADRQC: ::c_int = 54; +pub const EBADSLT: ::c_int = 55; +pub const EDEADLOCK: ::c_int = 56; +pub const EMULTIHOP: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 79; +pub const ENOTUNIQ: ::c_int = 80; +pub const EBADFD: ::c_int = 81; +pub const EBADMSG: ::c_int = 77; +pub const EREMCHG: ::c_int = 82; +pub const ELIBACC: ::c_int = 83; +pub const ELIBBAD: ::c_int = 84; +pub const ELIBSCN: ::c_int = 85; +pub const ELIBMAX: ::c_int = 86; +pub const ELIBEXEC: ::c_int = 87; +pub const EILSEQ: ::c_int = 88; +pub const ERESTART: ::c_int = 91; +pub const ESTRPIPE: ::c_int = 92; +pub const EUSERS: ::c_int = 94; +pub const ENOTSOCK: ::c_int = 95; +pub const EDESTADDRREQ: ::c_int = 96; +pub const EMSGSIZE: ::c_int = 97; +pub const EPROTOTYPE: ::c_int = 98; +pub const ENOPROTOOPT: ::c_int = 99; +pub const EPROTONOSUPPORT: ::c_int = 120; +pub const ESOCKTNOSUPPORT: ::c_int = 121; +pub const EOPNOTSUPP: ::c_int = 122; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 123; +pub const EAFNOSUPPORT: ::c_int = 124; +pub const EADDRINUSE: ::c_int = 125; +pub const EADDRNOTAVAIL: ::c_int = 126; +pub const ENETDOWN: ::c_int = 127; +pub const ENETUNREACH: ::c_int = 128; +pub const ENETRESET: ::c_int = 129; +pub const ECONNABORTED: ::c_int = 130; +pub const ECONNRESET: ::c_int = 131; +pub const ENOBUFS: ::c_int = 132; +pub const EISCONN: ::c_int = 133; +pub const ENOTCONN: ::c_int = 134; +pub const ESHUTDOWN: ::c_int = 143; +pub const ETOOMANYREFS: ::c_int = 144; +pub const ETIMEDOUT: ::c_int = 145; +pub const ECONNREFUSED: ::c_int = 146; +pub const EHOSTDOWN: ::c_int = 147; +pub const EHOSTUNREACH: ::c_int = 148; +pub const EALREADY: ::c_int = 149; +pub const EINPROGRESS: ::c_int = 150; +pub const ESTALE: ::c_int = 151; +pub const EUCLEAN: ::c_int = 135; +pub const ENOTNAM: ::c_int = 137; +pub const ENAVAIL: ::c_int = 138; +pub const EISNAM: ::c_int = 139; +pub const EREMOTEIO: ::c_int = 140; +pub const EDQUOT: ::c_int = 1133; +pub const ENOMEDIUM: ::c_int = 159; +pub const EMEDIUMTYPE: ::c_int = 160; +pub const ECANCELED: ::c_int = 158; +pub const ENOKEY: ::c_int = 161; +pub const EKEYEXPIRED: ::c_int = 162; +pub const EKEYREVOKED: ::c_int = 163; +pub const EKEYREJECTED: ::c_int = 164; +pub const EOWNERDEAD: ::c_int = 165; +pub const ENOTRECOVERABLE: ::c_int = 166; +pub const EHWPOISON: ::c_int = 168; +pub const ERFKILL: ::c_int = 167; + +pub const SOCK_STREAM: ::c_int = 2; +pub const SOCK_DGRAM: ::c_int = 1; +pub const SOCK_SEQPACKET: ::c_int = 5; + +pub const SOL_SOCKET: ::c_int = 65535; + +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_ACCEPTCONN: ::c_int = 0x1009; +pub const SO_PROTOCOL: ::c_int = 0x1028; +pub const SO_DOMAIN: ::c_int = 0x1029; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_PASSCRED: ::c_int = 17; +pub const SO_PEERCRED: ::c_int = 18; +pub const SO_SNDBUFFORCE: ::c_int = 31; +pub const SO_RCVBUFFORCE: ::c_int = 33; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 8; +pub const SA_NOCLDWAIT: ::c_int = 0x10000; + +pub const SIGCHLD: ::c_int = 18; +pub const SIGBUS: ::c_int = 10; +pub const SIGTTIN: ::c_int = 26; +pub const SIGTTOU: ::c_int = 27; +pub const SIGXCPU: ::c_int = 30; +pub const SIGXFSZ: ::c_int = 31; +pub const SIGVTALRM: ::c_int = 28; +pub const SIGPROF: ::c_int = 29; +pub const SIGWINCH: ::c_int = 20; +pub const SIGUSR1: ::c_int = 16; +pub const SIGUSR2: ::c_int = 17; +pub const SIGCONT: ::c_int = 25; +pub const SIGSTOP: ::c_int = 23; +pub const SIGTSTP: ::c_int = 24; +pub const SIGURG: ::c_int = 21; +pub const SIGIO: ::c_int = 22; +pub const SIGSYS: ::c_int = 12; +pub const SIGSTKFLT: ::c_int = 7; +pub const SIGPOLL: ::c_int = ::SIGIO; +pub const SIGPWR: ::c_int = 19; +pub const SIG_SETMASK: ::c_int = 3; +pub const SIG_BLOCK: ::c_int = 1; +pub const SIG_UNBLOCK: ::c_int = 2; + +pub const EXTPROC: ::tcflag_t = 0o200000; + +pub const MAP_HUGETLB: ::c_int = 0x80000; + +pub const F_GETLK: ::c_int = 33; +pub const F_GETOWN: ::c_int = 23; +pub const F_SETLK: ::c_int = 34; +pub const F_SETLKW: ::c_int = 35; +pub const F_SETOWN: ::c_int = 24; + +pub const VEOF: usize = 16; +pub const VEOL: usize = 17; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: ::tcflag_t = 0o000400; +pub const TOSTOP: ::tcflag_t = 0o100000; +pub const FLUSHO: ::tcflag_t = 0o020000; + +pub const TCGETS: ::c_int = 0x540D; +pub const TCSETS: ::c_int = 0x540E; +pub const TCSETSW: ::c_int = 0x540F; +pub const TCSETSF: ::c_int = 0x5410; +pub const TCGETA: ::c_int = 0x5401; +pub const TCSETA: ::c_int = 0x5402; +pub const TCSETAW: ::c_int = 0x5403; +pub const TCSETAF: ::c_int = 0x5404; +pub const TCSBRK: ::c_int = 0x5405; +pub const TCXONC: ::c_int = 0x5406; +pub const TCFLSH: ::c_int = 0x5407; +pub const TIOCGSOFTCAR: ::c_int = 0x5481; +pub const TIOCSSOFTCAR: ::c_int = 0x5482; +pub const TIOCLINUX: ::c_int = 0x5483; +pub const TIOCGSERIAL: ::c_int = 0x5484; +pub const TIOCEXCL: ::c_int = 0x740D; +pub const TIOCNXCL: ::c_int = 0x740E; +pub const TIOCSCTTY: ::c_int = 0x5480; +pub const TIOCGPGRP: ::c_int = 0x40047477; +pub const TIOCSPGRP: ::c_int = 0x80047476; +pub const TIOCOUTQ: ::c_int = 0x7472; +pub const TIOCSTI: ::c_int = 0x5472; +pub const TIOCGWINSZ: ::c_int = 0x40087468; +pub const TIOCSWINSZ: ::c_int = 0x80087467; +pub const TIOCMGET: ::c_int = 0x741D; +pub const TIOCMBIS: ::c_int = 0x741B; +pub const TIOCMBIC: ::c_int = 0x741C; +pub const TIOCMSET: ::c_int = 0x741A; +pub const FIONREAD: ::c_int = 0x467F; +pub const TIOCCONS: ::c_int = 0x80047478; + +pub const TIOCGRS485: ::c_int = 0x4020542E; +pub const TIOCSRS485: ::c_int = 0xC020542F; + +pub const POLLWRNORM: ::c_short = 0x4; +pub const POLLWRBAND: ::c_short = 0x100; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x010; +pub const TIOCM_SR: ::c_int = 0x020; +pub const TIOCM_CTS: ::c_int = 0x040; +pub const TIOCM_CAR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0x200; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0x400; + +pub const SYS_syscall: ::c_long = 4000 + 0; +pub const SYS_exit: ::c_long = 4000 + 1; +pub const SYS_fork: ::c_long = 4000 + 2; +pub const SYS_read: ::c_long = 4000 + 3; +pub const SYS_write: ::c_long = 4000 + 4; +pub const SYS_open: ::c_long = 4000 + 5; +pub const SYS_close: ::c_long = 4000 + 6; +pub const SYS_waitpid: ::c_long = 4000 + 7; +pub const SYS_creat: ::c_long = 4000 + 8; +pub const SYS_link: ::c_long = 4000 + 9; +pub const SYS_unlink: ::c_long = 4000 + 10; +pub const SYS_execve: ::c_long = 4000 + 11; +pub const SYS_chdir: ::c_long = 4000 + 12; +pub const SYS_time: ::c_long = 4000 + 13; +pub const SYS_mknod: ::c_long = 4000 + 14; +pub const SYS_chmod: ::c_long = 4000 + 15; +pub const SYS_lchown: ::c_long = 4000 + 16; +pub const SYS_break: ::c_long = 4000 + 17; +pub const SYS_lseek: ::c_long = 4000 + 19; +pub const SYS_getpid: ::c_long = 4000 + 20; +pub const SYS_mount: ::c_long = 4000 + 21; +pub const SYS_umount: ::c_long = 4000 + 22; +pub const SYS_setuid: ::c_long = 4000 + 23; +pub const SYS_getuid: ::c_long = 4000 + 24; +pub const SYS_stime: ::c_long = 4000 + 25; +pub const SYS_ptrace: ::c_long = 4000 + 26; +pub const SYS_alarm: ::c_long = 4000 + 27; +pub const SYS_pause: ::c_long = 4000 + 29; +pub const SYS_utime: ::c_long = 4000 + 30; +pub const SYS_stty: ::c_long = 4000 + 31; +pub const SYS_gtty: ::c_long = 4000 + 32; +pub const SYS_access: ::c_long = 4000 + 33; +pub const SYS_nice: ::c_long = 4000 + 34; +pub const SYS_ftime: ::c_long = 4000 + 35; +pub const SYS_sync: ::c_long = 4000 + 36; +pub const SYS_kill: ::c_long = 4000 + 37; +pub const SYS_rename: ::c_long = 4000 + 38; +pub const SYS_mkdir: ::c_long = 4000 + 39; +pub const SYS_rmdir: ::c_long = 4000 + 40; +pub const SYS_dup: ::c_long = 4000 + 41; +pub const SYS_pipe: ::c_long = 4000 + 42; +pub const SYS_times: ::c_long = 4000 + 43; +pub const SYS_prof: ::c_long = 4000 + 44; +pub const SYS_brk: ::c_long = 4000 + 45; +pub const SYS_setgid: ::c_long = 4000 + 46; +pub const SYS_getgid: ::c_long = 4000 + 47; +pub const SYS_signal: ::c_long = 4000 + 48; +pub const SYS_geteuid: ::c_long = 4000 + 49; +pub const SYS_getegid: ::c_long = 4000 + 50; +pub const SYS_acct: ::c_long = 4000 + 51; +pub const SYS_umount2: ::c_long = 4000 + 52; +pub const SYS_lock: ::c_long = 4000 + 53; +pub const SYS_ioctl: ::c_long = 4000 + 54; +pub const SYS_fcntl: ::c_long = 4000 + 55; +pub const SYS_mpx: ::c_long = 4000 + 56; +pub const SYS_setpgid: ::c_long = 4000 + 57; +pub const SYS_ulimit: ::c_long = 4000 + 58; +pub const SYS_umask: ::c_long = 4000 + 60; +pub const SYS_chroot: ::c_long = 4000 + 61; +pub const SYS_ustat: ::c_long = 4000 + 62; +pub const SYS_dup2: ::c_long = 4000 + 63; +pub const SYS_getppid: ::c_long = 4000 + 64; +pub const SYS_getpgrp: ::c_long = 4000 + 65; +pub const SYS_setsid: ::c_long = 4000 + 66; +pub const SYS_sigaction: ::c_long = 4000 + 67; +pub const SYS_sgetmask: ::c_long = 4000 + 68; +pub const SYS_ssetmask: ::c_long = 4000 + 69; +pub const SYS_setreuid: ::c_long = 4000 + 70; +pub const SYS_setregid: ::c_long = 4000 + 71; +pub const SYS_sigsuspend: ::c_long = 4000 + 72; +pub const SYS_sigpending: ::c_long = 4000 + 73; +pub const SYS_sethostname: ::c_long = 4000 + 74; +pub const SYS_setrlimit: ::c_long = 4000 + 75; +pub const SYS_getrlimit: ::c_long = 4000 + 76; +pub const SYS_getrusage: ::c_long = 4000 + 77; +pub const SYS_gettimeofday: ::c_long = 4000 + 78; +pub const SYS_settimeofday: ::c_long = 4000 + 79; +pub const SYS_getgroups: ::c_long = 4000 + 80; +pub const SYS_setgroups: ::c_long = 4000 + 81; +pub const SYS_symlink: ::c_long = 4000 + 83; +pub const SYS_readlink: ::c_long = 4000 + 85; +pub const SYS_uselib: ::c_long = 4000 + 86; +pub const SYS_swapon: ::c_long = 4000 + 87; +pub const SYS_reboot: ::c_long = 4000 + 88; +pub const SYS_readdir: ::c_long = 4000 + 89; +pub const SYS_mmap: ::c_long = 4000 + 90; +pub const SYS_munmap: ::c_long = 4000 + 91; +pub const SYS_truncate: ::c_long = 4000 + 92; +pub const SYS_ftruncate: ::c_long = 4000 + 93; +pub const SYS_fchmod: ::c_long = 4000 + 94; +pub const SYS_fchown: ::c_long = 4000 + 95; +pub const SYS_getpriority: ::c_long = 4000 + 96; +pub const SYS_setpriority: ::c_long = 4000 + 97; +pub const SYS_profil: ::c_long = 4000 + 98; +pub const SYS_statfs: ::c_long = 4000 + 99; +pub const SYS_fstatfs: ::c_long = 4000 + 100; +pub const SYS_ioperm: ::c_long = 4000 + 101; +pub const SYS_socketcall: ::c_long = 4000 + 102; +pub const SYS_syslog: ::c_long = 4000 + 103; +pub const SYS_setitimer: ::c_long = 4000 + 104; +pub const SYS_getitimer: ::c_long = 4000 + 105; +pub const SYS_stat: ::c_long = 4000 + 106; +pub const SYS_lstat: ::c_long = 4000 + 107; +pub const SYS_fstat: ::c_long = 4000 + 108; +pub const SYS_iopl: ::c_long = 4000 + 110; +pub const SYS_vhangup: ::c_long = 4000 + 111; +pub const SYS_idle: ::c_long = 4000 + 112; +pub const SYS_vm86: ::c_long = 4000 + 113; +pub const SYS_wait4: ::c_long = 4000 + 114; +pub const SYS_swapoff: ::c_long = 4000 + 115; +pub const SYS_sysinfo: ::c_long = 4000 + 116; +pub const SYS_ipc: ::c_long = 4000 + 117; +pub const SYS_fsync: ::c_long = 4000 + 118; +pub const SYS_sigreturn: ::c_long = 4000 + 119; +pub const SYS_clone: ::c_long = 4000 + 120; +pub const SYS_setdomainname: ::c_long = 4000 + 121; +pub const SYS_uname: ::c_long = 4000 + 122; +pub const SYS_modify_ldt: ::c_long = 4000 + 123; +pub const SYS_adjtimex: ::c_long = 4000 + 124; +pub const SYS_mprotect: ::c_long = 4000 + 125; +pub const SYS_sigprocmask: ::c_long = 4000 + 126; +pub const SYS_create_module: ::c_long = 4000 + 127; +pub const SYS_init_module: ::c_long = 4000 + 128; +pub const SYS_delete_module: ::c_long = 4000 + 129; +pub const SYS_get_kernel_syms: ::c_long = 4000 + 130; +pub const SYS_quotactl: ::c_long = 4000 + 131; +pub const SYS_getpgid: ::c_long = 4000 + 132; +pub const SYS_fchdir: ::c_long = 4000 + 133; +pub const SYS_bdflush: ::c_long = 4000 + 134; +pub const SYS_sysfs: ::c_long = 4000 + 135; +pub const SYS_personality: ::c_long = 4000 + 136; +pub const SYS_afs_syscall: ::c_long = 4000 + 137; +pub const SYS_setfsuid: ::c_long = 4000 + 138; +pub const SYS_setfsgid: ::c_long = 4000 + 139; +pub const SYS__llseek: ::c_long = 4000 + 140; +pub const SYS_getdents: ::c_long = 4000 + 141; +pub const SYS_flock: ::c_long = 4000 + 143; +pub const SYS_msync: ::c_long = 4000 + 144; +pub const SYS_readv: ::c_long = 4000 + 145; +pub const SYS_writev: ::c_long = 4000 + 146; +pub const SYS_cacheflush: ::c_long = 4000 + 147; +pub const SYS_cachectl: ::c_long = 4000 + 148; +pub const SYS_sysmips: ::c_long = 4000 + 149; +pub const SYS_getsid: ::c_long = 4000 + 151; +pub const SYS_fdatasync: ::c_long = 4000 + 152; +pub const SYS__sysctl: ::c_long = 4000 + 153; +pub const SYS_mlock: ::c_long = 4000 + 154; +pub const SYS_munlock: ::c_long = 4000 + 155; +pub const SYS_mlockall: ::c_long = 4000 + 156; +pub const SYS_munlockall: ::c_long = 4000 + 157; +pub const SYS_sched_setparam: ::c_long = 4000 + 158; +pub const SYS_sched_getparam: ::c_long = 4000 + 159; +pub const SYS_sched_setscheduler: ::c_long = 4000 + 160; +pub const SYS_sched_getscheduler: ::c_long = 4000 + 161; +pub const SYS_sched_yield: ::c_long = 4000 + 162; +pub const SYS_sched_get_priority_max: ::c_long = 4000 + 163; +pub const SYS_sched_get_priority_min: ::c_long = 4000 + 164; +pub const SYS_sched_rr_get_interval: ::c_long = 4000 + 165; +pub const SYS_nanosleep: ::c_long = 4000 + 166; +pub const SYS_mremap: ::c_long = 4000 + 167; +pub const SYS_accept: ::c_long = 4000 + 168; +pub const SYS_bind: ::c_long = 4000 + 169; +pub const SYS_connect: ::c_long = 4000 + 170; +pub const SYS_getpeername: ::c_long = 4000 + 171; +pub const SYS_getsockname: ::c_long = 4000 + 172; +pub const SYS_getsockopt: ::c_long = 4000 + 173; +pub const SYS_listen: ::c_long = 4000 + 174; +pub const SYS_recv: ::c_long = 4000 + 175; +pub const SYS_recvfrom: ::c_long = 4000 + 176; +pub const SYS_recvmsg: ::c_long = 4000 + 177; +pub const SYS_send: ::c_long = 4000 + 178; +pub const SYS_sendmsg: ::c_long = 4000 + 179; +pub const SYS_sendto: ::c_long = 4000 + 180; +pub const SYS_setsockopt: ::c_long = 4000 + 181; +pub const SYS_shutdown: ::c_long = 4000 + 182; +pub const SYS_socket: ::c_long = 4000 + 183; +pub const SYS_socketpair: ::c_long = 4000 + 184; +pub const SYS_setresuid: ::c_long = 4000 + 185; +pub const SYS_getresuid: ::c_long = 4000 + 186; +pub const SYS_query_module: ::c_long = 4000 + 187; +pub const SYS_poll: ::c_long = 4000 + 188; +pub const SYS_nfsservctl: ::c_long = 4000 + 189; +pub const SYS_setresgid: ::c_long = 4000 + 190; +pub const SYS_getresgid: ::c_long = 4000 + 191; +pub const SYS_prctl: ::c_long = 4000 + 192; +pub const SYS_rt_sigreturn: ::c_long = 4000 + 193; +pub const SYS_rt_sigaction: ::c_long = 4000 + 194; +pub const SYS_rt_sigprocmask: ::c_long = 4000 + 195; +pub const SYS_rt_sigpending: ::c_long = 4000 + 196; +pub const SYS_rt_sigtimedwait: ::c_long = 4000 + 197; +pub const SYS_rt_sigqueueinfo: ::c_long = 4000 + 198; +pub const SYS_rt_sigsuspend: ::c_long = 4000 + 199; +pub const SYS_chown: ::c_long = 4000 + 202; +pub const SYS_getcwd: ::c_long = 4000 + 203; +pub const SYS_capget: ::c_long = 4000 + 204; +pub const SYS_capset: ::c_long = 4000 + 205; +pub const SYS_sigaltstack: ::c_long = 4000 + 206; +pub const SYS_sendfile: ::c_long = 4000 + 207; +pub const SYS_getpmsg: ::c_long = 4000 + 208; +pub const SYS_putpmsg: ::c_long = 4000 + 209; +pub const SYS_mmap2: ::c_long = 4000 + 210; +pub const SYS_truncate64: ::c_long = 4000 + 211; +pub const SYS_ftruncate64: ::c_long = 4000 + 212; +pub const SYS_stat64: ::c_long = 4000 + 213; +pub const SYS_lstat64: ::c_long = 4000 + 214; +pub const SYS_fstat64: ::c_long = 4000 + 215; +pub const SYS_pivot_root: ::c_long = 4000 + 216; +pub const SYS_mincore: ::c_long = 4000 + 217; +pub const SYS_madvise: ::c_long = 4000 + 218; +pub const SYS_getdents64: ::c_long = 4000 + 219; +pub const SYS_fcntl64: ::c_long = 4000 + 220; +pub const SYS_gettid: ::c_long = 4000 + 222; +pub const SYS_readahead: ::c_long = 4000 + 223; +pub const SYS_setxattr: ::c_long = 4000 + 224; +pub const SYS_lsetxattr: ::c_long = 4000 + 225; +pub const SYS_fsetxattr: ::c_long = 4000 + 226; +pub const SYS_getxattr: ::c_long = 4000 + 227; +pub const SYS_lgetxattr: ::c_long = 4000 + 228; +pub const SYS_fgetxattr: ::c_long = 4000 + 229; +pub const SYS_listxattr: ::c_long = 4000 + 230; +pub const SYS_llistxattr: ::c_long = 4000 + 231; +pub const SYS_flistxattr: ::c_long = 4000 + 232; +pub const SYS_removexattr: ::c_long = 4000 + 233; +pub const SYS_lremovexattr: ::c_long = 4000 + 234; +pub const SYS_fremovexattr: ::c_long = 4000 + 235; +pub const SYS_tkill: ::c_long = 4000 + 236; +pub const SYS_sendfile64: ::c_long = 4000 + 237; +pub const SYS_futex: ::c_long = 4000 + 238; +pub const SYS_sched_setaffinity: ::c_long = 4000 + 239; +pub const SYS_sched_getaffinity: ::c_long = 4000 + 240; +pub const SYS_io_setup: ::c_long = 4000 + 241; +pub const SYS_io_destroy: ::c_long = 4000 + 242; +pub const SYS_io_getevents: ::c_long = 4000 + 243; +pub const SYS_io_submit: ::c_long = 4000 + 244; +pub const SYS_io_cancel: ::c_long = 4000 + 245; +pub const SYS_exit_group: ::c_long = 4000 + 246; +pub const SYS_lookup_dcookie: ::c_long = 4000 + 247; +pub const SYS_epoll_create: ::c_long = 4000 + 248; +pub const SYS_epoll_ctl: ::c_long = 4000 + 249; +pub const SYS_epoll_wait: ::c_long = 4000 + 250; +pub const SYS_remap_file_pages: ::c_long = 4000 + 251; +pub const SYS_set_tid_address: ::c_long = 4000 + 252; +pub const SYS_restart_syscall: ::c_long = 4000 + 253; +pub const SYS_statfs64: ::c_long = 4000 + 255; +pub const SYS_fstatfs64: ::c_long = 4000 + 256; +pub const SYS_timer_create: ::c_long = 4000 + 257; +pub const SYS_timer_settime: ::c_long = 4000 + 258; +pub const SYS_timer_gettime: ::c_long = 4000 + 259; +pub const SYS_timer_getoverrun: ::c_long = 4000 + 260; +pub const SYS_timer_delete: ::c_long = 4000 + 261; +pub const SYS_clock_settime: ::c_long = 4000 + 262; +pub const SYS_clock_gettime: ::c_long = 4000 + 263; +pub const SYS_clock_getres: ::c_long = 4000 + 264; +pub const SYS_clock_nanosleep: ::c_long = 4000 + 265; +pub const SYS_tgkill: ::c_long = 4000 + 266; +pub const SYS_utimes: ::c_long = 4000 + 267; +pub const SYS_mbind: ::c_long = 4000 + 268; +pub const SYS_get_mempolicy: ::c_long = 4000 + 269; +pub const SYS_set_mempolicy: ::c_long = 4000 + 270; +pub const SYS_mq_open: ::c_long = 4000 + 271; +pub const SYS_mq_unlink: ::c_long = 4000 + 272; +pub const SYS_mq_timedsend: ::c_long = 4000 + 273; +pub const SYS_mq_timedreceive: ::c_long = 4000 + 274; +pub const SYS_mq_notify: ::c_long = 4000 + 275; +pub const SYS_mq_getsetattr: ::c_long = 4000 + 276; +pub const SYS_vserver: ::c_long = 4000 + 277; +pub const SYS_waitid: ::c_long = 4000 + 278; +/* pub const SYS_sys_setaltroot: ::c_long = 4000 + 279; */ +pub const SYS_add_key: ::c_long = 4000 + 280; +pub const SYS_request_key: ::c_long = 4000 + 281; +pub const SYS_keyctl: ::c_long = 4000 + 282; +pub const SYS_set_thread_area: ::c_long = 4000 + 283; +pub const SYS_inotify_init: ::c_long = 4000 + 284; +pub const SYS_inotify_add_watch: ::c_long = 4000 + 285; +pub const SYS_inotify_rm_watch: ::c_long = 4000 + 286; +pub const SYS_migrate_pages: ::c_long = 4000 + 287; +pub const SYS_openat: ::c_long = 4000 + 288; +pub const SYS_mkdirat: ::c_long = 4000 + 289; +pub const SYS_mknodat: ::c_long = 4000 + 290; +pub const SYS_fchownat: ::c_long = 4000 + 291; +pub const SYS_futimesat: ::c_long = 4000 + 292; +pub const SYS_unlinkat: ::c_long = 4000 + 294; +pub const SYS_renameat: ::c_long = 4000 + 295; +pub const SYS_linkat: ::c_long = 4000 + 296; +pub const SYS_symlinkat: ::c_long = 4000 + 297; +pub const SYS_readlinkat: ::c_long = 4000 + 298; +pub const SYS_fchmodat: ::c_long = 4000 + 299; +pub const SYS_faccessat: ::c_long = 4000 + 300; +pub const SYS_pselect6: ::c_long = 4000 + 301; +pub const SYS_ppoll: ::c_long = 4000 + 302; +pub const SYS_unshare: ::c_long = 4000 + 303; +pub const SYS_splice: ::c_long = 4000 + 304; +pub const SYS_sync_file_range: ::c_long = 4000 + 305; +pub const SYS_tee: ::c_long = 4000 + 306; +pub const SYS_vmsplice: ::c_long = 4000 + 307; +pub const SYS_move_pages: ::c_long = 4000 + 308; +pub const SYS_set_robust_list: ::c_long = 4000 + 309; +pub const SYS_get_robust_list: ::c_long = 4000 + 310; +pub const SYS_kexec_load: ::c_long = 4000 + 311; +pub const SYS_getcpu: ::c_long = 4000 + 312; +pub const SYS_epoll_pwait: ::c_long = 4000 + 313; +pub const SYS_ioprio_set: ::c_long = 4000 + 314; +pub const SYS_ioprio_get: ::c_long = 4000 + 315; +pub const SYS_utimensat: ::c_long = 4000 + 316; +pub const SYS_signalfd: ::c_long = 4000 + 317; +pub const SYS_timerfd: ::c_long = 4000 + 318; +pub const SYS_eventfd: ::c_long = 4000 + 319; +pub const SYS_fallocate: ::c_long = 4000 + 320; +pub const SYS_timerfd_create: ::c_long = 4000 + 321; +pub const SYS_timerfd_gettime: ::c_long = 4000 + 322; +pub const SYS_timerfd_settime: ::c_long = 4000 + 323; +pub const SYS_signalfd4: ::c_long = 4000 + 324; +pub const SYS_eventfd2: ::c_long = 4000 + 325; +pub const SYS_epoll_create1: ::c_long = 4000 + 326; +pub const SYS_dup3: ::c_long = 4000 + 327; +pub const SYS_pipe2: ::c_long = 4000 + 328; +pub const SYS_inotify_init1: ::c_long = 4000 + 329; +pub const SYS_preadv: ::c_long = 4000 + 330; +pub const SYS_pwritev: ::c_long = 4000 + 331; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 4000 + 332; +pub const SYS_perf_event_open: ::c_long = 4000 + 333; +pub const SYS_accept4: ::c_long = 4000 + 334; +pub const SYS_recvmmsg: ::c_long = 4000 + 335; +pub const SYS_fanotify_init: ::c_long = 4000 + 336; +pub const SYS_fanotify_mark: ::c_long = 4000 + 337; +pub const SYS_prlimit64: ::c_long = 4000 + 338; +pub const SYS_name_to_handle_at: ::c_long = 4000 + 339; +pub const SYS_open_by_handle_at: ::c_long = 4000 + 340; +pub const SYS_clock_adjtime: ::c_long = 4000 + 341; +pub const SYS_syncfs: ::c_long = 4000 + 342; +pub const SYS_sendmmsg: ::c_long = 4000 + 343; +pub const SYS_setns: ::c_long = 4000 + 344; +pub const SYS_process_vm_readv: ::c_long = 4000 + 345; +pub const SYS_process_vm_writev: ::c_long = 4000 + 346; +pub const SYS_kcmp: ::c_long = 4000 + 347; +pub const SYS_finit_module: ::c_long = 4000 + 348; +pub const SYS_sched_setattr: ::c_long = 4000 + 349; +pub const SYS_sched_getattr: ::c_long = 4000 + 350; +pub const SYS_renameat2: ::c_long = 4000 + 351; +pub const SYS_seccomp: ::c_long = 4000 + 352; +pub const SYS_getrandom: ::c_long = 4000 + 353; +pub const SYS_memfd_create: ::c_long = 4000 + 354; +pub const SYS_bpf: ::c_long = 4000 + 355; +pub const SYS_execveat: ::c_long = 4000 + 356; +pub const SYS_userfaultfd: ::c_long = 4000 + 357; +pub const SYS_membarrier: ::c_long = 4000 + 358; +pub const SYS_mlock2: ::c_long = 4000 + 359; +pub const SYS_copy_file_range: ::c_long = 4000 + 360; +pub const SYS_preadv2: ::c_long = 4000 + 361; +pub const SYS_pwritev2: ::c_long = 4000 + 362; +pub const SYS_pkey_mprotect: ::c_long = 4000 + 363; +pub const SYS_pkey_alloc: ::c_long = 4000 + 364; +pub const SYS_pkey_free: ::c_long = 4000 + 365; +pub const SYS_statx: ::c_long = 4000 + 366; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/mod.rs new file mode 100644 index 0000000..7cf6da9 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/mod.rs @@ -0,0 +1,65 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type nlink_t = u32; +pub type blksize_t = ::c_long; +pub type __u64 = ::c_ulonglong; + +s! { + pub struct pthread_attr_t { + __size: [u32; 9] + } + + pub struct sigset_t { + __val: [::c_ulong; 32], + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::socklen_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::socklen_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct sem_t { + __val: [::c_int; 4], + } +} + +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; + +pub const TIOCINQ: ::c_int = ::FIONREAD; + +extern "C" { + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; +} + +cfg_if! { + if #[cfg(any(target_arch = "x86"))] { + mod x86; + pub use self::x86::*; + } else if #[cfg(any(target_arch = "mips"))] { + mod mips; + pub use self::mips::*; + } else if #[cfg(any(target_arch = "arm"))] { + mod arm; + pub use self::arm::*; + } else if #[cfg(any(target_arch = "powerpc"))] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(any(target_arch = "hexagon"))] { + mod hexagon; + pub use self::hexagon::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/powerpc.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/powerpc.rs new file mode 100644 index 0000000..6181b1c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -0,0 +1,863 @@ +pub type c_char = u8; +pub type wchar_t = i32; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_rdev_padding: ::c_short, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 2], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_rdev_padding: ::c_short, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 2], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_int, + __pad1: ::c_int, + __pad2: ::c_longlong, + __pad3: ::c_longlong + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + __unused1: ::c_int, + pub shm_atime: ::time_t, + __unused2: ::c_int, + pub shm_dtime: ::time_t, + __unused3: ::c_int, + pub shm_ctime: ::time_t, + __unused4: ::c_int, + pub shm_segsz: ::size_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::c_ulong, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + __unused1: ::c_int, + pub msg_stime: ::time_t, + __unused2: ::c_int, + pub msg_rtime: ::time_t, + __unused3: ::c_int, + pub msg_ctime: ::time_t, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + #[cfg(target_endian = "little")] + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + #[cfg(target_endian = "big")] + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } +} + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const SIGSTKSZ: ::size_t = 10240; +pub const MINSIGSTKSZ: ::size_t = 4096; + +pub const O_DIRECT: ::c_int = 0x20000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_LARGEFILE: ::c_int = 0x10000; + +pub const FIOCLEX: ::c_int = 0x20006601; +pub const FIONCLEX: ::c_int = 0x20006602; +pub const FIONBIO: ::c_int = 0x8004667E; + +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_NLIMITS: ::c_int = 15; + +pub const MCL_CURRENT: ::c_int = 0x2000; +pub const MCL_FUTURE: ::c_int = 0x4000; +pub const CBAUD: ::tcflag_t = 0o0000377; +pub const TAB1: ::c_int = 0x00000400; +pub const TAB2: ::c_int = 0x00000800; +pub const TAB3: ::c_int = 0x00000C00; +pub const CR1: ::c_int = 0x00001000; +pub const CR2: ::c_int = 0x00002000; +pub const CR3: ::c_int = 0x00003000; +pub const FF1: ::c_int = 0x00004000; +pub const BS1: ::c_int = 0x00008000; +pub const VT1: ::c_int = 0x00010000; +pub const VWERASE: usize = 10; +pub const VREPRINT: usize = 11; +pub const VSUSP: usize = 12; +pub const VSTART: usize = 13; +pub const VSTOP: usize = 14; +pub const VDISCARD: usize = 16; +pub const VTIME: usize = 7; +pub const IXON: ::tcflag_t = 0x00000200; +pub const IXOFF: ::tcflag_t = 0x00000400; +pub const ONLCR: ::tcflag_t = 0x00000002; +pub const CSIZE: ::tcflag_t = 0x00000300; +pub const CS6: ::tcflag_t = 0x00000100; +pub const CS7: ::tcflag_t = 0x00000200; +pub const CS8: ::tcflag_t = 0x00000300; +pub const CSTOPB: ::tcflag_t = 0x00000400; +pub const CREAD: ::tcflag_t = 0x00000800; +pub const PARENB: ::tcflag_t = 0x00001000; +pub const PARODD: ::tcflag_t = 0x00002000; +pub const HUPCL: ::tcflag_t = 0x00004000; +pub const CLOCAL: ::tcflag_t = 0x00008000; +pub const ECHOKE: ::tcflag_t = 0x00000001; +pub const ECHOE: ::tcflag_t = 0x00000002; +pub const ECHOK: ::tcflag_t = 0x00000004; +pub const ECHONL: ::tcflag_t = 0x00000010; +pub const ECHOPRT: ::tcflag_t = 0x00000020; +pub const ECHOCTL: ::tcflag_t = 0x00000040; +pub const ISIG: ::tcflag_t = 0x00000080; +pub const ICANON: ::tcflag_t = 0x00000100; +pub const PENDIN: ::tcflag_t = 0x20000000; +pub const NOFLSH: ::tcflag_t = 0x80000000; +pub const CIBAUD: ::tcflag_t = 0o00077600000; +pub const CBAUDEX: ::tcflag_t = 0o000020; +pub const VSWTC: usize = 9; +pub const OLCUC: ::tcflag_t = 0o000004; +pub const NLDLY: ::tcflag_t = 0o001400; +pub const CRDLY: ::tcflag_t = 0o030000; +pub const TABDLY: ::tcflag_t = 0o006000; +pub const BSDLY: ::tcflag_t = 0o100000; +pub const FFDLY: ::tcflag_t = 0o040000; +pub const VTDLY: ::tcflag_t = 0o200000; +pub const XTABS: ::tcflag_t = 0o006000; +pub const B57600: ::speed_t = 0o000020; +pub const B115200: ::speed_t = 0o000021; +pub const B230400: ::speed_t = 0o000022; +pub const B460800: ::speed_t = 0o000023; +pub const B500000: ::speed_t = 0o000024; +pub const B576000: ::speed_t = 0o000025; +pub const B921600: ::speed_t = 0o000026; +pub const B1000000: ::speed_t = 0o000027; +pub const B1152000: ::speed_t = 0o000030; +pub const B1500000: ::speed_t = 0o000031; +pub const B2000000: ::speed_t = 0o000032; +pub const B2500000: ::speed_t = 0o000033; +pub const B3000000: ::speed_t = 0o000034; +pub const B3500000: ::speed_t = 0o000035; +pub const B4000000: ::speed_t = 0o000036; + +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; + +pub const SOCK_NONBLOCK: ::c_int = 2048; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x00080; +pub const MAP_NORESERVE: ::c_int = 0x00040; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_SEQPACKET: ::c_int = 5; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EDEADLOCK: ::c_int = 58; +pub const EMULTIHOP: ::c_int = 72; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_RCVLOWAT: ::c_int = 16; +pub const SO_SNDLOWAT: ::c_int = 17; +pub const SO_RCVTIMEO: ::c_int = 18; +pub const SO_SNDTIMEO: ::c_int = 19; +pub const SO_PASSCRED: ::c_int = 20; +pub const SO_PEERCRED: ::c_int = 21; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const EXTPROC: ::tcflag_t = 0x10000000; + +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const F_GETLK: ::c_int = 12; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 13; +pub const F_SETLKW: ::c_int = 14; +pub const F_SETOWN: ::c_int = 8; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 6; +pub const VEOL2: usize = 8; +pub const VMIN: usize = 5; +pub const IEXTEN: ::tcflag_t = 0x00000400; +pub const TOSTOP: ::tcflag_t = 0x00400000; +pub const FLUSHO: ::tcflag_t = 0x00800000; + +pub const TCGETS: ::c_int = 0x402C7413; +pub const TCSETS: ::c_int = 0x802C7414; +pub const TCSETSW: ::c_int = 0x802C7415; +pub const TCSETSF: ::c_int = 0x802C7416; +pub const TCGETA: ::c_int = 0x40147417; +pub const TCSETA: ::c_int = 0x80147418; +pub const TCSETAW: ::c_int = 0x80147419; +pub const TCSETAF: ::c_int = 0x8014741C; +pub const TCSBRK: ::c_int = 0x2000741D; +pub const TCXONC: ::c_int = 0x2000741E; +pub const TCFLSH: ::c_int = 0x2000741F; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x40047477; +pub const TIOCSPGRP: ::c_int = 0x80047476; +pub const TIOCOUTQ: ::c_int = 0x40047473; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x40087468; +pub const TIOCSWINSZ: ::c_int = 0x80087467; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x4004667F; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const TIOCGRS485: ::c_int = 0x542e; +pub const TIOCSRS485: ::c_int = 0x542f; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +// Syscall table +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_break: ::c_long = 17; +pub const SYS_oldstat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_umount: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_stime: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_oldfstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_stty: ::c_long = 31; +pub const SYS_gtty: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_ftime: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_prof: ::c_long = 44; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_lock: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_mpx: ::c_long = 56; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_ulimit: ::c_long = 58; +pub const SYS_oldolduname: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_oldlstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_readdir: ::c_long = 89; +pub const SYS_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_profil: ::c_long = 98; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_ioperm: ::c_long = 101; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_olduname: ::c_long = 109; +pub const SYS_iopl: ::c_long = 110; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_idle: ::c_long = 112; +pub const SYS_vm86: ::c_long = 113; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_modify_ldt: ::c_long = 123; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_afs_syscall: ::c_long = 137; +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_query_module: ::c_long = 166; +pub const SYS_poll: ::c_long = 167; +pub const SYS_nfsservctl: ::c_long = 168; +pub const SYS_setresgid: ::c_long = 169; +pub const SYS_getresgid: ::c_long = 170; +pub const SYS_prctl: ::c_long = 171; +pub const SYS_rt_sigreturn: ::c_long = 172; +pub const SYS_rt_sigaction: ::c_long = 173; +pub const SYS_rt_sigprocmask: ::c_long = 174; +pub const SYS_rt_sigpending: ::c_long = 175; +pub const SYS_rt_sigtimedwait: ::c_long = 176; +pub const SYS_rt_sigqueueinfo: ::c_long = 177; +pub const SYS_rt_sigsuspend: ::c_long = 178; +pub const SYS_pread64: ::c_long = 179; +pub const SYS_pwrite64: ::c_long = 180; +pub const SYS_chown: ::c_long = 181; +pub const SYS_getcwd: ::c_long = 182; +pub const SYS_capget: ::c_long = 183; +pub const SYS_capset: ::c_long = 184; +pub const SYS_sigaltstack: ::c_long = 185; +pub const SYS_sendfile: ::c_long = 186; +pub const SYS_getpmsg: ::c_long = 187; +pub const SYS_putpmsg: ::c_long = 188; +pub const SYS_vfork: ::c_long = 189; +pub const SYS_ugetrlimit: ::c_long = 190; +pub const SYS_readahead: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_pciconfig_read: ::c_long = 198; +pub const SYS_pciconfig_write: ::c_long = 199; +pub const SYS_pciconfig_iobase: ::c_long = 200; +pub const SYS_multiplexer: ::c_long = 201; +pub const SYS_getdents64: ::c_long = 202; +pub const SYS_pivot_root: ::c_long = 203; +pub const SYS_fcntl64: ::c_long = 204; +pub const SYS_madvise: ::c_long = 205; +pub const SYS_mincore: ::c_long = 206; +pub const SYS_gettid: ::c_long = 207; +pub const SYS_tkill: ::c_long = 208; +pub const SYS_setxattr: ::c_long = 209; +pub const SYS_lsetxattr: ::c_long = 210; +pub const SYS_fsetxattr: ::c_long = 211; +pub const SYS_getxattr: ::c_long = 212; +pub const SYS_lgetxattr: ::c_long = 213; +pub const SYS_fgetxattr: ::c_long = 214; +pub const SYS_listxattr: ::c_long = 215; +pub const SYS_llistxattr: ::c_long = 216; +pub const SYS_flistxattr: ::c_long = 217; +pub const SYS_removexattr: ::c_long = 218; +pub const SYS_lremovexattr: ::c_long = 219; +pub const SYS_fremovexattr: ::c_long = 220; +pub const SYS_futex: ::c_long = 221; +pub const SYS_sched_setaffinity: ::c_long = 222; +pub const SYS_sched_getaffinity: ::c_long = 223; +pub const SYS_tuxcall: ::c_long = 225; +pub const SYS_sendfile64: ::c_long = 226; +pub const SYS_io_setup: ::c_long = 227; +pub const SYS_io_destroy: ::c_long = 228; +pub const SYS_io_getevents: ::c_long = 229; +pub const SYS_io_submit: ::c_long = 230; +pub const SYS_io_cancel: ::c_long = 231; +pub const SYS_set_tid_address: ::c_long = 232; +pub const SYS_fadvise64: ::c_long = 233; +pub const SYS_exit_group: ::c_long = 234; +pub const SYS_lookup_dcookie: ::c_long = 235; +pub const SYS_epoll_create: ::c_long = 236; +pub const SYS_epoll_ctl: ::c_long = 237; +pub const SYS_epoll_wait: ::c_long = 238; +pub const SYS_remap_file_pages: ::c_long = 239; +pub const SYS_timer_create: ::c_long = 240; +pub const SYS_timer_settime: ::c_long = 241; +pub const SYS_timer_gettime: ::c_long = 242; +pub const SYS_timer_getoverrun: ::c_long = 243; +pub const SYS_timer_delete: ::c_long = 244; +pub const SYS_clock_settime: ::c_long = 245; +pub const SYS_clock_gettime: ::c_long = 246; +pub const SYS_clock_getres: ::c_long = 247; +pub const SYS_clock_nanosleep: ::c_long = 248; +pub const SYS_swapcontext: ::c_long = 249; +pub const SYS_tgkill: ::c_long = 250; +pub const SYS_utimes: ::c_long = 251; +pub const SYS_statfs64: ::c_long = 252; +pub const SYS_fstatfs64: ::c_long = 253; +pub const SYS_fadvise64_64: ::c_long = 254; +pub const SYS_rtas: ::c_long = 255; +pub const SYS_sys_debug_setcontext: ::c_long = 256; +pub const SYS_migrate_pages: ::c_long = 258; +pub const SYS_mbind: ::c_long = 259; +pub const SYS_get_mempolicy: ::c_long = 260; +pub const SYS_set_mempolicy: ::c_long = 261; +pub const SYS_mq_open: ::c_long = 262; +pub const SYS_mq_unlink: ::c_long = 263; +pub const SYS_mq_timedsend: ::c_long = 264; +pub const SYS_mq_timedreceive: ::c_long = 265; +pub const SYS_mq_notify: ::c_long = 266; +pub const SYS_mq_getsetattr: ::c_long = 267; +pub const SYS_kexec_load: ::c_long = 268; +pub const SYS_add_key: ::c_long = 269; +pub const SYS_request_key: ::c_long = 270; +pub const SYS_keyctl: ::c_long = 271; +pub const SYS_waitid: ::c_long = 272; +pub const SYS_ioprio_set: ::c_long = 273; +pub const SYS_ioprio_get: ::c_long = 274; +pub const SYS_inotify_init: ::c_long = 275; +pub const SYS_inotify_add_watch: ::c_long = 276; +pub const SYS_inotify_rm_watch: ::c_long = 277; +pub const SYS_spu_run: ::c_long = 278; +pub const SYS_spu_create: ::c_long = 279; +pub const SYS_pselect6: ::c_long = 280; +pub const SYS_ppoll: ::c_long = 281; +pub const SYS_unshare: ::c_long = 282; +pub const SYS_splice: ::c_long = 283; +pub const SYS_tee: ::c_long = 284; +pub const SYS_vmsplice: ::c_long = 285; +pub const SYS_openat: ::c_long = 286; +pub const SYS_mkdirat: ::c_long = 287; +pub const SYS_mknodat: ::c_long = 288; +pub const SYS_fchownat: ::c_long = 289; +pub const SYS_futimesat: ::c_long = 290; +pub const SYS_fstatat64: ::c_long = 291; +pub const SYS_unlinkat: ::c_long = 292; +pub const SYS_renameat: ::c_long = 293; +pub const SYS_linkat: ::c_long = 294; +pub const SYS_symlinkat: ::c_long = 295; +pub const SYS_readlinkat: ::c_long = 296; +pub const SYS_fchmodat: ::c_long = 297; +pub const SYS_faccessat: ::c_long = 298; +pub const SYS_get_robust_list: ::c_long = 299; +pub const SYS_set_robust_list: ::c_long = 300; +pub const SYS_move_pages: ::c_long = 301; +pub const SYS_getcpu: ::c_long = 302; +pub const SYS_epoll_pwait: ::c_long = 303; +pub const SYS_utimensat: ::c_long = 304; +pub const SYS_signalfd: ::c_long = 305; +pub const SYS_timerfd_create: ::c_long = 306; +pub const SYS_eventfd: ::c_long = 307; +pub const SYS_sync_file_range2: ::c_long = 308; +pub const SYS_fallocate: ::c_long = 309; +pub const SYS_subpage_prot: ::c_long = 310; +pub const SYS_timerfd_settime: ::c_long = 311; +pub const SYS_timerfd_gettime: ::c_long = 312; +pub const SYS_signalfd4: ::c_long = 313; +pub const SYS_eventfd2: ::c_long = 314; +pub const SYS_epoll_create1: ::c_long = 315; +pub const SYS_dup3: ::c_long = 316; +pub const SYS_pipe2: ::c_long = 317; +pub const SYS_inotify_init1: ::c_long = 318; +pub const SYS_perf_event_open: ::c_long = 319; +pub const SYS_preadv: ::c_long = 320; +pub const SYS_pwritev: ::c_long = 321; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 322; +pub const SYS_fanotify_init: ::c_long = 323; +pub const SYS_fanotify_mark: ::c_long = 324; +pub const SYS_prlimit64: ::c_long = 325; +pub const SYS_socket: ::c_long = 326; +pub const SYS_bind: ::c_long = 327; +pub const SYS_connect: ::c_long = 328; +pub const SYS_listen: ::c_long = 329; +pub const SYS_accept: ::c_long = 330; +pub const SYS_getsockname: ::c_long = 331; +pub const SYS_getpeername: ::c_long = 332; +pub const SYS_socketpair: ::c_long = 333; +pub const SYS_send: ::c_long = 334; +pub const SYS_sendto: ::c_long = 335; +pub const SYS_recv: ::c_long = 336; +pub const SYS_recvfrom: ::c_long = 337; +pub const SYS_shutdown: ::c_long = 338; +pub const SYS_setsockopt: ::c_long = 339; +pub const SYS_getsockopt: ::c_long = 340; +pub const SYS_sendmsg: ::c_long = 341; +pub const SYS_recvmsg: ::c_long = 342; +pub const SYS_recvmmsg: ::c_long = 343; +pub const SYS_accept4: ::c_long = 344; +pub const SYS_name_to_handle_at: ::c_long = 345; +pub const SYS_open_by_handle_at: ::c_long = 346; +pub const SYS_clock_adjtime: ::c_long = 347; +pub const SYS_syncfs: ::c_long = 348; +pub const SYS_sendmmsg: ::c_long = 349; +pub const SYS_setns: ::c_long = 350; +pub const SYS_process_vm_readv: ::c_long = 351; +pub const SYS_process_vm_writev: ::c_long = 352; +pub const SYS_finit_module: ::c_long = 353; +pub const SYS_kcmp: ::c_long = 354; +pub const SYS_sched_setattr: ::c_long = 355; +pub const SYS_sched_getattr: ::c_long = 356; +pub const SYS_renameat2: ::c_long = 357; +pub const SYS_seccomp: ::c_long = 358; +pub const SYS_getrandom: ::c_long = 359; +pub const SYS_memfd_create: ::c_long = 360; +pub const SYS_bpf: ::c_long = 361; +pub const SYS_execveat: ::c_long = 362; +pub const SYS_switch_endian: ::c_long = 363; +pub const SYS_userfaultfd: ::c_long = 364; +pub const SYS_membarrier: ::c_long = 365; +pub const SYS_mlock2: ::c_long = 378; +pub const SYS_copy_file_range: ::c_long = 379; +pub const SYS_preadv2: ::c_long = 380; +pub const SYS_pwritev2: ::c_long = 381; +pub const SYS_kexec_file_load: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; +pub const SYS_pkey_alloc: ::c_long = 384; +pub const SYS_pkey_free: ::c_long = 385; +pub const SYS_pkey_mprotect: ::c_long = 386; + +extern "C" { + pub fn getrandom( + buf: *mut ::c_void, + buflen: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/x86/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/x86/align.rs new file mode 100644 index 0000000..7954417 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/x86/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f64; 3] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/x86/mod.rs new file mode 100644 index 0000000..fcd8ae4 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -0,0 +1,954 @@ +pub type c_char = i8; +pub type wchar_t = i32; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + __st_dev_padding: ::c_int, + __st_ino_truncated: ::c_long, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_rdev_padding: ::c_int, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_ino: ::ino_t, + } + + pub struct stat64 { + pub st_dev: ::dev_t, + __st_dev_padding: ::c_int, + __st_ino_truncated: ::c_long, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_rdev_padding: ::c_int, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_ino: ::ino_t, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_int, + __unused1: ::c_long, + __unused2: ::c_long + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + __unused1: ::c_int, + pub shm_dtime: ::time_t, + __unused2: ::c_int, + pub shm_ctime: ::time_t, + __unused3: ::c_int, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::c_ulong, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + __unused1: ::c_int, + pub msg_rtime: ::time_t, + __unused2: ::c_int, + pub msg_ctime: ::time_t, + __unused3: ::c_int, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct mcontext_t { + __private: [u32; 22] + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } +} + +s_no_extra_traits! { + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + __private: [u8; 112], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + && self + .__private + .iter() + .zip(other.__private.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for ucontext_t {} + + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } + } + + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + self.__private.hash(state); + } + } + } +} + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_LARGEFILE: ::c_int = 0o0100000; + +pub const FIOCLEX: ::c_int = 0x5451; +pub const FIONCLEX: ::c_int = 0x5450; +pub const FIONBIO: ::c_int = 0x5421; + +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_NLIMITS: ::c_int = 15; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; + +pub const SOCK_NONBLOCK: ::c_int = 2048; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_SEQPACKET: ::c_int = 5; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const EMULTIHOP: ::c_int = 72; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const EXTPROC: ::tcflag_t = 0x00010000; + +pub const MAP_HUGETLB: ::c_int = 0x040000; +pub const MAP_32BIT: ::c_int = 0x0040; + +pub const F_GETLK: ::c_int = 12; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 13; +pub const F_SETLKW: ::c_int = 14; +pub const F_SETOWN: ::c_int = 8; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; + +pub const TCGETS: ::c_int = 0x5401; +pub const TCSETS: ::c_int = 0x5402; +pub const TCSETSW: ::c_int = 0x5403; +pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETA: ::c_int = 0x5405; +pub const TCSETA: ::c_int = 0x5406; +pub const TCSETAW: ::c_int = 0x5407; +pub const TCSETAF: ::c_int = 0x5408; +pub const TCSBRK: ::c_int = 0x5409; +pub const TCXONC: ::c_int = 0x540A; +pub const TCFLSH: ::c_int = 0x540B; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x540F; +pub const TIOCSPGRP: ::c_int = 0x5410; +pub const TIOCOUTQ: ::c_int = 0x5411; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x5413; +pub const TIOCSWINSZ: ::c_int = 0x5414; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x541B; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +// Syscall table +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_break: ::c_long = 17; +pub const SYS_oldstat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_umount: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_stime: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_oldfstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_stty: ::c_long = 31; +pub const SYS_gtty: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_ftime: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_prof: ::c_long = 44; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_lock: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_mpx: ::c_long = 56; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_ulimit: ::c_long = 58; +pub const SYS_oldolduname: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_oldlstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_readdir: ::c_long = 89; +pub const SYS_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_profil: ::c_long = 98; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_ioperm: ::c_long = 101; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_olduname: ::c_long = 109; +pub const SYS_iopl: ::c_long = 110; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_idle: ::c_long = 112; +pub const SYS_vm86old: ::c_long = 113; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_modify_ldt: ::c_long = 123; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_afs_syscall: ::c_long = 137; +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_vm86: ::c_long = 166; +pub const SYS_query_module: ::c_long = 167; +pub const SYS_poll: ::c_long = 168; +pub const SYS_nfsservctl: ::c_long = 169; +pub const SYS_setresgid: ::c_long = 170; +pub const SYS_getresgid: ::c_long = 171; +pub const SYS_prctl: ::c_long = 172; +pub const SYS_rt_sigreturn: ::c_long = 173; +pub const SYS_rt_sigaction: ::c_long = 174; +pub const SYS_rt_sigprocmask: ::c_long = 175; +pub const SYS_rt_sigpending: ::c_long = 176; +pub const SYS_rt_sigtimedwait: ::c_long = 177; +pub const SYS_rt_sigqueueinfo: ::c_long = 178; +pub const SYS_rt_sigsuspend: ::c_long = 179; +pub const SYS_pread64: ::c_long = 180; +pub const SYS_pwrite64: ::c_long = 181; +pub const SYS_chown: ::c_long = 182; +pub const SYS_getcwd: ::c_long = 183; +pub const SYS_capget: ::c_long = 184; +pub const SYS_capset: ::c_long = 185; +pub const SYS_sigaltstack: ::c_long = 186; +pub const SYS_sendfile: ::c_long = 187; +pub const SYS_getpmsg: ::c_long = 188; +pub const SYS_putpmsg: ::c_long = 189; +pub const SYS_vfork: ::c_long = 190; +pub const SYS_ugetrlimit: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_lchown32: ::c_long = 198; +pub const SYS_getuid32: ::c_long = 199; +pub const SYS_getgid32: ::c_long = 200; +pub const SYS_geteuid32: ::c_long = 201; +pub const SYS_getegid32: ::c_long = 202; +pub const SYS_setreuid32: ::c_long = 203; +pub const SYS_setregid32: ::c_long = 204; +pub const SYS_getgroups32: ::c_long = 205; +pub const SYS_setgroups32: ::c_long = 206; +pub const SYS_fchown32: ::c_long = 207; +pub const SYS_setresuid32: ::c_long = 208; +pub const SYS_getresuid32: ::c_long = 209; +pub const SYS_setresgid32: ::c_long = 210; +pub const SYS_getresgid32: ::c_long = 211; +pub const SYS_chown32: ::c_long = 212; +pub const SYS_setuid32: ::c_long = 213; +pub const SYS_setgid32: ::c_long = 214; +pub const SYS_setfsuid32: ::c_long = 215; +pub const SYS_setfsgid32: ::c_long = 216; +pub const SYS_pivot_root: ::c_long = 217; +pub const SYS_mincore: ::c_long = 218; +pub const SYS_madvise: ::c_long = 219; +pub const SYS_getdents64: ::c_long = 220; +pub const SYS_fcntl64: ::c_long = 221; +pub const SYS_gettid: ::c_long = 224; +pub const SYS_readahead: ::c_long = 225; +pub const SYS_setxattr: ::c_long = 226; +pub const SYS_lsetxattr: ::c_long = 227; +pub const SYS_fsetxattr: ::c_long = 228; +pub const SYS_getxattr: ::c_long = 229; +pub const SYS_lgetxattr: ::c_long = 230; +pub const SYS_fgetxattr: ::c_long = 231; +pub const SYS_listxattr: ::c_long = 232; +pub const SYS_llistxattr: ::c_long = 233; +pub const SYS_flistxattr: ::c_long = 234; +pub const SYS_removexattr: ::c_long = 235; +pub const SYS_lremovexattr: ::c_long = 236; +pub const SYS_fremovexattr: ::c_long = 237; +pub const SYS_tkill: ::c_long = 238; +pub const SYS_sendfile64: ::c_long = 239; +pub const SYS_futex: ::c_long = 240; +pub const SYS_sched_setaffinity: ::c_long = 241; +pub const SYS_sched_getaffinity: ::c_long = 242; +pub const SYS_set_thread_area: ::c_long = 243; +pub const SYS_get_thread_area: ::c_long = 244; +pub const SYS_io_setup: ::c_long = 245; +pub const SYS_io_destroy: ::c_long = 246; +pub const SYS_io_getevents: ::c_long = 247; +pub const SYS_io_submit: ::c_long = 248; +pub const SYS_io_cancel: ::c_long = 249; +pub const SYS_fadvise64: ::c_long = 250; +pub const SYS_exit_group: ::c_long = 252; +pub const SYS_lookup_dcookie: ::c_long = 253; +pub const SYS_epoll_create: ::c_long = 254; +pub const SYS_epoll_ctl: ::c_long = 255; +pub const SYS_epoll_wait: ::c_long = 256; +pub const SYS_remap_file_pages: ::c_long = 257; +pub const SYS_set_tid_address: ::c_long = 258; +pub const SYS_timer_create: ::c_long = 259; +pub const SYS_timer_settime: ::c_long = 260; +pub const SYS_timer_gettime: ::c_long = 261; +pub const SYS_timer_getoverrun: ::c_long = 262; +pub const SYS_timer_delete: ::c_long = 263; +pub const SYS_clock_settime: ::c_long = 264; +pub const SYS_clock_gettime: ::c_long = 265; +pub const SYS_clock_getres: ::c_long = 266; +pub const SYS_clock_nanosleep: ::c_long = 267; +pub const SYS_statfs64: ::c_long = 268; +pub const SYS_fstatfs64: ::c_long = 269; +pub const SYS_tgkill: ::c_long = 270; +pub const SYS_utimes: ::c_long = 271; +pub const SYS_fadvise64_64: ::c_long = 272; +pub const SYS_vserver: ::c_long = 273; +pub const SYS_mbind: ::c_long = 274; +pub const SYS_get_mempolicy: ::c_long = 275; +pub const SYS_set_mempolicy: ::c_long = 276; +pub const SYS_mq_open: ::c_long = 277; +pub const SYS_mq_unlink: ::c_long = 278; +pub const SYS_mq_timedsend: ::c_long = 279; +pub const SYS_mq_timedreceive: ::c_long = 280; +pub const SYS_mq_notify: ::c_long = 281; +pub const SYS_mq_getsetattr: ::c_long = 282; +pub const SYS_kexec_load: ::c_long = 283; +pub const SYS_waitid: ::c_long = 284; +pub const SYS_add_key: ::c_long = 286; +pub const SYS_request_key: ::c_long = 287; +pub const SYS_keyctl: ::c_long = 288; +pub const SYS_ioprio_set: ::c_long = 289; +pub const SYS_ioprio_get: ::c_long = 290; +pub const SYS_inotify_init: ::c_long = 291; +pub const SYS_inotify_add_watch: ::c_long = 292; +pub const SYS_inotify_rm_watch: ::c_long = 293; +pub const SYS_migrate_pages: ::c_long = 294; +pub const SYS_openat: ::c_long = 295; +pub const SYS_mkdirat: ::c_long = 296; +pub const SYS_mknodat: ::c_long = 297; +pub const SYS_fchownat: ::c_long = 298; +pub const SYS_futimesat: ::c_long = 299; +pub const SYS_fstatat64: ::c_long = 300; +pub const SYS_unlinkat: ::c_long = 301; +pub const SYS_renameat: ::c_long = 302; +pub const SYS_linkat: ::c_long = 303; +pub const SYS_symlinkat: ::c_long = 304; +pub const SYS_readlinkat: ::c_long = 305; +pub const SYS_fchmodat: ::c_long = 306; +pub const SYS_faccessat: ::c_long = 307; +pub const SYS_pselect6: ::c_long = 308; +pub const SYS_ppoll: ::c_long = 309; +pub const SYS_unshare: ::c_long = 310; +pub const SYS_set_robust_list: ::c_long = 311; +pub const SYS_get_robust_list: ::c_long = 312; +pub const SYS_splice: ::c_long = 313; +pub const SYS_sync_file_range: ::c_long = 314; +pub const SYS_tee: ::c_long = 315; +pub const SYS_vmsplice: ::c_long = 316; +pub const SYS_move_pages: ::c_long = 317; +pub const SYS_getcpu: ::c_long = 318; +pub const SYS_epoll_pwait: ::c_long = 319; +pub const SYS_utimensat: ::c_long = 320; +pub const SYS_signalfd: ::c_long = 321; +pub const SYS_timerfd_create: ::c_long = 322; +pub const SYS_eventfd: ::c_long = 323; +pub const SYS_fallocate: ::c_long = 324; +pub const SYS_timerfd_settime: ::c_long = 325; +pub const SYS_timerfd_gettime: ::c_long = 326; +pub const SYS_signalfd4: ::c_long = 327; +pub const SYS_eventfd2: ::c_long = 328; +pub const SYS_epoll_create1: ::c_long = 329; +pub const SYS_dup3: ::c_long = 330; +pub const SYS_pipe2: ::c_long = 331; +pub const SYS_inotify_init1: ::c_long = 332; +pub const SYS_preadv: ::c_long = 333; +pub const SYS_pwritev: ::c_long = 334; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 335; +pub const SYS_perf_event_open: ::c_long = 336; +pub const SYS_recvmmsg: ::c_long = 337; +pub const SYS_fanotify_init: ::c_long = 338; +pub const SYS_fanotify_mark: ::c_long = 339; +pub const SYS_prlimit64: ::c_long = 340; +pub const SYS_name_to_handle_at: ::c_long = 341; +pub const SYS_open_by_handle_at: ::c_long = 342; +pub const SYS_clock_adjtime: ::c_long = 343; +pub const SYS_syncfs: ::c_long = 344; +pub const SYS_sendmmsg: ::c_long = 345; +pub const SYS_setns: ::c_long = 346; +pub const SYS_process_vm_readv: ::c_long = 347; +pub const SYS_process_vm_writev: ::c_long = 348; +pub const SYS_kcmp: ::c_long = 349; +pub const SYS_finit_module: ::c_long = 350; +pub const SYS_sched_setattr: ::c_long = 351; +pub const SYS_sched_getattr: ::c_long = 352; +pub const SYS_renameat2: ::c_long = 353; +pub const SYS_seccomp: ::c_long = 354; +pub const SYS_getrandom: ::c_long = 355; +pub const SYS_memfd_create: ::c_long = 356; +pub const SYS_bpf: ::c_long = 357; +pub const SYS_execveat: ::c_long = 358; +pub const SYS_socket: ::c_long = 359; +pub const SYS_socketpair: ::c_long = 360; +pub const SYS_bind: ::c_long = 361; +pub const SYS_connect: ::c_long = 362; +pub const SYS_listen: ::c_long = 363; +pub const SYS_accept4: ::c_long = 364; +pub const SYS_getsockopt: ::c_long = 365; +pub const SYS_setsockopt: ::c_long = 366; +pub const SYS_getsockname: ::c_long = 367; +pub const SYS_getpeername: ::c_long = 368; +pub const SYS_sendto: ::c_long = 369; +pub const SYS_sendmsg: ::c_long = 370; +pub const SYS_recvfrom: ::c_long = 371; +pub const SYS_recvmsg: ::c_long = 372; +pub const SYS_shutdown: ::c_long = 373; +pub const SYS_userfaultfd: ::c_long = 374; +pub const SYS_membarrier: ::c_long = 375; +pub const SYS_mlock2: ::c_long = 376; +pub const SYS_copy_file_range: ::c_long = 377; +pub const SYS_preadv2: ::c_long = 378; +pub const SYS_pwritev2: ::c_long = 379; +pub const SYS_pkey_mprotect: ::c_long = 380; +pub const SYS_pkey_alloc: ::c_long = 381; +pub const SYS_pkey_free: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; + +// offsets in user_regs_structs, from sys/reg.h +pub const EBX: ::c_int = 0; +pub const ECX: ::c_int = 1; +pub const EDX: ::c_int = 2; +pub const ESI: ::c_int = 3; +pub const EDI: ::c_int = 4; +pub const EBP: ::c_int = 5; +pub const EAX: ::c_int = 6; +pub const DS: ::c_int = 7; +pub const ES: ::c_int = 8; +pub const FS: ::c_int = 9; +pub const GS: ::c_int = 10; +pub const ORIG_EAX: ::c_int = 11; +pub const EIP: ::c_int = 12; +pub const CS: ::c_int = 13; +pub const EFL: ::c_int = 14; +pub const UESP: ::c_int = 15; +pub const SS: ::c_int = 16; + +extern "C" { + pub fn getrandom( + buf: *mut ::c_void, + buflen: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/aarch64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/aarch64/align.rs new file mode 100644 index 0000000..8e94996 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/aarch64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs new file mode 100644 index 0000000..876ff3c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -0,0 +1,655 @@ +pub type c_char = u8; +pub type __u64 = ::c_ulonglong; +pub type wchar_t = u32; +pub type nlink_t = u32; +pub type blksize_t = ::c_int; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad0: ::c_ulong, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + __pad1: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_uint; 2], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad0: ::c_ulong, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + __pad1: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_uint; 2], + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong, + } +} + +pub const O_APPEND: ::c_int = 1024; +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_LARGEFILE: ::c_int = 0x20000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_ASYNC: ::c_int = 0x2000; + +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOL_SOCKET: ::c_int = 1; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_SETOWN: ::c_int = 8; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const MINSIGSTKSZ: ::size_t = 6144; +pub const SIGSTKSZ: ::size_t = 12288; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const SYS_io_setup: ::c_long = 0; +pub const SYS_io_destroy: ::c_long = 1; +pub const SYS_io_submit: ::c_long = 2; +pub const SYS_io_cancel: ::c_long = 3; +pub const SYS_io_getevents: ::c_long = 4; +pub const SYS_setxattr: ::c_long = 5; +pub const SYS_lsetxattr: ::c_long = 6; +pub const SYS_fsetxattr: ::c_long = 7; +pub const SYS_getxattr: ::c_long = 8; +pub const SYS_lgetxattr: ::c_long = 9; +pub const SYS_fgetxattr: ::c_long = 10; +pub const SYS_listxattr: ::c_long = 11; +pub const SYS_llistxattr: ::c_long = 12; +pub const SYS_flistxattr: ::c_long = 13; +pub const SYS_removexattr: ::c_long = 14; +pub const SYS_lremovexattr: ::c_long = 15; +pub const SYS_fremovexattr: ::c_long = 16; +pub const SYS_getcwd: ::c_long = 17; +pub const SYS_lookup_dcookie: ::c_long = 18; +pub const SYS_eventfd2: ::c_long = 19; +pub const SYS_epoll_create1: ::c_long = 20; +pub const SYS_epoll_ctl: ::c_long = 21; +pub const SYS_epoll_pwait: ::c_long = 22; +pub const SYS_dup: ::c_long = 23; +pub const SYS_dup3: ::c_long = 24; +pub const SYS_fcntl: ::c_long = 25; +pub const SYS_inotify_init1: ::c_long = 26; +pub const SYS_inotify_add_watch: ::c_long = 27; +pub const SYS_inotify_rm_watch: ::c_long = 28; +pub const SYS_ioctl: ::c_long = 29; +pub const SYS_ioprio_set: ::c_long = 30; +pub const SYS_ioprio_get: ::c_long = 31; +pub const SYS_flock: ::c_long = 32; +pub const SYS_mknodat: ::c_long = 33; +pub const SYS_mkdirat: ::c_long = 34; +pub const SYS_unlinkat: ::c_long = 35; +pub const SYS_symlinkat: ::c_long = 36; +pub const SYS_linkat: ::c_long = 37; +pub const SYS_renameat: ::c_long = 38; +pub const SYS_umount2: ::c_long = 39; +pub const SYS_mount: ::c_long = 40; +pub const SYS_pivot_root: ::c_long = 41; +pub const SYS_nfsservctl: ::c_long = 42; +pub const SYS_fallocate: ::c_long = 47; +pub const SYS_faccessat: ::c_long = 48; +pub const SYS_chdir: ::c_long = 49; +pub const SYS_fchdir: ::c_long = 50; +pub const SYS_chroot: ::c_long = 51; +pub const SYS_fchmod: ::c_long = 52; +pub const SYS_fchmodat: ::c_long = 53; +pub const SYS_fchownat: ::c_long = 54; +pub const SYS_fchown: ::c_long = 55; +pub const SYS_openat: ::c_long = 56; +pub const SYS_close: ::c_long = 57; +pub const SYS_vhangup: ::c_long = 58; +pub const SYS_pipe2: ::c_long = 59; +pub const SYS_quotactl: ::c_long = 60; +pub const SYS_getdents64: ::c_long = 61; +pub const SYS_lseek: ::c_long = 62; +pub const SYS_read: ::c_long = 63; +pub const SYS_write: ::c_long = 64; +pub const SYS_readv: ::c_long = 65; +pub const SYS_writev: ::c_long = 66; +pub const SYS_pread64: ::c_long = 67; +pub const SYS_pwrite64: ::c_long = 68; +pub const SYS_preadv: ::c_long = 69; +pub const SYS_pwritev: ::c_long = 70; +pub const SYS_pselect6: ::c_long = 72; +pub const SYS_ppoll: ::c_long = 73; +pub const SYS_signalfd4: ::c_long = 74; +pub const SYS_vmsplice: ::c_long = 75; +pub const SYS_splice: ::c_long = 76; +pub const SYS_tee: ::c_long = 77; +pub const SYS_readlinkat: ::c_long = 78; +pub const SYS_newfstatat: ::c_long = 79; +pub const SYS_fstat: ::c_long = 80; +pub const SYS_sync: ::c_long = 81; +pub const SYS_fsync: ::c_long = 82; +pub const SYS_fdatasync: ::c_long = 83; +pub const SYS_sync_file_range: ::c_long = 84; +pub const SYS_timerfd_create: ::c_long = 85; +pub const SYS_timerfd_settime: ::c_long = 86; +pub const SYS_timerfd_gettime: ::c_long = 87; +pub const SYS_utimensat: ::c_long = 88; +pub const SYS_acct: ::c_long = 89; +pub const SYS_capget: ::c_long = 90; +pub const SYS_capset: ::c_long = 91; +pub const SYS_personality: ::c_long = 92; +pub const SYS_exit: ::c_long = 93; +pub const SYS_exit_group: ::c_long = 94; +pub const SYS_waitid: ::c_long = 95; +pub const SYS_set_tid_address: ::c_long = 96; +pub const SYS_unshare: ::c_long = 97; +pub const SYS_futex: ::c_long = 98; +pub const SYS_set_robust_list: ::c_long = 99; +pub const SYS_get_robust_list: ::c_long = 100; +pub const SYS_nanosleep: ::c_long = 101; +pub const SYS_getitimer: ::c_long = 102; +pub const SYS_setitimer: ::c_long = 103; +pub const SYS_kexec_load: ::c_long = 104; +pub const SYS_init_module: ::c_long = 105; +pub const SYS_delete_module: ::c_long = 106; +pub const SYS_timer_create: ::c_long = 107; +pub const SYS_timer_gettime: ::c_long = 108; +pub const SYS_timer_getoverrun: ::c_long = 109; +pub const SYS_timer_settime: ::c_long = 110; +pub const SYS_timer_delete: ::c_long = 111; +pub const SYS_clock_settime: ::c_long = 112; +pub const SYS_clock_gettime: ::c_long = 113; +pub const SYS_clock_getres: ::c_long = 114; +pub const SYS_clock_nanosleep: ::c_long = 115; +pub const SYS_syslog: ::c_long = 116; +pub const SYS_ptrace: ::c_long = 117; +pub const SYS_sched_setparam: ::c_long = 118; +pub const SYS_sched_setscheduler: ::c_long = 119; +pub const SYS_sched_getscheduler: ::c_long = 120; +pub const SYS_sched_getparam: ::c_long = 121; +pub const SYS_sched_setaffinity: ::c_long = 122; +pub const SYS_sched_getaffinity: ::c_long = 123; +pub const SYS_sched_yield: ::c_long = 124; +pub const SYS_sched_get_priority_max: ::c_long = 125; +pub const SYS_sched_get_priority_min: ::c_long = 126; +pub const SYS_sched_rr_get_interval: ::c_long = 127; +pub const SYS_restart_syscall: ::c_long = 128; +pub const SYS_kill: ::c_long = 129; +pub const SYS_tkill: ::c_long = 130; +pub const SYS_tgkill: ::c_long = 131; +pub const SYS_sigaltstack: ::c_long = 132; +pub const SYS_rt_sigsuspend: ::c_long = 133; +pub const SYS_rt_sigaction: ::c_long = 134; +pub const SYS_rt_sigprocmask: ::c_long = 135; +pub const SYS_rt_sigpending: ::c_long = 136; +pub const SYS_rt_sigtimedwait: ::c_long = 137; +pub const SYS_rt_sigqueueinfo: ::c_long = 138; +pub const SYS_rt_sigreturn: ::c_long = 139; +pub const SYS_setpriority: ::c_long = 140; +pub const SYS_getpriority: ::c_long = 141; +pub const SYS_reboot: ::c_long = 142; +pub const SYS_setregid: ::c_long = 143; +pub const SYS_setgid: ::c_long = 144; +pub const SYS_setreuid: ::c_long = 145; +pub const SYS_setuid: ::c_long = 146; +pub const SYS_setresuid: ::c_long = 147; +pub const SYS_getresuid: ::c_long = 148; +pub const SYS_setresgid: ::c_long = 149; +pub const SYS_getresgid: ::c_long = 150; +pub const SYS_setfsuid: ::c_long = 151; +pub const SYS_setfsgid: ::c_long = 152; +pub const SYS_times: ::c_long = 153; +pub const SYS_setpgid: ::c_long = 154; +pub const SYS_getpgid: ::c_long = 155; +pub const SYS_getsid: ::c_long = 156; +pub const SYS_setsid: ::c_long = 157; +pub const SYS_getgroups: ::c_long = 158; +pub const SYS_setgroups: ::c_long = 159; +pub const SYS_uname: ::c_long = 160; +pub const SYS_sethostname: ::c_long = 161; +pub const SYS_setdomainname: ::c_long = 162; +pub const SYS_getrlimit: ::c_long = 163; +pub const SYS_setrlimit: ::c_long = 164; +pub const SYS_getrusage: ::c_long = 165; +pub const SYS_umask: ::c_long = 166; +pub const SYS_prctl: ::c_long = 167; +pub const SYS_getcpu: ::c_long = 168; +pub const SYS_gettimeofday: ::c_long = 169; +pub const SYS_settimeofday: ::c_long = 170; +pub const SYS_adjtimex: ::c_long = 171; +pub const SYS_getpid: ::c_long = 172; +pub const SYS_getppid: ::c_long = 173; +pub const SYS_getuid: ::c_long = 174; +pub const SYS_geteuid: ::c_long = 175; +pub const SYS_getgid: ::c_long = 176; +pub const SYS_getegid: ::c_long = 177; +pub const SYS_gettid: ::c_long = 178; +pub const SYS_sysinfo: ::c_long = 179; +pub const SYS_mq_open: ::c_long = 180; +pub const SYS_mq_unlink: ::c_long = 181; +pub const SYS_mq_timedsend: ::c_long = 182; +pub const SYS_mq_timedreceive: ::c_long = 183; +pub const SYS_mq_notify: ::c_long = 184; +pub const SYS_mq_getsetattr: ::c_long = 185; +pub const SYS_msgget: ::c_long = 186; +pub const SYS_msgctl: ::c_long = 187; +pub const SYS_msgrcv: ::c_long = 188; +pub const SYS_msgsnd: ::c_long = 189; +pub const SYS_semget: ::c_long = 190; +pub const SYS_semctl: ::c_long = 191; +pub const SYS_semtimedop: ::c_long = 192; +pub const SYS_semop: ::c_long = 193; +pub const SYS_shmget: ::c_long = 194; +pub const SYS_shmctl: ::c_long = 195; +pub const SYS_shmat: ::c_long = 196; +pub const SYS_shmdt: ::c_long = 197; +pub const SYS_socket: ::c_long = 198; +pub const SYS_socketpair: ::c_long = 199; +pub const SYS_bind: ::c_long = 200; +pub const SYS_listen: ::c_long = 201; +pub const SYS_accept: ::c_long = 202; +pub const SYS_connect: ::c_long = 203; +pub const SYS_getsockname: ::c_long = 204; +pub const SYS_getpeername: ::c_long = 205; +pub const SYS_sendto: ::c_long = 206; +pub const SYS_recvfrom: ::c_long = 207; +pub const SYS_setsockopt: ::c_long = 208; +pub const SYS_getsockopt: ::c_long = 209; +pub const SYS_shutdown: ::c_long = 210; +pub const SYS_sendmsg: ::c_long = 211; +pub const SYS_recvmsg: ::c_long = 212; +pub const SYS_readahead: ::c_long = 213; +pub const SYS_brk: ::c_long = 214; +pub const SYS_munmap: ::c_long = 215; +pub const SYS_mremap: ::c_long = 216; +pub const SYS_add_key: ::c_long = 217; +pub const SYS_request_key: ::c_long = 218; +pub const SYS_keyctl: ::c_long = 219; +pub const SYS_clone: ::c_long = 220; +pub const SYS_execve: ::c_long = 221; +pub const SYS_mmap: ::c_long = 222; +pub const SYS_swapon: ::c_long = 224; +pub const SYS_swapoff: ::c_long = 225; +pub const SYS_mprotect: ::c_long = 226; +pub const SYS_msync: ::c_long = 227; +pub const SYS_mlock: ::c_long = 228; +pub const SYS_munlock: ::c_long = 229; +pub const SYS_mlockall: ::c_long = 230; +pub const SYS_munlockall: ::c_long = 231; +pub const SYS_mincore: ::c_long = 232; +pub const SYS_madvise: ::c_long = 233; +pub const SYS_remap_file_pages: ::c_long = 234; +pub const SYS_mbind: ::c_long = 235; +pub const SYS_get_mempolicy: ::c_long = 236; +pub const SYS_set_mempolicy: ::c_long = 237; +pub const SYS_migrate_pages: ::c_long = 238; +pub const SYS_move_pages: ::c_long = 239; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 240; +pub const SYS_perf_event_open: ::c_long = 241; +pub const SYS_accept4: ::c_long = 242; +pub const SYS_recvmmsg: ::c_long = 243; +pub const SYS_wait4: ::c_long = 260; +pub const SYS_prlimit64: ::c_long = 261; +pub const SYS_fanotify_init: ::c_long = 262; +pub const SYS_fanotify_mark: ::c_long = 263; +pub const SYS_name_to_handle_at: ::c_long = 264; +pub const SYS_open_by_handle_at: ::c_long = 265; +pub const SYS_clock_adjtime: ::c_long = 266; +pub const SYS_syncfs: ::c_long = 267; +pub const SYS_setns: ::c_long = 268; +pub const SYS_sendmmsg: ::c_long = 269; +pub const SYS_process_vm_readv: ::c_long = 270; +pub const SYS_process_vm_writev: ::c_long = 271; +pub const SYS_kcmp: ::c_long = 272; +pub const SYS_finit_module: ::c_long = 273; +pub const SYS_sched_setattr: ::c_long = 274; +pub const SYS_sched_getattr: ::c_long = 275; +pub const SYS_renameat2: ::c_long = 276; +pub const SYS_seccomp: ::c_long = 277; +pub const SYS_getrandom: ::c_long = 278; +pub const SYS_memfd_create: ::c_long = 279; +pub const SYS_bpf: ::c_long = 280; +pub const SYS_execveat: ::c_long = 281; +pub const SYS_userfaultfd: ::c_long = 282; +pub const SYS_membarrier: ::c_long = 283; +pub const SYS_mlock2: ::c_long = 284; +pub const SYS_copy_file_range: ::c_long = 285; +pub const SYS_preadv2: ::c_long = 286; +pub const SYS_pwritev2: ::c_long = 287; +pub const SYS_pkey_mprotect: ::c_long = 288; +pub const SYS_pkey_alloc: ::c_long = 289; +pub const SYS_pkey_free: ::c_long = 290; +pub const SYS_statx: ::c_long = 291; + +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const TIOCINQ: ::c_int = ::FIONREAD; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const FIOCLEX: ::c_int = 0x5451; +pub const FIONCLEX: ::c_int = 0x5450; +pub const FIONBIO: ::c_int = 0x5421; +pub const EDEADLK: ::c_int = 35; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const EXTPROC: ::tcflag_t = 0x00010000; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; +pub const TCGETS: ::c_int = 0x5401; +pub const TCSETS: ::c_int = 0x5402; +pub const TCSETSW: ::c_int = 0x5403; +pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETA: ::c_int = 0x5405; +pub const TCSETA: ::c_int = 0x5406; +pub const TCSETAW: ::c_int = 0x5407; +pub const TCSETAF: ::c_int = 0x5408; +pub const TCSBRK: ::c_int = 0x5409; +pub const TCXONC: ::c_int = 0x540A; +pub const TCFLSH: ::c_int = 0x540B; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x540F; +pub const TIOCSPGRP: ::c_int = 0x5410; +pub const TIOCOUTQ: ::c_int = 0x5411; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x5413; +pub const TIOCSWINSZ: ::c_int = 0x5414; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x541B; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +extern "C" { + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/mips64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/mips64.rs new file mode 100644 index 0000000..2c41050 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -0,0 +1,754 @@ +pub type c_char = i8; +pub type wchar_t = i32; +pub type __u64 = ::c_ulong; +pub type nlink_t = u64; +pub type blksize_t = i64; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + __pad1: [::c_int; 3], + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: [::c_uint; 2], + pub st_size: ::off_t, + __pad3: ::c_int, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + __pad4: ::c_uint, + pub st_blocks: ::blkcnt_t, + __pad5: [::c_int; 14], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + __pad1: [::c_int; 3], + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: [::c_uint; 2], + pub st_size: ::off_t, + __pad3: ::c_int, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + __pad4: ::c_uint, + pub st_blocks: ::blkcnt_t, + __pad5: [::c_int; 14], + } + + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 5], + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 5], + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_int, + __pad1: ::c_int, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } +} + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + +pub const SYS_read: ::c_long = 5000 + 0; +pub const SYS_write: ::c_long = 5000 + 1; +pub const SYS_open: ::c_long = 5000 + 2; +pub const SYS_close: ::c_long = 5000 + 3; +pub const SYS_stat: ::c_long = 5000 + 4; +pub const SYS_fstat: ::c_long = 5000 + 5; +pub const SYS_lstat: ::c_long = 5000 + 6; +pub const SYS_poll: ::c_long = 5000 + 7; +pub const SYS_lseek: ::c_long = 5000 + 8; +pub const SYS_mmap: ::c_long = 5000 + 9; +pub const SYS_mprotect: ::c_long = 5000 + 10; +pub const SYS_munmap: ::c_long = 5000 + 11; +pub const SYS_brk: ::c_long = 5000 + 12; +pub const SYS_rt_sigaction: ::c_long = 5000 + 13; +pub const SYS_rt_sigprocmask: ::c_long = 5000 + 14; +pub const SYS_ioctl: ::c_long = 5000 + 15; +pub const SYS_pread64: ::c_long = 5000 + 16; +pub const SYS_pwrite64: ::c_long = 5000 + 17; +pub const SYS_readv: ::c_long = 5000 + 18; +pub const SYS_writev: ::c_long = 5000 + 19; +pub const SYS_access: ::c_long = 5000 + 20; +pub const SYS_pipe: ::c_long = 5000 + 21; +pub const SYS__newselect: ::c_long = 5000 + 22; +pub const SYS_sched_yield: ::c_long = 5000 + 23; +pub const SYS_mremap: ::c_long = 5000 + 24; +pub const SYS_msync: ::c_long = 5000 + 25; +pub const SYS_mincore: ::c_long = 5000 + 26; +pub const SYS_madvise: ::c_long = 5000 + 27; +pub const SYS_shmget: ::c_long = 5000 + 28; +pub const SYS_shmat: ::c_long = 5000 + 29; +pub const SYS_shmctl: ::c_long = 5000 + 30; +pub const SYS_dup: ::c_long = 5000 + 31; +pub const SYS_dup2: ::c_long = 5000 + 32; +pub const SYS_pause: ::c_long = 5000 + 33; +pub const SYS_nanosleep: ::c_long = 5000 + 34; +pub const SYS_getitimer: ::c_long = 5000 + 35; +pub const SYS_setitimer: ::c_long = 5000 + 36; +pub const SYS_alarm: ::c_long = 5000 + 37; +pub const SYS_getpid: ::c_long = 5000 + 38; +pub const SYS_sendfile: ::c_long = 5000 + 39; +pub const SYS_socket: ::c_long = 5000 + 40; +pub const SYS_connect: ::c_long = 5000 + 41; +pub const SYS_accept: ::c_long = 5000 + 42; +pub const SYS_sendto: ::c_long = 5000 + 43; +pub const SYS_recvfrom: ::c_long = 5000 + 44; +pub const SYS_sendmsg: ::c_long = 5000 + 45; +pub const SYS_recvmsg: ::c_long = 5000 + 46; +pub const SYS_shutdown: ::c_long = 5000 + 47; +pub const SYS_bind: ::c_long = 5000 + 48; +pub const SYS_listen: ::c_long = 5000 + 49; +pub const SYS_getsockname: ::c_long = 5000 + 50; +pub const SYS_getpeername: ::c_long = 5000 + 51; +pub const SYS_socketpair: ::c_long = 5000 + 52; +pub const SYS_setsockopt: ::c_long = 5000 + 53; +pub const SYS_getsockopt: ::c_long = 5000 + 54; +pub const SYS_clone: ::c_long = 5000 + 55; +pub const SYS_fork: ::c_long = 5000 + 56; +pub const SYS_execve: ::c_long = 5000 + 57; +pub const SYS_exit: ::c_long = 5000 + 58; +pub const SYS_wait4: ::c_long = 5000 + 59; +pub const SYS_kill: ::c_long = 5000 + 60; +pub const SYS_uname: ::c_long = 5000 + 61; +pub const SYS_semget: ::c_long = 5000 + 62; +pub const SYS_semop: ::c_long = 5000 + 63; +pub const SYS_semctl: ::c_long = 5000 + 64; +pub const SYS_shmdt: ::c_long = 5000 + 65; +pub const SYS_msgget: ::c_long = 5000 + 66; +pub const SYS_msgsnd: ::c_long = 5000 + 67; +pub const SYS_msgrcv: ::c_long = 5000 + 68; +pub const SYS_msgctl: ::c_long = 5000 + 69; +pub const SYS_fcntl: ::c_long = 5000 + 70; +pub const SYS_flock: ::c_long = 5000 + 71; +pub const SYS_fsync: ::c_long = 5000 + 72; +pub const SYS_fdatasync: ::c_long = 5000 + 73; +pub const SYS_truncate: ::c_long = 5000 + 74; +pub const SYS_ftruncate: ::c_long = 5000 + 75; +pub const SYS_getdents: ::c_long = 5000 + 76; +pub const SYS_getcwd: ::c_long = 5000 + 77; +pub const SYS_chdir: ::c_long = 5000 + 78; +pub const SYS_fchdir: ::c_long = 5000 + 79; +pub const SYS_rename: ::c_long = 5000 + 80; +pub const SYS_mkdir: ::c_long = 5000 + 81; +pub const SYS_rmdir: ::c_long = 5000 + 82; +pub const SYS_creat: ::c_long = 5000 + 83; +pub const SYS_link: ::c_long = 5000 + 84; +pub const SYS_unlink: ::c_long = 5000 + 85; +pub const SYS_symlink: ::c_long = 5000 + 86; +pub const SYS_readlink: ::c_long = 5000 + 87; +pub const SYS_chmod: ::c_long = 5000 + 88; +pub const SYS_fchmod: ::c_long = 5000 + 89; +pub const SYS_chown: ::c_long = 5000 + 90; +pub const SYS_fchown: ::c_long = 5000 + 91; +pub const SYS_lchown: ::c_long = 5000 + 92; +pub const SYS_umask: ::c_long = 5000 + 93; +pub const SYS_gettimeofday: ::c_long = 5000 + 94; +pub const SYS_getrlimit: ::c_long = 5000 + 95; +pub const SYS_getrusage: ::c_long = 5000 + 96; +pub const SYS_sysinfo: ::c_long = 5000 + 97; +pub const SYS_times: ::c_long = 5000 + 98; +pub const SYS_ptrace: ::c_long = 5000 + 99; +pub const SYS_getuid: ::c_long = 5000 + 100; +pub const SYS_syslog: ::c_long = 5000 + 101; +pub const SYS_getgid: ::c_long = 5000 + 102; +pub const SYS_setuid: ::c_long = 5000 + 103; +pub const SYS_setgid: ::c_long = 5000 + 104; +pub const SYS_geteuid: ::c_long = 5000 + 105; +pub const SYS_getegid: ::c_long = 5000 + 106; +pub const SYS_setpgid: ::c_long = 5000 + 107; +pub const SYS_getppid: ::c_long = 5000 + 108; +pub const SYS_getpgrp: ::c_long = 5000 + 109; +pub const SYS_setsid: ::c_long = 5000 + 110; +pub const SYS_setreuid: ::c_long = 5000 + 111; +pub const SYS_setregid: ::c_long = 5000 + 112; +pub const SYS_getgroups: ::c_long = 5000 + 113; +pub const SYS_setgroups: ::c_long = 5000 + 114; +pub const SYS_setresuid: ::c_long = 5000 + 115; +pub const SYS_getresuid: ::c_long = 5000 + 116; +pub const SYS_setresgid: ::c_long = 5000 + 117; +pub const SYS_getresgid: ::c_long = 5000 + 118; +pub const SYS_getpgid: ::c_long = 5000 + 119; +pub const SYS_setfsuid: ::c_long = 5000 + 120; +pub const SYS_setfsgid: ::c_long = 5000 + 121; +pub const SYS_getsid: ::c_long = 5000 + 122; +pub const SYS_capget: ::c_long = 5000 + 123; +pub const SYS_capset: ::c_long = 5000 + 124; +pub const SYS_rt_sigpending: ::c_long = 5000 + 125; +pub const SYS_rt_sigtimedwait: ::c_long = 5000 + 126; +pub const SYS_rt_sigqueueinfo: ::c_long = 5000 + 127; +pub const SYS_rt_sigsuspend: ::c_long = 5000 + 128; +pub const SYS_sigaltstack: ::c_long = 5000 + 129; +pub const SYS_utime: ::c_long = 5000 + 130; +pub const SYS_mknod: ::c_long = 5000 + 131; +pub const SYS_personality: ::c_long = 5000 + 132; +pub const SYS_ustat: ::c_long = 5000 + 133; +pub const SYS_statfs: ::c_long = 5000 + 134; +pub const SYS_fstatfs: ::c_long = 5000 + 135; +pub const SYS_sysfs: ::c_long = 5000 + 136; +pub const SYS_getpriority: ::c_long = 5000 + 137; +pub const SYS_setpriority: ::c_long = 5000 + 138; +pub const SYS_sched_setparam: ::c_long = 5000 + 139; +pub const SYS_sched_getparam: ::c_long = 5000 + 140; +pub const SYS_sched_setscheduler: ::c_long = 5000 + 141; +pub const SYS_sched_getscheduler: ::c_long = 5000 + 142; +pub const SYS_sched_get_priority_max: ::c_long = 5000 + 143; +pub const SYS_sched_get_priority_min: ::c_long = 5000 + 144; +pub const SYS_sched_rr_get_interval: ::c_long = 5000 + 145; +pub const SYS_mlock: ::c_long = 5000 + 146; +pub const SYS_munlock: ::c_long = 5000 + 147; +pub const SYS_mlockall: ::c_long = 5000 + 148; +pub const SYS_munlockall: ::c_long = 5000 + 149; +pub const SYS_vhangup: ::c_long = 5000 + 150; +pub const SYS_pivot_root: ::c_long = 5000 + 151; +pub const SYS__sysctl: ::c_long = 5000 + 152; +pub const SYS_prctl: ::c_long = 5000 + 153; +pub const SYS_adjtimex: ::c_long = 5000 + 154; +pub const SYS_setrlimit: ::c_long = 5000 + 155; +pub const SYS_chroot: ::c_long = 5000 + 156; +pub const SYS_sync: ::c_long = 5000 + 157; +pub const SYS_acct: ::c_long = 5000 + 158; +pub const SYS_settimeofday: ::c_long = 5000 + 159; +pub const SYS_mount: ::c_long = 5000 + 160; +pub const SYS_umount2: ::c_long = 5000 + 161; +pub const SYS_swapon: ::c_long = 5000 + 162; +pub const SYS_swapoff: ::c_long = 5000 + 163; +pub const SYS_reboot: ::c_long = 5000 + 164; +pub const SYS_sethostname: ::c_long = 5000 + 165; +pub const SYS_setdomainname: ::c_long = 5000 + 166; +pub const SYS_create_module: ::c_long = 5000 + 167; +pub const SYS_init_module: ::c_long = 5000 + 168; +pub const SYS_delete_module: ::c_long = 5000 + 169; +pub const SYS_get_kernel_syms: ::c_long = 5000 + 170; +pub const SYS_query_module: ::c_long = 5000 + 171; +pub const SYS_quotactl: ::c_long = 5000 + 172; +pub const SYS_nfsservctl: ::c_long = 5000 + 173; +pub const SYS_getpmsg: ::c_long = 5000 + 174; +pub const SYS_putpmsg: ::c_long = 5000 + 175; +pub const SYS_afs_syscall: ::c_long = 5000 + 176; +pub const SYS_gettid: ::c_long = 5000 + 178; +pub const SYS_readahead: ::c_long = 5000 + 179; +pub const SYS_setxattr: ::c_long = 5000 + 180; +pub const SYS_lsetxattr: ::c_long = 5000 + 181; +pub const SYS_fsetxattr: ::c_long = 5000 + 182; +pub const SYS_getxattr: ::c_long = 5000 + 183; +pub const SYS_lgetxattr: ::c_long = 5000 + 184; +pub const SYS_fgetxattr: ::c_long = 5000 + 185; +pub const SYS_listxattr: ::c_long = 5000 + 186; +pub const SYS_llistxattr: ::c_long = 5000 + 187; +pub const SYS_flistxattr: ::c_long = 5000 + 188; +pub const SYS_removexattr: ::c_long = 5000 + 189; +pub const SYS_lremovexattr: ::c_long = 5000 + 190; +pub const SYS_fremovexattr: ::c_long = 5000 + 191; +pub const SYS_tkill: ::c_long = 5000 + 192; +pub const SYS_futex: ::c_long = 5000 + 194; +pub const SYS_sched_setaffinity: ::c_long = 5000 + 195; +pub const SYS_sched_getaffinity: ::c_long = 5000 + 196; +pub const SYS_cacheflush: ::c_long = 5000 + 197; +pub const SYS_cachectl: ::c_long = 5000 + 198; +pub const SYS_sysmips: ::c_long = 5000 + 199; +pub const SYS_io_setup: ::c_long = 5000 + 200; +pub const SYS_io_destroy: ::c_long = 5000 + 201; +pub const SYS_io_getevents: ::c_long = 5000 + 202; +pub const SYS_io_submit: ::c_long = 5000 + 203; +pub const SYS_io_cancel: ::c_long = 5000 + 204; +pub const SYS_exit_group: ::c_long = 5000 + 205; +pub const SYS_lookup_dcookie: ::c_long = 5000 + 206; +pub const SYS_epoll_create: ::c_long = 5000 + 207; +pub const SYS_epoll_ctl: ::c_long = 5000 + 208; +pub const SYS_epoll_wait: ::c_long = 5000 + 209; +pub const SYS_remap_file_pages: ::c_long = 5000 + 210; +pub const SYS_rt_sigreturn: ::c_long = 5000 + 211; +pub const SYS_set_tid_address: ::c_long = 5000 + 212; +pub const SYS_restart_syscall: ::c_long = 5000 + 213; +pub const SYS_semtimedop: ::c_long = 5000 + 214; +pub const SYS_fadvise64: ::c_long = 5000 + 215; +pub const SYS_timer_create: ::c_long = 5000 + 216; +pub const SYS_timer_settime: ::c_long = 5000 + 217; +pub const SYS_timer_gettime: ::c_long = 5000 + 218; +pub const SYS_timer_getoverrun: ::c_long = 5000 + 219; +pub const SYS_timer_delete: ::c_long = 5000 + 220; +pub const SYS_clock_settime: ::c_long = 5000 + 221; +pub const SYS_clock_gettime: ::c_long = 5000 + 222; +pub const SYS_clock_getres: ::c_long = 5000 + 223; +pub const SYS_clock_nanosleep: ::c_long = 5000 + 224; +pub const SYS_tgkill: ::c_long = 5000 + 225; +pub const SYS_utimes: ::c_long = 5000 + 226; +pub const SYS_mbind: ::c_long = 5000 + 227; +pub const SYS_get_mempolicy: ::c_long = 5000 + 228; +pub const SYS_set_mempolicy: ::c_long = 5000 + 229; +pub const SYS_mq_open: ::c_long = 5000 + 230; +pub const SYS_mq_unlink: ::c_long = 5000 + 231; +pub const SYS_mq_timedsend: ::c_long = 5000 + 232; +pub const SYS_mq_timedreceive: ::c_long = 5000 + 233; +pub const SYS_mq_notify: ::c_long = 5000 + 234; +pub const SYS_mq_getsetattr: ::c_long = 5000 + 235; +pub const SYS_vserver: ::c_long = 5000 + 236; +pub const SYS_waitid: ::c_long = 5000 + 237; +/* pub const SYS_sys_setaltroot: ::c_long = 5000 + 238; */ +pub const SYS_add_key: ::c_long = 5000 + 239; +pub const SYS_request_key: ::c_long = 5000 + 240; +pub const SYS_keyctl: ::c_long = 5000 + 241; +pub const SYS_set_thread_area: ::c_long = 5000 + 242; +pub const SYS_inotify_init: ::c_long = 5000 + 243; +pub const SYS_inotify_add_watch: ::c_long = 5000 + 244; +pub const SYS_inotify_rm_watch: ::c_long = 5000 + 245; +pub const SYS_migrate_pages: ::c_long = 5000 + 246; +pub const SYS_openat: ::c_long = 5000 + 247; +pub const SYS_mkdirat: ::c_long = 5000 + 248; +pub const SYS_mknodat: ::c_long = 5000 + 249; +pub const SYS_fchownat: ::c_long = 5000 + 250; +pub const SYS_futimesat: ::c_long = 5000 + 251; +pub const SYS_newfstatat: ::c_long = 5000 + 252; +pub const SYS_unlinkat: ::c_long = 5000 + 253; +pub const SYS_renameat: ::c_long = 5000 + 254; +pub const SYS_linkat: ::c_long = 5000 + 255; +pub const SYS_symlinkat: ::c_long = 5000 + 256; +pub const SYS_readlinkat: ::c_long = 5000 + 257; +pub const SYS_fchmodat: ::c_long = 5000 + 258; +pub const SYS_faccessat: ::c_long = 5000 + 259; +pub const SYS_pselect6: ::c_long = 5000 + 260; +pub const SYS_ppoll: ::c_long = 5000 + 261; +pub const SYS_unshare: ::c_long = 5000 + 262; +pub const SYS_splice: ::c_long = 5000 + 263; +pub const SYS_sync_file_range: ::c_long = 5000 + 264; +pub const SYS_tee: ::c_long = 5000 + 265; +pub const SYS_vmsplice: ::c_long = 5000 + 266; +pub const SYS_move_pages: ::c_long = 5000 + 267; +pub const SYS_set_robust_list: ::c_long = 5000 + 268; +pub const SYS_get_robust_list: ::c_long = 5000 + 269; +pub const SYS_kexec_load: ::c_long = 5000 + 270; +pub const SYS_getcpu: ::c_long = 5000 + 271; +pub const SYS_epoll_pwait: ::c_long = 5000 + 272; +pub const SYS_ioprio_set: ::c_long = 5000 + 273; +pub const SYS_ioprio_get: ::c_long = 5000 + 274; +pub const SYS_utimensat: ::c_long = 5000 + 275; +pub const SYS_signalfd: ::c_long = 5000 + 276; +pub const SYS_timerfd: ::c_long = 5000 + 277; +pub const SYS_eventfd: ::c_long = 5000 + 278; +pub const SYS_fallocate: ::c_long = 5000 + 279; +pub const SYS_timerfd_create: ::c_long = 5000 + 280; +pub const SYS_timerfd_gettime: ::c_long = 5000 + 281; +pub const SYS_timerfd_settime: ::c_long = 5000 + 282; +pub const SYS_signalfd4: ::c_long = 5000 + 283; +pub const SYS_eventfd2: ::c_long = 5000 + 284; +pub const SYS_epoll_create1: ::c_long = 5000 + 285; +pub const SYS_dup3: ::c_long = 5000 + 286; +pub const SYS_pipe2: ::c_long = 5000 + 287; +pub const SYS_inotify_init1: ::c_long = 5000 + 288; +pub const SYS_preadv: ::c_long = 5000 + 289; +pub const SYS_pwritev: ::c_long = 5000 + 290; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 5000 + 291; +pub const SYS_perf_event_open: ::c_long = 5000 + 292; +pub const SYS_accept4: ::c_long = 5000 + 293; +pub const SYS_recvmmsg: ::c_long = 5000 + 294; +pub const SYS_fanotify_init: ::c_long = 5000 + 295; +pub const SYS_fanotify_mark: ::c_long = 5000 + 296; +pub const SYS_prlimit64: ::c_long = 5000 + 297; +pub const SYS_name_to_handle_at: ::c_long = 5000 + 298; +pub const SYS_open_by_handle_at: ::c_long = 5000 + 299; +pub const SYS_clock_adjtime: ::c_long = 5000 + 300; +pub const SYS_syncfs: ::c_long = 5000 + 301; +pub const SYS_sendmmsg: ::c_long = 5000 + 302; +pub const SYS_setns: ::c_long = 5000 + 303; +pub const SYS_process_vm_readv: ::c_long = 5000 + 304; +pub const SYS_process_vm_writev: ::c_long = 5000 + 305; +pub const SYS_kcmp: ::c_long = 5000 + 306; +pub const SYS_finit_module: ::c_long = 5000 + 307; +pub const SYS_getdents64: ::c_long = 5000 + 308; +pub const SYS_sched_setattr: ::c_long = 5000 + 309; +pub const SYS_sched_getattr: ::c_long = 5000 + 310; +pub const SYS_renameat2: ::c_long = 5000 + 311; +pub const SYS_seccomp: ::c_long = 5000 + 312; +pub const SYS_getrandom: ::c_long = 5000 + 313; +pub const SYS_memfd_create: ::c_long = 5000 + 314; +pub const SYS_bpf: ::c_long = 5000 + 315; +pub const SYS_execveat: ::c_long = 5000 + 316; +pub const SYS_userfaultfd: ::c_long = 5000 + 317; +pub const SYS_membarrier: ::c_long = 5000 + 318; +pub const SYS_mlock2: ::c_long = 5000 + 319; +pub const SYS_copy_file_range: ::c_long = 5000 + 320; +pub const SYS_preadv2: ::c_long = 5000 + 321; +pub const SYS_pwritev2: ::c_long = 5000 + 322; +pub const SYS_pkey_mprotect: ::c_long = 5000 + 323; +pub const SYS_pkey_alloc: ::c_long = 5000 + 324; +pub const SYS_pkey_free: ::c_long = 5000 + 325; +pub const SYS_statx: ::c_long = 5000 + 326; + +pub const O_DIRECT: ::c_int = 0x8000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; + +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 256; +pub const O_EXCL: ::c_int = 1024; +pub const O_NOCTTY: ::c_int = 2048; +pub const O_NONBLOCK: ::c_int = 128; +pub const O_SYNC: ::c_int = 0x4010; +pub const O_RSYNC: ::c_int = 0x4010; +pub const O_DSYNC: ::c_int = 0x10; +pub const O_ASYNC: ::c_int = 0x1000; + +pub const EDEADLK: ::c_int = 45; +pub const ENAMETOOLONG: ::c_int = 78; +pub const ENOLCK: ::c_int = 46; +pub const ENOSYS: ::c_int = 89; +pub const ENOTEMPTY: ::c_int = 93; +pub const ELOOP: ::c_int = 90; +pub const ENOMSG: ::c_int = 35; +pub const EIDRM: ::c_int = 36; +pub const ECHRNG: ::c_int = 37; +pub const EL2NSYNC: ::c_int = 38; +pub const EL3HLT: ::c_int = 39; +pub const EL3RST: ::c_int = 40; +pub const ELNRNG: ::c_int = 41; +pub const EUNATCH: ::c_int = 42; +pub const ENOCSI: ::c_int = 43; +pub const EL2HLT: ::c_int = 44; +pub const EBADE: ::c_int = 50; +pub const EBADR: ::c_int = 51; +pub const EXFULL: ::c_int = 52; +pub const ENOANO: ::c_int = 53; +pub const EBADRQC: ::c_int = 54; +pub const EBADSLT: ::c_int = 55; +pub const EDEADLOCK: ::c_int = 56; +pub const EMULTIHOP: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 79; +pub const ENOTUNIQ: ::c_int = 80; +pub const EBADFD: ::c_int = 81; +pub const EBADMSG: ::c_int = 77; +pub const EREMCHG: ::c_int = 82; +pub const ELIBACC: ::c_int = 83; +pub const ELIBBAD: ::c_int = 84; +pub const ELIBSCN: ::c_int = 85; +pub const ELIBMAX: ::c_int = 86; +pub const ELIBEXEC: ::c_int = 87; +pub const EILSEQ: ::c_int = 88; +pub const ERESTART: ::c_int = 91; +pub const ESTRPIPE: ::c_int = 92; +pub const EUSERS: ::c_int = 94; +pub const ENOTSOCK: ::c_int = 95; +pub const EDESTADDRREQ: ::c_int = 96; +pub const EMSGSIZE: ::c_int = 97; +pub const EPROTOTYPE: ::c_int = 98; +pub const ENOPROTOOPT: ::c_int = 99; +pub const EPROTONOSUPPORT: ::c_int = 120; +pub const ESOCKTNOSUPPORT: ::c_int = 121; +pub const EOPNOTSUPP: ::c_int = 122; +pub const EPFNOSUPPORT: ::c_int = 123; +pub const EAFNOSUPPORT: ::c_int = 124; +pub const EADDRINUSE: ::c_int = 125; +pub const EADDRNOTAVAIL: ::c_int = 126; +pub const ENETDOWN: ::c_int = 127; +pub const ENETUNREACH: ::c_int = 128; +pub const ENETRESET: ::c_int = 129; +pub const ECONNABORTED: ::c_int = 130; +pub const ECONNRESET: ::c_int = 131; +pub const ENOBUFS: ::c_int = 132; +pub const EISCONN: ::c_int = 133; +pub const ENOTCONN: ::c_int = 134; +pub const ESHUTDOWN: ::c_int = 143; +pub const ETOOMANYREFS: ::c_int = 144; +pub const ETIMEDOUT: ::c_int = 145; +pub const ECONNREFUSED: ::c_int = 146; +pub const EHOSTDOWN: ::c_int = 147; +pub const EHOSTUNREACH: ::c_int = 148; +pub const EALREADY: ::c_int = 149; +pub const EINPROGRESS: ::c_int = 150; +pub const ESTALE: ::c_int = 151; +pub const EUCLEAN: ::c_int = 135; +pub const ENOTNAM: ::c_int = 137; +pub const ENAVAIL: ::c_int = 138; +pub const EISNAM: ::c_int = 139; +pub const EREMOTEIO: ::c_int = 140; +pub const EDQUOT: ::c_int = 1133; +pub const ENOMEDIUM: ::c_int = 159; +pub const EMEDIUMTYPE: ::c_int = 160; +pub const ECANCELED: ::c_int = 158; +pub const ENOKEY: ::c_int = 161; +pub const EKEYEXPIRED: ::c_int = 162; +pub const EKEYREVOKED: ::c_int = 163; +pub const EKEYREJECTED: ::c_int = 164; +pub const EOWNERDEAD: ::c_int = 165; +pub const ENOTRECOVERABLE: ::c_int = 166; +pub const ERFKILL: ::c_int = 167; + +pub const MAP_ANON: ::c_int = 0x800; +pub const MAP_GROWSDOWN: ::c_int = 0x1000; +pub const MAP_DENYWRITE: ::c_int = 0x2000; +pub const MAP_EXECUTABLE: ::c_int = 0x4000; +pub const MAP_LOCKED: ::c_int = 0x8000; +pub const MAP_NORESERVE: ::c_int = 0x400; +pub const MAP_POPULATE: ::c_int = 0x10000; +pub const MAP_NONBLOCK: ::c_int = 0x20000; +pub const MAP_STACK: ::c_int = 0x40000; +pub const MAP_HUGETLB: ::c_int = 0x080000; + +pub const SOCK_STREAM: ::c_int = 2; +pub const SOCK_DGRAM: ::c_int = 1; + +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ACCEPTCONN: ::c_int = 0x1009; +pub const SO_PROTOCOL: ::c_int = 0x1028; +pub const SO_DOMAIN: ::c_int = 0x1029; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_PASSCRED: ::c_int = 17; +pub const SO_PEERCRED: ::c_int = 18; +pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: ::c_int = 28; +pub const SO_PEERSEC: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 31; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PASSSEC: ::c_int = 34; +pub const SO_TIMESTAMPNS: ::c_int = 35; +pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; +pub const SO_WIFI_STATUS: ::c_int = 41; +pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; +pub const SO_NOFCS: ::c_int = 43; +pub const SO_LOCK_FILTER: ::c_int = 44; +pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; +pub const SO_MAX_PACING_RATE: ::c_int = 47; +pub const SO_BPF_EXTENSIONS: ::c_int = 48; +pub const SO_INCOMING_CPU: ::c_int = 49; +pub const SO_ATTACH_BPF: ::c_int = 50; +pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER; + +pub const FIOCLEX: ::c_int = 0x6601; +pub const FIONCLEX: ::c_int = 0x6602; +pub const FIONBIO: ::c_int = 0x667e; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000008; +pub const SA_NOCLDWAIT: ::c_int = 0x00010000; + +pub const SIGCHLD: ::c_int = 18; +pub const SIGBUS: ::c_int = 10; +pub const SIGTTIN: ::c_int = 26; +pub const SIGTTOU: ::c_int = 27; +pub const SIGXCPU: ::c_int = 30; +pub const SIGXFSZ: ::c_int = 31; +pub const SIGVTALRM: ::c_int = 28; +pub const SIGPROF: ::c_int = 29; +pub const SIGWINCH: ::c_int = 20; +pub const SIGUSR1: ::c_int = 16; +pub const SIGUSR2: ::c_int = 17; +pub const SIGCONT: ::c_int = 25; +pub const SIGSTOP: ::c_int = 23; +pub const SIGTSTP: ::c_int = 24; +pub const SIGURG: ::c_int = 21; +pub const SIGIO: ::c_int = 22; +pub const SIGSYS: ::c_int = 12; +pub const SIGPOLL: ::c_int = 22; +pub const SIGPWR: ::c_int = 19; +pub const SIG_SETMASK: ::c_int = 3; +pub const SIG_BLOCK: ::c_int = 0x1; +pub const SIG_UNBLOCK: ::c_int = 0x2; + +pub const POLLWRNORM: ::c_short = 0x004; +pub const POLLWRBAND: ::c_short = 0x100; + +pub const VEOF: usize = 16; +pub const VEOL: usize = 17; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: ::tcflag_t = 0x00000100; +pub const TOSTOP: ::tcflag_t = 0x00008000; +pub const FLUSHO: ::tcflag_t = 0x00002000; +pub const EXTPROC: ::tcflag_t = 0o200000; + +pub const F_GETLK: ::c_int = 14; +pub const F_GETOWN: ::c_int = 23; +pub const F_SETOWN: ::c_int = 24; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; + +pub const TCGETS: ::c_ulong = 0x540d; +pub const TCSETS: ::c_ulong = 0x540e; +pub const TCSETSW: ::c_ulong = 0x540f; +pub const TCSETSF: ::c_ulong = 0x5410; +pub const TCGETA: ::c_ulong = 0x5401; +pub const TCSETA: ::c_ulong = 0x5402; +pub const TCSETAW: ::c_ulong = 0x5403; +pub const TCSETAF: ::c_ulong = 0x5404; +pub const TCSBRK: ::c_ulong = 0x5405; +pub const TCXONC: ::c_ulong = 0x5406; +pub const TCFLSH: ::c_ulong = 0x5407; +pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; +pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; +pub const TIOCINQ: ::c_ulong = 0x467f; +pub const TIOCLINUX: ::c_ulong = 0x5483; +pub const TIOCGSERIAL: ::c_ulong = 0x5484; +pub const TIOCEXCL: ::c_ulong = 0x740d; +pub const TIOCNXCL: ::c_ulong = 0x740e; +pub const TIOCSCTTY: ::c_ulong = 0x5480; +pub const TIOCGPGRP: ::c_ulong = 0x40047477; +pub const TIOCSPGRP: ::c_ulong = 0x80047476; +pub const TIOCOUTQ: ::c_ulong = 0x7472; +pub const TIOCSTI: ::c_ulong = 0x5472; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const TIOCMGET: ::c_ulong = 0x741d; +pub const TIOCMBIS: ::c_ulong = 0x741b; +pub const TIOCMBIC: ::c_ulong = 0x741c; +pub const TIOCMSET: ::c_ulong = 0x741a; +pub const FIONREAD: ::c_ulong = 0x467f; +pub const TIOCCONS: ::c_ulong = 0x80047478; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const BOTHER: ::speed_t = 0o010000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const TIOCM_ST: ::c_int = 0x010; +pub const TIOCM_SR: ::c_int = 0x020; +pub const TIOCM_CTS: ::c_int = 0x040; +pub const TIOCM_CAR: ::c_int = 0x100; +pub const TIOCM_RNG: ::c_int = 0x200; +pub const TIOCM_DSR: ::c_int = 0x400; + +pub const EHWPOISON: ::c_int = 168; + +extern "C" { + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/mod.rs new file mode 100644 index 0000000..e6a8fc8 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/mod.rs @@ -0,0 +1,169 @@ +pub type c_long = i64; +pub type c_ulong = u64; + +s! { + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct pthread_attr_t { + __size: [u64; 7] + } + + pub struct sigset_t { + __val: [::c_ulong; 16], + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::c_ulong, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + pub msg_rtime: ::time_t, + pub msg_ctime: ::time_t, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + #[cfg(target_endian = "big")] + __pad1: ::c_int, + pub msg_iovlen: ::c_int, + #[cfg(target_endian = "little")] + __pad1: ::c_int, + pub msg_control: *mut ::c_void, + #[cfg(target_endian = "big")] + __pad2: ::c_int, + pub msg_controllen: ::socklen_t, + #[cfg(target_endian = "little")] + __pad2: ::c_int, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + #[cfg(target_endian = "big")] + pub __pad1: ::c_int, + pub cmsg_len: ::socklen_t, + #[cfg(target_endian = "little")] + pub __pad1: ::c_int, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct sem_t { + __val: [::c_int; 8], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } +} + +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; + +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_MEMLOCK: ::c_int = 8; + +pub const SOCK_NONBLOCK: ::c_int = 2048; + +pub const SOCK_SEQPACKET: ::c_int = 5; + +extern "C" { + pub fn getrandom( + buf: *mut ::c_void, + buflen: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "mips64")] { + mod mips64; + pub use self::mips64::*; + } else if #[cfg(any(target_arch = "powerpc64"))] { + mod powerpc64; + pub use self::powerpc64::*; + } else if #[cfg(any(target_arch = "x86_64"))] { + mod x86_64; + pub use self::x86_64::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/powerpc64.rs new file mode 100644 index 0000000..d27d703 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -0,0 +1,739 @@ +pub type c_char = u8; +pub type wchar_t = i32; +pub type __u64 = ::c_ulong; +pub type nlink_t = u64; +pub type blksize_t = ::c_long; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 3], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __reserved: [::c_long; 3], + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_int, + __unused1: ::c_long, + __unused2: ::c_long + } +} + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_32BIT: ::c_int = 0x0040; +pub const O_APPEND: ::c_int = 1024; +pub const O_DIRECT: ::c_int = 0x20000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_LARGEFILE: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_ASYNC: ::c_int = 0x2000; + +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOL_SOCKET: ::c_int = 1; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_SETOWN: ::c_int = 8; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const SIGSTKSZ: ::size_t = 10240; +pub const MINSIGSTKSZ: ::size_t = 4096; + +// Syscall table +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_break: ::c_long = 17; +pub const SYS_oldstat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_umount: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_stime: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_oldfstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_stty: ::c_long = 31; +pub const SYS_gtty: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_ftime: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_prof: ::c_long = 44; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_lock: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_mpx: ::c_long = 56; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_ulimit: ::c_long = 58; +pub const SYS_oldolduname: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_oldlstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_readdir: ::c_long = 89; +pub const SYS_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_profil: ::c_long = 98; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_ioperm: ::c_long = 101; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_olduname: ::c_long = 109; +pub const SYS_iopl: ::c_long = 110; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_idle: ::c_long = 112; +pub const SYS_vm86: ::c_long = 113; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_modify_ldt: ::c_long = 123; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_afs_syscall: ::c_long = 137; /* Syscall for Andrew File System */ +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_query_module: ::c_long = 166; +pub const SYS_poll: ::c_long = 167; +pub const SYS_nfsservctl: ::c_long = 168; +pub const SYS_setresgid: ::c_long = 169; +pub const SYS_getresgid: ::c_long = 170; +pub const SYS_prctl: ::c_long = 171; +pub const SYS_rt_sigreturn: ::c_long = 172; +pub const SYS_rt_sigaction: ::c_long = 173; +pub const SYS_rt_sigprocmask: ::c_long = 174; +pub const SYS_rt_sigpending: ::c_long = 175; +pub const SYS_rt_sigtimedwait: ::c_long = 176; +pub const SYS_rt_sigqueueinfo: ::c_long = 177; +pub const SYS_rt_sigsuspend: ::c_long = 178; +pub const SYS_pread64: ::c_long = 179; +pub const SYS_pwrite64: ::c_long = 180; +pub const SYS_chown: ::c_long = 181; +pub const SYS_getcwd: ::c_long = 182; +pub const SYS_capget: ::c_long = 183; +pub const SYS_capset: ::c_long = 184; +pub const SYS_sigaltstack: ::c_long = 185; +pub const SYS_sendfile: ::c_long = 186; +pub const SYS_getpmsg: ::c_long = 187; /* some people actually want streams */ +pub const SYS_putpmsg: ::c_long = 188; /* some people actually want streams */ +pub const SYS_vfork: ::c_long = 189; +pub const SYS_ugetrlimit: ::c_long = 190; /* SuS compliant getrlimit */ +pub const SYS_readahead: ::c_long = 191; +pub const SYS_pciconfig_read: ::c_long = 198; +pub const SYS_pciconfig_write: ::c_long = 199; +pub const SYS_pciconfig_iobase: ::c_long = 200; +pub const SYS_multiplexer: ::c_long = 201; +pub const SYS_getdents64: ::c_long = 202; +pub const SYS_pivot_root: ::c_long = 203; +pub const SYS_madvise: ::c_long = 205; +pub const SYS_mincore: ::c_long = 206; +pub const SYS_gettid: ::c_long = 207; +pub const SYS_tkill: ::c_long = 208; +pub const SYS_setxattr: ::c_long = 209; +pub const SYS_lsetxattr: ::c_long = 210; +pub const SYS_fsetxattr: ::c_long = 211; +pub const SYS_getxattr: ::c_long = 212; +pub const SYS_lgetxattr: ::c_long = 213; +pub const SYS_fgetxattr: ::c_long = 214; +pub const SYS_listxattr: ::c_long = 215; +pub const SYS_llistxattr: ::c_long = 216; +pub const SYS_flistxattr: ::c_long = 217; +pub const SYS_removexattr: ::c_long = 218; +pub const SYS_lremovexattr: ::c_long = 219; +pub const SYS_fremovexattr: ::c_long = 220; +pub const SYS_futex: ::c_long = 221; +pub const SYS_sched_setaffinity: ::c_long = 222; +pub const SYS_sched_getaffinity: ::c_long = 223; +pub const SYS_tuxcall: ::c_long = 225; +pub const SYS_io_setup: ::c_long = 227; +pub const SYS_io_destroy: ::c_long = 228; +pub const SYS_io_getevents: ::c_long = 229; +pub const SYS_io_submit: ::c_long = 230; +pub const SYS_io_cancel: ::c_long = 231; +pub const SYS_set_tid_address: ::c_long = 232; +pub const SYS_exit_group: ::c_long = 234; +pub const SYS_lookup_dcookie: ::c_long = 235; +pub const SYS_epoll_create: ::c_long = 236; +pub const SYS_epoll_ctl: ::c_long = 237; +pub const SYS_epoll_wait: ::c_long = 238; +pub const SYS_remap_file_pages: ::c_long = 239; +pub const SYS_timer_create: ::c_long = 240; +pub const SYS_timer_settime: ::c_long = 241; +pub const SYS_timer_gettime: ::c_long = 242; +pub const SYS_timer_getoverrun: ::c_long = 243; +pub const SYS_timer_delete: ::c_long = 244; +pub const SYS_clock_settime: ::c_long = 245; +pub const SYS_clock_gettime: ::c_long = 246; +pub const SYS_clock_getres: ::c_long = 247; +pub const SYS_clock_nanosleep: ::c_long = 248; +pub const SYS_swapcontext: ::c_long = 249; +pub const SYS_tgkill: ::c_long = 250; +pub const SYS_utimes: ::c_long = 251; +pub const SYS_statfs64: ::c_long = 252; +pub const SYS_fstatfs64: ::c_long = 253; +pub const SYS_rtas: ::c_long = 255; +pub const SYS_sys_debug_setcontext: ::c_long = 256; +pub const SYS_migrate_pages: ::c_long = 258; +pub const SYS_mbind: ::c_long = 259; +pub const SYS_get_mempolicy: ::c_long = 260; +pub const SYS_set_mempolicy: ::c_long = 261; +pub const SYS_mq_open: ::c_long = 262; +pub const SYS_mq_unlink: ::c_long = 263; +pub const SYS_mq_timedsend: ::c_long = 264; +pub const SYS_mq_timedreceive: ::c_long = 265; +pub const SYS_mq_notify: ::c_long = 266; +pub const SYS_mq_getsetattr: ::c_long = 267; +pub const SYS_kexec_load: ::c_long = 268; +pub const SYS_add_key: ::c_long = 269; +pub const SYS_request_key: ::c_long = 270; +pub const SYS_keyctl: ::c_long = 271; +pub const SYS_waitid: ::c_long = 272; +pub const SYS_ioprio_set: ::c_long = 273; +pub const SYS_ioprio_get: ::c_long = 274; +pub const SYS_inotify_init: ::c_long = 275; +pub const SYS_inotify_add_watch: ::c_long = 276; +pub const SYS_inotify_rm_watch: ::c_long = 277; +pub const SYS_spu_run: ::c_long = 278; +pub const SYS_spu_create: ::c_long = 279; +pub const SYS_pselect6: ::c_long = 280; +pub const SYS_ppoll: ::c_long = 281; +pub const SYS_unshare: ::c_long = 282; +pub const SYS_splice: ::c_long = 283; +pub const SYS_tee: ::c_long = 284; +pub const SYS_vmsplice: ::c_long = 285; +pub const SYS_openat: ::c_long = 286; +pub const SYS_mkdirat: ::c_long = 287; +pub const SYS_mknodat: ::c_long = 288; +pub const SYS_fchownat: ::c_long = 289; +pub const SYS_futimesat: ::c_long = 290; +pub const SYS_newfstatat: ::c_long = 291; +pub const SYS_unlinkat: ::c_long = 292; +pub const SYS_renameat: ::c_long = 293; +pub const SYS_linkat: ::c_long = 294; +pub const SYS_symlinkat: ::c_long = 295; +pub const SYS_readlinkat: ::c_long = 296; +pub const SYS_fchmodat: ::c_long = 297; +pub const SYS_faccessat: ::c_long = 298; +pub const SYS_get_robust_list: ::c_long = 299; +pub const SYS_set_robust_list: ::c_long = 300; +pub const SYS_move_pages: ::c_long = 301; +pub const SYS_getcpu: ::c_long = 302; +pub const SYS_epoll_pwait: ::c_long = 303; +pub const SYS_utimensat: ::c_long = 304; +pub const SYS_signalfd: ::c_long = 305; +pub const SYS_timerfd_create: ::c_long = 306; +pub const SYS_eventfd: ::c_long = 307; +pub const SYS_sync_file_range2: ::c_long = 308; +pub const SYS_fallocate: ::c_long = 309; +pub const SYS_subpage_prot: ::c_long = 310; +pub const SYS_timerfd_settime: ::c_long = 311; +pub const SYS_timerfd_gettime: ::c_long = 312; +pub const SYS_signalfd4: ::c_long = 313; +pub const SYS_eventfd2: ::c_long = 314; +pub const SYS_epoll_create1: ::c_long = 315; +pub const SYS_dup3: ::c_long = 316; +pub const SYS_pipe2: ::c_long = 317; +pub const SYS_inotify_init1: ::c_long = 318; +pub const SYS_perf_event_open: ::c_long = 319; +pub const SYS_preadv: ::c_long = 320; +pub const SYS_pwritev: ::c_long = 321; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 322; +pub const SYS_fanotify_init: ::c_long = 323; +pub const SYS_fanotify_mark: ::c_long = 324; +pub const SYS_prlimit64: ::c_long = 325; +pub const SYS_socket: ::c_long = 326; +pub const SYS_bind: ::c_long = 327; +pub const SYS_connect: ::c_long = 328; +pub const SYS_listen: ::c_long = 329; +pub const SYS_accept: ::c_long = 330; +pub const SYS_getsockname: ::c_long = 331; +pub const SYS_getpeername: ::c_long = 332; +pub const SYS_socketpair: ::c_long = 333; +pub const SYS_send: ::c_long = 334; +pub const SYS_sendto: ::c_long = 335; +pub const SYS_recv: ::c_long = 336; +pub const SYS_recvfrom: ::c_long = 337; +pub const SYS_shutdown: ::c_long = 338; +pub const SYS_setsockopt: ::c_long = 339; +pub const SYS_getsockopt: ::c_long = 340; +pub const SYS_sendmsg: ::c_long = 341; +pub const SYS_recvmsg: ::c_long = 342; +pub const SYS_recvmmsg: ::c_long = 343; +pub const SYS_accept4: ::c_long = 344; +pub const SYS_name_to_handle_at: ::c_long = 345; +pub const SYS_open_by_handle_at: ::c_long = 346; +pub const SYS_clock_adjtime: ::c_long = 347; +pub const SYS_syncfs: ::c_long = 348; +pub const SYS_sendmmsg: ::c_long = 349; +pub const SYS_setns: ::c_long = 350; +pub const SYS_process_vm_readv: ::c_long = 351; +pub const SYS_process_vm_writev: ::c_long = 352; +pub const SYS_finit_module: ::c_long = 353; +pub const SYS_kcmp: ::c_long = 354; +pub const SYS_sched_setattr: ::c_long = 355; +pub const SYS_sched_getattr: ::c_long = 356; +pub const SYS_renameat2: ::c_long = 357; +pub const SYS_seccomp: ::c_long = 358; +pub const SYS_getrandom: ::c_long = 359; +pub const SYS_memfd_create: ::c_long = 360; +pub const SYS_bpf: ::c_long = 361; +pub const SYS_execveat: ::c_long = 362; +pub const SYS_switch_endian: ::c_long = 363; +pub const SYS_userfaultfd: ::c_long = 364; +pub const SYS_membarrier: ::c_long = 365; +pub const SYS_mlock2: ::c_long = 378; +pub const SYS_copy_file_range: ::c_long = 379; +pub const SYS_preadv2: ::c_long = 380; +pub const SYS_pwritev2: ::c_long = 381; +pub const SYS_kexec_file_load: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; + +pub const FIOCLEX: ::c_int = 0x20006601; +pub const FIONCLEX: ::c_int = 0x20006602; +pub const FIONBIO: ::c_int = 0x8004667e; +pub const EDEADLK: ::c_int = 58; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const SO_PASSCRED: ::c_int = 20; +pub const SO_PEERCRED: ::c_int = 21; +pub const SO_RCVLOWAT: ::c_int = 16; +pub const SO_SNDLOWAT: ::c_int = 17; +pub const SO_RCVTIMEO: ::c_int = 18; +pub const SO_SNDTIMEO: ::c_int = 19; +pub const EXTPROC: ::tcflag_t = 0x10000000; +pub const VEOL: usize = 6; +pub const VEOL2: usize = 8; +pub const VMIN: usize = 5; +pub const IEXTEN: ::tcflag_t = 0x00000400; +pub const TOSTOP: ::tcflag_t = 0x00400000; +pub const FLUSHO: ::tcflag_t = 0x00800000; +pub const TCGETS: ::c_int = 0x403c7413; +pub const TCSETS: ::c_int = 0x803c7414; +pub const TCSETSW: ::c_int = 0x803c7415; +pub const TCSETSF: ::c_int = 0x803c7416; +pub const TCGETA: ::c_int = 0x40147417; +pub const TCSETA: ::c_int = 0x80147418; +pub const TCSETAW: ::c_int = 0x80147419; +pub const TCSETAF: ::c_int = 0x8014741c; +pub const TCSBRK: ::c_int = 0x2000741d; +pub const TCXONC: ::c_int = 0x2000741e; +pub const TCFLSH: ::c_int = 0x2000741f; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x40047477; +pub const TIOCSPGRP: ::c_int = 0x80047476; +pub const TIOCOUTQ: ::c_int = 0x40047473; +pub const TIOCGWINSZ: ::c_int = 0x40087468; +pub const TIOCSWINSZ: ::c_int = 0x80087467; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x4004667f; +pub const TIOCCONS: ::c_int = 0x541D; +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const TIOCINQ: ::c_int = ::FIONREAD; +pub const MCL_CURRENT: ::c_int = 0x2000; +pub const MCL_FUTURE: ::c_int = 0x4000; +pub const CBAUD: ::tcflag_t = 0xff; +pub const TAB1: ::c_int = 0x400; +pub const TAB2: ::c_int = 0x800; +pub const TAB3: ::c_int = 0xc00; +pub const CR1: ::c_int = 0x1000; +pub const CR2: ::c_int = 0x2000; +pub const CR3: ::c_int = 0x3000; +pub const FF1: ::c_int = 0x4000; +pub const BS1: ::c_int = 0x8000; +pub const VT1: ::c_int = 0x10000; +pub const VWERASE: usize = 10; +pub const VREPRINT: usize = 11; +pub const VSUSP: usize = 12; +pub const VSTART: usize = 13; +pub const VSTOP: usize = 14; +pub const VDISCARD: usize = 16; +pub const VTIME: usize = 7; +pub const IXON: ::tcflag_t = 0x00000200; +pub const IXOFF: ::tcflag_t = 0x00000400; +pub const ONLCR: ::tcflag_t = 0x2; +pub const CSIZE: ::tcflag_t = 0x00000300; + +pub const CS6: ::tcflag_t = 0x00000100; +pub const CS7: ::tcflag_t = 0x00000200; +pub const CS8: ::tcflag_t = 0x00000300; +pub const CSTOPB: ::tcflag_t = 0x00000400; +pub const CREAD: ::tcflag_t = 0x00000800; +pub const PARENB: ::tcflag_t = 0x00001000; +pub const PARODD: ::tcflag_t = 0x00002000; +pub const HUPCL: ::tcflag_t = 0x00004000; +pub const CLOCAL: ::tcflag_t = 0x00008000; +pub const ECHOKE: ::tcflag_t = 0x00000001; +pub const ECHOE: ::tcflag_t = 0x00000002; +pub const ECHOK: ::tcflag_t = 0x00000004; +pub const ECHONL: ::tcflag_t = 0x00000010; +pub const ECHOPRT: ::tcflag_t = 0x00000020; +pub const ECHOCTL: ::tcflag_t = 0x00000040; +pub const ISIG: ::tcflag_t = 0x00000080; +pub const ICANON: ::tcflag_t = 0x00000100; +pub const PENDIN: ::tcflag_t = 0x20000000; +pub const NOFLSH: ::tcflag_t = 0x80000000; + +pub const CIBAUD: ::tcflag_t = 0o77600000; +pub const CBAUDEX: ::tcflag_t = 0o0000020; +pub const VSWTC: usize = 9; +pub const OLCUC: ::tcflag_t = 0o000004; +pub const NLDLY: ::tcflag_t = 0o0001400; +pub const CRDLY: ::tcflag_t = 0o0030000; +pub const TABDLY: ::tcflag_t = 0o0006000; +pub const BSDLY: ::tcflag_t = 0o0100000; +pub const FFDLY: ::tcflag_t = 0o0040000; +pub const VTDLY: ::tcflag_t = 0o0200000; +pub const XTABS: ::tcflag_t = 0o00006000; + +pub const B57600: ::speed_t = 0o00020; +pub const B115200: ::speed_t = 0o00021; +pub const B230400: ::speed_t = 0o00022; +pub const B460800: ::speed_t = 0o00023; +pub const B500000: ::speed_t = 0o00024; +pub const B576000: ::speed_t = 0o00025; +pub const B921600: ::speed_t = 0o00026; +pub const B1000000: ::speed_t = 0o00027; +pub const B1152000: ::speed_t = 0o00030; +pub const B1500000: ::speed_t = 0o00031; +pub const B2000000: ::speed_t = 0o00032; +pub const B2500000: ::speed_t = 0o00033; +pub const B3000000: ::speed_t = 0o00034; +pub const B3500000: ::speed_t = 0o00035; +pub const B4000000: ::speed_t = 0o00036; + +extern "C" { + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/x86_64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/x86_64/align.rs new file mode 100644 index 0000000..7ca870f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/x86_64/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs new file mode 100644 index 0000000..ff9300c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -0,0 +1,961 @@ +pub type c_char = i8; +pub type wchar_t = i32; +pub type nlink_t = u64; +pub type blksize_t = ::c_long; +pub type __u64 = ::c_ulonglong; +pub type greg_t = i64; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 3], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __reserved: [::c_long; 3], + } + + pub struct user_regs_struct { + pub r15: ::c_ulong, + pub r14: ::c_ulong, + pub r13: ::c_ulong, + pub r12: ::c_ulong, + pub rbp: ::c_ulong, + pub rbx: ::c_ulong, + pub r11: ::c_ulong, + pub r10: ::c_ulong, + pub r9: ::c_ulong, + pub r8: ::c_ulong, + pub rax: ::c_ulong, + pub rcx: ::c_ulong, + pub rdx: ::c_ulong, + pub rsi: ::c_ulong, + pub rdi: ::c_ulong, + pub orig_rax: ::c_ulong, + pub rip: ::c_ulong, + pub cs: ::c_ulong, + pub eflags: ::c_ulong, + pub rsp: ::c_ulong, + pub ss: ::c_ulong, + pub fs_base: ::c_ulong, + pub gs_base: ::c_ulong, + pub ds: ::c_ulong, + pub es: ::c_ulong, + pub fs: ::c_ulong, + pub gs: ::c_ulong, + } + + pub struct user { + pub regs: user_regs_struct, + pub u_fpvalid: ::c_int, + pub i387: user_fpregs_struct, + pub u_tsize: ::c_ulong, + pub u_dsize: ::c_ulong, + pub u_ssize: ::c_ulong, + pub start_code: ::c_ulong, + pub start_stack: ::c_ulong, + pub signal: ::c_long, + __reserved: ::c_int, + #[cfg(target_pointer_width = "32")] + __pad1: u32, + pub u_ar0: *mut user_regs_struct, + #[cfg(target_pointer_width = "32")] + __pad2: u32, + pub u_fpstate: *mut user_fpregs_struct, + pub magic: ::c_ulong, + pub u_comm: [::c_char; 32], + pub u_debugreg: [::c_ulong; 8], + } + + // GitHub repo: ifduyue/musl/ + // commit: b4b1e10364c8737a632be61582e05a8d3acf5690 + // file: arch/x86_64/bits/signal.h#L80-L84 + pub struct mcontext_t { + pub gregs: [greg_t; 23], + __private: [u64; 9], + } + + pub struct ipc_perm { + pub __ipc_perm_key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub __seq: ::c_int, + __unused1: ::c_long, + __unused2: ::c_long + } +} + +s_no_extra_traits! { + pub struct user_fpregs_struct { + pub cwd: ::c_ushort, + pub swd: ::c_ushort, + pub ftw: ::c_ushort, + pub fop: ::c_ushort, + pub rip: ::c_ulong, + pub rdp: ::c_ulong, + pub mxcsr: ::c_uint, + pub mxcr_mask: ::c_uint, + pub st_space: [::c_uint; 32], + pub xmm_space: [::c_uint; 64], + padding: [::c_uint; 24], + } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + __private: [u8; 512], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for user_fpregs_struct { + fn eq(&self, other: &user_fpregs_struct) -> bool { + self.cwd == other.cwd + && self.swd == other.swd + && self.ftw == other.ftw + && self.fop == other.fop + && self.rip == other.rip + && self.rdp == other.rdp + && self.mxcsr == other.mxcsr + && self.mxcr_mask == other.mxcr_mask + && self.st_space == other.st_space + && self + .xmm_space + .iter() + .zip(other.xmm_space.iter()) + .all(|(a,b)| a == b) + // Ignore padding field + } + } + + impl Eq for user_fpregs_struct {} + + impl ::fmt::Debug for user_fpregs_struct { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("user_fpregs_struct") + .field("cwd", &self.cwd) + .field("ftw", &self.ftw) + .field("fop", &self.fop) + .field("rip", &self.rip) + .field("rdp", &self.rdp) + .field("mxcsr", &self.mxcsr) + .field("mxcr_mask", &self.mxcr_mask) + .field("st_space", &self.st_space) + // FIXME: .field("xmm_space", &self.xmm_space) + // Ignore padding field + .finish() + } + } + + impl ::hash::Hash for user_fpregs_struct { + fn hash(&self, state: &mut H) { + self.cwd.hash(state); + self.ftw.hash(state); + self.fop.hash(state); + self.rip.hash(state); + self.rdp.hash(state); + self.mxcsr.hash(state); + self.mxcr_mask.hash(state); + self.st_space.hash(state); + self.xmm_space.hash(state); + // Ignore padding field + } + } + + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + && self + .__private + .iter() + .zip(other.__private.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for ucontext_t {} + + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } + } + + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + self.__private.hash(state); + } + } + } +} + +// Syscall table + +pub const SYS_read: ::c_long = 0; +pub const SYS_write: ::c_long = 1; +pub const SYS_open: ::c_long = 2; +pub const SYS_close: ::c_long = 3; +pub const SYS_stat: ::c_long = 4; +pub const SYS_fstat: ::c_long = 5; +pub const SYS_lstat: ::c_long = 6; +pub const SYS_poll: ::c_long = 7; +pub const SYS_lseek: ::c_long = 8; +pub const SYS_mmap: ::c_long = 9; +pub const SYS_mprotect: ::c_long = 10; +pub const SYS_munmap: ::c_long = 11; +pub const SYS_brk: ::c_long = 12; +pub const SYS_rt_sigaction: ::c_long = 13; +pub const SYS_rt_sigprocmask: ::c_long = 14; +pub const SYS_rt_sigreturn: ::c_long = 15; +pub const SYS_ioctl: ::c_long = 16; +pub const SYS_pread64: ::c_long = 17; +pub const SYS_pwrite64: ::c_long = 18; +pub const SYS_readv: ::c_long = 19; +pub const SYS_writev: ::c_long = 20; +pub const SYS_access: ::c_long = 21; +pub const SYS_pipe: ::c_long = 22; +pub const SYS_select: ::c_long = 23; +pub const SYS_sched_yield: ::c_long = 24; +pub const SYS_mremap: ::c_long = 25; +pub const SYS_msync: ::c_long = 26; +pub const SYS_mincore: ::c_long = 27; +pub const SYS_madvise: ::c_long = 28; +pub const SYS_shmget: ::c_long = 29; +pub const SYS_shmat: ::c_long = 30; +pub const SYS_shmctl: ::c_long = 31; +pub const SYS_dup: ::c_long = 32; +pub const SYS_dup2: ::c_long = 33; +pub const SYS_pause: ::c_long = 34; +pub const SYS_nanosleep: ::c_long = 35; +pub const SYS_getitimer: ::c_long = 36; +pub const SYS_alarm: ::c_long = 37; +pub const SYS_setitimer: ::c_long = 38; +pub const SYS_getpid: ::c_long = 39; +pub const SYS_sendfile: ::c_long = 40; +pub const SYS_socket: ::c_long = 41; +pub const SYS_connect: ::c_long = 42; +pub const SYS_accept: ::c_long = 43; +pub const SYS_sendto: ::c_long = 44; +pub const SYS_recvfrom: ::c_long = 45; +pub const SYS_sendmsg: ::c_long = 46; +pub const SYS_recvmsg: ::c_long = 47; +pub const SYS_shutdown: ::c_long = 48; +pub const SYS_bind: ::c_long = 49; +pub const SYS_listen: ::c_long = 50; +pub const SYS_getsockname: ::c_long = 51; +pub const SYS_getpeername: ::c_long = 52; +pub const SYS_socketpair: ::c_long = 53; +pub const SYS_setsockopt: ::c_long = 54; +pub const SYS_getsockopt: ::c_long = 55; +pub const SYS_clone: ::c_long = 56; +pub const SYS_fork: ::c_long = 57; +pub const SYS_vfork: ::c_long = 58; +pub const SYS_execve: ::c_long = 59; +pub const SYS_exit: ::c_long = 60; +pub const SYS_wait4: ::c_long = 61; +pub const SYS_kill: ::c_long = 62; +pub const SYS_uname: ::c_long = 63; +pub const SYS_semget: ::c_long = 64; +pub const SYS_semop: ::c_long = 65; +pub const SYS_semctl: ::c_long = 66; +pub const SYS_shmdt: ::c_long = 67; +pub const SYS_msgget: ::c_long = 68; +pub const SYS_msgsnd: ::c_long = 69; +pub const SYS_msgrcv: ::c_long = 70; +pub const SYS_msgctl: ::c_long = 71; +pub const SYS_fcntl: ::c_long = 72; +pub const SYS_flock: ::c_long = 73; +pub const SYS_fsync: ::c_long = 74; +pub const SYS_fdatasync: ::c_long = 75; +pub const SYS_truncate: ::c_long = 76; +pub const SYS_ftruncate: ::c_long = 77; +pub const SYS_getdents: ::c_long = 78; +pub const SYS_getcwd: ::c_long = 79; +pub const SYS_chdir: ::c_long = 80; +pub const SYS_fchdir: ::c_long = 81; +pub const SYS_rename: ::c_long = 82; +pub const SYS_mkdir: ::c_long = 83; +pub const SYS_rmdir: ::c_long = 84; +pub const SYS_creat: ::c_long = 85; +pub const SYS_link: ::c_long = 86; +pub const SYS_unlink: ::c_long = 87; +pub const SYS_symlink: ::c_long = 88; +pub const SYS_readlink: ::c_long = 89; +pub const SYS_chmod: ::c_long = 90; +pub const SYS_fchmod: ::c_long = 91; +pub const SYS_chown: ::c_long = 92; +pub const SYS_fchown: ::c_long = 93; +pub const SYS_lchown: ::c_long = 94; +pub const SYS_umask: ::c_long = 95; +pub const SYS_gettimeofday: ::c_long = 96; +pub const SYS_getrlimit: ::c_long = 97; +pub const SYS_getrusage: ::c_long = 98; +pub const SYS_sysinfo: ::c_long = 99; +pub const SYS_times: ::c_long = 100; +pub const SYS_ptrace: ::c_long = 101; +pub const SYS_getuid: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_getgid: ::c_long = 104; +pub const SYS_setuid: ::c_long = 105; +pub const SYS_setgid: ::c_long = 106; +pub const SYS_geteuid: ::c_long = 107; +pub const SYS_getegid: ::c_long = 108; +pub const SYS_setpgid: ::c_long = 109; +pub const SYS_getppid: ::c_long = 110; +pub const SYS_getpgrp: ::c_long = 111; +pub const SYS_setsid: ::c_long = 112; +pub const SYS_setreuid: ::c_long = 113; +pub const SYS_setregid: ::c_long = 114; +pub const SYS_getgroups: ::c_long = 115; +pub const SYS_setgroups: ::c_long = 116; +pub const SYS_setresuid: ::c_long = 117; +pub const SYS_getresuid: ::c_long = 118; +pub const SYS_setresgid: ::c_long = 119; +pub const SYS_getresgid: ::c_long = 120; +pub const SYS_getpgid: ::c_long = 121; +pub const SYS_setfsuid: ::c_long = 122; +pub const SYS_setfsgid: ::c_long = 123; +pub const SYS_getsid: ::c_long = 124; +pub const SYS_capget: ::c_long = 125; +pub const SYS_capset: ::c_long = 126; +pub const SYS_rt_sigpending: ::c_long = 127; +pub const SYS_rt_sigtimedwait: ::c_long = 128; +pub const SYS_rt_sigqueueinfo: ::c_long = 129; +pub const SYS_rt_sigsuspend: ::c_long = 130; +pub const SYS_sigaltstack: ::c_long = 131; +pub const SYS_utime: ::c_long = 132; +pub const SYS_mknod: ::c_long = 133; +pub const SYS_uselib: ::c_long = 134; +pub const SYS_personality: ::c_long = 135; +pub const SYS_ustat: ::c_long = 136; +pub const SYS_statfs: ::c_long = 137; +pub const SYS_fstatfs: ::c_long = 138; +pub const SYS_sysfs: ::c_long = 139; +pub const SYS_getpriority: ::c_long = 140; +pub const SYS_setpriority: ::c_long = 141; +pub const SYS_sched_setparam: ::c_long = 142; +pub const SYS_sched_getparam: ::c_long = 143; +pub const SYS_sched_setscheduler: ::c_long = 144; +pub const SYS_sched_getscheduler: ::c_long = 145; +pub const SYS_sched_get_priority_max: ::c_long = 146; +pub const SYS_sched_get_priority_min: ::c_long = 147; +pub const SYS_sched_rr_get_interval: ::c_long = 148; +pub const SYS_mlock: ::c_long = 149; +pub const SYS_munlock: ::c_long = 150; +pub const SYS_mlockall: ::c_long = 151; +pub const SYS_munlockall: ::c_long = 152; +pub const SYS_vhangup: ::c_long = 153; +pub const SYS_modify_ldt: ::c_long = 154; +pub const SYS_pivot_root: ::c_long = 155; +pub const SYS__sysctl: ::c_long = 156; +pub const SYS_prctl: ::c_long = 157; +pub const SYS_arch_prctl: ::c_long = 158; +pub const SYS_adjtimex: ::c_long = 159; +pub const SYS_setrlimit: ::c_long = 160; +pub const SYS_chroot: ::c_long = 161; +pub const SYS_sync: ::c_long = 162; +pub const SYS_acct: ::c_long = 163; +pub const SYS_settimeofday: ::c_long = 164; +pub const SYS_mount: ::c_long = 165; +pub const SYS_umount2: ::c_long = 166; +pub const SYS_swapon: ::c_long = 167; +pub const SYS_swapoff: ::c_long = 168; +pub const SYS_reboot: ::c_long = 169; +pub const SYS_sethostname: ::c_long = 170; +pub const SYS_setdomainname: ::c_long = 171; +pub const SYS_iopl: ::c_long = 172; +pub const SYS_ioperm: ::c_long = 173; +pub const SYS_create_module: ::c_long = 174; +pub const SYS_init_module: ::c_long = 175; +pub const SYS_delete_module: ::c_long = 176; +pub const SYS_get_kernel_syms: ::c_long = 177; +pub const SYS_query_module: ::c_long = 178; +pub const SYS_quotactl: ::c_long = 179; +pub const SYS_nfsservctl: ::c_long = 180; +pub const SYS_getpmsg: ::c_long = 181; +pub const SYS_putpmsg: ::c_long = 182; +pub const SYS_afs_syscall: ::c_long = 183; +pub const SYS_tuxcall: ::c_long = 184; +pub const SYS_security: ::c_long = 185; +pub const SYS_gettid: ::c_long = 186; +pub const SYS_readahead: ::c_long = 187; +pub const SYS_setxattr: ::c_long = 188; +pub const SYS_lsetxattr: ::c_long = 189; +pub const SYS_fsetxattr: ::c_long = 190; +pub const SYS_getxattr: ::c_long = 191; +pub const SYS_lgetxattr: ::c_long = 192; +pub const SYS_fgetxattr: ::c_long = 193; +pub const SYS_listxattr: ::c_long = 194; +pub const SYS_llistxattr: ::c_long = 195; +pub const SYS_flistxattr: ::c_long = 196; +pub const SYS_removexattr: ::c_long = 197; +pub const SYS_lremovexattr: ::c_long = 198; +pub const SYS_fremovexattr: ::c_long = 199; +pub const SYS_tkill: ::c_long = 200; +pub const SYS_time: ::c_long = 201; +pub const SYS_futex: ::c_long = 202; +pub const SYS_sched_setaffinity: ::c_long = 203; +pub const SYS_sched_getaffinity: ::c_long = 204; +pub const SYS_set_thread_area: ::c_long = 205; +pub const SYS_io_setup: ::c_long = 206; +pub const SYS_io_destroy: ::c_long = 207; +pub const SYS_io_getevents: ::c_long = 208; +pub const SYS_io_submit: ::c_long = 209; +pub const SYS_io_cancel: ::c_long = 210; +pub const SYS_get_thread_area: ::c_long = 211; +pub const SYS_lookup_dcookie: ::c_long = 212; +pub const SYS_epoll_create: ::c_long = 213; +pub const SYS_epoll_ctl_old: ::c_long = 214; +pub const SYS_epoll_wait_old: ::c_long = 215; +pub const SYS_remap_file_pages: ::c_long = 216; +pub const SYS_getdents64: ::c_long = 217; +pub const SYS_set_tid_address: ::c_long = 218; +pub const SYS_restart_syscall: ::c_long = 219; +pub const SYS_semtimedop: ::c_long = 220; +pub const SYS_fadvise64: ::c_long = 221; +pub const SYS_timer_create: ::c_long = 222; +pub const SYS_timer_settime: ::c_long = 223; +pub const SYS_timer_gettime: ::c_long = 224; +pub const SYS_timer_getoverrun: ::c_long = 225; +pub const SYS_timer_delete: ::c_long = 226; +pub const SYS_clock_settime: ::c_long = 227; +pub const SYS_clock_gettime: ::c_long = 228; +pub const SYS_clock_getres: ::c_long = 229; +pub const SYS_clock_nanosleep: ::c_long = 230; +pub const SYS_exit_group: ::c_long = 231; +pub const SYS_epoll_wait: ::c_long = 232; +pub const SYS_epoll_ctl: ::c_long = 233; +pub const SYS_tgkill: ::c_long = 234; +pub const SYS_utimes: ::c_long = 235; +pub const SYS_vserver: ::c_long = 236; +pub const SYS_mbind: ::c_long = 237; +pub const SYS_set_mempolicy: ::c_long = 238; +pub const SYS_get_mempolicy: ::c_long = 239; +pub const SYS_mq_open: ::c_long = 240; +pub const SYS_mq_unlink: ::c_long = 241; +pub const SYS_mq_timedsend: ::c_long = 242; +pub const SYS_mq_timedreceive: ::c_long = 243; +pub const SYS_mq_notify: ::c_long = 244; +pub const SYS_mq_getsetattr: ::c_long = 245; +pub const SYS_kexec_load: ::c_long = 246; +pub const SYS_waitid: ::c_long = 247; +pub const SYS_add_key: ::c_long = 248; +pub const SYS_request_key: ::c_long = 249; +pub const SYS_keyctl: ::c_long = 250; +pub const SYS_ioprio_set: ::c_long = 251; +pub const SYS_ioprio_get: ::c_long = 252; +pub const SYS_inotify_init: ::c_long = 253; +pub const SYS_inotify_add_watch: ::c_long = 254; +pub const SYS_inotify_rm_watch: ::c_long = 255; +pub const SYS_migrate_pages: ::c_long = 256; +pub const SYS_openat: ::c_long = 257; +pub const SYS_mkdirat: ::c_long = 258; +pub const SYS_mknodat: ::c_long = 259; +pub const SYS_fchownat: ::c_long = 260; +pub const SYS_futimesat: ::c_long = 261; +pub const SYS_newfstatat: ::c_long = 262; +pub const SYS_unlinkat: ::c_long = 263; +pub const SYS_renameat: ::c_long = 264; +pub const SYS_linkat: ::c_long = 265; +pub const SYS_symlinkat: ::c_long = 266; +pub const SYS_readlinkat: ::c_long = 267; +pub const SYS_fchmodat: ::c_long = 268; +pub const SYS_faccessat: ::c_long = 269; +pub const SYS_pselect6: ::c_long = 270; +pub const SYS_ppoll: ::c_long = 271; +pub const SYS_unshare: ::c_long = 272; +pub const SYS_set_robust_list: ::c_long = 273; +pub const SYS_get_robust_list: ::c_long = 274; +pub const SYS_splice: ::c_long = 275; +pub const SYS_tee: ::c_long = 276; +pub const SYS_sync_file_range: ::c_long = 277; +pub const SYS_vmsplice: ::c_long = 278; +pub const SYS_move_pages: ::c_long = 279; +pub const SYS_utimensat: ::c_long = 280; +pub const SYS_epoll_pwait: ::c_long = 281; +pub const SYS_signalfd: ::c_long = 282; +pub const SYS_timerfd_create: ::c_long = 283; +pub const SYS_eventfd: ::c_long = 284; +pub const SYS_fallocate: ::c_long = 285; +pub const SYS_timerfd_settime: ::c_long = 286; +pub const SYS_timerfd_gettime: ::c_long = 287; +pub const SYS_accept4: ::c_long = 288; +pub const SYS_signalfd4: ::c_long = 289; +pub const SYS_eventfd2: ::c_long = 290; +pub const SYS_epoll_create1: ::c_long = 291; +pub const SYS_dup3: ::c_long = 292; +pub const SYS_pipe2: ::c_long = 293; +pub const SYS_inotify_init1: ::c_long = 294; +pub const SYS_preadv: ::c_long = 295; +pub const SYS_pwritev: ::c_long = 296; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 297; +pub const SYS_perf_event_open: ::c_long = 298; +pub const SYS_recvmmsg: ::c_long = 299; +pub const SYS_fanotify_init: ::c_long = 300; +pub const SYS_fanotify_mark: ::c_long = 301; +pub const SYS_prlimit64: ::c_long = 302; +pub const SYS_name_to_handle_at: ::c_long = 303; +pub const SYS_open_by_handle_at: ::c_long = 304; +pub const SYS_clock_adjtime: ::c_long = 305; +pub const SYS_syncfs: ::c_long = 306; +pub const SYS_sendmmsg: ::c_long = 307; +pub const SYS_setns: ::c_long = 308; +pub const SYS_getcpu: ::c_long = 309; +pub const SYS_process_vm_readv: ::c_long = 310; +pub const SYS_process_vm_writev: ::c_long = 311; +pub const SYS_kcmp: ::c_long = 312; +pub const SYS_finit_module: ::c_long = 313; +pub const SYS_sched_setattr: ::c_long = 314; +pub const SYS_sched_getattr: ::c_long = 315; +pub const SYS_renameat2: ::c_long = 316; +pub const SYS_seccomp: ::c_long = 317; +pub const SYS_getrandom: ::c_long = 318; +pub const SYS_memfd_create: ::c_long = 319; +pub const SYS_kexec_file_load: ::c_long = 320; +pub const SYS_bpf: ::c_long = 321; +pub const SYS_execveat: ::c_long = 322; +pub const SYS_userfaultfd: ::c_long = 323; +pub const SYS_membarrier: ::c_long = 324; +pub const SYS_mlock2: ::c_long = 325; +pub const SYS_copy_file_range: ::c_long = 326; +pub const SYS_preadv2: ::c_long = 327; +pub const SYS_pwritev2: ::c_long = 328; +pub const SYS_pkey_mprotect: ::c_long = 329; +pub const SYS_pkey_alloc: ::c_long = 330; +pub const SYS_pkey_free: ::c_long = 331; +pub const SYS_statx: ::c_long = 332; + +// offsets in user_regs_structs, from sys/reg.h +pub const R15: ::c_int = 0; +pub const R14: ::c_int = 1; +pub const R13: ::c_int = 2; +pub const R12: ::c_int = 3; +pub const RBP: ::c_int = 4; +pub const RBX: ::c_int = 5; +pub const R11: ::c_int = 6; +pub const R10: ::c_int = 7; +pub const R9: ::c_int = 8; +pub const R8: ::c_int = 9; +pub const RAX: ::c_int = 10; +pub const RCX: ::c_int = 11; +pub const RDX: ::c_int = 12; +pub const RSI: ::c_int = 13; +pub const RDI: ::c_int = 14; +pub const ORIG_RAX: ::c_int = 15; +pub const RIP: ::c_int = 16; +pub const CS: ::c_int = 17; +pub const EFLAGS: ::c_int = 18; +pub const RSP: ::c_int = 19; +pub const SS: ::c_int = 20; +pub const FS_BASE: ::c_int = 21; +pub const GS_BASE: ::c_int = 22; +pub const DS: ::c_int = 23; +pub const ES: ::c_int = 24; +pub const FS: ::c_int = 25; +pub const GS: ::c_int = 26; + +// offsets in mcontext_t.gregs from bits/signal.h +// GitHub repo: ifduyue/musl/ +// commit: b4b1e10364c8737a632be61582e05a8d3acf5690 +// file: arch/x86_64/bits/signal.h#L9-L56 +pub const REG_R8: ::c_int = 0; +pub const REG_R9: ::c_int = 1; +pub const REG_R10: ::c_int = 2; +pub const REG_R11: ::c_int = 3; +pub const REG_R12: ::c_int = 4; +pub const REG_R13: ::c_int = 5; +pub const REG_R14: ::c_int = 6; +pub const REG_R15: ::c_int = 7; +pub const REG_RDI: ::c_int = 8; +pub const REG_RSI: ::c_int = 9; +pub const REG_RBP: ::c_int = 10; +pub const REG_RBX: ::c_int = 11; +pub const REG_RDX: ::c_int = 12; +pub const REG_RAX: ::c_int = 13; +pub const REG_RCX: ::c_int = 14; +pub const REG_RSP: ::c_int = 15; +pub const REG_RIP: ::c_int = 16; +pub const REG_EFL: ::c_int = 17; +pub const REG_CSGSFS: ::c_int = 18; +pub const REG_ERR: ::c_int = 19; +pub const REG_TRAPNO: ::c_int = 20; +pub const REG_OLDMASK: ::c_int = 21; +pub const REG_CR2: ::c_int = 22; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_32BIT: ::c_int = 0x0040; +pub const O_APPEND: ::c_int = 1024; +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_LARGEFILE: ::c_int = 0; +pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_ASYNC: ::c_int = 0x2000; + +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_SETOWN: ::c_int = 8; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOL_SOCKET: ::c_int = 1; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const TIOCINQ: ::c_int = ::FIONREAD; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const FIOCLEX: ::c_int = 0x5451; +pub const FIONCLEX: ::c_int = 0x5450; +pub const FIONBIO: ::c_int = 0x5421; +pub const EDEADLK: ::c_int = 35; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const EXTPROC: ::tcflag_t = 0x00010000; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; +pub const TCGETS: ::c_int = 0x5401; +pub const TCSETS: ::c_int = 0x5402; +pub const TCSETSW: ::c_int = 0x5403; +pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETA: ::c_int = 0x5405; +pub const TCSETA: ::c_int = 0x5406; +pub const TCSETAW: ::c_int = 0x5407; +pub const TCSETAF: ::c_int = 0x5408; +pub const TCSBRK: ::c_int = 0x5409; +pub const TCXONC: ::c_int = 0x540A; +pub const TCFLSH: ::c_int = 0x540B; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x540F; +pub const TIOCSPGRP: ::c_int = 0x5410; +pub const TIOCOUTQ: ::c_int = 0x5411; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x5413; +pub const TIOCSWINSZ: ::c_int = 0x5414; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x541B; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +extern "C" { + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/mod.rs new file mode 100644 index 0000000..2c5d375 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/musl/mod.rs @@ -0,0 +1,436 @@ +pub type pthread_t = *mut ::c_void; +pub type clock_t = c_long; +pub type time_t = c_long; +pub type suseconds_t = c_long; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i64; + +pub type shmatt_t = ::c_ulong; +pub type msgqnum_t = ::c_ulong; +pub type msglen_t = ::c_ulong; +pub type fsblkcnt_t = ::c_ulonglong; +pub type fsfilcnt_t = ::c_ulonglong; +pub type rlim_t = ::c_ulonglong; + +pub type flock64 = flock; + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut ::c_void { + #[repr(C)] + struct siginfo_sigfault { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + si_addr: *mut ::c_void, + } + + (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + } + + pub unsafe fn si_value(&self) -> ::sigval { + #[repr(C)] + struct siginfo_si_value { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + _si_timerid: ::c_int, + _si_overrun: ::c_int, + si_value: ::sigval, + } + + (*(self as *const siginfo_t as *const siginfo_si_value)).si_value + } +} + +s! { + pub struct aiocb { + pub aio_fildes: ::c_int, + pub aio_lio_opcode: ::c_int, + pub aio_reqprio: ::c_int, + pub aio_buf: *mut ::c_void, + pub aio_nbytes: ::size_t, + pub aio_sigevent: ::sigevent, + __td: *mut ::c_void, + __lock: [::c_int; 2], + __err: ::c_int, + __ret: ::ssize_t, + pub aio_offset: off_t, + __next: *mut ::c_void, + __prev: *mut ::c_void, + #[cfg(target_pointer_width = "32")] + __dummy4: [::c_char; 24], + #[cfg(target_pointer_width = "64")] + __dummy4: [::c_char; 16], + } + + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + #[cfg(target_endian = "little")] + pub f_fsid: ::c_ulong, + #[cfg(target_pointer_width = "32")] + __f_unused: ::c_int, + #[cfg(target_endian = "big")] + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + pub __c_ispeed: ::speed_t, + pub __c_ospeed: ::speed_t, + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } +} + +s_no_extra_traits! { + pub struct sysinfo { + pub uptime: ::c_ulong, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub __reserved: [::c_char; 256], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sysinfo { + fn eq(&self, other: &sysinfo) -> bool { + self.uptime == other.uptime + && self.loads == other.loads + && self.totalram == other.totalram + && self.freeram == other.freeram + && self.sharedram == other.sharedram + && self.bufferram == other.bufferram + && self.totalswap == other.totalswap + && self.freeswap == other.freeswap + && self.procs == other.procs + && self.pad == other.pad + && self.totalhigh == other.totalhigh + && self.freehigh == other.freehigh + && self.mem_unit == other.mem_unit + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for sysinfo {} + + impl ::fmt::Debug for sysinfo { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sysinfo") + .field("uptime", &self.uptime) + .field("loads", &self.loads) + .field("totalram", &self.totalram) + .field("freeram", &self.freeram) + .field("sharedram", &self.sharedram) + .field("bufferram", &self.bufferram) + .field("totalswap", &self.totalswap) + .field("freeswap", &self.freeswap) + .field("procs", &self.procs) + .field("pad", &self.pad) + .field("totalhigh", &self.totalhigh) + .field("freehigh", &self.freehigh) + .field("mem_unit", &self.mem_unit) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } + } + + impl ::hash::Hash for sysinfo { + fn hash(&self, state: &mut H) { + self.uptime.hash(state); + self.loads.hash(state); + self.totalram.hash(state); + self.freeram.hash(state); + self.sharedram.hash(state); + self.bufferram.hash(state); + self.totalswap.hash(state); + self.freeswap.hash(state); + self.procs.hash(state); + self.pad.hash(state); + self.totalhigh.hash(state); + self.freehigh.hash(state); + self.mem_unit.hash(state); + self.__reserved.hash(state); + } + } + } +} + +pub const MS_RMT_MASK: ::c_ulong = 0x02800051; + +pub const SFD_CLOEXEC: ::c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: ::c_int = 512; +pub const O_NOATIME: ::c_int = 0o1000000; +pub const O_CLOEXEC: ::c_int = 0x80000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const BUFSIZ: ::c_uint = 1024; +pub const TMP_MAX: ::c_uint = 10000; +pub const FOPEN_MAX: ::c_uint = 1000; +pub const O_PATH: ::c_int = 0o10000000; +pub const O_EXEC: ::c_int = 0o10000000; +pub const O_SEARCH: ::c_int = 0o10000000; +pub const O_ACCMODE: ::c_int = 0o10000003; +pub const O_NDELAY: ::c_int = O_NONBLOCK; +pub const NI_MAXHOST: ::socklen_t = 255; +pub const PTHREAD_STACK_MIN: ::size_t = 2048; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + +pub const RLIM_INFINITY: ::rlim_t = !0; +pub const RLIMIT_RTTIME: ::c_int = 15; + +pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; + +pub const SOCK_DCCP: ::c_int = 6; +pub const SOCK_PACKET: ::c_int = 10; + +pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; +pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; +pub const TCP_THIN_DUPACK: ::c_int = 17; +pub const TCP_USER_TIMEOUT: ::c_int = 18; +pub const TCP_REPAIR: ::c_int = 19; +pub const TCP_REPAIR_QUEUE: ::c_int = 20; +pub const TCP_QUEUE_SEQ: ::c_int = 21; +pub const TCP_REPAIR_OPTIONS: ::c_int = 22; +pub const TCP_FASTOPEN: ::c_int = 23; +pub const TCP_TIMESTAMP: ::c_int = 24; + +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = ::SIGSYS; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + +pub const CPU_SETSIZE: ::c_int = 128; + +pub const PTRACE_TRACEME: ::c_int = 0; +pub const PTRACE_PEEKTEXT: ::c_int = 1; +pub const PTRACE_PEEKDATA: ::c_int = 2; +pub const PTRACE_PEEKUSER: ::c_int = 3; +pub const PTRACE_POKETEXT: ::c_int = 4; +pub const PTRACE_POKEDATA: ::c_int = 5; +pub const PTRACE_POKEUSER: ::c_int = 6; +pub const PTRACE_CONT: ::c_int = 7; +pub const PTRACE_KILL: ::c_int = 8; +pub const PTRACE_SINGLESTEP: ::c_int = 9; +pub const PTRACE_GETREGS: ::c_int = 12; +pub const PTRACE_SETREGS: ::c_int = 13; +pub const PTRACE_GETFPREGS: ::c_int = 14; +pub const PTRACE_SETFPREGS: ::c_int = 15; +pub const PTRACE_ATTACH: ::c_int = 16; +pub const PTRACE_DETACH: ::c_int = 17; +pub const PTRACE_GETFPXREGS: ::c_int = 18; +pub const PTRACE_SETFPXREGS: ::c_int = 19; +pub const PTRACE_SYSCALL: ::c_int = 24; +pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; +pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; +pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; +pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; +pub const PTRACE_GETREGSET: ::c_int = 0x4204; +pub const PTRACE_SETREGSET: ::c_int = 0x4205; +pub const PTRACE_SEIZE: ::c_int = 0x4206; +pub const PTRACE_INTERRUPT: ::c_int = 0x4207; +pub const PTRACE_LISTEN: ::c_int = 0x4208; +pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; + +pub const EPOLLWAKEUP: ::c_int = 0x20000000; + +pub const SEEK_DATA: ::c_int = 3; +pub const SEEK_HOLE: ::c_int = 4; + +pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK; + +pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; + +// TODO(#247) Temporarily musl-specific (available since musl 0.9.12 / Linux +// kernel 3.10). See also linux_like/mod.rs +pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; +pub const CLOCK_TAI: ::clockid_t = 11; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; + +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_MARK: ::c_int = 36; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_BUSY_POLL: ::c_int = 46; + +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_LOCKS: ::c_int = 10; +pub const RLIMIT_SIGPENDING: ::c_int = 11; +pub const RLIMIT_MSGQUEUE: ::c_int = 12; +pub const RLIMIT_NICE: ::c_int = 13; +pub const RLIMIT_RTPRIO: ::c_int = 14; + +extern "C" { + pub fn sendmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_uint, + ) -> ::c_int; + pub fn recvmmsg( + sockfd: ::c_int, + msgvec: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_uint, + timeout: *mut ::timespec, + ) -> ::c_int; + + pub fn getrlimit64(resource: ::c_int, rlim: *mut ::rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::c_int, rlim: *const ::rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn prlimit( + pid: ::pid_t, + resource: ::c_int, + new_limit: *const ::rlimit, + old_limit: *mut ::rlimit, + ) -> ::c_int; + pub fn prlimit64( + pid: ::pid_t, + resource: ::c_int, + new_limit: *const ::rlimit64, + old_limit: *mut ::rlimit64, + ) -> ::c_int; + + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + pub fn ptrace(request: ::c_int, ...) -> ::c_long; + pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; + pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; + pub fn pthread_getaffinity_np( + thread: ::pthread_t, + cpusetsize: ::size_t, + cpuset: *mut ::cpu_set_t, + ) -> ::c_int; + pub fn pthread_setaffinity_np( + thread: ::pthread_t, + cpusetsize: ::size_t, + cpuset: *const ::cpu_set_t, + ) -> ::c_int; + pub fn sched_getcpu() -> ::c_int; +} + +cfg_if! { + if #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "mips64", + target_arch = "powerpc64"))] { + mod b64; + pub use self::b64::*; + } else if #[cfg(any(target_arch = "x86", + target_arch = "mips", + target_arch = "powerpc", + target_arch = "hexagon", + target_arch = "arm"))] { + mod b32; + pub use self::b32::*; + } else { } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/no_align.rs new file mode 100644 index 0000000..13c2b71 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/linux/no_align.rs @@ -0,0 +1,84 @@ +macro_rules! expand_align { + () => { + s! { + pub struct pthread_mutexattr_t { + #[cfg(any(target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", + target_env = "musl")))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", + target_env = "musl"))))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_rwlockattr_t { + #[cfg(target_env = "musl")] + __align: [::c_int; 0], + #[cfg(not(target_env = "musl"))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + + s_no_extra_traits! { + pub struct pthread_cond_t { + #[cfg(target_env = "musl")] + __align: [*const ::c_void; 0], + #[cfg(not(target_env = "musl"))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "sparc", + all(target_arch = "x86_64", + target_pointer_width = "32")))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "sparc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "sparc", + all(target_arch = "x86_64", + target_pointer_width = "32")))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "sparc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + } + }; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/mod.rs new file mode 100644 index 0000000..792548f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/linux_like/mod.rs @@ -0,0 +1,1569 @@ +pub type sa_family_t = u16; +pub type speed_t = ::c_uint; +pub type tcflag_t = ::c_uint; +pub type clockid_t = ::c_int; +pub type key_t = ::c_int; +pub type id_t = ::c_uint; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum timezone {} +impl ::Copy for timezone {} +impl ::Clone for timezone { + fn clone(&self) -> timezone { + *self + } +} + +s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + pub imr_sourceaddr: in_addr, + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: socklen_t, + + #[cfg(any(target_os = "linux", + target_os = "emscripten"))] + pub ai_addr: *mut ::sockaddr, + + pub ai_canonname: *mut c_char, + + #[cfg(target_os = "android")] + pub ai_addr: *mut ::sockaddr, + + pub ai_next: *mut addrinfo, + } + + pub struct sockaddr_ll { + pub sll_family: ::c_ushort, + pub sll_protocol: ::c_ushort, + pub sll_ifindex: ::c_int, + pub sll_hatype: ::c_ushort, + pub sll_pkttype: ::c_uchar, + pub sll_halen: ::c_uchar, + pub sll_addr: [::c_uchar; 8] + } + + pub struct fd_set { + fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], + } + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + pub tm_gmtoff: ::c_long, + pub tm_zone: *const ::c_char, + } + + pub struct sched_param { + pub sched_priority: ::c_int, + #[cfg(any(target_env = "musl", target_os = "emscripten"))] + pub sched_ss_low_priority: ::c_int, + #[cfg(any(target_env = "musl", target_os = "emscripten"))] + pub sched_ss_repl_period: ::timespec, + #[cfg(any(target_env = "musl", target_os = "emscripten"))] + pub sched_ss_init_budget: ::timespec, + #[cfg(any(target_env = "musl", target_os = "emscripten"))] + pub sched_ss_max_repl: ::c_int, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct in_pktinfo { + pub ipi_ifindex: ::c_int, + pub ipi_spec_dst: ::in_addr, + pub ipi_addr: ::in_addr, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: ::c_uint, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union + pub ifa_data: *mut ::c_void + } + + pub struct in6_rtmsg { + rtmsg_dst: ::in6_addr, + rtmsg_src: ::in6_addr, + rtmsg_gateway: ::in6_addr, + rtmsg_type: u32, + rtmsg_dst_len: u16, + rtmsg_src_len: u16, + rtmsg_metric: u32, + rtmsg_info: ::c_ulong, + rtmsg_flags: u32, + rtmsg_ifindex: ::c_int, + } + + pub struct arpreq { + pub arp_pa: ::sockaddr, + pub arp_ha: ::sockaddr, + pub arp_flags: ::c_int, + pub arp_netmask: ::sockaddr, + pub arp_dev: [::c_char; 16], + } + + pub struct arpreq_old { + pub arp_pa: ::sockaddr, + pub arp_ha: ::sockaddr, + pub arp_flags: ::c_int, + pub arp_netmask: ::sockaddr, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + pub struct mmsghdr { + pub msg_hdr: ::msghdr, + pub msg_len: ::c_uint, + } +} + +s_no_extra_traits! { + #[cfg_attr( + any( + all( + target_arch = "x86", + not(target_env = "musl"), + not(target_os = "android")), + target_arch = "x86_64"), + repr(packed))] + pub struct epoll_event { + pub events: u32, + pub u64: u64, + } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 108] + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + __ss_align: ::size_t, + #[cfg(target_pointer_width = "32")] + __ss_pad2: [u8; 128 - 2 * 4], + #[cfg(target_pointer_width = "64")] + __ss_pad2: [u8; 128 - 2 * 8], + } + + pub struct utsname { + pub sysname: [::c_char; 65], + pub nodename: [::c_char; 65], + pub release: [::c_char; 65], + pub version: [::c_char; 65], + pub machine: [::c_char; 65], + pub domainname: [::c_char; 65] + } + + pub struct sigevent { + pub sigev_value: ::sigval, + pub sigev_signo: ::c_int, + pub sigev_notify: ::c_int, + // Actually a union. We only expose sigev_notify_thread_id because it's + // the most useful member + pub sigev_notify_thread_id: ::c_int, + #[cfg(target_pointer_width = "64")] + __unused1: [::c_int; 11], + #[cfg(target_pointer_width = "32")] + __unused1: [::c_int; 12] + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for epoll_event { + fn eq(&self, other: &epoll_event) -> bool { + self.events == other.events + && self.u64 == other.u64 + } + } + impl Eq for epoll_event {} + impl ::fmt::Debug for epoll_event { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let events = self.events; + let u64 = self.u64; + f.debug_struct("epoll_event") + .field("events", &events) + .field("u64", &u64) + .finish() + } + } + impl ::hash::Hash for epoll_event { + fn hash(&self, state: &mut H) { + let events = self.events; + let u64 = self.u64; + events.hash(state); + u64.hash(state); + } + } + + impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a, b)| a == b) + } + } + impl Eq for sockaddr_un {} + impl ::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } + } + impl ::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_family.hash(state); + self.sun_path.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_family == other.ss_family + && self + .__ss_pad2 + .iter() + .zip(other.__ss_pad2.iter()) + .all(|(a, b)| a == b) + } + } + + impl Eq for sockaddr_storage {} + + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_family", &self.ss_family) + .field("__ss_align", &self.__ss_align) + // FIXME: .field("__ss_pad2", &self.__ss_pad2) + .finish() + } + } + + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_family.hash(state); + self.__ss_pad2.hash(state); + } + } + + impl PartialEq for utsname { + fn eq(&self, other: &utsname) -> bool { + self.sysname + .iter() + .zip(other.sysname.iter()) + .all(|(a, b)| a == b) + && self + .nodename + .iter() + .zip(other.nodename.iter()) + .all(|(a, b)| a == b) + && self + .release + .iter() + .zip(other.release.iter()) + .all(|(a, b)| a == b) + && self + .version + .iter() + .zip(other.version.iter()) + .all(|(a, b)| a == b) + && self + .machine + .iter() + .zip(other.machine.iter()) + .all(|(a, b)| a == b) + && self + .domainname + .iter() + .zip(other.domainname.iter()) + .all(|(a, b)| a == b) + } + } + + impl Eq for utsname {} + + impl ::fmt::Debug for utsname { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utsname") + // FIXME: .field("sysname", &self.sysname) + // FIXME: .field("nodename", &self.nodename) + // FIXME: .field("release", &self.release) + // FIXME: .field("version", &self.version) + // FIXME: .field("machine", &self.machine) + // FIXME: .field("domainname", &self.domainname) + .finish() + } + } + + impl ::hash::Hash for utsname { + fn hash(&self, state: &mut H) { + self.sysname.hash(state); + self.nodename.hash(state); + self.release.hash(state); + self.version.hash(state); + self.machine.hash(state); + self.domainname.hash(state); + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_value == other.sigev_value + && self.sigev_signo == other.sigev_signo + && self.sigev_notify == other.sigev_notify + && self.sigev_notify_thread_id + == other.sigev_notify_thread_id + } + } + impl Eq for sigevent {} + impl ::fmt::Debug for sigevent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sigevent") + .field("sigev_value", &self.sigev_value) + .field("sigev_signo", &self.sigev_signo) + .field("sigev_notify", &self.sigev_notify) + .field("sigev_notify_thread_id", + &self.sigev_notify_thread_id) + .finish() + } + } + impl ::hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_value.hash(state); + self.sigev_signo.hash(state); + self.sigev_notify.hash(state); + self.sigev_notify_thread_id.hash(state); + } + } + } +} + +// intentionally not public, only used for fd_set +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + const ULONG_SIZE: usize = 32; + } else if #[cfg(target_pointer_width = "64")] { + const ULONG_SIZE: usize = 64; + } else { + // Unknown target_pointer_width + } +} + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 2147483647; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 2; +pub const _IOLBF: ::c_int = 1; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; + +// Linux-specific fcntls +pub const F_SETLEASE: ::c_int = 1024; +pub const F_GETLEASE: ::c_int = 1025; +pub const F_NOTIFY: ::c_int = 1026; +pub const F_CANCELLK: ::c_int = 1029; +pub const F_DUPFD_CLOEXEC: ::c_int = 1030; +pub const F_SETPIPE_SZ: ::c_int = 1031; +pub const F_GETPIPE_SZ: ::c_int = 1032; +pub const F_ADD_SEALS: ::c_int = 1033; +pub const F_GET_SEALS: ::c_int = 1034; + +pub const F_SEAL_SEAL: ::c_int = 0x0001; +pub const F_SEAL_SHRINK: ::c_int = 0x0002; +pub const F_SEAL_GROW: ::c_int = 0x0004; +pub const F_SEAL_WRITE: ::c_int = 0x0008; + +// TODO(#235): Include file sealing fcntls once we have a way to verify them. + +pub const SIGTRAP: ::c_int = 5; + +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; + +pub const CLOCK_REALTIME: ::clockid_t = 0; +pub const CLOCK_MONOTONIC: ::clockid_t = 1; +pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3; +pub const CLOCK_MONOTONIC_RAW: ::clockid_t = 4; +pub const CLOCK_REALTIME_COARSE: ::clockid_t = 5; +pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = 6; +pub const CLOCK_BOOTTIME: ::clockid_t = 7; +pub const CLOCK_REALTIME_ALARM: ::clockid_t = 8; +pub const CLOCK_BOOTTIME_ALARM: ::clockid_t = 9; +// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep +// 2014.) See also musl/mod.rs +// pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; +// pub const CLOCK_TAI: ::clockid_t = 11; +pub const TIMER_ABSTIME: ::c_int = 1; + +pub const RUSAGE_SELF: ::c_int = 0; + +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; + +pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; + +pub const S_IFIFO: ::mode_t = 4096; +pub const S_IFCHR: ::mode_t = 8192; +pub const S_IFBLK: ::mode_t = 24576; +pub const S_IFDIR: ::mode_t = 16384; +pub const S_IFREG: ::mode_t = 32768; +pub const S_IFLNK: ::mode_t = 40960; +pub const S_IFSOCK: ::mode_t = 49152; +pub const S_IFMT: ::mode_t = 61440; +pub const S_IRWXU: ::mode_t = 448; +pub const S_IXUSR: ::mode_t = 64; +pub const S_IWUSR: ::mode_t = 128; +pub const S_IRUSR: ::mode_t = 256; +pub const S_IRWXG: ::mode_t = 56; +pub const S_IXGRP: ::mode_t = 8; +pub const S_IWGRP: ::mode_t = 16; +pub const S_IRGRP: ::mode_t = 32; +pub const S_IRWXO: ::mode_t = 7; +pub const S_IXOTH: ::mode_t = 1; +pub const S_IWOTH: ::mode_t = 2; +pub const S_IROTH: ::mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const LC_CTYPE: ::c_int = 0; +pub const LC_NUMERIC: ::c_int = 1; +pub const LC_TIME: ::c_int = 2; +pub const LC_COLLATE: ::c_int = 3; +pub const LC_MONETARY: ::c_int = 4; +pub const LC_MESSAGES: ::c_int = 5; +pub const LC_ALL: ::c_int = 6; +pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE); +pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC); +pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME); +pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE); +pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY); +pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES); +// LC_ALL_MASK defined per platform + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +// MS_ flags for msync(2) +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MS_SYNC: ::c_int = 0x0004; + +// MS_ flags for mount(2) +pub const MS_RDONLY: ::c_ulong = 0x01; +pub const MS_NOSUID: ::c_ulong = 0x02; +pub const MS_NODEV: ::c_ulong = 0x04; +pub const MS_NOEXEC: ::c_ulong = 0x08; +pub const MS_SYNCHRONOUS: ::c_ulong = 0x10; +pub const MS_REMOUNT: ::c_ulong = 0x20; +pub const MS_MANDLOCK: ::c_ulong = 0x40; +pub const MS_DIRSYNC: ::c_ulong = 0x80; +pub const MS_NOATIME: ::c_ulong = 0x0400; +pub const MS_NODIRATIME: ::c_ulong = 0x0800; +pub const MS_BIND: ::c_ulong = 0x1000; +pub const MS_MOVE: ::c_ulong = 0x2000; +pub const MS_REC: ::c_ulong = 0x4000; +pub const MS_SILENT: ::c_ulong = 0x8000; +pub const MS_POSIXACL: ::c_ulong = 0x010000; +pub const MS_UNBINDABLE: ::c_ulong = 0x020000; +pub const MS_PRIVATE: ::c_ulong = 0x040000; +pub const MS_SLAVE: ::c_ulong = 0x080000; +pub const MS_SHARED: ::c_ulong = 0x100000; +pub const MS_RELATIME: ::c_ulong = 0x200000; +pub const MS_KERNMOUNT: ::c_ulong = 0x400000; +pub const MS_I_VERSION: ::c_ulong = 0x800000; +pub const MS_STRICTATIME: ::c_ulong = 0x1000000; +pub const MS_ACTIVE: ::c_ulong = 0x40000000; +pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000; +pub const MS_MGC_MSK: ::c_ulong = 0xffff0000; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const EWOULDBLOCK: ::c_int = EAGAIN; + +pub const SCM_RIGHTS: ::c_int = 0x01; +pub const SCM_CREDENTIALS: ::c_int = 0x02; + +pub const PROT_GROWSDOWN: ::c_int = 0x1000000; +pub const PROT_GROWSUP: ::c_int = 0x2000000; + +pub const MAP_TYPE: ::c_int = 0x000f; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_FREE: ::c_int = 8; +pub const MADV_REMOVE: ::c_int = 9; +pub const MADV_DONTFORK: ::c_int = 10; +pub const MADV_DOFORK: ::c_int = 11; +pub const MADV_MERGEABLE: ::c_int = 12; +pub const MADV_UNMERGEABLE: ::c_int = 13; +pub const MADV_HUGEPAGE: ::c_int = 14; +pub const MADV_NOHUGEPAGE: ::c_int = 15; +pub const MADV_DONTDUMP: ::c_int = 16; +pub const MADV_DODUMP: ::c_int = 17; +pub const MADV_HWPOISON: ::c_int = 100; + +pub const IFF_UP: ::c_int = 0x1; +pub const IFF_BROADCAST: ::c_int = 0x2; +pub const IFF_DEBUG: ::c_int = 0x4; +pub const IFF_LOOPBACK: ::c_int = 0x8; +pub const IFF_POINTOPOINT: ::c_int = 0x10; +pub const IFF_NOTRAILERS: ::c_int = 0x20; +pub const IFF_RUNNING: ::c_int = 0x40; +pub const IFF_NOARP: ::c_int = 0x80; +pub const IFF_PROMISC: ::c_int = 0x100; +pub const IFF_ALLMULTI: ::c_int = 0x200; +pub const IFF_MASTER: ::c_int = 0x400; +pub const IFF_SLAVE: ::c_int = 0x800; +pub const IFF_MULTICAST: ::c_int = 0x1000; +pub const IFF_PORTSEL: ::c_int = 0x2000; +pub const IFF_AUTOMEDIA: ::c_int = 0x4000; +pub const IFF_DYNAMIC: ::c_int = 0x8000; + +pub const SOL_IP: ::c_int = 0; +pub const SOL_TCP: ::c_int = 6; +pub const SOL_UDP: ::c_int = 17; +pub const SOL_IPV6: ::c_int = 41; +pub const SOL_ICMPV6: ::c_int = 58; +pub const SOL_RAW: ::c_int = 255; +pub const SOL_DECNET: ::c_int = 261; +pub const SOL_X25: ::c_int = 262; +pub const SOL_PACKET: ::c_int = 263; +pub const SOL_ATM: ::c_int = 264; +pub const SOL_AAL: ::c_int = 265; +pub const SOL_IRDA: ::c_int = 266; +pub const SOL_NETBEUI: ::c_int = 267; +pub const SOL_LLC: ::c_int = 268; +pub const SOL_DCCP: ::c_int = 269; +pub const SOL_NETLINK: ::c_int = 270; +pub const SOL_TIPC: ::c_int = 271; +pub const SOL_BLUETOOTH: ::c_int = 274; +pub const SOL_ALG: ::c_int = 279; + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_UNIX: ::c_int = 1; +pub const AF_LOCAL: ::c_int = 1; +pub const AF_INET: ::c_int = 2; +pub const AF_AX25: ::c_int = 3; +pub const AF_IPX: ::c_int = 4; +pub const AF_APPLETALK: ::c_int = 5; +pub const AF_NETROM: ::c_int = 6; +pub const AF_BRIDGE: ::c_int = 7; +pub const AF_ATMPVC: ::c_int = 8; +pub const AF_X25: ::c_int = 9; +pub const AF_INET6: ::c_int = 10; +pub const AF_ROSE: ::c_int = 11; +pub const AF_DECnet: ::c_int = 12; +pub const AF_NETBEUI: ::c_int = 13; +pub const AF_SECURITY: ::c_int = 14; +pub const AF_KEY: ::c_int = 15; +pub const AF_NETLINK: ::c_int = 16; +pub const AF_ROUTE: ::c_int = AF_NETLINK; +pub const AF_PACKET: ::c_int = 17; +pub const AF_ASH: ::c_int = 18; +pub const AF_ECONET: ::c_int = 19; +pub const AF_ATMSVC: ::c_int = 20; +pub const AF_RDS: ::c_int = 21; +pub const AF_SNA: ::c_int = 22; +pub const AF_IRDA: ::c_int = 23; +pub const AF_PPPOX: ::c_int = 24; +pub const AF_WANPIPE: ::c_int = 25; +pub const AF_LLC: ::c_int = 26; +pub const AF_CAN: ::c_int = 29; +pub const AF_TIPC: ::c_int = 30; +pub const AF_BLUETOOTH: ::c_int = 31; +pub const AF_IUCV: ::c_int = 32; +pub const AF_RXRPC: ::c_int = 33; +pub const AF_ISDN: ::c_int = 34; +pub const AF_PHONET: ::c_int = 35; +pub const AF_IEEE802154: ::c_int = 36; +pub const AF_CAIF: ::c_int = 37; +pub const AF_ALG: ::c_int = 38; + +pub const PF_UNSPEC: ::c_int = AF_UNSPEC; +pub const PF_UNIX: ::c_int = AF_UNIX; +pub const PF_LOCAL: ::c_int = AF_LOCAL; +pub const PF_INET: ::c_int = AF_INET; +pub const PF_AX25: ::c_int = AF_AX25; +pub const PF_IPX: ::c_int = AF_IPX; +pub const PF_APPLETALK: ::c_int = AF_APPLETALK; +pub const PF_NETROM: ::c_int = AF_NETROM; +pub const PF_BRIDGE: ::c_int = AF_BRIDGE; +pub const PF_ATMPVC: ::c_int = AF_ATMPVC; +pub const PF_X25: ::c_int = AF_X25; +pub const PF_INET6: ::c_int = AF_INET6; +pub const PF_ROSE: ::c_int = AF_ROSE; +pub const PF_DECnet: ::c_int = AF_DECnet; +pub const PF_NETBEUI: ::c_int = AF_NETBEUI; +pub const PF_SECURITY: ::c_int = AF_SECURITY; +pub const PF_KEY: ::c_int = AF_KEY; +pub const PF_NETLINK: ::c_int = AF_NETLINK; +pub const PF_ROUTE: ::c_int = AF_ROUTE; +pub const PF_PACKET: ::c_int = AF_PACKET; +pub const PF_ASH: ::c_int = AF_ASH; +pub const PF_ECONET: ::c_int = AF_ECONET; +pub const PF_ATMSVC: ::c_int = AF_ATMSVC; +pub const PF_RDS: ::c_int = AF_RDS; +pub const PF_SNA: ::c_int = AF_SNA; +pub const PF_IRDA: ::c_int = AF_IRDA; +pub const PF_PPPOX: ::c_int = AF_PPPOX; +pub const PF_WANPIPE: ::c_int = AF_WANPIPE; +pub const PF_LLC: ::c_int = AF_LLC; +pub const PF_CAN: ::c_int = AF_CAN; +pub const PF_TIPC: ::c_int = AF_TIPC; +pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; +pub const PF_IUCV: ::c_int = AF_IUCV; +pub const PF_RXRPC: ::c_int = AF_RXRPC; +pub const PF_ISDN: ::c_int = AF_ISDN; +pub const PF_PHONET: ::c_int = AF_PHONET; +pub const PF_IEEE802154: ::c_int = AF_IEEE802154; +pub const PF_CAIF: ::c_int = AF_CAIF; +pub const PF_ALG: ::c_int = AF_ALG; + +pub const SOMAXCONN: ::c_int = 128; + +pub const MSG_OOB: ::c_int = 1; +pub const MSG_PEEK: ::c_int = 2; +pub const MSG_DONTROUTE: ::c_int = 4; +pub const MSG_CTRUNC: ::c_int = 8; +pub const MSG_TRUNC: ::c_int = 0x20; +pub const MSG_DONTWAIT: ::c_int = 0x40; +pub const MSG_EOR: ::c_int = 0x80; +pub const MSG_WAITALL: ::c_int = 0x100; +pub const MSG_FIN: ::c_int = 0x200; +pub const MSG_SYN: ::c_int = 0x400; +pub const MSG_CONFIRM: ::c_int = 0x800; +pub const MSG_RST: ::c_int = 0x1000; +pub const MSG_ERRQUEUE: ::c_int = 0x2000; +pub const MSG_NOSIGNAL: ::c_int = 0x4000; +pub const MSG_MORE: ::c_int = 0x8000; +pub const MSG_WAITFORONE: ::c_int = 0x10000; +pub const MSG_FASTOPEN: ::c_int = 0x20000000; +pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000; + +pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; + +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_RDM: ::c_int = 4; +pub const IP_MULTICAST_IF: ::c_int = 32; +pub const IP_MULTICAST_TTL: ::c_int = 33; +pub const IP_MULTICAST_LOOP: ::c_int = 34; +pub const IP_TOS: ::c_int = 1; +pub const IP_TTL: ::c_int = 2; +pub const IP_HDRINCL: ::c_int = 3; +pub const IP_PKTINFO: ::c_int = 8; +pub const IP_RECVTOS: ::c_int = 13; +pub const IP_RECVERR: ::c_int = 11; +pub const IP_ADD_MEMBERSHIP: ::c_int = 35; +pub const IP_DROP_MEMBERSHIP: ::c_int = 36; +pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 39; +pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 40; +pub const IP_TRANSPARENT: ::c_int = 19; +pub const IPV6_ADDRFORM: ::c_int = 1; +pub const IPV6_2292PKTINFO: ::c_int = 2; +pub const IPV6_2292HOPOPTS: ::c_int = 3; +pub const IPV6_2292DSTOPTS: ::c_int = 4; +pub const IPV6_2292RTHDR: ::c_int = 5; +pub const IPV6_2292PKTOPTIONS: ::c_int = 6; +pub const IPV6_CHECKSUM: ::c_int = 7; +pub const IPV6_2292HOPLIMIT: ::c_int = 8; +pub const IPV6_NEXTHOP: ::c_int = 9; +pub const IPV6_FLOWINFO: ::c_int = 11; +pub const IPV6_UNICAST_HOPS: ::c_int = 16; +pub const IPV6_MULTICAST_IF: ::c_int = 17; +pub const IPV6_MULTICAST_HOPS: ::c_int = 18; +pub const IPV6_MULTICAST_LOOP: ::c_int = 19; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; +pub const IPV6_ROUTER_ALERT: ::c_int = 22; +pub const IPV6_MTU_DISCOVER: ::c_int = 23; +pub const IPV6_MTU: ::c_int = 24; +pub const IPV6_RECVERR: ::c_int = 25; +pub const IPV6_V6ONLY: ::c_int = 26; +pub const IPV6_JOIN_ANYCAST: ::c_int = 27; +pub const IPV6_LEAVE_ANYCAST: ::c_int = 28; +pub const IPV6_RECVPKTINFO: ::c_int = 49; +pub const IPV6_PKTINFO: ::c_int = 50; +pub const IPV6_RECVTCLASS: ::c_int = 66; +pub const IPV6_TCLASS: ::c_int = 67; + +pub const TCP_NODELAY: ::c_int = 1; +pub const TCP_MAXSEG: ::c_int = 2; +pub const TCP_CORK: ::c_int = 3; +pub const TCP_KEEPIDLE: ::c_int = 4; +pub const TCP_KEEPINTVL: ::c_int = 5; +pub const TCP_KEEPCNT: ::c_int = 6; +pub const TCP_SYNCNT: ::c_int = 7; +pub const TCP_LINGER2: ::c_int = 8; +pub const TCP_DEFER_ACCEPT: ::c_int = 9; +pub const TCP_WINDOW_CLAMP: ::c_int = 10; +pub const TCP_INFO: ::c_int = 11; +pub const TCP_QUICKACK: ::c_int = 12; +pub const TCP_CONGESTION: ::c_int = 13; + +pub const SO_DEBUG: ::c_int = 1; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; + +pub const SS_ONSTACK: ::c_int = 1; +pub const SS_DISABLE: ::c_int = 2; + +pub const PATH_MAX: ::c_int = 4096; + +pub const FD_SETSIZE: usize = 1024; + +pub const EPOLLIN: ::c_int = 0x1; +pub const EPOLLPRI: ::c_int = 0x2; +pub const EPOLLOUT: ::c_int = 0x4; +pub const EPOLLRDNORM: ::c_int = 0x40; +pub const EPOLLRDBAND: ::c_int = 0x80; +pub const EPOLLWRNORM: ::c_int = 0x100; +pub const EPOLLWRBAND: ::c_int = 0x200; +pub const EPOLLMSG: ::c_int = 0x400; +pub const EPOLLERR: ::c_int = 0x8; +pub const EPOLLHUP: ::c_int = 0x10; +pub const EPOLLET: ::c_int = 0x80000000; + +pub const EPOLL_CTL_ADD: ::c_int = 1; +pub const EPOLL_CTL_MOD: ::c_int = 3; +pub const EPOLL_CTL_DEL: ::c_int = 2; + +pub const MNT_DETACH: ::c_int = 0x2; +pub const MNT_EXPIRE: ::c_int = 0x4; + +pub const Q_GETFMT: ::c_int = 0x800004; +pub const Q_GETINFO: ::c_int = 0x800005; +pub const Q_SETINFO: ::c_int = 0x800006; +pub const QIF_BLIMITS: u32 = 1; +pub const QIF_SPACE: u32 = 2; +pub const QIF_ILIMITS: u32 = 4; +pub const QIF_INODES: u32 = 8; +pub const QIF_BTIME: u32 = 16; +pub const QIF_ITIME: u32 = 32; +pub const QIF_LIMITS: u32 = 5; +pub const QIF_USAGE: u32 = 10; +pub const QIF_TIMES: u32 = 48; +pub const QIF_ALL: u32 = 63; + +pub const MNT_FORCE: ::c_int = 0x1; + +pub const Q_SYNC: ::c_int = 0x800001; +pub const Q_QUOTAON: ::c_int = 0x800002; +pub const Q_QUOTAOFF: ::c_int = 0x800003; +pub const Q_GETQUOTA: ::c_int = 0x800007; +pub const Q_SETQUOTA: ::c_int = 0x800008; + +pub const TCIOFF: ::c_int = 2; +pub const TCION: ::c_int = 3; +pub const TCOOFF: ::c_int = 0; +pub const TCOON: ::c_int = 1; +pub const TCIFLUSH: ::c_int = 0; +pub const TCOFLUSH: ::c_int = 1; +pub const TCIOFLUSH: ::c_int = 2; +pub const NL0: ::tcflag_t = 0x00000000; +pub const NL1: ::tcflag_t = 0x00000100; +pub const TAB0: ::tcflag_t = 0x00000000; +pub const CR0: ::tcflag_t = 0x00000000; +pub const FF0: ::tcflag_t = 0x00000000; +pub const BS0: ::tcflag_t = 0x00000000; +pub const VT0: ::tcflag_t = 0x00000000; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VLNEXT: usize = 15; +pub const IGNBRK: ::tcflag_t = 0x00000001; +pub const BRKINT: ::tcflag_t = 0x00000002; +pub const IGNPAR: ::tcflag_t = 0x00000004; +pub const PARMRK: ::tcflag_t = 0x00000008; +pub const INPCK: ::tcflag_t = 0x00000010; +pub const ISTRIP: ::tcflag_t = 0x00000020; +pub const INLCR: ::tcflag_t = 0x00000040; +pub const IGNCR: ::tcflag_t = 0x00000080; +pub const ICRNL: ::tcflag_t = 0x00000100; +pub const IXANY: ::tcflag_t = 0x00000800; +pub const IMAXBEL: ::tcflag_t = 0x00002000; +pub const OPOST: ::tcflag_t = 0x1; +pub const CS5: ::tcflag_t = 0x00000000; +pub const CRTSCTS: ::tcflag_t = 0x80000000; +pub const ECHO: ::tcflag_t = 0x00000008; +pub const OCRNL: ::tcflag_t = 0o000010; +pub const ONOCR: ::tcflag_t = 0o000020; +pub const ONLRET: ::tcflag_t = 0o000040; +pub const OFILL: ::tcflag_t = 0o000100; +pub const OFDEL: ::tcflag_t = 0o000200; + +pub const CLONE_VM: ::c_int = 0x100; +pub const CLONE_FS: ::c_int = 0x200; +pub const CLONE_FILES: ::c_int = 0x400; +pub const CLONE_SIGHAND: ::c_int = 0x800; +pub const CLONE_PTRACE: ::c_int = 0x2000; +pub const CLONE_VFORK: ::c_int = 0x4000; +pub const CLONE_PARENT: ::c_int = 0x8000; +pub const CLONE_THREAD: ::c_int = 0x10000; +pub const CLONE_NEWNS: ::c_int = 0x20000; +pub const CLONE_SYSVSEM: ::c_int = 0x40000; +pub const CLONE_SETTLS: ::c_int = 0x80000; +pub const CLONE_PARENT_SETTID: ::c_int = 0x100000; +pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000; +pub const CLONE_DETACHED: ::c_int = 0x400000; +pub const CLONE_UNTRACED: ::c_int = 0x800000; +pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000; +pub const CLONE_NEWUTS: ::c_int = 0x04000000; +pub const CLONE_NEWIPC: ::c_int = 0x08000000; +pub const CLONE_NEWUSER: ::c_int = 0x10000000; +pub const CLONE_NEWPID: ::c_int = 0x20000000; +pub const CLONE_NEWNET: ::c_int = 0x40000000; +pub const CLONE_IO: ::c_int = 0x80000000; +pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; + +pub const WNOHANG: ::c_int = 0x00000001; +pub const WUNTRACED: ::c_int = 0x00000002; +pub const WSTOPPED: ::c_int = WUNTRACED; +pub const WEXITED: ::c_int = 0x00000004; +pub const WCONTINUED: ::c_int = 0x00000008; +pub const WNOWAIT: ::c_int = 0x01000000; + +// Options set using PTRACE_SETOPTIONS. +pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001; +pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002; +pub const PTRACE_O_TRACEVFORK: ::c_int = 0x00000004; +pub const PTRACE_O_TRACECLONE: ::c_int = 0x00000008; +pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010; +pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020; +pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040; +pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080; +pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000; +pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000; +pub const PTRACE_O_MASK: ::c_int = 0x003000ff; + +// Wait extended result codes for the above trace options. +pub const PTRACE_EVENT_FORK: ::c_int = 1; +pub const PTRACE_EVENT_VFORK: ::c_int = 2; +pub const PTRACE_EVENT_CLONE: ::c_int = 3; +pub const PTRACE_EVENT_EXEC: ::c_int = 4; +pub const PTRACE_EVENT_VFORK_DONE: ::c_int = 5; +pub const PTRACE_EVENT_EXIT: ::c_int = 6; +pub const PTRACE_EVENT_SECCOMP: ::c_int = 7; +// PTRACE_EVENT_STOP was added to glibc in 2.26 +// pub const PTRACE_EVENT_STOP: ::c_int = 128; + +pub const __WNOTHREAD: ::c_int = 0x20000000; +pub const __WALL: ::c_int = 0x40000000; +pub const __WCLONE: ::c_int = 0x80000000; + +pub const SPLICE_F_MOVE: ::c_uint = 0x01; +pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02; +pub const SPLICE_F_MORE: ::c_uint = 0x04; +pub const SPLICE_F_GIFT: ::c_uint = 0x08; + +pub const RTLD_LOCAL: ::c_int = 0; +pub const RTLD_LAZY: ::c_int = 1; + +pub const POSIX_FADV_NORMAL: ::c_int = 0; +pub const POSIX_FADV_RANDOM: ::c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_FADV_WILLNEED: ::c_int = 3; + +pub const AT_FDCWD: ::c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100; +pub const AT_REMOVEDIR: ::c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; +pub const AT_NO_AUTOMOUNT: ::c_int = 0x800; +pub const AT_EMPTY_PATH: ::c_int = 0x1000; + +pub const LOG_CRON: ::c_int = 9 << 3; +pub const LOG_AUTHPRIV: ::c_int = 10 << 3; +pub const LOG_FTP: ::c_int = 11 << 3; +pub const LOG_PERROR: ::c_int = 0x20; + +pub const PIPE_BUF: usize = 4096; + +pub const SI_LOAD_SHIFT: ::c_uint = 16; + +pub const SIGEV_SIGNAL: ::c_int = 0; +pub const SIGEV_NONE: ::c_int = 1; +pub const SIGEV_THREAD: ::c_int = 2; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + +pub const UTIME_OMIT: c_long = 1073741822; +pub const UTIME_NOW: c_long = 1073741823; + +pub const POLLIN: ::c_short = 0x1; +pub const POLLPRI: ::c_short = 0x2; +pub const POLLOUT: ::c_short = 0x4; +pub const POLLERR: ::c_short = 0x8; +pub const POLLHUP: ::c_short = 0x10; +pub const POLLNVAL: ::c_short = 0x20; +pub const POLLRDNORM: ::c_short = 0x040; +pub const POLLRDBAND: ::c_short = 0x080; + +pub const IPTOS_LOWDELAY: u8 = 0x10; +pub const IPTOS_THROUGHPUT: u8 = 0x08; +pub const IPTOS_RELIABILITY: u8 = 0x04; +pub const IPTOS_MINCOST: u8 = 0x02; + +pub const IPTOS_PREC_NETCONTROL: u8 = 0xe0; +pub const IPTOS_PREC_INTERNETCONTROL: u8 = 0xc0; +pub const IPTOS_PREC_CRITIC_ECP: u8 = 0xa0; +pub const IPTOS_PREC_FLASHOVERRIDE: u8 = 0x80; +pub const IPTOS_PREC_FLASH: u8 = 0x60; +pub const IPTOS_PREC_IMMEDIATE: u8 = 0x40; +pub const IPTOS_PREC_PRIORITY: u8 = 0x20; +pub const IPTOS_PREC_ROUTINE: u8 = 0x00; + +pub const IPTOS_ECN_MASK: u8 = 0x03; +pub const IPTOS_ECN_ECT1: u8 = 0x01; +pub const IPTOS_ECN_ECT0: u8 = 0x02; +pub const IPTOS_ECN_CE: u8 = 0x03; + +pub const IPOPT_COPY: u8 = 0x80; +pub const IPOPT_CLASS_MASK: u8 = 0x60; +pub const IPOPT_NUMBER_MASK: u8 = 0x1f; + +pub const IPOPT_CONTROL: u8 = 0x00; +pub const IPOPT_RESERVED1: u8 = 0x20; +pub const IPOPT_MEASUREMENT: u8 = 0x40; +pub const IPOPT_RESERVED2: u8 = 0x60; +pub const IPOPT_END: u8 = (0 | IPOPT_CONTROL); +pub const IPOPT_NOOP: u8 = (1 | IPOPT_CONTROL); +pub const IPOPT_SEC: u8 = (2 | IPOPT_CONTROL | IPOPT_COPY); +pub const IPOPT_LSRR: u8 = (3 | IPOPT_CONTROL | IPOPT_COPY); +pub const IPOPT_TIMESTAMP: u8 = (4 | IPOPT_MEASUREMENT); +pub const IPOPT_RR: u8 = (7 | IPOPT_CONTROL); +pub const IPOPT_SID: u8 = (8 | IPOPT_CONTROL | IPOPT_COPY); +pub const IPOPT_SSRR: u8 = (9 | IPOPT_CONTROL | IPOPT_COPY); +pub const IPOPT_RA: u8 = (20 | IPOPT_CONTROL | IPOPT_COPY); +pub const IPVERSION: u8 = 4; +pub const MAXTTL: u8 = 255; +pub const IPDEFTTL: u8 = 64; +pub const IPOPT_OPTVAL: u8 = 0; +pub const IPOPT_OLEN: u8 = 1; +pub const IPOPT_OFFSET: u8 = 2; +pub const IPOPT_MINOFF: u8 = 4; +pub const MAX_IPOPTLEN: u8 = 40; +pub const IPOPT_NOP: u8 = IPOPT_NOOP; +pub const IPOPT_EOL: u8 = IPOPT_END; +pub const IPOPT_TS: u8 = IPOPT_TIMESTAMP; +pub const IPOPT_TS_TSONLY: u8 = 0; +pub const IPOPT_TS_TSANDADDR: u8 = 1; +pub const IPOPT_TS_PRESPEC: u8 = 3; + +pub const ARPOP_RREQUEST: u16 = 3; +pub const ARPOP_RREPLY: u16 = 4; +pub const ARPOP_InREQUEST: u16 = 8; +pub const ARPOP_InREPLY: u16 = 9; +pub const ARPOP_NAK: u16 = 10; + +pub const ATF_NETMASK: ::c_int = 0x20; +pub const ATF_DONTPUB: ::c_int = 0x40; + +pub const ARPHRD_NETROM: u16 = 0; +pub const ARPHRD_ETHER: u16 = 1; +pub const ARPHRD_EETHER: u16 = 2; +pub const ARPHRD_AX25: u16 = 3; +pub const ARPHRD_PRONET: u16 = 4; +pub const ARPHRD_CHAOS: u16 = 5; +pub const ARPHRD_IEEE802: u16 = 6; +pub const ARPHRD_ARCNET: u16 = 7; +pub const ARPHRD_APPLETLK: u16 = 8; +pub const ARPHRD_DLCI: u16 = 15; +pub const ARPHRD_ATM: u16 = 19; +pub const ARPHRD_METRICOM: u16 = 23; +pub const ARPHRD_IEEE1394: u16 = 24; +pub const ARPHRD_EUI64: u16 = 27; +pub const ARPHRD_INFINIBAND: u16 = 32; + +pub const ARPHRD_SLIP: u16 = 256; +pub const ARPHRD_CSLIP: u16 = 257; +pub const ARPHRD_SLIP6: u16 = 258; +pub const ARPHRD_CSLIP6: u16 = 259; +pub const ARPHRD_RSRVD: u16 = 260; +pub const ARPHRD_ADAPT: u16 = 264; +pub const ARPHRD_ROSE: u16 = 270; +pub const ARPHRD_X25: u16 = 271; +pub const ARPHRD_HWX25: u16 = 272; +pub const ARPHRD_PPP: u16 = 512; +pub const ARPHRD_CISCO: u16 = 513; +pub const ARPHRD_HDLC: u16 = ARPHRD_CISCO; +pub const ARPHRD_LAPB: u16 = 516; +pub const ARPHRD_DDCMP: u16 = 517; +pub const ARPHRD_RAWHDLC: u16 = 518; + +pub const ARPHRD_TUNNEL: u16 = 768; +pub const ARPHRD_TUNNEL6: u16 = 769; +pub const ARPHRD_FRAD: u16 = 770; +pub const ARPHRD_SKIP: u16 = 771; +pub const ARPHRD_LOOPBACK: u16 = 772; +pub const ARPHRD_LOCALTLK: u16 = 773; +pub const ARPHRD_FDDI: u16 = 774; +pub const ARPHRD_BIF: u16 = 775; +pub const ARPHRD_SIT: u16 = 776; +pub const ARPHRD_IPDDP: u16 = 777; +pub const ARPHRD_IPGRE: u16 = 778; +pub const ARPHRD_PIMREG: u16 = 779; +pub const ARPHRD_HIPPI: u16 = 780; +pub const ARPHRD_ASH: u16 = 781; +pub const ARPHRD_ECONET: u16 = 782; +pub const ARPHRD_IRDA: u16 = 783; +pub const ARPHRD_FCPP: u16 = 784; +pub const ARPHRD_FCAL: u16 = 785; +pub const ARPHRD_FCPL: u16 = 786; +pub const ARPHRD_FCFABRIC: u16 = 787; +pub const ARPHRD_IEEE802_TR: u16 = 800; +pub const ARPHRD_IEEE80211: u16 = 801; +pub const ARPHRD_IEEE80211_PRISM: u16 = 802; +pub const ARPHRD_IEEE80211_RADIOTAP: u16 = 803; +pub const ARPHRD_IEEE802154: u16 = 804; + +pub const ARPHRD_VOID: u16 = 0xFFFF; +pub const ARPHRD_NONE: u16 = 0xFFFE; + +const_fn! { + {const} fn CMSG_ALIGN(len: usize) -> usize { + len + ::mem::size_of::() - 1 & !(::mem::size_of::() - 1) + } +} + +f! { + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize >= ::mem::size_of::() { + (*mhdr).msg_control as *mut cmsghdr + } else { + 0 as *mut cmsghdr + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar { + cmsg.offset(1) as *mut ::c_uchar + } + + pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::())) + as ::c_uint + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + CMSG_ALIGN(::mem::size_of::()) as ::c_uint + length + } + + pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return + } + + pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 + } + + pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WIFCONTINUED(status: ::c_int) -> bool { + status == 0xffff + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0x7f + } + + pub fn WIFEXITED(status: ::c_int) -> bool { + (status & 0x7f) == 0 + } + + pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WCOREDUMP(status: ::c_int) -> bool { + (status & 0x80) != 0 + } + + pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { + (cmd << 8) | (type_ & 0x00ff) + } + + pub fn IPOPT_COPIED(o: u8) -> u8 { + o & IPOPT_COPY + } + + pub fn IPOPT_CLASS(o: u8) -> u8 { + o & IPOPT_CLASS_MASK + } + + pub fn IPOPT_NUMBER(o: u8) -> u8 { + o & IPOPT_NUMBER_MASK + } + + pub fn IPTOS_ECN(x: u8) -> u8 { + x & ::IPTOS_ECN_MASK + } +} + +extern "C" { + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + pub fn sem_init( + sem: *mut sem_t, + pshared: ::c_int, + value: ::c_uint, + ) -> ::c_int; + pub fn fdatasync(fd: ::c_int) -> ::c_int; + pub fn mincore( + addr: *mut ::c_void, + len: ::size_t, + vec: *mut ::c_uchar, + ) -> ::c_int; + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_settime( + clk_id: ::clockid_t, + tp: *const ::timespec, + ) -> ::c_int; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + + pub fn pthread_getattr_np( + native: ::pthread_t, + attr: *mut ::pthread_attr_t, + ) -> ::c_int; + pub fn pthread_attr_getstack( + attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t, + ) -> ::c_int; + pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; + pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int; + pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn statfs64(path: *const ::c_char, buf: *mut statfs64) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + pub fn fstatfs64(fd: ::c_int, buf: *mut statfs64) -> ::c_int; + pub fn statvfs64(path: *const ::c_char, buf: *mut statvfs64) -> ::c_int; + pub fn fstatvfs64(fd: ::c_int, buf: *mut statvfs64) -> ::c_int; + pub fn memrchr( + cx: *const ::c_void, + c: ::c_int, + n: ::size_t, + ) -> *mut ::c_void; + + pub fn posix_fadvise( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + advise: ::c_int, + ) -> ::c_int; + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn utimensat( + dirfd: ::c_int, + path: *const ::c_char, + times: *const ::timespec, + flag: ::c_int, + ) -> ::c_int; + pub fn duplocale(base: ::locale_t) -> ::locale_t; + pub fn freelocale(loc: ::locale_t); + pub fn newlocale( + mask: ::c_int, + locale: *const ::c_char, + base: ::locale_t, + ) -> ::locale_t; + pub fn uselocale(loc: ::locale_t) -> ::locale_t; + pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int; + pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int; + pub fn fstatat64( + dirfd: ::c_int, + pathname: *const c_char, + buf: *mut stat64, + flags: ::c_int, + ) -> ::c_int; + pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int; + pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t; + pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int; + pub fn mmap64( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + flags: ::c_int, + fd: ::c_int, + offset: off64_t, + ) -> *mut ::c_void; + pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn openat64( + fd: ::c_int, + path: *const c_char, + oflag: ::c_int, + ... + ) -> ::c_int; + pub fn pread64( + fd: ::c_int, + buf: *mut ::c_void, + count: ::size_t, + offset: off64_t, + ) -> ::ssize_t; + pub fn preadv64( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off64_t, + ) -> ::ssize_t; + pub fn pwrite64( + fd: ::c_int, + buf: *const ::c_void, + count: ::size_t, + offset: off64_t, + ) -> ::ssize_t; + pub fn pwritev64( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off64_t, + ) -> ::ssize_t; + pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64; + pub fn readdir64_r( + dirp: *mut ::DIR, + entry: *mut ::dirent64, + result: *mut *mut ::dirent64, + ) -> ::c_int; + pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; + pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; + + pub fn mknodat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + dev: dev_t, + ) -> ::c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> ::c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + pub fn pthread_condattr_setpshared( + attr: *mut pthread_condattr_t, + pshared: ::c_int, + ) -> ::c_int; + pub fn accept4( + fd: ::c_int, + addr: *mut ::sockaddr, + len: *mut ::socklen_t, + flg: ::c_int, + ) -> ::c_int; + pub fn pthread_mutexattr_setpshared( + attr: *mut pthread_mutexattr_t, + pshared: ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_getpshared( + attr: *const pthread_rwlockattr_t, + val: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_setpshared( + attr: *mut pthread_rwlockattr_t, + val: ::c_int, + ) -> ::c_int; + pub fn ptsname_r( + fd: ::c_int, + buf: *mut ::c_char, + buflen: ::size_t, + ) -> ::c_int; + pub fn clearenv() -> ::c_int; + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut ::siginfo_t, + options: ::c_int, + ) -> ::c_int; + pub fn setreuid(ruid: ::uid_t, euid: ::uid_t) -> ::c_int; + pub fn setregid(rgid: ::gid_t, egid: ::gid_t) -> ::c_int; + pub fn getresuid( + ruid: *mut ::uid_t, + euid: *mut ::uid_t, + suid: *mut ::uid_t, + ) -> ::c_int; + pub fn getresgid( + rgid: *mut ::gid_t, + egid: *mut ::gid_t, + sgid: *mut ::gid_t, + ) -> ::c_int; + pub fn acct(filename: *const ::c_char) -> ::c_int; + pub fn brk(addr: *mut ::c_void) -> ::c_int; + pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void; + #[deprecated( + since = "0.2.66", + note = "causes memory corruption, see rust-lang/libc#1596" + )] + pub fn vfork() -> ::pid_t; + pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; + pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; + pub fn wait4( + pid: ::pid_t, + status: *mut ::c_int, + options: ::c_int, + rusage: *mut ::rusage, + ) -> ::pid_t; + pub fn openpty( + amaster: *mut ::c_int, + aslave: *mut ::c_int, + name: *mut ::c_char, + termp: *const termios, + winp: *const ::winsize, + ) -> ::c_int; + pub fn forkpty( + amaster: *mut ::c_int, + name: *mut ::c_char, + termp: *const termios, + winp: *const ::winsize, + ) -> ::pid_t; + pub fn login_tty(fd: ::c_int) -> ::c_int; + pub fn execvpe( + file: *const ::c_char, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + pub fn fexecve( + fd: ::c_int, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; + pub fn freeifaddrs(ifa: *mut ::ifaddrs); + pub fn bind( + socket: ::c_int, + address: *const ::sockaddr, + address_len: ::socklen_t, + ) -> ::c_int; + + pub fn writev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + pub fn readv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + + pub fn sendmsg( + fd: ::c_int, + msg: *const ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + pub fn recvmsg( + fd: ::c_int, + msg: *mut ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + pub fn uname(buf: *mut ::utsname) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_os = "emscripten")] { + mod emscripten; + pub use self::emscripten::*; + } else if #[cfg(target_os = "linux")] { + mod linux; + pub use self::linux::*; + } else if #[cfg(target_os = "android")] { + mod android; + pub use self::android::*; + } else { + // Unknown target_os + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/mod.rs new file mode 100644 index 0000000..238da24 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/mod.rs @@ -0,0 +1,1552 @@ +//! Definitions found commonly among almost all Unix derivatives +//! +//! More functions and definitions can be found in the more specific modules +//! according to the platform in question. + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type in_addr_t = u32; +pub type in_port_t = u16; +pub type sighandler_t = ::size_t; +pub type cc_t = ::c_uchar; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum DIR {} +impl ::Copy for DIR {} +impl ::Clone for DIR { + fn clone(&self) -> DIR { + *self + } +} +pub type locale_t = *mut ::c_void; + +s! { + pub struct group { + pub gr_name: *mut ::c_char, + pub gr_passwd: *mut ::c_char, + pub gr_gid: ::gid_t, + pub gr_mem: *mut *mut ::c_char, + } + + pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + // linux x32 compatibility + // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 + pub struct timespec { + pub tv_sec: time_t, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub tv_nsec: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub tv_nsec: ::c_long, + } + + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad1: u32, + pub ru_ixrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad2: u32, + pub ru_idrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad3: u32, + pub ru_isrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad4: u32, + pub ru_minflt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad5: u32, + pub ru_majflt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad6: u32, + pub ru_nswap: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad7: u32, + pub ru_inblock: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad8: u32, + pub ru_oublock: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad9: u32, + pub ru_msgsnd: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad10: u32, + pub ru_msgrcv: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad11: u32, + pub ru_nsignals: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad12: u32, + pub ru_nvcsw: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad13: u32, + pub ru_nivcsw: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad14: u32, + + #[cfg(any(target_env = "musl", target_os = "emscripten"))] + __reserved: [c_long; 16], + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + #[cfg(target_os = "android")] + pub ipv6mr_interface: ::c_int, + #[cfg(not(target_os = "android"))] + pub ipv6mr_interface: ::c_uint, + } + + pub struct hostent { + pub h_name: *mut ::c_char, + pub h_aliases: *mut *mut ::c_char, + pub h_addrtype: ::c_int, + pub h_length: ::c_int, + pub h_addr_list: *mut *mut ::c_char, + } + + pub struct iovec { + pub iov_base: *mut ::c_void, + pub iov_len: ::size_t, + } + + pub struct pollfd { + pub fd: ::c_int, + pub events: ::c_short, + pub revents: ::c_short, + } + + pub struct winsize { + pub ws_row: ::c_ushort, + pub ws_col: ::c_ushort, + pub ws_xpixel: ::c_ushort, + pub ws_ypixel: ::c_ushort, + } + + pub struct linger { + pub l_onoff: ::c_int, + pub l_linger: ::c_int, + } + + pub struct sigval { + // Actually a union of an int and a void* + pub sival_ptr: *mut ::c_void + } + + // + pub struct itimerval { + pub it_interval: ::timeval, + pub it_value: ::timeval, + } + + // + pub struct tms { + pub tms_utime: ::clock_t, + pub tms_stime: ::clock_t, + pub tms_cutime: ::clock_t, + pub tms_cstime: ::clock_t, + } + + pub struct servent { + pub s_name: *mut ::c_char, + pub s_aliases: *mut *mut ::c_char, + pub s_port: ::c_int, + pub s_proto: *mut ::c_char, + } + + pub struct protoent { + pub p_name: *mut ::c_char, + pub p_aliases: *mut *mut ::c_char, + pub p_proto: ::c_int, + } +} + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +pub const SIG_DFL: sighandler_t = 0 as sighandler_t; +pub const SIG_IGN: sighandler_t = 1 as sighandler_t; +pub const SIG_ERR: sighandler_t = !0 as sighandler_t; + +pub const DT_UNKNOWN: u8 = 0; +pub const DT_FIFO: u8 = 1; +pub const DT_CHR: u8 = 2; +pub const DT_DIR: u8 = 4; +pub const DT_BLK: u8 = 6; +pub const DT_REG: u8 = 8; +pub const DT_LNK: u8 = 10; +pub const DT_SOCK: u8 = 12; + +cfg_if! { + if #[cfg(not(target_os = "redox"))] { + pub const FD_CLOEXEC: ::c_int = 0x1; + } +} + +pub const USRQUOTA: ::c_int = 0; +pub const GRPQUOTA: ::c_int = 1; + +pub const SIGIOT: ::c_int = 6; + +pub const S_ISUID: ::mode_t = 0x800; +pub const S_ISGID: ::mode_t = 0x400; +pub const S_ISVTX: ::mode_t = 0x200; + +pub const IF_NAMESIZE: ::size_t = 16; +pub const IFNAMSIZ: ::size_t = IF_NAMESIZE; + +pub const LOG_EMERG: ::c_int = 0; +pub const LOG_ALERT: ::c_int = 1; +pub const LOG_CRIT: ::c_int = 2; +pub const LOG_ERR: ::c_int = 3; +pub const LOG_WARNING: ::c_int = 4; +pub const LOG_NOTICE: ::c_int = 5; +pub const LOG_INFO: ::c_int = 6; +pub const LOG_DEBUG: ::c_int = 7; + +pub const LOG_KERN: ::c_int = 0; +pub const LOG_USER: ::c_int = 1 << 3; +pub const LOG_MAIL: ::c_int = 2 << 3; +pub const LOG_DAEMON: ::c_int = 3 << 3; +pub const LOG_AUTH: ::c_int = 4 << 3; +pub const LOG_SYSLOG: ::c_int = 5 << 3; +pub const LOG_LPR: ::c_int = 6 << 3; +pub const LOG_NEWS: ::c_int = 7 << 3; +pub const LOG_UUCP: ::c_int = 8 << 3; +pub const LOG_LOCAL0: ::c_int = 16 << 3; +pub const LOG_LOCAL1: ::c_int = 17 << 3; +pub const LOG_LOCAL2: ::c_int = 18 << 3; +pub const LOG_LOCAL3: ::c_int = 19 << 3; +pub const LOG_LOCAL4: ::c_int = 20 << 3; +pub const LOG_LOCAL5: ::c_int = 21 << 3; +pub const LOG_LOCAL6: ::c_int = 22 << 3; +pub const LOG_LOCAL7: ::c_int = 23 << 3; + +pub const LOG_PID: ::c_int = 0x01; +pub const LOG_CONS: ::c_int = 0x02; +pub const LOG_ODELAY: ::c_int = 0x04; +pub const LOG_NDELAY: ::c_int = 0x08; +pub const LOG_NOWAIT: ::c_int = 0x10; + +pub const LOG_PRIMASK: ::c_int = 7; +pub const LOG_FACMASK: ::c_int = 0x3f8; + +pub const PRIO_PROCESS: ::c_int = 0; +pub const PRIO_PGRP: ::c_int = 1; +pub const PRIO_USER: ::c_int = 2; + +pub const PRIO_MIN: ::c_int = -20; +pub const PRIO_MAX: ::c_int = 20; + +pub const IPPROTO_ICMP: ::c_int = 1; +pub const IPPROTO_ICMPV6: ::c_int = 58; +pub const IPPROTO_TCP: ::c_int = 6; +pub const IPPROTO_UDP: ::c_int = 17; +pub const IPPROTO_IP: ::c_int = 0; +pub const IPPROTO_IPV6: ::c_int = 41; + +pub const INADDR_LOOPBACK: in_addr_t = 2130706433; +pub const INADDR_ANY: in_addr_t = 0; +pub const INADDR_BROADCAST: in_addr_t = 4294967295; +pub const INADDR_NONE: in_addr_t = 4294967295; + +pub const ARPOP_REQUEST: u16 = 1; +pub const ARPOP_REPLY: u16 = 2; + +pub const ATF_COM: ::c_int = 0x02; +pub const ATF_PERM: ::c_int = 0x04; +pub const ATF_PUBL: ::c_int = 0x08; +pub const ATF_USETRAILERS: ::c_int = 0x10; + +cfg_if! { + if #[cfg(target_os = "l4re")] { + // required libraries for L4Re are linked externally, ATM + } else if #[cfg(feature = "std")] { + // cargo build, don't pull in anything extra as the libstd dep + // already pulls in all libs. + } else if #[cfg(target_env = "musl")] { + #[cfg_attr(feature = "rustc-dep-of-std", + link(name = "c", kind = "static", + cfg(target_feature = "crt-static")))] + #[cfg_attr(feature = "rustc-dep-of-std", + link(name = "c", cfg(not(target_feature = "crt-static"))))] + extern {} + } else if #[cfg(target_os = "emscripten")] { + #[link(name = "c")] + extern {} + } else if #[cfg(all(target_os = "netbsd", + feature = "rustc-dep-of-std", + target_vendor = "rumprun"))] { + // Since we don't use -nodefaultlibs on Rumprun, libc is always pulled + // in automatically by the linker. We avoid passing it explicitly, as it + // causes some versions of binutils to crash with an assertion failure. + #[link(name = "m")] + extern {} + } else if #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "android", + target_os = "openbsd"))] { + #[link(name = "c")] + #[link(name = "m")] + extern {} + } else if #[cfg(target_os = "haiku")] { + #[link(name = "root")] + #[link(name = "network")] + extern {} + } else if #[cfg(target_env = "newlib")] { + #[link(name = "c")] + #[link(name = "m")] + extern {} + } else if #[cfg(target_os = "hermit")] { + // no_default_libraries is set to false for HermitCore, so only a link + // to "pthread" needs to be added. + #[link(name = "pthread")] + extern {} + } else if #[cfg(target_env = "illumos")] { + #[link(name = "c")] + #[link(name = "m")] + extern {} + } else if #[cfg(target_os = "redox")] { + #[cfg_attr(feature = "rustc-dep-of-std", + link(name = "c", kind = "static-nobundle", + cfg(target_feature = "crt-static")))] + #[cfg_attr(feature = "rustc-dep-of-std", + link(name = "c", cfg(not(target_feature = "crt-static"))))] + extern {} + } else { + #[link(name = "c")] + #[link(name = "m")] + #[link(name = "rt")] + #[link(name = "pthread")] + extern {} + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum FILE {} +impl ::Copy for FILE {} +impl ::Clone for FILE { + fn clone(&self) -> FILE { + *self + } +} +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum fpos_t {} // TODO: fill this out with a struct +impl ::Copy for fpos_t {} +impl ::Clone for fpos_t { + fn clone(&self) -> fpos_t { + *self + } +} + +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fopen$UNIX2003" + )] + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "freopen$UNIX2003" + )] + pub fn freopen( + filename: *const c_char, + mode: *const c_char, + file: *mut FILE, + ) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf( + stream: *mut FILE, + buffer: *mut c_char, + mode: c_int, + size: size_t, + ) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) + -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fputs$UNIX2003" + )] + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread( + ptr: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE, + ) -> size_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fwrite$UNIX2003" + )] + pub fn fwrite( + ptr: *const c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE, + ) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")] + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")] + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atoi(s: *const c_char) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "strtod$UNIX2003" + )] + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_long; + pub fn strtoul( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern "C" fn()) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "system$UNIX2003" + )] + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy( + dst: *mut c_char, + src: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat( + s: *mut c_char, + ct: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp( + s1: *const c_char, + s2: *const c_char, + n: size_t, + ) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "strerror$UNIX2003" + )] + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs( + dest: *mut c_char, + src: *const wchar_t, + n: size_t, + ) -> ::size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memmove( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; +} + +extern "C" { + #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")] + pub fn getpwnam(name: *const ::c_char) -> *mut passwd; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")] + pub fn getpwuid(uid: ::uid_t) -> *mut passwd; + + pub fn fprintf( + stream: *mut ::FILE, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn printf(format: *const ::c_char, ...) -> ::c_int; + pub fn snprintf( + s: *mut ::c_char, + n: ::size_t, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int; + #[cfg_attr(target_os = "linux", link_name = "__isoc99_fscanf")] + pub fn fscanf( + stream: *mut ::FILE, + format: *const ::c_char, + ... + ) -> ::c_int; + #[cfg_attr(target_os = "linux", link_name = "__isoc99_scanf")] + pub fn scanf(format: *const ::c_char, ...) -> ::c_int; + #[cfg_attr(target_os = "linux", link_name = "__isoc99_sscanf")] + pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) + -> ::c_int; + pub fn getchar_unlocked() -> ::c_int; + pub fn putchar_unlocked(c: ::c_int) -> ::c_int; + + #[cfg_attr(target_os = "netbsd", link_name = "__socket30")] + #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")] + pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "connect$UNIX2003" + )] + #[cfg_attr(target_os = "illumos", link_name = "__xnet_connect")] + pub fn connect( + socket: ::c_int, + address: *const sockaddr, + len: socklen_t, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "listen$UNIX2003" + )] + #[cfg_attr(target_os = "illumos", link_name = "__xnet_listen")] + pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "accept$UNIX2003" + )] + pub fn accept( + socket: ::c_int, + address: *mut sockaddr, + address_len: *mut socklen_t, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "getpeername$UNIX2003" + )] + pub fn getpeername( + socket: ::c_int, + address: *mut sockaddr, + address_len: *mut socklen_t, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "getsockname$UNIX2003" + )] + pub fn getsockname( + socket: ::c_int, + address: *mut sockaddr, + address_len: *mut socklen_t, + ) -> ::c_int; + pub fn setsockopt( + socket: ::c_int, + level: ::c_int, + name: ::c_int, + value: *const ::c_void, + option_len: socklen_t, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "socketpair$UNIX2003" + )] + #[cfg_attr(target_os = "illumos", link_name = "__xnet_socketpair")] + pub fn socketpair( + domain: ::c_int, + type_: ::c_int, + protocol: ::c_int, + socket_vector: *mut ::c_int, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sendto$UNIX2003" + )] + #[cfg_attr(target_os = "illumos", link_name = "__xnet_sendto")] + pub fn sendto( + socket: ::c_int, + buf: *const ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *const sockaddr, + addrlen: socklen_t, + ) -> ::ssize_t; + pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "chmod$UNIX2003" + )] + pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fchmod$UNIX2003" + )] + pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int; + + #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] + #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "fstat@FBSD_1.0" + )] + pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; + + pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int; + + #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] + #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "stat@FBSD_1.0" + )] + pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; + + pub fn pclose(stream: *mut ::FILE) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fdopen$UNIX2003" + )] + pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; + pub fn fileno(stream: *mut ::FILE) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "open$UNIX2003" + )] + pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "creat$UNIX2003" + )] + pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fcntl$UNIX2003" + )] + pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "opendir$INODE64" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "opendir$INODE64$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")] + pub fn opendir(dirname: *const c_char) -> *mut ::DIR; + + #[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")] + #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "readdir@FBSD_1.0" + )] + pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "closedir$UNIX2003" + )] + pub fn closedir(dirp: *mut ::DIR) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "rewinddir$INODE64" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "rewinddir$INODE64$UNIX2003" + )] + pub fn rewinddir(dirp: *mut ::DIR); + + pub fn fchmodat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + flags: ::c_int, + ) -> ::c_int; + pub fn fchown(fd: ::c_int, owner: ::uid_t, group: ::gid_t) -> ::c_int; + pub fn fchownat( + dirfd: ::c_int, + pathname: *const ::c_char, + owner: ::uid_t, + group: ::gid_t, + flags: ::c_int, + ) -> ::c_int; + #[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "fstatat@FBSD_1.1" + )] + pub fn fstatat( + dirfd: ::c_int, + pathname: *const ::c_char, + buf: *mut stat, + flags: ::c_int, + ) -> ::c_int; + pub fn linkat( + olddirfd: ::c_int, + oldpath: *const ::c_char, + newdirfd: ::c_int, + newpath: *const ::c_char, + flags: ::c_int, + ) -> ::c_int; + pub fn renameat( + olddirfd: ::c_int, + oldpath: *const ::c_char, + newdirfd: ::c_int, + newpath: *const ::c_char, + ) -> ::c_int; + pub fn symlinkat( + target: *const ::c_char, + newdirfd: ::c_int, + linkpath: *const ::c_char, + ) -> ::c_int; + pub fn unlinkat( + dirfd: ::c_int, + pathname: *const ::c_char, + flags: ::c_int, + ) -> ::c_int; + + pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; + pub fn alarm(seconds: ::c_uint) -> ::c_uint; + pub fn chdir(dir: *const c_char) -> ::c_int; + pub fn fchdir(dirfd: ::c_int) -> ::c_int; + pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "lchown$UNIX2003" + )] + pub fn lchown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "close$NOCANCEL$UNIX2003" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "close$NOCANCEL" + )] + pub fn close(fd: ::c_int) -> ::c_int; + pub fn dup(fd: ::c_int) -> ::c_int; + pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; + pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> ::c_int; + pub fn execle( + path: *const ::c_char, + arg0: *const ::c_char, + ... + ) -> ::c_int; + pub fn execlp( + file: *const ::c_char, + arg0: *const ::c_char, + ... + ) -> ::c_int; + pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::c_int; + pub fn execve( + prog: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> ::c_int; + pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; + pub fn fork() -> pid_t; + pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; + pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgid() -> gid_t; + pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) -> ::c_int; + pub fn getlogin() -> *mut c_char; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "getopt$UNIX2003" + )] + pub fn getopt( + argc: ::c_int, + argv: *const *mut c_char, + optstr: *const c_char, + ) -> ::c_int; + pub fn getpgid(pid: pid_t) -> pid_t; + pub fn getpgrp() -> pid_t; + pub fn getpid() -> pid_t; + pub fn getppid() -> pid_t; + pub fn getuid() -> uid_t; + pub fn isatty(fd: ::c_int) -> ::c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int; + pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t; + pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long; + pub fn pipe(fds: *mut ::c_int) -> ::c_int; + pub fn posix_memalign( + memptr: *mut *mut ::c_void, + align: ::size_t, + size: ::size_t, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "read$UNIX2003" + )] + pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) + -> ::ssize_t; + pub fn rmdir(path: *const c_char) -> ::c_int; + pub fn seteuid(uid: uid_t) -> ::c_int; + pub fn setegid(gid: gid_t) -> ::c_int; + pub fn setgid(gid: gid_t) -> ::c_int; + pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int; + pub fn setsid() -> pid_t; + pub fn setuid(uid: uid_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sleep$UNIX2003" + )] + pub fn sleep(secs: ::c_uint) -> ::c_uint; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "nanosleep$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")] + pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> ::c_int; + pub fn tcgetpgrp(fd: ::c_int) -> pid_t; + pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int; + pub fn ttyname(fd: ::c_int) -> *mut c_char; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "ttyname_r$UNIX2003" + )] + pub fn ttyname_r( + fd: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + pub fn unlink(c: *const c_char) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "wait$UNIX2003" + )] + pub fn wait(status: *mut ::c_int) -> pid_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "waitpid$UNIX2003" + )] + pub fn waitpid( + pid: pid_t, + status: *mut ::c_int, + options: ::c_int, + ) -> pid_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "write$UNIX2003" + )] + pub fn write( + fd: ::c_int, + buf: *const ::c_void, + count: ::size_t, + ) -> ::ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pread$UNIX2003" + )] + pub fn pread( + fd: ::c_int, + buf: *mut ::c_void, + count: ::size_t, + offset: off_t, + ) -> ::ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pwrite$UNIX2003" + )] + pub fn pwrite( + fd: ::c_int, + buf: *const ::c_void, + count: ::size_t, + offset: off_t, + ) -> ::ssize_t; + pub fn umask(mask: mode_t) -> mode_t; + + #[cfg_attr(target_os = "netbsd", link_name = "__utime50")] + pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "kill$UNIX2003" + )] + pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "killpg$UNIX2003" + )] + pub fn killpg(pgrp: pid_t, sig: ::c_int) -> ::c_int; + + pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn mlockall(flags: ::c_int) -> ::c_int; + pub fn munlockall() -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "mmap$UNIX2003" + )] + pub fn mmap( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + flags: ::c_int, + fd: ::c_int, + offset: off_t, + ) -> *mut ::c_void; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "munmap$UNIX2003" + )] + pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; + + pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint; + pub fn if_indextoname( + ifindex: ::c_uint, + ifname: *mut ::c_char, + ) -> *mut ::c_char; + + #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] + #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "lstat@FBSD_1.0" + )] + pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fsync$UNIX2003" + )] + pub fn fsync(fd: ::c_int) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "setenv$UNIX2003" + )] + pub fn setenv( + name: *const c_char, + val: *const c_char, + overwrite: ::c_int, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "unsetenv$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")] + pub fn unsetenv(name: *const c_char) -> ::c_int; + + pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int; + + pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int; + + pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t; + + #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] + pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; + + #[cfg_attr( + any(target_os = "macos", target_os = "ios"), + link_name = "realpath$DARWIN_EXTSN" + )] + pub fn realpath( + pathname: *const ::c_char, + resolved: *mut ::c_char, + ) -> *mut ::c_char; + + pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int; + + #[cfg_attr(target_os = "netbsd", link_name = "__times13")] + pub fn times(buf: *mut ::tms) -> ::clock_t; + + pub fn pthread_self() -> ::pthread_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_join$UNIX2003" + )] + pub fn pthread_join( + native: ::pthread_t, + value: *mut *mut ::c_void, + ) -> ::c_int; + pub fn pthread_exit(value: *mut ::c_void) -> !; + pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_setstacksize( + attr: *mut ::pthread_attr_t, + stack_size: ::size_t, + ) -> ::c_int; + pub fn pthread_attr_setdetachstate( + attr: *mut ::pthread_attr_t, + state: ::c_int, + ) -> ::c_int; + pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")] + pub fn sched_yield() -> ::c_int; + pub fn pthread_key_create( + key: *mut pthread_key_t, + dtor: ::Option, + ) -> ::c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; + pub fn pthread_setspecific( + key: pthread_key_t, + value: *const ::c_void, + ) -> ::c_int; + pub fn pthread_mutex_init( + lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> ::c_int; + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_mutexattr_destroy$UNIX2003" + )] + pub fn pthread_mutexattr_destroy( + attr: *mut pthread_mutexattr_t, + ) -> ::c_int; + pub fn pthread_mutexattr_settype( + attr: *mut pthread_mutexattr_t, + _type: ::c_int, + ) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_cond_init$UNIX2003" + )] + pub fn pthread_cond_init( + cond: *mut pthread_cond_t, + attr: *const pthread_condattr_t, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_cond_wait$UNIX2003" + )] + pub fn pthread_cond_wait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_cond_timedwait$UNIX2003" + )] + pub fn pthread_cond_timedwait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int; + pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_init$UNIX2003" + )] + pub fn pthread_rwlock_init( + lock: *mut pthread_rwlock_t, + attr: *const pthread_rwlockattr_t, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_destroy$UNIX2003" + )] + pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_rdlock$UNIX2003" + )] + pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_tryrdlock$UNIX2003" + )] + pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_wrlock$UNIX2003" + )] + pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_trywrlock$UNIX2003" + )] + pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_unlock$UNIX2003" + )] + pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) + -> ::c_int; + pub fn pthread_rwlockattr_destroy( + attr: *mut pthread_rwlockattr_t, + ) -> ::c_int; + + #[cfg_attr(target_os = "illumos", link_name = "__xnet_getsockopt")] + pub fn getsockopt( + sockfd: ::c_int, + level: ::c_int, + optname: ::c_int, + optval: *mut ::c_void, + optlen: *mut ::socklen_t, + ) -> ::c_int; + pub fn raise(signum: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")] + pub fn sigaction( + signum: ::c_int, + act: *const sigaction, + oldact: *mut sigaction, + ) -> ::c_int; + + #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")] + pub fn utimes( + filename: *const ::c_char, + times: *const ::timeval, + ) -> ::c_int; + pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void; + pub fn dlerror() -> *mut ::c_char; + pub fn dlsym( + handle: *mut ::c_void, + symbol: *const ::c_char, + ) -> *mut ::c_void; + pub fn dlclose(handle: *mut ::c_void) -> ::c_int; + pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int; + + pub fn getaddrinfo( + node: *const c_char, + service: *const c_char, + hints: *const addrinfo, + res: *mut *mut addrinfo, + ) -> ::c_int; + pub fn freeaddrinfo(res: *mut addrinfo); + pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; + #[cfg_attr( + any( + all(target_os = "linux", not(target_env = "musl")), + target_os = "freebsd", + target_os = "dragonfly", + target_os = "haiku" + ), + link_name = "__res_init" + )] + #[cfg_attr( + any(target_os = "macos", target_os = "ios"), + link_name = "res_9_init" + )] + pub fn res_init() -> ::c_int; + + #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] + pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")] + pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "mktime$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")] + pub fn mktime(tm: *mut tm) -> time_t; + #[cfg_attr(target_os = "netbsd", link_name = "__time50")] + pub fn time(time: *mut time_t) -> time_t; + #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")] + pub fn gmtime(time_p: *const time_t) -> *mut tm; + #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")] + pub fn localtime(time_p: *const time_t) -> *mut tm; + #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")] + pub fn difftime(time1: time_t, time0: time_t) -> ::c_double; + + #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "mknod@FBSD_1.0" + )] + pub fn mknod( + pathname: *const ::c_char, + mode: ::mode_t, + dev: ::dev_t, + ) -> ::c_int; + pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn getservbyname( + name: *const ::c_char, + proto: *const ::c_char, + ) -> *mut servent; + pub fn getprotobyname(name: *const ::c_char) -> *mut protoent; + pub fn getprotobynumber(proto: ::c_int) -> *mut protoent; + pub fn chroot(name: *const ::c_char) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "usleep$UNIX2003" + )] + pub fn usleep(secs: ::c_uint) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "send$UNIX2003" + )] + pub fn send( + socket: ::c_int, + buf: *const ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "recv$UNIX2003" + )] + pub fn recv( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "putenv$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")] + pub fn putenv(string: *mut c_char) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "poll$UNIX2003" + )] + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "select$1050" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "select$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__select50")] + pub fn select( + nfds: ::c_int, + readfs: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *mut timeval, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")] + pub fn setlocale( + category: ::c_int, + locale: *const ::c_char, + ) -> *mut ::c_char; + pub fn localeconv() -> *mut lconv; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sem_wait$UNIX2003" + )] + pub fn sem_wait(sem: *mut sem_t) -> ::c_int; + pub fn sem_trywait(sem: *mut sem_t) -> ::c_int; + pub fn sem_post(sem: *mut sem_t) -> ::c_int; + pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int; + pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int; + + pub fn readlink( + path: *const c_char, + buf: *mut c_char, + bufsz: ::size_t, + ) -> ::ssize_t; + + #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] + pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")] + pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")] + pub fn sigfillset(set: *mut sigset_t) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")] + pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")] + pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int; + + #[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")] + pub fn sigprocmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")] + pub fn sigpending(set: *mut sigset_t) -> ::c_int; + + #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] + pub fn timegm(tm: *mut ::tm) -> time_t; + + pub fn sysconf(name: ::c_int) -> ::c_long; + + pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "pselect$1050" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pselect$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")] + pub fn pselect( + nfds: ::c_int, + readfs: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *const timespec, + sigmask: *const sigset_t, + ) -> ::c_int; + pub fn fseeko( + stream: *mut ::FILE, + offset: ::off_t, + whence: ::c_int, + ) -> ::c_int; + pub fn ftello(stream: *mut ::FILE) -> ::off_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "tcdrain$UNIX2003" + )] + pub fn tcdrain(fd: ::c_int) -> ::c_int; + pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t; + pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t; + pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; + pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; + pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int; + pub fn tcsetattr( + fd: ::c_int, + optional_actions: ::c_int, + termios: *const ::termios, + ) -> ::c_int; + pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int; + pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int; + pub fn tcgetsid(fd: ::c_int) -> ::pid_t; + pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int; + pub fn mkstemp(template: *mut ::c_char) -> ::c_int; + pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char; + + pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char; + + pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int); + pub fn closelog(); + pub fn setlogmask(maskpri: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "macos", link_name = "syslog$DARWIN_EXTSN")] + pub fn syslog(priority: ::c_int, message: *const ::c_char, ...); + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "nice$UNIX2003" + )] + pub fn nice(incr: ::c_int) -> ::c_int; + + pub fn grantpt(fd: ::c_int) -> ::c_int; + pub fn posix_openpt(flags: ::c_int) -> ::c_int; + pub fn ptsname(fd: ::c_int) -> *mut ::c_char; + pub fn unlockpt(fd: ::c_int) -> ::c_int; + + pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn getline( + lineptr: *mut *mut c_char, + n: *mut size_t, + stream: *mut FILE, + ) -> ssize_t; +} + +cfg_if! { + if #[cfg(not(target_os = "redox"))] { + extern { + pub fn getsid(pid: pid_t) -> pid_t; + pub fn truncate(path: *const c_char, length: off_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pause$UNIX2003")] + pub fn pause() -> ::c_int; + + pub fn readlinkat(dirfd: ::c_int, + pathname: *const ::c_char, + buf: *mut ::c_char, + bufsiz: ::size_t) -> ::ssize_t; + pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char, + mode: ::mode_t) -> ::c_int; + pub fn openat(dirfd: ::c_int, pathname: *const ::c_char, + flags: ::c_int, ...) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "fdopendir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fdopendir$INODE64$UNIX2003")] + pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; + + #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] + #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "readdir_r@FBSD_1.0" + )] + /// The 64-bit libc on Solaris and illumos only has readdir_r. If a + /// 32-bit Solaris or illumos target is ever created, it should use + /// __posix_readdir_r. See libc(3LIB) on Solaris or illumos: + /// https://illumos.org/man/3lib/libc + /// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html + /// https://www.unix.com/man-page/opensolaris/3LIB/libc/ + pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent, + result: *mut *mut ::dirent) -> ::c_int; + } + } +} + +cfg_if! { + if #[cfg(not(any(target_os = "solaris", target_os = "illumos")))] { + extern { + pub fn cfmakeraw(termios: *mut ::termios); + pub fn cfsetspeed(termios: *mut ::termios, + speed: ::speed_t) -> ::c_int; + } + } +} + +cfg_if! { + if #[cfg(target_env = "uclibc")] { + mod uclibc; + pub use self::uclibc::*; + } else if #[cfg(target_env = "newlib")] { + mod newlib; + pub use self::newlib::*; + } else if #[cfg(any(target_os = "linux", + target_os = "android", + target_os = "emscripten"))] { + mod linux_like; + pub use self::linux_like::*; + } else if #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd", + target_os = "netbsd"))] { + mod bsd; + pub use self::bsd::*; + } else if #[cfg(any(target_os = "solaris", + target_os = "illumos"))] { + mod solarish; + pub use self::solarish::*; + } else if #[cfg(target_os = "haiku")] { + mod haiku; + pub use self::haiku::*; + } else if #[cfg(target_os = "hermit")] { + mod hermit; + pub use self::hermit::*; + } else if #[cfg(target_os = "redox")] { + mod redox; + pub use self::redox::*; + } else { + // Unknown target_os + } +} + +cfg_if! { + if #[cfg(libc_core_cvoid)] { + pub use ::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/aarch64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/aarch64/mod.rs new file mode 100644 index 0000000..7e1b2bb --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/aarch64/mod.rs @@ -0,0 +1,33 @@ +pub type c_char = u8; +pub type wchar_t = u32; + +pub type c_long = i64; +pub type c_ulong = u64; + +s! { + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: ::sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: ::sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [::c_char; 8], + } +} + +pub const POLLOUT: ::c_short = 0x4; +pub const POLLHUP: ::c_short = 0x10; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/align.rs new file mode 100644 index 0000000..db9beb8 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/align.rs @@ -0,0 +1,61 @@ +macro_rules! expand_align { + () => { + s! { + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_mutex_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_rwlock_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(8))] + pub struct pthread_cond_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + }; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/arm/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/arm/mod.rs new file mode 100644 index 0000000..39cb425 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/arm/mod.rs @@ -0,0 +1,35 @@ +pub type c_char = u8; +pub type wchar_t = u32; + +pub type c_long = i32; +pub type c_ulong = u32; + +s! { + pub struct sockaddr { + pub sa_family: ::sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in6 { + pub sin6_family: ::sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_in { + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_storage { + pub ss_family: ::sa_family_t, + pub __ss_padding: [u8; 26], + } +} + +pub const POLLOUT: ::c_short = 0x10; +pub const POLLHUP: ::c_short = 0x4; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/mod.rs new file mode 100644 index 0000000..bd9a107 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/mod.rs @@ -0,0 +1,725 @@ +pub type blkcnt_t = i32; +pub type blksize_t = i32; +pub type clock_t = i32; +pub type clockid_t = ::c_ulong; +pub type dev_t = u32; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u32; +pub type id_t = u32; +pub type ino_t = u32; +pub type key_t = ::c_int; +pub type loff_t = ::c_longlong; +pub type mode_t = ::c_uint; +pub type nfds_t = u32; +pub type nlink_t = ::c_ushort; +pub type off_t = i64; +pub type pthread_t = ::c_ulong; +pub type pthread_key_t = ::c_uint; +pub type rlim_t = u32; +pub type sa_family_t = u8; +pub type socklen_t = u32; +pub type speed_t = u32; +pub type suseconds_t = i32; +pub type tcflag_t = ::c_uint; +pub type time_t = i32; +pub type useconds_t = u32; + +s! { + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut ::c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct linger { + pub l_onoff: ::c_int, + pub l_linger: ::c_int, + } + + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct hostent { + pub h_name: *mut ::c_char, + pub h_aliases: *mut *mut ::c_char, + pub h_addrtype: ::c_int, + pub h_length: ::c_int, + pub h_addr_list: *mut *mut ::c_char, + pub h_addr: *mut ::c_char, + } + + pub struct pollfd { + pub fd: ::c_int, + pub events: ::c_int, + pub revents: ::c_int, + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + } + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_atime: time_t, + pub st_spare1: ::c_long, + pub st_mtime: time_t, + pub st_spare2: ::c_long, + pub st_ctime: time_t, + pub st_spare3: ::c_long, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_spare4: [::c_long; 2usize], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsfilcnt_t, + pub f_ffree: fsfilcnt_t, + pub f_favail: fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + } + + pub struct sigset_t { + __val: [::c_ulong; 16], + } + + pub struct sigaction { + pub sa_handler: extern fn(arg1: ::c_int), + pub sa_mask: sigset_t, + pub sa_flags: ::c_int, + } + + pub struct dirent { + pub d_ino: ino_t, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256usize], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: usize, + } + + pub struct fd_set { // Unverified + fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], + } + + pub struct passwd { // Unverified + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct termios { // Unverified + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + } + + pub struct sem_t { // Unverified + __size: [::c_char; 16], + } + + pub struct Dl_info { // Unverified + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct utsname { // Unverified + pub sysname: [::c_char; 65], + pub nodename: [::c_char; 65], + pub release: [::c_char; 65], + pub version: [::c_char; 65], + pub machine: [::c_char; 65], + pub domainname: [::c_char; 65] + } + + pub struct cpu_set_t { // Unverified + bits: [u32; 32], + } + + pub struct pthread_attr_t { // Unverified + __size: [u64; 7] + } + + pub struct pthread_rwlockattr_t { // Unverified + __lockkind: ::c_int, + __pshared: ::c_int, + } +} + +// unverified constants +align_const! { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], + }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], + }; + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + }; +} +pub const NCCS: usize = 32; +pub const __SIZEOF_PTHREAD_ATTR_T: usize = 56; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const __PTHREAD_MUTEX_HAVE_PREV: usize = 1; +pub const __PTHREAD_RWLOCK_INT_FLAGS_SHARED: usize = 1; +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; +pub const FD_SETSIZE: usize = 1024; +// intentionally not public, only used for fd_set +const ULONG_SIZE: usize = 32; + +// Other constants +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const ENOMSG: ::c_int = 35; +pub const EIDRM: ::c_int = 36; +pub const EDEADLK: ::c_int = 45; +pub const ENOLCK: ::c_int = 46; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENOLINK: ::c_int = 67; +pub const EPROTO: ::c_int = 71; +pub const EMULTIHOP: ::c_int = 74; +pub const EBADMSG: ::c_int = 77; +pub const EFTYPE: ::c_int = 79; +pub const ENOSYS: ::c_int = 88; +pub const ENOTEMPTY: ::c_int = 90; +pub const ENAMETOOLONG: ::c_int = 91; +pub const ELOOP: ::c_int = 92; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EAFNOSUPPORT: ::c_int = 106; +pub const EPROTOTYPE: ::c_int = 107; +pub const ENOTSOCK: ::c_int = 108; +pub const ENOPROTOOPT: ::c_int = 109; +pub const ECONNREFUSED: ::c_int = 111; +pub const EADDRINUSE: ::c_int = 112; +pub const ECONNABORTED: ::c_int = 113; +pub const ENETUNREACH: ::c_int = 114; +pub const ENETDOWN: ::c_int = 115; +pub const ETIMEDOUT: ::c_int = 116; +pub const EHOSTDOWN: ::c_int = 117; +pub const EHOSTUNREACH: ::c_int = 118; +pub const EINPROGRESS: ::c_int = 119; +pub const EALREADY: ::c_int = 120; +pub const EDESTADDRREQ: ::c_int = 121; +pub const EMSGSIZE: ::c_int = 122; +pub const EPROTONOSUPPORT: ::c_int = 123; +pub const EADDRNOTAVAIL: ::c_int = 125; +pub const ENETRESET: ::c_int = 126; +pub const EISCONN: ::c_int = 127; +pub const ENOTCONN: ::c_int = 128; +pub const ETOOMANYREFS: ::c_int = 129; +pub const EDQUOT: ::c_int = 132; +pub const ESTALE: ::c_int = 133; +pub const ENOTSUP: ::c_int = 134; +pub const EILSEQ: ::c_int = 138; +pub const EOVERFLOW: ::c_int = 139; +pub const ECANCELED: ::c_int = 140; +pub const ENOTRECOVERABLE: ::c_int = 141; +pub const EOWNERDEAD: ::c_int = 142; +pub const EWOULDBLOCK: ::c_int = 11; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; +pub const F_GETOWN: ::c_int = 5; +pub const F_SETOWN: ::c_int = 6; +pub const F_GETLK: ::c_int = 7; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; +pub const F_RGETLK: ::c_int = 10; +pub const F_RSETLK: ::c_int = 11; +pub const F_CNVT: ::c_int = 12; +pub const F_RSETLKW: ::c_int = 13; +pub const F_DUPFD_CLOEXEC: ::c_int = 14; + +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 512; +pub const O_TRUNC: ::c_int = 1024; +pub const O_EXCL: ::c_int = 2048; +pub const O_SYNC: ::c_int = 8192; +pub const O_NONBLOCK: ::c_int = 16384; + +pub const O_ACCMODE: ::c_int = 3; +pub const O_CLOEXEC: ::c_int = 0x80000; + +pub const POLLIN: ::c_short = 0x1; +pub const POLLPRI: ::c_short = 0x2; +pub const POLLERR: ::c_short = 0x8; +pub const POLLNVAL: ::c_short = 0x20; + +pub const RTLD_LAZY: ::c_int = 0x1; + +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; + +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; + +pub const FIONBIO: ::c_ulong = 1; +pub const FIOCLEX: ::c_ulong = 0x20006601; +pub const FIONCLEX: ::c_ulong = 0x20006602; + +pub const S_BLKSIZE: ::mode_t = 1024; +pub const S_IREAD: ::mode_t = 256; +pub const S_IWRITE: ::mode_t = 128; +pub const S_IEXEC: ::mode_t = 64; +pub const S_ENFMT: ::mode_t = 1024; +pub const S_IFMT: ::mode_t = 61440; +pub const S_IFDIR: ::mode_t = 16384; +pub const S_IFCHR: ::mode_t = 8192; +pub const S_IFBLK: ::mode_t = 24576; +pub const S_IFREG: ::mode_t = 32768; +pub const S_IFLNK: ::mode_t = 40960; +pub const S_IFSOCK: ::mode_t = 49152; +pub const S_IFIFO: ::mode_t = 4096; +pub const S_IRUSR: ::mode_t = 256; +pub const S_IWUSR: ::mode_t = 128; +pub const S_IXUSR: ::mode_t = 64; +pub const S_IRGRP: ::mode_t = 32; +pub const S_IWGRP: ::mode_t = 16; +pub const S_IXGRP: ::mode_t = 8; +pub const S_IROTH: ::mode_t = 4; +pub const S_IWOTH: ::mode_t = 2; +pub const S_IXOTH: ::mode_t = 1; + +pub const SOL_SOCKET: ::c_int = 65535; +pub const SOL_TCP: ::c_int = 6; + +pub const PF_UNSPEC: ::c_int = 0; +pub const PF_INET: ::c_int = 2; +pub const PF_INET6: ::c_int = 23; + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_INET: ::c_int = 2; +pub const AF_INET6: ::c_int = 23; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const MSG_OOB: ::c_int = 1; +pub const MSG_PEEK: ::c_int = 2; +pub const MSG_DONTWAIT: ::c_int = 4; +pub const MSG_DONTROUTE: ::c_int = 0; +pub const MSG_WAITALL: ::c_int = 0; +pub const MSG_MORE: ::c_int = 0; +pub const MSG_NOSIGNAL: ::c_int = 0; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const SO_BINTIME: ::c_int = 0x2000; +pub const SO_NO_OFFLOAD: ::c_int = 0x4000; +pub const SO_NO_DDP: ::c_int = 0x8000; +pub const SO_REUSEPORT_LB: ::c_int = 0x10000; +pub const SO_LABEL: ::c_int = 0x1009; +pub const SO_PEERLABEL: ::c_int = 0x1010; +pub const SO_LISTENQLIMIT: ::c_int = 0x1011; +pub const SO_LISTENQLEN: ::c_int = 0x1012; +pub const SO_LISTENINCQLEN: ::c_int = 0x1013; +pub const SO_SETFIB: ::c_int = 0x1014; +pub const SO_USER_COOKIE: ::c_int = 0x1015; +pub const SO_PROTOCOL: ::c_int = 0x1016; +pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL; +pub const SO_VENDOR: ::c_int = 0x80000000; +pub const SO_DEBUG: ::c_int = 0x01; +pub const SO_ACCEPTCONN: ::c_int = 0x0002; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_TIMESTAMP: ::c_int = 0x0400; +pub const SO_NOSIGPIPE: ::c_int = 0x0800; +pub const SO_ACCEPTFILTER: ::c_int = 0x1000; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; + +pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; + +pub const INET_ADDRSTRLEN: ::c_int = 16; + +// https://github. +// com/bminor/newlib/blob/master/newlib/libc/sys/linux/include/net/if.h#L121 +pub const IFF_UP: ::c_int = 0x1; // interface is up +pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid +pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging +pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link +pub const IFF_NOTRAILERS: ::c_int = 0x20; // avoid use of trailers +pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated +pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress +pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit +pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection +pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast + +pub const TCP_NODELAY: ::c_int = 8193; +pub const TCP_MAXSEG: ::c_int = 8194; +pub const TCP_NOPUSH: ::c_int = 4; +pub const TCP_NOOPT: ::c_int = 8; +pub const TCP_KEEPIDLE: ::c_int = 256; +pub const TCP_KEEPINTVL: ::c_int = 512; +pub const TCP_KEEPCNT: ::c_int = 1024; + +pub const IP_TOS: ::c_int = 3; +pub const IP_TTL: ::c_int = 8; +pub const IP_MULTICAST_IF: ::c_int = 9; +pub const IP_MULTICAST_TTL: ::c_int = 10; +pub const IP_MULTICAST_LOOP: ::c_int = 11; +pub const IP_ADD_MEMBERSHIP: ::c_int = 11; +pub const IP_DROP_MEMBERSHIP: ::c_int = 12; + +pub const IPV6_UNICAST_HOPS: ::c_int = 4; +pub const IPV6_MULTICAST_IF: ::c_int = 9; +pub const IPV6_MULTICAST_HOPS: ::c_int = 10; +pub const IPV6_MULTICAST_LOOP: ::c_int = 11; +pub const IPV6_V6ONLY: ::c_int = 27; +pub const IPV6_JOIN_GROUP: ::c_int = 12; +pub const IPV6_LEAVE_GROUP: ::c_int = 13; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; + +pub const HOST_NOT_FOUND: ::c_int = 1; +pub const NO_DATA: ::c_int = 2; +pub const NO_ADDRESS: ::c_int = 2; +pub const NO_RECOVERY: ::c_int = 3; +pub const TRY_AGAIN: ::c_int = 4; + +pub const AI_PASSIVE: ::c_int = 1; +pub const AI_CANONNAME: ::c_int = 2; +pub const AI_NUMERICHOST: ::c_int = 4; +pub const AI_NUMERICSERV: ::c_int = 0; +pub const AI_ADDRCONFIG: ::c_int = 0; + +pub const NI_MAXHOST: ::c_int = 1025; +pub const NI_MAXSERV: ::c_int = 32; +pub const NI_NOFQDN: ::c_int = 1; +pub const NI_NUMERICHOST: ::c_int = 2; +pub const NI_NAMEREQD: ::c_int = 4; +pub const NI_NUMERICSERV: ::c_int = 0; +pub const NI_DGRAM: ::c_int = 0; + +pub const EAI_FAMILY: ::c_int = -303; +pub const EAI_MEMORY: ::c_int = -304; +pub const EAI_NONAME: ::c_int = -305; +pub const EAI_SOCKTYPE: ::c_int = -307; + +f! { + pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { + let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); + return + } + + pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0 + } + + pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { + let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] |= 1 << (fd % bits); + return + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } +} + +extern "C" { + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + + #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")] + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + pub fn sem_init( + sem: *mut sem_t, + pshared: ::c_int, + value: ::c_uint, + ) -> ::c_int; + + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + + pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) + -> ::c_int; + pub fn closesocket(sockfd: ::c_int) -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + pub fn recvfrom( + fd: ::c_int, + buf: *mut ::c_void, + n: usize, + flags: ::c_int, + addr: *mut sockaddr, + addr_len: *mut socklen_t, + ) -> isize; + pub fn getnameinfo( + sa: *const sockaddr, + salen: socklen_t, + host: *mut ::c_char, + hostlen: socklen_t, + serv: *mut ::c_char, + servlen: socklen_t, + flags: ::c_int, + ) -> ::c_int; + pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; + pub fn fexecve( + fd: ::c_int, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigaltstack$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sem_close(sem: *mut sem_t) -> ::c_int; + pub fn getdtablesize() -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_sigmask$UNIX2003" + )] + pub fn pthread_sigmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const ::c_char) -> *mut ::group; + pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; + pub fn sem_unlink(name: *const ::c_char) -> ::c_int; + pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigwait$UNIX2003" + )] + #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] + pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; + pub fn pthread_atfork( + prepare: ::Option, + parent: ::Option, + child: ::Option, + ) -> ::c_int; + pub fn getgrgid(gid: ::gid_t) -> *mut ::group; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "popen$UNIX2003" + )] + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + pub fn uname(buf: *mut ::utsname) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else { + // Only tested on ARM so far. Other platforms might have different + // definitions for types and constants. + pub use target_arch_not_implemented; + } +} + +cfg_if! { + if #[cfg(libc_align)] { + #[macro_use] + mod align; + } else { + #[macro_use] + mod no_align; + } +} +expand_align!(); diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/no_align.rs new file mode 100644 index 0000000..316c464 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/newlib/no_align.rs @@ -0,0 +1,51 @@ +macro_rules! expand_align { + () => { + s! { + pub struct pthread_mutex_t { // Unverified + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { // Unverified + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + pub struct pthread_mutexattr_t { // Unverified + #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_cond_t { // Unverified + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + pub struct pthread_condattr_t { // Unverified + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/no_align.rs new file mode 100644 index 0000000..f6b9f4c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/no_align.rs @@ -0,0 +1,6 @@ +s! { + pub struct in6_addr { + pub s6_addr: [u8; 16], + __align: [u32; 0], + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/redox/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/redox/mod.rs new file mode 100644 index 0000000..b00a191 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/redox/mod.rs @@ -0,0 +1,1114 @@ +pub type c_char = i8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type wchar_t = i32; + +pub type blkcnt_t = ::c_ulong; +pub type blksize_t = ::c_long; +pub type clock_t = ::c_long; +pub type clockid_t = ::c_int; +pub type dev_t = ::c_long; +pub type fsblkcnt_t = ::c_ulong; +pub type fsfilcnt_t = ::c_ulong; +pub type ino_t = ::c_ulong; +pub type mode_t = ::c_int; +pub type nfds_t = ::c_ulong; +pub type nlink_t = ::c_ulong; +pub type off_t = ::c_long; +pub type pthread_t = *mut ::c_void; +pub type pthread_attr_t = *mut ::c_void; +pub type pthread_cond_t = *mut ::c_void; +pub type pthread_condattr_t = *mut ::c_void; +// Must be usize due to libstd/sys_common/thread_local.rs, +// should technically be *mut ::c_void +pub type pthread_key_t = usize; +pub type pthread_mutex_t = *mut ::c_void; +pub type pthread_mutexattr_t = *mut ::c_void; +pub type pthread_rwlock_t = *mut ::c_void; +pub type pthread_rwlockattr_t = *mut ::c_void; +pub type rlim_t = ::c_ulonglong; +pub type sa_family_t = u16; +pub type sem_t = *mut ::c_void; +pub type sigset_t = ::c_ulong; +pub type socklen_t = u32; +pub type speed_t = u32; +pub type suseconds_t = ::c_int; +pub type tcflag_t = u32; +pub type time_t = ::c_long; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum timezone {} +impl ::Copy for timezone {} +impl ::Clone for timezone { + fn clone(&self) -> timezone { + *self + } +} + +s_no_extra_traits! { + #[repr(C)] + pub struct utsname { + pub sysname: [::c_char; UTSLENGTH], + pub nodename: [::c_char; UTSLENGTH], + pub release: [::c_char; UTSLENGTH], + pub version: [::c_char; UTSLENGTH], + pub machine: [::c_char; UTSLENGTH], + pub domainname: [::c_char; UTSLENGTH], + } + + pub struct dirent { + pub d_ino: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct sockaddr_un { + pub sun_family: ::sa_family_t, + pub sun_path: [::c_char; 108] + } + + pub struct sockaddr_storage { + pub ss_family: ::sa_family_t, + __ss_padding: [ + u8; + 128 - + ::core::mem::size_of::() - + ::core::mem::size_of::() + ], + __ss_align: ::c_ulong, + } +} + +s! { + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: ::size_t, + pub ai_canonname: *mut ::c_char, + pub ai_addr: *mut ::sockaddr, + pub ai_next: *mut ::addrinfo, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct epoll_event { + pub events: u32, + pub u64: u64, + pub _pad: u64, + } + + pub struct fd_set { + fds_bits: [::c_ulong; ::FD_SETSIZE / ULONG_SIZE], + } + + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: ::in_addr, + pub imr_interface: ::in_addr, + } + + pub struct lconv { + pub currency_symbol: *const ::c_char, + pub decimal_point: *const ::c_char, + pub frac_digits: ::c_char, + pub grouping: *const ::c_char, + pub int_curr_symbol: *const ::c_char, + pub int_frac_digits: ::c_char, + pub mon_decimal_point: *const ::c_char, + pub mon_grouping: *const ::c_char, + pub mon_thousands_sep: *const ::c_char, + pub negative_sign: *const ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub n_sign_posn: ::c_char, + pub positive_sign: *const ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub thousands_sep: *const ::c_char, + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct sigaction { + pub sa_handler: ::sighandler_t, + pub sa_flags: ::c_ulong, + pub sa_restorer: ::Option, + pub sa_mask: ::sigset_t, + } + + pub struct sockaddr { + pub sa_family: ::sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [::c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: ::sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + _pad: [::c_char; 24], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + pub tm_gmtoff: ::c_long, + pub tm_zone: *const ::c_char, + } +} + +pub const UTSLENGTH: usize = 65; + +// intentionally not public, only used for fd_set +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + const ULONG_SIZE: usize = 32; + } else if #[cfg(target_pointer_width = "64")] { + const ULONG_SIZE: usize = 64; + } else { + // Unknown target_pointer_width + } +} + +// limits.h +pub const PATH_MAX: ::c_int = 4096; + +// fcntl.h +pub const F_GETLK: ::c_int = 5; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; + +// TODO: relibc { +pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; +// } + +// dlfcn.h +pub const RTLD_LAZY: ::c_int = 0x0001; +pub const RTLD_NOW: ::c_int = 0x0002; +pub const RTLD_GLOBAL: ::c_int = 0x0100; +pub const RTLD_LOCAL: ::c_int = 0x0000; + +// errno.h +pub const EPERM: ::c_int = 1; /* Operation not permitted */ +pub const ENOENT: ::c_int = 2; /* No such file or directory */ +pub const ESRCH: ::c_int = 3; /* No such process */ +pub const EINTR: ::c_int = 4; /* Interrupted system call */ +pub const EIO: ::c_int = 5; /* I/O error */ +pub const ENXIO: ::c_int = 6; /* No such device or address */ +pub const E2BIG: ::c_int = 7; /* Argument list too long */ +pub const ENOEXEC: ::c_int = 8; /* Exec format error */ +pub const EBADF: ::c_int = 9; /* Bad file number */ +pub const ECHILD: ::c_int = 10; /* No child processes */ +pub const EAGAIN: ::c_int = 11; /* Try again */ +pub const ENOMEM: ::c_int = 12; /* Out of memory */ +pub const EACCES: ::c_int = 13; /* Permission denied */ +pub const EFAULT: ::c_int = 14; /* Bad address */ +pub const ENOTBLK: ::c_int = 15; /* Block device required */ +pub const EBUSY: ::c_int = 16; /* Device or resource busy */ +pub const EEXIST: ::c_int = 17; /* File exists */ +pub const EXDEV: ::c_int = 18; /* Cross-device link */ +pub const ENODEV: ::c_int = 19; /* No such device */ +pub const ENOTDIR: ::c_int = 20; /* Not a directory */ +pub const EISDIR: ::c_int = 21; /* Is a directory */ +pub const EINVAL: ::c_int = 22; /* Invalid argument */ +pub const ENFILE: ::c_int = 23; /* File table overflow */ +pub const EMFILE: ::c_int = 24; /* Too many open files */ +pub const ENOTTY: ::c_int = 25; /* Not a typewriter */ +pub const ETXTBSY: ::c_int = 26; /* Text file busy */ +pub const EFBIG: ::c_int = 27; /* File too large */ +pub const ENOSPC: ::c_int = 28; /* No space left on device */ +pub const ESPIPE: ::c_int = 29; /* Illegal seek */ +pub const EROFS: ::c_int = 30; /* Read-only file system */ +pub const EMLINK: ::c_int = 31; /* Too many links */ +pub const EPIPE: ::c_int = 32; /* Broken pipe */ +pub const EDOM: ::c_int = 33; /* Math argument out of domain of func */ +pub const ERANGE: ::c_int = 34; /* Math result not representable */ +pub const EDEADLK: ::c_int = 35; /* Resource deadlock would occur */ +pub const ENAMETOOLONG: ::c_int = 36; /* File name too long */ +pub const ENOLCK: ::c_int = 37; /* No record locks available */ +pub const ENOSYS: ::c_int = 38; /* Function not implemented */ +pub const ENOTEMPTY: ::c_int = 39; /* Directory not empty */ +pub const ELOOP: ::c_int = 40; /* Too many symbolic links encountered */ +pub const EWOULDBLOCK: ::c_int = 41; /* Operation would block */ +pub const ENOMSG: ::c_int = 42; /* No message of desired type */ +pub const EIDRM: ::c_int = 43; /* Identifier removed */ +pub const ECHRNG: ::c_int = 44; /* Channel number out of range */ +pub const EL2NSYNC: ::c_int = 45; /* Level 2 not synchronized */ +pub const EL3HLT: ::c_int = 46; /* Level 3 halted */ +pub const EL3RST: ::c_int = 47; /* Level 3 reset */ +pub const ELNRNG: ::c_int = 48; /* Link number out of range */ +pub const EUNATCH: ::c_int = 49; /* Protocol driver not attached */ +pub const ENOCSI: ::c_int = 50; /* No CSI structure available */ +pub const EL2HLT: ::c_int = 51; /* Level 2 halted */ +pub const EBADE: ::c_int = 52; /* Invalid exchange */ +pub const EBADR: ::c_int = 53; /* Invalid request descriptor */ +pub const EXFULL: ::c_int = 54; /* Exchange full */ +pub const ENOANO: ::c_int = 55; /* No anode */ +pub const EBADRQC: ::c_int = 56; /* Invalid request code */ +pub const EBADSLT: ::c_int = 57; /* Invalid slot */ +pub const EDEADLOCK: ::c_int = 58; /* Resource deadlock would occur */ +pub const EBFONT: ::c_int = 59; /* Bad font file format */ +pub const ENOSTR: ::c_int = 60; /* Device not a stream */ +pub const ENODATA: ::c_int = 61; /* No data available */ +pub const ETIME: ::c_int = 62; /* Timer expired */ +pub const ENOSR: ::c_int = 63; /* Out of streams resources */ +pub const ENONET: ::c_int = 64; /* Machine is not on the network */ +pub const ENOPKG: ::c_int = 65; /* Package not installed */ +pub const EREMOTE: ::c_int = 66; /* Object is remote */ +pub const ENOLINK: ::c_int = 67; /* Link has been severed */ +pub const EADV: ::c_int = 68; /* Advertise error */ +pub const ESRMNT: ::c_int = 69; /* Srmount error */ +pub const ECOMM: ::c_int = 70; /* Communication error on send */ +pub const EPROTO: ::c_int = 71; /* Protocol error */ +pub const EMULTIHOP: ::c_int = 72; /* Multihop attempted */ +pub const EDOTDOT: ::c_int = 73; /* RFS specific error */ +pub const EBADMSG: ::c_int = 74; /* Not a data message */ +pub const EOVERFLOW: ::c_int = 75; /* Value too large for defined data type */ +pub const ENOTUNIQ: ::c_int = 76; /* Name not unique on network */ +pub const EBADFD: ::c_int = 77; /* File descriptor in bad state */ +pub const EREMCHG: ::c_int = 78; /* Remote address changed */ +pub const ELIBACC: ::c_int = 79; /* Can not access a needed shared library */ +pub const ELIBBAD: ::c_int = 80; /* Accessing a corrupted shared library */ +pub const ELIBSCN: ::c_int = 81; /* .lib section in a.out corrupted */ +/* Attempting to link in too many shared libraries */ +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; /* Cannot exec a shared library directly */ +pub const EILSEQ: ::c_int = 84; /* Illegal byte sequence */ +/* Interrupted system call should be restarted */ +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; /* Streams pipe error */ +pub const EUSERS: ::c_int = 87; /* Too many users */ +pub const ENOTSOCK: ::c_int = 88; /* Socket operation on non-socket */ +pub const EDESTADDRREQ: ::c_int = 89; /* Destination address required */ +pub const EMSGSIZE: ::c_int = 90; /* Message too long */ +pub const EPROTOTYPE: ::c_int = 91; /* Protocol wrong type for socket */ +pub const ENOPROTOOPT: ::c_int = 92; /* Protocol not available */ +pub const EPROTONOSUPPORT: ::c_int = 93; /* Protocol not supported */ +pub const ESOCKTNOSUPPORT: ::c_int = 94; /* Socket type not supported */ +/* Operation not supported on transport endpoint */ +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; /* Protocol family not supported */ +/* Address family not supported by protocol */ +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; /* Address already in use */ +pub const EADDRNOTAVAIL: ::c_int = 99; /* Cannot assign requested address */ +pub const ENETDOWN: ::c_int = 100; /* Network is down */ +pub const ENETUNREACH: ::c_int = 101; /* Network is unreachable */ +/* Network dropped connection because of reset */ +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; /* Software caused connection abort */ +pub const ECONNRESET: ::c_int = 104; /* Connection reset by peer */ +pub const ENOBUFS: ::c_int = 105; /* No buffer space available */ +pub const EISCONN: ::c_int = 106; /* Transport endpoint is already connected */ +pub const ENOTCONN: ::c_int = 107; /* Transport endpoint is not connected */ +/* Cannot send after transport endpoint shutdown */ +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; /* Too many references: cannot splice */ +pub const ETIMEDOUT: ::c_int = 110; /* Connection timed out */ +pub const ECONNREFUSED: ::c_int = 111; /* Connection refused */ +pub const EHOSTDOWN: ::c_int = 112; /* Host is down */ +pub const EHOSTUNREACH: ::c_int = 113; /* No route to host */ +pub const EALREADY: ::c_int = 114; /* Operation already in progress */ +pub const EINPROGRESS: ::c_int = 115; /* Operation now in progress */ +pub const ESTALE: ::c_int = 116; /* Stale NFS file handle */ +pub const EUCLEAN: ::c_int = 117; /* Structure needs cleaning */ +pub const ENOTNAM: ::c_int = 118; /* Not a XENIX named type file */ +pub const ENAVAIL: ::c_int = 119; /* No XENIX semaphores available */ +pub const EISNAM: ::c_int = 120; /* Is a named type file */ +pub const EREMOTEIO: ::c_int = 121; /* Remote I/O error */ +pub const EDQUOT: ::c_int = 122; /* Quota exceeded */ +pub const ENOMEDIUM: ::c_int = 123; /* No medium found */ +pub const EMEDIUMTYPE: ::c_int = 124; /* Wrong medium type */ +pub const ECANCELED: ::c_int = 125; /* Operation Canceled */ +pub const ENOKEY: ::c_int = 126; /* Required key not available */ +pub const EKEYEXPIRED: ::c_int = 127; /* Key has expired */ +pub const EKEYREVOKED: ::c_int = 128; /* Key has been revoked */ +pub const EKEYREJECTED: ::c_int = 129; /* Key was rejected by service */ +pub const EOWNERDEAD: ::c_int = 130; /* Owner died */ +pub const ENOTRECOVERABLE: ::c_int = 131; /* State not recoverable */ + +// fcntl.h +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; +// TODO: relibc { +pub const F_DUPFD_CLOEXEC: ::c_int = ::F_DUPFD; +// } +pub const FD_CLOEXEC: ::c_int = 0x0100_0000; +pub const O_RDONLY: ::c_int = 0x0001_0000; +pub const O_WRONLY: ::c_int = 0x0002_0000; +pub const O_RDWR: ::c_int = 0x0003_0000; +pub const O_ACCMODE: ::c_int = 0x0003_0000; +pub const O_NONBLOCK: ::c_int = 0x0004_0000; +pub const O_APPEND: ::c_int = 0x0008_0000; +pub const O_SHLOCK: ::c_int = 0x0010_0000; +pub const O_EXLOCK: ::c_int = 0x0020_0000; +pub const O_ASYNC: ::c_int = 0x0040_0000; +pub const O_FSYNC: ::c_int = 0x0080_0000; +pub const O_CLOEXEC: ::c_int = 0x0100_0000; +pub const O_CREAT: ::c_int = 0x0200_0000; +pub const O_TRUNC: ::c_int = 0x0400_0000; +pub const O_EXCL: ::c_int = 0x0800_0000; +pub const O_DIRECTORY: ::c_int = 0x1000_0000; +pub const O_PATH: ::c_int = 0x2000_0000; +pub const O_SYMLINK: ::c_int = 0x4000_0000; +// Negative to allow it to be used as int +// TODO: Fix negative values missing from includes +pub const O_NOFOLLOW: ::c_int = -0x8000_0000; + +// netdb.h +pub const EAI_SYSTEM: ::c_int = -11; + +// netinet/in.h +// TODO: relibc { +pub const IP_TTL: ::c_int = 2; +pub const IPV6_UNICAST_HOPS: ::c_int = 16; +pub const IPV6_MULTICAST_IF: ::c_int = 17; +pub const IPV6_MULTICAST_HOPS: ::c_int = 18; +pub const IPV6_MULTICAST_LOOP: ::c_int = 19; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; +pub const IPV6_V6ONLY: ::c_int = 26; +pub const IP_MULTICAST_IF: ::c_int = 32; +pub const IP_MULTICAST_TTL: ::c_int = 33; +pub const IP_MULTICAST_LOOP: ::c_int = 34; +pub const IP_ADD_MEMBERSHIP: ::c_int = 35; +pub const IP_DROP_MEMBERSHIP: ::c_int = 36; +// } + +// netinet/tcp.h +pub const TCP_NODELAY: ::c_int = 1; +// TODO: relibc { +pub const TCP_KEEPIDLE: ::c_int = 1; +// } + +// poll.h +pub const POLLIN: ::c_short = 0x001; +pub const POLLPRI: ::c_short = 0x002; +pub const POLLOUT: ::c_short = 0x004; +pub const POLLERR: ::c_short = 0x008; +pub const POLLHUP: ::c_short = 0x010; +pub const POLLNVAL: ::c_short = 0x020; + +// pthread.h +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const PTHREAD_MUTEX_INITIALIZER: ::pthread_mutex_t = -1isize as *mut _; +pub const PTHREAD_COND_INITIALIZER: ::pthread_cond_t = -1isize as *mut _; +pub const PTHREAD_RWLOCK_INITIALIZER: ::pthread_rwlock_t = -1isize as *mut _; +pub const PTHREAD_STACK_MIN: ::size_t = 4096; + +// signal.h +pub const SIG_BLOCK: ::c_int = 0; +pub const SIG_UNBLOCK: ::c_int = 1; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGTRAP: ::c_int = 5; +pub const SIGABRT: ::c_int = 6; +pub const SIGBUS: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGUSR1: ::c_int = 10; +pub const SIGSEGV: ::c_int = 11; +pub const SIGUSR2: ::c_int = 12; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGCHLD: ::c_int = 17; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGURG: ::c_int = 23; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGIO: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIGSYS: ::c_int = 31; +pub const NSIG: ::c_int = 32; + +pub const SA_NOCLDSTOP: ::c_ulong = 0x00000001; +pub const SA_NOCLDWAIT: ::c_ulong = 0x00000002; +pub const SA_SIGINFO: ::c_ulong = 0x00000004; +pub const SA_RESTORER: ::c_ulong = 0x04000000; +pub const SA_ONSTACK: ::c_ulong = 0x08000000; +pub const SA_RESTART: ::c_ulong = 0x10000000; +pub const SA_NODEFER: ::c_ulong = 0x40000000; +pub const SA_RESETHAND: ::c_ulong = 0x80000000; + +// sys/epoll.h +pub const EPOLL_CLOEXEC: ::c_int = 0x0100_0000; +pub const EPOLL_CTL_ADD: ::c_int = 1; +pub const EPOLL_CTL_DEL: ::c_int = 2; +pub const EPOLL_CTL_MOD: ::c_int = 3; +pub const EPOLLIN: ::c_int = 1; +pub const EPOLLPRI: ::c_int = 0; +pub const EPOLLOUT: ::c_int = 2; +pub const EPOLLRDNORM: ::c_int = 0; +pub const EPOLLNVAL: ::c_int = 0; +pub const EPOLLRDBAND: ::c_int = 0; +pub const EPOLLWRNORM: ::c_int = 0; +pub const EPOLLWRBAND: ::c_int = 0; +pub const EPOLLMSG: ::c_int = 0; +pub const EPOLLERR: ::c_int = 0; +pub const EPOLLHUP: ::c_int = 0; +pub const EPOLLRDHUP: ::c_int = 0; +pub const EPOLLEXCLUSIVE: ::c_int = 0; +pub const EPOLLWAKEUP: ::c_int = 0; +pub const EPOLLONESHOT: ::c_int = 0; +pub const EPOLLET: ::c_int = 0; + +// sys/stat.h +pub const S_IFMT: ::c_int = 0o0_170_000; +pub const S_IFDIR: ::c_int = 0o040_000; +pub const S_IFCHR: ::c_int = 0o020_000; +pub const S_IFBLK: ::c_int = 0o060_000; +pub const S_IFREG: ::c_int = 0o100_000; +pub const S_IFIFO: ::c_int = 0o010_000; +pub const S_IFLNK: ::c_int = 0o120_000; +pub const S_IFSOCK: ::c_int = 0o140_000; +pub const S_IRWXU: ::c_int = 0o0_700; +pub const S_IRUSR: ::c_int = 0o0_400; +pub const S_IWUSR: ::c_int = 0o0_200; +pub const S_IXUSR: ::c_int = 0o0_100; +pub const S_IRWXG: ::c_int = 0o0_070; +pub const S_IRGRP: ::c_int = 0o0_040; +pub const S_IWGRP: ::c_int = 0o0_020; +pub const S_IXGRP: ::c_int = 0o0_010; +pub const S_IRWXO: ::c_int = 0o0_007; +pub const S_IROTH: ::c_int = 0o0_004; +pub const S_IWOTH: ::c_int = 0o0_002; +pub const S_IXOTH: ::c_int = 0o0_001; + +// stdlib.h +pub const EXIT_SUCCESS: ::c_int = 0; +pub const EXIT_FAILURE: ::c_int = 1; + +// sys/ioctl.h +// TODO: relibc { +pub const FIONBIO: ::c_ulong = 0x5421; +pub const FIOCLEX: ::c_ulong = 0x5451; +// } +pub const TCGETS: ::c_ulong = 0x5401; +pub const TCSETS: ::c_ulong = 0x5402; +pub const TCFLSH: ::c_ulong = 0x540B; +pub const TIOCGPGRP: ::c_ulong = 0x540F; +pub const TIOCSPGRP: ::c_ulong = 0x5410; +pub const TIOCGWINSZ: ::c_ulong = 0x5413; +pub const TIOCSWINSZ: ::c_ulong = 0x5414; + +// sys/select.h +pub const FD_SETSIZE: usize = 1024; + +// sys/socket.h +pub const AF_UNIX: ::c_int = 1; +pub const AF_INET: ::c_int = 2; +pub const AF_INET6: ::c_int = 10; +pub const MSG_PEEK: ::c_int = 2; +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_ERROR: ::c_int = 4; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_LINGER: ::c_int = 13; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOL_SOCKET: ::c_int = 1; + +// sys/termios.h +pub const NCCS: usize = 32; + +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VEOF: usize = 4; +pub const VTIME: usize = 5; +pub const VMIN: usize = 6; +pub const VSWTC: usize = 7; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; +pub const VEOL: usize = 11; +pub const VREPRINT: usize = 12; +pub const VDISCARD: usize = 13; +pub const VWERASE: usize = 14; +pub const VLNEXT: usize = 15; +pub const VEOL2: usize = 16; + +pub const IGNBRK: ::tcflag_t = 0o000_001; +pub const BRKINT: ::tcflag_t = 0o000_002; +pub const IGNPAR: ::tcflag_t = 0o000_004; +pub const PARMRK: ::tcflag_t = 0o000_010; +pub const INPCK: ::tcflag_t = 0o000_020; +pub const ISTRIP: ::tcflag_t = 0o000_040; +pub const INLCR: ::tcflag_t = 0o000_100; +pub const IGNCR: ::tcflag_t = 0o000_200; +pub const ICRNL: ::tcflag_t = 0o000_400; +pub const IUCLC: ::tcflag_t = 0o001_000; +pub const IXON: ::tcflag_t = 0o002_000; +pub const IXANY: ::tcflag_t = 0o004_000; +pub const IXOFF: ::tcflag_t = 0o010_000; +pub const IMAXBEL: ::tcflag_t = 0o020_000; +pub const IUTF8: ::tcflag_t = 0o040_000; + +pub const OPOST: ::tcflag_t = 0o000_001; +pub const OLCUC: ::tcflag_t = 0o000_002; +pub const ONLCR: ::tcflag_t = 0o000_004; +pub const OCRNL: ::tcflag_t = 0o000_010; +pub const ONOCR: ::tcflag_t = 0o000_020; +pub const ONLRET: ::tcflag_t = 0o00_0040; +pub const OFILL: ::tcflag_t = 0o000_100; +pub const OFDEL: ::tcflag_t = 0o000_200; + +pub const VTDLY: usize = 0o040_000; +pub const VT0: usize = 0o000_000; +pub const VT1: usize = 0o040_000; + +pub const B0: speed_t = 0o000_000; +pub const B50: speed_t = 0o000_001; +pub const B75: speed_t = 0o000_002; +pub const B110: speed_t = 0o000_003; +pub const B134: speed_t = 0o000_004; +pub const B150: speed_t = 0o000_005; +pub const B200: speed_t = 0o000_006; +pub const B300: speed_t = 0o000_007; +pub const B600: speed_t = 0o000_010; +pub const B1200: speed_t = 0o000_011; +pub const B1800: speed_t = 0o000_012; +pub const B2400: speed_t = 0o000_013; +pub const B4800: speed_t = 0o000_014; +pub const B9600: speed_t = 0o000_015; +pub const B19200: speed_t = 0o000_016; +pub const B38400: speed_t = 0o000_017; + +pub const B57600: speed_t = 0o010_001; +pub const B115200: speed_t = 0o010_002; +pub const B230400: speed_t = 0o010_003; +pub const B460800: speed_t = 0o010_004; +pub const B500000: speed_t = 0o010_005; +pub const B576000: speed_t = 0o010_006; +pub const B921600: speed_t = 0o010_007; +pub const B1000000: speed_t = 0o010_010; +pub const B1152000: speed_t = 0o010_011; +pub const B1500000: speed_t = 0o010_012; +pub const B2000000: speed_t = 0o010_013; +pub const B2500000: speed_t = 0o010_014; +pub const B3000000: speed_t = 0o010_015; +pub const B3500000: speed_t = 0o010_016; +pub const B4000000: speed_t = 0o010_017; + +pub const CSIZE: ::tcflag_t = 0o000_060; +pub const CS5: ::tcflag_t = 0o000_000; +pub const CS6: ::tcflag_t = 0o000_020; +pub const CS7: ::tcflag_t = 0o000_040; +pub const CS8: ::tcflag_t = 0o000_060; +pub const CSTOPB: ::tcflag_t = 0o000_100; +pub const CREAD: ::tcflag_t = 0o000_200; +pub const PARENB: ::tcflag_t = 0o000_400; +pub const PARODD: ::tcflag_t = 0o001_000; +pub const HUPCL: ::tcflag_t = 0o002_000; +pub const CLOCAL: ::tcflag_t = 0o004_000; + +pub const ISIG: ::tcflag_t = 0o000_001; +pub const ICANON: ::tcflag_t = 0o000_002; +pub const ECHO: ::tcflag_t = 0o000_010; +pub const ECHOE: ::tcflag_t = 0o000_020; +pub const ECHOK: ::tcflag_t = 0o000_040; +pub const ECHONL: ::tcflag_t = 0o000_100; +pub const NOFLSH: ::tcflag_t = 0o000_200; +pub const TOSTOP: ::tcflag_t = 0o000_400; +pub const IEXTEN: ::tcflag_t = 0o100_000; + +pub const TCOOFF: ::c_int = 0; +pub const TCOON: ::c_int = 1; +pub const TCIOFF: ::c_int = 2; +pub const TCION: ::c_int = 3; + +pub const TCIFLUSH: ::c_int = 0; +pub const TCOFLUSH: ::c_int = 1; +pub const TCIOFLUSH: ::c_int = 2; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +// sys/wait.h +pub const WNOHANG: ::c_int = 1; +pub const WUNTRACED: ::c_int = 2; + +pub const WSTOPPED: ::c_int = 2; +pub const WEXITED: ::c_int = 4; +pub const WCONTINUED: ::c_int = 8; +pub const WNOWAIT: ::c_int = 0x0100_0000; + +pub const __WNOTHREAD: ::c_int = 0x2000_0000; +pub const __WALL: ::c_int = 0x4000_0000; +#[allow(overflowing_literals)] +pub const __WCLONE: ::c_int = 0x8000_0000; + +// time.h +pub const CLOCK_REALTIME: ::c_int = 1; +pub const CLOCK_MONOTONIC: ::c_int = 4; + +// unistd.h +// POSIX.1 { +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_CHILD_MAX: ::c_int = 1; +pub const _SC_CLK_TCK: ::c_int = 2; +pub const _SC_NGROUPS_MAX: ::c_int = 3; +pub const _SC_OPEN_MAX: ::c_int = 4; +pub const _SC_STREAM_MAX: ::c_int = 5; +pub const _SC_TZNAME_MAX: ::c_int = 6; +// ... +pub const _SC_VERSION: ::c_int = 29; +pub const _SC_PAGESIZE: ::c_int = 30; +pub const _SC_PAGE_SIZE: ::c_int = 30; +// ... +pub const _SC_RE_DUP_MAX: ::c_int = 44; +// ... +pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; +pub const _SC_TTY_NAME_MAX: ::c_int = 72; +// ... +pub const _SC_SYMLOOP_MAX: ::c_int = 173; +// ... +pub const _SC_HOST_NAME_MAX: ::c_int = 180; +// } POSIX.1 + +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; + +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; + +pub const _PC_LINK_MAX: ::c_int = 0; +pub const _PC_MAX_CANON: ::c_int = 1; +pub const _PC_MAX_INPUT: ::c_int = 2; +pub const _PC_NAME_MAX: ::c_int = 3; +pub const _PC_PATH_MAX: ::c_int = 4; +pub const _PC_PIPE_BUF: ::c_int = 5; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 6; +pub const _PC_NO_TRUNC: ::c_int = 7; +pub const _PC_VDISABLE: ::c_int = 8; +pub const _PC_SYNC_IO: ::c_int = 9; +pub const _PC_ASYNC_IO: ::c_int = 10; +pub const _PC_PRIO_IO: ::c_int = 11; +pub const _PC_SOCK_MAXBUF: ::c_int = 12; +pub const _PC_FILESIZEBITS: ::c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16; +pub const _PC_REC_XFER_ALIGN: ::c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18; +pub const _PC_SYMLINK_MAX: ::c_int = 19; +pub const _PC_2_SYMLINKS: ::c_int = 20; + +// wait.h +f! { + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WIFCONTINUED(status: ::c_int) -> bool { + status == 0xffff + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0x7f + } + + pub fn WIFEXITED(status: ::c_int) -> bool { + (status & 0x7f) == 0 + } + + pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WCOREDUMP(status: ::c_int) -> bool { + (status & 0x80) != 0 + } +} + +extern "C" { + // errno.h + pub fn __errno_location() -> *mut ::c_int; + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + // unistd.h + pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + + // malloc.h + pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; + + // pthread.h + pub fn pthread_atfork( + prepare: ::Option, + parent: ::Option, + child: ::Option, + ) -> ::c_int; + pub fn pthread_create( + tid: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + start: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + arg: *mut ::c_void, + ) -> ::c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + + // pwd.h + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + + // signal.h + pub fn pthread_sigmask( + how: ::c_int, + set: *const ::sigset_t, + oldset: *mut ::sigset_t, + ) -> ::c_int; + + // sys/epoll.h + pub fn epoll_create(size: ::c_int) -> ::c_int; + pub fn epoll_create1(flags: ::c_int) -> ::c_int; + pub fn epoll_wait( + epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: ::c_int, + ) -> ::c_int; + pub fn epoll_ctl( + epfd: ::c_int, + op: ::c_int, + fd: ::c_int, + event: *mut ::epoll_event, + ) -> ::c_int; + + // sys/ioctl.h + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + + // sys/resource.h + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + + // sys/socket.h + pub fn bind( + socket: ::c_int, + address: *const ::sockaddr, + address_len: ::socklen_t, + ) -> ::c_int; + pub fn recvfrom( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + ) -> ::ssize_t; + + // sys/stat.h + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + + // sys/uio.h + pub fn readv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + pub fn writev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + + // sys/utsname.h + pub fn uname(utsname: *mut utsname) -> ::c_int; + + // time.h + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for dirent {} + + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for sockaddr_un {} + + impl ::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } + } + + impl ::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_family.hash(state); + self.sun_path.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_family == other.ss_family + && self.__ss_align == self.__ss_align + && self + .__ss_padding + .iter() + .zip(other.__ss_padding.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for sockaddr_storage {} + + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_family", &self.ss_family) + .field("__ss_align", &self.__ss_align) + // FIXME: .field("__ss_padding", &self.__ss_padding) + .finish() + } + } + + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_family.hash(state); + self.__ss_padding.hash(state); + self.__ss_align.hash(state); + } + } + + impl PartialEq for utsname { + fn eq(&self, other: &utsname) -> bool { + self.sysname + .iter() + .zip(other.sysname.iter()) + .all(|(a, b)| a == b) + && self + .nodename + .iter() + .zip(other.nodename.iter()) + .all(|(a, b)| a == b) + && self + .release + .iter() + .zip(other.release.iter()) + .all(|(a, b)| a == b) + && self + .version + .iter() + .zip(other.version.iter()) + .all(|(a, b)| a == b) + && self + .machine + .iter() + .zip(other.machine.iter()) + .all(|(a, b)| a == b) + && self + .domainname + .iter() + .zip(other.domainname.iter()) + .all(|(a, b)| a == b) + } + } + + impl Eq for utsname {} + + impl ::fmt::Debug for utsname { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utsname") + // FIXME: .field("sysname", &self.sysname) + // FIXME: .field("nodename", &self.nodename) + // FIXME: .field("release", &self.release) + // FIXME: .field("version", &self.version) + // FIXME: .field("machine", &self.machine) + // FIXME: .field("domainname", &self.domainname) + .finish() + } + } + + impl ::hash::Hash for utsname { + fn hash(&self, state: &mut H) { + self.sysname.hash(state); + self.nodename.hash(state); + self.release.hash(state); + self.version.hash(state); + self.machine.hash(state); + self.domainname.hash(state); + } + } + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/solarish/compat.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/solarish/compat.rs new file mode 100644 index 0000000..a336452 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/solarish/compat.rs @@ -0,0 +1,32 @@ +// Common functions that are unfortunately missing on illumos and +// Solaris, but often needed by other crates. + +use unix::solarish::*; + +pub unsafe fn cfmakeraw(termios: *mut ::termios) { + let mut t = *termios as ::termios; + t.c_iflag &= !(IMAXBEL + | IGNBRK + | BRKINT + | PARMRK + | ISTRIP + | INLCR + | IGNCR + | ICRNL + | IXON); + t.c_oflag &= !OPOST; + t.c_lflag &= !(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + t.c_cflag &= !(CSIZE | PARENB); + t.c_cflag |= CS8; +} + +pub unsafe fn cfsetspeed( + termios: *mut ::termios, + speed: ::speed_t, +) -> ::c_int { + // Neither of these functions on illumos or Solaris actually ever + // return an error + ::cfsetispeed(termios, speed); + ::cfsetospeed(termios, speed); + 0 +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/solarish/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/solarish/mod.rs new file mode 100644 index 0000000..06c1a20 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/solarish/mod.rs @@ -0,0 +1,2499 @@ +pub type c_char = i8; +pub type c_long = i64; +pub type c_ulong = u64; + +pub type clockid_t = ::c_int; +pub type blkcnt_t = ::c_long; +pub type clock_t = ::c_long; +pub type daddr_t = ::c_long; +pub type dev_t = ::c_ulong; +pub type fsblkcnt_t = ::c_ulong; +pub type fsfilcnt_t = ::c_ulong; +pub type ino_t = ::c_ulong; +pub type key_t = ::c_int; +pub type major_t = ::c_uint; +pub type minor_t = ::c_uint; +pub type mode_t = ::c_uint; +pub type nlink_t = ::c_uint; +pub type rlim_t = ::c_ulong; +pub type speed_t = ::c_uint; +pub type tcflag_t = ::c_uint; +pub type time_t = ::c_long; +pub type wchar_t = ::c_int; +pub type nfds_t = ::c_ulong; + +pub type suseconds_t = ::c_long; +pub type off_t = ::c_long; +pub type useconds_t = ::c_uint; +pub type socklen_t = ::c_uint; +pub type sa_family_t = u16; +pub type pthread_t = ::c_uint; +pub type pthread_key_t = ::c_uint; +pub type blksize_t = ::c_int; +pub type nl_item = ::c_int; +pub type mqd_t = *mut ::c_void; +pub type id_t = ::c_int; +pub type idtype_t = ::c_uint; +pub type shmatt_t = ::c_ulong; + +pub type door_attr_t = ::c_uint; +pub type door_id_t = ::c_ulonglong; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum timezone {} +impl ::Copy for timezone {} +impl ::Clone for timezone { + fn clone(&self) -> timezone { + *self + } +} + +s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipc_perm { + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub seq: ::c_uint, + pub key: ::key_t, + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [::c_char; 8] + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + pub __sin6_src_id: u32 + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_age: *mut ::c_char, + pub pw_comment: *mut ::c_char, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut ::c_char, + pub ifa_flags: ::c_ulong, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_dstaddr: *mut ::sockaddr, + pub ifa_data: *mut ::c_void + } + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::socklen_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::socklen_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct pthread_attr_t { + __pthread_attrp: *mut ::c_void + } + + pub struct pthread_mutex_t { + __pthread_mutex_flag1: u16, + __pthread_mutex_flag2: u8, + __pthread_mutex_ceiling: u8, + __pthread_mutex_type: u16, + __pthread_mutex_magic: u16, + __pthread_mutex_lock: u64, + __pthread_mutex_data: u64 + } + + pub struct pthread_mutexattr_t { + __pthread_mutexattrp: *mut ::c_void + } + + pub struct pthread_cond_t { + __pthread_cond_flag: [u8; 4], + __pthread_cond_type: u16, + __pthread_cond_magic: u16, + __pthread_cond_data: u64 + } + + pub struct pthread_condattr_t { + __pthread_condattrp: *mut ::c_void, + } + + pub struct pthread_rwlock_t { + __pthread_rwlock_readers: i32, + __pthread_rwlock_type: u16, + __pthread_rwlock_magic: u16, + __pthread_rwlock_mutex: ::pthread_mutex_t, + __pthread_rwlock_readercv: ::pthread_cond_t, + __pthread_rwlock_writercv: ::pthread_cond_t + } + + pub struct pthread_rwlockattr_t { + __pthread_rwlockattrp: *mut ::c_void, + } + + pub struct dirent { + pub d_ino: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: u16, + pub d_name: [::c_char; 3] + } + + pub struct glob_t { + pub gl_pathc: ::size_t, + pub gl_pathv: *mut *mut ::c_char, + pub gl_offs: ::size_t, + __unused1: *mut ::c_void, + __unused2: ::c_int, + __unused3: ::c_int, + __unused4: ::c_int, + __unused5: *mut ::c_void, + __unused6: *mut ::c_void, + __unused7: *mut ::c_void, + __unused8: *mut ::c_void, + __unused9: *mut ::c_void, + __unused10: *mut ::c_void, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + #[cfg(target_arch = "sparc64")] + __sparcv9_pad: ::c_int, + pub ai_addrlen: ::socklen_t, + pub ai_canonname: *mut ::c_char, + pub ai_addr: *mut ::sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct shmid_ds { + pub shm_perm: ipc_perm, + pub shm_segsz: ::size_t, + #[cfg(target_os = "illumos")] + pub shm_amp: *mut ::c_void, + #[cfg(target_os = "solaris")] + pub shm_flags: ::uintptr_t, + pub shm_lkcnt: ::c_ushort, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_cnattch: ::c_ulong, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + #[cfg(target_os = "illumos")] + pub shm_pad4: [i64; 4], + #[cfg(target_os = "solaris")] + pub shm_amp: *mut ::c_void, + #[cfg(target_os = "solaris")] + pub shm_gransize: u64, + #[cfg(target_os = "solaris")] + pub shm_allocated: u64, + #[cfg(target_os = "solaris")] + pub shm_pad4: [i64; 1], + } + + pub struct sigset_t { + bits: [u32; 4], + } + + pub struct sigaction { + pub sa_flags: ::c_int, + pub sa_sigaction: ::sighandler_t, + pub sa_mask: sigset_t, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_basetype: [::c_char; 16], + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub f_fstr: [::c_char; 32] + } + + pub struct sched_param { + pub sched_priority: ::c_int, + sched_pad: [::c_int; 8] + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + __unused: [::c_char; 16] + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_cc: [::cc_t; ::NCCS] + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct sem_t { + pub sem_count: u32, + pub sem_type: u16, + pub sem_magic: u16, + pub sem_pad1: [u64; 3], + pub sem_pad2: [u64; 2] + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_sysid: ::c_int, + pub l_pid: ::pid_t, + pub l_pad: [::c_long; 4] + } + + pub struct if_nameindex { + pub if_index: ::c_uint, + pub if_name: *mut ::c_char, + } + + pub struct mq_attr { + pub mq_flags: ::c_long, + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_curmsgs: ::c_long, + _pad: [::c_int; 4] + } + + pub struct port_event { + pub portev_events: ::c_int, + pub portev_source: ::c_ushort, + pub portev_pad: ::c_ushort, + pub portev_object: ::uintptr_t, + pub portev_user: *mut ::c_void, + } + + pub struct door_desc_t__d_data__d_desc { + pub d_descriptor: ::c_int, + pub d_id: ::door_id_t + } + + pub struct exit_status { + e_termination: ::c_short, + e_exit: ::c_short, + } + + pub struct utmp { + pub ut_user: [::c_char; 8], + pub ut_id: [::c_char; 4], + pub ut_line: [::c_char; 12], + pub ut_pid: ::c_short, + pub ut_type: ::c_short, + pub ut_exit: exit_status, + pub ut_time: ::time_t, + } +} + +s_no_extra_traits! { + #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed))] + pub struct epoll_event { + pub events: u32, + pub u64: u64, + } + + pub struct utmpx { + pub ut_user: [::c_char; _UTX_USERSIZE], + pub ut_id: [::c_char; _UTX_IDSIZE], + pub ut_line: [::c_char; _UTX_LINESIZE], + pub ut_pid: ::pid_t, + pub ut_type: ::c_short, + pub ut_exit: exit_status, + pub ut_tv: ::timeval, + pub ut_session: ::c_int, + pub ut_pad: [::c_int; _UTX_PADSIZE], + pub ut_syslen: ::c_short, + pub ut_host: [::c_char; _UTX_HOSTSIZE], + } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108] + } + + pub struct utsname { + pub sysname: [::c_char; 257], + pub nodename: [::c_char; 257], + pub release: [::c_char; 257], + pub version: [::c_char; 257], + pub machine: [::c_char; 257], + } + + pub struct fd_set { + #[cfg(target_pointer_width = "64")] + fds_bits: [i64; FD_SETSIZE / 64], + #[cfg(target_pointer_width = "32")] + fds_bits: [i32; FD_SETSIZE / 32], + } + + pub struct sockaddr_storage { + pub ss_family: ::sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 240], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub si_pad: ::c_int, + pub si_addr: *mut ::c_void, + __pad: [u8; 232], + } + + pub struct sockaddr_dl { + pub sdl_family: ::c_ushort, + pub sdl_index: ::c_ushort, + pub sdl_type: ::c_uchar, + pub sdl_nlen: ::c_uchar, + pub sdl_alen: ::c_uchar, + pub sdl_slen: ::c_uchar, + pub sdl_data: [::c_char; 244], + } + + pub struct sigevent { + pub sigev_notify: ::c_int, + pub sigev_signo: ::c_int, + pub sigev_value: ::sigval, + pub ss_sp: *mut ::c_void, + pub sigev_notify_attributes: *const ::pthread_attr_t, + __sigev_pad2: ::c_int, + } + + pub union door_desc_t__d_data { + pub d_desc: door_desc_t__d_data__d_desc, + d_resv: [::c_int; 5], /* Check out /usr/include/sys/door.h */ + } + + pub struct door_desc_t { + pub d_attributes: door_attr_t, + pub d_data: door_desc_t__d_data, + } + + pub struct door_arg_t { + pub data_ptr: *const ::c_char, + pub data_size: ::size_t, + pub desc_ptr: *const door_desc_t, + pub dec_num: ::c_uint, + pub rbuf: *const ::c_char, + pub rsize: ::size_t, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self.ut_user == other.ut_user + && self.ut_line == other.ut_line + && self.ut_id == other.ut_id + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_syslen == other.ut_syslen + && self.ut_pad == other.ut_pad + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for utmpx {} + + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmpx") + .field("ut_user", &self.ut_user) + .field("ut_id", &self.ut_id) + .field("ut_line", &self.ut_line) + .field("ut_pid", &self.ut_pid) + .field("ut_type", &self.ut_type) + .field("ut_exit", &self.ut_exit) + .field("ut_tv", &self.ut_tv) + .field("ut_session", &self.ut_session) + .field("ut_pad", &self.ut_pad) + .field("ut_syslen", &self.ut_syslen) + .field("ut_host", &self.ut_host) + .finish() + } + } + + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_user.hash(state); + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_syslen.hash(state); + self.ut_pad.hash(state); + } + } + + impl PartialEq for epoll_event { + fn eq(&self, other: &epoll_event) -> bool { + self.events == other.events + && self.u64 == other.u64 + } + } + impl Eq for epoll_event {} + impl ::fmt::Debug for epoll_event { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let events = self.events; + let u64 = self.u64; + f.debug_struct("epoll_event") + .field("events", &events) + .field("u64", &u64) + .finish() + } + } + impl ::hash::Hash for epoll_event { + fn hash(&self, state: &mut H) { + let events = self.events; + let u64 = self.u64; + events.hash(state); + u64.hash(state); + } + } + + impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a, b)| a == b) + } + } + impl Eq for sockaddr_un {} + impl ::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } + } + impl ::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_family.hash(state); + self.sun_path.hash(state); + } + } + + impl PartialEq for utsname { + fn eq(&self, other: &utsname) -> bool { + self.sysname + .iter() + .zip(other.sysname.iter()) + .all(|(a, b)| a == b) + && self + .nodename + .iter() + .zip(other.nodename.iter()) + .all(|(a, b)| a == b) + && self + .release + .iter() + .zip(other.release.iter()) + .all(|(a, b)| a == b) + && self + .version + .iter() + .zip(other.version.iter()) + .all(|(a, b)| a == b) + && self + .machine + .iter() + .zip(other.machine.iter()) + .all(|(a, b)| a == b) + } + } + impl Eq for utsname {} + impl ::fmt::Debug for utsname { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utsname") + // FIXME: .field("sysname", &self.sysname) + // FIXME: .field("nodename", &self.nodename) + // FIXME: .field("release", &self.release) + // FIXME: .field("version", &self.version) + // FIXME: .field("machine", &self.machine) + .finish() + } + } + impl ::hash::Hash for utsname { + fn hash(&self, state: &mut H) { + self.sysname.hash(state); + self.nodename.hash(state); + self.release.hash(state); + self.version.hash(state); + self.machine.hash(state); + } + } + + impl PartialEq for fd_set { + fn eq(&self, other: &fd_set) -> bool { + self.fds_bits + .iter() + .zip(other.fds_bits.iter()) + .all(|(a, b)| a == b) + } + } + impl Eq for fd_set {} + impl ::fmt::Debug for fd_set { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("fd_set") + // FIXME: .field("fds_bits", &self.fds_bits) + .finish() + } + } + impl ::hash::Hash for fd_set { + fn hash(&self, state: &mut H) { + self.fds_bits.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_family == other.ss_family + && self.__ss_pad1 == other.__ss_pad1 + && self.__ss_align == other.__ss_align + && self + .__ss_pad2 + .iter() + .zip(other.__ss_pad2.iter()) + .all(|(a, b)| a == b) + } + } + impl Eq for sockaddr_storage {} + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_family", &self.ss_family) + .field("__ss_pad1", &self.__ss_pad1) + .field("__ss_align", &self.__ss_align) + // FIXME: .field("__ss_pad2", &self.__ss_pad2) + .finish() + } + } + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_family.hash(state); + self.__ss_pad1.hash(state); + self.__ss_align.hash(state); + self.__ss_pad2.hash(state); + } + } + + impl PartialEq for siginfo_t { + fn eq(&self, other: &siginfo_t) -> bool { + self.si_signo == other.si_signo + && self.si_code == other.si_code + && self.si_errno == other.si_errno + && self.si_addr == other.si_addr + && self + .__pad + .iter() + .zip(other.__pad.iter()) + .all(|(a, b)| a == b) + } + } + impl Eq for siginfo_t {} + impl ::fmt::Debug for siginfo_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("siginfo_t") + .field("si_signo", &self.si_signo) + .field("si_code", &self.si_code) + .field("si_errno", &self.si_errno) + .field("si_addr", &self.si_addr) + // FIXME: .field("__pad", &self.__pad) + .finish() + } + } + impl ::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_code.hash(state); + self.si_errno.hash(state); + self.si_addr.hash(state); + self.__pad.hash(state); + } + } + + impl PartialEq for sockaddr_dl { + fn eq(&self, other: &sockaddr_dl) -> bool { + self.sdl_family == other.sdl_family + && self.sdl_index == other.sdl_index + && self.sdl_type == other.sdl_type + && self.sdl_nlen == other.sdl_nlen + && self.sdl_alen == other.sdl_alen + && self.sdl_slen == other.sdl_slen + && self + .sdl_data + .iter() + .zip(other.sdl_data.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for sockaddr_dl {} + impl ::fmt::Debug for sockaddr_dl { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_dl") + .field("sdl_family", &self.sdl_family) + .field("sdl_index", &self.sdl_index) + .field("sdl_type", &self.sdl_type) + .field("sdl_nlen", &self.sdl_nlen) + .field("sdl_alen", &self.sdl_alen) + .field("sdl_slen", &self.sdl_slen) + // FIXME: .field("sdl_data", &self.sdl_data) + .finish() + } + } + impl ::hash::Hash for sockaddr_dl { + fn hash(&self, state: &mut H) { + self.sdl_family.hash(state); + self.sdl_index.hash(state); + self.sdl_type.hash(state); + self.sdl_nlen.hash(state); + self.sdl_alen.hash(state); + self.sdl_slen.hash(state); + self.sdl_data.hash(state); + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_notify == other.sigev_notify + && self.sigev_signo == other.sigev_signo + && self.sigev_value == other.sigev_value + && self.ss_sp == other.ss_sp + && self.sigev_notify_attributes + == other.sigev_notify_attributes + } + } + impl Eq for sigevent {} + impl ::fmt::Debug for sigevent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sigevent") + .field("sigev_notify", &self.sigev_notify) + .field("sigev_signo", &self.sigev_signo) + .field("sigev_value", &self.sigev_value) + .field("ss_sp", &self.ss_sp) + .field("sigev_notify_attributes", + &self.sigev_notify_attributes) + .finish() + } + } + impl ::hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_notify.hash(state); + self.sigev_signo.hash(state); + self.sigev_value.hash(state); + self.ss_sp.hash(state); + self.sigev_notify_attributes.hash(state); + } + } + + } +} + +pub const LC_CTYPE: ::c_int = 0; +pub const LC_NUMERIC: ::c_int = 1; +pub const LC_TIME: ::c_int = 2; +pub const LC_COLLATE: ::c_int = 3; +pub const LC_MONETARY: ::c_int = 4; +pub const LC_MESSAGES: ::c_int = 5; +pub const LC_ALL: ::c_int = 6; +pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE); +pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC); +pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME); +pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE); +pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY); +pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES); +pub const LC_ALL_MASK: ::c_int = LC_CTYPE_MASK + | LC_NUMERIC_MASK + | LC_TIME_MASK + | LC_COLLATE_MASK + | LC_MONETARY_MASK + | LC_MESSAGES_MASK; + +pub const DAY_1: ::nl_item = 1; +pub const DAY_2: ::nl_item = 2; +pub const DAY_3: ::nl_item = 3; +pub const DAY_4: ::nl_item = 4; +pub const DAY_5: ::nl_item = 5; +pub const DAY_6: ::nl_item = 6; +pub const DAY_7: ::nl_item = 7; + +pub const ABDAY_1: ::nl_item = 8; +pub const ABDAY_2: ::nl_item = 9; +pub const ABDAY_3: ::nl_item = 10; +pub const ABDAY_4: ::nl_item = 11; +pub const ABDAY_5: ::nl_item = 12; +pub const ABDAY_6: ::nl_item = 13; +pub const ABDAY_7: ::nl_item = 14; + +pub const MON_1: ::nl_item = 15; +pub const MON_2: ::nl_item = 16; +pub const MON_3: ::nl_item = 17; +pub const MON_4: ::nl_item = 18; +pub const MON_5: ::nl_item = 19; +pub const MON_6: ::nl_item = 20; +pub const MON_7: ::nl_item = 21; +pub const MON_8: ::nl_item = 22; +pub const MON_9: ::nl_item = 23; +pub const MON_10: ::nl_item = 24; +pub const MON_11: ::nl_item = 25; +pub const MON_12: ::nl_item = 26; + +pub const ABMON_1: ::nl_item = 27; +pub const ABMON_2: ::nl_item = 28; +pub const ABMON_3: ::nl_item = 29; +pub const ABMON_4: ::nl_item = 30; +pub const ABMON_5: ::nl_item = 31; +pub const ABMON_6: ::nl_item = 32; +pub const ABMON_7: ::nl_item = 33; +pub const ABMON_8: ::nl_item = 34; +pub const ABMON_9: ::nl_item = 35; +pub const ABMON_10: ::nl_item = 36; +pub const ABMON_11: ::nl_item = 37; +pub const ABMON_12: ::nl_item = 38; + +pub const RADIXCHAR: ::nl_item = 39; +pub const THOUSEP: ::nl_item = 40; +pub const YESSTR: ::nl_item = 41; +pub const NOSTR: ::nl_item = 42; +pub const CRNCYSTR: ::nl_item = 43; + +pub const D_T_FMT: ::nl_item = 44; +pub const D_FMT: ::nl_item = 45; +pub const T_FMT: ::nl_item = 46; +pub const AM_STR: ::nl_item = 47; +pub const PM_STR: ::nl_item = 48; + +pub const CODESET: ::nl_item = 49; +pub const T_FMT_AMPM: ::nl_item = 50; +pub const ERA: ::nl_item = 51; +pub const ERA_D_FMT: ::nl_item = 52; +pub const ERA_D_T_FMT: ::nl_item = 53; +pub const ERA_T_FMT: ::nl_item = 54; +pub const ALT_DIGITS: ::nl_item = 55; +pub const YESEXPR: ::nl_item = 56; +pub const NOEXPR: ::nl_item = 57; +pub const _DATE_FMT: ::nl_item = 58; +pub const MAXSTRMSG: ::nl_item = 58; + +pub const PATH_MAX: ::c_int = 1024; + +pub const SA_ONSTACK: ::c_int = 0x00000001; +pub const SA_RESETHAND: ::c_int = 0x00000002; +pub const SA_RESTART: ::c_int = 0x00000004; +pub const SA_SIGINFO: ::c_int = 0x00000008; +pub const SA_NODEFER: ::c_int = 0x00000010; +pub const SA_NOCLDWAIT: ::c_int = 0x00010000; +pub const SA_NOCLDSTOP: ::c_int = 0x00020000; + +pub const SS_ONSTACK: ::c_int = 1; +pub const SS_DISABLE: ::c_int = 2; + +pub const FIOCLEX: ::c_int = 0x20006601; +pub const FIONCLEX: ::c_int = 0x20006602; +pub const FIONREAD: ::c_int = 0x4004667f; +pub const FIONBIO: ::c_int = 0x8004667e; +pub const FIOASYNC: ::c_int = 0x8004667d; +pub const FIOSETOWN: ::c_int = 0x8004667c; +pub const FIOGETOWN: ::c_int = 0x4004667b; + +pub const SIGCHLD: ::c_int = 18; +pub const SIGBUS: ::c_int = 10; +pub const SIGINFO: ::c_int = 41; +pub const SIG_BLOCK: ::c_int = 1; +pub const SIG_UNBLOCK: ::c_int = 2; +pub const SIG_SETMASK: ::c_int = 3; + +pub const SIGEV_NONE: ::c_int = 1; +pub const SIGEV_SIGNAL: ::c_int = 2; +pub const SIGEV_THREAD: ::c_int = 3; + +pub const IPV6_UNICAST_HOPS: ::c_int = 0x5; +pub const IPV6_MULTICAST_IF: ::c_int = 0x6; +pub const IPV6_MULTICAST_HOPS: ::c_int = 0x7; +pub const IPV6_MULTICAST_LOOP: ::c_int = 0x8; +pub const IPV6_V6ONLY: ::c_int = 0x27; + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + pub const FD_SETSIZE: usize = 65536; + } else { + pub const FD_SETSIZE: usize = 1024; + } +} + +pub const ST_RDONLY: ::c_ulong = 1; +pub const ST_NOSUID: ::c_ulong = 2; + +pub const NI_MAXHOST: ::socklen_t = 1025; + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 32767; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 4; +pub const _IOLBF: ::c_int = 64; +pub const BUFSIZ: ::c_uint = 1024; +pub const FOPEN_MAX: ::c_uint = 20; +pub const FILENAME_MAX: ::c_uint = 1024; +pub const L_tmpnam: ::c_uint = 25; +pub const TMP_MAX: ::c_uint = 17576; + +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_NDELAY: ::c_int = 0x04; +pub const O_APPEND: ::c_int = 8; +pub const O_DSYNC: ::c_int = 0x40; +pub const O_CREAT: ::c_int = 256; +pub const O_EXCL: ::c_int = 1024; +pub const O_NOCTTY: ::c_int = 2048; +pub const O_TRUNC: ::c_int = 512; +pub const O_NOFOLLOW: ::c_int = 0x200000; +pub const O_SEARCH: ::c_int = 0x200000; +pub const O_EXEC: ::c_int = 0x400000; +pub const O_CLOEXEC: ::c_int = 0x800000; +pub const O_ACCMODE: ::c_int = 0x600003; +pub const S_IFIFO: mode_t = 4096; +pub const S_IFCHR: mode_t = 8192; +pub const S_IFBLK: mode_t = 24576; +pub const S_IFDIR: mode_t = 16384; +pub const S_IFREG: mode_t = 32768; +pub const S_IFLNK: mode_t = 40960; +pub const S_IFSOCK: mode_t = 49152; +pub const S_IFMT: mode_t = 61440; +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; +pub const S_IRWXU: mode_t = 448; +pub const S_IXUSR: mode_t = 64; +pub const S_IWUSR: mode_t = 128; +pub const S_IRUSR: mode_t = 256; +pub const S_IRWXG: mode_t = 56; +pub const S_IXGRP: mode_t = 8; +pub const S_IWGRP: mode_t = 16; +pub const S_IRGRP: mode_t = 32; +pub const S_IRWXO: mode_t = 7; +pub const S_IXOTH: mode_t = 1; +pub const S_IWOTH: mode_t = 2; +pub const S_IROTH: mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; +pub const F_DUPFD_CLOEXEC: ::c_int = 37; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_GETLK: ::c_int = 14; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGEMT: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGSYS: ::c_int = 12; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; +pub const SIGUSR1: ::c_int = 16; +pub const SIGUSR2: ::c_int = 17; +pub const SIGPWR: ::c_int = 19; +pub const SIGWINCH: ::c_int = 20; +pub const SIGURG: ::c_int = 21; +pub const SIGPOLL: ::c_int = 22; +pub const SIGIO: ::c_int = SIGPOLL; +pub const SIGSTOP: ::c_int = 23; +pub const SIGTSTP: ::c_int = 24; +pub const SIGCONT: ::c_int = 25; +pub const SIGTTIN: ::c_int = 26; +pub const SIGTTOU: ::c_int = 27; +pub const SIGVTALRM: ::c_int = 28; +pub const SIGPROF: ::c_int = 29; +pub const SIGXCPU: ::c_int = 30; +pub const SIGXFSZ: ::c_int = 31; + +pub const WNOHANG: ::c_int = 0x40; +pub const WUNTRACED: ::c_int = 0x04; + +pub const WEXITED: ::c_int = 0x01; +pub const WTRAPPED: ::c_int = 0x02; +pub const WSTOPPED: ::c_int = WUNTRACED; +pub const WCONTINUED: ::c_int = 0x08; +pub const WNOWAIT: ::c_int = 0x80; + +pub const AT_FDCWD: ::c_int = 0xffd19553; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x1000; + +pub const P_PID: idtype_t = 0; +pub const P_PPID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; +pub const P_SID: idtype_t = 3; +pub const P_CID: idtype_t = 4; +pub const P_UID: idtype_t = 5; +pub const P_GID: idtype_t = 6; +pub const P_ALL: idtype_t = 7; +pub const P_LWPID: idtype_t = 8; +pub const P_TASKID: idtype_t = 9; +pub const P_PROJID: idtype_t = 10; +pub const P_POOLID: idtype_t = 11; +pub const P_ZONEID: idtype_t = 12; +pub const P_CTID: idtype_t = 13; +pub const P_CPUID: idtype_t = 14; +pub const P_PSETID: idtype_t = 15; + +pub const UTIME_OMIT: c_long = -2; +pub const UTIME_NOW: c_long = -1; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const MAP_FILE: ::c_int = 0; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_NORESERVE: ::c_int = 0x40; +pub const MAP_ANON: ::c_int = 0x0100; +pub const MAP_ANONYMOUS: ::c_int = 0x0100; +pub const MAP_RENAME: ::c_int = 0x20; +pub const MAP_ALIGN: ::c_int = 0x200; +pub const MAP_TEXT: ::c_int = 0x400; +pub const MAP_INITDATA: ::c_int = 0x800; +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const MS_SYNC: ::c_int = 0x0004; +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MS_INVALCURPROC: ::c_int = 0x0008; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const ENOMSG: ::c_int = 35; +pub const EIDRM: ::c_int = 36; +pub const ECHRNG: ::c_int = 37; +pub const EL2NSYNC: ::c_int = 38; +pub const EL3HLT: ::c_int = 39; +pub const EL3RST: ::c_int = 40; +pub const ELNRNG: ::c_int = 41; +pub const EUNATCH: ::c_int = 42; +pub const ENOCSI: ::c_int = 43; +pub const EL2HLT: ::c_int = 44; +pub const EDEADLK: ::c_int = 45; +pub const ENOLCK: ::c_int = 46; +pub const ECANCELED: ::c_int = 47; +pub const ENOTSUP: ::c_int = 48; +pub const EDQUOT: ::c_int = 49; +pub const EBADE: ::c_int = 50; +pub const EBADR: ::c_int = 51; +pub const EXFULL: ::c_int = 52; +pub const ENOANO: ::c_int = 53; +pub const EBADRQC: ::c_int = 54; +pub const EBADSLT: ::c_int = 55; +pub const EDEADLOCK: ::c_int = 56; +pub const EBFONT: ::c_int = 57; +pub const EOWNERDEAD: ::c_int = 58; +pub const ENOTRECOVERABLE: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const ELOCKUNMAPPED: ::c_int = 72; +pub const ENOTACTIVE: ::c_int = 73; +pub const EMULTIHOP: ::c_int = 74; +pub const EADI: ::c_int = 75; +pub const EBADMSG: ::c_int = 77; +pub const ENAMETOOLONG: ::c_int = 78; +pub const EOVERFLOW: ::c_int = 79; +pub const ENOTUNIQ: ::c_int = 80; +pub const EBADFD: ::c_int = 81; +pub const EREMCHG: ::c_int = 82; +pub const ELIBACC: ::c_int = 83; +pub const ELIBBAD: ::c_int = 84; +pub const ELIBSCN: ::c_int = 85; +pub const ELIBMAX: ::c_int = 86; +pub const ELIBEXEC: ::c_int = 87; +pub const EILSEQ: ::c_int = 88; +pub const ENOSYS: ::c_int = 89; +pub const ELOOP: ::c_int = 90; +pub const ERESTART: ::c_int = 91; +pub const ESTRPIPE: ::c_int = 92; +pub const ENOTEMPTY: ::c_int = 93; +pub const EUSERS: ::c_int = 94; +pub const ENOTSOCK: ::c_int = 95; +pub const EDESTADDRREQ: ::c_int = 96; +pub const EMSGSIZE: ::c_int = 97; +pub const EPROTOTYPE: ::c_int = 98; +pub const ENOPROTOOPT: ::c_int = 99; +pub const EPROTONOSUPPORT: ::c_int = 120; +pub const ESOCKTNOSUPPORT: ::c_int = 121; +pub const EOPNOTSUPP: ::c_int = 122; +pub const EPFNOSUPPORT: ::c_int = 123; +pub const EAFNOSUPPORT: ::c_int = 124; +pub const EADDRINUSE: ::c_int = 125; +pub const EADDRNOTAVAIL: ::c_int = 126; +pub const ENETDOWN: ::c_int = 127; +pub const ENETUNREACH: ::c_int = 128; +pub const ENETRESET: ::c_int = 129; +pub const ECONNABORTED: ::c_int = 130; +pub const ECONNRESET: ::c_int = 131; +pub const ENOBUFS: ::c_int = 132; +pub const EISCONN: ::c_int = 133; +pub const ENOTCONN: ::c_int = 134; +pub const ESHUTDOWN: ::c_int = 143; +pub const ETOOMANYREFS: ::c_int = 144; +pub const ETIMEDOUT: ::c_int = 145; +pub const ECONNREFUSED: ::c_int = 146; +pub const EHOSTDOWN: ::c_int = 147; +pub const EHOSTUNREACH: ::c_int = 148; +pub const EWOULDBLOCK: ::c_int = EAGAIN; +pub const EALREADY: ::c_int = 149; +pub const EINPROGRESS: ::c_int = 150; +pub const ESTALE: ::c_int = 151; + +pub const EAI_AGAIN: ::c_int = 2; +pub const EAI_BADFLAGS: ::c_int = 3; +pub const EAI_FAIL: ::c_int = 4; +pub const EAI_FAMILY: ::c_int = 5; +pub const EAI_MEMORY: ::c_int = 6; +pub const EAI_NODATA: ::c_int = 7; +pub const EAI_NONAME: ::c_int = 8; +pub const EAI_SERVICE: ::c_int = 9; +pub const EAI_SOCKTYPE: ::c_int = 10; +pub const EAI_SYSTEM: ::c_int = 11; +pub const EAI_OVERFLOW: ::c_int = 12; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; + +pub const SIGTRAP: ::c_int = 5; + +pub const GLOB_APPEND: ::c_int = 32; +pub const GLOB_DOOFFS: ::c_int = 16; +pub const GLOB_ERR: ::c_int = 1; +pub const GLOB_MARK: ::c_int = 2; +pub const GLOB_NOCHECK: ::c_int = 8; +pub const GLOB_NOSORT: ::c_int = 4; +pub const GLOB_NOESCAPE: ::c_int = 64; + +pub const GLOB_NOSPACE: ::c_int = -2; +pub const GLOB_ABORTED: ::c_int = -1; +pub const GLOB_NOMATCH: ::c_int = -3; + +pub const POLLIN: ::c_short = 0x1; +pub const POLLPRI: ::c_short = 0x2; +pub const POLLOUT: ::c_short = 0x4; +pub const POLLERR: ::c_short = 0x8; +pub const POLLHUP: ::c_short = 0x10; +pub const POLLNVAL: ::c_short = 0x20; +pub const POLLNORM: ::c_short = 0x0040; +pub const POLLRDNORM: ::c_short = 0x0040; +pub const POLLWRNORM: ::c_short = 0x4; /* POLLOUT */ +pub const POLLRDBAND: ::c_short = 0x0080; +pub const POLLWRBAND: ::c_short = 0x0100; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 0x40; +pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; +pub const PTHREAD_PROCESS_PRIVATE: ::c_ushort = 0; +pub const PTHREAD_STACK_MIN: ::size_t = 4096; + +pub const SIGSTKSZ: ::size_t = 8192; + +// https://illumos.org/man/3c/clock_gettime +// https://github.com/illumos/illumos-gate/ +// blob/HEAD/usr/src/lib/libc/amd64/sys/__clock_gettime.s +// clock_gettime(3c) doesn't seem to accept anything other than CLOCK_REALTIME +// or __CLOCK_REALTIME0 +// +// https://github.com/illumos/illumos-gate/ +// blob/HEAD/usr/src/uts/common/sys/time_impl.h +// Confusing! CLOCK_HIGHRES==CLOCK_MONOTONIC==4 +// __CLOCK_REALTIME0==0 is an obsoleted version of CLOCK_REALTIME==3 +pub const CLOCK_REALTIME: ::clockid_t = 3; +pub const CLOCK_MONOTONIC: ::clockid_t = 4; +pub const TIMER_RELTIME: ::c_int = 0; +pub const TIMER_ABSTIME: ::c_int = 1; + +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_NOFILE: ::c_int = 5; +pub const RLIMIT_VMEM: ::c_int = 6; +pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM; + +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: rlim_t = 7; +pub const RLIM_INFINITY: rlim_t = 0x7fffffff; + +pub const RUSAGE_SELF: ::c_int = 0; +pub const RUSAGE_CHILDREN: ::c_int = -1; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_FREE: ::c_int = 5; + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_UNIX: ::c_int = 1; +pub const AF_LOCAL: ::c_int = 0; +pub const AF_FILE: ::c_int = 0; +pub const AF_INET: ::c_int = 2; +pub const AF_IMPLINK: ::c_int = 3; +pub const AF_PUP: ::c_int = 4; +pub const AF_CHAOS: ::c_int = 5; +pub const AF_NS: ::c_int = 6; +pub const AF_NBS: ::c_int = 7; +pub const AF_ECMA: ::c_int = 8; +pub const AF_DATAKIT: ::c_int = 9; +pub const AF_CCITT: ::c_int = 10; +pub const AF_SNA: ::c_int = 11; +pub const AF_DECnet: ::c_int = 12; +pub const AF_DLI: ::c_int = 13; +pub const AF_LAT: ::c_int = 14; +pub const AF_HYLINK: ::c_int = 15; +pub const AF_APPLETALK: ::c_int = 16; +pub const AF_NIT: ::c_int = 17; +pub const AF_802: ::c_int = 18; +pub const AF_OSI: ::c_int = 19; +pub const AF_X25: ::c_int = 20; +pub const AF_OSINET: ::c_int = 21; +pub const AF_GOSIP: ::c_int = 22; +pub const AF_IPX: ::c_int = 23; +pub const AF_ROUTE: ::c_int = 24; +pub const AF_LINK: ::c_int = 25; +pub const AF_INET6: ::c_int = 26; +pub const AF_KEY: ::c_int = 27; +pub const AF_NCA: ::c_int = 28; +pub const AF_POLICY: ::c_int = 29; +pub const AF_INET_OFFLOAD: ::c_int = 30; +pub const AF_TRILL: ::c_int = 31; +pub const AF_PACKET: ::c_int = 32; +pub const AF_LX_NETLINK: ::c_int = 33; + +pub const SOCK_DGRAM: ::c_int = 1; +pub const SOCK_STREAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 4; +pub const SOCK_RDM: ::c_int = 5; +pub const SOCK_SEQPACKET: ::c_int = 6; +pub const IP_MULTICAST_IF: ::c_int = 16; +pub const IP_MULTICAST_TTL: ::c_int = 17; +pub const IP_MULTICAST_LOOP: ::c_int = 18; +pub const IP_TTL: ::c_int = 4; +pub const IP_HDRINCL: ::c_int = 2; +pub const IP_ADD_MEMBERSHIP: ::c_int = 19; +pub const IP_DROP_MEMBERSHIP: ::c_int = 20; +pub const IPV6_JOIN_GROUP: ::c_int = 9; +pub const IPV6_LEAVE_GROUP: ::c_int = 10; + +pub const TCP_NODELAY: ::c_int = 1; +pub const TCP_KEEPIDLE: ::c_int = 34; +pub const SOL_SOCKET: ::c_int = 0xffff; +pub const SO_DEBUG: ::c_int = 0x01; +pub const SO_ACCEPTCONN: ::c_int = 0x0002; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_TIMESTAMP: ::c_int = 0x1013; + +pub const SCM_RIGHTS: ::c_int = 0x1010; +pub const SCM_UCRED: ::c_int = 0x1012; +pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; + +pub const MSG_OOB: ::c_int = 0x1; +pub const MSG_PEEK: ::c_int = 0x2; +pub const MSG_DONTROUTE: ::c_int = 0x4; +pub const MSG_EOR: ::c_int = 0x8; +pub const MSG_CTRUNC: ::c_int = 0x10; +pub const MSG_TRUNC: ::c_int = 0x20; +pub const MSG_WAITALL: ::c_int = 0x40; +pub const MSG_DONTWAIT: ::c_int = 0x80; +pub const MSG_NOTIFICATION: ::c_int = 0x100; +pub const MSG_NOSIGNAL: ::c_int = 0x200; +pub const MSG_DUPCTRL: ::c_int = 0x800; +pub const MSG_XPG4_2: ::c_int = 0x8000; +pub const MSG_MAXIOVLEN: ::c_int = 16; + +// https://docs.oracle.com/cd/E23824_01/html/821-1475/if-7p.html +pub const IFF_UP: ::c_int = 0x0000000001; // Address is up +pub const IFF_BROADCAST: ::c_int = 0x0000000002; // Broadcast address valid +pub const IFF_DEBUG: ::c_int = 0x0000000004; // Turn on debugging +pub const IFF_LOOPBACK: ::c_int = 0x0000000008; // Loopback net +pub const IFF_POINTOPOINT: ::c_int = 0x0000000010; // Interface is p-to-p +pub const IFF_NOTRAILERS: ::c_int = 0x0000000020; // Avoid use of trailers +pub const IFF_RUNNING: ::c_int = 0x0000000040; // Resources allocated +pub const IFF_NOARP: ::c_int = 0x0000000080; // No address res. protocol +pub const IFF_PROMISC: ::c_int = 0x0000000100; // Receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x0000000200; // Receive all multicast pkts +pub const IFF_INTELLIGENT: ::c_int = 0x0000000400; // Protocol code on board +pub const IFF_MULTICAST: ::c_int = 0x0000000800; // Supports multicast + +// Multicast using broadcst. add. +pub const IFF_MULTI_BCAST: ::c_int = 0x0000001000; +pub const IFF_UNNUMBERED: ::c_int = 0x0000002000; // Non-unique address +pub const IFF_DHCPRUNNING: ::c_int = 0x0000004000; // DHCP controls interface +pub const IFF_PRIVATE: ::c_int = 0x0000008000; // Do not advertise +pub const IFF_NOXMIT: ::c_int = 0x0000010000; // Do not transmit pkts + +// No address - just on-link subnet +pub const IFF_NOLOCAL: ::c_int = 0x0000020000; +pub const IFF_DEPRECATED: ::c_int = 0x0000040000; // Address is deprecated +pub const IFF_ADDRCONF: ::c_int = 0x0000080000; // Addr. from stateless addrconf +pub const IFF_ROUTER: ::c_int = 0x0000100000; // Router on interface +pub const IFF_NONUD: ::c_int = 0x0000200000; // No NUD on interface +pub const IFF_ANYCAST: ::c_int = 0x0000400000; // Anycast address +pub const IFF_NORTEXCH: ::c_int = 0x0000800000; // Don't xchange rout. info +pub const IFF_IPV4: ::c_int = 0x0001000000; // IPv4 interface +pub const IFF_IPV6: ::c_int = 0x0002000000; // IPv6 interface +pub const IFF_NOFAILOVER: ::c_int = 0x0008000000; // in.mpathd test address +pub const IFF_FAILED: ::c_int = 0x0010000000; // Interface has failed +pub const IFF_STANDBY: ::c_int = 0x0020000000; // Interface is a hot-spare +pub const IFF_INACTIVE: ::c_int = 0x0040000000; // Functioning but not used +pub const IFF_OFFLINE: ::c_int = 0x0080000000; // Interface is offline + // If CoS marking is supported +pub const IFF_COS_ENABLED: ::c_longlong = 0x0200000000; +pub const IFF_PREFERRED: ::c_longlong = 0x0400000000; // Prefer as source addr. +pub const IFF_TEMPORARY: ::c_longlong = 0x0800000000; // RFC3041 +pub const IFF_FIXEDMTU: ::c_longlong = 0x1000000000; // MTU set with SIOCSLIFMTU +pub const IFF_VIRTUAL: ::c_longlong = 0x2000000000; // Cannot send/receive pkts +pub const IFF_DUPLICATE: ::c_longlong = 0x4000000000; // Local address in use +pub const IFF_IPMP: ::c_longlong = 0x8000000000; // IPMP IP interface + +// sys/ipc.h: +pub const IPC_ALLOC: ::c_int = 0x8000; +pub const IPC_CREAT: ::c_int = 0x200; +pub const IPC_EXCL: ::c_int = 0x400; +pub const IPC_NOWAIT: ::c_int = 0x800; +pub const IPC_PRIVATE: key_t = 0; +pub const IPC_RMID: ::c_int = 10; +pub const IPC_SET: ::c_int = 11; +pub const IPC_SEAT: ::c_int = 12; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; + +pub const F_RDLCK: ::c_short = 1; +pub const F_WRLCK: ::c_short = 2; +pub const F_UNLCK: ::c_short = 3; + +pub const O_SYNC: ::c_int = 16; +pub const O_NONBLOCK: ::c_int = 128; + +pub const IPPROTO_RAW: ::c_int = 255; + +pub const _PC_LINK_MAX: ::c_int = 1; +pub const _PC_MAX_CANON: ::c_int = 2; +pub const _PC_MAX_INPUT: ::c_int = 3; +pub const _PC_NAME_MAX: ::c_int = 4; +pub const _PC_PATH_MAX: ::c_int = 5; +pub const _PC_PIPE_BUF: ::c_int = 6; +pub const _PC_NO_TRUNC: ::c_int = 7; +pub const _PC_VDISABLE: ::c_int = 8; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 9; +pub const _PC_ASYNC_IO: ::c_int = 10; +pub const _PC_PRIO_IO: ::c_int = 11; +pub const _PC_SYNC_IO: ::c_int = 12; +pub const _PC_ALLOC_SIZE_MIN: ::c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16; +pub const _PC_REC_XFER_ALIGN: ::c_int = 17; +pub const _PC_SYMLINK_MAX: ::c_int = 18; +pub const _PC_2_SYMLINKS: ::c_int = 19; +pub const _PC_ACL_ENABLED: ::c_int = 20; +pub const _PC_MIN_HOLE_SIZE: ::c_int = 21; +pub const _PC_CASE_BEHAVIOR: ::c_int = 22; +pub const _PC_SATTR_ENABLED: ::c_int = 23; +pub const _PC_SATTR_EXISTS: ::c_int = 24; +pub const _PC_ACCESS_FILTERING: ::c_int = 25; +pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 26; +pub const _PC_FILESIZEBITS: ::c_int = 67; +pub const _PC_XATTR_ENABLED: ::c_int = 100; +pub const _PC_LAST: ::c_int = 101; +pub const _PC_XATTR_EXISTS: ::c_int = 101; + +pub const _SC_ARG_MAX: ::c_int = 1; +pub const _SC_CHILD_MAX: ::c_int = 2; +pub const _SC_CLK_TCK: ::c_int = 3; +pub const _SC_NGROUPS_MAX: ::c_int = 4; +pub const _SC_OPEN_MAX: ::c_int = 5; +pub const _SC_JOB_CONTROL: ::c_int = 6; +pub const _SC_SAVED_IDS: ::c_int = 7; +pub const _SC_VERSION: ::c_int = 8; +pub const _SC_PASS_MAX: ::c_int = 9; +pub const _SC_LOGNAME_MAX: ::c_int = 10; +pub const _SC_PAGESIZE: ::c_int = 11; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_XOPEN_VERSION: ::c_int = 12; +pub const _SC_NPROCESSORS_CONF: ::c_int = 14; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 15; +pub const _SC_STREAM_MAX: ::c_int = 16; +pub const _SC_TZNAME_MAX: ::c_int = 17; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 18; +pub const _SC_AIO_MAX: ::c_int = 19; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 20; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 21; +pub const _SC_DELAYTIMER_MAX: ::c_int = 22; +pub const _SC_FSYNC: ::c_int = 23; +pub const _SC_MAPPED_FILES: ::c_int = 24; +pub const _SC_MEMLOCK: ::c_int = 25; +pub const _SC_MEMLOCK_RANGE: ::c_int = 26; +pub const _SC_MEMORY_PROTECTION: ::c_int = 27; +pub const _SC_MESSAGE_PASSING: ::c_int = 28; +pub const _SC_MQ_OPEN_MAX: ::c_int = 29; +pub const _SC_MQ_PRIO_MAX: ::c_int = 30; +pub const _SC_PRIORITIZED_IO: ::c_int = 31; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 32; +pub const _SC_REALTIME_SIGNALS: ::c_int = 33; +pub const _SC_RTSIG_MAX: ::c_int = 34; +pub const _SC_SEMAPHORES: ::c_int = 35; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 36; +pub const _SC_SEM_VALUE_MAX: ::c_int = 37; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 38; +pub const _SC_SIGQUEUE_MAX: ::c_int = 39; +pub const _SC_SIGRT_MIN: ::c_int = 40; +pub const _SC_SIGRT_MAX: ::c_int = 41; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 42; +pub const _SC_TIMERS: ::c_int = 43; +pub const _SC_TIMER_MAX: ::c_int = 44; +pub const _SC_2_C_BIND: ::c_int = 45; +pub const _SC_2_C_DEV: ::c_int = 46; +pub const _SC_2_C_VERSION: ::c_int = 47; +pub const _SC_2_FORT_DEV: ::c_int = 48; +pub const _SC_2_FORT_RUN: ::c_int = 49; +pub const _SC_2_LOCALEDEF: ::c_int = 50; +pub const _SC_2_SW_DEV: ::c_int = 51; +pub const _SC_2_UPE: ::c_int = 52; +pub const _SC_2_VERSION: ::c_int = 53; +pub const _SC_BC_BASE_MAX: ::c_int = 54; +pub const _SC_BC_DIM_MAX: ::c_int = 55; +pub const _SC_BC_SCALE_MAX: ::c_int = 56; +pub const _SC_BC_STRING_MAX: ::c_int = 57; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 58; +pub const _SC_EXPR_NEST_MAX: ::c_int = 59; +pub const _SC_LINE_MAX: ::c_int = 60; +pub const _SC_RE_DUP_MAX: ::c_int = 61; +pub const _SC_XOPEN_CRYPT: ::c_int = 62; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 63; +pub const _SC_XOPEN_SHM: ::c_int = 64; +pub const _SC_2_CHAR_TERM: ::c_int = 66; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 67; +pub const _SC_ATEXIT_MAX: ::c_int = 76; +pub const _SC_IOV_MAX: ::c_int = 77; +pub const _SC_XOPEN_UNIX: ::c_int = 78; +pub const _SC_T_IOV_MAX: ::c_int = 79; +pub const _SC_PHYS_PAGES: ::c_int = 500; +pub const _SC_AVPHYS_PAGES: ::c_int = 501; +pub const _SC_COHER_BLKSZ: ::c_int = 503; +pub const _SC_SPLIT_CACHE: ::c_int = 504; +pub const _SC_ICACHE_SZ: ::c_int = 505; +pub const _SC_DCACHE_SZ: ::c_int = 506; +pub const _SC_ICACHE_LINESZ: ::c_int = 507; +pub const _SC_DCACHE_LINESZ: ::c_int = 508; +pub const _SC_ICACHE_BLKSZ: ::c_int = 509; +pub const _SC_DCACHE_BLKSZ: ::c_int = 510; +pub const _SC_DCACHE_TBLKSZ: ::c_int = 511; +pub const _SC_ICACHE_ASSOC: ::c_int = 512; +pub const _SC_DCACHE_ASSOC: ::c_int = 513; +pub const _SC_MAXPID: ::c_int = 514; +pub const _SC_STACK_PROT: ::c_int = 515; +pub const _SC_NPROCESSORS_MAX: ::c_int = 516; +pub const _SC_CPUID_MAX: ::c_int = 517; +pub const _SC_EPHID_MAX: ::c_int = 518; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 568; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 569; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 570; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 571; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 572; +pub const _SC_THREAD_STACK_MIN: ::c_int = 573; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 574; +pub const _SC_TTY_NAME_MAX: ::c_int = 575; +pub const _SC_THREADS: ::c_int = 576; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 577; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 578; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 579; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 580; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 581; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 582; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 583; +pub const _SC_XOPEN_LEGACY: ::c_int = 717; +pub const _SC_XOPEN_REALTIME: ::c_int = 718; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 719; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 720; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 721; +pub const _SC_XBS5_LP64_OFF64: ::c_int = 722; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 723; +pub const _SC_2_PBS: ::c_int = 724; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 725; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 726; +pub const _SC_2_PBS_LOCATE: ::c_int = 728; +pub const _SC_2_PBS_MESSAGE: ::c_int = 729; +pub const _SC_2_PBS_TRACK: ::c_int = 730; +pub const _SC_ADVISORY_INFO: ::c_int = 731; +pub const _SC_BARRIERS: ::c_int = 732; +pub const _SC_CLOCK_SELECTION: ::c_int = 733; +pub const _SC_CPUTIME: ::c_int = 734; +pub const _SC_HOST_NAME_MAX: ::c_int = 735; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 736; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 737; +pub const _SC_REGEXP: ::c_int = 738; +pub const _SC_SHELL: ::c_int = 739; +pub const _SC_SPAWN: ::c_int = 740; +pub const _SC_SPIN_LOCKS: ::c_int = 741; +pub const _SC_SPORADIC_SERVER: ::c_int = 742; +pub const _SC_SS_REPL_MAX: ::c_int = 743; +pub const _SC_SYMLOOP_MAX: ::c_int = 744; +pub const _SC_THREAD_CPUTIME: ::c_int = 745; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 746; +pub const _SC_TIMEOUTS: ::c_int = 747; +pub const _SC_TRACE: ::c_int = 748; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 749; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 750; +pub const _SC_TRACE_INHERIT: ::c_int = 751; +pub const _SC_TRACE_LOG: ::c_int = 752; +pub const _SC_TRACE_NAME_MAX: ::c_int = 753; +pub const _SC_TRACE_SYS_MAX: ::c_int = 754; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 755; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 756; +pub const _SC_V6_ILP32_OFF32: ::c_int = 757; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = 758; +pub const _SC_V6_LP64_OFF64: ::c_int = 759; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 760; +pub const _SC_XOPEN_STREAMS: ::c_int = 761; +pub const _SC_IPV6: ::c_int = 762; +pub const _SC_RAW_SOCKETS: ::c_int = 763; + +pub const _MUTEX_MAGIC: u16 = 0x4d58; // MX +pub const _COND_MAGIC: u16 = 0x4356; // CV +pub const _RWL_MAGIC: u16 = 0x5257; // RW + +pub const NCCS: usize = 19; + +pub const LOG_CRON: ::c_int = 15 << 3; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __pthread_mutex_flag1: 0, + __pthread_mutex_flag2: 0, + __pthread_mutex_ceiling: 0, + __pthread_mutex_type: PTHREAD_PROCESS_PRIVATE, + __pthread_mutex_magic: _MUTEX_MAGIC, + __pthread_mutex_lock: 0, + __pthread_mutex_data: 0, +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __pthread_cond_flag: [0; 4], + __pthread_cond_type: PTHREAD_PROCESS_PRIVATE, + __pthread_cond_magic: _COND_MAGIC, + __pthread_cond_data: 0, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __pthread_rwlock_readers: 0, + __pthread_rwlock_type: PTHREAD_PROCESS_PRIVATE, + __pthread_rwlock_magic: _RWL_MAGIC, + __pthread_rwlock_mutex: PTHREAD_MUTEX_INITIALIZER, + __pthread_rwlock_readercv: PTHREAD_COND_INITIALIZER, + __pthread_rwlock_writercv: PTHREAD_COND_INITIALIZER, +}; +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 4; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; + +pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void; +pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void; +pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void; +pub const RTLD_PROBE: *mut ::c_void = -4isize as *mut ::c_void; + +pub const RTLD_LAZY: ::c_int = 0x1; +pub const RTLD_NOW: ::c_int = 0x2; +pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_LOCAL: ::c_int = 0x0; +pub const RTLD_PARENT: ::c_int = 0x200; +pub const RTLD_GROUP: ::c_int = 0x400; +pub const RTLD_WORLD: ::c_int = 0x800; +pub const RTLD_NODELETE: ::c_int = 0x1000; +pub const RTLD_FIRST: ::c_int = 0x2000; +pub const RTLD_CONFGEN: ::c_int = 0x10000; + +pub const PORT_SOURCE_AIO: ::c_int = 1; +pub const PORT_SOURCE_TIMER: ::c_int = 2; +pub const PORT_SOURCE_USER: ::c_int = 3; +pub const PORT_SOURCE_FD: ::c_int = 4; +pub const PORT_SOURCE_ALERT: ::c_int = 5; +pub const PORT_SOURCE_MQ: ::c_int = 6; +pub const PORT_SOURCE_FILE: ::c_int = 7; +pub const PORT_SOURCE_POSTWAIT: ::c_int = 8; +pub const PORT_SOURCE_SIGNAL: ::c_int = 9; + +pub const NONROOT_USR: ::c_short = 2; +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_PADSIZE: usize = 5; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 257; +pub const EMPTY: ::c_short = 0; +pub const RUN_LVL: ::c_short = 1; +pub const BOOT_TIME: ::c_short = 2; +pub const OLD_TIME: ::c_short = 3; +pub const NEW_TIME: ::c_short = 4; +pub const INIT_PROCESS: ::c_short = 5; +pub const LOGIN_PROCESS: ::c_short = 6; +pub const USER_PROCESS: ::c_short = 7; +pub const DEAD_PROCESS: ::c_short = 8; +pub const ACCOUNTING: ::c_short = 9; +pub const DOWN_TIME: ::c_short = 10; + +const _TIOC: ::c_int = ('T' as i32) << 8; +const tIOC: ::c_int = ('t' as i32) << 8; +pub const TCGETA: ::c_int = (_TIOC | 1); +pub const TCSETA: ::c_int = (_TIOC | 2); +pub const TCSETAW: ::c_int = (_TIOC | 3); +pub const TCSETAF: ::c_int = (_TIOC | 4); +pub const TCSBRK: ::c_int = (_TIOC | 5); +pub const TCXONC: ::c_int = (_TIOC | 6); +pub const TCFLSH: ::c_int = (_TIOC | 7); +pub const TCDSET: ::c_int = (_TIOC | 32); +pub const TCGETS: ::c_int = (_TIOC | 13); +pub const TCSETS: ::c_int = (_TIOC | 14); +pub const TCSANOW: ::c_int = (_TIOC | 14); +pub const TCSETSW: ::c_int = (_TIOC | 15); +pub const TCSADRAIN: ::c_int = (_TIOC | 15); +pub const TCSETSF: ::c_int = (_TIOC | 16); +pub const TCSAFLUSH: ::c_int = (_TIOC | 16); +pub const TCIFLUSH: ::c_int = 0; +pub const TCOFLUSH: ::c_int = 1; +pub const TCIOFLUSH: ::c_int = 2; +pub const TCOOFF: ::c_int = 0; +pub const TCOON: ::c_int = 1; +pub const TCIOFF: ::c_int = 2; +pub const TCION: ::c_int = 3; +pub const TIOC: ::c_int = _TIOC; +pub const TIOCKBON: ::c_int = (_TIOC | 8); +pub const TIOCKBOF: ::c_int = (_TIOC | 9); +pub const TIOCGWINSZ: ::c_int = (_TIOC | 104); +pub const TIOCSWINSZ: ::c_int = (_TIOC | 103); +pub const TIOCGSOFTCAR: ::c_int = (_TIOC | 105); +pub const TIOCSSOFTCAR: ::c_int = (_TIOC | 106); +pub const TIOCSETLD: ::c_int = (_TIOC | 123); +pub const TIOCGETLD: ::c_int = (_TIOC | 124); +pub const TIOCGPPS: ::c_int = (_TIOC | 125); +pub const TIOCSPPS: ::c_int = (_TIOC | 126); +pub const TIOCGPPSEV: ::c_int = (_TIOC | 127); +pub const TIOCGETD: ::c_int = (tIOC | 0); +pub const TIOCSETD: ::c_int = (tIOC | 1); +pub const TIOCHPCL: ::c_int = (tIOC | 2); +pub const TIOCGETP: ::c_int = (tIOC | 8); +pub const TIOCSETP: ::c_int = (tIOC | 9); +pub const TIOCSETN: ::c_int = (tIOC | 10); +pub const TIOCEXCL: ::c_int = (tIOC | 13); +pub const TIOCNXCL: ::c_int = (tIOC | 14); +pub const TIOCFLUSH: ::c_int = (tIOC | 16); +pub const TIOCSETC: ::c_int = (tIOC | 17); +pub const TIOCGETC: ::c_int = (tIOC | 18); +pub const TIOCLBIS: ::c_int = (tIOC | 127); +pub const TIOCLBIC: ::c_int = (tIOC | 126); +pub const TIOCLSET: ::c_int = (tIOC | 125); +pub const TIOCLGET: ::c_int = (tIOC | 124); +pub const TIOCSBRK: ::c_int = (tIOC | 123); +pub const TIOCCBRK: ::c_int = (tIOC | 122); +pub const TIOCSDTR: ::c_int = (tIOC | 121); +pub const TIOCCDTR: ::c_int = (tIOC | 120); +pub const TIOCSLTC: ::c_int = (tIOC | 117); +pub const TIOCGLTC: ::c_int = (tIOC | 116); +pub const TIOCOUTQ: ::c_int = (tIOC | 115); +pub const TIOCNOTTY: ::c_int = (tIOC | 113); +pub const TIOCSCTTY: ::c_int = (tIOC | 132); +pub const TIOCSTOP: ::c_int = (tIOC | 111); +pub const TIOCSTART: ::c_int = (tIOC | 110); +pub const TIOCSILOOP: ::c_int = (tIOC | 109); +pub const TIOCCILOOP: ::c_int = (tIOC | 108); +pub const TIOCGPGRP: ::c_int = (tIOC | 20); +pub const TIOCSPGRP: ::c_int = (tIOC | 21); +pub const TIOCGSID: ::c_int = (tIOC | 22); +pub const TIOCSTI: ::c_int = (tIOC | 23); +pub const TIOCMSET: ::c_int = (tIOC | 26); +pub const TIOCMBIS: ::c_int = (tIOC | 27); +pub const TIOCMBIC: ::c_int = (tIOC | 28); +pub const TIOCMGET: ::c_int = (tIOC | 29); +pub const TIOCREMOTE: ::c_int = (tIOC | 30); +pub const TIOCSIGNAL: ::c_int = (tIOC | 31); + +pub const EPOLLIN: ::c_int = 0x1; +pub const EPOLLPRI: ::c_int = 0x2; +pub const EPOLLOUT: ::c_int = 0x4; +pub const EPOLLRDNORM: ::c_int = 0x40; +pub const EPOLLRDBAND: ::c_int = 0x80; +pub const EPOLLWRNORM: ::c_int = 0x100; +pub const EPOLLWRBAND: ::c_int = 0x200; +pub const EPOLLMSG: ::c_int = 0x400; +pub const EPOLLERR: ::c_int = 0x8; +pub const EPOLLHUP: ::c_int = 0x10; +pub const EPOLLET: ::c_int = 0x80000000; +pub const EPOLLRDHUP: ::c_int = 0x2000; +pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; +pub const EPOLLONESHOT: ::c_int = 0x40000000; +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; +pub const EPOLL_CTL_ADD: ::c_int = 1; +pub const EPOLL_CTL_MOD: ::c_int = 3; +pub const EPOLL_CTL_DEL: ::c_int = 2; + +/* termios */ +pub const B0: speed_t = 0; +pub const B50: speed_t = 1; +pub const B75: speed_t = 2; +pub const B110: speed_t = 3; +pub const B134: speed_t = 4; +pub const B150: speed_t = 5; +pub const B200: speed_t = 6; +pub const B300: speed_t = 7; +pub const B600: speed_t = 8; +pub const B1200: speed_t = 9; +pub const B1800: speed_t = 10; +pub const B2400: speed_t = 11; +pub const B4800: speed_t = 12; +pub const B9600: speed_t = 13; +pub const B19200: speed_t = 14; +pub const B38400: speed_t = 15; +pub const B57600: speed_t = 16; +pub const B76800: speed_t = 17; +pub const B115200: speed_t = 18; +pub const B153600: speed_t = 19; +pub const B230400: speed_t = 20; +pub const B307200: speed_t = 21; +pub const B460800: speed_t = 22; +pub const B921600: speed_t = 23; +pub const CSTART: ::tcflag_t = 021; +pub const CSTOP: ::tcflag_t = 023; +pub const CSWTCH: ::tcflag_t = 032; +pub const CSIZE: ::tcflag_t = 0o000060; +pub const CS5: ::tcflag_t = 0; +pub const CS6: ::tcflag_t = 0o000020; +pub const CS7: ::tcflag_t = 0o000040; +pub const CS8: ::tcflag_t = 0o000060; +pub const CSTOPB: ::tcflag_t = 0o000100; +pub const ECHO: ::tcflag_t = 0o000010; +pub const ECHOE: ::tcflag_t = 0o000020; +pub const ECHOK: ::tcflag_t = 0o000040; +pub const ECHONL: ::tcflag_t = 0o000100; +pub const ECHOCTL: ::tcflag_t = 0o001000; +pub const ECHOPRT: ::tcflag_t = 0o002000; +pub const ECHOKE: ::tcflag_t = 0o004000; +pub const EXTPROC: ::tcflag_t = 0o200000; +pub const IGNBRK: ::tcflag_t = 0o000001; +pub const BRKINT: ::tcflag_t = 0o000002; +pub const IGNPAR: ::tcflag_t = 0o000004; +pub const PARMRK: ::tcflag_t = 0o000010; +pub const INPCK: ::tcflag_t = 0o000020; +pub const ISTRIP: ::tcflag_t = 0o000040; +pub const INLCR: ::tcflag_t = 0o000100; +pub const IGNCR: ::tcflag_t = 0o000200; +pub const ICRNL: ::tcflag_t = 0o000400; +pub const IXON: ::tcflag_t = 0o002000; +pub const IXOFF: ::tcflag_t = 0o010000; +pub const IXANY: ::tcflag_t = 0o004000; +pub const IMAXBEL: ::tcflag_t = 0o020000; +pub const OPOST: ::tcflag_t = 0o000001; +pub const ONLCR: ::tcflag_t = 0o000004; +pub const OCRNL: ::tcflag_t = 0o000010; +pub const ONOCR: ::tcflag_t = 0o000020; +pub const ONLRET: ::tcflag_t = 0o000040; +pub const CREAD: ::tcflag_t = 0o000200; +pub const PARENB: ::tcflag_t = 0o000400; +pub const PARODD: ::tcflag_t = 0o001000; +pub const HUPCL: ::tcflag_t = 0o002000; +pub const CLOCAL: ::tcflag_t = 0o004000; +pub const CRTSCTS: ::tcflag_t = 0o20000000000; +pub const ISIG: ::tcflag_t = 0o000001; +pub const ICANON: ::tcflag_t = 0o000002; +pub const IEXTEN: ::tcflag_t = 0o100000; +pub const TOSTOP: ::tcflag_t = 0o000400; +pub const FLUSHO: ::tcflag_t = 0o020000; +pub const PENDIN: ::tcflag_t = 0o040000; +pub const NOFLSH: ::tcflag_t = 0o000200; +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VEOF: usize = 4; +pub const VEOL: usize = 5; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const VTIME: usize = 5; +pub const VSWTCH: usize = 7; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; +pub const VDSUSP: usize = 11; +pub const VREPRINT: usize = 12; +pub const VDISCARD: usize = 13; +pub const VWERASE: usize = 14; +pub const VLNEXT: usize = 15; +pub const VSTATUS: usize = 16; +pub const VERASE2: usize = 17; + +// 3SOCKET flags +pub const SOCK_CLOEXEC: ::c_int = 0x080000; +pub const SOCK_NONBLOCK: ::c_int = 0x100000; +pub const SOCK_NDELAY: ::c_int = 0x200000; + +f! { + pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { + let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); + return + } + + pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0 + } + + pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { + let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] |= 1 << (fd % bits); + return + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } + + pub fn WIFEXITED(status: ::c_int) -> bool { + (status & 0xFF) == 0 + } + + pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status >> 8) & 0xFF + } + + pub fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0x7F + } + + pub fn WIFCONTINUED(status: ::c_int) -> bool { + (status & 0xffff) == 0xffff + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + (status & 0xff00) >> 8 + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + ((status & 0xff) > 0) && (status & 0xff00 == 0) + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + ((status & 0xff) == 0x7f) && ((status & 0xff00) != 0) + } + + pub fn WCOREDUMP(status: ::c_int) -> bool { + (status & 0x80) != 0 + } +} + +extern "C" { + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + pub fn sem_init( + sem: *mut sem_t, + pshared: ::c_int, + value: ::c_uint, + ) -> ::c_int; + + pub fn abs(i: ::c_int) -> ::c_int; + pub fn acct(filename: *const ::c_char) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + pub fn settimeofday(tp: *const ::timeval, tz: *const ::c_void) -> ::c_int; + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; + pub fn freeifaddrs(ifa: *mut ::ifaddrs); + + pub fn stack_getbounds(sp: *mut ::stack_t) -> ::c_int; + pub fn mincore( + addr: *const ::c_void, + len: ::size_t, + vec: *mut c_char, + ) -> ::c_int; + pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; + pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int; + pub fn ioctl(fildes: ::c_int, request: ::c_int, ...) -> ::c_int; + pub fn mprotect( + addr: *const ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn ___errno() -> *mut ::c_int; + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_nanosleep( + clk_id: ::clockid_t, + flags: ::c_int, + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + pub fn clock_settime( + clk_id: ::clockid_t, + tp: *const ::timespec, + ) -> ::c_int; + pub fn getnameinfo( + sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::socklen_t, + serv: *mut ::c_char, + sevlen: ::socklen_t, + flags: ::c_int, + ) -> ::c_int; + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + pub fn fdatasync(fd: ::c_int) -> ::c_int; + pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) + -> *mut ::c_char; + pub fn duplocale(base: ::locale_t) -> ::locale_t; + pub fn freelocale(loc: ::locale_t); + pub fn newlocale( + mask: ::c_int, + locale: *const ::c_char, + base: ::locale_t, + ) -> ::locale_t; + pub fn uselocale(loc: ::locale_t) -> ::locale_t; + pub fn getprogname() -> *const ::c_char; + pub fn setprogname(name: *const ::c_char); + pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; + pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; + pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) + -> ::c_int; + + pub fn mknodat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + dev: dev_t, + ) -> ::c_int; + pub fn mkfifoat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + ) -> ::c_int; + pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> ::c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + pub fn sem_timedwait( + sem: *mut sem_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut ::siginfo_t, + options: ::c_int, + ) -> ::c_int; + + pub fn glob( + pattern: *const ::c_char, + flags: ::c_int, + errfunc: ::Option< + extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int, + >, + pglob: *mut ::glob_t, + ) -> ::c_int; + + pub fn globfree(pglob: *mut ::glob_t); + + pub fn posix_madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn shmat( + shmid: ::c_int, + shmaddr: *const ::c_void, + shmflg: ::c_int, + ) -> *mut ::c_void; + + pub fn shmctl( + shmid: ::c_int, + cmd: ::c_int, + buf: *mut ::shmid_ds, + ) -> ::c_int; + + pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; + + pub fn shmget(key: key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; + + pub fn shm_open( + name: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); + + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; + pub fn madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn msync( + addr: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::c_int; + + pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; + + pub fn recvfrom( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + ) -> ::ssize_t; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + pub fn futimesat( + fd: ::c_int, + path: *const ::c_char, + times: *const ::timeval, + ) -> ::c_int; + pub fn futimens(dirfd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn utimensat( + dirfd: ::c_int, + path: *const ::c_char, + times: *const ::timespec, + flag: ::c_int, + ) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + #[cfg_attr(target_os = "illumos", link_name = "__xnet_bind")] + pub fn bind( + socket: ::c_int, + address: *const ::sockaddr, + address_len: ::socklen_t, + ) -> ::c_int; + + pub fn writev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + pub fn readv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + + #[cfg_attr(target_os = "illumos", link_name = "__xnet_sendmsg")] + pub fn sendmsg( + fd: ::c_int, + msg: *const ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + #[cfg_attr(target_os = "illumos", link_name = "__xnet_recvmsg")] + pub fn recvmsg( + fd: ::c_int, + msg: *mut ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + + pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; + pub fn mq_close(mqd: ::mqd_t) -> ::c_int; + pub fn mq_unlink(name: *const ::c_char) -> ::c_int; + pub fn mq_receive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + ) -> ::ssize_t; + pub fn mq_timedreceive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::ssize_t; + pub fn mq_send( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + ) -> ::c_int; + pub fn mq_timedsend( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::c_int; + pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; + pub fn mq_setattr( + mqd: ::mqd_t, + newattr: *const ::mq_attr, + oldattr: *mut ::mq_attr, + ) -> ::c_int; + pub fn port_create() -> ::c_int; + pub fn port_associate( + port: ::c_int, + source: ::c_int, + object: ::uintptr_t, + events: ::c_int, + user: *mut ::c_void, + ) -> ::c_int; + pub fn port_dissociate( + port: ::c_int, + source: ::c_int, + object: ::uintptr_t, + ) -> ::c_int; + pub fn port_get( + port: ::c_int, + pe: *mut port_event, + timeout: *mut ::timespec, + ) -> ::c_int; + pub fn port_getn( + port: ::c_int, + pe_list: *mut port_event, + max: ::c_uint, + nget: *mut ::c_uint, + timeout: *mut ::timespec, + ) -> ::c_int; + pub fn fexecve( + fd: ::c_int, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_getgrgid_r" + )] + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sem_close(sem: *mut sem_t) -> ::c_int; + pub fn getdtablesize() -> ::c_int; + + // The epoll functions are actually only present on illumos. However, + // there are things using epoll on illumos (built using the + // x86_64-sun-solaris target) which would break until the illumos target is + // present in rustc. + pub fn epoll_pwait( + epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: ::c_int, + sigmask: *const ::sigset_t, + ) -> ::c_int; + + pub fn epoll_create(size: ::c_int) -> ::c_int; + pub fn epoll_create1(flags: ::c_int) -> ::c_int; + pub fn epoll_wait( + epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: ::c_int, + ) -> ::c_int; + pub fn epoll_ctl( + epfd: ::c_int, + op: ::c_int, + fd: ::c_int, + event: *mut ::epoll_event, + ) -> ::c_int; + + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_getgrnam_r" + )] + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + pub fn pthread_sigmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const ::c_char) -> *mut ::group; + pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; + pub fn sem_unlink(name: *const ::c_char) -> ::c_int; + pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_getpwnam_r" + )] + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_getpwuid_r" + )] + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_getpwent_r" + )] + pub fn getpwent_r( + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_getgrent_r" + )] + pub fn getgrent_r( + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_sigwait" + )] + pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; + pub fn pthread_atfork( + prepare: ::Option, + parent: ::Option, + child: ::Option, + ) -> ::c_int; + pub fn getgrgid(gid: ::gid_t) -> *mut ::group; + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut ::group; + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + + pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; + pub fn uname(buf: *mut ::utsname) -> ::c_int; + pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + pub fn door_call(d: ::c_int, params: *const door_arg_t) -> ::c_int; + pub fn door_return( + data_ptr: *const ::c_char, + data_size: ::size_t, + desc_ptr: *const door_desc_t, + num_desc: ::c_uint, + ); + pub fn door_create( + server_procedure: extern "C" fn( + cookie: *const ::c_void, + argp: *const ::c_char, + arg_size: ::size_t, + dp: *const door_desc_t, + n_desc: ::c_uint, + ), + cookie: *const ::c_void, + attributes: door_attr_t, + ) -> ::c_int; + pub fn fattach(fildes: ::c_int, path: *const ::c_char) -> ::c_int; + + pub fn makeutx(ux: *const utmpx) -> *mut utmpx; + pub fn modutx(ux: *const utmpx) -> *mut utmpx; + pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int; + pub fn utmpxname(file: *const ::c_char) -> ::c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + + pub fn endutent(); + pub fn getutent() -> *mut utmp; + pub fn getutid(u: *const utmp) -> *mut utmp; + pub fn getutline(u: *const utmp) -> *mut utmp; + pub fn pututline(u: *const utmp) -> *mut utmp; + pub fn setutent(); + pub fn utmpname(file: *const ::c_char) -> ::c_int; + + pub fn getutmp(ux: *const utmpx, u: *mut utmp); + pub fn getutmpx(u: *const utmp, ux: *mut utmpx); + pub fn updwtmp(file: *const ::c_char, u: *mut utmp); +} + +mod compat; +pub use self::compat::*; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/align.rs new file mode 100644 index 0000000..76b524d --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/align.rs @@ -0,0 +1,66 @@ +macro_rules! expand_align { + () => { + s! { + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + + s_no_extra_traits! { + #[repr(align(8))] + #[allow(missing_debug_implementations)] + pub struct pthread_cond_t { + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + #[allow(missing_debug_implementations)] + pub struct pthread_mutex_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + #[allow(missing_debug_implementations)] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + } + }; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/arm/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/arm/align.rs new file mode 100644 index 0000000..4a0e074 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/arm/align.rs @@ -0,0 +1,13 @@ +s! { + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/arm/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/arm/mod.rs new file mode 100644 index 0000000..613a11f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/arm/mod.rs @@ -0,0 +1,1049 @@ +pub type c_char = u8; +pub type wchar_t = ::c_uint; +pub type c_long = i32; +pub type c_ulong = u32; +pub type time_t = ::c_long; + +pub type clock_t = ::c_long; +pub type fsblkcnt_t = ::c_ulong; +pub type fsfilcnt_t = ::c_ulong; +pub type ino_t = ::c_ulong; +pub type off_t = ::c_long; +pub type pthread_t = ::c_ulong; +pub type rlim_t = ::c_ulong; +pub type suseconds_t = ::c_long; + +pub type nlink_t = ::c_uint; +pub type blksize_t = ::c_long; +pub type blkcnt_t = ::c_long; + +s! { + pub struct cmsghdr { + pub cmsg_len: ::size_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::socklen_t, + pub msg_flags: ::c_int, + } + + pub struct pthread_attr_t { + __size: [::c_long; 9], + } + + pub struct stat { + pub st_dev: ::c_ulonglong, + pub __pad1: ::c_ushort, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulonglong, + pub __pad2: ::c_ushort, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_ulong, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_ulong, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_ulong, + pub __unused4: ::c_ulong, + pub __unused5: ::c_ulong, + } + + pub struct stat64 + { + pub st_dev: ::c_ulonglong, + pub __pad1: ::c_uint, + pub __st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulonglong, + pub __pad2: ::c_uint, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_ulong, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_ulong, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_ulong, + pub st_ino: ::ino64_t, + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct statfs { + pub f_type: ::c_int, + pub f_bsize: ::c_int, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_int, + pub f_frsize: ::c_int, + pub f_spare: [::c_int; 5], + } + + pub struct sigset_t { + __val: [::c_ulong; 2], + } + + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + // uClibc defines sa_flags as `unsigned long int`, + // but nix crate expects `int` + pub sa_flags: ::c_int, + pub sa_restorer: *mut ::c_void, + pub sa_mask: sigset_t, + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t, + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_ushort, + pub __pad1: ::c_ushort, + pub __seq: ::c_ushort, + pub __pad2: ::c_ushort, + pub __unused1: ::c_ulong, + pub __unused2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + pub __unused1: ::c_ulong, + pub msg_rtime: ::time_t, + pub __unused2: ::c_ulong, + pub msg_ctime: ::time_t, + pub __unused3: ::c_ulong, + pub __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + pub __unused4: ::c_ulong, + pub __unused5: ::c_ulong, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub __unused1: ::c_ulong, + pub shm_dtime: ::time_t, + pub __unused2: ::c_ulong, + pub shm_ctime: ::time_t, + pub __unused3: ::c_ulong, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub __unused4: ::c_ulong, + pub __unused5: ::c_ulong, + } + + pub struct ucred { + pub pid: ::pid_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + } + +} + +pub const O_CLOEXEC: ::c_int = 0o2000000; +pub const RLIM_INFINITY: rlim_t = !0; +pub const __SIZEOF_PTHREAD_ATTR_T: usize = 36; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_COND_COMPAT_T: usize = 12; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const NCCS: usize = 32; + +// I wasn't able to find those constants +// in uclibc build environment for armv7 +pub const AIO_ALLDONE: ::c_int = 2; // from linux/mod.rs +pub const AIO_CANCELED: ::c_int = 0; // from linux/mod.rs +pub const AIO_NOTCANCELED: ::c_int = 1; // from linux/mod.rs +pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; // from linux/mod.rs +pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; // from linux/mod.rs +pub const EPOLLWAKEUP: ::c_int = 0x20000000; // from linux/other/mod.rs +pub const EXTPROC: ::tcflag_t = 0o200000; // from asm-generic/termbits.h +pub const F_GETPIPE_SZ: ::c_int = 1032; // from linux_like/mod.rs +pub const F_SETPIPE_SZ: ::c_int = 1031; // from linux_like/mod.rs +pub const LIO_NOP: ::c_int = 2; // from linux/mod.rs +pub const LIO_NOWAIT: ::c_int = 1; // from linux/mod.rs +pub const LIO_READ: ::c_int = 0; // from linux/mod.rs +pub const LIO_WAIT: ::c_int = 0; // from linux/mod.rs +pub const LIO_WRITE: ::c_int = 1; // from linux/mod.rs +pub const MAP_HUGETLB: ::c_int = 0x040000; // from linux/other/mod.rs +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; +pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32; // from linux/mod.rs +pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32; // from linux/mod.rs +pub const SO_BUSY_POLL: ::c_int = 46; // from src/unix/linux_like/mod.rs +pub const SO_PEEK_OFF: ::c_int = 42; // from src/unix/linux_like/mod.rs +pub const SO_REUSEPORT: ::c_int = 15; // from src/unix/linux_like/mod.rs +pub const SOL_NETLINK: ::c_int = 270; // from src/unix/linux_like/mod.rs +pub const _POSIX_VDISABLE: ::cc_t = 0; // from linux/mod.rs +pub const AT_EMPTY_PATH: ::c_int = 0x1000; // from linux_like/mod.rs + +// autogenerated constants with hand tuned types +pub const AT_NO_AUTOMOUNT: ::c_int = 0x800; +pub const B0: ::speed_t = 0; +pub const B1000000: ::speed_t = 0x1008; +pub const B110: ::speed_t = 0x3; +pub const B115200: ::speed_t = 0x1002; +pub const B1152000: ::speed_t = 0x1009; +pub const B1200: ::speed_t = 0x9; +pub const B134: ::speed_t = 0x4; +pub const B150: ::speed_t = 0x5; +pub const B1500000: ::speed_t = 0x100a; +pub const B1800: ::speed_t = 0xa; +pub const B19200: ::speed_t = 0xe; +pub const B200: ::speed_t = 0x6; +pub const B2000000: ::speed_t = 0x100b; +pub const B230400: ::speed_t = 0x1003; +pub const B2400: ::speed_t = 0xb; +pub const B2500000: ::speed_t = 0x100c; +pub const B300: ::speed_t = 0x7; +pub const B3000000: ::speed_t = 0x100d; +pub const B3500000: ::speed_t = 0x100e; +pub const B38400: ::speed_t = 0xf; +pub const B4000000: ::speed_t = 0x100f; +pub const B460800: ::speed_t = 0x1004; +pub const B4800: ::speed_t = 0xc; +pub const B50: ::speed_t = 0x1; +pub const B500000: ::speed_t = 0x1005; +pub const B57600: ::speed_t = 0x1001; +pub const B576000: ::speed_t = 0x1006; +pub const B600: ::speed_t = 0x8; +pub const B75: ::speed_t = 0x2; +pub const B921600: ::speed_t = 0x1007; +pub const B9600: ::speed_t = 0xd; +pub const BS1: ::c_int = 0x2000; +pub const BSDLY: ::c_int = 0x2000; +pub const CBAUD: ::tcflag_t = 0x100f; +pub const CBAUDEX: ::tcflag_t = 0x1000; +pub const CIBAUD: ::tcflag_t = 0x100f0000; +pub const CLOCAL: ::tcflag_t = 0x800; +pub const CMSPAR: ::tcflag_t = 0x40000000; +pub const CPU_SETSIZE: ::c_int = 0x400; +pub const CR1: ::c_int = 0x200; +pub const CR2: ::c_int = 0x400; +pub const CR3: ::c_int = 0x600; +pub const CRDLY: ::c_int = 0x600; +pub const CREAD: ::tcflag_t = 0x80; +pub const CS6: ::tcflag_t = 0x10; +pub const CS7: ::tcflag_t = 0x20; +pub const CS8: ::tcflag_t = 0x30; +pub const CSIZE: ::tcflag_t = 0x30; +pub const CSTOPB: ::tcflag_t = 0x40; +pub const EADDRINUSE: ::c_int = 0x62; +pub const EADDRNOTAVAIL: ::c_int = 0x63; +pub const EADV: ::c_int = 0x44; +pub const EAFNOSUPPORT: ::c_int = 0x61; +pub const EALREADY: ::c_int = 0x72; +pub const EBADE: ::c_int = 0x34; +pub const EBADFD: ::c_int = 0x4d; +pub const EBADMSG: ::c_int = 0x4a; +pub const EBADR: ::c_int = 0x35; +pub const EBADRQC: ::c_int = 0x38; +pub const EBADSLT: ::c_int = 0x39; +pub const EBFONT: ::c_int = 0x3b; +pub const ECANCELED: ::c_int = 0x7d; +pub const ECHOCTL: ::tcflag_t = 0x200; +pub const ECHOE: ::tcflag_t = 0x10; +pub const ECHOK: ::tcflag_t = 0x20; +pub const ECHOKE: ::tcflag_t = 0x800; +pub const ECHONL: ::tcflag_t = 0x40; +pub const ECHOPRT: ::tcflag_t = 0x400; +pub const ECHRNG: ::c_int = 0x2c; +pub const ECOMM: ::c_int = 0x46; +pub const ECONNABORTED: ::c_int = 0x67; +pub const ECONNREFUSED: ::c_int = 0x6f; +pub const ECONNRESET: ::c_int = 0x68; +pub const EDEADLK: ::c_int = 0x23; +pub const EDESTADDRREQ: ::c_int = 0x59; +pub const EDOTDOT: ::c_int = 0x49; +pub const EDQUOT: ::c_int = 0x7a; +pub const EFD_CLOEXEC: ::c_int = 0x80000; +pub const EFD_NONBLOCK: ::c_int = 0x800; +pub const EHOSTDOWN: ::c_int = 0x70; +pub const EHOSTUNREACH: ::c_int = 0x71; +pub const EHWPOISON: ::c_int = 0x85; +pub const EIDRM: ::c_int = 0x2b; +pub const EILSEQ: ::c_int = 0x54; +pub const EINPROGRESS: ::c_int = 0x73; +pub const EISCONN: ::c_int = 0x6a; +pub const EISNAM: ::c_int = 0x78; +pub const EKEYEXPIRED: ::c_int = 0x7f; +pub const EKEYREJECTED: ::c_int = 0x81; +pub const EKEYREVOKED: ::c_int = 0x80; +pub const EL2HLT: ::c_int = 0x33; +pub const EL2NSYNC: ::c_int = 0x2d; +pub const EL3HLT: ::c_int = 0x2e; +pub const EL3RST: ::c_int = 0x2f; +pub const ELIBACC: ::c_int = 0x4f; +pub const ELIBBAD: ::c_int = 0x50; +pub const ELIBEXEC: ::c_int = 0x53; +pub const ELIBMAX: ::c_int = 0x52; +pub const ELIBSCN: ::c_int = 0x51; +pub const ELNRNG: ::c_int = 0x30; +pub const ELOOP: ::c_int = 0x28; +pub const EMEDIUMTYPE: ::c_int = 0x7c; +pub const EMSGSIZE: ::c_int = 0x5a; +pub const EMULTIHOP: ::c_int = 0x48; +pub const ENAMETOOLONG: ::c_int = 0x24; +pub const ENAVAIL: ::c_int = 0x77; +pub const ENETDOWN: ::c_int = 0x64; +pub const ENETRESET: ::c_int = 0x66; +pub const ENETUNREACH: ::c_int = 0x65; +pub const ENOANO: ::c_int = 0x37; +pub const ENOBUFS: ::c_int = 0x69; +pub const ENOCSI: ::c_int = 0x32; +pub const ENODATA: ::c_int = 0x3d; +pub const ENOKEY: ::c_int = 0x7e; +pub const ENOLCK: ::c_int = 0x25; +pub const ENOLINK: ::c_int = 0x43; +pub const ENOMEDIUM: ::c_int = 0x7b; +pub const ENOMSG: ::c_int = 0x2a; +pub const ENONET: ::c_int = 0x40; +pub const ENOPKG: ::c_int = 0x41; +pub const ENOPROTOOPT: ::c_int = 0x5c; +pub const ENOSR: ::c_int = 0x3f; +pub const ENOSTR: ::c_int = 0x3c; +pub const ENOSYS: ::c_int = 0x26; +pub const ENOTCONN: ::c_int = 0x6b; +pub const ENOTEMPTY: ::c_int = 0x27; +pub const ENOTNAM: ::c_int = 0x76; +pub const ENOTRECOVERABLE: ::c_int = 0x83; +pub const ENOTSOCK: ::c_int = 0x58; +pub const ENOTUNIQ: ::c_int = 0x4c; +pub const EOPNOTSUPP: ::c_int = 0x5f; +pub const EOVERFLOW: ::c_int = 0x4b; +pub const EOWNERDEAD: ::c_int = 0x82; +pub const EPFNOSUPPORT: ::c_int = 0x60; +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; +pub const EPROTO: ::c_int = 0x47; +pub const EPROTONOSUPPORT: ::c_int = 0x5d; +pub const EPROTOTYPE: ::c_int = 0x5b; +pub const EREMCHG: ::c_int = 0x4e; +pub const EREMOTE: ::c_int = 0x42; +pub const EREMOTEIO: ::c_int = 0x79; +pub const ERESTART: ::c_int = 0x55; +pub const ERFKILL: ::c_int = 0x84; +pub const ESHUTDOWN: ::c_int = 0x6c; +pub const ESOCKTNOSUPPORT: ::c_int = 0x5e; +pub const ESRMNT: ::c_int = 0x45; +pub const ESTALE: ::c_int = 0x74; +pub const ESTRPIPE: ::c_int = 0x56; +pub const ETIME: ::c_int = 0x3e; +pub const ETIMEDOUT: ::c_int = 0x6e; +pub const ETOOMANYREFS: ::c_int = 0x6d; +pub const EUCLEAN: ::c_int = 0x75; +pub const EUNATCH: ::c_int = 0x31; +pub const EUSERS: ::c_int = 0x57; +pub const EXFULL: ::c_int = 0x36; +pub const FF1: ::c_int = 0x8000; +pub const FFDLY: ::c_int = 0x8000; +pub const FIONBIO: ::c_ulong = 0x5421; +pub const FIOCLEX: ::c_ulong = 0x5451; +pub const FIONCLEX: ::c_ulong = 0x5450; +pub const FLUSHO: ::tcflag_t = 0x1000; +pub const F_GETLK: ::c_int = 0x5; +pub const F_SETLK: ::c_int = 0x6; +pub const F_SETLKW: ::c_int = 0x7; +pub const HUPCL: ::tcflag_t = 0x400; +pub const ICANON: ::tcflag_t = 0x2; +pub const IEXTEN: ::tcflag_t = 0x8000; +pub const ISIG: ::tcflag_t = 0x1; +pub const IUTF8: ::tcflag_t = 0x4000; +pub const IXOFF: ::tcflag_t = 0x1000; +pub const IXON: ::tcflag_t = 0x400; +pub const MAP_ANON: ::c_int = 0x20; +pub const MAP_ANONYMOUS: ::c_int = 0x20; +pub const MAP_DENYWRITE: ::c_int = 0x800; +pub const MAP_EXECUTABLE: ::c_int = 0x1000; +pub const MAP_GROWSDOWN: ::c_int = 0x100; +pub const MAP_LOCKED: ::c_int = 0x2000; +pub const MAP_NONBLOCK: ::c_int = 0x10000; +pub const MAP_NORESERVE: ::c_int = 0x4000; +pub const MAP_POPULATE: ::c_int = 0x8000; +pub const MAP_STACK: ::c_int = 0x20000; +pub const MS_ACTIVE: u32 = 0x40000000; +pub const MS_DIRSYNC: u32 = 0x80; +pub const MS_I_VERSION: u32 = 0x800000; +pub const MS_KERNMOUNT: u32 = 0x400000; +pub const MS_MOVE: u32 = 0x2000; +pub const MS_POSIXACL: u32 = 0x10000; +pub const MS_PRIVATE: u32 = 0x40000; +pub const MS_REC: u32 = 0x4000; +pub const MS_RELATIME: u32 = 0x200000; +pub const MS_SHARED: u32 = 0x100000; +pub const MS_SILENT: u32 = 0x8000; +pub const MS_SLAVE: u32 = 0x80000; +pub const MS_STRICTATIME: u32 = 0x1000000; +pub const MS_UNBINDABLE: u32 = 0x20000; +pub const NLDLY: ::tcflag_t = 0x100; +pub const NOFLSH: ::tcflag_t = 0x80; +pub const OCRNL: ::c_int = 0x8; +pub const OFDEL: ::c_int = 0x80; +pub const OFILL: ::c_int = 0x40; +pub const OLCUC: ::tcflag_t = 0x2; +pub const ONLCR: ::tcflag_t = 0x4; +pub const ONLRET: ::tcflag_t = 0x20; +pub const ONOCR: ::tcflag_t = 0x10; +pub const O_ACCMODE: ::c_int = 0x3; +pub const O_APPEND: ::c_int = 0x400; +pub const O_CREAT: ::c_int = 0x40; +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_DSYNC: ::c_int = 0x1000; +pub const O_EXCL: ::c_int = 0x80; +pub const O_NDELAY: ::c_int = 0x800; +pub const O_NOCTTY: ::c_int = 0x100; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_NONBLOCK: ::c_int = 0x800; +pub const O_SYNC: ::c_int = 0o10000; +pub const O_TRUNC: ::c_int = 0x200; +pub const PARENB: ::tcflag_t = 0x100; +pub const PARODD: ::tcflag_t = 0x200; +pub const PENDIN: ::tcflag_t = 0x4000; +pub const POLLRDBAND: ::c_short = 0x80; +pub const POLLRDNORM: ::c_short = 0x40; +pub const POLLWRBAND: ::c_short = 0x200; +pub const POLLWRNORM: ::c_short = 0x100; +pub const PTHREAD_STACK_MIN: ::size_t = 16384; +pub const QIF_ALL: u32 = 0x3f; +pub const QIF_BLIMITS: u32 = 0x1; +pub const QIF_BTIME: u32 = 0x10; +pub const QIF_ILIMITS: u32 = 0x4; +pub const QIF_INODES: u32 = 0x8; +pub const QIF_ITIME: u32 = 0x20; +pub const QIF_LIMITS: u32 = 0x5; +pub const QIF_SPACE: u32 = 0x2; +pub const QIF_TIMES: u32 = 0x30; +pub const QIF_USAGE: u32 = 0xa; +pub const SA_NOCLDSTOP: ::c_int = 0x1; +pub const SA_NOCLDWAIT: ::c_int = 0x2; +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_ONSTACK: ::c_int = 0x8000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_SIGINFO: ::c_int = 0x4; +pub const SFD_CLOEXEC: ::c_int = 0x80000; +pub const SFD_NONBLOCK: ::c_int = 0x800; +pub const SIGBUS: ::c_int = 0x7; +pub const SIGCHLD: ::c_int = 0x11; +pub const SIGCONT: ::c_int = 0x12; +pub const SIGIO: ::c_int = 0x1d; +pub const SIGPROF: ::c_int = 0x1b; +pub const SIGPWR: ::c_int = 0x1e; +pub const SIGSTKFLT: ::c_int = 0x10; +pub const SIGSTKSZ: ::size_t = 8192; +pub const SIGSTOP: ::c_int = 0x13; +pub const SIGSYS: ::c_int = 0x1f; +pub const SIGTSTP: ::c_int = 0x14; +pub const SIGTTIN: ::c_int = 0x15; +pub const SIGTTOU: ::c_int = 0x16; +pub const SIGURG: ::c_int = 0x17; +pub const SIGUSR1: ::c_int = 0xa; +pub const SIGUSR2: ::c_int = 0xc; +pub const SIGVTALRM: ::c_int = 0x1a; +pub const SIGWINCH: ::c_int = 0x1c; +pub const SIGXCPU: ::c_int = 0x18; +pub const SIGXFSZ: ::c_int = 0x19; +pub const SIG_BLOCK: ::c_int = 0; +pub const SIG_SETMASK: ::c_int = 0x2; +pub const SIG_UNBLOCK: ::c_int = 0x1; +pub const SOCK_DGRAM: ::c_int = 0x2; +pub const SOCK_NONBLOCK: ::c_int = 0o0004000; +pub const SOCK_SEQPACKET: ::c_int = 0x5; +pub const SOCK_STREAM: ::c_int = 0x1; +pub const SOL_SOCKET: ::c_int = 0x1; +pub const SO_ACCEPTCONN: ::c_int = 0x1e; +pub const SO_BINDTODEVICE: ::c_int = 0x19; +pub const SO_BROADCAST: ::c_int = 0x6; +pub const SO_BSDCOMPAT: ::c_int = 0xe; +pub const SO_DOMAIN: ::c_int = 0x27; +pub const SO_DONTROUTE: ::c_int = 0x5; +pub const SO_ERROR: ::c_int = 0x4; +pub const SO_KEEPALIVE: ::c_int = 0x9; +pub const SO_LINGER: ::c_int = 0xd; +pub const SO_MARK: ::c_int = 0x24; +pub const SO_OOBINLINE: ::c_int = 0xa; +pub const SO_PASSCRED: ::c_int = 0x10; +pub const SO_PEERCRED: ::c_int = 0x11; +pub const SO_PRIORITY: ::c_int = 0xc; +pub const SO_PROTOCOL: ::c_int = 0x26; +pub const SO_RCVBUF: ::c_int = 0x8; +pub const SO_RCVLOWAT: ::c_int = 0x12; +pub const SO_RCVTIMEO: ::c_int = 0x14; +pub const SO_REUSEADDR: ::c_int = 0x2; +pub const SO_RXQ_OVFL: ::c_int = 0x28; +pub const SO_SNDBUF: ::c_int = 0x7; +pub const SO_SNDBUFFORCE: ::c_int = 0x20; +pub const SO_SNDLOWAT: ::c_int = 0x13; +pub const SO_SNDTIMEO: ::c_int = 0x15; +pub const SO_TIMESTAMP: ::c_int = 0x1d; +pub const SO_TYPE: ::c_int = 0x3; +pub const TAB1: ::c_int = 0x800; +pub const TAB2: ::c_int = 0x1000; +pub const TAB3: ::c_int = 0x1800; +pub const TABDLY: ::c_int = 0x1800; +pub const TCSADRAIN: ::c_int = 0x1; +pub const TCSAFLUSH: ::c_int = 0x2; +pub const TCSANOW: ::c_int = 0; +pub const TOSTOP: ::tcflag_t = 0x100; +pub const VDISCARD: usize = 0xd; +pub const VEOF: usize = 0x4; +pub const VEOL: usize = 0xb; +pub const VEOL2: usize = 0x10; +pub const VMIN: usize = 0x6; +pub const VREPRINT: usize = 0xc; +pub const VSTART: usize = 0x8; +pub const VSTOP: usize = 0x9; +pub const VSUSP: usize = 0xa; +pub const VSWTC: usize = 0x7; +pub const VT1: ::c_int = 0x4000; +pub const VTDLY: ::c_int = 0x4000; +pub const VTIME: usize = 0x5; +pub const VWERASE: usize = 0xe; +pub const XTABS: ::tcflag_t = 0x1800; +pub const _PC_2_SYMLINKS: ::c_int = 0x14; +pub const _PC_ALLOC_SIZE_MIN: ::c_int = 0x12; +pub const _PC_ASYNC_IO: ::c_int = 0xa; +pub const _PC_FILESIZEBITS: ::c_int = 0xd; +pub const _PC_PRIO_IO: ::c_int = 0xb; +pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 0xe; +pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 0xf; +pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 0x10; +pub const _PC_REC_XFER_ALIGN: ::c_int = 0x11; +pub const _PC_SYMLINK_MAX: ::c_int = 0x13; +pub const _PC_SYNC_IO: ::c_int = 0x9; +pub const _SC_2_PBS: ::c_int = 0xa8; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 0xa9; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 0xaf; +pub const _SC_2_PBS_LOCATE: ::c_int = 0xaa; +pub const _SC_2_PBS_MESSAGE: ::c_int = 0xab; +pub const _SC_2_PBS_TRACK: ::c_int = 0xac; +pub const _SC_ADVISORY_INFO: ::c_int = 0x84; +pub const _SC_BARRIERS: ::c_int = 0x85; +pub const _SC_CLOCK_SELECTION: ::c_int = 0x89; +pub const _SC_CPUTIME: ::c_int = 0x8a; +pub const _SC_IPV6: ::c_int = 0xeb; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 0x95; +pub const _SC_RAW_SOCKETS: ::c_int = 0xec; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 0x99; +pub const _SC_REGEXP: ::c_int = 0x9b; +pub const _SC_SHELL: ::c_int = 0x9d; +pub const _SC_SPAWN: ::c_int = 0x9f; +pub const _SC_SPIN_LOCKS: ::c_int = 0x9a; +pub const _SC_SPORADIC_SERVER: ::c_int = 0xa0; +pub const _SC_SS_REPL_MAX: ::c_int = 0xf1; +pub const _SC_SYMLOOP_MAX: ::c_int = 0xad; +pub const _SC_THREAD_CPUTIME: ::c_int = 0x8b; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 0x52; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 0xf7; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 0xf8; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 0xa1; +pub const _SC_TIMEOUTS: ::c_int = 0xa4; +pub const _SC_TRACE: ::c_int = 0xb5; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 0xb6; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 0xf2; +pub const _SC_TRACE_INHERIT: ::c_int = 0xb7; +pub const _SC_TRACE_LOG: ::c_int = 0xb8; +pub const _SC_TRACE_NAME_MAX: ::c_int = 0xf3; +pub const _SC_TRACE_SYS_MAX: ::c_int = 0xf4; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 0xf5; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 0xa5; +pub const _SC_V6_ILP32_OFF32: ::c_int = 0xb0; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = 0xb1; +pub const _SC_V6_LP64_OFF64: ::c_int = 0xb2; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 0xb3; +pub const _SC_XOPEN_STREAMS: ::c_int = 0xf6; + +// Syscall table is copied from src/unix/notbsd/linux/musl/b32/arm.rs +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_pause: ::c_long = 29; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_poll: ::c_long = 168; +pub const SYS_nfsservctl: ::c_long = 169; +pub const SYS_setresgid: ::c_long = 170; +pub const SYS_getresgid: ::c_long = 171; +pub const SYS_prctl: ::c_long = 172; +pub const SYS_rt_sigreturn: ::c_long = 173; +pub const SYS_rt_sigaction: ::c_long = 174; +pub const SYS_rt_sigprocmask: ::c_long = 175; +pub const SYS_rt_sigpending: ::c_long = 176; +pub const SYS_rt_sigtimedwait: ::c_long = 177; +pub const SYS_rt_sigqueueinfo: ::c_long = 178; +pub const SYS_rt_sigsuspend: ::c_long = 179; +pub const SYS_pread64: ::c_long = 180; +pub const SYS_pwrite64: ::c_long = 181; +pub const SYS_chown: ::c_long = 182; +pub const SYS_getcwd: ::c_long = 183; +pub const SYS_capget: ::c_long = 184; +pub const SYS_capset: ::c_long = 185; +pub const SYS_sigaltstack: ::c_long = 186; +pub const SYS_sendfile: ::c_long = 187; +pub const SYS_vfork: ::c_long = 190; +pub const SYS_ugetrlimit: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_lchown32: ::c_long = 198; +pub const SYS_getuid32: ::c_long = 199; +pub const SYS_getgid32: ::c_long = 200; +pub const SYS_geteuid32: ::c_long = 201; +pub const SYS_getegid32: ::c_long = 202; +pub const SYS_setreuid32: ::c_long = 203; +pub const SYS_setregid32: ::c_long = 204; +pub const SYS_getgroups32: ::c_long = 205; +pub const SYS_setgroups32: ::c_long = 206; +pub const SYS_fchown32: ::c_long = 207; +pub const SYS_setresuid32: ::c_long = 208; +pub const SYS_getresuid32: ::c_long = 209; +pub const SYS_setresgid32: ::c_long = 210; +pub const SYS_getresgid32: ::c_long = 211; +pub const SYS_chown32: ::c_long = 212; +pub const SYS_setuid32: ::c_long = 213; +pub const SYS_setgid32: ::c_long = 214; +pub const SYS_setfsuid32: ::c_long = 215; +pub const SYS_setfsgid32: ::c_long = 216; +pub const SYS_getdents64: ::c_long = 217; +pub const SYS_pivot_root: ::c_long = 218; +pub const SYS_mincore: ::c_long = 219; +pub const SYS_madvise: ::c_long = 220; +pub const SYS_fcntl64: ::c_long = 221; +pub const SYS_gettid: ::c_long = 224; +pub const SYS_readahead: ::c_long = 225; +pub const SYS_setxattr: ::c_long = 226; +pub const SYS_lsetxattr: ::c_long = 227; +pub const SYS_fsetxattr: ::c_long = 228; +pub const SYS_getxattr: ::c_long = 229; +pub const SYS_lgetxattr: ::c_long = 230; +pub const SYS_fgetxattr: ::c_long = 231; +pub const SYS_listxattr: ::c_long = 232; +pub const SYS_llistxattr: ::c_long = 233; +pub const SYS_flistxattr: ::c_long = 234; +pub const SYS_removexattr: ::c_long = 235; +pub const SYS_lremovexattr: ::c_long = 236; +pub const SYS_fremovexattr: ::c_long = 237; +pub const SYS_tkill: ::c_long = 238; +pub const SYS_sendfile64: ::c_long = 239; +pub const SYS_futex: ::c_long = 240; +pub const SYS_sched_setaffinity: ::c_long = 241; +pub const SYS_sched_getaffinity: ::c_long = 242; +pub const SYS_io_setup: ::c_long = 243; +pub const SYS_io_destroy: ::c_long = 244; +pub const SYS_io_getevents: ::c_long = 245; +pub const SYS_io_submit: ::c_long = 246; +pub const SYS_io_cancel: ::c_long = 247; +pub const SYS_exit_group: ::c_long = 248; +pub const SYS_lookup_dcookie: ::c_long = 249; +pub const SYS_epoll_create: ::c_long = 250; +pub const SYS_epoll_ctl: ::c_long = 251; +pub const SYS_epoll_wait: ::c_long = 252; +pub const SYS_remap_file_pages: ::c_long = 253; +pub const SYS_set_tid_address: ::c_long = 256; +pub const SYS_timer_create: ::c_long = 257; +pub const SYS_timer_settime: ::c_long = 258; +pub const SYS_timer_gettime: ::c_long = 259; +pub const SYS_timer_getoverrun: ::c_long = 260; +pub const SYS_timer_delete: ::c_long = 261; +pub const SYS_clock_settime: ::c_long = 262; +pub const SYS_clock_gettime: ::c_long = 263; +pub const SYS_clock_getres: ::c_long = 264; +pub const SYS_clock_nanosleep: ::c_long = 265; +pub const SYS_statfs64: ::c_long = 266; +pub const SYS_fstatfs64: ::c_long = 267; +pub const SYS_tgkill: ::c_long = 268; +pub const SYS_utimes: ::c_long = 269; +pub const SYS_pciconfig_iobase: ::c_long = 271; +pub const SYS_pciconfig_read: ::c_long = 272; +pub const SYS_pciconfig_write: ::c_long = 273; +pub const SYS_mq_open: ::c_long = 274; +pub const SYS_mq_unlink: ::c_long = 275; +pub const SYS_mq_timedsend: ::c_long = 276; +pub const SYS_mq_timedreceive: ::c_long = 277; +pub const SYS_mq_notify: ::c_long = 278; +pub const SYS_mq_getsetattr: ::c_long = 279; +pub const SYS_waitid: ::c_long = 280; +pub const SYS_socket: ::c_long = 281; +pub const SYS_bind: ::c_long = 282; +pub const SYS_connect: ::c_long = 283; +pub const SYS_listen: ::c_long = 284; +pub const SYS_accept: ::c_long = 285; +pub const SYS_getsockname: ::c_long = 286; +pub const SYS_getpeername: ::c_long = 287; +pub const SYS_socketpair: ::c_long = 288; +pub const SYS_send: ::c_long = 289; +pub const SYS_sendto: ::c_long = 290; +pub const SYS_recv: ::c_long = 291; +pub const SYS_recvfrom: ::c_long = 292; +pub const SYS_shutdown: ::c_long = 293; +pub const SYS_setsockopt: ::c_long = 294; +pub const SYS_getsockopt: ::c_long = 295; +pub const SYS_sendmsg: ::c_long = 296; +pub const SYS_recvmsg: ::c_long = 297; +pub const SYS_semop: ::c_long = 298; +pub const SYS_semget: ::c_long = 299; +pub const SYS_semctl: ::c_long = 300; +pub const SYS_msgsnd: ::c_long = 301; +pub const SYS_msgrcv: ::c_long = 302; +pub const SYS_msgget: ::c_long = 303; +pub const SYS_msgctl: ::c_long = 304; +pub const SYS_shmat: ::c_long = 305; +pub const SYS_shmdt: ::c_long = 306; +pub const SYS_shmget: ::c_long = 307; +pub const SYS_shmctl: ::c_long = 308; +pub const SYS_add_key: ::c_long = 309; +pub const SYS_request_key: ::c_long = 310; +pub const SYS_keyctl: ::c_long = 311; +pub const SYS_semtimedop: ::c_long = 312; +pub const SYS_vserver: ::c_long = 313; +pub const SYS_ioprio_set: ::c_long = 314; +pub const SYS_ioprio_get: ::c_long = 315; +pub const SYS_inotify_init: ::c_long = 316; +pub const SYS_inotify_add_watch: ::c_long = 317; +pub const SYS_inotify_rm_watch: ::c_long = 318; +pub const SYS_mbind: ::c_long = 319; +pub const SYS_get_mempolicy: ::c_long = 320; +pub const SYS_set_mempolicy: ::c_long = 321; +pub const SYS_openat: ::c_long = 322; +pub const SYS_mkdirat: ::c_long = 323; +pub const SYS_mknodat: ::c_long = 324; +pub const SYS_fchownat: ::c_long = 325; +pub const SYS_futimesat: ::c_long = 326; +pub const SYS_fstatat64: ::c_long = 327; +pub const SYS_unlinkat: ::c_long = 328; +pub const SYS_renameat: ::c_long = 329; +pub const SYS_linkat: ::c_long = 330; +pub const SYS_symlinkat: ::c_long = 331; +pub const SYS_readlinkat: ::c_long = 332; +pub const SYS_fchmodat: ::c_long = 333; +pub const SYS_faccessat: ::c_long = 334; +pub const SYS_pselect6: ::c_long = 335; +pub const SYS_ppoll: ::c_long = 336; +pub const SYS_unshare: ::c_long = 337; +pub const SYS_set_robust_list: ::c_long = 338; +pub const SYS_get_robust_list: ::c_long = 339; +pub const SYS_splice: ::c_long = 340; +pub const SYS_tee: ::c_long = 342; +pub const SYS_vmsplice: ::c_long = 343; +pub const SYS_move_pages: ::c_long = 344; +pub const SYS_getcpu: ::c_long = 345; +pub const SYS_epoll_pwait: ::c_long = 346; +pub const SYS_kexec_load: ::c_long = 347; +pub const SYS_utimensat: ::c_long = 348; +pub const SYS_signalfd: ::c_long = 349; +pub const SYS_timerfd_create: ::c_long = 350; +pub const SYS_eventfd: ::c_long = 351; +pub const SYS_fallocate: ::c_long = 352; +pub const SYS_timerfd_settime: ::c_long = 353; +pub const SYS_timerfd_gettime: ::c_long = 354; +pub const SYS_signalfd4: ::c_long = 355; +pub const SYS_eventfd2: ::c_long = 356; +pub const SYS_epoll_create1: ::c_long = 357; +pub const SYS_dup3: ::c_long = 358; +pub const SYS_pipe2: ::c_long = 359; +pub const SYS_inotify_init1: ::c_long = 360; +pub const SYS_preadv: ::c_long = 361; +pub const SYS_pwritev: ::c_long = 362; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 363; +pub const SYS_perf_event_open: ::c_long = 364; +pub const SYS_recvmmsg: ::c_long = 365; +pub const SYS_accept4: ::c_long = 366; +pub const SYS_fanotify_init: ::c_long = 367; +pub const SYS_fanotify_mark: ::c_long = 368; +pub const SYS_prlimit64: ::c_long = 369; +pub const SYS_name_to_handle_at: ::c_long = 370; +pub const SYS_open_by_handle_at: ::c_long = 371; +pub const SYS_clock_adjtime: ::c_long = 372; +pub const SYS_syncfs: ::c_long = 373; +pub const SYS_sendmmsg: ::c_long = 374; +pub const SYS_setns: ::c_long = 375; +pub const SYS_process_vm_readv: ::c_long = 376; +pub const SYS_process_vm_writev: ::c_long = 377; +pub const SYS_kcmp: ::c_long = 378; +pub const SYS_finit_module: ::c_long = 379; +pub const SYS_sched_setattr: ::c_long = 380; +pub const SYS_sched_getattr: ::c_long = 381; +pub const SYS_renameat2: ::c_long = 382; +pub const SYS_seccomp: ::c_long = 383; +pub const SYS_getrandom: ::c_long = 384; +pub const SYS_memfd_create: ::c_long = 385; +pub const SYS_bpf: ::c_long = 386; +pub const SYS_execveat: ::c_long = 387; +pub const SYS_userfaultfd: ::c_long = 388; +pub const SYS_membarrier: ::c_long = 389; +pub const SYS_mlock2: ::c_long = 390; +pub const SYS_copy_file_range: ::c_long = 391; +pub const SYS_preadv2: ::c_long = 392; +pub const SYS_pwritev2: ::c_long = 393; +pub const SYS_pkey_mprotect: ::c_long = 394; +pub const SYS_pkey_alloc: ::c_long = 395; +pub const SYS_pkey_free: ::c_long = 396; + +fn CMSG_ALIGN(len: usize) -> usize { + len + ::mem::size_of::() - 1 & !(::mem::size_of::() - 1) +} + +f! { + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize >= ::mem::size_of::() { + (*mhdr).msg_control as *mut cmsghdr + } else { + 0 as *mut cmsghdr + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar { + cmsg.offset(1) as *mut ::c_uchar + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::())) + as ::c_uint + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + CMSG_ALIGN(::mem::size_of::()) as ::c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, + cmsg: *const cmsghdr) -> *mut cmsghdr { + if ((*cmsg).cmsg_len as usize) < ::mem::size_of::() { + return 0 as *mut cmsghdr; + }; + let next = (cmsg as usize + + CMSG_ALIGN((*cmsg).cmsg_len as usize)) + as *mut cmsghdr; + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if (next.offset(1)) as usize > max || + next as usize + CMSG_ALIGN((*next).cmsg_len as usize) > max + { + 0 as *mut cmsghdr + } else { + next as *mut cmsghdr + } + } + +} + +extern "C" { + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + pub fn openpty( + amaster: *mut ::c_int, + aslave: *mut ::c_int, + name: *mut ::c_char, + termp: *mut termios, + winp: *mut ::winsize, + ) -> ::c_int; + pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; + pub fn pwritev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn preadv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/arm/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/arm/no_align.rs new file mode 100644 index 0000000..e32bf67 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/arm/no_align.rs @@ -0,0 +1,10 @@ +s! { + // FIXME this is actually a union + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + __align: [::c_long; 0], + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips32/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips32/align.rs new file mode 100644 index 0000000..4a0e074 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips32/align.rs @@ -0,0 +1,13 @@ +s! { + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips32/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips32/mod.rs new file mode 100644 index 0000000..31bca58 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips32/mod.rs @@ -0,0 +1,633 @@ +pub type c_char = i8; +pub type c_long = i32; +pub type c_ulong = u32; +pub type clock_t = i32; +pub type time_t = i32; +pub type suseconds_t = i32; +pub type wchar_t = i32; +pub type off_t = i32; +pub type ino_t = u32; +pub type blkcnt_t = i32; +pub type blksize_t = i32; +pub type nlink_t = u32; +pub type fsblkcnt_t = ::c_ulong; +pub type fsfilcnt_t = ::c_ulong; +pub type rlim_t = c_ulong; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + st_pad1: [::c_long; 2], + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_pad2: [::c_long; 1], + pub st_size: ::off_t, + st_pad3: ::c_long, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + st_pad5: [::c_long; 14], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + st_pad1: [::c_long; 2], + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + st_pad2: [::c_long; 2], + pub st_size: ::off64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + st_pad3: ::c_long, + pub st_blocks: ::blkcnt64_t, + st_pad5: [::c_long; 14], + } + + pub struct pthread_attr_t { + __size: [u32; 9] + } + + pub struct sigaction { + pub sa_flags: ::c_uint, + pub sa_sigaction: ::sighandler_t, + pub sa_mask: sigset_t, + _restorer: *mut ::c_void, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct sigset_t { + __val: [::c_ulong; 4], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub _pad: [::c_int; 29], + } + + pub struct glob64_t { + pub gl_pathc: ::size_t, + pub gl_pathv: *mut *mut ::c_char, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_uint, + pub __seq: ::c_ushort, + __pad1: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused4: ::c_ulong, + __unused5: ::c_ulong + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + #[cfg(target_endian = "big")] + __glibc_reserved1: ::c_ulong, + pub msg_stime: ::time_t, + #[cfg(target_endian = "little")] + __glibc_reserved1: ::c_ulong, + #[cfg(target_endian = "big")] + __glibc_reserved2: ::c_ulong, + pub msg_rtime: ::time_t, + #[cfg(target_endian = "little")] + __glibc_reserved2: ::c_ulong, + #[cfg(target_endian = "big")] + __glibc_reserved3: ::c_ulong, + pub msg_ctime: ::time_t, + #[cfg(target_endian = "little")] + __glibc_reserved3: ::c_ulong, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved4: ::c_ulong, + __glibc_reserved5: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_frsize: ::c_long, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_files: ::fsblkcnt_t, + pub f_ffree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::c_long, + f_spare: [::c_long; 6], + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::size_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::size_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_sysid: ::c_long, + pub l_pid: ::pid_t, + pad: [::c_long; 4], + } + + pub struct sysinfo { + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 8], + } +} + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + +pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; + +pub const SYS_syscall: ::c_long = 4000 + 0; +pub const SYS_exit: ::c_long = 4000 + 1; +pub const SYS_fork: ::c_long = 4000 + 2; +pub const SYS_read: ::c_long = 4000 + 3; +pub const SYS_write: ::c_long = 4000 + 4; +pub const SYS_open: ::c_long = 4000 + 5; +pub const SYS_close: ::c_long = 4000 + 6; +pub const SYS_waitpid: ::c_long = 4000 + 7; +pub const SYS_creat: ::c_long = 4000 + 8; +pub const SYS_link: ::c_long = 4000 + 9; +pub const SYS_unlink: ::c_long = 4000 + 10; +pub const SYS_execve: ::c_long = 4000 + 11; +pub const SYS_chdir: ::c_long = 4000 + 12; +pub const SYS_time: ::c_long = 4000 + 13; +pub const SYS_mknod: ::c_long = 4000 + 14; +pub const SYS_chmod: ::c_long = 4000 + 15; +pub const SYS_lchown: ::c_long = 4000 + 16; +pub const SYS_break: ::c_long = 4000 + 17; +pub const SYS_lseek: ::c_long = 4000 + 19; +pub const SYS_getpid: ::c_long = 4000 + 20; +pub const SYS_mount: ::c_long = 4000 + 21; +pub const SYS_umount: ::c_long = 4000 + 22; +pub const SYS_setuid: ::c_long = 4000 + 23; +pub const SYS_getuid: ::c_long = 4000 + 24; +pub const SYS_stime: ::c_long = 4000 + 25; +pub const SYS_ptrace: ::c_long = 4000 + 26; +pub const SYS_alarm: ::c_long = 4000 + 27; +pub const SYS_pause: ::c_long = 4000 + 29; +pub const SYS_utime: ::c_long = 4000 + 30; +pub const SYS_stty: ::c_long = 4000 + 31; +pub const SYS_gtty: ::c_long = 4000 + 32; +pub const SYS_access: ::c_long = 4000 + 33; +pub const SYS_nice: ::c_long = 4000 + 34; +pub const SYS_ftime: ::c_long = 4000 + 35; +pub const SYS_sync: ::c_long = 4000 + 36; +pub const SYS_kill: ::c_long = 4000 + 37; +pub const SYS_rename: ::c_long = 4000 + 38; +pub const SYS_mkdir: ::c_long = 4000 + 39; +pub const SYS_rmdir: ::c_long = 4000 + 40; +pub const SYS_dup: ::c_long = 4000 + 41; +pub const SYS_pipe: ::c_long = 4000 + 42; +pub const SYS_times: ::c_long = 4000 + 43; +pub const SYS_prof: ::c_long = 4000 + 44; +pub const SYS_brk: ::c_long = 4000 + 45; +pub const SYS_setgid: ::c_long = 4000 + 46; +pub const SYS_getgid: ::c_long = 4000 + 47; +pub const SYS_signal: ::c_long = 4000 + 48; +pub const SYS_geteuid: ::c_long = 4000 + 49; +pub const SYS_getegid: ::c_long = 4000 + 50; +pub const SYS_acct: ::c_long = 4000 + 51; +pub const SYS_umount2: ::c_long = 4000 + 52; +pub const SYS_lock: ::c_long = 4000 + 53; +pub const SYS_ioctl: ::c_long = 4000 + 54; +pub const SYS_fcntl: ::c_long = 4000 + 55; +pub const SYS_mpx: ::c_long = 4000 + 56; +pub const SYS_setpgid: ::c_long = 4000 + 57; +pub const SYS_ulimit: ::c_long = 4000 + 58; +pub const SYS_umask: ::c_long = 4000 + 60; +pub const SYS_chroot: ::c_long = 4000 + 61; +pub const SYS_ustat: ::c_long = 4000 + 62; +pub const SYS_dup2: ::c_long = 4000 + 63; +pub const SYS_getppid: ::c_long = 4000 + 64; +pub const SYS_getpgrp: ::c_long = 4000 + 65; +pub const SYS_setsid: ::c_long = 4000 + 66; +pub const SYS_sigaction: ::c_long = 4000 + 67; +pub const SYS_sgetmask: ::c_long = 4000 + 68; +pub const SYS_ssetmask: ::c_long = 4000 + 69; +pub const SYS_setreuid: ::c_long = 4000 + 70; +pub const SYS_setregid: ::c_long = 4000 + 71; +pub const SYS_sigsuspend: ::c_long = 4000 + 72; +pub const SYS_sigpending: ::c_long = 4000 + 73; +pub const SYS_sethostname: ::c_long = 4000 + 74; +pub const SYS_setrlimit: ::c_long = 4000 + 75; +pub const SYS_getrlimit: ::c_long = 4000 + 76; +pub const SYS_getrusage: ::c_long = 4000 + 77; +pub const SYS_gettimeofday: ::c_long = 4000 + 78; +pub const SYS_settimeofday: ::c_long = 4000 + 79; +pub const SYS_getgroups: ::c_long = 4000 + 80; +pub const SYS_setgroups: ::c_long = 4000 + 81; +pub const SYS_symlink: ::c_long = 4000 + 83; +pub const SYS_readlink: ::c_long = 4000 + 85; +pub const SYS_uselib: ::c_long = 4000 + 86; +pub const SYS_swapon: ::c_long = 4000 + 87; +pub const SYS_reboot: ::c_long = 4000 + 88; +pub const SYS_readdir: ::c_long = 4000 + 89; +pub const SYS_mmap: ::c_long = 4000 + 90; +pub const SYS_munmap: ::c_long = 4000 + 91; +pub const SYS_truncate: ::c_long = 4000 + 92; +pub const SYS_ftruncate: ::c_long = 4000 + 93; +pub const SYS_fchmod: ::c_long = 4000 + 94; +pub const SYS_fchown: ::c_long = 4000 + 95; +pub const SYS_getpriority: ::c_long = 4000 + 96; +pub const SYS_setpriority: ::c_long = 4000 + 97; +pub const SYS_profil: ::c_long = 4000 + 98; +pub const SYS_statfs: ::c_long = 4000 + 99; +pub const SYS_fstatfs: ::c_long = 4000 + 100; +pub const SYS_ioperm: ::c_long = 4000 + 101; +pub const SYS_socketcall: ::c_long = 4000 + 102; +pub const SYS_syslog: ::c_long = 4000 + 103; +pub const SYS_setitimer: ::c_long = 4000 + 104; +pub const SYS_getitimer: ::c_long = 4000 + 105; +pub const SYS_stat: ::c_long = 4000 + 106; +pub const SYS_lstat: ::c_long = 4000 + 107; +pub const SYS_fstat: ::c_long = 4000 + 108; +pub const SYS_iopl: ::c_long = 4000 + 110; +pub const SYS_vhangup: ::c_long = 4000 + 111; +pub const SYS_idle: ::c_long = 4000 + 112; +pub const SYS_vm86: ::c_long = 4000 + 113; +pub const SYS_wait4: ::c_long = 4000 + 114; +pub const SYS_swapoff: ::c_long = 4000 + 115; +pub const SYS_sysinfo: ::c_long = 4000 + 116; +pub const SYS_ipc: ::c_long = 4000 + 117; +pub const SYS_fsync: ::c_long = 4000 + 118; +pub const SYS_sigreturn: ::c_long = 4000 + 119; +pub const SYS_clone: ::c_long = 4000 + 120; +pub const SYS_setdomainname: ::c_long = 4000 + 121; +pub const SYS_uname: ::c_long = 4000 + 122; +pub const SYS_modify_ldt: ::c_long = 4000 + 123; +pub const SYS_adjtimex: ::c_long = 4000 + 124; +pub const SYS_mprotect: ::c_long = 4000 + 125; +pub const SYS_sigprocmask: ::c_long = 4000 + 126; +pub const SYS_create_module: ::c_long = 4000 + 127; +pub const SYS_init_module: ::c_long = 4000 + 128; +pub const SYS_delete_module: ::c_long = 4000 + 129; +pub const SYS_get_kernel_syms: ::c_long = 4000 + 130; +pub const SYS_quotactl: ::c_long = 4000 + 131; +pub const SYS_getpgid: ::c_long = 4000 + 132; +pub const SYS_fchdir: ::c_long = 4000 + 133; +pub const SYS_bdflush: ::c_long = 4000 + 134; +pub const SYS_sysfs: ::c_long = 4000 + 135; +pub const SYS_personality: ::c_long = 4000 + 136; +pub const SYS_afs_syscall: ::c_long = 4000 + 137; +pub const SYS_setfsuid: ::c_long = 4000 + 138; +pub const SYS_setfsgid: ::c_long = 4000 + 139; +pub const SYS__llseek: ::c_long = 4000 + 140; +pub const SYS_getdents: ::c_long = 4000 + 141; +pub const SYS__newselect: ::c_long = 4000 + 142; +pub const SYS_flock: ::c_long = 4000 + 143; +pub const SYS_msync: ::c_long = 4000 + 144; +pub const SYS_readv: ::c_long = 4000 + 145; +pub const SYS_writev: ::c_long = 4000 + 146; +pub const SYS_cacheflush: ::c_long = 4000 + 147; +pub const SYS_cachectl: ::c_long = 4000 + 148; +pub const SYS_sysmips: ::c_long = 4000 + 149; +pub const SYS_getsid: ::c_long = 4000 + 151; +pub const SYS_fdatasync: ::c_long = 4000 + 152; +pub const SYS__sysctl: ::c_long = 4000 + 153; +pub const SYS_mlock: ::c_long = 4000 + 154; +pub const SYS_munlock: ::c_long = 4000 + 155; +pub const SYS_mlockall: ::c_long = 4000 + 156; +pub const SYS_munlockall: ::c_long = 4000 + 157; +pub const SYS_sched_setparam: ::c_long = 4000 + 158; +pub const SYS_sched_getparam: ::c_long = 4000 + 159; +pub const SYS_sched_setscheduler: ::c_long = 4000 + 160; +pub const SYS_sched_getscheduler: ::c_long = 4000 + 161; +pub const SYS_sched_yield: ::c_long = 4000 + 162; +pub const SYS_sched_get_priority_max: ::c_long = 4000 + 163; +pub const SYS_sched_get_priority_min: ::c_long = 4000 + 164; +pub const SYS_sched_rr_get_interval: ::c_long = 4000 + 165; +pub const SYS_nanosleep: ::c_long = 4000 + 166; +pub const SYS_mremap: ::c_long = 4000 + 167; +pub const SYS_accept: ::c_long = 4000 + 168; +pub const SYS_bind: ::c_long = 4000 + 169; +pub const SYS_connect: ::c_long = 4000 + 170; +pub const SYS_getpeername: ::c_long = 4000 + 171; +pub const SYS_getsockname: ::c_long = 4000 + 172; +pub const SYS_getsockopt: ::c_long = 4000 + 173; +pub const SYS_listen: ::c_long = 4000 + 174; +pub const SYS_recv: ::c_long = 4000 + 175; +pub const SYS_recvfrom: ::c_long = 4000 + 176; +pub const SYS_recvmsg: ::c_long = 4000 + 177; +pub const SYS_send: ::c_long = 4000 + 178; +pub const SYS_sendmsg: ::c_long = 4000 + 179; +pub const SYS_sendto: ::c_long = 4000 + 180; +pub const SYS_setsockopt: ::c_long = 4000 + 181; +pub const SYS_shutdown: ::c_long = 4000 + 182; +pub const SYS_socket: ::c_long = 4000 + 183; +pub const SYS_socketpair: ::c_long = 4000 + 184; +pub const SYS_setresuid: ::c_long = 4000 + 185; +pub const SYS_getresuid: ::c_long = 4000 + 186; +pub const SYS_query_module: ::c_long = 4000 + 187; +pub const SYS_poll: ::c_long = 4000 + 188; +pub const SYS_nfsservctl: ::c_long = 4000 + 189; +pub const SYS_setresgid: ::c_long = 4000 + 190; +pub const SYS_getresgid: ::c_long = 4000 + 191; +pub const SYS_prctl: ::c_long = 4000 + 192; +pub const SYS_rt_sigreturn: ::c_long = 4000 + 193; +pub const SYS_rt_sigaction: ::c_long = 4000 + 194; +pub const SYS_rt_sigprocmask: ::c_long = 4000 + 195; +pub const SYS_rt_sigpending: ::c_long = 4000 + 196; +pub const SYS_rt_sigtimedwait: ::c_long = 4000 + 197; +pub const SYS_rt_sigqueueinfo: ::c_long = 4000 + 198; +pub const SYS_rt_sigsuspend: ::c_long = 4000 + 199; +pub const SYS_pread64: ::c_long = 4000 + 200; +pub const SYS_pwrite64: ::c_long = 4000 + 201; +pub const SYS_chown: ::c_long = 4000 + 202; +pub const SYS_getcwd: ::c_long = 4000 + 203; +pub const SYS_capget: ::c_long = 4000 + 204; +pub const SYS_capset: ::c_long = 4000 + 205; +pub const SYS_sigaltstack: ::c_long = 4000 + 206; +pub const SYS_sendfile: ::c_long = 4000 + 207; +pub const SYS_getpmsg: ::c_long = 4000 + 208; +pub const SYS_putpmsg: ::c_long = 4000 + 209; +pub const SYS_mmap2: ::c_long = 4000 + 210; +pub const SYS_truncate64: ::c_long = 4000 + 211; +pub const SYS_ftruncate64: ::c_long = 4000 + 212; +pub const SYS_stat64: ::c_long = 4000 + 213; +pub const SYS_lstat64: ::c_long = 4000 + 214; +pub const SYS_fstat64: ::c_long = 4000 + 215; +pub const SYS_pivot_root: ::c_long = 4000 + 216; +pub const SYS_mincore: ::c_long = 4000 + 217; +pub const SYS_madvise: ::c_long = 4000 + 218; +pub const SYS_getdents64: ::c_long = 4000 + 219; +pub const SYS_fcntl64: ::c_long = 4000 + 220; +pub const SYS_gettid: ::c_long = 4000 + 222; +pub const SYS_readahead: ::c_long = 4000 + 223; +pub const SYS_setxattr: ::c_long = 4000 + 224; +pub const SYS_lsetxattr: ::c_long = 4000 + 225; +pub const SYS_fsetxattr: ::c_long = 4000 + 226; +pub const SYS_getxattr: ::c_long = 4000 + 227; +pub const SYS_lgetxattr: ::c_long = 4000 + 228; +pub const SYS_fgetxattr: ::c_long = 4000 + 229; +pub const SYS_listxattr: ::c_long = 4000 + 230; +pub const SYS_llistxattr: ::c_long = 4000 + 231; +pub const SYS_flistxattr: ::c_long = 4000 + 232; +pub const SYS_removexattr: ::c_long = 4000 + 233; +pub const SYS_lremovexattr: ::c_long = 4000 + 234; +pub const SYS_fremovexattr: ::c_long = 4000 + 235; +pub const SYS_tkill: ::c_long = 4000 + 236; +pub const SYS_sendfile64: ::c_long = 4000 + 237; +pub const SYS_futex: ::c_long = 4000 + 238; +pub const SYS_sched_setaffinity: ::c_long = 4000 + 239; +pub const SYS_sched_getaffinity: ::c_long = 4000 + 240; +pub const SYS_io_setup: ::c_long = 4000 + 241; +pub const SYS_io_destroy: ::c_long = 4000 + 242; +pub const SYS_io_getevents: ::c_long = 4000 + 243; +pub const SYS_io_submit: ::c_long = 4000 + 244; +pub const SYS_io_cancel: ::c_long = 4000 + 245; +pub const SYS_exit_group: ::c_long = 4000 + 246; +pub const SYS_lookup_dcookie: ::c_long = 4000 + 247; +pub const SYS_epoll_create: ::c_long = 4000 + 248; +pub const SYS_epoll_ctl: ::c_long = 4000 + 249; +pub const SYS_epoll_wait: ::c_long = 4000 + 250; +pub const SYS_remap_file_pages: ::c_long = 4000 + 251; +pub const SYS_set_tid_address: ::c_long = 4000 + 252; +pub const SYS_restart_syscall: ::c_long = 4000 + 253; +pub const SYS_fadvise64: ::c_long = 4000 + 254; +pub const SYS_statfs64: ::c_long = 4000 + 255; +pub const SYS_fstatfs64: ::c_long = 4000 + 256; +pub const SYS_timer_create: ::c_long = 4000 + 257; +pub const SYS_timer_settime: ::c_long = 4000 + 258; +pub const SYS_timer_gettime: ::c_long = 4000 + 259; +pub const SYS_timer_getoverrun: ::c_long = 4000 + 260; +pub const SYS_timer_delete: ::c_long = 4000 + 261; +pub const SYS_clock_settime: ::c_long = 4000 + 262; +pub const SYS_clock_gettime: ::c_long = 4000 + 263; +pub const SYS_clock_getres: ::c_long = 4000 + 264; +pub const SYS_clock_nanosleep: ::c_long = 4000 + 265; +pub const SYS_tgkill: ::c_long = 4000 + 266; +pub const SYS_utimes: ::c_long = 4000 + 267; +pub const SYS_mbind: ::c_long = 4000 + 268; +pub const SYS_get_mempolicy: ::c_long = 4000 + 269; +pub const SYS_set_mempolicy: ::c_long = 4000 + 270; +pub const SYS_mq_open: ::c_long = 4000 + 271; +pub const SYS_mq_unlink: ::c_long = 4000 + 272; +pub const SYS_mq_timedsend: ::c_long = 4000 + 273; +pub const SYS_mq_timedreceive: ::c_long = 4000 + 274; +pub const SYS_mq_notify: ::c_long = 4000 + 275; +pub const SYS_mq_getsetattr: ::c_long = 4000 + 276; +pub const SYS_vserver: ::c_long = 4000 + 277; +pub const SYS_waitid: ::c_long = 4000 + 278; +/* pub const SYS_sys_setaltroot: ::c_long = 4000 + 279; */ +pub const SYS_add_key: ::c_long = 4000 + 280; +pub const SYS_request_key: ::c_long = 4000 + 281; +pub const SYS_keyctl: ::c_long = 4000 + 282; +pub const SYS_set_thread_area: ::c_long = 4000 + 283; +pub const SYS_inotify_init: ::c_long = 4000 + 284; +pub const SYS_inotify_add_watch: ::c_long = 4000 + 285; +pub const SYS_inotify_rm_watch: ::c_long = 4000 + 286; +pub const SYS_migrate_pages: ::c_long = 4000 + 287; +pub const SYS_openat: ::c_long = 4000 + 288; +pub const SYS_mkdirat: ::c_long = 4000 + 289; +pub const SYS_mknodat: ::c_long = 4000 + 290; +pub const SYS_fchownat: ::c_long = 4000 + 291; +pub const SYS_futimesat: ::c_long = 4000 + 292; +pub const SYS_fstatat64: ::c_long = 4000 + 293; +pub const SYS_unlinkat: ::c_long = 4000 + 294; +pub const SYS_renameat: ::c_long = 4000 + 295; +pub const SYS_linkat: ::c_long = 4000 + 296; +pub const SYS_symlinkat: ::c_long = 4000 + 297; +pub const SYS_readlinkat: ::c_long = 4000 + 298; +pub const SYS_fchmodat: ::c_long = 4000 + 299; +pub const SYS_faccessat: ::c_long = 4000 + 300; +pub const SYS_pselect6: ::c_long = 4000 + 301; +pub const SYS_ppoll: ::c_long = 4000 + 302; +pub const SYS_unshare: ::c_long = 4000 + 303; +pub const SYS_splice: ::c_long = 4000 + 304; +pub const SYS_sync_file_range: ::c_long = 4000 + 305; +pub const SYS_tee: ::c_long = 4000 + 306; +pub const SYS_vmsplice: ::c_long = 4000 + 307; +pub const SYS_move_pages: ::c_long = 4000 + 308; +pub const SYS_set_robust_list: ::c_long = 4000 + 309; +pub const SYS_get_robust_list: ::c_long = 4000 + 310; +pub const SYS_kexec_load: ::c_long = 4000 + 311; +pub const SYS_getcpu: ::c_long = 4000 + 312; +pub const SYS_epoll_pwait: ::c_long = 4000 + 313; +pub const SYS_ioprio_set: ::c_long = 4000 + 314; +pub const SYS_ioprio_get: ::c_long = 4000 + 315; +pub const SYS_utimensat: ::c_long = 4000 + 316; +pub const SYS_signalfd: ::c_long = 4000 + 317; +pub const SYS_timerfd: ::c_long = 4000 + 318; +pub const SYS_eventfd: ::c_long = 4000 + 319; +pub const SYS_fallocate: ::c_long = 4000 + 320; +pub const SYS_timerfd_create: ::c_long = 4000 + 321; +pub const SYS_timerfd_gettime: ::c_long = 4000 + 322; +pub const SYS_timerfd_settime: ::c_long = 4000 + 323; +pub const SYS_signalfd4: ::c_long = 4000 + 324; +pub const SYS_eventfd2: ::c_long = 4000 + 325; +pub const SYS_epoll_create1: ::c_long = 4000 + 326; +pub const SYS_dup3: ::c_long = 4000 + 327; +pub const SYS_pipe2: ::c_long = 4000 + 328; +pub const SYS_inotify_init1: ::c_long = 4000 + 329; +pub const SYS_preadv: ::c_long = 4000 + 330; +pub const SYS_pwritev: ::c_long = 4000 + 331; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 4000 + 332; +pub const SYS_perf_event_open: ::c_long = 4000 + 333; +pub const SYS_accept4: ::c_long = 4000 + 334; +pub const SYS_recvmmsg: ::c_long = 4000 + 335; +pub const SYS_fanotify_init: ::c_long = 4000 + 336; +pub const SYS_fanotify_mark: ::c_long = 4000 + 337; +pub const SYS_prlimit64: ::c_long = 4000 + 338; +pub const SYS_name_to_handle_at: ::c_long = 4000 + 339; +pub const SYS_open_by_handle_at: ::c_long = 4000 + 340; +pub const SYS_clock_adjtime: ::c_long = 4000 + 341; +pub const SYS_syncfs: ::c_long = 4000 + 342; +pub const SYS_sendmmsg: ::c_long = 4000 + 343; +pub const SYS_setns: ::c_long = 4000 + 344; +pub const SYS_process_vm_readv: ::c_long = 4000 + 345; +pub const SYS_process_vm_writev: ::c_long = 4000 + 346; +pub const SYS_kcmp: ::c_long = 4000 + 347; +pub const SYS_finit_module: ::c_long = 4000 + 348; +pub const SYS_sched_setattr: ::c_long = 4000 + 349; +pub const SYS_sched_getattr: ::c_long = 4000 + 350; +pub const SYS_renameat2: ::c_long = 4000 + 351; +pub const SYS_seccomp: ::c_long = 4000 + 352; +pub const SYS_getrandom: ::c_long = 4000 + 353; +pub const SYS_memfd_create: ::c_long = 4000 + 354; +pub const SYS_bpf: ::c_long = 4000 + 355; +pub const SYS_execveat: ::c_long = 4000 + 356; +pub const SYS_userfaultfd: ::c_long = 4000 + 357; +pub const SYS_membarrier: ::c_long = 4000 + 358; +pub const SYS_mlock2: ::c_long = 4000 + 359; +pub const SYS_copy_file_range: ::c_long = 4000 + 360; +pub const SYS_preadv2: ::c_long = 4000 + 361; +pub const SYS_pwritev2: ::c_long = 4000 + 362; +pub const SYS_pkey_mprotect: ::c_long = 4000 + 363; +pub const SYS_pkey_alloc: ::c_long = 4000 + 364; +pub const SYS_pkey_free: ::c_long = 4000 + 365; + +#[link(name = "util")] +extern "C" { + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; + pub fn glob64( + pattern: *const ::c_char, + flags: ::c_int, + errfunc: ::Option< + extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int, + >, + pglob: *mut glob64_t, + ) -> ::c_int; + pub fn globfree64(pglob: *mut glob64_t); + pub fn ptrace(request: ::c_uint, ...) -> ::c_long; + pub fn pthread_attr_getaffinity_np( + attr: *const ::pthread_attr_t, + cpusetsize: ::size_t, + cpuset: *mut ::cpu_set_t, + ) -> ::c_int; + pub fn pthread_attr_setaffinity_np( + attr: *mut ::pthread_attr_t, + cpusetsize: ::size_t, + cpuset: *const ::cpu_set_t, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips32/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips32/no_align.rs new file mode 100644 index 0000000..e32bf67 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips32/no_align.rs @@ -0,0 +1,10 @@ +s! { + // FIXME this is actually a union + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + __align: [::c_long; 0], + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips64/align.rs new file mode 100644 index 0000000..21e2190 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips64/align.rs @@ -0,0 +1,10 @@ +s! { + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + __size: [::c_char; 32], + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips64/mod.rs new file mode 100644 index 0000000..735eb85 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips64/mod.rs @@ -0,0 +1,213 @@ +pub type blkcnt_t = i64; +pub type blksize_t = i64; +pub type c_char = i8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type fsblkcnt_t = ::c_ulong; +pub type fsfilcnt_t = ::c_ulong; +pub type ino_t = u64; +pub type nlink_t = u64; +pub type off_t = i64; +pub type rlim_t = ::c_ulong; +pub type suseconds_t = i64; +pub type time_t = i64; +pub type wchar_t = i32; + +s! { + pub struct stat { + pub st_dev: ::c_ulong, + st_pad1: [::c_long; 2], + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulong, + st_pad2: [::c_ulong; 1], + pub st_size: ::off_t, + st_pad3: ::c_long, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + st_pad4: ::c_long, + pub st_blocks: ::blkcnt_t, + st_pad5: [::c_long; 7], + } + + pub struct stat64 { + pub st_dev: ::c_ulong, + st_pad1: [::c_long; 2], + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulong, + st_pad2: [::c_long; 2], + pub st_size: ::off64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + st_pad3: ::c_long, + pub st_blocks: ::blkcnt64_t, + st_pad5: [::c_long; 7], + } + + pub struct pthread_attr_t { + __size: [::c_ulong; 7] + } + + pub struct sigaction { + pub sa_flags: ::c_int, + pub sa_sigaction: ::sighandler_t, + pub sa_mask: sigset_t, + _restorer: *mut ::c_void, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct sigset_t { + __size: [::c_ulong; 16], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + _pad: ::c_int, + _pad2: [::c_long; 14], + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_uint, + pub __seq: ::c_ushort, + __pad1: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused4: ::c_ulong, + __unused5: ::c_ulong + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + pub msg_rtime: ::time_t, + pub msg_ctime: ::time_t, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved4: ::c_ulong, + __glibc_reserved5: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_frsize: ::c_long, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_files: ::fsblkcnt_t, + pub f_ffree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::c_long, + f_spare: [::c_long; 6], + } + + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::size_t, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::size_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::size_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + } + + pub struct sysinfo { + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 0], + } +} + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + +pub const RLIM_INFINITY: ::rlim_t = 0xffff_ffff_ffff_ffff; + +pub const SYS_gettid: ::c_long = 5178; // Valid for n64 + +#[link(name = "util")] +extern "C" { + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips64/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips64/no_align.rs new file mode 100644 index 0000000..8909114 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mips64/no_align.rs @@ -0,0 +1,7 @@ +s! { + // FIXME this is actually a union + pub struct sem_t { + __size: [::c_char; 32], + __align: [::c_long; 0], + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mod.rs new file mode 100644 index 0000000..6a9b41c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mips/mod.rs @@ -0,0 +1,479 @@ +pub type pthread_t = ::c_ulong; + +pub const SFD_CLOEXEC: ::c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: ::c_int = 512; + +pub const O_CLOEXEC: ::c_int = 0x80000; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; + +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; + +pub const EFD_CLOEXEC: ::c_int = 0x80000; + +pub const BUFSIZ: ::c_uint = 4096; +pub const TMP_MAX: ::c_uint = 238328; +pub const FOPEN_MAX: ::c_uint = 16; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; +pub const _SC_2_C_VERSION: ::c_int = 96; +pub const O_ACCMODE: ::c_int = 3; +pub const O_DIRECT: ::c_int = 0x8000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const ST_RELATIME: ::c_ulong = 4096; +pub const NI_MAXHOST: ::socklen_t = 1025; + +pub const RLIMIT_NOFILE: ::c_int = 5; +pub const RLIMIT_AS: ::c_int = 6; +pub const RLIMIT_RSS: ::c_int = 7; +pub const RLIMIT_NPROC: ::c_int = 8; +pub const RLIMIT_MEMLOCK: ::c_int = 9; +pub const RLIMIT_NLIMITS: ::c_int = 15; + +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 256; +pub const O_EXCL: ::c_int = 1024; +pub const O_NOCTTY: ::c_int = 2048; +pub const O_NONBLOCK: ::c_int = 128; +pub const O_SYNC: ::c_int = 0x10; +pub const O_RSYNC: ::c_int = 0x10; +pub const O_DSYNC: ::c_int = 0x10; +pub const O_FSYNC: ::c_int = 0x10; +pub const O_ASYNC: ::c_int = 0x1000; +pub const O_NDELAY: ::c_int = 0x80; + +pub const SOCK_NONBLOCK: ::c_int = 128; + +pub const EDEADLK: ::c_int = 45; +pub const ENAMETOOLONG: ::c_int = 78; +pub const ENOLCK: ::c_int = 46; +pub const ENOSYS: ::c_int = 89; +pub const ENOTEMPTY: ::c_int = 93; +pub const ELOOP: ::c_int = 90; +pub const ENOMSG: ::c_int = 35; +pub const EIDRM: ::c_int = 36; +pub const ECHRNG: ::c_int = 37; +pub const EL2NSYNC: ::c_int = 38; +pub const EL3HLT: ::c_int = 39; +pub const EL3RST: ::c_int = 40; +pub const ELNRNG: ::c_int = 41; +pub const EUNATCH: ::c_int = 42; +pub const ENOCSI: ::c_int = 43; +pub const EL2HLT: ::c_int = 44; +pub const EBADE: ::c_int = 50; +pub const EBADR: ::c_int = 51; +pub const EXFULL: ::c_int = 52; +pub const ENOANO: ::c_int = 53; +pub const EBADRQC: ::c_int = 54; +pub const EBADSLT: ::c_int = 55; +pub const EDEADLOCK: ::c_int = 56; +pub const EMULTIHOP: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 79; +pub const ENOTUNIQ: ::c_int = 80; +pub const EBADFD: ::c_int = 81; +pub const EBADMSG: ::c_int = 77; +pub const EREMCHG: ::c_int = 82; +pub const ELIBACC: ::c_int = 83; +pub const ELIBBAD: ::c_int = 84; +pub const ELIBSCN: ::c_int = 85; +pub const ELIBMAX: ::c_int = 86; +pub const ELIBEXEC: ::c_int = 87; +pub const EILSEQ: ::c_int = 88; +pub const ERESTART: ::c_int = 91; +pub const ESTRPIPE: ::c_int = 92; +pub const EUSERS: ::c_int = 94; +pub const ENOTSOCK: ::c_int = 95; +pub const EDESTADDRREQ: ::c_int = 96; +pub const EMSGSIZE: ::c_int = 97; +pub const EPROTOTYPE: ::c_int = 98; +pub const ENOPROTOOPT: ::c_int = 99; +pub const EPROTONOSUPPORT: ::c_int = 120; +pub const ESOCKTNOSUPPORT: ::c_int = 121; +pub const EOPNOTSUPP: ::c_int = 122; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: ::c_int = 123; +pub const EAFNOSUPPORT: ::c_int = 124; +pub const EADDRINUSE: ::c_int = 125; +pub const EADDRNOTAVAIL: ::c_int = 126; +pub const ENETDOWN: ::c_int = 127; +pub const ENETUNREACH: ::c_int = 128; +pub const ENETRESET: ::c_int = 129; +pub const ECONNABORTED: ::c_int = 130; +pub const ECONNRESET: ::c_int = 131; +pub const ENOBUFS: ::c_int = 132; +pub const EISCONN: ::c_int = 133; +pub const ENOTCONN: ::c_int = 134; +pub const ESHUTDOWN: ::c_int = 143; +pub const ETOOMANYREFS: ::c_int = 144; +pub const ETIMEDOUT: ::c_int = 145; +pub const ECONNREFUSED: ::c_int = 146; +pub const EHOSTDOWN: ::c_int = 147; +pub const EHOSTUNREACH: ::c_int = 148; +pub const EALREADY: ::c_int = 149; +pub const EINPROGRESS: ::c_int = 150; +pub const ESTALE: ::c_int = 151; +pub const EUCLEAN: ::c_int = 135; +pub const ENOTNAM: ::c_int = 137; +pub const ENAVAIL: ::c_int = 138; +pub const EISNAM: ::c_int = 139; +pub const EREMOTEIO: ::c_int = 140; +pub const EDQUOT: ::c_int = 1133; +pub const ENOMEDIUM: ::c_int = 159; +pub const EMEDIUMTYPE: ::c_int = 160; +pub const ECANCELED: ::c_int = 158; +pub const ENOKEY: ::c_int = 161; +pub const EKEYEXPIRED: ::c_int = 162; +pub const EKEYREVOKED: ::c_int = 163; +pub const EKEYREJECTED: ::c_int = 164; +pub const EOWNERDEAD: ::c_int = 165; +pub const ENOTRECOVERABLE: ::c_int = 166; +pub const ERFKILL: ::c_int = 167; + +pub const MAP_NORESERVE: ::c_int = 0x400; +pub const MAP_ANON: ::c_int = 0x800; +pub const MAP_ANONYMOUS: ::c_int = 0x800; +pub const MAP_GROWSDOWN: ::c_int = 0x1000; +pub const MAP_DENYWRITE: ::c_int = 0x2000; +pub const MAP_EXECUTABLE: ::c_int = 0x4000; +pub const MAP_LOCKED: ::c_int = 0x8000; +pub const MAP_POPULATE: ::c_int = 0x10000; +pub const MAP_NONBLOCK: ::c_int = 0x20000; +pub const MAP_STACK: ::c_int = 0x40000; + +pub const SOCK_STREAM: ::c_int = 2; +pub const SOCK_DGRAM: ::c_int = 1; +pub const SOCK_SEQPACKET: ::c_int = 5; + +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_STYLE: ::c_int = SO_TYPE; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ACCEPTCONN: ::c_int = 0x1009; +pub const SO_PROTOCOL: ::c_int = 0x1028; +pub const SO_DOMAIN: ::c_int = 0x1029; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_PASSCRED: ::c_int = 17; +pub const SO_PEERCRED: ::c_int = 18; +pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: ::c_int = 28; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; +pub const SO_PEERSEC: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 31; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PASSSEC: ::c_int = 34; +pub const SO_TIMESTAMPNS: ::c_int = 35; +pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; +pub const SO_MARK: ::c_int = 36; +pub const SO_TIMESTAMPING: ::c_int = 37; +pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_WIFI_STATUS: ::c_int = 41; +pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_NOFCS: ::c_int = 43; +pub const SO_LOCK_FILTER: ::c_int = 44; +pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; +pub const SO_BUSY_POLL: ::c_int = 46; +pub const SO_MAX_PACING_RATE: ::c_int = 47; +pub const SO_BPF_EXTENSIONS: ::c_int = 48; + +pub const FIOCLEX: ::c_ulong = 0x6601; +pub const FIONCLEX: ::c_ulong = 0x6602; +pub const FIONBIO: ::c_ulong = 0x667e; + +pub const SA_ONSTACK: ::c_uint = 0x08000000; +pub const SA_SIGINFO: ::c_uint = 0x00000008; +pub const SA_NOCLDWAIT: ::c_int = 0x00010000; + +pub const SIGCHLD: ::c_int = 18; +pub const SIGBUS: ::c_int = 10; +pub const SIGTTIN: ::c_int = 26; +pub const SIGTTOU: ::c_int = 27; +pub const SIGXCPU: ::c_int = 30; +pub const SIGXFSZ: ::c_int = 31; +pub const SIGVTALRM: ::c_int = 28; +pub const SIGPROF: ::c_int = 29; +pub const SIGWINCH: ::c_int = 20; +pub const SIGUSR1: ::c_int = 16; +pub const SIGUSR2: ::c_int = 17; +pub const SIGCONT: ::c_int = 25; +pub const SIGSTOP: ::c_int = 23; +pub const SIGTSTP: ::c_int = 24; +pub const SIGURG: ::c_int = 21; +pub const SIGIO: ::c_int = 22; +pub const SIGSYS: ::c_int = 12; +pub const SIGPOLL: ::c_int = 22; +pub const SIGPWR: ::c_int = 19; +pub const SIG_SETMASK: ::c_int = 3; +pub const SIG_BLOCK: ::c_int = 0x1; +pub const SIG_UNBLOCK: ::c_int = 0x2; + +pub const POLLRDNORM: ::c_short = 0x040; +pub const POLLWRNORM: ::c_short = 0x004; +pub const POLLRDBAND: ::c_short = 0x080; +pub const POLLWRBAND: ::c_short = 0x100; + +pub const PTHREAD_STACK_MIN: ::size_t = 16384; + +pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; +pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; +pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; +pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; +pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; +pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; +pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; +pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; +pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; +pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; +pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; +pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; +pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; +pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; +pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; +pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; +pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; +pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; +pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; +pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; +pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; +pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; +pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; +pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; +pub const TMPFS_MAGIC: ::c_long = 0x01021994; +pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; + +pub const VEOF: usize = 16; +pub const VEOL: usize = 17; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: ::tcflag_t = 0x00000100; +pub const TOSTOP: ::tcflag_t = 0x00008000; +pub const FLUSHO: ::tcflag_t = 0x00002000; +pub const IUTF8: ::tcflag_t = 0x00004000; +pub const TCSANOW: ::c_int = 0x540e; +pub const TCSADRAIN: ::c_int = 0x540f; +pub const TCSAFLUSH: ::c_int = 0x5410; + +pub const CPU_SETSIZE: ::c_int = 0x400; + +pub const PTRACE_TRACEME: ::c_uint = 0; +pub const PTRACE_PEEKTEXT: ::c_uint = 1; +pub const PTRACE_PEEKDATA: ::c_uint = 2; +pub const PTRACE_PEEKUSER: ::c_uint = 3; +pub const PTRACE_POKETEXT: ::c_uint = 4; +pub const PTRACE_POKEDATA: ::c_uint = 5; +pub const PTRACE_POKEUSER: ::c_uint = 6; +pub const PTRACE_CONT: ::c_uint = 7; +pub const PTRACE_KILL: ::c_uint = 8; +pub const PTRACE_SINGLESTEP: ::c_uint = 9; +pub const PTRACE_ATTACH: ::c_uint = 16; +pub const PTRACE_DETACH: ::c_uint = 17; +pub const PTRACE_SYSCALL: ::c_uint = 24; +pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; +pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; +pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; +pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; +pub const PTRACE_GETFPREGS: ::c_uint = 14; +pub const PTRACE_SETFPREGS: ::c_uint = 15; +pub const PTRACE_GETFPXREGS: ::c_uint = 18; +pub const PTRACE_SETFPXREGS: ::c_uint = 19; +pub const PTRACE_GETREGS: ::c_uint = 12; +pub const PTRACE_SETREGS: ::c_uint = 13; + +pub const EFD_NONBLOCK: ::c_int = 0x80; + +pub const F_GETLK: ::c_int = 14; +pub const F_GETOWN: ::c_int = 23; +pub const F_SETOWN: ::c_int = 24; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; + +pub const SFD_NONBLOCK: ::c_int = 0x80; + +pub const TCGETS: ::c_ulong = 0x540d; +pub const TCSETS: ::c_ulong = 0x540e; +pub const TCSETSW: ::c_ulong = 0x540f; +pub const TCSETSF: ::c_ulong = 0x5410; +pub const TCGETA: ::c_ulong = 0x5401; +pub const TCSETA: ::c_ulong = 0x5402; +pub const TCSETAW: ::c_ulong = 0x5403; +pub const TCSETAF: ::c_ulong = 0x5404; +pub const TCSBRK: ::c_ulong = 0x5405; +pub const TCXONC: ::c_ulong = 0x5406; +pub const TCFLSH: ::c_ulong = 0x5407; +pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; +pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; +pub const TIOCINQ: ::c_ulong = 0x467f; +pub const TIOCLINUX: ::c_ulong = 0x5483; +pub const TIOCGSERIAL: ::c_ulong = 0x5484; +pub const TIOCEXCL: ::c_ulong = 0x740d; +pub const TIOCNXCL: ::c_ulong = 0x740e; +pub const TIOCSCTTY: ::c_ulong = 0x5480; +pub const TIOCGPGRP: ::c_ulong = 0x40047477; +pub const TIOCSPGRP: ::c_ulong = 0x80047476; +pub const TIOCOUTQ: ::c_ulong = 0x7472; +pub const TIOCSTI: ::c_ulong = 0x5472; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const TIOCMGET: ::c_ulong = 0x741d; +pub const TIOCMBIS: ::c_ulong = 0x741b; +pub const TIOCMBIC: ::c_ulong = 0x741c; +pub const TIOCMSET: ::c_ulong = 0x741a; +pub const FIONREAD: ::c_ulong = 0x467f; +pub const TIOCCONS: ::c_ulong = 0x80047478; + +pub const RTLD_DEEPBIND: ::c_int = 0x10; +pub const RTLD_GLOBAL: ::c_int = 0x4; +pub const RTLD_NOLOAD: ::c_int = 0x8; + +pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; +pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793; +pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278; +pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448; +pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216; + +pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567; +pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123; +pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF; +pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000; +pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC; +pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4; +pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2; +pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +cfg_if! { + if #[cfg(target_arch = "mips")] { + mod mips32; + pub use self::mips32::*; + } else if #[cfg(target_arch = "mips64")] { + mod mips64; + pub use self::mips64::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mod.rs new file mode 100644 index 0000000..b4fe036 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/mod.rs @@ -0,0 +1,2295 @@ +pub type sa_family_t = u16; +pub type pthread_key_t = ::c_uint; +pub type speed_t = ::c_uint; +pub type tcflag_t = ::c_uint; +pub type loff_t = ::c_longlong; +pub type clockid_t = ::c_int; +pub type key_t = ::c_int; +pub type id_t = ::c_uint; +pub type useconds_t = u32; +pub type dev_t = u64; +pub type socklen_t = u32; +pub type mode_t = u32; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; +pub type rlim64_t = u64; +pub type shmatt_t = ::c_ulong; +pub type mqd_t = ::c_int; +pub type msgqnum_t = ::c_ulong; +pub type msglen_t = ::c_ulong; +pub type nfds_t = ::c_ulong; +pub type nl_item = ::c_int; +pub type idtype_t = ::c_uint; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum fpos64_t {} // TODO: fill this out with a struct +impl ::Copy for fpos64_t {} +impl ::Clone for fpos64_t { + fn clone(&self) -> fpos64_t { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum timezone {} +impl ::Copy for timezone {} +impl ::Clone for timezone { + fn clone(&self) -> timezone { + *self + } +} + +s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: socklen_t, + + pub ai_addr: *mut ::sockaddr, + + pub ai_canonname: *mut c_char, + + pub ai_next: *mut addrinfo, + } + + pub struct sockaddr_ll { + pub sll_family: ::c_ushort, + pub sll_protocol: ::c_ushort, + pub sll_ifindex: ::c_int, + pub sll_hatype: ::c_ushort, + pub sll_pkttype: ::c_uchar, + pub sll_halen: ::c_uchar, + pub sll_addr: [::c_uchar; 8] + } + + pub struct fd_set { + fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], + } + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + pub tm_gmtoff: ::c_long, + pub tm_zone: *const ::c_char, + } + + pub struct sched_param { + pub sched_priority: ::c_int, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct rlimit64 { + pub rlim_cur: rlim64_t, + pub rlim_max: rlim64_t, + } + + pub struct glob_t { + pub gl_pathc: ::size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: ::c_uint, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union + pub ifa_data: *mut ::c_void + } + + pub struct pthread_rwlockattr_t { + __lockkind: ::c_int, + __pshared: ::c_int, + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct spwd { + pub sp_namp: *mut ::c_char, + pub sp_pwdp: *mut ::c_char, + pub sp_lstchg: ::c_long, + pub sp_min: ::c_long, + pub sp_max: ::c_long, + pub sp_warn: ::c_long, + pub sp_inact: ::c_long, + pub sp_expire: ::c_long, + pub sp_flag: ::c_ulong, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + #[cfg(target_endian = "little")] + pub f_fsid: ::c_ulong, + #[cfg(target_pointer_width = "32")] + __f_unused: ::c_int, + #[cfg(target_endian = "big")] + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct dqblk { + pub dqb_bhardlimit: u32, + pub dqb_bsoftlimit: u32, + pub dqb_curblocks: u32, + pub dqb_ihardlimit: u32, + pub dqb_isoftlimit: u32, + pub dqb_curinodes: u32, + pub dqb_btime: ::time_t, + pub dqb_itime: ::time_t, + } + + pub struct signalfd_siginfo { + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: u16, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: [u8; 28], + } + + pub struct fsid_t { + __val: [::c_int; 2], + } + + pub struct cpu_set_t { + #[cfg(target_pointer_width = "32")] + bits: [u32; 32], + #[cfg(target_pointer_width = "64")] + bits: [u64; 16], + } + + pub struct if_nameindex { + pub if_index: ::c_uint, + pub if_name: *mut ::c_char, + } + + // System V IPC + pub struct msginfo { + pub msgpool: ::c_int, + pub msgmap: ::c_int, + pub msgmax: ::c_int, + pub msgmnb: ::c_int, + pub msgmni: ::c_int, + pub msgssz: ::c_int, + pub msgtql: ::c_int, + pub msgseg: ::c_ushort, + } + + pub struct ucred { + pub pid: ::pid_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + } +} + +s_no_extra_traits! { + #[cfg_attr( + any(target_arch = "x86", target_arch = "x86_64"), + repr(packed) + )] + #[allow(missing_debug_implementations)] + pub struct epoll_event { + pub events: u32, + pub u64: u64, + } + + #[allow(missing_debug_implementations)] + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 108] + } + + #[allow(missing_debug_implementations)] + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + __ss_align: ::size_t, + #[cfg(target_pointer_width = "32")] + __ss_pad2: [u8; 128 - 2 * 4], + #[cfg(target_pointer_width = "64")] + __ss_pad2: [u8; 128 - 2 * 8], + } + + #[allow(missing_debug_implementations)] + pub struct utsname { + pub sysname: [::c_char; 65], + pub nodename: [::c_char; 65], + pub release: [::c_char; 65], + pub version: [::c_char; 65], + pub machine: [::c_char; 65], + pub domainname: [::c_char; 65] + } + + #[allow(missing_debug_implementations)] + pub struct dirent { + pub d_ino: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + #[allow(missing_debug_implementations)] + pub struct dirent64 { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct mq_attr { + pub mq_flags: ::c_long, + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_curmsgs: ::c_long, + pad: [::c_long; 4] + } + + pub struct sockaddr_nl { + pub nl_family: ::sa_family_t, + nl_pad: ::c_ushort, + pub nl_pid: u32, + pub nl_groups: u32 + } + + pub struct sigevent { + pub sigev_value: ::sigval, + pub sigev_signo: ::c_int, + pub sigev_notify: ::c_int, + // Actually a union. We only expose sigev_notify_thread_id because it's + // the most useful member + pub sigev_notify_thread_id: ::c_int, + #[cfg(target_pointer_width = "64")] + __unused1: [::c_int; 11], + #[cfg(target_pointer_width = "32")] + __unused1: [::c_int; 12] + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for mq_attr { + fn eq(&self, other: &mq_attr) -> bool { + self.mq_flags == other.mq_flags && + self.mq_maxmsg == other.mq_maxmsg && + self.mq_msgsize == other.mq_msgsize && + self.mq_curmsgs == other.mq_curmsgs + } + } + impl Eq for mq_attr {} + impl ::fmt::Debug for mq_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mq_attr") + .field("mq_flags", &self.mq_flags) + .field("mq_maxmsg", &self.mq_maxmsg) + .field("mq_msgsize", &self.mq_msgsize) + .field("mq_curmsgs", &self.mq_curmsgs) + .finish() + } + } + impl ::hash::Hash for mq_attr { + fn hash(&self, state: &mut H) { + self.mq_flags.hash(state); + self.mq_maxmsg.hash(state); + self.mq_msgsize.hash(state); + self.mq_curmsgs.hash(state); + } + } + + impl PartialEq for sockaddr_nl { + fn eq(&self, other: &sockaddr_nl) -> bool { + self.nl_family == other.nl_family && + self.nl_pid == other.nl_pid && + self.nl_groups == other.nl_groups + } + } + impl Eq for sockaddr_nl {} + impl ::fmt::Debug for sockaddr_nl { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_nl") + .field("nl_family", &self.nl_family) + .field("nl_pid", &self.nl_pid) + .field("nl_groups", &self.nl_groups) + .finish() + } + } + impl ::hash::Hash for sockaddr_nl { + fn hash(&self, state: &mut H) { + self.nl_family.hash(state); + self.nl_pid.hash(state); + self.nl_groups.hash(state); + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_value == other.sigev_value + && self.sigev_signo == other.sigev_signo + && self.sigev_notify == other.sigev_notify + && self.sigev_notify_thread_id + == other.sigev_notify_thread_id + } + } + impl Eq for sigevent {} + impl ::fmt::Debug for sigevent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sigevent") + .field("sigev_value", &self.sigev_value) + .field("sigev_signo", &self.sigev_signo) + .field("sigev_notify", &self.sigev_notify) + .field("sigev_notify_thread_id", + &self.sigev_notify_thread_id) + .finish() + } + } + impl ::hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_value.hash(state); + self.sigev_signo.hash(state); + self.sigev_notify.hash(state); + self.sigev_notify_thread_id.hash(state); + } + } + } +} + +// intentionally not public, only used for fd_set +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + const ULONG_SIZE: usize = 32; + } else if #[cfg(target_pointer_width = "64")] { + const ULONG_SIZE: usize = 64; + } else { + // Unknown target_pointer_width + } +} + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 2147483647; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 2; +pub const _IOLBF: ::c_int = 1; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; + +// Linux-specific fcntls +pub const F_SETLEASE: ::c_int = 1024; +pub const F_GETLEASE: ::c_int = 1025; +pub const F_NOTIFY: ::c_int = 1026; +pub const F_DUPFD_CLOEXEC: ::c_int = 1030; + +// TODO(#235): Include file sealing fcntls once we have a way to verify them. + +pub const SIGTRAP: ::c_int = 5; + +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; + +pub const CLOCK_REALTIME: ::clockid_t = 0; +pub const CLOCK_MONOTONIC: ::clockid_t = 1; +pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3; +// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep +// 2014.) See also musl/mod.rs +// pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; +// pub const CLOCK_TAI: ::clockid_t = 11; +pub const TIMER_ABSTIME: ::c_int = 1; + +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_LOCKS: ::c_int = 10; +pub const RLIMIT_SIGPENDING: ::c_int = 11; +pub const RLIMIT_MSGQUEUE: ::c_int = 12; +pub const RLIMIT_NICE: ::c_int = 13; +pub const RLIMIT_RTPRIO: ::c_int = 14; + +pub const RUSAGE_SELF: ::c_int = 0; + +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; + +pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; + +pub const S_IFIFO: ::mode_t = 4096; +pub const S_IFCHR: ::mode_t = 8192; +pub const S_IFBLK: ::mode_t = 24576; +pub const S_IFDIR: ::mode_t = 16384; +pub const S_IFREG: ::mode_t = 32768; +pub const S_IFLNK: ::mode_t = 40960; +pub const S_IFSOCK: ::mode_t = 49152; +pub const S_IFMT: ::mode_t = 61440; +pub const S_IRWXU: ::mode_t = 448; +pub const S_IXUSR: ::mode_t = 64; +pub const S_IWUSR: ::mode_t = 128; +pub const S_IRUSR: ::mode_t = 256; +pub const S_IRWXG: ::mode_t = 56; +pub const S_IXGRP: ::mode_t = 8; +pub const S_IWGRP: ::mode_t = 16; +pub const S_IRGRP: ::mode_t = 32; +pub const S_IRWXO: ::mode_t = 7; +pub const S_IXOTH: ::mode_t = 1; +pub const S_IWOTH: ::mode_t = 2; +pub const S_IROTH: ::mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const LC_CTYPE: ::c_int = 0; +pub const LC_NUMERIC: ::c_int = 1; +pub const LC_MONETARY: ::c_int = 2; +pub const LC_TIME: ::c_int = 3; +pub const LC_COLLATE: ::c_int = 4; +pub const LC_MESSAGES: ::c_int = 5; +pub const LC_ALL: ::c_int = 6; +pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE); +pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC); +pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME); +pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE); +pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY); +pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES); +// LC_ALL_MASK defined per platform + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +// MS_ flags for msync(2) +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MS_SYNC: ::c_int = 0x0004; + +// MS_ flags for mount(2) +pub const MS_RDONLY: ::c_ulong = 0x01; +pub const MS_NOSUID: ::c_ulong = 0x02; +pub const MS_NODEV: ::c_ulong = 0x04; +pub const MS_NOEXEC: ::c_ulong = 0x08; +pub const MS_SYNCHRONOUS: ::c_ulong = 0x10; +pub const MS_REMOUNT: ::c_ulong = 0x20; +pub const MS_MANDLOCK: ::c_ulong = 0x40; +pub const MS_NOATIME: ::c_ulong = 0x0400; +pub const MS_NODIRATIME: ::c_ulong = 0x0800; +pub const MS_BIND: ::c_ulong = 0x1000; +pub const MS_NOUSER: ::c_ulong = 0x80000000; +pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000; +pub const MS_MGC_MSK: ::c_ulong = 0xffff0000; +pub const MS_RMT_MASK: ::c_ulong = 0x800051; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const EWOULDBLOCK: ::c_int = EAGAIN; + +pub const SCM_RIGHTS: ::c_int = 0x01; +pub const SCM_CREDENTIALS: ::c_int = 0x02; + +// netinet/in.h +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// Hop-by-hop option header +pub const IPPROTO_HOPOPTS: ::c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: ::c_int = 2; +/// for compatibility +pub const IPPROTO_IPIP: ::c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// exterior gateway protocol +pub const IPPROTO_EGP: ::c_int = 8; +/// pup +pub const IPPROTO_PUP: ::c_int = 12; +// IPPROTO_UDP defined in src/unix/mod.rs +/// xns idp +pub const IPPROTO_IDP: ::c_int = 22; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: ::c_int = 29; +/// DCCP +pub const IPPROTO_DCCP: ::c_int = 33; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// IP6 routing header +pub const IPPROTO_ROUTING: ::c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: ::c_int = 44; +/// resource reservation +pub const IPPROTO_RSVP: ::c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: ::c_int = 47; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: ::c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: ::c_int = 51; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: ::c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: ::c_int = 60; +pub const IPPROTO_MTP: ::c_int = 92; +pub const IPPROTO_BEETPH: ::c_int = 94; +/// encapsulation header +pub const IPPROTO_ENCAP: ::c_int = 98; +/// Protocol indep. multicast +pub const IPPROTO_PIM: ::c_int = 103; +/// IP Payload Comp. Protocol +pub const IPPROTO_COMP: ::c_int = 108; +/// SCTP +pub const IPPROTO_SCTP: ::c_int = 132; +pub const IPPROTO_MH: ::c_int = 135; +pub const IPPROTO_UDPLITE: ::c_int = 136; +pub const IPPROTO_MPLS: ::c_int = 137; +/// raw IP packet +pub const IPPROTO_RAW: ::c_int = 255; +pub const IPPROTO_MAX: ::c_int = 256; + +pub const PROT_GROWSDOWN: ::c_int = 0x1000000; +pub const PROT_GROWSUP: ::c_int = 0x2000000; + +pub const MAP_TYPE: ::c_int = 0x000f; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_REMOVE: ::c_int = 9; +pub const MADV_DONTFORK: ::c_int = 10; +pub const MADV_DOFORK: ::c_int = 11; +pub const MADV_MERGEABLE: ::c_int = 12; +pub const MADV_UNMERGEABLE: ::c_int = 13; +pub const MADV_HWPOISON: ::c_int = 100; + +// https://github.com/kraj/uClibc/blob/master/include/net/if.h#L44 +pub const IFF_UP: ::c_int = 0x1; // Interface is up. +pub const IFF_BROADCAST: ::c_int = 0x2; // Broadcast address valid. +pub const IFF_DEBUG: ::c_int = 0x4; // Turn on debugging. +pub const IFF_LOOPBACK: ::c_int = 0x8; // Is a loopback net. +pub const IFF_POINTOPOINT: ::c_int = 0x10; // Interface is point-to-point link. +pub const IFF_NOTRAILERS: ::c_int = 0x20; // Avoid use of trailers. +pub const IFF_RUNNING: ::c_int = 0x40; // Resources allocated. +pub const IFF_NOARP: ::c_int = 0x80; // No address resolution protocol. +pub const IFF_PROMISC: ::c_int = 0x100; // Receive all packets. + +// Not supported +pub const IFF_ALLMULTI: ::c_int = 0x200; // Receive all multicast packets. +pub const IFF_MASTER: ::c_int = 0x400; // Master of a load balancer. +pub const IFF_SLAVE: ::c_int = 0x800; // Slave of a load balancer. +pub const IFF_MULTICAST: ::c_int = 0x1000; // Supports multicast. +pub const IFF_PORTSEL: ::c_int = 0x2000; // Can set media type. +pub const IFF_AUTOMEDIA: ::c_int = 0x4000; // Auto media select active. + +// Dialup device with changing addresses. +pub const IFF_DYNAMIC: ::c_int = 0x8000; + +pub const SOL_IP: ::c_int = 0; +pub const SOL_TCP: ::c_int = 6; +pub const SOL_IPV6: ::c_int = 41; +pub const SOL_ICMPV6: ::c_int = 58; +pub const SOL_RAW: ::c_int = 255; +pub const SOL_DECNET: ::c_int = 261; +pub const SOL_X25: ::c_int = 262; +pub const SOL_PACKET: ::c_int = 263; +pub const SOL_ATM: ::c_int = 264; +pub const SOL_AAL: ::c_int = 265; +pub const SOL_IRDA: ::c_int = 266; + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_UNIX: ::c_int = 1; +pub const AF_LOCAL: ::c_int = 1; +pub const AF_INET: ::c_int = 2; +pub const AF_AX25: ::c_int = 3; +pub const AF_IPX: ::c_int = 4; +pub const AF_APPLETALK: ::c_int = 5; +pub const AF_NETROM: ::c_int = 6; +pub const AF_BRIDGE: ::c_int = 7; +pub const AF_ATMPVC: ::c_int = 8; +pub const AF_X25: ::c_int = 9; +pub const AF_INET6: ::c_int = 10; +pub const AF_ROSE: ::c_int = 11; +pub const AF_DECnet: ::c_int = 12; +pub const AF_NETBEUI: ::c_int = 13; +pub const AF_SECURITY: ::c_int = 14; +pub const AF_KEY: ::c_int = 15; +pub const AF_NETLINK: ::c_int = 16; +pub const AF_ROUTE: ::c_int = AF_NETLINK; +pub const AF_PACKET: ::c_int = 17; +pub const AF_ASH: ::c_int = 18; +pub const AF_ECONET: ::c_int = 19; +pub const AF_ATMSVC: ::c_int = 20; +pub const AF_SNA: ::c_int = 22; +pub const AF_IRDA: ::c_int = 23; +pub const AF_PPPOX: ::c_int = 24; +pub const AF_WANPIPE: ::c_int = 25; +pub const AF_LLC: ::c_int = 26; +pub const AF_CAN: ::c_int = 29; +pub const AF_TIPC: ::c_int = 30; +pub const AF_BLUETOOTH: ::c_int = 31; +pub const AF_IUCV: ::c_int = 32; +pub const AF_RXRPC: ::c_int = 33; +pub const AF_ISDN: ::c_int = 34; +pub const AF_PHONET: ::c_int = 35; +pub const AF_IEEE802154: ::c_int = 36; +pub const AF_CAIF: ::c_int = 37; +pub const AF_ALG: ::c_int = 38; + +pub const PF_UNSPEC: ::c_int = AF_UNSPEC; +pub const PF_UNIX: ::c_int = AF_UNIX; +pub const PF_LOCAL: ::c_int = AF_LOCAL; +pub const PF_INET: ::c_int = AF_INET; +pub const PF_AX25: ::c_int = AF_AX25; +pub const PF_IPX: ::c_int = AF_IPX; +pub const PF_APPLETALK: ::c_int = AF_APPLETALK; +pub const PF_NETROM: ::c_int = AF_NETROM; +pub const PF_BRIDGE: ::c_int = AF_BRIDGE; +pub const PF_ATMPVC: ::c_int = AF_ATMPVC; +pub const PF_X25: ::c_int = AF_X25; +pub const PF_INET6: ::c_int = AF_INET6; +pub const PF_ROSE: ::c_int = AF_ROSE; +pub const PF_DECnet: ::c_int = AF_DECnet; +pub const PF_NETBEUI: ::c_int = AF_NETBEUI; +pub const PF_SECURITY: ::c_int = AF_SECURITY; +pub const PF_KEY: ::c_int = AF_KEY; +pub const PF_NETLINK: ::c_int = AF_NETLINK; +pub const PF_ROUTE: ::c_int = AF_ROUTE; +pub const PF_PACKET: ::c_int = AF_PACKET; +pub const PF_ASH: ::c_int = AF_ASH; +pub const PF_ECONET: ::c_int = AF_ECONET; +pub const PF_ATMSVC: ::c_int = AF_ATMSVC; +pub const PF_SNA: ::c_int = AF_SNA; +pub const PF_IRDA: ::c_int = AF_IRDA; +pub const PF_PPPOX: ::c_int = AF_PPPOX; +pub const PF_WANPIPE: ::c_int = AF_WANPIPE; +pub const PF_LLC: ::c_int = AF_LLC; +pub const PF_CAN: ::c_int = AF_CAN; +pub const PF_TIPC: ::c_int = AF_TIPC; +pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; +pub const PF_IUCV: ::c_int = AF_IUCV; +pub const PF_RXRPC: ::c_int = AF_RXRPC; +pub const PF_ISDN: ::c_int = AF_ISDN; +pub const PF_PHONET: ::c_int = AF_PHONET; +pub const PF_IEEE802154: ::c_int = AF_IEEE802154; +pub const PF_CAIF: ::c_int = AF_CAIF; +pub const PF_ALG: ::c_int = AF_ALG; + +pub const SOMAXCONN: ::c_int = 128; + +pub const MSG_OOB: ::c_int = 1; +pub const MSG_PEEK: ::c_int = 2; +pub const MSG_DONTROUTE: ::c_int = 4; +pub const MSG_CTRUNC: ::c_int = 8; +pub const MSG_TRUNC: ::c_int = 0x20; +pub const MSG_DONTWAIT: ::c_int = 0x40; +pub const MSG_EOR: ::c_int = 0x80; +pub const MSG_WAITALL: ::c_int = 0x100; +pub const MSG_FIN: ::c_int = 0x200; +pub const MSG_SYN: ::c_int = 0x400; +pub const MSG_CONFIRM: ::c_int = 0x800; +pub const MSG_RST: ::c_int = 0x1000; +pub const MSG_ERRQUEUE: ::c_int = 0x2000; +pub const MSG_NOSIGNAL: ::c_int = 0x4000; +pub const MSG_MORE: ::c_int = 0x8000; +pub const MSG_WAITFORONE: ::c_int = 0x10000; +pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000; + +pub const SOCK_RAW: ::c_int = 3; +pub const IP_MULTICAST_TTL: ::c_int = 33; +pub const IP_MULTICAST_LOOP: ::c_int = 34; +pub const IP_TTL: ::c_int = 2; +pub const IP_HDRINCL: ::c_int = 3; +pub const IP_ADD_MEMBERSHIP: ::c_int = 35; +pub const IP_DROP_MEMBERSHIP: ::c_int = 36; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; + +pub const IPV6_JOIN_GROUP: ::c_int = 20; +pub const IPV6_LEAVE_GROUP: ::c_int = 21; + +pub const TCP_NODELAY: ::c_int = 1; +pub const TCP_MAXSEG: ::c_int = 2; +pub const TCP_CORK: ::c_int = 3; +pub const TCP_KEEPIDLE: ::c_int = 4; +pub const TCP_KEEPINTVL: ::c_int = 5; +pub const TCP_KEEPCNT: ::c_int = 6; +pub const TCP_SYNCNT: ::c_int = 7; +pub const TCP_LINGER2: ::c_int = 8; +pub const TCP_DEFER_ACCEPT: ::c_int = 9; +pub const TCP_WINDOW_CLAMP: ::c_int = 10; +pub const TCP_INFO: ::c_int = 11; +pub const TCP_QUICKACK: ::c_int = 12; +pub const TCP_CONGESTION: ::c_int = 13; + +// Source: +// https://github.com/kraj/uClibc/blob/ca1c74d67dd115d059a875150e10b8560a9c35a8 +// /libc/sysdeps/linux/common/bits/in.h +// Same for all architectures +pub const IPV6_MULTICAST_HOPS: ::c_int = 18; +pub const IP_MULTICAST_IF: ::c_int = 32; +pub const IPV6_MULTICAST_IF: ::c_int = 17; +pub const IPV6_UNICAST_HOPS: ::c_int = 16; + +// Source: +// https://github.com/kraj/uClibc/tree/ca1c74d67dd115d059a875150e10b8560a9c35a8 +// Same for all architectures +pub const FUTEX_WAIT: ::c_int = 0; +pub const FUTEX_PRIVATE_FLAG: ::c_int = 128; +pub const FUTEX_WAKE: ::c_int = 1; + +pub const IPV6_MULTICAST_LOOP: ::c_int = 19; +pub const IPV6_V6ONLY: ::c_int = 26; + +pub const SO_DEBUG: ::c_int = 1; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; + +pub const SS_ONSTACK: ::c_int = 1; +pub const SS_DISABLE: ::c_int = 2; + +pub const PATH_MAX: ::c_int = 4096; + +pub const FD_SETSIZE: usize = 1024; + +pub const EPOLLIN: ::c_int = 0x1; +pub const EPOLLPRI: ::c_int = 0x2; +pub const EPOLLOUT: ::c_int = 0x4; +pub const EPOLLRDNORM: ::c_int = 0x40; +pub const EPOLLRDBAND: ::c_int = 0x80; +pub const EPOLLWRNORM: ::c_int = 0x100; +pub const EPOLLWRBAND: ::c_int = 0x200; +pub const EPOLLMSG: ::c_int = 0x400; +pub const EPOLLERR: ::c_int = 0x8; +pub const EPOLLHUP: ::c_int = 0x10; +pub const EPOLLET: ::c_int = 0x80000000; + +pub const EPOLL_CTL_ADD: ::c_int = 1; +pub const EPOLL_CTL_MOD: ::c_int = 3; +pub const EPOLL_CTL_DEL: ::c_int = 2; + +pub const MNT_DETACH: ::c_int = 0x2; +pub const MNT_EXPIRE: ::c_int = 0x4; + +pub const MNT_FORCE: ::c_int = 0x1; + +pub const Q_SYNC: ::c_int = 0x600; +pub const Q_QUOTAON: ::c_int = 0x100; +pub const Q_QUOTAOFF: ::c_int = 0x200; +pub const Q_GETQUOTA: ::c_int = 0x300; +pub const Q_SETQUOTA: ::c_int = 0x400; + +pub const TCIOFF: ::c_int = 2; +pub const TCION: ::c_int = 3; +pub const TCOOFF: ::c_int = 0; +pub const TCOON: ::c_int = 1; +pub const TCIFLUSH: ::c_int = 0; +pub const TCOFLUSH: ::c_int = 1; +pub const TCIOFLUSH: ::c_int = 2; +pub const NL0: ::tcflag_t = 0x00000000; +pub const NL1: ::tcflag_t = 0x00000100; +pub const TAB0: ::tcflag_t = 0x00000000; +pub const CR0: ::tcflag_t = 0x00000000; +pub const FF0: ::tcflag_t = 0x00000000; +pub const BS0: ::tcflag_t = 0x00000000; +pub const VT0: ::tcflag_t = 0x00000000; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VLNEXT: usize = 15; +pub const IGNBRK: ::tcflag_t = 0x00000001; +pub const BRKINT: ::tcflag_t = 0x00000002; +pub const IGNPAR: ::tcflag_t = 0x00000004; +pub const PARMRK: ::tcflag_t = 0x00000008; +pub const INPCK: ::tcflag_t = 0x00000010; +pub const ISTRIP: ::tcflag_t = 0x00000020; +pub const INLCR: ::tcflag_t = 0x00000040; +pub const IGNCR: ::tcflag_t = 0x00000080; +pub const ICRNL: ::tcflag_t = 0x00000100; +pub const IXANY: ::tcflag_t = 0x00000800; +pub const IMAXBEL: ::tcflag_t = 0x00002000; +pub const OPOST: ::tcflag_t = 0x1; +pub const CS5: ::tcflag_t = 0x00000000; +pub const CRTSCTS: ::tcflag_t = 0x80000000; +pub const ECHO: ::tcflag_t = 0x00000008; + +pub const CLONE_VM: ::c_int = 0x100; +pub const CLONE_FS: ::c_int = 0x200; +pub const CLONE_FILES: ::c_int = 0x400; +pub const CLONE_SIGHAND: ::c_int = 0x800; +pub const CLONE_PTRACE: ::c_int = 0x2000; +pub const CLONE_VFORK: ::c_int = 0x4000; +pub const CLONE_PARENT: ::c_int = 0x8000; +pub const CLONE_THREAD: ::c_int = 0x10000; +pub const CLONE_NEWNS: ::c_int = 0x20000; +pub const CLONE_SYSVSEM: ::c_int = 0x40000; +pub const CLONE_SETTLS: ::c_int = 0x80000; +pub const CLONE_PARENT_SETTID: ::c_int = 0x100000; +pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000; +pub const CLONE_DETACHED: ::c_int = 0x400000; +pub const CLONE_UNTRACED: ::c_int = 0x800000; +pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000; +pub const CLONE_NEWUTS: ::c_int = 0x04000000; +pub const CLONE_NEWIPC: ::c_int = 0x08000000; +pub const CLONE_NEWUSER: ::c_int = 0x10000000; +pub const CLONE_NEWPID: ::c_int = 0x20000000; +pub const CLONE_NEWNET: ::c_int = 0x40000000; +pub const CLONE_IO: ::c_int = 0x80000000; + +pub const WNOHANG: ::c_int = 0x00000001; +pub const WUNTRACED: ::c_int = 0x00000002; +pub const WSTOPPED: ::c_int = WUNTRACED; +pub const WEXITED: ::c_int = 0x00000004; +pub const WCONTINUED: ::c_int = 0x00000008; +pub const WNOWAIT: ::c_int = 0x01000000; + +pub const __WNOTHREAD: ::c_int = 0x20000000; +pub const __WALL: ::c_int = 0x40000000; +pub const __WCLONE: ::c_int = 0x80000000; + +pub const SPLICE_F_MOVE: ::c_uint = 0x01; +pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02; +pub const SPLICE_F_MORE: ::c_uint = 0x04; +pub const SPLICE_F_GIFT: ::c_uint = 0x08; + +pub const RTLD_LOCAL: ::c_int = 0; +pub const RTLD_LAZY: ::c_int = 1; + +pub const POSIX_FADV_NORMAL: ::c_int = 0; +pub const POSIX_FADV_RANDOM: ::c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_FADV_WILLNEED: ::c_int = 3; + +pub const AT_FDCWD: ::c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100; +pub const AT_REMOVEDIR: ::c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; + +pub const LOG_CRON: ::c_int = 9 << 3; +pub const LOG_AUTHPRIV: ::c_int = 10 << 3; +pub const LOG_FTP: ::c_int = 11 << 3; +pub const LOG_PERROR: ::c_int = 0x20; + +pub const POLLIN: ::c_short = 0x1; +pub const POLLPRI: ::c_short = 0x2; +pub const POLLOUT: ::c_short = 0x4; +pub const POLLERR: ::c_short = 0x8; +pub const POLLHUP: ::c_short = 0x10; +pub const POLLNVAL: ::c_short = 0x20; + +pub const PIPE_BUF: usize = 4096; + +pub const SI_LOAD_SHIFT: ::c_uint = 16; + +pub const SIGEV_SIGNAL: ::c_int = 0; +pub const SIGEV_NONE: ::c_int = 1; +pub const SIGEV_THREAD: ::c_int = 2; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + +pub const UTIME_OMIT: c_long = 1073741822; +pub const UTIME_NOW: c_long = 1073741823; + +pub const L_tmpnam: ::c_uint = 20; +pub const _PC_LINK_MAX: ::c_int = 0; +pub const _PC_MAX_CANON: ::c_int = 1; +pub const _PC_MAX_INPUT: ::c_int = 2; +pub const _PC_NAME_MAX: ::c_int = 3; +pub const _PC_PATH_MAX: ::c_int = 4; +pub const _PC_PIPE_BUF: ::c_int = 5; +pub const _PC_CHOWN_RESTRICTED: ::c_int = 6; +pub const _PC_NO_TRUNC: ::c_int = 7; +pub const _PC_VDISABLE: ::c_int = 8; + +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_CHILD_MAX: ::c_int = 1; +pub const _SC_CLK_TCK: ::c_int = 2; +pub const _SC_NGROUPS_MAX: ::c_int = 3; +pub const _SC_OPEN_MAX: ::c_int = 4; +pub const _SC_STREAM_MAX: ::c_int = 5; +pub const _SC_TZNAME_MAX: ::c_int = 6; +pub const _SC_JOB_CONTROL: ::c_int = 7; +pub const _SC_SAVED_IDS: ::c_int = 8; +pub const _SC_REALTIME_SIGNALS: ::c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; +pub const _SC_TIMERS: ::c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; +pub const _SC_PRIORITIZED_IO: ::c_int = 13; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; +pub const _SC_FSYNC: ::c_int = 15; +pub const _SC_MAPPED_FILES: ::c_int = 16; +pub const _SC_MEMLOCK: ::c_int = 17; +pub const _SC_MEMLOCK_RANGE: ::c_int = 18; +pub const _SC_MEMORY_PROTECTION: ::c_int = 19; +pub const _SC_MESSAGE_PASSING: ::c_int = 20; +pub const _SC_SEMAPHORES: ::c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; +pub const _SC_AIO_MAX: ::c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; +pub const _SC_DELAYTIMER_MAX: ::c_int = 26; +pub const _SC_MQ_OPEN_MAX: ::c_int = 27; +pub const _SC_MQ_PRIO_MAX: ::c_int = 28; +pub const _SC_VERSION: ::c_int = 29; +pub const _SC_PAGESIZE: ::c_int = 30; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: ::c_int = 31; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; +pub const _SC_SEM_VALUE_MAX: ::c_int = 33; +pub const _SC_SIGQUEUE_MAX: ::c_int = 34; +pub const _SC_TIMER_MAX: ::c_int = 35; +pub const _SC_BC_BASE_MAX: ::c_int = 36; +pub const _SC_BC_DIM_MAX: ::c_int = 37; +pub const _SC_BC_SCALE_MAX: ::c_int = 38; +pub const _SC_BC_STRING_MAX: ::c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; +pub const _SC_EXPR_NEST_MAX: ::c_int = 42; +pub const _SC_LINE_MAX: ::c_int = 43; +pub const _SC_RE_DUP_MAX: ::c_int = 44; +pub const _SC_2_VERSION: ::c_int = 46; +pub const _SC_2_C_BIND: ::c_int = 47; +pub const _SC_2_C_DEV: ::c_int = 48; +pub const _SC_2_FORT_DEV: ::c_int = 49; +pub const _SC_2_FORT_RUN: ::c_int = 50; +pub const _SC_2_SW_DEV: ::c_int = 51; +pub const _SC_2_LOCALEDEF: ::c_int = 52; +pub const _SC_IOV_MAX: ::c_int = 60; +pub const _SC_THREADS: ::c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; +pub const _SC_TTY_NAME_MAX: ::c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; +pub const _SC_THREAD_STACK_MIN: ::c_int = 75; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; +pub const _SC_ATEXIT_MAX: ::c_int = 87; +pub const _SC_XOPEN_VERSION: ::c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; +pub const _SC_XOPEN_UNIX: ::c_int = 91; +pub const _SC_XOPEN_CRYPT: ::c_int = 92; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; +pub const _SC_XOPEN_SHM: ::c_int = 94; +pub const _SC_2_CHAR_TERM: ::c_int = 95; +pub const _SC_2_UPE: ::c_int = 97; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; +pub const _SC_XOPEN_LEGACY: ::c_int = 129; +pub const _SC_XOPEN_REALTIME: ::c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; +pub const _SC_HOST_NAME_MAX: ::c_int = 180; + +pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; + +pub const GLOB_ERR: ::c_int = 1 << 0; +pub const GLOB_MARK: ::c_int = 1 << 1; +pub const GLOB_NOSORT: ::c_int = 1 << 2; +pub const GLOB_DOOFFS: ::c_int = 1 << 3; +pub const GLOB_NOCHECK: ::c_int = 1 << 4; +pub const GLOB_APPEND: ::c_int = 1 << 5; +pub const GLOB_NOESCAPE: ::c_int = 1 << 6; + +pub const GLOB_NOSPACE: ::c_int = 1; +pub const GLOB_ABORTED: ::c_int = 2; +pub const GLOB_NOMATCH: ::c_int = 3; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; + +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; + +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; + +pub const ST_RDONLY: ::c_ulong = 1; +pub const ST_NOSUID: ::c_ulong = 2; +pub const ST_NODEV: ::c_ulong = 4; +pub const ST_NOEXEC: ::c_ulong = 8; +pub const ST_SYNCHRONOUS: ::c_ulong = 16; +pub const ST_MANDLOCK: ::c_ulong = 64; +pub const ST_WRITE: ::c_ulong = 128; +pub const ST_APPEND: ::c_ulong = 256; +pub const ST_IMMUTABLE: ::c_ulong = 512; +pub const ST_NOATIME: ::c_ulong = 1024; +pub const ST_NODIRATIME: ::c_ulong = 2048; + +pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void; +pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; +pub const RTLD_NODELETE: ::c_int = 0x1000; +pub const RTLD_NOW: ::c_int = 0x2; + +pub const TCP_MD5SIG: ::c_int = 14; + +align_const! { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], + }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], + }; + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + }; +} +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; + +pub const SCHED_OTHER: ::c_int = 0; +pub const SCHED_FIFO: ::c_int = 1; +pub const SCHED_RR: ::c_int = 2; +pub const SCHED_BATCH: ::c_int = 3; +pub const SCHED_IDLE: ::c_int = 5; + +// System V IPC +pub const IPC_PRIVATE: ::key_t = 0; + +pub const IPC_CREAT: ::c_int = 0o1000; +pub const IPC_EXCL: ::c_int = 0o2000; +pub const IPC_NOWAIT: ::c_int = 0o4000; + +pub const IPC_RMID: ::c_int = 0; +pub const IPC_SET: ::c_int = 1; +pub const IPC_STAT: ::c_int = 2; +pub const IPC_INFO: ::c_int = 3; +pub const MSG_STAT: ::c_int = 11; +pub const MSG_INFO: ::c_int = 12; + +pub const MSG_NOERROR: ::c_int = 0o10000; +pub const MSG_EXCEPT: ::c_int = 0o20000; + +pub const SHM_R: ::c_int = 0o400; +pub const SHM_W: ::c_int = 0o200; + +pub const SHM_RDONLY: ::c_int = 0o10000; +pub const SHM_RND: ::c_int = 0o20000; +pub const SHM_REMAP: ::c_int = 0o40000; + +pub const SHM_LOCK: ::c_int = 11; +pub const SHM_UNLOCK: ::c_int = 12; + +pub const SHM_HUGETLB: ::c_int = 0o4000; +pub const SHM_NORESERVE: ::c_int = 0o10000; + +pub const EPOLLRDHUP: ::c_int = 0x2000; +pub const EPOLLONESHOT: ::c_int = 0x40000000; + +pub const QFMT_VFS_OLD: ::c_int = 1; +pub const QFMT_VFS_V0: ::c_int = 2; + +pub const EFD_SEMAPHORE: ::c_int = 0x1; + +pub const LOG_NFACILITIES: ::c_int = 24; + +pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t; + +pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32; +pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32; +pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32; +pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32; +pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32; + +pub const AI_PASSIVE: ::c_int = 0x0001; +pub const AI_CANONNAME: ::c_int = 0x0002; +pub const AI_NUMERICHOST: ::c_int = 0x0004; +pub const AI_V4MAPPED: ::c_int = 0x0008; +pub const AI_ALL: ::c_int = 0x0010; +pub const AI_ADDRCONFIG: ::c_int = 0x0020; + +pub const AI_NUMERICSERV: ::c_int = 0x0400; + +pub const EAI_BADFLAGS: ::c_int = -1; +pub const EAI_NONAME: ::c_int = -2; +pub const EAI_AGAIN: ::c_int = -3; +pub const EAI_FAIL: ::c_int = -4; +pub const EAI_FAMILY: ::c_int = -6; +pub const EAI_SOCKTYPE: ::c_int = -7; +pub const EAI_SERVICE: ::c_int = -8; +pub const EAI_MEMORY: ::c_int = -10; +pub const EAI_OVERFLOW: ::c_int = -12; + +pub const NI_NUMERICHOST: ::c_int = 1; +pub const NI_NUMERICSERV: ::c_int = 2; +pub const NI_NOFQDN: ::c_int = 4; +pub const NI_NAMEREQD: ::c_int = 8; +pub const NI_DGRAM: ::c_int = 16; + +pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1; +pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2; +pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4; + +pub const EAI_SYSTEM: ::c_int = -11; + +pub const MREMAP_MAYMOVE: ::c_int = 1; +pub const MREMAP_FIXED: ::c_int = 2; + +pub const PR_SET_PDEATHSIG: ::c_int = 1; +pub const PR_GET_PDEATHSIG: ::c_int = 2; + +pub const PR_GET_DUMPABLE: ::c_int = 3; +pub const PR_SET_DUMPABLE: ::c_int = 4; + +pub const PR_GET_UNALIGN: ::c_int = 5; +pub const PR_SET_UNALIGN: ::c_int = 6; +pub const PR_UNALIGN_NOPRINT: ::c_int = 1; +pub const PR_UNALIGN_SIGBUS: ::c_int = 2; + +pub const PR_GET_KEEPCAPS: ::c_int = 7; +pub const PR_SET_KEEPCAPS: ::c_int = 8; + +pub const PR_GET_FPEMU: ::c_int = 9; +pub const PR_SET_FPEMU: ::c_int = 10; +pub const PR_FPEMU_NOPRINT: ::c_int = 1; +pub const PR_FPEMU_SIGFPE: ::c_int = 2; + +pub const PR_GET_FPEXC: ::c_int = 11; +pub const PR_SET_FPEXC: ::c_int = 12; +pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80; +pub const PR_FP_EXC_DIV: ::c_int = 0x010000; +pub const PR_FP_EXC_OVF: ::c_int = 0x020000; +pub const PR_FP_EXC_UND: ::c_int = 0x040000; +pub const PR_FP_EXC_RES: ::c_int = 0x080000; +pub const PR_FP_EXC_INV: ::c_int = 0x100000; +pub const PR_FP_EXC_DISABLED: ::c_int = 0; +pub const PR_FP_EXC_NONRECOV: ::c_int = 1; +pub const PR_FP_EXC_ASYNC: ::c_int = 2; +pub const PR_FP_EXC_PRECISE: ::c_int = 3; + +pub const PR_GET_TIMING: ::c_int = 13; +pub const PR_SET_TIMING: ::c_int = 14; +pub const PR_TIMING_STATISTICAL: ::c_int = 0; +pub const PR_TIMING_TIMESTAMP: ::c_int = 1; + +pub const PR_SET_NAME: ::c_int = 15; +pub const PR_GET_NAME: ::c_int = 16; + +pub const PR_GET_ENDIAN: ::c_int = 19; +pub const PR_SET_ENDIAN: ::c_int = 20; +pub const PR_ENDIAN_BIG: ::c_int = 0; +pub const PR_ENDIAN_LITTLE: ::c_int = 1; +pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2; + +pub const PR_GET_SECCOMP: ::c_int = 21; +pub const PR_SET_SECCOMP: ::c_int = 22; + +pub const PR_CAPBSET_READ: ::c_int = 23; +pub const PR_CAPBSET_DROP: ::c_int = 24; + +pub const PR_GET_TSC: ::c_int = 25; +pub const PR_SET_TSC: ::c_int = 26; +pub const PR_TSC_ENABLE: ::c_int = 1; +pub const PR_TSC_SIGSEGV: ::c_int = 2; + +pub const PR_GET_SECUREBITS: ::c_int = 27; +pub const PR_SET_SECUREBITS: ::c_int = 28; + +pub const PR_SET_TIMERSLACK: ::c_int = 29; +pub const PR_GET_TIMERSLACK: ::c_int = 30; + +pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31; +pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32; + +pub const PR_MCE_KILL: ::c_int = 33; +pub const PR_MCE_KILL_CLEAR: ::c_int = 0; +pub const PR_MCE_KILL_SET: ::c_int = 1; + +pub const PR_MCE_KILL_LATE: ::c_int = 0; +pub const PR_MCE_KILL_EARLY: ::c_int = 1; +pub const PR_MCE_KILL_DEFAULT: ::c_int = 2; + +pub const PR_MCE_KILL_GET: ::c_int = 34; + +pub const PR_SET_MM: ::c_int = 35; +pub const PR_SET_MM_START_CODE: ::c_int = 1; +pub const PR_SET_MM_END_CODE: ::c_int = 2; +pub const PR_SET_MM_START_DATA: ::c_int = 3; +pub const PR_SET_MM_END_DATA: ::c_int = 4; +pub const PR_SET_MM_START_STACK: ::c_int = 5; +pub const PR_SET_MM_START_BRK: ::c_int = 6; +pub const PR_SET_MM_BRK: ::c_int = 7; +pub const PR_SET_MM_ARG_START: ::c_int = 8; +pub const PR_SET_MM_ARG_END: ::c_int = 9; +pub const PR_SET_MM_ENV_START: ::c_int = 10; +pub const PR_SET_MM_ENV_END: ::c_int = 11; +pub const PR_SET_MM_AUXV: ::c_int = 12; +pub const PR_SET_MM_EXE_FILE: ::c_int = 13; +pub const PR_SET_MM_MAP: ::c_int = 14; +pub const PR_SET_MM_MAP_SIZE: ::c_int = 15; + +pub const PR_SET_PTRACER: ::c_int = 0x59616d61; + +pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36; +pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37; + +pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38; +pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39; + +pub const PR_GET_TID_ADDRESS: ::c_int = 40; + +pub const PR_SET_THP_DISABLE: ::c_int = 41; +pub const PR_GET_THP_DISABLE: ::c_int = 42; + +pub const GRND_NONBLOCK: ::c_uint = 0x0001; +pub const GRND_RANDOM: ::c_uint = 0x0002; + +pub const ABDAY_1: ::nl_item = 0x300; +pub const ABDAY_2: ::nl_item = 0x301; +pub const ABDAY_3: ::nl_item = 0x302; +pub const ABDAY_4: ::nl_item = 0x303; +pub const ABDAY_5: ::nl_item = 0x304; +pub const ABDAY_6: ::nl_item = 0x305; +pub const ABDAY_7: ::nl_item = 0x306; + +pub const DAY_1: ::nl_item = 0x307; +pub const DAY_2: ::nl_item = 0x308; +pub const DAY_3: ::nl_item = 0x309; +pub const DAY_4: ::nl_item = 0x30A; +pub const DAY_5: ::nl_item = 0x30B; +pub const DAY_6: ::nl_item = 0x30C; +pub const DAY_7: ::nl_item = 0x30D; + +pub const ABMON_1: ::nl_item = 0x30E; +pub const ABMON_2: ::nl_item = 0x30F; +pub const ABMON_3: ::nl_item = 0x310; +pub const ABMON_4: ::nl_item = 0x311; +pub const ABMON_5: ::nl_item = 0x312; +pub const ABMON_6: ::nl_item = 0x313; +pub const ABMON_7: ::nl_item = 0x314; +pub const ABMON_8: ::nl_item = 0x315; +pub const ABMON_9: ::nl_item = 0x316; +pub const ABMON_10: ::nl_item = 0x317; +pub const ABMON_11: ::nl_item = 0x318; +pub const ABMON_12: ::nl_item = 0x319; + +pub const MON_1: ::nl_item = 0x31A; +pub const MON_2: ::nl_item = 0x31B; +pub const MON_3: ::nl_item = 0x31C; +pub const MON_4: ::nl_item = 0x31D; +pub const MON_5: ::nl_item = 0x31E; +pub const MON_6: ::nl_item = 0x31F; +pub const MON_7: ::nl_item = 0x320; +pub const MON_8: ::nl_item = 0x321; +pub const MON_9: ::nl_item = 0x322; +pub const MON_10: ::nl_item = 0x323; +pub const MON_11: ::nl_item = 0x324; +pub const MON_12: ::nl_item = 0x325; + +pub const AM_STR: ::nl_item = 0x326; +pub const PM_STR: ::nl_item = 0x327; + +pub const D_T_FMT: ::nl_item = 0x328; +pub const D_FMT: ::nl_item = 0x329; +pub const T_FMT: ::nl_item = 0x32A; +pub const T_FMT_AMPM: ::nl_item = 0x32B; + +pub const ERA: ::nl_item = 0x32C; +pub const ERA_D_FMT: ::nl_item = 0x32E; +pub const ALT_DIGITS: ::nl_item = 0x32F; +pub const ERA_D_T_FMT: ::nl_item = 0x330; +pub const ERA_T_FMT: ::nl_item = 0x331; + +pub const CODESET: ::nl_item = 10; + +pub const CRNCYSTR: ::nl_item = 0x215; + +pub const RADIXCHAR: ::nl_item = 0x100; +pub const THOUSEP: ::nl_item = 0x101; + +pub const NOEXPR: ::nl_item = 0x501; +pub const YESSTR: ::nl_item = 0x502; +pub const NOSTR: ::nl_item = 0x503; + +pub const FILENAME_MAX: ::c_uint = 4095; + +f! { + pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return + } + + pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 + } + + pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WIFCONTINUED(status: ::c_int) -> bool { + status == 0xffff + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0x7f + } + + pub fn WIFEXITED(status: ::c_int) -> bool { + (status & 0x7f) == 0 + } + + pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WCOREDUMP(status: ::c_int) -> bool { + (status & 0x80) != 0 + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits + = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] |= 1 << offset; + () + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits + = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] &= !(1 << offset); + () + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]); + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + 0 != (cpuset.bits[idx] & (1 << offset)) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.bits == set2.bits + } + + pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { + (cmd << 8) | (type_ & 0x00ff) + } +} + +extern "C" { + #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")] + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + pub fn sem_init( + sem: *mut sem_t, + pshared: ::c_int, + value: ::c_uint, + ) -> ::c_int; + + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + + pub fn fdatasync(fd: ::c_int) -> ::c_int; + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; + pub fn mincore( + addr: *mut ::c_void, + len: ::size_t, + vec: *mut ::c_uchar, + ) -> ::c_int; + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_nanosleep( + clk_id: ::clockid_t, + flags: ::c_int, + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + pub fn clock_settime( + clk_id: ::clockid_t, + tp: *const ::timespec, + ) -> ::c_int; + pub fn prctl(option: ::c_int, ...) -> ::c_int; + pub fn pthread_getattr_np( + native: ::pthread_t, + attr: *mut ::pthread_attr_t, + ) -> ::c_int; + pub fn pthread_attr_getguardsize( + attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t, + ) -> ::c_int; + pub fn pthread_attr_getstack( + attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t, + ) -> ::c_int; + pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; + pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int; + pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; + pub fn sched_setscheduler( + pid: ::pid_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; + pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; + pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; + pub fn epoll_create(size: ::c_int) -> ::c_int; + pub fn epoll_create1(flags: ::c_int) -> ::c_int; + pub fn epoll_ctl( + epfd: ::c_int, + op: ::c_int, + fd: ::c_int, + event: *mut ::epoll_event, + ) -> ::c_int; + pub fn epoll_wait( + epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: ::c_int, + ) -> ::c_int; + pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + pub fn mount( + src: *const ::c_char, + target: *const ::c_char, + fstype: *const ::c_char, + flags: ::c_ulong, + data: *const ::c_void, + ) -> ::c_int; + pub fn umount(target: *const ::c_char) -> ::c_int; + pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; + pub fn clone( + cb: extern "C" fn(*mut ::c_void) -> ::c_int, + child_stack: *mut ::c_void, + flags: ::c_int, + arg: *mut ::c_void, + ... + ) -> ::c_int; + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + pub fn memrchr( + cx: *const ::c_void, + c: ::c_int, + n: ::size_t, + ) -> *mut ::c_void; + pub fn syscall(num: ::c_long, ...) -> ::c_long; + pub fn sendfile( + out_fd: ::c_int, + in_fd: ::c_int, + offset: *mut off_t, + count: ::size_t, + ) -> ::ssize_t; + pub fn splice( + fd_in: ::c_int, + off_in: *mut ::loff_t, + fd_out: ::c_int, + off_out: *mut ::loff_t, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn tee( + fd_in: ::c_int, + fd_out: ::c_int, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn vmsplice( + fd: ::c_int, + iov: *const ::iovec, + nr_segs: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + + pub fn posix_fadvise( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + advise: ::c_int, + ) -> ::c_int; + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn utimensat( + dirfd: ::c_int, + path: *const ::c_char, + times: *const ::timespec, + flag: ::c_int, + ) -> ::c_int; + pub fn duplocale(base: ::locale_t) -> ::locale_t; + pub fn freelocale(loc: ::locale_t); + pub fn newlocale( + mask: ::c_int, + locale: *const ::c_char, + base: ::locale_t, + ) -> ::locale_t; + pub fn uselocale(loc: ::locale_t) -> ::locale_t; + pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int; + pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int; + pub fn fstatat64( + fildes: ::c_int, + path: *const ::c_char, + buf: *mut stat64, + flag: ::c_int, + ) -> ::c_int; + pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int; + pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int; + pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t; + pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int; + pub fn mmap64( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + flags: ::c_int, + fd: ::c_int, + offset: off64_t, + ) -> *mut ::c_void; + pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn openat64( + fd: ::c_int, + path: *const c_char, + oflag: ::c_int, + ... + ) -> ::c_int; + pub fn pread64( + fd: ::c_int, + buf: *mut ::c_void, + count: ::size_t, + offset: off64_t, + ) -> ::ssize_t; + pub fn pwrite64( + fd: ::c_int, + buf: *const ::c_void, + count: ::size_t, + offset: off64_t, + ) -> ::ssize_t; + pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64; + pub fn readdir64_r( + dirp: *mut ::DIR, + entry: *mut ::dirent64, + result: *mut *mut ::dirent64, + ) -> ::c_int; + pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; + pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; + pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; + pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; + + pub fn mknodat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + dev: dev_t, + ) -> ::c_int; + pub fn ppoll( + fds: *mut ::pollfd, + nfds: nfds_t, + timeout: *const ::timespec, + sigmask: *const sigset_t, + ) -> ::c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> ::c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + pub fn pthread_condattr_setpshared( + attr: *mut pthread_condattr_t, + pshared: ::c_int, + ) -> ::c_int; + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut ::c_int, + ) -> ::c_int; + pub fn sched_getaffinity( + pid: ::pid_t, + cpusetsize: ::size_t, + cpuset: *mut cpu_set_t, + ) -> ::c_int; + pub fn sched_setaffinity( + pid: ::pid_t, + cpusetsize: ::size_t, + cpuset: *const cpu_set_t, + ) -> ::c_int; + pub fn unshare(flags: ::c_int) -> ::c_int; + pub fn sem_timedwait( + sem: *mut sem_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int; + pub fn accept4( + fd: ::c_int, + addr: *mut ::sockaddr, + len: *mut ::socklen_t, + flg: ::c_int, + ) -> ::c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn pthread_mutexattr_setpshared( + attr: *mut pthread_mutexattr_t, + pshared: ::c_int, + ) -> ::c_int; + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_getkind_np( + attr: *const pthread_rwlockattr_t, + val: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_setkind_np( + attr: *mut pthread_rwlockattr_t, + val: ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_getpshared( + attr: *const pthread_rwlockattr_t, + val: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_rwlockattr_setpshared( + attr: *mut pthread_rwlockattr_t, + val: ::c_int, + ) -> ::c_int; + pub fn ptsname_r( + fd: ::c_int, + buf: *mut ::c_char, + buflen: ::size_t, + ) -> ::c_int; + pub fn clearenv() -> ::c_int; + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut ::siginfo_t, + options: ::c_int, + ) -> ::c_int; + + pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + pub fn setspent(); + pub fn endspent(); + pub fn getspent() -> *mut spwd; + pub fn getspnam(__name: *const ::c_char) -> *mut spwd; + + pub fn shm_open( + name: *const c_char, + oflag: ::c_int, + mode: mode_t, + ) -> ::c_int; + + // System V IPC + pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; + pub fn shmat( + shmid: ::c_int, + shmaddr: *const ::c_void, + shmflg: ::c_int, + ) -> *mut ::c_void; + pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; + pub fn shmctl( + shmid: ::c_int, + cmd: ::c_int, + buf: *mut ::shmid_ds, + ) -> ::c_int; + pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t; + pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) + -> ::c_int; + pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; + pub fn msgrcv( + msqid: ::c_int, + msgp: *mut ::c_void, + msgsz: ::size_t, + msgtyp: ::c_long, + msgflg: ::c_int, + ) -> ::ssize_t; + pub fn msgsnd( + msqid: ::c_int, + msgp: *const ::c_void, + msgsz: ::size_t, + msgflg: ::c_int, + ) -> ::c_int; + + pub fn mprotect( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + ) -> ::c_int; + pub fn __errno_location() -> *mut ::c_int; + + pub fn fopen64( + filename: *const c_char, + mode: *const c_char, + ) -> *mut ::FILE; + pub fn freopen64( + filename: *const c_char, + mode: *const c_char, + file: *mut ::FILE, + ) -> *mut ::FILE; + pub fn tmpfile64() -> *mut ::FILE; + pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int; + pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int; + pub fn fseeko64( + stream: *mut ::FILE, + offset: ::off64_t, + whence: ::c_int, + ) -> ::c_int; + pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; + pub fn readahead( + fd: ::c_int, + offset: ::off64_t, + count: ::size_t, + ) -> ::ssize_t; + pub fn getxattr( + path: *const c_char, + name: *const c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn lgetxattr( + path: *const c_char, + name: *const c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn fgetxattr( + filedes: ::c_int, + name: *const c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn setxattr( + path: *const c_char, + name: *const c_char, + value: *const ::c_void, + size: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn lsetxattr( + path: *const c_char, + name: *const c_char, + value: *const ::c_void, + size: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn fsetxattr( + filedes: ::c_int, + name: *const c_char, + value: *const ::c_void, + size: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn listxattr( + path: *const c_char, + list: *mut c_char, + size: ::size_t, + ) -> ::ssize_t; + pub fn llistxattr( + path: *const c_char, + list: *mut c_char, + size: ::size_t, + ) -> ::ssize_t; + pub fn flistxattr( + filedes: ::c_int, + list: *mut c_char, + size: ::size_t, + ) -> ::ssize_t; + pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int; + pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int; + pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int; + pub fn signalfd( + fd: ::c_int, + mask: *const ::sigset_t, + flags: ::c_int, + ) -> ::c_int; + pub fn quotactl( + cmd: ::c_int, + special: *const ::c_char, + id: ::c_int, + data: *mut ::c_char, + ) -> ::c_int; + pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; + pub fn mq_close(mqd: ::mqd_t) -> ::c_int; + pub fn mq_unlink(name: *const ::c_char) -> ::c_int; + pub fn mq_receive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + ) -> ::ssize_t; + pub fn mq_send( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + ) -> ::c_int; + pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; + pub fn mq_setattr( + mqd: ::mqd_t, + newattr: *const ::mq_attr, + oldattr: *mut ::mq_attr, + ) -> ::c_int; + pub fn epoll_pwait( + epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: ::c_int, + sigmask: *const ::sigset_t, + ) -> ::c_int; + pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int; + pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) + -> *mut ::c_char; + pub fn prlimit( + pid: ::pid_t, + resource: ::c_int, + new_limit: *const ::rlimit, + old_limit: *mut ::rlimit, + ) -> ::c_int; + pub fn prlimit64( + pid: ::pid_t, + resource: ::c_int, + new_limit: *const ::rlimit64, + old_limit: *mut ::rlimit64, + ) -> ::c_int; + pub fn reboot(how_to: ::c_int) -> ::c_int; + pub fn setfsgid(gid: ::gid_t) -> ::c_int; + pub fn setfsuid(uid: ::uid_t) -> ::c_int; + pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; + pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; + + // Not available now on Android + pub fn mkfifoat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + ) -> ::c_int; + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + pub fn sync_file_range( + fd: ::c_int, + offset: ::off64_t, + nbytes: ::off64_t, + flags: ::c_uint, + ) -> ::c_int; + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; + pub fn freeifaddrs(ifa: *mut ::ifaddrs); + + pub fn mremap( + addr: *mut ::c_void, + len: ::size_t, + new_len: ::size_t, + flags: ::c_int, + ... + ) -> *mut ::c_void; + + pub fn glob( + pattern: *const c_char, + flags: ::c_int, + errfunc: ::Option< + extern "C" fn(epath: *const c_char, errno: ::c_int) -> ::c_int, + >, + pglob: *mut ::glob_t, + ) -> ::c_int; + pub fn globfree(pglob: *mut ::glob_t); + + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); + + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; + pub fn madvise( + addr: *mut ::c_void, + len: ::size_t, + advice: ::c_int, + ) -> ::c_int; + + pub fn msync( + addr: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::c_int; + + pub fn recvfrom( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + ) -> ::ssize_t; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + pub fn bind( + socket: ::c_int, + address: *const ::sockaddr, + address_len: ::socklen_t, + ) -> ::c_int; + + pub fn writev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + pub fn readv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + + pub fn sendmsg( + fd: ::c_int, + msg: *const ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + pub fn recvmsg( + fd: ::c_int, + msg: *mut ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigaltstack$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sem_close(sem: *mut sem_t) -> ::c_int; + pub fn getdtablesize() -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_sigmask$UNIX2003" + )] + pub fn pthread_sigmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const ::c_char) -> *mut ::group; + pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; + pub fn sem_unlink(name: *const ::c_char) -> ::c_int; + pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigwait$UNIX2003" + )] + #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] + pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; + pub fn pthread_atfork( + prepare: ::Option, + parent: ::Option, + child: ::Option, + ) -> ::c_int; + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + pub fn getgrgid(gid: ::gid_t) -> *mut ::group; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "popen$UNIX2003" + )] + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + pub fn uname(buf: *mut ::utsname) -> ::c_int; +} + +cfg_if! { + if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { + mod mips; + pub use self::mips::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else { + pub use unsupported_target; + } +} + +cfg_if! { + if #[cfg(libc_align)] { + #[macro_use] + mod align; + } else { + #[macro_use] + mod no_align; + } +} + +expand_align!(); diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/no_align.rs new file mode 100644 index 0000000..a73dbde --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/no_align.rs @@ -0,0 +1,53 @@ +macro_rules! expand_align { + () => { + s! { + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(any(libc_align, + target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any( + target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + pub struct pthread_mutexattr_t { + #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_cond_t { + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/align.rs new file mode 100644 index 0000000..583a278 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/align.rs @@ -0,0 +1,77 @@ +macro_rules! expand_align { + () => { + s! { + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { // ToDo + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } + + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { // ToDo + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { // ToDo + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } + + s_no_extra_traits! { + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(all(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))), + repr(align(8)))] + #[allow(missing_debug_implementations)] + pub struct pthread_mutex_t { // ToDo + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[repr(align(8))] + #[allow(missing_debug_implementations)] + pub struct pthread_cond_t { // ToDo + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + #[allow(missing_debug_implementations)] + pub struct pthread_rwlock_t { // ToDo + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + } + }; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/l4re.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/l4re.rs new file mode 100644 index 0000000..16ec0ef --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/l4re.rs @@ -0,0 +1,48 @@ +/// L4Re specifics +/// This module contains definitions required by various L4Re libc backends. +/// Some of them are formally not part of the libc, but are a dependency of the +/// libc and hence we should provide them here. + +pub type l4_umword_t = ::c_ulong; // Unsigned machine word. +pub type pthread_t = *mut ::c_void; + +s! { + /// CPU sets. + pub struct l4_sched_cpu_set_t { + // from the L4Re docs + /// Combination of granularity and offset. + /// + /// The granularity defines how many CPUs each bit in map describes. + /// The offset is the numer of the first CPU described by the first + /// bit in the bitmap. + /// offset must be a multiple of 2^graularity. + /// + /// | MSB | LSB | + /// | ---------------- | ------------------- | + /// | 8bit granularity | 24bit offset .. | + gran_offset: l4_umword_t , + /// Bitmap of CPUs. + map: l4_umword_t , + } +} + +#[cfg(target_os = "l4re")] +#[allow(missing_debug_implementations)] +pub struct pthread_attr_t { + pub __detachstate: ::c_int, + pub __schedpolicy: ::c_int, + pub __schedparam: super::__sched_param, + pub __inheritsched: ::c_int, + pub __scope: ::c_int, + pub __guardsize: ::size_t, + pub __stackaddr_set: ::c_int, + pub __stackaddr: *mut ::c_void, // better don't use it + pub __stacksize: ::size_t, + // L4Re specifics + pub affinity: l4_sched_cpu_set_t, + pub create_flags: ::c_uint, +} + +// L4Re requires a min stack size of 64k; that isn't defined in uClibc, but +// somewhere in the core libraries. uClibc wants 16k, but that's not enough. +pub const PTHREAD_STACK_MIN: usize = 65536; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/mod.rs new file mode 100644 index 0000000..a8bb079 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/mod.rs @@ -0,0 +1,312 @@ +//! Definitions for uclibc on 64bit systems +pub type blkcnt_t = i64; +pub type blksize_t = i64; +pub type clock_t = i64; +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type fsblkcnt_t = ::c_ulong; +pub type fsfilcnt_t = ::c_ulong; +pub type fsword_t = ::c_long; +pub type ino_t = ::c_ulong; +pub type nlink_t = ::c_uint; +pub type off_t = ::c_long; +pub type rlim_t = c_ulong; +pub type rlim64_t = u64; +// [uClibc docs] Note stat64 has the same shape as stat for x86-64. +pub type stat64 = stat; +pub type suseconds_t = ::c_long; +pub type time_t = ::c_int; +pub type wchar_t = ::c_int; + +s! { + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_ushort, // read / write + __pad1: ::c_ushort, + pub __seq: ::c_ushort, + __pad2: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } + + #[cfg(not(target_os = "l4re"))] + pub struct pthread_attr_t { + __detachstate: ::c_int, + __schedpolicy: ::c_int, + __schedparam: __sched_param, + __inheritsched: ::c_int, + __scope: ::c_int, + __guardsize: ::size_t, + __stackaddr_set: ::c_int, + __stackaddr: *mut ::c_void, // better don't use it + __stacksize: ::size_t, + } + + pub struct __sched_param { + __sched_priority: ::c_int, + } + + pub struct siginfo_t { + si_signo: ::c_int, // signal number + si_errno: ::c_int, // if not zero: error value of signal, see errno.h + si_code: ::c_int, // signal code + pub _pad: [::c_int; 28], // unported union + _align: [usize; 0], + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, // segment size in bytes + pub shm_atime: ::time_t, // time of last shmat() + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused1: ::c_ulong, + __unused2: ::c_ulong + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + pub msg_rtime: ::time_t, + pub msg_ctime: ::time_t, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __ignored1: ::c_ulong, + __ignored2: ::c_ulong, + } + + pub struct sockaddr { + pub sa_family: ::sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: ::sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + // ------------------------------------------------------------ + // definitions below are *unverified* and might **break** the software +// pub struct in_addr { +// pub s_addr: in_addr_t, +// } +// +// pub struct in6_addr { +// pub s6_addr: [u8; 16], +// #[cfg(not(libc_align))] +// __align: [u32; 0], +// } + + pub struct stat { + pub st_dev: ::c_ulong, + pub st_ino: ::ino_t, + // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of + // nlink and mode are swapped on 64 bit systems. + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulong, // dev_t + pub st_size: off_t, // file size + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_ulong, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_ulong, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_ulong, + st_pad4: [::c_long; 3] + } + + pub struct sigaction { + pub sa_handler: ::sighandler_t, + pub sa_flags: ::c_ulong, + pub sa_restorer: *mut ::c_void, + pub sa_mask: ::sigset_t, + } + + pub struct stack_t { // ToDo + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct statfs { // ToDo + pub f_type: fsword_t, + pub f_bsize: fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: fsword_t, + pub f_frsize: fsword_t, + f_spare: [fsword_t; 5], + } + + pub struct msghdr { // ToDo + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::size_t, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::size_t, + pub msg_flags: ::c_int, + } + + pub struct termios { // ToDo + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + } + + pub struct sigset_t { // ToDo + __val: [::c_ulong; 16], + } + + pub struct sysinfo { // ToDo + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 0], + } + + pub struct glob_t { // ToDo + pub gl_pathc: ::size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct rlimit64 { // ToDo + pub rlim_cur: rlim64_t, + pub rlim_max: rlim64_t, + } + + pub struct cpu_set_t { // ToDo + #[cfg(target_pointer_width = "32")] + bits: [u32; 32], + #[cfg(target_pointer_width = "64")] + bits: [u64; 16], + } + + pub struct fsid_t { // ToDo + __val: [::c_int; 2], + } +} + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct dirent { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: u16, + pub d_type: u8, + pub d_name: [::c_char; 256], + } + #[allow(missing_debug_implementations)] + pub struct dirent64 { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: u16, + pub d_type: u8, + pub d_name: [::c_char; 256], + } +} + +// constants +pub const EADDRINUSE: ::c_int = 98; // Address already in use +pub const EADDRNOTAVAIL: ::c_int = 99; // Cannot assign requested address +pub const ECONNABORTED: ::c_int = 103; // Software caused connection abort +pub const ECONNREFUSED: ::c_int = 111; // Connection refused +pub const ECONNRESET: ::c_int = 104; // Connection reset by peer +pub const EDEADLK: ::c_int = 35; // Resource deadlock would occur +pub const ENOSYS: ::c_int = 38; // Function not implemented +pub const ENOTCONN: ::c_int = 107; // Transport endpoint is not connected +pub const ETIMEDOUT: ::c_int = 110; // connection timed out +pub const O_APPEND: ::c_int = 02000; +pub const O_ACCMODE: ::c_int = 0003; +pub const O_CLOEXEC: ::c_int = 0x80000; +pub const O_CREAT: ::c_int = 0100; +pub const O_DIRECTORY: ::c_int = 0200000; +pub const O_EXCL: ::c_int = 0200; +pub const O_NONBLOCK: ::c_int = 04000; +pub const O_TRUNC: ::c_int = 01000; +pub const NCCS: usize = 32; +pub const SIG_SETMASK: ::c_int = 2; // Set the set of blocked signals +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const SO_BROADCAST: ::c_int = 6; +pub const SOCK_DGRAM: ::c_int = 2; // connectionless, unreliable datagrams +pub const SOCK_STREAM: ::c_int = 1; // …/common/bits/socket_type.h +pub const SO_ERROR: ::c_int = 4; +pub const SOL_SOCKET: ::c_int = 1; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const RLIM_INFINITY: u64 = 0xffffffffffffffff; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + +cfg_if! { + if #[cfg(target_os = "l4re")] { + mod l4re; + pub use self::l4re::*; + } else { + mod other; + pub use other::*; + } +} + +cfg_if! { + if #[cfg(libc_align)] { + #[macro_use] + mod align; + } else { + #[macro_use] + mod no_align; + } +} +expand_align!(); diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/no_align.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/no_align.rs new file mode 100644 index 0000000..422d78f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/no_align.rs @@ -0,0 +1,59 @@ +macro_rules! expand_align { + () => { + s! { + pub struct sem_t { // ToDo + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + __align: [::c_long; 0], + } + + pub struct pthread_mutex_t { // ToDo + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_mutexattr_t { // ToDo + #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_cond_t { // ToDo + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + pub struct pthread_condattr_t { // ToDo + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + + pub struct pthread_rwlock_t { // ToDo + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + } + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/other.rs b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/other.rs new file mode 100644 index 0000000..481577c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/unix/uclibc/x86_64/other.rs @@ -0,0 +1,5 @@ +// Thestyle checker discourages the use of #[cfg], so this has to go into a +// separate module +pub type pthread_t = ::c_ulong; + +pub const PTHREAD_STACK_MIN: usize = 16384; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/vxworks/aarch64.rs b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/aarch64.rs new file mode 100644 index 0000000..4032488 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/aarch64.rs @@ -0,0 +1,4 @@ +pub type c_char = u8; +pub type wchar_t = u32; +pub type c_long = i64; +pub type c_ulong = u64; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/vxworks/arm.rs b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/arm.rs new file mode 100644 index 0000000..5524006 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/arm.rs @@ -0,0 +1,4 @@ +pub type c_char = u8; +pub type wchar_t = u32; +pub type c_long = i32; +pub type c_ulong = u32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/vxworks/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/mod.rs new file mode 100755 index 0000000..a086ded --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/mod.rs @@ -0,0 +1,2086 @@ +//! Interface to VxWorks C library + +use core::mem::size_of; +use core::ptr::null_mut; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum DIR {} +impl ::Copy for DIR {} +impl ::Clone for DIR { + fn clone(&self) -> DIR { + *self + } +} + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type uintptr_t = usize; +pub type intptr_t = isize; +pub type ptrdiff_t = isize; +pub type size_t = ::uintptr_t; +pub type ssize_t = ::intptr_t; + +pub type pid_t = ::c_int; +pub type in_addr_t = u32; +pub type sighandler_t = ::size_t; +pub type cpuset_t = u32; + +pub type blkcnt_t = ::c_long; +pub type blksize_t = ::c_long; +pub type ino_t = ::c_ulong; + +pub type rlim_t = ::c_ulong; +pub type suseconds_t = ::c_long; +pub type time_t = ::c_long; + +pub type errno_t = ::c_int; + +pub type useconds_t = ::c_ulong; + +pub type socklen_t = ::c_uint; + +pub type pthread_t = ::c_ulong; + +pub type clockid_t = ::c_int; + +//defined for the structs +pub type dev_t = ::c_ulong; +pub type mode_t = ::c_int; +pub type nlink_t = ::c_ulong; +pub type uid_t = ::c_ushort; +pub type gid_t = ::c_ushort; +pub type sigset_t = ::c_ulonglong; +pub type key_t = ::c_long; + +pub type nfds_t = ::c_uint; +pub type stat64 = ::stat; + +pub type pthread_key_t = ::c_ulong; + +// From b_off_t.h +pub type off_t = ::c_longlong; +pub type off64_t = off_t; + +// From b_BOOL.h +pub type BOOL = ::c_int; + +// From vxWind.h .. +pub type _Vx_OBJ_HANDLE = ::c_int; +pub type _Vx_TASK_ID = ::_Vx_OBJ_HANDLE; +pub type _Vx_MSG_Q_ID = ::_Vx_OBJ_HANDLE; +pub type _Vx_SEM_ID_KERNEL = ::_Vx_OBJ_HANDLE; +pub type _Vx_RTP_ID = ::_Vx_OBJ_HANDLE; +pub type _Vx_SD_ID = ::_Vx_OBJ_HANDLE; +pub type _Vx_CONDVAR_ID = ::_Vx_OBJ_HANDLE; +pub type _Vx_SEM_ID = *mut ::_Vx_semaphore; +pub type OBJ_HANDLE = ::_Vx_OBJ_HANDLE; +pub type TASK_ID = ::OBJ_HANDLE; +pub type MSG_Q_ID = ::OBJ_HANDLE; +pub type SEM_ID_KERNEL = ::OBJ_HANDLE; +pub type RTP_ID = ::OBJ_HANDLE; +pub type SD_ID = ::OBJ_HANDLE; +pub type CONDVAR_ID = ::OBJ_HANDLE; + +// From vxTypes.h +pub type _Vx_usr_arg_t = isize; +pub type _Vx_exit_code_t = isize; +pub type _Vx_ticks_t = ::c_uint; +pub type _Vx_ticks64_t = ::c_ulonglong; + +pub type sa_family_t = ::c_uchar; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum _Vx_semaphore {} +impl ::Copy for _Vx_semaphore {} +impl ::Clone for _Vx_semaphore { + fn clone(&self) -> _Vx_semaphore { + *self + } +} + +s! { + // b_pthread_condattr_t.h + pub struct pthread_condattr_t { + pub condAttrStatus: ::c_int, + pub condAttrPshared: ::c_int, + pub condAttrClockId: ::clockid_t, + } + + // b_pthread_cond_t.h + pub struct pthread_cond_t{ + pub condSemId: ::_Vx_SEM_ID, + pub condValid: ::c_int, + pub condInitted: ::c_int, + pub condRefCount: ::c_int, + pub condMutex: *mut ::pthread_mutex_t, + pub condAttr: ::pthread_condattr_t, + pub condSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX] + } + + // b_pthread_rwlockattr_t.h + pub struct pthread_rwlockattr_t { + pub rwlockAttrStatus: ::c_int, + pub rwlockAttrPshared: ::c_int, + pub rwlockAttrMaxReaders: ::c_uint, + pub rwlockAttrConformOpt: ::c_uint, + } + + // b_pthread_rwlock_t.h + pub struct pthread_rwlock_t { + pub rwlockSemId: :: _Vx_SEM_ID, + pub rwlockReadersRefCount: ::c_uint, + pub rwlockValid: ::c_int, + pub rwlockInitted: ::c_int, + pub rwlockAttr: ::pthread_rwlockattr_t, + pub rwlockSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX] + } + + // b_struct_timeval.h + pub struct timeval { + pub tv_sec: ::time_t, + pub tv_usec: ::suseconds_t, + } + + // socket.h + pub struct linger { + pub l_onoff: ::c_int, + pub l_linger: ::c_int, + } + + pub struct sockaddr { + pub sa_len : ::c_uchar, + pub sa_family : sa_family_t, + pub sa_data : [::c_char; 14], + } + + pub struct iovec { + pub iov_base: *mut ::c_void, + pub iov_len: ::size_t, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: socklen_t, + pub msg_iov: *mut iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut c_void, + pub msg_controllen: socklen_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: socklen_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + // poll.h + pub struct pollfd { + pub fd : ::c_int, + pub events : ::c_short, + pub revents : ::c_short, + } + + // resource.h + pub struct rlimit { + pub rlim_cur : ::rlim_t, + pub rlim_max : ::rlim_t, + } + + // stat.h + pub struct stat { + pub st_dev : ::dev_t, + pub st_ino : ::ino_t, + pub st_mode : ::mode_t, + pub st_nlink : ::nlink_t, + pub st_uid : ::uid_t, + pub st_gid : ::gid_t, + pub st_rdev : ::dev_t, + pub st_size : ::off_t, + pub st_atime : ::time_t, + pub st_mtime : ::time_t, + pub st_ctime : ::time_t, + pub st_blksize : ::blksize_t, + pub st_blocks : ::blkcnt_t, + pub st_attrib : ::c_uchar, + pub st_reserved1 : ::c_int, + pub st_reserved2 : ::c_int, + pub st_reserved3 : ::c_int, + pub st_reserved4 : ::c_int, + } + + //b_struct__Timespec.h + pub struct _Timespec { + pub tv_sec : ::time_t, + pub tv_nsec : ::c_long, + } + + // b_struct__Sched_param.h + pub struct _Sched_param { + pub sched_priority: ::c_int, /* scheduling priority */ + pub sched_ss_low_priority: ::c_int, /* low scheduling priority */ + pub sched_ss_repl_period: ::_Timespec, /* replenishment period */ + pub sched_ss_init_budget: ::_Timespec, /* initial budget */ + pub sched_ss_max_repl: ::c_int, /* max pending replenishment */ + + } + + // b_pthread_attr_t.h + pub struct pthread_attr_t { + pub threadAttrStatus : ::c_int, + pub threadAttrStacksize : ::size_t, + pub threadAttrStackaddr : *mut ::c_void, + pub threadAttrGuardsize : ::size_t, + pub threadAttrDetachstate : ::c_int, + pub threadAttrContentionscope : ::c_int, + pub threadAttrInheritsched : ::c_int, + pub threadAttrSchedpolicy : ::c_int, + pub threadAttrName : *mut ::c_char, + pub threadAttrOptions : ::c_int, + pub threadAttrSchedparam : ::_Sched_param, + } + + // signal.h + + pub struct sigaction { + pub sa_u : ::sa_u_t, + pub sa_mask : ::sigset_t, + pub sa_flags : ::c_int, + } + + // b_stack_t.h + pub struct stack_t { + pub ss_sp : *mut ::c_void, + pub ss_size : ::size_t, + pub ss_flags : ::c_int, + } + + // signal.h + pub struct siginfo_t { + pub si_signo : ::c_int, + pub si_code : ::c_int, + pub si_value : ::sigval, + pub si_errno : ::c_int, + pub si_status: ::c_int, + pub si_addr: *mut ::c_void, + pub si_uid: ::uid_t, + pub si_pid: ::pid_t, + } + + // pthread.h (krnl) + // b_pthread_mutexattr_t.h (usr) + pub struct pthread_mutexattr_t { + mutexAttrStatus : ::c_int, + mutexAttrPshared : ::c_int, + mutexAttrProtocol : ::c_int, + mutexAttrPrioceiling : ::c_int, + mutexAttrType : ::c_int, + } + + // pthread.h (krnl) + // b_pthread_mutex_t.h (usr) + pub struct pthread_mutex_t { + pub mutexSemId: ::_Vx_SEM_ID, /*_Vx_SEM_ID ..*/ + pub mutexValid: ::c_int, + pub mutexInitted: ::c_int, + pub mutexCondRefCount: ::c_int, + pub mutexSavPriority: ::c_int, + pub mutexAttr: ::pthread_mutexattr_t, + pub mutexSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX], + } + + // b_struct_timespec.h + pub struct timespec { + pub tv_sec: ::time_t, + pub tv_nsec: ::c_long, + } + + // time.h + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + } + + // in.h + pub struct in_addr { + pub s_addr: in_addr_t, + } + + // in.h + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + // in6.h + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [u8; 16], + } + + // in6.h + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: ::c_uint, + } + + // netdb.h + pub struct addrinfo { + pub ai_flags : ::c_int, + pub ai_family : ::c_int, + pub ai_socktype : ::c_int, + pub ai_protocol : ::c_int, + pub ai_addrlen : ::size_t, + pub ai_canonname: *mut ::c_char, + pub ai_addr : *mut ::sockaddr, + pub ai_next : *mut ::addrinfo, + } + + // in.h + pub struct sockaddr_in { + pub sin_len : u8, + pub sin_family: u8, + pub sin_port : u16, + pub sin_addr : ::in_addr, + pub sin_zero : [::c_char; 8], + } + + // in6.h + pub struct sockaddr_in6 { + pub sin6_len : u8, + pub sin6_family : u8, + pub sin6_port : u16, + pub sin6_flowinfo: u32, + pub sin6_addr : ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } +} + +s_no_extra_traits! { + // dirent.h + pub struct dirent { + pub d_ino : ::ino_t, + pub d_name : [::c_char; _PARM_NAME_MAX as usize + 1], + } + + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 104] + } + + // rtpLibCommon.h + pub struct RTP_DESC { + pub status : ::c_int, + pub options : u32, + pub entrAddr : *mut ::c_void, + pub initTaskId: ::TASK_ID, + pub parentId : ::RTP_ID, + pub pathName : [::c_char; VX_RTP_NAME_LENGTH as usize + 1], + pub taskCnt : ::c_int, + pub textStart : *mut ::c_void, + pub textEnd : *mut ::c_void, + } + // socket.h + pub struct sockaddr_storage { + pub ss_len : ::c_uchar, + pub ss_family : ::sa_family_t, + pub __ss_pad1 : [::c_char; _SS_PAD1SIZE], + pub __ss_align : i32, + pub __ss_pad2 : [::c_char; _SS_PAD2SIZE], + } + + pub union sa_u_t { + pub sa_handler : ::Option !>, + pub sa_sigaction: ::Option !>, + } + + pub union sigval { + pub sival_int : ::c_int, + pub sival_ptr : *mut ::c_void, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_name", &&self.d_name[..]) + .finish() + } + } + + impl ::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_len", &self.sun_len) + .field("sun_family", &self.sun_family) + .field("sun_path", &&self.sun_path[..]) + .finish() + } + } + + impl ::fmt::Debug for RTP_DESC { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("RTP_DESC") + .field("status", &self.status) + .field("options", &self.options) + .field("entrAddr", &self.entrAddr) + .field("initTaskId", &self.initTaskId) + .field("parentId", &self.parentId) + .field("pathName", &&self.pathName[..]) + .field("taskCnt", &self.taskCnt) + .field("textStart", &self.textStart) + .field("textEnd", &self.textEnd) + .finish() + } + } + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_len", &self.ss_len) + .field("ss_family", &self.ss_family) + .field("__ss_pad1", &&self.__ss_pad1[..]) + .field("__ss_align", &self.__ss_align) + .field("__ss_pad2", &&self.__ss_pad2[..]) + .finish() + } + } + + impl PartialEq for sa_u_t { + fn eq(&self, other: &sa_u_t) -> bool { + unsafe { + let h1 = match self.sa_handler { + Some(handler) => handler as usize, + None => 0 as usize, + }; + let h2 = match other.sa_handler { + Some(handler) => handler as usize, + None => 0 as usize, + }; + h1 == h2 + } + } + } + impl Eq for sa_u_t {} + impl ::fmt::Debug for sa_u_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + unsafe { + let h = match self.sa_handler { + Some(handler) => handler as usize, + None => 0 as usize, + }; + + f.debug_struct("sa_u_t") + .field("sa_handler", &h) + .finish() + } + } + } + impl ::hash::Hash for sa_u_t { + fn hash(&self, state: &mut H) { + unsafe { + let h = match self.sa_handler { + Some(handler) => handler as usize, + None => 0 as usize, + }; + h.hash(state) + } + } + } + + impl PartialEq for sigval { + fn eq(&self, other: &sigval) -> bool { + unsafe { self.sival_ptr as usize == other.sival_ptr as usize } + } + } + impl Eq for sigval {} + impl ::fmt::Debug for sigval { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sigval") + .field("sival_ptr", unsafe { &(self.sival_ptr as usize) }) + .finish() + } + } + impl ::hash::Hash for sigval { + fn hash(&self, state: &mut H) { + unsafe { (self.sival_ptr as usize).hash(state) }; + } + } + } +} + +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; + +pub const EXIT_SUCCESS: ::c_int = 0; +pub const EXIT_FAILURE: ::c_int = 1; + +pub const EAI_SERVICE: ::c_int = 9; +pub const EAI_SOCKTYPE: ::c_int = 10; +pub const EAI_SYSTEM: ::c_int = 11; + +// This is not defined in vxWorks, but we have to define it here +// to make the building pass for getrandom and libstd, FIXME +pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; + +//Clock Lib Stuff +pub const CLOCK_REALTIME: ::c_int = 0x0; +pub const CLOCK_MONOTONIC: ::c_int = 0x1; +pub const CLOCK_PROCESS_CPUTIME_ID: ::c_int = 0x2; +pub const CLOCK_THREAD_CPUTIME_ID: ::c_int = 0x3; +pub const TIMER_ABSTIME: ::c_int = 0x1; +pub const TIMER_RELTIME: ::c_int = 0x0; + +// PTHREAD STUFF +pub const PTHREAD_INITIALIZED_OBJ: ::c_int = 0xF70990EF; +pub const PTHREAD_DESTROYED_OBJ: ::c_int = -1; +pub const PTHREAD_VALID_OBJ: ::c_int = 0xEC542A37; +pub const PTHREAD_INVALID_OBJ: ::c_int = -1; +pub const PTHREAD_UNUSED_YET_OBJ: ::c_int = -1; + +pub const PTHREAD_PRIO_NONE: ::c_int = 0; +pub const PTHREAD_PRIO_INHERIT: ::c_int = 1; +pub const PTHREAD_PRIO_PROTECT: ::c_int = 2; + +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_STACK_MIN: usize = 4096; +pub const _PTHREAD_SHARED_SEM_NAME_MAX: usize = 30; + +// ERRNO STUFF +pub const OK: ::c_int = 0; +pub const EPERM: ::c_int = 1; /* Not owner */ +pub const ENOENT: ::c_int = 2; /* No such file or directory */ +pub const ESRCH: ::c_int = 3; /* No such process */ +pub const EINTR: ::c_int = 4; /* Interrupted system call */ +pub const EIO: ::c_int = 5; /* I/O error */ +pub const ENXIO: ::c_int = 6; /* No such device or address */ +pub const E2BIG: ::c_int = 7; /* Arg list too long */ +pub const ENOEXEC: ::c_int = 8; /* Exec format error */ +pub const EBADF: ::c_int = 9; /* Bad file number */ +pub const ECHILD: ::c_int = 10; /* No children */ +pub const EAGAIN: ::c_int = 11; /* No more processes */ +pub const ENOMEM: ::c_int = 12; /* Not enough core */ +pub const EACCES: ::c_int = 13; /* Permission denied */ +pub const EFAULT: ::c_int = 14; +pub const ENOTEMPTY: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENAMETOOLONG: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const EROFS: ::c_int = 30; +pub const EPIPE: ::c_int = 32; +pub const EDEADLK: ::c_int = 33; +pub const ERANGE: ::c_int = 38; +pub const EDESTADDRREQ: ::c_int = 40; +pub const EPROTOTYPE: ::c_int = 41; +pub const ENOPROTOOPT: ::c_int = 42; +pub const EPROTONOSUPPORT: ::c_int = 43; +pub const ESOCKTNOSUPPORT: ::c_int = 44; +pub const EOPNOTSUPP: ::c_int = 45; +pub const EPFNOSUPPORT: ::c_int = 46; +pub const EAFNOSUPPORT: ::c_int = 47; +pub const EADDRINUSE: ::c_int = 48; +pub const EADDRNOTAVAIL: ::c_int = 49; +pub const ENOTSOCK: ::c_int = 50; +pub const ENETUNREACH: ::c_int = 51; +pub const ENETRESET: ::c_int = 52; +pub const ECONNABORTED: ::c_int = 53; +pub const ECONNRESET: ::c_int = 54; +pub const ENOBUFS: ::c_int = 55; +pub const EISCONN: ::c_int = 56; +pub const ENOTCONN: ::c_int = 57; +pub const ESHUTDOWN: ::c_int = 58; +pub const ETOOMANYREFS: ::c_int = 59; +pub const ETIMEDOUT: ::c_int = 60; +pub const ECONNREFUSED: ::c_int = 61; +pub const EINPROGRESS: ::c_int = 68; +pub const EALREADY: ::c_int = 69; +pub const EWOULDBLOCK: ::c_int = 70; +pub const ENOSYS: ::c_int = 71; +pub const EDQUOT: ::c_int = 83; +pub const ESTALE: ::c_int = 88; + +// NFS errnos: Refer to pkgs_v2/storage/fs/nfs/h/nfs/nfsCommon.h +const M_nfsStat: ::c_int = 48 << 16; +enum nfsstat { + NFSERR_REMOTE = 71, + NFSERR_WFLUSH = 99, + NFSERR_BADHANDLE = 10001, + NFSERR_NOT_SYNC = 10002, + NFSERR_BAD_COOKIE = 10003, + NFSERR_TOOSMALL = 10005, + NFSERR_BADTYPE = 10007, + NFSERR_JUKEBOX = 10008, +} + +pub const S_nfsLib_NFS_OK: ::c_int = OK; +pub const S_nfsLib_NFSERR_PERM: ::c_int = EPERM; +pub const S_nfsLib_NFSERR_NOENT: ::c_int = ENOENT; +pub const S_nfsLib_NFSERR_IO: ::c_int = EIO; +pub const S_nfsLib_NFSERR_NXIO: ::c_int = ENXIO; +pub const S_nfsLib_NFSERR_ACCESS: ::c_int = EACCES; +pub const S_nfsLib_NFSERR_EXIST: ::c_int = EEXIST; +pub const S_nfsLib_NFSERR_ENODEV: ::c_int = ENODEV; +pub const S_nfsLib_NFSERR_NOTDIR: ::c_int = ENOTDIR; +pub const S_nfsLib_NFSERR_ISDIR: ::c_int = EISDIR; +pub const S_nfsLib_NFSERR_INVAL: ::c_int = EINVAL; +pub const S_nfsLib_NFSERR_FBIG: ::c_int = EFBIG; +pub const S_nfsLib_NFSERR_NOSPC: ::c_int = ENOSPC; +pub const S_nfsLib_NFSERR_ROFS: ::c_int = EROFS; +pub const S_nfsLib_NFSERR_NAMETOOLONG: ::c_int = ENAMETOOLONG; +pub const S_nfsLib_NFSERR_NOTEMPTY: ::c_int = ENOTEMPTY; +pub const S_nfsLib_NFSERR_DQUOT: ::c_int = EDQUOT; +pub const S_nfsLib_NFSERR_STALE: ::c_int = ESTALE; +pub const S_nfsLib_NFSERR_WFLUSH: ::c_int = + M_nfsStat | nfsstat::NFSERR_WFLUSH as ::c_int; +pub const S_nfsLib_NFSERR_REMOTE: ::c_int = + M_nfsStat | nfsstat::NFSERR_REMOTE as ::c_int; +pub const S_nfsLib_NFSERR_BADHANDLE: ::c_int = + M_nfsStat | nfsstat::NFSERR_BADHANDLE as ::c_int; +pub const S_nfsLib_NFSERR_NOT_SYNC: ::c_int = + M_nfsStat | nfsstat::NFSERR_NOT_SYNC as ::c_int; +pub const S_nfsLib_NFSERR_BAD_COOKIE: ::c_int = + M_nfsStat | nfsstat::NFSERR_BAD_COOKIE as ::c_int; +pub const S_nfsLib_NFSERR_NOTSUPP: ::c_int = EOPNOTSUPP; +pub const S_nfsLib_NFSERR_TOOSMALL: ::c_int = + M_nfsStat | nfsstat::NFSERR_TOOSMALL as ::c_int; +pub const S_nfsLib_NFSERR_SERVERFAULT: ::c_int = EIO; +pub const S_nfsLib_NFSERR_BADTYPE: ::c_int = + M_nfsStat | nfsstat::NFSERR_BADTYPE as ::c_int; +pub const S_nfsLib_NFSERR_JUKEBOX: ::c_int = + M_nfsStat | nfsstat::NFSERR_JUKEBOX as ::c_int; + +// in.h +pub const IPPROTO_IP: ::c_int = 0; +pub const IPPROTO_IPV6: ::c_int = 41; + +pub const IP_TTL: ::c_int = 4; +pub const IP_MULTICAST_IF: ::c_int = 9; +pub const IP_MULTICAST_TTL: ::c_int = 10; +pub const IP_MULTICAST_LOOP: ::c_int = 11; +pub const IP_ADD_MEMBERSHIP: ::c_int = 12; +pub const IP_DROP_MEMBERSHIP: ::c_int = 13; + +// in6.h +pub const IPV6_V6ONLY: ::c_int = 1; +pub const IPV6_UNICAST_HOPS: ::c_int = 4; +pub const IPV6_MULTICAST_IF: ::c_int = 9; +pub const IPV6_MULTICAST_HOPS: ::c_int = 10; +pub const IPV6_MULTICAST_LOOP: ::c_int = 11; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; + +// STAT Stuff +pub const S_IFMT: ::c_int = 0xf000; +pub const S_IFIFO: ::c_int = 0x1000; +pub const S_IFCHR: ::c_int = 0x2000; +pub const S_IFDIR: ::c_int = 0x4000; +pub const S_IFBLK: ::c_int = 0x6000; +pub const S_IFREG: ::c_int = 0x8000; +pub const S_IFLNK: ::c_int = 0xa000; +pub const S_IFSHM: ::c_int = 0xb000; +pub const S_IFSOCK: ::c_int = 0xc000; +pub const S_ISUID: ::c_int = 0x0800; +pub const S_ISGID: ::c_int = 0x0400; +pub const S_ISTXT: ::c_int = 0x0200; +pub const S_IRUSR: ::c_int = 0x0100; +pub const S_IWUSR: ::c_int = 0x0080; +pub const S_IXUSR: ::c_int = 0x0040; +pub const S_IRWXU: ::c_int = 0x01c0; +pub const S_IRGRP: ::c_int = 0x0020; +pub const S_IWGRP: ::c_int = 0x0010; +pub const S_IXGRP: ::c_int = 0x0008; +pub const S_IRWXG: ::c_int = 0x0038; +pub const S_IROTH: ::c_int = 0x0004; +pub const S_IWOTH: ::c_int = 0x0002; +pub const S_IXOTH: ::c_int = 0x0001; +pub const S_IRWXO: ::c_int = 0x0007; + +// socket.h +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_DEBUG: ::c_int = 0x0001; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_RCVLOWAT: ::c_int = 0x0012; +pub const SO_SNDLOWAT: ::c_int = 0x0013; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_ACCEPTCONN: ::c_int = 0x001e; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_REUSEPORT: ::c_int = 0x0200; + +pub const SO_VLAN: ::c_int = 0x8000; + +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_BINDTODEVICE: ::c_int = 0x1010; +pub const SO_OOBINLINE: ::c_int = 0x1011; +pub const SO_CONNTIMEO: ::c_int = 0x100a; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_RDM: ::c_int = 4; +pub const SOCK_SEQPACKET: ::c_int = 5; +pub const SOCK_PACKET: ::c_int = 10; + +pub const _SS_MAXSIZE: usize = 128; +pub const _SS_ALIGNSIZE: usize = size_of::(); +pub const _SS_PAD1SIZE: usize = + (_SS_ALIGNSIZE - size_of::<::c_uchar>() - size_of::<::sa_family_t>()); +pub const _SS_PAD2SIZE: usize = (_SS_MAXSIZE + - size_of::<::c_uchar>() + - size_of::<::sa_family_t>() + - _SS_PAD1SIZE + - _SS_ALIGNSIZE); + +pub const MSG_OOB: ::c_int = 0x0001; +pub const MSG_PEEK: ::c_int = 0x0002; +pub const MSG_DONTROUTE: ::c_int = 0x0004; +pub const MSG_EOR: ::c_int = 0x0008; +pub const MSG_TRUNC: ::c_int = 0x0010; +pub const MSG_CTRUNC: ::c_int = 0x0020; +pub const MSG_WAITALL: ::c_int = 0x0040; +pub const MSG_DONTWAIT: ::c_int = 0x0080; +pub const MSG_EOF: ::c_int = 0x0100; +pub const MSG_EXP: ::c_int = 0x0200; +pub const MSG_MBUF: ::c_int = 0x0400; +pub const MSG_NOTIFICATION: ::c_int = 0x0800; +pub const MSG_COMPAT: ::c_int = 0x8000; + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_LOCAL: ::c_int = 1; +pub const AF_UNIX: ::c_int = AF_LOCAL; +pub const AF_INET: ::c_int = 2; +pub const AF_NETLINK: ::c_int = 16; +pub const AF_ROUTE: ::c_int = 17; +pub const AF_LINK: ::c_int = 18; +pub const AF_PACKET: ::c_int = 19; +pub const pseudo_AF_KEY: ::c_int = 27; +pub const AF_KEY: ::c_int = pseudo_AF_KEY; +pub const AF_INET6: ::c_int = 28; +pub const AF_SOCKDEV: ::c_int = 31; +pub const AF_TIPC: ::c_int = 33; +pub const AF_MIPC: ::c_int = 34; +pub const AF_MIPC_SAFE: ::c_int = 35; +pub const AF_MAX: ::c_int = 37; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const IPPROTO_TCP: ::c_int = 6; +pub const TCP_NODELAY: ::c_int = 1; +pub const TCP_MAXSEG: ::c_int = 2; +pub const TCP_NOPUSH: ::c_int = 3; +pub const TCP_KEEPIDLE: ::c_int = 4; +pub const TCP_KEEPINTVL: ::c_int = 5; +pub const TCP_KEEPCNT: ::c_int = 6; + +// ioLib.h +pub const FIONREAD: ::c_int = 0x40040001; +pub const FIOFLUSH: ::c_int = 2; +pub const FIOOPTIONS: ::c_int = 3; +pub const FIOBAUDRATE: ::c_int = 4; +pub const FIODISKFORMAT: ::c_int = 5; +pub const FIODISKINIT: ::c_int = 6; +pub const FIOSEEK: ::c_int = 7; +pub const FIOWHERE: ::c_int = 8; +pub const FIODIRENTRY: ::c_int = 9; +pub const FIORENAME: ::c_int = 10; +pub const FIOREADYCHANGE: ::c_int = 11; +pub const FIODISKCHANGE: ::c_int = 13; +pub const FIOCANCEL: ::c_int = 14; +pub const FIOSQUEEZE: ::c_int = 15; +pub const FIOGETNAME: ::c_int = 18; +pub const FIONBIO: ::c_int = 0x90040010; + +// limits.h +pub const PATH_MAX: ::c_int = _PARM_PATH_MAX; +pub const _POSIX_PATH_MAX: ::c_int = 256; + +// Some poll stuff +pub const POLLIN: ::c_short = 0x0001; +pub const POLLPRI: ::c_short = 0x0002; +pub const POLLOUT: ::c_short = 0x0004; +pub const POLLRDNORM: ::c_short = 0x0040; +pub const POLLWRNORM: ::c_short = POLLOUT; +pub const POLLRDBAND: ::c_short = 0x0080; +pub const POLLWRBAND: ::c_short = 0x0100; +pub const POLLERR: ::c_short = 0x0008; +pub const POLLHUP: ::c_short = 0x0010; +pub const POLLNVAL: ::c_short = 0x0020; + +// fnctlcom.h +pub const FD_CLOEXEC: ::c_int = 1; +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; +pub const F_GETOWN: ::c_int = 5; +pub const F_SETOWN: ::c_int = 6; +pub const F_GETLK: ::c_int = 7; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; +pub const F_DUPFD_CLOEXEC: ::c_int = 14; + +// signal.h +pub const SIG_DFL: sighandler_t = 0 as sighandler_t; +pub const SIG_IGN: sighandler_t = 1 as sighandler_t; +pub const SIG_ERR: sighandler_t = -1 as isize as sighandler_t; + +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGTRAP: ::c_int = 5; +pub const SIGABRT: ::c_int = 6; +pub const SIGEMT: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGBUS: ::c_int = 10; +pub const SIGSEGV: ::c_int = 11; +pub const SIGFMT: ::c_int = 12; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; +pub const SIGCNCL: ::c_int = 16; +pub const SIGSTOP: ::c_int = 17; +pub const SIGTSTP: ::c_int = 18; +pub const SIGCONT: ::c_int = 19; +pub const SIGCHLD: ::c_int = 20; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; + +pub const SIG_BLOCK: ::c_int = 1; +pub const SIG_UNBLOCK: ::c_int = 2; +pub const SIG_SETMASK: ::c_int = 3; + +pub const SI_SYNC: ::c_int = 0; +pub const SI_USER: ::c_int = -1; +pub const SI_QUEUE: ::c_int = -2; +pub const SI_TIMER: ::c_int = -3; +pub const SI_ASYNCIO: ::c_int = -4; +pub const SI_MESGQ: ::c_int = -5; +pub const SI_CHILD: ::c_int = -6; +pub const SI_KILL: ::c_int = SI_USER; + +// vxParams.h definitions +pub const _PARM_NAME_MAX: ::c_int = 255; +pub const _PARM_PATH_MAX: ::c_int = 1024; + +// WAIT STUFF +pub const WNOHANG: ::c_int = 0x01; +pub const WUNTRACED: ::c_int = 0x02; + +const PTHREAD_MUTEXATTR_INITIALIZER: pthread_mutexattr_t = + pthread_mutexattr_t { + mutexAttrStatus: PTHREAD_INITIALIZED_OBJ, + mutexAttrProtocol: PTHREAD_PRIO_NONE, + mutexAttrPrioceiling: 0, + mutexAttrType: PTHREAD_MUTEX_DEFAULT, + mutexAttrPshared: 1, + }; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + mutexSemId: null_mut(), + mutexValid: PTHREAD_VALID_OBJ, + mutexInitted: PTHREAD_UNUSED_YET_OBJ, + mutexCondRefCount: 0, + mutexSavPriority: -1, + mutexAttr: PTHREAD_MUTEXATTR_INITIALIZER, + mutexSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX], +}; + +const PTHREAD_CONDATTR_INITIALIZER: pthread_condattr_t = pthread_condattr_t { + condAttrStatus: 0xf70990ef, + condAttrPshared: 1, + condAttrClockId: CLOCK_REALTIME, +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + condSemId: null_mut(), + condValid: PTHREAD_VALID_OBJ, + condInitted: PTHREAD_UNUSED_YET_OBJ, + condRefCount: 0, + condMutex: null_mut(), + condAttr: PTHREAD_CONDATTR_INITIALIZER, + condSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX], +}; + +const PTHREAD_RWLOCKATTR_INITIALIZER: pthread_rwlockattr_t = + pthread_rwlockattr_t { + rwlockAttrStatus: PTHREAD_INITIALIZED_OBJ, + rwlockAttrPshared: 1, + rwlockAttrMaxReaders: 0, + rwlockAttrConformOpt: 1, + }; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + rwlockSemId: null_mut(), + rwlockReadersRefCount: 0, + rwlockValid: PTHREAD_VALID_OBJ, + rwlockInitted: PTHREAD_UNUSED_YET_OBJ, + rwlockAttr: PTHREAD_RWLOCKATTR_INITIALIZER, + rwlockSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX], +}; + +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; + +// rtpLibCommon.h +pub const VX_RTP_NAME_LENGTH: ::c_int = 255; +pub const RTP_ID_ERROR: ::RTP_ID = -1; + +// h/public/unistd.h +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 21; // Via unistd.h +pub const _SC_PAGESIZE: ::c_int = 39; +pub const O_ACCMODE: ::c_int = 3; +pub const O_CLOEXEC: ::c_int = 0x100000; // fcntlcom +pub const O_EXCL: ::c_int = 0x0800; +pub const O_CREAT: ::c_int = 0x0200; +pub const O_TRUNC: ::c_int = 0x0400; +pub const O_APPEND: ::c_int = 0x0008; +pub const O_RDWR: ::c_int = 0x0002; +pub const O_WRONLY: ::c_int = 0x0001; +pub const O_RDONLY: ::c_int = 0; +pub const O_NONBLOCK: ::c_int = 0x4000; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum FILE {} +impl ::Copy for FILE {} +impl ::Clone for FILE { + fn clone(&self) -> FILE { + *self + } +} +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum fpos_t {} // TODO: fill this out with a struct +impl ::Copy for fpos_t {} +impl ::Clone for fpos_t { + fn clone(&self) -> fpos_t { + *self + } +} + +f! { + pub fn CMSG_ALIGN(len: usize) -> usize { + len + ::mem::size_of::() - 1 & !(::mem::size_of::() - 1) + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, + cmsg: *const cmsghdr) -> *mut cmsghdr { + let next = cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize) + + CMSG_ALIGN(::mem::size_of::<::cmsghdr>()); + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next <= max { + (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) + as *mut ::cmsghdr + } else { + 0 as *mut ::cmsghdr + } + } + + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize > 0 { + (*mhdr).msg_control as *mut cmsghdr + } else { + 0 as *mut cmsghdr + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar { + (cmsg as *mut ::c_uchar) + .offset(CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::())) + as ::c_uint + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + CMSG_ALIGN(::mem::size_of::()) as ::c_uint + length + } +} + +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen( + filename: *const c_char, + mode: *const c_char, + file: *mut FILE, + ) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf( + stream: *mut FILE, + buffer: *mut c_char, + mode: c_int, + size: size_t, + ) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) + -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread( + ptr: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE, + ) -> size_t; + pub fn fwrite( + ptr: *const c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE, + ) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atoi(s: *const c_char) -> c_int; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_long; + pub fn strtoul( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn atexit(cb: extern "C" fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy( + dst: *mut c_char, + src: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat( + s: *mut c_char, + ct: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp( + s1: *const c_char, + s2: *const c_char, + n: size_t, + ) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs( + dest: *mut c_char, + src: *const wchar_t, + n: size_t, + ) -> ::size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memmove( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; +} + +extern "C" { + pub fn fprintf( + stream: *mut ::FILE, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn printf(format: *const ::c_char, ...) -> ::c_int; + pub fn snprintf( + s: *mut ::c_char, + n: ::size_t, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int; + pub fn fscanf( + stream: *mut ::FILE, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn scanf(format: *const ::c_char, ...) -> ::c_int; + pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) + -> ::c_int; + pub fn getchar_unlocked() -> ::c_int; + pub fn putchar_unlocked(c: ::c_int) -> ::c_int; + pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; + pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; + pub fn fileno(stream: *mut ::FILE) -> ::c_int; + pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; + pub fn rewinddir(dirp: *mut ::DIR); + pub fn fchown(fd: ::c_int, owner: ::uid_t, group: ::gid_t) -> ::c_int; + pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; + pub fn alarm(seconds: ::c_uint) -> ::c_uint; + pub fn fchdir(dirfd: ::c_int) -> ::c_int; + pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int; + pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) -> ::c_int; + pub fn getlogin() -> *mut c_char; + pub fn getopt( + argc: ::c_int, + argv: *const *mut c_char, + optstr: *const c_char, + ) -> ::c_int; + pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long; + pub fn pause() -> ::c_int; + pub fn seteuid(uid: uid_t) -> ::c_int; + pub fn setegid(gid: gid_t) -> ::c_int; + pub fn sleep(secs: ::c_uint) -> ::c_uint; + pub fn ttyname(fd: ::c_int) -> *mut c_char; + pub fn wait(status: *mut ::c_int) -> pid_t; + pub fn umask(mask: mode_t) -> mode_t; + pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn mlockall(flags: ::c_int) -> ::c_int; + pub fn munlockall() -> ::c_int; + + pub fn mmap( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + flags: ::c_int, + fd: ::c_int, + offset: off_t, + ) -> *mut ::c_void; + pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; + pub fn truncate(path: *const c_char, length: off_t) -> ::c_int; + + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + pub fn pthread_exit(value: *mut ::c_void) -> !; + pub fn pthread_attr_setdetachstate( + attr: *mut ::pthread_attr_t, + state: ::c_int, + ) -> ::c_int; + + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + pub fn sigaction( + signum: ::c_int, + act: *const sigaction, + oldact: *mut sigaction, + ) -> ::c_int; + + pub fn utimes( + filename: *const ::c_char, + times: *const ::timeval, + ) -> ::c_int; + + #[link_name = "_rtld_dlopen"] + pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void; + + #[link_name = "_rtld_dlerror"] + pub fn dlerror() -> *mut ::c_char; + + #[link_name = "_rtld_dlsym"] + pub fn dlsym( + handle: *mut ::c_void, + symbol: *const ::c_char, + ) -> *mut ::c_void; + + #[link_name = "_rtld_dlclose"] + pub fn dlclose(handle: *mut ::c_void) -> ::c_int; + + #[link_name = "_rtld_dladdr"] + pub fn dladdr(addr: *mut ::c_void, info: *mut Dl_info) -> ::c_int; + + // time.h + pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + pub fn mktime(tm: *mut tm) -> time_t; + pub fn time(time: *mut time_t) -> time_t; + pub fn gmtime(time_p: *const time_t) -> *mut tm; + pub fn localtime(time_p: *const time_t) -> *mut tm; + pub fn timegm(tm: *mut tm) -> time_t; + pub fn difftime(time1: time_t, time0: time_t) -> ::c_double; + pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn usleep(secs: ::useconds_t) -> ::c_int; + pub fn putenv(string: *mut c_char) -> ::c_int; + pub fn setlocale( + category: ::c_int, + locale: *const ::c_char, + ) -> *mut ::c_char; + + pub fn sigprocmask( + how: ::c_int, + set: *const sigset_t, + oldset: *mut sigset_t, + ) -> ::c_int; + pub fn sigpending(set: *mut sigset_t) -> ::c_int; + + pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int; + + pub fn fseeko( + stream: *mut ::FILE, + offset: ::off_t, + whence: ::c_int, + ) -> ::c_int; + pub fn ftello(stream: *mut ::FILE) -> ::off_t; + pub fn mkstemp(template: *mut ::c_char) -> ::c_int; + + pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char; + + pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int); + pub fn closelog(); + pub fn setlogmask(maskpri: ::c_int) -> ::c_int; + pub fn syslog(priority: ::c_int, message: *const ::c_char, ...); + pub fn getline( + lineptr: *mut *mut c_char, + n: *mut size_t, + stream: *mut FILE, + ) -> ssize_t; + +} + +extern "C" { + // stdlib.h + pub fn memalign(block_size: ::size_t, size_arg: ::size_t) + -> *mut ::c_void; + + // ioLib.h + pub fn getcwd(buf: *mut ::c_char, size: ::size_t) -> *mut ::c_char; + + // ioLib.h + pub fn chdir(attr: *const ::c_char) -> ::c_int; + + // pthread.h + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int; + + // pthread.h + pub fn pthread_mutexattr_destroy( + attr: *mut pthread_mutexattr_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_mutexattr_settype( + pAttr: *mut ::pthread_mutexattr_t, + pType: ::c_int, + ) -> ::c_int; + + // pthread.h + pub fn pthread_mutex_init( + mutex: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_mutex_destroy(mutex: *mut pthread_mutex_t) -> ::c_int; + + // pthread.h + pub fn pthread_mutex_lock(mutex: *mut pthread_mutex_t) -> ::c_int; + + // pthread.h + pub fn pthread_mutex_trylock(mutex: *mut pthread_mutex_t) -> ::c_int; + + // pthread.h + pub fn pthread_mutex_timedlock( + attr: *mut pthread_mutex_t, + spec: *const timespec, + ) -> ::c_int; + + // pthread.h + pub fn pthread_mutex_unlock(mutex: *mut pthread_mutex_t) -> ::c_int; + + // pthread.h + pub fn pthread_attr_setname( + pAttr: *mut ::pthread_attr_t, + name: *mut ::c_char, + ) -> ::c_int; + + // pthread.h + pub fn pthread_attr_setstacksize( + attr: *mut ::pthread_attr_t, + stacksize: ::size_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_attr_getstacksize( + attr: *const ::pthread_attr_t, + size: *mut ::size_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; + + // pthread.h + pub fn pthread_create( + pThread: *mut ::pthread_t, + pAttr: *const ::pthread_attr_t, + start_routine: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + + // pthread.h + pub fn pthread_attr_destroy(thread: *mut ::pthread_attr_t) -> ::c_int; + + // pthread.h + pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; + + // int pthread_atfork (void (*)(void), void (*)(void), void (*)(void)); + pub fn pthread_atfork( + prepare: ::Option, + parent: ::Option, + child: ::Option, + ) -> ::c_int; + // stat.h + pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; + + // stat.h + pub fn lstat(path: *const ::c_char, buf: *mut stat) -> ::c_int; + + // unistd.h + pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int; + + // dirent.h + pub fn readdir_r( + pDir: *mut ::DIR, + entry: *mut ::dirent, + result: *mut *mut ::dirent, + ) -> ::c_int; + + // dirent.h + pub fn readdir(pDir: *mut ::DIR) -> *mut ::dirent; + + // fcntl.h or + // ioLib.h + pub fn open(path: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; + + // poll.h + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; + + // pthread.h + pub fn pthread_condattr_init(attr: *mut ::pthread_condattr_t) -> ::c_int; + + // pthread.h + pub fn pthread_condattr_destroy( + attr: *mut ::pthread_condattr_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_condattr_getclock( + pAttr: *const ::pthread_condattr_t, + pClockId: *mut ::clockid_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_condattr_setclock( + pAttr: *mut ::pthread_condattr_t, + clockId: ::clockid_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_cond_init( + cond: *mut ::pthread_cond_t, + attr: *const ::pthread_condattr_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int; + + // pthread.h + pub fn pthread_cond_signal(cond: *mut ::pthread_cond_t) -> ::c_int; + + // pthread.h + pub fn pthread_cond_broadcast(cond: *mut ::pthread_cond_t) -> ::c_int; + + // pthread.h + pub fn pthread_cond_wait( + cond: *mut ::pthread_cond_t, + mutex: *mut ::pthread_mutex_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_rwlockattr_init( + attr: *mut ::pthread_rwlockattr_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_rwlockattr_destroy( + attr: *mut ::pthread_rwlockattr_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_rwlockattr_setmaxreaders( + attr: *mut ::pthread_rwlockattr_t, + attr2: ::c_uint, + ) -> ::c_int; + + // pthread.h + pub fn pthread_rwlock_init( + attr: *mut ::pthread_rwlock_t, + host: *const ::pthread_rwlockattr_t, + ) -> ::c_int; + + // pthread.h + pub fn pthread_rwlock_destroy(attr: *mut ::pthread_rwlock_t) -> ::c_int; + + // pthread.h + pub fn pthread_rwlock_rdlock(attr: *mut ::pthread_rwlock_t) -> ::c_int; + + // pthread.h + pub fn pthread_rwlock_tryrdlock(attr: *mut ::pthread_rwlock_t) -> ::c_int; + + // pthread.h + pub fn pthread_rwlock_timedrdlock( + attr: *mut ::pthread_rwlock_t, + host: *const ::timespec, + ) -> ::c_int; + + // pthread.h + pub fn pthread_rwlock_wrlock(attr: *mut ::pthread_rwlock_t) -> ::c_int; + + // pthread.h + pub fn pthread_rwlock_trywrlock(attr: *mut ::pthread_rwlock_t) -> ::c_int; + + // pthread.h + pub fn pthread_rwlock_timedwrlock( + attr: *mut ::pthread_rwlock_t, + host: *const ::timespec, + ) -> ::c_int; + + // pthread.h + pub fn pthread_rwlock_unlock(attr: *mut ::pthread_rwlock_t) -> ::c_int; + + // pthread.h + pub fn pthread_key_create( + key: *mut ::pthread_key_t, + dtor: ::Option, + ) -> ::c_int; + + // pthread.h + pub fn pthread_key_delete(key: ::pthread_key_t) -> ::c_int; + + // pthread.h + pub fn pthread_setspecific( + key: ::pthread_key_t, + value: *const ::c_void, + ) -> ::c_int; + + // pthread.h + pub fn pthread_getspecific(key: ::pthread_key_t) -> *mut ::c_void; + + // pthread.h + pub fn pthread_cond_timedwait( + cond: *mut ::pthread_cond_t, + mutex: *mut ::pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + + // pthread.h + pub fn pthread_attr_getname( + attr: *mut ::pthread_attr_t, + name: *mut *mut ::c_char, + ) -> ::c_int; + + // pthread.h + pub fn pthread_join( + thread: ::pthread_t, + status: *mut *mut ::c_void, + ) -> ::c_int; + + // pthread.h + pub fn pthread_self() -> ::pthread_t; + + // clockLib.h + pub fn clock_gettime( + clock_id: ::clockid_t, + tp: *mut ::timespec, + ) -> ::c_int; + + // clockLib.h + pub fn clock_settime( + clock_id: ::clockid_t, + tp: *const ::timespec, + ) -> ::c_int; + + // clockLib.h + pub fn clock_getres( + clock_id: ::clockid_t, + res: *mut ::timespec, + ) -> ::c_int; + + // clockLib.h + pub fn clock_nanosleep( + clock_id: ::clockid_t, + flags: ::c_int, + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + + // timerLib.h + pub fn nanosleep( + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + + // socket.h + pub fn accept( + s: ::c_int, + addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, + ) -> ::c_int; + + // socket.h + pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) + -> ::c_int; + + // socket.h + pub fn connect( + s: ::c_int, + name: *const ::sockaddr, + namelen: ::socklen_t, + ) -> ::c_int; + + // socket.h + pub fn getpeername( + s: ::c_int, + name: *mut ::sockaddr, + namelen: *mut ::socklen_t, + ) -> ::c_int; + + // socket.h + pub fn getsockname( + socket: ::c_int, + address: *mut sockaddr, + address_len: *mut socklen_t, + ) -> ::c_int; + + // socket.h + pub fn getsockopt( + sockfd: ::c_int, + level: ::c_int, + optname: ::c_int, + optval: *mut ::c_void, + optlen: *mut ::socklen_t, + ) -> ::c_int; + + // socket.h + pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; + + // socket.h + pub fn recv( + s: ::c_int, + buf: *mut ::c_void, + bufLen: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + + // socket.h + pub fn recvfrom( + s: ::c_int, + buf: *mut ::c_void, + bufLen: ::size_t, + flags: ::c_int, + from: *mut ::sockaddr, + pFromLen: *mut ::socklen_t, + ) -> ::ssize_t; + + pub fn recvmsg( + socket: ::c_int, + mp: *mut ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + + // socket.h + pub fn send( + socket: ::c_int, + buf: *const ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + + pub fn sendmsg( + socket: ::c_int, + mp: *const ::msghdr, + flags: ::c_int, + ) -> ::ssize_t; + + // socket.h + pub fn sendto( + socket: ::c_int, + buf: *const ::c_void, + len: ::size_t, + flags: ::c_int, + addr: *const sockaddr, + addrlen: socklen_t, + ) -> ::ssize_t; + + // socket.h + pub fn setsockopt( + socket: ::c_int, + level: ::c_int, + name: ::c_int, + value: *const ::c_void, + option_len: socklen_t, + ) -> ::c_int; + + // socket.h + pub fn shutdown(s: ::c_int, how: ::c_int) -> ::c_int; + + // socket.h + pub fn socket( + domain: ::c_int, + _type: ::c_int, + protocol: ::c_int, + ) -> ::c_int; + + // icotl.h + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; + + // fcntl.h + pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; + + // ntp_rfc2553.h for kernel + // netdb.h for user + pub fn gai_strerror(errcode: ::c_int) -> *mut ::c_char; + + // ioLib.h or + // unistd.h + pub fn close(fd: ::c_int) -> ::c_int; + + // ioLib.h or + // unistd.h + pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) + -> ::ssize_t; + + // ioLib.h or + // unistd.h + pub fn write( + fd: ::c_int, + buf: *const ::c_void, + count: ::size_t, + ) -> ::ssize_t; + + // ioLib.h or + // unistd.h + pub fn isatty(fd: ::c_int) -> ::c_int; + + // ioLib.h or + // unistd.h + pub fn dup(src: ::c_int) -> ::c_int; + + // ioLib.h or + // unistd.h + pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; + + // ioLib.h or + // unistd.h + pub fn pipe(fds: *mut ::c_int) -> ::c_int; + + // ioLib.h or + // unistd.h + pub fn unlink(pathname: *const ::c_char) -> ::c_int; + + // unistd.h and + // ioLib.h + pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t; + + // netdb.h + pub fn getaddrinfo( + node: *const ::c_char, + service: *const ::c_char, + hints: *const addrinfo, + res: *mut *mut addrinfo, + ) -> ::c_int; + + // netdb.h + pub fn freeaddrinfo(res: *mut addrinfo); + + // signal.h + pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t; + + // unistd.h + pub fn getpid() -> pid_t; + + // unistd.h + pub fn getppid() -> pid_t; + + // wait.h + pub fn waitpid(pid: pid_t, status: *mut ::c_int, optons: ::c_int) + -> pid_t; + + // unistd.h + pub fn sysconf(attr: ::c_int) -> ::c_long; + + // stdlib.h + pub fn setenv( + // setenv.c + envVarName: *const ::c_char, + envVarValue: *const ::c_char, + overwrite: ::c_int, + ) -> ::c_int; + + // stdlib.h + pub fn unsetenv( + // setenv.c + envVarName: *const ::c_char, + ) -> ::c_int; + + // stdlib.h + pub fn realpath( + fileName: *const ::c_char, + resolvedName: *mut ::c_char, + ) -> *mut ::c_char; + + // unistd.h + pub fn link(src: *const ::c_char, dst: *const ::c_char) -> ::c_int; + + // unistd.h + pub fn readlink( + path: *const ::c_char, + buf: *mut ::c_char, + bufsize: ::size_t, + ) -> ::ssize_t; + + // unistd.h + pub fn symlink(path1: *const ::c_char, path2: *const ::c_char) -> ::c_int; + + // dirent.h + pub fn opendir(name: *const ::c_char) -> *mut ::DIR; + + // unistd.h + pub fn rmdir(path: *const ::c_char) -> ::c_int; + + // stat.h + pub fn mkdir(dirName: *const ::c_char, mode: ::mode_t) -> ::c_int; + + // stat.h + pub fn chmod(path: *const ::c_char, mode: ::mode_t) -> ::c_int; + + // stat.h + pub fn fchmod(attr1: ::c_int, attr2: ::mode_t) -> ::c_int; + + // unistd.h + pub fn fsync(fd: ::c_int) -> ::c_int; + + // dirent.h + pub fn closedir(ptr: *mut ::DIR) -> ::c_int; + + // sched.h + pub fn sched_yield() -> ::c_int; + + // errnoLib.h + pub fn errnoSet(err: ::c_int) -> ::c_int; + + // errnoLib.h + pub fn errnoGet() -> ::c_int; + + // unistd.h + pub fn _exit(status: ::c_int) -> !; + + // unistd.h + pub fn setgid(gid: ::gid_t) -> ::c_int; + + // unistd.h + pub fn getgid() -> ::gid_t; + + // unistd.h + pub fn setuid(uid: ::uid_t) -> ::c_int; + + // unistd.h + pub fn getuid() -> ::uid_t; + + // signal.h + pub fn sigemptyset(__set: *mut sigset_t) -> ::c_int; + + // pthread.h for kernel + // signal.h for user + pub fn pthread_sigmask( + __how: ::c_int, + __set: *const sigset_t, + __oset: *mut sigset_t, + ) -> ::c_int; + + // signal.h for user + pub fn kill(__pid: pid_t, __signo: ::c_int) -> ::c_int; + + // signal.h for user + pub fn sigqueue( + __pid: pid_t, + __signo: ::c_int, + __value: ::sigval, + ) -> ::c_int; + + // signal.h for user + pub fn _sigqueue( + rtpId: ::RTP_ID, + signo: ::c_int, + pValue: *const ::sigval, + sigCode: ::c_int, + ) -> ::c_int; + + // signal.h + pub fn taskKill(taskId: ::TASK_ID, signo: ::c_int) -> ::c_int; + + // signal.h + pub fn raise(__signo: ::c_int) -> ::c_int; + + // taskLibCommon.h + pub fn taskIdSelf() -> ::TASK_ID; + pub fn taskDelay(ticks: ::_Vx_ticks_t) -> ::c_int; + + // rtpLibCommon.h + pub fn rtpInfoGet(rtpId: ::RTP_ID, rtpStruct: *mut ::RTP_DESC) -> ::c_int; + pub fn rtpSpawn( + pubrtpFileName: *const ::c_char, + argv: *mut *const ::c_char, + envp: *mut *const ::c_char, + priority: ::c_int, + uStackSize: ::size_t, + options: ::c_int, + taskOptions: ::c_int, + ) -> RTP_ID; + + // ioLib.h + pub fn _realpath( + fileName: *const ::c_char, + resolvedName: *mut ::c_char, + ) -> *mut ::c_char; + + // pathLib.h + pub fn _pathIsAbsolute( + filepath: *const ::c_char, + pNameTail: *mut *const ::c_char, + ) -> BOOL; + + pub fn writev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + pub fn readv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + + // randomNumGen.h + pub fn randBytes(buf: *mut c_uchar, length: c_int) -> c_int; + pub fn randABytes(buf: *mut c_uchar, length: c_int) -> c_int; + pub fn randUBytes(buf: *mut c_uchar, length: c_int) -> c_int; + pub fn randSecure() -> c_int; +} + +//Dummy functions, these don't really exist in VxWorks. + +// wait.h macros +pub fn WIFEXITED(status: ::c_int) -> bool { + (status & 0xFF00) == 0 +} +pub fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0xFF00) != 0 +} +pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0xFF0000) != 0 +} +pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + status & 0xFF +} +pub fn WTERMSIG(status: ::c_int) -> ::c_int { + (status >> 8) & 0xFF +} +pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + (status >> 16) & 0xFF +} + +pub fn pread( + _fd: ::c_int, + _buf: *mut ::c_void, + _count: ::size_t, + _offset: off64_t, +) -> ::ssize_t { + -1 +} + +pub fn pwrite( + _fd: ::c_int, + _buf: *const ::c_void, + _count: ::size_t, + _offset: off64_t, +) -> ::ssize_t { + -1 +} +pub fn posix_memalign( + memptr: *mut *mut ::c_void, + align: ::size_t, + size: ::size_t, +) -> ::c_int { + // check to see if align is a power of 2 and if align is a multiple + // of sizeof(void *) + if (align & align - 1 != 0) + || (align as usize % size_of::<::size_t>() != 0) + { + return ::EINVAL; + } + + unsafe { + // posix_memalign should not set errno + let e = ::errnoGet(); + + let temp = memalign(align, size); + ::errnoSet(e as ::c_int); + + if temp.is_null() { + ::ENOMEM + } else { + *memptr = temp; + 0 + } + } +} + +cfg_if! { + if #[cfg(libc_core_cvoid)] { + pub use ::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(any(target_arch = "arm"))] { + mod arm; + pub use self::arm::*; + } else if #[cfg(any(target_arch = "x86"))] { + mod x86; + pub use self::x86::*; + } else if #[cfg(any(target_arch = "x86_64"))] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(any(target_arch = "powerpc"))] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(any(target_arch = "powerpc64"))] { + mod powerpc64; + pub use self::powerpc64::*; + } else { + // Unknown target_arch + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/vxworks/powerpc.rs b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/powerpc.rs new file mode 100644 index 0000000..5524006 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/powerpc.rs @@ -0,0 +1,4 @@ +pub type c_char = u8; +pub type wchar_t = u32; +pub type c_long = i32; +pub type c_ulong = u32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/vxworks/powerpc64.rs b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/powerpc64.rs new file mode 100644 index 0000000..4032488 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/powerpc64.rs @@ -0,0 +1,4 @@ +pub type c_char = u8; +pub type wchar_t = u32; +pub type c_long = i64; +pub type c_ulong = u64; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/vxworks/x86.rs b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/x86.rs new file mode 100644 index 0000000..e617bb8 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/x86.rs @@ -0,0 +1,4 @@ +pub type c_char = i8; +pub type wchar_t = i32; +pub type c_long = i32; +pub type c_ulong = u32; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/vxworks/x86_64.rs b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/x86_64.rs new file mode 100644 index 0000000..5e95ea2 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/vxworks/x86_64.rs @@ -0,0 +1,4 @@ +pub type c_char = i8; +pub type wchar_t = i32; +pub type c_long = i64; +pub type c_ulong = u64; diff --git a/third_party/cargo/vendor/libc-0.2.66/src/wasi.rs b/third_party/cargo/vendor/libc-0.2.66/src/wasi.rs new file mode 100644 index 0000000..2e0914d --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/wasi.rs @@ -0,0 +1,743 @@ +pub use ffi::c_void; + +pub type c_char = i8; +pub type c_uchar = u8; +pub type c_schar = i8; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type size_t = usize; +pub type ssize_t = isize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type off_t = i64; +pub type pid_t = i32; +pub type clock_t = c_longlong; +pub type time_t = c_longlong; +pub type c_double = f64; +pub type c_float = f32; +pub type ino_t = u64; +pub type sigset_t = c_uchar; +pub type suseconds_t = c_longlong; +pub type mode_t = u32; +pub type dev_t = u64; +pub type uid_t = u32; +pub type gid_t = u32; +pub type nlink_t = u64; +pub type blksize_t = c_long; +pub type blkcnt_t = i64; +pub type nfds_t = c_ulong; + +pub type __wasi_rights_t = u64; + +#[allow(missing_copy_implementations)] +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum FILE {} +#[allow(missing_copy_implementations)] +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum DIR {} +#[allow(missing_copy_implementations)] +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum __locale_struct {} + +pub type locale_t = *mut __locale_struct; + +s! { + #[repr(align(8))] + pub struct fpos_t { + data: [u8; 16], + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub __tm_gmtoff: c_int, + pub __tm_zone: *const c_char, + pub __tm_nsec: c_int, + } + + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub struct tms { + pub tms_utime: clock_t, + pub tms_stime: clock_t, + pub tms_cutime: clock_t, + pub tms_cstime: clock_t, + } + + pub struct itimerspec { + pub it_interval: timespec, + pub it_value: timespec, + } + + pub struct iovec { + pub iov_base: *mut c_void, + pub iov_len: size_t, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct pollfd { + pub fd: c_int, + pub events: c_short, + pub revents: c_short, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_nlink: nlink_t, + pub st_mode: mode_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + __pad0: c_uint, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_atim: timespec, + pub st_mtim: timespec, + pub st_ctim: timespec, + __reserved: [c_longlong; 3], + } +} + +// Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash, +// etc., since it contains a flexible array member with a dynamic size. +#[repr(C)] +#[allow(missing_copy_implementations)] +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub struct dirent { + pub d_ino: ino_t, + pub d_type: c_uchar, + /// d_name is declared in WASI libc as a flexible array member, which + /// can't be directly expressed in Rust. As an imperfect workaround, + /// declare it as a zero-length array instead. + pub d_name: [c_char; 0], +} + +pub const EXIT_SUCCESS: c_int = 0; +pub const EXIT_FAILURE: c_int = 1; +pub const STDIN_FILENO: c_int = 0; +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; +pub const SEEK_SET: c_int = 2; +pub const SEEK_CUR: c_int = 0; +pub const SEEK_END: c_int = 1; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; +pub const FD_SETSIZE: size_t = 1024; +pub const O_APPEND: c_int = 0x0001; +pub const O_DSYNC: c_int = 0x0002; +pub const O_NONBLOCK: c_int = 0x0004; +pub const O_RSYNC: c_int = 0x0008; +pub const O_SYNC: c_int = 0x0010; +pub const O_CREAT: c_int = 0x0001 << 12; +pub const O_DIRECTORY: c_int = 0x0002 << 12; +pub const O_EXCL: c_int = 0x0004 << 12; +pub const O_TRUNC: c_int = 0x0008 << 12; +pub const O_NOFOLLOW: c_int = 0x01000000; +pub const O_EXEC: c_int = 0x02000000; +pub const O_RDONLY: c_int = 0x04000000; +pub const O_SEARCH: c_int = 0x08000000; +pub const O_WRONLY: c_int = 0x10000000; +pub const O_RDWR: c_int = O_WRONLY | O_RDONLY; +pub const O_ACCMODE: c_int = O_EXEC | O_RDWR | O_SEARCH; +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; +pub const POSIX_FADV_NORMAL: c_int = 0; +pub const POSIX_FADV_RANDOM: c_int = 2; +pub const POSIX_FADV_SEQUENTIAL: c_int = 1; +pub const POSIX_FADV_WILLNEED: c_int = 3; +pub const AT_EACCESS: c_int = 0x0; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x1; +pub const AT_SYMLINK_FOLLOW: c_int = 0x2; +pub const AT_REMOVEDIR: c_int = 0x4; +pub const UTIME_OMIT: c_long = 1073741822; +pub const UTIME_NOW: c_long = 1073741823; + +pub const E2BIG: c_int = 1; +pub const EACCES: c_int = 2; +pub const EADDRINUSE: c_int = 3; +pub const EADDRNOTAVAIL: c_int = 4; +pub const EAFNOSUPPORT: c_int = 5; +pub const EAGAIN: c_int = 6; +pub const EALREADY: c_int = 7; +pub const EBADF: c_int = 8; +pub const EBADMSG: c_int = 9; +pub const EBUSY: c_int = 10; +pub const ECANCELED: c_int = 11; +pub const ECHILD: c_int = 12; +pub const ECONNABORTED: c_int = 13; +pub const ECONNREFUSED: c_int = 14; +pub const ECONNRESET: c_int = 15; +pub const EDEADLK: c_int = 16; +pub const EDESTADDRREQ: c_int = 17; +pub const EDOM: c_int = 18; +pub const EDQUOT: c_int = 19; +pub const EEXIST: c_int = 20; +pub const EFAULT: c_int = 21; +pub const EFBIG: c_int = 22; +pub const EHOSTUNREACH: c_int = 23; +pub const EIDRM: c_int = 24; +pub const EILSEQ: c_int = 25; +pub const EINPROGRESS: c_int = 26; +pub const EINTR: c_int = 27; +pub const EINVAL: c_int = 28; +pub const EIO: c_int = 29; +pub const EISCONN: c_int = 30; +pub const EISDIR: c_int = 31; +pub const ELOOP: c_int = 32; +pub const EMFILE: c_int = 33; +pub const EMLINK: c_int = 34; +pub const EMSGSIZE: c_int = 35; +pub const EMULTIHOP: c_int = 36; +pub const ENAMETOOLONG: c_int = 37; +pub const ENETDOWN: c_int = 38; +pub const ENETRESET: c_int = 39; +pub const ENETUNREACH: c_int = 40; +pub const ENFILE: c_int = 41; +pub const ENOBUFS: c_int = 42; +pub const ENODEV: c_int = 43; +pub const ENOENT: c_int = 44; +pub const ENOEXEC: c_int = 45; +pub const ENOLCK: c_int = 46; +pub const ENOLINK: c_int = 47; +pub const ENOMEM: c_int = 48; +pub const ENOMSG: c_int = 49; +pub const ENOPROTOOPT: c_int = 50; +pub const ENOSPC: c_int = 51; +pub const ENOSYS: c_int = 52; +pub const ENOTCONN: c_int = 53; +pub const ENOTDIR: c_int = 54; +pub const ENOTEMPTY: c_int = 55; +pub const ENOTRECOVERABLE: c_int = 56; +pub const ENOTSOCK: c_int = 57; +pub const ENOTSUP: c_int = 58; +pub const ENOTTY: c_int = 59; +pub const ENXIO: c_int = 60; +pub const EOVERFLOW: c_int = 61; +pub const EOWNERDEAD: c_int = 62; +pub const EPERM: c_int = 63; +pub const EPIPE: c_int = 64; +pub const EPROTO: c_int = 65; +pub const EPROTONOSUPPORT: c_int = 66; +pub const EPROTOTYPE: c_int = 67; +pub const ERANGE: c_int = 68; +pub const EROFS: c_int = 69; +pub const ESPIPE: c_int = 70; +pub const ESRCH: c_int = 71; +pub const ESTALE: c_int = 72; +pub const ETIMEDOUT: c_int = 73; +pub const ETXTBSY: c_int = 74; +pub const EXDEV: c_int = 75; +pub const ENOTCAPABLE: c_int = 76; +pub const EOPNOTSUPP: c_int = ENOTSUP; +pub const EWOULDBLOCK: c_int = EAGAIN; + +#[cfg_attr( + feature = "rustc-dep-of-std", + link(name = "c", kind = "static", cfg(target_feature = "crt-static")) +)] +#[cfg_attr( + feature = "rustc-dep-of-std", + link(name = "c", cfg(not(target_feature = "crt-static"))) +)] +extern "C" { + pub fn _Exit(code: c_int) -> !; + pub fn _exit(code: c_int) -> !; + pub fn abort() -> !; + pub fn aligned_alloc(a: size_t, b: size_t) -> *mut c_void; + pub fn calloc(amt: size_t, amt2: size_t) -> *mut c_void; + pub fn exit(code: c_int) -> !; + pub fn free(ptr: *mut c_void); + pub fn getenv(s: *const c_char) -> *mut c_char; + pub fn malloc(amt: size_t) -> *mut c_void; + pub fn malloc_usable_size(ptr: *mut c_void) -> size_t; + pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void; + pub fn rand() -> c_int; + pub fn read(fd: c_int, ptr: *mut c_void, size: size_t) -> ssize_t; + pub fn realloc(ptr: *mut c_void, amt: size_t) -> *mut c_void; + pub fn setenv(k: *const c_char, v: *const c_char, a: c_int) -> c_int; + pub fn unsetenv(k: *const c_char) -> c_int; + pub fn clearenv() -> ::c_int; + pub fn write(fd: c_int, ptr: *const c_void, size: size_t) -> ssize_t; + pub static mut environ: *mut *mut c_char; + pub fn fopen(a: *const c_char, b: *const c_char) -> *mut FILE; + pub fn freopen( + a: *const c_char, + b: *const c_char, + f: *mut FILE, + ) -> *mut FILE; + pub fn fclose(f: *mut FILE) -> c_int; + pub fn remove(a: *const c_char) -> c_int; + pub fn rename(a: *const c_char, b: *const c_char) -> c_int; + pub fn feof(f: *mut FILE) -> c_int; + pub fn ferror(f: *mut FILE) -> c_int; + pub fn fflush(f: *mut FILE) -> c_int; + pub fn clearerr(f: *mut FILE); + pub fn fseek(f: *mut FILE, b: c_long, c: c_int) -> c_int; + pub fn ftell(f: *mut FILE) -> c_long; + pub fn rewind(f: *mut FILE); + pub fn fgetpos(f: *mut FILE, pos: *mut fpos_t) -> c_int; + pub fn fsetpos(f: *mut FILE, pos: *const fpos_t) -> c_int; + pub fn fread( + buf: *mut c_void, + a: size_t, + b: size_t, + f: *mut FILE, + ) -> size_t; + pub fn fwrite( + buf: *const c_void, + a: size_t, + b: size_t, + f: *mut FILE, + ) -> size_t; + pub fn fgetc(f: *mut FILE) -> c_int; + pub fn getc(f: *mut FILE) -> c_int; + pub fn getchar() -> c_int; + pub fn ungetc(a: c_int, f: *mut FILE) -> c_int; + pub fn fputc(a: c_int, f: *mut FILE) -> c_int; + pub fn putc(a: c_int, f: *mut FILE) -> c_int; + pub fn putchar(a: c_int) -> c_int; + pub fn fputs(a: *const c_char, f: *mut FILE) -> c_int; + pub fn puts(a: *const c_char) -> c_int; + pub fn perror(a: *const c_char); + pub fn srand(a: c_uint); + pub fn atexit(a: extern "C" fn()) -> c_int; + pub fn at_quick_exit(a: extern "C" fn()) -> c_int; + pub fn quick_exit(a: c_int) -> !; + pub fn posix_memalign(a: *mut *mut c_void, b: size_t, c: size_t) -> c_int; + pub fn rand_r(a: *mut c_uint) -> c_int; + pub fn random() -> c_long; + pub fn srandom(a: c_uint); + pub fn putenv(a: *mut c_char) -> c_int; + pub fn clock() -> clock_t; + pub fn time(a: *mut time_t) -> time_t; + pub fn difftime(a: time_t, b: time_t) -> c_double; + pub fn mktime(a: *mut tm) -> time_t; + pub fn strftime( + a: *mut c_char, + b: size_t, + c: *const c_char, + d: *const tm, + ) -> size_t; + pub fn gmtime(a: *const time_t) -> *mut tm; + pub fn gmtime_r(a: *const time_t, b: *mut tm) -> *mut tm; + pub fn localtime_r(a: *const time_t, b: *mut tm) -> *mut tm; + pub fn asctime_r(a: *const tm, b: *mut c_char) -> *mut c_char; + pub fn ctime_r(a: *const time_t, b: *mut c_char) -> *mut c_char; + + pub fn nanosleep(a: *const timespec, b: *mut timespec) -> c_int; + // pub fn clock_getres(a: clockid_t, b: *mut timespec) -> c_int; + // pub fn clock_gettime(a: clockid_t, b: *mut timespec) -> c_int; + // pub fn clock_nanosleep( + // a: clockid_t, + // a2: c_int, + // b: *const timespec, + // c: *mut timespec, + // ) -> c_int; + + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn setvbuf( + stream: *mut FILE, + buffer: *mut c_char, + mode: c_int, + size: size_t, + ) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) + -> *mut c_char; + pub fn atoi(s: *const c_char) -> c_int; + pub fn atof(s: *const c_char) -> c_double; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_long; + pub fn strtoul( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_ulong; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy( + dst: *mut c_char, + src: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat( + s: *mut c_char, + ct: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp( + s1: *const c_char, + s2: *const c_char, + n: size_t, + ) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memmove( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn fprintf( + stream: *mut ::FILE, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn printf(format: *const ::c_char, ...) -> ::c_int; + pub fn snprintf( + s: *mut ::c_char, + n: ::size_t, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int; + pub fn fscanf( + stream: *mut ::FILE, + format: *const ::c_char, + ... + ) -> ::c_int; + pub fn scanf(format: *const ::c_char, ...) -> ::c_int; + pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) + -> ::c_int; + pub fn getchar_unlocked() -> ::c_int; + pub fn putchar_unlocked(c: ::c_int) -> ::c_int; + + pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int; + pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; + pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int; + pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; + pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; + pub fn fileno(stream: *mut ::FILE) -> ::c_int; + pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; + pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; + pub fn opendir(dirname: *const c_char) -> *mut ::DIR; + pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; + pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent; + pub fn closedir(dirp: *mut ::DIR) -> ::c_int; + pub fn rewinddir(dirp: *mut ::DIR); + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + + pub fn openat( + dirfd: ::c_int, + pathname: *const ::c_char, + flags: ::c_int, + ... + ) -> ::c_int; + pub fn fstatat( + dirfd: ::c_int, + pathname: *const ::c_char, + buf: *mut stat, + flags: ::c_int, + ) -> ::c_int; + pub fn linkat( + olddirfd: ::c_int, + oldpath: *const ::c_char, + newdirfd: ::c_int, + newpath: *const ::c_char, + flags: ::c_int, + ) -> ::c_int; + pub fn mkdirat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::mode_t, + ) -> ::c_int; + pub fn readlinkat( + dirfd: ::c_int, + pathname: *const ::c_char, + buf: *mut ::c_char, + bufsiz: ::size_t, + ) -> ::ssize_t; + pub fn renameat( + olddirfd: ::c_int, + oldpath: *const ::c_char, + newdirfd: ::c_int, + newpath: *const ::c_char, + ) -> ::c_int; + pub fn symlinkat( + target: *const ::c_char, + newdirfd: ::c_int, + linkpath: *const ::c_char, + ) -> ::c_int; + pub fn unlinkat( + dirfd: ::c_int, + pathname: *const ::c_char, + flags: ::c_int, + ) -> ::c_int; + + pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; + pub fn close(fd: ::c_int) -> ::c_int; + pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; + pub fn getopt( + argc: ::c_int, + argv: *const *mut c_char, + optstr: *const c_char, + ) -> ::c_int; + pub fn isatty(fd: ::c_int) -> ::c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int; + pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t; + pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long; + pub fn pause() -> ::c_int; + pub fn rmdir(path: *const c_char) -> ::c_int; + pub fn sleep(secs: ::c_uint) -> ::c_uint; + pub fn unlink(c: *const c_char) -> ::c_int; + pub fn pread( + fd: ::c_int, + buf: *mut ::c_void, + count: ::size_t, + offset: off_t, + ) -> ::ssize_t; + pub fn pwrite( + fd: ::c_int, + buf: *const ::c_void, + count: ::size_t, + offset: off_t, + ) -> ::ssize_t; + + pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; + + pub fn fsync(fd: ::c_int) -> ::c_int; + pub fn fdatasync(fd: ::c_int) -> ::c_int; + + pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int; + + pub fn truncate(path: *const c_char, length: off_t) -> ::c_int; + pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int; + + pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; + + pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; + pub fn times(buf: *mut ::tms) -> ::clock_t; + + pub fn strerror_r( + errnum: ::c_int, + buf: *mut c_char, + buflen: ::size_t, + ) -> ::c_int; + + pub fn usleep(secs: ::c_uint) -> ::c_int; + pub fn send( + socket: ::c_int, + buf: *const ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + pub fn recv( + socket: ::c_int, + buf: *mut ::c_void, + len: ::size_t, + flags: ::c_int, + ) -> ::ssize_t; + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; + pub fn setlocale( + category: ::c_int, + locale: *const ::c_char, + ) -> *mut ::c_char; + pub fn localeconv() -> *mut lconv; + + pub fn readlink( + path: *const c_char, + buf: *mut c_char, + bufsz: ::size_t, + ) -> ::ssize_t; + + pub fn timegm(tm: *mut ::tm) -> time_t; + + pub fn sysconf(name: ::c_int) -> ::c_long; + + pub fn fseeko( + stream: *mut ::FILE, + offset: ::off_t, + whence: ::c_int, + ) -> ::c_int; + pub fn ftello(stream: *mut ::FILE) -> ::off_t; + pub fn posix_fallocate( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + ) -> ::c_int; + + pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn getline( + lineptr: *mut *mut c_char, + n: *mut size_t, + stream: *mut FILE, + ) -> ssize_t; + + pub fn faccessat( + dirfd: ::c_int, + pathname: *const ::c_char, + mode: ::c_int, + flags: ::c_int, + ) -> ::c_int; + pub fn writev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + pub fn readv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + ) -> ::ssize_t; + pub fn pwritev( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn preadv( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t, + ) -> ::ssize_t; + pub fn posix_fadvise( + fd: ::c_int, + offset: ::off_t, + len: ::off_t, + advise: ::c_int, + ) -> ::c_int; + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn utimensat( + dirfd: ::c_int, + path: *const ::c_char, + times: *const ::timespec, + flag: ::c_int, + ) -> ::c_int; + pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; + pub fn memrchr( + cx: *const ::c_void, + c: ::c_int, + n: ::size_t, + ) -> *mut ::c_void; + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn duplocale(base: ::locale_t) -> ::locale_t; + pub fn freelocale(loc: ::locale_t); + pub fn newlocale( + mask: ::c_int, + locale: *const ::c_char, + base: ::locale_t, + ) -> ::locale_t; + pub fn uselocale(loc: ::locale_t) -> ::locale_t; + pub fn sched_yield() -> ::c_int; + + pub fn __wasilibc_register_preopened_fd( + fd: c_int, + path: *const c_char, + ) -> c_int; + pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int; + pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int; + pub fn __wasilibc_rmdirat(fd: c_int, path: *const c_char) -> c_int; + pub fn __wasilibc_init_preopen(); + pub fn __wasilibc_find_relpath( + path: *const c_char, + rights_base: __wasi_rights_t, + rights_inheriting: __wasi_rights_t, + relative_path: *mut *const c_char, + ) -> c_int; + pub fn __wasilibc_tell(fd: c_int) -> ::off_t; + + pub fn arc4random() -> u32; + pub fn arc4random_buf(a: *mut c_void, b: size_t); + pub fn arc4random_uniform(a: u32) -> u32; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/windows/gnu/align.rs b/third_party/cargo/vendor/libc-0.2.66/src/windows/gnu/align.rs new file mode 100644 index 0000000..3af99e3 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/windows/gnu/align.rs @@ -0,0 +1,19 @@ +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } + } + } else if #[cfg(target_pointer_width = "32")] { + s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [i64; 6] + } + } + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/windows/gnu/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/windows/gnu/mod.rs new file mode 100644 index 0000000..e74628b --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/windows/gnu/mod.rs @@ -0,0 +1,23 @@ +pub const L_tmpnam: ::c_uint = 14; +pub const TMP_MAX: ::c_uint = 0x7fff; + +// stdio file descriptor numbers +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; + +extern "C" { + pub fn strcasecmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int; + pub fn strncasecmp( + s1: *const ::c_char, + s2: *const ::c_char, + n: ::size_t, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/windows/mod.rs b/third_party/cargo/vendor/libc-0.2.66/src/windows/mod.rs new file mode 100644 index 0000000..a83baba --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/windows/mod.rs @@ -0,0 +1,604 @@ +//! Windows CRT definitions + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; +pub type sighandler_t = usize; + +pub type c_char = i8; +pub type c_long = i32; +pub type c_ulong = u32; +pub type wchar_t = u16; + +pub type clock_t = i32; + +cfg_if! { + if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { + pub type time_t = i32; + } else { + pub type time_t = i64; + } +} + +pub type off_t = i32; +pub type dev_t = u32; +pub type ino_t = u16; +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum timezone {} +impl ::Copy for timezone {} +impl ::Clone for timezone { + fn clone(&self) -> timezone { + *self + } +} +pub type time64_t = i64; + +pub type SOCKET = ::uintptr_t; + +s! { + // note this is the struct called stat64 in Windows. Not stat, nor stati64. + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: u16, + pub st_nlink: ::c_short, + pub st_uid: ::c_short, + pub st_gid: ::c_short, + pub st_rdev: dev_t, + pub st_size: i64, + pub st_atime: time64_t, + pub st_mtime: time64_t, + pub st_ctime: time64_t, + } + + // note that this is called utimbuf64 in Windows + pub struct utimbuf { + pub actime: time64_t, + pub modtime: time64_t, + } + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + } + + pub struct timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } + + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub struct sockaddr { + pub sa_family: c_ushort, + pub sa_data: [c_char; 14], + } +} + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 32767; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 4; +pub const _IOLBF: ::c_int = 64; +pub const BUFSIZ: ::c_uint = 512; +pub const FOPEN_MAX: ::c_uint = 20; +pub const FILENAME_MAX: ::c_uint = 260; + +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 256; +pub const O_EXCL: ::c_int = 1024; +pub const O_TEXT: ::c_int = 16384; +pub const O_BINARY: ::c_int = 32768; +pub const O_NOINHERIT: ::c_int = 128; +pub const O_TRUNC: ::c_int = 512; +pub const S_IFCHR: ::c_int = 8192; +pub const S_IFDIR: ::c_int = 16384; +pub const S_IFREG: ::c_int = 32768; +pub const S_IFMT: ::c_int = 61440; +pub const S_IEXEC: ::c_int = 64; +pub const S_IWRITE: ::c_int = 128; +pub const S_IREAD: ::c_int = 256; + +pub const LC_ALL: ::c_int = 0; +pub const LC_COLLATE: ::c_int = 1; +pub const LC_CTYPE: ::c_int = 2; +pub const LC_MONETARY: ::c_int = 3; +pub const LC_NUMERIC: ::c_int = 4; +pub const LC_TIME: ::c_int = 5; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const EDEADLK: ::c_int = 36; +pub const EDEADLOCK: ::c_int = 36; +pub const ENAMETOOLONG: ::c_int = 38; +pub const ENOLCK: ::c_int = 39; +pub const ENOSYS: ::c_int = 40; +pub const ENOTEMPTY: ::c_int = 41; +pub const EILSEQ: ::c_int = 42; +pub const STRUNCATE: ::c_int = 80; + +// POSIX Supplement (from errno.h) +pub const EADDRINUSE: ::c_int = 100; +pub const EADDRNOTAVAIL: ::c_int = 101; +pub const EAFNOSUPPORT: ::c_int = 102; +pub const EALREADY: ::c_int = 103; +pub const EBADMSG: ::c_int = 104; +pub const ECANCELED: ::c_int = 105; +pub const ECONNABORTED: ::c_int = 106; +pub const ECONNREFUSED: ::c_int = 107; +pub const ECONNRESET: ::c_int = 108; +pub const EDESTADDRREQ: ::c_int = 109; +pub const EHOSTUNREACH: ::c_int = 110; +pub const EIDRM: ::c_int = 111; +pub const EINPROGRESS: ::c_int = 112; +pub const EISCONN: ::c_int = 113; +pub const ELOOP: ::c_int = 114; +pub const EMSGSIZE: ::c_int = 115; +pub const ENETDOWN: ::c_int = 116; +pub const ENETRESET: ::c_int = 117; +pub const ENETUNREACH: ::c_int = 118; +pub const ENOBUFS: ::c_int = 119; +pub const ENODATA: ::c_int = 120; +pub const ENOLINK: ::c_int = 121; +pub const ENOMSG: ::c_int = 122; +pub const ENOPROTOOPT: ::c_int = 123; +pub const ENOSR: ::c_int = 124; +pub const ENOSTR: ::c_int = 125; +pub const ENOTCONN: ::c_int = 126; +pub const ENOTRECOVERABLE: ::c_int = 127; +pub const ENOTSOCK: ::c_int = 128; +pub const ENOTSUP: ::c_int = 129; +pub const EOPNOTSUPP: ::c_int = 130; +pub const EOVERFLOW: ::c_int = 132; +pub const EOWNERDEAD: ::c_int = 133; +pub const EPROTO: ::c_int = 134; +pub const EPROTONOSUPPORT: ::c_int = 135; +pub const EPROTOTYPE: ::c_int = 136; +pub const ETIME: ::c_int = 137; +pub const ETIMEDOUT: ::c_int = 138; +pub const ETXTBSY: ::c_int = 139; +pub const EWOULDBLOCK: ::c_int = 140; + +// signal codes +pub const SIGINT: ::c_int = 2; +pub const SIGILL: ::c_int = 4; +pub const SIGFPE: ::c_int = 8; +pub const SIGSEGV: ::c_int = 11; +pub const SIGTERM: ::c_int = 15; +pub const SIGABRT: ::c_int = 22; +pub const NSIG: ::c_int = 23; +pub const SIG_ERR: ::c_int = -1; + +// inline comment below appeases style checker +#[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if " +#[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))] +#[link(name = "libcmt", cfg(target_feature = "crt-static"))] +extern "C" {} + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum FILE {} +impl ::Copy for FILE {} +impl ::Clone for FILE { + fn clone(&self) -> FILE { + *self + } +} +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum fpos_t {} // TODO: fill this out with a struct +impl ::Copy for fpos_t {} +impl ::Clone for fpos_t { + fn clone(&self) -> fpos_t { + *self + } +} + +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen( + filename: *const c_char, + mode: *const c_char, + file: *mut FILE, + ) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf( + stream: *mut FILE, + buffer: *mut c_char, + mode: c_int, + size: size_t, + ) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) + -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread( + ptr: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE, + ) -> size_t; + pub fn fwrite( + ptr: *const c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE, + ) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atoi(s: *const c_char) -> c_int; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_long; + pub fn strtoul( + s: *const c_char, + endp: *mut *mut c_char, + base: c_int, + ) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern "C" fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy( + dst: *mut c_char, + src: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat( + s: *mut c_char, + ct: *const c_char, + n: size_t, + ) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs( + dest: *mut c_char, + src: *const wchar_t, + n: size_t, + ) -> ::size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memmove( + dest: *mut c_void, + src: *const c_void, + n: size_t, + ) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn abs(i: c_int) -> c_int; + pub fn atof(s: *const c_char) -> c_double; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + pub fn raise(signum: c_int) -> c_int; + + #[link_name = "_time64"] + pub fn time(destTime: *mut time_t) -> time_t; + #[link_name = "_chmod"] + pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int; + #[link_name = "_wchmod"] + pub fn wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int; + #[link_name = "_mkdir"] + pub fn mkdir(path: *const c_char) -> ::c_int; + #[link_name = "_wrmdir"] + pub fn wrmdir(path: *const wchar_t) -> ::c_int; + #[link_name = "_fstat64"] + pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; + #[link_name = "_stat64"] + pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; + #[link_name = "_wstat64"] + pub fn wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int; + #[link_name = "_wutime64"] + pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int; + #[link_name = "_popen"] + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + #[link_name = "_pclose"] + pub fn pclose(stream: *mut ::FILE) -> ::c_int; + #[link_name = "_fdopen"] + pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; + #[link_name = "_fileno"] + pub fn fileno(stream: *mut ::FILE) -> ::c_int; + #[link_name = "_open"] + pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; + #[link_name = "_wopen"] + pub fn wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int; + #[link_name = "_creat"] + pub fn creat(path: *const c_char, mode: ::c_int) -> ::c_int; + #[link_name = "_access"] + pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; + #[link_name = "_chdir"] + pub fn chdir(dir: *const c_char) -> ::c_int; + #[link_name = "_close"] + pub fn close(fd: ::c_int) -> ::c_int; + #[link_name = "_dup"] + pub fn dup(fd: ::c_int) -> ::c_int; + #[link_name = "_dup2"] + pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; + #[link_name = "_execv"] + pub fn execv( + prog: *const c_char, + argv: *const *const c_char, + ) -> ::intptr_t; + #[link_name = "_execve"] + pub fn execve( + prog: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> ::c_int; + #[link_name = "_execvp"] + pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; + #[link_name = "_execvpe"] + pub fn execvpe( + c: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> ::c_int; + #[link_name = "_getcwd"] + pub fn getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char; + #[link_name = "_getpid"] + pub fn getpid() -> ::c_int; + #[link_name = "_isatty"] + pub fn isatty(fd: ::c_int) -> ::c_int; + #[link_name = "_lseek"] + pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long; + #[link_name = "_lseeki64"] + pub fn lseek64( + fd: ::c_int, + offset: c_longlong, + origin: ::c_int, + ) -> c_longlong; + #[link_name = "_pipe"] + pub fn pipe( + fds: *mut ::c_int, + psize: ::c_uint, + textmode: ::c_int, + ) -> ::c_int; + #[link_name = "_read"] + pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int; + #[link_name = "_rmdir"] + pub fn rmdir(path: *const c_char) -> ::c_int; + #[link_name = "_unlink"] + pub fn unlink(c: *const c_char) -> ::c_int; + #[link_name = "_write"] + pub fn write( + fd: ::c_int, + buf: *const ::c_void, + count: ::c_uint, + ) -> ::c_int; + #[link_name = "_commit"] + pub fn commit(fd: ::c_int) -> ::c_int; + #[link_name = "_get_osfhandle"] + pub fn get_osfhandle(fd: ::c_int) -> ::intptr_t; + #[link_name = "_open_osfhandle"] + pub fn open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int; + pub fn setlocale(category: ::c_int, locale: *const c_char) -> *mut c_char; + #[link_name = "_wsetlocale"] + pub fn wsetlocale( + category: ::c_int, + locale: *const wchar_t, + ) -> *mut wchar_t; +} + +extern "system" { + pub fn listen(s: SOCKET, backlog: ::c_int) -> ::c_int; + pub fn accept( + s: SOCKET, + addr: *mut ::sockaddr, + addrlen: *mut ::c_int, + ) -> SOCKET; + pub fn bind( + s: SOCKET, + name: *const ::sockaddr, + namelen: ::c_int, + ) -> ::c_int; + pub fn connect( + s: SOCKET, + name: *const ::sockaddr, + namelen: ::c_int, + ) -> ::c_int; + pub fn getpeername( + s: SOCKET, + name: *mut ::sockaddr, + nameln: *mut ::c_int, + ) -> ::c_int; + pub fn getsockname( + s: SOCKET, + name: *mut ::sockaddr, + nameln: *mut ::c_int, + ) -> ::c_int; + pub fn getsockopt( + s: SOCKET, + level: ::c_int, + optname: ::c_int, + optval: *mut ::c_char, + optlen: *mut ::c_int, + ) -> ::c_int; + pub fn recvfrom( + s: SOCKET, + buf: *mut ::c_char, + len: ::c_int, + flags: ::c_int, + from: *mut ::sockaddr, + fromlen: *mut ::c_int, + ) -> ::c_int; + pub fn sendto( + s: SOCKET, + buf: *const ::c_char, + len: ::c_int, + flags: ::c_int, + to: *const ::sockaddr, + tolen: ::c_int, + ) -> ::c_int; + pub fn setsockopt( + s: SOCKET, + level: ::c_int, + optname: ::c_int, + optval: *const ::c_char, + optlen: ::c_int, + ) -> ::c_int; + pub fn socket( + af: ::c_int, + socket_type: ::c_int, + protocol: ::c_int, + ) -> SOCKET; +} + +cfg_if! { + if #[cfg(libc_core_cvoid)] { + pub use ::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} + +cfg_if! { + if #[cfg(all(target_env = "gnu"))] { + mod gnu; + pub use self::gnu::*; + } else if #[cfg(all(target_env = "msvc"))] { + mod msvc; + pub use self::msvc::*; + } else { + // Unknown target_env + } +} diff --git a/third_party/cargo/vendor/libc-0.2.66/src/windows/msvc.rs b/third_party/cargo/vendor/libc-0.2.66/src/windows/msvc.rs new file mode 100644 index 0000000..8f20deb --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/src/windows/msvc.rs @@ -0,0 +1,17 @@ +pub const L_tmpnam: ::c_uint = 260; +pub const TMP_MAX: ::c_uint = 0x7fff_ffff; + +// POSIX Supplement (from errno.h) +// This particular error code is only currently available in msvc toolchain +pub const EOTHER: ::c_int = 131; + +extern "C" { + #[link_name = "_stricmp"] + pub fn stricmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int; + #[link_name = "_strnicmp"] + pub fn strnicmp( + s1: *const ::c_char, + s2: *const ::c_char, + n: ::size_t, + ) -> ::c_int; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/tests/const_fn.rs b/third_party/cargo/vendor/libc-0.2.66/tests/const_fn.rs new file mode 100644 index 0000000..0e7e186 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/tests/const_fn.rs @@ -0,0 +1,5 @@ +#![cfg(libc_const_extern_fn)] // If this does not hold, the file is empty + +#[cfg(target_os = "linux")] +const _FOO: libc::c_uint = unsafe { libc::CMSG_SPACE(1) }; +//^ if CMSG_SPACE is not const, this will fail to compile diff --git a/third_party/cargo/vendor/libloading-0.5.2/.cargo-checksum.json b/third_party/cargo/vendor/libloading-0.5.2/.cargo-checksum.json new file mode 100644 index 0000000..6a7f51d --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"9110a58fe827a68e5df22f8d38e4beab38c259724942e868c5ae3debc2f0ebae","LICENSE":"b29f8b01452350c20dd1af16ef83b598fea3053578ccc1c7a0ef40e57be2620f","README.mkd":"b4cd83f110d01dc5aa8fcaf3da34bdbe1478efdba767d73abc14d4d87e4775fa","appveyor.yml":"8382c7f1769f6cf78029a221058c4d73f35a48308b5dfc38d875facabec1c139","build.rs":"d8f7fce1b459d117cd48d85ba3643124bd09657a0df9e0e90a1fd997decff741","src/changelog.rs":"e8a769578ebe2db81055b131ce12fa14c9ad0f21a79035748f244e5b347b2ada","src/lib.rs":"0cc0f6b42c98c14183dea2bc9deaf5aa574fabbe61081fe3339d74430f25fc12","src/os/mod.rs":"51d733e5522dacd6069642ad66aa6d7acf6c82950c934eb040e8dfd112e6d610","src/os/unix/global_static.c":"b1096dedf7d4aed5c28b658fc917f6603339ffd92390c84e25cb543bdc9460ac","src/os/unix/mod.rs":"9a84c15d0b9e5125a6ca086854a0e18884cb6c04cea54f47f1a44243e69335c2","src/os/windows/mod.rs":"c0ee0068a0564d64b7f3d3053d799492693c34571a935fc893a41a62a86fccdd","src/test_helpers.rs":"3a55052e8cd5231e97d9282b43398c2f144c57ced2d2df64bde7f482f5c778e7","src/util.rs":"5d1d3fcf7e5e9dc67df0dbf91332c5e3f5875e90c8f80ada5cfad0bc3c402d7e","tests/functions.rs":"4633f3673db6a5b3623ea8927b13314c25502c9fbb63bb17a5a35650ea489012","tests/markers.rs":"8e9c1b883404d9190e4f23ed39b3d6cbbccb3a07883f733b04aed4357b9c6aca","tests/nagisa32.dll":"5c69b2bd9c8a6ad04165c221075fc9fade1dd66ca697399ace528a5a62328e36","tests/nagisa64.dll":"e20b95e3036f3289421abd100760874d4f455afd33c3b5b64fec56b191f7d477","tests/windows.rs":"7711dfe19062d91356cd127546542b1b6e13aeef76ad3098f32c8a6ae319b66a"},"package":"f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753"} \ No newline at end of file diff --git a/third_party/cargo/vendor/libloading-0.5.2/BUILD b/third_party/cargo/vendor/libloading-0.5.2/BUILD new file mode 100644 index 0000000..169e954 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "ISC" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted +# Unsupported target "functions" with type "test" omitted + +rust_library( + name = "libloading", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/patches:libloading_global_static", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.5.2", + crate_features = [ + ], +) + +# Unsupported target "markers" with type "test" omitted +# Unsupported target "windows" with type "test" omitted diff --git a/third_party/cargo/vendor/libloading-0.5.2/Cargo.toml b/third_party/cargo/vendor/libloading-0.5.2/Cargo.toml new file mode 100644 index 0000000..f9b19a8 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/Cargo.toml @@ -0,0 +1,27 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "libloading" +version = "0.5.2" +authors = ["Simonas Kazlauskas "] +build = "build.rs" +description = "A safer binding to platform’s dynamic library loading utilities" +documentation = "https://docs.rs/libloading/" +keywords = ["dlopen", "load", "shared", "dylib"] +license = "ISC" +repository = "https://github.com/nagisa/rust_libloading/" +[build-dependencies.cc] +version = "1.0" +[target."cfg(windows)".dependencies.winapi] +version = "0.3" +features = ["winerror", "errhandlingapi", "libloaderapi"] diff --git a/third_party/cargo/vendor/libloading-0.5.2/LICENSE b/third_party/cargo/vendor/libloading-0.5.2/LICENSE new file mode 100644 index 0000000..9137d56 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/LICENSE @@ -0,0 +1,12 @@ +Copyright © 2015, Simonas Kazlauskas + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without +fee is hereby granted, provided that the above copyright notice and this permission notice appear +in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. diff --git a/third_party/cargo/vendor/libloading-0.5.2/README.mkd b/third_party/cargo/vendor/libloading-0.5.2/README.mkd new file mode 100644 index 0000000..da78158 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/README.mkd @@ -0,0 +1,21 @@ +# libloading [![Travis CI][tcii]][tci] [![Appveyor CI][acii]][aci] + +[tcii]: https://travis-ci.org/nagisa/rust_libloading.svg?branch=master +[tci]: https://travis-ci.org/nagisa/rust_libloading +[acii]: https://ci.appveyor.com/api/projects/status/cnncnu58qcxb1ikf/branch/master?svg=true +[aci]: https://ci.appveyor.com/project/nagisa/rust-libloading + +A memory-safer wrapper around system dynamic library loading primitives. The most important safety +guarantee by this library is prevention of dangling-`Symbol`s that may occur after a `Library` is +unloaded. + +Using this library allows loading dynamic libraries (also known as shared libraries) as well as use +functions and static variables these libraries contain. + +* [Documentation][docs] +* [Changelog][changelog] + +[docs]: https://docs.rs/libloading/ +[changelog]: https://docs.rs/libloading/*/libloading/changelog/index.html + +libloading is distributed under ISC (MIT-like) license. diff --git a/third_party/cargo/vendor/libloading-0.5.2/appveyor.yml b/third_party/cargo/vendor/libloading-0.5.2/appveyor.yml new file mode 100644 index 0000000..1bded0b --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/appveyor.yml @@ -0,0 +1,19 @@ +environment: + matrix: + - TARGET: nightly-x86_64-pc-windows-msvc + - TARGET: nightly-i686-pc-windows-msvc + - TARGET: nightly-x86_64-pc-windows-gnu + - TARGET: nightly-i686-pc-windows-gnu + - TARGET: 1.14.0-x86_64-pc-windows-msvc + - TARGET: 1.14.0-i686-pc-windows-msvc + - TARGET: 1.14.0-x86_64-pc-windows-gnu + - TARGET: 1.14.0-i686-pc-windows-gnu +install: + - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:TARGET}.exe" -FileName "rust.exe" + - ps: .\rust.exe /VERYSILENT /NORESTART /DIR="C:\rust" | Out-Null + - ps: $env:PATH="$env:PATH;C:\rust\bin" + - rustc -vV + - cargo -vV +build: off +test_script: + - cargo test diff --git a/third_party/cargo/vendor/libloading-0.5.2/build.rs b/third_party/cargo/vendor/libloading-0.5.2/build.rs new file mode 100644 index 0000000..fc380a7 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/build.rs @@ -0,0 +1,32 @@ +extern crate cc; + +use std::io::Write; +use std::env; + +fn main(){ + let target_os = env::var("CARGO_CFG_TARGET_OS"); + let is_unix = env::var_os("CARGO_CFG_UNIX").is_some(); + match target_os.as_ref().map(|x| &**x) { + Ok("linux") | Ok("android") => println!("cargo:rustc-link-lib=dl"), + Ok("freebsd") | Ok("dragonfly") => println!("cargo:rustc-link-lib=c"), + // netbsd claims dl* will be available to any dynamically linked binary, but I haven’t + // found any libraries that have to be linked to on other platforms. + // What happens if the executable is not linked up dynamically? + Ok("openbsd") | Ok("bitrig") | Ok("netbsd") | Ok("macos") | Ok("ios") => {} + Ok("solaris") => {} + Ok("haiku") => {} + // dependencies come with winapi + Ok("windows") => {} + tos => { + writeln!(::std::io::stderr(), + "Building for an unknown target_os=`{:?}`!\nPlease report an issue ", + tos).expect("could not report the error"); + ::std::process::exit(0xfc); + } + } + if is_unix { + cc::Build::new() + .file("src/os/unix/global_static.c") + .compile("global_static"); + } +} diff --git a/third_party/cargo/vendor/libloading-0.5.2/src/changelog.rs b/third_party/cargo/vendor/libloading-0.5.2/src/changelog.rs new file mode 100644 index 0000000..215ea89 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/src/changelog.rs @@ -0,0 +1,103 @@ +//! Project changelog + +/// Release 0.5.2 (2019-07-07) +/// +/// * Added API to convert OS-specific `Library` and `Symbol` conversion to underlying resources. +pub mod r0_5_2 {} + +/// Release 0.5.1 (2019-06-01) +/// +/// * Build on Haiku targets. +pub mod r0_5_1 {} + +/// Release 0.5.0 (2018-01-11) +/// +/// * Update to `winapi = ^0.3`; +/// +/// ## Breaking changes +/// +/// * libloading now requires a C compiler to build on UNIX; +/// * This is a temporary measure until the [`linkage`] attribute is stabilised; +/// * Necessary to resolve [#32]. +/// +/// [`linkage`]: https://github.com/rust-lang/rust/issues/29603 +/// [#32]: https://github.com/nagisa/rust_libloading/issues/32 +pub mod r0_5_0 {} + +/// Release 0.4.3 (2017-12-07) +/// +/// * Bump lazy-static dependency to `^1.0`; +/// * `cargo test --release` now works when testing libloading. +pub mod r0_4_3 {} + + +/// Release 0.4.2 (2017-09-24) +/// +/// * Improved error and race-condition handling on Windows; +/// * Improved documentation about thread-safety of Library; +/// * Added `Symbol::::lift_option() -> Option>` convenience method. +pub mod r0_4_2 {} + + +/// Release 0.4.1 (2017-08-29) +/// +/// * Solaris support +pub mod r0_4_1 {} + +/// Release 0.4.0 (2017-05-01) +/// +/// * Remove build-time dependency on target_build_utils (and by extension serde/phf); +/// * Require at least version 1.14.0 of rustc to build; +/// * Actually, it is cargo which has to be more recent here. The one shipped with rustc 1.14.0 +/// is what’s being required from now on. +pub mod r0_4_0 {} + +/// Release 0.3.4 (2017-03-25) +/// +/// * Remove rogue println! +pub mod r0_3_4 {} + +/// Release 0.3.3 (2017-03-25) +/// +/// * Panics when `Library::get` is called for incompatibly sized type such as named function +/// types (which are zero-sized). +pub mod r0_3_3 {} + +/// Release 0.3.2 (2017-02-10) +/// +/// * Minimum version required is now rustc 1.12.0; +/// * Updated dependency versions (most notably target_build_utils to 0.3.0) +pub mod r0_3_2 {} + +/// Release 0.3.1 (2016-10-01) +/// +/// * `Symbol` and `os::*::Symbol` now implement `Send` where `T: Send`; +/// * `Symbol` and `os::*::Symbol` now implement `Sync` where `T: Sync`; +/// * `Library` and `os::*::Library` now implement `Sync` (they were `Send` in 0.3.0 already). +pub mod r0_3_1 {} + +/// Release 0.3.0 (2016-07-27) +/// +/// * Greatly improved documentation, especially around platform-specific behaviours; +/// * Improved test suite by building our own library to test against; +/// * All `Library`-ies now implement `Send`. +/// * Added `impl From for Library` and `impl From for +/// os::platform::Library` allowing wrapping and extracting the platform-specific library handle; +/// * Added methods to wrap (`Symbol::from_raw`) and unwrap (`Symbol::into_raw`) the safe `Symbol` +/// wrapper into unsafe `os::platform::Symbol`. +/// +/// The last two additions focus on not restricting potential usecases of this library, allowing +/// users of the library to circumvent safety checks if need be. +/// +/// ## Breaking Changes +/// +/// `Library::new` defaults to `RTLD_NOW` instead of `RTLD_LAZY` on UNIX for more consistent +/// cross-platform behaviour. If a library loaded with `Library::new` had any linking errors, but +/// unresolved references weren’t forced to be resolved, the library would’ve “just worked”, +/// whereas now the call to `Library::new` will return an error signifying presence of such error. +/// +/// ## os::platform +/// * Added `os::unix::Library::open` which allows specifying arbitrary flags (e.g. `RTLD_LAZY`); +/// * Added `os::windows::Library::get_ordinal` which allows finding a function or variable by its +/// ordinal number; +pub mod r0_3_0 {} diff --git a/third_party/cargo/vendor/libloading-0.5.2/src/lib.rs b/third_party/cargo/vendor/libloading-0.5.2/src/lib.rs new file mode 100644 index 0000000..a3bfe10 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/src/lib.rs @@ -0,0 +1,310 @@ +//! A memory-safer wrapper around system dynamic library loading primitives. +//! +//! Using this library allows loading [dynamic libraries](struct.Library.html) (also known as +//! shared libraries) as well as use functions and static variables these libraries contain. +//! +//! While the library does expose a cross-platform interface to load a library and find stuff +//! inside it, little is done to paper over the platform differences, especially where library +//! loading is involved. The documentation for each function will attempt to document such +//! differences on the best-effort basis. +//! +//! Less safe, platform specific bindings are also available. See the +//! [`os::platform`](os/index.html) module for details. +//! +//! # Usage +//! +//! Add a dependency on this library to your `Cargo.toml`: +//! +//! ```toml +//! [dependencies] +//! libloading = "0.5" +//! ``` +//! +//! Then inside your project +//! +//! ```no_run +//! extern crate libloading as lib; +//! +//! fn call_dynamic() -> lib::Result { +//! let lib = lib::Library::new("/path/to/liblibrary.so")?; +//! unsafe { +//! let func: lib::Symbol u32> = lib.get(b"my_func")?; +//! Ok(func()) +//! } +//! } +//! ``` +//! +//! The compiler will ensure that the loaded `function` will not outlive the `Library` it comes +//! from, preventing a common cause of undefined behaviour and memory safety problems. +use std::ffi::OsStr; +use std::fmt; +use std::ops; +use std::marker; + +#[cfg(unix)] +use self::os::unix as imp; +#[cfg(windows)] +use self::os::windows as imp; + +pub mod os; +pub mod changelog; +mod util; + +pub type Result = ::std::io::Result; + +/// A loaded dynamic library. +pub struct Library(imp::Library); + +impl Library { + /// Find and load a dynamic library. + /// + /// The `filename` argument may be any of: + /// + /// * A library filename; + /// * Absolute path to the library; + /// * Relative (to the current working directory) path to the library. + /// + /// ## Thread-safety + /// + /// The implementation strives to be as MT-safe as sanely possible, however due to certain + /// error-handling related resources not always being safe, this library is not MT-safe either. + /// + /// * On Windows Vista and earlier error handling falls back to [`SetErrorMode`], which is not + /// MT-safe. MT-scenarios involving this function may cause a traditional data race; + /// * On some UNIX targets `dlerror` might not be MT-safe, resulting in garbage error messages + /// in certain MT-scenarios. + /// + /// [`SetErrorMode`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx + /// + /// Calling this function from multiple threads is not safe if used in conjunction with + /// path-less filename and library search path is modified (`SetDllDirectory` function on + /// Windows, `{DY,}LD_LIBRARY_PATH` environment variable on UNIX). + /// + /// ## Platform-specific behaviour + /// + /// When a plain library filename is supplied, locations where library is searched for is + /// platform specific and cannot be adjusted in a portable manner. + /// + /// ### Windows + /// + /// If the `filename` specifies a library filename without path and with extension omitted, + /// `.dll` extension is implicitly added. This behaviour may be suppressed by appending a + /// trailing `.` to the `filename`. + /// + /// If the library contains thread local variables (MSVC’s `_declspec(thread)`, Rust’s + /// `#[thread_local]` attributes), loading the library will fail on versions prior to Windows + /// Vista. + /// + /// ## Tips + /// + /// Distributing your dynamic libraries under a filename common to all platforms (e.g. + /// `awesome.module`) allows to avoid code which has to account for platform’s conventional + /// library filenames. + /// + /// Strive to specify absolute or relative path to your library, unless system-wide libraries + /// are being loaded. Platform-dependent library search locations combined with various quirks + /// related to path-less filenames may cause flaky code. + /// + /// ## Examples + /// + /// ```no_run + /// # use ::libloading::Library; + /// // Any of the following are valid. + /// let _ = Library::new("/path/to/awesome.module").unwrap(); + /// let _ = Library::new("../awesome.module").unwrap(); + /// let _ = Library::new("libsomelib.so.1").unwrap(); + /// ``` + pub fn new>(filename: P) -> Result { + imp::Library::new(filename).map(From::from) + } + + /// Get a pointer to function or static variable by symbol name. + /// + /// The `symbol` may not contain any null bytes, with an exception of last byte. A null + /// terminated `symbol` may avoid a string allocation in some cases. + /// + /// Symbol is interpreted as-is; no mangling is done. This means that symbols like `x::y` are + /// most likely invalid. + /// + /// ## Unsafety + /// + /// Pointer to a value of arbitrary type is returned. Using a value with wrong type is + /// undefined. + /// + /// ## Platform-specific behaviour + /// + /// On Linux and Windows, a TLS variable acts just like any regular static variable. OS X uses + /// some sort of lazy initialization scheme, which makes loading TLS variables this way + /// impossible. Using a TLS variable loaded this way on OS X is undefined behaviour. + /// + /// ## Examples + /// + /// Given a loaded library: + /// + /// ```no_run + /// # use ::libloading::Library; + /// let lib = Library::new("/path/to/awesome.module").unwrap(); + /// ``` + /// + /// Loading and using a function looks like this: + /// + /// ```no_run + /// # use ::libloading::{Library, Symbol}; + /// # let lib = Library::new("/path/to/awesome.module").unwrap(); + /// unsafe { + /// let awesome_function: Symbol f64> = + /// lib.get(b"awesome_function\0").unwrap(); + /// awesome_function(0.42); + /// } + /// ``` + /// + /// A static variable may also be loaded and inspected: + /// + /// ```no_run + /// # use ::libloading::{Library, Symbol}; + /// # let lib = Library::new("/path/to/awesome.module").unwrap(); + /// unsafe { + /// let awesome_variable: Symbol<*mut f64> = lib.get(b"awesome_variable\0").unwrap(); + /// **awesome_variable = 42.0; + /// }; + /// ``` + pub unsafe fn get<'lib, T>(&'lib self, symbol: &[u8]) -> Result> { + self.0.get(symbol).map(|from| Symbol::from_raw(from, self)) + } +} + +impl fmt::Debug for Library { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + +impl From for Library { + fn from(lib: imp::Library) -> Library { + Library(lib) + } +} + +impl From for imp::Library { + fn from(lib: Library) -> imp::Library { + lib.0 + } +} + +unsafe impl Send for Library {} +unsafe impl Sync for Library {} + +/// Symbol from a library. +/// +/// This type is a safeguard against using dynamically loaded symbols after a `Library` is +/// unloaded. Primary method to create an instance of a `Symbol` is via `Library::get`. +/// +/// Due to implementation of the `Deref` trait, an instance of `Symbol` may be used as if it was a +/// function or variable directly, without taking care to “extract” function or variable manually +/// most of the time. +/// +/// See [`Library::get`] for details. +/// +/// [`Library::get`]: ./struct.Library.html#method.get +pub struct Symbol<'lib, T: 'lib> { + inner: imp::Symbol, + pd: marker::PhantomData<&'lib T> +} + +impl<'lib, T> Symbol<'lib, T> { + /// Extract the wrapped `os::platform::Symbol`. + /// + /// ## Unsafety + /// Using this function relinquishes all the lifetime guarantees. It is up to programmer to + /// ensure the resulting `Symbol` is not used past the lifetime of the `Library` this symbol + /// was loaded from. + /// + /// ## Examples + /// + /// ```no_run + /// # use ::libloading::{Library, Symbol}; + /// let lib = Library::new("/path/to/awesome.module").unwrap(); + /// unsafe { + /// let symbol: Symbol<*mut u32> = lib.get(b"symbol\0").unwrap(); + /// let symbol = symbol.into_raw(); + /// } + /// ``` + pub unsafe fn into_raw(self) -> imp::Symbol { + self.inner + } + + /// Wrap the `os::platform::Symbol` into this safe wrapper. + /// + /// Note that, in order to create association between the symbol and the library this symbol + /// came from, this function requires reference to the library provided. + /// + /// ## Unsafety + /// + /// It is invalid to provide a reference to any other value other than the library the `sym` + /// was loaded from. Doing so invalidates any lifetime guarantees. + /// + /// ## Examples + /// + /// ```no_run + /// # use ::libloading::{Library, Symbol}; + /// let lib = Library::new("/path/to/awesome.module").unwrap(); + /// unsafe { + /// let symbol: Symbol<*mut u32> = lib.get(b"symbol\0").unwrap(); + /// let symbol = symbol.into_raw(); + /// let symbol = Symbol::from_raw(symbol, &lib); + /// } + /// ``` + pub unsafe fn from_raw(sym: imp::Symbol, _: &'lib L) -> Symbol<'lib, T> { + Symbol { + inner: sym, + pd: marker::PhantomData + } + } +} + +impl<'lib, T> Symbol<'lib, Option> { + /// Lift Option out of the symbol. + /// + /// ## Examples + /// + /// ```no_run + /// # use ::libloading::{Library, Symbol}; + /// let lib = Library::new("/path/to/awesome.module").unwrap(); + /// unsafe { + /// let symbol: Symbol> = lib.get(b"symbol\0").unwrap(); + /// let symbol: Symbol<*mut u32> = symbol.lift_option().expect("static is not null"); + /// } + /// ``` + pub fn lift_option(self) -> Option> { + self.inner.lift_option().map(|is| Symbol { + inner: is, + pd: marker::PhantomData, + }) + } +} + +impl<'lib, T> Clone for Symbol<'lib, T> { + fn clone(&self) -> Symbol<'lib, T> { + Symbol { + inner: self.inner.clone(), + pd: marker::PhantomData + } + } +} + +// FIXME: implement FnOnce for callable stuff instead. +impl<'lib, T> ops::Deref for Symbol<'lib, T> { + type Target = T; + fn deref(&self) -> &T { + ops::Deref::deref(&self.inner) + } +} + +impl<'lib, T> fmt::Debug for Symbol<'lib, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +unsafe impl<'lib, T: Send> Send for Symbol<'lib, T> {} +unsafe impl<'lib, T: Sync> Sync for Symbol<'lib, T> {} diff --git a/third_party/cargo/vendor/libloading-0.5.2/src/os/mod.rs b/third_party/cargo/vendor/libloading-0.5.2/src/os/mod.rs new file mode 100644 index 0000000..ccbc8e9 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/src/os/mod.rs @@ -0,0 +1,45 @@ +//! Unsafe, platform specific bindings to dynamic library loading facilities. +//! +//! These modules expose more extensive, powerful, less principled bindings to the dynamic +//! library loading facilities. Use of these bindings come at the cost of less (in most cases, +//! none at all) safety guarantees, which are provided by the top-level bindings. +//! +//! # Examples +//! +//! Using these modules will likely involve conditional compilation: +//! +//! ```ignore +//! # extern crate libloading; +//! #[cfg(unix)] +//! use libloading::os::unix::*; +//! #[cfg(windows)] +//! use libloading::os::windows::*; +//! ``` + +macro_rules! unix { + ($item: item) => { + /// UNIX implementation of dynamic library loading. + /// + /// This module should be expanded with more UNIX-specific functionality in the future. + $item + } +} + +macro_rules! windows { + ($item: item) => { + /// Windows implementation of dynamic library loading. + /// + /// This module should be expanded with more Windows-specific functionality in the future. + $item + } +} + +#[cfg(unix)] +unix!(pub mod unix;); +#[cfg(unix)] +windows!(pub mod windows {}); + +#[cfg(windows)] +windows!(pub mod windows;); +#[cfg(windows)] +unix!(pub mod unix {}); diff --git a/third_party/cargo/vendor/libloading-0.5.2/src/os/unix/global_static.c b/third_party/cargo/vendor/libloading-0.5.2/src/os/unix/global_static.c new file mode 100644 index 0000000..a905780 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/src/os/unix/global_static.c @@ -0,0 +1,20 @@ +#include +#include + +pthread_mutex_t __attribute__((weak)) rust_libloading_dlerror_mutex = PTHREAD_MUTEX_INITIALIZER; + +void __attribute__((weak)) +rust_libloading_dlerror_mutex_lock(void) +{ + if (pthread_mutex_lock(&rust_libloading_dlerror_mutex) != 0) { + abort(); + } +} + +void __attribute__((weak)) +rust_libloading_dlerror_mutex_unlock(void) +{ + if (pthread_mutex_unlock(&rust_libloading_dlerror_mutex) != 0) { + abort(); + } +} diff --git a/third_party/cargo/vendor/libloading-0.5.2/src/os/unix/mod.rs b/third_party/cargo/vendor/libloading-0.5.2/src/os/unix/mod.rs new file mode 100644 index 0000000..d0456dd --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/src/os/unix/mod.rs @@ -0,0 +1,336 @@ +use util::{ensure_compatible_types, cstr_cow_from_bytes}; + +use std::ffi::{CStr, OsStr}; +use std::{fmt, io, marker, mem, ptr}; +use std::os::raw; +use std::os::unix::ffi::OsStrExt; + +extern "C" { + fn rust_libloading_dlerror_mutex_lock(); + fn rust_libloading_dlerror_mutex_unlock(); +} + +struct DlerrorMutexGuard(()); + +impl DlerrorMutexGuard { + fn new() -> DlerrorMutexGuard { + unsafe { + rust_libloading_dlerror_mutex_lock(); + } + DlerrorMutexGuard(()) + } +} + +impl Drop for DlerrorMutexGuard { + fn drop(&mut self) { + unsafe { + rust_libloading_dlerror_mutex_unlock(); + } + } +} + +// libdl is crazy. +// +// First of all, whole error handling scheme in libdl is done via setting and querying some global +// state, therefore it is not safe to use libdl in MT-capable environment at all. Only in POSIX +// 2008+TC1 a thread-local state was allowed, which for our purposes is way too late. +fn with_dlerror(closure: F) -> Result> +where F: FnOnce() -> Option { + // We will guard all uses of libdl library with our own mutex. This makes libdl + // safe to use in MT programs provided the only way a program uses libdl is via this library. + let _lock = DlerrorMutexGuard::new(); + // While we could could call libdl here to clear the previous error value, only the dlsym + // depends on it being cleared beforehand and only in some cases too. We will instead clear the + // error inside the dlsym binding instead. + // + // In all the other cases, clearing the error here will only be hiding misuse of these bindings + // or the libdl. + closure().ok_or_else(|| unsafe { + // This code will only get executed if the `closure` returns `None`. + let error = dlerror(); + if error.is_null() { + // In non-dlsym case this may happen when there’re bugs in our bindings or there’s + // non-libloading user of libdl; possibly in another thread. + None + } else { + // You can’t even rely on error string being static here; call to subsequent dlerror + // may invalidate or overwrite the error message. Why couldn’t they simply give up the + // ownership over the message? + // TODO: should do locale-aware conversion here. OTOH Rust doesn’t seem to work well in + // any system that uses non-utf8 locale, so I doubt there’s a problem here. + let message = CStr::from_ptr(error).to_string_lossy().into_owned(); + Some(io::Error::new(io::ErrorKind::Other, message)) + // Since we do a copy of the error string above, maybe we should call dlerror again to + // let libdl know it may free its copy of the string now? + } + }) +} + +/// A platform-specific equivalent of the cross-platform `Library`. +pub struct Library { + handle: *mut raw::c_void +} + +unsafe impl Send for Library {} + +// That being said... this section in the volume 2 of POSIX.1-2008 states: +// +// > All functions defined by this volume of POSIX.1-2008 shall be thread-safe, except that the +// > following functions need not be thread-safe. +// +// With notable absence of any dl* function other than dlerror in the list. By “this volume” +// I suppose they refer precisely to the “volume 2”. dl* family of functions are specified +// by this same volume, so the conclusion is indeed that dl* functions are required by POSIX +// to be thread-safe. Great! +// +// See for more details: +// +// * https://github.com/nagisa/rust_libloading/pull/17 +// * http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_01 +unsafe impl Sync for Library {} + +impl Library { + /// Find and load a shared library (module). + /// + /// Locations where library is searched for is platform specific and can’t be adjusted + /// portably. + /// + /// Corresponds to `dlopen(filename, RTLD_NOW)`. + #[inline] + pub fn new>(filename: P) -> ::Result { + Library::open(Some(filename), RTLD_NOW) + } + + /// Load the dynamic libraries linked into main program. + /// + /// This allows retrieving symbols from any **dynamic** library linked into the program, + /// without specifying the exact library. + /// + /// Corresponds to `dlopen(NULL, RTLD_NOW)`. + #[inline] + pub fn this() -> Library { + Library::open(None::<&OsStr>, RTLD_NOW).unwrap() + } + + /// Find and load a shared library (module). + /// + /// Locations where library is searched for is platform specific and can’t be adjusted + /// portably. + /// + /// If the `filename` is None, null pointer is passed to `dlopen`. + /// + /// Corresponds to `dlopen(filename, flags)`. + pub fn open

(filename: Option

, flags: raw::c_int) -> ::Result + where P: AsRef { + let filename = match filename { + None => None, + Some(ref f) => Some(try!(cstr_cow_from_bytes(f.as_ref().as_bytes()))), + }; + with_dlerror(move || { + let result = unsafe { + let r = dlopen(match filename { + None => ptr::null(), + Some(ref f) => f.as_ptr() + }, flags); + // ensure filename lives until dlopen completes + drop(filename); + r + }; + if result.is_null() { + None + } else { + Some(Library { + handle: result + }) + } + }).map_err(|e| e.unwrap_or_else(|| + panic!("dlopen failed but dlerror did not report anything") + )) + } + + /// Get a pointer to function or static variable by symbol name. + /// + /// The `symbol` may not contain any null bytes, with an exception of last byte. A null + /// terminated `symbol` may avoid a string allocation in some cases. + /// + /// Symbol is interpreted as-is; no mangling is done. This means that symbols like `x::y` are + /// most likely invalid. + /// + /// ## Unsafety + /// + /// Pointer to a value of arbitrary type is returned. Using a value with wrong type is + /// undefined. + /// + /// ## Platform-specific behaviour + /// + /// OS X uses some sort of lazy initialization scheme, which makes loading TLS variables + /// impossible. Using a TLS variable loaded this way on OS X is undefined behaviour. + pub unsafe fn get(&self, symbol: &[u8]) -> ::Result> { + ensure_compatible_types::(); + let symbol = try!(cstr_cow_from_bytes(symbol)); + // `dlsym` may return nullptr in two cases: when a symbol genuinely points to a null + // pointer or the symbol cannot be found. In order to detect this case a double dlerror + // pattern must be used, which is, sadly, a little bit racy. + // + // We try to leave as little space as possible for this to occur, but we can’t exactly + // fully prevent it. + match with_dlerror(|| { + dlerror(); + let symbol = dlsym(self.handle, symbol.as_ptr()); + if symbol.is_null() { + None + } else { + Some(Symbol { + pointer: symbol, + pd: marker::PhantomData + }) + } + }) { + Err(None) => Ok(Symbol { + pointer: ptr::null_mut(), + pd: marker::PhantomData + }), + Err(Some(e)) => Err(e), + Ok(x) => Ok(x) + } + } + + /// Convert the `Library` to a raw handle. + /// + /// The handle returned by this function shall be usable with APIs which accept handles + /// as returned by `dlopen`. + pub fn into_raw(self) -> *mut raw::c_void { + let handle = self.handle; + mem::forget(self); + handle + } + + /// Convert a raw handle returned by `dlopen`-family of calls to a `Library`. + /// + /// ## Unsafety + /// + /// The pointer shall be a result of a successful call of the `dlopen`-family of functions or a + /// pointer previously returned by `Library::into_raw` call. It must be valid to call `dlclose` + /// with this pointer as an argument. + pub unsafe fn from_raw(handle: *mut raw::c_void) -> Library { + Library { + handle: handle + } + } +} + +impl Drop for Library { + fn drop(&mut self) { + with_dlerror(|| if unsafe { dlclose(self.handle) } == 0 { + Some(()) + } else { + None + }).unwrap(); + } +} + +impl fmt::Debug for Library { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(&format!("Library@{:p}", self.handle)) + } +} + +/// Symbol from a library. +/// +/// A major difference compared to the cross-platform `Symbol` is that this does not ensure the +/// `Symbol` does not outlive `Library` it comes from. +pub struct Symbol { + pointer: *mut raw::c_void, + pd: marker::PhantomData +} + +impl Symbol { + /// Convert the loaded Symbol into a raw pointer. + pub fn into_raw(self) -> *mut raw::c_void { + let pointer = self.pointer; + mem::forget(self); + pointer + } +} + +impl Symbol> { + /// Lift Option out of the symbol. + pub fn lift_option(self) -> Option> { + if self.pointer.is_null() { + None + } else { + Some(Symbol { + pointer: self.pointer, + pd: marker::PhantomData, + }) + } + } +} + +unsafe impl Send for Symbol {} +unsafe impl Sync for Symbol {} + +impl Clone for Symbol { + fn clone(&self) -> Symbol { + Symbol { ..*self } + } +} + +impl ::std::ops::Deref for Symbol { + type Target = T; + fn deref(&self) -> &T { + unsafe { + // Additional reference level for a dereference on `deref` return value. + mem::transmute(&self.pointer) + } + } +} + +impl fmt::Debug for Symbol { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + unsafe { + let mut info: DlInfo = mem::uninitialized(); + if dladdr(self.pointer, &mut info) != 0 { + if info.dli_sname.is_null() { + f.write_str(&format!("Symbol@{:p} from {:?}", + self.pointer, + CStr::from_ptr(info.dli_fname))) + } else { + f.write_str(&format!("Symbol {:?}@{:p} from {:?}", + CStr::from_ptr(info.dli_sname), self.pointer, + CStr::from_ptr(info.dli_fname))) + } + } else { + f.write_str(&format!("Symbol@{:p}", self.pointer)) + } + } + } +} + +// Platform specific things + +extern { + fn dlopen(filename: *const raw::c_char, flags: raw::c_int) -> *mut raw::c_void; + fn dlclose(handle: *mut raw::c_void) -> raw::c_int; + fn dlsym(handle: *mut raw::c_void, symbol: *const raw::c_char) -> *mut raw::c_void; + fn dlerror() -> *mut raw::c_char; + fn dladdr(addr: *mut raw::c_void, info: *mut DlInfo) -> raw::c_int; +} + +#[cfg(not(target_os="android"))] +const RTLD_NOW: raw::c_int = 2; +#[cfg(target_os="android")] +const RTLD_NOW: raw::c_int = 0; + +#[repr(C)] +struct DlInfo { + dli_fname: *const raw::c_char, + dli_fbase: *mut raw::c_void, + dli_sname: *const raw::c_char, + dli_saddr: *mut raw::c_void +} + +#[test] +fn this() { + Library::this(); +} diff --git a/third_party/cargo/vendor/libloading-0.5.2/src/os/windows/mod.rs b/third_party/cargo/vendor/libloading-0.5.2/src/os/windows/mod.rs new file mode 100644 index 0000000..8157eab --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/src/os/windows/mod.rs @@ -0,0 +1,313 @@ +extern crate winapi; +use self::winapi::shared::minwindef::{WORD, DWORD, HMODULE, FARPROC}; +use self::winapi::shared::ntdef::WCHAR; +use self::winapi::shared::winerror; +use self::winapi::um::{errhandlingapi, libloaderapi}; + +use util::{ensure_compatible_types, cstr_cow_from_bytes}; + +use std::ffi::{OsStr, OsString}; +use std::{fmt, io, marker, mem, ptr}; +use std::os::windows::ffi::{OsStrExt, OsStringExt}; +use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; + + +/// A platform-specific equivalent of the cross-platform `Library`. +pub struct Library(HMODULE); + +unsafe impl Send for Library {} +// Now, this is sort-of-tricky. MSDN documentation does not really make any claims as to safety of +// the Win32 APIs. Sadly, whomever I asked, even current and former Microsoft employees, couldn’t +// say for sure, whether the Win32 APIs used to implement `Library` are thread-safe or not. +// +// My investigation ended up with a question about thread-safety properties of the API involved +// being sent to an internal (to MS) general question mailing-list. The conclusion of the mail is +// as such: +// +// * Nobody inside MS (at least out of all the people who have seen the question) knows for +// sure either; +// * However, the general consensus between MS developers is that one can rely on the API being +// thread-safe. In case it is not thread-safe it should be considered a bug on the Windows +// part. (NB: bugs filled at https://connect.microsoft.com/ against Windows Server) +unsafe impl Sync for Library {} + +impl Library { + /// Find and load a shared library (module). + /// + /// Corresponds to `LoadLibraryW(filename)`. + #[inline] + pub fn new>(filename: P) -> ::Result { + let wide_filename: Vec = filename.as_ref().encode_wide().chain(Some(0)).collect(); + let _guard = ErrorModeGuard::new(); + + let ret = with_get_last_error(|| { + // Make sure no winapi calls as a result of drop happen inside this closure, because + // otherwise that might change the return value of the GetLastError. + let handle = unsafe { libloaderapi::LoadLibraryW(wide_filename.as_ptr()) }; + if handle.is_null() { + None + } else { + Some(Library(handle)) + } + }).map_err(|e| e.unwrap_or_else(|| + panic!("LoadLibraryW failed but GetLastError did not report the error") + )); + + drop(wide_filename); // Drop wide_filename here to ensure it doesn’t get moved and dropped + // inside the closure by mistake. See comment inside the closure. + ret + } + + /// Get a pointer to function or static variable by symbol name. + /// + /// The `symbol` may not contain any null bytes, with an exception of last byte. A null + /// terminated `symbol` may avoid a string allocation in some cases. + /// + /// Symbol is interpreted as-is; no mangling is done. This means that symbols like `x::y` are + /// most likely invalid. + /// + /// ## Unsafety + /// + /// Pointer to a value of arbitrary type is returned. Using a value with wrong type is + /// undefined. + pub unsafe fn get(&self, symbol: &[u8]) -> ::Result> { + ensure_compatible_types::(); + let symbol = try!(cstr_cow_from_bytes(symbol)); + with_get_last_error(|| { + let symbol = libloaderapi::GetProcAddress(self.0, symbol.as_ptr()); + if symbol.is_null() { + None + } else { + Some(Symbol { + pointer: symbol, + pd: marker::PhantomData + }) + } + }).map_err(|e| e.unwrap_or_else(|| + panic!("GetProcAddress failed but GetLastError did not report the error") + )) + } + + /// Get a pointer to function or static variable by ordinal number. + /// + /// ## Unsafety + /// + /// Pointer to a value of arbitrary type is returned. Using a value with wrong type is + /// undefined. + pub unsafe fn get_ordinal(&self, ordinal: WORD) -> ::Result> { + ensure_compatible_types::(); + with_get_last_error(|| { + let ordinal = ordinal as usize as *mut _; + let symbol = libloaderapi::GetProcAddress(self.0, ordinal); + if symbol.is_null() { + None + } else { + Some(Symbol { + pointer: symbol, + pd: marker::PhantomData + }) + } + }).map_err(|e| e.unwrap_or_else(|| + panic!("GetProcAddress failed but GetLastError did not report the error") + )) + } + + /// Convert the `Library` to a raw handle. + pub fn into_raw(self) -> HMODULE { + let handle = self.0; + mem::forget(self); + handle + } + + /// Convert a raw handle to a `Library`. + /// + /// ## Unsafety + /// + /// The handle shall be a result of a successful call of `LoadLibraryW` or a + /// handle previously returned by the `Library::into_raw` call. + pub unsafe fn from_raw(handle: HMODULE) -> Library { + Library(handle) + } +} + +impl Drop for Library { + fn drop(&mut self) { + with_get_last_error(|| { + if unsafe { libloaderapi::FreeLibrary(self.0) == 0 } { + None + } else { + Some(()) + } + }).unwrap() + } +} + +impl fmt::Debug for Library { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + unsafe { + let mut buf: [WCHAR; 1024] = mem::uninitialized(); + let len = libloaderapi::GetModuleFileNameW(self.0, + (&mut buf[..]).as_mut_ptr(), 1024) as usize; + if len == 0 { + f.write_str(&format!("Library@{:p}", self.0)) + } else { + let string: OsString = OsString::from_wide(&buf[..len]); + f.write_str(&format!("Library@{:p} from {:?}", self.0, string)) + } + } + } +} + +/// Symbol from a library. +/// +/// A major difference compared to the cross-platform `Symbol` is that this does not ensure the +/// `Symbol` does not outlive `Library` it comes from. +pub struct Symbol { + pointer: FARPROC, + pd: marker::PhantomData +} + +impl Symbol { + /// Convert the loaded Symbol into a handle. + pub fn into_raw(self) -> FARPROC { + let pointer = self.pointer; + mem::forget(self); + pointer + } +} + +impl Symbol> { + /// Lift Option out of the symbol. + pub fn lift_option(self) -> Option> { + if self.pointer.is_null() { + None + } else { + Some(Symbol { + pointer: self.pointer, + pd: marker::PhantomData, + }) + } + } +} + +unsafe impl Send for Symbol {} +unsafe impl Sync for Symbol {} + +impl Clone for Symbol { + fn clone(&self) -> Symbol { + Symbol { ..*self } + } +} + +impl ::std::ops::Deref for Symbol { + type Target = T; + fn deref(&self) -> &T { + unsafe { + // Additional reference level for a dereference on `deref` return value. + mem::transmute(&self.pointer) + } + } +} + +impl fmt::Debug for Symbol { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(&format!("Symbol@{:p}", self.pointer)) + } +} + + +static USE_ERRORMODE: AtomicBool = ATOMIC_BOOL_INIT; +struct ErrorModeGuard(DWORD); + +impl ErrorModeGuard { + fn new() -> Option { + const SEM_FAILCE: DWORD = 1; + unsafe { + if !USE_ERRORMODE.load(Ordering::Acquire) { + let mut previous_mode = 0; + let success = errhandlingapi::SetThreadErrorMode(SEM_FAILCE, &mut previous_mode) != 0; + if !success && errhandlingapi::GetLastError() == winerror::ERROR_CALL_NOT_IMPLEMENTED { + USE_ERRORMODE.store(true, Ordering::Release); + } else if !success { + // SetThreadErrorMode failed with some other error? How in the world is it + // possible for what is essentially a simple variable swap to fail? + // For now we just ignore the error -- the worst that can happen here is + // the previous mode staying on and user seeing a dialog error on older Windows + // machines. + return None; + } else if previous_mode == SEM_FAILCE { + return None; + } else { + return Some(ErrorModeGuard(previous_mode)); + } + } + match errhandlingapi::SetErrorMode(SEM_FAILCE) { + SEM_FAILCE => { + // This is important to reduce racy-ness when this library is used on multiple + // threads. In particular this helps with following race condition: + // + // T1: SetErrorMode(SEM_FAILCE) + // T2: SetErrorMode(SEM_FAILCE) + // T1: SetErrorMode(old_mode) # not SEM_FAILCE + // T2: SetErrorMode(SEM_FAILCE) # restores to SEM_FAILCE on drop + // + // This is still somewhat racy in a sense that T1 might restore the error + // mode before T2 finishes loading the library, but that is less of a + // concern – it will only end up in end user seeing a dialog. + // + // Also, SetErrorMode itself is probably not an atomic operation. + None + } + a => Some(ErrorModeGuard(a)) + } + } + } +} + +impl Drop for ErrorModeGuard { + fn drop(&mut self) { + unsafe { + if !USE_ERRORMODE.load(Ordering::Relaxed) { + errhandlingapi::SetThreadErrorMode(self.0, ptr::null_mut()); + } else { + errhandlingapi::SetErrorMode(self.0); + } + } + } +} + +fn with_get_last_error(closure: F) -> Result> +where F: FnOnce() -> Option { + closure().ok_or_else(|| { + let error = unsafe { errhandlingapi::GetLastError() }; + if error == 0 { + None + } else { + Some(io::Error::from_raw_os_error(error as i32)) + } + }) +} + +#[test] +fn works_getlasterror() { + let lib = Library::new("kernel32.dll").unwrap(); + let gle: Symbol DWORD> = unsafe { + lib.get(b"GetLastError").unwrap() + }; + unsafe { + errhandlingapi::SetLastError(42); + assert_eq!(errhandlingapi::GetLastError(), gle()) + } +} + +#[test] +fn works_getlasterror0() { + let lib = Library::new("kernel32.dll").unwrap(); + let gle: Symbol DWORD> = unsafe { + lib.get(b"GetLastError\0").unwrap() + }; + unsafe { + errhandlingapi::SetLastError(42); + assert_eq!(errhandlingapi::GetLastError(), gle()) + } +} diff --git a/third_party/cargo/vendor/libloading-0.5.2/src/test_helpers.rs b/third_party/cargo/vendor/libloading-0.5.2/src/test_helpers.rs new file mode 100644 index 0000000..32f7023 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/src/test_helpers.rs @@ -0,0 +1,49 @@ +//! This is a separate file containing helpers for tests of this library. It is built into a +//! dynamic library by the build.rs script. +#![crate_type="dylib"] // FIXME: should become a cdylib in due time +#![cfg_attr(test_nightly, feature(thread_local))] + +#[no_mangle] +pub static mut TEST_STATIC_U32: u32 = 0; + +#[no_mangle] +pub static mut TEST_STATIC_PTR: *mut () = 0 as *mut _; + +#[cfg(test_nightly)] +#[thread_local] +#[no_mangle] +pub static mut TEST_THREAD_LOCAL: u32 = 0; + +#[no_mangle] +pub extern "C" fn test_identity_u32(x: u32) -> u32 { + x +} + +#[repr(C)] +pub struct S { + a: u64, + b: u32, + c: u16, + d: u8 +} + +#[no_mangle] +pub extern "C" fn test_identity_struct(x: S) -> S { + x +} + +#[no_mangle] +pub unsafe extern "C" fn test_get_static_u32() -> u32 { + TEST_STATIC_U32 +} + +#[no_mangle] +pub unsafe extern "C" fn test_check_static_ptr() -> bool { + TEST_STATIC_PTR == (&mut TEST_STATIC_PTR as *mut *mut _ as *mut _) +} + +#[cfg(test_nightly)] +#[no_mangle] +pub unsafe extern "C" fn test_get_thread_local() -> u32 { + TEST_THREAD_LOCAL +} diff --git a/third_party/cargo/vendor/libloading-0.5.2/src/util.rs b/third_party/cargo/vendor/libloading-0.5.2/src/util.rs new file mode 100644 index 0000000..650266e --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/src/util.rs @@ -0,0 +1,61 @@ +use std::ffi::{CStr, CString, NulError, FromBytesWithNulError}; +use std::borrow::Cow; +use std::os::raw; + +#[derive(Debug)] +pub struct NullError; + +impl From for NullError { + fn from(_: NulError) -> NullError { + NullError + } +} + +impl From for NullError { + fn from(_: FromBytesWithNulError) -> NullError { + NullError + } +} + +impl From for ::std::io::Error { + fn from(e: NullError) -> ::std::io::Error { + ::std::io::Error::new(::std::io::ErrorKind::Other, format!("{}", e)) + } +} + +impl ::std::error::Error for NullError { + fn description(&self) -> &str { "non-final null byte found" } +} + +impl ::std::fmt::Display for NullError { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + write!(f, "non-final null byte found") + } +} + +/// Checks for last byte and avoids allocating if it is zero. +/// +/// Non-last null bytes still result in an error. +pub fn cstr_cow_from_bytes<'a>(slice: &'a [u8]) -> Result, NullError> { + static ZERO: raw::c_char = 0; + Ok(match slice.last() { + // Slice out of 0 elements + None => unsafe { Cow::Borrowed(CStr::from_ptr(&ZERO)) }, + // Slice with trailing 0 + Some(&0) => Cow::Borrowed(try!(CStr::from_bytes_with_nul(slice))), + // Slice with no trailing 0 + Some(_) => Cow::Owned(try!(CString::new(slice))), + }) +} + +#[inline] +pub fn ensure_compatible_types() { + #[cold] + #[inline(never)] + fn dopanic() { + panic!("value of requested type cannot be dynamically loaded"); + } + if ::std::mem::size_of::() != ::std::mem::size_of::() { + dopanic() + } +} diff --git a/third_party/cargo/vendor/libloading-0.5.2/tests/functions.rs b/third_party/cargo/vendor/libloading-0.5.2/tests/functions.rs new file mode 100644 index 0000000..c9bc067 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/tests/functions.rs @@ -0,0 +1,151 @@ +extern crate libloading; +use libloading::{Symbol, Library}; + +const LIBPATH: &'static str = concat!(env!("OUT_DIR"), "/libtest_helpers.dll"); + +fn make_helpers() { + static ONCE: ::std::sync::Once = ::std::sync::ONCE_INIT; + ONCE.call_once(|| { + let mut outpath = String::from(if let Some(od) = option_env!("OUT_DIR") { od } else { return }); + let rustc = option_env!("RUSTC").unwrap_or_else(|| { "rustc".into() }); + outpath.push_str(&"/libtest_helpers.dll"); // extension for windows required, POSIX does not care. + let _ = ::std::process::Command::new(rustc) + .arg("src/test_helpers.rs") + .arg("-o") + .arg(outpath) + .arg("-O") + .output() + .expect("could not compile the test helpers!"); + }); +} + +#[test] +fn test_id_u32() { + make_helpers(); + let lib = Library::new(LIBPATH).unwrap(); + unsafe { + let f: Symbol u32> = lib.get(b"test_identity_u32\0").unwrap(); + assert_eq!(42, f(42)); + } +} + +#[repr(C)] +#[derive(Clone,Copy,PartialEq,Debug)] +struct S { + a: u64, + b: u32, + c: u16, + d: u8 +} + +#[test] +fn test_id_struct() { + make_helpers(); + let lib = Library::new(LIBPATH).unwrap(); + unsafe { + let f: Symbol S> = lib.get(b"test_identity_struct\0").unwrap(); + assert_eq!(S { a: 1, b: 2, c: 3, d: 4 }, f(S { a: 1, b: 2, c: 3, d: 4 })); + } +} + +#[test] +fn test_0_no_0() { + make_helpers(); + let lib = Library::new(LIBPATH).unwrap(); + unsafe { + let f: Symbol S> = lib.get(b"test_identity_struct\0").unwrap(); + let f2: Symbol S> = lib.get(b"test_identity_struct").unwrap(); + assert_eq!(*f, *f2); + } +} + +#[test] +fn wrong_name_fails() { + Library::new(concat!(env!("OUT_DIR"), "/libtest_help")).err().unwrap(); +} + +#[test] +fn missing_symbol_fails() { + make_helpers(); + let lib = Library::new(LIBPATH).unwrap(); + unsafe { + lib.get::<*mut ()>(b"test_does_not_exist").err().unwrap(); + lib.get::<*mut ()>(b"test_does_not_exist\0").err().unwrap(); + } +} + +#[test] +fn interior_null_fails() { + make_helpers(); + let lib = Library::new(LIBPATH).unwrap(); + unsafe { + lib.get::<*mut ()>(b"test_does\0_not_exist").err().unwrap(); + lib.get::<*mut ()>(b"test\0_does_not_exist\0").err().unwrap(); + } +} + +#[test] +#[should_panic] +fn test_incompatible_type() { + make_helpers(); + let lib = Library::new(LIBPATH).unwrap(); + unsafe { + let _ = lib.get::<()>(b"test_identity_u32\0"); + } +} + +#[test] +#[should_panic] +fn test_incompatible_type_named_fn() { + make_helpers(); + unsafe fn get<'a, T>(l: &'a Library, _: T) -> libloading::Result> { + l.get::(b"test_identity_u32\0") + } + let lib = Library::new(LIBPATH).unwrap(); + unsafe { + let _ = get(&lib, test_incompatible_type_named_fn); + } +} + +#[test] +fn test_static_u32() { + make_helpers(); + let lib = Library::new(LIBPATH).unwrap(); + unsafe { + let var: Symbol<*mut u32> = lib.get(b"TEST_STATIC_U32\0").unwrap(); + **var = 42; + let help: Symbol u32> = lib.get(b"test_get_static_u32\0").unwrap(); + assert_eq!(42, help()); + } +} + +#[test] +fn test_static_ptr() { + make_helpers(); + let lib = Library::new(LIBPATH).unwrap(); + unsafe { + let var: Symbol<*mut *mut ()> = lib.get(b"TEST_STATIC_PTR\0").unwrap(); + **var = *var as *mut _; + let works: Symbol bool> = + lib.get(b"test_check_static_ptr\0").unwrap(); + assert!(works()); + } +} + +#[cfg(any(windows, target_os="linux"))] +#[cfg(test_nightly)] +#[test] +fn test_tls_static() { + make_helpers(); + let lib = Library::new(LIBPATH).unwrap(); + unsafe { + let var: Symbol<*mut u32> = lib.get(b"TEST_THREAD_LOCAL\0").unwrap(); + **var = 84; + let help: Symbol u32> = lib.get(b"test_get_thread_local\0").unwrap(); + assert_eq!(84, help()); + } + ::std::thread::spawn(move || unsafe { + let help: Symbol u32> = lib.get(b"test_get_thread_local\0").unwrap(); + assert_eq!(0, help()); + }).join().unwrap(); +} diff --git a/third_party/cargo/vendor/libloading-0.5.2/tests/markers.rs b/third_party/cargo/vendor/libloading-0.5.2/tests/markers.rs new file mode 100644 index 0000000..01da108 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/tests/markers.rs @@ -0,0 +1,79 @@ +extern crate libloading; + +#[cfg(test)] +fn assert_send() {} +#[cfg(test)] +fn assert_sync() {} + +#[test] +fn check_library_send() { + assert_send::(); +} + +#[cfg(unix)] +#[test] +fn check_unix_library_send() { + assert_send::(); +} + +#[cfg(windows)] +#[test] +fn check_windows_library_send() { + assert_send::(); +} + +#[test] +fn check_library_sync() { + assert_sync::(); +} + +#[cfg(unix)] +#[test] +fn check_unix_library_sync() { + assert_sync::(); +} + +#[cfg(windows)] +#[test] +fn check_windows_library_sync() { + assert_sync::(); +} + +#[test] +fn check_symbol_send() { + assert_send:: ()>>(); + // assert_not_send::>(); +} + +#[cfg(unix)] +#[test] +fn check_unix_symbol_send() { + assert_send:: ()>>(); + // assert_not_send::>(); +} + +#[cfg(windows)] +#[test] +fn check_windows_symbol_send() { + assert_send:: ()>>(); +} + +#[test] +fn check_symbol_sync() { + assert_sync:: ()>>(); + // assert_not_sync::>(); +} + +#[cfg(unix)] +#[test] +fn check_unix_symbol_sync() { + assert_sync:: ()>>(); + // assert_not_sync::>(); +} + +#[cfg(windows)] +#[test] +fn check_windows_symbol_sync() { + assert_sync:: ()>>(); + // assert_not_sync::>(); +} diff --git a/third_party/cargo/vendor/libloading-0.5.2/tests/nagisa32.dll b/third_party/cargo/vendor/libloading-0.5.2/tests/nagisa32.dll new file mode 100644 index 0000000..0a6218a Binary files /dev/null and b/third_party/cargo/vendor/libloading-0.5.2/tests/nagisa32.dll differ diff --git a/third_party/cargo/vendor/libloading-0.5.2/tests/nagisa64.dll b/third_party/cargo/vendor/libloading-0.5.2/tests/nagisa64.dll new file mode 100644 index 0000000..bacaa4b Binary files /dev/null and b/third_party/cargo/vendor/libloading-0.5.2/tests/nagisa64.dll differ diff --git a/third_party/cargo/vendor/libloading-0.5.2/tests/windows.rs b/third_party/cargo/vendor/libloading-0.5.2/tests/windows.rs new file mode 100644 index 0000000..343aaa1 --- /dev/null +++ b/third_party/cargo/vendor/libloading-0.5.2/tests/windows.rs @@ -0,0 +1,56 @@ +#![cfg(windows)] +extern crate libloading; +use libloading::os::windows::*; +use std::ffi::CStr; + +// The ordinal DLL contains exactly one function (other than DllMain, that is) with ordinal number +// 1. This function has the sugnature `fn() -> *const c_char` and returns a string "bunny\0" (in +// reference to WindowsBunny). +// +// Both x86_64 and x86 versions of the .dll are functionally the same. Ideally we would compile the +// dlls with well known ordinals from our own testing helpers library, but rustc does not allow +// specifying a custom .def file (https://github.com/rust-lang/rust/issues/35089) +// +// The DLLs were kindly compiled by WindowsBunny (aka. @retep998). + +#[cfg(target_arch="x86")] +fn load_ordinal_lib() -> Library { + Library::new("tests/nagisa32.dll").expect("nagisa32.dll") +} + +#[cfg(target_arch="x86_64")] +fn load_ordinal_lib() -> Library { + Library::new("tests/nagisa64.dll").expect("nagisa64.dll") +} + +#[cfg(any(target_arch="x86", target_arch="x86_64"))] +#[test] +fn test_ordinal() { + let lib = load_ordinal_lib(); + unsafe { + let windows: Symbol *const i8> = lib.get_ordinal(1).expect("function"); + assert_eq!(CStr::from_ptr(windows()).to_bytes(), b"bunny"); + } +} + +#[cfg(any(target_arch="x86", target_arch="x86_64"))] +#[test] +fn test_ordinal_missing_fails() { + let lib = load_ordinal_lib(); + unsafe { + let r: Result *const i8>, _> = lib.get_ordinal(2); + r.err().unwrap(); + let r: Result *const i8>, _> = lib.get_ordinal(!0); + r.err().unwrap(); + } +} + +#[test] +fn test_new_kernel23() { + Library::new("kernel23").err().unwrap(); +} + +#[test] +fn test_new_kernel32_no_ext() { + Library::new("kernel32").unwrap(); +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/.cargo-checksum.json b/third_party/cargo/vendor/line_drawing-0.7.0/.cargo-checksum.json new file mode 100644 index 0000000..10e6fb8 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"d39a2b21daf2ece98f112d355480f0b0160e73e85c66444b231755c473406084","README.md":"3ee098dae2a2797cdfadbb75138ef2bfd4019281b8e7616f1b12b21e923dd919","benches/benchmarks.rs":"3342bcf4823a6ec69cf25e8381c2f0dba66ac8e14d87acecf05c2d341accb3d4","examples/bresenham.rs":"997494fcc6b6e019435dab40ae5f3752cd6e9e4c79f59a9927591ff794383e2a","examples/bresenham_3d.rs":"88e18e9ce412c34cbc81382f0a0c3c19d5bc435c513c05f06af2bc8980749d63","examples/bresenham_circle.rs":"7c86ce1ff6b01eafc8c7e85e5b1c3f2ac197986907f2988b32b28449442945c4","examples/image.rs":"4e6f66a36b3535223c25cd2826c235a5487f64f43cd11d401f24ebc34bff360d","examples/midpoint.rs":"4d0d33a504ea034853f98c33a74bd8bd165cb27e2690b566d482be8010c5f480","examples/scale_up.rs":"576e7aecc28e227a10ef44962a57c66c498222e58e0b03262823193cc39ed892","examples/steps.rs":"821daeea0ab2a1c4169eadc49f89b2c41d1a8341ee4194fd05949e42a6692cc1","examples/supercover.rs":"867f74a037992e6db605a740c5e533f0163f59184b8a89e260bd4ea5ec0dbf13","examples/walk_grid.rs":"5712000d7b4b0618358149eafe1a78c5a4fc4f364bcb7151e1f0849edad469ff","examples/walk_voxels.rs":"e3af1341c10825c6c9d61ef4e50acad6976c2c431f88b6da8f34d4281ffe2888","examples/xiaolin_wu.rs":"310a07e63fc80ee1b041128c0fe94ee3b8f944f6b73ffac52b6c2a1fee1a3815","src/bresenham.rs":"bfae719b5a8883e15631976ea615636fc4b6fbc5532574ee0fdef5a41da2cbfb","src/bresenham_3d.rs":"41a06d404d36910a515def7834570ce3fe764bcc47aef271be6371e32c8aabf0","src/bresenham_circle.rs":"d1182b56632801da96bc44a2f0e4da54f1ba62f044344fb8342ca9c551755866","src/fuzzing.rs":"ddd523aed06cb438c46eab915f156ac454e37609a3a345c03a437e3046b3354a","src/grid_walking.rs":"fbde3c8cede0cc10262f2d33030ae800ab16a074dabb782a1370302c42b482a9","src/lib.rs":"d9fb18881dff7f0c62635df6939f9e3dbc1ce2fe9067929f08bf9a0b565679e8","src/midpoint.rs":"fa499e48d9d38b8bb8e4386e1d3c83ef83440f9a37b9cd7bdd8259979faf7334","src/octant.rs":"69644c46576a39b6d2de979b0b37f31faefb7ab6f4c01b6e46009ee12b39633c","src/steps.rs":"7b3af33b6a4b6e39f8a55c92603d9704a1edc9cf1754c8f553417d0f3bf59094","src/walk_voxels.rs":"d7dccc15c6ddcd734988a6d85ec04261f1c3394def5cf155b594a4f0e9565617","src/xiaolin_wu.rs":"768f1604904b8d1918957e7c923768c14ee8bbda62aeaea9431563077dfceb88"},"package":"5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9"} \ No newline at end of file diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/BUILD b/third_party/cargo/vendor/line_drawing-0.7.0/BUILD new file mode 100644 index 0000000..9bf00b0 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/BUILD @@ -0,0 +1,55 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "benchmarks" with type "bench" omitted +# Unsupported target "bresenham" with type "example" omitted +# Unsupported target "bresenham_3d" with type "example" omitted +# Unsupported target "bresenham_circle" with type "example" omitted +# Unsupported target "image" with type "example" omitted + +rust_library( + name = "line_drawing", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/num-traits-0.2.11:num_traits", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.7.0", + crate_features = [ + ], +) + +# Unsupported target "midpoint" with type "example" omitted +# Unsupported target "scale_up" with type "example" omitted +# Unsupported target "steps" with type "example" omitted +# Unsupported target "supercover" with type "example" omitted +# Unsupported target "walk_grid" with type "example" omitted +# Unsupported target "walk_voxels" with type "example" omitted +# Unsupported target "xiaolin_wu" with type "example" omitted diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/Cargo.toml b/third_party/cargo/vendor/line_drawing-0.7.0/Cargo.toml new file mode 100644 index 0000000..3ad3797 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/Cargo.toml @@ -0,0 +1,33 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "line_drawing" +version = "0.7.0" +authors = ["Expenses "] +description = "A collection of line-drawing algorithms for use in graphics and video games." +documentation = "https://docs.rs/line_drawing" +readme = "README.md" +keywords = ["line", "drawing", "bresenham", "sight", "game"] +categories = ["algorithms", "games"] +license = "MIT" +repository = "https://github.com/expenses/line_drawing" +[dependencies.num-traits] +version = "0" +[dev-dependencies.bresenham] +version = "0" + +[dev-dependencies.image] +version = "0" + +[dev-dependencies.rand] +version = "0" diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/README.md b/third_party/cargo/vendor/line_drawing-0.7.0/README.md new file mode 100644 index 0000000..05a0381 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/README.md @@ -0,0 +1,19 @@ +[![](https://img.shields.io/crates/v/line_drawing.svg)](https://crates.io/crates/line_drawing) +[![](https://docs.rs/line_drawing/badge.svg)](https://docs.rs/line_drawing) + +A collection of line-drawing algorithms for use in graphics and video games. + +Currently implemented: + +* `Bresenham` - An implementation of [Bresenham's line algorithm]. +* `Bresenham3d` - A 3-Dimensional implementation of bresenham. +* `BresenhamCircle` - Bresenham's circle algorithm. +* `Midpoint` - The [mid-point line algorithm]. +* `WalkGrid` and `Supercover` - implemented from [this article by Red Blob Games][article]. +* `WalkVoxels` - A similar 3-Dimensional algorithm that only takes orthogonal steps. +* `XiaolinWu` - [Xiaolin Wu's line algorithm]. + +[Bresenham's line algorithm]: https://en.wikipedia.org/wiki/Bresenham's_line_algorithm +[mid-point line algorithm]: http://www.mat.univie.ac.at/~kriegl/Skripten/CG/node25.html +[article]: http://www.redblobgames.com/grids/line-drawing.html +[Xiaolin Wu's line algorithm]: https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/benches/benchmarks.rs b/third_party/cargo/vendor/line_drawing-0.7.0/benches/benchmarks.rs new file mode 100644 index 0000000..1d42d8d --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/benches/benchmarks.rs @@ -0,0 +1,83 @@ +#![feature(test)] + +extern crate bresenham; +extern crate line_drawing; +extern crate test; + +use line_drawing::*; +use test::Bencher; + +const START: (isize, isize) = (678, 1000); +const END: (isize, isize) = (0, 0); + +const START_FLOAT: (f32, f32) = (START.0 as f32, START.1 as f32); +const END_FLOAT: (f32, f32) = (END.0 as f32, END.1 as f32); + +const START_VOXEL: (isize, isize, isize) = (START.0, START.1, 0); +const END_VOXEL: (isize, isize, isize) = (END.0, END.1, 0); + +const START_VOXEL_FLOAT: (f32, f32, f32) = (START_FLOAT.0, START_FLOAT.1, 0.0); +const END_VOXEL_FLOAT: (f32, f32, f32) = (END_FLOAT.0, END_FLOAT.1, 0.0); + +#[bench] +fn bench_bresenham(bencher: &mut Bencher) { + bencher.iter(|| black_box(Bresenham::new(START, END))); +} + +#[bench] +fn bench_bresenham_crate(bencher: &mut Bencher) { + bencher.iter(|| black_box(bresenham::Bresenham::new(START, END))); +} + +#[bench] +fn bench_walk_grid(bencher: &mut Bencher) { + bencher.iter(|| black_box(WalkGrid::new(START, END))); +} + +#[bench] +fn bench_supercover(bencher: &mut Bencher) { + bencher.iter(|| black_box(Supercover::new(START, END))); +} + +#[bench] +fn bench_midpoint(bencher: &mut Bencher) { + bencher.iter(|| black_box(Midpoint::<_, isize>::new(START_FLOAT, END_FLOAT))); +} + +#[bench] +fn bench_xiaolin_wu(bencher: &mut Bencher) { + bencher.iter(|| black_box(XiaolinWu::<_, isize>::new(START_FLOAT, END_FLOAT))); +} + +#[bench] +fn bench_bresenham_3d(bencher: &mut Bencher) { + bencher.iter(|| black_box(Bresenham3d::new(START_VOXEL, END_VOXEL))); +} + +#[bench] +fn bench_walk_voxels(bencher: &mut Bencher) { + bencher.iter(|| { + black_box(WalkVoxels::<_, isize>::new( + START_VOXEL_FLOAT, + END_VOXEL_FLOAT, + &VoxelOrigin::Center, + )) + }); +} + +#[bench] +fn bench_steps_bresenham(bencher: &mut Bencher) { + bencher.iter(|| black_box(Bresenham::new(START, END).steps())); +} + +#[bench] +fn bench_bresenham_circle(bencher: &mut Bencher) { + bencher.iter(|| black_box(BresenhamCircle::new(0, 0, 300))); +} + +#[inline] +fn black_box(iter: T) { + for item in iter { + test::black_box(item); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/bresenham.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/bresenham.rs new file mode 100644 index 0000000..376b656 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/bresenham.rs @@ -0,0 +1,8 @@ +extern crate line_drawing; +use line_drawing::Bresenham; + +fn main() { + for (x, y) in Bresenham::new((0, 0), (5, 6)) { + print!("({}, {}), ", x, y); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/bresenham_3d.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/bresenham_3d.rs new file mode 100644 index 0000000..50442d0 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/bresenham_3d.rs @@ -0,0 +1,8 @@ +extern crate line_drawing; +use line_drawing::Bresenham3d; + +fn main() { + for (x, y, z) in Bresenham3d::new((0, 0, 0), (5, 6, 7)) { + print!("({}, {}, {}), ", x, y, z); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/bresenham_circle.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/bresenham_circle.rs new file mode 100644 index 0000000..6bec54e --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/bresenham_circle.rs @@ -0,0 +1,8 @@ +extern crate line_drawing; +use line_drawing::BresenhamCircle; + +fn main() { + for (x, y) in BresenhamCircle::new(0, 0, 1) { + print!("({}, {}), ", x, y); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/image.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/image.rs new file mode 100644 index 0000000..515ca59 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/image.rs @@ -0,0 +1,71 @@ +extern crate image; +extern crate line_drawing; + +use line_drawing::*; +use image::{DynamicImage, ImageBuffer, Rgb}; + +type Image = ImageBuffer, Vec>; + +// Draw a line of pixels onto the image with a specific colour +fn draw_line(image: &mut Image, line: T, colour: [u8; 3]) +where + T: Iterator>, +{ + for point in line { + image.put_pixel(point.0 as u32, point.1 as u32, Rgb(colour)); + } +} + +// Draw an anti-aliased line of pixels +fn draw_xiaolin_wu(image: &mut Image, line: XiaolinWu) { + for (point, value) in line { + image.put_pixel( + point.0 as u32, + point.1 as u32, + Rgb([(255.0 * value).round() as u8; 3]), + ); + } +} + +fn main() { + let mut image = DynamicImage::new_rgb8(300, 300).to_rgb(); + + // Draw each of the different line types + draw_line(&mut image, WalkGrid::new((10, 230), (50, 290)), [255, 0, 0]); + draw_line( + &mut image, + Supercover::new((10, 210), (90, 290)), + [255, 128, 0], + ); + draw_line( + &mut image, + Midpoint::new((10.0, 187.5), (122.22, 290.0)), + [128, 255, 0], + ); + draw_line( + &mut image, + Bresenham::new((10, 165), (170, 290)), + [0, 255, 0], + ); + + // Draw two lines on top of each other to show how bresenham isn't symetrical + let a = (10, 10); + let b = (200, 290); + draw_line(&mut image, Bresenham::new(a, b), [255, 0, 0]); + draw_line(&mut image, Bresenham::new(b, a), [0, 128, 255]); + + // Draw a triangle made out of xiaolin wi lines + let a = (275.0, 150.0); + let b = (210.0, 285.0); + let c = (290.0, 290.0); + draw_xiaolin_wu(&mut image, XiaolinWu::new(a, b)); + draw_xiaolin_wu(&mut image, XiaolinWu::new(b, c)); + draw_xiaolin_wu(&mut image, XiaolinWu::new(c, a)); + + for point in BresenhamCircle::new(200, 100, 50) { + image.put_pixel(point.0 as u32, point.1 as u32, Rgb([255, 0, 0])); + } + + // Save the image + image.save("example.png").unwrap(); +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/midpoint.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/midpoint.rs new file mode 100644 index 0000000..9f5cd72 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/midpoint.rs @@ -0,0 +1,8 @@ +extern crate line_drawing; +use line_drawing::Midpoint; + +fn main() { + for (x, y) in Midpoint::<_, i8>::new((0.2, 0.02), (2.8, 7.7)) { + print!("({}, {}), ", x, y); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/scale_up.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/scale_up.rs new file mode 100644 index 0000000..ddcb0a3 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/scale_up.rs @@ -0,0 +1,40 @@ +extern crate image; +extern crate line_drawing; + +use line_drawing::*; +use image::*; + +const BLACK: [u8; 4] = [255, 255, 255, 255]; +const GREY: [u8; 4] = [128, 128, 128, 255]; +const SIZE: u32 = 15; +const SCALE: u32 = 15; + +const SCALE_I: i32 = SCALE as i32; +const SCALE_HALF: i32 = SCALE_I / 2; + +// Draw a line of pixels onto the image with a specific colour +fn draw_line(image: &mut DynamicImage, line: T, colour: [u8; 4]) +where + T: Iterator>, +{ + for point in line { + image.put_pixel(point.0 as u32, point.1 as u32, Rgba(colour)); + } +} + +fn main() { + let mut image = DynamicImage::new_rgb8(SIZE, SIZE); + let a = (0, 0); + let b = (6, 14); + + draw_line(&mut image, WalkGrid::new(a, b), BLACK); + + let mut image = image.resize(SIZE * SCALE, SIZE * SCALE, FilterType::Nearest); + + let a = (a.0 * SCALE_I + SCALE_HALF, a.1 * SCALE_I + SCALE_HALF); + let b = (b.0 * SCALE_I + SCALE_HALF, b.1 * SCALE_I + SCALE_HALF); + + draw_line(&mut image, Bresenham::new(a, b), GREY); + + image.to_rgb().save("test.png").unwrap(); +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/steps.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/steps.rs new file mode 100644 index 0000000..8021664 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/steps.rs @@ -0,0 +1,8 @@ +extern crate line_drawing; +use line_drawing::WalkGrid; + +fn main() { + for (start, end) in WalkGrid::new((0, 0), (5, 3)).steps() { + println!("{:?} -> {:?}", start, end); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/supercover.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/supercover.rs new file mode 100644 index 0000000..8037d9f --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/supercover.rs @@ -0,0 +1,8 @@ +extern crate line_drawing; +use line_drawing::Supercover; + +fn main() { + for (x, y) in Supercover::new((0, 0), (5, 5)) { + print!("({}, {}), ", x, y); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/walk_grid.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/walk_grid.rs new file mode 100644 index 0000000..cea5449 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/walk_grid.rs @@ -0,0 +1,8 @@ +extern crate line_drawing; +use line_drawing::WalkGrid; + +fn main() { + for (x, y) in WalkGrid::new((0, 0), (5, 3)) { + print!("({}, {}), ", x, y); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/walk_voxels.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/walk_voxels.rs new file mode 100644 index 0000000..07af00e --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/walk_voxels.rs @@ -0,0 +1,14 @@ +extern crate line_drawing; +use line_drawing::{VoxelOrigin, WalkVoxels}; + +fn main() { + let a = (0.0, 0.0, 0.0); + let b = (5.0, 6.0, 7.0); + + for (i, (x, y, z)) in WalkVoxels::::new(a, b, &VoxelOrigin::Center).enumerate() { + if i > 0 && i % 5 == 0 { + println!(); + } + print!("({}, {}, {}), ", x, y, z); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/examples/xiaolin_wu.rs b/third_party/cargo/vendor/line_drawing-0.7.0/examples/xiaolin_wu.rs new file mode 100644 index 0000000..8ed4631 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/examples/xiaolin_wu.rs @@ -0,0 +1,8 @@ +extern crate line_drawing; +use line_drawing::XiaolinWu; + +fn main() { + for ((x, y), value) in XiaolinWu::::new((0.0, 0.0), (3.0, 6.0)) { + print!("(({}, {}), {}), ", x, y, value); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/bresenham.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/bresenham.rs new file mode 100644 index 0000000..8dcde76 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/bresenham.rs @@ -0,0 +1,91 @@ +use {Point, SignedNum}; +use octant::Octant; +use steps::Steps; + +/// An implementation of [Bresenham's line algorithm]. +/// +/// Includes both the start and end point and is asymmetrical. +/// +/// Example: +/// +/// ```rust +/// extern crate line_drawing; +/// use line_drawing::Bresenham; +/// +/// fn main() { +/// for (x, y) in Bresenham::new((0, 0), (5, 6)) { +/// print!("({}, {}), ", x, y); +/// } +/// } +/// ``` +/// +/// ```text +/// (0, 0), (0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), +/// ``` +/// +/// [Bresenham's line algorithm]: https://en.wikipedia.org/wiki/Bresenham's_line_algorithm +pub struct Bresenham { + point: Point, + end_x: T, + delta_x: T, + delta_y: T, + error: T, + octant: Octant, +} + +impl Bresenham { + #[inline] + pub fn new(start: Point, end: Point) -> Self { + let octant = Octant::new(start, end); + let start = octant.to(start); + let end = octant.to(end); + + let delta_x = end.0 - start.0; + let delta_y = end.1 - start.1; + + Self { + delta_x, + delta_y, + octant, + point: start, + end_x: end.0, + error: delta_y - delta_x, + } + } + + #[inline] + pub fn steps(self) -> Steps, Self> { + Steps::new(self) + } +} + +impl Iterator for Bresenham { + type Item = Point; + + #[inline] + fn next(&mut self) -> Option { + if self.point.0 <= self.end_x { + let point = self.octant.from(self.point); + + if self.error >= T::zero() { + self.point.1 += T::one(); + self.error -= self.delta_x; + } + + self.point.0 += T::one(); + self.error += self.delta_y; + + Some(point) + } else { + None + } + } +} + +#[test] +fn test() { + assert_eq!( + Bresenham::new((0, 0), (5, 5)).collect::>(), + [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)] + ) +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/bresenham_3d.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/bresenham_3d.rs new file mode 100644 index 0000000..ffb21bd --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/bresenham_3d.rs @@ -0,0 +1,129 @@ +use {SignedNum, Voxel}; +use steps::Steps; +use std::cmp::max; + +/// An 3-D implementation of bresenham, sourced from [this site]. +/// +/// It includes both the start and end point and is asymmetrical. +/// +/// Example: +/// +/// ``` +/// extern crate line_drawing; +/// use line_drawing::Bresenham3d; +/// +/// fn main() { +/// for (x, y, z) in Bresenham3d::new((0, 0, 0), (5, 6, 7)) { +/// print!("({}, {}, {}), ", x, y, z); +/// } +/// } +/// ``` +/// +/// ```text +/// (0, 0, 0), (1, 1, 1), (1, 2, 2), (2, 3, 3), (3, 3, 4), (4, 4, 5), (4, 5, 6), (5, 6, 7), +/// ``` +/// +/// [this site]: http://members.chello.at/~easyfilter/bresenham.html +pub struct Bresenham3d { + sign_x: T, + sign_y: T, + sign_z: T, + err_x: T, + err_y: T, + err_z: T, + len_x: T, + len_y: T, + len_z: T, + longest: T, + count: T, + voxel: Voxel, +} + +impl Bresenham3d { + #[inline] + pub fn new(start: Voxel, end: Voxel) -> Self { + let delta_x = end.0 - start.0; + let delta_y = end.1 - start.1; + let delta_z = end.2 - start.2; + + let len_x = delta_x.abs(); + let len_y = delta_y.abs(); + let len_z = delta_z.abs(); + + let longest = max(len_x, max(len_y, len_z)); + + Self { + len_x, + len_y, + len_z, + longest, + count: longest, + err_x: longest / T::cast(2), + err_y: longest / T::cast(2), + err_z: longest / T::cast(2), + sign_x: delta_x.signum(), + sign_y: delta_y.signum(), + sign_z: delta_z.signum(), + voxel: start, + } + } + + #[inline] + pub fn steps(self) -> Steps, Self> { + Steps::new(self) + } +} + +impl Iterator for Bresenham3d { + type Item = Voxel; + + #[inline] + fn next(&mut self) -> Option { + if self.count >= T::zero() { + self.count -= T::one(); + self.err_x -= self.len_x; + self.err_y -= self.len_y; + self.err_z -= self.len_z; + + let voxel = self.voxel; + + if self.err_x < T::zero() { + self.err_x += self.longest; + self.voxel.0 += self.sign_x; + } + + if self.err_y < T::zero() { + self.err_y += self.longest; + self.voxel.1 += self.sign_y; + } + + if self.err_z < T::zero() { + self.err_z += self.longest; + self.voxel.2 += self.sign_z; + } + + Some(voxel) + } else { + None + } + } +} + +#[test] +fn tests() { + assert_eq!( + Bresenham3d::new((0, 0, 0), (5, 5, 5)).collect::>(), + [ + (0, 0, 0), + (1, 1, 1), + (2, 2, 2), + (3, 3, 3), + (4, 4, 4), + (5, 5, 5) + ] + ); + + assert_eq!(Bresenham3d::new((0, 0, 0), (500, 678, 1000)).count(), 1001); + + assert_eq!(Bresenham3d::new((500, 678, 1000), (0, 0, 0)).count(), 1001); +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/bresenham_circle.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/bresenham_circle.rs new file mode 100644 index 0000000..81b7d50 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/bresenham_circle.rs @@ -0,0 +1,87 @@ +use {Point, SignedNum}; + +/// An implementation of [Bresenham's circle algorithm]. +/// +/// This uses four quadrants, so calling `next()` will return a point for the first quadrant, +/// then the second, third, fourth and then back to first. +/// +/// Example: +/// +/// ``` +/// extern crate line_drawing; +/// use line_drawing::BresenhamCircle; +/// +/// fn main() { +/// for (x, y) in BresenhamCircle::new(0, 0, 1) { +/// print!("({}, {}), ", x, y); +/// } +/// } +/// ``` +/// +/// ```text +/// (1, 0), (0, 1), (-1, 0), (0, -1), +/// ``` +/// +/// [Bresenham's circle algorithm]: http://members.chello.at/~easyfilter/bresenham.html +pub struct BresenhamCircle { + x: T, + y: T, + center_x: T, + center_y: T, + radius: T, + error: T, + quadrant: u8, +} + +impl BresenhamCircle { + #[inline] + pub fn new(center_x: T, center_y: T, radius: T) -> Self { + Self { + center_x, + center_y, + radius, + x: -radius, + y: T::zero(), + error: T::cast(2) - T::cast(2) * radius, + quadrant: 1, + } + } +} + +impl Iterator for BresenhamCircle { + type Item = Point; + + #[inline] + fn next(&mut self) -> Option { + if self.x < T::zero() { + let point = match self.quadrant { + 1 => (self.center_x - self.x, self.center_y + self.y), + 2 => (self.center_x - self.y, self.center_y - self.x), + 3 => (self.center_x + self.x, self.center_y - self.y), + 4 => (self.center_x + self.y, self.center_y + self.x), + _ => unreachable!(), + }; + + // Update the variables after each set of quadrants + if self.quadrant == 4 { + self.radius = self.error; + + if self.radius <= self.y { + self.y += T::one(); + self.error += self.y * T::cast(2) + T::one(); + } + + if self.radius > self.x || self.error > self.y { + self.x += T::one(); + self.error += self.x * T::cast(2) + T::one(); + } + } + + self.quadrant = self.quadrant % 4 + 1; + + Some(point) + } else { + None + } + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/fuzzing.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/fuzzing.rs new file mode 100644 index 0000000..2c809f8 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/fuzzing.rs @@ -0,0 +1,102 @@ +#![cfg(test)] + +extern crate rand; + +use self::rand::Rng; +use self::rand::distributions::range::SampleRange; +use ::*; + +use std::ops::Neg; + +const NUM_TESTS: u16 = 10000; +const RANGE: isize = 500; +const RANGE_FLOAT: f32 = 500.0; + +pub fn reverse_slice(points: &[T]) -> Vec { + points.iter().rev().cloned().collect() +} + +fn random_point(rng: &mut rand::ThreadRng, range: T) -> Point +where + T: SampleRange + PartialOrd + Neg + Copy, +{ + (rng.gen_range(-range, range), rng.gen_range(-range, range)) +} + +fn random_voxel(rng: &mut rand::ThreadRng, range: T) -> Voxel +where + T: SampleRange + PartialOrd + Neg + Copy, +{ + ( + rng.gen_range(-range, range), + rng.gen_range(-range, range), + rng.gen_range(-range, range), + ) +} + +#[test] +fn supercover_symmetrical() { + let supercover = |a, b| Supercover::new(a, b).collect::>(); + + let mut rng = rand::thread_rng(); + + for _ in 0..NUM_TESTS { + let start = random_point(&mut rng, RANGE); + let end = random_point(&mut rng, RANGE); + + assert_eq!( + supercover(start, end), + reverse_slice(&supercover(end, start)) + ); + } +} + +#[test] +#[should_panic] +fn bresenham_not_symmetrical() { + let bresenham = |a, b| Bresenham::new(a, b).collect::>(); + let mut rng = rand::thread_rng(); + + for _ in 0..NUM_TESTS { + let start = random_point(&mut rng, RANGE); + let end = random_point(&mut rng, RANGE); + + assert_eq!(bresenham(start, end), reverse_slice(&bresenham(end, start))); + } +} + +#[test] +#[should_panic] +fn bresenham_3d_not_symmetrical() { + let bresenham_3d = |a, b| Bresenham3d::new(a, b).collect::>(); + let mut rng = rand::thread_rng(); + + for _ in 0..NUM_TESTS { + let start = random_voxel(&mut rng, RANGE); + let end = random_voxel(&mut rng, RANGE); + + assert_eq!( + bresenham_3d(start, end), + reverse_slice(&bresenham_3d(end, start)) + ); + } +} + +#[test] +#[should_panic] +fn walk_voxels_symmetrical() { + use VoxelOrigin::Center; + + let walk_voxels = |a, b| WalkVoxels::<_, i16>::new(a, b, &Center).collect::>(); + let mut rng = rand::thread_rng(); + + for _ in 0..NUM_TESTS { + let start = random_voxel(&mut rng, RANGE_FLOAT); + let end = random_voxel(&mut rng, RANGE_FLOAT); + + assert_eq!( + walk_voxels(start, end), + reverse_slice(&walk_voxels(end, start)) + ); + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/grid_walking.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/grid_walking.rs new file mode 100644 index 0000000..57a4a26 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/grid_walking.rs @@ -0,0 +1,240 @@ +use {Point, SignedNum}; +use steps::Steps; + +/// Walk along a grid, taking only orthogonal steps. +/// +/// See [this section] of the [article] for an interactive demonstration. +/// +/// Note that this algorithm isn't symetrical; if you swap `start` and `end`, the reversed line +/// might not be the same. +/// +/// Example: +/// +/// ``` +/// extern crate line_drawing; +/// use line_drawing::WalkGrid; +/// +/// fn main() { +/// for (x, y) in WalkGrid::new((0, 0), (5, 3)) { +/// print!("({}, {}), ", x, y); +/// } +/// } +/// ``` +/// +/// ```text +/// (0, 0), (1, 0), (1, 1), (2, 1), (2, 2), (3, 2), (4, 2), (4, 3), (5, 3), +/// ``` +/// +/// [this section]: http://www.redblobgames.com/grids/line-drawing.html#org3c085ed +/// [article]: http://www.redblobgames.com/grids/line-drawing.html +pub struct WalkGrid { + point: Point, + ix: f32, + iy: f32, + sign_x: T, + sign_y: T, + ny: f32, + nx: f32, +} + +impl WalkGrid { + #[inline] + pub fn new(start: Point, end: Point) -> WalkGrid { + // Delta values between the points + let (dx, dy) = (end.0 - start.0, end.1 - start.1); + + WalkGrid { + point: start, + ix: 0.0, + iy: 0.0, + sign_x: dx.signum(), + sign_y: dy.signum(), + nx: dx.abs().to_f32().unwrap(), + ny: dy.abs().to_f32().unwrap(), + } + } + + #[inline] + pub fn steps(self) -> Steps, WalkGrid> { + Steps::new(self) + } +} + +impl Iterator for WalkGrid { + type Item = Point; + + #[inline] + fn next(&mut self) -> Option { + if self.ix <= self.nx && self.iy <= self.ny { + let point = self.point; + + if (0.5 + self.ix) / self.nx < (0.5 + self.iy) / self.ny { + self.point.0 += self.sign_x; + self.ix += 1.0; + } else { + self.point.1 += self.sign_y; + self.iy += 1.0; + } + + Some(point) + } else { + None + } + } +} + +/// Like [`WalkGrid`] but takes diagonal steps if the line passes directly over a corner. +/// +/// See [this section][section] of the [article] for an interactive demonstration. +/// +/// This algorithm should always be symetrical. +/// +/// Example: +/// +/// ``` +/// extern crate line_drawing; +/// use line_drawing::Supercover; +/// +/// fn main() { +/// for (x, y) in Supercover::new((0, 0), (5, 5)) { +/// print!("({}, {}), ", x, y); +/// } +/// } +/// ``` +/// +/// ```text +/// (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), +/// ``` +/// +/// [`WalkGrid`]: struct.WalkGrid.html +/// [section]: http://www.redblobgames.com/grids/line-drawing.html#org1da485d +/// [article]: http://www.redblobgames.com/grids/line-drawing.html +pub struct Supercover { + point: Point, + ix: f32, + iy: f32, + sign_x: T, + sign_y: T, + ny: f32, + nx: f32, +} + +impl Supercover { + #[inline] + pub fn new(start: Point, end: Point) -> Self { + // Delta values between the points + let (dx, dy) = (end.0 - start.0, end.1 - start.1); + + Self { + point: start, + ix: 0.0, + iy: 0.0, + sign_x: dx.signum(), + sign_y: dy.signum(), + nx: dx.abs().to_f32().unwrap(), + ny: dy.abs().to_f32().unwrap(), + } + } + + #[inline] + pub fn steps(self) -> Steps, Self> { + Steps::new(self) + } +} + +impl Iterator for Supercover { + type Item = Point; + + #[inline] + fn next(&mut self) -> Option { + if self.ix <= self.nx && self.iy <= self.ny { + let point = self.point; + + let comparison = ((0.5 + self.ix) / self.nx) - ((0.5 + self.iy) / self.ny); + + // If the comparison is equal then jump diagonally + if comparison == 0.0 { + self.point.0 += self.sign_x; + self.point.1 += self.sign_y; + self.ix += 1.0; + self.iy += 1.0; + } else if comparison < 0.0 { + self.point.0 += self.sign_x; + self.ix += 1.0; + } else { + self.point.1 += self.sign_y; + self.iy += 1.0; + } + + Some(point) + } else { + None + } + } +} + +#[test] +fn walk_grid_tests() { + use fuzzing::reverse_slice; + let walk_grid = |a, b| WalkGrid::new(a, b).collect::>(); + + assert_eq!( + walk_grid((0, 0), (2, 2)), + [(0, 0), (0, 1), (1, 1), (1, 2), (2, 2)] + ); + + assert_eq!( + walk_grid((0, 0), (3, 2)), + [(0, 0), (1, 0), (1, 1), (2, 1), (2, 2), (3, 2)] + ); + + assert_eq!( + walk_grid((0, 0), (0, 5)), + [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5)] + ); + + assert_eq!( + walk_grid((0, 0), (5, 0)), + [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0)] + ); + + // by default, walk grid is asymmetrical + assert_ne!( + walk_grid((0, 0), (2, 2)), + reverse_slice(&walk_grid((2, 2), (0, 0))) + ); +} + +#[test] +fn supercover_tests() { + let walk_grid = |a, b| WalkGrid::new(a, b).collect::>(); + let supercover = |a, b| Supercover::new(a, b).collect::>(); + + // supercover should jump diagonally if the difference is equal + + assert_eq!( + supercover((0, 0), (5, 5)), + [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)] + ); + + assert_eq!(supercover((0, 0), (3, 1)), [(0, 0), (1, 0), (2, 1), (3, 1)]); + + assert_eq!( + supercover((0, 0), (0, 5)), + [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5)] + ); + + assert_eq!( + supercover((0, 0), (5, 0)), + [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0)] + ); + + assert_ne!(walk_grid((0, 0), (-10, 10)), supercover((0, 0), (-10, 10))); + assert_ne!( + walk_grid((20, 10), (10, 20)), + supercover((20, 10), (10, 20)) + ); + + // otherwise it should do the same as walk grid + assert_eq!(supercover((0, 0), (4, 5)), walk_grid((0, 0), (4, 5))); +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/lib.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/lib.rs new file mode 100644 index 0000000..e79f477 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/lib.rs @@ -0,0 +1,73 @@ +//! A collection of line-drawing algorithms for use in graphics and video games. +//! +//! Currently implemented: +//! +//! * [`Bresenham`] - An implementation of [Bresenham's line algorithm]. +//! * [`Bresenham3d`] - A 3-Dimensional implementation of bresenham. +//! * [`BresenhamCircle`] - Bresenham's circle algorithm. +//! * [`Midpoint`] - The [mid-point line algorithm]. +//! * [`WalkGrid`] and [`Supercover`] - implemented from [this article by Red Blob Games][article]. +//! * [`WalkVoxels`] - A similar 3-Dimensional algorithm that only takes orthogonal steps. +//! * [`XiaolinWu`] - [Xiaolin Wu's line algorithm]. +//! +//! [`Bresenham`]: struct.Bresenham.html +//! [Bresenham's line algorithm]: https://en.wikipedia.org/wiki/Bresenham's_line_algorithm +//! [`Bresenham3d`]: struct.Bresenham3d.html +//! [`BresenhamCircle`]: struct.BresenhamCircle.html +//! [`Midpoint`]: struct.Midpoint.html +//! [mid-point line algorithm]: http://www.mat.univie.ac.at/~kriegl/Skripten/CG/node25.html +//! [`WalkGrid`]: struct.WalkGrid.html +//! [`Supercover`]: struct.Supercover.html +//! [article]: http://www.redblobgames.com/grids/line-drawing.html +//! [`XiaolinWu`]: struct.XiaolinWu.html +//! [Xiaolin Wu's line algorithm]: https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm +//! [`WalkVoxels`]: struct.WalkVoxels.html + +extern crate num_traits; + +pub mod steps; +pub mod octant; + +mod bresenham; +mod midpoint; +mod xiaolin_wu; +mod grid_walking; +mod fuzzing; +mod bresenham_3d; +mod walk_voxels; +mod bresenham_circle; + +pub use bresenham::*; +pub use midpoint::*; +pub use xiaolin_wu::*; +pub use grid_walking::*; +pub use bresenham_3d::*; +pub use walk_voxels::*; +pub use bresenham_circle::*; + +use num_traits::{Float, NumAssignOps, NumCast, Signed}; + +/// A point in 2D space. +pub type Point = (T, T); +/// An point in 3D space. +pub type Voxel = (T, T, T); + +/// All the floating-point primitives. +pub trait FloatNum: Float + NumAssignOps { + #[inline] + fn cast(value: T) -> Self { + NumCast::from(value).unwrap() + } +} + +impl FloatNum for T {} + +/// All the signed integer primitives. +pub trait SignedNum: Signed + Ord + Copy + NumCast + NumAssignOps { + #[inline] + fn cast(value: T) -> Self { + NumCast::from(value).unwrap() + } +} + +impl SignedNum for T {} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/midpoint.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/midpoint.rs new file mode 100644 index 0000000..f43d249 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/midpoint.rs @@ -0,0 +1,107 @@ +use {FloatNum, Point, SignedNum}; +use octant::Octant; +use steps::Steps; + +/// An implementation of the [mid-point line drawing algorithm]. +/// +/// The biggest difference between this algorithm and [`Bresenham`] is that it uses floating-point points. +/// +/// Example: +/// +/// ``` +/// extern crate line_drawing; +/// use line_drawing::Midpoint; +/// +/// fn main() { +/// for (x, y) in Midpoint::::new((0.2, 0.02), (2.8, 7.7)) { +/// print!("({}, {}), ", x, y); +/// } +/// } +/// ``` +/// +/// ```text +/// (0, 0), (1, 1), (1, 2), (1, 3), (2, 4), (2, 5), (2, 6), (3, 7), (3, 8), +/// ``` +/// +/// [mid-point line drawing algorithm]: http://www.mat.univie.ac.at/~kriegl/Skripten/CG/node25.html +/// [`Bresenham`]: struct.bresenham.html +pub struct Midpoint { + octant: Octant, + point: Point, + a: I, + b: I, + k: I, + end_x: O, +} + +impl Midpoint { + #[inline] + pub fn new(start: Point, end: Point) -> Self { + // Get the octant to use + let octant = Octant::new(start, end); + + // Convert the points into the octant versions + let start = octant.to(start); + let end = octant.to(end); + + // Initialise the variables + + let a = -(end.1 - start.1); + let b = end.0 - start.0; + let c = start.0 * end.1 - end.0 * start.1; + + Self { + octant, + a, + b, + point: (O::cast(start.0.round()), O::cast(start.1.round())), + k: a * (start.0.round() + I::one()) + b * (start.1.round() + I::cast(0.5)) + c, + end_x: O::cast(end.0.round()), + } + } + + #[inline] + pub fn steps(self) -> Steps, Self> { + Steps::new(self) + } +} + +impl Iterator for Midpoint { + type Item = Point; + + #[inline] + fn next(&mut self) -> Option { + if self.point.0 <= self.end_x { + let point = self.octant.from(self.point); + + // Take an N step + if self.k <= I::zero() { + self.k += self.b; + self.point.1 += O::one(); + } + + // Take an E step + self.k += self.a; + self.point.0 += O::one(); + + Some(point) + } else { + None + } + } +} + +#[test] +fn tests() { + let midpoint = |a, b| Midpoint::new(a, b).collect::>(); + + assert_eq!( + midpoint((0.0, 0.0), (-5.0, -5.0)), + [(0, 0), (-1, -1), (-2, -2), (-3, -3), (-4, -4), (-5, -5)] + ); + + assert_eq!( + midpoint((0.0, 0.0), (6.0, 3.0)), + [(0, 0), (1, 1), (2, 1), (3, 2), (4, 2), (5, 3), (6, 3)] + ); +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/octant.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/octant.rs new file mode 100644 index 0000000..bb5b310 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/octant.rs @@ -0,0 +1,74 @@ +//! A simple octant struct for transforming line points. + +use Point; +use std::ops::{Neg, Sub}; +use num_traits::Zero; + +/// A simple octant struct for transforming line points. +pub struct Octant { + value: u8, +} + +impl Octant { + #[inline] + /// Get the relevant octant from a start and end point. + pub fn new(start: Point, end: Point) -> Self + where + T: Sub + Neg + PartialOrd + Zero, + { + let mut value = 0; + let mut dx = end.0 - start.0; + let mut dy = end.1 - start.1; + + if dy < T::zero() { + dx = -dx; + dy = -dy; + value += 4; + } + + if dx < T::zero() { + let tmp = dx; + dx = dy; + dy = -tmp; + value += 2 + } + + if dx < dy { + value += 1 + } + + Self { value } + } + + /// Convert a point to its position in the octant. + #[inline] + pub fn to>(&self, point: Point) -> Point { + match self.value { + 0 => (point.0, point.1), + 1 => (point.1, point.0), + 2 => (point.1, -point.0), + 3 => (-point.0, point.1), + 4 => (-point.0, -point.1), + 5 => (-point.1, -point.0), + 6 => (-point.1, point.0), + 7 => (point.0, -point.1), + _ => unreachable!(), + } + } + + /// Convert a point from its position in the octant. + #[inline] + pub fn from>(&self, point: Point) -> Point { + match self.value { + 0 => (point.0, point.1), + 1 => (point.1, point.0), + 2 => (-point.1, point.0), + 3 => (-point.0, point.1), + 4 => (-point.0, -point.1), + 5 => (-point.1, -point.0), + 6 => (point.1, -point.0), + 7 => (point.0, -point.1), + _ => unreachable!(), + } + } +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/steps.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/steps.rs new file mode 100644 index 0000000..0576fc0 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/steps.rs @@ -0,0 +1,78 @@ +//! An iterator that returns `(start, end)` tuples from the walk. + +/// An iterator that returns `(start, end)` tuples from the walk. +/// +/// All the algorithms in this crate should have a `steps()` function associated with them to turn +/// them into a [`Steps`] iterator. +/// +/// Example using [`WalkGrid`]: +/// +/// ``` +/// extern crate line_drawing; +/// use line_drawing::WalkGrid; +/// +/// fn main() { +/// for (start, end) in WalkGrid::new((0, 0), (5, 3)).steps() { +/// println!("{:?} -> {:?}", start, end); +/// } +/// } +/// ``` +/// +/// ```text +/// (0, 0) -> (1, 0) +/// (1, 0) -> (1, 1) +/// (1, 1) -> (2, 1) +/// (2, 1) -> (2, 2) +/// (2, 2) -> (3, 2) +/// (3, 2) -> (4, 2) +/// (4, 2) -> (4, 3) +/// (4, 3) -> (5, 3) +/// ``` +/// +/// [`Steps`]: struct.Steps.html +/// [`WalkGrid`]: ../struct.WalkGrid.html +pub struct Steps { + iterator: I, + prev: Option, +} + +impl> Steps { + #[inline] + pub fn new(mut iterator: I) -> Self { + Self { + prev: iterator.next(), + iterator, + } + } +} + +impl> Iterator for Steps { + type Item = (T, T); + + #[inline] + fn next(&mut self) -> Option { + self.iterator.next().and_then(|next| { + self.prev.map(|prev| { + self.prev = Some(next); + (prev, next) + }) + }) + } +} + +#[test] +fn steps() { + use Midpoint; + + assert_eq!( + Midpoint::new((0.0, 0.0), (3.0, 4.0)) + .steps() + .collect::>(), + [ + ((0, 0), (1, 1)), + ((1, 1), (2, 2)), + ((2, 2), (2, 3)), + ((2, 3), (3, 4)) + ] + ); +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/walk_voxels.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/walk_voxels.rs new file mode 100644 index 0000000..473164a --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/walk_voxels.rs @@ -0,0 +1,207 @@ +use {FloatNum, SignedNum, Voxel}; +use steps::Steps; + +#[inline] +fn compare(a: T, b: T) -> T { + if a > b { + T::one() + } else if a == b { + T::zero() + } else { + -T::one() + } +} + +/// Where the center of the voxel is, at the center or a corner. +/// +/// Generally you want `Center`. +pub enum VoxelOrigin { + Corner, + Center, +} + +impl VoxelOrigin { + #[inline] + /// Round a voxel's position based on the origin. + pub fn round(&self, voxel: Voxel) -> Voxel { + let (x, y, z) = match *self { + VoxelOrigin::Corner => voxel, + VoxelOrigin::Center => (voxel.0.round(), voxel.1.round(), voxel.2.round()), + }; + + (O::cast(x), O::cast(y), O::cast(z)) + } +} + +/// Walk between two voxels, taking orthogonal steps and visiting all voxels in between. +/// +/// Implemented from [this Stack Overflow answer]. +/// This algorithm takes floating-point numbers as input and should be symmetrical. +/// +/// Example: +/// +/// ``` +/// extern crate line_drawing; +/// use line_drawing::{VoxelOrigin, WalkVoxels}; +/// +/// fn main() { +/// let a = (0.0, 0.0, 0.0); +/// let b = (5.0, 6.0, 7.0); +/// +/// for (i, (x, y, z)) in WalkVoxels::::new(a, b, &VoxelOrigin::Center).enumerate() { +/// if i > 0 && i % 5 == 0 { +/// println!(); +/// } +/// print!("({}, {}, {}), ", x, y, z); +/// } +/// } +/// ``` +/// +/// ```text +/// (0, 0, 0), (0, 0, 1), (0, 1, 1), (1, 1, 1), (1, 1, 2), +/// (1, 2, 2), (2, 2, 2), (2, 2, 3), (2, 3, 3), (2, 3, 4), +/// (3, 3, 4), (3, 4, 4), (3, 4, 5), (4, 4, 5), (4, 5, 5), +/// (4, 5, 6), (4, 5, 7), (4, 6, 7), (5, 6, 7), +/// ``` +/// +/// [this Stack Overflow answer]: https://stackoverflow.com/a/16507714 +pub struct WalkVoxels { + voxel: Voxel, + count: O, + sign_x: O, + sign_y: O, + sign_z: O, + err_x: I, + err_y: I, + err_z: I, + d_err_x: I, + d_err_y: I, + d_err_z: I, +} + +impl WalkVoxels { + #[inline] + /// Create a new `WalkVoxels` iterator, with the origin of the voxels. + pub fn new(start: Voxel, end: Voxel, origin: &VoxelOrigin) -> Self { + let start_i: Voxel = origin.round(start); + let end_i: Voxel = origin.round(end); + + let count = + (start_i.0 - end_i.0).abs() + (start_i.1 - end_i.1).abs() + (start_i.2 - end_i.2).abs(); + + let sign_x = compare(end_i.0, start_i.0); + let sign_y = compare(end_i.1, start_i.1); + let sign_z = compare(end_i.2, start_i.2); + + // Planes for each axis that we will next cross + let x_plane = start_i.0 + (if end_i.0 > start_i.0 { + O::one() + } else { + O::zero() + }); + let y_plane = start_i.1 + (if end_i.1 > start_i.1 { + O::one() + } else { + O::zero() + }); + let z_plane = start_i.2 + (if end_i.2 > start_i.2 { + O::one() + } else { + O::zero() + }); + + // Only used for multiplying up the error margins + let vx = if start.0 == end.0 { + I::one() + } else { + end.0 - start.0 + }; + let vy = if start.1 == end.1 { + I::one() + } else { + end.1 - start.1 + }; + let vz = if start.2 == end.2 { + I::one() + } else { + end.2 - start.2 + }; + + // Error is normalized to vx * vy * vz so we only have to multiply up + let vxvy = vx * vy; + let vxvz = vx * vz; + let vyvz = vy * vz; + + Self { + sign_x, + sign_y, + sign_z, + count, + voxel: start_i, + // Error from the next plane accumulators, scaled up by vx * vy * vz + // gx0 + vx * rx === gxp + // vx * rx === gxp - gx0 + // rx === (gxp - gx0) / vx + err_x: (I::cast(x_plane) - start.0) * vyvz, + err_y: (I::cast(y_plane) - start.1) * vxvz, + err_z: (I::cast(z_plane) - start.2) * vxvy, + d_err_x: I::cast(sign_x) * vyvz, + d_err_y: I::cast(sign_y) * vxvz, + d_err_z: I::cast(sign_z) * vxvy, + } + } + + #[inline] + pub fn steps(self) -> Steps, Self> { + Steps::new(self) + } +} + +impl Iterator for WalkVoxels { + type Item = Voxel; + + #[inline] + fn next(&mut self) -> Option { + if self.count >= O::zero() { + self.count -= O::one(); + + // Which plane do we cross first? + let xr = self.err_x.abs(); + let yr = self.err_y.abs(); + let zr = self.err_z.abs(); + + let x_zero = self.sign_x == O::zero(); + let y_zero = self.sign_y == O::zero(); + let z_zero = self.sign_z == O::zero(); + + let voxel = self.voxel; + + if !x_zero && (y_zero || xr < yr) && (z_zero || xr < zr) { + self.voxel.0 += self.sign_x; + self.err_x += self.d_err_x; + } else if !y_zero && (z_zero || yr < zr) { + self.voxel.1 += self.sign_y; + self.err_y += self.d_err_y; + } else if !z_zero { + self.voxel.2 += self.sign_z; + self.err_z += self.d_err_z; + } + + Some(voxel) + } else { + None + } + } +} + +#[test] +fn tests() { + assert_eq!( + WalkVoxels::new( + (0.472, -1.100, 0.179), + (1.114, -0.391, 0.927), + &VoxelOrigin::Center + ).collect::>(), + [(0, -1, 0), (1, -1, 0), (1, -1, 1), (1, 0, 1)] + ); +} diff --git a/third_party/cargo/vendor/line_drawing-0.7.0/src/xiaolin_wu.rs b/third_party/cargo/vendor/line_drawing-0.7.0/src/xiaolin_wu.rs new file mode 100644 index 0000000..1742710 --- /dev/null +++ b/third_party/cargo/vendor/line_drawing-0.7.0/src/xiaolin_wu.rs @@ -0,0 +1,144 @@ +use {FloatNum, Point, SignedNum}; +use steps::Steps; +use std::mem::swap; + +/// An implementation of [Xiaolin Wu's line algorithm]. +/// +/// This algorithm works based on floating-points and returns an extra variable for how much a +/// a point is covered, which is useful for anti-aliasing. +/// +/// Note that due to the implementation, the returned line will always go from left to right. +/// +/// Example: +/// +/// ``` +/// extern crate line_drawing; +/// use line_drawing::XiaolinWu; +/// +/// fn main() { +/// for ((x, y), value) in XiaolinWu::::new((0.0, 0.0), (3.0, 6.0)) { +/// print!("(({}, {}), {}), ", x, y, value); +/// } +/// } +/// ``` +/// +/// ```text +/// ((0, 0), 0.5), ((0, 1), 0.5), ((1, 1), 0.5), ((1, 2), 1), ((1, 3), 0.5), ((2, 3), 0.5), ((2, 4), 1), ((2, 5), 0.5), ((3, 5), 0.5), ((3, 6), 0.5), +/// ``` +/// +/// [Xiaolin Wu's line algorithm]: https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm +pub struct XiaolinWu { + steep: bool, + gradient: I, + x: O, + y: I, + end_x: O, + lower: bool, +} + +impl XiaolinWu { + #[inline] + pub fn new(mut start: Point, mut end: Point) -> Self { + let steep = (end.1 - start.1).abs() > (end.0 - start.0).abs(); + + if steep { + start = (start.1, start.0); + end = (end.1, end.0); + } + + if start.0 > end.0 { + swap(&mut start, &mut end); + } + + let mut gradient = (end.1 - start.1) / (end.0 - start.0); + + if gradient == I::zero() { + gradient = I::one(); + } + + Self { + steep, + gradient, + x: O::cast(start.0.round()), + y: start.1, + end_x: O::cast(end.0.round()), + lower: false, + } + } + + #[inline] + pub fn steps(self) -> Steps<(Point, I), Self> { + Steps::new(self) + } +} + +impl Iterator for XiaolinWu { + type Item = (Point, I); + + #[inline] + fn next(&mut self) -> Option { + if self.x <= self.end_x { + // get the fractional part of y + let fpart = self.y - self.y.floor(); + + // Calculate the integer value of y + let mut y = O::cast(self.y); + if self.lower { + y += O::one(); + } + + // Get the point + let point = if self.steep { (y, self.x) } else { (self.x, y) }; + + if self.lower { + // Return the lower point + self.lower = false; + self.x += O::one(); + self.y += self.gradient; + Some((point, fpart)) + } else { + if fpart > I::zero() { + // Set to return the lower point if the fractional part is > 0 + self.lower = true; + } else { + // Otherwise move on + self.x += O::one(); + self.y += self.gradient; + } + + // Return the remainer of the fractional part + Some((point, I::one() - fpart)) + } + } else { + None + } + } +} + +#[test] +fn tests() { + let xiaolin_wu = |a, b| XiaolinWu::new(a, b).collect::>(); + + assert_eq!( + xiaolin_wu((0.0, 0.0), (6.0, 3.0)), + [ + ((0, 0), 1.0), + ((1, 0), 0.5), + ((1, 1), 0.5), + ((2, 1), 1.0), + ((3, 1), 0.5), + ((3, 2), 0.5), + ((4, 2), 1.0), + ((5, 2), 0.5), + ((5, 3), 0.5), + ((6, 3), 1.0) + ] + ); + + // The algorithm reorders the points to be left-to-right + + assert_eq!( + xiaolin_wu((340.5, 290.77), (110.0, 170.0)), + xiaolin_wu((110.0, 170.0), (340.5, 290.77)) + ); +} diff --git a/third_party/cargo/vendor/lock_api-0.1.5/.cargo-checksum.json b/third_party/cargo/vendor/lock_api-0.1.5/.cargo-checksum.json new file mode 100644 index 0000000..b8be5a0 --- /dev/null +++ b/third_party/cargo/vendor/lock_api-0.1.5/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"ab2a7a96105e15de46900fb0da37edbab44e5513a9818672153dae44ed318f7e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","src/lib.rs":"4a16128f58e3380b22b26b137ee1096732995b7e401f3d227dd7b0738b6bd604","src/mutex.rs":"fee397f72325621812c5f78c7a6b9369ea7ec14e71bb0049678a50349519c0c7","src/remutex.rs":"ed76d7b93a56b6248d79676de2aaa66b607b64f1b773c9dd7326b8324e2bc71a","src/rwlock.rs":"5ab1aab614358cfdaf23e8ff8a0ac5e0c7656b777f385aca2e5422f0aa8f0985"},"package":"62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"} \ No newline at end of file diff --git a/third_party/cargo/vendor/lock_api-0.1.5/BUILD b/third_party/cargo/vendor/lock_api-0.1.5/BUILD new file mode 100644 index 0000000..896b855 --- /dev/null +++ b/third_party/cargo/vendor/lock_api-0.1.5/BUILD @@ -0,0 +1,45 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0,MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "lock_api", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/owning_ref-0.4.0:owning_ref", + "//third_party/cargo/vendor/scopeguard-0.3.3:scopeguard", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.5", + crate_features = [ + "owning_ref", + ], +) + diff --git a/third_party/cargo/vendor/lock_api-0.1.5/Cargo.toml b/third_party/cargo/vendor/lock_api-0.1.5/Cargo.toml new file mode 100644 index 0000000..ee39d85 --- /dev/null +++ b/third_party/cargo/vendor/lock_api-0.1.5/Cargo.toml @@ -0,0 +1,31 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "lock_api" +version = "0.1.5" +authors = ["Amanieu d'Antras "] +description = "Wrappers to create fully-featured Mutex and RwLock types. Compatible with no_std." +keywords = ["mutex", "rwlock", "lock", "no_std"] +categories = ["concurrency", "no-std"] +license = "Apache-2.0/MIT" +repository = "https://github.com/Amanieu/parking_lot" +[dependencies.owning_ref] +version = "0.4" +optional = true + +[dependencies.scopeguard] +version = "0.3" +default-features = false + +[features] +nightly = [] diff --git a/third_party/cargo/vendor/lock_api-0.1.5/LICENSE-APACHE b/third_party/cargo/vendor/lock_api-0.1.5/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/lock_api-0.1.5/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/lock_api-0.1.5/LICENSE-MIT b/third_party/cargo/vendor/lock_api-0.1.5/LICENSE-MIT new file mode 100644 index 0000000..40b8817 --- /dev/null +++ b/third_party/cargo/vendor/lock_api-0.1.5/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/lock_api-0.1.5/src/lib.rs b/third_party/cargo/vendor/lock_api-0.1.5/src/lib.rs new file mode 100644 index 0000000..60271ed --- /dev/null +++ b/third_party/cargo/vendor/lock_api-0.1.5/src/lib.rs @@ -0,0 +1,109 @@ +// Copyright 2018 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +//! This library provides type-safe and fully-featured `Mutex` and `RwLock` +//! types which wrap a simple raw mutex or rwlock type. This has several +//! benefits: not only does it eliminate a large portion of the work in +//! implementing custom lock types, it also allows users to write code which is +//! generic with regards to different lock implementations. +//! +//! Basic usage of this crate is very straightforward: +//! +//! 1. Create a raw lock type. This should only contain the lock state, not any +//! data protected by the lock. +//! 2. Implement the `RawMutex` trait for your custom lock type. +//! 3. Export your mutex as a type alias for `lock_api::Mutex`, and +//! your mutex guard as a type alias for `lock_api::MutexGuard`. +//! See the [example](#example) below for details. +//! +//! This process is similar for RwLocks, except that two guards need to be +//! exported instead of one. (Or 3 guards if your type supports upgradable read +//! locks, see [extension traits](#extension-traits) below for details) +//! +//! # Example +//! +//! ``` +//! use lock_api::{RawMutex, Mutex, GuardSend}; +//! use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT}; +//! +//! // 1. Define our raw lock type +//! pub struct RawSpinlock(AtomicBool); +//! +//! // 2. Implement RawMutex for this type +//! unsafe impl RawMutex for RawSpinlock { +//! const INIT: RawSpinlock = RawSpinlock(ATOMIC_BOOL_INIT); +//! +//! // A spinlock guard can be sent to another thread and unlocked there +//! type GuardMarker = GuardSend; +//! +//! fn lock(&self) { +//! // Note: This isn't the best way of implementing a spinlock, but it +//! // suffices for the sake of this example. +//! while !self.try_lock() {} +//! } +//! +//! fn try_lock(&self) -> bool { +//! self.0.swap(true, Ordering::Acquire) +//! } +//! +//! fn unlock(&self) { +//! self.0.store(false, Ordering::Release); +//! } +//! } +//! +//! // 3. Export the wrappers. This are the types that your users will actually use. +//! pub type Spinlock = lock_api::Mutex; +//! pub type SpinlockGuard<'a, T> = lock_api::MutexGuard<'a, RawSpinlock, T>; +//! ``` +//! +//! # Extension traits +//! +//! In addition to basic locking & unlocking functionality, you have the option +//! of exposing additional functionality in your lock types by implementing +//! additional traits for it. Examples of extension features include: +//! +//! - Fair unlocking (`RawMutexFair`, `RawRwLockFair`) +//! - Lock timeouts (`RawMutexTimed`, `RawRwLockTimed`) +//! - Downgradable write locks (`RawRwLockDowngradable`) +//! - Recursive read locks (`RawRwLockRecursive`) +//! - Upgradable read locks (`RawRwLockUpgrade`) +//! +//! The `Mutex` and `RwLock` wrappers will automatically expose this additional +//! functionality if the raw lock type implements these extension traits. +//! +//! # Cargo features +//! +//! This crate supports two cargo features: +//! +//! - `owning_ref`: Allows your lock types to be used with the `owning_ref` crate. +//! - `nightly`: Enables nightly-only features. At the moment the only such +//! feature is `const fn` constructors for lock types. + +#![no_std] +#![warn(missing_docs)] +#![cfg_attr(feature = "nightly", feature(const_fn))] + +#[macro_use] +extern crate scopeguard; + +#[cfg(feature = "owning_ref")] +extern crate owning_ref; + +/// Marker type which indicates that the Guard type for a lock is `Send`. +pub struct GuardSend(()); + +/// Marker type which indicates that the Guard type for a lock is not `Send`. +pub struct GuardNoSend(*mut ()); + +mod mutex; +pub use mutex::*; + +mod remutex; +pub use remutex::*; + +mod rwlock; +pub use rwlock::*; diff --git a/third_party/cargo/vendor/lock_api-0.1.5/src/mutex.rs b/third_party/cargo/vendor/lock_api-0.1.5/src/mutex.rs new file mode 100644 index 0000000..b9cf49b --- /dev/null +++ b/third_party/cargo/vendor/lock_api-0.1.5/src/mutex.rs @@ -0,0 +1,550 @@ +// Copyright 2018 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use core::cell::UnsafeCell; +use core::fmt; +use core::marker::PhantomData; +use core::mem; +use core::ops::{Deref, DerefMut}; + +#[cfg(feature = "owning_ref")] +use owning_ref::StableAddress; + +/// Basic operations for a mutex. +/// +/// Types implementing this trait can be used by `Mutex` to form a safe and +/// fully-functioning mutex type. +/// +/// # Safety +/// +/// Implementations of this trait must ensure that the mutex is actually +/// exclusive: a lock can't be acquired while the mutex is already locked. +pub unsafe trait RawMutex { + /// Initial value for an unlocked mutex. + const INIT: Self; + + /// Marker type which determines whether a lock guard should be `Send`. Use + /// one of the `GuardSend` or `GuardNoSend` helper types here. + type GuardMarker; + + /// Acquires this mutex, blocking the current thread until it is able to do so. + fn lock(&self); + + /// Attempts to acquire this mutex without blocking. + fn try_lock(&self) -> bool; + + /// Unlocks this mutex. + fn unlock(&self); +} + +/// Additional methods for mutexes which support fair unlocking. +/// +/// Fair unlocking means that a lock is handed directly over to the next waiting +/// thread if there is one, without giving other threads the opportunity to +/// "steal" the lock in the meantime. This is typically slower than unfair +/// unlocking, but may be necessary in certain circumstances. +pub unsafe trait RawMutexFair: RawMutex { + /// Unlocks this mutex using a fair unlock protocol. + fn unlock_fair(&self); + + /// Temporarily yields the mutex to a waiting thread if there is one. + /// + /// This method is functionally equivalent to calling `unlock_fair` followed + /// by `lock`, however it can be much more efficient in the case where there + /// are no waiting threads. + fn bump(&self) { + self.unlock_fair(); + self.lock(); + } +} + +/// Additional methods for mutexes which support locking with timeouts. +/// +/// The `Duration` and `Instant` types are specified as associated types so that +/// this trait is usable even in `no_std` environments. +pub unsafe trait RawMutexTimed: RawMutex { + /// Duration type used for `try_lock_for`. + type Duration; + + /// Instant type used for `try_lock_until`. + type Instant; + + /// Attempts to acquire this lock until a timeout is reached. + fn try_lock_for(&self, timeout: Self::Duration) -> bool; + + /// Attempts to acquire this lock until a timeout is reached. + fn try_lock_until(&self, timeout: Self::Instant) -> bool; +} + +/// A mutual exclusion primitive useful for protecting shared data +/// +/// This mutex will block threads waiting for the lock to become available. The +/// mutex can also be statically initialized or created via a `new` +/// constructor. Each mutex has a type parameter which represents the data that +/// it is protecting. The data can only be accessed through the RAII guards +/// returned from `lock` and `try_lock`, which guarantees that the data is only +/// ever accessed when the mutex is locked. +pub struct Mutex { + raw: R, + data: UnsafeCell, +} + +unsafe impl Send for Mutex {} +unsafe impl Sync for Mutex {} + +impl Mutex { + /// Creates a new mutex in an unlocked state ready for use. + #[cfg(feature = "nightly")] + #[inline] + pub const fn new(val: T) -> Mutex { + Mutex { + data: UnsafeCell::new(val), + raw: R::INIT, + } + } + + /// Creates a new mutex in an unlocked state ready for use. + #[cfg(not(feature = "nightly"))] + #[inline] + pub fn new(val: T) -> Mutex { + Mutex { + data: UnsafeCell::new(val), + raw: R::INIT, + } + } + + /// Consumes this mutex, returning the underlying data. + #[inline] + #[allow(unused_unsafe)] + pub fn into_inner(self) -> T { + unsafe { self.data.into_inner() } + } +} + +impl Mutex { + #[inline] + fn guard(&self) -> MutexGuard { + MutexGuard { + mutex: self, + marker: PhantomData, + } + } + + /// Acquires a mutex, blocking the current thread until it is able to do so. + /// + /// This function will block the local thread until it is available to acquire + /// the mutex. Upon returning, the thread is the only thread with the mutex + /// held. An RAII guard is returned to allow scoped unlock of the lock. When + /// the guard goes out of scope, the mutex will be unlocked. + /// + /// Attempts to lock a mutex in the thread which already holds the lock will + /// result in a deadlock. + #[inline] + pub fn lock(&self) -> MutexGuard { + self.raw.lock(); + self.guard() + } + + /// Attempts to acquire this lock. + /// + /// If the lock could not be acquired at this time, then `None` is returned. + /// Otherwise, an RAII guard is returned. The lock will be unlocked when the + /// guard is dropped. + /// + /// This function does not block. + #[inline] + pub fn try_lock(&self) -> Option> { + if self.raw.try_lock() { + Some(self.guard()) + } else { + None + } + } + + /// Returns a mutable reference to the underlying data. + /// + /// Since this call borrows the `Mutex` mutably, no actual locking needs to + /// take place---the mutable borrow statically guarantees no locks exist. + #[inline] + pub fn get_mut(&mut self) -> &mut T { + unsafe { &mut *self.data.get() } + } + + /// Forcibly unlocks the mutex. + /// + /// This is useful when combined with `mem::forget` to hold a lock without + /// the need to maintain a `MutexGuard` object alive, for example when + /// dealing with FFI. + /// + /// # Safety + /// + /// This method must only be called if the current thread logically owns a + /// `MutexGuard` but that guard has be discarded using `mem::forget`. + /// Behavior is undefined if a mutex is unlocked when not locked. + #[inline] + pub unsafe fn force_unlock(&self) { + self.raw.unlock(); + } + + /// Returns the underlying raw mutex object. + /// + /// Note that you will most likely need to import the `RawMutex` trait from + /// `lock_api` to be able to call functions on the raw mutex. + /// + /// # Safety + /// + /// This method is unsafe because it allows unlocking a mutex while + /// still holding a reference to a `MutexGuard`. + #[inline] + pub unsafe fn raw(&self) -> &R { + &self.raw + } +} + +impl Mutex { + /// Forcibly unlocks the mutex using a fair unlock procotol. + /// + /// This is useful when combined with `mem::forget` to hold a lock without + /// the need to maintain a `MutexGuard` object alive, for example when + /// dealing with FFI. + /// + /// # Safety + /// + /// This method must only be called if the current thread logically owns a + /// `MutexGuard` but that guard has be discarded using `mem::forget`. + /// Behavior is undefined if a mutex is unlocked when not locked. + #[inline] + pub unsafe fn force_unlock_fair(&self) { + self.raw.unlock_fair(); + } +} + +impl Mutex { + /// Attempts to acquire this lock until a timeout is reached. + /// + /// If the lock could not be acquired before the timeout expired, then + /// `None` is returned. Otherwise, an RAII guard is returned. The lock will + /// be unlocked when the guard is dropped. + #[inline] + pub fn try_lock_for(&self, timeout: R::Duration) -> Option> { + if self.raw.try_lock_for(timeout) { + Some(self.guard()) + } else { + None + } + } + + /// Attempts to acquire this lock until a timeout is reached. + /// + /// If the lock could not be acquired before the timeout expired, then + /// `None` is returned. Otherwise, an RAII guard is returned. The lock will + /// be unlocked when the guard is dropped. + #[inline] + pub fn try_lock_until(&self, timeout: R::Instant) -> Option> { + if self.raw.try_lock_until(timeout) { + Some(self.guard()) + } else { + None + } + } +} + +impl Default for Mutex { + #[inline] + fn default() -> Mutex { + Mutex::new(Default::default()) + } +} + +impl From for Mutex { + #[inline] + fn from(t: T) -> Mutex { + Mutex::new(t) + } +} + +impl fmt::Debug for Mutex { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.try_lock() { + Some(guard) => f.debug_struct("Mutex").field("data", &&*guard).finish(), + None => f.pad("Mutex { }"), + } + } +} + +/// An RAII implementation of a "scoped lock" of a mutex. When this structure is +/// dropped (falls out of scope), the lock will be unlocked. +/// +/// The data protected by the mutex can be accessed through this guard via its +/// `Deref` and `DerefMut` implementations. +#[must_use] +pub struct MutexGuard<'a, R: RawMutex + 'a, T: ?Sized + 'a> { + mutex: &'a Mutex, + marker: PhantomData<(&'a mut T, R::GuardMarker)>, +} + +unsafe impl<'a, R: RawMutex + Sync + 'a, T: ?Sized + Sync + 'a> Sync for MutexGuard<'a, R, T> {} + +impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> MutexGuard<'a, R, T> { + /// Returns a reference to the original `Mutex` object. + pub fn mutex(s: &Self) -> &'a Mutex { + s.mutex + } + + /// Makes a new `MappedMutexGuard` for a component of the locked data. + /// + /// This operation cannot fail as the `MutexGuard` passed + /// in already locked the mutex. + /// + /// This is an associated function that needs to be + /// used as `MutexGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn map(s: Self, f: F) -> MappedMutexGuard<'a, R, U> + where + F: FnOnce(&mut T) -> &mut U, + { + let raw = &s.mutex.raw; + let data = f(unsafe { &mut *s.mutex.data.get() }); + mem::forget(s); + MappedMutexGuard { + raw, + data, + marker: PhantomData, + } + } + + /// Attempts to make a new `MappedMutexGuard` for a component of the + /// locked data. The original guard is return if the closure returns `None`. + /// + /// This operation cannot fail as the `MutexGuard` passed + /// in already locked the mutex. + /// + /// This is an associated function that needs to be + /// used as `MutexGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn try_map(s: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + { + let raw = &s.mutex.raw; + let data = match f(unsafe { &mut *s.mutex.data.get() }) { + Some(data) => data, + None => return Err(s), + }; + mem::forget(s); + Ok(MappedMutexGuard { + raw, + data, + marker: PhantomData, + }) + } + + /// Temporarily unlocks the mutex to execute the given function. + /// + /// This is safe because `&mut` guarantees that there exist no other + /// references to the data protected by the mutex. + #[inline] + pub fn unlocked(s: &mut Self, f: F) -> U + where + F: FnOnce() -> U, + { + s.mutex.raw.unlock(); + defer!(s.mutex.raw.lock()); + f() + } +} + +impl<'a, R: RawMutexFair + 'a, T: ?Sized + 'a> MutexGuard<'a, R, T> { + /// Unlocks the mutex using a fair unlock protocol. + /// + /// By default, mutexes are unfair and allow the current thread to re-lock + /// the mutex before another has the chance to acquire the lock, even if + /// that thread has been blocked on the mutex for a long time. This is the + /// default because it allows much higher throughput as it avoids forcing a + /// context switch on every mutex unlock. This can result in one thread + /// acquiring a mutex many more times than other threads. + /// + /// However in some cases it can be beneficial to ensure fairness by forcing + /// the lock to pass on to a waiting thread if there is one. This is done by + /// using this method instead of dropping the `MutexGuard` normally. + #[inline] + pub fn unlock_fair(s: Self) { + s.mutex.raw.unlock_fair(); + mem::forget(s); + } + + /// Temporarily unlocks the mutex to execute the given function. + /// + /// The mutex is unlocked a fair unlock protocol. + /// + /// This is safe because `&mut` guarantees that there exist no other + /// references to the data protected by the mutex. + #[inline] + pub fn unlocked_fair(s: &mut Self, f: F) -> U + where + F: FnOnce() -> U, + { + s.mutex.raw.unlock_fair(); + defer!(s.mutex.raw.lock()); + f() + } + + /// Temporarily yields the mutex to a waiting thread if there is one. + /// + /// This method is functionally equivalent to calling `unlock_fair` followed + /// by `lock`, however it can be much more efficient in the case where there + /// are no waiting threads. + #[inline] + pub fn bump(s: &mut Self) { + s.mutex.raw.bump(); + } +} + +impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> Deref for MutexGuard<'a, R, T> { + type Target = T; + #[inline] + fn deref(&self) -> &T { + unsafe { &*self.mutex.data.get() } + } +} + +impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> DerefMut for MutexGuard<'a, R, T> { + #[inline] + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *self.mutex.data.get() } + } +} + +impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> Drop for MutexGuard<'a, R, T> { + #[inline] + fn drop(&mut self) { + self.mutex.raw.unlock(); + } +} + +#[cfg(feature = "owning_ref")] +unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> StableAddress for MutexGuard<'a, R, T> {} + +/// An RAII mutex guard returned by `MutexGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedMutexGuard` and `MutexGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +#[must_use] +pub struct MappedMutexGuard<'a, R: RawMutex + 'a, T: ?Sized + 'a> { + raw: &'a R, + data: *mut T, + marker: PhantomData<&'a mut T>, +} + +unsafe impl<'a, R: RawMutex + Sync + 'a, T: ?Sized + Sync + 'a> Sync + for MappedMutexGuard<'a, R, T> +{} +unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> Send for MappedMutexGuard<'a, R, T> where + R::GuardMarker: Send +{} + +impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> MappedMutexGuard<'a, R, T> { + /// Makes a new `MappedMutexGuard` for a component of the locked data. + /// + /// This operation cannot fail as the `MappedMutexGuard` passed + /// in already locked the mutex. + /// + /// This is an associated function that needs to be + /// used as `MappedMutexGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn map(s: Self, f: F) -> MappedMutexGuard<'a, R, U> + where + F: FnOnce(&mut T) -> &mut U, + { + let raw = s.raw; + let data = f(unsafe { &mut *s.data }); + mem::forget(s); + MappedMutexGuard { + raw, + data, + marker: PhantomData, + } + } + + /// Attempts to make a new `MappedMutexGuard` for a component of the + /// locked data. The original guard is return if the closure returns `None`. + /// + /// This operation cannot fail as the `MappedMutexGuard` passed + /// in already locked the mutex. + /// + /// This is an associated function that needs to be + /// used as `MappedMutexGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn try_map(s: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + { + let raw = s.raw; + let data = match f(unsafe { &mut *s.data }) { + Some(data) => data, + None => return Err(s), + }; + mem::forget(s); + Ok(MappedMutexGuard { + raw, + data, + marker: PhantomData, + }) + } +} + +impl<'a, R: RawMutexFair + 'a, T: ?Sized + 'a> MappedMutexGuard<'a, R, T> { + /// Unlocks the mutex using a fair unlock protocol. + /// + /// By default, mutexes are unfair and allow the current thread to re-lock + /// the mutex before another has the chance to acquire the lock, even if + /// that thread has been blocked on the mutex for a long time. This is the + /// default because it allows much higher throughput as it avoids forcing a + /// context switch on every mutex unlock. This can result in one thread + /// acquiring a mutex many more times than other threads. + /// + /// However in some cases it can be beneficial to ensure fairness by forcing + /// the lock to pass on to a waiting thread if there is one. This is done by + /// using this method instead of dropping the `MutexGuard` normally. + #[inline] + pub fn unlock_fair(s: Self) { + s.raw.unlock_fair(); + mem::forget(s); + } +} + +impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> Deref for MappedMutexGuard<'a, R, T> { + type Target = T; + #[inline] + fn deref(&self) -> &T { + unsafe { &*self.data } + } +} + +impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> DerefMut for MappedMutexGuard<'a, R, T> { + #[inline] + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *self.data } + } +} + +impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> Drop for MappedMutexGuard<'a, R, T> { + #[inline] + fn drop(&mut self) { + self.raw.unlock(); + } +} + +#[cfg(feature = "owning_ref")] +unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> StableAddress for MappedMutexGuard<'a, R, T> {} diff --git a/third_party/cargo/vendor/lock_api-0.1.5/src/remutex.rs b/third_party/cargo/vendor/lock_api-0.1.5/src/remutex.rs new file mode 100644 index 0000000..3db9f51 --- /dev/null +++ b/third_party/cargo/vendor/lock_api-0.1.5/src/remutex.rs @@ -0,0 +1,618 @@ +// Copyright 2018 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use core::cell::{Cell, UnsafeCell}; +use core::fmt; +use core::marker::PhantomData; +use core::mem; +use core::ops::Deref; +use core::sync::atomic::{AtomicUsize, Ordering}; +use mutex::{RawMutex, RawMutexFair, RawMutexTimed}; +use GuardNoSend; + +#[cfg(feature = "owning_ref")] +use owning_ref::StableAddress; + +/// Helper trait which returns a non-zero thread ID. +/// +/// The simplest way to implement this trait is to return the address of a +/// thread-local variable. +/// +/// # Safety +/// +/// Implementations of this trait must ensure that no two active threads share +/// the same thread ID. However the ID of a thread that has exited can be +/// re-used since that thread is no longer active. +pub unsafe trait GetThreadId { + /// Initial value. + const INIT: Self; + + /// Returns a non-zero thread ID which identifies the current thread of + /// execution. + fn nonzero_thread_id(&self) -> usize; +} + +struct RawReentrantMutex { + owner: AtomicUsize, + lock_count: Cell, + mutex: R, + get_thread_id: G, +} + +impl RawReentrantMutex { + #[inline] + fn lock_internal bool>(&self, try_lock: F) -> bool { + let id = self.get_thread_id.nonzero_thread_id(); + if self.owner.load(Ordering::Relaxed) == id { + self.lock_count.set( + self.lock_count + .get() + .checked_add(1) + .expect("ReentrantMutex lock count overflow"), + ); + } else { + if !try_lock() { + return false; + } + self.owner.store(id, Ordering::Relaxed); + self.lock_count.set(1); + } + true + } + + #[inline] + fn lock(&self) { + self.lock_internal(|| { + self.mutex.lock(); + true + }); + } + + #[inline] + fn try_lock(&self) -> bool { + self.lock_internal(|| self.mutex.try_lock()) + } + + #[inline] + fn unlock(&self) { + let lock_count = self.lock_count.get() - 1; + if lock_count == 0 { + self.owner.store(0, Ordering::Relaxed); + self.mutex.unlock(); + } else { + self.lock_count.set(lock_count); + } + } +} + +impl RawReentrantMutex { + #[inline] + fn unlock_fair(&self) { + let lock_count = self.lock_count.get() - 1; + if lock_count == 0 { + self.owner.store(0, Ordering::Relaxed); + self.mutex.unlock_fair(); + } else { + self.lock_count.set(lock_count); + } + } + + #[inline] + fn bump(&self) { + if self.lock_count.get() == 1 { + let id = self.owner.load(Ordering::Relaxed); + self.owner.store(0, Ordering::Relaxed); + self.mutex.bump(); + self.owner.store(id, Ordering::Relaxed); + } + } +} + +impl RawReentrantMutex { + #[inline] + fn try_lock_until(&self, timeout: R::Instant) -> bool { + self.lock_internal(|| self.mutex.try_lock_until(timeout)) + } + + #[inline] + fn try_lock_for(&self, timeout: R::Duration) -> bool { + self.lock_internal(|| self.mutex.try_lock_for(timeout)) + } +} + +/// A mutex which can be recursively locked by a single thread. +/// +/// This type is identical to `Mutex` except for the following points: +/// +/// - Locking multiple times from the same thread will work correctly instead of +/// deadlocking. +/// - `ReentrantMutexGuard` does not give mutable references to the locked data. +/// Use a `RefCell` if you need this. +/// +/// See [`Mutex`](struct.Mutex.html) for more details about the underlying mutex +/// primitive. +pub struct ReentrantMutex { + raw: RawReentrantMutex, + data: UnsafeCell, +} + +unsafe impl Send + for ReentrantMutex +{} +unsafe impl Sync + for ReentrantMutex +{} + +impl ReentrantMutex { + /// Creates a new reentrant mutex in an unlocked state ready for use. + #[cfg(feature = "nightly")] + #[inline] + pub const fn new(val: T) -> ReentrantMutex { + ReentrantMutex { + data: UnsafeCell::new(val), + raw: RawReentrantMutex { + owner: AtomicUsize::new(0), + lock_count: Cell::new(0), + mutex: R::INIT, + get_thread_id: G::INIT, + }, + } + } + + /// Creates a new reentrant mutex in an unlocked state ready for use. + #[cfg(not(feature = "nightly"))] + #[inline] + pub fn new(val: T) -> ReentrantMutex { + ReentrantMutex { + data: UnsafeCell::new(val), + raw: RawReentrantMutex { + owner: AtomicUsize::new(0), + lock_count: Cell::new(0), + mutex: R::INIT, + get_thread_id: G::INIT, + }, + } + } + + /// Consumes this mutex, returning the underlying data. + #[inline] + #[allow(unused_unsafe)] + pub fn into_inner(self) -> T { + unsafe { self.data.into_inner() } + } +} + +impl ReentrantMutex { + #[inline] + fn guard(&self) -> ReentrantMutexGuard { + ReentrantMutexGuard { + remutex: &self, + marker: PhantomData, + } + } + + /// Acquires a reentrant mutex, blocking the current thread until it is able + /// to do so. + /// + /// If the mutex is held by another thread then this function will block the + /// local thread until it is available to acquire the mutex. If the mutex is + /// already held by the current thread then this function will increment the + /// lock reference count and return immediately. Upon returning, + /// the thread is the only thread with the mutex held. An RAII guard is + /// returned to allow scoped unlock of the lock. When the guard goes out of + /// scope, the mutex will be unlocked. + #[inline] + pub fn lock(&self) -> ReentrantMutexGuard { + self.raw.lock(); + self.guard() + } + + /// Attempts to acquire this lock. + /// + /// If the lock could not be acquired at this time, then `None` is returned. + /// Otherwise, an RAII guard is returned. The lock will be unlocked when the + /// guard is dropped. + /// + /// This function does not block. + #[inline] + pub fn try_lock(&self) -> Option> { + if self.raw.try_lock() { + Some(self.guard()) + } else { + None + } + } + + /// Returns a mutable reference to the underlying data. + /// + /// Since this call borrows the `ReentrantMutex` mutably, no actual locking needs to + /// take place---the mutable borrow statically guarantees no locks exist. + #[inline] + pub fn get_mut(&mut self) -> &mut T { + unsafe { &mut *self.data.get() } + } + + /// Forcibly unlocks the mutex. + /// + /// This is useful when combined with `mem::forget` to hold a lock without + /// the need to maintain a `ReentrantMutexGuard` object alive, for example when + /// dealing with FFI. + /// + /// # Safety + /// + /// This method must only be called if the current thread logically owns a + /// `ReentrantMutexGuard` but that guard has be discarded using `mem::forget`. + /// Behavior is undefined if a mutex is unlocked when not locked. + #[inline] + pub unsafe fn force_unlock(&self) { + self.raw.unlock(); + } + + /// Returns the underlying raw mutex object. + /// + /// Note that you will most likely need to import the `RawMutex` trait from + /// `lock_api` to be able to call functions on the raw mutex. + /// + /// # Safety + /// + /// This method is unsafe because it allows unlocking a mutex while + /// still holding a reference to a `ReentrantMutexGuard`. + #[inline] + pub unsafe fn raw(&self) -> &R { + &self.raw.mutex + } +} + +impl ReentrantMutex { + /// Forcibly unlocks the mutex using a fair unlock protocol. + /// + /// This is useful when combined with `mem::forget` to hold a lock without + /// the need to maintain a `ReentrantMutexGuard` object alive, for example when + /// dealing with FFI. + /// + /// # Safety + /// + /// This method must only be called if the current thread logically owns a + /// `ReentrantMutexGuard` but that guard has be discarded using `mem::forget`. + /// Behavior is undefined if a mutex is unlocked when not locked. + #[inline] + pub unsafe fn force_unlock_fair(&self) { + self.raw.unlock_fair(); + } +} + +impl ReentrantMutex { + /// Attempts to acquire this lock until a timeout is reached. + /// + /// If the lock could not be acquired before the timeout expired, then + /// `None` is returned. Otherwise, an RAII guard is returned. The lock will + /// be unlocked when the guard is dropped. + #[inline] + pub fn try_lock_for(&self, timeout: R::Duration) -> Option> { + if self.raw.try_lock_for(timeout) { + Some(self.guard()) + } else { + None + } + } + + /// Attempts to acquire this lock until a timeout is reached. + /// + /// If the lock could not be acquired before the timeout expired, then + /// `None` is returned. Otherwise, an RAII guard is returned. The lock will + /// be unlocked when the guard is dropped. + #[inline] + pub fn try_lock_until(&self, timeout: R::Instant) -> Option> { + if self.raw.try_lock_until(timeout) { + Some(self.guard()) + } else { + None + } + } +} + +impl Default for ReentrantMutex { + #[inline] + fn default() -> ReentrantMutex { + ReentrantMutex::new(Default::default()) + } +} + +impl From for ReentrantMutex { + #[inline] + fn from(t: T) -> ReentrantMutex { + ReentrantMutex::new(t) + } +} + +impl fmt::Debug for ReentrantMutex { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.try_lock() { + Some(guard) => f + .debug_struct("ReentrantMutex") + .field("data", &&*guard) + .finish(), + None => f.pad("ReentrantMutex { }"), + } + } +} + +/// An RAII implementation of a "scoped lock" of a reentrant mutex. When this structure +/// is dropped (falls out of scope), the lock will be unlocked. +/// +/// The data protected by the mutex can be accessed through this guard via its +/// `Deref` implementation. +#[must_use] +pub struct ReentrantMutexGuard<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> { + remutex: &'a ReentrantMutex, + marker: PhantomData<(&'a T, GuardNoSend)>, +} + +unsafe impl<'a, R: RawMutex + Sync + 'a, G: GetThreadId + Sync + 'a, T: ?Sized + Sync + 'a> Sync + for ReentrantMutexGuard<'a, R, G, T> +{} + +impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> ReentrantMutexGuard<'a, R, G, T> { + /// Returns a reference to the original `ReentrantMutex` object. + pub fn remutex(s: &Self) -> &'a ReentrantMutex { + s.remutex + } + + /// Makes a new `MappedReentrantMutexGuard` for a component of the locked data. + /// + /// This operation cannot fail as the `ReentrantMutexGuard` passed + /// in already locked the mutex. + /// + /// This is an associated function that needs to be + /// used as `ReentrantMutexGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn map(s: Self, f: F) -> MappedReentrantMutexGuard<'a, R, G, U> + where + F: FnOnce(&T) -> &U, + { + let raw = &s.remutex.raw; + let data = f(unsafe { &*s.remutex.data.get() }); + mem::forget(s); + MappedReentrantMutexGuard { + raw, + data, + marker: PhantomData, + } + } + + /// Attempts to make a new `MappedReentrantMutexGuard` for a component of the + /// locked data. The original guard is return if the closure returns `None`. + /// + /// This operation cannot fail as the `ReentrantMutexGuard` passed + /// in already locked the mutex. + /// + /// This is an associated function that needs to be + /// used as `ReentrantMutexGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn try_map(s: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + { + let raw = &s.remutex.raw; + let data = match f(unsafe { &mut *s.remutex.data.get() }) { + Some(data) => data, + None => return Err(s), + }; + mem::forget(s); + Ok(MappedReentrantMutexGuard { + raw, + data, + marker: PhantomData, + }) + } + + /// Temporarily unlocks the mutex to execute the given function. + /// + /// This is safe because `&mut` guarantees that there exist no other + /// references to the data protected by the mutex. + #[inline] + pub fn unlocked(s: &mut Self, f: F) -> U + where + F: FnOnce() -> U, + { + s.remutex.raw.unlock(); + defer!(s.remutex.raw.lock()); + f() + } +} + +impl<'a, R: RawMutexFair + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> + ReentrantMutexGuard<'a, R, G, T> +{ + /// Unlocks the mutex using a fair unlock protocol. + /// + /// By default, mutexes are unfair and allow the current thread to re-lock + /// the mutex before another has the chance to acquire the lock, even if + /// that thread has been blocked on the mutex for a long time. This is the + /// default because it allows much higher throughput as it avoids forcing a + /// context switch on every mutex unlock. This can result in one thread + /// acquiring a mutex many more times than other threads. + /// + /// However in some cases it can be beneficial to ensure fairness by forcing + /// the lock to pass on to a waiting thread if there is one. This is done by + /// using this method instead of dropping the `ReentrantMutexGuard` normally. + #[inline] + pub fn unlock_fair(s: Self) { + s.remutex.raw.unlock_fair(); + mem::forget(s); + } + + /// Temporarily unlocks the mutex to execute the given function. + /// + /// The mutex is unlocked a fair unlock protocol. + /// + /// This is safe because `&mut` guarantees that there exist no other + /// references to the data protected by the mutex. + #[inline] + pub fn unlocked_fair(s: &mut Self, f: F) -> U + where + F: FnOnce() -> U, + { + s.remutex.raw.unlock_fair(); + defer!(s.remutex.raw.lock()); + f() + } + + /// Temporarily yields the mutex to a waiting thread if there is one. + /// + /// This method is functionally equivalent to calling `unlock_fair` followed + /// by `lock`, however it can be much more efficient in the case where there + /// are no waiting threads. + #[inline] + pub fn bump(s: &mut Self) { + s.remutex.raw.bump(); + } +} + +impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> Deref + for ReentrantMutexGuard<'a, R, G, T> +{ + type Target = T; + #[inline] + fn deref(&self) -> &T { + unsafe { &*self.remutex.data.get() } + } +} + +impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> Drop + for ReentrantMutexGuard<'a, R, G, T> +{ + #[inline] + fn drop(&mut self) { + self.remutex.raw.unlock(); + } +} + +#[cfg(feature = "owning_ref")] +unsafe impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> StableAddress + for ReentrantMutexGuard<'a, R, G, T> +{} + +/// An RAII mutex guard returned by `ReentrantMutexGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedReentrantMutexGuard` and `ReentrantMutexGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +#[must_use] +pub struct MappedReentrantMutexGuard<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> { + raw: &'a RawReentrantMutex, + data: *const T, + marker: PhantomData<&'a T>, +} + +unsafe impl<'a, R: RawMutex + Sync + 'a, G: GetThreadId + Sync + 'a, T: ?Sized + Sync + 'a> Sync + for MappedReentrantMutexGuard<'a, R, G, T> +{} + +impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> + MappedReentrantMutexGuard<'a, R, G, T> +{ + /// Makes a new `MappedReentrantMutexGuard` for a component of the locked data. + /// + /// This operation cannot fail as the `MappedReentrantMutexGuard` passed + /// in already locked the mutex. + /// + /// This is an associated function that needs to be + /// used as `MappedReentrantMutexGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn map(s: Self, f: F) -> MappedReentrantMutexGuard<'a, R, G, U> + where + F: FnOnce(&T) -> &U, + { + let raw = s.raw; + let data = f(unsafe { &*s.data }); + mem::forget(s); + MappedReentrantMutexGuard { + raw, + data, + marker: PhantomData, + } + } + + /// Attempts to make a new `MappedReentrantMutexGuard` for a component of the + /// locked data. The original guard is return if the closure returns `None`. + /// + /// This operation cannot fail as the `MappedReentrantMutexGuard` passed + /// in already locked the mutex. + /// + /// This is an associated function that needs to be + /// used as `MappedReentrantMutexGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn try_map(s: Self, f: F) -> Result, Self> + where + F: FnOnce(&T) -> Option<&U>, + { + let raw = s.raw; + let data = match f(unsafe { &*s.data }) { + Some(data) => data, + None => return Err(s), + }; + mem::forget(s); + Ok(MappedReentrantMutexGuard { + raw, + data, + marker: PhantomData, + }) + } +} + +impl<'a, R: RawMutexFair + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> + MappedReentrantMutexGuard<'a, R, G, T> +{ + /// Unlocks the mutex using a fair unlock protocol. + /// + /// By default, mutexes are unfair and allow the current thread to re-lock + /// the mutex before another has the chance to acquire the lock, even if + /// that thread has been blocked on the mutex for a long time. This is the + /// default because it allows much higher throughput as it avoids forcing a + /// context switch on every mutex unlock. This can result in one thread + /// acquiring a mutex many more times than other threads. + /// + /// However in some cases it can be beneficial to ensure fairness by forcing + /// the lock to pass on to a waiting thread if there is one. This is done by + /// using this method instead of dropping the `ReentrantMutexGuard` normally. + #[inline] + pub fn unlock_fair(s: Self) { + s.raw.unlock_fair(); + mem::forget(s); + } +} + +impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> Deref + for MappedReentrantMutexGuard<'a, R, G, T> +{ + type Target = T; + #[inline] + fn deref(&self) -> &T { + unsafe { &*self.data } + } +} + +impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> Drop + for MappedReentrantMutexGuard<'a, R, G, T> +{ + #[inline] + fn drop(&mut self) { + self.raw.unlock(); + } +} + +#[cfg(feature = "owning_ref")] +unsafe impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> StableAddress + for MappedReentrantMutexGuard<'a, R, G, T> +{} diff --git a/third_party/cargo/vendor/lock_api-0.1.5/src/rwlock.rs b/third_party/cargo/vendor/lock_api-0.1.5/src/rwlock.rs new file mode 100644 index 0000000..4edb917 --- /dev/null +++ b/third_party/cargo/vendor/lock_api-0.1.5/src/rwlock.rs @@ -0,0 +1,1453 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use core::cell::UnsafeCell; +use core::fmt; +use core::marker::PhantomData; +use core::mem; +use core::ops::{Deref, DerefMut}; + +#[cfg(feature = "owning_ref")] +use owning_ref::StableAddress; + +/// Basic operations for a reader-writer lock. +/// +/// Types implementing this trait can be used by `RwLock` to form a safe and +/// fully-functioning `RwLock` type. +/// +/// # Safety +/// +/// Implementations of this trait must ensure that the `RwLock` is actually +/// exclusive: an exclusive lock can't be acquired while an exclusive or shared +/// lock exists, and a shared lock can't be acquire while an exclusive lock +/// exists. +pub unsafe trait RawRwLock { + /// Initial value for an unlocked `RwLock`. + const INIT: Self; + + /// Marker type which determines whether a lock guard should be `Send`. Use + /// one of the `GuardSend` or `GuardNoSend` helper types here. + type GuardMarker; + + /// Acquires a shared lock, blocking the current thread until it is able to do so. + fn lock_shared(&self); + + /// Attempts to acquire a shared lock without blocking. + fn try_lock_shared(&self) -> bool; + + /// Releases a shared lock. + fn unlock_shared(&self); + + /// Acquires an exclusive lock, blocking the current thread until it is able to do so. + fn lock_exclusive(&self); + + /// Attempts to acquire an exclusive lock without blocking. + fn try_lock_exclusive(&self) -> bool; + + /// Releases an exclusive lock. + fn unlock_exclusive(&self); +} + +/// Additional methods for RwLocks which support fair unlocking. +/// +/// Fair unlocking means that a lock is handed directly over to the next waiting +/// thread if there is one, without giving other threads the opportunity to +/// "steal" the lock in the meantime. This is typically slower than unfair +/// unlocking, but may be necessary in certain circumstances. +pub unsafe trait RawRwLockFair: RawRwLock { + /// Releases a shared lock using a fair unlock protocol. + fn unlock_shared_fair(&self); + + /// Releases an exclusive lock using a fair unlock protocol. + fn unlock_exclusive_fair(&self); + + /// Temporarily yields a shared lock to a waiting thread if there is one. + /// + /// This method is functionally equivalent to calling `unlock_shared_fair` followed + /// by `lock_shared`, however it can be much more efficient in the case where there + /// are no waiting threads. + fn bump_shared(&self) { + self.unlock_shared_fair(); + self.lock_shared(); + } + + /// Temporarily yields an exclusive lock to a waiting thread if there is one. + /// + /// This method is functionally equivalent to calling `unlock_exclusive_fair` followed + /// by `lock_exclusive`, however it can be much more efficient in the case where there + /// are no waiting threads. + fn bump_exclusive(&self) { + self.unlock_exclusive_fair(); + self.lock_exclusive(); + } +} + +/// Additional methods for RwLocks which support atomically downgrading an +/// exclusive lock to a shared lock. +pub unsafe trait RawRwLockDowngrade: RawRwLock { + /// Atomically downgrades an exclusive lock into a shared lock without + /// allowing any thread to take an exclusive lock in the meantime. + fn downgrade(&self); +} + +/// Additional methods for RwLocks which support locking with timeouts. +/// +/// The `Duration` and `Instant` types are specified as associated types so that +/// this trait is usable even in `no_std` environments. +pub unsafe trait RawRwLockTimed: RawRwLock { + /// Duration type used for `try_lock_for`. + type Duration; + + /// Instant type used for `try_lock_until`. + type Instant; + + /// Attempts to acquire a shared lock until a timeout is reached. + fn try_lock_shared_for(&self, timeout: Self::Duration) -> bool; + + /// Attempts to acquire a shared lock until a timeout is reached. + fn try_lock_shared_until(&self, timeout: Self::Instant) -> bool; + + /// Attempts to acquire an exclusive lock until a timeout is reached. + fn try_lock_exclusive_for(&self, timeout: Self::Duration) -> bool; + + /// Attempts to acquire an exclusive lock until a timeout is reached. + fn try_lock_exclusive_until(&self, timeout: Self::Instant) -> bool; +} + +/// Additional methods for RwLocks which support recursive read locks. +/// +/// These are guaranteed to succeed without blocking if +/// another read lock is held at the time of the call. This allows a thread +/// to recursively lock a `RwLock`. However using this method can cause +/// writers to starve since readers no longer block if a writer is waiting +/// for the lock. +pub unsafe trait RawRwLockRecursive: RawRwLock { + /// Acquires a shared lock without deadlocking in case of a recursive lock. + fn lock_shared_recursive(&self); + + /// Attempts to acquire a shared lock without deadlocking in case of a recursive lock. + fn try_lock_shared_recursive(&self) -> bool; +} + +/// Additional methods for RwLocks which support recursive read locks and timeouts. +pub unsafe trait RawRwLockRecursiveTimed: RawRwLockRecursive + RawRwLockTimed { + /// Attempts to acquire a shared lock until a timeout is reached, without + /// deadlocking in case of a recursive lock. + fn try_lock_shared_recursive_for(&self, timeout: Self::Duration) -> bool; + + /// Attempts to acquire a shared lock until a timeout is reached, without + /// deadlocking in case of a recursive lock. + fn try_lock_shared_recursive_until(&self, timeout: Self::Instant) -> bool; +} + +/// Additional methods for RwLocks which support atomically upgrading a shared +/// lock to an exclusive lock. +/// +/// This requires acquiring a special "upgradable read lock" instead of a +/// normal shared lock. There may only be one upgradable lock at any time, +/// otherwise deadlocks could occur when upgrading. +pub unsafe trait RawRwLockUpgrade: RawRwLock { + /// Acquires an upgradable lock, blocking the current thread until it is able to do so. + fn lock_upgradable(&self); + + /// Attempts to acquire an upgradable lock without blocking. + fn try_lock_upgradable(&self) -> bool; + + /// Releases an upgradable lock. + fn unlock_upgradable(&self); + + /// Upgrades an upgradable lock to an exclusive lock. + fn upgrade(&self); + + /// Attempts to upgrade an upgradable lock to an exclusive lock without + /// blocking. + fn try_upgrade(&self) -> bool; +} + +/// Additional methods for RwLocks which support upgradable locks and fair +/// unlocking. +pub unsafe trait RawRwLockUpgradeFair: RawRwLockUpgrade + RawRwLockFair { + /// Releases an upgradable lock using a fair unlock protocol. + fn unlock_upgradable_fair(&self); + + /// Temporarily yields an upgradable lock to a waiting thread if there is one. + /// + /// This method is functionally equivalent to calling `unlock_upgradable_fair` followed + /// by `lock_upgradable`, however it can be much more efficient in the case where there + /// are no waiting threads. + fn bump_upgradable(&self) { + self.unlock_upgradable_fair(); + self.lock_upgradable(); + } +} + +/// Additional methods for RwLocks which support upgradable locks and lock +/// downgrading. +pub unsafe trait RawRwLockUpgradeDowngrade: RawRwLockUpgrade + RawRwLockDowngrade { + /// Downgrades an upgradable lock to a shared lock. + fn downgrade_upgradable(&self); + + /// Downgrades an exclusive lock to an upgradable lock. + fn downgrade_to_upgradable(&self); +} + +/// Additional methods for RwLocks which support upgradable locks and locking +/// with timeouts. +pub unsafe trait RawRwLockUpgradeTimed: RawRwLockUpgrade + RawRwLockTimed { + /// Attempts to acquire an upgradable lock until a timeout is reached. + fn try_lock_upgradable_for(&self, timeout: Self::Duration) -> bool; + + /// Attempts to acquire an upgradable lock until a timeout is reached. + fn try_lock_upgradable_until(&self, timeout: Self::Instant) -> bool; + + /// Attempts to upgrade an upgradable lock to an exclusive lock until a + /// timeout is reached. + fn try_upgrade_for(&self, timeout: Self::Duration) -> bool; + + /// Attempts to upgrade an upgradable lock to an exclusive lock until a + /// timeout is reached. + fn try_upgrade_until(&self, timeout: Self::Instant) -> bool; +} + +/// A reader-writer lock +/// +/// This type of lock allows a number of readers or at most one writer at any +/// point in time. The write portion of this lock typically allows modification +/// of the underlying data (exclusive access) and the read portion of this lock +/// typically allows for read-only access (shared access). +/// +/// The type parameter `T` represents the data that this lock protects. It is +/// required that `T` satisfies `Send` to be shared across threads and `Sync` to +/// allow concurrent access through readers. The RAII guards returned from the +/// locking methods implement `Deref` (and `DerefMut` for the `write` methods) +/// to allow access to the contained of the lock. +pub struct RwLock { + raw: R, + data: UnsafeCell, +} + +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} + +impl RwLock { + /// Creates a new instance of an `RwLock` which is unlocked. + #[cfg(feature = "nightly")] + #[inline] + pub const fn new(val: T) -> RwLock { + RwLock { + data: UnsafeCell::new(val), + raw: R::INIT, + } + } + + /// Creates a new instance of an `RwLock` which is unlocked. + #[cfg(not(feature = "nightly"))] + #[inline] + pub fn new(val: T) -> RwLock { + RwLock { + data: UnsafeCell::new(val), + raw: R::INIT, + } + } + + /// Consumes this `RwLock`, returning the underlying data. + #[inline] + #[allow(unused_unsafe)] + pub fn into_inner(self) -> T { + unsafe { self.data.into_inner() } + } +} + +impl RwLock { + #[inline] + fn read_guard(&self) -> RwLockReadGuard { + RwLockReadGuard { + rwlock: self, + marker: PhantomData, + } + } + + #[inline] + fn write_guard(&self) -> RwLockWriteGuard { + RwLockWriteGuard { + rwlock: self, + marker: PhantomData, + } + } + + /// Locks this `RwLock` with shared read access, blocking the current thread + /// until it can be acquired. + /// + /// The calling thread will be blocked until there are no more writers which + /// hold the lock. There may be other readers currently inside the lock when + /// this method returns. + /// + /// Note that attempts to recursively acquire a read lock on a `RwLock` when + /// the current thread already holds one may result in a deadlock. + /// + /// Returns an RAII guard which will release this thread's shared access + /// once it is dropped. + #[inline] + pub fn read(&self) -> RwLockReadGuard { + self.raw.lock_shared(); + self.read_guard() + } + + /// Attempts to acquire this `RwLock` with shared read access. + /// + /// If the access could not be granted at this time, then `None` is returned. + /// Otherwise, an RAII guard is returned which will release the shared access + /// when it is dropped. + /// + /// This function does not block. + #[inline] + pub fn try_read(&self) -> Option> { + if self.raw.try_lock_shared() { + Some(self.read_guard()) + } else { + None + } + } + + /// Locks this `RwLock` with exclusive write access, blocking the current + /// thread until it can be acquired. + /// + /// This function will not return while other writers or other readers + /// currently have access to the lock. + /// + /// Returns an RAII guard which will drop the write access of this `RwLock` + /// when dropped. + #[inline] + pub fn write(&self) -> RwLockWriteGuard { + self.raw.lock_exclusive(); + self.write_guard() + } + + /// Attempts to lock this `RwLock` with exclusive write access. + /// + /// If the lock could not be acquired at this time, then `None` is returned. + /// Otherwise, an RAII guard is returned which will release the lock when + /// it is dropped. + /// + /// This function does not block. + #[inline] + pub fn try_write(&self) -> Option> { + if self.raw.try_lock_exclusive() { + Some(self.write_guard()) + } else { + None + } + } + + /// Returns a mutable reference to the underlying data. + /// + /// Since this call borrows the `RwLock` mutably, no actual locking needs to + /// take place---the mutable borrow statically guarantees no locks exist. + #[inline] + pub fn get_mut(&mut self) -> &mut T { + unsafe { &mut *self.data.get() } + } + + /// Forcibly unlocks a read lock. + /// + /// This is useful when combined with `mem::forget` to hold a lock without + /// the need to maintain a `RwLockReadGuard` object alive, for example when + /// dealing with FFI. + /// + /// # Safety + /// + /// This method must only be called if the current thread logically owns a + /// `RwLockReadGuard` but that guard has be discarded using `mem::forget`. + /// Behavior is undefined if a rwlock is read-unlocked when not read-locked. + #[inline] + pub unsafe fn force_unlock_read(&self) { + self.raw.unlock_shared(); + } + + /// Forcibly unlocks a write lock. + /// + /// This is useful when combined with `mem::forget` to hold a lock without + /// the need to maintain a `RwLockWriteGuard` object alive, for example when + /// dealing with FFI. + /// + /// # Safety + /// + /// This method must only be called if the current thread logically owns a + /// `RwLockWriteGuard` but that guard has be discarded using `mem::forget`. + /// Behavior is undefined if a rwlock is write-unlocked when not write-locked. + #[inline] + pub unsafe fn force_unlock_write(&self) { + self.raw.unlock_exclusive(); + } + + /// Returns the underlying raw reader-writer lock object. + /// + /// Note that you will most likely need to import the `RawRwLock` trait from + /// `lock_api` to be able to call functions on the raw + /// reader-writer lock. + /// + /// # Safety + /// + /// This method is unsafe because it allows unlocking a mutex while + /// still holding a reference to a lock guard. + pub unsafe fn raw(&self) -> &R { + &self.raw + } +} + +impl RwLock { + /// Forcibly unlocks a read lock using a fair unlock procotol. + /// + /// This is useful when combined with `mem::forget` to hold a lock without + /// the need to maintain a `RwLockReadGuard` object alive, for example when + /// dealing with FFI. + /// + /// # Safety + /// + /// This method must only be called if the current thread logically owns a + /// `RwLockReadGuard` but that guard has be discarded using `mem::forget`. + /// Behavior is undefined if a rwlock is read-unlocked when not read-locked. + #[inline] + pub unsafe fn force_unlock_read_fair(&self) { + self.raw.unlock_shared_fair(); + } + + /// Forcibly unlocks a write lock using a fair unlock procotol. + /// + /// This is useful when combined with `mem::forget` to hold a lock without + /// the need to maintain a `RwLockWriteGuard` object alive, for example when + /// dealing with FFI. + /// + /// # Safety + /// + /// This method must only be called if the current thread logically owns a + /// `RwLockWriteGuard` but that guard has be discarded using `mem::forget`. + /// Behavior is undefined if a rwlock is write-unlocked when not write-locked. + #[inline] + pub unsafe fn force_unlock_write_fair(&self) { + self.raw.unlock_exclusive_fair(); + } +} + +impl RwLock { + /// Attempts to acquire this `RwLock` with shared read access until a timeout + /// is reached. + /// + /// If the access could not be granted before the timeout expires, then + /// `None` is returned. Otherwise, an RAII guard is returned which will + /// release the shared access when it is dropped. + #[inline] + pub fn try_read_for(&self, timeout: R::Duration) -> Option> { + if self.raw.try_lock_shared_for(timeout) { + Some(self.read_guard()) + } else { + None + } + } + + /// Attempts to acquire this `RwLock` with shared read access until a timeout + /// is reached. + /// + /// If the access could not be granted before the timeout expires, then + /// `None` is returned. Otherwise, an RAII guard is returned which will + /// release the shared access when it is dropped. + #[inline] + pub fn try_read_until(&self, timeout: R::Instant) -> Option> { + if self.raw.try_lock_shared_until(timeout) { + Some(self.read_guard()) + } else { + None + } + } + + /// Attempts to acquire this `RwLock` with exclusive write access until a + /// timeout is reached. + /// + /// If the access could not be granted before the timeout expires, then + /// `None` is returned. Otherwise, an RAII guard is returned which will + /// release the exclusive access when it is dropped. + #[inline] + pub fn try_write_for(&self, timeout: R::Duration) -> Option> { + if self.raw.try_lock_exclusive_for(timeout) { + Some(self.write_guard()) + } else { + None + } + } + + /// Attempts to acquire this `RwLock` with exclusive write access until a + /// timeout is reached. + /// + /// If the access could not be granted before the timeout expires, then + /// `None` is returned. Otherwise, an RAII guard is returned which will + /// release the exclusive access when it is dropped. + #[inline] + pub fn try_write_until(&self, timeout: R::Instant) -> Option> { + if self.raw.try_lock_exclusive_until(timeout) { + Some(self.write_guard()) + } else { + None + } + } +} + +impl RwLock { + /// Locks this `RwLock` with shared read access, blocking the current thread + /// until it can be acquired. + /// + /// The calling thread will be blocked until there are no more writers which + /// hold the lock. There may be other readers currently inside the lock when + /// this method returns. + /// + /// Unlike `read`, this method is guaranteed to succeed without blocking if + /// another read lock is held at the time of the call. This allows a thread + /// to recursively lock a `RwLock`. However using this method can cause + /// writers to starve since readers no longer block if a writer is waiting + /// for the lock. + /// + /// Returns an RAII guard which will release this thread's shared access + /// once it is dropped. + #[inline] + pub fn read_recursive(&self) -> RwLockReadGuard { + self.raw.lock_shared_recursive(); + self.read_guard() + } + + /// Attempts to acquire this `RwLock` with shared read access. + /// + /// If the access could not be granted at this time, then `None` is returned. + /// Otherwise, an RAII guard is returned which will release the shared access + /// when it is dropped. + /// + /// This method is guaranteed to succeed if another read lock is held at the + /// time of the call. See the documentation for `read_recursive` for details. + /// + /// This function does not block. + #[inline] + pub fn try_read_recursive(&self) -> Option> { + if self.raw.try_lock_shared_recursive() { + Some(self.read_guard()) + } else { + None + } + } +} + +impl RwLock { + /// Attempts to acquire this `RwLock` with shared read access until a timeout + /// is reached. + /// + /// If the access could not be granted before the timeout expires, then + /// `None` is returned. Otherwise, an RAII guard is returned which will + /// release the shared access when it is dropped. + /// + /// This method is guaranteed to succeed without blocking if another read + /// lock is held at the time of the call. See the documentation for + /// `read_recursive` for details. + #[inline] + pub fn try_read_recursive_for(&self, timeout: R::Duration) -> Option> { + if self.raw.try_lock_shared_recursive_for(timeout) { + Some(self.read_guard()) + } else { + None + } + } + + /// Attempts to acquire this `RwLock` with shared read access until a timeout + /// is reached. + /// + /// If the access could not be granted before the timeout expires, then + /// `None` is returned. Otherwise, an RAII guard is returned which will + /// release the shared access when it is dropped. + #[inline] + pub fn try_read_recursive_until(&self, timeout: R::Instant) -> Option> { + if self.raw.try_lock_shared_recursive_until(timeout) { + Some(self.read_guard()) + } else { + None + } + } +} + +impl RwLock { + #[inline] + fn upgradable_guard(&self) -> RwLockUpgradableReadGuard { + RwLockUpgradableReadGuard { + rwlock: self, + marker: PhantomData, + } + } + + /// Locks this `RwLock` with upgradable read access, blocking the current thread + /// until it can be acquired. + /// + /// The calling thread will be blocked until there are no more writers or other + /// upgradable reads which hold the lock. There may be other readers currently + /// inside the lock when this method returns. + /// + /// Returns an RAII guard which will release this thread's shared access + /// once it is dropped. + #[inline] + pub fn upgradable_read(&self) -> RwLockUpgradableReadGuard { + self.raw.lock_upgradable(); + self.upgradable_guard() + } + + /// Attempts to acquire this `RwLock` with upgradable read access. + /// + /// If the access could not be granted at this time, then `None` is returned. + /// Otherwise, an RAII guard is returned which will release the shared access + /// when it is dropped. + /// + /// This function does not block. + #[inline] + pub fn try_upgradable_read(&self) -> Option> { + if self.raw.try_lock_upgradable() { + Some(self.upgradable_guard()) + } else { + None + } + } +} + +impl RwLock { + /// Attempts to acquire this `RwLock` with upgradable read access until a timeout + /// is reached. + /// + /// If the access could not be granted before the timeout expires, then + /// `None` is returned. Otherwise, an RAII guard is returned which will + /// release the shared access when it is dropped. + #[inline] + pub fn try_upgradable_read_for( + &self, + timeout: R::Duration, + ) -> Option> { + if self.raw.try_lock_upgradable_for(timeout) { + Some(self.upgradable_guard()) + } else { + None + } + } + + /// Attempts to acquire this `RwLock` with upgradable read access until a timeout + /// is reached. + /// + /// If the access could not be granted before the timeout expires, then + /// `None` is returned. Otherwise, an RAII guard is returned which will + /// release the shared access when it is dropped. + #[inline] + pub fn try_upgradable_read_until( + &self, + timeout: R::Instant, + ) -> Option> { + if self.raw.try_lock_upgradable_until(timeout) { + Some(self.upgradable_guard()) + } else { + None + } + } +} + +impl Default for RwLock { + #[inline] + fn default() -> RwLock { + RwLock::new(Default::default()) + } +} + +impl From for RwLock { + #[inline] + fn from(t: T) -> RwLock { + RwLock::new(t) + } +} + +impl fmt::Debug for RwLock { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.try_read() { + Some(guard) => f.debug_struct("RwLock").field("data", &&*guard).finish(), + None => f.pad("RwLock { }"), + } + } +} + +/// RAII structure used to release the shared read access of a lock when +/// dropped. +#[must_use] +pub struct RwLockReadGuard<'a, R: RawRwLock + 'a, T: ?Sized + 'a> { + rwlock: &'a RwLock, + marker: PhantomData<(&'a T, R::GuardMarker)>, +} + +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync for RwLockReadGuard<'a, R, T> {} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> RwLockReadGuard<'a, R, T> { + /// Returns a reference to the original reader-writer lock object. + pub fn rwlock(s: &Self) -> &'a RwLock { + s.rwlock + } + + /// Make a new `MappedRwLockReadGuard` for a component of the locked data. + /// + /// This operation cannot fail as the `RwLockReadGuard` passed + /// in already locked the data. + /// + /// This is an associated function that needs to be + /// used as `RwLockReadGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn map(s: Self, f: F) -> MappedRwLockReadGuard<'a, R, U> + where + F: FnOnce(&T) -> &U, + { + let raw = &s.rwlock.raw; + let data = f(unsafe { &*s.rwlock.data.get() }); + mem::forget(s); + MappedRwLockReadGuard { + raw, + data, + marker: PhantomData, + } + } + + /// Attempts to make a new `MappedRwLockReadGuard` for a component of the + /// locked data. The original guard is return if the closure returns `None`. + /// + /// This operation cannot fail as the `RwLockReadGuard` passed + /// in already locked the data. + /// + /// This is an associated function that needs to be + /// used as `RwLockReadGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn try_map(s: Self, f: F) -> Result, Self> + where + F: FnOnce(&T) -> Option<&U>, + { + let raw = &s.rwlock.raw; + let data = match f(unsafe { &*s.rwlock.data.get() }) { + Some(data) => data, + None => return Err(s), + }; + mem::forget(s); + Ok(MappedRwLockReadGuard { + raw, + data, + marker: PhantomData, + }) + } + + /// Temporarily unlocks the `RwLock` to execute the given function. + /// + /// The `RwLock` is unlocked a fair unlock protocol. + /// + /// This is safe because `&mut` guarantees that there exist no other + /// references to the data protected by the `RwLock`. + #[inline] + pub fn unlocked(s: &mut Self, f: F) -> U + where + F: FnOnce() -> U, + { + s.rwlock.raw.unlock_shared(); + defer!(s.rwlock.raw.lock_shared()); + f() + } +} + +impl<'a, R: RawRwLockFair + 'a, T: ?Sized + 'a> RwLockReadGuard<'a, R, T> { + /// Unlocks the `RwLock` using a fair unlock protocol. + /// + /// By default, `RwLock` is unfair and allow the current thread to re-lock + /// the `RwLock` before another has the chance to acquire the lock, even if + /// that thread has been blocked on the `RwLock` for a long time. This is + /// the default because it allows much higher throughput as it avoids + /// forcing a context switch on every `RwLock` unlock. This can result in one + /// thread acquiring a `RwLock` many more times than other threads. + /// + /// However in some cases it can be beneficial to ensure fairness by forcing + /// the lock to pass on to a waiting thread if there is one. This is done by + /// using this method instead of dropping the `RwLockReadGuard` normally. + #[inline] + pub fn unlock_fair(s: Self) { + s.rwlock.raw.unlock_shared_fair(); + mem::forget(s); + } + + /// Temporarily unlocks the `RwLock` to execute the given function. + /// + /// The `RwLock` is unlocked a fair unlock protocol. + /// + /// This is safe because `&mut` guarantees that there exist no other + /// references to the data protected by the `RwLock`. + #[inline] + pub fn unlocked_fair(s: &mut Self, f: F) -> U + where + F: FnOnce() -> U, + { + s.rwlock.raw.unlock_shared_fair(); + defer!(s.rwlock.raw.lock_shared()); + f() + } + + /// Temporarily yields the `RwLock` to a waiting thread if there is one. + /// + /// This method is functionally equivalent to calling `unlock_fair` followed + /// by `read`, however it can be much more efficient in the case where there + /// are no waiting threads. + #[inline] + pub fn bump(s: &mut Self) { + s.rwlock.raw.bump_shared(); + } +} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Deref for RwLockReadGuard<'a, R, T> { + type Target = T; + #[inline] + fn deref(&self) -> &T { + unsafe { &*self.rwlock.data.get() } + } +} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Drop for RwLockReadGuard<'a, R, T> { + #[inline] + fn drop(&mut self) { + self.rwlock.raw.unlock_shared(); + } +} + +#[cfg(feature = "owning_ref")] +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress for RwLockReadGuard<'a, R, T> {} + +/// RAII structure used to release the exclusive write access of a lock when +/// dropped. +#[must_use] +pub struct RwLockWriteGuard<'a, R: RawRwLock + 'a, T: ?Sized + 'a> { + rwlock: &'a RwLock, + marker: PhantomData<(&'a mut T, R::GuardMarker)>, +} + +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync for RwLockWriteGuard<'a, R, T> {} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T> { + /// Returns a reference to the original reader-writer lock object. + pub fn rwlock(s: &Self) -> &'a RwLock { + s.rwlock + } + + /// Make a new `MappedRwLockWriteGuard` for a component of the locked data. + /// + /// This operation cannot fail as the `RwLockWriteGuard` passed + /// in already locked the data. + /// + /// This is an associated function that needs to be + /// used as `RwLockWriteGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn map(s: Self, f: F) -> MappedRwLockWriteGuard<'a, R, U> + where + F: FnOnce(&mut T) -> &mut U, + { + let raw = &s.rwlock.raw; + let data = f(unsafe { &mut *s.rwlock.data.get() }); + mem::forget(s); + MappedRwLockWriteGuard { + raw, + data, + marker: PhantomData, + } + } + + /// Attempts to make a new `MappedRwLockWriteGuard` for a component of the + /// locked data. The original guard is return if the closure returns `None`. + /// + /// This operation cannot fail as the `RwLockWriteGuard` passed + /// in already locked the data. + /// + /// This is an associated function that needs to be + /// used as `RwLockWriteGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn try_map(s: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + { + let raw = &s.rwlock.raw; + let data = match f(unsafe { &mut *s.rwlock.data.get() }) { + Some(data) => data, + None => return Err(s), + }; + mem::forget(s); + Ok(MappedRwLockWriteGuard { + raw, + data, + marker: PhantomData, + }) + } + + /// Temporarily unlocks the `RwLock` to execute the given function. + /// + /// This is safe because `&mut` guarantees that there exist no other + /// references to the data protected by the `RwLock`. + #[inline] + pub fn unlocked(s: &mut Self, f: F) -> U + where + F: FnOnce() -> U, + { + s.rwlock.raw.unlock_exclusive(); + defer!(s.rwlock.raw.lock_exclusive()); + f() + } +} + +impl<'a, R: RawRwLockDowngrade + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T> { + /// Atomically downgrades a write lock into a read lock without allowing any + /// writers to take exclusive access of the lock in the meantime. + /// + /// Note that if there are any writers currently waiting to take the lock + /// then other readers may not be able to acquire the lock even if it was + /// downgraded. + pub fn downgrade(s: Self) -> RwLockReadGuard<'a, R, T> { + s.rwlock.raw.downgrade(); + let rwlock = s.rwlock; + mem::forget(s); + RwLockReadGuard { + rwlock, + marker: PhantomData, + } + } +} + +impl<'a, R: RawRwLockUpgradeDowngrade + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T> { + /// Atomically downgrades a write lock into an upgradable read lock without allowing any + /// writers to take exclusive access of the lock in the meantime. + /// + /// Note that if there are any writers currently waiting to take the lock + /// then other readers may not be able to acquire the lock even if it was + /// downgraded. + pub fn downgrade_to_upgradable(s: Self) -> RwLockUpgradableReadGuard<'a, R, T> { + s.rwlock.raw.downgrade_to_upgradable(); + let rwlock = s.rwlock; + mem::forget(s); + RwLockUpgradableReadGuard { + rwlock, + marker: PhantomData, + } + } +} + +impl<'a, R: RawRwLockFair + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T> { + /// Unlocks the `RwLock` using a fair unlock protocol. + /// + /// By default, `RwLock` is unfair and allow the current thread to re-lock + /// the `RwLock` before another has the chance to acquire the lock, even if + /// that thread has been blocked on the `RwLock` for a long time. This is + /// the default because it allows much higher throughput as it avoids + /// forcing a context switch on every `RwLock` unlock. This can result in one + /// thread acquiring a `RwLock` many more times than other threads. + /// + /// However in some cases it can be beneficial to ensure fairness by forcing + /// the lock to pass on to a waiting thread if there is one. This is done by + /// using this method instead of dropping the `RwLockWriteGuard` normally. + #[inline] + pub fn unlock_fair(s: Self) { + s.rwlock.raw.unlock_exclusive_fair(); + mem::forget(s); + } + + /// Temporarily unlocks the `RwLock` to execute the given function. + /// + /// The `RwLock` is unlocked a fair unlock protocol. + /// + /// This is safe because `&mut` guarantees that there exist no other + /// references to the data protected by the `RwLock`. + #[inline] + pub fn unlocked_fair(s: &mut Self, f: F) -> U + where + F: FnOnce() -> U, + { + s.rwlock.raw.unlock_exclusive_fair(); + defer!(s.rwlock.raw.lock_exclusive()); + f() + } + + /// Temporarily yields the `RwLock` to a waiting thread if there is one. + /// + /// This method is functionally equivalent to calling `unlock_fair` followed + /// by `write`, however it can be much more efficient in the case where there + /// are no waiting threads. + #[inline] + pub fn bump(s: &mut Self) { + s.rwlock.raw.bump_exclusive(); + } +} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Deref for RwLockWriteGuard<'a, R, T> { + type Target = T; + #[inline] + fn deref(&self) -> &T { + unsafe { &*self.rwlock.data.get() } + } +} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> DerefMut for RwLockWriteGuard<'a, R, T> { + #[inline] + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *self.rwlock.data.get() } + } +} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Drop for RwLockWriteGuard<'a, R, T> { + #[inline] + fn drop(&mut self) { + self.rwlock.raw.unlock_exclusive(); + } +} + +#[cfg(feature = "owning_ref")] +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress for RwLockWriteGuard<'a, R, T> {} + +/// RAII structure used to release the upgradable read access of a lock when +/// dropped. +#[must_use] +pub struct RwLockUpgradableReadGuard<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + 'a> { + rwlock: &'a RwLock, + marker: PhantomData<(&'a T, R::GuardMarker)>, +} + +unsafe impl<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + Sync + 'a> Sync + for RwLockUpgradableReadGuard<'a, R, T> +{} + +impl<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + 'a> RwLockUpgradableReadGuard<'a, R, T> { + /// Returns a reference to the original reader-writer lock object. + pub fn rwlock(s: &Self) -> &'a RwLock { + s.rwlock + } + + /// Temporarily unlocks the `RwLock` to execute the given function. + /// + /// This is safe because `&mut` guarantees that there exist no other + /// references to the data protected by the `RwLock`. + #[inline] + pub fn unlocked(s: &mut Self, f: F) -> U + where + F: FnOnce() -> U, + { + s.rwlock.raw.unlock_upgradable(); + defer!(s.rwlock.raw.lock_upgradable()); + f() + } + + /// Atomically upgrades an upgradable read lock lock into a exclusive write lock, + /// blocking the current thread until it can be acquired. + pub fn upgrade(s: Self) -> RwLockWriteGuard<'a, R, T> { + s.rwlock.raw.upgrade(); + let rwlock = s.rwlock; + mem::forget(s); + RwLockWriteGuard { + rwlock, + marker: PhantomData, + } + } + + /// Tries to atomically upgrade an upgradable read lock into a exclusive write lock. + /// + /// If the access could not be granted at this time, then the current guard is returned. + pub fn try_upgrade(s: Self) -> Result, Self> { + if s.rwlock.raw.try_upgrade() { + let rwlock = s.rwlock; + mem::forget(s); + Ok(RwLockWriteGuard { + rwlock, + marker: PhantomData, + }) + } else { + Err(s) + } + } +} + +impl<'a, R: RawRwLockUpgradeFair + 'a, T: ?Sized + 'a> RwLockUpgradableReadGuard<'a, R, T> { + /// Unlocks the `RwLock` using a fair unlock protocol. + /// + /// By default, `RwLock` is unfair and allow the current thread to re-lock + /// the `RwLock` before another has the chance to acquire the lock, even if + /// that thread has been blocked on the `RwLock` for a long time. This is + /// the default because it allows much higher throughput as it avoids + /// forcing a context switch on every `RwLock` unlock. This can result in one + /// thread acquiring a `RwLock` many more times than other threads. + /// + /// However in some cases it can be beneficial to ensure fairness by forcing + /// the lock to pass on to a waiting thread if there is one. This is done by + /// using this method instead of dropping the `RwLockUpgradableReadGuard` normally. + #[inline] + pub fn unlock_fair(s: Self) { + s.rwlock.raw.unlock_upgradable_fair(); + mem::forget(s); + } + + /// Temporarily unlocks the `RwLock` to execute the given function. + /// + /// The `RwLock` is unlocked a fair unlock protocol. + /// + /// This is safe because `&mut` guarantees that there exist no other + /// references to the data protected by the `RwLock`. + #[inline] + pub fn unlocked_fair(s: &mut Self, f: F) -> U + where + F: FnOnce() -> U, + { + s.rwlock.raw.unlock_upgradable_fair(); + defer!(s.rwlock.raw.lock_upgradable()); + f() + } + + /// Temporarily yields the `RwLock` to a waiting thread if there is one. + /// + /// This method is functionally equivalent to calling `unlock_fair` followed + /// by `upgradable_read`, however it can be much more efficient in the case where there + /// are no waiting threads. + #[inline] + pub fn bump(s: &mut Self) { + s.rwlock.raw.bump_upgradable(); + } +} + +impl<'a, R: RawRwLockUpgradeDowngrade + 'a, T: ?Sized + 'a> RwLockUpgradableReadGuard<'a, R, T> { + /// Atomically downgrades an upgradable read lock lock into a shared read lock + /// without allowing any writers to take exclusive access of the lock in the + /// meantime. + /// + /// Note that if there are any writers currently waiting to take the lock + /// then other readers may not be able to acquire the lock even if it was + /// downgraded. + pub fn downgrade(s: Self) -> RwLockReadGuard<'a, R, T> { + s.rwlock.raw.downgrade_upgradable(); + let rwlock = s.rwlock; + mem::forget(s); + RwLockReadGuard { + rwlock, + marker: PhantomData, + } + } +} + +impl<'a, R: RawRwLockUpgradeTimed + 'a, T: ?Sized + 'a> RwLockUpgradableReadGuard<'a, R, T> { + /// Tries to atomically upgrade an upgradable read lock into a exclusive + /// write lock, until a timeout is reached. + /// + /// If the access could not be granted before the timeout expires, then + /// the current guard is returned. + pub fn try_upgrade_for( + s: Self, + timeout: R::Duration, + ) -> Result, Self> { + if s.rwlock.raw.try_upgrade_for(timeout) { + let rwlock = s.rwlock; + mem::forget(s); + Ok(RwLockWriteGuard { + rwlock, + marker: PhantomData, + }) + } else { + Err(s) + } + } + + /// Tries to atomically upgrade an upgradable read lock into a exclusive + /// write lock, until a timeout is reached. + /// + /// If the access could not be granted before the timeout expires, then + /// the current guard is returned. + #[inline] + pub fn try_upgrade_until( + s: Self, + timeout: R::Instant, + ) -> Result, Self> { + if s.rwlock.raw.try_upgrade_until(timeout) { + let rwlock = s.rwlock; + mem::forget(s); + Ok(RwLockWriteGuard { + rwlock, + marker: PhantomData, + }) + } else { + Err(s) + } + } +} + +impl<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + 'a> Deref for RwLockUpgradableReadGuard<'a, R, T> { + type Target = T; + #[inline] + fn deref(&self) -> &T { + unsafe { &*self.rwlock.data.get() } + } +} + +impl<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + 'a> Drop for RwLockUpgradableReadGuard<'a, R, T> { + #[inline] + fn drop(&mut self) { + self.rwlock.raw.unlock_upgradable(); + } +} + +#[cfg(feature = "owning_ref")] +unsafe impl<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + 'a> StableAddress + for RwLockUpgradableReadGuard<'a, R, T> +{} + +/// An RAII read lock guard returned by `RwLockReadGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedRwLockReadGuard` and `RwLockReadGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +#[must_use] +pub struct MappedRwLockReadGuard<'a, R: RawRwLock + 'a, T: ?Sized + 'a> { + raw: &'a R, + data: *const T, + marker: PhantomData<&'a T>, +} + +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync for MappedRwLockReadGuard<'a, R, T> {} +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Send for MappedRwLockReadGuard<'a, R, T> where + R::GuardMarker: Send +{} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> MappedRwLockReadGuard<'a, R, T> { + /// Make a new `MappedRwLockReadGuard` for a component of the locked data. + /// + /// This operation cannot fail as the `MappedRwLockReadGuard` passed + /// in already locked the data. + /// + /// This is an associated function that needs to be + /// used as `MappedRwLockReadGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn map(s: Self, f: F) -> MappedRwLockReadGuard<'a, R, U> + where + F: FnOnce(&T) -> &U, + { + let raw = s.raw; + let data = f(unsafe { &*s.data }); + mem::forget(s); + MappedRwLockReadGuard { + raw, + data, + marker: PhantomData, + } + } + + /// Attempts to make a new `MappedRwLockReadGuard` for a component of the + /// locked data. The original guard is return if the closure returns `None`. + /// + /// This operation cannot fail as the `MappedRwLockReadGuard` passed + /// in already locked the data. + /// + /// This is an associated function that needs to be + /// used as `MappedRwLockReadGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn try_map(s: Self, f: F) -> Result, Self> + where + F: FnOnce(&T) -> Option<&U>, + { + let raw = s.raw; + let data = match f(unsafe { &*s.data }) { + Some(data) => data, + None => return Err(s), + }; + mem::forget(s); + Ok(MappedRwLockReadGuard { + raw, + data, + marker: PhantomData, + }) + } +} + +impl<'a, R: RawRwLockFair + 'a, T: ?Sized + 'a> MappedRwLockReadGuard<'a, R, T> { + /// Unlocks the `RwLock` using a fair unlock protocol. + /// + /// By default, `RwLock` is unfair and allow the current thread to re-lock + /// the `RwLock` before another has the chance to acquire the lock, even if + /// that thread has been blocked on the `RwLock` for a long time. This is + /// the default because it allows much higher throughput as it avoids + /// forcing a context switch on every `RwLock` unlock. This can result in one + /// thread acquiring a `RwLock` many more times than other threads. + /// + /// However in some cases it can be beneficial to ensure fairness by forcing + /// the lock to pass on to a waiting thread if there is one. This is done by + /// using this method instead of dropping the `MappedRwLockReadGuard` normally. + #[inline] + pub fn unlock_fair(s: Self) { + s.raw.unlock_shared_fair(); + mem::forget(s); + } +} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Deref for MappedRwLockReadGuard<'a, R, T> { + type Target = T; + #[inline] + fn deref(&self) -> &T { + unsafe { &*self.data } + } +} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Drop for MappedRwLockReadGuard<'a, R, T> { + #[inline] + fn drop(&mut self) { + self.raw.unlock_shared(); + } +} + +#[cfg(feature = "owning_ref")] +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress + for MappedRwLockReadGuard<'a, R, T> +{} + +/// An RAII write lock guard returned by `RwLockWriteGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedRwLockWriteGuard` and `RwLockWriteGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +#[must_use] +pub struct MappedRwLockWriteGuard<'a, R: RawRwLock + 'a, T: ?Sized + 'a> { + raw: &'a R, + data: *mut T, + marker: PhantomData<&'a mut T>, +} + +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync + for MappedRwLockWriteGuard<'a, R, T> +{} +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Send for MappedRwLockWriteGuard<'a, R, T> where + R::GuardMarker: Send +{} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> MappedRwLockWriteGuard<'a, R, T> { + /// Make a new `MappedRwLockWriteGuard` for a component of the locked data. + /// + /// This operation cannot fail as the `MappedRwLockWriteGuard` passed + /// in already locked the data. + /// + /// This is an associated function that needs to be + /// used as `MappedRwLockWriteGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn map(s: Self, f: F) -> MappedRwLockWriteGuard<'a, R, U> + where + F: FnOnce(&mut T) -> &mut U, + { + let raw = s.raw; + let data = f(unsafe { &mut *s.data }); + mem::forget(s); + MappedRwLockWriteGuard { + raw, + data, + marker: PhantomData, + } + } + + /// Attempts to make a new `MappedRwLockWriteGuard` for a component of the + /// locked data. The original guard is return if the closure returns `None`. + /// + /// This operation cannot fail as the `MappedRwLockWriteGuard` passed + /// in already locked the data. + /// + /// This is an associated function that needs to be + /// used as `MappedRwLockWriteGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the locked data. + #[inline] + pub fn try_map(s: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + { + let raw = s.raw; + let data = match f(unsafe { &mut *s.data }) { + Some(data) => data, + None => return Err(s), + }; + mem::forget(s); + Ok(MappedRwLockWriteGuard { + raw, + data, + marker: PhantomData, + }) + } +} + +impl<'a, R: RawRwLockDowngrade + 'a, T: ?Sized + 'a> MappedRwLockWriteGuard<'a, R, T> { + /// Atomically downgrades a write lock into a read lock without allowing any + /// writers to take exclusive access of the lock in the meantime. + /// + /// Note that if there are any writers currently waiting to take the lock + /// then other readers may not be able to acquire the lock even if it was + /// downgraded. + pub fn downgrade(s: Self) -> MappedRwLockReadGuard<'a, R, T> { + s.raw.downgrade(); + let raw = s.raw; + let data = s.data; + mem::forget(s); + MappedRwLockReadGuard { + raw, + data, + marker: PhantomData, + } + } +} + +impl<'a, R: RawRwLockFair + 'a, T: ?Sized + 'a> MappedRwLockWriteGuard<'a, R, T> { + /// Unlocks the `RwLock` using a fair unlock protocol. + /// + /// By default, `RwLock` is unfair and allow the current thread to re-lock + /// the `RwLock` before another has the chance to acquire the lock, even if + /// that thread has been blocked on the `RwLock` for a long time. This is + /// the default because it allows much higher throughput as it avoids + /// forcing a context switch on every `RwLock` unlock. This can result in one + /// thread acquiring a `RwLock` many more times than other threads. + /// + /// However in some cases it can be beneficial to ensure fairness by forcing + /// the lock to pass on to a waiting thread if there is one. This is done by + /// using this method instead of dropping the `MappedRwLockWriteGuard` normally. + #[inline] + pub fn unlock_fair(s: Self) { + s.raw.unlock_exclusive_fair(); + mem::forget(s); + } +} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Deref for MappedRwLockWriteGuard<'a, R, T> { + type Target = T; + #[inline] + fn deref(&self) -> &T { + unsafe { &*self.data } + } +} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> DerefMut for MappedRwLockWriteGuard<'a, R, T> { + #[inline] + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *self.data } + } +} + +impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Drop for MappedRwLockWriteGuard<'a, R, T> { + #[inline] + fn drop(&mut self) { + self.raw.unlock_exclusive(); + } +} + +#[cfg(feature = "owning_ref")] +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress + for MappedRwLockWriteGuard<'a, R, T> +{} diff --git a/third_party/cargo/vendor/log-0.4.8/.cargo-checksum.json b/third_party/cargo/vendor/log-0.4.8/.cargo-checksum.json new file mode 100644 index 0000000..c9cef5d --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"4a384a648f3c5f9deed5463bbcdb92cf95dfe86d755767c0c21140d0539c1243","Cargo.toml":"cde739d8e087cc2515bc06d8ce327648606575e6dd51b74fb0ffd6a329381ba1","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"0a6436eede658249802b63f1e693b28c9f80a2da2697bb80a2677e6c253c3a7d","build.rs":"16a49ad8a5b11a610382f904c72435ce3201b0807c584128c7e61fbb59c76b09","src/kv/error.rs":"296f6af53062a4526bb75eb4dbf955c75aed3b6332c260dc5bd7f0bc68c2d8c7","src/kv/key.rs":"68077f9ad149b28ccdeacd9e95c44c292b68d7fa0823aac5e022e2f3df6120e6","src/kv/mod.rs":"3397573933689b11ca5ad526193166c1e4f665e5692c38cd8fdb63a5aa61f7bf","src/kv/source.rs":"3783ac96b54e24fe6525f9e3cec91425800267f842704d947fea27ee344025a2","src/kv/value/impls.rs":"c8d4cb4e746e7b5a6e1f1993145c2b5309ac556f7ffc757fb80bb10b89bfa40d","src/kv/value/internal.rs":"b7e7d94d018d0207dfb30350a2ce916dc124c48c2e056e7637c159132c707a59","src/kv/value/mod.rs":"a4732af6fb9b3fad8ddf9dd5f9da90689eb9023984ff1f455f871ed32fde4aef","src/kv/value/test.rs":"99e0b87dd8822e7f148a3acfd1dd050718e2aee3ecd9314849076bf043a0a3e9","src/lib.rs":"c594c4a71bff2118e120c9c64e1e2e866dc76489af007965b6c67e57bf1a1797","src/macros.rs":"68cbe1a49a3ac846d6b80d291f427a70dbad0f57dac8beecac7449723293bd99","src/serde.rs":"4677851fba9d43adcddeb94c416af9e06eb70d4fb86e2840256e1edfc4638fef","tests/filters.rs":"90cae6653ba6dc3a462bab2a0b96cb66d5d21882492118bfd6999c0baff1b0e5"},"package":"14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"} \ No newline at end of file diff --git a/third_party/cargo/vendor/log-0.4.8/BUILD b/third_party/cargo/vendor/log-0.4.8/BUILD new file mode 100644 index 0000000..1b9070f --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "MIT OR Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted +# Unsupported target "filters" with type "test" omitted + +rust_library( + name = "log", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/cfg-if-0.1.10:cfg_if", + ], + rustc_flags = [ + "--cap-lints=allow", + "--cfg=atomic_cas", + ], + version = "0.4.8", + crate_features = [ + "std", + ], +) + diff --git a/third_party/cargo/vendor/log-0.4.8/CHANGELOG.md b/third_party/cargo/vendor/log-0.4.8/CHANGELOG.md new file mode 100644 index 0000000..e04562b --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/CHANGELOG.md @@ -0,0 +1,145 @@ +# Change Log + +## [Unreleased] + +## [0.4.8] - 2019-07-28 + +### New + +* Support attempting to get `Record` fields as static strings. + +## [0.4.7] - 2019-07-06 + +### New + +* Support for embedded environments with thread-unsafe initialization. +* Initial unstable support for capturing structured data under the `kv_unstable` +feature gate. This new API doesn't affect existing users and may change in future +patches (so those changes may not appear in the changelog until it stabilizes). + +### Improved + +* Docs for using `log` with the 2018 edition. +* Error messages for macros missing arguments. + +## [0.4.6] - 2018-10-27 + +### Improved + +* Support 2018-style macro import for the `log_enabled!` macro. + +## [0.4.5] - 2018-09-03 + +### Improved + +* Make `log`'s internal helper macros less likely to conflict with user-defined + macros. + +## [0.4.4] - 2018-08-17 + +### Improved + +* Support 2018-style imports of the log macros. + +## [0.4.3] - 2018-06-29 + +### Improved + +* More code generation improvements. + +## [0.4.2] - 2018-06-05 + +### Improved + +* Log invocations now generate less code. + +### Fixed + +* Example Logger implementations now properly set the max log level. + +## [0.4.1] - 2017-12-30 + +### Fixed + +* Some doc links were fixed. + +## [0.4.0] - 2017-12-24 + +The changes in this release include cleanup of some obscure functionality and a more robust public +API designed to support bridges to other logging systems, and provide more flexibility to new +features in the future. + +### Compatibility + +Vast portions of the Rust ecosystem use the 0.3.x release series of log, and we don't want to force +the community to go through the pain of upgrading every crate to 0.4.x at the exact same time. Along +with 0.4.0, we've published a new 0.3.9 release which acts as a "shim" over 0.4.0. This will allow +crates using either version to coexist without losing messages from one side or the other. + +There is one caveat - a log message generated by a crate using 0.4.x but consumed by a logging +implementation using 0.3.x will not have a file name or module path. Applications affected by this +can upgrade their logging implementations to one using 0.4.x to avoid losing this information. The +other direction does not lose any information, fortunately! + +**TL;DR** Libraries should feel comfortable upgrading to 0.4.0 without treating that as a breaking +change. Applications may need to update their logging implementation (e.g. env-logger) to a newer +version using log 0.4.x to avoid losing module and file information. + +### New + +* The crate is now `no_std` by default. +* `Level` and `LevelFilter` now implement `Serialize` and `Deserialize` when the `serde` feature is + enabled. +* The `Record` and `Metadata` types can now be constructed by third-party code via a builder API. +* The `logger` free function returns a reference to the logger implementation. This, along with the + ability to construct `Record`s, makes it possible to bridge from another logging framework to + this one without digging into the private internals of the crate. The standard `error!` `warn!`, + etc, macros now exclusively use the public API of the crate rather than "secret" internal APIs. +* `Log::flush` has been added to allow crates to tell the logging implementation to ensure that all + "in flight" log events have been persisted. This can be used, for example, just before an + application exits to ensure that asynchronous log sinks finish their work. + +### Removed + +* The `shutdown` and `shutdown_raw` functions have been removed. Supporting shutdown significantly + complicated the implementation and imposed a performance cost on each logging operation. +* The `log_panics` function and its associated `nightly` Cargo feature have been removed. Use the + [log-panics](https://crates.io/crates/log-panics) instead. + +### Changed + +* The `Log` prefix has been removed from type names. For example, `LogLevelFilter` is now + `LevelFilter`, and `LogRecord` is now `Record`. +* The `MaxLogLevelFilter` object has been removed in favor of a `set_max_level` free function. +* The `set_logger` free functions have been restructured. The logger is now directly passed to the + functions rather than a closure which returns the logger. `set_logger` now takes a `&'static + Log` and is usable in `no_std` contexts in place of the old `set_logger_raw`. `set_boxed_logger` + is a convenience function which takes a `Box` but otherwise acts like `set_logger`. It + requires the `std` feature. +* The `file` and `module_path` values in `Record` no longer have the `'static` lifetime to support + integration with other logging frameworks that don't provide a `'static` lifetime for the + equivalent values. +* The `file`, `line`, and `module_path` values in `Record` are now `Option`s to support integration + with other logging frameworks that don't provide those values. + +### In the Future + +* We're looking to add support for *structured* logging - the inclusion of extra key-value pairs of + information in a log event in addition to the normal string message. This should be able to be + added in a backwards compatible manner to the 0.4.x series when the design is worked out. + +## Older + +Look at the [release tags] for information about older releases. + +[Unreleased]: https://github.com/rust-lang-nursery/log/compare/0.4.8...HEAD +[0.4.8]: https://github.com/rust-lang-nursery/log/compare/0.4.7...0.4.8 +[0.4.7]: https://github.com/rust-lang-nursery/log/compare/0.4.6...0.4.7 +[0.4.6]: https://github.com/rust-lang-nursery/log/compare/0.4.5...0.4.6 +[0.4.5]: https://github.com/rust-lang-nursery/log/compare/0.4.4...0.4.5 +[0.4.4]: https://github.com/rust-lang-nursery/log/compare/0.4.3...0.4.4 +[0.4.3]: https://github.com/rust-lang-nursery/log/compare/0.4.2...0.4.3 +[0.4.2]: https://github.com/rust-lang-nursery/log/compare/0.4.1...0.4.2 +[0.4.1]: https://github.com/rust-lang-nursery/log/compare/0.4.0...0.4.1 +[0.4.0]: https://github.com/rust-lang-nursery/log/compare/0.3.8...0.4.0 +[release tags]: https://github.com/rust-lang-nursery/log/releases diff --git a/third_party/cargo/vendor/log-0.4.8/Cargo.toml b/third_party/cargo/vendor/log-0.4.8/Cargo.toml new file mode 100644 index 0000000..146060f --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/Cargo.toml @@ -0,0 +1,71 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "log" +version = "0.4.8" +authors = ["The Rust Project Developers"] +build = "build.rs" +exclude = ["rfcs/**/*", "/.travis.yml", "/appveyor.yml"] +description = "A lightweight logging facade for Rust\n" +documentation = "https://docs.rs/log" +readme = "README.md" +keywords = ["logging"] +categories = ["development-tools::debugging"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/log" +[package.metadata.docs.rs] +features = ["std", "serde", "kv_unstable_sval"] + +[[test]] +name = "filters" +harness = false +[dependencies.cfg-if] +version = "0.1.2" + +[dependencies.serde] +version = "1.0" +optional = true +default-features = false + +[dependencies.sval] +version = "0.4.2" +optional = true +default-features = false +[dev-dependencies.serde_test] +version = "1.0" + +[dev-dependencies.sval] +version = "0.4.2" +features = ["test"] + +[features] +kv_unstable = [] +kv_unstable_sval = ["kv_unstable", "sval/fmt"] +max_level_debug = [] +max_level_error = [] +max_level_info = [] +max_level_off = [] +max_level_trace = [] +max_level_warn = [] +release_max_level_debug = [] +release_max_level_error = [] +release_max_level_info = [] +release_max_level_off = [] +release_max_level_trace = [] +release_max_level_warn = [] +std = [] +[badges.appveyor] +repository = "alexcrichton/log" + +[badges.travis-ci] +repository = "rust-lang-nursery/log" diff --git a/third_party/cargo/vendor/log-0.4.8/LICENSE-APACHE b/third_party/cargo/vendor/log-0.4.8/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/log-0.4.8/LICENSE-MIT b/third_party/cargo/vendor/log-0.4.8/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/log-0.4.8/README.md b/third_party/cargo/vendor/log-0.4.8/README.md new file mode 100644 index 0000000..5fbcc97 --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/README.md @@ -0,0 +1,86 @@ +log +=== + +A Rust library providing a lightweight logging *facade*. + +[![Build Status](https://travis-ci.com/rust-lang-nursery/log.svg?branch=master)](https://travis-ci.com/rust-lang-nursery/log) +[![Build status](https://ci.appveyor.com/api/projects/status/nopdjmmjt45xcrki?svg=true)](https://ci.appveyor.com/project/alexcrichton/log) +[![Latest version](https://img.shields.io/crates/v/log.svg)](https://crates.io/crates/log) +[![Documentation](https://docs.rs/log/badge.svg)](https://docs.rs/log) +![License](https://img.shields.io/crates/l/log.svg) + +* [`log` documentation](https://docs.rs/log) + +A logging facade provides a single logging API that abstracts over the actual +logging implementation. Libraries can use the logging API provided by this +crate, and the consumer of those libraries can choose the logging +implementation that is most suitable for its use case. + + +## Minimum supported `rustc` + +`1.16.0+` + +This version is explicitly tested in CI and may be bumped in any release as needed. Maintaining compatibility with older compilers is a priority though, so the bar for bumping the minimum supported version is set very high. Any changes to the supported minimum version will be called out in the release notes. + +## Usage + +## In libraries + +Libraries should link only to the `log` crate, and use the provided macros to +log whatever information will be useful to downstream consumers: + +```toml +[dependencies] +log = "0.4" +``` + +```rust +use log::{info, trace, warn}; + +pub fn shave_the_yak(yak: &mut Yak) { + trace!("Commencing yak shaving"); + + loop { + match find_a_razor() { + Ok(razor) => { + info!("Razor located: {}", razor); + yak.shave(razor); + break; + } + Err(err) => { + warn!("Unable to locate a razor: {}, retrying", err); + } + } + } +} +``` + +## In executables + +In order to produce log output, executables have to use a logger implementation compatible with the facade. +There are many available implementations to chose from, here are some of the most popular ones: + +* Simple minimal loggers: + * [`env_logger`](https://docs.rs/env_logger/*/env_logger/) + * [`simple_logger`](https://github.com/borntyping/rust-simple_logger) + * [`simplelog`](https://github.com/drakulix/simplelog.rs) + * [`pretty_env_logger`](https://docs.rs/pretty_env_logger/*/pretty_env_logger/) + * [`stderrlog`](https://docs.rs/stderrlog/*/stderrlog/) + * [`flexi_logger`](https://docs.rs/flexi_logger/*/flexi_logger/) +* Complex configurable frameworks: + * [`log4rs`](https://docs.rs/log4rs/*/log4rs/) + * [`fern`](https://docs.rs/fern/*/fern/) +* Adaptors for other facilities: + * [`syslog`](https://docs.rs/syslog/*/syslog/) + * [`slog-stdlog`](https://docs.rs/slog-stdlog/*/slog_stdlog/) + * [`android_log`](https://docs.rs/android_log/*/android_log/) +* For WebAssembly binaries: + * [`console_log`](https://docs.rs/console_log/*/console_log/) + +Executables should choose a logger implementation and initialize it early in the +runtime of the program. Logger implementations will typically include a +function to do this. Any log messages generated before the logger is +initialized will be ignored. + +The executable itself may use the `log` crate to log as well. diff --git a/third_party/cargo/vendor/log-0.4.8/build.rs b/third_party/cargo/vendor/log-0.4.8/build.rs new file mode 100644 index 0000000..6717bf0 --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/build.rs @@ -0,0 +1,14 @@ +//! This build script detects target platforms that lack proper support for +//! atomics and sets `cfg` flags accordingly. + +use std::env; + +fn main() { + let target = env::var("TARGET").unwrap(); + + if !target.starts_with("thumbv6") { + println!("cargo:rustc-cfg=atomic_cas"); + } + + println!("cargo:rerun-if-changed=build.rs"); +} diff --git a/third_party/cargo/vendor/log-0.4.8/src/kv/error.rs b/third_party/cargo/vendor/log-0.4.8/src/kv/error.rs new file mode 100644 index 0000000..0f5652f --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/kv/error.rs @@ -0,0 +1,88 @@ +use std::fmt; + +/// An error encountered while working with structured data. +#[derive(Debug)] +pub struct Error { + inner: Inner +} + +#[derive(Debug)] +enum Inner { + #[cfg(feature = "std")] + Boxed(std_support::BoxedError), + Msg(&'static str), + Fmt, +} + +impl Error { + /// Create an error from a message. + pub fn msg(msg: &'static str) -> Self { + Error { + inner: Inner::Msg(msg), + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use self::Inner::*; + match &self.inner { + #[cfg(feature = "std")] + &Boxed(ref err) => err.fmt(f), + &Msg(ref msg) => msg.fmt(f), + &Fmt => fmt::Error.fmt(f), + } + } +} + +impl From for Error { + fn from(_: fmt::Error) -> Self { + Error { + inner: Inner::Fmt, + } + } +} + +impl From for fmt::Error { + fn from(_: Error) -> Self { + fmt::Error + } +} + +#[cfg(feature = "std")] +mod std_support { + use super::*; + use std::{error, io}; + + pub(super) type BoxedError = Box; + + impl Error { + /// Create an error from a standard error type. + pub fn boxed(err: E) -> Self + where + E: Into, + { + Error { + inner: Inner::Boxed(err.into()) + } + } + } + + impl error::Error for Error { + fn description(&self) -> &str { + "key values error" + } + } + + impl From for Error { + fn from(err: io::Error) -> Self { + Error::boxed(err) + } + } + + impl From for io::Error { + fn from(err: Error) -> Self { + io::Error::new(io::ErrorKind::Other, err) + } + } +} diff --git a/third_party/cargo/vendor/log-0.4.8/src/kv/key.rs b/third_party/cargo/vendor/log-0.4.8/src/kv/key.rs new file mode 100644 index 0000000..82f1e85 --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/kv/key.rs @@ -0,0 +1,143 @@ +//! Structured keys. + +use std::fmt; +use std::cmp; +use std::hash; +use std::borrow::Borrow; + +/// A type that can be converted into a [`Key`](struct.Key.html). +pub trait ToKey { + /// Perform the conversion. + fn to_key(&self) -> Key; +} + +impl<'a, T> ToKey for &'a T +where + T: ToKey + ?Sized, +{ + fn to_key(&self) -> Key { + (**self).to_key() + } +} + +impl<'k> ToKey for Key<'k> { + fn to_key(&self) -> Key { + Key { + key: self.key, + } + } +} + +impl ToKey for str { + fn to_key(&self) -> Key { + Key::from_str(self) + } +} + +/// A key in a structured key-value pair. +#[derive(Clone)] +pub struct Key<'k> { + key: &'k str, +} + +impl<'k> Key<'k> { + /// Get a key from a borrowed string. + pub fn from_str(key: &'k str) -> Self { + Key { + key: key, + } + } + + /// Get a borrowed string from this key. + pub fn as_str(&self) -> &str { + self.key + } +} + +impl<'k> fmt::Debug for Key<'k> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.key.fmt(f) + } +} + +impl<'k> fmt::Display for Key<'k> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.key.fmt(f) + } +} + +impl<'k> hash::Hash for Key<'k> { + fn hash(&self, state: &mut H) + where + H: hash::Hasher, + { + self.as_str().hash(state) + } +} + +impl<'k, 'ko> PartialEq> for Key<'k> { + fn eq(&self, other: &Key<'ko>) -> bool { + self.as_str().eq(other.as_str()) + } +} + +impl<'k> Eq for Key<'k> {} + +impl<'k, 'ko> PartialOrd> for Key<'k> { + fn partial_cmp(&self, other: &Key<'ko>) -> Option { + self.as_str().partial_cmp(other.as_str()) + } +} + +impl<'k> Ord for Key<'k> { + fn cmp(&self, other: &Self) -> cmp::Ordering { + self.as_str().cmp(other.as_str()) + } +} + +impl<'k> AsRef for Key<'k> { + fn as_ref(&self) -> &str { + self.as_str() + } +} + +impl<'k> Borrow for Key<'k> { + fn borrow(&self) -> &str { + self.as_str() + } +} + +impl<'k> From<&'k str> for Key<'k> { + fn from(s: &'k str) -> Self { + Key::from_str(s) + } +} + +#[cfg(feature = "std")] +mod std_support { + use super::*; + + use std::borrow::Cow; + + impl ToKey for String { + fn to_key(&self) -> Key { + Key::from_str(self) + } + } + + impl<'a> ToKey for Cow<'a, str> { + fn to_key(&self) -> Key { + Key::from_str(self) + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn key_from_string() { + assert_eq!("a key", Key::from_str("a key").as_str()); + } +} diff --git a/third_party/cargo/vendor/log-0.4.8/src/kv/mod.rs b/third_party/cargo/vendor/log-0.4.8/src/kv/mod.rs new file mode 100644 index 0000000..17226b4 --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/kv/mod.rs @@ -0,0 +1,23 @@ +//! **UNSTABLE:** Structured key-value pairs. +//! +//! This module is unstable and breaking changes may be made +//! at any time. See [the tracking issue](https://github.com/rust-lang-nursery/log/issues/328) +//! for more details. +//! +//! Add the `kv_unstable` feature to your `Cargo.toml` to enable +//! this module: +//! +//! ```toml +//! [dependencies.log] +//! features = ["kv_unstable"] +//! ``` + +mod error; +mod source; +mod key; +pub mod value; + +pub use self::error::Error; +pub use self::source::{Source, Visitor}; +pub use self::key::{Key, ToKey}; +pub use self::value::{Value, ToValue}; diff --git a/third_party/cargo/vendor/log-0.4.8/src/kv/source.rs b/third_party/cargo/vendor/log-0.4.8/src/kv/source.rs new file mode 100644 index 0000000..0538c14 --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/kv/source.rs @@ -0,0 +1,396 @@ +//! Sources for key-value pairs. + +use std::fmt; +use kv::{Error, Key, ToKey, Value, ToValue}; + +/// A source of key-value pairs. +/// +/// The source may be a single pair, a set of pairs, or a filter over a set of pairs. +/// Use the [`Visitor`](trait.Visitor.html) trait to inspect the structured data +/// in a source. +pub trait Source { + /// Visit key-value pairs. + /// + /// A source doesn't have to guarantee any ordering or uniqueness of key-value pairs. + /// If the given visitor returns an error then the source may early-return with it, + /// even if there are more key-value pairs. + /// + /// # Implementation notes + /// + /// A source should yield the same key-value pairs to a subsequent visitor unless + /// that visitor itself fails. + fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error>; + + /// Get the value for a given key. + /// + /// If the key appears multiple times in the source then which key is returned + /// is implementation specific. + /// + /// # Implementation notes + /// + /// A source that can provide a more efficient implementation of this method + /// should override it. + fn get<'v>(&'v self, key: Key) -> Option> { + struct Get<'k, 'v> { + key: Key<'k>, + found: Option>, + } + + impl<'k, 'kvs> Visitor<'kvs> for Get<'k, 'kvs> { + fn visit_pair(&mut self, key: Key<'kvs>, value: Value<'kvs>) -> Result<(), Error> { + if self.key == key { + self.found = Some(value); + } + + Ok(()) + } + } + + let mut get = Get { + key, + found: None, + }; + + let _ = self.visit(&mut get); + get.found + } + + /// Count the number of key-value pairs that can be visited. + /// + /// # Implementation notes + /// + /// A source that knows the number of key-value pairs upfront may provide a more + /// efficient implementation. + /// + /// A subsequent call to `visit` should yield the same number of key-value pairs + /// to the visitor, unless that visitor fails part way through. + fn count(&self) -> usize { + struct Count(usize); + + impl<'kvs> Visitor<'kvs> for Count { + fn visit_pair(&mut self, _: Key<'kvs>, _: Value<'kvs>) -> Result<(), Error> { + self.0 += 1; + + Ok(()) + } + } + + let mut count = Count(0); + let _ = self.visit(&mut count); + count.0 + } +} + +impl<'a, T> Source for &'a T +where + T: Source + ?Sized, +{ + fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error> { + Source::visit(&**self, visitor) + } + + fn get<'v>(&'v self, key: Key) -> Option> { + Source::get(&**self, key) + } + + fn count(&self) -> usize { + Source::count(&**self) + } +} + +impl Source for (K, V) +where + K: ToKey, + V: ToValue, +{ + fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error> { + visitor.visit_pair(self.0.to_key(), self.1.to_value()) + } + + fn get<'v>(&'v self, key: Key) -> Option> { + if self.0.to_key() == key { + Some(self.1.to_value()) + } else { + None + } + } + + fn count(&self) -> usize { + 1 + } +} + +impl Source for [S] +where + S: Source, +{ + fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error> { + for source in self { + source.visit(visitor)?; + } + + Ok(()) + } + + fn count(&self) -> usize { + self.len() + } +} + +impl Source for Option +where + S: Source, +{ + fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error> { + if let Some(ref source) = *self { + source.visit(visitor)?; + } + + Ok(()) + } + + fn count(&self) -> usize { + self.as_ref().map(Source::count).unwrap_or(0) + } +} + +/// A visitor for the key-value pairs in a [`Source`](trait.Source.html). +pub trait Visitor<'kvs> { + /// Visit a key-value pair. + fn visit_pair(&mut self, key: Key<'kvs>, value: Value<'kvs>) -> Result<(), Error>; +} + +impl<'a, 'kvs, T> Visitor<'kvs> for &'a mut T +where + T: Visitor<'kvs> + ?Sized, +{ + fn visit_pair(&mut self, key: Key<'kvs>, value: Value<'kvs>) -> Result<(), Error> { + (**self).visit_pair(key, value) + } +} + +impl<'a, 'b: 'a, 'kvs> Visitor<'kvs> for fmt::DebugMap<'a, 'b> { + fn visit_pair(&mut self, key: Key<'kvs>, value: Value<'kvs>) -> Result<(), Error> { + self.entry(&key, &value); + Ok(()) + } +} + +impl<'a, 'b: 'a, 'kvs> Visitor<'kvs> for fmt::DebugList<'a, 'b> { + fn visit_pair(&mut self, key: Key<'kvs>, value: Value<'kvs>) -> Result<(), Error> { + self.entry(&(key, value)); + Ok(()) + } +} + +impl<'a, 'b: 'a, 'kvs> Visitor<'kvs> for fmt::DebugSet<'a, 'b> { + fn visit_pair(&mut self, key: Key<'kvs>, value: Value<'kvs>) -> Result<(), Error> { + self.entry(&(key, value)); + Ok(()) + } +} + +impl<'a, 'b: 'a, 'kvs> Visitor<'kvs> for fmt::DebugTuple<'a, 'b> { + fn visit_pair(&mut self, key: Key<'kvs>, value: Value<'kvs>) -> Result<(), Error> { + self.field(&key); + self.field(&value); + Ok(()) + } +} + +#[cfg(feature = "std")] +mod std_support { + use super::*; + use std::borrow::Borrow; + use std::collections::{BTreeMap, HashMap}; + use std::hash::{BuildHasher, Hash}; + + impl Source for Box + where + S: Source + ?Sized, + { + fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error> { + Source::visit(&**self, visitor) + } + + fn get<'v>(&'v self, key: Key) -> Option> { + Source::get(&**self, key) + } + + fn count(&self) -> usize { + Source::count(&**self) + } + } + + impl Source for Vec + where + S: Source, + { + fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error> { + Source::visit(&**self, visitor) + } + + fn get<'v>(&'v self, key: Key) -> Option> { + Source::get(&**self, key) + } + + fn count(&self) -> usize { + Source::count(&**self) + } + } + + impl<'kvs, V> Visitor<'kvs> for Box + where + V: Visitor<'kvs> + ?Sized, + { + fn visit_pair(&mut self, key: Key<'kvs>, value: Value<'kvs>) -> Result<(), Error> { + (**self).visit_pair(key, value) + } + } + + impl Source for HashMap + where + K: ToKey + Borrow + Eq + Hash, + V: ToValue, + S: BuildHasher, + { + fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error> { + for (key, value) in self { + visitor.visit_pair(key.to_key(), value.to_value())?; + } + Ok(()) + } + + fn get<'v>(&'v self, key: Key) -> Option> { + HashMap::get(self, key.as_str()).map(|v| v.to_value()) + } + + fn count(&self) -> usize { + self.len() + } + } + + impl Source for BTreeMap + where + K: ToKey + Borrow + Ord, + V: ToValue, + { + fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error> { + for (key, value) in self { + visitor.visit_pair(key.to_key(), value.to_value())?; + } + Ok(()) + } + + fn get<'v>(&'v self, key: Key) -> Option> { + BTreeMap::get(self, key.as_str()).map(|v| v.to_value()) + } + + fn count(&self) -> usize { + self.len() + } + } + + #[cfg(test)] + mod tests { + use super::*; + use kv::value::test::Token; + use std::collections::{BTreeMap, HashMap}; + + #[test] + fn count() { + assert_eq!(1, Source::count(&Box::new(("a", 1)))); + assert_eq!(2, Source::count(&vec![("a", 1), ("b", 2)])); + } + + #[test] + fn get() { + let source = vec![("a", 1), ("b", 2), ("a", 1)]; + assert_eq!( + Token::I64(1), + Source::get(&source, Key::from_str("a")).unwrap().to_token() + ); + + let source = Box::new(Option::None::<(&str, i32)>); + assert!(Source::get(&source, Key::from_str("a")).is_none()); + } + + #[test] + fn hash_map() { + let mut map = HashMap::new(); + map.insert("a", 1); + map.insert("b", 2); + + assert_eq!(2, Source::count(&map)); + assert_eq!( + Token::I64(1), + Source::get(&map, Key::from_str("a")).unwrap().to_token() + ); + } + + #[test] + fn btree_map() { + let mut map = BTreeMap::new(); + map.insert("a", 1); + map.insert("b", 2); + + assert_eq!(2, Source::count(&map)); + assert_eq!( + Token::I64(1), + Source::get(&map, Key::from_str("a")).unwrap().to_token() + ); + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use kv::value::test::Token; + + #[test] + fn source_is_object_safe() { + fn _check(_: &Source) {} + } + + #[test] + fn visitor_is_object_safe() { + fn _check(_: &Visitor) {} + } + + #[test] + fn count() { + struct OnePair { + key: &'static str, + value: i32, + } + + impl Source for OnePair { + fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error> { + visitor.visit_pair(self.key.to_key(), self.value.to_value()) + } + } + + assert_eq!(1, Source::count(&("a", 1))); + assert_eq!(2, Source::count(&[("a", 1), ("b", 2)] as &[_])); + assert_eq!(0, Source::count(&Option::None::<(&str, i32)>)); + assert_eq!(1, Source::count(&OnePair { key: "a", value: 1 })); + } + + #[test] + fn get() { + let source = &[("a", 1), ("b", 2), ("a", 1)] as &[_]; + assert_eq!( + Token::I64(1), + Source::get(source, Key::from_str("a")).unwrap().to_token() + ); + assert_eq!( + Token::I64(2), + Source::get(source, Key::from_str("b")).unwrap().to_token() + ); + assert!(Source::get(&source, Key::from_str("c")).is_none()); + + let source = Option::None::<(&str, i32)>; + assert!(Source::get(&source, Key::from_str("a")).is_none()); + } +} diff --git a/third_party/cargo/vendor/log-0.4.8/src/kv/value/impls.rs b/third_party/cargo/vendor/log-0.4.8/src/kv/value/impls.rs new file mode 100644 index 0000000..ea18146 --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/kv/value/impls.rs @@ -0,0 +1,269 @@ +use std::fmt; + +use super::{ToValue, Value, Primitive}; + +impl ToValue for usize { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: usize) -> Self { + Value::from_primitive(Primitive::Unsigned(value as u64)) + } +} + +impl ToValue for isize { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: isize) -> Self { + Value::from_primitive(Primitive::Signed(value as i64)) + } +} + +impl ToValue for u8 { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: u8) -> Self { + Value::from_primitive(Primitive::Unsigned(value as u64)) + } +} + +impl ToValue for u16 { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: u16) -> Self { + Value::from_primitive(Primitive::Unsigned(value as u64)) + } +} + +impl ToValue for u32 { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: u32) -> Self { + Value::from_primitive(Primitive::Unsigned(value as u64)) + } +} + +impl ToValue for u64 { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: u64) -> Self { + Value::from_primitive(Primitive::Unsigned(value)) + } +} + +impl ToValue for i8 { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: i8) -> Self { + Value::from_primitive(Primitive::Signed(value as i64)) + } +} + +impl ToValue for i16 { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: i16) -> Self { + Value::from_primitive(Primitive::Signed(value as i64)) + } +} + +impl ToValue for i32 { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: i32) -> Self { + Value::from_primitive(Primitive::Signed(value as i64)) + } +} + +impl ToValue for i64 { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: i64) -> Self { + Value::from_primitive(Primitive::Signed(value)) + } +} + +impl ToValue for f32 { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: f32) -> Self { + Value::from_primitive(Primitive::Float(value as f64)) + } +} + +impl ToValue for f64 { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: f64) -> Self { + Value::from_primitive(Primitive::Float(value)) + } +} + +impl ToValue for bool { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: bool) -> Self { + Value::from_primitive(Primitive::Bool(value)) + } +} + +impl ToValue for char { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From for Value<'v> { + fn from(value: char) -> Self { + Value::from_primitive(Primitive::Char(value)) + } +} + +impl<'v> ToValue for &'v str { + fn to_value(&self) -> Value { + Value::from(*self) + } +} + +impl<'v> From<&'v str> for Value<'v> { + fn from(value: &'v str) -> Self { + Value::from_primitive(Primitive::Str(value)) + } +} + +impl ToValue for () { + fn to_value(&self) -> Value { + Value::from_primitive(Primitive::None) + } +} + +impl ToValue for Option +where + T: ToValue, +{ + fn to_value(&self) -> Value { + match *self { + Some(ref value) => value.to_value(), + None => Value::from_primitive(Primitive::None), + } + } +} + +impl<'v> ToValue for fmt::Arguments<'v> { + fn to_value(&self) -> Value { + Value::from_debug(self) + } +} + +#[cfg(feature = "std")] +mod std_support { + use super::*; + + use std::borrow::Cow; + + impl ToValue for Box + where + T: ToValue + ?Sized, + { + fn to_value(&self) -> Value { + (**self).to_value() + } + } + + impl ToValue for String { + fn to_value(&self) -> Value { + Value::from_primitive(Primitive::Str(&*self)) + } + } + + impl<'v> ToValue for Cow<'v, str> { + fn to_value(&self) -> Value { + Value::from_primitive(Primitive::Str(&*self)) + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use kv::value::test::Token; + + #[test] + fn test_to_value_display() { + assert_eq!(42u64.to_value().to_string(), "42"); + assert_eq!(42i64.to_value().to_string(), "42"); + assert_eq!(42.01f64.to_value().to_string(), "42.01"); + assert_eq!(true.to_value().to_string(), "true"); + assert_eq!('a'.to_value().to_string(), "'a'"); + assert_eq!(format_args!("a {}", "value").to_value().to_string(), "a value"); + assert_eq!("a loong string".to_value().to_string(), "\"a loong string\""); + assert_eq!(Some(true).to_value().to_string(), "true"); + assert_eq!(().to_value().to_string(), "None"); + assert_eq!(Option::None::.to_value().to_string(), "None"); + } + + #[test] + fn test_to_value_structured() { + assert_eq!(42u64.to_value().to_token(), Token::U64(42)); + assert_eq!(42i64.to_value().to_token(), Token::I64(42)); + assert_eq!(42.01f64.to_value().to_token(), Token::F64(42.01)); + assert_eq!(true.to_value().to_token(), Token::Bool(true)); + assert_eq!('a'.to_value().to_token(), Token::Char('a')); + assert_eq!(format_args!("a {}", "value").to_value().to_token(), Token::Str("a value".into())); + assert_eq!("a loong string".to_value().to_token(), Token::Str("a loong string".into())); + assert_eq!(Some(true).to_value().to_token(), Token::Bool(true)); + assert_eq!(().to_value().to_token(), Token::None); + assert_eq!(Option::None::.to_value().to_token(), Token::None); + } +} diff --git a/third_party/cargo/vendor/log-0.4.8/src/kv/value/internal.rs b/third_party/cargo/vendor/log-0.4.8/src/kv/value/internal.rs new file mode 100644 index 0000000..5f01a31 --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/kv/value/internal.rs @@ -0,0 +1,264 @@ +use std::fmt; + +use super::{Fill, Slot, Error}; +use kv; + +// `Visitor` is an internal API for visiting the structure of a value. +// It's not intended to be public (at this stage). + +/// A container for a structured value for a specific kind of visitor. +#[derive(Clone, Copy)] +pub(super) enum Inner<'v> { + /// A simple primitive value that can be copied without allocating. + Primitive(Primitive<'v>), + /// A value that can be filled. + Fill(&'v Fill), + /// A debuggable value. + Debug(&'v fmt::Debug), + /// A displayable value. + Display(&'v fmt::Display), + + #[cfg(feature = "kv_unstable_sval")] + /// A structured value from `sval`. + Sval(&'v sval_support::Value), +} + +impl<'v> Inner<'v> { + pub(super) fn visit(&self, visitor: &mut Visitor) -> Result<(), Error> { + match *self { + Inner::Primitive(value) => match value { + Primitive::Signed(value) => visitor.i64(value), + Primitive::Unsigned(value) => visitor.u64(value), + Primitive::Float(value) => visitor.f64(value), + Primitive::Bool(value) => visitor.bool(value), + Primitive::Char(value) => visitor.char(value), + Primitive::Str(value) => visitor.str(value), + Primitive::None => visitor.none(), + }, + Inner::Fill(value) => value.fill(&mut Slot::new(visitor)), + Inner::Debug(value) => visitor.debug(value), + Inner::Display(value) => visitor.display(value), + + #[cfg(feature = "kv_unstable_sval")] + Inner::Sval(value) => visitor.sval(value), + } + } +} + +/// The internal serialization contract. +pub(super) trait Visitor { + fn debug(&mut self, v: &fmt::Debug) -> Result<(), Error>; + fn display(&mut self, v: &fmt::Display) -> Result<(), Error> { + self.debug(&format_args!("{}", v)) + } + + fn u64(&mut self, v: u64) -> Result<(), Error>; + fn i64(&mut self, v: i64) -> Result<(), Error>; + fn f64(&mut self, v: f64) -> Result<(), Error>; + fn bool(&mut self, v: bool) -> Result<(), Error>; + fn char(&mut self, v: char) -> Result<(), Error>; + fn str(&mut self, v: &str) -> Result<(), Error>; + fn none(&mut self) -> Result<(), Error>; + + #[cfg(feature = "kv_unstable_sval")] + fn sval(&mut self, v: &sval_support::Value) -> Result<(), Error>; +} + +#[derive(Clone, Copy)] +pub(super) enum Primitive<'v> { + Signed(i64), + Unsigned(u64), + Float(f64), + Bool(bool), + Char(char), + Str(&'v str), + None, +} + +mod fmt_support { + use super::*; + + impl<'v> kv::Value<'v> { + /// Get a value from a debuggable type. + pub fn from_debug(value: &'v T) -> Self + where + T: fmt::Debug, + { + kv::Value { + inner: Inner::Debug(value), + } + } + + /// Get a value from a displayable type. + pub fn from_display(value: &'v T) -> Self + where + T: fmt::Display, + { + kv::Value { + inner: Inner::Display(value), + } + } + } + + impl<'v> fmt::Debug for kv::Value<'v> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.visit(&mut FmtVisitor(f))?; + + Ok(()) + } + } + + impl<'v> fmt::Display for kv::Value<'v> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.visit(&mut FmtVisitor(f))?; + + Ok(()) + } + } + + struct FmtVisitor<'a, 'b: 'a>(&'a mut fmt::Formatter<'b>); + + impl<'a, 'b: 'a> Visitor for FmtVisitor<'a, 'b> { + fn debug(&mut self, v: &fmt::Debug) -> Result<(), Error> { + v.fmt(self.0)?; + + Ok(()) + } + + fn u64(&mut self, v: u64) -> Result<(), Error> { + self.debug(&format_args!("{:?}", v)) + } + + fn i64(&mut self, v: i64) -> Result<(), Error> { + self.debug(&format_args!("{:?}", v)) + } + + fn f64(&mut self, v: f64) -> Result<(), Error> { + self.debug(&format_args!("{:?}", v)) + } + + fn bool(&mut self, v: bool) -> Result<(), Error> { + self.debug(&format_args!("{:?}", v)) + } + + fn char(&mut self, v: char) -> Result<(), Error> { + self.debug(&format_args!("{:?}", v)) + } + + fn str(&mut self, v: &str) -> Result<(), Error> { + self.debug(&format_args!("{:?}", v)) + } + + fn none(&mut self) -> Result<(), Error> { + self.debug(&format_args!("None")) + } + + #[cfg(feature = "kv_unstable_sval")] + fn sval(&mut self, v: &sval_support::Value) -> Result<(), Error> { + sval_support::fmt(self.0, v) + } + } +} + +#[cfg(feature = "kv_unstable_sval")] +pub(super) mod sval_support { + use super::*; + + extern crate sval; + + impl<'v> kv::Value<'v> { + /// Get a value from a structured type. + pub fn from_sval(value: &'v T) -> Self + where + T: sval::Value, + { + kv::Value { + inner: Inner::Sval(value), + } + } + } + + impl<'v> sval::Value for kv::Value<'v> { + fn stream(&self, s: &mut sval::value::Stream) -> sval::value::Result { + self.visit(&mut SvalVisitor(s)).map_err(Error::into_sval)?; + + Ok(()) + } + } + + pub(in kv::value) use self::sval::Value; + + pub(super) fn fmt(f: &mut fmt::Formatter, v: &sval::Value) -> Result<(), Error> { + sval::fmt::debug(f, v)?; + Ok(()) + } + + impl Error { + fn from_sval(_: sval::value::Error) -> Self { + Error::msg("`sval` serialization failed") + } + + fn into_sval(self) -> sval::value::Error { + sval::value::Error::msg("`sval` serialization failed") + } + } + + struct SvalVisitor<'a, 'b: 'a>(&'a mut sval::value::Stream<'b>); + + impl<'a, 'b: 'a> Visitor for SvalVisitor<'a, 'b> { + fn debug(&mut self, v: &fmt::Debug) -> Result<(), Error> { + self.0.fmt(format_args!("{:?}", v)).map_err(Error::from_sval) + } + + fn u64(&mut self, v: u64) -> Result<(), Error> { + self.0.u64(v).map_err(Error::from_sval) + } + + fn i64(&mut self, v: i64) -> Result<(), Error> { + self.0.i64(v).map_err(Error::from_sval) + } + + fn f64(&mut self, v: f64) -> Result<(), Error> { + self.0.f64(v).map_err(Error::from_sval) + } + + fn bool(&mut self, v: bool) -> Result<(), Error> { + self.0.bool(v).map_err(Error::from_sval) + } + + fn char(&mut self, v: char) -> Result<(), Error> { + self.0.char(v).map_err(Error::from_sval) + } + + fn str(&mut self, v: &str) -> Result<(), Error> { + self.0.str(v).map_err(Error::from_sval) + } + + fn none(&mut self) -> Result<(), Error> { + self.0.none().map_err(Error::from_sval) + } + + fn sval(&mut self, v: &sval::Value) -> Result<(), Error> { + self.0.any(v).map_err(Error::from_sval) + } + } + + #[cfg(test)] + mod tests { + use super::*; + use kv::value::test::Token; + + #[test] + fn test_from_sval() { + assert_eq!(kv::Value::from_sval(&42u64).to_token(), Token::Sval); + } + + #[test] + fn test_sval_structured() { + let value = kv::Value::from(42u64); + let expected = vec![sval::test::Token::Unsigned(42)]; + + assert_eq!(sval::test::tokens(value), expected); + } + } +} diff --git a/third_party/cargo/vendor/log-0.4.8/src/kv/value/mod.rs b/third_party/cargo/vendor/log-0.4.8/src/kv/value/mod.rs new file mode 100644 index 0000000..1695afb --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/kv/value/mod.rs @@ -0,0 +1,155 @@ +//! Structured values. + +use std::fmt; + +mod internal; +mod impls; + +#[cfg(test)] +pub(in kv) mod test; + +pub use kv::Error; + +use self::internal::{Inner, Visitor, Primitive}; + +/// A type that can be converted into a [`Value`](struct.Value.html). +pub trait ToValue { + /// Perform the conversion. + fn to_value(&self) -> Value; +} + +impl<'a, T> ToValue for &'a T +where + T: ToValue + ?Sized, +{ + fn to_value(&self) -> Value { + (**self).to_value() + } +} + +impl<'v> ToValue for Value<'v> { + fn to_value(&self) -> Value { + Value { + inner: self.inner, + } + } +} + +/// A type that requires extra work to convert into a [`Value`](struct.Value.html). +/// +/// This trait is a more advanced initialization API than [`ToValue`](trait.ToValue.html). +/// It's intended for erased values coming from other logging frameworks that may need +/// to perform extra work to determine the concrete type to use. +pub trait Fill { + /// Fill a value. + fn fill(&self, slot: &mut Slot) -> Result<(), Error>; +} + +impl<'a, T> Fill for &'a T +where + T: Fill + ?Sized, +{ + fn fill(&self, slot: &mut Slot) -> Result<(), Error> { + (**self).fill(slot) + } +} + +/// A value slot to fill using the [`Fill`](trait.Fill.html) trait. +pub struct Slot<'a> { + filled: bool, + visitor: &'a mut Visitor, +} + +impl<'a> fmt::Debug for Slot<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Slot").finish() + } +} + +impl<'a> Slot<'a> { + fn new(visitor: &'a mut Visitor) -> Self { + Slot { + visitor, + filled: false, + } + } + + /// Fill the slot with a value. + /// + /// The given value doesn't need to satisfy any particular lifetime constraints. + /// + /// # Panics + /// + /// Calling `fill` more than once will panic. + pub fn fill(&mut self, value: Value) -> Result<(), Error> { + assert!(!self.filled, "the slot has already been filled"); + self.filled = true; + + value.visit(self.visitor) + } +} + +/// A value in a structured key-value pair. +pub struct Value<'v> { + inner: Inner<'v>, +} + +impl<'v> Value<'v> { + /// Get a value from an internal `Visit`. + fn from_primitive(value: Primitive<'v>) -> Self { + Value { + inner: Inner::Primitive(value), + } + } + + /// Get a value from a fillable slot. + pub fn from_fill(value: &'v T) -> Self + where + T: Fill, + { + Value { + inner: Inner::Fill(value), + } + } + + fn visit(&self, visitor: &mut Visitor) -> Result<(), Error> { + self.inner.visit(visitor) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn fill_value() { + struct TestFill; + + impl Fill for TestFill { + fn fill(&self, slot: &mut Slot) -> Result<(), Error> { + let dbg: &fmt::Debug = &1; + + slot.fill(Value::from_debug(&dbg)) + } + } + + assert_eq!("1", Value::from_fill(&TestFill).to_string()); + } + + #[test] + #[should_panic] + fn fill_multiple_times_panics() { + struct BadFill; + + impl Fill for BadFill { + fn fill(&self, slot: &mut Slot) -> Result<(), Error> { + slot.fill(42.into())?; + slot.fill(6789.into())?; + + Ok(()) + } + } + + let _ = Value::from_fill(&BadFill).to_string(); + } +} diff --git a/third_party/cargo/vendor/log-0.4.8/src/kv/value/test.rs b/third_party/cargo/vendor/log-0.4.8/src/kv/value/test.rs new file mode 100644 index 0000000..c9c03dc --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/kv/value/test.rs @@ -0,0 +1,81 @@ +// Test support for inspecting Values + +use std::fmt; +use std::str; + +use super::{Value, Error}; +use super::internal; + +#[derive(Debug, PartialEq)] +pub(in kv) enum Token { + U64(u64), + I64(i64), + F64(f64), + Char(char), + Bool(bool), + Str(String), + None, + + #[cfg(feature = "kv_unstable_sval")] + Sval, +} + +#[cfg(test)] +impl<'v> Value<'v> { + pub(in kv) fn to_token(&self) -> Token { + struct TestVisitor(Option); + + impl internal::Visitor for TestVisitor { + fn debug(&mut self, v: &fmt::Debug) -> Result<(), Error> { + self.0 = Some(Token::Str(format!("{:?}", v))); + Ok(()) + } + + fn u64(&mut self, v: u64) -> Result<(), Error> { + self.0 = Some(Token::U64(v)); + Ok(()) + } + + fn i64(&mut self, v: i64) -> Result<(), Error> { + self.0 = Some(Token::I64(v)); + Ok(()) + } + + fn f64(&mut self, v: f64) -> Result<(), Error> { + self.0 = Some(Token::F64(v)); + Ok(()) + } + + fn bool(&mut self, v: bool) -> Result<(), Error> { + self.0 = Some(Token::Bool(v)); + Ok(()) + } + + fn char(&mut self, v: char) -> Result<(), Error> { + self.0 = Some(Token::Char(v)); + Ok(()) + } + + fn str(&mut self, v: &str) -> Result<(), Error> { + self.0 = Some(Token::Str(v.into())); + Ok(()) + } + + fn none(&mut self) -> Result<(), Error> { + self.0 = Some(Token::None); + Ok(()) + } + + #[cfg(feature = "kv_unstable_sval")] + fn sval(&mut self, _: &internal::sval_support::Value) -> Result<(), Error> { + self.0 = Some(Token::Sval); + Ok(()) + } + } + + let mut visitor = TestVisitor(None); + self.visit(&mut visitor).unwrap(); + + visitor.0.unwrap() + } +} diff --git a/third_party/cargo/vendor/log-0.4.8/src/lib.rs b/third_party/cargo/vendor/log-0.4.8/src/lib.rs new file mode 100644 index 0000000..c79219d --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/lib.rs @@ -0,0 +1,1668 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A lightweight logging facade. +//! +//! The `log` crate provides a single logging API that abstracts over the +//! actual logging implementation. Libraries can use the logging API provided +//! by this crate, and the consumer of those libraries can choose the logging +//! implementation that is most suitable for its use case. +//! +//! If no logging implementation is selected, the facade falls back to a "noop" +//! implementation that ignores all log messages. The overhead in this case +//! is very small - just an integer load, comparison and jump. +//! +//! A log request consists of a _target_, a _level_, and a _body_. A target is a +//! string which defaults to the module path of the location of the log request, +//! though that default may be overridden. Logger implementations typically use +//! the target to filter requests based on some user configuration. +//! +//! # Use +//! +//! The basic use of the log crate is through the five logging macros: [`error!`], +//! [`warn!`], [`info!`], [`debug!`] and [`trace!`] +//! where `error!` represents the highest-priority log messages +//! and `trace!` the lowest. The log messages are filtered by configuring +//! the log level to exclude messages with a lower priority. +//! Each of these macros accept format strings similarly to [`println!`]. +//! +//! +//! [`error!`]: ./macro.error.html +//! [`warn!`]: ./macro.warn.html +//! [`info!`]: ./macro.info.html +//! [`debug!`]: ./macro.debug.html +//! [`trace!`]: ./macro.trace.html +//! [`println!`]: https://doc.rust-lang.org/stable/std/macro.println.html +//! +//! ## In libraries +//! +//! Libraries should link only to the `log` crate, and use the provided +//! macros to log whatever information will be useful to downstream consumers. +//! +//! ### Examples +//! +//! ```edition2018 +//! # #[derive(Debug)] pub struct Yak(String); +//! # impl Yak { fn shave(&mut self, _: u32) {} } +//! # fn find_a_razor() -> Result { Ok(1) } +//! use log::{info, warn}; +//! +//! pub fn shave_the_yak(yak: &mut Yak) { +//! info!(target: "yak_events", "Commencing yak shaving for {:?}", yak); +//! +//! loop { +//! match find_a_razor() { +//! Ok(razor) => { +//! info!("Razor located: {}", razor); +//! yak.shave(razor); +//! break; +//! } +//! Err(err) => { +//! warn!("Unable to locate a razor: {}, retrying", err); +//! } +//! } +//! } +//! } +//! # fn main() {} +//! ``` +//! +//! ## In executables +//! +//! Executables should choose a logging implementation and initialize it early in the +//! runtime of the program. Logging implementations will typically include a +//! function to do this. Any log messages generated before +//! the implementation is initialized will be ignored. +//! +//! The executable itself may use the `log` crate to log as well. +//! +//! ### Warning +//! +//! The logging system may only be initialized once. +//! +//! # Available logging implementations +//! +//! In order to produce log output executables have to use +//! a logger implementation compatible with the facade. +//! There are many available implementations to choose from, +//! here are some of the most popular ones: +//! +//! * Simple minimal loggers: +//! * [env_logger] +//! * [simple_logger] +//! * [simplelog] +//! * [pretty_env_logger] +//! * [stderrlog] +//! * [flexi_logger] +//! * Complex configurable frameworks: +//! * [log4rs] +//! * [fern] +//! * Adaptors for other facilities: +//! * [syslog] +//! * [slog-stdlog] +//! +//! # Implementing a Logger +//! +//! Loggers implement the [`Log`] trait. Here's a very basic example that simply +//! logs all messages at the [`Error`][level_link], [`Warn`][level_link] or +//! [`Info`][level_link] levels to stdout: +//! +//! ```edition2018 +//! use log::{Record, Level, Metadata}; +//! +//! struct SimpleLogger; +//! +//! impl log::Log for SimpleLogger { +//! fn enabled(&self, metadata: &Metadata) -> bool { +//! metadata.level() <= Level::Info +//! } +//! +//! fn log(&self, record: &Record) { +//! if self.enabled(record.metadata()) { +//! println!("{} - {}", record.level(), record.args()); +//! } +//! } +//! +//! fn flush(&self) {} +//! } +//! +//! # fn main() {} +//! ``` +//! +//! Loggers are installed by calling the [`set_logger`] function. The maximum +//! log level also needs to be adjusted via the [`set_max_level`] function. The +//! logging facade uses this as an optimization to improve performance of log +//! messages at levels that are disabled. It's important to set it, as it +//! defaults to [`Off`][filter_link], so no log messages will ever be captured! +//! In the case of our example logger, we'll want to set the maximum log level +//! to [`Info`][filter_link], since we ignore any [`Debug`][level_link] or +//! [`Trace`][level_link] level log messages. A logging implementation should +//! provide a function that wraps a call to [`set_logger`] and +//! [`set_max_level`], handling initialization of the logger: +//! +//! ```edition2018 +//! # use log::{Level, Metadata}; +//! # struct SimpleLogger; +//! # impl log::Log for SimpleLogger { +//! # fn enabled(&self, _: &Metadata) -> bool { false } +//! # fn log(&self, _: &log::Record) {} +//! # fn flush(&self) {} +//! # } +//! # fn main() {} +//! use log::{SetLoggerError, LevelFilter}; +//! +//! static LOGGER: SimpleLogger = SimpleLogger; +//! +//! pub fn init() -> Result<(), SetLoggerError> { +//! log::set_logger(&LOGGER) +//! .map(|()| log::set_max_level(LevelFilter::Info)) +//! } +//! ``` +//! +//! Implementations that adjust their configurations at runtime should take care +//! to adjust the maximum log level as well. +//! +//! # Use with `std` +//! +//! `set_logger` requires you to provide a `&'static Log`, which can be hard to +//! obtain if your logger depends on some runtime configuration. The +//! `set_boxed_logger` function is available with the `std` Cargo feature. It is +//! identical to `set_logger` except that it takes a `Box` rather than a +//! `&'static Log`: +//! +//! ```edition2018 +//! # use log::{Level, LevelFilter, Log, SetLoggerError, Metadata}; +//! # struct SimpleLogger; +//! # impl log::Log for SimpleLogger { +//! # fn enabled(&self, _: &Metadata) -> bool { false } +//! # fn log(&self, _: &log::Record) {} +//! # fn flush(&self) {} +//! # } +//! # fn main() {} +//! # #[cfg(feature = "std")] +//! pub fn init() -> Result<(), SetLoggerError> { +//! log::set_boxed_logger(Box::new(SimpleLogger)) +//! .map(|()| log::set_max_level(LevelFilter::Info)) +//! } +//! ``` +//! +//! # Compile time filters +//! +//! Log levels can be statically disabled at compile time via Cargo features. Log invocations at +//! disabled levels will be skipped and will not even be present in the resulting binary unless the +//! log level is specified dynamically. This level is configured separately for release and debug +//! builds. The features are: +//! +//! * `max_level_off` +//! * `max_level_error` +//! * `max_level_warn` +//! * `max_level_info` +//! * `max_level_debug` +//! * `max_level_trace` +//! * `release_max_level_off` +//! * `release_max_level_error` +//! * `release_max_level_warn` +//! * `release_max_level_info` +//! * `release_max_level_debug` +//! * `release_max_level_trace` +//! +//! These features control the value of the `STATIC_MAX_LEVEL` constant. The logging macros check +//! this value before logging a message. By default, no levels are disabled. +//! +//! Libraries should avoid using the max level features because they're global and can't be changed +//! once they're set. +//! +//! For example, a crate can disable trace level logs in debug builds and trace, debug, and info +//! level logs in release builds with the following configuration: +//! +//! ```toml +//! [dependencies] +//! log = { version = "0.4", features = ["max_level_debug", "release_max_level_warn"] } +//! ``` +//! # Crate Feature Flags +//! +//! The following crate feature flags are avaliable in addition to the filters. They are +//! configured in your `Cargo.toml`. +//! +//! * `std` allows use of `std` crate instead of the default `core`. Enables using `std::error` and +//! `set_boxed_logger` functionality. +//! * `serde` enables support for serialization and deserialization of `Level` and `LevelFilter`. +//! +//! ```toml +//! [dependencies] +//! log = { version = "0.4", features = ["std", "serde"] } +//! ``` +//! +//! # Version compatibility +//! +//! The 0.3 and 0.4 versions of the `log` crate are almost entirely compatible. Log messages +//! made using `log` 0.3 will forward transparently to a logger implementation using `log` 0.4. Log +//! messages made using `log` 0.4 will forward to a logger implementation using `log` 0.3, but the +//! module path and file name information associated with the message will unfortunately be lost. +//! +//! [`Log`]: trait.Log.html +//! [level_link]: enum.Level.html +//! [filter_link]: enum.LevelFilter.html +//! [`set_logger`]: fn.set_logger.html +//! [`set_max_level`]: fn.set_max_level.html +//! [`try_set_logger_raw`]: fn.try_set_logger_raw.html +//! [`shutdown_logger_raw`]: fn.shutdown_logger_raw.html +//! [env_logger]: https://docs.rs/env_logger/*/env_logger/ +//! [simple_logger]: https://github.com/borntyping/rust-simple_logger +//! [simplelog]: https://github.com/drakulix/simplelog.rs +//! [pretty_env_logger]: https://docs.rs/pretty_env_logger/*/pretty_env_logger/ +//! [stderrlog]: https://docs.rs/stderrlog/*/stderrlog/ +//! [flexi_logger]: https://docs.rs/flexi_logger/*/flexi_logger/ +//! [syslog]: https://docs.rs/syslog/*/syslog/ +//! [slog-stdlog]: https://docs.rs/slog-stdlog/*/slog_stdlog/ +//! [log4rs]: https://docs.rs/log4rs/*/log4rs/ +//! [fern]: https://docs.rs/fern/*/fern/ + +#![doc( + html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://docs.rs/log/0.4.8" +)] +#![warn(missing_docs)] +#![deny(missing_debug_implementations)] +#![cfg_attr(all(not(feature = "std"), not(test)), no_std)] +// When compiled for the rustc compiler itself we want to make sure that this is +// an unstable crate +#![cfg_attr(rustbuild, feature(staged_api, rustc_private))] +#![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))] + +#[cfg(all(not(feature = "std"), not(test)))] +extern crate core as std; + +#[macro_use] +extern crate cfg_if; + +use std::cmp; +#[cfg(feature = "std")] +use std::error; +use std::fmt; +use std::mem; +use std::str::FromStr; +use std::sync::atomic::{AtomicUsize, Ordering}; + +// FIXME: ATOMIC_USIZE_INIT was deprecated in rust 1.34. Silence the +// deprecation warning until our MSRV >= 1.24, where we can use the +// replacement const fn `AtomicUsize::new` +#[allow(deprecated)] +use std::sync::atomic::ATOMIC_USIZE_INIT; + +#[macro_use] +mod macros; +mod serde; + +#[cfg(feature = "kv_unstable")] +pub mod kv; + +// The LOGGER static holds a pointer to the global logger. It is protected by +// the STATE static which determines whether LOGGER has been initialized yet. +static mut LOGGER: &'static Log = &NopLogger; + +#[allow(deprecated)] +static STATE: AtomicUsize = ATOMIC_USIZE_INIT; + +// There are three different states that we care about: the logger's +// uninitialized, the logger's initializing (set_logger's been called but +// LOGGER hasn't actually been set yet), or the logger's active. +const UNINITIALIZED: usize = 0; +const INITIALIZING: usize = 1; +const INITIALIZED: usize = 2; + +#[allow(deprecated)] +static MAX_LOG_LEVEL_FILTER: AtomicUsize = ATOMIC_USIZE_INIT; + +static LOG_LEVEL_NAMES: [&'static str; 6] = ["OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE"]; + +static SET_LOGGER_ERROR: &'static str = "attempted to set a logger after the logging system \ + was already initialized"; +static LEVEL_PARSE_ERROR: &'static str = + "attempted to convert a string that doesn't match an existing log level"; + +/// An enum representing the available verbosity levels of the logger. +/// +/// Typical usage includes: checking if a certain `Level` is enabled with +/// [`log_enabled!`](macro.log_enabled.html), specifying the `Level` of +/// [`log!`](macro.log.html), and comparing a `Level` directly to a +/// [`LevelFilter`](enum.LevelFilter.html). +#[repr(usize)] +#[derive(Copy, Eq, Debug, Hash)] +pub enum Level { + /// The "error" level. + /// + /// Designates very serious errors. + Error = 1, // This way these line up with the discriminants for LevelFilter below + /// The "warn" level. + /// + /// Designates hazardous situations. + Warn, + /// The "info" level. + /// + /// Designates useful information. + Info, + /// The "debug" level. + /// + /// Designates lower priority information. + Debug, + /// The "trace" level. + /// + /// Designates very low priority, often extremely verbose, information. + Trace, +} + +impl Clone for Level { + #[inline] + fn clone(&self) -> Level { + *self + } +} + +impl PartialEq for Level { + #[inline] + fn eq(&self, other: &Level) -> bool { + *self as usize == *other as usize + } +} + +impl PartialEq for Level { + #[inline] + fn eq(&self, other: &LevelFilter) -> bool { + *self as usize == *other as usize + } +} + +impl PartialOrd for Level { + #[inline] + fn partial_cmp(&self, other: &Level) -> Option { + Some(self.cmp(other)) + } + + #[inline] + fn lt(&self, other: &Level) -> bool { + (*self as usize) < *other as usize + } + + #[inline] + fn le(&self, other: &Level) -> bool { + *self as usize <= *other as usize + } + + #[inline] + fn gt(&self, other: &Level) -> bool { + *self as usize > *other as usize + } + + #[inline] + fn ge(&self, other: &Level) -> bool { + *self as usize >= *other as usize + } +} + +impl PartialOrd for Level { + #[inline] + fn partial_cmp(&self, other: &LevelFilter) -> Option { + Some((*self as usize).cmp(&(*other as usize))) + } + + #[inline] + fn lt(&self, other: &LevelFilter) -> bool { + (*self as usize) < *other as usize + } + + #[inline] + fn le(&self, other: &LevelFilter) -> bool { + *self as usize <= *other as usize + } + + #[inline] + fn gt(&self, other: &LevelFilter) -> bool { + *self as usize > *other as usize + } + + #[inline] + fn ge(&self, other: &LevelFilter) -> bool { + *self as usize >= *other as usize + } +} + +impl Ord for Level { + #[inline] + fn cmp(&self, other: &Level) -> cmp::Ordering { + (*self as usize).cmp(&(*other as usize)) + } +} + +fn ok_or(t: Option, e: E) -> Result { + match t { + Some(t) => Ok(t), + None => Err(e), + } +} + +// Reimplemented here because std::ascii is not available in libcore +fn eq_ignore_ascii_case(a: &str, b: &str) -> bool { + fn to_ascii_uppercase(c: u8) -> u8 { + if c >= b'a' && c <= b'z' { + c - b'a' + b'A' + } else { + c + } + } + + if a.len() == b.len() { + a.bytes() + .zip(b.bytes()) + .all(|(a, b)| to_ascii_uppercase(a) == to_ascii_uppercase(b)) + } else { + false + } +} + +impl FromStr for Level { + type Err = ParseLevelError; + fn from_str(level: &str) -> Result { + ok_or( + LOG_LEVEL_NAMES + .iter() + .position(|&name| eq_ignore_ascii_case(name, level)) + .into_iter() + .filter(|&idx| idx != 0) + .map(|idx| Level::from_usize(idx).unwrap()) + .next(), + ParseLevelError(()), + ) + } +} + +impl fmt::Display for Level { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.pad(LOG_LEVEL_NAMES[*self as usize]) + } +} + +impl Level { + fn from_usize(u: usize) -> Option { + match u { + 1 => Some(Level::Error), + 2 => Some(Level::Warn), + 3 => Some(Level::Info), + 4 => Some(Level::Debug), + 5 => Some(Level::Trace), + _ => None, + } + } + + /// Returns the most verbose logging level. + #[inline] + pub fn max() -> Level { + Level::Trace + } + + /// Converts the `Level` to the equivalent `LevelFilter`. + #[inline] + pub fn to_level_filter(&self) -> LevelFilter { + LevelFilter::from_usize(*self as usize).unwrap() + } +} + +/// An enum representing the available verbosity level filters of the logger. +/// +/// A `LevelFilter` may be compared directly to a [`Level`]. Use this type +/// to get and set the maximum log level with [`max_level()`] and [`set_max_level`]. +/// +/// [`Level`]: enum.Level.html +/// [`max_level()`]: fn.max_level.html +/// [`set_max_level`]: fn.set_max_level.html +#[repr(usize)] +#[derive(Copy, Eq, Debug, Hash)] +pub enum LevelFilter { + /// A level lower than all log levels. + Off, + /// Corresponds to the `Error` log level. + Error, + /// Corresponds to the `Warn` log level. + Warn, + /// Corresponds to the `Info` log level. + Info, + /// Corresponds to the `Debug` log level. + Debug, + /// Corresponds to the `Trace` log level. + Trace, +} + +// Deriving generates terrible impls of these traits + +impl Clone for LevelFilter { + #[inline] + fn clone(&self) -> LevelFilter { + *self + } +} + +impl PartialEq for LevelFilter { + #[inline] + fn eq(&self, other: &LevelFilter) -> bool { + *self as usize == *other as usize + } +} + +impl PartialEq for LevelFilter { + #[inline] + fn eq(&self, other: &Level) -> bool { + other.eq(self) + } +} + +impl PartialOrd for LevelFilter { + #[inline] + fn partial_cmp(&self, other: &LevelFilter) -> Option { + Some(self.cmp(other)) + } + + #[inline] + fn lt(&self, other: &LevelFilter) -> bool { + (*self as usize) < *other as usize + } + + #[inline] + fn le(&self, other: &LevelFilter) -> bool { + *self as usize <= *other as usize + } + + #[inline] + fn gt(&self, other: &LevelFilter) -> bool { + *self as usize > *other as usize + } + + #[inline] + fn ge(&self, other: &LevelFilter) -> bool { + *self as usize >= *other as usize + } +} + +impl PartialOrd for LevelFilter { + #[inline] + fn partial_cmp(&self, other: &Level) -> Option { + Some((*self as usize).cmp(&(*other as usize))) + } + + #[inline] + fn lt(&self, other: &Level) -> bool { + (*self as usize) < *other as usize + } + + #[inline] + fn le(&self, other: &Level) -> bool { + *self as usize <= *other as usize + } + + #[inline] + fn gt(&self, other: &Level) -> bool { + *self as usize > *other as usize + } + + #[inline] + fn ge(&self, other: &Level) -> bool { + *self as usize >= *other as usize + } +} + +impl Ord for LevelFilter { + #[inline] + fn cmp(&self, other: &LevelFilter) -> cmp::Ordering { + (*self as usize).cmp(&(*other as usize)) + } +} + +impl FromStr for LevelFilter { + type Err = ParseLevelError; + fn from_str(level: &str) -> Result { + ok_or( + LOG_LEVEL_NAMES + .iter() + .position(|&name| eq_ignore_ascii_case(name, level)) + .map(|p| LevelFilter::from_usize(p).unwrap()), + ParseLevelError(()), + ) + } +} + +impl fmt::Display for LevelFilter { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.pad(LOG_LEVEL_NAMES[*self as usize]) + } +} + +impl LevelFilter { + fn from_usize(u: usize) -> Option { + match u { + 0 => Some(LevelFilter::Off), + 1 => Some(LevelFilter::Error), + 2 => Some(LevelFilter::Warn), + 3 => Some(LevelFilter::Info), + 4 => Some(LevelFilter::Debug), + 5 => Some(LevelFilter::Trace), + _ => None, + } + } + /// Returns the most verbose logging level filter. + #[inline] + pub fn max() -> LevelFilter { + LevelFilter::Trace + } + + /// Converts `self` to the equivalent `Level`. + /// + /// Returns `None` if `self` is `LevelFilter::Off`. + #[inline] + pub fn to_level(&self) -> Option { + Level::from_usize(*self as usize) + } +} + +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] +enum MaybeStaticStr<'a> { + Static(&'static str), + Borrowed(&'a str), +} + +impl<'a> MaybeStaticStr<'a> { + #[inline] + fn get(&self) -> &'a str { + match *self { + MaybeStaticStr::Static(s) => s, + MaybeStaticStr::Borrowed(s) => s, + } + } +} + +/// The "payload" of a log message. +/// +/// # Use +/// +/// `Record` structures are passed as parameters to the [`log`][method.log] +/// method of the [`Log`] trait. Logger implementors manipulate these +/// structures in order to display log messages. `Record`s are automatically +/// created by the [`log!`] macro and so are not seen by log users. +/// +/// Note that the [`level()`] and [`target()`] accessors are equivalent to +/// `self.metadata().level()` and `self.metadata().target()` respectively. +/// These methods are provided as a convenience for users of this structure. +/// +/// # Example +/// +/// The following example shows a simple logger that displays the level, +/// module path, and message of any `Record` that is passed to it. +/// +/// ```edition2018 +/// struct SimpleLogger; +/// +/// impl log::Log for SimpleLogger { +/// fn enabled(&self, metadata: &log::Metadata) -> bool { +/// true +/// } +/// +/// fn log(&self, record: &log::Record) { +/// if !self.enabled(record.metadata()) { +/// return; +/// } +/// +/// println!("{}:{} -- {}", +/// record.level(), +/// record.target(), +/// record.args()); +/// } +/// fn flush(&self) {} +/// } +/// ``` +/// +/// [method.log]: trait.Log.html#tymethod.log +/// [`Log`]: trait.Log.html +/// [`log!`]: macro.log.html +/// [`level()`]: struct.Record.html#method.level +/// [`target()`]: struct.Record.html#method.target +#[derive(Clone, Debug)] +pub struct Record<'a> { + metadata: Metadata<'a>, + args: fmt::Arguments<'a>, + module_path: Option>, + file: Option>, + line: Option, + #[cfg(feature = "kv_unstable")] + key_values: KeyValues<'a>, +} + +// This wrapper type is only needed so we can +// `#[derive(Debug)]` on `Record`. It also +// provides a useful `Debug` implementation for +// the underlying `Source`. +#[cfg(feature = "kv_unstable")] +#[derive(Clone)] +struct KeyValues<'a>(&'a kv::Source); + +#[cfg(feature = "kv_unstable")] +impl<'a> fmt::Debug for KeyValues<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut visitor = f.debug_map(); + self.0.visit(&mut visitor)?; + visitor.finish() + } +} + +impl<'a> Record<'a> { + /// Returns a new builder. + #[inline] + pub fn builder() -> RecordBuilder<'a> { + RecordBuilder::new() + } + + /// The message body. + #[inline] + pub fn args(&self) -> &fmt::Arguments<'a> { + &self.args + } + + /// Metadata about the log directive. + #[inline] + pub fn metadata(&self) -> &Metadata<'a> { + &self.metadata + } + + /// The verbosity level of the message. + #[inline] + pub fn level(&self) -> Level { + self.metadata.level() + } + + /// The name of the target of the directive. + #[inline] + pub fn target(&self) -> &'a str { + self.metadata.target() + } + + /// The module path of the message. + #[inline] + pub fn module_path(&self) -> Option<&'a str> { + self.module_path.map(|s| s.get()) + } + + /// The module path of the message, if it is a `'static` string. + #[inline] + pub fn module_path_static(&self) -> Option<&'static str> { + match self.module_path { + Some(MaybeStaticStr::Static(s)) => Some(s), + _ => None, + } + } + + /// The source file containing the message. + #[inline] + pub fn file(&self) -> Option<&'a str> { + self.file.map(|s| s.get()) + } + + /// The module path of the message, if it is a `'static` string. + #[inline] + pub fn file_static(&self) -> Option<&'static str> { + match self.file { + Some(MaybeStaticStr::Static(s)) => Some(s), + _ => None, + } + } + + /// The line containing the message. + #[inline] + pub fn line(&self) -> Option { + self.line + } + + /// The structued key-value pairs associated with the message. + #[cfg(feature = "kv_unstable")] + #[inline] + pub fn key_values(&self) -> &kv::Source { + self.key_values.0 + } + + /// Create a new [`Builder`](struct.Builder.html) based on this record. + #[cfg(feature = "kv_unstable")] + #[inline] + pub fn to_builder(&self) -> RecordBuilder { + RecordBuilder { + record: Record { + metadata: Metadata { + level: self.metadata.level, + target: self.metadata.target, + }, + args: self.args, + module_path: self.module_path, + file: self.file, + line: self.line, + key_values: self.key_values.clone(), + } + } + } +} + +/// Builder for [`Record`](struct.Record.html). +/// +/// Typically should only be used by log library creators or for testing and "shim loggers". +/// The `RecordBuilder` can set the different parameters of `Record` object, and returns +/// the created object when `build` is called. +/// +/// # Examples +/// +/// +/// ```edition2018 +/// use log::{Level, Record}; +/// +/// let record = Record::builder() +/// .args(format_args!("Error!")) +/// .level(Level::Error) +/// .target("myApp") +/// .file(Some("server.rs")) +/// .line(Some(144)) +/// .module_path(Some("server")) +/// .build(); +/// ``` +/// +/// Alternatively, use [`MetadataBuilder`](struct.MetadataBuilder.html): +/// +/// ```edition2018 +/// use log::{Record, Level, MetadataBuilder}; +/// +/// let error_metadata = MetadataBuilder::new() +/// .target("myApp") +/// .level(Level::Error) +/// .build(); +/// +/// let record = Record::builder() +/// .metadata(error_metadata) +/// .args(format_args!("Error!")) +/// .line(Some(433)) +/// .file(Some("app.rs")) +/// .module_path(Some("server")) +/// .build(); +/// ``` +#[derive(Debug)] +pub struct RecordBuilder<'a> { + record: Record<'a>, +} + +impl<'a> RecordBuilder<'a> { + /// Construct new `RecordBuilder`. + /// + /// The default options are: + /// + /// - `args`: [`format_args!("")`] + /// - `metadata`: [`Metadata::builder().build()`] + /// - `module_path`: `None` + /// - `file`: `None` + /// - `line`: `None` + /// + /// [`format_args!("")`]: https://doc.rust-lang.org/std/macro.format_args.html + /// [`Metadata::builder().build()`]: struct.MetadataBuilder.html#method.build + #[inline] + pub fn new() -> RecordBuilder<'a> { + #[cfg(feature = "kv_unstable")] + return RecordBuilder { + record: Record { + args: format_args!(""), + metadata: Metadata::builder().build(), + module_path: None, + file: None, + line: None, + key_values: KeyValues(&Option::None::<(kv::Key, kv::Value)>), + }, + }; + + #[cfg(not(feature = "kv_unstable"))] + return RecordBuilder { + record: Record { + args: format_args!(""), + metadata: Metadata::builder().build(), + module_path: None, + file: None, + line: None, + }, + }; + } + + /// Set [`args`](struct.Record.html#method.args). + #[inline] + pub fn args(&mut self, args: fmt::Arguments<'a>) -> &mut RecordBuilder<'a> { + self.record.args = args; + self + } + + /// Set [`metadata`](struct.Record.html#method.metadata). Construct a `Metadata` object with [`MetadataBuilder`](struct.MetadataBuilder.html). + #[inline] + pub fn metadata(&mut self, metadata: Metadata<'a>) -> &mut RecordBuilder<'a> { + self.record.metadata = metadata; + self + } + + /// Set [`Metadata::level`](struct.Metadata.html#method.level). + #[inline] + pub fn level(&mut self, level: Level) -> &mut RecordBuilder<'a> { + self.record.metadata.level = level; + self + } + + /// Set [`Metadata::target`](struct.Metadata.html#method.target) + #[inline] + pub fn target(&mut self, target: &'a str) -> &mut RecordBuilder<'a> { + self.record.metadata.target = target; + self + } + + /// Set [`module_path`](struct.Record.html#method.module_path) + #[inline] + pub fn module_path(&mut self, path: Option<&'a str>) -> &mut RecordBuilder<'a> { + self.record.module_path = path.map(MaybeStaticStr::Borrowed); + self + } + + /// Set [`module_path`](struct.Record.html#method.module_path) to a `'static` string + #[inline] + pub fn module_path_static(&mut self, path: Option<&'static str>) -> &mut RecordBuilder<'a> { + self.record.module_path = path.map(MaybeStaticStr::Static); + self + } + + /// Set [`file`](struct.Record.html#method.file) + #[inline] + pub fn file(&mut self, file: Option<&'a str>) -> &mut RecordBuilder<'a> { + self.record.file = file.map(MaybeStaticStr::Borrowed); + self + } + + /// Set [`file`](struct.Record.html#method.file) to a `'static` string. + #[inline] + pub fn file_static(&mut self, file: Option<&'static str>) -> &mut RecordBuilder<'a> { + self.record.file = file.map(MaybeStaticStr::Static); + self + } + + /// Set [`line`](struct.Record.html#method.line) + #[inline] + pub fn line(&mut self, line: Option) -> &mut RecordBuilder<'a> { + self.record.line = line; + self + } + + /// Set [`key_values`](struct.Record.html#method.key_values) + #[cfg(feature = "kv_unstable")] + #[inline] + pub fn key_values(&mut self, kvs: &'a kv::Source) -> &mut RecordBuilder<'a> { + self.record.key_values = KeyValues(kvs); + self + } + + /// Invoke the builder and return a `Record` + #[inline] + pub fn build(&self) -> Record<'a> { + self.record.clone() + } +} + +/// Metadata about a log message. +/// +/// # Use +/// +/// `Metadata` structs are created when users of the library use +/// logging macros. +/// +/// They are consumed by implementations of the `Log` trait in the +/// `enabled` method. +/// +/// `Record`s use `Metadata` to determine the log message's severity +/// and target. +/// +/// Users should use the `log_enabled!` macro in their code to avoid +/// constructing expensive log messages. +/// +/// # Examples +/// +/// ```edition2018 +/// use log::{Record, Level, Metadata}; +/// +/// struct MyLogger; +/// +/// impl log::Log for MyLogger { +/// fn enabled(&self, metadata: &Metadata) -> bool { +/// metadata.level() <= Level::Info +/// } +/// +/// fn log(&self, record: &Record) { +/// if self.enabled(record.metadata()) { +/// println!("{} - {}", record.level(), record.args()); +/// } +/// } +/// fn flush(&self) {} +/// } +/// +/// # fn main(){} +/// ``` +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] +pub struct Metadata<'a> { + level: Level, + target: &'a str, +} + +impl<'a> Metadata<'a> { + /// Returns a new builder. + #[inline] + pub fn builder() -> MetadataBuilder<'a> { + MetadataBuilder::new() + } + + /// The verbosity level of the message. + #[inline] + pub fn level(&self) -> Level { + self.level + } + + /// The name of the target of the directive. + #[inline] + pub fn target(&self) -> &'a str { + self.target + } +} + +/// Builder for [`Metadata`](struct.Metadata.html). +/// +/// Typically should only be used by log library creators or for testing and "shim loggers". +/// The `MetadataBuilder` can set the different parameters of a `Metadata` object, and returns +/// the created object when `build` is called. +/// +/// # Example +/// +/// ```edition2018 +/// let target = "myApp"; +/// use log::{Level, MetadataBuilder}; +/// let metadata = MetadataBuilder::new() +/// .level(Level::Debug) +/// .target(target) +/// .build(); +/// ``` +#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] +pub struct MetadataBuilder<'a> { + metadata: Metadata<'a>, +} + +impl<'a> MetadataBuilder<'a> { + /// Construct a new `MetadataBuilder`. + /// + /// The default options are: + /// + /// - `level`: `Level::Info` + /// - `target`: `""` + #[inline] + pub fn new() -> MetadataBuilder<'a> { + MetadataBuilder { + metadata: Metadata { + level: Level::Info, + target: "", + }, + } + } + + /// Setter for [`level`](struct.Metadata.html#method.level). + #[inline] + pub fn level(&mut self, arg: Level) -> &mut MetadataBuilder<'a> { + self.metadata.level = arg; + self + } + + /// Setter for [`target`](struct.Metadata.html#method.target). + #[inline] + pub fn target(&mut self, target: &'a str) -> &mut MetadataBuilder<'a> { + self.metadata.target = target; + self + } + + /// Returns a `Metadata` object. + #[inline] + pub fn build(&self) -> Metadata<'a> { + self.metadata.clone() + } +} + +/// A trait encapsulating the operations required of a logger. +pub trait Log: Sync + Send { + /// Determines if a log message with the specified metadata would be + /// logged. + /// + /// This is used by the `log_enabled!` macro to allow callers to avoid + /// expensive computation of log message arguments if the message would be + /// discarded anyway. + fn enabled(&self, metadata: &Metadata) -> bool; + + /// Logs the `Record`. + /// + /// Note that `enabled` is *not* necessarily called before this method. + /// Implementations of `log` should perform all necessary filtering + /// internally. + fn log(&self, record: &Record); + + /// Flushes any buffered records. + fn flush(&self); +} + +// Just used as a dummy initial value for LOGGER +struct NopLogger; + +impl Log for NopLogger { + fn enabled(&self, _: &Metadata) -> bool { + false + } + + fn log(&self, _: &Record) {} + fn flush(&self) {} +} + +/// Sets the global maximum log level. +/// +/// Generally, this should only be called by the active logging implementation. +#[inline] +pub fn set_max_level(level: LevelFilter) { + MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::SeqCst) +} + +/// Returns the current maximum log level. +/// +/// The [`log!`], [`error!`], [`warn!`], [`info!`], [`debug!`], and [`trace!`] macros check +/// this value and discard any message logged at a higher level. The maximum +/// log level is set by the [`set_max_level`] function. +/// +/// [`log!`]: macro.log.html +/// [`error!`]: macro.error.html +/// [`warn!`]: macro.warn.html +/// [`info!`]: macro.info.html +/// [`debug!`]: macro.debug.html +/// [`trace!`]: macro.trace.html +/// [`set_max_level`]: fn.set_max_level.html +#[inline(always)] +pub fn max_level() -> LevelFilter { + unsafe { mem::transmute(MAX_LOG_LEVEL_FILTER.load(Ordering::Relaxed)) } +} + +/// Sets the global logger to a `Box`. +/// +/// This is a simple convenience wrapper over `set_logger`, which takes a +/// `Box` rather than a `&'static Log`. See the documentation for +/// [`set_logger`] for more details. +/// +/// Requires the `std` feature. +/// +/// # Errors +/// +/// An error is returned if a logger has already been set. +/// +/// [`set_logger`]: fn.set_logger.html +#[cfg(all(feature = "std", atomic_cas))] +pub fn set_boxed_logger(logger: Box) -> Result<(), SetLoggerError> { + set_logger_inner(|| unsafe { &*Box::into_raw(logger) }) +} + +/// Sets the global logger to a `&'static Log`. +/// +/// This function may only be called once in the lifetime of a program. Any log +/// events that occur before the call to `set_logger` completes will be ignored. +/// +/// This function does not typically need to be called manually. Logger +/// implementations should provide an initialization method that installs the +/// logger internally. +/// +/// # Availability +/// +/// This method is available even when the `std` feature is disabled. However, +/// it is currently unavailable on `thumbv6` targets, which lack support for +/// some atomic operations which are used by this function. Even on those +/// targets, [`set_logger_racy`] will be available. +/// +/// # Errors +/// +/// An error is returned if a logger has already been set. +/// +/// # Examples +/// +/// ```edition2018 +/// use log::{error, info, warn, Record, Level, Metadata, LevelFilter}; +/// +/// static MY_LOGGER: MyLogger = MyLogger; +/// +/// struct MyLogger; +/// +/// impl log::Log for MyLogger { +/// fn enabled(&self, metadata: &Metadata) -> bool { +/// metadata.level() <= Level::Info +/// } +/// +/// fn log(&self, record: &Record) { +/// if self.enabled(record.metadata()) { +/// println!("{} - {}", record.level(), record.args()); +/// } +/// } +/// fn flush(&self) {} +/// } +/// +/// # fn main(){ +/// log::set_logger(&MY_LOGGER).unwrap(); +/// log::set_max_level(LevelFilter::Info); +/// +/// info!("hello log"); +/// warn!("warning"); +/// error!("oops"); +/// # } +/// ``` +/// +/// [`set_logger_racy`]: fn.set_logger_racy.html +#[cfg(atomic_cas)] +pub fn set_logger(logger: &'static Log) -> Result<(), SetLoggerError> { + set_logger_inner(|| logger) +} + +#[cfg(atomic_cas)] +fn set_logger_inner(make_logger: F) -> Result<(), SetLoggerError> +where + F: FnOnce() -> &'static Log, +{ + unsafe { + match STATE.compare_and_swap(UNINITIALIZED, INITIALIZING, Ordering::SeqCst) { + UNINITIALIZED => { + LOGGER = make_logger(); + STATE.store(INITIALIZED, Ordering::SeqCst); + Ok(()) + } + INITIALIZING => { + while STATE.load(Ordering::SeqCst) == INITIALIZING {} + Err(SetLoggerError(())) + } + _ => Err(SetLoggerError(())), + } + } +} + +/// A thread-unsafe version of [`set_logger`]. +/// +/// This function is available on all platforms, even those that do not have +/// support for atomics that is needed by [`set_logger`]. +/// +/// In almost all cases, [`set_logger`] should be preferred. +/// +/// # Safety +/// +/// This function is only safe to call when no other logger initialization +/// function is called while this function still executes. +/// +/// This can be upheld by (for example) making sure that **there are no other +/// threads**, and (on embedded) that **interrupts are disabled**. +/// +/// It is safe to use other logging functions while this function runs +/// (including all logging macros). +/// +/// [`set_logger`]: fn.set_logger.html +pub unsafe fn set_logger_racy(logger: &'static Log) -> Result<(), SetLoggerError> { + match STATE.load(Ordering::SeqCst) { + UNINITIALIZED => { + LOGGER = logger; + STATE.store(INITIALIZED, Ordering::SeqCst); + Ok(()) + } + INITIALIZING => { + // This is just plain UB, since we were racing another initialization function + unreachable!("set_logger_racy must not be used with other initialization functions") + } + _ => Err(SetLoggerError(())), + } +} + +/// The type returned by [`set_logger`] if [`set_logger`] has already been called. +/// +/// [`set_logger`]: fn.set_logger.html +#[allow(missing_copy_implementations)] +#[derive(Debug)] +pub struct SetLoggerError(()); + +impl fmt::Display for SetLoggerError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.write_str(SET_LOGGER_ERROR) + } +} + +// The Error trait is not available in libcore +#[cfg(feature = "std")] +impl error::Error for SetLoggerError { + fn description(&self) -> &str { + SET_LOGGER_ERROR + } +} + +/// The type returned by [`from_str`] when the string doesn't match any of the log levels. +/// +/// [`from_str`]: https://doc.rust-lang.org/std/str/trait.FromStr.html#tymethod.from_str +#[allow(missing_copy_implementations)] +#[derive(Debug, PartialEq)] +pub struct ParseLevelError(()); + +impl fmt::Display for ParseLevelError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.write_str(LEVEL_PARSE_ERROR) + } +} + +// The Error trait is not available in libcore +#[cfg(feature = "std")] +impl error::Error for ParseLevelError { + fn description(&self) -> &str { + LEVEL_PARSE_ERROR + } +} + +/// Returns a reference to the logger. +/// +/// If a logger has not been set, a no-op implementation is returned. +pub fn logger() -> &'static Log { + unsafe { + if STATE.load(Ordering::SeqCst) != INITIALIZED { + static NOP: NopLogger = NopLogger; + &NOP + } else { + LOGGER + } + } +} + +// WARNING: this is not part of the crate's public API and is subject to change at any time +#[doc(hidden)] +pub fn __private_api_log( + args: fmt::Arguments, + level: Level, + &(target, module_path, file, line): &(&str, &'static str, &'static str, u32), +) { + logger().log( + &Record::builder() + .args(args) + .level(level) + .target(target) + .module_path_static(Some(module_path)) + .file_static(Some(file)) + .line(Some(line)) + .build(), + ); +} + +// WARNING: this is not part of the crate's public API and is subject to change at any time +#[doc(hidden)] +pub fn __private_api_enabled(level: Level, target: &str) -> bool { + logger().enabled(&Metadata::builder().level(level).target(target).build()) +} + +/// The statically resolved maximum log level. +/// +/// See the crate level documentation for information on how to configure this. +/// +/// This value is checked by the log macros, but not by the `Log`ger returned by +/// the [`logger`] function. Code that manually calls functions on that value +/// should compare the level against this value. +/// +/// [`logger`]: fn.logger.html +pub const STATIC_MAX_LEVEL: LevelFilter = MAX_LEVEL_INNER; + +cfg_if! { + if #[cfg(all(not(debug_assertions), feature = "release_max_level_off"))] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Off; + } else if #[cfg(all(not(debug_assertions), feature = "release_max_level_error"))] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Error; + } else if #[cfg(all(not(debug_assertions), feature = "release_max_level_warn"))] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Warn; + } else if #[cfg(all(not(debug_assertions), feature = "release_max_level_info"))] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Info; + } else if #[cfg(all(not(debug_assertions), feature = "release_max_level_debug"))] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Debug; + } else if #[cfg(all(not(debug_assertions), feature = "release_max_level_trace"))] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Trace; + } else if #[cfg(feature = "max_level_off")] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Off; + } else if #[cfg(feature = "max_level_error")] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Error; + } else if #[cfg(feature = "max_level_warn")] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Warn; + } else if #[cfg(feature = "max_level_info")] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Info; + } else if #[cfg(feature = "max_level_debug")] { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Debug; + } else { + const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Trace; + } +} + +#[cfg(test)] +mod tests { + extern crate std; + use super::{Level, LevelFilter, ParseLevelError}; + use tests::std::string::ToString; + + #[test] + fn test_levelfilter_from_str() { + let tests = [ + ("off", Ok(LevelFilter::Off)), + ("error", Ok(LevelFilter::Error)), + ("warn", Ok(LevelFilter::Warn)), + ("info", Ok(LevelFilter::Info)), + ("debug", Ok(LevelFilter::Debug)), + ("trace", Ok(LevelFilter::Trace)), + ("OFF", Ok(LevelFilter::Off)), + ("ERROR", Ok(LevelFilter::Error)), + ("WARN", Ok(LevelFilter::Warn)), + ("INFO", Ok(LevelFilter::Info)), + ("DEBUG", Ok(LevelFilter::Debug)), + ("TRACE", Ok(LevelFilter::Trace)), + ("asdf", Err(ParseLevelError(()))), + ]; + for &(s, ref expected) in &tests { + assert_eq!(expected, &s.parse()); + } + } + + #[test] + fn test_level_from_str() { + let tests = [ + ("OFF", Err(ParseLevelError(()))), + ("error", Ok(Level::Error)), + ("warn", Ok(Level::Warn)), + ("info", Ok(Level::Info)), + ("debug", Ok(Level::Debug)), + ("trace", Ok(Level::Trace)), + ("ERROR", Ok(Level::Error)), + ("WARN", Ok(Level::Warn)), + ("INFO", Ok(Level::Info)), + ("DEBUG", Ok(Level::Debug)), + ("TRACE", Ok(Level::Trace)), + ("asdf", Err(ParseLevelError(()))), + ]; + for &(s, ref expected) in &tests { + assert_eq!(expected, &s.parse()); + } + } + + #[test] + fn test_level_show() { + assert_eq!("INFO", Level::Info.to_string()); + assert_eq!("ERROR", Level::Error.to_string()); + } + + #[test] + fn test_levelfilter_show() { + assert_eq!("OFF", LevelFilter::Off.to_string()); + assert_eq!("ERROR", LevelFilter::Error.to_string()); + } + + #[test] + fn test_cross_cmp() { + assert!(Level::Debug > LevelFilter::Error); + assert!(LevelFilter::Warn < Level::Trace); + assert!(LevelFilter::Off < Level::Error); + } + + #[test] + fn test_cross_eq() { + assert!(Level::Error == LevelFilter::Error); + assert!(LevelFilter::Off != Level::Error); + assert!(Level::Trace == LevelFilter::Trace); + } + + #[test] + fn test_to_level() { + assert_eq!(Some(Level::Error), LevelFilter::Error.to_level()); + assert_eq!(None, LevelFilter::Off.to_level()); + assert_eq!(Some(Level::Debug), LevelFilter::Debug.to_level()); + } + + #[test] + fn test_to_level_filter() { + assert_eq!(LevelFilter::Error, Level::Error.to_level_filter()); + assert_eq!(LevelFilter::Trace, Level::Trace.to_level_filter()); + } + + #[test] + #[cfg(feature = "std")] + fn test_error_trait() { + use super::SetLoggerError; + use std::error::Error; + let e = SetLoggerError(()); + assert_eq!( + e.description(), + "attempted to set a logger after the logging system \ + was already initialized" + ); + } + + #[test] + fn test_metadata_builder() { + use super::MetadataBuilder; + let target = "myApp"; + let metadata_test = MetadataBuilder::new() + .level(Level::Debug) + .target(target) + .build(); + assert_eq!(metadata_test.level(), Level::Debug); + assert_eq!(metadata_test.target(), "myApp"); + } + + #[test] + fn test_metadata_convenience_builder() { + use super::Metadata; + let target = "myApp"; + let metadata_test = Metadata::builder() + .level(Level::Debug) + .target(target) + .build(); + assert_eq!(metadata_test.level(), Level::Debug); + assert_eq!(metadata_test.target(), "myApp"); + } + + #[test] + fn test_record_builder() { + use super::{MetadataBuilder, RecordBuilder}; + let target = "myApp"; + let metadata = MetadataBuilder::new().target(target).build(); + let fmt_args = format_args!("hello"); + let record_test = RecordBuilder::new() + .args(fmt_args) + .metadata(metadata) + .module_path(Some("foo")) + .file(Some("bar")) + .line(Some(30)) + .build(); + assert_eq!(record_test.metadata().target(), "myApp"); + assert_eq!(record_test.module_path(), Some("foo")); + assert_eq!(record_test.file(), Some("bar")); + assert_eq!(record_test.line(), Some(30)); + } + + #[test] + fn test_record_convenience_builder() { + use super::{Metadata, Record}; + let target = "myApp"; + let metadata = Metadata::builder().target(target).build(); + let fmt_args = format_args!("hello"); + let record_test = Record::builder() + .args(fmt_args) + .metadata(metadata) + .module_path(Some("foo")) + .file(Some("bar")) + .line(Some(30)) + .build(); + assert_eq!(record_test.target(), "myApp"); + assert_eq!(record_test.module_path(), Some("foo")); + assert_eq!(record_test.file(), Some("bar")); + assert_eq!(record_test.line(), Some(30)); + } + + #[test] + fn test_record_complete_builder() { + use super::{Level, Record}; + let target = "myApp"; + let record_test = Record::builder() + .module_path(Some("foo")) + .file(Some("bar")) + .line(Some(30)) + .target(target) + .level(Level::Error) + .build(); + assert_eq!(record_test.target(), "myApp"); + assert_eq!(record_test.level(), Level::Error); + assert_eq!(record_test.module_path(), Some("foo")); + assert_eq!(record_test.file(), Some("bar")); + assert_eq!(record_test.line(), Some(30)); + } + + #[test] + #[cfg(feature = "kv_unstable")] + fn test_record_key_values_builder() { + use super::Record; + use kv::{self, Visitor}; + + struct TestVisitor { + seen_pairs: usize, + } + + impl<'kvs> Visitor<'kvs> for TestVisitor { + fn visit_pair( + &mut self, + _: kv::Key<'kvs>, + _: kv::Value<'kvs> + ) -> Result<(), kv::Error> { + self.seen_pairs += 1; + Ok(()) + } + } + + let kvs: &[(&str, i32)] = &[ + ("a", 1), + ("b", 2) + ]; + let record_test = Record::builder() + .key_values(&kvs) + .build(); + + let mut visitor = TestVisitor { + seen_pairs: 0, + }; + + record_test.key_values().visit(&mut visitor).unwrap(); + + assert_eq!(2, visitor.seen_pairs); + } +} diff --git a/third_party/cargo/vendor/log-0.4.8/src/macros.rs b/third_party/cargo/vendor/log-0.4.8/src/macros.rs new file mode 100644 index 0000000..bb40b71 --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/macros.rs @@ -0,0 +1,250 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/// The standard logging macro. +/// +/// This macro will generically log with the specified `Level` and `format!` +/// based argument list. +/// +/// # Examples +/// +/// ```edition2018 +/// use log::{log, Level}; +/// +/// # fn main() { +/// let data = (42, "Forty-two"); +/// let private_data = "private"; +/// +/// log!(Level::Error, "Received errors: {}, {}", data.0, data.1); +/// log!(target: "app_events", Level::Warn, "App warning: {}, {}, {}", +/// data.0, data.1, private_data); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! log { + (target: $target:expr, $lvl:expr, $($arg:tt)+) => ({ + let lvl = $lvl; + if lvl <= $crate::STATIC_MAX_LEVEL && lvl <= $crate::max_level() { + $crate::__private_api_log( + __log_format_args!($($arg)+), + lvl, + &($target, __log_module_path!(), __log_file!(), __log_line!()), + ); + } + }); + ($lvl:expr, $($arg:tt)+) => (log!(target: __log_module_path!(), $lvl, $($arg)+)) +} + +/// Logs a message at the error level. +/// +/// # Examples +/// +/// ```edition2018 +/// use log::error; +/// +/// # fn main() { +/// let (err_info, port) = ("No connection", 22); +/// +/// error!("Error: {} on port {}", err_info, port); +/// error!(target: "app_events", "App Error: {}, Port: {}", err_info, 22); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! error { + (target: $target:expr, $($arg:tt)+) => ( + log!(target: $target, $crate::Level::Error, $($arg)+); + ); + ($($arg:tt)+) => ( + log!($crate::Level::Error, $($arg)+); + ) +} + +/// Logs a message at the warn level. +/// +/// # Examples +/// +/// ```edition2018 +/// use log::warn; +/// +/// # fn main() { +/// let warn_description = "Invalid Input"; +/// +/// warn!("Warning! {}!", warn_description); +/// warn!(target: "input_events", "App received warning: {}", warn_description); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! warn { + (target: $target:expr, $($arg:tt)+) => ( + log!(target: $target, $crate::Level::Warn, $($arg)+); + ); + ($($arg:tt)+) => ( + log!($crate::Level::Warn, $($arg)+); + ) +} + +/// Logs a message at the info level. +/// +/// # Examples +/// +/// ```edition2018 +/// use log::info; +/// +/// # fn main() { +/// # struct Connection { port: u32, speed: f32 } +/// let conn_info = Connection { port: 40, speed: 3.20 }; +/// +/// info!("Connected to port {} at {} Mb/s", conn_info.port, conn_info.speed); +/// info!(target: "connection_events", "Successfull connection, port: {}, speed: {}", +/// conn_info.port, conn_info.speed); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! info { + (target: $target:expr, $($arg:tt)+) => ( + log!(target: $target, $crate::Level::Info, $($arg)+); + ); + ($($arg:tt)+) => ( + log!($crate::Level::Info, $($arg)+); + ) +} + +/// Logs a message at the debug level. +/// +/// # Examples +/// +/// ```edition2018 +/// use log::debug; +/// +/// # fn main() { +/// # struct Position { x: f32, y: f32 } +/// let pos = Position { x: 3.234, y: -1.223 }; +/// +/// debug!("New position: x: {}, y: {}", pos.x, pos.y); +/// debug!(target: "app_events", "New position: x: {}, y: {}", pos.x, pos.y); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! debug { + (target: $target:expr, $($arg:tt)+) => ( + log!(target: $target, $crate::Level::Debug, $($arg)+); + ); + ($($arg:tt)+) => ( + log!($crate::Level::Debug, $($arg)+); + ) +} + +/// Logs a message at the trace level. +/// +/// # Examples +/// +/// ```edition2018 +/// use log::trace; +/// +/// # fn main() { +/// # struct Position { x: f32, y: f32 } +/// let pos = Position { x: 3.234, y: -1.223 }; +/// +/// trace!("Position is: x: {}, y: {}", pos.x, pos.y); +/// trace!(target: "app_events", "x is {} and y is {}", +/// if pos.x >= 0.0 { "positive" } else { "negative" }, +/// if pos.y >= 0.0 { "positive" } else { "negative" }); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! trace { + (target: $target:expr, $($arg:tt)+) => ( + log!(target: $target, $crate::Level::Trace, $($arg)+); + ); + ($($arg:tt)+) => ( + log!($crate::Level::Trace, $($arg)+); + ) +} + +/// Determines if a message logged at the specified level in that module will +/// be logged. +/// +/// This can be used to avoid expensive computation of log message arguments if +/// the message would be ignored anyway. +/// +/// # Examples +/// +/// ```edition2018 +/// use log::Level::Debug; +/// use log::{debug, log_enabled}; +/// +/// # fn foo() { +/// if log_enabled!(Debug) { +/// let data = expensive_call(); +/// debug!("expensive debug data: {} {}", data.x, data.y); +/// } +/// if log_enabled!(target: "Global", Debug) { +/// let data = expensive_call(); +/// debug!(target: "Global", "expensive debug data: {} {}", data.x, data.y); +/// } +/// # } +/// # struct Data { x: u32, y: u32 } +/// # fn expensive_call() -> Data { Data { x: 0, y: 0 } } +/// # fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! log_enabled { + (target: $target:expr, $lvl:expr) => {{ + let lvl = $lvl; + lvl <= $crate::STATIC_MAX_LEVEL + && lvl <= $crate::max_level() + && $crate::__private_api_enabled(lvl, $target) + }}; + ($lvl:expr) => { + log_enabled!(target: __log_module_path!(), $lvl) + }; +} + +// The log macro above cannot invoke format_args directly because it uses +// local_inner_macros. A format_args invocation there would resolve to +// $crate::format_args which does not exist. Instead invoke format_args here +// outside of local_inner_macros so that it resolves (probably) to +// core::format_args or std::format_args. Same for the several macros that +// follow. +// +// This is a workaround until we drop support for pre-1.30 compilers. At that +// point we can remove use of local_inner_macros, use $crate:: when invoking +// local macros, and invoke format_args directly. +#[doc(hidden)] +#[macro_export] +macro_rules! __log_format_args { + ($($args:tt)*) => { + format_args!($($args)*) + }; +} + +#[doc(hidden)] +#[macro_export] +macro_rules! __log_module_path { + () => { + module_path!() + }; +} + +#[doc(hidden)] +#[macro_export] +macro_rules! __log_file { + () => { + file!() + }; +} + +#[doc(hidden)] +#[macro_export] +macro_rules! __log_line { + () => { + line!() + }; +} diff --git a/third_party/cargo/vendor/log-0.4.8/src/serde.rs b/third_party/cargo/vendor/log-0.4.8/src/serde.rs new file mode 100644 index 0000000..efc9f14 --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/src/serde.rs @@ -0,0 +1,329 @@ +#![cfg(feature = "serde")] + +extern crate serde; +use self::serde::de::{ + Deserialize, DeserializeSeed, Deserializer, EnumAccess, Error, Unexpected, VariantAccess, + Visitor, +}; +use self::serde::ser::{Serialize, Serializer}; + +use {Level, LevelFilter, LOG_LEVEL_NAMES}; + +use std::fmt; +use std::str::{self, FromStr}; + +// The Deserialize impls are handwritten to be case insensitive using FromStr. + +impl Serialize for Level { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + Level::Error => serializer.serialize_unit_variant("Level", 0, "ERROR"), + Level::Warn => serializer.serialize_unit_variant("Level", 1, "WARN"), + Level::Info => serializer.serialize_unit_variant("Level", 2, "INFO"), + Level::Debug => serializer.serialize_unit_variant("Level", 3, "DEBUG"), + Level::Trace => serializer.serialize_unit_variant("Level", 4, "TRACE"), + } + } +} + +impl<'de> Deserialize<'de> for Level { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct LevelIdentifier; + + impl<'de> Visitor<'de> for LevelIdentifier { + type Value = Level; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("log level") + } + + fn visit_str(self, s: &str) -> Result + where + E: Error, + { + // Case insensitive. + FromStr::from_str(s).map_err(|_| Error::unknown_variant(s, &LOG_LEVEL_NAMES[1..])) + } + + fn visit_bytes(self, value: &[u8]) -> Result + where + E: Error, + { + let variant = str::from_utf8(value) + .map_err(|_| Error::invalid_value(Unexpected::Bytes(value), &self))?; + + self.visit_str(variant) + } + } + + impl<'de> DeserializeSeed<'de> for LevelIdentifier { + type Value = Level; + + fn deserialize(self, deserializer: D) -> Result + where + D: Deserializer<'de>, + { + deserializer.deserialize_identifier(LevelIdentifier) + } + } + + struct LevelEnum; + + impl<'de> Visitor<'de> for LevelEnum { + type Value = Level; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("log level") + } + + fn visit_enum(self, value: A) -> Result + where + A: EnumAccess<'de>, + { + let (level, variant) = value.variant_seed(LevelIdentifier)?; + // Every variant is a unit variant. + variant.unit_variant()?; + Ok(level) + } + } + + deserializer.deserialize_enum("Level", &LOG_LEVEL_NAMES[1..], LevelEnum) + } +} + +impl Serialize for LevelFilter { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + LevelFilter::Off => serializer.serialize_unit_variant("LevelFilter", 0, "OFF"), + LevelFilter::Error => serializer.serialize_unit_variant("LevelFilter", 1, "ERROR"), + LevelFilter::Warn => serializer.serialize_unit_variant("LevelFilter", 2, "WARN"), + LevelFilter::Info => serializer.serialize_unit_variant("LevelFilter", 3, "INFO"), + LevelFilter::Debug => serializer.serialize_unit_variant("LevelFilter", 4, "DEBUG"), + LevelFilter::Trace => serializer.serialize_unit_variant("LevelFilter", 5, "TRACE"), + } + } +} + +impl<'de> Deserialize<'de> for LevelFilter { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct LevelFilterIdentifier; + + impl<'de> Visitor<'de> for LevelFilterIdentifier { + type Value = LevelFilter; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("log level filter") + } + + fn visit_str(self, s: &str) -> Result + where + E: Error, + { + // Case insensitive. + FromStr::from_str(s).map_err(|_| Error::unknown_variant(s, &LOG_LEVEL_NAMES)) + } + + fn visit_bytes(self, value: &[u8]) -> Result + where + E: Error, + { + let variant = str::from_utf8(value) + .map_err(|_| Error::invalid_value(Unexpected::Bytes(value), &self))?; + + self.visit_str(variant) + } + } + + impl<'de> DeserializeSeed<'de> for LevelFilterIdentifier { + type Value = LevelFilter; + + fn deserialize(self, deserializer: D) -> Result + where + D: Deserializer<'de>, + { + deserializer.deserialize_identifier(LevelFilterIdentifier) + } + } + + struct LevelFilterEnum; + + impl<'de> Visitor<'de> for LevelFilterEnum { + type Value = LevelFilter; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("log level filter") + } + + fn visit_enum(self, value: A) -> Result + where + A: EnumAccess<'de>, + { + let (level_filter, variant) = value.variant_seed(LevelFilterIdentifier)?; + // Every variant is a unit variant. + variant.unit_variant()?; + Ok(level_filter) + } + } + + deserializer.deserialize_enum("LevelFilter", &LOG_LEVEL_NAMES, LevelFilterEnum) + } +} + +#[cfg(test)] +mod tests { + extern crate serde_test; + use self::serde_test::{assert_de_tokens, assert_de_tokens_error, assert_tokens, Token}; + + use {Level, LevelFilter}; + + fn level_token(variant: &'static str) -> Token { + Token::UnitVariant { + name: "Level", + variant: variant, + } + } + + fn level_bytes_tokens(variant: &'static [u8]) -> [Token; 3] { + [ + Token::Enum { name: "Level" }, + Token::Bytes(variant), + Token::Unit, + ] + } + + fn level_filter_token(variant: &'static str) -> Token { + Token::UnitVariant { + name: "LevelFilter", + variant: variant, + } + } + + fn level_filter_bytes_tokens(variant: &'static [u8]) -> [Token; 3] { + [ + Token::Enum { + name: "LevelFilter", + }, + Token::Bytes(variant), + Token::Unit, + ] + } + + #[test] + fn test_level_ser_de() { + let cases = [ + (Level::Error, [level_token("ERROR")]), + (Level::Warn, [level_token("WARN")]), + (Level::Info, [level_token("INFO")]), + (Level::Debug, [level_token("DEBUG")]), + (Level::Trace, [level_token("TRACE")]), + ]; + + for &(s, expected) in &cases { + assert_tokens(&s, &expected); + } + } + + #[test] + fn test_level_case_insensitive() { + let cases = [ + (Level::Error, [level_token("error")]), + (Level::Warn, [level_token("warn")]), + (Level::Info, [level_token("info")]), + (Level::Debug, [level_token("debug")]), + (Level::Trace, [level_token("trace")]), + ]; + + for &(s, expected) in &cases { + assert_de_tokens(&s, &expected); + } + } + + #[test] + fn test_level_de_bytes() { + let cases = [ + (Level::Error, level_bytes_tokens(b"ERROR")), + (Level::Warn, level_bytes_tokens(b"WARN")), + (Level::Info, level_bytes_tokens(b"INFO")), + (Level::Debug, level_bytes_tokens(b"DEBUG")), + (Level::Trace, level_bytes_tokens(b"TRACE")), + ]; + + for &(value, tokens) in &cases { + assert_de_tokens(&value, &tokens); + } + } + + #[test] + fn test_level_de_error() { + let msg = "unknown variant `errorx`, expected one of \ + `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`"; + assert_de_tokens_error::(&[level_token("errorx")], msg); + } + + #[test] + fn test_level_filter_ser_de() { + let cases = [ + (LevelFilter::Off, [level_filter_token("OFF")]), + (LevelFilter::Error, [level_filter_token("ERROR")]), + (LevelFilter::Warn, [level_filter_token("WARN")]), + (LevelFilter::Info, [level_filter_token("INFO")]), + (LevelFilter::Debug, [level_filter_token("DEBUG")]), + (LevelFilter::Trace, [level_filter_token("TRACE")]), + ]; + + for &(s, expected) in &cases { + assert_tokens(&s, &expected); + } + } + + #[test] + fn test_level_filter_case_insensitive() { + let cases = [ + (LevelFilter::Off, [level_filter_token("off")]), + (LevelFilter::Error, [level_filter_token("error")]), + (LevelFilter::Warn, [level_filter_token("warn")]), + (LevelFilter::Info, [level_filter_token("info")]), + (LevelFilter::Debug, [level_filter_token("debug")]), + (LevelFilter::Trace, [level_filter_token("trace")]), + ]; + + for &(s, expected) in &cases { + assert_de_tokens(&s, &expected); + } + } + + #[test] + fn test_level_filter_de_bytes() { + let cases = [ + (LevelFilter::Off, level_filter_bytes_tokens(b"OFF")), + (LevelFilter::Error, level_filter_bytes_tokens(b"ERROR")), + (LevelFilter::Warn, level_filter_bytes_tokens(b"WARN")), + (LevelFilter::Info, level_filter_bytes_tokens(b"INFO")), + (LevelFilter::Debug, level_filter_bytes_tokens(b"DEBUG")), + (LevelFilter::Trace, level_filter_bytes_tokens(b"TRACE")), + ]; + + for &(value, tokens) in &cases { + assert_de_tokens(&value, &tokens); + } + } + + #[test] + fn test_level_filter_de_error() { + let msg = "unknown variant `errorx`, expected one of \ + `OFF`, `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`"; + assert_de_tokens_error::(&[level_filter_token("errorx")], msg); + } +} diff --git a/third_party/cargo/vendor/log-0.4.8/tests/filters.rs b/third_party/cargo/vendor/log-0.4.8/tests/filters.rs new file mode 100644 index 0000000..e4d21a8 --- /dev/null +++ b/third_party/cargo/vendor/log-0.4.8/tests/filters.rs @@ -0,0 +1,72 @@ +#[macro_use] +extern crate log; + +use log::{Level, LevelFilter, Log, Metadata, Record}; +use std::sync::{Arc, Mutex}; + +#[cfg(feature = "std")] +use log::set_boxed_logger; + +#[cfg(not(feature = "std"))] +fn set_boxed_logger(logger: Box) -> Result<(), log::SetLoggerError> { + log::set_logger(unsafe { &*Box::into_raw(logger) }) +} + +struct State { + last_log: Mutex>, +} + +struct Logger(Arc); + +impl Log for Logger { + fn enabled(&self, _: &Metadata) -> bool { + true + } + + fn log(&self, record: &Record) { + *self.0.last_log.lock().unwrap() = Some(record.level()); + } + fn flush(&self) {} +} + +fn main() { + let me = Arc::new(State { + last_log: Mutex::new(None), + }); + let a = me.clone(); + set_boxed_logger(Box::new(Logger(me))).unwrap(); + + test(&a, LevelFilter::Off); + test(&a, LevelFilter::Error); + test(&a, LevelFilter::Warn); + test(&a, LevelFilter::Info); + test(&a, LevelFilter::Debug); + test(&a, LevelFilter::Trace); +} + +fn test(a: &State, filter: LevelFilter) { + log::set_max_level(filter); + error!(""); + last(&a, t(Level::Error, filter)); + warn!(""); + last(&a, t(Level::Warn, filter)); + info!(""); + last(&a, t(Level::Info, filter)); + debug!(""); + last(&a, t(Level::Debug, filter)); + trace!(""); + last(&a, t(Level::Trace, filter)); + + fn t(lvl: Level, filter: LevelFilter) -> Option { + if lvl <= filter { + Some(lvl) + } else { + None + } + } +} + +fn last(state: &State, expected: Option) { + let lvl = state.last_log.lock().unwrap().take(); + assert_eq!(lvl, expected); +} diff --git a/third_party/cargo/vendor/malloc_buf-0.0.6/.cargo-checksum.json b/third_party/cargo/vendor/malloc_buf-0.0.6/.cargo-checksum.json new file mode 100644 index 0000000..70cd125 --- /dev/null +++ b/third_party/cargo/vendor/malloc_buf-0.0.6/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"d87624d9d117489bd49dbaeb70077a0721e00ac2a76eb371faec818a92da5661","src/lib.rs":"1130dacbe045a20c1ea1e65e00976f18eb7513da492b07d538e7b1b5c64b8842"},"package":"62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"} \ No newline at end of file diff --git a/third_party/cargo/vendor/malloc_buf-0.0.6/BUILD b/third_party/cargo/vendor/malloc_buf-0.0.6/BUILD new file mode 100644 index 0000000..0791bf7 --- /dev/null +++ b/third_party/cargo/vendor/malloc_buf-0.0.6/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "malloc_buf", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.0.6", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/malloc_buf-0.0.6/Cargo.toml b/third_party/cargo/vendor/malloc_buf-0.0.6/Cargo.toml new file mode 100644 index 0000000..cfb0c08 --- /dev/null +++ b/third_party/cargo/vendor/malloc_buf-0.0.6/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "malloc_buf" +version = "0.0.6" +authors = ["Steven Sheldon"] + +description = "Structs for handling malloc'd memory passed to Rust." +repository = "https://github.com/SSheldon/malloc_buf" +documentation = "http://ssheldon.github.io/malloc_buf/malloc_buf/" +license = "MIT" + +exclude = [".gitignore"] + +[dependencies] +libc = ">= 0.1, < 0.3" diff --git a/third_party/cargo/vendor/malloc_buf-0.0.6/src/lib.rs b/third_party/cargo/vendor/malloc_buf-0.0.6/src/lib.rs new file mode 100644 index 0000000..24066b6 --- /dev/null +++ b/third_party/cargo/vendor/malloc_buf-0.0.6/src/lib.rs @@ -0,0 +1,95 @@ +extern crate libc; + +use std::marker::PhantomData; +use std::ops::Deref; +use std::slice; +use libc::c_void; + +struct MallocPtr(*mut c_void); + +impl Drop for MallocPtr { + fn drop(&mut self) { + unsafe { + libc::free(self.0); + } + } +} + +/// A type that represents a `malloc`'d chunk of memory. +pub struct MallocBuffer { + ptr: MallocPtr, + len: usize, + items: PhantomData<[T]>, +} + +impl MallocBuffer { + /// Constructs a new `MallocBuffer` for a `malloc`'d buffer + /// with the given length at the given pointer. + /// Returns `None` if the given pointer is null and the length is not 0. + /// + /// When this `MallocBuffer` drops, the buffer will be `free`'d. + /// + /// Unsafe because there must be `len` contiguous, valid instances of `T` + /// at `ptr`. + pub unsafe fn new(ptr: *mut T, len: usize) -> Option> { + if len > 0 && ptr.is_null() { + None + } else { + Some(MallocBuffer { + ptr: MallocPtr(ptr as *mut c_void), + len: len, + items: PhantomData, + }) + } + } +} + +impl Deref for MallocBuffer { + type Target = [T]; + + fn deref(&self) -> &[T] { + let ptr = if self.len == 0 && self.ptr.0.is_null() { + // Even a 0-size slice cannot be null, so just use another pointer + 0x1 as *const T + } else { + self.ptr.0 as *const T + }; + unsafe { + slice::from_raw_parts(ptr, self.len) + } + } +} + +#[cfg(test)] +mod tests { + use std::ptr; + use libc; + + use super::MallocBuffer; + + #[test] + fn test_null_buf() { + let buf = unsafe { + MallocBuffer::::new(ptr::null_mut(), 0).unwrap() + }; + assert!(&*buf == []); + assert!(Some(&*buf) == Some(&[])); + + let buf = unsafe { + MallocBuffer::::new(ptr::null_mut(), 7) + }; + assert!(buf.is_none()); + } + + #[test] + fn test_buf() { + let buf = unsafe { + let ptr = libc::malloc(12) as *mut u32; + *ptr = 1; + *ptr.offset(1) = 2; + *ptr.offset(2) = 3; + MallocBuffer::new(ptr, 3).unwrap() + }; + assert!(&*buf == [1, 2, 3]); + } +} diff --git a/third_party/cargo/vendor/maybe-uninit-2.0.0/.cargo-checksum.json b/third_party/cargo/vendor/maybe-uninit-2.0.0/.cargo-checksum.json new file mode 100644 index 0000000..21adadd --- /dev/null +++ b/third_party/cargo/vendor/maybe-uninit-2.0.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"a4e484fa7295e2a1b69c1faefbf3274acf652c66a6538924e0f6cc58d81c00cf","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0621878e61f0d0fda054bcbe02df75192c28bde1ecc8289cbd86aeba2dd72720","README.md":"2166f8a5c41801089365a655cda7d5e038f9721f0ada1a6bac55eb4d6de8e1c2","build.rs":"8cb7472f84e44c683b3bd590ce1b281eb9fc0d8d6911f7d914473310159ab2fa","src/lib.rs":"c8a4a04cb4114b6d0fa210350d7b6b20636a9cc24ffc3b9576e7219f61d8a7f4","src/maybe_uninit.rs":"c1365ba9745a71d6658f6f4ab8cff63a89743389860e33eacfb817d03a750fde","tests/doesnt_drop.rs":"2dcaf5a5ea84f1c65520c37b1de3b94e2de6ee599d049afb8175376c87c2ae46"},"package":"60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"} \ No newline at end of file diff --git a/third_party/cargo/vendor/maybe-uninit-2.0.0/BUILD b/third_party/cargo/vendor/maybe-uninit-2.0.0/BUILD new file mode 100644 index 0000000..ac50784 --- /dev/null +++ b/third_party/cargo/vendor/maybe-uninit-2.0.0/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "Apache-2.0 OR MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted +# Unsupported target "doesnt_drop" with type "test" omitted + +rust_library( + name = "maybe_uninit", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "2.0.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/maybe-uninit-2.0.0/Cargo.toml b/third_party/cargo/vendor/maybe-uninit-2.0.0/Cargo.toml new file mode 100644 index 0000000..f224562 --- /dev/null +++ b/third_party/cargo/vendor/maybe-uninit-2.0.0/Cargo.toml @@ -0,0 +1,22 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "maybe-uninit" +version = "2.0.0" +authors = ["est31 ", "The Rust Project Developers"] +description = "MaybeUninit for friends of backwards compatibility" +readme = "README.md" +license = "Apache-2.0 OR MIT" +repository = "https://github.com/est31/maybe-uninit" + +[dependencies] diff --git a/third_party/cargo/vendor/maybe-uninit-2.0.0/LICENSE-APACHE b/third_party/cargo/vendor/maybe-uninit-2.0.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/maybe-uninit-2.0.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/maybe-uninit-2.0.0/LICENSE-MIT b/third_party/cargo/vendor/maybe-uninit-2.0.0/LICENSE-MIT new file mode 100644 index 0000000..25597d5 --- /dev/null +++ b/third_party/cargo/vendor/maybe-uninit-2.0.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2010 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/maybe-uninit-2.0.0/README.md b/third_party/cargo/vendor/maybe-uninit-2.0.0/README.md new file mode 100644 index 0000000..ca0ec6e --- /dev/null +++ b/third_party/cargo/vendor/maybe-uninit-2.0.0/README.md @@ -0,0 +1,19 @@ +# maybe-uninit + +Quite often, uses of `std::mem::uninitialized()` end up in unsound code. +Therefore, the `MaybeUninit` union has been added to `std::mem` and `std::mem::uninitialized()` is being deprecated. +However, `MaybeUninit` has been added quite recently. +Sometimes you might want to support older versions of Rust as well. +Here is where `maybe-uninit` comes in: it supports stable Rust versions starting with 1.20.0. + +Sadly, a feature-complete implementation of `MaybeUninit` is not possible on stable Rust. +Therefore, the library offers the guarantees of `MaybeUninit` in a staged fashion: + +* Rust 1.36.0 onward: `MaybeUninit` implementation of Rust stable is being re-exported + +* Rust 1.22.x - 1.35.0: No panicing on uninhabited types, + unsoundness when used with types like `bool` or enums. + However, there is protection from accidentially `Drop`ing e.g. during unwind! + +* Rust 1.20.x - 1.21.x: No support for Copy/Clone of `MaybeUninit`, + even if `T` impls `Copy` or even `Clone`. diff --git a/third_party/cargo/vendor/maybe-uninit-2.0.0/build.rs b/third_party/cargo/vendor/maybe-uninit-2.0.0/build.rs new file mode 100644 index 0000000..ebb9cc8 --- /dev/null +++ b/third_party/cargo/vendor/maybe-uninit-2.0.0/build.rs @@ -0,0 +1,50 @@ +use std::env; +use std::process::Command; +use std::str::FromStr; + +fn main() { + let minor = match rustc_minor_version() { + Some(minor) => minor, + None => return, + }; + if minor >= 22 { + println!("cargo:rustc-cfg=derive_copy"); + } + if minor >= 28 { + println!("cargo:rustc-cfg=repr_transparent"); + } + if minor >= 36 { + println!("cargo:rustc-cfg=native_uninit"); + } + +} + +fn rustc_minor_version() -> Option { + let rustc = env::var_os("RUSTC"); + + let output = rustc.and_then(|rustc| { + Command::new(rustc).arg("--version").output().ok() + }); + + let version = output.and_then(|output| { + String::from_utf8(output.stdout).ok() + }); + + let version = if let Some(version) = version { + version + } else { + return None; + }; + + let mut pieces = version.split('.'); + if pieces.next() != Some("rustc 1") { + return None; + } + + let next = match pieces.next() { + Some(next) => next, + None => return None, + }; + + u32::from_str(next).ok() +} diff --git a/third_party/cargo/vendor/maybe-uninit-2.0.0/src/lib.rs b/third_party/cargo/vendor/maybe-uninit-2.0.0/src/lib.rs new file mode 100644 index 0000000..e6d697b --- /dev/null +++ b/third_party/cargo/vendor/maybe-uninit-2.0.0/src/lib.rs @@ -0,0 +1,10 @@ +#![no_std] + +#[cfg(not(native_uninit))] +mod maybe_uninit; + +#[cfg(not(native_uninit))] +pub use maybe_uninit::MaybeUninit; + +#[cfg(native_uninit)] +pub use core::mem::MaybeUninit; diff --git a/third_party/cargo/vendor/maybe-uninit-2.0.0/src/maybe_uninit.rs b/third_party/cargo/vendor/maybe-uninit-2.0.0/src/maybe_uninit.rs new file mode 100644 index 0000000..02c55ce --- /dev/null +++ b/third_party/cargo/vendor/maybe-uninit-2.0.0/src/maybe_uninit.rs @@ -0,0 +1,594 @@ +//use core::intrinsics; +use core::mem::ManuallyDrop; +use core::ptr; +use core::mem::uninitialized; + +/// A wrapper type to construct uninitialized instances of `T`. +/// +/// # Initialization invariant +/// +/// The compiler, in general, assumes that variables are properly initialized +/// at their respective type. For example, a variable of reference type must +/// be aligned and non-NULL. This is an invariant that must *always* be upheld, +/// even in unsafe code. As a consequence, zero-initializing a variable of reference +/// type causes instantaneous [undefined behavior][ub], no matter whether that reference +/// ever gets used to access memory: +/// +/// ```rust,no_run +/// # extern crate maybe_uninit; +/// # fn main() { +/// use maybe_uninit::MaybeUninit; +/// use std::mem; +/// +/// let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior! +/// // The equivalent code with `MaybeUninit<&i32>`: +/// let x: &i32 = unsafe { MaybeUninit::zeroed().assume_init() }; // undefined behavior! +/// # } +/// ``` +/// +/// This is exploited by the compiler for various optimizations, such as eliding +/// run-time checks and optimizing `enum` layout. +/// +/// Similarly, entirely uninitialized memory may have any content, while a `bool` must +/// always be `true` or `false`. Hence, creating an uninitialized `bool` is undefined behavior: +/// +/// ```rust,no_run +/// # extern crate maybe_uninit; +/// # fn main() { +/// use maybe_uninit::MaybeUninit; +/// use std::mem; +/// +/// let b: bool = unsafe { mem::uninitialized() }; // undefined behavior! +/// // The equivalent code with `MaybeUninit`: +/// let b: bool = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! +/// # } +/// ``` +/// +/// Moreover, uninitialized memory is special in that the compiler knows that +/// it does not have a fixed value. This makes it undefined behavior to have +/// uninitialized data in a variable even if that variable has an integer type, +/// which otherwise can hold any *fixed* bit pattern: +/// +/// ```rust,no_run +/// # extern crate maybe_uninit; +/// # fn main() { +/// use maybe_uninit::MaybeUninit; +/// use std::mem; +/// +/// let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior! +/// // The equivalent code with `MaybeUninit`: +/// let x: i32 = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! +/// # } +/// ``` +/// (Notice that the rules around uninitialized integers are not finalized yet, but +/// until they are, it is advisable to avoid them.) +/// +/// On top of that, remember that most types have additional invariants beyond merely +/// being considered initialized at the type level. For example, a `1`-initialized [`Vec`] +/// is considered initialized because the only requirement the compiler knows about it +/// is that the data pointer must be non-null. Creating such a `Vec` does not cause +/// *immediate* undefined behavior, but will cause undefined behavior with most +/// safe operations (including dropping it). +/// +/// [`Vec`]: ../../std/vec/struct.Vec.html +/// +/// # Examples +/// +/// `MaybeUninit` serves to enable unsafe code to deal with uninitialized data. +/// It is a signal to the compiler indicating that the data here might *not* +/// be initialized: +/// +/// ```rust +/// # extern crate maybe_uninit; +/// # fn main() { +/// use maybe_uninit::MaybeUninit; +/// use std::ptr::write; +/// +/// // Create an explicitly uninitialized reference. The compiler knows that data inside +/// // a `MaybeUninit` may be invalid, and hence this is not UB: +/// let mut x = MaybeUninit::<&i32>::uninit(); +/// // Set it to a valid value. +/// const V: &'static i32 = &0; +/// unsafe { write(x.as_mut_ptr(), V); } +/// // Extract the initialized data -- this is only allowed *after* properly +/// // initializing `x`! +/// let x = unsafe { x.assume_init() }; +/// # } +/// ``` +/// +/// The compiler then knows to not make any incorrect assumptions or optimizations on this code. +/// +/// You can think of `MaybeUninit` as being a bit like `Option` but without +/// any of the run-time tracking and without any of the safety checks. +/// +/// ## out-pointers +/// +/// You can use `MaybeUninit` to implement "out-pointers": instead of returning data +/// from a function, pass it a pointer to some (uninitialized) memory to put the +/// result into. This can be useful when it is important for the caller to control +/// how the memory the result is stored in gets allocated, and you want to avoid +/// unnecessary moves. +/// +/// ``` +/// # extern crate maybe_uninit; +/// # fn main() { +/// use maybe_uninit::MaybeUninit; +/// use std::ptr; +/// +/// unsafe fn make_vec(out: *mut Vec) { +/// // `write` does not drop the old contents, which is important. +/// ptr::write(out, vec![1, 2, 3]); +/// } +/// +/// let mut v = MaybeUninit::uninit(); +/// unsafe { make_vec(v.as_mut_ptr()); } +/// // Now we know `v` is initialized! This also makes sure the vector gets +/// // properly dropped. +/// let v = unsafe { v.assume_init() }; +/// assert_eq!(&v, &[1, 2, 3]); +/// # } +/// ``` +/// +/// ## Initializing an array element-by-element +/// +/// `MaybeUninit` can be used to initialize a large array element-by-element: +/// +/// ``` +/// # extern crate maybe_uninit; +/// # fn main() { +/// use maybe_uninit::MaybeUninit; +/// use std::mem; +/// use std::ptr; +/// +/// let data = { +/// // Create an uninitialized array of `MaybeUninit`. The `assume_init` is +/// // safe because the type we are claiming to have initialized here is a +/// // bunch of `MaybeUninit`s, which do not require initialization. +/// let mut data: [MaybeUninit>; 1000] = unsafe { +/// MaybeUninit::uninit().assume_init() +/// }; +/// +/// // Dropping a `MaybeUninit` does nothing, so if there is a panic during this loop, +/// // we have a memory leak, but there is no memory safety issue. +/// for elem in &mut data[..] { +/// unsafe { ptr::write(elem.as_mut_ptr(), vec![42]); } +/// } +/// +/// // Everything is initialized. Transmute the array to the +/// // initialized type. +/// unsafe { mem::transmute::<_, [Vec; 1000]>(data) } +/// }; +/// +/// assert_eq!(&data[0], &[42]); +/// # } +/// ``` +/// +/// You can also work with partially initialized arrays, which could +/// be found in low-level datastructures. +/// +/// ``` +/// # extern crate maybe_uninit; +/// # fn main() { +/// use maybe_uninit::MaybeUninit; +/// use std::ptr; +/// +/// // Create an uninitialized array of `MaybeUninit`. The `assume_init` is +/// // safe because the type we are claiming to have initialized here is a +/// // bunch of `MaybeUninit`s, which do not require initialization. +/// let mut data: [MaybeUninit; 1000] = unsafe { MaybeUninit::uninit().assume_init() }; +/// // Count the number of elements we have assigned. +/// let mut data_len: usize = 0; +/// +/// for elem in &mut data[0..500] { +/// unsafe { ptr::write(elem.as_mut_ptr(), String::from("hello")); } +/// data_len += 1; +/// } +/// +/// // For each item in the array, drop if we allocated it. +/// for elem in &mut data[0..data_len] { +/// unsafe { ptr::drop_in_place(elem.as_mut_ptr()); } +/// } +/// # } +/// ``` +/// +/// ## Initializing a struct field-by-field +/// +/// There is currently no supported way to create a raw pointer or reference +/// to a field of a struct inside `MaybeUninit`. That means it is not possible +/// to create a struct by calling `MaybeUninit::uninit::()` and then writing +/// to its fields. +/// +/// [ub]: ../../reference/behavior-considered-undefined.html +/// +/// # Layout +/// +/// `MaybeUninit` is guaranteed to have the same size, alignment, and ABI as `T`: +/// +/// ```rust +/// # extern crate maybe_uninit; +/// # #[cfg(not(derive_copy))] fn main() {} +/// # #[cfg(derive_copy)] fn main() { +/// use maybe_uninit::MaybeUninit; +/// use std::mem::{size_of, align_of}; +/// assert_eq!(size_of::>(), size_of::()); +/// assert_eq!(align_of::>(), align_of::()); +/// # } +/// ``` +/// +/// However remember that a type *containing* a `MaybeUninit` is not necessarily the same +/// layout; Rust does not in general guarantee that the fields of a `Foo` have the same order as +/// a `Foo` even if `T` and `U` have the same size and alignment. Furthermore because any bit +/// value is valid for a `MaybeUninit` the compiler can't apply non-zero/niche-filling +/// optimizations, potentially resulting in a larger size: +/// +/// ```no_run +/// # extern crate maybe_uninit; +/// # fn main() { +/// # use maybe_uninit::MaybeUninit; +/// # use std::mem::size_of; +/// assert_eq!(size_of::>(), 1); +/// assert_eq!(size_of::>>(), 2); +/// # } +/// ``` +/// +/// If `T` is FFI-safe, then so is `MaybeUninit`. +/// +/// While `MaybeUninit` is `#[repr(transparent)]` (indicating it guarantees the same size, +/// alignment, and ABI as `T`), this does *not* change any of the previous caveats. `Option` and +/// `Option>` may still have different sizes, and types containing a field of type +/// `T` may be laid out (and sized) differently than if that field were `MaybeUninit`. +/// `MaybeUninit` is a union type, and `#[repr(transparent)]` on unions is unstable (see [the +/// tracking issue](https://github.com/rust-lang/rust/issues/60405)). Over time, the exact +/// guarantees of `#[repr(transparent)]` on unions may evolve, and `MaybeUninit` may or may not +/// remain `#[repr(transparent)]`. That said, `MaybeUninit` will *always* guarantee that it has +/// the same size, alignment, and ABI as `T`; it's just that the way `MaybeUninit` implements that +/// guarantee may evolve. +#[cfg_attr(derive_copy, derive(Copy))] +#[cfg_attr(repr_transparent, repr(transparent))] +#[cfg_attr(not(repr_transparent), repr(C))] +pub struct MaybeUninit { + value: ManuallyDrop, +} + +#[cfg(derive_copy)] +impl Clone for MaybeUninit { + #[inline(always)] + fn clone(&self) -> Self { + // Not calling `T::clone()`, we cannot know if we are initialized enough for that. + *self + } +} + +impl MaybeUninit { + /// Creates a new `MaybeUninit` initialized with the given value. + /// It is safe to call [`assume_init`] on the return value of this function. + /// + /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. + /// It is your responsibility to make sure `T` gets dropped if it got initialized. + /// + /// [`assume_init`]: #method.assume_init + #[inline(always)] + pub fn new(val: T) -> MaybeUninit { + MaybeUninit { value: ManuallyDrop::new(val) } + } + + /// Creates a new `MaybeUninit` in an uninitialized state. + /// + /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. + /// It is your responsibility to make sure `T` gets dropped if it got initialized. + /// + /// See the [type-level documentation][type] for some examples. + /// + /// [type]: union.MaybeUninit.html + #[inline(always)] + pub fn uninit() -> MaybeUninit { + unsafe { MaybeUninit { value: uninitialized() } } + } + + /// Creates a new `MaybeUninit` in an uninitialized state, with the memory being + /// filled with `0` bytes. It depends on `T` whether that already makes for + /// proper initialization. For example, `MaybeUninit::zeroed()` is initialized, + /// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not + /// be null. + /// + /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. + /// It is your responsibility to make sure `T` gets dropped if it got initialized. + /// + /// # Example + /// + /// Correct usage of this function: initializing a struct with zero, where all + /// fields of the struct can hold the bit-pattern 0 as a valid value. + /// + /// ```rust + /// # extern crate maybe_uninit; + /// # fn main() { + /// use maybe_uninit::MaybeUninit; + /// + /// let x = MaybeUninit::<(u8, bool)>::zeroed(); + /// let x = unsafe { x.assume_init() }; + /// assert_eq!(x, (0, false)); + /// # } + /// ``` + /// + /// *Incorrect* usage of this function: initializing a struct with zero, where some fields + /// cannot hold 0 as a valid value. + /// + /// ```rust,no_run + /// # extern crate maybe_uninit; + /// # fn main() { + /// use maybe_uninit::MaybeUninit; + /// + /// enum NotZero { One = 1, Two = 2 }; + /// + /// let x = MaybeUninit::<(u8, NotZero)>::zeroed(); + /// let x = unsafe { x.assume_init() }; + /// // Inside a pair, we create a `NotZero` that does not have a valid discriminant. + /// // This is undefined behavior. + /// # } + /// ``` + #[inline] + pub fn zeroed() -> MaybeUninit { + let mut u = MaybeUninit::::uninit(); + unsafe { + ptr::write_bytes(u.as_mut_ptr(), 0u8, 1); + } + u + } + + /* + /// Sets the value of the `MaybeUninit`. This overwrites any previous value + /// without dropping it, so be careful not to use this twice unless you want to + /// skip running the destructor. For your convenience, this also returns a mutable + /// reference to the (now safely initialized) contents of `self`. + #[unstable(feature = "maybe_uninit_extra", issue = "53491")] + #[inline(always)] + pub fn write(&mut self, val: T) -> &mut T { + unsafe { + self.value = ManuallyDrop::new(val); + self.get_mut() + } + } + */ + + /// Gets a pointer to the contained value. Reading from this pointer or turning it + /// into a reference is undefined behavior unless the `MaybeUninit` is initialized. + /// Writing to memory that this pointer (non-transitively) points to is undefined behavior + /// (except inside an `UnsafeCell`). + /// + /// # Examples + /// + /// Correct usage of this method: + /// + /// ```rust + /// # extern crate maybe_uninit; + /// # fn main() { + /// use maybe_uninit::MaybeUninit; + /// use std::ptr; + /// + /// let mut x = MaybeUninit::>::uninit(); + /// unsafe { ptr::write(x.as_mut_ptr(), vec![0,1,2]); } + /// // Create a reference into the `MaybeUninit`. This is okay because we initialized it. + /// let x_vec = unsafe { &*x.as_ptr() }; + /// assert_eq!(x_vec.len(), 3); + /// # } + /// ``` + /// + /// *Incorrect* usage of this method: + /// + /// ```rust,no_run + /// # extern crate maybe_uninit; + /// # fn main() { + /// use maybe_uninit::MaybeUninit; + /// + /// let x = MaybeUninit::>::uninit(); + /// let x_vec = unsafe { &*x.as_ptr() }; + /// // We have created a reference to an uninitialized vector! This is undefined behavior. + /// # } + /// ``` + /// + /// (Notice that the rules around references to uninitialized data are not finalized yet, but + /// until they are, it is advisable to avoid them.) + #[inline(always)] + pub fn as_ptr(&self) -> *const T { + &*self.value as *const T + } + + /// Gets a mutable pointer to the contained value. Reading from this pointer or turning it + /// into a reference is undefined behavior unless the `MaybeUninit` is initialized. + /// + /// # Examples + /// + /// Correct usage of this method: + /// + /// ```rust + /// # extern crate maybe_uninit; + /// # fn main() { + /// use maybe_uninit::MaybeUninit; + /// use std::ptr; + /// + /// let mut x = MaybeUninit::>::uninit(); + /// unsafe { ptr::write(x.as_mut_ptr(), vec![0,1,2]); } + /// // Create a reference into the `MaybeUninit>`. + /// // This is okay because we initialized it. + /// let x_vec = unsafe { &mut *x.as_mut_ptr() }; + /// x_vec.push(3); + /// assert_eq!(x_vec.len(), 4); + /// # } + /// ``` + /// + /// *Incorrect* usage of this method: + /// + /// ```rust,no_run + /// # extern crate maybe_uninit; + /// # fn main() { + /// use maybe_uninit::MaybeUninit; + /// + /// let mut x = MaybeUninit::>::uninit(); + /// let x_vec = unsafe { &mut *x.as_mut_ptr() }; + /// // We have created a reference to an uninitialized vector! This is undefined behavior. + /// # } + /// ``` + /// + /// (Notice that the rules around references to uninitialized data are not finalized yet, but + /// until they are, it is advisable to avoid them.) + #[inline(always)] + pub fn as_mut_ptr(&mut self) -> *mut T { + &mut *self.value as *mut T + } + + /// Extracts the value from the `MaybeUninit` container. This is a great way + /// to ensure that the data will get dropped, because the resulting `T` is + /// subject to the usual drop handling. + /// + /// # Safety + /// + /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized + /// state. Calling this when the content is not yet fully initialized causes immediate undefined + /// behavior. The [type-level documentation][inv] contains more information about + /// this initialization invariant. + /// + /// [inv]: #initialization-invariant + /// + /// # Examples + /// + /// Correct usage of this method: + /// + /// ```rust + /// # extern crate maybe_uninit; + /// # fn main() { + /// use maybe_uninit::MaybeUninit; + /// use std::ptr::write; + /// + /// let mut x = MaybeUninit::::uninit(); + /// unsafe { write(x.as_mut_ptr(), true); } + /// let x_init = unsafe { x.assume_init() }; + /// assert_eq!(x_init, true); + /// # } + /// ``` + /// + /// *Incorrect* usage of this method: + /// + /// ```rust,no_run + /// # extern crate maybe_uninit; + /// # fn main() { + /// use maybe_uninit::MaybeUninit; + /// + /// let x = MaybeUninit::>::uninit(); + /// let x_init = unsafe { x.assume_init() }; + /// // `x` had not been initialized yet, so this last line caused undefined behavior. + /// # } + /// ``` + #[inline(always)] + pub unsafe fn assume_init(self) -> T { + //intrinsics::panic_if_uninhabited::(); + ManuallyDrop::into_inner(self.value) + } + + /* + /// Reads the value from the `MaybeUninit` container. The resulting `T` is subject + /// to the usual drop handling. + /// + /// Whenever possible, it is preferrable to use [`assume_init`] instead, which + /// prevents duplicating the content of the `MaybeUninit`. + /// + /// # Safety + /// + /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized + /// state. Calling this when the content is not yet fully initialized causes undefined + /// behavior. The [type-level documentation][inv] contains more information about + /// this initialization invariant. + /// + /// Moreover, this leaves a copy of the same data behind in the `MaybeUninit`. When using + /// multiple copies of the data (by calling `read` multiple times, or first + /// calling `read` and then [`assume_init`]), it is your responsibility + /// to ensure that that data may indeed be duplicated. + /// + /// [inv]: #initialization-invariant + /// [`assume_init`]: #method.assume_init + /// + /// # Examples + /// + /// Correct usage of this method: + /// + /// ```rust + /// #![feature(maybe_uninit_extra)] + /// use std::mem::MaybeUninit; + /// + /// let mut x = MaybeUninit::::uninit(); + /// x.write(13); + /// let x1 = unsafe { x.read() }; + /// // `u32` is `Copy`, so we may read multiple times. + /// let x2 = unsafe { x.read() }; + /// assert_eq!(x1, x2); + /// + /// let mut x = MaybeUninit::>>::uninit(); + /// x.write(None); + /// let x1 = unsafe { x.read() }; + /// // Duplicating a `None` value is okay, so we may read multiple times. + /// let x2 = unsafe { x.read() }; + /// assert_eq!(x1, x2); + /// ``` + /// + /// *Incorrect* usage of this method: + /// + /// ```rust,no_run + /// #![feature(maybe_uninit_extra)] + /// use std::mem::MaybeUninit; + /// + /// let mut x = MaybeUninit::>>::uninit(); + /// x.write(Some(vec![0,1,2])); + /// let x1 = unsafe { x.read() }; + /// let x2 = unsafe { x.read() }; + /// // We now created two copies of the same vector, leading to a double-free when + /// // they both get dropped! + /// ``` + #[unstable(feature = "maybe_uninit_extra", issue = "53491")] + #[inline(always)] + pub unsafe fn read(&self) -> T { + intrinsics::panic_if_uninhabited::(); + self.as_ptr().read() + } + + /// Gets a reference to the contained value. + /// + /// # Safety + /// + /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized + /// state. Calling this when the content is not yet fully initialized causes undefined + /// behavior. + #[unstable(feature = "maybe_uninit_ref", issue = "53491")] + #[inline(always)] + pub unsafe fn get_ref(&self) -> &T { + &*self.value + } + + /// Gets a mutable reference to the contained value. + /// + /// # Safety + /// + /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized + /// state. Calling this when the content is not yet fully initialized causes undefined + /// behavior. + // FIXME(#53491): We currently rely on the above being incorrect, i.e., we have references + // to uninitialized data (e.g., in `libcore/fmt/float.rs`). We should make + // a final decision about the rules before stabilization. + #[unstable(feature = "maybe_uninit_ref", issue = "53491")] + #[inline(always)] + pub unsafe fn get_mut(&mut self) -> &mut T { + &mut *self.value + } + + /// Gets a pointer to the first element of the array. + #[unstable(feature = "maybe_uninit_slice", issue = "53491")] + #[inline(always)] + pub fn first_ptr(this: &[MaybeUninit]) -> *const T { + this as *const [MaybeUninit] as *const T + } + + /// Gets a mutable pointer to the first element of the array. + #[unstable(feature = "maybe_uninit_slice", issue = "53491")] + #[inline(always)] + pub fn first_ptr_mut(this: &mut [MaybeUninit]) -> *mut T { + this as *mut [MaybeUninit] as *mut T + }*/ +} diff --git a/third_party/cargo/vendor/maybe-uninit-2.0.0/tests/doesnt_drop.rs b/third_party/cargo/vendor/maybe-uninit-2.0.0/tests/doesnt_drop.rs new file mode 100644 index 0000000..1d4b30f --- /dev/null +++ b/third_party/cargo/vendor/maybe-uninit-2.0.0/tests/doesnt_drop.rs @@ -0,0 +1,37 @@ +extern crate maybe_uninit; +use maybe_uninit::MaybeUninit; + +use std::cell::Cell; + +struct DecrementOnDrop<'a>(&'a Cell); + +impl<'a> DecrementOnDrop<'a> { + pub fn new(ref_:&'a Cell) -> Self { + ref_.set(1); + DecrementOnDrop(ref_) + } +} + +impl<'a> Clone for DecrementOnDrop<'a> { + fn clone(&self) -> Self { + self.0.set(self.0.get() + 1); + + DecrementOnDrop(self.0) + } +} + +impl<'a> Drop for DecrementOnDrop<'a>{ + fn drop(&mut self) { + self.0.set(self.0.get() - 1); + } +} + +#[test] +fn doesnt_drop(){ + let count = Cell::new(0); + let arc = DecrementOnDrop::new(&count); + let maybe = MaybeUninit::new(arc.clone()); + assert_eq!(count.get(), 2); + drop(maybe); + assert_eq!(count.get(), 2); +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/.cargo-checksum.json b/third_party/cargo/vendor/memchr-2.3.0/.cargo-checksum.json new file mode 100644 index 0000000..928cd51 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"COPYING":"01c266bced4a434da0051174d6bee16a4c82cf634e2679b6155d40d75012390f","Cargo.toml":"213363c927fbd46395684a1f86e38a3ba49f15b0801e174ab05f3ba566465e83","LICENSE-MIT":"0f96a83840e146e43c0ec96a22ec1f392e0680e6c1226e6f3ba87e0740af850f","README.md":"0362e0c6b859febb412a0cde35470097e560ccf38c9d97af615b0c6365e52931","UNLICENSE":"7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c","build.rs":"ed35d244304888581bfcbdc52596721a5bbb908bcbd56bbdfe977800ef3042e1","rustfmt.toml":"1ca600239a27401c4a43f363cf3f38183a212affc1f31bff3ae93234bbaec228","src/c.rs":"86fe35cbb46c8bece9927fbde20f1ca3af526defdde05ac969ad2f4bc9bb25e9","src/fallback.rs":"79519255d480a9c2667c06f9287931cfc2b85f6af6fcf92d453a11ee161dcb74","src/iter.rs":"23b1066d6b40159fe944388db7743c89422b1110ddb44667fde6d722f178ed4e","src/lib.rs":"0a6f72c2ae7827a057dd2ecdd699920f9f6a252290b7cb70e354396dadea571e","src/naive.rs":"c7453bc99cc4e58eb37cf5a50c88688833e50a270ee1849baefddb8acc0ccd94","src/tests/iter.rs":"8d5999a2a5b8a3228c76cd82cd3ee86dfa6f7b4022405b1f06eedf7d74e4c704","src/tests/memchr.rs":"f30074eeab99a16ce5ca8a30f1890f86c43c0422523a7195cbb3ca5f3e465b67","src/tests/mod.rs":"2ad0c82d33b32562087254522641ea7bfa2a283130152be5e927a33f1978ebc7","src/x86/avx.rs":"b19987410e49a079f33162424c42494626c91303c41824961e478be3b537c9c9","src/x86/mod.rs":"0b13becaabc150a0099f7528226c82e288136cc7ebcdb8e96cf5ee9aae0f05b6","src/x86/sse2.rs":"7c1b8248a8cd48396cb70a862d77f9a972f1e16324d65c260f39d13af73bf638","src/x86/sse42.rs":"f671ae9dd2b518a823e499a09ce32d4957bc5ae043db90d61c027e32f688f2b2"},"package":"3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223"} \ No newline at end of file diff --git a/third_party/cargo/vendor/memchr-2.3.0/BUILD b/third_party/cargo/vendor/memchr-2.3.0/BUILD new file mode 100644 index 0000000..93ce86d --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" + "unencumbered", # "Unlicense" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "memchr", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "2.3.0", + crate_features = [ + "default", + "std", + "use_std", + ], +) + diff --git a/third_party/cargo/vendor/memchr-2.3.0/COPYING b/third_party/cargo/vendor/memchr-2.3.0/COPYING new file mode 100644 index 0000000..bb9c20a --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/third_party/cargo/vendor/memchr-2.3.0/Cargo.toml b/third_party/cargo/vendor/memchr-2.3.0/Cargo.toml new file mode 100644 index 0000000..e2a5be8 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/Cargo.toml @@ -0,0 +1,47 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "memchr" +version = "2.3.0" +authors = ["Andrew Gallant ", "bluss"] +exclude = ["/ci/*", "/.travis.yml", "/Makefile", "/appveyor.yml"] +description = "Safe interface to memchr." +homepage = "https://github.com/BurntSushi/rust-memchr" +documentation = "https://docs.rs/memchr/" +readme = "README.md" +keywords = ["memchr", "char", "scan", "strchr", "string"] +license = "Unlicense/MIT" +repository = "https://github.com/BurntSushi/rust-memchr" +[profile.test] +opt-level = 3 + +[lib] +name = "memchr" +bench = false +[dependencies.libc] +version = "0.2.18" +optional = true +default-features = false +[dev-dependencies.quickcheck] +version = "0.9" +default-features = false + +[features] +default = ["std"] +std = [] +use_std = ["std"] +[badges.appveyor] +repository = "BurntSushi/rust-memchr" + +[badges.travis-ci] +repository = "BurntSushi/rust-memchr" diff --git a/third_party/cargo/vendor/memchr-2.3.0/LICENSE-MIT b/third_party/cargo/vendor/memchr-2.3.0/LICENSE-MIT new file mode 100644 index 0000000..3b0a5dc --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/third_party/cargo/vendor/memchr-2.3.0/README.md b/third_party/cargo/vendor/memchr-2.3.0/README.md new file mode 100644 index 0000000..e8a937e --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/README.md @@ -0,0 +1,80 @@ +memchr +====== +The `memchr` crate provides heavily optimized routines for searching bytes. + +[![Build status](https://api.travis-ci.org/BurntSushi/rust-memchr.png)](https://travis-ci.org/BurntSushi/rust-memchr) +[![Build status](https://ci.appveyor.com/api/projects/status/8i9484t8l4w7uql0/branch/master?svg=true)](https://ci.appveyor.com/project/BurntSushi/rust-memchr/branch/master) +[![](http://meritbadge.herokuapp.com/memchr)](https://crates.io/crates/memchr) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + + +### Documentation + +[https://docs.rs/memchr](https://docs.rs/memchr) + + +### Overview + +The `memchr` function is traditionally provided by libc, but its +performance can vary significantly depending on the specific +implementation of libc that is used. They can range from manually tuned +Assembly implementations (like that found in GNU's libc) all the way to +non-vectorized C implementations (like that found in MUSL). + +To smooth out the differences between implementations of libc, at least +on `x86_64` for Rust 1.27+, this crate provides its own implementation of +`memchr` that should perform competitively with the one found in GNU's libc. +The implementation is in pure Rust and has no dependency on a C compiler or an +Assembler. + +Additionally, GNU libc also provides an extension, `memrchr`. This crate +provides its own implementation of `memrchr` as well, on top of `memchr2`, +`memchr3`, `memrchr2` and `memrchr3`. The difference between `memchr` and +`memchr2` is that `memchr2` permits finding all occurrences of two bytes +instead of one. Similarly for `memchr3`. + +### Compiling without the standard library + +memchr links to the standard library by default, but you can disable the +`std` feature if you want to use it in a `#![no_std]` crate: + +```toml +[dependencies] +memchr = { version = "2", default-features = false } +``` + +On x86 platforms, when the `std` feature is disabled, the SSE2 +implementation of memchr will be used in compilers that support it. When +`std` is enabled, the AVX implementation of memchr will be used if the CPU +is determined to support it at runtime. + +### Using libc + +`memchr` is a routine that is part of libc, although this crate does not use +libc by default. Instead, it uses its own routines, which are either vectorized +or generic fallback routines. In general, these should be competitive with +what's in libc, although this has not been tested for all architectures. If +using `memchr` from libc is desirable and a vectorized routine is not otherwise +available in this crate, then enabling the `libc` feature will use libc's +version of `memchr`. + +The rest of the functions in this crate, e.g., `memchr2` or `memrchr3`, are not +a standard part of libc, so they will always use the implementations in this +crate. One exception to this is `memrchr`, which is an extension commonly found +on Linux. On Linux, `memrchr` is used in precisely the same scenario as +`memchr`, as described above. + + +### Minimum Rust version policy + +This crate's minimum supported `rustc` version is `1.28.0`. + +The current policy is that the minimum Rust version required to use this crate +can be increased in minor version updates. For example, if `crate 1.0` requires +Rust 1.20.0, then `crate 1.0.z` for all values of `z` will also require Rust +1.20.0 or newer. However, `crate 1.y` for `y > 0` may require a newer minimum +version of Rust. + +In general, this crate will be conservative with respect to the minimum +supported version of Rust. diff --git a/third_party/cargo/vendor/memchr-2.3.0/UNLICENSE b/third_party/cargo/vendor/memchr-2.3.0/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/third_party/cargo/vendor/memchr-2.3.0/build.rs b/third_party/cargo/vendor/memchr-2.3.0/build.rs new file mode 100644 index 0000000..4ae3184 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/build.rs @@ -0,0 +1,61 @@ +use std::env; + +fn main() { + enable_simd_optimizations(); + enable_libc(); +} + +// This adds various simd cfgs if this compiler supports it. +// +// This can be disabled with RUSTFLAGS="--cfg memchr_disable_auto_simd", but +// this is generally only intended for testing. +fn enable_simd_optimizations() { + if is_env_set("CARGO_CFG_MEMCHR_DISABLE_AUTO_SIMD") { + return; + } + println!("cargo:rustc-cfg=memchr_runtime_simd"); + println!("cargo:rustc-cfg=memchr_runtime_sse2"); + println!("cargo:rustc-cfg=memchr_runtime_sse42"); + println!("cargo:rustc-cfg=memchr_runtime_avx"); +} + +// This adds a `memchr_libc` cfg if and only if libc can be used, if no other +// better option is available. +// +// This could be performed in the source code, but it's simpler to do it once +// here and consolidate it into one cfg knob. +// +// Basically, we use libc only if its enabled and if we aren't targeting a +// known bad platform. For example, wasm32 doesn't have a libc and the +// performance of memchr on Windows is seemingly worse than the fallback +// implementation. +fn enable_libc() { + const NO_ARCH: &'static [&'static str] = &["wasm32", "windows"]; + const NO_ENV: &'static [&'static str] = &["sgx"]; + + if !is_feature_set("LIBC") { + return; + } + + let arch = match env::var("CARGO_CFG_TARGET_ARCH") { + Err(_) => return, + Ok(arch) => arch, + }; + let env = match env::var("CARGO_CFG_TARGET_ENV") { + Err(_) => return, + Ok(env) => env, + }; + if NO_ARCH.contains(&&*arch) || NO_ENV.contains(&&*env) { + return; + } + + println!("cargo:rustc-cfg=memchr_libc"); +} + +fn is_feature_set(name: &str) -> bool { + is_env_set(&format!("CARGO_FEATURE_{}", name)) +} + +fn is_env_set(name: &str) -> bool { + env::var_os(name).is_some() +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/rustfmt.toml b/third_party/cargo/vendor/memchr-2.3.0/rustfmt.toml new file mode 100644 index 0000000..aa37a21 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/rustfmt.toml @@ -0,0 +1,2 @@ +max_width = 79 +use_small_heuristics = "max" diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/c.rs b/third_party/cargo/vendor/memchr-2.3.0/src/c.rs new file mode 100644 index 0000000..63feca9 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/c.rs @@ -0,0 +1,44 @@ +// This module defines safe wrappers around memchr (POSIX) and memrchr (GNU +// extension). + +#![allow(dead_code)] + +extern crate libc; + +use self::libc::{c_int, c_void, size_t}; + +pub fn memchr(needle: u8, haystack: &[u8]) -> Option { + let p = unsafe { + libc::memchr( + haystack.as_ptr() as *const c_void, + needle as c_int, + haystack.len() as size_t, + ) + }; + if p.is_null() { + None + } else { + Some(p as usize - (haystack.as_ptr() as usize)) + } +} + +// memrchr is a GNU extension. We know it's available on Linux, so start there. +#[cfg(target_os = "linux")] +pub fn memrchr(needle: u8, haystack: &[u8]) -> Option { + // GNU's memrchr() will - unlike memchr() - error if haystack is empty. + if haystack.is_empty() { + return None; + } + let p = unsafe { + libc::memrchr( + haystack.as_ptr() as *const c_void, + needle as c_int, + haystack.len() as size_t, + ) + }; + if p.is_null() { + None + } else { + Some(p as usize - (haystack.as_ptr() as usize)) + } +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/fallback.rs b/third_party/cargo/vendor/memchr-2.3.0/src/fallback.rs new file mode 100644 index 0000000..8bc32b2 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/fallback.rs @@ -0,0 +1,330 @@ +// This module defines pure Rust platform independent implementations of all +// the memchr routines. We do our best to make them fast. Some of them may even +// get auto-vectorized. + +use core::cmp; +use core::usize; + +#[cfg(target_pointer_width = "16")] +const USIZE_BYTES: usize = 2; + +#[cfg(target_pointer_width = "32")] +const USIZE_BYTES: usize = 4; + +#[cfg(target_pointer_width = "64")] +const USIZE_BYTES: usize = 8; + +// The number of bytes to loop at in one iteration of memchr/memrchr. +const LOOP_SIZE: usize = 2 * USIZE_BYTES; + +/// Return `true` if `x` contains any zero byte. +/// +/// From *Matters Computational*, J. Arndt +/// +/// "The idea is to subtract one from each of the bytes and then look for +/// bytes where the borrow propagated all the way to the most significant +/// bit." +#[inline(always)] +fn contains_zero_byte(x: usize) -> bool { + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; + + const LO_USIZE: usize = LO_U64 as usize; + const HI_USIZE: usize = HI_U64 as usize; + + x.wrapping_sub(LO_USIZE) & !x & HI_USIZE != 0 +} + +/// Repeat the given byte into a word size number. That is, every 8 bits +/// is equivalent to the given byte. For example, if `b` is `\x4E` or +/// `01001110` in binary, then the returned value on a 32-bit system would be: +/// `01001110_01001110_01001110_01001110`. +#[inline(always)] +fn repeat_byte(b: u8) -> usize { + (b as usize) * (usize::MAX / 255) +} + +pub fn memchr(n1: u8, haystack: &[u8]) -> Option { + let vn1 = repeat_byte(n1); + let confirm = |byte| byte == n1; + let loop_size = cmp::min(LOOP_SIZE, haystack.len()); + let align = USIZE_BYTES - 1; + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = start_ptr; + + unsafe { + if haystack.len() < USIZE_BYTES { + return forward_search(start_ptr, end_ptr, ptr, confirm); + } + + let chunk = (ptr as *const usize).read_unaligned(); + if contains_zero_byte(chunk ^ vn1) { + return forward_search(start_ptr, end_ptr, ptr, confirm); + } + + ptr = ptr.add(USIZE_BYTES - (start_ptr as usize & align)); + debug_assert!(ptr > start_ptr); + debug_assert!(end_ptr.sub(USIZE_BYTES) >= start_ptr); + while loop_size == LOOP_SIZE && ptr <= end_ptr.sub(loop_size) { + debug_assert_eq!(0, (ptr as usize) % USIZE_BYTES); + + let a = *(ptr as *const usize); + let b = *(ptr.add(USIZE_BYTES) as *const usize); + let eqa = contains_zero_byte(a ^ vn1); + let eqb = contains_zero_byte(b ^ vn1); + if eqa || eqb { + break; + } + ptr = ptr.add(LOOP_SIZE); + } + forward_search(start_ptr, end_ptr, ptr, confirm) + } +} + +/// Like `memchr`, but searches for two bytes instead of one. +pub fn memchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option { + let vn1 = repeat_byte(n1); + let vn2 = repeat_byte(n2); + let confirm = |byte| byte == n1 || byte == n2; + let align = USIZE_BYTES - 1; + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = start_ptr; + + unsafe { + if haystack.len() < USIZE_BYTES { + return forward_search(start_ptr, end_ptr, ptr, confirm); + } + + let chunk = (ptr as *const usize).read_unaligned(); + let eq1 = contains_zero_byte(chunk ^ vn1); + let eq2 = contains_zero_byte(chunk ^ vn2); + if eq1 || eq2 { + return forward_search(start_ptr, end_ptr, ptr, confirm); + } + + ptr = ptr.add(USIZE_BYTES - (start_ptr as usize & align)); + debug_assert!(ptr > start_ptr); + debug_assert!(end_ptr.sub(USIZE_BYTES) >= start_ptr); + while ptr <= end_ptr.sub(USIZE_BYTES) { + debug_assert_eq!(0, (ptr as usize) % USIZE_BYTES); + + let chunk = *(ptr as *const usize); + let eq1 = contains_zero_byte(chunk ^ vn1); + let eq2 = contains_zero_byte(chunk ^ vn2); + if eq1 || eq2 { + break; + } + ptr = ptr.add(USIZE_BYTES); + } + forward_search(start_ptr, end_ptr, ptr, confirm) + } +} + +/// Like `memchr`, but searches for three bytes instead of one. +pub fn memchr3(n1: u8, n2: u8, n3: u8, haystack: &[u8]) -> Option { + let vn1 = repeat_byte(n1); + let vn2 = repeat_byte(n2); + let vn3 = repeat_byte(n3); + let confirm = |byte| byte == n1 || byte == n2 || byte == n3; + let align = USIZE_BYTES - 1; + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = start_ptr; + + unsafe { + if haystack.len() < USIZE_BYTES { + return forward_search(start_ptr, end_ptr, ptr, confirm); + } + + let chunk = (ptr as *const usize).read_unaligned(); + let eq1 = contains_zero_byte(chunk ^ vn1); + let eq2 = contains_zero_byte(chunk ^ vn2); + let eq3 = contains_zero_byte(chunk ^ vn3); + if eq1 || eq2 || eq3 { + return forward_search(start_ptr, end_ptr, ptr, confirm); + } + + ptr = ptr.add(USIZE_BYTES - (start_ptr as usize & align)); + debug_assert!(ptr > start_ptr); + debug_assert!(end_ptr.sub(USIZE_BYTES) >= start_ptr); + while ptr <= end_ptr.sub(USIZE_BYTES) { + debug_assert_eq!(0, (ptr as usize) % USIZE_BYTES); + + let chunk = *(ptr as *const usize); + let eq1 = contains_zero_byte(chunk ^ vn1); + let eq2 = contains_zero_byte(chunk ^ vn2); + let eq3 = contains_zero_byte(chunk ^ vn3); + if eq1 || eq2 || eq3 { + break; + } + ptr = ptr.add(USIZE_BYTES); + } + forward_search(start_ptr, end_ptr, ptr, confirm) + } +} + +/// Return the last index matching the byte `x` in `text`. +pub fn memrchr(n1: u8, haystack: &[u8]) -> Option { + let vn1 = repeat_byte(n1); + let confirm = |byte| byte == n1; + let loop_size = cmp::min(LOOP_SIZE, haystack.len()); + let align = USIZE_BYTES - 1; + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = end_ptr; + + unsafe { + if haystack.len() < USIZE_BYTES { + return reverse_search(start_ptr, end_ptr, ptr, confirm); + } + + let chunk = (ptr.sub(USIZE_BYTES) as *const usize).read_unaligned(); + if contains_zero_byte(chunk ^ vn1) { + return reverse_search(start_ptr, end_ptr, ptr, confirm); + } + + ptr = (end_ptr as usize & !align) as *const u8; + debug_assert!(start_ptr <= ptr && ptr <= end_ptr); + while loop_size == LOOP_SIZE && ptr >= start_ptr.add(loop_size) { + debug_assert_eq!(0, (ptr as usize) % USIZE_BYTES); + + let a = *(ptr.sub(2 * USIZE_BYTES) as *const usize); + let b = *(ptr.sub(1 * USIZE_BYTES) as *const usize); + let eqa = contains_zero_byte(a ^ vn1); + let eqb = contains_zero_byte(b ^ vn1); + if eqa || eqb { + break; + } + ptr = ptr.sub(loop_size); + } + reverse_search(start_ptr, end_ptr, ptr, confirm) + } +} + +/// Like `memrchr`, but searches for two bytes instead of one. +pub fn memrchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option { + let vn1 = repeat_byte(n1); + let vn2 = repeat_byte(n2); + let confirm = |byte| byte == n1 || byte == n2; + let align = USIZE_BYTES - 1; + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = end_ptr; + + unsafe { + if haystack.len() < USIZE_BYTES { + return reverse_search(start_ptr, end_ptr, ptr, confirm); + } + + let chunk = (ptr.sub(USIZE_BYTES) as *const usize).read_unaligned(); + let eq1 = contains_zero_byte(chunk ^ vn1); + let eq2 = contains_zero_byte(chunk ^ vn2); + if eq1 || eq2 { + return reverse_search(start_ptr, end_ptr, ptr, confirm); + } + + ptr = (end_ptr as usize & !align) as *const u8; + debug_assert!(start_ptr <= ptr && ptr <= end_ptr); + while ptr >= start_ptr.add(USIZE_BYTES) { + debug_assert_eq!(0, (ptr as usize) % USIZE_BYTES); + + let chunk = *(ptr.sub(USIZE_BYTES) as *const usize); + let eq1 = contains_zero_byte(chunk ^ vn1); + let eq2 = contains_zero_byte(chunk ^ vn2); + if eq1 || eq2 { + break; + } + ptr = ptr.sub(USIZE_BYTES); + } + reverse_search(start_ptr, end_ptr, ptr, confirm) + } +} + +/// Like `memrchr`, but searches for three bytes instead of one. +pub fn memrchr3(n1: u8, n2: u8, n3: u8, haystack: &[u8]) -> Option { + let vn1 = repeat_byte(n1); + let vn2 = repeat_byte(n2); + let vn3 = repeat_byte(n3); + let confirm = |byte| byte == n1 || byte == n2 || byte == n3; + let align = USIZE_BYTES - 1; + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = end_ptr; + + unsafe { + if haystack.len() < USIZE_BYTES { + return reverse_search(start_ptr, end_ptr, ptr, confirm); + } + + let chunk = (ptr.sub(USIZE_BYTES) as *const usize).read_unaligned(); + let eq1 = contains_zero_byte(chunk ^ vn1); + let eq2 = contains_zero_byte(chunk ^ vn2); + let eq3 = contains_zero_byte(chunk ^ vn3); + if eq1 || eq2 || eq3 { + return reverse_search(start_ptr, end_ptr, ptr, confirm); + } + + ptr = (end_ptr as usize & !align) as *const u8; + debug_assert!(start_ptr <= ptr && ptr <= end_ptr); + while ptr >= start_ptr.add(USIZE_BYTES) { + debug_assert_eq!(0, (ptr as usize) % USIZE_BYTES); + + let chunk = *(ptr.sub(USIZE_BYTES) as *const usize); + let eq1 = contains_zero_byte(chunk ^ vn1); + let eq2 = contains_zero_byte(chunk ^ vn2); + let eq3 = contains_zero_byte(chunk ^ vn3); + if eq1 || eq2 || eq3 { + break; + } + ptr = ptr.sub(USIZE_BYTES); + } + reverse_search(start_ptr, end_ptr, ptr, confirm) + } +} + +#[inline(always)] +unsafe fn forward_search bool>( + start_ptr: *const u8, + end_ptr: *const u8, + mut ptr: *const u8, + confirm: F, +) -> Option { + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr); + + while ptr < end_ptr { + if confirm(*ptr) { + return Some(sub(ptr, start_ptr)); + } + ptr = ptr.offset(1); + } + None +} + +#[inline(always)] +unsafe fn reverse_search bool>( + start_ptr: *const u8, + end_ptr: *const u8, + mut ptr: *const u8, + confirm: F, +) -> Option { + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr); + + while ptr > start_ptr { + ptr = ptr.offset(-1); + if confirm(*ptr) { + return Some(sub(ptr, start_ptr)); + } + } + None +} + +/// Subtract `b` from `a` and return the difference. `a` should be greater than +/// or equal to `b`. +fn sub(a: *const u8, b: *const u8) -> usize { + debug_assert!(a >= b); + (a as usize) - (b as usize) +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/iter.rs b/third_party/cargo/vendor/memchr-2.3.0/src/iter.rs new file mode 100644 index 0000000..6217ae4 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/iter.rs @@ -0,0 +1,173 @@ +use {memchr, memchr2, memchr3, memrchr, memrchr2, memrchr3}; + +macro_rules! iter_next { + // Common code for the memchr iterators: + // update haystack and position and produce the index + // + // self: &mut Self where Self is the iterator + // search_result: Option which is the result of the corresponding + // memchr function. + // + // Returns Option (the next iterator element) + ($self_:expr, $search_result:expr) => { + $search_result.map(move |index| { + // split and take the remaining back half + $self_.haystack = $self_.haystack.split_at(index + 1).1; + let found_position = $self_.position + index; + $self_.position = found_position + 1; + found_position + }) + }; +} + +macro_rules! iter_next_back { + ($self_:expr, $search_result:expr) => { + $search_result.map(move |index| { + // split and take the remaining front half + $self_.haystack = $self_.haystack.split_at(index).0; + $self_.position + index + }) + }; +} + +/// An iterator for `memchr`. +pub struct Memchr<'a> { + needle: u8, + // The haystack to iterate over + haystack: &'a [u8], + // The index + position: usize, +} + +impl<'a> Memchr<'a> { + /// Creates a new iterator that yields all positions of needle in haystack. + #[inline] + pub fn new(needle: u8, haystack: &[u8]) -> Memchr { + Memchr { needle: needle, haystack: haystack, position: 0 } + } +} + +impl<'a> Iterator for Memchr<'a> { + type Item = usize; + + #[inline] + fn next(&mut self) -> Option { + iter_next!(self, memchr(self.needle, self.haystack)) + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (0, Some(self.haystack.len())) + } +} + +impl<'a> DoubleEndedIterator for Memchr<'a> { + #[inline] + fn next_back(&mut self) -> Option { + iter_next_back!(self, memrchr(self.needle, self.haystack)) + } +} + +/// An iterator for `memchr2`. +pub struct Memchr2<'a> { + needle1: u8, + needle2: u8, + // The haystack to iterate over + haystack: &'a [u8], + // The index + position: usize, +} + +impl<'a> Memchr2<'a> { + /// Creates a new iterator that yields all positions of needle in haystack. + #[inline] + pub fn new(needle1: u8, needle2: u8, haystack: &[u8]) -> Memchr2 { + Memchr2 { + needle1: needle1, + needle2: needle2, + haystack: haystack, + position: 0, + } + } +} + +impl<'a> Iterator for Memchr2<'a> { + type Item = usize; + + #[inline] + fn next(&mut self) -> Option { + iter_next!(self, memchr2(self.needle1, self.needle2, self.haystack)) + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (0, Some(self.haystack.len())) + } +} + +impl<'a> DoubleEndedIterator for Memchr2<'a> { + #[inline] + fn next_back(&mut self) -> Option { + iter_next_back!( + self, + memrchr2(self.needle1, self.needle2, self.haystack) + ) + } +} + +/// An iterator for `memchr3`. +pub struct Memchr3<'a> { + needle1: u8, + needle2: u8, + needle3: u8, + // The haystack to iterate over + haystack: &'a [u8], + // The index + position: usize, +} + +impl<'a> Memchr3<'a> { + /// Create a new `Memchr3` that's initialized to zero with a haystack + #[inline] + pub fn new( + needle1: u8, + needle2: u8, + needle3: u8, + haystack: &[u8], + ) -> Memchr3 { + Memchr3 { + needle1: needle1, + needle2: needle2, + needle3: needle3, + haystack: haystack, + position: 0, + } + } +} + +impl<'a> Iterator for Memchr3<'a> { + type Item = usize; + + #[inline] + fn next(&mut self) -> Option { + iter_next!( + self, + memchr3(self.needle1, self.needle2, self.needle3, self.haystack) + ) + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (0, Some(self.haystack.len())) + } +} + +impl<'a> DoubleEndedIterator for Memchr3<'a> { + #[inline] + fn next_back(&mut self) -> Option { + iter_next_back!( + self, + memrchr3(self.needle1, self.needle2, self.needle3, self.haystack) + ) + } +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/lib.rs b/third_party/cargo/vendor/memchr-2.3.0/src/lib.rs new file mode 100644 index 0000000..61f5d85 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/lib.rs @@ -0,0 +1,395 @@ +/*! +The `memchr` crate provides heavily optimized routines for searching bytes. + +The `memchr` function is traditionally provided by libc, however, the +performance of `memchr` can vary significantly depending on the specific +implementation of libc that is used. They can range from manually tuned +Assembly implementations (like that found in GNU's libc) all the way to +non-vectorized C implementations (like that found in MUSL). + +To smooth out the differences between implementations of libc, at least +on `x86_64` for Rust 1.27+, this crate provides its own implementation of +`memchr` that should perform competitively with the one found in GNU's libc. +The implementation is in pure Rust and has no dependency on a C compiler or an +Assembler. + +Additionally, GNU libc also provides an extension, `memrchr`. This crate +provides its own implementation of `memrchr` as well, on top of `memchr2`, +`memchr3`, `memrchr2` and `memrchr3`. The difference between `memchr` and +`memchr2` is that that `memchr2` permits finding all occurrences of two bytes +instead of one. Similarly for `memchr3`. +*/ + +#![cfg_attr(not(feature = "std"), no_std)] +#![deny(missing_docs)] +#![doc(html_root_url = "https://docs.rs/memchr/2.0.0")] + +// Supporting 8-bit (or others) would be fine. If you need it, please submit a +// bug report at https://github.com/BurntSushi/rust-memchr +#[cfg(not(any( + target_pointer_width = "16", + target_pointer_width = "32", + target_pointer_width = "64" +)))] +compile_error!("memchr currently not supported on non-32 or non-64 bit"); + +#[cfg(feature = "std")] +extern crate core; + +#[cfg(test)] +#[macro_use] +extern crate quickcheck; + +use core::iter::Rev; + +pub use iter::{Memchr, Memchr2, Memchr3}; + +// N.B. If you're looking for the cfg knobs for libc, see build.rs. +#[cfg(memchr_libc)] +mod c; +#[allow(dead_code)] +mod fallback; +mod iter; +mod naive; +#[cfg(test)] +mod tests; +#[cfg(all(target_arch = "x86_64", memchr_runtime_simd))] +mod x86; + +/// An iterator over all occurrences of the needle in a haystack. +#[inline] +pub fn memchr_iter(needle: u8, haystack: &[u8]) -> Memchr { + Memchr::new(needle, haystack) +} + +/// An iterator over all occurrences of the needles in a haystack. +#[inline] +pub fn memchr2_iter(needle1: u8, needle2: u8, haystack: &[u8]) -> Memchr2 { + Memchr2::new(needle1, needle2, haystack) +} + +/// An iterator over all occurrences of the needles in a haystack. +#[inline] +pub fn memchr3_iter( + needle1: u8, + needle2: u8, + needle3: u8, + haystack: &[u8], +) -> Memchr3 { + Memchr3::new(needle1, needle2, needle3, haystack) +} + +/// An iterator over all occurrences of the needle in a haystack, in reverse. +#[inline] +pub fn memrchr_iter(needle: u8, haystack: &[u8]) -> Rev { + Memchr::new(needle, haystack).rev() +} + +/// An iterator over all occurrences of the needles in a haystack, in reverse. +#[inline] +pub fn memrchr2_iter( + needle1: u8, + needle2: u8, + haystack: &[u8], +) -> Rev { + Memchr2::new(needle1, needle2, haystack).rev() +} + +/// An iterator over all occurrences of the needles in a haystack, in reverse. +#[inline] +pub fn memrchr3_iter( + needle1: u8, + needle2: u8, + needle3: u8, + haystack: &[u8], +) -> Rev { + Memchr3::new(needle1, needle2, needle3, haystack).rev() +} + +/// Search for the first occurrence of a byte in a slice. +/// +/// This returns the index corresponding to the first occurrence of `needle` in +/// `haystack`, or `None` if one is not found. +/// +/// While this is operationally the same as something like +/// `haystack.iter().position(|&b| b == needle)`, `memchr` will use a highly +/// optimized routine that can be up to an order of magnitude faster in some +/// cases. +/// +/// # Example +/// +/// This shows how to find the first position of a byte in a byte string. +/// +/// ``` +/// use memchr::memchr; +/// +/// let haystack = b"the quick brown fox"; +/// assert_eq!(memchr(b'k', haystack), Some(8)); +/// ``` +#[inline] +pub fn memchr(needle: u8, haystack: &[u8]) -> Option { + #[cfg(all(target_arch = "x86_64", memchr_runtime_simd))] + #[inline(always)] + fn imp(n1: u8, haystack: &[u8]) -> Option { + x86::memchr(n1, haystack) + } + + #[cfg(all( + memchr_libc, + not(all(target_arch = "x86_64", memchr_runtime_simd)) + ))] + #[inline(always)] + fn imp(n1: u8, haystack: &[u8]) -> Option { + c::memchr(n1, haystack) + } + + #[cfg(all( + not(memchr_libc), + not(all(target_arch = "x86_64", memchr_runtime_simd)) + ))] + #[inline(always)] + fn imp(n1: u8, haystack: &[u8]) -> Option { + fallback::memchr(n1, haystack) + } + + if haystack.is_empty() { + None + } else { + imp(needle, haystack) + } +} + +/// Like `memchr`, but searches for either of two bytes instead of just one. +/// +/// This returns the index corresponding to the first occurrence of `needle1` +/// or the first occurrence of `needle2` in `haystack` (whichever occurs +/// earlier), or `None` if neither one is found. +/// +/// While this is operationally the same as something like +/// `haystack.iter().position(|&b| b == needle1 || b == needle2)`, `memchr2` +/// will use a highly optimized routine that can be up to an order of magnitude +/// faster in some cases. +/// +/// # Example +/// +/// This shows how to find the first position of either of two bytes in a byte +/// string. +/// +/// ``` +/// use memchr::memchr2; +/// +/// let haystack = b"the quick brown fox"; +/// assert_eq!(memchr2(b'k', b'q', haystack), Some(4)); +/// ``` +#[inline] +pub fn memchr2(needle1: u8, needle2: u8, haystack: &[u8]) -> Option { + #[cfg(all(target_arch = "x86_64", memchr_runtime_simd))] + #[inline(always)] + fn imp(n1: u8, n2: u8, haystack: &[u8]) -> Option { + x86::memchr2(n1, n2, haystack) + } + + #[cfg(not(all(target_arch = "x86_64", memchr_runtime_simd)))] + #[inline(always)] + fn imp(n1: u8, n2: u8, haystack: &[u8]) -> Option { + fallback::memchr2(n1, n2, haystack) + } + + if haystack.is_empty() { + None + } else { + imp(needle1, needle2, haystack) + } +} + +/// Like `memchr`, but searches for any of three bytes instead of just one. +/// +/// This returns the index corresponding to the first occurrence of `needle1`, +/// the first occurrence of `needle2`, or the first occurence of `needle3` in +/// `haystack` (whichever occurs earliest), or `None` if none are found. +/// +/// While this is operationally the same as something like +/// `haystack.iter().position(|&b| b == needle1 || b == needle2 || +/// b == needle3)`, `memchr3` will use a highly optimized routine that can be +/// up to an order of magnitude faster in some cases. +/// +/// # Example +/// +/// This shows how to find the first position of any of three bytes in a byte +/// string. +/// +/// ``` +/// use memchr::memchr3; +/// +/// let haystack = b"the quick brown fox"; +/// assert_eq!(memchr3(b'k', b'q', b'e', haystack), Some(2)); +/// ``` +#[inline] +pub fn memchr3( + needle1: u8, + needle2: u8, + needle3: u8, + haystack: &[u8], +) -> Option { + #[cfg(all(target_arch = "x86_64", memchr_runtime_simd))] + #[inline(always)] + fn imp(n1: u8, n2: u8, n3: u8, haystack: &[u8]) -> Option { + x86::memchr3(n1, n2, n3, haystack) + } + + #[cfg(not(all(target_arch = "x86_64", memchr_runtime_simd)))] + #[inline(always)] + fn imp(n1: u8, n2: u8, n3: u8, haystack: &[u8]) -> Option { + fallback::memchr3(n1, n2, n3, haystack) + } + + if haystack.is_empty() { + None + } else { + imp(needle1, needle2, needle3, haystack) + } +} + +/// Search for the last occurrence of a byte in a slice. +/// +/// This returns the index corresponding to the last occurrence of `needle` in +/// `haystack`, or `None` if one is not found. +/// +/// While this is operationally the same as something like +/// `haystack.iter().rposition(|&b| b == needle)`, `memrchr` will use a highly +/// optimized routine that can be up to an order of magnitude faster in some +/// cases. +/// +/// # Example +/// +/// This shows how to find the last position of a byte in a byte string. +/// +/// ``` +/// use memchr::memrchr; +/// +/// let haystack = b"the quick brown fox"; +/// assert_eq!(memrchr(b'o', haystack), Some(17)); +/// ``` +#[inline] +pub fn memrchr(needle: u8, haystack: &[u8]) -> Option { + #[cfg(all(target_arch = "x86_64", memchr_runtime_simd))] + #[inline(always)] + fn imp(n1: u8, haystack: &[u8]) -> Option { + x86::memrchr(n1, haystack) + } + + #[cfg(all( + all(memchr_libc, target_os = "linux"), + not(all(target_arch = "x86_64", memchr_runtime_simd)) + ))] + #[inline(always)] + fn imp(n1: u8, haystack: &[u8]) -> Option { + c::memrchr(n1, haystack) + } + + #[cfg(all( + not(all(memchr_libc, target_os = "linux")), + not(all(target_arch = "x86_64", memchr_runtime_simd)) + ))] + #[inline(always)] + fn imp(n1: u8, haystack: &[u8]) -> Option { + fallback::memrchr(n1, haystack) + } + + if haystack.is_empty() { + None + } else { + imp(needle, haystack) + } +} + +/// Like `memrchr`, but searches for either of two bytes instead of just one. +/// +/// This returns the index corresponding to the last occurrence of `needle1` +/// or the last occurrence of `needle2` in `haystack` (whichever occurs later), +/// or `None` if neither one is found. +/// +/// While this is operationally the same as something like +/// `haystack.iter().rposition(|&b| b == needle1 || b == needle2)`, `memrchr2` +/// will use a highly optimized routine that can be up to an order of magnitude +/// faster in some cases. +/// +/// # Example +/// +/// This shows how to find the last position of either of two bytes in a byte +/// string. +/// +/// ``` +/// use memchr::memrchr2; +/// +/// let haystack = b"the quick brown fox"; +/// assert_eq!(memrchr2(b'k', b'q', haystack), Some(8)); +/// ``` +#[inline] +pub fn memrchr2(needle1: u8, needle2: u8, haystack: &[u8]) -> Option { + #[cfg(all(target_arch = "x86_64", memchr_runtime_simd))] + #[inline(always)] + fn imp(n1: u8, n2: u8, haystack: &[u8]) -> Option { + x86::memrchr2(n1, n2, haystack) + } + + #[cfg(not(all(target_arch = "x86_64", memchr_runtime_simd)))] + #[inline(always)] + fn imp(n1: u8, n2: u8, haystack: &[u8]) -> Option { + fallback::memrchr2(n1, n2, haystack) + } + + if haystack.is_empty() { + None + } else { + imp(needle1, needle2, haystack) + } +} + +/// Like `memrchr`, but searches for any of three bytes instead of just one. +/// +/// This returns the index corresponding to the last occurrence of `needle1`, +/// the last occurrence of `needle2`, or the last occurence of `needle3` in +/// `haystack` (whichever occurs later), or `None` if none are found. +/// +/// While this is operationally the same as something like +/// `haystack.iter().rposition(|&b| b == needle1 || b == needle2 || +/// b == needle3)`, `memrchr3` will use a highly optimized routine that can be +/// up to an order of magnitude faster in some cases. +/// +/// # Example +/// +/// This shows how to find the last position of any of three bytes in a byte +/// string. +/// +/// ``` +/// use memchr::memrchr3; +/// +/// let haystack = b"the quick brown fox"; +/// assert_eq!(memrchr3(b'k', b'q', b'e', haystack), Some(8)); +/// ``` +#[inline] +pub fn memrchr3( + needle1: u8, + needle2: u8, + needle3: u8, + haystack: &[u8], +) -> Option { + #[cfg(all(target_arch = "x86_64", memchr_runtime_simd))] + #[inline(always)] + fn imp(n1: u8, n2: u8, n3: u8, haystack: &[u8]) -> Option { + x86::memrchr3(n1, n2, n3, haystack) + } + + #[cfg(not(all(target_arch = "x86_64", memchr_runtime_simd)))] + #[inline(always)] + fn imp(n1: u8, n2: u8, n3: u8, haystack: &[u8]) -> Option { + fallback::memrchr3(n1, n2, n3, haystack) + } + + if haystack.is_empty() { + None + } else { + imp(needle1, needle2, needle3, haystack) + } +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/naive.rs b/third_party/cargo/vendor/memchr-2.3.0/src/naive.rs new file mode 100644 index 0000000..3f3053d --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/naive.rs @@ -0,0 +1,25 @@ +#![allow(dead_code)] + +pub fn memchr(n1: u8, haystack: &[u8]) -> Option { + haystack.iter().position(|&b| b == n1) +} + +pub fn memchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option { + haystack.iter().position(|&b| b == n1 || b == n2) +} + +pub fn memchr3(n1: u8, n2: u8, n3: u8, haystack: &[u8]) -> Option { + haystack.iter().position(|&b| b == n1 || b == n2 || b == n3) +} + +pub fn memrchr(n1: u8, haystack: &[u8]) -> Option { + haystack.iter().rposition(|&b| b == n1) +} + +pub fn memrchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option { + haystack.iter().rposition(|&b| b == n1 || b == n2) +} + +pub fn memrchr3(n1: u8, n2: u8, n3: u8, haystack: &[u8]) -> Option { + haystack.iter().rposition(|&b| b == n1 || b == n2 || b == n3) +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/tests/iter.rs b/third_party/cargo/vendor/memchr-2.3.0/src/tests/iter.rs new file mode 100644 index 0000000..8f33500 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/tests/iter.rs @@ -0,0 +1,229 @@ +use tests::memchr_tests; +use {Memchr, Memchr2, Memchr3}; + +#[test] +fn memchr1_iter() { + for test in memchr_tests() { + test.iter_one(false, Memchr::new); + } +} + +#[test] +fn memchr2_iter() { + for test in memchr_tests() { + test.iter_two(false, Memchr2::new); + } +} + +#[test] +fn memchr3_iter() { + for test in memchr_tests() { + test.iter_three(false, Memchr3::new); + } +} + +#[test] +fn memrchr1_iter() { + for test in memchr_tests() { + test.iter_one(true, |n1, corpus| Memchr::new(n1, corpus).rev()); + } +} + +#[test] +fn memrchr2_iter() { + for test in memchr_tests() { + test.iter_two(true, |n1, n2, corpus| { + Memchr2::new(n1, n2, corpus).rev() + }) + } +} + +#[test] +fn memrchr3_iter() { + for test in memchr_tests() { + test.iter_three(true, |n1, n2, n3, corpus| { + Memchr3::new(n1, n2, n3, corpus).rev() + }) + } +} + +quickcheck! { + fn qc_memchr_double_ended_iter( + needle: u8, data: Vec, take_side: Vec + ) -> bool { + // make nonempty + let mut take_side = take_side; + if take_side.is_empty() { take_side.push(true) }; + + let iter = Memchr::new(needle, &data); + let all_found = double_ended_take( + iter, take_side.iter().cycle().cloned()); + + all_found.iter().cloned().eq(positions1(needle, &data)) + } + + fn qc_memchr2_double_ended_iter( + needle1: u8, needle2: u8, data: Vec, take_side: Vec + ) -> bool { + // make nonempty + let mut take_side = take_side; + if take_side.is_empty() { take_side.push(true) }; + + let iter = Memchr2::new(needle1, needle2, &data); + let all_found = double_ended_take( + iter, take_side.iter().cycle().cloned()); + + all_found.iter().cloned().eq(positions2(needle1, needle2, &data)) + } + + fn qc_memchr3_double_ended_iter( + needle1: u8, needle2: u8, needle3: u8, + data: Vec, take_side: Vec + ) -> bool { + // make nonempty + let mut take_side = take_side; + if take_side.is_empty() { take_side.push(true) }; + + let iter = Memchr3::new(needle1, needle2, needle3, &data); + let all_found = double_ended_take( + iter, take_side.iter().cycle().cloned()); + + all_found + .iter() + .cloned() + .eq(positions3(needle1, needle2, needle3, &data)) + } + + fn qc_memchr1_iter(data: Vec) -> bool { + let needle = 0; + let answer = positions1(needle, &data); + answer.eq(Memchr::new(needle, &data)) + } + + fn qc_memchr1_rev_iter(data: Vec) -> bool { + let needle = 0; + let answer = positions1(needle, &data); + answer.rev().eq(Memchr::new(needle, &data).rev()) + } + + fn qc_memchr2_iter(data: Vec) -> bool { + let needle1 = 0; + let needle2 = 1; + let answer = positions2(needle1, needle2, &data); + answer.eq(Memchr2::new(needle1, needle2, &data)) + } + + fn qc_memchr2_rev_iter(data: Vec) -> bool { + let needle1 = 0; + let needle2 = 1; + let answer = positions2(needle1, needle2, &data); + answer.rev().eq(Memchr2::new(needle1, needle2, &data).rev()) + } + + fn qc_memchr3_iter(data: Vec) -> bool { + let needle1 = 0; + let needle2 = 1; + let needle3 = 2; + let answer = positions3(needle1, needle2, needle3, &data); + answer.eq(Memchr3::new(needle1, needle2, needle3, &data)) + } + + fn qc_memchr3_rev_iter(data: Vec) -> bool { + let needle1 = 0; + let needle2 = 1; + let needle3 = 2; + let answer = positions3(needle1, needle2, needle3, &data); + answer.rev().eq(Memchr3::new(needle1, needle2, needle3, &data).rev()) + } + + fn qc_memchr1_iter_size_hint(data: Vec) -> bool { + // test that the size hint is within reasonable bounds + let needle = 0; + let mut iter = Memchr::new(needle, &data); + let mut real_count = data + .iter() + .filter(|&&elt| elt == needle) + .count(); + + while let Some(index) = iter.next() { + real_count -= 1; + let (lower, upper) = iter.size_hint(); + assert!(lower <= real_count); + assert!(upper.unwrap() >= real_count); + assert!(upper.unwrap() <= data.len() - index); + } + true + } +} + +// take items from a DEI, taking front for each true and back for each false. +// Return a vector with the concatenation of the fronts and the reverse of the +// backs. +fn double_ended_take(mut iter: I, take_side: J) -> Vec +where + I: DoubleEndedIterator, + J: Iterator, +{ + let mut found_front = Vec::new(); + let mut found_back = Vec::new(); + + for take_front in take_side { + if take_front { + if let Some(pos) = iter.next() { + found_front.push(pos); + } else { + break; + } + } else { + if let Some(pos) = iter.next_back() { + found_back.push(pos); + } else { + break; + } + }; + } + + let mut all_found = found_front; + all_found.extend(found_back.into_iter().rev()); + all_found +} + +// return an iterator of the 0-based indices of haystack that match the needle +fn positions1<'a>( + n1: u8, + haystack: &'a [u8], +) -> Box + 'a> { + let it = haystack + .iter() + .enumerate() + .filter(move |&(_, &b)| b == n1) + .map(|t| t.0); + Box::new(it) +} + +fn positions2<'a>( + n1: u8, + n2: u8, + haystack: &'a [u8], +) -> Box + 'a> { + let it = haystack + .iter() + .enumerate() + .filter(move |&(_, &b)| b == n1 || b == n2) + .map(|t| t.0); + Box::new(it) +} + +fn positions3<'a>( + n1: u8, + n2: u8, + n3: u8, + haystack: &'a [u8], +) -> Box + 'a> { + let it = haystack + .iter() + .enumerate() + .filter(move |&(_, &b)| b == n1 || b == n2 || b == n3) + .map(|t| t.0); + Box::new(it) +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/tests/memchr.rs b/third_party/cargo/vendor/memchr-2.3.0/src/tests/memchr.rs new file mode 100644 index 0000000..87d3d14 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/tests/memchr.rs @@ -0,0 +1,131 @@ +use fallback; +use naive; +use {memchr, memchr2, memchr3, memrchr, memrchr2, memrchr3}; + +use tests::memchr_tests; + +#[test] +fn memchr1_find() { + for test in memchr_tests() { + test.one(false, memchr); + } +} + +#[test] +fn memchr1_fallback_find() { + for test in memchr_tests() { + test.one(false, fallback::memchr); + } +} + +#[test] +fn memchr2_find() { + for test in memchr_tests() { + test.two(false, memchr2); + } +} + +#[test] +fn memchr2_fallback_find() { + for test in memchr_tests() { + test.two(false, fallback::memchr2); + } +} + +#[test] +fn memchr3_find() { + for test in memchr_tests() { + test.three(false, memchr3); + } +} + +#[test] +fn memchr3_fallback_find() { + for test in memchr_tests() { + test.three(false, fallback::memchr3); + } +} + +#[test] +fn memrchr1_find() { + for test in memchr_tests() { + test.one(true, memrchr); + } +} + +#[test] +fn memrchr1_fallback_find() { + for test in memchr_tests() { + test.one(true, fallback::memrchr); + } +} + +#[test] +fn memrchr2_find() { + for test in memchr_tests() { + test.two(true, memrchr2); + } +} + +#[test] +fn memrchr2_fallback_find() { + for test in memchr_tests() { + test.two(true, fallback::memrchr2); + } +} + +#[test] +fn memrchr3_find() { + for test in memchr_tests() { + test.three(true, memrchr3); + } +} + +#[test] +fn memrchr3_fallback_find() { + for test in memchr_tests() { + test.three(true, fallback::memrchr3); + } +} + +quickcheck! { + fn qc_memchr1_matches_naive(n1: u8, corpus: Vec) -> bool { + memchr(n1, &corpus) == naive::memchr(n1, &corpus) + } +} + +quickcheck! { + fn qc_memchr2_matches_naive(n1: u8, n2: u8, corpus: Vec) -> bool { + memchr2(n1, n2, &corpus) == naive::memchr2(n1, n2, &corpus) + } +} + +quickcheck! { + fn qc_memchr3_matches_naive( + n1: u8, n2: u8, n3: u8, + corpus: Vec + ) -> bool { + memchr3(n1, n2, n3, &corpus) == naive::memchr3(n1, n2, n3, &corpus) + } +} + +quickcheck! { + fn qc_memrchr1_matches_naive(n1: u8, corpus: Vec) -> bool { + memrchr(n1, &corpus) == naive::memrchr(n1, &corpus) + } +} + +quickcheck! { + fn qc_memrchr2_matches_naive(n1: u8, n2: u8, corpus: Vec) -> bool { + memrchr2(n1, n2, &corpus) == naive::memrchr2(n1, n2, &corpus) + } +} + +quickcheck! { + fn qc_memrchr3_matches_naive( + n1: u8, n2: u8, n3: u8, + corpus: Vec + ) -> bool { + memrchr3(n1, n2, n3, &corpus) == naive::memrchr3(n1, n2, n3, &corpus) + } +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/tests/mod.rs b/third_party/cargo/vendor/memchr-2.3.0/src/tests/mod.rs new file mode 100644 index 0000000..82c1a24 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/tests/mod.rs @@ -0,0 +1,362 @@ +use std::iter::repeat; + +mod iter; +mod memchr; + +#[cfg(target_endian = "little")] +#[test] +fn byte_order() { + eprintln!("LITTLE ENDIAN"); +} + +#[cfg(target_endian = "big")] +#[test] +fn byte_order() { + eprintln!("BIG ENDIAN"); +} + +/// Create a sequence of tests that should be run by memchr implementations. +fn memchr_tests() -> Vec { + let mut tests = Vec::new(); + for statict in MEMCHR_TESTS { + assert!(!statict.corpus.contains("%"), "% is not allowed in corpora"); + assert!(!statict.corpus.contains("#"), "# is not allowed in corpora"); + assert!(!statict.needles.contains(&b'%'), "% is an invalid needle"); + assert!(!statict.needles.contains(&b'#'), "# is an invalid needle"); + + let t = MemchrTest { + corpus: statict.corpus.to_string(), + needles: statict.needles.to_vec(), + positions: statict.positions.to_vec(), + }; + tests.push(t.clone()); + tests.extend(t.expand()); + } + tests +} + +/// A set of tests for memchr-like functions. +/// +/// These tests mostly try to cover the short string cases. We cover the longer +/// string cases via the benchmarks (which are tests themselves), via +/// quickcheck tests and via automatic expansion of each test case (by +/// increasing the corpus size). Finally, we cover different alignment cases +/// in the tests by varying the starting point of the slice. +const MEMCHR_TESTS: &[MemchrTestStatic] = &[ + // one needle (applied to memchr + memchr2 + memchr3) + MemchrTestStatic { corpus: "a", needles: &[b'a'], positions: &[0] }, + MemchrTestStatic { corpus: "aa", needles: &[b'a'], positions: &[0, 1] }, + MemchrTestStatic { + corpus: "aaa", + needles: &[b'a'], + positions: &[0, 1, 2], + }, + MemchrTestStatic { corpus: "", needles: &[b'a'], positions: &[] }, + MemchrTestStatic { corpus: "z", needles: &[b'a'], positions: &[] }, + MemchrTestStatic { corpus: "zz", needles: &[b'a'], positions: &[] }, + MemchrTestStatic { corpus: "zza", needles: &[b'a'], positions: &[2] }, + MemchrTestStatic { corpus: "zaza", needles: &[b'a'], positions: &[1, 3] }, + MemchrTestStatic { corpus: "zzza", needles: &[b'a'], positions: &[3] }, + MemchrTestStatic { corpus: "\x00a", needles: &[b'a'], positions: &[1] }, + MemchrTestStatic { corpus: "\x00", needles: &[b'\x00'], positions: &[0] }, + MemchrTestStatic { + corpus: "\x00\x00", + needles: &[b'\x00'], + positions: &[0, 1], + }, + MemchrTestStatic { + corpus: "\x00a\x00", + needles: &[b'\x00'], + positions: &[0, 2], + }, + MemchrTestStatic { + corpus: "zzzzzzzzzzzzzzzza", + needles: &[b'a'], + positions: &[16], + }, + MemchrTestStatic { + corpus: "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza", + needles: &[b'a'], + positions: &[32], + }, + // two needles (applied to memchr2 + memchr3) + MemchrTestStatic { + corpus: "az", + needles: &[b'a', b'z'], + positions: &[0, 1], + }, + MemchrTestStatic { + corpus: "az", + needles: &[b'a', b'z'], + positions: &[0, 1], + }, + MemchrTestStatic { corpus: "az", needles: &[b'x', b'y'], positions: &[] }, + MemchrTestStatic { corpus: "az", needles: &[b'a', b'y'], positions: &[0] }, + MemchrTestStatic { corpus: "az", needles: &[b'x', b'z'], positions: &[1] }, + MemchrTestStatic { + corpus: "yyyyaz", + needles: &[b'a', b'z'], + positions: &[4, 5], + }, + MemchrTestStatic { + corpus: "yyyyaz", + needles: &[b'z', b'a'], + positions: &[4, 5], + }, + // three needles (applied to memchr3) + MemchrTestStatic { + corpus: "xyz", + needles: &[b'x', b'y', b'z'], + positions: &[0, 1, 2], + }, + MemchrTestStatic { + corpus: "zxy", + needles: &[b'x', b'y', b'z'], + positions: &[0, 1, 2], + }, + MemchrTestStatic { + corpus: "zxy", + needles: &[b'x', b'a', b'z'], + positions: &[0, 1], + }, + MemchrTestStatic { + corpus: "zxy", + needles: &[b't', b'a', b'z'], + positions: &[0], + }, + MemchrTestStatic { + corpus: "yxz", + needles: &[b't', b'a', b'z'], + positions: &[2], + }, +]; + +/// A description of a test on a memchr like function. +#[derive(Clone, Debug)] +struct MemchrTest { + /// The thing to search. We use `&str` instead of `&[u8]` because they + /// are nicer to write in tests, and we don't miss much since memchr + /// doesn't care about UTF-8. + /// + /// Corpora cannot contain either '%' or '#'. We use these bytes when + /// expanding test cases into many test cases, and we assume they are not + /// used. If they are used, `memchr_tests` will panic. + corpus: String, + /// The needles to search for. This is intended to be an "alternation" of + /// needles. The number of needles may cause this test to be skipped for + /// some memchr variants. For example, a test with 2 needles cannot be used + /// to test `memchr`, but can be used to test `memchr2` and `memchr3`. + /// However, a test with only 1 needle can be used to test all of `memchr`, + /// `memchr2` and `memchr3`. We achieve this by filling in the needles with + /// bytes that we never used in the corpus (such as '#'). + needles: Vec, + /// The positions expected to match for all of the needles. + positions: Vec, +} + +/// Like MemchrTest, but easier to define as a constant. +#[derive(Clone, Debug)] +struct MemchrTestStatic { + corpus: &'static str, + needles: &'static [u8], + positions: &'static [usize], +} + +impl MemchrTest { + fn one Option>(&self, reverse: bool, f: F) { + let needles = match self.needles(1) { + None => return, + Some(needles) => needles, + }; + // We test different alignments here. Since some implementations use + // AVX2, which can read 32 bytes at a time, we test at least that. + // Moreover, with loop unrolling, we sometimes process 64 (sse2) or 128 + // (avx) bytes at a time, so we include that in our offsets as well. + // + // You might think this would cause most needles to not be found, but + // we actually expand our tests to include corpus sizes all the way up + // to >500 bytes, so we should exericse most branches. + for align in 0..130 { + let corpus = self.corpus(align); + assert_eq!( + self.positions(align, reverse).get(0).cloned(), + f(needles[0], corpus.as_bytes()), + "search for {:?} failed in: {:?} (len: {}, alignment: {})", + needles[0] as char, + corpus, + corpus.len(), + align + ); + } + } + + fn two Option>(&self, reverse: bool, f: F) { + let needles = match self.needles(2) { + None => return, + Some(needles) => needles, + }; + for align in 0..130 { + let corpus = self.corpus(align); + assert_eq!( + self.positions(align, reverse).get(0).cloned(), + f(needles[0], needles[1], corpus.as_bytes()), + "search for {:?}|{:?} failed in: {:?} \ + (len: {}, alignment: {})", + needles[0] as char, + needles[1] as char, + corpus, + corpus.len(), + align + ); + } + } + + fn three Option>( + &self, + reverse: bool, + f: F, + ) { + let needles = match self.needles(3) { + None => return, + Some(needles) => needles, + }; + for align in 0..130 { + let corpus = self.corpus(align); + assert_eq!( + self.positions(align, reverse).get(0).cloned(), + f(needles[0], needles[1], needles[2], corpus.as_bytes()), + "search for {:?}|{:?}|{:?} failed in: {:?} \ + (len: {}, alignment: {})", + needles[0] as char, + needles[1] as char, + needles[2] as char, + corpus, + corpus.len(), + align + ); + } + } + + fn iter_one<'a, I, F>(&'a self, reverse: bool, f: F) + where + F: FnOnce(u8, &'a [u8]) -> I, + I: Iterator, + { + if let Some(ns) = self.needles(1) { + self.iter(reverse, f(ns[0], self.corpus.as_bytes())); + } + } + + fn iter_two<'a, I, F>(&'a self, reverse: bool, f: F) + where + F: FnOnce(u8, u8, &'a [u8]) -> I, + I: Iterator, + { + if let Some(ns) = self.needles(2) { + self.iter(reverse, f(ns[0], ns[1], self.corpus.as_bytes())); + } + } + + fn iter_three<'a, I, F>(&'a self, reverse: bool, f: F) + where + F: FnOnce(u8, u8, u8, &'a [u8]) -> I, + I: Iterator, + { + if let Some(ns) = self.needles(3) { + self.iter(reverse, f(ns[0], ns[1], ns[2], self.corpus.as_bytes())); + } + } + + /// Test that the positions yielded by the given iterator match the + /// positions in this test. If reverse is true, then reverse the positions + /// before comparing them. + fn iter>(&self, reverse: bool, it: I) { + assert_eq!( + self.positions(0, reverse), + it.collect::>(), + r"search for {:?} failed in: {:?}", + self.needles.iter().map(|&b| b as char).collect::>(), + self.corpus + ); + } + + /// Expand this test into many variations of the same test. + /// + /// In particular, this will generate more tests with larger corpus sizes. + /// The expected positions are updated to maintain the integrity of the + /// test. + /// + /// This is important in testing a memchr implementation, because there are + /// often different cases depending on the length of the corpus. + /// + /// Note that we extend the corpus by adding `%` bytes, which we + /// don't otherwise use as a needle. + fn expand(&self) -> Vec { + let mut more = Vec::new(); + + // Add bytes to the start of the corpus. + for i in 1..515 { + let mut t = self.clone(); + let mut new_corpus: String = repeat('%').take(i).collect(); + new_corpus.push_str(&t.corpus); + t.corpus = new_corpus; + t.positions = t.positions.into_iter().map(|p| p + i).collect(); + more.push(t); + } + // Add bytes to the end of the corpus. + for i in 1..515 { + let mut t = self.clone(); + let padding: String = repeat('%').take(i).collect(); + t.corpus.push_str(&padding); + more.push(t); + } + + more + } + + /// Return the corpus at the given alignment. + /// + /// If the alignment exceeds the length of the corpus, then this returns + /// an empty slice. + fn corpus(&self, align: usize) -> &str { + self.corpus.get(align..).unwrap_or("") + } + + /// Return exactly `count` needles from this test. If this test has less + /// than `count` needles, then add `#` until the number of needles + /// matches `count`. If this test has more than `count` needles, then + /// return `None` (because there is no way to use this test data for a + /// search using fewer needles). + fn needles(&self, count: usize) -> Option> { + if self.needles.len() > count { + return None; + } + + let mut needles = self.needles.to_vec(); + for _ in needles.len()..count { + // we assume # is never used in tests. + needles.push(b'#'); + } + Some(needles) + } + + /// Return the positions in this test, reversed if `reverse` is true. + /// + /// If alignment is given, then all positions greater than or equal to that + /// alignment are offset by the alignment. Positions less than the + /// alignment are dropped. + fn positions(&self, align: usize, reverse: bool) -> Vec { + let positions = if reverse { + let mut positions = self.positions.to_vec(); + positions.reverse(); + positions + } else { + self.positions.to_vec() + }; + positions + .into_iter() + .filter(|&p| p >= align) + .map(|p| p - align) + .collect() + } +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/x86/avx.rs b/third_party/cargo/vendor/memchr-2.3.0/src/x86/avx.rs new file mode 100644 index 0000000..e3d8e89 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/x86/avx.rs @@ -0,0 +1,703 @@ +use core::arch::x86_64::*; +use core::cmp; +use core::mem::size_of; + +use x86::sse2; + +const VECTOR_SIZE: usize = size_of::<__m256i>(); +const VECTOR_ALIGN: usize = VECTOR_SIZE - 1; + +// The number of bytes to loop at in one iteration of memchr/memrchr. +const LOOP_SIZE: usize = 4 * VECTOR_SIZE; + +// The number of bytes to loop at in one iteration of memchr2/memrchr2 and +// memchr3/memrchr3. There was no observable difference between 128 and 64 +// bytes in benchmarks. memchr3 in particular only gets a very slight speed up +// from the loop unrolling. +const LOOP_SIZE2: usize = 2 * VECTOR_SIZE; + +#[target_feature(enable = "avx2")] +pub unsafe fn memchr(n1: u8, haystack: &[u8]) -> Option { + // For a high level explanation for how this algorithm works, see the + // sse2 implementation. The avx implementation here is the same, but with + // 256-bit vectors instead of 128-bit vectors. + + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = start_ptr; + + if haystack.len() < VECTOR_SIZE { + // For small haystacks, defer to the SSE2 implementation. Codegen + // suggests this completely avoids touching the AVX vectors. + return sse2::memchr(n1, haystack); + } + + let vn1 = _mm256_set1_epi8(n1 as i8); + let loop_size = cmp::min(LOOP_SIZE, haystack.len()); + if let Some(i) = forward_search1(start_ptr, end_ptr, ptr, vn1) { + return Some(i); + } + + ptr = ptr.add(VECTOR_SIZE - (start_ptr as usize & VECTOR_ALIGN)); + debug_assert!(ptr > start_ptr && end_ptr.sub(VECTOR_SIZE) >= start_ptr); + while loop_size == LOOP_SIZE && ptr <= end_ptr.sub(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + let a = _mm256_load_si256(ptr as *const __m256i); + let b = _mm256_load_si256(ptr.add(VECTOR_SIZE) as *const __m256i); + let c = _mm256_load_si256(ptr.add(2 * VECTOR_SIZE) as *const __m256i); + let d = _mm256_load_si256(ptr.add(3 * VECTOR_SIZE) as *const __m256i); + let eqa = _mm256_cmpeq_epi8(vn1, a); + let eqb = _mm256_cmpeq_epi8(vn1, b); + let eqc = _mm256_cmpeq_epi8(vn1, c); + let eqd = _mm256_cmpeq_epi8(vn1, d); + let or1 = _mm256_or_si256(eqa, eqb); + let or2 = _mm256_or_si256(eqc, eqd); + let or3 = _mm256_or_si256(or1, or2); + if _mm256_movemask_epi8(or3) != 0 { + let mut at = sub(ptr, start_ptr); + let mask = _mm256_movemask_epi8(eqa); + if mask != 0 { + return Some(at + forward_pos(mask)); + } + + at += VECTOR_SIZE; + let mask = _mm256_movemask_epi8(eqb); + if mask != 0 { + return Some(at + forward_pos(mask)); + } + + at += VECTOR_SIZE; + let mask = _mm256_movemask_epi8(eqc); + if mask != 0 { + return Some(at + forward_pos(mask)); + } + + at += VECTOR_SIZE; + let mask = _mm256_movemask_epi8(eqd); + debug_assert!(mask != 0); + return Some(at + forward_pos(mask)); + } + ptr = ptr.add(loop_size); + } + while ptr <= end_ptr.sub(VECTOR_SIZE) { + debug_assert!(sub(end_ptr, ptr) >= VECTOR_SIZE); + + if let Some(i) = forward_search1(start_ptr, end_ptr, ptr, vn1) { + return Some(i); + } + ptr = ptr.add(VECTOR_SIZE); + } + if ptr < end_ptr { + debug_assert!(sub(end_ptr, ptr) < VECTOR_SIZE); + ptr = ptr.sub(VECTOR_SIZE - sub(end_ptr, ptr)); + debug_assert_eq!(sub(end_ptr, ptr), VECTOR_SIZE); + + return forward_search1(start_ptr, end_ptr, ptr, vn1); + } + None +} + +#[target_feature(enable = "avx2")] +pub unsafe fn memchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option { + let vn1 = _mm256_set1_epi8(n1 as i8); + let vn2 = _mm256_set1_epi8(n2 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE2, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = start_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr < end_ptr { + if *ptr == n1 || *ptr == n2 { + return Some(sub(ptr, start_ptr)); + } + ptr = ptr.offset(1); + } + return None; + } + + if let Some(i) = forward_search2(start_ptr, end_ptr, ptr, vn1, vn2) { + return Some(i); + } + + ptr = ptr.add(VECTOR_SIZE - (start_ptr as usize & VECTOR_ALIGN)); + debug_assert!(ptr > start_ptr && end_ptr.sub(VECTOR_SIZE) >= start_ptr); + while loop_size == LOOP_SIZE2 && ptr <= end_ptr.sub(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + let a = _mm256_load_si256(ptr as *const __m256i); + let b = _mm256_load_si256(ptr.add(VECTOR_SIZE) as *const __m256i); + let eqa1 = _mm256_cmpeq_epi8(vn1, a); + let eqb1 = _mm256_cmpeq_epi8(vn1, b); + let eqa2 = _mm256_cmpeq_epi8(vn2, a); + let eqb2 = _mm256_cmpeq_epi8(vn2, b); + let or1 = _mm256_or_si256(eqa1, eqb1); + let or2 = _mm256_or_si256(eqa2, eqb2); + let or3 = _mm256_or_si256(or1, or2); + if _mm256_movemask_epi8(or3) != 0 { + let mut at = sub(ptr, start_ptr); + let mask1 = _mm256_movemask_epi8(eqa1); + let mask2 = _mm256_movemask_epi8(eqa2); + if mask1 != 0 || mask2 != 0 { + return Some(at + forward_pos2(mask1, mask2)); + } + + at += VECTOR_SIZE; + let mask1 = _mm256_movemask_epi8(eqb1); + let mask2 = _mm256_movemask_epi8(eqb2); + return Some(at + forward_pos2(mask1, mask2)); + } + ptr = ptr.add(loop_size); + } + while ptr <= end_ptr.sub(VECTOR_SIZE) { + if let Some(i) = forward_search2(start_ptr, end_ptr, ptr, vn1, vn2) { + return Some(i); + } + ptr = ptr.add(VECTOR_SIZE); + } + if ptr < end_ptr { + debug_assert!(sub(end_ptr, ptr) < VECTOR_SIZE); + ptr = ptr.sub(VECTOR_SIZE - sub(end_ptr, ptr)); + debug_assert_eq!(sub(end_ptr, ptr), VECTOR_SIZE); + + return forward_search2(start_ptr, end_ptr, ptr, vn1, vn2); + } + None +} + +#[target_feature(enable = "avx2")] +pub unsafe fn memchr3( + n1: u8, + n2: u8, + n3: u8, + haystack: &[u8], +) -> Option { + let vn1 = _mm256_set1_epi8(n1 as i8); + let vn2 = _mm256_set1_epi8(n2 as i8); + let vn3 = _mm256_set1_epi8(n3 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE2, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = start_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr < end_ptr { + if *ptr == n1 || *ptr == n2 || *ptr == n3 { + return Some(sub(ptr, start_ptr)); + } + ptr = ptr.offset(1); + } + return None; + } + + if let Some(i) = forward_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3) { + return Some(i); + } + + ptr = ptr.add(VECTOR_SIZE - (start_ptr as usize & VECTOR_ALIGN)); + debug_assert!(ptr > start_ptr && end_ptr.sub(VECTOR_SIZE) >= start_ptr); + while loop_size == LOOP_SIZE2 && ptr <= end_ptr.sub(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + let a = _mm256_load_si256(ptr as *const __m256i); + let b = _mm256_load_si256(ptr.add(VECTOR_SIZE) as *const __m256i); + let eqa1 = _mm256_cmpeq_epi8(vn1, a); + let eqb1 = _mm256_cmpeq_epi8(vn1, b); + let eqa2 = _mm256_cmpeq_epi8(vn2, a); + let eqb2 = _mm256_cmpeq_epi8(vn2, b); + let eqa3 = _mm256_cmpeq_epi8(vn3, a); + let eqb3 = _mm256_cmpeq_epi8(vn3, b); + let or1 = _mm256_or_si256(eqa1, eqb1); + let or2 = _mm256_or_si256(eqa2, eqb2); + let or3 = _mm256_or_si256(eqa3, eqb3); + let or4 = _mm256_or_si256(or1, or2); + let or5 = _mm256_or_si256(or3, or4); + if _mm256_movemask_epi8(or5) != 0 { + let mut at = sub(ptr, start_ptr); + let mask1 = _mm256_movemask_epi8(eqa1); + let mask2 = _mm256_movemask_epi8(eqa2); + let mask3 = _mm256_movemask_epi8(eqa3); + if mask1 != 0 || mask2 != 0 || mask3 != 0 { + return Some(at + forward_pos3(mask1, mask2, mask3)); + } + + at += VECTOR_SIZE; + let mask1 = _mm256_movemask_epi8(eqb1); + let mask2 = _mm256_movemask_epi8(eqb2); + let mask3 = _mm256_movemask_epi8(eqb3); + return Some(at + forward_pos3(mask1, mask2, mask3)); + } + ptr = ptr.add(loop_size); + } + while ptr <= end_ptr.sub(VECTOR_SIZE) { + if let Some(i) = + forward_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3) + { + return Some(i); + } + ptr = ptr.add(VECTOR_SIZE); + } + if ptr < end_ptr { + debug_assert!(sub(end_ptr, ptr) < VECTOR_SIZE); + ptr = ptr.sub(VECTOR_SIZE - sub(end_ptr, ptr)); + debug_assert_eq!(sub(end_ptr, ptr), VECTOR_SIZE); + + return forward_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3); + } + None +} + +#[target_feature(enable = "avx2")] +pub unsafe fn memrchr(n1: u8, haystack: &[u8]) -> Option { + let vn1 = _mm256_set1_epi8(n1 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = end_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr > start_ptr { + ptr = ptr.offset(-1); + if *ptr == n1 { + return Some(sub(ptr, start_ptr)); + } + } + return None; + } + + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = reverse_search1(start_ptr, end_ptr, ptr, vn1) { + return Some(i); + } + + ptr = (end_ptr as usize & !VECTOR_ALIGN) as *const u8; + debug_assert!(start_ptr <= ptr && ptr <= end_ptr); + while loop_size == LOOP_SIZE && ptr >= start_ptr.add(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + ptr = ptr.sub(loop_size); + let a = _mm256_load_si256(ptr as *const __m256i); + let b = _mm256_load_si256(ptr.add(VECTOR_SIZE) as *const __m256i); + let c = _mm256_load_si256(ptr.add(2 * VECTOR_SIZE) as *const __m256i); + let d = _mm256_load_si256(ptr.add(3 * VECTOR_SIZE) as *const __m256i); + let eqa = _mm256_cmpeq_epi8(vn1, a); + let eqb = _mm256_cmpeq_epi8(vn1, b); + let eqc = _mm256_cmpeq_epi8(vn1, c); + let eqd = _mm256_cmpeq_epi8(vn1, d); + let or1 = _mm256_or_si256(eqa, eqb); + let or2 = _mm256_or_si256(eqc, eqd); + let or3 = _mm256_or_si256(or1, or2); + if _mm256_movemask_epi8(or3) != 0 { + let mut at = sub(ptr.add(3 * VECTOR_SIZE), start_ptr); + let mask = _mm256_movemask_epi8(eqd); + if mask != 0 { + return Some(at + reverse_pos(mask)); + } + + at -= VECTOR_SIZE; + let mask = _mm256_movemask_epi8(eqc); + if mask != 0 { + return Some(at + reverse_pos(mask)); + } + + at -= VECTOR_SIZE; + let mask = _mm256_movemask_epi8(eqb); + if mask != 0 { + return Some(at + reverse_pos(mask)); + } + + at -= VECTOR_SIZE; + let mask = _mm256_movemask_epi8(eqa); + debug_assert!(mask != 0); + return Some(at + reverse_pos(mask)); + } + } + while ptr >= start_ptr.add(VECTOR_SIZE) { + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = reverse_search1(start_ptr, end_ptr, ptr, vn1) { + return Some(i); + } + } + if ptr > start_ptr { + debug_assert!(sub(ptr, start_ptr) < VECTOR_SIZE); + return reverse_search1(start_ptr, end_ptr, start_ptr, vn1); + } + None +} + +#[target_feature(enable = "avx2")] +pub unsafe fn memrchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option { + let vn1 = _mm256_set1_epi8(n1 as i8); + let vn2 = _mm256_set1_epi8(n2 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE2, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = end_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr > start_ptr { + ptr = ptr.offset(-1); + if *ptr == n1 || *ptr == n2 { + return Some(sub(ptr, start_ptr)); + } + } + return None; + } + + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = reverse_search2(start_ptr, end_ptr, ptr, vn1, vn2) { + return Some(i); + } + + ptr = (end_ptr as usize & !VECTOR_ALIGN) as *const u8; + debug_assert!(start_ptr <= ptr && ptr <= end_ptr); + while loop_size == LOOP_SIZE2 && ptr >= start_ptr.add(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + ptr = ptr.sub(loop_size); + let a = _mm256_load_si256(ptr as *const __m256i); + let b = _mm256_load_si256(ptr.add(VECTOR_SIZE) as *const __m256i); + let eqa1 = _mm256_cmpeq_epi8(vn1, a); + let eqb1 = _mm256_cmpeq_epi8(vn1, b); + let eqa2 = _mm256_cmpeq_epi8(vn2, a); + let eqb2 = _mm256_cmpeq_epi8(vn2, b); + let or1 = _mm256_or_si256(eqa1, eqb1); + let or2 = _mm256_or_si256(eqa2, eqb2); + let or3 = _mm256_or_si256(or1, or2); + if _mm256_movemask_epi8(or3) != 0 { + let mut at = sub(ptr.add(VECTOR_SIZE), start_ptr); + let mask1 = _mm256_movemask_epi8(eqb1); + let mask2 = _mm256_movemask_epi8(eqb2); + if mask1 != 0 || mask2 != 0 { + return Some(at + reverse_pos2(mask1, mask2)); + } + + at -= VECTOR_SIZE; + let mask1 = _mm256_movemask_epi8(eqa1); + let mask2 = _mm256_movemask_epi8(eqa2); + return Some(at + reverse_pos2(mask1, mask2)); + } + } + while ptr >= start_ptr.add(VECTOR_SIZE) { + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = reverse_search2(start_ptr, end_ptr, ptr, vn1, vn2) { + return Some(i); + } + } + if ptr > start_ptr { + debug_assert!(sub(ptr, start_ptr) < VECTOR_SIZE); + return reverse_search2(start_ptr, end_ptr, start_ptr, vn1, vn2); + } + None +} + +#[target_feature(enable = "avx2")] +pub unsafe fn memrchr3( + n1: u8, + n2: u8, + n3: u8, + haystack: &[u8], +) -> Option { + let vn1 = _mm256_set1_epi8(n1 as i8); + let vn2 = _mm256_set1_epi8(n2 as i8); + let vn3 = _mm256_set1_epi8(n3 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE2, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = end_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr > start_ptr { + ptr = ptr.offset(-1); + if *ptr == n1 || *ptr == n2 || *ptr == n3 { + return Some(sub(ptr, start_ptr)); + } + } + return None; + } + + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = reverse_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3) { + return Some(i); + } + + ptr = (end_ptr as usize & !VECTOR_ALIGN) as *const u8; + debug_assert!(start_ptr <= ptr && ptr <= end_ptr); + while loop_size == LOOP_SIZE2 && ptr >= start_ptr.add(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + ptr = ptr.sub(loop_size); + let a = _mm256_load_si256(ptr as *const __m256i); + let b = _mm256_load_si256(ptr.add(VECTOR_SIZE) as *const __m256i); + let eqa1 = _mm256_cmpeq_epi8(vn1, a); + let eqb1 = _mm256_cmpeq_epi8(vn1, b); + let eqa2 = _mm256_cmpeq_epi8(vn2, a); + let eqb2 = _mm256_cmpeq_epi8(vn2, b); + let eqa3 = _mm256_cmpeq_epi8(vn3, a); + let eqb3 = _mm256_cmpeq_epi8(vn3, b); + let or1 = _mm256_or_si256(eqa1, eqb1); + let or2 = _mm256_or_si256(eqa2, eqb2); + let or3 = _mm256_or_si256(eqa3, eqb3); + let or4 = _mm256_or_si256(or1, or2); + let or5 = _mm256_or_si256(or3, or4); + if _mm256_movemask_epi8(or5) != 0 { + let mut at = sub(ptr.add(VECTOR_SIZE), start_ptr); + let mask1 = _mm256_movemask_epi8(eqb1); + let mask2 = _mm256_movemask_epi8(eqb2); + let mask3 = _mm256_movemask_epi8(eqb3); + if mask1 != 0 || mask2 != 0 || mask3 != 0 { + return Some(at + reverse_pos3(mask1, mask2, mask3)); + } + + at -= VECTOR_SIZE; + let mask1 = _mm256_movemask_epi8(eqa1); + let mask2 = _mm256_movemask_epi8(eqa2); + let mask3 = _mm256_movemask_epi8(eqa3); + return Some(at + reverse_pos3(mask1, mask2, mask3)); + } + } + while ptr >= start_ptr.add(VECTOR_SIZE) { + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = + reverse_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3) + { + return Some(i); + } + } + if ptr > start_ptr { + debug_assert!(sub(ptr, start_ptr) < VECTOR_SIZE); + return reverse_search3(start_ptr, end_ptr, start_ptr, vn1, vn2, vn3); + } + None +} + +#[target_feature(enable = "avx2")] +unsafe fn forward_search1( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m256i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm256_loadu_si256(ptr as *const __m256i); + let mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(chunk, vn1)); + if mask != 0 { + Some(sub(ptr, start_ptr) + forward_pos(mask)) + } else { + None + } +} + +#[target_feature(enable = "avx2")] +unsafe fn forward_search2( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m256i, + vn2: __m256i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm256_loadu_si256(ptr as *const __m256i); + let eq1 = _mm256_cmpeq_epi8(chunk, vn1); + let eq2 = _mm256_cmpeq_epi8(chunk, vn2); + if _mm256_movemask_epi8(_mm256_or_si256(eq1, eq2)) != 0 { + let mask1 = _mm256_movemask_epi8(eq1); + let mask2 = _mm256_movemask_epi8(eq2); + Some(sub(ptr, start_ptr) + forward_pos2(mask1, mask2)) + } else { + None + } +} + +#[target_feature(enable = "avx2")] +unsafe fn forward_search3( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m256i, + vn2: __m256i, + vn3: __m256i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm256_loadu_si256(ptr as *const __m256i); + let eq1 = _mm256_cmpeq_epi8(chunk, vn1); + let eq2 = _mm256_cmpeq_epi8(chunk, vn2); + let eq3 = _mm256_cmpeq_epi8(chunk, vn3); + let or = _mm256_or_si256(eq1, eq2); + if _mm256_movemask_epi8(_mm256_or_si256(or, eq3)) != 0 { + let mask1 = _mm256_movemask_epi8(eq1); + let mask2 = _mm256_movemask_epi8(eq2); + let mask3 = _mm256_movemask_epi8(eq3); + Some(sub(ptr, start_ptr) + forward_pos3(mask1, mask2, mask3)) + } else { + None + } +} + +#[target_feature(enable = "avx2")] +unsafe fn reverse_search1( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m256i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm256_loadu_si256(ptr as *const __m256i); + let mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(vn1, chunk)); + if mask != 0 { + Some(sub(ptr, start_ptr) + reverse_pos(mask)) + } else { + None + } +} + +#[target_feature(enable = "avx2")] +unsafe fn reverse_search2( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m256i, + vn2: __m256i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm256_loadu_si256(ptr as *const __m256i); + let eq1 = _mm256_cmpeq_epi8(chunk, vn1); + let eq2 = _mm256_cmpeq_epi8(chunk, vn2); + if _mm256_movemask_epi8(_mm256_or_si256(eq1, eq2)) != 0 { + let mask1 = _mm256_movemask_epi8(eq1); + let mask2 = _mm256_movemask_epi8(eq2); + Some(sub(ptr, start_ptr) + reverse_pos2(mask1, mask2)) + } else { + None + } +} + +#[target_feature(enable = "avx2")] +unsafe fn reverse_search3( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m256i, + vn2: __m256i, + vn3: __m256i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm256_loadu_si256(ptr as *const __m256i); + let eq1 = _mm256_cmpeq_epi8(chunk, vn1); + let eq2 = _mm256_cmpeq_epi8(chunk, vn2); + let eq3 = _mm256_cmpeq_epi8(chunk, vn3); + let or = _mm256_or_si256(eq1, eq2); + if _mm256_movemask_epi8(_mm256_or_si256(or, eq3)) != 0 { + let mask1 = _mm256_movemask_epi8(eq1); + let mask2 = _mm256_movemask_epi8(eq2); + let mask3 = _mm256_movemask_epi8(eq3); + Some(sub(ptr, start_ptr) + reverse_pos3(mask1, mask2, mask3)) + } else { + None + } +} + +/// Compute the position of the first matching byte from the given mask. The +/// position returned is always in the range [0, 31]. +/// +/// The mask given is expected to be the result of _mm256_movemask_epi8. +fn forward_pos(mask: i32) -> usize { + // We are dealing with little endian here, where the most significant byte + // is at a higher address. That means the least significant bit that is set + // corresponds to the position of our first matching byte. That position + // corresponds to the number of zeros after the least significant bit. + mask.trailing_zeros() as usize +} + +/// Compute the position of the first matching byte from the given masks. The +/// position returned is always in the range [0, 31]. Each mask corresponds to +/// the equality comparison of a single byte. +/// +/// The masks given are expected to be the result of _mm256_movemask_epi8, +/// where at least one of the masks is non-zero (i.e., indicates a match). +fn forward_pos2(mask1: i32, mask2: i32) -> usize { + debug_assert!(mask1 != 0 || mask2 != 0); + + forward_pos(mask1 | mask2) +} + +/// Compute the position of the first matching byte from the given masks. The +/// position returned is always in the range [0, 31]. Each mask corresponds to +/// the equality comparison of a single byte. +/// +/// The masks given are expected to be the result of _mm256_movemask_epi8, +/// where at least one of the masks is non-zero (i.e., indicates a match). +fn forward_pos3(mask1: i32, mask2: i32, mask3: i32) -> usize { + debug_assert!(mask1 != 0 || mask2 != 0 || mask3 != 0); + + forward_pos(mask1 | mask2 | mask3) +} + +/// Compute the position of the last matching byte from the given mask. The +/// position returned is always in the range [0, 31]. +/// +/// The mask given is expected to be the result of _mm256_movemask_epi8. +fn reverse_pos(mask: i32) -> usize { + // We are dealing with little endian here, where the most significant byte + // is at a higher address. That means the most significant bit that is set + // corresponds to the position of our last matching byte. The position from + // the end of the mask is therefore the number of leading zeros in a 32 + // bit integer, and the position from the start of the mask is therefore + // 32 - (leading zeros) - 1. + VECTOR_SIZE - (mask as u32).leading_zeros() as usize - 1 +} + +/// Compute the position of the last matching byte from the given masks. The +/// position returned is always in the range [0, 31]. Each mask corresponds to +/// the equality comparison of a single byte. +/// +/// The masks given are expected to be the result of _mm256_movemask_epi8, +/// where at least one of the masks is non-zero (i.e., indicates a match). +fn reverse_pos2(mask1: i32, mask2: i32) -> usize { + debug_assert!(mask1 != 0 || mask2 != 0); + + reverse_pos(mask1 | mask2) +} + +/// Compute the position of the last matching byte from the given masks. The +/// position returned is always in the range [0, 31]. Each mask corresponds to +/// the equality comparison of a single byte. +/// +/// The masks given are expected to be the result of _mm256_movemask_epi8, +/// where at least one of the masks is non-zero (i.e., indicates a match). +fn reverse_pos3(mask1: i32, mask2: i32, mask3: i32) -> usize { + debug_assert!(mask1 != 0 || mask2 != 0 || mask3 != 0); + + reverse_pos(mask1 | mask2 | mask3) +} + +/// Subtract `b` from `a` and return the difference. `a` should be greater than +/// or equal to `b`. +fn sub(a: *const u8, b: *const u8) -> usize { + debug_assert!(a >= b); + (a as usize) - (b as usize) +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/x86/mod.rs b/third_party/cargo/vendor/memchr-2.3.0/src/x86/mod.rs new file mode 100644 index 0000000..855dc8b --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/x86/mod.rs @@ -0,0 +1,119 @@ +use fallback; + +// We only use AVX when we can detect at runtime whether it's available, which +// requires std. +#[cfg(feature = "std")] +mod avx; +mod sse2; + +// This macro employs a gcc-like "ifunc" trick where by upon first calling +// `memchr` (for example), CPU feature detection will be performed at runtime +// to determine the best implementation to use. After CPU feature detection +// is done, we replace `memchr`'s function pointer with the selection. Upon +// subsequent invocations, the CPU-specific routine is invoked directly, which +// skips the CPU feature detection and subsequent branch that's required. +// +// While this typically doesn't matter for rare occurrences or when used on +// larger haystacks, `memchr` can be called in tight loops where the overhead +// of this branch can actually add up *and is measurable*. This trick was +// necessary to bring this implementation up to glibc's speeds for the 'tiny' +// benchmarks, for example. +// +// At some point, I expect the Rust ecosystem will get a nice macro for doing +// exactly this, at which point, we can replace our hand-jammed version of it. +// +// N.B. The ifunc strategy does prevent function inlining of course, but on +// modern CPUs, you'll probably end up with the AVX2 implementation, which +// probably can't be inlined anyway---unless you've compiled your entire +// program with AVX2 enabled. However, even then, the various memchr +// implementations aren't exactly small, so inlining might not help anyway! +#[cfg(feature = "std")] +macro_rules! ifunc { + ($fnty:ty, $name:ident, $haystack:ident, $($needle:ident),+) => {{ + use std::mem; + use std::sync::atomic::{AtomicPtr, Ordering}; + + type FnRaw = *mut (); + + static FN: AtomicPtr<()> = AtomicPtr::new(detect as FnRaw); + + fn detect($($needle: u8),+, haystack: &[u8]) -> Option { + let fun = + if cfg!(memchr_runtime_avx) && is_x86_feature_detected!("avx2") { + avx::$name as FnRaw + } else if cfg!(memchr_runtime_sse2) { + sse2::$name as FnRaw + } else { + fallback::$name as FnRaw + }; + FN.store(fun as FnRaw, Ordering::Relaxed); + unsafe { + mem::transmute::(fun)($($needle),+, haystack) + } + } + + unsafe { + let fun = FN.load(Ordering::Relaxed); + mem::transmute::(fun)($($needle),+, $haystack) + } + }} +} + +// When std isn't available to provide runtime CPU feature detection, or if +// runtime CPU feature detection has been explicitly disabled, then just call +// our optimized SSE2 routine directly. SSE2 is avalbale on all x86_64 targets, +// so no CPU feature detection is necessary. +#[cfg(not(feature = "std"))] +macro_rules! ifunc { + ($fnty:ty, $name:ident, $haystack:ident, $($needle:ident),+) => {{ + if cfg!(memchr_runtime_sse2) { + unsafe { sse2::$name($($needle),+, $haystack) } + } else { + fallback::$name($($needle),+, $haystack) + } + }} +} + +#[inline(always)] +pub fn memchr(n1: u8, haystack: &[u8]) -> Option { + ifunc!(fn(u8, &[u8]) -> Option, memchr, haystack, n1) +} + +#[inline(always)] +pub fn memchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option { + ifunc!(fn(u8, u8, &[u8]) -> Option, memchr2, haystack, n1, n2) +} + +#[inline(always)] +pub fn memchr3(n1: u8, n2: u8, n3: u8, haystack: &[u8]) -> Option { + ifunc!( + fn(u8, u8, u8, &[u8]) -> Option, + memchr3, + haystack, + n1, + n2, + n3 + ) +} + +#[inline(always)] +pub fn memrchr(n1: u8, haystack: &[u8]) -> Option { + ifunc!(fn(u8, &[u8]) -> Option, memrchr, haystack, n1) +} + +#[inline(always)] +pub fn memrchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option { + ifunc!(fn(u8, u8, &[u8]) -> Option, memrchr2, haystack, n1, n2) +} + +#[inline(always)] +pub fn memrchr3(n1: u8, n2: u8, n3: u8, haystack: &[u8]) -> Option { + ifunc!( + fn(u8, u8, u8, &[u8]) -> Option, + memrchr3, + haystack, + n1, + n2, + n3 + ) +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/x86/sse2.rs b/third_party/cargo/vendor/memchr-2.3.0/src/x86/sse2.rs new file mode 100644 index 0000000..76f5a78 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/x86/sse2.rs @@ -0,0 +1,793 @@ +use core::arch::x86_64::*; +use core::cmp; +use core::mem::size_of; + +const VECTOR_SIZE: usize = size_of::<__m128i>(); +const VECTOR_ALIGN: usize = VECTOR_SIZE - 1; + +// The number of bytes to loop at in one iteration of memchr/memrchr. +const LOOP_SIZE: usize = 4 * VECTOR_SIZE; + +// The number of bytes to loop at in one iteration of memchr2/memrchr2 and +// memchr3/memrchr3. There was no observable difference between 64 and 32 bytes +// in benchmarks. memchr3 in particular only gets a very slight speed up from +// the loop unrolling. +const LOOP_SIZE2: usize = 2 * VECTOR_SIZE; + +#[target_feature(enable = "sse2")] +pub unsafe fn memchr(n1: u8, haystack: &[u8]) -> Option { + // What follows is a fast SSE2-only algorithm to detect the position of + // `n1` in `haystack` if it exists. From what I know, this is the "classic" + // algorithm. I believe it can be found in places like glibc and Go's + // standard library. It appears to be well known and is elaborated on in + // more detail here: https://gms.tf/stdfind-and-memchr-optimizations.html + // + // While this routine is very long, the basic idea is actually very simple + // and can be expressed straight-forwardly in pseudo code: + // + // needle = (n1 << 15) | (n1 << 14) | ... | (n1 << 1) | n1 + // // Note: shift amount in bytes + // + // while i <= haystack.len() - 16: + // // A 16 byte vector. Each byte in chunk corresponds to a byte in + // // the haystack. + // chunk = haystack[i:i+16] + // // Compare bytes in needle with bytes in chunk. The result is a 16 + // // byte chunk where each byte is 0xFF if the corresponding bytes + // // in needle and chunk were equal, or 0x00 otherwise. + // eqs = cmpeq(needle, chunk) + // // Return a 32 bit integer where the most significant 16 bits + // // are always 0 and the lower 16 bits correspond to whether the + // // most significant bit in the correspond byte in `eqs` is set. + // // In other words, `mask as u16` has bit i set if and only if + // // needle[i] == chunk[i]. + // mask = movemask(eqs) + // + // // Mask is 0 if there is no match, and non-zero otherwise. + // if mask != 0: + // // trailing_zeros tells us the position of the least significant + // // bit that is set. + // return i + trailing_zeros(mask) + // + // // haystack length may not be a multiple of 16, so search the rest. + // while i < haystack.len(): + // if haystack[i] == n1: + // return i + // + // // No match found. + // return NULL + // + // In fact, we could loosely translate the above code to Rust line-for-line + // and it would be a pretty fast algorithm. But, we pull out all the stops + // to go as fast as possible: + // + // 1. We use aligned loads. That is, we do some finagling to make sure our + // primary loop not only proceeds in increments of 16 bytes, but that + // the address of haystack's pointer that we dereference is aligned to + // 16 bytes. 16 is a magic number here because it is the size of SSE2 + // 128-bit vector. (For the AVX2 algorithm, 32 is the magic number.) + // Therefore, to get aligned loads, our pointer's address must be evenly + // divisible by 16. + // 2. Our primary loop proceeds 64 bytes at a time instead of 16. It's + // kind of like loop unrolling, but we combine the equality comparisons + // using a vector OR such that we only need to extract a single mask to + // determine whether a match exists or not. If so, then we do some + // book-keeping to determine the precise location but otherwise mush on. + // 3. We use our "chunk" comparison routine in as many places as possible, + // even if it means using unaligned loads. In particular, if haystack + // starts with an unaligned address, then we do an unaligned load to + // search the first 16 bytes. We then start our primary loop at the + // smallest subsequent aligned address, which will actually overlap with + // previously searched bytes. But we're OK with that. We do a similar + // dance at the end of our primary loop. Finally, to avoid a + // byte-at-a-time loop at the end, we do a final 16 byte unaligned load + // that may overlap with a previous load. This is OK because it converts + // a loop into a small number of very fast vector instructions. + // + // The primary downside of this algorithm is that it's effectively + // completely unsafe. Therefore, we have to be super careful to avoid + // undefined behavior: + // + // 1. We use raw pointers everywhere. Not only does dereferencing a pointer + // require the pointer to be valid, but we actually can't even store the + // address of an invalid pointer (unless it's 1 past the end of + // haystack) without sacrificing performance. + // 2. _mm_loadu_si128 is used when you don't care about alignment, and + // _mm_load_si128 is used when you do care. You cannot use the latter + // on unaligned pointers. + // 3. We make liberal use of debug_assert! to check assumptions. + // 4. We make a concerted effort to stick with pointers instead of indices. + // Indices are nicer because there's less to worry about with them (see + // above about pointer offsets), but I could not get the compiler to + // produce as good of code as what the below produces. In any case, + // pointers are what we really care about here, and alignment is + // expressed a bit more naturally with them. + // + // In general, most of the algorithms in this crate have a similar + // structure to what you see below, so this comment applies fairly well to + // all of them. + + let vn1 = _mm_set1_epi8(n1 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = start_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr < end_ptr { + if *ptr == n1 { + return Some(sub(ptr, start_ptr)); + } + ptr = ptr.offset(1); + } + return None; + } + + if let Some(i) = forward_search1(start_ptr, end_ptr, ptr, vn1) { + return Some(i); + } + + ptr = ptr.add(VECTOR_SIZE - (start_ptr as usize & VECTOR_ALIGN)); + debug_assert!(ptr > start_ptr && end_ptr.sub(VECTOR_SIZE) >= start_ptr); + while loop_size == LOOP_SIZE && ptr <= end_ptr.sub(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + let a = _mm_load_si128(ptr as *const __m128i); + let b = _mm_load_si128(ptr.add(VECTOR_SIZE) as *const __m128i); + let c = _mm_load_si128(ptr.add(2 * VECTOR_SIZE) as *const __m128i); + let d = _mm_load_si128(ptr.add(3 * VECTOR_SIZE) as *const __m128i); + let eqa = _mm_cmpeq_epi8(vn1, a); + let eqb = _mm_cmpeq_epi8(vn1, b); + let eqc = _mm_cmpeq_epi8(vn1, c); + let eqd = _mm_cmpeq_epi8(vn1, d); + let or1 = _mm_or_si128(eqa, eqb); + let or2 = _mm_or_si128(eqc, eqd); + let or3 = _mm_or_si128(or1, or2); + if _mm_movemask_epi8(or3) != 0 { + let mut at = sub(ptr, start_ptr); + let mask = _mm_movemask_epi8(eqa); + if mask != 0 { + return Some(at + forward_pos(mask)); + } + + at += VECTOR_SIZE; + let mask = _mm_movemask_epi8(eqb); + if mask != 0 { + return Some(at + forward_pos(mask)); + } + + at += VECTOR_SIZE; + let mask = _mm_movemask_epi8(eqc); + if mask != 0 { + return Some(at + forward_pos(mask)); + } + + at += VECTOR_SIZE; + let mask = _mm_movemask_epi8(eqd); + debug_assert!(mask != 0); + return Some(at + forward_pos(mask)); + } + ptr = ptr.add(loop_size); + } + while ptr <= end_ptr.sub(VECTOR_SIZE) { + debug_assert!(sub(end_ptr, ptr) >= VECTOR_SIZE); + + if let Some(i) = forward_search1(start_ptr, end_ptr, ptr, vn1) { + return Some(i); + } + ptr = ptr.add(VECTOR_SIZE); + } + if ptr < end_ptr { + debug_assert!(sub(end_ptr, ptr) < VECTOR_SIZE); + ptr = ptr.sub(VECTOR_SIZE - sub(end_ptr, ptr)); + debug_assert_eq!(sub(end_ptr, ptr), VECTOR_SIZE); + + return forward_search1(start_ptr, end_ptr, ptr, vn1); + } + None +} + +#[target_feature(enable = "sse2")] +pub unsafe fn memchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option { + let vn1 = _mm_set1_epi8(n1 as i8); + let vn2 = _mm_set1_epi8(n2 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE2, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = start_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr < end_ptr { + if *ptr == n1 || *ptr == n2 { + return Some(sub(ptr, start_ptr)); + } + ptr = ptr.offset(1); + } + return None; + } + + if let Some(i) = forward_search2(start_ptr, end_ptr, ptr, vn1, vn2) { + return Some(i); + } + + ptr = ptr.add(VECTOR_SIZE - (start_ptr as usize & VECTOR_ALIGN)); + debug_assert!(ptr > start_ptr && end_ptr.sub(VECTOR_SIZE) >= start_ptr); + while loop_size == LOOP_SIZE2 && ptr <= end_ptr.sub(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + let a = _mm_load_si128(ptr as *const __m128i); + let b = _mm_load_si128(ptr.add(VECTOR_SIZE) as *const __m128i); + let eqa1 = _mm_cmpeq_epi8(vn1, a); + let eqb1 = _mm_cmpeq_epi8(vn1, b); + let eqa2 = _mm_cmpeq_epi8(vn2, a); + let eqb2 = _mm_cmpeq_epi8(vn2, b); + let or1 = _mm_or_si128(eqa1, eqb1); + let or2 = _mm_or_si128(eqa2, eqb2); + let or3 = _mm_or_si128(or1, or2); + if _mm_movemask_epi8(or3) != 0 { + let mut at = sub(ptr, start_ptr); + let mask1 = _mm_movemask_epi8(eqa1); + let mask2 = _mm_movemask_epi8(eqa2); + if mask1 != 0 || mask2 != 0 { + return Some(at + forward_pos2(mask1, mask2)); + } + + at += VECTOR_SIZE; + let mask1 = _mm_movemask_epi8(eqb1); + let mask2 = _mm_movemask_epi8(eqb2); + return Some(at + forward_pos2(mask1, mask2)); + } + ptr = ptr.add(loop_size); + } + while ptr <= end_ptr.sub(VECTOR_SIZE) { + if let Some(i) = forward_search2(start_ptr, end_ptr, ptr, vn1, vn2) { + return Some(i); + } + ptr = ptr.add(VECTOR_SIZE); + } + if ptr < end_ptr { + debug_assert!(sub(end_ptr, ptr) < VECTOR_SIZE); + ptr = ptr.sub(VECTOR_SIZE - sub(end_ptr, ptr)); + debug_assert_eq!(sub(end_ptr, ptr), VECTOR_SIZE); + + return forward_search2(start_ptr, end_ptr, ptr, vn1, vn2); + } + None +} + +#[target_feature(enable = "sse2")] +pub unsafe fn memchr3( + n1: u8, + n2: u8, + n3: u8, + haystack: &[u8], +) -> Option { + let vn1 = _mm_set1_epi8(n1 as i8); + let vn2 = _mm_set1_epi8(n2 as i8); + let vn3 = _mm_set1_epi8(n3 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE2, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = start_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr < end_ptr { + if *ptr == n1 || *ptr == n2 || *ptr == n3 { + return Some(sub(ptr, start_ptr)); + } + ptr = ptr.offset(1); + } + return None; + } + + if let Some(i) = forward_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3) { + return Some(i); + } + + ptr = ptr.add(VECTOR_SIZE - (start_ptr as usize & VECTOR_ALIGN)); + debug_assert!(ptr > start_ptr && end_ptr.sub(VECTOR_SIZE) >= start_ptr); + while loop_size == LOOP_SIZE2 && ptr <= end_ptr.sub(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + let a = _mm_load_si128(ptr as *const __m128i); + let b = _mm_load_si128(ptr.add(VECTOR_SIZE) as *const __m128i); + let eqa1 = _mm_cmpeq_epi8(vn1, a); + let eqb1 = _mm_cmpeq_epi8(vn1, b); + let eqa2 = _mm_cmpeq_epi8(vn2, a); + let eqb2 = _mm_cmpeq_epi8(vn2, b); + let eqa3 = _mm_cmpeq_epi8(vn3, a); + let eqb3 = _mm_cmpeq_epi8(vn3, b); + let or1 = _mm_or_si128(eqa1, eqb1); + let or2 = _mm_or_si128(eqa2, eqb2); + let or3 = _mm_or_si128(eqa3, eqb3); + let or4 = _mm_or_si128(or1, or2); + let or5 = _mm_or_si128(or3, or4); + if _mm_movemask_epi8(or5) != 0 { + let mut at = sub(ptr, start_ptr); + let mask1 = _mm_movemask_epi8(eqa1); + let mask2 = _mm_movemask_epi8(eqa2); + let mask3 = _mm_movemask_epi8(eqa3); + if mask1 != 0 || mask2 != 0 || mask3 != 0 { + return Some(at + forward_pos3(mask1, mask2, mask3)); + } + + at += VECTOR_SIZE; + let mask1 = _mm_movemask_epi8(eqb1); + let mask2 = _mm_movemask_epi8(eqb2); + let mask3 = _mm_movemask_epi8(eqb3); + return Some(at + forward_pos3(mask1, mask2, mask3)); + } + ptr = ptr.add(loop_size); + } + while ptr <= end_ptr.sub(VECTOR_SIZE) { + if let Some(i) = + forward_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3) + { + return Some(i); + } + ptr = ptr.add(VECTOR_SIZE); + } + if ptr < end_ptr { + debug_assert!(sub(end_ptr, ptr) < VECTOR_SIZE); + ptr = ptr.sub(VECTOR_SIZE - sub(end_ptr, ptr)); + debug_assert_eq!(sub(end_ptr, ptr), VECTOR_SIZE); + + return forward_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3); + } + None +} + +#[target_feature(enable = "sse2")] +pub unsafe fn memrchr(n1: u8, haystack: &[u8]) -> Option { + let vn1 = _mm_set1_epi8(n1 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = end_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr > start_ptr { + ptr = ptr.offset(-1); + if *ptr == n1 { + return Some(sub(ptr, start_ptr)); + } + } + return None; + } + + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = reverse_search1(start_ptr, end_ptr, ptr, vn1) { + return Some(i); + } + + ptr = (end_ptr as usize & !VECTOR_ALIGN) as *const u8; + debug_assert!(start_ptr <= ptr && ptr <= end_ptr); + while loop_size == LOOP_SIZE && ptr >= start_ptr.add(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + ptr = ptr.sub(loop_size); + let a = _mm_load_si128(ptr as *const __m128i); + let b = _mm_load_si128(ptr.add(VECTOR_SIZE) as *const __m128i); + let c = _mm_load_si128(ptr.add(2 * VECTOR_SIZE) as *const __m128i); + let d = _mm_load_si128(ptr.add(3 * VECTOR_SIZE) as *const __m128i); + let eqa = _mm_cmpeq_epi8(vn1, a); + let eqb = _mm_cmpeq_epi8(vn1, b); + let eqc = _mm_cmpeq_epi8(vn1, c); + let eqd = _mm_cmpeq_epi8(vn1, d); + let or1 = _mm_or_si128(eqa, eqb); + let or2 = _mm_or_si128(eqc, eqd); + let or3 = _mm_or_si128(or1, or2); + if _mm_movemask_epi8(or3) != 0 { + let mut at = sub(ptr.add(3 * VECTOR_SIZE), start_ptr); + let mask = _mm_movemask_epi8(eqd); + if mask != 0 { + return Some(at + reverse_pos(mask)); + } + + at -= VECTOR_SIZE; + let mask = _mm_movemask_epi8(eqc); + if mask != 0 { + return Some(at + reverse_pos(mask)); + } + + at -= VECTOR_SIZE; + let mask = _mm_movemask_epi8(eqb); + if mask != 0 { + return Some(at + reverse_pos(mask)); + } + + at -= VECTOR_SIZE; + let mask = _mm_movemask_epi8(eqa); + debug_assert!(mask != 0); + return Some(at + reverse_pos(mask)); + } + } + while ptr >= start_ptr.add(VECTOR_SIZE) { + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = reverse_search1(start_ptr, end_ptr, ptr, vn1) { + return Some(i); + } + } + if ptr > start_ptr { + debug_assert!(sub(ptr, start_ptr) < VECTOR_SIZE); + return reverse_search1(start_ptr, end_ptr, start_ptr, vn1); + } + None +} + +#[target_feature(enable = "sse2")] +pub unsafe fn memrchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option { + let vn1 = _mm_set1_epi8(n1 as i8); + let vn2 = _mm_set1_epi8(n2 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE2, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = end_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr > start_ptr { + ptr = ptr.offset(-1); + if *ptr == n1 || *ptr == n2 { + return Some(sub(ptr, start_ptr)); + } + } + return None; + } + + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = reverse_search2(start_ptr, end_ptr, ptr, vn1, vn2) { + return Some(i); + } + + ptr = (end_ptr as usize & !VECTOR_ALIGN) as *const u8; + debug_assert!(start_ptr <= ptr && ptr <= end_ptr); + while loop_size == LOOP_SIZE2 && ptr >= start_ptr.add(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + ptr = ptr.sub(loop_size); + let a = _mm_load_si128(ptr as *const __m128i); + let b = _mm_load_si128(ptr.add(VECTOR_SIZE) as *const __m128i); + let eqa1 = _mm_cmpeq_epi8(vn1, a); + let eqb1 = _mm_cmpeq_epi8(vn1, b); + let eqa2 = _mm_cmpeq_epi8(vn2, a); + let eqb2 = _mm_cmpeq_epi8(vn2, b); + let or1 = _mm_or_si128(eqa1, eqb1); + let or2 = _mm_or_si128(eqa2, eqb2); + let or3 = _mm_or_si128(or1, or2); + if _mm_movemask_epi8(or3) != 0 { + let mut at = sub(ptr.add(VECTOR_SIZE), start_ptr); + let mask1 = _mm_movemask_epi8(eqb1); + let mask2 = _mm_movemask_epi8(eqb2); + if mask1 != 0 || mask2 != 0 { + return Some(at + reverse_pos2(mask1, mask2)); + } + + at -= VECTOR_SIZE; + let mask1 = _mm_movemask_epi8(eqa1); + let mask2 = _mm_movemask_epi8(eqa2); + return Some(at + reverse_pos2(mask1, mask2)); + } + } + while ptr >= start_ptr.add(VECTOR_SIZE) { + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = reverse_search2(start_ptr, end_ptr, ptr, vn1, vn2) { + return Some(i); + } + } + if ptr > start_ptr { + debug_assert!(sub(ptr, start_ptr) < VECTOR_SIZE); + return reverse_search2(start_ptr, end_ptr, start_ptr, vn1, vn2); + } + None +} + +#[target_feature(enable = "sse2")] +pub unsafe fn memrchr3( + n1: u8, + n2: u8, + n3: u8, + haystack: &[u8], +) -> Option { + let vn1 = _mm_set1_epi8(n1 as i8); + let vn2 = _mm_set1_epi8(n2 as i8); + let vn3 = _mm_set1_epi8(n3 as i8); + let len = haystack.len(); + let loop_size = cmp::min(LOOP_SIZE2, len); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = end_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr > start_ptr { + ptr = ptr.offset(-1); + if *ptr == n1 || *ptr == n2 || *ptr == n3 { + return Some(sub(ptr, start_ptr)); + } + } + return None; + } + + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = reverse_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3) { + return Some(i); + } + + ptr = (end_ptr as usize & !VECTOR_ALIGN) as *const u8; + debug_assert!(start_ptr <= ptr && ptr <= end_ptr); + while loop_size == LOOP_SIZE2 && ptr >= start_ptr.add(loop_size) { + debug_assert_eq!(0, (ptr as usize) % VECTOR_SIZE); + + ptr = ptr.sub(loop_size); + let a = _mm_load_si128(ptr as *const __m128i); + let b = _mm_load_si128(ptr.add(VECTOR_SIZE) as *const __m128i); + let eqa1 = _mm_cmpeq_epi8(vn1, a); + let eqb1 = _mm_cmpeq_epi8(vn1, b); + let eqa2 = _mm_cmpeq_epi8(vn2, a); + let eqb2 = _mm_cmpeq_epi8(vn2, b); + let eqa3 = _mm_cmpeq_epi8(vn3, a); + let eqb3 = _mm_cmpeq_epi8(vn3, b); + let or1 = _mm_or_si128(eqa1, eqb1); + let or2 = _mm_or_si128(eqa2, eqb2); + let or3 = _mm_or_si128(eqa3, eqb3); + let or4 = _mm_or_si128(or1, or2); + let or5 = _mm_or_si128(or3, or4); + if _mm_movemask_epi8(or5) != 0 { + let mut at = sub(ptr.add(VECTOR_SIZE), start_ptr); + let mask1 = _mm_movemask_epi8(eqb1); + let mask2 = _mm_movemask_epi8(eqb2); + let mask3 = _mm_movemask_epi8(eqb3); + if mask1 != 0 || mask2 != 0 || mask3 != 0 { + return Some(at + reverse_pos3(mask1, mask2, mask3)); + } + + at -= VECTOR_SIZE; + let mask1 = _mm_movemask_epi8(eqa1); + let mask2 = _mm_movemask_epi8(eqa2); + let mask3 = _mm_movemask_epi8(eqa3); + return Some(at + reverse_pos3(mask1, mask2, mask3)); + } + } + while ptr >= start_ptr.add(VECTOR_SIZE) { + ptr = ptr.sub(VECTOR_SIZE); + if let Some(i) = + reverse_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3) + { + return Some(i); + } + } + if ptr > start_ptr { + debug_assert!(sub(ptr, start_ptr) < VECTOR_SIZE); + return reverse_search3(start_ptr, end_ptr, start_ptr, vn1, vn2, vn3); + } + None +} + +#[target_feature(enable = "sse2")] +pub unsafe fn forward_search1( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m128i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm_loadu_si128(ptr as *const __m128i); + let mask = _mm_movemask_epi8(_mm_cmpeq_epi8(chunk, vn1)); + if mask != 0 { + Some(sub(ptr, start_ptr) + forward_pos(mask)) + } else { + None + } +} + +#[target_feature(enable = "sse2")] +unsafe fn forward_search2( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m128i, + vn2: __m128i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm_loadu_si128(ptr as *const __m128i); + let eq1 = _mm_cmpeq_epi8(chunk, vn1); + let eq2 = _mm_cmpeq_epi8(chunk, vn2); + if _mm_movemask_epi8(_mm_or_si128(eq1, eq2)) != 0 { + let mask1 = _mm_movemask_epi8(eq1); + let mask2 = _mm_movemask_epi8(eq2); + Some(sub(ptr, start_ptr) + forward_pos2(mask1, mask2)) + } else { + None + } +} + +#[target_feature(enable = "sse2")] +pub unsafe fn forward_search3( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m128i, + vn2: __m128i, + vn3: __m128i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm_loadu_si128(ptr as *const __m128i); + let eq1 = _mm_cmpeq_epi8(chunk, vn1); + let eq2 = _mm_cmpeq_epi8(chunk, vn2); + let eq3 = _mm_cmpeq_epi8(chunk, vn3); + let or = _mm_or_si128(eq1, eq2); + if _mm_movemask_epi8(_mm_or_si128(or, eq3)) != 0 { + let mask1 = _mm_movemask_epi8(eq1); + let mask2 = _mm_movemask_epi8(eq2); + let mask3 = _mm_movemask_epi8(eq3); + Some(sub(ptr, start_ptr) + forward_pos3(mask1, mask2, mask3)) + } else { + None + } +} + +#[target_feature(enable = "sse2")] +unsafe fn reverse_search1( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m128i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm_loadu_si128(ptr as *const __m128i); + let mask = _mm_movemask_epi8(_mm_cmpeq_epi8(vn1, chunk)); + if mask != 0 { + Some(sub(ptr, start_ptr) + reverse_pos(mask)) + } else { + None + } +} + +#[target_feature(enable = "sse2")] +unsafe fn reverse_search2( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m128i, + vn2: __m128i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm_loadu_si128(ptr as *const __m128i); + let eq1 = _mm_cmpeq_epi8(chunk, vn1); + let eq2 = _mm_cmpeq_epi8(chunk, vn2); + if _mm_movemask_epi8(_mm_or_si128(eq1, eq2)) != 0 { + let mask1 = _mm_movemask_epi8(eq1); + let mask2 = _mm_movemask_epi8(eq2); + Some(sub(ptr, start_ptr) + reverse_pos2(mask1, mask2)) + } else { + None + } +} + +#[target_feature(enable = "sse2")] +unsafe fn reverse_search3( + start_ptr: *const u8, + end_ptr: *const u8, + ptr: *const u8, + vn1: __m128i, + vn2: __m128i, + vn3: __m128i, +) -> Option { + debug_assert!(sub(end_ptr, start_ptr) >= VECTOR_SIZE); + debug_assert!(start_ptr <= ptr); + debug_assert!(ptr <= end_ptr.sub(VECTOR_SIZE)); + + let chunk = _mm_loadu_si128(ptr as *const __m128i); + let eq1 = _mm_cmpeq_epi8(chunk, vn1); + let eq2 = _mm_cmpeq_epi8(chunk, vn2); + let eq3 = _mm_cmpeq_epi8(chunk, vn3); + let or = _mm_or_si128(eq1, eq2); + if _mm_movemask_epi8(_mm_or_si128(or, eq3)) != 0 { + let mask1 = _mm_movemask_epi8(eq1); + let mask2 = _mm_movemask_epi8(eq2); + let mask3 = _mm_movemask_epi8(eq3); + Some(sub(ptr, start_ptr) + reverse_pos3(mask1, mask2, mask3)) + } else { + None + } +} + +/// Compute the position of the first matching byte from the given mask. The +/// position returned is always in the range [0, 15]. +/// +/// The mask given is expected to be the result of _mm_movemask_epi8. +fn forward_pos(mask: i32) -> usize { + // We are dealing with little endian here, where the most significant byte + // is at a higher address. That means the least significant bit that is set + // corresponds to the position of our first matching byte. That position + // corresponds to the number of zeros after the least significant bit. + mask.trailing_zeros() as usize +} + +/// Compute the position of the first matching byte from the given masks. The +/// position returned is always in the range [0, 15]. Each mask corresponds to +/// the equality comparison of a single byte. +/// +/// The masks given are expected to be the result of _mm_movemask_epi8, where +/// at least one of the masks is non-zero (i.e., indicates a match). +fn forward_pos2(mask1: i32, mask2: i32) -> usize { + debug_assert!(mask1 != 0 || mask2 != 0); + + forward_pos(mask1 | mask2) +} + +/// Compute the position of the first matching byte from the given masks. The +/// position returned is always in the range [0, 15]. Each mask corresponds to +/// the equality comparison of a single byte. +/// +/// The masks given are expected to be the result of _mm_movemask_epi8, where +/// at least one of the masks is non-zero (i.e., indicates a match). +fn forward_pos3(mask1: i32, mask2: i32, mask3: i32) -> usize { + debug_assert!(mask1 != 0 || mask2 != 0 || mask3 != 0); + + forward_pos(mask1 | mask2 | mask3) +} + +/// Compute the position of the last matching byte from the given mask. The +/// position returned is always in the range [0, 15]. +/// +/// The mask given is expected to be the result of _mm_movemask_epi8. +fn reverse_pos(mask: i32) -> usize { + // We are dealing with little endian here, where the most significant byte + // is at a higher address. That means the most significant bit that is set + // corresponds to the position of our last matching byte. The position from + // the end of the mask is therefore the number of leading zeros in a 16 + // bit integer, and the position from the start of the mask is therefore + // 16 - (leading zeros) - 1. + VECTOR_SIZE - (mask as u16).leading_zeros() as usize - 1 +} + +/// Compute the position of the last matching byte from the given masks. The +/// position returned is always in the range [0, 15]. Each mask corresponds to +/// the equality comparison of a single byte. +/// +/// The masks given are expected to be the result of _mm_movemask_epi8, where +/// at least one of the masks is non-zero (i.e., indicates a match). +fn reverse_pos2(mask1: i32, mask2: i32) -> usize { + debug_assert!(mask1 != 0 || mask2 != 0); + + reverse_pos(mask1 | mask2) +} + +/// Compute the position of the last matching byte from the given masks. The +/// position returned is always in the range [0, 15]. Each mask corresponds to +/// the equality comparison of a single byte. +/// +/// The masks given are expected to be the result of _mm_movemask_epi8, where +/// at least one of the masks is non-zero (i.e., indicates a match). +fn reverse_pos3(mask1: i32, mask2: i32, mask3: i32) -> usize { + debug_assert!(mask1 != 0 || mask2 != 0 || mask3 != 0); + + reverse_pos(mask1 | mask2 | mask3) +} + +/// Subtract `b` from `a` and return the difference. `a` should be greater than +/// or equal to `b`. +fn sub(a: *const u8, b: *const u8) -> usize { + debug_assert!(a >= b); + (a as usize) - (b as usize) +} diff --git a/third_party/cargo/vendor/memchr-2.3.0/src/x86/sse42.rs b/third_party/cargo/vendor/memchr-2.3.0/src/x86/sse42.rs new file mode 100644 index 0000000..78a9b37 --- /dev/null +++ b/third_party/cargo/vendor/memchr-2.3.0/src/x86/sse42.rs @@ -0,0 +1,75 @@ +// This code is unused. PCMPESTRI is gratuitously slow. I imagine it might +// start winning with a hypothetical memchr4 (or greater). This technique might +// also be good for exposing searches over ranges of bytes, but that departs +// from the standard memchr API, so it's not clear whether we actually want +// that or not. +// +// N.B. PCMPISTRI appears to be about twice as fast as PCMPESTRI, which is kind +// of neat. Unfortunately, UTF-8 strings can contain NUL bytes, which means +// I don't see a way of effectively using PCMPISTRI unless there's some fast +// way to replace zero bytes with a byte that is not not a needle byte. + +use core::arch::x86_64::*; +use core::mem::size_of; + +use x86::sse2; + +const VECTOR_SIZE: usize = size_of::<__m128i>(); +const CONTROL_ANY: i32 = + _SIDD_UBYTE_OPS + | _SIDD_CMP_EQUAL_ANY + | _SIDD_POSITIVE_POLARITY + | _SIDD_LEAST_SIGNIFICANT; + +#[target_feature(enable = "sse4.2")] +pub unsafe fn memchr3( + n1: u8, n2: u8, n3: u8, + haystack: &[u8] +) -> Option { + let vn1 = _mm_set1_epi8(n1 as i8); + let vn2 = _mm_set1_epi8(n2 as i8); + let vn3 = _mm_set1_epi8(n3 as i8); + let vn = _mm_setr_epi8( + n1 as i8, n2 as i8, n3 as i8, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + ); + let len = haystack.len(); + let start_ptr = haystack.as_ptr(); + let end_ptr = haystack[haystack.len()..].as_ptr(); + let mut ptr = start_ptr; + + if haystack.len() < VECTOR_SIZE { + while ptr < end_ptr { + if *ptr == n1 || *ptr == n2 || *ptr == n3 { + return Some(sub(ptr, start_ptr)); + } + ptr = ptr.offset(1); + } + return None; + } + while ptr <= end_ptr.sub(VECTOR_SIZE) { + let chunk = _mm_loadu_si128(ptr as *const __m128i); + let res = _mm_cmpestri(vn, 3, chunk, 16, CONTROL_ANY); + if res < 16 { + return Some(sub(ptr, start_ptr) + res as usize); + } + ptr = ptr.add(VECTOR_SIZE); + } + if ptr < end_ptr { + debug_assert!(sub(end_ptr, ptr) < VECTOR_SIZE); + ptr = ptr.sub(VECTOR_SIZE - sub(end_ptr, ptr)); + debug_assert_eq!(sub(end_ptr, ptr), VECTOR_SIZE); + + return sse2::forward_search3(start_ptr, end_ptr, ptr, vn1, vn2, vn3); + } + None +} + +/// Subtract `b` from `a` and return the difference. `a` should be greater than +/// or equal to `b`. +fn sub(a: *const u8, b: *const u8) -> usize { + debug_assert!(a >= b); + (a as usize) - (b as usize) +} diff --git a/third_party/cargo/vendor/memmap-0.7.0/.cargo-checksum.json b/third_party/cargo/vendor/memmap-0.7.0/.cargo-checksum.json new file mode 100644 index 0000000..6fda693 --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"4f6e813f7480758c57f9d180ade1276761a499245846fadb7a96a234342506ca","LICENSE-APACHE":"04ea4849dba9dcae07113850c6f1b1a69052c625210639914eee352023f750ad","LICENSE-MIT":"bd1d8f06a6ce1f7645991e347b95864b970eed43624305eb4bb78c09aef8692d","README.md":"193c46fdc56e4ca953ec7179bf4fd5f302b46557d86181b56b7d6294f25eaa96","ci/install.sh":"8841985e8645d391829ba52cd669bc5c5d98b1fdd8979c7cfd3cd3573c4a0a4b","ci/script.sh":"04127e49ac7346941f0a21d2e1a9177719e62f1e92755579c3601fc98e33006c","examples/cat.rs":"86cfee28482f92ea4c4ae4ebdff97d70fc095208cc5de09db39994118468d1ff","src/lib.rs":"82e116f2b1fbfc7e987a0dfde7e73e51b231f38f33b76369c6de0d46b63c60e1","src/unix.rs":"93fb4fe71dd04e2d1c5e1b6a285bce8b729456bdddbd758aa6768e8ab30ed143","src/windows.rs":"21566160bc1b2f2f82988b9e1274b3b700034cad0e5ca723695863a432da4896"},"package":"6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"} \ No newline at end of file diff --git a/third_party/cargo/vendor/memmap-0.7.0/BUILD b/third_party/cargo/vendor/memmap-0.7.0/BUILD new file mode 100644 index 0000000..0b97c3c --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "cat" with type "example" omitted + +rust_library( + name = "memmap", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.7.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/memmap-0.7.0/Cargo.toml b/third_party/cargo/vendor/memmap-0.7.0/Cargo.toml new file mode 100644 index 0000000..fef331e --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/Cargo.toml @@ -0,0 +1,33 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "memmap" +version = "0.7.0" +authors = ["Dan Burkert "] +description = "Cross-platform Rust API for memory-mapped file IO" +documentation = "https://docs.rs/memmap" +keywords = ["mmap", "memory-map", "io", "file"] +license = "MIT/Apache-2.0" +repository = "https://github.com/danburkert/memmap-rs" +[dev-dependencies.tempdir] +version = "0.3" +[target."cfg(unix)".dependencies.libc] +version = "0.2" +[target."cfg(windows)".dependencies.winapi] +version = "0.3" +features = ["basetsd", "handleapi", "memoryapi", "minwindef", "std", "sysinfoapi"] +[badges.appveyor] +repository = "danburkert/mmap" + +[badges.travis-ci] +repository = "danburkert/memmap-rs" diff --git a/third_party/cargo/vendor/memmap-0.7.0/LICENSE-APACHE b/third_party/cargo/vendor/memmap-0.7.0/LICENSE-APACHE new file mode 100644 index 0000000..7be3d81 --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [2015] [Dan Burkert] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/memmap-0.7.0/LICENSE-MIT b/third_party/cargo/vendor/memmap-0.7.0/LICENSE-MIT new file mode 100644 index 0000000..ebb42e1 --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2015 Dan Burkert + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/memmap-0.7.0/README.md b/third_party/cargo/vendor/memmap-0.7.0/README.md new file mode 100644 index 0000000..c230b32 --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/README.md @@ -0,0 +1,53 @@ +# memmap + +A Rust library for cross-platform memory mapped IO. + +[![Build Status](https://travis-ci.org/danburkert/memmap-rs.svg?branch=master)](https://travis-ci.org/danburkert/memmap-rs) +[![Windows Build Status](https://ci.appveyor.com/api/projects/status/ubka00959pstatkg/branch/master?svg=true)](https://ci.appveyor.com/project/danburkert/mmap) +[![Documentation](https://docs.rs/memmap/badge.svg)](https://docs.rs/memmap) +[![Crate](https://img.shields.io/crates/v/memmap.svg)](https://crates.io/crates/memmap) + +## Features + +- [x] file-backed memory maps +- [x] anonymous memory maps +- [x] synchronous and asynchronous flushing +- [x] copy-on-write memory maps +- [x] read-only memory maps +- [x] stack support (`MAP_STACK` on unix) +- [x] executable memory maps +- [ ] huge page support + +## Platforms + +`memmap` should work on any platform supported by +[`libc`](https://github.com/rust-lang-nursery/libc#platforms-and-documentation). +`memmap` requires Rust stable 1.13 or greater. + +`memmap` is continuously tested on: + * `x86_64-unknown-linux-gnu` (Linux) + * `i686-unknown-linux-gnu` + * `x86_64-unknown-linux-musl` (Linux MUSL) + * `x86_64-apple-darwin` (OSX) + * `i686-apple-darwin` + * `x86_64-pc-windows-msvc` (Windows) + * `i686-pc-windows-msvc` + * `x86_64-pc-windows-gnu` + * `i686-pc-windows-gnu` + +`memmap` is continuously cross-compiled against: + * `arm-linux-androideabi` (Android) + * `aarch64-unknown-linux-gnu` (ARM) + * `arm-unknown-linux-gnueabihf` + * `mips-unknown-linux-gnu` (MIPS) + * `x86_64-apple-ios` (iOS) + * `i686-apple-ios` + +## License + +`memmap` is primarily distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT) for details. + +Copyright (c) 2015 Dan Burkert. diff --git a/third_party/cargo/vendor/memmap-0.7.0/ci/install.sh b/third_party/cargo/vendor/memmap-0.7.0/ci/install.sh new file mode 100644 index 0000000..80e18e4 --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/ci/install.sh @@ -0,0 +1,47 @@ +set -ex + +main() { + local target= + if [ $TRAVIS_OS_NAME = linux ]; then + target=x86_64-unknown-linux-musl + sort=sort + else + target=x86_64-apple-darwin + sort=gsort # for `sort --sort-version`, from brew's coreutils. + fi + + # Builds for iOS are done on OSX, but require the specific target to be + # installed. + case $TARGET in + aarch64-apple-ios) + rustup target install aarch64-apple-ios + ;; + armv7-apple-ios) + rustup target install armv7-apple-ios + ;; + armv7s-apple-ios) + rustup target install armv7s-apple-ios + ;; + i386-apple-ios) + rustup target install i386-apple-ios + ;; + x86_64-apple-ios) + rustup target install x86_64-apple-ios + ;; + esac + + # This fetches latest stable release + local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \ + | cut -d/ -f3 \ + | grep -E '^v[0.1.0-9.]+$' \ + | $sort --version-sort \ + | tail -n1) + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- \ + --force \ + --git japaric/cross \ + --tag $tag \ + --target $target +} + +main diff --git a/third_party/cargo/vendor/memmap-0.7.0/ci/script.sh b/third_party/cargo/vendor/memmap-0.7.0/ci/script.sh new file mode 100644 index 0000000..3ccf556 --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/ci/script.sh @@ -0,0 +1,20 @@ +# This script takes care of testing your crate + +set -ex + +main() { + cross build --target $TARGET + cross build --target $TARGET --release + + if [ ! -z $DISABLE_TESTS ]; then + return + fi + + cross test --target $TARGET + cross test --target $TARGET --release +} + +# we don't run the "test phase" when doing deploys +if [ -z $TRAVIS_TAG ]; then + main +fi diff --git a/third_party/cargo/vendor/memmap-0.7.0/examples/cat.rs b/third_party/cargo/vendor/memmap-0.7.0/examples/cat.rs new file mode 100644 index 0000000..4745972 --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/examples/cat.rs @@ -0,0 +1,23 @@ +extern crate memmap; + +use std::env; +use std::fs::File; +use std::io::{self, Write}; + +use memmap::Mmap; + +/// Output a file's contents to stdout. The file path must be provided as the first process +/// argument. +fn main() { + let path = env::args() + .nth(1) + .expect("supply a single path as the program argument"); + + let file = File::open(path).expect("failed to open the file"); + + let mmap = unsafe { Mmap::map(&file).expect("failed to map the file") }; + + io::stdout() + .write_all(&mmap[..]) + .expect("failed to output the file contents"); +} diff --git a/third_party/cargo/vendor/memmap-0.7.0/src/lib.rs b/third_party/cargo/vendor/memmap-0.7.0/src/lib.rs new file mode 100644 index 0000000..5010c00 --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/src/lib.rs @@ -0,0 +1,1008 @@ +//! A cross-platform Rust API for memory mapped buffers. + +#![doc(html_root_url = "https://docs.rs/memmap/0.7.0")] + +#[cfg(windows)] +extern crate winapi; +#[cfg(windows)] +mod windows; +#[cfg(windows)] +use windows::MmapInner; + +#[cfg(unix)] +mod unix; +#[cfg(unix)] +use unix::MmapInner; + +use std::fmt; +use std::fs::File; +use std::io::{Error, ErrorKind, Result}; +use std::ops::{Deref, DerefMut}; +use std::slice; +use std::usize; + +/// A memory map builder, providing advanced options and flags for specifying memory map behavior. +/// +/// `MmapOptions` can be used to create an anonymous memory map using `MmapOptions::map_anon`, or a +/// file-backed memory map using one of `MmapOptions::map`, `MmapOptions::map_mut`, +/// `MmapOptions::map_exec`, or `MmapOptions::map_copy`. +#[derive(Clone, Debug, Default)] +pub struct MmapOptions { + offset: u64, + len: Option, + stack: bool, +} + +impl MmapOptions { + /// Creates a new set of options for configuring and creating a memory map. + /// + /// # Example + /// + /// ``` + /// use memmap::{MmapMut, MmapOptions}; + /// # use std::io::Result; + /// + /// # fn main() -> Result<()> { + /// // Create a new memory map builder. + /// let mut mmap_options = MmapOptions::new(); + /// + /// // Configure the memory map builder using option setters, then create + /// // a memory map using one of `mmap_options.map_anon`, `mmap_options.map`, + /// // `mmap_options.map_mut`, `mmap_options.map_exec`, or `mmap_options.map_copy`: + /// let mut mmap: MmapMut = mmap_options.len(36).map_anon()?; + /// + /// // Use the memory map: + /// mmap.copy_from_slice(b"...data to copy to the memory map..."); + /// # let _ = mmap_options; + /// # Ok(()) + /// # } + /// ``` + pub fn new() -> MmapOptions { + MmapOptions::default() + } + + /// Configures the memory map to start at byte `offset` from the beginning of the file. + /// + /// This option has no effect on anonymous memory maps. + /// + /// By default, the offset is 0. + /// + /// # Example + /// + /// ``` + /// use memmap::MmapOptions; + /// use std::fs::File; + /// + /// # fn main() -> std::io::Result<()> { + /// let mmap = unsafe { + /// MmapOptions::new() + /// .offset(10) + /// .map(&File::open("README.md")?)? + /// }; + /// assert_eq!(&b"A Rust library for cross-platform memory mapped IO."[..], + /// &mmap[..51]); + /// # Ok(()) + /// # } + /// ``` + pub fn offset(&mut self, offset: u64) -> &mut Self { + self.offset = offset; + self + } + + /// Configures the created memory mapped buffer to be `len` bytes long. + /// + /// This option is mandatory for anonymous memory maps. + /// + /// For file-backed memory maps, the length will default to the file length. + /// + /// # Example + /// + /// ``` + /// use memmap::MmapOptions; + /// use std::fs::File; + /// + /// # fn main() -> std::io::Result<()> { + /// let mmap = unsafe { + /// MmapOptions::new() + /// .len(8) + /// .map(&File::open("README.md")?)? + /// }; + /// assert_eq!(&b"# memmap"[..], &mmap[..]); + /// # Ok(()) + /// # } + /// ``` + pub fn len(&mut self, len: usize) -> &mut Self { + self.len = Some(len); + self + } + + /// Returns the configured length, or the length of the provided file. + fn get_len(&self, file: &File) -> Result { + self.len.map(Ok).unwrap_or_else(|| { + let len = file.metadata()?.len() - self.offset; + if len > (usize::MAX as u64) { + return Err(Error::new( + ErrorKind::InvalidData, + "memory map length overflows usize", + )); + } + Ok(len as usize) + }) + } + + /// Configures the anonymous memory map to be suitable for a process or thread stack. + /// + /// This option corresponds to the `MAP_STACK` flag on Linux. + /// + /// This option has no effect on file-backed memory maps. + /// + /// # Example + /// + /// ``` + /// use memmap::MmapOptions; + /// + /// # fn main() -> std::io::Result<()> { + /// let stack = MmapOptions::new().stack().len(4096).map_anon(); + /// # Ok(()) + /// # } + /// ``` + pub fn stack(&mut self) -> &mut Self { + self.stack = true; + self + } + + /// Creates a read-only memory map backed by a file. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails, which can happen for a + /// variety of reasons, such as when the file is not open with read permissions. + /// + /// # Example + /// + /// ``` + /// use memmap::MmapOptions; + /// use std::fs::File; + /// use std::io::Read; + /// + /// # fn main() -> std::io::Result<()> { + /// let mut file = File::open("README.md")?; + /// + /// let mut contents = Vec::new(); + /// file.read_to_end(&mut contents)?; + /// + /// let mmap = unsafe { + /// MmapOptions::new().map(&file)? + /// }; + /// + /// assert_eq!(&contents[..], &mmap[..]); + /// # Ok(()) + /// # } + /// ``` + pub unsafe fn map(&self, file: &File) -> Result { + MmapInner::map(self.get_len(file)?, file, self.offset).map(|inner| Mmap { inner: inner }) + } + + /// Creates a readable and executable memory map backed by a file. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails, which can happen for a + /// variety of reasons, such as when the file is not open with read permissions. + pub unsafe fn map_exec(&self, file: &File) -> Result { + MmapInner::map_exec(self.get_len(file)?, file, self.offset) + .map(|inner| Mmap { inner: inner }) + } + + /// Creates a writeable memory map backed by a file. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails, which can happen for a + /// variety of reasons, such as when the file is not open with read and write permissions. + /// + /// # Example + /// + /// ``` + /// # extern crate memmap; + /// # extern crate tempdir; + /// # + /// use std::fs::OpenOptions; + /// use std::path::PathBuf; + /// + /// use memmap::MmapOptions; + /// # + /// # fn main() -> std::io::Result<()> { + /// # let tempdir = tempdir::TempDir::new("mmap")?; + /// let path: PathBuf = /* path to file */ + /// # tempdir.path().join("map_mut"); + /// let file = OpenOptions::new().read(true).write(true).create(true).open(&path)?; + /// file.set_len(13)?; + /// + /// let mut mmap = unsafe { + /// MmapOptions::new().map_mut(&file)? + /// }; + /// + /// mmap.copy_from_slice(b"Hello, world!"); + /// # Ok(()) + /// # } + /// ``` + pub unsafe fn map_mut(&self, file: &File) -> Result { + MmapInner::map_mut(self.get_len(file)?, file, self.offset) + .map(|inner| MmapMut { inner: inner }) + } + + /// Creates a copy-on-write memory map backed by a file. + /// + /// Data written to the memory map will not be visible by other processes, + /// and will not be carried through to the underlying file. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails, which can happen for a + /// variety of reasons, such as when the file is not open with writable permissions. + /// + /// # Example + /// + /// ``` + /// use memmap::MmapOptions; + /// use std::fs::File; + /// use std::io::Write; + /// + /// # fn main() -> std::io::Result<()> { + /// let file = File::open("README.md")?; + /// let mut mmap = unsafe { MmapOptions::new().map_copy(&file)? }; + /// (&mut mmap[..]).write_all(b"Hello, world!")?; + /// # Ok(()) + /// # } + /// ``` + pub unsafe fn map_copy(&self, file: &File) -> Result { + MmapInner::map_copy(self.get_len(file)?, file, self.offset) + .map(|inner| MmapMut { inner: inner }) + } + + /// Creates an anonymous memory map. + /// + /// Note: the memory map length must be configured to be greater than 0 before creating an + /// anonymous memory map using `MmapOptions::len()`. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails. + pub fn map_anon(&self) -> Result { + MmapInner::map_anon(self.len.unwrap_or(0), self.stack).map(|inner| MmapMut { inner: inner }) + } +} + +/// An immutable memory mapped buffer. +/// +/// A `Mmap` may be backed by a file, or it can be anonymous map, backed by volatile memory. +/// +/// Use `MmapOptions` to configure and create a file-backed memory map. To create an immutable +/// anonymous memory map, first create a mutable anonymous memory map using `MmapOptions`, and then +/// make it immutable with `MmapMut::make_read_only`. +/// +/// # Example +/// +/// ``` +/// use memmap::MmapOptions; +/// use std::io::Write; +/// use std::fs::File; +/// +/// # fn main() -> std::io::Result<()> { +/// let file = File::open("README.md")?; +/// let mmap = unsafe { MmapOptions::new().map(&file)? }; +/// assert_eq!(b"# memmap", &mmap[0..8]); +/// # Ok(()) +/// # } +/// ``` +/// +/// See `MmapMut` for the mutable version. +pub struct Mmap { + inner: MmapInner, +} + +impl Mmap { + /// Creates a read-only memory map backed by a file. + /// + /// This is equivalent to calling `MmapOptions::new().map(file)`. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails, which can happen for a + /// variety of reasons, such as when the file is not open with read permissions. + /// + /// # Example + /// + /// ``` + /// use std::fs::File; + /// use std::io::Read; + /// + /// use memmap::Mmap; + /// + /// # fn main() -> std::io::Result<()> { + /// let mut file = File::open("README.md")?; + /// + /// let mut contents = Vec::new(); + /// file.read_to_end(&mut contents)?; + /// + /// let mmap = unsafe { Mmap::map(&file)? }; + /// + /// assert_eq!(&contents[..], &mmap[..]); + /// # Ok(()) + /// # } + /// ``` + pub unsafe fn map(file: &File) -> Result { + MmapOptions::new().map(file) + } + + /// Transition the memory map to be writable. + /// + /// If the memory map is file-backed, the file must have been opened with write permissions. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails, which can happen for a + /// variety of reasons, such as when the file is not open with writable permissions. + /// + /// # Example + /// + /// ``` + /// # extern crate memmap; + /// # extern crate tempdir; + /// # + /// use memmap::Mmap; + /// use std::ops::DerefMut; + /// use std::io::Write; + /// # use std::fs::OpenOptions; + /// + /// # fn main() -> std::io::Result<()> { + /// # let tempdir = tempdir::TempDir::new("mmap")?; + /// let file = /* file opened with write permissions */ + /// # OpenOptions::new() + /// # .read(true) + /// # .write(true) + /// # .create(true) + /// # .open(tempdir.path() + /// # .join("make_mut"))?; + /// # file.set_len(128)?; + /// let mmap = unsafe { Mmap::map(&file)? }; + /// // ... use the read-only memory map ... + /// let mut mut_mmap = mmap.make_mut()?; + /// mut_mmap.deref_mut().write_all(b"hello, world!")?; + /// # Ok(()) + /// # } + /// ``` + pub fn make_mut(mut self) -> Result { + self.inner.make_mut()?; + Ok(MmapMut { inner: self.inner }) + } +} + +impl Deref for Mmap { + type Target = [u8]; + + #[inline] + fn deref(&self) -> &[u8] { + unsafe { slice::from_raw_parts(self.inner.ptr(), self.inner.len()) } + } +} + +impl AsRef<[u8]> for Mmap { + #[inline] + fn as_ref(&self) -> &[u8] { + self.deref() + } +} + +impl fmt::Debug for Mmap { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("Mmap") + .field("ptr", &self.as_ptr()) + .field("len", &self.len()) + .finish() + } +} + +/// A mutable memory mapped buffer. +/// +/// A file-backed `MmapMut` buffer may be used to read from or write to a file. An anonymous +/// `MmapMut` buffer may be used any place that an in-memory byte buffer is needed. Use +/// `MmapOptions` for creating memory maps. +/// +/// See `Mmap` for the immutable version. +pub struct MmapMut { + inner: MmapInner, +} + +impl MmapMut { + /// Creates a writeable memory map backed by a file. + /// + /// This is equivalent to calling `MmapOptions::new().map_mut(file)`. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails, which can happen for a + /// variety of reasons, such as when the file is not open with read and write permissions. + /// + /// # Example + /// + /// ``` + /// # extern crate memmap; + /// # extern crate tempdir; + /// # + /// use std::fs::OpenOptions; + /// use std::path::PathBuf; + /// + /// use memmap::MmapMut; + /// # + /// # fn main() -> std::io::Result<()> { + /// # let tempdir = tempdir::TempDir::new("mmap")?; + /// let path: PathBuf = /* path to file */ + /// # tempdir.path().join("map_mut"); + /// let file = OpenOptions::new() + /// .read(true) + /// .write(true) + /// .create(true) + /// .open(&path)?; + /// file.set_len(13)?; + /// + /// let mut mmap = unsafe { MmapMut::map_mut(&file)? }; + /// + /// mmap.copy_from_slice(b"Hello, world!"); + /// # Ok(()) + /// # } + /// ``` + pub unsafe fn map_mut(file: &File) -> Result { + MmapOptions::new().map_mut(file) + } + + /// Creates an anonymous memory map. + /// + /// This is equivalent to calling `MmapOptions::new().len(length).map_anon()`. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails. + pub fn map_anon(length: usize) -> Result { + MmapOptions::new().len(length).map_anon() + } + + /// Flushes outstanding memory map modifications to disk. + /// + /// When this method returns with a non-error result, all outstanding changes to a file-backed + /// memory map are guaranteed to be durably stored. The file's metadata (including last + /// modification timestamp) may not be updated. + /// + /// # Example + /// + /// ``` + /// # extern crate memmap; + /// # extern crate tempdir; + /// # + /// use std::fs::OpenOptions; + /// use std::io::Write; + /// use std::path::PathBuf; + /// + /// use memmap::MmapMut; + /// + /// # fn main() -> std::io::Result<()> { + /// # let tempdir = tempdir::TempDir::new("mmap")?; + /// let path: PathBuf = /* path to file */ + /// # tempdir.path().join("flush"); + /// let file = OpenOptions::new().read(true).write(true).create(true).open(&path)?; + /// file.set_len(128)?; + /// + /// let mut mmap = unsafe { MmapMut::map_mut(&file)? }; + /// + /// (&mut mmap[..]).write_all(b"Hello, world!")?; + /// mmap.flush()?; + /// # Ok(()) + /// # } + /// ``` + pub fn flush(&self) -> Result<()> { + let len = self.len(); + self.inner.flush(0, len) + } + + /// Asynchronously flushes outstanding memory map modifications to disk. + /// + /// This method initiates flushing modified pages to durable storage, but it will not wait for + /// the operation to complete before returning. The file's metadata (including last + /// modification timestamp) may not be updated. + pub fn flush_async(&self) -> Result<()> { + let len = self.len(); + self.inner.flush_async(0, len) + } + + /// Flushes outstanding memory map modifications in the range to disk. + /// + /// The offset and length must be in the bounds of the memory map. + /// + /// When this method returns with a non-error result, all outstanding changes to a file-backed + /// memory in the range are guaranteed to be durable stored. The file's metadata (including + /// last modification timestamp) may not be updated. It is not guaranteed the only the changes + /// in the specified range are flushed; other outstanding changes to the memory map may be + /// flushed as well. + pub fn flush_range(&self, offset: usize, len: usize) -> Result<()> { + self.inner.flush(offset, len) + } + + /// Asynchronously flushes outstanding memory map modifications in the range to disk. + /// + /// The offset and length must be in the bounds of the memory map. + /// + /// This method initiates flushing modified pages to durable storage, but it will not wait for + /// the operation to complete before returning. The file's metadata (including last + /// modification timestamp) may not be updated. It is not guaranteed that the only changes + /// flushed are those in the specified range; other outstanding changes to the memory map may + /// be flushed as well. + pub fn flush_async_range(&self, offset: usize, len: usize) -> Result<()> { + self.inner.flush_async(offset, len) + } + + /// Returns an immutable version of this memory mapped buffer. + /// + /// If the memory map is file-backed, the file must have been opened with read permissions. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails, which can happen for a + /// variety of reasons, such as when the file has not been opened with read permissions. + /// + /// # Example + /// + /// ``` + /// # extern crate memmap; + /// # + /// use std::io::Write; + /// use std::path::PathBuf; + /// + /// use memmap::{Mmap, MmapMut}; + /// + /// # fn main() -> std::io::Result<()> { + /// let mut mmap = MmapMut::map_anon(128)?; + /// + /// (&mut mmap[..]).write(b"Hello, world!")?; + /// + /// let mmap: Mmap = mmap.make_read_only()?; + /// # Ok(()) + /// # } + /// ``` + pub fn make_read_only(mut self) -> Result { + self.inner.make_read_only()?; + Ok(Mmap { inner: self.inner }) + } + + /// Transition the memory map to be readable and executable. + /// + /// If the memory map is file-backed, the file must have been opened with execute permissions. + /// + /// # Errors + /// + /// This method returns an error when the underlying system call fails, which can happen for a + /// variety of reasons, such as when the file has not been opened with execute permissions. + pub fn make_exec(mut self) -> Result { + self.inner.make_exec()?; + Ok(Mmap { inner: self.inner }) + } +} + +impl Deref for MmapMut { + type Target = [u8]; + + #[inline] + fn deref(&self) -> &[u8] { + unsafe { slice::from_raw_parts(self.inner.ptr(), self.inner.len()) } + } +} + +impl DerefMut for MmapMut { + #[inline] + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { slice::from_raw_parts_mut(self.inner.mut_ptr(), self.inner.len()) } + } +} + +impl AsRef<[u8]> for MmapMut { + #[inline] + fn as_ref(&self) -> &[u8] { + self.deref() + } +} + +impl AsMut<[u8]> for MmapMut { + #[inline] + fn as_mut(&mut self) -> &mut [u8] { + self.deref_mut() + } +} + +impl fmt::Debug for MmapMut { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("MmapMut") + .field("ptr", &self.as_ptr()) + .field("len", &self.len()) + .finish() + } +} + +#[cfg(test)] +mod test { + + extern crate tempdir; + #[cfg(windows)] + extern crate winapi; + + use std::fs::OpenOptions; + use std::io::{Read, Write}; + #[cfg(windows)] + use std::os::windows::fs::OpenOptionsExt; + use std::sync::Arc; + use std::thread; + + #[cfg(windows)] + use winapi::um::winnt::GENERIC_ALL; + + use super::{Mmap, MmapMut, MmapOptions}; + + #[test] + fn map_file() { + let expected_len = 128; + let tempdir = tempdir::TempDir::new("mmap").unwrap(); + let path = tempdir.path().join("mmap"); + + let file = OpenOptions::new() + .read(true) + .write(true) + .create(true) + .open(&path) + .unwrap(); + + file.set_len(expected_len as u64).unwrap(); + + let mut mmap = unsafe { MmapMut::map_mut(&file).unwrap() }; + let len = mmap.len(); + assert_eq!(expected_len, len); + + let zeros = vec![0; len]; + let incr: Vec = (0..len as u8).collect(); + + // check that the mmap is empty + assert_eq!(&zeros[..], &mmap[..]); + + // write values into the mmap + (&mut mmap[..]).write_all(&incr[..]).unwrap(); + + // read values back + assert_eq!(&incr[..], &mmap[..]); + } + + /// Checks that a 0-length file will not be mapped. + #[test] + fn map_empty_file() { + let tempdir = tempdir::TempDir::new("mmap").unwrap(); + let path = tempdir.path().join("mmap"); + + let file = OpenOptions::new() + .read(true) + .write(true) + .create(true) + .open(&path) + .unwrap(); + let mmap = unsafe { Mmap::map(&file) }; + assert!(mmap.is_err()); + } + + #[test] + fn map_anon() { + let expected_len = 128; + let mut mmap = MmapMut::map_anon(expected_len).unwrap(); + let len = mmap.len(); + assert_eq!(expected_len, len); + + let zeros = vec![0; len]; + let incr: Vec = (0..len as u8).collect(); + + // check that the mmap is empty + assert_eq!(&zeros[..], &mmap[..]); + + // write values into the mmap + (&mut mmap[..]).write_all(&incr[..]).unwrap(); + + // read values back + assert_eq!(&incr[..], &mmap[..]); + } + + #[test] + fn map_anon_zero_len() { + assert!(MmapOptions::new().map_anon().is_err()) + } + + #[test] + fn file_write() { + let tempdir = tempdir::TempDir::new("mmap").unwrap(); + let path = tempdir.path().join("mmap"); + + let mut file = OpenOptions::new() + .read(true) + .write(true) + .create(true) + .open(&path) + .unwrap(); + file.set_len(128).unwrap(); + + let write = b"abc123"; + let mut read = [0u8; 6]; + + let mut mmap = unsafe { MmapMut::map_mut(&file).unwrap() }; + (&mut mmap[..]).write_all(write).unwrap(); + mmap.flush().unwrap(); + + file.read(&mut read).unwrap(); + assert_eq!(write, &read); + } + + #[test] + fn flush_range() { + let tempdir = tempdir::TempDir::new("mmap").unwrap(); + let path = tempdir.path().join("mmap"); + + let file = OpenOptions::new() + .read(true) + .write(true) + .create(true) + .open(&path) + .unwrap(); + file.set_len(128).unwrap(); + let write = b"abc123"; + + let mut mmap = unsafe { + MmapOptions::new() + .offset(2) + .len(write.len()) + .map_mut(&file) + .unwrap() + }; + (&mut mmap[..]).write_all(write).unwrap(); + mmap.flush_range(0, write.len()).unwrap(); + } + + #[test] + fn map_copy() { + let tempdir = tempdir::TempDir::new("mmap").unwrap(); + let path = tempdir.path().join("mmap"); + + let mut file = OpenOptions::new() + .read(true) + .write(true) + .create(true) + .open(&path) + .unwrap(); + file.set_len(128).unwrap(); + + let nulls = b"\0\0\0\0\0\0"; + let write = b"abc123"; + let mut read = [0u8; 6]; + + let mut mmap = unsafe { MmapOptions::new().map_copy(&file).unwrap() }; + + (&mut mmap[..]).write(write).unwrap(); + mmap.flush().unwrap(); + + // The mmap contains the write + (&mmap[..]).read(&mut read).unwrap(); + assert_eq!(write, &read); + + // The file does not contain the write + file.read(&mut read).unwrap(); + assert_eq!(nulls, &read); + + // another mmap does not contain the write + let mmap2 = unsafe { MmapOptions::new().map(&file).unwrap() }; + (&mmap2[..]).read(&mut read).unwrap(); + assert_eq!(nulls, &read); + } + + #[test] + fn map_offset() { + let tempdir = tempdir::TempDir::new("mmap").unwrap(); + let path = tempdir.path().join("mmap"); + + let file = OpenOptions::new() + .read(true) + .write(true) + .create(true) + .open(&path) + .unwrap(); + + let offset = u32::max_value() as u64 + 2; + let len = 5432; + file.set_len(offset + len as u64).unwrap(); + + // Check inferred length mmap. + let mmap = unsafe { MmapOptions::new().offset(offset).map_mut(&file).unwrap() }; + assert_eq!(len, mmap.len()); + + // Check explicit length mmap. + let mut mmap = unsafe { + MmapOptions::new() + .offset(offset) + .len(len) + .map_mut(&file) + .unwrap() + }; + assert_eq!(len, mmap.len()); + + let zeros = vec![0; len]; + let incr: Vec<_> = (0..len).map(|i| i as u8).collect(); + + // check that the mmap is empty + assert_eq!(&zeros[..], &mmap[..]); + + // write values into the mmap + (&mut mmap[..]).write_all(&incr[..]).unwrap(); + + // read values back + assert_eq!(&incr[..], &mmap[..]); + } + + #[test] + fn index() { + let mut mmap = MmapMut::map_anon(128).unwrap(); + mmap[0] = 42; + assert_eq!(42, mmap[0]); + } + + #[test] + fn sync_send() { + let mmap = Arc::new(MmapMut::map_anon(129).unwrap()); + thread::spawn(move || { + &mmap[..]; + }); + } + + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + fn jit_x86(mut mmap: MmapMut) { + use std::mem; + mmap[0] = 0xB8; // mov eax, 0xAB + mmap[1] = 0xAB; + mmap[2] = 0x00; + mmap[3] = 0x00; + mmap[4] = 0x00; + mmap[5] = 0xC3; // ret + + let mmap = mmap.make_exec().expect("make_exec"); + + let jitfn: extern "C" fn() -> u8 = unsafe { mem::transmute(mmap.as_ptr()) }; + assert_eq!(jitfn(), 0xab); + } + + #[test] + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + fn jit_x86_anon() { + jit_x86(MmapMut::map_anon(4096).unwrap()); + } + + #[test] + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + fn jit_x86_file() { + let tempdir = tempdir::TempDir::new("mmap").unwrap(); + let mut options = OpenOptions::new(); + #[cfg(windows)] + options.access_mode(GENERIC_ALL); + + let file = options + .read(true) + .write(true) + .create(true) + .open(&tempdir.path().join("jit_x86")) + .expect("open"); + + file.set_len(4096).expect("set_len"); + jit_x86(unsafe { MmapMut::map_mut(&file).expect("map_mut") }); + } + + #[test] + fn mprotect_file() { + let tempdir = tempdir::TempDir::new("mmap").unwrap(); + let path = tempdir.path().join("mmap"); + + let mut options = OpenOptions::new(); + #[cfg(windows)] + options.access_mode(GENERIC_ALL); + + let mut file = options + .read(true) + .write(true) + .create(true) + .open(&path) + .expect("open"); + file.set_len(256 as u64).expect("set_len"); + + let mmap = unsafe { MmapMut::map_mut(&file).expect("map_mut") }; + + let mmap = mmap.make_read_only().expect("make_read_only"); + let mut mmap = mmap.make_mut().expect("make_mut"); + + let write = b"abc123"; + let mut read = [0u8; 6]; + + (&mut mmap[..]).write(write).unwrap(); + mmap.flush().unwrap(); + + // The mmap contains the write + (&mmap[..]).read(&mut read).unwrap(); + assert_eq!(write, &read); + + // The file should contain the write + file.read(&mut read).unwrap(); + assert_eq!(write, &read); + + // another mmap should contain the write + let mmap2 = unsafe { MmapOptions::new().map(&file).unwrap() }; + (&mmap2[..]).read(&mut read).unwrap(); + assert_eq!(write, &read); + + let mmap = mmap.make_exec().expect("make_exec"); + + drop(mmap); + } + + #[test] + fn mprotect_copy() { + let tempdir = tempdir::TempDir::new("mmap").unwrap(); + let path = tempdir.path().join("mmap"); + + let mut options = OpenOptions::new(); + #[cfg(windows)] + options.access_mode(GENERIC_ALL); + + let mut file = options + .read(true) + .write(true) + .create(true) + .open(&path) + .expect("open"); + file.set_len(256 as u64).expect("set_len"); + + let mmap = unsafe { MmapOptions::new().map_copy(&file).expect("map_mut") }; + + let mmap = mmap.make_read_only().expect("make_read_only"); + let mut mmap = mmap.make_mut().expect("make_mut"); + + let nulls = b"\0\0\0\0\0\0"; + let write = b"abc123"; + let mut read = [0u8; 6]; + + (&mut mmap[..]).write(write).unwrap(); + mmap.flush().unwrap(); + + // The mmap contains the write + (&mmap[..]).read(&mut read).unwrap(); + assert_eq!(write, &read); + + // The file does not contain the write + file.read(&mut read).unwrap(); + assert_eq!(nulls, &read); + + // another mmap does not contain the write + let mmap2 = unsafe { MmapOptions::new().map(&file).unwrap() }; + (&mmap2[..]).read(&mut read).unwrap(); + assert_eq!(nulls, &read); + + let mmap = mmap.make_exec().expect("make_exec"); + + drop(mmap); + } + + #[test] + fn mprotect_anon() { + let mmap = MmapMut::map_anon(256).expect("map_mut"); + + let mmap = mmap.make_read_only().expect("make_read_only"); + let mmap = mmap.make_mut().expect("make_mut"); + let mmap = mmap.make_exec().expect("make_exec"); + drop(mmap); + } +} diff --git a/third_party/cargo/vendor/memmap-0.7.0/src/unix.rs b/third_party/cargo/vendor/memmap-0.7.0/src/unix.rs new file mode 100644 index 0000000..4838e7e --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/src/unix.rs @@ -0,0 +1,214 @@ +extern crate libc; + +use std::fs::File; +use std::os::unix::io::{AsRawFd, RawFd}; +use std::{io, ptr}; + +#[cfg(any( + all(target_os = "linux", not(target_arch = "mips")), + target_os = "freebsd", + target_os = "android" +))] +const MAP_STACK: libc::c_int = libc::MAP_STACK; + +#[cfg(not(any( + all(target_os = "linux", not(target_arch = "mips")), + target_os = "freebsd", + target_os = "android" +)))] +const MAP_STACK: libc::c_int = 0; + +pub struct MmapInner { + ptr: *mut libc::c_void, + len: usize, +} + +impl MmapInner { + /// Creates a new `MmapInner`. + /// + /// This is a thin wrapper around the `mmap` sytem call. + fn new( + len: usize, + prot: libc::c_int, + flags: libc::c_int, + file: RawFd, + offset: u64, + ) -> io::Result { + let alignment = offset % page_size() as u64; + let aligned_offset = offset - alignment; + let aligned_len = len + alignment as usize; + if aligned_len == 0 { + // Normally the OS would catch this, but it segfaults under QEMU. + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + "memory map must have a non-zero length", + )); + } + + unsafe { + let ptr = libc::mmap( + ptr::null_mut(), + aligned_len as libc::size_t, + prot, + flags, + file, + aligned_offset as libc::off_t, + ); + + if ptr == libc::MAP_FAILED { + Err(io::Error::last_os_error()) + } else { + Ok(MmapInner { + ptr: ptr.offset(alignment as isize), + len: len, + }) + } + } + } + + pub fn map(len: usize, file: &File, offset: u64) -> io::Result { + MmapInner::new( + len, + libc::PROT_READ, + libc::MAP_SHARED, + file.as_raw_fd(), + offset, + ) + } + + pub fn map_exec(len: usize, file: &File, offset: u64) -> io::Result { + MmapInner::new( + len, + libc::PROT_READ | libc::PROT_EXEC, + libc::MAP_SHARED, + file.as_raw_fd(), + offset, + ) + } + + pub fn map_mut(len: usize, file: &File, offset: u64) -> io::Result { + MmapInner::new( + len, + libc::PROT_READ | libc::PROT_WRITE, + libc::MAP_SHARED, + file.as_raw_fd(), + offset, + ) + } + + pub fn map_copy(len: usize, file: &File, offset: u64) -> io::Result { + MmapInner::new( + len, + libc::PROT_READ | libc::PROT_WRITE, + libc::MAP_PRIVATE, + file.as_raw_fd(), + offset, + ) + } + + /// Open an anonymous memory map. + pub fn map_anon(len: usize, stack: bool) -> io::Result { + let stack = if stack { MAP_STACK } else { 0 }; + MmapInner::new( + len, + libc::PROT_READ | libc::PROT_WRITE, + libc::MAP_SHARED | libc::MAP_ANON | stack, + -1, + 0, + ) + } + + pub fn flush(&self, offset: usize, len: usize) -> io::Result<()> { + let alignment = (self.ptr as usize + offset) % page_size(); + let offset = offset as isize - alignment as isize; + let len = len + alignment; + let result = + unsafe { libc::msync(self.ptr.offset(offset), len as libc::size_t, libc::MS_SYNC) }; + if result == 0 { + Ok(()) + } else { + Err(io::Error::last_os_error()) + } + } + + pub fn flush_async(&self, offset: usize, len: usize) -> io::Result<()> { + let alignment = offset % page_size(); + let aligned_offset = offset - alignment; + let aligned_len = len + alignment; + let result = unsafe { + libc::msync( + self.ptr.offset(aligned_offset as isize), + aligned_len as libc::size_t, + libc::MS_ASYNC, + ) + }; + if result == 0 { + Ok(()) + } else { + Err(io::Error::last_os_error()) + } + } + + fn mprotect(&mut self, prot: libc::c_int) -> io::Result<()> { + unsafe { + let alignment = self.ptr as usize % page_size(); + let ptr = self.ptr.offset(-(alignment as isize)); + let len = self.len + alignment; + if libc::mprotect(ptr, len, prot) == 0 { + Ok(()) + } else { + Err(io::Error::last_os_error()) + } + } + } + + pub fn make_read_only(&mut self) -> io::Result<()> { + self.mprotect(libc::PROT_READ) + } + + pub fn make_exec(&mut self) -> io::Result<()> { + self.mprotect(libc::PROT_READ | libc::PROT_EXEC) + } + + pub fn make_mut(&mut self) -> io::Result<()> { + self.mprotect(libc::PROT_READ | libc::PROT_WRITE) + } + + #[inline] + pub fn ptr(&self) -> *const u8 { + self.ptr as *const u8 + } + + #[inline] + pub fn mut_ptr(&mut self) -> *mut u8 { + self.ptr as *mut u8 + } + + #[inline] + pub fn len(&self) -> usize { + self.len + } +} + +impl Drop for MmapInner { + fn drop(&mut self) { + let alignment = self.ptr as usize % page_size(); + unsafe { + assert!( + libc::munmap( + self.ptr.offset(-(alignment as isize)), + (self.len + alignment) as libc::size_t + ) == 0, + "unable to unmap mmap: {}", + io::Error::last_os_error() + ); + } + } +} + +unsafe impl Sync for MmapInner {} +unsafe impl Send for MmapInner {} + +fn page_size() -> usize { + unsafe { libc::sysconf(libc::_SC_PAGESIZE) as usize } +} diff --git a/third_party/cargo/vendor/memmap-0.7.0/src/windows.rs b/third_party/cargo/vendor/memmap-0.7.0/src/windows.rs new file mode 100644 index 0000000..d8aa99d --- /dev/null +++ b/third_party/cargo/vendor/memmap-0.7.0/src/windows.rs @@ -0,0 +1,300 @@ +use std::fs::File; +use std::os::raw::c_void; +use std::os::windows::io::{AsRawHandle, RawHandle}; +use std::{io, mem, ptr}; + +use winapi::shared::basetsd::SIZE_T; +use winapi::shared::minwindef::DWORD; +use winapi::um::handleapi::{CloseHandle, INVALID_HANDLE_VALUE}; +use winapi::um::memoryapi::{ + CreateFileMappingW, FlushViewOfFile, MapViewOfFile, UnmapViewOfFile, VirtualProtect, + FILE_MAP_ALL_ACCESS, FILE_MAP_COPY, FILE_MAP_EXECUTE, FILE_MAP_READ, FILE_MAP_WRITE, +}; +use winapi::um::sysinfoapi::GetSystemInfo; +use winapi::um::winnt::{ + PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, PAGE_EXECUTE_WRITECOPY, PAGE_READONLY, + PAGE_READWRITE, PAGE_WRITECOPY, +}; + +pub struct MmapInner { + file: Option, + ptr: *mut c_void, + len: usize, + copy: bool, +} + +impl MmapInner { + /// Creates a new `MmapInner`. + /// + /// This is a thin wrapper around the `CreateFileMappingW` and `MapViewOfFile` system calls. + pub fn new( + file: &File, + protect: DWORD, + access: DWORD, + offset: u64, + len: usize, + copy: bool, + ) -> io::Result { + let alignment = offset % allocation_granularity() as u64; + let aligned_offset = offset - alignment as u64; + let aligned_len = len + alignment as usize; + + unsafe { + let handle = CreateFileMappingW( + file.as_raw_handle(), + ptr::null_mut(), + protect, + 0, + 0, + ptr::null(), + ); + if handle == ptr::null_mut() { + return Err(io::Error::last_os_error()); + } + + let ptr = MapViewOfFile( + handle, + access, + (aligned_offset >> 16 >> 16) as DWORD, + (aligned_offset & 0xffffffff) as DWORD, + aligned_len as SIZE_T, + ); + CloseHandle(handle); + + if ptr == ptr::null_mut() { + Err(io::Error::last_os_error()) + } else { + Ok(MmapInner { + file: Some(file.try_clone()?), + ptr: ptr.offset(alignment as isize), + len: len as usize, + copy: copy, + }) + } + } + } + + pub fn map(len: usize, file: &File, offset: u64) -> io::Result { + let write = protection_supported(file.as_raw_handle(), PAGE_READWRITE); + let exec = protection_supported(file.as_raw_handle(), PAGE_EXECUTE_READ); + let mut access = FILE_MAP_READ; + let protection = match (write, exec) { + (true, true) => { + access |= FILE_MAP_WRITE | FILE_MAP_EXECUTE; + PAGE_EXECUTE_READWRITE + } + (true, false) => { + access |= FILE_MAP_WRITE; + PAGE_READWRITE + } + (false, true) => { + access |= FILE_MAP_EXECUTE; + PAGE_EXECUTE_READ + } + (false, false) => PAGE_READONLY, + }; + + let mut inner = MmapInner::new(file, protection, access, offset, len, false)?; + if write || exec { + inner.make_read_only()?; + } + Ok(inner) + } + + pub fn map_exec(len: usize, file: &File, offset: u64) -> io::Result { + let write = protection_supported(file.as_raw_handle(), PAGE_READWRITE); + let mut access = FILE_MAP_READ | FILE_MAP_EXECUTE; + let protection = if write { + access |= FILE_MAP_WRITE; + PAGE_EXECUTE_READWRITE + } else { + PAGE_EXECUTE_READ + }; + + let mut inner = MmapInner::new(file, protection, access, offset, len, false)?; + if write { + inner.make_exec()?; + } + Ok(inner) + } + + pub fn map_mut(len: usize, file: &File, offset: u64) -> io::Result { + let exec = protection_supported(file.as_raw_handle(), PAGE_EXECUTE_READ); + let mut access = FILE_MAP_READ | FILE_MAP_WRITE; + let protection = if exec { + access |= FILE_MAP_EXECUTE; + PAGE_EXECUTE_READWRITE + } else { + PAGE_READWRITE + }; + + let mut inner = MmapInner::new(file, protection, access, offset, len, false)?; + if exec { + inner.make_mut()?; + } + Ok(inner) + } + + pub fn map_copy(len: usize, file: &File, offset: u64) -> io::Result { + let exec = protection_supported(file.as_raw_handle(), PAGE_EXECUTE_READWRITE); + let mut access = FILE_MAP_COPY; + let protection = if exec { + access |= FILE_MAP_EXECUTE; + PAGE_EXECUTE_WRITECOPY + } else { + PAGE_WRITECOPY + }; + + let mut inner = MmapInner::new(file, protection, access, offset, len, true)?; + if exec { + inner.make_mut()?; + } + Ok(inner) + } + + pub fn map_anon(len: usize, _stack: bool) -> io::Result { + unsafe { + // Create a mapping and view with maximum access permissions, then use `VirtualProtect` + // to set the actual `Protection`. This way, we can set more permissive protection later + // on. + // Also see https://msdn.microsoft.com/en-us/library/windows/desktop/aa366537.aspx + + let handle = CreateFileMappingW( + INVALID_HANDLE_VALUE, + ptr::null_mut(), + PAGE_EXECUTE_READWRITE, + (len >> 16 >> 16) as DWORD, + (len & 0xffffffff) as DWORD, + ptr::null(), + ); + if handle == ptr::null_mut() { + return Err(io::Error::last_os_error()); + } + let access = FILE_MAP_ALL_ACCESS | FILE_MAP_EXECUTE; + let ptr = MapViewOfFile(handle, access, 0, 0, len as SIZE_T); + CloseHandle(handle); + + if ptr == ptr::null_mut() { + return Err(io::Error::last_os_error()); + } + + let mut old = 0; + let result = VirtualProtect(ptr, len as SIZE_T, PAGE_READWRITE, &mut old); + if result != 0 { + Ok(MmapInner { + file: None, + ptr: ptr, + len: len as usize, + copy: false, + }) + } else { + Err(io::Error::last_os_error()) + } + } + } + + pub fn flush(&self, offset: usize, len: usize) -> io::Result<()> { + self.flush_async(offset, len)?; + if let Some(ref file) = self.file { + file.sync_data()?; + } + Ok(()) + } + + pub fn flush_async(&self, offset: usize, len: usize) -> io::Result<()> { + let result = unsafe { FlushViewOfFile(self.ptr.offset(offset as isize), len as SIZE_T) }; + if result != 0 { + Ok(()) + } else { + Err(io::Error::last_os_error()) + } + } + + fn virtual_protect(&mut self, protect: DWORD) -> io::Result<()> { + unsafe { + let alignment = self.ptr as usize % allocation_granularity(); + let ptr = self.ptr.offset(-(alignment as isize)); + let aligned_len = self.len as SIZE_T + alignment as SIZE_T; + + let mut old = 0; + let result = VirtualProtect(ptr, aligned_len, protect, &mut old); + + if result != 0 { + Ok(()) + } else { + Err(io::Error::last_os_error()) + } + } + } + + pub fn make_read_only(&mut self) -> io::Result<()> { + self.virtual_protect(PAGE_READONLY) + } + + pub fn make_exec(&mut self) -> io::Result<()> { + if self.copy { + self.virtual_protect(PAGE_EXECUTE_WRITECOPY) + } else { + self.virtual_protect(PAGE_EXECUTE_READ) + } + } + + pub fn make_mut(&mut self) -> io::Result<()> { + if self.copy { + self.virtual_protect(PAGE_WRITECOPY) + } else { + self.virtual_protect(PAGE_READWRITE) + } + } + + #[inline] + pub fn ptr(&self) -> *const u8 { + self.ptr as *const u8 + } + + #[inline] + pub fn mut_ptr(&mut self) -> *mut u8 { + self.ptr as *mut u8 + } + + #[inline] + pub fn len(&self) -> usize { + self.len + } +} + +impl Drop for MmapInner { + fn drop(&mut self) { + let alignment = self.ptr as usize % allocation_granularity(); + unsafe { + let ptr = self.ptr.offset(-(alignment as isize)); + assert!( + UnmapViewOfFile(ptr) != 0, + "unable to unmap mmap: {}", + io::Error::last_os_error() + ); + } + } +} + +unsafe impl Sync for MmapInner {} +unsafe impl Send for MmapInner {} + +fn protection_supported(handle: RawHandle, protection: DWORD) -> bool { + unsafe { + let handle = CreateFileMappingW(handle, ptr::null_mut(), protection, 0, 0, ptr::null()); + if handle == ptr::null_mut() { + return false; + } + CloseHandle(handle); + true + } +} + +fn allocation_granularity() -> usize { + unsafe { + let mut info = mem::zeroed(); + GetSystemInfo(&mut info); + return info.dwAllocationGranularity as usize; + } +} diff --git a/third_party/cargo/vendor/memoffset-0.2.1/.cargo-checksum.json b/third_party/cargo/vendor/memoffset-0.2.1/.cargo-checksum.json new file mode 100644 index 0000000..43dbd48 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.2.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"c48ab44d744586aab2bb02ff1288429679cced7cca191c0584982f9eb6edb6c7","LICENSE":"3234ac55816264ee7b6c7ee27efd61cf0a1fe775806870e3d9b4c41ea73c5cb1","README.md":"5b2de7b6eaa7f01720c0a58040264f1ba336fbd005d43284b55f82a826011d11","src/lib.rs":"f8cfb7f2f7e3b179de53d1bde8e814c51b5f66f638f1e744bc14cf9ae4148381","src/offset_of.rs":"1cf7c89bb7b05dee7241913596f107672289e14e8d3d404eecc8c97b302f2f12","src/span_of.rs":"513452dcb6e4c7d5354631973492561de83bed5aaa8306f82cc5828664962538"},"package":"0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"} \ No newline at end of file diff --git a/third_party/cargo/vendor/memoffset-0.2.1/BUILD b/third_party/cargo/vendor/memoffset-0.2.1/BUILD new file mode 100644 index 0000000..563d580 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.2.1/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "memoffset", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.2.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/memoffset-0.2.1/Cargo.toml b/third_party/cargo/vendor/memoffset-0.2.1/Cargo.toml new file mode 100644 index 0000000..3b6b907 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.2.1/Cargo.toml @@ -0,0 +1,24 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "memoffset" +version = "0.2.1" +authors = ["Gilad Naaman "] +description = "offset_of functionality for Rust structs." +readme = "README.md" +keywords = ["mem", "offset", "offset_of", "offsetof"] +categories = ["no-std"] +license = "MIT" +repository = "https://github.com/Gilnaa/memoffset" + +[dependencies] diff --git a/third_party/cargo/vendor/memoffset-0.2.1/LICENSE b/third_party/cargo/vendor/memoffset-0.2.1/LICENSE new file mode 100644 index 0000000..61f6081 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.2.1/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2017 Gilad Naaman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/third_party/cargo/vendor/memoffset-0.2.1/README.md b/third_party/cargo/vendor/memoffset-0.2.1/README.md new file mode 100644 index 0000000..1725d7d --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.2.1/README.md @@ -0,0 +1,47 @@ +# memoffset # + +[![](http://meritbadge.herokuapp.com/memoffset)](https://crates.io/crates/memoffset) + +C-Like `offset_of` functionality for Rust structs. + +Introduces the following macros: + * `offset_of!` for obtaining the offset of a member of a struct. + * `span_of!` for obtaining the range that a field, or fields, span. + +`memoffset` works under `no_std` environments. + +## Usage ## +Add the following dependency to your `Cargo.toml`: + +```toml +[dependencies] +memoffset = "0.2" +``` + +Add the following lines at the top of your `main.rs` or `lib.rs` files. + +```rust +#[macro_use] +extern crate memoffset; +``` + +## Examples ## +```rust +#[repr(C, packed)] +struct Foo { + a: u32, + b: u32, + c: [u8; 5], + d: u32, +} + +assert_eq!(offset_of!(Foo, b), 4); +assert_eq!(offset_of!(Foo, c[3]), 11); + +assert_eq!(span_of!(Foo, a), 0..4); +assert_eq!(span_of!(Foo, a .. c), 0..8); +assert_eq!(span_of!(Foo, a .. c[1]), 0..9); +assert_eq!(span_of!(Foo, a ..= c[1]), 0..10); +assert_eq!(span_of!(Foo, ..= d), 0..14); +assert_eq!(span_of!(Foo, b ..), 4..17); +``` diff --git a/third_party/cargo/vendor/memoffset-0.2.1/src/lib.rs b/third_party/cargo/vendor/memoffset-0.2.1/src/lib.rs new file mode 100644 index 0000000..2738be4 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.2.1/src/lib.rs @@ -0,0 +1,70 @@ +// Copyright (c) 2017 Gilad Naaman +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +//! A crate used for calculating offsets of struct members and their spans. +//! +//! Some of the funcationality of the crate makes no sense when used along with structs that +//! are not `#[repr(C, packed)]`, but it is up to the user to make sure that they are. +//! +//! ## Examples +//! ``` +//! #[macro_use] +//! extern crate memoffset; +//! +//! #[repr(C, packed)] +//! struct HelpMeIAmTrappedInAStructFactory { +//! help_me_before_they_: [u8; 15], +//! a: u32 +//! } +//! +//! fn main() { +//! assert_eq!(offset_of!(HelpMeIAmTrappedInAStructFactory, a), 15); +//! assert_eq!(span_of!(HelpMeIAmTrappedInAStructFactory, a), 15..19); +//! assert_eq!(span_of!(HelpMeIAmTrappedInAStructFactory, help_me_before_they_[2] .. a), 2..15); +//! } +//! ``` +//! +//! This functionality can be useful, for example, for checksum calculations: +//! +//! ```ignore +//! #[repr(C, packed)] +//! struct Message { +//! header: MessageHeader, +//! fragment_index: u32, +//! fragment_count: u32, +//! payload: [u8; 1024], +//! checksum: u16 +//! } +//! +//! let checksum_range = &raw[span_of!(Message, header..checksum)]; +//! let checksum = crc16(checksum_range); +//! ``` + +#![no_std] + +// This `use` statement enables the macros to use `$crate::mem`. +// Doing this enables this crate to function under both std and no-std crates. +#[doc(hidden)] +pub use core::mem; + +#[macro_use] +mod offset_of; +#[macro_use] +mod span_of; diff --git a/third_party/cargo/vendor/memoffset-0.2.1/src/offset_of.rs b/third_party/cargo/vendor/memoffset-0.2.1/src/offset_of.rs new file mode 100644 index 0000000..6148657 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.2.1/src/offset_of.rs @@ -0,0 +1,119 @@ +// Copyright (c) 2017 Gilad Naaman +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +/// Calculates the offset of the specified field from the start of the struct. +/// This macro supports arbitrary amount of subscripts and recursive member-accesses. +/// +/// *Note*: This macro may not make much sense when used on structs that are not `#[repr(C, packed)]` +/// +/// ## Examples - Simple +/// ``` +/// #[macro_use] +/// extern crate memoffset; +/// +/// #[repr(C, packed)] +/// struct Foo { +/// a: u32, +/// b: u64, +/// c: [u8; 5] +/// } +/// +/// fn main() { +/// assert_eq!(offset_of!(Foo, a), 0); +/// assert_eq!(offset_of!(Foo, b), 4); +/// assert_eq!(offset_of!(Foo, c[2]), 14); +/// } +/// ``` +/// +/// ## Examples - Advanced +/// ``` +/// #[macro_use] +/// extern crate memoffset; +/// +/// #[repr(C, packed)] +/// struct UnnecessarilyComplicatedStruct { +/// member: [UnnecessarilyComplexStruct; 12] +/// } +/// +/// #[repr(C, packed)] +/// struct UnnecessarilyComplexStruct { +/// a: u32, +/// b: u64, +/// c: [u8; 5] +/// } +/// +/// +/// fn main() { +/// assert_eq!(offset_of!(UnnecessarilyComplicatedStruct, member[3].c[3]), 66); +/// } +/// ``` +#[macro_export] +macro_rules! offset_of { + ($father:ty, $($field:tt)+) => ({ + #[allow(unused_unsafe)] + let root: $father = unsafe { $crate::mem::uninitialized() }; + + let base = &root as *const _ as usize; + + // Future error: borrow of packed field requires unsafe function or block (error E0133) + #[allow(unused_unsafe)] + let member = unsafe { &root.$($field)* as *const _ as usize }; + + $crate::mem::forget(root); + + member - base + }); +} + +#[cfg(test)] +mod tests { + #[repr(C, packed)] + struct Foo { + a: u32, + b: [u8; 4], + c: i64, + } + + #[test] + fn offset_simple() { + assert_eq!(offset_of!(Foo, a), 0); + assert_eq!(offset_of!(Foo, b), 4); + assert_eq!(offset_of!(Foo, c), 8); + } + + #[test] + fn offset_index() { + assert_eq!(offset_of!(Foo, b[2]), 6); + } + + #[test] + #[should_panic] + fn offset_index_out_of_bounds() { + offset_of!(Foo, b[4]); + } + + #[test] + fn tuple_struct() { + #[repr(C, packed)] + struct Tup(i32, i32); + + assert_eq!(offset_of!(Tup, 0), 0); + } +} diff --git a/third_party/cargo/vendor/memoffset-0.2.1/src/span_of.rs b/third_party/cargo/vendor/memoffset-0.2.1/src/span_of.rs new file mode 100644 index 0000000..fcb49ed --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.2.1/src/span_of.rs @@ -0,0 +1,274 @@ +// Copyright (c) 2017 Gilad Naaman +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +/// Produces a range instance representing the sub-slice containing the specified member. +/// +/// This macro provides 2 forms of differing functionalities. +/// +/// The first form is identical to the appearance of the `offset_of!` macro, +/// and just like `offset_of!`, it has no limit on the depth of fields / subscripts used. +/// +/// ```ignore +/// span_of!(Struct, member[index].field) +/// ``` +/// +/// The second form of `span_of!` returns a sub-slice which starts at one field, and ends at another. +/// The general pattern of this form is: +/// +/// ```ignore +/// // Exclusive +/// span_of!(Struct, member_a .. member_b) +/// // Inclusive +/// span_of!(Struct, member_a ..= member_b) +/// +/// // Open-ended ranges +/// span_of!(Struct, .. end) +/// span_of!(Struct, start ..) +/// ``` +/// +/// *Note*: +/// This macro uses recursion in order to resolve the range expressions, so there is a limit to the complexity of the expression. +/// In order to raise the limit, the compiler's recursion limit should be lifted. +/// +/// *Note*: +/// This macro may not make much sense when used on structs that are not `#[repr(C, packed)]` +/// +/// ## Examples +/// ``` +/// #[macro_use] +/// extern crate memoffset; +/// +/// #[repr(C, packed)] +/// struct Florp { +/// a: u32 +/// } +/// +/// #[repr(C, packed)] +/// struct Blarg { +/// x: u64, +/// y: [u8; 56], +/// z: Florp, +/// egg: [[u8; 4]; 4] +/// } +/// +/// fn main() { +/// assert_eq!(0..8, span_of!(Blarg, x)); +/// assert_eq!(64..68, span_of!(Blarg, z.a)); +/// assert_eq!(79..80, span_of!(Blarg, egg[2][3])); +/// +/// assert_eq!(8..64, span_of!(Blarg, y[0] .. z)); +/// assert_eq!(0..42, span_of!(Blarg, x .. y[34])); +/// assert_eq!(0..64, span_of!(Blarg, x ..= y)); +/// assert_eq!(58..68, span_of!(Blarg, y[50] ..= z)); +/// } +/// ``` +#[macro_export] +macro_rules! span_of { + (@helper $root:ident, [] ..=) => { + compile_error!("Expected a range, found '..='") + }; + (@helper $root:ident, [] ..) => { + compile_error!("Expected a range, found '..'") + }; + (@helper $root:ident, [] ..= $($field:tt)+) => { + (&$root as *const _ as usize, + &$root.$($field)* as *const _ as usize + $crate::mem::size_of_val(&$root.$($field)*)) + }; + (@helper $root:ident, [] .. $($field:tt)+) => { + (&$root as *const _ as usize, &$root.$($field)* as *const _ as usize) + }; + (@helper $root:ident, $(# $begin:tt)+ [] ..= $($end:tt)+) => { + (&$root.$($begin)* as *const _ as usize, + &$root.$($end)* as *const _ as usize + $crate::mem::size_of_val(&$root.$($end)*)) + }; + (@helper $root:ident, $(# $begin:tt)+ [] .. $($end:tt)+) => { + (&$root.$($begin)* as *const _ as usize, &$root.$($end)* as *const _ as usize) + }; + (@helper $root:ident, $(# $begin:tt)+ [] ..) => { + (&$root.$($begin)* as *const _ as usize, + &$root as *const _ as usize + $crate::mem::size_of_val(&$root)) + }; + (@helper $root:ident, $(# $begin:tt)+ [] ..=) => { + compile_error!( + "Found inclusive range to the end of a struct. Did you mean '..' instead of '..='?") + }; + (@helper $root:ident, $(# $begin:tt)+ []) => { + (&$root.$($begin)* as *const _ as usize, + &$root.$($begin)* as *const _ as usize + $crate::mem::size_of_val(&$root.$($begin)*)) + }; + (@helper $root:ident, $(# $begin:tt)+ [] $tt:tt $($rest:tt)*) => { + span_of!(@helper $root, $(#$begin)* #$tt [] $($rest)*) + }; + (@helper $root:ident, [] $tt:tt $($rest:tt)*) => { + span_of!(@helper $root, #$tt [] $($rest)*) + }; + + ($sty:ty, $($exp:tt)+) => ({ + unsafe { + let root: $sty = $crate::mem::uninitialized(); + let base = &root as *const _ as usize; + let (begin, end) = span_of!(@helper root, [] $($exp)*); + begin-base..end-base + } + }); +} + +#[cfg(test)] +mod tests { + use ::core::mem; + + #[repr(C, packed)] + struct Foo { + a: u32, + b: [u8; 4], + c: i64, + } + + #[test] + fn span_simple() { + assert_eq!(span_of!(Foo, a), 0..4); + assert_eq!(span_of!(Foo, b), 4..8); + assert_eq!(span_of!(Foo, c), 8..16); + } + + #[test] + fn span_index() { + assert_eq!(span_of!(Foo, b[1]), 5..6); + } + + #[test] + fn span_forms() { + #[repr(C, packed)] + struct Florp { + a: u32, + } + + #[repr(C, packed)] + struct Blarg { + x: u64, + y: [u8; 56], + z: Florp, + egg: [[u8; 4]; 4], + } + + // Love me some brute force + assert_eq!(0..8, span_of!(Blarg, x)); + assert_eq!(64..68, span_of!(Blarg, z.a)); + assert_eq!(79..80, span_of!(Blarg, egg[2][3])); + + assert_eq!(8..64, span_of!(Blarg, y[0]..z)); + assert_eq!(0..42, span_of!(Blarg, x..y[34])); + assert_eq!(0..64, span_of!(Blarg, x ..= y)); + assert_eq!(58..68, span_of!(Blarg, y[50] ..= z)); + } + + #[test] + fn ig_test() { + #[repr(C)] + struct Member { + foo: u32, + } + + #[repr(C)] + struct Test { + x: u64, + y: [u8; 56], + z: Member, + egg: [[u8; 4]; 4], + } + + assert_eq!(span_of!(Test, ..x), 0..0); + assert_eq!(span_of!(Test, ..=x), 0..8); + assert_eq!(span_of!(Test, ..y), 0..8); + assert_eq!(span_of!(Test, ..=y), 0..64); + assert_eq!(span_of!(Test, ..y[0]), 0..8); + assert_eq!(span_of!(Test, ..=y[0]), 0..9); + assert_eq!(span_of!(Test, ..z), 0..64); + assert_eq!(span_of!(Test, ..=z), 0..68); + assert_eq!(span_of!(Test, ..z.foo), 0..64); + assert_eq!(span_of!(Test, ..=z.foo), 0..68); + assert_eq!(span_of!(Test, ..egg), 0..68); + assert_eq!(span_of!(Test, ..=egg), 0..84); + assert_eq!(span_of!(Test, ..egg[0]), 0..68); + assert_eq!(span_of!(Test, ..=egg[0]), 0..72); + assert_eq!(span_of!(Test, ..egg[0][0]), 0..68); + assert_eq!(span_of!(Test, ..=egg[0][0]), 0..69); + assert_eq!( + span_of!(Test, x..), + offset_of!(Test, x)..mem::size_of::() + ); + assert_eq!( + span_of!(Test, y..), + offset_of!(Test, y)..mem::size_of::() + ); + assert_eq!( + span_of!(Test, y[0]..), + offset_of!(Test, y[0])..mem::size_of::() + ); + assert_eq!( + span_of!(Test, z..), + offset_of!(Test, z)..mem::size_of::() + ); + assert_eq!( + span_of!(Test, z.foo..), + offset_of!(Test, z.foo)..mem::size_of::() + ); + assert_eq!( + span_of!(Test, egg..), + offset_of!(Test, egg)..mem::size_of::() + ); + assert_eq!( + span_of!(Test, egg[0]..), + offset_of!(Test, egg[0])..mem::size_of::() + ); + assert_eq!( + span_of!(Test, egg[0][0]..), + offset_of!(Test, egg[0][0])..mem::size_of::() + ); + assert_eq!( + span_of!(Test, x..y), + offset_of!(Test, x)..offset_of!(Test, y) + ); + assert_eq!( + span_of!(Test, x..=y), + offset_of!(Test, x)..offset_of!(Test, y) + mem::size_of::<[u8; 56]>() + ); + assert_eq!( + span_of!(Test, x..y[4]), + offset_of!(Test, x)..offset_of!(Test, y[4]) + ); + assert_eq!( + span_of!(Test, x..=y[4]), + offset_of!(Test, x)..offset_of!(Test, y) + mem::size_of::<[u8; 5]>() + ); + assert_eq!( + span_of!(Test, x..z.foo), + offset_of!(Test, x)..offset_of!(Test, z.foo) + ); + assert_eq!( + span_of!(Test, x..=z.foo), + offset_of!(Test, x)..offset_of!(Test, z.foo) + mem::size_of::() + ); + assert_eq!( + span_of!(Test, egg[0][0]..egg[1][0]), + offset_of!(Test, egg[0][0])..offset_of!(Test, egg[1][0]) + ); + } +} diff --git a/third_party/cargo/vendor/memoffset-0.5.3/.cargo-checksum.json b/third_party/cargo/vendor/memoffset-0.5.3/.cargo-checksum.json new file mode 100644 index 0000000..ba1409c --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.5.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"8267091894b0a0e1ea8df0a56c9146ea5d91ba7359be513a6e62cbc2a3d41d93","LICENSE":"3234ac55816264ee7b6c7ee27efd61cf0a1fe775806870e3d9b4c41ea73c5cb1","README.md":"4ef95a9f9be0f34a463865fe2a6a91934e4bf3e17f67fb0792a3fd45c13dbd80","build.rs":"cc388da9e9bb47bcf5a571d6cf5ec4b9e3b3ef35ac2feb70496f0a7ad74f912d","ci/miri.sh":"9b8c77efb59b4dcf896ec7a648bee4218d779269eb017acc21a3a6d9f6e15104","src/lib.rs":"83e847629d1f0a5ac2880de303cf780685a58455d9a56a1088f10cc0565caa1e","src/offset_of.rs":"7794f44c7001f25287905c7844a508d33cb0516dbc59e439b08a1e951a526d99","src/span_of.rs":"922d7d7dcc0a448792e9d7c5cee113252f0fefbbb7a1a1ce65b80332fe69174a"},"package":"75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9"} \ No newline at end of file diff --git a/third_party/cargo/vendor/memoffset-0.5.3/BUILD b/third_party/cargo/vendor/memoffset-0.5.3/BUILD new file mode 100644 index 0000000..6f724ed --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.5.3/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "memoffset", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.5.3", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/memoffset-0.5.3/Cargo.toml b/third_party/cargo/vendor/memoffset-0.5.3/Cargo.toml new file mode 100644 index 0000000..8d54fb9 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.5.3/Cargo.toml @@ -0,0 +1,26 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "memoffset" +version = "0.5.3" +authors = ["Gilad Naaman "] +description = "offset_of functionality for Rust structs." +readme = "README.md" +keywords = ["mem", "offset", "offset_of", "offsetof"] +categories = ["no-std"] +license = "MIT" +repository = "https://github.com/Gilnaa/memoffset" +[dev-dependencies.doc-comment] +version = "0.3" +[build-dependencies.rustc_version] +version = "0.2.3" diff --git a/third_party/cargo/vendor/memoffset-0.5.3/LICENSE b/third_party/cargo/vendor/memoffset-0.5.3/LICENSE new file mode 100644 index 0000000..61f6081 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.5.3/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2017 Gilad Naaman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/third_party/cargo/vendor/memoffset-0.5.3/README.md b/third_party/cargo/vendor/memoffset-0.5.3/README.md new file mode 100644 index 0000000..82ab3aa --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.5.3/README.md @@ -0,0 +1,53 @@ +# memoffset # + +[![](http://meritbadge.herokuapp.com/memoffset)](https://crates.io/crates/memoffset) + +C-Like `offset_of` functionality for Rust structs. + +Introduces the following macros: + * `offset_of!` for obtaining the offset of a member of a struct. + * `span_of!` for obtaining the range that a field, or fields, span. + +`memoffset` works under `no_std` environments. + +## Usage ## +Add the following dependency to your `Cargo.toml`: + +```toml +[dependencies] +memoffset = "0.5" +``` + +These versions will compile fine with rustc versions greater or equal to 1.20. + +Add the following lines at the top of your `main.rs` or `lib.rs` files. + +```rust,ignore +#[macro_use] +extern crate memoffset; +``` + +## Examples ## +```rust +#[macro_use] +extern crate memoffset; + +#[repr(C, packed)] +struct Foo { + a: u32, + b: u32, + c: [u8; 5], + d: u32, +} + +fn main() { + assert_eq!(offset_of!(Foo, b), 4); + assert_eq!(offset_of!(Foo, d), 4+4+5); + + assert_eq!(span_of!(Foo, a), 0..4); + assert_eq!(span_of!(Foo, a .. c), 0..8); + assert_eq!(span_of!(Foo, a ..= c), 0..13); + assert_eq!(span_of!(Foo, ..= d), 0..17); + assert_eq!(span_of!(Foo, b ..), 4..17); +} +``` diff --git a/third_party/cargo/vendor/memoffset-0.5.3/build.rs b/third_party/cargo/vendor/memoffset-0.5.3/build.rs new file mode 100644 index 0000000..d4502cf --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.5.3/build.rs @@ -0,0 +1,18 @@ +extern crate rustc_version; +use rustc_version::{version, Version}; + +fn main() { + let version = version().unwrap(); + + // Assert we haven't travelled back in time + assert!(version.major >= 1); + + // Check for a minimum version + if version >= Version::from((1, 36, 0)) { + println!("cargo:rustc-cfg=memoffset_maybe_uninit"); + } + + if version >= Version::from((1, 40, 0)) { + println!("cargo:rustc-cfg=memoffset_doctests"); + } +} diff --git a/third_party/cargo/vendor/memoffset-0.5.3/ci/miri.sh b/third_party/cargo/vendor/memoffset-0.5.3/ci/miri.sh new file mode 100644 index 0000000..7aeb890 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.5.3/ci/miri.sh @@ -0,0 +1,10 @@ +set -ex + +MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri) +echo "Installing latest nightly with Miri: $MIRI_NIGHTLY" +rustup default "$MIRI_NIGHTLY" + +rustup component add miri +cargo miri setup + +cargo miri test diff --git a/third_party/cargo/vendor/memoffset-0.5.3/src/lib.rs b/third_party/cargo/vendor/memoffset-0.5.3/src/lib.rs new file mode 100644 index 0000000..6a7b111 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.5.3/src/lib.rs @@ -0,0 +1,80 @@ +// Copyright (c) 2017 Gilad Naaman +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +//! A crate used for calculating offsets of struct members and their spans. +//! +//! This functionality currently can not be used in compile time code such as `const` or `const fn` definitions. +//! +//! ## Examples +//! ``` +//! #[macro_use] +//! extern crate memoffset; +//! +//! #[repr(C, packed)] +//! struct HelpMeIAmTrappedInAStructFactory { +//! help_me_before_they_: [u8; 15], +//! a: u32 +//! } +//! +//! fn main() { +//! assert_eq!(offset_of!(HelpMeIAmTrappedInAStructFactory, a), 15); +//! assert_eq!(span_of!(HelpMeIAmTrappedInAStructFactory, a), 15..19); +//! assert_eq!(span_of!(HelpMeIAmTrappedInAStructFactory, help_me_before_they_ .. a), 0..15); +//! } +//! ``` +//! +//! This functionality can be useful, for example, for checksum calculations: +//! +//! ```ignore +//! #[repr(C, packed)] +//! struct Message { +//! header: MessageHeader, +//! fragment_index: u32, +//! fragment_count: u32, +//! payload: [u8; 1024], +//! checksum: u16 +//! } +//! +//! let checksum_range = &raw[span_of!(Message, header..checksum)]; +//! let checksum = crc16(checksum_range); +//! ``` + +#![no_std] + +#[macro_use] +#[cfg(memoffset_doctests)] +#[cfg(doctest)] +extern crate doc_comment; +#[cfg(memoffset_doctests)] +#[cfg(doctest)] +doctest!("../README.md"); + +// This `use` statement enables the macros to use `$crate::mem`. +// Doing this enables this crate to function under both std and no-std crates. +#[doc(hidden)] +pub use core::mem; + +#[doc(hidden)] +pub use core::ptr; + +#[macro_use] +mod offset_of; +#[macro_use] +mod span_of; diff --git a/third_party/cargo/vendor/memoffset-0.5.3/src/offset_of.rs b/third_party/cargo/vendor/memoffset-0.5.3/src/offset_of.rs new file mode 100644 index 0000000..441cf2a --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.5.3/src/offset_of.rs @@ -0,0 +1,148 @@ +// Copyright (c) 2017 Gilad Naaman +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +/// Macro to create a local `base_ptr` raw pointer of the given type, avoiding UB as +/// much as is possible currently. +#[cfg(memoffset_maybe_uninit)] +#[macro_export] +#[doc(hidden)] +macro_rules! _memoffset__let_base_ptr { + ($name:ident, $type:path) => { + // No UB here, and the pointer does not dangle, either. + // But we have to make sure that `uninit` lives long enough, + // so it has to be in the same scope as `$name`. That's why + // `let_base_ptr` declares a variable (several, actually) + // instad of returning one. + let uninit = $crate::mem::MaybeUninit::<$type>::uninit(); + let $name = uninit.as_ptr(); + }; +} +#[cfg(not(memoffset_maybe_uninit))] +#[macro_export] +#[doc(hidden)] +macro_rules! _memoffset__let_base_ptr { + ($name:ident, $type:path) => { + // No UB right here, but we will later dereference this pointer to + // offset into a field, and that is UB when the pointer is dangling. + let $name = $crate::mem::align_of::<$type>() as *const $type; + }; +} + +/// Deref-coercion protection macro. +#[macro_export] +#[doc(hidden)] +macro_rules! _memoffset__field_check { + ($type:path, $field:tt) => { + // Make sure the field actually exists. This line ensures that a + // compile-time error is generated if $field is accessed through a + // Deref impl. + let $type { $field: _, .. }; + }; +} + +/// Calculates the offset of the specified field from the start of the struct. +/// +/// ## Examples +/// ``` +/// #[macro_use] +/// extern crate memoffset; +/// +/// #[repr(C, packed)] +/// struct Foo { +/// a: u32, +/// b: u64, +/// c: [u8; 5] +/// } +/// +/// fn main() { +/// assert_eq!(offset_of!(Foo, a), 0); +/// assert_eq!(offset_of!(Foo, b), 4); +/// } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! offset_of { + ($parent:path, $field:tt) => {{ + _memoffset__field_check!($parent, $field); + + // Get a base pointer. + _memoffset__let_base_ptr!(base_ptr, $parent); + // Get the field address. This is UB because we are creating a reference to + // the uninitialized field. + // Crucially, we know that this will not trigger a deref coercion because + // of the `field_check!` we did above. + #[allow(unused_unsafe)] // for when the macro is used in an unsafe block + let field_ptr = unsafe { &(*base_ptr).$field as *const _ }; + let offset = (field_ptr as usize) - (base_ptr as usize); + offset + }}; +} + +#[cfg(test)] +mod tests { + #[test] + fn offset_simple() { + #[repr(C)] + struct Foo { + a: u32, + b: [u8; 2], + c: i64, + } + + assert_eq!(offset_of!(Foo, a), 0); + assert_eq!(offset_of!(Foo, b), 4); + assert_eq!(offset_of!(Foo, c), 8); + } + + #[test] + #[cfg(not(miri))] // this creates unaligned references + fn offset_simple_packed() { + #[repr(C, packed)] + struct Foo { + a: u32, + b: [u8; 2], + c: i64, + } + + assert_eq!(offset_of!(Foo, a), 0); + assert_eq!(offset_of!(Foo, b), 4); + assert_eq!(offset_of!(Foo, c), 6); + } + + #[test] + fn tuple_struct() { + #[repr(C)] + struct Tup(i32, i32); + + assert_eq!(offset_of!(Tup, 0), 0); + assert_eq!(offset_of!(Tup, 1), 4); + } + + #[test] + fn path() { + mod sub { + #[repr(C)] + pub struct Foo { + pub x: u32, + } + } + + assert_eq!(offset_of!(sub::Foo, x), 0); + } +} diff --git a/third_party/cargo/vendor/memoffset-0.5.3/src/span_of.rs b/third_party/cargo/vendor/memoffset-0.5.3/src/span_of.rs new file mode 100644 index 0000000..b6bed89 --- /dev/null +++ b/third_party/cargo/vendor/memoffset-0.5.3/src/span_of.rs @@ -0,0 +1,268 @@ +// Copyright (c) 2017 Gilad Naaman +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +/// Reexport for `local_inner_macros`; see +/// . +#[doc(hidden)] +#[macro_export] +macro_rules! _memoffset__compile_error { + ($($inner:tt)*) => { + compile_error! { $($inner)* } + } +} + +/// Produces a range instance representing the sub-slice containing the specified member. +/// +/// This macro provides 2 forms of differing functionalities. +/// +/// The first form is identical to the appearance of the `offset_of!` macro. +/// +/// ```ignore +/// span_of!(Struct, member) +/// ``` +/// +/// The second form of `span_of!` returns a sub-slice which starts at one field, and ends at another. +/// The general pattern of this form is: +/// +/// ```ignore +/// // Exclusive +/// span_of!(Struct, member_a .. member_b) +/// // Inclusive +/// span_of!(Struct, member_a ..= member_b) +/// +/// // Open-ended ranges +/// span_of!(Struct, .. end) +/// span_of!(Struct, start ..) +/// ``` +/// +/// *Note*: +/// This macro uses recursion in order to resolve the range expressions, so there is a limit to +/// the complexity of the expression. +/// In order to raise the limit, the compiler's recursion limit should be lifted. +/// +/// ## Examples +/// ``` +/// #[macro_use] +/// extern crate memoffset; +/// +/// #[repr(C)] +/// struct Florp { +/// a: u32 +/// } +/// +/// #[repr(C)] +/// struct Blarg { +/// x: [u32; 2], +/// y: [u8; 56], +/// z: Florp, +/// egg: [[u8; 4]; 4] +/// } +/// +/// fn main() { +/// assert_eq!(0..84, span_of!(Blarg, ..)); +/// assert_eq!(0..8, span_of!(Blarg, .. y)); +/// assert_eq!(0..64, span_of!(Blarg, ..= y)); +/// assert_eq!(0..8, span_of!(Blarg, x)); +/// assert_eq!(8..84, span_of!(Blarg, y ..)); +/// assert_eq!(0..8, span_of!(Blarg, x .. y)); +/// assert_eq!(0..64, span_of!(Blarg, x ..= y)); +/// } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! span_of { + (@helper $root:ident, [] ..=) => { + _memoffset__compile_error!("Expected a range, found '..='") + }; + (@helper $root:ident, [] ..) => { + _memoffset__compile_error!("Expected a range, found '..'") + }; + // Lots of UB due to taking references to uninitialized fields! But that can currently + // not be avoided. + // No explicit begin for range. + (@helper $root:ident, $parent:path, [] ..) => {{ + ($root as usize, + $root as usize + $crate::mem::size_of_val(&(*$root))) + }}; + (@helper $root:ident, $parent:path, [] ..= $field:tt) => {{ + _memoffset__field_check!($parent, $field); + ($root as usize, + &(*$root).$field as *const _ as usize + $crate::mem::size_of_val(&(*$root).$field)) + }}; + (@helper $root:ident, $parent:path, [] .. $field:tt) => {{ + _memoffset__field_check!($parent, $field); + ($root as usize, &(*$root).$field as *const _ as usize) + }}; + // Explicit begin and end for range. + (@helper $root:ident, $parent:path, # $begin:tt [] ..= $end:tt) => {{ + _memoffset__field_check!($parent, $begin); + _memoffset__field_check!($parent, $end); + (&(*$root).$begin as *const _ as usize, + &(*$root).$end as *const _ as usize + $crate::mem::size_of_val(&(*$root).$end)) + }}; + (@helper $root:ident, $parent:path, # $begin:tt [] .. $end:tt) => {{ + _memoffset__field_check!($parent, $begin); + _memoffset__field_check!($parent, $end); + (&(*$root).$begin as *const _ as usize, + &(*$root).$end as *const _ as usize) + }}; + // No explicit end for range. + (@helper $root:ident, $parent:path, # $begin:tt [] ..) => {{ + _memoffset__field_check!($parent, $begin); + (&(*$root).$begin as *const _ as usize, + $root as usize + $crate::mem::size_of_val(&*$root)) + }}; + (@helper $root:ident, $parent:path, # $begin:tt [] ..=) => {{ + _memoffset__compile_error!( + "Found inclusive range to the end of a struct. Did you mean '..' instead of '..='?") + }}; + // Just one field. + (@helper $root:ident, $parent:path, # $begin:tt []) => {{ + _memoffset__field_check!($parent, $begin); + (&(*$root).$begin as *const _ as usize, + &(*$root).$begin as *const _ as usize + $crate::mem::size_of_val(&(*$root).$begin)) + }}; + // Parsing. + (@helper $root:ident, $parent:path, $(# $begin:tt)+ [] $tt:tt $($rest:tt)*) => {{ + span_of!(@helper $root, $parent, $(#$begin)* #$tt [] $($rest)*) + }}; + (@helper $root:ident, $parent:path, [] $tt:tt $($rest:tt)*) => {{ + span_of!(@helper $root, $parent, #$tt [] $($rest)*) + }}; + + // Entry point. + ($sty:path, $($exp:tt)+) => ({ + unsafe { + // Get a base pointer. + _memoffset__let_base_ptr!(root, $sty); + let base = root as usize; + let (begin, end) = span_of!(@helper root, $sty, [] $($exp)*); + begin-base..end-base + } + }); +} + +#[cfg(test)] +mod tests { + use core::mem; + + #[test] + fn span_simple() { + #[repr(C)] + struct Foo { + a: u32, + b: [u8; 2], + c: i64, + } + + assert_eq!(span_of!(Foo, a), 0..4); + assert_eq!(span_of!(Foo, b), 4..6); + assert_eq!(span_of!(Foo, c), 8..8 + 8); + } + + #[test] + #[cfg(not(miri))] // this creates unaligned references + fn span_simple_packed() { + #[repr(C, packed)] + struct Foo { + a: u32, + b: [u8; 2], + c: i64, + } + + assert_eq!(span_of!(Foo, a), 0..4); + assert_eq!(span_of!(Foo, b), 4..6); + assert_eq!(span_of!(Foo, c), 6..6 + 8); + } + + #[test] + fn span_forms() { + #[repr(C)] + struct Florp { + a: u32, + } + + #[repr(C)] + struct Blarg { + x: u64, + y: [u8; 56], + z: Florp, + egg: [[u8; 4]; 5], + } + + // Love me some brute force + assert_eq!(0..8, span_of!(Blarg, x)); + assert_eq!(64..68, span_of!(Blarg, z)); + assert_eq!(68..mem::size_of::(), span_of!(Blarg, egg)); + + assert_eq!(8..64, span_of!(Blarg, y..z)); + assert_eq!(0..64, span_of!(Blarg, x..=y)); + } + + #[test] + fn ig_test() { + #[repr(C)] + struct Member { + foo: u32, + } + + #[repr(C)] + struct Test { + x: u64, + y: [u8; 56], + z: Member, + egg: [[u8; 4]; 4], + } + + assert_eq!(span_of!(Test, ..x), 0..0); + assert_eq!(span_of!(Test, ..=x), 0..8); + assert_eq!(span_of!(Test, ..y), 0..8); + assert_eq!(span_of!(Test, ..=y), 0..64); + assert_eq!(span_of!(Test, ..z), 0..64); + assert_eq!(span_of!(Test, ..=z), 0..68); + assert_eq!(span_of!(Test, ..egg), 0..68); + assert_eq!(span_of!(Test, ..=egg), 0..84); + assert_eq!(span_of!(Test, ..), 0..mem::size_of::()); + assert_eq!( + span_of!(Test, x..), + offset_of!(Test, x)..mem::size_of::() + ); + assert_eq!( + span_of!(Test, y..), + offset_of!(Test, y)..mem::size_of::() + ); + + assert_eq!( + span_of!(Test, z..), + offset_of!(Test, z)..mem::size_of::() + ); + assert_eq!( + span_of!(Test, egg..), + offset_of!(Test, egg)..mem::size_of::() + ); + assert_eq!( + span_of!(Test, x..y), + offset_of!(Test, x)..offset_of!(Test, y) + ); + assert_eq!( + span_of!(Test, x..=y), + offset_of!(Test, x)..offset_of!(Test, y) + mem::size_of::<[u8; 56]>() + ); + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/.cargo-checksum.json b/third_party/cargo/vendor/metal-0.13.1/.cargo-checksum.json new file mode 100644 index 0000000..cd7cfad --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"a0784f38460a934e9f25dea556eed763f01aedcfdc17dfbf8fe5a32e0eef3a2e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0621878e61f0d0fda054bcbe02df75192c28bde1ecc8289cbd86aeba2dd72720","README.md":"4142280fb79a5646fa21e3092c4a118d9a38e77b1f2f64446f82049e064bdc09","bors.toml":"06ccf7395c5f6b9a0549ccb499b7e3d1b0a984d43a54861e82ca3c22c9d7e1ca","examples/argument-buffer/main.rs":"815c8a2f5f5f5551556b25c12ecca067e0e9e61559887ea55f6be37a97edcb83","examples/bind/main.rs":"08c3f486b38f1615f5353681d7dd7c3d13f67eaf5d81d84f8f575c0f19e0b88f","examples/caps/main.rs":"ad3390a5e44cdabe0419021f201b360090ca93769fb5566c8605d80609cc62f8","examples/compute/compute-argument-buffer.metal":"6530bbd6a0101d9db2893805436f5dc877959e81ea97a27014c0fc52fc9fa77b","examples/compute/compute-argument-buffer.rs":"ad7a157e6307544fe702eaebe6425e58bd1aa74c7845ca4f71f65adc4f453b64","examples/compute/default.metallib":"0f8579c77cf5d5f35023f1922b672081a23d625f199b0be0a68f81a0bfa95384","examples/compute/embedded-lib.rs":"1ab2031c37f59342774f6e9ba63809f1a0de991298fb3a709bd03054e4767085","examples/compute/main.rs":"ce9fb57e8d40bf3882f1be30f753ea00dc52e0261be1072e657e435047862e8a","examples/compute/shaders.metal":"f2b15551bb5247b88a3029c3d8ef37c6fa04a4a6cca9f90f069894ed6822b4bf","examples/library/main.rs":"7a976d0963c521690830f8a8642cb0fe8aa4a7ffba263119d26ed7f81f13adee","examples/reflection/main.rs":"3b9caa8a5fbc37e4bd94ea0eb7fdba71fd552c532d5b8dddd050427c8833acfc","examples/window/default.metallib":"f43d32e42cb6cbd50a5364dfb11ff17fda4b5cf2046e371d2e3ddc1d2008bb9e","examples/window/main.rs":"b91e8743b6aa25ffa40e1caff874cda5e5a1096002da225a19604707a71f4d37","examples/window/shaders.metal":"4c7ea146229caeb0df1d4feea13b927d27c1a6fe8fd0245ce84bf1975772434a","src/argument.rs":"b8b16aa374481ff415714d4bbbfc4b72a828a01f941f5a471cf61be84998abe5","src/buffer.rs":"63abe11180daff420cd93c5e1e4b23698c292f21ebfb161df3c4be44052be5ae","src/capturemanager.rs":"986f88aa497e344381b83a98d0927d0298a1d1e04fdd688330d960c1d1290c9e","src/commandbuffer.rs":"7d863679ab853ddd0baef3aba2585fae05693ce40a48acc15e21f2b0100777b4","src/commandqueue.rs":"f8aee21c3e7c68b66a12a2863312870fd8328e62ff11e9a5b317aee0b8b0cbce","src/constants.rs":"91c2271722b07e98a39ba71ef6c6bcf8a049f578e5c817a24b6d5919f052a48e","src/depthstencil.rs":"ed0ea2a22a44c947b42fc89744ba7201f11bc1945838db784f1f227f62bcb729","src/device.rs":"dc48e59361605bca5af1a668ec67d14344f372d3f6f5343c0ef37ab3497f9c7b","src/drawable.rs":"1b2d6288b13b5d688430b6321fbbcf314e95c92468a514f5c02c6481dc1caf05","src/encoder.rs":"4b0b261ce37a4598c3ef953ee63af6f047713fbb106978ed15328ef335390ad8","src/heap.rs":"75049467abad6292af6b0898e3d00feca424b13898dab7169f15cfccfa86f4fd","src/lib.rs":"b96f6d8b132cb1f631cab3143c008b4649726b0a42b46b53b9329e62b789bb54","src/library.rs":"50c97deb97fb0d2cee1364c7b1dd7f82eb90e9679a586ca09c6b74c1849748a8","src/pipeline/compute.rs":"ae67d1bceccd501f93da1b8f948bba468d0521cccdf3406e742baba9691db05d","src/pipeline/mod.rs":"4f9679202950b1ae95c8d97072c69139908f8104631a8933f19117365b3d16e6","src/pipeline/render.rs":"665ef126282751e3b1ae933054ac5df02c9c48022c030f8b45ee01f7288299f1","src/renderpass.rs":"f105a54184f794766d96e5af01b2707c9ac9a6570dc8778722c56900c11b4fe4","src/resource.rs":"31d7c809965bf11919270a45b40adcc08e52b6f63651a8f001abc01a4991d8a9","src/sampler.rs":"20efa4e9603fc725268038eaaded6ffa2e0e773d24ea0b0832a22153721cecf9","src/texture.rs":"ed59aade1377c984b2889eb5680182553eeb54b4e72714c87c43984c2c95abea","src/types.rs":"b55b6f9508d82df30ac2d5032498724704738977d66c6939c937708e2af4c503","src/vertexdescriptor.rs":"79dc44e8f1ee87510bef1fe157b16edce9ccbcf2635c3d36cd860bad92f164c2"},"package":"7de9c2b83c946ab01c9942928388f911d93486b97636d9927541345905fea65d"} \ No newline at end of file diff --git a/third_party/cargo/vendor/metal-0.13.1/BUILD b/third_party/cargo/vendor/metal-0.13.1/BUILD new file mode 100644 index 0000000..cd6158f --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/BUILD @@ -0,0 +1,62 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "MIT OR Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "argument-buffer" with type "example" omitted +# Unsupported target "bind" with type "example" omitted +# Unsupported target "caps" with type "example" omitted +# Unsupported target "compute" with type "example" omitted +# Unsupported target "compute-argument-buffer" with type "example" omitted +# Unsupported target "embedded-lib" with type "example" omitted +# Unsupported target "library" with type "example" omitted + +rust_library( + name = "metal", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/bitflags-1.2.1:bitflags", + "//third_party/cargo/vendor/block-0.1.6:block", + "//third_party/cargo/vendor/cocoa-0.18.5:cocoa", + "//third_party/cargo/vendor/core-graphics-0.17.3:core_graphics", + "//third_party/cargo/vendor/foreign-types-0.3.2:foreign_types", + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/log-0.4.8:log", + "//third_party/cargo/vendor/objc-0.2.7:objc", + "//third_party/cargo/vendor/objc-foundation-0.1.1:objc_foundation", + "//third_party/cargo/vendor/objc_id-0.1.1:objc_id", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.13.1", + crate_features = [ + "default", + ], +) + +# Unsupported target "reflection" with type "example" omitted +# Unsupported target "window" with type "example" omitted diff --git a/third_party/cargo/vendor/metal-0.13.1/Cargo.toml b/third_party/cargo/vendor/metal-0.13.1/Cargo.toml new file mode 100644 index 0000000..7eb2691 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/Cargo.toml @@ -0,0 +1,94 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "metal" +version = "0.13.1" +authors = ["GFX Developers"] +description = "Rust bindings for Metal" +homepage = "https://github.com/gfx-rs/metal-rs" +documentation = "https://docs.rs/crate/metal" +readme = "README.md" +keywords = ["metal", "graphics", "bindings"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/gfx-rs/metal-rs" +[package.metadata.docs.rs] +default-target = "x86_64-apple-darwin" + +[[example]] +name = "window" + +[[example]] +name = "library" + +[[example]] +name = "reflection" + +[[example]] +name = "caps" + +[[example]] +name = "argument-buffer" + +[[example]] +name = "compute" +path = "examples/compute/main.rs" + +[[example]] +name = "embedded-lib" +path = "examples/compute/embedded-lib.rs" + +[[example]] +name = "compute-argument-buffer" +path = "examples/compute/compute-argument-buffer.rs" + +[[example]] +name = "bind" +[dependencies.bitflags] +version = "1" + +[dependencies.block] +version = "0.1.5" + +[dependencies.cocoa] +version = "0.18" + +[dependencies.core-graphics] +version = "0.17" + +[dependencies.foreign-types] +version = "0.3" + +[dependencies.libc] +version = "0.2" + +[dependencies.log] +version = "0.4" + +[dependencies.objc] +version = "0.2.3" +features = ["objc_exception"] + +[dependencies.objc-foundation] +version = "0.1" + +[dependencies.objc_id] +version = "0.1" +[dev-dependencies.sema] +version = "0.1.4" + +[dev-dependencies.winit] +version = "0.17" + +[features] +default = [] +private = [] diff --git a/third_party/cargo/vendor/metal-0.13.1/LICENSE-APACHE b/third_party/cargo/vendor/metal-0.13.1/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/metal-0.13.1/LICENSE-MIT b/third_party/cargo/vendor/metal-0.13.1/LICENSE-MIT new file mode 100644 index 0000000..25597d5 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2010 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/metal-0.13.1/README.md b/third_party/cargo/vendor/metal-0.13.1/README.md new file mode 100644 index 0000000..87a1e6b --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/README.md @@ -0,0 +1,19 @@ +# metal-rs +[![Build Status](https://travis-ci.org/gfx-rs/metal-rs.svg?branch=master)](https://travis-ci.org/gfx-rs/metal-rs) + +Unsafe Rust bindings for the Metal 3D Graphics API. + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/metal-0.13.1/bors.toml b/third_party/cargo/vendor/metal-0.13.1/bors.toml new file mode 100644 index 0000000..55c1d96 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/bors.toml @@ -0,0 +1,8 @@ +status = [ "continuous-integration/travis-ci/push" ] + +# Based on , +# we can expect a build to spend four hours in Travis CI's queue. +# +# This gives the build five hours to run, with four hours to sit +# and one hour to actually work. +timeout-sec = 18000 diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/argument-buffer/main.rs b/third_party/cargo/vendor/metal-0.13.1/examples/argument-buffer/main.rs new file mode 100644 index 0000000..675c9e5 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/argument-buffer/main.rs @@ -0,0 +1,45 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate metal; +extern crate cocoa; +#[macro_use] extern crate objc; +extern crate objc_id; +extern crate objc_foundation; + +use metal::*; + +use cocoa::foundation::NSAutoreleasePool; + +fn main() { + let pool = unsafe { NSAutoreleasePool::new(cocoa::base::nil) }; + + let device = Device::system_default(); + + let desc1 = ArgumentDescriptor::new(); + desc1.set_data_type(MTLDataType::Texture); + let desc2 = ArgumentDescriptor::new(); + desc2.set_data_type(MTLDataType::Sampler); + desc2.set_index(1); + + let encoder = device.new_argument_encoder(&Array::from_slice(&[desc1, desc2])); + println!("{:?}", encoder); + + let buffer = device.new_buffer(encoder.encoded_length(), MTLResourceOptions::empty()); + encoder.set_argument_buffer(&buffer, 0); + + let sampler = { + let descriptor = SamplerDescriptor::new(); + device.new_sampler(&descriptor) + }; + encoder.set_sampler_state(&sampler, 1); + println!("{:?}", sampler); + + unsafe { + msg_send![pool, release]; + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/bind/main.rs b/third_party/cargo/vendor/metal-0.13.1/examples/bind/main.rs new file mode 100644 index 0000000..901098a --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/bind/main.rs @@ -0,0 +1,45 @@ +// Copyright 2018 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate metal; +extern crate cocoa; +#[macro_use] extern crate objc; +extern crate objc_id; +extern crate objc_foundation; + +use metal::*; + +use cocoa::foundation::NSAutoreleasePool; + +fn main() { + let pool = unsafe { NSAutoreleasePool::new(cocoa::base::nil) }; + + let device = Device::system_default(); + + let buffer = device.new_buffer(4, MTLResourceOptions::empty()); + let sampler = { + let descriptor = SamplerDescriptor::new(); + device.new_sampler(&descriptor) + }; + + let queue = device.new_command_queue(); + let cmd_buf = queue.new_command_buffer(); + + let encoder = cmd_buf.new_compute_command_encoder(); + + encoder.set_buffers(2, &[Some(&buffer), None], &[4, 0]); + encoder.set_sampler_states(1, &[Some(&sampler), None]); + + encoder.end_encoding(); + cmd_buf.commit(); + + println!("Everything is bound"); + + unsafe { + msg_send![pool, release]; + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/caps/main.rs b/third_party/cargo/vendor/metal-0.13.1/examples/caps/main.rs new file mode 100644 index 0000000..452610c --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/caps/main.rs @@ -0,0 +1,28 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate metal; + +use metal::*; + +fn main() { + let device = Device::system_default(); + + #[cfg(feature = "private")] + { + println!("Vendor: {:?}", unsafe { device.vendor() }); + println!("Family: {:?}", unsafe { device.family_name() }); + } + println!("Max threads per threadgroup: {:?}", device.max_threads_per_threadgroup()); + #[cfg(target_os = "macos")] + { + println!("Integrated GPU: {:?}", device.is_low_power()); + println!("Headless: {:?}", device.is_headless()); + println!("D24S8: {:?}", device.d24_s8_supported()); + } + println!("Indirect argument buffer: {:?}", device.argument_buffers_support()); +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/compute/compute-argument-buffer.metal b/third_party/cargo/vendor/metal-0.13.1/examples/compute/compute-argument-buffer.metal new file mode 100644 index 0000000..1dcc79d --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/compute/compute-argument-buffer.metal @@ -0,0 +1,14 @@ +#include + +using namespace metal; + +struct SumInput { + device uint *data; + volatile device atomic_uint *sum; +}; + +kernel void sum(device SumInput& input [[ buffer(0) ]], + uint gid [[ thread_position_in_grid ]]) +{ + atomic_fetch_add_explicit(input.sum, input.data[gid], memory_order_relaxed); +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/compute/compute-argument-buffer.rs b/third_party/cargo/vendor/metal-0.13.1/examples/compute/compute-argument-buffer.rs new file mode 100644 index 0000000..10589fd --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/compute/compute-argument-buffer.rs @@ -0,0 +1,101 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate metal; +extern crate cocoa; +#[macro_use] extern crate objc; +extern crate objc_id; +extern crate objc_foundation; + +use metal::*; + +use cocoa::foundation::NSAutoreleasePool; + +use std::mem; + +static LIBRARY_SRC: &str = include_str!("compute-argument-buffer.metal"); + +fn main() { + let pool = unsafe { NSAutoreleasePool::new(cocoa::base::nil) }; + let device = Device::system_default(); + let command_queue = device.new_command_queue(); + + let data = [ + 1u32, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, + ]; + + let buffer = device.new_buffer_with_data( + unsafe { mem::transmute(data.as_ptr()) }, + (data.len() * mem::size_of::()) as u64, + MTLResourceOptions::CPUCacheModeDefaultCache); + + let sum = { + let data = [0u32]; + device.new_buffer_with_data( + unsafe { mem::transmute(data.as_ptr()) }, + (data.len() * mem::size_of::()) as u64, + MTLResourceOptions::CPUCacheModeDefaultCache) + }; + + let command_buffer = command_queue.new_command_buffer(); + let encoder = command_buffer.new_compute_command_encoder(); + + let library = device.new_library_with_source(LIBRARY_SRC, &CompileOptions::new()).unwrap(); + let kernel = library.get_function("sum", None).unwrap(); + + let argument_encoder = kernel.new_argument_encoder(0); + let arg_buffer = device.new_buffer( + argument_encoder.encoded_length(), + MTLResourceOptions::empty()); + argument_encoder.set_argument_buffer(&arg_buffer, 0); + argument_encoder.set_buffer(&buffer, 0, 0); + argument_encoder.set_buffer(&sum, 0, 1); + + let pipeline_state_descriptor = ComputePipelineDescriptor::new(); + pipeline_state_descriptor.set_compute_function(Some(&kernel)); + + let pipeline_state = device + .new_compute_pipeline_state_with_function( + pipeline_state_descriptor.compute_function().unwrap(), + ).unwrap(); + + encoder.set_compute_pipeline_state(&pipeline_state); + encoder.set_buffer(0, Some(&arg_buffer), 0); + + encoder.use_resource(&buffer, MTLResourceUsage::Read); + encoder.use_resource(&sum, MTLResourceUsage::Write); + + let width = 16; + + let thread_group_count = MTLSize { + width, + height: 1, + depth: 1 + }; + + let thread_group_size = MTLSize { + width: (data.len() as u64 + width) / width, + height: 1, + depth: 1 + }; + + encoder.dispatch_thread_groups(thread_group_count, thread_group_size); + encoder.end_encoding(); + command_buffer.commit(); + command_buffer.wait_until_completed(); + + let ptr = sum.contents() as *mut u32; + + unsafe { + assert_eq!(465, *ptr); + msg_send![pool, release]; + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/compute/default.metallib b/third_party/cargo/vendor/metal-0.13.1/examples/compute/default.metallib new file mode 100644 index 0000000..d93aa04 Binary files /dev/null and b/third_party/cargo/vendor/metal-0.13.1/examples/compute/default.metallib differ diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/compute/embedded-lib.rs b/third_party/cargo/vendor/metal-0.13.1/examples/compute/embedded-lib.rs new file mode 100644 index 0000000..ce93e69 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/compute/embedded-lib.rs @@ -0,0 +1,32 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate metal; +extern crate cocoa; +#[macro_use] extern crate objc; + +use metal::*; + +use cocoa::foundation::NSAutoreleasePool; + +fn main() { + let library_data = include_bytes!("default.metallib"); + + let pool = unsafe { NSAutoreleasePool::new(cocoa::base::nil) }; + let device = Device::system_default(); + + let library = device.new_library_with_data(&library_data[..]).unwrap(); + let kernel = library.get_function("sum", None).unwrap(); + + println!("Function name: {}", kernel.name()); + println!("Function type: {:?}", kernel.function_type()); + println!("OK"); + + unsafe { + msg_send![pool, release] + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/compute/main.rs b/third_party/cargo/vendor/metal-0.13.1/examples/compute/main.rs new file mode 100644 index 0000000..c2c9ae1 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/compute/main.rs @@ -0,0 +1,91 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate metal; +extern crate cocoa; +#[macro_use] extern crate objc; +extern crate objc_id; +extern crate objc_foundation; + +use metal::*; + +use cocoa::foundation::NSAutoreleasePool; + +use std::mem; + +fn main() { + let pool = unsafe { NSAutoreleasePool::new(cocoa::base::nil) }; + let device = Device::system_default(); + let command_queue = device.new_command_queue(); + + let data = [ + 1u32, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, + ]; + + let buffer = device.new_buffer_with_data( + unsafe { mem::transmute(data.as_ptr()) }, + (data.len() * mem::size_of::()) as u64, + MTLResourceOptions::CPUCacheModeDefaultCache); + + let sum = { + let data = [0u32]; + device.new_buffer_with_data( + unsafe { mem::transmute(data.as_ptr()) }, + (data.len() * mem::size_of::()) as u64, + MTLResourceOptions::CPUCacheModeDefaultCache) + }; + + + let command_buffer = command_queue.new_command_buffer(); + let encoder = command_buffer.new_compute_command_encoder(); + + + let library = device.new_library_with_file("examples/compute/default.metallib").unwrap(); + let kernel = library.get_function("sum", None).unwrap(); + + let pipeline_state_descriptor = ComputePipelineDescriptor::new(); + pipeline_state_descriptor.set_compute_function(Some(&kernel)); + + let pipeline_state = device + .new_compute_pipeline_state_with_function( + pipeline_state_descriptor.compute_function().unwrap() + ).unwrap(); + + encoder.set_compute_pipeline_state(&pipeline_state); + encoder.set_buffer(0, Some(&buffer), 0); + encoder.set_buffer(1, Some(&sum), 0); + + let width = 16; + + let thread_group_count = MTLSize { + width, + height: 1, + depth: 1 + }; + + let thread_group_size = MTLSize { + width: (data.len() as u64 + width) / width, + height: 1, + depth: 1 + }; + + encoder.dispatch_thread_groups(thread_group_count, thread_group_size); + encoder.end_encoding(); + command_buffer.commit(); + command_buffer.wait_until_completed(); + + let ptr = sum.contents() as *mut u32; + + unsafe { + assert_eq!(465, *ptr); + msg_send![pool, release]; + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/compute/shaders.metal b/third_party/cargo/vendor/metal-0.13.1/examples/compute/shaders.metal new file mode 100644 index 0000000..51363a1 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/compute/shaders.metal @@ -0,0 +1,10 @@ +#include + +using namespace metal; + +kernel void sum(device uint *data [[ buffer(0) ]], + volatile device atomic_uint *sum [[ buffer(1) ]], + uint gid [[ thread_position_in_grid ]]) +{ + atomic_fetch_add_explicit(sum, data[gid], memory_order_relaxed); +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/library/main.rs b/third_party/cargo/vendor/metal-0.13.1/examples/library/main.rs new file mode 100644 index 0000000..6d14b68 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/library/main.rs @@ -0,0 +1,19 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate metal; + +use metal::*; + +const PROGRAM: &'static str = ""; + +fn main() { + let device = Device::system_default(); + + let options = CompileOptions::new(); + let _library = device.new_library_with_source(PROGRAM, &options); +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/reflection/main.rs b/third_party/cargo/vendor/metal-0.13.1/examples/reflection/main.rs new file mode 100644 index 0000000..705577f --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/reflection/main.rs @@ -0,0 +1,79 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate metal; +extern crate cocoa; +#[macro_use] extern crate objc; + +use metal::*; + +use cocoa::foundation::NSAutoreleasePool; + +const PROGRAM: &'static str = " + #include \n\ + + using namespace metal;\n\ + + typedef struct {\n\ + float2 position;\n\ + float3 color;\n\ + } vertex_t;\n\ + + struct ColorInOut {\n\ + float4 position [[position]];\n\ + float4 color;\n\ + };\n\ + + vertex ColorInOut vs(device vertex_t* vertex_array [[ buffer(0) ]],\n\ + unsigned int vid [[ vertex_id ]])\n\ + {\n\ + ColorInOut out;\n\ + + out.position = float4(float2(vertex_array[vid].position), 0.0, 1.0);\n\ + out.color = float4(float3(vertex_array[vid].color), 1.0);\n\ + + return out;\n\ + }\n\ + + fragment float4 ps(ColorInOut in [[stage_in]])\n\ + {\n\ + return in.color;\n\ + };\n\ +"; + +fn main() { + let pool = unsafe { NSAutoreleasePool::new(cocoa::base::nil) }; + + let device = Device::system_default(); + + let options = CompileOptions::new(); + let library = device.new_library_with_source(PROGRAM, &options).unwrap(); + let (vs, ps) = (library.get_function("vs", None).unwrap(), library.get_function("ps", None).unwrap()); + + let vertex_desc = VertexDescriptor::new(); + + let desc = RenderPipelineDescriptor::new(); + desc.set_vertex_function(Some(&vs)); + desc.set_fragment_function(Some(&ps)); + desc.set_vertex_descriptor(Some(vertex_desc)); + + println!("{:?}", desc); + + #[cfg(features = "private")] + let _reflection = unsafe { RenderPipelineReflection::new( + desc.serialize_vertex_data(), + desc.serialize_fragment_data(), + vertex_desc.serialize_descriptor(), + &device, + 0x8, + 0x0 + ) }; + + unsafe { + msg_send![pool, release]; + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/window/default.metallib b/third_party/cargo/vendor/metal-0.13.1/examples/window/default.metallib new file mode 100644 index 0000000..731a3ab Binary files /dev/null and b/third_party/cargo/vendor/metal-0.13.1/examples/window/default.metallib differ diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/window/main.rs b/third_party/cargo/vendor/metal-0.13.1/examples/window/main.rs new file mode 100644 index 0000000..c63fede --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/window/main.rs @@ -0,0 +1,158 @@ +// Copyright 2016 metal-rs developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate cocoa; +extern crate core_graphics; +extern crate metal; +extern crate winit; +#[macro_use] extern crate objc; +extern crate objc_foundation; +extern crate block; +extern crate sema; + +use cocoa::base::id as cocoa_id; +use cocoa::foundation::{NSRange, NSAutoreleasePool}; +use cocoa::appkit::{NSWindow, NSView}; +use core_graphics::geometry::CGSize; + +use objc::runtime::YES; + +use metal::*; + +use winit::os::macos::WindowExt; + +use std::mem; + + +fn prepare_pipeline_state<'a>(device: &DeviceRef, library: &LibraryRef) -> RenderPipelineState { + let vert = library.get_function("triangle_vertex", None).unwrap(); + let frag = library.get_function("triangle_fragment", None).unwrap(); + + let pipeline_state_descriptor = RenderPipelineDescriptor::new(); + pipeline_state_descriptor.set_vertex_function(Some(&vert)); + pipeline_state_descriptor.set_fragment_function(Some(&frag)); + pipeline_state_descriptor.color_attachments().object_at(0).unwrap().set_pixel_format(MTLPixelFormat::BGRA8Unorm); + + device.new_render_pipeline_state(&pipeline_state_descriptor).unwrap() +} + +fn prepare_render_pass_descriptor(descriptor: &RenderPassDescriptorRef, texture: &TextureRef) { + //descriptor.color_attachments().set_object_at(0, MTLRenderPassColorAttachmentDescriptor::alloc()); + //let color_attachment: MTLRenderPassColorAttachmentDescriptor = unsafe { msg_send![descriptor.color_attachments().0, _descriptorAtIndex:0] };//descriptor.color_attachments().object_at(0); + let color_attachment = descriptor.color_attachments().object_at(0).unwrap(); + + color_attachment.set_texture(Some(texture)); + color_attachment.set_load_action(MTLLoadAction::Clear); + color_attachment.set_clear_color(MTLClearColor::new(0.5, 0.2, 0.2, 1.0)); + color_attachment.set_store_action(MTLStoreAction::Store); +} + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + let glutin_window = winit::WindowBuilder::new() + .with_dimensions((800, 600).into()) + .with_title("Metal".to_string()) + .build(&events_loop).unwrap(); + + let window: cocoa_id = unsafe { mem::transmute(glutin_window.get_nswindow()) }; + let device = Device::system_default(); + + let layer = CoreAnimationLayer::new(); + layer.set_device(&device); + layer.set_pixel_format(MTLPixelFormat::BGRA8Unorm); + layer.set_presents_with_transaction(false); + + unsafe { + let view = window.contentView(); + view.setWantsBestResolutionOpenGLSurface_(YES); + view.setWantsLayer(YES); + view.setLayer(mem::transmute(layer.as_ref())); + } + + let draw_size = glutin_window.get_inner_size().unwrap(); + layer.set_drawable_size(CGSize::new(draw_size.width as f64, draw_size.height as f64)); + + let library = device.new_library_with_file("examples/window/default.metallib").unwrap(); + let pipeline_state = prepare_pipeline_state(&device, &library); + let command_queue = device.new_command_queue(); + //let nc: () = msg_send![command_queue.0, setExecutionEnabled:true]; + + let vbuf = { + let vertex_data = [ + 0.0f32, 0.5, 1.0, 0.0, 0.0, + -0.5, -0.5, 0.0, 1.0, 0.0, + 0.5, 0.5, 0.0, 0.0, 1.0, + ]; + + device.new_buffer_with_data( + unsafe { mem::transmute(vertex_data.as_ptr()) }, + (vertex_data.len() * mem::size_of::()) as u64, + MTLResourceOptions::CPUCacheModeDefaultCache) + }; + + let mut pool = unsafe { NSAutoreleasePool::new(cocoa::base::nil) }; + let mut r = 0.0f32; + let mut running = true; + + while running { + events_loop.poll_events(|event| { + match event { + winit::Event::WindowEvent{ event: winit::WindowEvent::CloseRequested, .. } => running = false, + _ => () + } + }); + + if let Some(drawable) = layer.next_drawable() { + let render_pass_descriptor = RenderPassDescriptor::new(); + let _a = prepare_render_pass_descriptor(&render_pass_descriptor, drawable.texture()); + + let command_buffer = command_queue.new_command_buffer(); + let parallel_encoder = command_buffer.new_parallel_render_command_encoder(&render_pass_descriptor); + let encoder = parallel_encoder.render_command_encoder(); + encoder.set_render_pipeline_state(&pipeline_state); + encoder.set_vertex_buffer(0, Some(&vbuf), 0); + encoder.draw_primitives(MTLPrimitiveType::Triangle, 0, 3); + encoder.end_encoding(); + parallel_encoder.end_encoding(); + + render_pass_descriptor.color_attachments().object_at(0).unwrap().set_load_action(MTLLoadAction::DontCare); + + let parallel_encoder = command_buffer.new_parallel_render_command_encoder(&render_pass_descriptor); + let encoder = parallel_encoder.render_command_encoder(); + use std::mem; + let p = vbuf.contents(); + let vertex_data: &[u8; 60] = unsafe { mem::transmute(&[ + 0.0f32, 0.5, 1.0, 0.0-r, 0.0, + -0.5, -0.5, 0.0, 1.0-r, 0.0, + 0.5, 0.5, 0.0, 0.0, 1.0+r, + ]) }; + use std::ptr; + + unsafe { + ptr::copy(vertex_data.as_ptr(), p as *mut u8, (vertex_data.len() * mem::size_of::()) as usize); + } + vbuf.did_modify_range(NSRange::new(0 as u64, (vertex_data.len() * mem::size_of::()) as u64)); + + + encoder.set_render_pipeline_state(&pipeline_state); + encoder.set_vertex_buffer(0, Some(&vbuf), 0); + encoder.draw_primitives(MTLPrimitiveType::Triangle, 0, 3); + encoder.end_encoding(); + parallel_encoder.end_encoding(); + + command_buffer.present_drawable(&drawable); + command_buffer.commit(); + + r += 0.01f32; + //let _: () = msg_send![command_queue.0, _submitAvailableCommandBuffers]; + unsafe { + msg_send![pool, release]; + pool = NSAutoreleasePool::new(cocoa::base::nil); + } + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/examples/window/shaders.metal b/third_party/cargo/vendor/metal-0.13.1/examples/window/shaders.metal new file mode 100644 index 0000000..db1cc02 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/examples/window/shaders.metal @@ -0,0 +1,31 @@ +#include + +using namespace metal; + +typedef struct { + float2 position; + float3 color; +} vertex_t; + +struct ColorInOut { + float4 position [[position]]; + float4 color; +}; + +// vertex shader function +vertex ColorInOut default_fragment(device vertex_t* vertex_array [[ buffer(0) ]], + unsigned int vid [[ vertex_id ]]) +{ + ColorInOut out; + + out.position = float4(float2(vertex_array[vid].position), 0.0, 1.0); + out.color = float4(float3(vertex_array[vid].color), 1.0); + + return out; +} + +// fragment shader function +fragment float4 default_vertex(ColorInOut in [[stage_in]]) +{ + return in.color; +}; diff --git a/third_party/cargo/vendor/metal-0.13.1/src/argument.rs b/third_party/cargo/vendor/metal-0.13.1/src/argument.rs new file mode 100644 index 0000000..a8eda98 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/argument.rs @@ -0,0 +1,377 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use ::{Array, MTLTextureType}; + +use cocoa::foundation::NSUInteger; +use objc::runtime::{YES, NO}; +use objc_foundation::{NSString, INSString}; + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Copy, Clone, Debug)] +pub enum MTLDataType { + None = 0, + + Struct = 1, + Array = 2, + + Float = 3, + Float2 = 4, + Float3 = 5, + Float4 = 6, + + Float2x2 = 7, + Float2x3 = 8, + Float2x4 = 9, + + Float3x2 = 10, + Float3x3 = 11, + Float3x4 = 12, + + Float4x2 = 13, + Float4x3 = 14, + Float4x4 = 15, + + Half = 16, + Half2 = 17, + Half3 = 18, + Half4 = 19, + + Half2x2 = 20, + Half2x3 = 21, + Half2x4 = 22, + + Half3x2 = 23, + Half3x3 = 24, + Half3x4 = 25, + + Half4x2 = 26, + Half4x3 = 27, + Half4x4 = 28, + + Int = 29, + Int2 = 30, + Int3 = 31, + Int4 = 32, + + UInt = 33, + UInt2 = 34, + UInt3 = 35, + UInt4 = 36, + + Short = 37, + Short2 = 38, + Short3 = 39, + Short4 = 40, + + UShort = 41, + UShort2 = 42, + UShort3 = 43, + UShort4 = 44, + + Char = 45, + Char2 = 46, + Char3 = 47, + Char4 = 48, + + UChar = 49, + UChar2 = 50, + UChar3 = 51, + UChar4 = 52, + + Bool = 53, + Bool2 = 54, + Bool3 = 55, + Bool4 = 56, + + Texture = 58, + Sampler = 59, + Pointer = 60, + R8Unorm = 62, + R8Snorm = 63, + R16Unorm = 64, + R16Snorm = 65, + RG8Unorm = 66, + RG8Snorm = 67, + RG16Unorm = 68, + RG16Snorm = 69, + RGBA8Unorm = 70, + RGBA8Unorm_sRGB = 71, + RGBA8Snorm = 72, + RGBA16Unorm = 73, + RGBA16Snorm = 74, + RGB10A2Unorm = 75, + RG11B10Float = 76, + RGB9E5Float = 77, +} + +#[repr(u32)] +#[allow(non_camel_case_types)] +pub enum MTLArgumentType { + Buffer = 0, + ThreadgroupMemory = 1, + Texture = 2, + Sampler = 3, + ImageblockData = 16, + Imageblock = 17, +} + +#[repr(u32)] +#[allow(non_camel_case_types)] +pub enum MTLArgumentAccess { + ReadOnly = 0, + ReadWrite = 1, + WriteOnly = 2, +} + +pub enum MTLStructMember {} + +foreign_obj_type! { + type CType = MTLStructMember; + pub struct StructMember; + pub struct StructMemberRef; +} + +impl StructMemberRef { + pub fn name(&self) -> &str { + unsafe { + let name: &NSString = msg_send![self, name]; + name.as_str() + } + } + + pub fn offset(&self) -> NSUInteger { + unsafe { + msg_send![self, offset] + } + } + + pub fn data_type(&self) -> MTLDataType { + unsafe { + msg_send![self, dataType] + } + } + + pub fn struct_type(&self) -> MTLStructType { + unsafe { + msg_send![self, structType] + } + } + + pub fn array_type(&self) -> MTLArrayType { + unsafe { + msg_send![self, arrayType] + } + } +} + +pub enum MTLStructType {} + +foreign_obj_type! { + type CType = MTLStructType; + pub struct StructType; + pub struct StructTypeRef; +} + +impl StructTypeRef { + pub fn members(&self) -> &Array { + unsafe { + msg_send![self, members] + } + } + + pub fn member_from_name(&self, name: &str) -> Option<&StructMemberRef> { + let nsname = NSString::from_str(name); + + unsafe { + msg_send![self, memberByName:nsname] + } + } +} + +pub enum MTLArrayType {} + +foreign_obj_type! { + type CType = MTLArrayType; + pub struct ArrayType; + pub struct ArrayTypeRef; +} + +impl ArrayTypeRef { + pub fn array_length(&self) -> NSUInteger { + unsafe { + msg_send![self, arrayLength] + } + } + + pub fn stride(&self) -> NSUInteger { + unsafe { + msg_send![self, stride] + } + } + + pub fn element_type(&self) -> MTLDataType { + unsafe { + msg_send![self, elementType] + } + } + + pub fn element_struct_type(&self) -> MTLStructType { + unsafe { + msg_send![self, elementStructType] + } + } + + pub fn element_array_type(&self) -> MTLArrayType { + unsafe { + msg_send![self, elementArrayType] + } + } +} + +pub enum MTLArgument {} + +foreign_obj_type! { + type CType = MTLArgument; + pub struct Argument; + pub struct ArgumentRef; +} + +impl ArgumentRef { + pub fn name(&self) -> &str { + unsafe { + let name: &NSString = msg_send![self, name]; + name.as_str() + } + } + + pub fn type_(&self) -> MTLArgumentType { + unsafe { + msg_send![self, type] + } + } + + pub fn access(&self) -> MTLArgumentAccess { + unsafe { + msg_send![self, access] + } + } + + pub fn index(&self) -> NSUInteger { + unsafe { + msg_send![self, index] + } + } + + pub fn is_active(&self) -> bool { + unsafe { + match msg_send![self, isActive] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn buffer_alignment(&self) -> NSUInteger { + unsafe { + msg_send![self, bufferAlignment] + } + } + + pub fn buffer_data_size(&self) -> NSUInteger { + unsafe { + msg_send![self, bufferDataSize] + } + } + + pub fn buffer_data_type(&self) -> MTLDataType { + unsafe { + msg_send![self, bufferDataType] + } + } + + pub fn buffer_struct_type(&self) -> &StructTypeRef { + unsafe { + msg_send![self, bufferStructType] + } + } + + pub fn threadgroup_memory_alignment(&self) -> NSUInteger { + unsafe { + msg_send![self, threadgroupMemoryAlignment] + } + } + + pub fn threadgroup_memory_data_size(&self) -> NSUInteger { + unsafe { + msg_send![self, threadgroupMemoryDataSize] + } + } + + pub fn texture_type(&self) -> MTLTextureType { + unsafe { + msg_send![self, textureType] + } + } + + pub fn texture_data_type(&self) -> MTLDataType { + unsafe { + msg_send![self, textureDataType] + } + } +} + +pub enum MTLArgumentDescriptor {} + +foreign_obj_type! { + type CType = MTLArgumentDescriptor; + pub struct ArgumentDescriptor; + pub struct ArgumentDescriptorRef; +} + +impl ArgumentDescriptor { + pub fn new<'a>() -> &'a ArgumentDescriptorRef { + unsafe { + let class = class!(MTLArgumentDescriptor); + msg_send![class, argumentDescriptor] + } + } +} + +impl ArgumentDescriptorRef { + pub fn set_data_type(&self, ty: MTLDataType) { + unsafe { + msg_send![self, setDataType:ty] + } + } + + pub fn set_index(&self, index: NSUInteger) { + unsafe { + msg_send![self, setIndex:index] + } + } + + pub fn set_access(&self, access: MTLArgumentAccess) { + unsafe { + msg_send![self, setAccess:access] + } + } + + pub fn set_array_length(&self, length: NSUInteger) { + unsafe { + msg_send![self, setArrayLength:length] + } + } + + pub fn set_texture_type(&self, ty: MTLTextureType) { + unsafe { + msg_send![self, setTextureType:ty] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/buffer.rs b/third_party/cargo/vendor/metal-0.13.1/src/buffer.rs new file mode 100644 index 0000000..ad7c0d0 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/buffer.rs @@ -0,0 +1,50 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use cocoa::foundation::NSRange; + +pub enum MTLBuffer {} + +foreign_obj_type! { + type CType = MTLBuffer; + pub struct Buffer; + pub struct BufferRef; + type ParentType = ResourceRef; +} + + +impl BufferRef { + pub fn length(&self) -> u64 { + unsafe { + msg_send![self, length] + } + } + + pub fn contents(&self) -> *mut libc::c_void { + unsafe { + msg_send![self, contents] + } + } + + pub fn did_modify_range(&self, range: NSRange) { + unsafe { + msg_send![self, didModifyRange:range] + } + } + + pub fn new_texture_from_contents(&self, descriptor: &TextureDescriptorRef, offset: u64, stride: u64) -> Texture { + unsafe { + msg_send![self, + newTextureWithDescriptor:descriptor + offset:offset + bytesPerRow:stride + ] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/capturemanager.rs b/third_party/cargo/vendor/metal-0.13.1/src/capturemanager.rs new file mode 100644 index 0000000..bf8b6f2 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/capturemanager.rs @@ -0,0 +1,105 @@ +// Copyright 2018 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use objc_foundation::{INSString, NSString}; + +pub enum MTLCaptureScope {} + +foreign_obj_type! { + type CType = MTLCaptureScope; + pub struct CaptureScope; + pub struct CaptureScopeRef; +} + +impl CaptureScopeRef { + pub fn begin_scope(&self) { + unsafe { + msg_send![self, beginScope]; + } + } + + pub fn end_scope(&self) { + unsafe { + msg_send![self, endScope]; + } + } + + pub fn label(&self) -> &str { + unsafe { + let label: &NSString = msg_send![self, label]; + label.as_str() + } + } +} + +pub enum MTLCaptureManager {} + +foreign_obj_type! { + type CType = MTLCaptureManager; + pub struct CaptureManager; + pub struct CaptureManagerRef; +} + +impl CaptureManager { + pub fn shared<'a>() -> &'a CaptureManagerRef { + unsafe { + let class = class!(MTLCaptureManager); + msg_send![class, sharedCaptureManager] + } + } +} + +impl CaptureManagerRef { + pub fn new_capture_scope_with_device(&self, device: &DeviceRef) -> &CaptureScopeRef { + unsafe { msg_send![self, newCaptureScopeWithDevice: device] } + } + + pub fn new_capture_scope_with_command_queue( + &self, + command_queue: &CommandQueueRef, + ) -> &CaptureScopeRef { + unsafe { msg_send![self, newCaptureScopeWithCommandQueue: command_queue] } + } + + pub fn default_capture_scope(&self) -> Option<&CaptureScopeRef> { + unsafe { msg_send![self, defaultCaptureScope] } + } + + pub fn set_default_capture_scope(&self, scope: &CaptureScopeRef) { + unsafe { msg_send![self, setDefaultCaptureScope:scope] } + } + + pub fn start_capture_with_device(&self, device: &DeviceRef) { + unsafe { + msg_send![self, startCaptureWithDevice: device]; + } + } + + pub fn start_capture_with_command_queue(&self, command_queue: &CommandQueueRef) { + unsafe { + msg_send![self, startCaptureWithCommandQueue: command_queue]; + } + } + + pub fn start_capture_with_scope(&self, scope: &CaptureScopeRef) { + unsafe { + msg_send![self, startCaptureWithScope: scope]; + } + } + + pub fn stop_capture(&self) { + unsafe { + msg_send![self, stopCapture]; + } + } + + pub fn is_capturing(&self) -> bool { + unsafe { msg_send![self, isCapturing] } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/commandbuffer.rs b/third_party/cargo/vendor/metal-0.13.1/src/commandbuffer.rs new file mode 100644 index 0000000..c933f04 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/commandbuffer.rs @@ -0,0 +1,123 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use objc_foundation::{NSString, INSString}; +use block::Block; + +#[repr(u32)] +#[allow(non_camel_case_types)] +pub enum MTLCommandBufferStatus { + NotEnqueued = 0, + Enqueued = 1, + Committed = 2, + Scheduled = 3, + Completed = 4, + Error = 5, +} + +#[repr(u32)] +#[allow(non_camel_case_types)] +pub enum MTLCommandBufferError { + None = 0, + Internal = 1, + Timeout = 2, + PageFault = 3, + Blacklisted = 4, + NotPermitted = 7, + OutOfMemory = 8, + InvalidResource = 9, + Memoryless = 10, + DeviceRemoved = 11, +} + +type _MTLCommandBufferHandler = Block<(MTLCommandBuffer), ()>; + +pub enum MTLCommandBuffer {} + +foreign_obj_type! { + type CType = MTLCommandBuffer; + pub struct CommandBuffer; + pub struct CommandBufferRef; +} + +impl CommandBufferRef { + pub fn label(&self) -> &str { + unsafe { + let label: &NSString = msg_send![self, label]; + label.as_str() + } + } + + pub fn set_label(&self, label: &str) { + unsafe { + let nslabel = NSString::from_str(label); + msg_send![self, setLabel:nslabel]; + } + } + + pub fn enqueue(&self) { + unsafe { + msg_send![self, enqueue] + } + } + + pub fn commit(&self) { + unsafe { + msg_send![self, commit] + } + } + + pub fn status(&self) -> MTLCommandBufferStatus { + unsafe { + msg_send![self, status] + } + } + + pub fn present_drawable(&self, drawable: &DrawableRef) { + unsafe { + msg_send![self, presentDrawable:drawable] + } + } + + pub fn wait_until_completed(&self) { + unsafe { + msg_send![self, waitUntilCompleted] + } + } + + pub fn wait_until_scheduled(&self) { + unsafe { + msg_send![self, waitUntilScheduled] + } + } + + pub fn new_blit_command_encoder(&self) -> &BlitCommandEncoderRef { + unsafe { + msg_send![self, blitCommandEncoder] + } + } + + pub fn new_compute_command_encoder(&self) -> &ComputeCommandEncoderRef { + unsafe { + msg_send![self, computeCommandEncoder] + } + } + + pub fn new_render_command_encoder(&self, descriptor: &RenderPassDescriptorRef) -> &RenderCommandEncoderRef { + unsafe { + msg_send![self, renderCommandEncoderWithDescriptor:descriptor] + } + } + + pub fn new_parallel_render_command_encoder(&self, descriptor: &RenderPassDescriptorRef) -> &ParallelRenderCommandEncoderRef { + unsafe { + msg_send![self, parallelRenderCommandEncoderWithDescriptor:descriptor] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/commandqueue.rs b/third_party/cargo/vendor/metal-0.13.1/src/commandqueue.rs new file mode 100644 index 0000000..1dd7c24 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/commandqueue.rs @@ -0,0 +1,52 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use objc_foundation::{NSString, INSString}; + +pub enum MTLCommandQueue {} + +foreign_obj_type! { + type CType = MTLCommandQueue; + pub struct CommandQueue; + pub struct CommandQueueRef; +} + +impl CommandQueueRef { + pub fn label(&self) -> &str { + unsafe { + let label: &NSString = msg_send![self, label]; + label.as_str() + } + } + + pub fn set_label(&self, label: &str) { + unsafe { + let nslabel = NSString::from_str(label); + msg_send![self, setLabel:nslabel] + } + } + + pub fn new_command_buffer(&self) -> &CommandBufferRef { + unsafe { + msg_send![self, commandBuffer] + } + } + + pub fn new_command_buffer_with_unretained_references(&self) -> &CommandBufferRef { + unsafe { + msg_send![self, commandBufferWithUnretainedReferences] + } + } + + pub fn device(&self) -> &DeviceRef { + unsafe { + msg_send![self, device] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/constants.rs b/third_party/cargo/vendor/metal-0.13.1/src/constants.rs new file mode 100644 index 0000000..935c9cb --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/constants.rs @@ -0,0 +1,137 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum MTLPixelFormat { + Invalid = 0, + A8Unorm = 1, + R8Unorm = 10, + R8Unorm_sRGB = 11, + R8Snorm = 12, + R8Uint = 13, + R8Sint = 14, + R16Unorm = 20, + R16Snorm = 22, + R16Uint = 23, + R16Sint = 24, + R16Float = 25, + RG8Unorm = 30, + RG8Unorm_sRGB = 31, + RG8Snorm = 32, + RG8Uint = 33, + RG8Sint = 34, + B5G6R5Unorm = 40, + A1BGR5Unorm = 41, + ABGR4Unorm = 42, + BGR5A1Unorm = 43, + R32Uint = 53, + R32Sint = 54, + R32Float = 55, + RG16Unorm = 60, + RG16Snorm = 62, + RG16Uint = 63, + RG16Sint = 64, + RG16Float = 65, + RGBA8Unorm = 70, + RGBA8Unorm_sRGB = 71, + RGBA8Snorm = 72, + RGBA8Uint = 73, + RGBA8Sint = 74, + BGRA8Unorm = 80, + BGRA8Unorm_sRGB = 81, + RGB10A2Unorm = 90, + RGB10A2Uint = 91, + RG11B10Float = 92, + RGB9E5Float = 93, + BGR10A2Unorm = 94, + RG32Uint = 103, + RG32Sint = 104, + RG32Float = 105, + RGBA16Unorm = 110, + RGBA16Snorm = 112, + RGBA16Uint = 113, + RGBA16Sint = 114, + RGBA16Float = 115, + RGBA32Uint = 123, + RGBA32Sint = 124, + RGBA32Float = 125, + BC1_RGBA = 130, + BC1_RGBA_sRGB = 131, + BC2_RGBA = 132, + BC2_RGBA_sRGB = 133, + BC3_RGBA = 134, + BC3_RGBA_sRGB = 135, + BC4_RUnorm = 140, + BC4_RSnorm = 141, + BC5_RGUnorm = 142, + BC5_RGSnorm = 143, + BC6H_RGBFloat = 150, + BC6H_RGBUfloat = 151, + BC7_RGBAUnorm = 152, + BC7_RGBAUnorm_sRGB = 153, + PVRTC_RGB_2BPP = 160, + PVRTC_RGB_2BPP_sRGB = 161, + PVRTC_RGB_4BPP = 162, + PVRTC_RGB_4BPP_sRGB = 163, + PVRTC_RGBA_2BPP = 164, + PVRTC_RGBA_2BPP_sRGB = 165, + PVRTC_RGBA_4BPP = 166, + PVRTC_RGBA_4BPP_sRGB = 167, + EAC_R11Unorm = 170, + EAC_R11Snorm = 172, + EAC_RG11Unorm = 174, + EAC_RG11Snorm = 176, + EAC_RGBA8 = 178, + EAC_RGBA8_sRGB = 179, + ETC2_RGB8 = 180, + ETC2_RGB8_sRGB = 181, + ETC2_RGB8A1 = 182, + ETC2_RGB8A1_sRGB = 183, + ASTC_4x4_sRGB = 186, + ASTC_5x4_sRGB = 187, + ASTC_5x5_sRGB = 188, + ASTC_6x5_sRGB = 189, + ASTC_6x6_sRGB = 190, + ASTC_8x5_sRGB = 192, + ASTC_8x6_sRGB = 193, + ASTC_8x8_sRGB = 194, + ASTC_10x5_sRGB = 195, + ASTC_10x6_sRGB = 196, + ASTC_10x8_sRGB = 197, + ASTC_10x10_sRGB = 198, + ASTC_12x10_sRGB = 199, + ASTC_12x12_sRGB = 200, + ASTC_4x4_LDR = 204, + ASTC_5x4_LDR = 205, + ASTC_5x5_LDR = 206, + ASTC_6x5_LDR = 207, + ASTC_6x6_LDR = 208, + ASTC_8x5_LDR = 210, + ASTC_8x6_LDR = 211, + ASTC_8x8_LDR = 212, + ASTC_10x5_LDR = 213, + ASTC_10x6_LDR = 214, + ASTC_10x8_LDR = 215, + ASTC_10x10_LDR = 216, + ASTC_12x10_LDR = 217, + ASTC_12x12_LDR = 218, + GBGR422 = 240, + BGRG422 = 241, + Depth16Unorm = 250, + Depth32Float = 252, + Stencil8 = 253, + Depth24Unorm_Stencil8 = 255, + Depth32Float_Stencil8 = 260, + X32_Stencil8 = 261, + X24_Stencil8 = 262, + BGRA10_XR = 552, + BGRA10_XR_SRGB = 553, + BGR10_XR = 554, + BGR10_XR_SRGB = 555, +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/depthstencil.rs b/third_party/cargo/vendor/metal-0.13.1/src/depthstencil.rs new file mode 100644 index 0000000..42144b8 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/depthstencil.rs @@ -0,0 +1,203 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use objc::runtime::{YES, NO}; + +#[repr(u64)] +pub enum MTLCompareFunction { + Never = 0, + Less = 1, + Equal = 2, + LessEqual = 3, + Greater = 4, + NotEqual = 5, + GreaterEqual = 6, + Always = 7, +} + +#[repr(u64)] +pub enum MTLStencilOperation { + Keep = 0, + Zero = 1, + Replace = 2, + IncrementClamp = 3, + DecrementClamp = 4, + Invert = 5, + IncrementWrap = 6, + DecrementWrap = 7, +} + +pub enum MTLStencilDescriptor {} + +foreign_obj_type! { + type CType = MTLStencilDescriptor; + pub struct StencilDescriptor; + pub struct StencilDescriptorRef; +} + +impl StencilDescriptor { + pub fn new() -> Self { + unsafe { + let class = class!(MTLStencilDescriptor); + msg_send![class, new] + } + } +} + +impl StencilDescriptorRef { + pub fn stencil_compare_function(&self) -> MTLCompareFunction { + unsafe { + msg_send![self, stencilCompareFunction] + } + } + + pub fn set_stencil_compare_function(&self, func: MTLCompareFunction) { + unsafe { + msg_send![self, setStencilCompareFunction:func] + } + } + + pub fn stencil_failure_operation(&self) -> MTLStencilOperation { + unsafe { + msg_send![self, stencilFailureOperation] + } + } + + pub fn set_stencil_failure_operation(&self, operation: MTLStencilOperation) { + unsafe { + msg_send![self, setStencilFailureOperation:operation] + } + } + + pub fn depth_failure_operation(&self) -> MTLStencilOperation { + unsafe { + msg_send![self, depthFailureOperation] + } + } + + pub fn set_depth_failure_operation(&self, operation: MTLStencilOperation) { + unsafe { + msg_send![self, setDepthFailureOperation:operation] + } + } + + pub fn depth_stencil_pass_operation(&self) -> MTLStencilOperation { + unsafe { + msg_send![self, depthStencilPassOperation] + } + } + + pub fn set_depth_stencil_pass_operation(&self, operation: MTLStencilOperation) { + unsafe { + msg_send![self, setDepthStencilPassOperation:operation] + } + } + + pub fn read_mask(&self) -> u32 { + unsafe { + msg_send![self, readMask] + } + } + + pub fn set_read_mask(&self, mask: u32) { + unsafe { + msg_send![self, setReadMask:mask] + } + } + + pub fn write_mask(&self) -> u32 { + unsafe { + msg_send![self, writeMask] + } + } + + pub fn set_write_mask(&self, mask: u32) { + unsafe { + msg_send![self, setWriteMask:mask] + } + } +} + +pub enum MTLDepthStencilDescriptor {} + +foreign_obj_type! { + type CType = MTLDepthStencilDescriptor; + pub struct DepthStencilDescriptor; + pub struct DepthStencilDescriptorRef; +} + + +impl DepthStencilDescriptor { + pub fn new() -> Self { + unsafe { + let class = class!(MTLDepthStencilDescriptor); + msg_send![class, new] + } + } +} + +impl DepthStencilDescriptorRef { + pub fn depth_compare_function(&self) -> MTLCompareFunction { + unsafe { + msg_send![self, depthCompareFunction] + } + } + + pub fn set_depth_compare_function(&self, func: MTLCompareFunction) { + unsafe { + msg_send![self, setDepthCompareFunction:func] + } + } + + pub fn depth_write_enabled(&self) -> bool { + unsafe { + match msg_send![self, isDepthWriteEnabled] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn set_depth_write_enabled(&self, enabled: bool) { + unsafe { + msg_send![self, setDepthWriteEnabled:enabled] + } + } + + pub fn front_face_stencil(&self) -> Option<&StencilDescriptorRef> { + unsafe { + msg_send![self, frontFaceStencil] + } + } + + pub fn set_front_face_stencil(&self, descriptor: Option<&StencilDescriptorRef>) { + unsafe { + msg_send![self, setFrontFaceStencil:descriptor] + } + } + + pub fn back_face_stencil(&self) -> Option<&StencilDescriptorRef> { + unsafe { + msg_send![self, backFaceStencil] + } + } + + pub fn set_back_face_stencil(&self, descriptor: Option<&StencilDescriptorRef>) { + unsafe { + msg_send![self, setBackFaceStencil:descriptor] + } + } +} + +pub enum MTLDepthStencilState {} + +foreign_obj_type! { + type CType = MTLDepthStencilState; + pub struct DepthStencilState; + pub struct DepthStencilStateRef; +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/device.rs b/third_party/cargo/vendor/metal-0.13.1/src/device.rs new file mode 100644 index 0000000..ea4a426 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/device.rs @@ -0,0 +1,1651 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use block::{Block, ConcreteBlock}; +use cocoa::base::id; +use cocoa::foundation::{NSUInteger}; +use foreign_types::ForeignType; +use libc; +use objc::runtime::{Object, BOOL, YES, NO}; +use objc_foundation::{NSString, INSString}; + +use super::*; + +use std::ffi::CStr; +use std::path::Path; +use std::ptr; + + +#[allow(non_camel_case_types)] +#[repr(u64)] +#[derive(Copy, Clone, Debug)] +pub enum MTLFeatureSet { + iOS_GPUFamily1_v1 = 0, + iOS_GPUFamily2_v1 = 1, + iOS_GPUFamily1_v2 = 2, + iOS_GPUFamily2_v2 = 3, + iOS_GPUFamily3_v1 = 4, + iOS_GPUFamily1_v3 = 5, + iOS_GPUFamily2_v3 = 6, + iOS_GPUFamily3_v2 = 7, + iOS_GPUFamily1_v4 = 8, + iOS_GPUFamily2_v4 = 9, + iOS_GPUFamily3_v3 = 10, + iOS_GPUFamily4_v1 = 11, + // iOS_GPUFamily1_v5 = 12, TODO: Uncomment when feature tables updated + // iOS_GPUFamily2_v5 = 13, + // iOS_GPUFamily3_v4 = 14, + // iOS_GPUFamily4_v2 = 15, + + tvOS_GPUFamily1_v1 = 30000, + tvOS_GPUFamily1_v2 = 30001, + tvOS_GPUFamily1_v3 = 30002, + tvOS_GPUFamily2_v1 = 30003, + // tvOS_GPUFamily1_v4 = 30004, + // tvOS_GPUFamily2_v2 = 30005, + + macOS_GPUFamily1_v1 = 10000, + macOS_GPUFamily1_v2 = 10001, + //macOS_ReadWriteTextureTier2 = 10002, TODO: Uncomment when feature tables updated + macOS_GPUFamily1_v3 = 10003, + //macOS_GPUFamily1_v4 = 10004, + //macOS_GPUFamily2_v1 = 10005, +} + +bitflags! { + pub struct PixelFormatCapabilities: u32 { + const Filter = 1 << 0; + const Write = 1 << 1; + const Color = 1 << 2; + const Blend = 1 << 3; + const Msaa = 1 << 4; + const Resolve = 1 << 5; + } +} + +#[allow(non_camel_case_types)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +enum OS { + iOS, tvOS, macOS +} + +const KB: u32 = 1024; +const MB: u32 = 1024 * KB; +const GB: u32 = 1024 * MB; + +impl MTLFeatureSet { + fn os(&self) -> OS { + let value = *self as u64; + if value < 10_000 { + OS::iOS + } else if value < 20_000 { + OS::macOS + } else if value >= 30_000 || value < 40_000 { + OS::tvOS + } else { + unreachable!() + } + } + + fn os_version(&self) -> u32 { + use MTLFeatureSet::*; + match self { + iOS_GPUFamily1_v1 | iOS_GPUFamily2_v1 => 8, + iOS_GPUFamily1_v2 | iOS_GPUFamily2_v2 | iOS_GPUFamily3_v1 => 9, + iOS_GPUFamily1_v3 | iOS_GPUFamily2_v3 | iOS_GPUFamily3_v2 => 10, + iOS_GPUFamily1_v4 | iOS_GPUFamily2_v4 | iOS_GPUFamily3_v3 | iOS_GPUFamily4_v1 => 11, + tvOS_GPUFamily1_v1 => 9, + tvOS_GPUFamily1_v2 => 10, + tvOS_GPUFamily1_v3 | tvOS_GPUFamily2_v1 => 11, + macOS_GPUFamily1_v1 | macOS_GPUFamily1_v2 | macOS_GPUFamily1_v3 => 10, + } + } + + fn gpu_family(&self) -> u32 { + use MTLFeatureSet::*; + match self { + iOS_GPUFamily1_v1 + | iOS_GPUFamily1_v2 + | iOS_GPUFamily1_v3 + | iOS_GPUFamily1_v4 + | tvOS_GPUFamily1_v1 + | tvOS_GPUFamily1_v2 + | tvOS_GPUFamily1_v3 + | macOS_GPUFamily1_v1 + | macOS_GPUFamily1_v2 + | macOS_GPUFamily1_v3 => 1, + iOS_GPUFamily2_v1 + | iOS_GPUFamily2_v2 + | iOS_GPUFamily2_v3 + | iOS_GPUFamily2_v4 + | tvOS_GPUFamily2_v1 => 2, + iOS_GPUFamily3_v1 + | iOS_GPUFamily3_v2 + | iOS_GPUFamily3_v3 => 3, + iOS_GPUFamily4_v1 => 4, + } + } + + fn version(&self) -> u32 { + use MTLFeatureSet::*; + match self { + iOS_GPUFamily1_v1 + | iOS_GPUFamily2_v1 + | iOS_GPUFamily3_v1 + | iOS_GPUFamily4_v1 + | macOS_GPUFamily1_v1 + | tvOS_GPUFamily1_v1 + | tvOS_GPUFamily2_v1 => 1, + iOS_GPUFamily1_v2 + | iOS_GPUFamily2_v2 + | iOS_GPUFamily3_v2 + | macOS_GPUFamily1_v2 + | tvOS_GPUFamily1_v2 => 2, + iOS_GPUFamily1_v3 + | iOS_GPUFamily2_v3 + | iOS_GPUFamily3_v3 + | macOS_GPUFamily1_v3 + | tvOS_GPUFamily1_v3 => 3, + iOS_GPUFamily1_v4 + | iOS_GPUFamily2_v4 => 4, + } + } + + pub fn supports_metal_kit(&self) -> bool { + true + } + + pub fn supports_metal_performance_shaders(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 2, + OS::tvOS => true, + OS::macOS => self.version() >= 3, + } + } + + pub fn supports_programmable_blending(&self) -> bool { + self.os() != OS::macOS + } + + pub fn supports_pvrtc_pixel_formats(&self) -> bool { + self.os() != OS::macOS + } + + pub fn supports_eac_etc_pixel_formats(&self) -> bool { + self.os() != OS::macOS + } + + pub fn supports_astc_pixel_formats(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 2, + OS::tvOS => true, + OS::macOS => false, + } + } + + pub fn supports_linear_textures(&self) -> bool { + self.os() != OS::macOS || self.version() >= 3 + } + + pub fn supports_bc_pixel_formats(&self) -> bool { + self.os() == OS::macOS + } + + pub fn supports_msaa_depth_resolve(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => false, + } + } + + pub fn supports_counting_occlusion_query(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => true, + } + } + + pub fn supports_base_vertex_instance_drawing(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => true, + } + } + + pub fn supports_indirect_buffers(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => true, + } + } + + pub fn supports_cube_map_texture_arrays(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 4, + OS::tvOS => false, + OS::macOS => true, + } + } + + pub fn supports_texture_barriers(&self) -> bool { + self.os() == OS::macOS + } + + pub fn supports_layered_rendering(&self) -> bool { + self.os() == OS::macOS + } + + pub fn supports_tessellation(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3 && self.os_version() >= 10, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_resource_heaps(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => self.version() >= 3, + } + } + + pub fn supports_memoryless_render_targets(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => false, + } + } + + pub fn supports_function_specialization(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_function_buffer_read_writes(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3 && self.os_version() >= 10, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_function_texture_read_writes(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 4, + OS::tvOS => false, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_array_of_textures(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3 && self.os_version() >= 10, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => self.version() >= 3, + } + } + + pub fn supports_array_of_samplers(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3 && self.os_version() >= 11, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_stencil_texture_views(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_depth_16_pixel_format(&self) -> bool { + self.os() == OS::macOS && self.version() >= 2 + } + + pub fn supports_extended_range_pixel_formats(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3 && self.os_version() >= 10, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => false, + } + } + + pub fn supports_wide_color_pixel_format(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 11, + OS::tvOS => self.os_version() >= 11, + OS::macOS => self.version() >= 3, + } + } + + pub fn supports_combined_msaa_store_and_resolve_action(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3 && self.os_version() >= 10, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_deferred_store_action(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_msaa_blits(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => true, + } + } + + pub fn supports_srgb_writes(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 3 || (self.gpu_family() >= 2 && self.version() >= 3), + OS::tvOS => self.os_version() >= 10, + OS::macOS => false, + } + } + + pub fn supports_16_bit_unsigned_integer_coordinates(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_extract_insert_and_reverse_bits(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_simd_barrier(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => false, + } + } + + pub fn supports_sampler_max_anisotropy(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => false, + } + } + + pub fn supports_sampler_lod_clamp(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 10, + OS::tvOS => self.os_version() >= 10, + OS::macOS => false, + } + } + + pub fn supports_border_color(&self) -> bool { + self.os() == OS::macOS && self.version() >= 2 + } + + pub fn supports_dual_source_blending(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 11, + OS::tvOS => self.os_version() >= 11, + OS::macOS => self.version() >= 2, + } + } + + pub fn supports_argument_buffers(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 11, + OS::tvOS => self.os_version() >= 11, + OS::macOS => self.version() >= 3, + } + } + + pub fn supports_programmable_sample_positions(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 11, + OS::tvOS => self.os_version() >= 11, + OS::macOS => self.version() >= 3, + } + } + + pub fn supports_uniform_type(&self) -> bool { + match self.os() { + OS::iOS => self.os_version() >= 11, + OS::tvOS => self.os_version() >= 11, + OS::macOS => self.version() >= 3, + } + } + + pub fn supports_imageblocks(&self) -> bool { + self.os() == OS::iOS && self.gpu_family() >= 4 + } + + pub fn supports_tile_shaders(&self) -> bool { + self.os() == OS::iOS && self.gpu_family() >= 4 + } + + pub fn supports_imageblock_sample_coverage_control(&self) -> bool { + self.os() == OS::iOS && self.gpu_family() >= 4 + } + + pub fn supports_threadgroup_sharing(&self) -> bool { + self.os() == OS::iOS && self.gpu_family() >= 4 + } + + pub fn supports_post_depth_coverage(&self) -> bool { + self.os() == OS::iOS && self.gpu_family() >= 4 + } + + pub fn supports_quad_scoped_permute_operations(&self) -> bool { + self.os() == OS::iOS && self.gpu_family() >= 4 + } + + pub fn supports_raster_order_groups(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 4, + OS::tvOS => false, + OS::macOS => self.version() >= 3, + } + } + + pub fn supports_non_uniform_threadgroup_size(&self) -> bool { + match self.os() { + OS::iOS => self.gpu_family() >= 4, + OS::tvOS => false, + OS::macOS => self.version() >= 3, + } + } + + pub fn supports_multiple_viewports(&self) -> bool { + self.os() == OS::macOS && self.version() >= 3 + } + + pub fn supports_device_notifications(&self) -> bool { + self.os() == OS::macOS && self.version() >= 3 + } + + pub fn max_vertex_attributes(&self) -> u32 { + 31 + } + + pub fn max_buffer_argument_entries(&self) -> u32 { + 31 + } + + pub fn max_texture_argument_entries(&self) -> u32 { + if self.os() == OS::macOS { + 128 + } else { + 31 + } + } + + pub fn max_sampler_state_argument_entries(&self) -> u32 { + 16 + } + + pub fn max_threadgroup_memory_argument_entries(&self) -> u32 { + 31 + } + + pub fn max_inlined_constant_data_buffers(&self) -> u32 { + if self.os() == OS::macOS { + 14 + } else { + 31 + } + } + + pub fn max_inline_constant_buffer_length(&self) -> u32 { + 4 * KB + } + + pub fn max_threads_per_threadgroup(&self) -> u32 { + if self.os() == OS::macOS || self.gpu_family() == 4 { + 1024 + } else { + 512 + } + } + + pub fn max_total_threadgroup_memory_allocation(&self) -> u32 { + match (self.os(), self.gpu_family()) { + (OS::iOS, 4) => 32 * KB, + (OS::iOS, 3) => 16 * KB, + (OS::iOS, _) => 16 * KB - 32, + (OS::tvOS, 1) => 16 * KB - 32, + (OS::tvOS, _) => 16 * KB, + (OS::macOS, _) => 32 * KB, + } + } + + pub fn max_total_tile_memory_allocation(&self) -> u32 { + if self.os() == OS::iOS && self.gpu_family() == 4 { + 32 * KB + } else { + 0 + } + } + + pub fn threadgroup_memory_length_alignment(&self) -> u32 { + 16 + } + + pub fn max_constant_buffer_function_memory_allocation(&self) -> Option { + if self.os() == OS::macOS { + Some(64 * KB) + } else { + None + } + } + + pub fn max_fragment_inputs(&self) -> u32 { + if self.os() == OS::macOS { + 32 + } else { + 60 + } + } + + pub fn max_fragment_input_components(&self) -> u32 { + if self.os() == OS::macOS { + 128 + } else { + 60 + } + } + + pub fn max_function_constants(&self) -> u32 { + match self.os() { + OS::iOS if self.os_version() >= 11 => 65536, + OS::tvOS if self.os_version() >= 10 => 65536, + OS::macOS if self.version() >= 2 => 65536, + _ => 0, + } + } + + pub fn max_tessellation_factor(&self) -> u32 { + if self.supports_tessellation() { + match self.os() { + OS::iOS => 16, + OS::tvOS => 16, + OS::macOS => 64, + } + } else { + 0 + } + } + + pub fn max_viewports_and_scissor_rectangles(&self) -> u32 { + if self.supports_multiple_viewports() { + 16 + } else { + 1 + } + } + + pub fn max_raster_order_groups(&self) -> u32 { + if self.supports_raster_order_groups() { + 8 + } else { + 0 + } + } + + pub fn max_buffer_length(&self) -> u32 { + if self.os() == OS::macOS && self.version() >= 2 { + 1 * GB + } else { + 256 * MB + } + } + + pub fn min_buffer_offset_alignment(&self) -> u32 { + if self.os() == OS::macOS { + 256 + } else { + 4 + } + } + + pub fn max_1d_texture_size(&self) -> u32 { + match (self.os(), self.gpu_family()) { + (OS::iOS, 1) | (OS::iOS, 2) => if self.version() <= 2 { 4096 } else { 8192 }, + (OS::tvOS, 1) => 8192, + _ => 16384, + } + } + + pub fn max_2d_texture_size(&self) -> u32 { + match (self.os(), self.gpu_family()) { + (OS::iOS, 1) | (OS::iOS, 2) => if self.version() <= 2 { 4096 } else { 8192 }, + (OS::tvOS, 1) => 8192, + _ => 16384, + } + } + + pub fn max_cube_map_texture_size(&self) -> u32 { + match (self.os(), self.gpu_family()) { + (OS::iOS, 1) | (OS::iOS, 2) => if self.version() <= 2 { 4096 } else { 8192 }, + (OS::tvOS, 1) => 8192, + _ => 16384, + } + } + + pub fn max_3d_texture_size(&self) -> u32 { + 2048 + } + + pub fn max_array_layers(&self) -> u32 { + 2048 + } + + pub fn copy_texture_buffer_alignment(&self) -> u32 { + match (self.os(), self.gpu_family()) { + (OS::iOS, 1) | (OS::iOS, 2) | (OS::tvOS, 1) => 64, + (OS::iOS, _) | (OS::tvOS, _) => 16, + (OS::macOS, _) => 256, + } + } + + /// If this function returns `None` but linear textures are supported, + /// the buffer alignment can be discovered via API query + pub fn new_texture_buffer_alignment(&self) -> Option { + match self.os() { + OS::iOS => if self.os_version() >= 11 { + None + } else if self.gpu_family() == 3 { + Some(16) + } else { + Some(64) + }, + OS::tvOS => if self.os_version() >= 11 { + None + } else { + Some(64) + }, + OS::macOS => None, + } + } + + pub fn max_color_render_targets(&self) -> u32 { + if self.os() == OS::iOS && self.gpu_family() == 1 { + 4 + } else { + 8 + } + } + + pub fn max_point_primitive_size(&self) -> u32 { + 511 + } + + pub fn max_total_color_render_target_size(&self) -> Option { + match (self.os(), self.gpu_family()) { + (OS::iOS, 1) => Some(128), + (OS::iOS, 2) | (OS::iOS, 3) => Some(256), + (OS::iOS, _) => Some(512), + (OS::tvOS, _) => Some(256), + (OS::macOS, _) => None, + } + } + + pub fn max_visibility_query_offset(&self) -> u32 { + 64 * KB - 8 + } + + pub fn a8_unorm_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Filter + } + + pub fn r8_unorm_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::all() + } + + pub fn r8_unorm_srgb_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::empty() + } else if self.supports_srgb_writes() { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn r8_snorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::iOS && self.gpu_family() == 1 { + !PixelFormatCapabilities::Resolve + } else { + PixelFormatCapabilities::all() + } + } + + pub fn r8_uint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn r8_sint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn r16_unorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() != OS::macOS { + !PixelFormatCapabilities::Resolve + } else { + PixelFormatCapabilities::all() + } + } + + pub fn r16_snorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() != OS::macOS { + !PixelFormatCapabilities::Resolve + } else { + PixelFormatCapabilities::all() + } + } + + pub fn r16_uint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn r16_sint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn r16_float_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::all() + } + + pub fn rg8_unorm_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::all() + } + + pub fn rg8_unorm_srgb_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::empty() + } else if self.supports_srgb_writes() { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn rg8_snorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::iOS && self.gpu_family() == 1 { + !PixelFormatCapabilities::Resolve + } else { + PixelFormatCapabilities::all() + } + } + + pub fn rg8_uint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn rg8_sint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn b5_g6_r5_unorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::empty() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn a1_bgr5_unorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::empty() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn abgr4_unorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::empty() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn bgr5_a1_unorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::empty() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn r32_uint_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::iOS && self.os_version() == 8 { + PixelFormatCapabilities::Color + } else if self.os() == OS::macOS { + PixelFormatCapabilities::Color + | PixelFormatCapabilities::Write + | PixelFormatCapabilities::Msaa + } else { + PixelFormatCapabilities::Color | PixelFormatCapabilities::Write + } + } + + pub fn r32_sint_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::iOS && self.os_version() == 8 { + PixelFormatCapabilities::Color + } else if self.os() == OS::macOS { + PixelFormatCapabilities::Color + | PixelFormatCapabilities::Write + | PixelFormatCapabilities::Msaa + } else { + PixelFormatCapabilities::Color | PixelFormatCapabilities::Write + } + } + + pub fn r32_float_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::iOS && self.os_version() == 8 { + PixelFormatCapabilities::Color + | PixelFormatCapabilities::Blend + | PixelFormatCapabilities::Msaa + } else if self.os() == OS::macOS { + PixelFormatCapabilities::all() + } else { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Blend + | PixelFormatCapabilities::Msaa + } + } + + pub fn rg16_unorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Resolve + } + } + + pub fn rg16_snorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Resolve + } + } + + pub fn rg16_uint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn rg16_sint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn rg16_float_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::all() + } + + pub fn rgba8_unorm_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::all() + } + + pub fn rgba8_unorm_srgb_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_srgb_writes() { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn rgba8_snorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::iOS && self.gpu_family() == 1 { + !PixelFormatCapabilities::Resolve + } else { + PixelFormatCapabilities::all() + } + } + + pub fn rgba8_uint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn rgba8_sint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn bgra8_unorm_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::all() + } + + pub fn bgra8_unorm_srgb_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_srgb_writes() { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn rgb10_a2_unorm_capabilities(&self) -> PixelFormatCapabilities { + let supports_writes = match self.os() { + OS::iOS => self.gpu_family() >= 3, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => true, + }; + if supports_writes { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn rgb10_a2_uint_capabilities(&self) -> PixelFormatCapabilities { + let supports_writes = match self.os() { + OS::iOS => self.gpu_family() >= 3, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => true, + }; + if supports_writes { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } else { + PixelFormatCapabilities::Color | PixelFormatCapabilities::Msaa + } + } + + pub fn rg11_b10_float_capabilities(&self) -> PixelFormatCapabilities { + let supports_writes = match self.os() { + OS::iOS => self.gpu_family() >= 3, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => true, + }; + if supports_writes { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn rgb9_e5_float_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::Filter + } else { + let supports_writes = match self.os() { + OS::iOS => self.gpu_family() >= 3, + OS::tvOS => self.gpu_family() >= 2, + OS::macOS => false, + }; + if supports_writes { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Write + } + } + } + + pub fn rg32_uint_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::iOS && self.os_version() == 8 { + PixelFormatCapabilities::Color + } else if self.os() == OS::macOS { + PixelFormatCapabilities::Color + | PixelFormatCapabilities::Write + | PixelFormatCapabilities::Msaa + } else { + PixelFormatCapabilities::Color | PixelFormatCapabilities::Write + } + } + + pub fn rg32_sint_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::iOS && self.os_version() == 8 { + PixelFormatCapabilities::Color + } else if self.os() == OS::macOS { + PixelFormatCapabilities::Color + | PixelFormatCapabilities::Write + | PixelFormatCapabilities::Msaa + } else { + PixelFormatCapabilities::Color | PixelFormatCapabilities::Write + } + } + + pub fn rg32_float_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::all() + } else if self.os() == OS::iOS && self.os_version() == 8 { + PixelFormatCapabilities::Color | PixelFormatCapabilities::Blend + } else { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Blend + } + } + + pub fn rgba16_unorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn rgba16_snorm_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::all() + } else { + !PixelFormatCapabilities::Write + } + } + + pub fn rgba16_uint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn rgba16_sint_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Write + | PixelFormatCapabilities::Color + | PixelFormatCapabilities::Msaa + } + + pub fn rgba16_float_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::all() + } + + pub fn rgba32_uint_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::iOS && self.os_version() == 8 { + PixelFormatCapabilities::Color + } else if self.os() == OS::macOS { + PixelFormatCapabilities::Color + | PixelFormatCapabilities::Write + | PixelFormatCapabilities::Msaa + } else { + PixelFormatCapabilities::Color | PixelFormatCapabilities::Write + } + } + + pub fn rgba32_sint_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::iOS && self.os_version() == 8 { + PixelFormatCapabilities::Color + } else if self.os() == OS::macOS { + PixelFormatCapabilities::Color + | PixelFormatCapabilities::Write + | PixelFormatCapabilities::Msaa + } else { + PixelFormatCapabilities::Color | PixelFormatCapabilities::Write + } + } + + pub fn rgba32_float_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::all() + } else if self.os() == OS::iOS && self.version() == 8 { + PixelFormatCapabilities::Color + } else { + PixelFormatCapabilities::Write | PixelFormatCapabilities::Color + } + } + + pub fn pvrtc_pixel_formats_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_pvrtc_pixel_formats() { + PixelFormatCapabilities::Filter + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn eac_etc_pixel_formats_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_eac_etc_pixel_formats() { + PixelFormatCapabilities::Filter + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn astc_pixel_formats_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_astc_pixel_formats() { + PixelFormatCapabilities::Filter + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn bc_pixel_formats_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_bc_pixel_formats() { + PixelFormatCapabilities::Filter + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn gbgr422_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Filter + } + + pub fn bgrg422_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Filter + } + + pub fn depth16_unorm_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_depth_16_pixel_format() { + PixelFormatCapabilities::Filter + | PixelFormatCapabilities::Msaa + | PixelFormatCapabilities::Resolve + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn depth32_float_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::Filter + | PixelFormatCapabilities::Msaa + | PixelFormatCapabilities::Resolve + } else if self.supports_msaa_depth_resolve() { + PixelFormatCapabilities::Msaa | PixelFormatCapabilities::Resolve + } else { + PixelFormatCapabilities::Msaa + } + } + + pub fn stencil8_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Msaa + } + + pub fn depth24_unorm_stencil8_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::Filter + | PixelFormatCapabilities::Msaa + | PixelFormatCapabilities::Resolve + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn depth32_float_stencil8_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::Filter + | PixelFormatCapabilities::Msaa + | PixelFormatCapabilities::Resolve + } else if self.supports_msaa_depth_resolve() { + PixelFormatCapabilities::Msaa | PixelFormatCapabilities::Resolve + } else { + PixelFormatCapabilities::Msaa + } + } + + pub fn x24_stencil8_capabilities(&self) -> PixelFormatCapabilities { + if self.os() == OS::macOS { + PixelFormatCapabilities::Msaa + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn x32_stencil8_capabilities(&self) -> PixelFormatCapabilities { + PixelFormatCapabilities::Msaa + } + + pub fn bgra10_xr_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_extended_range_pixel_formats() { + PixelFormatCapabilities::all() + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn bgra10_xr_srgb_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_extended_range_pixel_formats() { + PixelFormatCapabilities::all() + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn bgr10_xr_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_extended_range_pixel_formats() { + PixelFormatCapabilities::all() + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn bgr10_xr_srgb_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_extended_range_pixel_formats() { + PixelFormatCapabilities::all() + } else { + PixelFormatCapabilities::empty() + } + } + + pub fn bgr10_a2_unorm_capabilities(&self) -> PixelFormatCapabilities { + if self.supports_wide_color_pixel_format() { + if self.os() == OS::macOS { + !PixelFormatCapabilities::Write + } else { + PixelFormatCapabilities::all() + } + } else { + PixelFormatCapabilities::empty() + } + } +} + +#[allow(non_camel_case_types)] +#[repr(u64)] +#[derive(Copy, Clone, Debug)] +pub enum MTLArgumentBuffersTier { + tier1 = 0, + tier2 = 1, +} + +bitflags! { + struct MTLPipelineOption: NSUInteger { + const ArgumentInfo = 1 << 0; + const BufferTypeInfo = 1 << 1; + } +} + +#[link(name = "Metal", kind = "framework")] +extern { + fn MTLCreateSystemDefaultDevice() -> *mut MTLDevice; + fn MTLCopyAllDevices() -> *mut Object; //TODO: Array +} + +#[allow(non_camel_case_types)] +type dispatch_data_t = id; +#[allow(non_camel_case_types)] +type dispatch_queue_t = id; +#[allow(non_camel_case_types)] +type dispatch_block_t = *const Block<(), ()>; + +#[cfg_attr(any(target_os = "macos", target_os = "ios"), + link(name = "System", kind = "dylib"))] +#[cfg_attr(not(any(target_os = "macos", target_os = "ios")), + link(name = "dispatch", kind = "dylib"))] +#[allow(improper_ctypes)] +extern { + static _dispatch_main_q: dispatch_queue_t; + + fn dispatch_data_create( + buffer: *const libc::c_void, + size: libc::size_t, + queue: dispatch_queue_t, + destructor: dispatch_block_t + ) -> dispatch_data_t; +} + +/*type MTLNewLibraryCompletionHandler = extern fn(library: id, error: id); +type MTLNewRenderPipelineStateCompletionHandler = extern fn(renderPipelineState: id, error: id); +type MTLNewRenderPipelineStateWithReflectionCompletionHandler = extern fn(renderPipelineState: id, reflection: id, error: id); +type MTLNewComputePipelineStateCompletionHandler = extern fn(computePipelineState: id, error: id); +type MTLNewComputePipelineStateWithReflectionCompletionHandler = extern fn(computePipelineState: id, reflection: id, error: id);*/ + +pub enum MTLDevice {} + +foreign_obj_type! { + type CType = MTLDevice; + pub struct Device; + pub struct DeviceRef; +} + +impl Device { + pub fn system_default() -> Self { + unsafe { Device(MTLCreateSystemDefaultDevice()) } + } + + pub fn all() -> Vec { + if cfg!(target_os = "ios") { + vec![Device::system_default()] + } else { + unsafe { + let array = MTLCopyAllDevices(); + let count: NSUInteger = msg_send![array, count]; + (0 .. count) + .map(|i| msg_send![array, objectAtIndex: i]) + .collect() + } + } + } +} + +impl DeviceRef { + pub fn name(&self) -> &str { + unsafe { + let name: &NSString = msg_send![self, name]; + name.as_str() + } + } + + #[cfg(feature = "private")] + pub unsafe fn vendor(&self) -> &str { + let name: &NSString = msg_send![self, vendorName]; + name.as_str() + } + + #[cfg(feature = "private")] + pub unsafe fn family_name(&self) -> &str { + let name: &NSString = msg_send![self, familyName]; + name.as_str() + } + + pub fn registry_id(&self) -> u64 { + unsafe { + msg_send![self, registryID] + } + } + + pub fn max_threads_per_threadgroup(&self) -> MTLSize { + unsafe { + msg_send![self, maxThreadsPerThreadgroup] + } + } + + pub fn is_low_power(&self) -> bool { + unsafe { + match msg_send![self, isLowPower] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn is_headless(&self) -> bool { + unsafe { + match msg_send![self, isHeadless] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn is_removable(&self) -> bool { + unsafe { + match msg_send![self, isRemovable] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn supports_feature_set(&self, feature: MTLFeatureSet) -> bool { + unsafe { + match msg_send![self, supportsFeatureSet:feature] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn supports_sample_count(&self, count: NSUInteger) -> bool { + unsafe { + match msg_send![self, supportsTextureSampleCount:count] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn d24_s8_supported(&self) -> bool { + unsafe { + match msg_send![self, isDepth24Stencil8PixelFormatSupported] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn new_command_queue(&self) -> CommandQueue { + unsafe { + msg_send![self, newCommandQueue] + } + } + + pub fn new_command_queue_with_max_command_buffer_count(&self, count: NSUInteger) -> CommandQueue { + unsafe { + msg_send![self, newCommandQueueWithMaxCommandBufferCount:count] + } + } + + pub fn new_default_library(&self) -> Library { + unsafe { + msg_send![self, newDefaultLibrary] + } + } + + pub fn new_library_with_source(&self, src: &str, options: &CompileOptionsRef) -> Result { + use cocoa::foundation::NSString as cocoa_NSString; + use cocoa::base::nil as cocoa_nil; + + unsafe { + let source = cocoa_NSString::alloc(cocoa_nil).init_str(src); + let mut err: *mut Object = ptr::null_mut(); + let library: *mut MTLLibrary = msg_send![self, newLibraryWithSource:source + options:options + error:&mut err]; + if !err.is_null() { + let desc: *mut Object = msg_send![err, localizedDescription]; + let compile_error: *const libc::c_char = msg_send![desc, UTF8String]; + let message = CStr::from_ptr(compile_error).to_string_lossy().into_owned(); + if library.is_null() { + msg_send![err, release]; + return Err(message); + } else { + warn!("Shader warnings: {}", message); + } + } + + assert!(!library.is_null()); + Ok(Library::from_ptr(library)) + } + } + + pub fn new_library_with_file>(&self, file: P) -> Result { + use cocoa::foundation::NSString as cocoa_NSString; + use cocoa::base::nil as cocoa_nil; + + unsafe { + let filename = cocoa_NSString::alloc(cocoa_nil) + .init_str(file.as_ref().to_string_lossy().as_ref()); + + let library: *mut MTLLibrary = try_objc!{ err => + msg_send![self, newLibraryWithFile:filename + error:&mut err] + }; + + Ok(Library::from_ptr(library)) + } + } + + pub fn new_library_with_data(&self, library_data: &[u8]) -> Result { + unsafe { + let destructor_block = ConcreteBlock::new(|| {}).copy(); + let data = dispatch_data_create( + library_data.as_ptr() as *const libc::c_void, + library_data.len() as libc::size_t, + &_dispatch_main_q as *const _ as dispatch_queue_t, + &*destructor_block.deref() + ); + + let library: *mut MTLLibrary = try_objc! { err => + msg_send![self, newLibraryWithData:data + error:&mut err] + }; + + Ok(Library::from_ptr(library)) + } + } + + pub fn new_render_pipeline_state_with_reflection(&self, descriptor: &RenderPipelineDescriptorRef, reflection: &RenderPipelineReflectionRef) -> Result { + unsafe { + let reflection_options = MTLPipelineOption::ArgumentInfo | MTLPipelineOption::BufferTypeInfo; + + let pipeline_state: *mut MTLRenderPipelineState = try_objc!{ err => + msg_send![self, newRenderPipelineStateWithDescriptor:descriptor + options:reflection_options + reflection:reflection + error:&mut err] + }; + + Ok(RenderPipelineState::from_ptr(pipeline_state)) + } + } + + pub fn new_render_pipeline_state(&self, descriptor: &RenderPipelineDescriptorRef) -> Result { + unsafe { + let pipeline_state: *mut MTLRenderPipelineState = try_objc!{ err => + msg_send![self, newRenderPipelineStateWithDescriptor:descriptor + error:&mut err] + }; + + Ok(RenderPipelineState::from_ptr(pipeline_state)) + } + } + + pub fn new_compute_pipeline_state_with_function(&self, function: &FunctionRef) -> Result { + unsafe { + let pipeline_state: *mut MTLComputePipelineState = try_objc!{ err => + msg_send![self, newComputePipelineStateWithFunction:function + error:&mut err] + }; + + Ok(ComputePipelineState::from_ptr(pipeline_state)) + } + } + + #[cfg(feature = "private")] + pub unsafe fn new_compute_pipeline_state(&self, descriptor: &ComputePipelineDescriptorRef) -> Result { + let pipeline_state: *mut MTLComputePipelineState = try_objc!{ err => + msg_send![self, newComputePipelineStateWithDescriptor:descriptor + error:&mut err] + }; + + Ok(ComputePipelineState::from_ptr(pipeline_state)) + } + + pub fn new_buffer(&self, length: u64, options: MTLResourceOptions) -> Buffer { + unsafe { + msg_send![self, newBufferWithLength:length + options:options] + } + } + + pub fn new_buffer_with_data(&self, bytes: *const libc::c_void, length: NSUInteger, options: MTLResourceOptions) -> Buffer { + unsafe { + msg_send![self, newBufferWithBytes:bytes + length:length + options:options] + } + } + + pub fn new_texture(&self, descriptor: &TextureDescriptorRef) -> Texture { + unsafe { + msg_send![self, newTextureWithDescriptor:descriptor] + } + } + + pub fn new_sampler(&self, descriptor: &SamplerDescriptorRef) -> SamplerState { + unsafe { + msg_send![self, newSamplerStateWithDescriptor:descriptor] + } + } + + pub fn new_depth_stencil_state(&self, descriptor: &DepthStencilDescriptorRef) -> DepthStencilState { + unsafe { + msg_send![self, newDepthStencilStateWithDescriptor:descriptor] + } + } + + pub fn argument_buffers_support(&self) -> Option { + unsafe { + let has_arg_buffers: BOOL = msg_send![self, respondsToSelector: sel!(argumentBuffersSupport)]; + if has_arg_buffers == YES { + Some(msg_send![self, argumentBuffersSupport]) + } else { + None + } + } + } + + pub fn new_argument_encoder(&self, arguments: &ArrayRef) -> ArgumentEncoder { + unsafe { + msg_send![self, newArgumentEncoderWithArguments:arguments] + } + } + + pub fn new_heap(&self, descriptor: &HeapDescriptorRef) -> Heap { + unsafe { + msg_send![self, newHeapWithDescriptor: descriptor] + } + } + + pub fn heap_buffer_size_and_align(&self, length: NSUInteger, options: MTLResourceOptions) -> MTLSizeAndAlign { + unsafe { + msg_send![self, heapBufferSizeAndAlignWithLength: length options: options] + } + } + + pub fn heap_texture_size_and_align(&self, descriptor: &TextureDescriptorRef) -> MTLSizeAndAlign { + unsafe { + msg_send![self, heapTextureSizeAndAlignWithDescriptor: descriptor] + } + } + + pub fn minimum_linear_texture_alignment_for_pixel_format(&self, format: MTLPixelFormat) -> NSUInteger { + unsafe { + msg_send![self, minimumLinearTextureAlignmentForPixelFormat: format] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/drawable.rs b/third_party/cargo/vendor/metal-0.13.1/src/drawable.rs new file mode 100644 index 0000000..eec1936 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/drawable.rs @@ -0,0 +1,23 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +pub enum MTLDrawable {} + +foreign_obj_type! { + type CType = MTLDrawable; + pub struct Drawable; + pub struct DrawableRef; +} + + +impl DrawableRef { + pub fn present(&self) { + unsafe { + msg_send![self, present] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/encoder.rs b/third_party/cargo/vendor/metal-0.13.1/src/encoder.rs new file mode 100644 index 0000000..5ed74da --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/encoder.rs @@ -0,0 +1,936 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use cocoa::foundation::{NSRange, NSUInteger, NSInteger}; +use objc_foundation::{NSString, INSString}; + +use libc; +use std::ops::Range; + + +#[repr(u64)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub enum MTLPrimitiveType { + Point = 0, + Line = 1, + LineStrip = 2, + Triangle = 3, + TriangleStrip = 4, +} + +#[repr(u64)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub enum MTLIndexType { + UInt16 = 0, + UInt32 = 1, +} + +#[repr(u64)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub enum MTLVisibilityResultMode { + Disabled = 0, + Boolean = 1, + Counting = 2, +} + +#[repr(u64)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub enum MTLCullMode { + None = 0, + Front = 1, + Back = 2, +} + +#[repr(u64)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub enum MTLWinding { + Clockwise = 0, + CounterClockwise = 1, +} + +#[repr(u64)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub enum MTLDepthClipMode { + Clip = 0, + Clamp = 1, +} + +#[repr(u64)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub enum MTLTriangleFillMode { + Fill = 0, + Lines = 1, +} + +bitflags! { + #[allow(non_upper_case_globals)] + pub struct MTLBlitOption: NSUInteger { + const DepthFromDepthStencil = 1 << 0; + const StencilFromDepthStencil = 1 << 1; + const RowLinearPVRTC = 1 << 2; + } +} + +#[repr(C)] +#[derive(Copy, Clone, Debug)] +pub struct MTLScissorRect { + pub x: NSUInteger, + pub y: NSUInteger, + pub width: NSUInteger, + pub height: NSUInteger +} + +#[repr(C)] +#[derive(Copy, Clone, Debug)] +pub struct MTLViewport { + pub originX: f64, + pub originY: f64, + pub width: f64, + pub height: f64, + pub znear: f64, + pub zfar: f64, +} + +#[repr(C)] +#[derive(Copy, Clone, Debug)] +pub struct MTLDrawPrimitivesIndirectArguments { + pub vertexCount: u32, + pub instanceCount: u32, + pub vertexStart: u32, + pub baseInstance: u32 +} + +#[repr(C)] +#[derive(Copy, Clone, Debug)] +pub struct MTLDrawIndexedPrimitivesIndirectArguments { + pub indexCount: u32, + pub instanceCount: u32, + pub indexStart: u32, + pub baseVertex: i32, + pub baseInstance: u32 +} + +pub enum MTLCommandEncoder {} + +foreign_obj_type! { + type CType = MTLCommandEncoder; + pub struct CommandEncoder; + pub struct CommandEncoderRef; +} + +impl CommandEncoderRef { + pub fn label(&self) -> &str { + unsafe { + let label: &NSString = msg_send![self, label]; + label.as_str() + } + } + + pub fn set_label(&self, label: &str) { + unsafe { + let nslabel = NSString::from_str(label); + msg_send![self, setLabel:nslabel]; + } + } + + pub fn end_encoding(&self) { + unsafe { + msg_send![self, endEncoding]; + } + } +} + +pub enum MTLParallelRenderCommandEncoder {} + +foreign_obj_type! { + type CType = MTLParallelRenderCommandEncoder; + pub struct ParallelRenderCommandEncoder; + pub struct ParallelRenderCommandEncoderRef; + type ParentType = CommandEncoderRef; +} + + +impl ParallelRenderCommandEncoderRef { + pub fn render_command_encoder(&self) -> &RenderCommandEncoderRef { + unsafe { + msg_send![self, renderCommandEncoder] + } + } +} + +pub enum MTLRenderCommandEncoder {} + +foreign_obj_type! { + type CType = MTLRenderCommandEncoder; + pub struct RenderCommandEncoder; + pub struct RenderCommandEncoderRef; + type ParentType = CommandEncoderRef; +} + +impl RenderCommandEncoderRef { + pub fn set_render_pipeline_state(&self, pipeline_state: &RenderPipelineStateRef) { + unsafe { + msg_send![self, setRenderPipelineState:pipeline_state] + } + } + + pub fn set_viewport(&self, viewport: MTLViewport) { + unsafe { + msg_send![self, setViewport:viewport] + } + } + + pub fn set_front_facing_winding(&self, winding: MTLWinding) { + unsafe { + msg_send![self, setFrontFacingWinding:winding] + } + } + + pub fn set_cull_mode(&self, mode: MTLCullMode) { + unsafe { + msg_send![self, setCullMode:mode] + } + } + + pub fn set_depth_clip_mode(&self, mode: MTLDepthClipMode) { + unsafe { + msg_send![self, setDepthClipMode:mode] + } + } + + pub fn set_depth_bias(&self, bias: f32, scale: f32, clamp: f32) { + unsafe { + msg_send![self, setDepthBias:bias + slopeScale:scale + clamp:clamp] + } + } + + pub fn set_scissor_rect(&self, rect: MTLScissorRect) { + unsafe { + msg_send![self, setScissorRect:rect] + } + } + + pub fn set_triangle_fill_mode(&self, mode: MTLTriangleFillMode) { + unsafe { + msg_send![self, setTriangleFillMode:mode] + } + } + + pub fn set_blend_color(&self, red: f32, green: f32, blue: f32, alpha: f32) { + unsafe { + msg_send![self, setBlendColorRed:red + green:green + blue:blue + alpha:alpha] + } + } + + pub fn set_depth_stencil_state(&self, depth_stencil_state: &DepthStencilStateRef) { + unsafe { + msg_send![self, setDepthStencilState:depth_stencil_state] + } + } + + pub fn set_stencil_reference_value(&self, value: u32) { + unsafe { + msg_send![self, setStencilReferenceValue:value] + } + } + + pub fn set_stencil_front_back_reference_value(&self, front: u32, back: u32) { + unsafe { + msg_send![self, setStencilFrontReferenceValue:front + backReferenceValue:back] + } + } + + //TODO: change argument order + pub fn set_visibility_result_mode(&self, offset: NSUInteger, mode: MTLVisibilityResultMode) { + unsafe { + msg_send![self, setVisibilityResultMode:mode + offset:offset] + } + } + + // Specifying Resources for a Vertex Shader Function + + pub fn set_vertex_bytes(&self, index: NSUInteger, length: NSUInteger, bytes: *const libc::c_void) { + unsafe { + msg_send![self, + setVertexBytes:bytes + length:length + atIndex:index + ] + } + } + + pub fn set_vertex_buffer(&self, index: NSUInteger, buffer: Option<&BufferRef>, offset: NSUInteger) { + unsafe { + msg_send![self, + setVertexBuffer:buffer + offset:offset + atIndex:index + ] + } + } + + pub fn set_vertex_buffers(&self, start_index: NSUInteger, data: &[Option<&BufferRef>], offsets: &[NSUInteger]) { + debug_assert_eq!(offsets.len(), data.len()); + unsafe { + msg_send![self, + setVertexBuffers: data.as_ptr() + offsets: offsets.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_vertex_texture(&self, index: u64, texture: Option<&TextureRef>) { + unsafe { + msg_send![self, + setVertexTexture:texture + atIndex:index + ] + } + } + + pub fn set_vertex_textures(&self, start_index: NSUInteger, data: &[Option<&TextureRef>]) { + unsafe { + msg_send![self, + setVertexTextures: data.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_vertex_sampler_state(&self, index: u64, sampler: Option<&SamplerStateRef>) { + unsafe { + msg_send![self, + setVertexSamplerState:sampler + atIndex:index + ] + } + } + + pub fn set_vertex_sampler_states(&self, start_index: NSUInteger, data: &[Option<&SamplerStateRef>]) { + unsafe { + msg_send![self, + setVertexSamplerStates: data.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_vertex_sampler_state_with_lod( + &self, index: NSUInteger, sampler: Option<&SamplerStateRef>, lod_clamp: Range + ) { + unsafe { + msg_send![self, + setVertexSamplerState:sampler + lodMinClamp:lod_clamp.start + lodMaxClamp:lod_clamp.end + atIndex:index + ] + } + } + + // Specifying Resources for a Fragment Shader Function + + pub fn set_fragment_bytes(&self, index: NSUInteger, length: NSUInteger, bytes: *const libc::c_void) { + unsafe { + msg_send![self, + setFragmentBytes:bytes + length:length + atIndex:index + ] + } + } + + pub fn set_fragment_buffer(&self, index: NSUInteger, buffer: Option<&BufferRef>, offset: NSUInteger) { + unsafe { + msg_send![self, + setFragmentBuffer:buffer + offset:offset + atIndex:index + ] + } + } + + pub fn set_fragment_buffers(&self, start_index: NSUInteger, data: &[Option<&BufferRef>], offsets: &[NSUInteger]) { + debug_assert_eq!(offsets.len(), data.len()); + unsafe { + msg_send![self, + setFragmentBuffers: data.as_ptr() + offsets: offsets.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_fragment_texture(&self, index: NSUInteger, texture: Option<&TextureRef>) { + unsafe { + msg_send![self, + setFragmentTexture:texture + atIndex:index + ] + } + } + + pub fn set_fragment_textures(&self, start_index: NSUInteger, data: &[Option<&TextureRef>]) { + unsafe { + msg_send![self, + setFragmentTextures: data.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_fragment_sampler_state(&self, index: NSUInteger, sampler: Option<&SamplerStateRef>) { + unsafe { + msg_send![self, setFragmentSamplerState:sampler + atIndex:index] + } + } + + pub fn set_fragment_sampler_states(&self, start_index: NSUInteger, data: &[Option<&SamplerStateRef>]) { + unsafe { + msg_send![self, + setFragmentSamplerStates: data.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_fragment_sampler_state_with_lod( + &self, index: NSUInteger, sampler: Option<&SamplerStateRef>, lod_clamp: Range + ) { + unsafe { + msg_send![self, + setFragmentSamplerState:sampler + lodMinClamp:lod_clamp.start + lodMaxClamp:lod_clamp.end + atIndex:index + ] + } + } + + // Drawing Geometric Primitives + + pub fn draw_primitives( + &self, primitive_type: MTLPrimitiveType, vertex_start: NSUInteger, vertex_count: NSUInteger + ) { + unsafe { + msg_send![self, + drawPrimitives: primitive_type + vertexStart: vertex_start + vertexCount: vertex_count + ] + } + } + + pub fn draw_primitives_instanced( + &self, primitive_type: MTLPrimitiveType, vertex_start: NSUInteger, vertex_count: NSUInteger, instance_count: NSUInteger + ) { + unsafe { + msg_send![self, + drawPrimitives: primitive_type + vertexStart: vertex_start + vertexCount: vertex_count + instanceCount: instance_count + ] + } + } + + pub fn draw_primitives_instanced_base_instance( + &self, primitive_type: MTLPrimitiveType, vertex_start: NSUInteger, vertex_count: NSUInteger, instance_count: NSUInteger, base_instance: NSUInteger + ) { + unsafe { + msg_send![self, + drawPrimitives: primitive_type + vertexStart: vertex_start + vertexCount: vertex_count + instanceCount: instance_count + baseInstance: base_instance + ] + } + } + + pub fn draw_primitives_indirect( + &self, primitive_type: MTLPrimitiveType, indirect_buffer: &BufferRef, indirect_buffer_offset: NSUInteger + ) { + unsafe { + msg_send![self, + drawPrimitives: primitive_type + indirectBuffer: indirect_buffer + indirectBufferOffset: indirect_buffer_offset + ] + } + } + + pub fn draw_indexed_primitives( + &self, primitive_type: MTLPrimitiveType, index_count: NSUInteger, index_type: MTLIndexType, index_buffer: &BufferRef, index_buffer_offset: NSUInteger + ) { + unsafe { + msg_send![self, + drawIndexedPrimitives: primitive_type + indexCount: index_count + indexType: index_type + indexBuffer: index_buffer + indexBufferOffset: index_buffer_offset + ] + } + } + + pub fn draw_indexed_primitives_instanced( + &self, primitive_type: MTLPrimitiveType, index_count: NSUInteger, index_type: MTLIndexType, index_buffer: &BufferRef, index_buffer_offset: NSUInteger, instance_count: NSUInteger + ) { + unsafe { + msg_send![self, + drawIndexedPrimitives: primitive_type + indexCount: index_count + indexType: index_type + indexBuffer: index_buffer + indexBufferOffset: index_buffer_offset + instanceCount: instance_count + ] + } + } + + pub fn draw_indexed_primitives_instanced_base_instance( + &self, primitive_type: MTLPrimitiveType, index_count: NSUInteger, index_type: MTLIndexType, index_buffer: &BufferRef, index_buffer_offset: NSUInteger, instance_count: NSUInteger, base_vertex: NSInteger, base_instance: NSUInteger + ) { + unsafe { + msg_send![self, + drawIndexedPrimitives: primitive_type + indexCount: index_count + indexType: index_type + indexBuffer: index_buffer + indexBufferOffset: index_buffer_offset + instanceCount: instance_count + baseVertex: base_vertex + baseInstance: base_instance + ] + } + } + + pub fn draw_indexed_primitives_indirect( + &self, primitive_type: MTLPrimitiveType, index_type: MTLIndexType, index_buffer: &BufferRef, index_buffer_offset: NSUInteger, indirect_buffer: &BufferRef, indirect_buffer_offset: NSUInteger + ) { + unsafe { + msg_send![self, + drawIndexedPrimitives: primitive_type + indexType: index_type + indexBuffer: index_buffer + indexBufferOffset: index_buffer_offset + indirectBuffer: indirect_buffer + indirectBufferOffset: indirect_buffer_offset + ] + } + } + + // TODO: more draws + // fn setVertexBufferOffset_atIndex(self, offset: NSUInteger, index: NSUInteger); + // fn setVertexBuffers_offsets_withRange(self, buffers: *const id, offsets: *const NSUInteger, range: NSRange); + // fn setVertexSamplerStates_lodMinClamps_lodMaxClamps_withRange(self, samplers: *const id, lodMinClamps: *const f32, lodMaxClamps: *const f32, range: NSRange); + + pub fn use_resource(&self, resource: &ResourceRef, usage: MTLResourceUsage) { + unsafe { + msg_send![self, useResource:resource + usage:usage] + } + } + + pub fn use_heap(&self, heap: &HeapRef) { + unsafe { + msg_send![self, useHeap:heap] + } + } +} + +pub enum MTLBlitCommandEncoder {} + +foreign_obj_type! { + type CType = MTLBlitCommandEncoder; + pub struct BlitCommandEncoder; + pub struct BlitCommandEncoderRef; + type ParentType = CommandEncoderRef; +} + +impl BlitCommandEncoderRef { + pub fn synchronize_resource(&self, resource: &ResourceRef) { + unsafe { + msg_send![self, synchronizeResource:resource] + } + } + + pub fn fill_buffer(&self, + destination_buffer: &BufferRef, range: NSRange, value: u8, + ) { + unsafe { + msg_send![self, + fillBuffer: destination_buffer + range: range + value: value + ] + } + } + + pub fn copy_from_buffer(&self, + source_buffer: &BufferRef, source_offset: NSUInteger, + destination_buffer: &BufferRef, destination_offset: NSUInteger, + size: NSUInteger, + ) { + unsafe { + msg_send![self, + copyFromBuffer: source_buffer + sourceOffset: source_offset + toBuffer: destination_buffer + destinationOffset: destination_offset + size: size + ] + } + } + + pub fn copy_from_texture(&self, + source_texture: &TextureRef, source_slice: NSUInteger, source_level: NSUInteger, source_origin: MTLOrigin, source_size: MTLSize, + destination_texture: &TextureRef, destination_slice: NSUInteger, destination_level: NSUInteger, destination_origin: MTLOrigin, + ) { + unsafe { + msg_send![self, + copyFromTexture: source_texture + sourceSlice: source_slice + sourceLevel: source_level + sourceOrigin: source_origin + sourceSize: source_size + toTexture: destination_texture + destinationSlice: destination_slice + destinationLevel: destination_level + destinationOrigin: destination_origin + ] + } + } + + pub fn copy_from_buffer_to_texture(&self, + source_buffer: &BufferRef, source_offset: NSUInteger, source_bytes_per_row: NSUInteger, source_bytes_per_image: NSUInteger, source_size: MTLSize, + destination_texture: &TextureRef, destination_slice: NSUInteger, destination_level: NSUInteger, destination_origin: MTLOrigin, + options: MTLBlitOption, + ) { + unsafe { + msg_send![self, + copyFromBuffer: source_buffer + sourceOffset: source_offset + sourceBytesPerRow: source_bytes_per_row + sourceBytesPerImage: source_bytes_per_image + sourceSize: source_size + toTexture: destination_texture + destinationSlice: destination_slice + destinationLevel: destination_level + destinationOrigin: destination_origin + options: options + ] + } + } + + pub fn copy_from_texture_to_buffer(&self, + source_texture: &TextureRef, source_slice: NSUInteger, source_level: NSUInteger, source_origin: MTLOrigin, source_size: MTLSize, + destination_buffer: &BufferRef, destination_offset: NSUInteger, destination_bytes_per_row: NSUInteger, destination_bytes_per_image: NSUInteger, + options: MTLBlitOption, + ) { + unsafe { + msg_send![self, + copyFromTexture: source_texture + sourceSlice: source_slice + sourceLevel: source_level + sourceOrigin: source_origin + sourceSize: source_size + toBuffer: destination_buffer + destinationOffset: destination_offset + destinationBytesPerRow: destination_bytes_per_row + destinationBytesPerImage: destination_bytes_per_image + options: options + ] + } + } +} + +pub enum MTLComputeCommandEncoder {} + +foreign_obj_type! { + type CType = MTLComputeCommandEncoder; + pub struct ComputeCommandEncoder; + pub struct ComputeCommandEncoderRef; + type ParentType = CommandEncoderRef; +} + +impl ComputeCommandEncoderRef { + pub fn set_compute_pipeline_state(&self, state: &ComputePipelineStateRef) { + unsafe { + msg_send![self, setComputePipelineState:state] + } + } + + pub fn set_buffer(&self, index: NSUInteger, buffer: Option<&BufferRef>, offset: NSUInteger) { + unsafe { + msg_send![self, setBuffer:buffer offset:offset atIndex:index] + } + } + + pub fn set_buffers(&self, start_index: NSUInteger, data: &[Option<&BufferRef>], offsets: &[NSUInteger]) { + debug_assert_eq!(offsets.len(), data.len()); + unsafe { + msg_send![self, + setBuffers: data.as_ptr() + offsets: offsets.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_texture(&self, index: NSUInteger, texture: Option<&TextureRef>) { + unsafe { + msg_send![self, + setTexture:texture + atIndex:index + ] + } + } + + pub fn set_textures(&self, start_index: NSUInteger, data: &[Option<&TextureRef>]) { + unsafe { + msg_send![self, + setTextures: data.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_sampler_state(&self, index: NSUInteger, sampler: Option<&SamplerStateRef>) { + unsafe { + msg_send![self, + setSamplerState:sampler + atIndex:index + ] + } + } + + pub fn set_sampler_states(&self, start_index: NSUInteger, data: &[Option<&SamplerStateRef>]) { + unsafe { + msg_send![self, + setSamplerStates: data.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_sampler_state_with_lod( + &self, index: NSUInteger, sampler: Option<&SamplerStateRef>, lod_clamp: Range + ) { + unsafe { + msg_send![self, + setSamplerState:sampler + lodMinClamp:lod_clamp.start + lodMaxClamp:lod_clamp.end + atIndex:index + ] + } + } + + pub fn set_bytes(&self, index: NSUInteger, length: NSUInteger, bytes: *const libc::c_void) { + unsafe { + msg_send![self, + setBytes: bytes + length: length + atIndex: index + ] + } + } + + pub fn dispatch_thread_groups(&self, thread_groups_count: MTLSize, threads_per_thread_group: MTLSize) { + unsafe { + msg_send![self, + dispatchThreadgroups:thread_groups_count + threadsPerThreadgroup:threads_per_thread_group + ] + } + } + + pub fn dispatch_thread_groups_indirect(&self, buffer: &BufferRef, offset: NSUInteger, threads_per_thread_group: MTLSize) { + unsafe { + msg_send![self, + dispatchThreadgroupsWithIndirectBuffer:buffer + indirectBufferOffset:offset + threadsPerThreadgroup:threads_per_thread_group + ] + } + } + + pub fn use_resource(&self, resource: &ResourceRef, usage: MTLResourceUsage) { + unsafe { + msg_send![self, + useResource:resource + usage:usage + ] + } + } + + pub fn use_heap(&self, heap: &HeapRef) { + unsafe { + msg_send![self, useHeap:heap] + } + } +} + +pub enum MTLArgumentEncoder {} + +foreign_obj_type! { + type CType = MTLArgumentEncoder; + pub struct ArgumentEncoder; + pub struct ArgumentEncoderRef; +} + +impl ArgumentEncoderRef { + pub fn encoded_length(&self) -> NSUInteger { + unsafe { + msg_send![self, encodedLength] + } + } + + pub fn alignment(&self) -> NSUInteger { + unsafe { + msg_send![self, alignment] + } + } + + pub fn set_argument_buffer(&self, buffer: &BufferRef, offset: NSUInteger) { + unsafe { + msg_send![self, + setArgumentBuffer: buffer + offset: offset + ] + } + } + + pub fn set_argument_buffer_to_element(&self, buffer: &BufferRef, offset: NSUInteger, array_element: NSUInteger) { + unsafe { + msg_send![self, + setArgumentBuffer: buffer + startOffset: offset + arrayElement: array_element + ] + } + } + + pub fn set_buffer(&self, buffer: &BufferRef, offset: NSUInteger, at_index: NSUInteger) { + unsafe { + msg_send![self, + setBuffer: buffer + offset: offset + atIndex: at_index + ] + } + } + + pub fn set_buffers(&self, data: &[&BufferRef], offsets: &[NSUInteger], start_index: NSUInteger) { + assert_eq!(offsets.len(), data.len()); + unsafe { + msg_send![self, + setBuffers: data.as_ptr() + offsets: offsets.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_texture(&self, texture: &TextureRef, at_index: NSUInteger) { + unsafe { + msg_send![self, + setTexture: texture + atIndex: at_index + ] + } + } + + pub fn set_textures(&self, data: &[&TextureRef], start_index: NSUInteger) { + unsafe { + msg_send![self, + setTextures: data.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn set_sampler_state(&self, sampler_state: &SamplerStateRef, at_index: NSUInteger) { + unsafe { + msg_send![self, + setSamplerState: sampler_state + atIndex: at_index + ] + } + } + + pub fn set_sampler_states(&self, data: &[&SamplerStateRef], start_index: NSUInteger) { + unsafe { + msg_send![self, + setSamplerStates: data.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + + pub fn constant_data(&self, at_index: NSUInteger) -> *mut libc::c_void { + unsafe { + msg_send![self, constantDataAtIndex:at_index] + } + } + + pub fn new_argument_encoder_for_buffer(&self, index: NSUInteger) -> ArgumentEncoder { + unsafe { + let ptr = msg_send![self, newArgumentEncoderForBufferAtIndex:index]; + ArgumentEncoder::from_ptr(ptr) + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/heap.rs b/third_party/cargo/vendor/metal-0.13.1/src/heap.rs new file mode 100644 index 0000000..856b306 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/heap.rs @@ -0,0 +1,134 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use cocoa::foundation::NSUInteger; + +pub enum MTLHeap {} + +foreign_obj_type! { + type CType = MTLHeap; + pub struct Heap; + pub struct HeapRef; +} + +impl HeapRef { + pub fn cpu_cache_mode(&self) -> MTLCPUCacheMode { + unsafe { + msg_send![self, cpuCacheMode] + } + } + + pub fn storage_mode(&self) -> MTLStorageMode { + unsafe { + msg_send![self, storageMode] + } + } + + pub fn set_purgeable_state(&self, state: MTLPurgeableState) -> MTLPurgeableState { + unsafe { + msg_send![self, setPurgeableState:state] + } + } + + pub fn size(&self) -> NSUInteger { + unsafe { + msg_send![self, size] + } + } + + pub fn used_size(&self) -> NSUInteger { + unsafe { + msg_send![self, usedSize] + } + } + + pub fn max_available_size(&self, alignment: NSUInteger) -> NSUInteger { + unsafe { + msg_send![self, maxAvailableSizeWithAlignment: alignment] + } + } + + pub fn new_buffer(&self, length: u64, options: MTLResourceOptions) -> Option { + unsafe { + let ptr: *mut MTLBuffer = msg_send![self, newBufferWithLength:length + options:options]; + if !ptr.is_null() { + Some(Buffer::from_ptr(ptr)) + } else { + None + } + } + } + + pub fn new_texture(&self, descriptor: &TextureDescriptorRef) -> Option { + unsafe { + let ptr: *mut MTLTexture = msg_send![self, newTextureWithDescriptor:descriptor]; + if !ptr.is_null() { + Some(Texture::from_ptr(ptr)) + } else { + None + } + } + } +} + +pub enum MTLHeapDescriptor {} + +foreign_obj_type! { + type CType = MTLHeapDescriptor; + pub struct HeapDescriptor; + pub struct HeapDescriptorRef; +} + +impl HeapDescriptor { + pub fn new() -> Self { + unsafe { + let class = class!(MTLHeapDescriptor); + msg_send![class, new] + } + } +} + +impl HeapDescriptorRef { + pub fn cpu_cache_mode(&self) -> MTLCPUCacheMode { + unsafe { + msg_send![self, cpuCacheMode] + } + } + + pub fn set_cpu_cache_mode(&self, mode: MTLCPUCacheMode) { + unsafe { + msg_send![self, setCpuCacheMode:mode] + } + } + + pub fn storage_mode(&self) -> MTLStorageMode { + unsafe { + msg_send![self, storageMode] + } + } + + pub fn set_storage_mode(&self, mode: MTLStorageMode) { + unsafe { + msg_send![self, setStorageMode:mode] + } + } + + pub fn size(&self) -> NSUInteger { + unsafe { + msg_send![self, size] + } + } + + pub fn set_size(&self, size: NSUInteger) { + unsafe { + msg_send![self, setSize: size]; + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/lib.rs b/third_party/cargo/vendor/metal-0.13.1/src/lib.rs new file mode 100644 index 0000000..28ff372 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/lib.rs @@ -0,0 +1,386 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] + +extern crate cocoa; +extern crate core_graphics; +#[macro_use] +extern crate bitflags; +extern crate libc; +#[macro_use] +extern crate log; +#[macro_use] +extern crate objc; +extern crate objc_foundation; +extern crate objc_id; +extern crate block; +#[macro_use] +extern crate foreign_types; + +use std::mem; +use std::marker::PhantomData; +use std::ops::Deref; +use std::borrow::{Borrow, ToOwned}; + +use objc::runtime::{Object, YES, NO}; +use core_graphics::base::CGFloat; +use core_graphics::geometry::CGSize; +use foreign_types::ForeignType; + +macro_rules! foreign_obj_type { + {type CType = $raw_ident:ident; + pub struct $owned_ident:ident; + pub struct $ref_ident:ident; + type ParentType = $parent_ref:ident; + } => { + foreign_obj_type! { + type CType = $raw_ident; + pub struct $owned_ident; + pub struct $ref_ident; + } + + impl ::std::ops::Deref for $ref_ident { + type Target = $parent_ref; + + fn deref(&self) -> &$parent_ref { + unsafe { &*(self as *const $ref_ident as *const $parent_ref) } + } + } + }; + {type CType = $raw_ident:ident; + pub struct $owned_ident:ident; + pub struct $ref_ident:ident; + } => { + foreign_type! { + type CType = $raw_ident; + fn drop = ::obj_drop; + fn clone = ::obj_clone; + pub struct $owned_ident; + pub struct $ref_ident; + } + + unsafe impl ::objc::Message for $raw_ident { + } + unsafe impl ::objc::Message for $ref_ident { + } + + impl ::std::fmt::Debug for $ref_ident { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + unsafe { + use ::objc_foundation::INSString; + // TODO: might leak, not 100% sure... + let string: &::objc_foundation::NSString = msg_send![self, debugDescription]; + write!(f, "{}", string.as_str()) + } + } + } + + impl ::std::fmt::Debug for $owned_ident { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::std::ops::Deref::deref(self).fmt(f) + } + } + }; +} + +macro_rules! try_objc { + { + $err_name: ident => $body:expr + } => { + { + let mut $err_name: *mut ::objc::runtime::Object = ::std::ptr::null_mut(); + let value = $body; + if !$err_name.is_null() { + let desc: *mut Object = msg_send![$err_name, localizedDescription]; + let compile_error: *const ::libc::c_char = msg_send![desc, UTF8String]; + let message = CStr::from_ptr(compile_error).to_string_lossy().into_owned(); + msg_send![$err_name, release]; + return Err(message); + } + value + } + }; +} + +pub struct NSArray { + _phantom: PhantomData, +} + +pub struct Array(*mut NSArray) where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static; +pub struct ArrayRef(foreign_types::Opaque, PhantomData) where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static; + +impl Drop for Array where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static, +{ + fn drop(&mut self) { + unsafe { + msg_send![self.0, release]; + } + } +} + +impl Clone for Array where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static, +{ + fn clone(&self) -> Self { + unsafe { + Array(msg_send![self.0, retain]) + } + } +} + +unsafe impl objc::Message for NSArray where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static, +{} +unsafe impl objc::Message for ArrayRef where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static, +{} + +impl Array where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static, + { + pub fn from_slice(s: &[&T::Ref]) -> Self { + unsafe { + let class = class!(NSArray); + msg_send![class, arrayWithObjects: s.as_ptr() count: s.len()] + } + } + + pub fn from_owned_slice(s: &[T]) -> Self { + unsafe { + let class = class!(NSArray); + msg_send![class, arrayWithObjects: s.as_ptr() count: s.len()] + } + } +} + +impl foreign_types::ForeignType for Array where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static, +{ + type CType = NSArray; + type Ref = ArrayRef; + + unsafe fn from_ptr(p: *mut NSArray) -> Self { + Array(p) + } + + fn as_ptr(&self) -> *mut NSArray { + self.0 + } +} + +impl foreign_types::ForeignTypeRef for ArrayRef where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static, +{ + type CType = NSArray; +} + +impl Deref for Array where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static, +{ + type Target = ArrayRef; + + fn deref(&self) -> &ArrayRef { + unsafe { mem::transmute(self.as_ptr()) } + } +} + +impl Borrow> for Array where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static, +{ + fn borrow(&self) -> &ArrayRef { + unsafe { mem::transmute(self.as_ptr()) } + } +} + +impl ToOwned for ArrayRef where + T: ForeignType + 'static, + T::Ref: objc::Message + 'static, +{ + type Owned = Array; + + fn to_owned(&self) -> Array { + unsafe { Array::from_ptr(msg_send![self, retain]) } + } +} + +pub enum CAMetalDrawable {} + +foreign_obj_type! { + type CType = CAMetalDrawable; + pub struct CoreAnimationDrawable; + pub struct CoreAnimationDrawableRef; + type ParentType = DrawableRef; +} + +impl CoreAnimationDrawableRef { + pub fn texture(&self) -> &TextureRef { + unsafe { + msg_send![self, texture] + } + } +} + +pub enum CAMetalLayer {} + +foreign_obj_type! { + type CType = CAMetalLayer; + pub struct CoreAnimationLayer; + pub struct CoreAnimationLayerRef; +} + +impl CoreAnimationLayer { + pub fn new() -> Self { + unsafe { + let class = class!(CAMetalLayer); + msg_send![class, new] + } + } +} + +impl CoreAnimationLayerRef { + pub fn set_device(&self, device: &DeviceRef) { + unsafe { + msg_send![self, setDevice:device] + } + } + + pub fn pixel_format(&self) -> MTLPixelFormat { + unsafe { + msg_send![self, pixelFormat] + } + } + + pub fn set_pixel_format(&self, pixel_format: MTLPixelFormat) { + unsafe { + msg_send![self, setPixelFormat:pixel_format] + } + } + + pub fn drawable_size(&self) -> CGSize { + unsafe { + msg_send![self, drawableSize] + } + } + + pub fn set_drawable_size(&self, size: CGSize) { + unsafe { + msg_send![self, setDrawableSize:size] + } + } + + pub fn presents_with_transaction(&self) -> bool { + unsafe { + match msg_send![self, presentsWithTransaction] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn set_presents_with_transaction(&self, transaction: bool) { + unsafe { + msg_send![self, setPresentsWithTransaction:transaction]; + } + } + + pub fn set_edge_antialiasing_mask(&self, mask: u64) { + unsafe { + msg_send![self, setEdgeAntialiasingMask:mask] + } + } + + pub fn set_masks_to_bounds(&self, masks: bool) { + unsafe { + msg_send![self, setMasksToBounds:masks] + } + } + + pub fn remove_all_animations(&self) { + unsafe { + msg_send![self, removeAllAnimations]; + } + } + + pub fn next_drawable(&self) -> Option<&CoreAnimationDrawableRef> { + unsafe { + msg_send![self, nextDrawable] + } + } + + pub fn set_contents_scale(&self, scale: CGFloat) { + unsafe { + msg_send![self, setContentsScale:scale]; + } + } +} + +mod constants; +mod types; +mod device; +mod texture; +mod sampler; +mod resource; +mod drawable; +mod buffer; +mod renderpass; +mod commandqueue; +mod commandbuffer; +mod encoder; +mod pipeline; +mod library; +mod argument; +mod vertexdescriptor; +mod depthstencil; +mod heap; +mod capturemanager; + +pub use constants::*; +pub use types::*; +pub use device::*; +pub use texture::*; +pub use sampler::*; +pub use resource::*; +pub use drawable::*; +pub use buffer::*; +pub use renderpass::*; +pub use commandqueue::*; +pub use commandbuffer::*; +pub use encoder::*; +pub use pipeline::*; +pub use library::*; +pub use argument::*; +pub use vertexdescriptor::*; +pub use depthstencil::*; +pub use heap::*; +pub use capturemanager::*; + +#[inline] +unsafe fn obj_drop(p: *mut T) { + msg_send![(p as *mut Object), release]; +} + +#[inline] +unsafe fn obj_clone(p: *mut T) -> *mut T { + msg_send![(p as *mut Object), retain] +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/library.rs b/third_party/cargo/vendor/metal-0.13.1/src/library.rs new file mode 100644 index 0000000..1e5c802 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/library.rs @@ -0,0 +1,252 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use objc::runtime::{Object, YES, NO}; +use objc_foundation::{NSString, INSString, NSArray}; +use cocoa::foundation::{NSUInteger}; +use foreign_types::ForeignType; +use std::ffi::CStr; + +pub enum MTLVertexAttribute {} + +foreign_obj_type! { + type CType = MTLVertexAttribute; + pub struct VertexAttribute; + pub struct VertexAttributeRef; +} + +impl VertexAttributeRef { + pub fn name(&self) -> &str { + unsafe { + let name: &NSString = msg_send![self, name]; + name.as_str() + } + } + + pub fn attribute_index(&self) -> u64 { + unsafe { + msg_send![self, attributeIndex] + } + } + + pub fn attribute_type(&self) -> MTLDataType { + unsafe { + msg_send![self, attributeType] + } + } + + pub fn is_active(&self) -> bool { + unsafe { + match msg_send![self, isActive] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + +} + +#[repr(u64)] +#[derive(Debug)] +pub enum MTLFunctionType { + Vertex = 1, + Fragment = 2, + Kernel = 3, +} + +pub enum MTLFunction {} + +foreign_obj_type! { + type CType = MTLFunction; + pub struct Function; + pub struct FunctionRef; +} + +impl FunctionRef { + pub fn name(&self) -> &str { + unsafe { + let name: &NSString = msg_send![self, name]; + name.as_str() + } + } + + pub fn function_type(&self) -> MTLFunctionType { + unsafe { + msg_send![self, functionType] + } + } + + pub fn vertex_attributes(&self) -> &Array { + unsafe { + msg_send![self, vertexAttributes] + } + } + + pub fn new_argument_encoder(&self, buffer_index: NSUInteger) -> ArgumentEncoder { + unsafe { + let ptr = msg_send![self, newArgumentEncoderWithBufferIndex:buffer_index]; + ArgumentEncoder::from_ptr(ptr) + } + } + + pub fn function_constants_dictionary(&self) -> *mut Object { + unsafe { + msg_send![self, functionConstantsDictionary] + } + } +} + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] +pub enum MTLLanguageVersion { + V1_0 = 0x10000, + V1_1 = 0x10001, + V1_2 = 0x10002, + V2_0 = 0x20000, +} + +pub enum MTLFunctionConstantValues {} + +foreign_obj_type! { + type CType = MTLFunctionConstantValues; + pub struct FunctionConstantValues; + pub struct FunctionConstantValuesRef; +} + +impl FunctionConstantValues { + pub fn new() -> Self { + unsafe { + let class = class!(MTLFunctionConstantValues); + msg_send![class, new] + } + } +} + +impl FunctionConstantValuesRef { + pub unsafe fn set_constant_value_at_index(&self, index: NSUInteger, ty: MTLDataType, value: *const std::os::raw::c_void) { + msg_send![self, setConstantValue:value type:ty atIndex:index] + } +} + +pub enum MTLCompileOptions {} + +foreign_obj_type! { + type CType = MTLCompileOptions; + pub struct CompileOptions; + pub struct CompileOptionsRef; +} + +impl CompileOptions { + pub fn new() -> Self { + unsafe { + let class = class!(MTLCompileOptions); + msg_send![class, new] + } + } +} + +impl CompileOptionsRef { + pub unsafe fn preprocessor_defines(&self) -> *mut Object { + msg_send![self, preprocessorMacros] + } + + pub unsafe fn set_preprocessor_defines(&self, defines: *mut Object) { + msg_send![self, setPreprocessorMacros:defines] + } + + pub fn is_fast_math_enabled(&self) -> bool { + unsafe { + match msg_send![self, fastMathEnabled] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn set_fast_math_enabled(&self, enabled: bool) { + unsafe { + msg_send![self, setFastMathEnabled:enabled] + } + } + + pub fn language_version(&self) -> MTLLanguageVersion { + unsafe { + msg_send![self, languageVersion] + } + } + + pub fn set_language_version(&self, version: MTLLanguageVersion) { + unsafe { + msg_send![self, setLanguageVersion:version] + } + } +} + +#[repr(u64)] +#[allow(non_camel_case_types)] +pub enum MTLLibraryError { + Unsupported = 1, + Internal = 2, + CompileFailure = 3, + CompileWarning = 4, +} + +pub enum MTLLibrary {} + +foreign_obj_type! { + type CType = MTLLibrary; + pub struct Library; + pub struct LibraryRef; +} + + +impl LibraryRef { + pub fn label(&self) -> &str { + unsafe { + let label: &NSString = msg_send![self, label]; + label.as_str() + } + } + + pub fn set_label(&self, label: &str) { + unsafe { + let nslabel = NSString::from_str(label); + msg_send![self, setLabel:nslabel] + } + } + + pub fn get_function(&self, name: &str, constants: Option) -> Result { + unsafe { + use cocoa::foundation::NSString as cocoa_NSString; + use cocoa::base::nil as cocoa_nil; + + let nsname = cocoa_NSString::alloc(cocoa_nil).init_str(name); + + let function: *mut MTLFunction = match constants { + Some(c) => try_objc!{ err => msg_send![self, newFunctionWithName:nsname constantValues:c error:&mut err] }, + None => msg_send![self, newFunctionWithName:nsname] + }; + + if !function.is_null() { + Ok(Function::from_ptr(function)) + } else { + Err(format!("Function '{}' does not exist", name)) + } + } + } + + pub fn function_names(&self) -> &NSArray { + unsafe { + msg_send![self, functionNames] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/pipeline/compute.rs b/third_party/cargo/vendor/metal-0.13.1/src/pipeline/compute.rs new file mode 100644 index 0000000..b2e53da --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/pipeline/compute.rs @@ -0,0 +1,477 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use cocoa::foundation::NSUInteger; +use objc::runtime::{YES, NO}; +use objc_foundation::{INSString, NSString}; + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum MTLMutability { + Default = 0, + Mutable = 1, + Immutable = 2, +} + +impl Default for MTLMutability { + #[inline] + fn default() -> Self { + MTLMutability::Default + } +} + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum MTLIndexType { + UInt16 = 0, + UInt32 = 1, +} + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum MTLAttributeFormat { + Invalid = 0, + UChar2 = 1, + UChar3 = 2, + UChar4 = 3, + Char2 = 4, + Char3 = 5, + Char4 = 6, + UChar2Normalized = 7, + UChar3Normalized = 8, + UChar4Normalized = 9, + Char2Normalized = 10, + Char3Normalized = 11, + Char4Normalized = 12, + UShort2 = 13, + UShort3 = 14, + UShort4 = 15, + Short2 = 16, + Short3 = 17, + Short4 = 18, + UShort2Normalized = 19, + UShort3Normalized = 20, + UShort4Normalized = 21, + Short2Normalized = 22, + Short3Normalized = 23, + Short4Normalized = 24, + Half2 = 25, + Half3 = 26, + Half4 = 27, + Float = 28, + Float2 = 29, + Float3 = 30, + Float4 = 31, + Int = 32, + Int2 = 33, + Int3 = 34, + Int4 = 35, + UInt = 36, + UInt2 = 37, + UInt3 = 38, + UInt4 = 39, + Int1010102Normalized = 40, + UInt1010102Normalized = 41, + UChar4Normalized_BGRA = 42, + UChar = 45, + Char = 46, + UCharNormalized = 47, + CharNormalized = 48, + UShort = 49, + Short = 50, + UShortNormalized = 51, + ShortNormalized = 52, + Half = 53, +} + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum MTLStepFunction { + Constant = 0, + PerInstance = 1, + PerPatch = 2, + PerPatchControlPoint = 3, + PerVertex = 4, + ThreadPositionInGridX = 5, + ThreadPositionInGridXIndexed = 6, + ThreadPositionInGridY = 7, + ThreadPositionInGridYIndexed = 8, +} + +pub enum MTLComputePipelineDescriptor {} + +foreign_obj_type! { + type CType = MTLComputePipelineDescriptor; + pub struct ComputePipelineDescriptor; + pub struct ComputePipelineDescriptorRef; +} + +impl ComputePipelineDescriptor { + pub fn new() -> Self { + unsafe { + let class = class!(MTLComputePipelineDescriptor); + msg_send![class, new] + } + } +} + +impl ComputePipelineDescriptorRef { + pub fn label(&self) -> &str { + unsafe { + let label: &NSString = msg_send![self, label]; + label.as_str() + } + } + + pub fn set_label(&self, label: &str) { + unsafe { + let nslabel = NSString::from_str(label); + msg_send![self, setLabel:nslabel] + } + } + + pub fn compute_function(&self) -> Option<&FunctionRef> { + unsafe { + msg_send![self, computeFunction] + } + } + + pub fn set_compute_function(&self, function: Option<&FunctionRef>) { + unsafe { + msg_send![self, setComputeFunction:function] + } + } + + pub fn thread_group_size_is_multiple_of_thread_execution_width(&self) -> bool { + unsafe { + match msg_send![self, threadGroupSizeIsMultipleOfThreadExecutionWidth] { + YES => true, + NO => false, + _ => unreachable!(), + } + } + } + + pub fn set_thread_group_size_is_multiple_of_thread_execution_width(&self, size_is_multiple_of_width: bool) { + unsafe { + msg_send![self, setThreadGroupSizeIsMultipleOfThreadExecutionWidth:size_is_multiple_of_width] + } + } + + pub fn stage_input_descriptor(&self) -> Option<&StageInputOutputDescriptorRef> { + unsafe { + msg_send![self, stageInputDescriptor] + } + } + + pub fn set_stage_input_descriptor(&self, descriptor: Option<&StageInputOutputDescriptorRef>) { + unsafe { + msg_send![self, setStageInputDescriptor:descriptor] + } + } + + pub fn buffers(&self) -> Option<&PipelineBufferDescriptorArrayRef> { + unsafe { + msg_send![self, buffers] + } + } + + pub fn reset(&self) { + unsafe { + msg_send![self, reset] + } + } +} + +pub enum MTLComputePipelineState {} + +foreign_obj_type! { + type CType = MTLComputePipelineState; + pub struct ComputePipelineState; + pub struct ComputePipelineStateRef; +} + +impl ComputePipelineStateRef { + pub fn label(&self) -> &str { + unsafe { + let label: &NSString = msg_send![self, label]; + label.as_str() + } + } + + pub fn set_label(&self, label: &str) { + unsafe { + let nslabel = NSString::from_str(label); + msg_send![self, setLabel:nslabel] + } + } + + pub fn max_total_threads_per_group(&self) -> NSUInteger { + unsafe { + msg_send![self, maxTotalThreadsPerThreadgroup] + } + } + + pub fn thread_execution_width(&self) -> NSUInteger { + unsafe { + msg_send![self, threadExecutionWidth] + } + } + + pub fn static_threadgroup_memory_length(&self) -> NSUInteger { + unsafe { + msg_send![self, staticThreadgroupMemoryLength] + } + } +} + +pub enum MTLPipelineBufferDescriptorArray {} + +foreign_obj_type! { + type CType = MTLPipelineBufferDescriptorArray; + pub struct PipelineBufferDescriptorArray; + pub struct PipelineBufferDescriptorArrayRef; +} + +impl PipelineBufferDescriptorArrayRef { + pub fn object_at(&self, index: usize) -> Option<&PipelineBufferDescriptorRef> { + unsafe { + msg_send![self, objectAtIndexedSubscript:index] + } + } + + pub fn set_object_at(&self, index: usize, buffer_desc: Option<&PipelineBufferDescriptorRef>) { + unsafe { + msg_send![self, setObject:buffer_desc atIndexedSubscript:index] + } + } +} + +pub enum MTLPipelineBufferDescriptor {} + +foreign_obj_type! { + type CType = MTLPipelineBufferDescriptor; + pub struct PipelineBufferDescriptor; + pub struct PipelineBufferDescriptorRef; +} + +impl PipelineBufferDescriptorRef { + pub fn mutability(&self) -> MTLMutability { + unsafe { + msg_send![self, mutability] + } + } + + pub fn set_mutability(&self, new_mutability: MTLMutability) { + unsafe { + msg_send![self, setMutability:new_mutability] + } + } +} + +pub enum MTLStageInputOutputDescriptor {} + +foreign_obj_type! { + type CType = MTLStageInputOutputDescriptor; + pub struct StageInputOutputDescriptor; + pub struct StageInputOutputDescriptorRef; +} + +impl StageInputOutputDescriptor { + pub fn new<'a>() -> &'a StageInputOutputDescriptorRef { + unsafe { + let class = class!(MTLStageInputOutputDescriptor); + msg_send![class, stageInputOutputDescriptor] + } + } +} + +impl StageInputOutputDescriptorRef { + pub fn attributes(&self) -> Option<&AttributeDescriptorArrayRef> { + unsafe { + msg_send![self, attributes] + } + } + + pub fn index_buffer_index(&self) -> NSUInteger { + unsafe { + msg_send![self, indexBufferIndex] + } + } + + pub fn set_index_buffer_index(&self, idx_buffer_idx: NSUInteger) { + unsafe { + msg_send![self, setIndexBufferIndex:idx_buffer_idx] + } + } + + pub fn index_type(&self) -> MTLIndexType { + unsafe { + msg_send![self, indexType] + } + } + + pub fn set_index_type(&self, index_ty: MTLIndexType) { + unsafe { + msg_send![self, setIndexType:index_ty] + } + } + + pub fn layouts(&self) -> Option<&BufferLayoutDescriptorArrayRef> { + unsafe { + msg_send![self, layouts] + } + } + + pub fn reset(&self) { + unsafe { + msg_send![self, reset] + } + } +} + +pub enum MTLAttributeDescriptorArray {} + +foreign_obj_type! { + type CType = MTLAttributeDescriptorArray; + pub struct AttributeDescriptorArray; + pub struct AttributeDescriptorArrayRef; +} + +impl AttributeDescriptorArrayRef { + pub fn object_at(&self, index: usize) -> Option<&AttributeDescriptorRef> { + unsafe { + msg_send![self, objectAtIndexedSubscript:index] + } + } + + pub fn set_object_at(&self, index: usize, buffer_desc: Option<&AttributeDescriptorRef>) { + unsafe { + msg_send![self, setObject:buffer_desc atIndexedSubscript:index] + } + } +} + +pub enum MTLAttributeDescriptor {} + +foreign_obj_type! { + type CType = MTLAttributeDescriptor; + pub struct AttributeDescriptor; + pub struct AttributeDescriptorRef; +} + +impl AttributeDescriptorRef { + pub fn buffer_index(&self) -> NSUInteger { + unsafe { + msg_send![self, bufferIndex] + } + } + + pub fn set_buffer_index(&self, buffer_index: NSUInteger) { + unsafe { + msg_send![self, setBufferIndex:buffer_index] + } + } + + pub fn format(&self) -> MTLAttributeFormat { + unsafe { + msg_send![self, format] + } + } + + pub fn set_format(&self, format: MTLAttributeFormat) { + unsafe { + msg_send![self, setFormat:format] + } + } + + pub fn offset(&self) -> NSUInteger { + unsafe { + msg_send![self, offset] + } + } + + pub fn set_offset(&self, offset: NSUInteger) { + unsafe { + msg_send![self, setOffset:offset] + } + } +} + +pub enum MTLBufferLayoutDescriptorArray {} + +foreign_obj_type! { + type CType = MTLBufferLayoutDescriptorArray; + pub struct BufferLayoutDescriptorArray; + pub struct BufferLayoutDescriptorArrayRef; +} + +impl BufferLayoutDescriptorArrayRef { + pub fn object_at(&self, index: usize) -> Option<&BufferLayoutDescriptorRef> { + unsafe { + msg_send![self, objectAtIndexedSubscript:index] + } + } + + pub fn set_object_at(&self, index: usize, buffer_desc: Option<&BufferLayoutDescriptorRef>) { + unsafe { + msg_send![self, setObject:buffer_desc atIndexedSubscript:index] + } + } +} + +pub enum MTLBufferLayoutDescriptor {} + +foreign_obj_type! { + type CType = MTLBufferLayoutDescriptor; + pub struct BufferLayoutDescriptor; + pub struct BufferLayoutDescriptorRef; +} + +impl BufferLayoutDescriptorRef { + pub fn step_function(&self) -> MTLStepFunction { + unsafe { + msg_send![self, stepFunction] + } + } + + pub fn set_step_function(&self, step_function: MTLStepFunction) { + unsafe { + msg_send![self, setStepFunction:step_function] + } + } + + pub fn step_rate(&self) -> NSUInteger { + unsafe { + msg_send![self, stepRate] + } + } + + pub fn set_step_rate(&self, step_rate: NSUInteger) { + unsafe { + msg_send![self, setStepRate:step_rate] + } + } + + pub fn stride(&self) -> NSUInteger { + unsafe { + msg_send![self, stride] + } + } + + pub fn set_stride(&self, stride: NSUInteger) { + unsafe { + msg_send![self, setStride:stride] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/pipeline/mod.rs b/third_party/cargo/vendor/metal-0.13.1/src/pipeline/mod.rs new file mode 100644 index 0000000..02548ad --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/pipeline/mod.rs @@ -0,0 +1,14 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +mod compute; +mod render; + +pub use self::compute::*; +pub use self::render::*; diff --git a/third_party/cargo/vendor/metal-0.13.1/src/pipeline/render.rs b/third_party/cargo/vendor/metal-0.13.1/src/pipeline/render.rs new file mode 100644 index 0000000..f0ab852 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/pipeline/render.rs @@ -0,0 +1,467 @@ +// Copyright 2017 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use cocoa::foundation::NSUInteger; +use objc::runtime::{YES, NO}; +use objc_foundation::{INSString, NSString}; + +#[cfg(feature = "private")] +use libc; + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum MTLBlendFactor { + Zero = 0, + One = 1, + SourceColor = 2, + OneMinusSourceColor = 3, + SourceAlpha = 4, + OneMinusSourceAlpha = 5, + DestinationColor = 6, + OneMinusDestinationColor = 7, + DestinationAlpha = 8, + OneMinusDestinationAlpha = 9, + SourceAlphaSaturated = 10, + BlendColor = 11, + OneMinusBlendColor = 12, + BlendAlpha = 13, + OneMinusBlendAlpha = 14, + Source1Color = 15, + OneMinusSource1Color = 16, + Source1Alpha = 17, + OneMinusSource1Alpha = 18, +} + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum MTLBlendOperation { + Add = 0, + Subtract = 1, + ReverseSubtract = 2, + Min = 3, + Max = 4, +} + +bitflags! { + pub struct MTLColorWriteMask: NSUInteger { + const Red = 0x1 << 3; + const Green = 0x1 << 2; + const Blue = 0x1 << 1; + const Alpha = 0x1 << 0; + } +} + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum MTLPrimitiveTopologyClass { + Unspecified = 0, + Point = 1, + Line = 2, + Triangle = 3, +} + +pub enum MTLRenderPipelineColorAttachmentDescriptor {} + +foreign_obj_type! { + type CType = MTLRenderPipelineColorAttachmentDescriptor; + pub struct RenderPipelineColorAttachmentDescriptor; + pub struct RenderPipelineColorAttachmentDescriptorRef; +} + +impl RenderPipelineColorAttachmentDescriptorRef { + pub fn pixel_format(&self) -> MTLPixelFormat { + unsafe { + msg_send![self, pixelFormat] + } + } + + pub fn set_pixel_format(&self, pixel_format: MTLPixelFormat) { + unsafe { + msg_send![self, setPixelFormat:pixel_format] + } + } + + pub fn is_blending_enabled(&self) -> bool { + unsafe { + match msg_send![self, isBlendingEnabled] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn set_blending_enabled(&self, enabled: bool) { + unsafe { + msg_send![self, setBlendingEnabled:enabled] + } + } + + pub fn source_rgb_blend_factor(&self) -> MTLBlendFactor { + unsafe { + msg_send![self, sourceRGBBlendFactor] + } + } + + pub fn set_source_rgb_blend_factor(&self, blend_factor: MTLBlendFactor) { + unsafe { + msg_send![self, setSourceRGBBlendFactor:blend_factor] + } + } + + pub fn destination_rgb_blend_factor(&self) -> MTLBlendFactor { + unsafe { + msg_send![self, destinationRGBBlendFactor] + } + } + + pub fn set_destination_rgb_blend_factor(&self, blend_factor: MTLBlendFactor) { + unsafe { + msg_send![self, setDestinationRGBBlendFactor:blend_factor] + } + } + + pub fn rgb_blend_operation(&self) -> MTLBlendOperation { + unsafe { + msg_send![self, rgbBlendOperation] + } + } + + pub fn set_rgb_blend_operation(&self, blend_operation: MTLBlendOperation) { + unsafe { + msg_send![self, setRgbBlendOperation:blend_operation] + } + } + + pub fn source_alpha_blend_factor(&self) -> MTLBlendFactor { + unsafe { + msg_send![self, sourceAlphaBlendFactor] + } + } + + pub fn set_source_alpha_blend_factor(&self, blend_factor: MTLBlendFactor) { + unsafe { + msg_send![self, setSourceAlphaBlendFactor:blend_factor] + } + } + + pub fn destination_alpha_blend_factor(&self) -> MTLBlendFactor { + unsafe { + msg_send![self, destinationAlphaBlendFactor] + } + } + + pub fn set_destination_alpha_blend_factor(&self, blend_factor: MTLBlendFactor) { + unsafe { + msg_send![self, setDestinationAlphaBlendFactor:blend_factor] + } + } + + pub fn alpha_blend_operation(&self) -> MTLBlendOperation { + unsafe { + msg_send![self, alphaBlendOperation] + } + } + + pub fn set_alpha_blend_operation(&self, blend_operation: MTLBlendOperation) { + unsafe { + msg_send![self, setAlphaBlendOperation:blend_operation] + } + } + + pub fn write_mask(&self) -> MTLColorWriteMask { + unsafe { + msg_send![self, writeMask] + } + } + + pub fn set_write_mask(&self, mask: MTLColorWriteMask) { + unsafe { + msg_send![self, setWriteMask:mask] + } + } +} + +pub enum MTLRenderPipelineReflection {} + +foreign_obj_type! { + type CType = MTLRenderPipelineReflection; + pub struct RenderPipelineReflection; + pub struct RenderPipelineReflectionRef; +} + +impl RenderPipelineReflection { + #[cfg(feature = "private")] + pub unsafe fn new(vertex_data: *mut libc::c_void, + fragment_data: *mut libc::c_void, vertex_desc: *mut libc::c_void, + device: &DeviceRef, options: u64, flags: u64) -> Self + { + let class = class!(MTLRenderPipelineReflection); + let this: RenderPipelineReflection = msg_send![class, alloc]; + let this_alias: *mut Object = msg_send![this.as_ref(), initWithVertexData:vertex_data + fragmentData:fragment_data + serializedVertexDescriptor:vertex_desc + device:device + options:options + flags:flags]; + if this_alias.is_null() { + panic!("[MTLRenderPipelineReflection init] failed"); + } + this + } +} + +impl RenderPipelineReflectionRef { + pub fn fragment_arguments(&self) -> &Array { + unsafe { + msg_send![self, fragmentArguments] + } + } + + pub fn vertex_arguments(&self) -> &Array { + unsafe { + msg_send![self, vertexArguments] + } + } +} + +pub enum MTLRenderPipelineDescriptor {} + +foreign_obj_type! { + type CType = MTLRenderPipelineDescriptor; + pub struct RenderPipelineDescriptor; + pub struct RenderPipelineDescriptorRef; +} + +impl RenderPipelineDescriptor { + pub fn new() -> Self { + unsafe { + let class = class!(MTLRenderPipelineDescriptor); + msg_send![class, new] + } + } +} + +impl RenderPipelineDescriptorRef { + pub fn label(&self) -> &str { + unsafe { + let label: &NSString = msg_send![self, label]; + label.as_str() + } + } + + pub fn set_label(&self, label: &str) { + unsafe { + let nslabel = NSString::from_str(label); + msg_send![self, setLabel:nslabel] + } + } + + pub fn vertex_function(&self) -> Option<&FunctionRef> { + unsafe { + msg_send![self, vertexFunction] + } + } + + pub fn set_vertex_function(&self, function: Option<&FunctionRef>) { + unsafe { + msg_send![self, setVertexFunction:function] + } + } + + pub fn fragment_function(&self) -> Option<&FunctionRef> { + unsafe { + msg_send![self, fragmentFunction] + } + } + + pub fn set_fragment_function(&self, function: Option<&FunctionRef>) { + unsafe { + msg_send![self, setFragmentFunction:function] + } + } + + pub fn vertex_descriptor(&self) -> Option<&VertexDescriptorRef> { + unsafe { + msg_send![self, vertexDescriptor] + } + } + + pub fn set_vertex_descriptor(&self, descriptor: Option<&VertexDescriptorRef>) { + unsafe { + msg_send![self, setVertexDescriptor:descriptor] + } + } + + pub fn sample_count(&self) -> NSUInteger { + unsafe { + msg_send![self, sampleCount] + } + } + + pub fn set_sample_count(&self, count: NSUInteger) { + unsafe { + msg_send![self, setSampleCount:count] + } + } + + pub fn is_alpha_to_coverage_enabled(&self) -> bool { + unsafe { + match msg_send![self, isAlphaToCoverageEnabled] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn set_alpha_to_coverage_enabled(&self, enabled: bool) { + unsafe { + msg_send![self, setAlphaToCoverageEnabled:enabled] + } + } + + pub fn is_alpha_to_one_enabled(&self) -> bool { + unsafe { + match msg_send![self, isAlphaToOneEnabled] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn set_alpha_to_one_enabled(&self, enabled: bool) { + unsafe { + msg_send![self, setAlphaToOneEnabled:enabled] + } + } + + pub fn is_rasterization_enabled(&self) -> bool { + unsafe { + match msg_send![self, isRasterizationEnabled] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn set_rasterization_enabled(&self, enabled: bool) { + unsafe { + msg_send![self, setRasterizationEnabled:enabled] + } + } + + pub fn color_attachments(&self) -> &RenderPipelineColorAttachmentDescriptorArrayRef { + unsafe { + msg_send![self, colorAttachments] + } + } + + pub fn depth_attachment_pixel_format(&self) -> MTLPixelFormat { + unsafe { + msg_send![self, depthAttachmentPixelFormat] + } + } + + pub fn set_depth_attachment_pixel_format(&self, pixel_format: MTLPixelFormat) { + unsafe { + msg_send![self, setDepthAttachmentPixelFormat:pixel_format] + } + } + + pub fn stencil_attachment_pixel_format(&self) -> MTLPixelFormat { + unsafe { + msg_send![self, stencilAttachmentPixelFormat] + } + } + + pub fn set_stencil_attachment_pixel_format(&self, pixel_format: MTLPixelFormat) { + unsafe { + msg_send![self, setStencilAttachmentPixelFormat:pixel_format] + } + } + + pub fn input_primitive_topology(&self) -> MTLPrimitiveTopologyClass { + unsafe { + msg_send![self, inputPrimitiveTopology] + } + } + + pub fn set_input_primitive_topology(&self, topology: MTLPrimitiveTopologyClass) { + unsafe { + msg_send![self, setInputPrimitiveTopology:topology] + } + } + + #[cfg(feature = "private")] + pub unsafe fn serialize_vertex_data(&self) -> *mut libc::c_void { + use std::ptr; + let flags = 0; + let err: *mut Object = ptr::null_mut(); + msg_send![self, newSerializedVertexDataWithFlags:flags + error:err] + } + + #[cfg(feature = "private")] + pub unsafe fn serialize_fragment_data(&self) -> *mut libc::c_void { + msg_send![self, serializeFragmentData] + } +} + +pub enum MTLRenderPipelineState {} + +foreign_obj_type! { + type CType = MTLRenderPipelineState; + pub struct RenderPipelineState; + pub struct RenderPipelineStateRef; +} + +impl RenderPipelineStateRef { + pub fn label(&self) -> &str { + unsafe { + let label: &NSString = msg_send![self, label]; + label.as_str() + } + } + + pub fn set_label(&self, label: &str) { + unsafe { + let nslabel = NSString::from_str(label); + msg_send![self, setLabel:nslabel] + } + } +} + +pub enum MTLRenderPipelineColorAttachmentDescriptorArray {} + +foreign_obj_type! { + type CType = MTLRenderPipelineColorAttachmentDescriptorArray; + pub struct RenderPipelineColorAttachmentDescriptorArray; + pub struct RenderPipelineColorAttachmentDescriptorArrayRef; +} + +impl RenderPipelineColorAttachmentDescriptorArrayRef { + pub fn object_at(&self, index: usize) -> Option<&RenderPipelineColorAttachmentDescriptorRef> { + unsafe { + msg_send![self, objectAtIndexedSubscript:index] + } + } + + pub fn set_object_at(&self, index: usize, attachment: Option<&RenderPipelineColorAttachmentDescriptorRef>) { + unsafe { + msg_send![self, setObject:attachment + atIndexedSubscript:index] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/renderpass.rs b/third_party/cargo/vendor/metal-0.13.1/src/renderpass.rs new file mode 100644 index 0000000..65dae31 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/renderpass.rs @@ -0,0 +1,354 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use cocoa::foundation::NSUInteger; + +#[repr(u64)] +#[derive(Clone, Debug)] +pub enum MTLLoadAction { + DontCare = 0, + Load = 1, + Clear = 2, +} + +#[repr(u64)] +#[derive(Clone, Debug)] +pub enum MTLStoreAction { + DontCare = 0, + Store = 1, + MultisampleResolve = 2, + StoreAndMultisampleResolve = 3, + Unknown = 4, + CustomSampleDepthStore = 5, +} + +#[repr(C)] +#[derive(Clone, Debug)] +pub struct MTLClearColor { + red: f64, + green: f64, + blue: f64, + alpha: f64 +} + +impl MTLClearColor { + #[inline] + pub fn new(red: f64, green: f64, blue: f64, alpha: f64) -> Self { + MTLClearColor { + red: red, + green: green, + blue: blue, + alpha: alpha + } + } +} + +pub enum MTLRenderPassAttachmentDescriptor {} + +foreign_obj_type! { + type CType = MTLRenderPassAttachmentDescriptor; + pub struct RenderPassAttachmentDescriptor; + pub struct RenderPassAttachmentDescriptorRef; +} + +impl RenderPassAttachmentDescriptorRef { + pub fn texture(&self) -> Option<&TextureRef> { + unsafe { + msg_send![self, texture] + } + } + + pub fn set_texture(&self, texture: Option<&TextureRef>) { + unsafe { + msg_send![self, setTexture:texture]; + } + } + + pub fn level(&self) -> NSUInteger { + unsafe { + msg_send![self, level] + } + } + + pub fn set_level(&self, level: NSUInteger) { + unsafe { + msg_send![self, setLevel:level] + } + } + + pub fn slice(&self) -> NSUInteger { + unsafe { + msg_send![self, slice] + } + } + + pub fn set_slice(&self, slice: NSUInteger) { + unsafe { + msg_send![self, setSlice:slice] + } + } + + pub fn depth_plane(&self) -> NSUInteger { + unsafe { + msg_send![self, depthPlane] + } + } + + pub fn set_depth_plane(&self, depth_plane: NSUInteger) { + unsafe { + msg_send![self, setDepthPlane:depth_plane] + } + } + + pub fn resolve_texture(&self) -> Option<&TextureRef> { + unsafe { + msg_send![self, resolveTexture] + } + } + + pub fn set_resolve_texture(&self, resolve_texture: Option<&TextureRef>) { + unsafe { + msg_send![self, setResolveTexture:resolve_texture] + } + } + + pub fn resolve_level(&self) -> NSUInteger { + unsafe { + msg_send![self, resolveLevel] + } + } + + pub fn set_resolve_level(&self, resolve_level: NSUInteger) { + unsafe { + msg_send![self, setResolveLevel:resolve_level] + } + } + + pub fn resolve_slice(&self) -> NSUInteger { + unsafe { + msg_send![self, resolveSlice] + } + } + + pub fn set_resolve_slice(&self, resolve_slice: NSUInteger) { + unsafe { + msg_send![self, setResolveSlice:resolve_slice] + } + } + + pub fn resolve_depth_plane(&self) -> NSUInteger { + unsafe { + msg_send![self, resolveDepthPlane] + } + } + + pub fn set_resolve_depth_plane(&self, resolve_depth_plane: NSUInteger) { + unsafe { + msg_send![self, setResolveDepthPlane:resolve_depth_plane] + } + } + + pub fn load_action(&self) -> MTLLoadAction { + unsafe { + msg_send![self, loadAction] + } + } + + pub fn set_load_action(&self, load_action: MTLLoadAction) { + unsafe { + msg_send![self, setLoadAction:load_action] + } + } + + pub fn store_action(&self) -> MTLStoreAction { + unsafe { + msg_send![self, storeAction] + } + } + + pub fn set_store_action(&self, store_action: MTLStoreAction) { + unsafe { + msg_send![self, setStoreAction:store_action] + } + } +} + +pub enum MTLRenderPassColorAttachmentDescriptor {} + +foreign_obj_type! { + type CType = MTLRenderPassColorAttachmentDescriptor; + pub struct RenderPassColorAttachmentDescriptor; + pub struct RenderPassColorAttachmentDescriptorRef; + type ParentType = RenderPassAttachmentDescriptorRef; +} + +impl RenderPassColorAttachmentDescriptor { + pub fn new() -> Self { + unsafe { + let class = class!(MTLRenderPassColorAttachmentDescriptor); + msg_send![class, new] + } + } +} + +impl RenderPassColorAttachmentDescriptorRef { + pub fn clear_color(&self) -> MTLClearColor { + unsafe { + msg_send![self, clearColor] + } + } + + pub fn set_clear_color(&self, clear_color: MTLClearColor) { + unsafe { + msg_send![self, setClearColor:clear_color] + } + } +} + +pub enum MTLRenderPassDepthAttachmentDescriptor {} + +foreign_obj_type! { + type CType = MTLRenderPassDepthAttachmentDescriptor; + pub struct RenderPassDepthAttachmentDescriptor; + pub struct RenderPassDepthAttachmentDescriptorRef; + type ParentType = RenderPassAttachmentDescriptorRef; +} + +impl RenderPassDepthAttachmentDescriptorRef { + pub fn clear_depth(&self) -> f64 { + unsafe { + msg_send![self, clearDepth] + } + } + + pub fn set_clear_depth(&self, clear_depth: f64) { + unsafe { + msg_send![self, setClearDepth:clear_depth] + } + } +} + +pub enum MTLRenderPassStencilAttachmentDescriptor {} + +foreign_obj_type! { + type CType = MTLRenderPassStencilAttachmentDescriptor; + pub struct RenderPassStencilAttachmentDescriptor; + pub struct RenderPassStencilAttachmentDescriptorRef; + type ParentType = RenderPassAttachmentDescriptorRef; +} + +impl RenderPassStencilAttachmentDescriptorRef { + pub fn clear_stencil(&self) -> u32 { + unsafe { + msg_send![self, clearStencil] + } + } + + pub fn set_clear_stencil(&self, clear_stencil: u32) { + unsafe { + msg_send![self, setClearStencil:clear_stencil] + } + } +} + +pub enum MTLRenderPassColorAttachmentDescriptorArray {} + +foreign_obj_type! { + type CType = MTLRenderPassColorAttachmentDescriptorArray; + pub struct RenderPassColorAttachmentDescriptorArray; + pub struct RenderPassColorAttachmentDescriptorArrayRef; +} + +impl RenderPassColorAttachmentDescriptorArrayRef { + pub fn object_at(&self, index: usize) -> Option<&RenderPassColorAttachmentDescriptorRef> { + unsafe { + msg_send![self, objectAtIndexedSubscript:index] + } + } + + pub fn set_object_at(&self, index: usize, attachment: Option<&RenderPassColorAttachmentDescriptorRef>) { + unsafe { + msg_send![self, setObject:attachment + atIndexedSubscript:index] + } + } +} + +pub enum MTLRenderPassDescriptor {} + +foreign_obj_type! { + type CType = MTLRenderPassDescriptor; + pub struct RenderPassDescriptor; + pub struct RenderPassDescriptorRef; +} + +impl RenderPassDescriptor { + pub fn new<'a>() -> &'a RenderPassDescriptorRef { + unsafe { + let class = class!(MTLRenderPassDescriptorInternal); + msg_send![class, renderPassDescriptor] + } + } +} + +impl RenderPassDescriptorRef { + pub fn color_attachments(&self) -> &RenderPassColorAttachmentDescriptorArrayRef { + unsafe { + msg_send![self, colorAttachments] + } + } + + pub fn depth_attachment(&self) -> Option<&RenderPassDepthAttachmentDescriptorRef> { + unsafe { + msg_send![self, depthAttachment] + } + } + + pub fn set_depth_attachment(&self, depth_attachment: Option<&RenderPassDepthAttachmentDescriptorRef>) { + unsafe { + msg_send![self, setDepthAttachment:depth_attachment] + } + } + + pub fn stencil_attachment(&self) -> Option<&RenderPassStencilAttachmentDescriptorRef> { + unsafe { + msg_send![self, stencilAttachment] + } + } + + pub fn set_stencil_attachment(&self, stencil_attachment: Option<&RenderPassStencilAttachmentDescriptorRef>) { + unsafe { + msg_send![self, setStencilAttachment:stencil_attachment] + } + } + + pub fn visibility_result_buffer(&self) -> Option<&BufferRef> { + unsafe { + msg_send![self, visibilityResultBuffer] + } + } + + pub fn set_visibility_result_buffer(&self, buffer: Option<&BufferRef>) { + unsafe { + msg_send![self, setVisibilityResultBuffer:buffer] + } + } + + pub fn render_target_array_length(&self) -> NSUInteger { + unsafe { + msg_send![self, renderTargetArrayLength] + } + } + + pub fn set_render_target_array_length(&self, length: NSUInteger) { + unsafe { + msg_send![self, setRenderTargetArrayLength:length] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/resource.rs b/third_party/cargo/vendor/metal-0.13.1/src/resource.rs new file mode 100644 index 0000000..d8a3c33 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/resource.rs @@ -0,0 +1,112 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use cocoa::foundation::NSUInteger; +use objc_foundation::{NSString, INSString}; + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum MTLPurgeableState { + KeepCurrent = 1, + NonVolatile = 2, + Volatile = 3, + Empty = 4, +} + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum MTLCPUCacheMode { + DefaultCache = 0, + WriteCombined = 1, +} + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum MTLStorageMode { + Shared = 0, + Managed = 1, + Private = 2, + Memoryless = 3, +} + +pub const MTLResourceCPUCacheModeShift: NSUInteger = 0; +pub const MTLResourceCPUCacheModeMask: NSUInteger = (0xf << MTLResourceCPUCacheModeShift); +pub const MTLResourceStorageModeShift: NSUInteger = 4; +pub const MTLResourceStorageModeMask: NSUInteger = (0xf << MTLResourceStorageModeShift); + +bitflags! { + #[allow(non_upper_case_globals)] + pub struct MTLResourceOptions: NSUInteger { + const CPUCacheModeDefaultCache = (MTLCPUCacheMode::DefaultCache as NSUInteger) << MTLResourceCPUCacheModeShift; + const CPUCacheModeWriteCombined = (MTLCPUCacheMode::WriteCombined as NSUInteger) << MTLResourceCPUCacheModeShift; + + const StorageModeShared = (MTLStorageMode::Shared as NSUInteger) << MTLResourceStorageModeShift; + const StorageModeManaged = (MTLStorageMode::Managed as NSUInteger) << MTLResourceStorageModeShift; + const StorageModePrivate = (MTLStorageMode::Private as NSUInteger) << MTLResourceStorageModeShift; + const StorageModeMemoryless = (MTLStorageMode::Memoryless as NSUInteger) << MTLResourceStorageModeShift; + } +} + +bitflags! { + pub struct MTLResourceUsage: NSUInteger { + const Read = 1 << 0; + const Write = 1 << 1; + const Sample = 1 << 2; + } +} + +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(C)] +pub struct MTLSizeAndAlign { + pub size: NSUInteger, + pub align: NSUInteger, +} + +pub enum MTLResource {} + +foreign_obj_type! { + type CType = MTLResource; + pub struct Resource; + pub struct ResourceRef; +} + +impl ResourceRef { + pub fn label(&self) -> &str { + unsafe { + let label: &NSString = msg_send![self, label]; + label.as_str() + } + } + + pub fn set_label(&self, label: &str) { + unsafe { + let nslabel = NSString::from_str(label); + msg_send![self, setLabel:nslabel] + } + } + + pub fn cpu_cache_mode(&self) -> MTLCPUCacheMode { + unsafe { + msg_send![self, cpuCacheMode] + } + } + + pub fn storage_mode(&self) -> MTLStorageMode { + unsafe { + msg_send![self, storageMode] + } + } + + pub fn set_purgeable_state(&self, state: MTLPurgeableState) -> MTLPurgeableState { + unsafe { + msg_send![self, setPurgeableState:state] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/sampler.rs b/third_party/cargo/vendor/metal-0.13.1/src/sampler.rs new file mode 100644 index 0000000..1c073b0 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/sampler.rs @@ -0,0 +1,161 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use cocoa::foundation::NSUInteger; + +use depthstencil::MTLCompareFunction; + +#[repr(u64)] +#[derive(Copy, Clone)] +pub enum MTLSamplerMinMagFilter { + Nearest = 0, + Linear = 1, +} + +#[repr(u64)] +#[derive(Copy, Clone)] +pub enum MTLSamplerMipFilter { + NotMipmapped = 0, + Nearest = 1, + Linear = 2, +} + +#[repr(u64)] +#[derive(Copy, Clone)] +pub enum MTLSamplerAddressMode { + ClampToEdge = 0, + MirrorClampToEdge = 1, + Repeat = 2, + MirrorRepeat = 3, + ClampToZero = 4, + ClampToBorderColor = 5 +} + +#[repr(u64)] +#[derive(Copy, Clone)] +pub enum MTLSamplerBorderColor { + TransparentBlack = 0, + OpaqueBlack = 1, + OpaqueWhite = 2, +} + +pub enum MTLSamplerDescriptor {} + +foreign_obj_type! { + type CType = MTLSamplerDescriptor; + pub struct SamplerDescriptor; + pub struct SamplerDescriptorRef; +} + + +impl SamplerDescriptor { + pub fn new() -> Self { + unsafe { + let class = class!(MTLSamplerDescriptor); + msg_send![class, new] + } + } +} + +impl SamplerDescriptorRef { + pub fn set_min_filter(&self, filter: MTLSamplerMinMagFilter) { + unsafe { + msg_send![self, setMinFilter:filter] + } + } + + pub fn set_mag_filter(&self, filter: MTLSamplerMinMagFilter) { + unsafe { + msg_send![self, setMagFilter:filter] + } + } + + pub fn set_mip_filter(&self, filter: MTLSamplerMipFilter) { + unsafe { + msg_send![self, setMipFilter:filter] + } + } + + pub fn set_address_mode_s(&self, mode: MTLSamplerAddressMode) { + unsafe { + msg_send![self, setSAddressMode:mode] + } + } + + pub fn set_address_mode_t(&self, mode: MTLSamplerAddressMode) { + unsafe { + msg_send![self, setTAddressMode:mode] + } + } + + pub fn set_address_mode_r(&self, mode: MTLSamplerAddressMode) { + unsafe { + msg_send![self, setRAddressMode:mode] + } + } + + pub fn set_max_anisotropy(&self, anisotropy: NSUInteger) { + unsafe { + msg_send![self, setMaxAnisotropy:anisotropy] + } + } + + pub fn set_compare_function(&self, func: MTLCompareFunction) { + unsafe { + msg_send![self, setCompareFunction:func] + } + } + + #[cfg(feature = "private")] + pub unsafe fn set_lod_bias(&self, bias: f32) { + msg_send![self, setLodBias:bias] + } + + pub fn set_lod_min_clamp(&self, clamp: f32) { + unsafe { + msg_send![self, setLodMinClamp:clamp] + } + } + + pub fn set_lod_max_clamp(&self, clamp: f32) { + unsafe { + msg_send![self, setLodMaxClamp:clamp] + } + } + + pub fn set_lod_average(&self, enable: bool) { + unsafe { + msg_send![self, setLodAverage:enable] + } + } + + pub fn set_normalized_coordinates(&self, enable: bool) { + unsafe { + msg_send![self, setNormalizedCoordinates:enable] + } + } + + pub fn set_support_argument_buffers(&self, enable: bool) { + unsafe { + msg_send![self, setSupportArgumentBuffers:enable] + } + } + + pub fn set_border_color(&self, color: MTLSamplerBorderColor) { + unsafe { + msg_send![self, setBorderColor:color] + } + } +} + +pub enum MTLSamplerState {} + +foreign_obj_type! { + type CType = MTLSamplerState; + pub struct SamplerState; + pub struct SamplerStateRef; +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/texture.rs b/third_party/cargo/vendor/metal-0.13.1/src/texture.rs new file mode 100644 index 0000000..ef0834c --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/texture.rs @@ -0,0 +1,373 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use super::*; + +use cocoa::foundation::{NSUInteger, NSRange}; +use objc::runtime::{YES, NO}; + +use libc; + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +pub enum MTLTextureType { + D1 = 0, + D1Array = 1, + D2 = 2, + D2Array = 3, + D2Multisample = 4, + Cube = 5, + CubeArray = 6, + D3 = 7, +} + +bitflags! { + pub struct MTLTextureUsage: NSUInteger { + const Unknown = 0x0000; + const ShaderRead = 0x0001; + const ShaderWrite = 0x0002; + const RenderTarget = 0x0004; + const PixelFormatView = 0x0010; + } +} + +pub enum MTLTextureDescriptor {} + +foreign_obj_type! { + type CType = MTLTextureDescriptor; + pub struct TextureDescriptor; + pub struct TextureDescriptorRef; +} + +impl TextureDescriptor { + pub fn new() -> Self { + unsafe { + let class = class!(MTLTextureDescriptor); + msg_send![class, new] + } + } +} + +impl TextureDescriptorRef { + pub fn texture_type(&self) -> MTLTextureType { + unsafe { + msg_send![self, textureType] + } + } + + pub fn set_texture_type(&self, texture_type: MTLTextureType) { + unsafe { + msg_send![self, setTextureType:texture_type] + } + } + + pub fn pixel_format(&self) -> MTLPixelFormat { + unsafe { + msg_send![self, pixelFormat] + } + } + + pub fn set_pixel_format(&self, pixel_format: MTLPixelFormat) { + unsafe { + msg_send![self, setPixelFormat:pixel_format] + } + } + + pub fn width(&self) -> NSUInteger { + unsafe { + msg_send![self, width] + } + } + + pub fn set_width(&self, width: NSUInteger) { + unsafe { + msg_send![self, setWidth:width] + } + } + + pub fn height(&self) -> NSUInteger { + unsafe { + msg_send![self, height] + } + } + + pub fn set_height(&self, height: NSUInteger) { + unsafe { + msg_send![self, setHeight:height] + } + } + + pub fn depth(&self) -> NSUInteger { + unsafe { + msg_send![self, depth] + } + } + + pub fn set_depth(&self, depth: NSUInteger) { + unsafe { + msg_send![self, setDepth:depth] + } + } + + pub fn mipmap_level_count(&self) -> NSUInteger { + unsafe { + msg_send![self, mipmapLevelCount] + } + } + + pub fn set_mipmap_level_count(&self, count: NSUInteger) { + unsafe { + msg_send![self, setMipmapLevelCount:count] + } + } + + pub fn sample_count(&self) -> NSUInteger { + unsafe { + msg_send![self, sampleCount] + } + } + + pub fn set_sample_count(&self, count: NSUInteger) { + unsafe { + msg_send![self, setSampleCount:count] + } + } + + pub fn array_length(&self) -> NSUInteger { + unsafe { + msg_send![self, arrayLength] + } + } + + pub fn set_array_length(&self, length: NSUInteger) { + unsafe { + msg_send![self, setArrayLength:length] + } + } + + pub fn resource_options(&self) -> MTLResourceOptions { + unsafe { + msg_send![self, resourceOptions] + } + } + + pub fn set_resource_options(&self, options: MTLResourceOptions) { + unsafe { + msg_send![self, setResourceOptions:options] + } + } + + pub fn cpu_cache_mode(&self) -> MTLCPUCacheMode { + unsafe { + msg_send![self, cpuCacheMode] + } + } + + pub fn set_cpu_cache_mode(&self, mode: MTLCPUCacheMode) { + unsafe { + msg_send![self, setCpuCacheMode:mode] + } + } + + pub fn storage_mode(&self) -> MTLStorageMode { + unsafe { + msg_send![self, storageMode] + } + } + + pub fn set_storage_mode(&self, mode: MTLStorageMode) { + unsafe { + msg_send![self, setStorageMode:mode] + } + } + + pub fn usage(&self) -> MTLTextureUsage { + unsafe { + msg_send![self, usage] + } + } + + pub fn set_usage(&self, usage: MTLTextureUsage) { + unsafe { + msg_send![self, setUsage:usage] + } + } +} + +pub enum MTLTexture {} + +foreign_obj_type! { + type CType = MTLTexture; + pub struct Texture; + pub struct TextureRef; + type ParentType = ResourceRef; +} + +impl TextureRef { + #[deprecated(since="0.13.0")] + pub fn root_resource(&self) -> Option<&ResourceRef> { + unsafe { + msg_send![self, rootResource] + } + } + + pub fn parent_texture(&self) -> Option<&TextureRef> { + unsafe { + msg_send![self, parentTexture] + } + } + + pub fn parent_relative_level(&self) -> NSUInteger { + unsafe { + msg_send![self, parentRelativeLevel] + } + } + + pub fn parent_relative_slice(&self) -> NSUInteger { + unsafe { + msg_send![self, parentRelativeSlice] + } + } + + pub fn buffer(&self) -> Option<&BufferRef> { + unsafe { + msg_send![self, buffer] + } + } + + pub fn buffer_offset(&self) -> NSUInteger { + unsafe { + msg_send![self, bufferOffset] + } + } + + pub fn buffer_stride(&self) -> NSUInteger { + unsafe { + msg_send![self, bufferBytesPerRow] + } + } + + pub fn texture_type(&self) -> MTLTextureType { + unsafe { + msg_send![self, textureType] + } + } + + pub fn pixel_format(&self) -> MTLPixelFormat { + unsafe { + msg_send![self, pixelFormat] + } + } + + pub fn width(&self) -> NSUInteger { + unsafe { + msg_send![self, width] + } + } + + pub fn height(&self) -> NSUInteger { + unsafe { + msg_send![self, height] + } + } + + pub fn depth(&self) -> NSUInteger { + unsafe { + msg_send![self, depth] + } + } + + pub fn mipmap_level_count(&self) -> NSUInteger { + unsafe { + msg_send![self, mipmapLevelCount] + } + } + + pub fn sample_count(&self) -> NSUInteger { + unsafe { + msg_send![self, sampleCount] + } + } + + pub fn array_length(&self) -> NSUInteger { + unsafe { + msg_send![self, arrayLength] + } + } + + pub fn usage(&self) -> MTLTextureUsage { + unsafe { + msg_send![self, usage] + } + } + + pub fn framebuffer_only(&self) -> bool { + unsafe { + match msg_send![self, framebufferOnly] { + YES => true, + NO => false, + _ => unreachable!() + } + } + } + + pub fn get_bytes(&self, bytes: *mut libc::c_void, region: MTLRegion, mipmap_level: NSUInteger, stride: NSUInteger) { + unsafe { + msg_send![self, getBytes:bytes + bytesPerRow:stride + fromRegion:region + mipmapLevel:mipmap_level] + } + } + + pub fn get_bytes_in_slice(&self, bytes: *mut libc::c_void, region: MTLRegion, mipmap_level: NSUInteger, stride: NSUInteger, image_stride: NSUInteger, slice: NSUInteger) { + unsafe { + msg_send![self, getBytes:bytes + bytesPerRow:stride + bytesPerImage:image_stride + fromRegion:region + mipmapLevel:mipmap_level + slice:slice] + } + } + + pub fn replace_region(&self, region: MTLRegion, mipmap_level: NSUInteger, stride: NSUInteger, bytes: *const libc::c_void) { + unsafe { + msg_send![self, replaceRegion:region + mipmapLevel:mipmap_level + withBytes:bytes + bytesPerRow:stride] + } + } + + pub fn replace_region_in_slice(&self, region: MTLRegion, mipmap_level: NSUInteger, image_stride: NSUInteger, stride: NSUInteger, slice: NSUInteger, bytes: *const libc::c_void) { + unsafe { + msg_send![self, replaceRegion:region + mipmapLevel:mipmap_level + slice:slice + withBytes:bytes + bytesPerRow:stride + bytesPerImage:image_stride] + } + } + + pub fn new_texture_view(&self, pixel_format: MTLPixelFormat) -> Texture { + unsafe { + msg_send![self, newTextureViewWithPixelFormat:pixel_format] + } + } + + pub fn new_texture_view_from_slice(&self, pixel_format: MTLPixelFormat, texture_type: MTLTextureType, mipmap_levels: NSRange, slices: NSRange) -> Texture { + unsafe { + msg_send![self, newTextureViewWithPixelFormat:pixel_format + textureType:texture_type + levels:mipmap_levels + slices:slices] + } + } +} diff --git a/third_party/cargo/vendor/metal-0.13.1/src/types.rs b/third_party/cargo/vendor/metal-0.13.1/src/types.rs new file mode 100644 index 0000000..6f4cf26 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/types.rs @@ -0,0 +1,32 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use cocoa::foundation::{NSUInteger}; + +#[repr(C)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub struct MTLOrigin { + pub x: NSUInteger, + pub y: NSUInteger, + pub z: NSUInteger +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub struct MTLSize { + pub width: NSUInteger, + pub height: NSUInteger, + pub depth: NSUInteger +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub struct MTLRegion { + pub origin: MTLOrigin, + pub size: MTLSize +} + diff --git a/third_party/cargo/vendor/metal-0.13.1/src/vertexdescriptor.rs b/third_party/cargo/vendor/metal-0.13.1/src/vertexdescriptor.rs new file mode 100644 index 0000000..49d0e23 --- /dev/null +++ b/third_party/cargo/vendor/metal-0.13.1/src/vertexdescriptor.rs @@ -0,0 +1,276 @@ +// Copyright 2016 GFX developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use cocoa::foundation::NSUInteger; + +#[cfg(feature = "private")] +use libc; + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub enum MTLVertexFormat { + Invalid = 0, + UChar2 = 1, + UChar3 = 2, + UChar4 = 3, + Char2 = 4, + Char3 = 5, + Char4 = 6, + UChar2Normalized = 7, + UChar3Normalized = 8, + UChar4Normalized = 9, + Char2Normalized = 10, + Char3Normalized = 11, + Char4Normalized = 12, + UShort2 = 13, + UShort3 = 14, + UShort4 = 15, + Short2 = 16, + Short3 = 17, + Short4 = 18, + UShort2Normalized = 19, + UShort3Normalized = 20, + UShort4Normalized = 21, + Short2Normalized = 22, + Short3Normalized = 23, + Short4Normalized = 24, + Half2 = 25, + Half3 = 26, + Half4 = 27, + Float = 28, + Float2 = 29, + Float3 = 30, + Float4 = 31, + Int = 32, + Int2 = 33, + Int3 = 34, + Int4 = 35, + UInt = 36, + UInt2 = 37, + UInt3 = 38, + UInt4 = 39, + Int1010102Normalized = 40, + UInt1010102Normalized = 41, + UChar4Normalized_BGRA = 42, + UChar = 45, + Char = 46, + UCharNormalized = 47, + CharNormalized = 48, + UShort = 49, + Short = 50, + UShortNormalized = 51, + ShortNormalized = 52, + Half = 53, +} + +#[repr(u64)] +pub enum MTLVertexStepFunction { + Constant = 0, + PerVertex = 1, + PerInstance = 2, + PerPatch = 3, + PerPatchControlPoint = 4, +} + +pub enum MTLVertexBufferLayoutDescriptor {} + +foreign_obj_type! { + type CType = MTLVertexBufferLayoutDescriptor; + pub struct VertexBufferLayoutDescriptor; + pub struct VertexBufferLayoutDescriptorRef; +} + +impl VertexBufferLayoutDescriptor { + pub fn new () -> Self { + unsafe { + let class = class!(MTLVertexBufferLayoutDescriptor); + msg_send![class, new] + } + } +} + +impl VertexBufferLayoutDescriptorRef { + pub fn stride(&self) -> NSUInteger { + unsafe { + msg_send![self, stride] + } + } + + pub fn set_stride(&self, stride: NSUInteger) { + unsafe { + msg_send![self, setStride:stride] + } + } + + pub fn step_function(&self) -> MTLVertexStepFunction { + unsafe { + msg_send![self, stepFunction] + } + } + + pub fn set_step_function(&self, func: MTLVertexStepFunction) { + unsafe { + msg_send![self, setStepFunction:func] + } + } + + pub fn step_rate(&self) -> NSUInteger { + unsafe { + msg_send![self, stepRate] + } + } + + pub fn set_step_rate(&self, step_rate: NSUInteger) { + unsafe { + msg_send![self, setStepRate:step_rate] + } + } +} + +pub enum MTLVertexBufferLayoutDescriptorArray {} + +foreign_obj_type! { + type CType = MTLVertexBufferLayoutDescriptorArray; + pub struct VertexBufferLayoutDescriptorArray; + pub struct VertexBufferLayoutDescriptorArrayRef; +} + +impl VertexBufferLayoutDescriptorArrayRef { + pub fn object_at(&self, index: usize) -> Option<&VertexBufferLayoutDescriptorRef> { + unsafe { + msg_send![self, objectAtIndexedSubscript:index] + } + } + + pub fn set_object_at(&self, index: usize, layout: Option<&VertexBufferLayoutDescriptorRef>) { + unsafe { + msg_send![self, setObject:layout + atIndexedSubscript:index] + } + } +} + +pub enum MTLVertexAttributeDescriptor {} + +foreign_obj_type! { + type CType = MTLVertexAttributeDescriptor; + pub struct VertexAttributeDescriptor; + pub struct VertexAttributeDescriptorRef; +} + +impl VertexAttributeDescriptor { + pub fn new() -> Self { + unsafe { + let class = class!(MTLVertexAttributeDescriptor); + msg_send![class, new] + } + } +} + +impl VertexAttributeDescriptorRef { + pub fn format(&self) -> MTLVertexFormat { + unsafe { + msg_send![self, format] + } + } + + pub fn set_format(&self, format: MTLVertexFormat) { + unsafe { + msg_send![self, setFormat:format] + } + } + + pub fn offset(&self) -> NSUInteger { + unsafe { + msg_send![self, offset] + } + } + + pub fn set_offset(&self, offset: NSUInteger) { + unsafe { + msg_send![self, setOffset:offset] + } + } + + pub fn buffer_index(&self) -> NSUInteger { + unsafe { + msg_send![self, bufferIndex] + } + } + + pub fn set_buffer_index(&self, index: NSUInteger) { + unsafe { + msg_send![self, setBufferIndex:index] + } + } +} + +pub enum MTLVertexAttributeDescriptorArray {} + +foreign_obj_type! { + type CType = MTLVertexAttributeDescriptorArray; + pub struct VertexAttributeDescriptorArray; + pub struct VertexAttributeDescriptorArrayRef; +} + +impl VertexAttributeDescriptorArrayRef { + pub fn object_at(&self, index: usize) -> Option<&VertexAttributeDescriptorRef> { + unsafe { + msg_send![self, objectAtIndexedSubscript:index] + } + } + + pub fn set_object_at(&self, index: usize, attribute: Option<&VertexAttributeDescriptorRef>) { + unsafe { + msg_send![self, setObject:attribute + atIndexedSubscript:index] + } + } +} + +pub enum MTLVertexDescriptor {} + +foreign_obj_type! { + type CType = MTLVertexDescriptor; + pub struct VertexDescriptor; + pub struct VertexDescriptorRef; +} + +impl VertexDescriptor { + pub fn new<'a>() -> &'a VertexDescriptorRef { + unsafe { + let class = class!(MTLVertexDescriptor); + msg_send![class, vertexDescriptor] + } + } +} + +impl VertexDescriptorRef { + pub fn layouts(&self) -> &VertexBufferLayoutDescriptorArrayRef { + unsafe { + msg_send![self, layouts] + } + } + + pub fn attributes(&self) -> &VertexAttributeDescriptorArrayRef { + unsafe { + msg_send![self, attributes] + } + } + + #[cfg(feature = "private")] + pub unsafe fn serialize_descriptor(&self) -> *mut libc::c_void { + msg_send![self, newSerializedDescriptor] + } + + pub fn reset(&self) { + unsafe { + msg_send![self, reset] + } + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/.cargo-checksum.json b/third_party/cargo/vendor/nix-0.14.1/.cargo-checksum.json new file mode 100644 index 0000000..c39b1c8 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"e3f15d12e1c760e00e08b0545b2be3266c0ed13ee331268b5a18534203777044","CONTRIBUTING.md":"a9101e3d1487170d691d5f062ff49a433c167582ac8984dd41a744be92652f74","CONVENTIONS.md":"e150ce43c1d188c392c1a3bf7f2e08e3cf84906705c7bef43f319037d29ea385","Cargo.toml":"bf11a3f9962cdb4e34307707952cf0deaaa7371abb0541f31747800dd09e7cea","LICENSE":"66e3ee1fa7f909ad3c612d556f2a0cdabcd809ad6e66f3b0605015ac64841b70","README.md":"6b14187b1cbc7655f788f43f5abe7d33d1c0fa117232981c4f4260a6eb3794ff","build.rs":"14c9c678c33f5894509da47f77d6a326b14aecb4190ce87a24cce98687ca63b2","src/dir.rs":"4cab6057561b0cd410f8592b025897e97ee8ec9aeeef3551e5f4f49eb6d51595","src/errno.rs":"a009ccf18b45c0a4c9319c65b0dc5bc322d9ad43cfe462ec4661559f44162451","src/errno_dragonfly.c":"a857e47b114acb85fddcb252a610ab5734d225c26b7bedd7c35d7789d46c8526","src/fcntl.rs":"1086d2de9c9331724dcb65dbb79878daa21238fe66f0d6ecaad9082caf2bfe89","src/features.rs":"96dddb379462eecdacbbf555b57ae67091392aca8cc9c2a650fce6e58566a8d8","src/ifaddrs.rs":"8316679172dfc5068764fc56be66d5a0ea335759bb4f49dd5cb73f5ef637e64c","src/kmod.rs":"4d8a695d3d761f351a39d654303a1bd168e74295b7d142b918737e355b24f34d","src/lib.rs":"87395fe92eb203430b4567e4b0ba6ec3a43a275b399fc39182bf6632983f0795","src/macros.rs":"aec27fa0fd98900913fada926c9a4581cd28f2640e3a7b5480707f923c9200f8","src/mount.rs":"cdf5db8409017483132db9d7493b5d6cc96df5560d0fa5ad8f385aff72db10ca","src/mqueue.rs":"8fb7cf968eae132e920eafdb0666f24488e90e79bf4353ccbd86ac7854c3f00d","src/net/if_.rs":"f7e02076fcf3cadf3fdf141884c9bd2c468a7047ba60bc490f0057df802b53ce","src/net/mod.rs":"577f70170e53d4a6de1abb70bf8f1031ec3e65c0e63ef5fcf05c907125e7ac17","src/poll.rs":"ad57f917800ec84ac884d965f0912ead233734380318666b61424f4023fef9dd","src/pty.rs":"5222a2430974f650765d3a2ff24b86d93a080c9b9e46d588548afa0c9bde5577","src/sched.rs":"0e69f0fbf09b079d1ed07bddd306ea52b9a5a6df5850cea3422949c51a48eeec","src/sys/aio.rs":"44eedf4c5e61f372f6a97a8c5050fce16327fcf666ef1ac1ea242a029b2735e6","src/sys/epoll.rs":"62e42d4860316ec0ebec19ad4b2648980162d3db725219c60bfde0034e61535e","src/sys/event.rs":"9ab3069f566c229fbe54f594b950744da602c2c57a08c531a678ae7368e32549","src/sys/eventfd.rs":"08008cf3dc64c2216847c02c0dd8d7189cf08edbaafe35ba2c57c053fde09ef4","src/sys/inotify.rs":"687c8417d737939aa93f805d6003afc4f84f50828b1bd9429ef5d00bef0e0955","src/sys/ioctl/bsd.rs":"56ca6ecf5f7cfb566f4f3ba589fcc778f747a517dd45e13780981922e6215344","src/sys/ioctl/linux.rs":"6cfbdff4dbfa1a3782acdedebe89ffa9f000fdfc4ab68cb46f52890ebc1c6f2d","src/sys/ioctl/mod.rs":"20bc3cf1fcbbc7c31e4d507baa4e576a793ea42fb33618d2e7afeda730c4324f","src/sys/memfd.rs":"11cd93c867fdbdbc9588cecb94268691de42b2ef2a38fe33525be7c7f60c85d5","src/sys/mman.rs":"f77d28611a7ff3bf62784a3c4f26d7d79969395b1d9bbc6ff15e734f52dc404f","src/sys/mod.rs":"e4db2257b9317686572448fbc5eea2b0952513e50b61f31277de9597c9d1e590","src/sys/pthread.rs":"cfa9ccd6f3b86c0c3fe012773c9c82a7813b298c2f20f8ab629781db627ce56b","src/sys/ptrace/bsd.rs":"8a7eacfc172b55763ae32109bf9b252669ba68b72cd5122f7504eb35c0c08345","src/sys/ptrace/linux.rs":"f09b45148004f4b28d8503c397a8d112d31046c98e68335bf4e89425d5b33f07","src/sys/ptrace/mod.rs":"671a6ccac955e75d5998f7e53ffc45ed4c7b6522a0f24a0937d60141f692dd39","src/sys/quota.rs":"4e65e0d25f42103ae4d4d0b96159bfb1de940f6a54fb90ec566c11ea24b7097d","src/sys/reboot.rs":"fde9da27c2928f7026231430fa14fec2058df4e49a0aeda2a237a60524f11241","src/sys/select.rs":"d8d15e0a36f76729e53f2cc036748c9e1279b2669e4c9e7a2ff0cbc76ba65a9f","src/sys/sendfile.rs":"1175a1c0507874e5f15af472ef0d346b957d5c791e3cd86ba7bf176219f96725","src/sys/signal.rs":"95358205fa124f5a49d9f6baf385db664b9807c289f85a844b45d2d189cf52bc","src/sys/signalfd.rs":"bfcfce619bf199e50f9cc80a3eb778d48474a015cfdafc64a0c3517373a225a9","src/sys/socket/addr.rs":"3ffefcafb425d2fd354538fd5927bda1ea2b89c379a1ec38405816b140bb4fbc","src/sys/socket/mod.rs":"fcea5717882d4fb200bc11dd1fa1d56156b4d2ae7935ba62b4b029998de0ba5b","src/sys/socket/sockopt.rs":"b65bfae43c081a05dbfa07966c5113b9852060b562fa090c08b4684fd57b1c51","src/sys/stat.rs":"352c87619e4e2fc370c52cc084b9be6f268fd8b60ab0a1d30c81cb6bf6b416f5","src/sys/statfs.rs":"39f276bb13133679a79134b998b6761f95ce22ae963eae57dc4a070cd31d36ef","src/sys/statvfs.rs":"889213d0c512fde373c2a9dbee7f33b15d179f6f99677899b861780437a22493","src/sys/sysinfo.rs":"cecc8134bc8a1ed8068b37b856da9bd52625e48a10ef08b379fa6f75e6a6de4f","src/sys/termios.rs":"ea01fb2d33095176b39e8faae46b77e72bccd246f29aed5efed5010eb6ad3333","src/sys/time.rs":"ede9a05b8d12ced62ee5a9f42448962d5af890edb26bbd45219193bd2043ad99","src/sys/uio.rs":"eef056f1dde66fbacf49973dde8c2f4e741c87ffd360f3a8ed62714b828173d3","src/sys/utsname.rs":"8fc57acc3947486f1809b21884eec047592297fb1dd739b48f6736f77c84bab9","src/sys/wait.rs":"9ce0ab7e4925bb5af67097c2020ed5ec5021e0b9701843387b31509a6bf5fa4c","src/ucontext.rs":"a03daf21919a091ee69dc0c51acc38bd2a96ac7fc828fae8df3b4d480d346e74","src/unistd.rs":"8bb5fd170c6fa5777d6e26540ef28162dea26a718654307fe96684ffa3df9b6d","test/sys/mod.rs":"e0821cbc289ad952f17229609c7de4282cca1e44cd13e1a7494a6378ecbc12f8","test/sys/test_aio.rs":"b2544bfb321ca7fbed276ee637c769fb438156d14666cdc1e1d547b3514a44e3","test/sys/test_aio_drop.rs":"30dd1d238269d00381fa50f6d3cb2b13794b7cceb9f6455f3878fcbffa9aa62d","test/sys/test_epoll.rs":"35093d0cb1096a934dfc4f6efc737eadc4bdc2e2134d2a879061374a51b10c97","test/sys/test_inotify.rs":"a4f804bcf414b6635d9863c8534769a609009c451c3476cc839cdc30c439b3b1","test/sys/test_ioctl.rs":"eea690ed386da0a666df5eb23a417421fddb99dc8e39556f63b30969bb6cf779","test/sys/test_lio_listio_resubmit.rs":"203a583313542593148f375b087ae30620222a745680173fa98fc448d1e5ae7f","test/sys/test_pthread.rs":"3890e5ecbf2082e0d05d102cc9cec6e76ede3c15f250d104e3483b1c1c3400b1","test/sys/test_ptrace.rs":"4e8d5dff5fe6bc56e4ae53bdfd10f5e8ea567d8099576d1c690cf7a6b2bc955f","test/sys/test_select.rs":"bdb20211fc6ec1e3f186337eac51e08757acb6901d307d67c71bf9011f0d54bd","test/sys/test_signal.rs":"84ae63c2baa49eebeabe5bbd347b9c5417e14ba97f342719d753dc1c1c768d60","test/sys/test_signalfd.rs":"71b5d6d782283f6db64ca90f7fb06617faec71091d59d2587e41bbc9d8c43d5c","test/sys/test_socket.rs":"c6d16d06d2e44a0de8e75c234622aa0f0e9ed11a21ac223ae9bd14dad07c08fc","test/sys/test_sockopt.rs":"b3d386c8279f86bf9439c772317bafcdba5630fa806c8319e87ddac0ccfa3a03","test/sys/test_sysinfo.rs":"1e1bea9130fe38ccb07cd0ad7334c7be1e45efc33f7656a5973f8cad7126f225","test/sys/test_termios.rs":"fa4be3ade859b527bf33408f85a6f57b127917cf5f2afb662d09f6019d07913a","test/sys/test_uio.rs":"9da234e3bd5003fd200cc37c4a5be147ecda1a7670feb1d505f23d646d3e1c57","test/sys/test_wait.rs":"e6c5147e213daa93892cd828f53214995d2e019ff2372cc48d85ce9b93d26ec9","test/test.rs":"974e2424b7cdb9d962a0e93cd28a02a30cef58e05c844004dffeb3ba9468bec3","test/test_dir.rs":"5d137a62f11d1a4993b4bb35dccc38a4c4416b7da374887f2335a9895b4fdee4","test/test_fcntl.rs":"fc46811761cf0d6d3236692cfee37f863acf65313014292c06bf76a638299026","test/test_kmod/hello_mod/Makefile":"0219f7bce0603f97d997fb377ca071966c90333ecc665e78a54dfeb97a9c811b","test/test_kmod/hello_mod/hello.c":"bcac6b19c5bd807e1f3878c15e426acc85785a8ade9840c3bb4d068635c9188c","test/test_kmod/mod.rs":"f4754f028402a8ba788c87686288424cd3784e77c7eb5d96682ef491b1dd5262","test/test_mount.rs":"78ddc657f5098360c764fffa3a7d844503e4b6b65b44bfd42d9aa9045b415cb6","test/test_mq.rs":"6fe92ae18ce203f8744e1487bb616f50dd1c5c898b1311d57ac7598560bae8eb","test/test_net.rs":"ec6d580b87292519d514b0236bdd5abdd576fcf4835cfe49ed1ddb47c5f1aea3","test/test_nix_path.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test/test_poll.rs":"5238731d0d3cfa5a0f7dabf236ca8ca85e4cf21f29cef5299b2ffc3a979c57fd","test/test_pty.rs":"be04f99904fa47b60400c2bd156a388b73df4b9aec2eebf13df7dcdfc9aacf45","test/test_ptymaster_drop.rs":"5cfbbb79551c205ab510c2d4ef497bf937ceac9151fbe2f2e543d6515e406990","test/test_sendfile.rs":"e0cbabbd34052ccaa03d6555d5631686aa076728f6378ee90f7ecec68f891144","test/test_stat.rs":"9916d19cdcdd2f52d62bf26683b0edeb3ed0a13277dabb089860e2cd6993443f","test/test_unistd.rs":"feda0dc868db132ca7d14677a038efbb1f2cac4c67d54efa0cb93e2dfb22251d"},"package":"6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce"} \ No newline at end of file diff --git a/third_party/cargo/vendor/nix-0.14.1/BUILD b/third_party/cargo/vendor/nix-0.14.1/BUILD new file mode 100644 index 0000000..4fca269 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/BUILD @@ -0,0 +1,52 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "nix", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/bitflags-1.2.1:bitflags", + "//third_party/cargo/vendor/cfg-if-0.1.10:cfg_if", + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/void-1.0.2:void", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.14.1", + crate_features = [ + ], +) + +# Unsupported target "test" with type "test" omitted +# Unsupported target "test-aio-drop" with type "test" omitted +# Unsupported target "test-lio-listio-resubmit" with type "test" omitted +# Unsupported target "test-mount" with type "test" omitted +# Unsupported target "test-ptymaster-drop" with type "test" omitted diff --git a/third_party/cargo/vendor/nix-0.14.1/CHANGELOG.md b/third_party/cargo/vendor/nix-0.14.1/CHANGELOG.md new file mode 100644 index 0000000..912b43e --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/CHANGELOG.md @@ -0,0 +1,708 @@ +# Change Log + +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](http://semver.org/). + +## [Unreleased] +### Added +### Changed +### Fixed +### Removed + +## [0.14.1] - 2019-06-06 +### Added +- Macros exported by `nix` may now be imported via `use` on the Rust 2018 + edition without importing helper macros on Linux targets. + ([#1066](https://github.com/nix-rust/nix/pull/1066)) + + For example, in Rust 2018, the `ioctl_read_bad!` macro can now be imported + without importing the `convert_ioctl_res!` macro. + + ```rust + use nix::ioctl_read_bad; + + ioctl_read_bad!(tcgets, libc::TCGETS, libc::termios); + ``` + +### Changed +- Changed some public types from reexports of libc types like `uint32_t` to the + native equivalents like `u32.` + ([#1072](https://github.com/nix-rust/nix/pull/1072/commits)) + +### Fixed +- Fix the build on Android and Linux/mips with recent versions of libc. + ([#1072](https://github.com/nix-rust/nix/pull/1072/commits)) + +### Removed + +## [0.14.0] - 2019-05-21 +### Added +- Add IP_RECVIF & IP_RECVDSTADDR. Enable IP_PKTINFO and IP6_PKTINFO on netbsd/openbsd. + ([#1002](https://github.com/nix-rust/nix/pull/1002)) +- Added `inotify_init1`, `inotify_add_watch` and `inotify_rm_watch` wrappers for + Android and Linux. ([#1016](https://github.com/nix-rust/nix/pull/1016)) +- Add `ALG_SET_IV`, `ALG_SET_OP` and `ALG_SET_AEAD_ASSOCLEN` control messages and `AF_ALG` + socket types on Linux and Android ([#1031](https://github.com/nix-rust/nix/pull/1031)) +- Add killpg + ([#1034](https://github.com/nix-rust/nix/pull/1034)) +- Added ENOTSUP errno support for Linux and Android. + ([#969](https://github.com/nix-rust/nix/pull/969)) +- Add several errno constants from OpenBSD 6.2 + ([#1036](https://github.com/nix-rust/nix/pull/1036)) +- Added `from_std` and `to_std` methods for `sys::socket::IpAddr` + ([#1043](https://github.com/nix-rust/nix/pull/1043)) +- Added `nix::unistd:seteuid` and `nix::unistd::setegid` for those platforms that do + not support `setresuid` nor `setresgid` respectively. + ([#1044](https://github.com/nix-rust/nix/pull/1044)) +- Added a `access` wrapper + ([#1045](https://github.com/nix-rust/nix/pull/1045)) +- Add `forkpty` + ([#1042](https://github.com/nix-rust/nix/pull/1042)) +- Add `sched_yield` + ([#1050](https://github.com/nix-rust/nix/pull/1050)) + +### Changed +- `PollFd` event flags renamed to `PollFlags` ([#1024](https://github.com/nix-rust/nix/pull/1024/)) +- `recvmsg` now returns an Iterator over `ControlMessageOwned` objects rather + than `ControlMessage` objects. This is sadly not backwards-compatible. Fix + code like this: + ```rust + if let ControlMessage::ScmRights(&fds) = cmsg { + ``` + + By replacing it with code like this: + ```rust + if let ControlMessageOwned::ScmRights(fds) = cmsg { + ``` + ([#1020](https://github.com/nix-rust/nix/pull/1020)) +- Replaced `CmsgSpace` with the `cmsg_space` macro. + ([#1020](https://github.com/nix-rust/nix/pull/1020)) + +### Fixed +- Fixed multiple bugs when using `sendmsg` and `recvmsg` with ancillary control messages + ([#1020](https://github.com/nix-rust/nix/pull/1020)) +- Macros exported by `nix` may now be imported via `use` on the Rust 2018 + edition without importing helper macros for BSD targets. + ([#1041](https://github.com/nix-rust/nix/pull/1041)) + + For example, in Rust 2018, the `ioctl_read_bad!` macro can now be imported + without importing the `convert_ioctl_res!` macro. + + ```rust + use nix::ioctl_read_bad; + + ioctl_read_bad!(tcgets, libc::TCGETS, libc::termios); + ``` + +### Removed +- `Daemon`, `NOTE_REAP`, and `NOTE_EXIT_REPARENTED` are now deprecated on OSX + and iOS. + ([#1033](https://github.com/nix-rust/nix/pull/1033)) +- `PTRACE_GETREGS`, `PTRACE_SETREGS`, `PTRACE_GETFPREGS`, and + `PTRACE_SETFPREGS` have been removed from some platforms where they never + should've been defined in the first place. + ([#1055](https://github.com/nix-rust/nix/pull/1055)) + +## [0.13.0] - 2019-01-15 +### Added +- Added PKTINFO(V4) & V6PKTINFO cmsg support - Android/FreeBSD/iOS/Linux/MacOS. + ([#990](https://github.com/nix-rust/nix/pull/990)) +- Added support of CString type in `setsockopt`. + ([#972](https://github.com/nix-rust/nix/pull/972)) +- Added option `TCP_CONGESTION` in `setsockopt`. + ([#972](https://github.com/nix-rust/nix/pull/972)) +- Added `symlinkat` wrapper. + ([#997](https://github.com/nix-rust/nix/pull/997)) +- Added `ptrace::{getregs, setregs}`. + ([#1010](https://github.com/nix-rust/nix/pull/1010)) +- Added `nix::sys::signal::signal`. + ([#817](https://github.com/nix-rust/nix/pull/817)) +- Added an `mprotect` wrapper. + ([#991](https://github.com/nix-rust/nix/pull/991)) + +### Changed +### Fixed +- `lutimes` never worked on OpenBSD as it is not implemented on OpenBSD. It has + been removed. ([#1000](https://github.com/nix-rust/nix/pull/1000)) +- `fexecve` never worked on NetBSD or on OpenBSD as it is not implemented on + either OS. It has been removed. ([#1000](https://github.com/nix-rust/nix/pull/1000)) + +### Removed + +## [0.12.0] 2018-11-28 + +### Added +- Added `FromStr` and `Display` impls for `nix::sys::Signal` + ([#884](https://github.com/nix-rust/nix/pull/884)) +- Added a `sync` wrapper. + ([#961](https://github.com/nix-rust/nix/pull/961)) +- Added a `sysinfo` wrapper. + ([#922](https://github.com/nix-rust/nix/pull/922)) +- Support the `SO_PEERCRED` socket option and the `UnixCredentials` type on all Linux and Android targets. + ([#921](https://github.com/nix-rust/nix/pull/921)) +- Added support for `SCM_CREDENTIALS`, allowing to send process credentials over Unix sockets. + ([#923](https://github.com/nix-rust/nix/pull/923)) +- Added a `dir` module for reading directories (wraps `fdopendir`, `readdir`, and `rewinddir`). + ([#916](https://github.com/nix-rust/nix/pull/916)) +- Added `kmod` module that allows loading and unloading kernel modules on Linux. + ([#930](https://github.com/nix-rust/nix/pull/930)) +- Added `futimens` and `utimesat` wrappers ([#944](https://github.com/nix-rust/nix/pull/944)), + an `lutimes` wrapper ([#967](https://github.com/nix-rust/nix/pull/967)), + and a `utimes` wrapper ([#946](https://github.com/nix-rust/nix/pull/946)). +- Added `AF_UNSPEC` wrapper to `AddressFamily` ([#948](https://github.com/nix-rust/nix/pull/948)) +- Added the `mode_t` public alias within `sys::stat`. + ([#954](https://github.com/nix-rust/nix/pull/954)) +- Added a `truncate` wrapper. + ([#956](https://github.com/nix-rust/nix/pull/956)) +- Added a `fchownat` wrapper. + ([#955](https://github.com/nix-rust/nix/pull/955)) +- Added support for `ptrace` on BSD operating systems ([#949](https://github.com/nix-rust/nix/pull/949)) +- Added `ptrace` functions for reads and writes to tracee memory and ptrace kill + ([#949](https://github.com/nix-rust/nix/pull/949)) ([#958](https://github.com/nix-rust/nix/pull/958)) +- Added a `acct` wrapper module for enabling and disabling process accounting + ([#952](https://github.com/nix-rust/nix/pull/952)) +- Added the `time_t` and `suseconds_t` public aliases within `sys::time`. + ([#968](https://github.com/nix-rust/nix/pull/968)) +- Added `unistd::execvpe` for Haiku, Linux and OpenBSD + ([#975](https://github.com/nix-rust/nix/pull/975)) +- Added `Error::as_errno`. + ([#977](https://github.com/nix-rust/nix/pull/977)) + +### Changed +- Increased required Rust version to 1.24.1 + ([#900](https://github.com/nix-rust/nix/pull/900)) + ([#966](https://github.com/nix-rust/nix/pull/966)) + +### Fixed +- Made `preadv` take immutable slice of IoVec. + ([#914](https://github.com/nix-rust/nix/pull/914)) +- Fixed passing multiple file descriptors over Unix Sockets. + ([#918](https://github.com/nix-rust/nix/pull/918)) + +### Removed + +## [0.11.0] 2018-06-01 + +### Added +- Added `sendfile` on FreeBSD and Darwin. + ([#901](https://github.com/nix-rust/nix/pull/901)) +- Added `pselect` + ([#894](https://github.com/nix-rust/nix/pull/894)) +- Exposed `preadv` and `pwritev` on the BSDs. + ([#883](https://github.com/nix-rust/nix/pull/883)) +- Added `mlockall` and `munlockall` + ([#876](https://github.com/nix-rust/nix/pull/876)) +- Added `SO_MARK` on Linux. + ([#873](https://github.com/nix-rust/nix/pull/873)) +- Added safe support for nearly any buffer type in the `sys::aio` module. + ([#872](https://github.com/nix-rust/nix/pull/872)) +- Added `sys::aio::LioCb` as a wrapper for `libc::lio_listio`. + ([#872](https://github.com/nix-rust/nix/pull/872)) +- Added `unistd::getsid` + ([#850](https://github.com/nix-rust/nix/pull/850)) +- Added `alarm`. ([#830](https://github.com/nix-rust/nix/pull/830)) +- Added interface flags `IFF_NO_PI, IFF_TUN, IFF_TAP` on linux-like systems. + ([#853](https://github.com/nix-rust/nix/pull/853)) +- Added `statvfs` module to all MacOS and Linux architectures. + ([#832](https://github.com/nix-rust/nix/pull/832)) +- Added `EVFILT_EMPTY`, `EVFILT_PROCDESC`, and `EVFILT_SENDFILE` on FreeBSD. + ([#825](https://github.com/nix-rust/nix/pull/825)) +- Exposed `termios::cfmakesane` on FreeBSD. + ([#825](https://github.com/nix-rust/nix/pull/825)) +- Exposed `MSG_CMSG_CLOEXEC` on *BSD. + ([#825](https://github.com/nix-rust/nix/pull/825)) +- Added `fchmod`, `fchmodat`. + ([#857](https://github.com/nix-rust/nix/pull/857)) +- Added `request_code_write_int!` on FreeBSD/DragonFlyBSD + ([#833](https://github.com/nix-rust/nix/pull/833)) + +### Changed +- `Display` and `Debug` for `SysControlAddr` now includes all fields. + ([#837](https://github.com/nix-rust/nix/pull/837)) +- `ioctl!` has been replaced with a family of `ioctl_*!` macros. + ([#833](https://github.com/nix-rust/nix/pull/833)) +- `io!`, `ior!`, `iow!`, and `iorw!` has been renamed to `request_code_none!`, `request_code_read!`, + `request_code_write!`, and `request_code_readwrite!` respectively. These have also now been exposed + in the documentation. + ([#833](https://github.com/nix-rust/nix/pull/833)) +- Enabled more `ptrace::Request` definitions for uncommon Linux platforms + ([#892](https://github.com/nix-rust/nix/pull/892)) +- Emulation of `FD_CLOEXEC` and `O_NONBLOCK` was removed from `socket()`, `accept4()`, and + `socketpair()`. + ([#907](https://github.com/nix-rust/nix/pull/907)) + +### Fixed +- Fixed possible panics when using `SigAction::flags` on Linux + ([#869](https://github.com/nix-rust/nix/pull/869)) +- Properly exposed 460800 and 921600 baud rates on NetBSD + ([#837](https://github.com/nix-rust/nix/pull/837)) +- Fixed `ioctl_write_int!` on FreeBSD/DragonFlyBSD + ([#833](https://github.com/nix-rust/nix/pull/833)) +- `ioctl_write_int!` now properly supports passing a `c_ulong` as the parameter on Linux non-musl targets + ([#833](https://github.com/nix-rust/nix/pull/833)) + +### Removed +- Removed explicit support for the `bytes` crate from the `sys::aio` module. + See `sys::aio::AioCb::from_boxed_slice` examples for alternatives. + ([#872](https://github.com/nix-rust/nix/pull/872)) +- Removed `sys::aio::lio_listio`. Use `sys::aio::LioCb::listio` instead. + ([#872](https://github.com/nix-rust/nix/pull/872)) +- Removed emulated `accept4()` from macos, ios, and netbsd targets + ([#907](https://github.com/nix-rust/nix/pull/907)) +- Removed `IFF_NOTRAILERS` on OpenBSD, as it has been removed in OpenBSD 6.3 + ([#893](https://github.com/nix-rust/nix/pull/893)) + +## [0.10.0] 2018-01-26 + +### Added +- Added specialized wrapper: `sys::ptrace::step` + ([#852](https://github.com/nix-rust/nix/pull/852)) +- Added `AioCb::from_ptr` and `AioCb::from_mut_ptr` + ([#820](https://github.com/nix-rust/nix/pull/820)) +- Added specialized wrappers: `sys::ptrace::{traceme, syscall, cont, attach}`. Using the matching routines + with `sys::ptrace::ptrace` is now deprecated. +- Added `nix::poll` module for all platforms + ([#672](https://github.com/nix-rust/nix/pull/672)) +- Added `nix::ppoll` function for FreeBSD and DragonFly + ([#672](https://github.com/nix-rust/nix/pull/672)) +- Added protocol families in `AddressFamily` enum. + ([#647](https://github.com/nix-rust/nix/pull/647)) +- Added the `pid()` method to `WaitStatus` for extracting the PID. + ([#722](https://github.com/nix-rust/nix/pull/722)) +- Added `nix::unistd:fexecve`. + ([#727](https://github.com/nix-rust/nix/pull/727)) +- Expose `uname()` on all platforms. + ([#739](https://github.com/nix-rust/nix/pull/739)) +- Expose `signalfd` module on Android as well. + ([#739](https://github.com/nix-rust/nix/pull/739)) +- Added `nix::sys::ptrace::detach`. + ([#749](https://github.com/nix-rust/nix/pull/749)) +- Added timestamp socket control message variant: + `nix::sys::socket::ControlMessage::ScmTimestamp` + ([#663](https://github.com/nix-rust/nix/pull/663)) +- Added socket option variant that enables the timestamp socket + control message: `nix::sys::socket::sockopt::ReceiveTimestamp` + ([#663](https://github.com/nix-rust/nix/pull/663)) +- Added more accessor methods for `AioCb` + ([#773](https://github.com/nix-rust/nix/pull/773)) +- Add `nix::sys::fallocate` + ([#768](https:://github.com/nix-rust/nix/pull/768)) +- Added `nix::unistd::mkfifo`. + ([#602](https://github.com/nix-rust/nix/pull/774)) +- Added `ptrace::Options::PTRACE_O_EXITKILL` on Linux and Android. + ([#771](https://github.com/nix-rust/nix/pull/771)) +- Added `nix::sys::uio::{process_vm_readv, process_vm_writev}` on Linux + ([#568](https://github.com/nix-rust/nix/pull/568)) +- Added `nix::unistd::{getgroups, setgroups, getgrouplist, initgroups}`. ([#733](https://github.com/nix-rust/nix/pull/733)) +- Added `nix::sys::socket::UnixAddr::as_abstract` on Linux and Android. + ([#785](https://github.com/nix-rust/nix/pull/785)) +- Added `nix::unistd::execveat` on Linux and Android. + ([#800](https://github.com/nix-rust/nix/pull/800)) +- Added the `from_raw()` method to `WaitStatus` for converting raw status values + to `WaitStatus` independent of syscalls. + ([#741](https://github.com/nix-rust/nix/pull/741)) +- Added more standard trait implementations for various types. + ([#814](https://github.com/nix-rust/nix/pull/814)) +- Added `sigprocmask` to the signal module. + ([#826](https://github.com/nix-rust/nix/pull/826)) +- Added `nix::sys::socket::LinkAddr` on Linux and all bsdlike system. + ([#813](https://github.com/nix-rust/nix/pull/813)) +- Add socket options for `IP_TRANSPARENT` / `BIND_ANY`. + ([#835](https://github.com/nix-rust/nix/pull/835)) + +### Changed +- Exposed the `mqueue` module for all supported operating systems. + ([#834](https://github.com/nix-rust/nix/pull/834)) +- Use native `pipe2` on all BSD targets. Users should notice no difference. + ([#777](https://github.com/nix-rust/nix/pull/777)) +- Renamed existing `ptrace` wrappers to encourage namespacing ([#692](https://github.com/nix-rust/nix/pull/692)) +- Marked `sys::ptrace::ptrace` as `unsafe`. +- Changed function signature of `socket()` and `socketpair()`. The `protocol` argument + has changed type from `c_int` to `SockProtocol`. + It accepts a `None` value for default protocol that was specified with zero using `c_int`. + ([#647](https://github.com/nix-rust/nix/pull/647)) +- Made `select` easier to use, adding the ability to automatically calculate the `nfds` parameter using the new + `FdSet::highest` ([#701](https://github.com/nix-rust/nix/pull/701)) +- Exposed `unistd::setresuid` and `unistd::setresgid` on FreeBSD and OpenBSD + ([#721](https://github.com/nix-rust/nix/pull/721)) +- Refactored the `statvfs` module removing extraneous API functions and the + `statvfs::vfs` module. Additionally `(f)statvfs()` now return the struct + directly. And the returned `Statvfs` struct now exposes its data through + accessor methods. ([#729](https://github.com/nix-rust/nix/pull/729)) +- The `addr` argument to `madvise` and `msync` is now `*mut` to better match the + libc API. ([#731](https://github.com/nix-rust/nix/pull/731)) +- `shm_open` and `shm_unlink` are no longer exposed on Android targets, where + they are not officially supported. ([#731](https://github.com/nix-rust/nix/pull/731)) +- `MapFlags`, `MmapAdvise`, and `MsFlags` expose some more variants and only + officially-supported variants are provided for each target. + ([#731](https://github.com/nix-rust/nix/pull/731)) +- Marked `pty::ptsname` function as `unsafe` + ([#744](https://github.com/nix-rust/nix/pull/744)) +- Moved constants ptrace request, event and options to enums and updated ptrace functions and argument types accordingly. + ([#749](https://github.com/nix-rust/nix/pull/749)) +- `AioCb::Drop` will now panic if the `AioCb` is still in-progress ([#715](https://github.com/nix-rust/nix/pull/715)) +- Restricted `nix::sys::socket::UnixAddr::new_abstract` to Linux and Android only. + ([#785](https://github.com/nix-rust/nix/pull/785)) +- The `ucred` struct has been removed in favor of a `UserCredentials` struct that + contains only getters for its fields. + ([#814](https://github.com/nix-rust/nix/pull/814)) +- Both `ip_mreq` and `ipv6_mreq` have been replaced with `IpMembershipRequest` and + `Ipv6MembershipRequest`. + ([#814](https://github.com/nix-rust/nix/pull/814)) +- Removed return type from `pause`. + ([#829](https://github.com/nix-rust/nix/pull/829)) +- Changed the termios APIs to allow for using a `u32` instead of the `BaudRate` + enum on BSD platforms to support arbitrary baud rates. See the module docs for + `nix::sys::termios` for more details. + ([#843](https://github.com/nix-rust/nix/pull/843)) + +### Fixed +- Fix compilation and tests for OpenBSD targets + ([#688](https://github.com/nix-rust/nix/pull/688)) +- Fixed error handling in `AioCb::fsync`, `AioCb::read`, and `AioCb::write`. + It is no longer an error to drop an `AioCb` that failed to enqueue in the OS. + ([#715](https://github.com/nix-rust/nix/pull/715)) +- Fix potential memory corruption on non-Linux platforms when using + `sendmsg`/`recvmsg`, caused by mismatched `msghdr` definition. + ([#648](https://github.com/nix-rust/nix/pull/648)) + +### Removed +- `AioCb::from_boxed_slice` has been removed. It was never actually safe. Use + `from_bytes` or `from_bytes_mut` instead. + ([#820](https://github.com/nix-rust/nix/pull/820)) +- The syscall module has been removed. This only exposed enough functionality for + `memfd_create()` and `pivot_root()`, which are still exposed as separate functions. + ([#747](https://github.com/nix-rust/nix/pull/747)) +- The `Errno` variants are no longer reexported from the `errno` module. `Errno` itself is no longer reexported from the + crate root and instead must be accessed using the `errno` module. ([#696](https://github.com/nix-rust/nix/pull/696)) +- Removed `MS_VERBOSE`, `MS_NOSEC`, and `MS_BORN` from `MsFlags`. These + are internal kernel flags and should never have been exposed. + ([#814](https://github.com/nix-rust/nix/pull/814)) + + +## [0.9.0] 2017-07-23 + +### Added +- Added `sysconf`, `pathconf`, and `fpathconf` + ([#630](https://github.com/nix-rust/nix/pull/630) +- Added `sys::signal::SigAction::{ flags, mask, handler}` + ([#611](https://github.com/nix-rust/nix/pull/609) +- Added `nix::sys::pthread::pthread_self` + ([#591](https://github.com/nix-rust/nix/pull/591) +- Added `AioCb::from_boxed_slice` + ([#582](https://github.com/nix-rust/nix/pull/582) +- Added `nix::unistd::{openat, fstatat, readlink, readlinkat}` + ([#551](https://github.com/nix-rust/nix/pull/551)) +- Added `nix::pty::{grantpt, posix_openpt, ptsname/ptsname_r, unlockpt}` + ([#556](https://github.com/nix-rust/nix/pull/556) +- Added `nix::ptr::openpty` + ([#456](https://github.com/nix-rust/nix/pull/456)) +- Added `nix::ptrace::{ptrace_get_data, ptrace_getsiginfo, ptrace_setsiginfo + and nix::Error::UnsupportedOperation}` + ([#614](https://github.com/nix-rust/nix/pull/614)) +- Added `cfmakeraw`, `cfsetspeed`, and `tcgetsid`. ([#527](https://github.com/nix-rust/nix/pull/527)) +- Added "bad none", "bad write_ptr", "bad write_int", and "bad readwrite" variants to the `ioctl!` + macro. ([#670](https://github.com/nix-rust/nix/pull/670)) +- On Linux and Android, added support for receiving `PTRACE_O_TRACESYSGOOD` + events from `wait` and `waitpid` using `WaitStatus::PtraceSyscall` + ([#566](https://github.com/nix-rust/nix/pull/566)). + +### Changed +- The `ioctl!` macro and its variants now allow the generated functions to have + doccomments. ([#661](https://github.com/nix-rust/nix/pull/661)) +- Changed `ioctl!(write ...)` into `ioctl!(write_ptr ...)` and `ioctl!(write_int ..)` variants + to more clearly separate those use cases. ([#670](https://github.com/nix-rust/nix/pull/670)) +- Marked `sys::mman::{ mmap, munmap, madvise, munlock, msync }` as unsafe. + ([#559](https://github.com/nix-rust/nix/pull/559)) +- Minimum supported Rust version is now 1.13. +- Removed `revents` argument from `PollFd::new()` as it's an output argument and + will be overwritten regardless of value. + ([#542](https://github.com/nix-rust/nix/pull/542)) +- Changed type signature of `sys::select::FdSet::contains` to make `self` + immutable ([#564](https://github.com/nix-rust/nix/pull/564)) +- Introduced wrapper types for `gid_t`, `pid_t`, and `uid_t` as `Gid`, `Pid`, and `Uid` + respectively. Various functions have been changed to use these new types as + arguments. ([#629](https://github.com/nix-rust/nix/pull/629)) +- Fixed compilation on all Android and iOS targets ([#527](https://github.com/nix-rust/nix/pull/527)) + and promoted them to Tier 2 support. +- `nix::sys::statfs::{statfs,fstatfs}` uses statfs definition from `libc::statfs` instead of own linux specific type `nix::sys::Statfs`. + Also file system type constants like `nix::sys::statfs::ADFS_SUPER_MAGIC` were removed in favor of the libc equivalent. + ([#561](https://github.com/nix-rust/nix/pull/561)) +- Revised the termios API including additional tests and documentation and exposed it on iOS. ([#527](https://github.com/nix-rust/nix/pull/527)) +- `eventfd`, `signalfd`, and `pwritev`/`preadv` functionality is now included by default for all + supported platforms. ([#681](https://github.com/nix-rust/nix/pull/561)) +- The `ioctl!` macro's plain variants has been replaced with "bad read" to be consistent with + other variants. The generated functions also have more strict types for their arguments. The + "*_buf" variants also now calculate total array size and take slice references for improved type + safety. The documentation has also been dramatically improved. + ([#670](https://github.com/nix-rust/nix/pull/670)) + +### Removed +- Removed `io::Error` from `nix::Error` and the conversion from `nix::Error` to `Errno` + ([#614](https://github.com/nix-rust/nix/pull/614)) +- All feature flags have been removed in favor of conditional compilation on supported platforms. + `execvpe` is no longer supported, but this was already broken and will be added back in the next + release. ([#681](https://github.com/nix-rust/nix/pull/561)) +- Removed `ioc_*` functions and many helper constants and macros within the `ioctl` module. These + should always have been private and only the `ioctl!` should be used in public code. + ([#670](https://github.com/nix-rust/nix/pull/670)) + +### Fixed +- Fixed multiple issues compiling under different archetectures and OSes. + Now compiles on Linux/MIPS ([#538](https://github.com/nix-rust/nix/pull/538)), + `Linux/PPC` ([#553](https://github.com/nix-rust/nix/pull/553)), + `MacOS/x86_64,i686` ([#553](https://github.com/nix-rust/nix/pull/553)), + `NetBSD/x64_64` ([#538](https://github.com/nix-rust/nix/pull/538)), + `FreeBSD/x86_64,i686` ([#536](https://github.com/nix-rust/nix/pull/536)), and + `Android` ([#631](https://github.com/nix-rust/nix/pull/631)). +- `bind` and `errno_location` now work correctly on `Android` + ([#631](https://github.com/nix-rust/nix/pull/631)) +- Added `nix::ptrace` on all Linux-kernel-based platforms + [#624](https://github.com/nix-rust/nix/pull/624). Previously it was + only available on x86, x86-64, and ARM, and also not on Android. +- Fixed `sys::socket::sendmsg` with zero entry `cmsgs` parameter. + ([#623](https://github.com/nix-rust/nix/pull/623)) +- Multiple constants related to the termios API have now been properly defined for + all supported platforms. ([#527](https://github.com/nix-rust/nix/pull/527)) +- `ioctl!` macro now supports working with non-int datatypes and properly supports all platforms. + ([#670](https://github.com/nix-rust/nix/pull/670)) + +## [0.8.1] 2017-04-16 + +### Fixed +- Fixed build on FreeBSD. (Cherry-picked + [a859ee3c](https://github.com/nix-rust/nix/commit/a859ee3c9396dfdb118fcc2c8ecc697e2d303467)) + +## [0.8.0] 2017-03-02 + +### Added +- Added `::nix::sys::termios::BaudRate` enum to provide portable baudrate + values. ([#518](https://github.com/nix-rust/nix/pull/518)) +- Added a new `WaitStatus::PtraceEvent` to support ptrace events on Linux + and Android ([#438](https://github.com/nix-rust/nix/pull/438)) +- Added support for POSIX AIO + ([#483](https://github.com/nix-rust/nix/pull/483)) + ([#506](https://github.com/nix-rust/nix/pull/506)) +- Added support for XNU system control sockets + ([#478](https://github.com/nix-rust/nix/pull/478)) +- Added support for `ioctl` calls on BSD platforms + ([#478](https://github.com/nix-rust/nix/pull/478)) +- Added struct `TimeSpec` + ([#475](https://github.com/nix-rust/nix/pull/475)) + ([#483](https://github.com/nix-rust/nix/pull/483)) +- Added complete definitions for all kqueue-related constants on all supported + OSes + ([#415](https://github.com/nix-rust/nix/pull/415)) +- Added function `epoll_create1` and bitflags `EpollCreateFlags` in + `::nix::sys::epoll` in order to support `::libc::epoll_create1`. + ([#410](https://github.com/nix-rust/nix/pull/410)) +- Added `setresuid` and `setresgid` for Linux in `::nix::unistd` + ([#448](https://github.com/nix-rust/nix/pull/448)) +- Added `getpgid` in `::nix::unistd` + ([#433](https://github.com/nix-rust/nix/pull/433)) +- Added `tcgetpgrp` and `tcsetpgrp` in `::nix::unistd` + ([#451](https://github.com/nix-rust/nix/pull/451)) +- Added `CLONE_NEWCGROUP` in `::nix::sched` + ([#457](https://github.com/nix-rust/nix/pull/457)) +- Added `getpgrp` in `::nix::unistd` + ([#491](https://github.com/nix-rust/nix/pull/491)) +- Added `fchdir` in `::nix::unistd` + ([#497](https://github.com/nix-rust/nix/pull/497)) +- Added `major` and `minor` in `::nix::sys::stat` for decomposing `dev_t` + ([#508](https://github.com/nix-rust/nix/pull/508)) +- Fixed the style of many bitflags and use `libc` in more places. + ([#503](https://github.com/nix-rust/nix/pull/503)) +- Added `ppoll` in `::nix::poll` + ([#520](https://github.com/nix-rust/nix/pull/520)) +- Added support for getting and setting pipe size with fcntl(2) on Linux + ([#540](https://github.com/nix-rust/nix/pull/540)) + +### Changed +- `::nix::sys::termios::{cfgetispeed, cfsetispeed, cfgetospeed, cfsetospeed}` + switched to use `BaudRate` enum from `speed_t`. + ([#518](https://github.com/nix-rust/nix/pull/518)) +- `epoll_ctl` now could accept None as argument `event` + when op is `EpollOp::EpollCtlDel`. + ([#480](https://github.com/nix-rust/nix/pull/480)) +- Removed the `bad` keyword from the `ioctl!` macro + ([#478](https://github.com/nix-rust/nix/pull/478)) +- Changed `TimeVal` into an opaque Newtype + ([#475](https://github.com/nix-rust/nix/pull/475)) +- `kill`'s signature, defined in `::nix::sys::signal`, changed, so that the + signal parameter has type `T: Into>`. `None` as an argument + for that parameter will result in a 0 passed to libc's `kill`, while a + `Some`-argument will result in the previous behavior for the contained + `Signal`. + ([#445](https://github.com/nix-rust/nix/pull/445)) +- The minimum supported version of rustc is now 1.7.0. + ([#444](https://github.com/nix-rust/nix/pull/444)) +- Changed `KEvent` to an opaque structure that may only be modified by its + constructor and the `ev_set` method. + ([#415](https://github.com/nix-rust/nix/pull/415)) + ([#442](https://github.com/nix-rust/nix/pull/442)) + ([#463](https://github.com/nix-rust/nix/pull/463)) +- `pipe2` now calls `libc::pipe2` where available. Previously it was emulated + using `pipe`, which meant that setting `O_CLOEXEC` was not atomic. + ([#427](https://github.com/nix-rust/nix/pull/427)) +- Renamed `EpollEventKind` to `EpollFlags` in `::nix::sys::epoll` in order for + it to conform with our conventions. + ([#410](https://github.com/nix-rust/nix/pull/410)) +- `EpollEvent` in `::nix::sys::epoll` is now an opaque proxy for + `::libc::epoll_event`. The formerly public field `events` is now be read-only + accessible with the new method `events()` of `EpollEvent`. Instances of + `EpollEvent` can be constructed using the new method `new()` of EpollEvent. + ([#410](https://github.com/nix-rust/nix/pull/410)) +- `SigFlags` in `::nix::sys::signal` has be renamed to `SigmaskHow` and its type + has changed from `bitflags` to `enum` in order to conform to our conventions. + ([#460](https://github.com/nix-rust/nix/pull/460)) +- `sethostname` now takes a `&str` instead of a `&[u8]` as this provides an API + that makes more sense in normal, correct usage of the API. +- `gethostname` previously did not expose the actual length of the hostname + written from the underlying system call at all. This has been updated to + return a `&CStr` within the provided buffer that is always properly + NUL-terminated (this is not guaranteed by the call with all platforms/libc + implementations). +- Exposed all fcntl(2) operations at the module level, so they can be + imported direclty instead of via `FcntlArg` enum. + ([#541](https://github.com/nix-rust/nix/pull/541)) + +### Fixed +- Fixed multiple issues with Unix domain sockets on non-Linux OSes + ([#474](https://github.com/nix-rust/nix/pull/415)) +- Fixed using kqueue with `EVFILT_USER` on FreeBSD + ([#415](https://github.com/nix-rust/nix/pull/415)) +- Fixed the build on FreeBSD, and fixed the getsockopt, sendmsg, and recvmsg + functions on that same OS. + ([#397](https://github.com/nix-rust/nix/pull/397)) +- Fixed an off-by-one bug in `UnixAddr::new_abstract` in `::nix::sys::socket`. + ([#429](https://github.com/nix-rust/nix/pull/429)) +- Fixed clone passing a potentially unaligned stack. + ([#490](https://github.com/nix-rust/nix/pull/490)) +- Fixed mkdev not creating a `dev_t` the same way as libc. + ([#508](https://github.com/nix-rust/nix/pull/508)) + +## [0.7.0] 2016-09-09 + +### Added +- Added `lseek` and `lseek64` in `::nix::unistd` + ([#377](https://github.com/nix-rust/nix/pull/377)) +- Added `mkdir` and `getcwd` in `::nix::unistd` + ([#416](https://github.com/nix-rust/nix/pull/416)) +- Added accessors `sigmask_mut` and `sigmask` to `UContext` in + `::nix::ucontext`. + ([#370](https://github.com/nix-rust/nix/pull/370)) +- Added `WUNTRACED` to `WaitPidFlag` in `::nix::sys::wait` for non-_linux_ + targets. + ([#379](https://github.com/nix-rust/nix/pull/379)) +- Added new module `::nix::sys::reboot` with enumeration `RebootMode` and + functions `reboot` and `set_cad_enabled`. Currently for _linux_ only. + ([#386](https://github.com/nix-rust/nix/pull/386)) +- `FdSet` in `::nix::sys::select` now also implements `Clone`. + ([#405](https://github.com/nix-rust/nix/pull/405)) +- Added `F_FULLFSYNC` to `FcntlArg` in `::nix::fcntl` for _apple_ targets. + ([#407](https://github.com/nix-rust/nix/pull/407)) +- Added `CpuSet::unset` in `::nix::sched`. + ([#402](https://github.com/nix-rust/nix/pull/402)) +- Added constructor method `new()` to `PollFd` in `::nix::poll`, in order to + allow creation of objects, after removing public access to members. + ([#399](https://github.com/nix-rust/nix/pull/399)) +- Added method `revents()` to `PollFd` in `::nix::poll`, in order to provide + read access to formerly public member `revents`. + ([#399](https://github.com/nix-rust/nix/pull/399)) +- Added `MSG_CMSG_CLOEXEC` to `MsgFlags` in `::nix::sys::socket` for _linux_ only. + ([#422](https://github.com/nix-rust/nix/pull/422)) + +### Changed +- Replaced the reexported integer constants for signals by the enumeration + `Signal` in `::nix::sys::signal`. + ([#362](https://github.com/nix-rust/nix/pull/362)) +- Renamed `EventFdFlag` to `EfdFlags` in `::nix::sys::eventfd`. + ([#383](https://github.com/nix-rust/nix/pull/383)) +- Changed the result types of `CpuSet::is_set` and `CpuSet::set` in + `::nix::sched` to `Result` and `Result<()>`, respectively. They now + return `EINVAL`, if an invalid argument for the `field` parameter is passed. + ([#402](https://github.com/nix-rust/nix/pull/402)) +- `MqAttr` in `::nix::mqueue` is now an opaque proxy for `::libc::mq_attr`, + which has the same structure as the old `MqAttr`. The field `mq_flags` of + `::libc::mq_attr` is readable using the new method `flags()` of `MqAttr`. + `MqAttr` also no longer implements `Debug`. + ([#392](https://github.com/nix-rust/nix/pull/392)) +- The parameter `msq_prio` of `mq_receive` with type `u32` in `::nix::mqueue` + was replaced by a parameter named `msg_prio` with type `&mut u32`, so that + the message priority can be obtained by the caller. + ([#392](https://github.com/nix-rust/nix/pull/392)) +- The type alias `MQd` in `::nix::queue` was replaced by the type alias + `libc::mqd_t`, both of which are aliases for the same type. + ([#392](https://github.com/nix-rust/nix/pull/392)) + +### Removed +- Type alias `SigNum` from `::nix::sys::signal`. + ([#362](https://github.com/nix-rust/nix/pull/362)) +- Type alias `CpuMask` from `::nix::shed`. + ([#402](https://github.com/nix-rust/nix/pull/402)) +- Removed public fields from `PollFd` in `::nix::poll`. (See also added method + `revents()`. + ([#399](https://github.com/nix-rust/nix/pull/399)) + +### Fixed +- Fixed the build problem for NetBSD (Note, that we currently do not support + it, so it might already be broken again). + ([#389](https://github.com/nix-rust/nix/pull/389)) +- Fixed the build on FreeBSD, and fixed the getsockopt, sendmsg, and recvmsg + functions on that same OS. + ([#397](https://github.com/nix-rust/nix/pull/397)) + +## [0.6.0] 2016-06-10 + +### Added +- Added `gettid` in `::nix::unistd` for _linux_ and _android_. + ([#293](https://github.com/nix-rust/nix/pull/293)) +- Some _mips_ support in `::nix::sched` and `::nix::sys::syscall`. + ([#301](https://github.com/nix-rust/nix/pull/301)) +- Added `SIGNALFD_SIGINFO_SIZE` in `::nix::sys::signalfd`. + ([#309](https://github.com/nix-rust/nix/pull/309)) +- Added new module `::nix::ucontext` with struct `UContext`. Currently for + _linux_ only. + ([#311](https://github.com/nix-rust/nix/pull/311)) +- Added `EPOLLEXCLUSIVE` to `EpollEventKind` in `::nix::sys::epoll`. + ([#330](https://github.com/nix-rust/nix/pull/330)) +- Added `pause` to `::nix::unistd`. + ([#336](https://github.com/nix-rust/nix/pull/336)) +- Added `sleep` to `::nix::unistd`. + ([#351](https://github.com/nix-rust/nix/pull/351)) +- Added `S_IFDIR`, `S_IFLNK`, `S_IFMT` to `SFlag` in `::nix::sys::stat`. + ([#359](https://github.com/nix-rust/nix/pull/359)) +- Added `clear` and `extend` functions to `SigSet`'s implementation in + `::nix::sys::signal`. + ([#347](https://github.com/nix-rust/nix/pull/347)) +- `sockaddr_storage_to_addr` in `::nix::sys::socket` now supports `sockaddr_nl` + on _linux_ and _android_. + ([#366](https://github.com/nix-rust/nix/pull/366)) +- Added support for `SO_ORIGINAL_DST` in `::nix::sys::socket` on _linux_. + ([#367](https://github.com/nix-rust/nix/pull/367)) +- Added `SIGINFO` in `::nix::sys::signal` for the _macos_ target as well as + `SIGPWR` and `SIGSTKFLT` in `::nix::sys::signal` for non-_macos_ targets. + ([#361](https://github.com/nix-rust/nix/pull/361)) + +### Changed +- Changed the structure `IoVec` in `::nix::sys::uio`. + ([#304](https://github.com/nix-rust/nix/pull/304)) +- Replaced `CREATE_NEW_FD` by `SIGNALFD_NEW` in `::nix::sys::signalfd`. + ([#309](https://github.com/nix-rust/nix/pull/309)) +- Renamed `SaFlag` to `SaFlags` and `SigFlag` to `SigFlags` in + `::nix::sys::signal`. + ([#314](https://github.com/nix-rust/nix/pull/314)) +- Renamed `Fork` to `ForkResult` and changed its fields in `::nix::unistd`. + ([#332](https://github.com/nix-rust/nix/pull/332)) +- Added the `signal` parameter to `clone`'s signature in `::nix::sched`. + ([#344](https://github.com/nix-rust/nix/pull/344)) +- `execv`, `execve`, and `execvp` now return `Result` instead of + `Result<()>` in `::nix::unistd`. + ([#357](https://github.com/nix-rust/nix/pull/357)) + +### Fixed +- Improved the conversion from `std::net::SocketAddr` to `InetAddr` in + `::nix::sys::socket::addr`. + ([#335](https://github.com/nix-rust/nix/pull/335)) + +## [0.5.0] 2016-03-01 diff --git a/third_party/cargo/vendor/nix-0.14.1/CONTRIBUTING.md b/third_party/cargo/vendor/nix-0.14.1/CONTRIBUTING.md new file mode 100644 index 0000000..03a1f63 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/CONTRIBUTING.md @@ -0,0 +1,114 @@ +# Contributing to nix + +We're really glad you're interested in contributing to nix! This +document has a few pointers and guidelines to help get you started. + +To have a welcoming and inclusive project, nix uses the Rust project's +[Code of Conduct][conduct]. All contributors are expected to follow it. + +[conduct]: https://www.rust-lang.org/conduct.html + + +# Issues + +We use GitHub's [issue tracker][issues]. + +[issues]: https://github.com/nix-rust/nix/issues + + +## Bug reports + +Before submitting a new bug report, please [search existing +issues][issue-search] to see if there's something related. If not, just +[open a new issue][new-issue]! + +As a reminder, the more information you can give in your issue, the +easier it is to figure out how to fix it. For nix, this will likely +include the OS and version, and the architecture. + +[issue-search]: https://github.com/nix-rust/nix/search?utf8=%E2%9C%93&q=is%3Aissue&type=Issues +[new-issue]: https://github.com/nix-rust/nix/issues/new + + +## Feature / API requests + +If you'd like a new API or feature added, please [open a new +issue][new-issue] requesting it. As with reporting a bug, the more +information you can provide, the better. + + +## Labels + +We use labels to help manage issues. The structure is modeled after +[Rust's issue labeling scheme][rust-labels]: +- **A-**prefixed labels state which area of the project the issue + relates to +- **E-**prefixed labels explain the level of experience necessary to fix the + issue +- **O-**prefixed labels specify the OS for issues that are OS-specific +- **R-**prefixed labels specify the architecture for issues that are + architecture-specific + +[rust-labels]: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#issue-triage + + +# Pull requests + +GitHub pull requests are the primary mechanism we use to change nix. GitHub itself has +some [great documentation][pr-docs] on using the Pull Request feature. We use the 'fork and +pull' model described there. + +Please make pull requests against the `master` branch. + +If you change the API by way of adding, removing or changing something or if +you fix a bug, please add an appropriate note to the [change log][cl]. We +follow the conventions of [Keep A CHANGELOG][kacl]. + +[cl]: https://github.com/nix-rust/nix/blob/master/CHANGELOG.md +[kacl]: https://github.com/olivierlacan/keep-a-changelog/tree/18adb5f5be7a898d046f6a4acb93e39dcf40c4ad +[pr-docs]: https://help.github.com/articles/using-pull-requests/ + +## Testing + +nix has a test suite that you can run with `cargo test`. Ideally, we'd like pull +requests to include tests where they make sense. For example, when fixing a bug, +add a test that would have failed without the fix. + +After you've made your change, make sure the tests pass in your development +environment. We also have [continuous integration set up on +Travis-CI][travis-ci], which might find some issues on other platforms. The CI +will run once you open a pull request. + +There is also infrastructure for running tests for other targets +locally. More information is available in the [CI Readme][ci-readme]. + +[travis-ci]: https://travis-ci.org/nix-rust/nix +[ci-readme]: ci/README.md + +### Disabling a test in the CI environment + +Sometimes there are features that cannot be tested in the CI environment. +To stop a test from running under CI, add `#[cfg_attr(travis, ignore)]` +to it. Please include a comment describing the reason it shouldn't run +under CI, and a link to an upstream issue if possible! + +## bors, the bot who merges all the PRs + +All pull requests are merged via [bors], an integration bot. After the +pull request has been reviewed, the reviewer will leave a comment like + +> bors r+ + +to let bors know that it was approved. Then bors will check that it passes +tests when merged with the latest changes in the `master` branch, and +merge if the tests succeed. + +[bors]: https://bors-ng.github.io/ + + +## API conventions + +If you're adding a new API, we have a [document with +conventions][conventions] to use throughout the nix project. + +[conventions]: https://github.com/nix-rust/nix/blob/master/CONVENTIONS.md diff --git a/third_party/cargo/vendor/nix-0.14.1/CONVENTIONS.md b/third_party/cargo/vendor/nix-0.14.1/CONVENTIONS.md new file mode 100644 index 0000000..48daa93 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/CONVENTIONS.md @@ -0,0 +1,87 @@ +# Conventions + +In order to achieve our goal of wrapping [libc][libc] code in idiomatic rust +constructs with minimal performance overhead, we follow the following +conventions. + +Note that, thus far, not all the code follows these conventions and not all +conventions we try to follow have been documented here. If you find an instance +of either, feel free to remedy the flaw by opening a pull request with +appropriate changes or additions. + +## Change Log + +We follow the conventions laid out in [Keep A CHANGELOG][kacl]. + +[kacl]: https://github.com/olivierlacan/keep-a-changelog/tree/18adb5f5be7a898d046f6a4acb93e39dcf40c4ad + +## libc constants, functions and structs + +We do not define integer constants ourselves, but use or reexport them from the +[libc crate][libc]. + +We use the functions exported from [libc][libc] instead of writing our own +`extern` declarations. + +We use the `struct` definitions from [libc][libc] internally instead of writing +our own. If we want to add methods to a libc type, we use the newtype pattern. +For example, + +```rust +pub struct SigSet(libc::sigset_t); + +impl SigSet { + ... +} +``` + +When creating newtypes, we use Rust's `CamelCase` type naming convention. + +## Bitflags + +Many C functions have flags parameters that are combined from constants using +bitwise operations. We represent the types of these parameters by types defined +using our `libc_bitflags!` macro, which is a convenience wrapper around the +`bitflags!` macro from the [bitflags crate][bitflags] that brings in the +constant value from `libc`. + +We name the type for a set of constants whose element's names start with `FOO_` +`FooFlags`. + +For example, + +```rust +libc_bitflags!{ + pub struct ProtFlags: libc::c_int { + PROT_NONE; + PROT_READ; + PROT_WRITE; + PROT_EXEC; + #[cfg(any(target_os = "linux", target_os = "android"))] + PROT_GROWSDOWN; + #[cfg(any(target_os = "linux", target_os = "android"))] + PROT_GROWSUP; + } +} +``` + + +## Enumerations + +We represent sets of constants that are intended as mutually exclusive arguments +to parameters of functions by [enumerations][enum]. + + +## Structures Initialized by libc Functions + +Whenever we need to use a [libc][libc] function to properly initialize a +variable and said function allows us to use uninitialized memory, we use +[`std::mem::uninitialized`][std_uninitialized] (or [`core::mem::uninitialized`][core_uninitialized]) +when defining the variable. This allows us to avoid the overhead incurred by +zeroing or otherwise initializing the variable. + +[bitflags]: https://crates.io/crates/bitflags/ +[core_uninitialized]: https://doc.rust-lang.org/core/mem/fn.uninitialized.html +[enum]: https://doc.rust-lang.org/reference.html#enumerations +[libc]: https://crates.io/crates/libc/ +[std_uninitialized]: https://doc.rust-lang.org/std/mem/fn.uninitialized.html diff --git a/third_party/cargo/vendor/nix-0.14.1/Cargo.toml b/third_party/cargo/vendor/nix-0.14.1/Cargo.toml new file mode 100644 index 0000000..7a7f733 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/Cargo.toml @@ -0,0 +1,70 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "nix" +version = "0.14.1" +authors = ["The nix-rust Project Developers"] +exclude = ["/.gitignore", "/.travis.yml", "/ci/*", "/Cross.toml", "/RELEASE_PROCEDURE.md", "/bors.toml"] +description = "Rust friendly bindings to *nix APIs" +categories = ["os::unix-apis"] +license = "MIT" +repository = "https://github.com/nix-rust/nix" + +[[test]] +name = "test" +path = "test/test.rs" + +[[test]] +name = "test-aio-drop" +path = "test/sys/test_aio_drop.rs" + +[[test]] +name = "test-lio-listio-resubmit" +path = "test/sys/test_lio_listio_resubmit.rs" + +[[test]] +name = "test-mount" +path = "test/test_mount.rs" +harness = false + +[[test]] +name = "test-ptymaster-drop" +path = "test/test_ptymaster_drop.rs" +[dependencies.bitflags] +version = "1.0" + +[dependencies.cfg-if] +version = "0.1.0" + +[dependencies.libc] +version = "0.2.57" + +[dependencies.void] +version = "1.0.2" +[dev-dependencies.bytes] +version = "0.4.8" + +[dev-dependencies.lazy_static] +version = "1.2" + +[dev-dependencies.rand] +version = ">= 0.6, < 0.7" + +[dev-dependencies.tempfile] +version = "3.0.5" +[target."cfg(any(target_os = \"android\", target_os = \"linux\"))".dev-dependencies.caps] +version = "0.3.1" +[target."cfg(target_os = \"dragonfly\")".build-dependencies.cc] +version = "1" +[target."cfg(target_os = \"freebsd\")".dev-dependencies.sysctl] +version = "0.1" diff --git a/third_party/cargo/vendor/nix-0.14.1/LICENSE b/third_party/cargo/vendor/nix-0.14.1/LICENSE new file mode 100644 index 0000000..aff9096 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Carl Lerche + nix-rust Authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/third_party/cargo/vendor/nix-0.14.1/README.md b/third_party/cargo/vendor/nix-0.14.1/README.md new file mode 100644 index 0000000..23a2053 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/README.md @@ -0,0 +1,110 @@ +# Rust bindings to *nix APIs + +[![Build Status](https://travis-ci.org/nix-rust/nix.svg?branch=master)](https://travis-ci.org/nix-rust/nix) +[![crates.io](http://meritbadge.herokuapp.com/nix)](https://crates.io/crates/nix) + +[Documentation (Releases)](https://docs.rs/nix/) + +Nix seeks to provide friendly bindings to various *nix platform APIs (Linux, Darwin, +...). The goal is to not provide a 100% unified interface, but to unify +what can be while still providing platform specific APIs. + +For many system APIs, Nix provides a safe alternative to the unsafe APIs +exposed by the [libc crate](https://github.com/rust-lang/libc). This is done by +wrapping the libc functionality with types/abstractions that enforce legal/safe +usage. + + +As an example of what Nix provides, examine the differences between what is +exposed by libc and nix for the +[gethostname](http://man7.org/linux/man-pages/man2/gethostname.2.html) system +call: + +```rust,ignore +// libc api (unsafe, requires handling return code/errno) +pub unsafe extern fn gethostname(name: *mut c_char, len: size_t) -> c_int; + +// nix api (returns a nix::Result) +pub fn gethostname<'a>(buffer: &'a mut [u8]) -> Result<&'a CStr>; +``` + +## Supported Platforms + +nix target support consists of two tiers. While nix attempts to support all +platforms supported by [libc](https://github.com/rust-lang/libc), only some +platforms are actively supported due to either technical or manpower +limitations. Support for platforms is split into three tiers: + + * Tier 1 - Builds and tests for this target are run in CI. Failures of either + block the inclusion of new code. + * Tier 2 - Builds for this target are run in CI. Failures during the build + blocks the inclusion of new code. Tests may be run, but failures + in tests don't block the inclusion of new code. + * Tier 3 - Builds for this target are run in CI. Failures during the build + *do not* block the inclusion of new code. Testing may be run, but + failures in tests don't block the inclusion of new code. + +The following targets are all supported by nix on Rust 1.24.1 or newer (unless +otherwise noted): + +Tier 1: + * aarch64-unknown-linux-gnu + * arm-unknown-linux-gnueabi + * armv7-unknown-linux-gnueabihf + * i686-apple-darwin + * i686-unknown-freebsd + * i686-unknown-linux-gnu + * i686-unknown-linux-musl + * mips-unknown-linux-gnu + * mips64-unknown-linux-gnuabi64 + * mips64el-unknown-linux-gnuabi64 + * mipsel-unknown-linux-gnu + * powerpc64-unknown-linux-gnu + * powerpc64le-unknown-linux-gnu + * x86_64-apple-darwin + * x86_64-unknown-freebsd + * x86_64-unknown-linux-gnu + * x86_64-unknown-linux-musl + +Tier 2: + * aarch64-apple-ios + * aarch64-linux-android + * arm-linux-androideabi + * arm-unknown-linux-musleabi + * armv7-apple-ios + * armv7-linux-androideabi + * armv7s-apple-ios + * i386-apple-ios + * i686-linux-android + * powerpc-unknown-linux-gnu + * s390x-unknown-linux-gnu + * x86_64-apple-ios + * x86_64-linux-android + * x86_64-unknown-netbsd + +## Usage + +To use `nix`, first add this to your `Cargo.toml`: + +```toml +[dependencies] +nix = "0.14.1" +``` + +Then, add this to your crate root: + +```rust,ignore +extern crate nix; +``` + +## Contributing + +Contributions are very welcome. Please See [CONTRIBUTING](CONTRIBUTING.md) for +additional details. + +Feel free to join us in [the nix-rust/nix](https://gitter.im/nix-rust/nix) channel on Gitter to +discuss `nix` development. + +## License + +Nix is licensed under the MIT license. See [LICENSE](LICENSE) for more details. diff --git a/third_party/cargo/vendor/nix-0.14.1/build.rs b/third_party/cargo/vendor/nix-0.14.1/build.rs new file mode 100644 index 0000000..92fd366 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/build.rs @@ -0,0 +1,12 @@ +#[cfg(target_os = "dragonfly")] +extern crate cc; + +#[cfg(target_os = "dragonfly")] +fn main() { + cc::Build::new() + .file("src/errno_dragonfly.c") + .compile("liberrno_dragonfly.a"); +} + +#[cfg(not(target_os = "dragonfly"))] +fn main() {} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/dir.rs b/third_party/cargo/vendor/nix-0.14.1/src/dir.rs new file mode 100644 index 0000000..814e9e0 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/dir.rs @@ -0,0 +1,210 @@ +use {Error, NixPath, Result}; +use errno::Errno; +use fcntl::{self, OFlag}; +use libc; +use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; +use std::{ffi, fmt, ptr}; +use sys; + +#[cfg(target_os = "linux")] +use libc::{dirent64 as dirent, readdir64_r as readdir_r}; + +#[cfg(not(target_os = "linux"))] +use libc::{dirent, readdir_r}; + +/// An open directory. +/// +/// This is a lower-level interface than `std::fs::ReadDir`. Notable differences: +/// * can be opened from a file descriptor (as returned by `openat`, perhaps before knowing +/// if the path represents a file or directory). +/// * implements `AsRawFd`, so it can be passed to `fstat`, `openat`, etc. +/// The file descriptor continues to be owned by the `Dir`, so callers must not keep a `RawFd` +/// after the `Dir` is dropped. +/// * can be iterated through multiple times without closing and reopening the file +/// descriptor. Each iteration rewinds when finished. +/// * returns entries for `.` (current directory) and `..` (parent directory). +/// * returns entries' names as a `CStr` (no allocation or conversion beyond whatever libc +/// does). +pub struct Dir( + // This could be ptr::NonNull once nix requires Rust 1.25. + *mut libc::DIR +); + +impl Dir { + /// Opens the given path as with `fcntl::open`. + pub fn open(path: &P, oflag: OFlag, + mode: sys::stat::Mode) -> Result { + let fd = fcntl::open(path, oflag, mode)?; + Dir::from_fd(fd) + } + + /// Opens the given path as with `fcntl::openat`. + pub fn openat(dirfd: RawFd, path: &P, oflag: OFlag, + mode: sys::stat::Mode) -> Result { + let fd = fcntl::openat(dirfd, path, oflag, mode)?; + Dir::from_fd(fd) + } + + /// Converts from a descriptor-based object, closing the descriptor on success or failure. + #[inline] + pub fn from(fd: F) -> Result { + Dir::from_fd(fd.into_raw_fd()) + } + + /// Converts from a file descriptor, closing it on success or failure. + pub fn from_fd(fd: RawFd) -> Result { + let d = unsafe { libc::fdopendir(fd) }; + if d.is_null() { + let e = Error::last(); + unsafe { libc::close(fd) }; + return Err(e); + }; + Ok(Dir(d)) + } + + /// Returns an iterator of `Result` which rewinds when finished. + pub fn iter(&mut self) -> Iter { + Iter(self) + } +} + +// `Dir` is not `Sync`. With the current implementation, it could be, but according to +// https://www.gnu.org/software/libc/manual/html_node/Reading_002fClosing-Directory.html, +// future versions of POSIX are likely to obsolete `readdir_r` and specify that it's unsafe to +// call `readdir` simultaneously from multiple threads. +// +// `Dir` is safe to pass from one thread to another, as it's not reference-counted. +unsafe impl Send for Dir {} + +impl AsRawFd for Dir { + fn as_raw_fd(&self) -> RawFd { + unsafe { libc::dirfd(self.0) } + } +} + +impl fmt::Debug for Dir { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Dir") + .field("fd", &self.as_raw_fd()) + .finish() + } +} + +impl Drop for Dir { + fn drop(&mut self) { + unsafe { libc::closedir(self.0) }; + } +} + +#[derive(Debug)] +pub struct Iter<'d>(&'d mut Dir); + +impl<'d> Iterator for Iter<'d> { + type Item = Result; + + fn next(&mut self) -> Option { + unsafe { + // Note: POSIX specifies that portable applications should dynamically allocate a + // buffer with room for a `d_name` field of size `pathconf(..., _PC_NAME_MAX)` plus 1 + // for the NUL byte. It doesn't look like the std library does this; it just uses + // fixed-sized buffers (and libc's dirent seems to be sized so this is appropriate). + // Probably fine here too then. + let mut ent: Entry = Entry(::std::mem::uninitialized()); + let mut result = ptr::null_mut(); + if let Err(e) = Errno::result(readdir_r((self.0).0, &mut ent.0, &mut result)) { + return Some(Err(e)); + } + if result == ptr::null_mut() { + return None; + } + assert_eq!(result, &mut ent.0 as *mut dirent); + return Some(Ok(ent)); + } + } +} + +impl<'d> Drop for Iter<'d> { + fn drop(&mut self) { + unsafe { libc::rewinddir((self.0).0) } + } +} + +/// A directory entry, similar to `std::fs::DirEntry`. +/// +/// Note that unlike the std version, this may represent the `.` or `..` entries. +#[derive(Copy, Clone)] +pub struct Entry(dirent); + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum Type { + Fifo, + CharacterDevice, + Directory, + BlockDevice, + File, + Symlink, + Socket, +} + +impl Entry { + /// Returns the inode number (`d_ino`) of the underlying `dirent`. + #[cfg(any(target_os = "android", + target_os = "emscripten", + target_os = "fuchsia", + target_os = "haiku", + target_os = "ios", + target_os = "l4re", + target_os = "linux", + target_os = "macos", + target_os = "solaris"))] + pub fn ino(&self) -> u64 { + self.0.d_ino as u64 + } + + /// Returns the inode number (`d_fileno`) of the underlying `dirent`. + #[cfg(not(any(target_os = "android", + target_os = "emscripten", + target_os = "fuchsia", + target_os = "haiku", + target_os = "ios", + target_os = "l4re", + target_os = "linux", + target_os = "macos", + target_os = "solaris")))] + pub fn ino(&self) -> u64 { + self.0.d_fileno as u64 + } + + /// Returns the bare file name of this directory entry without any other leading path component. + pub fn file_name(&self) -> &ffi::CStr { + unsafe { ::std::ffi::CStr::from_ptr(self.0.d_name.as_ptr()) } + } + + /// Returns the type of this directory entry, if known. + /// + /// See platform `readdir(3)` or `dirent(5)` manpage for when the file type is known; + /// notably, some Linux filesystems don't implement this. The caller should use `stat` or + /// `fstat` if this returns `None`. + pub fn file_type(&self) -> Option { + match self.0.d_type { + libc::DT_FIFO => Some(Type::Fifo), + libc::DT_CHR => Some(Type::CharacterDevice), + libc::DT_DIR => Some(Type::Directory), + libc::DT_BLK => Some(Type::BlockDevice), + libc::DT_REG => Some(Type::File), + libc::DT_LNK => Some(Type::Symlink), + libc::DT_SOCK => Some(Type::Socket), + /* libc::DT_UNKNOWN | */ _ => None, + } + } +} + +impl fmt::Debug for Entry { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Entry") + .field("ino", &self.ino()) + .field("file_name", &self.file_name()) + .field("file_type", &self.file_type()) + .finish() + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/errno.rs b/third_party/cargo/vendor/nix-0.14.1/src/errno.rs new file mode 100644 index 0000000..6a2447b --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/errno.rs @@ -0,0 +1,1963 @@ +#[cfg(not(target_os = "dragonfly"))] +use libc; +use libc::{c_int, c_void}; +use std::{fmt, io, error}; +use {Error, Result}; + +pub use self::consts::*; + +cfg_if! { + if #[cfg(any(target_os = "freebsd", + target_os = "ios", + target_os = "macos"))] { + unsafe fn errno_location() -> *mut c_int { + libc::__error() + } + } else if #[cfg(target_os = "dragonfly")] { + // DragonFly uses a thread-local errno variable, but #[thread_local] is + // feature-gated and not available in stable Rust as of this writing + // (Rust 1.21.0). We have to use a C extension to access it + // (src/errno_dragonfly.c). + // + // Tracking issue for `thread_local` stabilization: + // + // https://github.com/rust-lang/rust/issues/29594 + // + // Once this becomes stable, we can remove build.rs, + // src/errno_dragonfly.c, and use: + // + // extern { #[thread_local] static errno: c_int; } + // + #[link(name="errno_dragonfly", kind="static")] + extern { + pub fn errno_location() -> *mut c_int; + } + } else if #[cfg(any(target_os = "android", + target_os = "netbsd", + target_os = "openbsd"))] { + unsafe fn errno_location() -> *mut c_int { + libc::__errno() + } + } else if #[cfg(target_os = "linux")] { + unsafe fn errno_location() -> *mut c_int { + libc::__errno_location() + } + } +} + +/// Sets the platform-specific errno to no-error +unsafe fn clear() -> () { + *errno_location() = 0; +} + +/// Returns the platform-specific value of errno +pub fn errno() -> i32 { + unsafe { + (*errno_location()) as i32 + } +} + +impl Errno { + pub fn last() -> Self { + last() + } + + pub fn desc(self) -> &'static str { + desc(self) + } + + pub fn from_i32(err: i32) -> Errno { + from_i32(err) + } + + pub unsafe fn clear() -> () { + clear() + } + + /// Returns `Ok(value)` if it does not contain the sentinel value. This + /// should not be used when `-1` is not the errno sentinel value. + pub fn result>(value: S) -> Result { + if value == S::sentinel() { + Err(Error::Sys(Self::last())) + } else { + Ok(value) + } + } +} + +/// The sentinel value indicates that a function failed and more detailed +/// information about the error can be found in `errno` +pub trait ErrnoSentinel: Sized { + fn sentinel() -> Self; +} + +impl ErrnoSentinel for isize { + fn sentinel() -> Self { -1 } +} + +impl ErrnoSentinel for i32 { + fn sentinel() -> Self { -1 } +} + +impl ErrnoSentinel for i64 { + fn sentinel() -> Self { -1 } +} + +impl ErrnoSentinel for *mut c_void { + fn sentinel() -> Self { (-1 as isize) as *mut c_void } +} + +impl ErrnoSentinel for libc::sighandler_t { + fn sentinel() -> Self { libc::SIG_ERR } +} + +impl error::Error for Errno { + fn description(&self) -> &str { + self.desc() + } +} + +impl fmt::Display for Errno { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}: {}", self, self.desc()) + } +} + +impl From for io::Error { + fn from(err: Errno) -> Self { + io::Error::from_raw_os_error(err as i32) + } +} + +fn last() -> Errno { + Errno::from_i32(errno()) +} + +fn desc(errno: Errno) -> &'static str { + use self::Errno::*; + match errno { + UnknownErrno => "Unknown errno", + EPERM => "Operation not permitted", + ENOENT => "No such file or directory", + ESRCH => "No such process", + EINTR => "Interrupted system call", + EIO => "I/O error", + ENXIO => "No such device or address", + E2BIG => "Argument list too long", + ENOEXEC => "Exec format error", + EBADF => "Bad file number", + ECHILD => "No child processes", + EAGAIN => "Try again", + ENOMEM => "Out of memory", + EACCES => "Permission denied", + EFAULT => "Bad address", + ENOTBLK => "Block device required", + EBUSY => "Device or resource busy", + EEXIST => "File exists", + EXDEV => "Cross-device link", + ENODEV => "No such device", + ENOTDIR => "Not a directory", + EISDIR => "Is a directory", + EINVAL => "Invalid argument", + ENFILE => "File table overflow", + EMFILE => "Too many open files", + ENOTTY => "Not a typewriter", + ETXTBSY => "Text file busy", + EFBIG => "File too large", + ENOSPC => "No space left on device", + ESPIPE => "Illegal seek", + EROFS => "Read-only file system", + EMLINK => "Too many links", + EPIPE => "Broken pipe", + EDOM => "Math argument out of domain of func", + ERANGE => "Math result not representable", + EDEADLK => "Resource deadlock would occur", + ENAMETOOLONG => "File name too long", + ENOLCK => "No record locks available", + ENOSYS => "Function not implemented", + ENOTEMPTY => "Directory not empty", + ELOOP => "Too many symbolic links encountered", + ENOMSG => "No message of desired type", + EIDRM => "Identifier removed", + EINPROGRESS => "Operation now in progress", + EALREADY => "Operation already in progress", + ENOTSOCK => "Socket operation on non-socket", + EDESTADDRREQ => "Destination address required", + EMSGSIZE => "Message too long", + EPROTOTYPE => "Protocol wrong type for socket", + ENOPROTOOPT => "Protocol not available", + EPROTONOSUPPORT => "Protocol not supported", + ESOCKTNOSUPPORT => "Socket type not supported", + EPFNOSUPPORT => "Protocol family not supported", + EAFNOSUPPORT => "Address family not supported by protocol", + EADDRINUSE => "Address already in use", + EADDRNOTAVAIL => "Cannot assign requested address", + ENETDOWN => "Network is down", + ENETUNREACH => "Network is unreachable", + ENETRESET => "Network dropped connection because of reset", + ECONNABORTED => "Software caused connection abort", + ECONNRESET => "Connection reset by peer", + ENOBUFS => "No buffer space available", + EISCONN => "Transport endpoint is already connected", + ENOTCONN => "Transport endpoint is not connected", + ESHUTDOWN => "Cannot send after transport endpoint shutdown", + ETOOMANYREFS => "Too many references: cannot splice", + ETIMEDOUT => "Connection timed out", + ECONNREFUSED => "Connection refused", + EHOSTDOWN => "Host is down", + EHOSTUNREACH => "No route to host", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ECHRNG => "Channel number out of range", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EL2NSYNC => "Level 2 not synchronized", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EL3HLT => "Level 3 halted", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EL3RST => "Level 3 reset", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ELNRNG => "Link number out of range", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EUNATCH => "Protocol driver not attached", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENOCSI => "No CSI structure available", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EL2HLT => "Level 2 halted", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EBADE => "Invalid exchange", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EBADR => "Invalid request descriptor", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EXFULL => "Exchange full", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENOANO => "No anode", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EBADRQC => "Invalid request code", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EBADSLT => "Invalid slot", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EBFONT => "Bad font file format", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENOSTR => "Device not a stream", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENODATA => "No data available", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ETIME => "Timer expired", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENOSR => "Out of streams resources", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENONET => "Machine is not on the network", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENOPKG => "Package not installed", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EREMOTE => "Object is remote", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENOLINK => "Link has been severed", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EADV => "Advertise error", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ESRMNT => "Srmount error", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ECOMM => "Communication error on send", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EPROTO => "Protocol error", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EMULTIHOP => "Multihop attempted", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EDOTDOT => "RFS specific error", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EBADMSG => "Not a data message", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EOVERFLOW => "Value too large for defined data type", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENOTUNIQ => "Name not unique on network", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EBADFD => "File descriptor in bad state", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EREMCHG => "Remote address changed", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ELIBACC => "Can not access a needed shared library", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ELIBBAD => "Accessing a corrupted shared library", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ELIBSCN => ".lib section in a.out corrupted", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ELIBMAX => "Attempting to link in too many shared libraries", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ELIBEXEC => "Cannot exec a shared library directly", + + #[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))] + EILSEQ => "Illegal byte sequence", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ERESTART => "Interrupted system call should be restarted", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ESTRPIPE => "Streams pipe error", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EUSERS => "Too many users", + + #[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))] + EOPNOTSUPP => "Operation not supported on transport endpoint", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ESTALE => "Stale file handle", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EUCLEAN => "Structure needs cleaning", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENOTNAM => "Not a XENIX named type file", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENAVAIL => "No XENIX semaphores available", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EISNAM => "Is a named type file", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EREMOTEIO => "Remote I/O error", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EDQUOT => "Quota exceeded", + + #[cfg(any(target_os = "linux", target_os = "android", + target_os = "openbsd", target_os = "dragonfly"))] + ENOMEDIUM => "No medium found", + + #[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))] + EMEDIUMTYPE => "Wrong medium type", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ECANCELED => "Operation canceled", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENOKEY => "Required key not available", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EKEYEXPIRED => "Key has expired", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EKEYREVOKED => "Key has been revoked", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EKEYREJECTED => "Key was rejected by service", + + #[cfg(any(target_os = "linux", target_os = "android"))] + EOWNERDEAD => "Owner died", + + #[cfg(any(target_os = "linux", target_os = "android"))] + ENOTRECOVERABLE => "State not recoverable", + + #[cfg(all(target_os = "linux", not(target_arch="mips")))] + ERFKILL => "Operation not possible due to RF-kill", + + #[cfg(all(target_os = "linux", not(target_arch="mips")))] + EHWPOISON => "Memory page has hardware error", + + #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] + EDOOFUS => "Programming error", + + #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] + EMULTIHOP => "Multihop attempted", + + #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] + ENOLINK => "Link has been severed", + + #[cfg(target_os = "freebsd")] + ENOTCAPABLE => "Capabilities insufficient", + + #[cfg(target_os = "freebsd")] + ECAPMODE => "Not permitted in capability mode", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + ENEEDAUTH => "Need authenticator", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EOVERFLOW => "Value too large to be stored in data type", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "netbsd"))] + EILSEQ => "Illegal byte sequence", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + ENOATTR => "Attribute not found", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EBADMSG => "Bad message", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EPROTO => "Protocol error", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "ios", target_os = "openbsd", ))] + ENOTRECOVERABLE => "State not recoverable", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "ios", target_os = "openbsd"))] + EOWNERDEAD => "Previous owner died", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + ENOTSUP => "Operation not supported", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EPROCLIM => "Too many processes", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EUSERS => "Too many users", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EDQUOT => "Disc quota exceeded", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + ESTALE => "Stale NFS file handle", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EREMOTE => "Too many levels of remote in path", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EBADRPC => "RPC struct is bad", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + ERPCMISMATCH => "RPC version wrong", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EPROGUNAVAIL => "RPC prog. not avail", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EPROGMISMATCH => "Program version wrong", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EPROCUNAVAIL => "Bad procedure for program", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EFTYPE => "Inappropriate file type or format", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + EAUTH => "Authentication error", + + #[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd"))] + ECANCELED => "Operation canceled", + + #[cfg(any(target_os = "macos", target_os = "ios"))] + EPWROFF => "Device power is off", + + #[cfg(any(target_os = "macos", target_os = "ios"))] + EDEVERR => "Device error, e.g. paper out", + + #[cfg(any(target_os = "macos", target_os = "ios"))] + EBADEXEC => "Bad executable", + + #[cfg(any(target_os = "macos", target_os = "ios"))] + EBADARCH => "Bad CPU type in executable", + + #[cfg(any(target_os = "macos", target_os = "ios"))] + ESHLIBVERS => "Shared library version mismatch", + + #[cfg(any(target_os = "macos", target_os = "ios"))] + EBADMACHO => "Malformed Macho file", + + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + EMULTIHOP => "Reserved", + + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + ENODATA => "No message available on STREAM", + + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + ENOLINK => "Reserved", + + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + ENOSR => "No STREAM resources", + + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + ENOSTR => "Not a STREAM", + + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + ETIME => "STREAM ioctl timeout", + + #[cfg(any(target_os = "macos", target_os = "ios"))] + EOPNOTSUPP => "Operation not supported on socket", + + #[cfg(any(target_os = "macos", target_os = "ios"))] + ENOPOLICY => "No such policy registered", + + #[cfg(any(target_os = "macos", target_os = "ios"))] + EQFULL => "Interface output queue is full", + + #[cfg(target_os = "openbsd")] + EOPNOTSUPP => "Operation not supported", + + #[cfg(target_os = "openbsd")] + EIPSEC => "IPsec processing failure", + + #[cfg(target_os = "dragonfly")] + EASYNC => "Async", + } +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +mod consts { + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] + pub enum Errno { + UnknownErrno = 0, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EAGAIN = libc::EAGAIN, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EDEADLK = libc::EDEADLK, + ENAMETOOLONG = libc::ENAMETOOLONG, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + ENOTEMPTY = libc::ENOTEMPTY, + ELOOP = libc::ELOOP, + ENOMSG = libc::ENOMSG, + EIDRM = libc::EIDRM, + ECHRNG = libc::ECHRNG, + EL2NSYNC = libc::EL2NSYNC, + EL3HLT = libc::EL3HLT, + EL3RST = libc::EL3RST, + ELNRNG = libc::ELNRNG, + EUNATCH = libc::EUNATCH, + ENOCSI = libc::ENOCSI, + EL2HLT = libc::EL2HLT, + EBADE = libc::EBADE, + EBADR = libc::EBADR, + EXFULL = libc::EXFULL, + ENOANO = libc::ENOANO, + EBADRQC = libc::EBADRQC, + EBADSLT = libc::EBADSLT, + EBFONT = libc::EBFONT, + ENOSTR = libc::ENOSTR, + ENODATA = libc::ENODATA, + ETIME = libc::ETIME, + ENOSR = libc::ENOSR, + ENONET = libc::ENONET, + ENOPKG = libc::ENOPKG, + EREMOTE = libc::EREMOTE, + ENOLINK = libc::ENOLINK, + EADV = libc::EADV, + ESRMNT = libc::ESRMNT, + ECOMM = libc::ECOMM, + EPROTO = libc::EPROTO, + EMULTIHOP = libc::EMULTIHOP, + EDOTDOT = libc::EDOTDOT, + EBADMSG = libc::EBADMSG, + EOVERFLOW = libc::EOVERFLOW, + ENOTUNIQ = libc::ENOTUNIQ, + EBADFD = libc::EBADFD, + EREMCHG = libc::EREMCHG, + ELIBACC = libc::ELIBACC, + ELIBBAD = libc::ELIBBAD, + ELIBSCN = libc::ELIBSCN, + ELIBMAX = libc::ELIBMAX, + ELIBEXEC = libc::ELIBEXEC, + EILSEQ = libc::EILSEQ, + ERESTART = libc::ERESTART, + ESTRPIPE = libc::ESTRPIPE, + EUSERS = libc::EUSERS, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + EOPNOTSUPP = libc::EOPNOTSUPP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + EALREADY = libc::EALREADY, + EINPROGRESS = libc::EINPROGRESS, + ESTALE = libc::ESTALE, + EUCLEAN = libc::EUCLEAN, + ENOTNAM = libc::ENOTNAM, + ENAVAIL = libc::ENAVAIL, + EISNAM = libc::EISNAM, + EREMOTEIO = libc::EREMOTEIO, + EDQUOT = libc::EDQUOT, + ENOMEDIUM = libc::ENOMEDIUM, + EMEDIUMTYPE = libc::EMEDIUMTYPE, + ECANCELED = libc::ECANCELED, + ENOKEY = libc::ENOKEY, + EKEYEXPIRED = libc::EKEYEXPIRED, + EKEYREVOKED = libc::EKEYREVOKED, + EKEYREJECTED = libc::EKEYREJECTED, + EOWNERDEAD = libc::EOWNERDEAD, + ENOTRECOVERABLE = libc::ENOTRECOVERABLE, + #[cfg(not(any(target_os = "android", target_arch="mips")))] + ERFKILL = libc::ERFKILL, + #[cfg(not(any(target_os = "android", target_arch="mips")))] + EHWPOISON = libc::EHWPOISON, + } + + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + pub const EDEADLOCK: Errno = Errno::EDEADLK; + pub const ENOTSUP: Errno = Errno::EOPNOTSUPP; + + pub fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EAGAIN => EAGAIN, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EDEADLK => EDEADLK, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::ENOTEMPTY => ENOTEMPTY, + libc::ELOOP => ELOOP, + libc::ENOMSG => ENOMSG, + libc::EIDRM => EIDRM, + libc::ECHRNG => ECHRNG, + libc::EL2NSYNC => EL2NSYNC, + libc::EL3HLT => EL3HLT, + libc::EL3RST => EL3RST, + libc::ELNRNG => ELNRNG, + libc::EUNATCH => EUNATCH, + libc::ENOCSI => ENOCSI, + libc::EL2HLT => EL2HLT, + libc::EBADE => EBADE, + libc::EBADR => EBADR, + libc::EXFULL => EXFULL, + libc::ENOANO => ENOANO, + libc::EBADRQC => EBADRQC, + libc::EBADSLT => EBADSLT, + libc::EBFONT => EBFONT, + libc::ENOSTR => ENOSTR, + libc::ENODATA => ENODATA, + libc::ETIME => ETIME, + libc::ENOSR => ENOSR, + libc::ENONET => ENONET, + libc::ENOPKG => ENOPKG, + libc::EREMOTE => EREMOTE, + libc::ENOLINK => ENOLINK, + libc::EADV => EADV, + libc::ESRMNT => ESRMNT, + libc::ECOMM => ECOMM, + libc::EPROTO => EPROTO, + libc::EMULTIHOP => EMULTIHOP, + libc::EDOTDOT => EDOTDOT, + libc::EBADMSG => EBADMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::ENOTUNIQ => ENOTUNIQ, + libc::EBADFD => EBADFD, + libc::EREMCHG => EREMCHG, + libc::ELIBACC => ELIBACC, + libc::ELIBBAD => ELIBBAD, + libc::ELIBSCN => ELIBSCN, + libc::ELIBMAX => ELIBMAX, + libc::ELIBEXEC => ELIBEXEC, + libc::EILSEQ => EILSEQ, + libc::ERESTART => ERESTART, + libc::ESTRPIPE => ESTRPIPE, + libc::EUSERS => EUSERS, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::EOPNOTSUPP => EOPNOTSUPP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::EALREADY => EALREADY, + libc::EINPROGRESS => EINPROGRESS, + libc::ESTALE => ESTALE, + libc::EUCLEAN => EUCLEAN, + libc::ENOTNAM => ENOTNAM, + libc::ENAVAIL => ENAVAIL, + libc::EISNAM => EISNAM, + libc::EREMOTEIO => EREMOTEIO, + libc::EDQUOT => EDQUOT, + libc::ENOMEDIUM => ENOMEDIUM, + libc::EMEDIUMTYPE => EMEDIUMTYPE, + libc::ECANCELED => ECANCELED, + libc::ENOKEY => ENOKEY, + libc::EKEYEXPIRED => EKEYEXPIRED, + libc::EKEYREVOKED => EKEYREVOKED, + libc::EKEYREJECTED => EKEYREJECTED, + libc::EOWNERDEAD => EOWNERDEAD, + libc::ENOTRECOVERABLE => ENOTRECOVERABLE, + #[cfg(not(any(target_os = "android", target_arch="mips")))] + libc::ERFKILL => ERFKILL, + #[cfg(not(any(target_os = "android", target_arch="mips")))] + libc::EHWPOISON => EHWPOISON, + _ => UnknownErrno, + } + } +} + +#[cfg(any(target_os = "macos", target_os = "ios"))] +mod consts { + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] + pub enum Errno { + UnknownErrno = 0, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + ENOTSUP = libc::ENOTSUP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EFTYPE = libc::EFTYPE, + EAUTH = libc::EAUTH, + ENEEDAUTH = libc::ENEEDAUTH, + EPWROFF = libc::EPWROFF, + EDEVERR = libc::EDEVERR, + EOVERFLOW = libc::EOVERFLOW, + EBADEXEC = libc::EBADEXEC, + EBADARCH = libc::EBADARCH, + ESHLIBVERS = libc::ESHLIBVERS, + EBADMACHO = libc::EBADMACHO, + ECANCELED = libc::ECANCELED, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + EILSEQ = libc::EILSEQ, + ENOATTR = libc::ENOATTR, + EBADMSG = libc::EBADMSG, + EMULTIHOP = libc::EMULTIHOP, + ENODATA = libc::ENODATA, + ENOLINK = libc::ENOLINK, + ENOSR = libc::ENOSR, + ENOSTR = libc::ENOSTR, + EPROTO = libc::EPROTO, + ETIME = libc::ETIME, + EOPNOTSUPP = libc::EOPNOTSUPP, + ENOPOLICY = libc::ENOPOLICY, + ENOTRECOVERABLE = libc::ENOTRECOVERABLE, + EOWNERDEAD = libc::EOWNERDEAD, + EQFULL = libc::EQFULL, + } + + pub const ELAST: Errno = Errno::EQFULL; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + pub const EDEADLOCK: Errno = Errno::EDEADLK; + + pub const EL2NSYNC: Errno = Errno::UnknownErrno; + + pub fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::ENOTSUP => ENOTSUP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EFTYPE => EFTYPE, + libc::EAUTH => EAUTH, + libc::ENEEDAUTH => ENEEDAUTH, + libc::EPWROFF => EPWROFF, + libc::EDEVERR => EDEVERR, + libc::EOVERFLOW => EOVERFLOW, + libc::EBADEXEC => EBADEXEC, + libc::EBADARCH => EBADARCH, + libc::ESHLIBVERS => ESHLIBVERS, + libc::EBADMACHO => EBADMACHO, + libc::ECANCELED => ECANCELED, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::EILSEQ => EILSEQ, + libc::ENOATTR => ENOATTR, + libc::EBADMSG => EBADMSG, + libc::EMULTIHOP => EMULTIHOP, + libc::ENODATA => ENODATA, + libc::ENOLINK => ENOLINK, + libc::ENOSR => ENOSR, + libc::ENOSTR => ENOSTR, + libc::EPROTO => EPROTO, + libc::ETIME => ETIME, + libc::EOPNOTSUPP => EOPNOTSUPP, + libc::ENOPOLICY => ENOPOLICY, + libc::ENOTRECOVERABLE => ENOTRECOVERABLE, + libc::EOWNERDEAD => EOWNERDEAD, + libc::EQFULL => EQFULL, + _ => UnknownErrno, + } + } +} + +#[cfg(target_os = "freebsd")] +mod consts { + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] + pub enum Errno { + UnknownErrno = 0, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + ENOTSUP = libc::ENOTSUP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EFTYPE = libc::EFTYPE, + EAUTH = libc::EAUTH, + ENEEDAUTH = libc::ENEEDAUTH, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + EOVERFLOW = libc::EOVERFLOW, + ECANCELED = libc::ECANCELED, + EILSEQ = libc::EILSEQ, + ENOATTR = libc::ENOATTR, + EDOOFUS = libc::EDOOFUS, + EBADMSG = libc::EBADMSG, + EMULTIHOP = libc::EMULTIHOP, + ENOLINK = libc::ENOLINK, + EPROTO = libc::EPROTO, + ENOTCAPABLE = libc::ENOTCAPABLE, + ECAPMODE = libc::ECAPMODE, + ENOTRECOVERABLE = libc::ENOTRECOVERABLE, + EOWNERDEAD = libc::EOWNERDEAD, + } + + pub const ELAST: Errno = Errno::EOWNERDEAD; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + pub const EDEADLOCK: Errno = Errno::EDEADLK; + + pub const EL2NSYNC: Errno = Errno::UnknownErrno; + + pub fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::ENOTSUP => ENOTSUP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EFTYPE => EFTYPE, + libc::EAUTH => EAUTH, + libc::ENEEDAUTH => ENEEDAUTH, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::ECANCELED => ECANCELED, + libc::EILSEQ => EILSEQ, + libc::ENOATTR => ENOATTR, + libc::EDOOFUS => EDOOFUS, + libc::EBADMSG => EBADMSG, + libc::EMULTIHOP => EMULTIHOP, + libc::ENOLINK => ENOLINK, + libc::EPROTO => EPROTO, + libc::ENOTCAPABLE => ENOTCAPABLE, + libc::ECAPMODE => ECAPMODE, + libc::ENOTRECOVERABLE => ENOTRECOVERABLE, + libc::EOWNERDEAD => EOWNERDEAD, + _ => UnknownErrno, + } + } +} + + +#[cfg(target_os = "dragonfly")] +mod consts { + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] + pub enum Errno { + UnknownErrno = 0, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + ENOTSUP = libc::ENOTSUP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EFTYPE = libc::EFTYPE, + EAUTH = libc::EAUTH, + ENEEDAUTH = libc::ENEEDAUTH, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + EOVERFLOW = libc::EOVERFLOW, + ECANCELED = libc::ECANCELED, + EILSEQ = libc::EILSEQ, + ENOATTR = libc::ENOATTR, + EDOOFUS = libc::EDOOFUS, + EBADMSG = libc::EBADMSG, + EMULTIHOP = libc::EMULTIHOP, + ENOLINK = libc::ENOLINK, + EPROTO = libc::EPROTO, + ENOMEDIUM = libc::ENOMEDIUM, + EASYNC = libc::EASYNC, + } + + pub const ELAST: Errno = Errno::EASYNC; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + pub const EDEADLOCK: Errno = Errno::EDEADLK; + pub const EOPNOTSUPP: Errno = Errno::ENOTSUP; + + pub const EL2NSYNC: Errno = Errno::UnknownErrno; + + pub fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR=> EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::ENOTSUP => ENOTSUP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EFTYPE => EFTYPE, + libc::EAUTH => EAUTH, + libc::ENEEDAUTH => ENEEDAUTH, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::ECANCELED => ECANCELED, + libc::EILSEQ => EILSEQ, + libc::ENOATTR => ENOATTR, + libc::EDOOFUS => EDOOFUS, + libc::EBADMSG => EBADMSG, + libc::EMULTIHOP => EMULTIHOP, + libc::ENOLINK => ENOLINK, + libc::EPROTO => EPROTO, + libc::ENOMEDIUM => ENOMEDIUM, + libc::EASYNC => EASYNC, + _ => UnknownErrno, + } + } +} + + +#[cfg(target_os = "openbsd")] +mod consts { + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] + pub enum Errno { + UnknownErrno = 0, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + EOPNOTSUPP = libc::EOPNOTSUPP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EFTYPE = libc::EFTYPE, + EAUTH = libc::EAUTH, + ENEEDAUTH = libc::ENEEDAUTH, + EIPSEC = libc::EIPSEC, + ENOATTR = libc::ENOATTR, + EILSEQ = libc::EILSEQ, + ENOMEDIUM = libc::ENOMEDIUM, + EMEDIUMTYPE = libc::EMEDIUMTYPE, + EOVERFLOW = libc::EOVERFLOW, + ECANCELED = libc::ECANCELED, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + ENOTSUP = libc::ENOTSUP, + EBADMSG = libc::EBADMSG, + ENOTRECOVERABLE = libc::ENOTRECOVERABLE, + EOWNERDEAD = libc::EOWNERDEAD, + EPROTO = libc::EPROTO, + } + + pub const ELAST: Errno = Errno::ENOTSUP; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + + pub const EL2NSYNC: Errno = Errno::UnknownErrno; + + pub fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::EOPNOTSUPP => EOPNOTSUPP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EFTYPE => EFTYPE, + libc::EAUTH => EAUTH, + libc::ENEEDAUTH => ENEEDAUTH, + libc::EIPSEC => EIPSEC, + libc::ENOATTR => ENOATTR, + libc::EILSEQ => EILSEQ, + libc::ENOMEDIUM => ENOMEDIUM, + libc::EMEDIUMTYPE => EMEDIUMTYPE, + libc::EOVERFLOW => EOVERFLOW, + libc::ECANCELED => ECANCELED, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::ENOTSUP => ENOTSUP, + libc::EBADMSG => EBADMSG, + libc::ENOTRECOVERABLE => ENOTRECOVERABLE, + libc::EOWNERDEAD => EOWNERDEAD, + libc::EPROTO => EPROTO, + _ => UnknownErrno, + } + } +} + +#[cfg(target_os = "netbsd")] +mod consts { + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] + pub enum Errno { + UnknownErrno = 0, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + EOPNOTSUPP = libc::EOPNOTSUPP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EFTYPE = libc::EFTYPE, + EAUTH = libc::EAUTH, + ENEEDAUTH = libc::ENEEDAUTH, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + EOVERFLOW = libc::EOVERFLOW, + EILSEQ = libc::EILSEQ, + ENOTSUP = libc::ENOTSUP, + ECANCELED = libc::ECANCELED, + EBADMSG = libc::EBADMSG, + ENODATA = libc::ENODATA, + ENOSR = libc::ENOSR, + ENOSTR = libc::ENOSTR, + ETIME = libc::ETIME, + ENOATTR = libc::ENOATTR, + EMULTIHOP = libc::EMULTIHOP, + ENOLINK = libc::ENOLINK, + EPROTO = libc::EPROTO, + } + + pub const ELAST: Errno = Errno::ENOTSUP; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + + pub const EL2NSYNC: Errno = Errno::UnknownErrno; + + pub fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::EOPNOTSUPP => EOPNOTSUPP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EFTYPE => EFTYPE, + libc::EAUTH => EAUTH, + libc::ENEEDAUTH => ENEEDAUTH, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::EILSEQ => EILSEQ, + libc::ENOTSUP => ENOTSUP, + libc::ECANCELED => ECANCELED, + libc::EBADMSG => EBADMSG, + libc::ENODATA => ENODATA, + libc::ENOSR => ENOSR, + libc::ENOSTR => ENOSTR, + libc::ETIME => ETIME, + libc::ENOATTR => ENOATTR, + libc::EMULTIHOP => EMULTIHOP, + libc::ENOLINK => ENOLINK, + libc::EPROTO => EPROTO, + _ => UnknownErrno, + } + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/errno_dragonfly.c b/third_party/cargo/vendor/nix-0.14.1/src/errno_dragonfly.c new file mode 100644 index 0000000..32fb4da --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/errno_dragonfly.c @@ -0,0 +1,3 @@ +#include + +int *errno_location() { return &errno; } diff --git a/third_party/cargo/vendor/nix-0.14.1/src/fcntl.rs b/third_party/cargo/vendor/nix-0.14.1/src/fcntl.rs new file mode 100644 index 0000000..40f4cf9 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/fcntl.rs @@ -0,0 +1,394 @@ +use {Error, Result, NixPath}; +use errno::Errno; +use libc::{self, c_int, c_uint, c_char, size_t, ssize_t}; +use sys::stat::Mode; +use std::os::raw; +use std::os::unix::io::RawFd; +use std::ffi::OsStr; +use std::os::unix::ffi::OsStrExt; + +#[cfg(any(target_os = "android", target_os = "linux"))] +use sys::uio::IoVec; // For vmsplice + +libc_bitflags!{ + pub struct AtFlags: c_int { + AT_SYMLINK_NOFOLLOW; + #[cfg(any(target_os = "android", target_os = "linux"))] + AT_NO_AUTOMOUNT; + #[cfg(any(target_os = "android", target_os = "linux"))] + AT_EMPTY_PATH; + } +} + +libc_bitflags!( + /// Configuration options for opened files. + pub struct OFlag: c_int { + /// Mask for the access mode of the file. + O_ACCMODE; + /// Use alternate I/O semantics. + #[cfg(target_os = "netbsd")] + O_ALT_IO; + /// Open the file in append-only mode. + O_APPEND; + /// Generate a signal when input or output becomes possible. + O_ASYNC; + /// Closes the file descriptor once an `execve` call is made. + /// + /// Also sets the file offset to the beginning of the file. + O_CLOEXEC; + /// Create the file if it does not exist. + O_CREAT; + /// Try to minimize cache effects of the I/O for this file. + #[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd"))] + O_DIRECT; + /// If the specified path isn't a directory, fail. + O_DIRECTORY; + /// Implicitly follow each `write()` with an `fdatasync()`. + #[cfg(any(target_os = "android", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + O_DSYNC; + /// Error out if a file was not created. + O_EXCL; + /// Open for execute only. + #[cfg(target_os = "freebsd")] + O_EXEC; + /// Open with an exclusive file lock. + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + O_EXLOCK; + /// Same as `O_SYNC`. + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + all(target_os = "linux", not(target_env = "musl")), + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + O_FSYNC; + /// Allow files whose sizes can't be represented in an `off_t` to be opened. + #[cfg(any(target_os = "android", target_os = "linux"))] + O_LARGEFILE; + /// Do not update the file last access time during `read(2)`s. + #[cfg(any(target_os = "android", target_os = "linux"))] + O_NOATIME; + /// Don't attach the device as the process' controlling terminal. + O_NOCTTY; + /// Same as `O_NONBLOCK`. + O_NDELAY; + /// `open()` will fail if the given path is a symbolic link. + O_NOFOLLOW; + /// When possible, open the file in nonblocking mode. + O_NONBLOCK; + /// Don't deliver `SIGPIPE`. + #[cfg(target_os = "netbsd")] + O_NOSIGPIPE; + /// Obtain a file descriptor for low-level access. + /// + /// The file itself is not opened and other file operations will fail. + #[cfg(any(target_os = "android", target_os = "linux"))] + O_PATH; + /// Only allow reading. + /// + /// This should not be combined with `O_WRONLY` or `O_RDWR`. + O_RDONLY; + /// Allow both reading and writing. + /// + /// This should not be combined with `O_WRONLY` or `O_RDONLY`. + O_RDWR; + /// Similar to `O_DSYNC` but applies to `read`s instead. + #[cfg(any(target_os = "linux", target_os = "netbsd", target_os = "openbsd"))] + O_RSYNC; + /// Skip search permission checks. + #[cfg(target_os = "netbsd")] + O_SEARCH; + /// Open with a shared file lock. + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + O_SHLOCK; + /// Implicitly follow each `write()` with an `fsync()`. + O_SYNC; + /// Create an unnamed temporary file. + #[cfg(any(target_os = "android", target_os = "linux"))] + O_TMPFILE; + /// Truncate an existing regular file to 0 length if it allows writing. + O_TRUNC; + /// Restore default TTY attributes. + #[cfg(target_os = "freebsd")] + O_TTY_INIT; + /// Only allow writing. + /// + /// This should not be combined with `O_RDONLY` or `O_RDWR`. + O_WRONLY; + } +); + +pub fn open(path: &P, oflag: OFlag, mode: Mode) -> Result { + let fd = path.with_nix_path(|cstr| { + unsafe { libc::open(cstr.as_ptr(), oflag.bits(), mode.bits() as c_uint) } + })?; + + Errno::result(fd) +} + +pub fn openat(dirfd: RawFd, path: &P, oflag: OFlag, mode: Mode) -> Result { + let fd = path.with_nix_path(|cstr| { + unsafe { libc::openat(dirfd, cstr.as_ptr(), oflag.bits(), mode.bits() as c_uint) } + })?; + Errno::result(fd) +} + +fn wrap_readlink_result(buffer: &mut[u8], res: ssize_t) -> Result<&OsStr> { + match Errno::result(res) { + Err(err) => Err(err), + Ok(len) => { + if (len as usize) >= buffer.len() { + Err(Error::Sys(Errno::ENAMETOOLONG)) + } else { + Ok(OsStr::from_bytes(&buffer[..(len as usize)])) + } + } + } +} + +pub fn readlink<'a, P: ?Sized + NixPath>(path: &P, buffer: &'a mut [u8]) -> Result<&'a OsStr> { + let res = path.with_nix_path(|cstr| { + unsafe { libc::readlink(cstr.as_ptr(), buffer.as_mut_ptr() as *mut c_char, buffer.len() as size_t) } + })?; + + wrap_readlink_result(buffer, res) +} + + +pub fn readlinkat<'a, P: ?Sized + NixPath>(dirfd: RawFd, path: &P, buffer: &'a mut [u8]) -> Result<&'a OsStr> { + let res = path.with_nix_path(|cstr| { + unsafe { libc::readlinkat(dirfd, cstr.as_ptr(), buffer.as_mut_ptr() as *mut c_char, buffer.len() as size_t) } + })?; + + wrap_readlink_result(buffer, res) +} + +/// Computes the raw fd consumed by a function of the form `*at`. +pub(crate) fn at_rawfd(fd: Option) -> raw::c_int { + match fd { + None => libc::AT_FDCWD, + Some(fd) => fd, + } +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +libc_bitflags!( + /// Additional flags for file sealing, which allows for limiting operations on a file. + pub struct SealFlag: c_int { + /// Prevents further calls to `fcntl()` with `F_ADD_SEALS`. + F_SEAL_SEAL; + /// The file cannot be reduced in size. + F_SEAL_SHRINK; + /// The size of the file cannot be increased. + F_SEAL_GROW; + /// The file contents cannot be modified. + F_SEAL_WRITE; + } +); + +libc_bitflags!( + /// Additional configuration flags for `fcntl`'s `F_SETFD`. + pub struct FdFlag: c_int { + /// The file descriptor will automatically be closed during a successful `execve(2)`. + FD_CLOEXEC; + } +); + +#[allow(missing_debug_implementations)] +pub enum FcntlArg<'a> { + F_DUPFD(RawFd), + F_DUPFD_CLOEXEC(RawFd), + F_GETFD, + F_SETFD(FdFlag), // FD_FLAGS + F_GETFL, + F_SETFL(OFlag), // O_NONBLOCK + F_SETLK(&'a libc::flock), + F_SETLKW(&'a libc::flock), + F_GETLK(&'a mut libc::flock), + #[cfg(any(target_os = "linux", target_os = "android"))] + F_OFD_SETLK(&'a libc::flock), + #[cfg(any(target_os = "linux", target_os = "android"))] + F_OFD_SETLKW(&'a libc::flock), + #[cfg(any(target_os = "linux", target_os = "android"))] + F_OFD_GETLK(&'a mut libc::flock), + #[cfg(any(target_os = "android", target_os = "linux"))] + F_ADD_SEALS(SealFlag), + #[cfg(any(target_os = "android", target_os = "linux"))] + F_GET_SEALS, + #[cfg(any(target_os = "macos", target_os = "ios"))] + F_FULLFSYNC, + #[cfg(any(target_os = "linux", target_os = "android"))] + F_GETPIPE_SZ, + #[cfg(any(target_os = "linux", target_os = "android"))] + F_SETPIPE_SZ(c_int), + + // TODO: Rest of flags +} +pub use self::FcntlArg::*; + +// TODO: Figure out how to handle value fcntl returns +pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result { + let res = unsafe { + match arg { + F_DUPFD(rawfd) => libc::fcntl(fd, libc::F_DUPFD, rawfd), + F_DUPFD_CLOEXEC(rawfd) => libc::fcntl(fd, libc::F_DUPFD_CLOEXEC, rawfd), + F_GETFD => libc::fcntl(fd, libc::F_GETFD), + F_SETFD(flag) => libc::fcntl(fd, libc::F_SETFD, flag.bits()), + F_GETFL => libc::fcntl(fd, libc::F_GETFL), + F_SETFL(flag) => libc::fcntl(fd, libc::F_SETFL, flag.bits()), + F_SETLK(flock) => libc::fcntl(fd, libc::F_SETLK, flock), + F_SETLKW(flock) => libc::fcntl(fd, libc::F_SETLKW, flock), + F_GETLK(flock) => libc::fcntl(fd, libc::F_GETLK, flock), + #[cfg(any(target_os = "android", target_os = "linux"))] + F_ADD_SEALS(flag) => libc::fcntl(fd, libc::F_ADD_SEALS, flag.bits()), + #[cfg(any(target_os = "android", target_os = "linux"))] + F_GET_SEALS => libc::fcntl(fd, libc::F_GET_SEALS), + #[cfg(any(target_os = "macos", target_os = "ios"))] + F_FULLFSYNC => libc::fcntl(fd, libc::F_FULLFSYNC), + #[cfg(any(target_os = "linux", target_os = "android"))] + F_GETPIPE_SZ => libc::fcntl(fd, libc::F_GETPIPE_SZ), + #[cfg(any(target_os = "linux", target_os = "android"))] + F_SETPIPE_SZ(size) => libc::fcntl(fd, libc::F_SETPIPE_SZ, size), + #[cfg(any(target_os = "linux", target_os = "android"))] + _ => unimplemented!() + } + }; + + Errno::result(res) +} + +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub enum FlockArg { + LockShared, + LockExclusive, + Unlock, + LockSharedNonblock, + LockExclusiveNonblock, + UnlockNonblock, +} + +pub fn flock(fd: RawFd, arg: FlockArg) -> Result<()> { + use self::FlockArg::*; + + let res = unsafe { + match arg { + LockShared => libc::flock(fd, libc::LOCK_SH), + LockExclusive => libc::flock(fd, libc::LOCK_EX), + Unlock => libc::flock(fd, libc::LOCK_UN), + LockSharedNonblock => libc::flock(fd, libc::LOCK_SH | libc::LOCK_NB), + LockExclusiveNonblock => libc::flock(fd, libc::LOCK_EX | libc::LOCK_NB), + UnlockNonblock => libc::flock(fd, libc::LOCK_UN | libc::LOCK_NB), + } + }; + + Errno::result(res).map(drop) +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +libc_bitflags! { + /// Additional flags to `splice` and friends. + pub struct SpliceFFlags: c_uint { + /// Request that pages be moved instead of copied. + /// + /// Not applicable to `vmsplice`. + SPLICE_F_MOVE; + /// Do not block on I/O. + SPLICE_F_NONBLOCK; + /// Hint that more data will be coming in a subsequent splice. + /// + /// Not applicable to `vmsplice`. + SPLICE_F_MORE; + /// Gift the user pages to the kernel. + /// + /// Not applicable to `splice`. + SPLICE_F_GIFT; + } +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +pub fn splice(fd_in: RawFd, off_in: Option<&mut libc::loff_t>, + fd_out: RawFd, off_out: Option<&mut libc::loff_t>, + len: usize, flags: SpliceFFlags) -> Result { + use std::ptr; + let off_in = off_in.map(|offset| offset as *mut _).unwrap_or(ptr::null_mut()); + let off_out = off_out.map(|offset| offset as *mut _).unwrap_or(ptr::null_mut()); + + let ret = unsafe { libc::splice(fd_in, off_in, fd_out, off_out, len, flags.bits()) }; + Errno::result(ret).map(|r| r as usize) +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +pub fn tee(fd_in: RawFd, fd_out: RawFd, len: usize, flags: SpliceFFlags) -> Result { + let ret = unsafe { libc::tee(fd_in, fd_out, len, flags.bits()) }; + Errno::result(ret).map(|r| r as usize) +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +pub fn vmsplice(fd: RawFd, iov: &[IoVec<&[u8]>], flags: SpliceFFlags) -> Result { + let ret = unsafe { + libc::vmsplice(fd, iov.as_ptr() as *const libc::iovec, iov.len(), flags.bits()) + }; + Errno::result(ret).map(|r| r as usize) +} + +#[cfg(any(target_os = "linux"))] +libc_bitflags!( + /// Mode argument flags for fallocate determining operation performed on a given range. + pub struct FallocateFlags: c_int { + /// File size is not changed. + /// + /// offset + len can be greater than file size. + FALLOC_FL_KEEP_SIZE; + /// Deallocates space by creating a hole. + /// + /// Must be ORed with FALLOC_FL_KEEP_SIZE. Byte range starts at offset and continues for len bytes. + FALLOC_FL_PUNCH_HOLE; + /// Removes byte range from a file without leaving a hole. + /// + /// Byte range to collapse starts at offset and continues for len bytes. + FALLOC_FL_COLLAPSE_RANGE; + /// Zeroes space in specified byte range. + /// + /// Byte range starts at offset and continues for len bytes. + FALLOC_FL_ZERO_RANGE; + /// Increases file space by inserting a hole within the file size. + /// + /// Does not overwrite existing data. Hole starts at offset and continues for len bytes. + FALLOC_FL_INSERT_RANGE; + /// Shared file data extants are made private to the file. + /// + /// Gaurantees that a subsequent write will not fail due to lack of space. + FALLOC_FL_UNSHARE_RANGE; + } +); + +/// Manipulates file space. +/// +/// Allows the caller to directly manipulate the allocated disk space for the +/// file referred to by fd. +#[cfg(any(target_os = "linux"))] +pub fn fallocate(fd: RawFd, mode: FallocateFlags, offset: libc::off_t, len: libc::off_t) -> Result { + let res = unsafe { libc::fallocate(fd, mode.bits(), offset, len) }; + Errno::result(res) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/features.rs b/third_party/cargo/vendor/nix-0.14.1/src/features.rs new file mode 100644 index 0000000..7797aa4 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/features.rs @@ -0,0 +1,103 @@ +//! Feature tests for OS functionality +pub use self::os::*; + +#[cfg(any(target_os = "linux", target_os = "android"))] +mod os { + use sys::utsname::uname; + + // Features: + // * atomic cloexec on socket: 2.6.27 + // * pipe2: 2.6.27 + // * accept4: 2.6.28 + + static VERS_UNKNOWN: usize = 1; + static VERS_2_6_18: usize = 2; + static VERS_2_6_27: usize = 3; + static VERS_2_6_28: usize = 4; + static VERS_3: usize = 5; + + #[inline] + fn digit(dst: &mut usize, b: u8) { + *dst *= 10; + *dst += (b - b'0') as usize; + } + + fn parse_kernel_version() -> usize { + let u = uname(); + + let mut curr: usize = 0; + let mut major: usize = 0; + let mut minor: usize = 0; + let mut patch: usize = 0; + + for b in u.release().bytes() { + if curr >= 3 { + break; + } + + match b { + b'.' | b'-' => { + curr += 1; + } + b'0'...b'9' => { + match curr { + 0 => digit(&mut major, b), + 1 => digit(&mut minor, b), + _ => digit(&mut patch, b), + } + } + _ => break, + } + } + + if major >= 3 { + VERS_3 + } else if major >= 2 { + if minor >= 7 { + VERS_UNKNOWN + } else if minor >= 6 { + if patch >= 28 { + VERS_2_6_28 + } else if patch >= 27 { + VERS_2_6_27 + } else { + VERS_2_6_18 + } + } else { + VERS_UNKNOWN + } + } else { + VERS_UNKNOWN + } + } + + fn kernel_version() -> usize { + static mut KERNEL_VERS: usize = 0; + + unsafe { + if KERNEL_VERS == 0 { + KERNEL_VERS = parse_kernel_version(); + } + + KERNEL_VERS + } + } + + /// Check if the OS supports atomic close-on-exec for sockets + pub fn socket_atomic_cloexec() -> bool { + kernel_version() >= VERS_2_6_27 + } + + #[test] + pub fn test_parsing_kernel_version() { + assert!(kernel_version() > 0); + } +} + +#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] +mod os { + /// Check if the OS supports atomic close-on-exec for sockets + pub fn socket_atomic_cloexec() -> bool { + false + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/ifaddrs.rs b/third_party/cargo/vendor/nix-0.14.1/src/ifaddrs.rs new file mode 100644 index 0000000..61d36ff --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/ifaddrs.rs @@ -0,0 +1,146 @@ +//! Query network interface addresses +//! +//! Uses the Linux and/or BSD specific function `getifaddrs` to query the list +//! of interfaces and their associated addresses. + +use std::ffi; +use std::iter::Iterator; +use std::mem; +use std::option::Option; + +use libc; + +use {Result, Errno}; +use sys::socket::SockAddr; +use net::if_::*; + +/// Describes a single address for an interface as returned by `getifaddrs`. +#[derive(Clone, Eq, Hash, PartialEq, Debug)] +pub struct InterfaceAddress { + /// Name of the network interface + pub interface_name: String, + /// Flags as from `SIOCGIFFLAGS` ioctl + pub flags: InterfaceFlags, + /// Network address of this interface + pub address: Option, + /// Netmask of this interface + pub netmask: Option, + /// Broadcast address of this interface, if applicable + pub broadcast: Option, + /// Point-to-point destination address + pub destination: Option, +} + +cfg_if! { + if #[cfg(any(target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))] { + fn get_ifu_from_sockaddr(info: &libc::ifaddrs) -> *const libc::sockaddr { + info.ifa_ifu + } + } else { + fn get_ifu_from_sockaddr(info: &libc::ifaddrs) -> *const libc::sockaddr { + info.ifa_dstaddr + } + } +} + +impl InterfaceAddress { + /// Create an `InterfaceAddress` from the libc struct. + fn from_libc_ifaddrs(info: &libc::ifaddrs) -> InterfaceAddress { + let ifname = unsafe { ffi::CStr::from_ptr(info.ifa_name) }; + let address = unsafe { SockAddr::from_libc_sockaddr(info.ifa_addr) }; + let netmask = unsafe { SockAddr::from_libc_sockaddr(info.ifa_netmask) }; + let mut addr = InterfaceAddress { + interface_name: ifname.to_string_lossy().to_string(), + flags: InterfaceFlags::from_bits_truncate(info.ifa_flags as i32), + address: address, + netmask: netmask, + broadcast: None, + destination: None, + }; + + let ifu = get_ifu_from_sockaddr(info); + if addr.flags.contains(InterfaceFlags::IFF_POINTOPOINT) { + addr.destination = unsafe { SockAddr::from_libc_sockaddr(ifu) }; + } else if addr.flags.contains(InterfaceFlags::IFF_BROADCAST) { + addr.broadcast = unsafe { SockAddr::from_libc_sockaddr(ifu) }; + } + + addr + } +} + +/// Holds the results of `getifaddrs`. +/// +/// Use the function `getifaddrs` to create this Iterator. Note that the +/// actual list of interfaces can be iterated once and will be freed as +/// soon as the Iterator goes out of scope. +#[derive(Debug, Eq, Hash, PartialEq)] +pub struct InterfaceAddressIterator { + base: *mut libc::ifaddrs, + next: *mut libc::ifaddrs, +} + +impl Drop for InterfaceAddressIterator { + fn drop(&mut self) { + unsafe { libc::freeifaddrs(self.base) }; + } +} + +impl Iterator for InterfaceAddressIterator { + type Item = InterfaceAddress; + fn next(&mut self) -> Option<::Item> { + match unsafe { self.next.as_ref() } { + Some(ifaddr) => { + self.next = ifaddr.ifa_next; + Some(InterfaceAddress::from_libc_ifaddrs(ifaddr)) + } + None => None, + } + } +} + +/// Get interface addresses using libc's `getifaddrs` +/// +/// Note that the underlying implementation differs between OSes. Only the +/// most common address families are supported by the nix crate (due to +/// lack of time and complexity of testing). The address family is encoded +/// in the specific variant of `SockAddr` returned for the fields `address`, +/// `netmask`, `broadcast`, and `destination`. For any entry not supported, +/// the returned list will contain a `None` entry. +/// +/// # Example +/// ``` +/// let addrs = nix::ifaddrs::getifaddrs().unwrap(); +/// for ifaddr in addrs { +/// match ifaddr.address { +/// Some(address) => { +/// println!("interface {} address {}", +/// ifaddr.interface_name, address); +/// }, +/// None => { +/// println!("interface {} with unsupported address family", +/// ifaddr.interface_name); +/// } +/// } +/// } +/// ``` +pub fn getifaddrs() -> Result { + let mut addrs: *mut libc::ifaddrs = unsafe { mem::uninitialized() }; + Errno::result(unsafe { libc::getifaddrs(&mut addrs) }).map(|_| { + InterfaceAddressIterator { + base: addrs, + next: addrs, + } + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + // Only checks if `getifaddrs` can be invoked without panicking. + #[test] + fn test_getifaddrs() { + let _ = getifaddrs(); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/kmod.rs b/third_party/cargo/vendor/nix-0.14.1/src/kmod.rs new file mode 100644 index 0000000..e853261 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/kmod.rs @@ -0,0 +1,123 @@ +//! Load and unload kernel modules. +//! +//! For more details see + +use libc; +use std::ffi::CStr; +use std::os::unix::io::AsRawFd; + +use errno::Errno; +use Result; + +/// Loads a kernel module from a buffer. +/// +/// It loads an ELF image into kernel space, +/// performs any necessary symbol relocations, +/// initializes module parameters to values provided by the caller, +/// and then runs the module's init function. +/// +/// This function requires `CAP_SYS_MODULE` privilege. +/// +/// The `module_image` argument points to a buffer containing the binary image +/// to be loaded. The buffer should contain a valid ELF image +/// built for the running kernel. +/// +/// The `param_values` argument is a string containing space-delimited specifications +/// of the values for module parameters. +/// Each of the parameter specifications has the form: +/// +/// `name[=value[,value...]]` +/// +/// # Example +/// +/// ```no_run +/// use std::fs::File; +/// use std::io::Read; +/// use std::ffi::CString; +/// use nix::kmod::init_module; +/// +/// let mut f = File::open("mykernel.ko").unwrap(); +/// let mut contents: Vec = Vec::new(); +/// f.read_to_end(&mut contents).unwrap(); +/// init_module(&mut contents, &CString::new("who=Rust when=Now,12").unwrap()).unwrap(); +/// ``` +/// +/// See [`man init_module(2)`](http://man7.org/linux/man-pages/man2/init_module.2.html) for more information. +pub fn init_module(module_image: &[u8], param_values: &CStr) -> Result<()> { + let res = unsafe { + libc::syscall( + libc::SYS_init_module, + module_image.as_ptr(), + module_image.len(), + param_values.as_ptr(), + ) + }; + + Errno::result(res).map(drop) +} + +libc_bitflags!( + /// Flags used by the `finit_module` function. + pub struct ModuleInitFlags: libc::c_uint { + /// Ignore symbol version hashes. + MODULE_INIT_IGNORE_MODVERSIONS; + /// Ignore kernel version magic. + MODULE_INIT_IGNORE_VERMAGIC; + } +); + +/// Loads a kernel module from a given file descriptor. +/// +/// # Example +/// +/// ```no_run +/// use std::fs::File; +/// use std::ffi::CString; +/// use nix::kmod::{finit_module, ModuleInitFlags}; +/// +/// let f = File::open("mymod.ko").unwrap(); +/// finit_module(&f, &CString::new("").unwrap(), ModuleInitFlags::empty()).unwrap(); +/// ``` +/// +/// See [`man init_module(2)`](http://man7.org/linux/man-pages/man2/init_module.2.html) for more information. +pub fn finit_module(fd: &T, param_values: &CStr, flags: ModuleInitFlags) -> Result<()> { + let res = unsafe { + libc::syscall( + libc::SYS_finit_module, + fd.as_raw_fd(), + param_values.as_ptr(), + flags.bits(), + ) + }; + + Errno::result(res).map(drop) +} + +libc_bitflags!( + /// Flags used by `delete_module`. + /// + /// See [`man delete_module(2)`](http://man7.org/linux/man-pages/man2/delete_module.2.html) + /// for a detailed description how these flags work. + pub struct DeleteModuleFlags: libc::c_int { + O_NONBLOCK; + O_TRUNC; + } +); + +/// Unloads the kernel module with the given name. +/// +/// # Example +/// +/// ```no_run +/// use std::ffi::CString; +/// use nix::kmod::{delete_module, DeleteModuleFlags}; +/// +/// delete_module(&CString::new("mymod").unwrap(), DeleteModuleFlags::O_NONBLOCK).unwrap(); +/// ``` +/// +/// See [`man delete_module(2)`](http://man7.org/linux/man-pages/man2/delete_module.2.html) for more information. +pub fn delete_module(name: &CStr, flags: DeleteModuleFlags) -> Result<()> { + let res = unsafe { libc::syscall(libc::SYS_delete_module, name.as_ptr(), flags.bits()) }; + + Errno::result(res).map(drop) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/lib.rs b/third_party/cargo/vendor/nix-0.14.1/src/lib.rs new file mode 100644 index 0000000..ae3cc73 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/lib.rs @@ -0,0 +1,283 @@ +//! Rust friendly bindings to the various *nix system functions. +//! +//! Modules are structured according to the C header file that they would be +//! defined in. +#![crate_name = "nix"] +#![cfg(unix)] +#![allow(non_camel_case_types)] +// latest bitflags triggers a rustc bug with cross-crate macro expansions causing dead_code +// warnings even though the macro expands into something with allow(dead_code) +#![allow(dead_code)] +#![cfg_attr(test, deny(warnings))] +#![recursion_limit = "500"] +#![deny(unused)] +#![deny(unstable_features)] +#![deny(missing_copy_implementations)] +#![deny(missing_debug_implementations)] + +// External crates +#[macro_use] +extern crate bitflags; +#[macro_use] +extern crate cfg_if; +extern crate void; + +// Re-exported external crates +pub extern crate libc; + +// Private internal modules +#[macro_use] mod macros; + +// Public crates +pub mod dir; +pub mod errno; +#[deny(missing_docs)] +pub mod features; +pub mod fcntl; +#[deny(missing_docs)] +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +pub mod ifaddrs; +#[cfg(any(target_os = "android", + target_os = "linux"))] +pub mod kmod; +#[cfg(any(target_os = "android", + target_os = "linux"))] +pub mod mount; +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "fushsia", + target_os = "linux", + target_os = "netbsd"))] +pub mod mqueue; +#[deny(missing_docs)] +pub mod net; +#[deny(missing_docs)] +pub mod poll; +#[deny(missing_docs)] +pub mod pty; +#[cfg(any(target_os = "android", + target_os = "linux"))] +pub mod sched; +pub mod sys; +// This can be implemented for other platforms as soon as libc +// provides bindings for them. +#[cfg(all(target_os = "linux", + any(target_arch = "x86", target_arch = "x86_64")))] +pub mod ucontext; +pub mod unistd; + +/* + * + * ===== Result / Error ===== + * + */ + +use libc::{c_char, PATH_MAX}; + +use std::{error, fmt, ptr, result}; +use std::ffi::{CStr, OsStr}; +use std::os::unix::ffi::OsStrExt; +use std::path::{Path, PathBuf}; + +use errno::Errno; + +/// Nix Result Type +pub type Result = result::Result; + +/// Nix Error Type +/// +/// The nix error type provides a common way of dealing with +/// various system system/libc calls that might fail. Each +/// error has a corresponding errno (usually the one from the +/// underlying OS) to which it can be mapped in addition to +/// implementing other common traits. +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum Error { + Sys(Errno), + InvalidPath, + /// The operation involved a conversion to Rust's native String type, which failed because the + /// string did not contain all valid UTF-8. + InvalidUtf8, + /// The operation is not supported by Nix, in this instance either use the libc bindings or + /// consult the module documentation to see if there is a more appropriate interface available. + UnsupportedOperation, +} + +impl Error { + /// Convert this `Error` to an [`Errno`](enum.Errno.html). + /// + /// # Example + /// + /// ``` + /// # use nix::Error; + /// # use nix::errno::Errno; + /// let e = Error::from(Errno::EPERM); + /// assert_eq!(Some(Errno::EPERM), e.as_errno()); + /// ``` + pub fn as_errno(&self) -> Option { + if let &Error::Sys(ref e) = self { + Some(*e) + } else { + None + } + } + + /// Create a nix Error from a given errno + pub fn from_errno(errno: Errno) -> Error { + Error::Sys(errno) + } + + /// Get the current errno and convert it to a nix Error + pub fn last() -> Error { + Error::Sys(Errno::last()) + } + + /// Create a new invalid argument error (`EINVAL`) + pub fn invalid_argument() -> Error { + Error::Sys(Errno::EINVAL) + } + +} + +impl From for Error { + fn from(errno: Errno) -> Error { Error::from_errno(errno) } +} + +impl From for Error { + fn from(_: std::string::FromUtf8Error) -> Error { Error::InvalidUtf8 } +} + +impl error::Error for Error { + fn description(&self) -> &str { + match *self { + Error::InvalidPath => "Invalid path", + Error::InvalidUtf8 => "Invalid UTF-8 string", + Error::UnsupportedOperation => "Unsupported Operation", + Error::Sys(ref errno) => errno.desc(), + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Error::InvalidPath => write!(f, "Invalid path"), + Error::InvalidUtf8 => write!(f, "Invalid UTF-8 string"), + Error::UnsupportedOperation => write!(f, "Unsupported Operation"), + Error::Sys(errno) => write!(f, "{:?}: {}", errno, errno.desc()), + } + } +} + +pub trait NixPath { + fn len(&self) -> usize; + + fn with_nix_path(&self, f: F) -> Result + where F: FnOnce(&CStr) -> T; +} + +impl NixPath for str { + fn len(&self) -> usize { + NixPath::len(OsStr::new(self)) + } + + fn with_nix_path(&self, f: F) -> Result + where F: FnOnce(&CStr) -> T { + OsStr::new(self).with_nix_path(f) + } +} + +impl NixPath for OsStr { + fn len(&self) -> usize { + self.as_bytes().len() + } + + fn with_nix_path(&self, f: F) -> Result + where F: FnOnce(&CStr) -> T { + self.as_bytes().with_nix_path(f) + } +} + +impl NixPath for CStr { + fn len(&self) -> usize { + self.to_bytes().len() + } + + fn with_nix_path(&self, f: F) -> Result + where F: FnOnce(&CStr) -> T { + // Equivalence with the [u8] impl. + if self.len() >= PATH_MAX as usize { + return Err(Error::InvalidPath); + } + + Ok(f(self)) + } +} + +impl NixPath for [u8] { + fn len(&self) -> usize { + self.len() + } + + fn with_nix_path(&self, f: F) -> Result + where F: FnOnce(&CStr) -> T { + let mut buf = [0u8; PATH_MAX as usize]; + + if self.len() >= PATH_MAX as usize { + return Err(Error::InvalidPath); + } + + match self.iter().position(|b| *b == 0) { + Some(_) => Err(Error::InvalidPath), + None => { + unsafe { + // TODO: Replace with bytes::copy_memory. rust-lang/rust#24028 + ptr::copy_nonoverlapping(self.as_ptr(), buf.as_mut_ptr(), self.len()); + Ok(f(CStr::from_ptr(buf.as_ptr() as *const c_char))) + } + + } + } + } +} + +impl NixPath for Path { + fn len(&self) -> usize { + NixPath::len(self.as_os_str()) + } + + fn with_nix_path(&self, f: F) -> Result where F: FnOnce(&CStr) -> T { + self.as_os_str().with_nix_path(f) + } +} + +impl NixPath for PathBuf { + fn len(&self) -> usize { + NixPath::len(self.as_os_str()) + } + + fn with_nix_path(&self, f: F) -> Result where F: FnOnce(&CStr) -> T { + self.as_os_str().with_nix_path(f) + } +} + +/// Treats `None` as an empty string. +impl<'a, NP: ?Sized + NixPath> NixPath for Option<&'a NP> { + fn len(&self) -> usize { + self.map_or(0, NixPath::len) + } + + fn with_nix_path(&self, f: F) -> Result where F: FnOnce(&CStr) -> T { + if let Some(nix_path) = *self { + nix_path.with_nix_path(f) + } else { + unsafe { CStr::from_ptr("\0".as_ptr() as *const _).with_nix_path(f) } + } + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/macros.rs b/third_party/cargo/vendor/nix-0.14.1/src/macros.rs new file mode 100644 index 0000000..3d1b0e4 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/macros.rs @@ -0,0 +1,264 @@ +/// The `libc_bitflags!` macro helps with a common use case of defining a public bitflags type +/// with values from the libc crate. It is used the same way as the `bitflags!` macro, except +/// that only the name of the flag value has to be given. +/// +/// The `libc` crate must be in scope with the name `libc`. +/// +/// # Example +/// ``` +/// libc_bitflags!{ +/// pub struct ProtFlags: libc::c_int { +/// PROT_NONE; +/// PROT_READ; +/// /// PROT_WRITE enables write protect +/// PROT_WRITE; +/// PROT_EXEC; +/// #[cfg(any(target_os = "linux", target_os = "android"))] +/// PROT_GROWSDOWN; +/// #[cfg(any(target_os = "linux", target_os = "android"))] +/// PROT_GROWSUP; +/// } +/// } +/// ``` +/// +/// Example with casting, due to a mistake in libc. In this example, the +/// various flags have different types, so we cast the broken ones to the right +/// type. +/// +/// ``` +/// libc_bitflags!{ +/// pub struct SaFlags: libc::c_ulong { +/// SA_NOCLDSTOP as libc::c_ulong; +/// SA_NOCLDWAIT; +/// SA_NODEFER as libc::c_ulong; +/// SA_ONSTACK; +/// SA_RESETHAND as libc::c_ulong; +/// SA_RESTART as libc::c_ulong; +/// SA_SIGINFO; +/// } +/// } +/// ``` +macro_rules! libc_bitflags { + ( + $(#[$outer:meta])* + pub struct $BitFlags:ident: $T:ty { + $( + $(#[$inner:ident $($args:tt)*])* + $Flag:ident $(as $cast:ty)*; + )+ + } + ) => { + bitflags! { + $(#[$outer])* + pub struct $BitFlags: $T { + $( + $(#[$inner $($args)*])* + const $Flag = libc::$Flag $(as $cast)*; + )+ + } + } + }; +} + +/// The `libc_enum!` macro helps with a common use case of defining an enum exclusively using +/// values from the `libc` crate. This macro supports both `pub` and private `enum`s. +/// +/// The `libc` crate must be in scope with the name `libc`. +/// +/// # Example +/// ``` +/// libc_enum!{ +/// pub enum ProtFlags { +/// PROT_NONE, +/// PROT_READ, +/// PROT_WRITE, +/// PROT_EXEC, +/// #[cfg(any(target_os = "linux", target_os = "android"))] +/// PROT_GROWSDOWN, +/// #[cfg(any(target_os = "linux", target_os = "android"))] +/// PROT_GROWSUP, +/// } +/// } +/// ``` +macro_rules! libc_enum { + // (non-pub) Exit rule. + (@make_enum + { + name: $BitFlags:ident, + attrs: [$($attrs:tt)*], + entries: [$($entries:tt)*], + } + ) => { + $($attrs)* + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + enum $BitFlags { + $($entries)* + } + }; + + // (pub) Exit rule. + (@make_enum + { + pub, + name: $BitFlags:ident, + attrs: [$($attrs:tt)*], + entries: [$($entries:tt)*], + } + ) => { + $($attrs)* + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + pub enum $BitFlags { + $($entries)* + } + }; + + // (non-pub) Done accumulating. + (@accumulate_entries + { + name: $BitFlags:ident, + attrs: $attrs:tt, + }, + $entries:tt; + ) => { + libc_enum! { + @make_enum + { + name: $BitFlags, + attrs: $attrs, + entries: $entries, + } + } + }; + + // (pub) Done accumulating. + (@accumulate_entries + { + pub, + name: $BitFlags:ident, + attrs: $attrs:tt, + }, + $entries:tt; + ) => { + libc_enum! { + @make_enum + { + pub, + name: $BitFlags, + attrs: $attrs, + entries: $entries, + } + } + }; + + // Munch an attr. + (@accumulate_entries + $prefix:tt, + [$($entries:tt)*]; + #[$attr:meta] $($tail:tt)* + ) => { + libc_enum! { + @accumulate_entries + $prefix, + [ + $($entries)* + #[$attr] + ]; + $($tail)* + } + }; + + // Munch last ident if not followed by a comma. + (@accumulate_entries + $prefix:tt, + [$($entries:tt)*]; + $entry:ident + ) => { + libc_enum! { + @accumulate_entries + $prefix, + [ + $($entries)* + $entry = libc::$entry, + ]; + } + }; + + // Munch an ident; covers terminating comma case. + (@accumulate_entries + $prefix:tt, + [$($entries:tt)*]; + $entry:ident, $($tail:tt)* + ) => { + libc_enum! { + @accumulate_entries + $prefix, + [ + $($entries)* + $entry = libc::$entry, + ]; + $($tail)* + } + }; + + // Munch an ident and cast it to the given type; covers terminating comma. + (@accumulate_entries + $prefix:tt, + [$($entries:tt)*]; + $entry:ident as $ty:ty, $($tail:tt)* + ) => { + libc_enum! { + @accumulate_entries + $prefix, + [ + $($entries)* + $entry = libc::$entry as $ty, + ]; + $($tail)* + } + }; + + // (non-pub) Entry rule. + ( + $(#[$attr:meta])* + enum $BitFlags:ident { + $($vals:tt)* + } + ) => { + libc_enum! { + @accumulate_entries + { + name: $BitFlags, + attrs: [$(#[$attr])*], + }, + []; + $($vals)* + } + }; + + // (pub) Entry rule. + ( + $(#[$attr:meta])* + pub enum $BitFlags:ident { + $($vals:tt)* + } + ) => { + libc_enum! { + @accumulate_entries + { + pub, + name: $BitFlags, + attrs: [$(#[$attr])*], + }, + []; + $($vals)* + } + }; +} + +/// A Rust version of the familiar C `offset_of` macro. It returns the byte +/// offset of `field` within struct `ty` +macro_rules! offset_of { + ($ty:ty, $field:ident) => { + &(*(0 as *const $ty)).$field as *const _ as usize + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/mount.rs b/third_party/cargo/vendor/nix-0.14.1/src/mount.rs new file mode 100644 index 0000000..a9902b1 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/mount.rs @@ -0,0 +1,98 @@ +use libc::{self, c_ulong, c_int}; +use {Result, NixPath}; +use errno::Errno; + +libc_bitflags!( + pub struct MsFlags: c_ulong { + /// Mount read-only + MS_RDONLY; + /// Ignore suid and sgid bits + MS_NOSUID; + /// Disallow access to device special files + MS_NODEV; + /// Disallow program execution + MS_NOEXEC; + /// Writes are synced at once + MS_SYNCHRONOUS; + /// Alter flags of a mounted FS + MS_REMOUNT; + /// Allow mandatory locks on a FS + MS_MANDLOCK; + /// Directory modifications are synchronous + MS_DIRSYNC; + /// Do not update access times + MS_NOATIME; + /// Do not update directory access times + MS_NODIRATIME; + /// Linux 2.4.0 - Bind directory at different place + MS_BIND; + MS_MOVE; + MS_REC; + MS_SILENT; + MS_POSIXACL; + MS_UNBINDABLE; + MS_PRIVATE; + MS_SLAVE; + MS_SHARED; + MS_RELATIME; + MS_KERNMOUNT; + MS_I_VERSION; + MS_STRICTATIME; + MS_ACTIVE; + MS_NOUSER; + MS_RMT_MASK; + MS_MGC_VAL; + MS_MGC_MSK; + } +); + +libc_bitflags!( + pub struct MntFlags: c_int { + MNT_FORCE; + MNT_DETACH; + MNT_EXPIRE; + } +); + +pub fn mount( + source: Option<&P1>, + target: &P2, + fstype: Option<&P3>, + flags: MsFlags, + data: Option<&P4>) -> Result<()> { + + let res = + source.with_nix_path(|source| { + target.with_nix_path(|target| { + fstype.with_nix_path(|fstype| { + data.with_nix_path(|data| { + unsafe { + libc::mount(source.as_ptr(), + target.as_ptr(), + fstype.as_ptr(), + flags.bits, + data.as_ptr() as *const libc::c_void) + } + }) + }) + }) + })????; + + Errno::result(res).map(drop) +} + +pub fn umount(target: &P) -> Result<()> { + let res = target.with_nix_path(|cstr| { + unsafe { libc::umount(cstr.as_ptr()) } + })?; + + Errno::result(res).map(drop) +} + +pub fn umount2(target: &P, flags: MntFlags) -> Result<()> { + let res = target.with_nix_path(|cstr| { + unsafe { libc::umount2(cstr.as_ptr(), flags.bits) } + })?; + + Errno::result(res).map(drop) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/mqueue.rs b/third_party/cargo/vendor/nix-0.14.1/src/mqueue.rs new file mode 100644 index 0000000..87be653 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/mqueue.rs @@ -0,0 +1,173 @@ +//! Posix Message Queue functions +//! +//! [Further reading and details on the C API](http://man7.org/linux/man-pages/man7/mq_overview.7.html) + +use Result; +use errno::Errno; + +use libc::{self, c_char, c_long, mqd_t, size_t}; +use std::ffi::CString; +use sys::stat::Mode; +use std::mem; + +libc_bitflags!{ + pub struct MQ_OFlag: libc::c_int { + O_RDONLY; + O_WRONLY; + O_RDWR; + O_CREAT; + O_EXCL; + O_NONBLOCK; + O_CLOEXEC; + } +} + +libc_bitflags!{ + pub struct FdFlag: libc::c_int { + FD_CLOEXEC; + } +} + +#[repr(C)] +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct MqAttr { + mq_attr: libc::mq_attr, +} + +impl PartialEq for MqAttr { + fn eq(&self, other: &MqAttr) -> bool { + let self_attr = self.mq_attr; + let other_attr = other.mq_attr; + self_attr.mq_flags == other_attr.mq_flags && self_attr.mq_maxmsg == other_attr.mq_maxmsg && + self_attr.mq_msgsize == other_attr.mq_msgsize && + self_attr.mq_curmsgs == other_attr.mq_curmsgs + } +} + +impl MqAttr { + pub fn new(mq_flags: c_long, + mq_maxmsg: c_long, + mq_msgsize: c_long, + mq_curmsgs: c_long) + -> MqAttr { + let mut attr = unsafe { mem::uninitialized::() }; + attr.mq_flags = mq_flags; + attr.mq_maxmsg = mq_maxmsg; + attr.mq_msgsize = mq_msgsize; + attr.mq_curmsgs = mq_curmsgs; + MqAttr { mq_attr: attr } + } + + pub fn flags(&self) -> c_long { + self.mq_attr.mq_flags + } +} + + +/// Open a message queue +/// +/// See also [`mq_open(2)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_open.html) +pub fn mq_open(name: &CString, + oflag: MQ_OFlag, + mode: Mode, + attr: Option<&MqAttr>) + -> Result { + let res = match attr { + Some(mq_attr) => unsafe { + libc::mq_open(name.as_ptr(), + oflag.bits(), + mode.bits() as libc::c_int, + &mq_attr.mq_attr as *const libc::mq_attr) + }, + None => unsafe { libc::mq_open(name.as_ptr(), oflag.bits()) }, + }; + Errno::result(res) +} + +/// Remove a message queue +/// +/// See also [`mq_unlink(2)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_unlink.html) +pub fn mq_unlink(name: &CString) -> Result<()> { + let res = unsafe { libc::mq_unlink(name.as_ptr()) }; + Errno::result(res).map(drop) +} + +/// Close a message queue +/// +/// See also [`mq_close(2)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_close.html) +pub fn mq_close(mqdes: mqd_t) -> Result<()> { + let res = unsafe { libc::mq_close(mqdes) }; + Errno::result(res).map(drop) +} + +/// Receive a message from a message queue +/// +/// See also [`mq_receive(2)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html) +pub fn mq_receive(mqdes: mqd_t, message: &mut [u8], msg_prio: &mut u32) -> Result { + let len = message.len() as size_t; + let res = unsafe { + libc::mq_receive(mqdes, + message.as_mut_ptr() as *mut c_char, + len, + msg_prio as *mut u32) + }; + Errno::result(res).map(|r| r as usize) +} + +/// Send a message to a message queue +/// +/// See also [`mq_send(2)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html) +pub fn mq_send(mqdes: mqd_t, message: &[u8], msq_prio: u32) -> Result<()> { + let res = unsafe { + libc::mq_send(mqdes, + message.as_ptr() as *const c_char, + message.len(), + msq_prio) + }; + Errno::result(res).map(drop) +} + +/// Get message queue attributes +/// +/// See also [`mq_getattr(2)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_getattr.html) +pub fn mq_getattr(mqd: mqd_t) -> Result { + let mut attr = unsafe { mem::uninitialized::() }; + let res = unsafe { libc::mq_getattr(mqd, &mut attr) }; + Errno::result(res).map(|_| MqAttr { mq_attr: attr }) +} + +/// Set the attributes of the message queue. Only `O_NONBLOCK` can be set, everything else will be ignored +/// Returns the old attributes +/// It is recommend to use the `mq_set_nonblock()` and `mq_remove_nonblock()` convenience functions as they are easier to use +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_setattr.html) +pub fn mq_setattr(mqd: mqd_t, newattr: &MqAttr) -> Result { + let mut attr = unsafe { mem::uninitialized::() }; + let res = unsafe { libc::mq_setattr(mqd, &newattr.mq_attr as *const libc::mq_attr, &mut attr) }; + Errno::result(res).map(|_| MqAttr { mq_attr: attr }) +} + +/// Convenience function. +/// Sets the `O_NONBLOCK` attribute for a given message queue descriptor +/// Returns the old attributes +pub fn mq_set_nonblock(mqd: mqd_t) -> Result<(MqAttr)> { + let oldattr = mq_getattr(mqd)?; + let newattr = MqAttr::new(MQ_OFlag::O_NONBLOCK.bits() as c_long, + oldattr.mq_attr.mq_maxmsg, + oldattr.mq_attr.mq_msgsize, + oldattr.mq_attr.mq_curmsgs); + mq_setattr(mqd, &newattr) +} + +/// Convenience function. +/// Removes `O_NONBLOCK` attribute for a given message queue descriptor +/// Returns the old attributes +pub fn mq_remove_nonblock(mqd: mqd_t) -> Result<(MqAttr)> { + let oldattr = mq_getattr(mqd)?; + let newattr = MqAttr::new(0, + oldattr.mq_attr.mq_maxmsg, + oldattr.mq_attr.mq_msgsize, + oldattr.mq_attr.mq_curmsgs); + mq_setattr(mqd, &newattr) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/net/if_.rs b/third_party/cargo/vendor/nix-0.14.1/src/net/if_.rs new file mode 100644 index 0000000..58d677a --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/net/if_.rs @@ -0,0 +1,268 @@ +//! Network interface name resolution. +//! +//! Uses Linux and/or POSIX functions to resolve interface names like "eth0" +//! or "socan1" into device numbers. + +use libc; +use libc::c_uint; +use {Result, Error, NixPath}; + +/// Resolve an interface into a interface number. +pub fn if_nametoindex(name: &P) -> Result { + let if_index = name.with_nix_path(|name| unsafe { libc::if_nametoindex(name.as_ptr()) })?; + + if if_index == 0 { + Err(Error::last()) + } else { + Ok(if_index) + } +} + +libc_bitflags!( + /// Standard interface flags, used by `getifaddrs` + pub struct InterfaceFlags: libc::c_int { + /// Interface is running. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + IFF_UP; + /// Valid broadcast address set. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + IFF_BROADCAST; + /// Internal debugging flag. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + IFF_DEBUG; + /// Interface is a loopback interface. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + IFF_LOOPBACK; + /// Interface is a point-to-point link. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + IFF_POINTOPOINT; + /// Avoid use of trailers. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + #[cfg(any(target_os = "android", + target_os = "fuchsia", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "solaris"))] + IFF_NOTRAILERS; + /// Interface manages own routes. + #[cfg(any(target_os = "dragonfly"))] + IFF_SMART; + /// Resources allocated. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + #[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris"))] + IFF_RUNNING; + /// No arp protocol, L2 destination address not set. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + IFF_NOARP; + /// Interface is in promiscuous mode. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + IFF_PROMISC; + /// Receive all multicast packets. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + IFF_ALLMULTI; + /// Master of a load balancing bundle. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] + IFF_MASTER; + /// transmission in progress, tx hardware queue is full + #[cfg(any(target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "ios"))] + IFF_OACTIVE; + /// Protocol code on board. + #[cfg(target_os = "solaris")] + IFF_INTELLIGENT; + /// Slave of a load balancing bundle. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] + IFF_SLAVE; + /// Can't hear own transmissions. + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "osx"))] + IFF_SIMPLEX; + /// Supports multicast. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + IFF_MULTICAST; + /// Per link layer defined bit. + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "ios"))] + IFF_LINK0; + /// Multicast using broadcast. + #[cfg(any(target_os = "solaris"))] + IFF_MULTI_BCAST; + /// Is able to select media type via ifmap. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] + IFF_PORTSEL; + /// Per link layer defined bit. + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "ios"))] + IFF_LINK1; + /// Non-unique address. + #[cfg(any(target_os = "solaris"))] + IFF_UNNUMBERED; + /// Auto media selection active. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] + IFF_AUTOMEDIA; + /// Per link layer defined bit. + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "ios"))] + IFF_LINK2; + /// Use alternate physical connection. + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "ios"))] + IFF_ALTPHYS; + /// DHCP controlls interface. + #[cfg(any(target_os = "solaris"))] + IFF_DHCPRUNNING; + /// The addresses are lost when the interface goes down. (see + /// [`netdevice(7)`](http://man7.org/linux/man-pages/man7/netdevice.7.html)) + #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] + IFF_DYNAMIC; + /// Do not advertise. + #[cfg(any(target_os = "solaris"))] + IFF_PRIVATE; + /// Driver signals L1 up. Volatile. + #[cfg(any(target_os = "fuchsia", target_os = "linux"))] + IFF_LOWER_UP; + /// Interface is in polling mode. + #[cfg(any(target_os = "dragonfly"))] + IFF_POLLING_COMPAT; + /// Unconfigurable using ioctl(2). + #[cfg(any(target_os = "freebsd"))] + IFF_CANTCONFIG; + /// Do not transmit packets. + #[cfg(any(target_os = "solaris"))] + IFF_NOXMIT; + /// Driver signals dormant. Volatile. + #[cfg(any(target_os = "fuchsia", target_os = "linux"))] + IFF_DORMANT; + /// User-requested promisc mode. + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + IFF_PPROMISC; + /// Just on-link subnet. + #[cfg(any(target_os = "solaris"))] + IFF_NOLOCAL; + /// Echo sent packets. Volatile. + #[cfg(any(target_os = "fuchsia", target_os = "linux"))] + IFF_ECHO; + /// User-requested monitor mode. + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + IFF_MONITOR; + /// Address is deprecated. + #[cfg(any(target_os = "solaris"))] + IFF_DEPRECATED; + /// Static ARP. + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + IFF_STATICARP; + /// Address from stateless addrconf. + #[cfg(any(target_os = "solaris"))] + IFF_ADDRCONF; + /// Interface is in polling mode. + #[cfg(any(target_os = "dragonfly"))] + IFF_NPOLLING; + /// Router on interface. + #[cfg(any(target_os = "solaris"))] + IFF_ROUTER; + /// Interface is in polling mode. + #[cfg(any(target_os = "dragonfly"))] + IFF_IDIRECT; + /// Interface is winding down + #[cfg(any(target_os = "freebsd"))] + IFF_DYING; + /// No NUD on interface. + #[cfg(any(target_os = "solaris"))] + IFF_NONUD; + /// Interface is being renamed + #[cfg(any(target_os = "freebsd"))] + IFF_RENAMING; + /// Anycast address. + #[cfg(any(target_os = "solaris"))] + IFF_ANYCAST; + /// Don't exchange routing info. + #[cfg(any(target_os = "solaris"))] + IFF_NORTEXCH; + /// Do not provide packet information + #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] + IFF_NO_PI as libc::c_int; + /// TUN device (no Ethernet headers) + #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] + IFF_TUN as libc::c_int; + /// TAP device + #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] + IFF_TAP as libc::c_int; + /// IPv4 interface. + #[cfg(any(target_os = "solaris"))] + IFF_IPV4; + /// IPv6 interface. + #[cfg(any(target_os = "solaris"))] + IFF_IPV6; + /// in.mpathd test address + #[cfg(any(target_os = "solaris"))] + IFF_NOFAILOVER; + /// Interface has failed + #[cfg(any(target_os = "solaris"))] + IFF_FAILED; + /// Interface is a hot-spare + #[cfg(any(target_os = "solaris"))] + IFF_STANDBY; + /// Functioning but not used + #[cfg(any(target_os = "solaris"))] + IFF_INACTIVE; + /// Interface is offline + #[cfg(any(target_os = "solaris"))] + IFF_OFFLINE; + #[cfg(any(target_os = "solaris"))] + IFF_COS_ENABLED; + /// Prefer as source addr. + #[cfg(any(target_os = "solaris"))] + IFF_PREFERRED; + /// RFC3041 + #[cfg(any(target_os = "solaris"))] + IFF_TEMPORARY; + /// MTU set with SIOCSLIFMTU + #[cfg(any(target_os = "solaris"))] + IFF_FIXEDMTU; + /// Cannot send / receive packets + #[cfg(any(target_os = "solaris"))] + IFF_VIRTUAL; + /// Local address in use + #[cfg(any(target_os = "solaris"))] + IFF_DUPLICATE; + /// IPMP IP interface + #[cfg(any(target_os = "solaris"))] + IFF_IPMP; + } +); diff --git a/third_party/cargo/vendor/nix-0.14.1/src/net/mod.rs b/third_party/cargo/vendor/nix-0.14.1/src/net/mod.rs new file mode 100644 index 0000000..079fcfd --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/net/mod.rs @@ -0,0 +1,4 @@ +//! Functionality involving network interfaces +// To avoid clashing with the keyword "if", we use "if_" as the module name. +// The original header is called "net/if.h". +pub mod if_; diff --git a/third_party/cargo/vendor/nix-0.14.1/src/poll.rs b/third_party/cargo/vendor/nix-0.14.1/src/poll.rs new file mode 100644 index 0000000..160b5bc --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/poll.rs @@ -0,0 +1,161 @@ +//! Wait for events to trigger on specific file descriptors +#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] +use sys::time::TimeSpec; +#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] +use sys::signal::SigSet; +use std::os::unix::io::RawFd; +use std::fmt; + +use libc; +use Result; +use errno::Errno; + +/// This is a wrapper around `libc::pollfd`. +/// +/// It's meant to be used as an argument to the [`poll`](fn.poll.html) and +/// [`ppoll`](fn.ppoll.html) functions to specify the events of interest +/// for a specific file descriptor. +/// +/// After a call to `poll` or `ppoll`, the events that occured can be +/// retrieved by calling [`revents()`](#method.revents) on the `PollFd`. +#[repr(C)] +#[derive(Clone, Copy)] +pub struct PollFd { + pollfd: libc::pollfd, +} + +impl PollFd { + /// Creates a new `PollFd` specifying the events of interest + /// for a given file descriptor. + pub fn new(fd: RawFd, events: PollFlags) -> PollFd { + PollFd { + pollfd: libc::pollfd { + fd: fd, + events: events.bits(), + revents: PollFlags::empty().bits(), + }, + } + } + + /// Returns the events that occured in the last call to `poll` or `ppoll`. + pub fn revents(&self) -> Option { + PollFlags::from_bits(self.pollfd.revents) + } +} + +impl fmt::Debug for PollFd { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let pfd = self.pollfd; + let mut ds = f.debug_struct("PollFd"); + ds.field("fd", &pfd.fd); + match PollFlags::from_bits(pfd.events) { + None => ds.field("events", &pfd.events), + Some(ef) => ds.field("events", &ef), + }; + match PollFlags::from_bits(pfd.revents) { + None => ds.field("revents", &pfd.revents), + Some(ef) => ds.field("revents", &ef), + }; + ds.finish() + } +} + +libc_bitflags! { + /// These flags define the different events that can be monitored by `poll` and `ppoll` + pub struct PollFlags: libc::c_short { + /// There is data to read. + POLLIN; + /// There is some exceptional condition on the file descriptor. + /// + /// Possibilities include: + /// + /// * There is out-of-band data on a TCP socket (see + /// [tcp(7)](http://man7.org/linux/man-pages/man7/tcp.7.html)). + /// * A pseudoterminal master in packet mode has seen a state + /// change on the slave (see + /// [ioctl_tty(2)](http://man7.org/linux/man-pages/man2/ioctl_tty.2.html)). + /// * A cgroup.events file has been modified (see + /// [cgroups(7)](http://man7.org/linux/man-pages/man7/cgroups.7.html)). + POLLPRI; + /// Writing is now possible, though a write larger that the + /// available space in a socket or pipe will still block (unless + /// `O_NONBLOCK` is set). + POLLOUT; + /// Equivalent to [`POLLIN`](constant.POLLIN.html) + POLLRDNORM; + /// Equivalent to [`POLLOUT`](constant.POLLOUT.html) + POLLWRNORM; + /// Priority band data can be read (generally unused on Linux). + POLLRDBAND; + /// Priority data may be written. + POLLWRBAND; + /// Error condition (only returned in + /// [`PollFd::revents`](struct.PollFd.html#method.revents); + /// ignored in [`PollFd::new`](struct.PollFd.html#method.new)). + /// This bit is also set for a file descriptor referring to the + /// write end of a pipe when the read end has been closed. + POLLERR; + /// Hang up (only returned in [`PollFd::revents`](struct.PollFd.html#method.revents); + /// ignored in [`PollFd::new`](struct.PollFd.html#method.new)). + /// Note that when reading from a channel such as a pipe or a stream + /// socket, this event merely indicates that the peer closed its + /// end of the channel. Subsequent reads from the channel will + /// return 0 (end of file) only after all outstanding data in the + /// channel has been consumed. + POLLHUP; + /// Invalid request: `fd` not open (only returned in + /// [`PollFd::revents`](struct.PollFd.html#method.revents); + /// ignored in [`PollFd::new`](struct.PollFd.html#method.new)). + POLLNVAL; + } +} + +/// `poll` waits for one of a set of file descriptors to become ready to perform I/O. +/// ([`poll(2)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html)) +/// +/// `fds` contains all [`PollFd`](struct.PollFd.html) to poll. +/// The function will return as soon as any event occur for any of these `PollFd`s. +/// +/// The `timeout` argument specifies the number of milliseconds that `poll()` +/// should block waiting for a file descriptor to become ready. The call +/// will block until either: +/// +/// * a file descriptor becomes ready; +/// * the call is interrupted by a signal handler; or +/// * the timeout expires. +/// +/// Note that the timeout interval will be rounded up to the system clock +/// granularity, and kernel scheduling delays mean that the blocking +/// interval may overrun by a small amount. Specifying a negative value +/// in timeout means an infinite timeout. Specifying a timeout of zero +/// causes `poll()` to return immediately, even if no file descriptors are +/// ready. +pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result { + let res = unsafe { + libc::poll(fds.as_mut_ptr() as *mut libc::pollfd, + fds.len() as libc::nfds_t, + timeout) + }; + + Errno::result(res) +} + +/// `ppoll()` allows an application to safely wait until either a file +/// descriptor becomes ready or until a signal is caught. +/// ([`poll(2)`](http://man7.org/linux/man-pages/man2/poll.2.html)) +/// +/// `ppoll` behaves like `poll`, but let you specify what signals may interrupt it +/// with the `sigmask` argument. +/// +#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] +pub fn ppoll(fds: &mut [PollFd], timeout: TimeSpec, sigmask: SigSet) -> Result { + + + let res = unsafe { + libc::ppoll(fds.as_mut_ptr() as *mut libc::pollfd, + fds.len() as libc::nfds_t, + timeout.as_ref(), + sigmask.as_ref()) + }; + Errno::result(res) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/pty.rs b/third_party/cargo/vendor/nix-0.14.1/src/pty.rs new file mode 100644 index 0000000..41bd51b --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/pty.rs @@ -0,0 +1,327 @@ +//! Create master and slave virtual pseudo-terminals (PTYs) + +use libc; + +pub use libc::pid_t as SessionId; +pub use libc::winsize as Winsize; + +use std::ffi::CStr; +use std::mem; +use std::os::unix::prelude::*; + +use sys::termios::Termios; +use unistd::ForkResult; +use {Result, Error, fcntl}; +use errno::Errno; + +/// Representation of a master/slave pty pair +/// +/// This is returned by `openpty`. Note that this type does *not* implement `Drop`, so the user +/// must manually close the file descriptors. +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct OpenptyResult { + /// The master port in a virtual pty pair + pub master: RawFd, + /// The slave port in a virtual pty pair + pub slave: RawFd, +} + +/// Representation of a master with a forked pty +/// +/// This is returned by `forkpty`. Note that this type does *not* implement `Drop`, so the user +/// must manually close the file descriptors. +#[derive(Clone, Copy, Debug)] +pub struct ForkptyResult { + /// The master port in a virtual pty pair + pub master: RawFd, + /// Metadata about forked process + pub fork_result: ForkResult, +} + + +/// Representation of the Master device in a master/slave pty pair +/// +/// While this datatype is a thin wrapper around `RawFd`, it enforces that the available PTY +/// functions are given the correct file descriptor. Additionally this type implements `Drop`, +/// so that when it's consumed or goes out of scope, it's automatically cleaned-up. +#[derive(Debug)] +pub struct PtyMaster(RawFd); + +impl AsRawFd for PtyMaster { + fn as_raw_fd(&self) -> RawFd { + self.0 + } +} + +impl IntoRawFd for PtyMaster { + fn into_raw_fd(self) -> RawFd { + let fd = self.0; + mem::forget(self); + fd + } +} + +impl Drop for PtyMaster { + fn drop(&mut self) { + // On drop, we ignore errors like EINTR and EIO because there's no clear + // way to handle them, we can't return anything, and (on FreeBSD at + // least) the file descriptor is deallocated in these cases. However, + // we must panic on EBADF, because it is always an error to close an + // invalid file descriptor. That frequently indicates a double-close + // condition, which can cause confusing errors for future I/O + // operations. + let e = ::unistd::close(self.0); + if e == Err(Error::Sys(Errno::EBADF)) { + panic!("Closing an invalid file descriptor!"); + }; + } +} + +/// Grant access to a slave pseudoterminal (see +/// [`grantpt(3)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/grantpt.html)) +/// +/// `grantpt()` changes the mode and owner of the slave pseudoterminal device corresponding to the +/// master pseudoterminal referred to by `fd`. This is a necessary step towards opening the slave. +#[inline] +pub fn grantpt(fd: &PtyMaster) -> Result<()> { + if unsafe { libc::grantpt(fd.as_raw_fd()) } < 0 { + return Err(Error::last()); + } + + Ok(()) +} + +/// Open a pseudoterminal device (see +/// [`posix_openpt(3)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_openpt.html)) +/// +/// `posix_openpt()` returns a file descriptor to an existing unused pseuterminal master device. +/// +/// # Examples +/// +/// A common use case with this function is to open both a master and slave PTY pair. This can be +/// done as follows: +/// +/// ``` +/// use std::path::Path; +/// use nix::fcntl::{OFlag, open}; +/// use nix::pty::{grantpt, posix_openpt, ptsname, unlockpt}; +/// use nix::sys::stat::Mode; +/// +/// # #[allow(dead_code)] +/// # fn run() -> nix::Result<()> { +/// // Open a new PTY master +/// let master_fd = posix_openpt(OFlag::O_RDWR)?; +/// +/// // Allow a slave to be generated for it +/// grantpt(&master_fd)?; +/// unlockpt(&master_fd)?; +/// +/// // Get the name of the slave +/// let slave_name = unsafe { ptsname(&master_fd) }?; +/// +/// // Try to open the slave +/// let _slave_fd = open(Path::new(&slave_name), OFlag::O_RDWR, Mode::empty())?; +/// # Ok(()) +/// # } +/// ``` +#[inline] +pub fn posix_openpt(flags: fcntl::OFlag) -> Result { + let fd = unsafe { + libc::posix_openpt(flags.bits()) + }; + + if fd < 0 { + return Err(Error::last()); + } + + Ok(PtyMaster(fd)) +} + +/// Get the name of the slave pseudoterminal (see +/// [`ptsname(3)`](http://man7.org/linux/man-pages/man3/ptsname.3.html)) +/// +/// `ptsname()` returns the name of the slave pseudoterminal device corresponding to the master +/// referred to by `fd`. +/// +/// This value is useful for opening the slave pty once the master has already been opened with +/// `posix_openpt()`. +/// +/// # Safety +/// +/// `ptsname()` mutates global variables and is *not* threadsafe. +/// Mutating global variables is always considered `unsafe` by Rust and this +/// function is marked as `unsafe` to reflect that. +/// +/// For a threadsafe and non-`unsafe` alternative on Linux, see `ptsname_r()`. +#[inline] +pub unsafe fn ptsname(fd: &PtyMaster) -> Result { + let name_ptr = libc::ptsname(fd.as_raw_fd()); + if name_ptr.is_null() { + return Err(Error::last()); + } + + let name = CStr::from_ptr(name_ptr); + Ok(name.to_string_lossy().into_owned()) +} + +/// Get the name of the slave pseudoterminal (see +/// [`ptsname(3)`](http://man7.org/linux/man-pages/man3/ptsname.3.html)) +/// +/// `ptsname_r()` returns the name of the slave pseudoterminal device corresponding to the master +/// referred to by `fd`. This is the threadsafe version of `ptsname()`, but it is not part of the +/// POSIX standard and is instead a Linux-specific extension. +/// +/// This value is useful for opening the slave ptty once the master has already been opened with +/// `posix_openpt()`. +#[cfg(any(target_os = "android", target_os = "linux"))] +#[inline] +pub fn ptsname_r(fd: &PtyMaster) -> Result { + let mut name_buf = vec![0u8; 64]; + let name_buf_ptr = name_buf.as_mut_ptr() as *mut libc::c_char; + if unsafe { libc::ptsname_r(fd.as_raw_fd(), name_buf_ptr, name_buf.capacity()) } != 0 { + return Err(Error::last()); + } + + // Find the first null-character terminating this string. This is guaranteed to succeed if the + // return value of `libc::ptsname_r` is 0. + let null_index = name_buf.iter().position(|c| *c == b'\0').unwrap(); + name_buf.truncate(null_index); + + let name = String::from_utf8(name_buf)?; + Ok(name) +} + +/// Unlock a pseudoterminal master/slave pseudoterminal pair (see +/// [`unlockpt(3)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlockpt.html)) +/// +/// `unlockpt()` unlocks the slave pseudoterminal device corresponding to the master pseudoterminal +/// referred to by `fd`. This must be called before trying to open the slave side of a +/// pseuoterminal. +#[inline] +pub fn unlockpt(fd: &PtyMaster) -> Result<()> { + if unsafe { libc::unlockpt(fd.as_raw_fd()) } < 0 { + return Err(Error::last()); + } + + Ok(()) +} + + +/// Create a new pseudoterminal, returning the slave and master file descriptors +/// in `OpenptyResult` +/// (see [`openpty`](http://man7.org/linux/man-pages/man3/openpty.3.html)). +/// +/// If `winsize` is not `None`, the window size of the slave will be set to +/// the values in `winsize`. If `termios` is not `None`, the pseudoterminal's +/// terminal settings of the slave will be set to the values in `termios`. +#[inline] +pub fn openpty<'a, 'b, T: Into>, U: Into>>(winsize: T, termios: U) -> Result { + use std::ptr; + + let mut slave: libc::c_int = unsafe { mem::uninitialized() }; + let mut master: libc::c_int = unsafe { mem::uninitialized() }; + let ret = { + match (termios.into(), winsize.into()) { + (Some(termios), Some(winsize)) => { + let inner_termios = termios.get_libc_termios(); + unsafe { + libc::openpty( + &mut master, + &mut slave, + ptr::null_mut(), + &*inner_termios as *const libc::termios as *mut _, + winsize as *const Winsize as *mut _, + ) + } + } + (None, Some(winsize)) => { + unsafe { + libc::openpty( + &mut master, + &mut slave, + ptr::null_mut(), + ptr::null_mut(), + winsize as *const Winsize as *mut _, + ) + } + } + (Some(termios), None) => { + let inner_termios = termios.get_libc_termios(); + unsafe { + libc::openpty( + &mut master, + &mut slave, + ptr::null_mut(), + &*inner_termios as *const libc::termios as *mut _, + ptr::null_mut(), + ) + } + } + (None, None) => { + unsafe { + libc::openpty( + &mut master, + &mut slave, + ptr::null_mut(), + ptr::null_mut(), + ptr::null_mut(), + ) + } + } + } + }; + + Errno::result(ret)?; + + Ok(OpenptyResult { + master: master, + slave: slave, + }) +} + +/// Create a new pseudoterminal, returning the master file descriptor and forked pid. +/// in `ForkptyResult` +/// (see [`forkpty`](http://man7.org/linux/man-pages/man3/forkpty.3.html)). +/// +/// If `winsize` is not `None`, the window size of the slave will be set to +/// the values in `winsize`. If `termios` is not `None`, the pseudoterminal's +/// terminal settings of the slave will be set to the values in `termios`. +pub fn forkpty<'a, 'b, T: Into>, U: Into>>( + winsize: T, + termios: U, +) -> Result { + use std::ptr; + use unistd::Pid; + use unistd::ForkResult::*; + + let mut master: libc::c_int = unsafe { mem::uninitialized() }; + + let term = match termios.into() { + Some(termios) => { + let inner_termios = termios.get_libc_termios(); + &*inner_termios as *const libc::termios as *mut _ + }, + None => ptr::null_mut(), + }; + + let win = winsize + .into() + .map(|ws| ws as *const Winsize as *mut _) + .unwrap_or(ptr::null_mut()); + + let res = unsafe { + libc::forkpty(&mut master, ptr::null_mut(), term, win) + }; + + let fork_result = Errno::result(res).map(|res| match res { + 0 => Child, + res => Parent { child: Pid::from_raw(res) }, + })?; + + Ok(ForkptyResult { + master: master, + fork_result: fork_result, + }) +} + diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sched.rs b/third_party/cargo/vendor/nix-0.14.1/src/sched.rs new file mode 100644 index 0000000..d381cbb --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sched.rs @@ -0,0 +1,132 @@ +use std::mem; +use std::os::unix::io::RawFd; +use std::option::Option; +use libc::{self, c_int, c_void}; +use {Error, Result}; +use errno::Errno; +use ::unistd::Pid; + +// For some functions taking with a parameter of type CloneFlags, +// only a subset of these flags have an effect. +libc_bitflags!{ + pub struct CloneFlags: c_int { + CLONE_VM; + CLONE_FS; + CLONE_FILES; + CLONE_SIGHAND; + CLONE_PTRACE; + CLONE_VFORK; + CLONE_PARENT; + CLONE_THREAD; + CLONE_NEWNS; + CLONE_SYSVSEM; + CLONE_SETTLS; + CLONE_PARENT_SETTID; + CLONE_CHILD_CLEARTID; + CLONE_DETACHED; + CLONE_UNTRACED; + CLONE_CHILD_SETTID; + CLONE_NEWCGROUP; + CLONE_NEWUTS; + CLONE_NEWIPC; + CLONE_NEWUSER; + CLONE_NEWPID; + CLONE_NEWNET; + CLONE_IO; + } +} + +pub type CloneCb<'a> = Box isize + 'a>; + +#[repr(C)] +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct CpuSet { + cpu_set: libc::cpu_set_t, +} + +impl CpuSet { + pub fn new() -> CpuSet { + CpuSet { cpu_set: unsafe { mem::zeroed() } } + } + + pub fn is_set(&self, field: usize) -> Result { + if field >= 8 * mem::size_of::() { + Err(Error::Sys(Errno::EINVAL)) + } else { + Ok(unsafe { libc::CPU_ISSET(field, &self.cpu_set) }) + } + } + + pub fn set(&mut self, field: usize) -> Result<()> { + if field >= 8 * mem::size_of::() { + Err(Error::Sys(Errno::EINVAL)) + } else { + Ok(unsafe { libc::CPU_SET(field, &mut self.cpu_set) }) + } + } + + pub fn unset(&mut self, field: usize) -> Result<()> { + if field >= 8 * mem::size_of::() { + Err(Error::Sys(Errno::EINVAL)) + } else { + Ok(unsafe { libc::CPU_CLR(field, &mut self.cpu_set) }) + } + } +} + +pub fn sched_setaffinity(pid: Pid, cpuset: &CpuSet) -> Result<()> { + let res = unsafe { + libc::sched_setaffinity(pid.into(), + mem::size_of::() as libc::size_t, + &cpuset.cpu_set) + }; + + Errno::result(res).map(drop) +} + +/// Explicitly yield the processor to other threads. +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_yield.html) +pub fn sched_yield() -> Result<()> { + let res = unsafe { + libc::sched_yield() + }; + + Errno::result(res).map(drop) +} + +pub fn clone(mut cb: CloneCb, + stack: &mut [u8], + flags: CloneFlags, + signal: Option) + -> Result { + extern "C" fn callback(data: *mut CloneCb) -> c_int { + let cb: &mut CloneCb = unsafe { &mut *data }; + (*cb)() as c_int + } + + let res = unsafe { + let combined = flags.bits() | signal.unwrap_or(0); + let ptr = stack.as_mut_ptr().offset(stack.len() as isize); + let ptr_aligned = ptr.offset((ptr as usize % 16) as isize * -1); + libc::clone(mem::transmute(callback as extern "C" fn(*mut Box<::std::ops::FnMut() -> isize>) -> i32), + ptr_aligned as *mut c_void, + combined, + &mut cb as *mut _ as *mut c_void) + }; + + Errno::result(res).map(Pid::from_raw) +} + +pub fn unshare(flags: CloneFlags) -> Result<()> { + let res = unsafe { libc::unshare(flags.bits()) }; + + Errno::result(res).map(drop) +} + +pub fn setns(fd: RawFd, nstype: CloneFlags) -> Result<()> { + let res = unsafe { libc::setns(fd, nstype.bits()) }; + + Errno::result(res).map(drop) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/aio.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/aio.rs new file mode 100644 index 0000000..c54c2e3 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/aio.rs @@ -0,0 +1,1286 @@ +// vim: tw=80 +//! POSIX Asynchronous I/O +//! +//! The POSIX AIO interface is used for asynchronous I/O on files and disk-like +//! devices. It supports [`read`](struct.AioCb.html#method.read), +//! [`write`](struct.AioCb.html#method.write), and +//! [`fsync`](struct.AioCb.html#method.fsync) operations. Completion +//! notifications can optionally be delivered via +//! [signals](../signal/enum.SigevNotify.html#variant.SigevSignal), via the +//! [`aio_suspend`](fn.aio_suspend.html) function, or via polling. Some +//! platforms support other completion +//! notifications, such as +//! [kevent](../signal/enum.SigevNotify.html#variant.SigevKevent). +//! +//! Multiple operations may be submitted in a batch with +//! [`lio_listio`](fn.lio_listio.html), though the standard does not guarantee +//! that they will be executed atomically. +//! +//! Outstanding operations may be cancelled with +//! [`cancel`](struct.AioCb.html#method.cancel) or +//! [`aio_cancel_all`](fn.aio_cancel_all.html), though the operating system may +//! not support this for all filesystems and devices. + +use {Error, Result}; +use errno::Errno; +use std::os::unix::io::RawFd; +use libc::{c_void, off_t, size_t}; +use libc; +use std::borrow::{Borrow, BorrowMut}; +use std::fmt; +use std::fmt::Debug; +use std::marker::PhantomData; +use std::mem; +use std::ptr::{null, null_mut}; +use sys::signal::*; +use std::thread; +use sys::time::TimeSpec; + +libc_enum! { + /// Mode for `AioCb::fsync`. Controls whether only data or both data and + /// metadata are synced. + #[repr(i32)] + pub enum AioFsyncMode { + /// do it like `fsync` + O_SYNC, + /// on supported operating systems only, do it like `fdatasync` + #[cfg(any(target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + O_DSYNC + } +} + +libc_enum! { + /// When used with [`lio_listio`](fn.lio_listio.html), determines whether a + /// given `aiocb` should be used for a read operation, a write operation, or + /// ignored. Has no effect for any other aio functions. + #[repr(i32)] + pub enum LioOpcode { + LIO_NOP, + LIO_WRITE, + LIO_READ, + } +} + +libc_enum! { + /// Mode for [`lio_listio`](fn.lio_listio.html) + #[repr(i32)] + pub enum LioMode { + /// Requests that [`lio_listio`](fn.lio_listio.html) block until all + /// requested operations have been completed + LIO_WAIT, + /// Requests that [`lio_listio`](fn.lio_listio.html) return immediately + LIO_NOWAIT, + } +} + +/// Return values for [`AioCb::cancel`](struct.AioCb.html#method.cancel) and +/// [`aio_cancel_all`](fn.aio_cancel_all.html) +#[repr(i32)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum AioCancelStat { + /// All outstanding requests were canceled + AioCanceled = libc::AIO_CANCELED, + /// Some requests were not canceled. Their status should be checked with + /// `AioCb::error` + AioNotCanceled = libc::AIO_NOTCANCELED, + /// All of the requests have already finished + AioAllDone = libc::AIO_ALLDONE, +} + +/// Owns (uniquely or shared) a memory buffer to keep it from `Drop`ing while +/// the kernel has a pointer to it. +pub enum Buffer<'a> { + /// No buffer to own. + /// + /// Used for operations like `aio_fsync` that have no data, or for unsafe + /// operations that work with raw pointers. + None, + /// Keeps a reference to a slice + Phantom(PhantomData<&'a mut [u8]>), + /// Generic thing that keeps a buffer from dropping + BoxedSlice(Box>), + /// Generic thing that keeps a mutable buffer from dropping + BoxedMutSlice(Box>), +} + +impl<'a> Debug for Buffer<'a> { + // Note: someday it may be possible to Derive Debug for a trait object, but + // not today. + // https://github.com/rust-lang/rust/issues/1563 + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Buffer::None => write!(fmt, "None"), + Buffer::Phantom(p) => p.fmt(fmt), + Buffer::BoxedSlice(ref bs) => { + let borrowed : &Borrow<[u8]> = bs.borrow(); + write!(fmt, "BoxedSlice({:?})", + borrowed as *const Borrow<[u8]>) + }, + Buffer::BoxedMutSlice(ref bms) => { + let borrowed : &BorrowMut<[u8]> = bms.borrow(); + write!(fmt, "BoxedMutSlice({:?})", + borrowed as *const BorrowMut<[u8]>) + } + } + } +} + +/// AIO Control Block. +/// +/// The basic structure used by all aio functions. Each `AioCb` represents one +/// I/O request. +pub struct AioCb<'a> { + aiocb: libc::aiocb, + /// Tracks whether the buffer pointed to by `libc::aiocb.aio_buf` is mutable + mutable: bool, + /// Could this `AioCb` potentially have any in-kernel state? + in_progress: bool, + /// Optionally keeps a reference to the data. + /// + /// Used to keep buffers from `Drop`'ing, and may be returned once the + /// `AioCb` is completed by [`buffer`](#method.buffer). + buffer: Buffer<'a> +} + +impl<'a> AioCb<'a> { + /// Remove the inner `Buffer` and return it + /// + /// It is an error to call this method while the `AioCb` is still in + /// progress. + pub fn buffer(&mut self) -> Buffer<'a> { + assert!(!self.in_progress); + let mut x = Buffer::None; + mem::swap(&mut self.buffer, &mut x); + x + } + + /// Remove the inner boxed slice, if any, and return it. + /// + /// The returned value will be the argument that was passed to + /// `from_boxed_slice` when this `AioCb` was created. + /// + /// It is an error to call this method while the `AioCb` is still in + /// progress. + pub fn boxed_slice(&mut self) -> Option>> { + assert!(!self.in_progress, "Can't remove the buffer from an AioCb that's still in-progress. Did you forget to call aio_return?"); + if let Buffer::BoxedSlice(_) = self.buffer { + let mut oldbuffer = Buffer::None; + mem::swap(&mut self.buffer, &mut oldbuffer); + if let Buffer::BoxedSlice(inner) = oldbuffer { + Some(inner) + } else { + unreachable!(); + } + } else { + None + } + } + + /// Remove the inner boxed mutable slice, if any, and return it. + /// + /// The returned value will be the argument that was passed to + /// `from_boxed_mut_slice` when this `AioCb` was created. + /// + /// It is an error to call this method while the `AioCb` is still in + /// progress. + pub fn boxed_mut_slice(&mut self) -> Option>> { + assert!(!self.in_progress, "Can't remove the buffer from an AioCb that's still in-progress. Did you forget to call aio_return?"); + if let Buffer::BoxedMutSlice(_) = self.buffer { + let mut oldbuffer = Buffer::None; + mem::swap(&mut self.buffer, &mut oldbuffer); + if let Buffer::BoxedMutSlice(inner) = oldbuffer { + Some(inner) + } else { + unreachable!(); + } + } else { + None + } + } + + /// Returns the underlying file descriptor associated with the `AioCb` + pub fn fd(&self) -> RawFd { + self.aiocb.aio_fildes + } + + /// Constructs a new `AioCb` with no associated buffer. + /// + /// The resulting `AioCb` structure is suitable for use with `AioCb::fsync`. + /// + /// # Parameters + /// + /// * `fd`: File descriptor. Required for all aio functions. + /// * `prio`: If POSIX Prioritized IO is supported, then the + /// operation will be prioritized at the process's + /// priority level minus `prio`. + /// * `sigev_notify`: Determines how you will be notified of event + /// completion. + /// + /// # Examples + /// + /// Create an `AioCb` from a raw file descriptor and use it for an + /// [`fsync`](#method.fsync) operation. + /// + /// ``` + /// # extern crate tempfile; + /// # extern crate nix; + /// # use nix::errno::Errno; + /// # use nix::Error; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify::SigevNone; + /// # use std::{thread, time}; + /// # use std::os::unix::io::AsRawFd; + /// # use tempfile::tempfile; + /// # fn main() { + /// let f = tempfile().unwrap(); + /// let mut aiocb = AioCb::from_fd( f.as_raw_fd(), 0, SigevNone); + /// aiocb.fsync(AioFsyncMode::O_SYNC).expect("aio_fsync failed early"); + /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) { + /// thread::sleep(time::Duration::from_millis(10)); + /// } + /// aiocb.aio_return().expect("aio_fsync failed late"); + /// # } + /// ``` + pub fn from_fd(fd: RawFd, prio: libc::c_int, + sigev_notify: SigevNotify) -> AioCb<'a> { + let mut a = AioCb::common_init(fd, prio, sigev_notify); + a.aio_offset = 0; + a.aio_nbytes = 0; + a.aio_buf = null_mut(); + + AioCb { + aiocb: a, + mutable: false, + in_progress: false, + buffer: Buffer::None + } + } + + /// Constructs a new `AioCb` from a mutable slice. + /// + /// The resulting `AioCb` will be suitable for both read and write + /// operations, but only if the borrow checker can guarantee that the slice + /// will outlive the `AioCb`. That will usually be the case if the `AioCb` + /// is stack-allocated. If the borrow checker gives you trouble, try using + /// [`from_boxed_mut_slice`](#method.from_boxed_mut_slice) instead. + /// + /// # Parameters + /// + /// * `fd`: File descriptor. Required for all aio functions. + /// * `offs`: File offset + /// * `buf`: A memory buffer + /// * `prio`: If POSIX Prioritized IO is supported, then the + /// operation will be prioritized at the process's + /// priority level minus `prio` + /// * `sigev_notify`: Determines how you will be notified of event + /// completion. + /// * `opcode`: This field is only used for `lio_listio`. It + /// determines which operation to use for this individual + /// aiocb + /// + /// # Examples + /// + /// Create an `AioCb` from a mutable slice and read into it. + /// + /// ``` + /// # extern crate tempfile; + /// # extern crate nix; + /// # use nix::errno::Errno; + /// # use nix::Error; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify; + /// # use std::{thread, time}; + /// # use std::io::Write; + /// # use std::os::unix::io::AsRawFd; + /// # use tempfile::tempfile; + /// # fn main() { + /// const INITIAL: &[u8] = b"abcdef123456"; + /// const LEN: usize = 4; + /// let mut rbuf = vec![0; LEN]; + /// let mut f = tempfile().unwrap(); + /// f.write_all(INITIAL).unwrap(); + /// { + /// let mut aiocb = AioCb::from_mut_slice( f.as_raw_fd(), + /// 2, //offset + /// &mut rbuf, + /// 0, //priority + /// SigevNotify::SigevNone, + /// LioOpcode::LIO_NOP); + /// aiocb.read().unwrap(); + /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) { + /// thread::sleep(time::Duration::from_millis(10)); + /// } + /// assert_eq!(aiocb.aio_return().unwrap() as usize, LEN); + /// } + /// assert_eq!(rbuf, b"cdef"); + /// # } + /// ``` + pub fn from_mut_slice(fd: RawFd, offs: off_t, buf: &'a mut [u8], + prio: libc::c_int, sigev_notify: SigevNotify, + opcode: LioOpcode) -> AioCb<'a> { + let mut a = AioCb::common_init(fd, prio, sigev_notify); + a.aio_offset = offs; + a.aio_nbytes = buf.len() as size_t; + a.aio_buf = buf.as_ptr() as *mut c_void; + a.aio_lio_opcode = opcode as libc::c_int; + + AioCb { + aiocb: a, + mutable: true, + in_progress: false, + buffer: Buffer::Phantom(PhantomData), + } + } + + /// The safest and most flexible way to create an `AioCb`. + /// + /// Unlike [`from_slice`], this method returns a structure suitable for + /// placement on the heap. It may be used for write operations, but not + /// read operations. Unlike `from_ptr`, this method will ensure that the + /// buffer doesn't `drop` while the kernel is still processing it. Any + /// object that can be borrowed as a boxed slice will work. + /// + /// # Parameters + /// + /// * `fd`: File descriptor. Required for all aio functions. + /// * `offs`: File offset + /// * `buf`: A boxed slice-like object + /// * `prio`: If POSIX Prioritized IO is supported, then the + /// operation will be prioritized at the process's + /// priority level minus `prio` + /// * `sigev_notify`: Determines how you will be notified of event + /// completion. + /// * `opcode`: This field is only used for `lio_listio`. It + /// determines which operation to use for this individual + /// aiocb + /// + /// # Examples + /// + /// Create an `AioCb` from a Vector and use it for writing + /// + /// ``` + /// # extern crate tempfile; + /// # extern crate nix; + /// # use nix::errno::Errno; + /// # use nix::Error; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify; + /// # use std::{thread, time}; + /// # use std::io::Write; + /// # use std::os::unix::io::AsRawFd; + /// # use tempfile::tempfile; + /// # fn main() { + /// let wbuf = Box::new(Vec::from("CDEF")); + /// let expected_len = wbuf.len(); + /// let mut f = tempfile().unwrap(); + /// let mut aiocb = AioCb::from_boxed_slice( f.as_raw_fd(), + /// 2, //offset + /// wbuf, + /// 0, //priority + /// SigevNotify::SigevNone, + /// LioOpcode::LIO_NOP); + /// aiocb.write().unwrap(); + /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) { + /// thread::sleep(time::Duration::from_millis(10)); + /// } + /// assert_eq!(aiocb.aio_return().unwrap() as usize, expected_len); + /// # } + /// ``` + /// + /// Create an `AioCb` from a `Bytes` object + /// + /// ``` + /// # extern crate bytes; + /// # extern crate tempfile; + /// # extern crate nix; + /// # use bytes::Bytes; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify; + /// # use std::os::unix::io::AsRawFd; + /// # use tempfile::tempfile; + /// # fn main() { + /// let wbuf = Box::new(Bytes::from(&b"CDEF"[..])); + /// let mut f = tempfile().unwrap(); + /// let mut aiocb = AioCb::from_boxed_slice( f.as_raw_fd(), + /// 2, //offset + /// wbuf, + /// 0, //priority + /// SigevNotify::SigevNone, + /// LioOpcode::LIO_NOP); + /// # } + /// ``` + /// + /// If a library needs to work with buffers that aren't `Box`ed, it can + /// create a `Box`ed container for use with this method. Here's an example + /// using an un`Box`ed `Bytes` object. + /// + /// ``` + /// # extern crate bytes; + /// # extern crate tempfile; + /// # extern crate nix; + /// # use bytes::Bytes; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify; + /// # use std::borrow::Borrow; + /// # use std::os::unix::io::AsRawFd; + /// # use tempfile::tempfile; + /// struct BytesContainer(Bytes); + /// impl Borrow<[u8]> for BytesContainer { + /// fn borrow(&self) -> &[u8] { + /// self.0.as_ref() + /// } + /// } + /// fn main() { + /// let wbuf = Bytes::from(&b"CDEF"[..]); + /// let boxed_wbuf = Box::new(BytesContainer(wbuf)); + /// let mut f = tempfile().unwrap(); + /// let mut aiocb = AioCb::from_boxed_slice( f.as_raw_fd(), + /// 2, //offset + /// boxed_wbuf, + /// 0, //priority + /// SigevNotify::SigevNone, + /// LioOpcode::LIO_NOP); + /// } + /// ``` + /// + /// [`from_slice`]: #method.from_slice + pub fn from_boxed_slice(fd: RawFd, offs: off_t, buf: Box>, + prio: libc::c_int, sigev_notify: SigevNotify, + opcode: LioOpcode) -> AioCb<'a> { + let mut a = AioCb::common_init(fd, prio, sigev_notify); + { + let borrowed : &Borrow<[u8]> = buf.borrow(); + let slice : &[u8] = borrowed.borrow(); + a.aio_nbytes = slice.len() as size_t; + a.aio_buf = slice.as_ptr() as *mut c_void; + } + a.aio_offset = offs; + a.aio_lio_opcode = opcode as libc::c_int; + + AioCb { + aiocb: a, + mutable: false, + in_progress: false, + buffer: Buffer::BoxedSlice(buf), + } + } + + /// The safest and most flexible way to create an `AioCb` for reading. + /// + /// Like [`from_boxed_slice`], but the slice is a mutable one. More + /// flexible than [`from_mut_slice`], because a wide range of objects can be + /// used. + /// + /// # Examples + /// + /// Create an `AioCb` from a Vector and use it for reading + /// + /// ``` + /// # extern crate tempfile; + /// # extern crate nix; + /// # use nix::errno::Errno; + /// # use nix::Error; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify; + /// # use std::{thread, time}; + /// # use std::io::Write; + /// # use std::os::unix::io::AsRawFd; + /// # use tempfile::tempfile; + /// # fn main() { + /// const INITIAL: &[u8] = b"abcdef123456"; + /// const LEN: usize = 4; + /// let rbuf = Box::new(vec![0; LEN]); + /// let mut f = tempfile().unwrap(); + /// f.write_all(INITIAL).unwrap(); + /// let mut aiocb = AioCb::from_boxed_mut_slice( f.as_raw_fd(), + /// 2, //offset + /// rbuf, + /// 0, //priority + /// SigevNotify::SigevNone, + /// LioOpcode::LIO_NOP); + /// aiocb.read().unwrap(); + /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) { + /// thread::sleep(time::Duration::from_millis(10)); + /// } + /// assert_eq!(aiocb.aio_return().unwrap() as usize, LEN); + /// let mut buffer = aiocb.boxed_mut_slice().unwrap(); + /// const EXPECT: &[u8] = b"cdef"; + /// assert_eq!(buffer.borrow_mut(), EXPECT); + /// # } + /// ``` + /// + /// [`from_boxed_slice`]: #method.from_boxed_slice + /// [`from_mut_slice`]: #method.from_mut_slice + pub fn from_boxed_mut_slice(fd: RawFd, offs: off_t, + mut buf: Box>, + prio: libc::c_int, sigev_notify: SigevNotify, + opcode: LioOpcode) -> AioCb<'a> { + let mut a = AioCb::common_init(fd, prio, sigev_notify); + { + let borrowed : &mut BorrowMut<[u8]> = buf.borrow_mut(); + let slice : &mut [u8] = borrowed.borrow_mut(); + a.aio_nbytes = slice.len() as size_t; + a.aio_buf = slice.as_mut_ptr() as *mut c_void; + } + a.aio_offset = offs; + a.aio_lio_opcode = opcode as libc::c_int; + + AioCb { + aiocb: a, + mutable: true, + in_progress: false, + buffer: Buffer::BoxedMutSlice(buf), + } + } + + /// Constructs a new `AioCb` from a mutable raw pointer + /// + /// Unlike `from_mut_slice`, this method returns a structure suitable for + /// placement on the heap. It may be used for both reads and writes. Due + /// to its unsafety, this method is not recommended. It is most useful when + /// heap allocation is required but for some reason the data cannot be + /// wrapped in a `struct` that implements `BorrowMut<[u8]>` + /// + /// # Parameters + /// + /// * `fd`: File descriptor. Required for all aio functions. + /// * `offs`: File offset + /// * `buf`: Pointer to the memory buffer + /// * `len`: Length of the buffer pointed to by `buf` + /// * `prio`: If POSIX Prioritized IO is supported, then the + /// operation will be prioritized at the process's + /// priority level minus `prio` + /// * `sigev_notify`: Determines how you will be notified of event + /// completion. + /// * `opcode`: This field is only used for `lio_listio`. It + /// determines which operation to use for this individual + /// aiocb + /// + /// # Safety + /// + /// The caller must ensure that the storage pointed to by `buf` outlives the + /// `AioCb`. The lifetime checker can't help here. + pub unsafe fn from_mut_ptr(fd: RawFd, offs: off_t, + buf: *mut c_void, len: usize, + prio: libc::c_int, sigev_notify: SigevNotify, + opcode: LioOpcode) -> AioCb<'a> { + let mut a = AioCb::common_init(fd, prio, sigev_notify); + a.aio_offset = offs; + a.aio_nbytes = len; + a.aio_buf = buf; + a.aio_lio_opcode = opcode as libc::c_int; + + AioCb { + aiocb: a, + mutable: true, + in_progress: false, + buffer: Buffer::None + } + } + + /// Constructs a new `AioCb` from a raw pointer. + /// + /// Unlike `from_slice`, this method returns a structure suitable for + /// placement on the heap. Due to its unsafety, this method is not + /// recommended. It is most useful when heap allocation is required but for + /// some reason the data cannot be wrapped in a `struct` that implements + /// `Borrow<[u8]>` + /// + /// # Parameters + /// + /// * `fd`: File descriptor. Required for all aio functions. + /// * `offs`: File offset + /// * `buf`: Pointer to the memory buffer + /// * `len`: Length of the buffer pointed to by `buf` + /// * `prio`: If POSIX Prioritized IO is supported, then the + /// operation will be prioritized at the process's + /// priority level minus `prio` + /// * `sigev_notify`: Determines how you will be notified of event + /// completion. + /// * `opcode`: This field is only used for `lio_listio`. It + /// determines which operation to use for this individual + /// aiocb + /// + /// # Safety + /// + /// The caller must ensure that the storage pointed to by `buf` outlives the + /// `AioCb`. The lifetime checker can't help here. + pub unsafe fn from_ptr(fd: RawFd, offs: off_t, + buf: *const c_void, len: usize, + prio: libc::c_int, sigev_notify: SigevNotify, + opcode: LioOpcode) -> AioCb<'a> { + let mut a = AioCb::common_init(fd, prio, sigev_notify); + a.aio_offset = offs; + a.aio_nbytes = len; + // casting a const ptr to a mutable ptr here is ok, because we set the + // AioCb's mutable field to false + a.aio_buf = buf as *mut c_void; + a.aio_lio_opcode = opcode as libc::c_int; + + AioCb { + aiocb: a, + mutable: false, + in_progress: false, + buffer: Buffer::None + } + } + + /// Like `from_mut_slice`, but works on constant slices rather than + /// mutable slices. + /// + /// An `AioCb` created this way cannot be used with `read`, and its + /// `LioOpcode` cannot be set to `LIO_READ`. This method is useful when + /// writing a const buffer with `AioCb::write`, since `from_mut_slice` can't + /// work with const buffers. + /// + /// # Examples + /// + /// Construct an `AioCb` from a slice and use it for writing. + /// + /// ``` + /// # extern crate tempfile; + /// # extern crate nix; + /// # use nix::errno::Errno; + /// # use nix::Error; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify; + /// # use std::{thread, time}; + /// # use std::os::unix::io::AsRawFd; + /// # use tempfile::tempfile; + /// # fn main() { + /// const WBUF: &[u8] = b"abcdef123456"; + /// let mut f = tempfile().unwrap(); + /// let mut aiocb = AioCb::from_slice( f.as_raw_fd(), + /// 2, //offset + /// WBUF, + /// 0, //priority + /// SigevNotify::SigevNone, + /// LioOpcode::LIO_NOP); + /// aiocb.write().unwrap(); + /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) { + /// thread::sleep(time::Duration::from_millis(10)); + /// } + /// assert_eq!(aiocb.aio_return().unwrap() as usize, WBUF.len()); + /// # } + /// ``` + // Note: another solution to the problem of writing const buffers would be + // to genericize AioCb for both &mut [u8] and &[u8] buffers. AioCb::read + // could take the former and AioCb::write could take the latter. However, + // then lio_listio wouldn't work, because that function needs a slice of + // AioCb, and they must all be of the same type. + pub fn from_slice(fd: RawFd, offs: off_t, buf: &'a [u8], + prio: libc::c_int, sigev_notify: SigevNotify, + opcode: LioOpcode) -> AioCb { + let mut a = AioCb::common_init(fd, prio, sigev_notify); + a.aio_offset = offs; + a.aio_nbytes = buf.len() as size_t; + // casting an immutable buffer to a mutable pointer looks unsafe, + // but technically its only unsafe to dereference it, not to create + // it. + a.aio_buf = buf.as_ptr() as *mut c_void; + assert!(opcode != LioOpcode::LIO_READ, "Can't read into an immutable buffer"); + a.aio_lio_opcode = opcode as libc::c_int; + + AioCb { + aiocb: a, + mutable: false, + in_progress: false, + buffer: Buffer::None, + } + } + + fn common_init(fd: RawFd, prio: libc::c_int, + sigev_notify: SigevNotify) -> libc::aiocb { + // Use mem::zeroed instead of explicitly zeroing each field, because the + // number and name of reserved fields is OS-dependent. On some OSes, + // some reserved fields are used the kernel for state, and must be + // explicitly zeroed when allocated. + let mut a = unsafe { mem::zeroed::()}; + a.aio_fildes = fd; + a.aio_reqprio = prio; + a.aio_sigevent = SigEvent::new(sigev_notify).sigevent(); + a + } + + /// Update the notification settings for an existing `aiocb` + pub fn set_sigev_notify(&mut self, sigev_notify: SigevNotify) { + self.aiocb.aio_sigevent = SigEvent::new(sigev_notify).sigevent(); + } + + /// Cancels an outstanding AIO request. + /// + /// The operating system is not required to implement cancellation for all + /// file and device types. Even if it does, there is no guarantee that the + /// operation has not already completed. So the caller must check the + /// result and handle operations that were not canceled or that have already + /// completed. + /// + /// # Examples + /// + /// Cancel an outstanding aio operation. Note that we must still call + /// `aio_return` to free resources, even though we don't care about the + /// result. + /// + /// ``` + /// # extern crate tempfile; + /// # extern crate nix; + /// # use nix::errno::Errno; + /// # use nix::Error; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify; + /// # use std::{thread, time}; + /// # use std::io::Write; + /// # use std::os::unix::io::AsRawFd; + /// # use tempfile::tempfile; + /// # fn main() { + /// let wbuf = b"CDEF"; + /// let mut f = tempfile().unwrap(); + /// let mut aiocb = AioCb::from_slice( f.as_raw_fd(), + /// 2, //offset + /// &wbuf[..], + /// 0, //priority + /// SigevNotify::SigevNone, + /// LioOpcode::LIO_NOP); + /// aiocb.write().unwrap(); + /// let cs = aiocb.cancel().unwrap(); + /// if cs == AioCancelStat::AioNotCanceled { + /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) { + /// thread::sleep(time::Duration::from_millis(10)); + /// } + /// } + /// // Must call `aio_return`, but ignore the result + /// let _ = aiocb.aio_return(); + /// # } + /// ``` + /// + /// # References + /// + /// [aio_cancel](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_cancel.html) + pub fn cancel(&mut self) -> Result { + match unsafe { libc::aio_cancel(self.aiocb.aio_fildes, &mut self.aiocb) } { + libc::AIO_CANCELED => Ok(AioCancelStat::AioCanceled), + libc::AIO_NOTCANCELED => Ok(AioCancelStat::AioNotCanceled), + libc::AIO_ALLDONE => Ok(AioCancelStat::AioAllDone), + -1 => Err(Error::last()), + _ => panic!("unknown aio_cancel return value") + } + } + + /// Retrieve error status of an asynchronous operation. + /// + /// If the request has not yet completed, returns `EINPROGRESS`. Otherwise, + /// returns `Ok` or any other error. + /// + /// # Examples + /// + /// Issue an aio operation and use `error` to poll for completion. Polling + /// is an alternative to `aio_suspend`, used by most of the other examples. + /// + /// ``` + /// # extern crate tempfile; + /// # extern crate nix; + /// # use nix::errno::Errno; + /// # use nix::Error; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify; + /// # use std::{thread, time}; + /// # use std::os::unix::io::AsRawFd; + /// # use tempfile::tempfile; + /// # fn main() { + /// const WBUF: &[u8] = b"abcdef123456"; + /// let mut f = tempfile().unwrap(); + /// let mut aiocb = AioCb::from_slice( f.as_raw_fd(), + /// 2, //offset + /// WBUF, + /// 0, //priority + /// SigevNotify::SigevNone, + /// LioOpcode::LIO_NOP); + /// aiocb.write().unwrap(); + /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) { + /// thread::sleep(time::Duration::from_millis(10)); + /// } + /// assert_eq!(aiocb.aio_return().unwrap() as usize, WBUF.len()); + /// # } + /// ``` + /// + /// # References + /// + /// [aio_error](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_error.html) + pub fn error(&mut self) -> Result<()> { + match unsafe { libc::aio_error(&mut self.aiocb as *mut libc::aiocb) } { + 0 => Ok(()), + num if num > 0 => Err(Error::from_errno(Errno::from_i32(num))), + -1 => Err(Error::last()), + num => panic!("unknown aio_error return value {:?}", num) + } + } + + /// An asynchronous version of `fsync(2)`. + /// + /// # References + /// + /// [aio_fsync](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_fsync.html) + pub fn fsync(&mut self, mode: AioFsyncMode) -> Result<()> { + let p: *mut libc::aiocb = &mut self.aiocb; + Errno::result(unsafe { + libc::aio_fsync(mode as libc::c_int, p) + }).map(|_| { + self.in_progress = true; + }) + } + + /// Returns the `aiocb`'s `LioOpcode` field + /// + /// If the value cannot be represented as an `LioOpcode`, returns `None` + /// instead. + pub fn lio_opcode(&self) -> Option { + match self.aiocb.aio_lio_opcode { + libc::LIO_READ => Some(LioOpcode::LIO_READ), + libc::LIO_WRITE => Some(LioOpcode::LIO_WRITE), + libc::LIO_NOP => Some(LioOpcode::LIO_NOP), + _ => None + } + } + + /// Returns the requested length of the aio operation in bytes + /// + /// This method returns the *requested* length of the operation. To get the + /// number of bytes actually read or written by a completed operation, use + /// `aio_return` instead. + pub fn nbytes(&self) -> usize { + self.aiocb.aio_nbytes + } + + /// Returns the file offset stored in the `AioCb` + pub fn offset(&self) -> off_t { + self.aiocb.aio_offset + } + + /// Returns the priority of the `AioCb` + pub fn priority(&self) -> libc::c_int { + self.aiocb.aio_reqprio + } + + /// Asynchronously reads from a file descriptor into a buffer + /// + /// # References + /// + /// [aio_read](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_read.html) + pub fn read(&mut self) -> Result<()> { + assert!(self.mutable, "Can't read into an immutable buffer"); + let p: *mut libc::aiocb = &mut self.aiocb; + Errno::result(unsafe { + libc::aio_read(p) + }).map(|_| { + self.in_progress = true; + }) + } + + /// Returns the `SigEvent` stored in the `AioCb` + pub fn sigevent(&self) -> SigEvent { + SigEvent::from(&self.aiocb.aio_sigevent) + } + + /// Retrieve return status of an asynchronous operation. + /// + /// Should only be called once for each `AioCb`, after `AioCb::error` + /// indicates that it has completed. The result is the same as for the + /// synchronous `read(2)`, `write(2)`, of `fsync(2)` functions. + /// + /// # References + /// + /// [aio_return](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_return.html) + // Note: this should be just `return`, but that's a reserved word + pub fn aio_return(&mut self) -> Result { + let p: *mut libc::aiocb = &mut self.aiocb; + self.in_progress = false; + Errno::result(unsafe { libc::aio_return(p) }) + } + + /// Asynchronously writes from a buffer to a file descriptor + /// + /// # References + /// + /// [aio_write](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_write.html) + pub fn write(&mut self) -> Result<()> { + let p: *mut libc::aiocb = &mut self.aiocb; + Errno::result(unsafe { + libc::aio_write(p) + }).map(|_| { + self.in_progress = true; + }) + } + +} + +/// Cancels outstanding AIO requests for a given file descriptor. +/// +/// # Examples +/// +/// Issue an aio operation, then cancel all outstanding operations on that file +/// descriptor. +/// +/// ``` +/// # extern crate tempfile; +/// # extern crate nix; +/// # use nix::errno::Errno; +/// # use nix::Error; +/// # use nix::sys::aio::*; +/// # use nix::sys::signal::SigevNotify; +/// # use std::{thread, time}; +/// # use std::io::Write; +/// # use std::os::unix::io::AsRawFd; +/// # use tempfile::tempfile; +/// # fn main() { +/// let wbuf = b"CDEF"; +/// let mut f = tempfile().unwrap(); +/// let mut aiocb = AioCb::from_slice( f.as_raw_fd(), +/// 2, //offset +/// &wbuf[..], +/// 0, //priority +/// SigevNotify::SigevNone, +/// LioOpcode::LIO_NOP); +/// aiocb.write().unwrap(); +/// let cs = aio_cancel_all(f.as_raw_fd()).unwrap(); +/// if cs == AioCancelStat::AioNotCanceled { +/// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) { +/// thread::sleep(time::Duration::from_millis(10)); +/// } +/// } +/// // Must call `aio_return`, but ignore the result +/// let _ = aiocb.aio_return(); +/// # } +/// ``` +/// +/// # References +/// +/// [`aio_cancel`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_cancel.html) +pub fn aio_cancel_all(fd: RawFd) -> Result { + match unsafe { libc::aio_cancel(fd, null_mut()) } { + libc::AIO_CANCELED => Ok(AioCancelStat::AioCanceled), + libc::AIO_NOTCANCELED => Ok(AioCancelStat::AioNotCanceled), + libc::AIO_ALLDONE => Ok(AioCancelStat::AioAllDone), + -1 => Err(Error::last()), + _ => panic!("unknown aio_cancel return value") + } +} + +/// Suspends the calling process until at least one of the specified `AioCb`s +/// has completed, a signal is delivered, or the timeout has passed. +/// +/// If `timeout` is `None`, `aio_suspend` will block indefinitely. +/// +/// # Examples +/// +/// Use `aio_suspend` to block until an aio operation completes. +/// +// Disable doctest due to a known bug in FreeBSD's 32-bit emulation. The fix +// will be included in release 11.2. +// FIXME reenable the doc test when the CI machine gets upgraded to that release. +// https://svnweb.freebsd.org/base?view=revision&revision=325018 +/// ```no_run +/// # extern crate tempfile; +/// # extern crate nix; +/// # use nix::sys::aio::*; +/// # use nix::sys::signal::SigevNotify; +/// # use std::os::unix::io::AsRawFd; +/// # use tempfile::tempfile; +/// # fn main() { +/// const WBUF: &[u8] = b"abcdef123456"; +/// let mut f = tempfile().unwrap(); +/// let mut aiocb = AioCb::from_slice( f.as_raw_fd(), +/// 2, //offset +/// WBUF, +/// 0, //priority +/// SigevNotify::SigevNone, +/// LioOpcode::LIO_NOP); +/// aiocb.write().unwrap(); +/// aio_suspend(&[&aiocb], None).expect("aio_suspend failed"); +/// assert_eq!(aiocb.aio_return().unwrap() as usize, WBUF.len()); +/// # } +/// ``` +/// # References +/// +/// [`aio_suspend`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_suspend.html) +pub fn aio_suspend(list: &[&AioCb], timeout: Option) -> Result<()> { + let plist = list as *const [&AioCb] as *const [*const libc::aiocb]; + let p = plist as *const *const libc::aiocb; + let timep = match timeout { + None => null::(), + Some(x) => x.as_ref() as *const libc::timespec + }; + Errno::result(unsafe { + libc::aio_suspend(p, list.len() as i32, timep) + }).map(drop) +} + +impl<'a> Debug for AioCb<'a> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("AioCb") + .field("aio_fildes", &self.aiocb.aio_fildes) + .field("aio_offset", &self.aiocb.aio_offset) + .field("aio_buf", &self.aiocb.aio_buf) + .field("aio_nbytes", &self.aiocb.aio_nbytes) + .field("aio_lio_opcode", &self.aiocb.aio_lio_opcode) + .field("aio_reqprio", &self.aiocb.aio_reqprio) + .field("aio_sigevent", &SigEvent::from(&self.aiocb.aio_sigevent)) + .field("mutable", &self.mutable) + .field("in_progress", &self.in_progress) + .finish() + } +} + +impl<'a> Drop for AioCb<'a> { + /// If the `AioCb` has no remaining state in the kernel, just drop it. + /// Otherwise, dropping constitutes a resource leak, which is an error + fn drop(&mut self) { + assert!(thread::panicking() || !self.in_progress, + "Dropped an in-progress AioCb"); + } +} + +/// LIO Control Block. +/// +/// The basic structure used to issue multiple AIO operations simultaneously. +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +pub struct LioCb<'a> { + /// A collection of [`AioCb`]s. All of these will be issued simultaneously + /// by the [`listio`] method. + /// + /// [`AioCb`]: struct.AioCb.html + /// [`listio`]: #method.listio + pub aiocbs: Vec>, + + /// The actual list passed to `libc::lio_listio`. + /// + /// It must live for as long as any of the operations are still being + /// processesed, because the aio subsystem uses its address as a unique + /// identifier. + list: Vec<*mut libc::aiocb>, + + /// A partial set of results. This field will get populated by + /// `listio_resubmit` when an `LioCb` is resubmitted after an error + results: Vec>> +} + +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +impl<'a> LioCb<'a> { + /// Initialize an empty `LioCb` + pub fn with_capacity(capacity: usize) -> LioCb<'a> { + LioCb { + aiocbs: Vec::with_capacity(capacity), + list: Vec::with_capacity(capacity), + results: Vec::with_capacity(capacity) + } + } + + /// Submits multiple asynchronous I/O requests with a single system call. + /// + /// They are not guaranteed to complete atomically, and the order in which + /// the requests are carried out is not specified. Reads, writes, and + /// fsyncs may be freely mixed. + /// + /// This function is useful for reducing the context-switch overhead of + /// submitting many AIO operations. It can also be used with + /// `LioMode::LIO_WAIT` to block on the result of several independent + /// operations. Used that way, it is often useful in programs that + /// otherwise make little use of AIO. + /// + /// # Examples + /// + /// Use `listio` to submit an aio operation and wait for its completion. In + /// this case, there is no need to use [`aio_suspend`] to wait or + /// [`AioCb::error`] to poll. + /// + /// ``` + /// # extern crate tempfile; + /// # extern crate nix; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify; + /// # use std::os::unix::io::AsRawFd; + /// # use tempfile::tempfile; + /// # fn main() { + /// const WBUF: &[u8] = b"abcdef123456"; + /// let mut f = tempfile().unwrap(); + /// let mut liocb = LioCb::with_capacity(1); + /// liocb.aiocbs.push(AioCb::from_slice( f.as_raw_fd(), + /// 2, //offset + /// WBUF, + /// 0, //priority + /// SigevNotify::SigevNone, + /// LioOpcode::LIO_WRITE)); + /// liocb.listio(LioMode::LIO_WAIT, + /// SigevNotify::SigevNone).unwrap(); + /// assert_eq!(liocb.aio_return(0).unwrap() as usize, WBUF.len()); + /// # } + /// ``` + /// + /// # References + /// + /// [`lio_listio`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/lio_listio.html) + /// + /// [`aio_suspend`]: fn.aio_suspend.html + /// [`AioCb::error`]: struct.AioCb.html#method.error + pub fn listio(&mut self, mode: LioMode, + sigev_notify: SigevNotify) -> Result<()> { + let sigev = SigEvent::new(sigev_notify); + let sigevp = &mut sigev.sigevent() as *mut libc::sigevent; + self.list.clear(); + for a in &mut self.aiocbs { + a.in_progress = true; + self.list.push(a as *mut AioCb<'a> + as *mut libc::aiocb); + } + let p = self.list.as_ptr(); + Errno::result(unsafe { + libc::lio_listio(mode as i32, p, self.list.len() as i32, sigevp) + }).map(drop) + } + + /// Resubmits any incomplete operations with [`lio_listio`]. + /// + /// Sometimes, due to system resource limitations, an `lio_listio` call will + /// return `EIO`, or `EAGAIN`. Or, if a signal is received, it may return + /// `EINTR`. In any of these cases, only a subset of its constituent + /// operations will actually have been initiated. `listio_resubmit` will + /// resubmit any operations that are still uninitiated. + /// + /// After calling `listio_resubmit`, results should be collected by + /// [`LioCb::aio_return`]. + /// + /// # Examples + /// ```no_run + /// # extern crate tempfile; + /// # extern crate nix; + /// # use nix::Error; + /// # use nix::errno::Errno; + /// # use nix::sys::aio::*; + /// # use nix::sys::signal::SigevNotify; + /// # use std::os::unix::io::AsRawFd; + /// # use std::{thread, time}; + /// # use tempfile::tempfile; + /// # fn main() { + /// const WBUF: &[u8] = b"abcdef123456"; + /// let mut f = tempfile().unwrap(); + /// let mut liocb = LioCb::with_capacity(1); + /// liocb.aiocbs.push(AioCb::from_slice( f.as_raw_fd(), + /// 2, //offset + /// WBUF, + /// 0, //priority + /// SigevNotify::SigevNone, + /// LioOpcode::LIO_WRITE)); + /// let mut err = liocb.listio(LioMode::LIO_WAIT, SigevNotify::SigevNone); + /// while err == Err(Error::Sys(Errno::EIO)) || + /// err == Err(Error::Sys(Errno::EAGAIN)) { + /// thread::sleep(time::Duration::from_millis(10)); + /// err = liocb.listio_resubmit(LioMode::LIO_WAIT, SigevNotify::SigevNone); + /// } + /// assert_eq!(liocb.aio_return(0).unwrap() as usize, WBUF.len()); + /// # } + /// ``` + /// + /// # References + /// + /// [`lio_listio`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/lio_listio.html) + /// + /// [`lio_listio`]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/lio_listio.html + /// [`LioCb::aio_return`]: struct.LioCb.html#method.aio_return + // Note: the addresses of any EINPROGRESS or EOK aiocbs _must_ not be + // changed by this method, because the kernel relies on their addresses + // being stable. + // Note: aiocbs that are Ok(()) must be finalized by aio_return, or else the + // sigev_notify will immediately refire. + pub fn listio_resubmit(&mut self, mode:LioMode, + sigev_notify: SigevNotify) -> Result<()> { + let sigev = SigEvent::new(sigev_notify); + let sigevp = &mut sigev.sigevent() as *mut libc::sigevent; + self.list.clear(); + + while self.results.len() < self.aiocbs.len() { + self.results.push(None); + } + + for (i, a) in self.aiocbs.iter_mut().enumerate() { + if self.results[i].is_some() { + // Already collected final status for this operation + continue; + } + match a.error() { + Ok(()) => { + // aiocb is complete; collect its status and don't resubmit + self.results[i] = Some(a.aio_return()); + }, + Err(Error::Sys(Errno::EAGAIN)) => { + self.list.push(a as *mut AioCb<'a> as *mut libc::aiocb); + }, + Err(Error::Sys(Errno::EINPROGRESS)) => { + // aiocb is was successfully queued; no need to do anything + () + }, + Err(Error::Sys(Errno::EINVAL)) => panic!( + "AioCb was never submitted, or already finalized"), + _ => unreachable!() + } + } + let p = self.list.as_ptr(); + Errno::result(unsafe { + libc::lio_listio(mode as i32, p, self.list.len() as i32, sigevp) + }).map(drop) + } + + /// Collect final status for an individual `AioCb` submitted as part of an + /// `LioCb`. + /// + /// This is just like [`AioCb::aio_return`], except it takes into account + /// operations that were restarted by [`LioCb::listio_resubmit`] + /// + /// [`AioCb::aio_return`]: struct.AioCb.html#method.aio_return + /// [`LioCb::listio_resubmit`]: #method.listio_resubmit + pub fn aio_return(&mut self, i: usize) -> Result { + if i >= self.results.len() || self.results[i].is_none() { + self.aiocbs[i].aio_return() + } else { + self.results[i].unwrap() + } + } + + /// Retrieve error status of an individual `AioCb` submitted as part of an + /// `LioCb`. + /// + /// This is just like [`AioCb::error`], except it takes into account + /// operations that were restarted by [`LioCb::listio_resubmit`] + /// + /// [`AioCb::error`]: struct.AioCb.html#method.error + /// [`LioCb::listio_resubmit`]: #method.listio_resubmit + pub fn error(&mut self, i: usize) -> Result<()> { + if i >= self.results.len() || self.results[i].is_none() { + self.aiocbs[i].error() + } else { + Ok(()) + } + } +} + +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +impl<'a> Debug for LioCb<'a> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LioCb") + .field("aiocbs", &self.aiocbs) + .finish() + } +} + +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +impl<'a> From>> for LioCb<'a> { + fn from(src: Vec>) -> LioCb<'a> { + LioCb { + list: Vec::with_capacity(src.capacity()), + results: Vec::with_capacity(src.capacity()), + aiocbs: src, + } + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/epoll.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/epoll.rs new file mode 100644 index 0000000..3ed1dd7 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/epoll.rs @@ -0,0 +1,110 @@ +use Result; +use errno::Errno; +use libc::{self, c_int}; +use std::os::unix::io::RawFd; +use std::ptr; +use std::mem; +use ::Error; + +libc_bitflags!( + pub struct EpollFlags: c_int { + EPOLLIN; + EPOLLPRI; + EPOLLOUT; + EPOLLRDNORM; + EPOLLRDBAND; + EPOLLWRNORM; + EPOLLWRBAND; + EPOLLMSG; + EPOLLERR; + EPOLLHUP; + EPOLLRDHUP; + #[cfg(target_os = "linux")] // Added in 4.5; not in Android. + EPOLLEXCLUSIVE; + #[cfg(not(target_arch = "mips"))] + EPOLLWAKEUP; + EPOLLONESHOT; + EPOLLET; + } +); + +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +#[repr(i32)] +pub enum EpollOp { + EpollCtlAdd = libc::EPOLL_CTL_ADD, + EpollCtlDel = libc::EPOLL_CTL_DEL, + EpollCtlMod = libc::EPOLL_CTL_MOD, +} + +libc_bitflags!{ + pub struct EpollCreateFlags: c_int { + EPOLL_CLOEXEC; + } +} + +#[allow(missing_debug_implementations)] +#[derive(Clone, Copy)] +#[repr(C)] +pub struct EpollEvent { + event: libc::epoll_event, +} + +impl EpollEvent { + pub fn new(events: EpollFlags, data: u64) -> Self { + EpollEvent { event: libc::epoll_event { events: events.bits() as u32, u64: data } } + } + + pub fn empty() -> Self { + unsafe { mem::zeroed::() } + } + + pub fn events(&self) -> EpollFlags { + EpollFlags::from_bits(self.event.events as c_int).unwrap() + } + + pub fn data(&self) -> u64 { + self.event.u64 + } +} + +#[inline] +pub fn epoll_create() -> Result { + let res = unsafe { libc::epoll_create(1024) }; + + Errno::result(res) +} + +#[inline] +pub fn epoll_create1(flags: EpollCreateFlags) -> Result { + let res = unsafe { libc::epoll_create1(flags.bits()) }; + + Errno::result(res) +} + +#[inline] +pub fn epoll_ctl<'a, T>(epfd: RawFd, op: EpollOp, fd: RawFd, event: T) -> Result<()> + where T: Into> +{ + let mut event: Option<&mut EpollEvent> = event.into(); + if event.is_none() && op != EpollOp::EpollCtlDel { + Err(Error::Sys(Errno::EINVAL)) + } else { + let res = unsafe { + if let Some(ref mut event) = event { + libc::epoll_ctl(epfd, op as c_int, fd, &mut event.event) + } else { + libc::epoll_ctl(epfd, op as c_int, fd, ptr::null_mut()) + } + }; + Errno::result(res).map(drop) + } +} + +#[inline] +pub fn epoll_wait(epfd: RawFd, events: &mut [EpollEvent], timeout_ms: isize) -> Result { + let res = unsafe { + libc::epoll_wait(epfd, events.as_mut_ptr() as *mut libc::epoll_event, events.len() as c_int, timeout_ms as c_int) + }; + + Errno::result(res).map(|r| r as usize) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/event.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/event.rs new file mode 100644 index 0000000..f1eaa0d --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/event.rs @@ -0,0 +1,352 @@ +/* TOOD: Implement for other kqueue based systems + */ + +use {Errno, Result}; +#[cfg(not(target_os = "netbsd"))] +use libc::{timespec, time_t, c_int, c_long, intptr_t, uintptr_t}; +#[cfg(target_os = "netbsd")] +use libc::{timespec, time_t, c_long, intptr_t, uintptr_t, size_t}; +use libc; +use std::os::unix::io::RawFd; +use std::ptr; +use std::mem; + +// Redefine kevent in terms of programmer-friendly enums and bitfields. +#[derive(Clone, Copy)] +#[repr(C)] +#[allow(missing_debug_implementations)] +pub struct KEvent { + kevent: libc::kevent, +} + +#[cfg(any(target_os = "dragonfly", target_os = "freebsd", + target_os = "ios", target_os = "macos", + target_os = "openbsd"))] +type type_of_udata = *mut libc::c_void; +#[cfg(any(target_os = "dragonfly", target_os = "freebsd", + target_os = "ios", target_os = "macos"))] +type type_of_data = intptr_t; +#[cfg(any(target_os = "netbsd"))] +type type_of_udata = intptr_t; +#[cfg(any(target_os = "netbsd", target_os = "openbsd"))] +type type_of_data = libc::int64_t; + +#[cfg(target_os = "netbsd")] +type type_of_event_filter = u32; +#[cfg(not(target_os = "netbsd"))] +type type_of_event_filter = i16; +libc_enum! { + #[cfg_attr(target_os = "netbsd", repr(u32))] + #[cfg_attr(not(target_os = "netbsd"), repr(i16))] + pub enum EventFilter { + EVFILT_AIO, + /// Returns whenever there is no remaining data in the write buffer + #[cfg(target_os = "freebsd")] + EVFILT_EMPTY, + #[cfg(target_os = "dragonfly")] + EVFILT_EXCEPT, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos"))] + EVFILT_FS, + #[cfg(target_os = "freebsd")] + EVFILT_LIO, + #[cfg(any(target_os = "ios", target_os = "macos"))] + EVFILT_MACHPORT, + EVFILT_PROC, + /// Returns events associated with the process referenced by a given + /// process descriptor, created by `pdfork()`. The events to monitor are: + /// + /// - NOTE_EXIT: the process has exited. The exit status will be stored in data. + #[cfg(target_os = "freebsd")] + EVFILT_PROCDESC, + EVFILT_READ, + /// Returns whenever an asynchronous `sendfile()` call completes. + #[cfg(target_os = "freebsd")] + EVFILT_SENDFILE, + EVFILT_SIGNAL, + EVFILT_TIMER, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos"))] + EVFILT_USER, + #[cfg(any(target_os = "ios", target_os = "macos"))] + EVFILT_VM, + EVFILT_VNODE, + EVFILT_WRITE, + } +} + +#[cfg(any(target_os = "dragonfly", target_os = "freebsd", + target_os = "ios", target_os = "macos", + target_os = "openbsd"))] +pub type type_of_event_flag = u16; +#[cfg(any(target_os = "netbsd"))] +pub type type_of_event_flag = u32; +libc_bitflags!{ + pub struct EventFlag: type_of_event_flag { + EV_ADD; + EV_CLEAR; + EV_DELETE; + EV_DISABLE; + // No released version of OpenBSD supports EV_DISPATCH or EV_RECEIPT. + // These have been commited to the -current branch though and are + // expected to be part of the OpenBSD 6.2 release in Nov 2017. + // See: https://marc.info/?l=openbsd-tech&m=149621427511219&w=2 + // https://github.com/rust-lang/libc/pull/613 + #[cfg(any(target_os = "dragonfly", target_os = "freebsd", + target_os = "ios", target_os = "macos", + target_os = "netbsd"))] + EV_DISPATCH; + #[cfg(target_os = "freebsd")] + EV_DROP; + EV_ENABLE; + EV_EOF; + EV_ERROR; + #[cfg(any(target_os = "macos", target_os = "ios"))] + EV_FLAG0; + EV_FLAG1; + #[cfg(target_os = "dragonfly")] + EV_NODATA; + EV_ONESHOT; + #[cfg(any(target_os = "macos", target_os = "ios"))] + EV_OOBAND; + #[cfg(any(target_os = "macos", target_os = "ios"))] + EV_POLL; + #[cfg(any(target_os = "dragonfly", target_os = "freebsd", + target_os = "ios", target_os = "macos", + target_os = "netbsd"))] + EV_RECEIPT; + EV_SYSFLAGS; + } +} + +libc_bitflags!( + pub struct FilterFlag: u32 { + #[cfg(any(target_os = "macos", target_os = "ios"))] + NOTE_ABSOLUTE; + NOTE_ATTRIB; + NOTE_CHILD; + NOTE_DELETE; + #[cfg(target_os = "openbsd")] + NOTE_EOF; + NOTE_EXEC; + NOTE_EXIT; + #[cfg(any(target_os = "macos", target_os = "ios"))] + #[deprecated( since="0.14.0", note="Deprecated since OSX 10.9")] + #[allow(deprecated)] + NOTE_EXIT_REPARENTED; + #[cfg(any(target_os = "macos", target_os = "ios"))] + NOTE_EXITSTATUS; + NOTE_EXTEND; + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] + NOTE_FFAND; + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] + NOTE_FFCOPY; + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] + NOTE_FFCTRLMASK; + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] + NOTE_FFLAGSMASK; + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] + NOTE_FFNOP; + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] + NOTE_FFOR; + NOTE_FORK; + NOTE_LINK; + NOTE_LOWAT; + #[cfg(target_os = "freebsd")] + NOTE_MSECONDS; + #[cfg(any(target_os = "macos", target_os = "ios"))] + NOTE_NONE; + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))] + NOTE_NSECONDS; + #[cfg(target_os = "dragonfly")] + NOTE_OOB; + NOTE_PCTRLMASK; + NOTE_PDATAMASK; + #[cfg(any(target_os = "macos", target_os = "ios"))] + #[cfg(any(target_os = "macos", target_os = "ios"))] + #[deprecated( since="0.14.0", note="Deprecated since OSX 10.9")] + #[allow(deprecated)] + NOTE_REAP; + NOTE_RENAME; + NOTE_REVOKE; + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))] + NOTE_SECONDS; + #[cfg(any(target_os = "macos", target_os = "ios"))] + NOTE_SIGNAL; + NOTE_TRACK; + NOTE_TRACKERR; + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly"))] + NOTE_TRIGGER; + #[cfg(target_os = "openbsd")] + NOTE_TRUNCATE; + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))] + NOTE_USECONDS; + #[cfg(any(target_os = "macos", target_os = "ios"))] + NOTE_VM_ERROR; + #[cfg(any(target_os = "macos", target_os = "ios"))] + NOTE_VM_PRESSURE; + #[cfg(any(target_os = "macos", target_os = "ios"))] + NOTE_VM_PRESSURE_SUDDEN_TERMINATE; + #[cfg(any(target_os = "macos", target_os = "ios"))] + NOTE_VM_PRESSURE_TERMINATE; + NOTE_WRITE; + } +); + +pub fn kqueue() -> Result { + let res = unsafe { libc::kqueue() }; + + Errno::result(res) +} + + +// KEvent can't derive Send because on some operating systems, udata is defined +// as a void*. However, KEvent's public API always treats udata as an intptr_t, +// which is safe to Send. +unsafe impl Send for KEvent { +} + +impl KEvent { + pub fn new(ident: uintptr_t, filter: EventFilter, flags: EventFlag, + fflags:FilterFlag, data: intptr_t, udata: intptr_t) -> KEvent { + KEvent { kevent: libc::kevent { + ident: ident, + filter: filter as type_of_event_filter, + flags: flags.bits(), + fflags: fflags.bits(), + data: data as type_of_data, + udata: udata as type_of_udata + } } + } + + pub fn ident(&self) -> uintptr_t { + self.kevent.ident + } + + pub fn filter(&self) -> EventFilter { + unsafe { mem::transmute(self.kevent.filter as type_of_event_filter) } + } + + pub fn flags(&self) -> EventFlag { + EventFlag::from_bits(self.kevent.flags).unwrap() + } + + pub fn fflags(&self) -> FilterFlag { + FilterFlag::from_bits(self.kevent.fflags).unwrap() + } + + pub fn data(&self) -> intptr_t { + self.kevent.data as intptr_t + } + + pub fn udata(&self) -> intptr_t { + self.kevent.udata as intptr_t + } +} + +pub fn kevent(kq: RawFd, + changelist: &[KEvent], + eventlist: &mut [KEvent], + timeout_ms: usize) -> Result { + + // Convert ms to timespec + let timeout = timespec { + tv_sec: (timeout_ms / 1000) as time_t, + tv_nsec: ((timeout_ms % 1000) * 1_000_000) as c_long + }; + + kevent_ts(kq, changelist, eventlist, Some(timeout)) +} + +#[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd"))] +type type_of_nchanges = c_int; +#[cfg(target_os = "netbsd")] +type type_of_nchanges = size_t; + +pub fn kevent_ts(kq: RawFd, + changelist: &[KEvent], + eventlist: &mut [KEvent], + timeout_opt: Option) -> Result { + + let res = unsafe { + libc::kevent( + kq, + changelist.as_ptr() as *const libc::kevent, + changelist.len() as type_of_nchanges, + eventlist.as_mut_ptr() as *mut libc::kevent, + eventlist.len() as type_of_nchanges, + if let Some(ref timeout) = timeout_opt {timeout as *const timespec} else {ptr::null()}) + }; + + Errno::result(res).map(|r| r as usize) +} + +#[inline] +pub fn ev_set(ev: &mut KEvent, + ident: usize, + filter: EventFilter, + flags: EventFlag, + fflags: FilterFlag, + udata: intptr_t) { + + ev.kevent.ident = ident as uintptr_t; + ev.kevent.filter = filter as type_of_event_filter; + ev.kevent.flags = flags.bits(); + ev.kevent.fflags = fflags.bits(); + ev.kevent.data = 0; + ev.kevent.udata = udata as type_of_udata; +} + +#[test] +fn test_struct_kevent() { + let udata : intptr_t = 12345; + + let expected = libc::kevent{ident: 0xdead_beef, + filter: libc::EVFILT_READ, + flags: libc::EV_ONESHOT | libc::EV_ADD, + fflags: libc::NOTE_CHILD | libc::NOTE_EXIT, + data: 0x1337, + udata: udata as type_of_udata}; + let actual = KEvent::new(0xdead_beef, + EventFilter::EVFILT_READ, + EventFlag::EV_ONESHOT | EventFlag::EV_ADD, + FilterFlag::NOTE_CHILD | FilterFlag::NOTE_EXIT, + 0x1337, + udata); + assert!(expected.ident == actual.ident()); + assert!(expected.filter == actual.filter() as type_of_event_filter); + assert!(expected.flags == actual.flags().bits()); + assert!(expected.fflags == actual.fflags().bits()); + assert!(expected.data == actual.data() as type_of_data); + assert!(expected.udata == actual.udata() as type_of_udata); + assert!(mem::size_of::() == mem::size_of::()); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/eventfd.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/eventfd.rs new file mode 100644 index 0000000..c5a54e4 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/eventfd.rs @@ -0,0 +1,18 @@ +use libc; +use std::os::unix::io::RawFd; +use Result; +use errno::Errno; + +libc_bitflags! { + pub struct EfdFlags: libc::c_int { + EFD_CLOEXEC; // Since Linux 2.6.27 + EFD_NONBLOCK; // Since Linux 2.6.27 + EFD_SEMAPHORE; // Since Linux 2.6.30 + } +} + +pub fn eventfd(initval: libc::c_uint, flags: EfdFlags) -> Result { + let res = unsafe { libc::eventfd(initval, flags.bits()) }; + + Errno::result(res).map(|r| r as RawFd) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/inotify.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/inotify.rs new file mode 100644 index 0000000..e6c2cf6 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/inotify.rs @@ -0,0 +1,230 @@ +//! Monitoring API for filesystem events. +//! +//! Inotify is a Linux-only API to monitor filesystems events. +//! +//! For more documentation, please read [inotify(7)](http://man7.org/linux/man-pages/man7/inotify.7.html). +//! +//! # Examples +//! +//! Monitor all events happening in directory "test": +//! ```no_run +//! # use nix::sys::inotify::{AddWatchFlags,InitFlags,Inotify}; +//! # +//! // We create a new inotify instance. +//! let instance = Inotify::init(InitFlags::empty()).unwrap(); +//! +//! // We add a new watch on directory "test" for all events. +//! let wd = instance.add_watch("test", AddWatchFlags::IN_ALL_EVENTS).unwrap(); +//! +//! loop { +//! // We read from our inotify instance for events. +//! let events = instance.read_events().unwrap(); +//! println!("Events: {:?}", events); +//! } +//! ``` + +use libc; +use libc::{ + c_char, + c_int, +}; +use std::ffi::{OsString,OsStr,CStr}; +use std::os::unix::ffi::OsStrExt; +use std::mem::size_of; +use std::os::unix::io::{RawFd,AsRawFd,FromRawFd}; +use unistd::read; +use Result; +use NixPath; +use errno::Errno; + +libc_bitflags! { + /// Configuration options for [`inotify_add_watch`](fn.inotify_add_watch.html). + pub struct AddWatchFlags: u32 { + IN_ACCESS; + IN_MODIFY; + IN_ATTRIB; + IN_CLOSE_WRITE; + IN_CLOSE_NOWRITE; + IN_OPEN; + IN_MOVED_FROM; + IN_MOVED_TO; + IN_CREATE; + IN_DELETE; + IN_DELETE_SELF; + IN_MOVE_SELF; + + IN_UNMOUNT; + IN_Q_OVERFLOW; + IN_IGNORED; + + IN_CLOSE; + IN_MOVE; + + IN_ONLYDIR; + IN_DONT_FOLLOW; + + IN_ISDIR; + IN_ONESHOT; + IN_ALL_EVENTS; + } +} + +libc_bitflags! { + /// Configuration options for [`inotify_init1`](fn.inotify_init1.html). + pub struct InitFlags: c_int { + IN_CLOEXEC; + IN_NONBLOCK; + } +} + +/// An inotify instance. This is also a file descriptor, you can feed it to +/// other interfaces consuming file descriptors, epoll for example. +#[derive(Debug, Clone, Copy)] +pub struct Inotify { + fd: RawFd +} + +/// This object is returned when you create a new watch on an inotify instance. +/// It is then returned as part of an event once triggered. It allows you to +/// know which watch triggered which event. +#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq, Ord, PartialOrd)] +pub struct WatchDescriptor { + wd: i32 +} + +/// A single inotify event. +/// +/// For more documentation see, [inotify(7)](http://man7.org/linux/man-pages/man7/inotify.7.html). +#[derive(Debug)] +pub struct InotifyEvent { + /// Watch descriptor. This field corresponds to the watch descriptor you + /// were issued when calling add_watch. It allows you to know which watch + /// this event comes from. + pub wd: WatchDescriptor, + /// Event mask. This field is a bitfield describing the exact event that + /// occured. + pub mask: AddWatchFlags, + /// This cookie is a number that allows you to connect related events. For + /// now only IN_MOVED_FROM and IN_MOVED_TO can be connected. + pub cookie: u32, + /// Filename. This field exists only if the event was triggered for a file + /// inside the watched directory. + pub name: Option +} + +impl Inotify { + /// Initialize a new inotify instance. + /// + /// Returns a Result containing an inotify instance. + /// + /// For more information see, [inotify_init(2)](http://man7.org/linux/man-pages/man2/inotify_init.2.html). + pub fn init(flags: InitFlags) -> Result { + let res = Errno::result(unsafe { + libc::inotify_init1(flags.bits()) + }); + + res.map(|fd| Inotify { fd }) + } + + /// Adds a new watch on the target file or directory. + /// + /// Returns a watch descriptor. This is not a File Descriptor! + /// + /// For more information see, [inotify_add_watch(2)](http://man7.org/linux/man-pages/man2/inotify_add_watch.2.html). + pub fn add_watch(&self, + path: &P, + mask: AddWatchFlags) + -> Result + { + let res = path.with_nix_path(|cstr| { + unsafe { + libc::inotify_add_watch(self.fd, cstr.as_ptr(), mask.bits()) + } + })?; + + Errno::result(res).map(|wd| WatchDescriptor { wd }) + } + + /// Removes an existing watch using the watch descriptor returned by + /// inotify_add_watch. + /// + /// Returns an EINVAL error if the watch descriptor is invalid. + /// + /// For more information see, [inotify_rm_watch(2)](http://man7.org/linux/man-pages/man2/inotify_rm_watch.2.html). + #[cfg(target_os = "linux")] + pub fn rm_watch(&self, wd: WatchDescriptor) -> Result<()> { + let res = unsafe { libc::inotify_rm_watch(self.fd, wd.wd) }; + + Errno::result(res).map(drop) + } + + #[cfg(target_os = "android")] + pub fn rm_watch(&self, wd: WatchDescriptor) -> Result<()> { + let res = unsafe { libc::inotify_rm_watch(self.fd, wd.wd as u32) }; + + Errno::result(res).map(drop) + } + + /// Reads a collection of events from the inotify file descriptor. This call + /// can either be blocking or non blocking depending on whether IN_NONBLOCK + /// was set at initialization. + /// + /// Returns as many events as available. If the call was non blocking and no + /// events could be read then the EAGAIN error is returned. + pub fn read_events(&self) -> Result> { + let header_size = size_of::(); + let mut buffer = [0u8; 4096]; + let mut events = Vec::new(); + let mut offset = 0; + + let nread = read(self.fd, &mut buffer)?; + + while (nread - offset) >= header_size { + let event = unsafe { + &*( + buffer + .as_ptr() + .offset(offset as isize) as *const libc::inotify_event + ) + }; + + let name = match event.len { + 0 => None, + _ => { + let ptr = unsafe { + buffer + .as_ptr() + .offset(offset as isize + header_size as isize) + as *const c_char + }; + let cstr = unsafe { CStr::from_ptr(ptr) }; + + Some(OsStr::from_bytes(cstr.to_bytes()).to_owned()) + } + }; + + events.push(InotifyEvent { + wd: WatchDescriptor { wd: event.wd }, + mask: AddWatchFlags::from_bits_truncate(event.mask), + cookie: event.cookie, + name + }); + + offset += header_size + event.len as usize; + } + + Ok(events) + } +} + +impl AsRawFd for Inotify { + fn as_raw_fd(&self) -> RawFd { + self.fd + } +} + +impl FromRawFd for Inotify { + unsafe fn from_raw_fd(fd: RawFd) -> Self { + Inotify { fd } + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/ioctl/bsd.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/ioctl/bsd.rs new file mode 100644 index 0000000..9b8b0ff --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/ioctl/bsd.rs @@ -0,0 +1,102 @@ +/// The datatype used for the ioctl number +#[doc(hidden)] +pub type ioctl_num_type = ::libc::c_ulong; +/// The datatype used for the 3rd argument +#[doc(hidden)] +pub type ioctl_param_type = ::libc::c_int; + +mod consts { + use ::sys::ioctl::ioctl_num_type; + #[doc(hidden)] + pub const VOID: ioctl_num_type = 0x2000_0000; + #[doc(hidden)] + pub const OUT: ioctl_num_type = 0x4000_0000; + #[doc(hidden)] + pub const IN: ioctl_num_type = 0x8000_0000; + #[doc(hidden)] + pub const INOUT: ioctl_num_type = (IN|OUT); + #[doc(hidden)] + pub const IOCPARM_MASK: ioctl_num_type = 0x1fff; +} + +pub use self::consts::*; + +#[macro_export] +#[doc(hidden)] +macro_rules! ioc { + ($inout:expr, $group:expr, $num:expr, $len:expr) => ( + $inout | (($len as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::IOCPARM_MASK) << 16) | (($group as $crate::sys::ioctl::ioctl_num_type) << 8) | ($num as $crate::sys::ioctl::ioctl_num_type) + ) +} + +/// Generate an ioctl request code for a command that passes no data. +/// +/// This is equivalent to the `_IO()` macro exposed by the C ioctl API. +/// +/// You should only use this macro directly if the `ioctl` you're working +/// with is "bad" and you cannot use `ioctl_none!()` directly. +/// +/// # Example +/// +/// ``` +/// # #[macro_use] extern crate nix; +/// const KVMIO: u8 = 0xAE; +/// ioctl_write_int_bad!(kvm_create_vm, request_code_none!(KVMIO, 0x03)); +/// # fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! request_code_none { + ($g:expr, $n:expr) => (ioc!($crate::sys::ioctl::VOID, $g, $n, 0)) +} + +/// Generate an ioctl request code for a command that passes an integer +/// +/// This is equivalent to the `_IOWINT()` macro exposed by the C ioctl API. +/// +/// You should only use this macro directly if the `ioctl` you're working +/// with is "bad" and you cannot use `ioctl_write_int!()` directly. +#[macro_export(local_inner_macros)] +macro_rules! request_code_write_int { + ($g:expr, $n:expr) => (ioc!($crate::sys::ioctl::VOID, $g, $n, ::std::mem::size_of::<$crate::libc::c_int>())) +} + +/// Generate an ioctl request code for a command that reads. +/// +/// This is equivalent to the `_IOR()` macro exposed by the C ioctl API. +/// +/// You should only use this macro directly if the `ioctl` you're working +/// with is "bad" and you cannot use `ioctl_read!()` directly. +/// +/// The read/write direction is relative to userland, so this +/// command would be userland is reading and the kernel is +/// writing. +#[macro_export(local_inner_macros)] +macro_rules! request_code_read { + ($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::OUT, $g, $n, $len)) +} + +/// Generate an ioctl request code for a command that writes. +/// +/// This is equivalent to the `_IOW()` macro exposed by the C ioctl API. +/// +/// You should only use this macro directly if the `ioctl` you're working +/// with is "bad" and you cannot use `ioctl_write!()` directly. +/// +/// The read/write direction is relative to userland, so this +/// command would be userland is writing and the kernel is +/// reading. +#[macro_export(local_inner_macros)] +macro_rules! request_code_write { + ($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::IN, $g, $n, $len)) +} + +/// Generate an ioctl request code for a command that reads and writes. +/// +/// This is equivalent to the `_IOWR()` macro exposed by the C ioctl API. +/// +/// You should only use this macro directly if the `ioctl` you're working +/// with is "bad" and you cannot use `ioctl_readwrite!()` directly. +#[macro_export(local_inner_macros)] +macro_rules! request_code_readwrite { + ($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::INOUT, $g, $n, $len)) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/ioctl/linux.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/ioctl/linux.rs new file mode 100644 index 0000000..9cdac72 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/ioctl/linux.rs @@ -0,0 +1,140 @@ +/// The datatype used for the ioctl number +#[cfg(any(target_os = "android", target_env = "musl"))] +#[doc(hidden)] +pub type ioctl_num_type = ::libc::c_int; +#[cfg(not(any(target_os = "android", target_env = "musl")))] +#[doc(hidden)] +pub type ioctl_num_type = ::libc::c_ulong; +/// The datatype used for the 3rd argument +#[doc(hidden)] +pub type ioctl_param_type = ::libc::c_ulong; + +#[doc(hidden)] +pub const NRBITS: ioctl_num_type = 8; +#[doc(hidden)] +pub const TYPEBITS: ioctl_num_type = 8; + +#[cfg(any(target_arch = "mips", target_arch = "mips64", target_arch = "powerpc", target_arch = "powerpc64", target_arch = "sparc64"))] +mod consts { + #[doc(hidden)] + pub const NONE: u8 = 1; + #[doc(hidden)] + pub const READ: u8 = 2; + #[doc(hidden)] + pub const WRITE: u8 = 4; + #[doc(hidden)] + pub const SIZEBITS: u8 = 13; + #[doc(hidden)] + pub const DIRBITS: u8 = 3; +} + +// "Generic" ioctl protocol +#[cfg(any(target_arch = "x86", + target_arch = "arm", + target_arch = "s390x", + target_arch = "x86_64", + target_arch = "aarch64"))] +mod consts { + #[doc(hidden)] + pub const NONE: u8 = 0; + #[doc(hidden)] + pub const READ: u8 = 2; + #[doc(hidden)] + pub const WRITE: u8 = 1; + #[doc(hidden)] + pub const SIZEBITS: u8 = 14; + #[doc(hidden)] + pub const DIRBITS: u8 = 2; +} + +pub use self::consts::*; + +#[doc(hidden)] +pub const NRSHIFT: ioctl_num_type = 0; +#[doc(hidden)] +pub const TYPESHIFT: ioctl_num_type = NRSHIFT + NRBITS as ioctl_num_type; +#[doc(hidden)] +pub const SIZESHIFT: ioctl_num_type = TYPESHIFT + TYPEBITS as ioctl_num_type; +#[doc(hidden)] +pub const DIRSHIFT: ioctl_num_type = SIZESHIFT + SIZEBITS as ioctl_num_type; + +#[doc(hidden)] +pub const NRMASK: ioctl_num_type = (1 << NRBITS) - 1; +#[doc(hidden)] +pub const TYPEMASK: ioctl_num_type = (1 << TYPEBITS) - 1; +#[doc(hidden)] +pub const SIZEMASK: ioctl_num_type = (1 << SIZEBITS) - 1; +#[doc(hidden)] +pub const DIRMASK: ioctl_num_type = (1 << DIRBITS) - 1; + +/// Encode an ioctl command. +#[macro_export] +#[doc(hidden)] +macro_rules! ioc { + ($dir:expr, $ty:expr, $nr:expr, $sz:expr) => ( + (($dir as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::DIRMASK) << $crate::sys::ioctl::DIRSHIFT) | + (($ty as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::TYPEMASK) << $crate::sys::ioctl::TYPESHIFT) | + (($nr as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::NRMASK) << $crate::sys::ioctl::NRSHIFT) | + (($sz as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::SIZEMASK) << $crate::sys::ioctl::SIZESHIFT)) +} + +/// Generate an ioctl request code for a command that passes no data. +/// +/// This is equivalent to the `_IO()` macro exposed by the C ioctl API. +/// +/// You should only use this macro directly if the `ioctl` you're working +/// with is "bad" and you cannot use `ioctl_none!()` directly. +/// +/// # Example +/// +/// ``` +/// # #[macro_use] extern crate nix; +/// const KVMIO: u8 = 0xAE; +/// ioctl_write_int_bad!(kvm_create_vm, request_code_none!(KVMIO, 0x03)); +/// # fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! request_code_none { + ($ty:expr, $nr:expr) => (ioc!($crate::sys::ioctl::NONE, $ty, $nr, 0)) +} + +/// Generate an ioctl request code for a command that reads. +/// +/// This is equivalent to the `_IOR()` macro exposed by the C ioctl API. +/// +/// You should only use this macro directly if the `ioctl` you're working +/// with is "bad" and you cannot use `ioctl_read!()` directly. +/// +/// The read/write direction is relative to userland, so this +/// command would be userland is reading and the kernel is +/// writing. +#[macro_export(local_inner_macros)] +macro_rules! request_code_read { + ($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::READ, $ty, $nr, $sz)) +} + +/// Generate an ioctl request code for a command that writes. +/// +/// This is equivalent to the `_IOW()` macro exposed by the C ioctl API. +/// +/// You should only use this macro directly if the `ioctl` you're working +/// with is "bad" and you cannot use `ioctl_write!()` directly. +/// +/// The read/write direction is relative to userland, so this +/// command would be userland is writing and the kernel is +/// reading. +#[macro_export(local_inner_macros)] +macro_rules! request_code_write { + ($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::WRITE, $ty, $nr, $sz)) +} + +/// Generate an ioctl request code for a command that reads and writes. +/// +/// This is equivalent to the `_IOWR()` macro exposed by the C ioctl API. +/// +/// You should only use this macro directly if the `ioctl` you're working +/// with is "bad" and you cannot use `ioctl_readwrite!()` directly. +#[macro_export(local_inner_macros)] +macro_rules! request_code_readwrite { + ($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::READ | $crate::sys::ioctl::WRITE, $ty, $nr, $sz)) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/ioctl/mod.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/ioctl/mod.rs new file mode 100644 index 0000000..4513bf8 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/ioctl/mod.rs @@ -0,0 +1,778 @@ +//! Provide helpers for making ioctl system calls. +//! +//! This library is pretty low-level and messy. `ioctl` is not fun. +//! +//! What is an `ioctl`? +//! =================== +//! +//! The `ioctl` syscall is the grab-bag syscall on POSIX systems. Don't want to add a new +//! syscall? Make it an `ioctl`! `ioctl` refers to both the syscall, and the commands that can be +//! sent with it. `ioctl` stands for "IO control", and the commands are always sent to a file +//! descriptor. +//! +//! It is common to see `ioctl`s used for the following purposes: +//! +//! * Provide read/write access to out-of-band data related to a device such as configuration +//! (for instance, setting serial port options) +//! * Provide a mechanism for performing full-duplex data transfers (for instance, xfer on SPI +//! devices). +//! * Provide access to control functions on a device (for example, on Linux you can send +//! commands like pause, resume, and eject to the CDROM device. +//! * Do whatever else the device driver creator thought made most sense. +//! +//! `ioctl`s are synchronous system calls and are similar to read and write calls in that regard. +//! They operate on file descriptors and have an identifier that specifies what the ioctl is. +//! Additionally they may read or write data and therefore need to pass along a data pointer. +//! Besides the semantics of the ioctls being confusing, the generation of this identifer can also +//! be difficult. +//! +//! Historically `ioctl` numbers were arbitrary hard-coded values. In Linux (before 2.6) and some +//! unices this has changed to a more-ordered system where the ioctl numbers are partitioned into +//! subcomponents (For linux this is documented in +//! [`Documentation/ioctl/ioctl-number.txt`](http://elixir.free-electrons.com/linux/latest/source/Documentation/ioctl/ioctl-number.txt)): +//! +//! * Number: The actual ioctl ID +//! * Type: A grouping of ioctls for a common purpose or driver +//! * Size: The size in bytes of the data that will be transferred +//! * Direction: Whether there is any data and if it's read, write, or both +//! +//! Newer drivers should not generate complete integer identifiers for their `ioctl`s instead +//! preferring to use the 4 components above to generate the final ioctl identifier. Because of +//! how old `ioctl`s are, however, there are many hard-coded `ioctl` identifiers. These are +//! commonly referred to as "bad" in `ioctl` documentation. +//! +//! Defining `ioctl`s +//! ================= +//! +//! This library provides several `ioctl_*!` macros for binding `ioctl`s. These generate public +//! unsafe functions that can then be used for calling the ioctl. This macro has a few different +//! ways it can be used depending on the specific ioctl you're working with. +//! +//! A simple `ioctl` is `SPI_IOC_RD_MODE`. This ioctl works with the SPI interface on Linux. This +//! specific `ioctl` reads the mode of the SPI device as a `u8`. It's declared in +//! `/include/uapi/linux/spi/spidev.h` as `_IOR(SPI_IOC_MAGIC, 1, __u8)`. Since it uses the `_IOR` +//! macro, we know it's a `read` ioctl and can use the `ioctl_read!` macro as follows: +//! +//! ``` +//! # #[macro_use] extern crate nix; +//! const SPI_IOC_MAGIC: u8 = b'k'; // Defined in linux/spi/spidev.h +//! const SPI_IOC_TYPE_MODE: u8 = 1; +//! ioctl_read!(spi_read_mode, SPI_IOC_MAGIC, SPI_IOC_TYPE_MODE, u8); +//! # fn main() {} +//! ``` +//! +//! This generates the function: +//! +//! ``` +//! # #[macro_use] extern crate nix; +//! # use std::mem; +//! # use nix::{libc, Result}; +//! # use nix::errno::Errno; +//! # use nix::libc::c_int as c_int; +//! # const SPI_IOC_MAGIC: u8 = b'k'; // Defined in linux/spi/spidev.h +//! # const SPI_IOC_TYPE_MODE: u8 = 1; +//! pub unsafe fn spi_read_mode(fd: c_int, data: *mut u8) -> Result { +//! let res = libc::ioctl(fd, request_code_read!(SPI_IOC_MAGIC, SPI_IOC_TYPE_MODE, mem::size_of::()), data); +//! Errno::result(res) +//! } +//! # fn main() {} +//! ``` +//! +//! The return value for the wrapper functions generated by the `ioctl_*!` macros are `nix::Error`s. +//! These are generated by assuming the return value of the ioctl is `-1` on error and everything +//! else is a valid return value. If this is not the case, `Result::map` can be used to map some +//! of the range of "good" values (-Inf..-2, 0..Inf) into a smaller range in a helper function. +//! +//! Writing `ioctl`s generally use pointers as their data source and these should use the +//! `ioctl_write_ptr!`. But in some cases an `int` is passed directly. For these `ioctl`s use the +//! `ioctl_write_int!` macro. This variant does not take a type as the last argument: +//! +//! ``` +//! # #[macro_use] extern crate nix; +//! const HCI_IOC_MAGIC: u8 = b'k'; +//! const HCI_IOC_HCIDEVUP: u8 = 1; +//! ioctl_write_int!(hci_dev_up, HCI_IOC_MAGIC, HCI_IOC_HCIDEVUP); +//! # fn main() {} +//! ``` +//! +//! Some `ioctl`s don't transfer any data, and those should use `ioctl_none!`. This macro +//! doesn't take a type and so it is declared similar to the `write_int` variant shown above. +//! +//! The mode for a given `ioctl` should be clear from the documentation if it has good +//! documentation. Otherwise it will be clear based on the macro used to generate the `ioctl` +//! number where `_IO`, `_IOR`, `_IOW`, and `_IOWR` map to "none", "read", "write_*", and "readwrite" +//! respectively. To determine the specific `write_` variant to use you'll need to find +//! what the argument type is supposed to be. If it's an `int`, then `write_int` should be used, +//! otherwise it should be a pointer and `write_ptr` should be used. On Linux the +//! [`ioctl_list` man page](http://man7.org/linux/man-pages/man2/ioctl_list.2.html) describes a +//! large number of `ioctl`s and describes their argument data type. +//! +//! Using "bad" `ioctl`s +//! -------------------- +//! +//! As mentioned earlier, there are many old `ioctl`s that do not use the newer method of +//! generating `ioctl` numbers and instead use hardcoded values. These can be used with the +//! `ioctl_*_bad!` macros. This naming comes from the Linux kernel which refers to these +//! `ioctl`s as "bad". These are a different variant as they bypass calling the macro that generates +//! the ioctl number and instead use the defined value directly. +//! +//! For example the `TCGETS` `ioctl` reads a `termios` data structure for a given file descriptor. +//! It's defined as `0x5401` in `ioctls.h` on Linux and can be implemented as: +//! +//! ``` +//! # #[macro_use] extern crate nix; +//! # #[cfg(any(target_os = "android", target_os = "linux"))] +//! # use nix::libc::TCGETS as TCGETS; +//! # #[cfg(any(target_os = "android", target_os = "linux"))] +//! # use nix::libc::termios as termios; +//! # #[cfg(any(target_os = "android", target_os = "linux"))] +//! ioctl_read_bad!(tcgets, TCGETS, termios); +//! # fn main() {} +//! ``` +//! +//! The generated function has the same form as that generated by `ioctl_read!`: +//! +//! ```text +//! pub unsafe fn tcgets(fd: c_int, data: *mut termios) -> Result; +//! ``` +//! +//! Working with Arrays +//! ------------------- +//! +//! Some `ioctl`s work with entire arrays of elements. These are supported by the `ioctl_*_buf` +//! family of macros: `ioctl_read_buf`, `ioctl_write_buf`, and `ioctl_readwrite_buf`. Note that +//! there are no "bad" versions for working with buffers. The generated functions include a `len` +//! argument to specify the number of elements (where the type of each element is specified in the +//! macro). +//! +//! Again looking to the SPI `ioctl`s on Linux for an example, there is a `SPI_IOC_MESSAGE` `ioctl` +//! that queues up multiple SPI messages by writing an entire array of `spi_ioc_transfer` structs. +//! `linux/spi/spidev.h` defines a macro to calculate the `ioctl` number like: +//! +//! ```C +//! #define SPI_IOC_MAGIC 'k' +//! #define SPI_MSGSIZE(N) ... +//! #define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(N)]) +//! ``` +//! +//! The `SPI_MSGSIZE(N)` calculation is already handled by the `ioctl_*!` macros, so all that's +//! needed to define this `ioctl` is: +//! +//! ``` +//! # #[macro_use] extern crate nix; +//! const SPI_IOC_MAGIC: u8 = b'k'; // Defined in linux/spi/spidev.h +//! const SPI_IOC_TYPE_MESSAGE: u8 = 0; +//! # pub struct spi_ioc_transfer(u64); +//! ioctl_write_buf!(spi_transfer, SPI_IOC_MAGIC, SPI_IOC_TYPE_MESSAGE, spi_ioc_transfer); +//! # fn main() {} +//! ``` +//! +//! This generates a function like: +//! +//! ``` +//! # #[macro_use] extern crate nix; +//! # use std::mem; +//! # use nix::{libc, Result}; +//! # use nix::errno::Errno; +//! # use nix::libc::c_int as c_int; +//! # const SPI_IOC_MAGIC: u8 = b'k'; +//! # const SPI_IOC_TYPE_MESSAGE: u8 = 0; +//! # pub struct spi_ioc_transfer(u64); +//! pub unsafe fn spi_message(fd: c_int, data: &mut [spi_ioc_transfer]) -> Result { +//! let res = libc::ioctl(fd, +//! request_code_write!(SPI_IOC_MAGIC, SPI_IOC_TYPE_MESSAGE, data.len() * mem::size_of::()), +//! data); +//! Errno::result(res) +//! } +//! # fn main() {} +//! ``` +//! +//! Finding `ioctl` Documentation +//! ----------------------------- +//! +//! For Linux, look at your system's headers. For example, `/usr/include/linux/input.h` has a lot +//! of lines defining macros which use `_IO`, `_IOR`, `_IOW`, `_IOC`, and `_IOWR`. Some `ioctl`s are +//! documented directly in the headers defining their constants, but others have more extensive +//! documentation in man pages (like termios' `ioctl`s which are in `tty_ioctl(4)`). +//! +//! Documenting the Generated Functions +//! =================================== +//! +//! In many cases, users will wish for the functions generated by the `ioctl` +//! macro to be public and documented. For this reason, the generated functions +//! are public by default. If you wish to hide the ioctl, you will need to put +//! them in a private module. +//! +//! For documentation, it is possible to use doc comments inside the `ioctl_*!` macros. Here is an +//! example : +//! +//! ``` +//! # #[macro_use] extern crate nix; +//! # use nix::libc::c_int; +//! ioctl_read! { +//! /// Make the given terminal the controlling terminal of the calling process. The calling +//! /// process must be a session leader and not have a controlling terminal already. If the +//! /// terminal is already the controlling terminal of a different session group then the +//! /// ioctl will fail with **EPERM**, unless the caller is root (more precisely: has the +//! /// **CAP_SYS_ADMIN** capability) and arg equals 1, in which case the terminal is stolen +//! /// and all processes that had it as controlling terminal lose it. +//! tiocsctty, b't', 19, c_int +//! } +//! +//! # fn main() {} +//! ``` +#[cfg(any(target_os = "android", target_os = "linux"))] +#[macro_use] +mod linux; + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub use self::linux::*; + +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +#[macro_use] +mod bsd; + +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +pub use self::bsd::*; + +/// Convert raw ioctl return value to a Nix result +#[macro_export] +#[doc(hidden)] +macro_rules! convert_ioctl_res { + ($w:expr) => ( + { + $crate::errno::Errno::result($w) + } + ); +} + +/// Generates a wrapper function for an ioctl that passes no data to the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl identifier +/// * The ioctl sequence number +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +/// +/// # Example +/// +/// The `videodev2` driver on Linux defines the `log_status` `ioctl` as: +/// +/// ```C +/// #define VIDIOC_LOG_STATUS _IO('V', 70) +/// ``` +/// +/// This can be implemented in Rust like: +/// +/// ```no_run +/// # #[macro_use] extern crate nix; +/// ioctl_none!(log_status, b'V', 70); +/// fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! ioctl_none { + ($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, request_code_none!($ioty, $nr) as $crate::sys::ioctl::ioctl_num_type)) + } + ) +} + +/// Generates a wrapper function for a "bad" ioctl that passes no data to the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl request code +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +/// +/// # Example +/// +/// ```no_run +/// # #[macro_use] extern crate nix; +/// # extern crate libc; +/// # use libc::TIOCNXCL; +/// # use std::fs::File; +/// # use std::os::unix::io::AsRawFd; +/// ioctl_none_bad!(tiocnxcl, TIOCNXCL); +/// fn main() { +/// let file = File::open("/dev/ttyUSB0").unwrap(); +/// unsafe { tiocnxcl(file.as_raw_fd()) }.unwrap(); +/// } +/// ``` +// TODO: add an example using request_code_*!() +#[macro_export(local_inner_macros)] +macro_rules! ioctl_none_bad { + ($(#[$attr:meta])* $name:ident, $nr:expr) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, $nr as $crate::sys::ioctl::ioctl_num_type)) + } + ) +} + +/// Generates a wrapper function for an ioctl that reads data from the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl identifier +/// * The ioctl sequence number +/// * The data type passed by this ioctl +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: *mut DATA_TYPE) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +/// +/// # Example +/// +/// ``` +/// # #[macro_use] extern crate nix; +/// const SPI_IOC_MAGIC: u8 = b'k'; // Defined in linux/spi/spidev.h +/// const SPI_IOC_TYPE_MODE: u8 = 1; +/// ioctl_read!(spi_read_mode, SPI_IOC_MAGIC, SPI_IOC_TYPE_MODE, u8); +/// # fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! ioctl_read { + ($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: *mut $ty) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, request_code_read!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) +} + +/// Generates a wrapper function for a "bad" ioctl that reads data from the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl request code +/// * The data type passed by this ioctl +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: *mut DATA_TYPE) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +/// +/// # Example +/// +/// ``` +/// # extern crate libc; +/// # #[macro_use] extern crate nix; +/// # #[cfg(any(target_os = "android", target_os = "linux"))] +/// ioctl_read_bad!(tcgets, libc::TCGETS, libc::termios); +/// # fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! ioctl_read_bad { + ($(#[$attr:meta])* $name:ident, $nr:expr, $ty:ty) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: *mut $ty) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, $nr as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) +} + +/// Generates a wrapper function for an ioctl that writes data through a pointer to the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl identifier +/// * The ioctl sequence number +/// * The data type passed by this ioctl +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: *const DATA_TYPE) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +/// +/// # Example +/// +/// ``` +/// # #[macro_use] extern crate nix; +/// # pub struct v4l2_audio {} +/// ioctl_write_ptr!(s_audio, b'V', 34, v4l2_audio); +/// # fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! ioctl_write_ptr { + ($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: *const $ty) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, request_code_write!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) +} + +/// Generates a wrapper function for a "bad" ioctl that writes data through a pointer to the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl request code +/// * The data type passed by this ioctl +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: *const DATA_TYPE) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +/// +/// # Example +/// +/// ``` +/// # extern crate libc; +/// # #[macro_use] extern crate nix; +/// # #[cfg(any(target_os = "android", target_os = "linux"))] +/// ioctl_write_ptr_bad!(tcsets, libc::TCSETS, libc::termios); +/// # fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! ioctl_write_ptr_bad { + ($(#[$attr:meta])* $name:ident, $nr:expr, $ty:ty) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: *const $ty) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, $nr as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) +} + +cfg_if!{ + if #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] { + /// Generates a wrapper function for a ioctl that writes an integer to the kernel. + /// + /// The arguments to this macro are: + /// + /// * The function name + /// * The ioctl identifier + /// * The ioctl sequence number + /// + /// The generated function has the following signature: + /// + /// ```rust,ignore + /// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: nix::sys::ioctl::ioctl_param_type) -> Result + /// ``` + /// + /// `nix::sys::ioctl::ioctl_param_type` depends on the OS: + /// * BSD - `libc::c_int` + /// * Linux - `libc::c_ulong` + /// + /// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). + /// + /// # Example + /// + /// ``` + /// # #[macro_use] extern crate nix; + /// ioctl_write_int!(vt_activate, b'v', 4); + /// # fn main() {} + /// ``` + #[macro_export(local_inner_macros)] + macro_rules! ioctl_write_int { + ($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: $crate::sys::ioctl::ioctl_param_type) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, request_code_write_int!($ioty, $nr) as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) + } + } else { + /// Generates a wrapper function for a ioctl that writes an integer to the kernel. + /// + /// The arguments to this macro are: + /// + /// * The function name + /// * The ioctl identifier + /// * The ioctl sequence number + /// + /// The generated function has the following signature: + /// + /// ```rust,ignore + /// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: nix::sys::ioctl::ioctl_param_type) -> Result + /// ``` + /// + /// `nix::sys::ioctl::ioctl_param_type` depends on the OS: + /// * BSD - `libc::c_int` + /// * Linux - `libc::c_ulong` + /// + /// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). + /// + /// # Example + /// + /// ``` + /// # #[macro_use] extern crate nix; + /// const HCI_IOC_MAGIC: u8 = b'k'; + /// const HCI_IOC_HCIDEVUP: u8 = 1; + /// ioctl_write_int!(hci_dev_up, HCI_IOC_MAGIC, HCI_IOC_HCIDEVUP); + /// # fn main() {} + /// ``` + #[macro_export(local_inner_macros)] + macro_rules! ioctl_write_int { + ($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: $crate::sys::ioctl::ioctl_param_type) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, request_code_write!($ioty, $nr, ::std::mem::size_of::<$crate::libc::c_int>()) as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) + } + } +} + +/// Generates a wrapper function for a "bad" ioctl that writes an integer to the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl request code +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: libc::c_int) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +/// +/// # Examples +/// +/// ``` +/// # extern crate libc; +/// # #[macro_use] extern crate nix; +/// # #[cfg(any(target_os = "android", target_os = "linux"))] +/// ioctl_write_int_bad!(tcsbrk, libc::TCSBRK); +/// # fn main() {} +/// ``` +/// +/// ```rust +/// # #[macro_use] extern crate nix; +/// const KVMIO: u8 = 0xAE; +/// ioctl_write_int_bad!(kvm_create_vm, request_code_none!(KVMIO, 0x03)); +/// # fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! ioctl_write_int_bad { + ($(#[$attr:meta])* $name:ident, $nr:expr) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: $crate::libc::c_int) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, $nr as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) +} + +/// Generates a wrapper function for an ioctl that reads and writes data to the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl identifier +/// * The ioctl sequence number +/// * The data type passed by this ioctl +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: *mut DATA_TYPE) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +/// +/// # Example +/// +/// ``` +/// # #[macro_use] extern crate nix; +/// # pub struct v4l2_audio {} +/// ioctl_readwrite!(enum_audio, b'V', 65, v4l2_audio); +/// # fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! ioctl_readwrite { + ($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: *mut $ty) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, request_code_readwrite!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) +} + +/// Generates a wrapper function for a "bad" ioctl that reads and writes data to the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl request code +/// * The data type passed by this ioctl +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: *mut DATA_TYPE) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +// TODO: Find an example for ioctl_readwrite_bad +#[macro_export(local_inner_macros)] +macro_rules! ioctl_readwrite_bad { + ($(#[$attr:meta])* $name:ident, $nr:expr, $ty:ty) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: *mut $ty) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, $nr as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) +} + +/// Generates a wrapper function for an ioctl that reads an array of elements from the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl identifier +/// * The ioctl sequence number +/// * The data type passed by this ioctl +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: &mut [DATA_TYPE]) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +// TODO: Find an example for ioctl_read_buf +#[macro_export(local_inner_macros)] +macro_rules! ioctl_read_buf { + ($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: &mut [$ty]) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, request_code_read!($ioty, $nr, data.len() * ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) +} + +/// Generates a wrapper function for an ioctl that writes an array of elements to the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl identifier +/// * The ioctl sequence number +/// * The data type passed by this ioctl +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: &[DATA_TYPE]) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +/// +/// # Examples +/// +/// ``` +/// # #[macro_use] extern crate nix; +/// const SPI_IOC_MAGIC: u8 = b'k'; // Defined in linux/spi/spidev.h +/// const SPI_IOC_TYPE_MESSAGE: u8 = 0; +/// # pub struct spi_ioc_transfer(u64); +/// ioctl_write_buf!(spi_transfer, SPI_IOC_MAGIC, SPI_IOC_TYPE_MESSAGE, spi_ioc_transfer); +/// # fn main() {} +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! ioctl_write_buf { + ($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: &[$ty]) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, request_code_write!($ioty, $nr, data.len() * ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) +} + +/// Generates a wrapper function for an ioctl that reads and writes an array of elements to the kernel. +/// +/// The arguments to this macro are: +/// +/// * The function name +/// * The ioctl identifier +/// * The ioctl sequence number +/// * The data type passed by this ioctl +/// +/// The generated function has the following signature: +/// +/// ```rust,ignore +/// pub unsafe fn FUNCTION_NAME(fd: libc::c_int, data: &mut [DATA_TYPE]) -> Result +/// ``` +/// +/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html). +// TODO: Find an example for readwrite_buf +#[macro_export(local_inner_macros)] +macro_rules! ioctl_readwrite_buf { + ($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => ( + $(#[$attr])* + pub unsafe fn $name(fd: $crate::libc::c_int, + data: &mut [$ty]) + -> $crate::Result<$crate::libc::c_int> { + convert_ioctl_res!($crate::libc::ioctl(fd, request_code_readwrite!($ioty, $nr, data.len() * ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data)) + } + ) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/memfd.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/memfd.rs new file mode 100644 index 0000000..9672429 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/memfd.rs @@ -0,0 +1,20 @@ +use libc; +use std::os::unix::io::RawFd; +use Result; +use errno::Errno; +use std::ffi::CStr; + +libc_bitflags!( + pub struct MemFdCreateFlag: libc::c_uint { + MFD_CLOEXEC; + MFD_ALLOW_SEALING; + } +); + +pub fn memfd_create(name: &CStr, flags: MemFdCreateFlag) -> Result { + let res = unsafe { + libc::syscall(libc::SYS_memfd_create, name.as_ptr(), flags.bits()) + }; + + Errno::result(res).map(|r| r as RawFd) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/mman.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/mman.rs new file mode 100644 index 0000000..4e25050 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/mman.rs @@ -0,0 +1,325 @@ +use {Error, Result}; +#[cfg(not(target_os = "android"))] +use NixPath; +use errno::Errno; +#[cfg(not(target_os = "android"))] +use fcntl::OFlag; +use libc::{self, c_int, c_void, size_t, off_t}; +#[cfg(not(target_os = "android"))] +use sys::stat::Mode; +use std::os::unix::io::RawFd; + +libc_bitflags!{ + /// Desired memory protection of a memory mapping. + pub struct ProtFlags: c_int { + /// Pages cannot be accessed. + PROT_NONE; + /// Pages can be read. + PROT_READ; + /// Pages can be written. + PROT_WRITE; + /// Pages can be executed + PROT_EXEC; + /// Apply protection up to the end of a mapping that grows upwards. + #[cfg(any(target_os = "android", target_os = "linux"))] + PROT_GROWSDOWN; + /// Apply protection down to the beginning of a mapping that grows downwards. + #[cfg(any(target_os = "android", target_os = "linux"))] + PROT_GROWSUP; + } +} + +libc_bitflags!{ + /// Additional parameters for `mmap()`. + pub struct MapFlags: c_int { + /// Compatibility flag. Ignored. + MAP_FILE; + /// Share this mapping. Mutually exclusive with `MAP_PRIVATE`. + MAP_SHARED; + /// Create a private copy-on-write mapping. Mutually exclusive with `MAP_SHARED`. + MAP_PRIVATE; + /// Place the mapping at exactly the address specified in `addr`. + MAP_FIXED; + /// Synonym for `MAP_ANONYMOUS`. + MAP_ANON; + /// The mapping is not backed by any file. + #[cfg(any(target_os = "android", target_os = "linux", target_os = "freebsd"))] + MAP_ANONYMOUS; + /// Put the mapping into the first 2GB of the process address space. + #[cfg(any(all(any(target_os = "android", target_os = "linux"), + any(target_arch = "x86", target_arch = "x86_64")), + all(target_os = "linux", target_env = "musl", any(target_arch = "x86", target_arch = "x86_64")), + all(target_os = "freebsd", target_pointer_width = "64")))] + MAP_32BIT; + /// Used for stacks; indicates to the kernel that the mapping should extend downward in memory. + #[cfg(any(target_os = "android", target_os = "linux"))] + MAP_GROWSDOWN; + /// Compatibility flag. Ignored. + #[cfg(any(target_os = "android", target_os = "linux"))] + MAP_DENYWRITE; + /// Compatibility flag. Ignored. + #[cfg(any(target_os = "android", target_os = "linux"))] + MAP_EXECUTABLE; + /// Mark the mmaped region to be locked in the same way as `mlock(2)`. + #[cfg(any(target_os = "android", target_os = "linux"))] + MAP_LOCKED; + /// Do not reserve swap space for this mapping. + /// + /// This was removed in FreeBSD 11. + #[cfg(not(target_os = "freebsd"))] + MAP_NORESERVE; + /// Populate page tables for a mapping. + #[cfg(any(target_os = "android", target_os = "linux"))] + MAP_POPULATE; + /// Only meaningful when used with `MAP_POPULATE`. Don't perform read-ahead. + #[cfg(any(target_os = "android", target_os = "linux"))] + MAP_NONBLOCK; + /// Allocate the mapping using "huge pages." + #[cfg(any(target_os = "android", target_os = "linux"))] + MAP_HUGETLB; + /// Lock the mapped region into memory as with `mlock(2)`. + #[cfg(target_os = "netbsd")] + MAP_WIRED; + /// Causes dirtied data in the specified range to be flushed to disk only when necessary. + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + MAP_NOSYNC; + /// Rename private pages to a file. + /// + /// This was removed in FreeBSD 11. + #[cfg(any(target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd"))] + MAP_RENAME; + /// Region may contain semaphores. + #[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] + MAP_HASSEMAPHORE; + /// Region grows down, like a stack. + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] + MAP_STACK; + /// Pages in this mapping are not retained in the kernel's memory cache. + #[cfg(any(target_os = "ios", target_os = "macos"))] + MAP_NOCACHE; + #[cfg(any(target_os = "ios", target_os = "macos"))] + MAP_JIT; + } +} + +libc_enum!{ + /// Usage information for a range of memory to allow for performance optimizations by the kernel. + /// + /// Used by [`madvise`](./fn.madvise.html). + #[repr(i32)] + pub enum MmapAdvise { + /// No further special treatment. This is the default. + MADV_NORMAL, + /// Expect random page references. + MADV_RANDOM, + /// Expect sequential page references. + MADV_SEQUENTIAL, + /// Expect access in the near future. + MADV_WILLNEED, + /// Do not expect access in the near future. + MADV_DONTNEED, + /// Free up a given range of pages and its associated backing store. + #[cfg(any(target_os = "android", target_os = "linux"))] + MADV_REMOVE, + /// Do not make pages in this range available to the child after a `fork(2)`. + #[cfg(any(target_os = "android", target_os = "linux"))] + MADV_DONTFORK, + /// Undo the effect of `MADV_DONTFORK`. + #[cfg(any(target_os = "android", target_os = "linux"))] + MADV_DOFORK, + /// Poison the given pages. + /// + /// Subsequent references to those pages are treated like hardware memory corruption. + #[cfg(any(target_os = "android", target_os = "linux"))] + MADV_HWPOISON, + /// Enable Kernel Samepage Merging (KSM) for the given pages. + #[cfg(any(target_os = "android", target_os = "linux"))] + MADV_MERGEABLE, + /// Undo the effect of `MADV_MERGEABLE` + #[cfg(any(target_os = "android", target_os = "linux"))] + MADV_UNMERGEABLE, + /// Preserve the memory of each page but offline the original page. + #[cfg(any(target_os = "android", + all(target_os = "linux", any( + target_arch = "aarch64", + target_arch = "arm", + target_arch = "ppc", + target_arch = "s390x", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "sparc64"))))] + MADV_SOFT_OFFLINE, + /// Enable Transparent Huge Pages (THP) for pages in the given range. + #[cfg(any(target_os = "android", target_os = "linux"))] + MADV_HUGEPAGE, + /// Undo the effect of `MADV_HUGEPAGE`. + #[cfg(any(target_os = "android", target_os = "linux"))] + MADV_NOHUGEPAGE, + /// Exclude the given range from a core dump. + #[cfg(any(target_os = "android", target_os = "linux"))] + MADV_DONTDUMP, + /// Undo the effect of an earlier `MADV_DONTDUMP`. + #[cfg(any(target_os = "android", target_os = "linux"))] + MADV_DODUMP, + /// Specify that the application no longer needs the pages in the given range. + MADV_FREE, + /// Request that the system not flush the current range to disk unless it needs to. + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + MADV_NOSYNC, + /// Undoes the effects of `MADV_NOSYNC` for any future pages dirtied within the given range. + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + MADV_AUTOSYNC, + /// Region is not included in a core file. + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + MADV_NOCORE, + /// Include region in a core file + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + MADV_CORE, + #[cfg(any(target_os = "freebsd"))] + MADV_PROTECT, + /// Invalidate the hardware page table for the given region. + #[cfg(target_os = "dragonfly")] + MADV_INVAL, + /// Set the offset of the page directory page to `value` for the virtual page table. + #[cfg(target_os = "dragonfly")] + MADV_SETMAP, + /// Indicates that the application will not need the data in the given range. + #[cfg(any(target_os = "ios", target_os = "macos"))] + MADV_ZERO_WIRED_PAGES, + #[cfg(any(target_os = "ios", target_os = "macos"))] + MADV_FREE_REUSABLE, + #[cfg(any(target_os = "ios", target_os = "macos"))] + MADV_FREE_REUSE, + #[cfg(any(target_os = "ios", target_os = "macos"))] + MADV_CAN_REUSE, + } +} + +libc_bitflags!{ + /// Configuration flags for `msync`. + pub struct MsFlags: c_int { + /// Schedule an update but return immediately. + MS_ASYNC; + /// Invalidate all cached data. + MS_INVALIDATE; + /// Invalidate pages, but leave them mapped. + #[cfg(any(target_os = "ios", target_os = "macos"))] + MS_KILLPAGES; + /// Deactivate pages, but leave them mapped. + #[cfg(any(target_os = "ios", target_os = "macos"))] + MS_DEACTIVATE; + /// Perform an update and wait for it to complete. + MS_SYNC; + } +} + +libc_bitflags!{ + /// Flags for `mlockall`. + pub struct MlockAllFlags: c_int { + /// Lock pages that are currently mapped into the address space of the process. + MCL_CURRENT; + /// Lock pages which will become mapped into the address space of the process in the future. + MCL_FUTURE; + } +} + +/// Locks all memory pages that contain part of the address range with `length` bytes starting at +/// `addr`. Locked pages never move to the swap area. +pub unsafe fn mlock(addr: *const c_void, length: size_t) -> Result<()> { + Errno::result(libc::mlock(addr, length)).map(drop) +} + +/// Unlocks all memory pages that contain part of the address range with `length` bytes starting at +/// `addr`. +pub unsafe fn munlock(addr: *const c_void, length: size_t) -> Result<()> { + Errno::result(libc::munlock(addr, length)).map(drop) +} + +/// Locks all memory pages mapped into this process' address space. Locked pages never move to the +/// swap area. +pub fn mlockall(flags: MlockAllFlags) -> Result<()> { + unsafe { Errno::result(libc::mlockall(flags.bits())) }.map(drop) +} + +/// Unlocks all memory pages mapped into this process' address space. +pub fn munlockall() -> Result<()> { + unsafe { Errno::result(libc::munlockall()) }.map(drop) +} + +/// Calls to mmap are inherently unsafe, so they must be made in an unsafe block. Typically +/// a higher-level abstraction will hide the unsafe interactions with the mmap'd region. +pub unsafe fn mmap(addr: *mut c_void, length: size_t, prot: ProtFlags, flags: MapFlags, fd: RawFd, offset: off_t) -> Result<*mut c_void> { + let ret = libc::mmap(addr, length, prot.bits(), flags.bits(), fd, offset); + + if ret == libc::MAP_FAILED { + Err(Error::Sys(Errno::last())) + } else { + Ok(ret) + } +} + +pub unsafe fn munmap(addr: *mut c_void, len: size_t) -> Result<()> { + Errno::result(libc::munmap(addr, len)).map(drop) +} + +pub unsafe fn madvise(addr: *mut c_void, length: size_t, advise: MmapAdvise) -> Result<()> { + Errno::result(libc::madvise(addr, length, advise as i32)).map(drop) +} + +/// Set protection of memory mapping. +/// +/// See [`mprotect(3)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mprotect.html) for +/// details. +/// +/// # Safety +/// +/// Calls to `mprotect` are inherently unsafe, as changes to memory protections can lead to +/// SIGSEGVs. +/// +/// ``` +/// # use nix::libc::size_t; +/// # use nix::sys::mman::{mmap, mprotect, MapFlags, ProtFlags}; +/// # use std::ptr; +/// const ONE_K: size_t = 1024; +/// let mut slice: &mut [u8] = unsafe { +/// let mem = mmap(ptr::null_mut(), ONE_K, ProtFlags::PROT_NONE, +/// MapFlags::MAP_ANON | MapFlags::MAP_PRIVATE, -1, 0).unwrap(); +/// mprotect(mem, ONE_K, ProtFlags::PROT_READ | ProtFlags::PROT_WRITE).unwrap(); +/// std::slice::from_raw_parts_mut(mem as *mut u8, ONE_K) +/// }; +/// assert_eq!(slice[0], 0x00); +/// slice[0] = 0xFF; +/// assert_eq!(slice[0], 0xFF); +/// ``` +pub unsafe fn mprotect(addr: *mut c_void, length: size_t, prot: ProtFlags) -> Result<()> { + Errno::result(libc::mprotect(addr, length, prot.bits())).map(drop) +} + +pub unsafe fn msync(addr: *mut c_void, length: size_t, flags: MsFlags) -> Result<()> { + Errno::result(libc::msync(addr, length, flags.bits())).map(drop) +} + +#[cfg(not(target_os = "android"))] +pub fn shm_open(name: &P, flag: OFlag, mode: Mode) -> Result { + let ret = name.with_nix_path(|cstr| { + #[cfg(any(target_os = "macos", target_os = "ios"))] + unsafe { + libc::shm_open(cstr.as_ptr(), flag.bits(), mode.bits() as libc::c_uint) + } + #[cfg(not(any(target_os = "macos", target_os = "ios")))] + unsafe { + libc::shm_open(cstr.as_ptr(), flag.bits(), mode.bits() as libc::mode_t) + } + })?; + + Errno::result(ret) +} + +#[cfg(not(target_os = "android"))] +pub fn shm_unlink(name: &P) -> Result<()> { + let ret = name.with_nix_path(|cstr| { + unsafe { libc::shm_unlink(cstr.as_ptr()) } + })?; + + Errno::result(ret).map(drop) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/mod.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/mod.rs new file mode 100644 index 0000000..88c7251 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/mod.rs @@ -0,0 +1,93 @@ +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd"))] +pub mod aio; + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub mod epoll; + +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +pub mod event; + +#[cfg(target_os = "linux")] +pub mod eventfd; + +#[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +#[macro_use] +pub mod ioctl; + +#[cfg(target_os = "linux")] +pub mod memfd; + +pub mod mman; + +pub mod pthread; + +#[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +pub mod ptrace; + +#[cfg(target_os = "linux")] +pub mod quota; + +#[cfg(any(target_os = "linux"))] +pub mod reboot; + +pub mod select; + +#[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] +pub mod sendfile; + +pub mod signal; + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub mod signalfd; + +pub mod socket; + +pub mod stat; + +#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))] +pub mod statfs; + +pub mod statvfs; + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub mod sysinfo; + +pub mod termios; + +pub mod time; + +pub mod uio; + +pub mod utsname; + +pub mod wait; + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub mod inotify; diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/pthread.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/pthread.rs new file mode 100644 index 0000000..a4d9825 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/pthread.rs @@ -0,0 +1,13 @@ +use libc::{self, pthread_t}; + +pub type Pthread = pthread_t; + +/// Obtain ID of the calling thread (see +/// [`pthread_self(3)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_self.html) +/// +/// The thread ID returned by `pthread_self()` is not the same thing as +/// the kernel thread ID returned by a call to `gettid(2)`. +#[inline] +pub fn pthread_self() -> Pthread { + unsafe { libc::pthread_self() } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/ptrace/bsd.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/ptrace/bsd.rs new file mode 100644 index 0000000..7797d10 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/ptrace/bsd.rs @@ -0,0 +1,170 @@ +use errno::Errno; +use libc::{self, c_int}; +use std::ptr; +use sys::signal::Signal; +use unistd::Pid; +use Result; + +pub type RequestType = c_int; + +cfg_if! { + if #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "openbsd"))] { + #[doc(hidden)] + pub type AddressType = *mut ::libc::c_char; + } else { + #[doc(hidden)] + pub type AddressType = *mut ::libc::c_void; + } +} + +libc_enum! { + #[repr(i32)] + /// Ptrace Request enum defining the action to be taken. + pub enum Request { + PT_TRACE_ME, + PT_READ_I, + PT_READ_D, + #[cfg(target_os = "macos")] + PT_READ_U, + PT_WRITE_I, + PT_WRITE_D, + #[cfg(target_os = "macos")] + PT_WRITE_U, + PT_CONTINUE, + PT_KILL, + #[cfg(any(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos"), + all(target_os = "openbsd", target_arch = "x86_64"), + all(target_os = "netbsd", any(target_arch = "x86_64", + target_arch = "powerpc"))))] + PT_STEP, + PT_ATTACH, + PT_DETACH, + #[cfg(target_os = "macos")] + PT_SIGEXC, + #[cfg(target_os = "macos")] + PT_THUPDATE, + #[cfg(target_os = "macos")] + PT_ATTACHEXC + } +} + +unsafe fn ptrace_other( + request: Request, + pid: Pid, + addr: AddressType, + data: c_int, +) -> Result { + Errno::result(libc::ptrace( + request as RequestType, + libc::pid_t::from(pid), + addr, + data, + )).map(|_| 0) +} + +/// Sets the process as traceable, as with `ptrace(PT_TRACEME, ...)` +/// +/// Indicates that this process is to be traced by its parent. +/// This is the only ptrace request to be issued by the tracee. +pub fn traceme() -> Result<()> { + unsafe { ptrace_other(Request::PT_TRACE_ME, Pid::from_raw(0), ptr::null_mut(), 0).map(drop) } +} + +/// Attach to a running process, as with `ptrace(PT_ATTACH, ...)` +/// +/// Attaches to the process specified in pid, making it a tracee of the calling process. +pub fn attach(pid: Pid) -> Result<()> { + unsafe { ptrace_other(Request::PT_ATTACH, pid, ptr::null_mut(), 0).map(drop) } +} + +/// Detaches the current running process, as with `ptrace(PT_DETACH, ...)` +/// +/// Detaches from the process specified in pid allowing it to run freely +pub fn detach(pid: Pid) -> Result<()> { + unsafe { ptrace_other(Request::PT_DETACH, pid, ptr::null_mut(), 0).map(drop) } +} + +/// Restart the stopped tracee process, as with `ptrace(PTRACE_CONT, ...)` +/// +/// Continues the execution of the process with PID `pid`, optionally +/// delivering a signal specified by `sig`. +pub fn cont>>(pid: Pid, sig: T) -> Result<()> { + let data = match sig.into() { + Some(s) => s as c_int, + None => 0, + }; + unsafe { + // Ignore the useless return value + ptrace_other(Request::PT_CONTINUE, pid, 1 as AddressType, data).map(drop) + } +} + +/// Issues a kill request as with `ptrace(PT_KILL, ...)` +/// +/// This request is equivalent to `ptrace(PT_CONTINUE, ..., SIGKILL);` +pub fn kill(pid: Pid) -> Result<()> { + unsafe { + ptrace_other(Request::PT_KILL, pid, 0 as AddressType, 0).map(drop) + } +} + +/// Move the stopped tracee process forward by a single step as with +/// `ptrace(PT_STEP, ...)` +/// +/// Advances the execution of the process with PID `pid` by a single step optionally delivering a +/// signal specified by `sig`. +/// +/// # Example +/// ```rust +/// extern crate nix; +/// use nix::sys::ptrace::step; +/// use nix::unistd::Pid; +/// use nix::sys::signal::Signal; +/// use nix::sys::wait::*; +/// fn main() { +/// // If a process changes state to the stopped state because of a SIGUSR1 +/// // signal, this will step the process forward and forward the user +/// // signal to the stopped process +/// match waitpid(Pid::from_raw(-1), None) { +/// Ok(WaitStatus::Stopped(pid, Signal::SIGUSR1)) => { +/// let _ = step(pid, Signal::SIGUSR1); +/// } +/// _ => {}, +/// } +/// } +/// ``` +#[cfg( + any( + any(target_os = "dragonfly", target_os = "freebsd", target_os = "macos"), + all(target_os = "openbsd", target_arch = "x86_64"), + all(target_os = "netbsd", + any(target_arch = "x86_64", target_arch = "powerpc") + ) + ) +)] +pub fn step>>(pid: Pid, sig: T) -> Result<()> { + let data = match sig.into() { + Some(s) => s as c_int, + None => 0, + }; + unsafe { ptrace_other(Request::PT_STEP, pid, ptr::null_mut(), data).map(drop) } +} + +/// Reads a word from a processes memory at the given address +pub fn read(pid: Pid, addr: AddressType) -> Result { + unsafe { + // Traditionally there was a difference between reading data or + // instruction memory but not in modern systems. + ptrace_other(Request::PT_READ_D, pid, addr, 0) + } +} + +/// Writes a word into the processes memory at the given address +pub fn write(pid: Pid, addr: AddressType, data: c_int) -> Result<()> { + unsafe { ptrace_other(Request::PT_WRITE_D, pid, addr, data).map(drop) } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/ptrace/linux.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/ptrace/linux.rs new file mode 100644 index 0000000..df15e66 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/ptrace/linux.rs @@ -0,0 +1,402 @@ +//! For detailed description of the ptrace requests, consult `man ptrace`. + +use std::{mem, ptr}; +use {Error, Result}; +use errno::Errno; +use libc::{self, c_void, c_long, siginfo_t}; +use ::unistd::Pid; +use sys::signal::Signal; + +pub type AddressType = *mut ::libc::c_void; + +#[cfg(all(target_os = "linux", + any(target_arch = "x86_64", + target_arch = "x86"), + target_env = "gnu"))] +use libc::user_regs_struct; + +cfg_if! { + if #[cfg(any(all(target_os = "linux", target_arch = "s390x"), + all(target_os = "linux", target_env = "gnu")))] { + #[doc(hidden)] + pub type RequestType = ::libc::c_uint; + } else { + #[doc(hidden)] + pub type RequestType = ::libc::c_int; + } +} + +libc_enum!{ + #[cfg_attr(not(any(target_env = "musl", target_os = "android")), repr(u32))] + #[cfg_attr(any(target_env = "musl", target_os = "android"), repr(i32))] + /// Ptrace Request enum defining the action to be taken. + pub enum Request { + PTRACE_TRACEME, + PTRACE_PEEKTEXT, + PTRACE_PEEKDATA, + PTRACE_PEEKUSER, + PTRACE_POKETEXT, + PTRACE_POKEDATA, + PTRACE_POKEUSER, + PTRACE_CONT, + PTRACE_KILL, + PTRACE_SINGLESTEP, + #[cfg(any(all(target_os = "android", target_pointer_width = "32"), + all(target_os = "linux", any(target_env = "musl", + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86_64", + target_pointer_width = "32"))))] + PTRACE_GETREGS, + #[cfg(any(all(target_os = "android", target_pointer_width = "32"), + all(target_os = "linux", any(target_env = "musl", + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86_64", + target_pointer_width = "32"))))] + PTRACE_SETREGS, + #[cfg(any(all(target_os = "android", target_pointer_width = "32"), + all(target_os = "linux", any(target_env = "musl", + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86_64", + target_pointer_width = "32"))))] + PTRACE_GETFPREGS, + #[cfg(any(all(target_os = "android", target_pointer_width = "32"), + all(target_os = "linux", any(target_env = "musl", + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86_64", + target_pointer_width = "32"))))] + PTRACE_SETFPREGS, + PTRACE_ATTACH, + PTRACE_DETACH, + #[cfg(all(target_os = "linux", any(target_env = "musl", + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86", + target_arch = "x86_64")))] + PTRACE_GETFPXREGS, + #[cfg(all(target_os = "linux", any(target_env = "musl", + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86", + target_arch = "x86_64")))] + PTRACE_SETFPXREGS, + PTRACE_SYSCALL, + PTRACE_SETOPTIONS, + PTRACE_GETEVENTMSG, + PTRACE_GETSIGINFO, + PTRACE_SETSIGINFO, + #[cfg(all(target_os = "linux", not(any(target_arch = "mips", + target_arch = "mips64"))))] + PTRACE_GETREGSET, + #[cfg(all(target_os = "linux", not(any(target_arch = "mips", + target_arch = "mips64"))))] + PTRACE_SETREGSET, + #[cfg(all(target_os = "linux", not(any(target_arch = "mips", + target_arch = "mips64"))))] + PTRACE_SEIZE, + #[cfg(all(target_os = "linux", not(any(target_arch = "mips", + target_arch = "mips64"))))] + PTRACE_INTERRUPT, + #[cfg(all(target_os = "linux", not(any(target_arch = "mips", + target_arch = "mips64"))))] + PTRACE_LISTEN, + #[cfg(all(target_os = "linux", not(any(target_arch = "mips", + target_arch = "mips64"))))] + PTRACE_PEEKSIGINFO, + } +} + +libc_enum!{ + #[repr(i32)] + /// Using the ptrace options the tracer can configure the tracee to stop + /// at certain events. This enum is used to define those events as defined + /// in `man ptrace`. + pub enum Event { + /// Event that stops before a return from fork or clone. + PTRACE_EVENT_FORK, + /// Event that stops before a return from vfork or clone. + PTRACE_EVENT_VFORK, + /// Event that stops before a return from clone. + PTRACE_EVENT_CLONE, + /// Event that stops before a return from execve. + PTRACE_EVENT_EXEC, + /// Event for a return from vfork. + PTRACE_EVENT_VFORK_DONE, + /// Event for a stop before an exit. Unlike the waitpid Exit status program. + /// registers can still be examined + PTRACE_EVENT_EXIT, + /// STop triggered by a seccomp rule on a tracee. + PTRACE_EVENT_SECCOMP, + // PTRACE_EVENT_STOP not provided by libc because it's defined in glibc 2.26 + } +} + +libc_bitflags! { + /// Ptrace options used in conjunction with the PTRACE_SETOPTIONS request. + /// See `man ptrace` for more details. + pub struct Options: libc::c_int { + /// When delivering system call traps set a bit to allow tracer to + /// distinguish between normal stops or syscall stops. May not work on + /// all systems. + PTRACE_O_TRACESYSGOOD; + /// Stop tracee at next fork and start tracing the forked process. + PTRACE_O_TRACEFORK; + /// Stop tracee at next vfork call and trace the vforked process. + PTRACE_O_TRACEVFORK; + /// Stop tracee at next clone call and trace the cloned process. + PTRACE_O_TRACECLONE; + /// Stop tracee at next execve call. + PTRACE_O_TRACEEXEC; + /// Stop tracee at vfork completion. + PTRACE_O_TRACEVFORKDONE; + /// Stop tracee at next exit call. Stops before exit commences allowing + /// tracer to see location of exit and register states. + PTRACE_O_TRACEEXIT; + /// Stop tracee when a SECCOMP_RET_TRACE rule is triggered. See `man seccomp` for more + /// details. + PTRACE_O_TRACESECCOMP; + /// Send a SIGKILL to the tracee if the tracer exits. This is useful + /// for ptrace jailers to prevent tracees from escaping their control. + #[cfg(any(target_os = "android", target_os = "linux"))] + PTRACE_O_EXITKILL; + } +} + +/// Performs a ptrace request. If the request in question is provided by a specialised function +/// this function will return an unsupported operation error. +#[deprecated( + since="0.10.0", + note="usages of `ptrace()` should be replaced with the specialized helper functions instead" +)] +pub unsafe fn ptrace(request: Request, pid: Pid, addr: AddressType, data: *mut c_void) -> Result { + use self::Request::*; + match request { + PTRACE_PEEKTEXT | PTRACE_PEEKDATA | PTRACE_GETSIGINFO | + PTRACE_GETEVENTMSG | PTRACE_SETSIGINFO | PTRACE_SETOPTIONS | + PTRACE_POKETEXT | PTRACE_POKEDATA | PTRACE_KILL => Err(Error::UnsupportedOperation), + _ => ptrace_other(request, pid, addr, data) + } +} + +fn ptrace_peek(request: Request, pid: Pid, addr: AddressType, data: *mut c_void) -> Result { + let ret = unsafe { + Errno::clear(); + libc::ptrace(request as RequestType, libc::pid_t::from(pid), addr, data) + }; + match Errno::result(ret) { + Ok(..) | Err(Error::Sys(Errno::UnknownErrno)) => Ok(ret), + err @ Err(..) => err, + } +} + +/// Get user registers, as with `ptrace(PTRACE_GETREGS, ...)` +#[cfg(all(target_os = "linux", + any(target_arch = "x86_64", + target_arch = "x86"), + target_env = "gnu"))] +pub fn getregs(pid: Pid) -> Result { + ptrace_get_data::(Request::PTRACE_GETREGS, pid) +} + +/// Set user registers, as with `ptrace(PTRACE_SETREGS, ...)` +#[cfg(all(target_os = "linux", + any(target_arch = "x86_64", + target_arch = "x86"), + target_env = "gnu"))] +pub fn setregs(pid: Pid, regs: user_regs_struct) -> Result<()> { + let res = unsafe { + libc::ptrace(Request::PTRACE_SETREGS as RequestType, + libc::pid_t::from(pid), + ptr::null_mut::(), + ®s as *const _ as *const c_void) + }; + Errno::result(res).map(drop) +} + +/// Function for ptrace requests that return values from the data field. +/// Some ptrace get requests populate structs or larger elements than `c_long` +/// and therefore use the data field to return values. This function handles these +/// requests. +fn ptrace_get_data(request: Request, pid: Pid) -> Result { + // Creates an uninitialized pointer to store result in + let data: T = unsafe { mem::uninitialized() }; + let res = unsafe { + libc::ptrace(request as RequestType, + libc::pid_t::from(pid), + ptr::null_mut::(), + &data as *const _ as *const c_void) + }; + Errno::result(res)?; + Ok(data) +} + +unsafe fn ptrace_other(request: Request, pid: Pid, addr: AddressType, data: *mut c_void) -> Result { + Errno::result(libc::ptrace(request as RequestType, libc::pid_t::from(pid), addr, data)).map(|_| 0) +} + +/// Set options, as with `ptrace(PTRACE_SETOPTIONS,...)`. +pub fn setoptions(pid: Pid, options: Options) -> Result<()> { + let res = unsafe { + libc::ptrace(Request::PTRACE_SETOPTIONS as RequestType, + libc::pid_t::from(pid), + ptr::null_mut::(), + options.bits() as *mut c_void) + }; + Errno::result(res).map(drop) +} + +/// Gets a ptrace event as described by `ptrace(PTRACE_GETEVENTMSG,...)` +pub fn getevent(pid: Pid) -> Result { + ptrace_get_data::(Request::PTRACE_GETEVENTMSG, pid) +} + +/// Get siginfo as with `ptrace(PTRACE_GETSIGINFO,...)` +pub fn getsiginfo(pid: Pid) -> Result { + ptrace_get_data::(Request::PTRACE_GETSIGINFO, pid) +} + +/// Set siginfo as with `ptrace(PTRACE_SETSIGINFO,...)` +pub fn setsiginfo(pid: Pid, sig: &siginfo_t) -> Result<()> { + let ret = unsafe{ + Errno::clear(); + libc::ptrace(Request::PTRACE_SETSIGINFO as RequestType, + libc::pid_t::from(pid), + ptr::null_mut::(), + sig as *const _ as *const c_void) + }; + match Errno::result(ret) { + Ok(_) => Ok(()), + Err(e) => Err(e), + } +} + +/// Sets the process as traceable, as with `ptrace(PTRACE_TRACEME, ...)` +/// +/// Indicates that this process is to be traced by its parent. +/// This is the only ptrace request to be issued by the tracee. +pub fn traceme() -> Result<()> { + unsafe { + ptrace_other( + Request::PTRACE_TRACEME, + Pid::from_raw(0), + ptr::null_mut(), + ptr::null_mut(), + ).map(drop) // ignore the useless return value + } +} + +/// Ask for next syscall, as with `ptrace(PTRACE_SYSCALL, ...)` +/// +/// Arranges for the tracee to be stopped at the next entry to or exit from a system call. +pub fn syscall(pid: Pid) -> Result<()> { + unsafe { + ptrace_other( + Request::PTRACE_SYSCALL, + pid, + ptr::null_mut(), + ptr::null_mut(), + ).map(drop) // ignore the useless return value + } +} + +/// Attach to a running process, as with `ptrace(PTRACE_ATTACH, ...)` +/// +/// Attaches to the process specified in pid, making it a tracee of the calling process. +pub fn attach(pid: Pid) -> Result<()> { + unsafe { + ptrace_other( + Request::PTRACE_ATTACH, + pid, + ptr::null_mut(), + ptr::null_mut(), + ).map(drop) // ignore the useless return value + } +} + +/// Detaches the current running process, as with `ptrace(PTRACE_DETACH, ...)` +/// +/// Detaches from the process specified in pid allowing it to run freely +pub fn detach(pid: Pid) -> Result<()> { + unsafe { + ptrace_other( + Request::PTRACE_DETACH, + pid, + ptr::null_mut(), + ptr::null_mut() + ).map(drop) + } +} + +/// Restart the stopped tracee process, as with `ptrace(PTRACE_CONT, ...)` +/// +/// Continues the execution of the process with PID `pid`, optionally +/// delivering a signal specified by `sig`. +pub fn cont>>(pid: Pid, sig: T) -> Result<()> { + let data = match sig.into() { + Some(s) => s as i32 as *mut c_void, + None => ptr::null_mut(), + }; + unsafe { + ptrace_other(Request::PTRACE_CONT, pid, ptr::null_mut(), data).map(drop) // ignore the useless return value + } +} + +/// Issues a kill request as with `ptrace(PTRACE_KILL, ...)` +/// +/// This request is equivalent to `ptrace(PTRACE_CONT, ..., SIGKILL);` +pub fn kill(pid: Pid) -> Result<()> { + unsafe { + ptrace_other(Request::PTRACE_KILL, pid, ptr::null_mut(), ptr::null_mut()).map(drop) + } +} + +/// Move the stopped tracee process forward by a single step as with +/// `ptrace(PTRACE_SINGLESTEP, ...)` +/// +/// Advances the execution of the process with PID `pid` by a single step optionally delivering a +/// signal specified by `sig`. +/// +/// # Example +/// ```rust +/// extern crate nix; +/// use nix::sys::ptrace::step; +/// use nix::unistd::Pid; +/// use nix::sys::signal::Signal; +/// use nix::sys::wait::*; +/// fn main() { +/// // If a process changes state to the stopped state because of a SIGUSR1 +/// // signal, this will step the process forward and forward the user +/// // signal to the stopped process +/// match waitpid(Pid::from_raw(-1), None) { +/// Ok(WaitStatus::Stopped(pid, Signal::SIGUSR1)) => { +/// let _ = step(pid, Signal::SIGUSR1); +/// } +/// _ => {}, +/// } +/// } +/// ``` +pub fn step>>(pid: Pid, sig: T) -> Result<()> { + let data = match sig.into() { + Some(s) => s as i32 as *mut c_void, + None => ptr::null_mut(), + }; + unsafe { + ptrace_other(Request::PTRACE_SINGLESTEP, pid, ptr::null_mut(), data).map(drop) + } +} + + +/// Reads a word from a processes memory at the given address +pub fn read(pid: Pid, addr: AddressType) -> Result { + ptrace_peek(Request::PTRACE_PEEKDATA, pid, addr, ptr::null_mut()) +} + +/// Writes a word into the processes memory at the given address +pub fn write(pid: Pid, addr: AddressType, data: *mut c_void) -> Result<()> { + unsafe { + ptrace_other(Request::PTRACE_POKEDATA, pid, addr, data).map(drop) + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/ptrace/mod.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/ptrace/mod.rs new file mode 100644 index 0000000..782c304 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/ptrace/mod.rs @@ -0,0 +1,22 @@ +///! Provides helpers for making ptrace system calls + +#[cfg(any(target_os = "android", target_os = "linux"))] +mod linux; + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub use self::linux::*; + +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +mod bsd; + +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd" + ))] +pub use self::bsd::*; diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/quota.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/quota.rs new file mode 100644 index 0000000..14c0462 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/quota.rs @@ -0,0 +1,274 @@ +//! Set and configure disk quotas for users, groups, or projects. +//! +//! # Examples +//! +//! Enabling and setting a quota: +//! +//! ```rust,no_run +//! # use nix::sys::quota::{Dqblk, quotactl_on, quotactl_set, QuotaFmt, QuotaType, QuotaValidFlags}; +//! quotactl_on(QuotaType::USRQUOTA, "/dev/sda1", QuotaFmt::QFMT_VFS_V1, "aquota.user"); +//! let mut dqblk: Dqblk = Default::default(); +//! dqblk.set_blocks_hard_limit(10000); +//! dqblk.set_blocks_soft_limit(8000); +//! quotactl_set(QuotaType::USRQUOTA, "/dev/sda1", 50, &dqblk, QuotaValidFlags::QIF_BLIMITS); +//! ``` +use std::default::Default; +use std::{mem, ptr}; +use libc::{self, c_int, c_char}; +use {Result, NixPath}; +use errno::Errno; + +struct QuotaCmd(QuotaSubCmd, QuotaType); + +impl QuotaCmd { + fn as_int(&self) -> c_int { + unsafe { libc::QCMD(self.0 as i32, self.1 as i32) } + } +} + +// linux quota version >= 2 +libc_enum!{ + #[repr(i32)] + enum QuotaSubCmd { + Q_SYNC, + Q_QUOTAON, + Q_QUOTAOFF, + Q_GETQUOTA, + Q_SETQUOTA, + } +} + +libc_enum!{ + /// The scope of the quota. + #[repr(i32)] + pub enum QuotaType { + /// Specify a user quota + USRQUOTA, + /// Specify a group quota + GRPQUOTA, + } +} + +libc_enum!{ + /// The type of quota format to use. + #[repr(i32)] + pub enum QuotaFmt { + /// Use the original quota format. + QFMT_VFS_OLD, + /// Use the standard VFS v0 quota format. + /// + /// Handles 32-bit UIDs/GIDs and quota limits up to 232 bytes/232 inodes. + QFMT_VFS_V0, + /// Use the VFS v1 quota format. + /// + /// Handles 32-bit UIDs/GIDs and quota limits of 264 bytes/264 inodes. + QFMT_VFS_V1, + } +} + +libc_bitflags!( + /// Indicates the quota fields that are valid to read from. + #[derive(Default)] + pub struct QuotaValidFlags: u32 { + /// The block hard & soft limit fields. + QIF_BLIMITS; + /// The current space field. + QIF_SPACE; + /// The inode hard & soft limit fields. + QIF_ILIMITS; + /// The current inodes field. + QIF_INODES; + /// The disk use time limit field. + QIF_BTIME; + /// The file quote time limit field. + QIF_ITIME; + /// All block & inode limits. + QIF_LIMITS; + /// The space & inodes usage fields. + QIF_USAGE; + /// The time limit fields. + QIF_TIMES; + /// All fields. + QIF_ALL; + } +); + +/// Wrapper type for `if_dqblk` +// FIXME: Change to repr(transparent) +#[repr(C)] +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct Dqblk(libc::dqblk); + +impl Default for Dqblk { + fn default() -> Dqblk { + Dqblk(libc::dqblk { + dqb_bhardlimit: 0, + dqb_bsoftlimit: 0, + dqb_curspace: 0, + dqb_ihardlimit: 0, + dqb_isoftlimit: 0, + dqb_curinodes: 0, + dqb_btime: 0, + dqb_itime: 0, + dqb_valid: 0, + }) + } +} + +impl Dqblk { + /// The absolute limit on disk quota blocks allocated. + pub fn blocks_hard_limit(&self) -> Option { + let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid); + if valid_fields.contains(QuotaValidFlags::QIF_BLIMITS) { + Some(self.0.dqb_bhardlimit) + } else { + None + } + } + + /// Set the absolute limit on disk quota blocks allocated. + pub fn set_blocks_hard_limit(&mut self, limit: u64) { + self.0.dqb_bhardlimit = limit; + } + + /// Preferred limit on disk quota blocks + pub fn blocks_soft_limit(&self) -> Option { + let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid); + if valid_fields.contains(QuotaValidFlags::QIF_BLIMITS) { + Some(self.0.dqb_bsoftlimit) + } else { + None + } + } + + /// Set the preferred limit on disk quota blocks allocated. + pub fn set_blocks_soft_limit(&mut self, limit: u64) { + self.0.dqb_bsoftlimit = limit; + } + + /// Current occupied space (bytes). + pub fn occupied_space(&self) -> Option { + let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid); + if valid_fields.contains(QuotaValidFlags::QIF_SPACE) { + Some(self.0.dqb_curspace) + } else { + None + } + } + + /// Maximum number of allocated inodes. + pub fn inodes_hard_limit(&self) -> Option { + let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid); + if valid_fields.contains(QuotaValidFlags::QIF_ILIMITS) { + Some(self.0.dqb_ihardlimit) + } else { + None + } + } + + /// Set the maximum number of allocated inodes. + pub fn set_inodes_hard_limit(&mut self, limit: u64) { + self.0.dqb_ihardlimit = limit; + } + + /// Preferred inode limit + pub fn inodes_soft_limit(&self) -> Option { + let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid); + if valid_fields.contains(QuotaValidFlags::QIF_ILIMITS) { + Some(self.0.dqb_isoftlimit) + } else { + None + } + } + + /// Set the preferred limit of allocated inodes. + pub fn set_inodes_soft_limit(&mut self, limit: u64) { + self.0.dqb_isoftlimit = limit; + } + + /// Current number of allocated inodes. + pub fn allocated_inodes(&self) -> Option { + let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid); + if valid_fields.contains(QuotaValidFlags::QIF_INODES) { + Some(self.0.dqb_curinodes) + } else { + None + } + } + + /// Time limit for excessive disk use. + pub fn block_time_limit(&self) -> Option { + let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid); + if valid_fields.contains(QuotaValidFlags::QIF_BTIME) { + Some(self.0.dqb_btime) + } else { + None + } + } + + /// Set the time limit for excessive disk use. + pub fn set_block_time_limit(&mut self, limit: u64) { + self.0.dqb_btime = limit; + } + + /// Time limit for excessive files. + pub fn inode_time_limit(&self) -> Option { + let valid_fields = QuotaValidFlags::from_bits_truncate(self.0.dqb_valid); + if valid_fields.contains(QuotaValidFlags::QIF_ITIME) { + Some(self.0.dqb_itime) + } else { + None + } + } + + /// Set the time limit for excessive files. + pub fn set_inode_time_limit(&mut self, limit: u64) { + self.0.dqb_itime = limit; + } +} + +fn quotactl(cmd: QuotaCmd, special: Option<&P>, id: c_int, addr: *mut c_char) -> Result<()> { + unsafe { + Errno::clear(); + let res = match special { + Some(dev) => dev.with_nix_path(|path| libc::quotactl(cmd.as_int(), path.as_ptr(), id, addr)), + None => Ok(libc::quotactl(cmd.as_int(), ptr::null(), id, addr)), + }?; + + Errno::result(res).map(drop) + } +} + +/// Turn on disk quotas for a block device. +pub fn quotactl_on(which: QuotaType, special: &P, format: QuotaFmt, quota_file: &P) -> Result<()> { + quota_file.with_nix_path(|path| { + let mut path_copy = path.to_bytes_with_nul().to_owned(); + let p: *mut c_char = path_copy.as_mut_ptr() as *mut c_char; + quotactl(QuotaCmd(QuotaSubCmd::Q_QUOTAON, which), Some(special), format as c_int, p) + })? +} + +/// Disable disk quotas for a block device. +pub fn quotactl_off(which: QuotaType, special: &P) -> Result<()> { + quotactl(QuotaCmd(QuotaSubCmd::Q_QUOTAOFF, which), Some(special), 0, ptr::null_mut()) +} + +/// Update the on-disk copy of quota usages for a filesystem. +pub fn quotactl_sync(which: QuotaType, special: Option<&P>) -> Result<()> { + quotactl(QuotaCmd(QuotaSubCmd::Q_SYNC, which), special, 0, ptr::null_mut()) +} + +/// Get disk quota limits and current usage for the given user/group id. +pub fn quotactl_get(which: QuotaType, special: &P, id: c_int) -> Result { + let mut dqblk = unsafe { mem::uninitialized() }; + quotactl(QuotaCmd(QuotaSubCmd::Q_GETQUOTA, which), Some(special), id, &mut dqblk as *mut _ as *mut c_char)?; + dqblk +} + +/// Configure quota values for the specified fields for a given user/group id. +pub fn quotactl_set(which: QuotaType, special: &P, id: c_int, dqblk: &Dqblk, fields: QuotaValidFlags) -> Result<()> { + let mut dqblk_copy = *dqblk; + dqblk_copy.0.dqb_valid = fields.bits(); + quotactl(QuotaCmd(QuotaSubCmd::Q_SETQUOTA, which), Some(special), id, &mut dqblk_copy as *mut _ as *mut c_char) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/reboot.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/reboot.rs new file mode 100644 index 0000000..bafa8fc --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/reboot.rs @@ -0,0 +1,45 @@ +//! Reboot/shutdown or enable/disable Ctrl-Alt-Delete. + +use {Error, Result}; +use errno::Errno; +use libc; +use void::Void; +use std::mem::drop; + +libc_enum! { + /// How exactly should the system be rebooted. + /// + /// See [`set_cad_enabled()`](fn.set_cad_enabled.html) for + /// enabling/disabling Ctrl-Alt-Delete. + #[repr(i32)] + pub enum RebootMode { + RB_HALT_SYSTEM, + RB_KEXEC, + RB_POWER_OFF, + RB_AUTOBOOT, + // we do not support Restart2, + RB_SW_SUSPEND, + } +} + +pub fn reboot(how: RebootMode) -> Result { + unsafe { + libc::reboot(how as libc::c_int) + }; + Err(Error::Sys(Errno::last())) +} + +/// Enable or disable the reboot keystroke (Ctrl-Alt-Delete). +/// +/// Corresponds to calling `reboot(RB_ENABLE_CAD)` or `reboot(RB_DISABLE_CAD)` in C. +pub fn set_cad_enabled(enable: bool) -> Result<()> { + let cmd = if enable { + libc::RB_ENABLE_CAD + } else { + libc::RB_DISABLE_CAD + }; + let res = unsafe { + libc::reboot(cmd) + }; + Errno::result(res).map(drop) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/select.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/select.rs new file mode 100644 index 0000000..95b6b14 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/select.rs @@ -0,0 +1,335 @@ +use std::mem; +use std::os::unix::io::RawFd; +use std::ptr::{null, null_mut}; +use libc::{self, c_int}; +use Result; +use errno::Errno; +use sys::signal::SigSet; +use sys::time::{TimeSpec, TimeVal}; + +pub use libc::FD_SETSIZE; + +// FIXME: Change to repr(transparent) once it's stable +#[repr(C)] +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct FdSet(libc::fd_set); + +impl FdSet { + pub fn new() -> FdSet { + let mut fdset = unsafe { mem::uninitialized() }; + unsafe { libc::FD_ZERO(&mut fdset) }; + FdSet(fdset) + } + + pub fn insert(&mut self, fd: RawFd) { + unsafe { libc::FD_SET(fd, &mut self.0) }; + } + + pub fn remove(&mut self, fd: RawFd) { + unsafe { libc::FD_CLR(fd, &mut self.0) }; + } + + pub fn contains(&mut self, fd: RawFd) -> bool { + unsafe { libc::FD_ISSET(fd, &mut self.0) } + } + + pub fn clear(&mut self) { + unsafe { libc::FD_ZERO(&mut self.0) }; + } + + /// Finds the highest file descriptor in the set. + /// + /// Returns `None` if the set is empty. + /// + /// This can be used to calculate the `nfds` parameter of the [`select`] function. + /// + /// # Example + /// + /// ``` + /// # extern crate nix; + /// # use nix::sys::select::FdSet; + /// # fn main() { + /// let mut set = FdSet::new(); + /// set.insert(4); + /// set.insert(9); + /// assert_eq!(set.highest(), Some(9)); + /// # } + /// ``` + /// + /// [`select`]: fn.select.html + pub fn highest(&mut self) -> Option { + for i in (0..FD_SETSIZE).rev() { + let i = i as RawFd; + if unsafe { libc::FD_ISSET(i, self as *mut _ as *mut libc::fd_set) } { + return Some(i) + } + } + + None + } +} + +/// Monitors file descriptors for readiness +/// +/// Returns the total number of ready file descriptors in all sets. The sets are changed so that all +/// file descriptors that are ready for the given operation are set. +/// +/// When this function returns, `timeout` has an implementation-defined value. +/// +/// # Parameters +/// +/// * `nfds`: The highest file descriptor set in any of the passed `FdSet`s, plus 1. If `None`, this +/// is calculated automatically by calling [`FdSet::highest`] on all descriptor sets and adding 1 +/// to the maximum of that. +/// * `readfds`: File descriptors to check for being ready to read. +/// * `writefds`: File descriptors to check for being ready to write. +/// * `errorfds`: File descriptors to check for pending error conditions. +/// * `timeout`: Maximum time to wait for descriptors to become ready (`None` to block +/// indefinitely). +/// +/// # References +/// +/// [select(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html) +/// +/// [`FdSet::highest`]: struct.FdSet.html#method.highest +pub fn select<'a, N, R, W, E, T>(nfds: N, + readfds: R, + writefds: W, + errorfds: E, + timeout: T) -> Result +where + N: Into>, + R: Into>, + W: Into>, + E: Into>, + T: Into>, +{ + let mut readfds = readfds.into(); + let mut writefds = writefds.into(); + let mut errorfds = errorfds.into(); + let timeout = timeout.into(); + + let nfds = nfds.into().unwrap_or_else(|| { + readfds.iter_mut() + .chain(writefds.iter_mut()) + .chain(errorfds.iter_mut()) + .map(|set| set.highest().unwrap_or(-1)) + .max() + .unwrap_or(-1) + 1 + }); + + let readfds = readfds.map(|set| set as *mut _ as *mut libc::fd_set).unwrap_or(null_mut()); + let writefds = writefds.map(|set| set as *mut _ as *mut libc::fd_set).unwrap_or(null_mut()); + let errorfds = errorfds.map(|set| set as *mut _ as *mut libc::fd_set).unwrap_or(null_mut()); + let timeout = timeout.map(|tv| tv as *mut _ as *mut libc::timeval) + .unwrap_or(null_mut()); + + let res = unsafe { + libc::select(nfds, readfds, writefds, errorfds, timeout) + }; + + Errno::result(res) +} + +/// Monitors file descriptors for readiness with an altered signal mask. +/// +/// Returns the total number of ready file descriptors in all sets. The sets are changed so that all +/// file descriptors that are ready for the given operation are set. +/// +/// When this function returns, the original signal mask is restored. +/// +/// Unlike [`select`](#fn.select), `pselect` does not mutate the `timeout` value. +/// +/// # Parameters +/// +/// * `nfds`: The highest file descriptor set in any of the passed `FdSet`s, plus 1. If `None`, this +/// is calculated automatically by calling [`FdSet::highest`] on all descriptor sets and adding 1 +/// to the maximum of that. +/// * `readfds`: File descriptors to check for read readiness +/// * `writefds`: File descriptors to check for write readiness +/// * `errorfds`: File descriptors to check for pending error conditions. +/// * `timeout`: Maximum time to wait for descriptors to become ready (`None` to block +/// indefinitely). +/// * `sigmask`: Signal mask to activate while waiting for file descriptors to turn +/// ready (`None` to set no alternative signal mask). +/// +/// # References +/// +/// [pselect(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pselect.html) +/// +/// [The new pselect() system call](https://lwn.net/Articles/176911/) +/// +/// [`FdSet::highest`]: struct.FdSet.html#method.highest +pub fn pselect<'a, N, R, W, E, T, S>(nfds: N, + readfds: R, + writefds: W, + errorfds: E, + timeout: T, + sigmask: S) -> Result +where + N: Into>, + R: Into>, + W: Into>, + E: Into>, + T: Into>, + S: Into>, +{ + let mut readfds = readfds.into(); + let mut writefds = writefds.into(); + let mut errorfds = errorfds.into(); + let sigmask = sigmask.into(); + let timeout = timeout.into(); + + let nfds = nfds.into().unwrap_or_else(|| { + readfds.iter_mut() + .chain(writefds.iter_mut()) + .chain(errorfds.iter_mut()) + .map(|set| set.highest().unwrap_or(-1)) + .max() + .unwrap_or(-1) + 1 + }); + + let readfds = readfds.map(|set| set as *mut _ as *mut libc::fd_set).unwrap_or(null_mut()); + let writefds = writefds.map(|set| set as *mut _ as *mut libc::fd_set).unwrap_or(null_mut()); + let errorfds = errorfds.map(|set| set as *mut _ as *mut libc::fd_set).unwrap_or(null_mut()); + let timeout = timeout.map(|ts| ts.as_ref() as *const libc::timespec).unwrap_or(null()); + let sigmask = sigmask.map(|sm| sm.as_ref() as *const libc::sigset_t).unwrap_or(null()); + + let res = unsafe { + libc::pselect(nfds, readfds, writefds, errorfds, timeout, sigmask) + }; + + Errno::result(res) +} + + +#[cfg(test)] +mod tests { + use super::*; + use std::os::unix::io::RawFd; + use sys::time::{TimeVal, TimeValLike}; + use unistd::{write, pipe}; + + #[test] + fn fdset_insert() { + let mut fd_set = FdSet::new(); + + for i in 0..FD_SETSIZE { + assert!(!fd_set.contains(i as RawFd)); + } + + fd_set.insert(7); + + assert!(fd_set.contains(7)); + } + + #[test] + fn fdset_remove() { + let mut fd_set = FdSet::new(); + + for i in 0..FD_SETSIZE { + assert!(!fd_set.contains(i as RawFd)); + } + + fd_set.insert(7); + fd_set.remove(7); + + for i in 0..FD_SETSIZE { + assert!(!fd_set.contains(i as RawFd)); + } + } + + #[test] + fn fdset_clear() { + let mut fd_set = FdSet::new(); + fd_set.insert(1); + fd_set.insert((FD_SETSIZE / 2) as RawFd); + fd_set.insert((FD_SETSIZE - 1) as RawFd); + + fd_set.clear(); + + for i in 0..FD_SETSIZE { + assert!(!fd_set.contains(i as RawFd)); + } + } + + #[test] + fn fdset_highest() { + let mut set = FdSet::new(); + assert_eq!(set.highest(), None); + set.insert(0); + assert_eq!(set.highest(), Some(0)); + set.insert(90); + assert_eq!(set.highest(), Some(90)); + set.remove(0); + assert_eq!(set.highest(), Some(90)); + set.remove(90); + assert_eq!(set.highest(), None); + + set.insert(4); + set.insert(5); + set.insert(7); + assert_eq!(set.highest(), Some(7)); + } + + #[test] + fn test_select() { + let (r1, w1) = pipe().unwrap(); + write(w1, b"hi!").unwrap(); + let (r2, _w2) = pipe().unwrap(); + + let mut fd_set = FdSet::new(); + fd_set.insert(r1); + fd_set.insert(r2); + + let mut timeout = TimeVal::seconds(10); + assert_eq!(1, select(None, + &mut fd_set, + None, + None, + &mut timeout).unwrap()); + assert!(fd_set.contains(r1)); + assert!(!fd_set.contains(r2)); + } + + #[test] + fn test_select_nfds() { + let (r1, w1) = pipe().unwrap(); + write(w1, b"hi!").unwrap(); + let (r2, _w2) = pipe().unwrap(); + + let mut fd_set = FdSet::new(); + fd_set.insert(r1); + fd_set.insert(r2); + + let mut timeout = TimeVal::seconds(10); + assert_eq!(1, select(Some(fd_set.highest().unwrap() + 1), + &mut fd_set, + None, + None, + &mut timeout).unwrap()); + assert!(fd_set.contains(r1)); + assert!(!fd_set.contains(r2)); + } + + #[test] + fn test_select_nfds2() { + let (r1, w1) = pipe().unwrap(); + write(w1, b"hi!").unwrap(); + let (r2, _w2) = pipe().unwrap(); + + let mut fd_set = FdSet::new(); + fd_set.insert(r1); + fd_set.insert(r2); + + let mut timeout = TimeVal::seconds(10); + assert_eq!(1, select(::std::cmp::max(r1, r2) + 1, + &mut fd_set, + None, + None, + &mut timeout).unwrap()); + assert!(fd_set.contains(r1)); + assert!(!fd_set.contains(r2)); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/sendfile.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/sendfile.rs new file mode 100644 index 0000000..1190518 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/sendfile.rs @@ -0,0 +1,200 @@ +use std::os::unix::io::RawFd; +use std::ptr; + +use libc::{self, off_t}; + +use Result; +use errno::Errno; + +/// Copy up to `count` bytes to `out_fd` from `in_fd` starting at `offset`. +/// +/// Returns a `Result` with the number of bytes written. +/// +/// If `offset` is `None`, `sendfile` will begin reading at the current offset of `in_fd`and will +/// update the offset of `in_fd`. If `offset` is `Some`, `sendfile` will begin at the specified +/// offset and will not update the offset of `in_fd`. Instead, it will mutate `offset` to point to +/// the byte after the last byte copied. +/// +/// `in_fd` must support `mmap`-like operations and therefore cannot be a socket. +/// +/// For more information, see [the sendfile(2) man page.](http://man7.org/linux/man-pages/man2/sendfile.2.html) +#[cfg(any(target_os = "android", target_os = "linux"))] +pub fn sendfile( + out_fd: RawFd, + in_fd: RawFd, + offset: Option<&mut off_t>, + count: usize, +) -> Result { + let offset = offset + .map(|offset| offset as *mut _) + .unwrap_or(ptr::null_mut()); + let ret = unsafe { libc::sendfile(out_fd, in_fd, offset, count) }; + Errno::result(ret).map(|r| r as usize) +} + +cfg_if! { + if #[cfg(any(target_os = "freebsd", + target_os = "ios", + target_os = "macos"))] { + use sys::uio::IoVec; + + #[allow(missing_debug_implementations)] + struct SendfileHeaderTrailer<'a>( + libc::sf_hdtr, + Option>>, + Option>>, + ); + + impl<'a> SendfileHeaderTrailer<'a> { + fn new( + headers: Option<&'a [&'a [u8]]>, + trailers: Option<&'a [&'a [u8]]> + ) -> SendfileHeaderTrailer<'a> { + let header_iovecs: Option>> = + headers.map(|s| s.iter().map(|b| IoVec::from_slice(b)).collect()); + let trailer_iovecs: Option>> = + trailers.map(|s| s.iter().map(|b| IoVec::from_slice(b)).collect()); + SendfileHeaderTrailer( + libc::sf_hdtr { + headers: { + header_iovecs + .as_ref() + .map_or(ptr::null(), |v| v.as_ptr()) as *mut libc::iovec + }, + hdr_cnt: header_iovecs.as_ref().map(|v| v.len()).unwrap_or(0) as i32, + trailers: { + trailer_iovecs + .as_ref() + .map_or(ptr::null(), |v| v.as_ptr()) as *mut libc::iovec + }, + trl_cnt: trailer_iovecs.as_ref().map(|v| v.len()).unwrap_or(0) as i32 + }, + header_iovecs, + trailer_iovecs, + ) + } + } + } +} + +cfg_if! { + if #[cfg(target_os = "freebsd")] { + use libc::c_int; + + libc_bitflags!{ + /// Configuration options for [`sendfile`.](fn.sendfile.html) + pub struct SfFlags: c_int { + /// Causes `sendfile` to return EBUSY instead of blocking when attempting to read a + /// busy page. + SF_NODISKIO; + /// Causes `sendfile` to sleep until the network stack releases its reference to the + /// VM pages read. When `sendfile` returns, the data is not guaranteed to have been + /// sent, but it is safe to modify the file. + SF_SYNC; + /// Causes `sendfile` to cache exactly the number of pages specified in the + /// `readahead` parameter, disabling caching heuristics. + SF_USER_READAHEAD; + /// Causes `sendfile` not to cache the data read. + SF_NOCACHE; + } + } + + /// Read up to `count` bytes from `in_fd` starting at `offset` and write to `out_sock`. + /// + /// Returns a `Result` and a count of bytes written. Bytes written may be non-zero even if + /// an error occurs. + /// + /// `in_fd` must describe a regular file or shared memory object. `out_sock` must describe a + /// stream socket. + /// + /// If `offset` falls past the end of the file, the function returns success and zero bytes + /// written. + /// + /// If `count` is `None` or 0, bytes will be read from `in_fd` until reaching the end of + /// file (EOF). + /// + /// `headers` and `trailers` specify optional slices of byte slices to be sent before and + /// after the data read from `in_fd`, respectively. The length of headers and trailers sent + /// is included in the returned count of bytes written. The values of `offset` and `count` + /// do not apply to headers or trailers. + /// + /// `readahead` specifies the minimum number of pages to cache in memory ahead of the page + /// currently being sent. + /// + /// For more information, see + /// [the sendfile(2) man page.](https://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2) + pub fn sendfile( + in_fd: RawFd, + out_sock: RawFd, + offset: off_t, + count: Option, + headers: Option<&[&[u8]]>, + trailers: Option<&[&[u8]]>, + flags: SfFlags, + readahead: u16 + ) -> (Result<()>, off_t) { + // Readahead goes in upper 16 bits + // Flags goes in lower 16 bits + // see `man 2 sendfile` + let flags: u32 = ((readahead as u32) << 16) | (flags.bits() as u32); + let mut bytes_sent: off_t = 0; + let hdtr = headers.or(trailers).map(|_| SendfileHeaderTrailer::new(headers, trailers)); + let hdtr_ptr = hdtr.as_ref().map_or(ptr::null(), |s| &s.0 as *const libc::sf_hdtr); + let return_code = unsafe { + libc::sendfile(in_fd, + out_sock, + offset, + count.unwrap_or(0), + hdtr_ptr as *mut libc::sf_hdtr, + &mut bytes_sent as *mut off_t, + flags as c_int) + }; + (Errno::result(return_code).and(Ok(())), bytes_sent) + } + } else if #[cfg(any(target_os = "ios", target_os = "macos"))] { + /// Read bytes from `in_fd` starting at `offset` and write up to `count` bytes to + /// `out_sock`. + /// + /// Returns a `Result` and a count of bytes written. Bytes written may be non-zero even if + /// an error occurs. + /// + /// `in_fd` must describe a regular file. `out_sock` must describe a stream socket. + /// + /// If `offset` falls past the end of the file, the function returns success and zero bytes + /// written. + /// + /// If `count` is `None` or 0, bytes will be read from `in_fd` until reaching the end of + /// file (EOF). + /// + /// `hdtr` specifies an optional list of headers and trailers to be sent before and after + /// the data read from `in_fd`, respectively. The length of headers and trailers sent is + /// included in the returned count of bytes written. If any headers are specified and + /// `count` is non-zero, the length of the headers will be counted in the limit of total + /// bytes sent. Trailers do not count toward the limit of bytes sent and will always be sent + /// regardless. The value of `offset` does not affect headers or trailers. + /// + /// For more information, see + /// [the sendfile(2) man page.](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man2/sendfile.2.html) + pub fn sendfile( + in_fd: RawFd, + out_sock: RawFd, + offset: off_t, + count: Option, + headers: Option<&[&[u8]]>, + trailers: Option<&[&[u8]]> + ) -> (Result<()>, off_t) { + let mut len = count.unwrap_or(0); + let hdtr = headers.or(trailers).map(|_| SendfileHeaderTrailer::new(headers, trailers)); + let hdtr_ptr = hdtr.as_ref().map_or(ptr::null(), |s| &s.0 as *const libc::sf_hdtr); + let return_code = unsafe { + libc::sendfile(in_fd, + out_sock, + offset, + &mut len as *mut off_t, + hdtr_ptr as *mut libc::sf_hdtr, + 0) + }; + (Errno::result(return_code).and(Ok(())), len) + } + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/signal.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/signal.rs new file mode 100644 index 0000000..a49b273 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/signal.rs @@ -0,0 +1,992 @@ +// Portions of this file are Copyright 2014 The Rust Project Developers. +// See http://rust-lang.org/COPYRIGHT. + +///! Operating system signals. + +use libc; +use {Error, Result}; +use errno::Errno; +use std::mem; +use std::fmt; +use std::str::FromStr; +#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] +use std::os::unix::io::RawFd; +use std::ptr; + +#[cfg(not(target_os = "openbsd"))] +pub use self::sigevent::*; + +libc_enum!{ + // Currently there is only one definition of c_int in libc, as well as only one + // type for signal constants. + // We would prefer to use the libc::c_int alias in the repr attribute. Unfortunately + // this is not (yet) possible. + #[repr(i32)] + pub enum Signal { + SIGHUP, + SIGINT, + SIGQUIT, + SIGILL, + SIGTRAP, + SIGABRT, + SIGBUS, + SIGFPE, + SIGKILL, + SIGUSR1, + SIGSEGV, + SIGUSR2, + SIGPIPE, + SIGALRM, + SIGTERM, + #[cfg(all(any(target_os = "android", target_os = "emscripten", target_os = "linux"), + not(any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc64"))))] + SIGSTKFLT, + SIGCHLD, + SIGCONT, + SIGSTOP, + SIGTSTP, + SIGTTIN, + SIGTTOU, + SIGURG, + SIGXCPU, + SIGXFSZ, + SIGVTALRM, + SIGPROF, + SIGWINCH, + SIGIO, + #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))] + SIGPWR, + SIGSYS, + #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + SIGEMT, + #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + SIGINFO, + } +} + +impl FromStr for Signal { + type Err = Error; + fn from_str(s: &str) -> Result { + Ok(match s { + "SIGHUP" => Signal::SIGHUP, + "SIGINT" => Signal::SIGINT, + "SIGQUIT" => Signal::SIGQUIT, + "SIGILL" => Signal::SIGILL, + "SIGTRAP" => Signal::SIGTRAP, + "SIGABRT" => Signal::SIGABRT, + "SIGBUS" => Signal::SIGBUS, + "SIGFPE" => Signal::SIGFPE, + "SIGKILL" => Signal::SIGKILL, + "SIGUSR1" => Signal::SIGUSR1, + "SIGSEGV" => Signal::SIGSEGV, + "SIGUSR2" => Signal::SIGUSR2, + "SIGPIPE" => Signal::SIGPIPE, + "SIGALRM" => Signal::SIGALRM, + "SIGTERM" => Signal::SIGTERM, + #[cfg(all(any(target_os = "android", target_os = "emscripten", target_os = "linux"), + not(any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc64"))))] + "SIGSTKFLT" => Signal::SIGSTKFLT, + "SIGCHLD" => Signal::SIGCHLD, + "SIGCONT" => Signal::SIGCONT, + "SIGSTOP" => Signal::SIGSTOP, + "SIGTSTP" => Signal::SIGTSTP, + "SIGTTIN" => Signal::SIGTTIN, + "SIGTTOU" => Signal::SIGTTOU, + "SIGURG" => Signal::SIGURG, + "SIGXCPU" => Signal::SIGXCPU, + "SIGXFSZ" => Signal::SIGXFSZ, + "SIGVTALRM" => Signal::SIGVTALRM, + "SIGPROF" => Signal::SIGPROF, + "SIGWINCH" => Signal::SIGWINCH, + "SIGIO" => Signal::SIGIO, + #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))] + "SIGPWR" => Signal::SIGPWR, + "SIGSYS" => Signal::SIGSYS, + #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + "SIGEMT" => Signal::SIGEMT, + #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + "SIGINFO" => Signal::SIGINFO, + _ => return Err(Error::invalid_argument()), + }) + } +} + +impl AsRef for Signal { + fn as_ref(&self) -> &str { + match *self { + Signal::SIGHUP => "SIGHUP", + Signal::SIGINT => "SIGINT", + Signal::SIGQUIT => "SIGQUIT", + Signal::SIGILL => "SIGILL", + Signal::SIGTRAP => "SIGTRAP", + Signal::SIGABRT => "SIGABRT", + Signal::SIGBUS => "SIGBUS", + Signal::SIGFPE => "SIGFPE", + Signal::SIGKILL => "SIGKILL", + Signal::SIGUSR1 => "SIGUSR1", + Signal::SIGSEGV => "SIGSEGV", + Signal::SIGUSR2 => "SIGUSR2", + Signal::SIGPIPE => "SIGPIPE", + Signal::SIGALRM => "SIGALRM", + Signal::SIGTERM => "SIGTERM", + #[cfg(all(any(target_os = "android", target_os = "emscripten", target_os = "linux"), + not(any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc64"))))] + Signal::SIGSTKFLT => "SIGSTKFLT", + Signal::SIGCHLD => "SIGCHLD", + Signal::SIGCONT => "SIGCONT", + Signal::SIGSTOP => "SIGSTOP", + Signal::SIGTSTP => "SIGTSTP", + Signal::SIGTTIN => "SIGTTIN", + Signal::SIGTTOU => "SIGTTOU", + Signal::SIGURG => "SIGURG", + Signal::SIGXCPU => "SIGXCPU", + Signal::SIGXFSZ => "SIGXFSZ", + Signal::SIGVTALRM => "SIGVTALRM", + Signal::SIGPROF => "SIGPROF", + Signal::SIGWINCH => "SIGWINCH", + Signal::SIGIO => "SIGIO", + #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))] + Signal::SIGPWR => "SIGPWR", + Signal::SIGSYS => "SIGSYS", + #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + Signal::SIGEMT => "SIGEMT", + #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + Signal::SIGINFO => "SIGINFO", + } + } +} + +impl fmt::Display for Signal { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(self.as_ref()) + } +} + +pub use self::Signal::*; + +#[cfg(all(any(target_os = "linux", target_os = "android", target_os = "emscripten"), not(any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc64"))))] +const SIGNALS: [Signal; 31] = [ + SIGHUP, + SIGINT, + SIGQUIT, + SIGILL, + SIGTRAP, + SIGABRT, + SIGBUS, + SIGFPE, + SIGKILL, + SIGUSR1, + SIGSEGV, + SIGUSR2, + SIGPIPE, + SIGALRM, + SIGTERM, + SIGSTKFLT, + SIGCHLD, + SIGCONT, + SIGSTOP, + SIGTSTP, + SIGTTIN, + SIGTTOU, + SIGURG, + SIGXCPU, + SIGXFSZ, + SIGVTALRM, + SIGPROF, + SIGWINCH, + SIGIO, + SIGPWR, + SIGSYS]; +#[cfg(all(any(target_os = "linux", target_os = "android", target_os = "emscripten"), any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc64")))] +const SIGNALS: [Signal; 30] = [ + SIGHUP, + SIGINT, + SIGQUIT, + SIGILL, + SIGTRAP, + SIGABRT, + SIGBUS, + SIGFPE, + SIGKILL, + SIGUSR1, + SIGSEGV, + SIGUSR2, + SIGPIPE, + SIGALRM, + SIGTERM, + SIGCHLD, + SIGCONT, + SIGSTOP, + SIGTSTP, + SIGTTIN, + SIGTTOU, + SIGURG, + SIGXCPU, + SIGXFSZ, + SIGVTALRM, + SIGPROF, + SIGWINCH, + SIGIO, + SIGPWR, + SIGSYS]; +#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "emscripten")))] +const SIGNALS: [Signal; 31] = [ + SIGHUP, + SIGINT, + SIGQUIT, + SIGILL, + SIGTRAP, + SIGABRT, + SIGBUS, + SIGFPE, + SIGKILL, + SIGUSR1, + SIGSEGV, + SIGUSR2, + SIGPIPE, + SIGALRM, + SIGTERM, + SIGCHLD, + SIGCONT, + SIGSTOP, + SIGTSTP, + SIGTTIN, + SIGTTOU, + SIGURG, + SIGXCPU, + SIGXFSZ, + SIGVTALRM, + SIGPROF, + SIGWINCH, + SIGIO, + SIGSYS, + SIGEMT, + SIGINFO]; + +pub const NSIG: libc::c_int = 32; + +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct SignalIterator { + next: usize, +} + +impl Iterator for SignalIterator { + type Item = Signal; + + fn next(&mut self) -> Option { + if self.next < SIGNALS.len() { + let next_signal = SIGNALS[self.next]; + self.next += 1; + Some(next_signal) + } else { + None + } + } +} + +impl Signal { + pub fn iterator() -> SignalIterator { + SignalIterator{next: 0} + } + + // We do not implement the From trait, because it is supposed to be infallible. + // With Rust RFC 1542 comes the appropriate trait TryFrom. Once it is + // implemented, we'll replace this function. + #[inline] + pub fn from_c_int(signum: libc::c_int) -> Result { + if 0 < signum && signum < NSIG { + Ok(unsafe { mem::transmute(signum) }) + } else { + Err(Error::invalid_argument()) + } + } +} + +pub const SIGIOT : Signal = SIGABRT; +pub const SIGPOLL : Signal = SIGIO; +pub const SIGUNUSED : Signal = SIGSYS; + +libc_bitflags!{ + pub struct SaFlags: libc::c_int { + SA_NOCLDSTOP; + SA_NOCLDWAIT; + SA_NODEFER; + SA_ONSTACK; + SA_RESETHAND; + SA_RESTART; + SA_SIGINFO; + } +} + +libc_enum! { + #[repr(i32)] + pub enum SigmaskHow { + SIG_BLOCK, + SIG_UNBLOCK, + SIG_SETMASK, + } +} + +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct SigSet { + sigset: libc::sigset_t +} + + +impl SigSet { + pub fn all() -> SigSet { + let mut sigset: libc::sigset_t = unsafe { mem::uninitialized() }; + let _ = unsafe { libc::sigfillset(&mut sigset as *mut libc::sigset_t) }; + + SigSet { sigset: sigset } + } + + pub fn empty() -> SigSet { + let mut sigset: libc::sigset_t = unsafe { mem::uninitialized() }; + let _ = unsafe { libc::sigemptyset(&mut sigset as *mut libc::sigset_t) }; + + SigSet { sigset: sigset } + } + + pub fn add(&mut self, signal: Signal) { + unsafe { libc::sigaddset(&mut self.sigset as *mut libc::sigset_t, signal as libc::c_int) }; + } + + pub fn clear(&mut self) { + unsafe { libc::sigemptyset(&mut self.sigset as *mut libc::sigset_t) }; + } + + pub fn remove(&mut self, signal: Signal) { + unsafe { libc::sigdelset(&mut self.sigset as *mut libc::sigset_t, signal as libc::c_int) }; + } + + pub fn contains(&self, signal: Signal) -> bool { + let res = unsafe { libc::sigismember(&self.sigset as *const libc::sigset_t, signal as libc::c_int) }; + + match res { + 1 => true, + 0 => false, + _ => unreachable!("unexpected value from sigismember"), + } + } + + pub fn extend(&mut self, other: &SigSet) { + for signal in Signal::iterator() { + if other.contains(signal) { + self.add(signal); + } + } + } + + /// Gets the currently blocked (masked) set of signals for the calling thread. + pub fn thread_get_mask() -> Result { + let mut oldmask: SigSet = unsafe { mem::uninitialized() }; + pthread_sigmask(SigmaskHow::SIG_SETMASK, None, Some(&mut oldmask))?; + Ok(oldmask) + } + + /// Sets the set of signals as the signal mask for the calling thread. + pub fn thread_set_mask(&self) -> Result<()> { + pthread_sigmask(SigmaskHow::SIG_SETMASK, Some(self), None) + } + + /// Adds the set of signals to the signal mask for the calling thread. + pub fn thread_block(&self) -> Result<()> { + pthread_sigmask(SigmaskHow::SIG_BLOCK, Some(self), None) + } + + /// Removes the set of signals from the signal mask for the calling thread. + pub fn thread_unblock(&self) -> Result<()> { + pthread_sigmask(SigmaskHow::SIG_UNBLOCK, Some(self), None) + } + + /// Sets the set of signals as the signal mask, and returns the old mask. + pub fn thread_swap_mask(&self, how: SigmaskHow) -> Result { + let mut oldmask: SigSet = unsafe { mem::uninitialized() }; + pthread_sigmask(how, Some(self), Some(&mut oldmask))?; + Ok(oldmask) + } + + /// Suspends execution of the calling thread until one of the signals in the + /// signal mask becomes pending, and returns the accepted signal. + pub fn wait(&self) -> Result { + let mut signum: libc::c_int = unsafe { mem::uninitialized() }; + let res = unsafe { libc::sigwait(&self.sigset as *const libc::sigset_t, &mut signum) }; + + Errno::result(res).map(|_| Signal::from_c_int(signum).unwrap()) + } +} + +impl AsRef for SigSet { + fn as_ref(&self) -> &libc::sigset_t { + &self.sigset + } +} + +/// A signal handler. +#[allow(unknown_lints)] +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum SigHandler { + /// Default signal handling. + SigDfl, + /// Request that the signal be ignored. + SigIgn, + /// Use the given signal-catching function, which takes in the signal. + Handler(extern fn(libc::c_int)), + /// Use the given signal-catching function, which takes in the signal, information about how + /// the signal was generated, and a pointer to the threads `ucontext_t`. + SigAction(extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void)) +} + +/// Action to take on receipt of a signal. Corresponds to `sigaction`. +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct SigAction { + sigaction: libc::sigaction +} + +impl SigAction { + /// Creates a new action. + /// + /// The `SA_SIGINFO` bit in the `flags` argument is ignored (it will be set only if `handler` + /// is the `SigAction` variant). `mask` specifies other signals to block during execution of + /// the signal-catching function. + pub fn new(handler: SigHandler, flags: SaFlags, mask: SigSet) -> SigAction { + let mut s = unsafe { mem::uninitialized::() }; + s.sa_sigaction = match handler { + SigHandler::SigDfl => libc::SIG_DFL, + SigHandler::SigIgn => libc::SIG_IGN, + SigHandler::Handler(f) => f as *const extern fn(libc::c_int) as usize, + SigHandler::SigAction(f) => f as *const extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void) as usize, + }; + s.sa_flags = match handler { + SigHandler::SigAction(_) => (flags | SaFlags::SA_SIGINFO).bits(), + _ => (flags - SaFlags::SA_SIGINFO).bits(), + }; + s.sa_mask = mask.sigset; + + SigAction { sigaction: s } + } + + /// Returns the flags set on the action. + pub fn flags(&self) -> SaFlags { + SaFlags::from_bits_truncate(self.sigaction.sa_flags) + } + + /// Returns the set of signals that are blocked during execution of the action's + /// signal-catching function. + pub fn mask(&self) -> SigSet { + SigSet { sigset: self.sigaction.sa_mask } + } + + /// Returns the action's handler. + pub fn handler(&self) -> SigHandler { + match self.sigaction.sa_sigaction { + libc::SIG_DFL => SigHandler::SigDfl, + libc::SIG_IGN => SigHandler::SigIgn, + f if self.flags().contains(SaFlags::SA_SIGINFO) => + SigHandler::SigAction( unsafe { mem::transmute(f) } ), + f => SigHandler::Handler( unsafe { mem::transmute(f) } ), + } + } +} + +/// Changes the action taken by a process on receipt of a specific signal. +/// +/// `signal` can be any signal except `SIGKILL` or `SIGSTOP`. On success, it returns the previous +/// action for the given signal. If `sigaction` fails, no new signal handler is installed. +/// +/// # Safety +/// +/// Signal handlers may be called at any point during execution, which limits what is safe to do in +/// the body of the signal-catching function. Be certain to only make syscalls that are explicitly +/// marked safe for signal handlers and only share global data using atomics. +pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result { + let mut oldact = mem::uninitialized::(); + + let res = + libc::sigaction(signal as libc::c_int, &sigaction.sigaction as *const libc::sigaction, &mut oldact as *mut libc::sigaction); + + Errno::result(res).map(|_| SigAction { sigaction: oldact }) +} + +/// Signal management (see [signal(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/signal.html)) +/// +/// Installs `handler` for the given `signal`, returning the previous signal +/// handler. `signal` should only be used following another call to `signal` or +/// if the current handler is the default. The return value of `signal` is +/// undefined after setting the handler with [`sigaction`][SigActionFn]. +/// +/// # Safety +/// +/// If the pointer to the previous signal handler is invalid, undefined +/// behavior could be invoked when casting it back to a [`SigAction`][SigActionStruct]. +/// +/// # Examples +/// +/// Ignore `SIGINT`: +/// +/// ```no_run +/// # use nix::sys::signal::{self, Signal, SigHandler}; +/// unsafe { signal::signal(Signal::SIGINT, SigHandler::SigIgn) }.unwrap(); +/// ``` +/// +/// Use a signal handler to set a flag variable: +/// +/// ```no_run +/// # #[macro_use] extern crate lazy_static; +/// # extern crate libc; +/// # extern crate nix; +/// # use std::sync::atomic::{AtomicBool, Ordering}; +/// # use nix::sys::signal::{self, Signal, SigHandler}; +/// lazy_static! { +/// static ref SIGNALED: AtomicBool = AtomicBool::new(false); +/// } +/// +/// extern fn handle_sigint(signal: libc::c_int) { +/// let signal = Signal::from_c_int(signal).unwrap(); +/// SIGNALED.store(signal == Signal::SIGINT, Ordering::Relaxed); +/// } +/// +/// fn main() { +/// let handler = SigHandler::Handler(handle_sigint); +/// unsafe { signal::signal(Signal::SIGINT, handler) }.unwrap(); +/// } +/// ``` +/// +/// # Errors +/// +/// Returns [`Error::UnsupportedOperation`] if `handler` is +/// [`SigAction`][SigActionStruct]. Use [`sigaction`][SigActionFn] instead. +/// +/// `signal` also returns any error from `libc::signal`, such as when an attempt +/// is made to catch a signal that cannot be caught or to ignore a signal that +/// cannot be ignored. +/// +/// [`Error::UnsupportedOperation`]: ../../enum.Error.html#variant.UnsupportedOperation +/// [SigActionStruct]: struct.SigAction.html +/// [sigactionFn]: fn.sigaction.html +pub unsafe fn signal(signal: Signal, handler: SigHandler) -> Result { + let signal = signal as libc::c_int; + let res = match handler { + SigHandler::SigDfl => libc::signal(signal, libc::SIG_DFL), + SigHandler::SigIgn => libc::signal(signal, libc::SIG_IGN), + SigHandler::Handler(handler) => libc::signal(signal, handler as libc::sighandler_t), + SigHandler::SigAction(_) => return Err(Error::UnsupportedOperation), + }; + Errno::result(res).map(|oldhandler| { + match oldhandler { + libc::SIG_DFL => SigHandler::SigDfl, + libc::SIG_IGN => SigHandler::SigIgn, + f => SigHandler::Handler(mem::transmute(f)), + } + }) +} + +/// Manages the signal mask (set of blocked signals) for the calling thread. +/// +/// If the `set` parameter is `Some(..)`, then the signal mask will be updated with the signal set. +/// The `how` flag decides the type of update. If `set` is `None`, `how` will be ignored, +/// and no modification will take place. +/// +/// If the 'oldset' parameter is `Some(..)` then the current signal mask will be written into it. +/// +/// If both `set` and `oldset` is `Some(..)`, the current signal mask will be written into oldset, +/// and then it will be updated with `set`. +/// +/// If both `set` and `oldset` is None, this function is a no-op. +/// +/// For more information, visit the [`pthread_sigmask`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html), +/// or [`sigprocmask`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigprocmask.html) man pages. +pub fn pthread_sigmask(how: SigmaskHow, + set: Option<&SigSet>, + oldset: Option<&mut SigSet>) -> Result<()> { + if set.is_none() && oldset.is_none() { + return Ok(()) + } + + let res = unsafe { + // if set or oldset is None, pass in null pointers instead + libc::pthread_sigmask(how as libc::c_int, + set.map_or_else(ptr::null::, + |s| &s.sigset as *const libc::sigset_t), + oldset.map_or_else(ptr::null_mut::, + |os| &mut os.sigset as *mut libc::sigset_t)) + }; + + Errno::result(res).map(drop) +} + +/// Examine and change blocked signals. +/// +/// For more informations see the [`sigprocmask` man +/// pages](http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigprocmask.html). +pub fn sigprocmask(how: SigmaskHow, set: Option<&SigSet>, oldset: Option<&mut SigSet>) -> Result<()> { + if set.is_none() && oldset.is_none() { + return Ok(()) + } + + let res = unsafe { + // if set or oldset is None, pass in null pointers instead + libc::sigprocmask(how as libc::c_int, + set.map_or_else(ptr::null::, + |s| &s.sigset as *const libc::sigset_t), + oldset.map_or_else(ptr::null_mut::, + |os| &mut os.sigset as *mut libc::sigset_t)) + }; + + Errno::result(res).map(drop) +} + +pub fn kill>>(pid: ::unistd::Pid, signal: T) -> Result<()> { + let res = unsafe { libc::kill(pid.into(), + match signal.into() { + Some(s) => s as libc::c_int, + None => 0, + }) }; + + Errno::result(res).map(drop) +} + +/// Send a signal to a process group [(see +/// killpg(3))](http://pubs.opengroup.org/onlinepubs/9699919799/functions/killpg.html). +/// +/// If `pgrp` less then or equal 1, the behavior is platform-specific. +/// If `signal` is `None`, `killpg` will only preform error checking and won't +/// send any signal. +pub fn killpg>>(pgrp: ::unistd::Pid, signal: T) -> Result<()> { + let res = unsafe { libc::killpg(pgrp.into(), + match signal.into() { + Some(s) => s as libc::c_int, + None => 0, + }) }; + + Errno::result(res).map(drop) +} + +pub fn raise(signal: Signal) -> Result<()> { + let res = unsafe { libc::raise(signal as libc::c_int) }; + + Errno::result(res).map(drop) +} + + +#[cfg(target_os = "freebsd")] +pub type type_of_thread_id = libc::lwpid_t; +#[cfg(target_os = "linux")] +pub type type_of_thread_id = libc::pid_t; + +/// Used to request asynchronous notification of certain events, for example, +/// with POSIX AIO, POSIX message queues, and POSIX timers. +// sigval is actually a union of a int and a void*. But it's never really used +// as a pointer, because neither libc nor the kernel ever dereference it. nix +// therefore presents it as an intptr_t, which is how kevent uses it. +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum SigevNotify { + /// No notification will be delivered + SigevNone, + /// The signal given by `signal` will be delivered to the process. The + /// value in `si_value` will be present in the `si_value` field of the + /// `siginfo_t` structure of the queued signal. + SigevSignal { signal: Signal, si_value: libc::intptr_t }, + // Note: SIGEV_THREAD is not implemented because libc::sigevent does not + // expose a way to set the union members needed by SIGEV_THREAD. + /// A new `kevent` is posted to the kqueue `kq`. The `kevent`'s `udata` + /// field will contain the value in `udata`. + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + SigevKevent { kq: RawFd, udata: libc::intptr_t }, + /// The signal `signal` is queued to the thread whose LWP ID is given in + /// `thread_id`. The value stored in `si_value` will be present in the + /// `si_value` of the `siginfo_t` structure of the queued signal. + #[cfg(any(target_os = "freebsd", target_os = "linux"))] + SigevThreadId { signal: Signal, thread_id: type_of_thread_id, + si_value: libc::intptr_t }, +} + +#[cfg(not(target_os = "openbsd"))] +mod sigevent { + use libc; + use std::mem; + use std::ptr; + use std::fmt::{self, Debug}; + use super::SigevNotify; + #[cfg(any(target_os = "freebsd", target_os = "linux"))] + use super::type_of_thread_id; + + /// Used to request asynchronous notification of the completion of certain + /// events, such as POSIX AIO and timers. + #[repr(C)] + #[derive(Clone, Copy)] + pub struct SigEvent { + sigevent: libc::sigevent + } + + impl SigEvent { + /// **Note:** this constructor does not allow the user to set the + /// `sigev_notify_kevent_flags` field. That's considered ok because on FreeBSD + /// at least those flags don't do anything useful. That field is part of a + /// union that shares space with the more genuinely useful fields. + /// + /// **Note:** This constructor also doesn't allow the caller to set the + /// `sigev_notify_function` or `sigev_notify_attributes` fields, which are + /// required for `SIGEV_THREAD`. That's considered ok because on no operating + /// system is `SIGEV_THREAD` the most efficient way to deliver AIO + /// notification. FreeBSD and DragonFly BSD programs should prefer `SIGEV_KEVENT`. + /// Linux, Solaris, and portable programs should prefer `SIGEV_THREAD_ID` or + /// `SIGEV_SIGNAL`. That field is part of a union that shares space with the + /// more genuinely useful `sigev_notify_thread_id` + pub fn new(sigev_notify: SigevNotify) -> SigEvent { + let mut sev = unsafe { mem::zeroed::()}; + sev.sigev_notify = match sigev_notify { + SigevNotify::SigevNone => libc::SIGEV_NONE, + SigevNotify::SigevSignal{..} => libc::SIGEV_SIGNAL, + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + SigevNotify::SigevKevent{..} => libc::SIGEV_KEVENT, + #[cfg(target_os = "freebsd")] + SigevNotify::SigevThreadId{..} => libc::SIGEV_THREAD_ID, + #[cfg(all(target_os = "linux", target_env = "gnu", not(target_arch = "mips")))] + SigevNotify::SigevThreadId{..} => libc::SIGEV_THREAD_ID, + #[cfg(any(all(target_os = "linux", target_env = "musl"), target_arch = "mips"))] + SigevNotify::SigevThreadId{..} => 4 // No SIGEV_THREAD_ID defined + }; + sev.sigev_signo = match sigev_notify { + SigevNotify::SigevSignal{ signal, .. } => signal as libc::c_int, + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + SigevNotify::SigevKevent{ kq, ..} => kq, + #[cfg(any(target_os = "linux", target_os = "freebsd"))] + SigevNotify::SigevThreadId{ signal, .. } => signal as libc::c_int, + _ => 0 + }; + sev.sigev_value.sival_ptr = match sigev_notify { + SigevNotify::SigevNone => ptr::null_mut::(), + SigevNotify::SigevSignal{ si_value, .. } => si_value as *mut libc::c_void, + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + SigevNotify::SigevKevent{ udata, .. } => udata as *mut libc::c_void, + #[cfg(any(target_os = "freebsd", target_os = "linux"))] + SigevNotify::SigevThreadId{ si_value, .. } => si_value as *mut libc::c_void, + }; + SigEvent::set_tid(&mut sev, &sigev_notify); + SigEvent{sigevent: sev} + } + + #[cfg(any(target_os = "freebsd", target_os = "linux"))] + fn set_tid(sev: &mut libc::sigevent, sigev_notify: &SigevNotify) { + sev.sigev_notify_thread_id = match *sigev_notify { + SigevNotify::SigevThreadId { thread_id, .. } => thread_id, + _ => 0 as type_of_thread_id + }; + } + + #[cfg(not(any(target_os = "freebsd", target_os = "linux")))] + fn set_tid(_sev: &mut libc::sigevent, _sigev_notify: &SigevNotify) { + } + + pub fn sigevent(&self) -> libc::sigevent { + self.sigevent + } + } + + impl Debug for SigEvent { + #[cfg(any(target_os = "freebsd", target_os = "linux"))] + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("SigEvent") + .field("sigev_notify", &self.sigevent.sigev_notify) + .field("sigev_signo", &self.sigevent.sigev_signo) + .field("sigev_value", &self.sigevent.sigev_value.sival_ptr) + .field("sigev_notify_thread_id", + &self.sigevent.sigev_notify_thread_id) + .finish() + } + + #[cfg(not(any(target_os = "freebsd", target_os = "linux")))] + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("SigEvent") + .field("sigev_notify", &self.sigevent.sigev_notify) + .field("sigev_signo", &self.sigevent.sigev_signo) + .field("sigev_value", &self.sigevent.sigev_value.sival_ptr) + .finish() + } + } + + impl<'a> From<&'a libc::sigevent> for SigEvent { + fn from(sigevent: &libc::sigevent) -> Self { + SigEvent{ sigevent: *sigevent } + } + } +} + +#[cfg(test)] +mod tests { + use std::thread; + use super::*; + + #[test] + fn test_contains() { + let mut mask = SigSet::empty(); + mask.add(SIGUSR1); + + assert!(mask.contains(SIGUSR1)); + assert!(!mask.contains(SIGUSR2)); + + let all = SigSet::all(); + assert!(all.contains(SIGUSR1)); + assert!(all.contains(SIGUSR2)); + } + + #[test] + fn test_clear() { + let mut set = SigSet::all(); + set.clear(); + for signal in Signal::iterator() { + assert!(!set.contains(signal)); + } + } + + #[test] + fn test_from_str_round_trips() { + for signal in Signal::iterator() { + assert_eq!(signal.as_ref().parse::().unwrap(), signal); + assert_eq!(signal.to_string().parse::().unwrap(), signal); + } + } + + #[test] + fn test_from_str_invalid_value() { + let errval = Err(Error::Sys(Errno::EINVAL)); + assert_eq!("NOSIGNAL".parse::(), errval); + assert_eq!("kill".parse::(), errval); + assert_eq!("9".parse::(), errval); + } + + #[test] + fn test_extend() { + let mut one_signal = SigSet::empty(); + one_signal.add(SIGUSR1); + + let mut two_signals = SigSet::empty(); + two_signals.add(SIGUSR2); + two_signals.extend(&one_signal); + + assert!(two_signals.contains(SIGUSR1)); + assert!(two_signals.contains(SIGUSR2)); + } + + #[test] + fn test_thread_signal_set_mask() { + thread::spawn(|| { + let prev_mask = SigSet::thread_get_mask() + .expect("Failed to get existing signal mask!"); + + let mut test_mask = prev_mask; + test_mask.add(SIGUSR1); + + assert!(test_mask.thread_set_mask().is_ok()); + let new_mask = SigSet::thread_get_mask() + .expect("Failed to get new mask!"); + + assert!(new_mask.contains(SIGUSR1)); + assert!(!new_mask.contains(SIGUSR2)); + + prev_mask.thread_set_mask().expect("Failed to revert signal mask!"); + }).join().unwrap(); + } + + #[test] + fn test_thread_signal_block() { + thread::spawn(|| { + let mut mask = SigSet::empty(); + mask.add(SIGUSR1); + + assert!(mask.thread_block().is_ok()); + + assert!(SigSet::thread_get_mask().unwrap().contains(SIGUSR1)); + }).join().unwrap(); + } + + #[test] + fn test_thread_signal_unblock() { + thread::spawn(|| { + let mut mask = SigSet::empty(); + mask.add(SIGUSR1); + + assert!(mask.thread_unblock().is_ok()); + + assert!(!SigSet::thread_get_mask().unwrap().contains(SIGUSR1)); + }).join().unwrap(); + } + + #[test] + fn test_thread_signal_swap() { + thread::spawn(|| { + let mut mask = SigSet::empty(); + mask.add(SIGUSR1); + mask.thread_block().unwrap(); + + assert!(SigSet::thread_get_mask().unwrap().contains(SIGUSR1)); + + let mut mask2 = SigSet::empty(); + mask2.add(SIGUSR2); + + let oldmask = mask2.thread_swap_mask(SigmaskHow::SIG_SETMASK) + .unwrap(); + + assert!(oldmask.contains(SIGUSR1)); + assert!(!oldmask.contains(SIGUSR2)); + + assert!(SigSet::thread_get_mask().unwrap().contains(SIGUSR2)); + }).join().unwrap(); + } + + #[test] + fn test_sigaction() { + use libc; + thread::spawn(|| { + extern fn test_sigaction_handler(_: libc::c_int) {} + extern fn test_sigaction_action(_: libc::c_int, + _: *mut libc::siginfo_t, _: *mut libc::c_void) {} + + let handler_sig = SigHandler::Handler(test_sigaction_handler); + + let flags = SaFlags::SA_ONSTACK | SaFlags::SA_RESTART | + SaFlags::SA_SIGINFO; + + let mut mask = SigSet::empty(); + mask.add(SIGUSR1); + + let action_sig = SigAction::new(handler_sig, flags, mask); + + assert_eq!(action_sig.flags(), + SaFlags::SA_ONSTACK | SaFlags::SA_RESTART); + assert_eq!(action_sig.handler(), handler_sig); + + mask = action_sig.mask(); + assert!(mask.contains(SIGUSR1)); + assert!(!mask.contains(SIGUSR2)); + + let handler_act = SigHandler::SigAction(test_sigaction_action); + let action_act = SigAction::new(handler_act, flags, mask); + assert_eq!(action_act.handler(), handler_act); + + let action_dfl = SigAction::new(SigHandler::SigDfl, flags, mask); + assert_eq!(action_dfl.handler(), SigHandler::SigDfl); + + let action_ign = SigAction::new(SigHandler::SigIgn, flags, mask); + assert_eq!(action_ign.handler(), SigHandler::SigIgn); + }).join().unwrap(); + } + + #[test] + fn test_sigwait() { + thread::spawn(|| { + let mut mask = SigSet::empty(); + mask.add(SIGUSR1); + mask.add(SIGUSR2); + mask.thread_block().unwrap(); + + raise(SIGUSR1).unwrap(); + assert_eq!(mask.wait().unwrap(), SIGUSR1); + }).join().unwrap(); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/signalfd.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/signalfd.rs new file mode 100644 index 0000000..5425a27 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/signalfd.rs @@ -0,0 +1,170 @@ +//! Interface for the `signalfd` syscall. +//! +//! # Signal discarding +//! When a signal can't be delivered to a process (or thread), it will become a pending signal. +//! Failure to deliver could happen if the signal is blocked by every thread in the process or if +//! the signal handler is still handling a previous signal. +//! +//! If a signal is sent to a process (or thread) that already has a pending signal of the same +//! type, it will be discarded. This means that if signals of the same type are received faster than +//! they are processed, some of those signals will be dropped. Because of this limitation, +//! `signalfd` in itself cannot be used for reliable communication between processes or threads. +//! +//! Once the signal is unblocked, or the signal handler is finished, and a signal is still pending +//! (ie. not consumed from a signalfd) it will be delivered to the signal handler. +//! +//! Please note that signal discarding is not specific to `signalfd`, but also happens with regular +//! signal handlers. +use libc; +use unistd; +use {Error, Result}; +use errno::Errno; +pub use sys::signal::{self, SigSet}; +pub use libc::signalfd_siginfo as siginfo; + +use std::os::unix::io::{RawFd, AsRawFd}; +use std::mem; + + +libc_bitflags!{ + pub struct SfdFlags: libc::c_int { + SFD_NONBLOCK; + SFD_CLOEXEC; + } +} + +pub const SIGNALFD_NEW: RawFd = -1; +pub const SIGNALFD_SIGINFO_SIZE: usize = 128; + +/// Creates a new file descriptor for reading signals. +/// +/// **Important:** please read the module level documentation about signal discarding before using +/// this function! +/// +/// The `mask` parameter specifies the set of signals that can be accepted via this file descriptor. +/// +/// A signal must be blocked on every thread in a process, otherwise it won't be visible from +/// signalfd (the default handler will be invoked instead). +/// +/// See [the signalfd man page for more information](http://man7.org/linux/man-pages/man2/signalfd.2.html) +pub fn signalfd(fd: RawFd, mask: &SigSet, flags: SfdFlags) -> Result { + unsafe { + Errno::result(libc::signalfd(fd as libc::c_int, mask.as_ref(), flags.bits())) + } +} + +/// A helper struct for creating, reading and closing a `signalfd` instance. +/// +/// **Important:** please read the module level documentation about signal discarding before using +/// this struct! +/// +/// # Examples +/// +/// ``` +/// # use nix::sys::signalfd::*; +/// // Set the thread to block the SIGUSR1 signal, otherwise the default handler will be used +/// let mut mask = SigSet::empty(); +/// mask.add(signal::SIGUSR1); +/// mask.thread_block().unwrap(); +/// +/// // Signals are queued up on the file descriptor +/// let mut sfd = SignalFd::with_flags(&mask, SfdFlags::SFD_NONBLOCK).unwrap(); +/// +/// match sfd.read_signal() { +/// // we caught a signal +/// Ok(Some(sig)) => (), +/// // there were no signals waiting (only happens when the SFD_NONBLOCK flag is set, +/// // otherwise the read_signal call blocks) +/// Ok(None) => (), +/// Err(err) => (), // some error happend +/// } +/// ``` +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct SignalFd(RawFd); + +impl SignalFd { + pub fn new(mask: &SigSet) -> Result { + Self::with_flags(mask, SfdFlags::empty()) + } + + pub fn with_flags(mask: &SigSet, flags: SfdFlags) -> Result { + let fd = signalfd(SIGNALFD_NEW, mask, flags)?; + + Ok(SignalFd(fd)) + } + + pub fn set_mask(&mut self, mask: &SigSet) -> Result<()> { + signalfd(self.0, mask, SfdFlags::empty()).map(drop) + } + + pub fn read_signal(&mut self) -> Result> { + let mut buffer: [u8; SIGNALFD_SIGINFO_SIZE] = unsafe { mem::uninitialized() }; + + match unistd::read(self.0, &mut buffer) { + Ok(SIGNALFD_SIGINFO_SIZE) => Ok(Some(unsafe { mem::transmute(buffer) })), + Ok(_) => unreachable!("partial read on signalfd"), + Err(Error::Sys(Errno::EAGAIN)) => Ok(None), + Err(error) => Err(error) + } + } +} + +impl Drop for SignalFd { + fn drop(&mut self) { + let _ = unistd::close(self.0); + } +} + +impl AsRawFd for SignalFd { + fn as_raw_fd(&self) -> RawFd { + self.0 + } +} + +impl Iterator for SignalFd { + type Item = siginfo; + + fn next(&mut self) -> Option { + match self.read_signal() { + Ok(Some(sig)) => Some(sig), + Ok(None) | Err(_) => None, + } + } +} + + +#[cfg(test)] +mod tests { + use super::*; + use std::mem; + use libc; + + + #[test] + fn check_siginfo_size() { + assert_eq!(mem::size_of::(), SIGNALFD_SIGINFO_SIZE); + } + + #[test] + fn create_signalfd() { + let mask = SigSet::empty(); + let fd = SignalFd::new(&mask); + assert!(fd.is_ok()); + } + + #[test] + fn create_signalfd_with_opts() { + let mask = SigSet::empty(); + let fd = SignalFd::with_flags(&mask, SfdFlags::SFD_CLOEXEC | SfdFlags::SFD_NONBLOCK); + assert!(fd.is_ok()); + } + + #[test] + fn read_empty_signalfd() { + let mask = SigSet::empty(); + let mut fd = SignalFd::with_flags(&mask, SfdFlags::SFD_NONBLOCK).unwrap(); + + let res = fd.read_signal(); + assert!(res.unwrap().is_none()); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/socket/addr.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/socket/addr.rs new file mode 100644 index 0000000..fc24bd7 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/socket/addr.rs @@ -0,0 +1,1487 @@ +use super::sa_family_t; +use {Error, Result, NixPath}; +use errno::Errno; +use libc; +use std::{fmt, hash, mem, net, ptr, slice}; +use std::ffi::OsStr; +use std::path::Path; +use std::os::unix::ffi::OsStrExt; +#[cfg(any(target_os = "android", target_os = "linux"))] +use ::sys::socket::addr::netlink::NetlinkAddr; +#[cfg(any(target_os = "android", target_os = "linux"))] +use ::sys::socket::addr::alg::AlgAddr; +#[cfg(any(target_os = "ios", target_os = "macos"))] +use std::os::unix::io::RawFd; +#[cfg(any(target_os = "ios", target_os = "macos"))] +use ::sys::socket::addr::sys_control::SysControlAddr; +#[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +pub use self::datalink::LinkAddr; + +/// These constants specify the protocol family to be used +/// in [`socket`](fn.socket.html) and [`socketpair`](fn.socketpair.html) +#[repr(i32)] +#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] +pub enum AddressFamily { + /// Local communication (see [`unix(7)`](http://man7.org/linux/man-pages/man7/unix.7.html)) + Unix = libc::AF_UNIX, + /// IPv4 Internet protocols (see [`ip(7)`](http://man7.org/linux/man-pages/man7/ip.7.html)) + Inet = libc::AF_INET, + /// IPv6 Internet protocols (see [`ipv6(7)`](http://man7.org/linux/man-pages/man7/ipv6.7.html)) + Inet6 = libc::AF_INET6, + /// Kernel user interface device (see [`netlink(7)`](http://man7.org/linux/man-pages/man7/netlink.7.html)) + #[cfg(any(target_os = "android", target_os = "linux"))] + Netlink = libc::AF_NETLINK, + /// Low level packet interface (see [`packet(7)`](http://man7.org/linux/man-pages/man7/packet.7.html)) + #[cfg(any(target_os = "android", target_os = "linux"))] + Packet = libc::AF_PACKET, + /// KEXT Controls and Notifications + #[cfg(any(target_os = "ios", target_os = "macos"))] + System = libc::AF_SYSTEM, + /// Amateur radio AX.25 protocol + #[cfg(any(target_os = "android", target_os = "linux"))] + Ax25 = libc::AF_AX25, + /// IPX - Novell protocols + Ipx = libc::AF_IPX, + /// AppleTalk + AppleTalk = libc::AF_APPLETALK, + #[cfg(any(target_os = "android", target_os = "linux"))] + NetRom = libc::AF_NETROM, + #[cfg(any(target_os = "android", target_os = "linux"))] + Bridge = libc::AF_BRIDGE, + /// Access to raw ATM PVCs + #[cfg(any(target_os = "android", target_os = "linux"))] + AtmPvc = libc::AF_ATMPVC, + /// ITU-T X.25 / ISO-8208 protocol (see [`x25(7)`](http://man7.org/linux/man-pages/man7/x25.7.html)) + #[cfg(any(target_os = "android", target_os = "linux"))] + X25 = libc::AF_X25, + #[cfg(any(target_os = "android", target_os = "linux"))] + Rose = libc::AF_ROSE, + Decnet = libc::AF_DECnet, + #[cfg(any(target_os = "android", target_os = "linux"))] + NetBeui = libc::AF_NETBEUI, + #[cfg(any(target_os = "android", target_os = "linux"))] + Security = libc::AF_SECURITY, + #[cfg(any(target_os = "android", target_os = "linux"))] + Key = libc::AF_KEY, + #[cfg(any(target_os = "android", target_os = "linux"))] + Ash = libc::AF_ASH, + #[cfg(any(target_os = "android", target_os = "linux"))] + Econet = libc::AF_ECONET, + #[cfg(any(target_os = "android", target_os = "linux"))] + AtmSvc = libc::AF_ATMSVC, + #[cfg(any(target_os = "android", target_os = "linux"))] + Rds = libc::AF_RDS, + Sna = libc::AF_SNA, + #[cfg(any(target_os = "android", target_os = "linux"))] + Irda = libc::AF_IRDA, + #[cfg(any(target_os = "android", target_os = "linux"))] + Pppox = libc::AF_PPPOX, + #[cfg(any(target_os = "android", target_os = "linux"))] + Wanpipe = libc::AF_WANPIPE, + #[cfg(any(target_os = "android", target_os = "linux"))] + Llc = libc::AF_LLC, + #[cfg(target_os = "linux")] + Ib = libc::AF_IB, + #[cfg(target_os = "linux")] + Mpls = libc::AF_MPLS, + #[cfg(any(target_os = "android", target_os = "linux"))] + Can = libc::AF_CAN, + #[cfg(any(target_os = "android", target_os = "linux"))] + Tipc = libc::AF_TIPC, + #[cfg(not(any(target_os = "ios", target_os = "macos")))] + Bluetooth = libc::AF_BLUETOOTH, + #[cfg(any(target_os = "android", target_os = "linux"))] + Iucv = libc::AF_IUCV, + #[cfg(any(target_os = "android", target_os = "linux"))] + RxRpc = libc::AF_RXRPC, + Isdn = libc::AF_ISDN, + #[cfg(any(target_os = "android", target_os = "linux"))] + Phonet = libc::AF_PHONET, + #[cfg(any(target_os = "android", target_os = "linux"))] + Ieee802154 = libc::AF_IEEE802154, + #[cfg(any(target_os = "android", target_os = "linux"))] + Caif = libc::AF_CAIF, + /// Interface to kernel crypto API + #[cfg(any(target_os = "android", target_os = "linux"))] + Alg = libc::AF_ALG, + #[cfg(target_os = "linux")] + Nfc = libc::AF_NFC, + #[cfg(target_os = "linux")] + Vsock = libc::AF_VSOCK, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + ImpLink = libc::AF_IMPLINK, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Pup = libc::AF_PUP, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Chaos = libc::AF_CHAOS, + #[cfg(any(target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Ns = libc::AF_NS, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Iso = libc::AF_ISO, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Datakit = libc::AF_DATAKIT, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Ccitt = libc::AF_CCITT, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Dli = libc::AF_DLI, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Lat = libc::AF_LAT, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Hylink = libc::AF_HYLINK, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Link = libc::AF_LINK, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Coip = libc::AF_COIP, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Cnt = libc::AF_CNT, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Natm = libc::AF_NATM, + /// Unspecified address family, (see [`getaddrinfo(3)`](http://man7.org/linux/man-pages/man3/getaddrinfo.3.html)) + #[cfg(any(target_os = "android", target_os = "linux"))] + Unspec = libc::AF_UNSPEC, +} + +impl AddressFamily { + /// Create a new `AddressFamily` from an integer value retrieved from `libc`, usually from + /// the `sa_family` field of a `sockaddr`. + /// + /// Currently only supports these address families: Unix, Inet (v4 & v6), Netlink, Link/Packet + /// and System. Returns None for unsupported or unknown address families. + pub fn from_i32(family: i32) -> Option { + match family { + libc::AF_UNIX => Some(AddressFamily::Unix), + libc::AF_INET => Some(AddressFamily::Inet), + libc::AF_INET6 => Some(AddressFamily::Inet6), + #[cfg(any(target_os = "android", target_os = "linux"))] + libc::AF_NETLINK => Some(AddressFamily::Netlink), + #[cfg(any(target_os = "macos", target_os = "macos"))] + libc::AF_SYSTEM => Some(AddressFamily::System), + #[cfg(any(target_os = "android", target_os = "linux"))] + libc::AF_PACKET => Some(AddressFamily::Packet), + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + libc::AF_LINK => Some(AddressFamily::Link), + _ => None + } + } +} + +#[derive(Copy)] +pub enum InetAddr { + V4(libc::sockaddr_in), + V6(libc::sockaddr_in6), +} + +impl InetAddr { + pub fn from_std(std: &net::SocketAddr) -> InetAddr { + match *std { + net::SocketAddr::V4(ref addr) => { + InetAddr::V4(libc::sockaddr_in { + sin_family: AddressFamily::Inet as sa_family_t, + sin_port: addr.port().to_be(), // network byte order + sin_addr: Ipv4Addr::from_std(addr.ip()).0, + .. unsafe { mem::zeroed() } + }) + } + net::SocketAddr::V6(ref addr) => { + InetAddr::V6(libc::sockaddr_in6 { + sin6_family: AddressFamily::Inet6 as sa_family_t, + sin6_port: addr.port().to_be(), // network byte order + sin6_addr: Ipv6Addr::from_std(addr.ip()).0, + sin6_flowinfo: addr.flowinfo(), // host byte order + sin6_scope_id: addr.scope_id(), // host byte order + .. unsafe { mem::zeroed() } + }) + } + } + } + + pub fn new(ip: IpAddr, port: u16) -> InetAddr { + match ip { + IpAddr::V4(ref ip) => { + InetAddr::V4(libc::sockaddr_in { + sin_family: AddressFamily::Inet as sa_family_t, + sin_port: port.to_be(), + sin_addr: ip.0, + .. unsafe { mem::zeroed() } + }) + } + IpAddr::V6(ref ip) => { + InetAddr::V6(libc::sockaddr_in6 { + sin6_family: AddressFamily::Inet6 as sa_family_t, + sin6_port: port.to_be(), + sin6_addr: ip.0, + .. unsafe { mem::zeroed() } + }) + } + } + } + /// Gets the IP address associated with this socket address. + pub fn ip(&self) -> IpAddr { + match *self { + InetAddr::V4(ref sa) => IpAddr::V4(Ipv4Addr(sa.sin_addr)), + InetAddr::V6(ref sa) => IpAddr::V6(Ipv6Addr(sa.sin6_addr)), + } + } + + /// Gets the port number associated with this socket address + pub fn port(&self) -> u16 { + match *self { + InetAddr::V6(ref sa) => u16::from_be(sa.sin6_port), + InetAddr::V4(ref sa) => u16::from_be(sa.sin_port), + } + } + + pub fn to_std(&self) -> net::SocketAddr { + match *self { + InetAddr::V4(ref sa) => net::SocketAddr::V4( + net::SocketAddrV4::new( + Ipv4Addr(sa.sin_addr).to_std(), + self.port())), + InetAddr::V6(ref sa) => net::SocketAddr::V6( + net::SocketAddrV6::new( + Ipv6Addr(sa.sin6_addr).to_std(), + self.port(), + sa.sin6_flowinfo, + sa.sin6_scope_id)), + } + } + + pub fn to_str(&self) -> String { + format!("{}", self) + } +} + +impl PartialEq for InetAddr { + fn eq(&self, other: &InetAddr) -> bool { + match (*self, *other) { + (InetAddr::V4(ref a), InetAddr::V4(ref b)) => { + a.sin_port == b.sin_port && + a.sin_addr.s_addr == b.sin_addr.s_addr + } + (InetAddr::V6(ref a), InetAddr::V6(ref b)) => { + a.sin6_port == b.sin6_port && + a.sin6_addr.s6_addr == b.sin6_addr.s6_addr && + a.sin6_flowinfo == b.sin6_flowinfo && + a.sin6_scope_id == b.sin6_scope_id + } + _ => false, + } + } +} + +impl Eq for InetAddr { +} + +impl hash::Hash for InetAddr { + fn hash(&self, s: &mut H) { + match *self { + InetAddr::V4(ref a) => { + ( a.sin_family, + a.sin_port, + a.sin_addr.s_addr ).hash(s) + } + InetAddr::V6(ref a) => { + ( a.sin6_family, + a.sin6_port, + &a.sin6_addr.s6_addr, + a.sin6_flowinfo, + a.sin6_scope_id ).hash(s) + } + } + } +} + +impl Clone for InetAddr { + fn clone(&self) -> InetAddr { + *self + } +} + +impl fmt::Display for InetAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + InetAddr::V4(_) => write!(f, "{}:{}", self.ip(), self.port()), + InetAddr::V6(_) => write!(f, "[{}]:{}", self.ip(), self.port()), + } + } +} + +impl fmt::Debug for InetAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +/* + * + * ===== IpAddr ===== + * + */ +#[derive(Clone, Copy)] +pub enum IpAddr { + V4(Ipv4Addr), + V6(Ipv6Addr), +} + +impl IpAddr { + /// Create a new IpAddr that contains an IPv4 address. + /// + /// The result will represent the IP address a.b.c.d + pub fn new_v4(a: u8, b: u8, c: u8, d: u8) -> IpAddr { + IpAddr::V4(Ipv4Addr::new(a, b, c, d)) + } + + /// Create a new IpAddr that contains an IPv6 address. + /// + /// The result will represent the IP address a:b:c:d:e:f + pub fn new_v6(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> IpAddr { + IpAddr::V6(Ipv6Addr::new(a, b, c, d, e, f, g, h)) + } + + pub fn from_std(std: &net::IpAddr) -> IpAddr { + match *std { + net::IpAddr::V4(ref std) => IpAddr::V4(Ipv4Addr::from_std(std)), + net::IpAddr::V6(ref std) => IpAddr::V6(Ipv6Addr::from_std(std)), + } + } + + pub fn to_std(&self) -> net::IpAddr { + match *self { + IpAddr::V4(ref ip) => net::IpAddr::V4(ip.to_std()), + IpAddr::V6(ref ip) => net::IpAddr::V6(ip.to_std()), + } + } +} + +impl fmt::Display for IpAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + IpAddr::V4(ref v4) => v4.fmt(f), + IpAddr::V6(ref v6) => v6.fmt(f) + } + } +} + +impl fmt::Debug for IpAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +/* + * + * ===== Ipv4Addr ===== + * + */ + +#[derive(Copy)] +pub struct Ipv4Addr(pub libc::in_addr); + +impl Ipv4Addr { + pub fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr { + let ip = (((a as u32) << 24) | + ((b as u32) << 16) | + ((c as u32) << 8) | + ((d as u32) << 0)).to_be(); + + Ipv4Addr(libc::in_addr { s_addr: ip }) + } + + pub fn from_std(std: &net::Ipv4Addr) -> Ipv4Addr { + let bits = std.octets(); + Ipv4Addr::new(bits[0], bits[1], bits[2], bits[3]) + } + + pub fn any() -> Ipv4Addr { + Ipv4Addr(libc::in_addr { s_addr: libc::INADDR_ANY }) + } + + pub fn octets(&self) -> [u8; 4] { + let bits = u32::from_be(self.0.s_addr); + [(bits >> 24) as u8, (bits >> 16) as u8, (bits >> 8) as u8, bits as u8] + } + + pub fn to_std(&self) -> net::Ipv4Addr { + let bits = self.octets(); + net::Ipv4Addr::new(bits[0], bits[1], bits[2], bits[3]) + } +} + +impl PartialEq for Ipv4Addr { + fn eq(&self, other: &Ipv4Addr) -> bool { + self.0.s_addr == other.0.s_addr + } +} + +impl Eq for Ipv4Addr { +} + +impl hash::Hash for Ipv4Addr { + fn hash(&self, s: &mut H) { + let saddr = self.0.s_addr; + saddr.hash(s) + } +} + +impl Clone for Ipv4Addr { + fn clone(&self) -> Ipv4Addr { + *self + } +} + +impl fmt::Display for Ipv4Addr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let octets = self.octets(); + write!(fmt, "{}.{}.{}.{}", octets[0], octets[1], octets[2], octets[3]) + } +} + +impl fmt::Debug for Ipv4Addr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +/* + * + * ===== Ipv6Addr ===== + * + */ + +#[derive(Clone, Copy)] +pub struct Ipv6Addr(pub libc::in6_addr); + +// Note that IPv6 addresses are stored in big endian order on all architectures. +// See https://tools.ietf.org/html/rfc1700 or consult your favorite search +// engine. + +macro_rules! to_u8_array { + ($($num:ident),*) => { + [ $(($num>>8) as u8, ($num&0xff) as u8,)* ] + } +} + +macro_rules! to_u16_array { + ($slf:ident, $($first:expr, $second:expr),*) => { + [$( (($slf.0.s6_addr[$first] as u16) << 8) + $slf.0.s6_addr[$second] as u16,)*] + } +} + +impl Ipv6Addr { + pub fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr { + let mut in6_addr_var: libc::in6_addr = unsafe{mem::uninitialized()}; + in6_addr_var.s6_addr = to_u8_array!(a,b,c,d,e,f,g,h); + Ipv6Addr(in6_addr_var) + } + + pub fn from_std(std: &net::Ipv6Addr) -> Ipv6Addr { + let s = std.segments(); + Ipv6Addr::new(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]) + } + + /// Return the eight 16-bit segments that make up this address + pub fn segments(&self) -> [u16; 8] { + to_u16_array!(self, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) + } + + pub fn to_std(&self) -> net::Ipv6Addr { + let s = self.segments(); + net::Ipv6Addr::new(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]) + } +} + +impl fmt::Display for Ipv6Addr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + self.to_std().fmt(fmt) + } +} + +impl fmt::Debug for Ipv6Addr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +/* + * + * ===== UnixAddr ===== + * + */ + +/// A wrapper around `sockaddr_un`. +/// +/// This also tracks the length of `sun_path` address (excluding +/// a terminating null), because it may not be null-terminated. For example, +/// unconnected and Linux abstract sockets are never null-terminated, and POSIX +/// does not require that `sun_len` include the terminating null even for normal +/// sockets. Note that the actual sockaddr length is greater by +/// `offset_of!(libc::sockaddr_un, sun_path)` +#[derive(Copy)] +pub struct UnixAddr(pub libc::sockaddr_un, pub usize); + +impl UnixAddr { + /// Create a new sockaddr_un representing a filesystem path. + pub fn new(path: &P) -> Result { + path.with_nix_path(|cstr| { + unsafe { + let mut ret = libc::sockaddr_un { + sun_family: AddressFamily::Unix as sa_family_t, + .. mem::zeroed() + }; + + let bytes = cstr.to_bytes(); + + if bytes.len() > ret.sun_path.len() { + return Err(Error::Sys(Errno::ENAMETOOLONG)); + } + + ptr::copy_nonoverlapping(bytes.as_ptr(), + ret.sun_path.as_mut_ptr() as *mut u8, + bytes.len()); + + Ok(UnixAddr(ret, bytes.len())) + } + })? + } + + /// Create a new `sockaddr_un` representing an address in the "abstract namespace". + /// + /// The leading null byte for the abstract namespace is automatically added; + /// thus the input `path` is expected to be the bare name, not null-prefixed. + /// This is a Linux-specific extension, primarily used to allow chrooted + /// processes to communicate with processes having a different filesystem view. + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn new_abstract(path: &[u8]) -> Result { + unsafe { + let mut ret = libc::sockaddr_un { + sun_family: AddressFamily::Unix as sa_family_t, + .. mem::zeroed() + }; + + if path.len() + 1 > ret.sun_path.len() { + return Err(Error::Sys(Errno::ENAMETOOLONG)); + } + + // Abstract addresses are represented by sun_path[0] == + // b'\0', so copy starting one byte in. + ptr::copy_nonoverlapping(path.as_ptr(), + ret.sun_path.as_mut_ptr().offset(1) as *mut u8, + path.len()); + + Ok(UnixAddr(ret, path.len() + 1)) + } + } + + fn sun_path(&self) -> &[u8] { + unsafe { slice::from_raw_parts(self.0.sun_path.as_ptr() as *const u8, self.1) } + } + + /// If this address represents a filesystem path, return that path. + pub fn path(&self) -> Option<&Path> { + if self.1 == 0 || self.0.sun_path[0] == 0 { + // unnamed or abstract + None + } else { + let p = self.sun_path(); + // POSIX only requires that `sun_len` be at least long enough to + // contain the pathname, and it need not be null-terminated. So we + // need to create a string that is the shorter of the + // null-terminated length or the full length. + let ptr = &self.0.sun_path as *const libc::c_char; + let reallen = unsafe { libc::strnlen(ptr, p.len()) }; + Some(Path::new(::from_bytes(&p[..reallen]))) + } + } + + /// If this address represents an abstract socket, return its name. + /// + /// For abstract sockets only the bare name is returned, without the + /// leading null byte. `None` is returned for unnamed or path-backed sockets. + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn as_abstract(&self) -> Option<&[u8]> { + if self.1 >= 1 && self.0.sun_path[0] == 0 { + Some(&self.sun_path()[1..]) + } else { + // unnamed or filesystem path + None + } + } +} + +impl PartialEq for UnixAddr { + fn eq(&self, other: &UnixAddr) -> bool { + self.sun_path() == other.sun_path() + } +} + +impl Eq for UnixAddr { +} + +impl hash::Hash for UnixAddr { + fn hash(&self, s: &mut H) { + ( self.0.sun_family, self.sun_path() ).hash(s) + } +} + +impl Clone for UnixAddr { + fn clone(&self) -> UnixAddr { + *self + } +} + +impl fmt::Display for UnixAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.1 == 0 { + f.write_str("") + } else if let Some(path) = self.path() { + path.display().fmt(f) + } else { + let display = String::from_utf8_lossy(&self.sun_path()[1..]); + write!(f, "@{}", display) + } + } +} + +impl fmt::Debug for UnixAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +/* + * + * ===== Sock addr ===== + * + */ + +/// Represents a socket address +#[derive(Copy, Debug)] +pub enum SockAddr { + Inet(InetAddr), + Unix(UnixAddr), + #[cfg(any(target_os = "android", target_os = "linux"))] + Netlink(NetlinkAddr), + #[cfg(any(target_os = "android", target_os = "linux"))] + Alg(AlgAddr), + #[cfg(any(target_os = "ios", target_os = "macos"))] + SysControl(SysControlAddr), + /// Datalink address (MAC) + #[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Link(LinkAddr) +} + +impl SockAddr { + pub fn new_inet(addr: InetAddr) -> SockAddr { + SockAddr::Inet(addr) + } + + pub fn new_unix(path: &P) -> Result { + Ok(SockAddr::Unix(UnixAddr::new(path)?)) + } + + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn new_netlink(pid: u32, groups: u32) -> SockAddr { + SockAddr::Netlink(NetlinkAddr::new(pid, groups)) + } + + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn new_alg(alg_type: &str, alg_name: &str) -> SockAddr { + SockAddr::Alg(AlgAddr::new(alg_type, alg_name)) + } + + #[cfg(any(target_os = "ios", target_os = "macos"))] + pub fn new_sys_control(sockfd: RawFd, name: &str, unit: u32) -> Result { + SysControlAddr::from_name(sockfd, name, unit).map(|a| SockAddr::SysControl(a)) + } + + pub fn family(&self) -> AddressFamily { + match *self { + SockAddr::Inet(InetAddr::V4(..)) => AddressFamily::Inet, + SockAddr::Inet(InetAddr::V6(..)) => AddressFamily::Inet6, + SockAddr::Unix(..) => AddressFamily::Unix, + #[cfg(any(target_os = "android", target_os = "linux"))] + SockAddr::Netlink(..) => AddressFamily::Netlink, + #[cfg(any(target_os = "android", target_os = "linux"))] + SockAddr::Alg(..) => AddressFamily::Alg, + #[cfg(any(target_os = "ios", target_os = "macos"))] + SockAddr::SysControl(..) => AddressFamily::System, + #[cfg(any(target_os = "android", target_os = "linux"))] + SockAddr::Link(..) => AddressFamily::Packet, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + SockAddr::Link(..) => AddressFamily::Link + } + } + + pub fn to_str(&self) -> String { + format!("{}", self) + } + + /// Creates a `SockAddr` struct from libc's sockaddr. + /// + /// Supports only the following address families: Unix, Inet (v4 & v6), Netlink and System. + /// Returns None for unsupported families. + pub unsafe fn from_libc_sockaddr(addr: *const libc::sockaddr) -> Option { + if addr.is_null() { + None + } else { + match AddressFamily::from_i32((*addr).sa_family as i32) { + Some(AddressFamily::Unix) => None, + Some(AddressFamily::Inet) => Some(SockAddr::Inet( + InetAddr::V4(*(addr as *const libc::sockaddr_in)))), + Some(AddressFamily::Inet6) => Some(SockAddr::Inet( + InetAddr::V6(*(addr as *const libc::sockaddr_in6)))), + #[cfg(any(target_os = "android", target_os = "linux"))] + Some(AddressFamily::Netlink) => Some(SockAddr::Netlink( + NetlinkAddr(*(addr as *const libc::sockaddr_nl)))), + #[cfg(any(target_os = "ios", target_os = "macos"))] + Some(AddressFamily::System) => Some(SockAddr::SysControl( + SysControlAddr(*(addr as *const libc::sockaddr_ctl)))), + #[cfg(any(target_os = "android", target_os = "linux"))] + Some(AddressFamily::Packet) => Some(SockAddr::Link( + LinkAddr(*(addr as *const libc::sockaddr_ll)))), + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + Some(AddressFamily::Link) => { + let ether_addr = LinkAddr(*(addr as *const libc::sockaddr_dl)); + if ether_addr.is_empty() { + None + } else { + Some(SockAddr::Link(ether_addr)) + } + }, + // Other address families are currently not supported and simply yield a None + // entry instead of a proper conversion to a `SockAddr`. + Some(_) | None => None, + } + } + } + + /// Conversion from nix's SockAddr type to the underlying libc sockaddr type. + /// + /// This is useful for interfacing with other libc functions that don't yet have nix wrappers. + /// Returns a reference to the underlying data type (as a sockaddr reference) along + /// with the size of the actual data type. sockaddr is commonly used as a proxy for + /// a superclass as C doesn't support inheritance, so many functions that take + /// a sockaddr * need to take the size of the underlying type as well and then internally cast it back. + pub unsafe fn as_ffi_pair(&self) -> (&libc::sockaddr, libc::socklen_t) { + match *self { + SockAddr::Inet(InetAddr::V4(ref addr)) => (mem::transmute(addr), mem::size_of::() as libc::socklen_t), + SockAddr::Inet(InetAddr::V6(ref addr)) => (mem::transmute(addr), mem::size_of::() as libc::socklen_t), + SockAddr::Unix(UnixAddr(ref addr, len)) => (mem::transmute(addr), (len + offset_of!(libc::sockaddr_un, sun_path)) as libc::socklen_t), + #[cfg(any(target_os = "android", target_os = "linux"))] + SockAddr::Netlink(NetlinkAddr(ref sa)) => (mem::transmute(sa), mem::size_of::() as libc::socklen_t), + #[cfg(any(target_os = "android", target_os = "linux"))] + SockAddr::Alg(AlgAddr(ref sa)) => (mem::transmute(sa), mem::size_of::() as libc::socklen_t), + #[cfg(any(target_os = "ios", target_os = "macos"))] + SockAddr::SysControl(SysControlAddr(ref sa)) => (mem::transmute(sa), mem::size_of::() as libc::socklen_t), + #[cfg(any(target_os = "android", target_os = "linux"))] + SockAddr::Link(LinkAddr(ref ether_addr)) => (mem::transmute(ether_addr), mem::size_of::() as libc::socklen_t), + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + SockAddr::Link(LinkAddr(ref ether_addr)) => (mem::transmute(ether_addr), mem::size_of::() as libc::socklen_t), + } + } +} + +impl PartialEq for SockAddr { + fn eq(&self, other: &SockAddr) -> bool { + match (*self, *other) { + (SockAddr::Inet(ref a), SockAddr::Inet(ref b)) => { + a == b + } + (SockAddr::Unix(ref a), SockAddr::Unix(ref b)) => { + a == b + } + #[cfg(any(target_os = "android", target_os = "linux"))] + (SockAddr::Netlink(ref a), SockAddr::Netlink(ref b)) => { + a == b + } + #[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + (SockAddr::Link(ref a), SockAddr::Link(ref b)) => { + a == b + } + _ => false, + } + } +} + +impl Eq for SockAddr { +} + +impl hash::Hash for SockAddr { + fn hash(&self, s: &mut H) { + match *self { + SockAddr::Inet(ref a) => a.hash(s), + SockAddr::Unix(ref a) => a.hash(s), + #[cfg(any(target_os = "android", target_os = "linux"))] + SockAddr::Netlink(ref a) => a.hash(s), + #[cfg(any(target_os = "android", target_os = "linux"))] + SockAddr::Alg(ref a) => a.hash(s), + #[cfg(any(target_os = "ios", target_os = "macos"))] + SockAddr::SysControl(ref a) => a.hash(s), + #[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + SockAddr::Link(ref ether_addr) => ether_addr.hash(s) + } + } +} + +impl Clone for SockAddr { + fn clone(&self) -> SockAddr { + *self + } +} + +impl fmt::Display for SockAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + SockAddr::Inet(ref inet) => inet.fmt(f), + SockAddr::Unix(ref unix) => unix.fmt(f), + #[cfg(any(target_os = "android", target_os = "linux"))] + SockAddr::Netlink(ref nl) => nl.fmt(f), + #[cfg(any(target_os = "android", target_os = "linux"))] + SockAddr::Alg(ref nl) => nl.fmt(f), + #[cfg(any(target_os = "ios", target_os = "macos"))] + SockAddr::SysControl(ref sc) => sc.fmt(f), + #[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + SockAddr::Link(ref ether_addr) => ether_addr.fmt(f) + } + } +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub mod netlink { + use ::sys::socket::addr::AddressFamily; + use libc::{sa_family_t, sockaddr_nl}; + use std::{fmt, mem}; + use std::hash::{Hash, Hasher}; + + #[derive(Copy, Clone)] + pub struct NetlinkAddr(pub sockaddr_nl); + + // , PartialEq, Eq, Debug, Hash + impl PartialEq for NetlinkAddr { + fn eq(&self, other: &Self) -> bool { + let (inner, other) = (self.0, other.0); + (inner.nl_family, inner.nl_pid, inner.nl_groups) == + (other.nl_family, other.nl_pid, other.nl_groups) + } + } + + impl Eq for NetlinkAddr {} + + impl Hash for NetlinkAddr { + fn hash(&self, s: &mut H) { + let inner = self.0; + (inner.nl_family, inner.nl_pid, inner.nl_groups).hash(s); + } + } + + + impl NetlinkAddr { + pub fn new(pid: u32, groups: u32) -> NetlinkAddr { + let mut addr: sockaddr_nl = unsafe { mem::zeroed() }; + addr.nl_family = AddressFamily::Netlink as sa_family_t; + addr.nl_pid = pid; + addr.nl_groups = groups; + + NetlinkAddr(addr) + } + + pub fn pid(&self) -> u32 { + self.0.nl_pid + } + + pub fn groups(&self) -> u32 { + self.0.nl_groups + } + } + + impl fmt::Display for NetlinkAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "pid: {} groups: {}", self.pid(), self.groups()) + } + } + + impl fmt::Debug for NetlinkAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } + } +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub mod alg { + use libc::{AF_ALG, sockaddr_alg, c_char}; + use std::{fmt, mem, str}; + use std::hash::{Hash, Hasher}; + use std::ffi::CStr; + + #[derive(Copy, Clone)] + pub struct AlgAddr(pub sockaddr_alg); + + // , PartialEq, Eq, Debug, Hash + impl PartialEq for AlgAddr { + fn eq(&self, other: &Self) -> bool { + let (inner, other) = (self.0, other.0); + (inner.salg_family, &inner.salg_type[..], inner.salg_feat, inner.salg_mask, &inner.salg_name[..]) == + (other.salg_family, &other.salg_type[..], other.salg_feat, other.salg_mask, &other.salg_name[..]) + } + } + + impl Eq for AlgAddr {} + + impl Hash for AlgAddr { + fn hash(&self, s: &mut H) { + let inner = self.0; + (inner.salg_family, &inner.salg_type[..], inner.salg_feat, inner.salg_mask, &inner.salg_name[..]).hash(s); + } + } + + impl AlgAddr { + pub fn new(alg_type: &str, alg_name: &str) -> AlgAddr { + let mut addr: sockaddr_alg = unsafe { mem::zeroed() }; + addr.salg_family = AF_ALG as u16; + addr.salg_type[..alg_type.len()].copy_from_slice(alg_type.to_string().as_bytes()); + addr.salg_name[..alg_name.len()].copy_from_slice(alg_name.to_string().as_bytes()); + + AlgAddr(addr) + } + + + pub fn alg_type(&self) -> &CStr { + unsafe { CStr::from_ptr(self.0.salg_type.as_ptr() as *const c_char) } + } + + pub fn alg_name(&self) -> &CStr { + unsafe { CStr::from_ptr(self.0.salg_name.as_ptr() as *const c_char) } + } + } + + impl fmt::Display for AlgAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "type: {} alg: {}", + self.alg_name().to_string_lossy(), + self.alg_type().to_string_lossy()) + } + } + + impl fmt::Debug for AlgAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } + } +} + +#[cfg(any(target_os = "ios", target_os = "macos"))] +pub mod sys_control { + use ::sys::socket::addr::AddressFamily; + use libc::{self, c_uchar}; + use std::{fmt, mem}; + use std::hash::{Hash, Hasher}; + use std::os::unix::io::RawFd; + use {Errno, Error, Result}; + + #[repr(C)] + pub struct ctl_ioc_info { + pub ctl_id: u32, + pub ctl_name: [c_uchar; MAX_KCTL_NAME], + } + + const CTL_IOC_MAGIC: u8 = 'N' as u8; + const CTL_IOC_INFO: u8 = 3; + const MAX_KCTL_NAME: usize = 96; + + ioctl_readwrite!(ctl_info, CTL_IOC_MAGIC, CTL_IOC_INFO, ctl_ioc_info); + + #[derive(Copy, Clone)] + #[repr(C)] + pub struct SysControlAddr(pub libc::sockaddr_ctl); + + impl PartialEq for SysControlAddr { + fn eq(&self, other: &Self) -> bool { + let (inner, other) = (self.0, other.0); + (inner.sc_id, inner.sc_unit) == + (other.sc_id, other.sc_unit) + } + } + + impl Eq for SysControlAddr {} + + impl Hash for SysControlAddr { + fn hash(&self, s: &mut H) { + let inner = self.0; + (inner.sc_id, inner.sc_unit).hash(s); + } + } + + + impl SysControlAddr { + pub fn new(id: u32, unit: u32) -> SysControlAddr { + let addr = libc::sockaddr_ctl { + sc_len: mem::size_of::() as c_uchar, + sc_family: AddressFamily::System as c_uchar, + ss_sysaddr: libc::AF_SYS_CONTROL as u16, + sc_id: id, + sc_unit: unit, + sc_reserved: [0; 5] + }; + + SysControlAddr(addr) + } + + pub fn from_name(sockfd: RawFd, name: &str, unit: u32) -> Result { + if name.len() > MAX_KCTL_NAME { + return Err(Error::Sys(Errno::ENAMETOOLONG)); + } + + let mut ctl_name = [0; MAX_KCTL_NAME]; + ctl_name[..name.len()].clone_from_slice(name.as_bytes()); + let mut info = ctl_ioc_info { ctl_id: 0, ctl_name: ctl_name }; + + unsafe { ctl_info(sockfd, &mut info)?; } + + Ok(SysControlAddr::new(info.ctl_id, unit)) + } + + pub fn id(&self) -> u32 { + self.0.sc_id + } + + pub fn unit(&self) -> u32 { + self.0.sc_unit + } + } + + impl fmt::Display for SysControlAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(self, f) + } + } + + impl fmt::Debug for SysControlAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("SysControlAddr") + .field("sc_len", &self.0.sc_len) + .field("sc_family", &self.0.sc_family) + .field("ss_sysaddr", &self.0.ss_sysaddr) + .field("sc_id", &self.0.sc_id) + .field("sc_unit", &self.0.sc_unit) + .finish() + } + } +} + + +#[cfg(any(target_os = "android", target_os = "linux"))] +mod datalink { + use super::{libc, hash, fmt, AddressFamily}; + + /// Hardware Address + #[derive(Clone, Copy)] + pub struct LinkAddr(pub libc::sockaddr_ll); + + impl LinkAddr { + /// Always AF_PACKET + pub fn family(&self) -> AddressFamily { + assert_eq!(self.0.sll_family as i32, libc::AF_PACKET); + AddressFamily::Packet + } + + /// Physical-layer protocol + pub fn protocol(&self) -> u16 { + self.0.sll_protocol + } + + /// Interface number + pub fn ifindex(&self) -> usize { + self.0.sll_ifindex as usize + } + + /// ARP hardware type + pub fn hatype(&self) -> u16 { + self.0.sll_hatype + } + + /// Packet type + pub fn pkttype(&self) -> u8 { + self.0.sll_pkttype + } + + /// Length of MAC address + pub fn halen(&self) -> usize { + self.0.sll_halen as usize + } + + /// Physical-layer address (MAC) + pub fn addr(&self) -> [u8; 6] { + let a = self.0.sll_addr[0] as u8; + let b = self.0.sll_addr[1] as u8; + let c = self.0.sll_addr[2] as u8; + let d = self.0.sll_addr[3] as u8; + let e = self.0.sll_addr[4] as u8; + let f = self.0.sll_addr[5] as u8; + + [a, b, c, d, e, f] + } + } + + impl Eq for LinkAddr {} + + impl PartialEq for LinkAddr { + fn eq(&self, other: &Self) -> bool { + let (a, b) = (self.0, other.0); + (a.sll_family, a.sll_protocol, a.sll_ifindex, a.sll_hatype, + a.sll_pkttype, a.sll_halen, a.sll_addr) == + (b.sll_family, b.sll_protocol, b.sll_ifindex, b.sll_hatype, + b.sll_pkttype, b.sll_halen, b.sll_addr) + } + } + + impl hash::Hash for LinkAddr { + fn hash(&self, s: &mut H) { + let a = self.0; + (a.sll_family, a.sll_protocol, a.sll_ifindex, a.sll_hatype, + a.sll_pkttype, a.sll_halen, a.sll_addr).hash(s); + } + } + + impl fmt::Display for LinkAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let addr = self.addr(); + write!(f, "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", + addr[0], + addr[1], + addr[2], + addr[3], + addr[4], + addr[5]) + } + } + + impl fmt::Debug for LinkAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } + } +} + +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +mod datalink { + use super::{libc, hash, fmt, AddressFamily}; + + /// Hardware Address + #[derive(Clone, Copy)] + pub struct LinkAddr(pub libc::sockaddr_dl); + + impl LinkAddr { + /// Total length of sockaddr + pub fn len(&self) -> usize { + self.0.sdl_len as usize + } + + /// always == AF_LINK + pub fn family(&self) -> AddressFamily { + assert_eq!(self.0.sdl_family as i32, libc::AF_LINK); + AddressFamily::Link + } + + /// interface index, if != 0, system given index for interface + pub fn ifindex(&self) -> usize { + self.0.sdl_index as usize + } + + /// Datalink type + pub fn datalink_type(&self) -> u8 { + self.0.sdl_type + } + + // MAC address start position + pub fn nlen(&self) -> usize { + self.0.sdl_nlen as usize + } + + /// link level address length + pub fn alen(&self) -> usize { + self.0.sdl_alen as usize + } + + /// link layer selector length + pub fn slen(&self) -> usize { + self.0.sdl_slen as usize + } + + /// if link level address length == 0, + /// or `sdl_data` not be larger. + pub fn is_empty(&self) -> bool { + let nlen = self.nlen(); + let alen = self.alen(); + let data_len = self.0.sdl_data.len(); + + if alen > 0 && nlen + alen < data_len { + false + } else { + true + } + } + + /// Physical-layer address (MAC) + pub fn addr(&self) -> [u8; 6] { + let nlen = self.nlen(); + let data = self.0.sdl_data; + + assert!(!self.is_empty()); + + let a = data[nlen] as u8; + let b = data[nlen + 1] as u8; + let c = data[nlen + 2] as u8; + let d = data[nlen + 3] as u8; + let e = data[nlen + 4] as u8; + let f = data[nlen + 5] as u8; + + [a, b, c, d, e, f] + } + } + + impl Eq for LinkAddr {} + + impl PartialEq for LinkAddr { + #[cfg(any(target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + fn eq(&self, other: &Self) -> bool { + let (a, b) = (self.0, other.0); + (a.sdl_len, a.sdl_family, a.sdl_index, a.sdl_type, + a.sdl_nlen, a.sdl_alen, a.sdl_slen, &a.sdl_data[..]) == + (b.sdl_len, b.sdl_family, b.sdl_index, b.sdl_type, + b.sdl_nlen, b.sdl_alen, b.sdl_slen, &b.sdl_data[..]) + } + + #[cfg(target_os = "dragonfly")] + fn eq(&self, other: &Self) -> bool { + let (a, b) = (self.0, other.0); + (a.sdl_len, a.sdl_family, a.sdl_index, a.sdl_type, a.sdl_nlen, + a.sdl_alen, a.sdl_slen, a.sdl_data, a.sdl_rcf, a.sdl_route) == + (b.sdl_len, b.sdl_family, b.sdl_index, b.sdl_type, b.sdl_nlen, + b.sdl_alen, b.sdl_slen, b.sdl_data, b.sdl_rcf, b.sdl_route) + } + } + + impl hash::Hash for LinkAddr { + #[cfg(any(target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + fn hash(&self, s: &mut H) { + let a = self.0; + (a.sdl_len, a.sdl_family, a.sdl_index, a.sdl_type, + a.sdl_nlen, a.sdl_alen, a.sdl_slen, &a.sdl_data[..]).hash(s); + } + + #[cfg(target_os = "dragonfly")] + fn hash(&self, s: &mut H) { + let a = self.0; + (a.sdl_len, a.sdl_family, a.sdl_index, a.sdl_type, a.sdl_nlen, + a.sdl_alen, a.sdl_slen, a.sdl_data, a.sdl_rcf, a.sdl_route).hash(s); + } + } + + impl fmt::Display for LinkAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let addr = self.addr(); + write!(f, "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", + addr[0], + addr[1], + addr[2], + addr[3], + addr[4], + addr[5]) + } + } + + impl fmt::Debug for LinkAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } + } +} + +#[cfg(test)] +mod tests { + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + use super::*; + + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + #[test] + fn test_macos_loopback_datalink_addr() { + let bytes = [20i8, 18, 1, 0, 24, 3, 0, 0, 108, 111, 48, 0, 0, 0, 0, 0]; + let sa = bytes.as_ptr() as *const libc::sockaddr; + let _sock_addr = unsafe { SockAddr::from_libc_sockaddr(sa) }; + assert!(_sock_addr.is_none()); + } + + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + #[test] + fn test_macos_tap_datalink_addr() { + let bytes = [20i8, 18, 7, 0, 6, 3, 6, 0, 101, 110, 48, 24, 101, -112, -35, 76, -80]; + let ptr = bytes.as_ptr(); + let sa = ptr as *const libc::sockaddr; + let _sock_addr = unsafe { SockAddr::from_libc_sockaddr(sa) }; + + assert!(_sock_addr.is_some()); + + let sock_addr = _sock_addr.unwrap(); + + assert_eq!(sock_addr.family(), AddressFamily::Link); + + match sock_addr { + SockAddr::Link(ether_addr) => { + assert_eq!(ether_addr.addr(), [24u8, 101, 144, 221, 76, 176]); + }, + _ => { unreachable!() } + }; + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/socket/mod.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/socket/mod.rs new file mode 100644 index 0000000..0ba2835 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/socket/mod.rs @@ -0,0 +1,1338 @@ +//! Socket interface functions +//! +//! [Further reading](http://man7.org/linux/man-pages/man7/socket.7.html) +use {Error, Result}; +use errno::Errno; +use libc::{self, c_void, c_int, iovec, socklen_t, size_t, + CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_LEN}; +use std::{fmt, mem, ptr, slice}; +use std::os::unix::io::RawFd; +use sys::time::TimeVal; +use sys::uio::IoVec; + +mod addr; +pub mod sockopt; + +/* + * + * ===== Re-exports ===== + * + */ + +pub use self::addr::{ + AddressFamily, + SockAddr, + InetAddr, + UnixAddr, + IpAddr, + Ipv4Addr, + Ipv6Addr, + LinkAddr, +}; +#[cfg(any(target_os = "android", target_os = "linux"))] +pub use ::sys::socket::addr::netlink::NetlinkAddr; +#[cfg(any(target_os = "android", target_os = "linux"))] +pub use sys::socket::addr::alg::AlgAddr; + +pub use libc::{ + cmsghdr, + msghdr, + sa_family_t, + sockaddr, + sockaddr_in, + sockaddr_in6, + sockaddr_storage, + sockaddr_un, +}; + +// Needed by the cmsg_space macro +#[doc(hidden)] +pub use libc::{c_uint, CMSG_SPACE}; + +/// These constants are used to specify the communication semantics +/// when creating a socket with [`socket()`](fn.socket.html) +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +#[repr(i32)] +pub enum SockType { + /// Provides sequenced, reliable, two-way, connection- + /// based byte streams. An out-of-band data transmission + /// mechanism may be supported. + Stream = libc::SOCK_STREAM, + /// Supports datagrams (connectionless, unreliable + /// messages of a fixed maximum length). + Datagram = libc::SOCK_DGRAM, + /// Provides a sequenced, reliable, two-way connection- + /// based data transmission path for datagrams of fixed + /// maximum length; a consumer is required to read an + /// entire packet with each input system call. + SeqPacket = libc::SOCK_SEQPACKET, + /// Provides raw network protocol access. + Raw = libc::SOCK_RAW, + /// Provides a reliable datagram layer that does not + /// guarantee ordering. + Rdm = libc::SOCK_RDM, +} + +/// Constants used in [`socket`](fn.socket.html) and [`socketpair`](fn.socketpair.html) +/// to specify the protocol to use. +#[repr(i32)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub enum SockProtocol { + /// TCP protocol ([ip(7)](http://man7.org/linux/man-pages/man7/ip.7.html)) + Tcp = libc::IPPROTO_TCP, + /// UDP protocol ([ip(7)](http://man7.org/linux/man-pages/man7/ip.7.html)) + Udp = libc::IPPROTO_UDP, + /// Allows applications and other KEXTs to be notified when certain kernel events occur + /// ([ref](https://developer.apple.com/library/content/documentation/Darwin/Conceptual/NKEConceptual/control/control.html)) + #[cfg(any(target_os = "ios", target_os = "macos"))] + KextEvent = libc::SYSPROTO_EVENT, + /// Allows applications to configure and control a KEXT + /// ([ref](https://developer.apple.com/library/content/documentation/Darwin/Conceptual/NKEConceptual/control/control.html)) + #[cfg(any(target_os = "ios", target_os = "macos"))] + KextControl = libc::SYSPROTO_CONTROL, +} + +libc_bitflags!{ + /// Additional socket options + pub struct SockFlag: c_int { + /// Set non-blocking mode on the new socket + #[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd"))] + SOCK_NONBLOCK; + /// Set close-on-exec on the new descriptor + #[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd"))] + SOCK_CLOEXEC; + /// Return `EPIPE` instead of raising `SIGPIPE` + #[cfg(target_os = "netbsd")] + SOCK_NOSIGPIPE; + /// For domains `AF_INET(6)`, only allow `connect(2)`, `sendto(2)`, or `sendmsg(2)` + /// to the DNS port (typically 53) + #[cfg(target_os = "openbsd")] + SOCK_DNS; + } +} + +libc_bitflags!{ + /// Flags for send/recv and their relatives + pub struct MsgFlags: c_int { + /// Sends or requests out-of-band data on sockets that support this notion + /// (e.g., of type [`Stream`](enum.SockType.html)); the underlying protocol must also + /// support out-of-band data. + MSG_OOB; + /// Peeks at an incoming message. The data is treated as unread and the next + /// [`recv()`](fn.recv.html) + /// or similar function shall still return this data. + MSG_PEEK; + /// Enables nonblocking operation; if the operation would block, + /// `EAGAIN` or `EWOULDBLOCK` is returned. This provides similar + /// behavior to setting the `O_NONBLOCK` flag + /// (via the [`fcntl`](../../fcntl/fn.fcntl.html) + /// `F_SETFL` operation), but differs in that `MSG_DONTWAIT` is a per- + /// call option, whereas `O_NONBLOCK` is a setting on the open file + /// description (see [open(2)](http://man7.org/linux/man-pages/man2/open.2.html)), + /// which will affect all threads in + /// the calling process and as well as other processes that hold + /// file descriptors referring to the same open file description. + MSG_DONTWAIT; + /// Receive flags: Control Data was discarded (buffer too small) + MSG_CTRUNC; + /// For raw ([`Packet`](addr/enum.AddressFamily.html)), Internet datagram + /// (since Linux 2.4.27/2.6.8), + /// netlink (since Linux 2.6.22) and UNIX datagram (since Linux 3.4) + /// sockets: return the real length of the packet or datagram, even + /// when it was longer than the passed buffer. Not implemented for UNIX + /// domain ([unix(7)](https://linux.die.net/man/7/unix)) sockets. + /// + /// For use with Internet stream sockets, see [tcp(7)](https://linux.die.net/man/7/tcp). + MSG_TRUNC; + /// Terminates a record (when this notion is supported, as for + /// sockets of type [`SeqPacket`](enum.SockType.html)). + MSG_EOR; + /// This flag specifies that queued errors should be received from + /// the socket error queue. (For more details, see + /// [recvfrom(2)](https://linux.die.net/man/2/recvfrom)) + #[cfg(any(target_os = "android", target_os = "linux"))] + MSG_ERRQUEUE; + /// Set the `close-on-exec` flag for the file descriptor received via a UNIX domain + /// file descriptor using the `SCM_RIGHTS` operation (described in + /// [unix(7)](https://linux.die.net/man/7/unix)). + /// This flag is useful for the same reasons as the `O_CLOEXEC` flag of + /// [open(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html). + /// + /// Only used in [`recvmsg`](fn.recvmsg.html) function. + #[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd"))] + MSG_CMSG_CLOEXEC; + } +} + +cfg_if! { + if #[cfg(any(target_os = "android", target_os = "linux"))] { + /// Unix credentials of the sending process. + /// + /// This struct is used with the `SO_PEERCRED` ancillary message for UNIX sockets. + #[repr(C)] + #[derive(Clone, Copy)] + pub struct UnixCredentials(libc::ucred); + + impl UnixCredentials { + /// Returns the process identifier + pub fn pid(&self) -> libc::pid_t { + self.0.pid + } + + /// Returns the user identifier + pub fn uid(&self) -> libc::uid_t { + self.0.uid + } + + /// Returns the group identifier + pub fn gid(&self) -> libc::gid_t { + self.0.gid + } + } + + impl PartialEq for UnixCredentials { + fn eq(&self, other: &Self) -> bool { + self.0.pid == other.0.pid && self.0.uid == other.0.uid && self.0.gid == other.0.gid + } + } + impl Eq for UnixCredentials {} + + impl From for UnixCredentials { + fn from(cred: libc::ucred) -> Self { + UnixCredentials(cred) + } + } + + impl Into for UnixCredentials { + fn into(self) -> libc::ucred { + self.0 + } + } + + impl fmt::Debug for UnixCredentials { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("UnixCredentials") + .field("pid", &self.0.pid) + .field("uid", &self.0.uid) + .field("gid", &self.0.gid) + .finish() + } + } + } +} + +/// Request for multicast socket operations +/// +/// This is a wrapper type around `ip_mreq`. +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IpMembershipRequest(libc::ip_mreq); + +impl IpMembershipRequest { + /// Instantiate a new `IpMembershipRequest` + /// + /// If `interface` is `None`, then `Ipv4Addr::any()` will be used for the interface. + pub fn new(group: Ipv4Addr, interface: Option) -> Self { + IpMembershipRequest(libc::ip_mreq { + imr_multiaddr: group.0, + imr_interface: interface.unwrap_or_else(Ipv4Addr::any).0, + }) + } +} + +impl PartialEq for IpMembershipRequest { + fn eq(&self, other: &Self) -> bool { + self.0.imr_multiaddr.s_addr == other.0.imr_multiaddr.s_addr + && self.0.imr_interface.s_addr == other.0.imr_interface.s_addr + } +} +impl Eq for IpMembershipRequest {} + +impl fmt::Debug for IpMembershipRequest { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mref = &self.0.imr_multiaddr; + let maddr = mref.s_addr; + let iref = &self.0.imr_interface; + let ifaddr = iref.s_addr; + f.debug_struct("IpMembershipRequest") + .field("imr_multiaddr", &maddr) + .field("imr_interface", &ifaddr) + .finish() + } +} + +/// Request for ipv6 multicast socket operations +/// +/// This is a wrapper type around `ipv6_mreq`. +#[repr(C)] +#[derive(Clone, Copy)] +pub struct Ipv6MembershipRequest(libc::ipv6_mreq); + +impl Ipv6MembershipRequest { + /// Instantiate a new `Ipv6MembershipRequest` + pub fn new(group: Ipv6Addr) -> Self { + Ipv6MembershipRequest(libc::ipv6_mreq { + ipv6mr_multiaddr: group.0, + ipv6mr_interface: 0, + }) + } +} + +impl PartialEq for Ipv6MembershipRequest { + fn eq(&self, other: &Self) -> bool { + self.0.ipv6mr_multiaddr.s6_addr == other.0.ipv6mr_multiaddr.s6_addr && + self.0.ipv6mr_interface == other.0.ipv6mr_interface + } +} +impl Eq for Ipv6MembershipRequest {} + +impl fmt::Debug for Ipv6MembershipRequest { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Ipv6MembershipRequest") + .field("ipv6mr_multiaddr", &self.0.ipv6mr_multiaddr.s6_addr) + .field("ipv6mr_interface", &self.0.ipv6mr_interface) + .finish() + } +} + +cfg_if! { + // Darwin and DragonFly BSD always align struct cmsghdr to 32-bit only. + if #[cfg(any(target_os = "dragonfly", target_os = "ios", target_os = "macos"))] { + type align_of_cmsg_data = u32; + } else { + type align_of_cmsg_data = size_t; + } +} + +/// A type that can be used to store ancillary data received by +/// [`recvmsg`](fn.recvmsg.html) +pub trait CmsgBuffer { + fn as_bytes_mut(&mut self) -> &mut [u8]; +} + +/// Create a buffer large enough for storing some control messages as returned +/// by [`recvmsg`](fn.recvmsg.html). +/// +/// # Examples +/// +/// ``` +/// # #[macro_use] extern crate nix; +/// # use nix::sys::time::TimeVal; +/// # use std::os::unix::io::RawFd; +/// # fn main() { +/// // Create a buffer for a `ControlMessageOwned::ScmTimestamp` message +/// let _ = cmsg_space!(TimeVal); +/// // Create a buffer big enough for a `ControlMessageOwned::ScmRights` message +/// // with two file descriptors +/// let _ = cmsg_space!([RawFd; 2]); +/// // Create a buffer big enough for a `ControlMessageOwned::ScmRights` message +/// // and a `ControlMessageOwned::ScmTimestamp` message +/// let _ = cmsg_space!(RawFd, TimeVal); +/// # } +/// ``` +// Unfortunately, CMSG_SPACE isn't a const_fn, or else we could return a +// stack-allocated array. +#[macro_export] +macro_rules! cmsg_space { + ( $( $x:ty ),* ) => { + { + use nix::sys::socket::{c_uint, CMSG_SPACE}; + use std::mem; + let mut space = 0; + $( + // CMSG_SPACE is always safe + space += unsafe { + CMSG_SPACE(mem::size_of::<$x>() as c_uint) + } as usize; + )* + let mut v = Vec::::with_capacity(space); + // safe because any bit pattern is a valid u8 + unsafe {v.set_len(space)}; + v + } + } +} + +/// A structure used to make room in a cmsghdr passed to recvmsg. The +/// size and alignment match that of a cmsghdr followed by a T, but the +/// fields are not accessible, as the actual types will change on a call +/// to recvmsg. +/// +/// To make room for multiple messages, nest the type parameter with +/// tuples: +/// +/// ``` +/// use std::os::unix::io::RawFd; +/// use nix::sys::socket::CmsgSpace; +/// let cmsg: CmsgSpace<([RawFd; 3], CmsgSpace<[RawFd; 2]>)> = CmsgSpace::new(); +/// ``` +#[repr(C)] +#[allow(missing_debug_implementations)] +pub struct CmsgSpace { + _hdr: cmsghdr, + _pad: [align_of_cmsg_data; 0], + _data: T, +} + +impl CmsgSpace { + /// Create a CmsgSpace. The structure is used only for space, so + /// the fields are uninitialized. + #[deprecated( since="0.14.0", note="Use the cmsg_space! macro instead")] + pub fn new() -> Self { + // Safe because the fields themselves aren't accessible. + unsafe { mem::uninitialized() } + } +} + +impl CmsgBuffer for CmsgSpace { + fn as_bytes_mut(&mut self) -> &mut [u8] { + // Safe because nothing ever attempts to access CmsgSpace's fields + unsafe { + slice::from_raw_parts_mut(self as *mut CmsgSpace as *mut u8, + mem::size_of::()) + } + } +} + +impl CmsgBuffer for Vec { + fn as_bytes_mut(&mut self) -> &mut [u8] { + &mut self[..] + } +} + +#[allow(missing_debug_implementations)] // msghdr isn't Debug +pub struct RecvMsg<'a> { + pub bytes: usize, + cmsghdr: Option<&'a cmsghdr>, + pub address: Option, + pub flags: MsgFlags, + mhdr: msghdr, +} + +impl<'a> RecvMsg<'a> { + /// Iterate over the valid control messages pointed to by this + /// msghdr. + pub fn cmsgs(&self) -> CmsgIterator { + CmsgIterator { + cmsghdr: self.cmsghdr, + mhdr: &self.mhdr + } + } +} + +#[allow(missing_debug_implementations)] // msghdr isn't Debug +pub struct CmsgIterator<'a> { + /// Control message buffer to decode from. Must adhere to cmsg alignment. + cmsghdr: Option<&'a cmsghdr>, + mhdr: &'a msghdr +} + +impl<'a> Iterator for CmsgIterator<'a> { + type Item = ControlMessageOwned; + + fn next(&mut self) -> Option { + match self.cmsghdr { + None => None, // No more messages + Some(hdr) => { + // Get the data. + // Safe if cmsghdr points to valid data returned by recvmsg(2) + let cm = unsafe { Some(ControlMessageOwned::decode_from(hdr))}; + // Advance the internal pointer. Safe if mhdr and cmsghdr point + // to valid data returned by recvmsg(2) + self.cmsghdr = unsafe { + let p = CMSG_NXTHDR(self.mhdr as *const _, hdr as *const _); + p.as_ref() + }; + cm + } + } + } +} + +/// A type-safe wrapper around a single control message, as used with +/// [`recvmsg`](#fn.recvmsg). +/// +/// [Further reading](http://man7.org/linux/man-pages/man3/cmsg.3.html) +// Nix version 0.13.0 and earlier used ControlMessage for both recvmsg and +// sendmsg. However, on some platforms the messages returned by recvmsg may be +// unaligned. ControlMessageOwned takes those messages by copy, obviating any +// alignment issues. +// +// See https://github.com/nix-rust/nix/issues/999 +#[allow(missing_debug_implementations)] +pub enum ControlMessageOwned { + /// Received version of + /// [`ControlMessage::ScmRights`][#enum.ControlMessage.html#variant.ScmRights] + ScmRights(Vec), + /// Received version of + /// [`ControlMessage::ScmCredentials`][#enum.ControlMessage.html#variant.ScmCredentials] + #[cfg(any(target_os = "android", target_os = "linux"))] + ScmCredentials(libc::ucred), + /// A message of type `SCM_TIMESTAMP`, containing the time the + /// packet was received by the kernel. + /// + /// See the kernel's explanation in "SO_TIMESTAMP" of + /// [networking/timestamping](https://www.kernel.org/doc/Documentation/networking/timestamping.txt). + /// + /// # Examples + /// + // Disable this test on FreeBSD i386 + // https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222039 + #[cfg_attr(not(all(target_os = "freebsd", target_arch = "x86")), doc = " ```")] + #[cfg_attr(all(target_os = "freebsd", target_arch = "x86"), doc = " ```no_run")] + /// # #[macro_use] extern crate nix; + /// # use nix::sys::socket::*; + /// # use nix::sys::uio::IoVec; + /// # use nix::sys::time::*; + /// # use std::time::*; + /// # fn main() { + /// // Set up + /// let message = "Ohayō!".as_bytes(); + /// let in_socket = socket( + /// AddressFamily::Inet, + /// SockType::Datagram, + /// SockFlag::empty(), + /// None).unwrap(); + /// setsockopt(in_socket, sockopt::ReceiveTimestamp, &true).unwrap(); + /// let localhost = InetAddr::new(IpAddr::new_v4(127, 0, 0, 1), 0); + /// bind(in_socket, &SockAddr::new_inet(localhost)).unwrap(); + /// let address = getsockname(in_socket).unwrap(); + /// // Get initial time + /// let time0 = SystemTime::now(); + /// // Send the message + /// let iov = [IoVec::from_slice(message)]; + /// let flags = MsgFlags::empty(); + /// let l = sendmsg(in_socket, &iov, &[], flags, Some(&address)).unwrap(); + /// assert_eq!(message.len(), l); + /// // Receive the message + /// let mut buffer = vec![0u8; message.len()]; + /// let mut cmsgspace = cmsg_space!(TimeVal); + /// let iov = [IoVec::from_mut_slice(&mut buffer)]; + /// let r = recvmsg(in_socket, &iov, Some(&mut cmsgspace), flags).unwrap(); + /// let rtime = match r.cmsgs().next() { + /// Some(ControlMessageOwned::ScmTimestamp(rtime)) => rtime, + /// Some(_) => panic!("Unexpected control message"), + /// None => panic!("No control message") + /// }; + /// // Check the final time + /// let time1 = SystemTime::now(); + /// // the packet's received timestamp should lie in-between the two system + /// // times, unless the system clock was adjusted in the meantime. + /// let rduration = Duration::new(rtime.tv_sec() as u64, + /// rtime.tv_usec() as u32 * 1000); + /// assert!(time0.duration_since(UNIX_EPOCH).unwrap() <= rduration); + /// assert!(rduration <= time1.duration_since(UNIX_EPOCH).unwrap()); + /// // Close socket + /// nix::unistd::close(in_socket).unwrap(); + /// # } + /// ``` + ScmTimestamp(TimeVal), + #[cfg(any( + target_os = "android", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + ))] + Ipv4PacketInfo(libc::in_pktinfo), + #[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "openbsd", + target_os = "netbsd", + ))] + Ipv6PacketInfo(libc::in6_pktinfo), + #[cfg(any( + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + ))] + Ipv4RecvIf(libc::sockaddr_dl), + #[cfg(any( + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + ))] + Ipv4RecvDstAddr(libc::in_addr), + /// Catch-all variant for unimplemented cmsg types. + #[doc(hidden)] + Unknown(UnknownCmsg), +} + +impl ControlMessageOwned { + /// Decodes a `ControlMessageOwned` from raw bytes. + /// + /// This is only safe to call if the data is correct for the message type + /// specified in the header. Normally, the kernel ensures that this is the + /// case. "Correct" in this case includes correct length, alignment and + /// actual content. + /// + /// Returns `None` if the data may be unaligned. In that case use + /// `ControlMessageOwned::decode_from`. + unsafe fn decode_from(header: &cmsghdr) -> ControlMessageOwned + { + let p = CMSG_DATA(header); + let len = header as *const _ as usize + header.cmsg_len as usize + - p as usize; + match (header.cmsg_level, header.cmsg_type) { + (libc::SOL_SOCKET, libc::SCM_RIGHTS) => { + let n = len / mem::size_of::(); + let mut fds = Vec::with_capacity(n); + for i in 0..n { + let fdp = (p as *const RawFd).offset(i as isize); + fds.push(ptr::read_unaligned(fdp)); + } + let cmo = ControlMessageOwned::ScmRights(fds); + cmo + }, + #[cfg(any(target_os = "android", target_os = "linux"))] + (libc::SOL_SOCKET, libc::SCM_CREDENTIALS) => { + let cred: libc::ucred = ptr::read_unaligned(p as *const _); + ControlMessageOwned::ScmCredentials(cred) + } + (libc::SOL_SOCKET, libc::SCM_TIMESTAMP) => { + let tv: libc::timeval = ptr::read_unaligned(p as *const _); + ControlMessageOwned::ScmTimestamp(TimeVal::from(tv)) + }, + #[cfg(any( + target_os = "android", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos" + ))] + (libc::IPPROTO_IPV6, libc::IPV6_PKTINFO) => { + let info = ptr::read_unaligned(p as *const libc::in6_pktinfo); + ControlMessageOwned::Ipv6PacketInfo(info) + } + #[cfg(any( + target_os = "android", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + ))] + (libc::IPPROTO_IP, libc::IP_PKTINFO) => { + let info = ptr::read_unaligned(p as *const libc::in_pktinfo); + ControlMessageOwned::Ipv4PacketInfo(info) + } + #[cfg(any( + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + ))] + (libc::IPPROTO_IP, libc::IP_RECVIF) => { + let dl = ptr::read_unaligned(p as *const libc::sockaddr_dl); + ControlMessageOwned::Ipv4RecvIf(dl) + }, + #[cfg(any( + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + ))] + (libc::IPPROTO_IP, libc::IP_RECVDSTADDR) => { + let dl = ptr::read_unaligned(p as *const libc::in_addr); + ControlMessageOwned::Ipv4RecvDstAddr(dl) + }, + (_, _) => { + let sl = slice::from_raw_parts(p, len); + let ucmsg = UnknownCmsg(*header, Vec::::from(&sl[..])); + ControlMessageOwned::Unknown(ucmsg) + } + } + } +} + +/// A type-safe zero-copy wrapper around a single control message, as used wih +/// [`sendmsg`](#fn.sendmsg). More types may be added to this enum; do not +/// exhaustively pattern-match it. +/// +/// [Further reading](http://man7.org/linux/man-pages/man3/cmsg.3.html) +#[allow(missing_debug_implementations)] +pub enum ControlMessage<'a> { + /// A message of type `SCM_RIGHTS`, containing an array of file + /// descriptors passed between processes. + /// + /// See the description in the "Ancillary messages" section of the + /// [unix(7) man page](http://man7.org/linux/man-pages/man7/unix.7.html). + /// + /// Using multiple `ScmRights` messages for a single `sendmsg` call isn't + /// recommended since it causes platform-dependent behaviour: It might + /// swallow all but the first `ScmRights` message or fail with `EINVAL`. + /// Instead, you can put all fds to be passed into a single `ScmRights` + /// message. + ScmRights(&'a [RawFd]), + /// A message of type `SCM_CREDENTIALS`, containing the pid, uid and gid of + /// a process connected to the socket. + /// + /// This is similar to the socket option `SO_PEERCRED`, but requires a + /// process to explicitly send its credentials. A process running as root is + /// allowed to specify any credentials, while credentials sent by other + /// processes are verified by the kernel. + /// + /// For further information, please refer to the + /// [`unix(7)`](http://man7.org/linux/man-pages/man7/unix.7.html) man page. + // FIXME: When `#[repr(transparent)]` is stable, use it on `UnixCredentials` + // and put that in here instead of a raw ucred. + #[cfg(any(target_os = "android", target_os = "linux"))] + ScmCredentials(&'a libc::ucred), + + /// Set IV for `AF_ALG` crypto API. + /// + /// For further information, please refer to the + /// [`documentation`](https://kernel.readthedocs.io/en/sphinx-samples/crypto-API.html) + #[cfg(any( + target_os = "android", + target_os = "linux", + ))] + AlgSetIv(&'a [u8]), + /// Set crypto operation for `AF_ALG` crypto API. It may be one of + /// `ALG_OP_ENCRYPT` or `ALG_OP_DECRYPT` + /// + /// For further information, please refer to the + /// [`documentation`](https://kernel.readthedocs.io/en/sphinx-samples/crypto-API.html) + #[cfg(any( + target_os = "android", + target_os = "linux", + ))] + AlgSetOp(&'a libc::c_int), + /// Set the length of associated authentication data (AAD) (applicable only to AEAD algorithms) + /// for `AF_ALG` crypto API. + /// + /// For further information, please refer to the + /// [`documentation`](https://kernel.readthedocs.io/en/sphinx-samples/crypto-API.html) + #[cfg(any( + target_os = "android", + target_os = "linux", + ))] + AlgSetAeadAssoclen(&'a u32), + +} + +// An opaque structure used to prevent cmsghdr from being a public type +#[doc(hidden)] +#[allow(missing_debug_implementations)] +pub struct UnknownCmsg(cmsghdr, Vec); + +impl<'a> ControlMessage<'a> { + /// The value of CMSG_SPACE on this message. + /// Safe because CMSG_SPACE is always safe + fn space(&self) -> usize { + unsafe{CMSG_SPACE(self.len() as libc::c_uint) as usize} + } + + /// The value of CMSG_LEN on this message. + /// Safe because CMSG_LEN is always safe + #[cfg(any(target_os = "android", + all(target_os = "linux", not(target_env = "musl"))))] + fn cmsg_len(&self) -> usize { + unsafe{CMSG_LEN(self.len() as libc::c_uint) as usize} + } + + #[cfg(not(any(target_os = "android", + all(target_os = "linux", not(target_env = "musl")))))] + fn cmsg_len(&self) -> libc::c_uint { + unsafe{CMSG_LEN(self.len() as libc::c_uint)} + } + + /// Return a reference to the payload data as a byte pointer + fn copy_to_cmsg_data(&self, cmsg_data: *mut u8) { + let data_ptr = match self { + &ControlMessage::ScmRights(fds) => { + fds as *const _ as *const u8 + }, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::ScmCredentials(creds) => { + creds as *const libc::ucred as *const u8 + } + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::AlgSetIv(iv) => { + unsafe { + let alg_iv = cmsg_data as *mut libc::af_alg_iv; + (*alg_iv).ivlen = iv.len() as u32; + ptr::copy_nonoverlapping( + iv.as_ptr(), + (*alg_iv).iv.as_mut_ptr(), + iv.len() + ); + }; + return + }, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::AlgSetOp(op) => { + op as *const _ as *const u8 + }, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::AlgSetAeadAssoclen(len) => { + len as *const _ as *const u8 + }, + }; + unsafe { + ptr::copy_nonoverlapping( + data_ptr, + cmsg_data, + self.len() + ) + }; + } + + /// The size of the payload, excluding its cmsghdr + fn len(&self) -> usize { + match self { + &ControlMessage::ScmRights(fds) => { + mem::size_of_val(fds) + }, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::ScmCredentials(creds) => { + mem::size_of_val(creds) + } + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::AlgSetIv(iv) => { + mem::size_of::() + iv.len() + }, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::AlgSetOp(op) => { + mem::size_of_val(op) + }, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::AlgSetAeadAssoclen(len) => { + mem::size_of_val(len) + }, + } + } + + /// Returns the value to put into the `cmsg_level` field of the header. + fn cmsg_level(&self) -> libc::c_int { + match self { + &ControlMessage::ScmRights(_) => libc::SOL_SOCKET, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::ScmCredentials(_) => libc::SOL_SOCKET, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::AlgSetIv(_) | &ControlMessage::AlgSetOp(_) | &ControlMessage::AlgSetAeadAssoclen(_) => { + libc::SOL_ALG + }, + } + } + + /// Returns the value to put into the `cmsg_type` field of the header. + fn cmsg_type(&self) -> libc::c_int { + match self { + &ControlMessage::ScmRights(_) => libc::SCM_RIGHTS, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::ScmCredentials(_) => libc::SCM_CREDENTIALS, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::AlgSetIv(_) => { + libc::ALG_SET_IV + }, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::AlgSetOp(_) => { + libc::ALG_SET_OP + }, + #[cfg(any(target_os = "android", target_os = "linux"))] + &ControlMessage::AlgSetAeadAssoclen(_) => { + libc::ALG_SET_AEAD_ASSOCLEN + }, + } + } + + // Unsafe: cmsg must point to a valid cmsghdr with enough space to + // encode self. + unsafe fn encode_into(&self, cmsg: *mut cmsghdr) { + (*cmsg).cmsg_level = self.cmsg_level(); + (*cmsg).cmsg_type = self.cmsg_type(); + (*cmsg).cmsg_len = self.cmsg_len(); + self.copy_to_cmsg_data(CMSG_DATA(cmsg)); + } +} + + +/// Send data in scatter-gather vectors to a socket, possibly accompanied +/// by ancillary data. Optionally direct the message at the given address, +/// as with sendto. +/// +/// Allocates if cmsgs is nonempty. +pub fn sendmsg(fd: RawFd, iov: &[IoVec<&[u8]>], cmsgs: &[ControlMessage], + flags: MsgFlags, addr: Option<&SockAddr>) -> Result +{ + let capacity = cmsgs.iter().map(|c| c.space()).sum(); + + // First size the buffer needed to hold the cmsgs. It must be zeroed, + // because subsequent code will not clear the padding bytes. + let cmsg_buffer = vec![0u8; capacity]; + + // Next encode the sending address, if provided + let (name, namelen) = match addr { + Some(addr) => { + let (x, y) = unsafe { addr.as_ffi_pair() }; + (x as *const _, y) + }, + None => (ptr::null(), 0), + }; + + // The message header must be initialized before the individual cmsgs. + let cmsg_ptr = if capacity > 0 { + cmsg_buffer.as_ptr() as *mut c_void + } else { + ptr::null_mut() + }; + + let mhdr = { + // Musl's msghdr has private fields, so this is the only way to + // initialize it. + let mut mhdr: msghdr = unsafe{mem::uninitialized()}; + mhdr.msg_name = name as *mut _; + mhdr.msg_namelen = namelen; + // transmute iov into a mutable pointer. sendmsg doesn't really mutate + // the buffer, but the standard says that it takes a mutable pointer + mhdr.msg_iov = iov.as_ptr() as *mut _; + mhdr.msg_iovlen = iov.len() as _; + mhdr.msg_control = cmsg_ptr; + mhdr.msg_controllen = capacity as _; + mhdr.msg_flags = 0; + mhdr + }; + + // Encode each cmsg. This must happen after initializing the header because + // CMSG_NEXT_HDR and friends read the msg_control and msg_controllen fields. + // CMSG_FIRSTHDR is always safe + let mut pmhdr: *mut cmsghdr = unsafe{CMSG_FIRSTHDR(&mhdr as *const msghdr)}; + for cmsg in cmsgs { + assert_ne!(pmhdr, ptr::null_mut()); + // Safe because we know that pmhdr is valid, and we initialized it with + // sufficient space + unsafe { cmsg.encode_into(pmhdr) }; + // Safe because mhdr is valid + pmhdr = unsafe{CMSG_NXTHDR(&mhdr as *const msghdr, pmhdr)}; + } + + let ret = unsafe { libc::sendmsg(fd, &mhdr, flags.bits()) }; + + Errno::result(ret).map(|r| r as usize) +} + +/// Receive message in scatter-gather vectors from a socket, and +/// optionally receive ancillary data into the provided buffer. +/// If no ancillary data is desired, use () as the type parameter. +/// +/// # References +/// [recvmsg(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html) +pub fn recvmsg<'a>(fd: RawFd, iov: &[IoVec<&mut [u8]>], + cmsg_buffer: Option<&'a mut CmsgBuffer>, + flags: MsgFlags) -> Result> +{ + let mut address: sockaddr_storage = unsafe { mem::uninitialized() }; + let (msg_control, msg_controllen) = match cmsg_buffer { + Some(cmsgspace) => { + let msg_buf = cmsgspace.as_bytes_mut(); + (msg_buf.as_mut_ptr(), msg_buf.len()) + }, + None => (ptr::null_mut(), 0), + }; + let mut mhdr = { + // Musl's msghdr has private fields, so this is the only way to + // initialize it. + let mut mhdr: msghdr = unsafe{mem::uninitialized()}; + mhdr.msg_name = &mut address as *mut sockaddr_storage as *mut c_void; + mhdr.msg_namelen = mem::size_of::() as socklen_t; + mhdr.msg_iov = iov.as_ptr() as *mut iovec; + mhdr.msg_iovlen = iov.len() as _; + mhdr.msg_control = msg_control as *mut c_void; + mhdr.msg_controllen = msg_controllen as _; + mhdr.msg_flags = 0; + mhdr + }; + + let ret = unsafe { libc::recvmsg(fd, &mut mhdr, flags.bits()) }; + + Errno::result(ret).map(|r| { + let cmsghdr = unsafe { + if mhdr.msg_controllen > 0 { + // got control message(s) + debug_assert!(!mhdr.msg_control.is_null()); + debug_assert!(msg_controllen >= mhdr.msg_controllen as usize); + CMSG_FIRSTHDR(&mhdr as *const msghdr) + } else { + ptr::null() + }.as_ref() + }; + + let address = unsafe { + sockaddr_storage_to_addr(&address, mhdr.msg_namelen as usize).ok() + }; + RecvMsg { + bytes: r as usize, + cmsghdr, + address, + flags: MsgFlags::from_bits_truncate(mhdr.msg_flags), + mhdr, + } + }) +} + + +/// Create an endpoint for communication +/// +/// The `protocol` specifies a particular protocol to be used with the +/// socket. Normally only a single protocol exists to support a +/// particular socket type within a given protocol family, in which case +/// protocol can be specified as `None`. However, it is possible that many +/// protocols may exist, in which case a particular protocol must be +/// specified in this manner. +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html) +pub fn socket>>(domain: AddressFamily, ty: SockType, flags: SockFlag, protocol: T) -> Result { + let protocol = match protocol.into() { + None => 0, + Some(p) => p as c_int, + }; + + // SockFlags are usually embedded into `ty`, but we don't do that in `nix` because it's a + // little easier to understand by separating it out. So we have to merge these bitfields + // here. + let mut ty = ty as c_int; + ty |= flags.bits(); + + let res = unsafe { libc::socket(domain as c_int, ty, protocol) }; + + Errno::result(res) +} + +/// Create a pair of connected sockets +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/socketpair.html) +pub fn socketpair>>(domain: AddressFamily, ty: SockType, protocol: T, + flags: SockFlag) -> Result<(RawFd, RawFd)> { + let protocol = match protocol.into() { + None => 0, + Some(p) => p as c_int, + }; + + // SockFlags are usually embedded into `ty`, but we don't do that in `nix` because it's a + // little easier to understand by separating it out. So we have to merge these bitfields + // here. + let mut ty = ty as c_int; + ty |= flags.bits(); + + let mut fds = [-1, -1]; + + let res = unsafe { libc::socketpair(domain as c_int, ty, protocol, fds.as_mut_ptr()) }; + Errno::result(res)?; + + Ok((fds[0], fds[1])) +} + +/// Listen for connections on a socket +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html) +pub fn listen(sockfd: RawFd, backlog: usize) -> Result<()> { + let res = unsafe { libc::listen(sockfd, backlog as c_int) }; + + Errno::result(res).map(drop) +} + +/// Bind a name to a socket +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html) +pub fn bind(fd: RawFd, addr: &SockAddr) -> Result<()> { + let res = unsafe { + let (ptr, len) = addr.as_ffi_pair(); + libc::bind(fd, ptr, len) + }; + + Errno::result(res).map(drop) +} + +/// Accept a connection on a socket +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html) +pub fn accept(sockfd: RawFd) -> Result { + let res = unsafe { libc::accept(sockfd, ptr::null_mut(), ptr::null_mut()) }; + + Errno::result(res) +} + +/// Accept a connection on a socket +/// +/// [Further reading](http://man7.org/linux/man-pages/man2/accept.2.html) +#[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "linux", + target_os = "openbsd"))] +pub fn accept4(sockfd: RawFd, flags: SockFlag) -> Result { + let res = unsafe { libc::accept4(sockfd, ptr::null_mut(), ptr::null_mut(), flags.bits()) }; + + Errno::result(res) +} + +/// Initiate a connection on a socket +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html) +pub fn connect(fd: RawFd, addr: &SockAddr) -> Result<()> { + let res = unsafe { + let (ptr, len) = addr.as_ffi_pair(); + libc::connect(fd, ptr, len) + }; + + Errno::result(res).map(drop) +} + +/// Receive data from a connection-oriented socket. Returns the number of +/// bytes read +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html) +pub fn recv(sockfd: RawFd, buf: &mut [u8], flags: MsgFlags) -> Result { + unsafe { + let ret = libc::recv( + sockfd, + buf.as_ptr() as *mut c_void, + buf.len() as size_t, + flags.bits()); + + Errno::result(ret).map(|r| r as usize) + } +} + +/// Receive data from a connectionless or connection-oriented socket. Returns +/// the number of bytes read and the socket address of the sender. +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html) +pub fn recvfrom(sockfd: RawFd, buf: &mut [u8]) -> Result<(usize, SockAddr)> { + unsafe { + let addr: sockaddr_storage = mem::zeroed(); + let mut len = mem::size_of::() as socklen_t; + + let ret = Errno::result(libc::recvfrom( + sockfd, + buf.as_ptr() as *mut c_void, + buf.len() as size_t, + 0, + mem::transmute(&addr), + &mut len as *mut socklen_t))?; + + sockaddr_storage_to_addr(&addr, len as usize) + .map(|addr| (ret as usize, addr)) + } +} + +/// Send a message to a socket +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/sendto.html) +pub fn sendto(fd: RawFd, buf: &[u8], addr: &SockAddr, flags: MsgFlags) -> Result { + let ret = unsafe { + let (ptr, len) = addr.as_ffi_pair(); + libc::sendto(fd, buf.as_ptr() as *const c_void, buf.len() as size_t, flags.bits(), ptr, len) + }; + + Errno::result(ret).map(|r| r as usize) +} + +/// Send data to a connection-oriented socket. Returns the number of bytes read +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html) +pub fn send(fd: RawFd, buf: &[u8], flags: MsgFlags) -> Result { + let ret = unsafe { + libc::send(fd, buf.as_ptr() as *const c_void, buf.len() as size_t, flags.bits()) + }; + + Errno::result(ret).map(|r| r as usize) +} + +/* + * + * ===== Socket Options ===== + * + */ + +/// The protocol level at which to get / set socket options. Used as an +/// argument to `getsockopt` and `setsockopt`. +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html) +#[repr(i32)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub enum SockLevel { + Socket = libc::SOL_SOCKET, + Tcp = libc::IPPROTO_TCP, + Ip = libc::IPPROTO_IP, + Ipv6 = libc::IPPROTO_IPV6, + Udp = libc::IPPROTO_UDP, + #[cfg(any(target_os = "android", target_os = "linux"))] + Netlink = libc::SOL_NETLINK, + #[cfg(any(target_os = "android", target_os = "linux"))] + Alg = libc::SOL_ALG, +} + +/// Represents a socket option that can be accessed or set. Used as an argument +/// to `getsockopt` +pub trait GetSockOpt : Copy { + type Val; + + #[doc(hidden)] + fn get(&self, fd: RawFd) -> Result; +} + +/// Represents a socket option that can be accessed or set. Used as an argument +/// to `setsockopt` +pub trait SetSockOpt : Clone { + type Val; + + #[doc(hidden)] + fn set(&self, fd: RawFd, val: &Self::Val) -> Result<()>; +} + +/// Get the current value for the requested socket option +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html) +pub fn getsockopt(fd: RawFd, opt: O) -> Result { + opt.get(fd) +} + +/// Sets the value for the requested socket option +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html) +/// +/// # Examples +/// +/// ``` +/// use nix::sys::socket::setsockopt; +/// use nix::sys::socket::sockopt::KeepAlive; +/// use std::net::TcpListener; +/// use std::os::unix::io::AsRawFd; +/// +/// let listener = TcpListener::bind("0.0.0.0:0").unwrap(); +/// let fd = listener.as_raw_fd(); +/// let res = setsockopt(fd, KeepAlive, &true); +/// assert!(res.is_ok()); +/// ``` +pub fn setsockopt(fd: RawFd, opt: O, val: &O::Val) -> Result<()> { + opt.set(fd, val) +} + +/// Get the address of the peer connected to the socket `fd`. +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpeername.html) +pub fn getpeername(fd: RawFd) -> Result { + unsafe { + let addr: sockaddr_storage = mem::uninitialized(); + let mut len = mem::size_of::() as socklen_t; + + let ret = libc::getpeername(fd, mem::transmute(&addr), &mut len); + + Errno::result(ret)?; + + sockaddr_storage_to_addr(&addr, len as usize) + } +} + +/// Get the current address to which the socket `fd` is bound. +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html) +pub fn getsockname(fd: RawFd) -> Result { + unsafe { + let addr: sockaddr_storage = mem::uninitialized(); + let mut len = mem::size_of::() as socklen_t; + + let ret = libc::getsockname(fd, mem::transmute(&addr), &mut len); + + Errno::result(ret)?; + + sockaddr_storage_to_addr(&addr, len as usize) + } +} + +/// Return the appropriate `SockAddr` type from a `sockaddr_storage` of a certain +/// size. In C this would usually be done by casting. The `len` argument +/// should be the number of bytes in the `sockaddr_storage` that are actually +/// allocated and valid. It must be at least as large as all the useful parts +/// of the structure. Note that in the case of a `sockaddr_un`, `len` need not +/// include the terminating null. +pub unsafe fn sockaddr_storage_to_addr( + addr: &sockaddr_storage, + len: usize) -> Result { + + if len < mem::size_of_val(&addr.ss_family) { + return Err(Error::Sys(Errno::ENOTCONN)); + } + + match addr.ss_family as c_int { + libc::AF_INET => { + assert!(len as usize == mem::size_of::()); + let ret = *(addr as *const _ as *const sockaddr_in); + Ok(SockAddr::Inet(InetAddr::V4(ret))) + } + libc::AF_INET6 => { + assert!(len as usize == mem::size_of::()); + Ok(SockAddr::Inet(InetAddr::V6(*(addr as *const _ as *const sockaddr_in6)))) + } + libc::AF_UNIX => { + let sun = *(addr as *const _ as *const sockaddr_un); + let pathlen = len - offset_of!(sockaddr_un, sun_path); + Ok(SockAddr::Unix(UnixAddr(sun, pathlen))) + } + #[cfg(any(target_os = "android", target_os = "linux"))] + libc::AF_NETLINK => { + use libc::sockaddr_nl; + Ok(SockAddr::Netlink(NetlinkAddr(*(addr as *const _ as *const sockaddr_nl)))) + } + #[cfg(any(target_os = "android", target_os = "linux"))] + libc::AF_ALG => { + use libc::sockaddr_alg; + Ok(SockAddr::Alg(AlgAddr(*(addr as *const _ as *const sockaddr_alg)))) + } + af => panic!("unexpected address family {}", af), + } +} + + +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub enum Shutdown { + /// Further receptions will be disallowed. + Read, + /// Further transmissions will be disallowed. + Write, + /// Further receptions and transmissions will be disallowed. + Both, +} + +/// Shut down part of a full-duplex connection. +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html) +pub fn shutdown(df: RawFd, how: Shutdown) -> Result<()> { + unsafe { + use libc::shutdown; + + let how = match how { + Shutdown::Read => libc::SHUT_RD, + Shutdown::Write => libc::SHUT_WR, + Shutdown::Both => libc::SHUT_RDWR, + }; + + Errno::result(shutdown(df, how)).map(drop) + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/socket/sockopt.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/socket/sockopt.rs new file mode 100644 index 0000000..5f19e5f --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/socket/sockopt.rs @@ -0,0 +1,680 @@ +use super::{GetSockOpt, SetSockOpt}; +use Result; +use errno::Errno; +use sys::time::TimeVal; +use libc::{self, c_int, c_void, socklen_t}; +use std::mem; +use std::os::unix::io::RawFd; +use std::ffi::{OsStr, OsString}; +#[cfg(target_family = "unix")] +use std::os::unix::ffi::OsStrExt; + +// Constants +// TCP_CA_NAME_MAX isn't defined in user space include files +#[cfg(any(target_os = "freebsd", target_os = "linux"))] +const TCP_CA_NAME_MAX: usize = 16; + +/// Helper for implementing `SetSockOpt` for a given socket option. See +/// [`::sys::socket::SetSockOpt`](sys/socket/trait.SetSockOpt.html). +/// +/// This macro aims to help implementing `SetSockOpt` for different socket options that accept +/// different kinds of data to be used with `setsockopt`. +/// +/// Instead of using this macro directly consider using `sockopt_impl!`, especially if the option +/// you are implementing represents a simple type. +/// +/// # Arguments +/// +/// * `$name:ident`: name of the type you want to implement `SetSockOpt` for. +/// * `$level:path` : socket layer, or a `protocol level`: could be *raw sockets* +/// (`libc::SOL_SOCKET`), *ip protocol* (libc::IPPROTO_IP), *tcp protocol* (`libc::IPPROTO_TCP`), +/// and more. Please refer to your system manual for more options. Will be passed as the second +/// argument (`level`) to the `setsockopt` call. +/// * `$flag:path`: a flag name to set. Some examples: `libc::SO_REUSEADDR`, `libc::TCP_NODELAY`, +/// `libc::IP_ADD_MEMBERSHIP` and others. Will be passed as the third argument (`option_name`) +/// to the `setsockopt` call. +/// * Type of the value that you are going to set. +/// * Type that implements the `Set` trait for the type from the previous item (like `SetBool` for +/// `bool`, `SetUsize` for `usize`, etc.). +macro_rules! setsockopt_impl { + ($name:ident, $level:path, $flag:path, $ty:ty, $setter:ty) => { + impl SetSockOpt for $name { + type Val = $ty; + + fn set(&self, fd: RawFd, val: &$ty) -> Result<()> { + unsafe { + let setter: $setter = Set::new(val); + + let res = libc::setsockopt(fd, $level, $flag, + setter.ffi_ptr(), + setter.ffi_len()); + Errno::result(res).map(drop) + } + } + } + } +} + +/// Helper for implementing `GetSockOpt` for a given socket option. See +/// [`::sys::socket::GetSockOpt`](sys/socket/trait.GetSockOpt.html). +/// +/// This macro aims to help implementing `GetSockOpt` for different socket options that accept +/// different kinds of data to be use with `getsockopt`. +/// +/// Instead of using this macro directly consider using `sockopt_impl!`, especially if the option +/// you are implementing represents a simple type. +/// +/// # Arguments +/// +/// * Name of the type you want to implement `GetSockOpt` for. +/// * Socket layer, or a `protocol level`: could be *raw sockets* (`lic::SOL_SOCKET`), *ip +/// protocol* (libc::IPPROTO_IP), *tcp protocol* (`libc::IPPROTO_TCP`), and more. Please refer +/// to your system manual for more options. Will be passed as the second argument (`level`) to +/// the `getsockopt` call. +/// * A flag to set. Some examples: `libc::SO_REUSEADDR`, `libc::TCP_NODELAY`, +/// `libc::SO_ORIGINAL_DST` and others. Will be passed as the third argument (`option_name`) to +/// the `getsockopt` call. +/// * Type of the value that you are going to get. +/// * Type that implements the `Get` trait for the type from the previous item (`GetBool` for +/// `bool`, `GetUsize` for `usize`, etc.). +macro_rules! getsockopt_impl { + ($name:ident, $level:path, $flag:path, $ty:ty, $getter:ty) => { + impl GetSockOpt for $name { + type Val = $ty; + + fn get(&self, fd: RawFd) -> Result<$ty> { + unsafe { + let mut getter: $getter = Get::blank(); + + let res = libc::getsockopt(fd, $level, $flag, + getter.ffi_ptr(), + getter.ffi_len()); + Errno::result(res)?; + + Ok(getter.unwrap()) + } + } + } + } +} + +/// Helper to generate the sockopt accessors. See +/// [`::sys::socket::GetSockOpt`](sys/socket/trait.GetSockOpt.html) and +/// [`::sys::socket::SetSockOpt`](sys/socket/trait.SetSockOpt.html). +/// +/// This macro aims to help implementing `GetSockOpt` and `SetSockOpt` for different socket options +/// that accept different kinds of data to be use with `getsockopt` and `setsockopt` respectively. +/// +/// Basically this macro wraps up the [`getsockopt_impl!`](macro.getsockopt_impl.html) and +/// [`setsockopt_impl!`](macro.setsockopt_impl.html) macros. +/// +/// # Arguments +/// +/// * `GetOnly`, `SetOnly` or `Both`: whether you want to implement only getter, only setter or +/// both of them. +/// * `$name:ident`: name of type `GetSockOpt`/`SetSockOpt` will be implemented for. +/// * `$level:path` : socket layer, or a `protocol level`: could be *raw sockets* +/// (`lic::SOL_SOCKET`), *ip protocol* (libc::IPPROTO_IP), *tcp protocol* (`libc::IPPROTO_TCP`), +/// and more. Please refer to your system manual for more options. Will be passed as the second +/// argument (`level`) to the `getsockopt`/`setsockopt` call. +/// * `$flag:path`: a flag name to set. Some examples: `libc::SO_REUSEADDR`, `libc::TCP_NODELAY`, +/// `libc::IP_ADD_MEMBERSHIP` and others. Will be passed as the third argument (`option_name`) +/// to the `setsockopt`/`getsockopt` call. +/// * `$ty:ty`: type of the value that will be get/set. +/// * `$getter:ty`: `Get` implementation; optional; only for `GetOnly` and `Both`. +/// * `$setter:ty`: `Set` implementation; optional; only for `SetOnly` and `Both`. +macro_rules! sockopt_impl { + (GetOnly, $name:ident, $level:path, $flag:path, bool) => { + sockopt_impl!(GetOnly, $name, $level, $flag, bool, GetBool); + }; + + (GetOnly, $name:ident, $level:path, $flag:path, u8) => { + sockopt_impl!(GetOnly, $name, $level, $flag, u8, GetU8); + }; + + (GetOnly, $name:ident, $level:path, $flag:path, usize) => { + sockopt_impl!(GetOnly, $name, $level, $flag, usize, GetUsize); + }; + + (SetOnly, $name:ident, $level:path, $flag:path, bool) => { + sockopt_impl!(SetOnly, $name, $level, $flag, bool, SetBool); + }; + + (SetOnly, $name:ident, $level:path, $flag:path, u8) => { + sockopt_impl!(SetOnly, $name, $level, $flag, u8, SetU8); + }; + + (SetOnly, $name:ident, $level:path, $flag:path, usize) => { + sockopt_impl!(SetOnly, $name, $level, $flag, usize, SetUsize); + }; + + (Both, $name:ident, $level:path, $flag:path, bool) => { + sockopt_impl!(Both, $name, $level, $flag, bool, GetBool, SetBool); + }; + + (Both, $name:ident, $level:path, $flag:path, u8) => { + sockopt_impl!(Both, $name, $level, $flag, u8, GetU8, SetU8); + }; + + (Both, $name:ident, $level:path, $flag:path, usize) => { + sockopt_impl!(Both, $name, $level, $flag, usize, GetUsize, SetUsize); + }; + + (Both, $name:ident, $level:path, $flag:path, OsString<$array:ty>) => { + sockopt_impl!(Both, $name, $level, $flag, OsString, GetOsString<$array>, SetOsString); + }; + + /* + * Matchers with generic getter types must be placed at the end, so + * they'll only match _after_ specialized matchers fail + */ + (GetOnly, $name:ident, $level:path, $flag:path, $ty:ty) => { + sockopt_impl!(GetOnly, $name, $level, $flag, $ty, GetStruct<$ty>); + }; + + (GetOnly, $name:ident, $level:path, $flag:path, $ty:ty, $getter:ty) => { + #[derive(Copy, Clone, Debug)] + pub struct $name; + + getsockopt_impl!($name, $level, $flag, $ty, $getter); + }; + + (SetOnly, $name:ident, $level:path, $flag:path, $ty:ty) => { + sockopt_impl!(SetOnly, $name, $level, $flag, $ty, SetStruct<$ty>); + }; + + (SetOnly, $name:ident, $level:path, $flag:path, $ty:ty, $setter:ty) => { + #[derive(Copy, Clone, Debug)] + pub struct $name; + + setsockopt_impl!($name, $level, $flag, $ty, $setter); + }; + + (Both, $name:ident, $level:path, $flag:path, $ty:ty, $getter:ty, $setter:ty) => { + #[derive(Copy, Clone, Debug)] + pub struct $name; + + setsockopt_impl!($name, $level, $flag, $ty, $setter); + getsockopt_impl!($name, $level, $flag, $ty, $getter); + }; + + (Both, $name:ident, $level:path, $flag:path, $ty:ty) => { + sockopt_impl!(Both, $name, $level, $flag, $ty, GetStruct<$ty>, SetStruct<$ty>); + }; +} + +/* + * + * ===== Define sockopts ===== + * + */ + +sockopt_impl!(Both, ReuseAddr, libc::SOL_SOCKET, libc::SO_REUSEADDR, bool); +sockopt_impl!(Both, ReusePort, libc::SOL_SOCKET, libc::SO_REUSEPORT, bool); +sockopt_impl!(Both, TcpNoDelay, libc::IPPROTO_TCP, libc::TCP_NODELAY, bool); +sockopt_impl!(Both, Linger, libc::SOL_SOCKET, libc::SO_LINGER, libc::linger); +sockopt_impl!(SetOnly, IpAddMembership, libc::IPPROTO_IP, libc::IP_ADD_MEMBERSHIP, super::IpMembershipRequest); +sockopt_impl!(SetOnly, IpDropMembership, libc::IPPROTO_IP, libc::IP_DROP_MEMBERSHIP, super::IpMembershipRequest); +cfg_if! { + if #[cfg(any(target_os = "android", target_os = "linux"))] { + sockopt_impl!(SetOnly, Ipv6AddMembership, libc::IPPROTO_IPV6, libc::IPV6_ADD_MEMBERSHIP, super::Ipv6MembershipRequest); + sockopt_impl!(SetOnly, Ipv6DropMembership, libc::IPPROTO_IPV6, libc::IPV6_DROP_MEMBERSHIP, super::Ipv6MembershipRequest); + } else if #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] { + sockopt_impl!(SetOnly, Ipv6AddMembership, libc::IPPROTO_IPV6, libc::IPV6_JOIN_GROUP, super::Ipv6MembershipRequest); + sockopt_impl!(SetOnly, Ipv6DropMembership, libc::IPPROTO_IPV6, libc::IPV6_LEAVE_GROUP, super::Ipv6MembershipRequest); + } +} +sockopt_impl!(Both, IpMulticastTtl, libc::IPPROTO_IP, libc::IP_MULTICAST_TTL, u8); +sockopt_impl!(Both, IpMulticastLoop, libc::IPPROTO_IP, libc::IP_MULTICAST_LOOP, bool); +sockopt_impl!(Both, ReceiveTimeout, libc::SOL_SOCKET, libc::SO_RCVTIMEO, TimeVal); +sockopt_impl!(Both, SendTimeout, libc::SOL_SOCKET, libc::SO_SNDTIMEO, TimeVal); +sockopt_impl!(Both, Broadcast, libc::SOL_SOCKET, libc::SO_BROADCAST, bool); +sockopt_impl!(Both, OobInline, libc::SOL_SOCKET, libc::SO_OOBINLINE, bool); +sockopt_impl!(GetOnly, SocketError, libc::SOL_SOCKET, libc::SO_ERROR, i32); +sockopt_impl!(Both, KeepAlive, libc::SOL_SOCKET, libc::SO_KEEPALIVE, bool); +#[cfg(any(target_os = "android", target_os = "linux"))] +sockopt_impl!(GetOnly, PeerCredentials, libc::SOL_SOCKET, libc::SO_PEERCRED, super::UnixCredentials); +#[cfg(any(target_os = "ios", + target_os = "macos"))] +sockopt_impl!(Both, TcpKeepAlive, libc::IPPROTO_TCP, libc::TCP_KEEPALIVE, u32); +#[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "nacl"))] +sockopt_impl!(Both, TcpKeepIdle, libc::IPPROTO_TCP, libc::TCP_KEEPIDLE, u32); +sockopt_impl!(Both, RcvBuf, libc::SOL_SOCKET, libc::SO_RCVBUF, usize); +sockopt_impl!(Both, SndBuf, libc::SOL_SOCKET, libc::SO_SNDBUF, usize); +#[cfg(any(target_os = "android", target_os = "linux"))] +sockopt_impl!(SetOnly, RcvBufForce, libc::SOL_SOCKET, libc::SO_RCVBUFFORCE, usize); +#[cfg(any(target_os = "android", target_os = "linux"))] +sockopt_impl!(SetOnly, SndBufForce, libc::SOL_SOCKET, libc::SO_SNDBUFFORCE, usize); +sockopt_impl!(GetOnly, SockType, libc::SOL_SOCKET, libc::SO_TYPE, super::SockType); +sockopt_impl!(GetOnly, AcceptConn, libc::SOL_SOCKET, libc::SO_ACCEPTCONN, bool); +#[cfg(any(target_os = "android", target_os = "linux"))] +sockopt_impl!(GetOnly, OriginalDst, libc::SOL_IP, libc::SO_ORIGINAL_DST, libc::sockaddr_in); +sockopt_impl!(Both, ReceiveTimestamp, libc::SOL_SOCKET, libc::SO_TIMESTAMP, bool); +#[cfg(any(target_os = "android", target_os = "linux"))] +sockopt_impl!(Both, IpTransparent, libc::SOL_IP, libc::IP_TRANSPARENT, bool); +#[cfg(target_os = "openbsd")] +sockopt_impl!(Both, BindAny, libc::SOL_SOCKET, libc::SO_BINDANY, bool); +#[cfg(target_os = "freebsd")] +sockopt_impl!(Both, BindAny, libc::IPPROTO_IP, libc::IP_BINDANY, bool); +#[cfg(target_os = "linux")] +sockopt_impl!(Both, Mark, libc::SOL_SOCKET, libc::SO_MARK, u32); +#[cfg(any(target_os = "android", target_os = "linux"))] +sockopt_impl!(Both, PassCred, libc::SOL_SOCKET, libc::SO_PASSCRED, bool); +#[cfg(any(target_os = "freebsd", target_os = "linux"))] +sockopt_impl!(Both, TcpCongestion, libc::IPPROTO_TCP, libc::TCP_CONGESTION, OsString<[u8; TCP_CA_NAME_MAX]>); +#[cfg(any( + target_os = "android", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", +))] +sockopt_impl!(Both, Ipv4PacketInfo, libc::IPPROTO_IP, libc::IP_PKTINFO, bool); +#[cfg(any( + target_os = "android", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", +))] +sockopt_impl!(Both, Ipv6RecvPacketInfo, libc::IPPROTO_IPV6, libc::IPV6_RECVPKTINFO, bool); +#[cfg(any( + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", +))] +sockopt_impl!(Both, Ipv4RecvIf, libc::IPPROTO_IP, libc::IP_RECVIF, bool); +#[cfg(any( + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", +))] +sockopt_impl!(Both, Ipv4RecvDstAddr, libc::IPPROTO_IP, libc::IP_RECVDSTADDR, bool); + + +#[cfg(any(target_os = "android", target_os = "linux"))] +#[derive(Copy, Clone, Debug)] +pub struct AlgSetAeadAuthSize; + +// ALG_SET_AEAD_AUTH_SIZE read the length from passed `option_len` +// See https://elixir.bootlin.com/linux/v4.4/source/crypto/af_alg.c#L222 +#[cfg(any(target_os = "android", target_os = "linux"))] +impl SetSockOpt for AlgSetAeadAuthSize { + type Val = usize; + + fn set(&self, fd: RawFd, val: &usize) -> Result<()> { + unsafe { + let res = libc::setsockopt(fd, + libc::SOL_ALG, + libc::ALG_SET_AEAD_AUTHSIZE, + ::std::ptr::null(), + *val as libc::socklen_t); + Errno::result(res).map(drop) + } + } +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +#[derive(Clone, Debug)] +pub struct AlgSetKey(::std::marker::PhantomData); + +#[cfg(any(target_os = "android", target_os = "linux"))] +impl Default for AlgSetKey { + fn default() -> Self { + AlgSetKey(Default::default()) + } +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +impl SetSockOpt for AlgSetKey where T: AsRef<[u8]> + Clone { + type Val = T; + + fn set(&self, fd: RawFd, val: &T) -> Result<()> { + unsafe { + let res = libc::setsockopt(fd, + libc::SOL_ALG, + libc::ALG_SET_KEY, + val.as_ref().as_ptr() as *const _, + val.as_ref().len() as libc::socklen_t); + Errno::result(res).map(drop) + } + } +} + +/* + * + * ===== Accessor helpers ===== + * + */ + +/// Helper trait that describes what is expected from a `GetSockOpt` getter. +unsafe trait Get { + /// Returns an empty value. + unsafe fn blank() -> Self; + /// Returns a pointer to the stored value. This pointer will be passed to the system's + /// `getsockopt` call (`man 3p getsockopt`, argument `option_value`). + fn ffi_ptr(&mut self) -> *mut c_void; + /// Returns length of the stored value. This pointer will be passed to the system's + /// `getsockopt` call (`man 3p getsockopt`, argument `option_len`). + fn ffi_len(&mut self) -> *mut socklen_t; + /// Returns the stored value. + unsafe fn unwrap(self) -> T; +} + +/// Helper trait that describes what is expected from a `SetSockOpt` setter. +unsafe trait Set<'a, T> { + /// Initialize the setter with a given value. + fn new(val: &'a T) -> Self; + /// Returns a pointer to the stored value. This pointer will be passed to the system's + /// `setsockopt` call (`man 3p setsockopt`, argument `option_value`). + fn ffi_ptr(&self) -> *const c_void; + /// Returns length of the stored value. This pointer will be passed to the system's + /// `setsockopt` call (`man 3p setsockopt`, argument `option_len`). + fn ffi_len(&self) -> socklen_t; +} + +/// Getter for an arbitrary `struct`. +struct GetStruct { + len: socklen_t, + val: T, +} + +unsafe impl Get for GetStruct { + unsafe fn blank() -> Self { + GetStruct { + len: mem::size_of::() as socklen_t, + val: mem::zeroed(), + } + } + + fn ffi_ptr(&mut self) -> *mut c_void { + &mut self.val as *mut T as *mut c_void + } + + fn ffi_len(&mut self) -> *mut socklen_t { + &mut self.len + } + + unsafe fn unwrap(self) -> T { + assert!(self.len as usize == mem::size_of::(), "invalid getsockopt implementation"); + self.val + } +} + +/// Setter for an arbitrary `struct`. +struct SetStruct<'a, T: 'static> { + ptr: &'a T, +} + +unsafe impl<'a, T> Set<'a, T> for SetStruct<'a, T> { + fn new(ptr: &'a T) -> SetStruct<'a, T> { + SetStruct { ptr: ptr } + } + + fn ffi_ptr(&self) -> *const c_void { + self.ptr as *const T as *const c_void + } + + fn ffi_len(&self) -> socklen_t { + mem::size_of::() as socklen_t + } +} + +/// Getter for a boolean value. +struct GetBool { + len: socklen_t, + val: c_int, +} + +unsafe impl Get for GetBool { + unsafe fn blank() -> Self { + GetBool { + len: mem::size_of::() as socklen_t, + val: mem::zeroed(), + } + } + + fn ffi_ptr(&mut self) -> *mut c_void { + &mut self.val as *mut c_int as *mut c_void + } + + fn ffi_len(&mut self) -> *mut socklen_t { + &mut self.len + } + + unsafe fn unwrap(self) -> bool { + assert!(self.len as usize == mem::size_of::(), "invalid getsockopt implementation"); + self.val != 0 + } +} + +/// Setter for a boolean value. +struct SetBool { + val: c_int, +} + +unsafe impl<'a> Set<'a, bool> for SetBool { + fn new(val: &'a bool) -> SetBool { + SetBool { val: if *val { 1 } else { 0 } } + } + + fn ffi_ptr(&self) -> *const c_void { + &self.val as *const c_int as *const c_void + } + + fn ffi_len(&self) -> socklen_t { + mem::size_of::() as socklen_t + } +} + +/// Getter for an `u8` value. +struct GetU8 { + len: socklen_t, + val: u8, +} + +unsafe impl Get for GetU8 { + unsafe fn blank() -> Self { + GetU8 { + len: mem::size_of::() as socklen_t, + val: mem::zeroed(), + } + } + + fn ffi_ptr(&mut self) -> *mut c_void { + &mut self.val as *mut u8 as *mut c_void + } + + fn ffi_len(&mut self) -> *mut socklen_t { + &mut self.len + } + + unsafe fn unwrap(self) -> u8 { + assert!(self.len as usize == mem::size_of::(), "invalid getsockopt implementation"); + self.val as u8 + } +} + +/// Setter for an `u8` value. +struct SetU8 { + val: u8, +} + +unsafe impl<'a> Set<'a, u8> for SetU8 { + fn new(val: &'a u8) -> SetU8 { + SetU8 { val: *val as u8 } + } + + fn ffi_ptr(&self) -> *const c_void { + &self.val as *const u8 as *const c_void + } + + fn ffi_len(&self) -> socklen_t { + mem::size_of::() as socklen_t + } +} + +/// Getter for an `usize` value. +struct GetUsize { + len: socklen_t, + val: c_int, +} + +unsafe impl Get for GetUsize { + unsafe fn blank() -> Self { + GetUsize { + len: mem::size_of::() as socklen_t, + val: mem::zeroed(), + } + } + + fn ffi_ptr(&mut self) -> *mut c_void { + &mut self.val as *mut c_int as *mut c_void + } + + fn ffi_len(&mut self) -> *mut socklen_t { + &mut self.len + } + + unsafe fn unwrap(self) -> usize { + assert!(self.len as usize == mem::size_of::(), "invalid getsockopt implementation"); + self.val as usize + } +} + +/// Setter for an `usize` value. +struct SetUsize { + val: c_int, +} + +unsafe impl<'a> Set<'a, usize> for SetUsize { + fn new(val: &'a usize) -> SetUsize { + SetUsize { val: *val as c_int } + } + + fn ffi_ptr(&self) -> *const c_void { + &self.val as *const c_int as *const c_void + } + + fn ffi_len(&self) -> socklen_t { + mem::size_of::() as socklen_t + } +} + +/// Getter for a `OsString` value. +struct GetOsString> { + len: socklen_t, + val: T, +} + +unsafe impl> Get for GetOsString { + unsafe fn blank() -> Self { + GetOsString { + len: mem::size_of::() as socklen_t, + val: mem::zeroed(), + } + } + + fn ffi_ptr(&mut self) -> *mut c_void { + &mut self.val as *mut T as *mut c_void + } + + fn ffi_len(&mut self) -> *mut socklen_t { + &mut self.len + } + + unsafe fn unwrap(mut self) -> OsString { + OsStr::from_bytes(self.val.as_mut()).to_owned() + } +} + +/// Setter for a `OsString` value. +struct SetOsString<'a> { + val: &'a OsStr, +} + +unsafe impl<'a> Set<'a, OsString> for SetOsString<'a> { + fn new(val: &'a OsString) -> SetOsString { + SetOsString { val: val.as_os_str() } + } + + fn ffi_ptr(&self) -> *const c_void { + self.val.as_bytes().as_ptr() as *const c_void + } + + fn ffi_len(&self) -> socklen_t { + self.val.len() as socklen_t + } +} + + +#[cfg(test)] +mod test { + #[cfg(any(target_os = "android", target_os = "linux"))] + #[test] + fn can_get_peercred_on_unix_socket() { + use super::super::*; + + let (a, b) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()).unwrap(); + let a_cred = getsockopt(a, super::PeerCredentials).unwrap(); + let b_cred = getsockopt(b, super::PeerCredentials).unwrap(); + assert_eq!(a_cred, b_cred); + assert!(a_cred.pid() != 0); + } + + #[test] + fn is_socket_type_unix() { + use super::super::*; + use ::unistd::close; + + let (a, b) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()).unwrap(); + let a_type = getsockopt(a, super::SockType).unwrap(); + assert!(a_type == SockType::Stream); + close(a).unwrap(); + close(b).unwrap(); + } + + #[test] + fn is_socket_type_dgram() { + use super::super::*; + use ::unistd::close; + + let s = socket(AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), None).unwrap(); + let s_type = getsockopt(s, super::SockType).unwrap(); + assert!(s_type == SockType::Datagram); + close(s).unwrap(); + } + + #[cfg(any(target_os = "freebsd", + target_os = "linux", + target_os = "nacl"))] + #[test] + fn can_get_listen_on_tcp_socket() { + use super::super::*; + use ::unistd::close; + + let s = socket(AddressFamily::Inet, SockType::Stream, SockFlag::empty(), None).unwrap(); + let s_listening = getsockopt(s, super::AcceptConn).unwrap(); + assert!(!s_listening); + listen(s, 10).unwrap(); + let s_listening2 = getsockopt(s, super::AcceptConn).unwrap(); + assert!(s_listening2); + close(s).unwrap(); + } + +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/stat.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/stat.rs new file mode 100644 index 0000000..1e0936e --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/stat.rs @@ -0,0 +1,286 @@ +pub use libc::{dev_t, mode_t}; +pub use libc::stat as FileStat; + +use {Result, NixPath}; +use errno::Errno; +use fcntl::{AtFlags, at_rawfd}; +use libc; +use std::mem; +use std::os::unix::io::RawFd; +use sys::time::{TimeSpec, TimeVal}; + +libc_bitflags!( + pub struct SFlag: mode_t { + S_IFIFO; + S_IFCHR; + S_IFDIR; + S_IFBLK; + S_IFREG; + S_IFLNK; + S_IFSOCK; + S_IFMT; + } +); + +libc_bitflags! { + pub struct Mode: mode_t { + S_IRWXU; + S_IRUSR; + S_IWUSR; + S_IXUSR; + S_IRWXG; + S_IRGRP; + S_IWGRP; + S_IXGRP; + S_IRWXO; + S_IROTH; + S_IWOTH; + S_IXOTH; + S_ISUID as mode_t; + S_ISGID as mode_t; + S_ISVTX as mode_t; + } +} + +pub fn mknod(path: &P, kind: SFlag, perm: Mode, dev: dev_t) -> Result<()> { + let res = path.with_nix_path(|cstr| { + unsafe { + libc::mknod(cstr.as_ptr(), kind.bits | perm.bits() as mode_t, dev) + } + })?; + + Errno::result(res).map(drop) +} + +#[cfg(target_os = "linux")] +pub fn major(dev: dev_t) -> u64 { + ((dev >> 32) & 0xffff_f000) | + ((dev >> 8) & 0x0000_0fff) +} + +#[cfg(target_os = "linux")] +pub fn minor(dev: dev_t) -> u64 { + ((dev >> 12) & 0xffff_ff00) | + ((dev ) & 0x0000_00ff) +} + +#[cfg(target_os = "linux")] +pub fn makedev(major: u64, minor: u64) -> dev_t { + ((major & 0xffff_f000) << 32) | + ((major & 0x0000_0fff) << 8) | + ((minor & 0xffff_ff00) << 12) | + (minor & 0x0000_00ff) +} + +pub fn umask(mode: Mode) -> Mode { + let prev = unsafe { libc::umask(mode.bits() as mode_t) }; + Mode::from_bits(prev).expect("[BUG] umask returned invalid Mode") +} + +pub fn stat(path: &P) -> Result { + let mut dst = unsafe { mem::uninitialized() }; + let res = path.with_nix_path(|cstr| { + unsafe { + libc::stat(cstr.as_ptr(), &mut dst as *mut FileStat) + } + })?; + + Errno::result(res)?; + + Ok(dst) +} + +pub fn lstat(path: &P) -> Result { + let mut dst = unsafe { mem::uninitialized() }; + let res = path.with_nix_path(|cstr| { + unsafe { + libc::lstat(cstr.as_ptr(), &mut dst as *mut FileStat) + } + })?; + + Errno::result(res)?; + + Ok(dst) +} + +pub fn fstat(fd: RawFd) -> Result { + let mut dst = unsafe { mem::uninitialized() }; + let res = unsafe { libc::fstat(fd, &mut dst as *mut FileStat) }; + + Errno::result(res)?; + + Ok(dst) +} + +pub fn fstatat(dirfd: RawFd, pathname: &P, f: AtFlags) -> Result { + let mut dst = unsafe { mem::uninitialized() }; + let res = pathname.with_nix_path(|cstr| { + unsafe { libc::fstatat(dirfd, cstr.as_ptr(), &mut dst as *mut FileStat, f.bits() as libc::c_int) } + })?; + + Errno::result(res)?; + + Ok(dst) +} + +/// Change the file permission bits of the file specified by a file descriptor. +/// +/// # References +/// +/// [fchmod(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchmod.html). +pub fn fchmod(fd: RawFd, mode: Mode) -> Result<()> { + let res = unsafe { libc::fchmod(fd, mode.bits() as mode_t) }; + + Errno::result(res).map(drop) +} + +/// Flags for `fchmodat` function. +#[derive(Clone, Copy, Debug)] +pub enum FchmodatFlags { + FollowSymlink, + NoFollowSymlink, +} + +/// Change the file permission bits. +/// +/// The file to be changed is determined relative to the directory associated +/// with the file descriptor `dirfd` or the current working directory +/// if `dirfd` is `None`. +/// +/// If `flag` is `FchmodatFlags::NoFollowSymlink` and `path` names a symbolic link, +/// then the mode of the symbolic link is changed. +/// +/// `fchmod(None, path, mode, FchmodatFlags::FollowSymlink)` is identical to +/// a call `libc::chmod(path, mode)`. That's why `chmod` is unimplemented +/// in the `nix` crate. +/// +/// # References +/// +/// [fchmodat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchmodat.html). +pub fn fchmodat( + dirfd: Option, + path: &P, + mode: Mode, + flag: FchmodatFlags, +) -> Result<()> { + let atflag = + match flag { + FchmodatFlags::FollowSymlink => AtFlags::empty(), + FchmodatFlags::NoFollowSymlink => AtFlags::AT_SYMLINK_NOFOLLOW, + }; + let res = path.with_nix_path(|cstr| unsafe { + libc::fchmodat( + at_rawfd(dirfd), + cstr.as_ptr(), + mode.bits() as mode_t, + atflag.bits() as libc::c_int, + ) + })?; + + Errno::result(res).map(drop) +} + +/// Change the access and modification times of a file. +/// +/// `utimes(path, times)` is identical to +/// `utimensat(None, path, times, UtimensatFlags::FollowSymlink)`. The former +/// is a deprecated API so prefer using the latter if the platforms you care +/// about support it. +/// +/// # References +/// +/// [utimes(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/utimes.html). +pub fn utimes(path: &P, atime: &TimeVal, mtime: &TimeVal) -> Result<()> { + let times: [libc::timeval; 2] = [*atime.as_ref(), *mtime.as_ref()]; + let res = path.with_nix_path(|cstr| unsafe { + libc::utimes(cstr.as_ptr(), ×[0]) + })?; + + Errno::result(res).map(drop) +} + +/// Change the access and modification times of a file without following symlinks. +/// +/// `lutimes(path, times)` is identical to +/// `utimensat(None, path, times, UtimensatFlags::NoFollowSymlink)`. The former +/// is a deprecated API so prefer using the latter if the platforms you care +/// about support it. +/// +/// # References +/// +/// [lutimes(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/lutimes.html). +#[cfg(any(target_os = "linux", + target_os = "haiku", + target_os = "ios", + target_os = "macos", + target_os = "freebsd", + target_os = "netbsd"))] +pub fn lutimes(path: &P, atime: &TimeVal, mtime: &TimeVal) -> Result<()> { + let times: [libc::timeval; 2] = [*atime.as_ref(), *mtime.as_ref()]; + let res = path.with_nix_path(|cstr| unsafe { + libc::lutimes(cstr.as_ptr(), ×[0]) + })?; + + Errno::result(res).map(drop) +} + +/// Change the access and modification times of the file specified by a file descriptor. +/// +/// # References +/// +/// [futimens(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html). +#[inline] +pub fn futimens(fd: RawFd, atime: &TimeSpec, mtime: &TimeSpec) -> Result<()> { + let times: [libc::timespec; 2] = [*atime.as_ref(), *mtime.as_ref()]; + let res = unsafe { libc::futimens(fd, ×[0]) }; + + Errno::result(res).map(drop) +} + +/// Flags for `utimensat` function. +#[derive(Clone, Copy, Debug)] +pub enum UtimensatFlags { + FollowSymlink, + NoFollowSymlink, +} + +/// Change the access and modification times of a file. +/// +/// The file to be changed is determined relative to the directory associated +/// with the file descriptor `dirfd` or the current working directory +/// if `dirfd` is `None`. +/// +/// If `flag` is `UtimensatFlags::NoFollowSymlink` and `path` names a symbolic link, +/// then the mode of the symbolic link is changed. +/// +/// `utimensat(None, path, times, UtimensatFlags::FollowSymlink)` is identical to +/// `utimes(path, times)`. The latter is a deprecated API so prefer using the +/// former if the platforms you care about support it. +/// +/// # References +/// +/// [utimensat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/utimens.html). +pub fn utimensat( + dirfd: Option, + path: &P, + atime: &TimeSpec, + mtime: &TimeSpec, + flag: UtimensatFlags +) -> Result<()> { + let atflag = + match flag { + UtimensatFlags::FollowSymlink => AtFlags::empty(), + UtimensatFlags::NoFollowSymlink => AtFlags::AT_SYMLINK_NOFOLLOW, + }; + let times: [libc::timespec; 2] = [*atime.as_ref(), *mtime.as_ref()]; + let res = path.with_nix_path(|cstr| unsafe { + libc::utimensat( + at_rawfd(dirfd), + cstr.as_ptr(), + ×[0], + atflag.bits() as libc::c_int, + ) + })?; + + Errno::result(res).map(drop) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/statfs.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/statfs.rs new file mode 100644 index 0000000..e7ffae5 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/statfs.rs @@ -0,0 +1,20 @@ +use {Result, NixPath}; +use errno::Errno; +use std::os::unix::io::AsRawFd; +use libc; + +pub fn statfs(path: &P, stat: &mut libc::statfs) -> Result<()> { + unsafe { + Errno::clear(); + let res = path.with_nix_path(|path| libc::statfs(path.as_ptr(), stat))?; + + Errno::result(res).map(drop) + } +} + +pub fn fstatfs(fd: &T, stat: &mut libc::statfs) -> Result<()> { + unsafe { + Errno::clear(); + Errno::result(libc::fstatfs(fd.as_raw_fd(), stat)).map(drop) + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/statvfs.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/statvfs.rs new file mode 100644 index 0000000..de69ae5 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/statvfs.rs @@ -0,0 +1,161 @@ +//! Get filesystem statistics +//! +//! See [the man pages](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatvfs.html) +//! for more details. +use std::mem; +use std::os::unix::io::AsRawFd; + +use libc::{self, c_ulong}; + +use {Result, NixPath}; +use errno::Errno; + +libc_bitflags!( + /// File system mount Flags + #[repr(C)] + #[derive(Default)] + pub struct FsFlags: c_ulong { + /// Read Only + ST_RDONLY; + /// Do not allow the set-uid bits to have an effect + ST_NOSUID; + /// Do not interpret character or block-special devices + #[cfg(any(target_os = "android", target_os = "linux"))] + ST_NODEV; + /// Do not allow execution of binaries on the filesystem + #[cfg(any(target_os = "android", target_os = "linux"))] + ST_NOEXEC; + /// All IO should be done synchronously + #[cfg(any(target_os = "android", target_os = "linux"))] + ST_SYNCHRONOUS; + /// Allow mandatory locks on the filesystem + #[cfg(any(target_os = "android", target_os = "linux"))] + ST_MANDLOCK; + /// Write on file/directory/symlink + #[cfg(target_os = "linux")] + ST_WRITE; + /// Append-only file + #[cfg(target_os = "linux")] + ST_APPEND; + /// Immutable file + #[cfg(target_os = "linux")] + ST_IMMUTABLE; + /// Do not update access times on files + #[cfg(any(target_os = "android", target_os = "linux"))] + ST_NOATIME; + /// Do not update access times on files + #[cfg(any(target_os = "android", target_os = "linux"))] + ST_NODIRATIME; + /// Update access time relative to modify/change time + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_env = "musl"))))] + ST_RELATIME; + } +); + +/// Wrapper around the POSIX `statvfs` struct +/// +/// For more information see the [`statvfs(3)` man pages](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_statvfs.h.html). +// FIXME: Replace with repr(transparent) +#[repr(C)] +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct Statvfs(libc::statvfs); + +impl Statvfs { + /// get the file system block size + pub fn block_size(&self) -> c_ulong { + self.0.f_bsize + } + + /// Get the fundamental file system block size + pub fn fragment_size(&self) -> c_ulong { + self.0.f_frsize + } + + /// Get the number of blocks. + /// + /// Units are in units of `fragment_size()` + pub fn blocks(&self) -> libc::fsblkcnt_t { + self.0.f_blocks + } + + /// Get the number of free blocks in the file system + pub fn blocks_free(&self) -> libc::fsblkcnt_t { + self.0.f_bfree + } + + /// Get the number of free blocks for unprivileged users + pub fn blocks_available(&self) -> libc::fsblkcnt_t { + self.0.f_bavail + } + + /// Get the total number of file inodes + pub fn files(&self) -> libc::fsfilcnt_t { + self.0.f_files + } + + /// Get the number of free file inodes + pub fn files_free(&self) -> libc::fsfilcnt_t { + self.0.f_ffree + } + + /// Get the number of free file inodes for unprivileged users + pub fn files_available(&self) -> libc::fsfilcnt_t { + self.0.f_favail + } + + /// Get the file system id + pub fn filesystem_id(&self) -> c_ulong { + self.0.f_fsid + } + + /// Get the mount flags + pub fn flags(&self) -> FsFlags { + FsFlags::from_bits_truncate(self.0.f_flag) + } + + /// Get the maximum filename length + pub fn name_max(&self) -> c_ulong { + self.0.f_namemax + } + +} + +/// Return a `Statvfs` object with information about the `path` +pub fn statvfs(path: &P) -> Result { + unsafe { + Errno::clear(); + let mut stat: Statvfs = mem::uninitialized(); + let res = path.with_nix_path(|path| + libc::statvfs(path.as_ptr(), &mut stat.0) + )?; + + Errno::result(res).map(|_| stat) + } +} + +/// Return a `Statvfs` object with information about `fd` +pub fn fstatvfs(fd: &T) -> Result { + unsafe { + Errno::clear(); + let mut stat: Statvfs = mem::uninitialized(); + Errno::result(libc::fstatvfs(fd.as_raw_fd(), &mut stat.0)).map(|_| stat) + } +} + +#[cfg(test)] +mod test { + use std::fs::File; + use sys::statvfs::*; + + #[test] + fn statvfs_call() { + statvfs("/".as_bytes()).unwrap(); + } + + #[test] + fn fstatvfs_call() { + let root = File::open("/").unwrap(); + fstatvfs(&root).unwrap(); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/sysinfo.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/sysinfo.rs new file mode 100644 index 0000000..98ef7bd --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/sysinfo.rs @@ -0,0 +1,73 @@ +use libc::{self, SI_LOAD_SHIFT}; +use std::{cmp, mem}; +use std::time::Duration; + +use Result; +use errno::Errno; + +/// System info structure returned by `sysinfo`. +#[derive(Copy, Clone)] +#[allow(missing_debug_implementations)] // libc::sysinfo doesn't impl Debug +pub struct SysInfo(libc::sysinfo); + +impl SysInfo { + /// Returns the load average tuple. + /// + /// The returned values represent the load average over time intervals of + /// 1, 5, and 15 minutes, respectively. + pub fn load_average(&self) -> (f64, f64, f64) { + ( + self.0.loads[0] as f64 / (1 << SI_LOAD_SHIFT) as f64, + self.0.loads[1] as f64 / (1 << SI_LOAD_SHIFT) as f64, + self.0.loads[2] as f64 / (1 << SI_LOAD_SHIFT) as f64, + ) + } + + /// Returns the time since system boot. + pub fn uptime(&self) -> Duration { + // Truncate negative values to 0 + Duration::from_secs(cmp::max(self.0.uptime, 0) as u64) + } + + /// Current number of processes. + pub fn process_count(&self) -> u16 { + self.0.procs + } + + /// Returns the amount of swap memory in Bytes. + pub fn swap_total(&self) -> u64 { + self.scale_mem(self.0.totalswap) + } + + /// Returns the amount of unused swap memory in Bytes. + pub fn swap_free(&self) -> u64 { + self.scale_mem(self.0.freeswap) + } + + /// Returns the total amount of installed RAM in Bytes. + pub fn ram_total(&self) -> u64 { + self.scale_mem(self.0.totalram) + } + + /// Returns the amount of completely unused RAM in Bytes. + /// + /// "Unused" in this context means that the RAM in neither actively used by + /// programs, nor by the operating system as disk cache or buffer. It is + /// "wasted" RAM since it currently serves no purpose. + pub fn ram_unused(&self) -> u64 { + self.scale_mem(self.0.freeram) + } + + fn scale_mem(&self, units: libc::c_ulong) -> u64 { + units as u64 * self.0.mem_unit as u64 + } +} + +/// Returns system information. +/// +/// [See `sysinfo(2)`](http://man7.org/linux/man-pages/man2/sysinfo.2.html). +pub fn sysinfo() -> Result { + let mut info: libc::sysinfo = unsafe { mem::uninitialized() }; + let res = unsafe { libc::sysinfo(&mut info) }; + Errno::result(res).map(|_| SysInfo(info)) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/termios.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/termios.rs new file mode 100644 index 0000000..d8815ba --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/termios.rs @@ -0,0 +1,1108 @@ +//! An interface for controlling asynchronous communication ports +//! +//! This interface provides a safe wrapper around the termios subsystem defined by POSIX. The +//! underlying types are all implemented in libc for most platforms and either wrapped in safer +//! types here or exported directly. +//! +//! If you are unfamiliar with the `termios` API, you should first read the +//! [API documentation](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/termios.h.html) and +//! then come back to understand how `nix` safely wraps it. +//! +//! It should be noted that this API incurs some runtime overhead above the base `libc` definitions. +//! As this interface is not used with high-bandwidth information, this should be fine in most +//! cases. The primary cost when using this API is that the `Termios` datatype here duplicates the +//! standard fields of the underlying `termios` struct and uses safe type wrappers for those fields. +//! This means that when crossing the FFI interface to the underlying C library, data is first +//! copied into the underlying `termios` struct, then the operation is done, and the data is copied +//! back (with additional sanity checking) into the safe wrapper types. The `termios` struct is +//! relatively small across all platforms (on the order of 32-64 bytes). +//! +//! The following examples highlight some of the API use cases such that users coming from using C +//! or reading the standard documentation will understand how to use the safe API exposed here. +//! +//! Example disabling processing of the end-of-file control character: +//! +//! ``` +//! # use self::nix::sys::termios::SpecialCharacterIndices::VEOF; +//! # use self::nix::sys::termios::{_POSIX_VDISABLE, Termios}; +//! # let mut termios = unsafe { Termios::default_uninit() }; +//! termios.control_chars[VEOF as usize] = _POSIX_VDISABLE; +//! ``` +//! +//! The flags within `Termios` are defined as bitfields using the `bitflags` crate. This provides +//! an interface for working with bitfields that is similar to working with the raw unsigned +//! integer types but offers type safety because of the internal checking that values will always +//! be a valid combination of the defined flags. +//! +//! An example showing some of the basic operations for interacting with the control flags: +//! +//! ``` +//! # use self::nix::sys::termios::{ControlFlags, Termios}; +//! # let mut termios = unsafe { Termios::default_uninit() }; +//! termios.control_flags & ControlFlags::CSIZE == ControlFlags::CS5; +//! termios.control_flags |= ControlFlags::CS5; +//! ``` +//! +//! # Baud rates +//! +//! This API is not consistent across platforms when it comes to `BaudRate`: Android and Linux both +//! only support the rates specified by the `BaudRate` enum through their termios API while the BSDs +//! support arbitrary baud rates as the values of the `BaudRate` enum constants are the same integer +//! value of the constant (`B9600` == `9600`). Therefore the `nix::termios` API uses the following +//! conventions: +//! +//! * `cfgetispeed()` - Returns `u32` on BSDs, `BaudRate` on Android/Linux +//! * `cfgetospeed()` - Returns `u32` on BSDs, `BaudRate` on Android/Linux +//! * `cfsetispeed()` - Takes `u32` or `BaudRate` on BSDs, `BaudRate` on Android/Linux +//! * `cfsetospeed()` - Takes `u32` or `BaudRate` on BSDs, `BaudRate` on Android/Linux +//! * `cfsetspeed()` - Takes `u32` or `BaudRate` on BSDs, `BaudRate` on Android/Linux +//! +//! The most common use case of specifying a baud rate using the enum will work the same across +//! platforms: +//! +//! ```rust +//! # #[macro_use] extern crate nix; +//! # use nix::sys::termios::{BaudRate, cfsetispeed, cfsetospeed, cfsetspeed, Termios}; +//! # fn main() { +//! # let mut t = unsafe { Termios::default_uninit() }; +//! cfsetispeed(&mut t, BaudRate::B9600); +//! cfsetospeed(&mut t, BaudRate::B9600); +//! cfsetspeed(&mut t, BaudRate::B9600); +//! # } +//! ``` +//! +//! Additionally round-tripping baud rates is consistent across platforms: +//! +//! ```rust +//! # extern crate nix; +//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfgetospeed, cfsetispeed, cfsetspeed, Termios}; +//! # fn main() { +//! # let mut t = unsafe { Termios::default_uninit() }; +//! # cfsetspeed(&mut t, BaudRate::B9600); +//! let speed = cfgetispeed(&t); +//! assert!(speed == cfgetospeed(&t)); +//! cfsetispeed(&mut t, speed); +//! # } +//! ``` +//! +//! On non-BSDs, `cfgetispeed()` and `cfgetospeed()` both return a `BaudRate`: +//! +// FIXME: Replace `ignore` with `compile_fail` once 1.22 is the minimum support Rust version +#![cfg_attr(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "macos", target_os = "netbsd", target_os = "openbsd"), + doc = " ```rust,ignore")] +#![cfg_attr(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "macos", target_os = "netbsd", target_os = "openbsd")), + doc = " ```rust")] +//! # extern crate nix; +//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfgetospeed, cfsetspeed, Termios}; +//! # fn main() { +//! # let mut t = unsafe { Termios::default_uninit() }; +//! # cfsetspeed(&mut t, BaudRate::B9600); +//! assert!(cfgetispeed(&t) == BaudRate::B9600); +//! assert!(cfgetospeed(&t) == BaudRate::B9600); +//! # } +//! ``` +//! +//! But on the BSDs, `cfgetispeed()` and `cfgetospeed()` both return `u32`s: +//! +// FIXME: Replace `ignore` with `compile_fail` once 1.22 is the minimum support Rust version +#![cfg_attr(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "macos", target_os = "netbsd", target_os = "openbsd"), + doc = " ```rust")] +#![cfg_attr(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "macos", target_os = "netbsd", target_os = "openbsd")), + doc = " ```rust,ignore")] +//! # extern crate nix; +//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfgetospeed, cfsetspeed, Termios}; +//! # fn main() { +//! # let mut t = unsafe { Termios::default_uninit() }; +//! # cfsetspeed(&mut t, 9600u32); +//! assert!(cfgetispeed(&t) == 9600u32); +//! assert!(cfgetospeed(&t) == 9600u32); +//! # } +//! ``` +//! +//! It's trivial to convert from a `BaudRate` to a `u32` on BSDs: +//! +// FIXME: Replace `ignore` with `compile_fail` once 1.22 is the minimum support Rust version +#![cfg_attr(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "macos", target_os = "netbsd", target_os = "openbsd"), + doc = " ```rust")] +#![cfg_attr(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "macos", target_os = "netbsd", target_os = "openbsd")), + doc = " ```rust,ignore")] +//! # extern crate nix; +//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfsetspeed, Termios}; +//! # fn main() { +//! # let mut t = unsafe { Termios::default_uninit() }; +//! # cfsetspeed(&mut t, 9600u32); +//! assert!(cfgetispeed(&t) == BaudRate::B9600.into()); +//! assert!(u32::from(BaudRate::B9600) == 9600u32); +//! # } +//! ``` +//! +//! And on BSDs you can specify arbitrary baud rates (**note** this depends on hardware support) +//! by specifying baud rates directly using `u32`s: +//! +// FIXME: Replace `ignore` with `compile_fail` once 1.22 is the minimum support Rust version +#![cfg_attr(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "macos", target_os = "netbsd", target_os = "openbsd"), + doc = " ```rust")] +#![cfg_attr(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "macos", target_os = "netbsd", target_os = "openbsd")), + doc = " ```rust,ignore")] +//! # extern crate nix; +//! # use nix::sys::termios::{cfsetispeed, cfsetospeed, cfsetspeed, Termios}; +//! # fn main() { +//! # let mut t = unsafe { Termios::default_uninit() }; +//! cfsetispeed(&mut t, 9600u32); +//! cfsetospeed(&mut t, 9600u32); +//! cfsetspeed(&mut t, 9600u32); +//! # } +//! ``` +use Result; +use errno::Errno; +use libc::{self, c_int, tcflag_t}; +use std::cell::{Ref, RefCell}; +use std::convert::From; +use std::mem; +use std::os::unix::io::RawFd; + +use ::unistd::Pid; + +/// Stores settings for the termios API +/// +/// This is a wrapper around the `libc::termios` struct that provides a safe interface for the +/// standard fields. The only safe way to obtain an instance of this struct is to extract it from +/// an open port using `tcgetattr()`. +#[derive(Clone)] +#[allow(missing_debug_implementations)] +pub struct Termios { + inner: RefCell, + /// Input mode flags (see `termios.c_iflag` documentation) + pub input_flags: InputFlags, + /// Output mode flags (see `termios.c_oflag` documentation) + pub output_flags: OutputFlags, + /// Control mode flags (see `termios.c_cflag` documentation) + pub control_flags: ControlFlags, + /// Local mode flags (see `termios.c_lflag` documentation) + pub local_flags: LocalFlags, + /// Control characters (see `termios.c_cc` documentation) + pub control_chars: [libc::cc_t; NCCS], +} + +impl Termios { + /// Exposes an immutable reference to the underlying `libc::termios` data structure. + /// + /// This can be used for interfacing with other FFI functions like: + /// + /// ```rust + /// # extern crate libc; + /// # extern crate nix; + /// # fn main() { + /// # use nix::sys::termios::Termios; + /// # let mut termios = unsafe { Termios::default_uninit() }; + /// let inner_termios = termios.get_libc_termios(); + /// unsafe { libc::cfgetispeed(&*inner_termios) }; + /// # } + /// ``` + /// + /// There is no public API exposed for functions that modify the underlying `libc::termios` + /// data because it requires additional work to maintain type safety. + // FIXME: Switch this over to use pub(crate) + #[doc(hidden)] + pub fn get_libc_termios(&self) -> Ref { + { + let mut termios = self.inner.borrow_mut(); + termios.c_iflag = self.input_flags.bits(); + termios.c_oflag = self.output_flags.bits(); + termios.c_cflag = self.control_flags.bits(); + termios.c_lflag = self.local_flags.bits(); + termios.c_cc = self.control_chars; + } + self.inner.borrow() + } + + /// Exposes the inner `libc::termios` datastore within `Termios`. + /// + /// This is unsafe because if this is used to modify the inner libc::termios struct, it will not + /// automatically update the safe wrapper type around it. Therefore we disable docs to + /// effectively limit its use to nix internals. In this case it should also be paired with a + /// call to `update_wrapper()` so that the wrapper-type and internal representation stay + /// consistent. + unsafe fn get_libc_termios_mut(&mut self) -> *mut libc::termios { + { + let mut termios = self.inner.borrow_mut(); + termios.c_iflag = self.input_flags.bits(); + termios.c_oflag = self.output_flags.bits(); + termios.c_cflag = self.control_flags.bits(); + termios.c_lflag = self.local_flags.bits(); + termios.c_cc = self.control_chars; + } + self.inner.as_ptr() + } + + /// Allows for easily creating new `Termios` structs that will be overwritten with real data. + /// + /// This should only be used when the inner libc::termios struct will be overwritten before it's + /// read. + // FIXME: Switch this over to use pub(crate) + #[doc(hidden)] + pub unsafe fn default_uninit() -> Self { + Termios { + inner: RefCell::new(mem::uninitialized()), + input_flags: InputFlags::empty(), + output_flags: OutputFlags::empty(), + control_flags: ControlFlags::empty(), + local_flags: LocalFlags::empty(), + control_chars: [0 as libc::cc_t; NCCS], + } + } + + /// Updates the wrapper values from the internal `libc::termios` data structure. + #[doc(hidden)] + pub fn update_wrapper(&mut self) { + let termios = *self.inner.borrow_mut(); + self.input_flags = InputFlags::from_bits_truncate(termios.c_iflag); + self.output_flags = OutputFlags::from_bits_truncate(termios.c_oflag); + self.control_flags = ControlFlags::from_bits_truncate(termios.c_cflag); + self.local_flags = LocalFlags::from_bits_truncate(termios.c_lflag); + self.control_chars = termios.c_cc; + } +} + +impl From for Termios { + fn from(termios: libc::termios) -> Self { + Termios { + inner: RefCell::new(termios), + input_flags: InputFlags::from_bits_truncate(termios.c_iflag), + output_flags: OutputFlags::from_bits_truncate(termios.c_oflag), + control_flags: ControlFlags::from_bits_truncate(termios.c_cflag), + local_flags: LocalFlags::from_bits_truncate(termios.c_lflag), + control_chars: termios.c_cc, + } + } +} + +impl From for libc::termios { + fn from(termios: Termios) -> Self { + termios.inner.into_inner() + } +} + +libc_enum!{ + /// Baud rates supported by the system. + /// + /// For the BSDs, arbitrary baud rates can be specified by using `u32`s directly instead of this + /// enum. + /// + /// B0 is special and will disable the port. + #[cfg_attr(all(any(target_os = "ios", target_os = "macos"), target_pointer_width = "64"), repr(u64))] + #[cfg_attr(not(all(any(target_os = "ios", target_os = "macos"), target_pointer_width = "64")), repr(u32))] + pub enum BaudRate { + B0, + B50, + B75, + B110, + B134, + B150, + B200, + B300, + B600, + B1200, + B1800, + B2400, + B4800, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + B7200, + B9600, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + B14400, + B19200, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + B28800, + B38400, + B57600, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + B76800, + B115200, + B230400, + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd"))] + B460800, + #[cfg(any(target_os = "android", target_os = "linux"))] + B500000, + #[cfg(any(target_os = "android", target_os = "linux"))] + B576000, + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd"))] + B921600, + #[cfg(any(target_os = "android", target_os = "linux"))] + B1000000, + #[cfg(any(target_os = "android", target_os = "linux"))] + B1152000, + #[cfg(any(target_os = "android", target_os = "linux"))] + B1500000, + #[cfg(any(target_os = "android", target_os = "linux"))] + B2000000, + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_arch = "sparc64"))))] + B2500000, + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_arch = "sparc64"))))] + B3000000, + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_arch = "sparc64"))))] + B3500000, + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_arch = "sparc64"))))] + B4000000, + } +} + +impl From for BaudRate { + fn from(s: libc::speed_t) -> BaudRate { + + use libc::{B0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400, B4800, + B9600, B19200, B38400, B57600, B115200, B230400}; + #[cfg(any(target_os = "android", target_os = "linux"))] + use libc::{B500000, B576000, B1000000, B1152000, B1500000, B2000000}; + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_arch = "sparc64"))))] + use libc::{B2500000, B3000000, B3500000, B4000000}; + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + use libc::{B7200, B14400, B28800, B76800}; + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd"))] + use libc::{B460800, B921600}; + + match s { + B0 => BaudRate::B0, + B50 => BaudRate::B50, + B75 => BaudRate::B75, + B110 => BaudRate::B110, + B134 => BaudRate::B134, + B150 => BaudRate::B150, + B200 => BaudRate::B200, + B300 => BaudRate::B300, + B600 => BaudRate::B600, + B1200 => BaudRate::B1200, + B1800 => BaudRate::B1800, + B2400 => BaudRate::B2400, + B4800 => BaudRate::B4800, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + B7200 => BaudRate::B7200, + B9600 => BaudRate::B9600, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + B14400 => BaudRate::B14400, + B19200 => BaudRate::B19200, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + B28800 => BaudRate::B28800, + B38400 => BaudRate::B38400, + B57600 => BaudRate::B57600, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + B76800 => BaudRate::B76800, + B115200 => BaudRate::B115200, + B230400 => BaudRate::B230400, + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd"))] + B460800 => BaudRate::B460800, + #[cfg(any(target_os = "android", target_os = "linux"))] + B500000 => BaudRate::B500000, + #[cfg(any(target_os = "android", target_os = "linux"))] + B576000 => BaudRate::B576000, + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd"))] + B921600 => BaudRate::B921600, + #[cfg(any(target_os = "android", target_os = "linux"))] + B1000000 => BaudRate::B1000000, + #[cfg(any(target_os = "android", target_os = "linux"))] + B1152000 => BaudRate::B1152000, + #[cfg(any(target_os = "android", target_os = "linux"))] + B1500000 => BaudRate::B1500000, + #[cfg(any(target_os = "android", target_os = "linux"))] + B2000000 => BaudRate::B2000000, + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_arch = "sparc64"))))] + B2500000 => BaudRate::B2500000, + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_arch = "sparc64"))))] + B3000000 => BaudRate::B3000000, + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_arch = "sparc64"))))] + B3500000 => BaudRate::B3500000, + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_arch = "sparc64"))))] + B4000000 => BaudRate::B4000000, + b => unreachable!("Invalid baud constant: {}", b), + } + } +} + +// TODO: Include `TryFrom for BaudRate` once that API stabilizes +#[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +impl From for u32 { + fn from(b: BaudRate) -> u32 { + b as u32 + } +} + +// TODO: Add TCSASOFT, which will require treating this as a bitfield. +libc_enum! { + /// Specify when a port configuration change should occur. + /// + /// Used as an argument to `tcsetattr()` + #[repr(i32)] + pub enum SetArg { + /// The change will occur immediately + TCSANOW, + /// The change occurs after all output has been written + TCSADRAIN, + /// Same as `TCSADRAIN`, but will also flush the input buffer + TCSAFLUSH, + } +} + +libc_enum! { + /// Specify a combination of the input and output buffers to flush + /// + /// Used as an argument to `tcflush()`. + #[repr(i32)] + pub enum FlushArg { + /// Flush data that was received but not read + TCIFLUSH, + /// Flush data written but not transmitted + TCOFLUSH, + /// Flush both received data not read and written data not transmitted + TCIOFLUSH, + } +} + +libc_enum! { + /// Specify how transmission flow should be altered + /// + /// Used as an argument to `tcflow()`. + #[repr(i32)] + pub enum FlowArg { + /// Suspend transmission + TCOOFF, + /// Resume transmission + TCOON, + /// Transmit a STOP character, which should disable a connected terminal device + TCIOFF, + /// Transmit a START character, which should re-enable a connected terminal device + TCION, + } +} + +// TODO: Make this usable directly as a slice index. +libc_enum! { + /// Indices into the `termios.c_cc` array for special characters. + #[repr(usize)] + pub enum SpecialCharacterIndices { + VDISCARD, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + VDSUSP, + VEOF, + VEOL, + VEOL2, + VERASE, + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + VERASE2, + VINTR, + VKILL, + VLNEXT, + #[cfg(not(all(target_os = "linux", target_arch = "sparc64")))] + VMIN, + VQUIT, + VREPRINT, + VSTART, + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + VSTATUS, + VSTOP, + VSUSP, + #[cfg(target_os = "linux")] + VSWTC, + #[cfg(target_os = "haiku")] + VSWTCH, + #[cfg(not(all(target_os = "linux", target_arch = "sparc64")))] + VTIME, + VWERASE, + #[cfg(target_os = "dragonfly")] + VCHECKPT, + } +} + +pub use libc::NCCS; +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +pub use libc::_POSIX_VDISABLE; + +libc_bitflags! { + /// Flags for configuring the input mode of a terminal + pub struct InputFlags: tcflag_t { + IGNBRK; + BRKINT; + IGNPAR; + PARMRK; + INPCK; + ISTRIP; + INLCR; + IGNCR; + ICRNL; + IXON; + IXOFF; + IXANY; + IMAXBEL; + #[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))] + IUTF8; + } +} + +libc_bitflags! { + /// Flags for configuring the output mode of a terminal + pub struct OutputFlags: tcflag_t { + OPOST; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "linux", + target_os = "openbsd"))] + OLCUC; + ONLCR; + OCRNL as tcflag_t; + ONOCR as tcflag_t; + ONLRET as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + OFILL as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + OFDEL as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + NL0 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + NL1 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + CR0 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + CR1 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + CR2 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + CR3 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + TAB0 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + TAB1 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + TAB2 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + TAB3 as tcflag_t; + #[cfg(any(target_os = "android", target_os = "linux"))] + XTABS; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + BS0 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + BS1 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + VT0 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + VT1 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + FF0 as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + FF1 as tcflag_t; + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + OXTABS; + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + ONOEOT as tcflag_t; + + // Bitmasks for use with OutputFlags to select specific settings + // These should be moved to be a mask once https://github.com/rust-lang-nursery/bitflags/issues/110 + // is resolved. + + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + NLDLY as tcflag_t; // FIXME: Datatype needs to be corrected in libc for mac + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + CRDLY as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + TABDLY as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + BSDLY as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + VTDLY as tcflag_t; + #[cfg(any(target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] + FFDLY as tcflag_t; + } +} + +libc_bitflags! { + /// Flags for setting the control mode of a terminal + pub struct ControlFlags: tcflag_t { + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + CIGNORE; + CS5; + CS6; + CS7; + CS8; + CSTOPB; + CREAD; + PARENB; + PARODD; + HUPCL; + CLOCAL; + CRTSCTS; + #[cfg(any(target_os = "android", target_os = "linux"))] + CBAUD; + #[cfg(any(target_os = "android", all(target_os = "linux", not(target_arch = "mips"))))] + CMSPAR; + #[cfg(any(target_os = "android", + all(target_os = "linux", + not(any(target_arch = "powerpc", target_arch = "powerpc64")))))] + CIBAUD; + #[cfg(any(target_os = "android", target_os = "linux"))] + CBAUDEX; + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + MDMBUF; + #[cfg(any(target_os = "netbsd", target_os = "openbsd"))] + CHWFLOW; + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd"))] + CCTS_OFLOW; + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd"))] + CRTS_IFLOW; + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd"))] + CDTR_IFLOW; + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd"))] + CDSR_OFLOW; + #[cfg(any(target_os = "dragonfly", + target_os = "freebsd"))] + CCAR_OFLOW; + + // Bitmasks for use with ControlFlags to select specific settings + // These should be moved to be a mask once https://github.com/rust-lang-nursery/bitflags/issues/110 + // is resolved. + + CSIZE; + } +} + +libc_bitflags! { + /// Flags for setting any local modes + pub struct LocalFlags: tcflag_t { + ECHOKE; + ECHOE; + ECHOK; + ECHO; + ECHONL; + ECHOPRT; + ECHOCTL; + ISIG; + ICANON; + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + ALTWERASE; + IEXTEN; + EXTPROC; + TOSTOP; + FLUSHO; + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] + NOKERNINFO; + PENDIN; + NOFLSH; + } +} + +cfg_if!{ + if #[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] { + /// Get input baud rate (see + /// [cfgetispeed(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/cfgetispeed.html)). + /// + /// `cfgetispeed()` extracts the input baud rate from the given `Termios` structure. + pub fn cfgetispeed(termios: &Termios) -> u32 { + let inner_termios = termios.get_libc_termios(); + unsafe { libc::cfgetispeed(&*inner_termios) as u32 } + } + + /// Get output baud rate (see + /// [cfgetospeed(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/cfgetospeed.html)). + /// + /// `cfgetospeed()` extracts the output baud rate from the given `Termios` structure. + pub fn cfgetospeed(termios: &Termios) -> u32 { + let inner_termios = termios.get_libc_termios(); + unsafe { libc::cfgetospeed(&*inner_termios) as u32 } + } + + /// Set input baud rate (see + /// [cfsetispeed(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/cfsetispeed.html)). + /// + /// `cfsetispeed()` sets the intput baud rate in the given `Termios` structure. + pub fn cfsetispeed>(termios: &mut Termios, baud: T) -> Result<()> { + let inner_termios = unsafe { termios.get_libc_termios_mut() }; + let res = unsafe { libc::cfsetispeed(inner_termios, baud.into() as libc::speed_t) }; + termios.update_wrapper(); + Errno::result(res).map(drop) + } + + /// Set output baud rate (see + /// [cfsetospeed(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/cfsetospeed.html)). + /// + /// `cfsetospeed()` sets the output baud rate in the given termios structure. + pub fn cfsetospeed>(termios: &mut Termios, baud: T) -> Result<()> { + let inner_termios = unsafe { termios.get_libc_termios_mut() }; + let res = unsafe { libc::cfsetospeed(inner_termios, baud.into() as libc::speed_t) }; + termios.update_wrapper(); + Errno::result(res).map(drop) + } + + /// Set both the input and output baud rates (see + /// [termios(3)](https://www.freebsd.org/cgi/man.cgi?query=cfsetspeed)). + /// + /// `cfsetspeed()` sets the input and output baud rate in the given termios structure. Note that + /// this is part of the 4.4BSD standard and not part of POSIX. + pub fn cfsetspeed>(termios: &mut Termios, baud: T) -> Result<()> { + let inner_termios = unsafe { termios.get_libc_termios_mut() }; + let res = unsafe { libc::cfsetspeed(inner_termios, baud.into() as libc::speed_t) }; + termios.update_wrapper(); + Errno::result(res).map(drop) + } + } else { + /// Get input baud rate (see + /// [cfgetispeed(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/cfgetispeed.html)). + /// + /// `cfgetispeed()` extracts the input baud rate from the given `Termios` structure. + pub fn cfgetispeed(termios: &Termios) -> BaudRate { + let inner_termios = termios.get_libc_termios(); + unsafe { libc::cfgetispeed(&*inner_termios) }.into() + } + + /// Get output baud rate (see + /// [cfgetospeed(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/cfgetospeed.html)). + /// + /// `cfgetospeed()` extracts the output baud rate from the given `Termios` structure. + pub fn cfgetospeed(termios: &Termios) -> BaudRate { + let inner_termios = termios.get_libc_termios(); + unsafe { libc::cfgetospeed(&*inner_termios) }.into() + } + + /// Set input baud rate (see + /// [cfsetispeed(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/cfsetispeed.html)). + /// + /// `cfsetispeed()` sets the intput baud rate in the given `Termios` structure. + pub fn cfsetispeed(termios: &mut Termios, baud: BaudRate) -> Result<()> { + let inner_termios = unsafe { termios.get_libc_termios_mut() }; + let res = unsafe { libc::cfsetispeed(inner_termios, baud as libc::speed_t) }; + termios.update_wrapper(); + Errno::result(res).map(drop) + } + + /// Set output baud rate (see + /// [cfsetospeed(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/cfsetospeed.html)). + /// + /// `cfsetospeed()` sets the output baud rate in the given `Termios` structure. + pub fn cfsetospeed(termios: &mut Termios, baud: BaudRate) -> Result<()> { + let inner_termios = unsafe { termios.get_libc_termios_mut() }; + let res = unsafe { libc::cfsetospeed(inner_termios, baud as libc::speed_t) }; + termios.update_wrapper(); + Errno::result(res).map(drop) + } + + /// Set both the input and output baud rates (see + /// [termios(3)](https://www.freebsd.org/cgi/man.cgi?query=cfsetspeed)). + /// + /// `cfsetspeed()` sets the input and output baud rate in the given `Termios` structure. Note that + /// this is part of the 4.4BSD standard and not part of POSIX. + pub fn cfsetspeed(termios: &mut Termios, baud: BaudRate) -> Result<()> { + let inner_termios = unsafe { termios.get_libc_termios_mut() }; + let res = unsafe { libc::cfsetspeed(inner_termios, baud as libc::speed_t) }; + termios.update_wrapper(); + Errno::result(res).map(drop) + } + } +} + +/// Configures the port to something like the "raw" mode of the old Version 7 terminal driver (see +/// [termios(3)](http://man7.org/linux/man-pages/man3/termios.3.html)). +/// +/// `cfmakeraw()` configures the termios structure such that input is available character-by- +/// character, echoing is disabled, and all special input and output processing is disabled. Note +/// that this is a non-standard function, but is available on Linux and BSDs. +pub fn cfmakeraw(termios: &mut Termios) { + let inner_termios = unsafe { termios.get_libc_termios_mut() }; + unsafe { + libc::cfmakeraw(inner_termios); + } + termios.update_wrapper(); +} + +/// Configures the port to "sane" mode (like the configuration of a newly created terminal) (see +/// [tcsetattr(3)](https://www.freebsd.org/cgi/man.cgi?query=tcsetattr)). +/// +/// Note that this is a non-standard function, available on FreeBSD. +#[cfg(target_os = "freebsd")] +pub fn cfmakesane(termios: &mut Termios) { + let inner_termios = unsafe { termios.get_libc_termios_mut() }; + unsafe { + libc::cfmakesane(inner_termios); + } + termios.update_wrapper(); +} + +/// Return the configuration of a port +/// [tcgetattr(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetattr.html)). +/// +/// `tcgetattr()` returns a `Termios` structure with the current configuration for a port. Modifying +/// this structure *will not* reconfigure the port, instead the modifications should be done to +/// the `Termios` structure and then the port should be reconfigured using `tcsetattr()`. +pub fn tcgetattr(fd: RawFd) -> Result { + let mut termios: libc::termios = unsafe { mem::uninitialized() }; + + let res = unsafe { libc::tcgetattr(fd, &mut termios) }; + + Errno::result(res)?; + + Ok(termios.into()) +} + +/// Set the configuration for a terminal (see +/// [tcsetattr(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcsetattr.html)). +/// +/// `tcsetattr()` reconfigures the given port based on a given `Termios` structure. This change +/// takes affect at a time specified by `actions`. Note that this function may return success if +/// *any* of the parameters were successfully set, not only if all were set successfully. +pub fn tcsetattr(fd: RawFd, actions: SetArg, termios: &Termios) -> Result<()> { + let inner_termios = termios.get_libc_termios(); + Errno::result(unsafe { libc::tcsetattr(fd, actions as c_int, &*inner_termios) }).map(drop) +} + +/// Block until all output data is written (see +/// [tcdrain(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcdrain.html)). +pub fn tcdrain(fd: RawFd) -> Result<()> { + Errno::result(unsafe { libc::tcdrain(fd) }).map(drop) +} + +/// Suspend or resume the transmission or reception of data (see +/// [tcflow(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcflow.html)). +/// +/// `tcflow()` suspends of resumes the transmission or reception of data for the given port +/// depending on the value of `action`. +pub fn tcflow(fd: RawFd, action: FlowArg) -> Result<()> { + Errno::result(unsafe { libc::tcflow(fd, action as c_int) }).map(drop) +} + +/// Discard data in the output or input queue (see +/// [tcflush(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcflush.html)). +/// +/// `tcflush()` will discard data for a terminal port in the input queue, output queue, or both +/// depending on the value of `action`. +pub fn tcflush(fd: RawFd, action: FlushArg) -> Result<()> { + Errno::result(unsafe { libc::tcflush(fd, action as c_int) }).map(drop) +} + +/// Send a break for a specific duration (see +/// [tcsendbreak(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcsendbreak.html)). +/// +/// When using asynchronous data transmission `tcsendbreak()` will transmit a continuous stream +/// of zero-valued bits for an implementation-defined duration. +pub fn tcsendbreak(fd: RawFd, duration: c_int) -> Result<()> { + Errno::result(unsafe { libc::tcsendbreak(fd, duration) }).map(drop) +} + +/// Get the session controlled by the given terminal (see +/// [tcgetsid(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetsid.html)). +pub fn tcgetsid(fd: RawFd) -> Result { + let res = unsafe { libc::tcgetsid(fd) }; + + Errno::result(res).map(Pid::from_raw) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/time.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/time.rs new file mode 100644 index 0000000..4bd3b78 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/time.rs @@ -0,0 +1,580 @@ +use std::{cmp, fmt, ops}; +use std::convert::From; +use libc::{c_long, timespec, timeval}; +pub use libc::{time_t, suseconds_t}; + +pub trait TimeValLike: Sized { + #[inline] + fn zero() -> Self { + Self::seconds(0) + } + + #[inline] + fn hours(hours: i64) -> Self { + let secs = hours.checked_mul(SECS_PER_HOUR) + .expect("TimeValLike::hours ouf of bounds"); + Self::seconds(secs) + } + + #[inline] + fn minutes(minutes: i64) -> Self { + let secs = minutes.checked_mul(SECS_PER_MINUTE) + .expect("TimeValLike::minutes out of bounds"); + Self::seconds(secs) + } + + fn seconds(seconds: i64) -> Self; + fn milliseconds(milliseconds: i64) -> Self; + fn microseconds(microseconds: i64) -> Self; + fn nanoseconds(nanoseconds: i64) -> Self; + + #[inline] + fn num_hours(&self) -> i64 { + self.num_seconds() / 3600 + } + + #[inline] + fn num_minutes(&self) -> i64 { + self.num_seconds() / 60 + } + + fn num_seconds(&self) -> i64; + fn num_milliseconds(&self) -> i64; + fn num_microseconds(&self) -> i64; + fn num_nanoseconds(&self) -> i64; +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct TimeSpec(timespec); + +const NANOS_PER_SEC: i64 = 1_000_000_000; +const SECS_PER_MINUTE: i64 = 60; +const SECS_PER_HOUR: i64 = 3600; + +#[cfg(target_pointer_width = "64")] +const TS_MAX_SECONDS: i64 = (::std::i64::MAX / NANOS_PER_SEC) - 1; + +#[cfg(target_pointer_width = "32")] +const TS_MAX_SECONDS: i64 = ::std::isize::MAX as i64; + +const TS_MIN_SECONDS: i64 = -TS_MAX_SECONDS; + + +impl AsRef for TimeSpec { + fn as_ref(&self) -> ×pec { + &self.0 + } +} + +impl fmt::Debug for TimeSpec { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("TimeSpec") + .field("tv_sec", &self.tv_sec()) + .field("tv_nsec", &self.tv_nsec()) + .finish() + } +} + +impl PartialEq for TimeSpec { + // The implementation of cmp is simplified by assuming that the struct is + // normalized. That is, tv_nsec must always be within [0, 1_000_000_000) + fn eq(&self, other: &TimeSpec) -> bool { + self.tv_sec() == other.tv_sec() && self.tv_nsec() == other.tv_nsec() + } +} + +impl Eq for TimeSpec {} + +impl Ord for TimeSpec { + // The implementation of cmp is simplified by assuming that the struct is + // normalized. That is, tv_nsec must always be within [0, 1_000_000_000) + fn cmp(&self, other: &TimeSpec) -> cmp::Ordering { + if self.tv_sec() == other.tv_sec() { + self.tv_nsec().cmp(&other.tv_nsec()) + } else { + self.tv_sec().cmp(&other.tv_sec()) + } + } +} + +impl PartialOrd for TimeSpec { + fn partial_cmp(&self, other: &TimeSpec) -> Option { + Some(self.cmp(other)) + } +} + +impl TimeValLike for TimeSpec { + #[inline] + fn seconds(seconds: i64) -> TimeSpec { + assert!(seconds >= TS_MIN_SECONDS && seconds <= TS_MAX_SECONDS, + "TimeSpec out of bounds; seconds={}", seconds); + TimeSpec(timespec {tv_sec: seconds as time_t, tv_nsec: 0 }) + } + + #[inline] + fn milliseconds(milliseconds: i64) -> TimeSpec { + let nanoseconds = milliseconds.checked_mul(1_000_000) + .expect("TimeSpec::milliseconds out of bounds"); + + TimeSpec::nanoseconds(nanoseconds) + } + + /// Makes a new `TimeSpec` with given number of microseconds. + #[inline] + fn microseconds(microseconds: i64) -> TimeSpec { + let nanoseconds = microseconds.checked_mul(1_000) + .expect("TimeSpec::milliseconds out of bounds"); + + TimeSpec::nanoseconds(nanoseconds) + } + + /// Makes a new `TimeSpec` with given number of nanoseconds. + #[inline] + fn nanoseconds(nanoseconds: i64) -> TimeSpec { + let (secs, nanos) = div_mod_floor_64(nanoseconds, NANOS_PER_SEC); + assert!(secs >= TS_MIN_SECONDS && secs <= TS_MAX_SECONDS, + "TimeSpec out of bounds"); + TimeSpec(timespec {tv_sec: secs as time_t, + tv_nsec: nanos as c_long }) + } + + fn num_seconds(&self) -> i64 { + if self.tv_sec() < 0 && self.tv_nsec() > 0 { + (self.tv_sec() + 1) as i64 + } else { + self.tv_sec() as i64 + } + } + + fn num_milliseconds(&self) -> i64 { + self.num_nanoseconds() / 1_000_000 + } + + fn num_microseconds(&self) -> i64 { + self.num_nanoseconds() / 1_000_000_000 + } + + fn num_nanoseconds(&self) -> i64 { + let secs = self.num_seconds() * 1_000_000_000; + let nsec = self.nanos_mod_sec(); + secs + nsec as i64 + } +} + +impl TimeSpec { + fn nanos_mod_sec(&self) -> c_long { + if self.tv_sec() < 0 && self.tv_nsec() > 0 { + self.tv_nsec() - NANOS_PER_SEC as c_long + } else { + self.tv_nsec() + } + } + + pub fn tv_sec(&self) -> time_t { + self.0.tv_sec + } + + pub fn tv_nsec(&self) -> c_long { + self.0.tv_nsec + } +} + +impl ops::Neg for TimeSpec { + type Output = TimeSpec; + + fn neg(self) -> TimeSpec { + TimeSpec::nanoseconds(-self.num_nanoseconds()) + } +} + +impl ops::Add for TimeSpec { + type Output = TimeSpec; + + fn add(self, rhs: TimeSpec) -> TimeSpec { + TimeSpec::nanoseconds( + self.num_nanoseconds() + rhs.num_nanoseconds()) + } +} + +impl ops::Sub for TimeSpec { + type Output = TimeSpec; + + fn sub(self, rhs: TimeSpec) -> TimeSpec { + TimeSpec::nanoseconds( + self.num_nanoseconds() - rhs.num_nanoseconds()) + } +} + +impl ops::Mul for TimeSpec { + type Output = TimeSpec; + + fn mul(self, rhs: i32) -> TimeSpec { + let usec = self.num_nanoseconds().checked_mul(rhs as i64) + .expect("TimeSpec multiply out of bounds"); + + TimeSpec::nanoseconds(usec) + } +} + +impl ops::Div for TimeSpec { + type Output = TimeSpec; + + fn div(self, rhs: i32) -> TimeSpec { + let usec = self.num_nanoseconds() / rhs as i64; + TimeSpec::nanoseconds(usec) + } +} + +impl fmt::Display for TimeSpec { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let (abs, sign) = if self.tv_sec() < 0 { + (-*self, "-") + } else { + (*self, "") + }; + + let sec = abs.tv_sec(); + + write!(f, "{}", sign)?; + + if abs.tv_nsec() == 0 { + if abs.tv_sec() == 1 { + write!(f, "{} second", sec)?; + } else { + write!(f, "{} seconds", sec)?; + } + } else if abs.tv_nsec() % 1_000_000 == 0 { + write!(f, "{}.{:03} seconds", sec, abs.tv_nsec() / 1_000_000)?; + } else if abs.tv_nsec() % 1_000 == 0 { + write!(f, "{}.{:06} seconds", sec, abs.tv_nsec() / 1_000)?; + } else { + write!(f, "{}.{:09} seconds", sec, abs.tv_nsec())?; + } + + Ok(()) + } +} + + + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct TimeVal(timeval); + +const MICROS_PER_SEC: i64 = 1_000_000; + +#[cfg(target_pointer_width = "64")] +const TV_MAX_SECONDS: i64 = (::std::i64::MAX / MICROS_PER_SEC) - 1; + +#[cfg(target_pointer_width = "32")] +const TV_MAX_SECONDS: i64 = ::std::isize::MAX as i64; + +const TV_MIN_SECONDS: i64 = -TV_MAX_SECONDS; + +impl AsRef for TimeVal { + fn as_ref(&self) -> &timeval { + &self.0 + } +} + +impl fmt::Debug for TimeVal { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("TimeVal") + .field("tv_sec", &self.tv_sec()) + .field("tv_usec", &self.tv_usec()) + .finish() + } +} + +impl PartialEq for TimeVal { + // The implementation of cmp is simplified by assuming that the struct is + // normalized. That is, tv_usec must always be within [0, 1_000_000) + fn eq(&self, other: &TimeVal) -> bool { + self.tv_sec() == other.tv_sec() && self.tv_usec() == other.tv_usec() + } +} + +impl Eq for TimeVal {} + +impl Ord for TimeVal { + // The implementation of cmp is simplified by assuming that the struct is + // normalized. That is, tv_usec must always be within [0, 1_000_000) + fn cmp(&self, other: &TimeVal) -> cmp::Ordering { + if self.tv_sec() == other.tv_sec() { + self.tv_usec().cmp(&other.tv_usec()) + } else { + self.tv_sec().cmp(&other.tv_sec()) + } + } +} + +impl PartialOrd for TimeVal { + fn partial_cmp(&self, other: &TimeVal) -> Option { + Some(self.cmp(other)) + } +} + +impl TimeValLike for TimeVal { + #[inline] + fn seconds(seconds: i64) -> TimeVal { + assert!(seconds >= TV_MIN_SECONDS && seconds <= TV_MAX_SECONDS, + "TimeVal out of bounds; seconds={}", seconds); + TimeVal(timeval {tv_sec: seconds as time_t, tv_usec: 0 }) + } + + #[inline] + fn milliseconds(milliseconds: i64) -> TimeVal { + let microseconds = milliseconds.checked_mul(1_000) + .expect("TimeVal::milliseconds out of bounds"); + + TimeVal::microseconds(microseconds) + } + + /// Makes a new `TimeVal` with given number of microseconds. + #[inline] + fn microseconds(microseconds: i64) -> TimeVal { + let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC); + assert!(secs >= TV_MIN_SECONDS && secs <= TV_MAX_SECONDS, + "TimeVal out of bounds"); + TimeVal(timeval {tv_sec: secs as time_t, + tv_usec: micros as suseconds_t }) + } + + /// Makes a new `TimeVal` with given number of nanoseconds. Some precision + /// will be lost + #[inline] + fn nanoseconds(nanoseconds: i64) -> TimeVal { + let microseconds = nanoseconds / 1000; + let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC); + assert!(secs >= TV_MIN_SECONDS && secs <= TV_MAX_SECONDS, + "TimeVal out of bounds"); + TimeVal(timeval {tv_sec: secs as time_t, + tv_usec: micros as suseconds_t }) + } + + fn num_seconds(&self) -> i64 { + if self.tv_sec() < 0 && self.tv_usec() > 0 { + (self.tv_sec() + 1) as i64 + } else { + self.tv_sec() as i64 + } + } + + fn num_milliseconds(&self) -> i64 { + self.num_microseconds() / 1_000 + } + + fn num_microseconds(&self) -> i64 { + let secs = self.num_seconds() * 1_000_000; + let usec = self.micros_mod_sec(); + secs + usec as i64 + } + + fn num_nanoseconds(&self) -> i64 { + self.num_microseconds() * 1_000 + } +} + +impl TimeVal { + fn micros_mod_sec(&self) -> suseconds_t { + if self.tv_sec() < 0 && self.tv_usec() > 0 { + self.tv_usec() - MICROS_PER_SEC as suseconds_t + } else { + self.tv_usec() + } + } + + pub fn tv_sec(&self) -> time_t { + self.0.tv_sec + } + + pub fn tv_usec(&self) -> suseconds_t { + self.0.tv_usec + } +} + +impl ops::Neg for TimeVal { + type Output = TimeVal; + + fn neg(self) -> TimeVal { + TimeVal::microseconds(-self.num_microseconds()) + } +} + +impl ops::Add for TimeVal { + type Output = TimeVal; + + fn add(self, rhs: TimeVal) -> TimeVal { + TimeVal::microseconds( + self.num_microseconds() + rhs.num_microseconds()) + } +} + +impl ops::Sub for TimeVal { + type Output = TimeVal; + + fn sub(self, rhs: TimeVal) -> TimeVal { + TimeVal::microseconds( + self.num_microseconds() - rhs.num_microseconds()) + } +} + +impl ops::Mul for TimeVal { + type Output = TimeVal; + + fn mul(self, rhs: i32) -> TimeVal { + let usec = self.num_microseconds().checked_mul(rhs as i64) + .expect("TimeVal multiply out of bounds"); + + TimeVal::microseconds(usec) + } +} + +impl ops::Div for TimeVal { + type Output = TimeVal; + + fn div(self, rhs: i32) -> TimeVal { + let usec = self.num_microseconds() / rhs as i64; + TimeVal::microseconds(usec) + } +} + +impl fmt::Display for TimeVal { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let (abs, sign) = if self.tv_sec() < 0 { + (-*self, "-") + } else { + (*self, "") + }; + + let sec = abs.tv_sec(); + + write!(f, "{}", sign)?; + + if abs.tv_usec() == 0 { + if abs.tv_sec() == 1 { + write!(f, "{} second", sec)?; + } else { + write!(f, "{} seconds", sec)?; + } + } else if abs.tv_usec() % 1000 == 0 { + write!(f, "{}.{:03} seconds", sec, abs.tv_usec() / 1000)?; + } else { + write!(f, "{}.{:06} seconds", sec, abs.tv_usec())?; + } + + Ok(()) + } +} + +impl From for TimeVal { + fn from(tv: timeval) -> Self { + TimeVal(tv) + } +} + +#[inline] +fn div_mod_floor_64(this: i64, other: i64) -> (i64, i64) { + (div_floor_64(this, other), mod_floor_64(this, other)) +} + +#[inline] +fn div_floor_64(this: i64, other: i64) -> i64 { + match div_rem_64(this, other) { + (d, r) if (r > 0 && other < 0) + || (r < 0 && other > 0) => d - 1, + (d, _) => d, + } +} + +#[inline] +fn mod_floor_64(this: i64, other: i64) -> i64 { + match this % other { + r if (r > 0 && other < 0) + || (r < 0 && other > 0) => r + other, + r => r, + } +} + +#[inline] +fn div_rem_64(this: i64, other: i64) -> (i64, i64) { + (this / other, this % other) +} + +#[cfg(test)] +mod test { + use super::{TimeSpec, TimeVal, TimeValLike}; + + #[test] + pub fn test_timespec() { + assert!(TimeSpec::seconds(1) != TimeSpec::zero()); + assert_eq!(TimeSpec::seconds(1) + TimeSpec::seconds(2), + TimeSpec::seconds(3)); + assert_eq!(TimeSpec::minutes(3) + TimeSpec::seconds(2), + TimeSpec::seconds(182)); + } + + #[test] + pub fn test_timespec_neg() { + let a = TimeSpec::seconds(1) + TimeSpec::nanoseconds(123); + let b = TimeSpec::seconds(-1) + TimeSpec::nanoseconds(-123); + + assert_eq!(a, -b); + } + + #[test] + pub fn test_timespec_ord() { + assert!(TimeSpec::seconds(1) == TimeSpec::nanoseconds(1_000_000_000)); + assert!(TimeSpec::seconds(1) < TimeSpec::nanoseconds(1_000_000_001)); + assert!(TimeSpec::seconds(1) > TimeSpec::nanoseconds(999_999_999)); + assert!(TimeSpec::seconds(-1) < TimeSpec::nanoseconds(-999_999_999)); + assert!(TimeSpec::seconds(-1) > TimeSpec::nanoseconds(-1_000_000_001)); + } + + #[test] + pub fn test_timespec_fmt() { + assert_eq!(TimeSpec::zero().to_string(), "0 seconds"); + assert_eq!(TimeSpec::seconds(42).to_string(), "42 seconds"); + assert_eq!(TimeSpec::milliseconds(42).to_string(), "0.042 seconds"); + assert_eq!(TimeSpec::microseconds(42).to_string(), "0.000042 seconds"); + assert_eq!(TimeSpec::nanoseconds(42).to_string(), "0.000000042 seconds"); + assert_eq!(TimeSpec::seconds(-86401).to_string(), "-86401 seconds"); + } + + #[test] + pub fn test_timeval() { + assert!(TimeVal::seconds(1) != TimeVal::zero()); + assert_eq!(TimeVal::seconds(1) + TimeVal::seconds(2), + TimeVal::seconds(3)); + assert_eq!(TimeVal::minutes(3) + TimeVal::seconds(2), + TimeVal::seconds(182)); + } + + #[test] + pub fn test_timeval_ord() { + assert!(TimeVal::seconds(1) == TimeVal::microseconds(1_000_000)); + assert!(TimeVal::seconds(1) < TimeVal::microseconds(1_000_001)); + assert!(TimeVal::seconds(1) > TimeVal::microseconds(999_999)); + assert!(TimeVal::seconds(-1) < TimeVal::microseconds(-999_999)); + assert!(TimeVal::seconds(-1) > TimeVal::microseconds(-1_000_001)); + } + + #[test] + pub fn test_timeval_neg() { + let a = TimeVal::seconds(1) + TimeVal::microseconds(123); + let b = TimeVal::seconds(-1) + TimeVal::microseconds(-123); + + assert_eq!(a, -b); + } + + #[test] + pub fn test_timeval_fmt() { + assert_eq!(TimeVal::zero().to_string(), "0 seconds"); + assert_eq!(TimeVal::seconds(42).to_string(), "42 seconds"); + assert_eq!(TimeVal::milliseconds(42).to_string(), "0.042 seconds"); + assert_eq!(TimeVal::microseconds(42).to_string(), "0.000042 seconds"); + assert_eq!(TimeVal::nanoseconds(1402).to_string(), "0.000001 seconds"); + assert_eq!(TimeVal::seconds(-86401).to_string(), "-86401 seconds"); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/uio.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/uio.rs new file mode 100644 index 0000000..45860be --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/uio.rs @@ -0,0 +1,195 @@ +// Silence invalid warnings due to rust-lang/rust#16719 +#![allow(improper_ctypes)] + +use Result; +use errno::Errno; +use libc::{self, c_int, c_void, size_t, off_t}; +use std::marker::PhantomData; +use std::os::unix::io::RawFd; + +pub fn writev(fd: RawFd, iov: &[IoVec<&[u8]>]) -> Result { + let res = unsafe { libc::writev(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int) }; + + Errno::result(res).map(|r| r as usize) +} + +pub fn readv(fd: RawFd, iov: &mut [IoVec<&mut [u8]>]) -> Result { + let res = unsafe { libc::readv(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int) }; + + Errno::result(res).map(|r| r as usize) +} + +/// Write to `fd` at `offset` from buffers in `iov`. +/// +/// Buffers in `iov` will be written in order until all buffers have been written +/// or an error occurs. The file offset is not changed. +/// +/// See also: [`writev`](fn.writev.html) and [`pwrite`](fn.pwrite.html) +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd"))] +pub fn pwritev(fd: RawFd, iov: &[IoVec<&[u8]>], + offset: off_t) -> Result { + let res = unsafe { + libc::pwritev(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int, offset) + }; + + Errno::result(res).map(|r| r as usize) +} + +/// Read from `fd` at `offset` filling buffers in `iov`. +/// +/// Buffers in `iov` will be filled in order until all buffers have been filled, +/// no more bytes are available, or an error occurs. The file offset is not +/// changed. +/// +/// See also: [`readv`](fn.readv.html) and [`pread`](fn.pread.html) +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd"))] +pub fn preadv(fd: RawFd, iov: &[IoVec<&mut [u8]>], + offset: off_t) -> Result { + let res = unsafe { + libc::preadv(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int, offset) + }; + + Errno::result(res).map(|r| r as usize) +} + +pub fn pwrite(fd: RawFd, buf: &[u8], offset: off_t) -> Result { + let res = unsafe { + libc::pwrite(fd, buf.as_ptr() as *const c_void, buf.len() as size_t, + offset) + }; + + Errno::result(res).map(|r| r as usize) +} + +pub fn pread(fd: RawFd, buf: &mut [u8], offset: off_t) -> Result{ + let res = unsafe { + libc::pread(fd, buf.as_mut_ptr() as *mut c_void, buf.len() as size_t, + offset) + }; + + Errno::result(res).map(|r| r as usize) +} + +/// A slice of memory in a remote process, starting at address `base` +/// and consisting of `len` bytes. +/// +/// This is the same underlying C structure as [`IoVec`](struct.IoVec.html), +/// except that it refers to memory in some other process, and is +/// therefore not represented in Rust by an actual slice as `IoVec` is. It +/// is used with [`process_vm_readv`](fn.process_vm_readv.html) +/// and [`process_vm_writev`](fn.process_vm_writev.html). +#[cfg(target_os = "linux")] +#[repr(C)] +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct RemoteIoVec { + /// The starting address of this slice (`iov_base`). + pub base: usize, + /// The number of bytes in this slice (`iov_len`). + pub len: usize, +} + +/// Write data directly to another process's virtual memory +/// (see [`process_vm_writev`(2)]). +/// +/// `local_iov` is a list of [`IoVec`]s containing the data to be written, +/// and `remote_iov` is a list of [`RemoteIoVec`]s identifying where the +/// data should be written in the target process. On success, returns the +/// number of bytes written, which will always be a whole +/// number of `remote_iov` chunks. +/// +/// This requires the same permissions as debugging the process using +/// [ptrace]: you must either be a privileged process (with +/// `CAP_SYS_PTRACE`), or you must be running as the same user as the +/// target process and the OS must have unprivileged debugging enabled. +/// +/// This function is only available on Linux. +/// +/// [`process_vm_writev`(2)]: http://man7.org/linux/man-pages/man2/process_vm_writev.2.html +/// [ptrace]: ../ptrace/index.html +/// [`IoVec`]: struct.IoVec.html +/// [`RemoteIoVec`]: struct.RemoteIoVec.html +#[cfg(target_os = "linux")] +pub fn process_vm_writev(pid: ::unistd::Pid, local_iov: &[IoVec<&[u8]>], remote_iov: &[RemoteIoVec]) -> Result { + let res = unsafe { + libc::process_vm_writev(pid.into(), + local_iov.as_ptr() as *const libc::iovec, local_iov.len() as libc::c_ulong, + remote_iov.as_ptr() as *const libc::iovec, remote_iov.len() as libc::c_ulong, 0) + }; + + Errno::result(res).map(|r| r as usize) +} + +/// Read data directly from another process's virtual memory +/// (see [`process_vm_readv`(2)]). +/// +/// `local_iov` is a list of [`IoVec`]s containing the buffer to copy +/// data into, and `remote_iov` is a list of [`RemoteIoVec`]s identifying +/// where the source data is in the target process. On success, +/// returns the number of bytes written, which will always be a whole +/// number of `remote_iov` chunks. +/// +/// This requires the same permissions as debugging the process using +/// [`ptrace`]: you must either be a privileged process (with +/// `CAP_SYS_PTRACE`), or you must be running as the same user as the +/// target process and the OS must have unprivileged debugging enabled. +/// +/// This function is only available on Linux. +/// +/// [`process_vm_readv`(2)]: http://man7.org/linux/man-pages/man2/process_vm_readv.2.html +/// [`ptrace`]: ../ptrace/index.html +/// [`IoVec`]: struct.IoVec.html +/// [`RemoteIoVec`]: struct.RemoteIoVec.html +#[cfg(any(target_os = "linux"))] +pub fn process_vm_readv(pid: ::unistd::Pid, local_iov: &[IoVec<&mut [u8]>], remote_iov: &[RemoteIoVec]) -> Result { + let res = unsafe { + libc::process_vm_readv(pid.into(), + local_iov.as_ptr() as *const libc::iovec, local_iov.len() as libc::c_ulong, + remote_iov.as_ptr() as *const libc::iovec, remote_iov.len() as libc::c_ulong, 0) + }; + + Errno::result(res).map(|r| r as usize) +} + +#[repr(C)] +#[allow(missing_debug_implementations)] +pub struct IoVec(libc::iovec, PhantomData); + +impl IoVec { + #[inline] + pub fn as_slice(&self) -> &[u8] { + use std::slice; + + unsafe { + slice::from_raw_parts( + self.0.iov_base as *const u8, + self.0.iov_len as usize) + } + } +} + +impl<'a> IoVec<&'a [u8]> { + pub fn from_slice(buf: &'a [u8]) -> IoVec<&'a [u8]> { + IoVec(libc::iovec { + iov_base: buf.as_ptr() as *mut c_void, + iov_len: buf.len() as size_t, + }, PhantomData) + } +} + +impl<'a> IoVec<&'a mut [u8]> { + pub fn from_mut_slice(buf: &'a mut [u8]) -> IoVec<&'a mut [u8]> { + IoVec(libc::iovec { + iov_base: buf.as_ptr() as *mut c_void, + iov_len: buf.len() as size_t, + }, PhantomData) + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/utsname.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/utsname.rs new file mode 100644 index 0000000..e33d073 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/utsname.rs @@ -0,0 +1,68 @@ +use std::mem; +use libc::{self, c_char}; +use std::ffi::CStr; +use std::str::from_utf8_unchecked; + +#[repr(C)] +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct UtsName(libc::utsname); + +impl UtsName { + pub fn sysname(&self) -> &str { + to_str(&(&self.0.sysname as *const c_char ) as *const *const c_char) + } + + pub fn nodename(&self) -> &str { + to_str(&(&self.0.nodename as *const c_char ) as *const *const c_char) + } + + pub fn release(&self) -> &str { + to_str(&(&self.0.release as *const c_char ) as *const *const c_char) + } + + pub fn version(&self) -> &str { + to_str(&(&self.0.version as *const c_char ) as *const *const c_char) + } + + pub fn machine(&self) -> &str { + to_str(&(&self.0.machine as *const c_char ) as *const *const c_char) + } +} + +pub fn uname() -> UtsName { + unsafe { + let mut ret: UtsName = mem::uninitialized(); + libc::uname(&mut ret.0); + ret + } +} + +#[inline] +fn to_str<'a>(s: *const *const c_char) -> &'a str { + unsafe { + let res = CStr::from_ptr(*s).to_bytes(); + from_utf8_unchecked(res) + } +} + +#[cfg(test)] +mod test { + #[cfg(target_os = "linux")] + #[test] + pub fn test_uname_linux() { + assert_eq!(super::uname().sysname(), "Linux"); + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + #[test] + pub fn test_uname_darwin() { + assert_eq!(super::uname().sysname(), "Darwin"); + } + + #[cfg(target_os = "freebsd")] + #[test] + pub fn test_uname_freebsd() { + assert_eq!(super::uname().sysname(), "FreeBSD"); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/sys/wait.rs b/third_party/cargo/vendor/nix-0.14.1/src/sys/wait.rs new file mode 100644 index 0000000..3f99757 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/sys/wait.rs @@ -0,0 +1,239 @@ +use libc::{self, c_int}; +use Result; +use errno::Errno; +use unistd::Pid; + +use sys::signal::Signal; + +libc_bitflags!( + pub struct WaitPidFlag: c_int { + WNOHANG; + WUNTRACED; + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd"))] + WEXITED; + WCONTINUED; + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd"))] + WSTOPPED; + /// Don't reap, just poll status. + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd"))] + WNOWAIT; + /// Don't wait on children of other threads in this group + #[cfg(any(target_os = "android", target_os = "linux"))] + __WNOTHREAD; + /// Wait on all children, regardless of type + #[cfg(any(target_os = "android", target_os = "linux"))] + __WALL; + #[cfg(any(target_os = "android", target_os = "linux"))] + __WCLONE; + } +); + +/// Possible return values from `wait()` or `waitpid()`. +/// +/// Each status (other than `StillAlive`) describes a state transition +/// in a child process `Pid`, such as the process exiting or stopping, +/// plus additional data about the transition if any. +/// +/// Note that there are two Linux-specific enum variants, `PtraceEvent` +/// and `PtraceSyscall`. Portable code should avoid exhaustively +/// matching on `WaitStatus`. +#[derive(Eq, PartialEq, Clone, Copy, Debug)] +pub enum WaitStatus { + /// The process exited normally (as with `exit()` or returning from + /// `main`) with the given exit code. This case matches the C macro + /// `WIFEXITED(status)`; the second field is `WEXITSTATUS(status)`. + Exited(Pid, i32), + /// The process was killed by the given signal. The third field + /// indicates whether the signal generated a core dump. This case + /// matches the C macro `WIFSIGNALED(status)`; the last two fields + /// correspond to `WTERMSIG(status)` and `WCOREDUMP(status)`. + Signaled(Pid, Signal, bool), + /// The process is alive, but was stopped by the given signal. This + /// is only reported if `WaitPidFlag::WUNTRACED` was passed. This + /// case matches the C macro `WIFSTOPPED(status)`; the second field + /// is `WSTOPSIG(status)`. + Stopped(Pid, Signal), + /// The traced process was stopped by a `PTRACE_EVENT_*` event. See + /// [`nix::sys::ptrace`] and [`ptrace`(2)] for more information. All + /// currently-defined events use `SIGTRAP` as the signal; the third + /// field is the `PTRACE_EVENT_*` value of the event. + /// + /// [`nix::sys::ptrace`]: ../ptrace/index.html + /// [`ptrace`(2)]: http://man7.org/linux/man-pages/man2/ptrace.2.html + #[cfg(any(target_os = "linux", target_os = "android"))] + PtraceEvent(Pid, Signal, c_int), + /// The traced process was stopped by execution of a system call, + /// and `PTRACE_O_TRACESYSGOOD` is in effect. See [`ptrace`(2)] for + /// more information. + /// + /// [`ptrace`(2)]: http://man7.org/linux/man-pages/man2/ptrace.2.html + #[cfg(any(target_os = "linux", target_os = "android"))] + PtraceSyscall(Pid), + /// The process was previously stopped but has resumed execution + /// after receiving a `SIGCONT` signal. This is only reported if + /// `WaitPidFlag::WCONTINUED` was passed. This case matches the C + /// macro `WIFCONTINUED(status)`. + Continued(Pid), + /// There are currently no state changes to report in any awaited + /// child process. This is only returned if `WaitPidFlag::WNOHANG` + /// was used (otherwise `wait()` or `waitpid()` would block until + /// there was something to report). + StillAlive, +} + +impl WaitStatus { + /// Extracts the PID from the WaitStatus unless it equals StillAlive. + pub fn pid(&self) -> Option { + use self::WaitStatus::*; + match *self { + Exited(p, _) | Signaled(p, _, _) | + Stopped(p, _) | Continued(p) => Some(p), + StillAlive => None, + #[cfg(any(target_os = "android", target_os = "linux"))] + PtraceEvent(p, _, _) | PtraceSyscall(p) => Some(p), + } + } +} + +fn exited(status: i32) -> bool { + unsafe { libc::WIFEXITED(status) } +} + +fn exit_status(status: i32) -> i32 { + unsafe { libc::WEXITSTATUS(status) } +} + +fn signaled(status: i32) -> bool { + unsafe { libc::WIFSIGNALED(status) } +} + +fn term_signal(status: i32) -> Result { + Signal::from_c_int(unsafe { libc::WTERMSIG(status) }) +} + +fn dumped_core(status: i32) -> bool { + unsafe { libc::WCOREDUMP(status) } +} + +fn stopped(status: i32) -> bool { + unsafe { libc::WIFSTOPPED(status) } +} + +fn stop_signal(status: i32) -> Result { + Signal::from_c_int(unsafe { libc::WSTOPSIG(status) }) +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +fn syscall_stop(status: i32) -> bool { + // From ptrace(2), setting PTRACE_O_TRACESYSGOOD has the effect + // of delivering SIGTRAP | 0x80 as the signal number for syscall + // stops. This allows easily distinguishing syscall stops from + // genuine SIGTRAP signals. + unsafe { libc::WSTOPSIG(status) == libc::SIGTRAP | 0x80 } +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +fn stop_additional(status: i32) -> c_int { + (status >> 16) as c_int +} + +fn continued(status: i32) -> bool { + unsafe { libc::WIFCONTINUED(status) } +} + +impl WaitStatus { + /// Convert a raw `wstatus` as returned by `waitpid`/`wait` into a `WaitStatus` + /// + /// # Errors + /// + /// Returns an `Error` corresponding to `EINVAL` for invalid status values. + /// + /// # Examples + /// + /// Convert a `wstatus` obtained from `libc::waitpid` into a `WaitStatus`: + /// + /// ``` + /// use nix::sys::wait::WaitStatus; + /// use nix::sys::signal::Signal; + /// let pid = nix::unistd::Pid::from_raw(1); + /// let status = WaitStatus::from_raw(pid, 0x0002); + /// assert_eq!(status, Ok(WaitStatus::Signaled(pid, Signal::SIGINT, false))); + /// ``` + pub fn from_raw(pid: Pid, status: i32) -> Result { + Ok(if exited(status) { + WaitStatus::Exited(pid, exit_status(status)) + } else if signaled(status) { + WaitStatus::Signaled(pid, term_signal(status)?, dumped_core(status)) + } else if stopped(status) { + cfg_if! { + if #[cfg(any(target_os = "android", target_os = "linux"))] { + fn decode_stopped(pid: Pid, status: i32) -> Result { + let status_additional = stop_additional(status); + Ok(if syscall_stop(status) { + WaitStatus::PtraceSyscall(pid) + } else if status_additional == 0 { + WaitStatus::Stopped(pid, stop_signal(status)?) + } else { + WaitStatus::PtraceEvent(pid, stop_signal(status)?, + stop_additional(status)) + }) + } + } else { + fn decode_stopped(pid: Pid, status: i32) -> Result { + Ok(WaitStatus::Stopped(pid, stop_signal(status)?)) + } + } + } + return decode_stopped(pid, status); + } else { + assert!(continued(status)); + WaitStatus::Continued(pid) + }) + } +} + +pub fn waitpid>>(pid: P, options: Option) -> Result { + use self::WaitStatus::*; + + let mut status: i32 = 0; + + let option_bits = match options { + Some(bits) => bits.bits(), + None => 0, + }; + + let res = unsafe { + libc::waitpid( + pid.into().unwrap_or(Pid::from_raw(-1)).into(), + &mut status as *mut c_int, + option_bits, + ) + }; + + match Errno::result(res)? { + 0 => Ok(StillAlive), + res => WaitStatus::from_raw(Pid::from_raw(res), status), + } +} + +pub fn wait() -> Result { + waitpid(None, None) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/ucontext.rs b/third_party/cargo/vendor/nix-0.14.1/src/ucontext.rs new file mode 100644 index 0000000..c94464d --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/ucontext.rs @@ -0,0 +1,40 @@ +use libc; +#[cfg(not(target_env = "musl"))] +use Result; +#[cfg(not(target_env = "musl"))] +use errno::Errno; +use std::mem; +use sys::signal::SigSet; + +#[derive(Clone, Copy)] +#[allow(missing_debug_implementations)] +pub struct UContext { + context: libc::ucontext_t, +} + +impl UContext { + #[cfg(not(target_env = "musl"))] + pub fn get() -> Result { + let mut context: libc::ucontext_t = unsafe { mem::uninitialized() }; + let res = unsafe { + libc::getcontext(&mut context as *mut libc::ucontext_t) + }; + Errno::result(res).map(|_| UContext { context: context }) + } + + #[cfg(not(target_env = "musl"))] + pub fn set(&self) -> Result<()> { + let res = unsafe { + libc::setcontext(&self.context as *const libc::ucontext_t) + }; + Errno::result(res).map(drop) + } + + pub fn sigmask_mut(&mut self) -> &mut SigSet { + unsafe { mem::transmute(&mut self.context.uc_sigmask) } + } + + pub fn sigmask(&self) -> &SigSet { + unsafe { mem::transmute(&self.context.uc_sigmask) } + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/src/unistd.rs b/third_party/cargo/vendor/nix-0.14.1/src/unistd.rs new file mode 100644 index 0000000..96d8ace --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/src/unistd.rs @@ -0,0 +1,2358 @@ +//! Safe wrappers around functions found in libc "unistd.h" header + +use errno::{self, Errno}; +use {Error, Result, NixPath}; +use fcntl::{AtFlags, at_rawfd, fcntl, FdFlag, OFlag}; +use fcntl::FcntlArg::F_SETFD; +use libc::{self, c_char, c_void, c_int, c_long, c_uint, size_t, pid_t, off_t, + uid_t, gid_t, mode_t}; +use std::{fmt, mem, ptr}; +use std::ffi::{CString, CStr, OsString, OsStr}; +use std::os::unix::ffi::{OsStringExt, OsStrExt}; +use std::os::unix::io::RawFd; +use std::path::PathBuf; +use void::Void; +use sys::stat::Mode; + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub use self::pivot_root::*; + +#[cfg(any(target_os = "android", target_os = "freebsd", + target_os = "linux", target_os = "openbsd"))] +pub use self::setres::*; + +/// User identifier +/// +/// Newtype pattern around `uid_t` (which is just alias). It prevents bugs caused by accidentally +/// passing wrong value. +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +pub struct Uid(uid_t); + +impl Uid { + /// Creates `Uid` from raw `uid_t`. + pub fn from_raw(uid: uid_t) -> Self { + Uid(uid) + } + + /// Returns Uid of calling process. This is practically a more Rusty alias for `getuid`. + pub fn current() -> Self { + getuid() + } + + /// Returns effective Uid of calling process. This is practically a more Rusty alias for `geteuid`. + pub fn effective() -> Self { + geteuid() + } + + /// Returns true if the `Uid` represents privileged user - root. (If it equals zero.) + pub fn is_root(&self) -> bool { + *self == ROOT + } + + /// Get the raw `uid_t` wrapped by `self`. + pub fn as_raw(&self) -> uid_t { + self.0 + } +} + +impl From for uid_t { + fn from(uid: Uid) -> Self { + uid.0 + } +} + +impl fmt::Display for Uid { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.0, f) + } +} + +/// Constant for UID = 0 +pub const ROOT: Uid = Uid(0); + +/// Group identifier +/// +/// Newtype pattern around `gid_t` (which is just alias). It prevents bugs caused by accidentally +/// passing wrong value. +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +pub struct Gid(gid_t); + +impl Gid { + /// Creates `Gid` from raw `gid_t`. + pub fn from_raw(gid: gid_t) -> Self { + Gid(gid) + } + + /// Returns Gid of calling process. This is practically a more Rusty alias for `getgid`. + pub fn current() -> Self { + getgid() + } + + /// Returns effective Gid of calling process. This is practically a more Rusty alias for `getgid`. + pub fn effective() -> Self { + getegid() + } + + /// Get the raw `gid_t` wrapped by `self`. + pub fn as_raw(&self) -> gid_t { + self.0 + } +} + +impl From for gid_t { + fn from(gid: Gid) -> Self { + gid.0 + } +} + +impl fmt::Display for Gid { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.0, f) + } +} + +/// Process identifier +/// +/// Newtype pattern around `pid_t` (which is just alias). It prevents bugs caused by accidentally +/// passing wrong value. +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +pub struct Pid(pid_t); + +impl Pid { + /// Creates `Pid` from raw `pid_t`. + pub fn from_raw(pid: pid_t) -> Self { + Pid(pid) + } + + /// Returns PID of calling process + pub fn this() -> Self { + getpid() + } + + /// Returns PID of parent of calling process + pub fn parent() -> Self { + getppid() + } + + /// Get the raw `pid_t` wrapped by `self`. + pub fn as_raw(&self) -> pid_t { + self.0 + } +} + +impl From for pid_t { + fn from(pid: Pid) -> Self { + pid.0 + } +} + +impl fmt::Display for Pid { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.0, f) + } +} + + +/// Represents the successful result of calling `fork` +/// +/// When `fork` is called, the process continues execution in the parent process +/// and in the new child. This return type can be examined to determine whether +/// you are now executing in the parent process or in the child. +#[derive(Clone, Copy, Debug)] +pub enum ForkResult { + Parent { child: Pid }, + Child, +} + +impl ForkResult { + + /// Return `true` if this is the child process of the `fork()` + #[inline] + pub fn is_child(&self) -> bool { + match *self { + ForkResult::Child => true, + _ => false + } + } + + /// Returns `true` if this is the parent process of the `fork()` + #[inline] + pub fn is_parent(&self) -> bool { + !self.is_child() + } +} + +/// Create a new child process duplicating the parent process ([see +/// fork(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html)). +/// +/// After calling the fork system call (successfully) two processes will +/// be created that are identical with the exception of their pid and the +/// return value of this function. As an example: +/// +/// ```no_run +/// use nix::unistd::{fork, ForkResult}; +/// +/// match fork() { +/// Ok(ForkResult::Parent { child, .. }) => { +/// println!("Continuing execution in parent process, new child has pid: {}", child); +/// } +/// Ok(ForkResult::Child) => println!("I'm a new child process"), +/// Err(_) => println!("Fork failed"), +/// } +/// ``` +/// +/// This will print something like the following (order indeterministic). The +/// thing to note is that you end up with two processes continuing execution +/// immediately after the fork call but with different match arms. +/// +/// ```text +/// Continuing execution in parent process, new child has pid: 1234 +/// I'm a new child process +/// ``` +/// +/// # Safety +/// +/// In a multithreaded program, only [async-signal-safe] functions like `pause` +/// and `_exit` may be called by the child (the parent isn't restricted). Note +/// that memory allocation may **not** be async-signal-safe and thus must be +/// prevented. +/// +/// Those functions are only a small subset of your operating system's API, so +/// special care must be taken to only invoke code you can control and audit. +/// +/// [async-signal-safe]: http://man7.org/linux/man-pages/man7/signal-safety.7.html +#[inline] +pub fn fork() -> Result { + use self::ForkResult::*; + let res = unsafe { libc::fork() }; + + Errno::result(res).map(|res| match res { + 0 => Child, + res => Parent { child: Pid(res) }, + }) +} + +/// Get the pid of this process (see +/// [getpid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpid.html)). +/// +/// Since you are running code, there is always a pid to return, so there +/// is no error case that needs to be handled. +#[inline] +pub fn getpid() -> Pid { + Pid(unsafe { libc::getpid() }) +} + +/// Get the pid of this processes' parent (see +/// [getpid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getppid.html)). +/// +/// There is always a parent pid to return, so there is no error case that needs +/// to be handled. +#[inline] +pub fn getppid() -> Pid { + Pid(unsafe { libc::getppid() }) // no error handling, according to man page: "These functions are always successful." +} + +/// Set a process group ID (see +/// [setpgid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/setpgid.html)). +/// +/// Set the process group id (PGID) of a particular process. If a pid of zero +/// is specified, then the pid of the calling process is used. Process groups +/// may be used to group together a set of processes in order for the OS to +/// apply some operations across the group. +/// +/// `setsid()` may be used to create a new process group. +#[inline] +pub fn setpgid(pid: Pid, pgid: Pid) -> Result<()> { + let res = unsafe { libc::setpgid(pid.into(), pgid.into()) }; + Errno::result(res).map(drop) +} +#[inline] +pub fn getpgid(pid: Option) -> Result { + let res = unsafe { libc::getpgid(pid.unwrap_or(Pid(0)).into()) }; + Errno::result(res).map(Pid) +} + +/// Create new session and set process group id (see +/// [setsid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsid.html)). +#[inline] +pub fn setsid() -> Result { + Errno::result(unsafe { libc::setsid() }).map(Pid) +} + +/// Get the process group ID of a session leader +/// [getsid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsid.html). +/// +/// Obtain the process group ID of the process that is the session leader of the process specified +/// by pid. If pid is zero, it specifies the calling process. +#[inline] +pub fn getsid(pid: Option) -> Result { + let res = unsafe { libc::getsid(pid.unwrap_or(Pid(0)).into()) }; + Errno::result(res).map(Pid) +} + + +/// Get the terminal foreground process group (see +/// [tcgetpgrp(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetpgrp.html)). +/// +/// Get the group process id (GPID) of the foreground process group on the +/// terminal associated to file descriptor (FD). +#[inline] +pub fn tcgetpgrp(fd: c_int) -> Result { + let res = unsafe { libc::tcgetpgrp(fd) }; + Errno::result(res).map(Pid) +} +/// Set the terminal foreground process group (see +/// [tcgetpgrp(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcsetpgrp.html)). +/// +/// Get the group process id (PGID) to the foreground process group on the +/// terminal associated to file descriptor (FD). +#[inline] +pub fn tcsetpgrp(fd: c_int, pgrp: Pid) -> Result<()> { + let res = unsafe { libc::tcsetpgrp(fd, pgrp.into()) }; + Errno::result(res).map(drop) +} + + +/// Get the group id of the calling process (see +///[getpgrp(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpgrp.html)). +/// +/// Get the process group id (PGID) of the calling process. +/// According to the man page it is always successful. +#[inline] +pub fn getpgrp() -> Pid { + Pid(unsafe { libc::getpgrp() }) +} + +/// Get the caller's thread ID (see +/// [gettid(2)](http://man7.org/linux/man-pages/man2/gettid.2.html). +/// +/// This function is only available on Linux based systems. In a single +/// threaded process, the main thread will have the same ID as the process. In +/// a multithreaded process, each thread will have a unique thread id but the +/// same process ID. +/// +/// No error handling is required as a thread id should always exist for any +/// process, even if threads are not being used. +#[cfg(any(target_os = "linux", target_os = "android"))] +#[inline] +pub fn gettid() -> Pid { + Pid(unsafe { libc::syscall(libc::SYS_gettid) as pid_t }) +} + +/// Create a copy of the specified file descriptor (see +/// [dup(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup.html)). +/// +/// The new file descriptor will be have a new index but refer to the same +/// resource as the old file descriptor and the old and new file descriptors may +/// be used interchangeably. The new and old file descriptor share the same +/// underlying resource, offset, and file status flags. The actual index used +/// for the file descriptor will be the lowest fd index that is available. +/// +/// The two file descriptors do not share file descriptor flags (e.g. `OFlag::FD_CLOEXEC`). +#[inline] +pub fn dup(oldfd: RawFd) -> Result { + let res = unsafe { libc::dup(oldfd) }; + + Errno::result(res) +} + +/// Create a copy of the specified file descriptor using the specified fd (see +/// [dup(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup.html)). +/// +/// This function behaves similar to `dup()` except that it will try to use the +/// specified fd instead of allocating a new one. See the man pages for more +/// detail on the exact behavior of this function. +#[inline] +pub fn dup2(oldfd: RawFd, newfd: RawFd) -> Result { + let res = unsafe { libc::dup2(oldfd, newfd) }; + + Errno::result(res) +} + +/// Create a new copy of the specified file descriptor using the specified fd +/// and flags (see [dup(2)](http://man7.org/linux/man-pages/man2/dup.2.html)). +/// +/// This function behaves similar to `dup2()` but allows for flags to be +/// specified. +pub fn dup3(oldfd: RawFd, newfd: RawFd, flags: OFlag) -> Result { + dup3_polyfill(oldfd, newfd, flags) +} + +#[inline] +fn dup3_polyfill(oldfd: RawFd, newfd: RawFd, flags: OFlag) -> Result { + if oldfd == newfd { + return Err(Error::Sys(Errno::EINVAL)); + } + + let fd = dup2(oldfd, newfd)?; + + if flags.contains(OFlag::O_CLOEXEC) { + if let Err(e) = fcntl(fd, F_SETFD(FdFlag::FD_CLOEXEC)) { + let _ = close(fd); + return Err(e); + } + } + + Ok(fd) +} + +/// Change the current working directory of the calling process (see +/// [chdir(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/chdir.html)). +/// +/// This function may fail in a number of different scenarios. See the man +/// pages for additional details on possible failure cases. +#[inline] +pub fn chdir(path: &P) -> Result<()> { + let res = path.with_nix_path(|cstr| { + unsafe { libc::chdir(cstr.as_ptr()) } + })?; + + Errno::result(res).map(drop) +} + +/// Change the current working directory of the process to the one +/// given as an open file descriptor (see +/// [fchdir(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html)). +/// +/// This function may fail in a number of different scenarios. See the man +/// pages for additional details on possible failure cases. +#[inline] +pub fn fchdir(dirfd: RawFd) -> Result<()> { + let res = unsafe { libc::fchdir(dirfd) }; + + Errno::result(res).map(drop) +} + +/// Creates new directory `path` with access rights `mode`. (see [mkdir(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html)) +/// +/// # Errors +/// +/// There are several situations where mkdir might fail: +/// +/// - current user has insufficient rights in the parent directory +/// - the path already exists +/// - the path name is too long (longer than `PATH_MAX`, usually 4096 on linux, 1024 on OS X) +/// +/// # Example +/// +/// ```rust +/// extern crate tempfile; +/// extern crate nix; +/// +/// use nix::unistd; +/// use nix::sys::stat; +/// use tempfile::tempdir; +/// +/// fn main() { +/// let tmp_dir1 = tempdir().unwrap(); +/// let tmp_dir2 = tmp_dir1.path().join("new_dir"); +/// +/// // create new directory and give read, write and execute rights to the owner +/// match unistd::mkdir(&tmp_dir2, stat::Mode::S_IRWXU) { +/// Ok(_) => println!("created {:?}", tmp_dir2), +/// Err(err) => println!("Error creating directory: {}", err), +/// } +/// } +/// ``` +#[inline] +pub fn mkdir(path: &P, mode: Mode) -> Result<()> { + let res = path.with_nix_path(|cstr| { + unsafe { libc::mkdir(cstr.as_ptr(), mode.bits() as mode_t) } + })?; + + Errno::result(res).map(drop) +} + +/// Creates new fifo special file (named pipe) with path `path` and access rights `mode`. +/// +/// # Errors +/// +/// There are several situations where mkfifo might fail: +/// +/// - current user has insufficient rights in the parent directory +/// - the path already exists +/// - the path name is too long (longer than `PATH_MAX`, usually 4096 on linux, 1024 on OS X) +/// +/// For a full list consult +/// [posix specification](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkfifo.html) +/// +/// # Example +/// +/// ```rust +/// extern crate tempfile; +/// extern crate nix; +/// +/// use nix::unistd; +/// use nix::sys::stat; +/// use tempfile::tempdir; +/// +/// fn main() { +/// let tmp_dir = tempdir().unwrap(); +/// let fifo_path = tmp_dir.path().join("foo.pipe"); +/// +/// // create new fifo and give read, write and execute rights to the owner +/// match unistd::mkfifo(&fifo_path, stat::Mode::S_IRWXU) { +/// Ok(_) => println!("created {:?}", fifo_path), +/// Err(err) => println!("Error creating fifo: {}", err), +/// } +/// } +/// ``` +#[inline] +pub fn mkfifo(path: &P, mode: Mode) -> Result<()> { + let res = path.with_nix_path(|cstr| { + unsafe { libc::mkfifo(cstr.as_ptr(), mode.bits() as mode_t) } + })?; + + Errno::result(res).map(drop) +} + +/// Creates a symbolic link at `path2` which points to `path1`. +/// +/// If `dirfd` has a value, then `path2` is relative to directory associated +/// with the file descriptor. +/// +/// If `dirfd` is `None`, then `path2` is relative to the current working +/// directory. This is identical to `libc::symlink(path1, path2)`. +/// +/// See also [symlinkat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/symlinkat.html). +pub fn symlinkat( + path1: &P1, + dirfd: Option, + path2: &P2) -> Result<()> { + let res = + path1.with_nix_path(|path1| { + path2.with_nix_path(|path2| { + unsafe { + libc::symlinkat( + path1.as_ptr(), + dirfd.unwrap_or(libc::AT_FDCWD), + path2.as_ptr() + ) + } + }) + })??; + Errno::result(res).map(drop) +} + +/// Returns the current directory as a `PathBuf` +/// +/// Err is returned if the current user doesn't have the permission to read or search a component +/// of the current path. +/// +/// # Example +/// +/// ```rust +/// extern crate nix; +/// +/// use nix::unistd; +/// +/// fn main() { +/// // assume that we are allowed to get current directory +/// let dir = unistd::getcwd().unwrap(); +/// println!("The current directory is {:?}", dir); +/// } +/// ``` +#[inline] +pub fn getcwd() -> Result { + let mut buf = Vec::with_capacity(512); + loop { + unsafe { + let ptr = buf.as_mut_ptr() as *mut c_char; + + // The buffer must be large enough to store the absolute pathname plus + // a terminating null byte, or else null is returned. + // To safely handle this we start with a reasonable size (512 bytes) + // and double the buffer size upon every error + if !libc::getcwd(ptr, buf.capacity()).is_null() { + let len = CStr::from_ptr(buf.as_ptr() as *const c_char).to_bytes().len(); + buf.set_len(len); + buf.shrink_to_fit(); + return Ok(PathBuf::from(OsString::from_vec(buf))); + } else { + let error = Errno::last(); + // ERANGE means buffer was too small to store directory name + if error != Errno::ERANGE { + return Err(Error::Sys(error)); + } + } + + // Trigger the internal buffer resizing logic of `Vec` by requiring + // more space than the current capacity. + let cap = buf.capacity(); + buf.set_len(cap); + buf.reserve(1); + } + } +} + +/// Computes the raw UID and GID values to pass to a `*chown` call. +fn chown_raw_ids(owner: Option, group: Option) -> (libc::uid_t, libc::gid_t) { + // According to the POSIX specification, -1 is used to indicate that owner and group + // are not to be changed. Since uid_t and gid_t are unsigned types, we have to wrap + // around to get -1. + let uid = owner.map(Into::into).unwrap_or((0 as uid_t).wrapping_sub(1)); + let gid = group.map(Into::into).unwrap_or((0 as gid_t).wrapping_sub(1)); + (uid, gid) +} + +/// Change the ownership of the file at `path` to be owned by the specified +/// `owner` (user) and `group` (see +/// [chown(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html)). +/// +/// The owner/group for the provided path name will not be modified if `None` is +/// provided for that argument. Ownership change will be attempted for the path +/// only if `Some` owner/group is provided. +#[inline] +pub fn chown(path: &P, owner: Option, group: Option) -> Result<()> { + let res = path.with_nix_path(|cstr| { + let (uid, gid) = chown_raw_ids(owner, group); + unsafe { libc::chown(cstr.as_ptr(), uid, gid) } + })?; + + Errno::result(res).map(drop) +} + +/// Flags for `fchownat` function. +#[derive(Clone, Copy, Debug)] +pub enum FchownatFlags { + FollowSymlink, + NoFollowSymlink, +} + +/// Change the ownership of the file at `path` to be owned by the specified +/// `owner` (user) and `group`. +/// +/// The owner/group for the provided path name will not be modified if `None` is +/// provided for that argument. Ownership change will be attempted for the path +/// only if `Some` owner/group is provided. +/// +/// The file to be changed is determined relative to the directory associated +/// with the file descriptor `dirfd` or the current working directory +/// if `dirfd` is `None`. +/// +/// If `flag` is `FchownatFlags::NoFollowSymlink` and `path` names a symbolic link, +/// then the mode of the symbolic link is changed. +/// +/// `fchownat(None, path, mode, FchownatFlags::NoFollowSymlink)` is identical to +/// a call `libc::lchown(path, mode)`. That's why `lchmod` is unimplemented in +/// the `nix` crate. +/// +/// # References +/// +/// [fchownat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchownat.html). +pub fn fchownat( + dirfd: Option, + path: &P, + owner: Option, + group: Option, + flag: FchownatFlags, +) -> Result<()> { + let atflag = + match flag { + FchownatFlags::FollowSymlink => AtFlags::empty(), + FchownatFlags::NoFollowSymlink => AtFlags::AT_SYMLINK_NOFOLLOW, + }; + let res = path.with_nix_path(|cstr| unsafe { + let (uid, gid) = chown_raw_ids(owner, group); + libc::fchownat(at_rawfd(dirfd), cstr.as_ptr(), uid, gid, + atflag.bits() as libc::c_int) + })?; + + Errno::result(res).map(drop) +} + +fn to_exec_array(args: &[CString]) -> Vec<*const c_char> { + let mut args_p: Vec<*const c_char> = args.iter().map(|s| s.as_ptr()).collect(); + args_p.push(ptr::null()); + args_p +} + +/// Replace the current process image with a new one (see +/// [exec(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html)). +/// +/// See the `::nix::unistd::execve` system call for additional details. `execv` +/// performs the same action but does not allow for customization of the +/// environment for the new process. +#[inline] +pub fn execv(path: &CString, argv: &[CString]) -> Result { + let args_p = to_exec_array(argv); + + unsafe { + libc::execv(path.as_ptr(), args_p.as_ptr()) + }; + + Err(Error::Sys(Errno::last())) +} + + +/// Replace the current process image with a new one (see +/// [execve(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html)). +/// +/// The execve system call allows for another process to be "called" which will +/// replace the current process image. That is, this process becomes the new +/// command that is run. On success, this function will not return. Instead, +/// the new program will run until it exits. +/// +/// `::nix::unistd::execv` and `::nix::unistd::execve` take as arguments a slice +/// of `::std::ffi::CString`s for `args` and `env` (for `execve`). Each element +/// in the `args` list is an argument to the new process. Each element in the +/// `env` list should be a string in the form "key=value". +#[inline] +pub fn execve(path: &CString, args: &[CString], env: &[CString]) -> Result { + let args_p = to_exec_array(args); + let env_p = to_exec_array(env); + + unsafe { + libc::execve(path.as_ptr(), args_p.as_ptr(), env_p.as_ptr()) + }; + + Err(Error::Sys(Errno::last())) +} + +/// Replace the current process image with a new one and replicate shell `PATH` +/// searching behavior (see +/// [exec(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html)). +/// +/// See `::nix::unistd::execve` for additional details. `execvp` behaves the +/// same as execv except that it will examine the `PATH` environment variables +/// for file names not specified with a leading slash. For example, `execv` +/// would not work if "bash" was specified for the path argument, but `execvp` +/// would assuming that a bash executable was on the system `PATH`. +#[inline] +pub fn execvp(filename: &CString, args: &[CString]) -> Result { + let args_p = to_exec_array(args); + + unsafe { + libc::execvp(filename.as_ptr(), args_p.as_ptr()) + }; + + Err(Error::Sys(Errno::last())) +} + +/// Replace the current process image with a new one and replicate shell `PATH` +/// searching behavior (see +/// [`execvpe(3)`](http://man7.org/linux/man-pages/man3/exec.3.html)). +/// +/// This functions like a combination of `execvp(2)` and `execve(2)` to pass an +/// environment and have a search path. See these two for additional +/// information. +#[cfg(any(target_os = "haiku", + target_os = "linux", + target_os = "openbsd"))] +pub fn execvpe(filename: &CString, args: &[CString], env: &[CString]) -> Result { + let args_p = to_exec_array(args); + let env_p = to_exec_array(env); + + unsafe { + libc::execvpe(filename.as_ptr(), args_p.as_ptr(), env_p.as_ptr()) + }; + + Err(Error::Sys(Errno::last())) +} + +/// Replace the current process image with a new one (see +/// [fexecve(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fexecve.html)). +/// +/// The `fexecve` function allows for another process to be "called" which will +/// replace the current process image. That is, this process becomes the new +/// command that is run. On success, this function will not return. Instead, +/// the new program will run until it exits. +/// +/// This function is similar to `execve`, except that the program to be executed +/// is referenced as a file descriptor instead of a path. +// Note for NetBSD and OpenBSD: although rust-lang/libc includes it (under +// unix/bsd/netbsdlike/) fexecve is not currently implemented on NetBSD nor on +// OpenBSD. +#[cfg(any(target_os = "android", + target_os = "linux", + target_os = "freebsd"))] +#[inline] +pub fn fexecve(fd: RawFd, args: &[CString], env: &[CString]) -> Result { + let args_p = to_exec_array(args); + let env_p = to_exec_array(env); + + unsafe { + libc::fexecve(fd, args_p.as_ptr(), env_p.as_ptr()) + }; + + Err(Error::Sys(Errno::last())) +} + +/// Execute program relative to a directory file descriptor (see +/// [execveat(2)](http://man7.org/linux/man-pages/man2/execveat.2.html)). +/// +/// The `execveat` function allows for another process to be "called" which will +/// replace the current process image. That is, this process becomes the new +/// command that is run. On success, this function will not return. Instead, +/// the new program will run until it exits. +/// +/// This function is similar to `execve`, except that the program to be executed +/// is referenced as a file descriptor to the base directory plus a path. +#[cfg(any(target_os = "android", target_os = "linux"))] +#[inline] +pub fn execveat(dirfd: RawFd, pathname: &CString, args: &[CString], + env: &[CString], flags: super::fcntl::AtFlags) -> Result { + let args_p = to_exec_array(args); + let env_p = to_exec_array(env); + + unsafe { + libc::syscall(libc::SYS_execveat, dirfd, pathname.as_ptr(), + args_p.as_ptr(), env_p.as_ptr(), flags); + }; + + Err(Error::Sys(Errno::last())) +} + +/// Daemonize this process by detaching from the controlling terminal (see +/// [daemon(3)](http://man7.org/linux/man-pages/man3/daemon.3.html)). +/// +/// When a process is launched it is typically associated with a parent and it, +/// in turn, by its controlling terminal/process. In order for a process to run +/// in the "background" it must daemonize itself by detaching itself. Under +/// posix, this is done by doing the following: +/// +/// 1. Parent process (this one) forks +/// 2. Parent process exits +/// 3. Child process continues to run. +/// +/// `nochdir`: +/// +/// * `nochdir = true`: The current working directory after daemonizing will +/// be the current working directory. +/// * `nochdir = false`: The current working directory after daemonizing will +/// be the root direcory, `/`. +/// +/// `noclose`: +/// +/// * `noclose = true`: The process' current stdin, stdout, and stderr file +/// descriptors will remain identical after daemonizing. +/// * `noclose = false`: The process' stdin, stdout, and stderr will point to +/// `/dev/null` after daemonizing. +#[cfg_attr(any(target_os = "macos", target_os = "ios"), deprecated( + since="0.14.0", + note="Deprecated in MacOSX 10.5" +))] +#[cfg_attr(any(target_os = "macos", target_os = "ios"), allow(deprecated))] +pub fn daemon(nochdir: bool, noclose: bool) -> Result<()> { + let res = unsafe { libc::daemon(nochdir as c_int, noclose as c_int) }; + Errno::result(res).map(drop) +} + +/// Set the system host name (see +/// [sethostname(2)](http://man7.org/linux/man-pages/man2/gethostname.2.html)). +/// +/// Given a name, attempt to update the system host name to the given string. +/// On some systems, the host name is limited to as few as 64 bytes. An error +/// will be return if the name is not valid or the current process does not have +/// permissions to update the host name. +pub fn sethostname>(name: S) -> Result<()> { + // Handle some differences in type of the len arg across platforms. + cfg_if! { + if #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", ))] { + type sethostname_len_t = c_int; + } else { + type sethostname_len_t = size_t; + } + } + let ptr = name.as_ref().as_bytes().as_ptr() as *const c_char; + let len = name.as_ref().len() as sethostname_len_t; + + let res = unsafe { libc::sethostname(ptr, len) }; + Errno::result(res).map(drop) +} + +/// Get the host name and store it in the provided buffer, returning a pointer +/// the `CStr` in that buffer on success (see +/// [gethostname(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html)). +/// +/// This function call attempts to get the host name for the running system and +/// store it in a provided buffer. The buffer will be populated with bytes up +/// to the length of the provided slice including a NUL terminating byte. If +/// the hostname is longer than the length provided, no error will be provided. +/// The posix specification does not specify whether implementations will +/// null-terminate in this case, but the nix implementation will ensure that the +/// buffer is null terminated in this case. +/// +/// ```no_run +/// use nix::unistd; +/// +/// let mut buf = [0u8; 64]; +/// let hostname_cstr = unistd::gethostname(&mut buf).expect("Failed getting hostname"); +/// let hostname = hostname_cstr.to_str().expect("Hostname wasn't valid UTF-8"); +/// println!("Hostname: {}", hostname); +/// ``` +pub fn gethostname(buffer: &mut [u8]) -> Result<&CStr> { + let ptr = buffer.as_mut_ptr() as *mut c_char; + let len = buffer.len() as size_t; + + let res = unsafe { libc::gethostname(ptr, len) }; + Errno::result(res).map(|_| { + buffer[len - 1] = 0; // ensure always null-terminated + unsafe { CStr::from_ptr(buffer.as_ptr() as *const c_char) } + }) +} + +/// Close a raw file descriptor +/// +/// Be aware that many Rust types implicitly close-on-drop, including +/// `std::fs::File`. Explicitly closing them with this method too can result in +/// a double-close condition, which can cause confusing `EBADF` errors in +/// seemingly unrelated code. Caveat programmer. See also +/// [close(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html). +/// +/// # Examples +/// +/// ```no_run +/// extern crate tempfile; +/// extern crate nix; +/// +/// use std::os::unix::io::AsRawFd; +/// use nix::unistd::close; +/// +/// fn main() { +/// let f = tempfile::tempfile().unwrap(); +/// close(f.as_raw_fd()).unwrap(); // Bad! f will also close on drop! +/// } +/// ``` +/// +/// ```rust +/// extern crate tempfile; +/// extern crate nix; +/// +/// use std::os::unix::io::IntoRawFd; +/// use nix::unistd::close; +/// +/// fn main() { +/// let f = tempfile::tempfile().unwrap(); +/// close(f.into_raw_fd()).unwrap(); // Good. into_raw_fd consumes f +/// } +/// ``` +pub fn close(fd: RawFd) -> Result<()> { + let res = unsafe { libc::close(fd) }; + Errno::result(res).map(drop) +} + +/// Read from a raw file descriptor. +/// +/// See also [read(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html) +pub fn read(fd: RawFd, buf: &mut [u8]) -> Result { + let res = unsafe { libc::read(fd, buf.as_mut_ptr() as *mut c_void, buf.len() as size_t) }; + + Errno::result(res).map(|r| r as usize) +} + +/// Write to a raw file descriptor. +/// +/// See also [write(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html) +pub fn write(fd: RawFd, buf: &[u8]) -> Result { + let res = unsafe { libc::write(fd, buf.as_ptr() as *const c_void, buf.len() as size_t) }; + + Errno::result(res).map(|r| r as usize) +} + +/// Directive that tells [`lseek`] and [`lseek64`] what the offset is relative to. +/// +/// [`lseek`]: ./fn.lseek.html +/// [`lseek64`]: ./fn.lseek64.html +#[repr(i32)] +#[derive(Clone, Copy, Debug)] +pub enum Whence { + /// Specify an offset relative to the start of the file. + SeekSet = libc::SEEK_SET, + /// Specify an offset relative to the current file location. + SeekCur = libc::SEEK_CUR, + /// Specify an offset relative to the end of the file. + SeekEnd = libc::SEEK_END, + /// Specify an offset relative to the next location in the file greater than or + /// equal to offset that contains some data. If offset points to + /// some data, then the file offset is set to offset. + #[cfg(any(target_os = "dragonfly", target_os = "freebsd", + all(target_os = "linux", not(any(target_env = "musl", + target_arch = "mips", + target_arch = "mips64")))))] + SeekData = libc::SEEK_DATA, + /// Specify an offset relative to the next hole in the file greater than + /// or equal to offset. If offset points into the middle of a hole, then + /// the file offset should be set to offset. If there is no hole past offset, + /// then the file offset should be adjusted to the end of the file (i.e., there + /// is an implicit hole at the end of any file). + #[cfg(any(target_os = "dragonfly", target_os = "freebsd", + all(target_os = "linux", not(any(target_env = "musl", + target_arch = "mips", + target_arch = "mips64")))))] + SeekHole = libc::SEEK_HOLE +} + +/// Move the read/write file offset. +/// +/// See also [lseek(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html) +pub fn lseek(fd: RawFd, offset: off_t, whence: Whence) -> Result { + let res = unsafe { libc::lseek(fd, offset, whence as i32) }; + + Errno::result(res).map(|r| r as off_t) +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +pub fn lseek64(fd: RawFd, offset: libc::off64_t, whence: Whence) -> Result { + let res = unsafe { libc::lseek64(fd, offset, whence as i32) }; + + Errno::result(res).map(|r| r as libc::off64_t) +} + +/// Create an interprocess channel. +/// +/// See also [pipe(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pipe.html) +pub fn pipe() -> Result<(RawFd, RawFd)> { + unsafe { + let mut fds: [c_int; 2] = mem::uninitialized(); + + let res = libc::pipe(fds.as_mut_ptr()); + + Errno::result(res)?; + + Ok((fds[0], fds[1])) + } +} + +/// Like `pipe`, but allows setting certain file descriptor flags. +/// +/// The following flags are supported, and will be set atomically as the pipe is +/// created: +/// +/// `O_CLOEXEC`: Set the close-on-exec flag for the new file descriptors. +/// `O_NONBLOCK`: Set the non-blocking flag for the ends of the pipe. +/// +/// See also [pipe(2)](http://man7.org/linux/man-pages/man2/pipe.2.html) +#[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd"))] +pub fn pipe2(flags: OFlag) -> Result<(RawFd, RawFd)> { + let mut fds: [c_int; 2] = unsafe { mem::uninitialized() }; + + let res = unsafe { libc::pipe2(fds.as_mut_ptr(), flags.bits()) }; + + Errno::result(res)?; + + Ok((fds[0], fds[1])) +} + +/// Like `pipe`, but allows setting certain file descriptor flags. +/// +/// The following flags are supported, and will be set after the pipe is +/// created: +/// +/// `O_CLOEXEC`: Set the close-on-exec flag for the new file descriptors. +/// `O_NONBLOCK`: Set the non-blocking flag for the ends of the pipe. +#[cfg(any(target_os = "ios", target_os = "macos"))] +#[deprecated( + since="0.10.0", + note="pipe2(2) is not actually atomic on these platforms. Use pipe(2) and fcntl(2) instead" +)] +pub fn pipe2(flags: OFlag) -> Result<(RawFd, RawFd)> { + let mut fds: [c_int; 2] = unsafe { mem::uninitialized() }; + + let res = unsafe { libc::pipe(fds.as_mut_ptr()) }; + + Errno::result(res)?; + + pipe2_setflags(fds[0], fds[1], flags)?; + + Ok((fds[0], fds[1])) +} + +#[cfg(any(target_os = "ios", target_os = "macos"))] +fn pipe2_setflags(fd1: RawFd, fd2: RawFd, flags: OFlag) -> Result<()> { + use fcntl::FcntlArg::F_SETFL; + + let mut res = Ok(0); + + if flags.contains(OFlag::O_CLOEXEC) { + res = res + .and_then(|_| fcntl(fd1, F_SETFD(FdFlag::FD_CLOEXEC))) + .and_then(|_| fcntl(fd2, F_SETFD(FdFlag::FD_CLOEXEC))); + } + + if flags.contains(OFlag::O_NONBLOCK) { + res = res + .and_then(|_| fcntl(fd1, F_SETFL(OFlag::O_NONBLOCK))) + .and_then(|_| fcntl(fd2, F_SETFL(OFlag::O_NONBLOCK))); + } + + match res { + Ok(_) => Ok(()), + Err(e) => { + let _ = close(fd1); + let _ = close(fd2); + Err(e) + } + } +} + +/// Truncate a file to a specified length +/// +/// See also +/// [truncate(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html) +pub fn truncate(path: &P, len: off_t) -> Result<()> { + let res = path.with_nix_path(|cstr| { + unsafe { + libc::truncate(cstr.as_ptr(), len) + } + })?; + + Errno::result(res).map(drop) +} + +/// Truncate a file to a specified length +/// +/// See also +/// [ftruncate(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html) +pub fn ftruncate(fd: RawFd, len: off_t) -> Result<()> { + Errno::result(unsafe { libc::ftruncate(fd, len) }).map(drop) +} + +pub fn isatty(fd: RawFd) -> Result { + unsafe { + // ENOTTY means `fd` is a valid file descriptor, but not a TTY, so + // we return `Ok(false)` + if libc::isatty(fd) == 1 { + Ok(true) + } else { + match Errno::last() { + Errno::ENOTTY => Ok(false), + err => Err(Error::Sys(err)), + } + } + } +} + +/// Remove a directory entry +/// +/// See also [unlink(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html) +pub fn unlink(path: &P) -> Result<()> { + let res = path.with_nix_path(|cstr| { + unsafe { + libc::unlink(cstr.as_ptr()) + } + })?; + Errno::result(res).map(drop) +} + +#[inline] +pub fn chroot(path: &P) -> Result<()> { + let res = path.with_nix_path(|cstr| { + unsafe { libc::chroot(cstr.as_ptr()) } + })?; + + Errno::result(res).map(drop) +} + +/// Commit filesystem caches to disk +/// +/// See also [sync(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/sync.html) +#[cfg(any( + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd" +))] +pub fn sync() -> () { + unsafe { libc::sync() }; +} + +/// Synchronize changes to a file +/// +/// See also [fsync(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html) +#[inline] +pub fn fsync(fd: RawFd) -> Result<()> { + let res = unsafe { libc::fsync(fd) }; + + Errno::result(res).map(drop) +} + +/// Synchronize the data of a file +/// +/// See also +/// [fdatasync(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html) +// `fdatasync(2) is in POSIX, but in libc it is only defined in `libc::notbsd`. +// TODO: exclude only Apple systems after https://github.com/rust-lang/libc/pull/211 +#[cfg(any(target_os = "linux", + target_os = "android", + target_os = "emscripten"))] +#[inline] +pub fn fdatasync(fd: RawFd) -> Result<()> { + let res = unsafe { libc::fdatasync(fd) }; + + Errno::result(res).map(drop) +} + +/// Get a real user ID +/// +/// See also [getuid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getuid.html) +// POSIX requires that getuid is always successful, so no need to check return +// value or errno. +#[inline] +pub fn getuid() -> Uid { + Uid(unsafe { libc::getuid() }) +} + +/// Get the effective user ID +/// +/// See also [geteuid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/geteuid.html) +// POSIX requires that geteuid is always successful, so no need to check return +// value or errno. +#[inline] +pub fn geteuid() -> Uid { + Uid(unsafe { libc::geteuid() }) +} + +/// Get the real group ID +/// +/// See also [getgid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getgid.html) +// POSIX requires that getgid is always successful, so no need to check return +// value or errno. +#[inline] +pub fn getgid() -> Gid { + Gid(unsafe { libc::getgid() }) +} + +/// Get the effective group ID +/// +/// See also [getegid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getegid.html) +// POSIX requires that getegid is always successful, so no need to check return +// value or errno. +#[inline] +pub fn getegid() -> Gid { + Gid(unsafe { libc::getegid() }) +} + +/// Set the effective user ID +/// +/// See also [seteuid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/seteuid.html) +#[inline] +pub fn seteuid(euid: Uid) -> Result<()> { + let res = unsafe { libc::seteuid(euid.into()) }; + + Errno::result(res).map(drop) +} + +/// Set the effective group ID +/// +/// See also [setegid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/setegid.html) +#[inline] +pub fn setegid(egid: Gid) -> Result<()> { + let res = unsafe { libc::setegid(egid.into()) }; + + Errno::result(res).map(drop) +} + +/// Set the user ID +/// +/// See also [setuid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/setuid.html) +#[inline] +pub fn setuid(uid: Uid) -> Result<()> { + let res = unsafe { libc::setuid(uid.into()) }; + + Errno::result(res).map(drop) +} + +/// Set the group ID +/// +/// See also [setgid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/setgid.html) +#[inline] +pub fn setgid(gid: Gid) -> Result<()> { + let res = unsafe { libc::setgid(gid.into()) }; + + Errno::result(res).map(drop) +} + +/// Get the list of supplementary group IDs of the calling process. +/// +/// [Further reading](http://pubs.opengroup.org/onlinepubs/009695399/functions/getgroups.html) +/// +/// **Note:** This function is not available for Apple platforms. On those +/// platforms, checking group membership should be achieved via communication +/// with the `opendirectoryd` service. +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +pub fn getgroups() -> Result> { + // First get the number of groups so we can size our Vec + let ret = unsafe { libc::getgroups(0, ptr::null_mut()) }; + + // Now actually get the groups. We try multiple times in case the number of + // groups has changed since the first call to getgroups() and the buffer is + // now too small. + let mut groups = Vec::::with_capacity(Errno::result(ret)? as usize); + loop { + // FIXME: On the platforms we currently support, the `Gid` struct has + // the same representation in memory as a bare `gid_t`. This is not + // necessarily the case on all Rust platforms, though. See RFC 1785. + let ret = unsafe { + libc::getgroups(groups.capacity() as c_int, groups.as_mut_ptr() as *mut gid_t) + }; + + match Errno::result(ret) { + Ok(s) => { + unsafe { groups.set_len(s as usize) }; + return Ok(groups); + }, + Err(Error::Sys(Errno::EINVAL)) => { + // EINVAL indicates that the buffer size was too small. Trigger + // the internal buffer resizing logic of `Vec` by requiring + // more space than the current capacity. + let cap = groups.capacity(); + unsafe { groups.set_len(cap) }; + groups.reserve(1); + }, + Err(e) => return Err(e) + } + } +} + +/// Set the list of supplementary group IDs for the calling process. +/// +/// [Further reading](http://man7.org/linux/man-pages/man2/getgroups.2.html) +/// +/// **Note:** This function is not available for Apple platforms. On those +/// platforms, group membership management should be achieved via communication +/// with the `opendirectoryd` service. +/// +/// # Examples +/// +/// `setgroups` can be used when dropping privileges from the root user to a +/// specific user and group. For example, given the user `www-data` with UID +/// `33` and the group `backup` with the GID `34`, one could switch the user as +/// follows: +/// +/// ```rust,no_run +/// # use std::error::Error; +/// # use nix::unistd::*; +/// # +/// # fn try_main() -> Result<(), Box> { +/// let uid = Uid::from_raw(33); +/// let gid = Gid::from_raw(34); +/// setgroups(&[gid])?; +/// setgid(gid)?; +/// setuid(uid)?; +/// # +/// # Ok(()) +/// # } +/// # +/// # fn main() { +/// # try_main().unwrap(); +/// # } +/// ``` +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +pub fn setgroups(groups: &[Gid]) -> Result<()> { + cfg_if! { + if #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] { + type setgroups_ngroups_t = c_int; + } else { + type setgroups_ngroups_t = size_t; + } + } + // FIXME: On the platforms we currently support, the `Gid` struct has the + // same representation in memory as a bare `gid_t`. This is not necessarily + // the case on all Rust platforms, though. See RFC 1785. + let res = unsafe { + libc::setgroups(groups.len() as setgroups_ngroups_t, groups.as_ptr() as *const gid_t) + }; + + Errno::result(res).map(drop) +} + +/// Calculate the supplementary group access list. +/// +/// Gets the group IDs of all groups that `user` is a member of. The additional +/// group `group` is also added to the list. +/// +/// [Further reading](http://man7.org/linux/man-pages/man3/getgrouplist.3.html) +/// +/// **Note:** This function is not available for Apple platforms. On those +/// platforms, checking group membership should be achieved via communication +/// with the `opendirectoryd` service. +/// +/// # Errors +/// +/// Although the `getgrouplist()` call does not return any specific +/// errors on any known platforms, this implementation will return a system +/// error of `EINVAL` if the number of groups to be fetched exceeds the +/// `NGROUPS_MAX` sysconf value. This mimics the behaviour of `getgroups()` +/// and `setgroups()`. Additionally, while some implementations will return a +/// partial list of groups when `NGROUPS_MAX` is exceeded, this implementation +/// will only ever return the complete list or else an error. +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +pub fn getgrouplist(user: &CStr, group: Gid) -> Result> { + let ngroups_max = match sysconf(SysconfVar::NGROUPS_MAX) { + Ok(Some(n)) => n as c_int, + Ok(None) | Err(_) => ::max_value(), + }; + use std::cmp::min; + let mut ngroups = min(ngroups_max, 8); + let mut groups = Vec::::with_capacity(ngroups as usize); + cfg_if! { + if #[cfg(any(target_os = "ios", target_os = "macos"))] { + type getgrouplist_group_t = c_int; + } else { + type getgrouplist_group_t = gid_t; + } + } + let gid: gid_t = group.into(); + loop { + let ret = unsafe { + libc::getgrouplist(user.as_ptr(), + gid as getgrouplist_group_t, + groups.as_mut_ptr() as *mut getgrouplist_group_t, + &mut ngroups) + }; + + // BSD systems only return 0 or -1, Linux returns ngroups on success. + if ret >= 0 { + unsafe { groups.set_len(ngroups as usize) }; + return Ok(groups); + } else if ret == -1 { + // Returns -1 if ngroups is too small, but does not set errno. + // BSD systems will still fill the groups buffer with as many + // groups as possible, but Linux manpages do not mention this + // behavior. + + let cap = groups.capacity(); + if cap >= ngroups_max as usize { + // We already have the largest capacity we can, give up + return Err(Error::invalid_argument()); + } + + // Reserve space for at least ngroups + groups.reserve(ngroups as usize); + + // Even if the buffer gets resized to bigger than ngroups_max, + // don't ever ask for more than ngroups_max groups + ngroups = min(ngroups_max, groups.capacity() as c_int); + } + } +} + +/// Initialize the supplementary group access list. +/// +/// Sets the supplementary group IDs for the calling process using all groups +/// that `user` is a member of. The additional group `group` is also added to +/// the list. +/// +/// [Further reading](http://man7.org/linux/man-pages/man3/initgroups.3.html) +/// +/// **Note:** This function is not available for Apple platforms. On those +/// platforms, group membership management should be achieved via communication +/// with the `opendirectoryd` service. +/// +/// # Examples +/// +/// `initgroups` can be used when dropping privileges from the root user to +/// another user. For example, given the user `www-data`, we could look up the +/// UID and GID for the user in the system's password database (usually found +/// in `/etc/passwd`). If the `www-data` user's UID and GID were `33` and `33`, +/// respectively, one could switch the user as follows: +/// +/// ```rust,no_run +/// # use std::error::Error; +/// # use std::ffi::CString; +/// # use nix::unistd::*; +/// # +/// # fn try_main() -> Result<(), Box> { +/// let user = CString::new("www-data").unwrap(); +/// let uid = Uid::from_raw(33); +/// let gid = Gid::from_raw(33); +/// initgroups(&user, gid)?; +/// setgid(gid)?; +/// setuid(uid)?; +/// # +/// # Ok(()) +/// # } +/// # +/// # fn main() { +/// # try_main().unwrap(); +/// # } +/// ``` +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +pub fn initgroups(user: &CStr, group: Gid) -> Result<()> { + cfg_if! { + if #[cfg(any(target_os = "ios", target_os = "macos"))] { + type initgroups_group_t = c_int; + } else { + type initgroups_group_t = gid_t; + } + } + let gid: gid_t = group.into(); + let res = unsafe { libc::initgroups(user.as_ptr(), gid as initgroups_group_t) }; + + Errno::result(res).map(drop) +} + +/// Suspend the thread until a signal is received. +/// +/// See also [pause(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pause.html). +#[inline] +pub fn pause() { + unsafe { libc::pause() }; +} + +pub mod alarm { + //! Alarm signal scheduling. + //! + //! Scheduling an alarm will trigger a `SIGALRM` signal when the time has + //! elapsed, which has to be caught, because the default action for the + //! signal is to terminate the program. This signal also can't be ignored + //! because the system calls like `pause` will not be interrupted, see the + //! second example below. + //! + //! # Examples + //! + //! Canceling an alarm: + //! + //! ``` + //! use nix::unistd::alarm; + //! + //! // Set an alarm for 60 seconds from now. + //! alarm::set(60); + //! + //! // Cancel the above set alarm, which returns the number of seconds left + //! // of the previously set alarm. + //! assert_eq!(alarm::cancel(), Some(60)); + //! ``` + //! + //! Scheduling an alarm and waiting for the signal: + //! + //! ``` + //! use std::time::{Duration, Instant}; + //! + //! use nix::unistd::{alarm, pause}; + //! use nix::sys::signal::*; + //! + //! // We need to setup an empty signal handler to catch the alarm signal, + //! // otherwise the program will be terminated once the signal is delivered. + //! extern fn signal_handler(_: nix::libc::c_int) { } + //! unsafe { sigaction(Signal::SIGALRM, &SigAction::new(SigHandler::Handler(signal_handler), SaFlags::empty(), SigSet::empty())); } + //! + //! // Set an alarm for 1 second from now. + //! alarm::set(1); + //! + //! let start = Instant::now(); + //! // Pause the process until the alarm signal is received. + //! pause(); + //! + //! assert!(start.elapsed() >= Duration::from_secs(1)); + //! ``` + //! + //! # References + //! + //! See also [alarm(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/alarm.html). + + use libc; + + /// Schedule an alarm signal. + /// + /// This will cause the system to generate a `SIGALRM` signal for the + /// process after the specified number of seconds have elapsed. + /// + /// Returns the leftover time of a previously set alarm if there was one. + pub fn set(secs: libc::c_uint) -> Option { + assert!(secs != 0, "passing 0 to `alarm::set` is not allowed, to cancel an alarm use `alarm::cancel`"); + alarm(secs) + } + + /// Cancel an previously set alarm signal. + /// + /// Returns the leftover time of a previously set alarm if there was one. + pub fn cancel() -> Option { + alarm(0) + } + + fn alarm(secs: libc::c_uint) -> Option { + match unsafe { libc::alarm(secs) } { + 0 => None, + secs => Some(secs), + } + } +} + +/// Suspend execution for an interval of time +/// +/// See also [sleep(2)](http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html#tag_03_705_05) +// Per POSIX, does not fail +#[inline] +pub fn sleep(seconds: c_uint) -> c_uint { + unsafe { libc::sleep(seconds) } +} + +pub mod acct { + use libc; + use {Result, NixPath}; + use errno::Errno; + use std::ptr; + + /// Enable process accounting + /// + /// See also [acct(2)](https://linux.die.net/man/2/acct) + pub fn enable(filename: &P) -> Result<()> { + let res = filename.with_nix_path(|cstr| { + unsafe { libc::acct(cstr.as_ptr()) } + })?; + + Errno::result(res).map(drop) + } + + /// Disable process accounting + pub fn disable() -> Result<()> { + let res = unsafe { libc::acct(ptr::null()) }; + + Errno::result(res).map(drop) + } +} + +/// Creates a regular file which persists even after process termination +/// +/// * `template`: a path whose 6 rightmost characters must be X, e.g. `/tmp/tmpfile_XXXXXX` +/// * returns: tuple of file descriptor and filename +/// +/// Err is returned either if no temporary filename could be created or the template doesn't +/// end with XXXXXX +/// +/// See also [mkstemp(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkstemp.html) +/// +/// # Example +/// +/// ```rust +/// use nix::unistd; +/// +/// let _ = match unistd::mkstemp("/tmp/tempfile_XXXXXX") { +/// Ok((fd, path)) => { +/// unistd::unlink(path.as_path()).unwrap(); // flag file to be deleted at app termination +/// fd +/// } +/// Err(e) => panic!("mkstemp failed: {}", e) +/// }; +/// // do something with fd +/// ``` +#[inline] +pub fn mkstemp(template: &P) -> Result<(RawFd, PathBuf)> { + let mut path = template.with_nix_path(|path| {path.to_bytes_with_nul().to_owned()})?; + let p = path.as_mut_ptr() as *mut _; + let fd = unsafe { libc::mkstemp(p) }; + let last = path.pop(); // drop the trailing nul + debug_assert!(last == Some(b'\0')); + let pathname = OsString::from_vec(path); + Errno::result(fd)?; + Ok((fd, PathBuf::from(pathname))) +} + +/// Variable names for `pathconf` +/// +/// Nix uses the same naming convention for these variables as the +/// [getconf(1)](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getconf.html) utility. +/// That is, `PathconfVar` variables have the same name as the abstract +/// variables shown in the `pathconf(2)` man page. Usually, it's the same as +/// the C variable name without the leading `_PC_`. +/// +/// POSIX 1003.1-2008 standardizes all of these variables, but some OSes choose +/// not to implement variables that cannot change at runtime. +/// +/// # References +/// +/// - [pathconf(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pathconf.html) +/// - [limits.h](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html) +/// - [unistd.h](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html) +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +#[repr(i32)] +pub enum PathconfVar { + #[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "linux", + target_os = "netbsd", target_os = "openbsd"))] + /// Minimum number of bits needed to represent, as a signed integer value, + /// the maximum size of a regular file allowed in the specified directory. + FILESIZEBITS = libc::_PC_FILESIZEBITS, + /// Maximum number of links to a single file. + LINK_MAX = libc::_PC_LINK_MAX, + /// Maximum number of bytes in a terminal canonical input line. + MAX_CANON = libc::_PC_MAX_CANON, + /// Minimum number of bytes for which space is available in a terminal input + /// queue; therefore, the maximum number of bytes a conforming application + /// may require to be typed as input before reading them. + MAX_INPUT = libc::_PC_MAX_INPUT, + /// Maximum number of bytes in a filename (not including the terminating + /// null of a filename string). + NAME_MAX = libc::_PC_NAME_MAX, + /// Maximum number of bytes the implementation will store as a pathname in a + /// user-supplied buffer of unspecified size, including the terminating null + /// character. Minimum number the implementation will accept as the maximum + /// number of bytes in a pathname. + PATH_MAX = libc::_PC_PATH_MAX, + /// Maximum number of bytes that is guaranteed to be atomic when writing to + /// a pipe. + PIPE_BUF = libc::_PC_PIPE_BUF, + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "linux", + target_os = "netbsd", target_os = "openbsd"))] + /// Symbolic links can be created. + POSIX2_SYMLINKS = libc::_PC_2_SYMLINKS, + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "linux", target_os = "openbsd"))] + /// Minimum number of bytes of storage actually allocated for any portion of + /// a file. + POSIX_ALLOC_SIZE_MIN = libc::_PC_ALLOC_SIZE_MIN, + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "linux", target_os = "openbsd"))] + /// Recommended increment for file transfer sizes between the + /// `POSIX_REC_MIN_XFER_SIZE` and `POSIX_REC_MAX_XFER_SIZE` values. + POSIX_REC_INCR_XFER_SIZE = libc::_PC_REC_INCR_XFER_SIZE, + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "linux", target_os = "openbsd"))] + /// Maximum recommended file transfer size. + POSIX_REC_MAX_XFER_SIZE = libc::_PC_REC_MAX_XFER_SIZE, + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "linux", target_os = "openbsd"))] + /// Minimum recommended file transfer size. + POSIX_REC_MIN_XFER_SIZE = libc::_PC_REC_MIN_XFER_SIZE, + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "linux", target_os = "openbsd"))] + /// Recommended file transfer buffer alignment. + POSIX_REC_XFER_ALIGN = libc::_PC_REC_XFER_ALIGN, + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "linux", target_os = "netbsd", target_os = "openbsd"))] + /// Maximum number of bytes in a symbolic link. + SYMLINK_MAX = libc::_PC_SYMLINK_MAX, + /// The use of `chown` and `fchown` is restricted to a process with + /// appropriate privileges, and to changing the group ID of a file only to + /// the effective group ID of the process or to one of its supplementary + /// group IDs. + _POSIX_CHOWN_RESTRICTED = libc::_PC_CHOWN_RESTRICTED, + /// Pathname components longer than {NAME_MAX} generate an error. + _POSIX_NO_TRUNC = libc::_PC_NO_TRUNC, + /// This symbol shall be defined to be the value of a character that shall + /// disable terminal special character handling. + _POSIX_VDISABLE = libc::_PC_VDISABLE, + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "linux", target_os = "openbsd"))] + /// Asynchronous input or output operations may be performed for the + /// associated file. + _POSIX_ASYNC_IO = libc::_PC_ASYNC_IO, + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "linux", target_os = "openbsd"))] + /// Prioritized input or output operations may be performed for the + /// associated file. + _POSIX_PRIO_IO = libc::_PC_PRIO_IO, + #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "linux", target_os = "netbsd", target_os = "openbsd"))] + /// Synchronized input or output operations may be performed for the + /// associated file. + _POSIX_SYNC_IO = libc::_PC_SYNC_IO, + #[cfg(any(target_os = "dragonfly", target_os = "openbsd"))] + /// The resolution in nanoseconds for all file timestamps. + _POSIX_TIMESTAMP_RESOLUTION = libc::_PC_TIMESTAMP_RESOLUTION +} + +/// Like `pathconf`, but works with file descriptors instead of paths (see +/// [fpathconf(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pathconf.html)) +/// +/// # Parameters +/// +/// - `fd`: The file descriptor whose variable should be interrogated +/// - `var`: The pathconf variable to lookup +/// +/// # Returns +/// +/// - `Ok(Some(x))`: the variable's limit (for limit variables) or its +/// implementation level (for option variables). Implementation levels are +/// usually a decimal-coded date, such as 200112 for POSIX 2001.12 +/// - `Ok(None)`: the variable has no limit (for limit variables) or is +/// unsupported (for option variables) +/// - `Err(x)`: an error occurred +pub fn fpathconf(fd: RawFd, var: PathconfVar) -> Result> { + let raw = unsafe { + Errno::clear(); + libc::fpathconf(fd, var as c_int) + }; + if raw == -1 { + if errno::errno() == 0 { + Ok(None) + } else { + Err(Error::Sys(Errno::last())) + } + } else { + Ok(Some(raw)) + } +} + +/// Get path-dependent configurable system variables (see +/// [pathconf(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pathconf.html)) +/// +/// Returns the value of a path-dependent configurable system variable. Most +/// supported variables also have associated compile-time constants, but POSIX +/// allows their values to change at runtime. There are generally two types of +/// `pathconf` variables: options and limits. See [pathconf(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pathconf.html) for more details. +/// +/// # Parameters +/// +/// - `path`: Lookup the value of `var` for this file or directory +/// - `var`: The `pathconf` variable to lookup +/// +/// # Returns +/// +/// - `Ok(Some(x))`: the variable's limit (for limit variables) or its +/// implementation level (for option variables). Implementation levels are +/// usually a decimal-coded date, such as 200112 for POSIX 2001.12 +/// - `Ok(None)`: the variable has no limit (for limit variables) or is +/// unsupported (for option variables) +/// - `Err(x)`: an error occurred +pub fn pathconf(path: &P, var: PathconfVar) -> Result> { + let raw = path.with_nix_path(|cstr| { + unsafe { + Errno::clear(); + libc::pathconf(cstr.as_ptr(), var as c_int) + } + })?; + if raw == -1 { + if errno::errno() == 0 { + Ok(None) + } else { + Err(Error::Sys(Errno::last())) + } + } else { + Ok(Some(raw)) + } +} + +/// Variable names for `sysconf` +/// +/// Nix uses the same naming convention for these variables as the +/// [getconf(1)](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getconf.html) utility. +/// That is, `SysconfVar` variables have the same name as the abstract variables +/// shown in the `sysconf(3)` man page. Usually, it's the same as the C +/// variable name without the leading `_SC_`. +/// +/// All of these symbols are standardized by POSIX 1003.1-2008, but haven't been +/// implemented by all platforms. +/// +/// # References +/// +/// - [sysconf(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html) +/// - [unistd.h](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html) +/// - [limits.h](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html) +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +#[repr(i32)] +pub enum SysconfVar { + /// Maximum number of I/O operations in a single list I/O call supported by + /// the implementation. + AIO_LISTIO_MAX = libc::_SC_AIO_LISTIO_MAX, + /// Maximum number of outstanding asynchronous I/O operations supported by + /// the implementation. + AIO_MAX = libc::_SC_AIO_MAX, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + /// The maximum amount by which a process can decrease its asynchronous I/O + /// priority level from its own scheduling priority. + AIO_PRIO_DELTA_MAX = libc::_SC_AIO_PRIO_DELTA_MAX, + /// Maximum length of argument to the exec functions including environment data. + ARG_MAX = libc::_SC_ARG_MAX, + /// Maximum number of functions that may be registered with `atexit`. + ATEXIT_MAX = libc::_SC_ATEXIT_MAX, + /// Maximum obase values allowed by the bc utility. + BC_BASE_MAX = libc::_SC_BC_BASE_MAX, + /// Maximum number of elements permitted in an array by the bc utility. + BC_DIM_MAX = libc::_SC_BC_DIM_MAX, + /// Maximum scale value allowed by the bc utility. + BC_SCALE_MAX = libc::_SC_BC_SCALE_MAX, + /// Maximum length of a string constant accepted by the bc utility. + BC_STRING_MAX = libc::_SC_BC_STRING_MAX, + /// Maximum number of simultaneous processes per real user ID. + CHILD_MAX = libc::_SC_CHILD_MAX, + // _SC_CLK_TCK is obsolete + /// Maximum number of weights that can be assigned to an entry of the + /// LC_COLLATE order keyword in the locale definition file + COLL_WEIGHTS_MAX = libc::_SC_COLL_WEIGHTS_MAX, + /// Maximum number of timer expiration overruns. + DELAYTIMER_MAX = libc::_SC_DELAYTIMER_MAX, + /// Maximum number of expressions that can be nested within parentheses by + /// the expr utility. + EXPR_NEST_MAX = libc::_SC_EXPR_NEST_MAX, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// Maximum length of a host name (not including the terminating null) as + /// returned from the `gethostname` function + HOST_NAME_MAX = libc::_SC_HOST_NAME_MAX, + /// Maximum number of iovec structures that one process has available for + /// use with `readv` or `writev`. + IOV_MAX = libc::_SC_IOV_MAX, + /// Unless otherwise noted, the maximum length, in bytes, of a utility's + /// input line (either standard input or another file), when the utility is + /// described as processing text files. The length includes room for the + /// trailing . + LINE_MAX = libc::_SC_LINE_MAX, + /// Maximum length of a login name. + LOGIN_NAME_MAX = libc::_SC_LOGIN_NAME_MAX, + /// Maximum number of simultaneous supplementary group IDs per process. + NGROUPS_MAX = libc::_SC_NGROUPS_MAX, + /// Initial size of `getgrgid_r` and `getgrnam_r` data buffers + GETGR_R_SIZE_MAX = libc::_SC_GETGR_R_SIZE_MAX, + /// Initial size of `getpwuid_r` and `getpwnam_r` data buffers + GETPW_R_SIZE_MAX = libc::_SC_GETPW_R_SIZE_MAX, + /// The maximum number of open message queue descriptors a process may hold. + MQ_OPEN_MAX = libc::_SC_MQ_OPEN_MAX, + /// The maximum number of message priorities supported by the implementation. + MQ_PRIO_MAX = libc::_SC_MQ_PRIO_MAX, + /// A value one greater than the maximum value that the system may assign to + /// a newly-created file descriptor. + OPEN_MAX = libc::_SC_OPEN_MAX, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the Advisory Information option. + _POSIX_ADVISORY_INFO = libc::_SC_ADVISORY_INFO, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports barriers. + _POSIX_BARRIERS = libc::_SC_BARRIERS, + /// The implementation supports asynchronous input and output. + _POSIX_ASYNCHRONOUS_IO = libc::_SC_ASYNCHRONOUS_IO, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports clock selection. + _POSIX_CLOCK_SELECTION = libc::_SC_CLOCK_SELECTION, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the Process CPU-Time Clocks option. + _POSIX_CPUTIME = libc::_SC_CPUTIME, + /// The implementation supports the File Synchronization option. + _POSIX_FSYNC = libc::_SC_FSYNC, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the IPv6 option. + _POSIX_IPV6 = libc::_SC_IPV6, + /// The implementation supports job control. + _POSIX_JOB_CONTROL = libc::_SC_JOB_CONTROL, + /// The implementation supports memory mapped Files. + _POSIX_MAPPED_FILES = libc::_SC_MAPPED_FILES, + /// The implementation supports the Process Memory Locking option. + _POSIX_MEMLOCK = libc::_SC_MEMLOCK, + /// The implementation supports the Range Memory Locking option. + _POSIX_MEMLOCK_RANGE = libc::_SC_MEMLOCK_RANGE, + /// The implementation supports memory protection. + _POSIX_MEMORY_PROTECTION = libc::_SC_MEMORY_PROTECTION, + /// The implementation supports the Message Passing option. + _POSIX_MESSAGE_PASSING = libc::_SC_MESSAGE_PASSING, + /// The implementation supports the Monotonic Clock option. + _POSIX_MONOTONIC_CLOCK = libc::_SC_MONOTONIC_CLOCK, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + /// The implementation supports the Prioritized Input and Output option. + _POSIX_PRIORITIZED_IO = libc::_SC_PRIORITIZED_IO, + /// The implementation supports the Process Scheduling option. + _POSIX_PRIORITY_SCHEDULING = libc::_SC_PRIORITY_SCHEDULING, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the Raw Sockets option. + _POSIX_RAW_SOCKETS = libc::_SC_RAW_SOCKETS, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports read-write locks. + _POSIX_READER_WRITER_LOCKS = libc::_SC_READER_WRITER_LOCKS, + #[cfg(any(target_os = "android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os = "openbsd"))] + /// The implementation supports realtime signals. + _POSIX_REALTIME_SIGNALS = libc::_SC_REALTIME_SIGNALS, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the Regular Expression Handling option. + _POSIX_REGEXP = libc::_SC_REGEXP, + /// Each process has a saved set-user-ID and a saved set-group-ID. + _POSIX_SAVED_IDS = libc::_SC_SAVED_IDS, + /// The implementation supports semaphores. + _POSIX_SEMAPHORES = libc::_SC_SEMAPHORES, + /// The implementation supports the Shared Memory Objects option. + _POSIX_SHARED_MEMORY_OBJECTS = libc::_SC_SHARED_MEMORY_OBJECTS, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the POSIX shell. + _POSIX_SHELL = libc::_SC_SHELL, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the Spawn option. + _POSIX_SPAWN = libc::_SC_SPAWN, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports spin locks. + _POSIX_SPIN_LOCKS = libc::_SC_SPIN_LOCKS, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the Process Sporadic Server option. + _POSIX_SPORADIC_SERVER = libc::_SC_SPORADIC_SERVER, + #[cfg(any(target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + _POSIX_SS_REPL_MAX = libc::_SC_SS_REPL_MAX, + /// The implementation supports the Synchronized Input and Output option. + _POSIX_SYNCHRONIZED_IO = libc::_SC_SYNCHRONIZED_IO, + /// The implementation supports the Thread Stack Address Attribute option. + _POSIX_THREAD_ATTR_STACKADDR = libc::_SC_THREAD_ATTR_STACKADDR, + /// The implementation supports the Thread Stack Size Attribute option. + _POSIX_THREAD_ATTR_STACKSIZE = libc::_SC_THREAD_ATTR_STACKSIZE, + #[cfg(any(target_os = "ios", target_os="linux", target_os = "macos", + target_os="netbsd", target_os="openbsd"))] + /// The implementation supports the Thread CPU-Time Clocks option. + _POSIX_THREAD_CPUTIME = libc::_SC_THREAD_CPUTIME, + /// The implementation supports the Non-Robust Mutex Priority Inheritance + /// option. + _POSIX_THREAD_PRIO_INHERIT = libc::_SC_THREAD_PRIO_INHERIT, + /// The implementation supports the Non-Robust Mutex Priority Protection option. + _POSIX_THREAD_PRIO_PROTECT = libc::_SC_THREAD_PRIO_PROTECT, + /// The implementation supports the Thread Execution Scheduling option. + _POSIX_THREAD_PRIORITY_SCHEDULING = libc::_SC_THREAD_PRIORITY_SCHEDULING, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the Thread Process-Shared Synchronization + /// option. + _POSIX_THREAD_PROCESS_SHARED = libc::_SC_THREAD_PROCESS_SHARED, + #[cfg(any(target_os="dragonfly", target_os="linux", target_os="openbsd"))] + /// The implementation supports the Robust Mutex Priority Inheritance option. + _POSIX_THREAD_ROBUST_PRIO_INHERIT = libc::_SC_THREAD_ROBUST_PRIO_INHERIT, + #[cfg(any(target_os="dragonfly", target_os="linux", target_os="openbsd"))] + /// The implementation supports the Robust Mutex Priority Protection option. + _POSIX_THREAD_ROBUST_PRIO_PROTECT = libc::_SC_THREAD_ROBUST_PRIO_PROTECT, + /// The implementation supports thread-safe functions. + _POSIX_THREAD_SAFE_FUNCTIONS = libc::_SC_THREAD_SAFE_FUNCTIONS, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the Thread Sporadic Server option. + _POSIX_THREAD_SPORADIC_SERVER = libc::_SC_THREAD_SPORADIC_SERVER, + /// The implementation supports threads. + _POSIX_THREADS = libc::_SC_THREADS, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports timeouts. + _POSIX_TIMEOUTS = libc::_SC_TIMEOUTS, + /// The implementation supports timers. + _POSIX_TIMERS = libc::_SC_TIMERS, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the Trace option. + _POSIX_TRACE = libc::_SC_TRACE, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the Trace Event Filter option. + _POSIX_TRACE_EVENT_FILTER = libc::_SC_TRACE_EVENT_FILTER, + #[cfg(any(target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + _POSIX_TRACE_EVENT_NAME_MAX = libc::_SC_TRACE_EVENT_NAME_MAX, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the Trace Inherit option. + _POSIX_TRACE_INHERIT = libc::_SC_TRACE_INHERIT, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the Trace Log option. + _POSIX_TRACE_LOG = libc::_SC_TRACE_LOG, + #[cfg(any(target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + _POSIX_TRACE_NAME_MAX = libc::_SC_TRACE_NAME_MAX, + #[cfg(any(target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + _POSIX_TRACE_SYS_MAX = libc::_SC_TRACE_SYS_MAX, + #[cfg(any(target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + _POSIX_TRACE_USER_EVENT_MAX = libc::_SC_TRACE_USER_EVENT_MAX, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the Typed Memory Objects option. + _POSIX_TYPED_MEMORY_OBJECTS = libc::_SC_TYPED_MEMORY_OBJECTS, + /// Integer value indicating version of this standard (C-language binding) + /// to which the implementation conforms. For implementations conforming to + /// POSIX.1-2008, the value shall be 200809L. + _POSIX_VERSION = libc::_SC_VERSION, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation provides a C-language compilation environment with + /// 32-bit `int`, `long`, `pointer`, and `off_t` types. + _POSIX_V6_ILP32_OFF32 = libc::_SC_V6_ILP32_OFF32, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation provides a C-language compilation environment with + /// 32-bit `int`, `long`, and pointer types and an `off_t` type using at + /// least 64 bits. + _POSIX_V6_ILP32_OFFBIG = libc::_SC_V6_ILP32_OFFBIG, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation provides a C-language compilation environment with + /// 32-bit `int` and 64-bit `long`, `pointer`, and `off_t` types. + _POSIX_V6_LP64_OFF64 = libc::_SC_V6_LP64_OFF64, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation provides a C-language compilation environment with an + /// `int` type using at least 32 bits and `long`, pointer, and `off_t` types + /// using at least 64 bits. + _POSIX_V6_LPBIG_OFFBIG = libc::_SC_V6_LPBIG_OFFBIG, + /// The implementation supports the C-Language Binding option. + _POSIX2_C_BIND = libc::_SC_2_C_BIND, + /// The implementation supports the C-Language Development Utilities option. + _POSIX2_C_DEV = libc::_SC_2_C_DEV, + /// The implementation supports the Terminal Characteristics option. + _POSIX2_CHAR_TERM = libc::_SC_2_CHAR_TERM, + /// The implementation supports the FORTRAN Development Utilities option. + _POSIX2_FORT_DEV = libc::_SC_2_FORT_DEV, + /// The implementation supports the FORTRAN Runtime Utilities option. + _POSIX2_FORT_RUN = libc::_SC_2_FORT_RUN, + /// The implementation supports the creation of locales by the localedef + /// utility. + _POSIX2_LOCALEDEF = libc::_SC_2_LOCALEDEF, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the Batch Environment Services and Utilities + /// option. + _POSIX2_PBS = libc::_SC_2_PBS, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the Batch Accounting option. + _POSIX2_PBS_ACCOUNTING = libc::_SC_2_PBS_ACCOUNTING, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the Batch Checkpoint/Restart option. + _POSIX2_PBS_CHECKPOINT = libc::_SC_2_PBS_CHECKPOINT, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the Locate Batch Job Request option. + _POSIX2_PBS_LOCATE = libc::_SC_2_PBS_LOCATE, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the Batch Job Message Request option. + _POSIX2_PBS_MESSAGE = libc::_SC_2_PBS_MESSAGE, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + /// The implementation supports the Track Batch Job Request option. + _POSIX2_PBS_TRACK = libc::_SC_2_PBS_TRACK, + /// The implementation supports the Software Development Utilities option. + _POSIX2_SW_DEV = libc::_SC_2_SW_DEV, + /// The implementation supports the User Portability Utilities option. + _POSIX2_UPE = libc::_SC_2_UPE, + /// Integer value indicating version of the Shell and Utilities volume of + /// POSIX.1 to which the implementation conforms. + _POSIX2_VERSION = libc::_SC_2_VERSION, + /// The size of a system page in bytes. + /// + /// POSIX also defines an alias named `PAGESIZE`, but Rust does not allow two + /// enum constants to have the same value, so nix omits `PAGESIZE`. + PAGE_SIZE = libc::_SC_PAGE_SIZE, + PTHREAD_DESTRUCTOR_ITERATIONS = libc::_SC_THREAD_DESTRUCTOR_ITERATIONS, + PTHREAD_KEYS_MAX = libc::_SC_THREAD_KEYS_MAX, + PTHREAD_STACK_MIN = libc::_SC_THREAD_STACK_MIN, + PTHREAD_THREADS_MAX = libc::_SC_THREAD_THREADS_MAX, + RE_DUP_MAX = libc::_SC_RE_DUP_MAX, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + RTSIG_MAX = libc::_SC_RTSIG_MAX, + SEM_NSEMS_MAX = libc::_SC_SEM_NSEMS_MAX, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + SEM_VALUE_MAX = libc::_SC_SEM_VALUE_MAX, + #[cfg(any(target_os = "android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os = "openbsd"))] + SIGQUEUE_MAX = libc::_SC_SIGQUEUE_MAX, + STREAM_MAX = libc::_SC_STREAM_MAX, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="netbsd", + target_os="openbsd"))] + SYMLOOP_MAX = libc::_SC_SYMLOOP_MAX, + TIMER_MAX = libc::_SC_TIMER_MAX, + TTY_NAME_MAX = libc::_SC_TTY_NAME_MAX, + TZNAME_MAX = libc::_SC_TZNAME_MAX, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + /// The implementation supports the X/Open Encryption Option Group. + _XOPEN_CRYPT = libc::_SC_XOPEN_CRYPT, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + /// The implementation supports the Issue 4, Version 2 Enhanced + /// Internationalization Option Group. + _XOPEN_ENH_I18N = libc::_SC_XOPEN_ENH_I18N, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + _XOPEN_LEGACY = libc::_SC_XOPEN_LEGACY, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + /// The implementation supports the X/Open Realtime Option Group. + _XOPEN_REALTIME = libc::_SC_XOPEN_REALTIME, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + /// The implementation supports the X/Open Realtime Threads Option Group. + _XOPEN_REALTIME_THREADS = libc::_SC_XOPEN_REALTIME_THREADS, + /// The implementation supports the Issue 4, Version 2 Shared Memory Option + /// Group. + _XOPEN_SHM = libc::_SC_XOPEN_SHM, + #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", + target_os="linux", target_os = "macos", target_os="openbsd"))] + /// The implementation supports the XSI STREAMS Option Group. + _XOPEN_STREAMS = libc::_SC_XOPEN_STREAMS, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + /// The implementation supports the XSI option + _XOPEN_UNIX = libc::_SC_XOPEN_UNIX, + #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", + target_os = "ios", target_os="linux", target_os = "macos", + target_os="openbsd"))] + /// Integer value indicating version of the X/Open Portability Guide to + /// which the implementation conforms. + _XOPEN_VERSION = libc::_SC_XOPEN_VERSION, +} + +/// Get configurable system variables (see +/// [sysconf(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html)) +/// +/// Returns the value of a configurable system variable. Most supported +/// variables also have associated compile-time constants, but POSIX +/// allows their values to change at runtime. There are generally two types of +/// sysconf variables: options and limits. See sysconf(3) for more details. +/// +/// # Returns +/// +/// - `Ok(Some(x))`: the variable's limit (for limit variables) or its +/// implementation level (for option variables). Implementation levels are +/// usually a decimal-coded date, such as 200112 for POSIX 2001.12 +/// - `Ok(None)`: the variable has no limit (for limit variables) or is +/// unsupported (for option variables) +/// - `Err(x)`: an error occurred +pub fn sysconf(var: SysconfVar) -> Result> { + let raw = unsafe { + Errno::clear(); + libc::sysconf(var as c_int) + }; + if raw == -1 { + if errno::errno() == 0 { + Ok(None) + } else { + Err(Error::Sys(Errno::last())) + } + } else { + Ok(Some(raw)) + } +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +mod pivot_root { + use libc; + use {Result, NixPath}; + use errno::Errno; + + pub fn pivot_root( + new_root: &P1, put_old: &P2) -> Result<()> { + let res = new_root.with_nix_path(|new_root| { + put_old.with_nix_path(|put_old| { + unsafe { + libc::syscall(libc::SYS_pivot_root, new_root.as_ptr(), put_old.as_ptr()) + } + }) + })??; + + Errno::result(res).map(drop) + } +} + +#[cfg(any(target_os = "android", target_os = "freebsd", + target_os = "linux", target_os = "openbsd"))] +mod setres { + use libc; + use Result; + use errno::Errno; + use super::{Uid, Gid}; + + /// Sets the real, effective, and saved uid. + /// ([see setresuid(2)](http://man7.org/linux/man-pages/man2/setresuid.2.html)) + /// + /// * `ruid`: real user id + /// * `euid`: effective user id + /// * `suid`: saved user id + /// * returns: Ok or libc error code. + /// + /// Err is returned if the user doesn't have permission to set this UID. + #[inline] + pub fn setresuid(ruid: Uid, euid: Uid, suid: Uid) -> Result<()> { + let res = unsafe { libc::setresuid(ruid.into(), euid.into(), suid.into()) }; + + Errno::result(res).map(drop) + } + + /// Sets the real, effective, and saved gid. + /// ([see setresuid(2)](http://man7.org/linux/man-pages/man2/setresuid.2.html)) + /// + /// * `rgid`: real group id + /// * `egid`: effective group id + /// * `sgid`: saved group id + /// * returns: Ok or libc error code. + /// + /// Err is returned if the user doesn't have permission to set this GID. + #[inline] + pub fn setresgid(rgid: Gid, egid: Gid, sgid: Gid) -> Result<()> { + let res = unsafe { libc::setresgid(rgid.into(), egid.into(), sgid.into()) }; + + Errno::result(res).map(drop) + } +} + +libc_bitflags!{ + /// Options for access() + pub struct AccessFlags : c_int { + /// Test for existence of file. + F_OK; + /// Test for read permission. + R_OK; + /// Test for write permission. + W_OK; + /// Test for execute (search) permission. + X_OK; + } +} + +/// Checks the file named by `path` for accessibility according to the flags given by `amode` +/// See [access(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html) +pub fn access(path: &P, amode: AccessFlags) -> Result<()> { + let res = path.with_nix_path(|cstr| { + unsafe { + libc::access(cstr.as_ptr(), amode.bits) + } + })?; + Errno::result(res).map(drop) +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/mod.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/mod.rs new file mode 100644 index 0000000..60a58dd --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/mod.rs @@ -0,0 +1,38 @@ +mod test_signal; + +// NOTE: DragonFly lacks a kernel-level implementation of Posix AIO as of +// this writing. There is an user-level implementation, but whether aio +// works or not heavily depends on which pthread implementation is chosen +// by the user at link time. For this reason we do not want to run aio test +// cases on DragonFly. +#[cfg(any(target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd"))] +mod test_aio; +#[cfg(target_os = "linux")] +mod test_signalfd; +mod test_socket; +mod test_sockopt; +mod test_select; +#[cfg(any(target_os = "android", target_os = "linux"))] +mod test_sysinfo; +mod test_termios; +mod test_ioctl; +mod test_wait; +mod test_uio; + +#[cfg(target_os = "linux")] +mod test_epoll; +#[cfg(target_os = "linux")] +mod test_inotify; +mod test_pthread; +#[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +mod test_ptrace; diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_aio.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_aio.rs new file mode 100644 index 0000000..d4b09b0 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_aio.rs @@ -0,0 +1,654 @@ +use bytes::{Bytes, BytesMut}; +use libc::{c_int, c_void}; +use nix::{Error, Result}; +use nix::errno::*; +use nix::sys::aio::*; +use nix::sys::signal::{SaFlags, SigAction, sigaction, SigevNotify, SigHandler, Signal, SigSet}; +use nix::sys::time::{TimeSpec, TimeValLike}; +use std::io::{Write, Read, Seek, SeekFrom}; +use std::ops::Deref; +use std::os::unix::io::AsRawFd; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::{thread, time}; +use tempfile::tempfile; + +// Helper that polls an AioCb for completion or error +fn poll_aio(aiocb: &mut AioCb) -> Result<()> { + loop { + let err = aiocb.error(); + if err != Err(Error::from(Errno::EINPROGRESS)) { return err; }; + thread::sleep(time::Duration::from_millis(10)); + } +} + +#[test] +fn test_accessors() { + let mut rbuf = vec![0; 4]; + let aiocb = AioCb::from_mut_slice( 1001, + 2, //offset + &mut rbuf, + 42, //priority + SigevNotify::SigevSignal { + signal: Signal::SIGUSR2, + si_value: 99 + }, + LioOpcode::LIO_NOP); + assert_eq!(1001, aiocb.fd()); + assert_eq!(Some(LioOpcode::LIO_NOP), aiocb.lio_opcode()); + assert_eq!(4, aiocb.nbytes()); + assert_eq!(2, aiocb.offset()); + assert_eq!(42, aiocb.priority()); + let sev = aiocb.sigevent().sigevent(); + assert_eq!(Signal::SIGUSR2 as i32, sev.sigev_signo); + assert_eq!(99, sev.sigev_value.sival_ptr as i64); +} + +// Tests AioCb.cancel. We aren't trying to test the OS's implementation, only +// our bindings. So it's sufficient to check that AioCb.cancel returned any +// AioCancelStat value. +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_cancel() { + let wbuf: &[u8] = b"CDEF"; + + let f = tempfile().unwrap(); + let mut aiocb = AioCb::from_slice( f.as_raw_fd(), + 0, //offset + wbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + aiocb.write().unwrap(); + let err = aiocb.error(); + assert!(err == Ok(()) || err == Err(Error::from(Errno::EINPROGRESS))); + + let cancelstat = aiocb.cancel(); + assert!(cancelstat.is_ok()); + + // Wait for aiocb to complete, but don't care whether it succeeded + let _ = poll_aio(&mut aiocb); + let _ = aiocb.aio_return(); +} + +// Tests using aio_cancel_all for all outstanding IOs. +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_aio_cancel_all() { + let wbuf: &[u8] = b"CDEF"; + + let f = tempfile().unwrap(); + let mut aiocb = AioCb::from_slice(f.as_raw_fd(), + 0, //offset + wbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + aiocb.write().unwrap(); + let err = aiocb.error(); + assert!(err == Ok(()) || err == Err(Error::from(Errno::EINPROGRESS))); + + let cancelstat = aio_cancel_all(f.as_raw_fd()); + assert!(cancelstat.is_ok()); + + // Wait for aiocb to complete, but don't care whether it succeeded + let _ = poll_aio(&mut aiocb); + let _ = aiocb.aio_return(); +} + +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_fsync() { + const INITIAL: &[u8] = b"abcdef123456"; + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + let mut aiocb = AioCb::from_fd( f.as_raw_fd(), + 0, //priority + SigevNotify::SigevNone); + let err = aiocb.fsync(AioFsyncMode::O_SYNC); + assert!(err.is_ok()); + poll_aio(&mut aiocb).unwrap(); + aiocb.aio_return().unwrap(); +} + +/// `AioCb::fsync` should not modify the `AioCb` object if `libc::aio_fsync` returns +/// an error +// Skip on Linux, because Linux's AIO implementation can't detect errors +// synchronously +#[test] +#[cfg(any(target_os = "freebsd", target_os = "macos"))] +fn test_fsync_error() { + use std::mem; + + const INITIAL: &[u8] = b"abcdef123456"; + // Create an invalid AioFsyncMode + let mode = unsafe { mem::transmute(666) }; + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + let mut aiocb = AioCb::from_fd( f.as_raw_fd(), + 0, //priority + SigevNotify::SigevNone); + let err = aiocb.fsync(mode); + assert!(err.is_err()); +} + +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_aio_suspend() { + const INITIAL: &[u8] = b"abcdef123456"; + const WBUF: &[u8] = b"CDEFG"; + let timeout = TimeSpec::seconds(10); + let mut rbuf = vec![0; 4]; + let rlen = rbuf.len(); + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + + let mut wcb = AioCb::from_slice( f.as_raw_fd(), + 2, //offset + WBUF, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_WRITE); + + let mut rcb = AioCb::from_mut_slice( f.as_raw_fd(), + 8, //offset + &mut rbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_READ); + wcb.write().unwrap(); + rcb.read().unwrap(); + loop { + { + let cbbuf = [&wcb, &rcb]; + assert!(aio_suspend(&cbbuf[..], Some(timeout)).is_ok()); + } + if rcb.error() != Err(Error::from(Errno::EINPROGRESS)) && + wcb.error() != Err(Error::from(Errno::EINPROGRESS)) { + break + } + } + + assert!(wcb.aio_return().unwrap() as usize == WBUF.len()); + assert!(rcb.aio_return().unwrap() as usize == rlen); +} + +// Test a simple aio operation with no completion notification. We must poll +// for completion +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_read() { + const INITIAL: &[u8] = b"abcdef123456"; + let mut rbuf = vec![0; 4]; + const EXPECT: &[u8] = b"cdef"; + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + { + let mut aiocb = AioCb::from_mut_slice( f.as_raw_fd(), + 2, //offset + &mut rbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + aiocb.read().unwrap(); + + let err = poll_aio(&mut aiocb); + assert!(err == Ok(())); + assert!(aiocb.aio_return().unwrap() as usize == EXPECT.len()); + } + + assert!(EXPECT == rbuf.deref().deref()); +} + +/// `AioCb::read` should not modify the `AioCb` object if `libc::aio_read` +/// returns an error +// Skip on Linux, because Linux's AIO implementation can't detect errors +// synchronously +#[test] +#[cfg(any(target_os = "freebsd", target_os = "macos"))] +fn test_read_error() { + const INITIAL: &[u8] = b"abcdef123456"; + let mut rbuf = vec![0; 4]; + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + let mut aiocb = AioCb::from_mut_slice( f.as_raw_fd(), + -1, //an invalid offset + &mut rbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + assert!(aiocb.read().is_err()); +} + +// Tests from_mut_slice +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_read_into_mut_slice() { + const INITIAL: &[u8] = b"abcdef123456"; + let mut rbuf = vec![0; 4]; + const EXPECT: &[u8] = b"cdef"; + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + { + let mut aiocb = AioCb::from_mut_slice( f.as_raw_fd(), + 2, //offset + &mut rbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + aiocb.read().unwrap(); + + let err = poll_aio(&mut aiocb); + assert!(err == Ok(())); + assert!(aiocb.aio_return().unwrap() as usize == EXPECT.len()); + } + + assert!(rbuf == EXPECT); +} + +// Tests from_ptr +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_read_into_pointer() { + const INITIAL: &[u8] = b"abcdef123456"; + let mut rbuf = vec![0; 4]; + const EXPECT: &[u8] = b"cdef"; + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + { + // Safety: ok because rbuf lives until after poll_aio + let mut aiocb = unsafe { + AioCb::from_mut_ptr( f.as_raw_fd(), + 2, //offset + rbuf.as_mut_ptr() as *mut c_void, + rbuf.len(), + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP) + }; + aiocb.read().unwrap(); + + let err = poll_aio(&mut aiocb); + assert!(err == Ok(())); + assert!(aiocb.aio_return().unwrap() as usize == EXPECT.len()); + } + + assert!(rbuf == EXPECT); +} + +// Test reading into an immutable buffer. It should fail +// FIXME: This test fails to panic on Linux/musl +#[test] +#[should_panic(expected = "Can't read into an immutable buffer")] +#[cfg_attr(target_env = "musl", ignore)] +fn test_read_immutable_buffer() { + let rbuf: &[u8] = b"CDEF"; + let f = tempfile().unwrap(); + let mut aiocb = AioCb::from_slice( f.as_raw_fd(), + 2, //offset + rbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + aiocb.read().unwrap(); +} + + +// Test a simple aio operation with no completion notification. We must poll +// for completion. Unlike test_aio_read, this test uses AioCb::from_slice +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_write() { + const INITIAL: &[u8] = b"abcdef123456"; + let wbuf = "CDEF".to_string().into_bytes(); + let mut rbuf = Vec::new(); + const EXPECT: &[u8] = b"abCDEF123456"; + + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + let mut aiocb = AioCb::from_slice( f.as_raw_fd(), + 2, //offset + &wbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + aiocb.write().unwrap(); + + let err = poll_aio(&mut aiocb); + assert!(err == Ok(())); + assert!(aiocb.aio_return().unwrap() as usize == wbuf.len()); + + f.seek(SeekFrom::Start(0)).unwrap(); + let len = f.read_to_end(&mut rbuf).unwrap(); + assert!(len == EXPECT.len()); + assert!(rbuf == EXPECT); +} + +// Tests `AioCb::from_boxed_slice` with `Bytes` +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_write_bytes() { + const INITIAL: &[u8] = b"abcdef123456"; + let wbuf = Box::new(Bytes::from(&b"CDEF"[..])); + let mut rbuf = Vec::new(); + const EXPECT: &[u8] = b"abCDEF123456"; + let expected_len = wbuf.len(); + + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + let mut aiocb = AioCb::from_boxed_slice( f.as_raw_fd(), + 2, //offset + wbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + aiocb.write().unwrap(); + + let err = poll_aio(&mut aiocb); + assert!(err == Ok(())); + assert!(aiocb.aio_return().unwrap() as usize == expected_len); + + f.seek(SeekFrom::Start(0)).unwrap(); + let len = f.read_to_end(&mut rbuf).unwrap(); + assert!(len == EXPECT.len()); + assert!(rbuf == EXPECT); +} + +// Tests `AioCb::from_boxed_mut_slice` with `BytesMut` +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_read_bytes_mut_small() { + const INITIAL: &[u8] = b"abcdef"; + let rbuf = Box::new(BytesMut::from(vec![0; 4])); + const EXPECT: &[u8] = b"cdef"; + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + + let mut aiocb = AioCb::from_boxed_mut_slice( f.as_raw_fd(), + 2, //offset + rbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + aiocb.read().unwrap(); + + let err = poll_aio(&mut aiocb); + assert_eq!(err, Ok(())); + assert_eq!(aiocb.aio_return().unwrap() as usize, EXPECT.len()); + let buffer = aiocb.boxed_mut_slice().unwrap(); + assert_eq!(buffer.borrow(), EXPECT); +} + +// Tests `AioCb::from_ptr` +#[test] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_write_from_pointer() { + const INITIAL: &[u8] = b"abcdef123456"; + let wbuf = "CDEF".to_string().into_bytes(); + let mut rbuf = Vec::new(); + const EXPECT: &[u8] = b"abCDEF123456"; + + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + // Safety: ok because aiocb outlives poll_aio + let mut aiocb = unsafe { + AioCb::from_ptr( f.as_raw_fd(), + 2, //offset + wbuf.as_ptr() as *const c_void, + wbuf.len(), + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP) + }; + aiocb.write().unwrap(); + + let err = poll_aio(&mut aiocb); + assert!(err == Ok(())); + assert!(aiocb.aio_return().unwrap() as usize == wbuf.len()); + + f.seek(SeekFrom::Start(0)).unwrap(); + let len = f.read_to_end(&mut rbuf).unwrap(); + assert!(len == EXPECT.len()); + assert!(rbuf == EXPECT); +} + +/// `AioCb::write` should not modify the `AioCb` object if `libc::aio_write` +/// returns an error +// Skip on Linux, because Linux's AIO implementation can't detect errors +// synchronously +#[test] +#[cfg(any(target_os = "freebsd", target_os = "macos"))] +fn test_write_error() { + let wbuf = "CDEF".to_string().into_bytes(); + let mut aiocb = AioCb::from_slice( 666, // An invalid file descriptor + 0, //offset + &wbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + assert!(aiocb.write().is_err()); +} + +lazy_static! { + pub static ref SIGNALED: AtomicBool = AtomicBool::new(false); +} + +extern fn sigfunc(_: c_int) { + SIGNALED.store(true, Ordering::Relaxed); +} + +// Test an aio operation with completion delivered by a signal +// FIXME: This test is ignored on mips because of failures in qemu in CI +#[test] +#[cfg_attr(any(all(target_env = "musl", target_arch = "x86_64"), target_arch = "mips", target_arch = "mips64"), ignore)] +fn test_write_sigev_signal() { + let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); + let sa = SigAction::new(SigHandler::Handler(sigfunc), + SaFlags::SA_RESETHAND, + SigSet::empty()); + SIGNALED.store(false, Ordering::Relaxed); + unsafe { sigaction(Signal::SIGUSR2, &sa) }.unwrap(); + + const INITIAL: &[u8] = b"abcdef123456"; + const WBUF: &[u8] = b"CDEF"; + let mut rbuf = Vec::new(); + const EXPECT: &[u8] = b"abCDEF123456"; + + let mut f = tempfile().unwrap(); + f.write_all(INITIAL).unwrap(); + let mut aiocb = AioCb::from_slice( f.as_raw_fd(), + 2, //offset + WBUF, + 0, //priority + SigevNotify::SigevSignal { + signal: Signal::SIGUSR2, + si_value: 0 //TODO: validate in sigfunc + }, + LioOpcode::LIO_NOP); + aiocb.write().unwrap(); + while !SIGNALED.load(Ordering::Relaxed) { + thread::sleep(time::Duration::from_millis(10)); + } + + assert!(aiocb.aio_return().unwrap() as usize == WBUF.len()); + f.seek(SeekFrom::Start(0)).unwrap(); + let len = f.read_to_end(&mut rbuf).unwrap(); + assert!(len == EXPECT.len()); + assert!(rbuf == EXPECT); +} + +// Test LioCb::listio with LIO_WAIT, so all AIO ops should be complete by the +// time listio returns. +#[test] +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_liocb_listio_wait() { + const INITIAL: &[u8] = b"abcdef123456"; + const WBUF: &[u8] = b"CDEF"; + let mut rbuf = vec![0; 4]; + let rlen = rbuf.len(); + let mut rbuf2 = Vec::new(); + const EXPECT: &[u8] = b"abCDEF123456"; + let mut f = tempfile().unwrap(); + + f.write_all(INITIAL).unwrap(); + + { + let wcb = AioCb::from_slice( f.as_raw_fd(), + 2, //offset + WBUF, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_WRITE); + + let rcb = AioCb::from_mut_slice( f.as_raw_fd(), + 8, //offset + &mut rbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_READ); + let mut liocb = LioCb::with_capacity(2); + liocb.aiocbs.push(wcb); + liocb.aiocbs.push(rcb); + let err = liocb.listio(LioMode::LIO_WAIT, SigevNotify::SigevNone); + err.expect("lio_listio"); + + assert!(liocb.aio_return(0).unwrap() as usize == WBUF.len()); + assert!(liocb.aio_return(1).unwrap() as usize == rlen); + } + assert!(rbuf.deref().deref() == b"3456"); + + f.seek(SeekFrom::Start(0)).unwrap(); + let len = f.read_to_end(&mut rbuf2).unwrap(); + assert!(len == EXPECT.len()); + assert!(rbuf2 == EXPECT); +} + +// Test LioCb::listio with LIO_NOWAIT and no SigEvent, so we must use some other +// mechanism to check for the individual AioCb's completion. +#[test] +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)] +fn test_liocb_listio_nowait() { + const INITIAL: &[u8] = b"abcdef123456"; + const WBUF: &[u8] = b"CDEF"; + let mut rbuf = vec![0; 4]; + let rlen = rbuf.len(); + let mut rbuf2 = Vec::new(); + const EXPECT: &[u8] = b"abCDEF123456"; + let mut f = tempfile().unwrap(); + + f.write_all(INITIAL).unwrap(); + + { + let wcb = AioCb::from_slice( f.as_raw_fd(), + 2, //offset + WBUF, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_WRITE); + + let rcb = AioCb::from_mut_slice( f.as_raw_fd(), + 8, //offset + &mut rbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_READ); + let mut liocb = LioCb::with_capacity(2); + liocb.aiocbs.push(wcb); + liocb.aiocbs.push(rcb); + let err = liocb.listio(LioMode::LIO_NOWAIT, SigevNotify::SigevNone); + err.expect("lio_listio"); + + poll_aio(&mut liocb.aiocbs[0]).unwrap(); + poll_aio(&mut liocb.aiocbs[1]).unwrap(); + assert!(liocb.aiocbs[0].aio_return().unwrap() as usize == WBUF.len()); + assert!(liocb.aiocbs[1].aio_return().unwrap() as usize == rlen); + } + assert!(rbuf.deref().deref() == b"3456"); + + f.seek(SeekFrom::Start(0)).unwrap(); + let len = f.read_to_end(&mut rbuf2).unwrap(); + assert!(len == EXPECT.len()); + assert!(rbuf2 == EXPECT); +} + +// Test LioCb::listio with LIO_NOWAIT and a SigEvent to indicate when all +// AioCb's are complete. +// FIXME: This test is ignored on mips/mips64 because of failures in qemu in CI. +#[test] +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +#[cfg_attr(any(target_arch = "mips", target_arch = "mips64", target_env = "musl"), ignore)] +fn test_liocb_listio_signal() { + let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); + const INITIAL: &[u8] = b"abcdef123456"; + const WBUF: &[u8] = b"CDEF"; + let mut rbuf = vec![0; 4]; + let rlen = rbuf.len(); + let mut rbuf2 = Vec::new(); + const EXPECT: &[u8] = b"abCDEF123456"; + let mut f = tempfile().unwrap(); + let sa = SigAction::new(SigHandler::Handler(sigfunc), + SaFlags::SA_RESETHAND, + SigSet::empty()); + let sigev_notify = SigevNotify::SigevSignal { signal: Signal::SIGUSR2, + si_value: 0 }; + + f.write_all(INITIAL).unwrap(); + + { + let wcb = AioCb::from_slice( f.as_raw_fd(), + 2, //offset + WBUF, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_WRITE); + + let rcb = AioCb::from_mut_slice( f.as_raw_fd(), + 8, //offset + &mut rbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_READ); + let mut liocb = LioCb::with_capacity(2); + liocb.aiocbs.push(wcb); + liocb.aiocbs.push(rcb); + SIGNALED.store(false, Ordering::Relaxed); + unsafe { sigaction(Signal::SIGUSR2, &sa) }.unwrap(); + let err = liocb.listio(LioMode::LIO_NOWAIT, sigev_notify); + err.expect("lio_listio"); + while !SIGNALED.load(Ordering::Relaxed) { + thread::sleep(time::Duration::from_millis(10)); + } + + assert!(liocb.aiocbs[0].aio_return().unwrap() as usize == WBUF.len()); + assert!(liocb.aiocbs[1].aio_return().unwrap() as usize == rlen); + } + assert!(rbuf.deref().deref() == b"3456"); + + f.seek(SeekFrom::Start(0)).unwrap(); + let len = f.read_to_end(&mut rbuf2).unwrap(); + assert!(len == EXPECT.len()); + assert!(rbuf2 == EXPECT); +} + +// Try to use LioCb::listio to read into an immutable buffer. It should fail +// FIXME: This test fails to panic on Linux/musl +#[test] +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +#[should_panic(expected = "Can't read into an immutable buffer")] +#[cfg_attr(target_env = "musl", ignore)] +fn test_liocb_listio_read_immutable() { + let rbuf: &[u8] = b"abcd"; + let f = tempfile().unwrap(); + + + let mut liocb = LioCb::from(vec![ + AioCb::from_slice( f.as_raw_fd(), + 2, //offset + rbuf, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_READ) + ]); + let _ = liocb.listio(LioMode::LIO_NOWAIT, SigevNotify::SigevNone); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_aio_drop.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_aio_drop.rs new file mode 100644 index 0000000..492da40 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_aio_drop.rs @@ -0,0 +1,32 @@ +extern crate nix; +extern crate tempfile; + +// Test dropping an AioCb that hasn't yet finished. +// This must happen in its own process, because on OSX this test seems to hose +// the AIO subsystem and causes subsequent tests to fail +#[test] +#[should_panic(expected = "Dropped an in-progress AioCb")] +#[cfg(all(not(target_env = "musl"), + any(target_os = "linux", + target_os = "ios", + target_os = "macos", + target_os = "freebsd", + target_os = "netbsd")))] +fn test_drop() { + use nix::sys::aio::*; + use nix::sys::signal::*; + use std::os::unix::io::AsRawFd; + use tempfile::tempfile; + + const WBUF: &[u8] = b"CDEF"; + + let f = tempfile().unwrap(); + f.set_len(6).unwrap(); + let mut aiocb = AioCb::from_slice( f.as_raw_fd(), + 2, //offset + WBUF, + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_NOP); + aiocb.write().unwrap(); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_epoll.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_epoll.rs new file mode 100644 index 0000000..e0dc513 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_epoll.rs @@ -0,0 +1,24 @@ +use nix::sys::epoll::{EpollCreateFlags, EpollFlags, EpollOp, EpollEvent}; +use nix::sys::epoll::{epoll_create1, epoll_ctl}; +use nix::Error; +use nix::errno::Errno; + +#[test] +pub fn test_epoll_errno() { + let efd = epoll_create1(EpollCreateFlags::empty()).unwrap(); + let result = epoll_ctl(efd, EpollOp::EpollCtlDel, 1, None); + assert!(result.is_err()); + assert_eq!(result.unwrap_err(), Error::Sys(Errno::ENOENT)); + + let result = epoll_ctl(efd, EpollOp::EpollCtlAdd, 1, None); + assert!(result.is_err()); + assert_eq!(result.unwrap_err(), Error::Sys(Errno::EINVAL)); +} + +#[test] +pub fn test_epoll_ctl() { + let efd = epoll_create1(EpollCreateFlags::empty()).unwrap(); + let mut event = EpollEvent::new(EpollFlags::EPOLLIN | EpollFlags::EPOLLERR, 1); + epoll_ctl(efd, EpollOp::EpollCtlAdd, 1, &mut event).unwrap(); + epoll_ctl(efd, EpollOp::EpollCtlDel, 1, None).unwrap(); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_inotify.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_inotify.rs new file mode 100644 index 0000000..a8ead46 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_inotify.rs @@ -0,0 +1,65 @@ +use nix::sys::inotify::{AddWatchFlags,InitFlags,Inotify}; +use nix::Error; +use nix::errno::Errno; +use tempfile; +use std::ffi::OsString; +use std::fs::{rename, File}; + +#[test] +pub fn test_inotify() { + let instance = Inotify::init(InitFlags::IN_NONBLOCK) + .unwrap(); + let tempdir = tempfile::tempdir().unwrap(); + + instance.add_watch(tempdir.path(), AddWatchFlags::IN_ALL_EVENTS).unwrap(); + + let events = instance.read_events(); + assert_eq!(events.unwrap_err(), Error::Sys(Errno::EAGAIN)); + + File::create(tempdir.path().join("test")).unwrap(); + + let events = instance.read_events().unwrap(); + assert_eq!(events[0].name, Some(OsString::from("test"))); +} + +#[test] +pub fn test_inotify_multi_events() { + let instance = Inotify::init(InitFlags::IN_NONBLOCK) + .unwrap(); + let tempdir = tempfile::tempdir().unwrap(); + + instance.add_watch(tempdir.path(), AddWatchFlags::IN_ALL_EVENTS).unwrap(); + + let events = instance.read_events(); + assert_eq!(events.unwrap_err(), Error::Sys(Errno::EAGAIN)); + + File::create(tempdir.path().join("test")).unwrap(); + rename(tempdir.path().join("test"), tempdir.path().join("test2")).unwrap(); + + // Now there should be 5 events in queue: + // - IN_CREATE on test + // - IN_OPEN on test + // - IN_CLOSE_WRITE on test + // - IN_MOVED_FROM on test with a cookie + // - IN_MOVED_TO on test2 with the same cookie + + let events = instance.read_events().unwrap(); + assert_eq!(events.len(), 5); + + assert_eq!(events[0].mask, AddWatchFlags::IN_CREATE); + assert_eq!(events[0].name, Some(OsString::from("test"))); + + assert_eq!(events[1].mask, AddWatchFlags::IN_OPEN); + assert_eq!(events[1].name, Some(OsString::from("test"))); + + assert_eq!(events[2].mask, AddWatchFlags::IN_CLOSE_WRITE); + assert_eq!(events[2].name, Some(OsString::from("test"))); + + assert_eq!(events[3].mask, AddWatchFlags::IN_MOVED_FROM); + assert_eq!(events[3].name, Some(OsString::from("test"))); + + assert_eq!(events[4].mask, AddWatchFlags::IN_MOVED_TO); + assert_eq!(events[4].name, Some(OsString::from("test2"))); + + assert_eq!(events[3].cookie, events[4].cookie); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_ioctl.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_ioctl.rs new file mode 100644 index 0000000..0a439b3 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_ioctl.rs @@ -0,0 +1,334 @@ +#![allow(dead_code)] + +// Simple tests to ensure macro generated fns compile +ioctl_none_bad!(do_bad, 0x1234); +ioctl_read_bad!(do_bad_read, 0x1234, u16); +ioctl_write_int_bad!(do_bad_write_int, 0x1234); +ioctl_write_ptr_bad!(do_bad_write_ptr, 0x1234, u8); +ioctl_readwrite_bad!(do_bad_readwrite, 0x1234, u32); +ioctl_none!(do_none, 0, 0); +ioctl_read!(read_test, 0, 0, u32); +ioctl_write_int!(write_ptr_int, 0, 0); +ioctl_write_ptr!(write_ptr_u8, 0, 0, u8); +ioctl_write_ptr!(write_ptr_u32, 0, 0, u32); +ioctl_write_ptr!(write_ptr_u64, 0, 0, u64); +ioctl_readwrite!(readwrite_test, 0, 0, u64); +ioctl_read_buf!(readbuf_test, 0, 0, u32); +const SPI_IOC_MAGIC: u8 = b'k'; +const SPI_IOC_MESSAGE: u8 = 0; +ioctl_write_buf!(writebuf_test_consts, SPI_IOC_MAGIC, SPI_IOC_MESSAGE, u8); +ioctl_write_buf!(writebuf_test_u8, 0, 0, u8); +ioctl_write_buf!(writebuf_test_u32, 0, 0, u32); +ioctl_write_buf!(writebuf_test_u64, 0, 0, u64); +ioctl_readwrite_buf!(readwritebuf_test, 0, 0, u32); + +// See C code for source of values for op calculations (does NOT work for mips/powerpc): +// https://gist.github.com/posborne/83ea6880770a1aef332e +// +// TODO: Need a way to compute these constants at test time. Using precomputed +// values is fragile and needs to be maintained. + +#[cfg(any(target_os = "linux", target_os = "android"))] +mod linux { + #[test] + fn test_op_none() { + if cfg!(any(target_arch = "mips", target_arch = "mips64", target_arch="powerpc", target_arch="powerpc64")){ + assert_eq!(request_code_none!(b'q', 10), 0x2000_710A); + assert_eq!(request_code_none!(b'a', 255), 0x2000_61FF); + } else { + assert_eq!(request_code_none!(b'q', 10), 0x0000_710A); + assert_eq!(request_code_none!(b'a', 255), 0x0000_61FF); + } + } + + #[test] + fn test_op_write() { + if cfg!(any(target_arch = "mips", target_arch = "mips64", target_arch="powerpc", target_arch="powerpc64")){ + assert_eq!(request_code_write!(b'z', 10, 1), 0x8001_7A0A); + assert_eq!(request_code_write!(b'z', 10, 512), 0x8200_7A0A); + } else { + assert_eq!(request_code_write!(b'z', 10, 1), 0x4001_7A0A); + assert_eq!(request_code_write!(b'z', 10, 512), 0x4200_7A0A); + } + } + + #[cfg(target_pointer_width = "64")] + #[test] + fn test_op_write_64() { + if cfg!(any(target_arch = "mips64", target_arch="powerpc64")){ + assert_eq!(request_code_write!(b'z', 10, (1 as u64) << 32), 0x8000_7A0A); + } else { + assert_eq!(request_code_write!(b'z', 10, (1 as u64) << 32), 0x4000_7A0A); + } + + } + + #[test] + fn test_op_read() { + if cfg!(any(target_arch = "mips", target_arch = "mips64", target_arch="powerpc", target_arch="powerpc64")){ + assert_eq!(request_code_read!(b'z', 10, 1), 0x4001_7A0A); + assert_eq!(request_code_read!(b'z', 10, 512), 0x4200_7A0A); + } else { + assert_eq!(request_code_read!(b'z', 10, 1), 0x8001_7A0A); + assert_eq!(request_code_read!(b'z', 10, 512), 0x8200_7A0A); + } + } + + #[cfg(target_pointer_width = "64")] + #[test] + fn test_op_read_64() { + if cfg!(any(target_arch = "mips64", target_arch="powerpc64")){ + assert_eq!(request_code_read!(b'z', 10, (1 as u64) << 32), 0x4000_7A0A); + } else { + assert_eq!(request_code_read!(b'z', 10, (1 as u64) << 32), 0x8000_7A0A); + } + } + + #[test] + fn test_op_read_write() { + assert_eq!(request_code_readwrite!(b'z', 10, 1), 0xC001_7A0A); + assert_eq!(request_code_readwrite!(b'z', 10, 512), 0xC200_7A0A); + } + + #[cfg(target_pointer_width = "64")] + #[test] + fn test_op_read_write_64() { + assert_eq!(request_code_readwrite!(b'z', 10, (1 as u64) << 32), 0xC000_7A0A); + } +} + +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] +mod bsd { + #[test] + fn test_op_none() { + assert_eq!(request_code_none!(b'q', 10), 0x2000_710A); + assert_eq!(request_code_none!(b'a', 255), 0x2000_61FF); + } + + #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] + #[test] + fn test_op_write_int() { + assert_eq!(request_code_write_int!(b'v', 4), 0x2004_7604); + assert_eq!(request_code_write_int!(b'p', 2), 0x2004_7002); + } + + #[test] + fn test_op_write() { + assert_eq!(request_code_write!(b'z', 10, 1), 0x8001_7A0A); + assert_eq!(request_code_write!(b'z', 10, 512), 0x8200_7A0A); + } + + #[cfg(target_pointer_width = "64")] + #[test] + fn test_op_write_64() { + assert_eq!(request_code_write!(b'z', 10, (1 as u64) << 32), 0x8000_7A0A); + } + + #[test] + fn test_op_read() { + assert_eq!(request_code_read!(b'z', 10, 1), 0x4001_7A0A); + assert_eq!(request_code_read!(b'z', 10, 512), 0x4200_7A0A); + } + + #[cfg(target_pointer_width = "64")] + #[test] + fn test_op_read_64() { + assert_eq!(request_code_read!(b'z', 10, (1 as u64) << 32), 0x4000_7A0A); + } + + #[test] + fn test_op_read_write() { + assert_eq!(request_code_readwrite!(b'z', 10, 1), 0xC001_7A0A); + assert_eq!(request_code_readwrite!(b'z', 10, 512), 0xC200_7A0A); + } + + #[cfg(target_pointer_width = "64")] + #[test] + fn test_op_read_write_64() { + assert_eq!(request_code_readwrite!(b'z', 10, (1 as u64) << 32), 0xC000_7A0A); + } +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +mod linux_ioctls { + use std::mem; + use std::os::unix::io::AsRawFd; + + use tempfile::tempfile; + use libc::{TCGETS, TCSBRK, TCSETS, TIOCNXCL, termios}; + + use nix::Error::Sys; + use nix::errno::Errno::{ENOTTY, ENOSYS}; + + ioctl_none_bad!(tiocnxcl, TIOCNXCL); + #[test] + fn test_ioctl_none_bad() { + let file = tempfile().unwrap(); + let res = unsafe { tiocnxcl(file.as_raw_fd()) }; + assert_eq!(res, Err(Sys(ENOTTY))); + } + + ioctl_read_bad!(tcgets, TCGETS, termios); + #[test] + fn test_ioctl_read_bad() { + let file = tempfile().unwrap(); + let mut termios = unsafe { mem::uninitialized() }; + let res = unsafe { tcgets(file.as_raw_fd(), &mut termios) }; + assert_eq!(res, Err(Sys(ENOTTY))); + } + + ioctl_write_int_bad!(tcsbrk, TCSBRK); + #[test] + fn test_ioctl_write_int_bad() { + let file = tempfile().unwrap(); + let res = unsafe { tcsbrk(file.as_raw_fd(), 0) }; + assert_eq!(res, Err(Sys(ENOTTY))); + } + + ioctl_write_ptr_bad!(tcsets, TCSETS, termios); + #[test] + fn test_ioctl_write_ptr_bad() { + let file = tempfile().unwrap(); + let termios: termios = unsafe { mem::uninitialized() }; + let res = unsafe { tcsets(file.as_raw_fd(), &termios) }; + assert_eq!(res, Err(Sys(ENOTTY))); + } + + // FIXME: Find a suitable example for `ioctl_readwrite_bad` + + // From linux/videodev2.h + ioctl_none!(log_status, b'V', 70); + #[test] + fn test_ioctl_none() { + let file = tempfile().unwrap(); + let res = unsafe { log_status(file.as_raw_fd()) }; + assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + } + + #[repr(C)] + pub struct v4l2_audio { + index: u32, + name: [u8; 32], + capability: u32, + mode: u32, + reserved: [u32; 2], + } + + // From linux/videodev2.h + ioctl_write_ptr!(s_audio, b'V', 34, v4l2_audio); + #[test] + fn test_ioctl_write_ptr() { + let file = tempfile().unwrap(); + let data: v4l2_audio = unsafe { mem::zeroed() }; + let res = unsafe { s_audio(file.as_raw_fd(), &data) }; + assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + } + + // From linux/net/bluetooth/hci_sock.h + const HCI_IOC_MAGIC: u8 = b'H'; + const HCI_IOC_HCIDEVUP: u8 = 201; + ioctl_write_int!(hcidevup, HCI_IOC_MAGIC, HCI_IOC_HCIDEVUP); + #[test] + fn test_ioctl_write_int() { + let file = tempfile().unwrap(); + let res = unsafe { hcidevup(file.as_raw_fd(), 0) }; + assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + } + + // From linux/videodev2.h + ioctl_read!(g_audio, b'V', 33, v4l2_audio); + #[test] + fn test_ioctl_read() { + let file = tempfile().unwrap(); + let mut data: v4l2_audio = unsafe { mem::uninitialized() }; + let res = unsafe { g_audio(file.as_raw_fd(), &mut data) }; + assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + } + + // From linux/videodev2.h + ioctl_readwrite!(enum_audio, b'V', 65, v4l2_audio); + #[test] + fn test_ioctl_readwrite() { + let file = tempfile().unwrap(); + let mut data: v4l2_audio = unsafe { mem::uninitialized() }; + let res = unsafe { enum_audio(file.as_raw_fd(), &mut data) }; + assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + } + + // FIXME: Find a suitable example for `ioctl_read_buf`. + + #[repr(C)] + pub struct spi_ioc_transfer { + tx_buf: u64, + rx_buf: u64, + len: u32, + speed_hz: u32, + delay_usecs: u16, + bits_per_word: u8, + cs_change: u8, + tx_nbits: u8, + rx_nbits: u8, + pad: u16, + } + + // From linux/spi/spidev.h + ioctl_write_buf!(spi_ioc_message, super::SPI_IOC_MAGIC, super::SPI_IOC_MESSAGE, spi_ioc_transfer); + #[test] + fn test_ioctl_write_buf() { + let file = tempfile().unwrap(); + let data: [spi_ioc_transfer; 4] = unsafe { mem::zeroed() }; + let res = unsafe { spi_ioc_message(file.as_raw_fd(), &data[..]) }; + assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + } + + // FIXME: Find a suitable example for `ioctl_readwrite_buf`. +} + +#[cfg(target_os = "freebsd")] +mod freebsd_ioctls { + use std::mem; + use std::os::unix::io::AsRawFd; + + use tempfile::tempfile; + use libc::termios; + + use nix::Error::Sys; + use nix::errno::Errno::ENOTTY; + + // From sys/sys/ttycom.h + const TTY_IOC_MAGIC: u8 = b't'; + const TTY_IOC_TYPE_NXCL: u8 = 14; + const TTY_IOC_TYPE_GETA: u8 = 19; + const TTY_IOC_TYPE_SETA: u8 = 20; + + ioctl_none!(tiocnxcl, TTY_IOC_MAGIC, TTY_IOC_TYPE_NXCL); + #[test] + fn test_ioctl_none() { + let file = tempfile().unwrap(); + let res = unsafe { tiocnxcl(file.as_raw_fd()) }; + assert_eq!(res, Err(Sys(ENOTTY))); + } + + ioctl_read!(tiocgeta, TTY_IOC_MAGIC, TTY_IOC_TYPE_GETA, termios); + #[test] + fn test_ioctl_read() { + let file = tempfile().unwrap(); + let mut termios = unsafe { mem::uninitialized() }; + let res = unsafe { tiocgeta(file.as_raw_fd(), &mut termios) }; + assert_eq!(res, Err(Sys(ENOTTY))); + } + + ioctl_write_ptr!(tiocseta, TTY_IOC_MAGIC, TTY_IOC_TYPE_SETA, termios); + #[test] + fn test_ioctl_write_ptr() { + let file = tempfile().unwrap(); + let termios: termios = unsafe { mem::uninitialized() }; + let res = unsafe { tiocseta(file.as_raw_fd(), &termios) }; + assert_eq!(res, Err(Sys(ENOTTY))); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_lio_listio_resubmit.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_lio_listio_resubmit.rs new file mode 100644 index 0000000..19ee3fa --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_lio_listio_resubmit.rs @@ -0,0 +1,111 @@ +// vim: tw=80 + +// Annoyingly, Cargo is unable to conditionally build an entire test binary. So +// we must disable the test here rather than in Cargo.toml +#![cfg(target_os = "freebsd")] + +extern crate nix; +extern crate sysctl; +extern crate tempfile; + +use nix::Error; +use nix::errno::*; +use nix::libc::off_t; +use nix::sys::aio::*; +use nix::sys::signal::SigevNotify; +use nix::unistd::{SysconfVar, sysconf}; +use std::os::unix::io::AsRawFd; +use std::{thread, time}; +use sysctl::CtlValue; +use tempfile::tempfile; + +const BYTES_PER_OP: usize = 512; + +/// Attempt to collect final status for all of `liocb`'s operations, freeing +/// system resources +fn finish_liocb(liocb: &mut LioCb) { + for j in 0..liocb.aiocbs.len() { + loop { + let e = liocb.error(j); + match e { + Ok(()) => break, + Err(Error::Sys(Errno::EINPROGRESS)) => + thread::sleep(time::Duration::from_millis(10)), + Err(x) => panic!("aio_error({:?})", x) + } + } + assert_eq!(liocb.aio_return(j).unwrap(), BYTES_PER_OP as isize); + } +} + +// Deliberately exceed system resource limits, causing lio_listio to return EIO. +// This test must run in its own process since it deliberately uses all AIO +// resources. ATM it is only enabled on FreeBSD, because I don't know how to +// check system AIO limits on other operating systems. +#[test] +fn test_lio_listio_resubmit() { + let mut resubmit_count = 0; + + // Lookup system resource limits + let alm = sysconf(SysconfVar::AIO_LISTIO_MAX) + .expect("sysconf").unwrap() as usize; + let maqpp = if let CtlValue::Int(x) = sysctl::value( + "vfs.aio.max_aio_queue_per_proc").unwrap(){ + x as usize + } else { + panic!("unknown sysctl"); + }; + + // Find lio_listio sizes that satisfy the AIO_LISTIO_MAX constraint and also + // result in a final lio_listio call that can only partially be queued + let target_ops = maqpp + alm / 2; + let num_listios = (target_ops + alm - 3) / (alm - 2); + let ops_per_listio = (target_ops + num_listios - 1) / num_listios; + assert!((num_listios - 1) * ops_per_listio < maqpp, + "the last lio_listio won't make any progress; fix the algorithm"); + println!("Using {:?} LioCbs of {:?} operations apiece", num_listios, + ops_per_listio); + + let f = tempfile().unwrap(); + let buffer_set = (0..num_listios).map(|_| { + (0..ops_per_listio).map(|_| { + vec![0u8; BYTES_PER_OP] + }).collect::>() + }).collect::>(); + + let mut liocbs = (0..num_listios).map(|i| { + let mut liocb = LioCb::with_capacity(ops_per_listio); + for j in 0..ops_per_listio { + let offset = (BYTES_PER_OP * (i * ops_per_listio + j)) as off_t; + let wcb = AioCb::from_slice( f.as_raw_fd(), + offset, + &buffer_set[i][j][..], + 0, //priority + SigevNotify::SigevNone, + LioOpcode::LIO_WRITE); + liocb.aiocbs.push(wcb); + } + let mut err = liocb.listio(LioMode::LIO_NOWAIT, SigevNotify::SigevNone); + while err == Err(Error::Sys(Errno::EIO)) || + err == Err(Error::Sys(Errno::EAGAIN)) || + err == Err(Error::Sys(Errno::EINTR)) { + // + thread::sleep(time::Duration::from_millis(10)); + resubmit_count += 1; + err = liocb.listio_resubmit(LioMode::LIO_NOWAIT, + SigevNotify::SigevNone); + } + liocb + }).collect::>(); + + // Ensure that every AioCb completed + for liocb in liocbs.iter_mut() { + finish_liocb(liocb); + } + + if resubmit_count > 0 { + println!("Resubmitted {:?} times, test passed", resubmit_count); + } else { + println!("Never resubmitted. Test ambiguous"); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_pthread.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_pthread.rs new file mode 100644 index 0000000..8928010 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_pthread.rs @@ -0,0 +1,15 @@ +use nix::sys::pthread::*; + +#[cfg(target_env = "musl")] +#[test] +fn test_pthread_self() { + let tid = pthread_self(); + assert!(tid != ::std::ptr::null_mut()); +} + +#[cfg(not(target_env = "musl"))] +#[test] +fn test_pthread_self() { + let tid = pthread_self(); + assert!(tid != 0); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_ptrace.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_ptrace.rs new file mode 100644 index 0000000..24d9b52 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_ptrace.rs @@ -0,0 +1,107 @@ +use nix::Error; +use nix::errno::Errno; +use nix::unistd::getpid; +use nix::sys::ptrace; +#[cfg(any(target_os = "android", target_os = "linux"))] +use nix::sys::ptrace::Options; + +#[cfg(any(target_os = "android", target_os = "linux"))] +use std::mem; + +#[test] +fn test_ptrace() { + // Just make sure ptrace can be called at all, for now. + // FIXME: qemu-user doesn't implement ptrace on all arches, so permit ENOSYS + let err = ptrace::attach(getpid()).unwrap_err(); + assert!(err == Error::Sys(Errno::EPERM) || err == Error::Sys(Errno::EINVAL) || + err == Error::Sys(Errno::ENOSYS)); +} + +// Just make sure ptrace_setoptions can be called at all, for now. +#[test] +#[cfg(any(target_os = "android", target_os = "linux"))] +fn test_ptrace_setoptions() { + let err = ptrace::setoptions(getpid(), Options::PTRACE_O_TRACESYSGOOD).unwrap_err(); + assert!(err != Error::UnsupportedOperation); +} + +// Just make sure ptrace_getevent can be called at all, for now. +#[test] +#[cfg(any(target_os = "android", target_os = "linux"))] +fn test_ptrace_getevent() { + let err = ptrace::getevent(getpid()).unwrap_err(); + assert!(err != Error::UnsupportedOperation); +} + +// Just make sure ptrace_getsiginfo can be called at all, for now. +#[test] +#[cfg(any(target_os = "android", target_os = "linux"))] +fn test_ptrace_getsiginfo() { + if let Err(Error::UnsupportedOperation) = ptrace::getsiginfo(getpid()) { + panic!("ptrace_getsiginfo returns Error::UnsupportedOperation!"); + } +} + +// Just make sure ptrace_setsiginfo can be called at all, for now. +#[test] +#[cfg(any(target_os = "android", target_os = "linux"))] +fn test_ptrace_setsiginfo() { + let siginfo = unsafe { mem::uninitialized() }; + if let Err(Error::UnsupportedOperation) = ptrace::setsiginfo(getpid(), &siginfo) { + panic!("ptrace_setsiginfo returns Error::UnsupportedOperation!"); + } +} + + +#[test] +fn test_ptrace_cont() { + use nix::sys::ptrace; + use nix::sys::signal::{raise, Signal}; + use nix::sys::wait::{waitpid, WaitPidFlag, WaitStatus}; + use nix::unistd::fork; + use nix::unistd::ForkResult::*; + + let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + + // FIXME: qemu-user doesn't implement ptrace on all architectures + // and retunrs ENOSYS in this case. + // We (ab)use this behavior to detect the affected platforms + // and skip the test then. + // On valid platforms the ptrace call should return Errno::EPERM, this + // is already tested by `test_ptrace`. + let err = ptrace::attach(getpid()).unwrap_err(); + if err == Error::Sys(Errno::ENOSYS) { + return; + } + + match fork().expect("Error: Fork Failed") { + Child => { + ptrace::traceme().unwrap(); + // As recommended by ptrace(2), raise SIGTRAP to pause the child + // until the parent is ready to continue + loop { + raise(Signal::SIGTRAP).unwrap(); + } + + }, + Parent { child } => { + assert_eq!(waitpid(child, None), Ok(WaitStatus::Stopped(child, Signal::SIGTRAP))); + ptrace::cont(child, None).unwrap(); + assert_eq!(waitpid(child, None), Ok(WaitStatus::Stopped(child, Signal::SIGTRAP))); + ptrace::cont(child, Some(Signal::SIGKILL)).unwrap(); + match waitpid(child, None) { + Ok(WaitStatus::Signaled(pid, Signal::SIGKILL, _)) if pid == child => { + // FIXME It's been observed on some systems (apple) the + // tracee may not be killed but remain as a zombie process + // affecting other wait based tests. Add an extra kill just + // to make sure there are no zombies. + let _ = waitpid(child, Some(WaitPidFlag::WNOHANG)); + while ptrace::cont(child, Some(Signal::SIGKILL)).is_ok() { + let _ = waitpid(child, Some(WaitPidFlag::WNOHANG)); + } + } + _ => panic!("The process should have been killed"), + } + }, + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_select.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_select.rs new file mode 100644 index 0000000..cf68700 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_select.rs @@ -0,0 +1,54 @@ +use nix::sys::select::*; +use nix::unistd::{pipe, write}; +use nix::sys::signal::SigSet; +use nix::sys::time::{TimeSpec, TimeValLike}; + +#[test] +pub fn test_pselect() { + let _mtx = ::SIGNAL_MTX + .lock() + .expect("Mutex got poisoned by another test"); + + let (r1, w1) = pipe().unwrap(); + write(w1, b"hi!").unwrap(); + let (r2, _w2) = pipe().unwrap(); + + let mut fd_set = FdSet::new(); + fd_set.insert(r1); + fd_set.insert(r2); + + let timeout = TimeSpec::seconds(10); + let sigmask = SigSet::empty(); + assert_eq!( + 1, + pselect(None, &mut fd_set, None, None, &timeout, &sigmask).unwrap() + ); + assert!(fd_set.contains(r1)); + assert!(!fd_set.contains(r2)); +} + +#[test] +pub fn test_pselect_nfds2() { + let (r1, w1) = pipe().unwrap(); + write(w1, b"hi!").unwrap(); + let (r2, _w2) = pipe().unwrap(); + + let mut fd_set = FdSet::new(); + fd_set.insert(r1); + fd_set.insert(r2); + + let timeout = TimeSpec::seconds(10); + assert_eq!( + 1, + pselect( + ::std::cmp::max(r1, r2) + 1, + &mut fd_set, + None, + None, + &timeout, + None + ).unwrap() + ); + assert!(fd_set.contains(r1)); + assert!(!fd_set.contains(r2)); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_signal.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_signal.rs new file mode 100644 index 0000000..8780763 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_signal.rs @@ -0,0 +1,104 @@ +use libc; +use nix::Error; +use nix::sys::signal::*; +use nix::unistd::*; +use std::sync::atomic::{AtomicBool, Ordering}; + +#[test] +fn test_kill_none() { + kill(getpid(), None).expect("Should be able to send signal to myself."); +} + +#[test] +fn test_killpg_none() { + killpg(getpgrp(), None) + .expect("Should be able to send signal to my process group."); +} + +#[test] +fn test_old_sigaction_flags() { + extern "C" fn handler(_: ::libc::c_int) {} + let act = SigAction::new( + SigHandler::Handler(handler), + SaFlags::empty(), + SigSet::empty(), + ); + let oact = unsafe { sigaction(SIGINT, &act) }.unwrap(); + let _flags = oact.flags(); + let oact = unsafe { sigaction(SIGINT, &act) }.unwrap(); + let _flags = oact.flags(); +} + +#[test] +fn test_sigprocmask_noop() { + sigprocmask(SigmaskHow::SIG_BLOCK, None, None) + .expect("this should be an effective noop"); +} + +#[test] +fn test_sigprocmask() { + let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); + + // This needs to be a signal that rust doesn't use in the test harness. + const SIGNAL: Signal = Signal::SIGCHLD; + + let mut old_signal_set = SigSet::empty(); + sigprocmask(SigmaskHow::SIG_BLOCK, None, Some(&mut old_signal_set)) + .expect("expect to be able to retrieve old signals"); + + // Make sure the old set doesn't contain the signal, otherwise the following + // test don't make sense. + assert_eq!(old_signal_set.contains(SIGNAL), false, + "the {:?} signal is already blocked, please change to a \ + different one", SIGNAL); + + // Now block the signal. + let mut signal_set = SigSet::empty(); + signal_set.add(SIGNAL); + sigprocmask(SigmaskHow::SIG_BLOCK, Some(&signal_set), None) + .expect("expect to be able to block signals"); + + // And test it again, to make sure the change was effective. + old_signal_set.clear(); + sigprocmask(SigmaskHow::SIG_BLOCK, None, Some(&mut old_signal_set)) + .expect("expect to be able to retrieve old signals"); + assert_eq!(old_signal_set.contains(SIGNAL), true, + "expected the {:?} to be blocked", SIGNAL); + + // Reset the signal. + sigprocmask(SigmaskHow::SIG_UNBLOCK, Some(&signal_set), None) + .expect("expect to be able to block signals"); +} + +lazy_static! { + static ref SIGNALED: AtomicBool = AtomicBool::new(false); +} + +extern fn test_sigaction_handler(signal: libc::c_int) { + let signal = Signal::from_c_int(signal).unwrap(); + SIGNALED.store(signal == Signal::SIGINT, Ordering::Relaxed); +} + +extern fn test_sigaction_action(_: libc::c_int, _: *mut libc::siginfo_t, _: *mut libc::c_void) { +} + +#[test] +fn test_signal() { + let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); + + unsafe { signal(Signal::SIGINT, SigHandler::SigIgn) }.unwrap(); + raise(Signal::SIGINT).unwrap(); + assert_eq!(unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(), SigHandler::SigIgn); + + let handler = SigHandler::Handler(test_sigaction_handler); + assert_eq!(unsafe { signal(Signal::SIGINT, handler) }.unwrap(), SigHandler::SigDfl); + raise(Signal::SIGINT).unwrap(); + assert!(SIGNALED.load(Ordering::Relaxed)); + assert_eq!(unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(), handler); + + let action_handler = SigHandler::SigAction(test_sigaction_action); + assert_eq!(unsafe { signal(Signal::SIGINT, action_handler) }.unwrap_err(), Error::UnsupportedOperation); + + // Restore default signal handler + unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_signalfd.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_signalfd.rs new file mode 100644 index 0000000..a3b6098 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_signalfd.rs @@ -0,0 +1,25 @@ +#[test] +fn test_signalfd() { + use nix::sys::signalfd::SignalFd; + use nix::sys::signal::{self, raise, Signal, SigSet}; + + // Grab the mutex for altering signals so we don't interfere with other tests. + let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); + + // Block the SIGUSR1 signal from automatic processing for this thread + let mut mask = SigSet::empty(); + mask.add(signal::SIGUSR1); + mask.thread_block().unwrap(); + + let mut fd = SignalFd::new(&mask).unwrap(); + + // Send a SIGUSR1 signal to the current process. Note that this uses `raise` instead of `kill` + // because `kill` with `getpid` isn't correct during multi-threaded execution like during a + // cargo test session. Instead use `raise` which does the correct thing by default. + raise(signal::SIGUSR1).expect("Error: raise(SIGUSR1) failed"); + + // And now catch that same signal. + let res = fd.read_signal().unwrap().unwrap(); + let signo = Signal::from_c_int(res.ssi_signo as i32).unwrap(); + assert_eq!(signo, signal::SIGUSR1); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_socket.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_socket.rs new file mode 100644 index 0000000..9cbf025 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_socket.rs @@ -0,0 +1,969 @@ +use nix::sys::socket::{InetAddr, UnixAddr, getsockname}; +use std::slice; +use std::net::{self, Ipv6Addr, SocketAddr, SocketAddrV6}; +use std::path::Path; +use std::str::FromStr; +use std::os::unix::io::RawFd; +use libc::c_char; +use tempfile; + +#[test] +pub fn test_inetv4_addr_to_sock_addr() { + let actual: net::SocketAddr = FromStr::from_str("127.0.0.1:3000").unwrap(); + let addr = InetAddr::from_std(&actual); + + match addr { + InetAddr::V4(addr) => { + let ip: u32 = 0x7f00_0001; + let port: u16 = 3000; + let saddr = addr.sin_addr.s_addr; + + assert_eq!(saddr, ip.to_be()); + assert_eq!(addr.sin_port, port.to_be()); + } + _ => panic!("nope"), + } + + assert_eq!(addr.to_str(), "127.0.0.1:3000"); + + let inet = addr.to_std(); + assert_eq!(actual, inet); +} + +#[test] +pub fn test_inetv6_addr_to_sock_addr() { + let port: u16 = 3000; + let flowinfo: u32 = 1; + let scope_id: u32 = 2; + let ip: Ipv6Addr = "fe80::1".parse().unwrap(); + + let actual = SocketAddr::V6(SocketAddrV6::new(ip, port, flowinfo, scope_id)); + let addr = InetAddr::from_std(&actual); + + match addr { + InetAddr::V6(addr) => { + assert_eq!(addr.sin6_port, port.to_be()); + assert_eq!(addr.sin6_flowinfo, flowinfo); + assert_eq!(addr.sin6_scope_id, scope_id); + } + _ => panic!("nope"), + } + + assert_eq!(actual, addr.to_std()); +} + +#[test] +pub fn test_path_to_sock_addr() { + let path = "/foo/bar"; + let actual = Path::new(path); + let addr = UnixAddr::new(actual).unwrap(); + + let expect: &[c_char] = unsafe { + slice::from_raw_parts(path.as_bytes().as_ptr() as *const c_char, path.len()) + }; + assert_eq!(&addr.0.sun_path[..8], expect); + + assert_eq!(addr.path(), Some(actual)); +} + +// Test getting/setting abstract addresses (without unix socket creation) +#[cfg(target_os = "linux")] +#[test] +pub fn test_abstract_uds_addr() { + let empty = String::new(); + let addr = UnixAddr::new_abstract(empty.as_bytes()).unwrap(); + assert_eq!(addr.as_abstract(), Some(empty.as_bytes())); + + let name = String::from("nix\0abstract\0test"); + let addr = UnixAddr::new_abstract(name.as_bytes()).unwrap(); + assert_eq!(addr.as_abstract(), Some(name.as_bytes())); + assert_eq!(addr.path(), None); + + // Internally, name is null-prefixed (abstract namespace) + let internal: &[u8] = unsafe { + slice::from_raw_parts(addr.0.sun_path.as_ptr() as *const u8, addr.1) + }; + let mut abstract_name = name.clone(); + abstract_name.insert(0, '\0'); + assert_eq!(internal, abstract_name.as_bytes()); +} + +#[test] +pub fn test_getsockname() { + use nix::sys::socket::{socket, AddressFamily, SockType, SockFlag}; + use nix::sys::socket::{bind, SockAddr}; + + let tempdir = tempfile::tempdir().unwrap(); + let sockname = tempdir.path().join("sock"); + let sock = socket(AddressFamily::Unix, SockType::Stream, SockFlag::empty(), None) + .expect("socket failed"); + let sockaddr = SockAddr::new_unix(&sockname).unwrap(); + bind(sock, &sockaddr).expect("bind failed"); + assert_eq!(sockaddr.to_str(), + getsockname(sock).expect("getsockname failed").to_str()); +} + +#[test] +pub fn test_socketpair() { + use nix::unistd::{read, write}; + use nix::sys::socket::{socketpair, AddressFamily, SockType, SockFlag}; + + let (fd1, fd2) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()) + .unwrap(); + write(fd1, b"hello").unwrap(); + let mut buf = [0;5]; + read(fd2, &mut buf).unwrap(); + + assert_eq!(&buf[..], b"hello"); +} + +// Test error handling of our recvmsg wrapper +#[test] +pub fn test_recvmsg_ebadf() { + use nix::Error; + use nix::errno::Errno; + use nix::sys::socket::{MsgFlags, recvmsg}; + use nix::sys::uio::IoVec; + + let mut buf = [0u8; 5]; + let iov = [IoVec::from_mut_slice(&mut buf[..])]; + let fd = -1; // Bad file descriptor + let r = recvmsg(fd, &iov, None, MsgFlags::empty()); + assert_eq!(r.err().unwrap(), Error::Sys(Errno::EBADF)); +} + +// Disable the test on emulated platforms due to a bug in QEMU versions < +// 2.12.0. https://bugs.launchpad.net/qemu/+bug/1701808 +#[cfg_attr(not(any(target_arch = "x86_64", target_arch="i686")), ignore)] +#[test] +pub fn test_scm_rights() { + use nix::sys::uio::IoVec; + use nix::unistd::{pipe, read, write, close}; + use nix::sys::socket::{socketpair, sendmsg, recvmsg, + AddressFamily, SockType, SockFlag, + ControlMessage, ControlMessageOwned, MsgFlags}; + + let (fd1, fd2) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()) + .unwrap(); + let (r, w) = pipe().unwrap(); + let mut received_r: Option = None; + + { + let iov = [IoVec::from_slice(b"hello")]; + let fds = [r]; + let cmsg = ControlMessage::ScmRights(&fds); + assert_eq!(sendmsg(fd1, &iov, &[cmsg], MsgFlags::empty(), None).unwrap(), 5); + close(r).unwrap(); + close(fd1).unwrap(); + } + + { + let mut buf = [0u8; 5]; + let iov = [IoVec::from_mut_slice(&mut buf[..])]; + let mut cmsgspace = cmsg_space!([RawFd; 1]); + let msg = recvmsg(fd2, &iov, Some(&mut cmsgspace), MsgFlags::empty()).unwrap(); + + for cmsg in msg.cmsgs() { + if let ControlMessageOwned::ScmRights(fd) = cmsg { + assert_eq!(received_r, None); + assert_eq!(fd.len(), 1); + received_r = Some(fd[0]); + } else { + panic!("unexpected cmsg"); + } + } + assert_eq!(msg.bytes, 5); + assert!(!msg.flags.intersects(MsgFlags::MSG_TRUNC | MsgFlags::MSG_CTRUNC)); + close(fd2).unwrap(); + } + + let received_r = received_r.expect("Did not receive passed fd"); + // Ensure that the received file descriptor works + write(w, b"world").unwrap(); + let mut buf = [0u8; 5]; + read(received_r, &mut buf).unwrap(); + assert_eq!(&buf[..], b"world"); + close(received_r).unwrap(); + close(w).unwrap(); +} + +// Disable the test on emulated platforms due to not enabled support of AF_ALG in QEMU from rust cross +#[cfg_attr(not(any(target_arch = "x86_64", target_arch = "i686")), ignore)] +#[cfg(any(target_os = "linux", target_os= "android"))] +#[test] +pub fn test_af_alg_cipher() { + use libc; + use nix::sys::uio::IoVec; + use nix::unistd::read; + use nix::sys::socket::{socket, sendmsg, bind, accept, setsockopt, + AddressFamily, SockType, SockFlag, SockAddr, + ControlMessage, MsgFlags}; + use nix::sys::socket::sockopt::AlgSetKey; + + let alg_type = "skcipher"; + let alg_name = "ctr(aes)"; + // 256-bits secret key + let key = vec![0u8; 32]; + // 16-bytes IV + let iv_len = 16; + let iv = vec![1u8; iv_len]; + // 256-bytes plain payload + let payload_len = 256; + let payload = vec![2u8; payload_len]; + + let sock = socket(AddressFamily::Alg, SockType::SeqPacket, SockFlag::empty(), None) + .expect("socket failed"); + + let sockaddr = SockAddr::new_alg(alg_type, alg_name); + bind(sock, &sockaddr).expect("bind failed"); + + if let SockAddr::Alg(alg) = sockaddr { + assert_eq!(alg.alg_name().to_string_lossy(), alg_name); + assert_eq!(alg.alg_type().to_string_lossy(), alg_type); + } else { + panic!("unexpected SockAddr"); + } + + setsockopt(sock, AlgSetKey::default(), &key).expect("setsockopt"); + let session_socket = accept(sock).expect("accept failed"); + + let msgs = [ControlMessage::AlgSetOp(&libc::ALG_OP_ENCRYPT), ControlMessage::AlgSetIv(iv.as_slice())]; + let iov = IoVec::from_slice(&payload); + sendmsg(session_socket, &[iov], &msgs, MsgFlags::empty(), None).expect("sendmsg encrypt"); + + // allocate buffer for encrypted data + let mut encrypted = vec![0u8; payload_len]; + let num_bytes = read(session_socket, &mut encrypted).expect("read encrypt"); + assert_eq!(num_bytes, payload_len); + + let iov = IoVec::from_slice(&encrypted); + + let iv = vec![1u8; iv_len]; + + let msgs = [ControlMessage::AlgSetOp(&libc::ALG_OP_DECRYPT), ControlMessage::AlgSetIv(iv.as_slice())]; + sendmsg(session_socket, &[iov], &msgs, MsgFlags::empty(), None).expect("sendmsg decrypt"); + + // allocate buffer for decrypted data + let mut decrypted = vec![0u8; payload_len]; + let num_bytes = read(session_socket, &mut decrypted).expect("read decrypt"); + + assert_eq!(num_bytes, payload_len); + assert_eq!(decrypted, payload); +} + +// Disable the test on emulated platforms due to not enabled support of AF_ALG in QEMU from rust cross +#[cfg_attr(not(any(target_arch = "x86_64", target_arch = "i686")), ignore)] +#[cfg(any(target_os = "linux", target_os= "android"))] +#[test] +pub fn test_af_alg_aead() { + use libc; + use nix::sys::uio::IoVec; + use nix::unistd::{read, close}; + use nix::sys::socket::{socket, sendmsg, bind, accept, setsockopt, + AddressFamily, SockType, SockFlag, SockAddr, + ControlMessage, MsgFlags}; + use nix::sys::socket::sockopt::{AlgSetKey, AlgSetAeadAuthSize}; + + let auth_size = 4usize; + let assoc_size = 16u32; + + let alg_type = "aead"; + let alg_name = "gcm(aes)"; + // 256-bits secret key + let key = vec![0u8; 32]; + // 12-bytes IV + let iv_len = 12; + let iv = vec![1u8; iv_len]; + // 256-bytes plain payload + let payload_len = 256; + let mut payload = vec![2u8; payload_len + (assoc_size as usize) + auth_size]; + + for i in 0..assoc_size { + payload[i as usize] = 10; + } + + let len = payload.len(); + + for i in 0..auth_size { + payload[len - 1 - i] = 0; + } + + let sock = socket(AddressFamily::Alg, SockType::SeqPacket, SockFlag::empty(), None) + .expect("socket failed"); + + let sockaddr = SockAddr::new_alg(alg_type, alg_name); + bind(sock, &sockaddr).expect("bind failed"); + + setsockopt(sock, AlgSetAeadAuthSize, &auth_size).expect("setsockopt AlgSetAeadAuthSize"); + setsockopt(sock, AlgSetKey::default(), &key).expect("setsockopt AlgSetKey"); + let session_socket = accept(sock).expect("accept failed"); + + let msgs = [ + ControlMessage::AlgSetOp(&libc::ALG_OP_ENCRYPT), + ControlMessage::AlgSetIv(iv.as_slice()), + ControlMessage::AlgSetAeadAssoclen(&assoc_size)]; + let iov = IoVec::from_slice(&payload); + sendmsg(session_socket, &[iov], &msgs, MsgFlags::empty(), None).expect("sendmsg encrypt"); + + // allocate buffer for encrypted data + let mut encrypted = vec![0u8; (assoc_size as usize) + payload_len + auth_size]; + let num_bytes = read(session_socket, &mut encrypted).expect("read encrypt"); + assert_eq!(num_bytes, payload_len + auth_size + (assoc_size as usize)); + close(session_socket).expect("close"); + + for i in 0..assoc_size { + encrypted[i as usize] = 10; + } + + let iov = IoVec::from_slice(&encrypted); + + let iv = vec![1u8; iv_len]; + + let session_socket = accept(sock).expect("accept failed"); + + let msgs = [ + ControlMessage::AlgSetOp(&libc::ALG_OP_DECRYPT), + ControlMessage::AlgSetIv(iv.as_slice()), + ControlMessage::AlgSetAeadAssoclen(&assoc_size), + ]; + sendmsg(session_socket, &[iov], &msgs, MsgFlags::empty(), None).expect("sendmsg decrypt"); + + // allocate buffer for decrypted data + let mut decrypted = vec![0u8; payload_len + (assoc_size as usize) + auth_size]; + let num_bytes = read(session_socket, &mut decrypted).expect("read decrypt"); + + assert!(num_bytes >= payload_len + (assoc_size as usize)); + assert_eq!(decrypted[(assoc_size as usize)..(payload_len + (assoc_size as usize))], payload[(assoc_size as usize)..payload_len + (assoc_size as usize)]); +} + +/// Tests that passing multiple fds using a single `ControlMessage` works. +// Disable the test on emulated platforms due to a bug in QEMU versions < +// 2.12.0. https://bugs.launchpad.net/qemu/+bug/1701808 +#[cfg_attr(not(any(target_arch = "x86_64", target_arch="i686")), ignore)] +#[test] +fn test_scm_rights_single_cmsg_multiple_fds() { + use std::os::unix::net::UnixDatagram; + use std::os::unix::io::{RawFd, AsRawFd}; + use std::thread; + use nix::sys::socket::{ControlMessage, ControlMessageOwned, MsgFlags, + sendmsg, recvmsg}; + use nix::sys::uio::IoVec; + use libc; + + let (send, receive) = UnixDatagram::pair().unwrap(); + let thread = thread::spawn(move || { + let mut buf = [0u8; 8]; + let iovec = [IoVec::from_mut_slice(&mut buf)]; + let mut space = cmsg_space!([RawFd; 2]); + let msg = recvmsg( + receive.as_raw_fd(), + &iovec, + Some(&mut space), + MsgFlags::empty() + ).unwrap(); + assert!(!msg.flags.intersects(MsgFlags::MSG_TRUNC | MsgFlags::MSG_CTRUNC)); + + let mut cmsgs = msg.cmsgs(); + match cmsgs.next() { + Some(ControlMessageOwned::ScmRights(fds)) => { + assert_eq!(fds.len(), 2, + "unexpected fd count (expected 2 fds, got {})", + fds.len()); + }, + _ => panic!(), + } + assert!(cmsgs.next().is_none(), "unexpected control msg"); + + assert_eq!(msg.bytes, 8); + assert_eq!(iovec[0].as_slice(), [1u8, 2, 3, 4, 5, 6, 7, 8]); + }); + + let slice = [1u8, 2, 3, 4, 5, 6, 7, 8]; + let iov = [IoVec::from_slice(&slice)]; + let fds = [libc::STDIN_FILENO, libc::STDOUT_FILENO]; // pass stdin and stdout + let cmsg = [ControlMessage::ScmRights(&fds)]; + sendmsg(send.as_raw_fd(), &iov, &cmsg, MsgFlags::empty(), None).unwrap(); + thread.join().unwrap(); +} + +// Verify `sendmsg` builds a valid `msghdr` when passing an empty +// `cmsgs` argument. This should result in a msghdr with a nullptr +// msg_control field and a msg_controllen of 0 when calling into the +// raw `sendmsg`. +#[test] +pub fn test_sendmsg_empty_cmsgs() { + use nix::sys::uio::IoVec; + use nix::unistd::close; + use nix::sys::socket::{socketpair, sendmsg, recvmsg, + AddressFamily, SockType, SockFlag, MsgFlags}; + + let (fd1, fd2) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()) + .unwrap(); + + { + let iov = [IoVec::from_slice(b"hello")]; + assert_eq!(sendmsg(fd1, &iov, &[], MsgFlags::empty(), None).unwrap(), 5); + close(fd1).unwrap(); + } + + { + let mut buf = [0u8; 5]; + let iov = [IoVec::from_mut_slice(&mut buf[..])]; + let mut cmsgspace = cmsg_space!([RawFd; 1]); + let msg = recvmsg(fd2, &iov, Some(&mut cmsgspace), MsgFlags::empty()).unwrap(); + + for _ in msg.cmsgs() { + panic!("unexpected cmsg"); + } + assert!(!msg.flags.intersects(MsgFlags::MSG_TRUNC | MsgFlags::MSG_CTRUNC)); + assert_eq!(msg.bytes, 5); + close(fd2).unwrap(); + } +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +#[test] +fn test_scm_credentials() { + use libc; + use nix::sys::uio::IoVec; + use nix::unistd::{close, getpid, getuid, getgid}; + use nix::sys::socket::{socketpair, sendmsg, recvmsg, setsockopt, + AddressFamily, SockType, SockFlag, + ControlMessage, ControlMessageOwned, MsgFlags}; + use nix::sys::socket::sockopt::PassCred; + + let (send, recv) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()) + .unwrap(); + setsockopt(recv, PassCred, &true).unwrap(); + + { + let iov = [IoVec::from_slice(b"hello")]; + let cred = libc::ucred { + pid: getpid().as_raw(), + uid: getuid().as_raw(), + gid: getgid().as_raw(), + }; + let cmsg = ControlMessage::ScmCredentials(&cred); + assert_eq!(sendmsg(send, &iov, &[cmsg], MsgFlags::empty(), None).unwrap(), 5); + close(send).unwrap(); + } + + { + let mut buf = [0u8; 5]; + let iov = [IoVec::from_mut_slice(&mut buf[..])]; + let mut cmsgspace = cmsg_space!(libc::ucred); + let msg = recvmsg(recv, &iov, Some(&mut cmsgspace), MsgFlags::empty()).unwrap(); + let mut received_cred = None; + + for cmsg in msg.cmsgs() { + if let ControlMessageOwned::ScmCredentials(cred) = cmsg { + assert!(received_cred.is_none()); + assert_eq!(cred.pid, getpid().as_raw()); + assert_eq!(cred.uid, getuid().as_raw()); + assert_eq!(cred.gid, getgid().as_raw()); + received_cred = Some(cred); + } else { + panic!("unexpected cmsg"); + } + } + received_cred.expect("no creds received"); + assert_eq!(msg.bytes, 5); + assert!(!msg.flags.intersects(MsgFlags::MSG_TRUNC | MsgFlags::MSG_CTRUNC)); + close(recv).unwrap(); + } +} + +/// Ensure that we can send `SCM_CREDENTIALS` and `SCM_RIGHTS` with a single +/// `sendmsg` call. +#[cfg(any(target_os = "android", target_os = "linux"))] +// qemu's handling of multiple cmsgs is bugged, ignore tests on non-x86 +// see https://bugs.launchpad.net/qemu/+bug/1781280 +#[cfg_attr(not(any(target_arch = "x86_64", target_arch = "x86")), ignore)] +#[test] +fn test_scm_credentials_and_rights() { + use libc; + + let space = cmsg_space!(libc::ucred, RawFd); + test_impl_scm_credentials_and_rights(space); +} + +/// Ensure that passing a an oversized control message buffer to recvmsg +/// still works. +#[cfg(any(target_os = "android", target_os = "linux"))] +// qemu's handling of multiple cmsgs is bugged, ignore tests on non-x86 +// see https://bugs.launchpad.net/qemu/+bug/1781280 +#[cfg_attr(not(any(target_arch = "x86_64", target_arch = "x86")), ignore)] +#[test] +fn test_too_large_cmsgspace() { + let space = vec![0u8; 1024]; + test_impl_scm_credentials_and_rights(space); +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +fn test_impl_scm_credentials_and_rights(mut space: Vec) { + use libc; + use nix::sys::uio::IoVec; + use nix::unistd::{pipe, read, write, close, getpid, getuid, getgid}; + use nix::sys::socket::{socketpair, sendmsg, recvmsg, setsockopt, + AddressFamily, SockType, SockFlag, + ControlMessage, ControlMessageOwned, MsgFlags}; + use nix::sys::socket::sockopt::PassCred; + + let (send, recv) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()) + .unwrap(); + setsockopt(recv, PassCred, &true).unwrap(); + + let (r, w) = pipe().unwrap(); + let mut received_r: Option = None; + + { + let iov = [IoVec::from_slice(b"hello")]; + let cred = libc::ucred { + pid: getpid().as_raw(), + uid: getuid().as_raw(), + gid: getgid().as_raw(), + }; + let fds = [r]; + let cmsgs = [ + ControlMessage::ScmCredentials(&cred), + ControlMessage::ScmRights(&fds), + ]; + assert_eq!(sendmsg(send, &iov, &cmsgs, MsgFlags::empty(), None).unwrap(), 5); + close(r).unwrap(); + close(send).unwrap(); + } + + { + let mut buf = [0u8; 5]; + let iov = [IoVec::from_mut_slice(&mut buf[..])]; + let msg = recvmsg(recv, &iov, Some(&mut space), MsgFlags::empty()).unwrap(); + let mut received_cred = None; + + assert_eq!(msg.cmsgs().count(), 2, "expected 2 cmsgs"); + + for cmsg in msg.cmsgs() { + match cmsg { + ControlMessageOwned::ScmRights(fds) => { + assert_eq!(received_r, None, "already received fd"); + assert_eq!(fds.len(), 1); + received_r = Some(fds[0]); + } + ControlMessageOwned::ScmCredentials(cred) => { + assert!(received_cred.is_none()); + assert_eq!(cred.pid, getpid().as_raw()); + assert_eq!(cred.uid, getuid().as_raw()); + assert_eq!(cred.gid, getgid().as_raw()); + received_cred = Some(cred); + } + _ => panic!("unexpected cmsg"), + } + } + received_cred.expect("no creds received"); + assert_eq!(msg.bytes, 5); + assert!(!msg.flags.intersects(MsgFlags::MSG_TRUNC | MsgFlags::MSG_CTRUNC)); + close(recv).unwrap(); + } + + let received_r = received_r.expect("Did not receive passed fd"); + // Ensure that the received file descriptor works + write(w, b"world").unwrap(); + let mut buf = [0u8; 5]; + read(received_r, &mut buf).unwrap(); + assert_eq!(&buf[..], b"world"); + close(received_r).unwrap(); + close(w).unwrap(); +} + +// Test creating and using named unix domain sockets +#[test] +pub fn test_unixdomain() { + use nix::sys::socket::{AddressFamily, SockType, SockFlag}; + use nix::sys::socket::{bind, socket, connect, listen, accept, SockAddr}; + use nix::unistd::{read, write, close}; + use std::thread; + + let tempdir = tempfile::tempdir().unwrap(); + let sockname = tempdir.path().join("sock"); + let s1 = socket(AddressFamily::Unix, SockType::Stream, + SockFlag::empty(), None).expect("socket failed"); + let sockaddr = SockAddr::new_unix(&sockname).unwrap(); + bind(s1, &sockaddr).expect("bind failed"); + listen(s1, 10).expect("listen failed"); + + let thr = thread::spawn(move || { + let s2 = socket(AddressFamily::Unix, SockType::Stream, SockFlag::empty(), None) + .expect("socket failed"); + connect(s2, &sockaddr).expect("connect failed"); + write(s2, b"hello").expect("write failed"); + close(s2).unwrap(); + }); + + let s3 = accept(s1).expect("accept failed"); + + let mut buf = [0;5]; + read(s3, &mut buf).unwrap(); + close(s3).unwrap(); + close(s1).unwrap(); + thr.join().unwrap(); + + assert_eq!(&buf[..], b"hello"); +} + +// Test creating and using named system control sockets +#[cfg(any(target_os = "macos", target_os = "ios"))] +#[test] +pub fn test_syscontrol() { + use nix::Error; + use nix::errno::Errno; + use nix::sys::socket::{AddressFamily, socket, SockAddr, SockType, SockFlag, SockProtocol}; + + let fd = socket(AddressFamily::System, SockType::Datagram, + SockFlag::empty(), SockProtocol::KextControl) + .expect("socket failed"); + let _sockaddr = SockAddr::new_sys_control(fd, "com.apple.net.utun_control", 0).expect("resolving sys_control name failed"); + assert_eq!(SockAddr::new_sys_control(fd, "foo.bar.lol", 0).err(), Some(Error::Sys(Errno::ENOENT))); + + // requires root privileges + // connect(fd, &sockaddr).expect("connect failed"); +} + +use nix::ifaddrs::InterfaceAddress; +use nix::sys::socket::AddressFamily; +#[cfg(any( + target_os = "android", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", +))] +fn loopback_address(family: AddressFamily) -> Option { + use std::io; + use std::io::Write; + use nix::ifaddrs::getifaddrs; + use nix::sys::socket::SockAddr; + use nix::net::if_::*; + + let addrs = match getifaddrs() { + Ok(iter) => iter, + Err(e) => { + let stdioerr = io::stderr(); + let mut handle = stdioerr.lock(); + writeln!(handle, "getifaddrs: {:?}", e).unwrap(); + return None; + }, + }; + // return first address matching family + for ifaddr in addrs { + if ifaddr.flags.contains(InterfaceFlags::IFF_LOOPBACK) { + match ifaddr.address { + Some(SockAddr::Inet(InetAddr::V4(..))) => { + match family { + AddressFamily::Inet => return Some(ifaddr), + _ => continue + } + }, + Some(SockAddr::Inet(InetAddr::V6(..))) => { + match family { + AddressFamily::Inet6 => return Some(ifaddr), + _ => continue + } + }, + _ => continue, + } + } + } + None +} + +#[cfg(any( + target_os = "android", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", +))] +// qemu doesn't seem to be emulating this correctly in these architectures +#[cfg_attr(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "powerpc64", +), ignore)] +#[test] +pub fn test_recv_ipv4pktinfo() { + use libc; + use nix::sys::socket::sockopt::Ipv4PacketInfo; + use nix::sys::socket::{bind, SockFlag, SockType}; + use nix::sys::socket::{getsockname, setsockopt, socket}; + use nix::sys::socket::{recvmsg, sendmsg, ControlMessageOwned, MsgFlags}; + use nix::sys::uio::IoVec; + use nix::net::if_::*; + + let lo_ifaddr = loopback_address(AddressFamily::Inet); + let (lo_name, lo) = match lo_ifaddr { + Some(ifaddr) => (ifaddr.interface_name, + ifaddr.address.expect("Expect IPv4 address on interface")), + None => return, + }; + let receive = socket( + AddressFamily::Inet, + SockType::Datagram, + SockFlag::empty(), + None, + ).expect("receive socket failed"); + bind(receive, &lo).expect("bind failed"); + let sa = getsockname(receive).expect("getsockname failed"); + setsockopt(receive, Ipv4PacketInfo, &true).expect("setsockopt failed"); + + { + let slice = [1u8, 2, 3, 4, 5, 6, 7, 8]; + let iov = [IoVec::from_slice(&slice)]; + + let send = socket( + AddressFamily::Inet, + SockType::Datagram, + SockFlag::empty(), + None, + ).expect("send socket failed"); + sendmsg(send, &iov, &[], MsgFlags::empty(), Some(&sa)).expect("sendmsg failed"); + } + + { + let mut buf = [0u8; 8]; + let iovec = [IoVec::from_mut_slice(&mut buf)]; + let mut space = cmsg_space!(libc::in_pktinfo); + let msg = recvmsg( + receive, + &iovec, + Some(&mut space), + MsgFlags::empty(), + ).expect("recvmsg failed"); + assert!( + !msg.flags + .intersects(MsgFlags::MSG_TRUNC | MsgFlags::MSG_CTRUNC) + ); + + let mut cmsgs = msg.cmsgs(); + match cmsgs.next() { + Some(ControlMessageOwned::Ipv4PacketInfo(pktinfo)) => { + let i = if_nametoindex(lo_name.as_bytes()).expect("if_nametoindex"); + assert_eq!( + pktinfo.ipi_ifindex as libc::c_uint, + i, + "unexpected ifindex (expected {}, got {})", + i, + pktinfo.ipi_ifindex + ); + } + _ => (), + } + assert!(cmsgs.next().is_none(), "unexpected additional control msg"); + assert_eq!(msg.bytes, 8); + assert_eq!( + iovec[0].as_slice(), + [1u8, 2, 3, 4, 5, 6, 7, 8] + ); + } +} + +#[cfg(any( + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", +))] +// qemu doesn't seem to be emulating this correctly in these architectures +#[cfg_attr(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "powerpc64", +), ignore)] +#[test] +pub fn test_recvif() { + use libc; + use nix::net::if_::*; + use nix::sys::socket::sockopt::{Ipv4RecvIf, Ipv4RecvDstAddr}; + use nix::sys::socket::{bind, SockFlag, SockType}; + use nix::sys::socket::{getsockname, setsockopt, socket, SockAddr}; + use nix::sys::socket::{recvmsg, sendmsg, ControlMessageOwned, MsgFlags}; + use nix::sys::uio::IoVec; + + let lo_ifaddr = loopback_address(AddressFamily::Inet); + let (lo_name, lo) = match lo_ifaddr { + Some(ifaddr) => (ifaddr.interface_name, + ifaddr.address.expect("Expect IPv4 address on interface")), + None => return, + }; + let receive = socket( + AddressFamily::Inet, + SockType::Datagram, + SockFlag::empty(), + None, + ).expect("receive socket failed"); + bind(receive, &lo).expect("bind failed"); + let sa = getsockname(receive).expect("getsockname failed"); + setsockopt(receive, Ipv4RecvIf, &true).expect("setsockopt IP_RECVIF failed"); + setsockopt(receive, Ipv4RecvDstAddr, &true).expect("setsockopt IP_RECVDSTADDR failed"); + + { + let slice = [1u8, 2, 3, 4, 5, 6, 7, 8]; + let iov = [IoVec::from_slice(&slice)]; + + let send = socket( + AddressFamily::Inet, + SockType::Datagram, + SockFlag::empty(), + None, + ).expect("send socket failed"); + sendmsg(send, &iov, &[], MsgFlags::empty(), Some(&sa)).expect("sendmsg failed"); + } + + { + let mut buf = [0u8; 8]; + let iovec = [IoVec::from_mut_slice(&mut buf)]; + let mut space = cmsg_space!(libc::sockaddr_dl, libc::in_addr); + let msg = recvmsg( + receive, + &iovec, + Some(&mut space), + MsgFlags::empty(), + ).expect("recvmsg failed"); + assert!( + !msg.flags + .intersects(MsgFlags::MSG_TRUNC | MsgFlags::MSG_CTRUNC) + ); + assert_eq!(msg.cmsgs().count(), 2, "expected 2 cmsgs"); + + let mut rx_recvif = false; + let mut rx_recvdstaddr = false; + for cmsg in msg.cmsgs() { + match cmsg { + ControlMessageOwned::Ipv4RecvIf(dl) => { + rx_recvif = true; + let i = if_nametoindex(lo_name.as_bytes()).expect("if_nametoindex"); + assert_eq!( + dl.sdl_index as libc::c_uint, + i, + "unexpected ifindex (expected {}, got {})", + i, + dl.sdl_index + ); + }, + ControlMessageOwned::Ipv4RecvDstAddr(addr) => { + rx_recvdstaddr = true; + if let SockAddr::Inet(InetAddr::V4(a)) = lo { + assert_eq!(a.sin_addr.s_addr, + addr.s_addr, + "unexpected destination address (expected {}, got {})", + a.sin_addr.s_addr, + addr.s_addr); + } else { + panic!("unexpected Sockaddr"); + } + }, + _ => panic!("unexpected additional control msg"), + } + } + assert_eq!(rx_recvif, true); + assert_eq!(rx_recvdstaddr, true); + assert_eq!(msg.bytes, 8); + assert_eq!( + iovec[0].as_slice(), + [1u8, 2, 3, 4, 5, 6, 7, 8] + ); + } +} + +#[cfg(any( + target_os = "android", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", +))] +// qemu doesn't seem to be emulating this correctly in these architectures +#[cfg_attr(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "powerpc64", +), ignore)] +#[test] +pub fn test_recv_ipv6pktinfo() { + use libc; + use nix::net::if_::*; + use nix::sys::socket::sockopt::Ipv6RecvPacketInfo; + use nix::sys::socket::{bind, AddressFamily, SockFlag, SockType}; + use nix::sys::socket::{getsockname, setsockopt, socket}; + use nix::sys::socket::{recvmsg, sendmsg, ControlMessageOwned, MsgFlags}; + use nix::sys::uio::IoVec; + + let lo_ifaddr = loopback_address(AddressFamily::Inet6); + let (lo_name, lo) = match lo_ifaddr { + Some(ifaddr) => (ifaddr.interface_name, + ifaddr.address.expect("Expect IPv4 address on interface")), + None => return, + }; + let receive = socket( + AddressFamily::Inet6, + SockType::Datagram, + SockFlag::empty(), + None, + ).expect("receive socket failed"); + bind(receive, &lo).expect("bind failed"); + let sa = getsockname(receive).expect("getsockname failed"); + setsockopt(receive, Ipv6RecvPacketInfo, &true).expect("setsockopt failed"); + + { + let slice = [1u8, 2, 3, 4, 5, 6, 7, 8]; + let iov = [IoVec::from_slice(&slice)]; + + let send = socket( + AddressFamily::Inet6, + SockType::Datagram, + SockFlag::empty(), + None, + ).expect("send socket failed"); + sendmsg(send, &iov, &[], MsgFlags::empty(), Some(&sa)).expect("sendmsg failed"); + } + + { + let mut buf = [0u8; 8]; + let iovec = [IoVec::from_mut_slice(&mut buf)]; + let mut space = cmsg_space!(libc::in6_pktinfo); + let msg = recvmsg( + receive, + &iovec, + Some(&mut space), + MsgFlags::empty(), + ).expect("recvmsg failed"); + assert!( + !msg.flags + .intersects(MsgFlags::MSG_TRUNC | MsgFlags::MSG_CTRUNC) + ); + + let mut cmsgs = msg.cmsgs(); + match cmsgs.next() { + Some(ControlMessageOwned::Ipv6PacketInfo(pktinfo)) => { + let i = if_nametoindex(lo_name.as_bytes()).expect("if_nametoindex"); + assert_eq!( + pktinfo.ipi6_ifindex, + i, + "unexpected ifindex (expected {}, got {})", + i, + pktinfo.ipi6_ifindex + ); + } + _ => (), + } + assert!(cmsgs.next().is_none(), "unexpected additional control msg"); + assert_eq!(msg.bytes, 8); + assert_eq!( + iovec[0].as_slice(), + [1u8, 2, 3, 4, 5, 6, 7, 8] + ); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_sockopt.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_sockopt.rs new file mode 100644 index 0000000..c4860c0 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_sockopt.rs @@ -0,0 +1,53 @@ +use rand::{thread_rng, Rng}; +use nix::sys::socket::{socket, sockopt, getsockopt, setsockopt, AddressFamily, SockType, SockFlag, SockProtocol}; + +#[cfg(target_os = "linux")] +#[test] +fn is_so_mark_functional() { + use nix::sys::socket::sockopt; + + require_capability!(CAP_NET_ADMIN); + + let s = socket(AddressFamily::Inet, SockType::Stream, SockFlag::empty(), None).unwrap(); + setsockopt(s, sockopt::Mark, &1337).unwrap(); + let mark = getsockopt(s, sockopt::Mark).unwrap(); + assert_eq!(mark, 1337); +} + +#[test] +fn test_so_buf() { + let fd = socket(AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), SockProtocol::Udp) + .unwrap(); + let bufsize: usize = thread_rng().gen_range(4096, 131_072); + setsockopt(fd, sockopt::SndBuf, &bufsize).unwrap(); + let actual = getsockopt(fd, sockopt::SndBuf).unwrap(); + assert!(actual >= bufsize); + setsockopt(fd, sockopt::RcvBuf, &bufsize).unwrap(); + let actual = getsockopt(fd, sockopt::RcvBuf).unwrap(); + assert!(actual >= bufsize); +} + +// The CI doesn't supported getsockopt and setsockopt on emulated processors. +// It's beleived that a QEMU issue, the tests run ok on a fully emulated system. +// Current CI just run the binary with QEMU but the Kernel remains the same as the host. +// So the syscall doesn't work properly unless the kernel is also emulated. +#[test] +#[cfg(all( + any(target_arch = "x86", target_arch = "x86_64"), + any(target_os = "freebsd", target_os = "linux") +))] +fn test_tcp_congestion() { + use std::ffi::OsString; + + let fd = socket(AddressFamily::Inet, SockType::Stream, SockFlag::empty(), None).unwrap(); + + let val = getsockopt(fd, sockopt::TcpCongestion).unwrap(); + setsockopt(fd, sockopt::TcpCongestion, &val).unwrap(); + + setsockopt(fd, sockopt::TcpCongestion, &OsString::from("tcp_congestion_does_not_exist")).unwrap_err(); + + assert_eq!( + getsockopt(fd, sockopt::TcpCongestion).unwrap(), + val + ); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_sysinfo.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_sysinfo.rs new file mode 100644 index 0000000..73e6586 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_sysinfo.rs @@ -0,0 +1,18 @@ +use nix::sys::sysinfo::*; + +#[test] +fn sysinfo_works() { + let info = sysinfo().unwrap(); + + let (l1, l5, l15) = info.load_average(); + assert!(l1 >= 0.0); + assert!(l5 >= 0.0); + assert!(l15 >= 0.0); + + info.uptime(); // just test Duration construction + + assert!(info.swap_free() <= info.swap_total(), + "more swap available than installed (free: {}, total: {})", + info.swap_free(), + info.swap_total()); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_termios.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_termios.rs new file mode 100644 index 0000000..a14b8ce --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_termios.rs @@ -0,0 +1,136 @@ +use std::os::unix::prelude::*; +use tempfile::tempfile; + +use nix::{Error, fcntl}; +use nix::errno::Errno; +use nix::pty::openpty; +use nix::sys::termios::{self, LocalFlags, OutputFlags, Termios, tcgetattr}; +use nix::unistd::{read, write, close}; + +/// Helper function analogous to `std::io::Write::write_all`, but for `RawFd`s +fn write_all(f: RawFd, buf: &[u8]) { + let mut len = 0; + while len < buf.len() { + len += write(f, &buf[len..]).unwrap(); + } +} + +// Test tcgetattr on a terminal +#[test] +fn test_tcgetattr_pty() { + // openpty uses ptname(3) internally + let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test"); + + let pty = openpty(None, None).expect("openpty failed"); + assert!(termios::tcgetattr(pty.master).is_ok()); + close(pty.master).expect("closing the master failed"); + close(pty.slave).expect("closing the slave failed"); +} + +// Test tcgetattr on something that isn't a terminal +#[test] +fn test_tcgetattr_enotty() { + let file = tempfile().unwrap(); + assert_eq!(termios::tcgetattr(file.as_raw_fd()).err(), + Some(Error::Sys(Errno::ENOTTY))); +} + +// Test tcgetattr on an invalid file descriptor +#[test] +fn test_tcgetattr_ebadf() { + assert_eq!(termios::tcgetattr(-1).err(), + Some(Error::Sys(Errno::EBADF))); +} + +// Test modifying output flags +#[test] +fn test_output_flags() { + // openpty uses ptname(3) internally + let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test"); + + // Open one pty to get attributes for the second one + let mut termios = { + let pty = openpty(None, None).expect("openpty failed"); + assert!(pty.master > 0); + assert!(pty.slave > 0); + let termios = tcgetattr(pty.master).expect("tcgetattr failed"); + close(pty.master).unwrap(); + close(pty.slave).unwrap(); + termios + }; + + // Make sure postprocessing '\r' isn't specified by default or this test is useless. + assert!(!termios.output_flags.contains(OutputFlags::OPOST | OutputFlags::OCRNL)); + + // Specify that '\r' characters should be transformed to '\n' + // OPOST is specified to enable post-processing + termios.output_flags.insert(OutputFlags::OPOST | OutputFlags::OCRNL); + + // Open a pty + let pty = openpty(None, &termios).unwrap(); + assert!(pty.master > 0); + assert!(pty.slave > 0); + + // Write into the master + let string = "foofoofoo\r"; + write_all(pty.master, string.as_bytes()); + + // Read from the slave verifying that the output has been properly transformed + let mut buf = [0u8; 10]; + ::read_exact(pty.slave, &mut buf); + let transformed_string = "foofoofoo\n"; + close(pty.master).unwrap(); + close(pty.slave).unwrap(); + assert_eq!(&buf, transformed_string.as_bytes()); +} + +// Test modifying local flags +#[test] +fn test_local_flags() { + // openpty uses ptname(3) internally + let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test"); + + // Open one pty to get attributes for the second one + let mut termios = { + let pty = openpty(None, None).unwrap(); + assert!(pty.master > 0); + assert!(pty.slave > 0); + let termios = tcgetattr(pty.master).unwrap(); + close(pty.master).unwrap(); + close(pty.slave).unwrap(); + termios + }; + + // Make sure echo is specified by default or this test is useless. + assert!(termios.local_flags.contains(LocalFlags::ECHO)); + + // Disable local echo + termios.local_flags.remove(LocalFlags::ECHO); + + // Open a new pty with our modified termios settings + let pty = openpty(None, &termios).unwrap(); + assert!(pty.master > 0); + assert!(pty.slave > 0); + + // Set the master is in nonblocking mode or reading will never return. + let flags = fcntl::fcntl(pty.master, fcntl::F_GETFL).unwrap(); + let new_flags = fcntl::OFlag::from_bits_truncate(flags) | fcntl::OFlag::O_NONBLOCK; + fcntl::fcntl(pty.master, fcntl::F_SETFL(new_flags)).unwrap(); + + // Write into the master + let string = "foofoofoo\r"; + write_all(pty.master, string.as_bytes()); + + // Try to read from the master, which should not have anything as echoing was disabled. + let mut buf = [0u8; 10]; + let read = read(pty.master, &mut buf).unwrap_err(); + close(pty.master).unwrap(); + close(pty.slave).unwrap(); + assert_eq!(read, Error::Sys(Errno::EAGAIN)); +} + +#[test] +fn test_cfmakeraw() { + let mut termios = unsafe { Termios::default_uninit() }; + termios::cfmakeraw(&mut termios); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_uio.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_uio.rs new file mode 100644 index 0000000..3e4fc28 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_uio.rs @@ -0,0 +1,241 @@ +use nix::sys::uio::*; +use nix::unistd::*; +use rand::{thread_rng, Rng}; +use rand::distributions::Alphanumeric; +use std::{cmp, iter}; +use std::fs::{OpenOptions}; +use std::os::unix::io::AsRawFd; + +use tempfile::{tempfile, tempdir}; + +#[test] +fn test_writev() { + let mut to_write = Vec::with_capacity(16 * 128); + for _ in 0..16 { + let s: String = thread_rng().sample_iter(&Alphanumeric).take(128).collect(); + let b = s.as_bytes(); + to_write.extend(b.iter().cloned()); + } + // Allocate and fill iovecs + let mut iovecs = Vec::new(); + let mut consumed = 0; + while consumed < to_write.len() { + let left = to_write.len() - consumed; + let slice_len = if left <= 64 { left } else { thread_rng().gen_range(64, cmp::min(256, left)) }; + let b = &to_write[consumed..consumed+slice_len]; + iovecs.push(IoVec::from_slice(b)); + consumed += slice_len; + } + let pipe_res = pipe(); + assert!(pipe_res.is_ok()); + let (reader, writer) = pipe_res.ok().unwrap(); + // FileDesc will close its filedesc (reader). + let mut read_buf: Vec = iter::repeat(0u8).take(128 * 16).collect(); + // Blocking io, should write all data. + let write_res = writev(writer, &iovecs); + // Successful write + assert!(write_res.is_ok()); + let written = write_res.ok().unwrap(); + // Check whether we written all data + assert_eq!(to_write.len(), written); + let read_res = read(reader, &mut read_buf[..]); + // Successful read + assert!(read_res.is_ok()); + let read = read_res.ok().unwrap() as usize; + // Check we have read as much as we written + assert_eq!(read, written); + // Check equality of written and read data + assert_eq!(&to_write, &read_buf); + let close_res = close(writer); + assert!(close_res.is_ok()); + let close_res = close(reader); + assert!(close_res.is_ok()); +} + +#[test] +fn test_readv() { + let s:String = thread_rng().sample_iter(&Alphanumeric).take(128).collect(); + let to_write = s.as_bytes().to_vec(); + let mut storage = Vec::new(); + let mut allocated = 0; + while allocated < to_write.len() { + let left = to_write.len() - allocated; + let vec_len = if left <= 64 { left } else { thread_rng().gen_range(64, cmp::min(256, left)) }; + let v: Vec = iter::repeat(0u8).take(vec_len).collect(); + storage.push(v); + allocated += vec_len; + } + let mut iovecs = Vec::with_capacity(storage.len()); + for v in &mut storage { + iovecs.push(IoVec::from_mut_slice(&mut v[..])); + } + let pipe_res = pipe(); + assert!(pipe_res.is_ok()); + let (reader, writer) = pipe_res.ok().unwrap(); + // Blocking io, should write all data. + let write_res = write(writer, &to_write); + // Successful write + assert!(write_res.is_ok()); + let read_res = readv(reader, &mut iovecs[..]); + assert!(read_res.is_ok()); + let read = read_res.ok().unwrap(); + // Check whether we've read all data + assert_eq!(to_write.len(), read); + // Cccumulate data from iovecs + let mut read_buf = Vec::with_capacity(to_write.len()); + for iovec in &iovecs { + read_buf.extend(iovec.as_slice().iter().cloned()); + } + // Check whether iovecs contain all written data + assert_eq!(read_buf.len(), to_write.len()); + // Check equality of written and read data + assert_eq!(&read_buf, &to_write); + let close_res = close(reader); + assert!(close_res.is_ok()); + let close_res = close(writer); + assert!(close_res.is_ok()); +} + +#[test] +fn test_pwrite() { + use std::io::Read; + + let mut file = tempfile().unwrap(); + let buf = [1u8;8]; + assert_eq!(Ok(8), pwrite(file.as_raw_fd(), &buf, 8)); + let mut file_content = Vec::new(); + file.read_to_end(&mut file_content).unwrap(); + let mut expected = vec![0u8;8]; + expected.extend(vec![1;8]); + assert_eq!(file_content, expected); +} + +#[test] +fn test_pread() { + use std::io::Write; + + let tempdir = tempdir().unwrap(); + + let path = tempdir.path().join("pread_test_file"); + let mut file = OpenOptions::new().write(true).read(true).create(true) + .truncate(true).open(path).unwrap(); + let file_content: Vec = (0..64).collect(); + file.write_all(&file_content).unwrap(); + + let mut buf = [0u8;16]; + assert_eq!(Ok(16), pread(file.as_raw_fd(), &mut buf, 16)); + let expected: Vec<_> = (16..32).collect(); + assert_eq!(&buf[..], &expected[..]); +} + +#[test] +#[cfg(target_os = "linux")] +fn test_pwritev() { + use std::io::Read; + + let to_write: Vec = (0..128).collect(); + let expected: Vec = [vec![0;100], to_write.clone()].concat(); + + let iovecs = [ + IoVec::from_slice(&to_write[0..17]), + IoVec::from_slice(&to_write[17..64]), + IoVec::from_slice(&to_write[64..128]), + ]; + + let tempdir = tempdir().unwrap(); + + // pwritev them into a temporary file + let path = tempdir.path().join("pwritev_test_file"); + let mut file = OpenOptions::new().write(true).read(true).create(true) + .truncate(true).open(path).unwrap(); + + let written = pwritev(file.as_raw_fd(), &iovecs, 100).ok().unwrap(); + assert_eq!(written, to_write.len()); + + // Read the data back and make sure it matches + let mut contents = Vec::new(); + file.read_to_end(&mut contents).unwrap(); + assert_eq!(contents, expected); +} + +#[test] +#[cfg(target_os = "linux")] +fn test_preadv() { + use std::io::Write; + + let to_write: Vec = (0..200).collect(); + let expected: Vec = (100..200).collect(); + + let tempdir = tempdir().unwrap(); + + let path = tempdir.path().join("preadv_test_file"); + + let mut file = OpenOptions::new().read(true).write(true).create(true) + .truncate(true).open(path).unwrap(); + file.write_all(&to_write).unwrap(); + + let mut buffers: Vec> = vec![ + vec![0; 24], + vec![0; 1], + vec![0; 75], + ]; + + { + // Borrow the buffers into IoVecs and preadv into them + let iovecs: Vec<_> = buffers.iter_mut().map( + |buf| IoVec::from_mut_slice(&mut buf[..])).collect(); + assert_eq!(Ok(100), preadv(file.as_raw_fd(), &iovecs, 100)); + } + + let all = buffers.concat(); + assert_eq!(all, expected); +} + +#[test] +#[cfg(target_os = "linux")] +// FIXME: qemu-user doesn't implement process_vm_readv/writev on most arches +#[cfg_attr(not(any(target_arch = "x86", target_arch = "x86_64")), ignore)] +fn test_process_vm_readv() { + use nix::unistd::ForkResult::*; + use nix::sys::signal::*; + use nix::sys::wait::*; + + let _ = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + + // Pre-allocate memory in the child, since allocation isn't safe + // post-fork (~= async-signal-safe) + let mut vector = vec![1u8, 2, 3, 4, 5]; + + let (r, w) = pipe().unwrap(); + match fork().expect("Error: Fork Failed") { + Parent { child } => { + close(w).unwrap(); + // wait for child + read(r, &mut [0u8]).unwrap(); + close(r).unwrap(); + + let ptr = vector.as_ptr() as usize; + let remote_iov = RemoteIoVec { base: ptr, len: 5 }; + let mut buf = vec![0u8; 5]; + + let ret = process_vm_readv(child, + &[IoVec::from_mut_slice(&mut buf)], + &[remote_iov]); + + kill(child, SIGTERM).unwrap(); + waitpid(child, None).unwrap(); + + assert_eq!(Ok(5), ret); + assert_eq!(20u8, buf.iter().sum()); + }, + Child => { + let _ = close(r); + for i in &mut vector { + *i += 1; + } + let _ = write(w, b"\0"); + let _ = close(w); + loop { let _ = pause(); } + }, + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/sys/test_wait.rs b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_wait.rs new file mode 100644 index 0000000..d07d82f --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/sys/test_wait.rs @@ -0,0 +1,104 @@ +use nix::Error; +use nix::unistd::*; +use nix::unistd::ForkResult::*; +use nix::sys::signal::*; +use nix::sys::wait::*; +use libc::_exit; + +#[test] +fn test_wait_signal() { + let _ = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + + // Safe: The child only calls `pause` and/or `_exit`, which are async-signal-safe. + match fork().expect("Error: Fork Failed") { + Child => { + pause(); + unsafe { _exit(123) } + }, + Parent { child } => { + kill(child, Some(SIGKILL)).expect("Error: Kill Failed"); + assert_eq!(waitpid(child, None), Ok(WaitStatus::Signaled(child, SIGKILL, false))); + }, + } +} + +#[test] +fn test_wait_exit() { + let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + + // Safe: Child only calls `_exit`, which is async-signal-safe. + match fork().expect("Error: Fork Failed") { + Child => unsafe { _exit(12); }, + Parent { child } => { + assert_eq!(waitpid(child, None), Ok(WaitStatus::Exited(child, 12))); + }, + } +} + +#[test] +fn test_waitstatus_from_raw() { + let pid = Pid::from_raw(1); + assert_eq!(WaitStatus::from_raw(pid, 0x0002), Ok(WaitStatus::Signaled(pid, Signal::SIGINT, false))); + assert_eq!(WaitStatus::from_raw(pid, 0x0200), Ok(WaitStatus::Exited(pid, 2))); + assert_eq!(WaitStatus::from_raw(pid, 0x7f7f), Err(Error::invalid_argument())); +} + +#[test] +fn test_waitstatus_pid() { + let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + + match fork().unwrap() { + Child => unsafe { _exit(0) }, + Parent { child } => { + let status = waitpid(child, None).unwrap(); + assert_eq!(status.pid(), Some(child)); + } + } +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +// FIXME: qemu-user doesn't implement ptrace on most arches +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +mod ptrace { + use nix::sys::ptrace::{self, Options, Event}; + use nix::sys::signal::*; + use nix::sys::wait::*; + use nix::unistd::*; + use nix::unistd::ForkResult::*; + use libc::_exit; + + fn ptrace_child() -> ! { + ptrace::traceme().unwrap(); + // As recommended by ptrace(2), raise SIGTRAP to pause the child + // until the parent is ready to continue + raise(SIGTRAP).unwrap(); + unsafe { _exit(0) } + } + + fn ptrace_parent(child: Pid) { + // Wait for the raised SIGTRAP + assert_eq!(waitpid(child, None), Ok(WaitStatus::Stopped(child, SIGTRAP))); + // We want to test a syscall stop and a PTRACE_EVENT stop + assert!(ptrace::setoptions(child, Options::PTRACE_O_TRACESYSGOOD | Options::PTRACE_O_TRACEEXIT).is_ok()); + + // First, stop on the next system call, which will be exit() + assert!(ptrace::syscall(child).is_ok()); + assert_eq!(waitpid(child, None), Ok(WaitStatus::PtraceSyscall(child))); + // Then get the ptrace event for the process exiting + assert!(ptrace::cont(child, None).is_ok()); + assert_eq!(waitpid(child, None), Ok(WaitStatus::PtraceEvent(child, SIGTRAP, Event::PTRACE_EVENT_EXIT as i32))); + // Finally get the normal wait() result, now that the process has exited + assert!(ptrace::cont(child, None).is_ok()); + assert_eq!(waitpid(child, None), Ok(WaitStatus::Exited(child, 0))); + } + + #[test] + fn test_wait_ptrace() { + let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + + match fork().expect("Error: Fork Failed") { + Child => ptrace_child(), + Parent { child } => ptrace_parent(child), + } + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test.rs b/third_party/cargo/vendor/nix-0.14.1/test/test.rs new file mode 100644 index 0000000..4c7e5b1 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test.rs @@ -0,0 +1,147 @@ +extern crate bytes; +#[cfg(any(target_os = "android", target_os = "linux"))] +extern crate caps; +#[macro_use] +extern crate cfg_if; +#[macro_use] +extern crate nix; +#[macro_use] +extern crate lazy_static; +extern crate libc; +extern crate rand; +#[cfg(target_os = "freebsd")] +extern crate sysctl; +extern crate tempfile; + +#[cfg(any(target_os = "android", target_os = "linux"))] +macro_rules! require_capability { + ($capname:ident) => { + use ::caps::{Capability, CapSet, has_cap}; + use ::std::io::{self, Write}; + + if !has_cap(None, CapSet::Effective, Capability::$capname).unwrap() { + let stderr = io::stderr(); + let mut handle = stderr.lock(); + writeln!(handle, "Insufficient capabilities. Skipping test.") + .unwrap(); + return; + } + } +} + +#[cfg(target_os = "freebsd")] +macro_rules! skip_if_jailed { + ($name:expr) => { + use ::sysctl::CtlValue; + + if let CtlValue::Int(1) = ::sysctl::value("security.jail.jailed") + .unwrap() + { + use ::std::io::Write; + let stderr = ::std::io::stderr(); + let mut handle = stderr.lock(); + writeln!(handle, "{} cannot run in a jail. Skipping test.", $name) + .unwrap(); + return; + } + } +} + +macro_rules! skip_if_not_root { + ($name:expr) => { + use nix::unistd::Uid; + + if !Uid::current().is_root() { + use ::std::io::Write; + let stderr = ::std::io::stderr(); + let mut handle = stderr.lock(); + writeln!(handle, "{} requires root privileges. Skipping test.", $name).unwrap(); + return; + } + }; +} + +mod sys; +mod test_dir; +mod test_fcntl; +#[cfg(any(target_os = "android", + target_os = "linux"))] +mod test_kmod; +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "fushsia", + target_os = "linux", + target_os = "netbsd"))] +mod test_mq; +mod test_net; +mod test_nix_path; +mod test_poll; +mod test_pty; +#[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "ios", + target_os = "linux", + target_os = "macos"))] +mod test_sendfile; +mod test_stat; +mod test_unistd; + +use std::os::unix::io::RawFd; +use std::path::PathBuf; +use std::sync::{Mutex, RwLock, RwLockWriteGuard}; +use nix::unistd::{chdir, getcwd, read}; + +/// Helper function analogous to `std::io::Read::read_exact`, but for `RawFD`s +fn read_exact(f: RawFd, buf: &mut [u8]) { + let mut len = 0; + while len < buf.len() { + // get_mut would be better than split_at_mut, but it requires nightly + let (_, remaining) = buf.split_at_mut(len); + len += read(f, remaining).unwrap(); + } +} + +lazy_static! { + /// Any test that changes the process's current working directory must grab + /// the RwLock exclusively. Any process that cares about the current + /// working directory must grab it shared. + pub static ref CWD_LOCK: RwLock<()> = RwLock::new(()); + /// Any test that creates child processes must grab this mutex, regardless + /// of what it does with those children. + pub static ref FORK_MTX: Mutex<()> = Mutex::new(()); + /// Any test that changes the process's supplementary groups must grab this + /// mutex + pub static ref GROUPS_MTX: Mutex<()> = Mutex::new(()); + /// Any tests that loads or unloads kernel modules must grab this mutex + pub static ref KMOD_MTX: Mutex<()> = Mutex::new(()); + /// Any test that calls ptsname(3) must grab this mutex. + pub static ref PTSNAME_MTX: Mutex<()> = Mutex::new(()); + /// Any test that alters signal handling must grab this mutex. + pub static ref SIGNAL_MTX: Mutex<()> = Mutex::new(()); +} + +/// RAII object that restores a test's original directory on drop +struct DirRestore<'a> { + d: PathBuf, + _g: RwLockWriteGuard<'a, ()> +} + +impl<'a> DirRestore<'a> { + fn new() -> Self { + let guard = ::CWD_LOCK.write() + .expect("Lock got poisoned by another test"); + DirRestore{ + _g: guard, + d: getcwd().unwrap(), + } + } +} + +impl<'a> Drop for DirRestore<'a> { + fn drop(&mut self) { + let r = chdir(&self.d); + if std::thread::panicking() { + r.unwrap(); + } + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_dir.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_dir.rs new file mode 100644 index 0000000..c42fbcd --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_dir.rs @@ -0,0 +1,46 @@ +extern crate nix; +extern crate tempfile; + +use nix::dir::{Dir, Type}; +use nix::fcntl::OFlag; +use nix::sys::stat::Mode; +use std::fs::File; +use self::tempfile::tempdir; + +#[test] +fn read() { + let tmp = tempdir().unwrap(); + File::create(&tmp.path().join("foo")).unwrap(); + ::std::os::unix::fs::symlink("foo", tmp.path().join("bar")).unwrap(); + let mut dir = Dir::open(tmp.path(), OFlag::O_DIRECTORY | OFlag::O_RDONLY | OFlag::O_CLOEXEC, + Mode::empty()).unwrap(); + let mut entries: Vec<_> = dir.iter().map(|e| e.unwrap()).collect(); + entries.sort_by(|a, b| a.file_name().cmp(b.file_name())); + let entry_names: Vec<_> = entries + .iter() + .map(|e| e.file_name().to_str().unwrap().to_owned()) + .collect(); + assert_eq!(&entry_names[..], &[".", "..", "bar", "foo"]); + + // Check file types. The system is allowed to return DT_UNKNOWN (aka None here) but if it does + // return a type, ensure it's correct. + assert!(&[Some(Type::Directory), None].contains(&entries[0].file_type())); // .: dir + assert!(&[Some(Type::Directory), None].contains(&entries[1].file_type())); // ..: dir + assert!(&[Some(Type::Symlink), None].contains(&entries[2].file_type())); // bar: symlink + assert!(&[Some(Type::File), None].contains(&entries[3].file_type())); // foo: regular file +} + +#[test] +fn rewind() { + let tmp = tempdir().unwrap(); + let mut dir = Dir::open(tmp.path(), OFlag::O_DIRECTORY | OFlag::O_RDONLY | OFlag::O_CLOEXEC, + Mode::empty()).unwrap(); + let entries1: Vec<_> = dir.iter().map(|e| e.unwrap().file_name().to_owned()).collect(); + let entries2: Vec<_> = dir.iter().map(|e| e.unwrap().file_name().to_owned()).collect(); + assert_eq!(entries1, entries2); +} + +#[test] +fn ebadf() { + assert_eq!(Dir::from_fd(-1).unwrap_err(), nix::Error::Sys(nix::errno::Errno::EBADF)); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_fcntl.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_fcntl.rs new file mode 100644 index 0000000..bcc523b --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_fcntl.rs @@ -0,0 +1,143 @@ +use nix::fcntl::{openat, open, OFlag, readlink, readlinkat}; +use nix::sys::stat::Mode; +use nix::unistd::{close, read}; +use tempfile::{self, NamedTempFile}; +use std::io::prelude::*; +use std::os::unix::fs; + +#[test] +fn test_openat() { + const CONTENTS: &[u8] = b"abcd"; + let mut tmp = NamedTempFile::new().unwrap(); + tmp.write_all(CONTENTS).unwrap(); + + let dirfd = open(tmp.path().parent().unwrap(), + OFlag::empty(), + Mode::empty()).unwrap(); + let fd = openat(dirfd, + tmp.path().file_name().unwrap(), + OFlag::O_RDONLY, + Mode::empty()).unwrap(); + + let mut buf = [0u8; 1024]; + assert_eq!(4, read(fd, &mut buf).unwrap()); + assert_eq!(CONTENTS, &buf[0..4]); + + close(fd).unwrap(); + close(dirfd).unwrap(); +} + +#[test] +fn test_readlink() { + let tempdir = tempfile::tempdir().unwrap(); + let src = tempdir.path().join("a"); + let dst = tempdir.path().join("b"); + println!("a: {:?}, b: {:?}", &src, &dst); + fs::symlink(&src.as_path(), &dst.as_path()).unwrap(); + let dirfd = open(tempdir.path(), + OFlag::empty(), + Mode::empty()).unwrap(); + + let mut buf = vec![0; src.to_str().unwrap().len() + 1]; + assert_eq!(readlink(&dst, &mut buf).unwrap().to_str().unwrap(), + src.to_str().unwrap()); + assert_eq!(readlinkat(dirfd, "b", &mut buf).unwrap().to_str().unwrap(), + src.to_str().unwrap()); +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +mod linux_android { + use std::io::prelude::*; + use std::os::unix::prelude::*; + + use libc::loff_t; + + use nix::fcntl::{SpliceFFlags, FallocateFlags, fallocate, splice, tee, vmsplice}; + use nix::sys::uio::IoVec; + use nix::unistd::{close, pipe, read, write}; + + use tempfile::{tempfile, NamedTempFile}; + + #[test] + fn test_splice() { + const CONTENTS: &[u8] = b"abcdef123456"; + let mut tmp = tempfile().unwrap(); + tmp.write_all(CONTENTS).unwrap(); + + let (rd, wr) = pipe().unwrap(); + let mut offset: loff_t = 5; + let res = splice(tmp.as_raw_fd(), Some(&mut offset), + wr, None, 2, SpliceFFlags::empty()).unwrap(); + + assert_eq!(2, res); + + let mut buf = [0u8; 1024]; + assert_eq!(2, read(rd, &mut buf).unwrap()); + assert_eq!(b"f1", &buf[0..2]); + assert_eq!(7, offset); + + close(rd).unwrap(); + close(wr).unwrap(); + } + + #[test] + fn test_tee() { + let (rd1, wr1) = pipe().unwrap(); + let (rd2, wr2) = pipe().unwrap(); + + write(wr1, b"abc").unwrap(); + let res = tee(rd1, wr2, 2, SpliceFFlags::empty()).unwrap(); + + assert_eq!(2, res); + + let mut buf = [0u8; 1024]; + + // Check the tee'd bytes are at rd2. + assert_eq!(2, read(rd2, &mut buf).unwrap()); + assert_eq!(b"ab", &buf[0..2]); + + // Check all the bytes are still at rd1. + assert_eq!(3, read(rd1, &mut buf).unwrap()); + assert_eq!(b"abc", &buf[0..3]); + + close(rd1).unwrap(); + close(wr1).unwrap(); + close(rd2).unwrap(); + close(wr2).unwrap(); + } + + #[test] + fn test_vmsplice() { + let (rd, wr) = pipe().unwrap(); + + let buf1 = b"abcdef"; + let buf2 = b"defghi"; + let mut iovecs = Vec::with_capacity(2); + iovecs.push(IoVec::from_slice(&buf1[0..3])); + iovecs.push(IoVec::from_slice(&buf2[0..3])); + + let res = vmsplice(wr, &iovecs[..], SpliceFFlags::empty()).unwrap(); + + assert_eq!(6, res); + + // Check the bytes can be read at rd. + let mut buf = [0u8; 32]; + assert_eq!(6, read(rd, &mut buf).unwrap()); + assert_eq!(b"abcdef", &buf[0..6]); + + close(rd).unwrap(); + close(wr).unwrap(); + } + + #[test] + fn test_fallocate() { + let tmp = NamedTempFile::new().unwrap(); + + let fd = tmp.as_raw_fd(); + fallocate(fd, FallocateFlags::empty(), 0, 100).unwrap(); + + // Check if we read exactly 100 bytes + let mut buf = [0u8; 200]; + assert_eq!(100, read(fd, &mut buf).unwrap()); + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_kmod/hello_mod/Makefile b/third_party/cargo/vendor/nix-0.14.1/test/test_kmod/hello_mod/Makefile new file mode 100644 index 0000000..74c99b7 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_kmod/hello_mod/Makefile @@ -0,0 +1,7 @@ +obj-m += hello.o + +all: + make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules + +clean: + make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) clean diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_kmod/hello_mod/hello.c b/third_party/cargo/vendor/nix-0.14.1/test/test_kmod/hello_mod/hello.c new file mode 100644 index 0000000..1c34987 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_kmod/hello_mod/hello.c @@ -0,0 +1,26 @@ +/* + * SPDX-License-Identifier: GPL-2.0+ or MIT + */ +#include +#include + +static int number= 1; +static char *who = "World"; + +module_param(number, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); +MODULE_PARM_DESC(myint, "Just some number"); +module_param(who, charp, 0000); +MODULE_PARM_DESC(who, "Whot to greet"); + +int init_module(void) +{ + printk(KERN_INFO "Hello %s (%d)!\n", who, number); + return 0; +} + +void cleanup_module(void) +{ + printk(KERN_INFO "Goodbye %s (%d)!\n", who, number); +} + +MODULE_LICENSE("Dual MIT/GPL"); diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_kmod/mod.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_kmod/mod.rs new file mode 100644 index 0000000..ad40635 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_kmod/mod.rs @@ -0,0 +1,166 @@ +use std::fs::copy; +use std::path::PathBuf; +use std::process::Command; +use tempfile::{tempdir, TempDir}; + +fn compile_kernel_module() -> (PathBuf, String, TempDir) { + let _m = ::FORK_MTX + .lock() + .expect("Mutex got poisoned by another test"); + + let tmp_dir = tempdir().expect("unable to create temporary build directory"); + + copy( + "test/test_kmod/hello_mod/hello.c", + &tmp_dir.path().join("hello.c"), + ).expect("unable to copy hello.c to temporary build directory"); + copy( + "test/test_kmod/hello_mod/Makefile", + &tmp_dir.path().join("Makefile"), + ).expect("unable to copy Makefile to temporary build directory"); + + let status = Command::new("make") + .current_dir(tmp_dir.path()) + .status() + .expect("failed to run make"); + + assert!(status.success()); + + // Return the relative path of the build kernel module + (tmp_dir.path().join("hello.ko"), "hello".to_owned(), tmp_dir) +} + +use nix::errno::Errno; +use nix::kmod::{delete_module, DeleteModuleFlags}; +use nix::kmod::{finit_module, init_module, ModuleInitFlags}; +use nix::Error; +use std::ffi::CString; +use std::fs::File; +use std::io::Read; + +#[test] +fn test_finit_and_delete_module() { + require_capability!(CAP_SYS_MODULE); + let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test"); + let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test"); + + let (kmod_path, kmod_name, _kmod_dir) = compile_kernel_module(); + + let f = File::open(kmod_path).expect("unable to open kernel module"); + finit_module(&f, &CString::new("").unwrap(), ModuleInitFlags::empty()) + .expect("unable to load kernel module"); + + delete_module( + &CString::new(kmod_name).unwrap(), + DeleteModuleFlags::empty(), + ).expect("unable to unload kernel module"); +} + +#[test] +fn test_finit_and_delete_modul_with_params() { + require_capability!(CAP_SYS_MODULE); + let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test"); + let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test"); + + let (kmod_path, kmod_name, _kmod_dir) = compile_kernel_module(); + + let f = File::open(kmod_path).expect("unable to open kernel module"); + finit_module( + &f, + &CString::new("who=Rust number=2018").unwrap(), + ModuleInitFlags::empty(), + ).expect("unable to load kernel module"); + + delete_module( + &CString::new(kmod_name).unwrap(), + DeleteModuleFlags::empty(), + ).expect("unable to unload kernel module"); +} + +#[test] +fn test_init_and_delete_module() { + require_capability!(CAP_SYS_MODULE); + let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test"); + let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test"); + + let (kmod_path, kmod_name, _kmod_dir) = compile_kernel_module(); + + let mut f = File::open(kmod_path).expect("unable to open kernel module"); + let mut contents: Vec = Vec::new(); + f.read_to_end(&mut contents) + .expect("unable to read kernel module content to buffer"); + init_module(&mut contents, &CString::new("").unwrap()).expect("unable to load kernel module"); + + delete_module( + &CString::new(kmod_name).unwrap(), + DeleteModuleFlags::empty(), + ).expect("unable to unload kernel module"); +} + +#[test] +fn test_init_and_delete_module_with_params() { + require_capability!(CAP_SYS_MODULE); + let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test"); + let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test"); + + let (kmod_path, kmod_name, _kmod_dir) = compile_kernel_module(); + + let mut f = File::open(kmod_path).expect("unable to open kernel module"); + let mut contents: Vec = Vec::new(); + f.read_to_end(&mut contents) + .expect("unable to read kernel module content to buffer"); + init_module(&mut contents, &CString::new("who=Nix number=2015").unwrap()) + .expect("unable to load kernel module"); + + delete_module( + &CString::new(kmod_name).unwrap(), + DeleteModuleFlags::empty(), + ).expect("unable to unload kernel module"); +} + +#[test] +fn test_finit_module_invalid() { + require_capability!(CAP_SYS_MODULE); + let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test"); + let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test"); + + let kmod_path = "/dev/zero"; + + let f = File::open(kmod_path).expect("unable to open kernel module"); + let result = finit_module(&f, &CString::new("").unwrap(), ModuleInitFlags::empty()); + + assert_eq!(result.unwrap_err(), Error::Sys(Errno::EINVAL)); +} + +#[test] +fn test_finit_module_twice_and_delete_module() { + require_capability!(CAP_SYS_MODULE); + let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test"); + let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test"); + + let (kmod_path, kmod_name, _kmod_dir) = compile_kernel_module(); + + let f = File::open(kmod_path).expect("unable to open kernel module"); + finit_module(&f, &CString::new("").unwrap(), ModuleInitFlags::empty()) + .expect("unable to load kernel module"); + + let result = finit_module(&f, &CString::new("").unwrap(), ModuleInitFlags::empty()); + + assert_eq!(result.unwrap_err(), Error::Sys(Errno::EEXIST)); + + delete_module( + &CString::new(kmod_name).unwrap(), + DeleteModuleFlags::empty(), + ).expect("unable to unload kernel module"); +} + +#[test] +fn test_delete_module_not_loaded() { + require_capability!(CAP_SYS_MODULE); + let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test"); + let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test"); + + let result = delete_module(&CString::new("hello").unwrap(), DeleteModuleFlags::empty()); + + assert_eq!(result.unwrap_err(), Error::Sys(Errno::ENOENT)); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_mount.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_mount.rs new file mode 100644 index 0000000..d2e08bc --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_mount.rs @@ -0,0 +1,238 @@ +// Impelmentation note: to allow unprivileged users to run it, this test makes +// use of user and mount namespaces. On systems that allow unprivileged user +// namespaces (Linux >= 3.8 compiled with CONFIG_USER_NS), the test should run +// without root. + +extern crate libc; +extern crate nix; +extern crate tempfile; + +#[cfg(target_os = "linux")] +mod test_mount { + use std::fs::{self, File}; + use std::io::{self, Read, Write}; + use std::os::unix::fs::OpenOptionsExt; + use std::os::unix::fs::PermissionsExt; + use std::process::{self, Command}; + + use libc::{EACCES, EROFS}; + + use nix::errno::Errno; + use nix::mount::{mount, umount, MsFlags}; + use nix::sched::{unshare, CloneFlags}; + use nix::sys::stat::{self, Mode}; + use nix::unistd::getuid; + + use tempfile; + + static SCRIPT_CONTENTS: &'static [u8] = b"#!/bin/sh +exit 23"; + + const EXPECTED_STATUS: i32 = 23; + + const NONE: Option<&'static [u8]> = None; + pub fn test_mount_tmpfs_without_flags_allows_rwx() { + let tempdir = tempfile::tempdir().unwrap(); + + mount(NONE, + tempdir.path(), + Some(b"tmpfs".as_ref()), + MsFlags::empty(), + NONE) + .unwrap_or_else(|e| panic!("mount failed: {}", e)); + + let test_path = tempdir.path().join("test"); + + // Verify write. + fs::OpenOptions::new() + .create(true) + .write(true) + .mode((Mode::S_IRWXU | Mode::S_IRWXG | Mode::S_IRWXO).bits()) + .open(&test_path) + .or_else(|e| + if Errno::from_i32(e.raw_os_error().unwrap()) == Errno::EOVERFLOW { + // Skip tests on certain Linux kernels which have a bug + // regarding tmpfs in namespaces. + // Ubuntu 14.04 and 16.04 are known to be affected; 16.10 is + // not. There is no legitimate reason for open(2) to return + // EOVERFLOW here. + // https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1659087 + let stderr = io::stderr(); + let mut handle = stderr.lock(); + writeln!(handle, "Buggy Linux kernel detected. Skipping test.") + .unwrap(); + process::exit(0); + } else { + panic!("open failed: {}", e); + } + ) + .and_then(|mut f| f.write(SCRIPT_CONTENTS)) + .unwrap_or_else(|e| panic!("write failed: {}", e)); + + // Verify read. + let mut buf = Vec::new(); + File::open(&test_path) + .and_then(|mut f| f.read_to_end(&mut buf)) + .unwrap_or_else(|e| panic!("read failed: {}", e)); + assert_eq!(buf, SCRIPT_CONTENTS); + + // Verify execute. + assert_eq!(EXPECTED_STATUS, + Command::new(&test_path) + .status() + .unwrap_or_else(|e| panic!("exec failed: {}", e)) + .code() + .unwrap_or_else(|| panic!("child killed by signal"))); + + umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {}", e)); + } + + pub fn test_mount_rdonly_disallows_write() { + let tempdir = tempfile::tempdir().unwrap(); + + mount(NONE, + tempdir.path(), + Some(b"tmpfs".as_ref()), + MsFlags::MS_RDONLY, + NONE) + .unwrap_or_else(|e| panic!("mount failed: {}", e)); + + // EROFS: Read-only file system + assert_eq!(EROFS as i32, + File::create(tempdir.path().join("test")).unwrap_err().raw_os_error().unwrap()); + + umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {}", e)); + } + + pub fn test_mount_noexec_disallows_exec() { + let tempdir = tempfile::tempdir().unwrap(); + + mount(NONE, + tempdir.path(), + Some(b"tmpfs".as_ref()), + MsFlags::MS_NOEXEC, + NONE) + .unwrap_or_else(|e| panic!("mount failed: {}", e)); + + let test_path = tempdir.path().join("test"); + + fs::OpenOptions::new() + .create(true) + .write(true) + .mode((Mode::S_IRWXU | Mode::S_IRWXG | Mode::S_IRWXO).bits()) + .open(&test_path) + .and_then(|mut f| f.write(SCRIPT_CONTENTS)) + .unwrap_or_else(|e| panic!("write failed: {}", e)); + + // Verify that we cannot execute despite a+x permissions being set. + let mode = stat::Mode::from_bits_truncate(fs::metadata(&test_path) + .map(|md| md.permissions().mode()) + .unwrap_or_else(|e| { + panic!("metadata failed: {}", e) + })); + + assert!(mode.contains(Mode::S_IXUSR | Mode::S_IXGRP | Mode::S_IXOTH), + "{:?} did not have execute permissions", + &test_path); + + // EACCES: Permission denied + assert_eq!(EACCES as i32, + Command::new(&test_path).status().unwrap_err().raw_os_error().unwrap()); + + umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {}", e)); + } + + pub fn test_mount_bind() { + let tempdir = tempfile::tempdir().unwrap(); + let file_name = "test"; + + { + let mount_point = tempfile::tempdir().unwrap(); + + mount(Some(tempdir.path()), + mount_point.path(), + NONE, + MsFlags::MS_BIND, + NONE) + .unwrap_or_else(|e| panic!("mount failed: {}", e)); + + fs::OpenOptions::new() + .create(true) + .write(true) + .mode((Mode::S_IRWXU | Mode::S_IRWXG | Mode::S_IRWXO).bits()) + .open(mount_point.path().join(file_name)) + .and_then(|mut f| f.write(SCRIPT_CONTENTS)) + .unwrap_or_else(|e| panic!("write failed: {}", e)); + + umount(mount_point.path()).unwrap_or_else(|e| panic!("umount failed: {}", e)); + } + + // Verify the file written in the mount shows up in source directory, even + // after unmounting. + + let mut buf = Vec::new(); + File::open(tempdir.path().join(file_name)) + .and_then(|mut f| f.read_to_end(&mut buf)) + .unwrap_or_else(|e| panic!("read failed: {}", e)); + assert_eq!(buf, SCRIPT_CONTENTS); + } + + pub fn setup_namespaces() { + // Hold on to the uid in the parent namespace. + let uid = getuid(); + + unshare(CloneFlags::CLONE_NEWNS | CloneFlags::CLONE_NEWUSER).unwrap_or_else(|e| { + let stderr = io::stderr(); + let mut handle = stderr.lock(); + writeln!(handle, + "unshare failed: {}. Are unprivileged user namespaces available?", + e).unwrap(); + writeln!(handle, "mount is not being tested").unwrap(); + // Exit with success because not all systems support unprivileged user namespaces, and + // that's not what we're testing for. + process::exit(0); + }); + + // Map user as uid 1000. + fs::OpenOptions::new() + .write(true) + .open("/proc/self/uid_map") + .and_then(|mut f| f.write(format!("1000 {} 1\n", uid).as_bytes())) + .unwrap_or_else(|e| panic!("could not write uid map: {}", e)); + } +} + + +// Test runner + +/// Mimic normal test output (hackishly). +#[cfg(target_os = "linux")] +macro_rules! run_tests { + ( $($test_fn:ident),* ) => {{ + println!(); + + $( + print!("test test_mount::{} ... ", stringify!($test_fn)); + $test_fn(); + println!("ok"); + )* + + println!(); + }} +} + +#[cfg(target_os = "linux")] +fn main() { + use test_mount::{setup_namespaces, test_mount_tmpfs_without_flags_allows_rwx, + test_mount_rdonly_disallows_write, test_mount_noexec_disallows_exec, + test_mount_bind}; + setup_namespaces(); + + run_tests!(test_mount_tmpfs_without_flags_allows_rwx, + test_mount_rdonly_disallows_write, + test_mount_noexec_disallows_exec, + test_mount_bind); +} + +#[cfg(not(target_os = "linux"))] +fn main() {} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_mq.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_mq.rs new file mode 100644 index 0000000..41ab358 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_mq.rs @@ -0,0 +1,152 @@ +use libc::c_long; + +use std::ffi::CString; +use std::str; + +use nix::errno::Errno::*; +use nix::Error::Sys; +use nix::mqueue::{mq_open, mq_close, mq_send, mq_receive}; +use nix::mqueue::{MqAttr, MQ_OFlag}; +use nix::sys::stat::Mode; + +#[test] +fn test_mq_send_and_receive() { + const MSG_SIZE: c_long = 32; + let attr = MqAttr::new(0, 10, MSG_SIZE, 0); + let mq_name= &CString::new(b"/a_nix_test_queue".as_ref()).unwrap(); + + let oflag0 = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY; + let mode = Mode::S_IWUSR | Mode::S_IRUSR | Mode::S_IRGRP | Mode::S_IROTH; + let r0 = mq_open(mq_name, oflag0, mode, Some(&attr)); + if let Err(Sys(ENOSYS)) = r0 { + println!("message queues not supported or module not loaded?"); + return; + }; + let mqd0 = r0.unwrap(); + let msg_to_send = "msg_1"; + mq_send(mqd0, msg_to_send.as_bytes(), 1).unwrap(); + + let oflag1 = MQ_OFlag::O_CREAT | MQ_OFlag::O_RDONLY; + let mqd1 = mq_open(mq_name, oflag1, mode, Some(&attr)).unwrap(); + let mut buf = [0u8; 32]; + let mut prio = 0u32; + let len = mq_receive(mqd1, &mut buf, &mut prio).unwrap(); + assert!(prio == 1); + + mq_close(mqd1).unwrap(); + mq_close(mqd0).unwrap(); + assert_eq!(msg_to_send, str::from_utf8(&buf[0..len]).unwrap()); +} + + +#[test] +#[cfg(not(any(target_os = "netbsd")))] +fn test_mq_getattr() { + use nix::mqueue::mq_getattr; + const MSG_SIZE: c_long = 32; + let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0); + let mq_name = &CString::new(b"/attr_test_get_attr".as_ref()).unwrap(); + let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY; + let mode = Mode::S_IWUSR | Mode::S_IRUSR | Mode::S_IRGRP | Mode::S_IROTH; + let r = mq_open(mq_name, oflag, mode, Some(&initial_attr)); + if let Err(Sys(ENOSYS)) = r { + println!("message queues not supported or module not loaded?"); + return; + }; + let mqd = r.unwrap(); + + let read_attr = mq_getattr(mqd); + assert!(read_attr.unwrap() == initial_attr); + mq_close(mqd).unwrap(); +} + +// FIXME: Fix failures for mips in QEMU +#[test] +#[cfg(not(any(target_os = "netbsd")))] +#[cfg_attr(any(target_arch = "mips", target_arch = "mips64"), ignore)] +fn test_mq_setattr() { + use nix::mqueue::{mq_getattr, mq_setattr}; + const MSG_SIZE: c_long = 32; + let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0); + let mq_name = &CString::new(b"/attr_test_get_attr".as_ref()).unwrap(); + let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY; + let mode = Mode::S_IWUSR | Mode::S_IRUSR | Mode::S_IRGRP | Mode::S_IROTH; + let r = mq_open(mq_name, oflag, mode, Some(&initial_attr)); + if let Err(Sys(ENOSYS)) = r { + println!("message queues not supported or module not loaded?"); + return; + }; + let mqd = r.unwrap(); + + let new_attr = MqAttr::new(0, 20, MSG_SIZE * 2, 100); + let old_attr = mq_setattr(mqd, &new_attr); + assert!(old_attr.unwrap() == initial_attr); + + let new_attr_get = mq_getattr(mqd); + // The following tests make sense. No changes here because according to the Linux man page only + // O_NONBLOCK can be set (see tests below) + assert!(new_attr_get.unwrap() != new_attr); + + let new_attr_non_blocking = MqAttr::new(MQ_OFlag::O_NONBLOCK.bits() as c_long, 10, MSG_SIZE, 0); + mq_setattr(mqd, &new_attr_non_blocking).unwrap(); + let new_attr_get = mq_getattr(mqd); + + // now the O_NONBLOCK flag has been set + assert!(new_attr_get.unwrap() != initial_attr); + assert!(new_attr_get.unwrap() == new_attr_non_blocking); + mq_close(mqd).unwrap(); +} + +// FIXME: Fix failures for mips in QEMU +#[test] +#[cfg(not(any(target_os = "netbsd")))] +#[cfg_attr(any(target_arch = "mips", target_arch = "mips64"), ignore)] +fn test_mq_set_nonblocking() { + use nix::mqueue::{mq_getattr, mq_set_nonblock, mq_remove_nonblock}; + const MSG_SIZE: c_long = 32; + let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0); + let mq_name = &CString::new(b"/attr_test_get_attr".as_ref()).unwrap(); + let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY; + let mode = Mode::S_IWUSR | Mode::S_IRUSR | Mode::S_IRGRP | Mode::S_IROTH; + let r = mq_open(mq_name, oflag, mode, Some(&initial_attr)); + if let Err(Sys(ENOSYS)) = r { + println!("message queues not supported or module not loaded?"); + return; + }; + let mqd = r.unwrap(); + mq_set_nonblock(mqd).unwrap(); + let new_attr = mq_getattr(mqd); + assert!(new_attr.unwrap().flags() == MQ_OFlag::O_NONBLOCK.bits() as c_long); + mq_remove_nonblock(mqd).unwrap(); + let new_attr = mq_getattr(mqd); + assert!(new_attr.unwrap().flags() == 0); + mq_close(mqd).unwrap(); +} + +#[test] +#[cfg(not(any(target_os = "netbsd")))] +fn test_mq_unlink() { + use nix::mqueue::mq_unlink; + const MSG_SIZE: c_long = 32; + let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0); + let mq_name_opened = &CString::new(b"/mq_unlink_test".as_ref()).unwrap(); + let mq_name_not_opened = &CString::new(b"/mq_unlink_test".as_ref()).unwrap(); + let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY; + let mode = Mode::S_IWUSR | Mode::S_IRUSR | Mode::S_IRGRP | Mode::S_IROTH; + let r = mq_open(mq_name_opened, oflag, mode, Some(&initial_attr)); + if let Err(Sys(ENOSYS)) = r { + println!("message queues not supported or module not loaded?"); + return; + }; + let mqd = r.unwrap(); + + let res_unlink = mq_unlink(mq_name_opened); + assert!(res_unlink == Ok(()) ); + + let res_unlink_not_opened = mq_unlink(mq_name_not_opened); + assert!(res_unlink_not_opened == Err(Sys(ENOENT)) ); + + mq_close(mqd).unwrap(); + let res_unlink_after_close = mq_unlink(mq_name_opened); + assert!(res_unlink_after_close == Err(Sys(ENOENT)) ); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_net.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_net.rs new file mode 100644 index 0000000..b8940e7 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_net.rs @@ -0,0 +1,12 @@ +use nix::net::if_::*; + +#[cfg(any(target_os = "android", target_os = "linux"))] +const LOOPBACK: &[u8] = b"lo"; + +#[cfg(not(any(target_os = "android", target_os = "linux")))] +const LOOPBACK: &[u8] = b"lo0"; + +#[test] +fn test_if_nametoindex() { + assert!(if_nametoindex(&LOOPBACK[..]).is_ok()); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_nix_path.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_nix_path.rs new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_poll.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_poll.rs new file mode 100644 index 0000000..6cac3b7 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_poll.rs @@ -0,0 +1,68 @@ +use nix::poll::{PollFlags, poll, PollFd}; +use nix::unistd::{write, pipe, close}; + +#[test] +fn test_poll() { + let (r, w) = pipe().unwrap(); + let mut fds = [PollFd::new(r, PollFlags::POLLIN)]; + + // Poll an idle pipe. Should timeout + let nfds = poll(&mut fds, 100).unwrap(); + assert_eq!(nfds, 0); + assert!(!fds[0].revents().unwrap().contains(PollFlags::POLLIN)); + + write(w, b".").unwrap(); + + // Poll a readable pipe. Should return an event. + let nfds = poll(&mut fds, 100).unwrap(); + assert_eq!(nfds, 1); + assert!(fds[0].revents().unwrap().contains(PollFlags::POLLIN)); +} + +#[test] +fn test_poll_debug() { + assert_eq!(format!("{:?}", PollFd::new(0, PollFlags::empty())), + "PollFd { fd: 0, events: (empty), revents: (empty) }"); + assert_eq!(format!("{:?}", PollFd::new(1, PollFlags::POLLIN)), + "PollFd { fd: 1, events: POLLIN, revents: (empty) }"); + + // Testing revents requires doing some I/O + let (r, w) = pipe().unwrap(); + let mut fds = [PollFd::new(r, PollFlags::POLLIN)]; + write(w, b" ").unwrap(); + close(w).unwrap(); + poll(&mut fds, -1).unwrap(); + assert_eq!(format!("{:?}", fds[0]), + format!("PollFd {{ fd: {}, events: POLLIN, revents: POLLIN | POLLHUP }}", r)); + close(r).unwrap(); +} + +// ppoll(2) is the same as poll except for how it handles timeouts and signals. +// Repeating the test for poll(2) should be sufficient to check that our +// bindings are correct. +#[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux"))] +#[test] +fn test_ppoll() { + use nix::poll::ppoll; + use nix::sys::signal::SigSet; + use nix::sys::time::{TimeSpec, TimeValLike}; + + let timeout = TimeSpec::milliseconds(1); + let (r, w) = pipe().unwrap(); + let mut fds = [PollFd::new(r, PollFlags::POLLIN)]; + + // Poll an idle pipe. Should timeout + let nfds = ppoll(&mut fds, timeout, SigSet::empty()).unwrap(); + assert_eq!(nfds, 0); + assert!(!fds[0].revents().unwrap().contains(PollFlags::POLLIN)); + + write(w, b".").unwrap(); + + // Poll a readable pipe. Should return an event. + let nfds = ppoll(&mut fds, timeout, SigSet::empty()).unwrap(); + assert_eq!(nfds, 1); + assert!(fds[0].revents().unwrap().contains(PollFlags::POLLIN)); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_pty.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_pty.rs new file mode 100644 index 0000000..476b15c --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_pty.rs @@ -0,0 +1,235 @@ +use std::io::Write; +use std::path::Path; +use std::os::unix::prelude::*; +use tempfile::tempfile; + +use libc::{_exit, STDOUT_FILENO}; +use nix::fcntl::{OFlag, open}; +use nix::pty::*; +use nix::sys::stat; +use nix::sys::termios::*; +use nix::unistd::{write, close, pause}; + +/// Regression test for Issue #659 +/// This is the correct way to explicitly close a `PtyMaster` +#[test] +fn test_explicit_close() { + let mut f = { + let m = posix_openpt(OFlag::O_RDWR).unwrap(); + close(m.into_raw_fd()).unwrap(); + tempfile().unwrap() + }; + // This should work. But if there's been a double close, then it will + // return EBADF + f.write_all(b"whatever").unwrap(); +} + +/// Test equivalence of `ptsname` and `ptsname_r` +#[test] +#[cfg(any(target_os = "android", target_os = "linux"))] +fn test_ptsname_equivalence() { + let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test"); + + // Open a new PTTY master + let master_fd = posix_openpt(OFlag::O_RDWR).unwrap(); + assert!(master_fd.as_raw_fd() > 0); + + // Get the name of the slave + let slave_name = unsafe { ptsname(&master_fd) }.unwrap() ; + let slave_name_r = ptsname_r(&master_fd).unwrap(); + assert_eq!(slave_name, slave_name_r); +} + +/// Test data copying of `ptsname` +// TODO need to run in a subprocess, since ptsname is non-reentrant +#[test] +#[cfg(any(target_os = "android", target_os = "linux"))] +fn test_ptsname_copy() { + let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test"); + + // Open a new PTTY master + let master_fd = posix_openpt(OFlag::O_RDWR).unwrap(); + assert!(master_fd.as_raw_fd() > 0); + + // Get the name of the slave + let slave_name1 = unsafe { ptsname(&master_fd) }.unwrap(); + let slave_name2 = unsafe { ptsname(&master_fd) }.unwrap(); + assert!(slave_name1 == slave_name2); + // Also make sure that the string was actually copied and they point to different parts of + // memory. + assert!(slave_name1.as_ptr() != slave_name2.as_ptr()); +} + +/// Test data copying of `ptsname_r` +#[test] +#[cfg(any(target_os = "android", target_os = "linux"))] +fn test_ptsname_r_copy() { + // Open a new PTTY master + let master_fd = posix_openpt(OFlag::O_RDWR).unwrap(); + assert!(master_fd.as_raw_fd() > 0); + + // Get the name of the slave + let slave_name1 = ptsname_r(&master_fd).unwrap(); + let slave_name2 = ptsname_r(&master_fd).unwrap(); + assert!(slave_name1 == slave_name2); + assert!(slave_name1.as_ptr() != slave_name2.as_ptr()); +} + +/// Test that `ptsname` returns different names for different devices +#[test] +#[cfg(any(target_os = "android", target_os = "linux"))] +fn test_ptsname_unique() { + let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test"); + + // Open a new PTTY master + let master1_fd = posix_openpt(OFlag::O_RDWR).unwrap(); + assert!(master1_fd.as_raw_fd() > 0); + + // Open a second PTTY master + let master2_fd = posix_openpt(OFlag::O_RDWR).unwrap(); + assert!(master2_fd.as_raw_fd() > 0); + + // Get the name of the slave + let slave_name1 = unsafe { ptsname(&master1_fd) }.unwrap(); + let slave_name2 = unsafe { ptsname(&master2_fd) }.unwrap(); + assert!(slave_name1 != slave_name2); +} + +/// Test opening a master/slave PTTY pair +/// +/// This is a single larger test because much of these functions aren't useful by themselves. So for +/// this test we perform the basic act of getting a file handle for a connect master/slave PTTY +/// pair. +#[test] +fn test_open_ptty_pair() { + let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test"); + + // Open a new PTTY master + let master_fd = posix_openpt(OFlag::O_RDWR).expect("posix_openpt failed"); + assert!(master_fd.as_raw_fd() > 0); + + // Allow a slave to be generated for it + grantpt(&master_fd).expect("grantpt failed"); + unlockpt(&master_fd).expect("unlockpt failed"); + + // Get the name of the slave + let slave_name = unsafe { ptsname(&master_fd) }.expect("ptsname failed"); + + // Open the slave device + let slave_fd = open(Path::new(&slave_name), OFlag::O_RDWR, stat::Mode::empty()).unwrap(); + assert!(slave_fd > 0); +} + +#[test] +fn test_openpty() { + // openpty uses ptname(3) internally + let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test"); + + let pty = openpty(None, None).unwrap(); + assert!(pty.master > 0); + assert!(pty.slave > 0); + + // Writing to one should be readable on the other one + let string = "foofoofoo\n"; + let mut buf = [0u8; 10]; + write(pty.master, string.as_bytes()).unwrap(); + ::read_exact(pty.slave, &mut buf); + + assert_eq!(&buf, string.as_bytes()); + + // Read the echo as well + let echoed_string = "foofoofoo\r\n"; + let mut buf = [0u8; 11]; + ::read_exact(pty.master, &mut buf); + assert_eq!(&buf, echoed_string.as_bytes()); + + let string2 = "barbarbarbar\n"; + let echoed_string2 = "barbarbarbar\r\n"; + let mut buf = [0u8; 14]; + write(pty.slave, string2.as_bytes()).unwrap(); + ::read_exact(pty.master, &mut buf); + + assert_eq!(&buf, echoed_string2.as_bytes()); + + close(pty.master).unwrap(); + close(pty.slave).unwrap(); +} + +#[test] +fn test_openpty_with_termios() { + // openpty uses ptname(3) internally + let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test"); + + // Open one pty to get attributes for the second one + let mut termios = { + let pty = openpty(None, None).unwrap(); + assert!(pty.master > 0); + assert!(pty.slave > 0); + let termios = tcgetattr(pty.master).unwrap(); + close(pty.master).unwrap(); + close(pty.slave).unwrap(); + termios + }; + // Make sure newlines are not transformed so the data is preserved when sent. + termios.output_flags.remove(OutputFlags::ONLCR); + + let pty = openpty(None, &termios).unwrap(); + // Must be valid file descriptors + assert!(pty.master > 0); + assert!(pty.slave > 0); + + // Writing to one should be readable on the other one + let string = "foofoofoo\n"; + let mut buf = [0u8; 10]; + write(pty.master, string.as_bytes()).unwrap(); + ::read_exact(pty.slave, &mut buf); + + assert_eq!(&buf, string.as_bytes()); + + // read the echo as well + let echoed_string = "foofoofoo\n"; + ::read_exact(pty.master, &mut buf); + assert_eq!(&buf, echoed_string.as_bytes()); + + let string2 = "barbarbarbar\n"; + let echoed_string2 = "barbarbarbar\n"; + let mut buf = [0u8; 13]; + write(pty.slave, string2.as_bytes()).unwrap(); + ::read_exact(pty.master, &mut buf); + + assert_eq!(&buf, echoed_string2.as_bytes()); + + close(pty.master).unwrap(); + close(pty.slave).unwrap(); +} + +#[test] +fn test_forkpty() { + use nix::unistd::ForkResult::*; + use nix::sys::signal::*; + use nix::sys::wait::wait; + // forkpty calls openpty which uses ptname(3) internally. + let _m0 = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test"); + // forkpty spawns a child process + let _m1 = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + + let string = "naninani\n"; + let echoed_string = "naninani\r\n"; + let pty = forkpty(None, None).unwrap(); + match pty.fork_result { + Child => { + write(STDOUT_FILENO, string.as_bytes()).unwrap(); + pause(); // we need the child to stay alive until the parent calls read + unsafe { _exit(0); } + }, + Parent { child } => { + let mut buf = [0u8; 10]; + assert!(child.as_raw() > 0); + ::read_exact(pty.master, &mut buf); + kill(child, SIGTERM).unwrap(); + wait().unwrap(); // keep other tests using generic wait from getting our child + assert_eq!(&buf, echoed_string.as_bytes()); + close(pty.master).unwrap(); + }, + } +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_ptymaster_drop.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_ptymaster_drop.rs new file mode 100644 index 0000000..9b59d66 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_ptymaster_drop.rs @@ -0,0 +1,21 @@ +extern crate nix; + +use nix::fcntl::OFlag; +use nix::pty::*; +use nix::unistd::close; +use std::os::unix::io::AsRawFd; + +/// Regression test for Issue #659 +/// `PtyMaster` should panic rather than double close the file descriptor +/// This must run in its own test process because it deliberately creates a race +/// condition. +#[test] +#[should_panic(expected = "Closing an invalid file descriptor!")] +// In Travis on i686-unknown-linux-musl, this test gets SIGABRT. I don't know +// why. It doesn't happen on any other target, and it doesn't happen on my PC. +#[cfg_attr(all(target_env = "musl", target_arch = "x86"), ignore)] +fn test_double_close() { + let m = posix_openpt(OFlag::O_RDWR).unwrap(); + close(m.as_raw_fd()).unwrap(); + drop(m); // should panic here +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_sendfile.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_sendfile.rs new file mode 100644 index 0000000..3bc7932 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_sendfile.rs @@ -0,0 +1,129 @@ +use std::io::prelude::*; +use std::os::unix::prelude::*; + +use libc::off_t; +use nix::sys::sendfile::*; +use tempfile::tempfile; + +cfg_if! { + if #[cfg(any(target_os = "android", target_os = "linux"))] { + use nix::unistd::{close, pipe, read}; + } else if #[cfg(any(target_os = "freebsd", target_os = "ios", target_os = "macos"))] { + use std::net::Shutdown; + use std::os::unix::net::UnixStream; + } +} + +#[cfg(any(target_os = "android", target_os = "linux"))] +#[test] +fn test_sendfile_linux() { + const CONTENTS: &[u8] = b"abcdef123456"; + let mut tmp = tempfile().unwrap(); + tmp.write_all(CONTENTS).unwrap(); + + let (rd, wr) = pipe().unwrap(); + let mut offset: off_t = 5; + let res = sendfile(wr, tmp.as_raw_fd(), Some(&mut offset), 2).unwrap(); + + assert_eq!(2, res); + + let mut buf = [0u8; 1024]; + assert_eq!(2, read(rd, &mut buf).unwrap()); + assert_eq!(b"f1", &buf[0..2]); + assert_eq!(7, offset); + + close(rd).unwrap(); + close(wr).unwrap(); +} + +#[cfg(target_os = "freebsd")] +#[test] +fn test_sendfile_freebsd() { + // Declare the content + let header_strings = vec!["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"]; + let body = "Xabcdef123456"; + let body_offset = 1; + let trailer_strings = vec!["\n", "Served by Make Believe\n"]; + + // Write the body to a file + let mut tmp = tempfile().unwrap(); + tmp.write_all(body.as_bytes()).unwrap(); + + // Prepare headers and trailers for sendfile + let headers: Vec<&[u8]> = header_strings.iter().map(|s| s.as_bytes()).collect(); + let trailers: Vec<&[u8]> = trailer_strings.iter().map(|s| s.as_bytes()).collect(); + + // Prepare socket pair + let (mut rd, wr) = UnixStream::pair().unwrap(); + + // Call the test method + let (res, bytes_written) = sendfile( + tmp.as_raw_fd(), + wr.as_raw_fd(), + body_offset as off_t, + None, + Some(headers.as_slice()), + Some(trailers.as_slice()), + SfFlags::empty(), + 0, + ); + assert!(res.is_ok()); + wr.shutdown(Shutdown::Both).unwrap(); + + // Prepare the expected result + let expected_string = + header_strings.concat() + &body[body_offset..] + &trailer_strings.concat(); + + // Verify the message that was sent + assert_eq!(bytes_written as usize, expected_string.as_bytes().len()); + + let mut read_string = String::new(); + let bytes_read = rd.read_to_string(&mut read_string).unwrap(); + assert_eq!(bytes_written as usize, bytes_read); + assert_eq!(expected_string, read_string); +} + +#[cfg(any(target_os = "ios", target_os = "macos"))] +#[test] +fn test_sendfile_darwin() { + // Declare the content + let header_strings = vec!["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"]; + let body = "Xabcdef123456"; + let body_offset = 1; + let trailer_strings = vec!["\n", "Served by Make Believe\n"]; + + // Write the body to a file + let mut tmp = tempfile().unwrap(); + tmp.write_all(body.as_bytes()).unwrap(); + + // Prepare headers and trailers for sendfile + let headers: Vec<&[u8]> = header_strings.iter().map(|s| s.as_bytes()).collect(); + let trailers: Vec<&[u8]> = trailer_strings.iter().map(|s| s.as_bytes()).collect(); + + // Prepare socket pair + let (mut rd, wr) = UnixStream::pair().unwrap(); + + // Call the test method + let (res, bytes_written) = sendfile( + tmp.as_raw_fd(), + wr.as_raw_fd(), + body_offset as off_t, + None, + Some(headers.as_slice()), + Some(trailers.as_slice()), + ); + assert!(res.is_ok()); + wr.shutdown(Shutdown::Both).unwrap(); + + // Prepare the expected result + let expected_string = + header_strings.concat() + &body[body_offset..] + &trailer_strings.concat(); + + // Verify the message that was sent + assert_eq!(bytes_written as usize, expected_string.as_bytes().len()); + + let mut read_string = String::new(); + let bytes_read = rd.read_to_string(&mut read_string).unwrap(); + assert_eq!(bytes_written as usize, bytes_read); + assert_eq!(expected_string, read_string); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_stat.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_stat.rs new file mode 100644 index 0000000..b9da7fc --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_stat.rs @@ -0,0 +1,262 @@ +use std::fs::{self, File}; +use std::os::unix::fs::symlink; +use std::os::unix::prelude::AsRawFd; +use std::time::{Duration, UNIX_EPOCH}; + +#[cfg(not(any(target_os = "netbsd")))] +use libc::{S_IFMT, S_IFLNK}; + +use nix::fcntl; +use nix::sys::stat::{self, fchmod, fchmodat, futimens, stat, utimes, utimensat}; +#[cfg(any(target_os = "linux", + target_os = "haiku", + target_os = "ios", + target_os = "macos", + target_os = "freebsd", + target_os = "netbsd"))] +use nix::sys::stat::lutimes; +use nix::sys::stat::{Mode, FchmodatFlags, UtimensatFlags}; + +#[cfg(not(any(target_os = "netbsd")))] +use nix::sys::stat::FileStat; + +use nix::sys::time::{TimeSpec, TimeVal, TimeValLike}; +use nix::unistd::chdir; + +#[cfg(not(any(target_os = "netbsd")))] +use nix::Result; +use tempfile; + +#[allow(unused_comparisons)] +// uid and gid are signed on Windows, but not on other platforms. This function +// allows warning free compiles on all platforms, and can be removed when +// expression-level #[allow] is available. +#[cfg(not(any(target_os = "netbsd")))] +fn valid_uid_gid(stat: FileStat) -> bool { + // uid could be 0 for the `root` user. This quite possible when + // the tests are being run on a rooted Android device. + stat.st_uid >= 0 && stat.st_gid >= 0 +} + +#[cfg(not(any(target_os = "netbsd")))] +fn assert_stat_results(stat_result: Result) { + let stats = stat_result.expect("stat call failed"); + assert!(stats.st_dev > 0); // must be positive integer, exact number machine dependent + assert!(stats.st_ino > 0); // inode is positive integer, exact number machine dependent + assert!(stats.st_mode > 0); // must be positive integer + assert!(stats.st_nlink == 1); // there links created, must be 1 + assert!(valid_uid_gid(stats)); // must be positive integers + assert!(stats.st_size == 0); // size is 0 because we did not write anything to the file + assert!(stats.st_blksize > 0); // must be positive integer, exact number machine dependent + assert!(stats.st_blocks <= 16); // Up to 16 blocks can be allocated for a blank file +} + +#[cfg(not(any(target_os = "netbsd")))] +fn assert_lstat_results(stat_result: Result) { + let stats = stat_result.expect("stat call failed"); + assert!(stats.st_dev > 0); // must be positive integer, exact number machine dependent + assert!(stats.st_ino > 0); // inode is positive integer, exact number machine dependent + assert!(stats.st_mode > 0); // must be positive integer + + // st_mode is c_uint (u32 on Android) while S_IFMT is mode_t + // (u16 on Android), and that will be a compile error. + // On other platforms they are the same (either both are u16 or u32). + assert!((stats.st_mode as usize) & (S_IFMT as usize) == S_IFLNK as usize); // should be a link + assert!(stats.st_nlink == 1); // there links created, must be 1 + assert!(valid_uid_gid(stats)); // must be positive integers + assert!(stats.st_size > 0); // size is > 0 because it points to another file + assert!(stats.st_blksize > 0); // must be positive integer, exact number machine dependent + + // st_blocks depends on whether the machine's file system uses fast + // or slow symlinks, so just make sure it's not negative + // (Android's st_blocks is ulonglong which is always non-negative.) + assert!(stats.st_blocks >= 0); +} + +#[test] +#[cfg(not(any(target_os = "netbsd")))] +fn test_stat_and_fstat() { + use nix::sys::stat::fstat; + + let tempdir = tempfile::tempdir().unwrap(); + let filename = tempdir.path().join("foo.txt"); + let file = File::create(&filename).unwrap(); + + let stat_result = stat(&filename); + assert_stat_results(stat_result); + + let fstat_result = fstat(file.as_raw_fd()); + assert_stat_results(fstat_result); +} + +#[test] +#[cfg(not(any(target_os = "netbsd")))] +fn test_fstatat() { + let tempdir = tempfile::tempdir().unwrap(); + let filename = tempdir.path().join("foo.txt"); + File::create(&filename).unwrap(); + let dirfd = fcntl::open(tempdir.path(), + fcntl::OFlag::empty(), + stat::Mode::empty()); + + let result = stat::fstatat(dirfd.unwrap(), + &filename, + fcntl::AtFlags::empty()); + assert_stat_results(result); +} + +#[test] +#[cfg(not(any(target_os = "netbsd")))] +fn test_stat_fstat_lstat() { + use nix::sys::stat::{fstat, lstat}; + + let tempdir = tempfile::tempdir().unwrap(); + let filename = tempdir.path().join("bar.txt"); + let linkname = tempdir.path().join("barlink"); + + File::create(&filename).unwrap(); + symlink("bar.txt", &linkname).unwrap(); + let link = File::open(&linkname).unwrap(); + + // should be the same result as calling stat, + // since it's a regular file + let stat_result = stat(&filename); + assert_stat_results(stat_result); + + let lstat_result = lstat(&linkname); + assert_lstat_results(lstat_result); + + let fstat_result = fstat(link.as_raw_fd()); + assert_stat_results(fstat_result); +} + +#[test] +fn test_fchmod() { + let tempdir = tempfile::tempdir().unwrap(); + let filename = tempdir.path().join("foo.txt"); + let file = File::create(&filename).unwrap(); + + let mut mode1 = Mode::empty(); + mode1.insert(Mode::S_IRUSR); + mode1.insert(Mode::S_IWUSR); + fchmod(file.as_raw_fd(), mode1).unwrap(); + + let file_stat1 = stat(&filename).unwrap(); + assert_eq!(file_stat1.st_mode & 0o7777, mode1.bits()); + + let mut mode2 = Mode::empty(); + mode2.insert(Mode::S_IROTH); + fchmod(file.as_raw_fd(), mode2).unwrap(); + + let file_stat2 = stat(&filename).unwrap(); + assert_eq!(file_stat2.st_mode & 0o7777, mode2.bits()); +} + +#[test] +fn test_fchmodat() { + let _dr = ::DirRestore::new(); + let tempdir = tempfile::tempdir().unwrap(); + let filename = "foo.txt"; + let fullpath = tempdir.path().join(filename); + File::create(&fullpath).unwrap(); + + let dirfd = fcntl::open(tempdir.path(), fcntl::OFlag::empty(), stat::Mode::empty()).unwrap(); + + let mut mode1 = Mode::empty(); + mode1.insert(Mode::S_IRUSR); + mode1.insert(Mode::S_IWUSR); + fchmodat(Some(dirfd), filename, mode1, FchmodatFlags::FollowSymlink).unwrap(); + + let file_stat1 = stat(&fullpath).unwrap(); + assert_eq!(file_stat1.st_mode & 0o7777, mode1.bits()); + + chdir(tempdir.path()).unwrap(); + + let mut mode2 = Mode::empty(); + mode2.insert(Mode::S_IROTH); + fchmodat(None, filename, mode2, FchmodatFlags::FollowSymlink).unwrap(); + + let file_stat2 = stat(&fullpath).unwrap(); + assert_eq!(file_stat2.st_mode & 0o7777, mode2.bits()); +} + +/// Asserts that the atime and mtime in a file's metadata match expected values. +/// +/// The atime and mtime are expressed with a resolution of seconds because some file systems +/// (like macOS's HFS+) do not have higher granularity. +fn assert_times_eq(exp_atime_sec: u64, exp_mtime_sec: u64, attr: &fs::Metadata) { + assert_eq!( + Duration::new(exp_atime_sec, 0), + attr.accessed().unwrap().duration_since(UNIX_EPOCH).unwrap()); + assert_eq!( + Duration::new(exp_mtime_sec, 0), + attr.modified().unwrap().duration_since(UNIX_EPOCH).unwrap()); +} + +#[test] +fn test_utimes() { + let tempdir = tempfile::tempdir().unwrap(); + let fullpath = tempdir.path().join("file"); + drop(File::create(&fullpath).unwrap()); + + utimes(&fullpath, &TimeVal::seconds(9990), &TimeVal::seconds(5550)).unwrap(); + assert_times_eq(9990, 5550, &fs::metadata(&fullpath).unwrap()); +} + +#[test] +#[cfg(any(target_os = "linux", + target_os = "haiku", + target_os = "ios", + target_os = "macos", + target_os = "freebsd", + target_os = "netbsd"))] +fn test_lutimes() { + let tempdir = tempfile::tempdir().unwrap(); + let target = tempdir.path().join("target"); + let fullpath = tempdir.path().join("symlink"); + drop(File::create(&target).unwrap()); + symlink(&target, &fullpath).unwrap(); + + let exp_target_metadata = fs::symlink_metadata(&target).unwrap(); + lutimes(&fullpath, &TimeVal::seconds(4560), &TimeVal::seconds(1230)).unwrap(); + assert_times_eq(4560, 1230, &fs::symlink_metadata(&fullpath).unwrap()); + + let target_metadata = fs::symlink_metadata(&target).unwrap(); + assert_eq!(exp_target_metadata.accessed().unwrap(), target_metadata.accessed().unwrap(), + "atime of symlink target was unexpectedly modified"); + assert_eq!(exp_target_metadata.modified().unwrap(), target_metadata.modified().unwrap(), + "mtime of symlink target was unexpectedly modified"); +} + +#[test] +fn test_futimens() { + let tempdir = tempfile::tempdir().unwrap(); + let fullpath = tempdir.path().join("file"); + drop(File::create(&fullpath).unwrap()); + + let fd = fcntl::open(&fullpath, fcntl::OFlag::empty(), stat::Mode::empty()).unwrap(); + + futimens(fd, &TimeSpec::seconds(10), &TimeSpec::seconds(20)).unwrap(); + assert_times_eq(10, 20, &fs::metadata(&fullpath).unwrap()); +} + +#[test] +fn test_utimensat() { + let _dr = ::DirRestore::new(); + let tempdir = tempfile::tempdir().unwrap(); + let filename = "foo.txt"; + let fullpath = tempdir.path().join(filename); + drop(File::create(&fullpath).unwrap()); + + let dirfd = fcntl::open(tempdir.path(), fcntl::OFlag::empty(), stat::Mode::empty()).unwrap(); + + utimensat(Some(dirfd), filename, &TimeSpec::seconds(12345), &TimeSpec::seconds(678), + UtimensatFlags::FollowSymlink).unwrap(); + assert_times_eq(12345, 678, &fs::metadata(&fullpath).unwrap()); + + chdir(tempdir.path()).unwrap(); + + utimensat(None, filename, &TimeSpec::seconds(500), &TimeSpec::seconds(800), + UtimensatFlags::FollowSymlink).unwrap(); + assert_times_eq(500, 800, &fs::metadata(&fullpath).unwrap()); +} diff --git a/third_party/cargo/vendor/nix-0.14.1/test/test_unistd.rs b/third_party/cargo/vendor/nix-0.14.1/test/test_unistd.rs new file mode 100644 index 0000000..b206145 --- /dev/null +++ b/third_party/cargo/vendor/nix-0.14.1/test/test_unistd.rs @@ -0,0 +1,616 @@ +use nix::fcntl::{fcntl, FcntlArg, FdFlag, open, OFlag, readlink}; +use nix::unistd::*; +use nix::unistd::ForkResult::*; +use nix::sys::signal::{SaFlags, SigAction, SigHandler, SigSet, Signal, sigaction}; +use nix::sys::wait::*; +use nix::sys::stat::{self, Mode, SFlag}; +use nix::errno::Errno; +use std::{env, iter}; +use std::ffi::CString; +use std::fs::{self, File}; +use std::io::Write; +use std::os::unix::prelude::*; +use tempfile::{self, tempfile}; +use libc::{self, _exit, off_t}; + +#[test] +#[cfg(not(any(target_os = "netbsd")))] +fn test_fork_and_waitpid() { + let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + + // Safe: Child only calls `_exit`, which is signal-safe + match fork().expect("Error: Fork Failed") { + Child => unsafe { _exit(0) }, + Parent { child } => { + // assert that child was created and pid > 0 + let child_raw: ::libc::pid_t = child.into(); + assert!(child_raw > 0); + let wait_status = waitpid(child, None); + match wait_status { + // assert that waitpid returned correct status and the pid is the one of the child + Ok(WaitStatus::Exited(pid_t, _)) => assert!(pid_t == child), + + // panic, must never happen + s @ Ok(_) => panic!("Child exited {:?}, should never happen", s), + + // panic, waitpid should never fail + Err(s) => panic!("Error: waitpid returned Err({:?}", s) + } + + }, + } +} + +#[test] +fn test_wait() { + // Grab FORK_MTX so wait doesn't reap a different test's child process + let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + + // Safe: Child only calls `_exit`, which is signal-safe + match fork().expect("Error: Fork Failed") { + Child => unsafe { _exit(0) }, + Parent { child } => { + let wait_status = wait(); + + // just assert that (any) one child returns with WaitStatus::Exited + assert_eq!(wait_status, Ok(WaitStatus::Exited(child, 0))); + }, + } +} + +#[test] +fn test_mkstemp() { + let mut path = env::temp_dir(); + path.push("nix_tempfile.XXXXXX"); + + let result = mkstemp(&path); + match result { + Ok((fd, path)) => { + close(fd).unwrap(); + unlink(path.as_path()).unwrap(); + }, + Err(e) => panic!("mkstemp failed: {}", e) + } +} + +#[test] +fn test_mkstemp_directory() { + // mkstemp should fail if a directory is given + assert!(mkstemp(&env::temp_dir()).is_err()); +} + +#[test] +fn test_mkfifo() { + let tempdir = tempfile::tempdir().unwrap(); + let mkfifo_fifo = tempdir.path().join("mkfifo_fifo"); + + mkfifo(&mkfifo_fifo, Mode::S_IRUSR).unwrap(); + + let stats = stat::stat(&mkfifo_fifo).unwrap(); + let typ = stat::SFlag::from_bits_truncate(stats.st_mode); + assert!(typ == SFlag::S_IFIFO); +} + +#[test] +fn test_mkfifo_directory() { + // mkfifo should fail if a directory is given + assert!(mkfifo(&env::temp_dir(), Mode::S_IRUSR).is_err()); +} + +#[test] +fn test_getpid() { + let pid: ::libc::pid_t = getpid().into(); + let ppid: ::libc::pid_t = getppid().into(); + assert!(pid > 0); + assert!(ppid > 0); +} + +#[test] +fn test_getsid() { + let none_sid: ::libc::pid_t = getsid(None).unwrap().into(); + let pid_sid: ::libc::pid_t = getsid(Some(getpid())).unwrap().into(); + assert!(none_sid > 0); + assert!(none_sid == pid_sid); +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +mod linux_android { + use nix::unistd::gettid; + + #[test] + fn test_gettid() { + let tid: ::libc::pid_t = gettid().into(); + assert!(tid > 0); + } +} + +#[test] +// `getgroups()` and `setgroups()` do not behave as expected on Apple platforms +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +fn test_setgroups() { + // Skip this test when not run as root as `setgroups()` requires root. + skip_if_not_root!("test_setgroups"); + + let _m = ::GROUPS_MTX.lock().expect("Mutex got poisoned by another test"); + + // Save the existing groups + let old_groups = getgroups().unwrap(); + + // Set some new made up groups + let groups = [Gid::from_raw(123), Gid::from_raw(456)]; + setgroups(&groups).unwrap(); + + let new_groups = getgroups().unwrap(); + assert_eq!(new_groups, groups); + + // Revert back to the old groups + setgroups(&old_groups).unwrap(); +} + +#[test] +// `getgroups()` and `setgroups()` do not behave as expected on Apple platforms +#[cfg(not(any(target_os = "ios", target_os = "macos")))] +fn test_initgroups() { + // Skip this test when not run as root as `initgroups()` and `setgroups()` + // require root. + skip_if_not_root!("test_initgroups"); + + let _m = ::GROUPS_MTX.lock().expect("Mutex got poisoned by another test"); + + // Save the existing groups + let old_groups = getgroups().unwrap(); + + // It doesn't matter if the root user is not called "root" or if a user + // called "root" doesn't exist. We are just checking that the extra, + // made-up group, `123`, is set. + // FIXME: Test the other half of initgroups' functionality: whether the + // groups that the user belongs to are also set. + let user = CString::new("root").unwrap(); + let group = Gid::from_raw(123); + let group_list = getgrouplist(&user, group).unwrap(); + assert!(group_list.contains(&group)); + + initgroups(&user, group).unwrap(); + + let new_groups = getgroups().unwrap(); + assert_eq!(new_groups, group_list); + + // Revert back to the old groups + setgroups(&old_groups).unwrap(); +} + +macro_rules! execve_test_factory( + ($test_name:ident, $syscall:ident, $exe: expr $(, $pathname:expr, $flags:expr)*) => ( + #[test] + fn $test_name() { + let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + // The `exec`d process will write to `writer`, and we'll read that + // data from `reader`. + let (reader, writer) = pipe().unwrap(); + + // Safe: Child calls `exit`, `dup`, `close` and the provided `exec*` family function. + // NOTE: Technically, this makes the macro unsafe to use because you could pass anything. + // The tests make sure not to do that, though. + match fork().unwrap() { + Child => { + // Close stdout. + close(1).unwrap(); + // Make `writer` be the stdout of the new process. + dup(writer).unwrap(); + // exec! + $syscall( + $exe, + $(&CString::new($pathname).unwrap(), )* + &[CString::new(b"".as_ref()).unwrap(), + CString::new(b"-c".as_ref()).unwrap(), + CString::new(b"echo nix!!! && echo foo=$foo && echo baz=$baz" + .as_ref()).unwrap()], + &[CString::new(b"foo=bar".as_ref()).unwrap(), + CString::new(b"baz=quux".as_ref()).unwrap()] + $(, $flags)*).unwrap(); + }, + Parent { child } => { + // Wait for the child to exit. + waitpid(child, None).unwrap(); + // Read 1024 bytes. + let mut buf = [0u8; 1024]; + read(reader, &mut buf).unwrap(); + // It should contain the things we printed using `/bin/sh`. + let string = String::from_utf8_lossy(&buf); + assert!(string.contains("nix!!!")); + assert!(string.contains("foo=bar")); + assert!(string.contains("baz=quux")); + } + } + } + ) +); + +cfg_if!{ + if #[cfg(target_os = "android")] { + execve_test_factory!(test_execve, execve, &CString::new("/system/bin/sh").unwrap()); + execve_test_factory!(test_fexecve, fexecve, File::open("/system/bin/sh").unwrap().into_raw_fd()); + } else if #[cfg(any(target_os = "freebsd", + target_os = "linux"))] { + execve_test_factory!(test_execve, execve, &CString::new("/bin/sh").unwrap()); + execve_test_factory!(test_fexecve, fexecve, File::open("/bin/sh").unwrap().into_raw_fd()); + } else if #[cfg(any(target_os = "dragonfly", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] { + execve_test_factory!(test_execve, execve, &CString::new("/bin/sh").unwrap()); + // No fexecve() on DragonFly, ios, macos, NetBSD, OpenBSD. + // + // Note for NetBSD and OpenBSD: although rust-lang/libc includes it + // (under unix/bsd/netbsdlike/) fexecve is not currently implemented on + // NetBSD nor on OpenBSD. + } +} + +#[cfg(any(target_os = "haiku", target_os = "linux", target_os = "openbsd"))] +execve_test_factory!(test_execvpe, execvpe, &CString::new("sh").unwrap()); + +cfg_if!{ + if #[cfg(target_os = "android")] { + use nix::fcntl::AtFlags; + execve_test_factory!(test_execveat_empty, execveat, File::open("/system/bin/sh").unwrap().into_raw_fd(), + "", AtFlags::AT_EMPTY_PATH); + execve_test_factory!(test_execveat_relative, execveat, File::open("/system/bin/").unwrap().into_raw_fd(), + "./sh", AtFlags::empty()); + execve_test_factory!(test_execveat_absolute, execveat, File::open("/").unwrap().into_raw_fd(), + "/system/bin/sh", AtFlags::empty()); + } else if #[cfg(all(target_os = "linux"), any(target_arch ="x86_64", target_arch ="x86"))] { + use nix::fcntl::AtFlags; + execve_test_factory!(test_execveat_empty, execveat, File::open("/bin/sh").unwrap().into_raw_fd(), + "", AtFlags::AT_EMPTY_PATH); + execve_test_factory!(test_execveat_relative, execveat, File::open("/bin/").unwrap().into_raw_fd(), + "./sh", AtFlags::empty()); + execve_test_factory!(test_execveat_absolute, execveat, File::open("/").unwrap().into_raw_fd(), + "/bin/sh", AtFlags::empty()); + } +} + +#[test] +fn test_fchdir() { + // fchdir changes the process's cwd + let _dr = ::DirRestore::new(); + + let tmpdir = tempfile::tempdir().unwrap(); + let tmpdir_path = tmpdir.path().canonicalize().unwrap(); + let tmpdir_fd = File::open(&tmpdir_path).unwrap().into_raw_fd(); + + assert!(fchdir(tmpdir_fd).is_ok()); + assert_eq!(getcwd().unwrap(), tmpdir_path); + + assert!(close(tmpdir_fd).is_ok()); +} + +#[test] +fn test_getcwd() { + // chdir changes the process's cwd + let _dr = ::DirRestore::new(); + + let tmpdir = tempfile::tempdir().unwrap(); + let tmpdir_path = tmpdir.path().canonicalize().unwrap(); + assert!(chdir(&tmpdir_path).is_ok()); + assert_eq!(getcwd().unwrap(), tmpdir_path); + + // make path 500 chars longer so that buffer doubling in getcwd + // kicks in. Note: One path cannot be longer than 255 bytes + // (NAME_MAX) whole path cannot be longer than PATH_MAX (usually + // 4096 on linux, 1024 on macos) + let mut inner_tmp_dir = tmpdir_path.to_path_buf(); + for _ in 0..5 { + let newdir = iter::repeat("a").take(100).collect::(); + inner_tmp_dir.push(newdir); + assert!(mkdir(inner_tmp_dir.as_path(), Mode::S_IRWXU).is_ok()); + } + assert!(chdir(inner_tmp_dir.as_path()).is_ok()); + assert_eq!(getcwd().unwrap(), inner_tmp_dir.as_path()); +} + +#[test] +fn test_chown() { + // Testing for anything other than our own UID/GID is hard. + let uid = Some(getuid()); + let gid = Some(getgid()); + + let tempdir = tempfile::tempdir().unwrap(); + let path = tempdir.path().join("file"); + { + File::create(&path).unwrap(); + } + + chown(&path, uid, gid).unwrap(); + chown(&path, uid, None).unwrap(); + chown(&path, None, gid).unwrap(); + + fs::remove_file(&path).unwrap(); + chown(&path, uid, gid).unwrap_err(); +} + +#[test] +fn test_fchownat() { + let _dr = ::DirRestore::new(); + // Testing for anything other than our own UID/GID is hard. + let uid = Some(getuid()); + let gid = Some(getgid()); + + let tempdir = tempfile::tempdir().unwrap(); + let path = tempdir.path().join("file"); + { + File::create(&path).unwrap(); + } + + let dirfd = open(tempdir.path(), OFlag::empty(), Mode::empty()).unwrap(); + + fchownat(Some(dirfd), "file", uid, gid, FchownatFlags::FollowSymlink).unwrap(); + + chdir(tempdir.path()).unwrap(); + fchownat(None, "file", uid, gid, FchownatFlags::FollowSymlink).unwrap(); + + fs::remove_file(&path).unwrap(); + fchownat(None, "file", uid, gid, FchownatFlags::FollowSymlink).unwrap_err(); +} + +#[test] +fn test_lseek() { + const CONTENTS: &[u8] = b"abcdef123456"; + let mut tmp = tempfile().unwrap(); + tmp.write_all(CONTENTS).unwrap(); + let tmpfd = tmp.into_raw_fd(); + + let offset: off_t = 5; + lseek(tmpfd, offset, Whence::SeekSet).unwrap(); + + let mut buf = [0u8; 7]; + ::read_exact(tmpfd, &mut buf); + assert_eq!(b"f123456", &buf); + + close(tmpfd).unwrap(); +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +#[test] +fn test_lseek64() { + const CONTENTS: &[u8] = b"abcdef123456"; + let mut tmp = tempfile().unwrap(); + tmp.write_all(CONTENTS).unwrap(); + let tmpfd = tmp.into_raw_fd(); + + lseek64(tmpfd, 5, Whence::SeekSet).unwrap(); + + let mut buf = [0u8; 7]; + ::read_exact(tmpfd, &mut buf); + assert_eq!(b"f123456", &buf); + + close(tmpfd).unwrap(); +} + +cfg_if!{ + if #[cfg(any(target_os = "android", target_os = "linux"))] { + macro_rules! require_acct{ + () => { + require_capability!(CAP_SYS_PACCT); + } + } + } else if #[cfg(target_os = "freebsd")] { + macro_rules! require_acct{ + () => { + skip_if_not_root!("test_acct"); + skip_if_jailed!("test_acct"); + } + } + } else { + macro_rules! require_acct{ + () => { + skip_if_not_root!("test_acct"); + } + } + } +} + +#[test] +fn test_acct() { + use tempfile::NamedTempFile; + use std::process::Command; + use std::{thread, time}; + + let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + require_acct!(); + + let file = NamedTempFile::new().unwrap(); + let path = file.path().to_str().unwrap(); + + acct::enable(path).unwrap(); + + loop { + Command::new("echo").arg("Hello world"); + let len = fs::metadata(path).unwrap().len(); + if len > 0 { break; } + thread::sleep(time::Duration::from_millis(10)); + } + acct::disable().unwrap(); +} + +#[test] +fn test_fpathconf_limited() { + let f = tempfile().unwrap(); + // AFAIK, PATH_MAX is limited on all platforms, so it makes a good test + let path_max = fpathconf(f.as_raw_fd(), PathconfVar::PATH_MAX); + assert!(path_max.expect("fpathconf failed").expect("PATH_MAX is unlimited") > 0); +} + +#[test] +fn test_pathconf_limited() { + // AFAIK, PATH_MAX is limited on all platforms, so it makes a good test + let path_max = pathconf("/", PathconfVar::PATH_MAX); + assert!(path_max.expect("pathconf failed").expect("PATH_MAX is unlimited") > 0); +} + +#[test] +fn test_sysconf_limited() { + // AFAIK, OPEN_MAX is limited on all platforms, so it makes a good test + let open_max = sysconf(SysconfVar::OPEN_MAX); + assert!(open_max.expect("sysconf failed").expect("OPEN_MAX is unlimited") > 0); +} + +#[cfg(target_os = "freebsd")] +#[test] +fn test_sysconf_unsupported() { + // I know of no sysconf variables that are unsupported everywhere, but + // _XOPEN_CRYPT is unsupported on FreeBSD 11.0, which is one of the platforms + // we test. + let open_max = sysconf(SysconfVar::_XOPEN_CRYPT); + assert!(open_max.expect("sysconf failed").is_none()) +} + +// Test that we can create a pair of pipes. No need to verify that they pass +// data; that's the domain of the OS, not nix. +#[test] +fn test_pipe() { + let (fd0, fd1) = pipe().unwrap(); + let m0 = stat::SFlag::from_bits_truncate(stat::fstat(fd0).unwrap().st_mode); + // S_IFIFO means it's a pipe + assert_eq!(m0, SFlag::S_IFIFO); + let m1 = stat::SFlag::from_bits_truncate(stat::fstat(fd1).unwrap().st_mode); + assert_eq!(m1, SFlag::S_IFIFO); +} + +// pipe2(2) is the same as pipe(2), except it allows setting some flags. Check +// that we can set a flag. +#[test] +fn test_pipe2() { + let (fd0, fd1) = pipe2(OFlag::O_CLOEXEC).unwrap(); + let f0 = FdFlag::from_bits_truncate(fcntl(fd0, FcntlArg::F_GETFD).unwrap()); + assert!(f0.contains(FdFlag::FD_CLOEXEC)); + let f1 = FdFlag::from_bits_truncate(fcntl(fd1, FcntlArg::F_GETFD).unwrap()); + assert!(f1.contains(FdFlag::FD_CLOEXEC)); +} + +#[test] +fn test_truncate() { + let tempdir = tempfile::tempdir().unwrap(); + let path = tempdir.path().join("file"); + + { + let mut tmp = File::create(&path).unwrap(); + const CONTENTS: &[u8] = b"12345678"; + tmp.write_all(CONTENTS).unwrap(); + } + + truncate(&path, 4).unwrap(); + + let metadata = fs::metadata(&path).unwrap(); + assert_eq!(4, metadata.len()); +} + +#[test] +fn test_ftruncate() { + let tempdir = tempfile::tempdir().unwrap(); + let path = tempdir.path().join("file"); + + let tmpfd = { + let mut tmp = File::create(&path).unwrap(); + const CONTENTS: &[u8] = b"12345678"; + tmp.write_all(CONTENTS).unwrap(); + tmp.into_raw_fd() + }; + + ftruncate(tmpfd, 2).unwrap(); + close(tmpfd).unwrap(); + + let metadata = fs::metadata(&path).unwrap(); + assert_eq!(2, metadata.len()); +} + +// Used in `test_alarm`. +static mut ALARM_CALLED: bool = false; + +// Used in `test_alarm`. +pub extern fn alarm_signal_handler(raw_signal: libc::c_int) { + assert_eq!(raw_signal, libc::SIGALRM, "unexpected signal: {}", raw_signal); + unsafe { ALARM_CALLED = true }; +} + +#[test] +fn test_alarm() { + let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); + + let handler = SigHandler::Handler(alarm_signal_handler); + let signal_action = SigAction::new(handler, SaFlags::SA_RESTART, SigSet::empty()); + let old_handler = unsafe { + sigaction(Signal::SIGALRM, &signal_action) + .expect("unable to set signal handler for alarm") + }; + + // Set an alarm. + assert_eq!(alarm::set(60), None); + + // Overwriting an alarm should return the old alarm. + assert_eq!(alarm::set(1), Some(60)); + + // We should be woken up after 1 second by the alarm, so we'll sleep for 2 + // seconds to be sure. + sleep(2); + assert_eq!(unsafe { ALARM_CALLED }, true, "expected our alarm signal handler to be called"); + + // Reset the signal. + unsafe { + sigaction(Signal::SIGALRM, &old_handler) + .expect("unable to set signal handler for alarm"); + } +} + +#[test] +fn test_canceling_alarm() { + let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); + + assert_eq!(alarm::cancel(), None); + + assert_eq!(alarm::set(60), None); + assert_eq!(alarm::cancel(), Some(60)); +} + +#[test] +fn test_symlinkat() { + let mut buf = [0; 1024]; + let tempdir = tempfile::tempdir().unwrap(); + + let target = tempdir.path().join("a"); + let linkpath = tempdir.path().join("b"); + symlinkat(&target, None, &linkpath).unwrap(); + assert_eq!( + readlink(&linkpath, &mut buf).unwrap().to_str().unwrap(), + target.to_str().unwrap() + ); + + let dirfd = open(tempdir.path(), OFlag::empty(), Mode::empty()).unwrap(); + let target = "c"; + let linkpath = "d"; + symlinkat(target, Some(dirfd), linkpath).unwrap(); + assert_eq!( + readlink(&tempdir.path().join(linkpath), &mut buf) + .unwrap() + .to_str() + .unwrap(), + target + ); +} + +#[test] +fn test_access_not_existing() { + let tempdir = tempfile::tempdir().unwrap(); + let dir = tempdir.path().join("does_not_exist.txt"); + assert_eq!(access(&dir, AccessFlags::F_OK).err().unwrap().as_errno().unwrap(), + Errno::ENOENT); +} + +#[test] +fn test_access_file_exists() { + let tempdir = tempfile::tempdir().unwrap(); + let path = tempdir.path().join("does_exist.txt"); + let _file = File::create(path.clone()).unwrap(); + assert!(access(&path, AccessFlags::R_OK | AccessFlags::W_OK).is_ok()); +} diff --git a/third_party/cargo/vendor/nodrop-0.1.14/.cargo-checksum.json b/third_party/cargo/vendor/nodrop-0.1.14/.cargo-checksum.json new file mode 100644 index 0000000..69622d2 --- /dev/null +++ b/third_party/cargo/vendor/nodrop-0.1.14/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"e43d9892df1d8d932b5f5d27f303f1a302b550b5a37b9b8fb1b107aa5273b8af","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0245ee104228a100ce5fceecf43e25faae450494d9173f43fd94c27d69fdac13","README.rst":"3a12c4caf645c40c7b9608c150c7e2bee50eafd114b802329f508a489d9e175b","src/lib.rs":"3e00173987c5fc462956c36f492426cbf0d900a2634c6b4e47580d6b142273ee"},"package":"72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"} \ No newline at end of file diff --git a/third_party/cargo/vendor/nodrop-0.1.14/BUILD b/third_party/cargo/vendor/nodrop-0.1.14/BUILD new file mode 100644 index 0000000..2cdfc0f --- /dev/null +++ b/third_party/cargo/vendor/nodrop-0.1.14/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "nodrop", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.14", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/nodrop-0.1.14/Cargo.toml b/third_party/cargo/vendor/nodrop-0.1.14/Cargo.toml new file mode 100644 index 0000000..716eeda --- /dev/null +++ b/third_party/cargo/vendor/nodrop-0.1.14/Cargo.toml @@ -0,0 +1,36 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "nodrop" +version = "0.1.14" +authors = ["bluss"] +description = "A wrapper type to inhibit drop (destructor).\n\n***Deprecated: Use ManuallyDrop or MaybeUninit instead!***\n" +documentation = "https://docs.rs/nodrop/" +keywords = [] +categories = ["rust-patterns"] +license = "MIT/Apache-2.0" +repository = "https://github.com/bluss/arrayvec" +[package.metadata.release] +no-dev-version = true +tag-name = "nodrop-{{version}}" +[dependencies.nodrop-union] +version = "0.1.8" +optional = true + +[features] +default = ["std"] +std = [] +use_needs_drop = [] +use_union = ["nodrop-union"] +[badges.maintenance] +status = "deprecated" diff --git a/third_party/cargo/vendor/nodrop-0.1.14/LICENSE-APACHE b/third_party/cargo/vendor/nodrop-0.1.14/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/nodrop-0.1.14/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/nodrop-0.1.14/LICENSE-MIT b/third_party/cargo/vendor/nodrop-0.1.14/LICENSE-MIT new file mode 100644 index 0000000..2c8f27d --- /dev/null +++ b/third_party/cargo/vendor/nodrop-0.1.14/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) Ulrik Sverdrup "bluss" 2015-2017 + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/nodrop-0.1.14/README.rst b/third_party/cargo/vendor/nodrop-0.1.14/README.rst new file mode 100644 index 0000000..3886ba6 --- /dev/null +++ b/third_party/cargo/vendor/nodrop-0.1.14/README.rst @@ -0,0 +1,71 @@ + +nodrop +====== + +Recent Changes (nodrop) +----------------------- + +- 0.1.14 + + - Mark nodrop deprecated + + With the release of arrayvec 0.5, nodrop is unused. + + With the release of Rust 1.36 and MaybeUninit, nodrop has no + purpose (but for older Rust releases). + +- 0.1.13 + + - Update to include license files in the crate by @ignatenkobrain + +- 0.1.12 + + - Remove dependency on crate odds. + +- 0.1.11 + + - Remove erronous assertion in test (#77) + +- 0.1.10 + + - Update for stable ``needs_drop`` (Rust 1.21, was nightly only) + +- 0.1.9 + + - Fix issue in recent nightly where ``repr(u8)`` did not work. Use + a better way to get rid of the enum layout optimization. + +- 0.1.8 + + - Add crate feature ``use_union`` that uses untagged unions to implement NoDrop. + Finally we have an implementation without hacks, without a runtime flag, + and without an actual ``Drop`` impl (which was needed to suppress drop). + The crate feature requires nightly and is unstable. + +- 0.1.7 + + - Remove crate feature ``no_drop_flag``, because it doesn't compile on nightly + anymore. Drop flags are gone anyway! + +- 0.1.6 + + - Add feature std, which you can opt out of to use ``no_std``. + +- 0.1.5 + + - Added crate feature ``use_needs_drop`` which is a nightly-only + optimization, which skips overwriting if the inner value does not need + drop. + +License +======= + +Dual-licensed to be compatible with the Rust project. + +Licensed under the Apache License, Version 2.0 +http://www.apache.org/licenses/LICENSE-2.0 or the MIT license +http://opensource.org/licenses/MIT, at your +option. This file may not be copied, modified, or distributed +except according to those terms. + + diff --git a/third_party/cargo/vendor/nodrop-0.1.14/src/lib.rs b/third_party/cargo/vendor/nodrop-0.1.14/src/lib.rs new file mode 100644 index 0000000..a1a1547 --- /dev/null +++ b/third_party/cargo/vendor/nodrop-0.1.14/src/lib.rs @@ -0,0 +1,189 @@ +//! A wrapper type to inhibit drop (destructor). +//! +//! ***Deprecated: Use ManuallyDrop or MaybeUninit instead!*** +//! +//! The **nodrop** crate has the following cargo feature flags: +//! +//! - `std` +//! - Optional, enabled by default +//! - Use libstd +//! - `use_needs_drop` +//! - Optional +//! - Requires Rust 1.21 +//! - Use `needs_drop` to skip overwriting if not necessary +//! - `use_union` +//! - Optional +//! - Requires nightly channel +//! - Using untagged union, finally we have an implementation of `NoDrop` without hacks, +//! for example the fact that `NoDrop` never has a destructor anymore. +//! + +#![cfg_attr(not(any(test, feature="std")), no_std)] +#[cfg(not(any(test, feature="std")))] +extern crate core as std; + +#[cfg(feature = "use_union")] +extern crate nodrop_union as imp; + +pub use imp::NoDrop; + + +#[cfg(not(feature = "use_union"))] +mod imp { + use std::ptr; + use std::mem; + use std::ops::{Deref, DerefMut}; + + /// repr(u8) - Make sure the non-nullable pointer optimization does not occur! + #[repr(u8)] + enum Flag { + Alive(T), + // Dummy u8 field below, again to beat the enum layout opt + Dropped(u8), + } + + + /// A type holding **T** that will not call its destructor on drop + pub struct NoDrop(Flag); + + impl NoDrop { + /// Create a new **NoDrop**. + #[inline] + pub fn new(value: T) -> NoDrop { + NoDrop(Flag::Alive(value)) + } + + /// Extract the inner value. + /// + /// Once extracted, the value can of course drop again. + #[inline] + pub fn into_inner(mut self) -> T { + let inner = unsafe { + ptr::read(&mut *self) + }; + // skip Drop, so we don't even have to overwrite + mem::forget(self); + inner + } + } + + #[cfg(not(feature = "use_needs_drop"))] + #[inline] + fn needs_drop() -> bool { + true + } + + #[cfg(feature = "use_needs_drop")] + #[inline] + fn needs_drop() -> bool { + unsafe { + ::std::mem::needs_drop::() + } + } + + impl Drop for NoDrop { + fn drop(&mut self) { + if needs_drop::() { + // inhibit drop + unsafe { + ptr::write(&mut self.0, Flag::Dropped(0)); + } + } + } + } + + impl Deref for NoDrop { + type Target = T; + + // Use type invariant, always Flag::Alive. + #[inline] + fn deref(&self) -> &T { + match self.0 { + Flag::Alive(ref inner) => inner, + _ => unsafe { debug_assert_unreachable() } + } + } + } + + impl DerefMut for NoDrop { + // Use type invariant, always Flag::Alive. + #[inline] + fn deref_mut(&mut self) -> &mut T { + match self.0 { + Flag::Alive(ref mut inner) => inner, + _ => unsafe { debug_assert_unreachable() } + } + } + } + + #[cfg(test)] + #[test] + fn test_no_nonnullable_opt() { + // Make sure `Flag` does not apply the non-nullable pointer optimization + // as Option would do. + assert!(mem::size_of::>() > mem::size_of::<&i32>()); + assert!(mem::size_of::>>() > mem::size_of::>()); + } + + // copying this code saves us microcrate deps + #[inline] + unsafe fn debug_assert_unreachable() -> ! { + debug_assert!(false, "Reached unreachable section: this is a bug!"); + enum Void { } + match *(1 as *const Void) { } + } +} + +#[cfg(test)] +mod tests { + use super::NoDrop; + + #[test] + fn test_drop() { + use std::cell::Cell; + + let flag = &Cell::new(0); + + struct Bump<'a>(&'a Cell); + + impl<'a> Drop for Bump<'a> { + fn drop(&mut self) { + let n = self.0.get(); + self.0.set(n + 1); + } + } + + { + let _ = NoDrop::new([Bump(flag), Bump(flag)]); + } + assert_eq!(flag.get(), 0); + + // test something with the nullable pointer optimization + flag.set(0); + + { + let mut array = NoDrop::new(Vec::new()); + array.push(vec![Bump(flag)]); + array.push(vec![Bump(flag), Bump(flag)]); + array.push(vec![]); + array.push(vec![Bump(flag)]); + drop(array.pop()); + assert_eq!(flag.get(), 1); + drop(array.pop()); + assert_eq!(flag.get(), 1); + drop(array.pop()); + assert_eq!(flag.get(), 3); + } + + // last one didn't drop. + assert_eq!(flag.get(), 3); + + flag.set(0); + { + let array = NoDrop::new(Bump(flag)); + array.into_inner(); + assert_eq!(flag.get(), 1); + } + assert_eq!(flag.get(), 1); + } +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/.cargo-checksum.json b/third_party/cargo/vendor/num-traits-0.2.11/.cargo-checksum.json new file mode 100644 index 0000000..6d5d81b --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"6335f97bb03628277fae9c102661c705a81d4345d39cc604c5c00fe3b11afbfd","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"b442afb73953744a9d2134442845d3e960984ac5be2a058e5064ae851624d67f","RELEASES.md":"3d7bcef2c71d1765572e907ad010411c4737a3d169ae4381beb29d8c5e0076db","build.rs":"b4b2d0df90ca7570a339ca4d84a72e4ef00d9dced8927350424e666790c752d7","src/bounds.rs":"4fbc6bf3550e4da7ef55c9eb96466c6e0aee7f7542d7c85cfd742f16e3b4729f","src/cast.rs":"2eae0873cbe11fa0d1a012e304f48dea6a0802c0ee738dc25683779cf15b18fb","src/float.rs":"30d335615c0b06c31a33142b6af72e453c53c156007f1c219ffdc1d75dee6950","src/identities.rs":"5b6238ebd52e1fadd5b405bc40ad81e45346bcb1c4b46cf1f0496a30be7c9bc4","src/int.rs":"bbc014a02998848170430abf60ab80fa46d7835be3a5e8bf7d28e1c5318068ae","src/lib.rs":"beb207aa3f791811b043d7aa0daa34a2f8f3a52e0555bda8eb32e3359203a129","src/macros.rs":"b589a98c2468ca98131c641a058601964c4e82d75129b1c16fdc17aca8779eca","src/ops/checked.rs":"b6dfae21fe1a5ce41e92074c57d204284975ec56d45e63cac5f0136b8c3643b4","src/ops/inv.rs":"dd80b9bd48d815f17855a25842287942317fa49d1fdcdd655b61bd20ef927cda","src/ops/mod.rs":"036b2a1900dc8e7295a91060e660184b2bd98f33b5db81a62b08cf8d3df726cf","src/ops/mul_add.rs":"368bdebb40b16f3b4b85cf50235954268ff601ec7a458a3a83fe433f47f86f6d","src/ops/saturating.rs":"81c34038ec88fe49f4286e6e1213a1da831c5e66caac651f0a61506a4534c9ce","src/ops/wrapping.rs":"8d334dd2b8128e640bff6c3e93ea301182241987b3ed1fc158268292827bbd0c","src/pow.rs":"9f78cb9c4d5987b59e16f4141723a33ff689781cc352f357b0cc0111d22cde3a","src/real.rs":"b5115bb2cfb752a59426bb3fcbabf9cff15521a00a3f8b5ef4dfc0b0b31bb1f4","src/sign.rs":"81b1116300b5787546852d9d04f0375fa24342f85c34f5bc1ce5360b53fa411a","tests/cast.rs":"2c4b4f2185ec0d687e1bde292731dbc5efec527ab393478b5adf26f6e1352231"},"package":"c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"} \ No newline at end of file diff --git a/third_party/cargo/vendor/num-traits-0.2.11/BUILD b/third_party/cargo/vendor/num-traits-0.2.11/BUILD new file mode 100644 index 0000000..3f1c3fa --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/BUILD @@ -0,0 +1,46 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted +# Unsupported target "cast" with type "test" omitted + +rust_library( + name = "num_traits", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.2.11", + crate_features = [ + "default", + "std", + ], +) + diff --git a/third_party/cargo/vendor/num-traits-0.2.11/Cargo.toml b/third_party/cargo/vendor/num-traits-0.2.11/Cargo.toml new file mode 100644 index 0000000..a7bd387 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/Cargo.toml @@ -0,0 +1,38 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "num-traits" +version = "0.2.11" +authors = ["The Rust Project Developers"] +build = "build.rs" +exclude = ["/ci/*", "/.travis.yml", "/bors.toml"] +description = "Numeric traits for generic mathematics" +homepage = "https://github.com/rust-num/num-traits" +documentation = "https://docs.rs/num-traits" +readme = "README.md" +keywords = ["mathematics", "numerics"] +categories = ["algorithms", "science", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-num/num-traits" +[package.metadata.docs.rs] +features = ["std"] +[dependencies.libm] +version = "0.2.0" +optional = true +[build-dependencies.autocfg] +version = "1" + +[features] +default = ["std"] +i128 = [] +std = [] diff --git a/third_party/cargo/vendor/num-traits-0.2.11/LICENSE-APACHE b/third_party/cargo/vendor/num-traits-0.2.11/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/num-traits-0.2.11/LICENSE-MIT b/third_party/cargo/vendor/num-traits-0.2.11/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/num-traits-0.2.11/README.md b/third_party/cargo/vendor/num-traits-0.2.11/README.md new file mode 100644 index 0000000..43335b1 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/README.md @@ -0,0 +1,54 @@ +# num-traits + +[![crate](https://img.shields.io/crates/v/num-traits.svg)](https://crates.io/crates/num-traits) +[![documentation](https://docs.rs/num-traits/badge.svg)](https://docs.rs/num-traits) +![minimum rustc 1.8](https://img.shields.io/badge/rustc-1.8+-red.svg) +[![Travis status](https://travis-ci.org/rust-num/num-traits.svg?branch=master)](https://travis-ci.org/rust-num/num-traits) + +Numeric traits for generic mathematics in Rust. + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +num-traits = "0.2" +``` + +and this to your crate root: + +```rust +extern crate num_traits; +``` + +## Features + +This crate can be used without the standard library (`#![no_std]`) by disabling +the default `std` feature. Use this in `Cargo.toml`: + +```toml +[dependencies.num-traits] +version = "0.2" +default-features = false +# features = ["libm"] # <--- Uncomment if you wish to use `Float` and `Real` without `std` +``` + +The `Float` and `Real` traits are only available when either `std` or `libm` is enabled. +The `libm` feature is only available with Rust 1.31 and later ([see PR #99](https://github.com/rust-num/num-traits/pull/99)). + +The `FloatCore` trait is always available. `MulAdd` and `MulAddAssign` for `f32` +and `f64` also require `std` or `libm`, as do implementations of signed and floating- +point exponents in `Pow`. + +Implementations for `i128` and `u128` are only available with Rust 1.26 and +later. The build script automatically detects this, but you can make it +mandatory by enabling the `i128` crate feature. + +## Releases + +Release notes are available in [RELEASES.md](RELEASES.md). + +## Compatibility + +The `num-traits` crate is tested for rustc 1.8 and greater. diff --git a/third_party/cargo/vendor/num-traits-0.2.11/RELEASES.md b/third_party/cargo/vendor/num-traits-0.2.11/RELEASES.md new file mode 100644 index 0000000..6d1803e --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/RELEASES.md @@ -0,0 +1,188 @@ +# Release 0.2.11 (2020-01-09) + +- [Added the full circle constant τ as `FloatConst::TAU`][145]. +- [Updated the `autocfg` build dependency to 1.0][148]. + +**Contributors**: @cuviper, @m-ou-se + +[145]: https://github.com/rust-num/num-traits/pull/145 +[148]: https://github.com/rust-num/num-traits/pull/148 + +# Release 0.2.10 (2019-11-22) + +- [Updated the `libm` dependency to 0.2][144]. + +**Contributors**: @CryZe + +[144]: https://github.com/rust-num/num-traits/pull/144 + +# Release 0.2.9 (2019-11-12) + +- [A new optional `libm` dependency][99] enables the `Float` and `Real` traits + in `no_std` builds. +- [The new `clamp_min` and `clamp_max`][122] limit minimum and maximum values + while preserving input `NAN`s. +- [Fixed a panic in floating point `from_str_radix` on invalid signs][126]. +- Miscellaneous documentation updates. + +**Contributors**: @cuviper, @dingelish, @HeroicKatora, @jturner314, @ocstl, +@Shnatsel, @termoshtt, @waywardmonkeys, @yoanlcq + +[99]: https://github.com/rust-num/num-traits/pull/99 +[122]: https://github.com/rust-num/num-traits/pull/122 +[126]: https://github.com/rust-num/num-traits/pull/126 + +# Release 0.2.8 (2019-05-21) + +- [Fixed feature detection on `no_std` targets][116]. + +**Contributors**: @cuviper + +[116]: https://github.com/rust-num/num-traits/pull/116 + +# Release 0.2.7 (2019-05-20) + +- [Documented when `CheckedShl` and `CheckedShr` return `None`][90]. +- [The new `Zero::set_zero` and `One::set_one`][104] will set values to their + identities in place, possibly optimized better than direct assignment. +- [Documented general features and intentions of `PrimInt`][108]. + +**Contributors**: @cuviper, @dvdhrm, @ignatenkobrain, @lcnr, @samueltardieu + +[90]: https://github.com/rust-num/num-traits/pull/90 +[104]: https://github.com/rust-num/num-traits/pull/104 +[108]: https://github.com/rust-num/num-traits/pull/108 + +# Release 0.2.6 (2018-09-13) + +- [Documented that `pow(0, 0)` returns `1`][79]. Mathematically, this is not + strictly defined, but the current behavior is a pragmatic choice that has + precedent in Rust `core` for the primitives and in many other languages. +- [The new `WrappingShl` and `WrappingShr` traits][81] will wrap the shift count + if it exceeds the bit size of the type. + +**Contributors**: @cuviper, @edmccard, @meltinglava + +[79]: https://github.com/rust-num/num-traits/pull/79 +[81]: https://github.com/rust-num/num-traits/pull/81 + +# Release 0.2.5 (2018-06-20) + +- [Documentation for `mul_add` now clarifies that it's not always faster.][70] +- [The default methods in `FromPrimitive` and `ToPrimitive` are more robust.][73] + +**Contributors**: @cuviper, @frewsxcv + +[70]: https://github.com/rust-num/num-traits/pull/70 +[73]: https://github.com/rust-num/num-traits/pull/73 + +# Release 0.2.4 (2018-05-11) + +- [Support for 128-bit integers is now automatically detected and enabled.][69] + Setting the `i128` crate feature now causes the build script to panic if such + support is not detected. + +**Contributors**: @cuviper + +[69]: https://github.com/rust-num/num-traits/pull/69 + +# Release 0.2.3 (2018-05-10) + +- [The new `CheckedNeg` and `CheckedRem` traits][63] perform checked `Neg` and + `Rem`, returning `Some(output)` or `None` on overflow. +- [The `no_std` implementation of `FloatCore::to_degrees` for `f32`][61] now + uses a constant for greater accuracy, mirroring [rust#47919]. (With `std` it + just calls the inherent `f32::to_degrees` in the standard library.) +- [The new `MulAdd` and `MulAddAssign` traits][59] perform a fused multiply- + add. For integer types this is just a convenience, but for floating point + types this produces a more accurate result than the separate operations. +- [All applicable traits are now implemented for 128-bit integers][60] starting + with Rust 1.26, enabled by the new `i128` crate feature. The `FromPrimitive` + and `ToPrimitive` traits now also have corresponding 128-bit methods, which + default to converting via 64-bit integers for compatibility. + +**Contributors**: @cuviper, @LEXUGE, @regexident, @vks + +[59]: https://github.com/rust-num/num-traits/pull/59 +[60]: https://github.com/rust-num/num-traits/pull/60 +[61]: https://github.com/rust-num/num-traits/pull/61 +[63]: https://github.com/rust-num/num-traits/pull/63 +[rust#47919]: https://github.com/rust-lang/rust/pull/47919 + +# Release 0.2.2 (2018-03-18) + +- [Casting from floating point to integers now returns `None` on overflow][52], + avoiding [rustc's undefined behavior][rust-10184]. This applies to the `cast` + function and the traits `NumCast`, `FromPrimitive`, and `ToPrimitive`. + +**Contributors**: @apopiak, @cuviper, @dbarella + +[52]: https://github.com/rust-num/num-traits/pull/52 +[rust-10184]: https://github.com/rust-lang/rust/issues/10184 + + +# Release 0.2.1 (2018-03-01) + +- [The new `FloatCore` trait][32] offers a subset of `Float` for `#![no_std]` use. + [This includes everything][41] except the transcendental functions and FMA. +- [The new `Inv` trait][37] returns the multiplicative inverse, or reciprocal. +- [The new `Pow` trait][37] performs exponentiation, much like the existing `pow` + function, but with generic exponent types. +- [The new `One::is_one` method][39] tests if a value equals 1. Implementers + should override this method if there's a more efficient way to check for 1, + rather than comparing with a temporary `one()`. + +**Contributors**: @clarcharr, @cuviper, @vks + +[32]: https://github.com/rust-num/num-traits/pull/32 +[37]: https://github.com/rust-num/num-traits/pull/37 +[39]: https://github.com/rust-num/num-traits/pull/39 +[41]: https://github.com/rust-num/num-traits/pull/41 + + +# Release 0.2.0 (2018-02-06) + +- **breaking change**: [There is now a `std` feature][30], enabled by default, along + with the implication that building *without* this feature makes this a + `#![no_std]` crate. + - The `Float` and `Real` traits are only available when `std` is enabled. + - Otherwise, the API is unchanged, and num-traits 0.1.43 now re-exports its + items from num-traits 0.2 for compatibility (the [semver-trick]). + +**Contributors**: @cuviper, @termoshtt, @vks + +[semver-trick]: https://github.com/dtolnay/semver-trick +[30]: https://github.com/rust-num/num-traits/pull/30 + + +# Release 0.1.43 (2018-02-06) + +- All items are now [re-exported from num-traits 0.2][31] for compatibility. + +[31]: https://github.com/rust-num/num-traits/pull/31 + + +# Release 0.1.42 (2018-01-22) + +- [num-traits now has its own source repository][num-356] at [rust-num/num-traits][home]. +- [`ParseFloatError` now implements `Display`][22]. +- [The new `AsPrimitive` trait][17] implements generic casting with the `as` operator. +- [The new `CheckedShl` and `CheckedShr` traits][21] implement generic + support for the `checked_shl` and `checked_shr` methods on primitive integers. +- [The new `Real` trait][23] offers a subset of `Float` functionality that may be applicable to more + types, with a blanket implementation for all existing `T: Float` types. + +Thanks to @cuviper, @Enet4, @fabianschuiki, @svartalf, and @yoanlcq for their contributions! + +[home]: https://github.com/rust-num/num-traits +[num-356]: https://github.com/rust-num/num/pull/356 +[17]: https://github.com/rust-num/num-traits/pull/17 +[21]: https://github.com/rust-num/num-traits/pull/21 +[22]: https://github.com/rust-num/num-traits/pull/22 +[23]: https://github.com/rust-num/num-traits/pull/23 + + +# Prior releases + +No prior release notes were kept. Thanks all the same to the many +contributors that have made this crate what it is! diff --git a/third_party/cargo/vendor/num-traits-0.2.11/build.rs b/third_party/cargo/vendor/num-traits-0.2.11/build.rs new file mode 100644 index 0000000..e483c15 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/build.rs @@ -0,0 +1,14 @@ +extern crate autocfg; + +use std::env; + +fn main() { + let ac = autocfg::new(); + if ac.probe_type("i128") { + println!("cargo:rustc-cfg=has_i128"); + } else if env::var_os("CARGO_FEATURE_I128").is_some() { + panic!("i128 support was not detected!"); + } + + autocfg::rerun_path("build.rs"); +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/bounds.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/bounds.rs new file mode 100644 index 0000000..c9ff749 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/bounds.rs @@ -0,0 +1,127 @@ +use core::num::Wrapping; +use core::{f32, f64}; +#[cfg(has_i128)] +use core::{i128, u128}; +use core::{i16, i32, i64, i8, isize}; +use core::{u16, u32, u64, u8, usize}; + +/// Numbers which have upper and lower bounds +pub trait Bounded { + // FIXME (#5527): These should be associated constants + /// returns the smallest finite number this type can represent + fn min_value() -> Self; + /// returns the largest finite number this type can represent + fn max_value() -> Self; +} + +macro_rules! bounded_impl { + ($t:ty, $min:expr, $max:expr) => { + impl Bounded for $t { + #[inline] + fn min_value() -> $t { + $min + } + + #[inline] + fn max_value() -> $t { + $max + } + } + }; +} + +bounded_impl!(usize, usize::MIN, usize::MAX); +bounded_impl!(u8, u8::MIN, u8::MAX); +bounded_impl!(u16, u16::MIN, u16::MAX); +bounded_impl!(u32, u32::MIN, u32::MAX); +bounded_impl!(u64, u64::MIN, u64::MAX); +#[cfg(has_i128)] +bounded_impl!(u128, u128::MIN, u128::MAX); + +bounded_impl!(isize, isize::MIN, isize::MAX); +bounded_impl!(i8, i8::MIN, i8::MAX); +bounded_impl!(i16, i16::MIN, i16::MAX); +bounded_impl!(i32, i32::MIN, i32::MAX); +bounded_impl!(i64, i64::MIN, i64::MAX); +#[cfg(has_i128)] +bounded_impl!(i128, i128::MIN, i128::MAX); + +impl Bounded for Wrapping { + fn min_value() -> Self { + Wrapping(T::min_value()) + } + fn max_value() -> Self { + Wrapping(T::max_value()) + } +} + +bounded_impl!(f32, f32::MIN, f32::MAX); + +macro_rules! for_each_tuple_ { + ( $m:ident !! ) => ( + $m! { } + ); + ( $m:ident !! $h:ident, $($t:ident,)* ) => ( + $m! { $h $($t)* } + for_each_tuple_! { $m !! $($t,)* } + ); +} +macro_rules! for_each_tuple { + ($m:ident) => { + for_each_tuple_! { $m !! A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, } + }; +} + +macro_rules! bounded_tuple { + ( $($name:ident)* ) => ( + impl<$($name: Bounded,)*> Bounded for ($($name,)*) { + #[inline] + fn min_value() -> Self { + ($($name::min_value(),)*) + } + #[inline] + fn max_value() -> Self { + ($($name::max_value(),)*) + } + } + ); +} + +for_each_tuple!(bounded_tuple); +bounded_impl!(f64, f64::MIN, f64::MAX); + +#[test] +fn wrapping_bounded() { + macro_rules! test_wrapping_bounded { + ($($t:ty)+) => { + $( + assert_eq!( as Bounded>::min_value().0, <$t>::min_value()); + assert_eq!( as Bounded>::max_value().0, <$t>::max_value()); + )+ + }; + } + + test_wrapping_bounded!(usize u8 u16 u32 u64 isize i8 i16 i32 i64); +} + +#[cfg(has_i128)] +#[test] +fn wrapping_bounded_i128() { + macro_rules! test_wrapping_bounded { + ($($t:ty)+) => { + $( + assert_eq!( as Bounded>::min_value().0, <$t>::min_value()); + assert_eq!( as Bounded>::max_value().0, <$t>::max_value()); + )+ + }; + } + + test_wrapping_bounded!(u128 i128); +} + +#[test] +fn wrapping_is_bounded() { + fn require_bounded(_: &T) {} + require_bounded(&Wrapping(42_u32)); + require_bounded(&Wrapping(-42)); +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/cast.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/cast.rs new file mode 100644 index 0000000..cd66ae9 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/cast.rs @@ -0,0 +1,778 @@ +use core::mem::size_of; +use core::num::Wrapping; +use core::{f32, f64}; +#[cfg(has_i128)] +use core::{i128, u128}; +use core::{i16, i32, i64, i8, isize}; +use core::{u16, u32, u64, u8, usize}; + +use float::FloatCore; + +/// A generic trait for converting a value to a number. +pub trait ToPrimitive { + /// Converts the value of `self` to an `isize`. If the value cannot be + /// represented by an `isize`, then `None` is returned. + #[inline] + fn to_isize(&self) -> Option { + self.to_i64().as_ref().and_then(ToPrimitive::to_isize) + } + + /// Converts the value of `self` to an `i8`. If the value cannot be + /// represented by an `i8`, then `None` is returned. + #[inline] + fn to_i8(&self) -> Option { + self.to_i64().as_ref().and_then(ToPrimitive::to_i8) + } + + /// Converts the value of `self` to an `i16`. If the value cannot be + /// represented by an `i16`, then `None` is returned. + #[inline] + fn to_i16(&self) -> Option { + self.to_i64().as_ref().and_then(ToPrimitive::to_i16) + } + + /// Converts the value of `self` to an `i32`. If the value cannot be + /// represented by an `i32`, then `None` is returned. + #[inline] + fn to_i32(&self) -> Option { + self.to_i64().as_ref().and_then(ToPrimitive::to_i32) + } + + /// Converts the value of `self` to an `i64`. If the value cannot be + /// represented by an `i64`, then `None` is returned. + fn to_i64(&self) -> Option; + + /// Converts the value of `self` to an `i128`. If the value cannot be + /// represented by an `i128` (`i64` under the default implementation), then + /// `None` is returned. + /// + /// This method is only available with feature `i128` enabled on Rust >= 1.26. + /// + /// The default implementation converts through `to_i64()`. Types implementing + /// this trait should override this method if they can represent a greater range. + #[inline] + #[cfg(has_i128)] + fn to_i128(&self) -> Option { + self.to_i64().map(From::from) + } + + /// Converts the value of `self` to a `usize`. If the value cannot be + /// represented by a `usize`, then `None` is returned. + #[inline] + fn to_usize(&self) -> Option { + self.to_u64().as_ref().and_then(ToPrimitive::to_usize) + } + + /// Converts the value of `self` to a `u8`. If the value cannot be + /// represented by a `u8`, then `None` is returned. + #[inline] + fn to_u8(&self) -> Option { + self.to_u64().as_ref().and_then(ToPrimitive::to_u8) + } + + /// Converts the value of `self` to a `u16`. If the value cannot be + /// represented by a `u16`, then `None` is returned. + #[inline] + fn to_u16(&self) -> Option { + self.to_u64().as_ref().and_then(ToPrimitive::to_u16) + } + + /// Converts the value of `self` to a `u32`. If the value cannot be + /// represented by a `u32`, then `None` is returned. + #[inline] + fn to_u32(&self) -> Option { + self.to_u64().as_ref().and_then(ToPrimitive::to_u32) + } + + /// Converts the value of `self` to a `u64`. If the value cannot be + /// represented by a `u64`, then `None` is returned. + fn to_u64(&self) -> Option; + + /// Converts the value of `self` to a `u128`. If the value cannot be + /// represented by a `u128` (`u64` under the default implementation), then + /// `None` is returned. + /// + /// This method is only available with feature `i128` enabled on Rust >= 1.26. + /// + /// The default implementation converts through `to_u64()`. Types implementing + /// this trait should override this method if they can represent a greater range. + #[inline] + #[cfg(has_i128)] + fn to_u128(&self) -> Option { + self.to_u64().map(From::from) + } + + /// Converts the value of `self` to an `f32`. If the value cannot be + /// represented by an `f32`, then `None` is returned. + #[inline] + fn to_f32(&self) -> Option { + self.to_f64().as_ref().and_then(ToPrimitive::to_f32) + } + + /// Converts the value of `self` to an `f64`. If the value cannot be + /// represented by an `f64`, then `None` is returned. + #[inline] + fn to_f64(&self) -> Option { + match self.to_i64() { + Some(i) => i.to_f64(), + None => self.to_u64().as_ref().and_then(ToPrimitive::to_f64), + } + } +} + +macro_rules! impl_to_primitive_int_to_int { + ($SrcT:ident : $( $(#[$cfg:meta])* fn $method:ident -> $DstT:ident ; )*) => {$( + #[inline] + $(#[$cfg])* + fn $method(&self) -> Option<$DstT> { + let min = $DstT::MIN as $SrcT; + let max = $DstT::MAX as $SrcT; + if size_of::<$SrcT>() <= size_of::<$DstT>() || (min <= *self && *self <= max) { + Some(*self as $DstT) + } else { + None + } + } + )*} +} + +macro_rules! impl_to_primitive_int_to_uint { + ($SrcT:ident : $( $(#[$cfg:meta])* fn $method:ident -> $DstT:ident ; )*) => {$( + #[inline] + $(#[$cfg])* + fn $method(&self) -> Option<$DstT> { + let max = $DstT::MAX as $SrcT; + if 0 <= *self && (size_of::<$SrcT>() <= size_of::<$DstT>() || *self <= max) { + Some(*self as $DstT) + } else { + None + } + } + )*} +} + +macro_rules! impl_to_primitive_int { + ($T:ident) => { + impl ToPrimitive for $T { + impl_to_primitive_int_to_int! { $T: + fn to_isize -> isize; + fn to_i8 -> i8; + fn to_i16 -> i16; + fn to_i32 -> i32; + fn to_i64 -> i64; + #[cfg(has_i128)] + fn to_i128 -> i128; + } + + impl_to_primitive_int_to_uint! { $T: + fn to_usize -> usize; + fn to_u8 -> u8; + fn to_u16 -> u16; + fn to_u32 -> u32; + fn to_u64 -> u64; + #[cfg(has_i128)] + fn to_u128 -> u128; + } + + #[inline] + fn to_f32(&self) -> Option { + Some(*self as f32) + } + #[inline] + fn to_f64(&self) -> Option { + Some(*self as f64) + } + } + }; +} + +impl_to_primitive_int!(isize); +impl_to_primitive_int!(i8); +impl_to_primitive_int!(i16); +impl_to_primitive_int!(i32); +impl_to_primitive_int!(i64); +#[cfg(has_i128)] +impl_to_primitive_int!(i128); + +macro_rules! impl_to_primitive_uint_to_int { + ($SrcT:ident : $( $(#[$cfg:meta])* fn $method:ident -> $DstT:ident ; )*) => {$( + #[inline] + $(#[$cfg])* + fn $method(&self) -> Option<$DstT> { + let max = $DstT::MAX as $SrcT; + if size_of::<$SrcT>() < size_of::<$DstT>() || *self <= max { + Some(*self as $DstT) + } else { + None + } + } + )*} +} + +macro_rules! impl_to_primitive_uint_to_uint { + ($SrcT:ident : $( $(#[$cfg:meta])* fn $method:ident -> $DstT:ident ; )*) => {$( + #[inline] + $(#[$cfg])* + fn $method(&self) -> Option<$DstT> { + let max = $DstT::MAX as $SrcT; + if size_of::<$SrcT>() <= size_of::<$DstT>() || *self <= max { + Some(*self as $DstT) + } else { + None + } + } + )*} +} + +macro_rules! impl_to_primitive_uint { + ($T:ident) => { + impl ToPrimitive for $T { + impl_to_primitive_uint_to_int! { $T: + fn to_isize -> isize; + fn to_i8 -> i8; + fn to_i16 -> i16; + fn to_i32 -> i32; + fn to_i64 -> i64; + #[cfg(has_i128)] + fn to_i128 -> i128; + } + + impl_to_primitive_uint_to_uint! { $T: + fn to_usize -> usize; + fn to_u8 -> u8; + fn to_u16 -> u16; + fn to_u32 -> u32; + fn to_u64 -> u64; + #[cfg(has_i128)] + fn to_u128 -> u128; + } + + #[inline] + fn to_f32(&self) -> Option { + Some(*self as f32) + } + #[inline] + fn to_f64(&self) -> Option { + Some(*self as f64) + } + } + }; +} + +impl_to_primitive_uint!(usize); +impl_to_primitive_uint!(u8); +impl_to_primitive_uint!(u16); +impl_to_primitive_uint!(u32); +impl_to_primitive_uint!(u64); +#[cfg(has_i128)] +impl_to_primitive_uint!(u128); + +macro_rules! impl_to_primitive_float_to_float { + ($SrcT:ident : $( fn $method:ident -> $DstT:ident ; )*) => {$( + #[inline] + fn $method(&self) -> Option<$DstT> { + // Only finite values that are reducing size need to worry about overflow. + if size_of::<$SrcT>() > size_of::<$DstT>() && FloatCore::is_finite(*self) { + let n = *self as f64; + if n < $DstT::MIN as f64 || n > $DstT::MAX as f64 { + return None; + } + } + // We can safely cast NaN, +-inf, and finite values in range. + Some(*self as $DstT) + } + )*} +} + +macro_rules! impl_to_primitive_float_to_signed_int { + ($f:ident : $( $(#[$cfg:meta])* fn $method:ident -> $i:ident ; )*) => {$( + #[inline] + $(#[$cfg])* + fn $method(&self) -> Option<$i> { + // Float as int truncates toward zero, so we want to allow values + // in the exclusive range `(MIN-1, MAX+1)`. + if size_of::<$f>() > size_of::<$i>() { + // With a larger size, we can represent the range exactly. + const MIN_M1: $f = $i::MIN as $f - 1.0; + const MAX_P1: $f = $i::MAX as $f + 1.0; + if *self > MIN_M1 && *self < MAX_P1 { + return Some(*self as $i); + } + } else { + // We can't represent `MIN-1` exactly, but there's no fractional part + // at this magnitude, so we can just use a `MIN` inclusive boundary. + const MIN: $f = $i::MIN as $f; + // We can't represent `MAX` exactly, but it will round up to exactly + // `MAX+1` (a power of two) when we cast it. + const MAX_P1: $f = $i::MAX as $f; + if *self >= MIN && *self < MAX_P1 { + return Some(*self as $i); + } + } + None + } + )*} +} + +macro_rules! impl_to_primitive_float_to_unsigned_int { + ($f:ident : $( $(#[$cfg:meta])* fn $method:ident -> $u:ident ; )*) => {$( + #[inline] + $(#[$cfg])* + fn $method(&self) -> Option<$u> { + // Float as int truncates toward zero, so we want to allow values + // in the exclusive range `(-1, MAX+1)`. + if size_of::<$f>() > size_of::<$u>() { + // With a larger size, we can represent the range exactly. + const MAX_P1: $f = $u::MAX as $f + 1.0; + if *self > -1.0 && *self < MAX_P1 { + return Some(*self as $u); + } + } else { + // We can't represent `MAX` exactly, but it will round up to exactly + // `MAX+1` (a power of two) when we cast it. + // (`u128::MAX as f32` is infinity, but this is still ok.) + const MAX_P1: $f = $u::MAX as $f; + if *self > -1.0 && *self < MAX_P1 { + return Some(*self as $u); + } + } + None + } + )*} +} + +macro_rules! impl_to_primitive_float { + ($T:ident) => { + impl ToPrimitive for $T { + impl_to_primitive_float_to_signed_int! { $T: + fn to_isize -> isize; + fn to_i8 -> i8; + fn to_i16 -> i16; + fn to_i32 -> i32; + fn to_i64 -> i64; + #[cfg(has_i128)] + fn to_i128 -> i128; + } + + impl_to_primitive_float_to_unsigned_int! { $T: + fn to_usize -> usize; + fn to_u8 -> u8; + fn to_u16 -> u16; + fn to_u32 -> u32; + fn to_u64 -> u64; + #[cfg(has_i128)] + fn to_u128 -> u128; + } + + impl_to_primitive_float_to_float! { $T: + fn to_f32 -> f32; + fn to_f64 -> f64; + } + } + }; +} + +impl_to_primitive_float!(f32); +impl_to_primitive_float!(f64); + +/// A generic trait for converting a number to a value. +pub trait FromPrimitive: Sized { + /// Converts an `isize` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + #[inline] + fn from_isize(n: isize) -> Option { + n.to_i64().and_then(FromPrimitive::from_i64) + } + + /// Converts an `i8` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + #[inline] + fn from_i8(n: i8) -> Option { + FromPrimitive::from_i64(From::from(n)) + } + + /// Converts an `i16` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + #[inline] + fn from_i16(n: i16) -> Option { + FromPrimitive::from_i64(From::from(n)) + } + + /// Converts an `i32` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + #[inline] + fn from_i32(n: i32) -> Option { + FromPrimitive::from_i64(From::from(n)) + } + + /// Converts an `i64` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + fn from_i64(n: i64) -> Option; + + /// Converts an `i128` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + /// + /// This method is only available with feature `i128` enabled on Rust >= 1.26. + /// + /// The default implementation converts through `from_i64()`. Types implementing + /// this trait should override this method if they can represent a greater range. + #[inline] + #[cfg(has_i128)] + fn from_i128(n: i128) -> Option { + n.to_i64().and_then(FromPrimitive::from_i64) + } + + /// Converts a `usize` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + #[inline] + fn from_usize(n: usize) -> Option { + n.to_u64().and_then(FromPrimitive::from_u64) + } + + /// Converts an `u8` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + #[inline] + fn from_u8(n: u8) -> Option { + FromPrimitive::from_u64(From::from(n)) + } + + /// Converts an `u16` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + #[inline] + fn from_u16(n: u16) -> Option { + FromPrimitive::from_u64(From::from(n)) + } + + /// Converts an `u32` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + #[inline] + fn from_u32(n: u32) -> Option { + FromPrimitive::from_u64(From::from(n)) + } + + /// Converts an `u64` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + fn from_u64(n: u64) -> Option; + + /// Converts an `u128` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + /// + /// This method is only available with feature `i128` enabled on Rust >= 1.26. + /// + /// The default implementation converts through `from_u64()`. Types implementing + /// this trait should override this method if they can represent a greater range. + #[inline] + #[cfg(has_i128)] + fn from_u128(n: u128) -> Option { + n.to_u64().and_then(FromPrimitive::from_u64) + } + + /// Converts a `f32` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + #[inline] + fn from_f32(n: f32) -> Option { + FromPrimitive::from_f64(From::from(n)) + } + + /// Converts a `f64` to return an optional value of this type. If the + /// value cannot be represented by this type, then `None` is returned. + #[inline] + fn from_f64(n: f64) -> Option { + match n.to_i64() { + Some(i) => FromPrimitive::from_i64(i), + None => n.to_u64().and_then(FromPrimitive::from_u64), + } + } +} + +macro_rules! impl_from_primitive { + ($T:ty, $to_ty:ident) => { + #[allow(deprecated)] + impl FromPrimitive for $T { + #[inline] + fn from_isize(n: isize) -> Option<$T> { + n.$to_ty() + } + #[inline] + fn from_i8(n: i8) -> Option<$T> { + n.$to_ty() + } + #[inline] + fn from_i16(n: i16) -> Option<$T> { + n.$to_ty() + } + #[inline] + fn from_i32(n: i32) -> Option<$T> { + n.$to_ty() + } + #[inline] + fn from_i64(n: i64) -> Option<$T> { + n.$to_ty() + } + #[cfg(has_i128)] + #[inline] + fn from_i128(n: i128) -> Option<$T> { + n.$to_ty() + } + + #[inline] + fn from_usize(n: usize) -> Option<$T> { + n.$to_ty() + } + #[inline] + fn from_u8(n: u8) -> Option<$T> { + n.$to_ty() + } + #[inline] + fn from_u16(n: u16) -> Option<$T> { + n.$to_ty() + } + #[inline] + fn from_u32(n: u32) -> Option<$T> { + n.$to_ty() + } + #[inline] + fn from_u64(n: u64) -> Option<$T> { + n.$to_ty() + } + #[cfg(has_i128)] + #[inline] + fn from_u128(n: u128) -> Option<$T> { + n.$to_ty() + } + + #[inline] + fn from_f32(n: f32) -> Option<$T> { + n.$to_ty() + } + #[inline] + fn from_f64(n: f64) -> Option<$T> { + n.$to_ty() + } + } + }; +} + +impl_from_primitive!(isize, to_isize); +impl_from_primitive!(i8, to_i8); +impl_from_primitive!(i16, to_i16); +impl_from_primitive!(i32, to_i32); +impl_from_primitive!(i64, to_i64); +#[cfg(has_i128)] +impl_from_primitive!(i128, to_i128); +impl_from_primitive!(usize, to_usize); +impl_from_primitive!(u8, to_u8); +impl_from_primitive!(u16, to_u16); +impl_from_primitive!(u32, to_u32); +impl_from_primitive!(u64, to_u64); +#[cfg(has_i128)] +impl_from_primitive!(u128, to_u128); +impl_from_primitive!(f32, to_f32); +impl_from_primitive!(f64, to_f64); + +macro_rules! impl_to_primitive_wrapping { + ($( $(#[$cfg:meta])* fn $method:ident -> $i:ident ; )*) => {$( + #[inline] + $(#[$cfg])* + fn $method(&self) -> Option<$i> { + (self.0).$method() + } + )*} +} + +impl ToPrimitive for Wrapping { + impl_to_primitive_wrapping! { + fn to_isize -> isize; + fn to_i8 -> i8; + fn to_i16 -> i16; + fn to_i32 -> i32; + fn to_i64 -> i64; + #[cfg(has_i128)] + fn to_i128 -> i128; + + fn to_usize -> usize; + fn to_u8 -> u8; + fn to_u16 -> u16; + fn to_u32 -> u32; + fn to_u64 -> u64; + #[cfg(has_i128)] + fn to_u128 -> u128; + + fn to_f32 -> f32; + fn to_f64 -> f64; + } +} + +macro_rules! impl_from_primitive_wrapping { + ($( $(#[$cfg:meta])* fn $method:ident ( $i:ident ); )*) => {$( + #[inline] + $(#[$cfg])* + fn $method(n: $i) -> Option { + T::$method(n).map(Wrapping) + } + )*} +} + +impl FromPrimitive for Wrapping { + impl_from_primitive_wrapping! { + fn from_isize(isize); + fn from_i8(i8); + fn from_i16(i16); + fn from_i32(i32); + fn from_i64(i64); + #[cfg(has_i128)] + fn from_i128(i128); + + fn from_usize(usize); + fn from_u8(u8); + fn from_u16(u16); + fn from_u32(u32); + fn from_u64(u64); + #[cfg(has_i128)] + fn from_u128(u128); + + fn from_f32(f32); + fn from_f64(f64); + } +} + +/// Cast from one machine scalar to another. +/// +/// # Examples +/// +/// ``` +/// # use num_traits as num; +/// let twenty: f32 = num::cast(0x14).unwrap(); +/// assert_eq!(twenty, 20f32); +/// ``` +/// +#[inline] +pub fn cast(n: T) -> Option { + NumCast::from(n) +} + +/// An interface for casting between machine scalars. +pub trait NumCast: Sized + ToPrimitive { + /// Creates a number from another value that can be converted into + /// a primitive via the `ToPrimitive` trait. If the source value cannot be + /// represented by the target type, then `None` is returned. + fn from(n: T) -> Option; +} + +macro_rules! impl_num_cast { + ($T:ty, $conv:ident) => { + impl NumCast for $T { + #[inline] + #[allow(deprecated)] + fn from(n: N) -> Option<$T> { + // `$conv` could be generated using `concat_idents!`, but that + // macro seems to be broken at the moment + n.$conv() + } + } + }; +} + +impl_num_cast!(u8, to_u8); +impl_num_cast!(u16, to_u16); +impl_num_cast!(u32, to_u32); +impl_num_cast!(u64, to_u64); +#[cfg(has_i128)] +impl_num_cast!(u128, to_u128); +impl_num_cast!(usize, to_usize); +impl_num_cast!(i8, to_i8); +impl_num_cast!(i16, to_i16); +impl_num_cast!(i32, to_i32); +impl_num_cast!(i64, to_i64); +#[cfg(has_i128)] +impl_num_cast!(i128, to_i128); +impl_num_cast!(isize, to_isize); +impl_num_cast!(f32, to_f32); +impl_num_cast!(f64, to_f64); + +impl NumCast for Wrapping { + fn from(n: U) -> Option { + T::from(n).map(Wrapping) + } +} + +/// A generic interface for casting between machine scalars with the +/// `as` operator, which admits narrowing and precision loss. +/// Implementers of this trait `AsPrimitive` should behave like a primitive +/// numeric type (e.g. a newtype around another primitive), and the +/// intended conversion must never fail. +/// +/// # Examples +/// +/// ``` +/// # use num_traits::AsPrimitive; +/// let three: i32 = (3.14159265f32).as_(); +/// assert_eq!(three, 3); +/// ``` +/// +/// # Safety +/// +/// Currently, some uses of the `as` operator are not entirely safe. +/// In particular, it is undefined behavior if: +/// +/// - A truncated floating point value cannot fit in the target integer +/// type ([#10184](https://github.com/rust-lang/rust/issues/10184)); +/// +/// ```ignore +/// # use num_traits::AsPrimitive; +/// let x: u8 = (1.04E+17).as_(); // UB +/// ``` +/// +/// - Or a floating point value does not fit in another floating +/// point type ([#15536](https://github.com/rust-lang/rust/issues/15536)). +/// +/// ```ignore +/// # use num_traits::AsPrimitive; +/// let x: f32 = (1e300f64).as_(); // UB +/// ``` +/// +pub trait AsPrimitive: 'static + Copy +where + T: 'static + Copy, +{ + /// Convert a value to another, using the `as` operator. + fn as_(self) -> T; +} + +macro_rules! impl_as_primitive { + (@ $T: ty => $(#[$cfg:meta])* impl $U: ty ) => { + $(#[$cfg])* + impl AsPrimitive<$U> for $T { + #[inline] fn as_(self) -> $U { self as $U } + } + }; + (@ $T: ty => { $( $U: ty ),* } ) => {$( + impl_as_primitive!(@ $T => impl $U); + )*}; + ($T: ty => { $( $U: ty ),* } ) => { + impl_as_primitive!(@ $T => { $( $U ),* }); + impl_as_primitive!(@ $T => { u8, u16, u32, u64, usize }); + impl_as_primitive!(@ $T => #[cfg(has_i128)] impl u128); + impl_as_primitive!(@ $T => { i8, i16, i32, i64, isize }); + impl_as_primitive!(@ $T => #[cfg(has_i128)] impl i128); + }; +} + +impl_as_primitive!(u8 => { char, f32, f64 }); +impl_as_primitive!(i8 => { f32, f64 }); +impl_as_primitive!(u16 => { f32, f64 }); +impl_as_primitive!(i16 => { f32, f64 }); +impl_as_primitive!(u32 => { f32, f64 }); +impl_as_primitive!(i32 => { f32, f64 }); +impl_as_primitive!(u64 => { f32, f64 }); +impl_as_primitive!(i64 => { f32, f64 }); +#[cfg(has_i128)] +impl_as_primitive!(u128 => { f32, f64 }); +#[cfg(has_i128)] +impl_as_primitive!(i128 => { f32, f64 }); +impl_as_primitive!(usize => { f32, f64 }); +impl_as_primitive!(isize => { f32, f64 }); +impl_as_primitive!(f32 => { f32, f64 }); +impl_as_primitive!(f64 => { f32, f64 }); +impl_as_primitive!(char => { char }); +impl_as_primitive!(bool => {}); diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/float.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/float.rs new file mode 100644 index 0000000..d4821ae --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/float.rs @@ -0,0 +1,2359 @@ +use core::mem; +use core::num::FpCategory; +use core::ops::{Add, Neg}; + +use core::f32; +use core::f64; + +use {Num, NumCast, ToPrimitive}; + +#[cfg(all(not(feature = "std"), feature = "libm"))] +use libm; + +/// Generic trait for floating point numbers that works with `no_std`. +/// +/// This trait implements a subset of the `Float` trait. +pub trait FloatCore: Num + NumCast + Neg + PartialOrd + Copy { + /// Returns positive infinity. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T) { + /// assert!(T::infinity() == x); + /// } + /// + /// check(f32::INFINITY); + /// check(f64::INFINITY); + /// ``` + fn infinity() -> Self; + + /// Returns negative infinity. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T) { + /// assert!(T::neg_infinity() == x); + /// } + /// + /// check(f32::NEG_INFINITY); + /// check(f64::NEG_INFINITY); + /// ``` + fn neg_infinity() -> Self; + + /// Returns NaN. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// + /// fn check() { + /// let n = T::nan(); + /// assert!(n != n); + /// } + /// + /// check::(); + /// check::(); + /// ``` + fn nan() -> Self; + + /// Returns `-0.0`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(n: T) { + /// let z = T::neg_zero(); + /// assert!(z.is_zero()); + /// assert!(T::one() / z == n); + /// } + /// + /// check(f32::NEG_INFINITY); + /// check(f64::NEG_INFINITY); + /// ``` + fn neg_zero() -> Self; + + /// Returns the smallest finite value that this type can represent. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T) { + /// assert!(T::min_value() == x); + /// } + /// + /// check(f32::MIN); + /// check(f64::MIN); + /// ``` + fn min_value() -> Self; + + /// Returns the smallest positive, normalized value that this type can represent. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T) { + /// assert!(T::min_positive_value() == x); + /// } + /// + /// check(f32::MIN_POSITIVE); + /// check(f64::MIN_POSITIVE); + /// ``` + fn min_positive_value() -> Self; + + /// Returns epsilon, a small positive value. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T) { + /// assert!(T::epsilon() == x); + /// } + /// + /// check(f32::EPSILON); + /// check(f64::EPSILON); + /// ``` + fn epsilon() -> Self; + + /// Returns the largest finite value that this type can represent. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T) { + /// assert!(T::max_value() == x); + /// } + /// + /// check(f32::MAX); + /// check(f64::MAX); + /// ``` + fn max_value() -> Self; + + /// Returns `true` if the number is NaN. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, p: bool) { + /// assert!(x.is_nan() == p); + /// } + /// + /// check(f32::NAN, true); + /// check(f32::INFINITY, false); + /// check(f64::NAN, true); + /// check(0.0f64, false); + /// ``` + #[inline] + fn is_nan(self) -> bool { + self != self + } + + /// Returns `true` if the number is infinite. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, p: bool) { + /// assert!(x.is_infinite() == p); + /// } + /// + /// check(f32::INFINITY, true); + /// check(f32::NEG_INFINITY, true); + /// check(f32::NAN, false); + /// check(f64::INFINITY, true); + /// check(f64::NEG_INFINITY, true); + /// check(0.0f64, false); + /// ``` + #[inline] + fn is_infinite(self) -> bool { + self == Self::infinity() || self == Self::neg_infinity() + } + + /// Returns `true` if the number is neither infinite or NaN. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, p: bool) { + /// assert!(x.is_finite() == p); + /// } + /// + /// check(f32::INFINITY, false); + /// check(f32::MAX, true); + /// check(f64::NEG_INFINITY, false); + /// check(f64::MIN_POSITIVE, true); + /// check(f64::NAN, false); + /// ``` + #[inline] + fn is_finite(self) -> bool { + !(self.is_nan() || self.is_infinite()) + } + + /// Returns `true` if the number is neither zero, infinite, subnormal or NaN. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, p: bool) { + /// assert!(x.is_normal() == p); + /// } + /// + /// check(f32::INFINITY, false); + /// check(f32::MAX, true); + /// check(f64::NEG_INFINITY, false); + /// check(f64::MIN_POSITIVE, true); + /// check(0.0f64, false); + /// ``` + #[inline] + fn is_normal(self) -> bool { + self.classify() == FpCategory::Normal + } + + /// Returns the floating point category of the number. If only one property + /// is going to be tested, it is generally faster to use the specific + /// predicate instead. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// use std::num::FpCategory; + /// + /// fn check(x: T, c: FpCategory) { + /// assert!(x.classify() == c); + /// } + /// + /// check(f32::INFINITY, FpCategory::Infinite); + /// check(f32::MAX, FpCategory::Normal); + /// check(f64::NAN, FpCategory::Nan); + /// check(f64::MIN_POSITIVE, FpCategory::Normal); + /// check(f64::MIN_POSITIVE / 2.0, FpCategory::Subnormal); + /// check(0.0f64, FpCategory::Zero); + /// ``` + fn classify(self) -> FpCategory; + + /// Returns the largest integer less than or equal to a number. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, y: T) { + /// assert!(x.floor() == y); + /// } + /// + /// check(f32::INFINITY, f32::INFINITY); + /// check(0.9f32, 0.0); + /// check(1.0f32, 1.0); + /// check(1.1f32, 1.0); + /// check(-0.0f64, 0.0); + /// check(-0.9f64, -1.0); + /// check(-1.0f64, -1.0); + /// check(-1.1f64, -2.0); + /// check(f64::MIN, f64::MIN); + /// ``` + #[inline] + fn floor(self) -> Self { + let f = self.fract(); + if f.is_nan() || f.is_zero() { + self + } else if self < Self::zero() { + self - f - Self::one() + } else { + self - f + } + } + + /// Returns the smallest integer greater than or equal to a number. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, y: T) { + /// assert!(x.ceil() == y); + /// } + /// + /// check(f32::INFINITY, f32::INFINITY); + /// check(0.9f32, 1.0); + /// check(1.0f32, 1.0); + /// check(1.1f32, 2.0); + /// check(-0.0f64, 0.0); + /// check(-0.9f64, -0.0); + /// check(-1.0f64, -1.0); + /// check(-1.1f64, -1.0); + /// check(f64::MIN, f64::MIN); + /// ``` + #[inline] + fn ceil(self) -> Self { + let f = self.fract(); + if f.is_nan() || f.is_zero() { + self + } else if self > Self::zero() { + self - f + Self::one() + } else { + self - f + } + } + + /// Returns the nearest integer to a number. Round half-way cases away from `0.0`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, y: T) { + /// assert!(x.round() == y); + /// } + /// + /// check(f32::INFINITY, f32::INFINITY); + /// check(0.4f32, 0.0); + /// check(0.5f32, 1.0); + /// check(0.6f32, 1.0); + /// check(-0.4f64, 0.0); + /// check(-0.5f64, -1.0); + /// check(-0.6f64, -1.0); + /// check(f64::MIN, f64::MIN); + /// ``` + #[inline] + fn round(self) -> Self { + let one = Self::one(); + let h = Self::from(0.5).expect("Unable to cast from 0.5"); + let f = self.fract(); + if f.is_nan() || f.is_zero() { + self + } else if self > Self::zero() { + if f < h { + self - f + } else { + self - f + one + } + } else { + if -f < h { + self - f + } else { + self - f - one + } + } + } + + /// Return the integer part of a number. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, y: T) { + /// assert!(x.trunc() == y); + /// } + /// + /// check(f32::INFINITY, f32::INFINITY); + /// check(0.9f32, 0.0); + /// check(1.0f32, 1.0); + /// check(1.1f32, 1.0); + /// check(-0.0f64, 0.0); + /// check(-0.9f64, -0.0); + /// check(-1.0f64, -1.0); + /// check(-1.1f64, -1.0); + /// check(f64::MIN, f64::MIN); + /// ``` + #[inline] + fn trunc(self) -> Self { + let f = self.fract(); + if f.is_nan() { + self + } else { + self - f + } + } + + /// Returns the fractional part of a number. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, y: T) { + /// assert!(x.fract() == y); + /// } + /// + /// check(f32::MAX, 0.0); + /// check(0.75f32, 0.75); + /// check(1.0f32, 0.0); + /// check(1.25f32, 0.25); + /// check(-0.0f64, 0.0); + /// check(-0.75f64, -0.75); + /// check(-1.0f64, 0.0); + /// check(-1.25f64, -0.25); + /// check(f64::MIN, 0.0); + /// ``` + #[inline] + fn fract(self) -> Self { + if self.is_zero() { + Self::zero() + } else { + self % Self::one() + } + } + + /// Computes the absolute value of `self`. Returns `FloatCore::nan()` if the + /// number is `FloatCore::nan()`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, y: T) { + /// assert!(x.abs() == y); + /// } + /// + /// check(f32::INFINITY, f32::INFINITY); + /// check(1.0f32, 1.0); + /// check(0.0f64, 0.0); + /// check(-0.0f64, 0.0); + /// check(-1.0f64, 1.0); + /// check(f64::MIN, f64::MAX); + /// ``` + #[inline] + fn abs(self) -> Self { + if self.is_sign_positive() { + return self; + } + if self.is_sign_negative() { + return -self; + } + Self::nan() + } + + /// Returns a number that represents the sign of `self`. + /// + /// - `1.0` if the number is positive, `+0.0` or `FloatCore::infinity()` + /// - `-1.0` if the number is negative, `-0.0` or `FloatCore::neg_infinity()` + /// - `FloatCore::nan()` if the number is `FloatCore::nan()` + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, y: T) { + /// assert!(x.signum() == y); + /// } + /// + /// check(f32::INFINITY, 1.0); + /// check(3.0f32, 1.0); + /// check(0.0f32, 1.0); + /// check(-0.0f64, -1.0); + /// check(-3.0f64, -1.0); + /// check(f64::MIN, -1.0); + /// ``` + #[inline] + fn signum(self) -> Self { + if self.is_nan() { + Self::nan() + } else if self.is_sign_negative() { + -Self::one() + } else { + Self::one() + } + } + + /// Returns `true` if `self` is positive, including `+0.0` and + /// `FloatCore::infinity()`, and since Rust 1.20 also + /// `FloatCore::nan()`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, p: bool) { + /// assert!(x.is_sign_positive() == p); + /// } + /// + /// check(f32::INFINITY, true); + /// check(f32::MAX, true); + /// check(0.0f32, true); + /// check(-0.0f64, false); + /// check(f64::NEG_INFINITY, false); + /// check(f64::MIN_POSITIVE, true); + /// check(-f64::NAN, false); + /// ``` + #[inline] + fn is_sign_positive(self) -> bool { + !self.is_sign_negative() + } + + /// Returns `true` if `self` is negative, including `-0.0` and + /// `FloatCore::neg_infinity()`, and since Rust 1.20 also + /// `-FloatCore::nan()`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, p: bool) { + /// assert!(x.is_sign_negative() == p); + /// } + /// + /// check(f32::INFINITY, false); + /// check(f32::MAX, false); + /// check(0.0f32, false); + /// check(-0.0f64, true); + /// check(f64::NEG_INFINITY, true); + /// check(f64::MIN_POSITIVE, false); + /// check(f64::NAN, false); + /// ``` + #[inline] + fn is_sign_negative(self) -> bool { + let (_, _, sign) = self.integer_decode(); + sign < 0 + } + + /// Returns the minimum of the two numbers. + /// + /// If one of the arguments is NaN, then the other argument is returned. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, y: T, min: T) { + /// assert!(x.min(y) == min); + /// } + /// + /// check(1.0f32, 2.0, 1.0); + /// check(f32::NAN, 2.0, 2.0); + /// check(1.0f64, -2.0, -2.0); + /// check(1.0f64, f64::NAN, 1.0); + /// ``` + #[inline] + fn min(self, other: Self) -> Self { + if self.is_nan() { + return other; + } + if other.is_nan() { + return self; + } + if self < other { + self + } else { + other + } + } + + /// Returns the maximum of the two numbers. + /// + /// If one of the arguments is NaN, then the other argument is returned. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, y: T, min: T) { + /// assert!(x.max(y) == min); + /// } + /// + /// check(1.0f32, 2.0, 2.0); + /// check(1.0f32, f32::NAN, 1.0); + /// check(-1.0f64, 2.0, 2.0); + /// check(-1.0f64, f64::NAN, -1.0); + /// ``` + #[inline] + fn max(self, other: Self) -> Self { + if self.is_nan() { + return other; + } + if other.is_nan() { + return self; + } + if self > other { + self + } else { + other + } + } + + /// Returns the reciprocal (multiplicative inverse) of the number. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, y: T) { + /// assert!(x.recip() == y); + /// assert!(y.recip() == x); + /// } + /// + /// check(f32::INFINITY, 0.0); + /// check(2.0f32, 0.5); + /// check(-0.25f64, -4.0); + /// check(-0.0f64, f64::NEG_INFINITY); + /// ``` + #[inline] + fn recip(self) -> Self { + Self::one() / self + } + + /// Raise a number to an integer power. + /// + /// Using this function is generally faster than using `powf` + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// + /// fn check(x: T, exp: i32, powi: T) { + /// assert!(x.powi(exp) == powi); + /// } + /// + /// check(9.0f32, 2, 81.0); + /// check(1.0f32, -2, 1.0); + /// check(10.0f64, 20, 1e20); + /// check(4.0f64, -2, 0.0625); + /// check(-1.0f64, std::i32::MIN, 1.0); + /// ``` + #[inline] + fn powi(mut self, mut exp: i32) -> Self { + if exp < 0 { + exp = exp.wrapping_neg(); + self = self.recip(); + } + // It should always be possible to convert a positive `i32` to a `usize`. + // Note, `i32::MIN` will wrap and still be negative, so we need to convert + // to `u32` without sign-extension before growing to `usize`. + super::pow(self, (exp as u32).to_usize().unwrap()) + } + + /// Converts to degrees, assuming the number is in radians. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(rad: T, deg: T) { + /// assert!(rad.to_degrees() == deg); + /// } + /// + /// check(0.0f32, 0.0); + /// check(f32::consts::PI, 180.0); + /// check(f64::consts::FRAC_PI_4, 45.0); + /// check(f64::INFINITY, f64::INFINITY); + /// ``` + fn to_degrees(self) -> Self; + + /// Converts to radians, assuming the number is in degrees. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(deg: T, rad: T) { + /// assert!(deg.to_radians() == rad); + /// } + /// + /// check(0.0f32, 0.0); + /// check(180.0, f32::consts::PI); + /// check(45.0, f64::consts::FRAC_PI_4); + /// check(f64::INFINITY, f64::INFINITY); + /// ``` + fn to_radians(self) -> Self; + + /// Returns the mantissa, base 2 exponent, and sign as integers, respectively. + /// The original number can be recovered by `sign * mantissa * 2 ^ exponent`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::float::FloatCore; + /// use std::{f32, f64}; + /// + /// fn check(x: T, m: u64, e: i16, s:i8) { + /// let (mantissa, exponent, sign) = x.integer_decode(); + /// assert_eq!(mantissa, m); + /// assert_eq!(exponent, e); + /// assert_eq!(sign, s); + /// } + /// + /// check(2.0f32, 1 << 23, -22, 1); + /// check(-2.0f32, 1 << 23, -22, -1); + /// check(f32::INFINITY, 1 << 23, 105, 1); + /// check(f64::NEG_INFINITY, 1 << 52, 972, -1); + /// ``` + fn integer_decode(self) -> (u64, i16, i8); +} + +impl FloatCore for f32 { + constant! { + infinity() -> f32::INFINITY; + neg_infinity() -> f32::NEG_INFINITY; + nan() -> f32::NAN; + neg_zero() -> -0.0; + min_value() -> f32::MIN; + min_positive_value() -> f32::MIN_POSITIVE; + epsilon() -> f32::EPSILON; + max_value() -> f32::MAX; + } + + #[inline] + fn integer_decode(self) -> (u64, i16, i8) { + integer_decode_f32(self) + } + + #[inline] + #[cfg(not(feature = "std"))] + fn classify(self) -> FpCategory { + const EXP_MASK: u32 = 0x7f800000; + const MAN_MASK: u32 = 0x007fffff; + + // Safety: this identical to the implementation of f32::to_bits(), + // which is only available starting at Rust 1.20 + let bits: u32 = unsafe { mem::transmute(self) }; + match (bits & MAN_MASK, bits & EXP_MASK) { + (0, 0) => FpCategory::Zero, + (_, 0) => FpCategory::Subnormal, + (0, EXP_MASK) => FpCategory::Infinite, + (_, EXP_MASK) => FpCategory::Nan, + _ => FpCategory::Normal, + } + } + + #[inline] + #[cfg(not(feature = "std"))] + fn to_degrees(self) -> Self { + // Use a constant for better precision. + const PIS_IN_180: f32 = 57.2957795130823208767981548141051703_f32; + self * PIS_IN_180 + } + + #[inline] + #[cfg(not(feature = "std"))] + fn to_radians(self) -> Self { + self * (f32::consts::PI / 180.0) + } + + #[cfg(feature = "std")] + forward! { + Self::is_nan(self) -> bool; + Self::is_infinite(self) -> bool; + Self::is_finite(self) -> bool; + Self::is_normal(self) -> bool; + Self::classify(self) -> FpCategory; + Self::floor(self) -> Self; + Self::ceil(self) -> Self; + Self::round(self) -> Self; + Self::trunc(self) -> Self; + Self::fract(self) -> Self; + Self::abs(self) -> Self; + Self::signum(self) -> Self; + Self::is_sign_positive(self) -> bool; + Self::is_sign_negative(self) -> bool; + Self::min(self, other: Self) -> Self; + Self::max(self, other: Self) -> Self; + Self::recip(self) -> Self; + Self::powi(self, n: i32) -> Self; + Self::to_degrees(self) -> Self; + Self::to_radians(self) -> Self; + } +} + +impl FloatCore for f64 { + constant! { + infinity() -> f64::INFINITY; + neg_infinity() -> f64::NEG_INFINITY; + nan() -> f64::NAN; + neg_zero() -> -0.0; + min_value() -> f64::MIN; + min_positive_value() -> f64::MIN_POSITIVE; + epsilon() -> f64::EPSILON; + max_value() -> f64::MAX; + } + + #[inline] + fn integer_decode(self) -> (u64, i16, i8) { + integer_decode_f64(self) + } + + #[inline] + #[cfg(not(feature = "std"))] + fn classify(self) -> FpCategory { + const EXP_MASK: u64 = 0x7ff0000000000000; + const MAN_MASK: u64 = 0x000fffffffffffff; + + // Safety: this identical to the implementation of f64::to_bits(), + // which is only available starting at Rust 1.20 + let bits: u64 = unsafe { mem::transmute(self) }; + match (bits & MAN_MASK, bits & EXP_MASK) { + (0, 0) => FpCategory::Zero, + (_, 0) => FpCategory::Subnormal, + (0, EXP_MASK) => FpCategory::Infinite, + (_, EXP_MASK) => FpCategory::Nan, + _ => FpCategory::Normal, + } + } + + #[inline] + #[cfg(not(feature = "std"))] + fn to_degrees(self) -> Self { + // The division here is correctly rounded with respect to the true + // value of 180/π. (This differs from f32, where a constant must be + // used to ensure a correctly rounded result.) + self * (180.0 / f64::consts::PI) + } + + #[inline] + #[cfg(not(feature = "std"))] + fn to_radians(self) -> Self { + self * (f64::consts::PI / 180.0) + } + + #[cfg(feature = "std")] + forward! { + Self::is_nan(self) -> bool; + Self::is_infinite(self) -> bool; + Self::is_finite(self) -> bool; + Self::is_normal(self) -> bool; + Self::classify(self) -> FpCategory; + Self::floor(self) -> Self; + Self::ceil(self) -> Self; + Self::round(self) -> Self; + Self::trunc(self) -> Self; + Self::fract(self) -> Self; + Self::abs(self) -> Self; + Self::signum(self) -> Self; + Self::is_sign_positive(self) -> bool; + Self::is_sign_negative(self) -> bool; + Self::min(self, other: Self) -> Self; + Self::max(self, other: Self) -> Self; + Self::recip(self) -> Self; + Self::powi(self, n: i32) -> Self; + Self::to_degrees(self) -> Self; + Self::to_radians(self) -> Self; + } +} + +// FIXME: these doctests aren't actually helpful, because they're using and +// testing the inherent methods directly, not going through `Float`. + +/// Generic trait for floating point numbers +/// +/// This trait is only available with the `std` feature, or with the `libm` feature otherwise. +#[cfg(any(feature = "std", feature = "libm"))] +pub trait Float: Num + Copy + NumCast + PartialOrd + Neg { + /// Returns the `NaN` value. + /// + /// ``` + /// use num_traits::Float; + /// + /// let nan: f32 = Float::nan(); + /// + /// assert!(nan.is_nan()); + /// ``` + fn nan() -> Self; + /// Returns the infinite value. + /// + /// ``` + /// use num_traits::Float; + /// use std::f32; + /// + /// let infinity: f32 = Float::infinity(); + /// + /// assert!(infinity.is_infinite()); + /// assert!(!infinity.is_finite()); + /// assert!(infinity > f32::MAX); + /// ``` + fn infinity() -> Self; + /// Returns the negative infinite value. + /// + /// ``` + /// use num_traits::Float; + /// use std::f32; + /// + /// let neg_infinity: f32 = Float::neg_infinity(); + /// + /// assert!(neg_infinity.is_infinite()); + /// assert!(!neg_infinity.is_finite()); + /// assert!(neg_infinity < f32::MIN); + /// ``` + fn neg_infinity() -> Self; + /// Returns `-0.0`. + /// + /// ``` + /// use num_traits::{Zero, Float}; + /// + /// let inf: f32 = Float::infinity(); + /// let zero: f32 = Zero::zero(); + /// let neg_zero: f32 = Float::neg_zero(); + /// + /// assert_eq!(zero, neg_zero); + /// assert_eq!(7.0f32/inf, zero); + /// assert_eq!(zero * 10.0, zero); + /// ``` + fn neg_zero() -> Self; + + /// Returns the smallest finite value that this type can represent. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let x: f64 = Float::min_value(); + /// + /// assert_eq!(x, f64::MIN); + /// ``` + fn min_value() -> Self; + + /// Returns the smallest positive, normalized value that this type can represent. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let x: f64 = Float::min_positive_value(); + /// + /// assert_eq!(x, f64::MIN_POSITIVE); + /// ``` + fn min_positive_value() -> Self; + + /// Returns epsilon, a small positive value. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let x: f64 = Float::epsilon(); + /// + /// assert_eq!(x, f64::EPSILON); + /// ``` + /// + /// # Panics + /// + /// The default implementation will panic if `f32::EPSILON` cannot + /// be cast to `Self`. + fn epsilon() -> Self { + Self::from(f32::EPSILON).expect("Unable to cast from f32::EPSILON") + } + + /// Returns the largest finite value that this type can represent. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let x: f64 = Float::max_value(); + /// assert_eq!(x, f64::MAX); + /// ``` + fn max_value() -> Self; + + /// Returns `true` if this value is `NaN` and false otherwise. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let nan = f64::NAN; + /// let f = 7.0; + /// + /// assert!(nan.is_nan()); + /// assert!(!f.is_nan()); + /// ``` + fn is_nan(self) -> bool; + + /// Returns `true` if this value is positive infinity or negative infinity and + /// false otherwise. + /// + /// ``` + /// use num_traits::Float; + /// use std::f32; + /// + /// let f = 7.0f32; + /// let inf: f32 = Float::infinity(); + /// let neg_inf: f32 = Float::neg_infinity(); + /// let nan: f32 = f32::NAN; + /// + /// assert!(!f.is_infinite()); + /// assert!(!nan.is_infinite()); + /// + /// assert!(inf.is_infinite()); + /// assert!(neg_inf.is_infinite()); + /// ``` + fn is_infinite(self) -> bool; + + /// Returns `true` if this number is neither infinite nor `NaN`. + /// + /// ``` + /// use num_traits::Float; + /// use std::f32; + /// + /// let f = 7.0f32; + /// let inf: f32 = Float::infinity(); + /// let neg_inf: f32 = Float::neg_infinity(); + /// let nan: f32 = f32::NAN; + /// + /// assert!(f.is_finite()); + /// + /// assert!(!nan.is_finite()); + /// assert!(!inf.is_finite()); + /// assert!(!neg_inf.is_finite()); + /// ``` + fn is_finite(self) -> bool; + + /// Returns `true` if the number is neither zero, infinite, + /// [subnormal][subnormal], or `NaN`. + /// + /// ``` + /// use num_traits::Float; + /// use std::f32; + /// + /// let min = f32::MIN_POSITIVE; // 1.17549435e-38f32 + /// let max = f32::MAX; + /// let lower_than_min = 1.0e-40_f32; + /// let zero = 0.0f32; + /// + /// assert!(min.is_normal()); + /// assert!(max.is_normal()); + /// + /// assert!(!zero.is_normal()); + /// assert!(!f32::NAN.is_normal()); + /// assert!(!f32::INFINITY.is_normal()); + /// // Values between `0` and `min` are Subnormal. + /// assert!(!lower_than_min.is_normal()); + /// ``` + /// [subnormal]: http://en.wikipedia.org/wiki/Denormal_number + fn is_normal(self) -> bool; + + /// Returns the floating point category of the number. If only one property + /// is going to be tested, it is generally faster to use the specific + /// predicate instead. + /// + /// ``` + /// use num_traits::Float; + /// use std::num::FpCategory; + /// use std::f32; + /// + /// let num = 12.4f32; + /// let inf = f32::INFINITY; + /// + /// assert_eq!(num.classify(), FpCategory::Normal); + /// assert_eq!(inf.classify(), FpCategory::Infinite); + /// ``` + fn classify(self) -> FpCategory; + + /// Returns the largest integer less than or equal to a number. + /// + /// ``` + /// use num_traits::Float; + /// + /// let f = 3.99; + /// let g = 3.0; + /// + /// assert_eq!(f.floor(), 3.0); + /// assert_eq!(g.floor(), 3.0); + /// ``` + fn floor(self) -> Self; + + /// Returns the smallest integer greater than or equal to a number. + /// + /// ``` + /// use num_traits::Float; + /// + /// let f = 3.01; + /// let g = 4.0; + /// + /// assert_eq!(f.ceil(), 4.0); + /// assert_eq!(g.ceil(), 4.0); + /// ``` + fn ceil(self) -> Self; + + /// Returns the nearest integer to a number. Round half-way cases away from + /// `0.0`. + /// + /// ``` + /// use num_traits::Float; + /// + /// let f = 3.3; + /// let g = -3.3; + /// + /// assert_eq!(f.round(), 3.0); + /// assert_eq!(g.round(), -3.0); + /// ``` + fn round(self) -> Self; + + /// Return the integer part of a number. + /// + /// ``` + /// use num_traits::Float; + /// + /// let f = 3.3; + /// let g = -3.7; + /// + /// assert_eq!(f.trunc(), 3.0); + /// assert_eq!(g.trunc(), -3.0); + /// ``` + fn trunc(self) -> Self; + + /// Returns the fractional part of a number. + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 3.5; + /// let y = -3.5; + /// let abs_difference_x = (x.fract() - 0.5).abs(); + /// let abs_difference_y = (y.fract() - (-0.5)).abs(); + /// + /// assert!(abs_difference_x < 1e-10); + /// assert!(abs_difference_y < 1e-10); + /// ``` + fn fract(self) -> Self; + + /// Computes the absolute value of `self`. Returns `Float::nan()` if the + /// number is `Float::nan()`. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let x = 3.5; + /// let y = -3.5; + /// + /// let abs_difference_x = (x.abs() - x).abs(); + /// let abs_difference_y = (y.abs() - (-y)).abs(); + /// + /// assert!(abs_difference_x < 1e-10); + /// assert!(abs_difference_y < 1e-10); + /// + /// assert!(f64::NAN.abs().is_nan()); + /// ``` + fn abs(self) -> Self; + + /// Returns a number that represents the sign of `self`. + /// + /// - `1.0` if the number is positive, `+0.0` or `Float::infinity()` + /// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()` + /// - `Float::nan()` if the number is `Float::nan()` + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let f = 3.5; + /// + /// assert_eq!(f.signum(), 1.0); + /// assert_eq!(f64::NEG_INFINITY.signum(), -1.0); + /// + /// assert!(f64::NAN.signum().is_nan()); + /// ``` + fn signum(self) -> Self; + + /// Returns `true` if `self` is positive, including `+0.0`, + /// `Float::infinity()`, and since Rust 1.20 also `Float::nan()`. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let neg_nan: f64 = -f64::NAN; + /// + /// let f = 7.0; + /// let g = -7.0; + /// + /// assert!(f.is_sign_positive()); + /// assert!(!g.is_sign_positive()); + /// assert!(!neg_nan.is_sign_positive()); + /// ``` + fn is_sign_positive(self) -> bool; + + /// Returns `true` if `self` is negative, including `-0.0`, + /// `Float::neg_infinity()`, and since Rust 1.20 also `-Float::nan()`. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let nan: f64 = f64::NAN; + /// + /// let f = 7.0; + /// let g = -7.0; + /// + /// assert!(!f.is_sign_negative()); + /// assert!(g.is_sign_negative()); + /// assert!(!nan.is_sign_negative()); + /// ``` + fn is_sign_negative(self) -> bool; + + /// Fused multiply-add. Computes `(self * a) + b` with only one rounding + /// error, yielding a more accurate result than an unfused multiply-add. + /// + /// Using `mul_add` can be more performant than an unfused multiply-add if + /// the target architecture has a dedicated `fma` CPU instruction. + /// + /// ``` + /// use num_traits::Float; + /// + /// let m = 10.0; + /// let x = 4.0; + /// let b = 60.0; + /// + /// // 100.0 + /// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn mul_add(self, a: Self, b: Self) -> Self; + /// Take the reciprocal (inverse) of a number, `1/x`. + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 2.0; + /// let abs_difference = (x.recip() - (1.0/x)).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn recip(self) -> Self; + + /// Raise a number to an integer power. + /// + /// Using this function is generally faster than using `powf` + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 2.0; + /// let abs_difference = (x.powi(2) - x*x).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn powi(self, n: i32) -> Self; + + /// Raise a number to a floating point power. + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 2.0; + /// let abs_difference = (x.powf(2.0) - x*x).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn powf(self, n: Self) -> Self; + + /// Take the square root of a number. + /// + /// Returns NaN if `self` is a negative number. + /// + /// ``` + /// use num_traits::Float; + /// + /// let positive = 4.0; + /// let negative = -4.0; + /// + /// let abs_difference = (positive.sqrt() - 2.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// assert!(negative.sqrt().is_nan()); + /// ``` + fn sqrt(self) -> Self; + + /// Returns `e^(self)`, (the exponential function). + /// + /// ``` + /// use num_traits::Float; + /// + /// let one = 1.0; + /// // e^1 + /// let e = one.exp(); + /// + /// // ln(e) - 1 == 0 + /// let abs_difference = (e.ln() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn exp(self) -> Self; + + /// Returns `2^(self)`. + /// + /// ``` + /// use num_traits::Float; + /// + /// let f = 2.0; + /// + /// // 2^2 - 4 == 0 + /// let abs_difference = (f.exp2() - 4.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn exp2(self) -> Self; + + /// Returns the natural logarithm of the number. + /// + /// ``` + /// use num_traits::Float; + /// + /// let one = 1.0; + /// // e^1 + /// let e = one.exp(); + /// + /// // ln(e) - 1 == 0 + /// let abs_difference = (e.ln() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn ln(self) -> Self; + + /// Returns the logarithm of the number with respect to an arbitrary base. + /// + /// ``` + /// use num_traits::Float; + /// + /// let ten = 10.0; + /// let two = 2.0; + /// + /// // log10(10) - 1 == 0 + /// let abs_difference_10 = (ten.log(10.0) - 1.0).abs(); + /// + /// // log2(2) - 1 == 0 + /// let abs_difference_2 = (two.log(2.0) - 1.0).abs(); + /// + /// assert!(abs_difference_10 < 1e-10); + /// assert!(abs_difference_2 < 1e-10); + /// ``` + fn log(self, base: Self) -> Self; + + /// Returns the base 2 logarithm of the number. + /// + /// ``` + /// use num_traits::Float; + /// + /// let two = 2.0; + /// + /// // log2(2) - 1 == 0 + /// let abs_difference = (two.log2() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn log2(self) -> Self; + + /// Returns the base 10 logarithm of the number. + /// + /// ``` + /// use num_traits::Float; + /// + /// let ten = 10.0; + /// + /// // log10(10) - 1 == 0 + /// let abs_difference = (ten.log10() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn log10(self) -> Self; + + /// Converts radians to degrees. + /// + /// ``` + /// use std::f64::consts; + /// + /// let angle = consts::PI; + /// + /// let abs_difference = (angle.to_degrees() - 180.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + #[inline] + fn to_degrees(self) -> Self { + let halfpi = Self::zero().acos(); + let ninety = Self::from(90u8).unwrap(); + self * ninety / halfpi + } + + /// Converts degrees to radians. + /// + /// ``` + /// use std::f64::consts; + /// + /// let angle = 180.0_f64; + /// + /// let abs_difference = (angle.to_radians() - consts::PI).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + #[inline] + fn to_radians(self) -> Self { + let halfpi = Self::zero().acos(); + let ninety = Self::from(90u8).unwrap(); + self * halfpi / ninety + } + + /// Returns the maximum of the two numbers. + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 1.0; + /// let y = 2.0; + /// + /// assert_eq!(x.max(y), y); + /// ``` + fn max(self, other: Self) -> Self; + + /// Returns the minimum of the two numbers. + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 1.0; + /// let y = 2.0; + /// + /// assert_eq!(x.min(y), x); + /// ``` + fn min(self, other: Self) -> Self; + + /// The positive difference of two numbers. + /// + /// * If `self <= other`: `0:0` + /// * Else: `self - other` + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 3.0; + /// let y = -3.0; + /// + /// let abs_difference_x = (x.abs_sub(1.0) - 2.0).abs(); + /// let abs_difference_y = (y.abs_sub(1.0) - 0.0).abs(); + /// + /// assert!(abs_difference_x < 1e-10); + /// assert!(abs_difference_y < 1e-10); + /// ``` + fn abs_sub(self, other: Self) -> Self; + + /// Take the cubic root of a number. + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 8.0; + /// + /// // x^(1/3) - 2 == 0 + /// let abs_difference = (x.cbrt() - 2.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn cbrt(self) -> Self; + + /// Calculate the length of the hypotenuse of a right-angle triangle given + /// legs of length `x` and `y`. + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 2.0; + /// let y = 3.0; + /// + /// // sqrt(x^2 + y^2) + /// let abs_difference = (x.hypot(y) - (x.powi(2) + y.powi(2)).sqrt()).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn hypot(self, other: Self) -> Self; + + /// Computes the sine of a number (in radians). + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let x = f64::consts::PI/2.0; + /// + /// let abs_difference = (x.sin() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn sin(self) -> Self; + + /// Computes the cosine of a number (in radians). + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let x = 2.0*f64::consts::PI; + /// + /// let abs_difference = (x.cos() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn cos(self) -> Self; + + /// Computes the tangent of a number (in radians). + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let x = f64::consts::PI/4.0; + /// let abs_difference = (x.tan() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-14); + /// ``` + fn tan(self) -> Self; + + /// Computes the arcsine of a number. Return value is in radians in + /// the range [-pi/2, pi/2] or NaN if the number is outside the range + /// [-1, 1]. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let f = f64::consts::PI / 2.0; + /// + /// // asin(sin(pi/2)) + /// let abs_difference = (f.sin().asin() - f64::consts::PI / 2.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn asin(self) -> Self; + + /// Computes the arccosine of a number. Return value is in radians in + /// the range [0, pi] or NaN if the number is outside the range + /// [-1, 1]. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let f = f64::consts::PI / 4.0; + /// + /// // acos(cos(pi/4)) + /// let abs_difference = (f.cos().acos() - f64::consts::PI / 4.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn acos(self) -> Self; + + /// Computes the arctangent of a number. Return value is in radians in the + /// range [-pi/2, pi/2]; + /// + /// ``` + /// use num_traits::Float; + /// + /// let f = 1.0; + /// + /// // atan(tan(1)) + /// let abs_difference = (f.tan().atan() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn atan(self) -> Self; + + /// Computes the four quadrant arctangent of `self` (`y`) and `other` (`x`). + /// + /// * `x = 0`, `y = 0`: `0` + /// * `x >= 0`: `arctan(y/x)` -> `[-pi/2, pi/2]` + /// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]` + /// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)` + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let pi = f64::consts::PI; + /// // All angles from horizontal right (+x) + /// // 45 deg counter-clockwise + /// let x1 = 3.0; + /// let y1 = -3.0; + /// + /// // 135 deg clockwise + /// let x2 = -3.0; + /// let y2 = 3.0; + /// + /// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0)).abs(); + /// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0).abs(); + /// + /// assert!(abs_difference_1 < 1e-10); + /// assert!(abs_difference_2 < 1e-10); + /// ``` + fn atan2(self, other: Self) -> Self; + + /// Simultaneously computes the sine and cosine of the number, `x`. Returns + /// `(sin(x), cos(x))`. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let x = f64::consts::PI/4.0; + /// let f = x.sin_cos(); + /// + /// let abs_difference_0 = (f.0 - x.sin()).abs(); + /// let abs_difference_1 = (f.1 - x.cos()).abs(); + /// + /// assert!(abs_difference_0 < 1e-10); + /// assert!(abs_difference_0 < 1e-10); + /// ``` + fn sin_cos(self) -> (Self, Self); + + /// Returns `e^(self) - 1` in a way that is accurate even if the + /// number is close to zero. + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 7.0; + /// + /// // e^(ln(7)) - 1 + /// let abs_difference = (x.ln().exp_m1() - 6.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn exp_m1(self) -> Self; + + /// Returns `ln(1+n)` (natural logarithm) more accurately than if + /// the operations were performed separately. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let x = f64::consts::E - 1.0; + /// + /// // ln(1 + (e - 1)) == ln(e) == 1 + /// let abs_difference = (x.ln_1p() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn ln_1p(self) -> Self; + + /// Hyperbolic sine function. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let e = f64::consts::E; + /// let x = 1.0; + /// + /// let f = x.sinh(); + /// // Solving sinh() at 1 gives `(e^2-1)/(2e)` + /// let g = (e*e - 1.0)/(2.0*e); + /// let abs_difference = (f - g).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn sinh(self) -> Self; + + /// Hyperbolic cosine function. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let e = f64::consts::E; + /// let x = 1.0; + /// let f = x.cosh(); + /// // Solving cosh() at 1 gives this result + /// let g = (e*e + 1.0)/(2.0*e); + /// let abs_difference = (f - g).abs(); + /// + /// // Same result + /// assert!(abs_difference < 1.0e-10); + /// ``` + fn cosh(self) -> Self; + + /// Hyperbolic tangent function. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let e = f64::consts::E; + /// let x = 1.0; + /// + /// let f = x.tanh(); + /// // Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))` + /// let g = (1.0 - e.powi(-2))/(1.0 + e.powi(-2)); + /// let abs_difference = (f - g).abs(); + /// + /// assert!(abs_difference < 1.0e-10); + /// ``` + fn tanh(self) -> Self; + + /// Inverse hyperbolic sine function. + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 1.0; + /// let f = x.sinh().asinh(); + /// + /// let abs_difference = (f - x).abs(); + /// + /// assert!(abs_difference < 1.0e-10); + /// ``` + fn asinh(self) -> Self; + + /// Inverse hyperbolic cosine function. + /// + /// ``` + /// use num_traits::Float; + /// + /// let x = 1.0; + /// let f = x.cosh().acosh(); + /// + /// let abs_difference = (f - x).abs(); + /// + /// assert!(abs_difference < 1.0e-10); + /// ``` + fn acosh(self) -> Self; + + /// Inverse hyperbolic tangent function. + /// + /// ``` + /// use num_traits::Float; + /// use std::f64; + /// + /// let e = f64::consts::E; + /// let f = e.tanh().atanh(); + /// + /// let abs_difference = (f - e).abs(); + /// + /// assert!(abs_difference < 1.0e-10); + /// ``` + fn atanh(self) -> Self; + + /// Returns the mantissa, base 2 exponent, and sign as integers, respectively. + /// The original number can be recovered by `sign * mantissa * 2 ^ exponent`. + /// + /// ``` + /// use num_traits::Float; + /// + /// let num = 2.0f32; + /// + /// // (8388608, -22, 1) + /// let (mantissa, exponent, sign) = Float::integer_decode(num); + /// let sign_f = sign as f32; + /// let mantissa_f = mantissa as f32; + /// let exponent_f = num.powf(exponent as f32); + /// + /// // 1 * 8388608 * 2^(-22) == 2 + /// let abs_difference = (sign_f * mantissa_f * exponent_f - num).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn integer_decode(self) -> (u64, i16, i8); +} + +#[cfg(feature = "std")] +macro_rules! float_impl_std { + ($T:ident $decode:ident) => { + impl Float for $T { + constant! { + nan() -> $T::NAN; + infinity() -> $T::INFINITY; + neg_infinity() -> $T::NEG_INFINITY; + neg_zero() -> -0.0; + min_value() -> $T::MIN; + min_positive_value() -> $T::MIN_POSITIVE; + epsilon() -> $T::EPSILON; + max_value() -> $T::MAX; + } + + #[inline] + #[allow(deprecated)] + fn abs_sub(self, other: Self) -> Self { + <$T>::abs_sub(self, other) + } + + #[inline] + fn integer_decode(self) -> (u64, i16, i8) { + $decode(self) + } + + forward! { + Self::is_nan(self) -> bool; + Self::is_infinite(self) -> bool; + Self::is_finite(self) -> bool; + Self::is_normal(self) -> bool; + Self::classify(self) -> FpCategory; + Self::floor(self) -> Self; + Self::ceil(self) -> Self; + Self::round(self) -> Self; + Self::trunc(self) -> Self; + Self::fract(self) -> Self; + Self::abs(self) -> Self; + Self::signum(self) -> Self; + Self::is_sign_positive(self) -> bool; + Self::is_sign_negative(self) -> bool; + Self::mul_add(self, a: Self, b: Self) -> Self; + Self::recip(self) -> Self; + Self::powi(self, n: i32) -> Self; + Self::powf(self, n: Self) -> Self; + Self::sqrt(self) -> Self; + Self::exp(self) -> Self; + Self::exp2(self) -> Self; + Self::ln(self) -> Self; + Self::log(self, base: Self) -> Self; + Self::log2(self) -> Self; + Self::log10(self) -> Self; + Self::to_degrees(self) -> Self; + Self::to_radians(self) -> Self; + Self::max(self, other: Self) -> Self; + Self::min(self, other: Self) -> Self; + Self::cbrt(self) -> Self; + Self::hypot(self, other: Self) -> Self; + Self::sin(self) -> Self; + Self::cos(self) -> Self; + Self::tan(self) -> Self; + Self::asin(self) -> Self; + Self::acos(self) -> Self; + Self::atan(self) -> Self; + Self::atan2(self, other: Self) -> Self; + Self::sin_cos(self) -> (Self, Self); + Self::exp_m1(self) -> Self; + Self::ln_1p(self) -> Self; + Self::sinh(self) -> Self; + Self::cosh(self) -> Self; + Self::tanh(self) -> Self; + Self::asinh(self) -> Self; + Self::acosh(self) -> Self; + Self::atanh(self) -> Self; + } + } + }; +} + +#[cfg(all(not(feature = "std"), feature = "libm"))] +macro_rules! float_impl_libm { + ($T:ident $decode:ident) => { + constant! { + nan() -> $T::NAN; + infinity() -> $T::INFINITY; + neg_infinity() -> $T::NEG_INFINITY; + neg_zero() -> -0.0; + min_value() -> $T::MIN; + min_positive_value() -> $T::MIN_POSITIVE; + epsilon() -> $T::EPSILON; + max_value() -> $T::MAX; + } + + #[inline] + fn integer_decode(self) -> (u64, i16, i8) { + $decode(self) + } + + #[inline] + fn fract(self) -> Self { + self - FloatCore::trunc(self) + } + + #[inline] + fn log(self, base: Self) -> Self { + self.ln() / base.ln() + } + + forward! { + FloatCore::is_nan(self) -> bool; + FloatCore::is_infinite(self) -> bool; + FloatCore::is_finite(self) -> bool; + FloatCore::is_normal(self) -> bool; + FloatCore::classify(self) -> FpCategory; + FloatCore::signum(self) -> Self; + FloatCore::is_sign_positive(self) -> bool; + FloatCore::is_sign_negative(self) -> bool; + FloatCore::recip(self) -> Self; + FloatCore::powi(self, n: i32) -> Self; + FloatCore::to_degrees(self) -> Self; + FloatCore::to_radians(self) -> Self; + FloatCore::max(self, other: Self) -> Self; + FloatCore::min(self, other: Self) -> Self; + } + }; +} + +fn integer_decode_f32(f: f32) -> (u64, i16, i8) { + // Safety: this identical to the implementation of f32::to_bits(), + // which is only available starting at Rust 1.20 + let bits: u32 = unsafe { mem::transmute(f) }; + let sign: i8 = if bits >> 31 == 0 { 1 } else { -1 }; + let mut exponent: i16 = ((bits >> 23) & 0xff) as i16; + let mantissa = if exponent == 0 { + (bits & 0x7fffff) << 1 + } else { + (bits & 0x7fffff) | 0x800000 + }; + // Exponent bias + mantissa shift + exponent -= 127 + 23; + (mantissa as u64, exponent, sign) +} + +fn integer_decode_f64(f: f64) -> (u64, i16, i8) { + // Safety: this identical to the implementation of f64::to_bits(), + // which is only available starting at Rust 1.20 + let bits: u64 = unsafe { mem::transmute(f) }; + let sign: i8 = if bits >> 63 == 0 { 1 } else { -1 }; + let mut exponent: i16 = ((bits >> 52) & 0x7ff) as i16; + let mantissa = if exponent == 0 { + (bits & 0xfffffffffffff) << 1 + } else { + (bits & 0xfffffffffffff) | 0x10000000000000 + }; + // Exponent bias + mantissa shift + exponent -= 1023 + 52; + (mantissa, exponent, sign) +} + +#[cfg(feature = "std")] +float_impl_std!(f32 integer_decode_f32); +#[cfg(feature = "std")] +float_impl_std!(f64 integer_decode_f64); + +#[cfg(all(not(feature = "std"), feature = "libm"))] +impl Float for f32 { + float_impl_libm!(f32 integer_decode_f32); + + #[inline] + #[allow(deprecated)] + fn abs_sub(self, other: Self) -> Self { + libm::fdimf(self, other) + } + #[inline] + fn floor(self) -> Self { + libm::floorf(self) + } + #[inline] + fn ceil(self) -> Self { + libm::ceilf(self) + } + #[inline] + fn round(self) -> Self { + libm::roundf(self) + } + #[inline] + fn trunc(self) -> Self { + libm::truncf(self) + } + #[inline] + fn abs(self) -> Self { + libm::fabsf(self) + } + #[inline] + fn mul_add(self, a: Self, b: Self) -> Self { + libm::fmaf(self, a, b) + } + #[inline] + fn powf(self, n: Self) -> Self { + libm::powf(self, n) + } + #[inline] + fn sqrt(self) -> Self { + libm::sqrtf(self) + } + #[inline] + fn exp(self) -> Self { + libm::expf(self) + } + #[inline] + fn exp2(self) -> Self { + libm::exp2f(self) + } + #[inline] + fn ln(self) -> Self { + libm::logf(self) + } + #[inline] + fn log2(self) -> Self { + libm::log2f(self) + } + #[inline] + fn log10(self) -> Self { + libm::log10f(self) + } + #[inline] + fn cbrt(self) -> Self { + libm::cbrtf(self) + } + #[inline] + fn hypot(self, other: Self) -> Self { + libm::hypotf(self, other) + } + #[inline] + fn sin(self) -> Self { + libm::sinf(self) + } + #[inline] + fn cos(self) -> Self { + libm::cosf(self) + } + #[inline] + fn tan(self) -> Self { + libm::tanf(self) + } + #[inline] + fn asin(self) -> Self { + libm::asinf(self) + } + #[inline] + fn acos(self) -> Self { + libm::acosf(self) + } + #[inline] + fn atan(self) -> Self { + libm::atanf(self) + } + #[inline] + fn atan2(self, other: Self) -> Self { + libm::atan2f(self, other) + } + #[inline] + fn sin_cos(self) -> (Self, Self) { + libm::sincosf(self) + } + #[inline] + fn exp_m1(self) -> Self { + libm::expm1f(self) + } + #[inline] + fn ln_1p(self) -> Self { + libm::log1pf(self) + } + #[inline] + fn sinh(self) -> Self { + libm::sinhf(self) + } + #[inline] + fn cosh(self) -> Self { + libm::coshf(self) + } + #[inline] + fn tanh(self) -> Self { + libm::tanhf(self) + } + #[inline] + fn asinh(self) -> Self { + libm::asinhf(self) + } + #[inline] + fn acosh(self) -> Self { + libm::acoshf(self) + } + #[inline] + fn atanh(self) -> Self { + libm::atanhf(self) + } +} + +#[cfg(all(not(feature = "std"), feature = "libm"))] +impl Float for f64 { + float_impl_libm!(f64 integer_decode_f64); + + #[inline] + #[allow(deprecated)] + fn abs_sub(self, other: Self) -> Self { + libm::fdim(self, other) + } + #[inline] + fn floor(self) -> Self { + libm::floor(self) + } + #[inline] + fn ceil(self) -> Self { + libm::ceil(self) + } + #[inline] + fn round(self) -> Self { + libm::round(self) + } + #[inline] + fn trunc(self) -> Self { + libm::trunc(self) + } + #[inline] + fn abs(self) -> Self { + libm::fabs(self) + } + #[inline] + fn mul_add(self, a: Self, b: Self) -> Self { + libm::fma(self, a, b) + } + #[inline] + fn powf(self, n: Self) -> Self { + libm::pow(self, n) + } + #[inline] + fn sqrt(self) -> Self { + libm::sqrt(self) + } + #[inline] + fn exp(self) -> Self { + libm::exp(self) + } + #[inline] + fn exp2(self) -> Self { + libm::exp2(self) + } + #[inline] + fn ln(self) -> Self { + libm::log(self) + } + #[inline] + fn log2(self) -> Self { + libm::log2(self) + } + #[inline] + fn log10(self) -> Self { + libm::log10(self) + } + #[inline] + fn cbrt(self) -> Self { + libm::cbrt(self) + } + #[inline] + fn hypot(self, other: Self) -> Self { + libm::hypot(self, other) + } + #[inline] + fn sin(self) -> Self { + libm::sin(self) + } + #[inline] + fn cos(self) -> Self { + libm::cos(self) + } + #[inline] + fn tan(self) -> Self { + libm::tan(self) + } + #[inline] + fn asin(self) -> Self { + libm::asin(self) + } + #[inline] + fn acos(self) -> Self { + libm::acos(self) + } + #[inline] + fn atan(self) -> Self { + libm::atan(self) + } + #[inline] + fn atan2(self, other: Self) -> Self { + libm::atan2(self, other) + } + #[inline] + fn sin_cos(self) -> (Self, Self) { + libm::sincos(self) + } + #[inline] + fn exp_m1(self) -> Self { + libm::expm1(self) + } + #[inline] + fn ln_1p(self) -> Self { + libm::log1p(self) + } + #[inline] + fn sinh(self) -> Self { + libm::sinh(self) + } + #[inline] + fn cosh(self) -> Self { + libm::cosh(self) + } + #[inline] + fn tanh(self) -> Self { + libm::tanh(self) + } + #[inline] + fn asinh(self) -> Self { + libm::asinh(self) + } + #[inline] + fn acosh(self) -> Self { + libm::acosh(self) + } + #[inline] + fn atanh(self) -> Self { + libm::atanh(self) + } +} + +macro_rules! float_const_impl { + ($(#[$doc:meta] $constant:ident,)+) => ( + #[allow(non_snake_case)] + pub trait FloatConst { + $(#[$doc] fn $constant() -> Self;)+ + #[doc = "Return the full circle constant `τ`."] + #[inline] + fn TAU() -> Self where Self: Sized + Add { + Self::PI() + Self::PI() + } + } + float_const_impl! { @float f32, $($constant,)+ } + float_const_impl! { @float f64, $($constant,)+ } + ); + (@float $T:ident, $($constant:ident,)+) => ( + impl FloatConst for $T { + constant! { + $( $constant() -> $T::consts::$constant; )+ + TAU() -> 6.28318530717958647692528676655900577; + } + } + ); +} + +float_const_impl! { + #[doc = "Return Euler’s number."] + E, + #[doc = "Return `1.0 / π`."] + FRAC_1_PI, + #[doc = "Return `1.0 / sqrt(2.0)`."] + FRAC_1_SQRT_2, + #[doc = "Return `2.0 / π`."] + FRAC_2_PI, + #[doc = "Return `2.0 / sqrt(π)`."] + FRAC_2_SQRT_PI, + #[doc = "Return `π / 2.0`."] + FRAC_PI_2, + #[doc = "Return `π / 3.0`."] + FRAC_PI_3, + #[doc = "Return `π / 4.0`."] + FRAC_PI_4, + #[doc = "Return `π / 6.0`."] + FRAC_PI_6, + #[doc = "Return `π / 8.0`."] + FRAC_PI_8, + #[doc = "Return `ln(10.0)`."] + LN_10, + #[doc = "Return `ln(2.0)`."] + LN_2, + #[doc = "Return `log10(e)`."] + LOG10_E, + #[doc = "Return `log2(e)`."] + LOG2_E, + #[doc = "Return Archimedes’ constant `π`."] + PI, + #[doc = "Return `sqrt(2.0)`."] + SQRT_2, +} + +#[cfg(test)] +mod tests { + use core::f64::consts; + + const DEG_RAD_PAIRS: [(f64, f64); 7] = [ + (0.0, 0.), + (22.5, consts::FRAC_PI_8), + (30.0, consts::FRAC_PI_6), + (45.0, consts::FRAC_PI_4), + (60.0, consts::FRAC_PI_3), + (90.0, consts::FRAC_PI_2), + (180.0, consts::PI), + ]; + + #[test] + fn convert_deg_rad() { + use float::FloatCore; + + for &(deg, rad) in &DEG_RAD_PAIRS { + assert!((FloatCore::to_degrees(rad) - deg).abs() < 1e-6); + assert!((FloatCore::to_radians(deg) - rad).abs() < 1e-6); + + let (deg, rad) = (deg as f32, rad as f32); + assert!((FloatCore::to_degrees(rad) - deg).abs() < 1e-5); + assert!((FloatCore::to_radians(deg) - rad).abs() < 1e-5); + } + } + + #[cfg(any(feature = "std", feature = "libm"))] + #[test] + fn convert_deg_rad_std() { + for &(deg, rad) in &DEG_RAD_PAIRS { + use Float; + + assert!((Float::to_degrees(rad) - deg).abs() < 1e-6); + assert!((Float::to_radians(deg) - rad).abs() < 1e-6); + + let (deg, rad) = (deg as f32, rad as f32); + assert!((Float::to_degrees(rad) - deg).abs() < 1e-5); + assert!((Float::to_radians(deg) - rad).abs() < 1e-5); + } + } + + #[test] + // This fails with the forwarded `std` implementation in Rust 1.8. + // To avoid the failure, the test is limited to `no_std` builds. + #[cfg(not(feature = "std"))] + fn to_degrees_rounding() { + use float::FloatCore; + + assert_eq!( + FloatCore::to_degrees(1_f32), + 57.2957795130823208767981548141051703 + ); + } +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/identities.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/identities.rs new file mode 100644 index 0000000..7a99566 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/identities.rs @@ -0,0 +1,206 @@ +use core::num::Wrapping; +use core::ops::{Add, Mul}; + +/// Defines an additive identity element for `Self`. +/// +/// # Laws +/// +/// ```{.text} +/// a + 0 = a ∀ a ∈ Self +/// 0 + a = a ∀ a ∈ Self +/// ``` +pub trait Zero: Sized + Add { + /// Returns the additive identity element of `Self`, `0`. + /// # Purity + /// + /// This function should return the same result at all times regardless of + /// external mutable state, for example values stored in TLS or in + /// `static mut`s. + // This cannot be an associated constant, because of bignums. + fn zero() -> Self; + + /// Sets `self` to the additive identity element of `Self`, `0`. + fn set_zero(&mut self) { + *self = Zero::zero(); + } + + /// Returns `true` if `self` is equal to the additive identity. + fn is_zero(&self) -> bool; +} + +macro_rules! zero_impl { + ($t:ty, $v:expr) => { + impl Zero for $t { + #[inline] + fn zero() -> $t { + $v + } + #[inline] + fn is_zero(&self) -> bool { + *self == $v + } + } + }; +} + +zero_impl!(usize, 0); +zero_impl!(u8, 0); +zero_impl!(u16, 0); +zero_impl!(u32, 0); +zero_impl!(u64, 0); +#[cfg(has_i128)] +zero_impl!(u128, 0); + +zero_impl!(isize, 0); +zero_impl!(i8, 0); +zero_impl!(i16, 0); +zero_impl!(i32, 0); +zero_impl!(i64, 0); +#[cfg(has_i128)] +zero_impl!(i128, 0); + +zero_impl!(f32, 0.0); +zero_impl!(f64, 0.0); + +impl Zero for Wrapping +where + Wrapping: Add>, +{ + fn is_zero(&self) -> bool { + self.0.is_zero() + } + + fn set_zero(&mut self) { + self.0.set_zero(); + } + + fn zero() -> Self { + Wrapping(T::zero()) + } +} + +/// Defines a multiplicative identity element for `Self`. +/// +/// # Laws +/// +/// ```{.text} +/// a * 1 = a ∀ a ∈ Self +/// 1 * a = a ∀ a ∈ Self +/// ``` +pub trait One: Sized + Mul { + /// Returns the multiplicative identity element of `Self`, `1`. + /// + /// # Purity + /// + /// This function should return the same result at all times regardless of + /// external mutable state, for example values stored in TLS or in + /// `static mut`s. + // This cannot be an associated constant, because of bignums. + fn one() -> Self; + + /// Sets `self` to the multiplicative identity element of `Self`, `1`. + fn set_one(&mut self) { + *self = One::one(); + } + + /// Returns `true` if `self` is equal to the multiplicative identity. + /// + /// For performance reasons, it's best to implement this manually. + /// After a semver bump, this method will be required, and the + /// `where Self: PartialEq` bound will be removed. + #[inline] + fn is_one(&self) -> bool + where + Self: PartialEq, + { + *self == Self::one() + } +} + +macro_rules! one_impl { + ($t:ty, $v:expr) => { + impl One for $t { + #[inline] + fn one() -> $t { + $v + } + #[inline] + fn is_one(&self) -> bool { + *self == $v + } + } + }; +} + +one_impl!(usize, 1); +one_impl!(u8, 1); +one_impl!(u16, 1); +one_impl!(u32, 1); +one_impl!(u64, 1); +#[cfg(has_i128)] +one_impl!(u128, 1); + +one_impl!(isize, 1); +one_impl!(i8, 1); +one_impl!(i16, 1); +one_impl!(i32, 1); +one_impl!(i64, 1); +#[cfg(has_i128)] +one_impl!(i128, 1); + +one_impl!(f32, 1.0); +one_impl!(f64, 1.0); + +impl One for Wrapping +where + Wrapping: Mul>, +{ + fn set_one(&mut self) { + self.0.set_one(); + } + + fn one() -> Self { + Wrapping(T::one()) + } +} + +// Some helper functions provided for backwards compatibility. + +/// Returns the additive identity, `0`. +#[inline(always)] +pub fn zero() -> T { + Zero::zero() +} + +/// Returns the multiplicative identity, `1`. +#[inline(always)] +pub fn one() -> T { + One::one() +} + +#[test] +fn wrapping_identities() { + macro_rules! test_wrapping_identities { + ($($t:ty)+) => { + $( + assert_eq!(zero::<$t>(), zero::>().0); + assert_eq!(one::<$t>(), one::>().0); + assert_eq!((0 as $t).is_zero(), Wrapping(0 as $t).is_zero()); + assert_eq!((1 as $t).is_zero(), Wrapping(1 as $t).is_zero()); + )+ + }; + } + + test_wrapping_identities!(isize i8 i16 i32 i64 usize u8 u16 u32 u64); +} + +#[test] +fn wrapping_is_zero() { + fn require_zero(_: &T) {} + require_zero(&Wrapping(42)); +} +#[test] +fn wrapping_is_one() { + fn require_one(_: &T) {} + require_one(&Wrapping(42)); +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/int.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/int.rs new file mode 100644 index 0000000..26d5a9a --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/int.rs @@ -0,0 +1,409 @@ +use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr}; + +use bounds::Bounded; +use ops::checked::*; +use ops::saturating::Saturating; +use {Num, NumCast}; + +/// Generic trait for primitive integers. +/// +/// The `PrimInt` trait is an abstraction over the builtin primitive integer types (e.g., `u8`, +/// `u32`, `isize`, `i128`, ...). It inherits the basic numeric traits and extends them with +/// bitwise operators and non-wrapping arithmetic. +/// +/// The trait explicitly inherits `Copy`, `Eq`, `Ord`, and `Sized`. The intention is that all +/// types implementing this trait behave like primitive types that are passed by value by default +/// and behave like builtin integers. Furthermore, the types are expected to expose the integer +/// value in binary representation and support bitwise operators. The standard bitwise operations +/// (e.g., bitwise-and, bitwise-or, right-shift, left-shift) are inherited and the trait extends +/// these with introspective queries (e.g., `PrimInt::count_ones()`, `PrimInt::leading_zeros()`), +/// bitwise combinators (e.g., `PrimInt::rotate_left()`), and endianness converters (e.g., +/// `PrimInt::to_be()`). +/// +/// All `PrimInt` types are expected to be fixed-width binary integers. The width can be queried +/// via `T::zero().count_zeros()`. The trait currently lacks a way to query the width at +/// compile-time. +/// +/// While a default implementation for all builtin primitive integers is provided, the trait is in +/// no way restricted to these. Other integer types that fulfil the requirements are free to +/// implement the trait was well. +/// +/// This trait and many of the method names originate in the unstable `core::num::Int` trait from +/// the rust standard library. The original trait was never stabilized and thus removed from the +/// standard library. +pub trait PrimInt: + Sized + + Copy + + Num + + NumCast + + Bounded + + PartialOrd + + Ord + + Eq + + Not + + BitAnd + + BitOr + + BitXor + + Shl + + Shr + + CheckedAdd + + CheckedSub + + CheckedMul + + CheckedDiv + + Saturating +{ + /// Returns the number of ones in the binary representation of `self`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0b01001100u8; + /// + /// assert_eq!(n.count_ones(), 3); + /// ``` + fn count_ones(self) -> u32; + + /// Returns the number of zeros in the binary representation of `self`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0b01001100u8; + /// + /// assert_eq!(n.count_zeros(), 5); + /// ``` + fn count_zeros(self) -> u32; + + /// Returns the number of leading zeros in the binary representation + /// of `self`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0b0101000u16; + /// + /// assert_eq!(n.leading_zeros(), 10); + /// ``` + fn leading_zeros(self) -> u32; + + /// Returns the number of trailing zeros in the binary representation + /// of `self`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0b0101000u16; + /// + /// assert_eq!(n.trailing_zeros(), 3); + /// ``` + fn trailing_zeros(self) -> u32; + + /// Shifts the bits to the left by a specified amount amount, `n`, wrapping + /// the truncated bits to the end of the resulting integer. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0x0123456789ABCDEFu64; + /// let m = 0x3456789ABCDEF012u64; + /// + /// assert_eq!(n.rotate_left(12), m); + /// ``` + fn rotate_left(self, n: u32) -> Self; + + /// Shifts the bits to the right by a specified amount amount, `n`, wrapping + /// the truncated bits to the beginning of the resulting integer. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0x0123456789ABCDEFu64; + /// let m = 0xDEF0123456789ABCu64; + /// + /// assert_eq!(n.rotate_right(12), m); + /// ``` + fn rotate_right(self, n: u32) -> Self; + + /// Shifts the bits to the left by a specified amount amount, `n`, filling + /// zeros in the least significant bits. + /// + /// This is bitwise equivalent to signed `Shl`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0x0123456789ABCDEFu64; + /// let m = 0x3456789ABCDEF000u64; + /// + /// assert_eq!(n.signed_shl(12), m); + /// ``` + fn signed_shl(self, n: u32) -> Self; + + /// Shifts the bits to the right by a specified amount amount, `n`, copying + /// the "sign bit" in the most significant bits even for unsigned types. + /// + /// This is bitwise equivalent to signed `Shr`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0xFEDCBA9876543210u64; + /// let m = 0xFFFFEDCBA9876543u64; + /// + /// assert_eq!(n.signed_shr(12), m); + /// ``` + fn signed_shr(self, n: u32) -> Self; + + /// Shifts the bits to the left by a specified amount amount, `n`, filling + /// zeros in the least significant bits. + /// + /// This is bitwise equivalent to unsigned `Shl`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0x0123456789ABCDEFi64; + /// let m = 0x3456789ABCDEF000i64; + /// + /// assert_eq!(n.unsigned_shl(12), m); + /// ``` + fn unsigned_shl(self, n: u32) -> Self; + + /// Shifts the bits to the right by a specified amount amount, `n`, filling + /// zeros in the most significant bits. + /// + /// This is bitwise equivalent to unsigned `Shr`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = -8i8; // 0b11111000 + /// let m = 62i8; // 0b00111110 + /// + /// assert_eq!(n.unsigned_shr(2), m); + /// ``` + fn unsigned_shr(self, n: u32) -> Self; + + /// Reverses the byte order of the integer. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0x0123456789ABCDEFu64; + /// let m = 0xEFCDAB8967452301u64; + /// + /// assert_eq!(n.swap_bytes(), m); + /// ``` + fn swap_bytes(self) -> Self; + + /// Convert an integer from big endian to the target's endianness. + /// + /// On big endian this is a no-op. On little endian the bytes are swapped. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0x0123456789ABCDEFu64; + /// + /// if cfg!(target_endian = "big") { + /// assert_eq!(u64::from_be(n), n) + /// } else { + /// assert_eq!(u64::from_be(n), n.swap_bytes()) + /// } + /// ``` + fn from_be(x: Self) -> Self; + + /// Convert an integer from little endian to the target's endianness. + /// + /// On little endian this is a no-op. On big endian the bytes are swapped. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0x0123456789ABCDEFu64; + /// + /// if cfg!(target_endian = "little") { + /// assert_eq!(u64::from_le(n), n) + /// } else { + /// assert_eq!(u64::from_le(n), n.swap_bytes()) + /// } + /// ``` + fn from_le(x: Self) -> Self; + + /// Convert `self` to big endian from the target's endianness. + /// + /// On big endian this is a no-op. On little endian the bytes are swapped. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0x0123456789ABCDEFu64; + /// + /// if cfg!(target_endian = "big") { + /// assert_eq!(n.to_be(), n) + /// } else { + /// assert_eq!(n.to_be(), n.swap_bytes()) + /// } + /// ``` + fn to_be(self) -> Self; + + /// Convert `self` to little endian from the target's endianness. + /// + /// On little endian this is a no-op. On big endian the bytes are swapped. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// let n = 0x0123456789ABCDEFu64; + /// + /// if cfg!(target_endian = "little") { + /// assert_eq!(n.to_le(), n) + /// } else { + /// assert_eq!(n.to_le(), n.swap_bytes()) + /// } + /// ``` + fn to_le(self) -> Self; + + /// Raises self to the power of `exp`, using exponentiation by squaring. + /// + /// # Examples + /// + /// ``` + /// use num_traits::PrimInt; + /// + /// assert_eq!(2i32.pow(4), 16); + /// ``` + fn pow(self, exp: u32) -> Self; +} + +macro_rules! prim_int_impl { + ($T:ty, $S:ty, $U:ty) => { + impl PrimInt for $T { + #[inline] + fn count_ones(self) -> u32 { + <$T>::count_ones(self) + } + + #[inline] + fn count_zeros(self) -> u32 { + <$T>::count_zeros(self) + } + + #[inline] + fn leading_zeros(self) -> u32 { + <$T>::leading_zeros(self) + } + + #[inline] + fn trailing_zeros(self) -> u32 { + <$T>::trailing_zeros(self) + } + + #[inline] + fn rotate_left(self, n: u32) -> Self { + <$T>::rotate_left(self, n) + } + + #[inline] + fn rotate_right(self, n: u32) -> Self { + <$T>::rotate_right(self, n) + } + + #[inline] + fn signed_shl(self, n: u32) -> Self { + ((self as $S) << n) as $T + } + + #[inline] + fn signed_shr(self, n: u32) -> Self { + ((self as $S) >> n) as $T + } + + #[inline] + fn unsigned_shl(self, n: u32) -> Self { + ((self as $U) << n) as $T + } + + #[inline] + fn unsigned_shr(self, n: u32) -> Self { + ((self as $U) >> n) as $T + } + + #[inline] + fn swap_bytes(self) -> Self { + <$T>::swap_bytes(self) + } + + #[inline] + fn from_be(x: Self) -> Self { + <$T>::from_be(x) + } + + #[inline] + fn from_le(x: Self) -> Self { + <$T>::from_le(x) + } + + #[inline] + fn to_be(self) -> Self { + <$T>::to_be(self) + } + + #[inline] + fn to_le(self) -> Self { + <$T>::to_le(self) + } + + #[inline] + fn pow(self, exp: u32) -> Self { + <$T>::pow(self, exp) + } + } + }; +} + +// prim_int_impl!(type, signed, unsigned); +prim_int_impl!(u8, i8, u8); +prim_int_impl!(u16, i16, u16); +prim_int_impl!(u32, i32, u32); +prim_int_impl!(u64, i64, u64); +#[cfg(has_i128)] +prim_int_impl!(u128, i128, u128); +prim_int_impl!(usize, isize, usize); +prim_int_impl!(i8, i8, u8); +prim_int_impl!(i16, i16, u16); +prim_int_impl!(i32, i32, u32); +prim_int_impl!(i64, i64, u64); +#[cfg(has_i128)] +prim_int_impl!(i128, i128, u128); +prim_int_impl!(isize, isize, usize); diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/lib.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/lib.rs new file mode 100644 index 0000000..559a18c --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/lib.rs @@ -0,0 +1,572 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Numeric traits for generic mathematics +//! +//! ## Compatibility +//! +//! The `num-traits` crate is tested for rustc 1.8 and greater. + +#![doc(html_root_url = "https://docs.rs/num-traits/0.2")] +#![deny(unconditional_recursion)] +#![no_std] +#[cfg(feature = "std")] +extern crate std; + +// Only `no_std` builds actually use `libm`. +#[cfg(all(not(feature = "std"), feature = "libm"))] +extern crate libm; + +use core::fmt; +use core::num::Wrapping; +use core::ops::{Add, Div, Mul, Rem, Sub}; +use core::ops::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign}; + +pub use bounds::Bounded; +#[cfg(any(feature = "std", feature = "libm"))] +pub use float::Float; +pub use float::FloatConst; +// pub use real::{FloatCore, Real}; // NOTE: Don't do this, it breaks `use num_traits::*;`. +pub use cast::{cast, AsPrimitive, FromPrimitive, NumCast, ToPrimitive}; +pub use identities::{one, zero, One, Zero}; +pub use int::PrimInt; +pub use ops::checked::{ + CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, CheckedShr, CheckedSub, +}; +pub use ops::inv::Inv; +pub use ops::mul_add::{MulAdd, MulAddAssign}; +pub use ops::saturating::Saturating; +pub use ops::wrapping::{WrappingAdd, WrappingMul, WrappingShl, WrappingShr, WrappingSub}; +pub use pow::{checked_pow, pow, Pow}; +pub use sign::{abs, abs_sub, signum, Signed, Unsigned}; + +#[macro_use] +mod macros; + +pub mod bounds; +pub mod cast; +pub mod float; +pub mod identities; +pub mod int; +pub mod ops; +pub mod pow; +pub mod real; +pub mod sign; + +/// The base trait for numeric types, covering `0` and `1` values, +/// comparisons, basic numeric operations, and string conversion. +pub trait Num: PartialEq + Zero + One + NumOps { + type FromStrRadixErr; + + /// Convert from a string and radix <= 36. + /// + /// # Examples + /// + /// ```rust + /// use num_traits::Num; + /// + /// let result = ::from_str_radix("27", 10); + /// assert_eq!(result, Ok(27)); + /// + /// let result = ::from_str_radix("foo", 10); + /// assert!(result.is_err()); + /// ``` + fn from_str_radix(str: &str, radix: u32) -> Result; +} + +/// The trait for types implementing basic numeric operations +/// +/// This is automatically implemented for types which implement the operators. +pub trait NumOps: + Add + + Sub + + Mul + + Div + + Rem +{ +} + +impl NumOps for T where + T: Add + + Sub + + Mul + + Div + + Rem +{ +} + +/// The trait for `Num` types which also implement numeric operations taking +/// the second operand by reference. +/// +/// This is automatically implemented for types which implement the operators. +pub trait NumRef: Num + for<'r> NumOps<&'r Self> {} +impl NumRef for T where T: Num + for<'r> NumOps<&'r T> {} + +/// The trait for references which implement numeric operations, taking the +/// second operand either by value or by reference. +/// +/// This is automatically implemented for types which implement the operators. +pub trait RefNum: NumOps + for<'r> NumOps<&'r Base, Base> {} +impl RefNum for T where T: NumOps + for<'r> NumOps<&'r Base, Base> {} + +/// The trait for types implementing numeric assignment operators (like `+=`). +/// +/// This is automatically implemented for types which implement the operators. +pub trait NumAssignOps: + AddAssign + SubAssign + MulAssign + DivAssign + RemAssign +{ +} + +impl NumAssignOps for T where + T: AddAssign + SubAssign + MulAssign + DivAssign + RemAssign +{ +} + +/// The trait for `Num` types which also implement assignment operators. +/// +/// This is automatically implemented for types which implement the operators. +pub trait NumAssign: Num + NumAssignOps {} +impl NumAssign for T where T: Num + NumAssignOps {} + +/// The trait for `NumAssign` types which also implement assignment operations +/// taking the second operand by reference. +/// +/// This is automatically implemented for types which implement the operators. +pub trait NumAssignRef: NumAssign + for<'r> NumAssignOps<&'r Self> {} +impl NumAssignRef for T where T: NumAssign + for<'r> NumAssignOps<&'r T> {} + +macro_rules! int_trait_impl { + ($name:ident for $($t:ty)*) => ($( + impl $name for $t { + type FromStrRadixErr = ::core::num::ParseIntError; + #[inline] + fn from_str_radix(s: &str, radix: u32) + -> Result + { + <$t>::from_str_radix(s, radix) + } + } + )*) +} +int_trait_impl!(Num for usize u8 u16 u32 u64 isize i8 i16 i32 i64); +#[cfg(has_i128)] +int_trait_impl!(Num for u128 i128); + +impl Num for Wrapping +where + Wrapping: Add> + + Sub> + + Mul> + + Div> + + Rem>, +{ + type FromStrRadixErr = T::FromStrRadixErr; + fn from_str_radix(str: &str, radix: u32) -> Result { + T::from_str_radix(str, radix).map(Wrapping) + } +} + +#[derive(Debug)] +pub enum FloatErrorKind { + Empty, + Invalid, +} +// FIXME: core::num::ParseFloatError is stable in 1.0, but opaque to us, +// so there's not really any way for us to reuse it. +#[derive(Debug)] +pub struct ParseFloatError { + pub kind: FloatErrorKind, +} + +impl fmt::Display for ParseFloatError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let description = match self.kind { + FloatErrorKind::Empty => "cannot parse float from empty string", + FloatErrorKind::Invalid => "invalid float literal", + }; + + description.fmt(f) + } +} + +// FIXME: The standard library from_str_radix on floats was deprecated, so we're stuck +// with this implementation ourselves until we want to make a breaking change. +// (would have to drop it from `Num` though) +macro_rules! float_trait_impl { + ($name:ident for $($t:ident)*) => ($( + impl $name for $t { + type FromStrRadixErr = ParseFloatError; + + fn from_str_radix(src: &str, radix: u32) + -> Result + { + use self::FloatErrorKind::*; + use self::ParseFloatError as PFE; + + // Special values + match src { + "inf" => return Ok(core::$t::INFINITY), + "-inf" => return Ok(core::$t::NEG_INFINITY), + "NaN" => return Ok(core::$t::NAN), + _ => {}, + } + + fn slice_shift_char(src: &str) -> Option<(char, &str)> { + let mut chars = src.chars(); + if let Some(ch) = chars.next() { + Some((ch, chars.as_str())) + } else { + None + } + } + + let (is_positive, src) = match slice_shift_char(src) { + None => return Err(PFE { kind: Empty }), + Some(('-', "")) => return Err(PFE { kind: Empty }), + Some(('-', src)) => (false, src), + Some((_, _)) => (true, src), + }; + + // The significand to accumulate + let mut sig = if is_positive { 0.0 } else { -0.0 }; + // Necessary to detect overflow + let mut prev_sig = sig; + let mut cs = src.chars().enumerate(); + // Exponent prefix and exponent index offset + let mut exp_info = None::<(char, usize)>; + + // Parse the integer part of the significand + for (i, c) in cs.by_ref() { + match c.to_digit(radix) { + Some(digit) => { + // shift significand one digit left + sig = sig * (radix as $t); + + // add/subtract current digit depending on sign + if is_positive { + sig = sig + ((digit as isize) as $t); + } else { + sig = sig - ((digit as isize) as $t); + } + + // Detect overflow by comparing to last value, except + // if we've not seen any non-zero digits. + if prev_sig != 0.0 { + if is_positive && sig <= prev_sig + { return Ok(core::$t::INFINITY); } + if !is_positive && sig >= prev_sig + { return Ok(core::$t::NEG_INFINITY); } + + // Detect overflow by reversing the shift-and-add process + if is_positive && (prev_sig != (sig - digit as $t) / radix as $t) + { return Ok(core::$t::INFINITY); } + if !is_positive && (prev_sig != (sig + digit as $t) / radix as $t) + { return Ok(core::$t::NEG_INFINITY); } + } + prev_sig = sig; + }, + None => match c { + 'e' | 'E' | 'p' | 'P' => { + exp_info = Some((c, i + 1)); + break; // start of exponent + }, + '.' => { + break; // start of fractional part + }, + _ => { + return Err(PFE { kind: Invalid }); + }, + }, + } + } + + // If we are not yet at the exponent parse the fractional + // part of the significand + if exp_info.is_none() { + let mut power = 1.0; + for (i, c) in cs.by_ref() { + match c.to_digit(radix) { + Some(digit) => { + // Decrease power one order of magnitude + power = power / (radix as $t); + // add/subtract current digit depending on sign + sig = if is_positive { + sig + (digit as $t) * power + } else { + sig - (digit as $t) * power + }; + // Detect overflow by comparing to last value + if is_positive && sig < prev_sig + { return Ok(core::$t::INFINITY); } + if !is_positive && sig > prev_sig + { return Ok(core::$t::NEG_INFINITY); } + prev_sig = sig; + }, + None => match c { + 'e' | 'E' | 'p' | 'P' => { + exp_info = Some((c, i + 1)); + break; // start of exponent + }, + _ => { + return Err(PFE { kind: Invalid }); + }, + }, + } + } + } + + // Parse and calculate the exponent + let exp = match exp_info { + Some((c, offset)) => { + let base = match c { + 'E' | 'e' if radix == 10 => 10.0, + 'P' | 'p' if radix == 16 => 2.0, + _ => return Err(PFE { kind: Invalid }), + }; + + // Parse the exponent as decimal integer + let src = &src[offset..]; + let (is_positive, exp) = match slice_shift_char(src) { + Some(('-', src)) => (false, src.parse::()), + Some(('+', src)) => (true, src.parse::()), + Some((_, _)) => (true, src.parse::()), + None => return Err(PFE { kind: Invalid }), + }; + + #[cfg(feature = "std")] + fn pow(base: $t, exp: usize) -> $t { + Float::powi(base, exp as i32) + } + // otherwise uses the generic `pow` from the root + + match (is_positive, exp) { + (true, Ok(exp)) => pow(base, exp), + (false, Ok(exp)) => 1.0 / pow(base, exp), + (_, Err(_)) => return Err(PFE { kind: Invalid }), + } + }, + None => 1.0, // no exponent + }; + + Ok(sig * exp) + } + } + )*) +} +float_trait_impl!(Num for f32 f64); + +/// A value bounded by a minimum and a maximum +/// +/// If input is less than min then this returns min. +/// If input is greater than max then this returns max. +/// Otherwise this returns input. +/// +/// **Panics** in debug mode if `!(min <= max)`. +#[inline] +pub fn clamp(input: T, min: T, max: T) -> T { + debug_assert!(min <= max, "min must be less than or equal to max"); + if input < min { + min + } else if input > max { + max + } else { + input + } +} + +/// A value bounded by a minimum value +/// +/// If input is less than min then this returns min. +/// Otherwise this returns input. +/// `clamp_min(std::f32::NAN, 1.0)` preserves `NAN` different from `f32::min(std::f32::NAN, 1.0)`. +/// +/// **Panics** in debug mode if `!(min == min)`. (This occurs if `min` is `NAN`.) +#[inline] +pub fn clamp_min(input: T, min: T) -> T { + debug_assert!(min == min, "min must not be NAN"); + if input < min { + min + } else { + input + } +} + +/// A value bounded by a maximum value +/// +/// If input is greater than max then this returns max. +/// Otherwise this returns input. +/// `clamp_max(std::f32::NAN, 1.0)` preserves `NAN` different from `f32::max(std::f32::NAN, 1.0)`. +/// +/// **Panics** in debug mode if `!(max == max)`. (This occurs if `max` is `NAN`.) +#[inline] +pub fn clamp_max(input: T, max: T) -> T { + debug_assert!(max == max, "max must not be NAN"); + if input > max { + max + } else { + input + } +} + +#[test] +fn clamp_test() { + // Int test + assert_eq!(1, clamp(1, -1, 2)); + assert_eq!(-1, clamp(-2, -1, 2)); + assert_eq!(2, clamp(3, -1, 2)); + assert_eq!(1, clamp_min(1, -1)); + assert_eq!(-1, clamp_min(-2, -1)); + assert_eq!(-1, clamp_max(1, -1)); + assert_eq!(-2, clamp_max(-2, -1)); + + // Float test + assert_eq!(1.0, clamp(1.0, -1.0, 2.0)); + assert_eq!(-1.0, clamp(-2.0, -1.0, 2.0)); + assert_eq!(2.0, clamp(3.0, -1.0, 2.0)); + assert_eq!(1.0, clamp_min(1.0, -1.0)); + assert_eq!(-1.0, clamp_min(-2.0, -1.0)); + assert_eq!(-1.0, clamp_max(1.0, -1.0)); + assert_eq!(-2.0, clamp_max(-2.0, -1.0)); + assert!(clamp(::core::f32::NAN, -1.0, 1.0).is_nan()); + assert!(clamp_min(::core::f32::NAN, 1.0).is_nan()); + assert!(clamp_max(::core::f32::NAN, 1.0).is_nan()); +} + +#[test] +#[should_panic] +#[cfg(debug_assertions)] +fn clamp_nan_min() { + clamp(0., ::core::f32::NAN, 1.); +} + +#[test] +#[should_panic] +#[cfg(debug_assertions)] +fn clamp_nan_max() { + clamp(0., -1., ::core::f32::NAN); +} + +#[test] +#[should_panic] +#[cfg(debug_assertions)] +fn clamp_nan_min_max() { + clamp(0., ::core::f32::NAN, ::core::f32::NAN); +} + +#[test] +#[should_panic] +#[cfg(debug_assertions)] +fn clamp_min_nan_min() { + clamp_min(0., ::core::f32::NAN); +} + +#[test] +#[should_panic] +#[cfg(debug_assertions)] +fn clamp_max_nan_max() { + clamp_max(0., ::core::f32::NAN); +} + +#[test] +fn from_str_radix_unwrap() { + // The Result error must impl Debug to allow unwrap() + + let i: i32 = Num::from_str_radix("0", 10).unwrap(); + assert_eq!(i, 0); + + let f: f32 = Num::from_str_radix("0.0", 10).unwrap(); + assert_eq!(f, 0.0); +} + +#[test] +fn from_str_radix_multi_byte_fail() { + // Ensure parsing doesn't panic, even on invalid sign characters + assert!(f32::from_str_radix("™0.2", 10).is_err()); + + // Even when parsing the exponent sign + assert!(f32::from_str_radix("0.2E™1", 10).is_err()); +} + +#[test] +fn wrapping_is_num() { + fn require_num(_: &T) {} + require_num(&Wrapping(42_u32)); + require_num(&Wrapping(-42)); +} + +#[test] +fn wrapping_from_str_radix() { + macro_rules! test_wrapping_from_str_radix { + ($($t:ty)+) => { + $( + for &(s, r) in &[("42", 10), ("42", 2), ("-13.0", 10), ("foo", 10)] { + let w = Wrapping::<$t>::from_str_radix(s, r).map(|w| w.0); + assert_eq!(w, <$t as Num>::from_str_radix(s, r)); + } + )+ + }; + } + + test_wrapping_from_str_radix!(usize u8 u16 u32 u64 isize i8 i16 i32 i64); +} + +#[test] +fn check_num_ops() { + fn compute(x: T, y: T) -> T { + x * y / y % y + y - y + } + assert_eq!(compute(1, 2), 1) +} + +#[test] +fn check_numref_ops() { + fn compute(x: T, y: &T) -> T { + x * y / y % y + y - y + } + assert_eq!(compute(1, &2), 1) +} + +#[test] +fn check_refnum_ops() { + fn compute(x: &T, y: T) -> T + where + for<'a> &'a T: RefNum, + { + &(&(&(&(x * y) / y) % y) + y) - y + } + assert_eq!(compute(&1, 2), 1) +} + +#[test] +fn check_refref_ops() { + fn compute(x: &T, y: &T) -> T + where + for<'a> &'a T: RefNum, + { + &(&(&(&(x * y) / y) % y) + y) - y + } + assert_eq!(compute(&1, &2), 1) +} + +#[test] +fn check_numassign_ops() { + fn compute(mut x: T, y: T) -> T { + x *= y; + x /= y; + x %= y; + x += y; + x -= y; + x + } + assert_eq!(compute(1, 2), 1) +} + +// TODO test `NumAssignRef`, but even the standard numeric types don't +// implement this yet. (see rust pr41336) diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/macros.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/macros.rs new file mode 100644 index 0000000..4330cdf --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/macros.rs @@ -0,0 +1,37 @@ +// not all are used in all features configurations +#![allow(unused)] + +/// Forward a method to an inherent method or a base trait method. +macro_rules! forward { + ($( Self :: $method:ident ( self $( , $arg:ident : $ty:ty )* ) -> $ret:ty ; )*) + => {$( + #[inline] + fn $method(self $( , $arg : $ty )* ) -> $ret { + Self::$method(self $( , $arg )* ) + } + )*}; + ($( $base:ident :: $method:ident ( self $( , $arg:ident : $ty:ty )* ) -> $ret:ty ; )*) + => {$( + #[inline] + fn $method(self $( , $arg : $ty )* ) -> $ret { + ::$method(self $( , $arg )* ) + } + )*}; + ($( $base:ident :: $method:ident ( $( $arg:ident : $ty:ty ),* ) -> $ret:ty ; )*) + => {$( + #[inline] + fn $method( $( $arg : $ty ),* ) -> $ret { + ::$method( $( $arg ),* ) + } + )*} +} + +macro_rules! constant { + ($( $method:ident () -> $ret:expr ; )*) + => {$( + #[inline] + fn $method() -> Self { + $ret + } + )*}; +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/ops/checked.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/checked.rs new file mode 100644 index 0000000..3865570 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/checked.rs @@ -0,0 +1,277 @@ +use core::ops::{Add, Div, Mul, Rem, Shl, Shr, Sub}; + +/// Performs addition that returns `None` instead of wrapping around on +/// overflow. +pub trait CheckedAdd: Sized + Add { + /// Adds two numbers, checking for overflow. If overflow happens, `None` is + /// returned. + fn checked_add(&self, v: &Self) -> Option; +} + +macro_rules! checked_impl { + ($trait_name:ident, $method:ident, $t:ty) => { + impl $trait_name for $t { + #[inline] + fn $method(&self, v: &$t) -> Option<$t> { + <$t>::$method(*self, *v) + } + } + }; +} + +checked_impl!(CheckedAdd, checked_add, u8); +checked_impl!(CheckedAdd, checked_add, u16); +checked_impl!(CheckedAdd, checked_add, u32); +checked_impl!(CheckedAdd, checked_add, u64); +checked_impl!(CheckedAdd, checked_add, usize); +#[cfg(has_i128)] +checked_impl!(CheckedAdd, checked_add, u128); + +checked_impl!(CheckedAdd, checked_add, i8); +checked_impl!(CheckedAdd, checked_add, i16); +checked_impl!(CheckedAdd, checked_add, i32); +checked_impl!(CheckedAdd, checked_add, i64); +checked_impl!(CheckedAdd, checked_add, isize); +#[cfg(has_i128)] +checked_impl!(CheckedAdd, checked_add, i128); + +/// Performs subtraction that returns `None` instead of wrapping around on underflow. +pub trait CheckedSub: Sized + Sub { + /// Subtracts two numbers, checking for underflow. If underflow happens, + /// `None` is returned. + fn checked_sub(&self, v: &Self) -> Option; +} + +checked_impl!(CheckedSub, checked_sub, u8); +checked_impl!(CheckedSub, checked_sub, u16); +checked_impl!(CheckedSub, checked_sub, u32); +checked_impl!(CheckedSub, checked_sub, u64); +checked_impl!(CheckedSub, checked_sub, usize); +#[cfg(has_i128)] +checked_impl!(CheckedSub, checked_sub, u128); + +checked_impl!(CheckedSub, checked_sub, i8); +checked_impl!(CheckedSub, checked_sub, i16); +checked_impl!(CheckedSub, checked_sub, i32); +checked_impl!(CheckedSub, checked_sub, i64); +checked_impl!(CheckedSub, checked_sub, isize); +#[cfg(has_i128)] +checked_impl!(CheckedSub, checked_sub, i128); + +/// Performs multiplication that returns `None` instead of wrapping around on underflow or +/// overflow. +pub trait CheckedMul: Sized + Mul { + /// Multiplies two numbers, checking for underflow or overflow. If underflow + /// or overflow happens, `None` is returned. + fn checked_mul(&self, v: &Self) -> Option; +} + +checked_impl!(CheckedMul, checked_mul, u8); +checked_impl!(CheckedMul, checked_mul, u16); +checked_impl!(CheckedMul, checked_mul, u32); +checked_impl!(CheckedMul, checked_mul, u64); +checked_impl!(CheckedMul, checked_mul, usize); +#[cfg(has_i128)] +checked_impl!(CheckedMul, checked_mul, u128); + +checked_impl!(CheckedMul, checked_mul, i8); +checked_impl!(CheckedMul, checked_mul, i16); +checked_impl!(CheckedMul, checked_mul, i32); +checked_impl!(CheckedMul, checked_mul, i64); +checked_impl!(CheckedMul, checked_mul, isize); +#[cfg(has_i128)] +checked_impl!(CheckedMul, checked_mul, i128); + +/// Performs division that returns `None` instead of panicking on division by zero and instead of +/// wrapping around on underflow and overflow. +pub trait CheckedDiv: Sized + Div { + /// Divides two numbers, checking for underflow, overflow and division by + /// zero. If any of that happens, `None` is returned. + fn checked_div(&self, v: &Self) -> Option; +} + +checked_impl!(CheckedDiv, checked_div, u8); +checked_impl!(CheckedDiv, checked_div, u16); +checked_impl!(CheckedDiv, checked_div, u32); +checked_impl!(CheckedDiv, checked_div, u64); +checked_impl!(CheckedDiv, checked_div, usize); +#[cfg(has_i128)] +checked_impl!(CheckedDiv, checked_div, u128); + +checked_impl!(CheckedDiv, checked_div, i8); +checked_impl!(CheckedDiv, checked_div, i16); +checked_impl!(CheckedDiv, checked_div, i32); +checked_impl!(CheckedDiv, checked_div, i64); +checked_impl!(CheckedDiv, checked_div, isize); +#[cfg(has_i128)] +checked_impl!(CheckedDiv, checked_div, i128); + +/// Performs an integral remainder that returns `None` instead of panicking on division by zero and +/// instead of wrapping around on underflow and overflow. +pub trait CheckedRem: Sized + Rem { + /// Finds the remainder of dividing two numbers, checking for underflow, overflow and division + /// by zero. If any of that happens, `None` is returned. + /// + /// # Examples + /// + /// ``` + /// use num_traits::CheckedRem; + /// use std::i32::MIN; + /// + /// assert_eq!(CheckedRem::checked_rem(&10, &7), Some(3)); + /// assert_eq!(CheckedRem::checked_rem(&10, &-7), Some(3)); + /// assert_eq!(CheckedRem::checked_rem(&-10, &7), Some(-3)); + /// assert_eq!(CheckedRem::checked_rem(&-10, &-7), Some(-3)); + /// + /// assert_eq!(CheckedRem::checked_rem(&10, &0), None); + /// + /// assert_eq!(CheckedRem::checked_rem(&MIN, &1), Some(0)); + /// assert_eq!(CheckedRem::checked_rem(&MIN, &-1), None); + /// ``` + fn checked_rem(&self, v: &Self) -> Option; +} + +checked_impl!(CheckedRem, checked_rem, u8); +checked_impl!(CheckedRem, checked_rem, u16); +checked_impl!(CheckedRem, checked_rem, u32); +checked_impl!(CheckedRem, checked_rem, u64); +checked_impl!(CheckedRem, checked_rem, usize); +#[cfg(has_i128)] +checked_impl!(CheckedRem, checked_rem, u128); + +checked_impl!(CheckedRem, checked_rem, i8); +checked_impl!(CheckedRem, checked_rem, i16); +checked_impl!(CheckedRem, checked_rem, i32); +checked_impl!(CheckedRem, checked_rem, i64); +checked_impl!(CheckedRem, checked_rem, isize); +#[cfg(has_i128)] +checked_impl!(CheckedRem, checked_rem, i128); + +macro_rules! checked_impl_unary { + ($trait_name:ident, $method:ident, $t:ty) => { + impl $trait_name for $t { + #[inline] + fn $method(&self) -> Option<$t> { + <$t>::$method(*self) + } + } + }; +} + +/// Performs negation that returns `None` if the result can't be represented. +pub trait CheckedNeg: Sized { + /// Negates a number, returning `None` for results that can't be represented, like signed `MIN` + /// values that can't be positive, or non-zero unsigned values that can't be negative. + /// + /// # Examples + /// + /// ``` + /// use num_traits::CheckedNeg; + /// use std::i32::MIN; + /// + /// assert_eq!(CheckedNeg::checked_neg(&1_i32), Some(-1)); + /// assert_eq!(CheckedNeg::checked_neg(&-1_i32), Some(1)); + /// assert_eq!(CheckedNeg::checked_neg(&MIN), None); + /// + /// assert_eq!(CheckedNeg::checked_neg(&0_u32), Some(0)); + /// assert_eq!(CheckedNeg::checked_neg(&1_u32), None); + /// ``` + fn checked_neg(&self) -> Option; +} + +checked_impl_unary!(CheckedNeg, checked_neg, u8); +checked_impl_unary!(CheckedNeg, checked_neg, u16); +checked_impl_unary!(CheckedNeg, checked_neg, u32); +checked_impl_unary!(CheckedNeg, checked_neg, u64); +checked_impl_unary!(CheckedNeg, checked_neg, usize); +#[cfg(has_i128)] +checked_impl_unary!(CheckedNeg, checked_neg, u128); + +checked_impl_unary!(CheckedNeg, checked_neg, i8); +checked_impl_unary!(CheckedNeg, checked_neg, i16); +checked_impl_unary!(CheckedNeg, checked_neg, i32); +checked_impl_unary!(CheckedNeg, checked_neg, i64); +checked_impl_unary!(CheckedNeg, checked_neg, isize); +#[cfg(has_i128)] +checked_impl_unary!(CheckedNeg, checked_neg, i128); + +/// Performs a left shift that returns `None` on shifts larger than +/// the type width. +pub trait CheckedShl: Sized + Shl { + /// Checked shift left. Computes `self << rhs`, returning `None` + /// if `rhs` is larger than or equal to the number of bits in `self`. + /// + /// ``` + /// use num_traits::CheckedShl; + /// + /// let x: u16 = 0x0001; + /// + /// assert_eq!(CheckedShl::checked_shl(&x, 0), Some(0x0001)); + /// assert_eq!(CheckedShl::checked_shl(&x, 1), Some(0x0002)); + /// assert_eq!(CheckedShl::checked_shl(&x, 15), Some(0x8000)); + /// assert_eq!(CheckedShl::checked_shl(&x, 16), None); + /// ``` + fn checked_shl(&self, rhs: u32) -> Option; +} + +macro_rules! checked_shift_impl { + ($trait_name:ident, $method:ident, $t:ty) => { + impl $trait_name for $t { + #[inline] + fn $method(&self, rhs: u32) -> Option<$t> { + <$t>::$method(*self, rhs) + } + } + }; +} + +checked_shift_impl!(CheckedShl, checked_shl, u8); +checked_shift_impl!(CheckedShl, checked_shl, u16); +checked_shift_impl!(CheckedShl, checked_shl, u32); +checked_shift_impl!(CheckedShl, checked_shl, u64); +checked_shift_impl!(CheckedShl, checked_shl, usize); +#[cfg(has_i128)] +checked_shift_impl!(CheckedShl, checked_shl, u128); + +checked_shift_impl!(CheckedShl, checked_shl, i8); +checked_shift_impl!(CheckedShl, checked_shl, i16); +checked_shift_impl!(CheckedShl, checked_shl, i32); +checked_shift_impl!(CheckedShl, checked_shl, i64); +checked_shift_impl!(CheckedShl, checked_shl, isize); +#[cfg(has_i128)] +checked_shift_impl!(CheckedShl, checked_shl, i128); + +/// Performs a right shift that returns `None` on shifts larger than +/// the type width. +pub trait CheckedShr: Sized + Shr { + /// Checked shift right. Computes `self >> rhs`, returning `None` + /// if `rhs` is larger than or equal to the number of bits in `self`. + /// + /// ``` + /// use num_traits::CheckedShr; + /// + /// let x: u16 = 0x8000; + /// + /// assert_eq!(CheckedShr::checked_shr(&x, 0), Some(0x8000)); + /// assert_eq!(CheckedShr::checked_shr(&x, 1), Some(0x4000)); + /// assert_eq!(CheckedShr::checked_shr(&x, 15), Some(0x0001)); + /// assert_eq!(CheckedShr::checked_shr(&x, 16), None); + /// ``` + fn checked_shr(&self, rhs: u32) -> Option; +} + +checked_shift_impl!(CheckedShr, checked_shr, u8); +checked_shift_impl!(CheckedShr, checked_shr, u16); +checked_shift_impl!(CheckedShr, checked_shr, u32); +checked_shift_impl!(CheckedShr, checked_shr, u64); +checked_shift_impl!(CheckedShr, checked_shr, usize); +#[cfg(has_i128)] +checked_shift_impl!(CheckedShr, checked_shr, u128); + +checked_shift_impl!(CheckedShr, checked_shr, i8); +checked_shift_impl!(CheckedShr, checked_shr, i16); +checked_shift_impl!(CheckedShr, checked_shr, i32); +checked_shift_impl!(CheckedShr, checked_shr, i64); +checked_shift_impl!(CheckedShr, checked_shr, isize); +#[cfg(has_i128)] +checked_shift_impl!(CheckedShr, checked_shr, i128); diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/ops/inv.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/inv.rs new file mode 100644 index 0000000..7087d09 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/inv.rs @@ -0,0 +1,47 @@ +/// Unary operator for retrieving the multiplicative inverse, or reciprocal, of a value. +pub trait Inv { + /// The result after applying the operator. + type Output; + + /// Returns the multiplicative inverse of `self`. + /// + /// # Examples + /// + /// ``` + /// use std::f64::INFINITY; + /// use num_traits::Inv; + /// + /// assert_eq!(7.0.inv() * 7.0, 1.0); + /// assert_eq!((-0.0).inv(), -INFINITY); + /// ``` + fn inv(self) -> Self::Output; +} + +impl Inv for f32 { + type Output = f32; + #[inline] + fn inv(self) -> f32 { + 1.0 / self + } +} +impl Inv for f64 { + type Output = f64; + #[inline] + fn inv(self) -> f64 { + 1.0 / self + } +} +impl<'a> Inv for &'a f32 { + type Output = f32; + #[inline] + fn inv(self) -> f32 { + 1.0 / *self + } +} +impl<'a> Inv for &'a f64 { + type Output = f64; + #[inline] + fn inv(self) -> f64 { + 1.0 / *self + } +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/ops/mod.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/mod.rs new file mode 100644 index 0000000..fd1695d --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/mod.rs @@ -0,0 +1,5 @@ +pub mod checked; +pub mod inv; +pub mod mul_add; +pub mod saturating; +pub mod wrapping; diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/ops/mul_add.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/mul_add.rs new file mode 100644 index 0000000..c5835d3 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/mul_add.rs @@ -0,0 +1,151 @@ +/// Fused multiply-add. Computes `(self * a) + b` with only one rounding +/// error, yielding a more accurate result than an unfused multiply-add. +/// +/// Using `mul_add` can be more performant than an unfused multiply-add if +/// the target architecture has a dedicated `fma` CPU instruction. +/// +/// Note that `A` and `B` are `Self` by default, but this is not mandatory. +/// +/// # Example +/// +/// ``` +/// use std::f32; +/// +/// let m = 10.0_f32; +/// let x = 4.0_f32; +/// let b = 60.0_f32; +/// +/// // 100.0 +/// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs(); +/// +/// assert!(abs_difference <= 100.0 * f32::EPSILON); +/// ``` +pub trait MulAdd { + /// The resulting type after applying the fused multiply-add. + type Output; + + /// Performs the fused multiply-add operation. + fn mul_add(self, a: A, b: B) -> Self::Output; +} + +/// The fused multiply-add assignment operation. +pub trait MulAddAssign { + /// Performs the fused multiply-add operation. + fn mul_add_assign(&mut self, a: A, b: B); +} + +#[cfg(any(feature = "std", feature = "libm"))] +impl MulAdd for f32 { + type Output = Self; + + #[inline] + fn mul_add(self, a: Self, b: Self) -> Self::Output { + ::mul_add(self, a, b) + } +} + +#[cfg(any(feature = "std", feature = "libm"))] +impl MulAdd for f64 { + type Output = Self; + + #[inline] + fn mul_add(self, a: Self, b: Self) -> Self::Output { + ::mul_add(self, a, b) + } +} + +macro_rules! mul_add_impl { + ($trait_name:ident for $($t:ty)*) => {$( + impl $trait_name for $t { + type Output = Self; + + #[inline] + fn mul_add(self, a: Self, b: Self) -> Self::Output { + (self * a) + b + } + } + )*} +} + +mul_add_impl!(MulAdd for isize usize i8 u8 i16 u16 i32 u32 i64 u64); +#[cfg(has_i128)] +mul_add_impl!(MulAdd for i128 u128); + +#[cfg(any(feature = "std", feature = "libm"))] +impl MulAddAssign for f32 { + #[inline] + fn mul_add_assign(&mut self, a: Self, b: Self) { + *self = ::mul_add(*self, a, b) + } +} + +#[cfg(any(feature = "std", feature = "libm"))] +impl MulAddAssign for f64 { + #[inline] + fn mul_add_assign(&mut self, a: Self, b: Self) { + *self = ::mul_add(*self, a, b) + } +} + +macro_rules! mul_add_assign_impl { + ($trait_name:ident for $($t:ty)*) => {$( + impl $trait_name for $t { + #[inline] + fn mul_add_assign(&mut self, a: Self, b: Self) { + *self = (*self * a) + b + } + } + )*} +} + +mul_add_assign_impl!(MulAddAssign for isize usize i8 u8 i16 u16 i32 u32 i64 u64); +#[cfg(has_i128)] +mul_add_assign_impl!(MulAddAssign for i128 u128); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn mul_add_integer() { + macro_rules! test_mul_add { + ($($t:ident)+) => { + $( + { + let m: $t = 2; + let x: $t = 3; + let b: $t = 4; + + assert_eq!(MulAdd::mul_add(m, x, b), (m*x + b)); + } + )+ + }; + } + + test_mul_add!(usize u8 u16 u32 u64 isize i8 i16 i32 i64); + } + + #[test] + #[cfg(feature = "std")] + fn mul_add_float() { + macro_rules! test_mul_add { + ($($t:ident)+) => { + $( + { + use core::$t; + + let m: $t = 12.0; + let x: $t = 3.4; + let b: $t = 5.6; + + let abs_difference = (MulAdd::mul_add(m, x, b) - (m*x + b)).abs(); + + assert!(abs_difference <= 46.4 * $t::EPSILON); + } + )+ + }; + } + + test_mul_add!(f32 f64); + } +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/ops/saturating.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/saturating.rs new file mode 100644 index 0000000..fdce189 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/saturating.rs @@ -0,0 +1,30 @@ +/// Saturating math operations +pub trait Saturating { + /// Saturating addition operator. + /// Returns a+b, saturating at the numeric bounds instead of overflowing. + fn saturating_add(self, v: Self) -> Self; + + /// Saturating subtraction operator. + /// Returns a-b, saturating at the numeric bounds instead of overflowing. + fn saturating_sub(self, v: Self) -> Self; +} + +macro_rules! saturating_impl { + ($trait_name:ident for $($t:ty)*) => {$( + impl $trait_name for $t { + #[inline] + fn saturating_add(self, v: Self) -> Self { + Self::saturating_add(self, v) + } + + #[inline] + fn saturating_sub(self, v: Self) -> Self { + Self::saturating_sub(self, v) + } + } + )*} +} + +saturating_impl!(Saturating for isize usize i8 u8 i16 u16 i32 u32 i64 u64); +#[cfg(has_i128)] +saturating_impl!(Saturating for i128 u128); diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/ops/wrapping.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/wrapping.rs new file mode 100644 index 0000000..5ce16af --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/ops/wrapping.rs @@ -0,0 +1,272 @@ +use core::num::Wrapping; +use core::ops::{Add, Mul, Shl, Shr, Sub}; + +macro_rules! wrapping_impl { + ($trait_name:ident, $method:ident, $t:ty) => { + impl $trait_name for $t { + #[inline] + fn $method(&self, v: &Self) -> Self { + <$t>::$method(*self, *v) + } + } + }; + ($trait_name:ident, $method:ident, $t:ty, $rhs:ty) => { + impl $trait_name<$rhs> for $t { + #[inline] + fn $method(&self, v: &$rhs) -> Self { + <$t>::$method(*self, *v) + } + } + }; +} + +/// Performs addition that wraps around on overflow. +pub trait WrappingAdd: Sized + Add { + /// Wrapping (modular) addition. Computes `self + other`, wrapping around at the boundary of + /// the type. + fn wrapping_add(&self, v: &Self) -> Self; +} + +wrapping_impl!(WrappingAdd, wrapping_add, u8); +wrapping_impl!(WrappingAdd, wrapping_add, u16); +wrapping_impl!(WrappingAdd, wrapping_add, u32); +wrapping_impl!(WrappingAdd, wrapping_add, u64); +wrapping_impl!(WrappingAdd, wrapping_add, usize); +#[cfg(has_i128)] +wrapping_impl!(WrappingAdd, wrapping_add, u128); + +wrapping_impl!(WrappingAdd, wrapping_add, i8); +wrapping_impl!(WrappingAdd, wrapping_add, i16); +wrapping_impl!(WrappingAdd, wrapping_add, i32); +wrapping_impl!(WrappingAdd, wrapping_add, i64); +wrapping_impl!(WrappingAdd, wrapping_add, isize); +#[cfg(has_i128)] +wrapping_impl!(WrappingAdd, wrapping_add, i128); + +/// Performs subtraction that wraps around on overflow. +pub trait WrappingSub: Sized + Sub { + /// Wrapping (modular) subtraction. Computes `self - other`, wrapping around at the boundary + /// of the type. + fn wrapping_sub(&self, v: &Self) -> Self; +} + +wrapping_impl!(WrappingSub, wrapping_sub, u8); +wrapping_impl!(WrappingSub, wrapping_sub, u16); +wrapping_impl!(WrappingSub, wrapping_sub, u32); +wrapping_impl!(WrappingSub, wrapping_sub, u64); +wrapping_impl!(WrappingSub, wrapping_sub, usize); +#[cfg(has_i128)] +wrapping_impl!(WrappingSub, wrapping_sub, u128); + +wrapping_impl!(WrappingSub, wrapping_sub, i8); +wrapping_impl!(WrappingSub, wrapping_sub, i16); +wrapping_impl!(WrappingSub, wrapping_sub, i32); +wrapping_impl!(WrappingSub, wrapping_sub, i64); +wrapping_impl!(WrappingSub, wrapping_sub, isize); +#[cfg(has_i128)] +wrapping_impl!(WrappingSub, wrapping_sub, i128); + +/// Performs multiplication that wraps around on overflow. +pub trait WrappingMul: Sized + Mul { + /// Wrapping (modular) multiplication. Computes `self * other`, wrapping around at the boundary + /// of the type. + fn wrapping_mul(&self, v: &Self) -> Self; +} + +wrapping_impl!(WrappingMul, wrapping_mul, u8); +wrapping_impl!(WrappingMul, wrapping_mul, u16); +wrapping_impl!(WrappingMul, wrapping_mul, u32); +wrapping_impl!(WrappingMul, wrapping_mul, u64); +wrapping_impl!(WrappingMul, wrapping_mul, usize); +#[cfg(has_i128)] +wrapping_impl!(WrappingMul, wrapping_mul, u128); + +wrapping_impl!(WrappingMul, wrapping_mul, i8); +wrapping_impl!(WrappingMul, wrapping_mul, i16); +wrapping_impl!(WrappingMul, wrapping_mul, i32); +wrapping_impl!(WrappingMul, wrapping_mul, i64); +wrapping_impl!(WrappingMul, wrapping_mul, isize); +#[cfg(has_i128)] +wrapping_impl!(WrappingMul, wrapping_mul, i128); + +macro_rules! wrapping_shift_impl { + ($trait_name:ident, $method:ident, $t:ty) => { + impl $trait_name for $t { + #[inline] + fn $method(&self, rhs: u32) -> $t { + <$t>::$method(*self, rhs) + } + } + }; +} + +/// Performs a left shift that does not panic. +pub trait WrappingShl: Sized + Shl { + /// Panic-free bitwise shift-left; yields `self << mask(rhs)`, + /// where `mask` removes any high order bits of `rhs` that would + /// cause the shift to exceed the bitwidth of the type. + /// + /// ``` + /// use num_traits::WrappingShl; + /// + /// let x: u16 = 0x0001; + /// + /// assert_eq!(WrappingShl::wrapping_shl(&x, 0), 0x0001); + /// assert_eq!(WrappingShl::wrapping_shl(&x, 1), 0x0002); + /// assert_eq!(WrappingShl::wrapping_shl(&x, 15), 0x8000); + /// assert_eq!(WrappingShl::wrapping_shl(&x, 16), 0x0001); + /// ``` + fn wrapping_shl(&self, rhs: u32) -> Self; +} + +wrapping_shift_impl!(WrappingShl, wrapping_shl, u8); +wrapping_shift_impl!(WrappingShl, wrapping_shl, u16); +wrapping_shift_impl!(WrappingShl, wrapping_shl, u32); +wrapping_shift_impl!(WrappingShl, wrapping_shl, u64); +wrapping_shift_impl!(WrappingShl, wrapping_shl, usize); +#[cfg(has_i128)] +wrapping_shift_impl!(WrappingShl, wrapping_shl, u128); + +wrapping_shift_impl!(WrappingShl, wrapping_shl, i8); +wrapping_shift_impl!(WrappingShl, wrapping_shl, i16); +wrapping_shift_impl!(WrappingShl, wrapping_shl, i32); +wrapping_shift_impl!(WrappingShl, wrapping_shl, i64); +wrapping_shift_impl!(WrappingShl, wrapping_shl, isize); +#[cfg(has_i128)] +wrapping_shift_impl!(WrappingShl, wrapping_shl, i128); + +/// Performs a right shift that does not panic. +pub trait WrappingShr: Sized + Shr { + /// Panic-free bitwise shift-right; yields `self >> mask(rhs)`, + /// where `mask` removes any high order bits of `rhs` that would + /// cause the shift to exceed the bitwidth of the type. + /// + /// ``` + /// use num_traits::WrappingShr; + /// + /// let x: u16 = 0x8000; + /// + /// assert_eq!(WrappingShr::wrapping_shr(&x, 0), 0x8000); + /// assert_eq!(WrappingShr::wrapping_shr(&x, 1), 0x4000); + /// assert_eq!(WrappingShr::wrapping_shr(&x, 15), 0x0001); + /// assert_eq!(WrappingShr::wrapping_shr(&x, 16), 0x8000); + /// ``` + fn wrapping_shr(&self, rhs: u32) -> Self; +} + +wrapping_shift_impl!(WrappingShr, wrapping_shr, u8); +wrapping_shift_impl!(WrappingShr, wrapping_shr, u16); +wrapping_shift_impl!(WrappingShr, wrapping_shr, u32); +wrapping_shift_impl!(WrappingShr, wrapping_shr, u64); +wrapping_shift_impl!(WrappingShr, wrapping_shr, usize); +#[cfg(has_i128)] +wrapping_shift_impl!(WrappingShr, wrapping_shr, u128); + +wrapping_shift_impl!(WrappingShr, wrapping_shr, i8); +wrapping_shift_impl!(WrappingShr, wrapping_shr, i16); +wrapping_shift_impl!(WrappingShr, wrapping_shr, i32); +wrapping_shift_impl!(WrappingShr, wrapping_shr, i64); +wrapping_shift_impl!(WrappingShr, wrapping_shr, isize); +#[cfg(has_i128)] +wrapping_shift_impl!(WrappingShr, wrapping_shr, i128); + +// Well this is a bit funny, but all the more appropriate. +impl WrappingAdd for Wrapping +where + Wrapping: Add>, +{ + fn wrapping_add(&self, v: &Self) -> Self { + Wrapping(self.0.wrapping_add(&v.0)) + } +} +impl WrappingSub for Wrapping +where + Wrapping: Sub>, +{ + fn wrapping_sub(&self, v: &Self) -> Self { + Wrapping(self.0.wrapping_sub(&v.0)) + } +} +impl WrappingMul for Wrapping +where + Wrapping: Mul>, +{ + fn wrapping_mul(&self, v: &Self) -> Self { + Wrapping(self.0.wrapping_mul(&v.0)) + } +} +impl WrappingShl for Wrapping +where + Wrapping: Shl>, +{ + fn wrapping_shl(&self, rhs: u32) -> Self { + Wrapping(self.0.wrapping_shl(rhs)) + } +} +impl WrappingShr for Wrapping +where + Wrapping: Shr>, +{ + fn wrapping_shr(&self, rhs: u32) -> Self { + Wrapping(self.0.wrapping_shr(rhs)) + } +} + +#[test] +fn test_wrapping_traits() { + fn wrapping_add(a: T, b: T) -> T { + a.wrapping_add(&b) + } + fn wrapping_sub(a: T, b: T) -> T { + a.wrapping_sub(&b) + } + fn wrapping_mul(a: T, b: T) -> T { + a.wrapping_mul(&b) + } + fn wrapping_shl(a: T, b: u32) -> T { + a.wrapping_shl(b) + } + fn wrapping_shr(a: T, b: u32) -> T { + a.wrapping_shr(b) + } + assert_eq!(wrapping_add(255, 1), 0u8); + assert_eq!(wrapping_sub(0, 1), 255u8); + assert_eq!(wrapping_mul(255, 2), 254u8); + assert_eq!(wrapping_shl(255, 8), 255u8); + assert_eq!(wrapping_shr(255, 8), 255u8); + assert_eq!(wrapping_add(255, 1), (Wrapping(255u8) + Wrapping(1u8)).0); + assert_eq!(wrapping_sub(0, 1), (Wrapping(0u8) - Wrapping(1u8)).0); + assert_eq!(wrapping_mul(255, 2), (Wrapping(255u8) * Wrapping(2u8)).0); + assert_eq!(wrapping_shl(255, 8), (Wrapping(255u8) << 8).0); + assert_eq!(wrapping_shr(255, 8), (Wrapping(255u8) >> 8).0); +} + +#[test] +fn wrapping_is_wrappingadd() { + fn require_wrappingadd(_: &T) {} + require_wrappingadd(&Wrapping(42)); +} + +#[test] +fn wrapping_is_wrappingsub() { + fn require_wrappingsub(_: &T) {} + require_wrappingsub(&Wrapping(42)); +} + +#[test] +fn wrapping_is_wrappingmul() { + fn require_wrappingmul(_: &T) {} + require_wrappingmul(&Wrapping(42)); +} + +#[test] +fn wrapping_is_wrappingshl() { + fn require_wrappingshl(_: &T) {} + require_wrappingshl(&Wrapping(42)); +} + +#[test] +fn wrapping_is_wrappingshr() { + fn require_wrappingshr(_: &T) {} + require_wrappingshr(&Wrapping(42)); +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/pow.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/pow.rs new file mode 100644 index 0000000..8addc21 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/pow.rs @@ -0,0 +1,262 @@ +use core::num::Wrapping; +use core::ops::Mul; +use {CheckedMul, One}; + +/// Binary operator for raising a value to a power. +pub trait Pow { + /// The result after applying the operator. + type Output; + + /// Returns `self` to the power `rhs`. + /// + /// # Examples + /// + /// ``` + /// use num_traits::Pow; + /// assert_eq!(Pow::pow(10u32, 2u32), 100); + /// ``` + fn pow(self, rhs: RHS) -> Self::Output; +} + +macro_rules! pow_impl { + ($t:ty) => { + pow_impl!($t, u8); + pow_impl!($t, usize); + + // FIXME: these should be possible + // pow_impl!($t, u16); + // pow_impl!($t, u32); + // pow_impl!($t, u64); + }; + ($t:ty, $rhs:ty) => { + pow_impl!($t, $rhs, usize, pow); + }; + ($t:ty, $rhs:ty, $desired_rhs:ty, $method:expr) => { + impl Pow<$rhs> for $t { + type Output = $t; + #[inline] + fn pow(self, rhs: $rhs) -> $t { + ($method)(self, <$desired_rhs>::from(rhs)) + } + } + + impl<'a> Pow<&'a $rhs> for $t { + type Output = $t; + #[inline] + fn pow(self, rhs: &'a $rhs) -> $t { + ($method)(self, <$desired_rhs>::from(*rhs)) + } + } + + impl<'a> Pow<$rhs> for &'a $t { + type Output = $t; + #[inline] + fn pow(self, rhs: $rhs) -> $t { + ($method)(*self, <$desired_rhs>::from(rhs)) + } + } + + impl<'a, 'b> Pow<&'a $rhs> for &'b $t { + type Output = $t; + #[inline] + fn pow(self, rhs: &'a $rhs) -> $t { + ($method)(*self, <$desired_rhs>::from(*rhs)) + } + } + }; +} + +pow_impl!(u8, u8, u32, u8::pow); +pow_impl!(u8, u16, u32, u8::pow); +pow_impl!(u8, u32, u32, u8::pow); +pow_impl!(u8, usize); +pow_impl!(i8, u8, u32, i8::pow); +pow_impl!(i8, u16, u32, i8::pow); +pow_impl!(i8, u32, u32, i8::pow); +pow_impl!(i8, usize); +pow_impl!(u16, u8, u32, u16::pow); +pow_impl!(u16, u16, u32, u16::pow); +pow_impl!(u16, u32, u32, u16::pow); +pow_impl!(u16, usize); +pow_impl!(i16, u8, u32, i16::pow); +pow_impl!(i16, u16, u32, i16::pow); +pow_impl!(i16, u32, u32, i16::pow); +pow_impl!(i16, usize); +pow_impl!(u32, u8, u32, u32::pow); +pow_impl!(u32, u16, u32, u32::pow); +pow_impl!(u32, u32, u32, u32::pow); +pow_impl!(u32, usize); +pow_impl!(i32, u8, u32, i32::pow); +pow_impl!(i32, u16, u32, i32::pow); +pow_impl!(i32, u32, u32, i32::pow); +pow_impl!(i32, usize); +pow_impl!(u64, u8, u32, u64::pow); +pow_impl!(u64, u16, u32, u64::pow); +pow_impl!(u64, u32, u32, u64::pow); +pow_impl!(u64, usize); +pow_impl!(i64, u8, u32, i64::pow); +pow_impl!(i64, u16, u32, i64::pow); +pow_impl!(i64, u32, u32, i64::pow); +pow_impl!(i64, usize); + +#[cfg(has_i128)] +pow_impl!(u128, u8, u32, u128::pow); +#[cfg(has_i128)] +pow_impl!(u128, u16, u32, u128::pow); +#[cfg(has_i128)] +pow_impl!(u128, u32, u32, u128::pow); +#[cfg(has_i128)] +pow_impl!(u128, usize); + +#[cfg(has_i128)] +pow_impl!(i128, u8, u32, i128::pow); +#[cfg(has_i128)] +pow_impl!(i128, u16, u32, i128::pow); +#[cfg(has_i128)] +pow_impl!(i128, u32, u32, i128::pow); +#[cfg(has_i128)] +pow_impl!(i128, usize); + +pow_impl!(usize, u8, u32, usize::pow); +pow_impl!(usize, u16, u32, usize::pow); +pow_impl!(usize, u32, u32, usize::pow); +pow_impl!(usize, usize); +pow_impl!(isize, u8, u32, isize::pow); +pow_impl!(isize, u16, u32, isize::pow); +pow_impl!(isize, u32, u32, isize::pow); +pow_impl!(isize, usize); +pow_impl!(Wrapping); +pow_impl!(Wrapping); +pow_impl!(Wrapping); +pow_impl!(Wrapping); +pow_impl!(Wrapping); +pow_impl!(Wrapping); +pow_impl!(Wrapping); +pow_impl!(Wrapping); +#[cfg(has_i128)] +pow_impl!(Wrapping); +#[cfg(has_i128)] +pow_impl!(Wrapping); +pow_impl!(Wrapping); +pow_impl!(Wrapping); + +// FIXME: these should be possible +// pow_impl!(u8, u64); +// pow_impl!(i16, u64); +// pow_impl!(i8, u64); +// pow_impl!(u16, u64); +// pow_impl!(u32, u64); +// pow_impl!(i32, u64); +// pow_impl!(u64, u64); +// pow_impl!(i64, u64); +// pow_impl!(usize, u64); +// pow_impl!(isize, u64); + +#[cfg(any(feature = "std", feature = "libm"))] +mod float_impls { + use super::Pow; + use Float; + + pow_impl!(f32, i8, i32, ::powi); + pow_impl!(f32, u8, i32, ::powi); + pow_impl!(f32, i16, i32, ::powi); + pow_impl!(f32, u16, i32, ::powi); + pow_impl!(f32, i32, i32, ::powi); + pow_impl!(f64, i8, i32, ::powi); + pow_impl!(f64, u8, i32, ::powi); + pow_impl!(f64, i16, i32, ::powi); + pow_impl!(f64, u16, i32, ::powi); + pow_impl!(f64, i32, i32, ::powi); + pow_impl!(f32, f32, f32, ::powf); + pow_impl!(f64, f32, f64, ::powf); + pow_impl!(f64, f64, f64, ::powf); +} + +/// Raises a value to the power of exp, using exponentiation by squaring. +/// +/// Note that `0⁰` (`pow(0, 0)`) returns `1`. Mathematically this is undefined. +/// +/// # Example +/// +/// ```rust +/// use num_traits::pow; +/// +/// assert_eq!(pow(2i8, 4), 16); +/// assert_eq!(pow(6u8, 3), 216); +/// assert_eq!(pow(0u8, 0), 1); // Be aware if this case affects you +/// ``` +#[inline] +pub fn pow>(mut base: T, mut exp: usize) -> T { + if exp == 0 { + return T::one(); + } + + while exp & 1 == 0 { + base = base.clone() * base; + exp >>= 1; + } + if exp == 1 { + return base; + } + + let mut acc = base.clone(); + while exp > 1 { + exp >>= 1; + base = base.clone() * base; + if exp & 1 == 1 { + acc = acc * base.clone(); + } + } + acc +} + +/// Raises a value to the power of exp, returning `None` if an overflow occurred. +/// +/// Note that `0⁰` (`checked_pow(0, 0)`) returns `Some(1)`. Mathematically this is undefined. +/// +/// Otherwise same as the `pow` function. +/// +/// # Example +/// +/// ```rust +/// use num_traits::checked_pow; +/// +/// assert_eq!(checked_pow(2i8, 4), Some(16)); +/// assert_eq!(checked_pow(7i8, 8), None); +/// assert_eq!(checked_pow(7u32, 8), Some(5_764_801)); +/// assert_eq!(checked_pow(0u32, 0), Some(1)); // Be aware if this case affect you +/// ``` +#[inline] +pub fn checked_pow(mut base: T, mut exp: usize) -> Option { + if exp == 0 { + return Some(T::one()); + } + + macro_rules! optry { + ($expr:expr) => { + if let Some(val) = $expr { + val + } else { + return None; + } + }; + } + + while exp & 1 == 0 { + base = optry!(base.checked_mul(&base)); + exp >>= 1; + } + if exp == 1 { + return Some(base); + } + + let mut acc = base.clone(); + while exp > 1 { + exp >>= 1; + base = optry!(base.checked_mul(&base)); + if exp & 1 == 1 { + acc = optry!(acc.checked_mul(&base)); + } + } + Some(acc) +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/real.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/real.rs new file mode 100644 index 0000000..8b31cce --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/real.rs @@ -0,0 +1,834 @@ +#![cfg(any(feature = "std", feature = "libm"))] + +use core::ops::Neg; + +use {Float, Num, NumCast}; + +// NOTE: These doctests have the same issue as those in src/float.rs. +// They're testing the inherent methods directly, and not those of `Real`. + +/// A trait for real number types that do not necessarily have +/// floating-point-specific characteristics such as NaN and infinity. +/// +/// See [this Wikipedia article](https://en.wikipedia.org/wiki/Real_data_type) +/// for a list of data types that could meaningfully implement this trait. +/// +/// This trait is only available with the `std` feature, or with the `libm` feature otherwise. +pub trait Real: Num + Copy + NumCast + PartialOrd + Neg { + /// Returns the smallest finite value that this type can represent. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let x: f64 = Real::min_value(); + /// + /// assert_eq!(x, f64::MIN); + /// ``` + fn min_value() -> Self; + + /// Returns the smallest positive, normalized value that this type can represent. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let x: f64 = Real::min_positive_value(); + /// + /// assert_eq!(x, f64::MIN_POSITIVE); + /// ``` + fn min_positive_value() -> Self; + + /// Returns epsilon, a small positive value. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let x: f64 = Real::epsilon(); + /// + /// assert_eq!(x, f64::EPSILON); + /// ``` + /// + /// # Panics + /// + /// The default implementation will panic if `f32::EPSILON` cannot + /// be cast to `Self`. + fn epsilon() -> Self; + + /// Returns the largest finite value that this type can represent. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let x: f64 = Real::max_value(); + /// assert_eq!(x, f64::MAX); + /// ``` + fn max_value() -> Self; + + /// Returns the largest integer less than or equal to a number. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let f = 3.99; + /// let g = 3.0; + /// + /// assert_eq!(f.floor(), 3.0); + /// assert_eq!(g.floor(), 3.0); + /// ``` + fn floor(self) -> Self; + + /// Returns the smallest integer greater than or equal to a number. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let f = 3.01; + /// let g = 4.0; + /// + /// assert_eq!(f.ceil(), 4.0); + /// assert_eq!(g.ceil(), 4.0); + /// ``` + fn ceil(self) -> Self; + + /// Returns the nearest integer to a number. Round half-way cases away from + /// `0.0`. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let f = 3.3; + /// let g = -3.3; + /// + /// assert_eq!(f.round(), 3.0); + /// assert_eq!(g.round(), -3.0); + /// ``` + fn round(self) -> Self; + + /// Return the integer part of a number. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let f = 3.3; + /// let g = -3.7; + /// + /// assert_eq!(f.trunc(), 3.0); + /// assert_eq!(g.trunc(), -3.0); + /// ``` + fn trunc(self) -> Self; + + /// Returns the fractional part of a number. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 3.5; + /// let y = -3.5; + /// let abs_difference_x = (x.fract() - 0.5).abs(); + /// let abs_difference_y = (y.fract() - (-0.5)).abs(); + /// + /// assert!(abs_difference_x < 1e-10); + /// assert!(abs_difference_y < 1e-10); + /// ``` + fn fract(self) -> Self; + + /// Computes the absolute value of `self`. Returns `Float::nan()` if the + /// number is `Float::nan()`. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let x = 3.5; + /// let y = -3.5; + /// + /// let abs_difference_x = (x.abs() - x).abs(); + /// let abs_difference_y = (y.abs() - (-y)).abs(); + /// + /// assert!(abs_difference_x < 1e-10); + /// assert!(abs_difference_y < 1e-10); + /// + /// assert!(::num_traits::Float::is_nan(f64::NAN.abs())); + /// ``` + fn abs(self) -> Self; + + /// Returns a number that represents the sign of `self`. + /// + /// - `1.0` if the number is positive, `+0.0` or `Float::infinity()` + /// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()` + /// - `Float::nan()` if the number is `Float::nan()` + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let f = 3.5; + /// + /// assert_eq!(f.signum(), 1.0); + /// assert_eq!(f64::NEG_INFINITY.signum(), -1.0); + /// + /// assert!(f64::NAN.signum().is_nan()); + /// ``` + fn signum(self) -> Self; + + /// Returns `true` if `self` is positive, including `+0.0`, + /// `Float::infinity()`, and with newer versions of Rust `f64::NAN`. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let neg_nan: f64 = -f64::NAN; + /// + /// let f = 7.0; + /// let g = -7.0; + /// + /// assert!(f.is_sign_positive()); + /// assert!(!g.is_sign_positive()); + /// assert!(!neg_nan.is_sign_positive()); + /// ``` + fn is_sign_positive(self) -> bool; + + /// Returns `true` if `self` is negative, including `-0.0`, + /// `Float::neg_infinity()`, and with newer versions of Rust `-f64::NAN`. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let nan: f64 = f64::NAN; + /// + /// let f = 7.0; + /// let g = -7.0; + /// + /// assert!(!f.is_sign_negative()); + /// assert!(g.is_sign_negative()); + /// assert!(!nan.is_sign_negative()); + /// ``` + fn is_sign_negative(self) -> bool; + + /// Fused multiply-add. Computes `(self * a) + b` with only one rounding + /// error, yielding a more accurate result than an unfused multiply-add. + /// + /// Using `mul_add` can be more performant than an unfused multiply-add if + /// the target architecture has a dedicated `fma` CPU instruction. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let m = 10.0; + /// let x = 4.0; + /// let b = 60.0; + /// + /// // 100.0 + /// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn mul_add(self, a: Self, b: Self) -> Self; + + /// Take the reciprocal (inverse) of a number, `1/x`. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 2.0; + /// let abs_difference = (x.recip() - (1.0/x)).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn recip(self) -> Self; + + /// Raise a number to an integer power. + /// + /// Using this function is generally faster than using `powf` + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 2.0; + /// let abs_difference = (x.powi(2) - x*x).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn powi(self, n: i32) -> Self; + + /// Raise a number to a real number power. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 2.0; + /// let abs_difference = (x.powf(2.0) - x*x).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn powf(self, n: Self) -> Self; + + /// Take the square root of a number. + /// + /// Returns NaN if `self` is a negative floating-point number. + /// + /// # Panics + /// + /// If the implementing type doesn't support NaN, this method should panic if `self < 0`. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let positive = 4.0; + /// let negative = -4.0; + /// + /// let abs_difference = (positive.sqrt() - 2.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// assert!(::num_traits::Float::is_nan(negative.sqrt())); + /// ``` + fn sqrt(self) -> Self; + + /// Returns `e^(self)`, (the exponential function). + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let one = 1.0; + /// // e^1 + /// let e = one.exp(); + /// + /// // ln(e) - 1 == 0 + /// let abs_difference = (e.ln() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn exp(self) -> Self; + + /// Returns `2^(self)`. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let f = 2.0; + /// + /// // 2^2 - 4 == 0 + /// let abs_difference = (f.exp2() - 4.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn exp2(self) -> Self; + + /// Returns the natural logarithm of the number. + /// + /// # Panics + /// + /// If `self <= 0` and this type does not support a NaN representation, this function should panic. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let one = 1.0; + /// // e^1 + /// let e = one.exp(); + /// + /// // ln(e) - 1 == 0 + /// let abs_difference = (e.ln() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn ln(self) -> Self; + + /// Returns the logarithm of the number with respect to an arbitrary base. + /// + /// # Panics + /// + /// If `self <= 0` and this type does not support a NaN representation, this function should panic. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let ten = 10.0; + /// let two = 2.0; + /// + /// // log10(10) - 1 == 0 + /// let abs_difference_10 = (ten.log(10.0) - 1.0).abs(); + /// + /// // log2(2) - 1 == 0 + /// let abs_difference_2 = (two.log(2.0) - 1.0).abs(); + /// + /// assert!(abs_difference_10 < 1e-10); + /// assert!(abs_difference_2 < 1e-10); + /// ``` + fn log(self, base: Self) -> Self; + + /// Returns the base 2 logarithm of the number. + /// + /// # Panics + /// + /// If `self <= 0` and this type does not support a NaN representation, this function should panic. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let two = 2.0; + /// + /// // log2(2) - 1 == 0 + /// let abs_difference = (two.log2() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn log2(self) -> Self; + + /// Returns the base 10 logarithm of the number. + /// + /// # Panics + /// + /// If `self <= 0` and this type does not support a NaN representation, this function should panic. + /// + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let ten = 10.0; + /// + /// // log10(10) - 1 == 0 + /// let abs_difference = (ten.log10() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn log10(self) -> Self; + + /// Converts radians to degrees. + /// + /// ``` + /// use std::f64::consts; + /// + /// let angle = consts::PI; + /// + /// let abs_difference = (angle.to_degrees() - 180.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn to_degrees(self) -> Self; + + /// Converts degrees to radians. + /// + /// ``` + /// use std::f64::consts; + /// + /// let angle = 180.0_f64; + /// + /// let abs_difference = (angle.to_radians() - consts::PI).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn to_radians(self) -> Self; + + /// Returns the maximum of the two numbers. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 1.0; + /// let y = 2.0; + /// + /// assert_eq!(x.max(y), y); + /// ``` + fn max(self, other: Self) -> Self; + + /// Returns the minimum of the two numbers. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 1.0; + /// let y = 2.0; + /// + /// assert_eq!(x.min(y), x); + /// ``` + fn min(self, other: Self) -> Self; + + /// The positive difference of two numbers. + /// + /// * If `self <= other`: `0:0` + /// * Else: `self - other` + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 3.0; + /// let y = -3.0; + /// + /// let abs_difference_x = (x.abs_sub(1.0) - 2.0).abs(); + /// let abs_difference_y = (y.abs_sub(1.0) - 0.0).abs(); + /// + /// assert!(abs_difference_x < 1e-10); + /// assert!(abs_difference_y < 1e-10); + /// ``` + fn abs_sub(self, other: Self) -> Self; + + /// Take the cubic root of a number. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 8.0; + /// + /// // x^(1/3) - 2 == 0 + /// let abs_difference = (x.cbrt() - 2.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn cbrt(self) -> Self; + + /// Calculate the length of the hypotenuse of a right-angle triangle given + /// legs of length `x` and `y`. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 2.0; + /// let y = 3.0; + /// + /// // sqrt(x^2 + y^2) + /// let abs_difference = (x.hypot(y) - (x.powi(2) + y.powi(2)).sqrt()).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn hypot(self, other: Self) -> Self; + + /// Computes the sine of a number (in radians). + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let x = f64::consts::PI/2.0; + /// + /// let abs_difference = (x.sin() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn sin(self) -> Self; + + /// Computes the cosine of a number (in radians). + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let x = 2.0*f64::consts::PI; + /// + /// let abs_difference = (x.cos() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn cos(self) -> Self; + + /// Computes the tangent of a number (in radians). + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let x = f64::consts::PI/4.0; + /// let abs_difference = (x.tan() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-14); + /// ``` + fn tan(self) -> Self; + + /// Computes the arcsine of a number. Return value is in radians in + /// the range [-pi/2, pi/2] or NaN if the number is outside the range + /// [-1, 1]. + /// + /// # Panics + /// + /// If this type does not support a NaN representation, this function should panic + /// if the number is outside the range [-1, 1]. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let f = f64::consts::PI / 2.0; + /// + /// // asin(sin(pi/2)) + /// let abs_difference = (f.sin().asin() - f64::consts::PI / 2.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn asin(self) -> Self; + + /// Computes the arccosine of a number. Return value is in radians in + /// the range [0, pi] or NaN if the number is outside the range + /// [-1, 1]. + /// + /// # Panics + /// + /// If this type does not support a NaN representation, this function should panic + /// if the number is outside the range [-1, 1]. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let f = f64::consts::PI / 4.0; + /// + /// // acos(cos(pi/4)) + /// let abs_difference = (f.cos().acos() - f64::consts::PI / 4.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn acos(self) -> Self; + + /// Computes the arctangent of a number. Return value is in radians in the + /// range [-pi/2, pi/2]; + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let f = 1.0; + /// + /// // atan(tan(1)) + /// let abs_difference = (f.tan().atan() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn atan(self) -> Self; + + /// Computes the four quadrant arctangent of `self` (`y`) and `other` (`x`). + /// + /// * `x = 0`, `y = 0`: `0` + /// * `x >= 0`: `arctan(y/x)` -> `[-pi/2, pi/2]` + /// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]` + /// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)` + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let pi = f64::consts::PI; + /// // All angles from horizontal right (+x) + /// // 45 deg counter-clockwise + /// let x1 = 3.0; + /// let y1 = -3.0; + /// + /// // 135 deg clockwise + /// let x2 = -3.0; + /// let y2 = 3.0; + /// + /// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0)).abs(); + /// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0).abs(); + /// + /// assert!(abs_difference_1 < 1e-10); + /// assert!(abs_difference_2 < 1e-10); + /// ``` + fn atan2(self, other: Self) -> Self; + + /// Simultaneously computes the sine and cosine of the number, `x`. Returns + /// `(sin(x), cos(x))`. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let x = f64::consts::PI/4.0; + /// let f = x.sin_cos(); + /// + /// let abs_difference_0 = (f.0 - x.sin()).abs(); + /// let abs_difference_1 = (f.1 - x.cos()).abs(); + /// + /// assert!(abs_difference_0 < 1e-10); + /// assert!(abs_difference_0 < 1e-10); + /// ``` + fn sin_cos(self) -> (Self, Self); + + /// Returns `e^(self) - 1` in a way that is accurate even if the + /// number is close to zero. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 7.0; + /// + /// // e^(ln(7)) - 1 + /// let abs_difference = (x.ln().exp_m1() - 6.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn exp_m1(self) -> Self; + + /// Returns `ln(1+n)` (natural logarithm) more accurately than if + /// the operations were performed separately. + /// + /// # Panics + /// + /// If this type does not support a NaN representation, this function should panic + /// if `self-1 <= 0`. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let x = f64::consts::E - 1.0; + /// + /// // ln(1 + (e - 1)) == ln(e) == 1 + /// let abs_difference = (x.ln_1p() - 1.0).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn ln_1p(self) -> Self; + + /// Hyperbolic sine function. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let e = f64::consts::E; + /// let x = 1.0; + /// + /// let f = x.sinh(); + /// // Solving sinh() at 1 gives `(e^2-1)/(2e)` + /// let g = (e*e - 1.0)/(2.0*e); + /// let abs_difference = (f - g).abs(); + /// + /// assert!(abs_difference < 1e-10); + /// ``` + fn sinh(self) -> Self; + + /// Hyperbolic cosine function. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let e = f64::consts::E; + /// let x = 1.0; + /// let f = x.cosh(); + /// // Solving cosh() at 1 gives this result + /// let g = (e*e + 1.0)/(2.0*e); + /// let abs_difference = (f - g).abs(); + /// + /// // Same result + /// assert!(abs_difference < 1.0e-10); + /// ``` + fn cosh(self) -> Self; + + /// Hyperbolic tangent function. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let e = f64::consts::E; + /// let x = 1.0; + /// + /// let f = x.tanh(); + /// // Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))` + /// let g = (1.0 - e.powi(-2))/(1.0 + e.powi(-2)); + /// let abs_difference = (f - g).abs(); + /// + /// assert!(abs_difference < 1.0e-10); + /// ``` + fn tanh(self) -> Self; + + /// Inverse hyperbolic sine function. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 1.0; + /// let f = x.sinh().asinh(); + /// + /// let abs_difference = (f - x).abs(); + /// + /// assert!(abs_difference < 1.0e-10); + /// ``` + fn asinh(self) -> Self; + + /// Inverse hyperbolic cosine function. + /// + /// ``` + /// use num_traits::real::Real; + /// + /// let x = 1.0; + /// let f = x.cosh().acosh(); + /// + /// let abs_difference = (f - x).abs(); + /// + /// assert!(abs_difference < 1.0e-10); + /// ``` + fn acosh(self) -> Self; + + /// Inverse hyperbolic tangent function. + /// + /// ``` + /// use num_traits::real::Real; + /// use std::f64; + /// + /// let e = f64::consts::E; + /// let f = e.tanh().atanh(); + /// + /// let abs_difference = (f - e).abs(); + /// + /// assert!(abs_difference < 1.0e-10); + /// ``` + fn atanh(self) -> Self; +} + +impl Real for T { + forward! { + Float::min_value() -> Self; + Float::min_positive_value() -> Self; + Float::epsilon() -> Self; + Float::max_value() -> Self; + } + forward! { + Float::floor(self) -> Self; + Float::ceil(self) -> Self; + Float::round(self) -> Self; + Float::trunc(self) -> Self; + Float::fract(self) -> Self; + Float::abs(self) -> Self; + Float::signum(self) -> Self; + Float::is_sign_positive(self) -> bool; + Float::is_sign_negative(self) -> bool; + Float::mul_add(self, a: Self, b: Self) -> Self; + Float::recip(self) -> Self; + Float::powi(self, n: i32) -> Self; + Float::powf(self, n: Self) -> Self; + Float::sqrt(self) -> Self; + Float::exp(self) -> Self; + Float::exp2(self) -> Self; + Float::ln(self) -> Self; + Float::log(self, base: Self) -> Self; + Float::log2(self) -> Self; + Float::log10(self) -> Self; + Float::to_degrees(self) -> Self; + Float::to_radians(self) -> Self; + Float::max(self, other: Self) -> Self; + Float::min(self, other: Self) -> Self; + Float::abs_sub(self, other: Self) -> Self; + Float::cbrt(self) -> Self; + Float::hypot(self, other: Self) -> Self; + Float::sin(self) -> Self; + Float::cos(self) -> Self; + Float::tan(self) -> Self; + Float::asin(self) -> Self; + Float::acos(self) -> Self; + Float::atan(self) -> Self; + Float::atan2(self, other: Self) -> Self; + Float::sin_cos(self) -> (Self, Self); + Float::exp_m1(self) -> Self; + Float::ln_1p(self) -> Self; + Float::sinh(self) -> Self; + Float::cosh(self) -> Self; + Float::tanh(self) -> Self; + Float::asinh(self) -> Self; + Float::acosh(self) -> Self; + Float::atanh(self) -> Self; + } +} diff --git a/third_party/cargo/vendor/num-traits-0.2.11/src/sign.rs b/third_party/cargo/vendor/num-traits-0.2.11/src/sign.rs new file mode 100644 index 0000000..26d44c5 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/src/sign.rs @@ -0,0 +1,225 @@ +use core::num::Wrapping; +use core::ops::Neg; + +use float::FloatCore; +use Num; + +/// Useful functions for signed numbers (i.e. numbers that can be negative). +pub trait Signed: Sized + Num + Neg { + /// Computes the absolute value. + /// + /// For `f32` and `f64`, `NaN` will be returned if the number is `NaN`. + /// + /// For signed integers, `::MIN` will be returned if the number is `::MIN`. + fn abs(&self) -> Self; + + /// The positive difference of two numbers. + /// + /// Returns `zero` if the number is less than or equal to `other`, otherwise the difference + /// between `self` and `other` is returned. + fn abs_sub(&self, other: &Self) -> Self; + + /// Returns the sign of the number. + /// + /// For `f32` and `f64`: + /// + /// * `1.0` if the number is positive, `+0.0` or `INFINITY` + /// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` + /// * `NaN` if the number is `NaN` + /// + /// For signed integers: + /// + /// * `0` if the number is zero + /// * `1` if the number is positive + /// * `-1` if the number is negative + fn signum(&self) -> Self; + + /// Returns true if the number is positive and false if the number is zero or negative. + fn is_positive(&self) -> bool; + + /// Returns true if the number is negative and false if the number is zero or positive. + fn is_negative(&self) -> bool; +} + +macro_rules! signed_impl { + ($($t:ty)*) => ($( + impl Signed for $t { + #[inline] + fn abs(&self) -> $t { + if self.is_negative() { -*self } else { *self } + } + + #[inline] + fn abs_sub(&self, other: &$t) -> $t { + if *self <= *other { 0 } else { *self - *other } + } + + #[inline] + fn signum(&self) -> $t { + match *self { + n if n > 0 => 1, + 0 => 0, + _ => -1, + } + } + + #[inline] + fn is_positive(&self) -> bool { *self > 0 } + + #[inline] + fn is_negative(&self) -> bool { *self < 0 } + } + )*) +} + +signed_impl!(isize i8 i16 i32 i64); + +#[cfg(has_i128)] +signed_impl!(i128); + +impl Signed for Wrapping +where + Wrapping: Num + Neg>, +{ + #[inline] + fn abs(&self) -> Self { + Wrapping(self.0.abs()) + } + + #[inline] + fn abs_sub(&self, other: &Self) -> Self { + Wrapping(self.0.abs_sub(&other.0)) + } + + #[inline] + fn signum(&self) -> Self { + Wrapping(self.0.signum()) + } + + #[inline] + fn is_positive(&self) -> bool { + self.0.is_positive() + } + + #[inline] + fn is_negative(&self) -> bool { + self.0.is_negative() + } +} + +macro_rules! signed_float_impl { + ($t:ty) => { + impl Signed for $t { + /// Computes the absolute value. Returns `NAN` if the number is `NAN`. + #[inline] + fn abs(&self) -> $t { + FloatCore::abs(*self) + } + + /// The positive difference of two numbers. Returns `0.0` if the number is + /// less than or equal to `other`, otherwise the difference between`self` + /// and `other` is returned. + #[inline] + fn abs_sub(&self, other: &$t) -> $t { + if *self <= *other { + 0. + } else { + *self - *other + } + } + + /// # Returns + /// + /// - `1.0` if the number is positive, `+0.0` or `INFINITY` + /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` + /// - `NAN` if the number is NaN + #[inline] + fn signum(&self) -> $t { + FloatCore::signum(*self) + } + + /// Returns `true` if the number is positive, including `+0.0` and `INFINITY` + #[inline] + fn is_positive(&self) -> bool { + FloatCore::is_sign_positive(*self) + } + + /// Returns `true` if the number is negative, including `-0.0` and `NEG_INFINITY` + #[inline] + fn is_negative(&self) -> bool { + FloatCore::is_sign_negative(*self) + } + } + }; +} + +signed_float_impl!(f32); +signed_float_impl!(f64); + +/// Computes the absolute value. +/// +/// For `f32` and `f64`, `NaN` will be returned if the number is `NaN` +/// +/// For signed integers, `::MIN` will be returned if the number is `::MIN`. +#[inline(always)] +pub fn abs(value: T) -> T { + value.abs() +} + +/// The positive difference of two numbers. +/// +/// Returns zero if `x` is less than or equal to `y`, otherwise the difference +/// between `x` and `y` is returned. +#[inline(always)] +pub fn abs_sub(x: T, y: T) -> T { + x.abs_sub(&y) +} + +/// Returns the sign of the number. +/// +/// For `f32` and `f64`: +/// +/// * `1.0` if the number is positive, `+0.0` or `INFINITY` +/// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` +/// * `NaN` if the number is `NaN` +/// +/// For signed integers: +/// +/// * `0` if the number is zero +/// * `1` if the number is positive +/// * `-1` if the number is negative +#[inline(always)] +pub fn signum(value: T) -> T { + value.signum() +} + +/// A trait for values which cannot be negative +pub trait Unsigned: Num {} + +macro_rules! empty_trait_impl { + ($name:ident for $($t:ty)*) => ($( + impl $name for $t {} + )*) +} + +empty_trait_impl!(Unsigned for usize u8 u16 u32 u64); +#[cfg(has_i128)] +empty_trait_impl!(Unsigned for u128); + +impl Unsigned for Wrapping where Wrapping: Num {} + +#[test] +fn unsigned_wrapping_is_unsigned() { + fn require_unsigned(_: &T) {} + require_unsigned(&Wrapping(42_u32)); +} +/* +// Commenting this out since it doesn't compile on Rust 1.8, +// because on this version Wrapping doesn't implement Neg and therefore can't +// implement Signed. +#[test] +fn signed_wrapping_is_signed() { + fn require_signed(_: &T) {} + require_signed(&Wrapping(-42)); +} +*/ diff --git a/third_party/cargo/vendor/num-traits-0.2.11/tests/cast.rs b/third_party/cargo/vendor/num-traits-0.2.11/tests/cast.rs new file mode 100644 index 0000000..b3f3108 --- /dev/null +++ b/third_party/cargo/vendor/num-traits-0.2.11/tests/cast.rs @@ -0,0 +1,396 @@ +//! Tests of `num_traits::cast`. + +#![no_std] + +#[cfg(feature = "std")] +#[macro_use] +extern crate std; + +extern crate num_traits; + +use num_traits::cast::*; +use num_traits::Bounded; + +use core::{f32, f64}; +#[cfg(has_i128)] +use core::{i128, u128}; +use core::{i16, i32, i64, i8, isize}; +use core::{u16, u32, u64, u8, usize}; + +use core::fmt::Debug; +use core::mem; +use core::num::Wrapping; + +#[test] +fn to_primitive_float() { + let f32_toolarge = 1e39f64; + assert_eq!(f32_toolarge.to_f32(), None); + assert_eq!((f32::MAX as f64).to_f32(), Some(f32::MAX)); + assert_eq!((-f32::MAX as f64).to_f32(), Some(-f32::MAX)); + assert_eq!(f64::INFINITY.to_f32(), Some(f32::INFINITY)); + assert_eq!((f64::NEG_INFINITY).to_f32(), Some(f32::NEG_INFINITY)); + assert!((f64::NAN).to_f32().map_or(false, |f| f.is_nan())); +} + +#[test] +fn wrapping_to_primitive() { + macro_rules! test_wrapping_to_primitive { + ($($t:ty)+) => { + $({ + let i: $t = 0; + let w = Wrapping(i); + assert_eq!(i.to_u8(), w.to_u8()); + assert_eq!(i.to_u16(), w.to_u16()); + assert_eq!(i.to_u32(), w.to_u32()); + assert_eq!(i.to_u64(), w.to_u64()); + assert_eq!(i.to_usize(), w.to_usize()); + assert_eq!(i.to_i8(), w.to_i8()); + assert_eq!(i.to_i16(), w.to_i16()); + assert_eq!(i.to_i32(), w.to_i32()); + assert_eq!(i.to_i64(), w.to_i64()); + assert_eq!(i.to_isize(), w.to_isize()); + assert_eq!(i.to_f32(), w.to_f32()); + assert_eq!(i.to_f64(), w.to_f64()); + })+ + }; + } + + test_wrapping_to_primitive!(usize u8 u16 u32 u64 isize i8 i16 i32 i64); +} + +#[test] +fn wrapping_is_toprimitive() { + fn require_toprimitive(_: &T) {} + require_toprimitive(&Wrapping(42)); +} + +#[test] +fn wrapping_is_fromprimitive() { + fn require_fromprimitive(_: &T) {} + require_fromprimitive(&Wrapping(42)); +} + +#[test] +fn wrapping_is_numcast() { + fn require_numcast(_: &T) {} + require_numcast(&Wrapping(42)); +} + +#[test] +fn as_primitive() { + let x: f32 = (1.625f64).as_(); + assert_eq!(x, 1.625f32); + + let x: f32 = (3.14159265358979323846f64).as_(); + assert_eq!(x, 3.1415927f32); + + let x: u8 = (768i16).as_(); + assert_eq!(x, 0); +} + +#[test] +fn float_to_integer_checks_overflow() { + // This will overflow an i32 + let source: f64 = 1.0e+123f64; + + // Expect the overflow to be caught + assert_eq!(cast::(source), None); +} + +#[test] +fn cast_to_int_checks_overflow() { + let big_f: f64 = 1.0e123; + let normal_f: f64 = 1.0; + let small_f: f64 = -1.0e123; + assert_eq!(None, cast::(big_f)); + assert_eq!(None, cast::(big_f)); + assert_eq!(None, cast::(big_f)); + assert_eq!(None, cast::(big_f)); + assert_eq!(None, cast::(big_f)); + + assert_eq!(Some(normal_f as isize), cast::(normal_f)); + assert_eq!(Some(normal_f as i8), cast::(normal_f)); + assert_eq!(Some(normal_f as i16), cast::(normal_f)); + assert_eq!(Some(normal_f as i32), cast::(normal_f)); + assert_eq!(Some(normal_f as i64), cast::(normal_f)); + + assert_eq!(None, cast::(small_f)); + assert_eq!(None, cast::(small_f)); + assert_eq!(None, cast::(small_f)); + assert_eq!(None, cast::(small_f)); + assert_eq!(None, cast::(small_f)); +} + +#[test] +fn cast_to_unsigned_int_checks_overflow() { + let big_f: f64 = 1.0e123; + let normal_f: f64 = 1.0; + let small_f: f64 = -1.0e123; + assert_eq!(None, cast::(big_f)); + assert_eq!(None, cast::(big_f)); + assert_eq!(None, cast::(big_f)); + assert_eq!(None, cast::(big_f)); + assert_eq!(None, cast::(big_f)); + + assert_eq!(Some(normal_f as usize), cast::(normal_f)); + assert_eq!(Some(normal_f as u8), cast::(normal_f)); + assert_eq!(Some(normal_f as u16), cast::(normal_f)); + assert_eq!(Some(normal_f as u32), cast::(normal_f)); + assert_eq!(Some(normal_f as u64), cast::(normal_f)); + + assert_eq!(None, cast::(small_f)); + assert_eq!(None, cast::(small_f)); + assert_eq!(None, cast::(small_f)); + assert_eq!(None, cast::(small_f)); + assert_eq!(None, cast::(small_f)); +} + +#[test] +#[cfg(has_i128)] +fn cast_to_i128_checks_overflow() { + let big_f: f64 = 1.0e123; + let normal_f: f64 = 1.0; + let small_f: f64 = -1.0e123; + assert_eq!(None, cast::(big_f)); + assert_eq!(None, cast::(big_f)); + + assert_eq!(Some(normal_f as i128), cast::(normal_f)); + assert_eq!(Some(normal_f as u128), cast::(normal_f)); + + assert_eq!(None, cast::(small_f)); + assert_eq!(None, cast::(small_f)); +} + +#[cfg(feature = "std")] +fn dbg(args: ::core::fmt::Arguments) { + println!("{}", args); +} + +#[cfg(not(feature = "std"))] +fn dbg(_: ::core::fmt::Arguments) {} + +// Rust 1.8 doesn't handle cfg on macros correctly +macro_rules! dbg { ($($tok:tt)*) => { dbg(format_args!($($tok)*)) } } + +macro_rules! float_test_edge { + ($f:ident -> $($t:ident)+) => { $({ + dbg!("testing cast edge cases for {} -> {}", stringify!($f), stringify!($t)); + + let small = if $t::MIN == 0 || mem::size_of::<$t>() < mem::size_of::<$f>() { + $t::MIN as $f - 1.0 + } else { + ($t::MIN as $f).raw_offset(1).floor() + }; + let fmin = small.raw_offset(-1); + dbg!(" testing min {}\n\tvs. {:.0}\n\tand {:.0}", $t::MIN, fmin, small); + assert_eq!(Some($t::MIN), cast::<$f, $t>($t::MIN as $f)); + assert_eq!(Some($t::MIN), cast::<$f, $t>(fmin)); + assert_eq!(None, cast::<$f, $t>(small)); + + let (max, large) = if mem::size_of::<$t>() < mem::size_of::<$f>() { + ($t::MAX, $t::MAX as $f + 1.0) + } else { + let large = $t::MAX as $f; // rounds up! + let max = large.raw_offset(-1) as $t; // the next smallest possible + assert_eq!(max.count_ones(), $f::MANTISSA_DIGITS); + (max, large) + }; + let fmax = large.raw_offset(-1); + dbg!(" testing max {}\n\tvs. {:.0}\n\tand {:.0}", max, fmax, large); + assert_eq!(Some(max), cast::<$f, $t>(max as $f)); + assert_eq!(Some(max), cast::<$f, $t>(fmax)); + assert_eq!(None, cast::<$f, $t>(large)); + + dbg!(" testing non-finite values"); + assert_eq!(None, cast::<$f, $t>($f::NAN)); + assert_eq!(None, cast::<$f, $t>($f::INFINITY)); + assert_eq!(None, cast::<$f, $t>($f::NEG_INFINITY)); + })+} +} + +trait RawOffset: Sized { + type Raw; + fn raw_offset(self, offset: Self::Raw) -> Self; +} + +impl RawOffset for f32 { + type Raw = i32; + fn raw_offset(self, offset: Self::Raw) -> Self { + unsafe { + let raw: Self::Raw = mem::transmute(self); + mem::transmute(raw + offset) + } + } +} + +impl RawOffset for f64 { + type Raw = i64; + fn raw_offset(self, offset: Self::Raw) -> Self { + unsafe { + let raw: Self::Raw = mem::transmute(self); + mem::transmute(raw + offset) + } + } +} + +#[test] +fn cast_float_to_int_edge_cases() { + float_test_edge!(f32 -> isize i8 i16 i32 i64); + float_test_edge!(f32 -> usize u8 u16 u32 u64); + float_test_edge!(f64 -> isize i8 i16 i32 i64); + float_test_edge!(f64 -> usize u8 u16 u32 u64); +} + +#[test] +#[cfg(has_i128)] +fn cast_float_to_i128_edge_cases() { + float_test_edge!(f32 -> i128 u128); + float_test_edge!(f64 -> i128 u128); +} + +macro_rules! int_test_edge { + ($f:ident -> { $($t:ident)+ } with $BigS:ident $BigU:ident ) => { $({ + fn test_edge() { + dbg!("testing cast edge cases for {} -> {}", stringify!($f), stringify!($t)); + + match ($f::MIN as $BigS).cmp(&($t::MIN as $BigS)) { + Greater => { + assert_eq!(Some($f::MIN as $t), cast::<$f, $t>($f::MIN)); + } + Equal => { + assert_eq!(Some($t::MIN), cast::<$f, $t>($f::MIN)); + } + Less => { + let min = $t::MIN as $f; + assert_eq!(Some($t::MIN), cast::<$f, $t>(min)); + assert_eq!(None, cast::<$f, $t>(min - 1)); + } + } + + match ($f::MAX as $BigU).cmp(&($t::MAX as $BigU)) { + Greater => { + let max = $t::MAX as $f; + assert_eq!(Some($t::MAX), cast::<$f, $t>(max)); + assert_eq!(None, cast::<$f, $t>(max + 1)); + } + Equal => { + assert_eq!(Some($t::MAX), cast::<$f, $t>($f::MAX)); + } + Less => { + assert_eq!(Some($f::MAX as $t), cast::<$f, $t>($f::MAX)); + } + } + } + test_edge(); + })+} +} + +#[test] +fn cast_int_to_int_edge_cases() { + use core::cmp::Ordering::*; + + macro_rules! test_edge { + ($( $from:ident )+) => { $({ + int_test_edge!($from -> { isize i8 i16 i32 i64 } with i64 u64); + int_test_edge!($from -> { usize u8 u16 u32 u64 } with i64 u64); + })+} + } + + test_edge!(isize i8 i16 i32 i64); + test_edge!(usize u8 u16 u32 u64); +} + +#[test] +#[cfg(has_i128)] +fn cast_int_to_128_edge_cases() { + use core::cmp::Ordering::*; + + macro_rules! test_edge { + ($( $t:ident )+) => { + $( + int_test_edge!($t -> { i128 u128 } with i128 u128); + )+ + int_test_edge!(i128 -> { $( $t )+ } with i128 u128); + int_test_edge!(u128 -> { $( $t )+ } with i128 u128); + } + } + + test_edge!(isize i8 i16 i32 i64 i128); + test_edge!(usize u8 u16 u32 u64 u128); +} + +#[test] +fn newtype_from_primitive() { + #[derive(PartialEq, Debug)] + struct New(T); + + // minimal impl + impl FromPrimitive for New { + fn from_i64(n: i64) -> Option { + T::from_i64(n).map(New) + } + + fn from_u64(n: u64) -> Option { + T::from_u64(n).map(New) + } + } + + macro_rules! assert_eq_from { + ($( $from:ident )+) => {$( + assert_eq!(T::$from(Bounded::min_value()).map(New), + New::::$from(Bounded::min_value())); + assert_eq!(T::$from(Bounded::max_value()).map(New), + New::::$from(Bounded::max_value())); + )+} + } + + fn check() { + assert_eq_from!(from_i8 from_i16 from_i32 from_i64 from_isize); + assert_eq_from!(from_u8 from_u16 from_u32 from_u64 from_usize); + assert_eq_from!(from_f32 from_f64); + } + + macro_rules! check { + ($( $ty:ty )+) => {$( check::<$ty>(); )+} + } + check!(i8 i16 i32 i64 isize); + check!(u8 u16 u32 u64 usize); +} + +#[test] +fn newtype_to_primitive() { + #[derive(PartialEq, Debug)] + struct New(T); + + // minimal impl + impl ToPrimitive for New { + fn to_i64(&self) -> Option { + self.0.to_i64() + } + + fn to_u64(&self) -> Option { + self.0.to_u64() + } + } + + macro_rules! assert_eq_to { + ($( $to:ident )+) => {$( + assert_eq!(T::$to(&Bounded::min_value()), + New::::$to(&New(Bounded::min_value()))); + assert_eq!(T::$to(&Bounded::max_value()), + New::::$to(&New(Bounded::max_value()))); + )+} + } + + fn check() { + assert_eq_to!(to_i8 to_i16 to_i32 to_i64 to_isize); + assert_eq_to!(to_u8 to_u16 to_u32 to_u64 to_usize); + assert_eq_to!(to_f32 to_f64); + } + + macro_rules! check { + ($( $ty:ty )+) => {$( check::<$ty>(); )+} + } + check!(i8 i16 i32 i64 isize); + check!(u8 u16 u32 u64 usize); +} diff --git a/third_party/cargo/vendor/num_cpus-1.12.0/.cargo-checksum.json b/third_party/cargo/vendor/num_cpus-1.12.0/.cargo-checksum.json new file mode 100644 index 0000000..88ed1f2 --- /dev/null +++ b/third_party/cargo/vendor/num_cpus-1.12.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"a2123abd3878019668c6afc950368eec5ef43340e6b3ac46b8ab0d8c453d484c","CONTRIBUTING.md":"2390961aab1bba026135338da1216b6cc828dfaeed9357d9c155c55a252d3efb","Cargo.toml":"fa31772b1643d482a785c1b78b581a377d408ffe9715c8b2d45d80f6c7d09f62","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0593d22d122d4bfec6407115e3907546312976f75473417aaa4c57ecd2095ae6","README.md":"12451d6905fe9cdac206410de8071b562e5ea936b6e55a19ac97982831a0fcdb","examples/values.rs":"46c833324b7339d359054c4f8e8284259e860df206c552c63b5893ade59c16a6","src/lib.rs":"f0f45c2b20071c0cd947da3664330d696c0d33ed50352e182ea2ff4792a663b9"},"package":"46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"} \ No newline at end of file diff --git a/third_party/cargo/vendor/num_cpus-1.12.0/BUILD b/third_party/cargo/vendor/num_cpus-1.12.0/BUILD new file mode 100644 index 0000000..7d6bc7c --- /dev/null +++ b/third_party/cargo/vendor/num_cpus-1.12.0/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "num_cpus", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.12.0", + crate_features = [ + ], +) + +# Unsupported target "values" with type "example" omitted diff --git a/third_party/cargo/vendor/num_cpus-1.12.0/CHANGELOG.md b/third_party/cargo/vendor/num_cpus-1.12.0/CHANGELOG.md new file mode 100644 index 0000000..5c433df --- /dev/null +++ b/third_party/cargo/vendor/num_cpus-1.12.0/CHANGELOG.md @@ -0,0 +1,125 @@ +## v1.12.0 + +#### Fixes + +- fix `get` on OpenBSD to ignore offline CPUs +- implement `get_physical` on OpenBSD + +## v1.11.1 + +#### Fixes + +- Use `mem::zeroed` instead of `mem::uninitialized`. + +## v1.11.0 + +#### Features + +- add `hermit` target OS support +- removes `bitrig` support + +#### Fixes + +- fix `get_physical` count with AMD hyperthreading. + +## v1.10.1 + +#### Fixes + +- improve `haiku` CPU detection + +## v1.10.0 + +#### Features + +- add `illumos` target OS support +- add default fallback if target is unknown to `1` + +## v1.9.0 + +#### Features + +- add `sgx` target env support + +## v1.8.0 + +#### Features + +- add `wasm-unknown-unknown` target support + +## v1.7.0 + +#### Features + +- add `get_physical` support for macOS + +#### Fixes + +- use `_SC_NPROCESSORS_CONF` on Unix targets + +### v1.6.2 + +#### Fixes + +- revert 1.6.1 for now + +### v1.6.1 + +#### Fixes + +- fixes sometimes incorrect num on Android/ARM Linux (#45) + +## v1.6.0 + +#### Features + +- `get_physical` gains Windows support + +### v1.5.1 + +#### Fixes + +- fix `get` to return 1 if `sysconf(_SC_NPROCESSORS_ONLN)` failed + +## v1.5.0 + +#### Features + +- `get()` now checks `sched_affinity` on Linux + +## v1.4.0 + +#### Features + +- add `haiku` target support + +## v1.3.0 + +#### Features + +- add `redox` target support + +### v1.2.1 + +#### Fixes + +- fixes `get_physical` count (454ff1b) + +## v1.2.0 + +#### Features + +- add `emscripten` target support +- add `fuchsia` target support + +## v1.1.0 + +#### Features + +- added `get_physical` function to return number of physical CPUs found + +# v1.0.0 + +#### Features + +- `get` function returns number of CPUs (physical and virtual) of current platform diff --git a/third_party/cargo/vendor/num_cpus-1.12.0/CONTRIBUTING.md b/third_party/cargo/vendor/num_cpus-1.12.0/CONTRIBUTING.md new file mode 100644 index 0000000..5685b08 --- /dev/null +++ b/third_party/cargo/vendor/num_cpus-1.12.0/CONTRIBUTING.md @@ -0,0 +1,16 @@ +# Contributing + +## License + +Licensed under either of + + * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any +additional terms or conditions. diff --git a/third_party/cargo/vendor/num_cpus-1.12.0/Cargo.toml b/third_party/cargo/vendor/num_cpus-1.12.0/Cargo.toml new file mode 100644 index 0000000..949e0fe --- /dev/null +++ b/third_party/cargo/vendor/num_cpus-1.12.0/Cargo.toml @@ -0,0 +1,29 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "num_cpus" +version = "1.12.0" +authors = ["Sean McArthur "] +description = "Get the number of CPUs on a machine." +documentation = "https://docs.rs/num_cpus" +readme = "README.md" +keywords = ["cpu", "cpus", "cores"] +categories = ["hardware-support"] +license = "MIT/Apache-2.0" +repository = "https://github.com/seanmonstar/num_cpus" +[dependencies.libc] +version = "0.2.26" +[dev-dependencies.doc-comment] +version = "0.3" +[target."cfg(all(any(target_arch = \"x86_64\", target_arch = \"aarch64\"), target_os = \"hermit\"))".dependencies.hermit-abi] +version = "0.1.3" diff --git a/third_party/cargo/vendor/num_cpus-1.12.0/LICENSE-APACHE b/third_party/cargo/vendor/num_cpus-1.12.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/num_cpus-1.12.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/num_cpus-1.12.0/LICENSE-MIT b/third_party/cargo/vendor/num_cpus-1.12.0/LICENSE-MIT new file mode 100644 index 0000000..8e91dc9 --- /dev/null +++ b/third_party/cargo/vendor/num_cpus-1.12.0/LICENSE-MIT @@ -0,0 +1,20 @@ +Copyright (c) 2015 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/third_party/cargo/vendor/num_cpus-1.12.0/README.md b/third_party/cargo/vendor/num_cpus-1.12.0/README.md new file mode 100644 index 0000000..a0bbe97 --- /dev/null +++ b/third_party/cargo/vendor/num_cpus-1.12.0/README.md @@ -0,0 +1,28 @@ +# num_cpus + +[![crates.io](http://meritbadge.herokuapp.com/num_cpus)](https://crates.io/crates/num_cpus) +[![Travis CI Status](https://travis-ci.org/seanmonstar/num_cpus.svg?branch=master)](https://travis-ci.org/seanmonstar/num_cpus) +[![AppVeyor status](https://ci.appveyor.com/api/projects/status/qn8t6grhko5jwno6?svg=true)](https://ci.appveyor.com/project/seanmonstar/num-cpus) + +- [Documentation](https://docs.rs/num_cpus) +- [CHANGELOG](CHANGELOG.md) + +Count the number of CPUs on the current machine. + +## Usage + +Add to Cargo.toml: + +```toml +[dependencies] +num_cpus = "1.0" +``` + +In your `main.rs` or `lib.rs`: + +```rust +extern crate num_cpus; + +// count logical cores this process could try to use +let num = num_cpus::get(); +``` diff --git a/third_party/cargo/vendor/num_cpus-1.12.0/examples/values.rs b/third_party/cargo/vendor/num_cpus-1.12.0/examples/values.rs new file mode 100644 index 0000000..041cfaf --- /dev/null +++ b/third_party/cargo/vendor/num_cpus-1.12.0/examples/values.rs @@ -0,0 +1,6 @@ +extern crate num_cpus; + +fn main() { + println!("Logical CPUs: {}", num_cpus::get()); + println!("Physical CPUs: {}", num_cpus::get_physical()); +} diff --git a/third_party/cargo/vendor/num_cpus-1.12.0/src/lib.rs b/third_party/cargo/vendor/num_cpus-1.12.0/src/lib.rs new file mode 100644 index 0000000..807af39 --- /dev/null +++ b/third_party/cargo/vendor/num_cpus-1.12.0/src/lib.rs @@ -0,0 +1,526 @@ +//! A crate with utilities to determine the number of CPUs available on the +//! current system. +//! +//! Sometimes the CPU will exaggerate the number of CPUs it contains, because it can use +//! [processor tricks] to deliver increased performance when there are more threads. This +//! crate provides methods to get both the logical and physical numbers of cores. +//! +//! This information can be used as a guide to how many tasks can be run in parallel. +//! There are many properties of the system architecture that will affect parallelism, +//! for example memory access speeds (for all the caches and RAM) and the physical +//! architecture of the processor, so the number of CPUs should be used as a rough guide +//! only. +//! +//! +//! ## Examples +//! +//! Fetch the number of logical CPUs. +//! +//! ``` +//! let cpus = num_cpus::get(); +//! ``` +//! +//! See [`rayon::Threadpool`] for an example of where the number of CPUs could be +//! used when setting up parallel jobs (Where the threadpool example uses a fixed +//! number 8, it could use the number of CPUs). +//! +//! [processor tricks]: https://en.wikipedia.org/wiki/Simultaneous_multithreading +//! [`rayon::ThreadPool`]: https://docs.rs/rayon/1.*/rayon/struct.ThreadPool.html +#![cfg_attr(test, deny(warnings))] +#![deny(missing_docs)] +#![doc(html_root_url = "https://docs.rs/num_cpus/1.12.0")] +#![allow(non_snake_case)] + +#[cfg(not(windows))] +extern crate libc; + +#[cfg(target_os = "hermit")] +extern crate hermit_abi; + +#[cfg(test)] +#[macro_use] +extern crate doc_comment; + +#[cfg(test)] +doctest!("../README.md"); + +/// Returns the number of available CPUs of the current system. +/// +/// This function will get the number of logical cores. Sometimes this is different from the number +/// of physical cores (See [Simultaneous multithreading on Wikipedia][smt]). +/// +/// # Examples +/// +/// ``` +/// let cpus = num_cpus::get(); +/// if cpus > 1 { +/// println!("We are on a multicore system with {} CPUs", cpus); +/// } else { +/// println!("We are on a single core system"); +/// } +/// ``` +/// +/// # Note +/// +/// This will check [sched affinity] on Linux, showing a lower number of CPUs if the current +/// thread does not have access to all the computer's CPUs. +/// +/// [smt]: https://en.wikipedia.org/wiki/Simultaneous_multithreading +/// [sched affinity]: http://www.gnu.org/software/libc/manual/html_node/CPU-Affinity.html +#[inline] +pub fn get() -> usize { + get_num_cpus() +} + +/// Returns the number of physical cores of the current system. +/// +/// # Note +/// +/// Physical count is supported only on Linux, mac OS and Windows platforms. +/// On other platforms, or if the physical count fails on supported platforms, +/// this function returns the same as [`get()`], which is the number of logical +/// CPUS. +/// +/// # Examples +/// +/// ``` +/// let logical_cpus = num_cpus::get(); +/// let physical_cpus = num_cpus::get_physical(); +/// if logical_cpus > physical_cpus { +/// println!("We have simultaneous multithreading with about {:.2} \ +/// logical cores to 1 physical core.", +/// (logical_cpus as f64) / (physical_cpus as f64)); +/// } else if logical_cpus == physical_cpus { +/// println!("Either we don't have simultaneous multithreading, or our \ +/// system doesn't support getting the number of physical CPUs."); +/// } else { +/// println!("We have less logical CPUs than physical CPUs, maybe we only have access to \ +/// some of the CPUs on our system."); +/// } +/// ``` +/// +/// [`get()`]: fn.get.html +#[inline] +pub fn get_physical() -> usize { + get_num_physical_cpus() +} + + +#[cfg(not(any(target_os = "linux", target_os = "windows", target_os="macos", target_os="openbsd")))] +#[inline] +fn get_num_physical_cpus() -> usize { + // Not implemented, fall back + get_num_cpus() +} + +#[cfg(target_os = "windows")] +fn get_num_physical_cpus() -> usize { + match get_num_physical_cpus_windows() { + Some(num) => num, + None => get_num_cpus() + } +} + +#[cfg(target_os = "windows")] +fn get_num_physical_cpus_windows() -> Option { + // Inspired by https://msdn.microsoft.com/en-us/library/ms683194 + + use std::ptr; + use std::mem; + + #[allow(non_upper_case_globals)] + const RelationProcessorCore: u32 = 0; + + #[repr(C)] + #[allow(non_camel_case_types)] + struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION { + mask: usize, + relationship: u32, + _unused: [u64; 2] + } + + extern "system" { + fn GetLogicalProcessorInformation( + info: *mut SYSTEM_LOGICAL_PROCESSOR_INFORMATION, + length: &mut u32 + ) -> u32; + } + + // First we need to determine how much space to reserve. + + // The required size of the buffer, in bytes. + let mut needed_size = 0; + + unsafe { + GetLogicalProcessorInformation(ptr::null_mut(), &mut needed_size); + } + + let struct_size = mem::size_of::() as u32; + + // Could be 0, or some other bogus size. + if needed_size == 0 || needed_size < struct_size || needed_size % struct_size != 0 { + return None; + } + + let count = needed_size / struct_size; + + // Allocate some memory where we will store the processor info. + let mut buf = Vec::with_capacity(count as usize); + + let result; + + unsafe { + result = GetLogicalProcessorInformation(buf.as_mut_ptr(), &mut needed_size); + } + + // Failed for any reason. + if result == 0 { + return None; + } + + let count = needed_size / struct_size; + + unsafe { + buf.set_len(count as usize); + } + + let phys_proc_count = buf.iter() + // Only interested in processor packages (physical processors.) + .filter(|proc_info| proc_info.relationship == RelationProcessorCore) + .count(); + + if phys_proc_count == 0 { + None + } else { + Some(phys_proc_count) + } +} + +#[cfg(target_os = "linux")] +fn get_num_physical_cpus() -> usize { + use std::collections::HashMap; + use std::fs::File; + use std::io::BufRead; + use std::io::BufReader; + + let file = match File::open("/proc/cpuinfo") { + Ok(val) => val, + Err(_) => return get_num_cpus(), + }; + let reader = BufReader::new(file); + let mut map = HashMap::new(); + let mut physid: u32 = 0; + let mut cores: usize = 0; + let mut chgcount = 0; + for line in reader.lines().filter_map(|result| result.ok()) { + let mut it = line.split(':'); + let (key, value) = match (it.next(), it.next()) { + (Some(key), Some(value)) => (key.trim(), value.trim()), + _ => continue, + }; + if key == "physical id" { + match value.parse() { + Ok(val) => physid = val, + Err(_) => break, + }; + chgcount += 1; + } + if key == "cpu cores" { + match value.parse() { + Ok(val) => cores = val, + Err(_) => break, + }; + chgcount += 1; + } + if chgcount == 2 { + map.insert(physid, cores); + chgcount = 0; + } + } + let count = map.into_iter().fold(0, |acc, (_, cores)| acc + cores); + + if count == 0 { + get_num_cpus() + } else { + count + } +} + +#[cfg(windows)] +fn get_num_cpus() -> usize { + #[repr(C)] + struct SYSTEM_INFO { + wProcessorArchitecture: u16, + wReserved: u16, + dwPageSize: u32, + lpMinimumApplicationAddress: *mut u8, + lpMaximumApplicationAddress: *mut u8, + dwActiveProcessorMask: *mut u8, + dwNumberOfProcessors: u32, + dwProcessorType: u32, + dwAllocationGranularity: u32, + wProcessorLevel: u16, + wProcessorRevision: u16, + } + + extern "system" { + fn GetSystemInfo(lpSystemInfo: *mut SYSTEM_INFO); + } + + unsafe { + let mut sysinfo: SYSTEM_INFO = std::mem::zeroed(); + GetSystemInfo(&mut sysinfo); + sysinfo.dwNumberOfProcessors as usize + } +} + +#[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "netbsd"))] +fn get_num_cpus() -> usize { + use std::ptr; + + let mut cpus: libc::c_uint = 0; + let mut cpus_size = std::mem::size_of_val(&cpus); + + unsafe { + cpus = libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as libc::c_uint; + } + if cpus < 1 { + let mut mib = [libc::CTL_HW, libc::HW_NCPU, 0, 0]; + unsafe { + libc::sysctl(mib.as_mut_ptr(), + 2, + &mut cpus as *mut _ as *mut _, + &mut cpus_size as *mut _ as *mut _, + ptr::null_mut(), + 0); + } + if cpus < 1 { + cpus = 1; + } + } + cpus as usize +} + +#[cfg(target_os = "openbsd")] +fn get_num_cpus() -> usize { + use std::ptr; + + let mut cpus: libc::c_uint = 0; + let mut cpus_size = std::mem::size_of_val(&cpus); + let mut mib = [libc::CTL_HW, libc::HW_NCPUONLINE, 0, 0]; + let rc: libc::c_int; + + unsafe { + rc = libc::sysctl(mib.as_mut_ptr(), + 2, + &mut cpus as *mut _ as *mut _, + &mut cpus_size as *mut _ as *mut _, + ptr::null_mut(), + 0); + } + if rc < 0 { + cpus = 1; + } + cpus as usize +} + +#[cfg(target_os = "openbsd")] +fn get_num_physical_cpus() -> usize { + use std::ptr; + + let mut cpus: libc::c_uint = 0; + let mut cpus_size = std::mem::size_of_val(&cpus); + let mut mib = [libc::CTL_HW, libc::HW_NCPU, 0, 0]; + let rc: libc::c_int; + + unsafe { + rc = libc::sysctl(mib.as_mut_ptr(), + 2, + &mut cpus as *mut _ as *mut _, + &mut cpus_size as *mut _ as *mut _, + ptr::null_mut(), + 0); + } + if rc < 0 { + cpus = 1; + } + cpus as usize +} + + +#[cfg(target_os = "macos")] +fn get_num_physical_cpus() -> usize { + use std::ffi::CStr; + use std::ptr; + + let mut cpus: i32 = 0; + let mut cpus_size = std::mem::size_of_val(&cpus); + + let sysctl_name = CStr::from_bytes_with_nul(b"hw.physicalcpu\0") + .expect("byte literal is missing NUL"); + + unsafe { + if 0 != libc::sysctlbyname(sysctl_name.as_ptr(), + &mut cpus as *mut _ as *mut _, + &mut cpus_size as *mut _ as *mut _, + ptr::null_mut(), + 0) { + return get_num_cpus(); + } + } + cpus as usize +} + +#[cfg(target_os = "linux")] +fn get_num_cpus() -> usize { + let mut set: libc::cpu_set_t = unsafe { std::mem::zeroed() }; + if unsafe { libc::sched_getaffinity(0, std::mem::size_of::(), &mut set) } == 0 { + let mut count: u32 = 0; + for i in 0..libc::CPU_SETSIZE as usize { + if unsafe { libc::CPU_ISSET(i, &set) } { + count += 1 + } + } + count as usize + } else { + let cpus = unsafe { libc::sysconf(libc::_SC_NPROCESSORS_ONLN) }; + if cpus < 1 { + 1 + } else { + cpus as usize + } + } +} + +#[cfg(any( + target_os = "nacl", + target_os = "macos", + target_os = "ios", + target_os = "android", + target_os = "solaris", + target_os = "illumos", + target_os = "fuchsia") +)] +fn get_num_cpus() -> usize { + // On ARM targets, processors could be turned off to save power. + // Use `_SC_NPROCESSORS_CONF` to get the real number. + #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + const CONF_NAME: libc::c_int = libc::_SC_NPROCESSORS_CONF; + #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] + const CONF_NAME: libc::c_int = libc::_SC_NPROCESSORS_ONLN; + + let cpus = unsafe { libc::sysconf(CONF_NAME) }; + if cpus < 1 { + 1 + } else { + cpus as usize + } +} + +#[cfg(target_os = "haiku")] +fn get_num_cpus() -> usize { + use std::mem; + + #[allow(non_camel_case_types)] + type bigtime_t = i64; + #[allow(non_camel_case_types)] + type status_t = i32; + + #[repr(C)] + pub struct system_info { + pub boot_time: bigtime_t, + pub cpu_count: u32, + pub max_pages: u64, + pub used_pages: u64, + pub cached_pages: u64, + pub block_cache_pages: u64, + pub ignored_pages: u64, + pub needed_memory: u64, + pub free_memory: u64, + pub max_swap_pages: u64, + pub free_swap_pages: u64, + pub page_faults: u32, + pub max_sems: u32, + pub used_sems: u32, + pub max_ports: u32, + pub used_ports: u32, + pub max_threads: u32, + pub used_threads: u32, + pub max_teams: u32, + pub used_teams: u32, + pub kernel_name: [::std::os::raw::c_char; 256usize], + pub kernel_build_date: [::std::os::raw::c_char; 32usize], + pub kernel_build_time: [::std::os::raw::c_char; 32usize], + pub kernel_version: i64, + pub abi: u32, + } + + extern { + fn get_system_info(info: *mut system_info) -> status_t; + } + + let mut info: system_info = unsafe { mem::zeroed() }; + let status = unsafe { get_system_info(&mut info as *mut _) }; + if status == 0 { + info.cpu_count as usize + } else { + 1 + } +} + +#[cfg(target_os = "hermit")] +fn get_num_cpus() -> usize { + unsafe { hermit_abi::get_processor_count() } +} + +#[cfg(not(any( + target_os = "nacl", + target_os = "macos", + target_os = "ios", + target_os = "android", + target_os = "solaris", + target_os = "illumos", + target_os = "fuchsia", + target_os = "linux", + target_os = "openbsd", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "netbsd", + target_os = "haiku", + target_os = "hermit", + windows, +)))] +fn get_num_cpus() -> usize { + 1 +} + +#[cfg(test)] +mod tests { + fn env_var(name: &'static str) -> Option { + ::std::env::var(name).ok().map(|val| val.parse().unwrap()) + } + + #[test] + fn test_get() { + let num = super::get(); + if let Some(n) = env_var("NUM_CPUS_TEST_GET") { + assert_eq!(num, n); + } else { + assert!(num > 0); + assert!(num < 236_451); + } + } + + #[test] + fn test_get_physical() { + let num = super::get_physical(); + if let Some(n) = env_var("NUM_CPUS_TEST_GET_PHYSICAL") { + assert_eq!(num, n); + } else { + assert!(num > 0); + assert!(num < 236_451); + } + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/.cargo-checksum.json b/third_party/cargo/vendor/objc-0.2.7/.cargo-checksum.json new file mode 100644 index 0000000..d276f10 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"b75b0c2c69a1b22b3e8a554f94353c423aef7e3891a66eefdee0b3a0813debf7","Cargo.toml":"d051e9534ddcac152d11d2c2b6e040136b22397fb5579867fd3de67c0c3b44f3","LICENSE.txt":"e353f37b12aefbb9f9b29490e837cfee05d9bda70804b3562839a3285c1df1e5","README.md":"2798cf78a640ea9fb83bdf27e2c82d98d9f8f7459196ab9db10372fb843c7a65","examples/example.rs":"df5fd939ffa46505b368e4e31aa0a0b144202fbceac72e5343bedb706313ef5e","src/declare.rs":"a4409a3b849413af55398b9b6a86ca482bdea94dd16ce818b39d420228426b54","src/encode.rs":"6e792c73f7cfced248f20cebe93dc038a39d25bdd9cbe1a115464b7baa02885b","src/exception.rs":"a641f9fdb9267e1d44f680b685d650faa2931d5d22949b621c8e2783ed534a4f","src/lib.rs":"1b03c53c792b0abe909d2958d7b692b2264ae0f25a109c15dacf57da2352f6f7","src/macros.rs":"b0d82088510fa6a14b1dfa240e91f85b0d13536bbf1a28d33a5dc932409b7279","src/message/apple/arm.rs":"3df72141b9fa48e7eab13b33acfa76c0eae730c2eedad0cc92ed7f89c51ca0da","src/message/apple/arm64.rs":"3efa598e34232c1e1c2171de864beac7f79e10f85807b23d10537335e0e84bd3","src/message/apple/mod.rs":"8aa9b9419084f92acc4468dae647b6bc3bd4570de0dbffe82dd8b6a18883345e","src/message/apple/x86.rs":"a268b01e54d0c7cbd9ae765815524fbd5f7c92c339f110f1f3d76877e5238597","src/message/apple/x86_64.rs":"bb64ad8de038b65cda61eaa55a46ce56795aeb36b574dc4dbbfd0d328aa23889","src/message/gnustep.rs":"15bbf9abc5aa0edc25b8b1d9622ebcacc33fd1103fe20a6a93ba9d82ca1b262d","src/message/mod.rs":"aa9da24db7d02ed7d827d78d53936c132fc9302e7fdc09380bdf7021ddd16ae6","src/message/verify.rs":"0047219354c49568a14f7aa7a5bb91edca16e5636a30c66c15a1533668759845","src/rc/autorelease.rs":"f56e26a5f866b5dbbe5c336289bbe21d5a5872928d504c5dfdfda3eeaedd5a3e","src/rc/mod.rs":"ce4b5206fa8273ad3931376d18c1b9aca6cef8172eb2ff8daf962fee710db9d7","src/rc/strong.rs":"f472889e5827cd67f6df62f50e55fdc2101bcdfeb59c7d39dacc5f30a0ed06bb","src/rc/weak.rs":"0b4f77abcd9f1eec1993b6cc6f3db564d90aafe3dbf15233a6f268ded48ef6cb","src/runtime.rs":"69b33722d727faef47e3fb14e68bb18b96a970930a1f9b244e2bb4e161d67874","src/test_utils.rs":"db73875ff5ae4761187d3691998829a689e3dfd26b9812bdebc1bcae0388f78b"},"package":"915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"} \ No newline at end of file diff --git a/third_party/cargo/vendor/objc-0.2.7/BUILD b/third_party/cargo/vendor/objc-0.2.7/BUILD new file mode 100644 index 0000000..07dd5ea --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/BUILD @@ -0,0 +1,46 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "example" with type "example" omitted + +rust_library( + name = "objc", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/malloc_buf-0.0.6:malloc_buf", + "//third_party/cargo/vendor/objc_exception-0.1.2:objc_exception", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.2.7", + crate_features = [ + "objc_exception", + ], +) + diff --git a/third_party/cargo/vendor/objc-0.2.7/CHANGELOG.md b/third_party/cargo/vendor/objc-0.2.7/CHANGELOG.md new file mode 100644 index 0000000..c8b1bf8 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/CHANGELOG.md @@ -0,0 +1,117 @@ +## 0.2.7 + +### Fixed + +* Uses of `msg_send!` will now correctly fail to compile if no return type + can be inferred, instead of relying on an edge case of the compiler + that will soon change and silently cause undefined behavior. + +## 0.2.6 + +### Fixed + +* Suppressed a deprecation warning in `sel!`, `msg_send!`, and `class!`. + +## 0.2.5 + +### Added + +* `autoreleasepool` returns the value returned by its body closure. + +## 0.2.4 + +### Added + +* Added an `rc` module with reference counting utilities: + `StrongPtr`, `WeakPtr`, and `autoreleasepool`. + +* Added some reference counting ABI foreign functions to the `runtime` module. + +### Fixed + +* Messaging nil under GNUstep now correctly returns zeroed results for all + return types. + +## 0.2.3 + +### Added + +* Added a `class!` macro for getting statically-known classes. The result is + non-optional (avoiding a need to unwrap) and cached so each usage will only + look up the class once. + +* Added caching to the `sel!` macro so that each usage will only register the + selector once. + +### Fixed + +* Fixed the implementation of `objc::runtime` structs so there can't be unsound + references to uninhabited types. + +## 0.2.2 + +### Added + +* Implemented `Sync` and `Send` for `Sel`. + +## 0.2.1 + +### Added + +* Added support for working with protocols with the `Protocol` struct. + The protocols a class conforms to can be examined with the new + `Class::adopted_protocols` and `Class::conforms_to` methods. + +* Protocols can be declared using the new `ProtocolDecl` struct. + +## 0.2.0 + +### Added + +* Added verification for the types used when sending messages. + This can be enabled for all messages with the `"verify_message"` feature, + or you can test before sending specific messages with the + `Message::verify_message` method. Verification errors are reported using the + new `MessageError` struct. + +* Added support for the GNUstep runtime! + Operating systems besides OSX and iOS will fall back to the GNUstep runtime. + +* Root classes can be declared by using the `ClassDecl::root` constructor. + +### Changed + +* C types are now used from `std::os::raw` rather than `libc`. This means + `Encode` may not be implemented for `libc` types; switch them to the + `std::os::raw` equivalents instead. This avoids an issue that would arise + from simultaneously using different versions of the libc crate. + +* Dynamic messaging was moved into the `Message` trait; instead of + `().send(obj, sel!(description))`, use + `obj.send_message(sel!(description), ())`. + +* Rearranged the parameters to `ClassDecl::new` for consistency; instead of + `ClassDecl::new(superclass, "MyObject")`, use + `ClassDecl::new("MyObject", superclass)`. + +* Overhauled the `MethodImplementation` trait. Encodings are now accessed + through the `MethodImplementation::Args` associated type. The `imp_for` + method was replaced with `imp` and no longer takes a selector or returns an + `UnequalArgsError`, although `ClassDecl::add_method` still validates the + number of arguments. + +* Updated the definition of `Imp` to not use the old dispatch prototypes. + To invoke an `Imp`, it must first be transmuted to the correct type. + +* Removed `objc_msgSend` functions from the `runtime` module; the availability + of these functions varies and they shouldn't be called without trasmuting, + so they are now hidden as an implementation detail of messaging. + +### Fixed + +* Corrected alignment of ivars in `ClassDecl`; declared classes may now have a + smaller size. + +* With the `"exception"` or `"verify_message"` feature enabled, panics from + `msg_send!` will now be triggered from the line and file where the macro is + used, rather than from within the implementation of messaging. diff --git a/third_party/cargo/vendor/objc-0.2.7/Cargo.toml b/third_party/cargo/vendor/objc-0.2.7/Cargo.toml new file mode 100644 index 0000000..0827230 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/Cargo.toml @@ -0,0 +1,33 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "objc" +version = "0.2.7" +authors = ["Steven Sheldon"] +exclude = [".gitignore", ".travis.yml", "doc.sh", "travis_install.sh", "travis_test.sh", "tests-ios/**"] +description = "Objective-C Runtime bindings and wrapper for Rust." +documentation = "http://ssheldon.github.io/rust-objc/objc/" +readme = "README.md" +keywords = ["objective-c", "osx", "ios", "cocoa", "uikit"] +license = "MIT" +repository = "http://github.com/SSheldon/rust-objc" +[dependencies.malloc_buf] +version = "0.0" + +[dependencies.objc_exception] +version = "0.1" +optional = true + +[features] +exception = ["objc_exception"] +verify_message = [] diff --git a/third_party/cargo/vendor/objc-0.2.7/LICENSE.txt b/third_party/cargo/vendor/objc-0.2.7/LICENSE.txt new file mode 100644 index 0000000..e9ab3ba --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Steven Sheldon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/objc-0.2.7/README.md b/third_party/cargo/vendor/objc-0.2.7/README.md new file mode 100644 index 0000000..55fba64 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/README.md @@ -0,0 +1,99 @@ +Objective-C Runtime bindings and wrapper for Rust. + +* Documentation: http://ssheldon.github.io/rust-objc/objc/ +* Crate: https://crates.io/crates/objc + +## Messaging objects + +Objective-C objects can be messaged using the `msg_send!` macro: + +``` rust +let cls = class!(NSObject); +let obj: *mut Object = msg_send![cls, new]; +let hash: usize = msg_send![obj, hash]; +let is_kind: BOOL = msg_send![obj, isKindOfClass:cls]; +// Even void methods must have their return type annotated +let _: () = msg_send![obj, release]; +``` + +## Reference counting + +The utilities of the `rc` module provide ARC-like semantics for working with +Objective-C's reference counted objects in Rust. +A `StrongPtr` retains an object and releases the object when dropped. +A `WeakPtr` will not retain the object, but can be upgraded to a `StrongPtr` +and safely fails if the object has been deallocated. + +``` rust +// StrongPtr will release the object when dropped +let obj = unsafe { + StrongPtr::new(msg_send![class!(NSObject), new]) +}; + +// Cloning retains the object an additional time +let cloned = obj.clone(); +autoreleasepool(|| { + // Autorelease consumes the StrongPtr, but won't + // actually release until the end of an autoreleasepool + cloned.autorelease(); +}); + +// Weak references won't retain the object +let weak = obj.weak(); +drop(obj); +assert!(weak.load().is_null()); +``` + +## Declaring classes + +Classes can be declared using the `ClassDecl` struct. Instance variables and +methods can then be added before the class is ultimately registered. + +The following example demonstrates declaring a class named `MyNumber` that has +one ivar, a `u32` named `_number` and a `number` method that returns it: + +``` rust +let superclass = class!(NSObject); +let mut decl = ClassDecl::new("MyNumber", superclass).unwrap(); + +// Add an instance variable +decl.add_ivar::("_number"); + +// Add an ObjC method for getting the number +extern fn my_number_get(this: &Object, _cmd: Sel) -> u32 { + unsafe { *this.get_ivar("_number") } +} +unsafe { + decl.add_method(sel!(number), + my_number_get as extern fn(&Object, Sel) -> u32); +} + +decl.register(); +``` + +## Exceptions + +By default, if the `msg_send!` macro causes an exception to be thrown, this +will unwind into Rust resulting in unsafe, undefined behavior. +However, this crate has an `"exception"` feature which, when enabled, wraps +each `msg_send!` in a `@try`/`@catch` and panics if an exception is caught, +preventing Objective-C from unwinding into Rust. + +## Message type verification + +The Objective-C runtime includes encodings for each method that describe the +argument and return types. This crate can take advantage of these encodings to +verify that the types used in Rust match the types encoded for the method. + +To use this functionality, enable the `"verify_message"` feature. +With this feature enabled, type checking is performed for every message send, +which also requires that all arguments and return values for all messages +implement `Encode`. + +If this requirement is burdensome or you'd rather just verify specific messages, +you can call the `Message::verify_message` method for specific selectors. + +## Support for other Operating Systems + +The bindings can be used on Linux or *BSD utilizing the +[GNUstep Objective-C runtime](https://www.github.com/gnustep/libobjc2). diff --git a/third_party/cargo/vendor/objc-0.2.7/examples/example.rs b/third_party/cargo/vendor/objc-0.2.7/examples/example.rs new file mode 100644 index 0000000..5346b62 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/examples/example.rs @@ -0,0 +1,45 @@ +#[macro_use] +extern crate objc; + +use objc::Encode; +use objc::rc::StrongPtr; +use objc::runtime::{Class, Object}; + +fn main() { + // Get a class + let cls = class!(NSObject); + println!("NSObject size: {}", cls.instance_size()); + + // Inspect its ivars + println!("NSObject ivars:"); + for ivar in cls.instance_variables().iter() { + println!("{}", ivar.name()); + } + + // Allocate an instance + let obj = unsafe { + let obj: *mut Object = msg_send![cls, alloc]; + let obj: *mut Object = msg_send![obj, init]; + StrongPtr::new(obj) + }; + println!("NSObject address: {:p}", obj); + + // Access an ivar of the object + let isa: *const Class = unsafe { + *(**obj).get_ivar("isa") + }; + println!("NSObject isa: {:?}", isa); + + // Inspect a method of the class + let hash_sel = sel!(hash); + let hash_method = cls.instance_method(hash_sel).unwrap(); + let hash_return = hash_method.return_type(); + println!("-[NSObject hash] return type: {:?}", hash_return); + assert!(hash_return == usize::encode()); + + // Invoke a method on the object + let hash: usize = unsafe { + msg_send![*obj, hash] + }; + println!("NSObject hash: {}", hash); +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/declare.rs b/third_party/cargo/vendor/objc-0.2.7/src/declare.rs new file mode 100644 index 0000000..ed09015 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/declare.rs @@ -0,0 +1,340 @@ +/*! +Functionality for declaring Objective-C classes. + +Classes can be declared using the `ClassDecl` struct. Instance variables and +methods can then be added before the class is ultimately registered. + +# Example + +The following example demonstrates declaring a class named `MyNumber` that has +one ivar, a `u32` named `_number` and a `number` method that returns it: + +``` no_run +# #[macro_use] extern crate objc; +# use objc::declare::ClassDecl; +# use objc::runtime::{Class, Object, Sel}; +# fn main() { +let superclass = class!(NSObject); +let mut decl = ClassDecl::new("MyNumber", superclass).unwrap(); + +// Add an instance variable +decl.add_ivar::("_number"); + +// Add an ObjC method for getting the number +extern fn my_number_get(this: &Object, _cmd: Sel) -> u32 { + unsafe { *this.get_ivar("_number") } +} +unsafe { + decl.add_method(sel!(number), + my_number_get as extern fn(&Object, Sel) -> u32); +} + +decl.register(); +# } +``` +*/ + +use std::ffi::CString; +use std::mem; +use std::ptr; + +use runtime::{BOOL, Class, Imp, NO, Object, Protocol, Sel, self}; +use {Encode, EncodeArguments, Encoding, Message}; + +/// Types that can be used as the implementation of an Objective-C method. +pub trait MethodImplementation { + /// The callee type of the method. + type Callee: Message; + /// The return type of the method. + type Ret: Encode; + /// The argument types of the method. + type Args: EncodeArguments; + + /// Returns self as an `Imp` of a method. + fn imp(self) -> Imp; +} + +macro_rules! method_decl_impl { + (-$s:ident, $r:ident, $f:ty, $($t:ident),*) => ( + impl<$s, $r $(, $t)*> MethodImplementation for $f + where $s: Message, $r: Encode $(, $t: Encode)* { + type Callee = $s; + type Ret = $r; + type Args = ($($t,)*); + + fn imp(self) -> Imp { + unsafe { mem::transmute(self) } + } + } + ); + ($($t:ident),*) => ( + method_decl_impl!(-T, R, extern fn(&T, Sel $(, $t)*) -> R, $($t),*); + method_decl_impl!(-T, R, extern fn(&mut T, Sel $(, $t)*) -> R, $($t),*); + ); +} + +method_decl_impl!(); +method_decl_impl!(A); +method_decl_impl!(A, B); +method_decl_impl!(A, B, C); +method_decl_impl!(A, B, C, D); +method_decl_impl!(A, B, C, D, E); +method_decl_impl!(A, B, C, D, E, F); +method_decl_impl!(A, B, C, D, E, F, G); +method_decl_impl!(A, B, C, D, E, F, G, H); +method_decl_impl!(A, B, C, D, E, F, G, H, I); +method_decl_impl!(A, B, C, D, E, F, G, H, I, J); +method_decl_impl!(A, B, C, D, E, F, G, H, I, J, K); +method_decl_impl!(A, B, C, D, E, F, G, H, I, J, K, L); + +fn count_args(sel: Sel) -> usize { + sel.name().chars().filter(|&c| c == ':').count() +} + +fn method_type_encoding(ret: &Encoding, args: &[Encoding]) -> CString { + let mut types = ret.as_str().to_owned(); + // First two arguments are always self and the selector + types.push_str(<*mut Object>::encode().as_str()); + types.push_str(Sel::encode().as_str()); + types.extend(args.iter().map(|e| e.as_str())); + CString::new(types).unwrap() +} + +fn log2_align_of() -> u8 { + let align = mem::align_of::(); + // Alignments are required to be powers of 2 + debug_assert!(align.count_ones() == 1); + // log2 of a power of 2 is the number of trailing zeros + align.trailing_zeros() as u8 +} + +/// A type for declaring a new class and adding new methods and ivars to it +/// before registering it. +pub struct ClassDecl { + cls: *mut Class, +} + +impl ClassDecl { + fn with_superclass(name: &str, superclass: Option<&Class>) + -> Option { + let name = CString::new(name).unwrap(); + let super_ptr = superclass.map_or(ptr::null(), |c| c); + let cls = unsafe { + runtime::objc_allocateClassPair(super_ptr, name.as_ptr(), 0) + }; + if cls.is_null() { + None + } else { + Some(ClassDecl { cls: cls }) + } + } + + /// Constructs a `ClassDecl` with the given name and superclass. + /// Returns `None` if the class couldn't be allocated. + pub fn new(name: &str, superclass: &Class) -> Option { + ClassDecl::with_superclass(name, Some(superclass)) + } + + /** + Constructs a `ClassDecl` declaring a new root class with the given name. + Returns `None` if the class couldn't be allocated. + + An implementation for `+initialize` must also be given; the runtime calls + this method for all classes, so it must be defined on root classes. + + Note that implementing a root class is not a simple endeavor. + For example, your class probably cannot be passed to Cocoa code unless + the entire `NSObject` protocol is implemented. + Functionality it expects, like implementations of `-retain` and `-release` + used by ARC, will not be present otherwise. + */ + pub fn root(name: &str, intitialize_fn: extern fn(&Class, Sel)) + -> Option { + let mut decl = ClassDecl::with_superclass(name, None); + if let Some(ref mut decl) = decl { + unsafe { + decl.add_class_method(sel!(initialize), intitialize_fn); + } + } + decl + } + + /// Adds a method with the given name and implementation to self. + /// Panics if the method wasn't sucessfully added + /// or if the selector and function take different numbers of arguments. + /// Unsafe because the caller must ensure that the types match those that + /// are expected when the method is invoked from Objective-C. + pub unsafe fn add_method(&mut self, sel: Sel, func: F) + where F: MethodImplementation { + let encs = F::Args::encodings(); + let encs = encs.as_ref(); + let sel_args = count_args(sel); + assert!(sel_args == encs.len(), + "Selector accepts {} arguments, but function accepts {}", + sel_args, encs.len(), + ); + + let types = method_type_encoding(&F::Ret::encode(), encs); + let success = runtime::class_addMethod(self.cls, sel, func.imp(), + types.as_ptr()); + assert!(success != NO, "Failed to add method {:?}", sel); + } + + /// Adds a class method with the given name and implementation to self. + /// Panics if the method wasn't sucessfully added + /// or if the selector and function take different numbers of arguments. + /// Unsafe because the caller must ensure that the types match those that + /// are expected when the method is invoked from Objective-C. + pub unsafe fn add_class_method(&mut self, sel: Sel, func: F) + where F: MethodImplementation { + let encs = F::Args::encodings(); + let encs = encs.as_ref(); + let sel_args = count_args(sel); + assert!(sel_args == encs.len(), + "Selector accepts {} arguments, but function accepts {}", + sel_args, encs.len(), + ); + + let types = method_type_encoding(&F::Ret::encode(), encs); + let metaclass = (*self.cls).metaclass() as *const _ as *mut _; + let success = runtime::class_addMethod(metaclass, sel, func.imp(), + types.as_ptr()); + assert!(success != NO, "Failed to add class method {:?}", sel); + } + + /// Adds an ivar with type `T` and the provided name to self. + /// Panics if the ivar wasn't successfully added. + pub fn add_ivar(&mut self, name: &str) where T: Encode { + let c_name = CString::new(name).unwrap(); + let encoding = CString::new(T::encode().as_str()).unwrap(); + let size = mem::size_of::(); + let align = log2_align_of::(); + let success = unsafe { + runtime::class_addIvar(self.cls, c_name.as_ptr(), size, align, + encoding.as_ptr()) + }; + assert!(success != NO, "Failed to add ivar {}", name); + } + + /// Adds a protocol to self. Panics if the protocol wasn't successfully + /// added + pub fn add_protocol(&mut self, proto: &Protocol) { + let success = unsafe { runtime::class_addProtocol(self.cls, proto) }; + assert!(success != NO, "Failed to add protocol {:?}", proto); + } + + /// Registers self, consuming it and returning a reference to the + /// newly registered `Class`. + pub fn register(self) -> &'static Class { + unsafe { + let cls = self.cls; + runtime::objc_registerClassPair(cls); + // Forget self otherwise the class will be disposed in drop + mem::forget(self); + &*cls + } + } +} + +impl Drop for ClassDecl { + fn drop(&mut self) { + unsafe { + runtime::objc_disposeClassPair(self.cls); + } + } +} + +/// A type for declaring a new protocol and adding new methods to it +/// before registering it. +pub struct ProtocolDecl { + proto: *mut Protocol +} + +impl ProtocolDecl { + /// Constructs a `ProtocolDecl` with the given name. Returns `None` if the + /// protocol couldn't be allocated. + pub fn new(name: &str) -> Option { + let c_name = CString::new(name).unwrap(); + let proto = unsafe { + runtime::objc_allocateProtocol(c_name.as_ptr()) + }; + if proto.is_null() { + None + } else { + Some(ProtocolDecl { proto: proto }) + } + } + + fn add_method_description_common(&mut self, sel: Sel, is_required: bool, + is_instance_method: bool) + where Args: EncodeArguments, + Ret: Encode { + let encs = Args::encodings(); + let encs = encs.as_ref(); + let sel_args = count_args(sel); + assert!(sel_args == encs.len(), + "Selector accepts {} arguments, but function accepts {}", + sel_args, encs.len(), + ); + let types = method_type_encoding(&Ret::encode(), encs); + unsafe { + runtime::protocol_addMethodDescription( + self.proto, sel, types.as_ptr(), is_required as BOOL, is_instance_method as BOOL); + } + } + + /// Adds an instance method declaration with a given description to self. + pub fn add_method_description(&mut self, sel: Sel, is_required: bool) + where Args: EncodeArguments, + Ret: Encode { + self.add_method_description_common::(sel, is_required, true) + } + + /// Adds a class method declaration with a given description to self. + pub fn add_class_method_description(&mut self, sel: Sel, is_required: bool) + where Args: EncodeArguments, + Ret: Encode { + self.add_method_description_common::(sel, is_required, false) + } + + /// Adds a requirement on another protocol. + pub fn add_protocol(&mut self, proto: &Protocol) { + unsafe { + runtime::protocol_addProtocol(self.proto, proto); + } + } + + /// Registers self, consuming it and returning a reference to the + /// newly registered `Protocol`. + pub fn register(self) -> &'static Protocol { + unsafe { + runtime::objc_registerProtocol(self.proto); + &*self.proto + } + } +} + +#[cfg(test)] +mod tests { + use test_utils; + + #[test] + fn test_custom_class() { + // Registering the custom class is in test_utils + let obj = test_utils::custom_object(); + unsafe { + let _: () = msg_send![obj, setFoo:13u32]; + let result: u32 = msg_send![obj, foo]; + assert!(result == 13); + } + } + + #[test] + fn test_class_method() { + let cls = test_utils::custom_class(); + unsafe { + let result: u32 = msg_send![cls, classFoo]; + assert!(result == 7); + } + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/encode.rs b/third_party/cargo/vendor/objc-0.2.7/src/encode.rs new file mode 100644 index 0000000..921479d --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/encode.rs @@ -0,0 +1,279 @@ +use std::ffi::CStr; +use std::fmt; +use std::os::raw::{c_char, c_void}; +use std::str; +use malloc_buf::MallocBuffer; + +use runtime::{Class, Object, Sel}; + +const QUALIFIERS: &'static [char] = &[ + 'r', // const + 'n', // in + 'N', // inout + 'o', // out + 'O', // bycopy + 'R', // byref + 'V', // oneway +]; + +#[cfg(target_pointer_width = "64")] +const CODE_INLINE_CAP: usize = 30; + +#[cfg(target_pointer_width = "32")] +const CODE_INLINE_CAP: usize = 14; + +enum Code { + Slice(&'static str), + Owned(String), + Inline(u8, [u8; CODE_INLINE_CAP]), + Malloc(MallocBuffer) +} + +/// An Objective-C type encoding. +/// +/// For more information, see Apple's documentation: +/// +pub struct Encoding { + code: Code, +} + +impl Encoding { + /// Constructs an `Encoding` from its string representation. + /// Unsafe because the caller must ensure the string is a valid encoding. + pub unsafe fn from_str(code: &str) -> Encoding { + from_str(code) + } + + /// Returns self as a `str`. + pub fn as_str(&self) -> &str { + match self.code { + Code::Slice(code) => code, + Code::Owned(ref code) => code, + Code::Inline(len, ref bytes) => unsafe { + str::from_utf8_unchecked(&bytes[..len as usize]) + }, + Code::Malloc(ref buf) => unsafe { + str::from_utf8_unchecked(&buf[..buf.len() - 1]) + }, + } + } +} + +impl Clone for Encoding { + fn clone(&self) -> Encoding { + if let Code::Slice(code) = self.code { + from_static_str(code) + } else { + from_str(self.as_str()) + } + } +} + +impl PartialEq for Encoding { + fn eq(&self, other: &Encoding) -> bool { + // strip qualifiers when comparing + let s = self.as_str().trim_left_matches(QUALIFIERS); + let o = other.as_str().trim_left_matches(QUALIFIERS); + s == o + } +} + +impl fmt::Debug for Encoding { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.as_str()) + } +} + +pub fn from_static_str(code: &'static str) -> Encoding { + Encoding { code: Code::Slice(code) } +} + +pub fn from_str(code: &str) -> Encoding { + if code.len() > CODE_INLINE_CAP { + Encoding { code: Code::Owned(code.to_owned()) } + } else { + let mut bytes = [0; CODE_INLINE_CAP]; + for (dst, byte) in bytes.iter_mut().zip(code.bytes()) { + *dst = byte; + } + Encoding { code: Code::Inline(code.len() as u8, bytes) } + } +} + +pub unsafe fn from_malloc_str(ptr: *mut c_char) -> Encoding { + let s = CStr::from_ptr(ptr); + let bytes = s.to_bytes_with_nul(); + assert!(str::from_utf8(bytes).is_ok()); + let buf = MallocBuffer::new(ptr as *mut u8, bytes.len()).unwrap(); + Encoding { code: Code::Malloc(buf) } +} + +/// Types that have an Objective-C type encoding. +/// +/// Unsafe because Objective-C will make assumptions about the type (like its +/// size and alignment) from its encoding, so the implementer must verify that +/// the encoding is accurate. +pub unsafe trait Encode { + /// Returns the Objective-C type encoding for Self. + fn encode() -> Encoding; +} + +macro_rules! encode_impls { + ($($t:ty : $s:expr,)*) => ($( + unsafe impl Encode for $t { + fn encode() -> Encoding { from_static_str($s) } + } + )*); +} + +encode_impls!( + i8: "c", + i16: "s", + i32: "i", + i64: "q", + u8: "C", + u16: "S", + u32: "I", + u64: "Q", + f32: "f", + f64: "d", + bool: "B", + (): "v", + *mut c_char: "*", + *const c_char: "r*", + *mut c_void: "^v", + *const c_void: "r^v", + Sel: ":", +); + +unsafe impl Encode for isize { + #[cfg(target_pointer_width = "32")] + fn encode() -> Encoding { i32::encode() } + + #[cfg(target_pointer_width = "64")] + fn encode() -> Encoding { i64::encode() } +} + +unsafe impl Encode for usize { + #[cfg(target_pointer_width = "32")] + fn encode() -> Encoding { u32::encode() } + + #[cfg(target_pointer_width = "64")] + fn encode() -> Encoding { u64::encode() } +} + +macro_rules! encode_message_impl { + ($code:expr, $name:ident) => ( + encode_message_impl!($code, $name,); + ); + ($code:expr, $name:ident, $($t:ident),*) => ( + unsafe impl<'a $(, $t)*> $crate::Encode for &'a $name<$($t),*> { + fn encode() -> Encoding { from_static_str($code) } + } + + unsafe impl<'a $(, $t)*> $crate::Encode for &'a mut $name<$($t),*> { + fn encode() -> Encoding { from_static_str($code) } + } + + unsafe impl<'a $(, $t)*> $crate::Encode for Option<&'a $name<$($t),*>> { + fn encode() -> Encoding { from_static_str($code) } + } + + unsafe impl<'a $(, $t)*> $crate::Encode for Option<&'a mut $name<$($t),*>> { + fn encode() -> Encoding { from_static_str($code) } + } + + unsafe impl<$($t),*> $crate::Encode for *const $name<$($t),*> { + fn encode() -> Encoding { from_static_str($code) } + } + + unsafe impl<$($t),*> $crate::Encode for *mut $name<$($t),*> { + fn encode() -> Encoding { from_static_str($code) } + } + ); +} + +encode_message_impl!("@", Object); + +encode_message_impl!("#", Class); + +/// Types that represent a group of arguments, where each has an Objective-C +/// type encoding. +pub trait EncodeArguments { + /// The type as which the encodings for Self will be returned. + type Encs: AsRef<[Encoding]>; + + /// Returns the Objective-C type encodings for Self. + fn encodings() -> Self::Encs; +} + +macro_rules! count_idents { + () => (0); + ($a:ident) => (1); + ($a:ident, $($b:ident),+) => (1 + count_idents!($($b),*)); +} + +macro_rules! encode_args_impl { + ($($t:ident),*) => ( + impl<$($t: Encode),*> EncodeArguments for ($($t,)*) { + type Encs = [Encoding; count_idents!($($t),*)]; + + fn encodings() -> Self::Encs { + [ + $($t::encode()),* + ] + } + } + ); +} + +encode_args_impl!(); +encode_args_impl!(A); +encode_args_impl!(A, B); +encode_args_impl!(A, B, C); +encode_args_impl!(A, B, C, D); +encode_args_impl!(A, B, C, D, E); +encode_args_impl!(A, B, C, D, E, F); +encode_args_impl!(A, B, C, D, E, F, G); +encode_args_impl!(A, B, C, D, E, F, G, H); +encode_args_impl!(A, B, C, D, E, F, G, H, I); +encode_args_impl!(A, B, C, D, E, F, G, H, I, J); +encode_args_impl!(A, B, C, D, E, F, G, H, I, J, K); +encode_args_impl!(A, B, C, D, E, F, G, H, I, J, K, L); + +#[cfg(test)] +mod tests { + use runtime::{Class, Object, Sel}; + use super::{Encode, Encoding}; + + #[test] + fn test_encode() { + assert!(u32::encode().as_str() == "I"); + assert!(<()>::encode().as_str() == "v"); + assert!(<&Object>::encode().as_str() == "@"); + assert!(<*mut Object>::encode().as_str() == "@"); + assert!(<&Class>::encode().as_str() == "#"); + assert!(Sel::encode().as_str() == ":"); + } + + #[test] + fn test_inline_encoding() { + let enc = unsafe { Encoding::from_str("C") }; + assert!(enc.as_str() == "C"); + + let enc2 = enc.clone(); + assert!(enc2 == enc); + assert!(enc2.as_str() == "C"); + } + + #[test] + fn test_owned_encoding() { + let s = "{Test=CCCCCCCCCCCCCCCCCCCCCCCCC}"; + let enc = unsafe { Encoding::from_str(s) }; + assert!(enc.as_str() == s); + + let enc2 = enc.clone(); + assert!(enc2 == enc); + assert!(enc2.as_str() == s); + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/exception.rs b/third_party/cargo/vendor/objc-0.2.7/src/exception.rs new file mode 100644 index 0000000..6fcfa7e --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/exception.rs @@ -0,0 +1,11 @@ +use objc_exception; + +use rc::StrongPtr; +use runtime::Object; + +pub unsafe fn try(closure: F) -> Result + where F: FnOnce() -> R { + objc_exception::try(closure).map_err(|exception| { + StrongPtr::new(exception as *mut Object) + }) +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/lib.rs b/third_party/cargo/vendor/objc-0.2.7/src/lib.rs new file mode 100644 index 0000000..cdd30f5 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/lib.rs @@ -0,0 +1,90 @@ +/*! +Objective-C Runtime bindings and wrapper for Rust. + +# Messaging objects + +Objective-C objects can be messaged using the [`msg_send!`](macro.msg_send!.html) macro: + +``` no_run +# #[macro_use] extern crate objc; +# use objc::runtime::{BOOL, Class, Object}; +# fn main() { +# unsafe { +let cls = class!(NSObject); +let obj: *mut Object = msg_send![cls, new]; +let hash: usize = msg_send![obj, hash]; +let is_kind: BOOL = msg_send![obj, isKindOfClass:cls]; +// Even void methods must have their return type annotated +let _: () = msg_send![obj, release]; +# } +# } +``` + +# Reference counting + +Utilities for reference counting Objective-C objects are provided in the +[`rc`](rc/index.html) module. + +# Declaring classes + +Objective-C classes can even be declared from Rust using the functionality of +the [`declare`](declare/index.html) module. + +# Exceptions + +By default, if the `msg_send!` macro causes an exception to be thrown, this +will unwind into Rust resulting in unsafe, undefined behavior. +However, this crate has an `"exception"` feature which, when enabled, wraps +each `msg_send!` in a `@try`/`@catch` and panics if an exception is caught, +preventing Objective-C from unwinding into Rust. + +# Message type verification + +The Objective-C runtime includes encodings for each method that describe the +argument and return types. This crate can take advantage of these encodings to +verify that the types used in Rust match the types encoded for the method. + +To use this functionality, enable the `"verify_message"` feature. +With this feature enabled, type checking is performed for every message send, +which also requires that all arguments and return values for all messages +implement `Encode`. + +If this requirement is burdensome or you'd rather +just verify specific messages, you can call the +[`Message::verify_message`](trait.Message.html#method.verify_message) method +for specific selectors. + +# Support for other Operating Systems + +The bindings can be used on Linux or *BSD utilizing the +[GNUstep Objective-C runtime](https://www.github.com/gnustep/libobjc2). +*/ + +#![crate_name = "objc"] +#![crate_type = "lib"] + +#![warn(missing_docs)] + +extern crate malloc_buf; +#[cfg(feature = "exception")] +extern crate objc_exception; + +pub use encode::{Encode, EncodeArguments, Encoding}; +pub use message::{Message, MessageArguments, MessageError}; + +pub use message::send_message as __send_message; +pub use message::send_super_message as __send_super_message; + +#[macro_use] +mod macros; + +pub mod runtime; +pub mod declare; +pub mod rc; +mod encode; +#[cfg(feature = "exception")] +mod exception; +mod message; + +#[cfg(test)] +mod test_utils; diff --git a/third_party/cargo/vendor/objc-0.2.7/src/macros.rs b/third_party/cargo/vendor/objc-0.2.7/src/macros.rs new file mode 100644 index 0000000..c791f20 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/macros.rs @@ -0,0 +1,148 @@ +/** +Gets a reference to a `Class`. + +Panics if no class with the given name can be found. +To check for a class that may not exist, use `Class::get`. + +# Example +``` no_run +# #[macro_use] extern crate objc; +# fn main() { +let cls = class!(NSObject); +# } +``` +*/ +#[macro_export] +macro_rules! class { + ($name:ident) => ({ + #[allow(deprecated)] + #[inline(always)] + fn get_class(name: &str) -> Option<&'static $crate::runtime::Class> { + unsafe { + #[cfg_attr(feature = "cargo-clippy", allow(replace_consts))] + static CLASS: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT; + // `Relaxed` should be fine since `objc_getClass` is thread-safe. + let ptr = CLASS.load(::std::sync::atomic::Ordering::Relaxed) as *const $crate::runtime::Class; + if ptr.is_null() { + let cls = $crate::runtime::objc_getClass(name.as_ptr() as *const _); + CLASS.store(cls as usize, ::std::sync::atomic::Ordering::Relaxed); + if cls.is_null() { None } else { Some(&*cls) } + } else { + Some(&*ptr) + } + } + } + match get_class(concat!(stringify!($name), '\0')) { + Some(cls) => cls, + None => panic!("Class with name {} could not be found", stringify!($name)), + } + }) +} + +#[doc(hidden)] +#[macro_export] +macro_rules! sel_impl { + // Declare a function to hide unsafety, otherwise we can trigger the + // unused_unsafe lint; see rust-lang/rust#8472 + ($name:expr) => ({ + #[allow(deprecated)] + #[inline(always)] + fn register_sel(name: &str) -> $crate::runtime::Sel { + unsafe { + #[cfg_attr(feature = "cargo-clippy", allow(replace_consts))] + static SEL: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT; + let ptr = SEL.load(::std::sync::atomic::Ordering::Relaxed) as *const ::std::os::raw::c_void; + // It should be fine to use `Relaxed` ordering here because `sel_registerName` is + // thread-safe. + if ptr.is_null() { + let sel = $crate::runtime::sel_registerName(name.as_ptr() as *const _); + SEL.store(sel.as_ptr() as usize, ::std::sync::atomic::Ordering::Relaxed); + sel + } else { + $crate::runtime::Sel::from_ptr(ptr) + } + } + } + register_sel($name) + }) +} + +/** +Registers a selector, returning a `Sel`. + +# Example +``` +# #[macro_use] extern crate objc; +# fn main() { +let sel = sel!(description); +let sel = sel!(setObject:forKey:); +# } +``` +*/ +#[macro_export] +macro_rules! sel { + ($name:ident) => ({sel_impl!(concat!(stringify!($name), '\0'))}); + ($($name:ident :)+) => ({sel_impl!(concat!($(stringify!($name), ':'),+, '\0'))}); +} + +/** +Sends a message to an object. + +The first argument can be any type that dereferences to a type that implements +`Message`, like a reference, pointer, or an `Id`. +The syntax is similar to the message syntax in Objective-C. +Variadic arguments are not currently supported. + +# Example +``` no_run +# #[macro_use] extern crate objc; +# use objc::runtime::Object; +# fn main() { +# unsafe { +let obj: *mut Object; +# let obj: *mut Object = 0 as *mut Object; +let description: *const Object = msg_send![obj, description]; +let _: () = msg_send![obj, setArg1:1 arg2:2]; +# } +# } +``` +*/ +#[macro_export] +macro_rules! msg_send { + (super($obj:expr, $superclass:expr), $name:ident) => ({ + let sel = sel!($name); + let result; + match $crate::__send_super_message(&*$obj, $superclass, sel, ()) { + Err(s) => panic!("{}", s), + Ok(r) => result = r, + } + result + }); + (super($obj:expr, $superclass:expr), $($name:ident : $arg:expr)+) => ({ + let sel = sel!($($name:)+); + let result; + match $crate::__send_super_message(&*$obj, $superclass, sel, ($($arg,)*)) { + Err(s) => panic!("{}", s), + Ok(r) => result = r, + } + result + }); + ($obj:expr, $name:ident) => ({ + let sel = sel!($name); + let result; + match $crate::__send_message(&*$obj, sel, ()) { + Err(s) => panic!("{}", s), + Ok(r) => result = r, + } + result + }); + ($obj:expr, $($name:ident : $arg:expr)+) => ({ + let sel = sel!($($name:)+); + let result; + match $crate::__send_message(&*$obj, sel, ($($arg,)*)) { + Err(s) => panic!("{}", s), + Ok(r) => result = r, + } + result + }); +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/message/apple/arm.rs b/third_party/cargo/vendor/objc-0.2.7/src/message/apple/arm.rs new file mode 100644 index 0000000..d26defc --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/message/apple/arm.rs @@ -0,0 +1,40 @@ +use std::any::{Any, TypeId}; +use std::mem; + +use runtime::Imp; + +extern { + fn objc_msgSend(); + fn objc_msgSend_stret(); + + fn objc_msgSendSuper(); + fn objc_msgSendSuper_stret(); +} + +pub fn msg_send_fn() -> Imp { + // Double-word sized fundamental data types don't use stret, + // but any composite type larger than 4 bytes does. + // + + let type_id = TypeId::of::(); + if mem::size_of::() <= 4 || + type_id == TypeId::of::() || + type_id == TypeId::of::() || + type_id == TypeId::of::() { + objc_msgSend + } else { + objc_msgSend_stret + } +} + +pub fn msg_send_super_fn() -> Imp { + let type_id = TypeId::of::(); + if mem::size_of::() <= 4 || + type_id == TypeId::of::() || + type_id == TypeId::of::() || + type_id == TypeId::of::() { + objc_msgSendSuper + } else { + objc_msgSendSuper_stret + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/message/apple/arm64.rs b/third_party/cargo/vendor/objc-0.2.7/src/message/apple/arm64.rs new file mode 100644 index 0000000..54cfc89 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/message/apple/arm64.rs @@ -0,0 +1,18 @@ +use runtime::Imp; + +extern { + fn objc_msgSend(); + + fn objc_msgSendSuper(); +} + +pub fn msg_send_fn() -> Imp { + // stret is not even available in arm64. + // + + objc_msgSend +} + +pub fn msg_send_super_fn() -> Imp { + objc_msgSendSuper +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/message/apple/mod.rs b/third_party/cargo/vendor/objc-0.2.7/src/message/apple/mod.rs new file mode 100644 index 0000000..30f59ca --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/message/apple/mod.rs @@ -0,0 +1,40 @@ +use std::any::Any; + +use runtime::{Class, Object, Sel}; +use super::{Message, MessageArguments, MessageError, Super}; + +#[cfg(target_arch = "x86")] +#[path = "x86.rs"] +mod arch; +#[cfg(target_arch = "x86_64")] +#[path = "x86_64.rs"] +mod arch; +#[cfg(target_arch = "arm")] +#[path = "arm.rs"] +mod arch; +#[cfg(target_arch = "aarch64")] +#[path = "arm64.rs"] +mod arch; + +use self::arch::{msg_send_fn, msg_send_super_fn}; + +pub unsafe fn send_unverified(obj: *const T, sel: Sel, args: A) + -> Result + where T: Message, A: MessageArguments, R: Any { + let receiver = obj as *mut T as *mut Object; + let msg_send_fn = msg_send_fn::(); + objc_try!({ + A::invoke(msg_send_fn, receiver, sel, args) + }) +} + +pub unsafe fn send_super_unverified(obj: *const T, superclass: &Class, + sel: Sel, args: A) -> Result + where T: Message, A: MessageArguments, R: Any { + let sup = Super { receiver: obj as *mut T as *mut Object, superclass: superclass }; + let receiver = &sup as *const Super as *mut Object; + let msg_send_fn = msg_send_super_fn::(); + objc_try!({ + A::invoke(msg_send_fn, receiver, sel, args) + }) +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/message/apple/x86.rs b/third_party/cargo/vendor/objc-0.2.7/src/message/apple/x86.rs new file mode 100644 index 0000000..93422de --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/message/apple/x86.rs @@ -0,0 +1,40 @@ +use std::any::{Any, TypeId}; +use std::mem; + +use runtime::Imp; + +extern { + fn objc_msgSend(); + fn objc_msgSend_fpret(); + fn objc_msgSend_stret(); + + fn objc_msgSendSuper(); + fn objc_msgSendSuper_stret(); +} + +pub fn msg_send_fn() -> Imp { + // Structures 1 or 2 bytes in size are placed in EAX. + // Structures 4 or 8 bytes in size are placed in: EAX and EDX. + // Structures of other sizes are placed at the address supplied by the caller. + // + + let type_id = TypeId::of::(); + let size = mem::size_of::(); + if type_id == TypeId::of::() || + type_id == TypeId::of::() { + objc_msgSend_fpret + } else if size == 0 || size == 1 || size == 2 || size == 4 || size == 8 { + objc_msgSend + } else { + objc_msgSend_stret + } +} + +pub fn msg_send_super_fn() -> Imp { + let size = mem::size_of::(); + if size == 0 || size == 1 || size == 2 || size == 4 || size == 8 { + objc_msgSendSuper + } else { + objc_msgSendSuper_stret + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/message/apple/x86_64.rs b/third_party/cargo/vendor/objc-0.2.7/src/message/apple/x86_64.rs new file mode 100644 index 0000000..49c90ce --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/message/apple/x86_64.rs @@ -0,0 +1,32 @@ +use std::mem; + +use runtime::Imp; + +extern { + fn objc_msgSend(); + fn objc_msgSend_stret(); + + fn objc_msgSendSuper(); + fn objc_msgSendSuper_stret(); +} + +pub fn msg_send_fn() -> Imp { + // If the size of an object is larger than two eightbytes, it has class MEMORY. + // If the type has class MEMORY, then the caller provides space for the return + // value and passes the address of this storage. + // + + if mem::size_of::() <= 16 { + objc_msgSend + } else { + objc_msgSend_stret + } +} + +pub fn msg_send_super_fn() -> Imp { + if mem::size_of::() <= 16 { + objc_msgSendSuper + } else { + objc_msgSendSuper_stret + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/message/gnustep.rs b/third_party/cargo/vendor/objc-0.2.7/src/message/gnustep.rs new file mode 100644 index 0000000..2e28689 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/message/gnustep.rs @@ -0,0 +1,35 @@ +use std::any::Any; +use std::mem; + +use runtime::{Class, Object, Imp, Sel}; +use super::{Message, MessageArguments, MessageError, Super}; + +extern { + fn objc_msg_lookup(receiver: *mut Object, op: Sel) -> Imp; + fn objc_msg_lookup_super(sup: *const Super, sel: Sel) -> Imp; +} + +pub unsafe fn send_unverified(obj: *const T, sel: Sel, args: A) + -> Result + where T: Message, A: MessageArguments, R: Any { + if obj.is_null() { + return mem::zeroed(); + } + + let receiver = obj as *mut T as *mut Object; + let msg_send_fn = objc_msg_lookup(receiver, sel); + objc_try!({ + A::invoke(msg_send_fn, receiver, sel, args) + }) +} + +pub unsafe fn send_super_unverified(obj: *const T, superclass: &Class, + sel: Sel, args: A) -> Result + where T: Message, A: MessageArguments, R: Any { + let receiver = obj as *mut T as *mut Object; + let sup = Super { receiver: receiver, superclass: superclass }; + let msg_send_fn = objc_msg_lookup_super(&sup, sel); + objc_try!({ + A::invoke(msg_send_fn, receiver, sel, args) + }) +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/message/mod.rs b/third_party/cargo/vendor/objc-0.2.7/src/message/mod.rs new file mode 100644 index 0000000..cb11e99 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/message/mod.rs @@ -0,0 +1,296 @@ +use std::any::Any; +use std::error::Error; +use std::fmt; +use std::mem; + +use runtime::{Class, Imp, Object, Sel}; +use {Encode, EncodeArguments}; + +#[cfg(feature = "exception")] +macro_rules! objc_try { + ($b:block) => ( + $crate::exception::try(|| $b).map_err(|exception| + if exception.is_null() { + MessageError("Uncaught exception nil".to_owned()) + } else { + MessageError(format!("Uncaught exception {:?}", &**exception)) + } + ) + ) +} + +#[cfg(not(feature = "exception"))] +macro_rules! objc_try { + ($b:block) => (Ok($b)) +} + +mod verify; + +#[cfg(any(target_os = "macos", target_os = "ios"))] +#[path = "apple/mod.rs"] +mod platform; +#[cfg(not(any(target_os = "macos", target_os = "ios")))] +#[path = "gnustep.rs"] +mod platform; + +use self::platform::{send_unverified, send_super_unverified}; +use self::verify::verify_message_signature; + +/// Specifies the superclass of an instance. +#[repr(C)] +pub struct Super { + /// Specifies an instance of a class. + pub receiver: *mut Object, + /// Specifies the particular superclass of the instance to message. + pub superclass: *const Class, +} + +/// Types that may be sent Objective-C messages. +/// For example: objects, classes, and blocks. +pub unsafe trait Message { + /** + Sends a message to self with the given selector and arguments. + + The correct version of `objc_msgSend` will be chosen based on the + return type. For more information, see Apple's documentation: + + + If the selector is known at compile-time, it is recommended to use the + `msg_send!` macro rather than this method. + */ + #[cfg(not(feature = "verify_message"))] + unsafe fn send_message(&self, sel: Sel, args: A) + -> Result + where Self: Sized, A: MessageArguments, R: Any { + send_message(self, sel, args) + } + + #[cfg(feature = "verify_message")] + unsafe fn send_message(&self, sel: Sel, args: A) + -> Result + where Self: Sized, A: MessageArguments + EncodeArguments, + R: Any + Encode { + send_message(self, sel, args) + } + + /** + Verifies that the argument and return types match the encoding of the + method for the given selector. + + This will look up the encoding of the method for the given selector, `sel`, + and return a `MessageError` if any encodings differ for the arguments `A` + and return type `R`. + + # Example + ``` no_run + # #[macro_use] extern crate objc; + # use objc::runtime::{BOOL, Class, Object}; + # use objc::Message; + # fn main() { + let obj: &Object; + # obj = unsafe { msg_send![class!(NSObject), new] }; + let sel = sel!(isKindOfClass:); + // Verify isKindOfClass: takes one Class and returns a BOOL + let result = obj.verify_message::<(&Class,), BOOL>(sel); + assert!(result.is_ok()); + # } + ``` + */ + fn verify_message(&self, sel: Sel) -> Result<(), MessageError> + where Self: Sized, A: EncodeArguments, R: Encode { + let obj = unsafe { &*(self as *const _ as *const Object) }; + verify_message_signature::(obj.class(), sel) + } +} + +unsafe impl Message for Object { } + +unsafe impl Message for Class { } + +/// Types that may be used as the arguments of an Objective-C message. +pub trait MessageArguments: Sized { + /// Invoke an `Imp` with the given object, selector, and arguments. + /// + /// This method is the primitive used when sending messages and should not + /// be called directly; instead, use the `msg_send!` macro or, in cases + /// with a dynamic selector, the `Message::send_message` method. + unsafe fn invoke(imp: Imp, obj: *mut Object, sel: Sel, args: Self) -> R + where R: Any; +} + +macro_rules! message_args_impl { + ($($a:ident : $t:ident),*) => ( + impl<$($t),*> MessageArguments for ($($t,)*) { + unsafe fn invoke(imp: Imp, obj: *mut Object, sel: Sel, ($($a,)*): Self) -> R + where R: Any { + let imp: unsafe extern fn(*mut Object, Sel $(, $t)*) -> R = + mem::transmute(imp); + imp(obj, sel $(, $a)*) + } + } + ); +} + +message_args_impl!(); +message_args_impl!(a: A); +message_args_impl!(a: A, b: B); +message_args_impl!(a: A, b: B, c: C); +message_args_impl!(a: A, b: B, c: C, d: D); +message_args_impl!(a: A, b: B, c: C, d: D, e: E); +message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F); +message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G); +message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H); +message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I); +message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J); +message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K); +message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L); + +/** +An error encountered while attempting to send a message. + +Currently, an error may be returned in two cases: + +* an Objective-C exception is thrown and the `exception` feature is enabled +* the encodings of the arguments do not match the encoding of the method + and the `verify_message` feature is enabled +*/ +#[derive(Debug)] +pub struct MessageError(String); + +impl fmt::Display for MessageError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.0, f) + } +} + +impl Error for MessageError { + fn description(&self) -> &str { + &self.0 + } +} + +#[doc(hidden)] +#[inline(always)] +#[cfg(not(feature = "verify_message"))] +pub unsafe fn send_message(obj: *const T, sel: Sel, args: A) + -> Result + where T: Message, A: MessageArguments, R: Any { + send_unverified(obj, sel, args) +} + +#[doc(hidden)] +#[inline(always)] +#[cfg(feature = "verify_message")] +pub unsafe fn send_message(obj: *const T, sel: Sel, args: A) + -> Result + where T: Message, A: MessageArguments + EncodeArguments, + R: Any + Encode { + let cls = if obj.is_null() { + return Err(MessageError(format!("Messaging {:?} to nil", sel))); + } else { + (*(obj as *const Object)).class() + }; + + verify_message_signature::(cls, sel).and_then(|_| { + send_unverified(obj, sel, args) + }) +} + +#[doc(hidden)] +#[inline(always)] +#[cfg(not(feature = "verify_message"))] +pub unsafe fn send_super_message(obj: *const T, superclass: &Class, + sel: Sel, args: A) -> Result + where T: Message, A: MessageArguments, R: Any { + send_super_unverified(obj, superclass, sel, args) +} + +#[doc(hidden)] +#[inline(always)] +#[cfg(feature = "verify_message")] +pub unsafe fn send_super_message(obj: *const T, superclass: &Class, + sel: Sel, args: A) -> Result + where T: Message, A: MessageArguments + EncodeArguments, + R: Any + Encode { + if obj.is_null() { + return Err(MessageError(format!("Messaging {:?} to nil", sel))); + } + + verify_message_signature::(superclass, sel).and_then(|_| { + send_super_unverified(obj, superclass, sel, args) + }) +} + +#[cfg(test)] +mod tests { + use test_utils; + use runtime::Object; + use super::Message; + + #[test] + fn test_send_message() { + let obj = test_utils::custom_object(); + let result: u32 = unsafe { + let _: () = msg_send![obj, setFoo:4u32]; + msg_send![obj, foo] + }; + assert!(result == 4); + } + + #[test] + fn test_send_message_stret() { + let obj = test_utils::custom_object(); + let result: test_utils::CustomStruct = unsafe { + msg_send![obj, customStruct] + }; + let expected = test_utils::CustomStruct { a: 1, b:2, c: 3, d: 4 }; + assert!(result == expected); + } + + #[cfg(not(feature = "verify_message"))] + #[test] + fn test_send_message_nil() { + let nil: *mut Object = ::std::ptr::null_mut(); + let result: usize = unsafe { + msg_send![nil, hash] + }; + assert!(result == 0); + + let result: *mut Object = unsafe { + msg_send![nil, description] + }; + assert!(result.is_null()); + + let result: f64 = unsafe { + msg_send![nil, doubleValue] + }; + assert!(result == 0.0); + } + + #[test] + fn test_send_message_super() { + let obj = test_utils::custom_subclass_object(); + let superclass = test_utils::custom_class(); + unsafe { + let _: () = msg_send![obj, setFoo:4u32]; + let foo: u32 = msg_send![super(obj, superclass), foo]; + assert!(foo == 4); + + // The subclass is overriden to return foo + 2 + let foo: u32 = msg_send![obj, foo]; + assert!(foo == 6); + } + } + + #[test] + fn test_verify_message() { + let obj = test_utils::custom_object(); + assert!(obj.verify_message::<(), u32>(sel!(foo)).is_ok()); + assert!(obj.verify_message::<(u32,), ()>(sel!(setFoo:)).is_ok()); + + // Incorrect types + assert!(obj.verify_message::<(), u64>(sel!(setFoo:)).is_err()); + // Unimplemented selector + assert!(obj.verify_message::<(u32,), ()>(sel!(setFoo)).is_err()); + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/message/verify.rs b/third_party/cargo/vendor/objc-0.2.7/src/message/verify.rs new file mode 100644 index 0000000..61bd4eb --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/message/verify.rs @@ -0,0 +1,49 @@ +use runtime::{Class, Object, Sel}; +use {Encode, EncodeArguments}; +use super::MessageError; + +pub fn verify_message_signature(cls: &Class, sel: Sel) + -> Result<(), MessageError> + where A: EncodeArguments, R: Encode { + let method = match cls.instance_method(sel) { + Some(method) => method, + None => return Err(MessageError( + format!("Method {:?} not found on class {:?}", + sel, cls) + )), + }; + + let ret = R::encode(); + let expected_ret = method.return_type(); + if ret != expected_ret { + return Err(MessageError( + format!("Return type code {:?} does not match expected {:?} for method {:?}", + ret, expected_ret, method.name()) + )); + } + + let self_and_cmd = [<*mut Object>::encode(), Sel::encode()]; + let args = A::encodings(); + let args = args.as_ref(); + + let count = self_and_cmd.len() + args.len(); + let expected_count = method.arguments_count(); + if count != expected_count { + return Err(MessageError( + format!("Method {:?} accepts {} arguments, but {} were given", + method.name(), expected_count, count) + )); + } + + for (i, arg) in self_and_cmd.iter().chain(args).enumerate() { + let expected = method.argument_type(i).unwrap(); + if *arg != expected { + return Err(MessageError( + format!("Method {:?} expected argument at index {} with type code {:?} but was given {:?}", + method.name(), i, expected, arg) + )); + } + } + + Ok(()) +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/rc/autorelease.rs b/third_party/cargo/vendor/objc-0.2.7/src/rc/autorelease.rs new file mode 100644 index 0000000..ad7a5e2 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/rc/autorelease.rs @@ -0,0 +1,30 @@ +use std::os::raw::c_void; +use runtime::{objc_autoreleasePoolPush, objc_autoreleasePoolPop}; + +// we use a struct to ensure that objc_autoreleasePoolPop during unwinding. +struct AutoReleaseHelper { + context: *mut c_void, +} + +impl AutoReleaseHelper { + unsafe fn new() -> Self { + AutoReleaseHelper { context: objc_autoreleasePoolPush() } + } +} + +impl Drop for AutoReleaseHelper { + fn drop(&mut self) { + unsafe { objc_autoreleasePoolPop(self.context) } + } +} + +/** +Execute `f` in the context of a new autorelease pool. The pool is drained +after the execution of `f` completes. + +This corresponds to `@autoreleasepool` blocks in Objective-C and Swift. +*/ +pub fn autoreleasepool T>(f: F) -> T { + let _context = unsafe { AutoReleaseHelper::new() }; + f() +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/rc/mod.rs b/third_party/cargo/vendor/objc-0.2.7/src/rc/mod.rs new file mode 100644 index 0000000..f6d26f7 --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/rc/mod.rs @@ -0,0 +1,123 @@ +/*! +Utilities for reference counting Objective-C objects. + +The utilities of the `rc` module provide ARC-like semantics for working with +Objective-C's reference counted objects in Rust. +A `StrongPtr` retains an object and releases the object when dropped. +A `WeakPtr` will not retain the object, but can be upgraded to a `StrongPtr` +and safely fails if the object has been deallocated. + +These utilities are not intended to provide a fully safe interface, but can be +useful when writing higher-level Rust wrappers for Objective-C code. + +For more information on Objective-C's reference counting, see Apple's documentation: + + +# Example + +``` no_run +# #[macro_use] extern crate objc; +# use objc::rc::{autoreleasepool, StrongPtr}; +# fn main() { +// StrongPtr will release the object when dropped +let obj = unsafe { + StrongPtr::new(msg_send![class!(NSObject), new]) +}; + +// Cloning retains the object an additional time +let cloned = obj.clone(); +autoreleasepool(|| { + // Autorelease consumes the StrongPtr, but won't + // actually release until the end of an autoreleasepool + cloned.autorelease(); +}); + +// Weak references won't retain the object +let weak = obj.weak(); +drop(obj); +assert!(weak.load().is_null()); +# } +``` +*/ + +mod strong; +mod weak; +mod autorelease; + +pub use self::strong::StrongPtr; +pub use self::weak::WeakPtr; +pub use self::autorelease::autoreleasepool; + +// These tests use NSObject, which isn't present for GNUstep +#[cfg(all(test, any(target_os = "macos", target_os = "ios")))] +mod tests { + use runtime::Object; + use super::StrongPtr; + use super::autoreleasepool; + + #[test] + fn test_strong_clone() { + fn retain_count(obj: *mut Object) -> usize { + unsafe { msg_send![obj, retainCount] } + } + + let obj = unsafe { + StrongPtr::new(msg_send![class!(NSObject), new]) + }; + assert!(retain_count(*obj) == 1); + + let cloned = obj.clone(); + assert!(retain_count(*cloned) == 2); + assert!(retain_count(*obj) == 2); + + drop(obj); + assert!(retain_count(*cloned) == 1); + } + + #[test] + fn test_weak() { + let obj = unsafe { + StrongPtr::new(msg_send![class!(NSObject), new]) + }; + let weak = obj.weak(); + + let strong = weak.load(); + assert!(*strong == *obj); + drop(strong); + + drop(obj); + assert!(weak.load().is_null()); + } + + #[test] + fn test_weak_copy() { + let obj = unsafe { + StrongPtr::new(msg_send![class!(NSObject), new]) + }; + let weak = obj.weak(); + + let weak2 = weak.clone(); + let strong = weak2.load(); + assert!(*strong == *obj); + } + + #[test] + fn test_autorelease() { + let obj = unsafe { + StrongPtr::new(msg_send![class!(NSObject), new]) + }; + + fn retain_count(obj: *mut Object) -> usize { + unsafe { msg_send![obj, retainCount] } + } + let cloned = obj.clone(); + + autoreleasepool(|| { + obj.autorelease(); + assert!(retain_count(*cloned) == 2); + }); + + // make sure that the autoreleased value has been released + assert!(retain_count(*cloned) == 1); + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/rc/strong.rs b/third_party/cargo/vendor/objc-0.2.7/src/rc/strong.rs new file mode 100644 index 0000000..a61881b --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/rc/strong.rs @@ -0,0 +1,73 @@ +use std::fmt; +use std::mem; +use std::ops::Deref; + +use runtime::{Object, self}; +use super::WeakPtr; + +/// A pointer that strongly references an object, ensuring it won't be deallocated. +pub struct StrongPtr(*mut Object); + +impl StrongPtr { + /// Constructs a `StrongPtr` to a newly created object that already has a + /// +1 retain count. This will not retain the object. + /// When dropped, the object will be released. + /// Unsafe because the caller must ensure the given object pointer is valid. + pub unsafe fn new(ptr: *mut Object) -> Self { + StrongPtr(ptr) + } + + /// Retains the given object and constructs a `StrongPtr` to it. + /// When dropped, the object will be released. + /// Unsafe because the caller must ensure the given object pointer is valid. + pub unsafe fn retain(ptr: *mut Object) -> Self { + StrongPtr(runtime::objc_retain(ptr)) + } + + /// Autoreleases self, meaning that the object is not immediately released, + /// but will be when the autorelease pool is drained. A pointer to the + /// object is returned, but its validity is no longer ensured. + pub fn autorelease(self) -> *mut Object { + let ptr = self.0; + mem::forget(self); + unsafe { + runtime::objc_autorelease(ptr); + } + ptr + } + + /// Returns a `WeakPtr` to self. + pub fn weak(&self) -> WeakPtr { + unsafe { WeakPtr::new(self.0) } + } +} + +impl Drop for StrongPtr { + fn drop(&mut self) { + unsafe { + runtime::objc_release(self.0); + } + } +} + +impl Clone for StrongPtr { + fn clone(&self) -> StrongPtr { + unsafe { + StrongPtr::retain(self.0) + } + } +} + +impl Deref for StrongPtr { + type Target = *mut Object; + + fn deref(&self) -> &*mut Object { + &self.0 + } +} + +impl fmt::Pointer for StrongPtr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Pointer::fmt(&self.0, f) + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/rc/weak.rs b/third_party/cargo/vendor/objc-0.2.7/src/rc/weak.rs new file mode 100644 index 0000000..289bd8d --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/rc/weak.rs @@ -0,0 +1,50 @@ +use std::cell::UnsafeCell; +use std::ptr; + +use runtime::{Object, self}; +use super::StrongPtr; + +// Our pointer must have the same address even if we are moved, so Box it. +// Although loading the WeakPtr may modify the pointer, it is thread safe, +// so we must use an UnsafeCell to get a *mut without self being mutable. + +/// A pointer that weakly references an object, allowing to safely check +/// whether it has been deallocated. +pub struct WeakPtr(Box>); + +impl WeakPtr { + /// Constructs a `WeakPtr` to the given object. + /// Unsafe because the caller must ensure the given object pointer is valid. + pub unsafe fn new(obj: *mut Object) -> Self { + let ptr = Box::new(UnsafeCell::new(ptr::null_mut())); + runtime::objc_initWeak(ptr.get(), obj); + WeakPtr(ptr) + } + + /// Loads the object self points to, returning a `StrongPtr`. + /// If the object has been deallocated, the returned pointer will be null. + pub fn load(&self) -> StrongPtr { + unsafe { + let ptr = runtime::objc_loadWeakRetained(self.0.get()); + StrongPtr::new(ptr) + } + } +} + +impl Drop for WeakPtr { + fn drop(&mut self) { + unsafe { + runtime::objc_destroyWeak(self.0.get()); + } + } +} + +impl Clone for WeakPtr { + fn clone(&self) -> Self { + let ptr = Box::new(UnsafeCell::new(ptr::null_mut())); + unsafe { + runtime::objc_copyWeak(ptr.get(), self.0.get()); + } + WeakPtr(ptr) + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/runtime.rs b/third_party/cargo/vendor/objc-0.2.7/src/runtime.rs new file mode 100644 index 0000000..3b533ef --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/runtime.rs @@ -0,0 +1,632 @@ +//! A Rust interface for the functionality of the Objective-C runtime. +//! +//! For more information on foreign functions, see Apple's documentation: +//! + +use std::ffi::{CStr, CString}; +use std::fmt; +use std::os::raw::{c_char, c_int, c_uint, c_void}; +use std::ptr; +use std::str; +use malloc_buf::MallocBuffer; + +use encode; +use {Encode, Encoding}; + +/// The Objective-C `BOOL` type. +/// +/// To convert an Objective-C `BOOL` into a Rust `bool`, compare it with `NO`. +#[cfg(not(target_arch = "aarch64"))] +pub type BOOL = ::std::os::raw::c_schar; +/// The equivalent of true for Objective-C's `BOOL` type. +#[cfg(not(target_arch = "aarch64"))] +pub const YES: BOOL = 1; +/// The equivalent of false for Objective-C's `BOOL` type. +#[cfg(not(target_arch = "aarch64"))] +pub const NO: BOOL = 0; + +#[cfg(target_arch = "aarch64")] +pub type BOOL = bool; +#[cfg(target_arch = "aarch64")] +pub const YES: BOOL = true; +#[cfg(target_arch = "aarch64")] +pub const NO: BOOL = false; + +/// A type that represents a method selector. +#[repr(C)] +pub struct Sel { + ptr: *const c_void, +} + +/// A marker type to be embedded into other types just so that they cannot be +/// constructed externally. +type PrivateMarker = [u8; 0]; + +/// A type that represents an instance variable. +#[repr(C)] +pub struct Ivar { + _priv: PrivateMarker, +} + +/// A type that represents a method in a class definition. +#[repr(C)] +pub struct Method { + _priv: PrivateMarker, +} + +/// A type that represents an Objective-C class. +#[repr(C)] +pub struct Class { + _priv: PrivateMarker, +} + +/// A type that represents an Objective-C protocol. +#[repr(C)] +pub struct Protocol { + _priv: PrivateMarker +} + +/// A type that represents an instance of a class. +#[repr(C)] +pub struct Object { + _priv: PrivateMarker, +} + +/// A pointer to the start of a method implementation. +pub type Imp = unsafe extern fn(); + +#[link(name = "objc", kind = "dylib")] +extern { + pub fn sel_registerName(name: *const c_char) -> Sel; + pub fn sel_getName(sel: Sel) -> *const c_char; + + pub fn class_getName(cls: *const Class) -> *const c_char; + pub fn class_getSuperclass(cls: *const Class) -> *const Class; + pub fn class_getInstanceSize(cls: *const Class) -> usize; + pub fn class_getInstanceMethod(cls: *const Class, sel: Sel) -> *const Method; + pub fn class_getInstanceVariable(cls: *const Class, name: *const c_char) -> *const Ivar; + pub fn class_copyMethodList(cls: *const Class, outCount: *mut c_uint) -> *mut *const Method; + pub fn class_copyIvarList(cls: *const Class, outCount: *mut c_uint) -> *mut *const Ivar; + pub fn class_addMethod(cls: *mut Class, name: Sel, imp: Imp, types: *const c_char) -> BOOL; + pub fn class_addIvar(cls: *mut Class, name: *const c_char, size: usize, alignment: u8, types: *const c_char) -> BOOL; + pub fn class_addProtocol(cls: *mut Class, proto: *const Protocol) -> BOOL; + pub fn class_conformsToProtocol(cls: *const Class, proto: *const Protocol) -> BOOL; + pub fn class_copyProtocolList(cls: *const Class, outCount: *mut c_uint) -> *mut *const Protocol; + + pub fn objc_allocateClassPair(superclass: *const Class, name: *const c_char, extraBytes: usize) -> *mut Class; + pub fn objc_disposeClassPair(cls: *mut Class); + pub fn objc_registerClassPair(cls: *mut Class); + + pub fn class_createInstance(cls: *const Class, extraBytes: usize) -> *mut Object; + pub fn object_dispose(obj: *mut Object) -> *mut Object; + pub fn object_getClass(obj: *const Object) -> *const Class; + + pub fn objc_getClassList(buffer: *mut *const Class, bufferLen: c_int) -> c_int; + pub fn objc_copyClassList(outCount: *mut c_uint) -> *mut *const Class; + pub fn objc_getClass(name: *const c_char) -> *const Class; + pub fn objc_getProtocol(name: *const c_char) -> *const Protocol; + pub fn objc_copyProtocolList(outCount: *mut c_uint) -> *mut *const Protocol; + pub fn objc_allocateProtocol(name: *const c_char) -> *mut Protocol; + pub fn objc_registerProtocol(proto: *mut Protocol); + + pub fn objc_autoreleasePoolPush() -> *mut c_void; + pub fn objc_autoreleasePoolPop(context: *mut c_void); + + pub fn protocol_addMethodDescription(proto: *mut Protocol, name: Sel, types: *const c_char, isRequiredMethod: BOOL, + isInstanceMethod: BOOL); + pub fn protocol_addProtocol(proto: *mut Protocol, addition: *const Protocol); + pub fn protocol_getName(proto: *const Protocol) -> *const c_char; + pub fn protocol_isEqual(proto: *const Protocol, other: *const Protocol) -> BOOL; + pub fn protocol_copyProtocolList(proto: *const Protocol, outCount: *mut c_uint) -> *mut *const Protocol; + pub fn protocol_conformsToProtocol(proto: *const Protocol, other: *const Protocol) -> BOOL; + + pub fn ivar_getName(ivar: *const Ivar) -> *const c_char; + pub fn ivar_getOffset(ivar: *const Ivar) -> isize; + pub fn ivar_getTypeEncoding(ivar: *const Ivar) -> *const c_char; + + pub fn method_getName(method: *const Method) -> Sel; + pub fn method_getImplementation(method: *const Method) -> Imp; + pub fn method_copyReturnType(method: *const Method) -> *mut c_char; + pub fn method_copyArgumentType(method: *const Method, index: c_uint) -> *mut c_char; + pub fn method_getNumberOfArguments(method: *const Method) -> c_uint; + pub fn method_setImplementation(method: *mut Method, imp: Imp) -> Imp; + pub fn method_exchangeImplementations(m1: *mut Method, m2: *mut Method); + + pub fn objc_retain(obj: *mut Object) -> *mut Object; + pub fn objc_release(obj: *mut Object); + pub fn objc_autorelease(obj: *mut Object); + + pub fn objc_loadWeakRetained(location: *mut *mut Object) -> *mut Object; + pub fn objc_initWeak(location: *mut *mut Object, obj: *mut Object) -> *mut Object; + pub fn objc_destroyWeak(location: *mut *mut Object); + pub fn objc_copyWeak(to: *mut *mut Object, from: *mut *mut Object); +} + +impl Sel { + /// Registers a method with the Objective-C runtime system, + /// maps the method name to a selector, and returns the selector value. + pub fn register(name: &str) -> Sel { + let name = CString::new(name).unwrap(); + unsafe { + sel_registerName(name.as_ptr()) + } + } + + /// Returns the name of the method specified by self. + pub fn name(&self) -> &str { + let name = unsafe { + CStr::from_ptr(sel_getName(*self)) + }; + str::from_utf8(name.to_bytes()).unwrap() + } + + /// Wraps a raw pointer to a selector into a `Sel` object. + /// + /// This is almost never what you want; use `Sel::register()` instead. + #[inline] + pub unsafe fn from_ptr(ptr: *const c_void) -> Sel { + Sel { + ptr: ptr, + } + } + + /// Returns a pointer to the raw selector. + #[inline] + pub fn as_ptr(&self) -> *const c_void { + self.ptr + } +} + +impl PartialEq for Sel { + fn eq(&self, other: &Sel) -> bool { + self.ptr == other.ptr + } +} + +impl Eq for Sel { } + +// Sel is safe to share across threads because it is immutable +unsafe impl Sync for Sel { } +unsafe impl Send for Sel { } + +impl Copy for Sel { } + +impl Clone for Sel { + fn clone(&self) -> Sel { *self } +} + +impl fmt::Debug for Sel { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.name()) + } +} + +impl Ivar { + /// Returns the name of self. + pub fn name(&self) -> &str { + let name = unsafe { + CStr::from_ptr(ivar_getName(self)) + }; + str::from_utf8(name.to_bytes()).unwrap() + } + + /// Returns the offset of self. + pub fn offset(&self) -> isize { + let offset = unsafe { + ivar_getOffset(self) + }; + offset as isize + } + + /// Returns the `Encoding` of self. + pub fn type_encoding(&self) -> Encoding { + let encoding = unsafe { + CStr::from_ptr(ivar_getTypeEncoding(self)) + }; + let s = str::from_utf8(encoding.to_bytes()).unwrap(); + encode::from_str(s) + } +} + +impl Method { + /// Returns the name of self. + pub fn name(&self) -> Sel { + unsafe { + method_getName(self) + } + } + + /// Returns the `Encoding` of self's return type. + pub fn return_type(&self) -> Encoding { + unsafe { + let encoding = method_copyReturnType(self); + encode::from_malloc_str(encoding) + } + } + + /// Returns the `Encoding` of a single parameter type of self, or + /// `None` if self has no parameter at the given index. + pub fn argument_type(&self, index: usize) -> Option { + unsafe { + let encoding = method_copyArgumentType(self, index as c_uint); + if encoding.is_null() { + None + } else { + Some(encode::from_malloc_str(encoding)) + } + } + } + + /// Returns the number of arguments accepted by self. + pub fn arguments_count(&self) -> usize { + unsafe { + method_getNumberOfArguments(self) as usize + } + } + + /// Returns the implementation of self. + pub fn implementation(&self) -> Imp { + unsafe { + method_getImplementation(self) + } + } +} + +impl Class { + /// Returns the class definition of a specified class, or `None` if the + /// class is not registered with the Objective-C runtime. + pub fn get(name: &str) -> Option<&'static Class> { + let name = CString::new(name).unwrap(); + unsafe { + let cls = objc_getClass(name.as_ptr()); + if cls.is_null() { None } else { Some(&*cls) } + } + } + + /// Obtains the list of registered class definitions. + pub fn classes() -> MallocBuffer<&'static Class> { + unsafe { + let mut count: c_uint = 0; + let classes = objc_copyClassList(&mut count); + MallocBuffer::new(classes as *mut _, count as usize).unwrap() + } + } + + /// Returns the total number of registered classes. + pub fn classes_count() -> usize { + unsafe { + objc_getClassList(ptr::null_mut(), 0) as usize + } + } + + /// Returns the name of self. + pub fn name(&self) -> &str { + let name = unsafe { + CStr::from_ptr(class_getName(self)) + }; + str::from_utf8(name.to_bytes()).unwrap() + } + + /// Returns the superclass of self, or `None` if self is a root class. + pub fn superclass(&self) -> Option<&Class> { + unsafe { + let superclass = class_getSuperclass(self); + if superclass.is_null() { None } else { Some(&*superclass) } + } + } + + /// Returns the metaclass of self. + pub fn metaclass(&self) -> &Class { + unsafe { + let self_ptr: *const Class = self; + &*object_getClass(self_ptr as *const Object) + } + } + + /// Returns the size of instances of self. + pub fn instance_size(&self) -> usize { + unsafe { + class_getInstanceSize(self) as usize + } + } + + /// Returns a specified instance method for self, or `None` if self and + /// its superclasses do not contain an instance method with the + /// specified selector. + pub fn instance_method(&self, sel: Sel) -> Option<&Method> { + unsafe { + let method = class_getInstanceMethod(self, sel); + if method.is_null() { None } else { Some(&*method) } + } + } + + /// Returns the ivar for a specified instance variable of self, or `None` + /// if self has no ivar with the given name. + pub fn instance_variable(&self, name: &str) -> Option<&Ivar> { + let name = CString::new(name).unwrap(); + unsafe { + let ivar = class_getInstanceVariable(self, name.as_ptr()); + if ivar.is_null() { None } else { Some(&*ivar) } + } + } + + /// Describes the instance methods implemented by self. + pub fn instance_methods(&self) -> MallocBuffer<&Method> { + unsafe { + let mut count: c_uint = 0; + let methods = class_copyMethodList(self, &mut count); + MallocBuffer::new(methods as *mut _, count as usize).unwrap() + } + + } + + /// Checks whether this class conforms to the specified protocol. + pub fn conforms_to(&self, proto: &Protocol) -> bool { + unsafe { class_conformsToProtocol(self, proto) == YES } + } + + /// Get a list of the protocols to which this class conforms. + pub fn adopted_protocols(&self) -> MallocBuffer<&Protocol> { + unsafe { + let mut count: c_uint = 0; + let protos = class_copyProtocolList(self, &mut count); + MallocBuffer::new(protos as *mut _, count as usize).unwrap() + } + } + + /// Describes the instance variables declared by self. + pub fn instance_variables(&self) -> MallocBuffer<&Ivar> { + unsafe { + let mut count: c_uint = 0; + let ivars = class_copyIvarList(self, &mut count); + MallocBuffer::new(ivars as *mut _, count as usize).unwrap() + } + } +} + +impl PartialEq for Class { + fn eq(&self, other: &Class) -> bool { + let self_ptr: *const Class = self; + let other_ptr: *const Class = other; + self_ptr == other_ptr + } +} + +impl Eq for Class { } + +impl fmt::Debug for Class { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.name()) + } +} + +impl Protocol { + /// Returns the protocol definition of a specified protocol, or `None` if the + /// protocol is not registered with the Objective-C runtime. + pub fn get(name: &str) -> Option<&'static Protocol> { + let name = CString::new(name).unwrap(); + unsafe { + let proto = objc_getProtocol(name.as_ptr()); + if proto.is_null() { None } else { Some(&*proto) } + } + } + + /// Obtains the list of registered protocol definitions. + pub fn protocols() -> MallocBuffer<&'static Protocol> { + unsafe { + let mut count: c_uint = 0; + let protocols = objc_copyProtocolList(&mut count); + MallocBuffer::new(protocols as *mut _, count as usize).unwrap() + } + } + + /// Get a list of the protocols to which this protocol conforms. + pub fn adopted_protocols(&self) -> MallocBuffer<&Protocol> { + unsafe { + let mut count: c_uint = 0; + let protocols = protocol_copyProtocolList(self, &mut count); + MallocBuffer::new(protocols as *mut _, count as usize).unwrap() + } + } + + /// Checks whether this protocol conforms to the specified protocol. + pub fn conforms_to(&self, proto: &Protocol) -> bool { + unsafe { protocol_conformsToProtocol(self, proto) == YES } + } + + /// Returns the name of self. + pub fn name(&self) -> &str { + let name = unsafe { + CStr::from_ptr(protocol_getName(self)) + }; + str::from_utf8(name.to_bytes()).unwrap() + } +} + +impl PartialEq for Protocol { + fn eq(&self, other: &Protocol) -> bool { + unsafe { protocol_isEqual(self, other) == YES } + } +} + +impl Eq for Protocol { } + +impl fmt::Debug for Protocol { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.name()) + } +} + +impl Object { + /// Returns the class of self. + pub fn class(&self) -> &Class { + unsafe { + &*object_getClass(self) + } + } + + /// Returns a reference to the ivar of self with the given name. + /// Panics if self has no ivar with the given name. + /// Unsafe because the caller must ensure that the ivar is actually + /// of type `T`. + pub unsafe fn get_ivar(&self, name: &str) -> &T where T: Encode { + let offset = { + let cls = self.class(); + match cls.instance_variable(name) { + Some(ivar) => { + assert!(ivar.type_encoding() == T::encode()); + ivar.offset() + } + None => panic!("Ivar {} not found on class {:?}", name, cls), + } + }; + let ptr = { + let self_ptr: *const Object = self; + (self_ptr as *const u8).offset(offset) as *const T + }; + &*ptr + } + + /// Returns a mutable reference to the ivar of self with the given name. + /// Panics if self has no ivar with the given name. + /// Unsafe because the caller must ensure that the ivar is actually + /// of type `T`. + pub unsafe fn get_mut_ivar(&mut self, name: &str) -> &mut T + where T: Encode { + let offset = { + let cls = self.class(); + match cls.instance_variable(name) { + Some(ivar) => { + assert!(ivar.type_encoding() == T::encode()); + ivar.offset() + } + None => panic!("Ivar {} not found on class {:?}", name, cls), + } + }; + let ptr = { + let self_ptr: *mut Object = self; + (self_ptr as *mut u8).offset(offset) as *mut T + }; + &mut *ptr + } + + /// Sets the value of the ivar of self with the given name. + /// Panics if self has no ivar with the given name. + /// Unsafe because the caller must ensure that the ivar is actually + /// of type `T`. + pub unsafe fn set_ivar(&mut self, name: &str, value: T) + where T: Encode { + *self.get_mut_ivar::(name) = value; + } +} + +impl fmt::Debug for Object { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "<{:?}: {:p}>", self.class(), self) + } +} + +#[cfg(test)] +mod tests { + use test_utils; + use Encode; + use super::{Class, Protocol, Sel}; + + #[test] + fn test_ivar() { + let cls = test_utils::custom_class(); + let ivar = cls.instance_variable("_foo").unwrap(); + assert!(ivar.name() == "_foo"); + assert!(ivar.type_encoding() == ::encode()); + assert!(ivar.offset() > 0); + + let ivars = cls.instance_variables(); + assert!(ivars.len() > 0); + } + + #[test] + fn test_method() { + let cls = test_utils::custom_class(); + let sel = Sel::register("foo"); + let method = cls.instance_method(sel).unwrap(); + assert!(method.name().name() == "foo"); + assert!(method.arguments_count() == 2); + assert!(method.return_type() == ::encode()); + assert!(method.argument_type(1).unwrap() == Sel::encode()); + + let methods = cls.instance_methods(); + assert!(methods.len() > 0); + } + + #[test] + fn test_class() { + let cls = test_utils::custom_class(); + assert!(cls.name() == "CustomObject"); + assert!(cls.instance_size() > 0); + assert!(cls.superclass().is_none()); + + assert!(Class::get(cls.name()) == Some(cls)); + + let metaclass = cls.metaclass(); + // The metaclass of a root class is a subclass of the root class + assert!(metaclass.superclass().unwrap() == cls); + + let subclass = test_utils::custom_subclass(); + assert!(subclass.superclass().unwrap() == cls); + } + + #[test] + fn test_classes() { + assert!(Class::classes_count() > 0); + let classes = Class::classes(); + assert!(classes.len() > 0); + } + + #[test] + fn test_protocol() { + let proto = test_utils::custom_protocol(); + assert!(proto.name() == "CustomProtocol"); + let class = test_utils::custom_class(); + assert!(class.conforms_to(proto)); + let class_protocols = class.adopted_protocols(); + assert!(class_protocols.len() > 0); + } + + #[test] + fn test_protocol_method() { + let class = test_utils::custom_class(); + let result: i32 = unsafe { + msg_send![class, addNumber:1 toNumber:2] + }; + assert_eq!(result, 3); + } + + #[test] + fn test_subprotocols() { + let sub_proto = test_utils::custom_subprotocol(); + let super_proto = test_utils::custom_protocol(); + assert!(sub_proto.conforms_to(super_proto)); + let adopted_protocols = sub_proto.adopted_protocols(); + assert_eq!(adopted_protocols[0], super_proto); + } + + #[test] + fn test_protocols() { + // Ensure that a protocol has been registered on linux + let _ = test_utils::custom_protocol(); + + let protocols = Protocol::protocols(); + assert!(protocols.len() > 0); + } + + #[test] + fn test_object() { + let mut obj = test_utils::custom_object(); + assert!(obj.class() == test_utils::custom_class()); + let result: u32 = unsafe { + obj.set_ivar("_foo", 4u32); + *obj.get_ivar("_foo") + }; + assert!(result == 4); + } +} diff --git a/third_party/cargo/vendor/objc-0.2.7/src/test_utils.rs b/third_party/cargo/vendor/objc-0.2.7/src/test_utils.rs new file mode 100644 index 0000000..873f82f --- /dev/null +++ b/third_party/cargo/vendor/objc-0.2.7/src/test_utils.rs @@ -0,0 +1,187 @@ +use std::ops::{Deref, DerefMut}; +use std::os::raw::c_char; +use std::sync::{Once, ONCE_INIT}; + +use declare::{ClassDecl, ProtocolDecl}; +use runtime::{Class, Object, Protocol, Sel, self}; +use {Encode, Encoding}; + +pub struct CustomObject { + obj: *mut Object, +} + +impl CustomObject { + fn new(class: &Class) -> Self { + let obj = unsafe { + runtime::class_createInstance(class, 0) + }; + CustomObject { obj: obj } + } +} + +impl Deref for CustomObject { + type Target = Object; + + fn deref(&self) -> &Object { + unsafe { &*self.obj } + } +} + +impl DerefMut for CustomObject { + fn deref_mut(&mut self) -> &mut Object { + unsafe { &mut *self.obj } + } +} + +impl Drop for CustomObject { + fn drop(&mut self) { + unsafe { + runtime::object_dispose(self.obj); + } + } +} + +#[derive(Eq, PartialEq)] +pub struct CustomStruct { + pub a: u64, + pub b: u64, + pub c: u64, + pub d: u64, +} + +unsafe impl Encode for CustomStruct { + fn encode() -> Encoding { + let mut code = "{CustomStruct=".to_owned(); + for _ in 0..4 { + code.push_str(u64::encode().as_str()); + } + code.push_str("}"); + unsafe { + Encoding::from_str(&code) + } + } +} + +pub fn custom_class() -> &'static Class { + static REGISTER_CUSTOM_CLASS: Once = ONCE_INIT; + + REGISTER_CUSTOM_CLASS.call_once(|| { + // The runtime will call this method, so it has to be implemented + extern fn custom_obj_class_initialize(_this: &Class, _cmd: Sel) { } + + let mut decl = ClassDecl::root("CustomObject", custom_obj_class_initialize).unwrap(); + let proto = custom_protocol(); + + decl.add_protocol(proto); + decl.add_ivar::("_foo"); + + extern fn custom_obj_set_foo(this: &mut Object, _cmd: Sel, foo: u32) { + unsafe { this.set_ivar::("_foo", foo); } + } + + extern fn custom_obj_get_foo(this: &Object, _cmd: Sel) -> u32 { + unsafe { *this.get_ivar::("_foo") } + } + + extern fn custom_obj_get_struct(_this: &Object, _cmd: Sel) -> CustomStruct { + CustomStruct { a: 1, b: 2, c: 3, d: 4 } + } + + extern fn custom_obj_class_method(_this: &Class, _cmd: Sel) -> u32 { + 7 + } + + extern fn custom_obj_set_bar(this: &mut Object, _cmd: Sel, bar: u32) { + unsafe { this.set_ivar::("_foo", bar) ;} + } + + extern fn custom_obj_add_number_to_number(_this: &Class, _cmd: Sel, fst: i32, snd: i32) -> i32 { + fst + snd + } + + unsafe { + let set_foo: extern fn(&mut Object, Sel, u32) = custom_obj_set_foo; + decl.add_method(sel!(setFoo:), set_foo); + let get_foo: extern fn(&Object, Sel) -> u32 = custom_obj_get_foo; + decl.add_method(sel!(foo), get_foo); + let get_struct: extern fn(&Object, Sel) -> CustomStruct = custom_obj_get_struct; + decl.add_method(sel!(customStruct), get_struct); + let class_method: extern fn(&Class, Sel) -> u32 = custom_obj_class_method; + decl.add_class_method(sel!(classFoo), class_method); + + let protocol_instance_method: extern fn(&mut Object, Sel, u32) = custom_obj_set_bar; + decl.add_method(sel!(setBar:), protocol_instance_method); + let protocol_class_method: extern fn(&Class, Sel, i32, i32) -> i32 = custom_obj_add_number_to_number; + decl.add_class_method(sel!(addNumber:toNumber:), protocol_class_method); + } + + decl.register(); + }); + + class!(CustomObject) +} + +pub fn custom_protocol() -> &'static Protocol { + static REGISTER_CUSTOM_PROTOCOL: Once = ONCE_INIT; + + REGISTER_CUSTOM_PROTOCOL.call_once(|| { + let mut decl = ProtocolDecl::new("CustomProtocol").unwrap(); + + decl.add_method_description::<(i32,), ()>(sel!(setBar:), true); + decl.add_method_description::<(), *const c_char>(sel!(getName), false); + decl.add_class_method_description::<(i32, i32), i32>(sel!(addNumber:toNumber:), true); + + decl.register(); + }); + + Protocol::get("CustomProtocol").unwrap() +} + +pub fn custom_subprotocol() -> &'static Protocol { + static REGISTER_CUSTOM_SUBPROTOCOL: Once = ONCE_INIT; + + REGISTER_CUSTOM_SUBPROTOCOL.call_once(|| { + let super_proto = custom_protocol(); + let mut decl = ProtocolDecl::new("CustomSubProtocol").unwrap(); + + decl.add_protocol(super_proto); + decl.add_method_description::<(u32,), u32>(sel!(calculateFoo:), true); + + decl.register(); + }); + + Protocol::get("CustomSubProtocol").unwrap() +} + +pub fn custom_object() -> CustomObject { + CustomObject::new(custom_class()) +} + +pub fn custom_subclass() -> &'static Class { + static REGISTER_CUSTOM_SUBCLASS: Once = ONCE_INIT; + + REGISTER_CUSTOM_SUBCLASS.call_once(|| { + let superclass = custom_class(); + let mut decl = ClassDecl::new("CustomSubclassObject", superclass).unwrap(); + + extern fn custom_subclass_get_foo(this: &Object, _cmd: Sel) -> u32 { + let foo: u32 = unsafe { + msg_send![super(this, custom_class()), foo] + }; + foo + 2 + } + + unsafe { + let get_foo: extern fn(&Object, Sel) -> u32 = custom_subclass_get_foo; + decl.add_method(sel!(foo), get_foo); + } + + decl.register(); + }); + + class!(CustomSubclassObject) +} + +pub fn custom_subclass_object() -> CustomObject { + CustomObject::new(custom_subclass()) +} diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/.cargo-checksum.json b/third_party/cargo/vendor/objc-foundation-0.1.1/.cargo-checksum.json new file mode 100644 index 0000000..5d7a412 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"27c851b122617cfbf263603bcf05d637aaddbc87c12c2e78f8f91675739928a8","examples/custom_class.rs":"44fab02b2eb974cbfd35e649872044457fa50c61148a13b02a71395fe6e44f3f","examples/example.rs":"1f05e488809d0356b3658ac2bce12def26ac9518f4774dc599a216ddc719cd65","src/array.rs":"c3b7038821a5ecb10b043152cfc1ab0520ef5f923ea77b1e6a1c54ddf4586d96","src/data.rs":"9ae4e7fe1bd92a40edd700f364ce60a18467387d360459e04e6933e6b6d20cfc","src/dictionary.rs":"b42dcb6f280211ef674f9018559eb768138f4a6a382410706278f2bcff3164b9","src/enumerator.rs":"62f77fb4ccc7b9306c0d6564589d25234368d88b63d319e813622846fe0e5f47","src/lib.rs":"f6dd421ba10b1a0e57fa10609ce2819ae491f63c08ee4b78a6884dcc5e742389","src/macros.rs":"7c03375b7efa17b2a58f9c9821a61581b4b6eaa1e0185f2468e6d5ded57aef59","src/object.rs":"c6deba06b351936ed2264cdb56755685cdf0b92e37fcf4f6ba56e6021cd00384","src/string.rs":"aeffa50feb90c50e11979780a67ced5c7458f8d164d668d271c0aaafe64d8025","src/value.rs":"ee8168e2b45a3094b08a604e84e2d80c38454bb8ffbb859a24baf04725894be1"},"package":"1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"} \ No newline at end of file diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/BUILD b/third_party/cargo/vendor/objc-foundation-0.1.1/BUILD new file mode 100644 index 0000000..d2ba058 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "custom_class" with type "example" omitted +# Unsupported target "example" with type "example" omitted + +rust_library( + name = "objc_foundation", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/block-0.1.6:block", + "//third_party/cargo/vendor/objc-0.2.7:objc", + "//third_party/cargo/vendor/objc_id-0.1.1:objc_id", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/Cargo.toml b/third_party/cargo/vendor/objc-foundation-0.1.1/Cargo.toml new file mode 100644 index 0000000..82562fc --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "objc-foundation" +version = "0.1.1" +authors = ["Steven Sheldon"] + +description = "Rust wrapper for Objective-C's Foundation framework." +keywords = ["objective-c", "osx", "ios", "cocoa", "uikit"] +repository = "http://github.com/SSheldon/rust-objc-foundation" +documentation = "http://ssheldon.github.io/rust-objc/objc_foundation/" +license = "MIT" + +exclude = [".gitignore"] + +[dependencies] +block = "0.1" +objc = "0.2" +objc_id = "0.1" diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/examples/custom_class.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/examples/custom_class.rs new file mode 100644 index 0000000..793e0bf --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/examples/custom_class.rs @@ -0,0 +1,77 @@ +#[macro_use] +extern crate objc; +extern crate objc_foundation; + +use std::sync::{Once, ONCE_INIT}; + +use objc::Message; +use objc::declare::ClassDecl; +use objc::runtime::{Class, Object, Sel}; +use objc_foundation::{INSObject, NSObject}; + +pub enum MYObject { } + +impl MYObject { + fn number(&self) -> u32 { + unsafe { + let obj = &*(self as *const _ as *const Object); + *obj.get_ivar("_number") + } + } + + fn set_number(&mut self, number: u32) { + unsafe { + let obj = &mut *(self as *mut _ as *mut Object); + obj.set_ivar("_number", number); + } + } +} + +unsafe impl Message for MYObject { } + +static MYOBJECT_REGISTER_CLASS: Once = ONCE_INIT; + +impl INSObject for MYObject { + fn class() -> &'static Class { + MYOBJECT_REGISTER_CLASS.call_once(|| { + let superclass = NSObject::class(); + let mut decl = ClassDecl::new("MYObject", superclass).unwrap(); + decl.add_ivar::("_number"); + + // Add ObjC methods for getting and setting the number + extern fn my_object_set_number(this: &mut Object, _cmd: Sel, number: u32) { + unsafe { this.set_ivar("_number", number); } + } + + extern fn my_object_get_number(this: &Object, _cmd: Sel) -> u32 { + unsafe { *this.get_ivar("_number") } + } + + unsafe { + let set_number: extern fn(&mut Object, Sel, u32) = my_object_set_number; + decl.add_method(sel!(setNumber:), set_number); + let get_number: extern fn(&Object, Sel) -> u32 = my_object_get_number; + decl.add_method(sel!(number), get_number); + } + + decl.register(); + }); + + Class::get("MYObject").unwrap() + } +} + +fn main() { + let mut obj = MYObject::new(); + + obj.set_number(7); + println!("Number: {}", unsafe { + let number: u32 = msg_send![obj, number]; + number + }); + + unsafe { + let _: () = msg_send![obj, setNumber:12u32]; + } + println!("Number: {}", obj.number()); +} diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/examples/example.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/examples/example.rs new file mode 100644 index 0000000..5338487 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/examples/example.rs @@ -0,0 +1,38 @@ +extern crate objc_foundation; + +use objc_foundation::{NSArray, NSDictionary, NSObject, NSString, + INSArray, INSCopying, INSDictionary, INSObject, INSString}; + +fn main() { + // Create and compare NSObjects + let obj = NSObject::new(); + println!("{:?} == {:?}? {:?}", obj, obj, obj == obj); + + let obj2 = NSObject::new(); + println!("{:?} == {:?}? {:?}", obj, obj2, obj == obj2); + + // Create an NSArray from a Vec + let objs = vec![obj, obj2]; + let array = NSArray::from_vec(objs); + for obj in array.object_enumerator() { + println!("{:?}", obj); + } + println!("{}", array.count()); + + // Turn the NSArray back into a Vec + let mut objs = NSArray::into_vec(array); + let obj = objs.pop().unwrap(); + + // Create an NSString from a str slice + let string = NSString::from_str("Hello, world!"); + println!("{}", string.as_str()); + let string2 = string.copy(); + println!("{}", string2.as_str()); + + // Create a dictionary mapping strings to objects + let keys = &[&*string]; + let vals = vec![obj]; + let dict = NSDictionary::from_keys_and_objects(keys, vals); + println!("{:?}", dict.object_for(&string)); + println!("{}", dict.count()); +} diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/src/array.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/src/array.rs new file mode 100644 index 0000000..0bc04d4 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/src/array.rs @@ -0,0 +1,441 @@ +use std::cmp::Ordering; +use std::marker::PhantomData; +use std::ops::{Index, Range}; + +use objc::runtime::{Class, Object}; +use objc_id::{Id, Owned, Ownership, Shared, ShareId}; + +use {INSCopying, INSFastEnumeration, INSMutableCopying, INSObject, NSEnumerator}; + +#[repr(isize)] +#[derive(Clone, Copy)] +pub enum NSComparisonResult { + Ascending = -1, + Same = 0, + Descending = 1, +} + +impl NSComparisonResult { + pub fn from_ordering(order: Ordering) -> NSComparisonResult { + match order { + Ordering::Less => NSComparisonResult::Ascending, + Ordering::Equal => NSComparisonResult::Same, + Ordering::Greater => NSComparisonResult::Descending, + } + } + + pub fn as_ordering(&self) -> Ordering { + match *self { + NSComparisonResult::Ascending => Ordering::Less, + NSComparisonResult::Same => Ordering::Equal, + NSComparisonResult::Descending => Ordering::Greater, + } + } +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct NSRange { + pub location: usize, + pub length: usize, +} + +impl NSRange { + pub fn from_range(range: Range) -> NSRange { + assert!(range.end >= range.start); + NSRange { location: range.start, length: range.end - range.start } + } + + pub fn as_range(&self) -> Range { + Range { start: self.location, end: self.location + self.length } + } +} + +unsafe fn from_refs(refs: &[&A::Item]) -> Id where A: INSArray { + let cls = A::class(); + let obj: *mut A = msg_send![cls, alloc]; + let obj: *mut A = msg_send![obj, initWithObjects:refs.as_ptr() + count:refs.len()]; + Id::from_retained_ptr(obj) +} + +pub trait INSArray : INSObject { + type Item: INSObject; + type Own: Ownership; + + fn count(&self) -> usize { + unsafe { + msg_send![self, count] + } + } + + fn object_at(&self, index: usize) -> &Self::Item { + unsafe { + let obj: *const Self::Item = msg_send![self, objectAtIndex:index]; + &*obj + } + } + + fn first_object(&self) -> Option<&Self::Item> { + unsafe { + let obj: *const Self::Item = msg_send![self, firstObject]; + if obj.is_null() { None } else { Some(&*obj) } + } + } + + fn last_object(&self) -> Option<&Self::Item> { + unsafe { + let obj: *const Self::Item = msg_send![self, lastObject]; + if obj.is_null() { None } else { Some(&*obj) } + } + } + + fn object_enumerator(&self) -> NSEnumerator { + unsafe { + let result: *mut Object = msg_send![self, objectEnumerator]; + NSEnumerator::from_ptr(result) + } + } + + fn from_vec(vec: Vec>) -> Id { + let refs: Vec<&Self::Item> = vec.iter().map(|obj| &**obj).collect(); + unsafe { + from_refs(&refs) + } + } + + fn objects_in_range(&self, range: Range) -> Vec<&Self::Item> { + let range = NSRange::from_range(range); + let mut vec = Vec::with_capacity(range.length); + unsafe { + let _: () = msg_send![self, getObjects:vec.as_ptr() range:range]; + vec.set_len(range.length); + } + vec + } + + fn to_vec(&self) -> Vec<&Self::Item> { + self.objects_in_range(0..self.count()) + } + + fn into_vec(array: Id) -> Vec> { + array.to_vec().into_iter().map(|obj| unsafe { + let obj_ptr: *const Self::Item = obj; + Id::from_ptr(obj_ptr as *mut Self::Item) + }).collect() + } + + fn mut_object_at(&mut self, index: usize) -> &mut Self::Item + where Self: INSArray { + unsafe { + let result: *mut Self::Item = msg_send![self, objectAtIndex:index]; + &mut *result + } + } + + fn shared_object_at(&self, index: usize) -> ShareId + where Self: INSArray { + let obj = self.object_at(index); + unsafe { + Id::from_ptr(obj as *const _ as *mut Self::Item) + } + } + + fn from_slice(slice: &[ShareId]) -> Id + where Self: INSArray { + let refs: Vec<&Self::Item> = slice.iter().map(|obj| &**obj).collect(); + unsafe { + from_refs(&refs) + } + } + + fn to_shared_vec(&self) -> Vec> + where Self: INSArray { + self.to_vec().into_iter().map(|obj| unsafe { + let obj_ptr: *const Self::Item = obj; + Id::from_ptr(obj_ptr as *mut Self::Item) + }).collect() + } +} + +pub struct NSArray { + item: PhantomData>, +} + +object_impl!(NSArray); + +impl INSObject for NSArray where T: INSObject, O: Ownership { + fn class() -> &'static Class { + Class::get("NSArray").unwrap() + } +} + +impl INSArray for NSArray where T: INSObject, O: Ownership { + type Item = T; + type Own = O; +} + +impl INSCopying for NSArray where T: INSObject { + type Output = NSSharedArray; +} + +impl INSMutableCopying for NSArray where T: INSObject { + type Output = NSMutableSharedArray; +} + +impl INSFastEnumeration for NSArray + where T: INSObject, O: Ownership { + type Item = T; +} + +impl Index for NSArray where T: INSObject, O: Ownership { + type Output = T; + + fn index(&self, index: usize) -> &T { + self.object_at(index) + } +} + +pub type NSSharedArray = NSArray; + +pub trait INSMutableArray : INSArray { + fn add_object(&mut self, obj: Id) { + unsafe { + let _: () = msg_send![self, addObject:&*obj]; + } + } + + fn insert_object_at(&mut self, index: usize, obj: Id) { + unsafe { + let _: () = msg_send![self, insertObject:&*obj atIndex:index]; + } + } + + fn replace_object_at(&mut self, index: usize, obj: Id) -> + Id { + let old_obj = unsafe { + let obj = self.object_at(index); + Id::from_ptr(obj as *const _ as *mut Self::Item) + }; + unsafe { + let _: () = msg_send![self, replaceObjectAtIndex:index + withObject:&*obj]; + } + old_obj + } + + fn remove_object_at(&mut self, index: usize) -> Id { + let obj = unsafe { + let obj = self.object_at(index); + Id::from_ptr(obj as *const _ as *mut Self::Item) + }; + unsafe { + let _: () = msg_send![self, removeObjectAtIndex:index]; + } + obj + } + + fn remove_last_object(&mut self) -> Id { + let obj = self.last_object().map(|obj| unsafe { + Id::from_ptr(obj as *const _ as *mut Self::Item) + }); + unsafe { + let _: () = msg_send![self, removeLastObject]; + } + // removeLastObject would have failed if the array is empty, + // so we know this won't be None + obj.unwrap() + } + + fn remove_all_objects(&mut self) { + unsafe { + let _: () = msg_send![self, removeAllObjects]; + } + } + + fn sort_by(&mut self, compare: F) + where F: FnMut(&Self::Item, &Self::Item) -> Ordering { + extern fn compare_with_closure(obj1: &T, obj2: &T, + compare: &mut F) -> NSComparisonResult + where F: FnMut(&T, &T) -> Ordering { + NSComparisonResult::from_ordering((*compare)(obj1, obj2)) + } + + let f: extern fn(&Self::Item, &Self::Item, &mut F) -> NSComparisonResult = + compare_with_closure; + let mut closure = compare; + unsafe { + let _: () = msg_send![self, sortUsingFunction:f + context:&mut closure]; + } + } +} + +pub struct NSMutableArray { + item: PhantomData>, +} + +object_impl!(NSMutableArray); + +impl INSObject for NSMutableArray where T: INSObject, O: Ownership { + fn class() -> &'static Class { + Class::get("NSMutableArray").unwrap() + } +} + +impl INSArray for NSMutableArray where T: INSObject, O: Ownership { + type Item = T; + type Own = O; +} + +impl INSMutableArray for NSMutableArray + where T: INSObject, O: Ownership { } + +impl INSCopying for NSMutableArray where T: INSObject { + type Output = NSSharedArray; +} + +impl INSMutableCopying for NSMutableArray where T: INSObject { + type Output = NSMutableSharedArray; +} + +impl INSFastEnumeration for NSMutableArray + where T: INSObject, O: Ownership { + type Item = T; +} + +impl Index for NSMutableArray + where T: INSObject, O: Ownership { + type Output = T; + + fn index(&self, index: usize) -> &T { + self.object_at(index) + } +} + +pub type NSMutableSharedArray = NSMutableArray; + +#[cfg(test)] +mod tests { + use objc_id::Id; + use {INSObject, INSString, NSObject, NSString}; + use super::{INSArray, INSMutableArray, NSArray, NSMutableArray}; + + fn sample_array(len: usize) -> Id> { + let mut vec = Vec::with_capacity(len); + for _ in 0..len { + vec.push(NSObject::new()); + } + NSArray::from_vec(vec) + } + + #[test] + fn test_count() { + let empty_array = NSArray::::new(); + assert!(empty_array.count() == 0); + + let array = sample_array(4); + assert!(array.count() == 4); + } + + #[test] + fn test_object_at() { + let array = sample_array(4); + assert!(array.object_at(0) != array.object_at(3)); + assert!(array.first_object().unwrap() == array.object_at(0)); + assert!(array.last_object().unwrap() == array.object_at(3)); + + let empty_array: Id> = INSObject::new(); + assert!(empty_array.first_object().is_none()); + assert!(empty_array.last_object().is_none()); + } + + #[test] + fn test_object_enumerator() { + let array = sample_array(4); + + assert!(array.object_enumerator().count() == 4); + assert!(array.object_enumerator() + .enumerate() + .all(|(i, obj)| obj == array.object_at(i))); + } + + #[test] + fn test_objects_in_range() { + let array = sample_array(4); + + let middle_objs = array.objects_in_range(1..3); + assert!(middle_objs.len() == 2); + assert!(middle_objs[0] == array.object_at(1)); + assert!(middle_objs[1] == array.object_at(2)); + + let empty_objs = array.objects_in_range(1..1); + assert!(empty_objs.len() == 0); + + let all_objs = array.objects_in_range(0..4); + assert!(all_objs.len() == 4); + } + + #[test] + fn test_into_vec() { + let array = sample_array(4); + + let vec = INSArray::into_vec(array); + assert!(vec.len() == 4); + } + + #[test] + fn test_add_object() { + let mut array = NSMutableArray::new(); + let obj = NSObject::new(); + array.add_object(obj); + + assert!(array.count() == 1); + assert!(array.object_at(0) == array.object_at(0)); + + let obj = NSObject::new(); + array.insert_object_at(0, obj); + assert!(array.count() == 2); + } + + #[test] + fn test_replace_object() { + let mut array = NSMutableArray::new(); + let obj = NSObject::new(); + array.add_object(obj); + + let obj = NSObject::new(); + let old_obj = array.replace_object_at(0, obj); + assert!(&*old_obj != array.object_at(0)); + } + + #[test] + fn test_remove_object() { + let mut array = NSMutableArray::new(); + for _ in 0..4 { + array.add_object(NSObject::new()); + } + + array.remove_object_at(1); + assert!(array.count() == 3); + + array.remove_last_object(); + assert!(array.count() == 2); + + array.remove_all_objects(); + assert!(array.count() == 0); + } + + #[test] + fn test_sort() { + let strings = vec![ + NSString::from_str("hello"), + NSString::from_str("hi"), + ]; + let mut strings = NSMutableArray::from_vec(strings); + + strings.sort_by(|s1, s2| s1.as_str().len().cmp(&s2.as_str().len())); + assert!(strings[0].as_str() == "hi"); + assert!(strings[1].as_str() == "hello"); + } +} diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/src/data.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/src/data.rs new file mode 100644 index 0000000..f49aa95 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/src/data.rs @@ -0,0 +1,200 @@ +use std::mem; +use std::ops::Range; +use std::os::raw::c_void; +use std::slice; + +use objc_id::Id; +use block::{Block, ConcreteBlock}; +use {INSObject, INSCopying, INSMutableCopying, NSRange}; + +pub trait INSData : INSObject { + fn len(&self) -> usize { + unsafe { + msg_send![self, length] + } + } + + fn bytes(&self) -> &[u8] { + let ptr: *const c_void = unsafe { msg_send![self, bytes] }; + // The bytes pointer may be null for length zero + let (ptr, len) = if ptr.is_null() { + (0x1 as *const u8, 0) + } else { + (ptr as *const u8, self.len()) + }; + unsafe { + slice::from_raw_parts(ptr, len) + } + } + + fn with_bytes(bytes: &[u8]) -> Id { + let cls = Self::class(); + unsafe { + let obj: *mut Self = msg_send![cls, alloc]; + let obj: *mut Self = msg_send![obj, initWithBytes:bytes.as_ptr() + length:bytes.len()]; + Id::from_retained_ptr(obj) + } + } + + fn from_vec(bytes: Vec) -> Id { + let capacity = bytes.capacity(); + let dealloc = ConcreteBlock::new(move |bytes: *mut c_void, len: usize| unsafe { + // Recreate the Vec and let it drop + let _ = Vec::from_raw_parts(bytes as *mut u8, len, capacity); + }); + let dealloc = dealloc.copy(); + let dealloc: &Block<(*mut c_void, usize), ()> = &dealloc; + + let mut bytes = bytes; + let cls = Self::class(); + unsafe { + let obj: *mut Self = msg_send![cls, alloc]; + let obj: *mut Self = msg_send![obj, initWithBytesNoCopy:bytes.as_mut_ptr() + length:bytes.len() + deallocator:dealloc]; + mem::forget(bytes); + Id::from_retained_ptr(obj) + } + } +} + +object_struct!(NSData); + +impl INSData for NSData { } + +impl INSCopying for NSData { + type Output = NSData; +} + +impl INSMutableCopying for NSData { + type Output = NSMutableData; +} + +pub trait INSMutableData : INSData { + fn bytes_mut(&mut self) -> &mut [u8] { + let ptr: *mut c_void = unsafe { msg_send![self, mutableBytes] }; + // The bytes pointer may be null for length zero + let (ptr, len) = if ptr.is_null() { + (0x1 as *mut u8, 0) + } else { + (ptr as *mut u8, self.len()) + }; + unsafe { + slice::from_raw_parts_mut(ptr, len) + } + } + + fn set_len(&mut self, len: usize) { + unsafe { + let _: () = msg_send![self, setLength:len]; + } + } + + fn append(&mut self, bytes: &[u8]) { + unsafe { + let _: () = msg_send![self, appendBytes:bytes.as_ptr() + length:bytes.len()]; + } + } + + fn replace_range(&mut self, range: Range, bytes: &[u8]) { + let range = NSRange::from_range(range); + unsafe { + let _: () = msg_send![self, replaceBytesInRange:range + withBytes:bytes.as_ptr() + length:bytes.len()]; + } + } + + fn set_bytes(&mut self, bytes: &[u8]) { + let len = self.len(); + self.replace_range(0..len, bytes); + } +} + +object_struct!(NSMutableData); + +impl INSData for NSMutableData { } + +impl INSMutableData for NSMutableData { } + +impl INSCopying for NSMutableData { + type Output = NSData; +} + +impl INSMutableCopying for NSMutableData { + type Output = NSMutableData; +} + +#[cfg(test)] +mod tests { + use INSObject; + use super::{INSData, INSMutableData, NSData, NSMutableData}; + + #[test] + fn test_bytes() { + let bytes = [3, 7, 16, 52, 112, 19]; + let data = NSData::with_bytes(&bytes); + assert!(data.len() == bytes.len()); + assert!(data.bytes() == bytes); + } + + #[test] + fn test_no_bytes() { + let data = NSData::new(); + assert!(Some(data.bytes()).is_some()); + } + + #[test] + fn test_bytes_mut() { + let mut data = NSMutableData::with_bytes(&[7, 16]); + data.bytes_mut()[0] = 3; + assert!(data.bytes() == [3, 16]); + } + + #[test] + fn test_set_len() { + let mut data = NSMutableData::with_bytes(&[7, 16]); + data.set_len(4); + assert!(data.len() == 4); + assert!(data.bytes() == [7, 16, 0, 0]); + + data.set_len(1); + assert!(data.len() == 1); + assert!(data.bytes() == [7]); + } + + #[test] + fn test_append() { + let mut data = NSMutableData::with_bytes(&[7, 16]); + data.append(&[3, 52]); + assert!(data.len() == 4); + assert!(data.bytes() == [7, 16, 3, 52]); + } + + #[test] + fn test_replace() { + let mut data = NSMutableData::with_bytes(&[7, 16]); + data.replace_range(0..0, &[3]); + assert!(data.bytes() == [3, 7, 16]); + + data.replace_range(1..2, &[52, 13]); + assert!(data.bytes() == [3, 52, 13, 16]); + + data.replace_range(2..4, &[6]); + assert!(data.bytes() == [3, 52, 6]); + + data.set_bytes(&[8, 17]); + assert!(data.bytes() == [8, 17]); + } + + #[test] + fn test_from_vec() { + let bytes = vec![3, 7, 16]; + let bytes_ptr = bytes.as_ptr(); + + let data = NSData::from_vec(bytes); + assert!(data.bytes().as_ptr() == bytes_ptr); + } +} diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/src/dictionary.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/src/dictionary.rs new file mode 100644 index 0000000..ea561a6 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/src/dictionary.rs @@ -0,0 +1,230 @@ +use std::cmp::min; +use std::marker::PhantomData; +use std::ops::Index; +use std::ptr; + +use objc::runtime::Class; +use objc_id::{Id, Owned, Ownership, ShareId}; + +use { + INSArray, INSFastEnumeration, INSCopying, INSObject, + NSArray, NSSharedArray, NSEnumerator, +}; + +unsafe fn from_refs(keys: &[&T], vals: &[&D::Value]) -> Id + where D: INSDictionary, T: INSCopying { + let cls = D::class(); + let count = min(keys.len(), vals.len()); + let obj: *mut D = msg_send![cls, alloc]; + let obj: *mut D = msg_send![obj, initWithObjects:vals.as_ptr() + forKeys:keys.as_ptr() + count:count]; + Id::from_retained_ptr(obj) +} + +pub trait INSDictionary : INSObject { + type Key: INSObject; + type Value: INSObject; + type Own: Ownership; + + fn count(&self) -> usize { + unsafe { + msg_send![self, count] + } + } + + fn object_for(&self, key: &Self::Key) -> Option<&Self::Value> { + unsafe { + let obj: *mut Self::Value = msg_send![self, objectForKey:key]; + if obj.is_null() { None } else { Some(&*obj) } + } + } + + fn keys(&self) -> Vec<&Self::Key> { + let len = self.count(); + let mut keys = Vec::with_capacity(len); + unsafe { + let _: () = msg_send![self, getObjects:ptr::null_mut::() + andKeys:keys.as_mut_ptr()]; + keys.set_len(len); + } + keys + } + + fn values(&self) -> Vec<&Self::Value> { + let len = self.count(); + let mut vals = Vec::with_capacity(len); + unsafe { + let _: () = msg_send![self, getObjects:vals.as_mut_ptr() + andKeys:ptr::null_mut::()]; + vals.set_len(len); + } + vals + } + + fn keys_and_objects(&self) -> (Vec<&Self::Key>, Vec<&Self::Value>) { + let len = self.count(); + let mut keys = Vec::with_capacity(len); + let mut objs = Vec::with_capacity(len); + unsafe { + let _: () = msg_send![self, getObjects:objs.as_mut_ptr() + andKeys:keys.as_mut_ptr()]; + keys.set_len(len); + objs.set_len(len); + } + (keys, objs) + } + + fn key_enumerator(&self) -> NSEnumerator { + unsafe { + let result = msg_send![self, keyEnumerator]; + NSEnumerator::from_ptr(result) + } + } + + fn object_enumerator(&self) -> NSEnumerator { + unsafe { + let result = msg_send![self, objectEnumerator]; + NSEnumerator::from_ptr(result) + } + } + + fn keys_array(&self) -> Id> { + unsafe { + let keys: *mut NSSharedArray = msg_send![self, allKeys]; + Id::from_ptr(keys) + } + } + + fn from_keys_and_objects(keys: &[&T], + vals: Vec>) -> Id + where T: INSCopying { + let vals_refs: Vec<&Self::Value> = vals.iter().map(|obj| &**obj).collect(); + unsafe { + from_refs(keys, &vals_refs) + } + } + + fn into_values_array(dict: Id) -> Id> { + unsafe { + let vals = msg_send![dict, allValues]; + Id::from_ptr(vals) + } + } +} + +pub struct NSDictionary { + key: PhantomData>, + obj: PhantomData>, +} + +object_impl!(NSDictionary); + +impl INSObject for NSDictionary where K: INSObject, V: INSObject { + fn class() -> &'static Class { + Class::get("NSDictionary").unwrap() + } +} + +impl INSDictionary for NSDictionary + where K: INSObject, V: INSObject { + type Key = K; + type Value = V; + type Own = Owned; +} + +impl INSFastEnumeration for NSDictionary + where K: INSObject, V: INSObject { + type Item = K; +} + +impl<'a, K, V> Index<&'a K> for NSDictionary where K: INSObject, V: INSObject { + type Output = V; + + fn index(&self, index: &K) -> &V { + self.object_for(index).unwrap() + } +} + +#[cfg(test)] +mod tests { + use objc_id::Id; + use {INSArray, INSObject, INSString, NSObject, NSString}; + use super::{INSDictionary, NSDictionary}; + + fn sample_dict(key: &str) -> Id> { + let string = NSString::from_str(key); + let obj = NSObject::new(); + NSDictionary::from_keys_and_objects(&[&*string], vec![obj]) + } + + #[test] + fn test_count() { + let dict = sample_dict("abcd"); + assert!(dict.count() == 1); + } + + #[test] + fn test_object_for() { + let dict = sample_dict("abcd"); + + let string = NSString::from_str("abcd"); + assert!(dict.object_for(&string).is_some()); + + let string = NSString::from_str("abcde"); + assert!(dict.object_for(&string).is_none()); + } + + #[test] + fn test_keys() { + let dict = sample_dict("abcd"); + let keys = dict.keys(); + + assert!(keys.len() == 1); + assert!(keys[0].as_str() == "abcd"); + } + + #[test] + fn test_values() { + let dict = sample_dict("abcd"); + let vals = dict.values(); + + assert!(vals.len() == 1); + } + + #[test] + fn test_keys_and_objects() { + let dict = sample_dict("abcd"); + let (keys, objs) = dict.keys_and_objects(); + + assert!(keys.len() == 1); + assert!(objs.len() == 1); + assert!(keys[0].as_str() == "abcd"); + assert!(objs[0] == dict.object_for(keys[0]).unwrap()); + } + + #[test] + fn test_key_enumerator() { + let dict = sample_dict("abcd"); + assert!(dict.key_enumerator().count() == 1); + assert!(dict.key_enumerator().next().unwrap().as_str() == "abcd"); + } + + #[test] + fn test_object_enumerator() { + let dict = sample_dict("abcd"); + assert!(dict.object_enumerator().count() == 1); + } + + #[test] + fn test_arrays() { + let dict = sample_dict("abcd"); + + let keys = dict.keys_array(); + assert!(keys.count() == 1); + assert!(keys.object_at(0).as_str() == "abcd"); + + let objs = INSDictionary::into_values_array(dict); + assert!(objs.count() == 1); + } +} diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/src/enumerator.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/src/enumerator.rs new file mode 100644 index 0000000..9f2c081 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/src/enumerator.rs @@ -0,0 +1,166 @@ +use std::marker::PhantomData; +use std::mem; +use std::os::raw::c_ulong; +use std::ptr; +use std::slice; + +use objc::runtime::Object; +use objc_id::Id; + +use INSObject; + +pub struct NSEnumerator<'a, T> where T: INSObject { + id: Id, + item: PhantomData<&'a T>, +} + +impl<'a, T> NSEnumerator<'a, T> where T: INSObject { + pub unsafe fn from_ptr(ptr: *mut Object) -> NSEnumerator<'a, T> { + NSEnumerator { id: Id::from_ptr(ptr), item: PhantomData } + } +} + +impl<'a, T> Iterator for NSEnumerator<'a, T> where T: INSObject { + type Item = &'a T; + + fn next(&mut self) -> Option<&'a T> { + unsafe { + let obj: *mut T = msg_send![self.id, nextObject]; + if obj.is_null() { None } else { Some(&*obj) } + } + } +} + +pub trait INSFastEnumeration: INSObject { + type Item: INSObject; + + fn enumerator(&self) -> NSFastEnumerator { + NSFastEnumerator::new(self) + } +} + +#[repr(C)] +struct NSFastEnumerationState { + state: c_ulong, + items_ptr: *const *const T, + mutations_ptr: *mut c_ulong, + extra: [c_ulong; 5], +} + +fn enumerate<'a, 'b: 'a, C: INSFastEnumeration>(object: &'b C, + state: &mut NSFastEnumerationState, + buf: &'a mut [*const C::Item]) -> Option<&'a [*const C::Item]> { + let count: usize = unsafe { + // Reborrow state so that we don't move it + let state = &mut *state; + msg_send![object, countByEnumeratingWithState:state + objects:buf.as_mut_ptr() + count:buf.len()] + }; + + if count > 0 { + unsafe { Some(slice::from_raw_parts(state.items_ptr, count)) } + } else { + None + } +} + +const FAST_ENUM_BUF_SIZE: usize = 16; + +pub struct NSFastEnumerator<'a, C: 'a + INSFastEnumeration> { + object: &'a C, + + ptr: *const *const C::Item, + end: *const *const C::Item, + + state: NSFastEnumerationState, + buf: [*const C::Item; FAST_ENUM_BUF_SIZE], +} + +impl<'a, C: INSFastEnumeration> NSFastEnumerator<'a, C> { + fn new(object: &C) -> NSFastEnumerator { + NSFastEnumerator { + object: object, + + ptr: ptr::null(), + end: ptr::null(), + + state: unsafe { mem::zeroed() }, + buf: [ptr::null(); FAST_ENUM_BUF_SIZE], + } + } + + fn update_buf(&mut self) -> bool { + // If this isn't our first time enumerating, record the previous value + // from the mutations pointer. + let mutations = if !self.ptr.is_null() { + Some(unsafe { *self.state.mutations_ptr }) + } else { + None + }; + + let next_buf = enumerate(self.object, &mut self.state, &mut self.buf); + if let Some(buf) = next_buf { + // Check if the collection was mutated + if let Some(mutations) = mutations { + assert!(mutations == unsafe { *self.state.mutations_ptr }, + "Mutation detected during enumeration of object {:p}", + self.object); + } + + self.ptr = buf.as_ptr(); + self.end = unsafe { self.ptr.offset(buf.len() as isize) }; + true + } else { + self.ptr = ptr::null(); + self.end = ptr::null(); + false + } + } +} + +impl<'a, C: INSFastEnumeration> Iterator for NSFastEnumerator<'a, C> { + type Item = &'a C::Item; + + fn next(&mut self) -> Option<&'a C::Item> { + if self.ptr == self.end && !self.update_buf() { + None + } else { + unsafe { + let obj = *self.ptr; + self.ptr = self.ptr.offset(1); + Some(&*obj) + } + } + } +} + +#[cfg(test)] +mod tests { + use {INSArray, INSValue, NSArray, NSValue}; + use super::INSFastEnumeration; + + #[test] + fn test_enumerator() { + let vec = (0u32..4).map(NSValue::from_value).collect(); + let array = NSArray::from_vec(vec); + + let enumerator = array.object_enumerator(); + assert!(enumerator.count() == 4); + + let enumerator = array.object_enumerator(); + assert!(enumerator.enumerate().all(|(i, obj)| obj.value() == i as u32)); + } + + #[test] + fn test_fast_enumerator() { + let vec = (0u32..4).map(NSValue::from_value).collect(); + let array = NSArray::from_vec(vec); + + let enumerator = array.enumerator(); + assert!(enumerator.count() == 4); + + let enumerator = array.enumerator(); + assert!(enumerator.enumerate().all(|(i, obj)| obj.value() == i as u32)); + } +} diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/src/lib.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/src/lib.rs new file mode 100644 index 0000000..65bbd01 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/src/lib.rs @@ -0,0 +1,33 @@ +#![crate_name = "objc_foundation"] +#![crate_type = "lib"] + +#[macro_use] +extern crate objc; +extern crate objc_id; +extern crate block; + +pub use self::array::{ + INSArray, INSMutableArray, + NSArray, NSComparisonResult, NSMutableArray, NSRange, + NSMutableSharedArray, NSSharedArray, +}; +pub use self::data::{INSData, INSMutableData, NSData, NSMutableData}; +pub use self::dictionary::{INSDictionary, NSDictionary}; +pub use self::enumerator::{INSFastEnumeration, NSEnumerator, NSFastEnumerator}; +pub use self::object::{INSObject, NSObject}; +pub use self::string::{INSCopying, INSMutableCopying, INSString, NSString}; +pub use self::value::{INSValue, NSValue}; + +#[link(name = "Foundation", kind = "framework")] +extern { } + +#[macro_use] +mod macros; + +mod array; +mod data; +mod dictionary; +mod enumerator; +mod object; +mod string; +mod value; diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/src/macros.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/src/macros.rs new file mode 100644 index 0000000..cf06f2e --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/src/macros.rs @@ -0,0 +1,55 @@ +#[macro_export] +macro_rules! object_struct { + ($name:ident) => ( + pub struct $name { + _private: (), + } + + unsafe impl ::objc::Message for $name { } + + impl $crate::INSObject for $name { + fn class() -> &'static ::objc::runtime::Class { + let name = stringify!($name); + match ::objc::runtime::Class::get(name) { + Some(cls) => cls, + None => panic!("Class {} not found", name), + } + } + } + + impl ::std::cmp::PartialEq for $name { + fn eq(&self, other: &Self) -> bool { + use $crate::INSObject; + self.is_equal(other) + } + } + + impl ::std::cmp::Eq for $name { } + + impl ::std::hash::Hash for $name { + fn hash(&self, state: &mut H) where H: ::std::hash::Hasher { + use $crate::INSObject; + self.hash_code().hash(state); + } + } + + impl ::std::fmt::Debug for $name { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + use $crate::{INSObject, INSString}; + ::std::fmt::Debug::fmt(self.description().as_str(), f) + } + } + ); +} + +macro_rules! object_impl { + ($name:ident) => ( + object_impl!($name,); + ); + ($name:ident<$($t:ident),+>) => ( + object_impl!($name, $($t),+); + ); + ($name:ident, $($t:ident),*) => ( + unsafe impl<$($t),*> ::objc::Message for $name<$($t),*> { } + ); +} diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/src/object.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/src/object.rs new file mode 100644 index 0000000..2f11626 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/src/object.rs @@ -0,0 +1,91 @@ +use std::any::Any; + +use objc::Message; +use objc::runtime::{BOOL, Class, NO}; +use objc_id::{Id, ShareId}; + +use NSString; + +/* + The Sized bound is unfortunate; ideally, objc objects would not be + treated as Sized. However, rust won't allow casting a dynamically-sized type + pointer to an Object pointer, because dynamically-sized types can have fat + pointers (two words) instead of real pointers. + */ +pub trait INSObject : Any + Sized + Message { + fn class() -> &'static Class; + + fn hash_code(&self) -> usize { + unsafe { + msg_send![self, hash] + } + } + + fn is_equal(&self, other: &T) -> bool where T: INSObject { + let result: BOOL = unsafe { + msg_send![self, isEqual:other] + }; + result != NO + } + + fn description(&self) -> ShareId { + unsafe { + let result: *mut NSString = msg_send![self, description]; + Id::from_ptr(result) + } + } + + fn is_kind_of(&self, cls: &Class) -> bool { + let result: BOOL = unsafe { + msg_send![self, isKindOfClass:cls] + }; + result != NO + } + + fn new() -> Id { + let cls = Self::class(); + unsafe { + let obj: *mut Self = msg_send![cls, alloc]; + let obj: *mut Self = msg_send![obj, init]; + Id::from_retained_ptr(obj) + } + } +} + +object_struct!(NSObject); + +#[cfg(test)] +mod tests { + use {INSString, NSString}; + use super::{INSObject, NSObject}; + + #[test] + fn test_is_equal() { + let obj1 = NSObject::new(); + assert!(obj1.is_equal(&*obj1)); + + let obj2 = NSObject::new(); + assert!(!obj1.is_equal(&*obj2)); + } + + #[test] + fn test_hash_code() { + let obj = NSObject::new(); + assert!(obj.hash_code() == obj.hash_code()); + } + + #[test] + fn test_description() { + let obj = NSObject::new(); + let description = obj.description(); + let expected = format!("", &*obj); + assert!(description.as_str() == &*expected); + } + + #[test] + fn test_is_kind_of() { + let obj = NSObject::new(); + assert!(obj.is_kind_of(NSObject::class())); + assert!(!obj.is_kind_of(NSString::class())); + } +} diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/src/string.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/src/string.rs new file mode 100644 index 0000000..2d21550 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/src/string.rs @@ -0,0 +1,98 @@ +use std::os::raw::c_char; +use std::slice; +use std::str; + +use objc_id::{Id, ShareId}; + +use INSObject; + +pub trait INSCopying : INSObject { + type Output: INSObject; + + fn copy(&self) -> ShareId { + unsafe { + let obj: *mut Self::Output = msg_send![self, copy]; + Id::from_retained_ptr(obj) + } + } +} + +pub trait INSMutableCopying : INSObject { + type Output: INSObject; + + fn mutable_copy(&self) -> Id { + unsafe { + let obj: *mut Self::Output = msg_send![self, mutableCopy]; + Id::from_retained_ptr(obj) + } + } +} + +const UTF8_ENCODING: usize = 4; + +pub trait INSString : INSObject { + fn len(&self) -> usize { + unsafe { + msg_send![self, lengthOfBytesUsingEncoding:UTF8_ENCODING] + } + } + + fn as_str(&self) -> &str { + let bytes = unsafe { + let bytes: *const c_char = msg_send![self, UTF8String]; + bytes as *const u8 + }; + let len = self.len(); + unsafe { + let bytes = slice::from_raw_parts(bytes, len); + str::from_utf8(bytes).unwrap() + } + } + + fn from_str(string: &str) -> Id { + let cls = Self::class(); + unsafe { + let obj: *mut Self = msg_send![cls, alloc]; + let obj: *mut Self = msg_send![obj, initWithBytes:string.as_ptr() + length:string.len() + encoding:UTF8_ENCODING]; + Id::from_retained_ptr(obj) + } + } +} + +object_struct!(NSString); + +impl INSString for NSString { } + +impl INSCopying for NSString { + type Output = NSString; +} + +#[cfg(test)] +mod tests { + use super::{INSCopying, INSString, NSString}; + + #[test] + fn test_utf8() { + let expected = "ประเทศไทย中华Việt Nam"; + let s = NSString::from_str(expected); + assert!(s.len() == expected.len()); + assert!(s.as_str() == expected); + } + + #[test] + fn test_interior_nul() { + let expected = "Hello\0World"; + let s = NSString::from_str(expected); + assert!(s.len() == expected.len()); + assert!(s.as_str() == expected); + } + + #[test] + fn test_copy() { + let s = NSString::from_str("Hello!"); + let copied = s.copy(); + assert!(copied.as_str() == s.as_str()); + } +} diff --git a/third_party/cargo/vendor/objc-foundation-0.1.1/src/value.rs b/third_party/cargo/vendor/objc-foundation-0.1.1/src/value.rs new file mode 100644 index 0000000..405afe1 --- /dev/null +++ b/third_party/cargo/vendor/objc-foundation-0.1.1/src/value.rs @@ -0,0 +1,78 @@ +use std::any::Any; +use std::ffi::{CStr, CString}; +use std::marker::PhantomData; +use std::mem; +use std::os::raw::c_char; +use std::str; + +use objc::{Encode, Encoding}; +use objc::runtime::Class; +use objc_id::Id; + +use {INSCopying, INSObject}; + +pub trait INSValue : INSObject { + type Value: 'static + Copy + Encode; + + fn value(&self) -> Self::Value { + assert!(Self::Value::encode() == self.encoding()); + unsafe { + let mut value = mem::uninitialized::(); + let _: () = msg_send![self, getValue:&mut value]; + value + } + } + + fn encoding(&self) -> Encoding { + unsafe { + let result: *const c_char = msg_send![self, objCType]; + let s = CStr::from_ptr(result); + let s = str::from_utf8(s.to_bytes()).unwrap(); + Encoding::from_str(s) + } + } + + fn from_value(value: Self::Value) -> Id { + let cls = Self::class(); + let encoding = CString::new(Self::Value::encode().as_str()).unwrap(); + unsafe { + let obj: *mut Self = msg_send![cls, alloc]; + let obj: *mut Self = msg_send![obj, initWithBytes:&value + objCType:encoding.as_ptr()]; + Id::from_retained_ptr(obj) + } + } +} + +pub struct NSValue { + value: PhantomData, +} + +object_impl!(NSValue); + +impl INSObject for NSValue where T: Any { + fn class() -> &'static Class { + Class::get("NSValue").unwrap() + } +} + +impl INSValue for NSValue where T: Any + Copy + Encode { + type Value = T; +} + +impl INSCopying for NSValue where T: Any { + type Output = NSValue; +} + +#[cfg(test)] +mod tests { + use objc::Encode; + use {INSValue, NSValue}; + + #[test] + fn test_value() { + let val = NSValue::from_value(13u32); + assert!(val.value() == 13); + assert!(u32::encode() == val.encoding()); + } +} diff --git a/third_party/cargo/vendor/objc_exception-0.1.2/.cargo-checksum.json b/third_party/cargo/vendor/objc_exception-0.1.2/.cargo-checksum.json new file mode 100644 index 0000000..ac8ccd3 --- /dev/null +++ b/third_party/cargo/vendor/objc_exception-0.1.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"4c7727c5464280a94b263b3fbabd775838ce86794834b1adab9bfeefc8a2b731","build.rs":"6734724a6f3c46150f5a6a2adf07b9003ae6f1627fa0ee8fcafa28e9d4aafc15","extern/exception.m":"a6ee21d820126e98ee49ac34db1a6770cfd01f0fb0f71d03127e7eeff91a47c5","src/lib.rs":"24f3b04002dbf24397cc4fd2da7045d49c8b3a06101bab1918d007f7ae9b2207"},"package":"ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4"} \ No newline at end of file diff --git a/third_party/cargo/vendor/objc_exception-0.1.2/BUILD b/third_party/cargo/vendor/objc_exception-0.1.2/BUILD new file mode 100644 index 0000000..aad9b79 --- /dev/null +++ b/third_party/cargo/vendor/objc_exception-0.1.2/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "objc_exception", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.2", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/objc_exception-0.1.2/Cargo.toml b/third_party/cargo/vendor/objc_exception-0.1.2/Cargo.toml new file mode 100644 index 0000000..7cdfacb --- /dev/null +++ b/third_party/cargo/vendor/objc_exception-0.1.2/Cargo.toml @@ -0,0 +1,25 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "objc_exception" +version = "0.1.2" +authors = ["Steven Sheldon"] +build = "build.rs" +exclude = [".gitignore"] +description = "Rust interface for Objective-C's throw and try/catch statements." +documentation = "http://ssheldon.github.io/rust-objc/objc_exception/" +keywords = ["objective-c", "osx", "ios"] +license = "MIT" +repository = "http://github.com/SSheldon/rust-objc-exception" +[build-dependencies.cc] +version = "1" diff --git a/third_party/cargo/vendor/objc_exception-0.1.2/build.rs b/third_party/cargo/vendor/objc_exception-0.1.2/build.rs new file mode 100644 index 0000000..ba728b6 --- /dev/null +++ b/third_party/cargo/vendor/objc_exception-0.1.2/build.rs @@ -0,0 +1,7 @@ +extern crate cc; + +fn main() { + cc::Build::new() + .file("extern/exception.m") + .compile("libexception.a"); +} diff --git a/third_party/cargo/vendor/objc_exception-0.1.2/extern/exception.m b/third_party/cargo/vendor/objc_exception-0.1.2/extern/exception.m new file mode 100644 index 0000000..700439e --- /dev/null +++ b/third_party/cargo/vendor/objc_exception-0.1.2/extern/exception.m @@ -0,0 +1,21 @@ +#include +#include + +void RustObjCExceptionThrow(id exception) { + @throw exception; +} + +int RustObjCExceptionTryCatch(void (*try)(void *), void *context, id *error) { + @try { + try(context); + if (error) { + *error = nil; + } + return 0; + } @catch (id exception) { + if (error) { + *error = [exception retain]; + } + return 1; + } +} diff --git a/third_party/cargo/vendor/objc_exception-0.1.2/src/lib.rs b/third_party/cargo/vendor/objc_exception-0.1.2/src/lib.rs new file mode 100644 index 0000000..d381f60 --- /dev/null +++ b/third_party/cargo/vendor/objc_exception-0.1.2/src/lib.rs @@ -0,0 +1,100 @@ +//! Rust interface for Objective-C's `@throw` and `@try`/`@catch` statements. + +use std::mem; +use std::os::raw::{c_int, c_void}; +use std::ptr; + +#[link(name = "objc", kind = "dylib")] +extern { } + +extern { + fn RustObjCExceptionThrow(exception: *mut c_void); + fn RustObjCExceptionTryCatch(try: extern fn(*mut c_void), + context: *mut c_void, error: *mut *mut c_void) -> c_int; +} + +/// An opaque type representing any Objective-C object thrown as an exception. +pub enum Exception { } + +/// Throws an Objective-C exception. +/// The argument must be a pointer to an Objective-C object. +/// +/// Unsafe because this unwinds from Objective-C. +pub unsafe fn throw(exception: *mut Exception) -> ! { + RustObjCExceptionThrow(exception as *mut _); + unreachable!(); +} + +unsafe fn try_no_ret(closure: F) -> Result<(), *mut Exception> + where F: FnOnce() { + extern fn try_objc_execute_closure(closure: &mut Option) + where F: FnOnce() { + // This is always passed Some, so it's safe to unwrap + let closure = closure.take().unwrap(); + closure(); + } + + let f: extern fn(&mut Option) = try_objc_execute_closure; + let f: extern fn(*mut c_void) = mem::transmute(f); + // Wrap the closure in an Option so it can be taken + let mut closure = Some(closure); + let context = &mut closure as *mut _ as *mut c_void; + + let mut exception = ptr::null_mut(); + let success = RustObjCExceptionTryCatch(f, context, &mut exception); + + if success == 0 { + Ok(()) + } else { + Err(exception as *mut _) + } +} + +/// Tries to execute the given closure and catches an Objective-C exception +/// if one is thrown. +/// +/// Returns a `Result` that is either `Ok` if the closure succeeded without an +/// exception being thrown, or an `Err` with a pointer to an exception if one +/// was thrown. The exception is retained and so must be released. +/// +/// Unsafe because this encourages unwinding through the closure from +/// Objective-C, which is not safe. +pub unsafe fn try(closure: F) -> Result + where F: FnOnce() -> R { + let mut value = None; + let result = { + let value_ref = &mut value; + try_no_ret(move || { + *value_ref = Some(closure()); + }) + }; + // If the try succeeded, this was set so it's safe to unwrap + result.map(|_| value.unwrap()) +} + +#[cfg(test)] +mod tests { + use std::ptr; + use super::{throw, try}; + + #[test] + fn test_try() { + unsafe { + let s = "Hello".to_string(); + let result = try(move || { + if s.len() > 0 { + throw(ptr::null_mut()); + } + s.len() + }); + assert!(result.unwrap_err() == ptr::null_mut()); + + let mut s = "Hello".to_string(); + let result = try(move || { + s.push_str(", World!"); + s + }); + assert!(result.unwrap() == "Hello, World!"); + } + } +} diff --git a/third_party/cargo/vendor/objc_id-0.1.1/.cargo-checksum.json b/third_party/cargo/vendor/objc_id-0.1.1/.cargo-checksum.json new file mode 100644 index 0000000..e10f9d7 --- /dev/null +++ b/third_party/cargo/vendor/objc_id-0.1.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"7d444ee847aa9b34cbe6cddeaf4001b28be86b28c2855e09c2e7fbfa797a66dd","README.md":"09ef009a08879a901c3bbfa2aeb35813e084d841b721905e5ae2d1cd84f6063c","src/id.rs":"d5034fbefbd59e18cacc00ee20dbab087e2b1cb7a47780789dc25efc83f7918b","src/lib.rs":"fdc6a052f18cc8d96f24848e107c73eac0ddf12882b69f6d40f09f4652c7fc73"},"package":"c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"} \ No newline at end of file diff --git a/third_party/cargo/vendor/objc_id-0.1.1/BUILD b/third_party/cargo/vendor/objc_id-0.1.1/BUILD new file mode 100644 index 0000000..b65d342 --- /dev/null +++ b/third_party/cargo/vendor/objc_id-0.1.1/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "objc_id", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/objc-0.2.7:objc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/objc_id-0.1.1/Cargo.toml b/third_party/cargo/vendor/objc_id-0.1.1/Cargo.toml new file mode 100644 index 0000000..86eef1d --- /dev/null +++ b/third_party/cargo/vendor/objc_id-0.1.1/Cargo.toml @@ -0,0 +1,25 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "objc_id" +version = "0.1.1" +authors = ["Steven Sheldon"] +exclude = [".gitignore"] +description = "Rust smart pointers for Objective-C reference counting." +documentation = "http://ssheldon.github.io/rust-objc/objc_id/" +readme = "README.md" +keywords = ["objective-c", "osx", "ios"] +license = "MIT" +repository = "http://github.com/SSheldon/rust-objc-id" +[dependencies.objc] +version = "0.2.4" diff --git a/third_party/cargo/vendor/objc_id-0.1.1/README.md b/third_party/cargo/vendor/objc_id-0.1.1/README.md new file mode 100644 index 0000000..f1f362b --- /dev/null +++ b/third_party/cargo/vendor/objc_id-0.1.1/README.md @@ -0,0 +1,34 @@ +Rust smart pointers for Objective-C reference counting. + +To ensure that Objective-C objects are retained and released +at the proper times, we can use the Id struct. + +To enforce aliasing rules, an `Id` can be either owned or shared; if it is +owned, meaning the `Id` is the only reference to the object, it can be mutably +dereferenced. An owned `Id` can be downgraded to a ShareId +which can be cloned to allow multiple references. + +Weak references may be created using the WeakId struct. + +``` rust +use objc::runtime::{Class, Object}; +use objc_id::{Id, WeakId}; + +let cls = Class::get("NSObject").unwrap(); +let obj: Id = unsafe { + Id::from_retained_ptr(msg_send![cls, new]) +}; +// obj will be released when it goes out of scope + +// share the object so we can clone it +let obj = obj.share(); +let another_ref = obj.clone(); +// dropping our other reference will decrement the retain count +drop(another_ref); + +let weak = WeakId::new(&obj); +assert!(weak.load().is_some()); +// After the object is deallocated, our weak pointer returns none +drop(obj); +assert!(weak.load().is_none()); +``` diff --git a/third_party/cargo/vendor/objc_id-0.1.1/src/id.rs b/third_party/cargo/vendor/objc_id-0.1.1/src/id.rs new file mode 100644 index 0000000..b679f3b --- /dev/null +++ b/third_party/cargo/vendor/objc_id-0.1.1/src/id.rs @@ -0,0 +1,217 @@ +use std::any::Any; +use std::fmt; +use std::hash; +use std::marker::PhantomData; +use std::ops::{Deref, DerefMut}; + +use objc::Message; +use objc::rc::{StrongPtr, WeakPtr}; +use objc::runtime::Object; + +/// A type used to mark that a struct owns the object(s) it contains, +/// so it has the sole references to them. +pub enum Owned { } +/// A type used to mark that the object(s) a struct contains are shared, +/// so there may be other references to them. +pub enum Shared { } + +/// A type that marks what type of ownership a struct has over the object(s) +/// it contains; specifically, either `Owned` or `Shared`. +pub trait Ownership: Any { } +impl Ownership for Owned { } +impl Ownership for Shared { } + +/// A pointer type for Objective-C's reference counted objects. +/// +/// The object of an `Id` is retained and sent a `release` message when +/// the `Id` is dropped. +/// +/// An `Id` may be either `Owned` or `Shared`, represented by the types `Id` +/// and `ShareId`, respectively. If owned, there are no other references to the +/// object and the `Id` can be mutably dereferenced. `ShareId`, however, can +/// only be immutably dereferenced because there may be other references to the +/// object, but a `ShareId` can be cloned to provide more references to the +/// object. An owned `Id` can be "downgraded" freely to a `ShareId`, but there +/// is no way to safely upgrade back. +pub struct Id { + ptr: StrongPtr, + item: PhantomData, + own: PhantomData, +} + +impl Id where T: Message, O: Ownership { + unsafe fn new(ptr: StrongPtr) -> Id { + Id { ptr: ptr, item: PhantomData, own: PhantomData } + } + + /// Constructs an `Id` from a pointer to an unretained object and + /// retains it. Panics if the pointer is null. + /// Unsafe because the pointer must be to a valid object and + /// the caller must ensure the ownership is correct. + pub unsafe fn from_ptr(ptr: *mut T) -> Id { + assert!(!ptr.is_null(), "Attempted to construct an Id from a null pointer"); + Id::new(StrongPtr::retain(ptr as *mut Object)) + } + + /// Constructs an `Id` from a pointer to a retained object; this won't + /// retain the pointer, so the caller must ensure the object has a +1 + /// retain count. Panics if the pointer is null. + /// Unsafe because the pointer must be to a valid object and + /// the caller must ensure the ownership is correct. + pub unsafe fn from_retained_ptr(ptr: *mut T) -> Id { + assert!(!ptr.is_null(), "Attempted to construct an Id from a null pointer"); + Id::new(StrongPtr::new(ptr as *mut Object)) + } +} + +impl Id where T: Message { + /// "Downgrade" an owned `Id` to a `ShareId`, allowing it to be cloned. + pub fn share(self) -> ShareId { + let Id { ptr, .. } = self; + unsafe { Id::new(ptr) } + } +} + +impl Clone for Id where T: Message { + fn clone(&self) -> ShareId { + unsafe { + Id::new(self.ptr.clone()) + } + } +} + +unsafe impl Sync for Id where T: Sync { } + +unsafe impl Send for Id where T: Send { } + +unsafe impl Send for Id where T: Sync { } + +impl Deref for Id { + type Target = T; + + fn deref(&self) -> &T { + unsafe { &*(*self.ptr as *mut T) } + } +} + +impl DerefMut for Id { + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *(*self.ptr as *mut T) } + } +} + +impl PartialEq for Id where T: PartialEq { + fn eq(&self, other: &Id) -> bool { + self.deref() == other.deref() + } + + fn ne(&self, other: &Id) -> bool { + self.deref() != other.deref() + } +} + +impl Eq for Id where T: Eq { } + +impl hash::Hash for Id where T: hash::Hash { + fn hash(&self, state: &mut H) where H: hash::Hasher { + self.deref().hash(state) + } +} + +impl fmt::Debug for Id where T: fmt::Debug { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.deref().fmt(f) + } +} + +impl fmt::Pointer for Id { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Pointer::fmt(&self.ptr, f) + } +} + +/// A convenient alias for a shared `Id`. +pub type ShareId = Id; + +/// A pointer type for a weak reference to an Objective-C reference counted +/// object. +pub struct WeakId { + ptr: WeakPtr, + item: PhantomData, +} + +impl WeakId where T: Message { + /// Construct a new `WeakId` referencing the given `ShareId`. + pub fn new(obj: &ShareId) -> WeakId { + WeakId { + ptr: obj.ptr.weak(), + item: PhantomData, + } + } + + /// Load a `ShareId` from the `WeakId` if the object still exists. + /// Returns `None` if the object has been deallocated. + pub fn load(&self) -> Option> { + let obj = self.ptr.load(); + if obj.is_null() { + None + } else { + Some(unsafe { Id::new(obj) }) + } + } +} + +unsafe impl Sync for WeakId where T: Sync { } + +unsafe impl Send for WeakId where T: Sync { } + +#[cfg(test)] +mod tests { + use objc::runtime::Object; + use super::{Id, ShareId, WeakId}; + + fn retain_count(obj: &Object) -> usize { + unsafe { msg_send![obj, retainCount] } + } + + #[test] + fn test_clone() { + let cls = class!(NSObject); + let obj: Id = unsafe { + let obj: *mut Object = msg_send![cls, alloc]; + let obj: *mut Object = msg_send![obj, init]; + Id::from_retained_ptr(obj) + }; + assert!(retain_count(&obj) == 1); + + let obj = obj.share(); + assert!(retain_count(&obj) == 1); + + let cloned = obj.clone(); + assert!(retain_count(&cloned) == 2); + assert!(retain_count(&obj) == 2); + + drop(obj); + assert!(retain_count(&cloned) == 1); + } + + #[test] + fn test_weak() { + let cls = class!(NSObject); + let obj: ShareId = unsafe { + let obj: *mut Object = msg_send![cls, alloc]; + let obj: *mut Object = msg_send![obj, init]; + Id::from_retained_ptr(obj) + }; + + let weak = WeakId::new(&obj); + let strong = weak.load().unwrap(); + let strong_ptr: *const Object = &*strong; + let obj_ptr: *const Object = &*obj; + assert!(strong_ptr == obj_ptr); + drop(strong); + + drop(obj); + assert!(weak.load().is_none()); + } +} diff --git a/third_party/cargo/vendor/objc_id-0.1.1/src/lib.rs b/third_party/cargo/vendor/objc_id-0.1.1/src/lib.rs new file mode 100644 index 0000000..d03b354 --- /dev/null +++ b/third_party/cargo/vendor/objc_id-0.1.1/src/lib.rs @@ -0,0 +1,47 @@ +/*! +Rust smart pointers for Objective-C reference counting. + +To ensure that Objective-C objects are retained and released +at the proper times, we can use the [`Id`](struct.Id.html) struct. + +To enforce aliasing rules, an `Id` can be either owned or shared; if it is +owned, meaning the `Id` is the only reference to the object, it can be mutably +dereferenced. An owned `Id` can be downgraded to a [`ShareId`](type.ShareId.html) +which can be cloned to allow multiple references. + +Weak references may be created using the [`WeakId`](struct.WeakId.html) struct. + +``` +# #[macro_use] extern crate objc; +# extern crate objc_id; +use objc::runtime::{Class, Object}; +use objc_id::{Id, WeakId}; + +# fn main() { +let cls = Class::get("NSObject").unwrap(); +let obj: Id = unsafe { + Id::from_retained_ptr(msg_send![cls, new]) +}; +// obj will be released when it goes out of scope + +// share the object so we can clone it +let obj = obj.share(); +let another_ref = obj.clone(); +// dropping our other reference will decrement the retain count +drop(another_ref); + +let weak = WeakId::new(&obj); +assert!(weak.load().is_some()); +// After the object is deallocated, our weak pointer returns none +drop(obj); +assert!(weak.load().is_none()); +# } +``` +*/ + +#[macro_use] +extern crate objc; + +pub use id::{Id, Owned, Ownership, Shared, ShareId, WeakId}; + +mod id; diff --git a/third_party/cargo/vendor/ordered-float-1.0.2/.cargo-checksum.json b/third_party/cargo/vendor/ordered-float-1.0.2/.cargo-checksum.json new file mode 100644 index 0000000..a800257 --- /dev/null +++ b/third_party/cargo/vendor/ordered-float-1.0.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"336ccc4a5a4fb1d69641a7e4eb8aa29e49d13f907dcf10b22b18b7b219acde9d","LICENSE-MIT":"f7715d38a3fa1b4ac97c5729740752505a39cb92ee83ab5b102aeb5eaa7cdea4","README.md":"c4aee96bd98f215fe099f498385e4f31319bff37d2415998f8e6ac27bbea3cc5","src/lib.rs":"ce067c96f199d51bff2edf1f01924f9ecbe12949e5923eefeb97c6a993654fef","tests/test.rs":"c37407ab8f02a83756563894de8a9f8cf5d144395a592605555d57387e58360d","tests/test_deprecated_names.rs":"0e959949ce309229642d004a20f8e836c5a88cb9d117779f75bd375ff1a88d18"},"package":"18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518"} \ No newline at end of file diff --git a/third_party/cargo/vendor/ordered-float-1.0.2/BUILD b/third_party/cargo/vendor/ordered-float-1.0.2/BUILD new file mode 100644 index 0000000..ac6be7a --- /dev/null +++ b/third_party/cargo/vendor/ordered-float-1.0.2/BUILD @@ -0,0 +1,45 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "ordered_float", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/num-traits-0.2.11:num_traits", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.0.2", + crate_features = [ + ], +) + +# Unsupported target "test" with type "test" omitted +# Unsupported target "test_deprecated_names" with type "test" omitted diff --git a/third_party/cargo/vendor/ordered-float-1.0.2/Cargo.toml b/third_party/cargo/vendor/ordered-float-1.0.2/Cargo.toml new file mode 100644 index 0000000..b563d73 --- /dev/null +++ b/third_party/cargo/vendor/ordered-float-1.0.2/Cargo.toml @@ -0,0 +1,36 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "ordered-float" +version = "1.0.2" +authors = ["Jonathan Reem ", "Matt Brubeck "] +description = "Wrappers for total ordering on floats" +readme = "README.md" +keywords = ["no_std", "ord", "f64", "f32", "sort"] +categories = ["science", "rust-patterns", "no-std"] +license = "MIT" +repository = "https://github.com/reem/rust-ordered-float" +[dependencies.num-traits] +version = "0.2.1" +default-features = false + +[dependencies.serde] +version = "1.0" +optional = true +default-features = false +[dev-dependencies.serde_test] +version = "1.0" + +[features] +default = ["std"] +std = ["num-traits/std"] diff --git a/third_party/cargo/vendor/ordered-float-1.0.2/LICENSE-MIT b/third_party/cargo/vendor/ordered-float-1.0.2/LICENSE-MIT new file mode 100644 index 0000000..c8e0f5e --- /dev/null +++ b/third_party/cargo/vendor/ordered-float-1.0.2/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2015 Jonathan Reem + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/ordered-float-1.0.2/README.md b/third_party/cargo/vendor/ordered-float-1.0.2/README.md new file mode 100644 index 0000000..b5e3302 --- /dev/null +++ b/third_party/cargo/vendor/ordered-float-1.0.2/README.md @@ -0,0 +1,29 @@ +# Ordered Floats + +Provides several wrapper types for Ord and Eq implementations on f64. + +## Usage + +Use the crates.io repository; add this to your `Cargo.toml` along +with the rest of your dependencies: + +```toml +[dependencies] +ordered-float = "1.0" +``` + +See the [API documentation](https://docs.rs/ordered-float) for further details. + +## no_std + +To use `ordered_float` without requiring the Rust standard library, disable +the default `std` feature: + +```toml +[dependencies] +ordered-float = { version = "1.0", default-features = false } +``` + +## License + +MIT diff --git a/third_party/cargo/vendor/ordered-float-1.0.2/src/lib.rs b/third_party/cargo/vendor/ordered-float-1.0.2/src/lib.rs new file mode 100644 index 0000000..9db8097 --- /dev/null +++ b/third_party/cargo/vendor/ordered-float-1.0.2/src/lib.rs @@ -0,0 +1,697 @@ +#![no_std] +#![cfg_attr(test, deny(warnings))] +#![deny(missing_docs)] + +//! Wrappers for total order on Floats. + +extern crate num_traits; +#[cfg(feature = "std")] extern crate std; + +use core::cmp::Ordering; +use core::ops::{Add, AddAssign, Deref, DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Rem, + RemAssign, Sub, SubAssign}; +use core::hash::{Hash, Hasher}; +use core::fmt; +use core::mem; +use core::hint::unreachable_unchecked; +use core::str::FromStr; + +use num_traits::{Bounded, FromPrimitive, Num, NumCast, One, Signed, ToPrimitive, Zero}; +#[cfg(feature = "std")] +use num_traits::Float; +#[cfg(not(feature = "std"))] +use num_traits::float::FloatCore as Float; + +/// A wrapper around Floats providing an implementation of Ord and Hash. +/// +/// A NaN value cannot be stored in this type. +#[deprecated(since = "0.6.0", note = "renamed to `NotNan`")] +pub type NotNaN = NotNan; + +/// An error indicating an attempt to construct NotNan from a NaN +#[deprecated(since = "0.6.0", note = "renamed to `FloatIsNan`")] +pub type FloatIsNaN = FloatIsNan; + +// masks for the parts of the IEEE 754 float +const SIGN_MASK: u64 = 0x8000000000000000u64; +const EXP_MASK: u64 = 0x7ff0000000000000u64; +const MAN_MASK: u64 = 0x000fffffffffffffu64; + +// canonical raw bit patterns (for hashing) +const CANONICAL_NAN_BITS: u64 = 0x7ff8000000000000u64; +const CANONICAL_ZERO_BITS: u64 = 0x0u64; + +/// A wrapper around Floats providing an implementation of Ord and Hash. +/// +/// NaN is sorted as *greater* than all other values and *equal* +/// to itself, in contradiction with the IEEE standard. +#[derive(Debug, Default, Clone, Copy)] +#[repr(transparent)] +pub struct OrderedFloat(pub T); + +impl OrderedFloat { + /// Get the value out. + pub fn into_inner(self) -> T { + let OrderedFloat(val) = self; + val + } +} + +impl AsRef for OrderedFloat { + fn as_ref(&self) -> &T { + let OrderedFloat(ref val) = *self; + val + } +} + +impl AsMut for OrderedFloat { + fn as_mut(&mut self) -> &mut T { + let OrderedFloat(ref mut val) = *self; + val + } +} + +impl PartialOrd for OrderedFloat { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for OrderedFloat { + fn cmp(&self, other: &Self) -> Ordering { + let lhs = self.as_ref(); + let rhs = other.as_ref(); + match lhs.partial_cmp(&rhs) { + Some(ordering) => ordering, + None => { + if lhs.is_nan() { + if rhs.is_nan() { + Ordering::Equal + } else { + Ordering::Greater + } + } else { + Ordering::Less + } + } + } + } +} + +impl PartialEq for OrderedFloat { + fn eq(&self, other: &OrderedFloat) -> bool { + if self.as_ref().is_nan() { + other.as_ref().is_nan() + } else { + self.as_ref() == other.as_ref() + } + } +} + +impl Hash for OrderedFloat { + fn hash(&self, state: &mut H) { + if self.is_nan() { + // normalize to one representation of NaN + hash_float(&T::nan(), state) + } else { + hash_float(self.as_ref(), state) + } + } +} + +impl fmt::Display for OrderedFloat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.as_ref().fmt(f) + } +} + +impl Into for OrderedFloat { + fn into(self) -> f32 { + self.into_inner() + } +} + +impl Into for OrderedFloat { + fn into(self) -> f64 { + self.into_inner() + } +} + +impl From for OrderedFloat { + fn from(val: T) -> Self { + OrderedFloat(val) + } +} + +impl Deref for OrderedFloat { + type Target = T; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + +impl DerefMut for OrderedFloat { + fn deref_mut(&mut self) -> &mut Self::Target { + self.as_mut() + } +} + +impl Eq for OrderedFloat {} + +impl Bounded for OrderedFloat { + fn min_value() -> Self { + OrderedFloat(T::min_value()) + } + + fn max_value() -> Self { + OrderedFloat(T::max_value()) + } +} + +impl FromStr for OrderedFloat { + type Err = T::Err; + + /// Convert a &str to `OrderedFloat`. Returns an error if the string fails to parse. + /// + /// ``` + /// use ordered_float::OrderedFloat; + /// + /// assert!("-10".parse::>().is_ok()); + /// assert!("abc".parse::>().is_err()); + /// assert!("NaN".parse::>().is_ok()); + /// ``` + fn from_str(s: &str) -> Result { + T::from_str(s).map(OrderedFloat) + } +} + +/// A wrapper around Floats providing an implementation of Ord and Hash. +/// +/// A NaN value cannot be stored in this type. +#[derive(PartialOrd, PartialEq, Debug, Default, Clone, Copy)] +#[repr(transparent)] +pub struct NotNan(T); + +impl NotNan { + /// Create a NotNan value. + /// + /// Returns Err if val is NaN + pub fn new(val: T) -> Result { + match val { + ref val if val.is_nan() => Err(FloatIsNan), + val => Ok(NotNan(val)), + } + } + + /// Create a NotNan value from a value that is guaranteed to not be NaN + /// + /// Behaviour is undefined if `val` is NaN + pub unsafe fn unchecked_new(val: T) -> Self { + debug_assert!(!val.is_nan()); + NotNan(val) + } + + /// Get the value out. + pub fn into_inner(self) -> T { + self.0 + } +} + +impl AsRef for NotNan { + fn as_ref(&self) -> &T { + &self.0 + } +} + +impl Ord for NotNan { + fn cmp(&self, other: &NotNan) -> Ordering { + match self.partial_cmp(&other) { + Some(ord) => ord, + None => unsafe { unreachable_unchecked() }, + } + } +} + +impl Hash for NotNan { + fn hash(&self, state: &mut H) { + hash_float(self.as_ref(), state) + } +} + +impl fmt::Display for NotNan { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.as_ref().fmt(f) + } +} + +impl From> for f32 { + fn from(value: NotNan) -> Self { + value.into_inner() + } +} + +impl From> for f64 { + fn from(value: NotNan) -> Self { + value.into_inner() + } +} + +/// Creates a NotNan value from a Float. +/// +/// Panics if the provided value is NaN or the computation results in NaN +impl From for NotNan { + fn from(v: T) -> Self { + NotNan::new(v).expect("Tried to create a NotNan from a NaN") + } +} + +impl Deref for NotNan { + type Target = T; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + +impl Eq for NotNan {} + +/// Adds two NotNans. +/// +/// Panics if the computation results in NaN +impl Add for NotNan { + type Output = Self; + + fn add(self, other: Self) -> Self { + self + other.0 + } +} + +/// Adds a float directly. +/// +/// Panics if the provided value is NaN or the computation results in NaN +impl Add for NotNan { + type Output = Self; + + fn add(self, other: T) -> Self { + NotNan::new(self.0 + other).expect("Addition resulted in NaN") + } +} + +impl AddAssign for NotNan { + fn add_assign(&mut self, other: Self) { + *self += other.0; + } +} + +/// Adds a float directly. +/// +/// Panics if the provided value is NaN. +impl AddAssign for NotNan { + fn add_assign(&mut self, other: T) { + self.0 += other; + assert!(!self.0.is_nan(), "Addition resulted in NaN"); + } +} + +impl Sub for NotNan { + type Output = Self; + + fn sub(self, other: Self) -> Self { + self - other.0 + } +} + +/// Subtracts a float directly. +/// +/// Panics if the provided value is NaN or the computation results in NaN +impl Sub for NotNan { + type Output = Self; + + fn sub(self, other: T) -> Self { + NotNan::new(self.0 - other).expect("Subtraction resulted in NaN") + } +} + +impl SubAssign for NotNan { + fn sub_assign(&mut self, other: Self) { + *self -= other.0 + } +} + +/// Subtracts a float directly. +/// +/// Panics if the provided value is NaN or the computation results in NaN +impl SubAssign for NotNan { + fn sub_assign(&mut self, other: T) { + self.0 -= other; + assert!(!self.0.is_nan(), "Subtraction resulted in NaN"); + } +} + +impl Mul for NotNan { + type Output = Self; + + fn mul(self, other: Self) -> Self { + self * other.0 + } +} + +/// Multiplies a float directly. +/// +/// Panics if the provided value is NaN or the computation results in NaN +impl Mul for NotNan { + type Output = Self; + + fn mul(self, other: T) -> Self { + NotNan::new(self.0 * other).expect("Multiplication resulted in NaN") + } +} + +impl MulAssign for NotNan { + fn mul_assign(&mut self, other: Self) { + *self *= other.0 + } +} + +/// Multiplies a float directly. +/// +/// Panics if the provided value is NaN. +impl MulAssign for NotNan { + fn mul_assign(&mut self, other: T) { + self.0 *= other; + assert!(!self.0.is_nan(), "Multiplication resulted in NaN"); + } +} + +impl Div for NotNan { + type Output = Self; + + fn div(self, other: Self) -> Self { + self / other.0 + } +} + +/// Divides a float directly. +/// +/// Panics if the provided value is NaN or the computation results in NaN +impl Div for NotNan { + type Output = Self; + + fn div(self, other: T) -> Self { + NotNan::new(self.0 / other).expect("Division resulted in NaN") + } +} + +impl DivAssign for NotNan { + fn div_assign(&mut self, other: Self) { + *self /= other.0; + } +} + +/// Divides a float directly. +/// +/// Panics if the provided value is NaN or the computation results in NaN +impl DivAssign for NotNan { + fn div_assign(&mut self, other: T) { + self.0 /= other; + assert!(!self.0.is_nan(), "Division resulted in NaN"); + } +} + +impl Rem for NotNan { + type Output = Self; + + fn rem(self, other: Self) -> Self { + self % other.0 + } +} + +/// Calculates `%` with a float directly. +/// +/// Panics if the provided value is NaN or the computation results in NaN +impl Rem for NotNan { + type Output = Self; + + fn rem(self, other: T) -> Self { + NotNan::new(self.0 % other).expect("Rem resulted in NaN") + } +} + +impl RemAssign for NotNan { + fn rem_assign(&mut self, other: Self) { + *self %= other.0 + } +} + +/// Calculates `%=` with a float directly. +/// +/// Panics if the provided value is NaN or the computation results in NaN +impl RemAssign for NotNan { + fn rem_assign(&mut self, other: T) { + self.0 %= other; + assert!(!self.0.is_nan(), "Rem resulted in NaN"); + } +} + +impl Neg for NotNan { + type Output = Self; + + fn neg(self) -> Self { + NotNan(-self.0) + } +} + +/// An error indicating an attempt to construct NotNan from a NaN +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub struct FloatIsNan; + +#[cfg(feature = "std")] +impl std::error::Error for FloatIsNan { + fn description(&self) -> &str { + "NotNan constructed with NaN" + } +} + +impl fmt::Display for FloatIsNan { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "NotNan constructed with NaN") + } +} + +#[cfg(feature = "std")] +impl Into for FloatIsNan { + fn into(self) -> std::io::Error { + std::io::Error::new(std::io::ErrorKind::InvalidInput, self) + } +} + +#[inline] +fn hash_float(f: &F, state: &mut H) { + raw_double_bits(f).hash(state); +} + +#[inline] +fn raw_double_bits(f: &F) -> u64 { + if f.is_nan() { + return CANONICAL_NAN_BITS; + } + + let (man, exp, sign) = f.integer_decode(); + if man == 0 { + return CANONICAL_ZERO_BITS; + } + + let exp_u64 = unsafe { mem::transmute::(exp) } as u64; + let sign_u64 = if sign > 0 { 1u64 } else { 0u64 }; + (man & MAN_MASK) | ((exp_u64 << 52) & EXP_MASK) | ((sign_u64 << 63) & SIGN_MASK) +} + +impl Zero for NotNan { + fn zero() -> Self { NotNan(T::zero()) } + + fn is_zero(&self) -> bool { self.0.is_zero() } +} + +impl One for NotNan { + fn one() -> Self { NotNan(T::one()) } +} + +impl Bounded for NotNan { + fn min_value() -> Self { + NotNan(T::min_value()) + } + + fn max_value() -> Self { + NotNan(T::max_value()) + } +} + +impl FromStr for NotNan { + type Err = ParseNotNanError; + + /// Convert a &str to `NotNan`. Returns an error if the string fails to parse, + /// or if the resulting value is NaN + /// + /// ``` + /// use ordered_float::NotNan; + /// + /// assert!("-10".parse::>().is_ok()); + /// assert!("abc".parse::>().is_err()); + /// assert!("NaN".parse::>().is_err()); + /// ``` + fn from_str(src: &str) -> Result { + src.parse() + .map_err(ParseNotNanError::ParseFloatError) + .and_then(|f| NotNan::new(f).map_err(|_| ParseNotNanError::IsNaN)) + } +} + +impl FromPrimitive for NotNan { + fn from_i64(n: i64) -> Option { T::from_i64(n).and_then(|n| NotNan::new(n).ok()) } + fn from_u64(n: u64) -> Option { T::from_u64(n).and_then(|n| NotNan::new(n).ok()) } + + fn from_isize(n: isize) -> Option { T::from_isize(n).and_then(|n| NotNan::new(n).ok()) } + fn from_i8(n: i8) -> Option { T::from_i8(n).and_then(|n| NotNan::new(n).ok()) } + fn from_i16(n: i16) -> Option { T::from_i16(n).and_then(|n| NotNan::new(n).ok()) } + fn from_i32(n: i32) -> Option { T::from_i32(n).and_then(|n| NotNan::new(n).ok()) } + fn from_usize(n: usize) -> Option { T::from_usize(n).and_then(|n| NotNan::new(n).ok()) } + fn from_u8(n: u8) -> Option { T::from_u8(n).and_then(|n| NotNan::new(n).ok()) } + fn from_u16(n: u16) -> Option { T::from_u16(n).and_then(|n| NotNan::new(n).ok()) } + fn from_u32(n: u32) -> Option { T::from_u32(n).and_then(|n| NotNan::new(n).ok()) } + fn from_f32(n: f32) -> Option { T::from_f32(n).and_then(|n| NotNan::new(n).ok()) } + fn from_f64(n: f64) -> Option { T::from_f64(n).and_then(|n| NotNan::new(n).ok()) } +} + +impl ToPrimitive for NotNan { + fn to_i64(&self) -> Option { self.0.to_i64() } + fn to_u64(&self) -> Option { self.0.to_u64() } + + fn to_isize(&self) -> Option { self.0.to_isize() } + fn to_i8(&self) -> Option { self.0.to_i8() } + fn to_i16(&self) -> Option { self.0.to_i16() } + fn to_i32(&self) -> Option { self.0.to_i32() } + fn to_usize(&self) -> Option { self.0.to_usize() } + fn to_u8(&self) -> Option { self.0.to_u8() } + fn to_u16(&self) -> Option { self.0.to_u16() } + fn to_u32(&self) -> Option { self.0.to_u32() } + fn to_f32(&self) -> Option { self.0.to_f32() } + fn to_f64(&self) -> Option { self.0.to_f64() } +} + +/// An error indicating a parse error from a string for `NotNan`. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub enum ParseNotNanError { + /// A plain parse error from the underlying float type. + ParseFloatError(E), + /// The parsed float value resulted in a NaN. + IsNaN, +} + +#[cfg(feature = "std")] +impl std::error::Error for ParseNotNanError { + fn description(&self) -> &str { + return "Error parsing a not-NaN floating point value"; + } + + // TODO: add an implementation of cause(). This will be breaking because it requires E: Error. +} + +impl fmt::Display for ParseNotNanError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // TODO: replace this with a human readable fmt. Will require E: Display. + ::fmt(self, f) + } +} + +impl Num for NotNan { + type FromStrRadixErr = ParseNotNanError; + + fn from_str_radix(src: &str, radix: u32) -> Result { + T::from_str_radix(src, radix) + .map_err(|err| ParseNotNanError::ParseFloatError(err)) + .and_then(|n| NotNan::new(n).map_err(|_| ParseNotNanError::IsNaN)) + } +} + +impl Signed for NotNan { + fn abs(&self) -> Self { NotNan(self.0.abs()) } + + fn abs_sub(&self, other: &Self) -> Self { + NotNan::new(Signed::abs_sub(&self.0, &other.0)).expect("Subtraction resulted in NaN") + } + + fn signum(&self) -> Self { NotNan(self.0.signum()) } + fn is_positive(&self) -> bool { self.0.is_positive() } + fn is_negative(&self) -> bool { self.0.is_negative() } +} + +impl NumCast for NotNan { + fn from(n: F) -> Option { + T::from(n).and_then(|n| NotNan::new(n).ok()) + } +} + +#[cfg(feature = "serde")] +mod impl_serde { + extern crate serde; + use self::serde::{Serialize, Serializer, Deserialize, Deserializer}; + use self::serde::de::{Error, Unexpected}; + use super::{OrderedFloat, NotNan}; + #[cfg(feature = "std")] + use num_traits::Float; + #[cfg(not(feature = "std"))] + use num_traits::float::FloatCore as Float; + use core::f64; + + #[cfg(test)] + extern crate serde_test; + #[cfg(test)] + use self::serde_test::{Token, assert_tokens, assert_de_tokens_error}; + + impl Serialize for OrderedFloat { + fn serialize(&self, s: S) -> Result { + self.0.serialize(s) + } + } + + impl<'de, T: Float + Deserialize<'de>> Deserialize<'de> for OrderedFloat { + fn deserialize>(d: D) -> Result { + T::deserialize(d).map(OrderedFloat) + } + } + + impl Serialize for NotNan { + fn serialize(&self, s: S) -> Result { + self.0.serialize(s) + } + } + + impl<'de, T: Float + Deserialize<'de>> Deserialize<'de> for NotNan { + fn deserialize>(d: D) -> Result { + let float = T::deserialize(d)?; + NotNan::new(float).map_err(|_| { + Error::invalid_value(Unexpected::Float(f64::NAN), &"float (but not NaN)") + }) + } + } + + #[test] + fn test_ordered_float() { + let float = OrderedFloat(1.0f64); + assert_tokens(&float, &[Token::F64(1.0)]); + } + + #[test] + fn test_not_nan() { + let float = NotNan(1.0f64); + assert_tokens(&float, &[Token::F64(1.0)]); + } + + #[test] + fn test_fail_on_nan() { + assert_de_tokens_error::>( + &[Token::F64(f64::NAN)], + "invalid value: floating point `NaN`, expected float (but not NaN)"); + } +} diff --git a/third_party/cargo/vendor/ordered-float-1.0.2/tests/test.rs b/third_party/cargo/vendor/ordered-float-1.0.2/tests/test.rs new file mode 100644 index 0000000..889ee73 --- /dev/null +++ b/third_party/cargo/vendor/ordered-float-1.0.2/tests/test.rs @@ -0,0 +1,537 @@ +extern crate num_traits; +extern crate ordered_float; + +pub use ordered_float::*; +pub use num_traits::{Bounded, FromPrimitive, Num, One, Signed, ToPrimitive, Zero}; +#[cfg(feature = "std")] +pub use num_traits::Float; +#[cfg(not(feature = "std"))] +pub use num_traits::float::FloatCore as Float; + +pub use std::cmp::Ordering::*; +pub use std::{f32, f64, panic}; + +pub use std::collections::hash_map::RandomState; +pub use std::collections::HashSet; +pub use std::hash::*; + +#[test] +fn ordered_f32_compare_regular_floats() { + assert_eq!(OrderedFloat(7.0f32).cmp(&OrderedFloat(7.0)), Equal); + assert_eq!(OrderedFloat(8.0f32).cmp(&OrderedFloat(7.0)), Greater); + assert_eq!(OrderedFloat(4.0f32).cmp(&OrderedFloat(7.0)), Less); +} + +#[test] +fn ordered_f32_compare_regular_floats_op() { + assert!(OrderedFloat(7.0f32) == OrderedFloat(7.0)); + assert!(OrderedFloat(7.0f32) <= OrderedFloat(7.0)); + assert!(OrderedFloat(7.0f32) >= OrderedFloat(7.0)); + assert!(OrderedFloat(8.0f32) > OrderedFloat(7.0)); + assert!(OrderedFloat(8.0f32) >= OrderedFloat(7.0)); + assert!(OrderedFloat(4.0f32) < OrderedFloat(7.0)); + assert!(OrderedFloat(4.0f32) <= OrderedFloat(7.0)); +} + +#[test] +fn ordered_f32_compare_nan() { + let f32_nan: f32 = Float::nan(); + assert_eq!(OrderedFloat(f32_nan).cmp(&OrderedFloat(Float::nan())), Equal); + assert_eq!(OrderedFloat(f32_nan).cmp(&OrderedFloat(-100000.0f32)), Greater); + assert_eq!(OrderedFloat(-100.0f32).cmp(&OrderedFloat(Float::nan())), Less); +} + +#[test] +fn ordered_f32_compare_nan_op() { + let f32_nan: OrderedFloat = OrderedFloat(Float::nan()); + assert!(f32_nan == f32_nan); + assert!(f32_nan <= f32_nan); + assert!(f32_nan >= f32_nan); + assert!(f32_nan > OrderedFloat(-100000.0f32)); + assert!(f32_nan >= OrderedFloat(-100000.0f32)); + assert!(OrderedFloat(-100.0f32) < f32_nan); + assert!(OrderedFloat(-100.0f32) <= f32_nan); + assert!(f32_nan > OrderedFloat(Float::infinity())); + assert!(f32_nan >= OrderedFloat(Float::infinity())); + assert!(f32_nan > OrderedFloat(Float::neg_infinity())); + assert!(f32_nan >= OrderedFloat(Float::neg_infinity())); +} + +#[test] +fn ordered_f64_compare_regular_floats() { + assert_eq!(OrderedFloat(7.0f64).cmp(&OrderedFloat(7.0)), Equal); + assert_eq!(OrderedFloat(8.0f64).cmp(&OrderedFloat(7.0)), Greater); + assert_eq!(OrderedFloat(4.0f64).cmp(&OrderedFloat(7.0)), Less); +} + +#[test] +fn not_nan32_zero() { + assert_eq!(NotNan::::zero(), NotNan::from(0.0f32)); + assert!(NotNan::::zero().is_zero()); +} + +#[test] +fn not_nan32_one() { + assert_eq!(NotNan::::one(), NotNan::from(1.0f32)) +} + +#[test] +fn not_nan32_bounded() { + assert_eq!(NotNan::::min_value(), NotNan::from(::min_value())); + assert_eq!(NotNan::::max_value(), NotNan::from(::max_value())); +} + +#[test] +fn not_nan32_from_primitive() { + assert_eq!(NotNan::::from_i8(42i8), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_u8(42u8), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_i16(42i16), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_u16(42u16), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_i32(42i32), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_u32(42u32), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_i64(42i64), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_u64(42u64), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_isize(42isize), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_usize(42usize), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_f32(42f32), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_f32(42f32), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_f64(42f64), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_f64(42f64), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_f32(Float::nan()), None); + assert_eq!(NotNan::::from_f64(Float::nan()), None); +} + +#[test] +fn not_nan32_to_primitive() { + let x = NotNan::from(42.0f32); + assert_eq!(x.to_u8(), Some(42u8)); + assert_eq!(x.to_i8(), Some(42i8)); + assert_eq!(x.to_u16(), Some(42u16)); + assert_eq!(x.to_i16(), Some(42i16)); + assert_eq!(x.to_u32(), Some(42u32)); + assert_eq!(x.to_i32(), Some(42i32)); + assert_eq!(x.to_u64(), Some(42u64)); + assert_eq!(x.to_i64(), Some(42i64)); + assert_eq!(x.to_usize(), Some(42usize)); + assert_eq!(x.to_isize(), Some(42isize)); + assert_eq!(x.to_f32(), Some(42f32)); + assert_eq!(x.to_f32(), Some(42f32)); + assert_eq!(x.to_f64(), Some(42f64)); + assert_eq!(x.to_f64(), Some(42f64)); +} + +#[test] +fn not_nan32_num() { + assert_eq!(NotNan::::from_str_radix("42.0", 10).unwrap(), NotNan::from(42.0f32)); + assert!(NotNan::::from_str_radix("NaN", 10).is_err()); +} + +#[test] +fn not_nan32_signed() { + assert_eq!(NotNan::from(42f32).abs(), NotNan::from(42f32)); + assert_eq!(NotNan::from(-42f32).abs(), NotNan::from(42f32)); + + assert_eq!(NotNan::from(50f32).abs_sub(&NotNan::from(8f32)), NotNan::from(42f32)); + assert_eq!(NotNan::from(8f32).abs_sub(&NotNan::from(50f32)), NotNan::from(0f32)); +} + +#[test] +fn not_nan32_num_cast() { + assert_eq!( as num_traits::NumCast>::from(42), Some(NotNan::from(42f32))); + assert_eq!( as num_traits::NumCast>::from(f32::nan()), None); +} + +#[test] +fn ordered_f64_compare_nan() { + let f64_nan: f64 = Float::nan(); + assert_eq!( + OrderedFloat(f64_nan).cmp(&OrderedFloat(Float::nan())), + Equal + ); + assert_eq!( + OrderedFloat(f64_nan).cmp(&OrderedFloat(-100000.0f64)), + Greater + ); + assert_eq!( + OrderedFloat(-100.0f64).cmp(&OrderedFloat(Float::nan())), + Less + ); +} + +#[test] +fn ordered_f64_compare_regular_floats_op() { + assert!(OrderedFloat(7.0) == OrderedFloat(7.0)); + assert!(OrderedFloat(7.0) <= OrderedFloat(7.0)); + assert!(OrderedFloat(7.0) >= OrderedFloat(7.0)); + assert!(OrderedFloat(8.0) > OrderedFloat(7.0)); + assert!(OrderedFloat(8.0) >= OrderedFloat(7.0)); + assert!(OrderedFloat(4.0) < OrderedFloat(7.0)); + assert!(OrderedFloat(4.0) <= OrderedFloat(7.0)); +} + +#[test] +fn ordered_f64_compare_nan_op() { + let f64_nan: OrderedFloat = OrderedFloat(Float::nan()); + assert!(f64_nan == f64_nan); + assert!(f64_nan <= f64_nan); + assert!(f64_nan >= f64_nan); + assert!(f64_nan > OrderedFloat(-100000.0)); + assert!(f64_nan >= OrderedFloat(-100000.0)); + assert!(OrderedFloat(-100.0) < f64_nan); + assert!(OrderedFloat(-100.0) <= f64_nan); + assert!(f64_nan > OrderedFloat(Float::infinity())); + assert!(f64_nan >= OrderedFloat(Float::infinity())); + assert!(f64_nan > OrderedFloat(Float::neg_infinity())); + assert!(f64_nan >= OrderedFloat(Float::neg_infinity())); +} + +#[test] +fn not_nan32_compare_regular_floats() { + assert_eq!(NotNan::from(7.0f32).cmp(&NotNan::from(7.0)), Equal); + assert_eq!(NotNan::from(8.0f32).cmp(&NotNan::from(7.0)), Greater); + assert_eq!(NotNan::from(4.0f32).cmp(&NotNan::from(7.0)), Less); +} + +#[test] +fn not_nan32_fail_when_constructing_with_nan() { + let f32_nan: f32 = Float::nan(); + assert!(NotNan::new(f32_nan).is_err()); +} + +#[test] +fn not_nan32_calculate_correctly() { + assert_eq!( + *(NotNan::from(5.0f32) + NotNan::from(4.0f32)), + 5.0f32 + 4.0f32 + ); + assert_eq!(*(NotNan::from(5.0f32) + 4.0f32), 5.0f32 + 4.0f32); + assert_eq!( + *(NotNan::from(5.0f32) - NotNan::from(4.0f32)), + 5.0f32 - 4.0f32 + ); + assert_eq!(*(NotNan::from(5.0f32) - 4.0f32), 5.0f32 - 4.0f32); + assert_eq!( + *(NotNan::from(5.0f32) * NotNan::from(4.0f32)), + 5.0f32 * 4.0f32 + ); + assert_eq!(*(NotNan::from(5.0f32) * 4.0f32), 5.0f32 * 4.0f32); + assert_eq!( + *(NotNan::from(8.0f32) / NotNan::from(4.0f32)), + 8.0f32 / 4.0f32 + ); + assert_eq!(*(NotNan::from(8.0f32) / 4.0f32), 8.0f32 / 4.0f32); + assert_eq!( + *(NotNan::from(8.0f32) % NotNan::from(4.0f32)), + 8.0f32 % 4.0f32 + ); + assert_eq!(*(NotNan::from(8.0f32) % 4.0f32), 8.0f32 % 4.0f32); + assert_eq!(*(-NotNan::from(1.0f32)), -1.0f32); + + assert!(panic::catch_unwind(|| NotNan::from(0.0f32) + f32::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNan::from(0.0f32) - f32::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNan::from(0.0f32) * f32::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNan::from(0.0f32) / f32::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNan::from(0.0f32) % f32::NAN).is_err()); + + let mut number = NotNan::from(5.0f32); + number += NotNan::from(4.0f32); + assert_eq!(*number, 9.0f32); + number -= NotNan::from(4.0f32); + assert_eq!(*number, 5.0f32); + number *= NotNan::from(4.0f32); + assert_eq!(*number, 20.0f32); + number /= NotNan::from(4.0f32); + assert_eq!(*number, 5.0f32); + number %= NotNan::from(4.0f32); + assert_eq!(*number, 1.0f32); + + number = NotNan::from(5.0f32); + number += 4.0f32; + assert_eq!(*number, 9.0f32); + number -= 4.0f32; + assert_eq!(*number, 5.0f32); + number *= 4.0f32; + assert_eq!(*number, 20.0f32); + number /= 4.0f32; + assert_eq!(*number, 5.0f32); + number %= 4.0f32; + assert_eq!(*number, 1.0f32); + + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNan::from(0.0f32); + tmp += f32::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNan::from(0.0f32); + tmp -= f32::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNan::from(0.0f32); + tmp *= f32::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNan::from(0.0f32); + tmp /= f32::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNan::from(0.0f32); + tmp %= f32::NAN; + }).is_err() + ); +} + +#[test] +fn not_nan64_compare_regular_floats() { + assert_eq!(NotNan::from(7.0f64).cmp(&NotNan::from(7.0)), Equal); + assert_eq!(NotNan::from(8.0f64).cmp(&NotNan::from(7.0)), Greater); + assert_eq!(NotNan::from(4.0f64).cmp(&NotNan::from(7.0)), Less); +} + +#[test] +fn not_nan64_fail_when_constructing_with_nan() { + let f64_nan: f64 = Float::nan(); + assert!(NotNan::new(f64_nan).is_err()); +} + +#[test] +fn not_nan64_calculate_correctly() { + assert_eq!( + *(NotNan::from(5.0f64) + NotNan::from(4.0f64)), + 5.0f64 + 4.0f64 + ); + assert_eq!(*(NotNan::from(5.0f64) + 4.0f64), 5.0f64 + 4.0f64); + assert_eq!( + *(NotNan::from(5.0f64) - NotNan::from(4.0f64)), + 5.0f64 - 4.0f64 + ); + assert_eq!(*(NotNan::from(5.0f64) - 4.0f64), 5.0f64 - 4.0f64); + assert_eq!( + *(NotNan::from(5.0f64) * NotNan::from(4.0f64)), + 5.0f64 * 4.0f64 + ); + assert_eq!(*(NotNan::from(5.0f64) * 4.0f64), 5.0f64 * 4.0f64); + assert_eq!( + *(NotNan::from(8.0f64) / NotNan::from(4.0f64)), + 8.0f64 / 4.0f64 + ); + assert_eq!(*(NotNan::from(8.0f64) / 4.0f64), 8.0f64 / 4.0f64); + assert_eq!( + *(NotNan::from(8.0f64) % NotNan::from(4.0f64)), + 8.0f64 % 4.0f64 + ); + assert_eq!(*(NotNan::from(8.0f64) % 4.0f64), 8.0f64 % 4.0f64); + assert_eq!(*(-NotNan::from(1.0f64)), -1.0f64); + + assert!(panic::catch_unwind(|| NotNan::from(0.0f64) + f64::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNan::from(0.0f64) - f64::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNan::from(0.0f64) * f64::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNan::from(0.0f64) / f64::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNan::from(0.0f64) % f64::NAN).is_err()); + + let mut number = NotNan::from(5.0f64); + number += NotNan::from(4.0f64); + assert_eq!(*number, 9.0f64); + number -= NotNan::from(4.0f64); + assert_eq!(*number, 5.0f64); + number *= NotNan::from(4.0f64); + assert_eq!(*number, 20.0f64); + number /= NotNan::from(4.0f64); + assert_eq!(*number, 5.0f64); + number %= NotNan::from(4.0f64); + assert_eq!(*number, 1.0f64); + + number = NotNan::from(5.0f64); + number += 4.0f64; + assert_eq!(*number, 9.0f64); + number -= 4.0f64; + assert_eq!(*number, 5.0f64); + number *= 4.0f64; + assert_eq!(*number, 20.0f64); + number /= 4.0f64; + assert_eq!(*number, 5.0f64); + number %= 4.0f64; + assert_eq!(*number, 1.0f64); + + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNan::from(0.0f64); + tmp += f64::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNan::from(0.0f64); + tmp -= f64::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNan::from(0.0f64); + tmp *= f64::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNan::from(0.0f64); + tmp /= f64::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNan::from(0.0f64); + tmp %= f64::NAN; + }).is_err() + ); +} + +#[test] +fn not_nan64_zero() { + assert_eq!(NotNan::::zero(), NotNan::from(0.0f64)); + assert!(NotNan::::zero().is_zero()); +} + +#[test] +fn not_nan64_one() { + assert_eq!(NotNan::::one(), NotNan::from(1.0f64)) +} + +#[test] +fn not_nan64_bounded() { + assert_eq!(NotNan::::min_value(), NotNan::from(::min_value())); + assert_eq!(NotNan::::max_value(), NotNan::from(::max_value())); +} + +#[test] +fn not_nan64_from_primitive() { + assert_eq!(NotNan::::from_i8(42i8), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_u8(42u8), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_i16(42i16), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_u16(42u16), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_i32(42i32), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_u32(42u32), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_i64(42i64), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_u64(42u64), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_isize(42isize), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_usize(42usize), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_f64(42f64), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_f64(42f64), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_f64(42f64), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_f64(42f64), Some(NotNan::from(42.0))); + assert_eq!(NotNan::::from_f64(Float::nan()), None); + assert_eq!(NotNan::::from_f64(Float::nan()), None); +} + +#[test] +fn not_nan64_to_primitive() { + let x = NotNan::from(42.0f64); + assert_eq!(x.to_u8(), Some(42u8)); + assert_eq!(x.to_i8(), Some(42i8)); + assert_eq!(x.to_u16(), Some(42u16)); + assert_eq!(x.to_i16(), Some(42i16)); + assert_eq!(x.to_u32(), Some(42u32)); + assert_eq!(x.to_i32(), Some(42i32)); + assert_eq!(x.to_u64(), Some(42u64)); + assert_eq!(x.to_i64(), Some(42i64)); + assert_eq!(x.to_usize(), Some(42usize)); + assert_eq!(x.to_isize(), Some(42isize)); + assert_eq!(x.to_f64(), Some(42f64)); + assert_eq!(x.to_f64(), Some(42f64)); + assert_eq!(x.to_f64(), Some(42f64)); + assert_eq!(x.to_f64(), Some(42f64)); +} + +#[test] +fn not_nan64_num() { + assert_eq!(NotNan::::from_str_radix("42.0", 10).unwrap(), NotNan::from(42.0f64)); + assert!(NotNan::::from_str_radix("NaN", 10).is_err()); +} + +#[test] +fn not_nan64_signed() { + assert_eq!(NotNan::from(42f64).abs(), NotNan::from(42f64)); + assert_eq!(NotNan::from(-42f64).abs(), NotNan::from(42f64)); + + assert_eq!(NotNan::from(50f64).abs_sub(&NotNan::from(8f64)), NotNan::from(42f64)); + assert_eq!(NotNan::from(8f64).abs_sub(&NotNan::from(50f64)), NotNan::from(0f64)); +} + +#[test] +fn not_nan64_num_cast() { + assert_eq!( as num_traits::NumCast>::from(42), Some(NotNan::from(42f64))); + assert_eq!( as num_traits::NumCast>::from(f64::nan()), None); +} + +#[test] +fn hash_zero_and_neg_zero_to_the_same_hc() { + let state = RandomState::new(); + let mut h1 = state.build_hasher(); + let mut h2 = state.build_hasher(); + OrderedFloat::from(0f64).hash(&mut h1); + OrderedFloat::from(-0f64).hash(&mut h2); + assert_eq!(h1.finish(), h2.finish()); +} + +#[test] +fn hash_inf_and_neg_inf_to_different_hcs() { + let state = RandomState::new(); + let mut h1 = state.build_hasher(); + let mut h2 = state.build_hasher(); + OrderedFloat::from(f64::INFINITY).hash(&mut h1); + OrderedFloat::from(f64::NEG_INFINITY).hash(&mut h2); + assert!(h1.finish() != h2.finish()); +} + +#[test] +fn hash_is_good_for_whole_numbers() { + let state = RandomState::new(); + let limit = 10000; + + let mut set = ::std::collections::HashSet::with_capacity(limit); + for i in 0..limit { + let mut h = state.build_hasher(); + OrderedFloat::from(i as f64).hash(&mut h); + set.insert(h.finish()); + } + + // This allows 100 collisions, which is far too + // many, but should guard against transient issues + // that will result from using RandomState + let pct_unique = set.len() as f64 / limit as f64; + assert!(0.99f64 < pct_unique, "percent-unique={}", pct_unique); +} + +#[test] +fn hash_is_good_for_fractional_numbers() { + let state = RandomState::new(); + let limit = 10000; + + let mut set = ::std::collections::HashSet::with_capacity(limit); + for i in 0..limit { + let mut h = state.build_hasher(); + OrderedFloat::from(i as f64 * (1f64 / limit as f64)).hash(&mut h); + set.insert(h.finish()); + } + + // This allows 100 collisions, which is far too + // many, but should guard against transient issues + // that will result from using RandomState + let pct_unique = set.len() as f64 / limit as f64; + assert!(0.99f64 < pct_unique, "percent-unique={}", pct_unique); +} + +#[test] +#[should_panic] +fn test_add_fails_on_nan() { + let a = NotNan::new(std::f32::INFINITY).unwrap(); + let b = NotNan::new(std::f32::NEG_INFINITY).unwrap(); + let _c = a + b; +} diff --git a/third_party/cargo/vendor/ordered-float-1.0.2/tests/test_deprecated_names.rs b/third_party/cargo/vendor/ordered-float-1.0.2/tests/test_deprecated_names.rs new file mode 100644 index 0000000..44762e2 --- /dev/null +++ b/third_party/cargo/vendor/ordered-float-1.0.2/tests/test_deprecated_names.rs @@ -0,0 +1,530 @@ +#![allow(deprecated)] + +extern crate num_traits; +extern crate ordered_float; + +pub use ordered_float::*; +pub use num_traits::{Bounded, FromPrimitive, Num, One, Signed, ToPrimitive, Zero}; +#[cfg(feature = "std")] +pub use num_traits::Float; +#[cfg(not(feature = "std"))] +pub use num_traits::float::FloatCore as Float; +pub use std::cmp::Ordering::*; +pub use std::{f32, f64, panic}; + +pub use std::collections::hash_map::RandomState; +pub use std::collections::HashSet; +pub use std::hash::*; + +#[test] +fn ordered_f32_compare_regular_floats() { + assert_eq!(OrderedFloat(7.0f32).cmp(&OrderedFloat(7.0)), Equal); + assert_eq!(OrderedFloat(8.0f32).cmp(&OrderedFloat(7.0)), Greater); + assert_eq!(OrderedFloat(4.0f32).cmp(&OrderedFloat(7.0)), Less); +} + +#[test] +fn ordered_f32_compare_regular_floats_op() { + assert!(OrderedFloat(7.0f32) == OrderedFloat(7.0)); + assert!(OrderedFloat(7.0f32) <= OrderedFloat(7.0)); + assert!(OrderedFloat(7.0f32) >= OrderedFloat(7.0)); + assert!(OrderedFloat(8.0f32) > OrderedFloat(7.0)); + assert!(OrderedFloat(8.0f32) >= OrderedFloat(7.0)); + assert!(OrderedFloat(4.0f32) < OrderedFloat(7.0)); + assert!(OrderedFloat(4.0f32) <= OrderedFloat(7.0)); +} + +#[test] +fn ordered_f32_compare_nan() { + let f32_nan: f32 = Float::nan(); + assert_eq!(OrderedFloat(f32_nan).cmp(&OrderedFloat(Float::nan())), Equal); + assert_eq!(OrderedFloat(f32_nan).cmp(&OrderedFloat(-100000.0f32)), Greater); + assert_eq!(OrderedFloat(-100.0f32).cmp(&OrderedFloat(Float::nan())), Less); +} + +#[test] +fn ordered_f32_compare_nan_op() { + let f32_nan: OrderedFloat = OrderedFloat(Float::nan()); + assert!(f32_nan == f32_nan); + assert!(f32_nan <= f32_nan); + assert!(f32_nan >= f32_nan); + assert!(f32_nan > OrderedFloat(-100000.0f32)); + assert!(f32_nan >= OrderedFloat(-100000.0f32)); + assert!(OrderedFloat(-100.0f32) < f32_nan); + assert!(OrderedFloat(-100.0f32) <= f32_nan); + assert!(f32_nan > OrderedFloat(Float::infinity())); + assert!(f32_nan >= OrderedFloat(Float::infinity())); + assert!(f32_nan > OrderedFloat(Float::neg_infinity())); + assert!(f32_nan >= OrderedFloat(Float::neg_infinity())); +} + +#[test] +fn ordered_f64_compare_regular_floats() { + assert_eq!(OrderedFloat(7.0f64).cmp(&OrderedFloat(7.0)), Equal); + assert_eq!(OrderedFloat(8.0f64).cmp(&OrderedFloat(7.0)), Greater); + assert_eq!(OrderedFloat(4.0f64).cmp(&OrderedFloat(7.0)), Less); +} + +#[test] +fn not_nan32_zero() { + assert_eq!(NotNaN::::zero(), NotNaN::from(0.0f32)); + assert!(NotNaN::::zero().is_zero()); +} + +#[test] +fn not_nan32_one() { + assert_eq!(NotNaN::::one(), NotNaN::from(1.0f32)) +} + +#[test] +fn not_nan32_bounded() { + assert_eq!(NotNaN::::min_value(), NotNaN::from(::min_value())); + assert_eq!(NotNaN::::max_value(), NotNaN::from(::max_value())); +} + +#[test] +fn not_nan32_from_primitive() { + assert_eq!(NotNaN::::from_i8(42i8), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_u8(42u8), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_i16(42i16), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_u16(42u16), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_i32(42i32), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_u32(42u32), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_i64(42i64), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_u64(42u64), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_isize(42isize), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_usize(42usize), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_f32(42f32), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_f32(42f32), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_f64(42f64), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_f64(42f64), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_f32(Float::nan()), None); + assert_eq!(NotNaN::::from_f64(Float::nan()), None); +} + +#[test] +fn not_nan32_to_primitive() { + let x = NotNaN::from(42.0f32); + assert_eq!(x.to_u8(), Some(42u8)); + assert_eq!(x.to_i8(), Some(42i8)); + assert_eq!(x.to_u16(), Some(42u16)); + assert_eq!(x.to_i16(), Some(42i16)); + assert_eq!(x.to_u32(), Some(42u32)); + assert_eq!(x.to_i32(), Some(42i32)); + assert_eq!(x.to_u64(), Some(42u64)); + assert_eq!(x.to_i64(), Some(42i64)); + assert_eq!(x.to_usize(), Some(42usize)); + assert_eq!(x.to_isize(), Some(42isize)); + assert_eq!(x.to_f32(), Some(42f32)); + assert_eq!(x.to_f32(), Some(42f32)); + assert_eq!(x.to_f64(), Some(42f64)); + assert_eq!(x.to_f64(), Some(42f64)); +} + +#[test] +fn not_nan32_num() { + assert_eq!(NotNaN::::from_str_radix("42.0", 10).unwrap(), NotNaN::from(42.0f32)); + assert!(NotNaN::::from_str_radix("NaN", 10).is_err()); +} + +#[test] +fn not_nan32_signed() { + assert_eq!(NotNaN::from(42f32).abs(), NotNaN::from(42f32)); + assert_eq!(NotNaN::from(-42f32).abs(), NotNaN::from(42f32)); + + assert_eq!(NotNaN::from(50f32).abs_sub(&NotNaN::from(8f32)), NotNaN::from(42f32)); + assert_eq!(NotNaN::from(8f32).abs_sub(&NotNaN::from(50f32)), NotNaN::from(0f32)); +} + +#[test] +fn not_nan32_num_cast() { + assert_eq!( as num_traits::NumCast>::from(42), Some(NotNaN::from(42f32))); + assert_eq!( as num_traits::NumCast>::from(f32::nan()), None); +} + +#[test] +fn ordered_f64_compare_nan() { + let f64_nan: f64 = Float::nan(); + assert_eq!( + OrderedFloat(f64_nan).cmp(&OrderedFloat(Float::nan())), + Equal + ); + assert_eq!( + OrderedFloat(f64_nan).cmp(&OrderedFloat(-100000.0f64)), + Greater + ); + assert_eq!( + OrderedFloat(-100.0f64).cmp(&OrderedFloat(Float::nan())), + Less + ); +} + +#[test] +fn ordered_f64_compare_regular_floats_op() { + assert!(OrderedFloat(7.0) == OrderedFloat(7.0)); + assert!(OrderedFloat(7.0) <= OrderedFloat(7.0)); + assert!(OrderedFloat(7.0) >= OrderedFloat(7.0)); + assert!(OrderedFloat(8.0) > OrderedFloat(7.0)); + assert!(OrderedFloat(8.0) >= OrderedFloat(7.0)); + assert!(OrderedFloat(4.0) < OrderedFloat(7.0)); + assert!(OrderedFloat(4.0) <= OrderedFloat(7.0)); +} + +#[test] +fn ordered_f64_compare_nan_op() { + let f64_nan: OrderedFloat = OrderedFloat(Float::nan()); + assert!(f64_nan == f64_nan); + assert!(f64_nan <= f64_nan); + assert!(f64_nan >= f64_nan); + assert!(f64_nan > OrderedFloat(-100000.0)); + assert!(f64_nan >= OrderedFloat(-100000.0)); + assert!(OrderedFloat(-100.0) < f64_nan); + assert!(OrderedFloat(-100.0) <= f64_nan); + assert!(f64_nan > OrderedFloat(Float::infinity())); + assert!(f64_nan >= OrderedFloat(Float::infinity())); + assert!(f64_nan > OrderedFloat(Float::neg_infinity())); + assert!(f64_nan >= OrderedFloat(Float::neg_infinity())); +} + +#[test] +fn not_nan32_compare_regular_floats() { + assert_eq!(NotNaN::from(7.0f32).cmp(&NotNaN::from(7.0)), Equal); + assert_eq!(NotNaN::from(8.0f32).cmp(&NotNaN::from(7.0)), Greater); + assert_eq!(NotNaN::from(4.0f32).cmp(&NotNaN::from(7.0)), Less); +} + +#[test] +fn not_nan32_fail_when_constructing_with_nan() { + let f32_nan: f32 = Float::nan(); + assert!(NotNaN::new(f32_nan).is_err()); +} + +#[test] +fn not_nan32_calculate_correctly() { + assert_eq!( + *(NotNaN::from(5.0f32) + NotNaN::from(4.0f32)), + 5.0f32 + 4.0f32 + ); + assert_eq!(*(NotNaN::from(5.0f32) + 4.0f32), 5.0f32 + 4.0f32); + assert_eq!( + *(NotNaN::from(5.0f32) - NotNaN::from(4.0f32)), + 5.0f32 - 4.0f32 + ); + assert_eq!(*(NotNaN::from(5.0f32) - 4.0f32), 5.0f32 - 4.0f32); + assert_eq!( + *(NotNaN::from(5.0f32) * NotNaN::from(4.0f32)), + 5.0f32 * 4.0f32 + ); + assert_eq!(*(NotNaN::from(5.0f32) * 4.0f32), 5.0f32 * 4.0f32); + assert_eq!( + *(NotNaN::from(8.0f32) / NotNaN::from(4.0f32)), + 8.0f32 / 4.0f32 + ); + assert_eq!(*(NotNaN::from(8.0f32) / 4.0f32), 8.0f32 / 4.0f32); + assert_eq!( + *(NotNaN::from(8.0f32) % NotNaN::from(4.0f32)), + 8.0f32 % 4.0f32 + ); + assert_eq!(*(NotNaN::from(8.0f32) % 4.0f32), 8.0f32 % 4.0f32); + assert_eq!(*(-NotNaN::from(1.0f32)), -1.0f32); + + assert!(panic::catch_unwind(|| NotNaN::from(0.0f32) + f32::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNaN::from(0.0f32) - f32::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNaN::from(0.0f32) * f32::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNaN::from(0.0f32) / f32::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNaN::from(0.0f32) % f32::NAN).is_err()); + + let mut number = NotNaN::from(5.0f32); + number += NotNaN::from(4.0f32); + assert_eq!(*number, 9.0f32); + number -= NotNaN::from(4.0f32); + assert_eq!(*number, 5.0f32); + number *= NotNaN::from(4.0f32); + assert_eq!(*number, 20.0f32); + number /= NotNaN::from(4.0f32); + assert_eq!(*number, 5.0f32); + number %= NotNaN::from(4.0f32); + assert_eq!(*number, 1.0f32); + + number = NotNaN::from(5.0f32); + number += 4.0f32; + assert_eq!(*number, 9.0f32); + number -= 4.0f32; + assert_eq!(*number, 5.0f32); + number *= 4.0f32; + assert_eq!(*number, 20.0f32); + number /= 4.0f32; + assert_eq!(*number, 5.0f32); + number %= 4.0f32; + assert_eq!(*number, 1.0f32); + + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNaN::from(0.0f32); + tmp += f32::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNaN::from(0.0f32); + tmp -= f32::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNaN::from(0.0f32); + tmp *= f32::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNaN::from(0.0f32); + tmp /= f32::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNaN::from(0.0f32); + tmp %= f32::NAN; + }).is_err() + ); +} + +#[test] +fn not_nan64_compare_regular_floats() { + assert_eq!(NotNaN::from(7.0f64).cmp(&NotNaN::from(7.0)), Equal); + assert_eq!(NotNaN::from(8.0f64).cmp(&NotNaN::from(7.0)), Greater); + assert_eq!(NotNaN::from(4.0f64).cmp(&NotNaN::from(7.0)), Less); +} + +#[test] +fn not_nan64_fail_when_constructing_with_nan() { + let f64_nan: f64 = Float::nan(); + assert!(NotNaN::new(f64_nan).is_err()); +} + +#[test] +fn not_nan64_calculate_correctly() { + assert_eq!( + *(NotNaN::from(5.0f64) + NotNaN::from(4.0f64)), + 5.0f64 + 4.0f64 + ); + assert_eq!(*(NotNaN::from(5.0f64) + 4.0f64), 5.0f64 + 4.0f64); + assert_eq!( + *(NotNaN::from(5.0f64) - NotNaN::from(4.0f64)), + 5.0f64 - 4.0f64 + ); + assert_eq!(*(NotNaN::from(5.0f64) - 4.0f64), 5.0f64 - 4.0f64); + assert_eq!( + *(NotNaN::from(5.0f64) * NotNaN::from(4.0f64)), + 5.0f64 * 4.0f64 + ); + assert_eq!(*(NotNaN::from(5.0f64) * 4.0f64), 5.0f64 * 4.0f64); + assert_eq!( + *(NotNaN::from(8.0f64) / NotNaN::from(4.0f64)), + 8.0f64 / 4.0f64 + ); + assert_eq!(*(NotNaN::from(8.0f64) / 4.0f64), 8.0f64 / 4.0f64); + assert_eq!( + *(NotNaN::from(8.0f64) % NotNaN::from(4.0f64)), + 8.0f64 % 4.0f64 + ); + assert_eq!(*(NotNaN::from(8.0f64) % 4.0f64), 8.0f64 % 4.0f64); + assert_eq!(*(-NotNaN::from(1.0f64)), -1.0f64); + + assert!(panic::catch_unwind(|| NotNaN::from(0.0f64) + f64::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNaN::from(0.0f64) - f64::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNaN::from(0.0f64) * f64::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNaN::from(0.0f64) / f64::NAN).is_err()); + assert!(panic::catch_unwind(|| NotNaN::from(0.0f64) % f64::NAN).is_err()); + + let mut number = NotNaN::from(5.0f64); + number += NotNaN::from(4.0f64); + assert_eq!(*number, 9.0f64); + number -= NotNaN::from(4.0f64); + assert_eq!(*number, 5.0f64); + number *= NotNaN::from(4.0f64); + assert_eq!(*number, 20.0f64); + number /= NotNaN::from(4.0f64); + assert_eq!(*number, 5.0f64); + number %= NotNaN::from(4.0f64); + assert_eq!(*number, 1.0f64); + + number = NotNaN::from(5.0f64); + number += 4.0f64; + assert_eq!(*number, 9.0f64); + number -= 4.0f64; + assert_eq!(*number, 5.0f64); + number *= 4.0f64; + assert_eq!(*number, 20.0f64); + number /= 4.0f64; + assert_eq!(*number, 5.0f64); + number %= 4.0f64; + assert_eq!(*number, 1.0f64); + + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNaN::from(0.0f64); + tmp += f64::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNaN::from(0.0f64); + tmp -= f64::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNaN::from(0.0f64); + tmp *= f64::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNaN::from(0.0f64); + tmp /= f64::NAN; + }).is_err() + ); + assert!( + panic::catch_unwind(|| { + let mut tmp = NotNaN::from(0.0f64); + tmp %= f64::NAN; + }).is_err() + ); +} + +#[test] +fn not_nan64_zero() { + assert_eq!(NotNaN::::zero(), NotNaN::from(0.0f64)); + assert!(NotNaN::::zero().is_zero()); +} + +#[test] +fn not_nan64_one() { + assert_eq!(NotNaN::::one(), NotNaN::from(1.0f64)) +} + +#[test] +fn not_nan64_bounded() { + assert_eq!(NotNaN::::min_value(), NotNaN::from(::min_value())); + assert_eq!(NotNaN::::max_value(), NotNaN::from(::max_value())); +} + +#[test] +fn not_nan64_from_primitive() { + assert_eq!(NotNaN::::from_i8(42i8), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_u8(42u8), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_i16(42i16), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_u16(42u16), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_i32(42i32), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_u32(42u32), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_i64(42i64), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_u64(42u64), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_isize(42isize), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_usize(42usize), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_f64(42f64), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_f64(42f64), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_f64(42f64), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_f64(42f64), Some(NotNaN::from(42.0))); + assert_eq!(NotNaN::::from_f64(Float::nan()), None); + assert_eq!(NotNaN::::from_f64(Float::nan()), None); +} + +#[test] +fn not_nan64_to_primitive() { + let x = NotNaN::from(42.0f64); + assert_eq!(x.to_u8(), Some(42u8)); + assert_eq!(x.to_i8(), Some(42i8)); + assert_eq!(x.to_u16(), Some(42u16)); + assert_eq!(x.to_i16(), Some(42i16)); + assert_eq!(x.to_u32(), Some(42u32)); + assert_eq!(x.to_i32(), Some(42i32)); + assert_eq!(x.to_u64(), Some(42u64)); + assert_eq!(x.to_i64(), Some(42i64)); + assert_eq!(x.to_usize(), Some(42usize)); + assert_eq!(x.to_isize(), Some(42isize)); + assert_eq!(x.to_f64(), Some(42f64)); + assert_eq!(x.to_f64(), Some(42f64)); + assert_eq!(x.to_f64(), Some(42f64)); + assert_eq!(x.to_f64(), Some(42f64)); +} + +#[test] +fn not_nan64_num() { + assert_eq!(NotNaN::::from_str_radix("42.0", 10).unwrap(), NotNaN::from(42.0f64)); + assert!(NotNaN::::from_str_radix("NaN", 10).is_err()); +} + +#[test] +fn not_nan64_signed() { + assert_eq!(NotNaN::from(42f64).abs(), NotNaN::from(42f64)); + assert_eq!(NotNaN::from(-42f64).abs(), NotNaN::from(42f64)); + + assert_eq!(NotNaN::from(50f64).abs_sub(&NotNaN::from(8f64)), NotNaN::from(42f64)); + assert_eq!(NotNaN::from(8f64).abs_sub(&NotNaN::from(50f64)), NotNaN::from(0f64)); +} + +#[test] +fn not_nan64_num_cast() { + assert_eq!( as num_traits::NumCast>::from(42), Some(NotNaN::from(42f64))); + assert_eq!( as num_traits::NumCast>::from(f64::nan()), None); +} + +#[test] +fn hash_zero_and_neg_zero_to_the_same_hc() { + let state = RandomState::new(); + let mut h1 = state.build_hasher(); + let mut h2 = state.build_hasher(); + OrderedFloat::from(0f64).hash(&mut h1); + OrderedFloat::from(-0f64).hash(&mut h2); + assert_eq!(h1.finish(), h2.finish()); +} + +#[test] +fn hash_inf_and_neg_inf_to_different_hcs() { + let state = RandomState::new(); + let mut h1 = state.build_hasher(); + let mut h2 = state.build_hasher(); + OrderedFloat::from(f64::INFINITY).hash(&mut h1); + OrderedFloat::from(f64::NEG_INFINITY).hash(&mut h2); + assert!(h1.finish() != h2.finish()); +} + +#[test] +fn hash_is_good_for_whole_numbers() { + let state = RandomState::new(); + let limit = 10000; + + let mut set = ::std::collections::HashSet::with_capacity(limit); + for i in 0..limit { + let mut h = state.build_hasher(); + OrderedFloat::from(i as f64).hash(&mut h); + set.insert(h.finish()); + } + + // This allows 100 collisions, which is far too + // many, but should guard against transient issues + // that will result from using RandomState + let pct_unique = set.len() as f64 / limit as f64; + assert!(0.99f64 < pct_unique, "percent-unique={}", pct_unique); +} + +#[test] +fn hash_is_good_for_fractional_numbers() { + let state = RandomState::new(); + let limit = 10000; + + let mut set = ::std::collections::HashSet::with_capacity(limit); + for i in 0..limit { + let mut h = state.build_hasher(); + OrderedFloat::from(i as f64 * (1f64 / limit as f64)).hash(&mut h); + set.insert(h.finish()); + } + + // This allows 100 collisions, which is far too + // many, but should guard against transient issues + // that will result from using RandomState + let pct_unique = set.len() as f64 / limit as f64; + assert!(0.99f64 < pct_unique, "percent-unique={}", pct_unique); +} diff --git a/third_party/cargo/vendor/owning_ref-0.4.0/.cargo-checksum.json b/third_party/cargo/vendor/owning_ref-0.4.0/.cargo-checksum.json new file mode 100644 index 0000000..636230f --- /dev/null +++ b/third_party/cargo/vendor/owning_ref-0.4.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"9cc8936f2504375b24b88060b766a908e69690246cd063138b3a9b39287640d7","LICENSE":"90bc15ed094593083fd129fdd1a03607be80fe8839c5564616a5961ab7f7a194","README.md":"a479bb465878f3cbb8d53d2f42a26ac309e121d7c635956b7547a6bdfedce5d4","src/lib.rs":"e1e523638bea245fcf00b6643c61f856f2404f4d5d9ed0c230a6c4d2d8550b1c"},"package":"49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"} \ No newline at end of file diff --git a/third_party/cargo/vendor/owning_ref-0.4.0/BUILD b/third_party/cargo/vendor/owning_ref-0.4.0/BUILD new file mode 100644 index 0000000..57c72d5 --- /dev/null +++ b/third_party/cargo/vendor/owning_ref-0.4.0/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "owning_ref", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/stable_deref_trait-1.1.1:stable_deref_trait", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/owning_ref-0.4.0/Cargo.toml b/third_party/cargo/vendor/owning_ref-0.4.0/Cargo.toml new file mode 100644 index 0000000..4ef64ea --- /dev/null +++ b/third_party/cargo/vendor/owning_ref-0.4.0/Cargo.toml @@ -0,0 +1,24 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "owning_ref" +version = "0.4.0" +authors = ["Marvin Löbel "] +description = "A library for creating references that carry their owner with them." +documentation = "http://kimundi.github.io/owning-ref-rs/owning_ref/index.html" +readme = "README.md" +keywords = ["reference", "sibling", "field", "owning"] +license = "MIT" +repository = "https://github.com/Kimundi/owning-ref-rs" +[dependencies.stable_deref_trait] +version = "1.0.0" diff --git a/third_party/cargo/vendor/owning_ref-0.4.0/LICENSE b/third_party/cargo/vendor/owning_ref-0.4.0/LICENSE new file mode 100644 index 0000000..dff72d1 --- /dev/null +++ b/third_party/cargo/vendor/owning_ref-0.4.0/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Marvin Löbel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/owning_ref-0.4.0/README.md b/third_party/cargo/vendor/owning_ref-0.4.0/README.md new file mode 100644 index 0000000..cd14b2e --- /dev/null +++ b/third_party/cargo/vendor/owning_ref-0.4.0/README.md @@ -0,0 +1,67 @@ +owning-ref-rs +============== + +A library for creating references that carry their owner with them. + +This can sometimes be useful because Rust borrowing rules normally prevent +moving a type that has been borrowed from. For example, this kind of code gets rejected: + +```rust +fn return_owned_and_referenced<'a>() -> (Vec, &'a [u8]) { + let v = vec![1, 2, 3, 4]; + let s = &v[1..3]; + (v, s) +} +``` + +This library enables this safe usage by keeping the owner and the reference +bundled together in a wrapper type that ensure that lifetime constraint: + +```rust +fn return_owned_and_referenced() -> OwningRef, [u8]> { + let v = vec![1, 2, 3, 4]; + let or = OwningRef::new(v); + let or = or.map(|v| &v[1..3]); + or +} +``` + +[![Travis-CI Status](https://travis-ci.org/Kimundi/owning-ref-rs.png?branch=master)](https://travis-ci.org/Kimundi/owning-ref-rs) + +# Getting Started + +[owning-ref-rs is available on crates.io](https://crates.io/crates/owning_ref). +It is recommended to look there for the newest released version, as well as links to the newest builds of the docs. + +At the point of the last update of this README, the latest published version could be used like this: + +Add the following dependency to your Cargo manifest... + +```toml +[dependencies] +owning_ref = "0.3" +``` + +...and see the [docs](http://kimundi.github.io/owning-ref-rs/owning_ref/index.html) for how to use it. + +# Example + +```rust +extern crate owning_ref; +use owning_ref::BoxRef; + +fn main() { + // Create an array owned by a Box. + let arr = Box::new([1, 2, 3, 4]) as Box<[i32]>; + + // Transfer into a BoxRef. + let arr: BoxRef<[i32]> = BoxRef::new(arr); + assert_eq!(&*arr, &[1, 2, 3, 4]); + + // We can slice the array without losing ownership or changing type. + let arr: BoxRef<[i32]> = arr.map(|arr| &arr[1..3]); + assert_eq!(&*arr, &[2, 3]); + + // Also works for Arc, Rc, String and Vec! +} +``` diff --git a/third_party/cargo/vendor/owning_ref-0.4.0/src/lib.rs b/third_party/cargo/vendor/owning_ref-0.4.0/src/lib.rs new file mode 100644 index 0000000..7a29136 --- /dev/null +++ b/third_party/cargo/vendor/owning_ref-0.4.0/src/lib.rs @@ -0,0 +1,1918 @@ +#![warn(missing_docs)] + +/*! +# An owning reference. + +This crate provides the _owning reference_ types `OwningRef` and `OwningRefMut` +that enables it to bundle a reference together with the owner of the data it points to. +This allows moving and dropping of a `OwningRef` without needing to recreate the reference. + +This can sometimes be useful because Rust borrowing rules normally prevent +moving a type that has been moved from. For example, this kind of code gets rejected: + +```rust,ignore +fn return_owned_and_referenced<'a>() -> (Vec, &'a [u8]) { + let v = vec![1, 2, 3, 4]; + let s = &v[1..3]; + (v, s) +} +``` + +Even though, from a memory-layout point of view, this can be entirely safe +if the new location of the vector still lives longer than the lifetime `'a` +of the reference because the backing allocation of the vector does not change. + +This library enables this safe usage by keeping the owner and the reference +bundled together in a wrapper type that ensure that lifetime constraint: + +```rust +# extern crate owning_ref; +# use owning_ref::OwningRef; +# fn main() { +fn return_owned_and_referenced() -> OwningRef, [u8]> { + let v = vec![1, 2, 3, 4]; + let or = OwningRef::new(v); + let or = or.map(|v| &v[1..3]); + or +} +# } +``` + +It works by requiring owner types to dereference to stable memory locations +and preventing mutable access to root containers, which in practice requires heap allocation +as provided by `Box`, `Rc`, etc. + +Also provided are typedefs for common owner type combinations, +which allow for less verbose type signatures. For example, `BoxRef` instead of `OwningRef, T>`. + +The crate also provides the more advanced `OwningHandle` type, +which allows more freedom in bundling a dependent handle object +along with the data it depends on, at the cost of some unsafe needed in the API. +See the documentation around `OwningHandle` for more details. + +# Examples + +## Basics + +``` +extern crate owning_ref; +use owning_ref::BoxRef; + +fn main() { + // Create an array owned by a Box. + let arr = Box::new([1, 2, 3, 4]) as Box<[i32]>; + + // Transfer into a BoxRef. + let arr: BoxRef<[i32]> = BoxRef::new(arr); + assert_eq!(&*arr, &[1, 2, 3, 4]); + + // We can slice the array without losing ownership or changing type. + let arr: BoxRef<[i32]> = arr.map(|arr| &arr[1..3]); + assert_eq!(&*arr, &[2, 3]); + + // Also works for Arc, Rc, String and Vec! +} +``` + +## Caching a reference to a struct field + +``` +extern crate owning_ref; +use owning_ref::BoxRef; + +fn main() { + struct Foo { + tag: u32, + x: u16, + y: u16, + z: u16, + } + let foo = Foo { tag: 1, x: 100, y: 200, z: 300 }; + + let or = BoxRef::new(Box::new(foo)).map(|foo| { + match foo.tag { + 0 => &foo.x, + 1 => &foo.y, + 2 => &foo.z, + _ => panic!(), + } + }); + + assert_eq!(*or, 200); +} +``` + +## Caching a reference to an entry in a vector + +``` +extern crate owning_ref; +use owning_ref::VecRef; + +fn main() { + let v = VecRef::new(vec![1, 2, 3, 4, 5]).map(|v| &v[3]); + assert_eq!(*v, 4); +} +``` + +## Caching a subslice of a String + +``` +extern crate owning_ref; +use owning_ref::StringRef; + +fn main() { + let s = StringRef::new("hello world".to_owned()) + .map(|s| s.split(' ').nth(1).unwrap()); + + assert_eq!(&*s, "world"); +} +``` + +## Reference counted slices that share ownership of the backing storage + +``` +extern crate owning_ref; +use owning_ref::RcRef; +use std::rc::Rc; + +fn main() { + let rc: RcRef<[i32]> = RcRef::new(Rc::new([1, 2, 3, 4]) as Rc<[i32]>); + assert_eq!(&*rc, &[1, 2, 3, 4]); + + let rc_a: RcRef<[i32]> = rc.clone().map(|s| &s[0..2]); + let rc_b = rc.clone().map(|s| &s[1..3]); + let rc_c = rc.clone().map(|s| &s[2..4]); + assert_eq!(&*rc_a, &[1, 2]); + assert_eq!(&*rc_b, &[2, 3]); + assert_eq!(&*rc_c, &[3, 4]); + + let rc_c_a = rc_c.clone().map(|s| &s[1]); + assert_eq!(&*rc_c_a, &4); +} +``` + +## Atomic reference counted slices that share ownership of the backing storage + +``` +extern crate owning_ref; +use owning_ref::ArcRef; +use std::sync::Arc; + +fn main() { + use std::thread; + + fn par_sum(rc: ArcRef<[i32]>) -> i32 { + if rc.len() == 0 { + return 0; + } else if rc.len() == 1 { + return rc[0]; + } + let mid = rc.len() / 2; + let left = rc.clone().map(|s| &s[..mid]); + let right = rc.map(|s| &s[mid..]); + + let left = thread::spawn(move || par_sum(left)); + let right = thread::spawn(move || par_sum(right)); + + left.join().unwrap() + right.join().unwrap() + } + + let rc: Arc<[i32]> = Arc::new([1, 2, 3, 4]); + let rc: ArcRef<[i32]> = rc.into(); + + assert_eq!(par_sum(rc), 10); +} +``` + +## References into RAII locks + +``` +extern crate owning_ref; +use owning_ref::RefRef; +use std::cell::{RefCell, Ref}; + +fn main() { + let refcell = RefCell::new((1, 2, 3, 4)); + // Also works with Mutex and RwLock + + let refref = { + let refref = RefRef::new(refcell.borrow()).map(|x| &x.3); + assert_eq!(*refref, 4); + + // We move the RAII lock and the reference to one of + // the subfields in the data it guards here: + refref + }; + + assert_eq!(*refref, 4); + + drop(refref); + + assert_eq!(*refcell.borrow(), (1, 2, 3, 4)); +} +``` + +## Mutable reference + +When the owned container implements `DerefMut`, it is also possible to make +a _mutable owning reference_. (E.g. with `Box`, `RefMut`, `MutexGuard`) + +``` +extern crate owning_ref; +use owning_ref::RefMutRefMut; +use std::cell::{RefCell, RefMut}; + +fn main() { + let refcell = RefCell::new((1, 2, 3, 4)); + + let mut refmut_refmut = { + let mut refmut_refmut = RefMutRefMut::new(refcell.borrow_mut()).map_mut(|x| &mut x.3); + assert_eq!(*refmut_refmut, 4); + *refmut_refmut *= 2; + + refmut_refmut + }; + + assert_eq!(*refmut_refmut, 8); + *refmut_refmut *= 2; + + drop(refmut_refmut); + + assert_eq!(*refcell.borrow(), (1, 2, 3, 16)); +} +``` +*/ + +extern crate stable_deref_trait; +pub use stable_deref_trait::{StableDeref as StableAddress, CloneStableDeref as CloneStableAddress}; + +/// An owning reference. +/// +/// This wraps an owner `O` and a reference `&T` pointing +/// at something reachable from `O::Target` while keeping +/// the ability to move `self` around. +/// +/// The owner is usually a pointer that points at some base type. +/// +/// For more details and examples, see the module and method docs. +pub struct OwningRef { + owner: O, + reference: *const T, +} + +/// An mutable owning reference. +/// +/// This wraps an owner `O` and a reference `&mut T` pointing +/// at something reachable from `O::Target` while keeping +/// the ability to move `self` around. +/// +/// The owner is usually a pointer that points at some base type. +/// +/// For more details and examples, see the module and method docs. +pub struct OwningRefMut { + owner: O, + reference: *mut T, +} + +/// Helper trait for an erased concrete type an owner dereferences to. +/// This is used in form of a trait object for keeping +/// something around to (virtually) call the destructor. +pub trait Erased {} +impl Erased for T {} + +/// Helper trait for erasing the concrete type of what an owner derferences to, +/// for example `Box -> Box`. This would be unneeded with +/// higher kinded types support in the language. +pub unsafe trait IntoErased<'a> { + /// Owner with the dereference type substituted to `Erased`. + type Erased; + /// Perform the type erasure. + fn into_erased(self) -> Self::Erased; +} + +///////////////////////////////////////////////////////////////////////////// +// OwningRef +///////////////////////////////////////////////////////////////////////////// + +impl OwningRef { + /// Creates a new owning reference from a owner + /// initialized to the direct dereference of it. + /// + /// # Example + /// ``` + /// extern crate owning_ref; + /// use owning_ref::OwningRef; + /// + /// fn main() { + /// let owning_ref = OwningRef::new(Box::new(42)); + /// assert_eq!(*owning_ref, 42); + /// } + /// ``` + pub fn new(o: O) -> Self + where O: StableAddress, + O: Deref, + { + OwningRef { + reference: &*o, + owner: o, + } + } + + /// Like `new`, but doesn’t require `O` to implement the `StableAddress` trait. + /// Instead, the caller is responsible to make the same promises as implementing the trait. + /// + /// This is useful for cases where coherence rules prevents implementing the trait + /// without adding a dependency to this crate in a third-party library. + pub unsafe fn new_assert_stable_address(o: O) -> Self + where O: Deref, + { + OwningRef { + reference: &*o, + owner: o, + } + } + + /// Converts `self` into a new owning reference that points at something reachable + /// from the previous one. + /// + /// This can be a reference to a field of `U`, something reachable from a field of + /// `U`, or even something unrelated with a `'static` lifetime. + /// + /// # Example + /// ``` + /// extern crate owning_ref; + /// use owning_ref::OwningRef; + /// + /// fn main() { + /// let owning_ref = OwningRef::new(Box::new([1, 2, 3, 4])); + /// + /// // create a owning reference that points at the + /// // third element of the array. + /// let owning_ref = owning_ref.map(|array| &array[2]); + /// assert_eq!(*owning_ref, 3); + /// } + /// ``` + pub fn map(self, f: F) -> OwningRef + where O: StableAddress, + F: FnOnce(&T) -> &U + { + OwningRef { + reference: f(&self), + owner: self.owner, + } + } + + /// Tries to convert `self` into a new owning reference that points + /// at something reachable from the previous one. + /// + /// This can be a reference to a field of `U`, something reachable from a field of + /// `U`, or even something unrelated with a `'static` lifetime. + /// + /// # Example + /// ``` + /// extern crate owning_ref; + /// use owning_ref::OwningRef; + /// + /// fn main() { + /// let owning_ref = OwningRef::new(Box::new([1, 2, 3, 4])); + /// + /// // create a owning reference that points at the + /// // third element of the array. + /// let owning_ref = owning_ref.try_map(|array| { + /// if array[2] == 3 { Ok(&array[2]) } else { Err(()) } + /// }); + /// assert_eq!(*owning_ref.unwrap(), 3); + /// } + /// ``` + pub fn try_map(self, f: F) -> Result, E> + where O: StableAddress, + F: FnOnce(&T) -> Result<&U, E> + { + Ok(OwningRef { + reference: f(&self)?, + owner: self.owner, + }) + } + + /// Converts `self` into a new owning reference with a different owner type. + /// + /// The new owner type needs to still contain the original owner in some way + /// so that the reference into it remains valid. This function is marked unsafe + /// because the user needs to manually uphold this guarantee. + pub unsafe fn map_owner(self, f: F) -> OwningRef + where O: StableAddress, + P: StableAddress, + F: FnOnce(O) -> P + { + OwningRef { + reference: self.reference, + owner: f(self.owner), + } + } + + /// Converts `self` into a new owning reference where the owner is wrapped + /// in an additional `Box`. + /// + /// This can be used to safely erase the owner of any `OwningRef` + /// to a `OwningRef, T>`. + pub fn map_owner_box(self) -> OwningRef, T> { + OwningRef { + reference: self.reference, + owner: Box::new(self.owner), + } + } + + /// Erases the concrete base type of the owner with a trait object. + /// + /// This allows mixing of owned references with different owner base types. + /// + /// # Example + /// ``` + /// extern crate owning_ref; + /// use owning_ref::{OwningRef, Erased}; + /// + /// fn main() { + /// // NB: Using the concrete types here for explicitnes. + /// // For less verbose code type aliases like `BoxRef` are provided. + /// + /// let owning_ref_a: OwningRef, [i32; 4]> + /// = OwningRef::new(Box::new([1, 2, 3, 4])); + /// + /// let owning_ref_b: OwningRef>, Vec<(i32, bool)>> + /// = OwningRef::new(Box::new(vec![(0, false), (1, true)])); + /// + /// let owning_ref_a: OwningRef, i32> + /// = owning_ref_a.map(|a| &a[0]); + /// + /// let owning_ref_b: OwningRef>, i32> + /// = owning_ref_b.map(|a| &a[1].0); + /// + /// let owning_refs: [OwningRef, i32>; 2] + /// = [owning_ref_a.erase_owner(), owning_ref_b.erase_owner()]; + /// + /// assert_eq!(*owning_refs[0], 1); + /// assert_eq!(*owning_refs[1], 1); + /// } + /// ``` + pub fn erase_owner<'a>(self) -> OwningRef + where O: IntoErased<'a>, + { + OwningRef { + reference: self.reference, + owner: self.owner.into_erased(), + } + } + + // TODO: wrap_owner + + /// A reference to the underlying owner. + pub fn as_owner(&self) -> &O { + &self.owner + } + + /// Discards the reference and retrieves the owner. + pub fn into_owner(self) -> O { + self.owner + } +} + +impl OwningRefMut { + /// Creates a new owning reference from a owner + /// initialized to the direct dereference of it. + /// + /// # Example + /// ``` + /// extern crate owning_ref; + /// use owning_ref::OwningRefMut; + /// + /// fn main() { + /// let owning_ref_mut = OwningRefMut::new(Box::new(42)); + /// assert_eq!(*owning_ref_mut, 42); + /// } + /// ``` + pub fn new(mut o: O) -> Self + where O: StableAddress, + O: DerefMut, + { + OwningRefMut { + reference: &mut *o, + owner: o, + } + } + + /// Like `new`, but doesn’t require `O` to implement the `StableAddress` trait. + /// Instead, the caller is responsible to make the same promises as implementing the trait. + /// + /// This is useful for cases where coherence rules prevents implementing the trait + /// without adding a dependency to this crate in a third-party library. + pub unsafe fn new_assert_stable_address(mut o: O) -> Self + where O: DerefMut, + { + OwningRefMut { + reference: &mut *o, + owner: o, + } + } + + /// Converts `self` into a new _shared_ owning reference that points at + /// something reachable from the previous one. + /// + /// This can be a reference to a field of `U`, something reachable from a field of + /// `U`, or even something unrelated with a `'static` lifetime. + /// + /// # Example + /// ``` + /// extern crate owning_ref; + /// use owning_ref::OwningRefMut; + /// + /// fn main() { + /// let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4])); + /// + /// // create a owning reference that points at the + /// // third element of the array. + /// let owning_ref = owning_ref_mut.map(|array| &array[2]); + /// assert_eq!(*owning_ref, 3); + /// } + /// ``` + pub fn map(mut self, f: F) -> OwningRef + where O: StableAddress, + F: FnOnce(&mut T) -> &U + { + OwningRef { + reference: f(&mut self), + owner: self.owner, + } + } + + /// Converts `self` into a new _mutable_ owning reference that points at + /// something reachable from the previous one. + /// + /// This can be a reference to a field of `U`, something reachable from a field of + /// `U`, or even something unrelated with a `'static` lifetime. + /// + /// # Example + /// ``` + /// extern crate owning_ref; + /// use owning_ref::OwningRefMut; + /// + /// fn main() { + /// let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4])); + /// + /// // create a owning reference that points at the + /// // third element of the array. + /// let owning_ref_mut = owning_ref_mut.map_mut(|array| &mut array[2]); + /// assert_eq!(*owning_ref_mut, 3); + /// } + /// ``` + pub fn map_mut(mut self, f: F) -> OwningRefMut + where O: StableAddress, + F: FnOnce(&mut T) -> &mut U + { + OwningRefMut { + reference: f(&mut self), + owner: self.owner, + } + } + + /// Tries to convert `self` into a new _shared_ owning reference that points + /// at something reachable from the previous one. + /// + /// This can be a reference to a field of `U`, something reachable from a field of + /// `U`, or even something unrelated with a `'static` lifetime. + /// + /// # Example + /// ``` + /// extern crate owning_ref; + /// use owning_ref::OwningRefMut; + /// + /// fn main() { + /// let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4])); + /// + /// // create a owning reference that points at the + /// // third element of the array. + /// let owning_ref = owning_ref_mut.try_map(|array| { + /// if array[2] == 3 { Ok(&array[2]) } else { Err(()) } + /// }); + /// assert_eq!(*owning_ref.unwrap(), 3); + /// } + /// ``` + pub fn try_map(mut self, f: F) -> Result, E> + where O: StableAddress, + F: FnOnce(&mut T) -> Result<&U, E> + { + Ok(OwningRef { + reference: f(&mut self)?, + owner: self.owner, + }) + } + + /// Tries to convert `self` into a new _mutable_ owning reference that points + /// at something reachable from the previous one. + /// + /// This can be a reference to a field of `U`, something reachable from a field of + /// `U`, or even something unrelated with a `'static` lifetime. + /// + /// # Example + /// ``` + /// extern crate owning_ref; + /// use owning_ref::OwningRefMut; + /// + /// fn main() { + /// let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4])); + /// + /// // create a owning reference that points at the + /// // third element of the array. + /// let owning_ref_mut = owning_ref_mut.try_map_mut(|array| { + /// if array[2] == 3 { Ok(&mut array[2]) } else { Err(()) } + /// }); + /// assert_eq!(*owning_ref_mut.unwrap(), 3); + /// } + /// ``` + pub fn try_map_mut(mut self, f: F) -> Result, E> + where O: StableAddress, + F: FnOnce(&mut T) -> Result<&mut U, E> + { + Ok(OwningRefMut { + reference: f(&mut self)?, + owner: self.owner, + }) + } + + /// Converts `self` into a new owning reference with a different owner type. + /// + /// The new owner type needs to still contain the original owner in some way + /// so that the reference into it remains valid. This function is marked unsafe + /// because the user needs to manually uphold this guarantee. + pub unsafe fn map_owner(self, f: F) -> OwningRefMut + where O: StableAddress, + P: StableAddress, + F: FnOnce(O) -> P + { + OwningRefMut { + reference: self.reference, + owner: f(self.owner), + } + } + + /// Converts `self` into a new owning reference where the owner is wrapped + /// in an additional `Box`. + /// + /// This can be used to safely erase the owner of any `OwningRefMut` + /// to a `OwningRefMut, T>`. + pub fn map_owner_box(self) -> OwningRefMut, T> { + OwningRefMut { + reference: self.reference, + owner: Box::new(self.owner), + } + } + + /// Erases the concrete base type of the owner with a trait object. + /// + /// This allows mixing of owned references with different owner base types. + /// + /// # Example + /// ``` + /// extern crate owning_ref; + /// use owning_ref::{OwningRefMut, Erased}; + /// + /// fn main() { + /// // NB: Using the concrete types here for explicitnes. + /// // For less verbose code type aliases like `BoxRef` are provided. + /// + /// let owning_ref_mut_a: OwningRefMut, [i32; 4]> + /// = OwningRefMut::new(Box::new([1, 2, 3, 4])); + /// + /// let owning_ref_mut_b: OwningRefMut>, Vec<(i32, bool)>> + /// = OwningRefMut::new(Box::new(vec![(0, false), (1, true)])); + /// + /// let owning_ref_mut_a: OwningRefMut, i32> + /// = owning_ref_mut_a.map_mut(|a| &mut a[0]); + /// + /// let owning_ref_mut_b: OwningRefMut>, i32> + /// = owning_ref_mut_b.map_mut(|a| &mut a[1].0); + /// + /// let owning_refs_mut: [OwningRefMut, i32>; 2] + /// = [owning_ref_mut_a.erase_owner(), owning_ref_mut_b.erase_owner()]; + /// + /// assert_eq!(*owning_refs_mut[0], 1); + /// assert_eq!(*owning_refs_mut[1], 1); + /// } + /// ``` + pub fn erase_owner<'a>(self) -> OwningRefMut + where O: IntoErased<'a>, + { + OwningRefMut { + reference: self.reference, + owner: self.owner.into_erased(), + } + } + + // TODO: wrap_owner + + /// A reference to the underlying owner. + pub fn as_owner(&self) -> &O { + &self.owner + } + + /// A mutable reference to the underlying owner. + pub fn as_owner_mut(&mut self) -> &mut O { + &mut self.owner + } + + /// Discards the reference and retrieves the owner. + pub fn into_owner(self) -> O { + self.owner + } +} + +///////////////////////////////////////////////////////////////////////////// +// OwningHandle +///////////////////////////////////////////////////////////////////////////// + +use std::ops::{Deref, DerefMut}; + +/// `OwningHandle` is a complement to `OwningRef`. Where `OwningRef` allows +/// consumers to pass around an owned object and a dependent reference, +/// `OwningHandle` contains an owned object and a dependent _object_. +/// +/// `OwningHandle` can encapsulate a `RefMut` along with its associated +/// `RefCell`, or an `RwLockReadGuard` along with its associated `RwLock`. +/// However, the API is completely generic and there are no restrictions on +/// what types of owning and dependent objects may be used. +/// +/// `OwningHandle` is created by passing an owner object (which dereferences +/// to a stable address) along with a callback which receives a pointer to +/// that stable location. The callback may then dereference the pointer and +/// mint a dependent object, with the guarantee that the returned object will +/// not outlive the referent of the pointer. +/// +/// Since the callback needs to dereference a raw pointer, it requires `unsafe` +/// code. To avoid forcing this unsafety on most callers, the `ToHandle` trait is +/// implemented for common data structures. Types that implement `ToHandle` can +/// be wrapped into an `OwningHandle` without passing a callback. +pub struct OwningHandle + where O: StableAddress, H: Deref, +{ + handle: H, + _owner: O, +} + +impl Deref for OwningHandle + where O: StableAddress, H: Deref, +{ + type Target = H::Target; + fn deref(&self) -> &H::Target { + self.handle.deref() + } +} + +unsafe impl StableAddress for OwningHandle + where O: StableAddress, H: StableAddress, +{} + +impl DerefMut for OwningHandle + where O: StableAddress, H: DerefMut, +{ + fn deref_mut(&mut self) -> &mut H::Target { + self.handle.deref_mut() + } +} + +/// Trait to implement the conversion of owner to handle for common types. +pub trait ToHandle { + /// The type of handle to be encapsulated by the OwningHandle. + type Handle: Deref; + + /// Given an appropriately-long-lived pointer to ourselves, create a + /// handle to be encapsulated by the `OwningHandle`. + unsafe fn to_handle(x: *const Self) -> Self::Handle; +} + +/// Trait to implement the conversion of owner to mutable handle for common types. +pub trait ToHandleMut { + /// The type of handle to be encapsulated by the OwningHandle. + type HandleMut: DerefMut; + + /// Given an appropriately-long-lived pointer to ourselves, create a + /// mutable handle to be encapsulated by the `OwningHandle`. + unsafe fn to_handle_mut(x: *const Self) -> Self::HandleMut; +} + +impl OwningHandle + where O: StableAddress, O::Target: ToHandle, H: Deref, +{ + /// Create a new `OwningHandle` for a type that implements `ToHandle`. For types + /// that don't implement `ToHandle`, callers may invoke `new_with_fn`, which accepts + /// a callback to perform the conversion. + pub fn new(o: O) -> Self { + OwningHandle::new_with_fn(o, |x| unsafe { O::Target::to_handle(x) }) + } +} + +impl OwningHandle + where O: StableAddress, O::Target: ToHandleMut, H: DerefMut, +{ + /// Create a new mutable `OwningHandle` for a type that implements `ToHandleMut`. + pub fn new_mut(o: O) -> Self { + OwningHandle::new_with_fn(o, |x| unsafe { O::Target::to_handle_mut(x) }) + } +} + +impl OwningHandle + where O: StableAddress, H: Deref, +{ + /// Create a new OwningHandle. The provided callback will be invoked with + /// a pointer to the object owned by `o`, and the returned value is stored + /// as the object to which this `OwningHandle` will forward `Deref` and + /// `DerefMut`. + pub fn new_with_fn(o: O, f: F) -> Self + where F: FnOnce(*const O::Target) -> H + { + let h: H; + { + h = f(o.deref() as *const O::Target); + } + + OwningHandle { + handle: h, + _owner: o, + } + } + + /// Create a new OwningHandle. The provided callback will be invoked with + /// a pointer to the object owned by `o`, and the returned value is stored + /// as the object to which this `OwningHandle` will forward `Deref` and + /// `DerefMut`. + pub fn try_new(o: O, f: F) -> Result + where F: FnOnce(*const O::Target) -> Result + { + let h: H; + { + h = f(o.deref() as *const O::Target)?; + } + + Ok(OwningHandle { + handle: h, + _owner: o, + }) + } + + /// A getter for the underlying owner. + pub fn as_owner(&self) -> &O { + &self._owner + } + + /// Discards the dependent object and returns the owner. + pub fn into_owner(self) -> O { + self._owner + } +} + +///////////////////////////////////////////////////////////////////////////// +// std traits +///////////////////////////////////////////////////////////////////////////// + +use std::convert::From; +use std::fmt::{self, Debug}; +use std::marker::{Send, Sync}; +use std::cmp::{Eq, PartialEq, Ord, PartialOrd, Ordering}; +use std::hash::{Hash, Hasher}; +use std::borrow::Borrow; + +impl Deref for OwningRef { + type Target = T; + + fn deref(&self) -> &T { + unsafe { + &*self.reference + } + } +} + +impl Deref for OwningRefMut { + type Target = T; + + fn deref(&self) -> &T { + unsafe { + &*self.reference + } + } +} + +impl DerefMut for OwningRefMut { + fn deref_mut(&mut self) -> &mut T { + unsafe { + &mut *self.reference + } + } +} + +unsafe impl StableAddress for OwningRef {} + +unsafe impl StableAddress for OwningRefMut {} + +impl AsRef for OwningRef { + fn as_ref(&self) -> &T { + &*self + } +} + +impl AsRef for OwningRefMut { + fn as_ref(&self) -> &T { + &*self + } +} + +impl AsMut for OwningRefMut { + fn as_mut(&mut self) -> &mut T { + &mut *self + } +} + +impl Borrow for OwningRef { + fn borrow(&self) -> &T { + &*self + } +} + +impl From for OwningRef + where O: StableAddress, + O: Deref, +{ + fn from(owner: O) -> Self { + OwningRef::new(owner) + } +} + +impl From for OwningRefMut + where O: StableAddress, + O: DerefMut +{ + fn from(owner: O) -> Self { + OwningRefMut::new(owner) + } +} + +impl From> for OwningRef + where O: StableAddress, + O: DerefMut +{ + fn from(other: OwningRefMut) -> Self { + OwningRef { + owner: other.owner, + reference: other.reference, + } + } +} + +// ^ FIXME: Is a Into impl for calling into_owner() possible as well? + +impl Debug for OwningRef + where O: Debug, + T: Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(f, + "OwningRef {{ owner: {:?}, reference: {:?} }}", + self.as_owner(), + &**self) + } +} + +impl Debug for OwningRefMut + where O: Debug, + T: Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(f, + "OwningRefMut {{ owner: {:?}, reference: {:?} }}", + self.as_owner(), + &**self) + } +} + +impl Clone for OwningRef + where O: CloneStableAddress, +{ + fn clone(&self) -> Self { + OwningRef { + owner: self.owner.clone(), + reference: self.reference, + } + } +} + +unsafe impl CloneStableAddress for OwningRef + where O: CloneStableAddress {} + +unsafe impl Send for OwningRef + where O: Send, for<'a> (&'a T): Send {} +unsafe impl Sync for OwningRef + where O: Sync, for<'a> (&'a T): Sync {} + +unsafe impl Send for OwningRefMut + where O: Send, for<'a> (&'a mut T): Send {} +unsafe impl Sync for OwningRefMut + where O: Sync, for<'a> (&'a mut T): Sync {} + +impl Debug for Erased { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(f, "",) + } +} + +impl PartialEq for OwningRef where T: PartialEq { + fn eq(&self, other: &Self) -> bool { + (&*self as &T).eq(&*other as &T) + } +} + +impl Eq for OwningRef where T: Eq {} + +impl PartialOrd for OwningRef where T: PartialOrd { + fn partial_cmp(&self, other: &Self) -> Option { + (&*self as &T).partial_cmp(&*other as &T) + } +} + +impl Ord for OwningRef where T: Ord { + fn cmp(&self, other: &Self) -> Ordering { + (&*self as &T).cmp(&*other as &T) + } +} + +impl Hash for OwningRef where T: Hash { + fn hash(&self, state: &mut H) { + (&*self as &T).hash(state); + } +} + +impl PartialEq for OwningRefMut where T: PartialEq { + fn eq(&self, other: &Self) -> bool { + (&*self as &T).eq(&*other as &T) + } +} + +impl Eq for OwningRefMut where T: Eq {} + +impl PartialOrd for OwningRefMut where T: PartialOrd { + fn partial_cmp(&self, other: &Self) -> Option { + (&*self as &T).partial_cmp(&*other as &T) + } +} + +impl Ord for OwningRefMut where T: Ord { + fn cmp(&self, other: &Self) -> Ordering { + (&*self as &T).cmp(&*other as &T) + } +} + +impl Hash for OwningRefMut where T: Hash { + fn hash(&self, state: &mut H) { + (&*self as &T).hash(state); + } +} + +///////////////////////////////////////////////////////////////////////////// +// std types integration and convenience type defs +///////////////////////////////////////////////////////////////////////////// + +use std::boxed::Box; +use std::rc::Rc; +use std::sync::Arc; +use std::sync::{MutexGuard, RwLockReadGuard, RwLockWriteGuard}; +use std::cell::{Ref, RefCell, RefMut}; + +impl ToHandle for RefCell { + type Handle = Ref<'static, T>; + unsafe fn to_handle(x: *const Self) -> Self::Handle { (*x).borrow() } +} + +impl ToHandleMut for RefCell { + type HandleMut = RefMut<'static, T>; + unsafe fn to_handle_mut(x: *const Self) -> Self::HandleMut { (*x).borrow_mut() } +} + +// NB: Implementing ToHandle{,Mut} for Mutex and RwLock requires a decision +// about which handle creation to use (i.e. read() vs try_read()) as well as +// what to do with error results. + +/// Typedef of a owning reference that uses a `Box` as the owner. +pub type BoxRef = OwningRef, U>; +/// Typedef of a owning reference that uses a `Vec` as the owner. +pub type VecRef = OwningRef, U>; +/// Typedef of a owning reference that uses a `String` as the owner. +pub type StringRef = OwningRef; + +/// Typedef of a owning reference that uses a `Rc` as the owner. +pub type RcRef = OwningRef, U>; +/// Typedef of a owning reference that uses a `Arc` as the owner. +pub type ArcRef = OwningRef, U>; + +/// Typedef of a owning reference that uses a `Ref` as the owner. +pub type RefRef<'a, T, U = T> = OwningRef, U>; +/// Typedef of a owning reference that uses a `RefMut` as the owner. +pub type RefMutRef<'a, T, U = T> = OwningRef, U>; +/// Typedef of a owning reference that uses a `MutexGuard` as the owner. +pub type MutexGuardRef<'a, T, U = T> = OwningRef, U>; +/// Typedef of a owning reference that uses a `RwLockReadGuard` as the owner. +pub type RwLockReadGuardRef<'a, T, U = T> = OwningRef, U>; +/// Typedef of a owning reference that uses a `RwLockWriteGuard` as the owner. +pub type RwLockWriteGuardRef<'a, T, U = T> = OwningRef, U>; + +/// Typedef of a mutable owning reference that uses a `Box` as the owner. +pub type BoxRefMut = OwningRefMut, U>; +/// Typedef of a mutable owning reference that uses a `Vec` as the owner. +pub type VecRefMut = OwningRefMut, U>; +/// Typedef of a mutable owning reference that uses a `String` as the owner. +pub type StringRefMut = OwningRefMut; + +/// Typedef of a mutable owning reference that uses a `RefMut` as the owner. +pub type RefMutRefMut<'a, T, U = T> = OwningRefMut, U>; +/// Typedef of a mutable owning reference that uses a `MutexGuard` as the owner. +pub type MutexGuardRefMut<'a, T, U = T> = OwningRefMut, U>; +/// Typedef of a mutable owning reference that uses a `RwLockWriteGuard` as the owner. +pub type RwLockWriteGuardRefMut<'a, T, U = T> = OwningRefMut, U>; + +unsafe impl<'a, T: 'a> IntoErased<'a> for Box { + type Erased = Box; + fn into_erased(self) -> Self::Erased { + self + } +} +unsafe impl<'a, T: 'a> IntoErased<'a> for Rc { + type Erased = Rc; + fn into_erased(self) -> Self::Erased { + self + } +} +unsafe impl<'a, T: 'a> IntoErased<'a> for Arc { + type Erased = Arc; + fn into_erased(self) -> Self::Erased { + self + } +} + +/// Typedef of a owning reference that uses an erased `Box` as the owner. +pub type ErasedBoxRef = OwningRef, U>; +/// Typedef of a owning reference that uses an erased `Rc` as the owner. +pub type ErasedRcRef = OwningRef, U>; +/// Typedef of a owning reference that uses an erased `Arc` as the owner. +pub type ErasedArcRef = OwningRef, U>; + +/// Typedef of a mutable owning reference that uses an erased `Box` as the owner. +pub type ErasedBoxRefMut = OwningRefMut, U>; + +#[cfg(test)] +mod tests { + mod owning_ref { + use super::super::OwningRef; + use super::super::{RcRef, BoxRef, Erased, ErasedBoxRef}; + use std::cmp::{PartialEq, Ord, PartialOrd, Ordering}; + use std::hash::{Hash, Hasher}; + use std::collections::hash_map::DefaultHasher; + use std::collections::HashMap; + use std::rc::Rc; + + #[derive(Debug, PartialEq)] + struct Example(u32, String, [u8; 3]); + fn example() -> Example { + Example(42, "hello world".to_string(), [1, 2, 3]) + } + + #[test] + fn new_deref() { + let or: OwningRef, ()> = OwningRef::new(Box::new(())); + assert_eq!(&*or, &()); + } + + #[test] + fn into() { + let or: OwningRef, ()> = Box::new(()).into(); + assert_eq!(&*or, &()); + } + + #[test] + fn map_offset_ref() { + let or: BoxRef = Box::new(example()).into(); + let or: BoxRef<_, u32> = or.map(|x| &x.0); + assert_eq!(&*or, &42); + + let or: BoxRef = Box::new(example()).into(); + let or: BoxRef<_, u8> = or.map(|x| &x.2[1]); + assert_eq!(&*or, &2); + } + + #[test] + fn map_heap_ref() { + let or: BoxRef = Box::new(example()).into(); + let or: BoxRef<_, str> = or.map(|x| &x.1[..5]); + assert_eq!(&*or, "hello"); + } + + #[test] + fn map_static_ref() { + let or: BoxRef<()> = Box::new(()).into(); + let or: BoxRef<_, str> = or.map(|_| "hello"); + assert_eq!(&*or, "hello"); + } + + #[test] + fn map_chained() { + let or: BoxRef = Box::new(example().1).into(); + let or: BoxRef<_, str> = or.map(|x| &x[1..5]); + let or: BoxRef<_, str> = or.map(|x| &x[..2]); + assert_eq!(&*or, "el"); + } + + #[test] + fn map_chained_inference() { + let or = BoxRef::new(Box::new(example().1)) + .map(|x| &x[..5]) + .map(|x| &x[1..3]); + assert_eq!(&*or, "el"); + } + + #[test] + fn as_owner() { + let or: BoxRef = Box::new(example().1).into(); + let or = or.map(|x| &x[..5]); + assert_eq!(&*or, "hello"); + assert_eq!(&**or.as_owner(), "hello world"); + } + + #[test] + fn into_owner() { + let or: BoxRef = Box::new(example().1).into(); + let or = or.map(|x| &x[..5]); + assert_eq!(&*or, "hello"); + let s = *or.into_owner(); + assert_eq!(&s, "hello world"); + } + + #[test] + fn fmt_debug() { + let or: BoxRef = Box::new(example().1).into(); + let or = or.map(|x| &x[..5]); + let s = format!("{:?}", or); + assert_eq!(&s, "OwningRef { owner: \"hello world\", reference: \"hello\" }"); + } + + #[test] + fn erased_owner() { + let o1: BoxRef = BoxRef::new(Box::new(example())) + .map(|x| &x.1[..]); + + let o2: BoxRef = BoxRef::new(Box::new(example().1)) + .map(|x| &x[..]); + + let os: Vec> = vec![o1.erase_owner(), o2.erase_owner()]; + assert!(os.iter().all(|e| &e[..] == "hello world")); + } + + #[test] + fn non_static_erased_owner() { + let foo = [413, 612]; + let bar = &foo; + + // FIXME: lifetime inference fails us, and we can't easily define a lifetime for a closure + // (see https://github.com/rust-lang/rust/issues/22340) + // So we use a function to identify the lifetimes instead. + fn borrow<'a>(a: &'a &[i32; 2]) -> &'a i32 { + &a[0] + } + + let o: BoxRef<&[i32; 2]> = Box::new(bar).into(); + let o: BoxRef<&[i32; 2], i32> = o.map(borrow); + let o: BoxRef = o.erase_owner(); + + assert_eq!(*o, 413); + } + + #[test] + fn raii_locks() { + use super::super::{RefRef, RefMutRef}; + use std::cell::RefCell; + use super::super::{MutexGuardRef, RwLockReadGuardRef, RwLockWriteGuardRef}; + use std::sync::{Mutex, RwLock}; + + { + let a = RefCell::new(1); + let a = { + let a = RefRef::new(a.borrow()); + assert_eq!(*a, 1); + a + }; + assert_eq!(*a, 1); + drop(a); + } + { + let a = RefCell::new(1); + let a = { + let a = RefMutRef::new(a.borrow_mut()); + assert_eq!(*a, 1); + a + }; + assert_eq!(*a, 1); + drop(a); + } + { + let a = Mutex::new(1); + let a = { + let a = MutexGuardRef::new(a.lock().unwrap()); + assert_eq!(*a, 1); + a + }; + assert_eq!(*a, 1); + drop(a); + } + { + let a = RwLock::new(1); + let a = { + let a = RwLockReadGuardRef::new(a.read().unwrap()); + assert_eq!(*a, 1); + a + }; + assert_eq!(*a, 1); + drop(a); + } + { + let a = RwLock::new(1); + let a = { + let a = RwLockWriteGuardRef::new(a.write().unwrap()); + assert_eq!(*a, 1); + a + }; + assert_eq!(*a, 1); + drop(a); + } + } + + #[test] + fn eq() { + let or1: BoxRef<[u8]> = BoxRef::new(vec![1, 2, 3].into_boxed_slice()); + let or2: BoxRef<[u8]> = BoxRef::new(vec![1, 2, 3].into_boxed_slice()); + assert_eq!(or1.eq(&or2), true); + } + + #[test] + fn cmp() { + let or1: BoxRef<[u8]> = BoxRef::new(vec![1, 2, 3].into_boxed_slice()); + let or2: BoxRef<[u8]> = BoxRef::new(vec![4, 5, 6].into_boxed_slice()); + assert_eq!(or1.cmp(&or2), Ordering::Less); + } + + #[test] + fn partial_cmp() { + let or1: BoxRef<[u8]> = BoxRef::new(vec![4, 5, 6].into_boxed_slice()); + let or2: BoxRef<[u8]> = BoxRef::new(vec![1, 2, 3].into_boxed_slice()); + assert_eq!(or1.partial_cmp(&or2), Some(Ordering::Greater)); + } + + #[test] + fn hash() { + let mut h1 = DefaultHasher::new(); + let mut h2 = DefaultHasher::new(); + + let or1: BoxRef<[u8]> = BoxRef::new(vec![1, 2, 3].into_boxed_slice()); + let or2: BoxRef<[u8]> = BoxRef::new(vec![1, 2, 3].into_boxed_slice()); + + or1.hash(&mut h1); + or2.hash(&mut h2); + + assert_eq!(h1.finish(), h2.finish()); + } + + #[test] + fn borrow() { + let mut hash = HashMap::new(); + let key = RcRef::::new(Rc::new("foo-bar".to_string())).map(|s| &s[..]); + + hash.insert(key.clone().map(|s| &s[..3]), 42); + hash.insert(key.clone().map(|s| &s[4..]), 23); + + assert_eq!(hash.get("foo"), Some(&42)); + assert_eq!(hash.get("bar"), Some(&23)); + } + + #[test] + fn total_erase() { + let a: OwningRef, [u8]> + = OwningRef::new(vec![]).map(|x| &x[..]); + let b: OwningRef, [u8]> + = OwningRef::new(vec![].into_boxed_slice()).map(|x| &x[..]); + + let c: OwningRef>, [u8]> = unsafe {a.map_owner(Rc::new)}; + let d: OwningRef>, [u8]> = unsafe {b.map_owner(Rc::new)}; + + let e: OwningRef, [u8]> = c.erase_owner(); + let f: OwningRef, [u8]> = d.erase_owner(); + + let _g = e.clone(); + let _h = f.clone(); + } + + #[test] + fn total_erase_box() { + let a: OwningRef, [u8]> + = OwningRef::new(vec![]).map(|x| &x[..]); + let b: OwningRef, [u8]> + = OwningRef::new(vec![].into_boxed_slice()).map(|x| &x[..]); + + let c: OwningRef>, [u8]> = a.map_owner_box(); + let d: OwningRef>, [u8]> = b.map_owner_box(); + + let _e: OwningRef, [u8]> = c.erase_owner(); + let _f: OwningRef, [u8]> = d.erase_owner(); + } + + #[test] + fn try_map1() { + use std::any::Any; + + let x = Box::new(123_i32); + let y: Box = x; + + OwningRef::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_ok(); + } + + #[test] + fn try_map2() { + use std::any::Any; + + let x = Box::new(123_i32); + let y: Box = x; + + OwningRef::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_err(); + } + } + + mod owning_handle { + use super::super::OwningHandle; + use super::super::RcRef; + use std::rc::Rc; + use std::cell::RefCell; + use std::sync::Arc; + use std::sync::RwLock; + + #[test] + fn owning_handle() { + use std::cell::RefCell; + let cell = Rc::new(RefCell::new(2)); + let cell_ref = RcRef::new(cell); + let mut handle = OwningHandle::new_with_fn(cell_ref, |x| unsafe { x.as_ref() }.unwrap().borrow_mut()); + assert_eq!(*handle, 2); + *handle = 3; + assert_eq!(*handle, 3); + } + + #[test] + fn try_owning_handle_ok() { + use std::cell::RefCell; + let cell = Rc::new(RefCell::new(2)); + let cell_ref = RcRef::new(cell); + let mut handle = OwningHandle::try_new::<_, ()>(cell_ref, |x| { + Ok(unsafe { + x.as_ref() + }.unwrap().borrow_mut()) + }).unwrap(); + assert_eq!(*handle, 2); + *handle = 3; + assert_eq!(*handle, 3); + } + + #[test] + fn try_owning_handle_err() { + use std::cell::RefCell; + let cell = Rc::new(RefCell::new(2)); + let cell_ref = RcRef::new(cell); + let handle = OwningHandle::try_new::<_, ()>(cell_ref, |x| { + if false { + return Ok(unsafe { + x.as_ref() + }.unwrap().borrow_mut()) + } + Err(()) + }); + assert!(handle.is_err()); + } + + #[test] + fn nested() { + use std::cell::RefCell; + use std::sync::{Arc, RwLock}; + + let result = { + let complex = Rc::new(RefCell::new(Arc::new(RwLock::new("someString")))); + let curr = RcRef::new(complex); + let curr = OwningHandle::new_with_fn(curr, |x| unsafe { x.as_ref() }.unwrap().borrow_mut()); + let mut curr = OwningHandle::new_with_fn(curr, |x| unsafe { x.as_ref() }.unwrap().try_write().unwrap()); + assert_eq!(*curr, "someString"); + *curr = "someOtherString"; + curr + }; + assert_eq!(*result, "someOtherString"); + } + + #[test] + fn owning_handle_safe() { + use std::cell::RefCell; + let cell = Rc::new(RefCell::new(2)); + let cell_ref = RcRef::new(cell); + let handle = OwningHandle::new(cell_ref); + assert_eq!(*handle, 2); + } + + #[test] + fn owning_handle_mut_safe() { + use std::cell::RefCell; + let cell = Rc::new(RefCell::new(2)); + let cell_ref = RcRef::new(cell); + let mut handle = OwningHandle::new_mut(cell_ref); + assert_eq!(*handle, 2); + *handle = 3; + assert_eq!(*handle, 3); + } + + #[test] + fn owning_handle_safe_2() { + let result = { + let complex = Rc::new(RefCell::new(Arc::new(RwLock::new("someString")))); + let curr = RcRef::new(complex); + let curr = OwningHandle::new_with_fn(curr, |x| unsafe { x.as_ref() }.unwrap().borrow_mut()); + let mut curr = OwningHandle::new_with_fn(curr, |x| unsafe { x.as_ref() }.unwrap().try_write().unwrap()); + assert_eq!(*curr, "someString"); + *curr = "someOtherString"; + curr + }; + assert_eq!(*result, "someOtherString"); + } + } + + mod owning_ref_mut { + use super::super::{OwningRefMut, BoxRefMut, Erased, ErasedBoxRefMut}; + use super::super::BoxRef; + use std::cmp::{PartialEq, Ord, PartialOrd, Ordering}; + use std::hash::{Hash, Hasher}; + use std::collections::hash_map::DefaultHasher; + use std::collections::HashMap; + + #[derive(Debug, PartialEq)] + struct Example(u32, String, [u8; 3]); + fn example() -> Example { + Example(42, "hello world".to_string(), [1, 2, 3]) + } + + #[test] + fn new_deref() { + let or: OwningRefMut, ()> = OwningRefMut::new(Box::new(())); + assert_eq!(&*or, &()); + } + + #[test] + fn new_deref_mut() { + let mut or: OwningRefMut, ()> = OwningRefMut::new(Box::new(())); + assert_eq!(&mut *or, &mut ()); + } + + #[test] + fn mutate() { + let mut or: OwningRefMut, usize> = OwningRefMut::new(Box::new(0)); + assert_eq!(&*or, &0); + *or = 1; + assert_eq!(&*or, &1); + } + + #[test] + fn into() { + let or: OwningRefMut, ()> = Box::new(()).into(); + assert_eq!(&*or, &()); + } + + #[test] + fn map_offset_ref() { + let or: BoxRefMut = Box::new(example()).into(); + let or: BoxRef<_, u32> = or.map(|x| &mut x.0); + assert_eq!(&*or, &42); + + let or: BoxRefMut = Box::new(example()).into(); + let or: BoxRef<_, u8> = or.map(|x| &mut x.2[1]); + assert_eq!(&*or, &2); + } + + #[test] + fn map_heap_ref() { + let or: BoxRefMut = Box::new(example()).into(); + let or: BoxRef<_, str> = or.map(|x| &mut x.1[..5]); + assert_eq!(&*or, "hello"); + } + + #[test] + fn map_static_ref() { + let or: BoxRefMut<()> = Box::new(()).into(); + let or: BoxRef<_, str> = or.map(|_| "hello"); + assert_eq!(&*or, "hello"); + } + + #[test] + fn map_mut_offset_ref() { + let or: BoxRefMut = Box::new(example()).into(); + let or: BoxRefMut<_, u32> = or.map_mut(|x| &mut x.0); + assert_eq!(&*or, &42); + + let or: BoxRefMut = Box::new(example()).into(); + let or: BoxRefMut<_, u8> = or.map_mut(|x| &mut x.2[1]); + assert_eq!(&*or, &2); + } + + #[test] + fn map_mut_heap_ref() { + let or: BoxRefMut = Box::new(example()).into(); + let or: BoxRefMut<_, str> = or.map_mut(|x| &mut x.1[..5]); + assert_eq!(&*or, "hello"); + } + + #[test] + fn map_mut_static_ref() { + static mut MUT_S: [u8; 5] = *b"hello"; + + let mut_s: &'static mut [u8] = unsafe { &mut MUT_S }; + + let or: BoxRefMut<()> = Box::new(()).into(); + let or: BoxRefMut<_, [u8]> = or.map_mut(move |_| mut_s); + assert_eq!(&*or, b"hello"); + } + + #[test] + fn map_mut_chained() { + let or: BoxRefMut = Box::new(example().1).into(); + let or: BoxRefMut<_, str> = or.map_mut(|x| &mut x[1..5]); + let or: BoxRefMut<_, str> = or.map_mut(|x| &mut x[..2]); + assert_eq!(&*or, "el"); + } + + #[test] + fn map_chained_inference() { + let or = BoxRefMut::new(Box::new(example().1)) + .map_mut(|x| &mut x[..5]) + .map_mut(|x| &mut x[1..3]); + assert_eq!(&*or, "el"); + } + + #[test] + fn try_map_mut() { + let or: BoxRefMut = Box::new(example().1).into(); + let or: Result, ()> = or.try_map_mut(|x| Ok(&mut x[1..5])); + assert_eq!(&*or.unwrap(), "ello"); + + let or: BoxRefMut = Box::new(example().1).into(); + let or: Result, ()> = or.try_map_mut(|_| Err(())); + assert!(or.is_err()); + } + + #[test] + fn as_owner() { + let or: BoxRefMut = Box::new(example().1).into(); + let or = or.map_mut(|x| &mut x[..5]); + assert_eq!(&*or, "hello"); + assert_eq!(&**or.as_owner(), "hello world"); + } + + #[test] + fn into_owner() { + let or: BoxRefMut = Box::new(example().1).into(); + let or = or.map_mut(|x| &mut x[..5]); + assert_eq!(&*or, "hello"); + let s = *or.into_owner(); + assert_eq!(&s, "hello world"); + } + + #[test] + fn fmt_debug() { + let or: BoxRefMut = Box::new(example().1).into(); + let or = or.map_mut(|x| &mut x[..5]); + let s = format!("{:?}", or); + assert_eq!(&s, + "OwningRefMut { owner: \"hello world\", reference: \"hello\" }"); + } + + #[test] + fn erased_owner() { + let o1: BoxRefMut = BoxRefMut::new(Box::new(example())) + .map_mut(|x| &mut x.1[..]); + + let o2: BoxRefMut = BoxRefMut::new(Box::new(example().1)) + .map_mut(|x| &mut x[..]); + + let os: Vec> = vec![o1.erase_owner(), o2.erase_owner()]; + assert!(os.iter().all(|e| &e[..] == "hello world")); + } + + #[test] + fn non_static_erased_owner() { + let mut foo = [413, 612]; + let bar = &mut foo; + + // FIXME: lifetime inference fails us, and we can't easily define a lifetime for a closure + // (see https://github.com/rust-lang/rust/issues/22340) + // So we use a function to identify the lifetimes instead. + fn borrow<'a>(a: &'a mut &mut [i32; 2]) -> &'a mut i32 { + &mut a[0] + } + + let o: BoxRefMut<&mut [i32; 2]> = Box::new(bar).into(); + let o: BoxRefMut<&mut [i32; 2], i32> = o.map_mut(borrow); + let o: BoxRefMut = o.erase_owner(); + + assert_eq!(*o, 413); + } + + #[test] + fn raii_locks() { + use super::super::RefMutRefMut; + use std::cell::RefCell; + use super::super::{MutexGuardRefMut, RwLockWriteGuardRefMut}; + use std::sync::{Mutex, RwLock}; + + { + let a = RefCell::new(1); + let a = { + let a = RefMutRefMut::new(a.borrow_mut()); + assert_eq!(*a, 1); + a + }; + assert_eq!(*a, 1); + drop(a); + } + { + let a = Mutex::new(1); + let a = { + let a = MutexGuardRefMut::new(a.lock().unwrap()); + assert_eq!(*a, 1); + a + }; + assert_eq!(*a, 1); + drop(a); + } + { + let a = RwLock::new(1); + let a = { + let a = RwLockWriteGuardRefMut::new(a.write().unwrap()); + assert_eq!(*a, 1); + a + }; + assert_eq!(*a, 1); + drop(a); + } + } + + #[test] + fn eq() { + let or1: BoxRefMut<[u8]> = BoxRefMut::new(vec![1, 2, 3].into_boxed_slice()); + let or2: BoxRefMut<[u8]> = BoxRefMut::new(vec![1, 2, 3].into_boxed_slice()); + assert_eq!(or1.eq(&or2), true); + } + + #[test] + fn cmp() { + let or1: BoxRefMut<[u8]> = BoxRefMut::new(vec![1, 2, 3].into_boxed_slice()); + let or2: BoxRefMut<[u8]> = BoxRefMut::new(vec![4, 5, 6].into_boxed_slice()); + assert_eq!(or1.cmp(&or2), Ordering::Less); + } + + #[test] + fn partial_cmp() { + let or1: BoxRefMut<[u8]> = BoxRefMut::new(vec![4, 5, 6].into_boxed_slice()); + let or2: BoxRefMut<[u8]> = BoxRefMut::new(vec![1, 2, 3].into_boxed_slice()); + assert_eq!(or1.partial_cmp(&or2), Some(Ordering::Greater)); + } + + #[test] + fn hash() { + let mut h1 = DefaultHasher::new(); + let mut h2 = DefaultHasher::new(); + + let or1: BoxRefMut<[u8]> = BoxRefMut::new(vec![1, 2, 3].into_boxed_slice()); + let or2: BoxRefMut<[u8]> = BoxRefMut::new(vec![1, 2, 3].into_boxed_slice()); + + or1.hash(&mut h1); + or2.hash(&mut h2); + + assert_eq!(h1.finish(), h2.finish()); + } + + #[test] + fn borrow() { + let mut hash = HashMap::new(); + let key1 = BoxRefMut::::new(Box::new("foo".to_string())).map(|s| &s[..]); + let key2 = BoxRefMut::::new(Box::new("bar".to_string())).map(|s| &s[..]); + + hash.insert(key1, 42); + hash.insert(key2, 23); + + assert_eq!(hash.get("foo"), Some(&42)); + assert_eq!(hash.get("bar"), Some(&23)); + } + + #[test] + fn total_erase() { + let a: OwningRefMut, [u8]> + = OwningRefMut::new(vec![]).map_mut(|x| &mut x[..]); + let b: OwningRefMut, [u8]> + = OwningRefMut::new(vec![].into_boxed_slice()).map_mut(|x| &mut x[..]); + + let c: OwningRefMut>, [u8]> = unsafe {a.map_owner(Box::new)}; + let d: OwningRefMut>, [u8]> = unsafe {b.map_owner(Box::new)}; + + let _e: OwningRefMut, [u8]> = c.erase_owner(); + let _f: OwningRefMut, [u8]> = d.erase_owner(); + } + + #[test] + fn total_erase_box() { + let a: OwningRefMut, [u8]> + = OwningRefMut::new(vec![]).map_mut(|x| &mut x[..]); + let b: OwningRefMut, [u8]> + = OwningRefMut::new(vec![].into_boxed_slice()).map_mut(|x| &mut x[..]); + + let c: OwningRefMut>, [u8]> = a.map_owner_box(); + let d: OwningRefMut>, [u8]> = b.map_owner_box(); + + let _e: OwningRefMut, [u8]> = c.erase_owner(); + let _f: OwningRefMut, [u8]> = d.erase_owner(); + } + + #[test] + fn try_map1() { + use std::any::Any; + + let x = Box::new(123_i32); + let y: Box = x; + + OwningRefMut::new(y).try_map_mut(|x| x.downcast_mut::().ok_or(())).is_ok(); + } + + #[test] + fn try_map2() { + use std::any::Any; + + let x = Box::new(123_i32); + let y: Box = x; + + OwningRefMut::new(y).try_map_mut(|x| x.downcast_mut::().ok_or(())).is_err(); + } + + #[test] + fn try_map3() { + use std::any::Any; + + let x = Box::new(123_i32); + let y: Box = x; + + OwningRefMut::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_ok(); + } + + #[test] + fn try_map4() { + use std::any::Any; + + let x = Box::new(123_i32); + let y: Box = x; + + OwningRefMut::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_err(); + } + + #[test] + fn into_owning_ref() { + use super::super::BoxRef; + + let or: BoxRefMut<()> = Box::new(()).into(); + let or: BoxRef<()> = or.into(); + assert_eq!(&*or, &()); + } + + struct Foo { + u: u32, + } + struct Bar { + f: Foo, + } + + #[test] + fn ref_mut() { + use std::cell::RefCell; + + let a = RefCell::new(Bar { f: Foo { u: 42 } }); + let mut b = OwningRefMut::new(a.borrow_mut()); + assert_eq!(b.f.u, 42); + b.f.u = 43; + let mut c = b.map_mut(|x| &mut x.f); + assert_eq!(c.u, 43); + c.u = 44; + let mut d = c.map_mut(|x| &mut x.u); + assert_eq!(*d, 44); + *d = 45; + assert_eq!(*d, 45); + } + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/.cargo-checksum.json b/third_party/cargo/vendor/parking_lot-0.6.4/.cargo-checksum.json new file mode 100644 index 0000000..336edcf --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"e254fac6600c725edb746f31f41b1b2ceeb9cfc85f4f9a3e6af874c70b020823","Cargo.toml":"e5d073e0f98041047612bb2e226585f81fcb2d3eabef9579c9ce322f7708b38d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","README.md":"a52cf38f796e7f12215662e8a3a23aa9802c170a09ecba0e4be766c88f95a9c5","appveyor.yml":"cb1d02316926d88e174976bfc6781194569ca27f386c50e3091d8e52587d30a2","src/condvar.rs":"ce127f75bad5c175abb8147aac4b5be78aabdb599c5f8f3aad77f6bc3705274d","src/deadlock.rs":"8916c2e2820bfd3a55860ddb9f1b907888406b68cdae2b7a2093c825d28f3b99","src/elision.rs":"89072fe0aca87d53abc0f56490ae77bcf9d77e28e291bd13e861b1924bbb079f","src/lib.rs":"3e259bf3421f10c3e920daca511a4880b2620145a1fcb070a37548835c4f429a","src/mutex.rs":"0ac3e654e4aa2c3078a6aa22c83428d604e7f3f8ed4c261c40d030d232ca7b64","src/once.rs":"606e0e88d6c1ff82b69bda56e7409ec3a1aefa66b45b7fa42b88cba07ae70598","src/raw_mutex.rs":"881e75a843d76399d01c4ae0f09cd23b93b137b5035a47bd7886505132e58165","src/raw_rwlock.rs":"2e3c13e80cd06be53118ae2bcc7bdec708dda8c139c371ee12885f48903cf69c","src/remutex.rs":"bad8022610344086010b0661998a416db4b458c222e671b67df03fc4795c0298","src/rwlock.rs":"fc826cbcf2d7862ecb184b657a82bb8794a9e26ac329c8f87b589fa09f15d245","src/util.rs":"2d07c0c010a857790ae2ed6a1215eeed8af76859e076797ea1ba8dec82169e84"},"package":"f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5"} \ No newline at end of file diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/BUILD b/third_party/cargo/vendor/parking_lot-0.6.4/BUILD new file mode 100644 index 0000000..b84f55c --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0,MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "parking_lot", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/lock_api-0.1.5:lock_api", + "//third_party/cargo/vendor/parking_lot_core-0.3.1:parking_lot_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.4", + crate_features = [ + "default", + "lock_api", + "owning_ref", + ], +) + diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/CHANGELOG.md b/third_party/cargo/vendor/parking_lot-0.6.4/CHANGELOG.md new file mode 100644 index 0000000..20651aa --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/CHANGELOG.md @@ -0,0 +1,48 @@ +0.6.3 (2018-07-18) +================== + +- Export `RawMutex`, `RawRwLock` and `RawThreadId`. + +0.6.2 (2018-06-18) +================== + +- Enable `lock_api/nightly` feature from `parking_lot/nightly` (#79) + +0.6.1 (2018-06-08) +================== + +Added missing typedefs for mapped lock guards: + +- `MappedMutexGuard` +- `MappedReentrantMutexGuard` +- `MappedRwLockReadGuard` +- `MappedRwLockWriteGuard` + +0.6.0 (2018-06-08) +================== + +This release moves most of the code for type-safe `Mutex` and `RwLock` types +into a separate crate called `lock_api`. This new crate is compatible with +`no_std` and provides `Mutex` and `RwLock` type-safe wrapper types from a +raw mutex type which implements the `RawMutex` or `RawRwLock` trait. The API +provided by the wrapper types can be extended by implementing more traits on the +raw mutex type which provide more functionality (e.g. `RawMutexTimed`). See the +crate documentation for more details. + +There are also several major changes: + +- The minimum required Rust version is bumped to 1.26. +- All methods on `MutexGuard` (and other guard types) are no longer inherent + methods and must be called as `MutexGuard::method(self)`. This avoids + conflicts with methods from the inner type. +- `MutexGuard` (and other guard types) add the `unlocked` method which + temporarily unlocks a mutex, runs the given closure, and then re-locks the + mutex. +- `MutexGuard` (and other guard types) add the `bump` method which gives a + chance for other threads to acquire the mutex by temporarily unlocking it and + re-locking it. However this is optimized for the common case where there are + no threads waiting on the lock, in which case no unlocking is performed. +- `MutexGuard` (and other guard types) add the `map` method which returns a + `MappedMutexGuard` which holds only a subset of the original locked type. The + `MappedMutexGuard` type is identical to `MutexGuard` except that it does not + support the `unlocked` and `bump` methods, and can't be used with `CondVar`. diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/Cargo.toml b/third_party/cargo/vendor/parking_lot-0.6.4/Cargo.toml new file mode 100644 index 0000000..67765d1 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/Cargo.toml @@ -0,0 +1,35 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "parking_lot" +version = "0.6.4" +authors = ["Amanieu d'Antras "] +description = "More compact and efficient implementations of the standard synchronization primitives." +readme = "README.md" +keywords = ["mutex", "condvar", "rwlock", "once", "thread"] +categories = ["concurrency"] +license = "Apache-2.0/MIT" +repository = "https://github.com/Amanieu/parking_lot" +[dependencies.lock_api] +version = "0.1" + +[dependencies.parking_lot_core] +version = "0.3" +[dev-dependencies.rand] +version = "0.5" + +[features] +deadlock_detection = ["parking_lot_core/deadlock_detection"] +default = ["owning_ref"] +nightly = ["parking_lot_core/nightly", "lock_api/nightly"] +owning_ref = ["lock_api/owning_ref"] diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/LICENSE-APACHE b/third_party/cargo/vendor/parking_lot-0.6.4/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/LICENSE-MIT b/third_party/cargo/vendor/parking_lot-0.6.4/LICENSE-MIT new file mode 100644 index 0000000..40b8817 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/README.md b/third_party/cargo/vendor/parking_lot-0.6.4/README.md new file mode 100644 index 0000000..4e9204c --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/README.md @@ -0,0 +1,138 @@ +parking_lot +============ + +[![Build Status](https://travis-ci.org/Amanieu/parking_lot.svg?branch=master)](https://travis-ci.org/Amanieu/parking_lot) [![Build status](https://ci.appveyor.com/api/projects/status/wppcc32ttpud0a30/branch/master?svg=true)](https://ci.appveyor.com/project/Amanieu/parking-lot/branch/master) [![Crates.io](https://img.shields.io/crates/v/parking_lot.svg)](https://crates.io/crates/parking_lot) + +[Documentation (synchronization primitives)](https://docs.rs/parking_lot/) + +[Documentation (core parking lot API)](https://docs.rs/parking_lot_core/) + +[Documentation (type-safe lock API)](https://docs.rs/lock_api/) + +This library provides implementations of `Mutex`, `RwLock`, `Condvar` and +`Once` that are smaller, faster and more flexible than those in the Rust +standard library, as well as a `ReentrantMutex` type which supports recursive +locking. It also exposes a low-level API for creating your own efficient +synchronization primitives. + +When tested on x86_64 Linux, `parking_lot::Mutex` was found to be 1.5x +faster than `std::sync::Mutex` when uncontended, and up to 5x faster when +contended from multiple threads. The numbers for `RwLock` vary depending on +the number of reader and writer threads, but are almost always faster than +the standard library `RwLock`, and even up to 50x faster in some cases. + +## Features + +The primitives provided by this library have several advantages over those +in the Rust standard library: + +1. `Mutex` and `Once` only require 1 byte of storage space, while `Condvar` + and `RwLock` only require 1 word of storage space. On the other hand the + standard library primitives require a dynamically allocated `Box` to hold + OS-specific synchronization primitives. The small size of `Mutex` in + particular encourages the use of fine-grained locks to increase + parallelism. +2. Since they consist of just a single atomic variable, have constant + initializers and don't need destructors, these primitives can be used as + `static` global variables. The standard library primitives require + dynamic initialization and thus need to be lazily initialized with + `lazy_static!`. +3. Uncontended lock acquisition and release is done through fast inline + paths which only require a single atomic operation. +4. Microcontention (a contended lock with a short critical section) is + efficiently handled by spinning a few times while trying to acquire a + lock. +5. The locks are adaptive and will suspend a thread after a few failed spin + attempts. This makes the locks suitable for both long and short critical + sections. +6. `Condvar`, `RwLock` and `Once` work on Windows XP, unlike the standard + library versions of those types. +7. `RwLock` takes advantage of hardware lock elision on processors that + support it, which can lead to huge performance wins with many readers. +8. `RwLock` uses a task-fair locking policy, which avoids reader and writer + starvation, whereas the standard library version makes no guarantees. +9. `Condvar` is guaranteed not to produce spurious wakeups. A thread will + only be woken up if it timed out or it was woken up by a notification. +10. `Condvar::notify_all` will only wake up a single thread and requeue the + rest to wait on the associated `Mutex`. This avoids a thundering herd + problem where all threads try to acquire the lock at the same time. +11. `RwLock` supports atomically downgrading a write lock into a read lock. +12. `Mutex` and `RwLock` allow raw unlocking without a RAII guard object. +13. `Mutex<()>` and `RwLock<()>` allow raw locking without a RAII guard + object. +14. `Mutex` and `RwLock` support [eventual fairness](https://trac.webkit.org/changeset/203350) + which allows them to be fair on average without sacrificing performance. +15. A `ReentrantMutex` type which supports recursive locking. +16. An *experimental* deadlock detector that works for `Mutex`, + `RwLock` and `ReentrantMutex`. This feature is disabled by default and + can be enabled via the `deadlock_detection` feature. +17. `RwLock` supports atomically upgrading an "upgradable" read lock into a + write lock. + +## The parking lot + +To keep these primitives small, all thread queuing and suspending +functionality is offloaded to the *parking lot*. The idea behind this is +based on the Webkit [`WTF::ParkingLot`](https://webkit.org/blog/6161/locking-in-webkit/) +class, which essentially consists of a hash table mapping of lock addresses +to queues of parked (sleeping) threads. The Webkit parking lot was itself +inspired by Linux [futexes](http://man7.org/linux/man-pages/man2/futex.2.html), +but it is more powerful since it allows invoking callbacks while holding a queue +lock. + +## Nightly vs stable + +There are a few restrictions when using this library on stable Rust: + +- `Mutex` and `Once` will use 1 word of space instead of 1 byte. +- You will have to use `lazy_static!` to statically initialize `Mutex`, + `Condvar` and `RwLock` types instead of `const fn`. +- `RwLock` will not be able to take advantage of hardware lock elision for + readers, which improves performance when there are multiple readers. + +To enable nightly-only functionality, you need to enable the `nightly` feature +in Cargo (see below). + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +parking_lot = "0.6" +``` + +and this to your crate root: + +```rust +extern crate parking_lot; +``` + +To enable nightly-only features, add this to your `Cargo.toml` instead: + +```toml +[dependencies] +parking_lot = {version = "0.6", features = ["nightly"]} +``` + +The experimental deadlock detector can be enabled with the +`deadlock_detection` Cargo feature. + +The core parking lot API is provided by the `parking_lot_core` crate. It is +separate from the synchronization primitives in the `parking_lot` crate so that +changes to the core API do not cause breaking changes for users of `parking_lot`. + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any +additional terms or conditions. diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/appveyor.yml b/third_party/cargo/vendor/parking_lot-0.6.4/appveyor.yml new file mode 100644 index 0000000..fef6b57 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/appveyor.yml @@ -0,0 +1,29 @@ +environment: + TRAVIS_CARGO_NIGHTLY_FEATURE: nightly + RUST_TEST_THREADS: 1 + matrix: + - TARGET: nightly-x86_64-pc-windows-msvc + - TARGET: nightly-i686-pc-windows-msvc + - TARGET: nightly-x86_64-pc-windows-gnu + - TARGET: nightly-i686-pc-windows-gnu + - TARGET: 1.24.0-x86_64-pc-windows-msvc + - TARGET: 1.24.0-i686-pc-windows-msvc + - TARGET: 1.24.0-x86_64-pc-windows-gnu + - TARGET: 1.24.0-i686-pc-windows-gnu + +install: + - SET PATH=C:\Python27;C:\Python27\Scripts;%PATH%;%APPDATA%\Python\Scripts + - pip install "travis-cargo<0.2" --user + - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:TARGET}.exe" -FileName "rust-install.exe" + - ps: .\rust-install.exe /VERYSILENT /NORESTART /DIR="C:\rust" | Out-Null + - ps: $env:PATH="$env:PATH;C:\rust\bin" + - rustc -vV + - cargo -vV + +build_script: + - travis-cargo build + +test_script: + - travis-cargo test + - travis-cargo test -- --features=deadlock_detection + - travis-cargo doc diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/condvar.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/condvar.rs new file mode 100644 index 0000000..89ddac7 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/condvar.rs @@ -0,0 +1,533 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use deadlock; +use lock_api::RawMutex as RawMutexTrait; +use mutex::MutexGuard; +use parking_lot_core::{self, ParkResult, RequeueOp, UnparkResult, DEFAULT_PARK_TOKEN}; +use raw_mutex::{RawMutex, TOKEN_HANDOFF, TOKEN_NORMAL}; +use std::sync::atomic::{AtomicPtr, Ordering}; +use std::time::{Duration, Instant}; +use std::{fmt, ptr}; + +/// A type indicating whether a timed wait on a condition variable returned +/// due to a time out or not. +#[derive(Debug, PartialEq, Eq, Copy, Clone)] +pub struct WaitTimeoutResult(bool); + +impl WaitTimeoutResult { + /// Returns whether the wait was known to have timed out. + #[inline] + pub fn timed_out(&self) -> bool { + self.0 + } +} + +/// A Condition Variable +/// +/// Condition variables represent the ability to block a thread such that it +/// consumes no CPU time while waiting for an event to occur. Condition +/// variables are typically associated with a boolean predicate (a condition) +/// and a mutex. The predicate is always verified inside of the mutex before +/// determining that thread must block. +/// +/// Note that this module places one additional restriction over the system +/// condition variables: each condvar can be used with only one mutex at a +/// time. Any attempt to use multiple mutexes on the same condition variable +/// simultaneously will result in a runtime panic. However it is possible to +/// switch to a different mutex if there are no threads currently waiting on +/// the condition variable. +/// +/// # Differences from the standard library `Condvar` +/// +/// - No spurious wakeups: A wait will only return a non-timeout result if it +/// was woken up by `notify_one` or `notify_all`. +/// - `Condvar::notify_all` will only wake up a single thread, the rest are +/// requeued to wait for the `Mutex` to be unlocked by the thread that was +/// woken up. +/// - Only requires 1 word of space, whereas the standard library boxes the +/// `Condvar` due to platform limitations. +/// - Can be statically constructed (requires the `const_fn` nightly feature). +/// - Does not require any drop glue when dropped. +/// - Inline fast path for the uncontended case. +/// +/// # Examples +/// +/// ``` +/// use parking_lot::{Mutex, Condvar}; +/// use std::sync::Arc; +/// use std::thread; +/// +/// let pair = Arc::new((Mutex::new(false), Condvar::new())); +/// let pair2 = pair.clone(); +/// +/// // Inside of our lock, spawn a new thread, and then wait for it to start +/// thread::spawn(move|| { +/// let &(ref lock, ref cvar) = &*pair2; +/// let mut started = lock.lock(); +/// *started = true; +/// cvar.notify_one(); +/// }); +/// +/// // wait for the thread to start up +/// let &(ref lock, ref cvar) = &*pair; +/// let mut started = lock.lock(); +/// while !*started { +/// cvar.wait(&mut started); +/// } +/// ``` +pub struct Condvar { + state: AtomicPtr, +} + +impl Condvar { + /// Creates a new condition variable which is ready to be waited on and + /// notified. + #[cfg(feature = "nightly")] + #[inline] + pub const fn new() -> Condvar { + Condvar { + state: AtomicPtr::new(ptr::null_mut()), + } + } + + /// Creates a new condition variable which is ready to be waited on and + /// notified. + #[cfg(not(feature = "nightly"))] + #[inline] + pub fn new() -> Condvar { + Condvar { + state: AtomicPtr::new(ptr::null_mut()), + } + } + + /// Wakes up one blocked thread on this condvar. + /// + /// If there is a blocked thread on this condition variable, then it will + /// be woken up from its call to `wait` or `wait_timeout`. Calls to + /// `notify_one` are not buffered in any way. + /// + /// To wake up all threads, see `notify_all()`. + #[inline] + pub fn notify_one(&self) { + // Nothing to do if there are no waiting threads + if self.state.load(Ordering::Relaxed).is_null() { + return; + } + + self.notify_one_slow(); + } + + #[cold] + #[inline(never)] + fn notify_one_slow(&self) { + unsafe { + // Unpark one thread + let addr = self as *const _ as usize; + let callback = |result: UnparkResult| { + // Clear our state if there are no more waiting threads + if !result.have_more_threads { + self.state.store(ptr::null_mut(), Ordering::Relaxed); + } + TOKEN_NORMAL + }; + parking_lot_core::unpark_one(addr, callback); + } + } + + /// Wakes up all blocked threads on this condvar. + /// + /// This method will ensure that any current waiters on the condition + /// variable are awoken. Calls to `notify_all()` are not buffered in any + /// way. + /// + /// To wake up only one thread, see `notify_one()`. + #[inline] + pub fn notify_all(&self) { + // Nothing to do if there are no waiting threads + let state = self.state.load(Ordering::Relaxed); + if state.is_null() { + return; + } + + self.notify_all_slow(state); + } + + #[cold] + #[inline(never)] + fn notify_all_slow(&self, mutex: *mut RawMutex) { + unsafe { + // Unpark one thread and requeue the rest onto the mutex + let from = self as *const _ as usize; + let to = mutex as usize; + let validate = || { + // Make sure that our atomic state still points to the same + // mutex. If not then it means that all threads on the current + // mutex were woken up and a new waiting thread switched to a + // different mutex. In that case we can get away with doing + // nothing. + if self.state.load(Ordering::Relaxed) != mutex { + return RequeueOp::Abort; + } + + // Clear our state since we are going to unpark or requeue all + // threads. + self.state.store(ptr::null_mut(), Ordering::Relaxed); + + // Unpark one thread if the mutex is unlocked, otherwise just + // requeue everything to the mutex. This is safe to do here + // since unlocking the mutex when the parked bit is set requires + // locking the queue. There is the possibility of a race if the + // mutex gets locked after we check, but that doesn't matter in + // this case. + if (*mutex).mark_parked_if_locked() { + RequeueOp::RequeueAll + } else { + RequeueOp::UnparkOneRequeueRest + } + }; + let callback = |op, result: UnparkResult| { + // If we requeued threads to the mutex, mark it as having + // parked threads. The RequeueAll case is already handled above. + if op == RequeueOp::UnparkOneRequeueRest && result.have_more_threads { + (*mutex).mark_parked(); + } + TOKEN_NORMAL + }; + parking_lot_core::unpark_requeue(from, to, validate, callback); + } + } + + /// Blocks the current thread until this condition variable receives a + /// notification. + /// + /// This function will atomically unlock the mutex specified (represented by + /// `mutex_guard`) and block the current thread. This means that any calls + /// to `notify_*()` which happen logically after the mutex is unlocked are + /// candidates to wake this thread up. When this function call returns, the + /// lock specified will have been re-acquired. + /// + /// # Panics + /// + /// This function will panic if another thread is waiting on the `Condvar` + /// with a different `Mutex` object. + #[inline] + pub fn wait(&self, mutex_guard: &mut MutexGuard) { + self.wait_until_internal(unsafe { MutexGuard::mutex(mutex_guard).raw() }, None); + } + + /// Waits on this condition variable for a notification, timing out after + /// the specified time instant. + /// + /// The semantics of this function are equivalent to `wait()` except that + /// the thread will be blocked roughly until `timeout` is reached. This + /// method should not be used for precise timing due to anomalies such as + /// preemption or platform differences that may not cause the maximum + /// amount of time waited to be precisely `timeout`. + /// + /// Note that the best effort is made to ensure that the time waited is + /// measured with a monotonic clock, and not affected by the changes made to + /// the system time. + /// + /// The returned `WaitTimeoutResult` value indicates if the timeout is + /// known to have elapsed. + /// + /// Like `wait`, the lock specified will be re-acquired when this function + /// returns, regardless of whether the timeout elapsed or not. + /// + /// # Panics + /// + /// This function will panic if another thread is waiting on the `Condvar` + /// with a different `Mutex` object. + #[inline] + pub fn wait_until( + &self, + mutex_guard: &mut MutexGuard, + timeout: Instant, + ) -> WaitTimeoutResult { + self.wait_until_internal( + unsafe { MutexGuard::mutex(mutex_guard).raw() }, + Some(timeout), + ) + } + + // This is a non-generic function to reduce the monomorphization cost of + // using `wait_until`. + fn wait_until_internal( + &self, + mutex: &RawMutex, + timeout: Option, + ) -> WaitTimeoutResult { + unsafe { + let result; + let mut bad_mutex = false; + let mut requeued = false; + { + let addr = self as *const _ as usize; + let lock_addr = mutex as *const _ as *mut _; + let validate = || { + // Ensure we don't use two different mutexes with the same + // Condvar at the same time. This is done while locked to + // avoid races with notify_one + let state = self.state.load(Ordering::Relaxed); + if state.is_null() { + self.state.store(lock_addr, Ordering::Relaxed); + } else if state != lock_addr { + bad_mutex = true; + return false; + } + true + }; + let before_sleep = || { + // Unlock the mutex before sleeping... + mutex.unlock(); + }; + let timed_out = |k, was_last_thread| { + // If we were requeued to a mutex, then we did not time out. + // We'll just park ourselves on the mutex again when we try + // to lock it later. + requeued = k != addr; + + // If we were the last thread on the queue then we need to + // clear our state. This is normally done by the + // notify_{one,all} functions when not timing out. + if !requeued && was_last_thread { + self.state.store(ptr::null_mut(), Ordering::Relaxed); + } + }; + result = parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + DEFAULT_PARK_TOKEN, + timeout, + ); + } + + // Panic if we tried to use multiple mutexes with a Condvar. Note + // that at this point the MutexGuard is still locked. It will be + // unlocked by the unwinding logic. + if bad_mutex { + panic!("attempted to use a condition variable with more than one mutex"); + } + + // ... and re-lock it once we are done sleeping + if result == ParkResult::Unparked(TOKEN_HANDOFF) { + deadlock::acquire_resource(mutex as *const _ as usize); + } else { + mutex.lock(); + } + + WaitTimeoutResult(!(result.is_unparked() || requeued)) + } + } + + /// Waits on this condition variable for a notification, timing out after a + /// specified duration. + /// + /// The semantics of this function are equivalent to `wait()` except that + /// the thread will be blocked for roughly no longer than `timeout`. This + /// method should not be used for precise timing due to anomalies such as + /// preemption or platform differences that may not cause the maximum + /// amount of time waited to be precisely `timeout`. + /// + /// Note that the best effort is made to ensure that the time waited is + /// measured with a monotonic clock, and not affected by the changes made to + /// the system time. + /// + /// The returned `WaitTimeoutResult` value indicates if the timeout is + /// known to have elapsed. + /// + /// Like `wait`, the lock specified will be re-acquired when this function + /// returns, regardless of whether the timeout elapsed or not. + #[inline] + pub fn wait_for( + &self, + guard: &mut MutexGuard, + timeout: Duration, + ) -> WaitTimeoutResult { + self.wait_until(guard, Instant::now() + timeout) + } +} + +impl Default for Condvar { + #[inline] + fn default() -> Condvar { + Condvar::new() + } +} + +impl fmt::Debug for Condvar { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Condvar { .. }") + } +} + +#[cfg(test)] +mod tests { + use std::sync::mpsc::channel; + use std::sync::Arc; + use std::thread; + use std::time::{Duration, Instant}; + use {Condvar, Mutex}; + + #[test] + fn smoke() { + let c = Condvar::new(); + c.notify_one(); + c.notify_all(); + } + + #[test] + fn notify_one() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + let mut g = m.lock(); + let _t = thread::spawn(move || { + let _g = m2.lock(); + c2.notify_one(); + }); + c.wait(&mut g); + } + + #[test] + fn notify_all() { + const N: usize = 10; + + let data = Arc::new((Mutex::new(0), Condvar::new())); + let (tx, rx) = channel(); + for _ in 0..N { + let data = data.clone(); + let tx = tx.clone(); + thread::spawn(move || { + let &(ref lock, ref cond) = &*data; + let mut cnt = lock.lock(); + *cnt += 1; + if *cnt == N { + tx.send(()).unwrap(); + } + while *cnt != 0 { + cond.wait(&mut cnt); + } + tx.send(()).unwrap(); + }); + } + drop(tx); + + let &(ref lock, ref cond) = &*data; + rx.recv().unwrap(); + let mut cnt = lock.lock(); + *cnt = 0; + cond.notify_all(); + drop(cnt); + + for _ in 0..N { + rx.recv().unwrap(); + } + } + + #[test] + fn wait_for() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + let mut g = m.lock(); + let no_timeout = c.wait_for(&mut g, Duration::from_millis(1)); + assert!(no_timeout.timed_out()); + let _t = thread::spawn(move || { + let _g = m2.lock(); + c2.notify_one(); + }); + let timeout_res = c.wait_for(&mut g, Duration::from_millis(u32::max_value() as u64)); + assert!(!timeout_res.timed_out()); + drop(g); + } + + #[test] + fn wait_until() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + let mut g = m.lock(); + let no_timeout = c.wait_until(&mut g, Instant::now() + Duration::from_millis(1)); + assert!(no_timeout.timed_out()); + let _t = thread::spawn(move || { + let _g = m2.lock(); + c2.notify_one(); + }); + let timeout_res = c.wait_until( + &mut g, + Instant::now() + Duration::from_millis(u32::max_value() as u64), + ); + assert!(!timeout_res.timed_out()); + drop(g); + } + + #[test] + #[should_panic] + fn two_mutexes() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let m3 = Arc::new(Mutex::new(())); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + // Make sure we don't leave the child thread dangling + struct PanicGuard<'a>(&'a Condvar); + impl<'a> Drop for PanicGuard<'a> { + fn drop(&mut self) { + self.0.notify_one(); + } + } + + let (tx, rx) = channel(); + let g = m.lock(); + let _t = thread::spawn(move || { + let mut g = m2.lock(); + tx.send(()).unwrap(); + c2.wait(&mut g); + }); + drop(g); + rx.recv().unwrap(); + let _g = m.lock(); + let _guard = PanicGuard(&*c); + let _ = c.wait(&mut m3.lock()); + } + + #[test] + fn two_mutexes_disjoint() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let m3 = Arc::new(Mutex::new(())); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + let mut g = m.lock(); + let _t = thread::spawn(move || { + let _g = m2.lock(); + c2.notify_one(); + }); + c.wait(&mut g); + drop(g); + + let _ = c.wait_for(&mut m3.lock(), Duration::from_millis(1)); + } + + #[test] + fn test_debug_condvar() { + let c = Condvar::new(); + assert_eq!(format!("{:?}", c), "Condvar { .. }"); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/deadlock.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/deadlock.rs new file mode 100644 index 0000000..ef7d619 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/deadlock.rs @@ -0,0 +1,218 @@ +//! \[Experimental\] Deadlock detection +//! +//! This feature is optional and can be enabled via the `deadlock_detection` feature flag. +//! +//! # Example +//! +//! ``` +//! #[cfg(feature = "deadlock_detection")] +//! { // only for #[cfg] +//! use std::thread; +//! use std::time::Duration; +//! use parking_lot::deadlock; +//! +//! // Create a background thread which checks for deadlocks every 10s +//! thread::spawn(move || { +//! loop { +//! thread::sleep(Duration::from_secs(10)); +//! let deadlocks = deadlock::check_deadlock(); +//! if deadlocks.is_empty() { +//! continue; +//! } +//! +//! println!("{} deadlocks detected", deadlocks.len()); +//! for (i, threads) in deadlocks.iter().enumerate() { +//! println!("Deadlock #{}", i); +//! for t in threads { +//! println!("Thread Id {:#?}", t.thread_id()); +//! println!("{:#?}", t.backtrace()); +//! } +//! } +//! } +//! }); +//! } // only for #[cfg] +//! ``` + +#[cfg(feature = "deadlock_detection")] +pub use parking_lot_core::deadlock::check_deadlock; +pub(crate) use parking_lot_core::deadlock::{acquire_resource, release_resource}; + +#[cfg(test)] +#[cfg(feature = "deadlock_detection")] +mod tests { + use std::sync::{Arc, Barrier}; + use std::thread::{self, sleep}; + use std::time::Duration; + use {Mutex, ReentrantMutex, RwLock}; + + fn check_deadlock() -> bool { + use parking_lot_core::deadlock::check_deadlock; + !check_deadlock().is_empty() + } + + #[test] + fn test_mutex_deadlock() { + let m1: Arc> = Default::default(); + let m2: Arc> = Default::default(); + let m3: Arc> = Default::default(); + let b = Arc::new(Barrier::new(4)); + + let m1_ = m1.clone(); + let m2_ = m2.clone(); + let m3_ = m3.clone(); + let b1 = b.clone(); + let b2 = b.clone(); + let b3 = b.clone(); + + assert!(!check_deadlock()); + + let _t1 = thread::spawn(move || { + let _g = m1.lock(); + b1.wait(); + let _ = m2_.lock(); + }); + + let _t2 = thread::spawn(move || { + let _g = m2.lock(); + b2.wait(); + let _ = m3_.lock(); + }); + + let _t3 = thread::spawn(move || { + let _g = m3.lock(); + b3.wait(); + let _ = m1_.lock(); + }); + + assert!(!check_deadlock()); + + b.wait(); + sleep(Duration::from_millis(50)); + assert!(check_deadlock()); + + assert!(!check_deadlock()); + } + + #[test] + fn test_mutex_deadlock_reentrant() { + let m1: Arc> = Default::default(); + + assert!(!check_deadlock()); + + let _t1 = thread::spawn(move || { + let _g = m1.lock(); + let _ = m1.lock(); + }); + + sleep(Duration::from_millis(50)); + assert!(check_deadlock()); + + assert!(!check_deadlock()); + } + + #[test] + fn test_remutex_deadlock() { + let m1: Arc> = Default::default(); + let m2: Arc> = Default::default(); + let m3: Arc> = Default::default(); + let b = Arc::new(Barrier::new(4)); + + let m1_ = m1.clone(); + let m2_ = m2.clone(); + let m3_ = m3.clone(); + let b1 = b.clone(); + let b2 = b.clone(); + let b3 = b.clone(); + + assert!(!check_deadlock()); + + let _t1 = thread::spawn(move || { + let _g = m1.lock(); + let _g = m1.lock(); + b1.wait(); + let _ = m2_.lock(); + }); + + let _t2 = thread::spawn(move || { + let _g = m2.lock(); + let _g = m2.lock(); + b2.wait(); + let _ = m3_.lock(); + }); + + let _t3 = thread::spawn(move || { + let _g = m3.lock(); + let _g = m3.lock(); + b3.wait(); + let _ = m1_.lock(); + }); + + assert!(!check_deadlock()); + + b.wait(); + sleep(Duration::from_millis(50)); + assert!(check_deadlock()); + + assert!(!check_deadlock()); + } + + #[test] + fn test_rwlock_deadlock() { + let m1: Arc> = Default::default(); + let m2: Arc> = Default::default(); + let m3: Arc> = Default::default(); + let b = Arc::new(Barrier::new(4)); + + let m1_ = m1.clone(); + let m2_ = m2.clone(); + let m3_ = m3.clone(); + let b1 = b.clone(); + let b2 = b.clone(); + let b3 = b.clone(); + + assert!(!check_deadlock()); + + let _t1 = thread::spawn(move || { + let _g = m1.read(); + b1.wait(); + let _g = m2_.write(); + }); + + let _t2 = thread::spawn(move || { + let _g = m2.read(); + b2.wait(); + let _g = m3_.write(); + }); + + let _t3 = thread::spawn(move || { + let _g = m3.read(); + b3.wait(); + let _ = m1_.write(); + }); + + assert!(!check_deadlock()); + + b.wait(); + sleep(Duration::from_millis(50)); + assert!(check_deadlock()); + + assert!(!check_deadlock()); + } + + #[test] + fn test_rwlock_deadlock_reentrant() { + let m1: Arc> = Default::default(); + + assert!(!check_deadlock()); + + let _t1 = thread::spawn(move || { + let _g = m1.read(); + let _ = m1.write(); + }); + + sleep(Duration::from_millis(50)); + assert!(check_deadlock()); + + assert!(!check_deadlock()); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/elision.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/elision.rs new file mode 100644 index 0000000..23895b1 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/elision.rs @@ -0,0 +1,169 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::sync::atomic::AtomicUsize; + +// Extension trait to add lock elision primitives to atomic types +pub trait AtomicElisionExt { + type IntType; + + // Perform a compare_exchange and start a transaction + fn elision_acquire( + &self, + current: Self::IntType, + new: Self::IntType, + ) -> Result; + // Perform a compare_exchange and end a transaction + fn elision_release( + &self, + current: Self::IntType, + new: Self::IntType, + ) -> Result; +} + +// Indicates whether the target architecture supports lock elision +#[inline] +pub fn have_elision() -> bool { + cfg!(all( + feature = "nightly", + any(target_arch = "x86", target_arch = "x86_64"), + )) +} + +// This implementation is never actually called because it is guarded by +// have_elision(). +#[cfg(not(all(feature = "nightly", any(target_arch = "x86", target_arch = "x86_64"))))] +impl AtomicElisionExt for AtomicUsize { + type IntType = usize; + + #[inline] + fn elision_acquire(&self, _: usize, _: usize) -> Result { + unreachable!(); + } + + #[inline] + fn elision_release(&self, _: usize, _: usize) -> Result { + unreachable!(); + } +} + +#[cfg(all(feature = "nightly", target_arch = "x86"))] +impl AtomicElisionExt for AtomicUsize { + type IntType = usize; + + #[inline] + fn elision_acquire(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xacquire; lock; cmpxchgl $2, $1" + : "={eax}" (prev), "+*m" (self) + : "r" (new), "{eax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } + + #[inline] + fn elision_release(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xrelease; lock; cmpxchgl $2, $1" + : "={eax}" (prev), "+*m" (self) + : "r" (new), "{eax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } +} + +#[cfg(all(feature = "nightly", target_arch = "x86_64", target_pointer_width = "32"))] +impl AtomicElisionExt for AtomicUsize { + type IntType = usize; + + #[inline] + fn elision_acquire(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xacquire; lock; cmpxchgl $2, $1" + : "={rax}" (prev), "+*m" (self) + : "r" (new), "{rax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } + + #[inline] + fn elision_release(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xrelease; lock; cmpxchgl $2, $1" + : "={rax}" (prev), "+*m" (self) + : "r" (new), "{rax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } +} + +#[cfg(all(feature = "nightly", target_arch = "x86_64", target_pointer_width = "64"))] +impl AtomicElisionExt for AtomicUsize { + type IntType = usize; + + #[inline] + fn elision_acquire(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xacquire; lock; cmpxchgq $2, $1" + : "={rax}" (prev), "+*m" (self) + : "r" (new), "{rax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } + + #[inline] + fn elision_release(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xrelease; lock; cmpxchgq $2, $1" + : "={rax}" (prev), "+*m" (self) + : "r" (new), "{rax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/lib.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/lib.rs new file mode 100644 index 0000000..f16b821 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/lib.rs @@ -0,0 +1,44 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +//! This library provides implementations of `Mutex`, `RwLock`, `Condvar` and +//! `Once` that are smaller, faster and more flexible than those in the Rust +//! standard library. It also provides a `ReentrantMutex` type. + +#![warn(missing_docs)] +#![cfg_attr(feature = "nightly", feature(const_fn))] +#![cfg_attr(feature = "nightly", feature(integer_atomics))] +#![cfg_attr(feature = "nightly", feature(asm))] + +extern crate lock_api; +extern crate parking_lot_core; + +mod condvar; +mod elision; +mod mutex; +mod once; +mod raw_mutex; +mod raw_rwlock; +mod remutex; +mod rwlock; +mod util; + +#[cfg(feature = "deadlock_detection")] +pub mod deadlock; +#[cfg(not(feature = "deadlock_detection"))] +mod deadlock; + +pub use condvar::{Condvar, WaitTimeoutResult}; +pub use mutex::{MappedMutexGuard, Mutex, MutexGuard}; +pub use once::{Once, OnceState, ONCE_INIT}; +pub use raw_mutex::RawMutex; +pub use raw_rwlock::RawRwLock; +pub use remutex::{MappedReentrantMutexGuard, RawThreadId, ReentrantMutex, ReentrantMutexGuard}; +pub use rwlock::{ + MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLock, RwLockReadGuard, + RwLockUpgradableReadGuard, RwLockWriteGuard, +}; diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/mutex.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/mutex.rs new file mode 100644 index 0000000..d530400 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/mutex.rs @@ -0,0 +1,298 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use lock_api; +use raw_mutex::RawMutex; + +/// A mutual exclusion primitive useful for protecting shared data +/// +/// This mutex will block threads waiting for the lock to become available. The +/// mutex can also be statically initialized or created via a `new` +/// constructor. Each mutex has a type parameter which represents the data that +/// it is protecting. The data can only be accessed through the RAII guards +/// returned from `lock` and `try_lock`, which guarantees that the data is only +/// ever accessed when the mutex is locked. +/// +/// # Fairness +/// +/// A typical unfair lock can often end up in a situation where a single thread +/// quickly acquires and releases the same mutex in succession, which can starve +/// other threads waiting to acquire the mutex. While this improves performance +/// because it doesn't force a context switch when a thread tries to re-acquire +/// a mutex it has just released, this can starve other threads. +/// +/// This mutex uses [eventual fairness](https://trac.webkit.org/changeset/203350) +/// to ensure that the lock will be fair on average without sacrificing +/// performance. This is done by forcing a fair unlock on average every 0.5ms, +/// which will force the lock to go to the next thread waiting for the mutex. +/// +/// Additionally, any critical section longer than 1ms will always use a fair +/// unlock, which has a negligible performance impact compared to the length of +/// the critical section. +/// +/// You can also force a fair unlock by calling `MutexGuard::unlock_fair` when +/// unlocking a mutex instead of simply dropping the `MutexGuard`. +/// +/// # Differences from the standard library `Mutex` +/// +/// - No poisoning, the lock is released normally on panic. +/// - Only requires 1 byte of space, whereas the standard library boxes the +/// `Mutex` due to platform limitations. +/// - Can be statically constructed (requires the `const_fn` nightly feature). +/// - Does not require any drop glue when dropped. +/// - Inline fast path for the uncontended case. +/// - Efficient handling of micro-contention using adaptive spinning. +/// - Allows raw locking & unlocking without a guard. +/// - Supports eventual fairness so that the mutex is fair on average. +/// - Optionally allows making the mutex fair by calling `MutexGuard::unlock_fair`. +/// +/// # Examples +/// +/// ``` +/// use std::sync::Arc; +/// use parking_lot::Mutex; +/// use std::thread; +/// use std::sync::mpsc::channel; +/// +/// const N: usize = 10; +/// +/// // Spawn a few threads to increment a shared variable (non-atomically), and +/// // let the main thread know once all increments are done. +/// // +/// // Here we're using an Arc to share memory among threads, and the data inside +/// // the Arc is protected with a mutex. +/// let data = Arc::new(Mutex::new(0)); +/// +/// let (tx, rx) = channel(); +/// for _ in 0..10 { +/// let (data, tx) = (data.clone(), tx.clone()); +/// thread::spawn(move || { +/// // The shared state can only be accessed once the lock is held. +/// // Our non-atomic increment is safe because we're the only thread +/// // which can access the shared state when the lock is held. +/// let mut data = data.lock(); +/// *data += 1; +/// if *data == N { +/// tx.send(()).unwrap(); +/// } +/// // the lock is unlocked here when `data` goes out of scope. +/// }); +/// } +/// +/// rx.recv().unwrap(); +/// ``` +pub type Mutex = lock_api::Mutex; + +/// An RAII implementation of a "scoped lock" of a mutex. When this structure is +/// dropped (falls out of scope), the lock will be unlocked. +/// +/// The data protected by the mutex can be accessed through this guard via its +/// `Deref` and `DerefMut` implementations. +pub type MutexGuard<'a, T> = lock_api::MutexGuard<'a, RawMutex, T>; + +/// An RAII mutex guard returned by `MutexGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedMutexGuard` and `MutexGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +pub type MappedMutexGuard<'a, T> = lock_api::MappedMutexGuard<'a, RawMutex, T>; + +#[cfg(test)] +mod tests { + use std::sync::atomic::{AtomicUsize, Ordering}; + use std::sync::mpsc::channel; + use std::sync::Arc; + use std::thread; + use {Condvar, Mutex}; + + struct Packet(Arc<(Mutex, Condvar)>); + + #[derive(Eq, PartialEq, Debug)] + struct NonCopy(i32); + + unsafe impl Send for Packet {} + unsafe impl Sync for Packet {} + + #[test] + fn smoke() { + let m = Mutex::new(()); + drop(m.lock()); + drop(m.lock()); + } + + #[test] + fn lots_and_lots() { + const J: u32 = 1000; + const K: u32 = 3; + + let m = Arc::new(Mutex::new(0)); + + fn inc(m: &Mutex) { + for _ in 0..J { + *m.lock() += 1; + } + } + + let (tx, rx) = channel(); + for _ in 0..K { + let tx2 = tx.clone(); + let m2 = m.clone(); + thread::spawn(move || { + inc(&m2); + tx2.send(()).unwrap(); + }); + let tx2 = tx.clone(); + let m2 = m.clone(); + thread::spawn(move || { + inc(&m2); + tx2.send(()).unwrap(); + }); + } + + drop(tx); + for _ in 0..2 * K { + rx.recv().unwrap(); + } + assert_eq!(*m.lock(), J * K * 2); + } + + #[test] + fn try_lock() { + let m = Mutex::new(()); + *m.try_lock().unwrap() = (); + } + + #[test] + fn test_into_inner() { + let m = Mutex::new(NonCopy(10)); + assert_eq!(m.into_inner(), NonCopy(10)); + } + + #[test] + fn test_into_inner_drop() { + struct Foo(Arc); + impl Drop for Foo { + fn drop(&mut self) { + self.0.fetch_add(1, Ordering::SeqCst); + } + } + let num_drops = Arc::new(AtomicUsize::new(0)); + let m = Mutex::new(Foo(num_drops.clone())); + assert_eq!(num_drops.load(Ordering::SeqCst), 0); + { + let _inner = m.into_inner(); + assert_eq!(num_drops.load(Ordering::SeqCst), 0); + } + assert_eq!(num_drops.load(Ordering::SeqCst), 1); + } + + #[test] + fn test_get_mut() { + let mut m = Mutex::new(NonCopy(10)); + *m.get_mut() = NonCopy(20); + assert_eq!(m.into_inner(), NonCopy(20)); + } + + #[test] + fn test_mutex_arc_condvar() { + let packet = Packet(Arc::new((Mutex::new(false), Condvar::new()))); + let packet2 = Packet(packet.0.clone()); + let (tx, rx) = channel(); + let _t = thread::spawn(move || { + // wait until parent gets in + rx.recv().unwrap(); + let &(ref lock, ref cvar) = &*packet2.0; + let mut lock = lock.lock(); + *lock = true; + cvar.notify_one(); + }); + + let &(ref lock, ref cvar) = &*packet.0; + let mut lock = lock.lock(); + tx.send(()).unwrap(); + assert!(!*lock); + while !*lock { + cvar.wait(&mut lock); + } + } + + #[test] + fn test_mutex_arc_nested() { + // Tests nested mutexes and access + // to underlying data. + let arc = Arc::new(Mutex::new(1)); + let arc2 = Arc::new(Mutex::new(arc)); + let (tx, rx) = channel(); + let _t = thread::spawn(move || { + let lock = arc2.lock(); + let lock2 = lock.lock(); + assert_eq!(*lock2, 1); + tx.send(()).unwrap(); + }); + rx.recv().unwrap(); + } + + #[test] + fn test_mutex_arc_access_in_unwind() { + let arc = Arc::new(Mutex::new(1)); + let arc2 = arc.clone(); + let _ = thread::spawn(move || -> () { + struct Unwinder { + i: Arc>, + } + impl Drop for Unwinder { + fn drop(&mut self) { + *self.i.lock() += 1; + } + } + let _u = Unwinder { i: arc2 }; + panic!(); + }).join(); + let lock = arc.lock(); + assert_eq!(*lock, 2); + } + + #[test] + fn test_mutex_unsized() { + let mutex: &Mutex<[i32]> = &Mutex::new([1, 2, 3]); + { + let b = &mut *mutex.lock(); + b[0] = 4; + b[2] = 5; + } + let comp: &[i32] = &[4, 2, 5]; + assert_eq!(&*mutex.lock(), comp); + } + + #[test] + fn test_mutexguard_sync() { + fn sync(_: T) {} + + let mutex = Mutex::new(()); + sync(mutex.lock()); + } + + #[test] + fn test_mutex_debug() { + let mutex = Mutex::new(vec![0u8, 10]); + + assert_eq!(format!("{:?}", mutex), "Mutex { data: [0, 10] }"); + assert_eq!( + format!("{:#?}", mutex), + "Mutex { + data: [ + 0, + 10 + ] +}" + ); + let _lock = mutex.lock(); + assert_eq!(format!("{:?}", mutex), "Mutex { }"); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/once.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/once.rs new file mode 100644 index 0000000..f3e70be --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/once.rs @@ -0,0 +1,488 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::sync::atomic::{fence, Ordering}; +#[cfg(feature = "nightly")] +use std::sync::atomic::{ATOMIC_U8_INIT, AtomicU8}; +#[cfg(feature = "nightly")] +type U8 = u8; +#[cfg(not(feature = "nightly"))] +use std::sync::atomic::AtomicUsize as AtomicU8; +#[cfg(not(feature = "nightly"))] +use std::sync::atomic::ATOMIC_USIZE_INIT as ATOMIC_U8_INIT; +#[cfg(not(feature = "nightly"))] +type U8 = usize; +use parking_lot_core::{self, SpinWait, DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN}; +use std::fmt; +use std::mem; +use util::UncheckedOptionExt; + +const DONE_BIT: U8 = 1; +const POISON_BIT: U8 = 2; +const LOCKED_BIT: U8 = 4; +const PARKED_BIT: U8 = 8; + +/// Current state of a `Once`. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub enum OnceState { + /// A closure has not been executed yet + New, + + /// A closure was executed but panicked. + Poisoned, + + /// A thread is currently executing a closure. + InProgress, + + /// A closure has completed sucessfully. + Done, +} + +impl OnceState { + /// Returns whether the associated `Once` has been poisoned. + /// + /// Once an initalization routine for a `Once` has panicked it will forever + /// indicate to future forced initialization routines that it is poisoned. + #[inline] + pub fn poisoned(&self) -> bool { + match *self { + OnceState::Poisoned => true, + _ => false, + } + } + + /// Returns whether the associated `Once` has successfullly executed a + /// closure. + #[inline] + pub fn done(&self) -> bool { + match *self { + OnceState::Done => true, + _ => false, + } + } +} + +/// A synchronization primitive which can be used to run a one-time +/// initialization. Useful for one-time initialization for globals, FFI or +/// related functionality. +/// +/// # Differences from the standard library `Once` +/// +/// - Only requires 1 byte of space, instead of 1 word. +/// - Not required to be `'static`. +/// - Relaxed memory barriers in the fast path, which can significantly improve +/// performance on some architectures. +/// - Efficient handling of micro-contention using adaptive spinning. +/// +/// # Examples +/// +/// ``` +/// use parking_lot::{Once, ONCE_INIT}; +/// +/// static START: Once = ONCE_INIT; +/// +/// START.call_once(|| { +/// // run initialization here +/// }); +/// ``` +pub struct Once(AtomicU8); + +/// Initialization value for static `Once` values. +pub const ONCE_INIT: Once = Once(ATOMIC_U8_INIT); + +impl Once { + /// Creates a new `Once` value. + #[cfg(feature = "nightly")] + #[inline] + pub const fn new() -> Once { + Once(ATOMIC_U8_INIT) + } + + /// Creates a new `Once` value. + #[cfg(not(feature = "nightly"))] + #[inline] + pub fn new() -> Once { + Once(ATOMIC_U8_INIT) + } + + /// Returns the current state of this `Once`. + #[inline] + pub fn state(&self) -> OnceState { + let state = self.0.load(Ordering::Acquire); + if state & DONE_BIT != 0 { + OnceState::Done + } else if state & LOCKED_BIT != 0 { + OnceState::InProgress + } else if state & POISON_BIT != 0 { + OnceState::Poisoned + } else { + OnceState::New + } + } + + /// Performs an initialization routine once and only once. The given closure + /// will be executed if this is the first time `call_once` has been called, + /// and otherwise the routine will *not* be invoked. + /// + /// This method will block the calling thread if another initialization + /// routine is currently running. + /// + /// When this function returns, it is guaranteed that some initialization + /// has run and completed (it may not be the closure specified). It is also + /// guaranteed that any memory writes performed by the executed closure can + /// be reliably observed by other threads at this point (there is a + /// happens-before relation between the closure and code executing after the + /// return). + /// + /// # Examples + /// + /// ``` + /// use parking_lot::{Once, ONCE_INIT}; + /// + /// static mut VAL: usize = 0; + /// static INIT: Once = ONCE_INIT; + /// + /// // Accessing a `static mut` is unsafe much of the time, but if we do so + /// // in a synchronized fashion (e.g. write once or read all) then we're + /// // good to go! + /// // + /// // This function will only call `expensive_computation` once, and will + /// // otherwise always return the value returned from the first invocation. + /// fn get_cached_val() -> usize { + /// unsafe { + /// INIT.call_once(|| { + /// VAL = expensive_computation(); + /// }); + /// VAL + /// } + /// } + /// + /// fn expensive_computation() -> usize { + /// // ... + /// # 2 + /// } + /// ``` + /// + /// # Panics + /// + /// The closure `f` will only be executed once if this is called + /// concurrently amongst many threads. If that closure panics, however, then + /// it will *poison* this `Once` instance, causing all future invocations of + /// `call_once` to also panic. + #[inline] + pub fn call_once(&self, f: F) + where + F: FnOnce(), + { + if self.0.load(Ordering::Acquire) == DONE_BIT { + return; + } + + let mut f = Some(f); + self.call_once_slow(false, &mut |_| unsafe { f.take().unchecked_unwrap()() }); + } + + /// Performs the same function as `call_once` except ignores poisoning. + /// + /// If this `Once` has been poisoned (some initialization panicked) then + /// this function will continue to attempt to call initialization functions + /// until one of them doesn't panic. + /// + /// The closure `f` is yielded a structure which can be used to query the + /// state of this `Once` (whether initialization has previously panicked or + /// not). + #[inline] + pub fn call_once_force(&self, f: F) + where + F: FnOnce(OnceState), + { + if self.0.load(Ordering::Acquire) == DONE_BIT { + return; + } + + let mut f = Some(f); + self.call_once_slow(true, &mut |state| unsafe { + f.take().unchecked_unwrap()(state) + }); + } + + // This is a non-generic function to reduce the monomorphization cost of + // using `call_once` (this isn't exactly a trivial or small implementation). + // + // Additionally, this is tagged with `#[cold]` as it should indeed be cold + // and it helps let LLVM know that calls to this function should be off the + // fast path. Essentially, this should help generate more straight line code + // in LLVM. + // + // Finally, this takes an `FnMut` instead of a `FnOnce` because there's + // currently no way to take an `FnOnce` and call it via virtual dispatch + // without some allocation overhead. + #[cold] + #[inline(never)] + fn call_once_slow(&self, ignore_poison: bool, f: &mut FnMut(OnceState)) { + let mut spinwait = SpinWait::new(); + let mut state = self.0.load(Ordering::Relaxed); + loop { + // If another thread called the closure, we're done + if state & DONE_BIT != 0 { + // An acquire fence is needed here since we didn't load the + // state with Ordering::Acquire. + fence(Ordering::Acquire); + return; + } + + // If the state has been poisoned and we aren't forcing, then panic + if state & POISON_BIT != 0 && !ignore_poison { + // Need the fence here as well for the same reason + fence(Ordering::Acquire); + panic!("Once instance has previously been poisoned"); + } + + // Grab the lock if it isn't locked, even if there is a queue on it. + // We also clear the poison bit since we are going to try running + // the closure again. + if state & LOCKED_BIT == 0 { + match self.0.compare_exchange_weak( + state, + (state | LOCKED_BIT) & !POISON_BIT, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => break, + Err(x) => state = x, + } + continue; + } + + // If there is no queue, try spinning a few times + if state & PARKED_BIT == 0 && spinwait.spin() { + state = self.0.load(Ordering::Relaxed); + continue; + } + + // Set the parked bit + if state & PARKED_BIT == 0 { + if let Err(x) = self.0.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + state = x; + continue; + } + } + + // Park our thread until we are woken up by the thread that owns the + // lock. + unsafe { + let addr = self as *const _ as usize; + let validate = || self.0.load(Ordering::Relaxed) == LOCKED_BIT | PARKED_BIT; + let before_sleep = || {}; + let timed_out = |_, _| unreachable!(); + parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + DEFAULT_PARK_TOKEN, + None, + ); + } + + // Loop back and check if the done bit was set + spinwait.reset(); + state = self.0.load(Ordering::Relaxed); + } + + struct PanicGuard<'a>(&'a Once); + impl<'a> Drop for PanicGuard<'a> { + fn drop(&mut self) { + // Mark the state as poisoned, unlock it and unpark all threads. + let once = self.0; + let state = once.0.swap(POISON_BIT, Ordering::Release); + if state & PARKED_BIT != 0 { + unsafe { + let addr = once as *const _ as usize; + parking_lot_core::unpark_all(addr, DEFAULT_UNPARK_TOKEN); + } + } + } + } + + // At this point we have the lock, so run the closure. Make sure we + // properly clean up if the closure panicks. + let guard = PanicGuard(self); + let once_state = if state & POISON_BIT != 0 { + OnceState::Poisoned + } else { + OnceState::New + }; + f(once_state); + mem::forget(guard); + + // Now unlock the state, set the done bit and unpark all threads + let state = self.0.swap(DONE_BIT, Ordering::Release); + if state & PARKED_BIT != 0 { + unsafe { + let addr = self as *const _ as usize; + parking_lot_core::unpark_all(addr, DEFAULT_UNPARK_TOKEN); + } + } + } +} + +impl Default for Once { + #[inline] + fn default() -> Once { + Once::new() + } +} + +impl fmt::Debug for Once { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Once") + .field("state", &self.state()) + .finish() + } +} + +#[cfg(test)] +mod tests { + #[cfg(feature = "nightly")] + use std::panic; + use std::sync::mpsc::channel; + use std::thread; + use {Once, ONCE_INIT}; + + #[test] + fn smoke_once() { + static O: Once = ONCE_INIT; + let mut a = 0; + O.call_once(|| a += 1); + assert_eq!(a, 1); + O.call_once(|| a += 1); + assert_eq!(a, 1); + } + + #[test] + fn stampede_once() { + static O: Once = ONCE_INIT; + static mut RUN: bool = false; + + let (tx, rx) = channel(); + for _ in 0..10 { + let tx = tx.clone(); + thread::spawn(move || { + for _ in 0..4 { + thread::yield_now() + } + unsafe { + O.call_once(|| { + assert!(!RUN); + RUN = true; + }); + assert!(RUN); + } + tx.send(()).unwrap(); + }); + } + + unsafe { + O.call_once(|| { + assert!(!RUN); + RUN = true; + }); + assert!(RUN); + } + + for _ in 0..10 { + rx.recv().unwrap(); + } + } + + #[cfg(feature = "nightly")] + #[test] + fn poison_bad() { + static O: Once = ONCE_INIT; + + // poison the once + let t = panic::catch_unwind(|| { + O.call_once(|| panic!()); + }); + assert!(t.is_err()); + + // poisoning propagates + let t = panic::catch_unwind(|| { + O.call_once(|| {}); + }); + assert!(t.is_err()); + + // we can subvert poisoning, however + let mut called = false; + O.call_once_force(|p| { + called = true; + assert!(p.poisoned()) + }); + assert!(called); + + // once any success happens, we stop propagating the poison + O.call_once(|| {}); + } + + #[cfg(feature = "nightly")] + #[test] + fn wait_for_force_to_finish() { + static O: Once = ONCE_INIT; + + // poison the once + let t = panic::catch_unwind(|| { + O.call_once(|| panic!()); + }); + assert!(t.is_err()); + + // make sure someone's waiting inside the once via a force + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + let t1 = thread::spawn(move || { + O.call_once_force(|p| { + assert!(p.poisoned()); + tx1.send(()).unwrap(); + rx2.recv().unwrap(); + }); + }); + + rx1.recv().unwrap(); + + // put another waiter on the once + let t2 = thread::spawn(|| { + let mut called = false; + O.call_once(|| { + called = true; + }); + assert!(!called); + }); + + tx2.send(()).unwrap(); + + assert!(t1.join().is_ok()); + assert!(t2.join().is_ok()); + } + + #[test] + fn test_once_debug() { + static O: Once = ONCE_INIT; + + assert_eq!(format!("{:?}", O), "Once { state: New }"); + assert_eq!( + format!("{:#?}", O), + "Once { + state: New +}" + ); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/raw_mutex.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/raw_mutex.rs new file mode 100644 index 0000000..1ba5581 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/raw_mutex.rs @@ -0,0 +1,312 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::sync::atomic::Ordering; +#[cfg(feature = "nightly")] +use std::sync::atomic::{ATOMIC_U8_INIT, AtomicU8}; +#[cfg(feature = "nightly")] +type U8 = u8; +#[cfg(not(feature = "nightly"))] +use std::sync::atomic::AtomicUsize as AtomicU8; +#[cfg(not(feature = "nightly"))] +use std::sync::atomic::ATOMIC_USIZE_INIT as ATOMIC_U8_INIT; +#[cfg(not(feature = "nightly"))] +type U8 = usize; +use deadlock; +use lock_api::{GuardNoSend, RawMutex as RawMutexTrait, RawMutexFair, RawMutexTimed}; +use parking_lot_core::{self, ParkResult, SpinWait, UnparkResult, UnparkToken, DEFAULT_PARK_TOKEN}; +use std::time::{Duration, Instant}; + +// UnparkToken used to indicate that that the target thread should attempt to +// lock the mutex again as soon as it is unparked. +pub(crate) const TOKEN_NORMAL: UnparkToken = UnparkToken(0); + +// UnparkToken used to indicate that the mutex is being handed off to the target +// thread directly without unlocking it. +pub(crate) const TOKEN_HANDOFF: UnparkToken = UnparkToken(1); + +const LOCKED_BIT: U8 = 1; +const PARKED_BIT: U8 = 2; + +/// Raw mutex type backed by the parking lot. +pub struct RawMutex { + state: AtomicU8, +} + +unsafe impl RawMutexTrait for RawMutex { + const INIT: RawMutex = RawMutex { + state: ATOMIC_U8_INIT, + }; + + type GuardMarker = GuardNoSend; + + #[inline] + fn lock(&self) { + if self + .state + .compare_exchange_weak(0, LOCKED_BIT, Ordering::Acquire, Ordering::Relaxed) + .is_err() + { + self.lock_slow(None); + } + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + + #[inline] + fn try_lock(&self) -> bool { + let mut state = self.state.load(Ordering::Relaxed); + loop { + if state & LOCKED_BIT != 0 { + return false; + } + match self.state.compare_exchange_weak( + state, + state | LOCKED_BIT, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + return true; + } + Err(x) => state = x, + } + } + } + + #[inline] + fn unlock(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(LOCKED_BIT, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_slow(false); + } +} + +unsafe impl RawMutexFair for RawMutex { + #[inline] + fn unlock_fair(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(LOCKED_BIT, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_slow(true); + } + + #[inline] + fn bump(&self) { + if self.state.load(Ordering::Relaxed) & PARKED_BIT != 0 { + self.bump_slow(); + } + } +} + +unsafe impl RawMutexTimed for RawMutex { + type Duration = Duration; + type Instant = Instant; + + #[inline] + fn try_lock_until(&self, timeout: Instant) -> bool { + let result = if self + .state + .compare_exchange_weak(0, LOCKED_BIT, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + true + } else { + self.lock_slow(Some(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_for(&self, timeout: Duration) -> bool { + let result = if self + .state + .compare_exchange_weak(0, LOCKED_BIT, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + true + } else { + self.lock_slow(Some(Instant::now() + timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } +} + +impl RawMutex { + // Used by Condvar when requeuing threads to us, must be called while + // holding the queue lock. + #[inline] + pub(crate) fn mark_parked_if_locked(&self) -> bool { + let mut state = self.state.load(Ordering::Relaxed); + loop { + if state & LOCKED_BIT == 0 { + return false; + } + match self.state.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + } + } + + // Used by Condvar when requeuing threads to us, must be called while + // holding the queue lock. + #[inline] + pub(crate) fn mark_parked(&self) { + self.state.fetch_or(PARKED_BIT, Ordering::Relaxed); + } + + #[cold] + #[inline(never)] + fn lock_slow(&self, timeout: Option) -> bool { + let mut spinwait = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Grab the lock if it isn't locked, even if there is a queue on it + if state & LOCKED_BIT == 0 { + match self.state.compare_exchange_weak( + state, + state | LOCKED_BIT, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + continue; + } + + // If there is no queue, try spinning a few times + if state & PARKED_BIT == 0 && spinwait.spin() { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Set the parked bit + if state & PARKED_BIT == 0 { + if let Err(x) = self.state.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + state = x; + continue; + } + } + + // Park our thread until we are woken up by an unlock + unsafe { + let addr = self as *const _ as usize; + let validate = || self.state.load(Ordering::Relaxed) == LOCKED_BIT | PARKED_BIT; + let before_sleep = || {}; + let timed_out = |_, was_last_thread| { + // Clear the parked bit if we were the last parked thread + if was_last_thread { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + }; + match parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + DEFAULT_PARK_TOKEN, + timeout, + ) { + // The thread that unparked us passed the lock on to us + // directly without unlocking it. + ParkResult::Unparked(TOKEN_HANDOFF) => return true, + + // We were unparked normally, try acquiring the lock again + ParkResult::Unparked(_) => (), + + // The validation function failed, try locking again + ParkResult::Invalid => (), + + // Timeout expired + ParkResult::TimedOut => return false, + } + } + + // Loop back and try locking again + spinwait.reset(); + state = self.state.load(Ordering::Relaxed); + } + } + + #[cold] + #[inline(never)] + fn unlock_slow(&self, force_fair: bool) { + // Unlock directly if there are no parked threads + if self + .state + .compare_exchange(LOCKED_BIT, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + + // Unpark one thread and leave the parked bit set if there might + // still be parked threads on this address. + unsafe { + let addr = self as *const _ as usize; + let callback = |result: UnparkResult| { + // If we are using a fair unlock then we should keep the + // mutex locked and hand it off to the unparked thread. + if result.unparked_threads != 0 && (force_fair || result.be_fair) { + // Clear the parked bit if there are no more parked + // threads. + if !result.have_more_threads { + self.state.store(LOCKED_BIT, Ordering::Relaxed); + } + return TOKEN_HANDOFF; + } + + // Clear the locked bit, and the parked bit as well if there + // are no more parked threads. + if result.have_more_threads { + self.state.store(PARKED_BIT, Ordering::Release); + } else { + self.state.store(0, Ordering::Release); + } + TOKEN_NORMAL + }; + parking_lot_core::unpark_one(addr, callback); + } + } + + #[cold] + #[inline(never)] + fn bump_slow(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + self.unlock_slow(true); + self.lock(); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/raw_rwlock.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/raw_rwlock.rs new file mode 100644 index 0000000..f59a6ac --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/raw_rwlock.rs @@ -0,0 +1,1402 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use deadlock; +use elision::{have_elision, AtomicElisionExt}; +use lock_api::{ + GuardNoSend, RawRwLock as RawRwLockTrait, RawRwLockDowngrade, RawRwLockFair, + RawRwLockRecursive, RawRwLockRecursiveTimed, RawRwLockTimed, RawRwLockUpgrade, + RawRwLockUpgradeDowngrade, RawRwLockUpgradeFair, RawRwLockUpgradeTimed, +}; +use parking_lot_core::{self, FilterOp, ParkResult, ParkToken, SpinWait, UnparkResult}; +use raw_mutex::{TOKEN_HANDOFF, TOKEN_NORMAL}; +use std::cell::Cell; +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use std::time::{Duration, Instant}; + +const PARKED_BIT: usize = 0b001; +const UPGRADING_BIT: usize = 0b010; +// A shared guard acquires a single guard resource +const SHARED_GUARD: usize = 0b100; +const GUARD_COUNT_MASK: usize = !(SHARED_GUARD - 1); +// An exclusive lock acquires all of guard resource (i.e. it is exclusive) +const EXCLUSIVE_GUARD: usize = GUARD_COUNT_MASK; +// An upgradable lock acquires just over half of the guard resource +// This should be (GUARD_COUNT_MASK + SHARED_GUARD) >> 1, however this might +// overflow, so we shift before adding (which is okay since the least +// significant bit is zero for both GUARD_COUNT_MASK and SHARED_GUARD) +const UPGRADABLE_GUARD: usize = (GUARD_COUNT_MASK >> 1) + (SHARED_GUARD >> 1); + +// Token indicating what type of lock queued threads are trying to acquire +const TOKEN_SHARED: ParkToken = ParkToken(SHARED_GUARD); +const TOKEN_EXCLUSIVE: ParkToken = ParkToken(EXCLUSIVE_GUARD); +const TOKEN_UPGRADABLE: ParkToken = ParkToken(UPGRADABLE_GUARD); +const TOKEN_UPGRADING: ParkToken = ParkToken((EXCLUSIVE_GUARD - UPGRADABLE_GUARD) | UPGRADING_BIT); + +/// Raw reader-writer lock type backed by the parking lot. +pub struct RawRwLock { + state: AtomicUsize, +} + +unsafe impl RawRwLockTrait for RawRwLock { + const INIT: RawRwLock = RawRwLock { + state: ATOMIC_USIZE_INIT, + }; + + type GuardMarker = GuardNoSend; + + #[inline] + fn lock_exclusive(&self) { + if self + .state + .compare_exchange_weak(0, EXCLUSIVE_GUARD, Ordering::Acquire, Ordering::Relaxed) + .is_err() + { + let result = self.lock_exclusive_slow(None); + debug_assert!(result); + } + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + + #[inline] + fn try_lock_exclusive(&self) -> bool { + if self + .state + .compare_exchange(0, EXCLUSIVE_GUARD, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + true + } else { + false + } + } + + #[inline] + fn unlock_exclusive(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(EXCLUSIVE_GUARD, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_exclusive_slow(false); + } + + #[inline] + fn lock_shared(&self) { + if !self.try_lock_shared_fast(false) { + let result = self.lock_shared_slow(false, None); + debug_assert!(result); + } + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + + #[inline] + fn try_lock_shared(&self) -> bool { + let result = if self.try_lock_shared_fast(false) { + true + } else { + self.try_lock_shared_slow(false) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn unlock_shared(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + let state = self.state.load(Ordering::Relaxed); + if state & PARKED_BIT == 0 + || (state & UPGRADING_BIT == 0 && state & GUARD_COUNT_MASK != SHARED_GUARD) + { + if have_elision() { + if self + .state + .elision_release(state, state - SHARED_GUARD) + .is_ok() + { + return; + } + } else { + if self + .state + .compare_exchange_weak( + state, + state - SHARED_GUARD, + Ordering::Release, + Ordering::Relaxed, + ) + .is_ok() + { + return; + } + } + } + self.unlock_shared_slow(false); + } +} + +unsafe impl RawRwLockFair for RawRwLock { + #[inline] + fn unlock_shared_fair(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + let state = self.state.load(Ordering::Relaxed); + if state & PARKED_BIT == 0 + || (state & UPGRADING_BIT == 0 && state & GUARD_COUNT_MASK != SHARED_GUARD) + { + if have_elision() { + if self + .state + .elision_release(state, state - SHARED_GUARD) + .is_ok() + { + return; + } + } else { + if self + .state + .compare_exchange_weak( + state, + state - SHARED_GUARD, + Ordering::Release, + Ordering::Relaxed, + ) + .is_ok() + { + return; + } + } + } + self.unlock_shared_slow(true); + } + + #[inline] + fn unlock_exclusive_fair(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(EXCLUSIVE_GUARD, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_exclusive_slow(true); + } + + #[inline] + fn bump_shared(&self) { + if self.state.load(Ordering::Relaxed) & PARKED_BIT != 0 { + self.bump_shared_slow(); + } + } + + #[inline] + fn bump_exclusive(&self) { + if self.state.load(Ordering::Relaxed) & PARKED_BIT != 0 { + self.bump_exclusive_slow(); + } + } +} + +unsafe impl RawRwLockDowngrade for RawRwLock { + #[inline] + fn downgrade(&self) { + let state = self + .state + .fetch_sub(EXCLUSIVE_GUARD - SHARED_GUARD, Ordering::Release); + + // Wake up parked shared and upgradable threads if there are any + if state & PARKED_BIT != 0 { + self.downgrade_slow(); + } + } +} + +unsafe impl RawRwLockTimed for RawRwLock { + type Duration = Duration; + type Instant = Instant; + + #[inline] + fn try_lock_shared_for(&self, timeout: Self::Duration) -> bool { + let result = if self.try_lock_shared_fast(false) { + true + } else { + self.lock_shared_slow(false, Some(Instant::now() + timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_shared_until(&self, timeout: Self::Instant) -> bool { + let result = if self.try_lock_shared_fast(false) { + true + } else { + self.lock_shared_slow(false, Some(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_exclusive_for(&self, timeout: Duration) -> bool { + let result = if self + .state + .compare_exchange_weak(0, EXCLUSIVE_GUARD, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + true + } else { + self.lock_exclusive_slow(Some(Instant::now() + timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_exclusive_until(&self, timeout: Instant) -> bool { + let result = if self + .state + .compare_exchange_weak(0, EXCLUSIVE_GUARD, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + true + } else { + self.lock_exclusive_slow(Some(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } +} + +unsafe impl RawRwLockRecursive for RawRwLock { + #[inline] + fn lock_shared_recursive(&self) { + if !self.try_lock_shared_fast(true) { + let result = self.lock_shared_slow(true, None); + debug_assert!(result); + } + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + + #[inline] + fn try_lock_shared_recursive(&self) -> bool { + let result = if self.try_lock_shared_fast(true) { + true + } else { + self.try_lock_shared_slow(true) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } +} + +unsafe impl RawRwLockRecursiveTimed for RawRwLock { + #[inline] + fn try_lock_shared_recursive_for(&self, timeout: Self::Duration) -> bool { + let result = if self.try_lock_shared_fast(true) { + true + } else { + self.lock_shared_slow(true, Some(Instant::now() + timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_shared_recursive_until(&self, timeout: Self::Instant) -> bool { + let result = if self.try_lock_shared_fast(true) { + true + } else { + self.lock_shared_slow(true, Some(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } +} + +unsafe impl RawRwLockUpgrade for RawRwLock { + #[inline] + fn lock_upgradable(&self) { + if !self.try_lock_upgradable_fast() { + let result = self.lock_upgradable_slow(None); + debug_assert!(result); + } + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + + #[inline] + fn try_lock_upgradable(&self) -> bool { + let result = if self.try_lock_upgradable_fast() { + true + } else { + self.try_lock_upgradable_slow() + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn unlock_upgradable(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(UPGRADABLE_GUARD, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_upgradable_slow(false); + } + + #[inline] + fn upgrade(&self) { + if self + .state + .compare_exchange_weak( + UPGRADABLE_GUARD, + EXCLUSIVE_GUARD, + Ordering::Relaxed, + Ordering::Relaxed, + ) + .is_err() + { + let result = self.upgrade_slow(None); + debug_assert!(result); + } + } + + fn try_upgrade(&self) -> bool { + if self + .state + .compare_exchange_weak( + UPGRADABLE_GUARD, + EXCLUSIVE_GUARD, + Ordering::Relaxed, + Ordering::Relaxed, + ) + .is_ok() + { + true + } else { + self.try_upgrade_slow() + } + } +} + +unsafe impl RawRwLockUpgradeFair for RawRwLock { + #[inline] + fn unlock_upgradable_fair(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(UPGRADABLE_GUARD, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_upgradable_slow(true); + } + + #[inline] + fn bump_upgradable(&self) { + if self.state.load(Ordering::Relaxed) & PARKED_BIT != 0 { + self.bump_upgradable_slow(); + } + } +} + +unsafe impl RawRwLockUpgradeDowngrade for RawRwLock { + #[inline] + fn downgrade_upgradable(&self) { + let state = self + .state + .fetch_sub(UPGRADABLE_GUARD - SHARED_GUARD, Ordering::Relaxed); + + // Wake up parked shared and upgradable threads if there are any + if state & PARKED_BIT != 0 { + self.downgrade_upgradable_slow(state); + } + } + + #[inline] + fn downgrade_to_upgradable(&self) { + let state = self + .state + .fetch_sub(EXCLUSIVE_GUARD - UPGRADABLE_GUARD, Ordering::Release); + + // Wake up parked shared threads if there are any + if state & PARKED_BIT != 0 { + self.downgrade_to_upgradable_slow(); + } + } +} + +unsafe impl RawRwLockUpgradeTimed for RawRwLock { + #[inline] + fn try_lock_upgradable_until(&self, timeout: Instant) -> bool { + let result = if self.try_lock_upgradable_fast() { + true + } else { + self.lock_upgradable_slow(Some(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_upgradable_for(&self, timeout: Duration) -> bool { + let result = if self.try_lock_upgradable_fast() { + true + } else { + self.lock_upgradable_slow(Some(Instant::now() + timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_upgrade_until(&self, timeout: Instant) -> bool { + if self + .state + .compare_exchange_weak( + UPGRADABLE_GUARD, + EXCLUSIVE_GUARD, + Ordering::Relaxed, + Ordering::Relaxed, + ) + .is_ok() + { + true + } else { + self.upgrade_slow(Some(timeout)) + } + } + + #[inline] + fn try_upgrade_for(&self, timeout: Duration) -> bool { + if self + .state + .compare_exchange_weak( + UPGRADABLE_GUARD, + EXCLUSIVE_GUARD, + Ordering::Relaxed, + Ordering::Relaxed, + ) + .is_ok() + { + true + } else { + self.upgrade_slow(Some(Instant::now() + timeout)) + } + } +} + +impl RawRwLock { + #[inline(always)] + fn try_lock_shared_fast(&self, recursive: bool) -> bool { + let state = self.state.load(Ordering::Relaxed); + + // We can't allow grabbing a shared lock while there are parked threads + // since that could lead to writer starvation. + if !recursive && state & PARKED_BIT != 0 { + return false; + } + + // Use hardware lock elision to avoid cache conflicts when multiple + // readers try to acquire the lock. We only do this if the lock is + // completely empty since elision handles conflicts poorly. + if have_elision() && state == 0 { + self.state.elision_acquire(0, SHARED_GUARD).is_ok() + } else if let Some(new_state) = state.checked_add(SHARED_GUARD) { + self.state + .compare_exchange_weak(state, new_state, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + } else { + false + } + } + + #[inline(always)] + fn try_lock_upgradable_fast(&self) -> bool { + let state = self.state.load(Ordering::Relaxed); + + // We can't allow grabbing an upgradable lock while there are parked threads + // since that could lead to writer starvation. + if state & PARKED_BIT != 0 { + return false; + } + + if let Some(new_state) = state.checked_add(UPGRADABLE_GUARD) { + self.state + .compare_exchange_weak(state, new_state, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + } else { + false + } + } + + #[cold] + #[inline(never)] + fn lock_exclusive_slow(&self, timeout: Option) -> bool { + let mut spinwait = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Grab the lock if it isn't locked, even if there are other + // threads parked. + if let Some(new_state) = state.checked_add(EXCLUSIVE_GUARD) { + match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + continue; + } + + // If there are no parked threads and only one reader or writer, try + // spinning a few times. + if (state == EXCLUSIVE_GUARD || state == SHARED_GUARD || state == UPGRADABLE_GUARD) + && spinwait.spin() + { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Park our thread until we are woken up by an unlock + unsafe { + let addr = self as *const _ as usize; + let validate = || { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // If the rwlock is free, abort the park and try to grab + // it immediately. + if state & GUARD_COUNT_MASK == 0 { + return false; + } + + // Nothing to do if the parked bit is already set + if state & PARKED_BIT != 0 { + return true; + } + + // Set the parked bit + match self.state.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + } + }; + let before_sleep = || {}; + let timed_out = |_, was_last_thread| { + // Clear the parked bit if we were the last parked thread + if was_last_thread { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + }; + match parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + TOKEN_EXCLUSIVE, + timeout, + ) { + // The thread that unparked us passed the lock on to us + // directly without unlocking it. + ParkResult::Unparked(TOKEN_HANDOFF) => return true, + + // We were unparked normally, try acquiring the lock again + ParkResult::Unparked(_) => (), + + // The validation function failed, try locking again + ParkResult::Invalid => (), + + // Timeout expired + ParkResult::TimedOut => return false, + } + } + + // Loop back and try locking again + spinwait.reset(); + state = self.state.load(Ordering::Relaxed); + } + } + + #[cold] + #[inline(never)] + fn unlock_exclusive_slow(&self, force_fair: bool) { + // Unlock directly if there are no parked threads + if self + .state + .compare_exchange(EXCLUSIVE_GUARD, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + }; + + // There are threads to unpark. We unpark threads up to the guard capacity. + let guard_count = Cell::new(0usize); + unsafe { + let addr = self as *const _ as usize; + let filter = |ParkToken(token)| -> FilterOp { + match guard_count.get().checked_add(token) { + Some(new_guard_count) => { + guard_count.set(new_guard_count); + FilterOp::Unpark + } + None => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + // If we are using a fair unlock then we should keep the + // rwlock locked and hand it off to the unparked threads. + if result.unparked_threads != 0 && (force_fair || result.be_fair) { + // We need to set the guard count accordingly. + let mut new_state = guard_count.get(); + + if result.have_more_threads { + new_state |= PARKED_BIT; + } + + self.state.store(new_state, Ordering::Release); + TOKEN_HANDOFF + } else { + // Clear the parked bit if there are no more parked threads. + if result.have_more_threads { + self.state.store(PARKED_BIT, Ordering::Release); + } else { + self.state.store(0, Ordering::Release); + } + TOKEN_NORMAL + } + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn downgrade_slow(&self) { + unsafe { + let addr = self as *const _ as usize; + let mut guard_count = SHARED_GUARD; + let filter = |ParkToken(token)| -> FilterOp { + match guard_count.checked_add(token) { + Some(new_guard_count) => { + guard_count = new_guard_count; + FilterOp::Unpark + } + None => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + // Clear the parked bit if there no more parked threads + if !result.have_more_threads { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + TOKEN_NORMAL + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn downgrade_to_upgradable_slow(&self) { + unsafe { + let addr = self as *const _ as usize; + let mut guard_count = UPGRADABLE_GUARD; + let filter = |ParkToken(token)| -> FilterOp { + match guard_count.checked_add(token) { + Some(new_guard_count) => { + guard_count = new_guard_count; + FilterOp::Unpark + } + None => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + // Clear the parked bit if there no more parked threads + if !result.have_more_threads { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + TOKEN_NORMAL + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn lock_shared_slow(&self, recursive: bool, timeout: Option) -> bool { + let mut spinwait = SpinWait::new(); + let mut spinwait_shared = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + let mut unparked = false; + loop { + // Use hardware lock elision to avoid cache conflicts when multiple + // readers try to acquire the lock. We only do this if the lock is + // completely empty since elision handles conflicts poorly. + if have_elision() && state == 0 { + match self.state.elision_acquire(0, SHARED_GUARD) { + Ok(_) => return true, + Err(x) => state = x, + } + } + + // Grab the lock if there are no exclusive threads locked or + // waiting. However if we were unparked then we are allowed to grab + // the lock even if there are pending exclusive threads. + if unparked || recursive || state & PARKED_BIT == 0 { + if let Some(new_state) = state.checked_add(SHARED_GUARD) { + if self + .state + .compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) + .is_ok() + { + return true; + } + + // If there is high contention on the reader count then we want + // to leave some time between attempts to acquire the lock to + // let other threads make progress. + spinwait_shared.spin_no_yield(); + state = self.state.load(Ordering::Relaxed); + continue; + } else { + // We were unparked spuriously, reset unparked flag. + unparked = false; + } + } + + // If there are no parked threads, try spinning a few times + if state & PARKED_BIT == 0 && spinwait.spin() { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Park our thread until we are woken up by an unlock + unsafe { + let addr = self as *const _ as usize; + let validate = || { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Nothing to do if the parked bit is already set + if state & PARKED_BIT != 0 { + return true; + } + + // If the parked bit is not set then it means we are at + // the front of the queue. If there is space for another + // lock then we should abort the park and try acquiring + // the lock again. + if state & GUARD_COUNT_MASK != GUARD_COUNT_MASK { + return false; + } + + // Set the parked bit + match self.state.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + } + }; + let before_sleep = || {}; + let timed_out = |_, was_last_thread| { + // Clear the parked bit if we were the last parked thread + if was_last_thread { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + }; + match parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + TOKEN_SHARED, + timeout, + ) { + // The thread that unparked us passed the lock on to us + // directly without unlocking it. + ParkResult::Unparked(TOKEN_HANDOFF) => return true, + + // We were unparked normally, try acquiring the lock again + ParkResult::Unparked(_) => (), + + // The validation function failed, try locking again + ParkResult::Invalid => (), + + // Timeout expired + ParkResult::TimedOut => return false, + } + } + + // Loop back and try locking again + spinwait.reset(); + spinwait_shared.reset(); + state = self.state.load(Ordering::Relaxed); + unparked = true; + } + } + + #[cold] + #[inline(never)] + fn try_lock_shared_slow(&self, recursive: bool) -> bool { + let mut state = self.state.load(Ordering::Relaxed); + loop { + if !recursive && state & PARKED_BIT != 0 { + return false; + } + if have_elision() && state == 0 { + match self.state.elision_acquire(0, SHARED_GUARD) { + Ok(_) => return true, + Err(x) => state = x, + } + } else { + match state.checked_add(SHARED_GUARD) { + Some(new_state) => match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + }, + None => return false, + } + } + } + } + + #[cold] + #[inline(never)] + fn unlock_shared_slow(&self, force_fair: bool) { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Just release the lock if there are no parked thread or if we are + // not the last shared thread. + if state & PARKED_BIT == 0 + || (state & UPGRADING_BIT == 0 && state & GUARD_COUNT_MASK != SHARED_GUARD) + || (state & UPGRADING_BIT != 0 + && state & GUARD_COUNT_MASK != UPGRADABLE_GUARD + SHARED_GUARD) + { + match self.state.compare_exchange_weak( + state, + state - SHARED_GUARD, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return, + Err(x) => state = x, + } + continue; + } + + break; + } + + // There are threads to unpark. If there is a thread waiting to be + // upgraded, we find that thread and let it upgrade, otherwise we + // unpark threads up to the guard capacity. Note that there is a + // potential race condition here: another thread might grab a shared + // lock between now and when we actually release our lock. + let additional_guards = Cell::new(0usize); + let has_upgraded = Cell::new(if state & UPGRADING_BIT == 0 { + None + } else { + Some(false) + }); + unsafe { + let addr = self as *const _ as usize; + let filter = |ParkToken(token)| -> FilterOp { + match has_upgraded.get() { + None => match additional_guards.get().checked_add(token) { + Some(x) => { + additional_guards.set(x); + FilterOp::Unpark + } + None => FilterOp::Stop, + }, + Some(false) => if token & UPGRADING_BIT != 0 { + additional_guards.set(token & !UPGRADING_BIT); + has_upgraded.set(Some(true)); + FilterOp::Unpark + } else { + FilterOp::Skip + }, + Some(true) => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Release our shared lock + let mut new_state = state - SHARED_GUARD; + + // Clear the parked bit if there are no more threads in + // the queue. + if !result.have_more_threads { + new_state &= !PARKED_BIT; + } + + // Clear the upgrading bit if we are upgrading a thread. + if let Some(true) = has_upgraded.get() { + new_state &= !UPGRADING_BIT; + } + + // Consider using fair unlocking. If we are, then we should set + // the state to the new value and tell the threads that we are + // handing the lock directly. + let token = if result.unparked_threads != 0 && (force_fair || result.be_fair) { + match new_state.checked_add(additional_guards.get()) { + Some(x) => { + new_state = x; + TOKEN_HANDOFF + } + None => TOKEN_NORMAL, + } + } else { + TOKEN_NORMAL + }; + + match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return token, + Err(x) => state = x, + } + } + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn lock_upgradable_slow(&self, timeout: Option) -> bool { + let mut spinwait = SpinWait::new(); + let mut spinwait_shared = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + let mut unparked = false; + loop { + // Grab the lock if there are no exclusive or upgradable threads + // locked or waiting. However if we were unparked then we are + // allowed to grab the lock even if there are pending exclusive threads. + if unparked || state & PARKED_BIT == 0 { + if let Some(new_state) = state.checked_add(UPGRADABLE_GUARD) { + if self + .state + .compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) + .is_ok() + { + return true; + } + + // If there is high contention on the reader count then we want + // to leave some time between attempts to acquire the lock to + // let other threads make progress. + spinwait_shared.spin_no_yield(); + state = self.state.load(Ordering::Relaxed); + continue; + } else { + // We were unparked spuriously, reset unparked flag. + unparked = false; + } + } + + // If there are no parked threads, try spinning a few times + if state & PARKED_BIT == 0 && spinwait.spin() { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Park our thread until we are woken up by an unlock + unsafe { + let addr = self as *const _ as usize; + let validate = || { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Nothing to do if the parked bit is already set + if state & PARKED_BIT != 0 { + return true; + } + + // If the parked bit is not set then it means we are at + // the front of the queue. If there is space for an + // upgradable lock then we should abort the park and try + // acquiring the lock again. + if state & UPGRADABLE_GUARD != UPGRADABLE_GUARD { + return false; + } + + // Set the parked bit + match self.state.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + } + }; + let before_sleep = || {}; + let timed_out = |_, was_last_thread| { + // Clear the parked bit if we were the last parked thread + if was_last_thread { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + }; + match parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + TOKEN_UPGRADABLE, + timeout, + ) { + // The thread that unparked us passed the lock on to us + // directly without unlocking it. + ParkResult::Unparked(TOKEN_HANDOFF) => return true, + + // We were unparked normally, try acquiring the lock again + ParkResult::Unparked(_) => (), + + // The validation function failed, try locking again + ParkResult::Invalid => (), + + // Timeout expired + ParkResult::TimedOut => return false, + } + } + + // Loop back and try locking again + spinwait.reset(); + spinwait_shared.reset(); + state = self.state.load(Ordering::Relaxed); + unparked = true; + } + } + + #[cold] + #[inline(never)] + fn try_lock_upgradable_slow(&self) -> bool { + let mut state = self.state.load(Ordering::Relaxed); + loop { + if state & PARKED_BIT != 0 { + return false; + } + + match state.checked_add(UPGRADABLE_GUARD) { + Some(new_state) => match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + }, + None => return false, + } + } + } + + #[cold] + #[inline(never)] + fn unlock_upgradable_slow(&self, force_fair: bool) { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Just release the lock if there are no parked threads. + if state & PARKED_BIT == 0 { + match self.state.compare_exchange_weak( + state, + state - UPGRADABLE_GUARD, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return, + Err(x) => state = x, + } + continue; + } + + break; + } + + // There are threads to unpark. We unpark threads up to the guard capacity. + let additional_guards = Cell::new(0usize); + unsafe { + let addr = self as *const _ as usize; + let filter = |ParkToken(token)| -> FilterOp { + match additional_guards.get().checked_add(token) { + Some(x) => { + additional_guards.set(x); + FilterOp::Unpark + } + None => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Release our upgradable lock + let mut new_state = state - UPGRADABLE_GUARD; + + // Clear the parked bit if there are no more threads in + // the queue + if !result.have_more_threads { + new_state &= !PARKED_BIT; + } + + // Consider using fair unlocking. If we are, then we should set + // the state to the new value and tell the threads that we are + // handing the lock directly. + let token = if result.unparked_threads != 0 && (force_fair || result.be_fair) { + match new_state.checked_add(additional_guards.get()) { + Some(x) => { + new_state = x; + TOKEN_HANDOFF + } + None => TOKEN_NORMAL, + } + } else { + TOKEN_NORMAL + }; + + match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return token, + Err(x) => state = x, + } + } + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn downgrade_upgradable_slow(&self, state: usize) { + unsafe { + let addr = self as *const _ as usize; + let mut guard_count = (state & GUARD_COUNT_MASK) - UPGRADABLE_GUARD; + let filter = |ParkToken(token)| -> FilterOp { + match guard_count.checked_add(token) { + Some(x) => { + guard_count = x; + FilterOp::Unpark + } + None => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + // Clear the parked bit if there no more parked threads + if !result.have_more_threads { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + TOKEN_NORMAL + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn try_upgrade_slow(&self) -> bool { + let mut state = self.state.load(Ordering::Relaxed); + loop { + match state.checked_add(EXCLUSIVE_GUARD - SHARED_GUARD) { + Some(new_state) => match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + }, + None => return false, + } + } + } + + #[cold] + #[inline(never)] + fn upgrade_slow(&self, timeout: Option) -> bool { + let mut spinwait = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Grab the lock if it isn't locked, even if there are other + // threads parked. + if let Some(new_state) = state.checked_add(EXCLUSIVE_GUARD - UPGRADABLE_GUARD) { + match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + continue; + } + + // If there are no parked threads and only one other reader, try + // spinning a few times. + if state == UPGRADABLE_GUARD | SHARED_GUARD && spinwait.spin() { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Park our thread until we are woken up by an unlock + unsafe { + let addr = self as *const _ as usize; + let validate = || { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // If the rwlock is free, abort the park and try to grab + // it immediately. + if state & GUARD_COUNT_MASK == UPGRADABLE_GUARD { + return false; + } + + // Set the upgrading and parked bits + match self.state.compare_exchange_weak( + state, + state | (UPGRADING_BIT | PARKED_BIT), + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + } + }; + let before_sleep = || {}; + let timed_out = |_, was_last_thread| { + // Clear the upgrading bit + let mut flags = UPGRADING_BIT; + + // Clear the parked bit if we were the last parked thread + if was_last_thread { + flags |= PARKED_BIT; + } + + self.state.fetch_and(!flags, Ordering::Relaxed); + }; + match parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + TOKEN_UPGRADING, + timeout, + ) { + // The thread that unparked us passed the lock on to us + // directly without unlocking it. + ParkResult::Unparked(TOKEN_HANDOFF) => return true, + + // We were unparked normally, try acquiring the lock again + ParkResult::Unparked(_) => (), + + // The validation function failed, try locking again + ParkResult::Invalid => (), + + // Timeout expired + ParkResult::TimedOut => return false, + } + } + + // Loop back and try locking again + spinwait.reset(); + state = self.state.load(Ordering::Relaxed); + } + } + + #[cold] + #[inline(never)] + fn bump_shared_slow(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + self.unlock_shared_slow(true); + self.lock_shared(); + } + + #[cold] + #[inline(never)] + fn bump_exclusive_slow(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + self.unlock_exclusive_slow(true); + self.lock_exclusive(); + } + + #[cold] + #[inline(never)] + fn bump_upgradable_slow(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + self.unlock_upgradable_slow(true); + self.lock_upgradable(); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/remutex.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/remutex.rs new file mode 100644 index 0000000..ba9e004 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/remutex.rs @@ -0,0 +1,126 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use lock_api::{self, GetThreadId}; +use raw_mutex::RawMutex; + +/// Implementation of the `GetThreadId` trait for `lock_api::ReentrantMutex`. +pub struct RawThreadId; + +unsafe impl GetThreadId for RawThreadId { + const INIT: RawThreadId = RawThreadId; + + fn nonzero_thread_id(&self) -> usize { + // The address of a thread-local variable is guaranteed to be unique to the + // current thread, and is also guaranteed to be non-zero. + thread_local!(static KEY: u8 = unsafe { ::std::mem::uninitialized() }); + KEY.with(|x| x as *const _ as usize) + } +} + +/// A mutex which can be recursively locked by a single thread. +/// +/// This type is identical to `Mutex` except for the following points: +/// +/// - Locking multiple times from the same thread will work correctly instead of +/// deadlocking. +/// - `ReentrantMutexGuard` does not give mutable references to the locked data. +/// Use a `RefCell` if you need this. +/// +/// See [`Mutex`](struct.Mutex.html) for more details about the underlying mutex +/// primitive. +pub type ReentrantMutex = lock_api::ReentrantMutex; + +/// An RAII implementation of a "scoped lock" of a reentrant mutex. When this structure +/// is dropped (falls out of scope), the lock will be unlocked. +/// +/// The data protected by the mutex can be accessed through this guard via its +/// `Deref` implementation. +pub type ReentrantMutexGuard<'a, T> = + lock_api::ReentrantMutexGuard<'a, RawMutex, RawThreadId, T>; + +/// An RAII mutex guard returned by `ReentrantMutexGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedReentrantMutexGuard` and `ReentrantMutexGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +pub type MappedReentrantMutexGuard<'a, T> = + lock_api::MappedReentrantMutexGuard<'a, RawMutex, RawThreadId, T>; + +#[cfg(test)] +mod tests { + use std::cell::RefCell; + use std::sync::Arc; + use std::thread; + use ReentrantMutex; + + #[test] + fn smoke() { + let m = ReentrantMutex::new(()); + { + let a = m.lock(); + { + let b = m.lock(); + { + let c = m.lock(); + assert_eq!(*c, ()); + } + assert_eq!(*b, ()); + } + assert_eq!(*a, ()); + } + } + + #[test] + fn is_mutex() { + let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); + let m2 = m.clone(); + let lock = m.lock(); + let child = thread::spawn(move || { + let lock = m2.lock(); + assert_eq!(*lock.borrow(), 4950); + }); + for i in 0..100 { + let lock = m.lock(); + *lock.borrow_mut() += i; + } + drop(lock); + child.join().unwrap(); + } + + #[test] + fn trylock_works() { + let m = Arc::new(ReentrantMutex::new(())); + let m2 = m.clone(); + let _lock = m.try_lock(); + let _lock2 = m.try_lock(); + thread::spawn(move || { + let lock = m2.try_lock(); + assert!(lock.is_none()); + }).join() + .unwrap(); + let _lock3 = m.try_lock(); + } + + #[test] + fn test_reentrant_mutex_debug() { + let mutex = ReentrantMutex::new(vec![0u8, 10]); + + assert_eq!(format!("{:?}", mutex), "ReentrantMutex { data: [0, 10] }"); + assert_eq!( + format!("{:#?}", mutex), + "ReentrantMutex { + data: [ + 0, + 10 + ] +}" + ); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/rwlock.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/rwlock.rs new file mode 100644 index 0000000..5a1d0cb --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/rwlock.rs @@ -0,0 +1,564 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use lock_api; +use raw_rwlock::RawRwLock; + +/// A reader-writer lock +/// +/// This type of lock allows a number of readers or at most one writer at any +/// point in time. The write portion of this lock typically allows modification +/// of the underlying data (exclusive access) and the read portion of this lock +/// typically allows for read-only access (shared access). +/// +/// This lock uses a task-fair locking policy which avoids both reader and +/// writer starvation. This means that readers trying to acquire the lock will +/// block even if the lock is unlocked when there are writers waiting to acquire +/// the lock. Because of this, attempts to recursively acquire a read lock +/// within a single thread may result in a deadlock. +/// +/// The type parameter `T` represents the data that this lock protects. It is +/// required that `T` satisfies `Send` to be shared across threads and `Sync` to +/// allow concurrent access through readers. The RAII guards returned from the +/// locking methods implement `Deref` (and `DerefMut` for the `write` methods) +/// to allow access to the contained of the lock. +/// +/// # Fairness +/// +/// A typical unfair lock can often end up in a situation where a single thread +/// quickly acquires and releases the same lock in succession, which can starve +/// other threads waiting to acquire the rwlock. While this improves performance +/// because it doesn't force a context switch when a thread tries to re-acquire +/// a rwlock it has just released, this can starve other threads. +/// +/// This rwlock uses [eventual fairness](https://trac.webkit.org/changeset/203350) +/// to ensure that the lock will be fair on average without sacrificing +/// performance. This is done by forcing a fair unlock on average every 0.5ms, +/// which will force the lock to go to the next thread waiting for the rwlock. +/// +/// Additionally, any critical section longer than 1ms will always use a fair +/// unlock, which has a negligible performance impact compared to the length of +/// the critical section. +/// +/// You can also force a fair unlock by calling `RwLockReadGuard::unlock_fair` +/// or `RwLockWriteGuard::unlock_fair` when unlocking a mutex instead of simply +/// dropping the guard. +/// +/// # Differences from the standard library `RwLock` +/// +/// - Supports atomically downgrading a write lock into a read lock. +/// - Task-fair locking policy instead of an unspecified platform default. +/// - No poisoning, the lock is released normally on panic. +/// - Only requires 1 word of space, whereas the standard library boxes the +/// `RwLock` due to platform limitations. +/// - Can be statically constructed (requires the `const_fn` nightly feature). +/// - Does not require any drop glue when dropped. +/// - Inline fast path for the uncontended case. +/// - Efficient handling of micro-contention using adaptive spinning. +/// - Allows raw locking & unlocking without a guard. +/// - Supports eventual fairness so that the rwlock is fair on average. +/// - Optionally allows making the rwlock fair by calling +/// `RwLockReadGuard::unlock_fair` and `RwLockWriteGuard::unlock_fair`. +/// +/// # Examples +/// +/// ``` +/// use parking_lot::RwLock; +/// +/// let lock = RwLock::new(5); +/// +/// // many reader locks can be held at once +/// { +/// let r1 = lock.read(); +/// let r2 = lock.read(); +/// assert_eq!(*r1, 5); +/// assert_eq!(*r2, 5); +/// } // read locks are dropped at this point +/// +/// // only one write lock may be held, however +/// { +/// let mut w = lock.write(); +/// *w += 1; +/// assert_eq!(*w, 6); +/// } // write lock is dropped here +/// ``` +pub type RwLock = lock_api::RwLock; + +/// RAII structure used to release the shared read access of a lock when +/// dropped. +pub type RwLockReadGuard<'a, T> = lock_api::RwLockReadGuard<'a, RawRwLock, T>; + +/// RAII structure used to release the exclusive write access of a lock when +/// dropped. +pub type RwLockWriteGuard<'a, T> = lock_api::RwLockWriteGuard<'a, RawRwLock, T>; + +/// An RAII read lock guard returned by `RwLockReadGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedRwLockReadGuard` and `RwLockReadGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +pub type MappedRwLockReadGuard<'a, T> = lock_api::MappedRwLockReadGuard<'a, RawRwLock, T>; + +/// An RAII write lock guard returned by `RwLockWriteGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedRwLockWriteGuard` and `RwLockWriteGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +pub type MappedRwLockWriteGuard<'a, T> = lock_api::MappedRwLockWriteGuard<'a, RawRwLock, T>; + +/// RAII structure used to release the upgradable read access of a lock when +/// dropped. +pub type RwLockUpgradableReadGuard<'a, T> = + lock_api::RwLockUpgradableReadGuard<'a, RawRwLock, T>; + +#[cfg(test)] +mod tests { + extern crate rand; + use self::rand::Rng; + use std::sync::atomic::{AtomicUsize, Ordering}; + use std::sync::mpsc::channel; + use std::sync::Arc; + use std::thread; + use std::time::Duration; + use {RwLock, RwLockUpgradableReadGuard, RwLockWriteGuard}; + + #[derive(Eq, PartialEq, Debug)] + struct NonCopy(i32); + + #[test] + fn smoke() { + let l = RwLock::new(()); + drop(l.read()); + drop(l.write()); + drop(l.upgradable_read()); + drop((l.read(), l.read())); + drop((l.read(), l.upgradable_read())); + drop(l.write()); + } + + #[test] + fn frob() { + const N: u32 = 10; + const M: u32 = 1000; + + let r = Arc::new(RwLock::new(())); + + let (tx, rx) = channel::<()>(); + for _ in 0..N { + let tx = tx.clone(); + let r = r.clone(); + thread::spawn(move || { + let mut rng = rand::thread_rng(); + for _ in 0..M { + if rng.gen_bool(1.0 / N as f64) { + drop(r.write()); + } else { + drop(r.read()); + } + } + drop(tx); + }); + } + drop(tx); + let _ = rx.recv(); + } + + #[test] + fn test_rw_arc_no_poison_wr() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.write(); + panic!(); + }).join(); + let lock = arc.read(); + assert_eq!(*lock, 1); + } + + #[test] + fn test_rw_arc_no_poison_ww() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.write(); + panic!(); + }).join(); + let lock = arc.write(); + assert_eq!(*lock, 1); + } + + #[test] + fn test_rw_arc_no_poison_rr() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.read(); + panic!(); + }).join(); + let lock = arc.read(); + assert_eq!(*lock, 1); + } + + #[test] + fn test_rw_arc_no_poison_rw() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.read(); + panic!() + }).join(); + let lock = arc.write(); + assert_eq!(*lock, 1); + } + + #[test] + fn test_ruw_arc() { + let arc = Arc::new(RwLock::new(0)); + let arc2 = arc.clone(); + let (tx, rx) = channel(); + + thread::spawn(move || { + for _ in 0..10 { + let mut lock = arc2.write(); + let tmp = *lock; + *lock = -1; + thread::yield_now(); + *lock = tmp + 1; + } + tx.send(()).unwrap(); + }); + + let mut children = Vec::new(); + + // Upgradable readers try to catch the writer in the act and also + // try to touch the value + for _ in 0..5 { + let arc3 = arc.clone(); + children.push(thread::spawn(move || { + let lock = arc3.upgradable_read(); + let tmp = *lock; + assert!(tmp >= 0); + thread::yield_now(); + let mut lock = RwLockUpgradableReadGuard::upgrade(lock); + assert_eq!(tmp, *lock); + *lock = -1; + thread::yield_now(); + *lock = tmp + 1; + })); + } + + // Readers try to catch the writers in the act + for _ in 0..5 { + let arc4 = arc.clone(); + children.push(thread::spawn(move || { + let lock = arc4.read(); + assert!(*lock >= 0); + })); + } + + // Wait for children to pass their asserts + for r in children { + assert!(r.join().is_ok()); + } + + // Wait for writer to finish + rx.recv().unwrap(); + let lock = arc.read(); + assert_eq!(*lock, 15); + } + + #[test] + fn test_rw_arc() { + let arc = Arc::new(RwLock::new(0)); + let arc2 = arc.clone(); + let (tx, rx) = channel(); + + thread::spawn(move || { + let mut lock = arc2.write(); + for _ in 0..10 { + let tmp = *lock; + *lock = -1; + thread::yield_now(); + *lock = tmp + 1; + } + tx.send(()).unwrap(); + }); + + // Readers try to catch the writer in the act + let mut children = Vec::new(); + for _ in 0..5 { + let arc3 = arc.clone(); + children.push(thread::spawn(move || { + let lock = arc3.read(); + assert!(*lock >= 0); + })); + } + + // Wait for children to pass their asserts + for r in children { + assert!(r.join().is_ok()); + } + + // Wait for writer to finish + rx.recv().unwrap(); + let lock = arc.read(); + assert_eq!(*lock, 10); + } + + #[test] + fn test_rw_arc_access_in_unwind() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _ = thread::spawn(move || -> () { + struct Unwinder { + i: Arc>, + } + impl Drop for Unwinder { + fn drop(&mut self) { + let mut lock = self.i.write(); + *lock += 1; + } + } + let _u = Unwinder { i: arc2 }; + panic!(); + }).join(); + let lock = arc.read(); + assert_eq!(*lock, 2); + } + + #[test] + fn test_rwlock_unsized() { + let rw: &RwLock<[i32]> = &RwLock::new([1, 2, 3]); + { + let b = &mut *rw.write(); + b[0] = 4; + b[2] = 5; + } + let comp: &[i32] = &[4, 2, 5]; + assert_eq!(&*rw.read(), comp); + } + + #[test] + fn test_rwlock_try_read() { + let lock = RwLock::new(0isize); + { + let read_guard = lock.read(); + + let read_result = lock.try_read(); + assert!( + read_result.is_some(), + "try_read should succeed while read_guard is in scope" + ); + + drop(read_guard); + } + { + let upgrade_guard = lock.upgradable_read(); + + let read_result = lock.try_read(); + assert!( + read_result.is_some(), + "try_read should succeed while upgrade_guard is in scope" + ); + + drop(upgrade_guard); + } + { + let write_guard = lock.write(); + + let read_result = lock.try_read(); + assert!( + read_result.is_none(), + "try_read should fail while write_guard is in scope" + ); + + drop(write_guard); + } + } + + #[test] + fn test_rwlock_try_write() { + let lock = RwLock::new(0isize); + { + let read_guard = lock.read(); + + let write_result = lock.try_write(); + assert!( + write_result.is_none(), + "try_write should fail while read_guard is in scope" + ); + + drop(read_guard); + } + { + let upgrade_guard = lock.upgradable_read(); + + let write_result = lock.try_write(); + assert!( + write_result.is_none(), + "try_write should fail while upgrade_guard is in scope" + ); + + drop(upgrade_guard); + } + { + let write_guard = lock.write(); + + let write_result = lock.try_write(); + assert!( + write_result.is_none(), + "try_write should fail while write_guard is in scope" + ); + + drop(write_guard); + } + } + + #[test] + fn test_rwlock_try_upgrade() { + let lock = RwLock::new(0isize); + { + let read_guard = lock.read(); + + let upgrade_result = lock.try_upgradable_read(); + assert!( + upgrade_result.is_some(), + "try_upgradable_read should succeed while read_guard is in scope" + ); + + drop(read_guard); + } + { + let upgrade_guard = lock.upgradable_read(); + + let upgrade_result = lock.try_upgradable_read(); + assert!( + upgrade_result.is_none(), + "try_upgradable_read should fail while upgrade_guard is in scope" + ); + + drop(upgrade_guard); + } + { + let write_guard = lock.write(); + + let upgrade_result = lock.try_upgradable_read(); + assert!( + upgrade_result.is_none(), + "try_upgradable should fail while write_guard is in scope" + ); + + drop(write_guard); + } + } + + #[test] + fn test_into_inner() { + let m = RwLock::new(NonCopy(10)); + assert_eq!(m.into_inner(), NonCopy(10)); + } + + #[test] + fn test_into_inner_drop() { + struct Foo(Arc); + impl Drop for Foo { + fn drop(&mut self) { + self.0.fetch_add(1, Ordering::SeqCst); + } + } + let num_drops = Arc::new(AtomicUsize::new(0)); + let m = RwLock::new(Foo(num_drops.clone())); + assert_eq!(num_drops.load(Ordering::SeqCst), 0); + { + let _inner = m.into_inner(); + assert_eq!(num_drops.load(Ordering::SeqCst), 0); + } + assert_eq!(num_drops.load(Ordering::SeqCst), 1); + } + + #[test] + fn test_get_mut() { + let mut m = RwLock::new(NonCopy(10)); + *m.get_mut() = NonCopy(20); + assert_eq!(m.into_inner(), NonCopy(20)); + } + + #[test] + fn test_rwlockguard_sync() { + fn sync(_: T) {} + + let rwlock = RwLock::new(()); + sync(rwlock.read()); + sync(rwlock.write()); + } + + #[test] + fn test_rwlock_downgrade() { + let x = Arc::new(RwLock::new(0)); + let mut handles = Vec::new(); + for _ in 0..8 { + let x = x.clone(); + handles.push(thread::spawn(move || { + for _ in 0..100 { + let mut writer = x.write(); + *writer += 1; + let cur_val = *writer; + let reader = RwLockWriteGuard::downgrade(writer); + assert_eq!(cur_val, *reader); + } + })); + } + for handle in handles { + handle.join().unwrap() + } + assert_eq!(*x.read(), 800); + } + + #[test] + fn test_rwlock_recursive() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _lock1 = arc.read(); + thread::spawn(move || { + let _lock = arc2.write(); + }); + thread::sleep(Duration::from_millis(100)); + + // A normal read would block here since there is a pending writer + let _lock2 = arc.read_recursive(); + } + + #[test] + fn test_rwlock_debug() { + let x = RwLock::new(vec![0u8, 10]); + + assert_eq!(format!("{:?}", x), "RwLock { data: [0, 10] }"); + assert_eq!( + format!("{:#?}", x), + "RwLock { + data: [ + 0, + 10 + ] +}" + ); + let _lock = x.write(); + assert_eq!(format!("{:?}", x), "RwLock { }"); + } + + #[test] + fn test_clone() { + let rwlock = RwLock::new(Arc::new(1)); + let a = rwlock.read_recursive(); + let b = a.clone(); + assert_eq!(Arc::strong_count(&b), 2); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.6.4/src/util.rs b/third_party/cargo/vendor/parking_lot-0.6.4/src/util.rs new file mode 100644 index 0000000..c7dfd32 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.6.4/src/util.rs @@ -0,0 +1,32 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +// Option::unchecked_unwrap +pub trait UncheckedOptionExt { + unsafe fn unchecked_unwrap(self) -> T; +} + +impl UncheckedOptionExt for Option { + #[inline] + unsafe fn unchecked_unwrap(self) -> T { + match self { + Some(x) => x, + None => unreachable(), + } + } +} + +// Equivalent to intrinsics::unreachable() in release mode +#[inline] +unsafe fn unreachable() -> ! { + if cfg!(debug_assertions) { + unreachable!(); + } else { + enum Void {} + match *(1 as *const Void) {} + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/.cargo-checksum.json b/third_party/cargo/vendor/parking_lot-0.7.1/.cargo-checksum.json new file mode 100644 index 0000000..57e8d3e --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"f9a9c82373818d32816c42e0f127f6f14a64d37925f02041c10c66a528e0d454","Cargo.toml":"5cc50b68f3a7a4a61c78fb216a7b5e3e7426d1e3e6f55149ec4d9e35a5e27e94","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","README.md":"0840b0fe8613d0336800633c48bde4352f80a97a0e85910e1e0d2914d81109cc","appveyor.yml":"a0525637948083d463186164cddbfde87c2d371029ea538a35d2b2c7129a348f","src/condvar.rs":"24cb08be64fb45323a71c8a06de0d3ef7a991f76aca8911e4d39f105003a4dbc","src/deadlock.rs":"8916c2e2820bfd3a55860ddb9f1b907888406b68cdae2b7a2093c825d28f3b99","src/elision.rs":"f55cb93d29b20d8908cde523428fec32503224e7c9ca7bf1475475bc4c1f6202","src/lib.rs":"db6f074b1c35d60116c0b13b25cce6bb497bb680d340058bb942a1427c6b4d4e","src/mutex.rs":"637590d99bf310194171e4bc2d4f23c23e9a5cbf680f383873e2106cfd1e1390","src/once.rs":"02e92cf50e4d81cb9dfc459c9742d8bc2db72f53296f28b38fa81fa1eec0fea6","src/raw_mutex.rs":"ce66c9e9abc5d6f12a1969a369dc8374854e92a33114d6c068752ce36312a562","src/raw_rwlock.rs":"0c996433cf6445fcf3071b19fba1b7d96b0d039435afdb5c6eb5bed88a37f6c2","src/remutex.rs":"b75c9e98bb82e2dec607d3b4cee54daf60f91deea454d337f85416291a6ccc96","src/rwlock.rs":"946214fca407049d5b33cda41d146478f5884bd722bbc441085af7a887922618","src/util.rs":"b69018d1cb4f02c0c4ea068e51d4dbf8a1ae1a3996c3c911a309c3dd05a2c250"},"package":"ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"} \ No newline at end of file diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/BUILD b/third_party/cargo/vendor/parking_lot-0.7.1/BUILD new file mode 100644 index 0000000..c320a6b --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0,MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "parking_lot", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/lock_api-0.1.5:lock_api", + "//third_party/cargo/vendor/parking_lot_core-0.4.0:parking_lot_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.7.1", + crate_features = [ + "default", + "lock_api", + "owning_ref", + ], +) + diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/CHANGELOG.md b/third_party/cargo/vendor/parking_lot-0.7.1/CHANGELOG.md new file mode 100644 index 0000000..ee87251 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/CHANGELOG.md @@ -0,0 +1,59 @@ +0.7.1 (2019-01-01) +================== + +- Fixed potential deadlock when upgrading a RwLock. +- Fixed overflow panic on very long timeouts (#111). + +0.7.0 (2018-11-20) +================== + +- Return if or how many threads were notified from `Condvar::notify_*` + +0.6.3 (2018-07-18) +================== + +- Export `RawMutex`, `RawRwLock` and `RawThreadId`. + +0.6.2 (2018-06-18) +================== + +- Enable `lock_api/nightly` feature from `parking_lot/nightly` (#79) + +0.6.1 (2018-06-08) +================== + +Added missing typedefs for mapped lock guards: + +- `MappedMutexGuard` +- `MappedReentrantMutexGuard` +- `MappedRwLockReadGuard` +- `MappedRwLockWriteGuard` + +0.6.0 (2018-06-08) +================== + +This release moves most of the code for type-safe `Mutex` and `RwLock` types +into a separate crate called `lock_api`. This new crate is compatible with +`no_std` and provides `Mutex` and `RwLock` type-safe wrapper types from a +raw mutex type which implements the `RawMutex` or `RawRwLock` trait. The API +provided by the wrapper types can be extended by implementing more traits on the +raw mutex type which provide more functionality (e.g. `RawMutexTimed`). See the +crate documentation for more details. + +There are also several major changes: + +- The minimum required Rust version is bumped to 1.26. +- All methods on `MutexGuard` (and other guard types) are no longer inherent + methods and must be called as `MutexGuard::method(self)`. This avoids + conflicts with methods from the inner type. +- `MutexGuard` (and other guard types) add the `unlocked` method which + temporarily unlocks a mutex, runs the given closure, and then re-locks the + mutex. +- `MutexGuard` (and other guard types) add the `bump` method which gives a + chance for other threads to acquire the mutex by temporarily unlocking it and + re-locking it. However this is optimized for the common case where there are + no threads waiting on the lock, in which case no unlocking is performed. +- `MutexGuard` (and other guard types) add the `map` method which returns a + `MappedMutexGuard` which holds only a subset of the original locked type. The + `MappedMutexGuard` type is identical to `MutexGuard` except that it does not + support the `unlocked` and `bump` methods, and can't be used with `CondVar`. diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/Cargo.toml b/third_party/cargo/vendor/parking_lot-0.7.1/Cargo.toml new file mode 100644 index 0000000..19a73ca --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/Cargo.toml @@ -0,0 +1,35 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "parking_lot" +version = "0.7.1" +authors = ["Amanieu d'Antras "] +description = "More compact and efficient implementations of the standard synchronization primitives." +readme = "README.md" +keywords = ["mutex", "condvar", "rwlock", "once", "thread"] +categories = ["concurrency"] +license = "Apache-2.0/MIT" +repository = "https://github.com/Amanieu/parking_lot" +[dependencies.lock_api] +version = "0.1" + +[dependencies.parking_lot_core] +version = "0.4" +[dev-dependencies.rand] +version = "0.6" + +[features] +deadlock_detection = ["parking_lot_core/deadlock_detection"] +default = ["owning_ref"] +nightly = ["parking_lot_core/nightly", "lock_api/nightly"] +owning_ref = ["lock_api/owning_ref"] diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/LICENSE-APACHE b/third_party/cargo/vendor/parking_lot-0.7.1/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/LICENSE-MIT b/third_party/cargo/vendor/parking_lot-0.7.1/LICENSE-MIT new file mode 100644 index 0000000..40b8817 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/README.md b/third_party/cargo/vendor/parking_lot-0.7.1/README.md new file mode 100644 index 0000000..a8f339a --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/README.md @@ -0,0 +1,143 @@ +parking_lot +============ + +[![Build Status](https://travis-ci.org/Amanieu/parking_lot.svg?branch=master)](https://travis-ci.org/Amanieu/parking_lot) [![Build status](https://ci.appveyor.com/api/projects/status/wppcc32ttpud0a30/branch/master?svg=true)](https://ci.appveyor.com/project/Amanieu/parking-lot/branch/master) [![Crates.io](https://img.shields.io/crates/v/parking_lot.svg)](https://crates.io/crates/parking_lot) + +[Documentation (synchronization primitives)](https://docs.rs/parking_lot/) + +[Documentation (core parking lot API)](https://docs.rs/parking_lot_core/) + +[Documentation (type-safe lock API)](https://docs.rs/lock_api/) + +This library provides implementations of `Mutex`, `RwLock`, `Condvar` and +`Once` that are smaller, faster and more flexible than those in the Rust +standard library, as well as a `ReentrantMutex` type which supports recursive +locking. It also exposes a low-level API for creating your own efficient +synchronization primitives. + +When tested on x86_64 Linux, `parking_lot::Mutex` was found to be 1.5x +faster than `std::sync::Mutex` when uncontended, and up to 5x faster when +contended from multiple threads. The numbers for `RwLock` vary depending on +the number of reader and writer threads, but are almost always faster than +the standard library `RwLock`, and even up to 50x faster in some cases. + +## Features + +The primitives provided by this library have several advantages over those +in the Rust standard library: + +1. `Mutex` and `Once` only require 1 byte of storage space, while `Condvar` + and `RwLock` only require 1 word of storage space. On the other hand the + standard library primitives require a dynamically allocated `Box` to hold + OS-specific synchronization primitives. The small size of `Mutex` in + particular encourages the use of fine-grained locks to increase + parallelism. +2. Since they consist of just a single atomic variable, have constant + initializers and don't need destructors, these primitives can be used as + `static` global variables. The standard library primitives require + dynamic initialization and thus need to be lazily initialized with + `lazy_static!`. +3. Uncontended lock acquisition and release is done through fast inline + paths which only require a single atomic operation. +4. Microcontention (a contended lock with a short critical section) is + efficiently handled by spinning a few times while trying to acquire a + lock. +5. The locks are adaptive and will suspend a thread after a few failed spin + attempts. This makes the locks suitable for both long and short critical + sections. +6. `Condvar`, `RwLock` and `Once` work on Windows XP, unlike the standard + library versions of those types. +7. `RwLock` takes advantage of hardware lock elision on processors that + support it, which can lead to huge performance wins with many readers. +8. `RwLock` uses a task-fair locking policy, which avoids reader and writer + starvation, whereas the standard library version makes no guarantees. +9. `Condvar` is guaranteed not to produce spurious wakeups. A thread will + only be woken up if it timed out or it was woken up by a notification. +10. `Condvar::notify_all` will only wake up a single thread and requeue the + rest to wait on the associated `Mutex`. This avoids a thundering herd + problem where all threads try to acquire the lock at the same time. +11. `RwLock` supports atomically downgrading a write lock into a read lock. +12. `Mutex` and `RwLock` allow raw unlocking without a RAII guard object. +13. `Mutex<()>` and `RwLock<()>` allow raw locking without a RAII guard + object. +14. `Mutex` and `RwLock` support [eventual fairness](https://trac.webkit.org/changeset/203350) + which allows them to be fair on average without sacrificing performance. +15. A `ReentrantMutex` type which supports recursive locking. +16. An *experimental* deadlock detector that works for `Mutex`, + `RwLock` and `ReentrantMutex`. This feature is disabled by default and + can be enabled via the `deadlock_detection` feature. +17. `RwLock` supports atomically upgrading an "upgradable" read lock into a + write lock. + +## The parking lot + +To keep these primitives small, all thread queuing and suspending +functionality is offloaded to the *parking lot*. The idea behind this is +based on the Webkit [`WTF::ParkingLot`](https://webkit.org/blog/6161/locking-in-webkit/) +class, which essentially consists of a hash table mapping of lock addresses +to queues of parked (sleeping) threads. The Webkit parking lot was itself +inspired by Linux [futexes](http://man7.org/linux/man-pages/man2/futex.2.html), +but it is more powerful since it allows invoking callbacks while holding a queue +lock. + +## Nightly vs stable + +There are a few restrictions when using this library on stable Rust: + +- `Mutex` and `Once` will use 1 word of space instead of 1 byte. +- You will have to use `lazy_static!` to statically initialize `Mutex`, + `Condvar` and `RwLock` types instead of `const fn`. +- `RwLock` will not be able to take advantage of hardware lock elision for + readers, which improves performance when there are multiple readers. + +To enable nightly-only functionality, you need to enable the `nightly` feature +in Cargo (see below). + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +parking_lot = "0.6" +``` + +and this to your crate root: + +```rust +extern crate parking_lot; +``` + +To enable nightly-only features, add this to your `Cargo.toml` instead: + +```toml +[dependencies] +parking_lot = {version = "0.6", features = ["nightly"]} +``` + +The experimental deadlock detector can be enabled with the +`deadlock_detection` Cargo feature. + +The core parking lot API is provided by the `parking_lot_core` crate. It is +separate from the synchronization primitives in the `parking_lot` crate so that +changes to the core API do not cause breaking changes for users of `parking_lot`. + +## Minimum Rust version + +The current minimum required Rust version is 1.24. Any change to this is +considered a breaking change and will require a major version bump. + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any +additional terms or conditions. diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/appveyor.yml b/third_party/cargo/vendor/parking_lot-0.7.1/appveyor.yml new file mode 100644 index 0000000..83498db --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/appveyor.yml @@ -0,0 +1,29 @@ +environment: + TRAVIS_CARGO_NIGHTLY_FEATURE: nightly + RUST_TEST_THREADS: 1 + matrix: + - TARGET: nightly-x86_64-pc-windows-msvc + - TARGET: nightly-i686-pc-windows-msvc + - TARGET: nightly-x86_64-pc-windows-gnu + - TARGET: nightly-i686-pc-windows-gnu + - TARGET: 1.24.0-x86_64-pc-windows-msvc + - TARGET: 1.24.0-i686-pc-windows-msvc + - TARGET: 1.24.0-x86_64-pc-windows-gnu + - TARGET: 1.24.0-i686-pc-windows-gnu + +install: + - SET PATH=C:\Python27;C:\Python27\Scripts;%PATH%;%APPDATA%\Python\Scripts + - pip install "travis-cargo<0.2" --user + - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:TARGET}.exe" -FileName "rust-install.exe" + - ps: .\rust-install.exe /VERYSILENT /NORESTART /DIR="C:\rust" | Out-Null + - ps: $env:PATH="$env:PATH;C:\rust\bin" + - rustc -vV + - cargo -vV + +build_script: + - travis-cargo build + +test_script: + - travis-cargo test + - travis-cargo --only nightly test -- --features=deadlock_detection + - travis-cargo doc diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/condvar.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/condvar.rs new file mode 100644 index 0000000..cb85e88 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/condvar.rs @@ -0,0 +1,677 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use deadlock; +use lock_api::RawMutex as RawMutexTrait; +use mutex::MutexGuard; +use parking_lot_core::{self, ParkResult, RequeueOp, UnparkResult, DEFAULT_PARK_TOKEN}; +use raw_mutex::{RawMutex, TOKEN_HANDOFF, TOKEN_NORMAL}; +use std::sync::atomic::{AtomicPtr, Ordering}; +use std::time::{Duration, Instant}; +use std::{fmt, ptr}; +use util; + +/// A type indicating whether a timed wait on a condition variable returned +/// due to a time out or not. +#[derive(Debug, PartialEq, Eq, Copy, Clone)] +pub struct WaitTimeoutResult(bool); + +impl WaitTimeoutResult { + /// Returns whether the wait was known to have timed out. + #[inline] + pub fn timed_out(&self) -> bool { + self.0 + } +} + +/// A Condition Variable +/// +/// Condition variables represent the ability to block a thread such that it +/// consumes no CPU time while waiting for an event to occur. Condition +/// variables are typically associated with a boolean predicate (a condition) +/// and a mutex. The predicate is always verified inside of the mutex before +/// determining that thread must block. +/// +/// Note that this module places one additional restriction over the system +/// condition variables: each condvar can be used with only one mutex at a +/// time. Any attempt to use multiple mutexes on the same condition variable +/// simultaneously will result in a runtime panic. However it is possible to +/// switch to a different mutex if there are no threads currently waiting on +/// the condition variable. +/// +/// # Differences from the standard library `Condvar` +/// +/// - No spurious wakeups: A wait will only return a non-timeout result if it +/// was woken up by `notify_one` or `notify_all`. +/// - `Condvar::notify_all` will only wake up a single thread, the rest are +/// requeued to wait for the `Mutex` to be unlocked by the thread that was +/// woken up. +/// - Only requires 1 word of space, whereas the standard library boxes the +/// `Condvar` due to platform limitations. +/// - Can be statically constructed (requires the `const_fn` nightly feature). +/// - Does not require any drop glue when dropped. +/// - Inline fast path for the uncontended case. +/// +/// # Examples +/// +/// ``` +/// use parking_lot::{Mutex, Condvar}; +/// use std::sync::Arc; +/// use std::thread; +/// +/// let pair = Arc::new((Mutex::new(false), Condvar::new())); +/// let pair2 = pair.clone(); +/// +/// // Inside of our lock, spawn a new thread, and then wait for it to start +/// thread::spawn(move|| { +/// let &(ref lock, ref cvar) = &*pair2; +/// let mut started = lock.lock(); +/// *started = true; +/// cvar.notify_one(); +/// }); +/// +/// // wait for the thread to start up +/// let &(ref lock, ref cvar) = &*pair; +/// let mut started = lock.lock(); +/// while !*started { +/// cvar.wait(&mut started); +/// } +/// ``` +pub struct Condvar { + state: AtomicPtr, +} + +impl Condvar { + /// Creates a new condition variable which is ready to be waited on and + /// notified. + #[cfg(feature = "nightly")] + #[inline] + pub const fn new() -> Condvar { + Condvar { + state: AtomicPtr::new(ptr::null_mut()), + } + } + + /// Creates a new condition variable which is ready to be waited on and + /// notified. + #[cfg(not(feature = "nightly"))] + #[inline] + pub fn new() -> Condvar { + Condvar { + state: AtomicPtr::new(ptr::null_mut()), + } + } + + /// Wakes up one blocked thread on this condvar. + /// + /// Returns whether a thread was woken up. + /// + /// If there is a blocked thread on this condition variable, then it will + /// be woken up from its call to `wait` or `wait_timeout`. Calls to + /// `notify_one` are not buffered in any way. + /// + /// To wake up all threads, see `notify_all()`. + /// + /// # Examples + /// + /// ``` + /// use parking_lot::Condvar; + /// + /// let condvar = Condvar::new(); + /// + /// // do something with condvar, share it with other threads + /// + /// if !condvar.notify_one() { + /// println!("Nobody was listening for this."); + /// } + /// ``` + #[inline] + pub fn notify_one(&self) -> bool { + // Nothing to do if there are no waiting threads + let state = self.state.load(Ordering::Relaxed); + if state.is_null() { + return false; + } + + self.notify_one_slow(state) + } + + #[cold] + #[inline(never)] + fn notify_one_slow(&self, mutex: *mut RawMutex) -> bool { + unsafe { + // Unpark one thread and requeue the rest onto the mutex + let from = self as *const _ as usize; + let to = mutex as usize; + let validate = || { + // Make sure that our atomic state still points to the same + // mutex. If not then it means that all threads on the current + // mutex were woken up and a new waiting thread switched to a + // different mutex. In that case we can get away with doing + // nothing. + if self.state.load(Ordering::Relaxed) != mutex { + return RequeueOp::Abort; + } + + // Unpark one thread if the mutex is unlocked, otherwise just + // requeue everything to the mutex. This is safe to do here + // since unlocking the mutex when the parked bit is set requires + // locking the queue. There is the possibility of a race if the + // mutex gets locked after we check, but that doesn't matter in + // this case. + if (*mutex).mark_parked_if_locked() { + RequeueOp::RequeueOne + } else { + RequeueOp::UnparkOne + } + }; + let callback = |_op, result: UnparkResult| { + // Clear our state if there are no more waiting threads + if !result.have_more_threads { + self.state.store(ptr::null_mut(), Ordering::Relaxed); + } + TOKEN_NORMAL + }; + let res = parking_lot_core::unpark_requeue(from, to, validate, callback); + + res.unparked_threads + res.requeued_threads != 0 + } + } + + /// Wakes up all blocked threads on this condvar. + /// + /// Returns the number of threads woken up. + /// + /// This method will ensure that any current waiters on the condition + /// variable are awoken. Calls to `notify_all()` are not buffered in any + /// way. + /// + /// To wake up only one thread, see `notify_one()`. + #[inline] + pub fn notify_all(&self) -> usize { + // Nothing to do if there are no waiting threads + let state = self.state.load(Ordering::Relaxed); + if state.is_null() { + return 0; + } + + self.notify_all_slow(state) + } + + #[cold] + #[inline(never)] + fn notify_all_slow(&self, mutex: *mut RawMutex) -> usize { + unsafe { + // Unpark one thread and requeue the rest onto the mutex + let from = self as *const _ as usize; + let to = mutex as usize; + let validate = || { + // Make sure that our atomic state still points to the same + // mutex. If not then it means that all threads on the current + // mutex were woken up and a new waiting thread switched to a + // different mutex. In that case we can get away with doing + // nothing. + if self.state.load(Ordering::Relaxed) != mutex { + return RequeueOp::Abort; + } + + // Clear our state since we are going to unpark or requeue all + // threads. + self.state.store(ptr::null_mut(), Ordering::Relaxed); + + // Unpark one thread if the mutex is unlocked, otherwise just + // requeue everything to the mutex. This is safe to do here + // since unlocking the mutex when the parked bit is set requires + // locking the queue. There is the possibility of a race if the + // mutex gets locked after we check, but that doesn't matter in + // this case. + if (*mutex).mark_parked_if_locked() { + RequeueOp::RequeueAll + } else { + RequeueOp::UnparkOneRequeueRest + } + }; + let callback = |op, result: UnparkResult| { + // If we requeued threads to the mutex, mark it as having + // parked threads. The RequeueAll case is already handled above. + if op == RequeueOp::UnparkOneRequeueRest && result.requeued_threads != 0 { + (*mutex).mark_parked(); + } + TOKEN_NORMAL + }; + let res = parking_lot_core::unpark_requeue(from, to, validate, callback); + + res.unparked_threads + res.requeued_threads + } + } + + /// Blocks the current thread until this condition variable receives a + /// notification. + /// + /// This function will atomically unlock the mutex specified (represented by + /// `mutex_guard`) and block the current thread. This means that any calls + /// to `notify_*()` which happen logically after the mutex is unlocked are + /// candidates to wake this thread up. When this function call returns, the + /// lock specified will have been re-acquired. + /// + /// # Panics + /// + /// This function will panic if another thread is waiting on the `Condvar` + /// with a different `Mutex` object. + #[inline] + pub fn wait(&self, mutex_guard: &mut MutexGuard) { + self.wait_until_internal(unsafe { MutexGuard::mutex(mutex_guard).raw() }, None); + } + + /// Waits on this condition variable for a notification, timing out after + /// the specified time instant. + /// + /// The semantics of this function are equivalent to `wait()` except that + /// the thread will be blocked roughly until `timeout` is reached. This + /// method should not be used for precise timing due to anomalies such as + /// preemption or platform differences that may not cause the maximum + /// amount of time waited to be precisely `timeout`. + /// + /// Note that the best effort is made to ensure that the time waited is + /// measured with a monotonic clock, and not affected by the changes made to + /// the system time. + /// + /// The returned `WaitTimeoutResult` value indicates if the timeout is + /// known to have elapsed. + /// + /// Like `wait`, the lock specified will be re-acquired when this function + /// returns, regardless of whether the timeout elapsed or not. + /// + /// # Panics + /// + /// This function will panic if another thread is waiting on the `Condvar` + /// with a different `Mutex` object. + #[inline] + pub fn wait_until( + &self, + mutex_guard: &mut MutexGuard, + timeout: Instant, + ) -> WaitTimeoutResult { + self.wait_until_internal( + unsafe { MutexGuard::mutex(mutex_guard).raw() }, + Some(timeout), + ) + } + + // This is a non-generic function to reduce the monomorphization cost of + // using `wait_until`. + fn wait_until_internal(&self, mutex: &RawMutex, timeout: Option) -> WaitTimeoutResult { + unsafe { + let result; + let mut bad_mutex = false; + let mut requeued = false; + { + let addr = self as *const _ as usize; + let lock_addr = mutex as *const _ as *mut _; + let validate = || { + // Ensure we don't use two different mutexes with the same + // Condvar at the same time. This is done while locked to + // avoid races with notify_one + let state = self.state.load(Ordering::Relaxed); + if state.is_null() { + self.state.store(lock_addr, Ordering::Relaxed); + } else if state != lock_addr { + bad_mutex = true; + return false; + } + true + }; + let before_sleep = || { + // Unlock the mutex before sleeping... + mutex.unlock(); + }; + let timed_out = |k, was_last_thread| { + // If we were requeued to a mutex, then we did not time out. + // We'll just park ourselves on the mutex again when we try + // to lock it later. + requeued = k != addr; + + // If we were the last thread on the queue then we need to + // clear our state. This is normally done by the + // notify_{one,all} functions when not timing out. + if !requeued && was_last_thread { + self.state.store(ptr::null_mut(), Ordering::Relaxed); + } + }; + result = parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + DEFAULT_PARK_TOKEN, + timeout, + ); + } + + // Panic if we tried to use multiple mutexes with a Condvar. Note + // that at this point the MutexGuard is still locked. It will be + // unlocked by the unwinding logic. + if bad_mutex { + panic!("attempted to use a condition variable with more than one mutex"); + } + + // ... and re-lock it once we are done sleeping + if result == ParkResult::Unparked(TOKEN_HANDOFF) { + deadlock::acquire_resource(mutex as *const _ as usize); + } else { + mutex.lock(); + } + + WaitTimeoutResult(!(result.is_unparked() || requeued)) + } + } + + /// Waits on this condition variable for a notification, timing out after a + /// specified duration. + /// + /// The semantics of this function are equivalent to `wait()` except that + /// the thread will be blocked for roughly no longer than `timeout`. This + /// method should not be used for precise timing due to anomalies such as + /// preemption or platform differences that may not cause the maximum + /// amount of time waited to be precisely `timeout`. + /// + /// Note that the best effort is made to ensure that the time waited is + /// measured with a monotonic clock, and not affected by the changes made to + /// the system time. + /// + /// The returned `WaitTimeoutResult` value indicates if the timeout is + /// known to have elapsed. + /// + /// Like `wait`, the lock specified will be re-acquired when this function + /// returns, regardless of whether the timeout elapsed or not. + /// + /// # Panics + /// + /// Panics if the given `timeout` is so large that it can't be added to the current time. + /// This panic is not possible if the crate is built with the `nightly` feature, then a too + /// large `timeout` becomes equivalent to just calling `wait`. + #[inline] + pub fn wait_for( + &self, + mutex_guard: &mut MutexGuard, + timeout: Duration, + ) -> WaitTimeoutResult { + let deadline = util::to_deadline(timeout); + self.wait_until_internal(unsafe { MutexGuard::mutex(mutex_guard).raw() }, deadline) + } +} + +impl Default for Condvar { + #[inline] + fn default() -> Condvar { + Condvar::new() + } +} + +impl fmt::Debug for Condvar { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Condvar { .. }") + } +} + +#[cfg(test)] +mod tests { + use std::sync::mpsc::channel; + use std::sync::Arc; + use std::thread; + use std::time::{Duration, Instant}; + use {Condvar, Mutex}; + + #[test] + fn smoke() { + let c = Condvar::new(); + c.notify_one(); + c.notify_all(); + } + + #[test] + fn notify_one() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + let mut g = m.lock(); + let _t = thread::spawn(move || { + let _g = m2.lock(); + c2.notify_one(); + }); + c.wait(&mut g); + } + + #[test] + fn notify_all() { + const N: usize = 10; + + let data = Arc::new((Mutex::new(0), Condvar::new())); + let (tx, rx) = channel(); + for _ in 0..N { + let data = data.clone(); + let tx = tx.clone(); + thread::spawn(move || { + let &(ref lock, ref cond) = &*data; + let mut cnt = lock.lock(); + *cnt += 1; + if *cnt == N { + tx.send(()).unwrap(); + } + while *cnt != 0 { + cond.wait(&mut cnt); + } + tx.send(()).unwrap(); + }); + } + drop(tx); + + let &(ref lock, ref cond) = &*data; + rx.recv().unwrap(); + let mut cnt = lock.lock(); + *cnt = 0; + cond.notify_all(); + drop(cnt); + + for _ in 0..N { + rx.recv().unwrap(); + } + } + + #[test] + fn notify_one_return_true() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + let mut g = m.lock(); + let _t = thread::spawn(move || { + let _g = m2.lock(); + assert!(c2.notify_one()); + }); + c.wait(&mut g); + } + + #[test] + fn notify_one_return_false() { + let m = Arc::new(Mutex::new(())); + let c = Arc::new(Condvar::new()); + + let _t = thread::spawn(move || { + let _g = m.lock(); + assert!(!c.notify_one()); + }); + } + + #[test] + fn notify_all_return() { + const N: usize = 10; + + let data = Arc::new((Mutex::new(0), Condvar::new())); + let (tx, rx) = channel(); + for _ in 0..N { + let data = data.clone(); + let tx = tx.clone(); + thread::spawn(move || { + let &(ref lock, ref cond) = &*data; + let mut cnt = lock.lock(); + *cnt += 1; + if *cnt == N { + tx.send(()).unwrap(); + } + while *cnt != 0 { + cond.wait(&mut cnt); + } + tx.send(()).unwrap(); + }); + } + drop(tx); + + let &(ref lock, ref cond) = &*data; + rx.recv().unwrap(); + let mut cnt = lock.lock(); + *cnt = 0; + assert_eq!(cond.notify_all(), N); + drop(cnt); + + for _ in 0..N { + rx.recv().unwrap(); + } + + assert_eq!(cond.notify_all(), 0); + } + + #[test] + fn wait_for() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + let mut g = m.lock(); + let no_timeout = c.wait_for(&mut g, Duration::from_millis(1)); + assert!(no_timeout.timed_out()); + + let _t = thread::spawn(move || { + let _g = m2.lock(); + c2.notify_one(); + }); + // Non-nightly panics on too large timeouts. Nightly treats it as indefinite wait. + let very_long_timeout = if cfg!(feature = "nightly") { + Duration::from_secs(u64::max_value()) + } else { + Duration::from_millis(u32::max_value() as u64) + }; + + let timeout_res = c.wait_for(&mut g, very_long_timeout); + assert!(!timeout_res.timed_out()); + + drop(g); + } + + #[test] + fn wait_until() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + let mut g = m.lock(); + let no_timeout = c.wait_until(&mut g, Instant::now() + Duration::from_millis(1)); + assert!(no_timeout.timed_out()); + let _t = thread::spawn(move || { + let _g = m2.lock(); + c2.notify_one(); + }); + let timeout_res = c.wait_until( + &mut g, + Instant::now() + Duration::from_millis(u32::max_value() as u64), + ); + assert!(!timeout_res.timed_out()); + drop(g); + } + + #[test] + #[should_panic] + fn two_mutexes() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let m3 = Arc::new(Mutex::new(())); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + // Make sure we don't leave the child thread dangling + struct PanicGuard<'a>(&'a Condvar); + impl<'a> Drop for PanicGuard<'a> { + fn drop(&mut self) { + self.0.notify_one(); + } + } + + let (tx, rx) = channel(); + let g = m.lock(); + let _t = thread::spawn(move || { + let mut g = m2.lock(); + tx.send(()).unwrap(); + c2.wait(&mut g); + }); + drop(g); + rx.recv().unwrap(); + let _g = m.lock(); + let _guard = PanicGuard(&*c); + let _ = c.wait(&mut m3.lock()); + } + + #[test] + fn two_mutexes_disjoint() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let m3 = Arc::new(Mutex::new(())); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + + let mut g = m.lock(); + let _t = thread::spawn(move || { + let _g = m2.lock(); + c2.notify_one(); + }); + c.wait(&mut g); + drop(g); + + let _ = c.wait_for(&mut m3.lock(), Duration::from_millis(1)); + } + + #[test] + fn test_debug_condvar() { + let c = Condvar::new(); + assert_eq!(format!("{:?}", c), "Condvar { .. }"); + } + + #[test] + fn test_condvar_requeue() { + let m = Arc::new(Mutex::new(())); + let m2 = m.clone(); + let c = Arc::new(Condvar::new()); + let c2 = c.clone(); + let t = thread::spawn(move || { + let mut g = m2.lock(); + c2.wait(&mut g); + }); + + let mut g = m.lock(); + while !c.notify_one() { + // Wait for the thread to get into wait() + ::MutexGuard::bump(&mut g); + } + // The thread should have been requeued to the mutex, which we wake up now. + drop(g); + t.join().unwrap(); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/deadlock.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/deadlock.rs new file mode 100644 index 0000000..ef7d619 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/deadlock.rs @@ -0,0 +1,218 @@ +//! \[Experimental\] Deadlock detection +//! +//! This feature is optional and can be enabled via the `deadlock_detection` feature flag. +//! +//! # Example +//! +//! ``` +//! #[cfg(feature = "deadlock_detection")] +//! { // only for #[cfg] +//! use std::thread; +//! use std::time::Duration; +//! use parking_lot::deadlock; +//! +//! // Create a background thread which checks for deadlocks every 10s +//! thread::spawn(move || { +//! loop { +//! thread::sleep(Duration::from_secs(10)); +//! let deadlocks = deadlock::check_deadlock(); +//! if deadlocks.is_empty() { +//! continue; +//! } +//! +//! println!("{} deadlocks detected", deadlocks.len()); +//! for (i, threads) in deadlocks.iter().enumerate() { +//! println!("Deadlock #{}", i); +//! for t in threads { +//! println!("Thread Id {:#?}", t.thread_id()); +//! println!("{:#?}", t.backtrace()); +//! } +//! } +//! } +//! }); +//! } // only for #[cfg] +//! ``` + +#[cfg(feature = "deadlock_detection")] +pub use parking_lot_core::deadlock::check_deadlock; +pub(crate) use parking_lot_core::deadlock::{acquire_resource, release_resource}; + +#[cfg(test)] +#[cfg(feature = "deadlock_detection")] +mod tests { + use std::sync::{Arc, Barrier}; + use std::thread::{self, sleep}; + use std::time::Duration; + use {Mutex, ReentrantMutex, RwLock}; + + fn check_deadlock() -> bool { + use parking_lot_core::deadlock::check_deadlock; + !check_deadlock().is_empty() + } + + #[test] + fn test_mutex_deadlock() { + let m1: Arc> = Default::default(); + let m2: Arc> = Default::default(); + let m3: Arc> = Default::default(); + let b = Arc::new(Barrier::new(4)); + + let m1_ = m1.clone(); + let m2_ = m2.clone(); + let m3_ = m3.clone(); + let b1 = b.clone(); + let b2 = b.clone(); + let b3 = b.clone(); + + assert!(!check_deadlock()); + + let _t1 = thread::spawn(move || { + let _g = m1.lock(); + b1.wait(); + let _ = m2_.lock(); + }); + + let _t2 = thread::spawn(move || { + let _g = m2.lock(); + b2.wait(); + let _ = m3_.lock(); + }); + + let _t3 = thread::spawn(move || { + let _g = m3.lock(); + b3.wait(); + let _ = m1_.lock(); + }); + + assert!(!check_deadlock()); + + b.wait(); + sleep(Duration::from_millis(50)); + assert!(check_deadlock()); + + assert!(!check_deadlock()); + } + + #[test] + fn test_mutex_deadlock_reentrant() { + let m1: Arc> = Default::default(); + + assert!(!check_deadlock()); + + let _t1 = thread::spawn(move || { + let _g = m1.lock(); + let _ = m1.lock(); + }); + + sleep(Duration::from_millis(50)); + assert!(check_deadlock()); + + assert!(!check_deadlock()); + } + + #[test] + fn test_remutex_deadlock() { + let m1: Arc> = Default::default(); + let m2: Arc> = Default::default(); + let m3: Arc> = Default::default(); + let b = Arc::new(Barrier::new(4)); + + let m1_ = m1.clone(); + let m2_ = m2.clone(); + let m3_ = m3.clone(); + let b1 = b.clone(); + let b2 = b.clone(); + let b3 = b.clone(); + + assert!(!check_deadlock()); + + let _t1 = thread::spawn(move || { + let _g = m1.lock(); + let _g = m1.lock(); + b1.wait(); + let _ = m2_.lock(); + }); + + let _t2 = thread::spawn(move || { + let _g = m2.lock(); + let _g = m2.lock(); + b2.wait(); + let _ = m3_.lock(); + }); + + let _t3 = thread::spawn(move || { + let _g = m3.lock(); + let _g = m3.lock(); + b3.wait(); + let _ = m1_.lock(); + }); + + assert!(!check_deadlock()); + + b.wait(); + sleep(Duration::from_millis(50)); + assert!(check_deadlock()); + + assert!(!check_deadlock()); + } + + #[test] + fn test_rwlock_deadlock() { + let m1: Arc> = Default::default(); + let m2: Arc> = Default::default(); + let m3: Arc> = Default::default(); + let b = Arc::new(Barrier::new(4)); + + let m1_ = m1.clone(); + let m2_ = m2.clone(); + let m3_ = m3.clone(); + let b1 = b.clone(); + let b2 = b.clone(); + let b3 = b.clone(); + + assert!(!check_deadlock()); + + let _t1 = thread::spawn(move || { + let _g = m1.read(); + b1.wait(); + let _g = m2_.write(); + }); + + let _t2 = thread::spawn(move || { + let _g = m2.read(); + b2.wait(); + let _g = m3_.write(); + }); + + let _t3 = thread::spawn(move || { + let _g = m3.read(); + b3.wait(); + let _ = m1_.write(); + }); + + assert!(!check_deadlock()); + + b.wait(); + sleep(Duration::from_millis(50)); + assert!(check_deadlock()); + + assert!(!check_deadlock()); + } + + #[test] + fn test_rwlock_deadlock_reentrant() { + let m1: Arc> = Default::default(); + + assert!(!check_deadlock()); + + let _t1 = thread::spawn(move || { + let _g = m1.read(); + let _ = m1.write(); + }); + + sleep(Duration::from_millis(50)); + assert!(check_deadlock()); + + assert!(!check_deadlock()); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/elision.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/elision.rs new file mode 100644 index 0000000..b1201ee --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/elision.rs @@ -0,0 +1,177 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::sync::atomic::AtomicUsize; + +// Extension trait to add lock elision primitives to atomic types +pub trait AtomicElisionExt { + type IntType; + + // Perform a compare_exchange and start a transaction + fn elision_acquire( + &self, + current: Self::IntType, + new: Self::IntType, + ) -> Result; + // Perform a compare_exchange and end a transaction + fn elision_release( + &self, + current: Self::IntType, + new: Self::IntType, + ) -> Result; +} + +// Indicates whether the target architecture supports lock elision +#[inline] +pub fn have_elision() -> bool { + cfg!(all( + feature = "nightly", + any(target_arch = "x86", target_arch = "x86_64"), + )) +} + +// This implementation is never actually called because it is guarded by +// have_elision(). +#[cfg(not(all(feature = "nightly", any(target_arch = "x86", target_arch = "x86_64"))))] +impl AtomicElisionExt for AtomicUsize { + type IntType = usize; + + #[inline] + fn elision_acquire(&self, _: usize, _: usize) -> Result { + unreachable!(); + } + + #[inline] + fn elision_release(&self, _: usize, _: usize) -> Result { + unreachable!(); + } +} + +#[cfg(all(feature = "nightly", target_arch = "x86"))] +impl AtomicElisionExt for AtomicUsize { + type IntType = usize; + + #[inline] + fn elision_acquire(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xacquire; lock; cmpxchgl $2, $1" + : "={eax}" (prev), "+*m" (self) + : "r" (new), "{eax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } + + #[inline] + fn elision_release(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xrelease; lock; cmpxchgl $2, $1" + : "={eax}" (prev), "+*m" (self) + : "r" (new), "{eax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } +} + +#[cfg(all( + feature = "nightly", + target_arch = "x86_64", + target_pointer_width = "32" +))] +impl AtomicElisionExt for AtomicUsize { + type IntType = usize; + + #[inline] + fn elision_acquire(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xacquire; lock; cmpxchgl $2, $1" + : "={rax}" (prev), "+*m" (self) + : "r" (new), "{rax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } + + #[inline] + fn elision_release(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xrelease; lock; cmpxchgl $2, $1" + : "={rax}" (prev), "+*m" (self) + : "r" (new), "{rax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } +} + +#[cfg(all( + feature = "nightly", + target_arch = "x86_64", + target_pointer_width = "64" +))] +impl AtomicElisionExt for AtomicUsize { + type IntType = usize; + + #[inline] + fn elision_acquire(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xacquire; lock; cmpxchgq $2, $1" + : "={rax}" (prev), "+*m" (self) + : "r" (new), "{rax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } + + #[inline] + fn elision_release(&self, current: usize, new: usize) -> Result { + unsafe { + let prev: usize; + asm!("xrelease; lock; cmpxchgq $2, $1" + : "={rax}" (prev), "+*m" (self) + : "r" (new), "{rax}" (current) + : "memory" + : "volatile"); + if prev == current { + Ok(prev) + } else { + Err(prev) + } + } + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/lib.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/lib.rs new file mode 100644 index 0000000..e8cd726 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/lib.rs @@ -0,0 +1,45 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +//! This library provides implementations of `Mutex`, `RwLock`, `Condvar` and +//! `Once` that are smaller, faster and more flexible than those in the Rust +//! standard library. It also provides a `ReentrantMutex` type. + +#![warn(missing_docs)] +#![cfg_attr(feature = "nightly", feature(const_fn))] +#![cfg_attr(feature = "nightly", feature(integer_atomics))] +#![cfg_attr(feature = "nightly", feature(asm))] +#![cfg_attr(feature = "nightly", feature(time_checked_add))] + +extern crate lock_api; +extern crate parking_lot_core; + +mod condvar; +mod elision; +mod mutex; +mod once; +mod raw_mutex; +mod raw_rwlock; +mod remutex; +mod rwlock; +mod util; + +#[cfg(feature = "deadlock_detection")] +pub mod deadlock; +#[cfg(not(feature = "deadlock_detection"))] +mod deadlock; + +pub use condvar::{Condvar, WaitTimeoutResult}; +pub use mutex::{MappedMutexGuard, Mutex, MutexGuard}; +pub use once::{Once, OnceState, ONCE_INIT}; +pub use raw_mutex::RawMutex; +pub use raw_rwlock::RawRwLock; +pub use remutex::{MappedReentrantMutexGuard, RawThreadId, ReentrantMutex, ReentrantMutexGuard}; +pub use rwlock::{ + MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLock, RwLockReadGuard, + RwLockUpgradableReadGuard, RwLockWriteGuard, +}; diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/mutex.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/mutex.rs new file mode 100644 index 0000000..0e26570 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/mutex.rs @@ -0,0 +1,299 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use lock_api; +use raw_mutex::RawMutex; + +/// A mutual exclusion primitive useful for protecting shared data +/// +/// This mutex will block threads waiting for the lock to become available. The +/// mutex can also be statically initialized or created via a `new` +/// constructor. Each mutex has a type parameter which represents the data that +/// it is protecting. The data can only be accessed through the RAII guards +/// returned from `lock` and `try_lock`, which guarantees that the data is only +/// ever accessed when the mutex is locked. +/// +/// # Fairness +/// +/// A typical unfair lock can often end up in a situation where a single thread +/// quickly acquires and releases the same mutex in succession, which can starve +/// other threads waiting to acquire the mutex. While this improves performance +/// because it doesn't force a context switch when a thread tries to re-acquire +/// a mutex it has just released, this can starve other threads. +/// +/// This mutex uses [eventual fairness](https://trac.webkit.org/changeset/203350) +/// to ensure that the lock will be fair on average without sacrificing +/// performance. This is done by forcing a fair unlock on average every 0.5ms, +/// which will force the lock to go to the next thread waiting for the mutex. +/// +/// Additionally, any critical section longer than 1ms will always use a fair +/// unlock, which has a negligible performance impact compared to the length of +/// the critical section. +/// +/// You can also force a fair unlock by calling `MutexGuard::unlock_fair` when +/// unlocking a mutex instead of simply dropping the `MutexGuard`. +/// +/// # Differences from the standard library `Mutex` +/// +/// - No poisoning, the lock is released normally on panic. +/// - Only requires 1 byte of space, whereas the standard library boxes the +/// `Mutex` due to platform limitations. +/// - Can be statically constructed (requires the `const_fn` nightly feature). +/// - Does not require any drop glue when dropped. +/// - Inline fast path for the uncontended case. +/// - Efficient handling of micro-contention using adaptive spinning. +/// - Allows raw locking & unlocking without a guard. +/// - Supports eventual fairness so that the mutex is fair on average. +/// - Optionally allows making the mutex fair by calling `MutexGuard::unlock_fair`. +/// +/// # Examples +/// +/// ``` +/// use std::sync::Arc; +/// use parking_lot::Mutex; +/// use std::thread; +/// use std::sync::mpsc::channel; +/// +/// const N: usize = 10; +/// +/// // Spawn a few threads to increment a shared variable (non-atomically), and +/// // let the main thread know once all increments are done. +/// // +/// // Here we're using an Arc to share memory among threads, and the data inside +/// // the Arc is protected with a mutex. +/// let data = Arc::new(Mutex::new(0)); +/// +/// let (tx, rx) = channel(); +/// for _ in 0..10 { +/// let (data, tx) = (data.clone(), tx.clone()); +/// thread::spawn(move || { +/// // The shared state can only be accessed once the lock is held. +/// // Our non-atomic increment is safe because we're the only thread +/// // which can access the shared state when the lock is held. +/// let mut data = data.lock(); +/// *data += 1; +/// if *data == N { +/// tx.send(()).unwrap(); +/// } +/// // the lock is unlocked here when `data` goes out of scope. +/// }); +/// } +/// +/// rx.recv().unwrap(); +/// ``` +pub type Mutex = lock_api::Mutex; + +/// An RAII implementation of a "scoped lock" of a mutex. When this structure is +/// dropped (falls out of scope), the lock will be unlocked. +/// +/// The data protected by the mutex can be accessed through this guard via its +/// `Deref` and `DerefMut` implementations. +pub type MutexGuard<'a, T> = lock_api::MutexGuard<'a, RawMutex, T>; + +/// An RAII mutex guard returned by `MutexGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedMutexGuard` and `MutexGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +pub type MappedMutexGuard<'a, T> = lock_api::MappedMutexGuard<'a, RawMutex, T>; + +#[cfg(test)] +mod tests { + use std::sync::atomic::{AtomicUsize, Ordering}; + use std::sync::mpsc::channel; + use std::sync::Arc; + use std::thread; + use {Condvar, Mutex}; + + struct Packet(Arc<(Mutex, Condvar)>); + + #[derive(Eq, PartialEq, Debug)] + struct NonCopy(i32); + + unsafe impl Send for Packet {} + unsafe impl Sync for Packet {} + + #[test] + fn smoke() { + let m = Mutex::new(()); + drop(m.lock()); + drop(m.lock()); + } + + #[test] + fn lots_and_lots() { + const J: u32 = 1000; + const K: u32 = 3; + + let m = Arc::new(Mutex::new(0)); + + fn inc(m: &Mutex) { + for _ in 0..J { + *m.lock() += 1; + } + } + + let (tx, rx) = channel(); + for _ in 0..K { + let tx2 = tx.clone(); + let m2 = m.clone(); + thread::spawn(move || { + inc(&m2); + tx2.send(()).unwrap(); + }); + let tx2 = tx.clone(); + let m2 = m.clone(); + thread::spawn(move || { + inc(&m2); + tx2.send(()).unwrap(); + }); + } + + drop(tx); + for _ in 0..2 * K { + rx.recv().unwrap(); + } + assert_eq!(*m.lock(), J * K * 2); + } + + #[test] + fn try_lock() { + let m = Mutex::new(()); + *m.try_lock().unwrap() = (); + } + + #[test] + fn test_into_inner() { + let m = Mutex::new(NonCopy(10)); + assert_eq!(m.into_inner(), NonCopy(10)); + } + + #[test] + fn test_into_inner_drop() { + struct Foo(Arc); + impl Drop for Foo { + fn drop(&mut self) { + self.0.fetch_add(1, Ordering::SeqCst); + } + } + let num_drops = Arc::new(AtomicUsize::new(0)); + let m = Mutex::new(Foo(num_drops.clone())); + assert_eq!(num_drops.load(Ordering::SeqCst), 0); + { + let _inner = m.into_inner(); + assert_eq!(num_drops.load(Ordering::SeqCst), 0); + } + assert_eq!(num_drops.load(Ordering::SeqCst), 1); + } + + #[test] + fn test_get_mut() { + let mut m = Mutex::new(NonCopy(10)); + *m.get_mut() = NonCopy(20); + assert_eq!(m.into_inner(), NonCopy(20)); + } + + #[test] + fn test_mutex_arc_condvar() { + let packet = Packet(Arc::new((Mutex::new(false), Condvar::new()))); + let packet2 = Packet(packet.0.clone()); + let (tx, rx) = channel(); + let _t = thread::spawn(move || { + // wait until parent gets in + rx.recv().unwrap(); + let &(ref lock, ref cvar) = &*packet2.0; + let mut lock = lock.lock(); + *lock = true; + cvar.notify_one(); + }); + + let &(ref lock, ref cvar) = &*packet.0; + let mut lock = lock.lock(); + tx.send(()).unwrap(); + assert!(!*lock); + while !*lock { + cvar.wait(&mut lock); + } + } + + #[test] + fn test_mutex_arc_nested() { + // Tests nested mutexes and access + // to underlying data. + let arc = Arc::new(Mutex::new(1)); + let arc2 = Arc::new(Mutex::new(arc)); + let (tx, rx) = channel(); + let _t = thread::spawn(move || { + let lock = arc2.lock(); + let lock2 = lock.lock(); + assert_eq!(*lock2, 1); + tx.send(()).unwrap(); + }); + rx.recv().unwrap(); + } + + #[test] + fn test_mutex_arc_access_in_unwind() { + let arc = Arc::new(Mutex::new(1)); + let arc2 = arc.clone(); + let _ = thread::spawn(move || -> () { + struct Unwinder { + i: Arc>, + } + impl Drop for Unwinder { + fn drop(&mut self) { + *self.i.lock() += 1; + } + } + let _u = Unwinder { i: arc2 }; + panic!(); + }) + .join(); + let lock = arc.lock(); + assert_eq!(*lock, 2); + } + + #[test] + fn test_mutex_unsized() { + let mutex: &Mutex<[i32]> = &Mutex::new([1, 2, 3]); + { + let b = &mut *mutex.lock(); + b[0] = 4; + b[2] = 5; + } + let comp: &[i32] = &[4, 2, 5]; + assert_eq!(&*mutex.lock(), comp); + } + + #[test] + fn test_mutexguard_sync() { + fn sync(_: T) {} + + let mutex = Mutex::new(()); + sync(mutex.lock()); + } + + #[test] + fn test_mutex_debug() { + let mutex = Mutex::new(vec![0u8, 10]); + + assert_eq!(format!("{:?}", mutex), "Mutex { data: [0, 10] }"); + assert_eq!( + format!("{:#?}", mutex), + "Mutex { + data: [ + 0, + 10 + ] +}" + ); + let _lock = mutex.lock(); + assert_eq!(format!("{:?}", mutex), "Mutex { }"); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/once.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/once.rs new file mode 100644 index 0000000..33b7572 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/once.rs @@ -0,0 +1,488 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::sync::atomic::{fence, Ordering}; +#[cfg(feature = "nightly")] +use std::sync::atomic::{AtomicU8, ATOMIC_U8_INIT}; +#[cfg(feature = "nightly")] +type U8 = u8; +#[cfg(not(feature = "nightly"))] +use std::sync::atomic::AtomicUsize as AtomicU8; +#[cfg(not(feature = "nightly"))] +use std::sync::atomic::ATOMIC_USIZE_INIT as ATOMIC_U8_INIT; +#[cfg(not(feature = "nightly"))] +type U8 = usize; +use parking_lot_core::{self, SpinWait, DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN}; +use std::fmt; +use std::mem; +use util::UncheckedOptionExt; + +const DONE_BIT: U8 = 1; +const POISON_BIT: U8 = 2; +const LOCKED_BIT: U8 = 4; +const PARKED_BIT: U8 = 8; + +/// Current state of a `Once`. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub enum OnceState { + /// A closure has not been executed yet + New, + + /// A closure was executed but panicked. + Poisoned, + + /// A thread is currently executing a closure. + InProgress, + + /// A closure has completed successfully. + Done, +} + +impl OnceState { + /// Returns whether the associated `Once` has been poisoned. + /// + /// Once an initialization routine for a `Once` has panicked it will forever + /// indicate to future forced initialization routines that it is poisoned. + #[inline] + pub fn poisoned(&self) -> bool { + match *self { + OnceState::Poisoned => true, + _ => false, + } + } + + /// Returns whether the associated `Once` has successfully executed a + /// closure. + #[inline] + pub fn done(&self) -> bool { + match *self { + OnceState::Done => true, + _ => false, + } + } +} + +/// A synchronization primitive which can be used to run a one-time +/// initialization. Useful for one-time initialization for globals, FFI or +/// related functionality. +/// +/// # Differences from the standard library `Once` +/// +/// - Only requires 1 byte of space, instead of 1 word. +/// - Not required to be `'static`. +/// - Relaxed memory barriers in the fast path, which can significantly improve +/// performance on some architectures. +/// - Efficient handling of micro-contention using adaptive spinning. +/// +/// # Examples +/// +/// ``` +/// use parking_lot::{Once, ONCE_INIT}; +/// +/// static START: Once = ONCE_INIT; +/// +/// START.call_once(|| { +/// // run initialization here +/// }); +/// ``` +pub struct Once(AtomicU8); + +/// Initialization value for static `Once` values. +pub const ONCE_INIT: Once = Once(ATOMIC_U8_INIT); + +impl Once { + /// Creates a new `Once` value. + #[cfg(feature = "nightly")] + #[inline] + pub const fn new() -> Once { + Once(ATOMIC_U8_INIT) + } + + /// Creates a new `Once` value. + #[cfg(not(feature = "nightly"))] + #[inline] + pub fn new() -> Once { + Once(ATOMIC_U8_INIT) + } + + /// Returns the current state of this `Once`. + #[inline] + pub fn state(&self) -> OnceState { + let state = self.0.load(Ordering::Acquire); + if state & DONE_BIT != 0 { + OnceState::Done + } else if state & LOCKED_BIT != 0 { + OnceState::InProgress + } else if state & POISON_BIT != 0 { + OnceState::Poisoned + } else { + OnceState::New + } + } + + /// Performs an initialization routine once and only once. The given closure + /// will be executed if this is the first time `call_once` has been called, + /// and otherwise the routine will *not* be invoked. + /// + /// This method will block the calling thread if another initialization + /// routine is currently running. + /// + /// When this function returns, it is guaranteed that some initialization + /// has run and completed (it may not be the closure specified). It is also + /// guaranteed that any memory writes performed by the executed closure can + /// be reliably observed by other threads at this point (there is a + /// happens-before relation between the closure and code executing after the + /// return). + /// + /// # Examples + /// + /// ``` + /// use parking_lot::{Once, ONCE_INIT}; + /// + /// static mut VAL: usize = 0; + /// static INIT: Once = ONCE_INIT; + /// + /// // Accessing a `static mut` is unsafe much of the time, but if we do so + /// // in a synchronized fashion (e.g. write once or read all) then we're + /// // good to go! + /// // + /// // This function will only call `expensive_computation` once, and will + /// // otherwise always return the value returned from the first invocation. + /// fn get_cached_val() -> usize { + /// unsafe { + /// INIT.call_once(|| { + /// VAL = expensive_computation(); + /// }); + /// VAL + /// } + /// } + /// + /// fn expensive_computation() -> usize { + /// // ... + /// # 2 + /// } + /// ``` + /// + /// # Panics + /// + /// The closure `f` will only be executed once if this is called + /// concurrently amongst many threads. If that closure panics, however, then + /// it will *poison* this `Once` instance, causing all future invocations of + /// `call_once` to also panic. + #[inline] + pub fn call_once(&self, f: F) + where + F: FnOnce(), + { + if self.0.load(Ordering::Acquire) == DONE_BIT { + return; + } + + let mut f = Some(f); + self.call_once_slow(false, &mut |_| unsafe { f.take().unchecked_unwrap()() }); + } + + /// Performs the same function as `call_once` except ignores poisoning. + /// + /// If this `Once` has been poisoned (some initialization panicked) then + /// this function will continue to attempt to call initialization functions + /// until one of them doesn't panic. + /// + /// The closure `f` is yielded a structure which can be used to query the + /// state of this `Once` (whether initialization has previously panicked or + /// not). + #[inline] + pub fn call_once_force(&self, f: F) + where + F: FnOnce(OnceState), + { + if self.0.load(Ordering::Acquire) == DONE_BIT { + return; + } + + let mut f = Some(f); + self.call_once_slow(true, &mut |state| unsafe { + f.take().unchecked_unwrap()(state) + }); + } + + // This is a non-generic function to reduce the monomorphization cost of + // using `call_once` (this isn't exactly a trivial or small implementation). + // + // Additionally, this is tagged with `#[cold]` as it should indeed be cold + // and it helps let LLVM know that calls to this function should be off the + // fast path. Essentially, this should help generate more straight line code + // in LLVM. + // + // Finally, this takes an `FnMut` instead of a `FnOnce` because there's + // currently no way to take an `FnOnce` and call it via virtual dispatch + // without some allocation overhead. + #[cold] + #[inline(never)] + fn call_once_slow(&self, ignore_poison: bool, f: &mut FnMut(OnceState)) { + let mut spinwait = SpinWait::new(); + let mut state = self.0.load(Ordering::Relaxed); + loop { + // If another thread called the closure, we're done + if state & DONE_BIT != 0 { + // An acquire fence is needed here since we didn't load the + // state with Ordering::Acquire. + fence(Ordering::Acquire); + return; + } + + // If the state has been poisoned and we aren't forcing, then panic + if state & POISON_BIT != 0 && !ignore_poison { + // Need the fence here as well for the same reason + fence(Ordering::Acquire); + panic!("Once instance has previously been poisoned"); + } + + // Grab the lock if it isn't locked, even if there is a queue on it. + // We also clear the poison bit since we are going to try running + // the closure again. + if state & LOCKED_BIT == 0 { + match self.0.compare_exchange_weak( + state, + (state | LOCKED_BIT) & !POISON_BIT, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => break, + Err(x) => state = x, + } + continue; + } + + // If there is no queue, try spinning a few times + if state & PARKED_BIT == 0 && spinwait.spin() { + state = self.0.load(Ordering::Relaxed); + continue; + } + + // Set the parked bit + if state & PARKED_BIT == 0 { + if let Err(x) = self.0.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + state = x; + continue; + } + } + + // Park our thread until we are woken up by the thread that owns the + // lock. + unsafe { + let addr = self as *const _ as usize; + let validate = || self.0.load(Ordering::Relaxed) == LOCKED_BIT | PARKED_BIT; + let before_sleep = || {}; + let timed_out = |_, _| unreachable!(); + parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + DEFAULT_PARK_TOKEN, + None, + ); + } + + // Loop back and check if the done bit was set + spinwait.reset(); + state = self.0.load(Ordering::Relaxed); + } + + struct PanicGuard<'a>(&'a Once); + impl<'a> Drop for PanicGuard<'a> { + fn drop(&mut self) { + // Mark the state as poisoned, unlock it and unpark all threads. + let once = self.0; + let state = once.0.swap(POISON_BIT, Ordering::Release); + if state & PARKED_BIT != 0 { + unsafe { + let addr = once as *const _ as usize; + parking_lot_core::unpark_all(addr, DEFAULT_UNPARK_TOKEN); + } + } + } + } + + // At this point we have the lock, so run the closure. Make sure we + // properly clean up if the closure panicks. + let guard = PanicGuard(self); + let once_state = if state & POISON_BIT != 0 { + OnceState::Poisoned + } else { + OnceState::New + }; + f(once_state); + mem::forget(guard); + + // Now unlock the state, set the done bit and unpark all threads + let state = self.0.swap(DONE_BIT, Ordering::Release); + if state & PARKED_BIT != 0 { + unsafe { + let addr = self as *const _ as usize; + parking_lot_core::unpark_all(addr, DEFAULT_UNPARK_TOKEN); + } + } + } +} + +impl Default for Once { + #[inline] + fn default() -> Once { + Once::new() + } +} + +impl fmt::Debug for Once { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Once") + .field("state", &self.state()) + .finish() + } +} + +#[cfg(test)] +mod tests { + #[cfg(feature = "nightly")] + use std::panic; + use std::sync::mpsc::channel; + use std::thread; + use {Once, ONCE_INIT}; + + #[test] + fn smoke_once() { + static O: Once = ONCE_INIT; + let mut a = 0; + O.call_once(|| a += 1); + assert_eq!(a, 1); + O.call_once(|| a += 1); + assert_eq!(a, 1); + } + + #[test] + fn stampede_once() { + static O: Once = ONCE_INIT; + static mut RUN: bool = false; + + let (tx, rx) = channel(); + for _ in 0..10 { + let tx = tx.clone(); + thread::spawn(move || { + for _ in 0..4 { + thread::yield_now() + } + unsafe { + O.call_once(|| { + assert!(!RUN); + RUN = true; + }); + assert!(RUN); + } + tx.send(()).unwrap(); + }); + } + + unsafe { + O.call_once(|| { + assert!(!RUN); + RUN = true; + }); + assert!(RUN); + } + + for _ in 0..10 { + rx.recv().unwrap(); + } + } + + #[cfg(feature = "nightly")] + #[test] + fn poison_bad() { + static O: Once = ONCE_INIT; + + // poison the once + let t = panic::catch_unwind(|| { + O.call_once(|| panic!()); + }); + assert!(t.is_err()); + + // poisoning propagates + let t = panic::catch_unwind(|| { + O.call_once(|| {}); + }); + assert!(t.is_err()); + + // we can subvert poisoning, however + let mut called = false; + O.call_once_force(|p| { + called = true; + assert!(p.poisoned()) + }); + assert!(called); + + // once any success happens, we stop propagating the poison + O.call_once(|| {}); + } + + #[cfg(feature = "nightly")] + #[test] + fn wait_for_force_to_finish() { + static O: Once = ONCE_INIT; + + // poison the once + let t = panic::catch_unwind(|| { + O.call_once(|| panic!()); + }); + assert!(t.is_err()); + + // make sure someone's waiting inside the once via a force + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + let t1 = thread::spawn(move || { + O.call_once_force(|p| { + assert!(p.poisoned()); + tx1.send(()).unwrap(); + rx2.recv().unwrap(); + }); + }); + + rx1.recv().unwrap(); + + // put another waiter on the once + let t2 = thread::spawn(|| { + let mut called = false; + O.call_once(|| { + called = true; + }); + assert!(!called); + }); + + tx2.send(()).unwrap(); + + assert!(t1.join().is_ok()); + assert!(t2.join().is_ok()); + } + + #[test] + fn test_once_debug() { + static O: Once = ONCE_INIT; + + assert_eq!(format!("{:?}", O), "Once { state: New }"); + assert_eq!( + format!("{:#?}", O), + "Once { + state: New +}" + ); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/raw_mutex.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/raw_mutex.rs new file mode 100644 index 0000000..4b5f762 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/raw_mutex.rs @@ -0,0 +1,313 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::sync::atomic::Ordering; +#[cfg(feature = "nightly")] +use std::sync::atomic::{AtomicU8, ATOMIC_U8_INIT}; +#[cfg(feature = "nightly")] +type U8 = u8; +#[cfg(not(feature = "nightly"))] +use std::sync::atomic::AtomicUsize as AtomicU8; +#[cfg(not(feature = "nightly"))] +use std::sync::atomic::ATOMIC_USIZE_INIT as ATOMIC_U8_INIT; +#[cfg(not(feature = "nightly"))] +type U8 = usize; +use deadlock; +use lock_api::{GuardNoSend, RawMutex as RawMutexTrait, RawMutexFair, RawMutexTimed}; +use parking_lot_core::{self, ParkResult, SpinWait, UnparkResult, UnparkToken, DEFAULT_PARK_TOKEN}; +use std::time::{Duration, Instant}; +use util; + +// UnparkToken used to indicate that that the target thread should attempt to +// lock the mutex again as soon as it is unparked. +pub(crate) const TOKEN_NORMAL: UnparkToken = UnparkToken(0); + +// UnparkToken used to indicate that the mutex is being handed off to the target +// thread directly without unlocking it. +pub(crate) const TOKEN_HANDOFF: UnparkToken = UnparkToken(1); + +const LOCKED_BIT: U8 = 1; +const PARKED_BIT: U8 = 2; + +/// Raw mutex type backed by the parking lot. +pub struct RawMutex { + state: AtomicU8, +} + +unsafe impl RawMutexTrait for RawMutex { + const INIT: RawMutex = RawMutex { + state: ATOMIC_U8_INIT, + }; + + type GuardMarker = GuardNoSend; + + #[inline] + fn lock(&self) { + if self + .state + .compare_exchange_weak(0, LOCKED_BIT, Ordering::Acquire, Ordering::Relaxed) + .is_err() + { + self.lock_slow(None); + } + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + + #[inline] + fn try_lock(&self) -> bool { + let mut state = self.state.load(Ordering::Relaxed); + loop { + if state & LOCKED_BIT != 0 { + return false; + } + match self.state.compare_exchange_weak( + state, + state | LOCKED_BIT, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + return true; + } + Err(x) => state = x, + } + } + } + + #[inline] + fn unlock(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(LOCKED_BIT, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_slow(false); + } +} + +unsafe impl RawMutexFair for RawMutex { + #[inline] + fn unlock_fair(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(LOCKED_BIT, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_slow(true); + } + + #[inline] + fn bump(&self) { + if self.state.load(Ordering::Relaxed) & PARKED_BIT != 0 { + self.bump_slow(); + } + } +} + +unsafe impl RawMutexTimed for RawMutex { + type Duration = Duration; + type Instant = Instant; + + #[inline] + fn try_lock_until(&self, timeout: Instant) -> bool { + let result = if self + .state + .compare_exchange_weak(0, LOCKED_BIT, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + true + } else { + self.lock_slow(Some(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_for(&self, timeout: Duration) -> bool { + let result = if self + .state + .compare_exchange_weak(0, LOCKED_BIT, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + true + } else { + self.lock_slow(util::to_deadline(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } +} + +impl RawMutex { + // Used by Condvar when requeuing threads to us, must be called while + // holding the queue lock. + #[inline] + pub(crate) fn mark_parked_if_locked(&self) -> bool { + let mut state = self.state.load(Ordering::Relaxed); + loop { + if state & LOCKED_BIT == 0 { + return false; + } + match self.state.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + } + } + + // Used by Condvar when requeuing threads to us, must be called while + // holding the queue lock. + #[inline] + pub(crate) fn mark_parked(&self) { + self.state.fetch_or(PARKED_BIT, Ordering::Relaxed); + } + + #[cold] + #[inline(never)] + fn lock_slow(&self, timeout: Option) -> bool { + let mut spinwait = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Grab the lock if it isn't locked, even if there is a queue on it + if state & LOCKED_BIT == 0 { + match self.state.compare_exchange_weak( + state, + state | LOCKED_BIT, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + continue; + } + + // If there is no queue, try spinning a few times + if state & PARKED_BIT == 0 && spinwait.spin() { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Set the parked bit + if state & PARKED_BIT == 0 { + if let Err(x) = self.state.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + state = x; + continue; + } + } + + // Park our thread until we are woken up by an unlock + unsafe { + let addr = self as *const _ as usize; + let validate = || self.state.load(Ordering::Relaxed) == LOCKED_BIT | PARKED_BIT; + let before_sleep = || {}; + let timed_out = |_, was_last_thread| { + // Clear the parked bit if we were the last parked thread + if was_last_thread { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + }; + match parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + DEFAULT_PARK_TOKEN, + timeout, + ) { + // The thread that unparked us passed the lock on to us + // directly without unlocking it. + ParkResult::Unparked(TOKEN_HANDOFF) => return true, + + // We were unparked normally, try acquiring the lock again + ParkResult::Unparked(_) => (), + + // The validation function failed, try locking again + ParkResult::Invalid => (), + + // Timeout expired + ParkResult::TimedOut => return false, + } + } + + // Loop back and try locking again + spinwait.reset(); + state = self.state.load(Ordering::Relaxed); + } + } + + #[cold] + #[inline(never)] + fn unlock_slow(&self, force_fair: bool) { + // Unlock directly if there are no parked threads + if self + .state + .compare_exchange(LOCKED_BIT, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + + // Unpark one thread and leave the parked bit set if there might + // still be parked threads on this address. + unsafe { + let addr = self as *const _ as usize; + let callback = |result: UnparkResult| { + // If we are using a fair unlock then we should keep the + // mutex locked and hand it off to the unparked thread. + if result.unparked_threads != 0 && (force_fair || result.be_fair) { + // Clear the parked bit if there are no more parked + // threads. + if !result.have_more_threads { + self.state.store(LOCKED_BIT, Ordering::Relaxed); + } + return TOKEN_HANDOFF; + } + + // Clear the locked bit, and the parked bit as well if there + // are no more parked threads. + if result.have_more_threads { + self.state.store(PARKED_BIT, Ordering::Release); + } else { + self.state.store(0, Ordering::Release); + } + TOKEN_NORMAL + }; + parking_lot_core::unpark_one(addr, callback); + } + } + + #[cold] + #[inline(never)] + fn bump_slow(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + self.unlock_slow(true); + self.lock(); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/raw_rwlock.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/raw_rwlock.rs new file mode 100644 index 0000000..de70066 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/raw_rwlock.rs @@ -0,0 +1,1403 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use deadlock; +use elision::{have_elision, AtomicElisionExt}; +use lock_api::{ + GuardNoSend, RawRwLock as RawRwLockTrait, RawRwLockDowngrade, RawRwLockFair, + RawRwLockRecursive, RawRwLockRecursiveTimed, RawRwLockTimed, RawRwLockUpgrade, + RawRwLockUpgradeDowngrade, RawRwLockUpgradeFair, RawRwLockUpgradeTimed, +}; +use parking_lot_core::{self, FilterOp, ParkResult, ParkToken, SpinWait, UnparkResult}; +use raw_mutex::{TOKEN_HANDOFF, TOKEN_NORMAL}; +use std::cell::Cell; +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use std::time::{Duration, Instant}; +use util; + +const PARKED_BIT: usize = 0b001; +const UPGRADING_BIT: usize = 0b010; +// A shared guard acquires a single guard resource +const SHARED_GUARD: usize = 0b100; +const GUARD_COUNT_MASK: usize = !(SHARED_GUARD - 1); +// An exclusive lock acquires all of guard resource (i.e. it is exclusive) +const EXCLUSIVE_GUARD: usize = GUARD_COUNT_MASK; +// An upgradable lock acquires just over half of the guard resource +// This should be (GUARD_COUNT_MASK + SHARED_GUARD) >> 1, however this might +// overflow, so we shift before adding (which is okay since the least +// significant bit is zero for both GUARD_COUNT_MASK and SHARED_GUARD) +const UPGRADABLE_GUARD: usize = (GUARD_COUNT_MASK >> 1) + (SHARED_GUARD >> 1); + +// Token indicating what type of lock queued threads are trying to acquire +const TOKEN_SHARED: ParkToken = ParkToken(SHARED_GUARD); +const TOKEN_EXCLUSIVE: ParkToken = ParkToken(EXCLUSIVE_GUARD); +const TOKEN_UPGRADABLE: ParkToken = ParkToken(UPGRADABLE_GUARD); +const TOKEN_UPGRADING: ParkToken = ParkToken((EXCLUSIVE_GUARD - UPGRADABLE_GUARD) | UPGRADING_BIT); + +/// Raw reader-writer lock type backed by the parking lot. +pub struct RawRwLock { + state: AtomicUsize, +} + +unsafe impl RawRwLockTrait for RawRwLock { + const INIT: RawRwLock = RawRwLock { + state: ATOMIC_USIZE_INIT, + }; + + type GuardMarker = GuardNoSend; + + #[inline] + fn lock_exclusive(&self) { + if self + .state + .compare_exchange_weak(0, EXCLUSIVE_GUARD, Ordering::Acquire, Ordering::Relaxed) + .is_err() + { + let result = self.lock_exclusive_slow(None); + debug_assert!(result); + } + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + + #[inline] + fn try_lock_exclusive(&self) -> bool { + if self + .state + .compare_exchange(0, EXCLUSIVE_GUARD, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + true + } else { + false + } + } + + #[inline] + fn unlock_exclusive(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(EXCLUSIVE_GUARD, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_exclusive_slow(false); + } + + #[inline] + fn lock_shared(&self) { + if !self.try_lock_shared_fast(false) { + let result = self.lock_shared_slow(false, None); + debug_assert!(result); + } + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + + #[inline] + fn try_lock_shared(&self) -> bool { + let result = if self.try_lock_shared_fast(false) { + true + } else { + self.try_lock_shared_slow(false) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn unlock_shared(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + let state = self.state.load(Ordering::Relaxed); + if state & PARKED_BIT == 0 + || (state & UPGRADING_BIT == 0 && state & GUARD_COUNT_MASK != SHARED_GUARD) + { + if have_elision() { + if self + .state + .elision_release(state, state - SHARED_GUARD) + .is_ok() + { + return; + } + } else { + if self + .state + .compare_exchange_weak( + state, + state - SHARED_GUARD, + Ordering::Release, + Ordering::Relaxed, + ) + .is_ok() + { + return; + } + } + } + self.unlock_shared_slow(false); + } +} + +unsafe impl RawRwLockFair for RawRwLock { + #[inline] + fn unlock_shared_fair(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + let state = self.state.load(Ordering::Relaxed); + if state & PARKED_BIT == 0 + || (state & UPGRADING_BIT == 0 && state & GUARD_COUNT_MASK != SHARED_GUARD) + { + if have_elision() { + if self + .state + .elision_release(state, state - SHARED_GUARD) + .is_ok() + { + return; + } + } else { + if self + .state + .compare_exchange_weak( + state, + state - SHARED_GUARD, + Ordering::Release, + Ordering::Relaxed, + ) + .is_ok() + { + return; + } + } + } + self.unlock_shared_slow(true); + } + + #[inline] + fn unlock_exclusive_fair(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(EXCLUSIVE_GUARD, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_exclusive_slow(true); + } + + #[inline] + fn bump_shared(&self) { + if self.state.load(Ordering::Relaxed) & PARKED_BIT != 0 { + self.bump_shared_slow(); + } + } + + #[inline] + fn bump_exclusive(&self) { + if self.state.load(Ordering::Relaxed) & PARKED_BIT != 0 { + self.bump_exclusive_slow(); + } + } +} + +unsafe impl RawRwLockDowngrade for RawRwLock { + #[inline] + fn downgrade(&self) { + let state = self + .state + .fetch_sub(EXCLUSIVE_GUARD - SHARED_GUARD, Ordering::Release); + + // Wake up parked shared and upgradable threads if there are any + if state & PARKED_BIT != 0 { + self.downgrade_slow(); + } + } +} + +unsafe impl RawRwLockTimed for RawRwLock { + type Duration = Duration; + type Instant = Instant; + + #[inline] + fn try_lock_shared_for(&self, timeout: Self::Duration) -> bool { + let result = if self.try_lock_shared_fast(false) { + true + } else { + self.lock_shared_slow(false, util::to_deadline(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_shared_until(&self, timeout: Self::Instant) -> bool { + let result = if self.try_lock_shared_fast(false) { + true + } else { + self.lock_shared_slow(false, Some(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_exclusive_for(&self, timeout: Duration) -> bool { + let result = if self + .state + .compare_exchange_weak(0, EXCLUSIVE_GUARD, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + true + } else { + self.lock_exclusive_slow(util::to_deadline(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_exclusive_until(&self, timeout: Instant) -> bool { + let result = if self + .state + .compare_exchange_weak(0, EXCLUSIVE_GUARD, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + true + } else { + self.lock_exclusive_slow(Some(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } +} + +unsafe impl RawRwLockRecursive for RawRwLock { + #[inline] + fn lock_shared_recursive(&self) { + if !self.try_lock_shared_fast(true) { + let result = self.lock_shared_slow(true, None); + debug_assert!(result); + } + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + + #[inline] + fn try_lock_shared_recursive(&self) -> bool { + let result = if self.try_lock_shared_fast(true) { + true + } else { + self.try_lock_shared_slow(true) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } +} + +unsafe impl RawRwLockRecursiveTimed for RawRwLock { + #[inline] + fn try_lock_shared_recursive_for(&self, timeout: Self::Duration) -> bool { + let result = if self.try_lock_shared_fast(true) { + true + } else { + self.lock_shared_slow(true, util::to_deadline(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_shared_recursive_until(&self, timeout: Self::Instant) -> bool { + let result = if self.try_lock_shared_fast(true) { + true + } else { + self.lock_shared_slow(true, Some(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } +} + +unsafe impl RawRwLockUpgrade for RawRwLock { + #[inline] + fn lock_upgradable(&self) { + if !self.try_lock_upgradable_fast() { + let result = self.lock_upgradable_slow(None); + debug_assert!(result); + } + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + + #[inline] + fn try_lock_upgradable(&self) -> bool { + let result = if self.try_lock_upgradable_fast() { + true + } else { + self.try_lock_upgradable_slow() + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn unlock_upgradable(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(UPGRADABLE_GUARD, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_upgradable_slow(false); + } + + #[inline] + fn upgrade(&self) { + if self + .state + .compare_exchange_weak( + UPGRADABLE_GUARD, + EXCLUSIVE_GUARD, + Ordering::Relaxed, + Ordering::Relaxed, + ) + .is_err() + { + let result = self.upgrade_slow(None); + debug_assert!(result); + } + } + + fn try_upgrade(&self) -> bool { + if self + .state + .compare_exchange_weak( + UPGRADABLE_GUARD, + EXCLUSIVE_GUARD, + Ordering::Relaxed, + Ordering::Relaxed, + ) + .is_ok() + { + true + } else { + self.try_upgrade_slow() + } + } +} + +unsafe impl RawRwLockUpgradeFair for RawRwLock { + #[inline] + fn unlock_upgradable_fair(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + if self + .state + .compare_exchange_weak(UPGRADABLE_GUARD, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + self.unlock_upgradable_slow(true); + } + + #[inline] + fn bump_upgradable(&self) { + if self.state.load(Ordering::Relaxed) & PARKED_BIT != 0 { + self.bump_upgradable_slow(); + } + } +} + +unsafe impl RawRwLockUpgradeDowngrade for RawRwLock { + #[inline] + fn downgrade_upgradable(&self) { + let state = self + .state + .fetch_sub(UPGRADABLE_GUARD - SHARED_GUARD, Ordering::Relaxed); + + // Wake up parked shared and upgradable threads if there are any + if state & PARKED_BIT != 0 { + self.downgrade_upgradable_slow(state); + } + } + + #[inline] + fn downgrade_to_upgradable(&self) { + let state = self + .state + .fetch_sub(EXCLUSIVE_GUARD - UPGRADABLE_GUARD, Ordering::Release); + + // Wake up parked shared threads if there are any + if state & PARKED_BIT != 0 { + self.downgrade_to_upgradable_slow(); + } + } +} + +unsafe impl RawRwLockUpgradeTimed for RawRwLock { + #[inline] + fn try_lock_upgradable_until(&self, timeout: Instant) -> bool { + let result = if self.try_lock_upgradable_fast() { + true + } else { + self.lock_upgradable_slow(Some(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_lock_upgradable_for(&self, timeout: Duration) -> bool { + let result = if self.try_lock_upgradable_fast() { + true + } else { + self.lock_upgradable_slow(util::to_deadline(timeout)) + }; + if result { + unsafe { deadlock::acquire_resource(self as *const _ as usize) }; + } + result + } + + #[inline] + fn try_upgrade_until(&self, timeout: Instant) -> bool { + if self + .state + .compare_exchange_weak( + UPGRADABLE_GUARD, + EXCLUSIVE_GUARD, + Ordering::Relaxed, + Ordering::Relaxed, + ) + .is_ok() + { + true + } else { + self.upgrade_slow(Some(timeout)) + } + } + + #[inline] + fn try_upgrade_for(&self, timeout: Duration) -> bool { + if self + .state + .compare_exchange_weak( + UPGRADABLE_GUARD, + EXCLUSIVE_GUARD, + Ordering::Relaxed, + Ordering::Relaxed, + ) + .is_ok() + { + true + } else { + self.upgrade_slow(util::to_deadline(timeout)) + } + } +} + +impl RawRwLock { + #[inline(always)] + fn try_lock_shared_fast(&self, recursive: bool) -> bool { + let state = self.state.load(Ordering::Relaxed); + + // We can't allow grabbing a shared lock while there are parked threads + // since that could lead to writer starvation. + if !recursive && state & PARKED_BIT != 0 { + return false; + } + + // Use hardware lock elision to avoid cache conflicts when multiple + // readers try to acquire the lock. We only do this if the lock is + // completely empty since elision handles conflicts poorly. + if have_elision() && state == 0 { + self.state.elision_acquire(0, SHARED_GUARD).is_ok() + } else if let Some(new_state) = state.checked_add(SHARED_GUARD) { + self.state + .compare_exchange_weak(state, new_state, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + } else { + false + } + } + + #[inline(always)] + fn try_lock_upgradable_fast(&self) -> bool { + let state = self.state.load(Ordering::Relaxed); + + // We can't allow grabbing an upgradable lock while there are parked threads + // since that could lead to writer starvation. + if state & PARKED_BIT != 0 { + return false; + } + + if let Some(new_state) = state.checked_add(UPGRADABLE_GUARD) { + self.state + .compare_exchange_weak(state, new_state, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + } else { + false + } + } + + #[cold] + #[inline(never)] + fn lock_exclusive_slow(&self, timeout: Option) -> bool { + let mut spinwait = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Grab the lock if it isn't locked, even if there are other + // threads parked. + if let Some(new_state) = state.checked_add(EXCLUSIVE_GUARD) { + match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + continue; + } + + // If there are no parked threads and only one reader or writer, try + // spinning a few times. + if (state == EXCLUSIVE_GUARD || state == SHARED_GUARD || state == UPGRADABLE_GUARD) + && spinwait.spin() + { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Park our thread until we are woken up by an unlock + unsafe { + let addr = self as *const _ as usize; + let validate = || { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // If the rwlock is free, abort the park and try to grab + // it immediately. + if state & GUARD_COUNT_MASK == 0 { + return false; + } + + // Nothing to do if the parked bit is already set + if state & PARKED_BIT != 0 { + return true; + } + + // Set the parked bit + match self.state.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + } + }; + let before_sleep = || {}; + let timed_out = |_, was_last_thread| { + // Clear the parked bit if we were the last parked thread + if was_last_thread { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + }; + match parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + TOKEN_EXCLUSIVE, + timeout, + ) { + // The thread that unparked us passed the lock on to us + // directly without unlocking it. + ParkResult::Unparked(TOKEN_HANDOFF) => return true, + + // We were unparked normally, try acquiring the lock again + ParkResult::Unparked(_) => (), + + // The validation function failed, try locking again + ParkResult::Invalid => (), + + // Timeout expired + ParkResult::TimedOut => return false, + } + } + + // Loop back and try locking again + spinwait.reset(); + state = self.state.load(Ordering::Relaxed); + } + } + + #[cold] + #[inline(never)] + fn unlock_exclusive_slow(&self, force_fair: bool) { + // Unlock directly if there are no parked threads + if self + .state + .compare_exchange(EXCLUSIVE_GUARD, 0, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + }; + + // There are threads to unpark. We unpark threads up to the guard capacity. + let guard_count = Cell::new(0usize); + unsafe { + let addr = self as *const _ as usize; + let filter = |ParkToken(token)| -> FilterOp { + match guard_count.get().checked_add(token) { + Some(new_guard_count) => { + guard_count.set(new_guard_count); + FilterOp::Unpark + } + None => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + // If we are using a fair unlock then we should keep the + // rwlock locked and hand it off to the unparked threads. + if result.unparked_threads != 0 && (force_fair || result.be_fair) { + // We need to set the guard count accordingly. + let mut new_state = guard_count.get(); + + if result.have_more_threads { + new_state |= PARKED_BIT; + } + + self.state.store(new_state, Ordering::Release); + TOKEN_HANDOFF + } else { + // Clear the parked bit if there are no more parked threads. + if result.have_more_threads { + self.state.store(PARKED_BIT, Ordering::Release); + } else { + self.state.store(0, Ordering::Release); + } + TOKEN_NORMAL + } + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn downgrade_slow(&self) { + unsafe { + let addr = self as *const _ as usize; + let mut guard_count = SHARED_GUARD; + let filter = |ParkToken(token)| -> FilterOp { + match guard_count.checked_add(token) { + Some(new_guard_count) => { + guard_count = new_guard_count; + FilterOp::Unpark + } + None => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + // Clear the parked bit if there no more parked threads + if !result.have_more_threads { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + TOKEN_NORMAL + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn downgrade_to_upgradable_slow(&self) { + unsafe { + let addr = self as *const _ as usize; + let mut guard_count = UPGRADABLE_GUARD; + let filter = |ParkToken(token)| -> FilterOp { + match guard_count.checked_add(token) { + Some(new_guard_count) => { + guard_count = new_guard_count; + FilterOp::Unpark + } + None => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + // Clear the parked bit if there no more parked threads + if !result.have_more_threads { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + TOKEN_NORMAL + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn lock_shared_slow(&self, recursive: bool, timeout: Option) -> bool { + let mut spinwait = SpinWait::new(); + let mut spinwait_shared = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + let mut unparked = false; + loop { + // Use hardware lock elision to avoid cache conflicts when multiple + // readers try to acquire the lock. We only do this if the lock is + // completely empty since elision handles conflicts poorly. + if have_elision() && state == 0 { + match self.state.elision_acquire(0, SHARED_GUARD) { + Ok(_) => return true, + Err(x) => state = x, + } + } + + // Grab the lock if there are no exclusive threads locked or + // waiting. However if we were unparked then we are allowed to grab + // the lock even if there are pending exclusive threads. + if unparked || recursive || state & PARKED_BIT == 0 { + if let Some(new_state) = state.checked_add(SHARED_GUARD) { + if self + .state + .compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) + .is_ok() + { + return true; + } + + // If there is high contention on the reader count then we want + // to leave some time between attempts to acquire the lock to + // let other threads make progress. + spinwait_shared.spin_no_yield(); + state = self.state.load(Ordering::Relaxed); + continue; + } else { + // We were unparked spuriously, reset unparked flag. + unparked = false; + } + } + + // If there are no parked threads, try spinning a few times + if state & PARKED_BIT == 0 && spinwait.spin() { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Park our thread until we are woken up by an unlock + unsafe { + let addr = self as *const _ as usize; + let validate = || { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Nothing to do if the parked bit is already set + if state & PARKED_BIT != 0 { + return true; + } + + // If the parked bit is not set then it means we are at + // the front of the queue. If there is space for another + // lock then we should abort the park and try acquiring + // the lock again. + if state & GUARD_COUNT_MASK != GUARD_COUNT_MASK { + return false; + } + + // Set the parked bit + match self.state.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + } + }; + let before_sleep = || {}; + let timed_out = |_, was_last_thread| { + // Clear the parked bit if we were the last parked thread + if was_last_thread { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + }; + match parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + TOKEN_SHARED, + timeout, + ) { + // The thread that unparked us passed the lock on to us + // directly without unlocking it. + ParkResult::Unparked(TOKEN_HANDOFF) => return true, + + // We were unparked normally, try acquiring the lock again + ParkResult::Unparked(_) => (), + + // The validation function failed, try locking again + ParkResult::Invalid => (), + + // Timeout expired + ParkResult::TimedOut => return false, + } + } + + // Loop back and try locking again + spinwait.reset(); + spinwait_shared.reset(); + state = self.state.load(Ordering::Relaxed); + unparked = true; + } + } + + #[cold] + #[inline(never)] + fn try_lock_shared_slow(&self, recursive: bool) -> bool { + let mut state = self.state.load(Ordering::Relaxed); + loop { + if !recursive && state & PARKED_BIT != 0 { + return false; + } + if have_elision() && state == 0 { + match self.state.elision_acquire(0, SHARED_GUARD) { + Ok(_) => return true, + Err(x) => state = x, + } + } else { + match state.checked_add(SHARED_GUARD) { + Some(new_state) => match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + }, + None => return false, + } + } + } + } + + #[cold] + #[inline(never)] + fn unlock_shared_slow(&self, force_fair: bool) { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Just release the lock if there are no parked thread or if we are + // not the last shared thread. + if state & PARKED_BIT == 0 + || (state & UPGRADING_BIT == 0 && state & GUARD_COUNT_MASK != SHARED_GUARD) + || (state & UPGRADING_BIT != 0 + && state & GUARD_COUNT_MASK != UPGRADABLE_GUARD + SHARED_GUARD) + { + match self.state.compare_exchange_weak( + state, + state - SHARED_GUARD, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return, + Err(x) => state = x, + } + continue; + } + + break; + } + + // There are threads to unpark. If there is a thread waiting to be + // upgraded, we find that thread and let it upgrade, otherwise we + // unpark threads up to the guard capacity. Note that there is a + // potential race condition here: another thread might grab a shared + // lock between now and when we actually release our lock. + let additional_guards = Cell::new(0usize); + let has_upgraded = Cell::new(false); + unsafe { + let addr = self as *const _ as usize; + let filter = |ParkToken(token)| -> FilterOp { + // We need to check UPGRADING_BIT while holding the bucket lock, + // otherwise we might miss a thread trying to upgrade. + if self.state.load(Ordering::Relaxed) & UPGRADING_BIT == 0 { + match additional_guards.get().checked_add(token) { + Some(x) => { + additional_guards.set(x); + FilterOp::Unpark + } + None => FilterOp::Stop, + } + } else if has_upgraded.get() { + FilterOp::Stop + } else { + if token & UPGRADING_BIT != 0 { + additional_guards.set(token & !UPGRADING_BIT); + has_upgraded.set(true); + FilterOp::Unpark + } else { + FilterOp::Skip + } + } + }; + let callback = |result: UnparkResult| { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Release our shared lock + let mut new_state = state - SHARED_GUARD; + + // Clear the parked bit if there are no more threads in + // the queue. + if !result.have_more_threads { + new_state &= !PARKED_BIT; + } + + // Clear the upgrading bit if we are upgrading a thread. + if has_upgraded.get() { + new_state &= !UPGRADING_BIT; + } + + // Consider using fair unlocking. If we are, then we should set + // the state to the new value and tell the threads that we are + // handing the lock directly. + let token = if result.unparked_threads != 0 && (force_fair || result.be_fair) { + match new_state.checked_add(additional_guards.get()) { + Some(x) => { + new_state = x; + TOKEN_HANDOFF + } + None => TOKEN_NORMAL, + } + } else { + TOKEN_NORMAL + }; + + match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return token, + Err(x) => state = x, + } + } + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn lock_upgradable_slow(&self, timeout: Option) -> bool { + let mut spinwait = SpinWait::new(); + let mut spinwait_shared = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + let mut unparked = false; + loop { + // Grab the lock if there are no exclusive or upgradable threads + // locked or waiting. However if we were unparked then we are + // allowed to grab the lock even if there are pending exclusive threads. + if unparked || state & PARKED_BIT == 0 { + if let Some(new_state) = state.checked_add(UPGRADABLE_GUARD) { + if self + .state + .compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) + .is_ok() + { + return true; + } + + // If there is high contention on the reader count then we want + // to leave some time between attempts to acquire the lock to + // let other threads make progress. + spinwait_shared.spin_no_yield(); + state = self.state.load(Ordering::Relaxed); + continue; + } else { + // We were unparked spuriously, reset unparked flag. + unparked = false; + } + } + + // If there are no parked threads, try spinning a few times + if state & PARKED_BIT == 0 && spinwait.spin() { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Park our thread until we are woken up by an unlock + unsafe { + let addr = self as *const _ as usize; + let validate = || { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Nothing to do if the parked bit is already set + if state & PARKED_BIT != 0 { + return true; + } + + // If the parked bit is not set then it means we are at + // the front of the queue. If there is space for an + // upgradable lock then we should abort the park and try + // acquiring the lock again. + if state & UPGRADABLE_GUARD != UPGRADABLE_GUARD { + return false; + } + + // Set the parked bit + match self.state.compare_exchange_weak( + state, + state | PARKED_BIT, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + } + }; + let before_sleep = || {}; + let timed_out = |_, was_last_thread| { + // Clear the parked bit if we were the last parked thread + if was_last_thread { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + }; + match parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + TOKEN_UPGRADABLE, + timeout, + ) { + // The thread that unparked us passed the lock on to us + // directly without unlocking it. + ParkResult::Unparked(TOKEN_HANDOFF) => return true, + + // We were unparked normally, try acquiring the lock again + ParkResult::Unparked(_) => (), + + // The validation function failed, try locking again + ParkResult::Invalid => (), + + // Timeout expired + ParkResult::TimedOut => return false, + } + } + + // Loop back and try locking again + spinwait.reset(); + spinwait_shared.reset(); + state = self.state.load(Ordering::Relaxed); + unparked = true; + } + } + + #[cold] + #[inline(never)] + fn try_lock_upgradable_slow(&self) -> bool { + let mut state = self.state.load(Ordering::Relaxed); + loop { + if state & PARKED_BIT != 0 { + return false; + } + + match state.checked_add(UPGRADABLE_GUARD) { + Some(new_state) => match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + }, + None => return false, + } + } + } + + #[cold] + #[inline(never)] + fn unlock_upgradable_slow(&self, force_fair: bool) { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Just release the lock if there are no parked threads. + if state & PARKED_BIT == 0 { + match self.state.compare_exchange_weak( + state, + state - UPGRADABLE_GUARD, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return, + Err(x) => state = x, + } + continue; + } + + break; + } + + // There are threads to unpark. We unpark threads up to the guard capacity. + let additional_guards = Cell::new(0usize); + unsafe { + let addr = self as *const _ as usize; + let filter = |ParkToken(token)| -> FilterOp { + match additional_guards.get().checked_add(token) { + Some(x) => { + additional_guards.set(x); + FilterOp::Unpark + } + None => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Release our upgradable lock + let mut new_state = state - UPGRADABLE_GUARD; + + // Clear the parked bit if there are no more threads in + // the queue + if !result.have_more_threads { + new_state &= !PARKED_BIT; + } + + // Consider using fair unlocking. If we are, then we should set + // the state to the new value and tell the threads that we are + // handing the lock directly. + let token = if result.unparked_threads != 0 && (force_fair || result.be_fair) { + match new_state.checked_add(additional_guards.get()) { + Some(x) => { + new_state = x; + TOKEN_HANDOFF + } + None => TOKEN_NORMAL, + } + } else { + TOKEN_NORMAL + }; + + match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return token, + Err(x) => state = x, + } + } + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn downgrade_upgradable_slow(&self, state: usize) { + unsafe { + let addr = self as *const _ as usize; + let mut guard_count = (state & GUARD_COUNT_MASK) - UPGRADABLE_GUARD; + let filter = |ParkToken(token)| -> FilterOp { + match guard_count.checked_add(token) { + Some(x) => { + guard_count = x; + FilterOp::Unpark + } + None => FilterOp::Stop, + } + }; + let callback = |result: UnparkResult| { + // Clear the parked bit if there no more parked threads + if !result.have_more_threads { + self.state.fetch_and(!PARKED_BIT, Ordering::Relaxed); + } + TOKEN_NORMAL + }; + parking_lot_core::unpark_filter(addr, filter, callback); + } + } + + #[cold] + #[inline(never)] + fn try_upgrade_slow(&self) -> bool { + let mut state = self.state.load(Ordering::Relaxed); + loop { + match state.checked_add(EXCLUSIVE_GUARD - SHARED_GUARD) { + Some(new_state) => match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + }, + None => return false, + } + } + } + + #[cold] + #[inline(never)] + fn upgrade_slow(&self, timeout: Option) -> bool { + let mut spinwait = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Grab the lock if it isn't locked, even if there are other + // threads parked. + if let Some(new_state) = state.checked_add(EXCLUSIVE_GUARD - UPGRADABLE_GUARD) { + match self.state.compare_exchange_weak( + state, + new_state, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + continue; + } + + // If there are no parked threads and only one other reader, try + // spinning a few times. + if state == UPGRADABLE_GUARD | SHARED_GUARD && spinwait.spin() { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Park our thread until we are woken up by an unlock + unsafe { + let addr = self as *const _ as usize; + let validate = || { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // If the rwlock is free, abort the park and try to grab + // it immediately. + if state & GUARD_COUNT_MASK == UPGRADABLE_GUARD { + return false; + } + + // Set the upgrading and parked bits + match self.state.compare_exchange_weak( + state, + state | (UPGRADING_BIT | PARKED_BIT), + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => return true, + Err(x) => state = x, + } + } + }; + let before_sleep = || {}; + let timed_out = |_, was_last_thread| { + // Clear the upgrading bit + let mut flags = UPGRADING_BIT; + + // Clear the parked bit if we were the last parked thread + if was_last_thread { + flags |= PARKED_BIT; + } + + self.state.fetch_and(!flags, Ordering::Relaxed); + }; + match parking_lot_core::park( + addr, + validate, + before_sleep, + timed_out, + TOKEN_UPGRADING, + timeout, + ) { + // The thread that unparked us passed the lock on to us + // directly without unlocking it. + ParkResult::Unparked(TOKEN_HANDOFF) => return true, + + // We were unparked normally, try acquiring the lock again + ParkResult::Unparked(_) => (), + + // The validation function failed, try locking again + ParkResult::Invalid => (), + + // Timeout expired + ParkResult::TimedOut => return false, + } + } + + // Loop back and try locking again + spinwait.reset(); + state = self.state.load(Ordering::Relaxed); + } + } + + #[cold] + #[inline(never)] + fn bump_shared_slow(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + self.unlock_shared_slow(true); + self.lock_shared(); + } + + #[cold] + #[inline(never)] + fn bump_exclusive_slow(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + self.unlock_exclusive_slow(true); + self.lock_exclusive(); + } + + #[cold] + #[inline(never)] + fn bump_upgradable_slow(&self) { + unsafe { deadlock::release_resource(self as *const _ as usize) }; + self.unlock_upgradable_slow(true); + self.lock_upgradable(); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/remutex.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/remutex.rs new file mode 100644 index 0000000..aa40e14 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/remutex.rs @@ -0,0 +1,126 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use lock_api::{self, GetThreadId}; +use raw_mutex::RawMutex; + +/// Implementation of the `GetThreadId` trait for `lock_api::ReentrantMutex`. +pub struct RawThreadId; + +unsafe impl GetThreadId for RawThreadId { + const INIT: RawThreadId = RawThreadId; + + fn nonzero_thread_id(&self) -> usize { + // The address of a thread-local variable is guaranteed to be unique to the + // current thread, and is also guaranteed to be non-zero. + thread_local!(static KEY: u8 = unsafe { ::std::mem::uninitialized() }); + KEY.with(|x| x as *const _ as usize) + } +} + +/// A mutex which can be recursively locked by a single thread. +/// +/// This type is identical to `Mutex` except for the following points: +/// +/// - Locking multiple times from the same thread will work correctly instead of +/// deadlocking. +/// - `ReentrantMutexGuard` does not give mutable references to the locked data. +/// Use a `RefCell` if you need this. +/// +/// See [`Mutex`](struct.Mutex.html) for more details about the underlying mutex +/// primitive. +pub type ReentrantMutex = lock_api::ReentrantMutex; + +/// An RAII implementation of a "scoped lock" of a reentrant mutex. When this structure +/// is dropped (falls out of scope), the lock will be unlocked. +/// +/// The data protected by the mutex can be accessed through this guard via its +/// `Deref` implementation. +pub type ReentrantMutexGuard<'a, T> = lock_api::ReentrantMutexGuard<'a, RawMutex, RawThreadId, T>; + +/// An RAII mutex guard returned by `ReentrantMutexGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedReentrantMutexGuard` and `ReentrantMutexGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +pub type MappedReentrantMutexGuard<'a, T> = + lock_api::MappedReentrantMutexGuard<'a, RawMutex, RawThreadId, T>; + +#[cfg(test)] +mod tests { + use std::cell::RefCell; + use std::sync::Arc; + use std::thread; + use ReentrantMutex; + + #[test] + fn smoke() { + let m = ReentrantMutex::new(()); + { + let a = m.lock(); + { + let b = m.lock(); + { + let c = m.lock(); + assert_eq!(*c, ()); + } + assert_eq!(*b, ()); + } + assert_eq!(*a, ()); + } + } + + #[test] + fn is_mutex() { + let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); + let m2 = m.clone(); + let lock = m.lock(); + let child = thread::spawn(move || { + let lock = m2.lock(); + assert_eq!(*lock.borrow(), 4950); + }); + for i in 0..100 { + let lock = m.lock(); + *lock.borrow_mut() += i; + } + drop(lock); + child.join().unwrap(); + } + + #[test] + fn trylock_works() { + let m = Arc::new(ReentrantMutex::new(())); + let m2 = m.clone(); + let _lock = m.try_lock(); + let _lock2 = m.try_lock(); + thread::spawn(move || { + let lock = m2.try_lock(); + assert!(lock.is_none()); + }) + .join() + .unwrap(); + let _lock3 = m.try_lock(); + } + + #[test] + fn test_reentrant_mutex_debug() { + let mutex = ReentrantMutex::new(vec![0u8, 10]); + + assert_eq!(format!("{:?}", mutex), "ReentrantMutex { data: [0, 10] }"); + assert_eq!( + format!("{:#?}", mutex), + "ReentrantMutex { + data: [ + 0, + 10 + ] +}" + ); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/rwlock.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/rwlock.rs new file mode 100644 index 0000000..f970924 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/rwlock.rs @@ -0,0 +1,568 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use lock_api; +use raw_rwlock::RawRwLock; + +/// A reader-writer lock +/// +/// This type of lock allows a number of readers or at most one writer at any +/// point in time. The write portion of this lock typically allows modification +/// of the underlying data (exclusive access) and the read portion of this lock +/// typically allows for read-only access (shared access). +/// +/// This lock uses a task-fair locking policy which avoids both reader and +/// writer starvation. This means that readers trying to acquire the lock will +/// block even if the lock is unlocked when there are writers waiting to acquire +/// the lock. Because of this, attempts to recursively acquire a read lock +/// within a single thread may result in a deadlock. +/// +/// The type parameter `T` represents the data that this lock protects. It is +/// required that `T` satisfies `Send` to be shared across threads and `Sync` to +/// allow concurrent access through readers. The RAII guards returned from the +/// locking methods implement `Deref` (and `DerefMut` for the `write` methods) +/// to allow access to the contained of the lock. +/// +/// # Fairness +/// +/// A typical unfair lock can often end up in a situation where a single thread +/// quickly acquires and releases the same lock in succession, which can starve +/// other threads waiting to acquire the rwlock. While this improves performance +/// because it doesn't force a context switch when a thread tries to re-acquire +/// a rwlock it has just released, this can starve other threads. +/// +/// This rwlock uses [eventual fairness](https://trac.webkit.org/changeset/203350) +/// to ensure that the lock will be fair on average without sacrificing +/// performance. This is done by forcing a fair unlock on average every 0.5ms, +/// which will force the lock to go to the next thread waiting for the rwlock. +/// +/// Additionally, any critical section longer than 1ms will always use a fair +/// unlock, which has a negligible performance impact compared to the length of +/// the critical section. +/// +/// You can also force a fair unlock by calling `RwLockReadGuard::unlock_fair` +/// or `RwLockWriteGuard::unlock_fair` when unlocking a mutex instead of simply +/// dropping the guard. +/// +/// # Differences from the standard library `RwLock` +/// +/// - Supports atomically downgrading a write lock into a read lock. +/// - Task-fair locking policy instead of an unspecified platform default. +/// - No poisoning, the lock is released normally on panic. +/// - Only requires 1 word of space, whereas the standard library boxes the +/// `RwLock` due to platform limitations. +/// - Can be statically constructed (requires the `const_fn` nightly feature). +/// - Does not require any drop glue when dropped. +/// - Inline fast path for the uncontended case. +/// - Efficient handling of micro-contention using adaptive spinning. +/// - Allows raw locking & unlocking without a guard. +/// - Supports eventual fairness so that the rwlock is fair on average. +/// - Optionally allows making the rwlock fair by calling +/// `RwLockReadGuard::unlock_fair` and `RwLockWriteGuard::unlock_fair`. +/// +/// # Examples +/// +/// ``` +/// use parking_lot::RwLock; +/// +/// let lock = RwLock::new(5); +/// +/// // many reader locks can be held at once +/// { +/// let r1 = lock.read(); +/// let r2 = lock.read(); +/// assert_eq!(*r1, 5); +/// assert_eq!(*r2, 5); +/// } // read locks are dropped at this point +/// +/// // only one write lock may be held, however +/// { +/// let mut w = lock.write(); +/// *w += 1; +/// assert_eq!(*w, 6); +/// } // write lock is dropped here +/// ``` +pub type RwLock = lock_api::RwLock; + +/// RAII structure used to release the shared read access of a lock when +/// dropped. +pub type RwLockReadGuard<'a, T> = lock_api::RwLockReadGuard<'a, RawRwLock, T>; + +/// RAII structure used to release the exclusive write access of a lock when +/// dropped. +pub type RwLockWriteGuard<'a, T> = lock_api::RwLockWriteGuard<'a, RawRwLock, T>; + +/// An RAII read lock guard returned by `RwLockReadGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedRwLockReadGuard` and `RwLockReadGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +pub type MappedRwLockReadGuard<'a, T> = lock_api::MappedRwLockReadGuard<'a, RawRwLock, T>; + +/// An RAII write lock guard returned by `RwLockWriteGuard::map`, which can point to a +/// subfield of the protected data. +/// +/// The main difference between `MappedRwLockWriteGuard` and `RwLockWriteGuard` is that the +/// former doesn't support temporarily unlocking and re-locking, since that +/// could introduce soundness issues if the locked object is modified by another +/// thread. +pub type MappedRwLockWriteGuard<'a, T> = lock_api::MappedRwLockWriteGuard<'a, RawRwLock, T>; + +/// RAII structure used to release the upgradable read access of a lock when +/// dropped. +pub type RwLockUpgradableReadGuard<'a, T> = lock_api::RwLockUpgradableReadGuard<'a, RawRwLock, T>; + +#[cfg(test)] +mod tests { + extern crate rand; + use self::rand::Rng; + use std::sync::atomic::{AtomicUsize, Ordering}; + use std::sync::mpsc::channel; + use std::sync::Arc; + use std::thread; + use std::time::Duration; + use {RwLock, RwLockUpgradableReadGuard, RwLockWriteGuard}; + + #[derive(Eq, PartialEq, Debug)] + struct NonCopy(i32); + + #[test] + fn smoke() { + let l = RwLock::new(()); + drop(l.read()); + drop(l.write()); + drop(l.upgradable_read()); + drop((l.read(), l.read())); + drop((l.read(), l.upgradable_read())); + drop(l.write()); + } + + #[test] + fn frob() { + const N: u32 = 10; + const M: u32 = 1000; + + let r = Arc::new(RwLock::new(())); + + let (tx, rx) = channel::<()>(); + for _ in 0..N { + let tx = tx.clone(); + let r = r.clone(); + thread::spawn(move || { + let mut rng = rand::thread_rng(); + for _ in 0..M { + if rng.gen_bool(1.0 / N as f64) { + drop(r.write()); + } else { + drop(r.read()); + } + } + drop(tx); + }); + } + drop(tx); + let _ = rx.recv(); + } + + #[test] + fn test_rw_arc_no_poison_wr() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.write(); + panic!(); + }) + .join(); + let lock = arc.read(); + assert_eq!(*lock, 1); + } + + #[test] + fn test_rw_arc_no_poison_ww() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.write(); + panic!(); + }) + .join(); + let lock = arc.write(); + assert_eq!(*lock, 1); + } + + #[test] + fn test_rw_arc_no_poison_rr() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.read(); + panic!(); + }) + .join(); + let lock = arc.read(); + assert_eq!(*lock, 1); + } + + #[test] + fn test_rw_arc_no_poison_rw() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.read(); + panic!() + }) + .join(); + let lock = arc.write(); + assert_eq!(*lock, 1); + } + + #[test] + fn test_ruw_arc() { + let arc = Arc::new(RwLock::new(0)); + let arc2 = arc.clone(); + let (tx, rx) = channel(); + + thread::spawn(move || { + for _ in 0..10 { + let mut lock = arc2.write(); + let tmp = *lock; + *lock = -1; + thread::yield_now(); + *lock = tmp + 1; + } + tx.send(()).unwrap(); + }); + + let mut children = Vec::new(); + + // Upgradable readers try to catch the writer in the act and also + // try to touch the value + for _ in 0..5 { + let arc3 = arc.clone(); + children.push(thread::spawn(move || { + let lock = arc3.upgradable_read(); + let tmp = *lock; + assert!(tmp >= 0); + thread::yield_now(); + let mut lock = RwLockUpgradableReadGuard::upgrade(lock); + assert_eq!(tmp, *lock); + *lock = -1; + thread::yield_now(); + *lock = tmp + 1; + })); + } + + // Readers try to catch the writers in the act + for _ in 0..5 { + let arc4 = arc.clone(); + children.push(thread::spawn(move || { + let lock = arc4.read(); + assert!(*lock >= 0); + })); + } + + // Wait for children to pass their asserts + for r in children { + assert!(r.join().is_ok()); + } + + // Wait for writer to finish + rx.recv().unwrap(); + let lock = arc.read(); + assert_eq!(*lock, 15); + } + + #[test] + fn test_rw_arc() { + let arc = Arc::new(RwLock::new(0)); + let arc2 = arc.clone(); + let (tx, rx) = channel(); + + thread::spawn(move || { + let mut lock = arc2.write(); + for _ in 0..10 { + let tmp = *lock; + *lock = -1; + thread::yield_now(); + *lock = tmp + 1; + } + tx.send(()).unwrap(); + }); + + // Readers try to catch the writer in the act + let mut children = Vec::new(); + for _ in 0..5 { + let arc3 = arc.clone(); + children.push(thread::spawn(move || { + let lock = arc3.read(); + assert!(*lock >= 0); + })); + } + + // Wait for children to pass their asserts + for r in children { + assert!(r.join().is_ok()); + } + + // Wait for writer to finish + rx.recv().unwrap(); + let lock = arc.read(); + assert_eq!(*lock, 10); + } + + #[test] + fn test_rw_arc_access_in_unwind() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _ = thread::spawn(move || -> () { + struct Unwinder { + i: Arc>, + } + impl Drop for Unwinder { + fn drop(&mut self) { + let mut lock = self.i.write(); + *lock += 1; + } + } + let _u = Unwinder { i: arc2 }; + panic!(); + }) + .join(); + let lock = arc.read(); + assert_eq!(*lock, 2); + } + + #[test] + fn test_rwlock_unsized() { + let rw: &RwLock<[i32]> = &RwLock::new([1, 2, 3]); + { + let b = &mut *rw.write(); + b[0] = 4; + b[2] = 5; + } + let comp: &[i32] = &[4, 2, 5]; + assert_eq!(&*rw.read(), comp); + } + + #[test] + fn test_rwlock_try_read() { + let lock = RwLock::new(0isize); + { + let read_guard = lock.read(); + + let read_result = lock.try_read(); + assert!( + read_result.is_some(), + "try_read should succeed while read_guard is in scope" + ); + + drop(read_guard); + } + { + let upgrade_guard = lock.upgradable_read(); + + let read_result = lock.try_read(); + assert!( + read_result.is_some(), + "try_read should succeed while upgrade_guard is in scope" + ); + + drop(upgrade_guard); + } + { + let write_guard = lock.write(); + + let read_result = lock.try_read(); + assert!( + read_result.is_none(), + "try_read should fail while write_guard is in scope" + ); + + drop(write_guard); + } + } + + #[test] + fn test_rwlock_try_write() { + let lock = RwLock::new(0isize); + { + let read_guard = lock.read(); + + let write_result = lock.try_write(); + assert!( + write_result.is_none(), + "try_write should fail while read_guard is in scope" + ); + + drop(read_guard); + } + { + let upgrade_guard = lock.upgradable_read(); + + let write_result = lock.try_write(); + assert!( + write_result.is_none(), + "try_write should fail while upgrade_guard is in scope" + ); + + drop(upgrade_guard); + } + { + let write_guard = lock.write(); + + let write_result = lock.try_write(); + assert!( + write_result.is_none(), + "try_write should fail while write_guard is in scope" + ); + + drop(write_guard); + } + } + + #[test] + fn test_rwlock_try_upgrade() { + let lock = RwLock::new(0isize); + { + let read_guard = lock.read(); + + let upgrade_result = lock.try_upgradable_read(); + assert!( + upgrade_result.is_some(), + "try_upgradable_read should succeed while read_guard is in scope" + ); + + drop(read_guard); + } + { + let upgrade_guard = lock.upgradable_read(); + + let upgrade_result = lock.try_upgradable_read(); + assert!( + upgrade_result.is_none(), + "try_upgradable_read should fail while upgrade_guard is in scope" + ); + + drop(upgrade_guard); + } + { + let write_guard = lock.write(); + + let upgrade_result = lock.try_upgradable_read(); + assert!( + upgrade_result.is_none(), + "try_upgradable should fail while write_guard is in scope" + ); + + drop(write_guard); + } + } + + #[test] + fn test_into_inner() { + let m = RwLock::new(NonCopy(10)); + assert_eq!(m.into_inner(), NonCopy(10)); + } + + #[test] + fn test_into_inner_drop() { + struct Foo(Arc); + impl Drop for Foo { + fn drop(&mut self) { + self.0.fetch_add(1, Ordering::SeqCst); + } + } + let num_drops = Arc::new(AtomicUsize::new(0)); + let m = RwLock::new(Foo(num_drops.clone())); + assert_eq!(num_drops.load(Ordering::SeqCst), 0); + { + let _inner = m.into_inner(); + assert_eq!(num_drops.load(Ordering::SeqCst), 0); + } + assert_eq!(num_drops.load(Ordering::SeqCst), 1); + } + + #[test] + fn test_get_mut() { + let mut m = RwLock::new(NonCopy(10)); + *m.get_mut() = NonCopy(20); + assert_eq!(m.into_inner(), NonCopy(20)); + } + + #[test] + fn test_rwlockguard_sync() { + fn sync(_: T) {} + + let rwlock = RwLock::new(()); + sync(rwlock.read()); + sync(rwlock.write()); + } + + #[test] + fn test_rwlock_downgrade() { + let x = Arc::new(RwLock::new(0)); + let mut handles = Vec::new(); + for _ in 0..8 { + let x = x.clone(); + handles.push(thread::spawn(move || { + for _ in 0..100 { + let mut writer = x.write(); + *writer += 1; + let cur_val = *writer; + let reader = RwLockWriteGuard::downgrade(writer); + assert_eq!(cur_val, *reader); + } + })); + } + for handle in handles { + handle.join().unwrap() + } + assert_eq!(*x.read(), 800); + } + + #[test] + fn test_rwlock_recursive() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _lock1 = arc.read(); + thread::spawn(move || { + let _lock = arc2.write(); + }); + thread::sleep(Duration::from_millis(100)); + + // A normal read would block here since there is a pending writer + let _lock2 = arc.read_recursive(); + } + + #[test] + fn test_rwlock_debug() { + let x = RwLock::new(vec![0u8, 10]); + + assert_eq!(format!("{:?}", x), "RwLock { data: [0, 10] }"); + assert_eq!( + format!("{:#?}", x), + "RwLock { + data: [ + 0, + 10 + ] +}" + ); + let _lock = x.write(); + assert_eq!(format!("{:?}", x), "RwLock { }"); + } + + #[test] + fn test_clone() { + let rwlock = RwLock::new(Arc::new(1)); + let a = rwlock.read_recursive(); + let b = a.clone(); + assert_eq!(Arc::strong_count(&b), 2); + } +} diff --git a/third_party/cargo/vendor/parking_lot-0.7.1/src/util.rs b/third_party/cargo/vendor/parking_lot-0.7.1/src/util.rs new file mode 100644 index 0000000..c05a539 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot-0.7.1/src/util.rs @@ -0,0 +1,44 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::time::{Duration, Instant}; + +// Option::unchecked_unwrap +pub trait UncheckedOptionExt { + unsafe fn unchecked_unwrap(self) -> T; +} + +impl UncheckedOptionExt for Option { + #[inline] + unsafe fn unchecked_unwrap(self) -> T { + match self { + Some(x) => x, + None => unreachable(), + } + } +} + +// Equivalent to intrinsics::unreachable() in release mode +#[inline] +unsafe fn unreachable() -> ! { + if cfg!(debug_assertions) { + unreachable!(); + } else { + enum Void {} + match *(1 as *const Void) {} + } +} + +#[inline] +pub fn to_deadline(timeout: Duration) -> Option { + #[cfg(feature = "nightly")] + let deadline = Instant::now().checked_add(timeout); + #[cfg(not(feature = "nightly"))] + let deadline = Some(Instant::now() + timeout); + + deadline +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/.cargo-checksum.json b/third_party/cargo/vendor/parking_lot_core-0.3.1/.cargo-checksum.json new file mode 100644 index 0000000..6706d64 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"dc95a171db000a9243f985288bafad64342c5a669cfeb63a11776d0858e7c0a1","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","build.rs":"b4ca69501aa539f2d9a50a3188e93d69eb5ad0c38d5cd194df361a3f2f9a8b92","src/lib.rs":"9d5d80460481b44b8d9048b7319be33ac989250960c61b7c4528c0431f9ad36c","src/parking_lot.rs":"f7f597e768def124c78241a419ca2df965f0896b079e195a9d884d89cfbe9f17","src/spinwait.rs":"45a0f2a57177bc9759c0c2167f758ee220fba7cd8bdf1fbcd9c2b962fef9a1e5","src/thread_parker/generic.rs":"985966b1bdc763ada6d1fee800d19dd92611da4f84cfeef2d82763ffd2a499c3","src/thread_parker/linux.rs":"c41d08ab333972b67f20443f474ed25a1f171db0f87e227df4bdc504f6f9d897","src/thread_parker/unix.rs":"6364bcfeacfb3189bcebeddfccef1b9843d3c59d6d0f046827e62b33bcee30dd","src/thread_parker/windows/keyed_event.rs":"83d4bace5d2f17993071de28043e94f3b9673c887e01c72653b6fd24db260634","src/thread_parker/windows/mod.rs":"f31eed53f3e402477d80a70a7c6d474c01ba4c9ad952bbe562509448cd3cc1ad","src/thread_parker/windows/waitaddress.rs":"1a6eee8ab9131c746089e78b0aab900f23a5ed8ee6f2e789b8ec4d2232153ab8","src/util.rs":"2d07c0c010a857790ae2ed6a1215eeed8af76859e076797ea1ba8dec82169e84","src/word_lock.rs":"c4d50c0d37e6dd92fb078c80f84dc5b5c83bdf46baad34ed35af8730a345a2b5"},"package":"ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c"} \ No newline at end of file diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/BUILD b/third_party/cargo/vendor/parking_lot_core-0.3.1/BUILD new file mode 100644 index 0000000..75b4bdb --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/BUILD @@ -0,0 +1,46 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0,MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "parking_lot_core", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/rand-0.5.6:rand", + "//third_party/cargo/vendor/smallvec-0.6.13:smallvec", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.3.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/Cargo.toml b/third_party/cargo/vendor/parking_lot_core-0.3.1/Cargo.toml new file mode 100644 index 0000000..b84475a --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/Cargo.toml @@ -0,0 +1,49 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "parking_lot_core" +version = "0.3.1" +authors = ["Amanieu d'Antras "] +description = "An advanced API for creating custom synchronization primitives." +keywords = ["mutex", "condvar", "rwlock", "once", "thread"] +categories = ["concurrency"] +license = "Apache-2.0/MIT" +repository = "https://github.com/Amanieu/parking_lot" +[dependencies.backtrace] +version = "0.3.2" +optional = true + +[dependencies.petgraph] +version = "0.4.5" +optional = true + +[dependencies.rand] +version = "0.5" + +[dependencies.smallvec] +version = "0.6" + +[dependencies.thread-id] +version = "3.2.0" +optional = true +[build-dependencies.rustc_version] +version = "0.2" + +[features] +deadlock_detection = ["petgraph", "thread-id", "backtrace"] +nightly = [] +[target."cfg(unix)".dependencies.libc] +version = "0.2.27" +[target."cfg(windows)".dependencies.winapi] +version = "0.3" +features = ["winnt", "ntstatus", "minwindef", "winerror", "winbase", "errhandlingapi", "handleapi"] diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/LICENSE-APACHE b/third_party/cargo/vendor/parking_lot_core-0.3.1/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/LICENSE-MIT b/third_party/cargo/vendor/parking_lot_core-0.3.1/LICENSE-MIT new file mode 100644 index 0000000..40b8817 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/build.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/build.rs new file mode 100644 index 0000000..8d745ee --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/build.rs @@ -0,0 +1,8 @@ +extern crate rustc_version; +use rustc_version::{version, Version}; + +fn main() { + if version().unwrap() >= Version::parse("1.26.0").unwrap() { + println!("cargo:rustc-cfg=has_localkey_try_with"); + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/lib.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/lib.rs new file mode 100644 index 0000000..338b63e --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/lib.rs @@ -0,0 +1,84 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +//! This library exposes a low-level API for creating your own efficient +//! synchronization primitives. +//! +//! # The parking lot +//! +//! To keep synchronization primitives small, all thread queuing and suspending +//! functionality is offloaded to the *parking lot*. The idea behind this is based +//! on the Webkit [`WTF::ParkingLot`](https://webkit.org/blog/6161/locking-in-webkit/) +//! class, which essentially consists of a hash table mapping of lock addresses +//! to queues of parked (sleeping) threads. The Webkit parking lot was itself +//! inspired by Linux [futexes](http://man7.org/linux/man-pages/man2/futex.2.html), +//! but it is more powerful since it allows invoking callbacks while holding a +//! queue lock. +//! +//! There are two main operations that can be performed on the parking lot: +//! +//! - *Parking* refers to suspending the thread while simultaneously enqueuing it +//! on a queue keyed by some address. +//! - *Unparking* refers to dequeuing a thread from a queue keyed by some address +//! and resuming it. +//! +//! See the documentation of the individual functions for more details. +//! +//! # Building custom synchronization primitives +//! +//! Building custom synchronization primitives is very simple since the parking +//! lot takes care of all the hard parts for you. A simple example for a +//! custom primitive would be to integrate a `Mutex` inside another data type. +//! Since a mutex only requires 2 bits, it can share space with other data. +//! For example, one could create an `ArcMutex` type that combines the atomic +//! reference count and the two mutex bits in the same atomic word. + +#![warn(missing_docs)] +#![cfg_attr( + all(feature = "nightly", target_os = "linux"), + feature(integer_atomics) +)] + +extern crate rand; +extern crate smallvec; + +#[cfg(feature = "deadlock_detection")] +extern crate backtrace; +#[cfg(feature = "deadlock_detection")] +extern crate petgraph; +#[cfg(feature = "deadlock_detection")] +extern crate thread_id; + +#[cfg(unix)] +extern crate libc; + +#[cfg(windows)] +extern crate winapi; + +#[cfg(all(feature = "nightly", target_os = "linux"))] +#[path = "thread_parker/linux.rs"] +mod thread_parker; +#[cfg(all(unix, not(all(feature = "nightly", target_os = "linux"))))] +#[path = "thread_parker/unix.rs"] +mod thread_parker; +#[cfg(windows)] +#[path = "thread_parker/windows/mod.rs"] +mod thread_parker; +#[cfg(not(any(windows, unix)))] +#[path = "thread_parker/generic.rs"] +mod thread_parker; + +mod parking_lot; +mod spinwait; +mod util; +mod word_lock; + +pub use parking_lot::deadlock; +pub use parking_lot::{park, unpark_all, unpark_filter, unpark_one, unpark_requeue}; +pub use parking_lot::{FilterOp, ParkResult, ParkToken, RequeueOp, UnparkResult, UnparkToken}; +pub use parking_lot::{DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN}; +pub use spinwait::SpinWait; diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/parking_lot.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/parking_lot.rs new file mode 100644 index 0000000..2d525a7 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/parking_lot.rs @@ -0,0 +1,1391 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use rand::rngs::SmallRng; +use rand::{FromEntropy, Rng}; +use smallvec::SmallVec; +use std::cell::{Cell, UnsafeCell}; +use std::mem; +#[cfg(not(has_localkey_try_with))] +use std::panic; +use std::ptr; +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use std::thread::LocalKey; +use std::time::{Duration, Instant}; +use thread_parker::ThreadParker; +use util::UncheckedOptionExt; +use word_lock::WordLock; + +static NUM_THREADS: AtomicUsize = ATOMIC_USIZE_INIT; +static HASHTABLE: AtomicUsize = ATOMIC_USIZE_INIT; + +// Even with 3x more buckets than threads, the memory overhead per thread is +// still only a few hundred bytes per thread. +const LOAD_FACTOR: usize = 3; + +struct HashTable { + // Hash buckets for the table + entries: Box<[Bucket]>, + + // Number of bits used for the hash function + hash_bits: u32, + + // Previous table. This is only kept to keep leak detectors happy. + _prev: *const HashTable, +} + +impl HashTable { + fn new(num_threads: usize, prev: *const HashTable) -> Box { + let new_size = (num_threads * LOAD_FACTOR).next_power_of_two(); + let hash_bits = 0usize.leading_zeros() - new_size.leading_zeros() - 1; + let bucket = Bucket { + mutex: WordLock::new(), + queue_head: Cell::new(ptr::null()), + queue_tail: Cell::new(ptr::null()), + fair_timeout: UnsafeCell::new(FairTimeout::new()), + _padding: unsafe { mem::uninitialized() }, + }; + Box::new(HashTable { + entries: vec![bucket; new_size].into_boxed_slice(), + hash_bits: hash_bits, + _prev: prev, + }) + } +} + +struct Bucket { + // Lock protecting the queue + mutex: WordLock, + + // Linked list of threads waiting on this bucket + queue_head: Cell<*const ThreadData>, + queue_tail: Cell<*const ThreadData>, + + // Next time at which point be_fair should be set + fair_timeout: UnsafeCell, + + // Padding to avoid false sharing between buckets. Ideally we would just + // align the bucket structure to 64 bytes, but Rust doesn't support that + // yet. + _padding: [u8; 64], +} + +// Implementation of Clone for Bucket, needed to make vec![] work +impl Clone for Bucket { + fn clone(&self) -> Bucket { + Bucket { + mutex: WordLock::new(), + queue_head: Cell::new(ptr::null()), + queue_tail: Cell::new(ptr::null()), + fair_timeout: UnsafeCell::new(FairTimeout::new()), + _padding: unsafe { mem::uninitialized() }, + } + } +} + +struct FairTimeout { + // Next time at which point be_fair should be set + timeout: Instant, + + // Random number generator for calculating the next timeout + rng: SmallRng, +} + +impl FairTimeout { + fn new() -> FairTimeout { + FairTimeout { + timeout: Instant::now(), + rng: SmallRng::from_entropy(), + } + } + + // Determine whether we should force a fair unlock, and update the timeout + fn should_timeout(&mut self) -> bool { + let now = Instant::now(); + if now > self.timeout { + self.timeout = now + Duration::new(0, self.rng.gen_range(0, 1000000)); + true + } else { + false + } + } +} + +struct ThreadData { + parker: ThreadParker, + + // Key that this thread is sleeping on. This may change if the thread is + // requeued to a different key. + key: AtomicUsize, + + // Linked list of parked threads in a bucket + next_in_queue: Cell<*const ThreadData>, + + // UnparkToken passed to this thread when it is unparked + unpark_token: Cell, + + // ParkToken value set by the thread when it was parked + park_token: Cell, + + // Is the thread parked with a timeout? + parked_with_timeout: Cell, + + // Extra data for deadlock detection + // TODO: once supported in stable replace with #[cfg...] & remove dummy struct/impl + #[allow(dead_code)] + deadlock_data: deadlock::DeadlockData, +} + +impl ThreadData { + fn new() -> ThreadData { + // Keep track of the total number of live ThreadData objects and resize + // the hash table accordingly. + let num_threads = NUM_THREADS.fetch_add(1, Ordering::Relaxed) + 1; + unsafe { + grow_hashtable(num_threads); + } + + ThreadData { + parker: ThreadParker::new(), + key: AtomicUsize::new(0), + next_in_queue: Cell::new(ptr::null()), + unpark_token: Cell::new(DEFAULT_UNPARK_TOKEN), + park_token: Cell::new(DEFAULT_PARK_TOKEN), + parked_with_timeout: Cell::new(false), + deadlock_data: deadlock::DeadlockData::new(), + } + } +} + +// Returns a ThreadData structure for the current thread +unsafe fn get_thread_data(local: &mut Option) -> &ThreadData { + // Try to read from thread-local storage, but return None if the TLS has + // already been destroyed. + #[cfg(has_localkey_try_with)] + fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { + key.try_with(|x| x as *const ThreadData).ok() + } + #[cfg(not(has_localkey_try_with))] + fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { + panic::catch_unwind(|| key.with(|x| x as *const ThreadData)).ok() + } + + // Unlike word_lock::ThreadData, parking_lot::ThreadData is always expensive + // to construct. Try to use a thread-local version if possible. + thread_local!(static THREAD_DATA: ThreadData = ThreadData::new()); + if let Some(tls) = try_get_tls(&THREAD_DATA) { + return &*tls; + } + + // Otherwise just create a ThreadData on the stack + *local = Some(ThreadData::new()); + local.as_ref().unwrap() +} + +impl Drop for ThreadData { + fn drop(&mut self) { + NUM_THREADS.fetch_sub(1, Ordering::Relaxed); + } +} + +// Get a pointer to the latest hash table, creating one if it doesn't exist yet. +unsafe fn get_hashtable() -> *const HashTable { + let mut table = HASHTABLE.load(Ordering::Acquire); + + // If there is no table, create one + if table == 0 { + let new_table = Box::into_raw(HashTable::new(LOAD_FACTOR, ptr::null())); + + // If this fails then it means some other thread created the hash + // table first. + match HASHTABLE.compare_exchange( + 0, + new_table as usize, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return new_table, + Err(x) => table = x, + } + + // Free the table we created + Box::from_raw(new_table); + } + + table as *const HashTable +} + +// Grow the hash table so that it is big enough for the given number of threads. +// This isn't performance-critical since it is only done when a ThreadData is +// created, which only happens once per thread. +unsafe fn grow_hashtable(num_threads: usize) { + // If there is no table, create one + if HASHTABLE.load(Ordering::Relaxed) == 0 { + let new_table = Box::into_raw(HashTable::new(num_threads, ptr::null())); + + // If this fails then it means some other thread created the hash + // table first. + if HASHTABLE + .compare_exchange(0, new_table as usize, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + + // Free the table we created + Box::from_raw(new_table); + } + + let mut old_table; + loop { + old_table = HASHTABLE.load(Ordering::Acquire) as *mut HashTable; + + // Check if we need to resize the existing table + if (*old_table).entries.len() >= LOAD_FACTOR * num_threads { + return; + } + + // Lock all buckets in the old table + for b in &(*old_table).entries[..] { + b.mutex.lock(); + } + + // Now check if our table is still the latest one. Another thread could + // have grown the hash table between us reading HASHTABLE and locking + // the buckets. + if HASHTABLE.load(Ordering::Relaxed) == old_table as usize { + break; + } + + // Unlock buckets and try again + for b in &(*old_table).entries[..] { + b.mutex.unlock(); + } + } + + // Create the new table + let new_table = HashTable::new(num_threads, old_table); + + // Move the entries from the old table to the new one + for b in &(*old_table).entries[..] { + let mut current = b.queue_head.get(); + while !current.is_null() { + let next = (*current).next_in_queue.get(); + let hash = hash((*current).key.load(Ordering::Relaxed), new_table.hash_bits); + if new_table.entries[hash].queue_tail.get().is_null() { + new_table.entries[hash].queue_head.set(current); + } else { + (*new_table.entries[hash].queue_tail.get()) + .next_in_queue + .set(current); + } + new_table.entries[hash].queue_tail.set(current); + (*current).next_in_queue.set(ptr::null()); + current = next; + } + } + + // Publish the new table. No races are possible at this point because + // any other thread trying to grow the hash table is blocked on the bucket + // locks in the old table. + HASHTABLE.store(Box::into_raw(new_table) as usize, Ordering::Release); + + // Unlock all buckets in the old table + for b in &(*old_table).entries[..] { + b.mutex.unlock(); + } +} + +// Hash function for addresses +#[cfg(target_pointer_width = "32")] +fn hash(key: usize, bits: u32) -> usize { + key.wrapping_mul(0x9E3779B9) >> (32 - bits) +} +#[cfg(target_pointer_width = "64")] +fn hash(key: usize, bits: u32) -> usize { + key.wrapping_mul(0x9E3779B97F4A7C15) >> (64 - bits) +} + +// Lock the bucket for the given key +unsafe fn lock_bucket<'a>(key: usize) -> &'a Bucket { + let mut bucket; + loop { + let hashtable = get_hashtable(); + + let hash = hash(key, (*hashtable).hash_bits); + bucket = &(*hashtable).entries[hash]; + + // Lock the bucket + bucket.mutex.lock(); + + // If no other thread has rehashed the table before we grabbed the lock + // then we are good to go! The lock we grabbed prevents any rehashes. + if HASHTABLE.load(Ordering::Relaxed) == hashtable as usize { + return bucket; + } + + // Unlock the bucket and try again + bucket.mutex.unlock(); + } +} + +// Lock the bucket for the given key, but check that the key hasn't been changed +// in the meantime due to a requeue. +unsafe fn lock_bucket_checked<'a>(key: &AtomicUsize) -> (usize, &'a Bucket) { + let mut bucket; + loop { + let hashtable = get_hashtable(); + let current_key = key.load(Ordering::Relaxed); + + let hash = hash(current_key, (*hashtable).hash_bits); + bucket = &(*hashtable).entries[hash]; + + // Lock the bucket + bucket.mutex.lock(); + + // Check that both the hash table and key are correct while the bucket + // is locked. Note that the key can't change once we locked the proper + // bucket for it, so we just keep trying until we have the correct key. + if HASHTABLE.load(Ordering::Relaxed) == hashtable as usize + && key.load(Ordering::Relaxed) == current_key + { + return (current_key, bucket); + } + + // Unlock the bucket and try again + bucket.mutex.unlock(); + } +} + +// Lock the two buckets for the given pair of keys +unsafe fn lock_bucket_pair<'a>(key1: usize, key2: usize) -> (&'a Bucket, &'a Bucket) { + let mut bucket1; + loop { + let hashtable = get_hashtable(); + + // Get the lowest bucket first + let hash1 = hash(key1, (*hashtable).hash_bits); + let hash2 = hash(key2, (*hashtable).hash_bits); + if hash1 <= hash2 { + bucket1 = &(*hashtable).entries[hash1]; + } else { + bucket1 = &(*hashtable).entries[hash2]; + } + + // Lock the first bucket + bucket1.mutex.lock(); + + // If no other thread has rehashed the table before we grabbed the lock + // then we are good to go! The lock we grabbed prevents any rehashes. + if HASHTABLE.load(Ordering::Relaxed) == hashtable as usize { + // Now lock the second bucket and return the two buckets + if hash1 == hash2 { + return (bucket1, bucket1); + } else if hash1 < hash2 { + let bucket2 = &(*hashtable).entries[hash2]; + bucket2.mutex.lock(); + return (bucket1, bucket2); + } else { + let bucket2 = &(*hashtable).entries[hash1]; + bucket2.mutex.lock(); + return (bucket2, bucket1); + } + } + + // Unlock the bucket and try again + bucket1.mutex.unlock(); + } +} + +// Unlock a pair of buckets +unsafe fn unlock_bucket_pair(bucket1: &Bucket, bucket2: &Bucket) { + if bucket1 as *const _ == bucket2 as *const _ { + bucket1.mutex.unlock(); + } else if bucket1 as *const _ < bucket2 as *const _ { + bucket2.mutex.unlock(); + bucket1.mutex.unlock(); + } else { + bucket1.mutex.unlock(); + bucket2.mutex.unlock(); + } +} + +/// Result of a park operation. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub enum ParkResult { + /// We were unparked by another thread with the given token. + Unparked(UnparkToken), + + /// The validation callback returned false. + Invalid, + + /// The timeout expired. + TimedOut, +} + +impl ParkResult { + /// Returns true if we were unparked by another thread. + pub fn is_unparked(self) -> bool { + if let ParkResult::Unparked(_) = self { + true + } else { + false + } + } +} + +/// Result of an unpark operation. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub struct UnparkResult { + /// The number of threads that were unparked. + pub unparked_threads: usize, + + /// Whether there are any threads remaining in the queue. This only returns + /// true if a thread was unparked. + pub have_more_threads: bool, + + /// This is set to true on average once every 0.5ms for any given key. It + /// should be used to switch to a fair unlocking mechanism for a particular + /// unlock. + pub be_fair: bool, +} + +/// Operation that `unpark_requeue` should perform. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub enum RequeueOp { + /// Abort the operation without doing anything. + Abort, + + /// Unpark one thread and requeue the rest onto the target queue. + UnparkOneRequeueRest, + + /// Requeue all threads onto the target queue. + RequeueAll, +} + +/// Operation that `unpark_filter` should perform for each thread. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub enum FilterOp { + /// Unpark the thread and continue scanning the list of parked threads. + Unpark, + + /// Don't unpark the thread and continue scanning the list of parked threads. + Skip, + + /// Don't unpark the thread and stop scanning the list of parked threads. + Stop, +} + +/// A value which is passed from an unparker to a parked thread. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub struct UnparkToken(pub usize); + +/// A value associated with a parked thread which can be used by `unpark_filter`. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub struct ParkToken(pub usize); + +/// A default unpark token to use. +pub const DEFAULT_UNPARK_TOKEN: UnparkToken = UnparkToken(0); + +/// A default park token to use. +pub const DEFAULT_PARK_TOKEN: ParkToken = ParkToken(0); + +/// Parks the current thread in the queue associated with the given key. +/// +/// The `validate` function is called while the queue is locked and can abort +/// the operation by returning false. If `validate` returns true then the +/// current thread is appended to the queue and the queue is unlocked. +/// +/// The `before_sleep` function is called after the queue is unlocked but before +/// the thread is put to sleep. The thread will then sleep until it is unparked +/// or the given timeout is reached. +/// +/// The `timed_out` function is also called while the queue is locked, but only +/// if the timeout was reached. It is passed the key of the queue it was in when +/// it timed out, which may be different from the original key if +/// `unpark_requeue` was called. It is also passed a bool which indicates +/// whether it was the last thread in the queue. +/// +/// # Safety +/// +/// You should only call this function with an address that you control, since +/// you could otherwise interfere with the operation of other synchronization +/// primitives. +/// +/// The `validate` and `timed_out` functions are called while the queue is +/// locked and must not panic or call into any function in `parking_lot`. +/// +/// The `before_sleep` function is called outside the queue lock and is allowed +/// to call `unpark_one`, `unpark_all`, `unpark_requeue` or `unpark_filter`, but +/// it is not allowed to call `park` or panic. +#[inline] +pub unsafe fn park( + key: usize, + validate: V, + before_sleep: B, + timed_out: T, + park_token: ParkToken, + timeout: Option, +) -> ParkResult +where + V: FnOnce() -> bool, + B: FnOnce(), + T: FnOnce(usize, bool), +{ + let mut v = Some(validate); + let mut b = Some(before_sleep); + let mut t = Some(timed_out); + park_internal( + key, + &mut || v.take().unchecked_unwrap()(), + &mut || b.take().unchecked_unwrap()(), + &mut |key, was_last_thread| t.take().unchecked_unwrap()(key, was_last_thread), + park_token, + timeout, + ) +} + +// Non-generic version to reduce monomorphization cost +unsafe fn park_internal( + key: usize, + validate: &mut FnMut() -> bool, + before_sleep: &mut FnMut(), + timed_out: &mut FnMut(usize, bool), + park_token: ParkToken, + timeout: Option, +) -> ParkResult { + // Grab our thread data, this also ensures that the hash table exists + let mut thread_data = None; + let thread_data = get_thread_data(&mut thread_data); + + // Lock the bucket for the given key + let bucket = lock_bucket(key); + + // If the validation function fails, just return + if !validate() { + bucket.mutex.unlock(); + return ParkResult::Invalid; + } + + // Append our thread data to the queue and unlock the bucket + thread_data.parked_with_timeout.set(timeout.is_some()); + thread_data.next_in_queue.set(ptr::null()); + thread_data.key.store(key, Ordering::Relaxed); + thread_data.park_token.set(park_token); + thread_data.parker.prepare_park(); + if !bucket.queue_head.get().is_null() { + (*bucket.queue_tail.get()).next_in_queue.set(thread_data); + } else { + bucket.queue_head.set(thread_data); + } + bucket.queue_tail.set(thread_data); + bucket.mutex.unlock(); + + // Invoke the pre-sleep callback + before_sleep(); + + // Park our thread and determine whether we were woken up by an unpark or by + // our timeout. Note that this isn't precise: we can still be unparked since + // we are still in the queue. + let unparked = match timeout { + Some(timeout) => thread_data.parker.park_until(timeout), + None => { + thread_data.parker.park(); + // call deadlock detection on_unpark hook + deadlock::on_unpark(thread_data); + true + } + }; + + // If we were unparked, return now + if unparked { + return ParkResult::Unparked(thread_data.unpark_token.get()); + } + + // Lock our bucket again. Note that the hashtable may have been rehashed in + // the meantime. Our key may also have changed if we were requeued. + let (key, bucket) = lock_bucket_checked(&thread_data.key); + + // Now we need to check again if we were unparked or timed out. Unlike the + // last check this is precise because we hold the bucket lock. + if !thread_data.parker.timed_out() { + bucket.mutex.unlock(); + return ParkResult::Unparked(thread_data.unpark_token.get()); + } + + // We timed out, so we now need to remove our thread from the queue + let mut link = &bucket.queue_head; + let mut current = bucket.queue_head.get(); + let mut previous = ptr::null(); + while !current.is_null() { + if current == thread_data { + let next = (*current).next_in_queue.get(); + link.set(next); + let mut was_last_thread = true; + if bucket.queue_tail.get() == current { + bucket.queue_tail.set(previous); + } else { + // Scan the rest of the queue to see if there are any other + // entries with the given key. + let mut scan = next; + while !scan.is_null() { + if (*scan).key.load(Ordering::Relaxed) == key { + was_last_thread = false; + break; + } + scan = (*scan).next_in_queue.get(); + } + } + + // Callback to indicate that we timed out, and whether we were the + // last thread on the queue. + timed_out(key, was_last_thread); + break; + } else { + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + } + + // There should be no way for our thread to have been removed from the queue + // if we timed out. + debug_assert!(!current.is_null()); + + // Unlock the bucket, we are done + bucket.mutex.unlock(); + ParkResult::TimedOut +} + +/// Unparks one thread from the queue associated with the given key. +/// +/// The `callback` function is called while the queue is locked and before the +/// target thread is woken up. The `UnparkResult` argument to the function +/// indicates whether a thread was found in the queue and whether this was the +/// last thread in the queue. This value is also returned by `unpark_one`. +/// +/// The `callback` function should return an `UnparkToken` value which will be +/// passed to the thread that is unparked. If no thread is unparked then the +/// returned value is ignored. +/// +/// # Safety +/// +/// You should only call this function with an address that you control, since +/// you could otherwise interfere with the operation of other synchronization +/// primitives. +/// +/// The `callback` function is called while the queue is locked and must not +/// panic or call into any function in `parking_lot`. +#[inline] +pub unsafe fn unpark_one(key: usize, callback: C) -> UnparkResult +where + C: FnOnce(UnparkResult) -> UnparkToken, +{ + let mut c = Some(callback); + unpark_one_internal(key, &mut |result| c.take().unchecked_unwrap()(result)) +} + +// Non-generic version to reduce monomorphization cost +unsafe fn unpark_one_internal( + key: usize, + callback: &mut FnMut(UnparkResult) -> UnparkToken, +) -> UnparkResult { + // Lock the bucket for the given key + let bucket = lock_bucket(key); + + // Find a thread with a matching key and remove it from the queue + let mut link = &bucket.queue_head; + let mut current = bucket.queue_head.get(); + let mut previous = ptr::null(); + let mut result = UnparkResult { + unparked_threads: 0, + have_more_threads: false, + be_fair: false, + }; + while !current.is_null() { + if (*current).key.load(Ordering::Relaxed) == key { + // Remove the thread from the queue + let next = (*current).next_in_queue.get(); + link.set(next); + if bucket.queue_tail.get() == current { + bucket.queue_tail.set(previous); + } else { + // Scan the rest of the queue to see if there are any other + // entries with the given key. + let mut scan = next; + while !scan.is_null() { + if (*scan).key.load(Ordering::Relaxed) == key { + result.have_more_threads = true; + break; + } + scan = (*scan).next_in_queue.get(); + } + } + + // Invoke the callback before waking up the thread + result.unparked_threads = 1; + result.be_fair = (*bucket.fair_timeout.get()).should_timeout(); + let token = callback(result); + + // Set the token for the target thread + (*current).unpark_token.set(token); + + // This is a bit tricky: we first lock the ThreadParker to prevent + // the thread from exiting and freeing its ThreadData if its wait + // times out. Then we unlock the queue since we don't want to keep + // the queue locked while we perform a system call. Finally we wake + // up the parked thread. + let handle = (*current).parker.unpark_lock(); + bucket.mutex.unlock(); + handle.unpark(); + + return result; + } else { + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + } + + // No threads with a matching key were found in the bucket + callback(result); + bucket.mutex.unlock(); + result +} + +/// Unparks all threads in the queue associated with the given key. +/// +/// The given `UnparkToken` is passed to all unparked threads. +/// +/// This function returns the number of threads that were unparked. +/// +/// # Safety +/// +/// You should only call this function with an address that you control, since +/// you could otherwise interfere with the operation of other synchronization +/// primitives. +pub unsafe fn unpark_all(key: usize, unpark_token: UnparkToken) -> usize { + // Lock the bucket for the given key + let bucket = lock_bucket(key); + + // Remove all threads with the given key in the bucket + let mut link = &bucket.queue_head; + let mut current = bucket.queue_head.get(); + let mut previous = ptr::null(); + let mut threads = SmallVec::<[_; 8]>::new(); + while !current.is_null() { + if (*current).key.load(Ordering::Relaxed) == key { + // Remove the thread from the queue + let next = (*current).next_in_queue.get(); + link.set(next); + if bucket.queue_tail.get() == current { + bucket.queue_tail.set(previous); + } + + // Set the token for the target thread + (*current).unpark_token.set(unpark_token); + + // Don't wake up threads while holding the queue lock. See comment + // in unpark_one. For now just record which threads we need to wake + // up. + threads.push((*current).parker.unpark_lock()); + current = next; + } else { + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + } + + // Unlock the bucket + bucket.mutex.unlock(); + + // Now that we are outside the lock, wake up all the threads that we removed + // from the queue. + let num_threads = threads.len(); + for handle in threads.into_iter() { + handle.unpark(); + } + + num_threads +} + +/// Removes all threads from the queue associated with `key_from`, optionally +/// unparks the first one and requeues the rest onto the queue associated with +/// `key_to`. +/// +/// The `validate` function is called while both queues are locked and can abort +/// the operation by returning `RequeueOp::Abort`. It can also choose to +/// unpark the first thread in the source queue while moving the rest by +/// returning `RequeueOp::UnparkFirstRequeueRest`. Returning +/// `RequeueOp::RequeueAll` will move all threads to the destination queue. +/// +/// The `callback` function is also called while both queues are locked. It is +/// passed the `RequeueOp` returned by `validate` and an `UnparkResult` +/// indicating whether a thread was unparked and whether there are threads still +/// parked in the new queue. This `UnparkResult` value is also returned by +/// `unpark_requeue`. +/// +/// The `callback` function should return an `UnparkToken` value which will be +/// passed to the thread that is unparked. If no thread is unparked then the +/// returned value is ignored. +/// +/// # Safety +/// +/// You should only call this function with an address that you control, since +/// you could otherwise interfere with the operation of other synchronization +/// primitives. +/// +/// The `validate` and `callback` functions are called while the queue is locked +/// and must not panic or call into any function in `parking_lot`. +#[inline] +pub unsafe fn unpark_requeue( + key_from: usize, + key_to: usize, + validate: V, + callback: C, +) -> UnparkResult +where + V: FnOnce() -> RequeueOp, + C: FnOnce(RequeueOp, UnparkResult) -> UnparkToken, +{ + let mut v = Some(validate); + let mut c = Some(callback); + unpark_requeue_internal( + key_from, + key_to, + &mut || v.take().unchecked_unwrap()(), + &mut |op, r| c.take().unchecked_unwrap()(op, r), + ) +} + +// Non-generic version to reduce monomorphization cost +unsafe fn unpark_requeue_internal( + key_from: usize, + key_to: usize, + validate: &mut FnMut() -> RequeueOp, + callback: &mut FnMut(RequeueOp, UnparkResult) -> UnparkToken, +) -> UnparkResult { + // Lock the two buckets for the given key + let (bucket_from, bucket_to) = lock_bucket_pair(key_from, key_to); + + // If the validation function fails, just return + let mut result = UnparkResult { + unparked_threads: 0, + have_more_threads: false, + be_fair: false, + }; + let op = validate(); + if op == RequeueOp::Abort { + unlock_bucket_pair(bucket_from, bucket_to); + return result; + } + + // Remove all threads with the given key in the source bucket + let mut link = &bucket_from.queue_head; + let mut current = bucket_from.queue_head.get(); + let mut previous = ptr::null(); + let mut requeue_threads: *const ThreadData = ptr::null(); + let mut requeue_threads_tail: *const ThreadData = ptr::null(); + let mut wakeup_thread = None; + while !current.is_null() { + if (*current).key.load(Ordering::Relaxed) == key_from { + // Remove the thread from the queue + let next = (*current).next_in_queue.get(); + link.set(next); + if bucket_from.queue_tail.get() == current { + bucket_from.queue_tail.set(previous); + } + + // Prepare the first thread for wakeup and requeue the rest. + if op == RequeueOp::UnparkOneRequeueRest && wakeup_thread.is_none() { + wakeup_thread = Some(current); + result.unparked_threads = 1; + } else { + if !requeue_threads.is_null() { + (*requeue_threads_tail).next_in_queue.set(current); + } else { + requeue_threads = current; + } + requeue_threads_tail = current; + (*current).key.store(key_to, Ordering::Relaxed); + result.have_more_threads = true; + } + current = next; + } else { + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + } + + // Add the requeued threads to the destination bucket + if !requeue_threads.is_null() { + (*requeue_threads_tail).next_in_queue.set(ptr::null()); + if !bucket_to.queue_head.get().is_null() { + (*bucket_to.queue_tail.get()) + .next_in_queue + .set(requeue_threads); + } else { + bucket_to.queue_head.set(requeue_threads); + } + bucket_to.queue_tail.set(requeue_threads_tail); + } + + // Invoke the callback before waking up the thread + if result.unparked_threads != 0 { + result.be_fair = (*bucket_from.fair_timeout.get()).should_timeout(); + } + let token = callback(op, result); + + // See comment in unpark_one for why we mess with the locking + if let Some(wakeup_thread) = wakeup_thread { + (*wakeup_thread).unpark_token.set(token); + let handle = (*wakeup_thread).parker.unpark_lock(); + unlock_bucket_pair(bucket_from, bucket_to); + handle.unpark(); + } else { + unlock_bucket_pair(bucket_from, bucket_to); + } + + result +} + +/// Unparks a number of threads from the front of the queue associated with +/// `key` depending on the results of a filter function which inspects the +/// `ParkToken` associated with each thread. +/// +/// The `filter` function is called for each thread in the queue or until +/// `FilterOp::Stop` is returned. This function is passed the `ParkToken` +/// associated with a particular thread, which is unparked if `FilterOp::Unpark` +/// is returned. +/// +/// The `callback` function is also called while both queues are locked. It is +/// passed an `UnparkResult` indicating the number of threads that were unparked +/// and whether there are still parked threads in the queue. This `UnparkResult` +/// value is also returned by `unpark_filter`. +/// +/// The `callback` function should return an `UnparkToken` value which will be +/// passed to all threads that are unparked. If no thread is unparked then the +/// returned value is ignored. +/// +/// # Safety +/// +/// You should only call this function with an address that you control, since +/// you could otherwise interfere with the operation of other synchronization +/// primitives. +/// +/// The `filter` and `callback` functions are called while the queue is locked +/// and must not panic or call into any function in `parking_lot`. +#[inline] +pub unsafe fn unpark_filter(key: usize, mut filter: F, callback: C) -> UnparkResult +where + F: FnMut(ParkToken) -> FilterOp, + C: FnOnce(UnparkResult) -> UnparkToken, +{ + let mut c = Some(callback); + unpark_filter_internal(key, &mut filter, &mut |r| c.take().unchecked_unwrap()(r)) +} + +// Non-generic version to reduce monomorphization cost +unsafe fn unpark_filter_internal( + key: usize, + filter: &mut FnMut(ParkToken) -> FilterOp, + callback: &mut FnMut(UnparkResult) -> UnparkToken, +) -> UnparkResult { + // Lock the bucket for the given key + let bucket = lock_bucket(key); + + // Go through the queue looking for threads with a matching key + let mut link = &bucket.queue_head; + let mut current = bucket.queue_head.get(); + let mut previous = ptr::null(); + let mut threads = SmallVec::<[_; 8]>::new(); + let mut result = UnparkResult { + unparked_threads: 0, + have_more_threads: false, + be_fair: false, + }; + while !current.is_null() { + if (*current).key.load(Ordering::Relaxed) == key { + // Call the filter function with the thread's ParkToken + let next = (*current).next_in_queue.get(); + match filter((*current).park_token.get()) { + FilterOp::Unpark => { + // Remove the thread from the queue + link.set(next); + if bucket.queue_tail.get() == current { + bucket.queue_tail.set(previous); + } + + // Add the thread to our list of threads to unpark + threads.push((current, None)); + + current = next; + } + FilterOp::Skip => { + result.have_more_threads = true; + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + FilterOp::Stop => { + result.have_more_threads = true; + break; + } + } + } else { + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + } + + // Invoke the callback before waking up the threads + result.unparked_threads = threads.len(); + if result.unparked_threads != 0 { + result.be_fair = (*bucket.fair_timeout.get()).should_timeout(); + } + let token = callback(result); + + // Pass the token to all threads that are going to be unparked and prepare + // them for unparking. + for t in threads.iter_mut() { + (*t.0).unpark_token.set(token); + t.1 = Some((*t.0).parker.unpark_lock()); + } + + bucket.mutex.unlock(); + + // Now that we are outside the lock, wake up all the threads that we removed + // from the queue. + for (_, handle) in threads.into_iter() { + handle.unchecked_unwrap().unpark(); + } + + result +} + +/// \[Experimental\] Deadlock detection +/// +/// Enabled via the `deadlock_detection` feature flag. +pub mod deadlock { + #[cfg(feature = "deadlock_detection")] + use super::deadlock_impl; + + #[cfg(feature = "deadlock_detection")] + pub(super) use super::deadlock_impl::DeadlockData; + + #[cfg(not(feature = "deadlock_detection"))] + pub(super) struct DeadlockData {} + + #[cfg(not(feature = "deadlock_detection"))] + impl DeadlockData { + pub(super) fn new() -> Self { + DeadlockData {} + } + } + + /// Acquire a resource identified by key in the deadlock detector + /// Noop if deadlock_detection feature isn't enabled. + /// Note: Call after the resource is acquired + #[inline] + pub unsafe fn acquire_resource(_key: usize) { + #[cfg(feature = "deadlock_detection")] + deadlock_impl::acquire_resource(_key); + } + + /// Release a resource identified by key in the deadlock detector. + /// Noop if deadlock_detection feature isn't enabled. + /// Note: Call before the resource is released + /// # Panics + /// Panics if the resource was already released or wasn't acquired in this thread. + #[inline] + pub unsafe fn release_resource(_key: usize) { + #[cfg(feature = "deadlock_detection")] + deadlock_impl::release_resource(_key); + } + + /// Returns all deadlocks detected *since* the last call. + /// Each cycle consist of a vector of `DeadlockedThread`. + #[cfg(feature = "deadlock_detection")] + #[inline] + pub fn check_deadlock() -> Vec> { + deadlock_impl::check_deadlock() + } + + #[inline] + pub(super) unsafe fn on_unpark(_td: &super::ThreadData) { + #[cfg(feature = "deadlock_detection")] + deadlock_impl::on_unpark(_td); + } +} + +#[cfg(feature = "deadlock_detection")] +mod deadlock_impl { + use super::{get_hashtable, get_thread_data, lock_bucket, ThreadData, NUM_THREADS}; + use backtrace::Backtrace; + use petgraph; + use petgraph::graphmap::DiGraphMap; + use std::cell::{Cell, UnsafeCell}; + use std::collections::HashSet; + use std::sync::atomic::Ordering; + use std::sync::mpsc; + use thread_id; + + /// Representation of a deadlocked thread + pub struct DeadlockedThread { + thread_id: usize, + backtrace: Backtrace, + } + + impl DeadlockedThread { + /// The system thread id + pub fn thread_id(&self) -> usize { + self.thread_id + } + + /// The thread backtrace + pub fn backtrace(&self) -> &Backtrace { + &self.backtrace + } + } + + pub struct DeadlockData { + // Currently owned resources (keys) + resources: UnsafeCell>, + + // Set when there's a pending callstack request + deadlocked: Cell, + + // Sender used to report the backtrace + backtrace_sender: UnsafeCell>>, + + // System thread id + thread_id: usize, + } + + impl DeadlockData { + pub fn new() -> Self { + DeadlockData { + resources: UnsafeCell::new(Vec::new()), + deadlocked: Cell::new(false), + backtrace_sender: UnsafeCell::new(None), + thread_id: thread_id::get(), + } + } + } + + pub(super) unsafe fn on_unpark(td: &ThreadData) { + if td.deadlock_data.deadlocked.get() { + let sender = (*td.deadlock_data.backtrace_sender.get()).take().unwrap(); + sender + .send(DeadlockedThread { + thread_id: td.deadlock_data.thread_id, + backtrace: Backtrace::new(), + }).unwrap(); + // make sure to close this sender + drop(sender); + + // park until the end of the time + td.parker.prepare_park(); + td.parker.park(); + unreachable!("unparked deadlocked thread!"); + } + } + + pub unsafe fn acquire_resource(key: usize) { + let mut thread_data = None; + let thread_data = get_thread_data(&mut thread_data); + (*thread_data.deadlock_data.resources.get()).push(key); + } + + pub unsafe fn release_resource(key: usize) { + let mut thread_data = None; + let thread_data = get_thread_data(&mut thread_data); + let resources = &mut (*thread_data.deadlock_data.resources.get()); + match resources.iter().rposition(|x| *x == key) { + Some(p) => resources.swap_remove(p), + None => panic!("key {} not found in thread resources", key), + }; + } + + pub fn check_deadlock() -> Vec> { + unsafe { + // fast pass + if check_wait_graph_fast() { + // double check + check_wait_graph_slow() + } else { + Vec::new() + } + } + } + + // Simple algorithm that builds a wait graph f the threads and the resources, + // then checks for the presence of cycles (deadlocks). + // This variant isn't precise as it doesn't lock the entire table before checking + unsafe fn check_wait_graph_fast() -> bool { + let table = get_hashtable(); + let thread_count = NUM_THREADS.load(Ordering::Relaxed); + let mut graph = DiGraphMap::::with_capacity(thread_count * 2, thread_count * 2); + + for b in &(*table).entries[..] { + b.mutex.lock(); + let mut current = b.queue_head.get(); + while !current.is_null() { + if !(*current).parked_with_timeout.get() + && !(*current).deadlock_data.deadlocked.get() + { + // .resources are waiting for their owner + for &resource in &(*(*current).deadlock_data.resources.get()) { + graph.add_edge(resource, current as usize, ()); + } + // owner waits for resource .key + graph.add_edge(current as usize, (*current).key.load(Ordering::Relaxed), ()); + } + current = (*current).next_in_queue.get(); + } + b.mutex.unlock(); + } + + petgraph::algo::is_cyclic_directed(&graph) + } + + #[derive(Hash, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)] + enum WaitGraphNode { + Thread(*const ThreadData), + Resource(usize), + } + + use self::WaitGraphNode::*; + + // Contrary to the _fast variant this locks the entrie table before looking for cycles. + // Returns all detected thread wait cycles. + // Note that once a cycle is reported it's never reported again. + unsafe fn check_wait_graph_slow() -> Vec> { + let mut table = get_hashtable(); + loop { + // Lock all buckets in the old table + for b in &(*table).entries[..] { + b.mutex.lock(); + } + + // Now check if our table is still the latest one. Another thread could + // have grown the hash table between us getting and locking the hash table. + let new_table = get_hashtable(); + if new_table == table { + break; + } + + // Unlock buckets and try again + for b in &(*table).entries[..] { + b.mutex.unlock(); + } + + table = new_table; + } + + let thread_count = NUM_THREADS.load(Ordering::Relaxed); + let mut graph = + DiGraphMap::::with_capacity(thread_count * 2, thread_count * 2); + + for b in &(*table).entries[..] { + let mut current = b.queue_head.get(); + while !current.is_null() { + if !(*current).parked_with_timeout.get() + && !(*current).deadlock_data.deadlocked.get() + { + // .resources are waiting for their owner + for &resource in &(*(*current).deadlock_data.resources.get()) { + graph.add_edge(Resource(resource), Thread(current), ()); + } + // owner waits for resource .key + graph.add_edge( + Thread(current), + Resource((*current).key.load(Ordering::Relaxed)), + (), + ); + } + current = (*current).next_in_queue.get(); + } + } + + for b in &(*table).entries[..] { + b.mutex.unlock(); + } + + // find cycles + let cycles = graph_cycles(&graph); + + let mut results = Vec::with_capacity(cycles.len()); + + for cycle in cycles { + let (sender, receiver) = mpsc::channel(); + for td in cycle { + let bucket = lock_bucket((*td).key.load(Ordering::Relaxed)); + (*td).deadlock_data.deadlocked.set(true); + *(*td).deadlock_data.backtrace_sender.get() = Some(sender.clone()); + let handle = (*td).parker.unpark_lock(); + bucket.mutex.unlock(); + // unpark the deadlocked thread! + // on unpark it'll notice the deadlocked flag and report back + handle.unpark(); + } + // make sure to drop our sender before collecting results + drop(sender); + results.push(receiver.iter().collect()); + } + + results + } + + // normalize a cycle to start with the "smallest" node + fn normalize_cycle(input: &[T]) -> Vec { + let min_pos = input + .iter() + .enumerate() + .min_by_key(|&(_, &t)| t) + .map(|(p, _)| p) + .unwrap_or(0); + input + .iter() + .cycle() + .skip(min_pos) + .take(input.len()) + .cloned() + .collect() + } + + // returns all thread cycles in the wait graph + fn graph_cycles(g: &DiGraphMap) -> Vec> { + use petgraph::visit::depth_first_search; + use petgraph::visit::DfsEvent; + use petgraph::visit::NodeIndexable; + + let mut cycles = HashSet::new(); + let mut path = Vec::with_capacity(g.node_bound()); + // start from threads to get the correct threads cycle + let threads = g + .nodes() + .filter(|n| if let &Thread(_) = n { true } else { false }); + + depth_first_search(g, threads, |e| match e { + DfsEvent::Discover(Thread(n), _) => path.push(n), + DfsEvent::Finish(Thread(_), _) => { + path.pop(); + } + DfsEvent::BackEdge(_, Thread(n)) => { + let from = path.iter().rposition(|&i| i == n).unwrap(); + cycles.insert(normalize_cycle(&path[from..])); + } + _ => (), + }); + + cycles.iter().cloned().collect() + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/spinwait.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/spinwait.rs new file mode 100644 index 0000000..4185026 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/spinwait.rs @@ -0,0 +1,125 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +#[cfg(unix)] +use libc; +use std::sync::atomic::spin_loop_hint; +#[cfg(not(any(windows, unix)))] +use std::thread; +#[cfg(windows)] +use winapi; + +// Yields the rest of the current timeslice to the OS +#[cfg(windows)] +#[inline] +fn thread_yield() { + // Note that this is manually defined here rather than using the definition + // through `winapi`. The `winapi` definition comes from the `synchapi` + // header which enables the "synchronization.lib" library. It turns out, + // however that `Sleep` comes from `kernel32.dll` so this activation isn't + // necessary. + // + // This was originally identified in rust-lang/rust where on MinGW the + // libsynchronization.a library pulls in a dependency on a newer DLL not + // present in older versions of Windows. (see rust-lang/rust#49438) + // + // This is a bit of a hack for now and ideally we'd fix MinGW's own import + // libraries, but that'll probably take a lot longer than patching this here + // and avoiding the `synchapi` feature entirely. + extern "system" { + fn Sleep(a: winapi::shared::minwindef::DWORD); + } + unsafe { + // We don't use SwitchToThread here because it doesn't consider all + // threads in the system and the thread we are waiting for may not get + // selected. + Sleep(0); + } +} +#[cfg(unix)] +#[inline] +fn thread_yield() { + unsafe { + libc::sched_yield(); + } +} +#[cfg(not(any(windows, unix)))] +#[inline] +fn thread_yield() { + thread::yield_now(); +} + +// Wastes some CPU time for the given number of iterations, +// using a hint to indicate to the CPU that we are spinning. +#[inline] +fn cpu_relax(iterations: u32) { + for _ in 0..iterations { + spin_loop_hint() + } +} + +/// A counter used to perform exponential backoff in spin loops. +pub struct SpinWait { + counter: u32, +} + +impl SpinWait { + /// Creates a new `SpinWait`. + #[inline] + pub fn new() -> SpinWait { + SpinWait { counter: 0 } + } + + /// Resets a `SpinWait` to its initial state. + #[inline] + pub fn reset(&mut self) { + self.counter = 0; + } + + /// Spins until the sleep threshold has been reached. + /// + /// This function returns whether the sleep threshold has been reached, at + /// which point further spinning has diminishing returns and the thread + /// should be parked instead. + /// + /// The spin strategy will initially use a CPU-bound loop but will fall back + /// to yielding the CPU to the OS after a few iterations. + #[inline] + pub fn spin(&mut self) -> bool { + if self.counter >= 10 { + return false; + } + self.counter += 1; + if self.counter <= 3 { + cpu_relax(1 << self.counter); + } else { + thread_yield(); + } + true + } + + /// Spins without yielding the thread to the OS. + /// + /// Instead, the backoff is simply capped at a maximum value. This can be + /// used to improve throughput in `compare_exchange` loops that have high + /// contention. + #[inline] + pub fn spin_no_yield(&mut self) { + self.counter += 1; + if self.counter > 10 { + self.counter = 10; + } + cpu_relax(1 << self.counter); + } +} + +impl Default for SpinWait { + #[inline] + fn default() -> SpinWait { + SpinWait::new() + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/generic.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/generic.rs new file mode 100644 index 0000000..d06406a --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/generic.rs @@ -0,0 +1,98 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::cell::Cell; +use std::sync::{Condvar, Mutex, MutexGuard}; +use std::time::Instant; + +// Helper type for putting a thread to sleep until some other thread wakes it up +pub struct ThreadParker { + should_park: Cell, + mutex: Mutex<()>, + condvar: Condvar, +} + +impl ThreadParker { + pub fn new() -> ThreadParker { + ThreadParker { + should_park: Cell::new(false), + mutex: Mutex::new(()), + condvar: Condvar::new(), + } + } + + // Prepares the parker. This should be called before adding it to the queue. + pub unsafe fn prepare_park(&self) { + self.should_park.set(true); + } + + // Checks if the park timed out. This should be called while holding the + // queue lock after park_until has returned false. + pub unsafe fn timed_out(&self) -> bool { + // We need to grab the mutex here because another thread may be + // concurrently executing UnparkHandle::unpark, which is done without + // holding the queue lock. + let _lock = self.mutex.lock().unwrap(); + self.should_park.get() + } + + // Parks the thread until it is unparked. This should be called after it has + // been added to the queue, after unlocking the queue. + pub unsafe fn park(&self) { + let mut lock = self.mutex.lock().unwrap(); + while self.should_park.get() { + lock = self.condvar.wait(lock).unwrap(); + } + } + + // Parks the thread until it is unparked or the timeout is reached. This + // should be called after it has been added to the queue, after unlocking + // the queue. Returns true if we were unparked and false if we timed out. + pub unsafe fn park_until(&self, timeout: Instant) -> bool { + let mut lock = self.mutex.lock().unwrap(); + while self.should_park.get() { + let now = Instant::now(); + if timeout <= now { + return false; + } + let (new_lock, _) = self.condvar.wait_timeout(lock, timeout - now).unwrap(); + lock = new_lock; + } + true + } + + // Locks the parker to prevent the target thread from exiting. This is + // necessary to ensure that thread-local ThreadData objects remain valid. + // This should be called while holding the queue lock. + pub unsafe fn unpark_lock(&self) -> UnparkHandle { + UnparkHandle { + thread_parker: self, + _guard: self.mutex.lock().unwrap(), + } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub struct UnparkHandle<'a> { + thread_parker: *const ThreadParker, + _guard: MutexGuard<'a, ()>, +} + +impl<'a> UnparkHandle<'a> { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + (*self.thread_parker).should_park.set(false); + + // We notify while holding the lock here to avoid races with the target + // thread. In particular, the thread could exit after we unlock the + // mutex, which would make the condvar access invalid memory. + (*self.thread_parker).condvar.notify_one(); + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/linux.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/linux.rs new file mode 100644 index 0000000..4a13d73 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/linux.rs @@ -0,0 +1,137 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use libc; +use std::sync::atomic::{AtomicI32, Ordering}; +use std::time::Instant; + +const FUTEX_WAIT: i32 = 0; +const FUTEX_WAKE: i32 = 1; +const FUTEX_PRIVATE: i32 = 128; + +// x32 Linux uses a non-standard type for tv_nsec in timespec. +// See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +#[allow(non_camel_case_types)] +type tv_nsec_t = i64; +#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] +#[allow(non_camel_case_types)] +type tv_nsec_t = libc::c_long; + +// Helper type for putting a thread to sleep until some other thread wakes it up +pub struct ThreadParker { + futex: AtomicI32, +} + +impl ThreadParker { + pub fn new() -> ThreadParker { + ThreadParker { + futex: AtomicI32::new(0), + } + } + + // Prepares the parker. This should be called before adding it to the queue. + pub unsafe fn prepare_park(&self) { + self.futex.store(1, Ordering::Relaxed); + } + + // Checks if the park timed out. This should be called while holding the + // queue lock after park_until has returned false. + pub unsafe fn timed_out(&self) -> bool { + self.futex.load(Ordering::Relaxed) != 0 + } + + // Parks the thread until it is unparked. This should be called after it has + // been added to the queue, after unlocking the queue. + pub unsafe fn park(&self) { + while self.futex.load(Ordering::Acquire) != 0 { + let r = libc::syscall( + libc::SYS_futex, + &self.futex, + FUTEX_WAIT | FUTEX_PRIVATE, + 1, + 0, + ); + debug_assert!(r == 0 || r == -1); + if r == -1 { + debug_assert!( + *libc::__errno_location() == libc::EINTR + || *libc::__errno_location() == libc::EAGAIN + ); + } + } + } + + // Parks the thread until it is unparked or the timeout is reached. This + // should be called after it has been added to the queue, after unlocking + // the queue. Returns true if we were unparked and false if we timed out. + pub unsafe fn park_until(&self, timeout: Instant) -> bool { + while self.futex.load(Ordering::Acquire) != 0 { + let now = Instant::now(); + if timeout <= now { + return false; + } + let diff = timeout - now; + if diff.as_secs() as libc::time_t as u64 != diff.as_secs() { + // Timeout overflowed, just sleep indefinitely + self.park(); + return true; + } + let ts = libc::timespec { + tv_sec: diff.as_secs() as libc::time_t, + tv_nsec: diff.subsec_nanos() as tv_nsec_t, + }; + let r = libc::syscall( + libc::SYS_futex, + &self.futex, + FUTEX_WAIT | FUTEX_PRIVATE, + 1, + &ts, + ); + debug_assert!(r == 0 || r == -1); + if r == -1 { + debug_assert!( + *libc::__errno_location() == libc::EINTR + || *libc::__errno_location() == libc::EAGAIN + || *libc::__errno_location() == libc::ETIMEDOUT + ); + } + } + true + } + + // Locks the parker to prevent the target thread from exiting. This is + // necessary to ensure that thread-local ThreadData objects remain valid. + // This should be called while holding the queue lock. + pub unsafe fn unpark_lock(&self) -> UnparkHandle { + // We don't need to lock anything, just clear the state + self.futex.store(0, Ordering::Release); + + UnparkHandle { futex: &self.futex } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub struct UnparkHandle { + futex: *const AtomicI32, +} + +impl UnparkHandle { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + // The thread data may have been freed at this point, but it doesn't + // matter since the syscall will just return EFAULT in that case. + let r = libc::syscall(libc::SYS_futex, self.futex, FUTEX_WAKE | FUTEX_PRIVATE, 1); + debug_assert!(r == 0 || r == 1 || r == -1); + if r == -1 { + debug_assert_eq!(*libc::__errno_location(), libc::EFAULT); + } + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/unix.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/unix.rs new file mode 100644 index 0000000..169586b --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/unix.rs @@ -0,0 +1,242 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use libc; +use std::cell::{Cell, UnsafeCell}; +use std::mem; +#[cfg(any(target_os = "macos", target_os = "ios"))] +use std::ptr; +use std::time::{Duration, Instant}; + +// x32 Linux uses a non-standard type for tv_nsec in timespec. +// See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +#[allow(non_camel_case_types)] +type tv_nsec_t = i64; +#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] +#[allow(non_camel_case_types)] +type tv_nsec_t = libc::c_long; + +// Helper type for putting a thread to sleep until some other thread wakes it up +pub struct ThreadParker { + should_park: Cell, + mutex: UnsafeCell, + condvar: UnsafeCell, + initialized: Cell, +} + +impl ThreadParker { + pub fn new() -> ThreadParker { + ThreadParker { + should_park: Cell::new(false), + mutex: UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER), + condvar: UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER), + initialized: Cell::new(false), + } + } + + // Initializes the condvar to use CLOCK_MONOTONIC instead of CLOCK_REALTIME. + #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "android" + ))] + unsafe fn init(&self) {} + #[cfg(not(any( + target_os = "macos", + target_os = "ios", + target_os = "android" + )))] + unsafe fn init(&self) { + let mut attr: libc::pthread_condattr_t = mem::uninitialized(); + let r = libc::pthread_condattr_init(&mut attr); + debug_assert_eq!(r, 0); + let r = libc::pthread_condattr_setclock(&mut attr, libc::CLOCK_MONOTONIC); + debug_assert_eq!(r, 0); + let r = libc::pthread_cond_init(self.condvar.get(), &attr); + debug_assert_eq!(r, 0); + let r = libc::pthread_condattr_destroy(&mut attr); + debug_assert_eq!(r, 0); + } + + // Prepares the parker. This should be called before adding it to the queue. + pub unsafe fn prepare_park(&self) { + self.should_park.set(true); + if !self.initialized.get() { + self.init(); + self.initialized.set(true); + } + } + + // Checks if the park timed out. This should be called while holding the + // queue lock after park_until has returned false. + pub unsafe fn timed_out(&self) -> bool { + // We need to grab the mutex here because another thread may be + // concurrently executing UnparkHandle::unpark, which is done without + // holding the queue lock. + let r = libc::pthread_mutex_lock(self.mutex.get()); + debug_assert_eq!(r, 0); + let should_park = self.should_park.get(); + let r = libc::pthread_mutex_unlock(self.mutex.get()); + debug_assert_eq!(r, 0); + should_park + } + + // Parks the thread until it is unparked. This should be called after it has + // been added to the queue, after unlocking the queue. + pub unsafe fn park(&self) { + let r = libc::pthread_mutex_lock(self.mutex.get()); + debug_assert_eq!(r, 0); + while self.should_park.get() { + let r = libc::pthread_cond_wait(self.condvar.get(), self.mutex.get()); + debug_assert_eq!(r, 0); + } + let r = libc::pthread_mutex_unlock(self.mutex.get()); + debug_assert_eq!(r, 0); + } + + // Parks the thread until it is unparked or the timeout is reached. This + // should be called after it has been added to the queue, after unlocking + // the queue. Returns true if we were unparked and false if we timed out. + pub unsafe fn park_until(&self, timeout: Instant) -> bool { + let r = libc::pthread_mutex_lock(self.mutex.get()); + debug_assert_eq!(r, 0); + while self.should_park.get() { + let now = Instant::now(); + if timeout <= now { + let r = libc::pthread_mutex_unlock(self.mutex.get()); + debug_assert_eq!(r, 0); + return false; + } + + if let Some(ts) = timeout_to_timespec(timeout - now) { + let r = libc::pthread_cond_timedwait(self.condvar.get(), self.mutex.get(), &ts); + if ts.tv_sec < 0 { + // On some systems, negative timeouts will return EINVAL. In + // that case we won't sleep and will just busy loop instead, + // which is the best we can do. + debug_assert!(r == 0 || r == libc::ETIMEDOUT || r == libc::EINVAL); + } else { + debug_assert!(r == 0 || r == libc::ETIMEDOUT); + } + } else { + // Timeout calculation overflowed, just sleep indefinitely + let r = libc::pthread_cond_wait(self.condvar.get(), self.mutex.get()); + debug_assert_eq!(r, 0); + } + } + let r = libc::pthread_mutex_unlock(self.mutex.get()); + debug_assert_eq!(r, 0); + true + } + + // Locks the parker to prevent the target thread from exiting. This is + // necessary to ensure that thread-local ThreadData objects remain valid. + // This should be called while holding the queue lock. + pub unsafe fn unpark_lock(&self) -> UnparkHandle { + let r = libc::pthread_mutex_lock(self.mutex.get()); + debug_assert_eq!(r, 0); + + UnparkHandle { + thread_parker: self, + } + } +} + +impl Drop for ThreadParker { + fn drop(&mut self) { + // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a + // mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER. + // Once it is used (locked/unlocked) or pthread_mutex_init() is called, + // this behaviour no longer occurs. The same applies to condvars. + unsafe { + let r = libc::pthread_mutex_destroy(self.mutex.get()); + if cfg!(target_os = "dragonfly") { + debug_assert!(r == 0 || r == libc::EINVAL); + } else { + debug_assert_eq!(r, 0); + } + let r = libc::pthread_cond_destroy(self.condvar.get()); + if cfg!(target_os = "dragonfly") { + debug_assert!(r == 0 || r == libc::EINVAL); + } else { + debug_assert_eq!(r, 0); + } + } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub struct UnparkHandle { + thread_parker: *const ThreadParker, +} + +impl UnparkHandle { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + (*self.thread_parker).should_park.set(false); + + // We notify while holding the lock here to avoid races with the target + // thread. In particular, the thread could exit after we unlock the + // mutex, which would make the condvar access invalid memory. + let r = libc::pthread_cond_signal((*self.thread_parker).condvar.get()); + debug_assert_eq!(r, 0); + let r = libc::pthread_mutex_unlock((*self.thread_parker).mutex.get()); + debug_assert_eq!(r, 0); + } +} + +// Returns the current time on the clock used by pthread_cond_t as a timespec. +#[cfg(any(target_os = "macos", target_os = "ios"))] +unsafe fn timespec_now() -> libc::timespec { + let mut now: libc::timeval = mem::uninitialized(); + let r = libc::gettimeofday(&mut now, ptr::null_mut()); + debug_assert_eq!(r, 0); + libc::timespec { + tv_sec: now.tv_sec, + tv_nsec: now.tv_usec as tv_nsec_t * 1000, + } +} +#[cfg(not(any(target_os = "macos", target_os = "ios")))] +unsafe fn timespec_now() -> libc::timespec { + let mut now: libc::timespec = mem::uninitialized(); + let clock = if cfg!(target_os = "android") { + // Android doesn't support pthread_condattr_setclock, so we need to + // specify the timeout in CLOCK_REALTIME. + libc::CLOCK_REALTIME + } else { + libc::CLOCK_MONOTONIC + }; + let r = libc::clock_gettime(clock, &mut now); + debug_assert_eq!(r, 0); + now +} + +// Converts a relative timeout into an absolute timeout in the clock used by +// pthread_cond_t. +unsafe fn timeout_to_timespec(timeout: Duration) -> Option { + // Handle overflows early on + if timeout.as_secs() > libc::time_t::max_value() as u64 { + return None; + } + + let now = timespec_now(); + let mut nsec = now.tv_nsec + timeout.subsec_nanos() as tv_nsec_t; + let mut sec = now.tv_sec.checked_add(timeout.as_secs() as libc::time_t); + if nsec >= 1_000_000_000 { + nsec -= 1_000_000_000; + sec = sec.and_then(|sec| sec.checked_add(1)); + } + + sec.map(|sec| libc::timespec { + tv_nsec: nsec, + tv_sec: sec, + }) +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/windows/keyed_event.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/windows/keyed_event.rs new file mode 100644 index 0000000..0e32fce --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/windows/keyed_event.rs @@ -0,0 +1,197 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::mem; +use std::ptr; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::time::Instant; + +use winapi::shared::minwindef::{TRUE, ULONG}; +use winapi::shared::ntdef::NTSTATUS; +use winapi::shared::ntstatus::{STATUS_SUCCESS, STATUS_TIMEOUT}; +use winapi::um::handleapi::CloseHandle; +use winapi::um::libloaderapi::{GetModuleHandleA, GetProcAddress}; +use winapi::um::winnt::{ACCESS_MASK, GENERIC_READ, GENERIC_WRITE, LPCSTR}; +use winapi::um::winnt::{BOOLEAN, HANDLE, LARGE_INTEGER, PHANDLE, PLARGE_INTEGER, PVOID}; + +const STATE_UNPARKED: usize = 0; +const STATE_PARKED: usize = 1; +const STATE_TIMED_OUT: usize = 2; + +#[allow(non_snake_case)] +pub struct KeyedEvent { + handle: HANDLE, + NtReleaseKeyedEvent: extern "system" fn( + EventHandle: HANDLE, + Key: PVOID, + Alertable: BOOLEAN, + Timeout: PLARGE_INTEGER, + ) -> NTSTATUS, + NtWaitForKeyedEvent: extern "system" fn( + EventHandle: HANDLE, + Key: PVOID, + Alertable: BOOLEAN, + Timeout: PLARGE_INTEGER, + ) -> NTSTATUS, +} + +impl KeyedEvent { + unsafe fn wait_for(&self, key: PVOID, timeout: PLARGE_INTEGER) -> NTSTATUS { + (self.NtWaitForKeyedEvent)(self.handle, key, 0, timeout) + } + + unsafe fn release(&self, key: PVOID) -> NTSTATUS { + (self.NtReleaseKeyedEvent)(self.handle, key, 0, ptr::null_mut()) + } + + #[allow(non_snake_case)] + pub unsafe fn create() -> Option { + let ntdll = GetModuleHandleA(b"ntdll.dll\0".as_ptr() as LPCSTR); + if ntdll.is_null() { + return None; + } + + let NtCreateKeyedEvent = GetProcAddress(ntdll, b"NtCreateKeyedEvent\0".as_ptr() as LPCSTR); + if NtCreateKeyedEvent.is_null() { + return None; + } + let NtReleaseKeyedEvent = + GetProcAddress(ntdll, b"NtReleaseKeyedEvent\0".as_ptr() as LPCSTR); + if NtReleaseKeyedEvent.is_null() { + return None; + } + let NtWaitForKeyedEvent = + GetProcAddress(ntdll, b"NtWaitForKeyedEvent\0".as_ptr() as LPCSTR); + if NtWaitForKeyedEvent.is_null() { + return None; + } + + let NtCreateKeyedEvent: extern "system" fn( + KeyedEventHandle: PHANDLE, + DesiredAccess: ACCESS_MASK, + ObjectAttributes: PVOID, + Flags: ULONG, + ) -> NTSTATUS = mem::transmute(NtCreateKeyedEvent); + let mut handle = mem::uninitialized(); + let status = NtCreateKeyedEvent( + &mut handle, + GENERIC_READ | GENERIC_WRITE, + ptr::null_mut(), + 0, + ); + if status != STATUS_SUCCESS { + return None; + } + + Some(KeyedEvent { + handle, + NtReleaseKeyedEvent: mem::transmute(NtReleaseKeyedEvent), + NtWaitForKeyedEvent: mem::transmute(NtWaitForKeyedEvent), + }) + } + + pub unsafe fn prepare_park(&'static self, key: &AtomicUsize) { + key.store(STATE_PARKED, Ordering::Relaxed); + } + + pub unsafe fn timed_out(&'static self, key: &AtomicUsize) -> bool { + key.load(Ordering::Relaxed) == STATE_TIMED_OUT + } + + pub unsafe fn park(&'static self, key: &AtomicUsize) { + let status = self.wait_for(key as *const _ as PVOID, ptr::null_mut()); + debug_assert_eq!(status, STATUS_SUCCESS); + } + + pub unsafe fn park_until(&'static self, key: &AtomicUsize, timeout: Instant) -> bool { + let now = Instant::now(); + if timeout <= now { + // If another thread unparked us, we need to call + // NtWaitForKeyedEvent otherwise that thread will stay stuck at + // NtReleaseKeyedEvent. + if key.swap(STATE_TIMED_OUT, Ordering::Relaxed) == STATE_UNPARKED { + self.park(key); + return true; + } + return false; + } + + // NT uses a timeout in units of 100ns. We use a negative value to + // indicate a relative timeout based on a monotonic clock. + let mut nt_timeout: LARGE_INTEGER = mem::zeroed(); + let diff = timeout - now; + let value = (diff.as_secs() as i64) + .checked_mul(-10000000) + .and_then(|x| x.checked_sub((diff.subsec_nanos() as i64 + 99) / 100)); + + match value { + Some(x) => *nt_timeout.QuadPart_mut() = x, + None => { + // Timeout overflowed, just sleep indefinitely + self.park(key); + return true; + } + }; + + let status = self.wait_for(key as *const _ as PVOID, &mut nt_timeout); + if status == STATUS_SUCCESS { + return true; + } + debug_assert_eq!(status, STATUS_TIMEOUT); + + // If another thread unparked us, we need to call NtWaitForKeyedEvent + // otherwise that thread will stay stuck at NtReleaseKeyedEvent. + if key.swap(STATE_TIMED_OUT, Ordering::Relaxed) == STATE_UNPARKED { + self.park(key); + return true; + } + false + } + + pub unsafe fn unpark_lock(&'static self, key: &AtomicUsize) -> UnparkHandle { + // If the state was STATE_PARKED then we need to wake up the thread + if key.swap(STATE_UNPARKED, Ordering::Relaxed) == STATE_PARKED { + UnparkHandle { + key: key, + keyed_event: self, + } + } else { + UnparkHandle { + key: ptr::null(), + keyed_event: self, + } + } + } +} + +impl Drop for KeyedEvent { + fn drop(&mut self) { + unsafe { + let ok = CloseHandle(self.handle); + debug_assert_eq!(ok, TRUE); + } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub struct UnparkHandle { + key: *const AtomicUsize, + keyed_event: &'static KeyedEvent, +} + +impl UnparkHandle { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + if !self.key.is_null() { + let status = self.keyed_event.release(self.key as PVOID); + debug_assert_eq!(status, STATUS_SUCCESS); + } + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/windows/mod.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/windows/mod.rs new file mode 100644 index 0000000..a91ab61 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/windows/mod.rs @@ -0,0 +1,136 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use std::time::Instant; + +mod keyed_event; +mod waitaddress; + +enum Backend { + KeyedEvent(keyed_event::KeyedEvent), + WaitAddress(waitaddress::WaitAddress), +} + +impl Backend { + unsafe fn get() -> &'static Backend { + static BACKEND: AtomicUsize = ATOMIC_USIZE_INIT; + + // Fast path: use the existing object + let backend = BACKEND.load(Ordering::Acquire); + if backend != 0 { + return &*(backend as *const Backend); + }; + + // Try to create a new Backend + let backend; + if let Some(waitaddress) = waitaddress::WaitAddress::create() { + backend = Backend::WaitAddress(waitaddress); + } else if let Some(keyed_event) = keyed_event::KeyedEvent::create() { + backend = Backend::KeyedEvent(keyed_event); + } else { + panic!( + "parking_lot requires either NT Keyed Events (WinXP+) or \ + WaitOnAddress/WakeByAddress (Win8+)" + ); + } + + // Try to create a new object + let backend = Box::into_raw(Box::new(backend)); + match BACKEND.compare_exchange(0, backend as usize, Ordering::Release, Ordering::Relaxed) { + Ok(_) => &*(backend as *const Backend), + Err(x) => { + // We lost the race, free our object and return the global one + Box::from_raw(backend); + &*(x as *const Backend) + } + } + } +} + +// Helper type for putting a thread to sleep until some other thread wakes it up +pub struct ThreadParker { + key: AtomicUsize, + backend: &'static Backend, +} + +impl ThreadParker { + pub fn new() -> ThreadParker { + // Initialize the backend here to ensure we don't get any panics + // later on, which could leave synchronization primitives in a broken + // state. + ThreadParker { + key: AtomicUsize::new(0), + backend: unsafe { Backend::get() }, + } + } + + // Prepares the parker. This should be called before adding it to the queue. + pub unsafe fn prepare_park(&self) { + match *self.backend { + Backend::KeyedEvent(ref x) => x.prepare_park(&self.key), + Backend::WaitAddress(ref x) => x.prepare_park(&self.key), + } + } + + // Checks if the park timed out. This should be called while holding the + // queue lock after park_until has returned false. + pub unsafe fn timed_out(&self) -> bool { + match *self.backend { + Backend::KeyedEvent(ref x) => x.timed_out(&self.key), + Backend::WaitAddress(ref x) => x.timed_out(&self.key), + } + } + + // Parks the thread until it is unparked. This should be called after it has + // been added to the queue, after unlocking the queue. + pub unsafe fn park(&self) { + match *self.backend { + Backend::KeyedEvent(ref x) => x.park(&self.key), + Backend::WaitAddress(ref x) => x.park(&self.key), + } + } + + // Parks the thread until it is unparked or the timeout is reached. This + // should be called after it has been added to the queue, after unlocking + // the queue. Returns true if we were unparked and false if we timed out. + pub unsafe fn park_until(&self, timeout: Instant) -> bool { + match *self.backend { + Backend::KeyedEvent(ref x) => x.park_until(&self.key, timeout), + Backend::WaitAddress(ref x) => x.park_until(&self.key, timeout), + } + } + + // Locks the parker to prevent the target thread from exiting. This is + // necessary to ensure that thread-local ThreadData objects remain valid. + // This should be called while holding the queue lock. + pub unsafe fn unpark_lock(&self) -> UnparkHandle { + match *self.backend { + Backend::KeyedEvent(ref x) => UnparkHandle::KeyedEvent(x.unpark_lock(&self.key)), + Backend::WaitAddress(ref x) => UnparkHandle::WaitAddress(x.unpark_lock(&self.key)), + } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub enum UnparkHandle { + KeyedEvent(keyed_event::UnparkHandle), + WaitAddress(waitaddress::UnparkHandle), +} + +impl UnparkHandle { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + match self { + UnparkHandle::KeyedEvent(x) => x.unpark(), + UnparkHandle::WaitAddress(x) => x.unpark(), + } + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/windows/waitaddress.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/windows/waitaddress.rs new file mode 100644 index 0000000..1d9fca8 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/thread_parker/windows/waitaddress.rs @@ -0,0 +1,134 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::mem; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::time::Instant; + +use winapi::shared::basetsd::SIZE_T; +use winapi::shared::minwindef::{BOOL, DWORD, FALSE, TRUE}; +use winapi::shared::winerror::ERROR_TIMEOUT; +use winapi::um::errhandlingapi::GetLastError; +use winapi::um::libloaderapi::{GetModuleHandleA, GetProcAddress}; +use winapi::um::winbase::INFINITE; +use winapi::um::winnt::{LPCSTR, PVOID}; + +#[allow(non_snake_case)] +pub struct WaitAddress { + WaitOnAddress: extern "system" fn( + Address: PVOID, + CompareAddress: PVOID, + AddressSize: SIZE_T, + dwMilliseconds: DWORD, + ) -> BOOL, + WakeByAddressSingle: extern "system" fn(Address: PVOID), +} + +impl WaitAddress { + #[allow(non_snake_case)] + pub unsafe fn create() -> Option { + // MSDN claims that that WaitOnAddress and WakeByAddressSingle are + // located in kernel32.dll, but they are lying... + let synch_dll = GetModuleHandleA(b"api-ms-win-core-synch-l1-2-0.dll\0".as_ptr() as LPCSTR); + if synch_dll.is_null() { + return None; + } + + let WaitOnAddress = GetProcAddress(synch_dll, b"WaitOnAddress\0".as_ptr() as LPCSTR); + if WaitOnAddress.is_null() { + return None; + } + let WakeByAddressSingle = + GetProcAddress(synch_dll, b"WakeByAddressSingle\0".as_ptr() as LPCSTR); + if WakeByAddressSingle.is_null() { + return None; + } + Some(WaitAddress { + WaitOnAddress: mem::transmute(WaitOnAddress), + WakeByAddressSingle: mem::transmute(WakeByAddressSingle), + }) + } + + pub unsafe fn prepare_park(&'static self, key: &AtomicUsize) { + key.store(1, Ordering::Relaxed); + } + + pub unsafe fn timed_out(&'static self, key: &AtomicUsize) -> bool { + key.load(Ordering::Relaxed) != 0 + } + + pub unsafe fn park(&'static self, key: &AtomicUsize) { + while key.load(Ordering::Acquire) != 0 { + let cmp = 1usize; + let r = (self.WaitOnAddress)( + key as *const _ as PVOID, + &cmp as *const _ as PVOID, + mem::size_of::() as SIZE_T, + INFINITE, + ); + debug_assert!(r == TRUE); + } + } + + pub unsafe fn park_until(&'static self, key: &AtomicUsize, timeout: Instant) -> bool { + while key.load(Ordering::Acquire) != 0 { + let now = Instant::now(); + if timeout <= now { + return false; + } + let diff = timeout - now; + let timeout = diff + .as_secs() + .checked_mul(1000) + .and_then(|x| x.checked_add((diff.subsec_nanos() as u64 + 999999) / 1000000)) + .map(|ms| { + if ms > ::max_value() as u64 { + INFINITE + } else { + ms as DWORD + } + }).unwrap_or(INFINITE); + let cmp = 1usize; + let r = (self.WaitOnAddress)( + key as *const _ as PVOID, + &cmp as *const _ as PVOID, + mem::size_of::() as SIZE_T, + timeout, + ); + if r == FALSE { + debug_assert_eq!(GetLastError(), ERROR_TIMEOUT); + } + } + true + } + + pub unsafe fn unpark_lock(&'static self, key: &AtomicUsize) -> UnparkHandle { + // We don't need to lock anything, just clear the state + key.store(0, Ordering::Release); + + UnparkHandle { + key: key, + waitaddress: self, + } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub struct UnparkHandle { + key: *const AtomicUsize, + waitaddress: &'static WaitAddress, +} + +impl UnparkHandle { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + (self.waitaddress.WakeByAddressSingle)(self.key as PVOID); + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/util.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/util.rs new file mode 100644 index 0000000..c7dfd32 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/util.rs @@ -0,0 +1,32 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +// Option::unchecked_unwrap +pub trait UncheckedOptionExt { + unsafe fn unchecked_unwrap(self) -> T; +} + +impl UncheckedOptionExt for Option { + #[inline] + unsafe fn unchecked_unwrap(self) -> T { + match self { + Some(x) => x, + None => unreachable(), + } + } +} + +// Equivalent to intrinsics::unreachable() in release mode +#[inline] +unsafe fn unreachable() -> ! { + if cfg!(debug_assertions) { + unreachable!(); + } else { + enum Void {} + match *(1 as *const Void) {} + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.3.1/src/word_lock.rs b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/word_lock.rs new file mode 100644 index 0000000..7960568 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.3.1/src/word_lock.rs @@ -0,0 +1,279 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use spinwait::SpinWait; +use std::cell::Cell; +use std::mem; +#[cfg(not(has_localkey_try_with))] +use std::panic; +use std::ptr; +use std::sync::atomic::{fence, AtomicUsize, Ordering}; +use std::thread::LocalKey; +use thread_parker::ThreadParker; + +struct ThreadData { + parker: ThreadParker, + + // Linked list of threads in the queue. The queue is split into two parts: + // the processed part and the unprocessed part. When new nodes are added to + // the list, they only have the next pointer set, and queue_tail is null. + // + // Nodes are processed with the queue lock held, which consists of setting + // the prev pointer for each node and setting the queue_tail pointer on the + // first processed node of the list. + // + // This setup allows nodes to be added to the queue without a lock, while + // still allowing O(1) removal of nodes from the processed part of the list. + // The only cost is the O(n) processing, but this only needs to be done + // once for each node, and therefore isn't too expensive. + queue_tail: Cell<*const ThreadData>, + prev: Cell<*const ThreadData>, + next: Cell<*const ThreadData>, +} + +impl ThreadData { + fn new() -> ThreadData { + ThreadData { + parker: ThreadParker::new(), + queue_tail: Cell::new(ptr::null()), + prev: Cell::new(ptr::null()), + next: Cell::new(ptr::null()), + } + } +} + +// Returns a ThreadData structure for the current thread +unsafe fn get_thread_data(local: &mut Option) -> &ThreadData { + // Try to read from thread-local storage, but return None if the TLS has + // already been destroyed. + #[cfg(has_localkey_try_with)] + fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { + key.try_with(|x| x as *const ThreadData).ok() + } + #[cfg(not(has_localkey_try_with))] + fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { + panic::catch_unwind(|| key.with(|x| x as *const ThreadData)).ok() + } + + // If ThreadData is expensive to construct, then we want to use a cached + // version in thread-local storage if possible. + if !cfg!(windows) && !cfg!(all(feature = "nightly", target_os = "linux")) { + thread_local!(static THREAD_DATA: ThreadData = ThreadData::new()); + if let Some(tls) = try_get_tls(&THREAD_DATA) { + return &*tls; + } + } + + // Otherwise just create a ThreadData on the stack + *local = Some(ThreadData::new()); + local.as_ref().unwrap() +} + +const LOCKED_BIT: usize = 1; +const QUEUE_LOCKED_BIT: usize = 2; +const QUEUE_MASK: usize = !3; + +// Word-sized lock that is used to implement the parking_lot API. Since this +// can't use parking_lot, it instead manages its own queue of waiting threads. +pub struct WordLock { + state: AtomicUsize, +} + +impl WordLock { + #[inline] + pub fn new() -> WordLock { + WordLock { + state: AtomicUsize::new(0), + } + } + + #[inline] + pub unsafe fn lock(&self) { + if self + .state + .compare_exchange_weak(0, LOCKED_BIT, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + return; + } + self.lock_slow(); + } + + #[inline] + pub unsafe fn unlock(&self) { + let state = self.state.fetch_sub(LOCKED_BIT, Ordering::Release); + if state & QUEUE_LOCKED_BIT != 0 || state & QUEUE_MASK == 0 { + return; + } + self.unlock_slow(); + } + + #[cold] + #[inline(never)] + unsafe fn lock_slow(&self) { + let mut spinwait = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Grab the lock if it isn't locked, even if there is a queue on it + if state & LOCKED_BIT == 0 { + match self.state.compare_exchange_weak( + state, + state | LOCKED_BIT, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return, + Err(x) => state = x, + } + continue; + } + + // If there is no queue, try spinning a few times + if state & QUEUE_MASK == 0 && spinwait.spin() { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Get our thread data and prepare it for parking + let mut thread_data = None; + let thread_data = get_thread_data(&mut thread_data); + assert!(mem::align_of_val(thread_data) > !QUEUE_MASK); + thread_data.parker.prepare_park(); + + // Add our thread to the front of the queue + let queue_head = (state & QUEUE_MASK) as *const ThreadData; + if queue_head.is_null() { + thread_data.queue_tail.set(thread_data); + thread_data.prev.set(ptr::null()); + } else { + thread_data.queue_tail.set(ptr::null()); + thread_data.prev.set(ptr::null()); + thread_data.next.set(queue_head); + } + if let Err(x) = self.state.compare_exchange_weak( + state, + (state & !QUEUE_MASK) | thread_data as *const _ as usize, + Ordering::Release, + Ordering::Relaxed, + ) { + state = x; + continue; + } + + // Sleep until we are woken up by an unlock + thread_data.parker.park(); + + // Loop back and try locking again + spinwait.reset(); + self.state.load(Ordering::Relaxed); + } + } + + #[cold] + #[inline(never)] + unsafe fn unlock_slow(&self) { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // We just unlocked the WordLock. Just check if there is a thread + // to wake up. If the queue is locked then another thread is already + // taking care of waking up a thread. + if state & QUEUE_LOCKED_BIT != 0 || state & QUEUE_MASK == 0 { + return; + } + + // Try to grab the queue lock + match self.state.compare_exchange_weak( + state, + state | QUEUE_LOCKED_BIT, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => break, + Err(x) => state = x, + } + } + + // Now we have the queue lock and the queue is non-empty + 'outer: loop { + // First, we need to fill in the prev pointers for any newly added + // threads. We do this until we reach a node that we previously + // processed, which has a non-null queue_tail pointer. + let queue_head = (state & QUEUE_MASK) as *const ThreadData; + let mut queue_tail; + let mut current = queue_head; + loop { + queue_tail = (*current).queue_tail.get(); + if !queue_tail.is_null() { + break; + } + let next = (*current).next.get(); + (*next).prev.set(current); + current = next; + } + + // Set queue_tail on the queue head to indicate that the whole list + // has prev pointers set correctly. + (*queue_head).queue_tail.set(queue_tail); + + // If the WordLock is locked, then there is no point waking up a + // thread now. Instead we let the next unlocker take care of waking + // up a thread. + if state & LOCKED_BIT != 0 { + match self.state.compare_exchange_weak( + state, + state & !QUEUE_LOCKED_BIT, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return, + Err(x) => state = x, + } + + // Need an acquire fence before reading the new queue + fence(Ordering::Acquire); + continue; + } + + // Remove the last thread from the queue and unlock the queue + let new_tail = (*queue_tail).prev.get(); + if new_tail.is_null() { + loop { + match self.state.compare_exchange_weak( + state, + state & LOCKED_BIT, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => break, + Err(x) => state = x, + } + + // If the compare_exchange failed because a new thread was + // added to the queue then we need to re-scan the queue to + // find the previous element. + if state & QUEUE_MASK == 0 { + continue; + } else { + // Need an acquire fence before reading the new queue + fence(Ordering::Acquire); + continue 'outer; + } + } + } else { + (*queue_head).queue_tail.set(new_tail); + self.state.fetch_and(!QUEUE_LOCKED_BIT, Ordering::Release); + } + + // Finally, wake up the thread we removed from the queue. Note that + // we don't need to worry about any races here since the thread is + // guaranteed to be sleeping right now and we are the only one who + // can wake it up. + (*queue_tail).parker.unpark_lock().unpark(); + break; + } + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/.cargo-checksum.json b/third_party/cargo/vendor/parking_lot_core-0.4.0/.cargo-checksum.json new file mode 100644 index 0000000..8cbf15c --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"b8af1f3d0946ea4db58f7fa34c19e38165eac9b070bb055e5888d55fa52e3007","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","build.rs":"b4ca69501aa539f2d9a50a3188e93d69eb5ad0c38d5cd194df361a3f2f9a8b92","src/lib.rs":"9d5d80460481b44b8d9048b7319be33ac989250960c61b7c4528c0431f9ad36c","src/parking_lot.rs":"70d621eed1e4a85d4e4f619d50fd11b12e3a4b7141d4400252d3ab071d665f8e","src/spinwait.rs":"45a0f2a57177bc9759c0c2167f758ee220fba7cd8bdf1fbcd9c2b962fef9a1e5","src/thread_parker/generic.rs":"985966b1bdc763ada6d1fee800d19dd92611da4f84cfeef2d82763ffd2a499c3","src/thread_parker/linux.rs":"c41d08ab333972b67f20443f474ed25a1f171db0f87e227df4bdc504f6f9d897","src/thread_parker/unix.rs":"6364bcfeacfb3189bcebeddfccef1b9843d3c59d6d0f046827e62b33bcee30dd","src/thread_parker/windows/keyed_event.rs":"83d4bace5d2f17993071de28043e94f3b9673c887e01c72653b6fd24db260634","src/thread_parker/windows/mod.rs":"f31eed53f3e402477d80a70a7c6d474c01ba4c9ad952bbe562509448cd3cc1ad","src/thread_parker/windows/waitaddress.rs":"1a6eee8ab9131c746089e78b0aab900f23a5ed8ee6f2e789b8ec4d2232153ab8","src/util.rs":"2d07c0c010a857790ae2ed6a1215eeed8af76859e076797ea1ba8dec82169e84","src/word_lock.rs":"c4d50c0d37e6dd92fb078c80f84dc5b5c83bdf46baad34ed35af8730a345a2b5"},"package":"94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9"} \ No newline at end of file diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/BUILD b/third_party/cargo/vendor/parking_lot_core-0.4.0/BUILD new file mode 100644 index 0000000..9eff31c --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/BUILD @@ -0,0 +1,46 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0,MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "parking_lot_core", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/rand-0.6.5:rand", + "//third_party/cargo/vendor/smallvec-0.6.13:smallvec", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/Cargo.toml b/third_party/cargo/vendor/parking_lot_core-0.4.0/Cargo.toml new file mode 100644 index 0000000..8a37925 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/Cargo.toml @@ -0,0 +1,49 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "parking_lot_core" +version = "0.4.0" +authors = ["Amanieu d'Antras "] +description = "An advanced API for creating custom synchronization primitives." +keywords = ["mutex", "condvar", "rwlock", "once", "thread"] +categories = ["concurrency"] +license = "Apache-2.0/MIT" +repository = "https://github.com/Amanieu/parking_lot" +[dependencies.backtrace] +version = "0.3.2" +optional = true + +[dependencies.petgraph] +version = "0.4.5" +optional = true + +[dependencies.rand] +version = "0.6" + +[dependencies.smallvec] +version = "0.6" + +[dependencies.thread-id] +version = "3.2.0" +optional = true +[build-dependencies.rustc_version] +version = "0.2" + +[features] +deadlock_detection = ["petgraph", "thread-id", "backtrace"] +nightly = [] +[target."cfg(unix)".dependencies.libc] +version = "0.2.27" +[target."cfg(windows)".dependencies.winapi] +version = "0.3" +features = ["winnt", "ntstatus", "minwindef", "winerror", "winbase", "errhandlingapi", "handleapi"] diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/LICENSE-APACHE b/third_party/cargo/vendor/parking_lot_core-0.4.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/LICENSE-MIT b/third_party/cargo/vendor/parking_lot_core-0.4.0/LICENSE-MIT new file mode 100644 index 0000000..40b8817 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/build.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/build.rs new file mode 100644 index 0000000..8d745ee --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/build.rs @@ -0,0 +1,8 @@ +extern crate rustc_version; +use rustc_version::{version, Version}; + +fn main() { + if version().unwrap() >= Version::parse("1.26.0").unwrap() { + println!("cargo:rustc-cfg=has_localkey_try_with"); + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/lib.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/lib.rs new file mode 100644 index 0000000..338b63e --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/lib.rs @@ -0,0 +1,84 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +//! This library exposes a low-level API for creating your own efficient +//! synchronization primitives. +//! +//! # The parking lot +//! +//! To keep synchronization primitives small, all thread queuing and suspending +//! functionality is offloaded to the *parking lot*. The idea behind this is based +//! on the Webkit [`WTF::ParkingLot`](https://webkit.org/blog/6161/locking-in-webkit/) +//! class, which essentially consists of a hash table mapping of lock addresses +//! to queues of parked (sleeping) threads. The Webkit parking lot was itself +//! inspired by Linux [futexes](http://man7.org/linux/man-pages/man2/futex.2.html), +//! but it is more powerful since it allows invoking callbacks while holding a +//! queue lock. +//! +//! There are two main operations that can be performed on the parking lot: +//! +//! - *Parking* refers to suspending the thread while simultaneously enqueuing it +//! on a queue keyed by some address. +//! - *Unparking* refers to dequeuing a thread from a queue keyed by some address +//! and resuming it. +//! +//! See the documentation of the individual functions for more details. +//! +//! # Building custom synchronization primitives +//! +//! Building custom synchronization primitives is very simple since the parking +//! lot takes care of all the hard parts for you. A simple example for a +//! custom primitive would be to integrate a `Mutex` inside another data type. +//! Since a mutex only requires 2 bits, it can share space with other data. +//! For example, one could create an `ArcMutex` type that combines the atomic +//! reference count and the two mutex bits in the same atomic word. + +#![warn(missing_docs)] +#![cfg_attr( + all(feature = "nightly", target_os = "linux"), + feature(integer_atomics) +)] + +extern crate rand; +extern crate smallvec; + +#[cfg(feature = "deadlock_detection")] +extern crate backtrace; +#[cfg(feature = "deadlock_detection")] +extern crate petgraph; +#[cfg(feature = "deadlock_detection")] +extern crate thread_id; + +#[cfg(unix)] +extern crate libc; + +#[cfg(windows)] +extern crate winapi; + +#[cfg(all(feature = "nightly", target_os = "linux"))] +#[path = "thread_parker/linux.rs"] +mod thread_parker; +#[cfg(all(unix, not(all(feature = "nightly", target_os = "linux"))))] +#[path = "thread_parker/unix.rs"] +mod thread_parker; +#[cfg(windows)] +#[path = "thread_parker/windows/mod.rs"] +mod thread_parker; +#[cfg(not(any(windows, unix)))] +#[path = "thread_parker/generic.rs"] +mod thread_parker; + +mod parking_lot; +mod spinwait; +mod util; +mod word_lock; + +pub use parking_lot::deadlock; +pub use parking_lot::{park, unpark_all, unpark_filter, unpark_one, unpark_requeue}; +pub use parking_lot::{FilterOp, ParkResult, ParkToken, RequeueOp, UnparkResult, UnparkToken}; +pub use parking_lot::{DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN}; +pub use spinwait::SpinWait; diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/parking_lot.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/parking_lot.rs new file mode 100644 index 0000000..64acaf9 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/parking_lot.rs @@ -0,0 +1,1406 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use rand::rngs::SmallRng; +use rand::{FromEntropy, Rng}; +use smallvec::SmallVec; +use std::cell::{Cell, UnsafeCell}; +use std::mem; +#[cfg(not(has_localkey_try_with))] +use std::panic; +use std::ptr; +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use std::thread::LocalKey; +use std::time::{Duration, Instant}; +use thread_parker::ThreadParker; +use util::UncheckedOptionExt; +use word_lock::WordLock; + +static NUM_THREADS: AtomicUsize = ATOMIC_USIZE_INIT; +static HASHTABLE: AtomicUsize = ATOMIC_USIZE_INIT; + +// Even with 3x more buckets than threads, the memory overhead per thread is +// still only a few hundred bytes per thread. +const LOAD_FACTOR: usize = 3; + +struct HashTable { + // Hash buckets for the table + entries: Box<[Bucket]>, + + // Number of bits used for the hash function + hash_bits: u32, + + // Previous table. This is only kept to keep leak detectors happy. + _prev: *const HashTable, +} + +impl HashTable { + fn new(num_threads: usize, prev: *const HashTable) -> Box { + let new_size = (num_threads * LOAD_FACTOR).next_power_of_two(); + let hash_bits = 0usize.leading_zeros() - new_size.leading_zeros() - 1; + let bucket = Bucket { + mutex: WordLock::new(), + queue_head: Cell::new(ptr::null()), + queue_tail: Cell::new(ptr::null()), + fair_timeout: UnsafeCell::new(FairTimeout::new()), + _padding: unsafe { mem::uninitialized() }, + }; + Box::new(HashTable { + entries: vec![bucket; new_size].into_boxed_slice(), + hash_bits: hash_bits, + _prev: prev, + }) + } +} + +struct Bucket { + // Lock protecting the queue + mutex: WordLock, + + // Linked list of threads waiting on this bucket + queue_head: Cell<*const ThreadData>, + queue_tail: Cell<*const ThreadData>, + + // Next time at which point be_fair should be set + fair_timeout: UnsafeCell, + + // Padding to avoid false sharing between buckets. Ideally we would just + // align the bucket structure to 64 bytes, but Rust doesn't support that + // yet. + _padding: [u8; 64], +} + +// Implementation of Clone for Bucket, needed to make vec![] work +impl Clone for Bucket { + fn clone(&self) -> Bucket { + Bucket { + mutex: WordLock::new(), + queue_head: Cell::new(ptr::null()), + queue_tail: Cell::new(ptr::null()), + fair_timeout: UnsafeCell::new(FairTimeout::new()), + _padding: unsafe { mem::uninitialized() }, + } + } +} + +struct FairTimeout { + // Next time at which point be_fair should be set + timeout: Instant, + + // Random number generator for calculating the next timeout + rng: SmallRng, +} + +impl FairTimeout { + fn new() -> FairTimeout { + FairTimeout { + timeout: Instant::now(), + rng: SmallRng::from_entropy(), + } + } + + // Determine whether we should force a fair unlock, and update the timeout + fn should_timeout(&mut self) -> bool { + let now = Instant::now(); + if now > self.timeout { + self.timeout = now + Duration::new(0, self.rng.gen_range(0, 1000000)); + true + } else { + false + } + } +} + +struct ThreadData { + parker: ThreadParker, + + // Key that this thread is sleeping on. This may change if the thread is + // requeued to a different key. + key: AtomicUsize, + + // Linked list of parked threads in a bucket + next_in_queue: Cell<*const ThreadData>, + + // UnparkToken passed to this thread when it is unparked + unpark_token: Cell, + + // ParkToken value set by the thread when it was parked + park_token: Cell, + + // Is the thread parked with a timeout? + parked_with_timeout: Cell, + + // Extra data for deadlock detection + // TODO: once supported in stable replace with #[cfg...] & remove dummy struct/impl + #[allow(dead_code)] + deadlock_data: deadlock::DeadlockData, +} + +impl ThreadData { + fn new() -> ThreadData { + // Keep track of the total number of live ThreadData objects and resize + // the hash table accordingly. + let num_threads = NUM_THREADS.fetch_add(1, Ordering::Relaxed) + 1; + unsafe { + grow_hashtable(num_threads); + } + + ThreadData { + parker: ThreadParker::new(), + key: AtomicUsize::new(0), + next_in_queue: Cell::new(ptr::null()), + unpark_token: Cell::new(DEFAULT_UNPARK_TOKEN), + park_token: Cell::new(DEFAULT_PARK_TOKEN), + parked_with_timeout: Cell::new(false), + deadlock_data: deadlock::DeadlockData::new(), + } + } +} + +// Returns a ThreadData structure for the current thread +unsafe fn get_thread_data(local: &mut Option) -> &ThreadData { + // Try to read from thread-local storage, but return None if the TLS has + // already been destroyed. + #[cfg(has_localkey_try_with)] + fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { + key.try_with(|x| x as *const ThreadData).ok() + } + #[cfg(not(has_localkey_try_with))] + fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { + panic::catch_unwind(|| key.with(|x| x as *const ThreadData)).ok() + } + + // Unlike word_lock::ThreadData, parking_lot::ThreadData is always expensive + // to construct. Try to use a thread-local version if possible. + thread_local!(static THREAD_DATA: ThreadData = ThreadData::new()); + if let Some(tls) = try_get_tls(&THREAD_DATA) { + return &*tls; + } + + // Otherwise just create a ThreadData on the stack + *local = Some(ThreadData::new()); + local.as_ref().unwrap() +} + +impl Drop for ThreadData { + fn drop(&mut self) { + NUM_THREADS.fetch_sub(1, Ordering::Relaxed); + } +} + +// Get a pointer to the latest hash table, creating one if it doesn't exist yet. +unsafe fn get_hashtable() -> *const HashTable { + let mut table = HASHTABLE.load(Ordering::Acquire); + + // If there is no table, create one + if table == 0 { + let new_table = Box::into_raw(HashTable::new(LOAD_FACTOR, ptr::null())); + + // If this fails then it means some other thread created the hash + // table first. + match HASHTABLE.compare_exchange( + 0, + new_table as usize, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return new_table, + Err(x) => table = x, + } + + // Free the table we created + Box::from_raw(new_table); + } + + table as *const HashTable +} + +// Grow the hash table so that it is big enough for the given number of threads. +// This isn't performance-critical since it is only done when a ThreadData is +// created, which only happens once per thread. +unsafe fn grow_hashtable(num_threads: usize) { + // If there is no table, create one + if HASHTABLE.load(Ordering::Relaxed) == 0 { + let new_table = Box::into_raw(HashTable::new(num_threads, ptr::null())); + + // If this fails then it means some other thread created the hash + // table first. + if HASHTABLE + .compare_exchange(0, new_table as usize, Ordering::Release, Ordering::Relaxed) + .is_ok() + { + return; + } + + // Free the table we created + Box::from_raw(new_table); + } + + let mut old_table; + loop { + old_table = HASHTABLE.load(Ordering::Acquire) as *mut HashTable; + + // Check if we need to resize the existing table + if (*old_table).entries.len() >= LOAD_FACTOR * num_threads { + return; + } + + // Lock all buckets in the old table + for b in &(*old_table).entries[..] { + b.mutex.lock(); + } + + // Now check if our table is still the latest one. Another thread could + // have grown the hash table between us reading HASHTABLE and locking + // the buckets. + if HASHTABLE.load(Ordering::Relaxed) == old_table as usize { + break; + } + + // Unlock buckets and try again + for b in &(*old_table).entries[..] { + b.mutex.unlock(); + } + } + + // Create the new table + let new_table = HashTable::new(num_threads, old_table); + + // Move the entries from the old table to the new one + for b in &(*old_table).entries[..] { + let mut current = b.queue_head.get(); + while !current.is_null() { + let next = (*current).next_in_queue.get(); + let hash = hash((*current).key.load(Ordering::Relaxed), new_table.hash_bits); + if new_table.entries[hash].queue_tail.get().is_null() { + new_table.entries[hash].queue_head.set(current); + } else { + (*new_table.entries[hash].queue_tail.get()) + .next_in_queue + .set(current); + } + new_table.entries[hash].queue_tail.set(current); + (*current).next_in_queue.set(ptr::null()); + current = next; + } + } + + // Publish the new table. No races are possible at this point because + // any other thread trying to grow the hash table is blocked on the bucket + // locks in the old table. + HASHTABLE.store(Box::into_raw(new_table) as usize, Ordering::Release); + + // Unlock all buckets in the old table + for b in &(*old_table).entries[..] { + b.mutex.unlock(); + } +} + +// Hash function for addresses +#[cfg(target_pointer_width = "32")] +fn hash(key: usize, bits: u32) -> usize { + key.wrapping_mul(0x9E3779B9) >> (32 - bits) +} +#[cfg(target_pointer_width = "64")] +fn hash(key: usize, bits: u32) -> usize { + key.wrapping_mul(0x9E3779B97F4A7C15) >> (64 - bits) +} + +// Lock the bucket for the given key +unsafe fn lock_bucket<'a>(key: usize) -> &'a Bucket { + let mut bucket; + loop { + let hashtable = get_hashtable(); + + let hash = hash(key, (*hashtable).hash_bits); + bucket = &(*hashtable).entries[hash]; + + // Lock the bucket + bucket.mutex.lock(); + + // If no other thread has rehashed the table before we grabbed the lock + // then we are good to go! The lock we grabbed prevents any rehashes. + if HASHTABLE.load(Ordering::Relaxed) == hashtable as usize { + return bucket; + } + + // Unlock the bucket and try again + bucket.mutex.unlock(); + } +} + +// Lock the bucket for the given key, but check that the key hasn't been changed +// in the meantime due to a requeue. +unsafe fn lock_bucket_checked<'a>(key: &AtomicUsize) -> (usize, &'a Bucket) { + let mut bucket; + loop { + let hashtable = get_hashtable(); + let current_key = key.load(Ordering::Relaxed); + + let hash = hash(current_key, (*hashtable).hash_bits); + bucket = &(*hashtable).entries[hash]; + + // Lock the bucket + bucket.mutex.lock(); + + // Check that both the hash table and key are correct while the bucket + // is locked. Note that the key can't change once we locked the proper + // bucket for it, so we just keep trying until we have the correct key. + if HASHTABLE.load(Ordering::Relaxed) == hashtable as usize + && key.load(Ordering::Relaxed) == current_key + { + return (current_key, bucket); + } + + // Unlock the bucket and try again + bucket.mutex.unlock(); + } +} + +// Lock the two buckets for the given pair of keys +unsafe fn lock_bucket_pair<'a>(key1: usize, key2: usize) -> (&'a Bucket, &'a Bucket) { + let mut bucket1; + loop { + let hashtable = get_hashtable(); + + // Get the lowest bucket first + let hash1 = hash(key1, (*hashtable).hash_bits); + let hash2 = hash(key2, (*hashtable).hash_bits); + if hash1 <= hash2 { + bucket1 = &(*hashtable).entries[hash1]; + } else { + bucket1 = &(*hashtable).entries[hash2]; + } + + // Lock the first bucket + bucket1.mutex.lock(); + + // If no other thread has rehashed the table before we grabbed the lock + // then we are good to go! The lock we grabbed prevents any rehashes. + if HASHTABLE.load(Ordering::Relaxed) == hashtable as usize { + // Now lock the second bucket and return the two buckets + if hash1 == hash2 { + return (bucket1, bucket1); + } else if hash1 < hash2 { + let bucket2 = &(*hashtable).entries[hash2]; + bucket2.mutex.lock(); + return (bucket1, bucket2); + } else { + let bucket2 = &(*hashtable).entries[hash1]; + bucket2.mutex.lock(); + return (bucket2, bucket1); + } + } + + // Unlock the bucket and try again + bucket1.mutex.unlock(); + } +} + +// Unlock a pair of buckets +unsafe fn unlock_bucket_pair(bucket1: &Bucket, bucket2: &Bucket) { + if bucket1 as *const _ == bucket2 as *const _ { + bucket1.mutex.unlock(); + } else if bucket1 as *const _ < bucket2 as *const _ { + bucket2.mutex.unlock(); + bucket1.mutex.unlock(); + } else { + bucket1.mutex.unlock(); + bucket2.mutex.unlock(); + } +} + +/// Result of a park operation. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub enum ParkResult { + /// We were unparked by another thread with the given token. + Unparked(UnparkToken), + + /// The validation callback returned false. + Invalid, + + /// The timeout expired. + TimedOut, +} + +impl ParkResult { + /// Returns true if we were unparked by another thread. + pub fn is_unparked(self) -> bool { + if let ParkResult::Unparked(_) = self { + true + } else { + false + } + } +} + +/// Result of an unpark operation. +#[derive(Copy, Clone, Default, Eq, PartialEq, Debug)] +pub struct UnparkResult { + /// The number of threads that were unparked. + pub unparked_threads: usize, + + /// The number of threads that were requeued. + pub requeued_threads: usize, + + /// Whether there are any threads remaining in the queue. This only returns + /// true if a thread was unparked. + pub have_more_threads: bool, + + /// This is set to true on average once every 0.5ms for any given key. It + /// should be used to switch to a fair unlocking mechanism for a particular + /// unlock. + pub be_fair: bool, + + /// Private field so new fields can be added without breakage. + _sealed: (), +} + +/// Operation that `unpark_requeue` should perform. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub enum RequeueOp { + /// Abort the operation without doing anything. + Abort, + + /// Unpark one thread and requeue the rest onto the target queue. + UnparkOneRequeueRest, + + /// Requeue all threads onto the target queue. + RequeueAll, + + /// Unpark one thread and leave the rest parked. No requeuing is done. + UnparkOne, + + /// Requeue one thread and leave the rest parked on the original queue. + RequeueOne, +} + +/// Operation that `unpark_filter` should perform for each thread. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub enum FilterOp { + /// Unpark the thread and continue scanning the list of parked threads. + Unpark, + + /// Don't unpark the thread and continue scanning the list of parked threads. + Skip, + + /// Don't unpark the thread and stop scanning the list of parked threads. + Stop, +} + +/// A value which is passed from an unparker to a parked thread. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub struct UnparkToken(pub usize); + +/// A value associated with a parked thread which can be used by `unpark_filter`. +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub struct ParkToken(pub usize); + +/// A default unpark token to use. +pub const DEFAULT_UNPARK_TOKEN: UnparkToken = UnparkToken(0); + +/// A default park token to use. +pub const DEFAULT_PARK_TOKEN: ParkToken = ParkToken(0); + +/// Parks the current thread in the queue associated with the given key. +/// +/// The `validate` function is called while the queue is locked and can abort +/// the operation by returning false. If `validate` returns true then the +/// current thread is appended to the queue and the queue is unlocked. +/// +/// The `before_sleep` function is called after the queue is unlocked but before +/// the thread is put to sleep. The thread will then sleep until it is unparked +/// or the given timeout is reached. +/// +/// The `timed_out` function is also called while the queue is locked, but only +/// if the timeout was reached. It is passed the key of the queue it was in when +/// it timed out, which may be different from the original key if +/// `unpark_requeue` was called. It is also passed a bool which indicates +/// whether it was the last thread in the queue. +/// +/// # Safety +/// +/// You should only call this function with an address that you control, since +/// you could otherwise interfere with the operation of other synchronization +/// primitives. +/// +/// The `validate` and `timed_out` functions are called while the queue is +/// locked and must not panic or call into any function in `parking_lot`. +/// +/// The `before_sleep` function is called outside the queue lock and is allowed +/// to call `unpark_one`, `unpark_all`, `unpark_requeue` or `unpark_filter`, but +/// it is not allowed to call `park` or panic. +#[inline] +pub unsafe fn park( + key: usize, + validate: V, + before_sleep: B, + timed_out: T, + park_token: ParkToken, + timeout: Option, +) -> ParkResult +where + V: FnOnce() -> bool, + B: FnOnce(), + T: FnOnce(usize, bool), +{ + let mut v = Some(validate); + let mut b = Some(before_sleep); + let mut t = Some(timed_out); + park_internal( + key, + &mut || v.take().unchecked_unwrap()(), + &mut || b.take().unchecked_unwrap()(), + &mut |key, was_last_thread| t.take().unchecked_unwrap()(key, was_last_thread), + park_token, + timeout, + ) +} + +// Non-generic version to reduce monomorphization cost +unsafe fn park_internal( + key: usize, + validate: &mut FnMut() -> bool, + before_sleep: &mut FnMut(), + timed_out: &mut FnMut(usize, bool), + park_token: ParkToken, + timeout: Option, +) -> ParkResult { + // Grab our thread data, this also ensures that the hash table exists + let mut thread_data = None; + let thread_data = get_thread_data(&mut thread_data); + + // Lock the bucket for the given key + let bucket = lock_bucket(key); + + // If the validation function fails, just return + if !validate() { + bucket.mutex.unlock(); + return ParkResult::Invalid; + } + + // Append our thread data to the queue and unlock the bucket + thread_data.parked_with_timeout.set(timeout.is_some()); + thread_data.next_in_queue.set(ptr::null()); + thread_data.key.store(key, Ordering::Relaxed); + thread_data.park_token.set(park_token); + thread_data.parker.prepare_park(); + if !bucket.queue_head.get().is_null() { + (*bucket.queue_tail.get()).next_in_queue.set(thread_data); + } else { + bucket.queue_head.set(thread_data); + } + bucket.queue_tail.set(thread_data); + bucket.mutex.unlock(); + + // Invoke the pre-sleep callback + before_sleep(); + + // Park our thread and determine whether we were woken up by an unpark or by + // our timeout. Note that this isn't precise: we can still be unparked since + // we are still in the queue. + let unparked = match timeout { + Some(timeout) => thread_data.parker.park_until(timeout), + None => { + thread_data.parker.park(); + // call deadlock detection on_unpark hook + deadlock::on_unpark(thread_data); + true + } + }; + + // If we were unparked, return now + if unparked { + return ParkResult::Unparked(thread_data.unpark_token.get()); + } + + // Lock our bucket again. Note that the hashtable may have been rehashed in + // the meantime. Our key may also have changed if we were requeued. + let (key, bucket) = lock_bucket_checked(&thread_data.key); + + // Now we need to check again if we were unparked or timed out. Unlike the + // last check this is precise because we hold the bucket lock. + if !thread_data.parker.timed_out() { + bucket.mutex.unlock(); + return ParkResult::Unparked(thread_data.unpark_token.get()); + } + + // We timed out, so we now need to remove our thread from the queue + let mut link = &bucket.queue_head; + let mut current = bucket.queue_head.get(); + let mut previous = ptr::null(); + while !current.is_null() { + if current == thread_data { + let next = (*current).next_in_queue.get(); + link.set(next); + let mut was_last_thread = true; + if bucket.queue_tail.get() == current { + bucket.queue_tail.set(previous); + } else { + // Scan the rest of the queue to see if there are any other + // entries with the given key. + let mut scan = next; + while !scan.is_null() { + if (*scan).key.load(Ordering::Relaxed) == key { + was_last_thread = false; + break; + } + scan = (*scan).next_in_queue.get(); + } + } + + // Callback to indicate that we timed out, and whether we were the + // last thread on the queue. + timed_out(key, was_last_thread); + break; + } else { + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + } + + // There should be no way for our thread to have been removed from the queue + // if we timed out. + debug_assert!(!current.is_null()); + + // Unlock the bucket, we are done + bucket.mutex.unlock(); + ParkResult::TimedOut +} + +/// Unparks one thread from the queue associated with the given key. +/// +/// The `callback` function is called while the queue is locked and before the +/// target thread is woken up. The `UnparkResult` argument to the function +/// indicates whether a thread was found in the queue and whether this was the +/// last thread in the queue. This value is also returned by `unpark_one`. +/// +/// The `callback` function should return an `UnparkToken` value which will be +/// passed to the thread that is unparked. If no thread is unparked then the +/// returned value is ignored. +/// +/// # Safety +/// +/// You should only call this function with an address that you control, since +/// you could otherwise interfere with the operation of other synchronization +/// primitives. +/// +/// The `callback` function is called while the queue is locked and must not +/// panic or call into any function in `parking_lot`. +#[inline] +pub unsafe fn unpark_one(key: usize, callback: C) -> UnparkResult +where + C: FnOnce(UnparkResult) -> UnparkToken, +{ + let mut c = Some(callback); + unpark_one_internal(key, &mut |result| c.take().unchecked_unwrap()(result)) +} + +// Non-generic version to reduce monomorphization cost +unsafe fn unpark_one_internal( + key: usize, + callback: &mut FnMut(UnparkResult) -> UnparkToken, +) -> UnparkResult { + // Lock the bucket for the given key + let bucket = lock_bucket(key); + + // Find a thread with a matching key and remove it from the queue + let mut link = &bucket.queue_head; + let mut current = bucket.queue_head.get(); + let mut previous = ptr::null(); + let mut result = UnparkResult::default(); + while !current.is_null() { + if (*current).key.load(Ordering::Relaxed) == key { + // Remove the thread from the queue + let next = (*current).next_in_queue.get(); + link.set(next); + if bucket.queue_tail.get() == current { + bucket.queue_tail.set(previous); + } else { + // Scan the rest of the queue to see if there are any other + // entries with the given key. + let mut scan = next; + while !scan.is_null() { + if (*scan).key.load(Ordering::Relaxed) == key { + result.have_more_threads = true; + break; + } + scan = (*scan).next_in_queue.get(); + } + } + + // Invoke the callback before waking up the thread + result.unparked_threads = 1; + result.be_fair = (*bucket.fair_timeout.get()).should_timeout(); + let token = callback(result); + + // Set the token for the target thread + (*current).unpark_token.set(token); + + // This is a bit tricky: we first lock the ThreadParker to prevent + // the thread from exiting and freeing its ThreadData if its wait + // times out. Then we unlock the queue since we don't want to keep + // the queue locked while we perform a system call. Finally we wake + // up the parked thread. + let handle = (*current).parker.unpark_lock(); + bucket.mutex.unlock(); + handle.unpark(); + + return result; + } else { + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + } + + // No threads with a matching key were found in the bucket + callback(result); + bucket.mutex.unlock(); + result +} + +/// Unparks all threads in the queue associated with the given key. +/// +/// The given `UnparkToken` is passed to all unparked threads. +/// +/// This function returns the number of threads that were unparked. +/// +/// # Safety +/// +/// You should only call this function with an address that you control, since +/// you could otherwise interfere with the operation of other synchronization +/// primitives. +pub unsafe fn unpark_all(key: usize, unpark_token: UnparkToken) -> usize { + // Lock the bucket for the given key + let bucket = lock_bucket(key); + + // Remove all threads with the given key in the bucket + let mut link = &bucket.queue_head; + let mut current = bucket.queue_head.get(); + let mut previous = ptr::null(); + let mut threads = SmallVec::<[_; 8]>::new(); + while !current.is_null() { + if (*current).key.load(Ordering::Relaxed) == key { + // Remove the thread from the queue + let next = (*current).next_in_queue.get(); + link.set(next); + if bucket.queue_tail.get() == current { + bucket.queue_tail.set(previous); + } + + // Set the token for the target thread + (*current).unpark_token.set(unpark_token); + + // Don't wake up threads while holding the queue lock. See comment + // in unpark_one. For now just record which threads we need to wake + // up. + threads.push((*current).parker.unpark_lock()); + current = next; + } else { + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + } + + // Unlock the bucket + bucket.mutex.unlock(); + + // Now that we are outside the lock, wake up all the threads that we removed + // from the queue. + let num_threads = threads.len(); + for handle in threads.into_iter() { + handle.unpark(); + } + + num_threads +} + +/// Removes all threads from the queue associated with `key_from`, optionally +/// unparks the first one and requeues the rest onto the queue associated with +/// `key_to`. +/// +/// The `validate` function is called while both queues are locked. Its return +/// value will determine which operation is performed, or whether the operation +/// should be aborted. See `RequeueOp` for details about the different possible +/// return values. +/// +/// The `callback` function is also called while both queues are locked. It is +/// passed the `RequeueOp` returned by `validate` and an `UnparkResult` +/// indicating whether a thread was unparked and whether there are threads still +/// parked in the new queue. This `UnparkResult` value is also returned by +/// `unpark_requeue`. +/// +/// The `callback` function should return an `UnparkToken` value which will be +/// passed to the thread that is unparked. If no thread is unparked then the +/// returned value is ignored. +/// +/// # Safety +/// +/// You should only call this function with an address that you control, since +/// you could otherwise interfere with the operation of other synchronization +/// primitives. +/// +/// The `validate` and `callback` functions are called while the queue is locked +/// and must not panic or call into any function in `parking_lot`. +#[inline] +pub unsafe fn unpark_requeue( + key_from: usize, + key_to: usize, + validate: V, + callback: C, +) -> UnparkResult +where + V: FnOnce() -> RequeueOp, + C: FnOnce(RequeueOp, UnparkResult) -> UnparkToken, +{ + let mut v = Some(validate); + let mut c = Some(callback); + unpark_requeue_internal( + key_from, + key_to, + &mut || v.take().unchecked_unwrap()(), + &mut |op, r| c.take().unchecked_unwrap()(op, r), + ) +} + +// Non-generic version to reduce monomorphization cost +unsafe fn unpark_requeue_internal( + key_from: usize, + key_to: usize, + validate: &mut FnMut() -> RequeueOp, + callback: &mut FnMut(RequeueOp, UnparkResult) -> UnparkToken, +) -> UnparkResult { + // Lock the two buckets for the given key + let (bucket_from, bucket_to) = lock_bucket_pair(key_from, key_to); + + // If the validation function fails, just return + let mut result = UnparkResult::default(); + let op = validate(); + if op == RequeueOp::Abort { + unlock_bucket_pair(bucket_from, bucket_to); + return result; + } + + // Remove all threads with the given key in the source bucket + let mut link = &bucket_from.queue_head; + let mut current = bucket_from.queue_head.get(); + let mut previous = ptr::null(); + let mut requeue_threads: *const ThreadData = ptr::null(); + let mut requeue_threads_tail: *const ThreadData = ptr::null(); + let mut wakeup_thread = None; + while !current.is_null() { + if (*current).key.load(Ordering::Relaxed) == key_from { + // Remove the thread from the queue + let next = (*current).next_in_queue.get(); + link.set(next); + if bucket_from.queue_tail.get() == current { + bucket_from.queue_tail.set(previous); + } + + // Prepare the first thread for wakeup and requeue the rest. + if (op == RequeueOp::UnparkOneRequeueRest || op == RequeueOp::UnparkOne) + && wakeup_thread.is_none() + { + wakeup_thread = Some(current); + result.unparked_threads = 1; + } else { + if !requeue_threads.is_null() { + (*requeue_threads_tail).next_in_queue.set(current); + } else { + requeue_threads = current; + } + requeue_threads_tail = current; + (*current).key.store(key_to, Ordering::Relaxed); + result.requeued_threads += 1; + } + if op == RequeueOp::UnparkOne || op == RequeueOp::RequeueOne { + // Scan the rest of the queue to see if there are any other + // entries with the given key. + let mut scan = next; + while !scan.is_null() { + if (*scan).key.load(Ordering::Relaxed) == key_from { + result.have_more_threads = true; + break; + } + scan = (*scan).next_in_queue.get(); + } + break; + } + current = next; + } else { + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + } + + // Add the requeued threads to the destination bucket + if !requeue_threads.is_null() { + (*requeue_threads_tail).next_in_queue.set(ptr::null()); + if !bucket_to.queue_head.get().is_null() { + (*bucket_to.queue_tail.get()) + .next_in_queue + .set(requeue_threads); + } else { + bucket_to.queue_head.set(requeue_threads); + } + bucket_to.queue_tail.set(requeue_threads_tail); + } + + // Invoke the callback before waking up the thread + if result.unparked_threads != 0 { + result.be_fair = (*bucket_from.fair_timeout.get()).should_timeout(); + } + let token = callback(op, result); + + // See comment in unpark_one for why we mess with the locking + if let Some(wakeup_thread) = wakeup_thread { + (*wakeup_thread).unpark_token.set(token); + let handle = (*wakeup_thread).parker.unpark_lock(); + unlock_bucket_pair(bucket_from, bucket_to); + handle.unpark(); + } else { + unlock_bucket_pair(bucket_from, bucket_to); + } + + result +} + +/// Unparks a number of threads from the front of the queue associated with +/// `key` depending on the results of a filter function which inspects the +/// `ParkToken` associated with each thread. +/// +/// The `filter` function is called for each thread in the queue or until +/// `FilterOp::Stop` is returned. This function is passed the `ParkToken` +/// associated with a particular thread, which is unparked if `FilterOp::Unpark` +/// is returned. +/// +/// The `callback` function is also called while both queues are locked. It is +/// passed an `UnparkResult` indicating the number of threads that were unparked +/// and whether there are still parked threads in the queue. This `UnparkResult` +/// value is also returned by `unpark_filter`. +/// +/// The `callback` function should return an `UnparkToken` value which will be +/// passed to all threads that are unparked. If no thread is unparked then the +/// returned value is ignored. +/// +/// # Safety +/// +/// You should only call this function with an address that you control, since +/// you could otherwise interfere with the operation of other synchronization +/// primitives. +/// +/// The `filter` and `callback` functions are called while the queue is locked +/// and must not panic or call into any function in `parking_lot`. +#[inline] +pub unsafe fn unpark_filter(key: usize, mut filter: F, callback: C) -> UnparkResult +where + F: FnMut(ParkToken) -> FilterOp, + C: FnOnce(UnparkResult) -> UnparkToken, +{ + let mut c = Some(callback); + unpark_filter_internal(key, &mut filter, &mut |r| c.take().unchecked_unwrap()(r)) +} + +// Non-generic version to reduce monomorphization cost +unsafe fn unpark_filter_internal( + key: usize, + filter: &mut FnMut(ParkToken) -> FilterOp, + callback: &mut FnMut(UnparkResult) -> UnparkToken, +) -> UnparkResult { + // Lock the bucket for the given key + let bucket = lock_bucket(key); + + // Go through the queue looking for threads with a matching key + let mut link = &bucket.queue_head; + let mut current = bucket.queue_head.get(); + let mut previous = ptr::null(); + let mut threads = SmallVec::<[_; 8]>::new(); + let mut result = UnparkResult::default(); + while !current.is_null() { + if (*current).key.load(Ordering::Relaxed) == key { + // Call the filter function with the thread's ParkToken + let next = (*current).next_in_queue.get(); + match filter((*current).park_token.get()) { + FilterOp::Unpark => { + // Remove the thread from the queue + link.set(next); + if bucket.queue_tail.get() == current { + bucket.queue_tail.set(previous); + } + + // Add the thread to our list of threads to unpark + threads.push((current, None)); + + current = next; + } + FilterOp::Skip => { + result.have_more_threads = true; + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + FilterOp::Stop => { + result.have_more_threads = true; + break; + } + } + } else { + link = &(*current).next_in_queue; + previous = current; + current = link.get(); + } + } + + // Invoke the callback before waking up the threads + result.unparked_threads = threads.len(); + if result.unparked_threads != 0 { + result.be_fair = (*bucket.fair_timeout.get()).should_timeout(); + } + let token = callback(result); + + // Pass the token to all threads that are going to be unparked and prepare + // them for unparking. + for t in threads.iter_mut() { + (*t.0).unpark_token.set(token); + t.1 = Some((*t.0).parker.unpark_lock()); + } + + bucket.mutex.unlock(); + + // Now that we are outside the lock, wake up all the threads that we removed + // from the queue. + for (_, handle) in threads.into_iter() { + handle.unchecked_unwrap().unpark(); + } + + result +} + +/// \[Experimental\] Deadlock detection +/// +/// Enabled via the `deadlock_detection` feature flag. +pub mod deadlock { + #[cfg(feature = "deadlock_detection")] + use super::deadlock_impl; + + #[cfg(feature = "deadlock_detection")] + pub(super) use super::deadlock_impl::DeadlockData; + + #[cfg(not(feature = "deadlock_detection"))] + pub(super) struct DeadlockData {} + + #[cfg(not(feature = "deadlock_detection"))] + impl DeadlockData { + pub(super) fn new() -> Self { + DeadlockData {} + } + } + + /// Acquire a resource identified by key in the deadlock detector + /// Noop if deadlock_detection feature isn't enabled. + /// Note: Call after the resource is acquired + #[inline] + pub unsafe fn acquire_resource(_key: usize) { + #[cfg(feature = "deadlock_detection")] + deadlock_impl::acquire_resource(_key); + } + + /// Release a resource identified by key in the deadlock detector. + /// Noop if deadlock_detection feature isn't enabled. + /// Note: Call before the resource is released + /// # Panics + /// Panics if the resource was already released or wasn't acquired in this thread. + #[inline] + pub unsafe fn release_resource(_key: usize) { + #[cfg(feature = "deadlock_detection")] + deadlock_impl::release_resource(_key); + } + + /// Returns all deadlocks detected *since* the last call. + /// Each cycle consist of a vector of `DeadlockedThread`. + #[cfg(feature = "deadlock_detection")] + #[inline] + pub fn check_deadlock() -> Vec> { + deadlock_impl::check_deadlock() + } + + #[inline] + pub(super) unsafe fn on_unpark(_td: &super::ThreadData) { + #[cfg(feature = "deadlock_detection")] + deadlock_impl::on_unpark(_td); + } +} + +#[cfg(feature = "deadlock_detection")] +mod deadlock_impl { + use super::{get_hashtable, get_thread_data, lock_bucket, ThreadData, NUM_THREADS}; + use backtrace::Backtrace; + use petgraph; + use petgraph::graphmap::DiGraphMap; + use std::cell::{Cell, UnsafeCell}; + use std::collections::HashSet; + use std::sync::atomic::Ordering; + use std::sync::mpsc; + use thread_id; + + /// Representation of a deadlocked thread + pub struct DeadlockedThread { + thread_id: usize, + backtrace: Backtrace, + } + + impl DeadlockedThread { + /// The system thread id + pub fn thread_id(&self) -> usize { + self.thread_id + } + + /// The thread backtrace + pub fn backtrace(&self) -> &Backtrace { + &self.backtrace + } + } + + pub struct DeadlockData { + // Currently owned resources (keys) + resources: UnsafeCell>, + + // Set when there's a pending callstack request + deadlocked: Cell, + + // Sender used to report the backtrace + backtrace_sender: UnsafeCell>>, + + // System thread id + thread_id: usize, + } + + impl DeadlockData { + pub fn new() -> Self { + DeadlockData { + resources: UnsafeCell::new(Vec::new()), + deadlocked: Cell::new(false), + backtrace_sender: UnsafeCell::new(None), + thread_id: thread_id::get(), + } + } + } + + pub(super) unsafe fn on_unpark(td: &ThreadData) { + if td.deadlock_data.deadlocked.get() { + let sender = (*td.deadlock_data.backtrace_sender.get()).take().unwrap(); + sender + .send(DeadlockedThread { + thread_id: td.deadlock_data.thread_id, + backtrace: Backtrace::new(), + }) + .unwrap(); + // make sure to close this sender + drop(sender); + + // park until the end of the time + td.parker.prepare_park(); + td.parker.park(); + unreachable!("unparked deadlocked thread!"); + } + } + + pub unsafe fn acquire_resource(key: usize) { + let mut thread_data = None; + let thread_data = get_thread_data(&mut thread_data); + (*thread_data.deadlock_data.resources.get()).push(key); + } + + pub unsafe fn release_resource(key: usize) { + let mut thread_data = None; + let thread_data = get_thread_data(&mut thread_data); + let resources = &mut (*thread_data.deadlock_data.resources.get()); + match resources.iter().rposition(|x| *x == key) { + Some(p) => resources.swap_remove(p), + None => panic!("key {} not found in thread resources", key), + }; + } + + pub fn check_deadlock() -> Vec> { + unsafe { + // fast pass + if check_wait_graph_fast() { + // double check + check_wait_graph_slow() + } else { + Vec::new() + } + } + } + + // Simple algorithm that builds a wait graph f the threads and the resources, + // then checks for the presence of cycles (deadlocks). + // This variant isn't precise as it doesn't lock the entire table before checking + unsafe fn check_wait_graph_fast() -> bool { + let table = get_hashtable(); + let thread_count = NUM_THREADS.load(Ordering::Relaxed); + let mut graph = DiGraphMap::::with_capacity(thread_count * 2, thread_count * 2); + + for b in &(*table).entries[..] { + b.mutex.lock(); + let mut current = b.queue_head.get(); + while !current.is_null() { + if !(*current).parked_with_timeout.get() + && !(*current).deadlock_data.deadlocked.get() + { + // .resources are waiting for their owner + for &resource in &(*(*current).deadlock_data.resources.get()) { + graph.add_edge(resource, current as usize, ()); + } + // owner waits for resource .key + graph.add_edge(current as usize, (*current).key.load(Ordering::Relaxed), ()); + } + current = (*current).next_in_queue.get(); + } + b.mutex.unlock(); + } + + petgraph::algo::is_cyclic_directed(&graph) + } + + #[derive(Hash, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)] + enum WaitGraphNode { + Thread(*const ThreadData), + Resource(usize), + } + + use self::WaitGraphNode::*; + + // Contrary to the _fast variant this locks the entries table before looking for cycles. + // Returns all detected thread wait cycles. + // Note that once a cycle is reported it's never reported again. + unsafe fn check_wait_graph_slow() -> Vec> { + let mut table = get_hashtable(); + loop { + // Lock all buckets in the old table + for b in &(*table).entries[..] { + b.mutex.lock(); + } + + // Now check if our table is still the latest one. Another thread could + // have grown the hash table between us getting and locking the hash table. + let new_table = get_hashtable(); + if new_table == table { + break; + } + + // Unlock buckets and try again + for b in &(*table).entries[..] { + b.mutex.unlock(); + } + + table = new_table; + } + + let thread_count = NUM_THREADS.load(Ordering::Relaxed); + let mut graph = + DiGraphMap::::with_capacity(thread_count * 2, thread_count * 2); + + for b in &(*table).entries[..] { + let mut current = b.queue_head.get(); + while !current.is_null() { + if !(*current).parked_with_timeout.get() + && !(*current).deadlock_data.deadlocked.get() + { + // .resources are waiting for their owner + for &resource in &(*(*current).deadlock_data.resources.get()) { + graph.add_edge(Resource(resource), Thread(current), ()); + } + // owner waits for resource .key + graph.add_edge( + Thread(current), + Resource((*current).key.load(Ordering::Relaxed)), + (), + ); + } + current = (*current).next_in_queue.get(); + } + } + + for b in &(*table).entries[..] { + b.mutex.unlock(); + } + + // find cycles + let cycles = graph_cycles(&graph); + + let mut results = Vec::with_capacity(cycles.len()); + + for cycle in cycles { + let (sender, receiver) = mpsc::channel(); + for td in cycle { + let bucket = lock_bucket((*td).key.load(Ordering::Relaxed)); + (*td).deadlock_data.deadlocked.set(true); + *(*td).deadlock_data.backtrace_sender.get() = Some(sender.clone()); + let handle = (*td).parker.unpark_lock(); + bucket.mutex.unlock(); + // unpark the deadlocked thread! + // on unpark it'll notice the deadlocked flag and report back + handle.unpark(); + } + // make sure to drop our sender before collecting results + drop(sender); + results.push(receiver.iter().collect()); + } + + results + } + + // normalize a cycle to start with the "smallest" node + fn normalize_cycle(input: &[T]) -> Vec { + let min_pos = input + .iter() + .enumerate() + .min_by_key(|&(_, &t)| t) + .map(|(p, _)| p) + .unwrap_or(0); + input + .iter() + .cycle() + .skip(min_pos) + .take(input.len()) + .cloned() + .collect() + } + + // returns all thread cycles in the wait graph + fn graph_cycles(g: &DiGraphMap) -> Vec> { + use petgraph::visit::depth_first_search; + use petgraph::visit::DfsEvent; + use petgraph::visit::NodeIndexable; + + let mut cycles = HashSet::new(); + let mut path = Vec::with_capacity(g.node_bound()); + // start from threads to get the correct threads cycle + let threads = g + .nodes() + .filter(|n| if let &Thread(_) = n { true } else { false }); + + depth_first_search(g, threads, |e| match e { + DfsEvent::Discover(Thread(n), _) => path.push(n), + DfsEvent::Finish(Thread(_), _) => { + path.pop(); + } + DfsEvent::BackEdge(_, Thread(n)) => { + let from = path.iter().rposition(|&i| i == n).unwrap(); + cycles.insert(normalize_cycle(&path[from..])); + } + _ => (), + }); + + cycles.iter().cloned().collect() + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/spinwait.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/spinwait.rs new file mode 100644 index 0000000..4185026 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/spinwait.rs @@ -0,0 +1,125 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +#[cfg(unix)] +use libc; +use std::sync::atomic::spin_loop_hint; +#[cfg(not(any(windows, unix)))] +use std::thread; +#[cfg(windows)] +use winapi; + +// Yields the rest of the current timeslice to the OS +#[cfg(windows)] +#[inline] +fn thread_yield() { + // Note that this is manually defined here rather than using the definition + // through `winapi`. The `winapi` definition comes from the `synchapi` + // header which enables the "synchronization.lib" library. It turns out, + // however that `Sleep` comes from `kernel32.dll` so this activation isn't + // necessary. + // + // This was originally identified in rust-lang/rust where on MinGW the + // libsynchronization.a library pulls in a dependency on a newer DLL not + // present in older versions of Windows. (see rust-lang/rust#49438) + // + // This is a bit of a hack for now and ideally we'd fix MinGW's own import + // libraries, but that'll probably take a lot longer than patching this here + // and avoiding the `synchapi` feature entirely. + extern "system" { + fn Sleep(a: winapi::shared::minwindef::DWORD); + } + unsafe { + // We don't use SwitchToThread here because it doesn't consider all + // threads in the system and the thread we are waiting for may not get + // selected. + Sleep(0); + } +} +#[cfg(unix)] +#[inline] +fn thread_yield() { + unsafe { + libc::sched_yield(); + } +} +#[cfg(not(any(windows, unix)))] +#[inline] +fn thread_yield() { + thread::yield_now(); +} + +// Wastes some CPU time for the given number of iterations, +// using a hint to indicate to the CPU that we are spinning. +#[inline] +fn cpu_relax(iterations: u32) { + for _ in 0..iterations { + spin_loop_hint() + } +} + +/// A counter used to perform exponential backoff in spin loops. +pub struct SpinWait { + counter: u32, +} + +impl SpinWait { + /// Creates a new `SpinWait`. + #[inline] + pub fn new() -> SpinWait { + SpinWait { counter: 0 } + } + + /// Resets a `SpinWait` to its initial state. + #[inline] + pub fn reset(&mut self) { + self.counter = 0; + } + + /// Spins until the sleep threshold has been reached. + /// + /// This function returns whether the sleep threshold has been reached, at + /// which point further spinning has diminishing returns and the thread + /// should be parked instead. + /// + /// The spin strategy will initially use a CPU-bound loop but will fall back + /// to yielding the CPU to the OS after a few iterations. + #[inline] + pub fn spin(&mut self) -> bool { + if self.counter >= 10 { + return false; + } + self.counter += 1; + if self.counter <= 3 { + cpu_relax(1 << self.counter); + } else { + thread_yield(); + } + true + } + + /// Spins without yielding the thread to the OS. + /// + /// Instead, the backoff is simply capped at a maximum value. This can be + /// used to improve throughput in `compare_exchange` loops that have high + /// contention. + #[inline] + pub fn spin_no_yield(&mut self) { + self.counter += 1; + if self.counter > 10 { + self.counter = 10; + } + cpu_relax(1 << self.counter); + } +} + +impl Default for SpinWait { + #[inline] + fn default() -> SpinWait { + SpinWait::new() + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/generic.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/generic.rs new file mode 100644 index 0000000..d06406a --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/generic.rs @@ -0,0 +1,98 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::cell::Cell; +use std::sync::{Condvar, Mutex, MutexGuard}; +use std::time::Instant; + +// Helper type for putting a thread to sleep until some other thread wakes it up +pub struct ThreadParker { + should_park: Cell, + mutex: Mutex<()>, + condvar: Condvar, +} + +impl ThreadParker { + pub fn new() -> ThreadParker { + ThreadParker { + should_park: Cell::new(false), + mutex: Mutex::new(()), + condvar: Condvar::new(), + } + } + + // Prepares the parker. This should be called before adding it to the queue. + pub unsafe fn prepare_park(&self) { + self.should_park.set(true); + } + + // Checks if the park timed out. This should be called while holding the + // queue lock after park_until has returned false. + pub unsafe fn timed_out(&self) -> bool { + // We need to grab the mutex here because another thread may be + // concurrently executing UnparkHandle::unpark, which is done without + // holding the queue lock. + let _lock = self.mutex.lock().unwrap(); + self.should_park.get() + } + + // Parks the thread until it is unparked. This should be called after it has + // been added to the queue, after unlocking the queue. + pub unsafe fn park(&self) { + let mut lock = self.mutex.lock().unwrap(); + while self.should_park.get() { + lock = self.condvar.wait(lock).unwrap(); + } + } + + // Parks the thread until it is unparked or the timeout is reached. This + // should be called after it has been added to the queue, after unlocking + // the queue. Returns true if we were unparked and false if we timed out. + pub unsafe fn park_until(&self, timeout: Instant) -> bool { + let mut lock = self.mutex.lock().unwrap(); + while self.should_park.get() { + let now = Instant::now(); + if timeout <= now { + return false; + } + let (new_lock, _) = self.condvar.wait_timeout(lock, timeout - now).unwrap(); + lock = new_lock; + } + true + } + + // Locks the parker to prevent the target thread from exiting. This is + // necessary to ensure that thread-local ThreadData objects remain valid. + // This should be called while holding the queue lock. + pub unsafe fn unpark_lock(&self) -> UnparkHandle { + UnparkHandle { + thread_parker: self, + _guard: self.mutex.lock().unwrap(), + } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub struct UnparkHandle<'a> { + thread_parker: *const ThreadParker, + _guard: MutexGuard<'a, ()>, +} + +impl<'a> UnparkHandle<'a> { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + (*self.thread_parker).should_park.set(false); + + // We notify while holding the lock here to avoid races with the target + // thread. In particular, the thread could exit after we unlock the + // mutex, which would make the condvar access invalid memory. + (*self.thread_parker).condvar.notify_one(); + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/linux.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/linux.rs new file mode 100644 index 0000000..4a13d73 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/linux.rs @@ -0,0 +1,137 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use libc; +use std::sync::atomic::{AtomicI32, Ordering}; +use std::time::Instant; + +const FUTEX_WAIT: i32 = 0; +const FUTEX_WAKE: i32 = 1; +const FUTEX_PRIVATE: i32 = 128; + +// x32 Linux uses a non-standard type for tv_nsec in timespec. +// See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +#[allow(non_camel_case_types)] +type tv_nsec_t = i64; +#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] +#[allow(non_camel_case_types)] +type tv_nsec_t = libc::c_long; + +// Helper type for putting a thread to sleep until some other thread wakes it up +pub struct ThreadParker { + futex: AtomicI32, +} + +impl ThreadParker { + pub fn new() -> ThreadParker { + ThreadParker { + futex: AtomicI32::new(0), + } + } + + // Prepares the parker. This should be called before adding it to the queue. + pub unsafe fn prepare_park(&self) { + self.futex.store(1, Ordering::Relaxed); + } + + // Checks if the park timed out. This should be called while holding the + // queue lock after park_until has returned false. + pub unsafe fn timed_out(&self) -> bool { + self.futex.load(Ordering::Relaxed) != 0 + } + + // Parks the thread until it is unparked. This should be called after it has + // been added to the queue, after unlocking the queue. + pub unsafe fn park(&self) { + while self.futex.load(Ordering::Acquire) != 0 { + let r = libc::syscall( + libc::SYS_futex, + &self.futex, + FUTEX_WAIT | FUTEX_PRIVATE, + 1, + 0, + ); + debug_assert!(r == 0 || r == -1); + if r == -1 { + debug_assert!( + *libc::__errno_location() == libc::EINTR + || *libc::__errno_location() == libc::EAGAIN + ); + } + } + } + + // Parks the thread until it is unparked or the timeout is reached. This + // should be called after it has been added to the queue, after unlocking + // the queue. Returns true if we were unparked and false if we timed out. + pub unsafe fn park_until(&self, timeout: Instant) -> bool { + while self.futex.load(Ordering::Acquire) != 0 { + let now = Instant::now(); + if timeout <= now { + return false; + } + let diff = timeout - now; + if diff.as_secs() as libc::time_t as u64 != diff.as_secs() { + // Timeout overflowed, just sleep indefinitely + self.park(); + return true; + } + let ts = libc::timespec { + tv_sec: diff.as_secs() as libc::time_t, + tv_nsec: diff.subsec_nanos() as tv_nsec_t, + }; + let r = libc::syscall( + libc::SYS_futex, + &self.futex, + FUTEX_WAIT | FUTEX_PRIVATE, + 1, + &ts, + ); + debug_assert!(r == 0 || r == -1); + if r == -1 { + debug_assert!( + *libc::__errno_location() == libc::EINTR + || *libc::__errno_location() == libc::EAGAIN + || *libc::__errno_location() == libc::ETIMEDOUT + ); + } + } + true + } + + // Locks the parker to prevent the target thread from exiting. This is + // necessary to ensure that thread-local ThreadData objects remain valid. + // This should be called while holding the queue lock. + pub unsafe fn unpark_lock(&self) -> UnparkHandle { + // We don't need to lock anything, just clear the state + self.futex.store(0, Ordering::Release); + + UnparkHandle { futex: &self.futex } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub struct UnparkHandle { + futex: *const AtomicI32, +} + +impl UnparkHandle { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + // The thread data may have been freed at this point, but it doesn't + // matter since the syscall will just return EFAULT in that case. + let r = libc::syscall(libc::SYS_futex, self.futex, FUTEX_WAKE | FUTEX_PRIVATE, 1); + debug_assert!(r == 0 || r == 1 || r == -1); + if r == -1 { + debug_assert_eq!(*libc::__errno_location(), libc::EFAULT); + } + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/unix.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/unix.rs new file mode 100644 index 0000000..169586b --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/unix.rs @@ -0,0 +1,242 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use libc; +use std::cell::{Cell, UnsafeCell}; +use std::mem; +#[cfg(any(target_os = "macos", target_os = "ios"))] +use std::ptr; +use std::time::{Duration, Instant}; + +// x32 Linux uses a non-standard type for tv_nsec in timespec. +// See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +#[allow(non_camel_case_types)] +type tv_nsec_t = i64; +#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] +#[allow(non_camel_case_types)] +type tv_nsec_t = libc::c_long; + +// Helper type for putting a thread to sleep until some other thread wakes it up +pub struct ThreadParker { + should_park: Cell, + mutex: UnsafeCell, + condvar: UnsafeCell, + initialized: Cell, +} + +impl ThreadParker { + pub fn new() -> ThreadParker { + ThreadParker { + should_park: Cell::new(false), + mutex: UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER), + condvar: UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER), + initialized: Cell::new(false), + } + } + + // Initializes the condvar to use CLOCK_MONOTONIC instead of CLOCK_REALTIME. + #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "android" + ))] + unsafe fn init(&self) {} + #[cfg(not(any( + target_os = "macos", + target_os = "ios", + target_os = "android" + )))] + unsafe fn init(&self) { + let mut attr: libc::pthread_condattr_t = mem::uninitialized(); + let r = libc::pthread_condattr_init(&mut attr); + debug_assert_eq!(r, 0); + let r = libc::pthread_condattr_setclock(&mut attr, libc::CLOCK_MONOTONIC); + debug_assert_eq!(r, 0); + let r = libc::pthread_cond_init(self.condvar.get(), &attr); + debug_assert_eq!(r, 0); + let r = libc::pthread_condattr_destroy(&mut attr); + debug_assert_eq!(r, 0); + } + + // Prepares the parker. This should be called before adding it to the queue. + pub unsafe fn prepare_park(&self) { + self.should_park.set(true); + if !self.initialized.get() { + self.init(); + self.initialized.set(true); + } + } + + // Checks if the park timed out. This should be called while holding the + // queue lock after park_until has returned false. + pub unsafe fn timed_out(&self) -> bool { + // We need to grab the mutex here because another thread may be + // concurrently executing UnparkHandle::unpark, which is done without + // holding the queue lock. + let r = libc::pthread_mutex_lock(self.mutex.get()); + debug_assert_eq!(r, 0); + let should_park = self.should_park.get(); + let r = libc::pthread_mutex_unlock(self.mutex.get()); + debug_assert_eq!(r, 0); + should_park + } + + // Parks the thread until it is unparked. This should be called after it has + // been added to the queue, after unlocking the queue. + pub unsafe fn park(&self) { + let r = libc::pthread_mutex_lock(self.mutex.get()); + debug_assert_eq!(r, 0); + while self.should_park.get() { + let r = libc::pthread_cond_wait(self.condvar.get(), self.mutex.get()); + debug_assert_eq!(r, 0); + } + let r = libc::pthread_mutex_unlock(self.mutex.get()); + debug_assert_eq!(r, 0); + } + + // Parks the thread until it is unparked or the timeout is reached. This + // should be called after it has been added to the queue, after unlocking + // the queue. Returns true if we were unparked and false if we timed out. + pub unsafe fn park_until(&self, timeout: Instant) -> bool { + let r = libc::pthread_mutex_lock(self.mutex.get()); + debug_assert_eq!(r, 0); + while self.should_park.get() { + let now = Instant::now(); + if timeout <= now { + let r = libc::pthread_mutex_unlock(self.mutex.get()); + debug_assert_eq!(r, 0); + return false; + } + + if let Some(ts) = timeout_to_timespec(timeout - now) { + let r = libc::pthread_cond_timedwait(self.condvar.get(), self.mutex.get(), &ts); + if ts.tv_sec < 0 { + // On some systems, negative timeouts will return EINVAL. In + // that case we won't sleep and will just busy loop instead, + // which is the best we can do. + debug_assert!(r == 0 || r == libc::ETIMEDOUT || r == libc::EINVAL); + } else { + debug_assert!(r == 0 || r == libc::ETIMEDOUT); + } + } else { + // Timeout calculation overflowed, just sleep indefinitely + let r = libc::pthread_cond_wait(self.condvar.get(), self.mutex.get()); + debug_assert_eq!(r, 0); + } + } + let r = libc::pthread_mutex_unlock(self.mutex.get()); + debug_assert_eq!(r, 0); + true + } + + // Locks the parker to prevent the target thread from exiting. This is + // necessary to ensure that thread-local ThreadData objects remain valid. + // This should be called while holding the queue lock. + pub unsafe fn unpark_lock(&self) -> UnparkHandle { + let r = libc::pthread_mutex_lock(self.mutex.get()); + debug_assert_eq!(r, 0); + + UnparkHandle { + thread_parker: self, + } + } +} + +impl Drop for ThreadParker { + fn drop(&mut self) { + // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a + // mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER. + // Once it is used (locked/unlocked) or pthread_mutex_init() is called, + // this behaviour no longer occurs. The same applies to condvars. + unsafe { + let r = libc::pthread_mutex_destroy(self.mutex.get()); + if cfg!(target_os = "dragonfly") { + debug_assert!(r == 0 || r == libc::EINVAL); + } else { + debug_assert_eq!(r, 0); + } + let r = libc::pthread_cond_destroy(self.condvar.get()); + if cfg!(target_os = "dragonfly") { + debug_assert!(r == 0 || r == libc::EINVAL); + } else { + debug_assert_eq!(r, 0); + } + } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub struct UnparkHandle { + thread_parker: *const ThreadParker, +} + +impl UnparkHandle { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + (*self.thread_parker).should_park.set(false); + + // We notify while holding the lock here to avoid races with the target + // thread. In particular, the thread could exit after we unlock the + // mutex, which would make the condvar access invalid memory. + let r = libc::pthread_cond_signal((*self.thread_parker).condvar.get()); + debug_assert_eq!(r, 0); + let r = libc::pthread_mutex_unlock((*self.thread_parker).mutex.get()); + debug_assert_eq!(r, 0); + } +} + +// Returns the current time on the clock used by pthread_cond_t as a timespec. +#[cfg(any(target_os = "macos", target_os = "ios"))] +unsafe fn timespec_now() -> libc::timespec { + let mut now: libc::timeval = mem::uninitialized(); + let r = libc::gettimeofday(&mut now, ptr::null_mut()); + debug_assert_eq!(r, 0); + libc::timespec { + tv_sec: now.tv_sec, + tv_nsec: now.tv_usec as tv_nsec_t * 1000, + } +} +#[cfg(not(any(target_os = "macos", target_os = "ios")))] +unsafe fn timespec_now() -> libc::timespec { + let mut now: libc::timespec = mem::uninitialized(); + let clock = if cfg!(target_os = "android") { + // Android doesn't support pthread_condattr_setclock, so we need to + // specify the timeout in CLOCK_REALTIME. + libc::CLOCK_REALTIME + } else { + libc::CLOCK_MONOTONIC + }; + let r = libc::clock_gettime(clock, &mut now); + debug_assert_eq!(r, 0); + now +} + +// Converts a relative timeout into an absolute timeout in the clock used by +// pthread_cond_t. +unsafe fn timeout_to_timespec(timeout: Duration) -> Option { + // Handle overflows early on + if timeout.as_secs() > libc::time_t::max_value() as u64 { + return None; + } + + let now = timespec_now(); + let mut nsec = now.tv_nsec + timeout.subsec_nanos() as tv_nsec_t; + let mut sec = now.tv_sec.checked_add(timeout.as_secs() as libc::time_t); + if nsec >= 1_000_000_000 { + nsec -= 1_000_000_000; + sec = sec.and_then(|sec| sec.checked_add(1)); + } + + sec.map(|sec| libc::timespec { + tv_nsec: nsec, + tv_sec: sec, + }) +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/windows/keyed_event.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/windows/keyed_event.rs new file mode 100644 index 0000000..0e32fce --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/windows/keyed_event.rs @@ -0,0 +1,197 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::mem; +use std::ptr; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::time::Instant; + +use winapi::shared::minwindef::{TRUE, ULONG}; +use winapi::shared::ntdef::NTSTATUS; +use winapi::shared::ntstatus::{STATUS_SUCCESS, STATUS_TIMEOUT}; +use winapi::um::handleapi::CloseHandle; +use winapi::um::libloaderapi::{GetModuleHandleA, GetProcAddress}; +use winapi::um::winnt::{ACCESS_MASK, GENERIC_READ, GENERIC_WRITE, LPCSTR}; +use winapi::um::winnt::{BOOLEAN, HANDLE, LARGE_INTEGER, PHANDLE, PLARGE_INTEGER, PVOID}; + +const STATE_UNPARKED: usize = 0; +const STATE_PARKED: usize = 1; +const STATE_TIMED_OUT: usize = 2; + +#[allow(non_snake_case)] +pub struct KeyedEvent { + handle: HANDLE, + NtReleaseKeyedEvent: extern "system" fn( + EventHandle: HANDLE, + Key: PVOID, + Alertable: BOOLEAN, + Timeout: PLARGE_INTEGER, + ) -> NTSTATUS, + NtWaitForKeyedEvent: extern "system" fn( + EventHandle: HANDLE, + Key: PVOID, + Alertable: BOOLEAN, + Timeout: PLARGE_INTEGER, + ) -> NTSTATUS, +} + +impl KeyedEvent { + unsafe fn wait_for(&self, key: PVOID, timeout: PLARGE_INTEGER) -> NTSTATUS { + (self.NtWaitForKeyedEvent)(self.handle, key, 0, timeout) + } + + unsafe fn release(&self, key: PVOID) -> NTSTATUS { + (self.NtReleaseKeyedEvent)(self.handle, key, 0, ptr::null_mut()) + } + + #[allow(non_snake_case)] + pub unsafe fn create() -> Option { + let ntdll = GetModuleHandleA(b"ntdll.dll\0".as_ptr() as LPCSTR); + if ntdll.is_null() { + return None; + } + + let NtCreateKeyedEvent = GetProcAddress(ntdll, b"NtCreateKeyedEvent\0".as_ptr() as LPCSTR); + if NtCreateKeyedEvent.is_null() { + return None; + } + let NtReleaseKeyedEvent = + GetProcAddress(ntdll, b"NtReleaseKeyedEvent\0".as_ptr() as LPCSTR); + if NtReleaseKeyedEvent.is_null() { + return None; + } + let NtWaitForKeyedEvent = + GetProcAddress(ntdll, b"NtWaitForKeyedEvent\0".as_ptr() as LPCSTR); + if NtWaitForKeyedEvent.is_null() { + return None; + } + + let NtCreateKeyedEvent: extern "system" fn( + KeyedEventHandle: PHANDLE, + DesiredAccess: ACCESS_MASK, + ObjectAttributes: PVOID, + Flags: ULONG, + ) -> NTSTATUS = mem::transmute(NtCreateKeyedEvent); + let mut handle = mem::uninitialized(); + let status = NtCreateKeyedEvent( + &mut handle, + GENERIC_READ | GENERIC_WRITE, + ptr::null_mut(), + 0, + ); + if status != STATUS_SUCCESS { + return None; + } + + Some(KeyedEvent { + handle, + NtReleaseKeyedEvent: mem::transmute(NtReleaseKeyedEvent), + NtWaitForKeyedEvent: mem::transmute(NtWaitForKeyedEvent), + }) + } + + pub unsafe fn prepare_park(&'static self, key: &AtomicUsize) { + key.store(STATE_PARKED, Ordering::Relaxed); + } + + pub unsafe fn timed_out(&'static self, key: &AtomicUsize) -> bool { + key.load(Ordering::Relaxed) == STATE_TIMED_OUT + } + + pub unsafe fn park(&'static self, key: &AtomicUsize) { + let status = self.wait_for(key as *const _ as PVOID, ptr::null_mut()); + debug_assert_eq!(status, STATUS_SUCCESS); + } + + pub unsafe fn park_until(&'static self, key: &AtomicUsize, timeout: Instant) -> bool { + let now = Instant::now(); + if timeout <= now { + // If another thread unparked us, we need to call + // NtWaitForKeyedEvent otherwise that thread will stay stuck at + // NtReleaseKeyedEvent. + if key.swap(STATE_TIMED_OUT, Ordering::Relaxed) == STATE_UNPARKED { + self.park(key); + return true; + } + return false; + } + + // NT uses a timeout in units of 100ns. We use a negative value to + // indicate a relative timeout based on a monotonic clock. + let mut nt_timeout: LARGE_INTEGER = mem::zeroed(); + let diff = timeout - now; + let value = (diff.as_secs() as i64) + .checked_mul(-10000000) + .and_then(|x| x.checked_sub((diff.subsec_nanos() as i64 + 99) / 100)); + + match value { + Some(x) => *nt_timeout.QuadPart_mut() = x, + None => { + // Timeout overflowed, just sleep indefinitely + self.park(key); + return true; + } + }; + + let status = self.wait_for(key as *const _ as PVOID, &mut nt_timeout); + if status == STATUS_SUCCESS { + return true; + } + debug_assert_eq!(status, STATUS_TIMEOUT); + + // If another thread unparked us, we need to call NtWaitForKeyedEvent + // otherwise that thread will stay stuck at NtReleaseKeyedEvent. + if key.swap(STATE_TIMED_OUT, Ordering::Relaxed) == STATE_UNPARKED { + self.park(key); + return true; + } + false + } + + pub unsafe fn unpark_lock(&'static self, key: &AtomicUsize) -> UnparkHandle { + // If the state was STATE_PARKED then we need to wake up the thread + if key.swap(STATE_UNPARKED, Ordering::Relaxed) == STATE_PARKED { + UnparkHandle { + key: key, + keyed_event: self, + } + } else { + UnparkHandle { + key: ptr::null(), + keyed_event: self, + } + } + } +} + +impl Drop for KeyedEvent { + fn drop(&mut self) { + unsafe { + let ok = CloseHandle(self.handle); + debug_assert_eq!(ok, TRUE); + } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub struct UnparkHandle { + key: *const AtomicUsize, + keyed_event: &'static KeyedEvent, +} + +impl UnparkHandle { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + if !self.key.is_null() { + let status = self.keyed_event.release(self.key as PVOID); + debug_assert_eq!(status, STATUS_SUCCESS); + } + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/windows/mod.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/windows/mod.rs new file mode 100644 index 0000000..a91ab61 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/windows/mod.rs @@ -0,0 +1,136 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use std::time::Instant; + +mod keyed_event; +mod waitaddress; + +enum Backend { + KeyedEvent(keyed_event::KeyedEvent), + WaitAddress(waitaddress::WaitAddress), +} + +impl Backend { + unsafe fn get() -> &'static Backend { + static BACKEND: AtomicUsize = ATOMIC_USIZE_INIT; + + // Fast path: use the existing object + let backend = BACKEND.load(Ordering::Acquire); + if backend != 0 { + return &*(backend as *const Backend); + }; + + // Try to create a new Backend + let backend; + if let Some(waitaddress) = waitaddress::WaitAddress::create() { + backend = Backend::WaitAddress(waitaddress); + } else if let Some(keyed_event) = keyed_event::KeyedEvent::create() { + backend = Backend::KeyedEvent(keyed_event); + } else { + panic!( + "parking_lot requires either NT Keyed Events (WinXP+) or \ + WaitOnAddress/WakeByAddress (Win8+)" + ); + } + + // Try to create a new object + let backend = Box::into_raw(Box::new(backend)); + match BACKEND.compare_exchange(0, backend as usize, Ordering::Release, Ordering::Relaxed) { + Ok(_) => &*(backend as *const Backend), + Err(x) => { + // We lost the race, free our object and return the global one + Box::from_raw(backend); + &*(x as *const Backend) + } + } + } +} + +// Helper type for putting a thread to sleep until some other thread wakes it up +pub struct ThreadParker { + key: AtomicUsize, + backend: &'static Backend, +} + +impl ThreadParker { + pub fn new() -> ThreadParker { + // Initialize the backend here to ensure we don't get any panics + // later on, which could leave synchronization primitives in a broken + // state. + ThreadParker { + key: AtomicUsize::new(0), + backend: unsafe { Backend::get() }, + } + } + + // Prepares the parker. This should be called before adding it to the queue. + pub unsafe fn prepare_park(&self) { + match *self.backend { + Backend::KeyedEvent(ref x) => x.prepare_park(&self.key), + Backend::WaitAddress(ref x) => x.prepare_park(&self.key), + } + } + + // Checks if the park timed out. This should be called while holding the + // queue lock after park_until has returned false. + pub unsafe fn timed_out(&self) -> bool { + match *self.backend { + Backend::KeyedEvent(ref x) => x.timed_out(&self.key), + Backend::WaitAddress(ref x) => x.timed_out(&self.key), + } + } + + // Parks the thread until it is unparked. This should be called after it has + // been added to the queue, after unlocking the queue. + pub unsafe fn park(&self) { + match *self.backend { + Backend::KeyedEvent(ref x) => x.park(&self.key), + Backend::WaitAddress(ref x) => x.park(&self.key), + } + } + + // Parks the thread until it is unparked or the timeout is reached. This + // should be called after it has been added to the queue, after unlocking + // the queue. Returns true if we were unparked and false if we timed out. + pub unsafe fn park_until(&self, timeout: Instant) -> bool { + match *self.backend { + Backend::KeyedEvent(ref x) => x.park_until(&self.key, timeout), + Backend::WaitAddress(ref x) => x.park_until(&self.key, timeout), + } + } + + // Locks the parker to prevent the target thread from exiting. This is + // necessary to ensure that thread-local ThreadData objects remain valid. + // This should be called while holding the queue lock. + pub unsafe fn unpark_lock(&self) -> UnparkHandle { + match *self.backend { + Backend::KeyedEvent(ref x) => UnparkHandle::KeyedEvent(x.unpark_lock(&self.key)), + Backend::WaitAddress(ref x) => UnparkHandle::WaitAddress(x.unpark_lock(&self.key)), + } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub enum UnparkHandle { + KeyedEvent(keyed_event::UnparkHandle), + WaitAddress(waitaddress::UnparkHandle), +} + +impl UnparkHandle { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + match self { + UnparkHandle::KeyedEvent(x) => x.unpark(), + UnparkHandle::WaitAddress(x) => x.unpark(), + } + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/windows/waitaddress.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/windows/waitaddress.rs new file mode 100644 index 0000000..1d9fca8 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/thread_parker/windows/waitaddress.rs @@ -0,0 +1,134 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::mem; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::time::Instant; + +use winapi::shared::basetsd::SIZE_T; +use winapi::shared::minwindef::{BOOL, DWORD, FALSE, TRUE}; +use winapi::shared::winerror::ERROR_TIMEOUT; +use winapi::um::errhandlingapi::GetLastError; +use winapi::um::libloaderapi::{GetModuleHandleA, GetProcAddress}; +use winapi::um::winbase::INFINITE; +use winapi::um::winnt::{LPCSTR, PVOID}; + +#[allow(non_snake_case)] +pub struct WaitAddress { + WaitOnAddress: extern "system" fn( + Address: PVOID, + CompareAddress: PVOID, + AddressSize: SIZE_T, + dwMilliseconds: DWORD, + ) -> BOOL, + WakeByAddressSingle: extern "system" fn(Address: PVOID), +} + +impl WaitAddress { + #[allow(non_snake_case)] + pub unsafe fn create() -> Option { + // MSDN claims that that WaitOnAddress and WakeByAddressSingle are + // located in kernel32.dll, but they are lying... + let synch_dll = GetModuleHandleA(b"api-ms-win-core-synch-l1-2-0.dll\0".as_ptr() as LPCSTR); + if synch_dll.is_null() { + return None; + } + + let WaitOnAddress = GetProcAddress(synch_dll, b"WaitOnAddress\0".as_ptr() as LPCSTR); + if WaitOnAddress.is_null() { + return None; + } + let WakeByAddressSingle = + GetProcAddress(synch_dll, b"WakeByAddressSingle\0".as_ptr() as LPCSTR); + if WakeByAddressSingle.is_null() { + return None; + } + Some(WaitAddress { + WaitOnAddress: mem::transmute(WaitOnAddress), + WakeByAddressSingle: mem::transmute(WakeByAddressSingle), + }) + } + + pub unsafe fn prepare_park(&'static self, key: &AtomicUsize) { + key.store(1, Ordering::Relaxed); + } + + pub unsafe fn timed_out(&'static self, key: &AtomicUsize) -> bool { + key.load(Ordering::Relaxed) != 0 + } + + pub unsafe fn park(&'static self, key: &AtomicUsize) { + while key.load(Ordering::Acquire) != 0 { + let cmp = 1usize; + let r = (self.WaitOnAddress)( + key as *const _ as PVOID, + &cmp as *const _ as PVOID, + mem::size_of::() as SIZE_T, + INFINITE, + ); + debug_assert!(r == TRUE); + } + } + + pub unsafe fn park_until(&'static self, key: &AtomicUsize, timeout: Instant) -> bool { + while key.load(Ordering::Acquire) != 0 { + let now = Instant::now(); + if timeout <= now { + return false; + } + let diff = timeout - now; + let timeout = diff + .as_secs() + .checked_mul(1000) + .and_then(|x| x.checked_add((diff.subsec_nanos() as u64 + 999999) / 1000000)) + .map(|ms| { + if ms > ::max_value() as u64 { + INFINITE + } else { + ms as DWORD + } + }).unwrap_or(INFINITE); + let cmp = 1usize; + let r = (self.WaitOnAddress)( + key as *const _ as PVOID, + &cmp as *const _ as PVOID, + mem::size_of::() as SIZE_T, + timeout, + ); + if r == FALSE { + debug_assert_eq!(GetLastError(), ERROR_TIMEOUT); + } + } + true + } + + pub unsafe fn unpark_lock(&'static self, key: &AtomicUsize) -> UnparkHandle { + // We don't need to lock anything, just clear the state + key.store(0, Ordering::Release); + + UnparkHandle { + key: key, + waitaddress: self, + } + } +} + +// Handle for a thread that is about to be unparked. We need to mark the thread +// as unparked while holding the queue lock, but we delay the actual unparking +// until after the queue lock is released. +pub struct UnparkHandle { + key: *const AtomicUsize, + waitaddress: &'static WaitAddress, +} + +impl UnparkHandle { + // Wakes up the parked thread. This should be called after the queue lock is + // released to avoid blocking the queue for too long. + pub unsafe fn unpark(self) { + (self.waitaddress.WakeByAddressSingle)(self.key as PVOID); + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/util.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/util.rs new file mode 100644 index 0000000..c7dfd32 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/util.rs @@ -0,0 +1,32 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +// Option::unchecked_unwrap +pub trait UncheckedOptionExt { + unsafe fn unchecked_unwrap(self) -> T; +} + +impl UncheckedOptionExt for Option { + #[inline] + unsafe fn unchecked_unwrap(self) -> T { + match self { + Some(x) => x, + None => unreachable(), + } + } +} + +// Equivalent to intrinsics::unreachable() in release mode +#[inline] +unsafe fn unreachable() -> ! { + if cfg!(debug_assertions) { + unreachable!(); + } else { + enum Void {} + match *(1 as *const Void) {} + } +} diff --git a/third_party/cargo/vendor/parking_lot_core-0.4.0/src/word_lock.rs b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/word_lock.rs new file mode 100644 index 0000000..7960568 --- /dev/null +++ b/third_party/cargo/vendor/parking_lot_core-0.4.0/src/word_lock.rs @@ -0,0 +1,279 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use spinwait::SpinWait; +use std::cell::Cell; +use std::mem; +#[cfg(not(has_localkey_try_with))] +use std::panic; +use std::ptr; +use std::sync::atomic::{fence, AtomicUsize, Ordering}; +use std::thread::LocalKey; +use thread_parker::ThreadParker; + +struct ThreadData { + parker: ThreadParker, + + // Linked list of threads in the queue. The queue is split into two parts: + // the processed part and the unprocessed part. When new nodes are added to + // the list, they only have the next pointer set, and queue_tail is null. + // + // Nodes are processed with the queue lock held, which consists of setting + // the prev pointer for each node and setting the queue_tail pointer on the + // first processed node of the list. + // + // This setup allows nodes to be added to the queue without a lock, while + // still allowing O(1) removal of nodes from the processed part of the list. + // The only cost is the O(n) processing, but this only needs to be done + // once for each node, and therefore isn't too expensive. + queue_tail: Cell<*const ThreadData>, + prev: Cell<*const ThreadData>, + next: Cell<*const ThreadData>, +} + +impl ThreadData { + fn new() -> ThreadData { + ThreadData { + parker: ThreadParker::new(), + queue_tail: Cell::new(ptr::null()), + prev: Cell::new(ptr::null()), + next: Cell::new(ptr::null()), + } + } +} + +// Returns a ThreadData structure for the current thread +unsafe fn get_thread_data(local: &mut Option) -> &ThreadData { + // Try to read from thread-local storage, but return None if the TLS has + // already been destroyed. + #[cfg(has_localkey_try_with)] + fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { + key.try_with(|x| x as *const ThreadData).ok() + } + #[cfg(not(has_localkey_try_with))] + fn try_get_tls(key: &'static LocalKey) -> Option<*const ThreadData> { + panic::catch_unwind(|| key.with(|x| x as *const ThreadData)).ok() + } + + // If ThreadData is expensive to construct, then we want to use a cached + // version in thread-local storage if possible. + if !cfg!(windows) && !cfg!(all(feature = "nightly", target_os = "linux")) { + thread_local!(static THREAD_DATA: ThreadData = ThreadData::new()); + if let Some(tls) = try_get_tls(&THREAD_DATA) { + return &*tls; + } + } + + // Otherwise just create a ThreadData on the stack + *local = Some(ThreadData::new()); + local.as_ref().unwrap() +} + +const LOCKED_BIT: usize = 1; +const QUEUE_LOCKED_BIT: usize = 2; +const QUEUE_MASK: usize = !3; + +// Word-sized lock that is used to implement the parking_lot API. Since this +// can't use parking_lot, it instead manages its own queue of waiting threads. +pub struct WordLock { + state: AtomicUsize, +} + +impl WordLock { + #[inline] + pub fn new() -> WordLock { + WordLock { + state: AtomicUsize::new(0), + } + } + + #[inline] + pub unsafe fn lock(&self) { + if self + .state + .compare_exchange_weak(0, LOCKED_BIT, Ordering::Acquire, Ordering::Relaxed) + .is_ok() + { + return; + } + self.lock_slow(); + } + + #[inline] + pub unsafe fn unlock(&self) { + let state = self.state.fetch_sub(LOCKED_BIT, Ordering::Release); + if state & QUEUE_LOCKED_BIT != 0 || state & QUEUE_MASK == 0 { + return; + } + self.unlock_slow(); + } + + #[cold] + #[inline(never)] + unsafe fn lock_slow(&self) { + let mut spinwait = SpinWait::new(); + let mut state = self.state.load(Ordering::Relaxed); + loop { + // Grab the lock if it isn't locked, even if there is a queue on it + if state & LOCKED_BIT == 0 { + match self.state.compare_exchange_weak( + state, + state | LOCKED_BIT, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => return, + Err(x) => state = x, + } + continue; + } + + // If there is no queue, try spinning a few times + if state & QUEUE_MASK == 0 && spinwait.spin() { + state = self.state.load(Ordering::Relaxed); + continue; + } + + // Get our thread data and prepare it for parking + let mut thread_data = None; + let thread_data = get_thread_data(&mut thread_data); + assert!(mem::align_of_val(thread_data) > !QUEUE_MASK); + thread_data.parker.prepare_park(); + + // Add our thread to the front of the queue + let queue_head = (state & QUEUE_MASK) as *const ThreadData; + if queue_head.is_null() { + thread_data.queue_tail.set(thread_data); + thread_data.prev.set(ptr::null()); + } else { + thread_data.queue_tail.set(ptr::null()); + thread_data.prev.set(ptr::null()); + thread_data.next.set(queue_head); + } + if let Err(x) = self.state.compare_exchange_weak( + state, + (state & !QUEUE_MASK) | thread_data as *const _ as usize, + Ordering::Release, + Ordering::Relaxed, + ) { + state = x; + continue; + } + + // Sleep until we are woken up by an unlock + thread_data.parker.park(); + + // Loop back and try locking again + spinwait.reset(); + self.state.load(Ordering::Relaxed); + } + } + + #[cold] + #[inline(never)] + unsafe fn unlock_slow(&self) { + let mut state = self.state.load(Ordering::Relaxed); + loop { + // We just unlocked the WordLock. Just check if there is a thread + // to wake up. If the queue is locked then another thread is already + // taking care of waking up a thread. + if state & QUEUE_LOCKED_BIT != 0 || state & QUEUE_MASK == 0 { + return; + } + + // Try to grab the queue lock + match self.state.compare_exchange_weak( + state, + state | QUEUE_LOCKED_BIT, + Ordering::Acquire, + Ordering::Relaxed, + ) { + Ok(_) => break, + Err(x) => state = x, + } + } + + // Now we have the queue lock and the queue is non-empty + 'outer: loop { + // First, we need to fill in the prev pointers for any newly added + // threads. We do this until we reach a node that we previously + // processed, which has a non-null queue_tail pointer. + let queue_head = (state & QUEUE_MASK) as *const ThreadData; + let mut queue_tail; + let mut current = queue_head; + loop { + queue_tail = (*current).queue_tail.get(); + if !queue_tail.is_null() { + break; + } + let next = (*current).next.get(); + (*next).prev.set(current); + current = next; + } + + // Set queue_tail on the queue head to indicate that the whole list + // has prev pointers set correctly. + (*queue_head).queue_tail.set(queue_tail); + + // If the WordLock is locked, then there is no point waking up a + // thread now. Instead we let the next unlocker take care of waking + // up a thread. + if state & LOCKED_BIT != 0 { + match self.state.compare_exchange_weak( + state, + state & !QUEUE_LOCKED_BIT, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => return, + Err(x) => state = x, + } + + // Need an acquire fence before reading the new queue + fence(Ordering::Acquire); + continue; + } + + // Remove the last thread from the queue and unlock the queue + let new_tail = (*queue_tail).prev.get(); + if new_tail.is_null() { + loop { + match self.state.compare_exchange_weak( + state, + state & LOCKED_BIT, + Ordering::Release, + Ordering::Relaxed, + ) { + Ok(_) => break, + Err(x) => state = x, + } + + // If the compare_exchange failed because a new thread was + // added to the queue then we need to re-scan the queue to + // find the previous element. + if state & QUEUE_MASK == 0 { + continue; + } else { + // Need an acquire fence before reading the new queue + fence(Ordering::Acquire); + continue 'outer; + } + } + } else { + (*queue_head).queue_tail.set(new_tail); + self.state.fetch_and(!QUEUE_LOCKED_BIT, Ordering::Release); + } + + // Finally, wake up the thread we removed from the queue. Note that + // we don't need to worry about any races here since the thread is + // guaranteed to be sleeping right now and we are the only one who + // can wake it up. + (*queue_tail).parker.unpark_lock().unpark(); + break; + } + } +} diff --git a/third_party/cargo/vendor/percent-encoding-1.0.1/.cargo-checksum.json b/third_party/cargo/vendor/percent-encoding-1.0.1/.cargo-checksum.json new file mode 100644 index 0000000..70eda28 --- /dev/null +++ b/third_party/cargo/vendor/percent-encoding-1.0.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"1e0b9724c150337dc13080547f26367d8a0d3a4050de38d5f16d2f3991e97637","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"20c7855c364d57ea4c97889a5e8d98470a9952dade37bd9248b9a54431670e5e","lib.rs":"d32a0b432c49053214a4aa51fd5e6b62215dea5a001f229a8ba1a17eb6be20f1"},"package":"31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"} \ No newline at end of file diff --git a/third_party/cargo/vendor/percent-encoding-1.0.1/BUILD b/third_party/cargo/vendor/percent-encoding-1.0.1/BUILD new file mode 100644 index 0000000..f5a62c5 --- /dev/null +++ b/third_party/cargo/vendor/percent-encoding-1.0.1/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "percent_encoding", + crate_root = "lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.0.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/percent-encoding-1.0.1/Cargo.toml b/third_party/cargo/vendor/percent-encoding-1.0.1/Cargo.toml new file mode 100644 index 0000000..bae0da0 --- /dev/null +++ b/third_party/cargo/vendor/percent-encoding-1.0.1/Cargo.toml @@ -0,0 +1,24 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "percent-encoding" +version = "1.0.1" +authors = ["The rust-url developers"] +description = "Percent encoding and decoding" +license = "MIT/Apache-2.0" +repository = "https://github.com/servo/rust-url/" + +[lib] +path = "lib.rs" +test = false +doctest = false diff --git a/third_party/cargo/vendor/percent-encoding-1.0.1/LICENSE-APACHE b/third_party/cargo/vendor/percent-encoding-1.0.1/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/percent-encoding-1.0.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/percent-encoding-1.0.1/LICENSE-MIT b/third_party/cargo/vendor/percent-encoding-1.0.1/LICENSE-MIT new file mode 100644 index 0000000..24de6b4 --- /dev/null +++ b/third_party/cargo/vendor/percent-encoding-1.0.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2013-2016 The rust-url developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/percent-encoding-1.0.1/lib.rs b/third_party/cargo/vendor/percent-encoding-1.0.1/lib.rs new file mode 100644 index 0000000..16d37ad --- /dev/null +++ b/third_party/cargo/vendor/percent-encoding-1.0.1/lib.rs @@ -0,0 +1,442 @@ +// Copyright 2013-2016 The rust-url developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! URLs use special chacters to indicate the parts of the request. For example, a forward slash +//! indicates a path. In order for that charcter to exist outside of a path separator, that +//! charcter would need to be encoded. +//! +//! Percent encoding replaces reserved charcters with the `%` escape charcter followed by hexidecimal +//! ASCII representaton. For non-ASCII charcters that are percent encoded, a UTF-8 byte sequence +//! becomes percent encoded. A simple example can be seen when the space literal is replaced with +//! `%20`. +//! +//! Percent encoding is further complicated by the fact that different parts of an URL have +//! different encoding requirements. In order to support the variety of encoding requirements, +//! `url::percent_encoding` includes different *encode sets*. +//! See [URL Standard](https://url.spec.whatwg.org/#percent-encoded-bytes) for details. +//! +//! This module provides some `*_ENCODE_SET` constants. +//! If a different set is required, it can be created with +//! the [`define_encode_set!`](../macro.define_encode_set!.html) macro. +//! +//! # Examples +//! +//! ``` +//! use url::percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET}; +//! +//! assert_eq!(utf8_percent_encode("foo bar?", DEFAULT_ENCODE_SET).to_string(), "foo%20bar%3F"); +//! ``` + +use std::ascii::AsciiExt; +use std::borrow::Cow; +use std::fmt; +use std::slice; +use std::str; + +/// Represents a set of characters / bytes that should be percent-encoded. +/// +/// See [encode sets specification](http://url.spec.whatwg.org/#simple-encode-set). +/// +/// Different characters need to be encoded in different parts of an URL. +/// For example, a literal `?` question mark in an URL’s path would indicate +/// the start of the query string. +/// A question mark meant to be part of the path therefore needs to be percent-encoded. +/// In the query string however, a question mark does not have any special meaning +/// and does not need to be percent-encoded. +/// +/// A few sets are defined in this module. +/// Use the [`define_encode_set!`](../macro.define_encode_set!.html) macro to define different ones. +pub trait EncodeSet: Clone { + /// Called with UTF-8 bytes rather than code points. + /// Should return true for all non-ASCII bytes. + fn contains(&self, byte: u8) -> bool; +} + +/// Define a new struct +/// that implements the [`EncodeSet`](percent_encoding/trait.EncodeSet.html) trait, +/// for use in [`percent_decode()`](percent_encoding/fn.percent_encode.html) +/// and related functions. +/// +/// Parameters are characters to include in the set in addition to those of the base set. +/// See [encode sets specification](http://url.spec.whatwg.org/#simple-encode-set). +/// +/// Example +/// ======= +/// +/// ```rust +/// #[macro_use] extern crate percent_encoding; +/// use percent_encoding::{utf8_percent_encode, SIMPLE_ENCODE_SET}; +/// define_encode_set! { +/// /// This encode set is used in the URL parser for query strings. +/// pub QUERY_ENCODE_SET = [SIMPLE_ENCODE_SET] | {' ', '"', '#', '<', '>'} +/// } +/// # fn main() { +/// assert_eq!(utf8_percent_encode("foo bar", QUERY_ENCODE_SET).collect::(), "foo%20bar"); +/// # } +/// ``` +#[macro_export] +macro_rules! define_encode_set { + ($(#[$attr: meta])* pub $name: ident = [$base_set: expr] | {$($ch: pat),*}) => { + $(#[$attr])* + #[derive(Copy, Clone, Debug)] + #[allow(non_camel_case_types)] + pub struct $name; + + impl $crate::EncodeSet for $name { + #[inline] + fn contains(&self, byte: u8) -> bool { + match byte as char { + $( + $ch => true, + )* + _ => $base_set.contains(byte) + } + } + } + } +} + +/// This encode set is used for the path of cannot-be-a-base URLs. +/// +/// All ASCII charcters less than hexidecimal 20 and greater than 7E are encoded. This includes +/// special charcters such as line feed, carriage return, NULL, etc. +#[derive(Copy, Clone, Debug)] +#[allow(non_camel_case_types)] +pub struct SIMPLE_ENCODE_SET; + +impl EncodeSet for SIMPLE_ENCODE_SET { + #[inline] + fn contains(&self, byte: u8) -> bool { + byte < 0x20 || byte > 0x7E + } +} + +define_encode_set! { + /// This encode set is used in the URL parser for query strings. + /// + /// Aside from special chacters defined in the [`SIMPLE_ENCODE_SET`](struct.SIMPLE_ENCODE_SET.html), + /// space, double quote ("), hash (#), and inequality qualifiers (<), (>) are encoded. + pub QUERY_ENCODE_SET = [SIMPLE_ENCODE_SET] | {' ', '"', '#', '<', '>'} +} + +define_encode_set! { + /// This encode set is used for path components. + /// + /// Aside from special chacters defined in the [`SIMPLE_ENCODE_SET`](struct.SIMPLE_ENCODE_SET.html), + /// space, double quote ("), hash (#), inequality qualifiers (<), (>), backtick (`), + /// question mark (?), and curly brackets ({), (}) are encoded. + pub DEFAULT_ENCODE_SET = [QUERY_ENCODE_SET] | {'`', '?', '{', '}'} +} + +define_encode_set! { + /// This encode set is used for on '/'-separated path segment + /// + /// Aside from special chacters defined in the [`SIMPLE_ENCODE_SET`](struct.SIMPLE_ENCODE_SET.html), + /// space, double quote ("), hash (#), inequality qualifiers (<), (>), backtick (`), + /// question mark (?), and curly brackets ({), (}), percent sign (%), forward slash (/) are + /// encoded. + pub PATH_SEGMENT_ENCODE_SET = [DEFAULT_ENCODE_SET] | {'%', '/'} +} + +define_encode_set! { + /// This encode set is used for username and password. + /// + /// Aside from special chacters defined in the [`SIMPLE_ENCODE_SET`](struct.SIMPLE_ENCODE_SET.html), + /// space, double quote ("), hash (#), inequality qualifiers (<), (>), backtick (`), + /// question mark (?), and curly brackets ({), (}), forward slash (/), colon (:), semi-colon (;), + /// equality (=), at (@), backslash (\\), square brackets ([), (]), caret (\^), and pipe (|) are + /// encoded. + pub USERINFO_ENCODE_SET = [DEFAULT_ENCODE_SET] | { + '/', ':', ';', '=', '@', '[', '\\', ']', '^', '|' + } +} + +/// Return the percent-encoding of the given bytes. +/// +/// This is unconditional, unlike `percent_encode()` which uses an encode set. +/// +/// # Examples +/// +/// ``` +/// use url::percent_encoding::percent_encode_byte; +/// +/// assert_eq!("foo bar".bytes().map(percent_encode_byte).collect::(), +/// "%66%6F%6F%20%62%61%72"); +/// ``` +pub fn percent_encode_byte(byte: u8) -> &'static str { + let index = usize::from(byte) * 3; + &"\ + %00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F\ + %10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F\ + %20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F\ + %30%31%32%33%34%35%36%37%38%39%3A%3B%3C%3D%3E%3F\ + %40%41%42%43%44%45%46%47%48%49%4A%4B%4C%4D%4E%4F\ + %50%51%52%53%54%55%56%57%58%59%5A%5B%5C%5D%5E%5F\ + %60%61%62%63%64%65%66%67%68%69%6A%6B%6C%6D%6E%6F\ + %70%71%72%73%74%75%76%77%78%79%7A%7B%7C%7D%7E%7F\ + %80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F\ + %90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F\ + %A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF\ + %B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF\ + %C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF\ + %D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF\ + %E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF\ + %F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF\ + "[index..index + 3] +} + +/// Percent-encode the given bytes with the given encode set. +/// +/// The encode set define which bytes (in addition to non-ASCII and controls) +/// need to be percent-encoded. +/// The choice of this set depends on context. +/// For example, `?` needs to be encoded in an URL path but not in a query string. +/// +/// The return value is an iterator of `&str` slices (so it has a `.collect::()` method) +/// that also implements `Display` and `Into>`. +/// The latter returns `Cow::Borrowed` when none of the bytes in `input` +/// are in the given encode set. +/// +/// # Examples +/// +/// ``` +/// use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; +/// +/// assert_eq!(percent_encode(b"foo bar?", DEFAULT_ENCODE_SET).to_string(), "foo%20bar%3F"); +/// ``` +#[inline] +pub fn percent_encode(input: &[u8], encode_set: E) -> PercentEncode { + PercentEncode { + bytes: input, + encode_set: encode_set, + } +} + +/// Percent-encode the UTF-8 encoding of the given string. +/// +/// See `percent_encode()` for how to use the return value. +/// +/// # Examples +/// +/// ``` +/// use url::percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET}; +/// +/// assert_eq!(utf8_percent_encode("foo bar?", DEFAULT_ENCODE_SET).to_string(), "foo%20bar%3F"); +/// ``` +#[inline] +pub fn utf8_percent_encode(input: &str, encode_set: E) -> PercentEncode { + percent_encode(input.as_bytes(), encode_set) +} + +/// The return type of `percent_encode()` and `utf8_percent_encode()`. +#[derive(Clone, Debug)] +pub struct PercentEncode<'a, E: EncodeSet> { + bytes: &'a [u8], + encode_set: E, +} + +impl<'a, E: EncodeSet> Iterator for PercentEncode<'a, E> { + type Item = &'a str; + + fn next(&mut self) -> Option<&'a str> { + if let Some((&first_byte, remaining)) = self.bytes.split_first() { + if self.encode_set.contains(first_byte) { + self.bytes = remaining; + Some(percent_encode_byte(first_byte)) + } else { + assert!(first_byte.is_ascii()); + for (i, &byte) in remaining.iter().enumerate() { + if self.encode_set.contains(byte) { + // 1 for first_byte + i for previous iterations of this loop + let (unchanged_slice, remaining) = self.bytes.split_at(1 + i); + self.bytes = remaining; + return Some(unsafe { str::from_utf8_unchecked(unchanged_slice) }) + } else { + assert!(byte.is_ascii()); + } + } + let unchanged_slice = self.bytes; + self.bytes = &[][..]; + Some(unsafe { str::from_utf8_unchecked(unchanged_slice) }) + } + } else { + None + } + } + + fn size_hint(&self) -> (usize, Option) { + if self.bytes.is_empty() { + (0, Some(0)) + } else { + (1, Some(self.bytes.len())) + } + } +} + +impl<'a, E: EncodeSet> fmt::Display for PercentEncode<'a, E> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + for c in (*self).clone() { + formatter.write_str(c)? + } + Ok(()) + } +} + +impl<'a, E: EncodeSet> From> for Cow<'a, str> { + fn from(mut iter: PercentEncode<'a, E>) -> Self { + match iter.next() { + None => "".into(), + Some(first) => { + match iter.next() { + None => first.into(), + Some(second) => { + let mut string = first.to_owned(); + string.push_str(second); + string.extend(iter); + string.into() + } + } + } + } + } +} + +/// Percent-decode the given bytes. +/// +/// The return value is an iterator of decoded `u8` bytes +/// that also implements `Into>` +/// (which returns `Cow::Borrowed` when `input` contains no percent-encoded sequence) +/// and has `decode_utf8()` and `decode_utf8_lossy()` methods. +/// +/// # Examples +/// +/// ``` +/// use url::percent_encoding::percent_decode; +/// +/// assert_eq!(percent_decode(b"foo%20bar%3F").decode_utf8().unwrap(), "foo bar?"); +/// ``` +#[inline] +pub fn percent_decode(input: &[u8]) -> PercentDecode { + PercentDecode { + bytes: input.iter() + } +} + +/// The return type of `percent_decode()`. +#[derive(Clone, Debug)] +pub struct PercentDecode<'a> { + bytes: slice::Iter<'a, u8>, +} + +fn after_percent_sign(iter: &mut slice::Iter) -> Option { + let initial_iter = iter.clone(); + let h = iter.next().and_then(|&b| (b as char).to_digit(16)); + let l = iter.next().and_then(|&b| (b as char).to_digit(16)); + if let (Some(h), Some(l)) = (h, l) { + Some(h as u8 * 0x10 + l as u8) + } else { + *iter = initial_iter; + None + } +} + +impl<'a> Iterator for PercentDecode<'a> { + type Item = u8; + + fn next(&mut self) -> Option { + self.bytes.next().map(|&byte| { + if byte == b'%' { + after_percent_sign(&mut self.bytes).unwrap_or(byte) + } else { + byte + } + }) + } + + fn size_hint(&self) -> (usize, Option) { + let bytes = self.bytes.len(); + (bytes / 3, Some(bytes)) + } +} + +impl<'a> From> for Cow<'a, [u8]> { + fn from(iter: PercentDecode<'a>) -> Self { + match iter.if_any() { + Some(vec) => Cow::Owned(vec), + None => Cow::Borrowed(iter.bytes.as_slice()), + } + } +} + +impl<'a> PercentDecode<'a> { + /// If the percent-decoding is different from the input, return it as a new bytes vector. + pub fn if_any(&self) -> Option> { + let mut bytes_iter = self.bytes.clone(); + while bytes_iter.any(|&b| b == b'%') { + if let Some(decoded_byte) = after_percent_sign(&mut bytes_iter) { + let initial_bytes = self.bytes.as_slice(); + let unchanged_bytes_len = initial_bytes.len() - bytes_iter.len() - 3; + let mut decoded = initial_bytes[..unchanged_bytes_len].to_owned(); + decoded.push(decoded_byte); + decoded.extend(PercentDecode { + bytes: bytes_iter + }); + return Some(decoded) + } + } + // Nothing to decode + None + } + + /// Decode the result of percent-decoding as UTF-8. + /// + /// This is return `Err` when the percent-decoded bytes are not well-formed in UTF-8. + pub fn decode_utf8(self) -> Result, str::Utf8Error> { + match self.clone().into() { + Cow::Borrowed(bytes) => { + match str::from_utf8(bytes) { + Ok(s) => Ok(s.into()), + Err(e) => Err(e), + } + } + Cow::Owned(bytes) => { + match String::from_utf8(bytes) { + Ok(s) => Ok(s.into()), + Err(e) => Err(e.utf8_error()), + } + } + } + } + + /// Decode the result of percent-decoding as UTF-8, lossily. + /// + /// Invalid UTF-8 percent-encoded byte sequences will be replaced � U+FFFD, + /// the replacement character. + pub fn decode_utf8_lossy(self) -> Cow<'a, str> { + decode_utf8_lossy(self.clone().into()) + } +} + +fn decode_utf8_lossy(input: Cow<[u8]>) -> Cow { + match input { + Cow::Borrowed(bytes) => String::from_utf8_lossy(bytes), + Cow::Owned(bytes) => { + let raw_utf8: *const [u8]; + match String::from_utf8_lossy(&bytes) { + Cow::Borrowed(utf8) => raw_utf8 = utf8.as_bytes(), + Cow::Owned(s) => return s.into(), + } + // from_utf8_lossy returned a borrow of `bytes` unchanged. + debug_assert!(raw_utf8 == &*bytes as *const [u8]); + // Reuse the existing `Vec` allocation. + unsafe { String::from_utf8_unchecked(bytes) }.into() + } + } +} + + diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/.cargo-checksum.json b/third_party/cargo/vendor/pkg-config-0.3.17/.cargo-checksum.json new file mode 100644 index 0000000..1c4514b --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"bf596de388b5e265a425d7add721853b70a4bd09118e67aa6d8efade7c0c3640","Cargo.toml":"679bfb4cbbd2d81a2292542c5f7b544e5ba3f3fdbf98ed4134929a955b361ff2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"9e5845fc0a7234b8902d97eea371c7964bc5cd60dca5bc0552f81f64f34e867f","src/lib.rs":"3af1d40127d03dbc7b05e28e464437977cf48be8768f03e11be4acbe36c7e37f","tests/escape.pc":"00caa4136799dbe5bd504239ba90d1156c12def365c8d761da319fe8a83b398e","tests/foo.pc":"f77712847e77ea81ac6362de5861dc0eddf14b9c07dce1853b3e3e587ffcac5e","tests/framework.pc":"304fdb6cea92973650e410ab1f70ce1ebeb7718af3f139e806efbf182acd565c","tests/test.rs":"3d51b8a273d365abcf986830e1c0be3aa4b7283739437039bc7633e864497eca"},"package":"05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"} \ No newline at end of file diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/BUILD b/third_party/cargo/vendor/pkg-config-0.3.17/BUILD new file mode 100644 index 0000000..e1e7a63 --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "pkg_config", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.3.17", + crate_features = [ + ], +) + +# Unsupported target "test" with type "test" omitted diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/CHANGELOG.md b/third_party/cargo/vendor/pkg-config-0.3.17/CHANGELOG.md new file mode 100644 index 0000000..12d0072 --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/CHANGELOG.md @@ -0,0 +1,73 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [0.3.17] - 2019-11-02 + +### Fixed + +- Fix support for multiple version number constraints (#95) + +## [0.3.16] - 2019-09-09 + +### Changed +- Stop using deprecated functions and require Rust 1.30 (#84) + +### Fixed +- Fix repository URL in README.md +- Fix various clippy warnings + +### Added +- Run `cargo fmt` as part of the CI (#89) +- Derive `Clone` for `Library` and `Debug` for `Config (#91) +- Add support for `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS` and enable by default (#93) + +## [0.3.15] - 2019-07-25 + +### Changed +- Changes minimum documented rust version to 1.28 (#76) + +### Fixed +- Fix Travis CI badge url (#78) +- Fix project name in README.md (#81) + +### Added +- Support specifying range of versions (#75) +- Allow cross-compilation if pkg-config is customized (#44, #86) + +## [0.3.14] - 2018-08-28 + +### Fixed +- Don't append .lib suffix on MSVC builds (#72) + +## [0.3.13] - 2018-08-06 + +### Fixed +- Fix MSVC support to actually work and consider library paths too (#71) + +## [0.3.12] - 2018-06-18 + +### Added +- Support for MSVC (#70) +- Document and test Rust 1.13 as minimally supported version (#66) + +## [0.3.11] - 2018-04-24 + +### Fixed +- Re-added AsciiExt import (#65) + +## [0.3.10] - 2018-04-23 + +### Added +- Allow static linking of /usr/ on macOS (#42) +- Add support for parsing `-Wl,` style framework flags (#48) +- Parse defines in `pkg-config` output (#49) +- Rerun on `PKG_CONFIG_PATH` changes (#50) +- Introduce target-scoped variables (#58) +- Respect pkg-config escaping rules used with --cflags and --libs (#61) + +### Changed +- Use `?` instead of `try!()` in the codebase (#63) diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/Cargo.toml b/third_party/cargo/vendor/pkg-config-0.3.17/Cargo.toml new file mode 100644 index 0000000..34113b1 --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/Cargo.toml @@ -0,0 +1,25 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "pkg-config" +version = "0.3.17" +authors = ["Alex Crichton "] +description = "A library to run the pkg-config system tool at build time in order to be used in\nCargo build scripts.\n" +documentation = "https://docs.rs/pkg-config" +keywords = ["build-dependencies"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-lang/pkg-config-rs" +[dev-dependencies.lazy_static] +version = "1" +[badges.travis-ci] +repository = "rust-lang/pkg-config-rs" diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/LICENSE-APACHE b/third_party/cargo/vendor/pkg-config-0.3.17/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/LICENSE-MIT b/third_party/cargo/vendor/pkg-config-0.3.17/LICENSE-MIT new file mode 100644 index 0000000..39e0ed6 --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/README.md b/third_party/cargo/vendor/pkg-config-0.3.17/README.md new file mode 100644 index 0000000..d7a825d --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/README.md @@ -0,0 +1,73 @@ +# pkg-config-rs + +[![Build Status](https://travis-ci.com/rust-lang/pkg-config-rs.svg?branch=master)](https://travis-ci.com/rust-lang/pkg-config-rs) +[![Rust](https://img.shields.io/badge/rust-1.30%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/pkg-config-rs/) + +[Documentation](https://docs.rs/pkg-config) + +A simple library meant to be used as a build dependency with Cargo packages in +order to use the system `pkg-config` tool (if available) to determine where a +library is located. + +You can use this crate directly to probe for specific libraries, or use +[metadeps](https://github.com/joshtriplett/metadeps) to declare all your +`pkg-config` dependencies in `Cargo.toml`. + +This library requires Rust 1.30+. + +# Example + +Find the system library named `foo`, with minimum version 1.2.3: + +```rust +extern crate pkg_config; + +fn main() { + pkg_config::Config::new().atleast_version("1.2.3").probe("foo").unwrap(); +} +``` + +Find the system library named `foo`, with no version requirement (not +recommended): + +```rust +extern crate pkg_config; + +fn main() { + pkg_config::probe_library("foo").unwrap(); +} +``` + +# External configuration via target-scoped environment variables + +In cross-compilation context, it is useful to manage separately PKG_CONFIG_PATH +and a few other variables for the `host` and the `target` platform. + +The supported variables are: `PKG_CONFIG_PATH`, `PKG_CONFIG_LIBDIR`, and +`PKG_CONFIG_SYSROOT_DIR`. + +Each of these variables can also be supplied with certain prefixes and suffixes, in the following prioritized order: + +1. `_` - for example, `PKG_CONFIG_PATH_x86_64-unknown-linux-gnu` +2. `_` - for example, `PKG_CONFIG_PATH_x86_64_unknown_linux_gnu` +3. `_` - for example, `HOST_PKG_CONFIG_PATH` or `TARGET_PKG_CONFIG_PATH` +4. `` - a plain `PKG_CONFIG_PATH` + +Also note that `PKG_CONFIG_ALLOW_CROSS` must always be set in cross-compilation context. + +# License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in pkg-config-rs by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/src/lib.rs b/third_party/cargo/vendor/pkg-config-0.3.17/src/lib.rs new file mode 100644 index 0000000..0c78c0d --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/src/lib.rs @@ -0,0 +1,701 @@ +//! A build dependency for Cargo libraries to find system artifacts through the +//! `pkg-config` utility. +//! +//! This library will shell out to `pkg-config` as part of build scripts and +//! probe the system to determine how to link to a specified library. The +//! `Config` structure serves as a method of configuring how `pkg-config` is +//! invoked in a builder style. +//! +//! A number of environment variables are available to globally configure how +//! this crate will invoke `pkg-config`: +//! +//! * `PKG_CONFIG_ALLOW_CROSS` - if this variable is not set, then `pkg-config` +//! will automatically be disabled for all cross compiles. +//! * `FOO_NO_PKG_CONFIG` - if set, this will disable running `pkg-config` when +//! probing for the library named `foo`. +//! +//! There are also a number of environment variables which can configure how a +//! library is linked to (dynamically vs statically). These variables control +//! whether the `--static` flag is passed. Note that this behavior can be +//! overridden by configuring explicitly on `Config`. The variables are checked +//! in the following order: +//! +//! * `FOO_STATIC` - pass `--static` for the library `foo` +//! * `FOO_DYNAMIC` - do not pass `--static` for the library `foo` +//! * `PKG_CONFIG_ALL_STATIC` - pass `--static` for all libraries +//! * `PKG_CONFIG_ALL_DYNAMIC` - do not pass `--static` for all libraries +//! +//! After running `pkg-config` all appropriate Cargo metadata will be printed on +//! stdout if the search was successful. +//! +//! # Example +//! +//! Find the system library named `foo`, with minimum version 1.2.3: +//! +//! ```no_run +//! extern crate pkg_config; +//! +//! fn main() { +//! pkg_config::Config::new().atleast_version("1.2.3").probe("foo").unwrap(); +//! } +//! ``` +//! +//! Find the system library named `foo`, with no version requirement (not +//! recommended): +//! +//! ```no_run +//! extern crate pkg_config; +//! +//! fn main() { +//! pkg_config::probe_library("foo").unwrap(); +//! } +//! ``` +//! +//! Configure how library `foo` is linked to. +//! +//! ```no_run +//! extern crate pkg_config; +//! +//! fn main() { +//! pkg_config::Config::new().atleast_version("1.2.3").statik(true).probe("foo").unwrap(); +//! } +//! ``` + +#![doc(html_root_url = "https://docs.rs/pkg-config/0.3")] + +use std::collections::HashMap; +use std::env; +use std::error; +use std::ffi::{OsStr, OsString}; +use std::fmt; +use std::io; +use std::ops::{Bound, RangeBounds}; +use std::path::{Path, PathBuf}; +use std::process::{Command, Output}; +use std::str; + +#[derive(Clone, Debug)] +pub struct Config { + statik: Option, + min_version: Bound, + max_version: Bound, + extra_args: Vec, + cargo_metadata: bool, + env_metadata: bool, + print_system_libs: bool, + print_system_cflags: bool, +} + +#[derive(Clone, Debug)] +pub struct Library { + pub libs: Vec, + pub link_paths: Vec, + pub frameworks: Vec, + pub framework_paths: Vec, + pub include_paths: Vec, + pub defines: HashMap>, + pub version: String, + _priv: (), +} + +/// Represents all reasons `pkg-config` might not succeed or be run at all. +#[derive(Debug)] +pub enum Error { + /// Aborted because of `*_NO_PKG_CONFIG` environment variable. + /// + /// Contains the name of the responsible environment variable. + EnvNoPkgConfig(String), + + /// Cross compilation detected. + /// + /// Override with `PKG_CONFIG_ALLOW_CROSS=1`. + CrossCompilation, + + /// Failed to run `pkg-config`. + /// + /// Contains the command and the cause. + Command { command: String, cause: io::Error }, + + /// `pkg-config` did not exit sucessfully. + /// + /// Contains the command and output. + Failure { command: String, output: Output }, + + #[doc(hidden)] + // please don't match on this, we're likely to add more variants over time + __Nonexhaustive, +} + +impl error::Error for Error { + fn description(&self) -> &str { + match *self { + Error::EnvNoPkgConfig(_) => "pkg-config requested to be aborted", + Error::CrossCompilation => { + "pkg-config doesn't handle cross compilation. \ + Use PKG_CONFIG_ALLOW_CROSS=1 to override" + } + Error::Command { .. } => "failed to run pkg-config", + Error::Failure { .. } => "pkg-config did not exit sucessfully", + Error::__Nonexhaustive => panic!(), + } + } + + fn cause(&self) -> Option<&dyn error::Error> { + match *self { + Error::Command { ref cause, .. } => Some(cause), + _ => None, + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + match *self { + Error::EnvNoPkgConfig(ref name) => write!(f, "Aborted because {} is set", name), + Error::CrossCompilation => write!( + f, + "Cross compilation detected. \ + Use PKG_CONFIG_ALLOW_CROSS=1 to override" + ), + Error::Command { + ref command, + ref cause, + } => write!(f, "Failed to run `{}`: {}", command, cause), + Error::Failure { + ref command, + ref output, + } => { + let stdout = str::from_utf8(&output.stdout).unwrap(); + let stderr = str::from_utf8(&output.stderr).unwrap(); + write!( + f, + "`{}` did not exit successfully: {}", + command, output.status + )?; + if !stdout.is_empty() { + write!(f, "\n--- stdout\n{}", stdout)?; + } + if !stderr.is_empty() { + write!(f, "\n--- stderr\n{}", stderr)?; + } + Ok(()) + } + Error::__Nonexhaustive => panic!(), + } + } +} + +/// Deprecated in favor of the probe_library function +#[doc(hidden)] +pub fn find_library(name: &str) -> Result { + probe_library(name).map_err(|e| e.to_string()) +} + +/// Simple shortcut for using all default options for finding a library. +pub fn probe_library(name: &str) -> Result { + Config::new().probe(name) +} + +/// Run `pkg-config` to get the value of a variable from a package using +/// --variable. +pub fn get_variable(package: &str, variable: &str) -> Result { + let arg = format!("--variable={}", variable); + let cfg = Config::new(); + let out = run(cfg.command(package, &[&arg]))?; + Ok(str::from_utf8(&out).unwrap().trim_end().to_owned()) +} + +impl Config { + /// Creates a new set of configuration options which are all initially set + /// to "blank". + pub fn new() -> Config { + Config { + statik: None, + min_version: Bound::Unbounded, + max_version: Bound::Unbounded, + extra_args: vec![], + print_system_cflags: true, + print_system_libs: true, + cargo_metadata: true, + env_metadata: false, + } + } + + /// Indicate whether the `--static` flag should be passed. + /// + /// This will override the inference from environment variables described in + /// the crate documentation. + pub fn statik(&mut self, statik: bool) -> &mut Config { + self.statik = Some(statik); + self + } + + /// Indicate that the library must be at least version `vers`. + pub fn atleast_version(&mut self, vers: &str) -> &mut Config { + self.min_version = Bound::Included(vers.to_string()); + self.max_version = Bound::Unbounded; + self + } + + /// Indicate that the library must be equal to version `vers`. + pub fn exactly_version(&mut self, vers: &str) -> &mut Config { + self.min_version = Bound::Included(vers.to_string()); + self.max_version = Bound::Included(vers.to_string()); + self + } + + /// Indicate that the library's version must be in `range`. + pub fn range_version<'a, R>(&mut self, range: R) -> &mut Config + where + R: RangeBounds<&'a str>, + { + self.min_version = match range.start_bound() { + Bound::Included(vers) => Bound::Included(vers.to_string()), + Bound::Excluded(vers) => Bound::Excluded(vers.to_string()), + Bound::Unbounded => Bound::Unbounded, + }; + self.max_version = match range.end_bound() { + Bound::Included(vers) => Bound::Included(vers.to_string()), + Bound::Excluded(vers) => Bound::Excluded(vers.to_string()), + Bound::Unbounded => Bound::Unbounded, + }; + self + } + + /// Add an argument to pass to pkg-config. + /// + /// It's placed after all of the arguments generated by this library. + pub fn arg>(&mut self, arg: S) -> &mut Config { + self.extra_args.push(arg.as_ref().to_os_string()); + self + } + + /// Define whether metadata should be emitted for cargo allowing it to + /// automatically link the binary. Defaults to `true`. + pub fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Config { + self.cargo_metadata = cargo_metadata; + self + } + + /// Define whether metadata should be emitted for cargo allowing to + /// automatically rebuild when environment variables change. Defaults to + /// `false`. + pub fn env_metadata(&mut self, env_metadata: bool) -> &mut Config { + self.env_metadata = env_metadata; + self + } + + /// Enable or disable the `PKG_CONFIG_ALLOW_SYSTEM_LIBS` environment + /// variable. + /// + /// This env var is enabled by default. + pub fn print_system_libs(&mut self, print: bool) -> &mut Config { + self.print_system_libs = print; + self + } + + /// Enable or disable the `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS` environment + /// variable. + /// + /// This env var is enabled by default. + pub fn print_system_cflags(&mut self, print: bool) -> &mut Config { + self.print_system_cflags = print; + self + } + + /// Deprecated in favor fo the `probe` function + #[doc(hidden)] + pub fn find(&self, name: &str) -> Result { + self.probe(name).map_err(|e| e.to_string()) + } + + /// Run `pkg-config` to find the library `name`. + /// + /// This will use all configuration previously set to specify how + /// `pkg-config` is run. + pub fn probe(&self, name: &str) -> Result { + let abort_var_name = format!("{}_NO_PKG_CONFIG", envify(name)); + if self.env_var_os(&abort_var_name).is_some() { + return Err(Error::EnvNoPkgConfig(abort_var_name)); + } else if !self.target_supported() { + return Err(Error::CrossCompilation); + } + + let mut library = Library::new(); + + let output = run(self.command(name, &["--libs", "--cflags"]))?; + library.parse_libs_cflags(name, &output, self); + + let output = run(self.command(name, &["--modversion"]))?; + library.parse_modversion(str::from_utf8(&output).unwrap()); + + Ok(library) + } + + pub fn target_supported(&self) -> bool { + let target = env::var("TARGET").unwrap_or_default(); + let host = env::var("HOST").unwrap_or_default(); + + // Only use pkg-config in host == target situations by default (allowing an + // override). + if host == target { + return true; + } + + // pkg-config may not be aware of cross-compilation, and require + // a wrapper script that sets up platform-specific prefixes. + match self.targetted_env_var("PKG_CONFIG_ALLOW_CROSS") { + // don't use pkg-config if explicitly disabled + Ok(ref val) if val == "0" => false, + Ok(_) => true, + Err(_) => { + // if not disabled, and pkg-config is customized, + // then assume it's prepared for cross-compilation + self.targetted_env_var("PKG_CONFIG").is_ok() + || self.targetted_env_var("PKG_CONFIG_SYSROOT_DIR").is_ok() + } + } + } + + /// Deprecated in favor of the top level `get_variable` function + #[doc(hidden)] + pub fn get_variable(package: &str, variable: &str) -> Result { + get_variable(package, variable).map_err(|e| e.to_string()) + } + + fn targetted_env_var(&self, var_base: &str) -> Result { + if let Ok(target) = env::var("TARGET") { + let host = env::var("HOST")?; + let kind = if host == target { "HOST" } else { "TARGET" }; + let target_u = target.replace("-", "_"); + + self.env_var(&format!("{}_{}", var_base, target)) + .or_else(|_| self.env_var(&format!("{}_{}", var_base, target_u))) + .or_else(|_| self.env_var(&format!("{}_{}", kind, var_base))) + .or_else(|_| self.env_var(var_base)) + } else { + self.env_var(var_base) + } + } + + fn env_var(&self, name: &str) -> Result { + if self.env_metadata { + println!("cargo:rerun-if-env-changed={}", name); + } + env::var(name) + } + + fn env_var_os(&self, name: &str) -> Option { + if self.env_metadata { + println!("cargo:rerun-if-env-changed={}", name); + } + env::var_os(name) + } + + fn is_static(&self, name: &str) -> bool { + self.statik.unwrap_or_else(|| self.infer_static(name)) + } + + fn command(&self, name: &str, args: &[&str]) -> Command { + let exe = self + .env_var("PKG_CONFIG") + .unwrap_or_else(|_| String::from("pkg-config")); + let mut cmd = Command::new(exe); + if self.is_static(name) { + cmd.arg("--static"); + } + cmd.args(args).args(&self.extra_args); + + if let Ok(value) = self.targetted_env_var("PKG_CONFIG_PATH") { + cmd.env("PKG_CONFIG_PATH", value); + } + if let Ok(value) = self.targetted_env_var("PKG_CONFIG_LIBDIR") { + cmd.env("PKG_CONFIG_LIBDIR", value); + } + if let Ok(value) = self.targetted_env_var("PKG_CONFIG_SYSROOT_DIR") { + cmd.env("PKG_CONFIG_SYSROOT_DIR", value); + } + if self.print_system_libs { + cmd.env("PKG_CONFIG_ALLOW_SYSTEM_LIBS", "1"); + } + if self.print_system_cflags { + cmd.env("PKG_CONFIG_ALLOW_SYSTEM_CFLAGS", "1"); + } + cmd.arg(name); + match self.min_version { + Bound::Included(ref version) => { + cmd.arg(&format!("{} >= {}", name, version)); + } + Bound::Excluded(ref version) => { + cmd.arg(&format!("{} > {}", name, version)); + } + _ => (), + } + match self.max_version { + Bound::Included(ref version) => { + cmd.arg(&format!("{} <= {}", name, version)); + } + Bound::Excluded(ref version) => { + cmd.arg(&format!("{} < {}", name, version)); + } + _ => (), + } + cmd + } + + fn print_metadata(&self, s: &str) { + if self.cargo_metadata { + println!("cargo:{}", s); + } + } + + fn infer_static(&self, name: &str) -> bool { + let name = envify(name); + if self.env_var_os(&format!("{}_STATIC", name)).is_some() { + true + } else if self.env_var_os(&format!("{}_DYNAMIC", name)).is_some() { + false + } else if self.env_var_os("PKG_CONFIG_ALL_STATIC").is_some() { + true + } else if self.env_var_os("PKG_CONFIG_ALL_DYNAMIC").is_some() { + false + } else { + false + } + } +} + +// Implement Default manualy since Bound does not implement Default. +impl Default for Config { + fn default() -> Config { + Config { + statik: None, + min_version: Bound::Unbounded, + max_version: Bound::Unbounded, + extra_args: vec![], + print_system_cflags: false, + print_system_libs: false, + cargo_metadata: false, + env_metadata: false, + } + } +} + +impl Library { + fn new() -> Library { + Library { + libs: Vec::new(), + link_paths: Vec::new(), + include_paths: Vec::new(), + frameworks: Vec::new(), + framework_paths: Vec::new(), + defines: HashMap::new(), + version: String::new(), + _priv: (), + } + } + + fn parse_libs_cflags(&mut self, name: &str, output: &[u8], config: &Config) { + let mut is_msvc = false; + if let Ok(target) = env::var("TARGET") { + if target.contains("msvc") { + is_msvc = true; + } + } + + let words = split_flags(output); + let parts = words + .iter() + .filter(|l| l.len() > 2) + .map(|arg| (&arg[0..2], &arg[2..])) + .collect::>(); + + let mut dirs = Vec::new(); + let statik = config.is_static(name); + for &(flag, val) in &parts { + match flag { + "-L" => { + let meta = format!("rustc-link-search=native={}", val); + config.print_metadata(&meta); + dirs.push(PathBuf::from(val)); + self.link_paths.push(PathBuf::from(val)); + } + "-F" => { + let meta = format!("rustc-link-search=framework={}", val); + config.print_metadata(&meta); + self.framework_paths.push(PathBuf::from(val)); + } + "-I" => { + self.include_paths.push(PathBuf::from(val)); + } + "-l" => { + // These are provided by the CRT with MSVC + if is_msvc && ["m", "c", "pthread"].contains(&val) { + continue; + } + + if statik && is_static_available(val, &dirs) { + let meta = format!("rustc-link-lib=static={}", val); + config.print_metadata(&meta); + } else { + let meta = format!("rustc-link-lib={}", val); + config.print_metadata(&meta); + } + + self.libs.push(val.to_string()); + } + "-D" => { + let mut iter = val.split('='); + self.defines.insert( + iter.next().unwrap().to_owned(), + iter.next().map(|s| s.to_owned()), + ); + } + _ => {} + } + } + + let mut iter = words.iter().flat_map(|arg| { + if arg.starts_with("-Wl,") { + arg[4..].split(',').collect() + } else { + vec![arg.as_ref()] + } + }); + while let Some(part) = iter.next() { + if part != "-framework" { + continue; + } + if let Some(lib) = iter.next() { + let meta = format!("rustc-link-lib=framework={}", lib); + config.print_metadata(&meta); + self.frameworks.push(lib.to_string()); + } + } + } + + fn parse_modversion(&mut self, output: &str) { + self.version.push_str(output.lines().nth(0).unwrap().trim()); + } +} + +fn envify(name: &str) -> String { + name.chars() + .map(|c| c.to_ascii_uppercase()) + .map(|c| if c == '-' { '_' } else { c }) + .collect() +} + +/// System libraries should only be linked dynamically +fn is_static_available(name: &str, dirs: &[PathBuf]) -> bool { + let libname = format!("lib{}.a", name); + let system_roots = if cfg!(target_os = "macos") { + vec![Path::new("/Library"), Path::new("/System")] + } else { + vec![Path::new("/usr")] + }; + + dirs.iter().any(|dir| { + !system_roots.iter().any(|sys| dir.starts_with(sys)) && dir.join(&libname).exists() + }) +} + +fn run(mut cmd: Command) -> Result, Error> { + match cmd.output() { + Ok(output) => { + if output.status.success() { + Ok(output.stdout) + } else { + Err(Error::Failure { + command: format!("{:?}", cmd), + output, + }) + } + } + Err(cause) => Err(Error::Command { + command: format!("{:?}", cmd), + cause, + }), + } +} + +/// Split output produced by pkg-config --cflags and / or --libs into separate flags. +/// +/// Backslash in output is used to preserve literal meaning of following byte. Different words are +/// separated by unescaped space. Other whitespace characters generally should not occur unescaped +/// at all, apart from the newline at the end of output. For compatibility with what others +/// consumers of pkg-config output would do in this scenario, they are used here for splitting as +/// well. +fn split_flags(output: &[u8]) -> Vec { + let mut word = Vec::new(); + let mut words = Vec::new(); + let mut escaped = false; + + for &b in output { + match b { + _ if escaped => { + escaped = false; + word.push(b); + } + b'\\' => escaped = true, + b'\t' | b'\n' | b'\r' | b' ' => { + if !word.is_empty() { + words.push(String::from_utf8(word).unwrap()); + word = Vec::new(); + } + } + _ => word.push(b), + } + } + + if !word.is_empty() { + words.push(String::from_utf8(word).unwrap()); + } + + words +} + +#[test] +#[cfg(target_os = "macos")] +fn system_library_mac_test() { + assert!(!is_static_available( + "PluginManager", + &[PathBuf::from("/Library/Frameworks")] + )); + assert!(!is_static_available( + "python2.7", + &[PathBuf::from( + "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config" + )] + )); + assert!(!is_static_available( + "ffi_convenience", + &[PathBuf::from( + "/Library/Ruby/Gems/2.0.0/gems/ffi-1.9.10/ext/ffi_c/libffi-x86_64/.libs" + )] + )); + + // Homebrew is in /usr/local, and it's not a part of the OS + if Path::new("/usr/local/lib/libpng16.a").exists() { + assert!(is_static_available( + "png16", + &[PathBuf::from("/usr/local/lib")] + )); + + let libpng = Config::new() + .range_version("1".."99") + .probe("libpng16") + .unwrap(); + assert!(libpng.version.find('\n').is_none()); + } +} + +#[test] +#[cfg(target_os = "linux")] +fn system_library_linux_test() { + assert!(!is_static_available( + "util", + &[PathBuf::from("/usr/lib/x86_64-linux-gnu")] + )); + assert!(!is_static_available("dialog", &[PathBuf::from("/usr/lib")])); +} diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/tests/escape.pc b/third_party/cargo/vendor/pkg-config-0.3.17/tests/escape.pc new file mode 100644 index 0000000..701c4bf --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/tests/escape.pc @@ -0,0 +1,5 @@ +Name: Escape +Version: 4.2.0 +Description: Escape utility library +Libs: -Llink\ path\ with\ spaces +Cflags: -Iinclude\ path\ with\ spaces -DA=\"escaped\ string\'\ literal\" -DB=ESCAPED\ IDENTIFIER -DFOX=🦊 diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/tests/foo.pc b/third_party/cargo/vendor/pkg-config-0.3.17/tests/foo.pc new file mode 100644 index 0000000..b1ae3d8 --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/tests/foo.pc @@ -0,0 +1,16 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include/valgrind +arch=amd64 +os=linux +platform=amd64-linux +valt_load_address=0x38000000 + +Name: Valgrind +Description: A dynamic binary instrumentation framework +Version: 3.10.0.SVN +Requires: +Libs: -L${libdir}/valgrind -lcoregrind-amd64-linux -lvex-amd64-linux -lgcc +Cflags: -I${includedir} + diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/tests/framework.pc b/third_party/cargo/vendor/pkg-config-0.3.17/tests/framework.pc new file mode 100644 index 0000000..fec17f4 --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/tests/framework.pc @@ -0,0 +1,16 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include/valgrind +arch=amd64 +os=linux +platform=amd64-linux +valt_load_address=0x38000000 + +Name: Valgrind +Description: A dynamic binary instrumentation framework +Version: 3.10.0.SVN +Requires: +Libs: -F${libdir} -framework foo -Wl,-framework,bar -Wl,-framework -Wl,baz -Wl,-framework,foobar,-framework,foobaz +Cflags: -I${includedir} + diff --git a/third_party/cargo/vendor/pkg-config-0.3.17/tests/test.rs b/third_party/cargo/vendor/pkg-config-0.3.17/tests/test.rs new file mode 100644 index 0000000..33a623c --- /dev/null +++ b/third_party/cargo/vendor/pkg-config-0.3.17/tests/test.rs @@ -0,0 +1,309 @@ +extern crate pkg_config; +#[macro_use] +extern crate lazy_static; + +use pkg_config::Error; +use std::env; +use std::path::PathBuf; +use std::sync::Mutex; + +lazy_static! { + static ref LOCK: Mutex<()> = Mutex::new(()); +} + +fn reset() { + for (k, _) in env::vars() { + if k.contains("DYNAMIC") + || k.contains("STATIC") + || k.contains("PKG_CONFIG_ALLOW_CROSS") + || k.contains("PKG_CONFIG_SYSROOT_DIR") + || k.contains("FOO_NO_PKG_CONFIG") + { + env::remove_var(&k); + } + } + env::remove_var("TARGET"); + env::remove_var("HOST"); + env::set_var( + "PKG_CONFIG_PATH", + &env::current_dir().unwrap().join("tests"), + ); +} + +fn find(name: &str) -> Result { + pkg_config::probe_library(name) +} + +#[test] +fn cross_disabled() { + let _g = LOCK.lock(); + reset(); + env::set_var("TARGET", "foo"); + env::set_var("HOST", "bar"); + match find("foo") { + Err(Error::CrossCompilation) => {} + x => panic!("Error::CrossCompilation expected, found `{:?}`", x), + } +} + +#[test] +fn cross_enabled() { + let _g = LOCK.lock(); + reset(); + env::set_var("TARGET", "foo"); + env::set_var("HOST", "bar"); + env::set_var("PKG_CONFIG_ALLOW_CROSS", "1"); + find("foo").unwrap(); +} + +#[test] +fn cross_enabled_if_customized() { + let _g = LOCK.lock(); + reset(); + env::set_var("TARGET", "foo"); + env::set_var("HOST", "bar"); + env::set_var("PKG_CONFIG_SYSROOT_DIR", "/tmp/cross-test"); + find("foo").unwrap(); +} + +#[test] +fn cross_disabled_if_customized() { + let _g = LOCK.lock(); + reset(); + env::set_var("TARGET", "foo"); + env::set_var("HOST", "bar"); + env::set_var("PKG_CONFIG_ALLOW_CROSS", "0"); + env::set_var("PKG_CONFIG_SYSROOT_DIR", "/tmp/cross-test"); + match find("foo") { + Err(Error::CrossCompilation) => {} + _ => panic!("expected CrossCompilation failure"), + } +} + +#[test] +fn package_disabled() { + let _g = LOCK.lock(); + reset(); + env::set_var("FOO_NO_PKG_CONFIG", "1"); + match find("foo") { + Err(Error::EnvNoPkgConfig(name)) => assert_eq!(name, "FOO_NO_PKG_CONFIG"), + x => panic!("Error::EnvNoPkgConfig expected, found `{:?}`", x), + } +} + +#[test] +fn output_ok() { + let _g = LOCK.lock(); + reset(); + let lib = find("foo").unwrap(); + assert!(lib.libs.contains(&"gcc".to_string())); + assert!(lib.libs.contains(&"coregrind-amd64-linux".to_string())); + assert!(lib.link_paths.contains(&PathBuf::from("/usr/lib/valgrind"))); +} + +#[test] +fn escapes() { + let _g = LOCK.lock(); + reset(); + let lib = find("escape").unwrap(); + assert!(lib + .include_paths + .contains(&PathBuf::from("include path with spaces"))); + assert!(lib + .link_paths + .contains(&PathBuf::from("link path with spaces"))); + assert_eq!( + lib.defines.get("A"), + Some(&Some("\"escaped string' literal\"".to_owned())) + ); + assert_eq!( + lib.defines.get("B"), + Some(&Some("ESCAPED IDENTIFIER".to_owned())) + ); + assert_eq!(lib.defines.get("FOX"), Some(&Some("🦊".to_owned()))); +} + +#[test] +fn framework() { + let _g = LOCK.lock(); + reset(); + let lib = find("framework").unwrap(); + assert!(lib.frameworks.contains(&"foo".to_string())); + assert!(lib.frameworks.contains(&"bar".to_string())); + assert!(lib.frameworks.contains(&"baz".to_string())); + assert!(lib.frameworks.contains(&"foobar".to_string())); + assert!(lib.frameworks.contains(&"foobaz".to_string())); + assert!(lib.framework_paths.contains(&PathBuf::from("/usr/lib"))); +} + +#[test] +fn get_variable() { + let _g = LOCK.lock(); + reset(); + let prefix = pkg_config::get_variable("foo", "prefix").unwrap(); + assert_eq!(prefix, "/usr"); +} + +#[test] +fn version() { + let _g = LOCK.lock(); + reset(); + assert_eq!(&find("foo").unwrap().version[..], "3.10.0.SVN"); +} + +#[test] +fn atleast_version_ok() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .atleast_version("3.10") + .probe("foo") + .unwrap(); +} + +#[test] +#[should_panic] +fn atleast_version_ng() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .atleast_version("3.11") + .probe("foo") + .unwrap(); +} + +#[test] +fn exactly_version_ok() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .exactly_version("3.10.0.SVN") + .probe("foo") + .unwrap(); +} + +#[test] +#[should_panic] +fn exactly_version_ng() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .exactly_version("3.10.0") + .probe("foo") + .unwrap(); +} + +#[test] +fn range_version_range_ok() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version("4.2.0".."4.4.0") + .probe("escape") + .unwrap(); +} + +#[test] +#[should_panic] +fn range_version_range_ng() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version("4.0.0".."4.2.0") + .probe("escape") + .unwrap(); +} + +#[test] +fn range_version_range_inclusive_ok() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version("4.0.0"..="4.2.0") + .probe("escape") + .unwrap(); +} + +#[test] +#[should_panic] +fn range_version_range_inclusive_ng() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version("3.8.0"..="4.0.0") + .probe("escape") + .unwrap(); +} + +#[test] +fn range_version_range_from_ok() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version("4.0.0"..) + .probe("escape") + .unwrap(); +} + +#[test] +#[should_panic] +fn range_version_range_from_ng() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version("4.4.0"..) + .probe("escape") + .unwrap(); +} + +#[test] +fn range_version_range_to_ok() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version(.."4.4.0") + .probe("escape") + .unwrap(); +} + +#[test] +#[should_panic] +fn range_version_range_to_ng() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version(.."4.2.0") + .probe("escape") + .unwrap(); +} + +#[test] +fn range_version_range_to_inclusive_ok() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version(..="4.2.0") + .probe("escape") + .unwrap(); +} + +#[test] +#[should_panic] +fn range_version_range_to_inclusive_ng() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version(..="4.0.0") + .probe("escape") + .unwrap(); +} + +#[test] +fn range_version_full() { + let _g = LOCK.lock(); + reset(); + pkg_config::Config::new() + .range_version(..) + .probe("escape") + .unwrap(); +} diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/.cargo-checksum.json b/third_party/cargo/vendor/proc-macro2-0.4.30/.cargo-checksum.json new file mode 100644 index 0000000..ef6f59c --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"8b5f969f3fa1acf284b10c1eca350c563cc62fe0da90d9f1aa09c6ddb4410067","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"e7de11d9de411a04366b5ee96ce92216b8f97f3db1728be698f71de5e2f11737","build.rs":"c8339bb526fdc6a0d5bcb2ffbd5bf8c23b6cf1beb247cbfbc7d9e0f783668cb2","src/fallback.rs":"33a562ce167b681ebb8302f61b08aec30816980ea16a5ab29daab70c2208ac5f","src/lib.rs":"9de84db0203e305e027fb90cfdd3f389de5eb07fa89e2d37f786ead0ab18e0c6","src/strnom.rs":"60f5380106dbe568cca7abd09877e133c874fbee95d502e4830425c4613a640d","src/wrapper.rs":"9718c9a9e734a88e58945059805e09db753d711a22fede3efa296ee5fba066a6","tests/marker.rs":"0227d07bbc7f2e2ad34662a6acb65668b7dc2f79141c4faa672703a04e27bea0","tests/test.rs":"eab4362ed56b708e704c099a525db1b97bb06f798b0aa7c1ddef7aaef4c7476b"},"package":"cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"} \ No newline at end of file diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/BUILD b/third_party/cargo/vendor/proc-macro2-0.4.30/BUILD new file mode 100644 index 0000000..5aa98e8 --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/BUILD @@ -0,0 +1,48 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted +# Unsupported target "marker" with type "test" omitted + +rust_library( + name = "proc_macro2", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/unicode-xid-0.1.0:unicode_xid", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.30", + crate_features = [ + "default", + "proc-macro", + ], +) + +# Unsupported target "test" with type "test" omitted diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/Cargo.toml b/third_party/cargo/vendor/proc-macro2-0.4.30/Cargo.toml new file mode 100644 index 0000000..da5378f --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/Cargo.toml @@ -0,0 +1,39 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "proc-macro2" +version = "0.4.30" +authors = ["Alex Crichton "] +build = "build.rs" +description = "A stable implementation of the upcoming new `proc_macro` API. Comes with an\noption, off by default, to also reimplement itself in terms of the upstream\nunstable API.\n" +homepage = "https://github.com/alexcrichton/proc-macro2" +documentation = "https://docs.rs/proc-macro2" +readme = "README.md" +keywords = ["macros"] +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/proc-macro2" +[package.metadata.docs.rs] +rustc-args = ["--cfg", "procmacro2_semver_exempt"] +rustdoc-args = ["--cfg", "procmacro2_semver_exempt"] +[dependencies.unicode-xid] +version = "0.1" +[dev-dependencies.quote] +version = "0.6" + +[features] +default = ["proc-macro"] +nightly = [] +proc-macro = [] +span-locations = [] +[badges.travis-ci] +repository = "alexcrichton/proc-macro2" diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/LICENSE-APACHE b/third_party/cargo/vendor/proc-macro2-0.4.30/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/LICENSE-MIT b/third_party/cargo/vendor/proc-macro2-0.4.30/LICENSE-MIT new file mode 100644 index 0000000..39e0ed6 --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/README.md b/third_party/cargo/vendor/proc-macro2-0.4.30/README.md new file mode 100644 index 0000000..67d523d --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/README.md @@ -0,0 +1,100 @@ +# proc-macro2 + +[![Build Status](https://api.travis-ci.com/alexcrichton/proc-macro2.svg?branch=master)](https://travis-ci.com/alexcrichton/proc-macro2) +[![Latest Version](https://img.shields.io/crates/v/proc-macro2.svg)](https://crates.io/crates/proc-macro2) +[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/proc-macro2) + +A wrapper around the procedural macro API of the compiler's `proc_macro` crate. +This library serves three purposes: + +- **Bring proc-macro-like functionality to other contexts like build.rs and + main.rs.** Types from `proc_macro` are entirely specific to procedural macros + and cannot ever exist in code outside of a procedural macro. Meanwhile + `proc_macro2` types may exist anywhere including non-macro code. By developing + foundational libraries like [syn] and [quote] against `proc_macro2` rather + than `proc_macro`, the procedural macro ecosystem becomes easily applicable to + many other use cases and we avoid reimplementing non-macro equivalents of + those libraries. + +- **Make procedural macros unit testable.** As a consequence of being specific + to procedural macros, nothing that uses `proc_macro` can be executed from a + unit test. In order for helper libraries or components of a macro to be + testable in isolation, they must be implemented using `proc_macro2`. + +- **Provide the latest and greatest APIs across all compiler versions.** + Procedural macros were first introduced to Rust in 1.15.0 with an extremely + minimal interface. Since then, many improvements have landed to make macros + more flexible and easier to write. This library tracks the procedural macro + API of the most recent stable compiler but employs a polyfill to provide that + API consistently across any compiler since 1.15.0. + +[syn]: https://github.com/dtolnay/syn +[quote]: https://github.com/dtolnay/quote + +## Usage + +```toml +[dependencies] +proc-macro2 = "0.4" +``` + +The skeleton of a typical procedural macro typically looks like this: + +```rust +extern crate proc_macro; + +#[proc_macro_derive(MyDerive)] +pub fn my_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let input = proc_macro2::TokenStream::from(input); + + let output: proc_macro2::TokenStream = { + /* transform input */ + }; + + proc_macro::TokenStream::from(output) +} +``` + +If parsing with [Syn], you'll use [`parse_macro_input!`] instead to propagate +parse errors correctly back to the compiler when parsing fails. + +[`parse_macro_input!`]: https://docs.rs/syn/0.15/syn/macro.parse_macro_input.html + +## Unstable features + +The default feature set of proc-macro2 tracks the most recent stable compiler +API. Functionality in `proc_macro` that is not yet stable is not exposed by +proc-macro2 by default. + +To opt into the additional APIs available in the most recent nightly compiler, +the `procmacro2_semver_exempt` config flag must be passed to rustc. As usual, we +will polyfill those nightly-only APIs all the way back to Rust 1.15.0. As these +are unstable APIs that track the nightly compiler, minor versions of proc-macro2 +may make breaking changes to them at any time. + +``` +RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build +``` + +Note that this must not only be done for your crate, but for any crate that +depends on your crate. This infectious nature is intentional, as it serves as a +reminder that you are outside of the normal semver guarantees. + +Semver exempt methods are marked as such in the proc-macro2 documentation. + +# License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in this crate by you, as defined in the Apache-2.0 license, shall +be dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/build.rs b/third_party/cargo/vendor/proc-macro2-0.4.30/build.rs new file mode 100644 index 0000000..187255f --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/build.rs @@ -0,0 +1,157 @@ +// rustc-cfg emitted by the build script: +// +// "u128" +// Include u128 and i128 constructors for proc_macro2::Literal. Enabled on +// any compiler 1.26+. +// +// "use_proc_macro" +// Link to extern crate proc_macro. Available on any compiler and any target +// except wasm32. Requires "proc-macro" Cargo cfg to be enabled (default is +// enabled). On wasm32 we never link to proc_macro even if "proc-macro" cfg +// is enabled. +// +// "wrap_proc_macro" +// Wrap types from libproc_macro rather than polyfilling the whole API. +// Enabled on rustc 1.29+ as long as procmacro2_semver_exempt is not set, +// because we can't emulate the unstable API without emulating everything +// else. Also enabled unconditionally on nightly, in which case the +// procmacro2_semver_exempt surface area is implemented by using the +// nightly-only proc_macro API. +// +// "slow_extend" +// Fallback when `impl Extend for TokenStream` is not available. These impls +// were added one version later than the rest of the proc_macro token API. +// Enabled on rustc 1.29 only. +// +// "proc_macro_span" +// Enable non-dummy behavior of Span::start and Span::end methods which +// requires an unstable compiler feature. Enabled when building with +// nightly, unless `-Z allow-feature` in RUSTFLAGS disallows unstable +// features. +// +// "super_unstable" +// Implement the semver exempt API in terms of the nightly-only proc_macro +// API. Enabled when using procmacro2_semver_exempt on a nightly compiler. +// +// "span_locations" +// Provide methods Span::start and Span::end which give the line/column +// location of a token. Enabled by procmacro2_semver_exempt or the +// "span-locations" Cargo cfg. This is behind a cfg because tracking +// location inside spans is a performance hit. + +use std::env; +use std::process::Command; +use std::str; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let target = env::var("TARGET").unwrap(); + + let version = match rustc_version() { + Some(version) => version, + None => return, + }; + + if version.minor >= 26 { + println!("cargo:rustc-cfg=u128"); + } + + let semver_exempt = cfg!(procmacro2_semver_exempt); + if semver_exempt { + // https://github.com/alexcrichton/proc-macro2/issues/147 + println!("cargo:rustc-cfg=procmacro2_semver_exempt"); + } + + if semver_exempt || cfg!(feature = "span-locations") { + println!("cargo:rustc-cfg=span_locations"); + } + + if !enable_use_proc_macro(&target) { + return; + } + + println!("cargo:rustc-cfg=use_proc_macro"); + + // Rust 1.29 stabilized the necessary APIs in the `proc_macro` crate + if version.nightly || version.minor >= 29 && !semver_exempt { + println!("cargo:rustc-cfg=wrap_proc_macro"); + } + + if version.minor == 29 { + println!("cargo:rustc-cfg=slow_extend"); + } + + if version.nightly && feature_allowed("proc_macro_span") { + println!("cargo:rustc-cfg=proc_macro_span"); + } + + if semver_exempt && version.nightly { + println!("cargo:rustc-cfg=super_unstable"); + } +} + +fn enable_use_proc_macro(target: &str) -> bool { + // wasm targets don't have the `proc_macro` crate, disable this feature. + if target.contains("wasm32") { + return false; + } + + // Otherwise, only enable it if our feature is actually enabled. + cfg!(feature = "proc-macro") +} + +struct RustcVersion { + minor: u32, + nightly: bool, +} + +fn rustc_version() -> Option { + macro_rules! otry { + ($e:expr) => { + match $e { + Some(e) => e, + None => return None, + } + }; + } + + let rustc = otry!(env::var_os("RUSTC")); + let output = otry!(Command::new(rustc).arg("--version").output().ok()); + let version = otry!(str::from_utf8(&output.stdout).ok()); + let nightly = version.contains("nightly"); + let mut pieces = version.split('.'); + if pieces.next() != Some("rustc 1") { + return None; + } + let minor = otry!(pieces.next()); + let minor = otry!(minor.parse().ok()); + + Some(RustcVersion { + minor: minor, + nightly: nightly, + }) +} + +fn feature_allowed(feature: &str) -> bool { + // Recognized formats: + // + // -Z allow-features=feature1,feature2 + // + // -Zallow-features=feature1,feature2 + + if let Some(rustflags) = env::var_os("RUSTFLAGS") { + for mut flag in rustflags.to_string_lossy().split(' ') { + if flag.starts_with("-Z") { + flag = &flag["-Z".len()..]; + } + if flag.starts_with("allow-features=") { + flag = &flag["allow-features=".len()..]; + return flag.split(',').any(|allowed| allowed == feature); + } + } + } + + // No allow-features= flag, allowed by default. + true +} diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/src/fallback.rs b/third_party/cargo/vendor/proc-macro2-0.4.30/src/fallback.rs new file mode 100644 index 0000000..f40a874 --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/src/fallback.rs @@ -0,0 +1,1435 @@ +#[cfg(span_locations)] +use std::cell::RefCell; +#[cfg(procmacro2_semver_exempt)] +use std::cmp; +use std::fmt; +use std::iter; +#[cfg(procmacro2_semver_exempt)] +use std::path::Path; +use std::path::PathBuf; +use std::str::FromStr; +use std::vec; + +use strnom::{block_comment, skip_whitespace, whitespace, word_break, Cursor, PResult}; +use unicode_xid::UnicodeXID; + +use {Delimiter, Punct, Spacing, TokenTree}; + +#[derive(Clone)] +pub struct TokenStream { + inner: Vec, +} + +#[derive(Debug)] +pub struct LexError; + +impl TokenStream { + pub fn new() -> TokenStream { + TokenStream { inner: Vec::new() } + } + + pub fn is_empty(&self) -> bool { + self.inner.len() == 0 + } +} + +#[cfg(span_locations)] +fn get_cursor(src: &str) -> Cursor { + // Create a dummy file & add it to the source map + SOURCE_MAP.with(|cm| { + let mut cm = cm.borrow_mut(); + let name = format!("", cm.files.len()); + let span = cm.add_file(&name, src); + Cursor { + rest: src, + off: span.lo, + } + }) +} + +#[cfg(not(span_locations))] +fn get_cursor(src: &str) -> Cursor { + Cursor { rest: src } +} + +impl FromStr for TokenStream { + type Err = LexError; + + fn from_str(src: &str) -> Result { + // Create a dummy file & add it to the source map + let cursor = get_cursor(src); + + match token_stream(cursor) { + Ok((input, output)) => { + if skip_whitespace(input).len() != 0 { + Err(LexError) + } else { + Ok(output) + } + } + Err(LexError) => Err(LexError), + } + } +} + +impl fmt::Display for TokenStream { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut joint = false; + for (i, tt) in self.inner.iter().enumerate() { + if i != 0 && !joint { + write!(f, " ")?; + } + joint = false; + match *tt { + TokenTree::Group(ref tt) => { + let (start, end) = match tt.delimiter() { + Delimiter::Parenthesis => ("(", ")"), + Delimiter::Brace => ("{", "}"), + Delimiter::Bracket => ("[", "]"), + Delimiter::None => ("", ""), + }; + if tt.stream().into_iter().next().is_none() { + write!(f, "{} {}", start, end)? + } else { + write!(f, "{} {} {}", start, tt.stream(), end)? + } + } + TokenTree::Ident(ref tt) => write!(f, "{}", tt)?, + TokenTree::Punct(ref tt) => { + write!(f, "{}", tt.as_char())?; + match tt.spacing() { + Spacing::Alone => {} + Spacing::Joint => joint = true, + } + } + TokenTree::Literal(ref tt) => write!(f, "{}", tt)?, + } + } + + Ok(()) + } +} + +impl fmt::Debug for TokenStream { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("TokenStream ")?; + f.debug_list().entries(self.clone()).finish() + } +} + +#[cfg(use_proc_macro)] +impl From<::proc_macro::TokenStream> for TokenStream { + fn from(inner: ::proc_macro::TokenStream) -> TokenStream { + inner + .to_string() + .parse() + .expect("compiler token stream parse failed") + } +} + +#[cfg(use_proc_macro)] +impl From for ::proc_macro::TokenStream { + fn from(inner: TokenStream) -> ::proc_macro::TokenStream { + inner + .to_string() + .parse() + .expect("failed to parse to compiler tokens") + } +} + +impl From for TokenStream { + fn from(tree: TokenTree) -> TokenStream { + TokenStream { inner: vec![tree] } + } +} + +impl iter::FromIterator for TokenStream { + fn from_iter>(streams: I) -> Self { + let mut v = Vec::new(); + + for token in streams.into_iter() { + v.push(token); + } + + TokenStream { inner: v } + } +} + +impl iter::FromIterator for TokenStream { + fn from_iter>(streams: I) -> Self { + let mut v = Vec::new(); + + for stream in streams.into_iter() { + v.extend(stream.inner); + } + + TokenStream { inner: v } + } +} + +impl Extend for TokenStream { + fn extend>(&mut self, streams: I) { + self.inner.extend(streams); + } +} + +impl Extend for TokenStream { + fn extend>(&mut self, streams: I) { + self.inner + .extend(streams.into_iter().flat_map(|stream| stream)); + } +} + +pub type TokenTreeIter = vec::IntoIter; + +impl IntoIterator for TokenStream { + type Item = TokenTree; + type IntoIter = TokenTreeIter; + + fn into_iter(self) -> TokenTreeIter { + self.inner.into_iter() + } +} + +#[derive(Clone, PartialEq, Eq)] +pub struct SourceFile { + path: PathBuf, +} + +impl SourceFile { + /// Get the path to this source file as a string. + pub fn path(&self) -> PathBuf { + self.path.clone() + } + + pub fn is_real(&self) -> bool { + // XXX(nika): Support real files in the future? + false + } +} + +impl fmt::Debug for SourceFile { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("SourceFile") + .field("path", &self.path()) + .field("is_real", &self.is_real()) + .finish() + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct LineColumn { + pub line: usize, + pub column: usize, +} + +#[cfg(span_locations)] +thread_local! { + static SOURCE_MAP: RefCell = RefCell::new(SourceMap { + // NOTE: We start with a single dummy file which all call_site() and + // def_site() spans reference. + files: vec![{ + #[cfg(procmacro2_semver_exempt)] + { + FileInfo { + name: "".to_owned(), + span: Span { lo: 0, hi: 0 }, + lines: vec![0], + } + } + + #[cfg(not(procmacro2_semver_exempt))] + { + FileInfo { + span: Span { lo: 0, hi: 0 }, + lines: vec![0], + } + } + }], + }); +} + +#[cfg(span_locations)] +struct FileInfo { + #[cfg(procmacro2_semver_exempt)] + name: String, + span: Span, + lines: Vec, +} + +#[cfg(span_locations)] +impl FileInfo { + fn offset_line_column(&self, offset: usize) -> LineColumn { + assert!(self.span_within(Span { + lo: offset as u32, + hi: offset as u32 + })); + let offset = offset - self.span.lo as usize; + match self.lines.binary_search(&offset) { + Ok(found) => LineColumn { + line: found + 1, + column: 0, + }, + Err(idx) => LineColumn { + line: idx, + column: offset - self.lines[idx - 1], + }, + } + } + + fn span_within(&self, span: Span) -> bool { + span.lo >= self.span.lo && span.hi <= self.span.hi + } +} + +/// Computesthe offsets of each line in the given source string. +#[cfg(span_locations)] +fn lines_offsets(s: &str) -> Vec { + let mut lines = vec![0]; + let mut prev = 0; + while let Some(len) = s[prev..].find('\n') { + prev += len + 1; + lines.push(prev); + } + lines +} + +#[cfg(span_locations)] +struct SourceMap { + files: Vec, +} + +#[cfg(span_locations)] +impl SourceMap { + fn next_start_pos(&self) -> u32 { + // Add 1 so there's always space between files. + // + // We'll always have at least 1 file, as we initialize our files list + // with a dummy file. + self.files.last().unwrap().span.hi + 1 + } + + fn add_file(&mut self, name: &str, src: &str) -> Span { + let lines = lines_offsets(src); + let lo = self.next_start_pos(); + // XXX(nika): Shouild we bother doing a checked cast or checked add here? + let span = Span { + lo: lo, + hi: lo + (src.len() as u32), + }; + + #[cfg(procmacro2_semver_exempt)] + self.files.push(FileInfo { + name: name.to_owned(), + span: span, + lines: lines, + }); + + #[cfg(not(procmacro2_semver_exempt))] + self.files.push(FileInfo { + span: span, + lines: lines, + }); + let _ = name; + + span + } + + fn fileinfo(&self, span: Span) -> &FileInfo { + for file in &self.files { + if file.span_within(span) { + return file; + } + } + panic!("Invalid span with no related FileInfo!"); + } +} + +#[derive(Clone, Copy, PartialEq, Eq)] +pub struct Span { + #[cfg(span_locations)] + lo: u32, + #[cfg(span_locations)] + hi: u32, +} + +impl Span { + #[cfg(not(span_locations))] + pub fn call_site() -> Span { + Span {} + } + + #[cfg(span_locations)] + pub fn call_site() -> Span { + Span { lo: 0, hi: 0 } + } + + #[cfg(procmacro2_semver_exempt)] + pub fn def_site() -> Span { + Span::call_site() + } + + #[cfg(procmacro2_semver_exempt)] + pub fn resolved_at(&self, _other: Span) -> Span { + // Stable spans consist only of line/column information, so + // `resolved_at` and `located_at` only select which span the + // caller wants line/column information from. + *self + } + + #[cfg(procmacro2_semver_exempt)] + pub fn located_at(&self, other: Span) -> Span { + other + } + + #[cfg(procmacro2_semver_exempt)] + pub fn source_file(&self) -> SourceFile { + SOURCE_MAP.with(|cm| { + let cm = cm.borrow(); + let fi = cm.fileinfo(*self); + SourceFile { + path: Path::new(&fi.name).to_owned(), + } + }) + } + + #[cfg(span_locations)] + pub fn start(&self) -> LineColumn { + SOURCE_MAP.with(|cm| { + let cm = cm.borrow(); + let fi = cm.fileinfo(*self); + fi.offset_line_column(self.lo as usize) + }) + } + + #[cfg(span_locations)] + pub fn end(&self) -> LineColumn { + SOURCE_MAP.with(|cm| { + let cm = cm.borrow(); + let fi = cm.fileinfo(*self); + fi.offset_line_column(self.hi as usize) + }) + } + + #[cfg(procmacro2_semver_exempt)] + pub fn join(&self, other: Span) -> Option { + SOURCE_MAP.with(|cm| { + let cm = cm.borrow(); + // If `other` is not within the same FileInfo as us, return None. + if !cm.fileinfo(*self).span_within(other) { + return None; + } + Some(Span { + lo: cmp::min(self.lo, other.lo), + hi: cmp::max(self.hi, other.hi), + }) + }) + } +} + +impl fmt::Debug for Span { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[cfg(procmacro2_semver_exempt)] + return write!(f, "bytes({}..{})", self.lo, self.hi); + + #[cfg(not(procmacro2_semver_exempt))] + write!(f, "Span") + } +} + +pub fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) { + if cfg!(procmacro2_semver_exempt) { + debug.field("span", &span); + } +} + +#[derive(Clone)] +pub struct Group { + delimiter: Delimiter, + stream: TokenStream, + span: Span, +} + +impl Group { + pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group { + Group { + delimiter: delimiter, + stream: stream, + span: Span::call_site(), + } + } + + pub fn delimiter(&self) -> Delimiter { + self.delimiter + } + + pub fn stream(&self) -> TokenStream { + self.stream.clone() + } + + pub fn span(&self) -> Span { + self.span + } + + #[cfg(procmacro2_semver_exempt)] + pub fn span_open(&self) -> Span { + self.span + } + + #[cfg(procmacro2_semver_exempt)] + pub fn span_close(&self) -> Span { + self.span + } + + pub fn set_span(&mut self, span: Span) { + self.span = span; + } +} + +impl fmt::Display for Group { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let (left, right) = match self.delimiter { + Delimiter::Parenthesis => ("(", ")"), + Delimiter::Brace => ("{", "}"), + Delimiter::Bracket => ("[", "]"), + Delimiter::None => ("", ""), + }; + + f.write_str(left)?; + self.stream.fmt(f)?; + f.write_str(right)?; + + Ok(()) + } +} + +impl fmt::Debug for Group { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let mut debug = fmt.debug_struct("Group"); + debug.field("delimiter", &self.delimiter); + debug.field("stream", &self.stream); + #[cfg(procmacro2_semver_exempt)] + debug.field("span", &self.span); + debug.finish() + } +} + +#[derive(Clone)] +pub struct Ident { + sym: String, + span: Span, + raw: bool, +} + +impl Ident { + fn _new(string: &str, raw: bool, span: Span) -> Ident { + validate_ident(string); + + Ident { + sym: string.to_owned(), + span: span, + raw: raw, + } + } + + pub fn new(string: &str, span: Span) -> Ident { + Ident::_new(string, false, span) + } + + pub fn new_raw(string: &str, span: Span) -> Ident { + Ident::_new(string, true, span) + } + + pub fn span(&self) -> Span { + self.span + } + + pub fn set_span(&mut self, span: Span) { + self.span = span; + } +} + +#[inline] +fn is_ident_start(c: char) -> bool { + ('a' <= c && c <= 'z') + || ('A' <= c && c <= 'Z') + || c == '_' + || (c > '\x7f' && UnicodeXID::is_xid_start(c)) +} + +#[inline] +fn is_ident_continue(c: char) -> bool { + ('a' <= c && c <= 'z') + || ('A' <= c && c <= 'Z') + || c == '_' + || ('0' <= c && c <= '9') + || (c > '\x7f' && UnicodeXID::is_xid_continue(c)) +} + +fn validate_ident(string: &str) { + let validate = string; + if validate.is_empty() { + panic!("Ident is not allowed to be empty; use Option"); + } + + if validate.bytes().all(|digit| digit >= b'0' && digit <= b'9') { + panic!("Ident cannot be a number; use Literal instead"); + } + + fn ident_ok(string: &str) -> bool { + let mut chars = string.chars(); + let first = chars.next().unwrap(); + if !is_ident_start(first) { + return false; + } + for ch in chars { + if !is_ident_continue(ch) { + return false; + } + } + true + } + + if !ident_ok(validate) { + panic!("{:?} is not a valid Ident", string); + } +} + +impl PartialEq for Ident { + fn eq(&self, other: &Ident) -> bool { + self.sym == other.sym && self.raw == other.raw + } +} + +impl PartialEq for Ident +where + T: ?Sized + AsRef, +{ + fn eq(&self, other: &T) -> bool { + let other = other.as_ref(); + if self.raw { + other.starts_with("r#") && self.sym == other[2..] + } else { + self.sym == other + } + } +} + +impl fmt::Display for Ident { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.raw { + "r#".fmt(f)?; + } + self.sym.fmt(f) + } +} + +impl fmt::Debug for Ident { + // Ident(proc_macro), Ident(r#union) + #[cfg(not(procmacro2_semver_exempt))] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut debug = f.debug_tuple("Ident"); + debug.field(&format_args!("{}", self)); + debug.finish() + } + + // Ident { + // sym: proc_macro, + // span: bytes(128..138) + // } + #[cfg(procmacro2_semver_exempt)] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut debug = f.debug_struct("Ident"); + debug.field("sym", &format_args!("{}", self)); + debug.field("span", &self.span); + debug.finish() + } +} + +#[derive(Clone)] +pub struct Literal { + text: String, + span: Span, +} + +macro_rules! suffixed_numbers { + ($($name:ident => $kind:ident,)*) => ($( + pub fn $name(n: $kind) -> Literal { + Literal::_new(format!(concat!("{}", stringify!($kind)), n)) + } + )*) +} + +macro_rules! unsuffixed_numbers { + ($($name:ident => $kind:ident,)*) => ($( + pub fn $name(n: $kind) -> Literal { + Literal::_new(n.to_string()) + } + )*) +} + +impl Literal { + fn _new(text: String) -> Literal { + Literal { + text: text, + span: Span::call_site(), + } + } + + suffixed_numbers! { + u8_suffixed => u8, + u16_suffixed => u16, + u32_suffixed => u32, + u64_suffixed => u64, + usize_suffixed => usize, + i8_suffixed => i8, + i16_suffixed => i16, + i32_suffixed => i32, + i64_suffixed => i64, + isize_suffixed => isize, + + f32_suffixed => f32, + f64_suffixed => f64, + } + + #[cfg(u128)] + suffixed_numbers! { + u128_suffixed => u128, + i128_suffixed => i128, + } + + unsuffixed_numbers! { + u8_unsuffixed => u8, + u16_unsuffixed => u16, + u32_unsuffixed => u32, + u64_unsuffixed => u64, + usize_unsuffixed => usize, + i8_unsuffixed => i8, + i16_unsuffixed => i16, + i32_unsuffixed => i32, + i64_unsuffixed => i64, + isize_unsuffixed => isize, + } + + #[cfg(u128)] + unsuffixed_numbers! { + u128_unsuffixed => u128, + i128_unsuffixed => i128, + } + + pub fn f32_unsuffixed(f: f32) -> Literal { + let mut s = f.to_string(); + if !s.contains(".") { + s.push_str(".0"); + } + Literal::_new(s) + } + + pub fn f64_unsuffixed(f: f64) -> Literal { + let mut s = f.to_string(); + if !s.contains(".") { + s.push_str(".0"); + } + Literal::_new(s) + } + + pub fn string(t: &str) -> Literal { + let mut text = String::with_capacity(t.len() + 2); + text.push('"'); + for c in t.chars() { + if c == '\'' { + // escape_default turns this into "\'" which is unnecessary. + text.push(c); + } else { + text.extend(c.escape_default()); + } + } + text.push('"'); + Literal::_new(text) + } + + pub fn character(t: char) -> Literal { + let mut text = String::new(); + text.push('\''); + if t == '"' { + // escape_default turns this into '\"' which is unnecessary. + text.push(t); + } else { + text.extend(t.escape_default()); + } + text.push('\''); + Literal::_new(text) + } + + pub fn byte_string(bytes: &[u8]) -> Literal { + let mut escaped = "b\"".to_string(); + for b in bytes { + match *b { + b'\0' => escaped.push_str(r"\0"), + b'\t' => escaped.push_str(r"\t"), + b'\n' => escaped.push_str(r"\n"), + b'\r' => escaped.push_str(r"\r"), + b'"' => escaped.push_str("\\\""), + b'\\' => escaped.push_str("\\\\"), + b'\x20'...b'\x7E' => escaped.push(*b as char), + _ => escaped.push_str(&format!("\\x{:02X}", b)), + } + } + escaped.push('"'); + Literal::_new(escaped) + } + + pub fn span(&self) -> Span { + self.span + } + + pub fn set_span(&mut self, span: Span) { + self.span = span; + } +} + +impl fmt::Display for Literal { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.text.fmt(f) + } +} + +impl fmt::Debug for Literal { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let mut debug = fmt.debug_struct("Literal"); + debug.field("lit", &format_args!("{}", self.text)); + #[cfg(procmacro2_semver_exempt)] + debug.field("span", &self.span); + debug.finish() + } +} + +fn token_stream(mut input: Cursor) -> PResult { + let mut trees = Vec::new(); + loop { + let input_no_ws = skip_whitespace(input); + if input_no_ws.rest.len() == 0 { + break; + } + if let Ok((a, tokens)) = doc_comment(input_no_ws) { + input = a; + trees.extend(tokens); + continue; + } + + let (a, tt) = match token_tree(input_no_ws) { + Ok(p) => p, + Err(_) => break, + }; + trees.push(tt); + input = a; + } + Ok((input, TokenStream { inner: trees })) +} + +#[cfg(not(span_locations))] +fn spanned<'a, T>( + input: Cursor<'a>, + f: fn(Cursor<'a>) -> PResult<'a, T>, +) -> PResult<'a, (T, ::Span)> { + let (a, b) = f(skip_whitespace(input))?; + Ok((a, ((b, ::Span::_new_stable(Span::call_site()))))) +} + +#[cfg(span_locations)] +fn spanned<'a, T>( + input: Cursor<'a>, + f: fn(Cursor<'a>) -> PResult<'a, T>, +) -> PResult<'a, (T, ::Span)> { + let input = skip_whitespace(input); + let lo = input.off; + let (a, b) = f(input)?; + let hi = a.off; + let span = ::Span::_new_stable(Span { lo: lo, hi: hi }); + Ok((a, (b, span))) +} + +fn token_tree(input: Cursor) -> PResult { + let (rest, (mut tt, span)) = spanned(input, token_kind)?; + tt.set_span(span); + Ok((rest, tt)) +} + +named!(token_kind -> TokenTree, alt!( + map!(group, |g| TokenTree::Group(::Group::_new_stable(g))) + | + map!(literal, |l| TokenTree::Literal(::Literal::_new_stable(l))) // must be before symbol + | + map!(op, TokenTree::Punct) + | + symbol_leading_ws +)); + +named!(group -> Group, alt!( + delimited!( + punct!("("), + token_stream, + punct!(")") + ) => { |ts| Group::new(Delimiter::Parenthesis, ts) } + | + delimited!( + punct!("["), + token_stream, + punct!("]") + ) => { |ts| Group::new(Delimiter::Bracket, ts) } + | + delimited!( + punct!("{"), + token_stream, + punct!("}") + ) => { |ts| Group::new(Delimiter::Brace, ts) } +)); + +fn symbol_leading_ws(input: Cursor) -> PResult { + symbol(skip_whitespace(input)) +} + +fn symbol(input: Cursor) -> PResult { + let mut chars = input.char_indices(); + + let raw = input.starts_with("r#"); + if raw { + chars.next(); + chars.next(); + } + + match chars.next() { + Some((_, ch)) if is_ident_start(ch) => {} + _ => return Err(LexError), + } + + let mut end = input.len(); + for (i, ch) in chars { + if !is_ident_continue(ch) { + end = i; + break; + } + } + + let a = &input.rest[..end]; + if a == "r#_" { + Err(LexError) + } else { + let ident = if raw { + ::Ident::_new_raw(&a[2..], ::Span::call_site()) + } else { + ::Ident::new(a, ::Span::call_site()) + }; + Ok((input.advance(end), ident.into())) + } +} + +fn literal(input: Cursor) -> PResult { + let input_no_ws = skip_whitespace(input); + + match literal_nocapture(input_no_ws) { + Ok((a, ())) => { + let start = input.len() - input_no_ws.len(); + let len = input_no_ws.len() - a.len(); + let end = start + len; + Ok((a, Literal::_new(input.rest[start..end].to_string()))) + } + Err(LexError) => Err(LexError), + } +} + +named!(literal_nocapture -> (), alt!( + string + | + byte_string + | + byte + | + character + | + float + | + int +)); + +named!(string -> (), alt!( + quoted_string + | + preceded!( + punct!("r"), + raw_string + ) => { |_| () } +)); + +named!(quoted_string -> (), delimited!( + punct!("\""), + cooked_string, + tag!("\"") +)); + +fn cooked_string(input: Cursor) -> PResult<()> { + let mut chars = input.char_indices().peekable(); + while let Some((byte_offset, ch)) = chars.next() { + match ch { + '"' => { + return Ok((input.advance(byte_offset), ())); + } + '\r' => { + if let Some((_, '\n')) = chars.next() { + // ... + } else { + break; + } + } + '\\' => match chars.next() { + Some((_, 'x')) => { + if !backslash_x_char(&mut chars) { + break; + } + } + Some((_, 'n')) | Some((_, 'r')) | Some((_, 't')) | Some((_, '\\')) + | Some((_, '\'')) | Some((_, '"')) | Some((_, '0')) => {} + Some((_, 'u')) => { + if !backslash_u(&mut chars) { + break; + } + } + Some((_, '\n')) | Some((_, '\r')) => { + while let Some(&(_, ch)) = chars.peek() { + if ch.is_whitespace() { + chars.next(); + } else { + break; + } + } + } + _ => break, + }, + _ch => {} + } + } + Err(LexError) +} + +named!(byte_string -> (), alt!( + delimited!( + punct!("b\""), + cooked_byte_string, + tag!("\"") + ) => { |_| () } + | + preceded!( + punct!("br"), + raw_string + ) => { |_| () } +)); + +fn cooked_byte_string(mut input: Cursor) -> PResult<()> { + let mut bytes = input.bytes().enumerate(); + 'outer: while let Some((offset, b)) = bytes.next() { + match b { + b'"' => { + return Ok((input.advance(offset), ())); + } + b'\r' => { + if let Some((_, b'\n')) = bytes.next() { + // ... + } else { + break; + } + } + b'\\' => match bytes.next() { + Some((_, b'x')) => { + if !backslash_x_byte(&mut bytes) { + break; + } + } + Some((_, b'n')) | Some((_, b'r')) | Some((_, b't')) | Some((_, b'\\')) + | Some((_, b'0')) | Some((_, b'\'')) | Some((_, b'"')) => {} + Some((newline, b'\n')) | Some((newline, b'\r')) => { + let rest = input.advance(newline + 1); + for (offset, ch) in rest.char_indices() { + if !ch.is_whitespace() { + input = rest.advance(offset); + bytes = input.bytes().enumerate(); + continue 'outer; + } + } + break; + } + _ => break, + }, + b if b < 0x80 => {} + _ => break, + } + } + Err(LexError) +} + +fn raw_string(input: Cursor) -> PResult<()> { + let mut chars = input.char_indices(); + let mut n = 0; + while let Some((byte_offset, ch)) = chars.next() { + match ch { + '"' => { + n = byte_offset; + break; + } + '#' => {} + _ => return Err(LexError), + } + } + for (byte_offset, ch) in chars { + match ch { + '"' if input.advance(byte_offset + 1).starts_with(&input.rest[..n]) => { + let rest = input.advance(byte_offset + 1 + n); + return Ok((rest, ())); + } + '\r' => {} + _ => {} + } + } + Err(LexError) +} + +named!(byte -> (), do_parse!( + punct!("b") >> + tag!("'") >> + cooked_byte >> + tag!("'") >> + (()) +)); + +fn cooked_byte(input: Cursor) -> PResult<()> { + let mut bytes = input.bytes().enumerate(); + let ok = match bytes.next().map(|(_, b)| b) { + Some(b'\\') => match bytes.next().map(|(_, b)| b) { + Some(b'x') => backslash_x_byte(&mut bytes), + Some(b'n') | Some(b'r') | Some(b't') | Some(b'\\') | Some(b'0') | Some(b'\'') + | Some(b'"') => true, + _ => false, + }, + b => b.is_some(), + }; + if ok { + match bytes.next() { + Some((offset, _)) => { + if input.chars().as_str().is_char_boundary(offset) { + Ok((input.advance(offset), ())) + } else { + Err(LexError) + } + } + None => Ok((input.advance(input.len()), ())), + } + } else { + Err(LexError) + } +} + +named!(character -> (), do_parse!( + punct!("'") >> + cooked_char >> + tag!("'") >> + (()) +)); + +fn cooked_char(input: Cursor) -> PResult<()> { + let mut chars = input.char_indices(); + let ok = match chars.next().map(|(_, ch)| ch) { + Some('\\') => match chars.next().map(|(_, ch)| ch) { + Some('x') => backslash_x_char(&mut chars), + Some('u') => backslash_u(&mut chars), + Some('n') | Some('r') | Some('t') | Some('\\') | Some('0') | Some('\'') | Some('"') => { + true + } + _ => false, + }, + ch => ch.is_some(), + }; + if ok { + match chars.next() { + Some((idx, _)) => Ok((input.advance(idx), ())), + None => Ok((input.advance(input.len()), ())), + } + } else { + Err(LexError) + } +} + +macro_rules! next_ch { + ($chars:ident @ $pat:pat $(| $rest:pat)*) => { + match $chars.next() { + Some((_, ch)) => match ch { + $pat $(| $rest)* => ch, + _ => return false, + }, + None => return false + } + }; +} + +fn backslash_x_char(chars: &mut I) -> bool +where + I: Iterator, +{ + next_ch!(chars @ '0'...'7'); + next_ch!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F'); + true +} + +fn backslash_x_byte(chars: &mut I) -> bool +where + I: Iterator, +{ + next_ch!(chars @ b'0'...b'9' | b'a'...b'f' | b'A'...b'F'); + next_ch!(chars @ b'0'...b'9' | b'a'...b'f' | b'A'...b'F'); + true +} + +fn backslash_u(chars: &mut I) -> bool +where + I: Iterator, +{ + next_ch!(chars @ '{'); + next_ch!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F'); + loop { + let c = next_ch!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F' | '_' | '}'); + if c == '}' { + return true; + } + } +} + +fn float(input: Cursor) -> PResult<()> { + let (rest, ()) = float_digits(input)?; + for suffix in &["f32", "f64"] { + if rest.starts_with(suffix) { + return word_break(rest.advance(suffix.len())); + } + } + word_break(rest) +} + +fn float_digits(input: Cursor) -> PResult<()> { + let mut chars = input.chars().peekable(); + match chars.next() { + Some(ch) if ch >= '0' && ch <= '9' => {} + _ => return Err(LexError), + } + + let mut len = 1; + let mut has_dot = false; + let mut has_exp = false; + while let Some(&ch) = chars.peek() { + match ch { + '0'...'9' | '_' => { + chars.next(); + len += 1; + } + '.' => { + if has_dot { + break; + } + chars.next(); + if chars + .peek() + .map(|&ch| ch == '.' || UnicodeXID::is_xid_start(ch)) + .unwrap_or(false) + { + return Err(LexError); + } + len += 1; + has_dot = true; + } + 'e' | 'E' => { + chars.next(); + len += 1; + has_exp = true; + break; + } + _ => break, + } + } + + let rest = input.advance(len); + if !(has_dot || has_exp || rest.starts_with("f32") || rest.starts_with("f64")) { + return Err(LexError); + } + + if has_exp { + let mut has_exp_value = false; + while let Some(&ch) = chars.peek() { + match ch { + '+' | '-' => { + if has_exp_value { + break; + } + chars.next(); + len += 1; + } + '0'...'9' => { + chars.next(); + len += 1; + has_exp_value = true; + } + '_' => { + chars.next(); + len += 1; + } + _ => break, + } + } + if !has_exp_value { + return Err(LexError); + } + } + + Ok((input.advance(len), ())) +} + +fn int(input: Cursor) -> PResult<()> { + let (rest, ()) = digits(input)?; + for suffix in &[ + "isize", "i8", "i16", "i32", "i64", "i128", "usize", "u8", "u16", "u32", "u64", "u128", + ] { + if rest.starts_with(suffix) { + return word_break(rest.advance(suffix.len())); + } + } + word_break(rest) +} + +fn digits(mut input: Cursor) -> PResult<()> { + let base = if input.starts_with("0x") { + input = input.advance(2); + 16 + } else if input.starts_with("0o") { + input = input.advance(2); + 8 + } else if input.starts_with("0b") { + input = input.advance(2); + 2 + } else { + 10 + }; + + let mut len = 0; + let mut empty = true; + for b in input.bytes() { + let digit = match b { + b'0'...b'9' => (b - b'0') as u64, + b'a'...b'f' => 10 + (b - b'a') as u64, + b'A'...b'F' => 10 + (b - b'A') as u64, + b'_' => { + if empty && base == 10 { + return Err(LexError); + } + len += 1; + continue; + } + _ => break, + }; + if digit >= base { + return Err(LexError); + } + len += 1; + empty = false; + } + if empty { + Err(LexError) + } else { + Ok((input.advance(len), ())) + } +} + +fn op(input: Cursor) -> PResult { + let input = skip_whitespace(input); + match op_char(input) { + Ok((rest, '\'')) => { + symbol(rest)?; + Ok((rest, Punct::new('\'', Spacing::Joint))) + } + Ok((rest, ch)) => { + let kind = match op_char(rest) { + Ok(_) => Spacing::Joint, + Err(LexError) => Spacing::Alone, + }; + Ok((rest, Punct::new(ch, kind))) + } + Err(LexError) => Err(LexError), + } +} + +fn op_char(input: Cursor) -> PResult { + if input.starts_with("//") || input.starts_with("/*") { + // Do not accept `/` of a comment as an op. + return Err(LexError); + } + + let mut chars = input.chars(); + let first = match chars.next() { + Some(ch) => ch, + None => { + return Err(LexError); + } + }; + let recognized = "~!@#$%^&*-=+|;:,<.>/?'"; + if recognized.contains(first) { + Ok((input.advance(first.len_utf8()), first)) + } else { + Err(LexError) + } +} + +fn doc_comment(input: Cursor) -> PResult> { + let mut trees = Vec::new(); + let (rest, ((comment, inner), span)) = spanned(input, doc_comment_contents)?; + trees.push(TokenTree::Punct(Punct::new('#', Spacing::Alone))); + if inner { + trees.push(Punct::new('!', Spacing::Alone).into()); + } + let mut stream = vec![ + TokenTree::Ident(::Ident::new("doc", span)), + TokenTree::Punct(Punct::new('=', Spacing::Alone)), + TokenTree::Literal(::Literal::string(comment)), + ]; + for tt in stream.iter_mut() { + tt.set_span(span); + } + let group = Group::new(Delimiter::Bracket, stream.into_iter().collect()); + trees.push(::Group::_new_stable(group).into()); + for tt in trees.iter_mut() { + tt.set_span(span); + } + Ok((rest, trees)) +} + +named!(doc_comment_contents -> (&str, bool), alt!( + do_parse!( + punct!("//!") >> + s: take_until_newline_or_eof!() >> + ((s, true)) + ) + | + do_parse!( + option!(whitespace) >> + peek!(tag!("/*!")) >> + s: block_comment >> + ((s, true)) + ) + | + do_parse!( + punct!("///") >> + not!(tag!("/")) >> + s: take_until_newline_or_eof!() >> + ((s, false)) + ) + | + do_parse!( + option!(whitespace) >> + peek!(tuple!(tag!("/**"), not!(tag!("*")))) >> + s: block_comment >> + ((s, false)) + ) +)); diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/src/lib.rs b/third_party/cargo/vendor/proc-macro2-0.4.30/src/lib.rs new file mode 100644 index 0000000..7181455 --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/src/lib.rs @@ -0,0 +1,1156 @@ +//! A wrapper around the procedural macro API of the compiler's [`proc_macro`] +//! crate. This library serves three purposes: +//! +//! [`proc_macro`]: https://doc.rust-lang.org/proc_macro/ +//! +//! - **Bring proc-macro-like functionality to other contexts like build.rs and +//! main.rs.** Types from `proc_macro` are entirely specific to procedural +//! macros and cannot ever exist in code outside of a procedural macro. +//! Meanwhile `proc_macro2` types may exist anywhere including non-macro code. +//! By developing foundational libraries like [syn] and [quote] against +//! `proc_macro2` rather than `proc_macro`, the procedural macro ecosystem +//! becomes easily applicable to many other use cases and we avoid +//! reimplementing non-macro equivalents of those libraries. +//! +//! - **Make procedural macros unit testable.** As a consequence of being +//! specific to procedural macros, nothing that uses `proc_macro` can be +//! executed from a unit test. In order for helper libraries or components of +//! a macro to be testable in isolation, they must be implemented using +//! `proc_macro2`. +//! +//! - **Provide the latest and greatest APIs across all compiler versions.** +//! Procedural macros were first introduced to Rust in 1.15.0 with an +//! extremely minimal interface. Since then, many improvements have landed to +//! make macros more flexible and easier to write. This library tracks the +//! procedural macro API of the most recent stable compiler but employs a +//! polyfill to provide that API consistently across any compiler since +//! 1.15.0. +//! +//! [syn]: https://github.com/dtolnay/syn +//! [quote]: https://github.com/dtolnay/quote +//! +//! # Usage +//! +//! The skeleton of a typical procedural macro typically looks like this: +//! +//! ```edition2018 +//! extern crate proc_macro; +//! +//! # const IGNORE: &str = stringify! { +//! #[proc_macro_derive(MyDerive)] +//! # }; +//! pub fn my_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { +//! let input = proc_macro2::TokenStream::from(input); +//! +//! let output: proc_macro2::TokenStream = { +//! /* transform input */ +//! # input +//! }; +//! +//! proc_macro::TokenStream::from(output) +//! } +//! ``` +//! +//! If parsing with [Syn], you'll use [`parse_macro_input!`] instead to +//! propagate parse errors correctly back to the compiler when parsing fails. +//! +//! [`parse_macro_input!`]: https://docs.rs/syn/0.15/syn/macro.parse_macro_input.html +//! +//! # Unstable features +//! +//! The default feature set of proc-macro2 tracks the most recent stable +//! compiler API. Functionality in `proc_macro` that is not yet stable is not +//! exposed by proc-macro2 by default. +//! +//! To opt into the additional APIs available in the most recent nightly +//! compiler, the `procmacro2_semver_exempt` config flag must be passed to +//! rustc. As usual, we will polyfill those nightly-only APIs all the way back +//! to Rust 1.15.0. As these are unstable APIs that track the nightly compiler, +//! minor versions of proc-macro2 may make breaking changes to them at any time. +//! +//! ```sh +//! RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build +//! ``` +//! +//! Note that this must not only be done for your crate, but for any crate that +//! depends on your crate. This infectious nature is intentional, as it serves +//! as a reminder that you are outside of the normal semver guarantees. +//! +//! Semver exempt methods are marked as such in the proc-macro2 documentation. + +// Proc-macro2 types in rustdoc of other crates get linked to here. +#![doc(html_root_url = "https://docs.rs/proc-macro2/0.4.30")] +#![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))] +#![cfg_attr(super_unstable, feature(proc_macro_raw_ident, proc_macro_def_site))] + +#[cfg(use_proc_macro)] +extern crate proc_macro; +extern crate unicode_xid; + +use std::cmp::Ordering; +use std::fmt; +use std::hash::{Hash, Hasher}; +use std::iter::FromIterator; +use std::marker; +#[cfg(procmacro2_semver_exempt)] +use std::path::PathBuf; +use std::rc::Rc; +use std::str::FromStr; + +#[macro_use] +mod strnom; +mod fallback; + +#[cfg(not(wrap_proc_macro))] +use fallback as imp; +#[path = "wrapper.rs"] +#[cfg(wrap_proc_macro)] +mod imp; + +/// An abstract stream of tokens, or more concretely a sequence of token trees. +/// +/// This type provides interfaces for iterating over token trees and for +/// collecting token trees into one stream. +/// +/// Token stream is both the input and output of `#[proc_macro]`, +/// `#[proc_macro_attribute]` and `#[proc_macro_derive]` definitions. +#[derive(Clone)] +pub struct TokenStream { + inner: imp::TokenStream, + _marker: marker::PhantomData>, +} + +/// Error returned from `TokenStream::from_str`. +pub struct LexError { + inner: imp::LexError, + _marker: marker::PhantomData>, +} + +impl TokenStream { + fn _new(inner: imp::TokenStream) -> TokenStream { + TokenStream { + inner: inner, + _marker: marker::PhantomData, + } + } + + fn _new_stable(inner: fallback::TokenStream) -> TokenStream { + TokenStream { + inner: inner.into(), + _marker: marker::PhantomData, + } + } + + /// Returns an empty `TokenStream` containing no token trees. + pub fn new() -> TokenStream { + TokenStream::_new(imp::TokenStream::new()) + } + + #[deprecated(since = "0.4.4", note = "please use TokenStream::new")] + pub fn empty() -> TokenStream { + TokenStream::new() + } + + /// Checks if this `TokenStream` is empty. + pub fn is_empty(&self) -> bool { + self.inner.is_empty() + } +} + +/// `TokenStream::default()` returns an empty stream, +/// i.e. this is equivalent with `TokenStream::new()`. +impl Default for TokenStream { + fn default() -> Self { + TokenStream::new() + } +} + +/// Attempts to break the string into tokens and parse those tokens into a token +/// stream. +/// +/// May fail for a number of reasons, for example, if the string contains +/// unbalanced delimiters or characters not existing in the language. +/// +/// NOTE: Some errors may cause panics instead of returning `LexError`. We +/// reserve the right to change these errors into `LexError`s later. +impl FromStr for TokenStream { + type Err = LexError; + + fn from_str(src: &str) -> Result { + let e = src.parse().map_err(|e| LexError { + inner: e, + _marker: marker::PhantomData, + })?; + Ok(TokenStream::_new(e)) + } +} + +#[cfg(use_proc_macro)] +impl From for TokenStream { + fn from(inner: proc_macro::TokenStream) -> TokenStream { + TokenStream::_new(inner.into()) + } +} + +#[cfg(use_proc_macro)] +impl From for proc_macro::TokenStream { + fn from(inner: TokenStream) -> proc_macro::TokenStream { + inner.inner.into() + } +} + +impl Extend for TokenStream { + fn extend>(&mut self, streams: I) { + self.inner.extend(streams) + } +} + +impl Extend for TokenStream { + fn extend>(&mut self, streams: I) { + self.inner + .extend(streams.into_iter().map(|stream| stream.inner)) + } +} + +/// Collects a number of token trees into a single stream. +impl FromIterator for TokenStream { + fn from_iter>(streams: I) -> Self { + TokenStream::_new(streams.into_iter().collect()) + } +} +impl FromIterator for TokenStream { + fn from_iter>(streams: I) -> Self { + TokenStream::_new(streams.into_iter().map(|i| i.inner).collect()) + } +} + +/// Prints the token stream as a string that is supposed to be losslessly +/// convertible back into the same token stream (modulo spans), except for +/// possibly `TokenTree::Group`s with `Delimiter::None` delimiters and negative +/// numeric literals. +impl fmt::Display for TokenStream { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +/// Prints token in a form convenient for debugging. +impl fmt::Debug for TokenStream { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +impl fmt::Debug for LexError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +/// The source file of a given `Span`. +/// +/// This type is semver exempt and not exposed by default. +#[cfg(procmacro2_semver_exempt)] +#[derive(Clone, PartialEq, Eq)] +pub struct SourceFile { + inner: imp::SourceFile, + _marker: marker::PhantomData>, +} + +#[cfg(procmacro2_semver_exempt)] +impl SourceFile { + fn _new(inner: imp::SourceFile) -> Self { + SourceFile { + inner: inner, + _marker: marker::PhantomData, + } + } + + /// Get the path to this source file. + /// + /// ### Note + /// + /// If the code span associated with this `SourceFile` was generated by an + /// external macro, this may not be an actual path on the filesystem. Use + /// [`is_real`] to check. + /// + /// Also note that even if `is_real` returns `true`, if + /// `--remap-path-prefix` was passed on the command line, the path as given + /// may not actually be valid. + /// + /// [`is_real`]: #method.is_real + pub fn path(&self) -> PathBuf { + self.inner.path() + } + + /// Returns `true` if this source file is a real source file, and not + /// generated by an external macro's expansion. + pub fn is_real(&self) -> bool { + self.inner.is_real() + } +} + +#[cfg(procmacro2_semver_exempt)] +impl fmt::Debug for SourceFile { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +/// A line-column pair representing the start or end of a `Span`. +/// +/// This type is semver exempt and not exposed by default. +#[cfg(span_locations)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct LineColumn { + /// The 1-indexed line in the source file on which the span starts or ends + /// (inclusive). + pub line: usize, + /// The 0-indexed column (in UTF-8 characters) in the source file on which + /// the span starts or ends (inclusive). + pub column: usize, +} + +/// A region of source code, along with macro expansion information. +#[derive(Copy, Clone)] +pub struct Span { + inner: imp::Span, + _marker: marker::PhantomData>, +} + +impl Span { + fn _new(inner: imp::Span) -> Span { + Span { + inner: inner, + _marker: marker::PhantomData, + } + } + + fn _new_stable(inner: fallback::Span) -> Span { + Span { + inner: inner.into(), + _marker: marker::PhantomData, + } + } + + /// The span of the invocation of the current procedural macro. + /// + /// Identifiers created with this span will be resolved as if they were + /// written directly at the macro call location (call-site hygiene) and + /// other code at the macro call site will be able to refer to them as well. + pub fn call_site() -> Span { + Span::_new(imp::Span::call_site()) + } + + /// A span that resolves at the macro definition site. + /// + /// This method is semver exempt and not exposed by default. + #[cfg(procmacro2_semver_exempt)] + pub fn def_site() -> Span { + Span::_new(imp::Span::def_site()) + } + + /// Creates a new span with the same line/column information as `self` but + /// that resolves symbols as though it were at `other`. + /// + /// This method is semver exempt and not exposed by default. + #[cfg(procmacro2_semver_exempt)] + pub fn resolved_at(&self, other: Span) -> Span { + Span::_new(self.inner.resolved_at(other.inner)) + } + + /// Creates a new span with the same name resolution behavior as `self` but + /// with the line/column information of `other`. + /// + /// This method is semver exempt and not exposed by default. + #[cfg(procmacro2_semver_exempt)] + pub fn located_at(&self, other: Span) -> Span { + Span::_new(self.inner.located_at(other.inner)) + } + + /// Convert `proc_macro2::Span` to `proc_macro::Span`. + /// + /// This method is available when building with a nightly compiler, or when + /// building with rustc 1.29+ *without* semver exempt features. + /// + /// # Panics + /// + /// Panics if called from outside of a procedural macro. Unlike + /// `proc_macro2::Span`, the `proc_macro::Span` type can only exist within + /// the context of a procedural macro invocation. + #[cfg(wrap_proc_macro)] + pub fn unwrap(self) -> proc_macro::Span { + self.inner.unwrap() + } + + // Soft deprecated. Please use Span::unwrap. + #[cfg(wrap_proc_macro)] + #[doc(hidden)] + pub fn unstable(self) -> proc_macro::Span { + self.unwrap() + } + + /// The original source file into which this span points. + /// + /// This method is semver exempt and not exposed by default. + #[cfg(procmacro2_semver_exempt)] + pub fn source_file(&self) -> SourceFile { + SourceFile::_new(self.inner.source_file()) + } + + /// Get the starting line/column in the source file for this span. + /// + /// This method requires the `"span-locations"` feature to be enabled. + #[cfg(span_locations)] + pub fn start(&self) -> LineColumn { + let imp::LineColumn { line, column } = self.inner.start(); + LineColumn { + line: line, + column: column, + } + } + + /// Get the ending line/column in the source file for this span. + /// + /// This method requires the `"span-locations"` feature to be enabled. + #[cfg(span_locations)] + pub fn end(&self) -> LineColumn { + let imp::LineColumn { line, column } = self.inner.end(); + LineColumn { + line: line, + column: column, + } + } + + /// Create a new span encompassing `self` and `other`. + /// + /// Returns `None` if `self` and `other` are from different files. + /// + /// This method is semver exempt and not exposed by default. + #[cfg(procmacro2_semver_exempt)] + pub fn join(&self, other: Span) -> Option { + self.inner.join(other.inner).map(Span::_new) + } + + /// Compares to spans to see if they're equal. + /// + /// This method is semver exempt and not exposed by default. + #[cfg(procmacro2_semver_exempt)] + pub fn eq(&self, other: &Span) -> bool { + self.inner.eq(&other.inner) + } +} + +/// Prints a span in a form convenient for debugging. +impl fmt::Debug for Span { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +/// A single token or a delimited sequence of token trees (e.g. `[1, (), ..]`). +#[derive(Clone)] +pub enum TokenTree { + /// A token stream surrounded by bracket delimiters. + Group(Group), + /// An identifier. + Ident(Ident), + /// A single punctuation character (`+`, `,`, `$`, etc.). + Punct(Punct), + /// A literal character (`'a'`), string (`"hello"`), number (`2.3`), etc. + Literal(Literal), +} + +impl TokenTree { + /// Returns the span of this tree, delegating to the `span` method of + /// the contained token or a delimited stream. + pub fn span(&self) -> Span { + match *self { + TokenTree::Group(ref t) => t.span(), + TokenTree::Ident(ref t) => t.span(), + TokenTree::Punct(ref t) => t.span(), + TokenTree::Literal(ref t) => t.span(), + } + } + + /// Configures the span for *only this token*. + /// + /// Note that if this token is a `Group` then this method will not configure + /// the span of each of the internal tokens, this will simply delegate to + /// the `set_span` method of each variant. + pub fn set_span(&mut self, span: Span) { + match *self { + TokenTree::Group(ref mut t) => t.set_span(span), + TokenTree::Ident(ref mut t) => t.set_span(span), + TokenTree::Punct(ref mut t) => t.set_span(span), + TokenTree::Literal(ref mut t) => t.set_span(span), + } + } +} + +impl From for TokenTree { + fn from(g: Group) -> TokenTree { + TokenTree::Group(g) + } +} + +impl From for TokenTree { + fn from(g: Ident) -> TokenTree { + TokenTree::Ident(g) + } +} + +impl From for TokenTree { + fn from(g: Punct) -> TokenTree { + TokenTree::Punct(g) + } +} + +impl From for TokenTree { + fn from(g: Literal) -> TokenTree { + TokenTree::Literal(g) + } +} + +/// Prints the token tree as a string that is supposed to be losslessly +/// convertible back into the same token tree (modulo spans), except for +/// possibly `TokenTree::Group`s with `Delimiter::None` delimiters and negative +/// numeric literals. +impl fmt::Display for TokenTree { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + TokenTree::Group(ref t) => t.fmt(f), + TokenTree::Ident(ref t) => t.fmt(f), + TokenTree::Punct(ref t) => t.fmt(f), + TokenTree::Literal(ref t) => t.fmt(f), + } + } +} + +/// Prints token tree in a form convenient for debugging. +impl fmt::Debug for TokenTree { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // Each of these has the name in the struct type in the derived debug, + // so don't bother with an extra layer of indirection + match *self { + TokenTree::Group(ref t) => t.fmt(f), + TokenTree::Ident(ref t) => { + let mut debug = f.debug_struct("Ident"); + debug.field("sym", &format_args!("{}", t)); + imp::debug_span_field_if_nontrivial(&mut debug, t.span().inner); + debug.finish() + } + TokenTree::Punct(ref t) => t.fmt(f), + TokenTree::Literal(ref t) => t.fmt(f), + } + } +} + +/// A delimited token stream. +/// +/// A `Group` internally contains a `TokenStream` which is surrounded by +/// `Delimiter`s. +#[derive(Clone)] +pub struct Group { + inner: imp::Group, +} + +/// Describes how a sequence of token trees is delimited. +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum Delimiter { + /// `( ... )` + Parenthesis, + /// `{ ... }` + Brace, + /// `[ ... ]` + Bracket, + /// `Ø ... Ø` + /// + /// An implicit delimiter, that may, for example, appear around tokens + /// coming from a "macro variable" `$var`. It is important to preserve + /// operator priorities in cases like `$var * 3` where `$var` is `1 + 2`. + /// Implicit delimiters may not survive roundtrip of a token stream through + /// a string. + None, +} + +impl Group { + fn _new(inner: imp::Group) -> Self { + Group { inner: inner } + } + + fn _new_stable(inner: fallback::Group) -> Self { + Group { + inner: inner.into(), + } + } + + /// Creates a new `Group` with the given delimiter and token stream. + /// + /// This constructor will set the span for this group to + /// `Span::call_site()`. To change the span you can use the `set_span` + /// method below. + pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group { + Group { + inner: imp::Group::new(delimiter, stream.inner), + } + } + + /// Returns the delimiter of this `Group` + pub fn delimiter(&self) -> Delimiter { + self.inner.delimiter() + } + + /// Returns the `TokenStream` of tokens that are delimited in this `Group`. + /// + /// Note that the returned token stream does not include the delimiter + /// returned above. + pub fn stream(&self) -> TokenStream { + TokenStream::_new(self.inner.stream()) + } + + /// Returns the span for the delimiters of this token stream, spanning the + /// entire `Group`. + /// + /// ```text + /// pub fn span(&self) -> Span { + /// ^^^^^^^ + /// ``` + pub fn span(&self) -> Span { + Span::_new(self.inner.span()) + } + + /// Returns the span pointing to the opening delimiter of this group. + /// + /// ```text + /// pub fn span_open(&self) -> Span { + /// ^ + /// ``` + #[cfg(procmacro2_semver_exempt)] + pub fn span_open(&self) -> Span { + Span::_new(self.inner.span_open()) + } + + /// Returns the span pointing to the closing delimiter of this group. + /// + /// ```text + /// pub fn span_close(&self) -> Span { + /// ^ + /// ``` + #[cfg(procmacro2_semver_exempt)] + pub fn span_close(&self) -> Span { + Span::_new(self.inner.span_close()) + } + + /// Configures the span for this `Group`'s delimiters, but not its internal + /// tokens. + /// + /// This method will **not** set the span of all the internal tokens spanned + /// by this group, but rather it will only set the span of the delimiter + /// tokens at the level of the `Group`. + pub fn set_span(&mut self, span: Span) { + self.inner.set_span(span.inner) + } +} + +/// Prints the group as a string that should be losslessly convertible back +/// into the same group (modulo spans), except for possibly `TokenTree::Group`s +/// with `Delimiter::None` delimiters. +impl fmt::Display for Group { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.inner, formatter) + } +} + +impl fmt::Debug for Group { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.inner, formatter) + } +} + +/// An `Punct` is an single punctuation character like `+`, `-` or `#`. +/// +/// Multicharacter operators like `+=` are represented as two instances of +/// `Punct` with different forms of `Spacing` returned. +#[derive(Clone)] +pub struct Punct { + op: char, + spacing: Spacing, + span: Span, +} + +/// Whether an `Punct` is followed immediately by another `Punct` or followed by +/// another token or whitespace. +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum Spacing { + /// E.g. `+` is `Alone` in `+ =`, `+ident` or `+()`. + Alone, + /// E.g. `+` is `Joint` in `+=` or `'#`. + /// + /// Additionally, single quote `'` can join with identifiers to form + /// lifetimes `'ident`. + Joint, +} + +impl Punct { + /// Creates a new `Punct` from the given character and spacing. + /// + /// The `ch` argument must be a valid punctuation character permitted by the + /// language, otherwise the function will panic. + /// + /// The returned `Punct` will have the default span of `Span::call_site()` + /// which can be further configured with the `set_span` method below. + pub fn new(op: char, spacing: Spacing) -> Punct { + Punct { + op: op, + spacing: spacing, + span: Span::call_site(), + } + } + + /// Returns the value of this punctuation character as `char`. + pub fn as_char(&self) -> char { + self.op + } + + /// Returns the spacing of this punctuation character, indicating whether + /// it's immediately followed by another `Punct` in the token stream, so + /// they can potentially be combined into a multicharacter operator + /// (`Joint`), or it's followed by some other token or whitespace (`Alone`) + /// so the operator has certainly ended. + pub fn spacing(&self) -> Spacing { + self.spacing + } + + /// Returns the span for this punctuation character. + pub fn span(&self) -> Span { + self.span + } + + /// Configure the span for this punctuation character. + pub fn set_span(&mut self, span: Span) { + self.span = span; + } +} + +/// Prints the punctuation character as a string that should be losslessly +/// convertible back into the same character. +impl fmt::Display for Punct { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.op.fmt(f) + } +} + +impl fmt::Debug for Punct { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let mut debug = fmt.debug_struct("Punct"); + debug.field("op", &self.op); + debug.field("spacing", &self.spacing); + imp::debug_span_field_if_nontrivial(&mut debug, self.span.inner); + debug.finish() + } +} + +/// A word of Rust code, which may be a keyword or legal variable name. +/// +/// An identifier consists of at least one Unicode code point, the first of +/// which has the XID_Start property and the rest of which have the XID_Continue +/// property. +/// +/// - The empty string is not an identifier. Use `Option`. +/// - A lifetime is not an identifier. Use `syn::Lifetime` instead. +/// +/// An identifier constructed with `Ident::new` is permitted to be a Rust +/// keyword, though parsing one through its [`Parse`] implementation rejects +/// Rust keywords. Use `input.call(Ident::parse_any)` when parsing to match the +/// behaviour of `Ident::new`. +/// +/// [`Parse`]: https://docs.rs/syn/0.15/syn/parse/trait.Parse.html +/// +/// # Examples +/// +/// A new ident can be created from a string using the `Ident::new` function. +/// A span must be provided explicitly which governs the name resolution +/// behavior of the resulting identifier. +/// +/// ```edition2018 +/// use proc_macro2::{Ident, Span}; +/// +/// fn main() { +/// let call_ident = Ident::new("calligraphy", Span::call_site()); +/// +/// println!("{}", call_ident); +/// } +/// ``` +/// +/// An ident can be interpolated into a token stream using the `quote!` macro. +/// +/// ```edition2018 +/// use proc_macro2::{Ident, Span}; +/// use quote::quote; +/// +/// fn main() { +/// let ident = Ident::new("demo", Span::call_site()); +/// +/// // Create a variable binding whose name is this ident. +/// let expanded = quote! { let #ident = 10; }; +/// +/// // Create a variable binding with a slightly different name. +/// let temp_ident = Ident::new(&format!("new_{}", ident), Span::call_site()); +/// let expanded = quote! { let #temp_ident = 10; }; +/// } +/// ``` +/// +/// A string representation of the ident is available through the `to_string()` +/// method. +/// +/// ```edition2018 +/// # use proc_macro2::{Ident, Span}; +/// # +/// # let ident = Ident::new("another_identifier", Span::call_site()); +/// # +/// // Examine the ident as a string. +/// let ident_string = ident.to_string(); +/// if ident_string.len() > 60 { +/// println!("Very long identifier: {}", ident_string) +/// } +/// ``` +#[derive(Clone)] +pub struct Ident { + inner: imp::Ident, + _marker: marker::PhantomData>, +} + +impl Ident { + fn _new(inner: imp::Ident) -> Ident { + Ident { + inner: inner, + _marker: marker::PhantomData, + } + } + + /// Creates a new `Ident` with the given `string` as well as the specified + /// `span`. + /// + /// The `string` argument must be a valid identifier permitted by the + /// language, otherwise the function will panic. + /// + /// Note that `span`, currently in rustc, configures the hygiene information + /// for this identifier. + /// + /// As of this time `Span::call_site()` explicitly opts-in to "call-site" + /// hygiene meaning that identifiers created with this span will be resolved + /// as if they were written directly at the location of the macro call, and + /// other code at the macro call site will be able to refer to them as well. + /// + /// Later spans like `Span::def_site()` will allow to opt-in to + /// "definition-site" hygiene meaning that identifiers created with this + /// span will be resolved at the location of the macro definition and other + /// code at the macro call site will not be able to refer to them. + /// + /// Due to the current importance of hygiene this constructor, unlike other + /// tokens, requires a `Span` to be specified at construction. + /// + /// # Panics + /// + /// Panics if the input string is neither a keyword nor a legal variable + /// name. If you are not sure whether the string contains an identifier and + /// need to handle an error case, use + /// syn::parse_str::<Ident> + /// rather than `Ident::new`. + pub fn new(string: &str, span: Span) -> Ident { + Ident::_new(imp::Ident::new(string, span.inner)) + } + + /// Same as `Ident::new`, but creates a raw identifier (`r#ident`). + /// + /// This method is semver exempt and not exposed by default. + #[cfg(procmacro2_semver_exempt)] + pub fn new_raw(string: &str, span: Span) -> Ident { + Ident::_new_raw(string, span) + } + + fn _new_raw(string: &str, span: Span) -> Ident { + Ident::_new(imp::Ident::new_raw(string, span.inner)) + } + + /// Returns the span of this `Ident`. + pub fn span(&self) -> Span { + Span::_new(self.inner.span()) + } + + /// Configures the span of this `Ident`, possibly changing its hygiene + /// context. + pub fn set_span(&mut self, span: Span) { + self.inner.set_span(span.inner); + } +} + +impl PartialEq for Ident { + fn eq(&self, other: &Ident) -> bool { + self.inner == other.inner + } +} + +impl PartialEq for Ident +where + T: ?Sized + AsRef, +{ + fn eq(&self, other: &T) -> bool { + self.inner == other + } +} + +impl Eq for Ident {} + +impl PartialOrd for Ident { + fn partial_cmp(&self, other: &Ident) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Ident { + fn cmp(&self, other: &Ident) -> Ordering { + self.to_string().cmp(&other.to_string()) + } +} + +impl Hash for Ident { + fn hash(&self, hasher: &mut H) { + self.to_string().hash(hasher) + } +} + +/// Prints the identifier as a string that should be losslessly convertible back +/// into the same identifier. +impl fmt::Display for Ident { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +impl fmt::Debug for Ident { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +/// A literal string (`"hello"`), byte string (`b"hello"`), character (`'a'`), +/// byte character (`b'a'`), an integer or floating point number with or without +/// a suffix (`1`, `1u8`, `2.3`, `2.3f32`). +/// +/// Boolean literals like `true` and `false` do not belong here, they are +/// `Ident`s. +#[derive(Clone)] +pub struct Literal { + inner: imp::Literal, + _marker: marker::PhantomData>, +} + +macro_rules! suffixed_int_literals { + ($($name:ident => $kind:ident,)*) => ($( + /// Creates a new suffixed integer literal with the specified value. + /// + /// This function will create an integer like `1u32` where the integer + /// value specified is the first part of the token and the integral is + /// also suffixed at the end. Literals created from negative numbers may + /// not survive rountrips through `TokenStream` or strings and may be + /// broken into two tokens (`-` and positive literal). + /// + /// Literals created through this method have the `Span::call_site()` + /// span by default, which can be configured with the `set_span` method + /// below. + pub fn $name(n: $kind) -> Literal { + Literal::_new(imp::Literal::$name(n)) + } + )*) +} + +macro_rules! unsuffixed_int_literals { + ($($name:ident => $kind:ident,)*) => ($( + /// Creates a new unsuffixed integer literal with the specified value. + /// + /// This function will create an integer like `1` where the integer + /// value specified is the first part of the token. No suffix is + /// specified on this token, meaning that invocations like + /// `Literal::i8_unsuffixed(1)` are equivalent to + /// `Literal::u32_unsuffixed(1)`. Literals created from negative numbers + /// may not survive rountrips through `TokenStream` or strings and may + /// be broken into two tokens (`-` and positive literal). + /// + /// Literals created through this method have the `Span::call_site()` + /// span by default, which can be configured with the `set_span` method + /// below. + pub fn $name(n: $kind) -> Literal { + Literal::_new(imp::Literal::$name(n)) + } + )*) +} + +impl Literal { + fn _new(inner: imp::Literal) -> Literal { + Literal { + inner: inner, + _marker: marker::PhantomData, + } + } + + fn _new_stable(inner: fallback::Literal) -> Literal { + Literal { + inner: inner.into(), + _marker: marker::PhantomData, + } + } + + suffixed_int_literals! { + u8_suffixed => u8, + u16_suffixed => u16, + u32_suffixed => u32, + u64_suffixed => u64, + usize_suffixed => usize, + i8_suffixed => i8, + i16_suffixed => i16, + i32_suffixed => i32, + i64_suffixed => i64, + isize_suffixed => isize, + } + + #[cfg(u128)] + suffixed_int_literals! { + u128_suffixed => u128, + i128_suffixed => i128, + } + + unsuffixed_int_literals! { + u8_unsuffixed => u8, + u16_unsuffixed => u16, + u32_unsuffixed => u32, + u64_unsuffixed => u64, + usize_unsuffixed => usize, + i8_unsuffixed => i8, + i16_unsuffixed => i16, + i32_unsuffixed => i32, + i64_unsuffixed => i64, + isize_unsuffixed => isize, + } + + #[cfg(u128)] + unsuffixed_int_literals! { + u128_unsuffixed => u128, + i128_unsuffixed => i128, + } + + pub fn f64_unsuffixed(f: f64) -> Literal { + assert!(f.is_finite()); + Literal::_new(imp::Literal::f64_unsuffixed(f)) + } + + pub fn f64_suffixed(f: f64) -> Literal { + assert!(f.is_finite()); + Literal::_new(imp::Literal::f64_suffixed(f)) + } + + /// Creates a new unsuffixed floating-point literal. + /// + /// This constructor is similar to those like `Literal::i8_unsuffixed` where + /// the float's value is emitted directly into the token but no suffix is + /// used, so it may be inferred to be a `f64` later in the compiler. + /// Literals created from negative numbers may not survive rountrips through + /// `TokenStream` or strings and may be broken into two tokens (`-` and + /// positive literal). + /// + /// # Panics + /// + /// This function requires that the specified float is finite, for example + /// if it is infinity or NaN this function will panic. + pub fn f32_unsuffixed(f: f32) -> Literal { + assert!(f.is_finite()); + Literal::_new(imp::Literal::f32_unsuffixed(f)) + } + + pub fn f32_suffixed(f: f32) -> Literal { + assert!(f.is_finite()); + Literal::_new(imp::Literal::f32_suffixed(f)) + } + + pub fn string(string: &str) -> Literal { + Literal::_new(imp::Literal::string(string)) + } + + pub fn character(ch: char) -> Literal { + Literal::_new(imp::Literal::character(ch)) + } + + pub fn byte_string(s: &[u8]) -> Literal { + Literal::_new(imp::Literal::byte_string(s)) + } + + pub fn span(&self) -> Span { + Span::_new(self.inner.span()) + } + + pub fn set_span(&mut self, span: Span) { + self.inner.set_span(span.inner); + } +} + +impl fmt::Debug for Literal { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +impl fmt::Display for Literal { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +/// Public implementation details for the `TokenStream` type, such as iterators. +pub mod token_stream { + use std::fmt; + use std::marker; + use std::rc::Rc; + + use imp; + pub use TokenStream; + use TokenTree; + + /// An iterator over `TokenStream`'s `TokenTree`s. + /// + /// The iteration is "shallow", e.g. the iterator doesn't recurse into + /// delimited groups, and returns whole groups as token trees. + #[derive(Clone)] + pub struct IntoIter { + inner: imp::TokenTreeIter, + _marker: marker::PhantomData>, + } + + impl Iterator for IntoIter { + type Item = TokenTree; + + fn next(&mut self) -> Option { + self.inner.next() + } + } + + impl fmt::Debug for IntoIter { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } + } + + impl IntoIterator for TokenStream { + type Item = TokenTree; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + IntoIter { + inner: self.inner.into_iter(), + _marker: marker::PhantomData, + } + } + } +} diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/src/strnom.rs b/third_party/cargo/vendor/proc-macro2-0.4.30/src/strnom.rs new file mode 100644 index 0000000..96789d5 --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/src/strnom.rs @@ -0,0 +1,393 @@ +//! Adapted from [`nom`](https://github.com/Geal/nom). + +use std::str::{Bytes, CharIndices, Chars}; + +use unicode_xid::UnicodeXID; + +use fallback::LexError; + +#[derive(Copy, Clone, Eq, PartialEq)] +pub struct Cursor<'a> { + pub rest: &'a str, + #[cfg(span_locations)] + pub off: u32, +} + +impl<'a> Cursor<'a> { + #[cfg(not(span_locations))] + pub fn advance(&self, amt: usize) -> Cursor<'a> { + Cursor { + rest: &self.rest[amt..], + } + } + #[cfg(span_locations)] + pub fn advance(&self, amt: usize) -> Cursor<'a> { + Cursor { + rest: &self.rest[amt..], + off: self.off + (amt as u32), + } + } + + pub fn find(&self, p: char) -> Option { + self.rest.find(p) + } + + pub fn starts_with(&self, s: &str) -> bool { + self.rest.starts_with(s) + } + + pub fn is_empty(&self) -> bool { + self.rest.is_empty() + } + + pub fn len(&self) -> usize { + self.rest.len() + } + + pub fn as_bytes(&self) -> &'a [u8] { + self.rest.as_bytes() + } + + pub fn bytes(&self) -> Bytes<'a> { + self.rest.bytes() + } + + pub fn chars(&self) -> Chars<'a> { + self.rest.chars() + } + + pub fn char_indices(&self) -> CharIndices<'a> { + self.rest.char_indices() + } +} + +pub type PResult<'a, O> = Result<(Cursor<'a>, O), LexError>; + +pub fn whitespace(input: Cursor) -> PResult<()> { + if input.is_empty() { + return Err(LexError); + } + + let bytes = input.as_bytes(); + let mut i = 0; + while i < bytes.len() { + let s = input.advance(i); + if bytes[i] == b'/' { + if s.starts_with("//") + && (!s.starts_with("///") || s.starts_with("////")) + && !s.starts_with("//!") + { + if let Some(len) = s.find('\n') { + i += len + 1; + continue; + } + break; + } else if s.starts_with("/**/") { + i += 4; + continue; + } else if s.starts_with("/*") + && (!s.starts_with("/**") || s.starts_with("/***")) + && !s.starts_with("/*!") + { + let (_, com) = block_comment(s)?; + i += com.len(); + continue; + } + } + match bytes[i] { + b' ' | 0x09...0x0d => { + i += 1; + continue; + } + b if b <= 0x7f => {} + _ => { + let ch = s.chars().next().unwrap(); + if is_whitespace(ch) { + i += ch.len_utf8(); + continue; + } + } + } + return if i > 0 { Ok((s, ())) } else { Err(LexError) }; + } + Ok((input.advance(input.len()), ())) +} + +pub fn block_comment(input: Cursor) -> PResult<&str> { + if !input.starts_with("/*") { + return Err(LexError); + } + + let mut depth = 0; + let bytes = input.as_bytes(); + let mut i = 0; + let upper = bytes.len() - 1; + while i < upper { + if bytes[i] == b'/' && bytes[i + 1] == b'*' { + depth += 1; + i += 1; // eat '*' + } else if bytes[i] == b'*' && bytes[i + 1] == b'/' { + depth -= 1; + if depth == 0 { + return Ok((input.advance(i + 2), &input.rest[..i + 2])); + } + i += 1; // eat '/' + } + i += 1; + } + Err(LexError) +} + +pub fn skip_whitespace(input: Cursor) -> Cursor { + match whitespace(input) { + Ok((rest, _)) => rest, + Err(LexError) => input, + } +} + +fn is_whitespace(ch: char) -> bool { + // Rust treats left-to-right mark and right-to-left mark as whitespace + ch.is_whitespace() || ch == '\u{200e}' || ch == '\u{200f}' +} + +pub fn word_break(input: Cursor) -> PResult<()> { + match input.chars().next() { + Some(ch) if UnicodeXID::is_xid_continue(ch) => Err(LexError), + Some(_) | None => Ok((input, ())), + } +} + +macro_rules! named { + ($name:ident -> $o:ty, $submac:ident!( $($args:tt)* )) => { + fn $name<'a>(i: Cursor<'a>) -> $crate::strnom::PResult<'a, $o> { + $submac!(i, $($args)*) + } + }; +} + +macro_rules! alt { + ($i:expr, $e:ident | $($rest:tt)*) => { + alt!($i, call!($e) | $($rest)*) + }; + + ($i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => { + match $subrule!($i, $($args)*) { + res @ Ok(_) => res, + _ => alt!($i, $($rest)*) + } + }; + + ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)+) => { + match $subrule!($i, $($args)*) { + Ok((i, o)) => Ok((i, $gen(o))), + Err(LexError) => alt!($i, $($rest)*) + } + }; + + ($i:expr, $e:ident => { $gen:expr } | $($rest:tt)*) => { + alt!($i, call!($e) => { $gen } | $($rest)*) + }; + + ($i:expr, $e:ident => { $gen:expr }) => { + alt!($i, call!($e) => { $gen }) + }; + + ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr }) => { + match $subrule!($i, $($args)*) { + Ok((i, o)) => Ok((i, $gen(o))), + Err(LexError) => Err(LexError), + } + }; + + ($i:expr, $e:ident) => { + alt!($i, call!($e)) + }; + + ($i:expr, $subrule:ident!( $($args:tt)*)) => { + $subrule!($i, $($args)*) + }; +} + +macro_rules! do_parse { + ($i:expr, ( $($rest:expr),* )) => { + Ok(($i, ( $($rest),* ))) + }; + + ($i:expr, $e:ident >> $($rest:tt)*) => { + do_parse!($i, call!($e) >> $($rest)*) + }; + + ($i:expr, $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { + match $submac!($i, $($args)*) { + Err(LexError) => Err(LexError), + Ok((i, _)) => do_parse!(i, $($rest)*), + } + }; + + ($i:expr, $field:ident : $e:ident >> $($rest:tt)*) => { + do_parse!($i, $field: call!($e) >> $($rest)*) + }; + + ($i:expr, $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { + match $submac!($i, $($args)*) { + Err(LexError) => Err(LexError), + Ok((i, o)) => { + let $field = o; + do_parse!(i, $($rest)*) + }, + } + }; +} + +macro_rules! peek { + ($i:expr, $submac:ident!( $($args:tt)* )) => { + match $submac!($i, $($args)*) { + Ok((_, o)) => Ok(($i, o)), + Err(LexError) => Err(LexError), + } + }; +} + +macro_rules! call { + ($i:expr, $fun:expr $(, $args:expr)*) => { + $fun($i $(, $args)*) + }; +} + +macro_rules! option { + ($i:expr, $f:expr) => { + match $f($i) { + Ok((i, o)) => Ok((i, Some(o))), + Err(LexError) => Ok(($i, None)), + } + }; +} + +macro_rules! take_until_newline_or_eof { + ($i:expr,) => {{ + if $i.len() == 0 { + Ok(($i, "")) + } else { + match $i.find('\n') { + Some(i) => Ok(($i.advance(i), &$i.rest[..i])), + None => Ok(($i.advance($i.len()), &$i.rest[..$i.len()])), + } + } + }}; +} + +macro_rules! tuple { + ($i:expr, $($rest:tt)*) => { + tuple_parser!($i, (), $($rest)*) + }; +} + +/// Do not use directly. Use `tuple!`. +macro_rules! tuple_parser { + ($i:expr, ($($parsed:tt),*), $e:ident, $($rest:tt)*) => { + tuple_parser!($i, ($($parsed),*), call!($e), $($rest)*) + }; + + ($i:expr, (), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => { + match $submac!($i, $($args)*) { + Err(LexError) => Err(LexError), + Ok((i, o)) => tuple_parser!(i, (o), $($rest)*), + } + }; + + ($i:expr, ($($parsed:tt)*), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => { + match $submac!($i, $($args)*) { + Err(LexError) => Err(LexError), + Ok((i, o)) => tuple_parser!(i, ($($parsed)* , o), $($rest)*), + } + }; + + ($i:expr, ($($parsed:tt),*), $e:ident) => { + tuple_parser!($i, ($($parsed),*), call!($e)) + }; + + ($i:expr, (), $submac:ident!( $($args:tt)* )) => { + $submac!($i, $($args)*) + }; + + ($i:expr, ($($parsed:expr),*), $submac:ident!( $($args:tt)* )) => { + match $submac!($i, $($args)*) { + Err(LexError) => Err(LexError), + Ok((i, o)) => Ok((i, ($($parsed),*, o))) + } + }; + + ($i:expr, ($($parsed:expr),*)) => { + Ok(($i, ($($parsed),*))) + }; +} + +macro_rules! not { + ($i:expr, $submac:ident!( $($args:tt)* )) => { + match $submac!($i, $($args)*) { + Ok((_, _)) => Err(LexError), + Err(LexError) => Ok(($i, ())), + } + }; +} + +macro_rules! tag { + ($i:expr, $tag:expr) => { + if $i.starts_with($tag) { + Ok(($i.advance($tag.len()), &$i.rest[..$tag.len()])) + } else { + Err(LexError) + } + }; +} + +macro_rules! punct { + ($i:expr, $punct:expr) => { + $crate::strnom::punct($i, $punct) + }; +} + +/// Do not use directly. Use `punct!`. +pub fn punct<'a>(input: Cursor<'a>, token: &'static str) -> PResult<'a, &'a str> { + let input = skip_whitespace(input); + if input.starts_with(token) { + Ok((input.advance(token.len()), token)) + } else { + Err(LexError) + } +} + +macro_rules! preceded { + ($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => { + match tuple!($i, $submac!($($args)*), $submac2!($($args2)*)) { + Ok((remaining, (_, o))) => Ok((remaining, o)), + Err(LexError) => Err(LexError), + } + }; + + ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => { + preceded!($i, $submac!($($args)*), call!($g)) + }; +} + +macro_rules! delimited { + ($i:expr, $submac:ident!( $($args:tt)* ), $($rest:tt)+) => { + match tuple_parser!($i, (), $submac!($($args)*), $($rest)*) { + Err(LexError) => Err(LexError), + Ok((i1, (_, o, _))) => Ok((i1, o)) + } + }; +} + +macro_rules! map { + ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => { + match $submac!($i, $($args)*) { + Err(LexError) => Err(LexError), + Ok((i, o)) => Ok((i, call!(o, $g))) + } + }; + + ($i:expr, $f:expr, $g:expr) => { + map!($i, call!($f), $g) + }; +} diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/src/wrapper.rs b/third_party/cargo/vendor/proc-macro2-0.4.30/src/wrapper.rs new file mode 100644 index 0000000..994ed24 --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/src/wrapper.rs @@ -0,0 +1,928 @@ +use std::fmt; +use std::iter; +use std::panic::{self, PanicInfo}; +#[cfg(super_unstable)] +use std::path::PathBuf; +use std::str::FromStr; + +use fallback; +use proc_macro; + +use {Delimiter, Punct, Spacing, TokenTree}; + +#[derive(Clone)] +pub enum TokenStream { + Compiler(proc_macro::TokenStream), + Fallback(fallback::TokenStream), +} + +pub enum LexError { + Compiler(proc_macro::LexError), + Fallback(fallback::LexError), +} + +fn nightly_works() -> bool { + use std::sync::atomic::*; + use std::sync::Once; + + #[allow(deprecated)] + static WORKS: AtomicUsize = ATOMIC_USIZE_INIT; + static INIT: Once = Once::new(); + + match WORKS.load(Ordering::SeqCst) { + 1 => return false, + 2 => return true, + _ => {} + } + + // Swap in a null panic hook to avoid printing "thread panicked" to stderr, + // then use catch_unwind to determine whether the compiler's proc_macro is + // working. When proc-macro2 is used from outside of a procedural macro all + // of the proc_macro crate's APIs currently panic. + // + // The Once is to prevent the possibility of this ordering: + // + // thread 1 calls take_hook, gets the user's original hook + // thread 1 calls set_hook with the null hook + // thread 2 calls take_hook, thinks null hook is the original hook + // thread 2 calls set_hook with the null hook + // thread 1 calls set_hook with the actual original hook + // thread 2 calls set_hook with what it thinks is the original hook + // + // in which the user's hook has been lost. + // + // There is still a race condition where a panic in a different thread can + // happen during the interval that the user's original panic hook is + // unregistered such that their hook is incorrectly not called. This is + // sufficiently unlikely and less bad than printing panic messages to stderr + // on correct use of this crate. Maybe there is a libstd feature request + // here. For now, if a user needs to guarantee that this failure mode does + // not occur, they need to call e.g. `proc_macro2::Span::call_site()` from + // the main thread before launching any other threads. + INIT.call_once(|| { + type PanicHook = Fn(&PanicInfo) + Sync + Send + 'static; + + let null_hook: Box = Box::new(|_panic_info| { /* ignore */ }); + let sanity_check = &*null_hook as *const PanicHook; + let original_hook = panic::take_hook(); + panic::set_hook(null_hook); + + let works = panic::catch_unwind(|| proc_macro::Span::call_site()).is_ok(); + WORKS.store(works as usize + 1, Ordering::SeqCst); + + let hopefully_null_hook = panic::take_hook(); + panic::set_hook(original_hook); + if sanity_check != &*hopefully_null_hook { + panic!("observed race condition in proc_macro2::nightly_works"); + } + }); + nightly_works() +} + +fn mismatch() -> ! { + panic!("stable/nightly mismatch") +} + +impl TokenStream { + pub fn new() -> TokenStream { + if nightly_works() { + TokenStream::Compiler(proc_macro::TokenStream::new()) + } else { + TokenStream::Fallback(fallback::TokenStream::new()) + } + } + + pub fn is_empty(&self) -> bool { + match self { + TokenStream::Compiler(tts) => tts.is_empty(), + TokenStream::Fallback(tts) => tts.is_empty(), + } + } + + fn unwrap_nightly(self) -> proc_macro::TokenStream { + match self { + TokenStream::Compiler(s) => s, + TokenStream::Fallback(_) => mismatch(), + } + } + + fn unwrap_stable(self) -> fallback::TokenStream { + match self { + TokenStream::Compiler(_) => mismatch(), + TokenStream::Fallback(s) => s, + } + } +} + +impl FromStr for TokenStream { + type Err = LexError; + + fn from_str(src: &str) -> Result { + if nightly_works() { + Ok(TokenStream::Compiler(src.parse()?)) + } else { + Ok(TokenStream::Fallback(src.parse()?)) + } + } +} + +impl fmt::Display for TokenStream { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + TokenStream::Compiler(tts) => tts.fmt(f), + TokenStream::Fallback(tts) => tts.fmt(f), + } + } +} + +impl From for TokenStream { + fn from(inner: proc_macro::TokenStream) -> TokenStream { + TokenStream::Compiler(inner) + } +} + +impl From for proc_macro::TokenStream { + fn from(inner: TokenStream) -> proc_macro::TokenStream { + match inner { + TokenStream::Compiler(inner) => inner, + TokenStream::Fallback(inner) => inner.to_string().parse().unwrap(), + } + } +} + +impl From for TokenStream { + fn from(inner: fallback::TokenStream) -> TokenStream { + TokenStream::Fallback(inner) + } +} + +impl From for TokenStream { + fn from(token: TokenTree) -> TokenStream { + if !nightly_works() { + return TokenStream::Fallback(token.into()); + } + let tt: proc_macro::TokenTree = match token { + TokenTree::Group(tt) => tt.inner.unwrap_nightly().into(), + TokenTree::Punct(tt) => { + let spacing = match tt.spacing() { + Spacing::Joint => proc_macro::Spacing::Joint, + Spacing::Alone => proc_macro::Spacing::Alone, + }; + let mut op = proc_macro::Punct::new(tt.as_char(), spacing); + op.set_span(tt.span().inner.unwrap_nightly()); + op.into() + } + TokenTree::Ident(tt) => tt.inner.unwrap_nightly().into(), + TokenTree::Literal(tt) => tt.inner.unwrap_nightly().into(), + }; + TokenStream::Compiler(tt.into()) + } +} + +impl iter::FromIterator for TokenStream { + fn from_iter>(trees: I) -> Self { + if nightly_works() { + let trees = trees + .into_iter() + .map(TokenStream::from) + .flat_map(|t| match t { + TokenStream::Compiler(s) => s, + TokenStream::Fallback(_) => mismatch(), + }); + TokenStream::Compiler(trees.collect()) + } else { + TokenStream::Fallback(trees.into_iter().collect()) + } + } +} + +impl iter::FromIterator for TokenStream { + fn from_iter>(streams: I) -> Self { + let mut streams = streams.into_iter(); + match streams.next() { + #[cfg(slow_extend)] + Some(TokenStream::Compiler(first)) => { + let stream = iter::once(first) + .chain(streams.map(|s| match s { + TokenStream::Compiler(s) => s, + TokenStream::Fallback(_) => mismatch(), + })) + .collect(); + TokenStream::Compiler(stream) + } + #[cfg(not(slow_extend))] + Some(TokenStream::Compiler(mut first)) => { + first.extend(streams.map(|s| match s { + TokenStream::Compiler(s) => s, + TokenStream::Fallback(_) => mismatch(), + })); + TokenStream::Compiler(first) + } + Some(TokenStream::Fallback(mut first)) => { + first.extend(streams.map(|s| match s { + TokenStream::Fallback(s) => s, + TokenStream::Compiler(_) => mismatch(), + })); + TokenStream::Fallback(first) + } + None => TokenStream::new(), + } + } +} + +impl Extend for TokenStream { + fn extend>(&mut self, streams: I) { + match self { + TokenStream::Compiler(tts) => { + #[cfg(not(slow_extend))] + { + tts.extend( + streams + .into_iter() + .map(|t| TokenStream::from(t).unwrap_nightly()), + ); + } + #[cfg(slow_extend)] + { + *tts = + tts.clone() + .into_iter() + .chain(streams.into_iter().map(TokenStream::from).flat_map( + |t| match t { + TokenStream::Compiler(tts) => tts.into_iter(), + _ => mismatch(), + }, + )) + .collect(); + } + } + TokenStream::Fallback(tts) => tts.extend(streams), + } + } +} + +impl Extend for TokenStream { + fn extend>(&mut self, streams: I) { + match self { + TokenStream::Compiler(tts) => { + #[cfg(not(slow_extend))] + { + tts.extend(streams.into_iter().map(|stream| stream.unwrap_nightly())); + } + #[cfg(slow_extend)] + { + *tts = tts + .clone() + .into_iter() + .chain(streams.into_iter().flat_map(|t| match t { + TokenStream::Compiler(tts) => tts.into_iter(), + _ => mismatch(), + })) + .collect(); + } + } + TokenStream::Fallback(tts) => { + tts.extend(streams.into_iter().map(|stream| stream.unwrap_stable())) + } + } + } +} + +impl fmt::Debug for TokenStream { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + TokenStream::Compiler(tts) => tts.fmt(f), + TokenStream::Fallback(tts) => tts.fmt(f), + } + } +} + +impl From for LexError { + fn from(e: proc_macro::LexError) -> LexError { + LexError::Compiler(e) + } +} + +impl From for LexError { + fn from(e: fallback::LexError) -> LexError { + LexError::Fallback(e) + } +} + +impl fmt::Debug for LexError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + LexError::Compiler(e) => e.fmt(f), + LexError::Fallback(e) => e.fmt(f), + } + } +} + +#[derive(Clone)] +pub enum TokenTreeIter { + Compiler(proc_macro::token_stream::IntoIter), + Fallback(fallback::TokenTreeIter), +} + +impl IntoIterator for TokenStream { + type Item = TokenTree; + type IntoIter = TokenTreeIter; + + fn into_iter(self) -> TokenTreeIter { + match self { + TokenStream::Compiler(tts) => TokenTreeIter::Compiler(tts.into_iter()), + TokenStream::Fallback(tts) => TokenTreeIter::Fallback(tts.into_iter()), + } + } +} + +impl Iterator for TokenTreeIter { + type Item = TokenTree; + + fn next(&mut self) -> Option { + let token = match self { + TokenTreeIter::Compiler(iter) => iter.next()?, + TokenTreeIter::Fallback(iter) => return iter.next(), + }; + Some(match token { + proc_macro::TokenTree::Group(tt) => ::Group::_new(Group::Compiler(tt)).into(), + proc_macro::TokenTree::Punct(tt) => { + let spacing = match tt.spacing() { + proc_macro::Spacing::Joint => Spacing::Joint, + proc_macro::Spacing::Alone => Spacing::Alone, + }; + let mut o = Punct::new(tt.as_char(), spacing); + o.set_span(::Span::_new(Span::Compiler(tt.span()))); + o.into() + } + proc_macro::TokenTree::Ident(s) => ::Ident::_new(Ident::Compiler(s)).into(), + proc_macro::TokenTree::Literal(l) => ::Literal::_new(Literal::Compiler(l)).into(), + }) + } + + fn size_hint(&self) -> (usize, Option) { + match self { + TokenTreeIter::Compiler(tts) => tts.size_hint(), + TokenTreeIter::Fallback(tts) => tts.size_hint(), + } + } +} + +impl fmt::Debug for TokenTreeIter { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("TokenTreeIter").finish() + } +} + +#[derive(Clone, PartialEq, Eq)] +#[cfg(super_unstable)] +pub enum SourceFile { + Compiler(proc_macro::SourceFile), + Fallback(fallback::SourceFile), +} + +#[cfg(super_unstable)] +impl SourceFile { + fn nightly(sf: proc_macro::SourceFile) -> Self { + SourceFile::Compiler(sf) + } + + /// Get the path to this source file as a string. + pub fn path(&self) -> PathBuf { + match self { + SourceFile::Compiler(a) => a.path(), + SourceFile::Fallback(a) => a.path(), + } + } + + pub fn is_real(&self) -> bool { + match self { + SourceFile::Compiler(a) => a.is_real(), + SourceFile::Fallback(a) => a.is_real(), + } + } +} + +#[cfg(super_unstable)] +impl fmt::Debug for SourceFile { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + SourceFile::Compiler(a) => a.fmt(f), + SourceFile::Fallback(a) => a.fmt(f), + } + } +} + +#[cfg(any(super_unstable, feature = "span-locations"))] +pub struct LineColumn { + pub line: usize, + pub column: usize, +} + +#[derive(Copy, Clone)] +pub enum Span { + Compiler(proc_macro::Span), + Fallback(fallback::Span), +} + +impl Span { + pub fn call_site() -> Span { + if nightly_works() { + Span::Compiler(proc_macro::Span::call_site()) + } else { + Span::Fallback(fallback::Span::call_site()) + } + } + + #[cfg(super_unstable)] + pub fn def_site() -> Span { + if nightly_works() { + Span::Compiler(proc_macro::Span::def_site()) + } else { + Span::Fallback(fallback::Span::def_site()) + } + } + + #[cfg(super_unstable)] + pub fn resolved_at(&self, other: Span) -> Span { + match (self, other) { + (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.resolved_at(b)), + (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.resolved_at(b)), + _ => mismatch(), + } + } + + #[cfg(super_unstable)] + pub fn located_at(&self, other: Span) -> Span { + match (self, other) { + (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.located_at(b)), + (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.located_at(b)), + _ => mismatch(), + } + } + + pub fn unwrap(self) -> proc_macro::Span { + match self { + Span::Compiler(s) => s, + Span::Fallback(_) => panic!("proc_macro::Span is only available in procedural macros"), + } + } + + #[cfg(super_unstable)] + pub fn source_file(&self) -> SourceFile { + match self { + Span::Compiler(s) => SourceFile::nightly(s.source_file()), + Span::Fallback(s) => SourceFile::Fallback(s.source_file()), + } + } + + #[cfg(any(super_unstable, feature = "span-locations"))] + pub fn start(&self) -> LineColumn { + match self { + #[cfg(proc_macro_span)] + Span::Compiler(s) => { + let proc_macro::LineColumn { line, column } = s.start(); + LineColumn { line, column } + } + #[cfg(not(proc_macro_span))] + Span::Compiler(_) => LineColumn { line: 0, column: 0 }, + Span::Fallback(s) => { + let fallback::LineColumn { line, column } = s.start(); + LineColumn { line, column } + } + } + } + + #[cfg(any(super_unstable, feature = "span-locations"))] + pub fn end(&self) -> LineColumn { + match self { + #[cfg(proc_macro_span)] + Span::Compiler(s) => { + let proc_macro::LineColumn { line, column } = s.end(); + LineColumn { line, column } + } + #[cfg(not(proc_macro_span))] + Span::Compiler(_) => LineColumn { line: 0, column: 0 }, + Span::Fallback(s) => { + let fallback::LineColumn { line, column } = s.end(); + LineColumn { line, column } + } + } + } + + #[cfg(super_unstable)] + pub fn join(&self, other: Span) -> Option { + let ret = match (self, other) { + (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.join(b)?), + (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.join(b)?), + _ => return None, + }; + Some(ret) + } + + #[cfg(super_unstable)] + pub fn eq(&self, other: &Span) -> bool { + match (self, other) { + (Span::Compiler(a), Span::Compiler(b)) => a.eq(b), + (Span::Fallback(a), Span::Fallback(b)) => a.eq(b), + _ => false, + } + } + + fn unwrap_nightly(self) -> proc_macro::Span { + match self { + Span::Compiler(s) => s, + Span::Fallback(_) => mismatch(), + } + } +} + +impl From for ::Span { + fn from(proc_span: proc_macro::Span) -> ::Span { + ::Span::_new(Span::Compiler(proc_span)) + } +} + +impl From for Span { + fn from(inner: fallback::Span) -> Span { + Span::Fallback(inner) + } +} + +impl fmt::Debug for Span { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Span::Compiler(s) => s.fmt(f), + Span::Fallback(s) => s.fmt(f), + } + } +} + +pub fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) { + match span { + Span::Compiler(s) => { + debug.field("span", &s); + } + Span::Fallback(s) => fallback::debug_span_field_if_nontrivial(debug, s), + } +} + +#[derive(Clone)] +pub enum Group { + Compiler(proc_macro::Group), + Fallback(fallback::Group), +} + +impl Group { + pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group { + match stream { + TokenStream::Compiler(stream) => { + let delimiter = match delimiter { + Delimiter::Parenthesis => proc_macro::Delimiter::Parenthesis, + Delimiter::Bracket => proc_macro::Delimiter::Bracket, + Delimiter::Brace => proc_macro::Delimiter::Brace, + Delimiter::None => proc_macro::Delimiter::None, + }; + Group::Compiler(proc_macro::Group::new(delimiter, stream)) + } + TokenStream::Fallback(stream) => { + Group::Fallback(fallback::Group::new(delimiter, stream)) + } + } + } + + pub fn delimiter(&self) -> Delimiter { + match self { + Group::Compiler(g) => match g.delimiter() { + proc_macro::Delimiter::Parenthesis => Delimiter::Parenthesis, + proc_macro::Delimiter::Bracket => Delimiter::Bracket, + proc_macro::Delimiter::Brace => Delimiter::Brace, + proc_macro::Delimiter::None => Delimiter::None, + }, + Group::Fallback(g) => g.delimiter(), + } + } + + pub fn stream(&self) -> TokenStream { + match self { + Group::Compiler(g) => TokenStream::Compiler(g.stream()), + Group::Fallback(g) => TokenStream::Fallback(g.stream()), + } + } + + pub fn span(&self) -> Span { + match self { + Group::Compiler(g) => Span::Compiler(g.span()), + Group::Fallback(g) => Span::Fallback(g.span()), + } + } + + #[cfg(super_unstable)] + pub fn span_open(&self) -> Span { + match self { + Group::Compiler(g) => Span::Compiler(g.span_open()), + Group::Fallback(g) => Span::Fallback(g.span_open()), + } + } + + #[cfg(super_unstable)] + pub fn span_close(&self) -> Span { + match self { + Group::Compiler(g) => Span::Compiler(g.span_close()), + Group::Fallback(g) => Span::Fallback(g.span_close()), + } + } + + pub fn set_span(&mut self, span: Span) { + match (self, span) { + (Group::Compiler(g), Span::Compiler(s)) => g.set_span(s), + (Group::Fallback(g), Span::Fallback(s)) => g.set_span(s), + _ => mismatch(), + } + } + + fn unwrap_nightly(self) -> proc_macro::Group { + match self { + Group::Compiler(g) => g, + Group::Fallback(_) => mismatch(), + } + } +} + +impl From for Group { + fn from(g: fallback::Group) -> Self { + Group::Fallback(g) + } +} + +impl fmt::Display for Group { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + match self { + Group::Compiler(group) => group.fmt(formatter), + Group::Fallback(group) => group.fmt(formatter), + } + } +} + +impl fmt::Debug for Group { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + match self { + Group::Compiler(group) => group.fmt(formatter), + Group::Fallback(group) => group.fmt(formatter), + } + } +} + +#[derive(Clone)] +pub enum Ident { + Compiler(proc_macro::Ident), + Fallback(fallback::Ident), +} + +impl Ident { + pub fn new(string: &str, span: Span) -> Ident { + match span { + Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new(string, s)), + Span::Fallback(s) => Ident::Fallback(fallback::Ident::new(string, s)), + } + } + + pub fn new_raw(string: &str, span: Span) -> Ident { + match span { + Span::Compiler(s) => { + let p: proc_macro::TokenStream = string.parse().unwrap(); + let ident = match p.into_iter().next() { + Some(proc_macro::TokenTree::Ident(mut i)) => { + i.set_span(s); + i + } + _ => panic!(), + }; + Ident::Compiler(ident) + } + Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_raw(string, s)), + } + } + + pub fn span(&self) -> Span { + match self { + Ident::Compiler(t) => Span::Compiler(t.span()), + Ident::Fallback(t) => Span::Fallback(t.span()), + } + } + + pub fn set_span(&mut self, span: Span) { + match (self, span) { + (Ident::Compiler(t), Span::Compiler(s)) => t.set_span(s), + (Ident::Fallback(t), Span::Fallback(s)) => t.set_span(s), + _ => mismatch(), + } + } + + fn unwrap_nightly(self) -> proc_macro::Ident { + match self { + Ident::Compiler(s) => s, + Ident::Fallback(_) => mismatch(), + } + } +} + +impl PartialEq for Ident { + fn eq(&self, other: &Ident) -> bool { + match (self, other) { + (Ident::Compiler(t), Ident::Compiler(o)) => t.to_string() == o.to_string(), + (Ident::Fallback(t), Ident::Fallback(o)) => t == o, + _ => mismatch(), + } + } +} + +impl PartialEq for Ident +where + T: ?Sized + AsRef, +{ + fn eq(&self, other: &T) -> bool { + let other = other.as_ref(); + match self { + Ident::Compiler(t) => t.to_string() == other, + Ident::Fallback(t) => t == other, + } + } +} + +impl fmt::Display for Ident { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Ident::Compiler(t) => t.fmt(f), + Ident::Fallback(t) => t.fmt(f), + } + } +} + +impl fmt::Debug for Ident { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Ident::Compiler(t) => t.fmt(f), + Ident::Fallback(t) => t.fmt(f), + } + } +} + +#[derive(Clone)] +pub enum Literal { + Compiler(proc_macro::Literal), + Fallback(fallback::Literal), +} + +macro_rules! suffixed_numbers { + ($($name:ident => $kind:ident,)*) => ($( + pub fn $name(n: $kind) -> Literal { + if nightly_works() { + Literal::Compiler(proc_macro::Literal::$name(n)) + } else { + Literal::Fallback(fallback::Literal::$name(n)) + } + } + )*) +} + +macro_rules! unsuffixed_integers { + ($($name:ident => $kind:ident,)*) => ($( + pub fn $name(n: $kind) -> Literal { + if nightly_works() { + Literal::Compiler(proc_macro::Literal::$name(n)) + } else { + Literal::Fallback(fallback::Literal::$name(n)) + } + } + )*) +} + +impl Literal { + suffixed_numbers! { + u8_suffixed => u8, + u16_suffixed => u16, + u32_suffixed => u32, + u64_suffixed => u64, + usize_suffixed => usize, + i8_suffixed => i8, + i16_suffixed => i16, + i32_suffixed => i32, + i64_suffixed => i64, + isize_suffixed => isize, + + f32_suffixed => f32, + f64_suffixed => f64, + } + + #[cfg(u128)] + suffixed_numbers! { + i128_suffixed => i128, + u128_suffixed => u128, + } + + unsuffixed_integers! { + u8_unsuffixed => u8, + u16_unsuffixed => u16, + u32_unsuffixed => u32, + u64_unsuffixed => u64, + usize_unsuffixed => usize, + i8_unsuffixed => i8, + i16_unsuffixed => i16, + i32_unsuffixed => i32, + i64_unsuffixed => i64, + isize_unsuffixed => isize, + } + + #[cfg(u128)] + unsuffixed_integers! { + i128_unsuffixed => i128, + u128_unsuffixed => u128, + } + + pub fn f32_unsuffixed(f: f32) -> Literal { + if nightly_works() { + Literal::Compiler(proc_macro::Literal::f32_unsuffixed(f)) + } else { + Literal::Fallback(fallback::Literal::f32_unsuffixed(f)) + } + } + + pub fn f64_unsuffixed(f: f64) -> Literal { + if nightly_works() { + Literal::Compiler(proc_macro::Literal::f64_unsuffixed(f)) + } else { + Literal::Fallback(fallback::Literal::f64_unsuffixed(f)) + } + } + + pub fn string(t: &str) -> Literal { + if nightly_works() { + Literal::Compiler(proc_macro::Literal::string(t)) + } else { + Literal::Fallback(fallback::Literal::string(t)) + } + } + + pub fn character(t: char) -> Literal { + if nightly_works() { + Literal::Compiler(proc_macro::Literal::character(t)) + } else { + Literal::Fallback(fallback::Literal::character(t)) + } + } + + pub fn byte_string(bytes: &[u8]) -> Literal { + if nightly_works() { + Literal::Compiler(proc_macro::Literal::byte_string(bytes)) + } else { + Literal::Fallback(fallback::Literal::byte_string(bytes)) + } + } + + pub fn span(&self) -> Span { + match self { + Literal::Compiler(lit) => Span::Compiler(lit.span()), + Literal::Fallback(lit) => Span::Fallback(lit.span()), + } + } + + pub fn set_span(&mut self, span: Span) { + match (self, span) { + (Literal::Compiler(lit), Span::Compiler(s)) => lit.set_span(s), + (Literal::Fallback(lit), Span::Fallback(s)) => lit.set_span(s), + _ => mismatch(), + } + } + + fn unwrap_nightly(self) -> proc_macro::Literal { + match self { + Literal::Compiler(s) => s, + Literal::Fallback(_) => mismatch(), + } + } +} + +impl From for Literal { + fn from(s: fallback::Literal) -> Literal { + Literal::Fallback(s) + } +} + +impl fmt::Display for Literal { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Literal::Compiler(t) => t.fmt(f), + Literal::Fallback(t) => t.fmt(f), + } + } +} + +impl fmt::Debug for Literal { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Literal::Compiler(t) => t.fmt(f), + Literal::Fallback(t) => t.fmt(f), + } + } +} diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/tests/marker.rs b/third_party/cargo/vendor/proc-macro2-0.4.30/tests/marker.rs new file mode 100644 index 0000000..7bb5027 --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/tests/marker.rs @@ -0,0 +1,61 @@ +extern crate proc_macro2; + +use proc_macro2::*; + +macro_rules! assert_impl { + ($ty:ident is $($marker:ident) and +) => { + #[test] + #[allow(non_snake_case)] + fn $ty() { + fn assert_implemented() {} + assert_implemented::<$ty>(); + } + }; + + ($ty:ident is not $($marker:ident) or +) => { + #[test] + #[allow(non_snake_case)] + fn $ty() { + $( + { + // Implemented for types that implement $marker. + trait IsNotImplemented { + fn assert_not_implemented() {} + } + impl IsNotImplemented for T {} + + // Implemented for the type being tested. + trait IsImplemented { + fn assert_not_implemented() {} + } + impl IsImplemented for $ty {} + + // If $ty does not implement $marker, there is no ambiguity + // in the following trait method call. + <$ty>::assert_not_implemented(); + } + )+ + } + }; +} + +assert_impl!(Delimiter is Send and Sync); +assert_impl!(Spacing is Send and Sync); + +assert_impl!(Group is not Send or Sync); +assert_impl!(Ident is not Send or Sync); +assert_impl!(LexError is not Send or Sync); +assert_impl!(Literal is not Send or Sync); +assert_impl!(Punct is not Send or Sync); +assert_impl!(Span is not Send or Sync); +assert_impl!(TokenStream is not Send or Sync); +assert_impl!(TokenTree is not Send or Sync); + +#[cfg(procmacro2_semver_exempt)] +mod semver_exempt { + use super::*; + + assert_impl!(LineColumn is Send and Sync); + + assert_impl!(SourceFile is not Send or Sync); +} diff --git a/third_party/cargo/vendor/proc-macro2-0.4.30/tests/test.rs b/third_party/cargo/vendor/proc-macro2-0.4.30/tests/test.rs new file mode 100644 index 0000000..370392b --- /dev/null +++ b/third_party/cargo/vendor/proc-macro2-0.4.30/tests/test.rs @@ -0,0 +1,452 @@ +extern crate proc_macro2; + +use std::str::{self, FromStr}; + +use proc_macro2::{Ident, Literal, Spacing, Span, TokenStream, TokenTree}; + +#[test] +fn idents() { + assert_eq!( + Ident::new("String", Span::call_site()).to_string(), + "String" + ); + assert_eq!(Ident::new("fn", Span::call_site()).to_string(), "fn"); + assert_eq!(Ident::new("_", Span::call_site()).to_string(), "_"); +} + +#[test] +#[cfg(procmacro2_semver_exempt)] +fn raw_idents() { + assert_eq!( + Ident::new_raw("String", Span::call_site()).to_string(), + "r#String" + ); + assert_eq!(Ident::new_raw("fn", Span::call_site()).to_string(), "r#fn"); + assert_eq!(Ident::new_raw("_", Span::call_site()).to_string(), "r#_"); +} + +#[test] +#[should_panic(expected = "Ident is not allowed to be empty; use Option")] +fn ident_empty() { + Ident::new("", Span::call_site()); +} + +#[test] +#[should_panic(expected = "Ident cannot be a number; use Literal instead")] +fn ident_number() { + Ident::new("255", Span::call_site()); +} + +#[test] +#[should_panic(expected = "\"a#\" is not a valid Ident")] +fn ident_invalid() { + Ident::new("a#", Span::call_site()); +} + +#[test] +#[should_panic(expected = "not a valid Ident")] +fn raw_ident_empty() { + Ident::new("r#", Span::call_site()); +} + +#[test] +#[should_panic(expected = "not a valid Ident")] +fn raw_ident_number() { + Ident::new("r#255", Span::call_site()); +} + +#[test] +#[should_panic(expected = "\"r#a#\" is not a valid Ident")] +fn raw_ident_invalid() { + Ident::new("r#a#", Span::call_site()); +} + +#[test] +#[should_panic(expected = "not a valid Ident")] +fn lifetime_empty() { + Ident::new("'", Span::call_site()); +} + +#[test] +#[should_panic(expected = "not a valid Ident")] +fn lifetime_number() { + Ident::new("'255", Span::call_site()); +} + +#[test] +#[should_panic(expected = r#""\'a#" is not a valid Ident"#)] +fn lifetime_invalid() { + Ident::new("'a#", Span::call_site()); +} + +#[test] +fn literal_string() { + assert_eq!(Literal::string("foo").to_string(), "\"foo\""); + assert_eq!(Literal::string("\"").to_string(), "\"\\\"\""); + assert_eq!(Literal::string("didn't").to_string(), "\"didn't\""); +} + +#[test] +fn literal_character() { + assert_eq!(Literal::character('x').to_string(), "'x'"); + assert_eq!(Literal::character('\'').to_string(), "'\\''"); + assert_eq!(Literal::character('"').to_string(), "'\"'"); +} + +#[test] +fn literal_float() { + assert_eq!(Literal::f32_unsuffixed(10.0).to_string(), "10.0"); +} + +#[test] +fn roundtrip() { + fn roundtrip(p: &str) { + println!("parse: {}", p); + let s = p.parse::().unwrap().to_string(); + println!("first: {}", s); + let s2 = s.to_string().parse::().unwrap().to_string(); + assert_eq!(s, s2); + } + roundtrip("a"); + roundtrip("<<"); + roundtrip("<<="); + roundtrip( + " + 1 + 1.0 + 1f32 + 2f64 + 1usize + 4isize + 4e10 + 1_000 + 1_0i32 + 8u8 + 9 + 0 + 0xffffffffffffffffffffffffffffffff + ", + ); + roundtrip("'a"); + roundtrip("'_"); + roundtrip("'static"); + roundtrip("'\\u{10__FFFF}'"); + roundtrip("\"\\u{10_F0FF__}foo\\u{1_0_0_0__}\""); +} + +#[test] +fn fail() { + fn fail(p: &str) { + if let Ok(s) = p.parse::() { + panic!("should have failed to parse: {}\n{:#?}", p, s); + } + } + fail("1x"); + fail("1u80"); + fail("1f320"); + fail("' static"); + fail("r#1"); + fail("r#_"); +} + +#[cfg(span_locations)] +#[test] +fn span_test() { + use proc_macro2::TokenTree; + + fn check_spans(p: &str, mut lines: &[(usize, usize, usize, usize)]) { + let ts = p.parse::().unwrap(); + check_spans_internal(ts, &mut lines); + } + + fn check_spans_internal(ts: TokenStream, lines: &mut &[(usize, usize, usize, usize)]) { + for i in ts { + if let Some((&(sline, scol, eline, ecol), rest)) = lines.split_first() { + *lines = rest; + + let start = i.span().start(); + assert_eq!(start.line, sline, "sline did not match for {}", i); + assert_eq!(start.column, scol, "scol did not match for {}", i); + + let end = i.span().end(); + assert_eq!(end.line, eline, "eline did not match for {}", i); + assert_eq!(end.column, ecol, "ecol did not match for {}", i); + + match i { + TokenTree::Group(ref g) => { + check_spans_internal(g.stream().clone(), lines); + } + _ => {} + } + } + } + } + + check_spans( + "\ +/// This is a document comment +testing 123 +{ + testing 234 +}", + &[ + (1, 0, 1, 30), // # + (1, 0, 1, 30), // [ ... ] + (1, 0, 1, 30), // doc + (1, 0, 1, 30), // = + (1, 0, 1, 30), // "This is..." + (2, 0, 2, 7), // testing + (2, 8, 2, 11), // 123 + (3, 0, 5, 1), // { ... } + (4, 2, 4, 9), // testing + (4, 10, 4, 13), // 234 + ], + ); +} + +#[cfg(procmacro2_semver_exempt)] +#[cfg(not(nightly))] +#[test] +fn default_span() { + let start = Span::call_site().start(); + assert_eq!(start.line, 1); + assert_eq!(start.column, 0); + let end = Span::call_site().end(); + assert_eq!(end.line, 1); + assert_eq!(end.column, 0); + let source_file = Span::call_site().source_file(); + assert_eq!(source_file.path().to_string_lossy(), ""); + assert!(!source_file.is_real()); +} + +#[cfg(procmacro2_semver_exempt)] +#[test] +fn span_join() { + let source1 = "aaa\nbbb" + .parse::() + .unwrap() + .into_iter() + .collect::>(); + let source2 = "ccc\nddd" + .parse::() + .unwrap() + .into_iter() + .collect::>(); + + assert!(source1[0].span().source_file() != source2[0].span().source_file()); + assert_eq!( + source1[0].span().source_file(), + source1[1].span().source_file() + ); + + let joined1 = source1[0].span().join(source1[1].span()); + let joined2 = source1[0].span().join(source2[0].span()); + assert!(joined1.is_some()); + assert!(joined2.is_none()); + + let start = joined1.unwrap().start(); + let end = joined1.unwrap().end(); + assert_eq!(start.line, 1); + assert_eq!(start.column, 0); + assert_eq!(end.line, 2); + assert_eq!(end.column, 3); + + assert_eq!( + joined1.unwrap().source_file(), + source1[0].span().source_file() + ); +} + +#[test] +fn no_panic() { + let s = str::from_utf8(b"b\'\xc2\x86 \x00\x00\x00^\"").unwrap(); + assert!(s.parse::().is_err()); +} + +#[test] +fn tricky_doc_comment() { + let stream = "/**/".parse::().unwrap(); + let tokens = stream.into_iter().collect::>(); + assert!(tokens.is_empty(), "not empty -- {:?}", tokens); + + let stream = "/// doc".parse::().unwrap(); + let tokens = stream.into_iter().collect::>(); + assert!(tokens.len() == 2, "not length 2 -- {:?}", tokens); + match tokens[0] { + proc_macro2::TokenTree::Punct(ref tt) => assert_eq!(tt.as_char(), '#'), + _ => panic!("wrong token {:?}", tokens[0]), + } + let mut tokens = match tokens[1] { + proc_macro2::TokenTree::Group(ref tt) => { + assert_eq!(tt.delimiter(), proc_macro2::Delimiter::Bracket); + tt.stream().into_iter() + } + _ => panic!("wrong token {:?}", tokens[0]), + }; + + match tokens.next().unwrap() { + proc_macro2::TokenTree::Ident(ref tt) => assert_eq!(tt.to_string(), "doc"), + t => panic!("wrong token {:?}", t), + } + match tokens.next().unwrap() { + proc_macro2::TokenTree::Punct(ref tt) => assert_eq!(tt.as_char(), '='), + t => panic!("wrong token {:?}", t), + } + match tokens.next().unwrap() { + proc_macro2::TokenTree::Literal(ref tt) => { + assert_eq!(tt.to_string(), "\" doc\""); + } + t => panic!("wrong token {:?}", t), + } + assert!(tokens.next().is_none()); + + let stream = "//! doc".parse::().unwrap(); + let tokens = stream.into_iter().collect::>(); + assert!(tokens.len() == 3, "not length 3 -- {:?}", tokens); +} + +#[test] +fn op_before_comment() { + let mut tts = TokenStream::from_str("~// comment").unwrap().into_iter(); + match tts.next().unwrap() { + TokenTree::Punct(tt) => { + assert_eq!(tt.as_char(), '~'); + assert_eq!(tt.spacing(), Spacing::Alone); + } + wrong => panic!("wrong token {:?}", wrong), + } +} + +#[test] +fn raw_identifier() { + let mut tts = TokenStream::from_str("r#dyn").unwrap().into_iter(); + match tts.next().unwrap() { + TokenTree::Ident(raw) => assert_eq!("r#dyn", raw.to_string()), + wrong => panic!("wrong token {:?}", wrong), + } + assert!(tts.next().is_none()); +} + +#[test] +fn test_debug_ident() { + let ident = Ident::new("proc_macro", Span::call_site()); + + #[cfg(not(procmacro2_semver_exempt))] + let expected = "Ident(proc_macro)"; + + #[cfg(procmacro2_semver_exempt)] + let expected = "Ident { sym: proc_macro, span: bytes(0..0) }"; + + assert_eq!(expected, format!("{:?}", ident)); +} + +#[test] +fn test_debug_tokenstream() { + let tts = TokenStream::from_str("[a + 1]").unwrap(); + + #[cfg(not(procmacro2_semver_exempt))] + let expected = "\ +TokenStream [ + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + sym: a, + }, + Punct { + op: '+', + spacing: Alone, + }, + Literal { + lit: 1, + }, + ], + }, +]\ + "; + + #[cfg(not(procmacro2_semver_exempt))] + let expected_before_trailing_commas = "\ +TokenStream [ + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + sym: a + }, + Punct { + op: '+', + spacing: Alone + }, + Literal { + lit: 1 + } + ] + } +]\ + "; + + #[cfg(procmacro2_semver_exempt)] + let expected = "\ +TokenStream [ + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + sym: a, + span: bytes(2..3), + }, + Punct { + op: '+', + spacing: Alone, + span: bytes(4..5), + }, + Literal { + lit: 1, + span: bytes(6..7), + }, + ], + span: bytes(1..8), + }, +]\ + "; + + #[cfg(procmacro2_semver_exempt)] + let expected_before_trailing_commas = "\ +TokenStream [ + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + sym: a, + span: bytes(2..3) + }, + Punct { + op: '+', + spacing: Alone, + span: bytes(4..5) + }, + Literal { + lit: 1, + span: bytes(6..7) + } + ], + span: bytes(1..8) + } +]\ + "; + + let actual = format!("{:#?}", tts); + if actual.ends_with(",\n]") { + assert_eq!(expected, actual); + } else { + assert_eq!(expected_before_trailing_commas, actual); + } +} + +#[test] +fn default_tokenstream_is_empty() { + let default_token_stream: TokenStream = Default::default(); + + assert!(default_token_stream.is_empty()); +} diff --git a/third_party/cargo/vendor/quick-error-1.2.3/.cargo-checksum.json b/third_party/cargo/vendor/quick-error-1.2.3/.cargo-checksum.json new file mode 100644 index 0000000..0605353 --- /dev/null +++ b/third_party/cargo/vendor/quick-error-1.2.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"1f24b567c7f10b4ec44f5baf033d27da39f659c09df0e8a057437d10ecdd551a","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"058f01fe181608d027fcde7e528fc03ea3cf90f30903c407644b0a9bbc54f500","README.rst":"8bd690e0089d4c38eb71f1327f5144741009f4b2f49f0b16f2547f528171e2e6","bulk.yaml":"17c2548388e0cd3a63473021a2f1e4ddedee082d79d9167cb31ad06a1890d3fc","examples/context.rs":"b9be9a4ca021a1f0ba659932bfc0cf891728bfaea49d48a8be183644c492515b","src/lib.rs":"a02c8a3c40fa1dcee8285b9c238d40cb3078cf4dded1c972fa6361a485d1667f","vagga.yaml":"b01ad1fd3aa25de2439c0f7a437c6517808ba3a7eeeb0363eb209f08e326cc8e"},"package":"a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"} \ No newline at end of file diff --git a/third_party/cargo/vendor/quick-error-1.2.3/BUILD b/third_party/cargo/vendor/quick-error-1.2.3/BUILD new file mode 100644 index 0000000..318b98b --- /dev/null +++ b/third_party/cargo/vendor/quick-error-1.2.3/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "context" with type "example" omitted + +rust_library( + name = "quick_error", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.2.3", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/quick-error-1.2.3/Cargo.toml b/third_party/cargo/vendor/quick-error-1.2.3/Cargo.toml new file mode 100644 index 0000000..b5d5f60 --- /dev/null +++ b/third_party/cargo/vendor/quick-error-1.2.3/Cargo.toml @@ -0,0 +1,23 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "quick-error" +version = "1.2.3" +authors = ["Paul Colomiets ", "Colin Kiegel "] +description = " A macro which makes error types pleasant to write.\n" +homepage = "http://github.com/tailhook/quick-error" +documentation = "http://docs.rs/quick-error" +keywords = ["macro", "error", "type", "enum"] +categories = ["rust-patterns"] +license = "MIT/Apache-2.0" +repository = "http://github.com/tailhook/quick-error" diff --git a/third_party/cargo/vendor/quick-error-1.2.3/LICENSE-APACHE b/third_party/cargo/vendor/quick-error-1.2.3/LICENSE-APACHE new file mode 100644 index 0000000..8f71f43 --- /dev/null +++ b/third_party/cargo/vendor/quick-error-1.2.3/LICENSE-APACHE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/third_party/cargo/vendor/quick-error-1.2.3/LICENSE-MIT b/third_party/cargo/vendor/quick-error-1.2.3/LICENSE-MIT new file mode 100644 index 0000000..14f715b --- /dev/null +++ b/third_party/cargo/vendor/quick-error-1.2.3/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) 2015 The quick-error Developers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/quick-error-1.2.3/README.rst b/third_party/cargo/vendor/quick-error-1.2.3/README.rst new file mode 100644 index 0000000..e54c055 --- /dev/null +++ b/third_party/cargo/vendor/quick-error-1.2.3/README.rst @@ -0,0 +1,66 @@ +=========== +Quick Error +=========== + +:Status: production-ready +:Documentation: http://tailhook.github.io/quick-error/ + +A macro which makes error types pleasant to write. + +Features: + +* Define enum type with arbitrary parameters +* Concise notation of ``Display`` and ``Error`` traits +* Full control of ``Display`` and ``Error`` trait implementation +* Any number of ``From`` traits +* Support for all enum-variants ``Unit``, ``Tuple`` and ``Struct`` + +Here is the comprehensive example: + +.. code-block:: rust + + quick_error! { + #[derive(Debug)] + pub enum IoWrapper { + Io(err: io::Error) { + from() + display("I/O error: {}", err) + cause(err) + } + Other(descr: &'static str) { + display("Error {}", descr) + } + IoAt { place: &'static str, err: io::Error } { + cause(err) + display(me) -> ("io error at {}: {}", place, err) + from(s: String) -> { + place: "some string", + err: io::Error::new(io::ErrorKind::Other, s) + } + } + Discard { + from(&'static str) + } + } + } + +======= +License +======= + +Licensed under either of + + * Apache License, Version 2.0, (./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license (./LICENSE-MIT or http://opensource.org/licenses/MIT) + +at your option. + +------------ +Contribution +------------ + +Unless you explicitly state otherwise, any contribution intentionally +submitted for inclusion in the work by you, as defined in the Apache-2.0 +license, shall be dual licensed as above, without any additional terms or +conditions. + diff --git a/third_party/cargo/vendor/quick-error-1.2.3/bulk.yaml b/third_party/cargo/vendor/quick-error-1.2.3/bulk.yaml new file mode 100644 index 0000000..cdb9763 --- /dev/null +++ b/third_party/cargo/vendor/quick-error-1.2.3/bulk.yaml @@ -0,0 +1,8 @@ +minimum-bulk: v0.4.5 + +versions: + +- file: Cargo.toml + block-start: ^\[package\] + block-end: ^\[.*\] + regex: ^version\s*=\s*"(\S+)" diff --git a/third_party/cargo/vendor/quick-error-1.2.3/examples/context.rs b/third_party/cargo/vendor/quick-error-1.2.3/examples/context.rs new file mode 100644 index 0000000..334700a --- /dev/null +++ b/third_party/cargo/vendor/quick-error-1.2.3/examples/context.rs @@ -0,0 +1,48 @@ +#[macro_use(quick_error)] extern crate quick_error; + +use std::io::{self, stderr, Read, Write}; +use std::fs::File; +use std::env; +use std::num::ParseIntError; +use std::path::{Path, PathBuf}; + +use quick_error::ResultExt; + +quick_error! { + #[derive(Debug)] + pub enum Error { + NoFileName { + description("no file name specified") + } + Io(err: io::Error, path: PathBuf) { + display("could not read file {:?}: {}", path, err) + context(path: &'a Path, err: io::Error) + -> (err, path.to_path_buf()) + } + Parse(err: ParseIntError, path: PathBuf) { + display("could not parse file {:?}: {}", path, err) + context(path: &'a Path, err: ParseIntError) + -> (err, path.to_path_buf()) + } + } +} + +fn parse_file() -> Result { + let fname = try!(env::args().skip(1).next().ok_or(Error::NoFileName)); + let fname = Path::new(&fname); + let mut file = try!(File::open(fname).context(fname)); + let mut buf = String::new(); + try!(file.read_to_string(&mut buf).context(fname)); + Ok(try!(buf.parse().context(fname))) +} + +fn main() { + match parse_file() { + Ok(val) => { + println!("Read: {}", val); + } + Err(e) => { + writeln!(&mut stderr(), "Error: {}", e).ok(); + } + } +} diff --git a/third_party/cargo/vendor/quick-error-1.2.3/src/lib.rs b/third_party/cargo/vendor/quick-error-1.2.3/src/lib.rs new file mode 100644 index 0000000..17fc455 --- /dev/null +++ b/third_party/cargo/vendor/quick-error-1.2.3/src/lib.rs @@ -0,0 +1,1262 @@ +#![warn(missing_docs)] +//! A macro which makes errors easy to write +//! +//! Minimum type is like this: +//! +//! ```rust +//! #[macro_use] extern crate quick_error; +//! # fn main() {} +//! +//! quick_error! { +//! #[derive(Debug)] +//! pub enum SomeError { +//! Variant1 {} +//! } +//! } +//! ``` +//! Both ``pub`` and non-public types may be declared, and all meta attributes +//! (such as ``#[derive(Debug)]``) are forwarded as is. The `Debug` must be +//! implemented (but you may do that yourself if you like). The documentation +//! comments ``/// something`` (as well as other meta attrbiutes) on variants +//! are allowed. +//! +//! # Allowed Syntax +//! +//! You may add arbitrary parameters to any struct variant: +//! +//! ```rust +//! # #[macro_use] extern crate quick_error; +//! # fn main() {} +//! # +//! quick_error! { +//! #[derive(Debug)] +//! pub enum SomeError { +//! /// IO Error +//! Io(err: std::io::Error) {} +//! /// Utf8 Error +//! Utf8(err: std::str::Utf8Error) {} +//! } +//! } +//! ``` +//! +//! Note unlike in normal Enum declarations you declare names of fields (which +//! are omitted from type). How they can be used is outlined below. +//! +//! Now you might have noticed trailing braces `{}`. They are used to define +//! implementations. By default: +//! +//! * `Error::cause()` returns None (even if type wraps some value) +//! * `Display` outputs debug representation +//! * No `From` implementations are defined +//! +//! ```rust +//! # #[macro_use] extern crate quick_error; +//! # fn main() {} +//! # +//! quick_error! { +//! #[derive(Debug)] +//! pub enum SomeError { +//! Io(err: std::io::Error) { +//! display("{}", err) +//! } +//! Utf8(err: std::str::Utf8Error) { +//! display("utf8 error") +//! } +//! } +//! } +//! ``` +//! +//! To change `cause` method to return some error, add `cause(value)`, for +//! example: +//! +//! ```rust +//! # #[macro_use] extern crate quick_error; +//! # fn main() {} +//! # +//! quick_error! { +//! #[derive(Debug)] +//! pub enum SomeError { +//! Io(err: std::io::Error) { +//! cause(err) +//! } +//! Utf8(err: std::str::Utf8Error) { +//! display("utf8 error") +//! } +//! Other(err: Box) { +//! cause(&**err) +//! } +//! } +//! } +//! ``` +//! Note you don't need to wrap value in `Some`, its implicit. In case you want +//! `None` returned just omit the `cause`. You can't return `None` +//! conditionally. +//! +//! To change how each clause is `Display`ed add `display(pattern,..args)`, +//! for example: +//! +//! ```rust +//! # #[macro_use] extern crate quick_error; +//! # fn main() {} +//! # +//! quick_error! { +//! #[derive(Debug)] +//! pub enum SomeError { +//! Io(err: std::io::Error) { +//! display("I/O error: {}", err) +//! } +//! Utf8(err: std::str::Utf8Error) { +//! display("Utf8 error, valid up to {}", err.valid_up_to()) +//! } +//! } +//! } +//! ``` +//! +//! If you need a reference to the error when `Display`ing, you can instead use +//! `display(x) -> (pattern, ..args)`, where `x` sets the name of the reference. +//! +//! ```rust +//! # #[macro_use] extern crate quick_error; +//! # fn main() {} +//! # +//! use std::error::Error; // put methods like `source()` of this trait into scope +//! +//! quick_error! { +//! #[derive(Debug)] +//! pub enum SomeError { +//! Io(err: std::io::Error) { +//! display(x) -> ("I/O: {}", err) +//! } +//! Utf8(err: std::str::Utf8Error) { +//! display(self_) -> ("UTF-8 error. Valid up to {}", err.valid_up_to()) +//! } +//! } +//! } +//! ``` +//! +//! To convert to the type from any other, use one of the three forms of +//! `from` clause. +//! +//! For example, to convert simple wrapper use bare `from()`: +//! +//! ```rust +//! # #[macro_use] extern crate quick_error; +//! # fn main() {} +//! # +//! quick_error! { +//! #[derive(Debug)] +//! pub enum SomeError { +//! Io(err: std::io::Error) { +//! from() +//! } +//! } +//! } +//! ``` +//! +//! This implements ``From``. +//! +//! To convert to singleton enumeration type (discarding the value), use +//! the `from(type)` form: +//! +//! ```rust +//! # #[macro_use] extern crate quick_error; +//! # fn main() {} +//! # +//! quick_error! { +//! #[derive(Debug)] +//! pub enum SomeError { +//! FormatError { +//! from(std::fmt::Error) +//! } +//! } +//! } +//! ``` +//! +//! And the most powerful form is `from(var: type) -> (arguments...)`. It +//! might be used to convert to type with multiple arguments or for arbitrary +//! value conversions: +//! +//! ```rust +//! # #[macro_use] extern crate quick_error; +//! # fn main() {} +//! # +//! quick_error! { +//! #[derive(Debug)] +//! pub enum SomeError { +//! FailedOperation(s: &'static str, errno: i32) { +//! from(errno: i32) -> ("os error", errno) +//! from(e: std::io::Error) -> ("io error", e.raw_os_error().unwrap()) +//! } +//! /// Converts from both kinds of utf8 errors +//! Utf8(err: std::str::Utf8Error) { +//! from() +//! from(err: std::string::FromUtf8Error) -> (err.utf8_error()) +//! } +//! } +//! } +//! ``` +//! # Context +//! +//! Since quick-error 1.1 we also have a `context` declaration, which is +//! similar to (the longest form of) `from`, but allows adding some context to +//! the error. We need a longer example to demonstrate this: +//! +//! ```rust +//! # #[macro_use] extern crate quick_error; +//! # use std::io; +//! # use std::fs::File; +//! # use std::path::{Path, PathBuf}; +//! # +//! use quick_error::ResultExt; +//! +//! quick_error! { +//! #[derive(Debug)] +//! pub enum Error { +//! File(filename: PathBuf, err: io::Error) { +//! context(path: &'a Path, err: io::Error) +//! -> (path.to_path_buf(), err) +//! } +//! } +//! } +//! +//! fn openfile(path: &Path) -> Result<(), Error> { +//! try!(File::open(path).context(path)); +//! +//! // If we didn't have context, the line above would be written as; +//! // +//! // try!(File::open(path) +//! // .map_err(|err| Error::File(path.to_path_buf(), err))); +//! +//! Ok(()) +//! } +//! +//! # fn main() { +//! # openfile(Path::new("/etc/somefile")).ok(); +//! # } +//! ``` +//! +//! Each `context(a: A, b: B)` clause implements +//! `From> for Error`. Which means multiple `context` clauses +//! are a subject to the normal coherence rules. Unfortunately, we can't +//! provide full support of generics for the context, but you may either use a +//! lifetime `'a` for references or `AsRef` (the latter means `A: +//! AsRef`, and `Type` must be concrete). It's also occasionally useful +//! to use a tuple as a type of the first argument. +//! +//! You also need to `use quick_error::ResultExt` extension trait to get +//! working `.context()` method. +//! +//! More info on context in [this article](http://bit.ly/1PsuxDt). +//! +//! All forms of `from`, `display`, `cause`, and `context` +//! clauses can be combined and put in arbitrary order. Only `from` and +//! `context` can be used multiple times in single variant of enumeration. +//! Docstrings are also okay. Empty braces can be omitted as of quick_error +//! 0.1.3. +//! +//! # Private Enums +//! +//! Since quick-error 1.2.0 we have a way to make a private enum that is +//! wrapped by public structure: +//! +//! ```rust +//! #[macro_use] extern crate quick_error; +//! # fn main() {} +//! +//! quick_error! { +//! #[derive(Debug)] +//! pub enum PubError wraps ErrorEnum { +//! Variant1 {} +//! } +//! } +//! ``` +//! +//! This generates data structures like this +//! +//! ```rust +//! +//! pub struct PubError(ErrorEnum); +//! +//! enum ErrorEnum { +//! Variant1, +//! } +//! +//! ``` +//! +//! Which in turn allows you to export just `PubError` in your crate and keep +//! actual enumeration private to the crate. This is useful to keep backwards +//! compatibility for error types. Currently there is no shorcuts to define +//! error constructors for the inner type, but we consider adding some in +//! future versions. +//! +//! It's possible to declare internal enum as public too. +//! +//! + + +/// Main macro that does all the work +#[macro_export] +macro_rules! quick_error { + + ( $(#[$meta:meta])* + pub enum $name:ident { $($chunks:tt)* } + ) => { + quick_error!(SORT [pub enum $name $(#[$meta])* ] + items [] buf [] + queue [ $($chunks)* ]); + }; + ( $(#[$meta:meta])* + enum $name:ident { $($chunks:tt)* } + ) => { + quick_error!(SORT [enum $name $(#[$meta])* ] + items [] buf [] + queue [ $($chunks)* ]); + }; + + ( $(#[$meta:meta])* + pub enum $name:ident wraps $enum_name:ident { $($chunks:tt)* } + ) => { + quick_error!(WRAPPER $enum_name [ pub struct ] $name $(#[$meta])*); + quick_error!(SORT [enum $enum_name $(#[$meta])* ] + items [] buf [] + queue [ $($chunks)* ]); + }; + + ( $(#[$meta:meta])* + pub enum $name:ident wraps pub $enum_name:ident { $($chunks:tt)* } + ) => { + quick_error!(WRAPPER $enum_name [ pub struct ] $name $(#[$meta])*); + quick_error!(SORT [pub enum $enum_name $(#[$meta])* ] + items [] buf [] + queue [ $($chunks)* ]); + }; + ( $(#[$meta:meta])* + enum $name:ident wraps $enum_name:ident { $($chunks:tt)* } + ) => { + quick_error!(WRAPPER $enum_name [ struct ] $name $(#[$meta])*); + quick_error!(SORT [enum $enum_name $(#[$meta])* ] + items [] buf [] + queue [ $($chunks)* ]); + }; + + ( $(#[$meta:meta])* + enum $name:ident wraps pub $enum_name:ident { $($chunks:tt)* } + ) => { + quick_error!(WRAPPER $enum_name [ struct ] $name $(#[$meta])*); + quick_error!(SORT [pub enum $enum_name $(#[$meta])* ] + items [] buf [] + queue [ $($chunks)* ]); + }; + + + ( + WRAPPER $internal:ident [ $($strdef:tt)* ] $strname:ident + $(#[$meta:meta])* + ) => { + $(#[$meta])* + $($strdef)* $strname ( $internal ); + + impl ::std::fmt::Display for $strname { + fn fmt(&self, f: &mut ::std::fmt::Formatter) + -> ::std::fmt::Result + { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl From<$internal> for $strname { + fn from(err: $internal) -> Self { + $strname(err) + } + } + + impl ::std::error::Error for $strname { + #[allow(deprecated)] + fn cause(&self) -> Option<&::std::error::Error> { + self.0.cause() + } + } + }; + + // Queue is empty, can do the work + (SORT [enum $name:ident $( #[$meta:meta] )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [ ] + queue [ ] + ) => { + quick_error!(ENUM_DEFINITION [enum $name $( #[$meta] )*] + body [] + queue [$($( #[$imeta] )* + => $iitem: $imode [$( $ivar: $ityp ),*] )*] + ); + quick_error!(IMPLEMENTATIONS $name {$( + $iitem: $imode [$(#[$imeta])*] [$( $ivar: $ityp ),*] {$( $ifuncs )*} + )*}); + $( + quick_error!(ERROR_CHECK $imode $($ifuncs)*); + )* + }; + (SORT [pub enum $name:ident $( #[$meta:meta] )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [ ] + queue [ ] + ) => { + quick_error!(ENUM_DEFINITION [pub enum $name $( #[$meta] )*] + body [] + queue [$($( #[$imeta] )* + => $iitem: $imode [$( $ivar: $ityp ),*] )*] + ); + quick_error!(IMPLEMENTATIONS $name {$( + $iitem: $imode [$(#[$imeta])*] [$( $ivar: $ityp ),*] {$( $ifuncs )*} + )*}); + $( + quick_error!(ERROR_CHECK $imode $($ifuncs)*); + )* + }; + // Add meta to buffer + (SORT [$( $def:tt )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [$( #[$bmeta:meta] )*] + queue [ #[$qmeta:meta] $( $tail:tt )*] + ) => { + quick_error!(SORT [$( $def )*] + items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*] + buf [$( #[$bmeta] )* #[$qmeta] ] + queue [$( $tail )*]); + }; + // Add ident to buffer + (SORT [$( $def:tt )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [$( #[$bmeta:meta] )*] + queue [ $qitem:ident $( $tail:tt )*] + ) => { + quick_error!(SORT [$( $def )*] + items [$( $(#[$imeta])* + => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*] + buf [$(#[$bmeta])* => $qitem : UNIT [ ] ] + queue [$( $tail )*]); + }; + // Flush buffer on meta after ident + (SORT [$( $def:tt )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [$( #[$bmeta:meta] )* + => $bitem:ident: $bmode:tt [$( $bvar:ident: $btyp:ty ),*] ] + queue [ #[$qmeta:meta] $( $tail:tt )*] + ) => { + quick_error!(SORT [$( $def )*] + enum [$( $(#[$emeta])* => $eitem $(( $($etyp),* ))* )* + $(#[$bmeta])* => $bitem: $bmode $(( $($btyp),* ))*] + items [$($( #[$imeta:meta] )* + => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )* + $bitem: $bmode [$( $bvar:$btyp ),*] {} ] + buf [ #[$qmeta] ] + queue [$( $tail )*]); + }; + // Add tuple enum-variant + (SORT [$( $def:tt )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [$( #[$bmeta:meta] )* => $bitem:ident: UNIT [ ] ] + queue [($( $qvar:ident: $qtyp:ty ),+) $( $tail:tt )*] + ) => { + quick_error!(SORT [$( $def )*] + items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*] + buf [$( #[$bmeta] )* => $bitem: TUPLE [$( $qvar:$qtyp ),*] ] + queue [$( $tail )*] + ); + }; + // Add struct enum-variant - e.g. { descr: &'static str } + (SORT [$( $def:tt )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [$( #[$bmeta:meta] )* => $bitem:ident: UNIT [ ] ] + queue [{ $( $qvar:ident: $qtyp:ty ),+} $( $tail:tt )*] + ) => { + quick_error!(SORT [$( $def )*] + items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*] + buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),*] ] + queue [$( $tail )*]); + }; + // Add struct enum-variant, with excess comma - e.g. { descr: &'static str, } + (SORT [$( $def:tt )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [$( #[$bmeta:meta] )* => $bitem:ident: UNIT [ ] ] + queue [{$( $qvar:ident: $qtyp:ty ),+ ,} $( $tail:tt )*] + ) => { + quick_error!(SORT [$( $def )*] + items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*] + buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),*] ] + queue [$( $tail )*]); + }; + // Add braces and flush always on braces + (SORT [$( $def:tt )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [$( #[$bmeta:meta] )* + => $bitem:ident: $bmode:tt [$( $bvar:ident: $btyp:ty ),*] ] + queue [ {$( $qfuncs:tt )*} $( $tail:tt )*] + ) => { + quick_error!(SORT [$( $def )*] + items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )* + $(#[$bmeta])* => $bitem: $bmode [$( $bvar:$btyp ),*] {$( $qfuncs )*} ] + buf [ ] + queue [$( $tail )*]); + }; + // Flush buffer on double ident + (SORT [$( $def:tt )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [$( #[$bmeta:meta] )* + => $bitem:ident: $bmode:tt [$( $bvar:ident: $btyp:ty ),*] ] + queue [ $qitem:ident $( $tail:tt )*] + ) => { + quick_error!(SORT [$( $def )*] + items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )* + $(#[$bmeta])* => $bitem: $bmode [$( $bvar:$btyp ),*] {} ] + buf [ => $qitem : UNIT [ ] ] + queue [$( $tail )*]); + }; + // Flush buffer on end + (SORT [$( $def:tt )*] + items [$($( #[$imeta:meta] )* + => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] + {$( $ifuncs:tt )*} )* ] + buf [$( #[$bmeta:meta] )* + => $bitem:ident: $bmode:tt [$( $bvar:ident: $btyp:ty ),*] ] + queue [ ] + ) => { + quick_error!(SORT [$( $def )*] + items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )* + $(#[$bmeta])* => $bitem: $bmode [$( $bvar:$btyp ),*] {} ] + buf [ ] + queue [ ]); + }; + // Public enum (Queue Empty) + (ENUM_DEFINITION [pub enum $name:ident $( #[$meta:meta] )*] + body [$($( #[$imeta:meta] )* + => $iitem:ident ($(($( $ttyp:ty ),+))*) {$({$( $svar:ident: $styp:ty ),*})*} )* ] + queue [ ] + ) => { + #[allow(unknown_lints)] // no unused_doc_comments in older rust + #[allow(renamed_and_removed_lints)] + #[allow(unused_doc_comment)] + #[allow(unused_doc_comments)] + $(#[$meta])* + pub enum $name { + $( + $(#[$imeta])* + $iitem $(($( $ttyp ),*))* $({$( $svar: $styp ),*})*, + )* + } + }; + // Private enum (Queue Empty) + (ENUM_DEFINITION [enum $name:ident $( #[$meta:meta] )*] + body [$($( #[$imeta:meta] )* + => $iitem:ident ($(($( $ttyp:ty ),+))*) {$({$( $svar:ident: $styp:ty ),*})*} )* ] + queue [ ] + ) => { + #[allow(unknown_lints)] // no unused_doc_comments in older rust + #[allow(renamed_and_removed_lints)] + #[allow(unused_doc_comment)] + #[allow(unused_doc_comments)] + $(#[$meta])* + enum $name { + $( + $(#[$imeta])* + $iitem $(($( $ttyp ),*))* $({$( $svar: $styp ),*})*, + )* + } + }; + // Unit variant + (ENUM_DEFINITION [$( $def:tt )*] + body [$($( #[$imeta:meta] )* + => $iitem:ident ($(($( $ttyp:ty ),+))*) {$({$( $svar:ident: $styp:ty ),*})*} )* ] + queue [$( #[$qmeta:meta] )* + => $qitem:ident: UNIT [ ] $( $queue:tt )*] + ) => { + quick_error!(ENUM_DEFINITION [ $($def)* ] + body [$($( #[$imeta] )* => $iitem ($(($( $ttyp ),+))*) {$({$( $svar: $styp ),*})*} )* + $( #[$qmeta] )* => $qitem () {} ] + queue [ $($queue)* ] + ); + }; + // Tuple variant + (ENUM_DEFINITION [$( $def:tt )*] + body [$($( #[$imeta:meta] )* + => $iitem:ident ($(($( $ttyp:ty ),+))*) {$({$( $svar:ident: $styp:ty ),*})*} )* ] + queue [$( #[$qmeta:meta] )* + => $qitem:ident: TUPLE [$( $qvar:ident: $qtyp:ty ),+] $( $queue:tt )*] + ) => { + quick_error!(ENUM_DEFINITION [ $($def)* ] + body [$($( #[$imeta] )* => $iitem ($(($( $ttyp ),+))*) {$({$( $svar: $styp ),*})*} )* + $( #[$qmeta] )* => $qitem (($( $qtyp ),*)) {} ] + queue [ $($queue)* ] + ); + }; + // Struct variant + (ENUM_DEFINITION [$( $def:tt )*] + body [$($( #[$imeta:meta] )* + => $iitem:ident ($(($( $ttyp:ty ),+))*) {$({$( $svar:ident: $styp:ty ),*})*} )* ] + queue [$( #[$qmeta:meta] )* + => $qitem:ident: STRUCT [$( $qvar:ident: $qtyp:ty ),*] $( $queue:tt )*] + ) => { + quick_error!(ENUM_DEFINITION [ $($def)* ] + body [$($( #[$imeta] )* => $iitem ($(($( $ttyp ),+))*) {$({$( $svar: $styp ),*})*} )* + $( #[$qmeta] )* => $qitem () {{$( $qvar: $qtyp ),*}} ] + queue [ $($queue)* ] + ); + }; + (IMPLEMENTATIONS + $name:ident {$( + $item:ident: $imode:tt [$(#[$imeta:meta])*] [$( $var:ident: $typ:ty ),*] {$( $funcs:tt )*} + )*} + ) => { + #[allow(unused)] + #[allow(unknown_lints)] // no unused_doc_comments in older rust + #[allow(renamed_and_removed_lints)] + #[allow(unused_doc_comment)] + #[allow(unused_doc_comments)] + impl ::std::fmt::Display for $name { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) + -> ::std::fmt::Result + { + match *self { + $( + $(#[$imeta])* + quick_error!(ITEM_PATTERN + $name $item: $imode [$( ref $var ),*] + ) => { + let display_fn = quick_error!(FIND_DISPLAY_IMPL + $name $item: $imode + {$( $funcs )*}); + + display_fn(self, fmt) + } + )* + } + } + } + #[allow(unused)] + #[allow(unknown_lints)] // no unused_doc_comments in older rust + #[allow(renamed_and_removed_lints)] + #[allow(unused_doc_comment)] + #[allow(unused_doc_comments)] + impl ::std::error::Error for $name { + fn cause(&self) -> Option<&::std::error::Error> { + match *self { + $( + $(#[$imeta])* + quick_error!(ITEM_PATTERN + $name $item: $imode [$( ref $var ),*] + ) => { + quick_error!(FIND_CAUSE_IMPL + $item: $imode [$( $var ),*] + {$( $funcs )*}) + } + )* + } + } + } + $( + quick_error!(FIND_FROM_IMPL + $name $item: $imode [$( $var:$typ ),*] + {$( $funcs )*}); + )* + $( + quick_error!(FIND_CONTEXT_IMPL + $name $item: $imode [$( $var:$typ ),*] + {$( $funcs )*}); + )* + }; + (FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt + { display($self_:tt) -> ($( $exprs:tt )*) $( $tail:tt )*} + ) => { + |quick_error!(IDENT $self_): &$name, f: &mut ::std::fmt::Formatter| { write!(f, $( $exprs )*) } + }; + (FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt + { display($pattern:expr) $( $tail:tt )*} + ) => { + |_, f: &mut ::std::fmt::Formatter| { write!(f, $pattern) } + }; + (FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt + { display($pattern:expr, $( $exprs:tt )*) $( $tail:tt )*} + ) => { + |_, f: &mut ::std::fmt::Formatter| { write!(f, $pattern, $( $exprs )*) } + }; + (FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt + { $t:tt $( $tail:tt )*} + ) => { + quick_error!(FIND_DISPLAY_IMPL + $name $item: $imode + {$( $tail )*}) + }; + (FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt + { } + ) => { + |self_: &$name, f: &mut ::std::fmt::Formatter| { + write!(f, "{:?}", self_) + } + }; + (FIND_DESCRIPTION_IMPL $item:ident: $imode:tt $me:ident $fmt:ident + [$( $var:ident ),*] + { description($expr:expr) $( $tail:tt )*} + ) => {}; + (FIND_DESCRIPTION_IMPL $item:ident: $imode:tt $me:ident $fmt:ident + [$( $var:ident ),*] + { $t:tt $( $tail:tt )*} + ) => {}; + (FIND_DESCRIPTION_IMPL $item:ident: $imode:tt $me:ident $fmt:ident + [$( $var:ident ),*] + { } + ) => {}; + (FIND_CAUSE_IMPL $item:ident: $imode:tt + [$( $var:ident ),*] + { cause($expr:expr) $( $tail:tt )*} + ) => { + Some($expr) + }; + (FIND_CAUSE_IMPL $item:ident: $imode:tt + [$( $var:ident ),*] + { $t:tt $( $tail:tt )*} + ) => { + quick_error!(FIND_CAUSE_IMPL + $item: $imode [$( $var ),*] + { $($tail)* }) + }; + (FIND_CAUSE_IMPL $item:ident: $imode:tt + [$( $var:ident ),*] + { } + ) => { + None + }; + // ----------------------------- FROM IMPL -------------------------- + (FIND_FROM_IMPL $name:ident $item:ident: $imode:tt + [$( $var:ident: $typ:ty ),*] + { from() $( $tail:tt )*} + ) => { + $( + impl From<$typ> for $name { + fn from($var: $typ) -> $name { + $name::$item($var) + } + } + )* + quick_error!(FIND_FROM_IMPL + $name $item: $imode [$( $var:$typ ),*] + {$( $tail )*}); + }; + (FIND_FROM_IMPL $name:ident $item:ident: UNIT + [ ] + { from($ftyp:ty) $( $tail:tt )*} + ) => { + impl From<$ftyp> for $name { + fn from(_discarded_error: $ftyp) -> $name { + $name::$item + } + } + quick_error!(FIND_FROM_IMPL + $name $item: UNIT [ ] + {$( $tail )*}); + }; + (FIND_FROM_IMPL $name:ident $item:ident: TUPLE + [$( $var:ident: $typ:ty ),*] + { from($fvar:ident: $ftyp:ty) -> ($( $texpr:expr ),*) $( $tail:tt )*} + ) => { + impl From<$ftyp> for $name { + fn from($fvar: $ftyp) -> $name { + $name::$item($( $texpr ),*) + } + } + quick_error!(FIND_FROM_IMPL + $name $item: TUPLE [$( $var:$typ ),*] + { $($tail)* }); + }; + (FIND_FROM_IMPL $name:ident $item:ident: STRUCT + [$( $var:ident: $typ:ty ),*] + { from($fvar:ident: $ftyp:ty) -> {$( $tvar:ident: $texpr:expr ),*} $( $tail:tt )*} + ) => { + impl From<$ftyp> for $name { + fn from($fvar: $ftyp) -> $name { + $name::$item { + $( $tvar: $texpr ),* + } + } + } + quick_error!(FIND_FROM_IMPL + $name $item: STRUCT [$( $var:$typ ),*] + { $($tail)* }); + }; + (FIND_FROM_IMPL $name:ident $item:ident: $imode:tt + [$( $var:ident: $typ:ty ),*] + { $t:tt $( $tail:tt )*} + ) => { + quick_error!(FIND_FROM_IMPL + $name $item: $imode [$( $var:$typ ),*] + {$( $tail )*} + ); + }; + (FIND_FROM_IMPL $name:ident $item:ident: $imode:tt + [$( $var:ident: $typ:ty ),*] + { } + ) => { + }; + // ----------------------------- CONTEXT IMPL -------------------------- + (FIND_CONTEXT_IMPL $name:ident $item:ident: TUPLE + [$( $var:ident: $typ:ty ),*] + { context($cvar:ident: AsRef<$ctyp:ty>, $fvar:ident: $ftyp:ty) + -> ($( $texpr:expr ),*) $( $tail:tt )* } + ) => { + impl> From<$crate::Context> for $name { + fn from( + $crate::Context($cvar, $fvar): $crate::Context) + -> $name + { + $name::$item($( $texpr ),*) + } + } + quick_error!(FIND_CONTEXT_IMPL + $name $item: TUPLE [$( $var:$typ ),*] + { $($tail)* }); + }; + (FIND_CONTEXT_IMPL $name:ident $item:ident: TUPLE + [$( $var:ident: $typ:ty ),*] + { context($cvar:ident: $ctyp:ty, $fvar:ident: $ftyp:ty) + -> ($( $texpr:expr ),*) $( $tail:tt )* } + ) => { + impl<'a> From<$crate::Context<$ctyp, $ftyp>> for $name { + fn from( + $crate::Context($cvar, $fvar): $crate::Context<$ctyp, $ftyp>) + -> $name + { + $name::$item($( $texpr ),*) + } + } + quick_error!(FIND_CONTEXT_IMPL + $name $item: TUPLE [$( $var:$typ ),*] + { $($tail)* }); + }; + (FIND_CONTEXT_IMPL $name:ident $item:ident: STRUCT + [$( $var:ident: $typ:ty ),*] + { context($cvar:ident: AsRef<$ctyp:ty>, $fvar:ident: $ftyp:ty) + -> {$( $tvar:ident: $texpr:expr ),*} $( $tail:tt )* } + ) => { + impl> From<$crate::Context> for $name { + fn from( + $crate::Context($cvar, $fvar): $crate::Context<$ctyp, $ftyp>) + -> $name + { + $name::$item { + $( $tvar: $texpr ),* + } + } + } + quick_error!(FIND_CONTEXT_IMPL + $name $item: STRUCT [$( $var:$typ ),*] + { $($tail)* }); + }; + (FIND_CONTEXT_IMPL $name:ident $item:ident: STRUCT + [$( $var:ident: $typ:ty ),*] + { context($cvar:ident: $ctyp:ty, $fvar:ident: $ftyp:ty) + -> {$( $tvar:ident: $texpr:expr ),*} $( $tail:tt )* } + ) => { + impl<'a> From<$crate::Context<$ctyp, $ftyp>> for $name { + fn from( + $crate::Context($cvar, $fvar): $crate::Context<$ctyp, $ftyp>) + -> $name + { + $name::$item { + $( $tvar: $texpr ),* + } + } + } + quick_error!(FIND_CONTEXT_IMPL + $name $item: STRUCT [$( $var:$typ ),*] + { $($tail)* }); + }; + (FIND_CONTEXT_IMPL $name:ident $item:ident: $imode:tt + [$( $var:ident: $typ:ty ),*] + { $t:tt $( $tail:tt )*} + ) => { + quick_error!(FIND_CONTEXT_IMPL + $name $item: $imode [$( $var:$typ ),*] + {$( $tail )*} + ); + }; + (FIND_CONTEXT_IMPL $name:ident $item:ident: $imode:tt + [$( $var:ident: $typ:ty ),*] + { } + ) => { + }; + // ----------------------------- ITEM IMPL -------------------------- + (ITEM_BODY $(#[$imeta:meta])* $item:ident: UNIT + ) => { }; + (ITEM_BODY $(#[$imeta:meta])* $item:ident: TUPLE + [$( $typ:ty ),*] + ) => { + ($( $typ ),*) + }; + (ITEM_BODY $(#[$imeta:meta])* $item:ident: STRUCT + [$( $var:ident: $typ:ty ),*] + ) => { + {$( $var:$typ ),*} + }; + (ITEM_PATTERN $name:ident $item:ident: UNIT [] + ) => { + $name::$item + }; + (ITEM_PATTERN $name:ident $item:ident: TUPLE + [$( ref $var:ident ),*] + ) => { + $name::$item ($( ref $var ),*) + }; + (ITEM_PATTERN $name:ident $item:ident: STRUCT + [$( ref $var:ident ),*] + ) => { + $name::$item {$( ref $var ),*} + }; + // This one should match all allowed sequences in "funcs" but not match + // anything else. + // This is to contrast FIND_* clauses which just find stuff they need and + // skip everything else completely + (ERROR_CHECK $imode:tt display($self_:tt) -> ($( $exprs:tt )*) $( $tail:tt )*) + => { quick_error!(ERROR_CHECK $imode $($tail)*); }; + (ERROR_CHECK $imode:tt display($pattern: expr) $( $tail:tt )*) + => { quick_error!(ERROR_CHECK $imode $($tail)*); }; + (ERROR_CHECK $imode:tt display($pattern: expr, $( $exprs:tt )*) $( $tail:tt )*) + => { quick_error!(ERROR_CHECK $imode $($tail)*); }; + (ERROR_CHECK $imode:tt description($expr:expr) $( $tail:tt )*) + => { quick_error!(ERROR_CHECK $imode $($tail)*); }; + (ERROR_CHECK $imode:tt cause($expr:expr) $($tail:tt)*) + => { quick_error!(ERROR_CHECK $imode $($tail)*); }; + (ERROR_CHECK $imode:tt from() $($tail:tt)*) + => { quick_error!(ERROR_CHECK $imode $($tail)*); }; + (ERROR_CHECK $imode:tt from($ftyp:ty) $($tail:tt)*) + => { quick_error!(ERROR_CHECK $imode $($tail)*); }; + (ERROR_CHECK TUPLE from($fvar:ident: $ftyp:ty) -> ($( $e:expr ),*) $( $tail:tt )*) + => { quick_error!(ERROR_CHECK TUPLE $($tail)*); }; + (ERROR_CHECK STRUCT from($fvar:ident: $ftyp:ty) -> {$( $v:ident: $e:expr ),*} $( $tail:tt )*) + => { quick_error!(ERROR_CHECK STRUCT $($tail)*); }; + + (ERROR_CHECK TUPLE context($cvar:ident: $ctyp:ty, $fvar:ident: $ftyp:ty) + -> ($( $e:expr ),*) $( $tail:tt )*) + => { quick_error!(ERROR_CHECK TUPLE $($tail)*); }; + (ERROR_CHECK STRUCT context($cvar:ident: $ctyp:ty, $fvar:ident: $ftyp:ty) + -> {$( $v:ident: $e:expr ),*} $( $tail:tt )*) + => { quick_error!(ERROR_CHECK STRUCT $($tail)*); }; + + (ERROR_CHECK $imode:tt ) => {}; + // Utility functions + (IDENT $ident:ident) => { $ident } +} + + +/// Generic context type +/// +/// Used mostly as a transport for `ResultExt::context` method +#[derive(Debug)] +pub struct Context(pub X, pub E); + +/// Result extension trait adding a `context` method +pub trait ResultExt { + /// The method is use to add context information to current operation + /// + /// The context data is then used in error constructor to store additional + /// information within error. For example, you may add a filename as a + /// context for file operation. See crate documentation for the actual + /// example. + fn context(self, x: X) -> Result>; +} + +impl ResultExt for Result { + fn context(self, x: X) -> Result> { + self.map_err(|e| Context(x, e)) + } +} + + + +#[cfg(test)] +#[allow(deprecated)] +mod test { + use std::num::{ParseFloatError, ParseIntError}; + use std::str::Utf8Error; + use std::string::FromUtf8Error; + use std::error::Error; + use std::path::{Path, PathBuf}; + + use super::ResultExt; + + quick_error! { + #[derive(Debug)] + pub enum Bare { + One + Two + } + } + + #[test] + fn bare_item_direct() { + assert_eq!(format!("{}", Bare::One), "One".to_string()); + assert_eq!(format!("{:?}", Bare::One), "One".to_string()); + assert!(Bare::One.cause().is_none()); + } + #[test] + fn bare_item_trait() { + let err: &Error = &Bare::Two; + assert_eq!(format!("{}", err), "Two".to_string()); + assert_eq!(format!("{:?}", err), "Two".to_string()); + assert!(err.cause().is_none()); + } + + quick_error! { + #[derive(Debug)] + pub enum Wrapper wraps Wrapped { + One + Two(s: String) { + display("two: {}", s) + from() + } + } + } + + #[test] + fn wrapper() { + assert_eq!(format!("{}", Wrapper::from(Wrapped::One)), + "One".to_string()); + assert_eq!(format!("{}", + Wrapper::from(Wrapped::from(String::from("hello")))), + "two: hello".to_string()); + assert_eq!(format!("{:?}", Wrapper::from(Wrapped::One)), + "Wrapper(One)".to_string()); + } + + quick_error! { + #[derive(Debug, PartialEq)] + pub enum TupleWrapper { + /// ParseFloat Error + ParseFloatError(err: ParseFloatError) { + from() + display("parse float error: {err}", err=err) + cause(err) + } + Other(descr: &'static str) { + display("Error: {}", descr) + } + /// FromUtf8 Error + FromUtf8Error(err: Utf8Error, source: Vec) { + cause(err) + display(me) -> ("{desc} at index {pos}: {err}", desc="utf8 error", pos=err.valid_up_to(), err=err) + from(err: FromUtf8Error) -> (err.utf8_error().clone(), err.into_bytes()) + } + Discard { + from(&'static str) + } + Singleton { + display("Just a string") + } + } + } + + #[test] + fn tuple_wrapper_err() { + let cause = "one and a half times pi".parse::().unwrap_err(); + let err = TupleWrapper::ParseFloatError(cause.clone()); + assert_eq!(format!("{}", err), format!("parse float error: {}", cause)); + assert_eq!(format!("{:?}", err), format!("ParseFloatError({:?})", cause)); + assert_eq!(format!("{:?}", err.cause().unwrap()), format!("{:?}", cause)); + } + + #[test] + fn tuple_wrapper_trait_str() { + let desc = "hello"; + let err: &Error = &TupleWrapper::Other(desc); + assert_eq!(format!("{}", err), format!("Error: {}", desc)); + assert_eq!(format!("{:?}", err), format!("Other({:?})", desc)); + assert!(err.cause().is_none()); + } + + #[test] + fn tuple_wrapper_trait_two_fields() { + let invalid_utf8: Vec = vec![0, 159, 146, 150]; + let cause = String::from_utf8(invalid_utf8.clone()).unwrap_err().utf8_error(); + let err: &Error = &TupleWrapper::FromUtf8Error(cause.clone(), invalid_utf8.clone()); + assert_eq!(format!("{}", err), format!("{desc} at index {pos}: {cause}", desc="utf8 error", pos=cause.valid_up_to(), cause=cause)); + assert_eq!(format!("{:?}", err), format!("FromUtf8Error({:?}, {:?})", cause, invalid_utf8)); + assert_eq!(format!("{:?}", err.cause().unwrap()), format!("{:?}", cause)); + } + + #[test] + fn tuple_wrapper_from() { + let cause = "one and a half times pi".parse::().unwrap_err(); + let err = TupleWrapper::ParseFloatError(cause.clone()); + let err_from: TupleWrapper = From::from(cause); + assert_eq!(err_from, err); + } + + #[test] + fn tuple_wrapper_custom_from() { + let invalid_utf8: Vec = vec![0, 159, 146, 150]; + let cause = String::from_utf8(invalid_utf8.clone()).unwrap_err(); + let err = TupleWrapper::FromUtf8Error(cause.utf8_error().clone(), invalid_utf8); + let err_from: TupleWrapper = From::from(cause); + assert_eq!(err_from, err); + } + + #[test] + fn tuple_wrapper_discard() { + let err: TupleWrapper = From::from("hello"); + assert_eq!(format!("{}", err), format!("Discard")); + assert_eq!(format!("{:?}", err), format!("Discard")); + assert!(err.cause().is_none()); + } + + #[test] + fn tuple_wrapper_singleton() { + let err: TupleWrapper = TupleWrapper::Singleton; + assert_eq!(format!("{}", err), format!("Just a string")); + assert_eq!(format!("{:?}", err), format!("Singleton")); + assert!(err.cause().is_none()); + } + + quick_error! { + #[derive(Debug, PartialEq)] + pub enum StructWrapper { + // Utf8 Error + Utf8Error{ err: Utf8Error, hint: Option<&'static str> } { + cause(err) + display(me) -> ("{desc} at index {pos}: {err}", desc="utf8 error", pos=err.valid_up_to(), err=err) + from(err: Utf8Error) -> { err: err, hint: None } + } + // Utf8 Error + ExcessComma { descr: &'static str, } { + display("Error: {}", descr) + } + } + } + + #[test] + fn struct_wrapper_err() { + let invalid_utf8: Vec = vec![0, 159, 146, 150]; + let cause = String::from_utf8(invalid_utf8.clone()).unwrap_err().utf8_error(); + let err: &Error = &StructWrapper::Utf8Error{ err: cause.clone(), hint: Some("nonsense") }; + assert_eq!(format!("{}", err), format!("{desc} at index {pos}: {cause}", desc="utf8 error", pos=cause.valid_up_to(), cause=cause)); + assert_eq!(format!("{:?}", err), format!("Utf8Error {{ err: {:?}, hint: {:?} }}", cause, Some("nonsense"))); + assert_eq!(format!("{:?}", err.cause().unwrap()), format!("{:?}", cause)); + } + + #[test] + fn struct_wrapper_struct_from() { + let invalid_utf8: Vec = vec![0, 159, 146, 150]; + let cause = String::from_utf8(invalid_utf8.clone()).unwrap_err().utf8_error(); + let err = StructWrapper::Utf8Error{ err: cause.clone(), hint: None }; + let err_from: StructWrapper = From::from(cause); + assert_eq!(err_from, err); + } + + #[test] + fn struct_wrapper_excess_comma() { + let descr = "hello"; + let err = StructWrapper::ExcessComma { descr: descr }; + assert_eq!(format!("{}", err), format!("Error: {}", descr)); + assert_eq!(format!("{:?}", err), format!("ExcessComma {{ descr: {:?} }}", descr)); + assert!(err.cause().is_none()); + } + + quick_error! { + #[derive(Debug)] + pub enum ContextErr { + Float(src: String, err: ParseFloatError) { + context(s: &'a str, e: ParseFloatError) -> (s.to_string(), e) + display("Float error {:?}: {}", src, err) + } + Int { src: String, err: ParseIntError } { + context(s: &'a str, e: ParseIntError) + -> {src: s.to_string(), err: e} + display("Int error {:?}: {}", src, err) + } + Utf8(path: PathBuf, err: Utf8Error) { + context(p: AsRef, e: Utf8Error) + -> (p.as_ref().to_path_buf(), e) + display("Path error at {:?}: {}", path, err) + } + Utf8Str(s: String, err: ::std::io::Error) { + context(s: AsRef, e: ::std::io::Error) + -> (s.as_ref().to_string(), e) + display("Str error {:?}: {}", s, err) + } + } + } + + #[test] + fn parse_float_error() { + fn parse_float(s: &str) -> Result { + Ok(try!(s.parse().context(s))) + } + assert_eq!(format!("{}", parse_float("12ab").unwrap_err()), + r#"Float error "12ab": invalid float literal"#); + } + + #[test] + fn parse_int_error() { + fn parse_int(s: &str) -> Result { + Ok(try!(s.parse().context(s))) + } + assert_eq!(format!("{}", parse_int("12.5").unwrap_err()), + r#"Int error "12.5": invalid digit found in string"#); + } + + #[test] + fn debug_context() { + fn parse_int(s: &str) -> i32 { + s.parse().context(s).unwrap() + } + assert_eq!(parse_int("12"), 12); + assert_eq!(format!("{:?}", "x".parse::().context("x")), + r#"Err(Context("x", ParseIntError { kind: InvalidDigit }))"#); + } + + #[test] + fn path_context() { + fn parse_utf>(s: &[u8], p: P) + -> Result<(), ContextErr> + { + try!(::std::str::from_utf8(s).context(p)); + Ok(()) + } + let etext = parse_utf(b"a\x80\x80", "/etc").unwrap_err().to_string(); + assert!(etext.starts_with( + "Path error at \"/etc\": invalid utf-8")); + let etext = parse_utf(b"\x80\x80", PathBuf::from("/tmp")).unwrap_err() + .to_string(); + assert!(etext.starts_with( + "Path error at \"/tmp\": invalid utf-8")); + } + + #[test] + fn conditional_compilation() { + quick_error! { + #[allow(dead_code)] + #[derive(Debug)] + pub enum Test { + #[cfg(feature = "foo")] + Variant + } + } + } +} diff --git a/third_party/cargo/vendor/quick-error-1.2.3/vagga.yaml b/third_party/cargo/vendor/quick-error-1.2.3/vagga.yaml new file mode 100644 index 0000000..71b9be4 --- /dev/null +++ b/third_party/cargo/vendor/quick-error-1.2.3/vagga.yaml @@ -0,0 +1,36 @@ +commands: + + cargo: !Command + description: Run any cargo command + container: ubuntu + run: [cargo] + + test: !Command + description: Run unit tests + container: ubuntu + run: [cargo, test] + + _bulk: !Command + description: Run `bulk` command (for version bookkeeping) + container: ubuntu + run: [bulk] + +containers: + + ubuntu: + setup: + - !Ubuntu xenial + - !Install [ca-certificates, build-essential, vim] + + - !TarInstall + url: "https://static.rust-lang.org/dist/rust-1.16.0-x86_64-unknown-linux-gnu.tar.gz" + script: "./install.sh --prefix=/usr \ + --components=rustc,rust-std-x86_64-unknown-linux-gnu,cargo" + - &bulk !Tar + url: "https://github.com/tailhook/bulk/releases/download/v0.4.9/bulk-v0.4.9.tar.gz" + sha256: 23471a9986274bb4b7098c03e2eb7e1204171869b72c45385fcee1c64db2d111 + path: / + + environ: + HOME: /work/target + USER: pc diff --git a/third_party/cargo/vendor/quote-0.6.13/.cargo-checksum.json b/third_party/cargo/vendor/quote-0.6.13/.cargo-checksum.json new file mode 100644 index 0000000..2789307 --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"13a29a2a545e9e4bfae873b826ebe21de636eff1ed43e8886bd1706fd3c8e7fd","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","README.md":"a398cc6ad5faa5f8682b6ff56b159205a17e0f23ecf5dea496d3392d072fd4e8","src/ext.rs":"03919239a20f8393288783a21bf6fdee12e405d13d162c9faa6f8f5ce54b003b","src/lib.rs":"670c044274458bfe0d584804f1913f05faceb27d0ad71357d0817bfc879282b4","src/runtime.rs":"e8092bf5b845289b9ecfcb7d7f8a8bbc36877460221ba8994adf6c93236394ee","src/to_tokens.rs":"5b4155ff36262fb81f98ca8a9e903e9cf1ca346e72cb36a2de746e10d3b24d49","tests/conditional/integer128.rs":"d83e21a91efbaa801a82ae499111bdda2d31edaa620e78c0199eba42d69c9ee6","tests/test.rs":"5a7095e813d9c69082ae7f13ac0577c97c867c6e8fb80b9732e105c1bc7d14ab"},"package":"6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"} \ No newline at end of file diff --git a/third_party/cargo/vendor/quote-0.6.13/BUILD b/third_party/cargo/vendor/quote-0.6.13/BUILD new file mode 100644 index 0000000..6381404 --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "MIT OR Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "quote", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/proc-macro2-0.4.30:proc_macro2", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.13", + crate_features = [ + "default", + "proc-macro", + "proc-macro2", + ], +) + +# Unsupported target "test" with type "test" omitted diff --git a/third_party/cargo/vendor/quote-0.6.13/Cargo.toml b/third_party/cargo/vendor/quote-0.6.13/Cargo.toml new file mode 100644 index 0000000..378e9fb --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/Cargo.toml @@ -0,0 +1,33 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "quote" +version = "0.6.13" +authors = ["David Tolnay "] +include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] +description = "Quasi-quoting macro quote!(...)" +documentation = "https://docs.rs/quote/" +readme = "README.md" +keywords = ["syn"] +categories = ["development-tools::procedural-macro-helpers"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/dtolnay/quote" +[dependencies.proc-macro2] +version = "0.4.21" +default-features = false + +[features] +default = ["proc-macro"] +proc-macro = ["proc-macro2/proc-macro"] +[badges.travis-ci] +repository = "dtolnay/quote" diff --git a/third_party/cargo/vendor/quote-0.6.13/LICENSE-APACHE b/third_party/cargo/vendor/quote-0.6.13/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/quote-0.6.13/LICENSE-MIT b/third_party/cargo/vendor/quote-0.6.13/LICENSE-MIT new file mode 100644 index 0000000..40b8817 --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/quote-0.6.13/README.md b/third_party/cargo/vendor/quote-0.6.13/README.md new file mode 100644 index 0000000..8a5d590 --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/README.md @@ -0,0 +1,243 @@ +Rust Quasi-Quoting +================== + +[![Build Status](https://api.travis-ci.org/dtolnay/quote.svg?branch=master)](https://travis-ci.org/dtolnay/quote) +[![Latest Version](https://img.shields.io/crates/v/quote.svg)](https://crates.io/crates/quote) +[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/quote/) + +This crate provides the [`quote!`] macro for turning Rust syntax tree data +structures into tokens of source code. + +[`quote!`]: https://docs.rs/quote/0.6/quote/macro.quote.html + +Procedural macros in Rust receive a stream of tokens as input, execute arbitrary +Rust code to determine how to manipulate those tokens, and produce a stream of +tokens to hand back to the compiler to compile into the caller's crate. +Quasi-quoting is a solution to one piece of that -- producing tokens to return +to the compiler. + +The idea of quasi-quoting is that we write *code* that we treat as *data*. +Within the `quote!` macro, we can write what looks like code to our text editor +or IDE. We get all the benefits of the editor's brace matching, syntax +highlighting, indentation, and maybe autocompletion. But rather than compiling +that as code into the current crate, we can treat it as data, pass it around, +mutate it, and eventually hand it back to the compiler as tokens to compile into +the macro caller's crate. + +This crate is motivated by the procedural macro use case, but is a +general-purpose Rust quasi-quoting library and is not specific to procedural +macros. + +*Version requirement: Quote supports any compiler version back to Rust's very +first support for procedural macros in Rust 1.15.0.* + +[*Release notes*](https://github.com/dtolnay/quote/releases) + +```toml +[dependencies] +quote = "0.6" +``` + +## Syntax + +The quote crate provides a [`quote!`] macro within which you can write Rust code +that gets packaged into a [`TokenStream`] and can be treated as data. You should +think of `TokenStream` as representing a fragment of Rust source code. + +[`TokenStream`]: https://docs.rs/proc-macro2/0.4/proc_macro2/struct.TokenStream.html + +Within the `quote!` macro, interpolation is done with `#var`. Any type +implementing the [`quote::ToTokens`] trait can be interpolated. This includes +most Rust primitive types as well as most of the syntax tree types from [`syn`]. + +[`quote::ToTokens`]: https://docs.rs/quote/0.6/quote/trait.ToTokens.html +[`syn`]: https://github.com/dtolnay/syn + +```rust +let tokens = quote! { + struct SerializeWith #generics #where_clause { + value: &'a #field_ty, + phantom: core::marker::PhantomData<#item_ty>, + } + + impl #generics serde::Serialize for SerializeWith #generics #where_clause { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + #path(self.value, serializer) + } + } + + SerializeWith { + value: #value, + phantom: core::marker::PhantomData::<#item_ty>, + } +}; +``` + +## Repetition + +Repetition is done using `#(...)*` or `#(...),*` similar to `macro_rules!`. This +iterates through the elements of any variable interpolated within the repetition +and inserts a copy of the repetition body for each one. The variables in an +interpolation may be anything that implements `IntoIterator`, including `Vec` or +a pre-existing iterator. + +- `#(#var)*` — no separators +- `#(#var),*` — the character before the asterisk is used as a separator +- `#( struct #var; )*` — the repetition can contain other things +- `#( #k => println!("{}", #v), )*` — even multiple interpolations + +Note that there is a difference between `#(#var ,)*` and `#(#var),*`—the latter +does not produce a trailing comma. This matches the behavior of delimiters in +`macro_rules!`. + +## Returning tokens to the compiler + +The `quote!` macro evaluates to an expression of type +`proc_macro2::TokenStream`. Meanwhile Rust procedural macros are expected to +return the type `proc_macro::TokenStream`. + +The difference between the two types is that `proc_macro` types are entirely +specific to procedural macros and cannot ever exist in code outside of a +procedural macro, while `proc_macro2` types may exist anywhere including tests +and non-macro code like main.rs and build.rs. This is why even the procedural +macro ecosystem is largely built around `proc_macro2`, because that ensures the +libraries are unit testable and accessible in non-macro contexts. + +There is a [`From`]-conversion in both directions so returning the output of +`quote!` from a procedural macro usually looks like `tokens.into()` or +`proc_macro::TokenStream::from(tokens)`. + +[`From`]: https://doc.rust-lang.org/std/convert/trait.From.html + +## Examples + +### Combining quoted fragments + +Usually you don't end up constructing an entire final `TokenStream` in one +piece. Different parts may come from different helper functions. The tokens +produced by `quote!` themselves implement `ToTokens` and so can be interpolated +into later `quote!` invocations to build up a final result. + +```rust +let type_definition = quote! {...}; +let methods = quote! {...}; + +let tokens = quote! { + #type_definition + #methods +}; +``` + +### Constructing identifiers + +Suppose we have an identifier `ident` which came from somewhere in a macro +input and we need to modify it in some way for the macro output. Let's consider +prepending the identifier with an underscore. + +Simply interpolating the identifier next to an underscore will not have the +behavior of concatenating them. The underscore and the identifier will continue +to be two separate tokens as if you had written `_ x`. + +```rust +// incorrect +quote! { + let mut _#ident = 0; +} +``` + +The solution is to perform token-level manipulations using the APIs provided by +Syn and proc-macro2. + +```rust +let concatenated = format!("_{}", ident); +let varname = syn::Ident::new(&concatenated, ident.span()); +quote! { + let mut #varname = 0; +} +``` + +### Making method calls + +Let's say our macro requires some type specified in the macro input to have a +constructor called `new`. We have the type in a variable called `field_type` of +type `syn::Type` and want to invoke the constructor. + +```rust +// incorrect +quote! { + let value = #field_type::new(); +} +``` + +This works only sometimes. If `field_type` is `String`, the expanded code +contains `String::new()` which is fine. But if `field_type` is something like +`Vec` then the expanded code is `Vec::new()` which is invalid syntax. +Ordinarily in handwritten Rust we would write `Vec::::new()` but for macros +often the following is more convenient. + +```rust +quote! { + let value = <#field_type>::new(); +} +``` + +This expands to `>::new()` which behaves correctly. + +A similar pattern is appropriate for trait methods. + +```rust +quote! { + let value = <#field_type as core::default::Default>::default(); +} +``` + +## Hygiene + +Any interpolated tokens preserve the `Span` information provided by their +`ToTokens` implementation. Tokens that originate within a `quote!` invocation +are spanned with [`Span::call_site()`]. + +[`Span::call_site()`]: https://docs.rs/proc-macro2/0.4/proc_macro2/struct.Span.html#method.call_site + +A different span can be provided explicitly through the [`quote_spanned!`] +macro. + +[`quote_spanned!`]: https://docs.rs/quote/0.6/quote/macro.quote_spanned.html + +### Limitations + +- A non-repeating variable may not be interpolated inside of a repeating block + ([#7]). +- The same variable may not be interpolated more than once inside of a repeating + block ([#8]). + +[#7]: https://github.com/dtolnay/quote/issues/7 +[#8]: https://github.com/dtolnay/quote/issues/8 + +### Recursion limit + +The `quote!` macro relies on deep recursion so some large invocations may fail +with "recursion limit reached" when you compile. If it fails, bump up the +recursion limit by adding `#![recursion_limit = "128"]` to your crate. An even +higher limit may be necessary for especially large invocations. You don't need +this unless the compiler tells you that you need it. + +
+ +#### License + + +Licensed under either of Apache License, Version +2.0 or MIT license at your option. + + +
+ + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in this crate by you, as defined in the Apache-2.0 license, shall +be dual licensed as above, without any additional terms or conditions. + diff --git a/third_party/cargo/vendor/quote-0.6.13/src/ext.rs b/third_party/cargo/vendor/quote-0.6.13/src/ext.rs new file mode 100644 index 0000000..7ebbe30 --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/src/ext.rs @@ -0,0 +1,112 @@ +use super::ToTokens; + +use std::iter; + +use proc_macro2::{TokenStream, TokenTree}; + +/// TokenStream extension trait with methods for appending tokens. +/// +/// This trait is sealed and cannot be implemented outside of the `quote` crate. +pub trait TokenStreamExt: private::Sealed { + /// For use by `ToTokens` implementations. + /// + /// Appends the token specified to this list of tokens. + fn append(&mut self, token: U) + where + U: Into; + + /// For use by `ToTokens` implementations. + /// + /// ```edition2018 + /// # use quote::{quote, TokenStreamExt, ToTokens}; + /// # use proc_macro2::TokenStream; + /// # + /// struct X; + /// + /// impl ToTokens for X { + /// fn to_tokens(&self, tokens: &mut TokenStream) { + /// tokens.append_all(&[true, false]); + /// } + /// } + /// + /// let tokens = quote!(#X); + /// assert_eq!(tokens.to_string(), "true false"); + /// ``` + fn append_all(&mut self, iter: I) + where + T: ToTokens, + I: IntoIterator; + + /// For use by `ToTokens` implementations. + /// + /// Appends all of the items in the iterator `I`, separated by the tokens + /// `U`. + fn append_separated(&mut self, iter: I, op: U) + where + T: ToTokens, + I: IntoIterator, + U: ToTokens; + + /// For use by `ToTokens` implementations. + /// + /// Appends all tokens in the iterator `I`, appending `U` after each + /// element, including after the last element of the iterator. + fn append_terminated(&mut self, iter: I, term: U) + where + T: ToTokens, + I: IntoIterator, + U: ToTokens; +} + +impl TokenStreamExt for TokenStream { + fn append(&mut self, token: U) + where + U: Into, + { + self.extend(iter::once(token.into())); + } + + fn append_all(&mut self, iter: I) + where + T: ToTokens, + I: IntoIterator, + { + for token in iter { + token.to_tokens(self); + } + } + + fn append_separated(&mut self, iter: I, op: U) + where + T: ToTokens, + I: IntoIterator, + U: ToTokens, + { + for (i, token) in iter.into_iter().enumerate() { + if i > 0 { + op.to_tokens(self); + } + token.to_tokens(self); + } + } + + fn append_terminated(&mut self, iter: I, term: U) + where + T: ToTokens, + I: IntoIterator, + U: ToTokens, + { + for token in iter { + token.to_tokens(self); + term.to_tokens(self); + } + } +} + +mod private { + use proc_macro2::TokenStream; + + pub trait Sealed {} + + impl Sealed for TokenStream {} +} diff --git a/third_party/cargo/vendor/quote-0.6.13/src/lib.rs b/third_party/cargo/vendor/quote-0.6.13/src/lib.rs new file mode 100644 index 0000000..c201d60 --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/src/lib.rs @@ -0,0 +1,861 @@ +//! This crate provides the [`quote!`] macro for turning Rust syntax tree data +//! structures into tokens of source code. +//! +//! [`quote!`]: macro.quote.html +//! +//! Procedural macros in Rust receive a stream of tokens as input, execute +//! arbitrary Rust code to determine how to manipulate those tokens, and produce +//! a stream of tokens to hand back to the compiler to compile into the caller's +//! crate. Quasi-quoting is a solution to one piece of that -- producing tokens +//! to return to the compiler. +//! +//! The idea of quasi-quoting is that we write *code* that we treat as *data*. +//! Within the `quote!` macro, we can write what looks like code to our text +//! editor or IDE. We get all the benefits of the editor's brace matching, +//! syntax highlighting, indentation, and maybe autocompletion. But rather than +//! compiling that as code into the current crate, we can treat it as data, pass +//! it around, mutate it, and eventually hand it back to the compiler as tokens +//! to compile into the macro caller's crate. +//! +//! This crate is motivated by the procedural macro use case, but is a +//! general-purpose Rust quasi-quoting library and is not specific to procedural +//! macros. +//! +//! *Version requirement: Quote supports any compiler version back to Rust's +//! very first support for procedural macros in Rust 1.15.0.* +//! +//! ```toml +//! [dependencies] +//! quote = "0.6" +//! ``` +//! +//! # Example +//! +//! The following quasi-quoted block of code is something you might find in [a] +//! procedural macro having to do with data structure serialization. The `#var` +//! syntax performs interpolation of runtime variables into the quoted tokens. +//! Check out the documentation of the [`quote!`] macro for more detail about +//! the syntax. See also the [`quote_spanned!`] macro which is important for +//! implementing hygienic procedural macros. +//! +//! [a]: https://serde.rs/ +//! [`quote_spanned!`]: macro.quote_spanned.html +//! +//! ```edition2018 +//! # use quote::quote; +//! # +//! # let generics = ""; +//! # let where_clause = ""; +//! # let field_ty = ""; +//! # let item_ty = ""; +//! # let path = ""; +//! # let value = ""; +//! # +//! let tokens = quote! { +//! struct SerializeWith #generics #where_clause { +//! value: &'a #field_ty, +//! phantom: core::marker::PhantomData<#item_ty>, +//! } +//! +//! impl #generics serde::Serialize for SerializeWith #generics #where_clause { +//! fn serialize(&self, serializer: S) -> Result +//! where +//! S: serde::Serializer, +//! { +//! #path(self.value, serializer) +//! } +//! } +//! +//! SerializeWith { +//! value: #value, +//! phantom: core::marker::PhantomData::<#item_ty>, +//! } +//! }; +//! ``` +//! +//! # Recursion limit +//! +//! The `quote!` macro relies on deep recursion so some large invocations may +//! fail with "recursion limit reached" when you compile. If it fails, bump up +//! the recursion limit by adding `#![recursion_limit = "128"]` to your crate. +//! An even higher limit may be necessary for especially large invocations. + +// Quote types in rustdoc of other crates get linked to here. +#![doc(html_root_url = "https://docs.rs/quote/0.6.13")] + +#[cfg(all( + not(all(target_arch = "wasm32", target_os = "unknown")), + feature = "proc-macro" +))] +extern crate proc_macro; +extern crate proc_macro2; + +mod ext; +pub use ext::TokenStreamExt; + +mod to_tokens; +pub use to_tokens::ToTokens; + +// Not public API. +#[doc(hidden)] +#[path = "runtime.rs"] +pub mod __rt; + +/// The whole point. +/// +/// Performs variable interpolation against the input and produces it as +/// [`TokenStream`]. For returning tokens to the compiler in a procedural macro, use +/// `into()` to build a `TokenStream`. +/// +/// [`TokenStream`]: https://docs.rs/proc-macro2/0.4/proc_macro2/struct.TokenStream.html +/// +/// # Interpolation +/// +/// Variable interpolation is done with `#var` (similar to `$var` in +/// `macro_rules!` macros). This grabs the `var` variable that is currently in +/// scope and inserts it in that location in the output tokens. Any type +/// implementing the [`ToTokens`] trait can be interpolated. This includes most +/// Rust primitive types as well as most of the syntax tree types from the [Syn] +/// crate. +/// +/// [`ToTokens`]: trait.ToTokens.html +/// [Syn]: https://github.com/dtolnay/syn +/// +/// Repetition is done using `#(...)*` or `#(...),*` again similar to +/// `macro_rules!`. This iterates through the elements of any variable +/// interpolated within the repetition and inserts a copy of the repetition body +/// for each one. The variables in an interpolation may be anything that +/// implements `IntoIterator`, including `Vec` or a pre-existing iterator. +/// +/// - `#(#var)*` — no separators +/// - `#(#var),*` — the character before the asterisk is used as a separator +/// - `#( struct #var; )*` — the repetition can contain other tokens +/// - `#( #k => println!("{}", #v), )*` — even multiple interpolations +/// +/// There are two limitations around interpolations in a repetition: +/// +/// - Every interpolation inside of a repetition must be a distinct variable. +/// That is, `#(#a #a)*` is not allowed. Work around this by collecting `a` +/// into a vector and taking references `a1 = &a` and `a2 = &a` which you use +/// inside the repetition: `#(#a1 #a2)*`. Where possible, use meaningful names +/// that indicate the distinct role of each copy. +/// +/// - Every interpolation inside of a repetition must be iterable. If we have +/// `vec` which is a vector and `ident` which is a single identifier, +/// `#(#ident #vec)*` is not allowed. Work around this by using +/// `std::iter::repeat(ident)` to produce an iterable that can be used from +/// within the repetition. +/// +/// # Hygiene +/// +/// Any interpolated tokens preserve the `Span` information provided by their +/// `ToTokens` implementation. Tokens that originate within the `quote!` +/// invocation are spanned with [`Span::call_site()`]. +/// +/// [`Span::call_site()`]: https://docs.rs/proc-macro2/0.4/proc_macro2/struct.Span.html#method.call_site +/// +/// A different span can be provided through the [`quote_spanned!`] macro. +/// +/// [`quote_spanned!`]: macro.quote_spanned.html +/// +/// # Return type +/// +/// The macro evaluates to an expression of type `proc_macro2::TokenStream`. +/// Meanwhile Rust procedural macros are expected to return the type +/// `proc_macro::TokenStream`. +/// +/// The difference between the two types is that `proc_macro` types are entirely +/// specific to procedural macros and cannot ever exist in code outside of a +/// procedural macro, while `proc_macro2` types may exist anywhere including +/// tests and non-macro code like main.rs and build.rs. This is why even the +/// procedural macro ecosystem is largely built around `proc_macro2`, because +/// that ensures the libraries are unit testable and accessible in non-macro +/// contexts. +/// +/// There is a [`From`]-conversion in both directions so returning the output of +/// `quote!` from a procedural macro usually looks like `tokens.into()` or +/// `proc_macro::TokenStream::from(tokens)`. +/// +/// [`From`]: https://doc.rust-lang.org/std/convert/trait.From.html +/// +/// # Examples +/// +/// ## Procedural macro +/// +/// The structure of a basic procedural macro is as follows. Refer to the [Syn] +/// crate for further useful guidance on using `quote!` as part of a procedural +/// macro. +/// +/// [Syn]: https://github.com/dtolnay/syn +/// +/// ```edition2018 +/// # #[cfg(any())] +/// extern crate proc_macro; +/// # use proc_macro2 as proc_macro; +/// +/// use proc_macro::TokenStream; +/// use quote::quote; +/// +/// # const IGNORE_TOKENS: &'static str = stringify! { +/// #[proc_macro_derive(HeapSize)] +/// # }; +/// pub fn derive_heap_size(input: TokenStream) -> TokenStream { +/// // Parse the input and figure out what implementation to generate... +/// # const IGNORE_TOKENS: &'static str = stringify! { +/// let name = /* ... */; +/// let expr = /* ... */; +/// # }; +/// # +/// # let name = 0; +/// # let expr = 0; +/// +/// let expanded = quote! { +/// // The generated impl. +/// impl heapsize::HeapSize for #name { +/// fn heap_size_of_children(&self) -> usize { +/// #expr +/// } +/// } +/// }; +/// +/// // Hand the output tokens back to the compiler. +/// TokenStream::from(expanded) +/// } +/// ``` +/// +/// ## Combining quoted fragments +/// +/// Usually you don't end up constructing an entire final `TokenStream` in one +/// piece. Different parts may come from different helper functions. The tokens +/// produced by `quote!` themselves implement `ToTokens` and so can be +/// interpolated into later `quote!` invocations to build up a final result. +/// +/// ```edition2018 +/// # use quote::quote; +/// # +/// let type_definition = quote! {...}; +/// let methods = quote! {...}; +/// +/// let tokens = quote! { +/// #type_definition +/// #methods +/// }; +/// ``` +/// +/// ## Constructing identifiers +/// +/// Suppose we have an identifier `ident` which came from somewhere in a macro +/// input and we need to modify it in some way for the macro output. Let's +/// consider prepending the identifier with an underscore. +/// +/// Simply interpolating the identifier next to an underscore will not have the +/// behavior of concatenating them. The underscore and the identifier will +/// continue to be two separate tokens as if you had written `_ x`. +/// +/// ```edition2018 +/// # use proc_macro2::{self as syn, Span}; +/// # use quote::quote; +/// # +/// # let ident = syn::Ident::new("i", Span::call_site()); +/// # +/// // incorrect +/// quote! { +/// let mut _#ident = 0; +/// } +/// # ; +/// ``` +/// +/// The solution is to perform token-level manipulations using the APIs provided +/// by Syn and proc-macro2. +/// +/// ```edition2018 +/// # use proc_macro2::{self as syn, Span}; +/// # use quote::quote; +/// # +/// # let ident = syn::Ident::new("i", Span::call_site()); +/// # +/// let concatenated = format!("_{}", ident); +/// let varname = syn::Ident::new(&concatenated, ident.span()); +/// quote! { +/// let mut #varname = 0; +/// } +/// # ; +/// ``` +/// +/// ## Making method calls +/// +/// Let's say our macro requires some type specified in the macro input to have +/// a constructor called `new`. We have the type in a variable called +/// `field_type` of type `syn::Type` and want to invoke the constructor. +/// +/// ```edition2018 +/// # use quote::quote; +/// # +/// # let field_type = quote!(...); +/// # +/// // incorrect +/// quote! { +/// let value = #field_type::new(); +/// } +/// # ; +/// ``` +/// +/// This works only sometimes. If `field_type` is `String`, the expanded code +/// contains `String::new()` which is fine. But if `field_type` is something +/// like `Vec` then the expanded code is `Vec::new()` which is invalid +/// syntax. Ordinarily in handwritten Rust we would write `Vec::::new()` +/// but for macros often the following is more convenient. +/// +/// ```edition2018 +/// # use quote::quote; +/// # +/// # let field_type = quote!(...); +/// # +/// quote! { +/// let value = <#field_type>::new(); +/// } +/// # ; +/// ``` +/// +/// This expands to `>::new()` which behaves correctly. +/// +/// A similar pattern is appropriate for trait methods. +/// +/// ```edition2018 +/// # use quote::quote; +/// # +/// # let field_type = quote!(...); +/// # +/// quote! { +/// let value = <#field_type as core::default::Default>::default(); +/// } +/// # ; +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! quote { + ($($tt:tt)*) => { + quote_spanned!($crate::__rt::Span::call_site()=> $($tt)*) + }; +} + +/// Same as `quote!`, but applies a given span to all tokens originating within +/// the macro invocation. +/// +/// # Syntax +/// +/// A span expression of type [`Span`], followed by `=>`, followed by the tokens +/// to quote. The span expression should be brief -- use a variable for anything +/// more than a few characters. There should be no space before the `=>` token. +/// +/// [`Span`]: https://docs.rs/proc-macro2/0.4/proc_macro2/struct.Span.html +/// +/// ```edition2018 +/// # use proc_macro2::Span; +/// # use quote::quote_spanned; +/// # +/// # const IGNORE_TOKENS: &'static str = stringify! { +/// let span = /* ... */; +/// # }; +/// # let span = Span::call_site(); +/// # let init = 0; +/// +/// // On one line, use parentheses. +/// let tokens = quote_spanned!(span=> Box::into_raw(Box::new(#init))); +/// +/// // On multiple lines, place the span at the top and use braces. +/// let tokens = quote_spanned! {span=> +/// Box::into_raw(Box::new(#init)) +/// }; +/// ``` +/// +/// The lack of space before the `=>` should look jarring to Rust programmers +/// and this is intentional. The formatting is designed to be visibly +/// off-balance and draw the eye a particular way, due to the span expression +/// being evaluated in the context of the procedural macro and the remaining +/// tokens being evaluated in the generated code. +/// +/// # Hygiene +/// +/// Any interpolated tokens preserve the `Span` information provided by their +/// `ToTokens` implementation. Tokens that originate within the `quote_spanned!` +/// invocation are spanned with the given span argument. +/// +/// # Example +/// +/// The following procedural macro code uses `quote_spanned!` to assert that a +/// particular Rust type implements the [`Sync`] trait so that references can be +/// safely shared between threads. +/// +/// [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html +/// +/// ```edition2018 +/// # use quote::{quote_spanned, TokenStreamExt, ToTokens}; +/// # use proc_macro2::{Span, TokenStream}; +/// # +/// # struct Type; +/// # +/// # impl Type { +/// # fn span(&self) -> Span { +/// # Span::call_site() +/// # } +/// # } +/// # +/// # impl ToTokens for Type { +/// # fn to_tokens(&self, _tokens: &mut TokenStream) {} +/// # } +/// # +/// # let ty = Type; +/// # let call_site = Span::call_site(); +/// # +/// let ty_span = ty.span(); +/// let assert_sync = quote_spanned! {ty_span=> +/// struct _AssertSync where #ty: Sync; +/// }; +/// ``` +/// +/// If the assertion fails, the user will see an error like the following. The +/// input span of their type is hightlighted in the error. +/// +/// ```text +/// error[E0277]: the trait bound `*const (): std::marker::Sync` is not satisfied +/// --> src/main.rs:10:21 +/// | +/// 10 | static ref PTR: *const () = &(); +/// | ^^^^^^^^^ `*const ()` cannot be shared between threads safely +/// ``` +/// +/// In this example it is important for the where-clause to be spanned with the +/// line/column information of the user's input type so that error messages are +/// placed appropriately by the compiler. But it is also incredibly important +/// that `Sync` resolves at the macro definition site and not the macro call +/// site. If we resolve `Sync` at the same span that the user's type is going to +/// be resolved, then they could bypass our check by defining their own trait +/// named `Sync` that is implemented for their type. +#[macro_export(local_inner_macros)] +macro_rules! quote_spanned { + ($span:expr=> $($tt:tt)*) => {{ + let mut _s = $crate::__rt::TokenStream::new(); + let _span = $span; + quote_each_token!(_s _span $($tt)*); + _s + }}; +} + +// Extract the names of all #metavariables and pass them to the $finish macro. +// +// in: pounded_var_names!(then () a #b c #( #d )* #e) +// out: then!(() b d e) +#[macro_export(local_inner_macros)] +#[doc(hidden)] +macro_rules! pounded_var_names { + ($finish:ident ($($found:ident)*) # ( $($inner:tt)* ) $($rest:tt)*) => { + pounded_var_names!($finish ($($found)*) $($inner)* $($rest)*) + }; + + ($finish:ident ($($found:ident)*) # [ $($inner:tt)* ] $($rest:tt)*) => { + pounded_var_names!($finish ($($found)*) $($inner)* $($rest)*) + }; + + ($finish:ident ($($found:ident)*) # { $($inner:tt)* } $($rest:tt)*) => { + pounded_var_names!($finish ($($found)*) $($inner)* $($rest)*) + }; + + ($finish:ident ($($found:ident)*) # $first:ident $($rest:tt)*) => { + pounded_var_names!($finish ($($found)* $first) $($rest)*) + }; + + ($finish:ident ($($found:ident)*) ( $($inner:tt)* ) $($rest:tt)*) => { + pounded_var_names!($finish ($($found)*) $($inner)* $($rest)*) + }; + + ($finish:ident ($($found:ident)*) [ $($inner:tt)* ] $($rest:tt)*) => { + pounded_var_names!($finish ($($found)*) $($inner)* $($rest)*) + }; + + ($finish:ident ($($found:ident)*) { $($inner:tt)* } $($rest:tt)*) => { + pounded_var_names!($finish ($($found)*) $($inner)* $($rest)*) + }; + + ($finish:ident ($($found:ident)*) $ignore:tt $($rest:tt)*) => { + pounded_var_names!($finish ($($found)*) $($rest)*) + }; + + ($finish:ident ($($found:ident)*)) => { + $finish!(() $($found)*) + }; +} + +// in: nested_tuples_pat!(() a b c d e) +// out: ((((a b) c) d) e) +// +// in: nested_tuples_pat!(() a) +// out: a +#[macro_export(local_inner_macros)] +#[doc(hidden)] +macro_rules! nested_tuples_pat { + (()) => { + &() + }; + + (() $first:ident $($rest:ident)*) => { + nested_tuples_pat!(($first) $($rest)*) + }; + + (($pat:pat) $first:ident $($rest:ident)*) => { + nested_tuples_pat!((($pat, $first)) $($rest)*) + }; + + (($done:pat)) => { + $done + }; +} + +// in: multi_zip_expr!(() a b c d e) +// out: a.into_iter().zip(b).zip(c).zip(d).zip(e) +// +// in: multi_zip_iter!(() a) +// out: a +#[macro_export(local_inner_macros)] +#[doc(hidden)] +macro_rules! multi_zip_expr { + (()) => { + &[] + }; + + (() $single:ident) => { + $single + }; + + (() $first:ident $($rest:ident)*) => { + multi_zip_expr!(($first.into_iter()) $($rest)*) + }; + + (($zips:expr) $first:ident $($rest:ident)*) => { + multi_zip_expr!(($zips.zip($first)) $($rest)*) + }; + + (($done:expr)) => { + $done + }; +} + +#[macro_export(local_inner_macros)] +#[doc(hidden)] +macro_rules! quote_each_token { + ($tokens:ident $span:ident) => {}; + + ($tokens:ident $span:ident # ! $($rest:tt)*) => { + quote_each_token!($tokens $span #); + quote_each_token!($tokens $span !); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident # ( $($inner:tt)* ) * $($rest:tt)*) => { + for pounded_var_names!(nested_tuples_pat () $($inner)*) + in pounded_var_names!(multi_zip_expr () $($inner)*) { + quote_each_token!($tokens $span $($inner)*); + } + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident # ( $($inner:tt)* ) $sep:tt * $($rest:tt)*) => { + for (_i, pounded_var_names!(nested_tuples_pat () $($inner)*)) + in pounded_var_names!(multi_zip_expr () $($inner)*).into_iter().enumerate() { + if _i > 0 { + quote_each_token!($tokens $span $sep); + } + quote_each_token!($tokens $span $($inner)*); + } + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident # [ $($inner:tt)* ] $($rest:tt)*) => { + quote_each_token!($tokens $span #); + $tokens.extend({ + let mut g = $crate::__rt::Group::new( + $crate::__rt::Delimiter::Bracket, + quote_spanned!($span=> $($inner)*), + ); + g.set_span($span); + Some($crate::__rt::TokenTree::from(g)) + }); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident # $first:ident $($rest:tt)*) => { + $crate::ToTokens::to_tokens(&$first, &mut $tokens); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident ( $($first:tt)* ) $($rest:tt)*) => { + $tokens.extend({ + let mut g = $crate::__rt::Group::new( + $crate::__rt::Delimiter::Parenthesis, + quote_spanned!($span=> $($first)*), + ); + g.set_span($span); + Some($crate::__rt::TokenTree::from(g)) + }); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident [ $($first:tt)* ] $($rest:tt)*) => { + $tokens.extend({ + let mut g = $crate::__rt::Group::new( + $crate::__rt::Delimiter::Bracket, + quote_spanned!($span=> $($first)*), + ); + g.set_span($span); + Some($crate::__rt::TokenTree::from(g)) + }); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident { $($first:tt)* } $($rest:tt)*) => { + $tokens.extend({ + let mut g = $crate::__rt::Group::new( + $crate::__rt::Delimiter::Brace, + quote_spanned!($span=> $($first)*), + ); + g.set_span($span); + Some($crate::__rt::TokenTree::from(g)) + }); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident + $($rest:tt)*) => { + $crate::__rt::push_add(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident += $($rest:tt)*) => { + $crate::__rt::push_add_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident & $($rest:tt)*) => { + $crate::__rt::push_and(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident && $($rest:tt)*) => { + $crate::__rt::push_and_and(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident &= $($rest:tt)*) => { + $crate::__rt::push_and_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident @ $($rest:tt)*) => { + $crate::__rt::push_at(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident ! $($rest:tt)*) => { + $crate::__rt::push_bang(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident ^ $($rest:tt)*) => { + $crate::__rt::push_caret(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident ^= $($rest:tt)*) => { + $crate::__rt::push_caret_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident : $($rest:tt)*) => { + $crate::__rt::push_colon(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident :: $($rest:tt)*) => { + $crate::__rt::push_colon2(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident , $($rest:tt)*) => { + $crate::__rt::push_comma(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident / $($rest:tt)*) => { + $crate::__rt::push_div(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident /= $($rest:tt)*) => { + $crate::__rt::push_div_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident . $($rest:tt)*) => { + $crate::__rt::push_dot(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident .. $($rest:tt)*) => { + $crate::__rt::push_dot2(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident ... $($rest:tt)*) => { + $crate::__rt::push_dot3(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident ..= $($rest:tt)*) => { + $crate::__rt::push_dot_dot_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident = $($rest:tt)*) => { + $crate::__rt::push_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident == $($rest:tt)*) => { + $crate::__rt::push_eq_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident >= $($rest:tt)*) => { + $crate::__rt::push_ge(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident > $($rest:tt)*) => { + $crate::__rt::push_gt(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident <= $($rest:tt)*) => { + $crate::__rt::push_le(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident < $($rest:tt)*) => { + $crate::__rt::push_lt(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident *= $($rest:tt)*) => { + $crate::__rt::push_mul_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident != $($rest:tt)*) => { + $crate::__rt::push_ne(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident | $($rest:tt)*) => { + $crate::__rt::push_or(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident |= $($rest:tt)*) => { + $crate::__rt::push_or_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident || $($rest:tt)*) => { + $crate::__rt::push_or_or(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident # $($rest:tt)*) => { + $crate::__rt::push_pound(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident ? $($rest:tt)*) => { + $crate::__rt::push_question(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident -> $($rest:tt)*) => { + $crate::__rt::push_rarrow(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident <- $($rest:tt)*) => { + $crate::__rt::push_larrow(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident % $($rest:tt)*) => { + $crate::__rt::push_rem(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident %= $($rest:tt)*) => { + $crate::__rt::push_rem_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident => $($rest:tt)*) => { + $crate::__rt::push_fat_arrow(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident ; $($rest:tt)*) => { + $crate::__rt::push_semi(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident << $($rest:tt)*) => { + $crate::__rt::push_shl(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident <<= $($rest:tt)*) => { + $crate::__rt::push_shl_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident >> $($rest:tt)*) => { + $crate::__rt::push_shr(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident >>= $($rest:tt)*) => { + $crate::__rt::push_shr_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident * $($rest:tt)*) => { + $crate::__rt::push_star(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident - $($rest:tt)*) => { + $crate::__rt::push_sub(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident -= $($rest:tt)*) => { + $crate::__rt::push_sub_eq(&mut $tokens, $span); + quote_each_token!($tokens $span $($rest)*); + }; + + ($tokens:ident $span:ident $first:tt $($rest:tt)*) => { + $crate::__rt::parse(&mut $tokens, $span, quote_stringify!($first)); + quote_each_token!($tokens $span $($rest)*); + }; +} + +// Unhygienically invoke whatever `stringify` the caller has in scope i.e. not a +// local macro. The macros marked `local_inner_macros` above cannot invoke +// `stringify` directly. +#[macro_export] +#[doc(hidden)] +macro_rules! quote_stringify { + ($tt:tt) => { + stringify!($tt) + }; +} diff --git a/third_party/cargo/vendor/quote-0.6.13/src/runtime.rs b/third_party/cargo/vendor/quote-0.6.13/src/runtime.rs new file mode 100644 index 0000000..75337c9 --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/src/runtime.rs @@ -0,0 +1,108 @@ +use ext::TokenStreamExt; +pub use proc_macro2::*; + +fn is_ident_start(c: u8) -> bool { + (b'a' <= c && c <= b'z') || (b'A' <= c && c <= b'Z') || c == b'_' +} + +fn is_ident_continue(c: u8) -> bool { + (b'a' <= c && c <= b'z') || (b'A' <= c && c <= b'Z') || c == b'_' || (b'0' <= c && c <= b'9') +} + +fn is_ident(token: &str) -> bool { + let mut iter = token.bytes(); + let first_ok = iter.next().map(is_ident_start).unwrap_or(false); + + first_ok && iter.all(is_ident_continue) +} + +pub fn parse(tokens: &mut TokenStream, span: Span, s: &str) { + if is_ident(s) { + // Fast path, since idents are the most common token. + tokens.append(Ident::new(s, span)); + } else { + let s: TokenStream = s.parse().expect("invalid token stream"); + tokens.extend(s.into_iter().map(|mut t| { + t.set_span(span); + t + })); + } +} + +macro_rules! push_punct { + ($name:ident $char1:tt) => { + pub fn $name(tokens: &mut TokenStream, span: Span) { + let mut punct = Punct::new($char1, Spacing::Alone); + punct.set_span(span); + tokens.append(punct); + } + }; + ($name:ident $char1:tt $char2:tt) => { + pub fn $name(tokens: &mut TokenStream, span: Span) { + let mut punct = Punct::new($char1, Spacing::Joint); + punct.set_span(span); + tokens.append(punct); + let mut punct = Punct::new($char2, Spacing::Alone); + punct.set_span(span); + tokens.append(punct); + } + }; + ($name:ident $char1:tt $char2:tt $char3:tt) => { + pub fn $name(tokens: &mut TokenStream, span: Span) { + let mut punct = Punct::new($char1, Spacing::Joint); + punct.set_span(span); + tokens.append(punct); + let mut punct = Punct::new($char2, Spacing::Joint); + punct.set_span(span); + tokens.append(punct); + let mut punct = Punct::new($char3, Spacing::Alone); + punct.set_span(span); + tokens.append(punct); + } + }; +} + +push_punct!(push_add '+'); +push_punct!(push_add_eq '+' '='); +push_punct!(push_and '&'); +push_punct!(push_and_and '&' '&'); +push_punct!(push_and_eq '&' '='); +push_punct!(push_at '@'); +push_punct!(push_bang '!'); +push_punct!(push_caret '^'); +push_punct!(push_caret_eq '^' '='); +push_punct!(push_colon ':'); +push_punct!(push_colon2 ':' ':'); +push_punct!(push_comma ','); +push_punct!(push_div '/'); +push_punct!(push_div_eq '/' '='); +push_punct!(push_dot '.'); +push_punct!(push_dot2 '.' '.'); +push_punct!(push_dot3 '.' '.' '.'); +push_punct!(push_dot_dot_eq '.' '.' '='); +push_punct!(push_eq '='); +push_punct!(push_eq_eq '=' '='); +push_punct!(push_ge '>' '='); +push_punct!(push_gt '>'); +push_punct!(push_le '<' '='); +push_punct!(push_lt '<'); +push_punct!(push_mul_eq '*' '='); +push_punct!(push_ne '!' '='); +push_punct!(push_or '|'); +push_punct!(push_or_eq '|' '='); +push_punct!(push_or_or '|' '|'); +push_punct!(push_pound '#'); +push_punct!(push_question '?'); +push_punct!(push_rarrow '-' '>'); +push_punct!(push_larrow '<' '-'); +push_punct!(push_rem '%'); +push_punct!(push_rem_eq '%' '='); +push_punct!(push_fat_arrow '=' '>'); +push_punct!(push_semi ';'); +push_punct!(push_shl '<' '<'); +push_punct!(push_shl_eq '<' '<' '='); +push_punct!(push_shr '>' '>'); +push_punct!(push_shr_eq '>' '>' '='); +push_punct!(push_star '*'); +push_punct!(push_sub '-'); +push_punct!(push_sub_eq '-' '='); diff --git a/third_party/cargo/vendor/quote-0.6.13/src/to_tokens.rs b/third_party/cargo/vendor/quote-0.6.13/src/to_tokens.rs new file mode 100644 index 0000000..9d221b2 --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/src/to_tokens.rs @@ -0,0 +1,205 @@ +use super::TokenStreamExt; + +use std::borrow::Cow; +use std::iter; +use std::rc::Rc; + +use proc_macro2::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree}; + +/// Types that can be interpolated inside a [`quote!`] invocation. +/// +/// [`quote!`]: macro.quote.html +pub trait ToTokens { + /// Write `self` to the given `TokenStream`. + /// + /// The token append methods provided by the [`TokenStreamExt`] extension + /// trait may be useful for implementing `ToTokens`. + /// + /// [`TokenStreamExt`]: trait.TokenStreamExt.html + /// + /// # Example + /// + /// Example implementation for a struct representing Rust paths like + /// `std::cmp::PartialEq`: + /// + /// ```edition2018 + /// use proc_macro2::{TokenTree, Spacing, Span, Punct, TokenStream}; + /// use quote::{TokenStreamExt, ToTokens}; + /// + /// pub struct Path { + /// pub global: bool, + /// pub segments: Vec, + /// } + /// + /// impl ToTokens for Path { + /// fn to_tokens(&self, tokens: &mut TokenStream) { + /// for (i, segment) in self.segments.iter().enumerate() { + /// if i > 0 || self.global { + /// // Double colon `::` + /// tokens.append(Punct::new(':', Spacing::Joint)); + /// tokens.append(Punct::new(':', Spacing::Alone)); + /// } + /// segment.to_tokens(tokens); + /// } + /// } + /// } + /// # + /// # pub struct PathSegment; + /// # + /// # impl ToTokens for PathSegment { + /// # fn to_tokens(&self, tokens: &mut TokenStream) { + /// # unimplemented!() + /// # } + /// # } + /// ``` + fn to_tokens(&self, tokens: &mut TokenStream); + + /// Convert `self` directly into a `TokenStream` object. + /// + /// This method is implicitly implemented using `to_tokens`, and acts as a + /// convenience method for consumers of the `ToTokens` trait. + fn into_token_stream(self) -> TokenStream + where + Self: Sized, + { + let mut tokens = TokenStream::new(); + self.to_tokens(&mut tokens); + tokens + } +} + +impl<'a, T: ?Sized + ToTokens> ToTokens for &'a T { + fn to_tokens(&self, tokens: &mut TokenStream) { + (**self).to_tokens(tokens); + } +} + +impl<'a, T: ?Sized + ToTokens> ToTokens for &'a mut T { + fn to_tokens(&self, tokens: &mut TokenStream) { + (**self).to_tokens(tokens); + } +} + +impl<'a, T: ?Sized + ToOwned + ToTokens> ToTokens for Cow<'a, T> { + fn to_tokens(&self, tokens: &mut TokenStream) { + (**self).to_tokens(tokens); + } +} + +impl ToTokens for Box { + fn to_tokens(&self, tokens: &mut TokenStream) { + (**self).to_tokens(tokens); + } +} + +impl ToTokens for Rc { + fn to_tokens(&self, tokens: &mut TokenStream) { + (**self).to_tokens(tokens); + } +} + +impl ToTokens for Option { + fn to_tokens(&self, tokens: &mut TokenStream) { + if let Some(ref t) = *self { + t.to_tokens(tokens); + } + } +} + +impl ToTokens for str { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append(Literal::string(self)); + } +} + +impl ToTokens for String { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.as_str().to_tokens(tokens); + } +} + +macro_rules! primitive { + ($($t:ident => $name:ident)*) => ($( + impl ToTokens for $t { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append(Literal::$name(*self)); + } + } + )*) +} + +primitive! { + i8 => i8_suffixed + i16 => i16_suffixed + i32 => i32_suffixed + i64 => i64_suffixed + isize => isize_suffixed + + u8 => u8_suffixed + u16 => u16_suffixed + u32 => u32_suffixed + u64 => u64_suffixed + usize => usize_suffixed + + f32 => f32_suffixed + f64 => f64_suffixed +} + +#[cfg(integer128)] +primitive! { + i128 => i128_suffixed + u128 => u128_suffixed +} + +impl ToTokens for char { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append(Literal::character(*self)); + } +} + +impl ToTokens for bool { + fn to_tokens(&self, tokens: &mut TokenStream) { + let word = if *self { "true" } else { "false" }; + tokens.append(Ident::new(word, Span::call_site())); + } +} + +impl ToTokens for Group { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append(self.clone()); + } +} + +impl ToTokens for Ident { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append(self.clone()); + } +} + +impl ToTokens for Punct { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append(self.clone()); + } +} + +impl ToTokens for Literal { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append(self.clone()); + } +} + +impl ToTokens for TokenTree { + fn to_tokens(&self, dst: &mut TokenStream) { + dst.append(self.clone()); + } +} + +impl ToTokens for TokenStream { + fn to_tokens(&self, dst: &mut TokenStream) { + dst.extend(iter::once(self.clone())); + } + + fn into_token_stream(self) -> TokenStream { + self + } +} diff --git a/third_party/cargo/vendor/quote-0.6.13/tests/conditional/integer128.rs b/third_party/cargo/vendor/quote-0.6.13/tests/conditional/integer128.rs new file mode 100644 index 0000000..61e2274 --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/tests/conditional/integer128.rs @@ -0,0 +1,11 @@ +#[test] +fn test_integer128() { + let ii128 = -1i128; + let uu128 = 1u128; + + let tokens = quote! { + #ii128 #uu128 + }; + let expected = "-1i128 1u128"; + assert_eq!(expected, tokens.to_string()); +} diff --git a/third_party/cargo/vendor/quote-0.6.13/tests/test.rs b/third_party/cargo/vendor/quote-0.6.13/tests/test.rs new file mode 100644 index 0000000..85562bf --- /dev/null +++ b/third_party/cargo/vendor/quote-0.6.13/tests/test.rs @@ -0,0 +1,295 @@ +#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))] + +use std::borrow::Cow; + +extern crate proc_macro2; +#[macro_use] +extern crate quote; + +use proc_macro2::{Ident, Span, TokenStream}; +use quote::TokenStreamExt; + +mod conditional { + #[cfg(integer128)] + mod integer128; +} + +struct X; + +impl quote::ToTokens for X { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append(Ident::new("X", Span::call_site())); + } +} + +#[test] +fn test_quote_impl() { + let tokens = quote! { + impl<'a, T: ToTokens> ToTokens for &'a T { + fn to_tokens(&self, tokens: &mut TokenStream) { + (**self).to_tokens(tokens) + } + } + }; + + let expected = concat!( + "impl < 'a , T : ToTokens > ToTokens for & 'a T { ", + "fn to_tokens ( & self , tokens : & mut TokenStream ) { ", + "( * * self ) . to_tokens ( tokens ) ", + "} ", + "}" + ); + + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_substitution() { + let x = X; + let tokens = quote!(#x <#x> (#x) [#x] {#x}); + + let expected = "X < X > ( X ) [ X ] { X }"; + + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_iter() { + let primes = &[X, X, X, X]; + + assert_eq!("X X X X", quote!(#(#primes)*).to_string()); + + assert_eq!("X , X , X , X ,", quote!(#(#primes,)*).to_string()); + + assert_eq!("X , X , X , X", quote!(#(#primes),*).to_string()); +} + +#[test] +fn test_advanced() { + let generics = quote!( <'a, T> ); + + let where_clause = quote!( where T: Serialize ); + + let field_ty = quote!(String); + + let item_ty = quote!(Cow<'a, str>); + + let path = quote!(SomeTrait::serialize_with); + + let value = quote!(self.x); + + let tokens = quote! { + struct SerializeWith #generics #where_clause { + value: &'a #field_ty, + phantom: ::std::marker::PhantomData<#item_ty>, + } + + impl #generics ::serde::Serialize for SerializeWith #generics #where_clause { + fn serialize(&self, s: &mut S) -> Result<(), S::Error> + where S: ::serde::Serializer + { + #path(self.value, s) + } + } + + SerializeWith { + value: #value, + phantom: ::std::marker::PhantomData::<#item_ty>, + } + }; + + let expected = concat!( + "struct SerializeWith < 'a , T > where T : Serialize { ", + "value : & 'a String , ", + "phantom : :: std :: marker :: PhantomData < Cow < 'a , str > > , ", + "} ", + "impl < 'a , T > :: serde :: Serialize for SerializeWith < 'a , T > where T : Serialize { ", + "fn serialize < S > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > ", + "where S : :: serde :: Serializer ", + "{ ", + "SomeTrait :: serialize_with ( self . value , s ) ", + "} ", + "} ", + "SerializeWith { ", + "value : self . x , ", + "phantom : :: std :: marker :: PhantomData :: < Cow < 'a , str > > , ", + "}" + ); + + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_integer() { + let ii8 = -1i8; + let ii16 = -1i16; + let ii32 = -1i32; + let ii64 = -1i64; + let iisize = -1isize; + let uu8 = 1u8; + let uu16 = 1u16; + let uu32 = 1u32; + let uu64 = 1u64; + let uusize = 1usize; + + let tokens = quote! { + #ii8 #ii16 #ii32 #ii64 #iisize + #uu8 #uu16 #uu32 #uu64 #uusize + }; + let expected = "-1i8 -1i16 -1i32 -1i64 -1isize 1u8 1u16 1u32 1u64 1usize"; + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_floating() { + let e32 = 2.345f32; + + let e64 = 2.345f64; + + let tokens = quote! { + #e32 + #e64 + }; + let expected = concat!("2.345f32 2.345f64"); + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_char() { + let zero = '\0'; + let pound = '#'; + let quote = '"'; + let apost = '\''; + let newline = '\n'; + let heart = '\u{2764}'; + + let tokens = quote! { + #zero #pound #quote #apost #newline #heart + }; + let expected = "'\\u{0}' '#' '\"' '\\'' '\\n' '\\u{2764}'"; + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_str() { + let s = "\0 a 'b \" c"; + let tokens = quote!(#s); + let expected = "\"\\u{0} a 'b \\\" c\""; + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_string() { + let s = "\0 a 'b \" c".to_string(); + let tokens = quote!(#s); + let expected = "\"\\u{0} a 'b \\\" c\""; + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_ident() { + let foo = Ident::new("Foo", Span::call_site()); + let bar = Ident::new(&format!("Bar{}", 7), Span::call_site()); + let tokens = quote!(struct #foo; enum #bar {}); + let expected = "struct Foo ; enum Bar7 { }"; + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_duplicate() { + let ch = 'x'; + + let tokens = quote!(#ch #ch); + + let expected = "'x' 'x'"; + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_fancy_repetition() { + let foo = vec!["a", "b"]; + let bar = vec![true, false]; + + let tokens = quote! { + #(#foo: #bar),* + }; + + let expected = r#""a" : true , "b" : false"#; + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_nested_fancy_repetition() { + let nested = vec![vec!['a', 'b', 'c'], vec!['x', 'y', 'z']]; + + let tokens = quote! { + #( + #(#nested)* + ),* + }; + + let expected = "'a' 'b' 'c' , 'x' 'y' 'z'"; + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_empty_repetition() { + let tokens = quote!(#(a b)* #(c d),*); + assert_eq!("", tokens.to_string()); +} + +#[test] +fn test_variable_name_conflict() { + // The implementation of `#(...),*` uses the variable `_i` but it should be + // fine, if a little confusing when debugging. + let _i = vec!['a', 'b']; + let tokens = quote! { #(#_i),* }; + let expected = "'a' , 'b'"; + assert_eq!(expected, tokens.to_string()); +} + +#[test] +fn test_empty_quote() { + let tokens = quote!(); + assert_eq!("", tokens.to_string()); +} + +#[test] +fn test_box_str() { + let b = "str".to_owned().into_boxed_str(); + let tokens = quote! { #b }; + assert_eq!("\"str\"", tokens.to_string()); +} + +#[test] +fn test_cow() { + let owned: Cow = Cow::Owned(Ident::new("owned", Span::call_site())); + + let ident = Ident::new("borrowed", Span::call_site()); + let borrowed = Cow::Borrowed(&ident); + + let tokens = quote! { #owned #borrowed }; + assert_eq!("owned borrowed", tokens.to_string()); +} + +#[test] +fn test_closure() { + fn field_i(i: usize) -> Ident { + Ident::new(&format!("__field{}", i), Span::call_site()) + } + + let fields = (0usize..3) + .map(field_i as fn(_) -> _) + .map(|var| quote! { #var }); + + let tokens = quote! { #(#fields)* }; + assert_eq!("__field0 __field1 __field2", tokens.to_string()); +} + +#[test] +fn test_append_tokens() { + let mut a = quote!(a); + let b = quote!(b); + a.append_all(b); + assert_eq!("a b", a.to_string()); +} diff --git a/third_party/cargo/vendor/rand-0.5.6/.cargo-checksum.json b/third_party/cargo/vendor/rand-0.5.6/.cargo-checksum.json new file mode 100644 index 0000000..a5c9a91 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"f5372c19151008367e30b37ced248ed2aac4ba74294204cf657070f54d405aac","CONTRIBUTING.md":"ce1d116f2991f195479a217ecad883e65812d739476ce313adbbed16425e9730","Cargo.toml":"226ebec959d588987fb0006d0ad708dd2a21a48ab70fd4581079a13c1a513203","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"2a9b60793f4b06217710ba574fb266850f64d265359c00d06ab05e0e3f4b7bb3","UPDATING.md":"995b503e4e25662c63df1710ca557e9688e1095644a4de80c6d19a2aa4281f2d","appveyor.yml":"e72b9bf8fa81ec7bc8939da12f51df6de946b93246542cf1f538ff1119497de6","benches/distributions.rs":"041c5adb223ee3a42bf6d5841e123ed1ea24838463bf88c29a5cb5a5dcfb320b","benches/generators.rs":"ef5e38c2462f9fb6dfeb7892061123b668826404a4546463bf34a8a939b39d1b","benches/misc.rs":"674e06347bc95cdd14588fefa673dbbc52d043b8e93d2bd56ee2fc9ad030d570","examples/monte-carlo.rs":"5b52e0dff8b2c29b2037c1f93f703e1c203d05b884640db99520137307fd9d6e","examples/monty-hall.rs":"d4873d567a606822dcb2be7e06517144f44d0d0ec39990751756b6265acaa88c","src/distributions/bernoulli.rs":"3a8dbab7dc97e6ad8d3225857dd6413e44a78d49ff870c25b1cd2c3bf7fdb6c3","src/distributions/binomial.rs":"38e46f348097920583707d86ec30522fb816355f216fd2a97fb427a5ed03c860","src/distributions/cauchy.rs":"a075e8e4d181bac25136a80f2af6cdc8b6d60c6d16df5b67a5181ea00ae3a34e","src/distributions/exponential.rs":"1702c7640d6027c49913d7e46b12c292646f9f4007ef74ba238c582de47014ee","src/distributions/float.rs":"0d0e79423d002a3187a7dec73e11e5acd9060590e71a3e39ca44375cafc687d4","src/distributions/gamma.rs":"8763faa2f6a244ea95d5af2b1e48ec8ddd1983eb4e170cf873c513fc8bc0746c","src/distributions/integer.rs":"a9c9edda09a457831c06e93ce94e7074af5bf97fd663a940b2f09ea21b1106a9","src/distributions/log_gamma.rs":"9f1fda43162c3f6184af15e9fabf3475de7e4e2e46412e7ae1480de1c7e5a68e","src/distributions/mod.rs":"3b7d190ce0d0c60fabac2902538116af27c5fa9291899287d281e2a16a8078bb","src/distributions/normal.rs":"987dc08c94e33f4f07e227d3b887d3cb522ddc6439bb93adcd0daf9b64097900","src/distributions/other.rs":"9962a738ed861d6c59e46272401290eca4237862127b3a143c7865616d9c1bed","src/distributions/pareto.rs":"ba207487d655295db7a566fec97ed636f0bcf4e50642138da553fd58e613cefe","src/distributions/poisson.rs":"3a44644936dea768ef83b45c9be86626356c67fc72f48f10d72111428ad77ddf","src/distributions/uniform.rs":"6cc7b9916e72a5807a9f7fdd90cb2944e9d175570758a507d6ce5779abda5a45","src/distributions/ziggurat_tables.rs":"4757d144fd1fc13fc0118e073f9ecf2a3cc94144a254a6633900705c3d9f7db3","src/lib.rs":"1560e7529869bc73603410a76a9d9c434953288d06c9743c4dd0d4f5d7438b94","src/prelude.rs":"a2f76c76bc2c7822bb4ce67ba13b076305b434a542aaa5f07b67f66f65e3e8cc","src/prng/chacha.rs":"f8659eb5beceb19e582f81050584007f6893b537da60e697fa04b1302a1e161f","src/prng/hc128.rs":"0b44d4877159ee82109fcd4415635db6baf27db1381598b0f18cecb7841c975c","src/prng/isaac.rs":"e8b9ee17f39c38b51fd2baeedc130979a81ff4b963a1016f57e78ffc16fb0d3f","src/prng/isaac64.rs":"32a1fee407b95349ff115e7bd9768214f953664124e577f62388a7bc5c129051","src/prng/isaac_array.rs":"9371fcd04f29aa21b10a6bba76949853d8a80b72fbb5c61ba9b0d9db8d6bbb3c","src/prng/mod.rs":"1055528c5755d280ef9e420615e69dde35f8267c7cf20d178b75145a722ad462","src/prng/xorshift.rs":"dacb87577d3faafe5a5333c7e4eae6cab5a9f23eef68069a9b7195dfd74a2901","src/rngs/adapter/mod.rs":"1f956553588693682d29be3a61385a6738d0c682719138a32460407aa626d5a3","src/rngs/adapter/read.rs":"72000e758119093ca090b281a5d2e76981e218175162c8502ceaff021b706198","src/rngs/adapter/reseeding.rs":"0b0ad2f47fba9d5aa787c7c2284d7f0dc9464830a63a3347a63270c011b1a1a5","src/rngs/entropy.rs":"8024dde0ae9fa5a87235c7fb09568c59f2a1fcab86324992192ed3e6c5eed7eb","src/rngs/jitter.rs":"24797e2fb6c7f2fa896b824591a74841fe1e5da980725161ab03882404ffd13a","src/rngs/mock.rs":"5ce40a4da78a623dd379035ccb2bc58e713508d0db0e89098dc362f7d7fbb4e3","src/rngs/mod.rs":"a6d2fba84dd76a96f43ba4a47b7ad067625f3acaeb3c532edbc82b9222f62a92","src/rngs/os.rs":"cf38bed5e8af7e1f1838cf8d3d5abf00702fc05aee34dd3e7d1b6ab8f1bafa2c","src/rngs/small.rs":"a6d51c0066e225bcab8a563b26a0f1b8a555ef1e3aca20210b6cd38513f08c8a","src/rngs/std.rs":"a38628a9bb2ed68daa9f9288380f274713f035b27f287e67a310c5bb4cb14f97","src/rngs/thread.rs":"645cfaa31458ad20d0bebc12a0f1aa4a6a3b00bcc6a446c5e232a14c6a396329","src/seq.rs":"124236e85d71c9cc7a8d065b45f0746cddc1a2af997d34abf664cfdab7354e81","tests/bool.rs":"b57dd7c6e597383f7f84a172cd29e85246475f2686159ca6aa61c52989f762ba","utils/ci/install.sh":"cbc29da047c6e516ff5d13731c8b07812fd40986e7b19b61a7c5deaf5d6ffdd0","utils/ci/script.sh":"309a982ecc8f5669cc1a9d0d67e0f743f3969f1a5a49e8285966ab5518767c43","utils/ziggurat_tables.py":"97d156574ad51465dd023ee63a3fbb52a5603963b09f3f30a50cdfd2bbf1a1e1"},"package":"c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand-0.5.6/BUILD b/third_party/cargo/vendor/rand-0.5.6/BUILD new file mode 100644 index 0000000..c2dedab --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/BUILD @@ -0,0 +1,58 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "bool" with type "test" omitted +# Unsupported target "distributions" with type "bench" omitted +# Unsupported target "generators" with type "bench" omitted +# Unsupported target "misc" with type "bench" omitted +# Unsupported target "monte-carlo" with type "example" omitted +# Unsupported target "monty-hall" with type "example" omitted + +rust_library( + name = "rand", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/rand_core-0.3.1:rand_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.5.6", + crate_features = [ + "alloc", + "cloudabi", + "default", + "fuchsia-cprng", + "libc", + "rand_core", + "std", + "winapi", + ], +) + diff --git a/third_party/cargo/vendor/rand-0.5.6/CHANGELOG.md b/third_party/cargo/vendor/rand-0.5.6/CHANGELOG.md new file mode 100644 index 0000000..4a09a5d --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/CHANGELOG.md @@ -0,0 +1,422 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md). + +You may also find the [Update Guide](UPDATING.md) useful. + + +## [0.5.6] - 2019-01-25 +### Platforms +- Fuchsia: Replaced fuchsia-zircon with fuchsia-cprng + + +## [0.5.5] - 2018-08-07 +### Documentation +- Fix links in documentation (#582) + + +## [0.5.4] - 2018-07-11 +### Platform support +- Make `OsRng` work via WASM/stdweb for WebWorkers + + +## [0.5.3] - 2018-06-26 +### Platform support +- OpenBSD, Bitrig: fix compilation (broken in 0.5.1) (#530) + + +## [0.5.2] - 2018-06-18 +### Platform support +- Hide `OsRng` and `JitterRng` on unsupported platforms (#512; fixes #503). + + +## [0.5.1] - 2018-06-08 + +### New distributions +- Added Cauchy distribution. (#474, #486) +- Added Pareto distribution. (#495) + +### Platform support and `OsRng` +- Remove blanket Unix implementation. (#484) +- Remove Wasm unimplemented stub. (#484) +- Dragonfly BSD: read from `/dev/random`. (#484) +- Bitrig: use `getentropy` like OpenBSD. (#484) +- Solaris: (untested) use `getrandom` if available, otherwise `/dev/random`. (#484) +- Emscripten, `stdweb`: split the read up in chunks. (#484) +- Emscripten, Haiku: don't do an extra blocking read from `/dev/random`. (#484) +- Linux, NetBSD, Solaris: read in blocking mode on first use in `fill_bytes`. (#484) +- Fuchsia, CloudABI: fix compilation (broken in Rand 0.5). (#484) + + +## [0.5.0] - 2018-05-21 + +### Crate features and organisation +- Minimum Rust version update: 1.22.0. (#239) +- Create a separate `rand_core` crate. (#288) +- Deprecate `rand_derive`. (#256) +- Add `prelude` (and module reorganisation). (#435) +- Add `log` feature. Logging is now available in `JitterRng`, `OsRng`, `EntropyRng` and `ReseedingRng`. (#246) +- Add `serde1` feature for some PRNGs. (#189) +- `stdweb` feature for `OsRng` support on WASM via stdweb. (#272, #336) + +### `Rng` trait +- Split `Rng` in `RngCore` and `Rng` extension trait. + `next_u32`, `next_u64` and `fill_bytes` are now part of `RngCore`. (#265) +- Add `Rng::sample`. (#256) +- Deprecate `Rng::gen_weighted_bool`. (#308) +- Add `Rng::gen_bool`. (#308) +- Remove `Rng::next_f32` and `Rng::next_f64`. (#273) +- Add optimized `Rng::fill` and `Rng::try_fill` methods. (#247) +- Deprecate `Rng::gen_iter`. (#286) +- Deprecate `Rng::gen_ascii_chars`. (#279) + +### `rand_core` crate +- `rand` now depends on new `rand_core` crate (#288) +- `RngCore` and `SeedableRng` are now part of `rand_core`. (#288) +- Add modules to help implementing RNGs `impl` and `le`. (#209, #228) +- Add `Error` and `ErrorKind`. (#225) +- Add `CryptoRng` marker trait. (#273) +- Add `BlockRngCore` trait. (#281) +- Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325) +- Revise the `SeedableRng` trait. (#233) +- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288) +- Add `RngCore::try_fill_bytes`. (#225) + +### Other traits and types +- Add `FromEntropy` trait. (#233, #375) +- Add `SmallRng` wrapper. (#296) +- Rewrite `ReseedingRng` to only work with `BlockRngCore` (substantial performance improvement). (#281) +- Deprecate `weak_rng`. Use `SmallRng` instead. (#296) +- Deprecate `AsciiGenerator`. (#279) + +### Random number generators +- Switch `StdRng` and `thread_rng` to HC-128. (#277) +- `StdRng` must now be created with `from_entropy` instead of `new` +- Change `thread_rng` reseeding threshold to 32 MiB. (#277) +- PRNGs no longer implement `Copy`. (#209) +- `Debug` implementations no longer show internals. (#209) +- Implement `Clone` for `ReseedingRng`, `JitterRng`, OsRng`. (#383, #384) +- Implement serialization for `XorShiftRng`, `IsaacRng` and `Isaac64Rng` under the `serde1` feature. (#189) +- Implement `BlockRngCore` for `ChaChaCore` and `Hc128Core`. (#281) +- All PRNGs are now portable across big- and little-endian architectures. (#209) +- `Isaac64Rng::next_u32` no longer throws away half the results. (#209) +- Add `IsaacRng::new_from_u64` and `Isaac64Rng::new_from_u64`. (#209) +- Add the HC-128 CSPRNG `Hc128Rng`. (#210) +- Change ChaCha20 to have 64-bit counter and 64-bit stream. (#349) +- Changes to `JitterRng` to get its size down from 2112 to 24 bytes. (#251) +- Various performance improvements to all PRNGs. + +### Platform support and `OsRng` +- Add support for CloudABI. (#224) +- Remove support for NaCl. (#225) +- WASM support for `OsRng` via stdweb, behind the `stdweb` feature. (#272, #336) +- Use `getrandom` on more platforms for Linux, and on Android. (#338) +- Use the `SecRandomCopyBytes` interface on macOS. (#322) +- On systems that do not have a syscall interface, only keep a single file descriptor open for `OsRng`. (#239) +- On Unix, first try a single read from `/dev/random`, then `/dev/urandom`. (#338) +- Better error handling and reporting in `OsRng` (using new error type). (#225) +- `OsRng` now uses non-blocking when available. (#225) +- Add `EntropyRng`, which provides `OsRng`, but has `JitterRng` as a fallback. (#235) + +### Distributions +- New `Distribution` trait. (#256) +- Add `Distribution::sample_iter` and `Rng::::sample_iter`. (#361) +- Deprecate `Rand`, `Sample` and `IndependentSample` traits. (#256) +- Add a `Standard` distribution (replaces most `Rand` implementations). (#256) +- Add `Binomial` and `Poisson` distributions. (#96) +- Add `Bernoulli` dsitribution. (#411) +- Add `Alphanumeric` distribution. (#279) +- Remove `Closed01` distribution, add `OpenClosed01`. (#274, #420) +- Rework `Range` type, making it possible to implement it for user types. (#274) +- Rename `Range` to `Uniform`. (#395) +- Add `Uniform::new_inclusive` for inclusive ranges. (#274) +- Use widening multiply method for much faster integer range reduction. (#274) +- `Standard` distribution for `char` uses `Uniform` internally. (#274) +- `Standard` distribution for `bool` uses sign test. (#274) +- Implement `Standard` distribution for `Wrapping`. (#436) +- Implement `Uniform` distribution for `Duration`. (#427) + + +## [0.4.3] - 2018-08-16 +### Fixed +- Use correct syscall number for PowerPC (#589) + + +## [0.4.2] - 2018-01-06 +### Changed +- Use `winapi` on Windows +- Update for Fuchsia OS +- Remove dev-dependency on `log` + + +## [0.4.1] - 2017-12-17 +### Added +- `no_std` support + + +## [0.4.0-pre.0] - 2017-12-11 +### Added +- `JitterRng` added as a high-quality alternative entropy source using the + system timer +- new `seq` module with `sample_iter`, `sample_slice`, etc. +- WASM support via dummy implementations (fail at run-time) +- Additional benchmarks, covering generators and new seq code + +### Changed +- `thread_rng` uses `JitterRng` if seeding from system time fails + (slower but more secure than previous method) + +### Deprecated + - `sample` function deprecated (replaced by `sample_iter`) + + +## [0.3.20] - 2018-01-06 +### Changed +- Remove dev-dependency on `log` +- Update `fuchsia-zircon` dependency to 0.3.2 + + +## [0.3.19] - 2017-12-27 +### Changed +- Require `log <= 0.3.8` for dev builds +- Update `fuchsia-zircon` dependency to 0.3 +- Fix broken links in docs (to unblock compiler docs testing CI) + + +## [0.3.18] - 2017-11-06 +### Changed +- `thread_rng` is seeded from the system time if `OsRng` fails +- `weak_rng` now uses `thread_rng` internally + + +## [0.3.17] - 2017-10-07 +### Changed + - Fuchsia: Magenta was renamed Zircon + +## [0.3.16] - 2017-07-27 +### Added +- Implement Debug for mote non-public types +- implement `Rand` for (i|u)i128 +- Support for Fuchsia + +### Changed +- Add inline attribute to SampleRange::construct_range. + This improves the benchmark for sample in 11% and for shuffle in 16%. +- Use `RtlGenRandom` instead of `CryptGenRandom` + + +## [0.3.15] - 2016-11-26 +### Added +- Add `Rng` trait method `choose_mut` +- Redox support + +### Changed +- Use `arc4rand` for `OsRng` on FreeBSD. +- Use `arc4random(3)` for `OsRng` on OpenBSD. + +### Fixed +- Fix filling buffers 4 GiB or larger with `OsRng::fill_bytes` on Windows + + +## [0.3.14] - 2016-02-13 +### Fixed +- Inline definitions from winapi/advapi32, wich decreases build times + + +## [0.3.13] - 2016-01-09 +### Fixed +- Compatible with Rust 1.7.0-nightly (needed some extra type annotations) + + +## [0.3.12] - 2015-11-09 +### Changed +- Replaced the methods in `next_f32` and `next_f64` with the technique described + Saito & Matsumoto at MCQMC'08. The new method should exhibit a slightly more + uniform distribution. +- Depend on libc 0.2 + +### Fixed +- Fix iterator protocol issue in `rand::sample` + + +## [0.3.11] - 2015-08-31 +### Added +- Implement `Rand` for arrays with n <= 32 + + +## [0.3.10] - 2015-08-17 +### Added +- Support for NaCl platforms + +### Changed +- Allow `Rng` to be `?Sized`, impl for `&mut R` and `Box` where `R: ?Sized + Rng` + + +## [0.3.9] - 2015-06-18 +### Changed +- Use `winapi` for Windows API things + +### Fixed +- Fixed test on stable/nightly +- Fix `getrandom` syscall number for aarch64-unknown-linux-gnu + + +## [0.3.8] - 2015-04-23 +### Changed +- `log` is a dev dependency + +### Fixed +- Fix race condition of atomics in `is_getrandom_available` + + +## [0.3.7] - 2015-04-03 +### Fixed +- Derive Copy/Clone changes + + +## [0.3.6] - 2015-04-02 +### Changed +- Move to stable Rust! + + +## [0.3.5] - 2015-04-01 +### Fixed +- Compatible with Rust master + + +## [0.3.4] - 2015-03-31 +### Added +- Implement Clone for `Weighted` + +### Fixed +- Compatible with Rust master + + +## [0.3.3] - 2015-03-26 +### Fixed +- Fix compile on Windows + + +## [0.3.2] - 2015-03-26 + + +## [0.3.1] - 2015-03-26 +### Fixed +- Fix compile on Windows + + +## [0.3.0] - 2015-03-25 +### Changed +- Update to use log version 0.3.x + + +## [0.2.1] - 2015-03-22 +### Fixed +- Compatible with Rust master +- Fixed iOS compilation + + +## [0.2.0] - 2015-03-06 +### Fixed +- Compatible with Rust master (move from `old_io` to `std::io`) + + +## [0.1.4] - 2015-03-04 +### Fixed +- Compatible with Rust master (use wrapping ops) + + +## [0.1.3] - 2015-02-20 +### Fixed +- Compatible with Rust master + +### Removed +- Removed Copy implementations from RNGs + + +## [0.1.2] - 2015-02-03 +### Added +- Imported functionality from `std::rand`, including: + - `StdRng`, `SeedableRng`, `TreadRng`, `weak_rng()` + - `ReaderRng`: A wrapper around any Reader to treat it as an RNG. +- Imported documentation from `std::rand` +- Imported tests from `std::rand` + + +## [0.1.1] - 2015-02-03 +### Added +- Migrate to a cargo-compatible directory structure. + +### Fixed +- Do not use entropy during `gen_weighted_bool(1)` + + +## [Rust 0.12.0] - 2014-10-09 +### Added +- Impl Rand for tuples of arity 11 and 12 +- Include ChaCha pseudorandom generator +- Add `next_f64` and `next_f32` to Rng +- Implement Clone for PRNGs + +### Changed +- Rename `TaskRng` to `ThreadRng` and `task_rng` to `thread_rng` (since a + runtime is removed from Rust). + +### Fixed +- Improved performance of ISAAC and ISAAC64 by 30% and 12 % respectively, by + informing the optimiser that indexing is never out-of-bounds. + +### Removed +- Removed the Deprecated `choose_option` + + +## [Rust 0.11.0] - 2014-07-02 +### Added +- document when to use `OSRng` in cryptographic context, and explain why we use `/dev/urandom` instead of `/dev/random` +- `Rng::gen_iter()` which will return an infinite stream of random values +- `Rng::gen_ascii_chars()` which will return an infinite stream of random ascii characters + +### Changed +- Now only depends on libcore! +- Remove `Rng.choose()`, rename `Rng.choose_option()` to `.choose()` +- Rename OSRng to OsRng +- The WeightedChoice structure is no longer built with a `Vec>`, + but rather a `&mut [Weighted]`. This means that the WeightedChoice + structure now has a lifetime associated with it. +- The `sample` method on `Rng` has been moved to a top-level function in the + `rand` module due to its dependence on `Vec`. + +### Removed +- `Rng::gen_vec()` was removed. Previous behavior can be regained with + `rng.gen_iter().take(n).collect()` +- `Rng::gen_ascii_str()` was removed. Previous behavior can be regained with + `rng.gen_ascii_chars().take(n).collect()` +- {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all + relied on being able to use an OSRng for seeding, but this is no longer + available in librand (where these types are defined). To retain the same + functionality, these types now implement the `Rand` trait so they can be + generated with a random seed from another random number generator. This allows + the stdlib to use an OSRng to create seeded instances of these RNGs. +- Rand implementations for `Box` and `@T` were removed. These seemed to be + pretty rare in the codebase, and it allows for librand to not depend on + liballoc. Additionally, other pointer types like Rc and Arc were not + supported. +- Remove a slew of old deprecated functions + + +## [Rust 0.10] - 2014-04-03 +### Changed +- replace `Rng.shuffle's` functionality with `.shuffle_mut` +- bubble up IO errors when creating an OSRng + +### Fixed +- Use `fill()` instead of `read()` +- Rewrite OsRng in Rust for windows + +## [0.10-pre] - 2014-03-02 +### Added +- Seperate `rand` out of the standard library diff --git a/third_party/cargo/vendor/rand-0.5.6/CONTRIBUTING.md b/third_party/cargo/vendor/rand-0.5.6/CONTRIBUTING.md new file mode 100644 index 0000000..37c1a9d --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/CONTRIBUTING.md @@ -0,0 +1,93 @@ +# Contributing to Rand + +Thank you for your interest in contributing to Rand! + +The following is a list of notes and tips for when you want to contribute to +Rand with a pull request. + +If you want to make major changes, it is usually best to open an issue to +discuss the idea first. + +Rand doesn't (yet) use rustfmt. It is best to follow the style of the +surrounding code, and try to keep an 80 character line limit. + + +## Documentation + +We especially welcome documentation PRs. + +As of Rust 1.25 there are differences in how stable and nightly render +documentation links. Make sure it works on stable, then nightly should be good +too. One Travis CI build checks for dead links using `cargo-deadlinks`. If you +want to run the check locally: +```sh +cargo install cargo-deadlinks +# It is recommended to remove left-over files from previous compilations +rm -rf /target/doc +cargo doc --no-deps +cargo deadlinks --dir target/doc +``` + +When making changes to code examples in the documentation, make sure they build +with: +```sh +cargo test --doc +``` + +A helpful command to rebuild documentation automatically on save (only works on +Linux): +``` +while inotifywait -r -e close_write src/ rand_core/; do cargo doc; done +``` + + +## Testing + +Rand already contains a number of unit tests, but could use more. Also the +existing ones could use clean-up. Any work on the tests is appreciated. + +Not every change or new bit of functionality requires tests, but if you can +think of a test that adds value, please add it. + +Depending on the code you change, test with one of: +```sh +cargo test +cargo test --package rand_core +# Test log, serde and 128-bit support +cargo test --features serde1,log,nightly +``` + +We want to be able to not only run the unit tests with `std` available, but also +without. Because `thread_rng()` and `FromEntropy` are not available without the +`std` feature, you may have to disable a new test with `#[cfg(feature="std")]`. +In other cases using `::test::rng` with a constant seed is a good option: +```rust +let mut rng = ::test::rng(528); // just pick some number +``` + +Only the unit tests should work in `no_std` mode, we don't want to complicate +the doc-tests. Run the tests with: +```sh +# Test no_std support +cargo test --lib --no-default-features +cargo test --package rand_core --no-default-features + +# Test no_std+alloc support; requires nightly +cargo test --lib --no-default-features --features alloc +``` + + +## Benchmarking + +A lot of code in Rand is performance-sensitive, most of it is expected to be +used in hot loops in some libraries/applications. If you change code in the +`rngs`, `prngs` or `distributions` modules, especially when you see an 'obvious +cleanup', make sure the benchmarks do not regress. It is nice to report the +benchmark results in the PR (or to report nothing's changed). + +```sh +# Benchmarks (requires nightly) +cargo bench +# Some benchmarks have a faster path with i128_support +cargo bench --features=nightly +``` diff --git a/third_party/cargo/vendor/rand-0.5.6/Cargo.toml b/third_party/cargo/vendor/rand-0.5.6/Cargo.toml new file mode 100644 index 0000000..32d6ef0 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/Cargo.toml @@ -0,0 +1,72 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand" +version = "0.5.6" +authors = ["The Rust Project Developers"] +description = "Random number generators and other randomness functionality.\n" +homepage = "https://crates.io/crates/rand" +documentation = "https://docs.rs/rand" +readme = "README.md" +keywords = ["random", "rng"] +categories = ["algorithms", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-lang-nursery/rand" +[package.metadata.docs.rs] +all-features = true +[dependencies.log] +version = "0.4" +optional = true + +[dependencies.rand_core] +version = "0.3" +default-features = false + +[dependencies.serde] +version = "1" +optional = true + +[dependencies.serde_derive] +version = "1" +optional = true +[dev-dependencies.bincode] +version = "1.0" + +[features] +alloc = ["rand_core/alloc"] +default = ["std"] +i128_support = [] +nightly = ["i128_support"] +serde1 = ["serde", "serde_derive", "rand_core/serde1"] +std = ["rand_core/std", "alloc", "libc", "winapi", "cloudabi", "fuchsia-cprng"] +[target."cfg(target_os = \"cloudabi\")".dependencies.cloudabi] +version = "0.0.3" +optional = true +[target."cfg(target_os = \"fuchsia\")".dependencies.fuchsia-cprng] +version = "0.1.0" +optional = true +[target."cfg(unix)".dependencies.libc] +version = "0.2" +optional = true +[target."cfg(windows)".dependencies.winapi] +version = "0.3" +features = ["minwindef", "ntsecapi", "profileapi", "winnt"] +optional = true +[target.wasm32-unknown-unknown.dependencies.stdweb] +version = "0.4" +optional = true +[badges.appveyor] +repository = "alexcrichton/rand" + +[badges.travis-ci] +repository = "rust-lang-nursery/rand" diff --git a/third_party/cargo/vendor/rand-0.5.6/LICENSE-APACHE b/third_party/cargo/vendor/rand-0.5.6/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand-0.5.6/LICENSE-MIT b/third_party/cargo/vendor/rand-0.5.6/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand-0.5.6/README.md b/third_party/cargo/vendor/rand-0.5.6/README.md new file mode 100644 index 0000000..75950ed --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/README.md @@ -0,0 +1,143 @@ +# Rand + +[![Build Status](https://travis-ci.org/rust-lang-nursery/rand.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-lang-nursery/rand?svg=true)](https://ci.appveyor.com/project/alexcrichton/rand) +[![Latest version](https://img.shields.io/crates/v/rand.svg)](https://crates.io/crates/rand) +[![Documentation](https://docs.rs/rand/badge.svg)](https://docs.rs/rand) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-yellow.svg)](https://github.com/rust-lang-nursery/rand#rust-version-requirements) + +A Rust library for random number generation. + +Rand provides utilities to generate random numbers, to convert them to useful +types and distributions, and some randomness-related algorithms. + +The core random number generation traits of Rand live in the [rand_core]( +https://crates.io/crates/rand_core) crate; this crate is most useful when +implementing RNGs. + +API reference: +[master branch](https://rust-lang-nursery.github.io/rand/rand/index.html), +[by release](https://docs.rs/rand/0.5). + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +rand = "0.5" +``` + +and this to your crate root: + +```rust +extern crate rand; + +use rand::prelude::*; + +fn main() { + // basic usage with random(): + let x: u8 = random(); + println!("{}", x); + + let y = random::(); + println!("{}", y); + + if random() { // generates a boolean + println!("Heads!"); + } + + // normal usage needs both an RNG and a function to generate the appropriate + // type, range, distribution, etc. + let mut rng = thread_rng(); + if rng.gen() { // random bool + let x: f64 = rng.gen(); // random number in range [0, 1) + println!("x is: {}", x); + let ch = rng.gen::(); // Sometimes you need type annotation + println!("char is: {}", ch); + println!("Number from 0 to 9: {}", rng.gen_range(0, 10)); + } +} +``` + +## Functionality + +The Rand crate provides: + +- A convenient to use default RNG, `thread_rng`: an automatically seeded, + crypto-grade generator stored in thread-local memory. +- Pseudo-random number generators: `StdRng`, `SmallRng`, `prng` module. +- Functionality for seeding PRNGs: the `FromEntropy` trait, and as sources of + external randomness `EntropyRng`, `OsRng` and `JitterRng`. +- Most content from [`rand_core`](https://crates.io/crates/rand_core) + (re-exported): base random number generator traits and error-reporting types. +- 'Distributions' producing many different types of random values: + - A `Standard` distribution for integers, floats, and derived types including + tuples, arrays and `Option` + - Unbiased sampling from specified `Uniform` ranges. + - Sampling from exponential/normal/gamma distributions. + - Sampling from binomial/poisson distributions. + - `gen_bool` aka Bernoulli distribution. +- `seq`-uence related functionality: + - Sampling a subset of elements. + - Randomly shuffling a list. + + +## Versions + +Version 0.5 is the latest version and contains many breaking changes. +See [the Upgrade Guide](UPDATING.md) for guidance on updating from previous +versions. + +Version 0.4 was released in December 2017. It contains almost no breaking +changes since the 0.3 series. + +For more details, see the [changelog](CHANGELOG.md). + +### Rust version requirements + +The 0.5 release of Rand requires **Rustc version 1.22 or greater**. +Rand 0.4 and 0.3 (since approx. June 2017) require Rustc version 1.15 or +greater. Subsets of the Rand code may work with older Rust versions, but this +is not supported. + +Travis CI always has a build with a pinned version of Rustc matching the oldest +supported Rust release. The current policy is that this can be updated in any +Rand release if required, but the change must be noted in the changelog. + + +## Crate Features + +Rand is built with only the `std` feature enabled by default. The following +optional features are available: + +- `alloc` can be used instead of `std` to provide `Vec` and `Box`. +- `i128_support` enables support for generating `u128` and `i128` values. +- `log` enables some logging via the `log` crate. +- `nightly` enables all unstable features (`i128_support`). +- `serde1` enables serialization for some types, via Serde version 1. +- `stdweb` enables support for `OsRng` on `wasm-unknown-unknown` via `stdweb` + combined with `cargo-web`. + +`no_std` mode is activated by setting `default-features = false`; this removes +functionality depending on `std`: + +- `thread_rng()`, and `random()` are not available, as they require thread-local + storage and an entropy source. +- `OsRng` and `EntropyRng` are unavailable. +- `JitterRng` code is still present, but a nanosecond timer must be provided via + `JitterRng::new_with_timer` +- Since no external entropy is available, it is not possible to create + generators with fresh seeds using the `FromEntropy` trait (user must provide + a seed). +- Exponential, normal and gamma type distributions are unavailable since `exp` + and `log` functions are not provided in `core`. +- The `seq`-uence module is unavailable, as it requires `Vec`. + + +# License + +Rand is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details. diff --git a/third_party/cargo/vendor/rand-0.5.6/UPDATING.md b/third_party/cargo/vendor/rand-0.5.6/UPDATING.md new file mode 100644 index 0000000..09321b7 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/UPDATING.md @@ -0,0 +1,260 @@ +# Update Guide + +This guide gives a few more details than the [changelog], in particular giving +guidance on how to use new features and migrate away from old ones. + +[changelog]: CHANGELOG.md + +## Rand 0.5 + +The 0.5 release has quite significant changes over the 0.4 release; as such, +it may be worth reading through the following coverage of breaking changes. +This release also contains many optimisations, which are not detailed below. + +### Crates + +We have a new crate: `rand_core`! This crate houses some important traits, +`RngCore`, `BlockRngCore`, `SeedableRng` and `CryptoRng`, the error types, as +well as two modules with helpers for implementations: `le` and `impls`. It is +recommended that implementations of generators use the `rand_core` crate while +other users use only the `rand` crate, which re-exports most parts of `rand_core`. + +The `rand_derive` crate has been deprecated due to very low usage and +deprecation of `Rand`. + +### Features + +Several new Cargo feature flags have been added: + +- `alloc`, used without `std`, allows use of `Box` and `Vec` +- `serde1` adds serialization support to some PRNGs +- `log` adds logging in a few places (primarily to `OsRng` and `JitterRng`) + +### `Rng` and friends (core traits) + +`Rng` trait has been split into two traits, a "back end" `RngCore` (implemented +by generators) and a "front end" `Rng` implementing all the convenient extension +methods. + +Implementations of generators must `impl RngCore` instead. Usage of `rand_core` +for implementations is encouraged; the `rand_core::{le, impls}` modules may +prove useful. + +Users of `Rng` *who don't need to implement it* won't need to make so many +changes; often users can forget about `RngCore` and only import `Rng`. Instead +of `RngCore::next_u32()` / `next_u64()` users should prefer `Rng::gen()`, and +instead of `RngCore::fill_bytes(dest)`, `Rng::fill(dest)` can be used. + +#### `Rng` / `RngCore` methods + +To allow error handling from fallible sources (e.g. `OsRng`), a new +`RngCore::try_fill_bytes` method has been added; for example `EntropyRng` uses +this mechanism to fall back to `JitterRng` if `OsRng` fails, and various +handlers produce better error messages. +As before, the other methods will panic on failure, but since these are usually +used with algorithmic generators which are usually infallible, this is +considered an appropriate compromise. + +A few methods from the old `Rng` have been removed or deprecated: + +- `next_f32` and `next_f64`; these are no longer implementable by generators; + use `gen` instead +- `gen_iter`; users may instead use standard iterators with closures: + `::std::iter::repeat(()).map(|()| rng.gen())` +- `gen_ascii_chars`; use `repeat` as above and `rng.sample(Alphanumeric)` +- `gen_weighted_bool(n)`; use `gen_bool(1.0 / n)` instead + +`Rng` has a few new methods: + +- `sample(distr)` is a shortcut for `distr.sample(rng)` for any `Distribution` +- `gen_bool(p)` generates a boolean with probability `p` of being true +- `fill` and `try_fill`, corresponding to `fill_bytes` and `try_fill_bytes` + respectively (i.e. the only difference is error handling); these can fill + and integer slice / array directly, and provide better performance + than `gen()` + +#### Constructing PRNGs + +##### New randomly-initialised PRNGs + +A new trait has been added: `FromEntropy`. This is automatically implemented for +any type supporting `SeedableRng`, and provides construction from fresh, strong +entropy: + +```rust +use rand::{ChaChaRng, FromEntropy}; + +let mut rng = ChaChaRng::from_entropy(); +``` + +##### Seeding PRNGs + +The `SeedableRng` trait has been modified to include the seed type via an +associated type (`SeedableRng::Seed`) instead of a template parameter +(`SeedableRng`). Additionally, all PRNGs now seed from a byte-array +(`[u8; N]` for some fixed N). This allows generic handling of PRNG seeding +which was not previously possible. + +PRNGs are no longer constructed from other PRNGs via `Rand` support / `gen()`, +but through `SeedableRng::from_rng`, which allows error handling and is +intentionally explicit. + +`SeedableRng::reseed` has been removed since it has no utility over `from_seed` +and its performance advantage is questionable. + +Implementations of `SeedableRng` may need to change their `Seed` type to a +byte-array; this restriction has been made to ensure portable handling of +Endianness. Helper functions are available in `rand_core::le` to read `u32` and +`u64` values from byte arrays. + +#### Block-based PRNGs + +rand_core has a new helper trait, `BlockRngCore`, and implementation, +`BlockRng`. These are for use by generators which generate a block of random +data at a time instead of word-sized values. Using this trait and implementation +has two advantages: optimised `RngCore` methods are provided, and the PRNG can +be used with `ReseedingRng` with very low overhead. + +#### Cryptographic RNGs + +A new trait has been added: `CryptoRng`. This is purely a marker trait to +indicate which generators should be suitable for cryptography, e.g. +`fn foo(rng: &mut R)`. *Suitability for cryptographic +use cannot be guaranteed.* + +### Error handling + +A new `Error` type has been added, designed explicitly for no-std compatibility, +simplicity, and enough flexibility for our uses (carrying a `cause` when +possible): +```rust +pub struct Error { + pub kind: ErrorKind, + pub msg: &'static str, + // some fields omitted +} +``` +The associated `ErrorKind` allows broad classification of errors into permanent, +unexpected, transient and not-yet-ready kinds. + +The following use the new error type: + +- `RngCore::try_fill_bytes` +- `Rng::try_fill` +- `OsRng::new` +- `JitterRng::new` + +### External generators + +We have a new generator, `EntropyRng`, which wraps `OsRng` and `JitterRng` +(preferring to use the former, but falling back to the latter if necessary). +This allows easy construction with fallback via `SeedableRng::from_rng`, +e.g. `IsaacRng::from_rng(EntropyRng::new())?`. This is equivalent to using +`FromEntropy` except for error handling. + +It is recommended to use `EntropyRng` over `OsRng` to avoid errors on platforms +with broken system generator, but it should be noted that the `JitterRng` +fallback is very slow. + +### PRNGs + +*Pseudo-Random Number Generators* (i.e. deterministic algorithmic generators) +have had a few changes since 0.4, and are now housed in the `prng` module +(old names remain temporarily available for compatibility; eventually these +generators will likely be housed outside the `rand` crate). + +All PRNGs now do not implement `Copy` to prevent accidental copying of the +generator's state (and thus repetitions of generated values). Explicit cloning +via `Clone` is still available. All PRNGs now have a custom implementation of +`Debug` which does not print any internal state; this helps avoid accidentally +leaking cryptographic generator state in log files. External PRNG +implementations are advised to follow this pattern (see also doc on `RngCore`). + +`SmallRng` has been added as a wrapper, currently around `XorShiftRng` (but +likely another algorithm soon). This is for uses where small state and fast +initialisation are important but cryptographic strength is not required. +(Actual performance of generation varies by benchmark; dependending on usage +this may or may not be the fastest algorithm, but will always be fast.) + +#### `ReseedingRng` + +The `ReseedingRng` wrapper has been signficantly altered to reduce overhead. +Unfortunately the new `ReseedingRng` is not compatible with all RNGs, but only +those using `BlockRngCore`. + +#### ISAAC PRNGs + +The `IsaacRng` and `Isaac64Rng` PRNGs now have an additional construction +method: `new_from_u64(seed)`. 64 bits of state is insufficient for cryptography +but may be of use in simulations and games. This will likely be superceeded by +a method to construct any PRNG from any hashable object in the future. + +#### HC-128 + +This is a new cryptographic generator, selected as one of the "stream ciphers +suitable for widespread adoption" by eSTREAM. This is now the default +cryptographic generator, used by `StdRng` and `thread_rng()`. + +### Helper functions/traits + +The `Rand` trait has been deprecated. Instead, users are encouraged to use +`Standard` which is a real distribution and supports the same sampling as +`Rand`. `Rng::gen()` now uses `Standard` and should work exactly as before. +See the documentation of the `distributions` module on how to implement +`Distribution` for `Standard` for user types `T` + +`weak_rng()` has been deprecated; use `SmallRng::from_entropy()` instead. + +### Distributions + +The `Sample` and `IndependentSample` traits have been replaced by a single +trait, `Distribution`. This is largely equivalent to `IndependentSample`, but +with `ind_sample` replaced by just `sample`. Support for mutable distributions +has been dropped; although it appears there may be a few genuine uses, these +are not used widely enough to justify the existance of two independent traits +or of having to provide mutable access to a distribution object. Both `Sample` +and `IndependentSample` are still available, but deprecated; they will be +removed in a future release. + +`Distribution::sample` (as well as several other functions) can now be called +directly on type-erased (unsized) RNGs. + +`RandSample` has been removed (see `Rand` deprecation and new `Standard` +distribution). + +The `Closed01` wrapper has been removed, but `OpenClosed01` has been added. + +#### Uniform distributions + +Two new distributions are available: + +- `Standard` produces uniformly-distributed samples for many different types, + and acts as a replacement for `Rand` +- `Alphanumeric` samples `char`s from the ranges `a-z A-Z 0-9` + +##### Ranges + +The `Range` distribution has been heavily adapted, and renamed to `Uniform`: + +- `Uniform::new(low, high)` remains (half open `[low, high)`) +- `Uniform::new_inclusive(low, high)` has been added, including `high` in the sample range +- `Uniform::sample_single(low, high, rng)` is a faster variant for single usage sampling from `[low, high)` + +`Uniform` can now be implemented for user-defined types; see the `uniform` module. + +#### Non-uniform distributions + +Two distributions have been added: + +- Poisson, modelling the number of events expected from a constant-rate + source within a fixed time interval (e.g. nuclear decay) +- Binomial, modelling the outcome of a fixed number of yes-no trials + +The sampling methods are based on those in "Numerical Recipes in C". + +##### Exponential and Normal distributions + +The main `Exp` and `Normal` distributions are unchanged, however the +"standard" versions, `Exp1` and `StandardNormal` are no longer wrapper types, +but full distributions. Instead of writing `let Exp1(x) = rng.gen();` you now +write `let x = rng.sample(Exp1);`. diff --git a/third_party/cargo/vendor/rand-0.5.6/appveyor.yml b/third_party/cargo/vendor/rand-0.5.6/appveyor.yml new file mode 100644 index 0000000..97d3ce6 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/appveyor.yml @@ -0,0 +1,39 @@ +environment: + + # At the time this was added AppVeyor was having troubles with checking + # revocation of SSL certificates of sites like static.rust-lang.org and what + # we think is crates.io. The libcurl HTTP client by default checks for + # revocation on Windows and according to a mailing list [1] this can be + # disabled. + # + # The `CARGO_HTTP_CHECK_REVOKE` env var here tells cargo to disable SSL + # revocation checking on Windows in libcurl. Note, though, that rustup, which + # we're using to download Rust here, also uses libcurl as the default backend. + # Unlike Cargo, however, rustup doesn't have a mechanism to disable revocation + # checking. To get rustup working we set `RUSTUP_USE_HYPER` which forces it to + # use the Hyper instead of libcurl backend. Both Hyper and libcurl use + # schannel on Windows but it appears that Hyper configures it slightly + # differently such that revocation checking isn't turned on by default. + # + # [1]: https://curl.haxx.se/mail/lib-2016-03/0202.html + RUSTUP_USE_HYPER: 1 + CARGO_HTTP_CHECK_REVOKE: false + + matrix: + - TARGET: x86_64-pc-windows-msvc + - TARGET: i686-pc-windows-msvc +install: + - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe + - rustup-init.exe -y --default-host %TARGET% --default-toolchain nightly + - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin + - rustc -V + - cargo -V + +build: false + +test_script: + - cargo test --all # cannot use --all and --features together + - cargo test --all --benches + - cargo test --features serde1,log,nightly + - cargo test --tests --no-default-features --features=alloc,serde1 + - cargo test --package rand_core --no-default-features --features=alloc,serde1 diff --git a/third_party/cargo/vendor/rand-0.5.6/benches/distributions.rs b/third_party/cargo/vendor/rand-0.5.6/benches/distributions.rs new file mode 100644 index 0000000..fd6b5ae --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/benches/distributions.rs @@ -0,0 +1,161 @@ +#![feature(test)] +#![cfg_attr(all(feature="i128_support", feature="nightly"), allow(stable_features))] // stable since 2018-03-27 +#![cfg_attr(all(feature="i128_support", feature="nightly"), feature(i128_type, i128))] + +extern crate test; +extern crate rand; + +const RAND_BENCH_N: u64 = 1000; + +use std::mem::size_of; +use test::Bencher; + +use rand::{Rng, FromEntropy, XorShiftRng}; +use rand::distributions::*; + +macro_rules! distr_int { + ($fnn:ident, $ty:ty, $distr:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = XorShiftRng::from_entropy(); + let distr = $distr; + + b.iter(|| { + let mut accum = 0 as $ty; + for _ in 0..::RAND_BENCH_N { + let x: $ty = distr.sample(&mut rng); + accum = accum.wrapping_add(x); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N; + } + } +} + +macro_rules! distr_float { + ($fnn:ident, $ty:ty, $distr:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = XorShiftRng::from_entropy(); + let distr = $distr; + + b.iter(|| { + let mut accum = 0.0; + for _ in 0..::RAND_BENCH_N { + let x: $ty = distr.sample(&mut rng); + accum += x; + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N; + } + } +} + +macro_rules! distr { + ($fnn:ident, $ty:ty, $distr:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = XorShiftRng::from_entropy(); + let distr = $distr; + + b.iter(|| { + let mut accum = 0u32; + for _ in 0..::RAND_BENCH_N { + let x: $ty = distr.sample(&mut rng); + accum = accum.wrapping_add(x as u32); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N; + } + } +} + +// uniform +distr_int!(distr_uniform_i8, i8, Uniform::new(20i8, 100)); +distr_int!(distr_uniform_i16, i16, Uniform::new(-500i16, 2000)); +distr_int!(distr_uniform_i32, i32, Uniform::new(-200_000_000i32, 800_000_000)); +distr_int!(distr_uniform_i64, i64, Uniform::new(3i64, 123_456_789_123)); +#[cfg(feature = "i128_support")] +distr_int!(distr_uniform_i128, i128, Uniform::new(-123_456_789_123i128, 123_456_789_123_456_789)); + +distr_float!(distr_uniform_f32, f32, Uniform::new(2.26f32, 2.319)); +distr_float!(distr_uniform_f64, f64, Uniform::new(2.26f64, 2.319)); + +// standard +distr_int!(distr_standard_i8, i8, Standard); +distr_int!(distr_standard_i16, i16, Standard); +distr_int!(distr_standard_i32, i32, Standard); +distr_int!(distr_standard_i64, i64, Standard); +#[cfg(feature = "i128_support")] +distr_int!(distr_standard_i128, i128, Standard); + +distr!(distr_standard_bool, bool, Standard); +distr!(distr_standard_alphanumeric, char, Alphanumeric); +distr!(distr_standard_codepoint, char, Standard); + +distr_float!(distr_standard_f32, f32, Standard); +distr_float!(distr_standard_f64, f64, Standard); +distr_float!(distr_open01_f32, f32, Open01); +distr_float!(distr_open01_f64, f64, Open01); +distr_float!(distr_openclosed01_f32, f32, OpenClosed01); +distr_float!(distr_openclosed01_f64, f64, OpenClosed01); + +// distributions +distr_float!(distr_exp, f64, Exp::new(1.23 * 4.56)); +distr_float!(distr_normal, f64, Normal::new(-1.23, 4.56)); +distr_float!(distr_log_normal, f64, LogNormal::new(-1.23, 4.56)); +distr_float!(distr_gamma_large_shape, f64, Gamma::new(10., 1.0)); +distr_float!(distr_gamma_small_shape, f64, Gamma::new(0.1, 1.0)); +distr_float!(distr_cauchy, f64, Cauchy::new(4.2, 6.9)); +distr_int!(distr_binomial, u64, Binomial::new(20, 0.7)); +distr_int!(distr_poisson, u64, Poisson::new(4.0)); +distr!(distr_bernoulli, bool, Bernoulli::new(0.18)); + + +// construct and sample from a range +macro_rules! gen_range_int { + ($fnn:ident, $ty:ident, $low:expr, $high:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = XorShiftRng::from_entropy(); + + b.iter(|| { + let mut high = $high; + let mut accum: $ty = 0; + for _ in 0..::RAND_BENCH_N { + accum = accum.wrapping_add(rng.gen_range($low, high)); + // force recalculation of range each time + high = high.wrapping_add(1) & std::$ty::MAX; + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N; + } + } +} + +gen_range_int!(gen_range_i8, i8, -20i8, 100); +gen_range_int!(gen_range_i16, i16, -500i16, 2000); +gen_range_int!(gen_range_i32, i32, -200_000_000i32, 800_000_000); +gen_range_int!(gen_range_i64, i64, 3i64, 123_456_789_123); +#[cfg(feature = "i128_support")] +gen_range_int!(gen_range_i128, i128, -12345678901234i128, 123_456_789_123_456_789); + +#[bench] +fn dist_iter(b: &mut Bencher) { + let mut rng = XorShiftRng::from_entropy(); + let distr = Normal::new(-2.71828, 3.14159); + let mut iter = distr.sample_iter(&mut rng); + + b.iter(|| { + let mut accum = 0.0; + for _ in 0..::RAND_BENCH_N { + accum += iter.next().unwrap(); + } + accum + }); + b.bytes = size_of::() as u64 * ::RAND_BENCH_N; +} diff --git a/third_party/cargo/vendor/rand-0.5.6/benches/generators.rs b/third_party/cargo/vendor/rand-0.5.6/benches/generators.rs new file mode 100644 index 0000000..402a87b --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/benches/generators.rs @@ -0,0 +1,176 @@ +#![feature(test)] + +extern crate test; +extern crate rand; + +const RAND_BENCH_N: u64 = 1000; +const BYTES_LEN: usize = 1024; + +use std::mem::size_of; +use test::{black_box, Bencher}; + +use rand::prelude::*; +use rand::prng::{XorShiftRng, Hc128Rng, IsaacRng, Isaac64Rng, ChaChaRng}; +use rand::prng::hc128::Hc128Core; +use rand::rngs::adapter::ReseedingRng; +use rand::rngs::{OsRng, JitterRng, EntropyRng}; + +macro_rules! gen_bytes { + ($fnn:ident, $gen:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = $gen; + let mut buf = [0u8; BYTES_LEN]; + b.iter(|| { + for _ in 0..RAND_BENCH_N { + rng.fill_bytes(&mut buf); + black_box(buf); + } + }); + b.bytes = BYTES_LEN as u64 * RAND_BENCH_N; + } + } +} + +gen_bytes!(gen_bytes_xorshift, XorShiftRng::from_entropy()); +gen_bytes!(gen_bytes_chacha20, ChaChaRng::from_entropy()); +gen_bytes!(gen_bytes_hc128, Hc128Rng::from_entropy()); +gen_bytes!(gen_bytes_isaac, IsaacRng::from_entropy()); +gen_bytes!(gen_bytes_isaac64, Isaac64Rng::from_entropy()); +gen_bytes!(gen_bytes_std, StdRng::from_entropy()); +gen_bytes!(gen_bytes_small, SmallRng::from_entropy()); +gen_bytes!(gen_bytes_os, OsRng::new().unwrap()); + +macro_rules! gen_uint { + ($fnn:ident, $ty:ty, $gen:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = $gen; + b.iter(|| { + let mut accum: $ty = 0; + for _ in 0..RAND_BENCH_N { + accum = accum.wrapping_add(rng.gen::<$ty>()); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N; + } + } +} + +gen_uint!(gen_u32_xorshift, u32, XorShiftRng::from_entropy()); +gen_uint!(gen_u32_chacha20, u32, ChaChaRng::from_entropy()); +gen_uint!(gen_u32_hc128, u32, Hc128Rng::from_entropy()); +gen_uint!(gen_u32_isaac, u32, IsaacRng::from_entropy()); +gen_uint!(gen_u32_isaac64, u32, Isaac64Rng::from_entropy()); +gen_uint!(gen_u32_std, u32, StdRng::from_entropy()); +gen_uint!(gen_u32_small, u32, SmallRng::from_entropy()); +gen_uint!(gen_u32_os, u32, OsRng::new().unwrap()); + +gen_uint!(gen_u64_xorshift, u64, XorShiftRng::from_entropy()); +gen_uint!(gen_u64_chacha20, u64, ChaChaRng::from_entropy()); +gen_uint!(gen_u64_hc128, u64, Hc128Rng::from_entropy()); +gen_uint!(gen_u64_isaac, u64, IsaacRng::from_entropy()); +gen_uint!(gen_u64_isaac64, u64, Isaac64Rng::from_entropy()); +gen_uint!(gen_u64_std, u64, StdRng::from_entropy()); +gen_uint!(gen_u64_small, u64, SmallRng::from_entropy()); +gen_uint!(gen_u64_os, u64, OsRng::new().unwrap()); + +// Do not test JitterRng like the others by running it RAND_BENCH_N times per, +// measurement, because it is way too slow. Only run it once. +#[bench] +fn gen_u64_jitter(b: &mut Bencher) { + let mut rng = JitterRng::new().unwrap(); + b.iter(|| { + rng.gen::() + }); + b.bytes = size_of::() as u64; +} + +macro_rules! init_gen { + ($fnn:ident, $gen:ident) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = XorShiftRng::from_entropy(); + b.iter(|| { + let r2 = $gen::from_rng(&mut rng).unwrap(); + r2 + }); + } + } +} + +init_gen!(init_xorshift, XorShiftRng); +init_gen!(init_hc128, Hc128Rng); +init_gen!(init_isaac, IsaacRng); +init_gen!(init_isaac64, Isaac64Rng); +init_gen!(init_chacha, ChaChaRng); + +#[bench] +fn init_jitter(b: &mut Bencher) { + b.iter(|| { + JitterRng::new().unwrap() + }); +} + + +const RESEEDING_THRESHOLD: u64 = 1024*1024*1024; // something high enough to get + // deterministic measurements + +#[bench] +fn reseeding_hc128_bytes(b: &mut Bencher) { + let mut rng = ReseedingRng::new(Hc128Core::from_entropy(), + RESEEDING_THRESHOLD, + EntropyRng::new()); + let mut buf = [0u8; BYTES_LEN]; + b.iter(|| { + for _ in 0..RAND_BENCH_N { + rng.fill_bytes(&mut buf); + black_box(buf); + } + }); + b.bytes = BYTES_LEN as u64 * RAND_BENCH_N; +} + +macro_rules! reseeding_uint { + ($fnn:ident, $ty:ty) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = ReseedingRng::new(Hc128Core::from_entropy(), + RESEEDING_THRESHOLD, + EntropyRng::new()); + b.iter(|| { + let mut accum: $ty = 0; + for _ in 0..RAND_BENCH_N { + accum = accum.wrapping_add(rng.gen::<$ty>()); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N; + } + } +} + +reseeding_uint!(reseeding_hc128_u32, u32); +reseeding_uint!(reseeding_hc128_u64, u64); + + +macro_rules! threadrng_uint { + ($fnn:ident, $ty:ty) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = thread_rng(); + b.iter(|| { + let mut accum: $ty = 0; + for _ in 0..RAND_BENCH_N { + accum = accum.wrapping_add(rng.gen::<$ty>()); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N; + } + } +} + +threadrng_uint!(thread_rng_u32, u32); +threadrng_uint!(thread_rng_u64, u64); diff --git a/third_party/cargo/vendor/rand-0.5.6/benches/misc.rs b/third_party/cargo/vendor/rand-0.5.6/benches/misc.rs new file mode 100644 index 0000000..a1822a5 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/benches/misc.rs @@ -0,0 +1,194 @@ +#![feature(test)] + +extern crate test; +extern crate rand; + +const RAND_BENCH_N: u64 = 1000; + +use test::Bencher; + +use rand::prelude::*; +use rand::seq::*; + +#[bench] +fn misc_gen_bool_const(b: &mut Bencher) { + let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let mut accum = true; + for _ in 0..::RAND_BENCH_N { + accum ^= rng.gen_bool(0.18); + } + accum + }) +} + +#[bench] +fn misc_gen_bool_var(b: &mut Bencher) { + let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let mut accum = true; + let mut p = 0.18; + for _ in 0..::RAND_BENCH_N { + accum ^= rng.gen_bool(p); + p += 0.0001; + } + accum + }) +} + +#[bench] +fn misc_bernoulli_const(b: &mut Bencher) { + let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap(); + let d = rand::distributions::Bernoulli::new(0.18); + b.iter(|| { + // Can be evaluated at compile time. + let mut accum = true; + for _ in 0..::RAND_BENCH_N { + accum ^= rng.sample(d); + } + accum + }) +} + +#[bench] +fn misc_bernoulli_var(b: &mut Bencher) { + let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let mut accum = true; + let mut p = 0.18; + for _ in 0..::RAND_BENCH_N { + let d = rand::distributions::Bernoulli::new(p); + accum ^= rng.sample(d); + p += 0.0001; + } + accum + }) +} + +macro_rules! sample_binomial { + ($name:ident, $n:expr, $p:expr) => { + #[bench] + fn $name(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + let (n, p) = ($n, $p); + b.iter(|| { + let d = rand::distributions::Binomial::new(n, p); + rng.sample(d) + }) + } + } +} + +sample_binomial!(misc_binomial_1, 1, 0.9); +sample_binomial!(misc_binomial_10, 10, 0.9); +sample_binomial!(misc_binomial_100, 100, 0.99); +sample_binomial!(misc_binomial_1000, 1000, 0.01); +sample_binomial!(misc_binomial_1e12, 1000_000_000_000, 0.2); + +#[bench] +fn misc_shuffle_100(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &mut [usize] = &mut [1; 100]; + b.iter(|| { + rng.shuffle(x); + x[0] + }) +} + +#[bench] +fn misc_sample_iter_10_of_100(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &[usize] = &[1; 100]; + b.iter(|| { + sample_iter(&mut rng, x, 10).unwrap_or_else(|e| e) + }) +} + +#[bench] +fn misc_sample_slice_10_of_100(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &[usize] = &[1; 100]; + b.iter(|| { + sample_slice(&mut rng, x, 10) + }) +} + +#[bench] +fn misc_sample_slice_ref_10_of_100(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &[usize] = &[1; 100]; + b.iter(|| { + sample_slice_ref(&mut rng, x, 10) + }) +} + +macro_rules! sample_indices { + ($name:ident, $amount:expr, $length:expr) => { + #[bench] + fn $name(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + b.iter(|| { + sample_indices(&mut rng, $length, $amount) + }) + } + } +} + +sample_indices!(misc_sample_indices_10_of_1k, 10, 1000); +sample_indices!(misc_sample_indices_50_of_1k, 50, 1000); +sample_indices!(misc_sample_indices_100_of_1k, 100, 1000); + +#[bench] +fn gen_1k_iter_repeat(b: &mut Bencher) { + use std::iter; + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let v: Vec = iter::repeat(()).map(|()| rng.gen()).take(128).collect(); + v + }); + b.bytes = 1024; +} + +#[bench] +#[allow(deprecated)] +fn gen_1k_gen_iter(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let v: Vec = rng.gen_iter().take(128).collect(); + v + }); + b.bytes = 1024; +} + +#[bench] +fn gen_1k_sample_iter(b: &mut Bencher) { + use rand::distributions::{Distribution, Standard}; + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let v: Vec = Standard.sample_iter(&mut rng).take(128).collect(); + v + }); + b.bytes = 1024; +} + +#[bench] +fn gen_1k_gen_array(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + // max supported array length is 32! + let v: [[u64; 32]; 4] = rng.gen(); + v + }); + b.bytes = 1024; +} + +#[bench] +fn gen_1k_fill(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + let mut buf = [0u64; 128]; + b.iter(|| { + rng.fill(&mut buf[..]); + buf + }); + b.bytes = 1024; +} diff --git a/third_party/cargo/vendor/rand-0.5.6/examples/monte-carlo.rs b/third_party/cargo/vendor/rand-0.5.6/examples/monte-carlo.rs new file mode 100644 index 0000000..c18108a --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/examples/monte-carlo.rs @@ -0,0 +1,52 @@ +// Copyright 2013-2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! # Monte Carlo estimation of π +//! +//! Imagine that we have a square with sides of length 2 and a unit circle +//! (radius = 1), both centered at the origin. The areas are: +//! +//! ```text +//! area of circle = πr² = π * r * r = π +//! area of square = 2² = 4 +//! ``` +//! +//! The circle is entirely within the square, so if we sample many points +//! randomly from the square, roughly π / 4 of them should be inside the circle. +//! +//! We can use the above fact to estimate the value of π: pick many points in +//! the square at random, calculate the fraction that fall within the circle, +//! and multiply this fraction by 4. + +#![cfg(feature="std")] + + +extern crate rand; + +use rand::distributions::{Distribution, Uniform}; + +fn main() { + let range = Uniform::new(-1.0f64, 1.0); + let mut rng = rand::thread_rng(); + + let total = 1_000_000; + let mut in_circle = 0; + + for _ in 0..total { + let a = range.sample(&mut rng); + let b = range.sample(&mut rng); + if a*a + b*b <= 1.0 { + in_circle += 1; + } + } + + // prints something close to 3.14159... + println!("π is approximately {}", 4. * (in_circle as f64) / (total as f64)); +} diff --git a/third_party/cargo/vendor/rand-0.5.6/examples/monty-hall.rs b/third_party/cargo/vendor/rand-0.5.6/examples/monty-hall.rs new file mode 100644 index 0000000..3750f8f --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/examples/monty-hall.rs @@ -0,0 +1,117 @@ +// Copyright 2013-2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! ## Monty Hall Problem +//! +//! This is a simulation of the [Monty Hall Problem][]: +//! +//! > Suppose you're on a game show, and you're given the choice of three doors: +//! > Behind one door is a car; behind the others, goats. You pick a door, say +//! > No. 1, and the host, who knows what's behind the doors, opens another +//! > door, say No. 3, which has a goat. He then says to you, "Do you want to +//! > pick door No. 2?" Is it to your advantage to switch your choice? +//! +//! The rather unintuitive answer is that you will have a 2/3 chance of winning +//! if you switch and a 1/3 chance of winning if you don't, so it's better to +//! switch. +//! +//! This program will simulate the game show and with large enough simulation +//! steps it will indeed confirm that it is better to switch. +//! +//! [Monty Hall Problem]: https://en.wikipedia.org/wiki/Monty_Hall_problem + +#![cfg(feature="std")] + + +extern crate rand; + +use rand::Rng; +use rand::distributions::{Distribution, Uniform}; + +struct SimulationResult { + win: bool, + switch: bool, +} + +// Run a single simulation of the Monty Hall problem. +fn simulate(random_door: &Uniform, rng: &mut R) + -> SimulationResult { + let car = random_door.sample(rng); + + // This is our initial choice + let mut choice = random_door.sample(rng); + + // The game host opens a door + let open = game_host_open(car, choice, rng); + + // Shall we switch? + let switch = rng.gen(); + if switch { + choice = switch_door(choice, open); + } + + SimulationResult { win: choice == car, switch } +} + +// Returns the door the game host opens given our choice and knowledge of +// where the car is. The game host will never open the door with the car. +fn game_host_open(car: u32, choice: u32, rng: &mut R) -> u32 { + let choices = free_doors(&[car, choice]); + rand::seq::sample_slice(rng, &choices, 1)[0] +} + +// Returns the door we switch to, given our current choice and +// the open door. There will only be one valid door. +fn switch_door(choice: u32, open: u32) -> u32 { + free_doors(&[choice, open])[0] +} + +fn free_doors(blocked: &[u32]) -> Vec { + (0..3).filter(|x| !blocked.contains(x)).collect() +} + +fn main() { + // The estimation will be more accurate with more simulations + let num_simulations = 10000; + + let mut rng = rand::thread_rng(); + let random_door = Uniform::new(0u32, 3); + + let (mut switch_wins, mut switch_losses) = (0, 0); + let (mut keep_wins, mut keep_losses) = (0, 0); + + println!("Running {} simulations...", num_simulations); + for _ in 0..num_simulations { + let result = simulate(&random_door, &mut rng); + + match (result.win, result.switch) { + (true, true) => switch_wins += 1, + (true, false) => keep_wins += 1, + (false, true) => switch_losses += 1, + (false, false) => keep_losses += 1, + } + } + + let total_switches = switch_wins + switch_losses; + let total_keeps = keep_wins + keep_losses; + + println!("Switched door {} times with {} wins and {} losses", + total_switches, switch_wins, switch_losses); + + println!("Kept our choice {} times with {} wins and {} losses", + total_keeps, keep_wins, keep_losses); + + // With a large number of simulations, the values should converge to + // 0.667 and 0.333 respectively. + println!("Estimated chance to win if we switch: {}", + switch_wins as f32 / total_switches as f32); + println!("Estimated chance to win if we don't: {}", + keep_wins as f32 / total_keeps as f32); +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/bernoulli.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/bernoulli.rs new file mode 100644 index 0000000..2361fac --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/bernoulli.rs @@ -0,0 +1,120 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +//! The Bernoulli distribution. + +use Rng; +use distributions::Distribution; + +/// The Bernoulli distribution. +/// +/// This is a special case of the Binomial distribution where `n = 1`. +/// +/// # Example +/// +/// ```rust +/// use rand::distributions::{Bernoulli, Distribution}; +/// +/// let d = Bernoulli::new(0.3); +/// let v = d.sample(&mut rand::thread_rng()); +/// println!("{} is from a Bernoulli distribution", v); +/// ``` +/// +/// # Precision +/// +/// This `Bernoulli` distribution uses 64 bits from the RNG (a `u64`), +/// so only probabilities that are multiples of 2-64 can be +/// represented. +#[derive(Clone, Copy, Debug)] +pub struct Bernoulli { + /// Probability of success, relative to the maximal integer. + p_int: u64, +} + +impl Bernoulli { + /// Construct a new `Bernoulli` with the given probability of success `p`. + /// + /// # Panics + /// + /// If `p < 0` or `p > 1`. + /// + /// # Precision + /// + /// For `p = 1.0`, the resulting distribution will always generate true. + /// For `p = 0.0`, the resulting distribution will always generate false. + /// + /// This method is accurate for any input `p` in the range `[0, 1]` which is + /// a multiple of 2-64. (Note that not all multiples of + /// 2-64 in `[0, 1]` can be represented as a `f64`.) + #[inline] + pub fn new(p: f64) -> Bernoulli { + assert!((p >= 0.0) & (p <= 1.0), "Bernoulli::new not called with 0 <= p <= 0"); + // Technically, this should be 2^64 or `u64::MAX + 1` because we compare + // using `<` when sampling. However, `u64::MAX` rounds to an `f64` + // larger than `u64::MAX` anyway. + const MAX_P_INT: f64 = ::core::u64::MAX as f64; + let p_int = if p < 1.0 { + (p * MAX_P_INT) as u64 + } else { + // Avoid overflow: `MAX_P_INT` cannot be represented as u64. + ::core::u64::MAX + }; + Bernoulli { p_int } + } +} + +impl Distribution for Bernoulli { + #[inline] + fn sample(&self, rng: &mut R) -> bool { + // Make sure to always return true for p = 1.0. + if self.p_int == ::core::u64::MAX { + return true; + } + let r: u64 = rng.gen(); + r < self.p_int + } +} + +#[cfg(test)] +mod test { + use Rng; + use distributions::Distribution; + use super::Bernoulli; + + #[test] + fn test_trivial() { + let mut r = ::test::rng(1); + let always_false = Bernoulli::new(0.0); + let always_true = Bernoulli::new(1.0); + for _ in 0..5 { + assert_eq!(r.sample::(&always_false), false); + assert_eq!(r.sample::(&always_true), true); + assert_eq!(Distribution::::sample(&always_false, &mut r), false); + assert_eq!(Distribution::::sample(&always_true, &mut r), true); + } + } + + #[test] + fn test_average() { + const P: f64 = 0.3; + let d = Bernoulli::new(P); + const N: u32 = 10_000_000; + + let mut sum: u32 = 0; + let mut rng = ::test::rng(2); + for _ in 0..N { + if d.sample(&mut rng) { + sum += 1; + } + } + let avg = (sum as f64) / (N as f64); + + assert!((avg - P).abs() < 1e-3); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/binomial.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/binomial.rs new file mode 100644 index 0000000..5eb03e3 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/binomial.rs @@ -0,0 +1,178 @@ +// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The binomial distribution. + +use Rng; +use distributions::{Distribution, Bernoulli, Cauchy}; +use distributions::log_gamma::log_gamma; + +/// The binomial distribution `Binomial(n, p)`. +/// +/// This distribution has density function: +/// `f(k) = n!/(k! (n-k)!) p^k (1-p)^(n-k)` for `k >= 0`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Binomial, Distribution}; +/// +/// let bin = Binomial::new(20, 0.3); +/// let v = bin.sample(&mut rand::thread_rng()); +/// println!("{} is from a binomial distribution", v); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Binomial { + /// Number of trials. + n: u64, + /// Probability of success. + p: f64, +} + +impl Binomial { + /// Construct a new `Binomial` with the given shape parameters `n` (number + /// of trials) and `p` (probability of success). + /// + /// Panics if `p < 0` or `p > 1`. + pub fn new(n: u64, p: f64) -> Binomial { + assert!(p >= 0.0, "Binomial::new called with p < 0"); + assert!(p <= 1.0, "Binomial::new called with p > 1"); + Binomial { n, p } + } +} + +impl Distribution for Binomial { + fn sample(&self, rng: &mut R) -> u64 { + // Handle these values directly. + if self.p == 0.0 { + return 0; + } else if self.p == 1.0 { + return self.n; + } + + // For low n, it is faster to sample directly. For both methods, + // performance is independent of p. On Intel Haswell CPU this method + // appears to be faster for approx n < 300. + if self.n < 300 { + let mut result = 0; + let d = Bernoulli::new(self.p); + for _ in 0 .. self.n { + result += rng.sample(d) as u32; + } + return result as u64; + } + + // binomial distribution is symmetrical with respect to p -> 1-p, k -> n-k + // switch p so that it is less than 0.5 - this allows for lower expected values + // we will just invert the result at the end + let p = if self.p <= 0.5 { + self.p + } else { + 1.0 - self.p + }; + + // prepare some cached values + let float_n = self.n as f64; + let ln_fact_n = log_gamma(float_n + 1.0); + let pc = 1.0 - p; + let log_p = p.ln(); + let log_pc = pc.ln(); + let expected = self.n as f64 * p; + let sq = (expected * (2.0 * pc)).sqrt(); + + let mut lresult; + + // we use the Cauchy distribution as the comparison distribution + // f(x) ~ 1/(1+x^2) + let cauchy = Cauchy::new(0.0, 1.0); + loop { + let mut comp_dev: f64; + loop { + // draw from the Cauchy distribution + comp_dev = rng.sample(cauchy); + // shift the peak of the comparison ditribution + lresult = expected + sq * comp_dev; + // repeat the drawing until we are in the range of possible values + if lresult >= 0.0 && lresult < float_n + 1.0 { + break; + } + } + + // the result should be discrete + lresult = lresult.floor(); + + let log_binomial_dist = ln_fact_n - log_gamma(lresult+1.0) - + log_gamma(float_n - lresult + 1.0) + lresult*log_p + (float_n - lresult)*log_pc; + // this is the binomial probability divided by the comparison probability + // we will generate a uniform random value and if it is larger than this, + // we interpret it as a value falling out of the distribution and repeat + let comparison_coeff = (log_binomial_dist.exp() * sq) * (1.2 * (1.0 + comp_dev*comp_dev)); + + if comparison_coeff >= rng.gen() { + break; + } + } + + // invert the result for p < 0.5 + if p != self.p { + self.n - lresult as u64 + } else { + lresult as u64 + } + } +} + +#[cfg(test)] +mod test { + use Rng; + use distributions::Distribution; + use super::Binomial; + + fn test_binomial_mean_and_variance(n: u64, p: f64, rng: &mut R) { + let binomial = Binomial::new(n, p); + + let expected_mean = n as f64 * p; + let expected_variance = n as f64 * p * (1.0 - p); + + let mut results = [0.0; 1000]; + for i in results.iter_mut() { *i = binomial.sample(rng) as f64; } + + let mean = results.iter().sum::() / results.len() as f64; + assert!((mean as f64 - expected_mean).abs() < expected_mean / 50.0); + + let variance = + results.iter().map(|x| (x - mean) * (x - mean)).sum::() + / results.len() as f64; + assert!((variance - expected_variance).abs() < expected_variance / 10.0); + } + + #[test] + fn test_binomial() { + let mut rng = ::test::rng(351); + test_binomial_mean_and_variance(150, 0.1, &mut rng); + test_binomial_mean_and_variance(70, 0.6, &mut rng); + test_binomial_mean_and_variance(40, 0.5, &mut rng); + test_binomial_mean_and_variance(20, 0.7, &mut rng); + test_binomial_mean_and_variance(20, 0.5, &mut rng); + } + + #[test] + fn test_binomial_end_points() { + let mut rng = ::test::rng(352); + assert_eq!(rng.sample(Binomial::new(20, 0.0)), 0); + assert_eq!(rng.sample(Binomial::new(20, 1.0)), 20); + } + + #[test] + #[should_panic] + fn test_binomial_invalid_lambda_neg() { + Binomial::new(20, -10.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/cauchy.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/cauchy.rs new file mode 100644 index 0000000..5ac55bd --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/cauchy.rs @@ -0,0 +1,116 @@ +// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Cauchy distribution. + +use Rng; +use distributions::Distribution; +use std::f64::consts::PI; + +/// The Cauchy distribution `Cauchy(median, scale)`. +/// +/// This distribution has a density function: +/// `f(x) = 1 / (pi * scale * (1 + ((x - median) / scale)^2))` +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Cauchy, Distribution}; +/// +/// let cau = Cauchy::new(2.0, 5.0); +/// let v = cau.sample(&mut rand::thread_rng()); +/// println!("{} is from a Cauchy(2, 5) distribution", v); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Cauchy { + median: f64, + scale: f64 +} + +impl Cauchy { + /// Construct a new `Cauchy` with the given shape parameters + /// `median` the peak location and `scale` the scale factor. + /// Panics if `scale <= 0`. + pub fn new(median: f64, scale: f64) -> Cauchy { + assert!(scale > 0.0, "Cauchy::new called with scale factor <= 0"); + Cauchy { + median, + scale + } + } +} + +impl Distribution for Cauchy { + fn sample(&self, rng: &mut R) -> f64 { + // sample from [0, 1) + let x = rng.gen::(); + // get standard cauchy random number + // note that π/2 is not exactly representable, even if x=0.5 the result is finite + let comp_dev = (PI * x).tan(); + // shift and scale according to parameters + let result = self.median + self.scale * comp_dev; + result + } +} + +#[cfg(test)] +mod test { + use distributions::Distribution; + use super::Cauchy; + + fn median(mut numbers: &mut [f64]) -> f64 { + sort(&mut numbers); + let mid = numbers.len() / 2; + numbers[mid] + } + + fn sort(numbers: &mut [f64]) { + numbers.sort_by(|a, b| a.partial_cmp(b).unwrap()); + } + + #[test] + fn test_cauchy_median() { + let cauchy = Cauchy::new(10.0, 5.0); + let mut rng = ::test::rng(123); + let mut numbers: [f64; 1000] = [0.0; 1000]; + for i in 0..1000 { + numbers[i] = cauchy.sample(&mut rng); + } + let median = median(&mut numbers); + println!("Cauchy median: {}", median); + assert!((median - 10.0).abs() < 0.5); // not 100% certain, but probable enough + } + + #[test] + fn test_cauchy_mean() { + let cauchy = Cauchy::new(10.0, 5.0); + let mut rng = ::test::rng(123); + let mut sum = 0.0; + for _ in 0..1000 { + sum += cauchy.sample(&mut rng); + } + let mean = sum / 1000.0; + println!("Cauchy mean: {}", mean); + // for a Cauchy distribution the mean should not converge + assert!((mean - 10.0).abs() > 0.5); // not 100% certain, but probable enough + } + + #[test] + #[should_panic] + fn test_cauchy_invalid_scale_zero() { + Cauchy::new(0.0, 0.0); + } + + #[test] + #[should_panic] + fn test_cauchy_invalid_scale_neg() { + Cauchy::new(0.0, -10.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/exponential.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/exponential.rs new file mode 100644 index 0000000..e8dbdc9 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/exponential.rs @@ -0,0 +1,122 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The exponential distribution. + +use {Rng}; +use distributions::{ziggurat, ziggurat_tables, Distribution}; + +/// Samples floating-point numbers according to the exponential distribution, +/// with rate parameter `λ = 1`. This is equivalent to `Exp::new(1.0)` or +/// sampling with `-rng.gen::().ln()`, but faster. +/// +/// See `Exp` for the general exponential distribution. +/// +/// Implemented via the ZIGNOR variant[^1] of the Ziggurat method. The exact +/// description in the paper was adjusted to use tables for the exponential +/// distribution rather than normal. +/// +/// [^1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to +/// Generate Normal Random Samples*]( +/// https://www.doornik.com/research/ziggurat.pdf). +/// Nuffield College, Oxford +/// +/// # Example +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::Exp1; +/// +/// let val: f64 = SmallRng::from_entropy().sample(Exp1); +/// println!("{}", val); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Exp1; + +// This could be done via `-rng.gen::().ln()` but that is slower. +impl Distribution for Exp1 { + #[inline] + fn sample(&self, rng: &mut R) -> f64 { + #[inline] + fn pdf(x: f64) -> f64 { + (-x).exp() + } + #[inline] + fn zero_case(rng: &mut R, _u: f64) -> f64 { + ziggurat_tables::ZIG_EXP_R - rng.gen::().ln() + } + + ziggurat(rng, false, + &ziggurat_tables::ZIG_EXP_X, + &ziggurat_tables::ZIG_EXP_F, + pdf, zero_case) + } +} + +/// The exponential distribution `Exp(lambda)`. +/// +/// This distribution has density function: `f(x) = lambda * exp(-lambda * x)` +/// for `x > 0`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Exp, Distribution}; +/// +/// let exp = Exp::new(2.0); +/// let v = exp.sample(&mut rand::thread_rng()); +/// println!("{} is from a Exp(2) distribution", v); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Exp { + /// `lambda` stored as `1/lambda`, since this is what we scale by. + lambda_inverse: f64 +} + +impl Exp { + /// Construct a new `Exp` with the given shape parameter + /// `lambda`. Panics if `lambda <= 0`. + #[inline] + pub fn new(lambda: f64) -> Exp { + assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0"); + Exp { lambda_inverse: 1.0 / lambda } + } +} + +impl Distribution for Exp { + fn sample(&self, rng: &mut R) -> f64 { + let n: f64 = rng.sample(Exp1); + n * self.lambda_inverse + } +} + +#[cfg(test)] +mod test { + use distributions::Distribution; + use super::Exp; + + #[test] + fn test_exp() { + let exp = Exp::new(10.0); + let mut rng = ::test::rng(221); + for _ in 0..1000 { + assert!(exp.sample(&mut rng) >= 0.0); + } + } + #[test] + #[should_panic] + fn test_exp_invalid_lambda_zero() { + Exp::new(0.0); + } + #[test] + #[should_panic] + fn test_exp_invalid_lambda_neg() { + Exp::new(-10.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/float.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/float.rs new file mode 100644 index 0000000..0058122 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/float.rs @@ -0,0 +1,206 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Basic floating-point number distributions + +use core::mem; +use Rng; +use distributions::{Distribution, Standard}; + +/// A distribution to sample floating point numbers uniformly in the half-open +/// interval `(0, 1]`, i.e. including 1 but not 0. +/// +/// All values that can be generated are of the form `n * ε/2`. For `f32` +/// the 23 most significant random bits of a `u32` are used and for `f64` the +/// 53 most significant bits of a `u64` are used. The conversion uses the +/// multiplicative method. +/// +/// See also: [`Standard`] which samples from `[0, 1)`, [`Open01`] +/// which samples from `(0, 1)` and [`Uniform`] which samples from arbitrary +/// ranges. +/// +/// # Example +/// ``` +/// use rand::{thread_rng, Rng}; +/// use rand::distributions::OpenClosed01; +/// +/// let val: f32 = thread_rng().sample(OpenClosed01); +/// println!("f32 from (0, 1): {}", val); +/// ``` +/// +/// [`Standard`]: struct.Standard.html +/// [`Open01`]: struct.Open01.html +/// [`Uniform`]: uniform/struct.Uniform.html +#[derive(Clone, Copy, Debug)] +pub struct OpenClosed01; + +/// A distribution to sample floating point numbers uniformly in the open +/// interval `(0, 1)`, i.e. not including either endpoint. +/// +/// All values that can be generated are of the form `n * ε + ε/2`. For `f32` +/// the 22 most significant random bits of an `u32` are used, for `f64` 52 from +/// an `u64`. The conversion uses a transmute-based method. +/// +/// See also: [`Standard`] which samples from `[0, 1)`, [`OpenClosed01`] +/// which samples from `(0, 1]` and [`Uniform`] which samples from arbitrary +/// ranges. +/// +/// # Example +/// ``` +/// use rand::{thread_rng, Rng}; +/// use rand::distributions::Open01; +/// +/// let val: f32 = thread_rng().sample(Open01); +/// println!("f32 from (0, 1): {}", val); +/// ``` +/// +/// [`Standard`]: struct.Standard.html +/// [`OpenClosed01`]: struct.OpenClosed01.html +/// [`Uniform`]: uniform/struct.Uniform.html +#[derive(Clone, Copy, Debug)] +pub struct Open01; + + +pub(crate) trait IntoFloat { + type F; + + /// Helper method to combine the fraction and a contant exponent into a + /// float. + /// + /// Only the least significant bits of `self` may be set, 23 for `f32` and + /// 52 for `f64`. + /// The resulting value will fall in a range that depends on the exponent. + /// As an example the range with exponent 0 will be + /// [20..21), which is [1..2). + fn into_float_with_exponent(self, exponent: i32) -> Self::F; +} + +macro_rules! float_impls { + ($ty:ty, $uty:ty, $fraction_bits:expr, $exponent_bias:expr) => { + impl IntoFloat for $uty { + type F = $ty; + #[inline(always)] + fn into_float_with_exponent(self, exponent: i32) -> $ty { + // The exponent is encoded using an offset-binary representation + let exponent_bits = + (($exponent_bias + exponent) as $uty) << $fraction_bits; + unsafe { mem::transmute(self | exponent_bits) } + } + } + + impl Distribution<$ty> for Standard { + fn sample(&self, rng: &mut R) -> $ty { + // Multiply-based method; 24/53 random bits; [0, 1) interval. + // We use the most significant bits because for simple RNGs + // those are usually more random. + let float_size = mem::size_of::<$ty>() * 8; + let precision = $fraction_bits + 1; + let scale = 1.0 / ((1 as $uty << precision) as $ty); + + let value: $uty = rng.gen(); + scale * (value >> (float_size - precision)) as $ty + } + } + + impl Distribution<$ty> for OpenClosed01 { + fn sample(&self, rng: &mut R) -> $ty { + // Multiply-based method; 24/53 random bits; (0, 1] interval. + // We use the most significant bits because for simple RNGs + // those are usually more random. + let float_size = mem::size_of::<$ty>() * 8; + let precision = $fraction_bits + 1; + let scale = 1.0 / ((1 as $uty << precision) as $ty); + + let value: $uty = rng.gen(); + let value = value >> (float_size - precision); + // Add 1 to shift up; will not overflow because of right-shift: + scale * (value + 1) as $ty + } + } + + impl Distribution<$ty> for Open01 { + fn sample(&self, rng: &mut R) -> $ty { + // Transmute-based method; 23/52 random bits; (0, 1) interval. + // We use the most significant bits because for simple RNGs + // those are usually more random. + const EPSILON: $ty = 1.0 / (1u64 << $fraction_bits) as $ty; + let float_size = mem::size_of::<$ty>() * 8; + + let value: $uty = rng.gen(); + let fraction = value >> (float_size - $fraction_bits); + fraction.into_float_with_exponent(0) - (1.0 - EPSILON / 2.0) + } + } + } +} +float_impls! { f32, u32, 23, 127 } +float_impls! { f64, u64, 52, 1023 } + + +#[cfg(test)] +mod tests { + use Rng; + use distributions::{Open01, OpenClosed01}; + use rngs::mock::StepRng; + + const EPSILON32: f32 = ::core::f32::EPSILON; + const EPSILON64: f64 = ::core::f64::EPSILON; + + #[test] + fn standard_fp_edge_cases() { + let mut zeros = StepRng::new(0, 0); + assert_eq!(zeros.gen::(), 0.0); + assert_eq!(zeros.gen::(), 0.0); + + let mut one32 = StepRng::new(1 << 8, 0); + assert_eq!(one32.gen::(), EPSILON32 / 2.0); + + let mut one64 = StepRng::new(1 << 11, 0); + assert_eq!(one64.gen::(), EPSILON64 / 2.0); + + let mut max = StepRng::new(!0, 0); + assert_eq!(max.gen::(), 1.0 - EPSILON32 / 2.0); + assert_eq!(max.gen::(), 1.0 - EPSILON64 / 2.0); + } + + #[test] + fn openclosed01_edge_cases() { + let mut zeros = StepRng::new(0, 0); + assert_eq!(zeros.sample::(OpenClosed01), 0.0 + EPSILON32 / 2.0); + assert_eq!(zeros.sample::(OpenClosed01), 0.0 + EPSILON64 / 2.0); + + let mut one32 = StepRng::new(1 << 8, 0); + assert_eq!(one32.sample::(OpenClosed01), EPSILON32); + + let mut one64 = StepRng::new(1 << 11, 0); + assert_eq!(one64.sample::(OpenClosed01), EPSILON64); + + let mut max = StepRng::new(!0, 0); + assert_eq!(max.sample::(OpenClosed01), 1.0); + assert_eq!(max.sample::(OpenClosed01), 1.0); + } + + #[test] + fn open01_edge_cases() { + let mut zeros = StepRng::new(0, 0); + assert_eq!(zeros.sample::(Open01), 0.0 + EPSILON32 / 2.0); + assert_eq!(zeros.sample::(Open01), 0.0 + EPSILON64 / 2.0); + + let mut one32 = StepRng::new(1 << 9, 0); + assert_eq!(one32.sample::(Open01), EPSILON32 / 2.0 * 3.0); + + let mut one64 = StepRng::new(1 << 12, 0); + assert_eq!(one64.sample::(Open01), EPSILON64 / 2.0 * 3.0); + + let mut max = StepRng::new(!0, 0); + assert_eq!(max.sample::(Open01), 1.0 - EPSILON32 / 2.0); + assert_eq!(max.sample::(Open01), 1.0 - EPSILON64 / 2.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/gamma.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/gamma.rs new file mode 100644 index 0000000..f02cf3b --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/gamma.rs @@ -0,0 +1,360 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Gamma and derived distributions. + +use self::GammaRepr::*; +use self::ChiSquaredRepr::*; + +use Rng; +use distributions::normal::StandardNormal; +use distributions::{Distribution, Exp, Open01}; + +/// The Gamma distribution `Gamma(shape, scale)` distribution. +/// +/// The density function of this distribution is +/// +/// ```text +/// f(x) = x^(k - 1) * exp(-x / θ) / (Γ(k) * θ^k) +/// ``` +/// +/// where `Γ` is the Gamma function, `k` is the shape and `θ` is the +/// scale and both `k` and `θ` are strictly positive. +/// +/// The algorithm used is that described by Marsaglia & Tsang 2000[^1], +/// falling back to directly sampling from an Exponential for `shape +/// == 1`, and using the boosting technique described in that paper for +/// `shape < 1`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Distribution, Gamma}; +/// +/// let gamma = Gamma::new(2.0, 5.0); +/// let v = gamma.sample(&mut rand::thread_rng()); +/// println!("{} is from a Gamma(2, 5) distribution", v); +/// ``` +/// +/// [^1]: George Marsaglia and Wai Wan Tsang. 2000. "A Simple Method for +/// Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3 +/// (September 2000), 363-372. +/// DOI:[10.1145/358407.358414](https://doi.acm.org/10.1145/358407.358414) +#[derive(Clone, Copy, Debug)] +pub struct Gamma { + repr: GammaRepr, +} + +#[derive(Clone, Copy, Debug)] +enum GammaRepr { + Large(GammaLargeShape), + One(Exp), + Small(GammaSmallShape) +} + +// These two helpers could be made public, but saving the +// match-on-Gamma-enum branch from using them directly (e.g. if one +// knows that the shape is always > 1) doesn't appear to be much +// faster. + +/// Gamma distribution where the shape parameter is less than 1. +/// +/// Note, samples from this require a compulsory floating-point `pow` +/// call, which makes it significantly slower than sampling from a +/// gamma distribution where the shape parameter is greater than or +/// equal to 1. +/// +/// See `Gamma` for sampling from a Gamma distribution with general +/// shape parameters. +#[derive(Clone, Copy, Debug)] +struct GammaSmallShape { + inv_shape: f64, + large_shape: GammaLargeShape +} + +/// Gamma distribution where the shape parameter is larger than 1. +/// +/// See `Gamma` for sampling from a Gamma distribution with general +/// shape parameters. +#[derive(Clone, Copy, Debug)] +struct GammaLargeShape { + scale: f64, + c: f64, + d: f64 +} + +impl Gamma { + /// Construct an object representing the `Gamma(shape, scale)` + /// distribution. + /// + /// Panics if `shape <= 0` or `scale <= 0`. + #[inline] + pub fn new(shape: f64, scale: f64) -> Gamma { + assert!(shape > 0.0, "Gamma::new called with shape <= 0"); + assert!(scale > 0.0, "Gamma::new called with scale <= 0"); + + let repr = if shape == 1.0 { + One(Exp::new(1.0 / scale)) + } else if shape < 1.0 { + Small(GammaSmallShape::new_raw(shape, scale)) + } else { + Large(GammaLargeShape::new_raw(shape, scale)) + }; + Gamma { repr } + } +} + +impl GammaSmallShape { + fn new_raw(shape: f64, scale: f64) -> GammaSmallShape { + GammaSmallShape { + inv_shape: 1. / shape, + large_shape: GammaLargeShape::new_raw(shape + 1.0, scale) + } + } +} + +impl GammaLargeShape { + fn new_raw(shape: f64, scale: f64) -> GammaLargeShape { + let d = shape - 1. / 3.; + GammaLargeShape { + scale, + c: 1. / (9. * d).sqrt(), + d + } + } +} + +impl Distribution for Gamma { + fn sample(&self, rng: &mut R) -> f64 { + match self.repr { + Small(ref g) => g.sample(rng), + One(ref g) => g.sample(rng), + Large(ref g) => g.sample(rng), + } + } +} +impl Distribution for GammaSmallShape { + fn sample(&self, rng: &mut R) -> f64 { + let u: f64 = rng.sample(Open01); + + self.large_shape.sample(rng) * u.powf(self.inv_shape) + } +} +impl Distribution for GammaLargeShape { + fn sample(&self, rng: &mut R) -> f64 { + loop { + let x = rng.sample(StandardNormal); + let v_cbrt = 1.0 + self.c * x; + if v_cbrt <= 0.0 { // a^3 <= 0 iff a <= 0 + continue + } + + let v = v_cbrt * v_cbrt * v_cbrt; + let u: f64 = rng.sample(Open01); + + let x_sqr = x * x; + if u < 1.0 - 0.0331 * x_sqr * x_sqr || + u.ln() < 0.5 * x_sqr + self.d * (1.0 - v + v.ln()) { + return self.d * v * self.scale + } + } + } +} + +/// The chi-squared distribution `χ²(k)`, where `k` is the degrees of +/// freedom. +/// +/// For `k > 0` integral, this distribution is the sum of the squares +/// of `k` independent standard normal random variables. For other +/// `k`, this uses the equivalent characterisation +/// `χ²(k) = Gamma(k/2, 2)`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{ChiSquared, Distribution}; +/// +/// let chi = ChiSquared::new(11.0); +/// let v = chi.sample(&mut rand::thread_rng()); +/// println!("{} is from a χ²(11) distribution", v) +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct ChiSquared { + repr: ChiSquaredRepr, +} + +#[derive(Clone, Copy, Debug)] +enum ChiSquaredRepr { + // k == 1, Gamma(alpha, ..) is particularly slow for alpha < 1, + // e.g. when alpha = 1/2 as it would be for this case, so special- + // casing and using the definition of N(0,1)^2 is faster. + DoFExactlyOne, + DoFAnythingElse(Gamma), +} + +impl ChiSquared { + /// Create a new chi-squared distribution with degrees-of-freedom + /// `k`. Panics if `k < 0`. + pub fn new(k: f64) -> ChiSquared { + let repr = if k == 1.0 { + DoFExactlyOne + } else { + assert!(k > 0.0, "ChiSquared::new called with `k` < 0"); + DoFAnythingElse(Gamma::new(0.5 * k, 2.0)) + }; + ChiSquared { repr } + } +} +impl Distribution for ChiSquared { + fn sample(&self, rng: &mut R) -> f64 { + match self.repr { + DoFExactlyOne => { + // k == 1 => N(0,1)^2 + let norm = rng.sample(StandardNormal); + norm * norm + } + DoFAnythingElse(ref g) => g.sample(rng) + } + } +} + +/// The Fisher F distribution `F(m, n)`. +/// +/// This distribution is equivalent to the ratio of two normalised +/// chi-squared distributions, that is, `F(m,n) = (χ²(m)/m) / +/// (χ²(n)/n)`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{FisherF, Distribution}; +/// +/// let f = FisherF::new(2.0, 32.0); +/// let v = f.sample(&mut rand::thread_rng()); +/// println!("{} is from an F(2, 32) distribution", v) +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct FisherF { + numer: ChiSquared, + denom: ChiSquared, + // denom_dof / numer_dof so that this can just be a straight + // multiplication, rather than a division. + dof_ratio: f64, +} + +impl FisherF { + /// Create a new `FisherF` distribution, with the given + /// parameter. Panics if either `m` or `n` are not positive. + pub fn new(m: f64, n: f64) -> FisherF { + assert!(m > 0.0, "FisherF::new called with `m < 0`"); + assert!(n > 0.0, "FisherF::new called with `n < 0`"); + + FisherF { + numer: ChiSquared::new(m), + denom: ChiSquared::new(n), + dof_ratio: n / m + } + } +} +impl Distribution for FisherF { + fn sample(&self, rng: &mut R) -> f64 { + self.numer.sample(rng) / self.denom.sample(rng) * self.dof_ratio + } +} + +/// The Student t distribution, `t(nu)`, where `nu` is the degrees of +/// freedom. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{StudentT, Distribution}; +/// +/// let t = StudentT::new(11.0); +/// let v = t.sample(&mut rand::thread_rng()); +/// println!("{} is from a t(11) distribution", v) +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct StudentT { + chi: ChiSquared, + dof: f64 +} + +impl StudentT { + /// Create a new Student t distribution with `n` degrees of + /// freedom. Panics if `n <= 0`. + pub fn new(n: f64) -> StudentT { + assert!(n > 0.0, "StudentT::new called with `n <= 0`"); + StudentT { + chi: ChiSquared::new(n), + dof: n + } + } +} +impl Distribution for StudentT { + fn sample(&self, rng: &mut R) -> f64 { + let norm = rng.sample(StandardNormal); + norm * (self.dof / self.chi.sample(rng)).sqrt() + } +} + +#[cfg(test)] +mod test { + use distributions::Distribution; + use super::{ChiSquared, StudentT, FisherF}; + + #[test] + fn test_chi_squared_one() { + let chi = ChiSquared::new(1.0); + let mut rng = ::test::rng(201); + for _ in 0..1000 { + chi.sample(&mut rng); + } + } + #[test] + fn test_chi_squared_small() { + let chi = ChiSquared::new(0.5); + let mut rng = ::test::rng(202); + for _ in 0..1000 { + chi.sample(&mut rng); + } + } + #[test] + fn test_chi_squared_large() { + let chi = ChiSquared::new(30.0); + let mut rng = ::test::rng(203); + for _ in 0..1000 { + chi.sample(&mut rng); + } + } + #[test] + #[should_panic] + fn test_chi_squared_invalid_dof() { + ChiSquared::new(-1.0); + } + + #[test] + fn test_f() { + let f = FisherF::new(2.0, 32.0); + let mut rng = ::test::rng(204); + for _ in 0..1000 { + f.sample(&mut rng); + } + } + + #[test] + fn test_t() { + let t = StudentT::new(11.0); + let mut rng = ::test::rng(205); + for _ in 0..1000 { + t.sample(&mut rng); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/integer.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/integer.rs new file mode 100644 index 0000000..a23ddd5 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/integer.rs @@ -0,0 +1,113 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The implementations of the `Standard` distribution for integer types. + +use {Rng}; +use distributions::{Distribution, Standard}; + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> u8 { + rng.next_u32() as u8 + } +} + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> u16 { + rng.next_u32() as u16 + } +} + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> u32 { + rng.next_u32() + } +} + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> u64 { + rng.next_u64() + } +} + +#[cfg(feature = "i128_support")] +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> u128 { + // Use LE; we explicitly generate one value before the next. + let x = rng.next_u64() as u128; + let y = rng.next_u64() as u128; + (y << 64) | x + } +} + +impl Distribution for Standard { + #[inline] + #[cfg(any(target_pointer_width = "32", target_pointer_width = "16"))] + fn sample(&self, rng: &mut R) -> usize { + rng.next_u32() as usize + } + + #[inline] + #[cfg(target_pointer_width = "64")] + fn sample(&self, rng: &mut R) -> usize { + rng.next_u64() as usize + } +} + +macro_rules! impl_int_from_uint { + ($ty:ty, $uty:ty) => { + impl Distribution<$ty> for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> $ty { + rng.gen::<$uty>() as $ty + } + } + } +} + +impl_int_from_uint! { i8, u8 } +impl_int_from_uint! { i16, u16 } +impl_int_from_uint! { i32, u32 } +impl_int_from_uint! { i64, u64 } +#[cfg(feature = "i128_support")] impl_int_from_uint! { i128, u128 } +impl_int_from_uint! { isize, usize } + + +#[cfg(test)] +mod tests { + use Rng; + use distributions::{Standard}; + + #[test] + fn test_integers() { + let mut rng = ::test::rng(806); + + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + #[cfg(feature = "i128_support")] + rng.sample::(Standard); + + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + #[cfg(feature = "i128_support")] + rng.sample::(Standard); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/log_gamma.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/log_gamma.rs new file mode 100644 index 0000000..f1fa383 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/log_gamma.rs @@ -0,0 +1,51 @@ +// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/// Calculates ln(gamma(x)) (natural logarithm of the gamma +/// function) using the Lanczos approximation. +/// +/// The approximation expresses the gamma function as: +/// `gamma(z+1) = sqrt(2*pi)*(z+g+0.5)^(z+0.5)*exp(-z-g-0.5)*Ag(z)` +/// `g` is an arbitrary constant; we use the approximation with `g=5`. +/// +/// Noting that `gamma(z+1) = z*gamma(z)` and applying `ln` to both sides: +/// `ln(gamma(z)) = (z+0.5)*ln(z+g+0.5)-(z+g+0.5) + ln(sqrt(2*pi)*Ag(z)/z)` +/// +/// `Ag(z)` is an infinite series with coefficients that can be calculated +/// ahead of time - we use just the first 6 terms, which is good enough +/// for most purposes. +pub fn log_gamma(x: f64) -> f64 { + // precalculated 6 coefficients for the first 6 terms of the series + let coefficients: [f64; 6] = [ + 76.18009172947146, + -86.50532032941677, + 24.01409824083091, + -1.231739572450155, + 0.1208650973866179e-2, + -0.5395239384953e-5, + ]; + + // (x+0.5)*ln(x+g+0.5)-(x+g+0.5) + let tmp = x + 5.5; + let log = (x + 0.5) * tmp.ln() - tmp; + + // the first few terms of the series for Ag(x) + let mut a = 1.000000000190015; + let mut denom = x; + for coeff in &coefficients { + denom += 1.0; + a += coeff / denom; + } + + // get everything together + // a is Ag(x) + // 2.5066... is sqrt(2pi) + log + (2.5066282746310005 * a / x).ln() +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/mod.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/mod.rs new file mode 100644 index 0000000..24dd3a3 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/mod.rs @@ -0,0 +1,784 @@ +// Copyright 2013-2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Generating random samples from probability distributions. +//! +//! This module is the home of the [`Distribution`] trait and several of its +//! implementations. It is the workhorse behind some of the convenient +//! functionality of the [`Rng`] trait, including [`gen`], [`gen_range`] and +//! of course [`sample`]. +//! +//! Abstractly, a [probability distribution] describes the probability of +//! occurance of each value in its sample space. +//! +//! More concretely, an implementation of `Distribution` for type `X` is an +//! algorithm for choosing values from the sample space (a subset of `T`) +//! according to the distribution `X` represents, using an external source of +//! randomness (an RNG supplied to the `sample` function). +//! +//! A type `X` may implement `Distribution` for multiple types `T`. +//! Any type implementing [`Distribution`] is stateless (i.e. immutable), +//! but it may have internal parameters set at construction time (for example, +//! [`Uniform`] allows specification of its sample space as a range within `T`). +//! +//! +//! # The `Standard` distribution +//! +//! The [`Standard`] distribution is important to mention. This is the +//! distribution used by [`Rng::gen()`] and represents the "default" way to +//! produce a random value for many different types, including most primitive +//! types, tuples, arrays, and a few derived types. See the documentation of +//! [`Standard`] for more details. +//! +//! Implementing `Distribution` for [`Standard`] for user types `T` makes it +//! possible to generate type `T` with [`Rng::gen()`], and by extension also +//! with the [`random()`] function. +//! +//! +//! # Distribution to sample from a `Uniform` range +//! +//! The [`Uniform`] distribution is more flexible than [`Standard`], but also +//! more specialised: it supports fewer target types, but allows the sample +//! space to be specified as an arbitrary range within its target type `T`. +//! Both [`Standard`] and [`Uniform`] are in some sense uniform distributions. +//! +//! Values may be sampled from this distribution using [`Rng::gen_range`] or +//! by creating a distribution object with [`Uniform::new`], +//! [`Uniform::new_inclusive`] or `From`. When the range limits are not +//! known at compile time it is typically faster to reuse an existing +//! distribution object than to call [`Rng::gen_range`]. +//! +//! User types `T` may also implement `Distribution` for [`Uniform`], +//! although this is less straightforward than for [`Standard`] (see the +//! documentation in the [`uniform` module]. Doing so enables generation of +//! values of type `T` with [`Rng::gen_range`]. +//! +//! +//! # Other distributions +//! +//! There are surprisingly many ways to uniformly generate random floats. A +//! range between 0 and 1 is standard, but the exact bounds (open vs closed) +//! and accuracy differ. In addition to the [`Standard`] distribution Rand offers +//! [`Open01`] and [`OpenClosed01`]. See [Floating point implementation] for +//! more details. +//! +//! [`Alphanumeric`] is a simple distribution to sample random letters and +//! numbers of the `char` type; in contrast [`Standard`] may sample any valid +//! `char`. +//! +//! +//! # Non-uniform probability distributions +//! +//! Rand currently provides the following probability distributions: +//! +//! - Related to real-valued quantities that grow linearly +//! (e.g. errors, offsets): +//! - [`Normal`] distribution, and [`StandardNormal`] as a primitive +//! - [`Cauchy`] distribution +//! - Related to Bernoulli trials (yes/no events, with a given probability): +//! - [`Binomial`] distribution +//! - [`Bernoulli`] distribution, similar to [`Rng::gen_bool`]. +//! - Related to positive real-valued quantities that grow exponentially +//! (e.g. prices, incomes, populations): +//! - [`LogNormal`] distribution +//! - Related to the occurrence of independent events at a given rate: +//! - [`Poisson`] distribution +//! - [`Exp`]onential distribution, and [`Exp1`] as a primitive +//! - Gamma and derived distributions: +//! - [`Gamma`] distribution +//! - [`ChiSquared`] distribution +//! - [`StudentT`] distribution +//! - [`FisherF`] distribution +//! +//! +//! # Examples +//! +//! Sampling from a distribution: +//! +//! ``` +//! use rand::{thread_rng, Rng}; +//! use rand::distributions::Exp; +//! +//! let exp = Exp::new(2.0); +//! let v = thread_rng().sample(exp); +//! println!("{} is from an Exp(2) distribution", v); +//! ``` +//! +//! Implementing the [`Standard`] distribution for a user type: +//! +//! ``` +//! # #![allow(dead_code)] +//! use rand::Rng; +//! use rand::distributions::{Distribution, Standard}; +//! +//! struct MyF32 { +//! x: f32, +//! } +//! +//! impl Distribution for Standard { +//! fn sample(&self, rng: &mut R) -> MyF32 { +//! MyF32 { x: rng.gen() } +//! } +//! } +//! ``` +//! +//! +//! [probability distribution]: https://en.wikipedia.org/wiki/Probability_distribution +//! [`Distribution`]: trait.Distribution.html +//! [`gen_range`]: ../trait.Rng.html#method.gen_range +//! [`gen`]: ../trait.Rng.html#method.gen +//! [`sample`]: ../trait.Rng.html#method.sample +//! [`new_inclusive`]: struct.Uniform.html#method.new_inclusive +//! [`random()`]: ../fn.random.html +//! [`Rng::gen_bool`]: ../trait.Rng.html#method.gen_bool +//! [`Rng::gen_range`]: ../trait.Rng.html#method.gen_range +//! [`Rng::gen()`]: ../trait.Rng.html#method.gen +//! [`Rng`]: ../trait.Rng.html +//! [`uniform` module]: uniform/index.html +//! [Floating point implementation]: struct.Standard.html#floating-point-implementation +// distributions +//! [`Alphanumeric`]: struct.Alphanumeric.html +//! [`Bernoulli`]: struct.Bernoulli.html +//! [`Binomial`]: struct.Binomial.html +//! [`Cauchy`]: struct.Cauchy.html +//! [`ChiSquared`]: struct.ChiSquared.html +//! [`Exp`]: struct.Exp.html +//! [`Exp1`]: struct.Exp1.html +//! [`FisherF`]: struct.FisherF.html +//! [`Gamma`]: struct.Gamma.html +//! [`LogNormal`]: struct.LogNormal.html +//! [`Normal`]: struct.Normal.html +//! [`Open01`]: struct.Open01.html +//! [`OpenClosed01`]: struct.OpenClosed01.html +//! [`Pareto`]: struct.Pareto.html +//! [`Poisson`]: struct.Poisson.html +//! [`Standard`]: struct.Standard.html +//! [`StandardNormal`]: struct.StandardNormal.html +//! [`StudentT`]: struct.StudentT.html +//! [`Uniform`]: struct.Uniform.html +//! [`Uniform::new`]: struct.Uniform.html#method.new +//! [`Uniform::new_inclusive`]: struct.Uniform.html#method.new_inclusive + +use Rng; + +#[doc(inline)] pub use self::other::Alphanumeric; +#[doc(inline)] pub use self::uniform::Uniform; +#[doc(inline)] pub use self::float::{OpenClosed01, Open01}; +#[deprecated(since="0.5.0", note="use Uniform instead")] +pub use self::uniform::Uniform as Range; +#[cfg(feature="std")] +#[doc(inline)] pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT}; +#[cfg(feature="std")] +#[doc(inline)] pub use self::normal::{Normal, LogNormal, StandardNormal}; +#[cfg(feature="std")] +#[doc(inline)] pub use self::exponential::{Exp, Exp1}; +#[cfg(feature="std")] +#[doc(inline)] pub use self::pareto::Pareto; +#[cfg(feature = "std")] +#[doc(inline)] pub use self::poisson::Poisson; +#[cfg(feature = "std")] +#[doc(inline)] pub use self::binomial::Binomial; +#[doc(inline)] pub use self::bernoulli::Bernoulli; +#[cfg(feature = "std")] +#[doc(inline)] pub use self::cauchy::Cauchy; + +pub mod uniform; +#[cfg(feature="std")] +#[doc(hidden)] pub mod gamma; +#[cfg(feature="std")] +#[doc(hidden)] pub mod normal; +#[cfg(feature="std")] +#[doc(hidden)] pub mod exponential; +#[cfg(feature="std")] +#[doc(hidden)] pub mod pareto; +#[cfg(feature = "std")] +#[doc(hidden)] pub mod poisson; +#[cfg(feature = "std")] +#[doc(hidden)] pub mod binomial; +#[doc(hidden)] pub mod bernoulli; +#[cfg(feature = "std")] +#[doc(hidden)] pub mod cauchy; + +mod float; +mod integer; +#[cfg(feature="std")] +mod log_gamma; +mod other; +#[cfg(feature="std")] +mod ziggurat_tables; +#[cfg(feature="std")] +use distributions::float::IntoFloat; + +/// Types that can be used to create a random instance of `Support`. +#[deprecated(since="0.5.0", note="use Distribution instead")] +pub trait Sample { + /// Generate a random value of `Support`, using `rng` as the + /// source of randomness. + fn sample(&mut self, rng: &mut R) -> Support; +} + +/// `Sample`s that do not require keeping track of state. +/// +/// Since no state is recorded, each sample is (statistically) +/// independent of all others, assuming the `Rng` used has this +/// property. +#[allow(deprecated)] +#[deprecated(since="0.5.0", note="use Distribution instead")] +pub trait IndependentSample: Sample { + /// Generate a random value. + fn ind_sample(&self, &mut R) -> Support; +} + +/// DEPRECATED: Use `distributions::uniform` instead. +#[deprecated(since="0.5.0", note="use uniform instead")] +pub mod range { + pub use distributions::uniform::Uniform as Range; + pub use distributions::uniform::SampleUniform as SampleRange; +} + +#[allow(deprecated)] +mod impls { + use Rng; + use distributions::{Distribution, Sample, IndependentSample, + WeightedChoice}; + #[cfg(feature="std")] + use distributions::exponential::Exp; + #[cfg(feature="std")] + use distributions::gamma::{Gamma, ChiSquared, FisherF, StudentT}; + #[cfg(feature="std")] + use distributions::normal::{Normal, LogNormal}; + use distributions::range::{Range, SampleRange}; + + impl<'a, T: Clone> Sample for WeightedChoice<'a, T> { + fn sample(&mut self, rng: &mut R) -> T { + Distribution::sample(self, rng) + } + } + impl<'a, T: Clone> IndependentSample for WeightedChoice<'a, T> { + fn ind_sample(&self, rng: &mut R) -> T { + Distribution::sample(self, rng) + } + } + + impl Sample for Range { + fn sample(&mut self, rng: &mut R) -> T { + Distribution::sample(self, rng) + } + } + impl IndependentSample for Range { + fn ind_sample(&self, rng: &mut R) -> T { + Distribution::sample(self, rng) + } + } + + #[cfg(feature="std")] + macro_rules! impl_f64 { + ($($name: ident), *) => { + $( + impl Sample for $name { + fn sample(&mut self, rng: &mut R) -> f64 { + Distribution::sample(self, rng) + } + } + impl IndependentSample for $name { + fn ind_sample(&self, rng: &mut R) -> f64 { + Distribution::sample(self, rng) + } + } + )* + } + } + #[cfg(feature="std")] + impl_f64!(Exp, Gamma, ChiSquared, FisherF, StudentT, Normal, LogNormal); +} + +/// Types (distributions) that can be used to create a random instance of `T`. +/// +/// It is possible to sample from a distribution through both the +/// `Distribution` and [`Rng`] traits, via `distr.sample(&mut rng)` and +/// `rng.sample(distr)`. They also both offer the [`sample_iter`] method, which +/// produces an iterator that samples from the distribution. +/// +/// All implementations are expected to be immutable; this has the significant +/// advantage of not needing to consider thread safety, and for most +/// distributions efficient state-less sampling algorithms are available. +/// +/// [`Rng`]: ../trait.Rng.html +/// [`sample_iter`]: trait.Distribution.html#method.sample_iter +pub trait Distribution { + /// Generate a random value of `T`, using `rng` as the source of randomness. + fn sample(&self, rng: &mut R) -> T; + + /// Create an iterator that generates random values of `T`, using `rng` as + /// the source of randomness. + /// + /// # Example + /// + /// ``` + /// use rand::thread_rng; + /// use rand::distributions::{Distribution, Alphanumeric, Uniform, Standard}; + /// + /// let mut rng = thread_rng(); + /// + /// // Vec of 16 x f32: + /// let v: Vec = Standard.sample_iter(&mut rng).take(16).collect(); + /// + /// // String: + /// let s: String = Alphanumeric.sample_iter(&mut rng).take(7).collect(); + /// + /// // Dice-rolling: + /// let die_range = Uniform::new_inclusive(1, 6); + /// let mut roll_die = die_range.sample_iter(&mut rng); + /// while roll_die.next().unwrap() != 6 { + /// println!("Not a 6; rolling again!"); + /// } + /// ``` + fn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> + where Self: Sized, R: Rng + { + DistIter { + distr: self, + rng: rng, + phantom: ::core::marker::PhantomData, + } + } +} + +impl<'a, T, D: Distribution> Distribution for &'a D { + fn sample(&self, rng: &mut R) -> T { + (*self).sample(rng) + } +} + + +/// An iterator that generates random values of `T` with distribution `D`, +/// using `R` as the source of randomness. +/// +/// This `struct` is created by the [`sample_iter`] method on [`Distribution`]. +/// See its documentation for more. +/// +/// [`Distribution`]: trait.Distribution.html +/// [`sample_iter`]: trait.Distribution.html#method.sample_iter +#[derive(Debug)] +pub struct DistIter<'a, D: 'a, R: 'a, T> { + distr: &'a D, + rng: &'a mut R, + phantom: ::core::marker::PhantomData, +} + +impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> + where D: Distribution, R: Rng + 'a +{ + type Item = T; + + #[inline(always)] + fn next(&mut self) -> Option { + Some(self.distr.sample(self.rng)) + } + + fn size_hint(&self) -> (usize, Option) { + (usize::max_value(), None) + } +} + + +/// A generic random value distribution, implemented for many primitive types. +/// Usually generates values with a numerically uniform distribution, and with a +/// range appropriate to the type. +/// +/// ## Built-in Implementations +/// +/// Assuming the provided `Rng` is well-behaved, these implementations +/// generate values with the following ranges and distributions: +/// +/// * Integers (`i32`, `u32`, `isize`, `usize`, etc.): Uniformly distributed +/// over all values of the type. +/// * `char`: Uniformly distributed over all Unicode scalar values, i.e. all +/// code points in the range `0...0x10_FFFF`, except for the range +/// `0xD800...0xDFFF` (the surrogate code points). This includes +/// unassigned/reserved code points. +/// * `bool`: Generates `false` or `true`, each with probability 0.5. +/// * Floating point types (`f32` and `f64`): Uniformly distributed in the +/// half-open range `[0, 1)`. See notes below. +/// * Wrapping integers (`Wrapping`), besides the type identical to their +/// normal integer variants. +/// +/// The following aggregate types also implement the distribution `Standard` as +/// long as their component types implement it: +/// +/// * Tuples and arrays: Each element of the tuple or array is generated +/// independently, using the `Standard` distribution recursively. +/// * `Option` where `Standard` is implemented for `T`: Returns `None` with +/// probability 0.5; otherwise generates a random `x: T` and returns `Some(x)`. +/// +/// # Example +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::Standard; +/// +/// let val: f32 = SmallRng::from_entropy().sample(Standard); +/// println!("f32 from [0, 1): {}", val); +/// ``` +/// +/// # Floating point implementation +/// The floating point implementations for `Standard` generate a random value in +/// the half-open interval `[0, 1)`, i.e. including 0 but not 1. +/// +/// All values that can be generated are of the form `n * ε/2`. For `f32` +/// the 23 most significant random bits of a `u32` are used and for `f64` the +/// 53 most significant bits of a `u64` are used. The conversion uses the +/// multiplicative method: `(rng.gen::<$uty>() >> N) as $ty * (ε/2)`. +/// +/// See also: [`Open01`] which samples from `(0, 1)`, [`OpenClosed01`] which +/// samples from `(0, 1]` and `Rng::gen_range(0, 1)` which also samples from +/// `[0, 1)`. Note that `Open01` and `gen_range` (which uses [`Uniform`]) use +/// transmute-based methods which yield 1 bit less precision but may perform +/// faster on some architectures (on modern Intel CPUs all methods have +/// approximately equal performance). +/// +/// [`Open01`]: struct.Open01.html +/// [`OpenClosed01`]: struct.OpenClosed01.html +/// [`Uniform`]: uniform/struct.Uniform.html +#[derive(Clone, Copy, Debug)] +pub struct Standard; + +#[allow(deprecated)] +impl ::Rand for T where Standard: Distribution { + fn rand(rng: &mut R) -> Self { + Standard.sample(rng) + } +} + + +/// A value with a particular weight for use with `WeightedChoice`. +#[derive(Copy, Clone, Debug)] +pub struct Weighted { + /// The numerical weight of this item + pub weight: u32, + /// The actual item which is being weighted + pub item: T, +} + +/// A distribution that selects from a finite collection of weighted items. +/// +/// Each item has an associated weight that influences how likely it +/// is to be chosen: higher weight is more likely. +/// +/// The `Clone` restriction is a limitation of the `Distribution` trait. +/// Note that `&T` is (cheaply) `Clone` for all `T`, as is `u32`, so one can +/// store references or indices into another vector. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Weighted, WeightedChoice, Distribution}; +/// +/// let mut items = vec!(Weighted { weight: 2, item: 'a' }, +/// Weighted { weight: 4, item: 'b' }, +/// Weighted { weight: 1, item: 'c' }); +/// let wc = WeightedChoice::new(&mut items); +/// let mut rng = rand::thread_rng(); +/// for _ in 0..16 { +/// // on average prints 'a' 4 times, 'b' 8 and 'c' twice. +/// println!("{}", wc.sample(&mut rng)); +/// } +/// ``` +#[derive(Debug)] +pub struct WeightedChoice<'a, T:'a> { + items: &'a mut [Weighted], + weight_range: Uniform, +} + +impl<'a, T: Clone> WeightedChoice<'a, T> { + /// Create a new `WeightedChoice`. + /// + /// Panics if: + /// + /// - `items` is empty + /// - the total weight is 0 + /// - the total weight is larger than a `u32` can contain. + pub fn new(items: &'a mut [Weighted]) -> WeightedChoice<'a, T> { + // strictly speaking, this is subsumed by the total weight == 0 case + assert!(!items.is_empty(), "WeightedChoice::new called with no items"); + + let mut running_total: u32 = 0; + + // we convert the list from individual weights to cumulative + // weights so we can binary search. This *could* drop elements + // with weight == 0 as an optimisation. + for item in items.iter_mut() { + running_total = match running_total.checked_add(item.weight) { + Some(n) => n, + None => panic!("WeightedChoice::new called with a total weight \ + larger than a u32 can contain") + }; + + item.weight = running_total; + } + assert!(running_total != 0, "WeightedChoice::new called with a total weight of 0"); + + WeightedChoice { + items, + // we're likely to be generating numbers in this range + // relatively often, so might as well cache it + weight_range: Uniform::new(0, running_total) + } + } +} + +impl<'a, T: Clone> Distribution for WeightedChoice<'a, T> { + fn sample(&self, rng: &mut R) -> T { + // we want to find the first element that has cumulative + // weight > sample_weight, which we do by binary since the + // cumulative weights of self.items are sorted. + + // choose a weight in [0, total_weight) + let sample_weight = self.weight_range.sample(rng); + + // short circuit when it's the first item + if sample_weight < self.items[0].weight { + return self.items[0].item.clone(); + } + + let mut idx = 0; + let mut modifier = self.items.len(); + + // now we know that every possibility has an element to the + // left, so we can just search for the last element that has + // cumulative weight <= sample_weight, then the next one will + // be "it". (Note that this greatest element will never be the + // last element of the vector, since sample_weight is chosen + // in [0, total_weight) and the cumulative weight of the last + // one is exactly the total weight.) + while modifier > 1 { + let i = idx + modifier / 2; + if self.items[i].weight <= sample_weight { + // we're small, so look to the right, but allow this + // exact element still. + idx = i; + // we need the `/ 2` to round up otherwise we'll drop + // the trailing elements when `modifier` is odd. + modifier += 1; + } else { + // otherwise we're too big, so go left. (i.e. do + // nothing) + } + modifier /= 2; + } + self.items[idx + 1].item.clone() + } +} + +/// Sample a random number using the Ziggurat method (specifically the +/// ZIGNOR variant from Doornik 2005). Most of the arguments are +/// directly from the paper: +/// +/// * `rng`: source of randomness +/// * `symmetric`: whether this is a symmetric distribution, or one-sided with P(x < 0) = 0. +/// * `X`: the $x_i$ abscissae. +/// * `F`: precomputed values of the PDF at the $x_i$, (i.e. $f(x_i)$) +/// * `F_DIFF`: precomputed values of $f(x_i) - f(x_{i+1})$ +/// * `pdf`: the probability density function +/// * `zero_case`: manual sampling from the tail when we chose the +/// bottom box (i.e. i == 0) + +// the perf improvement (25-50%) is definitely worth the extra code +// size from force-inlining. +#[cfg(feature="std")] +#[inline(always)] +fn ziggurat( + rng: &mut R, + symmetric: bool, + x_tab: ziggurat_tables::ZigTable, + f_tab: ziggurat_tables::ZigTable, + mut pdf: P, + mut zero_case: Z) + -> f64 where P: FnMut(f64) -> f64, Z: FnMut(&mut R, f64) -> f64 { + loop { + // As an optimisation we re-implement the conversion to a f64. + // From the remaining 12 most significant bits we use 8 to construct `i`. + // This saves us generating a whole extra random number, while the added + // precision of using 64 bits for f64 does not buy us much. + let bits = rng.next_u64(); + let i = bits as usize & 0xff; + + let u = if symmetric { + // Convert to a value in the range [2,4) and substract to get [-1,1) + // We can't convert to an open range directly, that would require + // substracting `3.0 - EPSILON`, which is not representable. + // It is possible with an extra step, but an open range does not + // seem neccesary for the ziggurat algorithm anyway. + (bits >> 12).into_float_with_exponent(1) - 3.0 + } else { + // Convert to a value in the range [1,2) and substract to get (0,1) + (bits >> 12).into_float_with_exponent(0) + - (1.0 - ::core::f64::EPSILON / 2.0) + }; + let x = u * x_tab[i]; + + let test_x = if symmetric { x.abs() } else {x}; + + // algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i]) + if test_x < x_tab[i + 1] { + return x; + } + if i == 0 { + return zero_case(rng, u); + } + // algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1 + if f_tab[i + 1] + (f_tab[i] - f_tab[i + 1]) * rng.gen::() < pdf(x) { + return x; + } + } +} + +#[cfg(test)] +mod tests { + use Rng; + use rngs::mock::StepRng; + use super::{WeightedChoice, Weighted, Distribution}; + + #[test] + fn test_weighted_choice() { + // this makes assumptions about the internal implementation of + // WeightedChoice. It may fail when the implementation in + // `distributions::uniform::UniformInt` changes. + + macro_rules! t { + ($items:expr, $expected:expr) => {{ + let mut items = $items; + let mut total_weight = 0; + for item in &items { total_weight += item.weight; } + + let wc = WeightedChoice::new(&mut items); + let expected = $expected; + + // Use extremely large steps between the random numbers, because + // we test with small ranges and `UniformInt` is designed to prefer + // the most significant bits. + let mut rng = StepRng::new(0, !0 / (total_weight as u64)); + + for &val in expected.iter() { + assert_eq!(wc.sample(&mut rng), val) + } + }} + } + + t!([Weighted { weight: 1, item: 10}], [10]); + + // skip some + t!([Weighted { weight: 0, item: 20}, + Weighted { weight: 2, item: 21}, + Weighted { weight: 0, item: 22}, + Weighted { weight: 1, item: 23}], + [21, 21, 23]); + + // different weights + t!([Weighted { weight: 4, item: 30}, + Weighted { weight: 3, item: 31}], + [30, 31, 30, 31, 30, 31, 30]); + + // check that we're binary searching + // correctly with some vectors of odd + // length. + t!([Weighted { weight: 1, item: 40}, + Weighted { weight: 1, item: 41}, + Weighted { weight: 1, item: 42}, + Weighted { weight: 1, item: 43}, + Weighted { weight: 1, item: 44}], + [40, 41, 42, 43, 44]); + t!([Weighted { weight: 1, item: 50}, + Weighted { weight: 1, item: 51}, + Weighted { weight: 1, item: 52}, + Weighted { weight: 1, item: 53}, + Weighted { weight: 1, item: 54}, + Weighted { weight: 1, item: 55}, + Weighted { weight: 1, item: 56}], + [50, 54, 51, 55, 52, 56, 53]); + } + + #[test] + fn test_weighted_clone_initialization() { + let initial : Weighted = Weighted {weight: 1, item: 1}; + let clone = initial.clone(); + assert_eq!(initial.weight, clone.weight); + assert_eq!(initial.item, clone.item); + } + + #[test] #[should_panic] + fn test_weighted_clone_change_weight() { + let initial : Weighted = Weighted {weight: 1, item: 1}; + let mut clone = initial.clone(); + clone.weight = 5; + assert_eq!(initial.weight, clone.weight); + } + + #[test] #[should_panic] + fn test_weighted_clone_change_item() { + let initial : Weighted = Weighted {weight: 1, item: 1}; + let mut clone = initial.clone(); + clone.item = 5; + assert_eq!(initial.item, clone.item); + + } + + #[test] #[should_panic] + fn test_weighted_choice_no_items() { + WeightedChoice::::new(&mut []); + } + #[test] #[should_panic] + fn test_weighted_choice_zero_weight() { + WeightedChoice::new(&mut [Weighted { weight: 0, item: 0}, + Weighted { weight: 0, item: 1}]); + } + #[test] #[should_panic] + fn test_weighted_choice_weight_overflows() { + let x = ::core::u32::MAX / 2; // x + x + 2 is the overflow + WeightedChoice::new(&mut [Weighted { weight: x, item: 0 }, + Weighted { weight: 1, item: 1 }, + Weighted { weight: x, item: 2 }, + Weighted { weight: 1, item: 3 }]); + } + + #[test] #[allow(deprecated)] + fn test_backwards_compat_sample() { + use distributions::{Sample, IndependentSample}; + + struct Constant { val: T } + impl Sample for Constant { + fn sample(&mut self, _: &mut R) -> T { self.val } + } + impl IndependentSample for Constant { + fn ind_sample(&self, _: &mut R) -> T { self.val } + } + + let mut sampler = Constant{ val: 293 }; + assert_eq!(sampler.sample(&mut ::test::rng(233)), 293); + assert_eq!(sampler.ind_sample(&mut ::test::rng(234)), 293); + } + + #[cfg(feature="std")] + #[test] #[allow(deprecated)] + fn test_backwards_compat_exp() { + use distributions::{IndependentSample, Exp}; + let sampler = Exp::new(1.0); + sampler.ind_sample(&mut ::test::rng(235)); + } + + #[cfg(feature="std")] + #[test] + fn test_distributions_iter() { + use distributions::Normal; + let mut rng = ::test::rng(210); + let distr = Normal::new(10.0, 10.0); + let results: Vec<_> = distr.sample_iter(&mut rng).take(100).collect(); + println!("{:?}", results); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/normal.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/normal.rs new file mode 100644 index 0000000..f053fb6 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/normal.rs @@ -0,0 +1,192 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The normal and derived distributions. + +use Rng; +use distributions::{ziggurat, ziggurat_tables, Distribution, Open01}; + +/// Samples floating-point numbers according to the normal distribution +/// `N(0, 1)` (a.k.a. a standard normal, or Gaussian). This is equivalent to +/// `Normal::new(0.0, 1.0)` but faster. +/// +/// See `Normal` for the general normal distribution. +/// +/// Implemented via the ZIGNOR variant[^1] of the Ziggurat method. +/// +/// [^1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to +/// Generate Normal Random Samples*]( +/// https://www.doornik.com/research/ziggurat.pdf). +/// Nuffield College, Oxford +/// +/// # Example +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::StandardNormal; +/// +/// let val: f64 = SmallRng::from_entropy().sample(StandardNormal); +/// println!("{}", val); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct StandardNormal; + +impl Distribution for StandardNormal { + fn sample(&self, rng: &mut R) -> f64 { + #[inline] + fn pdf(x: f64) -> f64 { + (-x*x/2.0).exp() + } + #[inline] + fn zero_case(rng: &mut R, u: f64) -> f64 { + // compute a random number in the tail by hand + + // strange initial conditions, because the loop is not + // do-while, so the condition should be true on the first + // run, they get overwritten anyway (0 < 1, so these are + // good). + let mut x = 1.0f64; + let mut y = 0.0f64; + + while -2.0 * y < x * x { + let x_: f64 = rng.sample(Open01); + let y_: f64 = rng.sample(Open01); + + x = x_.ln() / ziggurat_tables::ZIG_NORM_R; + y = y_.ln(); + } + + if u < 0.0 { x - ziggurat_tables::ZIG_NORM_R } else { ziggurat_tables::ZIG_NORM_R - x } + } + + ziggurat(rng, true, // this is symmetric + &ziggurat_tables::ZIG_NORM_X, + &ziggurat_tables::ZIG_NORM_F, + pdf, zero_case) + } +} + +/// The normal distribution `N(mean, std_dev**2)`. +/// +/// This uses the ZIGNOR variant of the Ziggurat method, see `StandardNormal` +/// for more details. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Normal, Distribution}; +/// +/// // mean 2, standard deviation 3 +/// let normal = Normal::new(2.0, 3.0); +/// let v = normal.sample(&mut rand::thread_rng()); +/// println!("{} is from a N(2, 9) distribution", v) +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Normal { + mean: f64, + std_dev: f64, +} + +impl Normal { + /// Construct a new `Normal` distribution with the given mean and + /// standard deviation. + /// + /// # Panics + /// + /// Panics if `std_dev < 0`. + #[inline] + pub fn new(mean: f64, std_dev: f64) -> Normal { + assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0"); + Normal { + mean, + std_dev + } + } +} +impl Distribution for Normal { + fn sample(&self, rng: &mut R) -> f64 { + let n = rng.sample(StandardNormal); + self.mean + self.std_dev * n + } +} + + +/// The log-normal distribution `ln N(mean, std_dev**2)`. +/// +/// If `X` is log-normal distributed, then `ln(X)` is `N(mean, std_dev**2)` +/// distributed. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{LogNormal, Distribution}; +/// +/// // mean 2, standard deviation 3 +/// let log_normal = LogNormal::new(2.0, 3.0); +/// let v = log_normal.sample(&mut rand::thread_rng()); +/// println!("{} is from an ln N(2, 9) distribution", v) +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct LogNormal { + norm: Normal +} + +impl LogNormal { + /// Construct a new `LogNormal` distribution with the given mean + /// and standard deviation. + /// + /// # Panics + /// + /// Panics if `std_dev < 0`. + #[inline] + pub fn new(mean: f64, std_dev: f64) -> LogNormal { + assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0"); + LogNormal { norm: Normal::new(mean, std_dev) } + } +} +impl Distribution for LogNormal { + fn sample(&self, rng: &mut R) -> f64 { + self.norm.sample(rng).exp() + } +} + +#[cfg(test)] +mod tests { + use distributions::Distribution; + use super::{Normal, LogNormal}; + + #[test] + fn test_normal() { + let norm = Normal::new(10.0, 10.0); + let mut rng = ::test::rng(210); + for _ in 0..1000 { + norm.sample(&mut rng); + } + } + #[test] + #[should_panic] + fn test_normal_invalid_sd() { + Normal::new(10.0, -1.0); + } + + + #[test] + fn test_log_normal() { + let lnorm = LogNormal::new(10.0, 10.0); + let mut rng = ::test::rng(211); + for _ in 0..1000 { + lnorm.sample(&mut rng); + } + } + #[test] + #[should_panic] + fn test_log_normal_invalid_sd() { + LogNormal::new(10.0, -1.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/other.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/other.rs new file mode 100644 index 0000000..f23d2b8 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/other.rs @@ -0,0 +1,215 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The implementations of the `Standard` distribution for other built-in types. + +use core::char; +use core::num::Wrapping; + +use {Rng}; +use distributions::{Distribution, Standard, Uniform}; + +// ----- Sampling distributions ----- + +/// Sample a `char`, uniformly distributed over ASCII letters and numbers: +/// a-z, A-Z and 0-9. +/// +/// # Example +/// +/// ``` +/// use std::iter; +/// use rand::{Rng, thread_rng}; +/// use rand::distributions::Alphanumeric; +/// +/// let mut rng = thread_rng(); +/// let chars: String = iter::repeat(()) +/// .map(|()| rng.sample(Alphanumeric)) +/// .take(7) +/// .collect(); +/// println!("Random chars: {}", chars); +/// ``` +#[derive(Debug)] +pub struct Alphanumeric; + + +// ----- Implementations of distributions ----- + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> char { + let range = Uniform::new(0u32, 0x11_0000); + loop { + match char::from_u32(range.sample(rng)) { + Some(c) => return c, + // About 0.2% of numbers in the range 0..0x110000 are invalid + // codepoints (surrogates). + None => {} + } + } + } +} + +impl Distribution for Alphanumeric { + fn sample(&self, rng: &mut R) -> char { + const RANGE: u32 = 26 + 26 + 10; + const GEN_ASCII_STR_CHARSET: &[u8] = + b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ + abcdefghijklmnopqrstuvwxyz\ + 0123456789"; + // We can pick from 62 characters. This is so close to a power of 2, 64, + // that we can do better than `Uniform`. Use a simple bitshift and + // rejection sampling. We do not use a bitmask, because for small RNGs + // the most significant bits are usually of higher quality. + loop { + let var = rng.next_u32() >> (32 - 6); + if var < RANGE { + return GEN_ASCII_STR_CHARSET[var as usize] as char + } + } + } +} + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> bool { + // We can compare against an arbitrary bit of an u32 to get a bool. + // Because the least significant bits of a lower quality RNG can have + // simple patterns, we compare against the most significant bit. This is + // easiest done using a sign test. + (rng.next_u32() as i32) < 0 + } +} + +macro_rules! tuple_impl { + // use variables to indicate the arity of the tuple + ($($tyvar:ident),* ) => { + // the trailing commas are for the 1 tuple + impl< $( $tyvar ),* > + Distribution<( $( $tyvar ),* , )> + for Standard + where $( Standard: Distribution<$tyvar> ),* + { + #[inline] + fn sample(&self, _rng: &mut R) -> ( $( $tyvar ),* , ) { + ( + // use the $tyvar's to get the appropriate number of + // repeats (they're not actually needed) + $( + _rng.gen::<$tyvar>() + ),* + , + ) + } + } + } +} + +impl Distribution<()> for Standard { + #[inline] + fn sample(&self, _: &mut R) -> () { () } +} +tuple_impl!{A} +tuple_impl!{A, B} +tuple_impl!{A, B, C} +tuple_impl!{A, B, C, D} +tuple_impl!{A, B, C, D, E} +tuple_impl!{A, B, C, D, E, F} +tuple_impl!{A, B, C, D, E, F, G} +tuple_impl!{A, B, C, D, E, F, G, H} +tuple_impl!{A, B, C, D, E, F, G, H, I} +tuple_impl!{A, B, C, D, E, F, G, H, I, J} +tuple_impl!{A, B, C, D, E, F, G, H, I, J, K} +tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L} + +macro_rules! array_impl { + // recursive, given at least one type parameter: + {$n:expr, $t:ident, $($ts:ident,)*} => { + array_impl!{($n - 1), $($ts,)*} + + impl Distribution<[T; $n]> for Standard where Standard: Distribution { + #[inline] + fn sample(&self, _rng: &mut R) -> [T; $n] { + [_rng.gen::<$t>(), $(_rng.gen::<$ts>()),*] + } + } + }; + // empty case: + {$n:expr,} => { + impl Distribution<[T; $n]> for Standard { + fn sample(&self, _rng: &mut R) -> [T; $n] { [] } + } + }; +} + +array_impl!{32, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,} + +impl Distribution> for Standard where Standard: Distribution { + #[inline] + fn sample(&self, rng: &mut R) -> Option { + // UFCS is needed here: https://github.com/rust-lang/rust/issues/24066 + if rng.gen::() { + Some(rng.gen()) + } else { + None + } + } +} + +impl Distribution> for Standard where Standard: Distribution { + #[inline] + fn sample(&self, rng: &mut R) -> Wrapping { + Wrapping(rng.gen()) + } +} + + +#[cfg(test)] +mod tests { + use {Rng, RngCore, Standard}; + use distributions::Alphanumeric; + #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::string::String; + + #[test] + fn test_misc() { + let rng: &mut RngCore = &mut ::test::rng(820); + + rng.sample::(Standard); + rng.sample::(Standard); + } + + #[cfg(feature="alloc")] + #[test] + fn test_chars() { + use core::iter; + let mut rng = ::test::rng(805); + + // Test by generating a relatively large number of chars, so we also + // take the rejection sampling path. + let word: String = iter::repeat(()) + .map(|()| rng.gen::()).take(1000).collect(); + assert!(word.len() != 0); + } + + #[test] + fn test_alphanumeric() { + let mut rng = ::test::rng(806); + + // Test by generating a relatively large number of chars, so we also + // take the rejection sampling path. + let mut incorrect = false; + for _ in 0..100 { + let c = rng.sample(Alphanumeric); + incorrect |= !((c >= '0' && c <= '9') || + (c >= 'A' && c <= 'Z') || + (c >= 'a' && c <= 'z') ); + } + assert!(incorrect == false); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/pareto.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/pareto.rs new file mode 100644 index 0000000..ba628e0 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/pareto.rs @@ -0,0 +1,76 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Pareto distribution. + +use Rng; +use distributions::{Distribution, OpenClosed01}; + +/// Samples floating-point numbers according to the Pareto distribution +/// +/// # Example +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::Pareto; +/// +/// let val: f64 = SmallRng::from_entropy().sample(Pareto::new(1., 2.)); +/// println!("{}", val); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Pareto { + scale: f64, + inv_neg_shape: f64, +} + +impl Pareto { + /// Construct a new Pareto distribution with given `scale` and `shape`. + /// + /// In the literature, `scale` is commonly written as xm or k and + /// `shape` is often written as α. + /// + /// # Panics + /// + /// `scale` and `shape` have to be non-zero and positive. + pub fn new(scale: f64, shape: f64) -> Pareto { + assert!((scale > 0.) & (shape > 0.)); + Pareto { scale, inv_neg_shape: -1.0 / shape } + } +} + +impl Distribution for Pareto { + fn sample(&self, rng: &mut R) -> f64 { + let u: f64 = rng.sample(OpenClosed01); + self.scale * u.powf(self.inv_neg_shape) + } +} + +#[cfg(test)] +mod tests { + use distributions::Distribution; + use super::Pareto; + + #[test] + #[should_panic] + fn invalid() { + Pareto::new(0., 0.); + } + + #[test] + fn sample() { + let scale = 1.0; + let shape = 2.0; + let d = Pareto::new(scale, shape); + let mut rng = ::test::rng(1); + for _ in 0..1000 { + let r = d.sample(&mut rng); + assert!(r >= scale); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/poisson.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/poisson.rs new file mode 100644 index 0000000..bdecb77 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/poisson.rs @@ -0,0 +1,158 @@ +// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Poisson distribution. + +use Rng; +use distributions::{Distribution, Cauchy}; +use distributions::log_gamma::log_gamma; + +/// The Poisson distribution `Poisson(lambda)`. +/// +/// This distribution has a density function: +/// `f(k) = lambda^k * exp(-lambda) / k!` for `k >= 0`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Poisson, Distribution}; +/// +/// let poi = Poisson::new(2.0); +/// let v = poi.sample(&mut rand::thread_rng()); +/// println!("{} is from a Poisson(2) distribution", v); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Poisson { + lambda: f64, + // precalculated values + exp_lambda: f64, + log_lambda: f64, + sqrt_2lambda: f64, + magic_val: f64, +} + +impl Poisson { + /// Construct a new `Poisson` with the given shape parameter + /// `lambda`. Panics if `lambda <= 0`. + pub fn new(lambda: f64) -> Poisson { + assert!(lambda > 0.0, "Poisson::new called with lambda <= 0"); + let log_lambda = lambda.ln(); + Poisson { + lambda, + exp_lambda: (-lambda).exp(), + log_lambda, + sqrt_2lambda: (2.0 * lambda).sqrt(), + magic_val: lambda * log_lambda - log_gamma(1.0 + lambda), + } + } +} + +impl Distribution for Poisson { + fn sample(&self, rng: &mut R) -> u64 { + // using the algorithm from Numerical Recipes in C + + // for low expected values use the Knuth method + if self.lambda < 12.0 { + let mut result = 0; + let mut p = 1.0; + while p > self.exp_lambda { + p *= rng.gen::(); + result += 1; + } + result - 1 + } + // high expected values - rejection method + else { + let mut int_result: u64; + + // we use the Cauchy distribution as the comparison distribution + // f(x) ~ 1/(1+x^2) + let cauchy = Cauchy::new(0.0, 1.0); + + loop { + let mut result; + let mut comp_dev; + + loop { + // draw from the Cauchy distribution + comp_dev = rng.sample(cauchy); + // shift the peak of the comparison ditribution + result = self.sqrt_2lambda * comp_dev + self.lambda; + // repeat the drawing until we are in the range of possible values + if result >= 0.0 { + break; + } + } + // now the result is a random variable greater than 0 with Cauchy distribution + // the result should be an integer value + result = result.floor(); + int_result = result as u64; + + // this is the ratio of the Poisson distribution to the comparison distribution + // the magic value scales the distribution function to a range of approximately 0-1 + // since it is not exact, we multiply the ratio by 0.9 to avoid ratios greater than 1 + // this doesn't change the resulting distribution, only increases the rate of failed drawings + let check = 0.9 * (1.0 + comp_dev * comp_dev) + * (result * self.log_lambda - log_gamma(1.0 + result) - self.magic_val).exp(); + + // check with uniform random value - if below the threshold, we are within the target distribution + if rng.gen::() <= check { + break; + } + } + int_result + } + } +} + +#[cfg(test)] +mod test { + use distributions::Distribution; + use super::Poisson; + + #[test] + fn test_poisson_10() { + let poisson = Poisson::new(10.0); + let mut rng = ::test::rng(123); + let mut sum = 0; + for _ in 0..1000 { + sum += poisson.sample(&mut rng); + } + let avg = (sum as f64) / 1000.0; + println!("Poisson average: {}", avg); + assert!((avg - 10.0).abs() < 0.5); // not 100% certain, but probable enough + } + + #[test] + fn test_poisson_15() { + // Take the 'high expected values' path + let poisson = Poisson::new(15.0); + let mut rng = ::test::rng(123); + let mut sum = 0; + for _ in 0..1000 { + sum += poisson.sample(&mut rng); + } + let avg = (sum as f64) / 1000.0; + println!("Poisson average: {}", avg); + assert!((avg - 15.0).abs() < 0.5); // not 100% certain, but probable enough + } + + #[test] + #[should_panic] + fn test_poisson_invalid_lambda_zero() { + Poisson::new(0.0); + } + + #[test] + #[should_panic] + fn test_poisson_invalid_lambda_neg() { + Poisson::new(-10.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/uniform.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/uniform.rs new file mode 100644 index 0000000..8fda031 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/uniform.rs @@ -0,0 +1,856 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A distribution uniformly sampling numbers within a given range. +//! +//! [`Uniform`] is the standard distribution to sample uniformly from a range; +//! e.g. `Uniform::new_inclusive(1, 6)` can sample integers from 1 to 6, like a +//! standard die. [`Rng::gen_range`] supports any type supported by +//! [`Uniform`]. +//! +//! This distribution is provided with support for several primitive types +//! (all integer and floating-point types) as well as `std::time::Duration`, +//! and supports extension to user-defined types via a type-specific *back-end* +//! implementation. +//! +//! The types [`UniformInt`], [`UniformFloat`] and [`UniformDuration`] are the +//! back-ends supporting sampling from primitive integer and floating-point +//! ranges as well as from `std::time::Duration`; these types do not normally +//! need to be used directly (unless implementing a derived back-end). +//! +//! # Example usage +//! +//! ``` +//! use rand::{Rng, thread_rng}; +//! use rand::distributions::Uniform; +//! +//! let mut rng = thread_rng(); +//! let side = Uniform::new(-10.0, 10.0); +//! +//! // sample between 1 and 10 points +//! for _ in 0..rng.gen_range(1, 11) { +//! // sample a point from the square with sides -10 - 10 in two dimensions +//! let (x, y) = (rng.sample(side), rng.sample(side)); +//! println!("Point: {}, {}", x, y); +//! } +//! ``` +//! +//! # Extending `Uniform` to support a custom type +//! +//! To extend [`Uniform`] to support your own types, write a back-end which +//! implements the [`UniformSampler`] trait, then implement the [`SampleUniform`] +//! helper trait to "register" your back-end. See the `MyF32` example below. +//! +//! At a minimum, the back-end needs to store any parameters needed for sampling +//! (e.g. the target range) and implement `new`, `new_inclusive` and `sample`. +//! Those methods should include an assert to check the range is valid (i.e. +//! `low < high`). The example below merely wraps another back-end. +//! +//! ``` +//! use rand::prelude::*; +//! use rand::distributions::uniform::{Uniform, SampleUniform, +//! UniformSampler, UniformFloat}; +//! +//! struct MyF32(f32); +//! +//! #[derive(Clone, Copy, Debug)] +//! struct UniformMyF32 { +//! inner: UniformFloat, +//! } +//! +//! impl UniformSampler for UniformMyF32 { +//! type X = MyF32; +//! fn new(low: Self::X, high: Self::X) -> Self { +//! UniformMyF32 { +//! inner: UniformFloat::::new(low.0, high.0), +//! } +//! } +//! fn new_inclusive(low: Self::X, high: Self::X) -> Self { +//! UniformSampler::new(low, high) +//! } +//! fn sample(&self, rng: &mut R) -> Self::X { +//! MyF32(self.inner.sample(rng)) +//! } +//! } +//! +//! impl SampleUniform for MyF32 { +//! type Sampler = UniformMyF32; +//! } +//! +//! let (low, high) = (MyF32(17.0f32), MyF32(22.0f32)); +//! let uniform = Uniform::new(low, high); +//! let x = uniform.sample(&mut thread_rng()); +//! ``` +//! +//! [`Uniform`]: struct.Uniform.html +//! [`Rng::gen_range`]: ../../trait.Rng.html#method.gen_range +//! [`SampleUniform`]: trait.SampleUniform.html +//! [`UniformSampler`]: trait.UniformSampler.html +//! [`UniformInt`]: struct.UniformInt.html +//! [`UniformFloat`]: struct.UniformFloat.html +//! [`UniformDuration`]: struct.UniformDuration.html + +#[cfg(feature = "std")] +use std::time::Duration; + +use Rng; +use distributions::Distribution; +use distributions::float::IntoFloat; + +/// Sample values uniformly between two bounds. +/// +/// [`Uniform::new`] and [`Uniform::new_inclusive`] construct a uniform +/// distribution sampling from the given range; these functions may do extra +/// work up front to make sampling of multiple values faster. +/// +/// When sampling from a constant range, many calculations can happen at +/// compile-time and all methods should be fast; for floating-point ranges and +/// the full range of integer types this should have comparable performance to +/// the `Standard` distribution. +/// +/// Steps are taken to avoid bias which might be present in naive +/// implementations; for example `rng.gen::() % 170` samples from the range +/// `[0, 169]` but is twice as likely to select numbers less than 85 than other +/// values. Further, the implementations here give more weight to the high-bits +/// generated by the RNG than the low bits, since with some RNGs the low-bits +/// are of lower quality than the high bits. +/// +/// Implementations should attempt to sample in `[low, high)` for +/// `Uniform::new(low, high)`, i.e., excluding `high`, but this may be very +/// difficult. All the primitive integer types satisfy this property, and the +/// float types normally satisfy it, but rounding may mean `high` can occur. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Distribution, Uniform}; +/// +/// fn main() { +/// let between = Uniform::from(10..10000); +/// let mut rng = rand::thread_rng(); +/// let mut sum = 0; +/// for _ in 0..1000 { +/// sum += between.sample(&mut rng); +/// } +/// println!("{}", sum); +/// } +/// ``` +/// +/// [`Uniform::new`]: struct.Uniform.html#method.new +/// [`Uniform::new_inclusive`]: struct.Uniform.html#method.new_inclusive +/// [`new`]: struct.Uniform.html#method.new +/// [`new_inclusive`]: struct.Uniform.html#method.new_inclusive +#[derive(Clone, Copy, Debug)] +pub struct Uniform { + inner: X::Sampler, +} + +impl Uniform { + /// Create a new `Uniform` instance which samples uniformly from the half + /// open range `[low, high)` (excluding `high`). Panics if `low >= high`. + pub fn new(low: X, high: X) -> Uniform { + Uniform { inner: X::Sampler::new(low, high) } + } + + /// Create a new `Uniform` instance which samples uniformly from the closed + /// range `[low, high]` (inclusive). Panics if `low > high`. + pub fn new_inclusive(low: X, high: X) -> Uniform { + Uniform { inner: X::Sampler::new_inclusive(low, high) } + } +} + +impl Distribution for Uniform { + fn sample(&self, rng: &mut R) -> X { + self.inner.sample(rng) + } +} + +/// Helper trait for creating objects using the correct implementation of +/// [`UniformSampler`] for the sampling type. +/// +/// See the [module documentation] on how to implement [`Uniform`] range +/// sampling for a custom type. +/// +/// [`UniformSampler`]: trait.UniformSampler.html +/// [module documentation]: index.html +/// [`Uniform`]: struct.Uniform.html +pub trait SampleUniform: Sized { + /// The `UniformSampler` implementation supporting type `X`. + type Sampler: UniformSampler; +} + +/// Helper trait handling actual uniform sampling. +/// +/// See the [module documentation] on how to implement [`Uniform`] range +/// sampling for a custom type. +/// +/// Implementation of [`sample_single`] is optional, and is only useful when +/// the implementation can be faster than `Self::new(low, high).sample(rng)`. +/// +/// [module documentation]: index.html +/// [`Uniform`]: struct.Uniform.html +/// [`sample_single`]: trait.UniformSampler.html#method.sample_single +pub trait UniformSampler: Sized { + /// The type sampled by this implementation. + type X; + + /// Construct self, with inclusive lower bound and exclusive upper bound + /// `[low, high)`. + /// + /// Usually users should not call this directly but instead use + /// `Uniform::new`, which asserts that `low < high` before calling this. + fn new(low: Self::X, high: Self::X) -> Self; + + /// Construct self, with inclusive bounds `[low, high]`. + /// + /// Usually users should not call this directly but instead use + /// `Uniform::new_inclusive`, which asserts that `low <= high` before + /// calling this. + fn new_inclusive(low: Self::X, high: Self::X) -> Self; + + /// Sample a value. + fn sample(&self, rng: &mut R) -> Self::X; + + /// Sample a single value uniformly from a range with inclusive lower bound + /// and exclusive upper bound `[low, high)`. + /// + /// Usually users should not call this directly but instead use + /// `Uniform::sample_single`, which asserts that `low < high` before calling + /// this. + /// + /// Via this method, implementations can provide a method optimized for + /// sampling only a single value from the specified range. The default + /// implementation simply calls `UniformSampler::new` then `sample` on the + /// result. + fn sample_single(low: Self::X, high: Self::X, rng: &mut R) + -> Self::X + { + let uniform: Self = UniformSampler::new(low, high); + uniform.sample(rng) + } +} + +impl From<::core::ops::Range> for Uniform { + fn from(r: ::core::ops::Range) -> Uniform { + Uniform::new(r.start, r.end) + } +} + +//////////////////////////////////////////////////////////////////////////////// + +// What follows are all back-ends. + + +/// The back-end implementing [`UniformSampler`] for integer types. +/// +/// Unless you are implementing [`UniformSampler`] for your own type, this type +/// should not be used directly, use [`Uniform`] instead. +/// +/// # Implementation notes +/// +/// For a closed range, the number of possible numbers we should generate is +/// `range = (high - low + 1)`. It is not possible to end up with a uniform +/// distribution if we map *all* the random integers that can be generated to +/// this range. We have to map integers from a `zone` that is a multiple of the +/// range. The rest of the integers, that cause a bias, are rejected. +/// +/// The problem with `range` is that to cover the full range of the type, it has +/// to store `unsigned_max + 1`, which can't be represented. But if the range +/// covers the full range of the type, no modulus is needed. A range of size 0 +/// can't exist, so we use that to represent this special case. Wrapping +/// arithmetic even makes representing `unsigned_max + 1` as 0 simple. +/// +/// We don't calculate `zone` directly, but first calculate the number of +/// integers to reject. To handle `unsigned_max + 1` not fitting in the type, +/// we use: +/// `ints_to_reject = (unsigned_max + 1) % range;` +/// `ints_to_reject = (unsigned_max - range + 1) % range;` +/// +/// The smallest integer PRNGs generate is `u32`. That is why for small integer +/// sizes (`i8`/`u8` and `i16`/`u16`) there is an optimization: don't pick the +/// largest zone that can fit in the small type, but pick the largest zone that +/// can fit in an `u32`. `ints_to_reject` is always less than half the size of +/// the small integer. This means the first bit of `zone` is always 1, and so +/// are all the other preceding bits of a larger integer. The easiest way to +/// grow the `zone` for the larger type is to simply sign extend it. +/// +/// An alternative to using a modulus is widening multiply: After a widening +/// multiply by `range`, the result is in the high word. Then comparing the low +/// word against `zone` makes sure our distribution is uniform. +/// +/// [`UniformSampler`]: trait.UniformSampler.html +/// [`Uniform`]: struct.Uniform.html +#[derive(Clone, Copy, Debug)] +pub struct UniformInt { + low: X, + range: X, + zone: X, +} + +macro_rules! uniform_int_impl { + ($ty:ty, $signed:ty, $unsigned:ident, + $i_large:ident, $u_large:ident) => { + impl SampleUniform for $ty { + type Sampler = UniformInt<$ty>; + } + + impl UniformSampler for UniformInt<$ty> { + // We play free and fast with unsigned vs signed here + // (when $ty is signed), but that's fine, since the + // contract of this macro is for $ty and $unsigned to be + // "bit-equal", so casting between them is a no-op. + + type X = $ty; + + #[inline] // if the range is constant, this helps LLVM to do the + // calculations at compile-time. + fn new(low: Self::X, high: Self::X) -> Self { + assert!(low < high, "Uniform::new called with `low >= high`"); + UniformSampler::new_inclusive(low, high - 1) + } + + #[inline] // if the range is constant, this helps LLVM to do the + // calculations at compile-time. + fn new_inclusive(low: Self::X, high: Self::X) -> Self { + assert!(low <= high, + "Uniform::new_inclusive called with `low > high`"); + let unsigned_max = ::core::$unsigned::MAX; + + let range = high.wrapping_sub(low).wrapping_add(1) as $unsigned; + let ints_to_reject = + if range > 0 { + (unsigned_max - range + 1) % range + } else { + 0 + }; + let zone = unsigned_max - ints_to_reject; + + UniformInt { + low: low, + // These are really $unsigned values, but store as $ty: + range: range as $ty, + zone: zone as $ty + } + } + + fn sample(&self, rng: &mut R) -> Self::X { + let range = self.range as $unsigned as $u_large; + if range > 0 { + // Grow `zone` to fit a type of at least 32 bits, by + // sign-extending it (the first bit is always 1, so are all + // the preceding bits of the larger type). + // For types that already have the right size, all the + // casting is a no-op. + let zone = self.zone as $signed as $i_large as $u_large; + loop { + let v: $u_large = rng.gen(); + let (hi, lo) = v.wmul(range); + if lo <= zone { + return self.low.wrapping_add(hi as $ty); + } + } + } else { + // Sample from the entire integer range. + rng.gen() + } + } + + fn sample_single(low: Self::X, + high: Self::X, + rng: &mut R) -> Self::X + { + assert!(low < high, + "Uniform::sample_single called with low >= high"); + let range = high.wrapping_sub(low) as $unsigned as $u_large; + let zone = + if ::core::$unsigned::MAX <= ::core::u16::MAX as $unsigned { + // Using a modulus is faster than the approximation for + // i8 and i16. I suppose we trade the cost of one + // modulus for near-perfect branch prediction. + let unsigned_max: $u_large = ::core::$u_large::MAX; + let ints_to_reject = (unsigned_max - range + 1) % range; + unsigned_max - ints_to_reject + } else { + // conservative but fast approximation + range << range.leading_zeros() + }; + + loop { + let v: $u_large = rng.gen(); + let (hi, lo) = v.wmul(range); + if lo <= zone { + return low.wrapping_add(hi as $ty); + } + } + } + } + } +} + +uniform_int_impl! { i8, i8, u8, i32, u32 } +uniform_int_impl! { i16, i16, u16, i32, u32 } +uniform_int_impl! { i32, i32, u32, i32, u32 } +uniform_int_impl! { i64, i64, u64, i64, u64 } +#[cfg(feature = "i128_support")] +uniform_int_impl! { i128, i128, u128, u128, u128 } +uniform_int_impl! { isize, isize, usize, isize, usize } +uniform_int_impl! { u8, i8, u8, i32, u32 } +uniform_int_impl! { u16, i16, u16, i32, u32 } +uniform_int_impl! { u32, i32, u32, i32, u32 } +uniform_int_impl! { u64, i64, u64, i64, u64 } +uniform_int_impl! { usize, isize, usize, isize, usize } +#[cfg(feature = "i128_support")] +uniform_int_impl! { u128, u128, u128, i128, u128 } + + +trait WideningMultiply { + type Output; + + fn wmul(self, x: RHS) -> Self::Output; +} + +macro_rules! wmul_impl { + ($ty:ty, $wide:ty, $shift:expr) => { + impl WideningMultiply for $ty { + type Output = ($ty, $ty); + + #[inline(always)] + fn wmul(self, x: $ty) -> Self::Output { + let tmp = (self as $wide) * (x as $wide); + ((tmp >> $shift) as $ty, tmp as $ty) + } + } + } +} +wmul_impl! { u8, u16, 8 } +wmul_impl! { u16, u32, 16 } +wmul_impl! { u32, u64, 32 } +#[cfg(feature = "i128_support")] +wmul_impl! { u64, u128, 64 } + +// This code is a translation of the __mulddi3 function in LLVM's +// compiler-rt. It is an optimised variant of the common method +// `(a + b) * (c + d) = ac + ad + bc + bd`. +// +// For some reason LLVM can optimise the C version very well, but +// keeps shuffeling registers in this Rust translation. +macro_rules! wmul_impl_large { + ($ty:ty, $half:expr) => { + impl WideningMultiply for $ty { + type Output = ($ty, $ty); + + #[inline(always)] + fn wmul(self, b: $ty) -> Self::Output { + const LOWER_MASK: $ty = !0 >> $half; + let mut low = (self & LOWER_MASK).wrapping_mul(b & LOWER_MASK); + let mut t = low >> $half; + low &= LOWER_MASK; + t += (self >> $half).wrapping_mul(b & LOWER_MASK); + low += (t & LOWER_MASK) << $half; + let mut high = t >> $half; + t = low >> $half; + low &= LOWER_MASK; + t += (b >> $half).wrapping_mul(self & LOWER_MASK); + low += (t & LOWER_MASK) << $half; + high += t >> $half; + high += (self >> $half).wrapping_mul(b >> $half); + + (high, low) + } + } + } +} +#[cfg(not(feature = "i128_support"))] +wmul_impl_large! { u64, 32 } +#[cfg(feature = "i128_support")] +wmul_impl_large! { u128, 64 } + +macro_rules! wmul_impl_usize { + ($ty:ty) => { + impl WideningMultiply for usize { + type Output = (usize, usize); + + #[inline(always)] + fn wmul(self, x: usize) -> Self::Output { + let (high, low) = (self as $ty).wmul(x as $ty); + (high as usize, low as usize) + } + } + } +} +#[cfg(target_pointer_width = "32")] +wmul_impl_usize! { u32 } +#[cfg(target_pointer_width = "64")] +wmul_impl_usize! { u64 } + + + +/// The back-end implementing [`UniformSampler`] for floating-point types. +/// +/// Unless you are implementing [`UniformSampler`] for your own type, this type +/// should not be used directly, use [`Uniform`] instead. +/// +/// # Implementation notes +/// +/// Instead of generating a float in the `[0, 1)` range using [`Standard`], the +/// `UniformFloat` implementation converts the output of an PRNG itself. This +/// way one or two steps can be optimized out. +/// +/// The floats are first converted to a value in the `[1, 2)` interval using a +/// transmute-based method, and then mapped to the expected range with a +/// multiply and addition. Values produced this way have what equals 22 bits of +/// random digits for an `f32`, and 52 for an `f64`. +/// +/// Currently there is no difference between [`new`] and [`new_inclusive`], +/// because the boundaries of a floats range are a bit of a fuzzy concept due to +/// rounding errors. +/// +/// [`UniformSampler`]: trait.UniformSampler.html +/// [`new`]: trait.UniformSampler.html#tymethod.new +/// [`new_inclusive`]: trait.UniformSampler.html#tymethod.new_inclusive +/// [`Uniform`]: struct.Uniform.html +/// [`Standard`]: ../struct.Standard.html +#[derive(Clone, Copy, Debug)] +pub struct UniformFloat { + scale: X, + offset: X, +} + +macro_rules! uniform_float_impl { + ($ty:ty, $bits_to_discard:expr, $next_u:ident) => { + impl SampleUniform for $ty { + type Sampler = UniformFloat<$ty>; + } + + impl UniformSampler for UniformFloat<$ty> { + type X = $ty; + + fn new(low: Self::X, high: Self::X) -> Self { + assert!(low < high, "Uniform::new called with `low >= high`"); + let scale = high - low; + let offset = low - scale; + UniformFloat { + scale: scale, + offset: offset, + } + } + + fn new_inclusive(low: Self::X, high: Self::X) -> Self { + assert!(low <= high, + "Uniform::new_inclusive called with `low > high`"); + let scale = high - low; + let offset = low - scale; + UniformFloat { + scale: scale, + offset: offset, + } + } + + fn sample(&self, rng: &mut R) -> Self::X { + // Generate a value in the range [1, 2) + let value1_2 = (rng.$next_u() >> $bits_to_discard) + .into_float_with_exponent(0); + // We don't use `f64::mul_add`, because it is not available with + // `no_std`. Furthermore, it is slower for some targets (but + // faster for others). However, the order of multiplication and + // addition is important, because on some platforms (e.g. ARM) + // it will be optimized to a single (non-FMA) instruction. + value1_2 * self.scale + self.offset + } + + fn sample_single(low: Self::X, + high: Self::X, + rng: &mut R) -> Self::X { + assert!(low < high, + "Uniform::sample_single called with low >= high"); + let scale = high - low; + let offset = low - scale; + // Generate a value in the range [1, 2) + let value1_2 = (rng.$next_u() >> $bits_to_discard) + .into_float_with_exponent(0); + // Doing multiply before addition allows some architectures to + // use a single instruction. + value1_2 * scale + offset + } + } + } +} + +uniform_float_impl! { f32, 32 - 23, next_u32 } +uniform_float_impl! { f64, 64 - 52, next_u64 } + + + +/// The back-end implementing [`UniformSampler`] for `Duration`. +/// +/// Unless you are implementing [`UniformSampler`] for your own types, this type +/// should not be used directly, use [`Uniform`] instead. +/// +/// [`UniformSampler`]: trait.UniformSampler.html +/// [`Uniform`]: struct.Uniform.html +#[cfg(feature = "std")] +#[derive(Clone, Copy, Debug)] +pub struct UniformDuration { + offset: Duration, + mode: UniformDurationMode, +} + +#[cfg(feature = "std")] +#[derive(Debug, Copy, Clone)] +enum UniformDurationMode { + Small { + nanos: Uniform, + }, + Large { + size: Duration, + secs: Uniform, + } +} + +#[cfg(feature = "std")] +impl SampleUniform for Duration { + type Sampler = UniformDuration; +} + +#[cfg(feature = "std")] +impl UniformSampler for UniformDuration { + type X = Duration; + + #[inline] + fn new(low: Duration, high: Duration) -> UniformDuration { + assert!(low < high, "Uniform::new called with `low >= high`"); + UniformDuration::new_inclusive(low, high - Duration::new(0, 1)) + } + + #[inline] + fn new_inclusive(low: Duration, high: Duration) -> UniformDuration { + assert!(low <= high, "Uniform::new_inclusive called with `low > high`"); + let size = high - low; + let nanos = size + .as_secs() + .checked_mul(1_000_000_000) + .and_then(|n| n.checked_add(size.subsec_nanos() as u64)); + + let mode = match nanos { + Some(nanos) => { + UniformDurationMode::Small { + nanos: Uniform::new_inclusive(0, nanos), + } + } + None => { + UniformDurationMode::Large { + size: size, + secs: Uniform::new_inclusive(0, size.as_secs()), + } + } + }; + + UniformDuration { + mode, + offset: low, + } + } + + #[inline] + fn sample(&self, rng: &mut R) -> Duration { + let d = match self.mode { + UniformDurationMode::Small { nanos } => { + let nanos = nanos.sample(rng); + Duration::new(nanos / 1_000_000_000, (nanos % 1_000_000_000) as u32) + } + UniformDurationMode::Large { size, secs } => { + // constant folding means this is at least as fast as `gen_range` + let nano_range = Uniform::new(0, 1_000_000_000); + loop { + let d = Duration::new(secs.sample(rng), nano_range.sample(rng)); + if d <= size { + break d; + } + } + } + }; + + self.offset + d + } +} + +#[cfg(test)] +mod tests { + use Rng; + use distributions::uniform::{Uniform, UniformSampler, UniformFloat, SampleUniform}; + + #[should_panic] + #[test] + fn test_uniform_bad_limits_equal_int() { + Uniform::new(10, 10); + } + + #[should_panic] + #[test] + fn test_uniform_bad_limits_equal_float() { + Uniform::new(10., 10.); + } + + #[test] + fn test_uniform_good_limits_equal_int() { + let mut rng = ::test::rng(804); + let dist = Uniform::new_inclusive(10, 10); + for _ in 0..20 { + assert_eq!(rng.sample(dist), 10); + } + } + + #[test] + fn test_uniform_good_limits_equal_float() { + let mut rng = ::test::rng(805); + let dist = Uniform::new_inclusive(10., 10.); + for _ in 0..20 { + assert_eq!(rng.sample(dist), 10.); + } + } + + #[should_panic] + #[test] + fn test_uniform_bad_limits_flipped_int() { + Uniform::new(10, 5); + } + + #[should_panic] + #[test] + fn test_uniform_bad_limits_flipped_float() { + Uniform::new(10., 5.); + } + + #[test] + fn test_integers() { + let mut rng = ::test::rng(251); + macro_rules! t { + ($($ty:ident),*) => {{ + $( + let v: &[($ty, $ty)] = &[(0, 10), + (10, 127), + (::core::$ty::MIN, ::core::$ty::MAX)]; + for &(low, high) in v.iter() { + let my_uniform = Uniform::new(low, high); + for _ in 0..1000 { + let v: $ty = rng.sample(my_uniform); + assert!(low <= v && v < high); + } + + let my_uniform = Uniform::new_inclusive(low, high); + for _ in 0..1000 { + let v: $ty = rng.sample(my_uniform); + assert!(low <= v && v <= high); + } + + for _ in 0..1000 { + let v: $ty = rng.gen_range(low, high); + assert!(low <= v && v < high); + } + } + )* + }} + } + t!(i8, i16, i32, i64, isize, + u8, u16, u32, u64, usize); + #[cfg(feature = "i128_support")] + t!(i128, u128) + } + + #[test] + fn test_floats() { + let mut rng = ::test::rng(252); + macro_rules! t { + ($($ty:ty),*) => {{ + $( + let v: &[($ty, $ty)] = &[(0.0, 100.0), + (-1e35, -1e25), + (1e-35, 1e-25), + (-1e35, 1e35)]; + for &(low, high) in v.iter() { + let my_uniform = Uniform::new(low, high); + for _ in 0..1000 { + let v: $ty = rng.sample(my_uniform); + assert!(low <= v && v < high); + } + } + )* + }} + } + + t!(f32, f64) + } + + #[test] + #[cfg(feature = "std")] + fn test_durations() { + use std::time::Duration; + + let mut rng = ::test::rng(253); + + let v = &[(Duration::new(10, 50000), Duration::new(100, 1234)), + (Duration::new(0, 100), Duration::new(1, 50)), + (Duration::new(0, 0), Duration::new(u64::max_value(), 999_999_999))]; + for &(low, high) in v.iter() { + let my_uniform = Uniform::new(low, high); + for _ in 0..1000 { + let v = rng.sample(my_uniform); + assert!(low <= v && v < high); + } + } + } + + #[test] + fn test_custom_uniform() { + #[derive(Clone, Copy, PartialEq, PartialOrd)] + struct MyF32 { + x: f32, + } + #[derive(Clone, Copy, Debug)] + struct UniformMyF32 { + inner: UniformFloat, + } + impl UniformSampler for UniformMyF32 { + type X = MyF32; + fn new(low: Self::X, high: Self::X) -> Self { + UniformMyF32 { + inner: UniformFloat::::new(low.x, high.x), + } + } + fn new_inclusive(low: Self::X, high: Self::X) -> Self { + UniformSampler::new(low, high) + } + fn sample(&self, rng: &mut R) -> Self::X { + MyF32 { x: self.inner.sample(rng) } + } + } + impl SampleUniform for MyF32 { + type Sampler = UniformMyF32; + } + + let (low, high) = (MyF32{ x: 17.0f32 }, MyF32{ x: 22.0f32 }); + let uniform = Uniform::new(low, high); + let mut rng = ::test::rng(804); + for _ in 0..100 { + let x: MyF32 = rng.sample(uniform); + assert!(low <= x && x < high); + } + } + + #[test] + fn test_uniform_from_std_range() { + let r = Uniform::from(2u32..7); + assert_eq!(r.inner.low, 2); + assert_eq!(r.inner.range, 5); + let r = Uniform::from(2.0f64..7.0); + assert_eq!(r.inner.offset, -3.0); + assert_eq!(r.inner.scale, 5.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/distributions/ziggurat_tables.rs b/third_party/cargo/vendor/rand-0.5.6/src/distributions/ziggurat_tables.rs new file mode 100644 index 0000000..11a2172 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/distributions/ziggurat_tables.rs @@ -0,0 +1,280 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tables for distributions which are sampled using the ziggurat +// algorithm. Autogenerated by `ziggurat_tables.py`. + +pub type ZigTable = &'static [f64; 257]; +pub const ZIG_NORM_R: f64 = 3.654152885361008796; +pub static ZIG_NORM_X: [f64; 257] = + [3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074, + 3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434, + 2.978603279880844834, 2.934366867207854224, 2.894121053612348060, 2.857138730872132548, + 2.822877396825325125, 2.790921174000785765, 2.760944005278822555, 2.732685359042827056, + 2.705933656121858100, 2.680514643284522158, 2.656283037575502437, 2.633116393630324570, + 2.610910518487548515, 2.589575986706995181, 2.569035452680536569, 2.549221550323460761, + 2.530075232158516929, 2.511544441625342294, 2.493583041269680667, 2.476149939669143318, + 2.459208374333311298, 2.442725318198956774, 2.426670984935725972, 2.411018413899685520, + 2.395743119780480601, 2.380822795170626005, 2.366237056715818632, 2.351967227377659952, + 2.337996148795031370, 2.324308018869623016, 2.310888250599850036, 2.297723348901329565, + 2.284800802722946056, 2.272108990226823888, 2.259637095172217780, 2.247375032945807760, + 2.235313384928327984, 2.223443340090905718, 2.211756642882544366, 2.200245546609647995, + 2.188902771624720689, 2.177721467738641614, 2.166695180352645966, 2.155817819875063268, + 2.145083634046203613, 2.134487182844320152, 2.124023315687815661, 2.113687150684933957, + 2.103474055713146829, 2.093379631137050279, 2.083399693996551783, 2.073530263516978778, + 2.063767547809956415, 2.054107931648864849, 2.044547965215732788, 2.035084353727808715, + 2.025713947862032960, 2.016433734904371722, 2.007240830558684852, 1.998132471356564244, + 1.989106007615571325, 1.980158896898598364, 1.971288697931769640, 1.962493064942461896, + 1.953769742382734043, 1.945116560006753925, 1.936531428273758904, 1.928012334050718257, + 1.919557336591228847, 1.911164563769282232, 1.902832208548446369, 1.894558525668710081, + 1.886341828534776388, 1.878180486290977669, 1.870072921069236838, 1.862017605397632281, + 1.854013059758148119, 1.846057850283119750, 1.838150586580728607, 1.830289919680666566, + 1.822474540091783224, 1.814703175964167636, 1.806974591348693426, 1.799287584547580199, + 1.791640986550010028, 1.784033659547276329, 1.776464495522344977, 1.768932414909077933, + 1.761436365316706665, 1.753975320315455111, 1.746548278279492994, 1.739154261283669012, + 1.731792314050707216, 1.724461502945775715, 1.717160915015540690, 1.709889657069006086, + 1.702646854797613907, 1.695431651932238548, 1.688243209434858727, 1.681080704722823338, + 1.673943330923760353, 1.666830296159286684, 1.659740822855789499, 1.652674147080648526, + 1.645629517902360339, 1.638606196773111146, 1.631603456932422036, 1.624620582830568427, + 1.617656869570534228, 1.610711622367333673, 1.603784156023583041, 1.596873794420261339, + 1.589979870021648534, 1.583101723393471438, 1.576238702733332886, 1.569390163412534456, + 1.562555467528439657, 1.555733983466554893, 1.548925085471535512, 1.542128153226347553, + 1.535342571438843118, 1.528567729435024614, 1.521803020758293101, 1.515047842773992404, + 1.508301596278571965, 1.501563685112706548, 1.494833515777718391, 1.488110497054654369, + 1.481394039625375747, 1.474683555695025516, 1.467978458615230908, 1.461278162507407830, + 1.454582081885523293, 1.447889631277669675, 1.441200224845798017, 1.434513276002946425, + 1.427828197027290358, 1.421144398672323117, 1.414461289772464658, 1.407778276843371534, + 1.401094763676202559, 1.394410150925071257, 1.387723835686884621, 1.381035211072741964, + 1.374343665770030531, 1.367648583594317957, 1.360949343030101844, 1.354245316759430606, + 1.347535871177359290, 1.340820365893152122, 1.334098153216083604, 1.327368577624624679, + 1.320630975217730096, 1.313884673146868964, 1.307128989027353860, 1.300363230327433728, + 1.293586693733517645, 1.286798664489786415, 1.279998415710333237, 1.273185207661843732, + 1.266358287014688333, 1.259516886060144225, 1.252660221891297887, 1.245787495544997903, + 1.238897891102027415, 1.231990574742445110, 1.225064693752808020, 1.218119375481726552, + 1.211153726239911244, 1.204166830140560140, 1.197157747875585931, 1.190125515422801650, + 1.183069142678760732, 1.175987612011489825, 1.168879876726833800, 1.161744859441574240, + 1.154581450355851802, 1.147388505416733873, 1.140164844363995789, 1.132909248648336975, + 1.125620459211294389, 1.118297174115062909, 1.110938046009249502, 1.103541679420268151, + 1.096106627847603487, 1.088631390649514197, 1.081114409698889389, 1.073554065787871714, + 1.065948674757506653, 1.058296483326006454, 1.050595664586207123, 1.042844313139370538, + 1.035040439828605274, 1.027181966030751292, 1.019266717460529215, 1.011292417434978441, + 1.003256679539591412, 0.995156999629943084, 0.986990747093846266, 0.978755155288937750, + 0.970447311058864615, 0.962064143217605250, 0.953602409875572654, 0.945058684462571130, + 0.936429340280896860, 0.927710533396234771, 0.918898183643734989, 0.909987953490768997, + 0.900975224455174528, 0.891855070726792376, 0.882622229578910122, 0.873271068082494550, + 0.863795545546826915, 0.854189171001560554, 0.844444954902423661, 0.834555354079518752, + 0.824512208745288633, 0.814306670128064347, 0.803929116982664893, 0.793369058833152785, + 0.782615023299588763, 0.771654424216739354, 0.760473406422083165, 0.749056662009581653, + 0.737387211425838629, 0.725446140901303549, 0.713212285182022732, 0.700661841097584448, + 0.687767892786257717, 0.674499822827436479, 0.660822574234205984, 0.646695714884388928, + 0.632072236375024632, 0.616896989996235545, 0.601104617743940417, 0.584616766093722262, + 0.567338257040473026, 0.549151702313026790, 0.529909720646495108, 0.509423329585933393, + 0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746, + 0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806, + 0.000000000000000000]; +pub static ZIG_NORM_F: [f64; 257] = + [0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872, + 0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100, + 0.011842757857943104, 0.013497450601780807, 0.015177088307982072, 0.016880083152595839, + 0.018605121275783350, 0.020351096230109354, 0.022117062707379922, 0.023902203305873237, + 0.025705804008632656, 0.027527235669693315, 0.029365939758230111, 0.031221417192023690, + 0.033093219458688698, 0.034980941461833073, 0.036884215688691151, 0.038802707404656918, + 0.040736110656078753, 0.042684144916619378, 0.044646552251446536, 0.046623094902089664, + 0.048613553216035145, 0.050617723861121788, 0.052635418276973649, 0.054666461325077916, + 0.056710690106399467, 0.058767952921137984, 0.060838108349751806, 0.062921024437977854, + 0.065016577971470438, 0.067124653828023989, 0.069245144397250269, 0.071377949059141965, + 0.073522973714240991, 0.075680130359194964, 0.077849336702372207, 0.080030515814947509, + 0.082223595813495684, 0.084428509570654661, 0.086645194450867782, 0.088873592068594229, + 0.091113648066700734, 0.093365311913026619, 0.095628536713353335, 0.097903279039215627, + 0.100189498769172020, 0.102487158942306270, 0.104796225622867056, 0.107116667775072880, + 0.109448457147210021, 0.111791568164245583, 0.114145977828255210, 0.116511665626037014, + 0.118888613443345698, 0.121276805485235437, 0.123676228202051403, 0.126086870220650349, + 0.128508722280473636, 0.130941777174128166, 0.133386029692162844, 0.135841476571757352, + 0.138308116449064322, 0.140785949814968309, 0.143274978974047118, 0.145775208006537926, + 0.148286642733128721, 0.150809290682410169, 0.153343161060837674, 0.155888264725064563, + 0.158444614156520225, 0.161012223438117663, 0.163591108232982951, 0.166181285765110071, + 0.168782774801850333, 0.171395595638155623, 0.174019770082499359, 0.176655321444406654, + 0.179302274523530397, 0.181960655600216487, 0.184630492427504539, 0.187311814224516926, + 0.190004651671193070, 0.192709036904328807, 0.195425003514885592, 0.198152586546538112, + 0.200891822495431333, 0.203642749311121501, 0.206405406398679298, 0.209179834621935651, + 0.211966076307852941, 0.214764175252008499, 0.217574176725178370, 0.220396127481011589, + 0.223230075764789593, 0.226076071323264877, 0.228934165415577484, 0.231804410825248525, + 0.234686861873252689, 0.237581574432173676, 0.240488605941449107, 0.243408015423711988, + 0.246339863502238771, 0.249284212419516704, 0.252241126056943765, 0.255210669955677150, + 0.258192911338648023, 0.261187919133763713, 0.264195763998317568, 0.267216518344631837, + 0.270250256366959984, 0.273297054069675804, 0.276356989296781264, 0.279430141762765316, + 0.282516593084849388, 0.285616426816658109, 0.288729728483353931, 0.291856585618280984, + 0.294997087801162572, 0.298151326697901342, 0.301319396102034120, 0.304501391977896274, + 0.307697412505553769, 0.310907558127563710, 0.314131931597630143, 0.317370638031222396, + 0.320623784958230129, 0.323891482377732021, 0.327173842814958593, 0.330470981380537099, + 0.333783015832108509, 0.337110066638412809, 0.340452257045945450, 0.343809713148291340, + 0.347182563958251478, 0.350570941482881204, 0.353974980801569250, 0.357394820147290515, + 0.360830600991175754, 0.364282468130549597, 0.367750569780596226, 0.371235057669821344, + 0.374736087139491414, 0.378253817247238111, 0.381788410875031348, 0.385340034841733958, + 0.388908860020464597, 0.392495061461010764, 0.396098818517547080, 0.399720314981931668, + 0.403359739222868885, 0.407017284331247953, 0.410693148271983222, 0.414387534042706784, + 0.418100649839684591, 0.421832709231353298, 0.425583931339900579, 0.429354541031341519, + 0.433144769114574058, 0.436954852549929273, 0.440785034667769915, 0.444635565397727750, + 0.448506701509214067, 0.452398706863882505, 0.456311852680773566, 0.460246417814923481, + 0.464202689050278838, 0.468180961407822172, 0.472181538469883255, 0.476204732721683788, + 0.480250865911249714, 0.484320269428911598, 0.488413284707712059, 0.492530263646148658, + 0.496671569054796314, 0.500837575128482149, 0.505028667945828791, 0.509245245998136142, + 0.513487720749743026, 0.517756517232200619, 0.522052074674794864, 0.526374847174186700, + 0.530725304406193921, 0.535103932383019565, 0.539511234259544614, 0.543947731192649941, + 0.548413963257921133, 0.552910490428519918, 0.557437893621486324, 0.561996775817277916, + 0.566587763258951771, 0.571211506738074970, 0.575868682975210544, 0.580559996103683473, + 0.585286179266300333, 0.590047996335791969, 0.594846243770991268, 0.599681752622167719, + 0.604555390700549533, 0.609468064928895381, 0.614420723892076803, 0.619414360609039205, + 0.624450015550274240, 0.629528779928128279, 0.634651799290960050, 0.639820277456438991, + 0.645035480824251883, 0.650298743114294586, 0.655611470583224665, 0.660975147780241357, + 0.666391343912380640, 0.671861719900766374, 0.677388036222513090, 0.682972161648791376, + 0.688616083008527058, 0.694321916130032579, 0.700091918140490099, 0.705928501336797409, + 0.711834248882358467, 0.717811932634901395, 0.723864533472881599, 0.729995264565802437, + 0.736207598131266683, 0.742505296344636245, 0.748892447223726720, 0.755373506511754500, + 0.761953346841546475, 0.768637315803334831, 0.775431304986138326, 0.782341832659861902, + 0.789376143571198563, 0.796542330428254619, 0.803849483176389490, 0.811307874318219935, + 0.818929191609414797, 0.826726833952094231, 0.834716292992930375, 0.842915653118441077, + 0.851346258465123684, 0.860033621203008636, 0.869008688043793165, 0.878309655816146839, + 0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247, + 0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328, + 1.000000000000000000]; +pub const ZIG_EXP_R: f64 = 7.697117470131050077; +pub static ZIG_EXP_X: [f64; 257] = + [8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696, + 6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488, + 5.323090505754398016, 5.181487281301500047, 5.054288489981304089, 4.938777085901250530, + 4.832939741025112035, 4.735242996601741083, 4.644491885420085175, 4.559737061707351380, + 4.480211746528421912, 4.405287693473573185, 4.334443680317273007, 4.267242480277365857, + 4.203313713735184365, 4.142340865664051464, 4.084051310408297830, 4.028208544647936762, + 3.974606066673788796, 3.923062500135489739, 3.873417670399509127, 3.825529418522336744, + 3.779270992411667862, 3.734528894039797375, 3.691201090237418825, 3.649195515760853770, + 3.608428813128909507, 3.568825265648337020, 3.530315889129343354, 3.492837654774059608, + 3.456332821132760191, 3.420748357251119920, 3.386035442460300970, 3.352149030900109405, + 3.319047470970748037, 3.286692171599068679, 3.255047308570449882, 3.224079565286264160, + 3.193757903212240290, 3.164053358025972873, 3.134938858084440394, 3.106389062339824481, + 3.078380215254090224, 3.050890016615455114, 3.023897504455676621, 2.997382949516130601, + 2.971327759921089662, 2.945714394895045718, 2.920526286512740821, 2.895747768600141825, + 2.871364012015536371, 2.847360965635188812, 2.823725302450035279, 2.800444370250737780, + 2.777506146439756574, 2.754899196562344610, 2.732612636194700073, 2.710636095867928752, + 2.688959688741803689, 2.667573980773266573, 2.646469963151809157, 2.625639026797788489, + 2.605072938740835564, 2.584763820214140750, 2.564704126316905253, 2.544886627111869970, + 2.525304390037828028, 2.505950763528594027, 2.486819361740209455, 2.467904050297364815, + 2.449198932978249754, 2.430698339264419694, 2.412396812688870629, 2.394289099921457886, + 2.376370140536140596, 2.358635057409337321, 2.341079147703034380, 2.323697874390196372, + 2.306486858283579799, 2.289441870532269441, 2.272558825553154804, 2.255833774367219213, + 2.239262898312909034, 2.222842503111036816, 2.206569013257663858, 2.190438966723220027, + 2.174449009937774679, 2.158595893043885994, 2.142876465399842001, 2.127287671317368289, + 2.111826546019042183, 2.096490211801715020, 2.081275874393225145, 2.066180819490575526, + 2.051202409468584786, 2.036338080248769611, 2.021585338318926173, 2.006941757894518563, + 1.992404978213576650, 1.977972700957360441, 1.963642687789548313, 1.949412758007184943, + 1.935280786297051359, 1.921244700591528076, 1.907302480018387536, 1.893452152939308242, + 1.879691795072211180, 1.866019527692827973, 1.852433515911175554, 1.838931967018879954, + 1.825513128903519799, 1.812175288526390649, 1.798916770460290859, 1.785735935484126014, + 1.772631179231305643, 1.759600930889074766, 1.746643651946074405, 1.733757834985571566, + 1.720942002521935299, 1.708194705878057773, 1.695514524101537912, 1.682900062917553896, + 1.670349953716452118, 1.657862852574172763, 1.645437439303723659, 1.633072416535991334, + 1.620766508828257901, 1.608518461798858379, 1.596327041286483395, 1.584191032532688892, + 1.572109239386229707, 1.560080483527888084, 1.548103603714513499, 1.536177455041032092, + 1.524300908219226258, 1.512472848872117082, 1.500692176842816750, 1.488957805516746058, + 1.477268661156133867, 1.465623682245745352, 1.454021818848793446, 1.442462031972012504, + 1.430943292938879674, 1.419464582769983219, 1.408024891569535697, 1.396623217917042137, + 1.385258568263121992, 1.373929956328490576, 1.362636402505086775, 1.351376933258335189, + 1.340150580529504643, 1.328956381137116560, 1.317793376176324749, 1.306660610415174117, + 1.295557131686601027, 1.284481990275012642, 1.273434238296241139, 1.262412929069615330, + 1.251417116480852521, 1.240445854334406572, 1.229498195693849105, 1.218573192208790124, + 1.207669893426761121, 1.196787346088403092, 1.185924593404202199, 1.175080674310911677, + 1.164254622705678921, 1.153445466655774743, 1.142652227581672841, 1.131873919411078511, + 1.121109547701330200, 1.110358108727411031, 1.099618588532597308, 1.088889961938546813, + 1.078171191511372307, 1.067461226479967662, 1.056759001602551429, 1.046063435977044209, + 1.035373431790528542, 1.024687873002617211, 1.014005623957096480, 1.003325527915696735, + 0.992646405507275897, 0.981967053085062602, 0.971286240983903260, 0.960602711668666509, + 0.949915177764075969, 0.939222319955262286, 0.928522784747210395, 0.917815182070044311, + 0.907098082715690257, 0.896370015589889935, 0.885629464761751528, 0.874874866291025066, + 0.864104604811004484, 0.853317009842373353, 0.842510351810368485, 0.831682837734273206, + 0.820832606554411814, 0.809957724057418282, 0.799056177355487174, 0.788125868869492430, + 0.777164609759129710, 0.766170112735434672, 0.755139984181982249, 0.744071715500508102, + 0.732962673584365398, 0.721810090308756203, 0.710611050909655040, 0.699362481103231959, + 0.688061132773747808, 0.676703568029522584, 0.665286141392677943, 0.653804979847664947, + 0.642255960424536365, 0.630634684933490286, 0.618936451394876075, 0.607156221620300030, + 0.595288584291502887, 0.583327712748769489, 0.571267316532588332, 0.559100585511540626, + 0.546820125163310577, 0.534417881237165604, 0.521885051592135052, 0.509211982443654398, + 0.496388045518671162, 0.483401491653461857, 0.470239275082169006, 0.456886840931420235, + 0.443327866073552401, 0.429543940225410703, 0.415514169600356364, 0.401214678896277765, + 0.386617977941119573, 0.371692145329917234, 0.356399760258393816, 0.340696481064849122, + 0.324529117016909452, 0.307832954674932158, 0.290527955491230394, 0.272513185478464703, + 0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842, + 0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570, + 0.000000000000000000]; +pub static ZIG_EXP_F: [f64; 257] = + [0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573, + 0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797, + 0.004877655983542396, 0.005619642207205489, 0.006381905937319183, 0.007163353183634991, + 0.007963077438017043, 0.008780314985808977, 0.009614413642502212, 0.010464810181029981, + 0.011331013597834600, 0.012212592426255378, 0.013109164931254991, 0.014020391403181943, + 0.014945968011691148, 0.015885621839973156, 0.016839106826039941, 0.017806200410911355, + 0.018786700744696024, 0.019780424338009740, 0.020787204072578114, 0.021806887504283581, + 0.022839335406385240, 0.023884420511558174, 0.024942026419731787, 0.026012046645134221, + 0.027094383780955803, 0.028188948763978646, 0.029295660224637411, 0.030414443910466622, + 0.031545232172893622, 0.032687963508959555, 0.033842582150874358, 0.035009037697397431, + 0.036187284781931443, 0.037377282772959382, 0.038578995503074871, 0.039792391023374139, + 0.041017441380414840, 0.042254122413316254, 0.043502413568888197, 0.044762297732943289, + 0.046033761076175184, 0.047316792913181561, 0.048611385573379504, 0.049917534282706379, + 0.051235237055126281, 0.052564494593071685, 0.053905310196046080, 0.055257689676697030, + 0.056621641283742870, 0.057997175631200659, 0.059384305633420280, 0.060783046445479660, + 0.062193415408541036, 0.063615431999807376, 0.065049117786753805, 0.066494496385339816, + 0.067951593421936643, 0.069420436498728783, 0.070901055162371843, 0.072393480875708752, + 0.073897746992364746, 0.075413888734058410, 0.076941943170480517, 0.078481949201606435, + 0.080033947542319905, 0.081597980709237419, 0.083174093009632397, 0.084762330532368146, + 0.086362741140756927, 0.087975374467270231, 0.089600281910032886, 0.091237516631040197, + 0.092887133556043569, 0.094549189376055873, 0.096223742550432825, 0.097910853311492213, + 0.099610583670637132, 0.101322997425953631, 0.103048160171257702, 0.104786139306570145, + 0.106537004050001632, 0.108300825451033755, 0.110077676405185357, 0.111867631670056283, + 0.113670767882744286, 0.115487163578633506, 0.117316899211555525, 0.119160057175327641, + 0.121016721826674792, 0.122886979509545108, 0.124770918580830933, 0.126668629437510671, + 0.128580204545228199, 0.130505738468330773, 0.132445327901387494, 0.134399071702213602, + 0.136367070926428829, 0.138349428863580176, 0.140346251074862399, 0.142357645432472146, + 0.144383722160634720, 0.146424593878344889, 0.148480375643866735, 0.150551185001039839, + 0.152637142027442801, 0.154738369384468027, 0.156854992369365148, 0.158987138969314129, + 0.161134939917591952, 0.163298528751901734, 0.165478041874935922, 0.167673618617250081, + 0.169885401302527550, 0.172113535315319977, 0.174358169171353411, 0.176619454590494829, + 0.178897546572478278, 0.181192603475496261, 0.183504787097767436, 0.185834262762197083, + 0.188181199404254262, 0.190545769663195363, 0.192928149976771296, 0.195328520679563189, + 0.197747066105098818, 0.200183974691911210, 0.202639439093708962, 0.205113656293837654, + 0.207606827724221982, 0.210119159388988230, 0.212650861992978224, 0.215202151075378628, + 0.217773247148700472, 0.220364375843359439, 0.222975768058120111, 0.225607660116683956, + 0.228260293930716618, 0.230933917169627356, 0.233628783437433291, 0.236345152457059560, + 0.239083290262449094, 0.241843469398877131, 0.244625969131892024, 0.247431075665327543, + 0.250259082368862240, 0.253110290015629402, 0.255985007030415324, 0.258883549749016173, + 0.261806242689362922, 0.264753418835062149, 0.267725419932044739, 0.270722596799059967, + 0.273745309652802915, 0.276793928448517301, 0.279868833236972869, 0.282970414538780746, + 0.286099073737076826, 0.289255223489677693, 0.292439288161892630, 0.295651704281261252, + 0.298892921015581847, 0.302163400675693528, 0.305463619244590256, 0.308794066934560185, + 0.312155248774179606, 0.315547685227128949, 0.318971912844957239, 0.322428484956089223, + 0.325917972393556354, 0.329440964264136438, 0.332998068761809096, 0.336589914028677717, + 0.340217149066780189, 0.343880444704502575, 0.347580494621637148, 0.351318016437483449, + 0.355093752866787626, 0.358908472948750001, 0.362762973354817997, 0.366658079781514379, + 0.370594648435146223, 0.374573567615902381, 0.378595759409581067, 0.382662181496010056, + 0.386773829084137932, 0.390931736984797384, 0.395136981833290435, 0.399390684475231350, + 0.403694012530530555, 0.408048183152032673, 0.412454465997161457, 0.416914186433003209, + 0.421428728997616908, 0.425999541143034677, 0.430628137288459167, 0.435316103215636907, + 0.440065100842354173, 0.444876873414548846, 0.449753251162755330, 0.454696157474615836, + 0.459707615642138023, 0.464789756250426511, 0.469944825283960310, 0.475175193037377708, + 0.480483363930454543, 0.485871987341885248, 0.491343869594032867, 0.496901987241549881, + 0.502549501841348056, 0.508289776410643213, 0.514126393814748894, 0.520063177368233931, + 0.526104213983620062, 0.532253880263043655, 0.538516872002862246, 0.544898237672440056, + 0.551403416540641733, 0.558038282262587892, 0.564809192912400615, 0.571723048664826150, + 0.578787358602845359, 0.586010318477268366, 0.593400901691733762, 0.600968966365232560, + 0.608725382079622346, 0.616682180915207878, 0.624852738703666200, 0.633251994214366398, + 0.641896716427266423, 0.650805833414571433, 0.660000841079000145, 0.669506316731925177, + 0.679350572264765806, 0.689566496117078431, 0.700192655082788606, 0.711274760805076456, + 0.722867659593572465, 0.735038092431424039, 0.747868621985195658, 0.761463388849896838, + 0.775956852040116218, 0.791527636972496285, 0.808421651523009044, 0.826993296643051101, + 0.847785500623990496, 0.871704332381204705, 0.900469929925747703, 0.938143680862176477, + 1.000000000000000000]; diff --git a/third_party/cargo/vendor/rand-0.5.6/src/lib.rs b/third_party/cargo/vendor/rand-0.5.6/src/lib.rs new file mode 100644 index 0000000..a1eb469 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/lib.rs @@ -0,0 +1,1238 @@ +// Copyright 2013-2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Utilities for random number generation +//! +//! Rand provides utilities to generate random numbers, to convert them to +//! useful types and distributions, and some randomness-related algorithms. +//! +//! # Basic usage +//! +//! To get you started quickly, the easiest and highest-level way to get +//! a random value is to use [`random()`]. +//! +//! ``` +//! let x: u8 = rand::random(); +//! println!("{}", x); +//! +//! let y = rand::random::(); +//! println!("{}", y); +//! +//! if rand::random() { // generates a boolean +//! println!("Heads!"); +//! } +//! ``` +//! +//! This supports generating most common types but is not very flexible, thus +//! you probably want to learn a bit more about the Rand library. +//! +//! +//! # The two-step process to get a random value +//! +//! Generating random values is typically a two-step process: +//! +//! - get some *random data* (an integer or bit/byte sequence) from a random +//! number generator (RNG); +//! - use some function to transform that *data* into the type of value you want +//! (this function is an implementation of some *distribution* describing the +//! kind of value produced). +//! +//! Rand represents the first step with the [`RngCore`] trait and the second +//! step via a combination of the [`Rng`] extension trait and the +//! [`distributions` module]. +//! In practice you probably won't use [`RngCore`] directly unless you are +//! implementing a random number generator (RNG). +//! +//! There are many kinds of RNGs, with different trade-offs. You can read more +//! about them in the [`rngs` module] and even more in the [`prng` module], +//! however, often you can just use [`thread_rng()`]. This function +//! automatically initializes an RNG in thread-local memory, then returns a +//! reference to it. It is fast, good quality, and secure (unpredictable). +//! +//! To turn the output of the RNG into something usable, you usually want to use +//! the methods from the [`Rng`] trait. Some of the most useful methods are: +//! +//! - [`gen`] generates a random value appropriate for the type (just like +//! [`random()`]). For integers this is normally the full representable range +//! (e.g. from `0u32` to `std::u32::MAX`), for floats this is between 0 and 1, +//! and some other types are supported, including arrays and tuples. See the +//! [`Standard`] distribution which provides the implementations. +//! - [`gen_range`] samples from a specific range of values; this is like +//! [`gen`] but with specific upper and lower bounds. +//! - [`sample`] samples directly from some distribution. +//! +//! [`random()`] is defined using just the above: `thread_rng().gen()`. +//! +//! ## Distributions +//! +//! What are distributions, you ask? Specifying only the type and range of +//! values (known as the *sample space*) is not enough; samples must also have +//! a *probability distribution*, describing the relative probability of +//! sampling each value in that space. +//! +//! In many cases a *uniform* distribution is used, meaning roughly that each +//! value is equally likely (or for "continuous" types like floats, that each +//! equal-sized sub-range has the same probability of containing a sample). +//! [`gen`] and [`gen_range`] both use statistically uniform distributions. +//! +//! The [`distributions` module] provides implementations +//! of some other distributions, including Normal, Log-Normal and Exponential. +//! +//! It is worth noting that the functionality already mentioned is implemented +//! with distributions: [`gen`] samples values using the [`Standard`] +//! distribution, while [`gen_range`] uses [`Uniform`]. +//! +//! ## Importing (prelude) +//! +//! The most convenient way to import items from Rand is to use the [prelude]. +//! This includes the most important parts of Rand, but only those unlikely to +//! cause name conflicts. +//! +//! Note that Rand 0.5 has significantly changed the module organization and +//! contents relative to previous versions. Where possible old names have been +//! kept (but are hidden in the documentation), however these will be removed +//! in the future. We therefore recommend migrating to use the prelude or the +//! new module organization in your imports. +//! +//! +//! ## Examples +//! +//! ``` +//! use rand::prelude::*; +//! +//! // thread_rng is often the most convenient source of randomness: +//! let mut rng = thread_rng(); +//! +//! if rng.gen() { // random bool +//! let x: f64 = rng.gen(); // random number in range [0, 1) +//! println!("x is: {}", x); +//! let ch = rng.gen::(); // using type annotation +//! println!("char is: {}", ch); +//! println!("Number from 0 to 9: {}", rng.gen_range(0, 10)); +//! } +//! ``` +//! +//! +//! # More functionality +//! +//! The [`Rng`] trait includes a few more methods not mentioned above: +//! +//! - [`Rng::sample_iter`] allows iterating over values from a chosen +//! distribution. +//! - [`Rng::gen_bool`] generates boolean "events" with a given probability. +//! - [`Rng::fill`] and [`Rng::try_fill`] are fast alternatives to fill a slice +//! of integers. +//! - [`Rng::shuffle`] randomly shuffles elements in a slice. +//! - [`Rng::choose`] picks one element at random from a slice. +//! +//! For more slice/sequence related functionality, look in the [`seq` module]. +//! +//! There is also [`distributions::WeightedChoice`], which can be used to pick +//! elements at random with some probability. But it does not work well at the +//! moment and is going through a redesign. +//! +//! +//! # Error handling +//! +//! Error handling in Rand is a compromise between simplicity and necessity. +//! Most RNGs and sampling functions will never produce errors, and making these +//! able to handle errors would add significant overhead (to code complexity +//! and ergonomics of usage at least, and potentially also performance, +//! depending on the approach). +//! However, external RNGs can fail, and being able to handle this is important. +//! +//! It has therefore been decided that *most* methods should not return a +//! `Result` type, with as exceptions [`Rng::try_fill`], +//! [`RngCore::try_fill_bytes`], and [`SeedableRng::from_rng`]. +//! +//! Note that it is the RNG that panics when it fails but is not used through a +//! method that can report errors. Currently Rand contains only three RNGs that +//! can return an error (and thus may panic), and documents this property: +//! [`OsRng`], [`EntropyRng`] and [`ReadRng`]. Other RNGs, like [`ThreadRng`] +//! and [`StdRng`], can be used with all methods without concern. +//! +//! One further problem is that if Rand is unable to get any external randomness +//! when initializing an RNG with [`EntropyRng`], it will panic in +//! [`FromEntropy::from_entropy`], and notably in [`thread_rng()`]. Except by +//! compromising security, this problem is as unsolvable as running out of +//! memory. +//! +//! +//! # Distinction between Rand and `rand_core` +//! +//! The [`rand_core`] crate provides the necessary traits and functionality for +//! implementing RNGs; this includes the [`RngCore`] and [`SeedableRng`] traits +//! and the [`Error`] type. +//! Crates implementing RNGs should depend on [`rand_core`]. +//! +//! Applications and libraries consuming random values are encouraged to use the +//! Rand crate, which re-exports the common parts of [`rand_core`]. +//! +//! +//! # More examples +//! +//! For some inspiration, see the examples: +//! +//! - [Monte Carlo estimation of π]( +//! https://github.com/rust-lang-nursery/rand/blob/master/examples/monte-carlo.rs) +//! - [Monty Hall Problem]( +//! https://github.com/rust-lang-nursery/rand/blob/master/examples/monty-hall.rs) +//! +//! +//! [`distributions` module]: distributions/index.html +//! [`distributions::WeightedChoice`]: distributions/struct.WeightedChoice.html +//! [`FromEntropy::from_entropy`]: trait.FromEntropy.html#tymethod.from_entropy +//! [`EntropyRng`]: rngs/struct.EntropyRng.html +//! [`Error`]: struct.Error.html +//! [`gen_range`]: trait.Rng.html#method.gen_range +//! [`gen`]: trait.Rng.html#method.gen +//! [`OsRng`]: rngs/struct.OsRng.html +//! [prelude]: prelude/index.html +//! [`rand_core`]: https://crates.io/crates/rand_core +//! [`random()`]: fn.random.html +//! [`ReadRng`]: rngs/adapter/struct.ReadRng.html +//! [`Rng::choose`]: trait.Rng.html#method.choose +//! [`Rng::fill`]: trait.Rng.html#method.fill +//! [`Rng::gen_bool`]: trait.Rng.html#method.gen_bool +//! [`Rng::gen`]: trait.Rng.html#method.gen +//! [`Rng::sample_iter`]: trait.Rng.html#method.sample_iter +//! [`Rng::shuffle`]: trait.Rng.html#method.shuffle +//! [`RngCore`]: trait.RngCore.html +//! [`RngCore::try_fill_bytes`]: trait.RngCore.html#method.try_fill_bytes +//! [`rngs` module]: rngs/index.html +//! [`prng` module]: prng/index.html +//! [`Rng`]: trait.Rng.html +//! [`Rng::try_fill`]: trait.Rng.html#method.try_fill +//! [`sample`]: trait.Rng.html#method.sample +//! [`SeedableRng`]: trait.SeedableRng.html +//! [`SeedableRng::from_rng`]: trait.SeedableRng.html#method.from_rng +//! [`seq` module]: seq/index.html +//! [`SmallRng`]: rngs/struct.SmallRng.html +//! [`StdRng`]: rngs/struct.StdRng.html +//! [`thread_rng()`]: fn.thread_rng.html +//! [`ThreadRng`]: rngs/struct.ThreadRng.html +//! [`Standard`]: distributions/struct.Standard.html +//! [`Uniform`]: distributions/struct.Uniform.html + + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://docs.rs/rand/0.5.6")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] + +#![cfg_attr(not(feature="std"), no_std)] +#![cfg_attr(all(feature="alloc", not(feature="std")), feature(alloc))] +#![cfg_attr(all(feature="i128_support", feature="nightly"), allow(stable_features))] // stable since 2018-03-27 +#![cfg_attr(all(feature="i128_support", feature="nightly"), feature(i128_type, i128))] +#![cfg_attr(feature = "stdweb", recursion_limit="128")] + +#[cfg(feature="std")] extern crate std as core; +#[cfg(all(feature = "alloc", not(feature="std")))] extern crate alloc; + +#[cfg(test)] #[cfg(feature="serde1")] extern crate bincode; +#[cfg(feature="serde1")] extern crate serde; +#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive; + +#[cfg(all(target_arch="wasm32", not(target_os="emscripten"), feature="stdweb"))] +#[macro_use] +extern crate stdweb; + +extern crate rand_core; + +#[cfg(feature = "log")] #[macro_use] extern crate log; +#[allow(unused)] +#[cfg(not(feature = "log"))] macro_rules! trace { ($($x:tt)*) => () } +#[allow(unused)] +#[cfg(not(feature = "log"))] macro_rules! debug { ($($x:tt)*) => () } +#[allow(unused)] +#[cfg(not(feature = "log"))] macro_rules! info { ($($x:tt)*) => () } +#[allow(unused)] +#[cfg(not(feature = "log"))] macro_rules! warn { ($($x:tt)*) => () } +#[allow(unused)] +#[cfg(not(feature = "log"))] macro_rules! error { ($($x:tt)*) => () } + + +// Re-exports from rand_core +pub use rand_core::{RngCore, CryptoRng, SeedableRng}; +pub use rand_core::{ErrorKind, Error}; + +// Public exports +#[cfg(feature="std")] pub use rngs::thread::thread_rng; + +// Public modules +pub mod distributions; +pub mod prelude; +pub mod prng; +pub mod rngs; +#[cfg(feature = "alloc")] pub mod seq; + +//////////////////////////////////////////////////////////////////////////////// +// Compatibility re-exports. Documentation is hidden; will be removed eventually. + +#[cfg(feature="std")] #[doc(hidden)] pub use rngs::adapter::read; +#[doc(hidden)] pub use rngs::adapter::ReseedingRng; + +#[allow(deprecated)] +#[cfg(feature="std")] #[doc(hidden)] pub use rngs::EntropyRng; + +#[allow(deprecated)] +#[cfg(all(feature="std", + any(target_os = "linux", target_os = "android", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "haiku", + target_os = "emscripten", + target_os = "solaris", + target_os = "cloudabi", + target_os = "macos", target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", target_os = "bitrig", + target_os = "redox", + target_os = "fuchsia", + windows, + all(target_arch = "wasm32", feature = "stdweb") +)))] +#[doc(hidden)] +pub use rngs::OsRng; + +#[doc(hidden)] pub use prng::{ChaChaRng, IsaacRng, Isaac64Rng, XorShiftRng}; +#[doc(hidden)] pub use rngs::StdRng; + + +#[allow(deprecated)] +#[doc(hidden)] +pub mod jitter { + pub use rngs::{JitterRng, TimerError}; +} +#[allow(deprecated)] +#[cfg(all(feature="std", + any(target_os = "linux", target_os = "android", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "haiku", + target_os = "emscripten", + target_os = "solaris", + target_os = "cloudabi", + target_os = "macos", target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", target_os = "bitrig", + target_os = "redox", + target_os = "fuchsia", + windows, + all(target_arch = "wasm32", feature = "stdweb") +)))] +#[doc(hidden)] +pub mod os { + pub use rngs::OsRng; +} +#[allow(deprecated)] +#[doc(hidden)] +pub mod chacha { + //! The ChaCha random number generator. + pub use prng::ChaChaRng; +} +#[doc(hidden)] +pub mod isaac { + //! The ISAAC random number generator. + pub use prng::{IsaacRng, Isaac64Rng}; +} + +#[cfg(feature="std")] #[doc(hidden)] pub use rngs::ThreadRng; + +//////////////////////////////////////////////////////////////////////////////// + + +use core::{marker, mem, slice}; +use distributions::{Distribution, Standard}; +use distributions::uniform::{SampleUniform, UniformSampler}; + + +/// A type that can be randomly generated using an [`Rng`]. +/// +/// This is merely an adapter around the [`Standard`] distribution for +/// convenience and backwards-compatibility. +/// +/// [`Rng`]: trait.Rng.html +/// [`Standard`]: distributions/struct.Standard.html +#[deprecated(since="0.5.0", note="replaced by distributions::Standard")] +pub trait Rand : Sized { + /// Generates a random instance of this type using the specified source of + /// randomness. + fn rand(rng: &mut R) -> Self; +} + +/// An automatically-implemented extension trait on [`RngCore`] providing high-level +/// generic methods for sampling values and other convenience methods. +/// +/// This is the primary trait to use when generating random values. +/// +/// # Generic usage +/// +/// The basic pattern is `fn foo(rng: &mut R)`. Some +/// things are worth noting here: +/// +/// - Since `Rng: RngCore` and every `RngCore` implements `Rng`, it makes no +/// difference whether we use `R: Rng` or `R: RngCore`. +/// - The `+ ?Sized` un-bounding allows functions to be called directly on +/// type-erased references; i.e. `foo(r)` where `r: &mut RngCore`. Without +/// this it would be necessary to write `foo(&mut r)`. +/// +/// An alternative pattern is possible: `fn foo(rng: R)`. This has some +/// trade-offs. It allows the argument to be consumed directly without a `&mut` +/// (which is how `from_rng(thread_rng())` works); also it still works directly +/// on references (including type-erased references). Unfortunately within the +/// function `foo` it is not known whether `rng` is a reference type or not, +/// hence many uses of `rng` require an extra reference, either explicitly +/// (`distr.sample(&mut rng)`) or implicitly (`rng.gen()`); one may hope the +/// optimiser can remove redundant references later. +/// +/// Example: +/// +/// ``` +/// # use rand::thread_rng; +/// use rand::Rng; +/// +/// fn foo(rng: &mut R) -> f32 { +/// rng.gen() +/// } +/// +/// # let v = foo(&mut thread_rng()); +/// ``` +/// +/// [`RngCore`]: trait.RngCore.html +pub trait Rng: RngCore { + /// Return a random value supporting the [`Standard`] distribution. + /// + /// [`Standard`]: distributions/struct.Standard.html + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// let x: u32 = rng.gen(); + /// println!("{}", x); + /// println!("{:?}", rng.gen::<(f64, bool)>()); + /// ``` + #[inline] + fn gen(&mut self) -> T where Standard: Distribution { + Standard.sample(self) + } + + /// Generate a random value in the range [`low`, `high`), i.e. inclusive of + /// `low` and exclusive of `high`. + /// + /// This function is optimised for the case that only a single sample is + /// made from the given range. See also the [`Uniform`] distribution + /// type which may be faster if sampling from the same range repeatedly. + /// + /// # Panics + /// + /// Panics if `low >= high`. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// let n: u32 = rng.gen_range(0, 10); + /// println!("{}", n); + /// let m: f64 = rng.gen_range(-40.0f64, 1.3e5f64); + /// println!("{}", m); + /// ``` + /// + /// [`Uniform`]: distributions/uniform/struct.Uniform.html + fn gen_range(&mut self, low: T, high: T) -> T { + T::Sampler::sample_single(low, high, self) + } + + /// Sample a new value, using the given distribution. + /// + /// ### Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// use rand::distributions::Uniform; + /// + /// let mut rng = thread_rng(); + /// let x = rng.sample(Uniform::new(10u32, 15)); + /// // Type annotation requires two types, the type and distribution; the + /// // distribution can be inferred. + /// let y = rng.sample::(Uniform::new(10, 15)); + /// ``` + fn sample>(&mut self, distr: D) -> T { + distr.sample(self) + } + + /// Create an iterator that generates values using the given distribution. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// use rand::distributions::{Alphanumeric, Uniform, Standard}; + /// + /// let mut rng = thread_rng(); + /// + /// // Vec of 16 x f32: + /// let v: Vec = thread_rng().sample_iter(&Standard).take(16).collect(); + /// + /// // String: + /// let s: String = rng.sample_iter(&Alphanumeric).take(7).collect(); + /// + /// // Combined values + /// println!("{:?}", thread_rng().sample_iter(&Standard).take(5) + /// .collect::>()); + /// + /// // Dice-rolling: + /// let die_range = Uniform::new_inclusive(1, 6); + /// let mut roll_die = rng.sample_iter(&die_range); + /// while roll_die.next().unwrap() != 6 { + /// println!("Not a 6; rolling again!"); + /// } + /// ``` + fn sample_iter<'a, T, D: Distribution>(&'a mut self, distr: &'a D) + -> distributions::DistIter<'a, D, Self, T> where Self: Sized + { + distr.sample_iter(self) + } + + /// Fill `dest` entirely with random bytes (uniform value distribution), + /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices + /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.). + /// + /// On big-endian platforms this performs byte-swapping to ensure + /// portability of results from reproducible generators. + /// + /// This uses [`fill_bytes`] internally which may handle some RNG errors + /// implicitly (e.g. waiting if the OS generator is not ready), but panics + /// on other errors. See also [`try_fill`] which returns errors. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut arr = [0i8; 20]; + /// thread_rng().fill(&mut arr[..]); + /// ``` + /// + /// [`fill_bytes`]: trait.RngCore.html#method.fill_bytes + /// [`try_fill`]: trait.Rng.html#method.try_fill + /// [`AsByteSliceMut`]: trait.AsByteSliceMut.html + fn fill(&mut self, dest: &mut T) { + self.fill_bytes(dest.as_byte_slice_mut()); + dest.to_le(); + } + + /// Fill `dest` entirely with random bytes (uniform value distribution), + /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices + /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.). + /// + /// On big-endian platforms this performs byte-swapping to ensure + /// portability of results from reproducible generators. + /// + /// This uses [`try_fill_bytes`] internally and forwards all RNG errors. In + /// some cases errors may be resolvable; see [`ErrorKind`] and + /// documentation for the RNG in use. If you do not plan to handle these + /// errors you may prefer to use [`fill`]. + /// + /// # Example + /// + /// ``` + /// # use rand::Error; + /// use rand::{thread_rng, Rng}; + /// + /// # fn try_inner() -> Result<(), Error> { + /// let mut arr = [0u64; 4]; + /// thread_rng().try_fill(&mut arr[..])?; + /// # Ok(()) + /// # } + /// + /// # try_inner().unwrap() + /// ``` + /// + /// [`ErrorKind`]: enum.ErrorKind.html + /// [`try_fill_bytes`]: trait.RngCore.html#method.try_fill_bytes + /// [`fill`]: trait.Rng.html#method.fill + /// [`AsByteSliceMut`]: trait.AsByteSliceMut.html + fn try_fill(&mut self, dest: &mut T) -> Result<(), Error> { + self.try_fill_bytes(dest.as_byte_slice_mut())?; + dest.to_le(); + Ok(()) + } + + /// Return a bool with a probability `p` of being true. + /// + /// This is a wrapper around [`distributions::Bernoulli`]. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// println!("{}", rng.gen_bool(1.0 / 3.0)); + /// ``` + /// + /// # Panics + /// + /// If `p` < 0 or `p` > 1. + /// + /// [`distributions::Bernoulli`]: distributions/bernoulli/struct.Bernoulli.html + #[inline] + fn gen_bool(&mut self, p: f64) -> bool { + let d = distributions::Bernoulli::new(p); + self.sample(d) + } + + /// Return a random element from `values`. + /// + /// Return `None` if `values` is empty. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let choices = [1, 2, 4, 8, 16, 32]; + /// let mut rng = thread_rng(); + /// println!("{:?}", rng.choose(&choices)); + /// assert_eq!(rng.choose(&choices[..0]), None); + /// ``` + fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> { + if values.is_empty() { + None + } else { + Some(&values[self.gen_range(0, values.len())]) + } + } + + /// Return a mutable pointer to a random element from `values`. + /// + /// Return `None` if `values` is empty. + fn choose_mut<'a, T>(&mut self, values: &'a mut [T]) -> Option<&'a mut T> { + if values.is_empty() { + None + } else { + let len = values.len(); + Some(&mut values[self.gen_range(0, len)]) + } + } + + /// Shuffle a mutable slice in place. + /// + /// This applies Durstenfeld's algorithm for the [Fisher–Yates shuffle]( + /// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm) + /// which produces an unbiased permutation. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// let mut y = [1, 2, 3]; + /// rng.shuffle(&mut y); + /// println!("{:?}", y); + /// rng.shuffle(&mut y); + /// println!("{:?}", y); + /// ``` + fn shuffle(&mut self, values: &mut [T]) { + let mut i = values.len(); + while i >= 2 { + // invariant: elements with index >= i have been locked in place. + i -= 1; + // lock element i in place. + values.swap(i, self.gen_range(0, i + 1)); + } + } + + /// Return an iterator that will yield an infinite number of randomly + /// generated items. + /// + /// # Example + /// + /// ``` + /// # #![allow(deprecated)] + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// let x = rng.gen_iter::().take(10).collect::>(); + /// println!("{:?}", x); + /// println!("{:?}", rng.gen_iter::<(f64, bool)>().take(5) + /// .collect::>()); + /// ``` + #[allow(deprecated)] + #[deprecated(since="0.5.0", note="use Rng::sample_iter(&Standard) instead")] + fn gen_iter(&mut self) -> Generator where Standard: Distribution { + Generator { rng: self, _marker: marker::PhantomData } + } + + /// Return a bool with a 1 in n chance of true + /// + /// # Example + /// + /// ``` + /// # #![allow(deprecated)] + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// assert_eq!(rng.gen_weighted_bool(0), true); + /// assert_eq!(rng.gen_weighted_bool(1), true); + /// // Just like `rng.gen::()` a 50-50% chance, but using a slower + /// // method with different results. + /// println!("{}", rng.gen_weighted_bool(2)); + /// // First meaningful use of `gen_weighted_bool`. + /// println!("{}", rng.gen_weighted_bool(3)); + /// ``` + #[deprecated(since="0.5.0", note="use gen_bool instead")] + fn gen_weighted_bool(&mut self, n: u32) -> bool { + // Short-circuit after `n <= 1` to avoid panic in `gen_range` + n <= 1 || self.gen_range(0, n) == 0 + } + + /// Return an iterator of random characters from the set A-Z,a-z,0-9. + /// + /// # Example + /// + /// ``` + /// # #![allow(deprecated)] + /// use rand::{thread_rng, Rng}; + /// + /// let s: String = thread_rng().gen_ascii_chars().take(10).collect(); + /// println!("{}", s); + /// ``` + #[allow(deprecated)] + #[deprecated(since="0.5.0", note="use sample_iter(&Alphanumeric) instead")] + fn gen_ascii_chars(&mut self) -> AsciiGenerator<&mut Self> { + AsciiGenerator { rng: self } + } +} + +impl Rng for R {} + +/// Trait for casting types to byte slices +/// +/// This is used by the [`fill`] and [`try_fill`] methods. +/// +/// [`fill`]: trait.Rng.html#method.fill +/// [`try_fill`]: trait.Rng.html#method.try_fill +pub trait AsByteSliceMut { + /// Return a mutable reference to self as a byte slice + fn as_byte_slice_mut(&mut self) -> &mut [u8]; + + /// Call `to_le` on each element (i.e. byte-swap on Big Endian platforms). + fn to_le(&mut self); +} + +impl AsByteSliceMut for [u8] { + fn as_byte_slice_mut(&mut self) -> &mut [u8] { + self + } + + fn to_le(&mut self) {} +} + +macro_rules! impl_as_byte_slice { + ($t:ty) => { + impl AsByteSliceMut for [$t] { + fn as_byte_slice_mut(&mut self) -> &mut [u8] { + if self.len() == 0 { + unsafe { + // must not use null pointer + slice::from_raw_parts_mut(0x1 as *mut u8, 0) + } + } else { + unsafe { + slice::from_raw_parts_mut(&mut self[0] + as *mut $t + as *mut u8, + self.len() * mem::size_of::<$t>() + ) + } + } + } + + fn to_le(&mut self) { + for x in self { + *x = x.to_le(); + } + } + } + } +} + +impl_as_byte_slice!(u16); +impl_as_byte_slice!(u32); +impl_as_byte_slice!(u64); +#[cfg(feature="i128_support")] impl_as_byte_slice!(u128); +impl_as_byte_slice!(usize); +impl_as_byte_slice!(i8); +impl_as_byte_slice!(i16); +impl_as_byte_slice!(i32); +impl_as_byte_slice!(i64); +#[cfg(feature="i128_support")] impl_as_byte_slice!(i128); +impl_as_byte_slice!(isize); + +macro_rules! impl_as_byte_slice_arrays { + ($n:expr,) => {}; + ($n:expr, $N:ident, $($NN:ident,)*) => { + impl_as_byte_slice_arrays!($n - 1, $($NN,)*); + + impl AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut { + fn as_byte_slice_mut(&mut self) -> &mut [u8] { + self[..].as_byte_slice_mut() + } + + fn to_le(&mut self) { + self[..].to_le() + } + } + }; + (!div $n:expr,) => {}; + (!div $n:expr, $N:ident, $($NN:ident,)*) => { + impl_as_byte_slice_arrays!(!div $n / 2, $($NN,)*); + + impl AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut { + fn as_byte_slice_mut(&mut self) -> &mut [u8] { + self[..].as_byte_slice_mut() + } + + fn to_le(&mut self) { + self[..].to_le() + } + } + }; +} +impl_as_byte_slice_arrays!(32, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,); +impl_as_byte_slice_arrays!(!div 4096, N,N,N,N,N,N,N,); + +/// Iterator which will generate a stream of random items. +/// +/// This iterator is created via the [`gen_iter`] method on [`Rng`]. +/// +/// [`gen_iter`]: trait.Rng.html#method.gen_iter +/// [`Rng`]: trait.Rng.html +#[derive(Debug)] +#[allow(deprecated)] +#[deprecated(since="0.5.0", note="use Rng::sample_iter instead")] +pub struct Generator { + rng: R, + _marker: marker::PhantomData T>, +} + +#[allow(deprecated)] +impl Iterator for Generator where Standard: Distribution { + type Item = T; + + fn next(&mut self) -> Option { + Some(self.rng.gen()) + } +} + +/// Iterator which will continuously generate random ascii characters. +/// +/// This iterator is created via the [`gen_ascii_chars`] method on [`Rng`]. +/// +/// [`gen_ascii_chars`]: trait.Rng.html#method.gen_ascii_chars +/// [`Rng`]: trait.Rng.html +#[derive(Debug)] +#[allow(deprecated)] +#[deprecated(since="0.5.0", note="use distributions::Alphanumeric instead")] +pub struct AsciiGenerator { + rng: R, +} + +#[allow(deprecated)] +impl Iterator for AsciiGenerator { + type Item = char; + + fn next(&mut self) -> Option { + const GEN_ASCII_STR_CHARSET: &[u8] = + b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ + abcdefghijklmnopqrstuvwxyz\ + 0123456789"; + Some(*self.rng.choose(GEN_ASCII_STR_CHARSET).unwrap() as char) + } +} + + +/// A convenience extension to [`SeedableRng`] allowing construction from fresh +/// entropy. This trait is automatically implemented for any PRNG implementing +/// [`SeedableRng`] and is not intended to be implemented by users. +/// +/// This is equivalent to using `SeedableRng::from_rng(EntropyRng::new())` then +/// unwrapping the result. +/// +/// Since this is convenient and secure, it is the recommended way to create +/// PRNGs, though two alternatives may be considered: +/// +/// * Deterministic creation using [`SeedableRng::from_seed`] with a fixed seed +/// * Seeding from `thread_rng`: `SeedableRng::from_rng(thread_rng())?`; +/// this will usually be faster and should also be secure, but requires +/// trusting one extra component. +/// +/// ## Example +/// +/// ``` +/// use rand::{Rng, FromEntropy}; +/// use rand::rngs::StdRng; +/// +/// let mut rng = StdRng::from_entropy(); +/// println!("Random die roll: {}", rng.gen_range(1, 7)); +/// ``` +/// +/// [`EntropyRng`]: rngs/struct.EntropyRng.html +/// [`SeedableRng`]: trait.SeedableRng.html +/// [`SeedableRng::from_seed`]: trait.SeedableRng.html#tymethod.from_seed +#[cfg(feature="std")] +pub trait FromEntropy: SeedableRng { + /// Creates a new instance, automatically seeded with fresh entropy. + /// + /// Normally this will use `OsRng`, but if that fails `JitterRng` will be + /// used instead. Both should be suitable for cryptography. It is possible + /// that both entropy sources will fail though unlikely; failures would + /// almost certainly be platform limitations or build issues, i.e. most + /// applications targetting PC/mobile platforms should not need to worry + /// about this failing. + /// + /// # Panics + /// + /// If all entropy sources fail this will panic. If you need to handle + /// errors, use the following code, equivalent aside from error handling: + /// + /// ``` + /// # use rand::Error; + /// use rand::prelude::*; + /// use rand::rngs::EntropyRng; + /// + /// # fn try_inner() -> Result<(), Error> { + /// // This uses StdRng, but is valid for any R: SeedableRng + /// let mut rng = StdRng::from_rng(EntropyRng::new())?; + /// + /// println!("random number: {}", rng.gen_range(1, 10)); + /// # Ok(()) + /// # } + /// + /// # try_inner().unwrap() + /// ``` + fn from_entropy() -> Self; +} + +#[cfg(feature="std")] +impl FromEntropy for R { + fn from_entropy() -> R { + R::from_rng(EntropyRng::new()).unwrap_or_else(|err| + panic!("FromEntropy::from_entropy() failed: {}", err)) + } +} + + +/// DEPRECATED: use [`SmallRng`] instead. +/// +/// Create a weak random number generator with a default algorithm and seed. +/// +/// It returns the fastest `Rng` algorithm currently available in Rust without +/// consideration for cryptography or security. If you require a specifically +/// seeded `Rng` for consistency over time you should pick one algorithm and +/// create the `Rng` yourself. +/// +/// This will seed the generator with randomness from `thread_rng`. +/// +/// [`SmallRng`]: rngs/struct.SmallRng.html +#[deprecated(since="0.5.0", note="removed in favor of SmallRng")] +#[cfg(feature="std")] +pub fn weak_rng() -> XorShiftRng { + XorShiftRng::from_rng(thread_rng()).unwrap_or_else(|err| + panic!("weak_rng failed: {:?}", err)) +} + +/// Generates a random value using the thread-local random number generator. +/// +/// This is simply a shortcut for `thread_rng().gen()`. See [`thread_rng`] for +/// documentation of the entropy source and [`Standard`] for documentation of +/// distributions and type-specific generation. +/// +/// # Examples +/// +/// ``` +/// let x = rand::random::(); +/// println!("{}", x); +/// +/// let y = rand::random::(); +/// println!("{}", y); +/// +/// if rand::random() { // generates a boolean +/// println!("Better lucky than good!"); +/// } +/// ``` +/// +/// If you're calling `random()` in a loop, caching the generator as in the +/// following example can increase performance. +/// +/// ``` +/// # #![allow(deprecated)] +/// use rand::Rng; +/// +/// let mut v = vec![1, 2, 3]; +/// +/// for x in v.iter_mut() { +/// *x = rand::random() +/// } +/// +/// // can be made faster by caching thread_rng +/// +/// let mut rng = rand::thread_rng(); +/// +/// for x in v.iter_mut() { +/// *x = rng.gen(); +/// } +/// ``` +/// +/// [`thread_rng`]: fn.thread_rng.html +/// [`Standard`]: distributions/struct.Standard.html +#[cfg(feature="std")] +#[inline] +pub fn random() -> T where Standard: Distribution { + thread_rng().gen() +} + +/// DEPRECATED: use `seq::sample_iter` instead. +/// +/// Randomly sample up to `amount` elements from a finite iterator. +/// The order of elements in the sample is not random. +/// +/// # Example +/// +/// ``` +/// # #![allow(deprecated)] +/// use rand::{thread_rng, sample}; +/// +/// let mut rng = thread_rng(); +/// let sample = sample(&mut rng, 1..100, 5); +/// println!("{:?}", sample); +/// ``` +#[cfg(feature="std")] +#[inline] +#[deprecated(since="0.4.0", note="renamed to seq::sample_iter")] +pub fn sample(rng: &mut R, iterable: I, amount: usize) -> Vec + where I: IntoIterator, + R: Rng, +{ + // the legacy sample didn't care whether amount was met + seq::sample_iter(rng, iterable, amount) + .unwrap_or_else(|e| e) +} + +#[cfg(test)] +mod test { + use rngs::mock::StepRng; + use super::*; + #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::boxed::Box; + + pub struct TestRng { inner: R } + + impl RngCore for TestRng { + fn next_u32(&mut self) -> u32 { + self.inner.next_u32() + } + fn next_u64(&mut self) -> u64 { + self.inner.next_u64() + } + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.inner.fill_bytes(dest) + } + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.inner.try_fill_bytes(dest) + } + } + + pub fn rng(seed: u64) -> TestRng { + TestRng { inner: StdRng::seed_from_u64(seed) } + } + + #[test] + fn test_fill_bytes_default() { + let mut r = StepRng::new(0x11_22_33_44_55_66_77_88, 0); + + // check every remainder mod 8, both in small and big vectors. + let lengths = [0, 1, 2, 3, 4, 5, 6, 7, + 80, 81, 82, 83, 84, 85, 86, 87]; + for &n in lengths.iter() { + let mut buffer = [0u8; 87]; + let v = &mut buffer[0..n]; + r.fill_bytes(v); + + // use this to get nicer error messages. + for (i, &byte) in v.iter().enumerate() { + if byte == 0 { + panic!("byte {} of {} is zero", i, n) + } + } + } + } + + #[test] + fn test_fill() { + let x = 9041086907909331047; // a random u64 + let mut rng = StepRng::new(x, 0); + + // Convert to byte sequence and back to u64; byte-swap twice if BE. + let mut array = [0u64; 2]; + rng.fill(&mut array[..]); + assert_eq!(array, [x, x]); + assert_eq!(rng.next_u64(), x); + + // Convert to bytes then u32 in LE order + let mut array = [0u32; 2]; + rng.fill(&mut array[..]); + assert_eq!(array, [x as u32, (x >> 32) as u32]); + assert_eq!(rng.next_u32(), x as u32); + } + + #[test] + fn test_fill_empty() { + let mut array = [0u32; 0]; + let mut rng = StepRng::new(0, 1); + rng.fill(&mut array); + rng.fill(&mut array[..]); + } + + #[test] + fn test_gen_range() { + let mut r = rng(101); + for _ in 0..1000 { + let a = r.gen_range(-3, 42); + assert!(a >= -3 && a < 42); + assert_eq!(r.gen_range(0, 1), 0); + assert_eq!(r.gen_range(-12, -11), -12); + } + + for _ in 0..1000 { + let a = r.gen_range(10, 42); + assert!(a >= 10 && a < 42); + assert_eq!(r.gen_range(0, 1), 0); + assert_eq!(r.gen_range(3_000_000, 3_000_001), 3_000_000); + } + + } + + #[test] + #[should_panic] + fn test_gen_range_panic_int() { + let mut r = rng(102); + r.gen_range(5, -2); + } + + #[test] + #[should_panic] + fn test_gen_range_panic_usize() { + let mut r = rng(103); + r.gen_range(5, 2); + } + + #[test] + #[allow(deprecated)] + fn test_gen_weighted_bool() { + let mut r = rng(104); + assert_eq!(r.gen_weighted_bool(0), true); + assert_eq!(r.gen_weighted_bool(1), true); + } + + #[test] + fn test_gen_bool() { + let mut r = rng(105); + for _ in 0..5 { + assert_eq!(r.gen_bool(0.0), false); + assert_eq!(r.gen_bool(1.0), true); + } + } + + #[test] + fn test_choose() { + let mut r = rng(107); + assert_eq!(r.choose(&[1, 1, 1]).map(|&x|x), Some(1)); + + let v: &[isize] = &[]; + assert_eq!(r.choose(v), None); + } + + #[test] + fn test_shuffle() { + let mut r = rng(108); + let empty: &mut [isize] = &mut []; + r.shuffle(empty); + let mut one = [1]; + r.shuffle(&mut one); + let b: &[_] = &[1]; + assert_eq!(one, b); + + let mut two = [1, 2]; + r.shuffle(&mut two); + assert!(two == [1, 2] || two == [2, 1]); + + let mut x = [1, 1, 1]; + r.shuffle(&mut x); + let b: &[_] = &[1, 1, 1]; + assert_eq!(x, b); + } + + #[test] + fn test_rng_trait_object() { + use distributions::{Distribution, Standard}; + let mut rng = rng(109); + let mut r = &mut rng as &mut RngCore; + r.next_u32(); + r.gen::(); + let mut v = [1, 1, 1]; + r.shuffle(&mut v); + let b: &[_] = &[1, 1, 1]; + assert_eq!(v, b); + assert_eq!(r.gen_range(0, 1), 0); + let _c: u8 = Standard.sample(&mut r); + } + + #[test] + #[cfg(feature="alloc")] + fn test_rng_boxed_trait() { + use distributions::{Distribution, Standard}; + let rng = rng(110); + let mut r = Box::new(rng) as Box; + r.next_u32(); + r.gen::(); + let mut v = [1, 1, 1]; + r.shuffle(&mut v); + let b: &[_] = &[1, 1, 1]; + assert_eq!(v, b); + assert_eq!(r.gen_range(0, 1), 0); + let _c: u8 = Standard.sample(&mut r); + } + + #[test] + #[cfg(feature="std")] + fn test_random() { + // not sure how to test this aside from just getting some values + let _n : usize = random(); + let _f : f32 = random(); + let _o : Option> = random(); + let _many : ((), + (usize, + isize, + Option<(u32, (bool,))>), + (u8, i8, u16, i16, u32, i32, u64, i64), + (f32, (f64, (f64,)))) = random(); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/prelude.rs b/third_party/cargo/vendor/rand-0.5.6/src/prelude.rs new file mode 100644 index 0000000..358c237 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/prelude.rs @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Convenience re-export of common members +//! +//! Like the standard library's prelude, this module simplifies importing of +//! common items. Unlike the standard prelude, the contents of this module must +//! be imported manually: +//! +//! ``` +//! use rand::prelude::*; +//! # let _ = StdRng::from_entropy(); +//! # let mut r = SmallRng::from_rng(thread_rng()).unwrap(); +//! # let _: f32 = r.gen(); +//! ``` + +#[doc(no_inline)] pub use distributions::Distribution; +#[doc(no_inline)] pub use rngs::{SmallRng, StdRng}; +#[doc(no_inline)] #[cfg(feature="std")] pub use rngs::ThreadRng; +#[doc(no_inline)] pub use {Rng, RngCore, CryptoRng, SeedableRng}; +#[doc(no_inline)] #[cfg(feature="std")] pub use {FromEntropy, random, thread_rng}; diff --git a/third_party/cargo/vendor/rand-0.5.6/src/prng/chacha.rs b/third_party/cargo/vendor/rand-0.5.6/src/prng/chacha.rs new file mode 100644 index 0000000..2817f8f --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/prng/chacha.rs @@ -0,0 +1,477 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://www.rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The ChaCha random number generator. + +use core::fmt; +use rand_core::{CryptoRng, RngCore, SeedableRng, Error, le}; +use rand_core::block::{BlockRngCore, BlockRng}; + +const SEED_WORDS: usize = 8; // 8 words for the 256-bit key +const STATE_WORDS: usize = 16; + +/// A cryptographically secure random number generator that uses the ChaCha +/// algorithm. +/// +/// ChaCha is a stream cipher designed by Daniel J. Bernstein [^1], that we use +/// as an RNG. It is an improved variant of the Salsa20 cipher family, which was +/// selected as one of the "stream ciphers suitable for widespread adoption" by +/// eSTREAM [^2]. +/// +/// ChaCha uses add-rotate-xor (ARX) operations as its basis. These are safe +/// against timing attacks, although that is mostly a concern for ciphers and +/// not for RNGs. Also it is very suitable for SIMD implementation. +/// Here we do not provide a SIMD implementation yet, except for what is +/// provided by auto-vectorisation. +/// +/// With the ChaCha algorithm it is possible to choose the number of rounds the +/// core algorithm should run. The number of rounds is a tradeoff between +/// performance and security, where 8 rounds is the minimum potentially +/// secure configuration, and 20 rounds is widely used as a conservative choice. +/// We use 20 rounds in this implementation, but hope to allow type-level +/// configuration in the future. +/// +/// We use a 64-bit counter and 64-bit stream identifier as in Benstein's +/// implementation [^1] except that we use a stream identifier in place of a +/// nonce. A 64-bit counter over 64-byte (16 word) blocks allows 1 ZiB of output +/// before cycling, and the stream identifier allows 264 unique +/// streams of output per seed. Both counter and stream are initialized to zero +/// but may be set via [`set_word_pos`] and [`set_stream`]. +/// +/// The word layout is: +/// +/// ```text +/// constant constant constant constant +/// seed seed seed seed +/// seed seed seed seed +/// counter counter nonce nonce +/// ``` +/// +/// This implementation uses an output buffer of sixteen `u32` words, and uses +/// [`BlockRng`] to implement the [`RngCore`] methods. +/// +/// [^1]: D. J. Bernstein, [*ChaCha, a variant of Salsa20*]( +/// https://cr.yp.to/chacha.html) +/// +/// [^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( +/// http://www.ecrypt.eu.org/stream/) +/// +/// [`set_word_pos`]: #method.set_word_pos +/// [`set_stream`]: #method.set_stream +/// [`BlockRng`]: ../../../rand_core/block/struct.BlockRng.html +/// [`RngCore`]: ../../trait.RngCore.html +#[derive(Clone, Debug)] +pub struct ChaChaRng(BlockRng); + +impl RngCore for ChaChaRng { + #[inline] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + #[inline] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for ChaChaRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + ChaChaRng(BlockRng::::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + BlockRng::::from_rng(rng).map(ChaChaRng) + } +} + +impl CryptoRng for ChaChaRng {} + +impl ChaChaRng { + /// Create an ChaCha random number generator using the default + /// fixed key of 8 zero words. + /// + /// # Examples + /// + /// ``` + /// # #![allow(deprecated)] + /// use rand::{RngCore, ChaChaRng}; + /// + /// let mut ra = ChaChaRng::new_unseeded(); + /// println!("{:?}", ra.next_u32()); + /// println!("{:?}", ra.next_u32()); + /// ``` + /// + /// Since this equivalent to a RNG with a fixed seed, repeated executions + /// of an unseeded RNG will produce the same result. This code sample will + /// consistently produce: + /// + /// - 2917185654 + /// - 2419978656 + #[deprecated(since="0.5.0", note="use the FromEntropy or SeedableRng trait")] + pub fn new_unseeded() -> ChaChaRng { + ChaChaRng::from_seed([0; SEED_WORDS*4]) + } + + /// Get the offset from the start of the stream, in 32-bit words. + /// + /// Since the generated blocks are 16 words (24) long and the + /// counter is 64-bits, the offset is a 68-bit number. Sub-word offsets are + /// not supported, hence the result can simply be multiplied by 4 to get a + /// byte-offset. + /// + /// Note: this function is currently only available when the `i128_support` + /// feature is enabled. In the future this will be enabled by default. + #[cfg(feature = "i128_support")] + pub fn get_word_pos(&self) -> u128 { + let mut c = (self.0.core.state[13] as u64) << 32 + | (self.0.core.state[12] as u64); + let mut index = self.0.index(); + // c is the end of the last block generated, unless index is at end + if index >= STATE_WORDS { + index = 0; + } else { + c = c.wrapping_sub(1); + } + ((c as u128) << 4) | (index as u128) + } + + /// Set the offset from the start of the stream, in 32-bit words. + /// + /// As with `get_word_pos`, we use a 68-bit number. Since the generator + /// simply cycles at the end of its period (1 ZiB), we ignore the upper + /// 60 bits. + /// + /// Note: this function is currently only available when the `i128_support` + /// feature is enabled. In the future this will be enabled by default. + #[cfg(feature = "i128_support")] + pub fn set_word_pos(&mut self, word_offset: u128) { + let index = (word_offset as usize) & 0xF; + let counter = (word_offset >> 4) as u64; + self.0.core.state[12] = counter as u32; + self.0.core.state[13] = (counter >> 32) as u32; + if index != 0 { + self.0.generate_and_set(index); // also increments counter + } else { + self.0.reset(); + } + } + + /// Set the stream number. + /// + /// This is initialized to zero; 264 unique streams of output + /// are available per seed/key. + /// + /// Note that in order to reproduce ChaCha output with a specific 64-bit + /// nonce, one can convert that nonce to a `u64` in little-endian fashion + /// and pass to this function. In theory a 96-bit nonce can be used by + /// passing the last 64-bits to this function and using the first 32-bits as + /// the most significant half of the 64-bit counter (which may be set + /// indirectly via `set_word_pos`), but this is not directly supported. + pub fn set_stream(&mut self, stream: u64) { + let index = self.0.index(); + self.0.core.state[14] = stream as u32; + self.0.core.state[15] = (stream >> 32) as u32; + if index < STATE_WORDS { + // we need to regenerate a partial result buffer + { + // reverse of counter adjustment in generate() + if self.0.core.state[12] == 0 { + self.0.core.state[13] = self.0.core.state[13].wrapping_sub(1); + } + self.0.core.state[12] = self.0.core.state[12].wrapping_sub(1); + } + self.0.generate_and_set(index); + } + } +} + +/// The core of `ChaChaRng`, used with `BlockRng`. +#[derive(Clone)] +pub struct ChaChaCore { + state: [u32; STATE_WORDS], +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for ChaChaCore { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ChaChaCore {{}}") + } +} + +macro_rules! quarter_round{ + ($a: expr, $b: expr, $c: expr, $d: expr) => {{ + $a = $a.wrapping_add($b); $d ^= $a; $d = $d.rotate_left(16); + $c = $c.wrapping_add($d); $b ^= $c; $b = $b.rotate_left(12); + $a = $a.wrapping_add($b); $d ^= $a; $d = $d.rotate_left( 8); + $c = $c.wrapping_add($d); $b ^= $c; $b = $b.rotate_left( 7); + }} +} + +macro_rules! double_round{ + ($x: expr) => {{ + // Column round + quarter_round!($x[ 0], $x[ 4], $x[ 8], $x[12]); + quarter_round!($x[ 1], $x[ 5], $x[ 9], $x[13]); + quarter_round!($x[ 2], $x[ 6], $x[10], $x[14]); + quarter_round!($x[ 3], $x[ 7], $x[11], $x[15]); + // Diagonal round + quarter_round!($x[ 0], $x[ 5], $x[10], $x[15]); + quarter_round!($x[ 1], $x[ 6], $x[11], $x[12]); + quarter_round!($x[ 2], $x[ 7], $x[ 8], $x[13]); + quarter_round!($x[ 3], $x[ 4], $x[ 9], $x[14]); + }} +} + +impl BlockRngCore for ChaChaCore { + type Item = u32; + type Results = [u32; STATE_WORDS]; + + fn generate(&mut self, results: &mut Self::Results) { + // For some reason extracting this part into a separate function + // improves performance by 50%. + fn core(results: &mut [u32; STATE_WORDS], + state: &[u32; STATE_WORDS]) + { + let mut tmp = *state; + let rounds = 20; + for _ in 0..rounds / 2 { + double_round!(tmp); + } + for i in 0..STATE_WORDS { + results[i] = tmp[i].wrapping_add(state[i]); + } + } + + core(results, &self.state); + + // update 64-bit counter + self.state[12] = self.state[12].wrapping_add(1); + if self.state[12] != 0 { return; }; + self.state[13] = self.state[13].wrapping_add(1); + } +} + +impl SeedableRng for ChaChaCore { + type Seed = [u8; SEED_WORDS*4]; + + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_le = [0u32; SEED_WORDS]; + le::read_u32_into(&seed, &mut seed_le); + Self { + state: [0x61707865, 0x3320646E, 0x79622D32, 0x6B206574, // constants + seed_le[0], seed_le[1], seed_le[2], seed_le[3], // seed + seed_le[4], seed_le[5], seed_le[6], seed_le[7], // seed + 0, 0, 0, 0], // counter + } + } +} + +impl CryptoRng for ChaChaCore {} + +impl From for ChaChaRng { + fn from(core: ChaChaCore) -> Self { + ChaChaRng(BlockRng::new(core)) + } +} + +#[cfg(test)] +mod test { + use {RngCore, SeedableRng}; + use super::ChaChaRng; + + #[test] + fn test_chacha_construction() { + let seed = [0,0,0,0,0,0,0,0, + 1,0,0,0,0,0,0,0, + 2,0,0,0,0,0,0,0, + 3,0,0,0,0,0,0,0]; + let mut rng1 = ChaChaRng::from_seed(seed); + assert_eq!(rng1.next_u32(), 137206642); + + let mut rng2 = ChaChaRng::from_rng(rng1).unwrap(); + assert_eq!(rng2.next_u32(), 1325750369); + } + + #[test] + fn test_chacha_true_values_a() { + // Test vectors 1 and 2 from + // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 + let seed = [0u8; 32]; + let mut rng = ChaChaRng::from_seed(seed); + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653, + 0xb819d2bd, 0x1aed8da0, 0xccef36a8, 0xc70d778b, + 0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8, + 0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2]; + assert_eq!(results, expected); + + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0xbee7079f, 0x7a385155, 0x7c97ba98, 0x0d082d73, + 0xa0290fcb, 0x6965e348, 0x3e53c612, 0xed7aee32, + 0x7621b729, 0x434ee69c, 0xb03371d5, 0xd539d874, + 0x281fed31, 0x45fb0a51, 0x1f0ae1ac, 0x6f4d794b]; + assert_eq!(results, expected); + } + + #[test] + fn test_chacha_true_values_b() { + // Test vector 3 from + // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 + let seed = [0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1]; + let mut rng = ChaChaRng::from_seed(seed); + + // Skip block 0 + for _ in 0..16 { rng.next_u32(); } + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0x2452eb3a, 0x9249f8ec, 0x8d829d9b, 0xddd4ceb1, + 0xe8252083, 0x60818b01, 0xf38422b8, 0x5aaa49c9, + 0xbb00ca8e, 0xda3ba7b4, 0xc4b592d1, 0xfdf2732f, + 0x4436274e, 0x2561b3c8, 0xebdd4aa6, 0xa0136c00]; + assert_eq!(results, expected); + } + + #[test] + #[cfg(feature = "i128_support")] + fn test_chacha_true_values_c() { + // Test vector 4 from + // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 + let seed = [0, 0xff, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0]; + let expected = [0xfb4dd572, 0x4bc42ef1, 0xdf922636, 0x327f1394, + 0xa78dea8f, 0x5e269039, 0xa1bebbc1, 0xcaf09aae, + 0xa25ab213, 0x48a6b46c, 0x1b9d9bcb, 0x092c5be6, + 0x546ca624, 0x1bec45d5, 0x87f47473, 0x96f0992e]; + let expected_end = 3 * 16; + let mut results = [0u32; 16]; + + // Test block 2 by skipping block 0 and 1 + let mut rng1 = ChaChaRng::from_seed(seed); + for _ in 0..32 { rng1.next_u32(); } + for i in results.iter_mut() { *i = rng1.next_u32(); } + assert_eq!(results, expected); + assert_eq!(rng1.get_word_pos(), expected_end); + + // Test block 2 by using `set_word_pos` + let mut rng2 = ChaChaRng::from_seed(seed); + rng2.set_word_pos(2 * 16); + for i in results.iter_mut() { *i = rng2.next_u32(); } + assert_eq!(results, expected); + assert_eq!(rng2.get_word_pos(), expected_end); + + // Test skipping behaviour with other types + let mut buf = [0u8; 32]; + rng2.fill_bytes(&mut buf[..]); + assert_eq!(rng2.get_word_pos(), expected_end + 8); + rng2.fill_bytes(&mut buf[0..25]); + assert_eq!(rng2.get_word_pos(), expected_end + 15); + rng2.next_u64(); + assert_eq!(rng2.get_word_pos(), expected_end + 17); + rng2.next_u32(); + rng2.next_u64(); + assert_eq!(rng2.get_word_pos(), expected_end + 20); + rng2.fill_bytes(&mut buf[0..1]); + assert_eq!(rng2.get_word_pos(), expected_end + 21); + } + + #[test] + fn test_chacha_multiple_blocks() { + let seed = [0,0,0,0, 1,0,0,0, 2,0,0,0, 3,0,0,0, 4,0,0,0, 5,0,0,0, 6,0,0,0, 7,0,0,0]; + let mut rng = ChaChaRng::from_seed(seed); + + // Store the 17*i-th 32-bit word, + // i.e., the i-th word of the i-th 16-word block + let mut results = [0u32; 16]; + for i in results.iter_mut() { + *i = rng.next_u32(); + for _ in 0..16 { + rng.next_u32(); + } + } + let expected = [0xf225c81a, 0x6ab1be57, 0x04d42951, 0x70858036, + 0x49884684, 0x64efec72, 0x4be2d186, 0x3615b384, + 0x11cfa18e, 0xd3c50049, 0x75c775f6, 0x434c6530, + 0x2c5bad8f, 0x898881dc, 0x5f1c86d9, 0xc1f8e7f4]; + assert_eq!(results, expected); + } + + #[test] + fn test_chacha_true_bytes() { + let seed = [0u8; 32]; + let mut rng = ChaChaRng::from_seed(seed); + let mut results = [0u8; 32]; + rng.fill_bytes(&mut results); + let expected = [118, 184, 224, 173, 160, 241, 61, 144, + 64, 93, 106, 229, 83, 134, 189, 40, + 189, 210, 25, 184, 160, 141, 237, 26, + 168, 54, 239, 204, 139, 119, 13, 199]; + assert_eq!(results, expected); + } + + #[test] + fn test_chacha_nonce() { + // Test vector 5 from + // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 + // Although we do not support setting a nonce, we try it here anyway so + // we can use this test vector. + let seed = [0u8; 32]; + let mut rng = ChaChaRng::from_seed(seed); + // 96-bit nonce in LE order is: 0,0,0,0, 0,0,0,0, 0,0,0,2 + rng.set_stream(2u64 << (24 + 32)); + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0x374dc6c2, 0x3736d58c, 0xb904e24a, 0xcd3f93ef, + 0x88228b1a, 0x96a4dfb3, 0x5b76ab72, 0xc727ee54, + 0x0e0e978a, 0xf3145c95, 0x1b748ea8, 0xf786c297, + 0x99c28f5f, 0x628314e8, 0x398a19fa, 0x6ded1b53]; + assert_eq!(results, expected); + } + + #[test] + fn test_chacha_clone_streams() { + let seed = [0,0,0,0, 1,0,0,0, 2,0,0,0, 3,0,0,0, 4,0,0,0, 5,0,0,0, 6,0,0,0, 7,0,0,0]; + let mut rng = ChaChaRng::from_seed(seed); + let mut clone = rng.clone(); + for _ in 0..16 { + assert_eq!(rng.next_u64(), clone.next_u64()); + } + + rng.set_stream(51); + for _ in 0..7 { + assert!(rng.next_u32() != clone.next_u32()); + } + clone.set_stream(51); // switch part way through block + for _ in 7..16 { + assert_eq!(rng.next_u32(), clone.next_u32()); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/prng/hc128.rs b/third_party/cargo/vendor/rand-0.5.6/src/prng/hc128.rs new file mode 100644 index 0000000..5aa2d24 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/prng/hc128.rs @@ -0,0 +1,464 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://www.rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The HC-128 random number generator. + +use core::fmt; +use rand_core::{CryptoRng, RngCore, SeedableRng, Error, le}; +use rand_core::block::{BlockRngCore, BlockRng}; + +const SEED_WORDS: usize = 8; // 128 bit key followed by 128 bit iv + +/// A cryptographically secure random number generator that uses the HC-128 +/// algorithm. +/// +/// HC-128 is a stream cipher designed by Hongjun Wu[^1], that we use as an +/// RNG. It is selected as one of the "stream ciphers suitable for widespread +/// adoption" by eSTREAM[^2]. +/// +/// HC-128 is an array based RNG. In this it is similar to RC-4 and ISAAC before +/// it, but those have never been proven cryptographically secure (or have even +/// been significantly compromised, as in the case of RC-4[^5]). +/// +/// Because HC-128 works with simple indexing into a large array and with a few +/// operations that parallelize well, it has very good performance. The size of +/// the array it needs, 4kb, can however be a disadvantage. +/// +/// This implementation is not based on the version of HC-128 submitted to the +/// eSTREAM contest, but on a later version by the author with a few small +/// improvements from December 15, 2009[^3]. +/// +/// HC-128 has no known weaknesses that are easier to exploit than doing a +/// brute-force search of 2128. A very comprehensive analysis of the +/// current state of known attacks / weaknesses of HC-128 is given in *Some +/// Results On Analysis And Implementation Of HC-128 Stream Cipher*[^4]. +/// +/// The average cycle length is expected to be +/// 21024*32+10-1 = 232777. +/// We support seeding with a 256-bit array, which matches the 128-bit key +/// concatenated with a 128-bit IV from the stream cipher. +/// +/// This implementation uses an output buffer of sixteen `u32` words, and uses +/// [`BlockRng`] to implement the [`RngCore`] methods. +/// +/// ## References +/// [^1]: Hongjun Wu (2008). ["The Stream Cipher HC-128"]( +/// http://www.ecrypt.eu.org/stream/p3ciphers/hc/hc128_p3.pdf). +/// *The eSTREAM Finalists*, LNCS 4986, pp. 39–47, Springer-Verlag. +/// +/// [^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( +/// http://www.ecrypt.eu.org/stream/) +/// +/// [^3]: Hongjun Wu, [Stream Ciphers HC-128 and HC-256]( +/// https://www.ntu.edu.sg/home/wuhj/research/hc/index.html) +/// +/// [^4]: Shashwat Raizada (January 2015),["Some Results On Analysis And +/// Implementation Of HC-128 Stream Cipher"]( +/// http://library.isical.ac.in:8080/jspui/bitstream/123456789/6636/1/TH431.pdf). +/// +/// [^5]: Internet Engineering Task Force (February 2015), +/// ["Prohibiting RC4 Cipher Suites"](https://tools.ietf.org/html/rfc7465). +/// +/// [`BlockRng`]: ../../../rand_core/block/struct.BlockRng.html +/// [`RngCore`]: ../../trait.RngCore.html +#[derive(Clone, Debug)] +pub struct Hc128Rng(BlockRng); + +impl RngCore for Hc128Rng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for Hc128Rng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + Hc128Rng(BlockRng::::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + BlockRng::::from_rng(rng).map(Hc128Rng) + } +} + +impl CryptoRng for Hc128Rng {} + +/// The core of `Hc128Rng`, used with `BlockRng`. +#[derive(Clone)] +pub struct Hc128Core { + t: [u32; 1024], + counter1024: usize, +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for Hc128Core { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Hc128Core {{}}") + } +} + +impl BlockRngCore for Hc128Core { + type Item = u32; + type Results = [u32; 16]; + + fn generate(&mut self, results: &mut Self::Results) { + assert!(self.counter1024 % 16 == 0); + + let cc = self.counter1024 % 512; + let dd = (cc + 16) % 512; + let ee = cc.wrapping_sub(16) % 512; + + if self.counter1024 & 512 == 0 { + // P block + results[0] = self.step_p(cc+0, cc+1, ee+13, ee+6, ee+4); + results[1] = self.step_p(cc+1, cc+2, ee+14, ee+7, ee+5); + results[2] = self.step_p(cc+2, cc+3, ee+15, ee+8, ee+6); + results[3] = self.step_p(cc+3, cc+4, cc+0, ee+9, ee+7); + results[4] = self.step_p(cc+4, cc+5, cc+1, ee+10, ee+8); + results[5] = self.step_p(cc+5, cc+6, cc+2, ee+11, ee+9); + results[6] = self.step_p(cc+6, cc+7, cc+3, ee+12, ee+10); + results[7] = self.step_p(cc+7, cc+8, cc+4, ee+13, ee+11); + results[8] = self.step_p(cc+8, cc+9, cc+5, ee+14, ee+12); + results[9] = self.step_p(cc+9, cc+10, cc+6, ee+15, ee+13); + results[10] = self.step_p(cc+10, cc+11, cc+7, cc+0, ee+14); + results[11] = self.step_p(cc+11, cc+12, cc+8, cc+1, ee+15); + results[12] = self.step_p(cc+12, cc+13, cc+9, cc+2, cc+0); + results[13] = self.step_p(cc+13, cc+14, cc+10, cc+3, cc+1); + results[14] = self.step_p(cc+14, cc+15, cc+11, cc+4, cc+2); + results[15] = self.step_p(cc+15, dd+0, cc+12, cc+5, cc+3); + } else { + // Q block + results[0] = self.step_q(cc+0, cc+1, ee+13, ee+6, ee+4); + results[1] = self.step_q(cc+1, cc+2, ee+14, ee+7, ee+5); + results[2] = self.step_q(cc+2, cc+3, ee+15, ee+8, ee+6); + results[3] = self.step_q(cc+3, cc+4, cc+0, ee+9, ee+7); + results[4] = self.step_q(cc+4, cc+5, cc+1, ee+10, ee+8); + results[5] = self.step_q(cc+5, cc+6, cc+2, ee+11, ee+9); + results[6] = self.step_q(cc+6, cc+7, cc+3, ee+12, ee+10); + results[7] = self.step_q(cc+7, cc+8, cc+4, ee+13, ee+11); + results[8] = self.step_q(cc+8, cc+9, cc+5, ee+14, ee+12); + results[9] = self.step_q(cc+9, cc+10, cc+6, ee+15, ee+13); + results[10] = self.step_q(cc+10, cc+11, cc+7, cc+0, ee+14); + results[11] = self.step_q(cc+11, cc+12, cc+8, cc+1, ee+15); + results[12] = self.step_q(cc+12, cc+13, cc+9, cc+2, cc+0); + results[13] = self.step_q(cc+13, cc+14, cc+10, cc+3, cc+1); + results[14] = self.step_q(cc+14, cc+15, cc+11, cc+4, cc+2); + results[15] = self.step_q(cc+15, dd+0, cc+12, cc+5, cc+3); + } + self.counter1024 = self.counter1024.wrapping_add(16); + } +} + +impl Hc128Core { + // One step of HC-128, update P and generate 32 bits keystream + #[inline(always)] + fn step_p(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) + -> u32 + { + let (p, q) = self.t.split_at_mut(512); + // FIXME: it would be great if we the bounds checks here could be + // optimized out, and we would not need unsafe. + // This improves performance by about 7%. + unsafe { + let temp0 = p.get_unchecked(i511).rotate_right(23); + let temp1 = p.get_unchecked(i3).rotate_right(10); + let temp2 = p.get_unchecked(i10).rotate_right(8); + *p.get_unchecked_mut(i) = p.get_unchecked(i) + .wrapping_add(temp2) + .wrapping_add(temp0 ^ temp1); + let temp3 = { + // The h1 function in HC-128 + let a = *p.get_unchecked(i12) as u8; + let c = (p.get_unchecked(i12) >> 16) as u8; + q[a as usize].wrapping_add(q[256 + c as usize]) + }; + temp3 ^ p.get_unchecked(i) + } + } + + // One step of HC-128, update Q and generate 32 bits keystream + // Similar to `step_p`, but `p` and `q` are swapped, and the rotates are to + // the left instead of to the right. + #[inline(always)] + fn step_q(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) + -> u32 + { + let (p, q) = self.t.split_at_mut(512); + unsafe { + let temp0 = q.get_unchecked(i511).rotate_left(23); + let temp1 = q.get_unchecked(i3).rotate_left(10); + let temp2 = q.get_unchecked(i10).rotate_left(8); + *q.get_unchecked_mut(i) = q.get_unchecked(i) + .wrapping_add(temp2) + .wrapping_add(temp0 ^ temp1); + let temp3 = { + // The h2 function in HC-128 + let a = *q.get_unchecked(i12) as u8; + let c = (q.get_unchecked(i12) >> 16) as u8; + p[a as usize].wrapping_add(p[256 + c as usize]) + }; + temp3 ^ q.get_unchecked(i) + } + } + + fn sixteen_steps(&mut self) { + assert!(self.counter1024 % 16 == 0); + + let cc = self.counter1024 % 512; + let dd = (cc + 16) % 512; + let ee = cc.wrapping_sub(16) % 512; + + if self.counter1024 < 512 { + // P block + self.t[cc+0] = self.step_p(cc+0, cc+1, ee+13, ee+6, ee+4); + self.t[cc+1] = self.step_p(cc+1, cc+2, ee+14, ee+7, ee+5); + self.t[cc+2] = self.step_p(cc+2, cc+3, ee+15, ee+8, ee+6); + self.t[cc+3] = self.step_p(cc+3, cc+4, cc+0, ee+9, ee+7); + self.t[cc+4] = self.step_p(cc+4, cc+5, cc+1, ee+10, ee+8); + self.t[cc+5] = self.step_p(cc+5, cc+6, cc+2, ee+11, ee+9); + self.t[cc+6] = self.step_p(cc+6, cc+7, cc+3, ee+12, ee+10); + self.t[cc+7] = self.step_p(cc+7, cc+8, cc+4, ee+13, ee+11); + self.t[cc+8] = self.step_p(cc+8, cc+9, cc+5, ee+14, ee+12); + self.t[cc+9] = self.step_p(cc+9, cc+10, cc+6, ee+15, ee+13); + self.t[cc+10] = self.step_p(cc+10, cc+11, cc+7, cc+0, ee+14); + self.t[cc+11] = self.step_p(cc+11, cc+12, cc+8, cc+1, ee+15); + self.t[cc+12] = self.step_p(cc+12, cc+13, cc+9, cc+2, cc+0); + self.t[cc+13] = self.step_p(cc+13, cc+14, cc+10, cc+3, cc+1); + self.t[cc+14] = self.step_p(cc+14, cc+15, cc+11, cc+4, cc+2); + self.t[cc+15] = self.step_p(cc+15, dd+0, cc+12, cc+5, cc+3); + } else { + // Q block + self.t[cc+512+0] = self.step_q(cc+0, cc+1, ee+13, ee+6, ee+4); + self.t[cc+512+1] = self.step_q(cc+1, cc+2, ee+14, ee+7, ee+5); + self.t[cc+512+2] = self.step_q(cc+2, cc+3, ee+15, ee+8, ee+6); + self.t[cc+512+3] = self.step_q(cc+3, cc+4, cc+0, ee+9, ee+7); + self.t[cc+512+4] = self.step_q(cc+4, cc+5, cc+1, ee+10, ee+8); + self.t[cc+512+5] = self.step_q(cc+5, cc+6, cc+2, ee+11, ee+9); + self.t[cc+512+6] = self.step_q(cc+6, cc+7, cc+3, ee+12, ee+10); + self.t[cc+512+7] = self.step_q(cc+7, cc+8, cc+4, ee+13, ee+11); + self.t[cc+512+8] = self.step_q(cc+8, cc+9, cc+5, ee+14, ee+12); + self.t[cc+512+9] = self.step_q(cc+9, cc+10, cc+6, ee+15, ee+13); + self.t[cc+512+10] = self.step_q(cc+10, cc+11, cc+7, cc+0, ee+14); + self.t[cc+512+11] = self.step_q(cc+11, cc+12, cc+8, cc+1, ee+15); + self.t[cc+512+12] = self.step_q(cc+12, cc+13, cc+9, cc+2, cc+0); + self.t[cc+512+13] = self.step_q(cc+13, cc+14, cc+10, cc+3, cc+1); + self.t[cc+512+14] = self.step_q(cc+14, cc+15, cc+11, cc+4, cc+2); + self.t[cc+512+15] = self.step_q(cc+15, dd+0, cc+12, cc+5, cc+3); + } + self.counter1024 += 16; + } + + // Initialize an HC-128 random number generator. The seed has to be + // 256 bits in length (`[u32; 8]`), matching the 128 bit `key` followed by + // 128 bit `iv` when HC-128 where to be used as a stream cipher. + fn init(seed: [u32; SEED_WORDS]) -> Self { + #[inline] + fn f1(x: u32) -> u32 { + x.rotate_right(7) ^ x.rotate_right(18) ^ (x >> 3) + } + + #[inline] + fn f2(x: u32) -> u32 { + x.rotate_right(17) ^ x.rotate_right(19) ^ (x >> 10) + } + + let mut t = [0u32; 1024]; + + // Expand the key and iv into P and Q + let (key, iv) = seed.split_at(4); + t[..4].copy_from_slice(key); + t[4..8].copy_from_slice(key); + t[8..12].copy_from_slice(iv); + t[12..16].copy_from_slice(iv); + + // Generate the 256 intermediate values W[16] ... W[256+16-1], and + // copy the last 16 generated values to the start op P. + for i in 16..256+16 { + t[i] = f2(t[i-2]).wrapping_add(t[i-7]).wrapping_add(f1(t[i-15])) + .wrapping_add(t[i-16]).wrapping_add(i as u32); + } + { + let (p1, p2) = t.split_at_mut(256); + p1[0..16].copy_from_slice(&p2[0..16]); + } + + // Generate both the P and Q tables + for i in 16..1024 { + t[i] = f2(t[i-2]).wrapping_add(t[i-7]).wrapping_add(f1(t[i-15])) + .wrapping_add(t[i-16]).wrapping_add(256 + i as u32); + } + + let mut core = Self { t, counter1024: 0 }; + + // run the cipher 1024 steps + for _ in 0..64 { core.sixteen_steps() }; + core.counter1024 = 0; + core + } +} + +impl SeedableRng for Hc128Core { + type Seed = [u8; SEED_WORDS*4]; + + /// Create an HC-128 random number generator with a seed. The seed has to be + /// 256 bits in length, matching the 128 bit `key` followed by 128 bit `iv` + /// when HC-128 where to be used as a stream cipher. + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_u32 = [0u32; SEED_WORDS]; + le::read_u32_into(&seed, &mut seed_u32); + Self::init(seed_u32) + } +} + +impl CryptoRng for Hc128Core {} + +#[cfg(test)] +mod test { + use {RngCore, SeedableRng}; + use super::Hc128Rng; + + #[test] + // Test vector 1 from the paper "The Stream Cipher HC-128" + fn test_hc128_true_values_a() { + let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng = Hc128Rng::from_seed(seed); + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0x73150082, 0x3bfd03a0, 0xfb2fd77f, 0xaa63af0e, + 0xde122fc6, 0xa7dc29b6, 0x62a68527, 0x8b75ec68, + 0x9036db1e, 0x81896005, 0x00ade078, 0x491fbf9a, + 0x1cdc3013, 0x6c3d6e24, 0x90f664b2, 0x9cd57102]; + assert_eq!(results, expected); + } + + #[test] + // Test vector 2 from the paper "The Stream Cipher HC-128" + fn test_hc128_true_values_b() { + let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 1,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng = Hc128Rng::from_seed(seed); + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0xc01893d5, 0xb7dbe958, 0x8f65ec98, 0x64176604, + 0x36fc6724, 0xc82c6eec, 0x1b1c38a7, 0xc9b42a95, + 0x323ef123, 0x0a6a908b, 0xce757b68, 0x9f14f7bb, + 0xe4cde011, 0xaeb5173f, 0x89608c94, 0xb5cf46ca]; + assert_eq!(results, expected); + } + + #[test] + // Test vector 3 from the paper "The Stream Cipher HC-128" + fn test_hc128_true_values_c() { + let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng = Hc128Rng::from_seed(seed); + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0x518251a4, 0x04b4930a, 0xb02af931, 0x0639f032, + 0xbcb4a47a, 0x5722480b, 0x2bf99f72, 0xcdc0e566, + 0x310f0c56, 0xd3cc83e8, 0x663db8ef, 0x62dfe07f, + 0x593e1790, 0xc5ceaa9c, 0xab03806f, 0xc9a6e5a0]; + assert_eq!(results, expected); + } + + #[test] + fn test_hc128_true_values_u64() { + let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng = Hc128Rng::from_seed(seed); + + let mut results = [0u64; 8]; + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected = [0x3bfd03a073150082, 0xaa63af0efb2fd77f, + 0xa7dc29b6de122fc6, 0x8b75ec6862a68527, + 0x818960059036db1e, 0x491fbf9a00ade078, + 0x6c3d6e241cdc3013, 0x9cd5710290f664b2]; + assert_eq!(results, expected); + + // The RNG operates in a P block of 512 results and next a Q block. + // After skipping 2*800 u32 results we end up somewhere in the Q block + // of the second round + for _ in 0..800 { rng.next_u64(); } + + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected = [0xd8c4d6ca84d0fc10, 0xf16a5d91dc66e8e7, + 0xd800de5bc37a8653, 0x7bae1f88c0dfbb4c, + 0x3bfe1f374e6d4d14, 0x424b55676be3fa06, + 0xe3a1e8758cbff579, 0x417f7198c5652bcd]; + assert_eq!(results, expected); + } + + #[test] + fn test_hc128_true_values_bytes() { + let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng = Hc128Rng::from_seed(seed); + let expected = [0x31, 0xf9, 0x2a, 0xb0, 0x32, 0xf0, 0x39, 0x06, + 0x7a, 0xa4, 0xb4, 0xbc, 0x0b, 0x48, 0x22, 0x57, + 0x72, 0x9f, 0xf9, 0x2b, 0x66, 0xe5, 0xc0, 0xcd, + 0x56, 0x0c, 0x0f, 0x31, 0xe8, 0x83, 0xcc, 0xd3, + 0xef, 0xb8, 0x3d, 0x66, 0x7f, 0xe0, 0xdf, 0x62, + 0x90, 0x17, 0x3e, 0x59, 0x9c, 0xaa, 0xce, 0xc5, + 0x6f, 0x80, 0x03, 0xab, 0xa0, 0xe5, 0xa6, 0xc9, + 0x60, 0x95, 0x84, 0x7a, 0xa5, 0x68, 0x5a, 0x84, + 0xea, 0xd5, 0xf3, 0xea, 0x73, 0xa9, 0xad, 0x01, + 0x79, 0x7d, 0xbe, 0x9f, 0xea, 0xe3, 0xf9, 0x74, + 0x0e, 0xda, 0x2f, 0xa0, 0xe4, 0x7b, 0x4b, 0x1b, + 0xdd, 0x17, 0x69, 0x4a, 0xfe, 0x9f, 0x56, 0x95, + 0xad, 0x83, 0x6b, 0x9d, 0x60, 0xa1, 0x99, 0x96, + 0x90, 0x00, 0x66, 0x7f, 0xfa, 0x7e, 0x65, 0xe9, + 0xac, 0x8b, 0x92, 0x34, 0x77, 0xb4, 0x23, 0xd0, + 0xb9, 0xab, 0xb1, 0x47, 0x7d, 0x4a, 0x13, 0x0a]; + + // Pick a somewhat large buffer so we can test filling with the + // remainder from `state.results`, directly filling the buffer, and + // filling the remainder of the buffer. + let mut buffer = [0u8; 16*4*2]; + // Consume a value so that we have a remainder. + assert!(rng.next_u64() == 0x04b4930a518251a4); + rng.fill_bytes(&mut buffer); + + // [u8; 128] doesn't implement PartialEq + assert_eq!(buffer.len(), expected.len()); + for (b, e) in buffer.iter().zip(expected.iter()) { + assert_eq!(b, e); + } + } + + #[test] + fn test_hc128_clone() { + let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng1 = Hc128Rng::from_seed(seed); + let mut rng2 = rng1.clone(); + for _ in 0..16 { + assert_eq!(rng1.next_u32(), rng2.next_u32()); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/prng/isaac.rs b/third_party/cargo/vendor/rand-0.5.6/src/prng/isaac.rs new file mode 100644 index 0000000..99c80d6 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/prng/isaac.rs @@ -0,0 +1,494 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The ISAAC random number generator. + +use core::{fmt, slice}; +use core::num::Wrapping as w; +use rand_core::{RngCore, SeedableRng, Error, le}; +use rand_core::block::{BlockRngCore, BlockRng}; +use prng::isaac_array::IsaacArray; + +#[allow(non_camel_case_types)] +type w32 = w; + +const RAND_SIZE_LEN: usize = 8; +const RAND_SIZE: usize = 1 << RAND_SIZE_LEN; + +/// A random number generator that uses the ISAAC algorithm. +/// +/// ISAAC stands for "Indirection, Shift, Accumulate, Add, and Count" which are +/// the principal bitwise operations employed. It is the most advanced of a +/// series of array based random number generator designed by Robert Jenkins +/// in 1996[^1][^2]. +/// +/// ISAAC is notably fast and produces excellent quality random numbers for +/// non-cryptographic applications. +/// +/// In spite of being designed with cryptographic security in mind, ISAAC hasn't +/// been stringently cryptanalyzed and thus cryptographers do not not +/// consensually trust it to be secure. When looking for a secure RNG, prefer +/// [`Hc128Rng`] instead, which, like ISAAC, is an array-based RNG and one of +/// the stream-ciphers selected the by eSTREAM contest. +/// +/// In 2006 an improvement to ISAAC was suggested by Jean-Philippe Aumasson, +/// named ISAAC+[^3]. But because the specification is not complete, because +/// there is no good implementation, and because the suggested bias may not +/// exist, it is not implemented here. +/// +/// ## Overview of the ISAAC algorithm: +/// (in pseudo-code) +/// +/// ```text +/// Input: a, b, c, s[256] // state +/// Output: r[256] // results +/// +/// mix(a,i) = a ^ a << 13 if i = 0 mod 4 +/// a ^ a >> 6 if i = 1 mod 4 +/// a ^ a << 2 if i = 2 mod 4 +/// a ^ a >> 16 if i = 3 mod 4 +/// +/// c = c + 1 +/// b = b + c +/// +/// for i in 0..256 { +/// x = s_[i] +/// a = f(a,i) + s[i+128 mod 256] +/// y = a + b + s[x>>2 mod 256] +/// s[i] = y +/// b = x + s[y>>10 mod 256] +/// r[i] = b +/// } +/// ``` +/// +/// Numbers are generated in blocks of 256. This means the function above only +/// runs once every 256 times you ask for a next random number. In all other +/// circumstances the last element of the results array is returned. +/// +/// ISAAC therefore needs a lot of memory, relative to other non-crypto RNGs. +/// 2 * 256 * 4 = 2 kb to hold the state and results. +/// +/// This implementation uses [`BlockRng`] to implement the [`RngCore`] methods. +/// +/// ## References +/// [^1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number generator*]( +/// http://burtleburtle.net/bob/rand/isaacafa.html) +/// +/// [^2]: Bob Jenkins, [*ISAAC and RC4*]( +/// http://burtleburtle.net/bob/rand/isaac.html) +/// +/// [^3]: Jean-Philippe Aumasson, [*On the pseudo-random generator ISAAC*]( +/// https://eprint.iacr.org/2006/438) +/// +/// [`Hc128Rng`]: ../hc128/struct.Hc128Rng.html +/// [`BlockRng`]: ../../../rand_core/block/struct.BlockRng.html +/// [`RngCore`]: ../../trait.RngCore.html +#[derive(Clone, Debug)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct IsaacRng(BlockRng); + +impl RngCore for IsaacRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for IsaacRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + IsaacRng(BlockRng::::from_seed(seed)) + } + + /// Create an ISAAC random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + fn seed_from_u64(seed: u64) -> Self { + IsaacRng(BlockRng::::seed_from_u64(seed)) + } + + fn from_rng(rng: S) -> Result { + BlockRng::::from_rng(rng).map(|rng| IsaacRng(rng)) + } +} + +impl IsaacRng { + /// Create an ISAAC random number generator using the default + /// fixed seed. + /// + /// DEPRECATED. `IsaacRng::new_from_u64(0)` will produce identical results. + #[deprecated(since="0.5.0", note="use the FromEntropy or SeedableRng trait")] + pub fn new_unseeded() -> Self { + Self::seed_from_u64(0) + } + + /// Create an ISAAC random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + #[deprecated(since="0.6.0", note="use SeedableRng::seed_from_u64 instead")] + pub fn new_from_u64(seed: u64) -> Self { + Self::seed_from_u64(seed) + } +} + +/// The core of `IsaacRng`, used with `BlockRng`. +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct IsaacCore { + #[cfg_attr(feature="serde1",serde(with="super::isaac_array::isaac_array_serde"))] + mem: [w32; RAND_SIZE], + a: w32, + b: w32, + c: w32, +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for IsaacCore { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "IsaacCore {{}}") + } +} + +impl BlockRngCore for IsaacCore { + type Item = u32; + type Results = IsaacArray; + + /// Refills the output buffer, `results`. See also the pseudocode desciption + /// of the algorithm in the [`IsaacRng`] documentation. + /// + /// Optimisations used (similar to the reference implementation): + /// + /// - The loop is unrolled 4 times, once for every constant of mix(). + /// - The contents of the main loop are moved to a function `rngstep`, to + /// reduce code duplication. + /// - We use local variables for a and b, which helps with optimisations. + /// - We split the main loop in two, one that operates over 0..128 and one + /// over 128..256. This way we can optimise out the addition and modulus + /// from `s[i+128 mod 256]`. + /// - We maintain one index `i` and add `m` or `m2` as base (m2 for the + /// `s[i+128 mod 256]`), relying on the optimizer to turn it into pointer + /// arithmetic. + /// - We fill `results` backwards. The reference implementation reads values + /// from `results` in reverse. We read them in the normal direction, to + /// make `fill_bytes` a memcopy. To maintain compatibility we fill in + /// reverse. + /// + /// [`IsaacRng`]: struct.IsaacRng.html + fn generate(&mut self, results: &mut IsaacArray) { + self.c += w(1); + // abbreviations + let mut a = self.a; + let mut b = self.b + self.c; + const MIDPOINT: usize = RAND_SIZE / 2; + + #[inline] + fn ind(mem:&[w32; RAND_SIZE], v: w32, amount: usize) -> w32 { + let index = (v >> amount).0 as usize % RAND_SIZE; + mem[index] + } + + #[inline] + fn rngstep(mem: &mut [w32; RAND_SIZE], + results: &mut [u32; RAND_SIZE], + mix: w32, + a: &mut w32, + b: &mut w32, + base: usize, + m: usize, + m2: usize) { + let x = mem[base + m]; + *a = mix + mem[base + m2]; + let y = *a + *b + ind(&mem, x, 2); + mem[base + m] = y; + *b = x + ind(&mem, y, 2 + RAND_SIZE_LEN); + results[RAND_SIZE - 1 - base - m] = (*b).0; + } + + let mut m = 0; + let mut m2 = MIDPOINT; + for i in (0..MIDPOINT/4).map(|i| i * 4) { + rngstep(&mut self.mem, results, a ^ (a << 13), &mut a, &mut b, i + 0, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 6 ), &mut a, &mut b, i + 1, m, m2); + rngstep(&mut self.mem, results, a ^ (a << 2 ), &mut a, &mut b, i + 2, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 16), &mut a, &mut b, i + 3, m, m2); + } + + m = MIDPOINT; + m2 = 0; + for i in (0..MIDPOINT/4).map(|i| i * 4) { + rngstep(&mut self.mem, results, a ^ (a << 13), &mut a, &mut b, i + 0, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 6 ), &mut a, &mut b, i + 1, m, m2); + rngstep(&mut self.mem, results, a ^ (a << 2 ), &mut a, &mut b, i + 2, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 16), &mut a, &mut b, i + 3, m, m2); + } + + self.a = a; + self.b = b; + } +} + +impl IsaacCore { + /// Create a new ISAAC random number generator. + /// + /// The author Bob Jenkins describes how to best initialize ISAAC here: + /// + /// The answer is included here just in case: + /// + /// "No, you don't need a full 8192 bits of seed data. Normal key sizes will + /// do fine, and they should have their expected strength (eg a 40-bit key + /// will take as much time to brute force as 40-bit keys usually will). You + /// could fill the remainder with 0, but set the last array element to the + /// length of the key provided (to distinguish keys that differ only by + /// different amounts of 0 padding). You do still need to call `randinit()` + /// to make sure the initial state isn't uniform-looking." + /// "After publishing ISAAC, I wanted to limit the key to half the size of + /// `r[]`, and repeat it twice. That would have made it hard to provide a + /// key that sets the whole internal state to anything convenient. But I'd + /// already published it." + /// + /// And his answer to the question "For my code, would repeating the key + /// over and over to fill 256 integers be a better solution than + /// zero-filling, or would they essentially be the same?": + /// "If the seed is under 32 bytes, they're essentially the same, otherwise + /// repeating the seed would be stronger. randinit() takes a chunk of 32 + /// bytes, mixes it, and combines that with the next 32 bytes, et cetera. + /// Then loops over all the elements the same way a second time." + #[inline] + fn init(mut mem: [w32; RAND_SIZE], rounds: u32) -> Self { + fn mix(a: &mut w32, b: &mut w32, c: &mut w32, d: &mut w32, + e: &mut w32, f: &mut w32, g: &mut w32, h: &mut w32) { + *a ^= *b << 11; *d += *a; *b += *c; + *b ^= *c >> 2; *e += *b; *c += *d; + *c ^= *d << 8; *f += *c; *d += *e; + *d ^= *e >> 16; *g += *d; *e += *f; + *e ^= *f << 10; *h += *e; *f += *g; + *f ^= *g >> 4; *a += *f; *g += *h; + *g ^= *h << 8; *b += *g; *h += *a; + *h ^= *a >> 9; *c += *h; *a += *b; + } + + // These numbers are the result of initializing a...h with the + // fractional part of the golden ratio in binary (0x9e3779b9) + // and applying mix() 4 times. + let mut a = w(0x1367df5a); + let mut b = w(0x95d90059); + let mut c = w(0xc3163e4b); + let mut d = w(0x0f421ad8); + let mut e = w(0xd92a4a78); + let mut f = w(0xa51a3c49); + let mut g = w(0xc4efea1b); + let mut h = w(0x30609119); + + // Normally this should do two passes, to make all of the seed effect + // all of `mem` + for _ in 0..rounds { + for i in (0..RAND_SIZE/8).map(|i| i * 8) { + a += mem[i ]; b += mem[i+1]; + c += mem[i+2]; d += mem[i+3]; + e += mem[i+4]; f += mem[i+5]; + g += mem[i+6]; h += mem[i+7]; + mix(&mut a, &mut b, &mut c, &mut d, + &mut e, &mut f, &mut g, &mut h); + mem[i ] = a; mem[i+1] = b; + mem[i+2] = c; mem[i+3] = d; + mem[i+4] = e; mem[i+5] = f; + mem[i+6] = g; mem[i+7] = h; + } + } + + Self { mem, a: w(0), b: w(0), c: w(0) } + } +} + +impl SeedableRng for IsaacCore { + type Seed = [u8; 32]; + + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_u32 = [0u32; 8]; + le::read_u32_into(&seed, &mut seed_u32); + // Convert the seed to `Wrapping` and zero-extend to `RAND_SIZE`. + let mut seed_extended = [w(0); RAND_SIZE]; + for (x, y) in seed_extended.iter_mut().zip(seed_u32.iter()) { + *x = w(*y); + } + Self::init(seed_extended, 2) + } + + /// Create an ISAAC random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + fn seed_from_u64(seed: u64) -> Self { + let mut key = [w(0); RAND_SIZE]; + key[0] = w(seed as u32); + key[1] = w((seed >> 32) as u32); + // Initialize with only one pass. + // A second pass does not improve the quality here, because all of the + // seed was already available in the first round. + // Not doing the second pass has the small advantage that if + // `seed == 0` this method produces exactly the same state as the + // reference implementation when used unseeded. + Self::init(key, 1) + } + + fn from_rng(mut rng: R) -> Result { + // Custom `from_rng` implementation that fills a seed with the same size + // as the entire state. + let mut seed = [w(0u32); RAND_SIZE]; + unsafe { + let ptr = seed.as_mut_ptr() as *mut u8; + + let slice = slice::from_raw_parts_mut(ptr, RAND_SIZE * 4); + rng.try_fill_bytes(slice)?; + } + for i in seed.iter_mut() { + *i = w(i.0.to_le()); + } + + Ok(Self::init(seed, 2)) + } +} + +#[cfg(test)] +mod test { + use {RngCore, SeedableRng}; + use super::IsaacRng; + + #[test] + fn test_isaac_construction() { + // Test that various construction techniques produce a working RNG. + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng1 = IsaacRng::from_seed(seed); + assert_eq!(rng1.next_u32(), 2869442790); + + let mut rng2 = IsaacRng::from_rng(rng1).unwrap(); + assert_eq!(rng2.next_u32(), 3094074039); + } + + #[test] + fn test_isaac_true_values_32() { + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng1 = IsaacRng::from_seed(seed); + let mut results = [0u32; 10]; + for i in results.iter_mut() { *i = rng1.next_u32(); } + let expected = [ + 2558573138, 873787463, 263499565, 2103644246, 3595684709, + 4203127393, 264982119, 2765226902, 2737944514, 3900253796]; + assert_eq!(results, expected); + + let seed = [57,48,0,0, 50,9,1,0, 49,212,0,0, 148,38,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng2 = IsaacRng::from_seed(seed); + // skip forward to the 10000th number + for _ in 0..10000 { rng2.next_u32(); } + + for i in results.iter_mut() { *i = rng2.next_u32(); } + let expected = [ + 3676831399, 3183332890, 2834741178, 3854698763, 2717568474, + 1576568959, 3507990155, 179069555, 141456972, 2478885421]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac_true_values_64() { + // As above, using little-endian versions of above values + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng = IsaacRng::from_seed(seed); + let mut results = [0u64; 5]; + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected = [ + 3752888579798383186, 9035083239252078381,18052294697452424037, + 11876559110374379111, 16751462502657800130]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac_true_bytes() { + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng = IsaacRng::from_seed(seed); + let mut results = [0u8; 32]; + rng.fill_bytes(&mut results); + // Same as first values in test_isaac_true_values as bytes in LE order + let expected = [82, 186, 128, 152, 71, 240, 20, 52, + 45, 175, 180, 15, 86, 16, 99, 125, + 101, 203, 81, 214, 97, 162, 134, 250, + 103, 78, 203, 15, 150, 3, 210, 164]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac_new_uninitialized() { + // Compare the results from initializing `IsaacRng` with + // `seed_from_u64(0)`, to make sure it is the same as the reference + // implementation when used uninitialized. + // Note: We only test the first 16 integers, not the full 256 of the + // first block. + let mut rng = IsaacRng::seed_from_u64(0); + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected: [u32; 16] = [ + 0x71D71FD2, 0xB54ADAE7, 0xD4788559, 0xC36129FA, + 0x21DC1EA9, 0x3CB879CA, 0xD83B237F, 0xFA3CE5BD, + 0x8D048509, 0xD82E9489, 0xDB452848, 0xCA20E846, + 0x500F972E, 0x0EEFF940, 0x00D6B993, 0xBC12C17F]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac_clone() { + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng1 = IsaacRng::from_seed(seed); + let mut rng2 = rng1.clone(); + for _ in 0..16 { + assert_eq!(rng1.next_u32(), rng2.next_u32()); + } + } + + #[test] + #[cfg(all(feature="serde1", feature="std"))] + fn test_isaac_serde() { + use bincode; + use std::io::{BufWriter, BufReader}; + + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng = IsaacRng::from_seed(seed); + + let buf: Vec = Vec::new(); + let mut buf = BufWriter::new(buf); + bincode::serialize_into(&mut buf, &rng).expect("Could not serialize"); + + let buf = buf.into_inner().unwrap(); + let mut read = BufReader::new(&buf[..]); + let mut deserialized: IsaacRng = bincode::deserialize_from(&mut read).expect("Could not deserialize"); + + for _ in 0..300 { // more than the 256 buffered results + assert_eq!(rng.next_u32(), deserialized.next_u32()); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/prng/isaac64.rs b/third_party/cargo/vendor/rand-0.5.6/src/prng/isaac64.rs new file mode 100644 index 0000000..fb3156d --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/prng/isaac64.rs @@ -0,0 +1,491 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The ISAAC-64 random number generator. + +use core::{fmt, slice}; +use core::num::Wrapping as w; +use rand_core::{RngCore, SeedableRng, Error, le}; +use rand_core::block::{BlockRngCore, BlockRng64}; +use prng::isaac_array::IsaacArray; + +#[allow(non_camel_case_types)] +type w64 = w; + +const RAND_SIZE_LEN: usize = 8; +const RAND_SIZE: usize = 1 << RAND_SIZE_LEN; + +/// A random number generator that uses ISAAC-64, the 64-bit variant of the +/// ISAAC algorithm. +/// +/// ISAAC stands for "Indirection, Shift, Accumulate, Add, and Count" which are +/// the principal bitwise operations employed. It is the most advanced of a +/// series of array based random number generator designed by Robert Jenkins +/// in 1996[^1]. +/// +/// ISAAC-64 is mostly similar to ISAAC. Because it operates on 64-bit integers +/// instead of 32-bit, it uses twice as much memory to hold its state and +/// results. Also it uses different constants for shifts and indirect indexing, +/// optimized to give good results for 64bit arithmetic. +/// +/// ISAAC-64 is notably fast and produces excellent quality random numbers for +/// non-cryptographic applications. +/// +/// In spite of being designed with cryptographic security in mind, ISAAC hasn't +/// been stringently cryptanalyzed and thus cryptographers do not not +/// consensually trust it to be secure. When looking for a secure RNG, prefer +/// [`Hc128Rng`] instead, which, like ISAAC, is an array-based RNG and one of +/// the stream-ciphers selected the by eSTREAM contest. +/// +/// ## Overview of the ISAAC-64 algorithm: +/// (in pseudo-code) +/// +/// ```text +/// Input: a, b, c, s[256] // state +/// Output: r[256] // results +/// +/// mix(a,i) = !(a ^ a << 21) if i = 0 mod 4 +/// a ^ a >> 5 if i = 1 mod 4 +/// a ^ a << 12 if i = 2 mod 4 +/// a ^ a >> 33 if i = 3 mod 4 +/// +/// c = c + 1 +/// b = b + c +/// +/// for i in 0..256 { +/// x = s_[i] +/// a = mix(a,i) + s[i+128 mod 256] +/// y = a + b + s[x>>3 mod 256] +/// s[i] = y +/// b = x + s[y>>11 mod 256] +/// r[i] = b +/// } +/// ``` +/// +/// This implementation uses [`BlockRng64`] to implement the [`RngCore`] methods. +/// +/// See for more information the documentation of [`IsaacRng`]. +/// +/// [^1]: Bob Jenkins, [*ISAAC and RC4*]( +/// http://burtleburtle.net/bob/rand/isaac.html) +/// +/// [`IsaacRng`]: ../isaac/struct.IsaacRng.html +/// [`Hc128Rng`]: ../hc128/struct.Hc128Rng.html +/// [`BlockRng64`]: ../../../rand_core/block/struct.BlockRng64.html +/// [`RngCore`]: ../../trait.RngCore.html +#[derive(Clone, Debug)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct Isaac64Rng(BlockRng64); + +impl RngCore for Isaac64Rng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for Isaac64Rng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + Isaac64Rng(BlockRng64::::from_seed(seed)) + } + + /// Create an ISAAC random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + fn seed_from_u64(seed: u64) -> Self { + Isaac64Rng(BlockRng64::::seed_from_u64(seed)) + } + + fn from_rng(rng: S) -> Result { + BlockRng64::::from_rng(rng).map(|rng| Isaac64Rng(rng)) + } +} + +impl Isaac64Rng { + /// Create a 64-bit ISAAC random number generator using the + /// default fixed seed. + /// + /// DEPRECATED. `Isaac64Rng::new_from_u64(0)` will produce identical results. + #[deprecated(since="0.5.0", note="use the FromEntropy or SeedableRng trait")] + pub fn new_unseeded() -> Self { + Self::seed_from_u64(0) + } + + /// Create an ISAAC-64 random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + #[deprecated(since="0.6.0", note="use SeedableRng::seed_from_u64 instead")] + pub fn new_from_u64(seed: u64) -> Self { + Self::seed_from_u64(seed) + } +} + +/// The core of `Isaac64Rng`, used with `BlockRng`. +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct Isaac64Core { + #[cfg_attr(feature="serde1",serde(with="super::isaac_array::isaac_array_serde"))] + mem: [w64; RAND_SIZE], + a: w64, + b: w64, + c: w64, +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for Isaac64Core { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Isaac64Core {{}}") + } +} + +impl BlockRngCore for Isaac64Core { + type Item = u64; + type Results = IsaacArray; + + /// Refills the output buffer, `results`. See also the pseudocode desciption + /// of the algorithm in the [`Isaac64Rng`] documentation. + /// + /// Optimisations used (similar to the reference implementation): + /// + /// - The loop is unrolled 4 times, once for every constant of mix(). + /// - The contents of the main loop are moved to a function `rngstep`, to + /// reduce code duplication. + /// - We use local variables for a and b, which helps with optimisations. + /// - We split the main loop in two, one that operates over 0..128 and one + /// over 128..256. This way we can optimise out the addition and modulus + /// from `s[i+128 mod 256]`. + /// - We maintain one index `i` and add `m` or `m2` as base (m2 for the + /// `s[i+128 mod 256]`), relying on the optimizer to turn it into pointer + /// arithmetic. + /// - We fill `results` backwards. The reference implementation reads values + /// from `results` in reverse. We read them in the normal direction, to + /// make `fill_bytes` a memcopy. To maintain compatibility we fill in + /// reverse. + /// + /// [`Isaac64Rng`]: struct.Isaac64Rng.html + fn generate(&mut self, results: &mut IsaacArray) { + self.c += w(1); + // abbreviations + let mut a = self.a; + let mut b = self.b + self.c; + const MIDPOINT: usize = RAND_SIZE / 2; + + #[inline] + fn ind(mem:&[w64; RAND_SIZE], v: w64, amount: usize) -> w64 { + let index = (v >> amount).0 as usize % RAND_SIZE; + mem[index] + } + + #[inline] + fn rngstep(mem: &mut [w64; RAND_SIZE], + results: &mut [u64; RAND_SIZE], + mix: w64, + a: &mut w64, + b: &mut w64, + base: usize, + m: usize, + m2: usize) { + let x = mem[base + m]; + *a = mix + mem[base + m2]; + let y = *a + *b + ind(&mem, x, 3); + mem[base + m] = y; + *b = x + ind(&mem, y, 3 + RAND_SIZE_LEN); + results[RAND_SIZE - 1 - base - m] = (*b).0; + } + + let mut m = 0; + let mut m2 = MIDPOINT; + for i in (0..MIDPOINT/4).map(|i| i * 4) { + rngstep(&mut self.mem, results, !(a ^ (a << 21)), &mut a, &mut b, i + 0, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 5 ), &mut a, &mut b, i + 1, m, m2); + rngstep(&mut self.mem, results, a ^ (a << 12), &mut a, &mut b, i + 2, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 33), &mut a, &mut b, i + 3, m, m2); + } + + m = MIDPOINT; + m2 = 0; + for i in (0..MIDPOINT/4).map(|i| i * 4) { + rngstep(&mut self.mem, results, !(a ^ (a << 21)), &mut a, &mut b, i + 0, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 5 ), &mut a, &mut b, i + 1, m, m2); + rngstep(&mut self.mem, results, a ^ (a << 12), &mut a, &mut b, i + 2, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 33), &mut a, &mut b, i + 3, m, m2); + } + + self.a = a; + self.b = b; + } +} + +impl Isaac64Core { + /// Create a new ISAAC-64 random number generator. + fn init(mut mem: [w64; RAND_SIZE], rounds: u32) -> Self { + fn mix(a: &mut w64, b: &mut w64, c: &mut w64, d: &mut w64, + e: &mut w64, f: &mut w64, g: &mut w64, h: &mut w64) { + *a -= *e; *f ^= *h >> 9; *h += *a; + *b -= *f; *g ^= *a << 9; *a += *b; + *c -= *g; *h ^= *b >> 23; *b += *c; + *d -= *h; *a ^= *c << 15; *c += *d; + *e -= *a; *b ^= *d >> 14; *d += *e; + *f -= *b; *c ^= *e << 20; *e += *f; + *g -= *c; *d ^= *f >> 17; *f += *g; + *h -= *d; *e ^= *g << 14; *g += *h; + } + + // These numbers are the result of initializing a...h with the + // fractional part of the golden ratio in binary (0x9e3779b97f4a7c13) + // and applying mix() 4 times. + let mut a = w(0x647c4677a2884b7c); + let mut b = w(0xb9f8b322c73ac862); + let mut c = w(0x8c0ea5053d4712a0); + let mut d = w(0xb29b2e824a595524); + let mut e = w(0x82f053db8355e0ce); + let mut f = w(0x48fe4a0fa5a09315); + let mut g = w(0xae985bf2cbfc89ed); + let mut h = w(0x98f5704f6c44c0ab); + + // Normally this should do two passes, to make all of the seed effect + // all of `mem` + for _ in 0..rounds { + for i in (0..RAND_SIZE/8).map(|i| i * 8) { + a += mem[i ]; b += mem[i+1]; + c += mem[i+2]; d += mem[i+3]; + e += mem[i+4]; f += mem[i+5]; + g += mem[i+6]; h += mem[i+7]; + mix(&mut a, &mut b, &mut c, &mut d, + &mut e, &mut f, &mut g, &mut h); + mem[i ] = a; mem[i+1] = b; + mem[i+2] = c; mem[i+3] = d; + mem[i+4] = e; mem[i+5] = f; + mem[i+6] = g; mem[i+7] = h; + } + } + + Self { mem, a: w(0), b: w(0), c: w(0) } + } + + /// Create an ISAAC-64 random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + #[deprecated(since="0.6.0", note="use SeedableRng::seed_from_u64 instead")] + pub fn new_from_u64(seed: u64) -> Self { + Self::seed_from_u64(seed) + } +} + +impl SeedableRng for Isaac64Core { + type Seed = [u8; 32]; + + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_u64 = [0u64; 4]; + le::read_u64_into(&seed, &mut seed_u64); + // Convert the seed to `Wrapping` and zero-extend to `RAND_SIZE`. + let mut seed_extended = [w(0); RAND_SIZE]; + for (x, y) in seed_extended.iter_mut().zip(seed_u64.iter()) { + *x = w(*y); + } + Self::init(seed_extended, 2) + } + + fn seed_from_u64(seed: u64) -> Self { + let mut key = [w(0); RAND_SIZE]; + key[0] = w(seed); + // Initialize with only one pass. + // A second pass does not improve the quality here, because all of the + // seed was already available in the first round. + // Not doing the second pass has the small advantage that if + // `seed == 0` this method produces exactly the same state as the + // reference implementation when used unseeded. + Self::init(key, 1) + } + + fn from_rng(mut rng: R) -> Result { + // Custom `from_rng` implementation that fills a seed with the same size + // as the entire state. + let mut seed = [w(0u64); RAND_SIZE]; + unsafe { + let ptr = seed.as_mut_ptr() as *mut u8; + let slice = slice::from_raw_parts_mut(ptr, RAND_SIZE * 8); + rng.try_fill_bytes(slice)?; + } + for i in seed.iter_mut() { + *i = w(i.0.to_le()); + } + + Ok(Self::init(seed, 2)) + } +} + +#[cfg(test)] +mod test { + use {RngCore, SeedableRng}; + use super::Isaac64Rng; + + #[test] + fn test_isaac64_construction() { + // Test that various construction techniques produce a working RNG. + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng1 = Isaac64Rng::from_seed(seed); + assert_eq!(rng1.next_u64(), 14964555543728284049); + + let mut rng2 = Isaac64Rng::from_rng(rng1).unwrap(); + assert_eq!(rng2.next_u64(), 919595328260451758); + } + + #[test] + fn test_isaac64_true_values_64() { + let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0, + 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0]; + let mut rng1 = Isaac64Rng::from_seed(seed); + let mut results = [0u64; 10]; + for i in results.iter_mut() { *i = rng1.next_u64(); } + let expected = [ + 15071495833797886820, 7720185633435529318, + 10836773366498097981, 5414053799617603544, + 12890513357046278984, 17001051845652595546, + 9240803642279356310, 12558996012687158051, + 14673053937227185542, 1677046725350116783]; + assert_eq!(results, expected); + + let seed = [57,48,0,0, 0,0,0,0, 50,9,1,0, 0,0,0,0, + 49,212,0,0, 0,0,0,0, 148,38,0,0, 0,0,0,0]; + let mut rng2 = Isaac64Rng::from_seed(seed); + // skip forward to the 10000th number + for _ in 0..10000 { rng2.next_u64(); } + + for i in results.iter_mut() { *i = rng2.next_u64(); } + let expected = [ + 18143823860592706164, 8491801882678285927, 2699425367717515619, + 17196852593171130876, 2606123525235546165, 15790932315217671084, + 596345674630742204, 9947027391921273664, 11788097613744130851, + 10391409374914919106]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac64_true_values_32() { + let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0, + 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0]; + let mut rng = Isaac64Rng::from_seed(seed); + let mut results = [0u32; 12]; + for i in results.iter_mut() { *i = rng.next_u32(); } + // Subset of above values, as an LE u32 sequence + let expected = [ + 3477963620, 3509106075, + 687845478, 1797495790, + 227048253, 2523132918, + 4044335064, 1260557630, + 4079741768, 3001306521, + 69157722, 3958365844]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac64_true_values_mixed() { + let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0, + 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0]; + let mut rng = Isaac64Rng::from_seed(seed); + // Test alternating between `next_u64` and `next_u32` works as expected. + // Values are the same as `test_isaac64_true_values` and + // `test_isaac64_true_values_32`. + assert_eq!(rng.next_u64(), 15071495833797886820); + assert_eq!(rng.next_u32(), 687845478); + assert_eq!(rng.next_u32(), 1797495790); + assert_eq!(rng.next_u64(), 10836773366498097981); + assert_eq!(rng.next_u32(), 4044335064); + // Skip one u32 + assert_eq!(rng.next_u64(), 12890513357046278984); + assert_eq!(rng.next_u32(), 69157722); + } + + #[test] + fn test_isaac64_true_bytes() { + let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0, + 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0]; + let mut rng = Isaac64Rng::from_seed(seed); + let mut results = [0u8; 32]; + rng.fill_bytes(&mut results); + // Same as first values in test_isaac64_true_values as bytes in LE order + let expected = [100, 131, 77, 207, 155, 181, 40, 209, + 102, 176, 255, 40, 238, 155, 35, 107, + 61, 123, 136, 13, 246, 243, 99, 150, + 216, 167, 15, 241, 62, 149, 34, 75]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac64_new_uninitialized() { + // Compare the results from initializing `IsaacRng` with + // `seed_from_u64(0)`, to make sure it is the same as the reference + // implementation when used uninitialized. + // Note: We only test the first 16 integers, not the full 256 of the + // first block. + let mut rng = Isaac64Rng::seed_from_u64(0); + let mut results = [0u64; 16]; + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected: [u64; 16] = [ + 0xF67DFBA498E4937C, 0x84A5066A9204F380, 0xFEE34BD5F5514DBB, + 0x4D1664739B8F80D6, 0x8607459AB52A14AA, 0x0E78BC5A98529E49, + 0xFE5332822AD13777, 0x556C27525E33D01A, 0x08643CA615F3149F, + 0xD0771FAF3CB04714, 0x30E86F68A37B008D, 0x3074EBC0488A3ADF, + 0x270645EA7A2790BC, 0x5601A0A8D3763C6A, 0x2F83071F53F325DD, + 0xB9090F3D42D2D2EA]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac64_clone() { + let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0, + 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0]; + let mut rng1 = Isaac64Rng::from_seed(seed); + let mut rng2 = rng1.clone(); + for _ in 0..16 { + assert_eq!(rng1.next_u64(), rng2.next_u64()); + } + } + + #[test] + #[cfg(all(feature="serde1", feature="std"))] + fn test_isaac64_serde() { + use bincode; + use std::io::{BufWriter, BufReader}; + + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng = Isaac64Rng::from_seed(seed); + + let buf: Vec = Vec::new(); + let mut buf = BufWriter::new(buf); + bincode::serialize_into(&mut buf, &rng).expect("Could not serialize"); + + let buf = buf.into_inner().unwrap(); + let mut read = BufReader::new(&buf[..]); + let mut deserialized: Isaac64Rng = bincode::deserialize_from(&mut read).expect("Could not deserialize"); + + for _ in 0..300 { // more than the 256 buffered results + assert_eq!(rng.next_u64(), deserialized.next_u64()); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/prng/isaac_array.rs b/third_party/cargo/vendor/rand-0.5.6/src/prng/isaac_array.rs new file mode 100644 index 0000000..3ebf828 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/prng/isaac_array.rs @@ -0,0 +1,137 @@ +// Copyright 2017-2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! ISAAC helper functions for 256-element arrays. + +// Terrible workaround because arrays with more than 32 elements do not +// implement `AsRef`, `Default`, `Serialize`, `Deserialize`, or any other +// traits for that matter. + +#[cfg(feature="serde1")] use serde::{Serialize, Deserialize}; + +const RAND_SIZE_LEN: usize = 8; +const RAND_SIZE: usize = 1 << RAND_SIZE_LEN; + + +#[derive(Copy, Clone)] +#[allow(missing_debug_implementations)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct IsaacArray { + #[cfg_attr(feature="serde1",serde(with="isaac_array_serde"))] + #[cfg_attr(feature="serde1", serde(bound( + serialize = "T: Serialize", + deserialize = "T: Deserialize<'de> + Copy + Default")))] + inner: [T; RAND_SIZE] +} + +impl ::core::convert::AsRef<[T]> for IsaacArray { + #[inline(always)] + fn as_ref(&self) -> &[T] { + &self.inner[..] + } +} + +impl ::core::convert::AsMut<[T]> for IsaacArray { + #[inline(always)] + fn as_mut(&mut self) -> &mut [T] { + &mut self.inner[..] + } +} + +impl ::core::ops::Deref for IsaacArray { + type Target = [T; RAND_SIZE]; + #[inline(always)] + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl ::core::ops::DerefMut for IsaacArray { + #[inline(always)] + fn deref_mut(&mut self) -> &mut [T; RAND_SIZE] { + &mut self.inner + } +} + +impl ::core::default::Default for IsaacArray where T: Copy + Default { + fn default() -> IsaacArray { + IsaacArray { inner: [T::default(); RAND_SIZE] } + } +} + + +#[cfg(feature="serde1")] +pub(super) mod isaac_array_serde { + const RAND_SIZE_LEN: usize = 8; + const RAND_SIZE: usize = 1 << RAND_SIZE_LEN; + + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + use serde::de::{Visitor,SeqAccess}; + use serde::de; + + use core::fmt; + + pub fn serialize(arr: &[T;RAND_SIZE], ser: S) -> Result + where + T: Serialize, + S: Serializer + { + use serde::ser::SerializeTuple; + + let mut seq = ser.serialize_tuple(RAND_SIZE)?; + + for e in arr.iter() { + seq.serialize_element(&e)?; + } + + seq.end() + } + + #[inline] + pub fn deserialize<'de, T, D>(de: D) -> Result<[T;RAND_SIZE], D::Error> + where + T: Deserialize<'de>+Default+Copy, + D: Deserializer<'de>, + { + use core::marker::PhantomData; + struct ArrayVisitor { + _pd: PhantomData, + }; + impl<'de,T> Visitor<'de> for ArrayVisitor + where + T: Deserialize<'de>+Default+Copy + { + type Value = [T; RAND_SIZE]; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Isaac state array") + } + + #[inline] + fn visit_seq(self, mut seq: A) -> Result<[T; RAND_SIZE], A::Error> + where + A: SeqAccess<'de>, + { + let mut out = [Default::default();RAND_SIZE]; + + for i in 0..RAND_SIZE { + match seq.next_element()? { + Some(val) => out[i] = val, + None => return Err(de::Error::invalid_length(i, &self)), + }; + } + + Ok(out) + } + } + + de.deserialize_tuple(RAND_SIZE, ArrayVisitor{_pd: PhantomData}) + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/prng/mod.rs b/third_party/cargo/vendor/rand-0.5.6/src/prng/mod.rs new file mode 100644 index 0000000..240b682 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/prng/mod.rs @@ -0,0 +1,330 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Pseudo-random number generators. +//! +//! Pseudo-random number generators are algorithms to produce apparently random +//! numbers deterministically, and usually fairly quickly. See the documentation +//! of the [`rngs` module] for some introduction to PRNGs. +//! +//! As mentioned there, PRNGs fall in two broad categories: +//! +//! - [basic PRNGs], primarily designed for simulations +//! - [CSPRNGs], primarily designed for cryptography +//! +//! In simple terms, the basic PRNGs are often predictable; CSPRNGs should not +//! be predictable *when used correctly*. +//! +//! Contents of this documentation: +//! +//! 1. [The generators](#the-generators) +//! 1. [Performance and size](#performance) +//! 1. [Quality and cycle length](#quality) +//! 1. [Security](#security) +//! 1. [Extra features](#extra-features) +//! 1. [Further reading](#further-reading) +//! +//! +//! # The generators +//! +//! ## Basic pseudo-random number generators (PRNGs) +//! +//! The goal of regular, non-cryptographic PRNGs is usually to find a good +//! balance between simplicity, quality, memory usage and performance. These +//! algorithms are very important to Monte Carlo simulations, and also suitable +//! for several other problems such as randomized algorithms and games (except +//! where there is a risk of players predicting the next output value from +//! previous values, in which case a CSPRNG should be used). +//! +//! Currently Rand provides only one PRNG, and not a very good one at that: +//! +//! | name | full name | performance | memory | quality | period | features | +//! |------|-----------|-------------|--------|---------|--------|----------| +//! | [`XorShiftRng`] | Xorshift 32/128 | ★★★☆☆ | 16 bytes | ★☆☆☆☆ | `u32` * 2128 - 1 | — | +//! +// Quality stars [not rendered in documentation]: +// 5. reserved for crypto-level (e.g. ChaCha8, ISAAC) +// 4. good performance on TestU01 and PractRand, good theory +// (e.g. PCG, truncated Xorshift*) +// 3. good performance on TestU01 and PractRand, but "falling through the +// cracks" or insufficient theory (e.g. SFC, Xoshiro) +// 2. imperfect performance on tests or other limiting properties, but not +// terrible (e.g. Xoroshiro128+) +// 1. clear deficiencies in test results, cycle length, theory, or other +// properties (e.g. Xorshift) +// +// Performance stars [not rendered in documentation]: +// Meant to give an indication of relative performance. Roughly follows a log +// scale, based on the performance of `next_u64` on a current i5/i7: +// - 5. 8000 MB/s+ +// - 4. 4000 MB/s+ +// - 3. 2000 MB/s+ +// - 2. 1000 MB/s+ +// - 1. < 1000 MB/s +// +//! ## Cryptographically secure pseudo-random number generators (CSPRNGs) +//! +//! CSPRNGs have much higher requirements than basic PRNGs. The primary +//! consideration is security. Performance and simplicity are also important, +//! but in general CSPRNGs are more complex and slower than regular PRNGs. +//! Quality is no longer a concern, as it is a requirement for a +//! CSPRNG that the output is basically indistinguishable from true randomness +//! since any bias or correlation makes the output more predictable. +//! +//! There is a close relationship between CSPRNGs and cryptographic ciphers. +//! Any block cipher can be turned into a CSPRNG by encrypting a counter. Stream +//! ciphers are basically a CSPRNG and a combining operation, usually XOR. This +//! means that we can easily use any stream cipher as a CSPRNG. +//! +//! Rand currently provides two trustworthy CSPRNGs and two CSPRNG-like PRNGs: +//! +//! | name | full name | performance | initialization | memory | predictability | forward secrecy | +//! |------|-----------|--------------|--------------|----------|----------------|-------------------------| +//! | [`ChaChaRng`] | ChaCha20 | ★☆☆☆☆ | fast | 136 bytes | secure | no | +//! | [`Hc128Rng`] | HC-128 | ★★☆☆☆ | slow | 4176 bytes | secure | no | +//! | [`IsaacRng`] | ISAAC | ★★☆☆☆ | slow | 2072 bytes | unknown | unknown | +//! | [`Isaac64Rng`] | ISAAC-64 | ★★☆☆☆ | slow | 4136 bytes| unknown | unknown | +//! +//! It should be noted that the ISAAC generators are only included for +//! historical reasons, they have been with the Rust language since the very +//! beginning. They have good quality output and no attacks are known, but have +//! received little attention from cryptography experts. +//! +//! +//! # Performance +//! +//! First it has to be said most PRNGs are very fast, and will rarely be a +//! performance bottleneck. +//! +//! Performance of basic PRNGs is a bit of a subtle thing. It depends a lot on +//! the CPU architecture (32 vs. 64 bits), inlining, and also on the number of +//! available registers. This often causes the performance to be affected by +//! surrounding code due to inlining and other usage of registers. +//! +//! When choosing a PRNG for performance it is important to benchmark your own +//! application due to interactions between PRNGs and surrounding code and +//! dependence on the CPU architecture as well as the impact of the size of +//! data requested. Because of all this, we do not include performance numbers +//! here but merely a qualitative rating. +//! +//! CSPRNGs are a little different in that they typically generate a block of +//! output in a cache, and pull outputs from the cache. This allows them to have +//! good amortised performance, and reduces or completely removes the influence +//! of surrounding code on the CSPRNG performance. +//! +//! ### Worst-case performance +//! Because CSPRNGs usually produce a block of values into a cache, they have +//! poor worst case performance (in contrast to basic PRNGs, where the +//! performance is usually quite regular). +//! +//! ## State size +//! +//! Simple PRNGs often use very little memory, commonly only a few words, where +//! a *word* is usually either `u32` or `u64`. This is not true for all +//! non-cryptographic PRNGs however, for example the historically popular +//! Mersenne Twister MT19937 algorithm requires 2.5 kB of state. +//! +//! CSPRNGs typically require more memory; since the seed size is recommended +//! to be at least 192 bits and some more may be required for the algorithm, +//! 256 bits would be approximately the minimum secure size. In practice, +//! CSPRNGs tend to use quite a bit more, [`ChaChaRng`] is relatively small with +//! 136 bytes of state. +//! +//! ## Initialization time +//! +//! The time required to initialize new generators varies significantly. Many +//! simple PRNGs and even some cryptographic ones (including [`ChaChaRng`]) +//! only need to copy the seed value and some constants into their state, and +//! thus can be constructed very quickly. In contrast, CSPRNGs with large state +//! require an expensive key-expansion. +//! +//! # Quality +//! +//! Many basic PRNGs are not much more than a couple of bitwise and arithmetic +//! operations. Their simplicity gives good performance, but also means there +//! are small regularities hidden in the generated random number stream. +//! +//! How much do those hidden regularities matter? That is hard to say, and +//! depends on how the RNG gets used. If there happen to be correlations between +//! the random numbers and the algorithm they are used in, the results can be +//! wrong or misleading. +//! +//! A random number generator can be considered good if it gives the correct +//! results in as many applications as possible. The quality of PRNG +//! algorithms can be evaluated to some extend analytically, to determine the +//! cycle length and to rule out some correlations. Then there are empirical +//! test suites designed to test how well a PRNG performs on a wide range of +//! possible uses, the latest and most complete of which are [TestU01] and +//! [PractRand]. +//! +//! CSPRNGs tend to be more complex, and have an explicit requirement to be +//! unpredictable. This implies there must be no obvious correlations between +//! output values. +//! +//! ### Quality stars: +//! PRNGs with 3 stars or more should be good enough for any purpose. +//! 1 or 2 stars may be good enough for typical apps and games, but do not work +//! well with all algorithms. +//! +//! ## Period +//! +//! The *period* or *cycle length* of a PRNG is the number of values that can be +//! generated after which it starts repeating the same random number stream. +//! Many PRNGs have a fixed-size period, but for some only an expected average +//! cycle length can be given, where the exact length depends on the seed. +//! +//! On today's hardware, even a fast RNG with a cycle length of *only* +//! 264 can be used for centuries before cycling. Yet we recommend a +//! period of 2128 or more, which most modern PRNGs satisfy. +//! Alternatively a PRNG with shorter period but support for multiple streams +//! may be chosen. There are two reasons for this, as follows. +//! +//! If we see the entire period of an RNG as one long random number stream, +//! every independently seeded RNG returns a slice of that stream. When multiple +//! RNG are seeded randomly, there is an increasingly large chance to end up +//! with a partially overlapping slice of the stream. +//! +//! If the period of the RNG is 2128, and an application consumes +//! 248 values, it then takes about 232 random +//! initializations to have a chance of 1 in a million to repeat part of an +//! already used stream. This seems good enough for common usage of +//! non-cryptographic generators, hence the recommendation of at least +//! 2128. As an estimate, the chance of any overlap in a period of +//! size `p` with `n` independent seeds and `u` values used per seed is +//! approximately `1 - e^(-u * n^2 / (2 * p))`. +//! +//! Further, it is not recommended to use the full period of an RNG. Many +//! PRNGs have a property called *k-dimensional equidistribution*, meaning that +//! for values of some size (potentially larger than the output size), all +//! possible values are produced the same number of times over the generator's +//! period. This is not a property of true randomness. This is known as the +//! generalized birthday problem, see the [PCG paper] for a good explanation. +//! This results in a noticable bias on output after generating more values +//! than the square root of the period (after 264 values for a +//! period of 2128). +//! +//! +//! # Security +//! +//! ## Predictability +//! +//! From the context of any PRNG, one can ask the question *given some previous +//! output from the PRNG, is it possible to predict the next output value?* +//! This is an important property in any situation where there might be an +//! adversary. +//! +//! Regular PRNGs tend to be predictable, although with varying difficulty. In +//! some cases prediction is trivial, for example plain Xorshift outputs part of +//! its state without mutation, and prediction is as simple as seeding a new +//! Xorshift generator from four `u32` outputs. Other generators, like +//! [PCG](http://www.pcg-random.org/predictability.html) and truncated Xorshift* +//! are harder to predict, but not outside the realm of common mathematics and a +//! desktop PC. +//! +//! The basic security that CSPRNGs must provide is the infeasibility to predict +//! output. This requirement is formalized as the [next-bit test]; this is +//! roughly stated as: given the first *k* bits of a random sequence, the +//! sequence satisfies the next-bit test if there is no algorithm able to +//! predict the next bit using reasonable computing power. +//! +//! A further security that *some* CSPRNGs provide is forward secrecy: +//! in the event that the CSPRNGs state is revealed at some point, it must be +//! infeasible to reconstruct previous states or output. Note that many CSPRNGs +//! *do not* have forward secrecy in their usual formulations. +//! +//! As an outsider it is hard to get a good idea about the security of an +//! algorithm. People in the field of cryptography spend a lot of effort +//! analyzing existing designs, and what was once considered good may now turn +//! out to be weaker. Generally it is best to use algorithms well-analyzed by +//! experts, such as those recommended by NIST or ECRYPT. +//! +//! ## State and seeding +//! +//! It is worth noting that a CSPRNG's security relies absolutely on being +//! seeded with a secure random key. Should the key be known or guessable, all +//! output of the CSPRNG is easy to guess. This implies that the seed should +//! come from a trusted source; usually either the OS or another CSPRNG. Our +//! seeding helper trait, [`FromEntropy`], and the source it uses +//! ([`EntropyRng`]), should be secure. Additionally, [`ThreadRng`] is a CSPRNG, +//! thus it is acceptable to seed from this (although for security applications +//! fresh/external entropy should be preferred). +//! +//! Further, it should be obvious that the internal state of a CSPRNG must be +//! kept secret. With that in mind, our implementations do not provide direct +//! access to most of their internal state, and `Debug` implementations do not +//! print any internal state. This does not fully protect CSPRNG state; code +//! within the same process may read this memory (and we allow cloning and +//! serialisation of CSPRNGs for convenience). Further, a running process may be +//! forked by the operating system, which may leave both processes with a copy +//! of the same generator. +//! +//! ## Not a crypto library +//! +//! It should be emphasised that this is not a cryptography library; although +//! Rand does take some measures to provide secure random numbers, it does not +//! necessarily take all recommended measures. Further, cryptographic processes +//! such as encryption and authentication are complex and must be implemented +//! very carefully to avoid flaws and resist known attacks. It is therefore +//! recommended to use specialized libraries where possible, for example +//! [openssl], [ring] and the [RustCrypto libraries]. +//! +//! +//! # Extra features +//! +//! Some PRNGs may provide extra features, like: +//! +//! - Support for multiple streams, which can help with parallel tasks. +//! - The ability to jump or seek around in the random number stream; +//! with large periood this can be used as an alternative to streams. +//! +//! +//! # Further reading +//! +//! There is quite a lot that can be said about PRNGs. The [PCG paper] is a +//! very approachable explaining more concepts. +//! +//! A good paper about RNG quality is +//! ["Good random number generators are (not so) easy to find"]( +//! http://random.mat.sbg.ac.at/results/peter/A19final.pdf) by P. Hellekalek. +//! +//! +//! [`rngs` module]: ../rngs/index.html +//! [basic PRNGs]: #basic-pseudo-random-number-generators-prngs +//! [CSPRNGs]: #cryptographically-secure-pseudo-random-number-generators-csprngs +//! [`XorShiftRng`]: struct.XorShiftRng.html +//! [`ChaChaRng`]: chacha/struct.ChaChaRng.html +//! [`Hc128Rng`]: hc128/struct.Hc128Rng.html +//! [`IsaacRng`]: isaac/struct.IsaacRng.html +//! [`Isaac64Rng`]: isaac64/struct.Isaac64Rng.html +//! [`ThreadRng`]: ../rngs/struct.ThreadRng.html +//! [`FromEntropy`]: ../trait.FromEntropy.html +//! [`EntropyRng`]: ../rngs/struct.EntropyRng.html +//! [TestU01]: http://simul.iro.umontreal.ca/testu01/tu01.html +//! [PractRand]: http://pracrand.sourceforge.net/ +//! [PCG paper]: http://www.pcg-random.org/pdf/hmc-cs-2014-0905.pdf +//! [openssl]: https://crates.io/crates/openssl +//! [ring]: https://crates.io/crates/ring +//! [RustCrypto libraries]: https://github.com/RustCrypto +//! [next-bit test]: https://en.wikipedia.org/wiki/Next-bit_test + + +pub mod chacha; +pub mod hc128; +pub mod isaac; +pub mod isaac64; +mod xorshift; + +mod isaac_array; + +pub use self::chacha::ChaChaRng; +pub use self::hc128::Hc128Rng; +pub use self::isaac::IsaacRng; +pub use self::isaac64::Isaac64Rng; +pub use self::xorshift::XorShiftRng; diff --git a/third_party/cargo/vendor/rand-0.5.6/src/prng/xorshift.rs b/third_party/cargo/vendor/rand-0.5.6/src/prng/xorshift.rs new file mode 100644 index 0000000..90871f8 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/prng/xorshift.rs @@ -0,0 +1,225 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Xorshift generators + +use core::num::Wrapping as w; +use core::{fmt, slice}; +use rand_core::{RngCore, SeedableRng, Error, impls, le}; + +/// An Xorshift random number generator. +/// +/// The Xorshift[^1] algorithm is not suitable for cryptographic purposes +/// but is very fast. If you do not know for sure that it fits your +/// requirements, use a more secure one such as `IsaacRng` or `OsRng`. +/// +/// [^1]: Marsaglia, George (July 2003). +/// ["Xorshift RNGs"](https://www.jstatsoft.org/v08/i14/paper). +/// *Journal of Statistical Software*. Vol. 8 (Issue 14). +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))] +pub struct XorShiftRng { + x: w, + y: w, + z: w, + w: w, +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for XorShiftRng { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "XorShiftRng {{}}") + } +} + +impl XorShiftRng { + /// Creates a new XorShiftRng instance which is not seeded. + /// + /// The initial values of this RNG are constants, so all generators created + /// by this function will yield the same stream of random numbers. It is + /// highly recommended that this is created through `SeedableRng` instead of + /// this function + #[deprecated(since="0.5.0", note="use the FromEntropy or SeedableRng trait")] + pub fn new_unseeded() -> XorShiftRng { + XorShiftRng { + x: w(0x193a6754), + y: w(0xa8a7d469), + z: w(0x97830e05), + w: w(0x113ba7bb), + } + } +} + +impl RngCore for XorShiftRng { + #[inline] + fn next_u32(&mut self) -> u32 { + let x = self.x; + let t = x ^ (x << 11); + self.x = self.y; + self.y = self.z; + self.z = self.w; + let w_ = self.w; + self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8)); + self.w.0 + } + + #[inline] + fn next_u64(&mut self) -> u64 { + impls::next_u64_via_u32(self) + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + impls::fill_bytes_via_next(self, dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} + +impl SeedableRng for XorShiftRng { + type Seed = [u8; 16]; + + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_u32 = [0u32; 4]; + le::read_u32_into(&seed, &mut seed_u32); + + // Xorshift cannot be seeded with 0 and we cannot return an Error, but + // also do not wish to panic (because a random seed can legitimately be + // 0); our only option is therefore to use a preset value. + if seed_u32.iter().all(|&x| x == 0) { + seed_u32 = [0xBAD_5EED, 0xBAD_5EED, 0xBAD_5EED, 0xBAD_5EED]; + } + + XorShiftRng { + x: w(seed_u32[0]), + y: w(seed_u32[1]), + z: w(seed_u32[2]), + w: w(seed_u32[3]), + } + } + + fn from_rng(mut rng: R) -> Result { + let mut seed_u32 = [0u32; 4]; + loop { + unsafe { + let ptr = seed_u32.as_mut_ptr() as *mut u8; + + let slice = slice::from_raw_parts_mut(ptr, 4 * 4); + rng.try_fill_bytes(slice)?; + } + if !seed_u32.iter().all(|&x| x == 0) { break; } + } + + Ok(XorShiftRng { + x: w(seed_u32[0]), + y: w(seed_u32[1]), + z: w(seed_u32[2]), + w: w(seed_u32[3]), + }) + } +} + +#[cfg(test)] +mod tests { + use {RngCore, SeedableRng}; + use super::XorShiftRng; + + #[test] + fn test_xorshift_construction() { + // Test that various construction techniques produce a working RNG. + let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16]; + let mut rng1 = XorShiftRng::from_seed(seed); + assert_eq!(rng1.next_u64(), 4325440999699518727); + + let _rng2 = XorShiftRng::from_rng(rng1).unwrap(); + // Note: we cannot test the state of _rng2 because from_rng does not + // fix Endianness. This is allowed in the trait specification. + } + + #[test] + fn test_xorshift_true_values() { + let seed = [16,15,14,13, 12,11,10,9, 8,7,6,5, 4,3,2,1]; + let mut rng = XorShiftRng::from_seed(seed); + + let mut results = [0u32; 9]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected: [u32; 9] = [ + 2081028795, 620940381, 269070770, 16943764, 854422573, 29242889, + 1550291885, 1227154591, 271695242]; + assert_eq!(results, expected); + + let mut results = [0u64; 9]; + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected: [u64; 9] = [ + 9247529084182843387, 8321512596129439293, 14104136531997710878, + 6848554330849612046, 343577296533772213, 17828467390962600268, + 9847333257685787782, 7717352744383350108, 1133407547287910111]; + assert_eq!(results, expected); + + let mut results = [0u8; 32]; + rng.fill_bytes(&mut results); + let expected = [102, 57, 212, 16, 233, 130, 49, 183, + 158, 187, 44, 203, 63, 149, 45, 17, + 117, 129, 131, 160, 70, 121, 158, 155, + 224, 209, 192, 53, 10, 62, 57, 72]; + assert_eq!(results, expected); + } + + #[test] + fn test_xorshift_zero_seed() { + // Xorshift does not work with an all zero seed. + // Assert it does not panic. + let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng = XorShiftRng::from_seed(seed); + let a = rng.next_u64(); + let b = rng.next_u64(); + assert!(a != 0); + assert!(b != a); + } + + #[test] + fn test_xorshift_clone() { + let seed = [1,2,3,4, 5,5,7,8, 8,7,6,5, 4,3,2,1]; + let mut rng1 = XorShiftRng::from_seed(seed); + let mut rng2 = rng1.clone(); + for _ in 0..16 { + assert_eq!(rng1.next_u64(), rng2.next_u64()); + } + } + + #[cfg(all(feature="serde1", feature="std"))] + #[test] + fn test_xorshift_serde() { + use bincode; + use std::io::{BufWriter, BufReader}; + + let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16]; + let mut rng = XorShiftRng::from_seed(seed); + + let buf: Vec = Vec::new(); + let mut buf = BufWriter::new(buf); + bincode::serialize_into(&mut buf, &rng).expect("Could not serialize"); + + let buf = buf.into_inner().unwrap(); + let mut read = BufReader::new(&buf[..]); + let mut deserialized: XorShiftRng = bincode::deserialize_from(&mut read).expect("Could not deserialize"); + + assert_eq!(rng.x, deserialized.x); + assert_eq!(rng.y, deserialized.y); + assert_eq!(rng.z, deserialized.z); + assert_eq!(rng.w, deserialized.w); + + for _ in 0..16 { + assert_eq!(rng.next_u64(), deserialized.next_u64()); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/adapter/mod.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/adapter/mod.rs new file mode 100644 index 0000000..9a3851a --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/adapter/mod.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Wrappers / adapters forming RNGs + +#[cfg(feature="std")] #[doc(hidden)] pub mod read; +mod reseeding; + +#[cfg(feature="std")] pub use self::read::ReadRng; +pub use self::reseeding::ReseedingRng; diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/adapter/read.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/adapter/read.rs new file mode 100644 index 0000000..de75f97 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/adapter/read.rs @@ -0,0 +1,137 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A wrapper around any Read to treat it as an RNG. + +use std::io::Read; + +use rand_core::{RngCore, Error, ErrorKind, impls}; + + +/// An RNG that reads random bytes straight from any type supporting +/// `std::io::Read`, for example files. +/// +/// This will work best with an infinite reader, but that is not required. +/// +/// This can be used with `/dev/urandom` on Unix but it is recommended to use +/// [`OsRng`] instead. +/// +/// # Panics +/// +/// `ReadRng` uses `std::io::read_exact`, which retries on interrupts. All other +/// errors from the underlying reader, including when it does not have enough +/// data, will only be reported through [`try_fill_bytes`]. The other +/// [`RngCore`] methods will panic in case of an error. +/// +/// # Example +/// +/// ``` +/// use rand::{read, Rng}; +/// +/// let data = vec![1, 2, 3, 4, 5, 6, 7, 8]; +/// let mut rng = read::ReadRng::new(&data[..]); +/// println!("{:x}", rng.gen::()); +/// ``` +/// +/// [`OsRng`]: ../struct.OsRng.html +/// [`RngCore`]: ../../trait.RngCore.html +/// [`try_fill_bytes`]: ../../trait.RngCore.html#method.tymethod.try_fill_bytes +#[derive(Debug)] +pub struct ReadRng { + reader: R +} + +impl ReadRng { + /// Create a new `ReadRng` from a `Read`. + pub fn new(r: R) -> ReadRng { + ReadRng { + reader: r + } + } +} + +impl RngCore for ReadRng { + fn next_u32(&mut self) -> u32 { + impls::next_u32_via_fill(self) + } + + fn next_u64(&mut self) -> u64 { + impls::next_u64_via_fill(self) + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.try_fill_bytes(dest).unwrap_or_else(|err| + panic!("reading random bytes from Read implementation failed; error: {}", err)); + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + if dest.len() == 0 { return Ok(()); } + // Use `std::io::read_exact`, which retries on `ErrorKind::Interrupted`. + self.reader.read_exact(dest).map_err(|err| { + match err.kind() { + ::std::io::ErrorKind::UnexpectedEof => Error::with_cause( + ErrorKind::Unavailable, + "not enough bytes available, reached end of source", err), + _ => Error::with_cause(ErrorKind::Unavailable, + "error reading from Read source", err) + } + }) + } +} + +#[cfg(test)] +mod test { + use super::ReadRng; + use {RngCore, ErrorKind}; + + #[test] + fn test_reader_rng_u64() { + // transmute from the target to avoid endianness concerns. + let v = vec![0u8, 0, 0, 0, 0, 0, 0, 1, + 0 , 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3]; + let mut rng = ReadRng::new(&v[..]); + + assert_eq!(rng.next_u64(), 1_u64.to_be()); + assert_eq!(rng.next_u64(), 2_u64.to_be()); + assert_eq!(rng.next_u64(), 3_u64.to_be()); + } + + #[test] + fn test_reader_rng_u32() { + let v = vec![0u8, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3]; + let mut rng = ReadRng::new(&v[..]); + + assert_eq!(rng.next_u32(), 1_u32.to_be()); + assert_eq!(rng.next_u32(), 2_u32.to_be()); + assert_eq!(rng.next_u32(), 3_u32.to_be()); + } + + #[test] + fn test_reader_rng_fill_bytes() { + let v = [1u8, 2, 3, 4, 5, 6, 7, 8]; + let mut w = [0u8; 8]; + + let mut rng = ReadRng::new(&v[..]); + rng.fill_bytes(&mut w); + + assert!(v == w); + } + + #[test] + fn test_reader_rng_insufficient_bytes() { + let v = [1u8, 2, 3, 4, 5, 6, 7, 8]; + let mut w = [0u8; 9]; + + let mut rng = ReadRng::new(&v[..]); + + assert!(rng.try_fill_bytes(&mut w).err().unwrap().kind == ErrorKind::Unavailable); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/adapter/reseeding.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/adapter/reseeding.rs new file mode 100644 index 0000000..7ec8de5 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/adapter/reseeding.rs @@ -0,0 +1,260 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A wrapper around another PRNG that reseeds it after it +//! generates a certain number of random bytes. + +use core::mem::size_of; + +use rand_core::{RngCore, CryptoRng, SeedableRng, Error, ErrorKind}; +use rand_core::block::{BlockRngCore, BlockRng}; + +/// A wrapper around any PRNG which reseeds the underlying PRNG after it has +/// generated a certain number of random bytes. +/// +/// When the RNG gets cloned, the clone is reseeded on first use. +/// +/// Reseeding is never strictly *necessary*. Cryptographic PRNGs don't have a +/// limited number of bytes they can output, or at least not a limit reachable +/// in any practical way. There is no such thing as 'running out of entropy'. +/// +/// Some small non-cryptographic PRNGs can have very small periods, for +/// example less than 264. Would reseeding help to ensure that you do +/// not wrap around at the end of the period? A period of 264 still +/// takes several centuries of CPU-years on current hardware. Reseeding will +/// actually make things worse, because the reseeded PRNG will just continue +/// somewhere else *in the same period*, with a high chance of overlapping with +/// previously used parts of it. +/// +/// # When should you use `ReseedingRng`? +/// +/// - Reseeding can be seen as some form of 'security in depth'. Even if in the +/// future a cryptographic weakness is found in the CSPRNG being used, +/// occasionally reseeding should make exploiting it much more difficult or +/// even impossible. +/// - It can be used as a poor man's cryptography (not recommended, just use a +/// good CSPRNG). Previous implementations of `thread_rng` for example used +/// `ReseedingRng` with the ISAAC RNG. That algorithm, although apparently +/// strong and with no known attack, does not come with any proof of security +/// and does not meet the current standards for a cryptographically secure +/// PRNG. By reseeding it frequently (every 32 kiB) it seems safe to assume +/// there is no attack that can operate on the tiny window between reseeds. +/// +/// # Error handling +/// +/// Although extremely unlikely, reseeding the wrapped PRNG can fail. +/// `ReseedingRng` will never panic but try to handle the error intelligently +/// through some combination of retrying and delaying reseeding until later. +/// If handling the source error fails `ReseedingRng` will continue generating +/// data from the wrapped PRNG without reseeding. +#[derive(Debug)] +pub struct ReseedingRng(BlockRng>) +where R: BlockRngCore + SeedableRng, + Rsdr: RngCore; + +impl ReseedingRng +where R: BlockRngCore + SeedableRng, + Rsdr: RngCore +{ + /// Create a new `ReseedingRng` with the given parameters. + /// + /// # Arguments + /// + /// * `rng`: the random number generator to use. + /// * `threshold`: the number of generated bytes after which to reseed the RNG. + /// * `reseeder`: the RNG to use for reseeding. + pub fn new(rng: R, threshold: u64, reseeder: Rsdr) -> Self { + ReseedingRng(BlockRng::new(ReseedingCore::new(rng, threshold, reseeder))) + } + + /// Reseed the internal PRNG. + pub fn reseed(&mut self) -> Result<(), Error> { + self.0.core.reseed() + } +} + +// TODO: this should be implemented for any type where the inner type +// implements RngCore, but we can't specify that because ReseedingCore is private +impl RngCore for ReseedingRng +where R: BlockRngCore + SeedableRng, + ::Results: AsRef<[u32]> + AsMut<[u32]> +{ + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl Clone for ReseedingRng +where R: BlockRngCore + SeedableRng + Clone, + Rsdr: RngCore + Clone +{ + fn clone(&self) -> ReseedingRng { + // Recreating `BlockRng` seems easier than cloning it and resetting + // the index. + ReseedingRng(BlockRng::new(self.0.core.clone())) + } +} + +impl CryptoRng for ReseedingRng +where R: BlockRngCore + SeedableRng + CryptoRng, + Rsdr: RngCore + CryptoRng {} + +#[derive(Debug)] +struct ReseedingCore { + inner: R, + reseeder: Rsdr, + threshold: i64, + bytes_until_reseed: i64, +} + +impl BlockRngCore for ReseedingCore +where R: BlockRngCore + SeedableRng, + Rsdr: RngCore +{ + type Item = ::Item; + type Results = ::Results; + + fn generate(&mut self, results: &mut Self::Results) { + if self.bytes_until_reseed <= 0 { + // We get better performance by not calling only `auto_reseed` here + // and continuing with the rest of the function, but by directly + // returning from a non-inlined function. + return self.reseed_and_generate(results); + } + let num_bytes = results.as_ref().len() * size_of::(); + self.bytes_until_reseed -= num_bytes as i64; + self.inner.generate(results); + } +} + +impl ReseedingCore +where R: BlockRngCore + SeedableRng, + Rsdr: RngCore +{ + /// Create a new `ReseedingCore` with the given parameters. + /// + /// # Arguments + /// + /// * `rng`: the random number generator to use. + /// * `threshold`: the number of generated bytes after which to reseed the RNG. + /// * `reseeder`: the RNG to use for reseeding. + pub fn new(rng: R, threshold: u64, reseeder: Rsdr) -> Self { + assert!(threshold <= ::core::i64::MAX as u64); + ReseedingCore { + inner: rng, + reseeder, + threshold: threshold as i64, + bytes_until_reseed: threshold as i64, + } + } + + /// Reseed the internal PRNG. + fn reseed(&mut self) -> Result<(), Error> { + R::from_rng(&mut self.reseeder).map(|result| { + self.bytes_until_reseed = self.threshold; + self.inner = result + }) + } + + #[inline(never)] + fn reseed_and_generate(&mut self, + results: &mut ::Results) + { + trace!("Reseeding RNG after {} generated bytes", + self.threshold - self.bytes_until_reseed); + let threshold = if let Err(e) = self.reseed() { + let delay = match e.kind { + ErrorKind::Transient => 0, + kind @ _ if kind.should_retry() => self.threshold >> 8, + _ => self.threshold, + }; + warn!("Reseeding RNG delayed reseeding by {} bytes due to \ + error from source: {}", delay, e); + delay + } else { + self.threshold + }; + + let num_bytes = results.as_ref().len() * size_of::<::Item>(); + self.bytes_until_reseed = threshold - num_bytes as i64; + self.inner.generate(results); + } +} + +impl Clone for ReseedingCore +where R: BlockRngCore + SeedableRng + Clone, + Rsdr: RngCore + Clone +{ + fn clone(&self) -> ReseedingCore { + ReseedingCore { + inner: self.inner.clone(), + reseeder: self.reseeder.clone(), + threshold: self.threshold, + bytes_until_reseed: 0, // reseed clone on first use + } + } +} + +impl CryptoRng for ReseedingCore +where R: BlockRngCore + SeedableRng + CryptoRng, + Rsdr: RngCore + CryptoRng {} + +#[cfg(test)] +mod test { + use {Rng, SeedableRng}; + use prng::chacha::ChaChaCore; + use rngs::mock::StepRng; + use super::ReseedingRng; + + #[test] + fn test_reseeding() { + let mut zero = StepRng::new(0, 0); + let rng = ChaChaCore::from_rng(&mut zero).unwrap(); + let mut reseeding = ReseedingRng::new(rng, 32*4, zero); + + // Currently we only support for arrays up to length 32. + // TODO: cannot generate seq via Rng::gen because it uses different alg + let mut buf = [0u32; 32]; // Needs to be a multiple of the RNGs result + // size to test exactly. + reseeding.fill(&mut buf); + let seq = buf; + for _ in 0..10 { + reseeding.fill(&mut buf); + assert_eq!(buf, seq); + } + } + + #[test] + fn test_clone_reseeding() { + let mut zero = StepRng::new(0, 0); + let rng = ChaChaCore::from_rng(&mut zero).unwrap(); + let mut rng1 = ReseedingRng::new(rng, 32*4, zero); + + let first: u32 = rng1.gen(); + for _ in 0..10 { let _ = rng1.gen::(); } + + let mut rng2 = rng1.clone(); + assert_eq!(first, rng2.gen::()); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/entropy.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/entropy.rs new file mode 100644 index 0000000..b8f4be7 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/entropy.rs @@ -0,0 +1,296 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Entropy generator, or wrapper around external generators + +use rand_core::{RngCore, CryptoRng, Error, ErrorKind, impls}; +#[allow(unused)] +use rngs; + +/// An interface returning random data from external source(s), provided +/// specifically for securely seeding algorithmic generators (PRNGs). +/// +/// Where possible, `EntropyRng` retrieves random data from the operating +/// system's interface for random numbers ([`OsRng`]); if that fails it will +/// fall back to the [`JitterRng`] entropy collector. In the latter case it will +/// still try to use [`OsRng`] on the next usage. +/// +/// If no secure source of entropy is available `EntropyRng` will panic on use; +/// i.e. it should never output predictable data. +/// +/// This is either a little slow ([`OsRng`] requires a system call) or extremely +/// slow ([`JitterRng`] must use significant CPU time to generate sufficient +/// jitter); for better performance it is common to seed a local PRNG from +/// external entropy then primarily use the local PRNG ([`thread_rng`] is +/// provided as a convenient, local, automatically-seeded CSPRNG). +/// +/// # Panics +/// +/// On most systems, like Windows, Linux, macOS and *BSD on common hardware, it +/// is highly unlikely for both [`OsRng`] and [`JitterRng`] to fail. But on +/// combinations like webassembly without Emscripten or stdweb both sources are +/// unavailable. If both sources fail, only [`try_fill_bytes`] is able to +/// report the error, and only the one from `OsRng`. The other [`RngCore`] +/// methods will panic in case of an error. +/// +/// [`OsRng`]: struct.OsRng.html +/// [`JitterRng`]: jitter/struct.JitterRng.html +/// [`thread_rng`]: ../fn.thread_rng.html +/// [`RngCore`]: ../trait.RngCore.html +/// [`try_fill_bytes`]: ../trait.RngCore.html#method.tymethod.try_fill_bytes +#[derive(Debug)] +pub struct EntropyRng { + source: Source, +} + +#[derive(Debug)] +enum Source { + Os(Os), + Custom(Custom), + Jitter(Jitter), + None, +} + +impl EntropyRng { + /// Create a new `EntropyRng`. + /// + /// This method will do no system calls or other initialization routines, + /// those are done on first use. This is done to make `new` infallible, + /// and `try_fill_bytes` the only place to report errors. + pub fn new() -> Self { + EntropyRng { source: Source::None } + } +} + +impl Default for EntropyRng { + fn default() -> Self { + EntropyRng::new() + } +} + +impl RngCore for EntropyRng { + fn next_u32(&mut self) -> u32 { + impls::next_u32_via_fill(self) + } + + fn next_u64(&mut self) -> u64 { + impls::next_u64_via_fill(self) + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.try_fill_bytes(dest).unwrap_or_else(|err| + panic!("all entropy sources failed; first error: {}", err)) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let mut reported_error = None; + + if let Source::Os(ref mut os_rng) = self.source { + match os_rng.fill(dest) { + Ok(()) => return Ok(()), + Err(err) => { + warn!("EntropyRng: OsRng failed \ + [trying other entropy sources]: {}", err); + reported_error = Some(err); + }, + } + } else if Os::is_supported() { + match Os::new_and_fill(dest) { + Ok(os_rng) => { + debug!("EntropyRng: using OsRng"); + self.source = Source::Os(os_rng); + return Ok(()); + }, + Err(err) => { reported_error = reported_error.or(Some(err)) }, + } + } + + if let Source::Custom(ref mut rng) = self.source { + match rng.fill(dest) { + Ok(()) => return Ok(()), + Err(err) => { + warn!("EntropyRng: custom entropy source failed \ + [trying other entropy sources]: {}", err); + reported_error = Some(err); + }, + } + } else if Custom::is_supported() { + match Custom::new_and_fill(dest) { + Ok(custom) => { + debug!("EntropyRng: using custom entropy source"); + self.source = Source::Custom(custom); + return Ok(()); + }, + Err(err) => { reported_error = reported_error.or(Some(err)) }, + } + } + + if let Source::Jitter(ref mut jitter_rng) = self.source { + match jitter_rng.fill(dest) { + Ok(()) => return Ok(()), + Err(err) => { + warn!("EntropyRng: JitterRng failed: {}", err); + reported_error = Some(err); + }, + } + } else if Jitter::is_supported() { + match Jitter::new_and_fill(dest) { + Ok(jitter_rng) => { + debug!("EntropyRng: using JitterRng"); + self.source = Source::Jitter(jitter_rng); + return Ok(()); + }, + Err(err) => { reported_error = reported_error.or(Some(err)) }, + } + } + + if let Some(err) = reported_error { + Err(Error::with_cause(ErrorKind::Unavailable, + "All entropy sources failed", + err)) + } else { + Err(Error::new(ErrorKind::Unavailable, + "No entropy sources available")) + } + } +} + +impl CryptoRng for EntropyRng {} + + + +trait EntropySource { + fn new_and_fill(dest: &mut [u8]) -> Result + where Self: Sized; + + fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error>; + + fn is_supported() -> bool { true } +} + +#[allow(unused)] +#[derive(Clone, Debug)] +struct NoSource; + +#[allow(unused)] +impl EntropySource for NoSource { + fn new_and_fill(dest: &mut [u8]) -> Result { + Err(Error::new(ErrorKind::Unavailable, "Source not supported")) + } + + fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error> { + unreachable!() + } + + fn is_supported() -> bool { false } +} + + +#[cfg(all(feature="std", + any(target_os = "linux", target_os = "android", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "haiku", + target_os = "emscripten", + target_os = "solaris", + target_os = "cloudabi", + target_os = "macos", target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", target_os = "bitrig", + target_os = "redox", + target_os = "fuchsia", + windows, + all(target_arch = "wasm32", feature = "stdweb") +)))] +#[derive(Clone, Debug)] +pub struct Os(rngs::OsRng); + +#[cfg(all(feature="std", + any(target_os = "linux", target_os = "android", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "haiku", + target_os = "emscripten", + target_os = "solaris", + target_os = "cloudabi", + target_os = "macos", target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", target_os = "bitrig", + target_os = "redox", + target_os = "fuchsia", + windows, + all(target_arch = "wasm32", feature = "stdweb") +)))] +impl EntropySource for Os { + fn new_and_fill(dest: &mut [u8]) -> Result { + let mut rng = rngs::OsRng::new()?; + rng.try_fill_bytes(dest)?; + Ok(Os(rng)) + } + + fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +#[cfg(not(all(feature="std", + any(target_os = "linux", target_os = "android", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "haiku", + target_os = "emscripten", + target_os = "solaris", + target_os = "cloudabi", + target_os = "macos", target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", target_os = "bitrig", + target_os = "redox", + target_os = "fuchsia", + windows, + all(target_arch = "wasm32", feature = "stdweb") +))))] +type Os = NoSource; + + +type Custom = NoSource; + + +#[cfg(not(target_arch = "wasm32"))] +#[derive(Clone, Debug)] +pub struct Jitter(rngs::JitterRng); + +#[cfg(not(target_arch = "wasm32"))] +impl EntropySource for Jitter { + fn new_and_fill(dest: &mut [u8]) -> Result { + let mut rng = rngs::JitterRng::new()?; + rng.try_fill_bytes(dest)?; + Ok(Jitter(rng)) + } + + fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +#[cfg(target_arch = "wasm32")] +type Jitter = NoSource; + + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_entropy() { + let mut rng = EntropyRng::new(); + let n = (rng.next_u32() ^ rng.next_u32()).count_ones(); + assert!(n >= 2); // p(failure) approx 1e-7 + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/jitter.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/jitter.rs new file mode 100644 index 0000000..311682c --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/jitter.rs @@ -0,0 +1,887 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// Based on jitterentropy-library, http://www.chronox.de/jent.html. +// Copyright Stephan Mueller , 2014 - 2017. +// +// With permission from Stephan Mueller to relicense the Rust translation under +// the MIT license. + +//! Non-physical true random number generator based on timing jitter. + +// Note: the C implementation of `Jitterentropy` relies on being compiled +// without optimizations. This implementation goes through lengths to make the +// compiler not optimize out code which does influence timing jitter, but is +// technically dead code. + +use rand_core::{RngCore, CryptoRng, Error, ErrorKind, impls}; + +use core::{fmt, mem, ptr}; +#[cfg(all(feature="std", not(target_arch = "wasm32")))] +use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; + +const MEMORY_BLOCKS: usize = 64; +const MEMORY_BLOCKSIZE: usize = 32; +const MEMORY_SIZE: usize = MEMORY_BLOCKS * MEMORY_BLOCKSIZE; + +/// A true random number generator based on jitter in the CPU execution time, +/// and jitter in memory access time. +/// +/// This is a true random number generator, as opposed to pseudo-random +/// generators. Random numbers generated by `JitterRng` can be seen as fresh +/// entropy. A consequence is that is orders of magnitude slower than [`OsRng`] +/// and PRNGs (about 103..106 slower). +/// +/// There are very few situations where using this RNG is appropriate. Only very +/// few applications require true entropy. A normal PRNG can be statistically +/// indistinguishable, and a cryptographic PRNG should also be as impossible to +/// predict. +/// +/// Use of `JitterRng` is recommended for initializing cryptographic PRNGs when +/// [`OsRng`] is not available. +/// +/// `JitterRng` can be used without the standard library, but not conveniently, +/// you must provide a high-precision timer and carefully have to follow the +/// instructions of [`new_with_timer`]. +/// +/// This implementation is based on +/// [Jitterentropy](http://www.chronox.de/jent.html) version 2.1.0. +/// +/// Note: There is no accurate timer available on Wasm platforms, to help +/// prevent fingerprinting or timing side-channel attacks. Therefore +/// [`JitterRng::new()`] is not available on Wasm. +/// +/// # Quality testing +/// +/// [`JitterRng::new()`] has build-in, but limited, quality testing, however +/// before using `JitterRng` on untested hardware, or after changes that could +/// effect how the code is optimized (such as a new LLVM version), it is +/// recommend to run the much more stringent +/// [NIST SP 800-90B Entropy Estimation Suite]( +/// https://github.com/usnistgov/SP800-90B_EntropyAssessment). +/// +/// Use the following code using [`timer_stats`] to collect the data: +/// +/// ```no_run +/// use rand::jitter::JitterRng; +/// # +/// # use std::error::Error; +/// # use std::fs::File; +/// # use std::io::Write; +/// # +/// # fn try_main() -> Result<(), Box> { +/// let mut rng = JitterRng::new()?; +/// +/// // 1_000_000 results are required for the +/// // NIST SP 800-90B Entropy Estimation Suite +/// const ROUNDS: usize = 1_000_000; +/// let mut deltas_variable: Vec = Vec::with_capacity(ROUNDS); +/// let mut deltas_minimal: Vec = Vec::with_capacity(ROUNDS); +/// +/// for _ in 0..ROUNDS { +/// deltas_variable.push(rng.timer_stats(true) as u8); +/// deltas_minimal.push(rng.timer_stats(false) as u8); +/// } +/// +/// // Write out after the statistics collection loop, to not disturb the +/// // test results. +/// File::create("jitter_rng_var.bin")?.write(&deltas_variable)?; +/// File::create("jitter_rng_min.bin")?.write(&deltas_minimal)?; +/// # +/// # Ok(()) +/// # } +/// # +/// # fn main() { +/// # try_main().unwrap(); +/// # } +/// ``` +/// +/// This will produce two files: `jitter_rng_var.bin` and `jitter_rng_min.bin`. +/// Run the Entropy Estimation Suite in three configurations, as outlined below. +/// Every run has two steps. One step to produce an estimation, another to +/// validate the estimation. +/// +/// 1. Estimate the expected amount of entropy that is at least available with +/// each round of the entropy collector. This number should be greater than +/// the amount estimated with `64 / test_timer()`. +/// ```sh +/// python noniid_main.py -v jitter_rng_var.bin 8 +/// restart.py -v jitter_rng_var.bin 8 +/// ``` +/// 2. Estimate the expected amount of entropy that is available in the last 4 +/// bits of the timer delta after running noice sources. Note that a value of +/// `3.70` is the minimum estimated entropy for true randomness. +/// ```sh +/// python noniid_main.py -v -u 4 jitter_rng_var.bin 4 +/// restart.py -v -u 4 jitter_rng_var.bin 4 +/// ``` +/// 3. Estimate the expected amount of entropy that is available to the entropy +/// collector if both noice sources only run their minimal number of times. +/// This measures the absolute worst-case, and gives a lower bound for the +/// available entropy. +/// ```sh +/// python noniid_main.py -v -u 4 jitter_rng_min.bin 4 +/// restart.py -v -u 4 jitter_rng_min.bin 4 +/// ``` +/// +/// [`OsRng`]: struct.OsRng.html +/// [`JitterRng::new()`]: struct.JitterRng.html#method.new +/// [`new_with_timer`]: struct.JitterRng.html#method.new_with_timer +/// [`timer_stats`]: struct.JitterRng.html#method.timer_stats +pub struct JitterRng { + data: u64, // Actual random number + // Number of rounds to run the entropy collector per 64 bits + rounds: u8, + // Timer used by `measure_jitter` + timer: fn() -> u64, + // Memory for the Memory Access noise source + mem_prev_index: u16, + // Make `next_u32` not waste 32 bits + data_half_used: bool, +} + +// Note: `JitterRng` maintains a small 64-bit entropy pool. With every +// `generate` 64 new bits should be integrated in the pool. If a round of +// `generate` were to collect less than the expected 64 bit, then the returned +// value, and the new state of the entropy pool, would be in some way related to +// the initial state. It is therefore better if the initial state of the entropy +// pool is different on each call to `generate`. This has a few implications: +// - `generate` should be called once before using `JitterRng` to produce the +// first usable value (this is done by default in `new`); +// - We do not zero the entropy pool after generating a result. The reference +// implementation also does not support zeroing, but recommends generating a +// new value without using it if you want to protect a previously generated +// 'secret' value from someone inspecting the memory; +// - Implementing `Clone` seems acceptable, as it would not cause the systematic +// bias a constant might cause. Only instead of one value that could be +// potentially related to the same initial state, there are now two. + +// Entropy collector state. +// These values are not necessary to preserve across runs. +struct EcState { + // Previous time stamp to determine the timer delta + prev_time: u64, + // Deltas used for the stuck test + last_delta: i32, + last_delta2: i32, + // Memory for the Memory Access noise source + mem: [u8; MEMORY_SIZE], +} + +impl EcState { + // Stuck test by checking the: + // - 1st derivation of the jitter measurement (time delta) + // - 2nd derivation of the jitter measurement (delta of time deltas) + // - 3rd derivation of the jitter measurement (delta of delta of time + // deltas) + // + // All values must always be non-zero. + // This test is a heuristic to see whether the last measurement holds + // entropy. + fn stuck(&mut self, current_delta: i32) -> bool { + let delta2 = self.last_delta - current_delta; + let delta3 = delta2 - self.last_delta2; + + self.last_delta = current_delta; + self.last_delta2 = delta2; + + current_delta == 0 || delta2 == 0 || delta3 == 0 + } +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for JitterRng { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "JitterRng {{}}") + } +} + +impl Clone for JitterRng { + fn clone(&self) -> JitterRng { + JitterRng { + data: self.data, + rounds: self.rounds, + timer: self.timer, + mem_prev_index: self.mem_prev_index, + // The 32 bits that may still be unused from the previous round are + // for the original to use, not for the clone. + data_half_used: false, + } + } +} + +/// An error that can occur when [`JitterRng::test_timer`] fails. +/// +/// [`JitterRng::test_timer`]: struct.JitterRng.html#method.test_timer +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum TimerError { + /// No timer available. + NoTimer, + /// Timer too coarse to use as an entropy source. + CoarseTimer, + /// Timer is not monotonically increasing. + NotMonotonic, + /// Variations of deltas of time too small. + TinyVariantions, + /// Too many stuck results (indicating no added entropy). + TooManyStuck, + #[doc(hidden)] + __Nonexhaustive, +} + +impl TimerError { + fn description(&self) -> &'static str { + match *self { + TimerError::NoTimer => "no timer available", + TimerError::CoarseTimer => "coarse timer", + TimerError::NotMonotonic => "timer not monotonic", + TimerError::TinyVariantions => "time delta variations too small", + TimerError::TooManyStuck => "too many stuck results", + TimerError::__Nonexhaustive => unreachable!(), + } + } +} + +impl fmt::Display for TimerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.description()) + } +} + +#[cfg(feature="std")] +impl ::std::error::Error for TimerError { + fn description(&self) -> &str { + self.description() + } +} + +impl From for Error { + fn from(err: TimerError) -> Error { + // Timer check is already quite permissive of failures so we don't + // expect false-positive failures, i.e. any error is irrecoverable. + Error::with_cause(ErrorKind::Unavailable, + "timer jitter failed basic quality tests", err) + } +} + +// Initialise to zero; must be positive +#[cfg(all(feature="std", not(target_arch = "wasm32")))] +static JITTER_ROUNDS: AtomicUsize = ATOMIC_USIZE_INIT; + +impl JitterRng { + /// Create a new `JitterRng`. Makes use of `std::time` for a timer, or a + /// platform-specific function with higher accuracy if necessary and + /// available. + /// + /// During initialization CPU execution timing jitter is measured a few + /// hundred times. If this does not pass basic quality tests, an error is + /// returned. The test result is cached to make subsequent calls faster. + #[cfg(all(feature="std", not(target_arch = "wasm32")))] + pub fn new() -> Result { + let mut state = JitterRng::new_with_timer(platform::get_nstime); + let mut rounds = JITTER_ROUNDS.load(Ordering::Relaxed) as u8; + if rounds == 0 { + // No result yet: run test. + // This allows the timer test to run multiple times; we don't care. + rounds = state.test_timer()?; + JITTER_ROUNDS.store(rounds as usize, Ordering::Relaxed); + info!("JitterRng: using {} rounds per u64 output", rounds); + } + state.set_rounds(rounds); + + // Fill `data` with a non-zero value. + state.gen_entropy(); + Ok(state) + } + + /// Create a new `JitterRng`. + /// A custom timer can be supplied, making it possible to use `JitterRng` in + /// `no_std` environments. + /// + /// The timer must have nanosecond precision. + /// + /// This method is more low-level than `new()`. It is the responsibility of + /// the caller to run [`test_timer`] before using any numbers generated with + /// `JitterRng`, and optionally call [`set_rounds`]. Also it is important to + /// consume at least one `u64` before using the first result to initialize + /// the entropy collection pool. + /// + /// # Example + /// + /// ``` + /// # use rand::{Rng, Error}; + /// use rand::jitter::JitterRng; + /// + /// # fn try_inner() -> Result<(), Error> { + /// fn get_nstime() -> u64 { + /// use std::time::{SystemTime, UNIX_EPOCH}; + /// + /// let dur = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); + /// // The correct way to calculate the current time is + /// // `dur.as_secs() * 1_000_000_000 + dur.subsec_nanos() as u64` + /// // But this is faster, and the difference in terms of entropy is + /// // negligible (log2(10^9) == 29.9). + /// dur.as_secs() << 30 | dur.subsec_nanos() as u64 + /// } + /// + /// let mut rng = JitterRng::new_with_timer(get_nstime); + /// let rounds = rng.test_timer()?; + /// rng.set_rounds(rounds); // optional + /// let _ = rng.gen::(); + /// + /// // Ready for use + /// let v: u64 = rng.gen(); + /// # Ok(()) + /// # } + /// + /// # let _ = try_inner(); + /// ``` + /// + /// [`test_timer`]: struct.JitterRng.html#method.test_timer + /// [`set_rounds`]: struct.JitterRng.html#method.set_rounds + pub fn new_with_timer(timer: fn() -> u64) -> JitterRng { + JitterRng { + data: 0, + rounds: 64, + timer, + mem_prev_index: 0, + data_half_used: false, + } + } + + /// Configures how many rounds are used to generate each 64-bit value. + /// This must be greater than zero, and has a big impact on performance + /// and output quality. + /// + /// [`new_with_timer`] conservatively uses 64 rounds, but often less rounds + /// can be used. The `test_timer()` function returns the minimum number of + /// rounds required for full strength (platform dependent), so one may use + /// `rng.set_rounds(rng.test_timer()?);` or cache the value. + /// + /// [`new_with_timer`]: struct.JitterRng.html#method.new_with_timer + pub fn set_rounds(&mut self, rounds: u8) { + assert!(rounds > 0); + self.rounds = rounds; + } + + // Calculate a random loop count used for the next round of an entropy + // collection, based on bits from a fresh value from the timer. + // + // The timer is folded to produce a number that contains at most `n_bits` + // bits. + // + // Note: A constant should be added to the resulting random loop count to + // prevent loops that run 0 times. + #[inline(never)] + fn random_loop_cnt(&mut self, n_bits: u32) -> u32 { + let mut rounds = 0; + + let mut time = (self.timer)(); + // Mix with the current state of the random number balance the random + // loop counter a bit more. + time ^= self.data; + + // We fold the time value as much as possible to ensure that as many + // bits of the time stamp are included as possible. + let folds = (64 + n_bits - 1) / n_bits; + let mask = (1 << n_bits) - 1; + for _ in 0..folds { + rounds ^= time & mask; + time >>= n_bits; + } + + rounds as u32 + } + + // CPU jitter noise source + // Noise source based on the CPU execution time jitter + // + // This function injects the individual bits of the time value into the + // entropy pool using an LFSR. + // + // The code is deliberately inefficient with respect to the bit shifting. + // This function not only acts as folding operation, but this function's + // execution is used to measure the CPU execution time jitter. Any change to + // the loop in this function implies that careful retesting must be done. + #[inline(never)] + fn lfsr_time(&mut self, time: u64, var_rounds: bool) { + fn lfsr(mut data: u64, time: u64) -> u64{ + for i in 1..65 { + let mut tmp = time << (64 - i); + tmp >>= 64 - 1; + + // Fibonacci LSFR with polynomial of + // x^64 + x^61 + x^56 + x^31 + x^28 + x^23 + 1 which is + // primitive according to + // http://poincare.matf.bg.ac.rs/~ezivkovm/publications/primpol1.pdf + // (the shift values are the polynomial values minus one + // due to counting bits from 0 to 63). As the current + // position is always the LSB, the polynomial only needs + // to shift data in from the left without wrap. + data ^= tmp; + data ^= (data >> 63) & 1; + data ^= (data >> 60) & 1; + data ^= (data >> 55) & 1; + data ^= (data >> 30) & 1; + data ^= (data >> 27) & 1; + data ^= (data >> 22) & 1; + data = data.rotate_left(1); + } + data + } + + // Note: in the reference implementation only the last round effects + // `self.data`, all the other results are ignored. To make sure the + // other rounds are not optimised out, we first run all but the last + // round on a throw-away value instead of the real `self.data`. + let mut lfsr_loop_cnt = 0; + if var_rounds { lfsr_loop_cnt = self.random_loop_cnt(4) }; + + let mut throw_away: u64 = 0; + for _ in 0..lfsr_loop_cnt { + throw_away = lfsr(throw_away, time); + } + black_box(throw_away); + + self.data = lfsr(self.data, time); + } + + // Memory Access noise source + // This is a noise source based on variations in memory access times + // + // This function performs memory accesses which will add to the timing + // variations due to an unknown amount of CPU wait states that need to be + // added when accessing memory. The memory size should be larger than the L1 + // caches as outlined in the documentation and the associated testing. + // + // The L1 cache has a very high bandwidth, albeit its access rate is usually + // slower than accessing CPU registers. Therefore, L1 accesses only add + // minimal variations as the CPU has hardly to wait. Starting with L2, + // significant variations are added because L2 typically does not belong to + // the CPU any more and therefore a wider range of CPU wait states is + // necessary for accesses. L3 and real memory accesses have even a wider + // range of wait states. However, to reliably access either L3 or memory, + // the `self.mem` memory must be quite large which is usually not desirable. + #[inline(never)] + fn memaccess(&mut self, mem: &mut [u8; MEMORY_SIZE], var_rounds: bool) { + let mut acc_loop_cnt = 128; + if var_rounds { acc_loop_cnt += self.random_loop_cnt(4) }; + + let mut index = self.mem_prev_index as usize; + for _ in 0..acc_loop_cnt { + // Addition of memblocksize - 1 to index with wrap around logic to + // ensure that every memory location is hit evenly. + // The modulus also allows the compiler to remove the indexing + // bounds check. + index = (index + MEMORY_BLOCKSIZE - 1) % MEMORY_SIZE; + + // memory access: just add 1 to one byte + // memory access implies read from and write to memory location + mem[index] = mem[index].wrapping_add(1); + } + self.mem_prev_index = index as u16; + } + + // This is the heart of the entropy generation: calculate time deltas and + // use the CPU jitter in the time deltas. The jitter is injected into the + // entropy pool. + // + // Ensure that `ec.prev_time` is primed before using the output of this + // function. This can be done by calling this function and not using its + // result. + fn measure_jitter(&mut self, ec: &mut EcState) -> Option<()> { + // Invoke one noise source before time measurement to add variations + self.memaccess(&mut ec.mem, true); + + // Get time stamp and calculate time delta to previous + // invocation to measure the timing variations + let time = (self.timer)(); + // Note: wrapping_sub combined with a cast to `i64` generates a correct + // delta, even in the unlikely case this is a timer that is not strictly + // monotonic. + let current_delta = time.wrapping_sub(ec.prev_time) as i64 as i32; + ec.prev_time = time; + + // Call the next noise source which also injects the data + self.lfsr_time(current_delta as u64, true); + + // Check whether we have a stuck measurement (i.e. does the last + // measurement holds entropy?). + if ec.stuck(current_delta) { return None }; + + // Rotate the data buffer by a prime number (any odd number would + // do) to ensure that every bit position of the input time stamp + // has an even chance of being merged with a bit position in the + // entropy pool. We do not use one here as the adjacent bits in + // successive time deltas may have some form of dependency. The + // chosen value of 7 implies that the low 7 bits of the next + // time delta value is concatenated with the current time delta. + self.data = self.data.rotate_left(7); + + Some(()) + } + + // Shuffle the pool a bit by mixing some value with a bijective function + // (XOR) into the pool. + // + // The function generates a mixer value that depends on the bits set and + // the location of the set bits in the random number generated by the + // entropy source. Therefore, based on the generated random number, this + // mixer value can have 2^64 different values. That mixer value is + // initialized with the first two SHA-1 constants. After obtaining the + // mixer value, it is XORed into the random number. + // + // The mixer value is not assumed to contain any entropy. But due to the + // XOR operation, it can also not destroy any entropy present in the + // entropy pool. + #[inline(never)] + fn stir_pool(&mut self) { + // This constant is derived from the first two 32 bit initialization + // vectors of SHA-1 as defined in FIPS 180-4 section 5.3.1 + // The order does not really matter as we do not rely on the specific + // numbers. We just pick the SHA-1 constants as they have a good mix of + // bit set and unset. + const CONSTANT: u64 = 0x67452301efcdab89; + + // The start value of the mixer variable is derived from the third + // and fourth 32 bit initialization vector of SHA-1 as defined in + // FIPS 180-4 section 5.3.1 + let mut mixer = 0x98badcfe10325476; + + // This is a constant time function to prevent leaking timing + // information about the random number. + // The normal code is: + // ``` + // for i in 0..64 { + // if ((self.data >> i) & 1) == 1 { mixer ^= CONSTANT; } + // } + // ``` + // This is a bit fragile, as LLVM really wants to use branches here, and + // we rely on it to not recognise the opportunity. + for i in 0..64 { + let apply = (self.data >> i) & 1; + let mask = !apply.wrapping_sub(1); + mixer ^= CONSTANT & mask; + mixer = mixer.rotate_left(1); + } + + self.data ^= mixer; + } + + fn gen_entropy(&mut self) -> u64 { + trace!("JitterRng: collecting entropy"); + + // Prime `ec.prev_time`, and run the noice sources to make sure the + // first loop round collects the expected entropy. + let mut ec = EcState { + prev_time: (self.timer)(), + last_delta: 0, + last_delta2: 0, + mem: [0; MEMORY_SIZE], + }; + let _ = self.measure_jitter(&mut ec); + + for _ in 0..self.rounds { + // If a stuck measurement is received, repeat measurement + // Note: we do not guard against an infinite loop, that would mean + // the timer suddenly became broken. + while self.measure_jitter(&mut ec).is_none() {} + } + + // Do a single read from `self.mem` to make sure the Memory Access noise + // source is not optimised out. + black_box(ec.mem[0]); + + self.stir_pool(); + self.data + } + + /// Basic quality tests on the timer, by measuring CPU timing jitter a few + /// hundred times. + /// + /// If succesful, this will return the estimated number of rounds necessary + /// to collect 64 bits of entropy. Otherwise a [`TimerError`] with the cause + /// of the failure will be returned. + /// + /// [`TimerError`]: enum.TimerError.html + pub fn test_timer(&mut self) -> Result { + debug!("JitterRng: testing timer ..."); + // We could add a check for system capabilities such as `clock_getres` + // or check for `CONFIG_X86_TSC`, but it does not make much sense as the + // following sanity checks verify that we have a high-resolution timer. + + let mut delta_sum = 0; + let mut old_delta = 0; + + let mut time_backwards = 0; + let mut count_mod = 0; + let mut count_stuck = 0; + + let mut ec = EcState { + prev_time: (self.timer)(), + last_delta: 0, + last_delta2: 0, + mem: [0; MEMORY_SIZE], + }; + + // TESTLOOPCOUNT needs some loops to identify edge systems. + // 100 is definitely too little. + const TESTLOOPCOUNT: u64 = 300; + const CLEARCACHE: u64 = 100; + + for i in 0..(CLEARCACHE + TESTLOOPCOUNT) { + // Measure time delta of core entropy collection logic + let time = (self.timer)(); + self.memaccess(&mut ec.mem, true); + self.lfsr_time(time, true); + let time2 = (self.timer)(); + + // Test whether timer works + if time == 0 || time2 == 0 { + return Err(TimerError::NoTimer); + } + let delta = time2.wrapping_sub(time) as i64 as i32; + + // Test whether timer is fine grained enough to provide delta even + // when called shortly after each other -- this implies that we also + // have a high resolution timer + if delta == 0 { + return Err(TimerError::CoarseTimer); + } + + // Up to here we did not modify any variable that will be + // evaluated later, but we already performed some work. Thus we + // already have had an impact on the caches, branch prediction, + // etc. with the goal to clear it to get the worst case + // measurements. + if i < CLEARCACHE { continue; } + + if ec.stuck(delta) { count_stuck += 1; } + + // Test whether we have an increasing timer. + if !(time2 > time) { time_backwards += 1; } + + // Count the number of times the counter increases in steps of 100ns + // or greater. + if (delta % 100) == 0 { count_mod += 1; } + + // Ensure that we have a varying delta timer which is necessary for + // the calculation of entropy -- perform this check only after the + // first loop is executed as we need to prime the old_delta value + delta_sum += (delta - old_delta).abs() as u64; + old_delta = delta; + } + + // Do a single read from `self.mem` to make sure the Memory Access noise + // source is not optimised out. + black_box(ec.mem[0]); + + // We allow the time to run backwards for up to three times. + // This can happen if the clock is being adjusted by NTP operations. + // If such an operation just happens to interfere with our test, it + // should not fail. The value of 3 should cover the NTP case being + // performed during our test run. + if time_backwards > 3 { + return Err(TimerError::NotMonotonic); + } + + // Test that the available amount of entropy per round does not get to + // low. We expect 1 bit of entropy per round as a reasonable minimum + // (although less is possible, it means the collector loop has to run + // much more often). + // `assert!(delta_average >= log2(1))` + // `assert!(delta_sum / TESTLOOPCOUNT >= 1)` + // `assert!(delta_sum >= TESTLOOPCOUNT)` + if delta_sum < TESTLOOPCOUNT { + return Err(TimerError::TinyVariantions); + } + + // Ensure that we have variations in the time stamp below 100 for at + // least 10% of all checks -- on some platforms, the counter increments + // in multiples of 100, but not always + if count_mod > (TESTLOOPCOUNT * 9 / 10) { + return Err(TimerError::CoarseTimer); + } + + // If we have more than 90% stuck results, then this Jitter RNG is + // likely to not work well. + if count_stuck > (TESTLOOPCOUNT * 9 / 10) { + return Err(TimerError::TooManyStuck); + } + + // Estimate the number of `measure_jitter` rounds necessary for 64 bits + // of entropy. + // + // We don't try very hard to come up with a good estimate of the + // available bits of entropy per round here for two reasons: + // 1. Simple estimates of the available bits (like Shannon entropy) are + // too optimistic. + // 2. Unless we want to waste a lot of time during intialization, there + // only a small number of samples are available. + // + // Therefore we use a very simple and conservative estimate: + // `let bits_of_entropy = log2(delta_average) / 2`. + // + // The number of rounds `measure_jitter` should run to collect 64 bits + // of entropy is `64 / bits_of_entropy`. + let delta_average = delta_sum / TESTLOOPCOUNT; + + if delta_average >= 16 { + let log2 = 64 - delta_average.leading_zeros(); + // Do something similar to roundup(64/(log2/2)): + Ok( ((64u32 * 2 + log2 - 1) / log2) as u8) + } else { + // For values < 16 the rounding error becomes too large, use a + // lookup table. + // Values 0 and 1 are invalid, and filtered out by the + // `delta_sum < TESTLOOPCOUNT` test above. + let log2_lookup = [0, 0, 128, 81, 64, 56, 50, 46, + 43, 41, 39, 38, 36, 35, 34, 33]; + Ok(log2_lookup[delta_average as usize]) + } + } + + /// Statistical test: return the timer delta of one normal run of the + /// `JitterRng` entropy collector. + /// + /// Setting `var_rounds` to `true` will execute the memory access and the + /// CPU jitter noice sources a variable amount of times (just like a real + /// `JitterRng` round). + /// + /// Setting `var_rounds` to `false` will execute the noice sources the + /// minimal number of times. This can be used to measure the minimum amount + /// of entropy one round of the entropy collector can collect in the worst + /// case. + /// + /// See [Quality testing](struct.JitterRng.html#quality-testing) on how to + /// use `timer_stats` to test the quality of `JitterRng`. + pub fn timer_stats(&mut self, var_rounds: bool) -> i64 { + let mut mem = [0; MEMORY_SIZE]; + + let time = (self.timer)(); + self.memaccess(&mut mem, var_rounds); + self.lfsr_time(time, var_rounds); + let time2 = (self.timer)(); + time2.wrapping_sub(time) as i64 + } +} + +#[cfg(feature="std")] +mod platform { + #[cfg(not(any(target_os = "macos", target_os = "ios", + target_os = "windows", + target_arch = "wasm32")))] + pub fn get_nstime() -> u64 { + use std::time::{SystemTime, UNIX_EPOCH}; + + let dur = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); + // The correct way to calculate the current time is + // `dur.as_secs() * 1_000_000_000 + dur.subsec_nanos() as u64` + // But this is faster, and the difference in terms of entropy is + // negligible (log2(10^9) == 29.9). + dur.as_secs() << 30 | dur.subsec_nanos() as u64 + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub fn get_nstime() -> u64 { + extern crate libc; + // On Mac OS and iOS std::time::SystemTime only has 1000ns resolution. + // We use `mach_absolute_time` instead. This provides a CPU dependent + // unit, to get real nanoseconds the result should by multiplied by + // numer/denom from `mach_timebase_info`. + // But we are not interested in the exact nanoseconds, just entropy. So + // we use the raw result. + unsafe { libc::mach_absolute_time() } + } + + #[cfg(target_os = "windows")] + pub fn get_nstime() -> u64 { + extern crate winapi; + unsafe { + let mut t = super::mem::zeroed(); + winapi::um::profileapi::QueryPerformanceCounter(&mut t); + *t.QuadPart() as u64 + } + } +} + +// A function that is opaque to the optimizer to assist in avoiding dead-code +// elimination. Taken from `bencher`. +fn black_box(dummy: T) -> T { + unsafe { + let ret = ptr::read_volatile(&dummy); + mem::forget(dummy); + ret + } +} + +impl RngCore for JitterRng { + fn next_u32(&mut self) -> u32 { + // We want to use both parts of the generated entropy + if self.data_half_used { + self.data_half_used = false; + (self.data >> 32) as u32 + } else { + self.data = self.next_u64(); + self.data_half_used = true; + self.data as u32 + } + } + + fn next_u64(&mut self) -> u64 { + self.data_half_used = false; + self.gen_entropy() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + // Fill using `next_u32`. This is faster for filling small slices (four + // bytes or less), while the overhead is negligible. + // + // This is done especially for wrappers that implement `next_u32` + // themselves via `fill_bytes`. + impls::fill_bytes_via_next(self, dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} + +impl CryptoRng for JitterRng {} + +#[cfg(test)] +mod test_jitter_init { + use jitter::JitterRng; + + #[cfg(all(feature="std", not(target_arch = "wasm32")))] + #[test] + fn test_jitter_init() { + use RngCore; + // Because this is a debug build, measurements here are not representive + // of the final release build. + // Don't fail this test if initializing `JitterRng` fails because of a + // bad timer (the timer from the standard library may not have enough + // accuracy on all platforms). + match JitterRng::new() { + Ok(ref mut rng) => { + // false positives are possible, but extremely unlikely + assert!(rng.next_u32() | rng.next_u32() != 0); + }, + Err(_) => {}, + } + } + + #[test] + fn test_jitter_bad_timer() { + fn bad_timer() -> u64 { 0 } + let mut rng = JitterRng::new_with_timer(bad_timer); + assert!(rng.test_timer().is_err()); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/mock.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/mock.rs new file mode 100644 index 0000000..812e4be --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/mock.rs @@ -0,0 +1,61 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Mock random number generator + +use rand_core::{RngCore, Error, impls}; + +/// A simple implementation of `RngCore` for testing purposes. +/// +/// This generates an arithmetic sequence (i.e. adds a constant each step) +/// over a `u64` number, using wrapping arithmetic. If the increment is 0 +/// the generator yields a constant. +/// +/// ``` +/// use rand::Rng; +/// use rand::rngs::mock::StepRng; +/// +/// let mut my_rng = StepRng::new(2, 1); +/// let sample: [u64; 3] = my_rng.gen(); +/// assert_eq!(sample, [2, 3, 4]); +/// ``` +#[derive(Debug, Clone)] +pub struct StepRng { + v: u64, + a: u64, +} + +impl StepRng { + /// Create a `StepRng`, yielding an arithmetic sequence starting with + /// `initial` and incremented by `increment` each time. + pub fn new(initial: u64, increment: u64) -> Self { + StepRng { v: initial, a: increment } + } +} + +impl RngCore for StepRng { + fn next_u32(&mut self) -> u32 { + self.next_u64() as u32 + } + + fn next_u64(&mut self) -> u64 { + let result = self.v; + self.v = self.v.wrapping_add(self.a); + result + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + impls::fill_bytes_via_next(self, dest); + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/mod.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/mod.rs new file mode 100644 index 0000000..acc207d --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/mod.rs @@ -0,0 +1,218 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Random number generators and adapters for common usage: +//! +//! - [`ThreadRng`], a fast, secure, auto-seeded thread-local generator +//! - [`StdRng`] and [`SmallRng`], algorithms to cover typical usage +//! - [`EntropyRng`], [`OsRng`] and [`JitterRng`] as entropy sources +//! - [`mock::StepRng`] as a simple counter for tests +//! - [`adapter::ReadRng`] to read from a file/stream +//! +//! # Background — Random number generators (RNGs) +//! +//! Computers are inherently deterministic, so to get *random* numbers one +//! either has to use a hardware generator or collect bits of *entropy* from +//! various sources (e.g. event timestamps, or jitter). This is a relatively +//! slow and complicated operation. +//! +//! Generally the operating system will collect some entropy, remove bias, and +//! use that to seed its own PRNG; [`OsRng`] provides an interface to this. +//! [`JitterRng`] is an entropy collector included with Rand that measures +//! jitter in the CPU execution time, and jitter in memory access time. +//! [`EntropyRng`] is a wrapper that uses the best entropy source that is +//! available. +//! +//! ## Pseudo-random number generators +//! +//! What is commonly used instead of "true" random number renerators, are +//! *pseudo-random number generators* (PRNGs), deterministic algorithms that +//! produce an infinite stream of pseudo-random numbers from a small random +//! seed. PRNGs are faster, and have better provable properties. The numbers +//! produced can be statistically of very high quality and can be impossible to +//! predict. (They can also have obvious correlations and be trivial to predict; +//! quality varies.) +//! +//! There are two different types of PRNGs: those developed for simulations +//! and statistics, and those developed for use in cryptography; the latter are +//! called Cryptographically Secure PRNGs (CSPRNG or CPRNG). Both types can +//! have good statistical quality but the latter also have to be impossible to +//! predict, even after seeing many previous output values. Rand provides a good +//! default algorithm from each class: +//! +//! - [`SmallRng`] is a PRNG chosen for low memory usage, high performance and +//! good statistical quality. +//! The current algorithm (plain Xorshift) unfortunately performs +//! poorly in statistical quality test suites (TestU01 and PractRand) and will +//! be replaced in the next major release. +//! - [`StdRng`] is a CSPRNG chosen for good performance and trust of security +//! (based on reviews, maturity and usage). The current algorithm is HC-128, +//! which is one of the recommendations by ECRYPT's eSTREAM project. +//! +//! The above PRNGs do not cover all use-cases; more algorithms can be found in +//! the [`prng` module], as well as in several other crates. For example, you +//! may wish a CSPRNG with significantly lower memory usage than [`StdRng`] +//! while being less concerned about performance, in which case [`ChaChaRng`] +//! is a good choice. +//! +//! One complexity is that the internal state of a PRNG must change with every +//! generated number. For APIs this generally means a mutable reference to the +//! state of the PRNG has to be passed around. +//! +//! A solution is [`ThreadRng`]. This is a thread-local implementation of +//! [`StdRng`] with automatic seeding on first use. It is the best choice if you +//! "just" want a convenient, secure, fast random number source. Use via the +//! [`thread_rng`] function, which gets a reference to the current thread's +//! local instance. +//! +//! ## Seeding +//! +//! As mentioned above, PRNGs require a random seed in order to produce random +//! output. This is especially important for CSPRNGs, which are still +//! deterministic algorithms, thus can only be secure if their seed value is +//! also secure. To seed a PRNG, use one of: +//! +//! - [`FromEntropy::from_entropy`]; this is the most convenient way to seed +//! with fresh, secure random data. +//! - [`SeedableRng::from_rng`]; this allows seeding from another PRNG or +//! from an entropy source such as [`EntropyRng`]. +//! - [`SeedableRng::from_seed`]; this is mostly useful if you wish to be able +//! to reproduce the output sequence by using a fixed seed. (Don't use +//! [`StdRng`] or [`SmallRng`] in this case since different algorithms may be +//! used by future versions of Rand; use an algorithm from the +//! [`prng` module].) +//! +//! ## Conclusion +//! +//! - [`thread_rng`] is what you often want to use. +//! - If you want more control, flexibility, or better performance, use +//! [`StdRng`], [`SmallRng`] or an algorithm from the [`prng` module]. +//! - Use [`FromEntropy::from_entropy`] to seed new PRNGs. +//! - If you need reproducibility, use [`SeedableRng::from_seed`] combined with +//! a named PRNG. +//! +//! More information and notes on cryptographic security can be found +//! in the [`prng` module]. +//! +//! ## Examples +//! +//! Examples of seeding PRNGs: +//! +//! ``` +//! use rand::prelude::*; +//! # use rand::Error; +//! +//! // StdRng seeded securely by the OS or local entropy collector: +//! let mut rng = StdRng::from_entropy(); +//! # let v: u32 = rng.gen(); +//! +//! // SmallRng seeded from thread_rng: +//! # fn try_inner() -> Result<(), Error> { +//! let mut rng = SmallRng::from_rng(thread_rng())?; +//! # let v: u32 = rng.gen(); +//! # Ok(()) +//! # } +//! # try_inner().unwrap(); +//! +//! // SmallRng seeded by a constant, for deterministic results: +//! let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16]; // byte array +//! let mut rng = SmallRng::from_seed(seed); +//! # let v: u32 = rng.gen(); +//! ``` +//! +//! +//! # Implementing custom RNGs +//! +//! If you want to implement custom RNG, see the [`rand_core`] crate. The RNG +//! will have to implement the [`RngCore`] trait, where the [`Rng`] trait is +//! build on top of. +//! +//! If the RNG needs seeding, also implement the [`SeedableRng`] trait. +//! +//! [`CryptoRng`] is a marker trait cryptographically secure PRNGs can +//! implement. +//! +//! +// This module: +//! [`ThreadRng`]: struct.ThreadRng.html +//! [`StdRng`]: struct.StdRng.html +//! [`SmallRng`]: struct.SmallRng.html +//! [`EntropyRng`]: struct.EntropyRng.html +//! [`OsRng`]: struct.OsRng.html +//! [`JitterRng`]: struct.JitterRng.html +// Other traits and functions: +//! [`rand_core`]: https://crates.io/crates/rand_core +//! [`prng` module]: ../prng/index.html +//! [`CryptoRng`]: ../trait.CryptoRng.html +//! [`FromEntropy`]: ../trait.FromEntropy.html +//! [`FromEntropy::from_entropy`]: ../trait.FromEntropy.html#tymethod.from_entropy +//! [`RngCore`]: ../trait.RngCore.html +//! [`Rng`]: ../trait.Rng.html +//! [`SeedableRng`]: ../trait.SeedableRng.html +//! [`SeedableRng::from_rng`]: ../trait.SeedableRng.html#tymethod.from_rng +//! [`SeedableRng::from_seed`]: ../trait.SeedableRng.html#tymethod.from_seed +//! [`thread_rng`]: ../fn.thread_rng.html +//! [`mock::StepRng`]: mock/struct.StepRng.html +//! [`adapter::ReadRng`]: adapter/struct.ReadRng.html +//! [`ChaChaRng`]: ../prng/chacha/struct.ChaChaRng.html + +pub mod adapter; + +#[cfg(feature="std")] mod entropy; +#[doc(hidden)] pub mod jitter; +pub mod mock; // Public so we don't export `StepRng` directly, making it a bit + // more clear it is intended for testing. +mod small; +mod std; +#[cfg(feature="std")] pub(crate) mod thread; + + +pub use self::jitter::{JitterRng, TimerError}; +#[cfg(feature="std")] pub use self::entropy::EntropyRng; + +pub use self::small::SmallRng; +pub use self::std::StdRng; +#[cfg(feature="std")] pub use self::thread::ThreadRng; + +#[cfg(all(feature="std", + any(target_os = "linux", target_os = "android", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "haiku", + target_os = "emscripten", + target_os = "solaris", + target_os = "cloudabi", + target_os = "macos", target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", target_os = "bitrig", + target_os = "redox", + target_os = "fuchsia", + windows, + all(target_arch = "wasm32", feature = "stdweb") +)))] +mod os; + +#[cfg(all(feature="std", + any(target_os = "linux", target_os = "android", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "haiku", + target_os = "emscripten", + target_os = "solaris", + target_os = "cloudabi", + target_os = "macos", target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", target_os = "bitrig", + target_os = "redox", + target_os = "fuchsia", + windows, + all(target_arch = "wasm32", feature = "stdweb") +)))] +pub use self::os::OsRng; diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/os.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/os.rs new file mode 100644 index 0000000..ecc5f32 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/os.rs @@ -0,0 +1,1171 @@ +// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Interface to the random number generator of the operating system. + +use std::fmt; +use rand_core::{CryptoRng, RngCore, Error, impls}; + +/// A random number generator that retrieves randomness straight from the +/// operating system. +/// +/// This is the preferred external source of entropy for most applications. +/// Commonly it is used to initialize a user-space RNG, which can then be used +/// to generate random values with much less overhead than `OsRng`. +/// +/// You may prefer to use [`EntropyRng`] instead of `OsRng`. It is unlikely, but +/// not entirely theoretical, for `OsRng` to fail. In such cases [`EntropyRng`] +/// falls back on a good alternative entropy source. +/// +/// `OsRng::new()` is guaranteed to be very cheap (after the first successful +/// call), and will never consume more than one file handle per process. +/// +/// # Platform sources +/// +/// | OS | interface +/// |------------------|--------------------------------------------------------- +/// | Linux, Android | [`getrandom`][1] system call if available, otherwise [`/dev/urandom`][2] after reading from `/dev/random` once +/// | Windows | [`RtlGenRandom`][3] +/// | macOS, iOS | [`SecRandomCopyBytes`][4] +/// | FreeBSD | [`kern.arandom`][5] +/// | OpenBSD, Bitrig | [`getentropy`][6] +/// | NetBSD | [`/dev/urandom`][7] after reading from `/dev/random` once +/// | Dragonfly BSD | [`/dev/random`][8] +/// | Solaris, illumos | [`getrandom`][9] system call if available, otherwise [`/dev/random`][10] +/// | Fuchsia OS | [`cprng_draw`][11] +/// | Redox | [`rand:`][12] +/// | CloudABI | [`random_get`][13] +/// | Haiku | `/dev/random` (identical to `/dev/urandom`) +/// | Web browsers | [`Crypto.getRandomValues`][14] (see [Support for WebAssembly and ams.js][14]) +/// | Node.js | [`crypto.randomBytes`][15] (see [Support for WebAssembly and ams.js][16]) +/// +/// Rand doesn't have a blanket implementation for all Unix-like operating +/// systems that reads from `/dev/urandom`. This ensures all supported operating +/// systems are using the recommended interface and respect maximum buffer +/// sizes. +/// +/// ## Support for WebAssembly and ams.js +/// +/// The three Emscripten targets `asmjs-unknown-emscripten`, +/// `wasm32-unknown-emscripten` and `wasm32-experimental-emscripten` use +/// Emscripten's emulation of `/dev/random` on web browsers and Node.js. +/// Unfortunately it falls back to the insecure `Math.random()` if a browser +/// doesn't support [`Crypto.getRandomValues`][12]. +/// +/// The bare Wasm target `wasm32-unknown-unknown` tries to call the javascript +/// methods directly, using `stdweb` in combination with `cargo-web`. +/// `wasm-bindgen` is not yet supported. +/// +/// ## Early boot +/// +/// It is possible that early in the boot process the OS hasn't had enough time +/// yet to collect entropy to securely seed its RNG, especially on virtual +/// machines. +/// +/// Some operating systems always block the thread until the RNG is securely +/// seeded. This can take anywhere from a few seconds to more than a minute. +/// Others make a best effort to use a seed from before the shutdown and don't +/// document much. +/// +/// A few, Linux, NetBSD and Solaris, offer a choice between blocking, and +/// getting an error. With `try_fill_bytes` we choose to get the error +/// ([`ErrorKind::NotReady`]), while the other methods use a blocking interface. +/// +/// On Linux (when the `genrandom` system call is not available) and on NetBSD +/// reading from `/dev/urandom` never blocks, even when the OS hasn't collected +/// enough entropy yet. As a countermeasure we try to do a single read from +/// `/dev/random` until we know the OS RNG is initialized (and store this in a +/// global static). +/// +/// # Panics +/// +/// `OsRng` is extremely unlikely to fail if `OsRng::new()`, and one read from +/// it, where succesfull. But in case it does fail, only [`try_fill_bytes`] is +/// able to report the cause. Depending on the error the other [`RngCore`] +/// methods will retry several times, and panic in case the error remains. +/// +/// [`EntropyRng`]: struct.EntropyRng.html +/// [`RngCore`]: ../trait.RngCore.html +/// [`try_fill_bytes`]: ../trait.RngCore.html#method.tymethod.try_fill_bytes +/// [`ErrorKind::NotReady`]: ../enum.ErrorKind.html#variant.NotReady +/// +/// [1]: http://man7.org/linux/man-pages/man2/getrandom.2.html +/// [2]: http://man7.org/linux/man-pages/man4/urandom.4.html +/// [3]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx +/// [4]: https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc +/// [5]: https://www.freebsd.org/cgi/man.cgi?query=random&sektion=4 +/// [6]: https://man.openbsd.org/getentropy.2 +/// [7]: http://netbsd.gw.com/cgi-bin/man-cgi?random+4+NetBSD-current +/// [8]: https://leaf.dragonflybsd.org/cgi/web-man?command=random§ion=4 +/// [9]: https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html +/// [10]: https://docs.oracle.com/cd/E86824_01/html/E54777/random-7d.html +/// [11]: https://fuchsia.googlesource.com/zircon/+/HEAD/docs/syscalls/cprng_draw.md +/// [12]: https://github.com/redox-os/randd/blob/master/src/main.rs +/// [13]: https://github.com/NuxiNL/cloudabi/blob/v0.20/cloudabi.txt#L1826 +/// [14]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues +/// [15]: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback +/// [16]: #support-for-webassembly-and-amsjs + + +#[derive(Clone)] +pub struct OsRng(imp::OsRng); + +impl fmt::Debug for OsRng { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + +impl OsRng { + /// Create a new `OsRng`. + pub fn new() -> Result { + imp::OsRng::new().map(OsRng) + } +} + +impl CryptoRng for OsRng {} + +impl RngCore for OsRng { + fn next_u32(&mut self) -> u32 { + impls::next_u32_via_fill(self) + } + + fn next_u64(&mut self) -> u64 { + impls::next_u64_via_fill(self) + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + use std::{time, thread}; + + // We cannot return Err(..), so we try to handle before panicking. + const MAX_RETRY_PERIOD: u32 = 10; // max 10s + const WAIT_DUR_MS: u32 = 100; // retry every 100ms + let wait_dur = time::Duration::from_millis(WAIT_DUR_MS as u64); + const RETRY_LIMIT: u32 = (MAX_RETRY_PERIOD * 1000) / WAIT_DUR_MS; + const TRANSIENT_RETRIES: u32 = 8; + let mut err_count = 0; + let mut error_logged = false; + + // Maybe block until the OS RNG is initialized + let mut read = 0; + if let Ok(n) = self.0.test_initialized(dest, true) { read = n }; + let dest = &mut dest[read..]; + + loop { + if let Err(e) = self.try_fill_bytes(dest) { + if err_count >= RETRY_LIMIT { + error!("OsRng failed too many times; last error: {}", e); + panic!("OsRng failed too many times; last error: {}", e); + } + + if e.kind.should_wait() { + if !error_logged { + warn!("OsRng failed; waiting up to {}s and retrying. Error: {}", + MAX_RETRY_PERIOD, e); + error_logged = true; + } + err_count += 1; + thread::sleep(wait_dur); + continue; + } else if e.kind.should_retry() { + if !error_logged { + warn!("OsRng failed; retrying up to {} times. Error: {}", + TRANSIENT_RETRIES, e); + error_logged = true; + } + err_count += (RETRY_LIMIT + TRANSIENT_RETRIES - 1) + / TRANSIENT_RETRIES; // round up + continue; + } else { + error!("OsRng failed: {}", e); + panic!("OsRng fatal error: {}", e); + } + } + + break; + } + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + // Some systems do not support reading 0 random bytes. + // (And why waste a system call?) + if dest.len() == 0 { return Ok(()); } + + let read = self.0.test_initialized(dest, false)?; + let dest = &mut dest[read..]; + + let max = self.0.max_chunk_size(); + if dest.len() <= max { + trace!("OsRng: reading {} bytes via {}", + dest.len(), self.0.method_str()); + } else { + trace!("OsRng: reading {} bytes via {} in {} chunks of {} bytes", + dest.len(), self.0.method_str(), (dest.len() + max) / max, max); + } + for slice in dest.chunks_mut(max) { + self.0.fill_chunk(slice)?; + } + Ok(()) + } +} + +trait OsRngImpl where Self: Sized { + // Create a new `OsRng` platform interface. + fn new() -> Result; + + // Fill a chunk with random bytes. + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error>; + + // Test whether the OS RNG is initialized. This method may not be possible + // to support cheaply (or at all) on all operating systems. + // + // If `blocking` is set, this will cause the OS the block execution until + // its RNG is initialized. + // + // Random values that are read while this are stored in `dest`, the amount + // of read bytes is returned. + fn test_initialized(&mut self, _dest: &mut [u8], _blocking: bool) + -> Result { Ok(0) } + + // Maximum chunk size supported. + fn max_chunk_size(&self) -> usize { ::core::usize::MAX } + + // Name of the OS interface (used for logging). + fn method_str(&self) -> &'static str; +} + + + + +// Helper functions to read from a random device such as `/dev/urandom`. +// +// All instances use a single internal file handle, to prevent possible +// exhaustion of file descriptors. +#[cfg(any(target_os = "linux", target_os = "android", + target_os = "netbsd", target_os = "dragonfly", + target_os = "solaris", target_os = "redox", + target_os = "haiku", target_os = "emscripten"))] +mod random_device { + use {Error, ErrorKind}; + use std::fs::File; + use std::io; + use std::io::Read; + use std::sync::{Once, Mutex, ONCE_INIT}; + + // TODO: remove outer Option when `Mutex::new(None)` is a constant expression + static mut READ_RNG_FILE: Option>> = None; + static READ_RNG_ONCE: Once = ONCE_INIT; + + #[allow(unused)] + pub fn open(path: &'static str, open_fn: F) -> Result<(), Error> + where F: Fn(&'static str) -> Result + { + READ_RNG_ONCE.call_once(|| { + unsafe { READ_RNG_FILE = Some(Mutex::new(None)) } + }); + + // We try opening the file outside the `call_once` fn because we cannot + // clone the error, thus we must retry on failure. + + let mutex = unsafe { READ_RNG_FILE.as_ref().unwrap() }; + let mut guard = mutex.lock().unwrap(); + if (*guard).is_none() { + info!("OsRng: opening random device {}", path); + let file = open_fn(path).map_err(map_err)?; + *guard = Some(file); + }; + Ok(()) + } + + pub fn read(dest: &mut [u8]) -> Result<(), Error> { + // We expect this function only to be used after `random_device::open` + // was succesful. Therefore we can assume that our memory was set with a + // valid object. + let mutex = unsafe { READ_RNG_FILE.as_ref().unwrap() }; + let mut guard = mutex.lock().unwrap(); + let file = (*guard).as_mut().unwrap(); + + // Use `std::io::read_exact`, which retries on `ErrorKind::Interrupted`. + file.read_exact(dest).map_err(|err| { + Error::with_cause(ErrorKind::Unavailable, + "error reading random device", err) + }) + + } + + pub fn map_err(err: io::Error) -> Error { + match err.kind() { + io::ErrorKind::Interrupted => + Error::new(ErrorKind::Transient, "interrupted"), + io::ErrorKind::WouldBlock => + Error::with_cause(ErrorKind::NotReady, + "OS RNG not yet seeded", err), + _ => Error::with_cause(ErrorKind::Unavailable, + "error while opening random device", err) + } + } +} + + +#[cfg(any(target_os = "linux", target_os = "android"))] +mod imp { + extern crate libc; + + use {Error, ErrorKind}; + use super::random_device; + use super::OsRngImpl; + + use std::io; + use std::io::Read; + use std::fs::{File, OpenOptions}; + use std::os::unix::fs::OpenOptionsExt; + use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; + use std::sync::{Once, ONCE_INIT}; + + #[derive(Clone, Debug)] + pub struct OsRng { + method: OsRngMethod, + initialized: bool, + } + + #[derive(Clone, Debug)] + enum OsRngMethod { + GetRandom, + RandomDevice, + } + + impl OsRngImpl for OsRng { + fn new() -> Result { + if is_getrandom_available() { + return Ok(OsRng { method: OsRngMethod::GetRandom, + initialized: false }); + } + random_device::open("/dev/urandom", &|p| File::open(p))?; + Ok(OsRng { method: OsRngMethod::RandomDevice, initialized: false }) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + match self.method { + OsRngMethod::GetRandom => getrandom_try_fill(dest, false), + OsRngMethod::RandomDevice => random_device::read(dest), + } + } + + fn test_initialized(&mut self, dest: &mut [u8], blocking: bool) + -> Result + { + static OS_RNG_INITIALIZED: AtomicBool = ATOMIC_BOOL_INIT; + if !self.initialized { + self.initialized = OS_RNG_INITIALIZED.load(Ordering::Relaxed); + } + if self.initialized { return Ok(0); } + + let result = match self.method { + OsRngMethod::GetRandom => { + getrandom_try_fill(dest, blocking)?; + Ok(dest.len()) + } + OsRngMethod::RandomDevice => { + info!("OsRng: testing random device /dev/random"); + let mut file = OpenOptions::new() + .read(true) + .custom_flags(if blocking { 0 } else { libc::O_NONBLOCK }) + .open("/dev/random") + .map_err(random_device::map_err)?; + file.read(&mut dest[..1]).map_err(random_device::map_err)?; + Ok(1) + } + }; + OS_RNG_INITIALIZED.store(true, Ordering::Relaxed); + self.initialized = true; + result + } + + fn method_str(&self) -> &'static str { + match self.method { + OsRngMethod::GetRandom => "getrandom", + OsRngMethod::RandomDevice => "/dev/urandom", + } + } + } + + #[cfg(target_arch = "x86_64")] + const NR_GETRANDOM: libc::c_long = 318; + #[cfg(target_arch = "x86")] + const NR_GETRANDOM: libc::c_long = 355; + #[cfg(target_arch = "arm")] + const NR_GETRANDOM: libc::c_long = 384; + #[cfg(target_arch = "aarch64")] + const NR_GETRANDOM: libc::c_long = 278; + #[cfg(target_arch = "s390x")] + const NR_GETRANDOM: libc::c_long = 349; + #[cfg(target_arch = "powerpc")] + const NR_GETRANDOM: libc::c_long = 359; + #[cfg(target_arch = "mips")] // old ABI + const NR_GETRANDOM: libc::c_long = 4353; + #[cfg(target_arch = "mips64")] + const NR_GETRANDOM: libc::c_long = 5313; + #[cfg(not(any(target_arch = "x86_64", target_arch = "x86", + target_arch = "arm", target_arch = "aarch64", + target_arch = "s390x", target_arch = "powerpc", + target_arch = "mips", target_arch = "mips64")))] + const NR_GETRANDOM: libc::c_long = 0; + + fn getrandom(buf: &mut [u8], blocking: bool) -> libc::c_long { + extern "C" { + fn syscall(number: libc::c_long, ...) -> libc::c_long; + } + const GRND_NONBLOCK: libc::c_uint = 0x0001; + + if NR_GETRANDOM == 0 { return -1 }; + + unsafe { + syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), + if blocking { 0 } else { GRND_NONBLOCK }) + } + } + + fn getrandom_try_fill(dest: &mut [u8], blocking: bool) -> Result<(), Error> { + let mut read = 0; + while read < dest.len() { + let result = getrandom(&mut dest[read..], blocking); + if result == -1 { + let err = io::Error::last_os_error(); + let kind = err.kind(); + if kind == io::ErrorKind::Interrupted { + continue; + } else if kind == io::ErrorKind::WouldBlock { + return Err(Error::with_cause( + ErrorKind::NotReady, + "getrandom not ready", + err, + )); + } else { + return Err(Error::with_cause( + ErrorKind::Unavailable, + "unexpected getrandom error", + err, + )); + } + } else { + read += result as usize; + } + } + Ok(()) + } + + fn is_getrandom_available() -> bool { + static CHECKER: Once = ONCE_INIT; + static AVAILABLE: AtomicBool = ATOMIC_BOOL_INIT; + + if NR_GETRANDOM == 0 { return false }; + + CHECKER.call_once(|| { + debug!("OsRng: testing getrandom"); + let mut buf: [u8; 0] = []; + let result = getrandom(&mut buf, false); + let available = if result == -1 { + let err = io::Error::last_os_error().raw_os_error(); + err != Some(libc::ENOSYS) + } else { + true + }; + AVAILABLE.store(available, Ordering::Relaxed); + info!("OsRng: using {}", if available { "getrandom" } else { "/dev/urandom" }); + }); + + AVAILABLE.load(Ordering::Relaxed) + } +} + + +#[cfg(target_os = "netbsd")] +mod imp { + use Error; + use super::random_device; + use super::OsRngImpl; + + use std::fs::File; + use std::io::Read; + use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; + + #[derive(Clone, Debug)] + pub struct OsRng { initialized: bool } + + impl OsRngImpl for OsRng { + fn new() -> Result { + random_device::open("/dev/urandom", &|p| File::open(p))?; + Ok(OsRng { initialized: false }) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + random_device::read(dest) + } + + // Read a single byte from `/dev/random` to determine if the OS RNG is + // already seeded. NetBSD always blocks if not yet ready. + fn test_initialized(&mut self, dest: &mut [u8], _blocking: bool) + -> Result + { + static OS_RNG_INITIALIZED: AtomicBool = ATOMIC_BOOL_INIT; + if !self.initialized { + self.initialized = OS_RNG_INITIALIZED.load(Ordering::Relaxed); + } + if self.initialized { return Ok(0); } + + info!("OsRng: testing random device /dev/random"); + let mut file = + File::open("/dev/random").map_err(random_device::map_err)?; + file.read(&mut dest[..1]).map_err(random_device::map_err)?; + + OS_RNG_INITIALIZED.store(true, Ordering::Relaxed); + self.initialized = true; + Ok(1) + } + + fn method_str(&self) -> &'static str { "/dev/urandom" } + } +} + + +#[cfg(any(target_os = "dragonfly", + target_os = "haiku", + target_os = "emscripten"))] +mod imp { + use Error; + use super::random_device; + use super::OsRngImpl; + use std::fs::File; + + #[derive(Clone, Debug)] + pub struct OsRng(); + + impl OsRngImpl for OsRng { + fn new() -> Result { + random_device::open("/dev/random", &|p| File::open(p))?; + Ok(OsRng()) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + random_device::read(dest) + } + + #[cfg(target_os = "emscripten")] + fn max_chunk_size(&self) -> usize { + // `Crypto.getRandomValues` documents `dest` should be at most 65536 + // bytes. `crypto.randomBytes` documents: "To minimize threadpool + // task length variation, partition large randomBytes requests when + // doing so as part of fulfilling a client request. + 65536 + } + + fn method_str(&self) -> &'static str { "/dev/random" } + } +} + + +// Read from `/dev/random`, with chunks of limited size (1040 bytes). +// `/dev/random` uses the Hash_DRBG with SHA512 algorithm from NIST SP 800-90A. +// `/dev/urandom` uses the FIPS 186-2 algorithm, which is considered less +// secure. We choose to read from `/dev/random`. +// +// Since Solaris 11.3 the `getrandom` syscall is available. To make sure we can +// compile on both Solaris and on OpenSolaris derivatives, that do not have the +// function, we do a direct syscall instead of calling a library function. +// +// We have no way to differentiate between Solaris, illumos, SmartOS, etc. +#[cfg(target_os = "solaris")] +mod imp { + extern crate libc; + + use {Error, ErrorKind}; + use super::random_device; + use super::OsRngImpl; + + use std::io; + use std::io::Read; + use std::fs::{File, OpenOptions}; + use std::os::unix::fs::OpenOptionsExt; + use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; + + #[derive(Clone, Debug)] + pub struct OsRng { + method: OsRngMethod, + initialized: bool, + } + + #[derive(Clone, Debug)] + enum OsRngMethod { + GetRandom, + RandomDevice, + } + + impl OsRngImpl for OsRng { + fn new() -> Result { + if is_getrandom_available() { + return Ok(OsRng { method: OsRngMethod::GetRandom, + initialized: false }); + } + let open = |p| OpenOptions::new() + .read(true) + .custom_flags(libc::O_NONBLOCK) + .open(p); + random_device::open("/dev/random", &open)?; + Ok(OsRng { method: OsRngMethod::RandomDevice, initialized: false }) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + match self.method { + OsRngMethod::GetRandom => getrandom_try_fill(dest, false), + OsRngMethod::RandomDevice => random_device::read(dest), + } + } + + fn test_initialized(&mut self, dest: &mut [u8], blocking: bool) + -> Result + { + static OS_RNG_INITIALIZED: AtomicBool = ATOMIC_BOOL_INIT; + if !self.initialized { + self.initialized = OS_RNG_INITIALIZED.load(Ordering::Relaxed); + } + if self.initialized { return Ok(0); } + + let chunk_len = ::core::cmp::min(1024, dest.len()); + let dest = &mut dest[..chunk_len]; + + match self.method { + OsRngMethod::GetRandom => getrandom_try_fill(dest, blocking)?, + OsRngMethod::RandomDevice => { + if blocking { + info!("OsRng: testing random device /dev/random"); + // We already have a non-blocking handle, but now need a + // blocking one. Not much choice except opening it twice + let mut file = File::open("/dev/random") + .map_err(random_device::map_err)?; + file.read(dest).map_err(random_device::map_err)?; + } else { + self.fill_chunk(dest)?; + } + } + }; + OS_RNG_INITIALIZED.store(true, Ordering::Relaxed); + self.initialized = true; + Ok(chunk_len) + } + + fn max_chunk_size(&self) -> usize { + // The documentation says 1024 is the maximum for getrandom, but + // 1040 for /dev/random. + 1024 + } + + fn method_str(&self) -> &'static str { + match self.method { + OsRngMethod::GetRandom => "getrandom", + OsRngMethod::RandomDevice => "/dev/random", + } + } + } + + fn getrandom(buf: &mut [u8], blocking: bool) -> libc::c_long { + extern "C" { + fn syscall(number: libc::c_long, ...) -> libc::c_long; + } + + const SYS_GETRANDOM: libc::c_long = 143; + const GRND_NONBLOCK: libc::c_uint = 0x0001; + const GRND_RANDOM: libc::c_uint = 0x0002; + + unsafe { + syscall(SYS_GETRANDOM, buf.as_mut_ptr(), buf.len(), + if blocking { 0 } else { GRND_NONBLOCK } | GRND_RANDOM) + } + } + + fn getrandom_try_fill(dest: &mut [u8], blocking: bool) -> Result<(), Error> { + let result = getrandom(dest, blocking); + if result == -1 || result == 0 { + let err = io::Error::last_os_error(); + let kind = err.kind(); + if kind == io::ErrorKind::WouldBlock { + return Err(Error::with_cause( + ErrorKind::NotReady, + "getrandom not ready", + err, + )); + } else { + return Err(Error::with_cause( + ErrorKind::Unavailable, + "unexpected getrandom error", + err, + )); + } + } else if result != dest.len() as i64 { + return Err(Error::new(ErrorKind::Unavailable, + "unexpected getrandom error")); + } + Ok(()) + } + + fn is_getrandom_available() -> bool { + use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; + use std::sync::{Once, ONCE_INIT}; + + static CHECKER: Once = ONCE_INIT; + static AVAILABLE: AtomicBool = ATOMIC_BOOL_INIT; + + CHECKER.call_once(|| { + debug!("OsRng: testing getrandom"); + let mut buf: [u8; 0] = []; + let result = getrandom(&mut buf, false); + let available = if result == -1 { + let err = io::Error::last_os_error().raw_os_error(); + err != Some(libc::ENOSYS) + } else { + true + }; + AVAILABLE.store(available, Ordering::Relaxed); + info!("OsRng: using {}", if available { "getrandom" } else { "/dev/random" }); + }); + + AVAILABLE.load(Ordering::Relaxed) + } +} + + +#[cfg(target_os = "cloudabi")] +mod imp { + extern crate cloudabi; + + use std::io; + use {Error, ErrorKind}; + use super::OsRngImpl; + + #[derive(Clone, Debug)] + pub struct OsRng; + + impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let errno = unsafe { cloudabi::random_get(dest) }; + if errno == cloudabi::errno::SUCCESS { + Ok(()) + } else { + // Cloudlibc provides its own `strerror` implementation so we + // can use `from_raw_os_error` here. + Err(Error::with_cause( + ErrorKind::Unavailable, + "random_get() system call failed", + io::Error::from_raw_os_error(errno as i32), + )) + } + } + + fn method_str(&self) -> &'static str { "cloudabi::random_get" } + } +} + + +#[cfg(any(target_os = "macos", target_os = "ios"))] +mod imp { + extern crate libc; + + use {Error, ErrorKind}; + use super::OsRngImpl; + + use std::io; + use self::libc::{c_int, size_t}; + + #[derive(Clone, Debug)] + pub struct OsRng; + + enum SecRandom {} + + #[allow(non_upper_case_globals)] + const kSecRandomDefault: *const SecRandom = 0 as *const SecRandom; + + #[link(name = "Security", kind = "framework")] + extern { + fn SecRandomCopyBytes(rnd: *const SecRandom, + count: size_t, bytes: *mut u8) -> c_int; + } + + impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let ret = unsafe { + SecRandomCopyBytes(kSecRandomDefault, + dest.len() as size_t, + dest.as_mut_ptr()) + }; + if ret == -1 { + Err(Error::with_cause( + ErrorKind::Unavailable, + "couldn't generate random bytes", + io::Error::last_os_error())) + } else { + Ok(()) + } + } + + fn method_str(&self) -> &'static str { "SecRandomCopyBytes" } + } +} + + +#[cfg(target_os = "freebsd")] +mod imp { + extern crate libc; + + use {Error, ErrorKind}; + use super::OsRngImpl; + + use std::ptr; + use std::io; + + #[derive(Clone, Debug)] + pub struct OsRng; + + impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let mib = [libc::CTL_KERN, libc::KERN_ARND]; + let mut len = dest.len(); + let ret = unsafe { + libc::sysctl(mib.as_ptr(), mib.len() as libc::c_uint, + dest.as_mut_ptr() as *mut _, &mut len, + ptr::null(), 0) + }; + if ret == -1 || len != dest.len() { + return Err(Error::with_cause( + ErrorKind::Unavailable, + "kern.arandom sysctl failed", + io::Error::last_os_error())); + } + Ok(()) + } + + fn max_chunk_size(&self) -> usize { 256 } + + fn method_str(&self) -> &'static str { "kern.arandom" } + } +} + + +#[cfg(any(target_os = "openbsd", target_os = "bitrig"))] +mod imp { + extern crate libc; + + use {Error, ErrorKind}; + use super::OsRngImpl; + + use std::io; + + #[derive(Clone, Debug)] + pub struct OsRng; + + impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let ret = unsafe { + libc::getentropy(dest.as_mut_ptr() as *mut libc::c_void, dest.len()) + }; + if ret == -1 { + return Err(Error::with_cause( + ErrorKind::Unavailable, + "getentropy failed", + io::Error::last_os_error())); + } + Ok(()) + } + + fn max_chunk_size(&self) -> usize { 256 } + + fn method_str(&self) -> &'static str { "getentropy" } + } +} + + +#[cfg(target_os = "redox")] +mod imp { + use Error; + use super::random_device; + use super::OsRngImpl; + use std::fs::File; + + #[derive(Clone, Debug)] + pub struct OsRng(); + + impl OsRngImpl for OsRng { + fn new() -> Result { + random_device::open("rand:", &|p| File::open(p))?; + Ok(OsRng()) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + random_device::read(dest) + } + + fn method_str(&self) -> &'static str { "'rand:'" } + } +} + + +#[cfg(target_os = "fuchsia")] +mod imp { + extern crate fuchsia_cprng; + + use Error; + use super::OsRngImpl; + + #[derive(Clone, Debug)] + pub struct OsRng; + + impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + fuchsia_cprng::cprng_draw(dest); + Ok(()) + } + + fn method_str(&self) -> &'static str { "cprng_draw" } + } +} + + +#[cfg(windows)] +mod imp { + extern crate winapi; + + use {Error, ErrorKind}; + use super::OsRngImpl; + + use std::io; + + use self::winapi::shared::minwindef::ULONG; + use self::winapi::um::ntsecapi::RtlGenRandom; + use self::winapi::um::winnt::PVOID; + + #[derive(Clone, Debug)] + pub struct OsRng; + + impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let ret = unsafe { + RtlGenRandom(dest.as_mut_ptr() as PVOID, dest.len() as ULONG) + }; + if ret == 0 { + return Err(Error::with_cause( + ErrorKind::Unavailable, + "couldn't generate random bytes", + io::Error::last_os_error())); + } + Ok(()) + } + + fn max_chunk_size(&self) -> usize { ::max_value() as usize } + + fn method_str(&self) -> &'static str { "RtlGenRandom" } + } +} + + +#[cfg(all(target_arch = "wasm32", + not(target_os = "emscripten"), + feature = "stdweb"))] +mod imp { + use std::mem; + use stdweb::unstable::TryInto; + use stdweb::web::error::Error as WebError; + use {Error, ErrorKind}; + use super::OsRngImpl; + + #[derive(Clone, Debug)] + enum OsRngMethod { + Browser, + Node + } + + #[derive(Clone, Debug)] + pub struct OsRng(OsRngMethod); + + impl OsRngImpl for OsRng { + fn new() -> Result { + let result = js! { + try { + if ( + typeof self === "object" && + typeof self.crypto === "object" && + typeof self.crypto.getRandomValues === "function" + ) { + return { success: true, ty: 1 }; + } + + if (typeof require("crypto").randomBytes === "function") { + return { success: true, ty: 2 }; + } + + return { success: false, error: new Error("not supported") }; + } catch(err) { + return { success: false, error: err }; + } + }; + + if js!{ return @{ result.as_ref() }.success } == true { + let ty = js!{ return @{ result }.ty }; + + if ty == 1 { Ok(OsRng(OsRngMethod::Browser)) } + else if ty == 2 { Ok(OsRng(OsRngMethod::Node)) } + else { unreachable!() } + } else { + let err: WebError = js!{ return @{ result }.error }.try_into().unwrap(); + Err(Error::with_cause(ErrorKind::Unavailable, "WASM Error", err)) + } + } + + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + assert_eq!(mem::size_of::(), 4); + + let len = dest.len() as u32; + let ptr = dest.as_mut_ptr() as i32; + + let result = match self.0 { + OsRngMethod::Browser => js! { + try { + let array = new Uint8Array(@{ len }); + self.crypto.getRandomValues(array); + HEAPU8.set(array, @{ ptr }); + + return { success: true }; + } catch(err) { + return { success: false, error: err }; + } + }, + OsRngMethod::Node => js! { + try { + let bytes = require("crypto").randomBytes(@{ len }); + HEAPU8.set(new Uint8Array(bytes), @{ ptr }); + + return { success: true }; + } catch(err) { + return { success: false, error: err }; + } + } + }; + + if js!{ return @{ result.as_ref() }.success } == true { + Ok(()) + } else { + let err: WebError = js!{ return @{ result }.error }.try_into().unwrap(); + Err(Error::with_cause(ErrorKind::Unexpected, "WASM Error", err)) + } + } + + fn max_chunk_size(&self) -> usize { 65536 } + + fn method_str(&self) -> &'static str { + match self.0 { + OsRngMethod::Browser => "Crypto.getRandomValues", + OsRngMethod::Node => "crypto.randomBytes", + } + } + } +} + + +#[cfg(test)] +mod test { + use RngCore; + use OsRng; + + #[test] + fn test_os_rng() { + let mut r = OsRng::new().unwrap(); + + r.next_u32(); + r.next_u64(); + + let mut v1 = [0u8; 1000]; + r.fill_bytes(&mut v1); + + let mut v2 = [0u8; 1000]; + r.fill_bytes(&mut v2); + + let mut n_diff_bits = 0; + for i in 0..v1.len() { + n_diff_bits += (v1[i] ^ v2[i]).count_ones(); + } + + // Check at least 1 bit per byte differs. p(failure) < 1e-1000 with random input. + assert!(n_diff_bits >= v1.len() as u32); + } + + #[test] + fn test_os_rng_empty() { + let mut r = OsRng::new().unwrap(); + + let mut empty = [0u8; 0]; + r.fill_bytes(&mut empty); + } + + #[test] + fn test_os_rng_huge() { + let mut r = OsRng::new().unwrap(); + + let mut huge = [0u8; 100_000]; + r.fill_bytes(&mut huge); + } + + #[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))] + #[test] + fn test_os_rng_tasks() { + use std::sync::mpsc::channel; + use std::thread; + + let mut txs = vec!(); + for _ in 0..20 { + let (tx, rx) = channel(); + txs.push(tx); + + thread::spawn(move|| { + // wait until all the tasks are ready to go. + rx.recv().unwrap(); + + // deschedule to attempt to interleave things as much + // as possible (XXX: is this a good test?) + let mut r = OsRng::new().unwrap(); + thread::yield_now(); + let mut v = [0u8; 1000]; + + for _ in 0..100 { + r.next_u32(); + thread::yield_now(); + r.next_u64(); + thread::yield_now(); + r.fill_bytes(&mut v); + thread::yield_now(); + } + }); + } + + // start all the tasks + for tx in txs.iter() { + tx.send(()).unwrap(); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/small.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/small.rs new file mode 100644 index 0000000..effdbff --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/small.rs @@ -0,0 +1,101 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A small fast RNG + +use {RngCore, SeedableRng, Error}; +use prng::XorShiftRng; + +/// An RNG recommended when small state, cheap initialization and good +/// performance are required. The PRNG algorithm in `SmallRng` is chosen to be +/// efficient on the current platform, **without consideration for cryptography +/// or security**. The size of its state is much smaller than for [`StdRng`]. +/// +/// Reproducibility of output from this generator is however not required, thus +/// future library versions may use a different internal generator with +/// different output. Further, this generator may not be portable and can +/// produce different output depending on the architecture. If you require +/// reproducible output, use a named RNG, for example [`XorShiftRng`]. +/// +/// The current algorithm used on all platforms is [Xorshift]. +/// +/// # Examples +/// +/// Initializing `SmallRng` with a random seed can be done using [`FromEntropy`]: +/// +/// ``` +/// # use rand::Rng; +/// use rand::FromEntropy; +/// use rand::rngs::SmallRng; +/// +/// // Create small, cheap to initialize and fast RNG with a random seed. +/// // The randomness is supplied by the operating system. +/// let mut small_rng = SmallRng::from_entropy(); +/// # let v: u32 = small_rng.gen(); +/// ``` +/// +/// When initializing a lot of `SmallRng`'s, using [`thread_rng`] can be more +/// efficient: +/// +/// ``` +/// use std::iter; +/// use rand::{SeedableRng, thread_rng}; +/// use rand::rngs::SmallRng; +/// +/// // Create a big, expensive to initialize and slower, but unpredictable RNG. +/// // This is cached and done only once per thread. +/// let mut thread_rng = thread_rng(); +/// // Create small, cheap to initialize and fast RNGs with random seeds. +/// // One can generally assume this won't fail. +/// let rngs: Vec = iter::repeat(()) +/// .map(|()| SmallRng::from_rng(&mut thread_rng).unwrap()) +/// .take(10) +/// .collect(); +/// ``` +/// +/// [`FromEntropy`]: ../trait.FromEntropy.html +/// [`StdRng`]: struct.StdRng.html +/// [`thread_rng`]: ../fn.thread_rng.html +/// [Xorshift]: ../prng/struct.XorShiftRng.html +/// [`XorShiftRng`]: ../prng/struct.XorShiftRng.html +#[derive(Clone, Debug)] +pub struct SmallRng(XorShiftRng); + +impl RngCore for SmallRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for SmallRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + SmallRng(XorShiftRng::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + XorShiftRng::from_rng(rng).map(SmallRng) + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/std.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/std.rs new file mode 100644 index 0000000..1451f76 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/std.rs @@ -0,0 +1,83 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The standard RNG + +use {RngCore, CryptoRng, Error, SeedableRng}; +use prng::Hc128Rng; + +/// The standard RNG. The PRNG algorithm in `StdRng` is chosen to be efficient +/// on the current platform, to be statistically strong and unpredictable +/// (meaning a cryptographically secure PRNG). +/// +/// The current algorithm used on all platforms is [HC-128]. +/// +/// Reproducibility of output from this generator is however not required, thus +/// future library versions may use a different internal generator with +/// different output. Further, this generator may not be portable and can +/// produce different output depending on the architecture. If you require +/// reproducible output, use a named RNG, for example [`ChaChaRng`]. +/// +/// [HC-128]: ../prng/hc128/struct.Hc128Rng.html +/// [`ChaChaRng`]: ../prng/chacha/struct.ChaChaRng.html +#[derive(Clone, Debug)] +pub struct StdRng(Hc128Rng); + +impl RngCore for StdRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for StdRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + StdRng(Hc128Rng::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + Hc128Rng::from_rng(rng).map(StdRng) + } +} + +impl CryptoRng for StdRng {} + + +#[cfg(test)] +mod test { + use {RngCore, SeedableRng}; + use rngs::StdRng; + + #[test] + fn test_stdrng_construction() { + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng1 = StdRng::from_seed(seed); + assert_eq!(rng1.next_u64(), 15759097995037006553); + + let mut rng2 = StdRng::from_rng(rng1).unwrap(); + assert_eq!(rng2.next_u64(), 6766915756997287454); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/rngs/thread.rs b/third_party/cargo/vendor/rand-0.5.6/src/rngs/thread.rs new file mode 100644 index 0000000..863b79d --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/rngs/thread.rs @@ -0,0 +1,141 @@ +// Copyright 2017-2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Thread-local random number generator + +use std::cell::UnsafeCell; +use std::rc::Rc; + +use {RngCore, CryptoRng, SeedableRng, Error}; +use rngs::adapter::ReseedingRng; +use rngs::EntropyRng; +use prng::hc128::Hc128Core; + +// Rationale for using `UnsafeCell` in `ThreadRng`: +// +// Previously we used a `RefCell`, with an overhead of ~15%. There will only +// ever be one mutable reference to the interior of the `UnsafeCell`, because +// we only have such a reference inside `next_u32`, `next_u64`, etc. Within a +// single thread (which is the definition of `ThreadRng`), there will only ever +// be one of these methods active at a time. +// +// A possible scenario where there could be multiple mutable references is if +// `ThreadRng` is used inside `next_u32` and co. But the implementation is +// completely under our control. We just have to ensure none of them use +// `ThreadRng` internally, which is nonsensical anyway. We should also never run +// `ThreadRng` in destructors of its implementation, which is also nonsensical. +// +// The additional `Rc` is not strictly neccesary, and could be removed. For now +// it ensures `ThreadRng` stays `!Send` and `!Sync`, and implements `Clone`. + + +// Number of generated bytes after which to reseed `TreadRng`. +// +// The time it takes to reseed HC-128 is roughly equivalent to generating 7 KiB. +// We pick a treshold here that is large enough to not reduce the average +// performance too much, but also small enough to not make reseeding something +// that basically never happens. +const THREAD_RNG_RESEED_THRESHOLD: u64 = 32*1024*1024; // 32 MiB + +/// The type returned by [`thread_rng`], essentially just a reference to the +/// PRNG in thread-local memory. +/// +/// `ThreadRng` uses [`ReseedingRng`] wrapping the same PRNG as [`StdRng`], +/// which is reseeded after generating 32 MiB of random data. A single instance +/// is cached per thread and the returned `ThreadRng` is a reference to this +/// instance — hence `ThreadRng` is neither `Send` nor `Sync` but is safe to use +/// within a single thread. This RNG is seeded and reseeded via [`EntropyRng`] +/// as required. +/// +/// Note that the reseeding is done as an extra precaution against entropy +/// leaks and is in theory unnecessary — to predict `ThreadRng`'s output, an +/// attacker would have to either determine most of the RNG's seed or internal +/// state, or crack the algorithm used. +/// +/// Like [`StdRng`], `ThreadRng` is a cryptographically secure PRNG. The current +/// algorithm used is [HC-128], which is an array-based PRNG that trades memory +/// usage for better performance. This makes it similar to ISAAC, the algorithm +/// used in `ThreadRng` before rand 0.5. +/// +/// Cloning this handle just produces a new reference to the same thread-local +/// generator. +/// +/// [`thread_rng`]: ../fn.thread_rng.html +/// [`ReseedingRng`]: adapter/struct.ReseedingRng.html +/// [`StdRng`]: struct.StdRng.html +/// [`EntropyRng`]: struct.EntropyRng.html +/// [HC-128]: ../prng/hc128/struct.Hc128Rng.html +#[derive(Clone, Debug)] +pub struct ThreadRng { + rng: Rc>>, +} + +thread_local!( + static THREAD_RNG_KEY: Rc>> = { + let mut entropy_source = EntropyRng::new(); + let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err| + panic!("could not initialize thread_rng: {}", err)); + let rng = ReseedingRng::new(r, + THREAD_RNG_RESEED_THRESHOLD, + entropy_source); + Rc::new(UnsafeCell::new(rng)) + } +); + +/// Retrieve the lazily-initialized thread-local random number +/// generator, seeded by the system. Intended to be used in method +/// chaining style, e.g. `thread_rng().gen::()`, or cached locally, e.g. +/// `let mut rng = thread_rng();`. +/// +/// For more information see [`ThreadRng`]. +/// +/// [`ThreadRng`]: rngs/struct.ThreadRng.html +pub fn thread_rng() -> ThreadRng { + ThreadRng { rng: THREAD_RNG_KEY.with(|t| t.clone()) } +} + +impl RngCore for ThreadRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + unsafe { (*self.rng.get()).next_u32() } + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + unsafe { (*self.rng.get()).next_u64() } + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + unsafe { (*self.rng.get()).fill_bytes(dest) } + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + unsafe { (*self.rng.get()).try_fill_bytes(dest) } + } +} + +impl CryptoRng for ThreadRng {} + + +#[cfg(test)] +mod test { + #[test] + #[cfg(not(feature="stdweb"))] + fn test_thread_rng() { + use Rng; + let mut r = ::thread_rng(); + r.gen::(); + let mut v = [1, 1, 1]; + r.shuffle(&mut v); + let b: &[_] = &[1, 1, 1]; + assert_eq!(v, b); + assert_eq!(r.gen_range(0, 1), 0); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/src/seq.rs b/third_party/cargo/vendor/rand-0.5.6/src/seq.rs new file mode 100644 index 0000000..8c7ed47 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/src/seq.rs @@ -0,0 +1,334 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Functions for randomly accessing and sampling sequences. + +use super::Rng; + +// This crate is only enabled when either std or alloc is available. +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::vec::Vec; +// BTreeMap is not as fast in tests, but better than nothing. +#[cfg(feature="std")] use std::collections::HashMap; +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::collections::BTreeMap; + +/// Randomly sample `amount` elements from a finite iterator. +/// +/// The following can be returned: +/// +/// - `Ok`: `Vec` of `amount` non-repeating randomly sampled elements. The order is not random. +/// - `Err`: `Vec` of all the elements from `iterable` in sequential order. This happens when the +/// length of `iterable` was less than `amount`. This is considered an error since exactly +/// `amount` elements is typically expected. +/// +/// This implementation uses `O(len(iterable))` time and `O(amount)` memory. +/// +/// # Example +/// +/// ``` +/// use rand::{thread_rng, seq}; +/// +/// let mut rng = thread_rng(); +/// let sample = seq::sample_iter(&mut rng, 1..100, 5).unwrap(); +/// println!("{:?}", sample); +/// ``` +pub fn sample_iter(rng: &mut R, iterable: I, amount: usize) -> Result, Vec> + where I: IntoIterator, + R: Rng + ?Sized, +{ + let mut iter = iterable.into_iter(); + let mut reservoir = Vec::with_capacity(amount); + reservoir.extend(iter.by_ref().take(amount)); + + // Continue unless the iterator was exhausted + // + // note: this prevents iterators that "restart" from causing problems. + // If the iterator stops once, then so do we. + if reservoir.len() == amount { + for (i, elem) in iter.enumerate() { + let k = rng.gen_range(0, i + 1 + amount); + if let Some(spot) = reservoir.get_mut(k) { + *spot = elem; + } + } + Ok(reservoir) + } else { + // Don't hang onto extra memory. There is a corner case where + // `amount` was much less than `len(iterable)`. + reservoir.shrink_to_fit(); + Err(reservoir) + } +} + +/// Randomly sample exactly `amount` values from `slice`. +/// +/// The values are non-repeating and in random order. +/// +/// This implementation uses `O(amount)` time and memory. +/// +/// Panics if `amount > slice.len()` +/// +/// # Example +/// +/// ``` +/// use rand::{thread_rng, seq}; +/// +/// let mut rng = thread_rng(); +/// let values = vec![5, 6, 1, 3, 4, 6, 7]; +/// println!("{:?}", seq::sample_slice(&mut rng, &values, 3)); +/// ``` +pub fn sample_slice(rng: &mut R, slice: &[T], amount: usize) -> Vec + where R: Rng + ?Sized, + T: Clone +{ + let indices = sample_indices(rng, slice.len(), amount); + + let mut out = Vec::with_capacity(amount); + out.extend(indices.iter().map(|i| slice[*i].clone())); + out +} + +/// Randomly sample exactly `amount` references from `slice`. +/// +/// The references are non-repeating and in random order. +/// +/// This implementation uses `O(amount)` time and memory. +/// +/// Panics if `amount > slice.len()` +/// +/// # Example +/// +/// ``` +/// use rand::{thread_rng, seq}; +/// +/// let mut rng = thread_rng(); +/// let values = vec![5, 6, 1, 3, 4, 6, 7]; +/// println!("{:?}", seq::sample_slice_ref(&mut rng, &values, 3)); +/// ``` +pub fn sample_slice_ref<'a, R, T>(rng: &mut R, slice: &'a [T], amount: usize) -> Vec<&'a T> + where R: Rng + ?Sized +{ + let indices = sample_indices(rng, slice.len(), amount); + + let mut out = Vec::with_capacity(amount); + out.extend(indices.iter().map(|i| &slice[*i])); + out +} + +/// Randomly sample exactly `amount` indices from `0..length`. +/// +/// The values are non-repeating and in random order. +/// +/// This implementation uses `O(amount)` time and memory. +/// +/// This method is used internally by the slice sampling methods, but it can sometimes be useful to +/// have the indices themselves so this is provided as an alternative. +/// +/// Panics if `amount > length` +pub fn sample_indices(rng: &mut R, length: usize, amount: usize) -> Vec + where R: Rng + ?Sized, +{ + if amount > length { + panic!("`amount` must be less than or equal to `slice.len()`"); + } + + // We are going to have to allocate at least `amount` for the output no matter what. However, + // if we use the `cached` version we will have to allocate `amount` as a HashMap as well since + // it inserts an element for every loop. + // + // Therefore, if `amount >= length / 2` then inplace will be both faster and use less memory. + // In fact, benchmarks show the inplace version is faster for length up to about 20 times + // faster than amount. + // + // TODO: there is probably even more fine-tuning that can be done here since + // `HashMap::with_capacity(amount)` probably allocates more than `amount` in practice, + // and a trade off could probably be made between memory/cpu, since hashmap operations + // are slower than array index swapping. + if amount >= length / 20 { + sample_indices_inplace(rng, length, amount) + } else { + sample_indices_cache(rng, length, amount) + } +} + +/// Sample an amount of indices using an inplace partial fisher yates method. +/// +/// This allocates the entire `length` of indices and randomizes only the first `amount`. +/// It then truncates to `amount` and returns. +/// +/// This is better than using a `HashMap` "cache" when `amount >= length / 2` +/// since it does not require allocating an extra cache and is much faster. +fn sample_indices_inplace(rng: &mut R, length: usize, amount: usize) -> Vec + where R: Rng + ?Sized, +{ + debug_assert!(amount <= length); + let mut indices: Vec = Vec::with_capacity(length); + indices.extend(0..length); + for i in 0..amount { + let j: usize = rng.gen_range(i, length); + indices.swap(i, j); + } + indices.truncate(amount); + debug_assert_eq!(indices.len(), amount); + indices +} + + +/// This method performs a partial fisher-yates on a range of indices using a +/// `HashMap` as a cache to record potential collisions. +/// +/// The cache avoids allocating the entire `length` of values. This is especially useful when +/// `amount <<< length`, i.e. select 3 non-repeating from `1_000_000` +fn sample_indices_cache( + rng: &mut R, + length: usize, + amount: usize, +) -> Vec + where R: Rng + ?Sized, +{ + debug_assert!(amount <= length); + #[cfg(feature="std")] let mut cache = HashMap::with_capacity(amount); + #[cfg(not(feature="std"))] let mut cache = BTreeMap::new(); + let mut out = Vec::with_capacity(amount); + for i in 0..amount { + let j: usize = rng.gen_range(i, length); + + // equiv: let tmp = slice[i]; + let tmp = match cache.get(&i) { + Some(e) => *e, + None => i, + }; + + // equiv: slice[i] = slice[j]; + let x = match cache.get(&j) { + Some(x) => *x, + None => j, + }; + + // equiv: slice[j] = tmp; + cache.insert(j, tmp); + + // note that in the inplace version, slice[i] is automatically "returned" value + out.push(x); + } + debug_assert_eq!(out.len(), amount); + out +} + +#[cfg(test)] +mod test { + use super::*; + use {XorShiftRng, Rng, SeedableRng}; + #[cfg(not(feature="std"))] + use alloc::vec::Vec; + + #[test] + fn test_sample_iter() { + let min_val = 1; + let max_val = 100; + + let mut r = ::test::rng(401); + let vals = (min_val..max_val).collect::>(); + let small_sample = sample_iter(&mut r, vals.iter(), 5).unwrap(); + let large_sample = sample_iter(&mut r, vals.iter(), vals.len() + 5).unwrap_err(); + + assert_eq!(small_sample.len(), 5); + assert_eq!(large_sample.len(), vals.len()); + // no randomization happens when amount >= len + assert_eq!(large_sample, vals.iter().collect::>()); + + assert!(small_sample.iter().all(|e| { + **e >= min_val && **e <= max_val + })); + } + #[test] + fn test_sample_slice_boundaries() { + let empty: &[u8] = &[]; + + let mut r = ::test::rng(402); + + // sample 0 items + assert_eq!(&sample_slice(&mut r, empty, 0)[..], [0u8; 0]); + assert_eq!(&sample_slice(&mut r, &[42, 2, 42], 0)[..], [0u8; 0]); + + // sample 1 item + assert_eq!(&sample_slice(&mut r, &[42], 1)[..], [42]); + let v = sample_slice(&mut r, &[1, 42], 1)[0]; + assert!(v == 1 || v == 42); + + // sample "all" the items + let v = sample_slice(&mut r, &[42, 133], 2); + assert!(&v[..] == [42, 133] || v[..] == [133, 42]); + + assert_eq!(&sample_indices_inplace(&mut r, 0, 0)[..], [0usize; 0]); + assert_eq!(&sample_indices_inplace(&mut r, 1, 0)[..], [0usize; 0]); + assert_eq!(&sample_indices_inplace(&mut r, 1, 1)[..], [0]); + + assert_eq!(&sample_indices_cache(&mut r, 0, 0)[..], [0usize; 0]); + assert_eq!(&sample_indices_cache(&mut r, 1, 0)[..], [0usize; 0]); + assert_eq!(&sample_indices_cache(&mut r, 1, 1)[..], [0]); + + // Make sure lucky 777's aren't lucky + let slice = &[42, 777]; + let mut num_42 = 0; + let total = 1000; + for _ in 0..total { + let v = sample_slice(&mut r, slice, 1); + assert_eq!(v.len(), 1); + let v = v[0]; + assert!(v == 42 || v == 777); + if v == 42 { + num_42 += 1; + } + } + let ratio_42 = num_42 as f64 / 1000 as f64; + assert!(0.4 <= ratio_42 || ratio_42 <= 0.6, "{}", ratio_42); + } + + #[test] + fn test_sample_slice() { + let xor_rng = XorShiftRng::from_seed; + + let max_range = 100; + let mut r = ::test::rng(403); + + for length in 1usize..max_range { + let amount = r.gen_range(0, length); + let mut seed = [0u8; 16]; + r.fill(&mut seed); + + // assert that the two index methods give exactly the same result + let inplace = sample_indices_inplace( + &mut xor_rng(seed), length, amount); + let cache = sample_indices_cache( + &mut xor_rng(seed), length, amount); + assert_eq!(inplace, cache); + + // assert the basics work + let regular = sample_indices( + &mut xor_rng(seed), length, amount); + assert_eq!(regular.len(), amount); + assert!(regular.iter().all(|e| *e < length)); + assert_eq!(regular, inplace); + + // also test that sampling the slice works + let vec: Vec = (0..length).collect(); + { + let result = sample_slice(&mut xor_rng(seed), &vec, amount); + assert_eq!(result, regular); + } + + { + let result = sample_slice_ref(&mut xor_rng(seed), &vec, amount); + let expected = regular.iter().map(|v| v).collect::>(); + assert_eq!(result, expected); + } + } + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/tests/bool.rs b/third_party/cargo/vendor/rand-0.5.6/tests/bool.rs new file mode 100644 index 0000000..c4208a0 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/tests/bool.rs @@ -0,0 +1,23 @@ +#![no_std] + +extern crate rand; + +use rand::SeedableRng; +use rand::rngs::SmallRng; +use rand::distributions::{Distribution, Bernoulli}; + +/// This test should make sure that we don't accidentally have undefined +/// behavior for large propabilties due to +/// https://github.com/rust-lang/rust/issues/10184. +/// Expressions like `1.0*(u64::MAX as f64) as u64` have to be avoided. +#[test] +fn large_probability() { + let p = 1. - ::core::f64::EPSILON / 2.; + assert!(p < 1.); + let d = Bernoulli::new(p); + let mut rng = SmallRng::from_seed( + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + for _ in 0..10 { + assert!(d.sample(&mut rng), "extremely unlikely to fail by accident"); + } +} diff --git a/third_party/cargo/vendor/rand-0.5.6/utils/ci/install.sh b/third_party/cargo/vendor/rand-0.5.6/utils/ci/install.sh new file mode 100644 index 0000000..8e636e1 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/utils/ci/install.sh @@ -0,0 +1,49 @@ +# From https://github.com/japaric/trust + +set -ex + +main() { + local target= + if [ $TRAVIS_OS_NAME = linux ]; then + target=x86_64-unknown-linux-musl + sort=sort + else + target=x86_64-apple-darwin + sort=gsort # for `sort --sort-version`, from brew's coreutils. + fi + + # Builds for iOS are done on OSX, but require the specific target to be + # installed. + case $TARGET in + aarch64-apple-ios) + rustup target install aarch64-apple-ios + ;; + armv7-apple-ios) + rustup target install armv7-apple-ios + ;; + armv7s-apple-ios) + rustup target install armv7s-apple-ios + ;; + i386-apple-ios) + rustup target install i386-apple-ios + ;; + x86_64-apple-ios) + rustup target install x86_64-apple-ios + ;; + esac + + # This fetches latest stable release + local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \ + | cut -d/ -f3 \ + | grep -E '^v[0.1.0-9.]+$' \ + | $sort --version-sort \ + | tail -n1) + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- \ + --force \ + --git japaric/cross \ + --tag $tag \ + --target $target +} + +main diff --git a/third_party/cargo/vendor/rand-0.5.6/utils/ci/script.sh b/third_party/cargo/vendor/rand-0.5.6/utils/ci/script.sh new file mode 100644 index 0000000..21188f3 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/utils/ci/script.sh @@ -0,0 +1,29 @@ +# Derived from https://github.com/japaric/trust + +set -ex + +main() { + if [ ! -z $DISABLE_TESTS ]; then # tests are disabled + cross build --no-default-features --target $TARGET --release + if [ -z $DISABLE_STD ]; then # std is enabled + cross build --features log,serde1 --target $TARGET + fi + return + fi + + if [ ! -z $NIGHTLY ]; then # have nightly Rust + cross test --tests --no-default-features --features alloc --target $TARGET + cross test --package rand_core --no-default-features --features alloc --target $TARGET + cross test --features serde1,log,nightly,alloc --target $TARGET + cross test --all --benches --target $TARGET + else # have stable Rust + cross test --tests --no-default-features --target $TARGET + cross test --package rand_core --no-default-features --target $TARGET + cross test --features serde1,log --target $TARGET + fi +} + +# we don't run the "test phase" when doing deploys +if [ -z $TRAVIS_TAG ]; then + main +fi diff --git a/third_party/cargo/vendor/rand-0.5.6/utils/ziggurat_tables.py b/third_party/cargo/vendor/rand-0.5.6/utils/ziggurat_tables.py new file mode 100755 index 0000000..9973b83 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.5.6/utils/ziggurat_tables.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python +# +# Copyright 2013 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# https://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +# This creates the tables used for distributions implemented using the +# ziggurat algorithm in `rand::distributions;`. They are +# (basically) the tables as used in the ZIGNOR variant (Doornik 2005). +# They are changed rarely, so the generated file should be checked in +# to git. +# +# It creates 3 tables: X as in the paper, F which is f(x_i), and +# F_DIFF which is f(x_i) - f(x_{i-1}). The latter two are just cached +# values which is not done in that paper (but is done in other +# variants). Note that the adZigR table is unnecessary because of +# algebra. +# +# It is designed to be compatible with Python 2 and 3. + +from math import exp, sqrt, log, floor +import random + +# The order should match the return value of `tables` +TABLE_NAMES = ['X', 'F'] + +# The actual length of the table is 1 more, to stop +# index-out-of-bounds errors. This should match the bitwise operation +# to find `i` in `zigurrat` in `libstd/rand/mod.rs`. Also the *_R and +# *_V constants below depend on this value. +TABLE_LEN = 256 + +# equivalent to `zigNorInit` in Doornik2005, but generalised to any +# distribution. r = dR, v = dV, f = probability density function, +# f_inv = inverse of f +def tables(r, v, f, f_inv): + # compute the x_i + xvec = [0]*(TABLE_LEN+1) + + xvec[0] = v / f(r) + xvec[1] = r + + for i in range(2, TABLE_LEN): + last = xvec[i-1] + xvec[i] = f_inv(v / last + f(last)) + + # cache the f's + fvec = [0]*(TABLE_LEN+1) + for i in range(TABLE_LEN+1): + fvec[i] = f(xvec[i]) + + return xvec, fvec + +# Distributions +# N(0, 1) +def norm_f(x): + return exp(-x*x/2.0) +def norm_f_inv(y): + return sqrt(-2.0*log(y)) + +NORM_R = 3.6541528853610088 +NORM_V = 0.00492867323399 + +NORM = tables(NORM_R, NORM_V, + norm_f, norm_f_inv) + +# Exp(1) +def exp_f(x): + return exp(-x) +def exp_f_inv(y): + return -log(y) + +EXP_R = 7.69711747013104972 +EXP_V = 0.0039496598225815571993 + +EXP = tables(EXP_R, EXP_V, + exp_f, exp_f_inv) + + +# Output the tables/constants/types + +def render_static(name, type, value): + # no space or + return 'pub static %s: %s =%s;\n' % (name, type, value) + +# static `name`: [`type`, .. `len(values)`] = +# [values[0], ..., values[3], +# values[4], ..., values[7], +# ... ]; +def render_table(name, values): + rows = [] + # 4 values on each row + for i in range(0, len(values), 4): + row = values[i:i+4] + rows.append(', '.join('%.18f' % f for f in row)) + + rendered = '\n [%s]' % ',\n '.join(rows) + return render_static(name, '[f64, .. %d]' % len(values), rendered) + + +with open('ziggurat_tables.rs', 'w') as f: + f.write('''// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// https://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tables for distributions which are sampled using the ziggurat +// algorithm. Autogenerated by `ziggurat_tables.py`. + +pub type ZigTable = &\'static [f64, .. %d]; +''' % (TABLE_LEN + 1)) + for name, tables, r in [('NORM', NORM, NORM_R), + ('EXP', EXP, EXP_R)]: + f.write(render_static('ZIG_%s_R' % name, 'f64', ' %.18f' % r)) + for (tabname, table) in zip(TABLE_NAMES, tables): + f.write(render_table('ZIG_%s_%s' % (name, tabname), table)) diff --git a/third_party/cargo/vendor/rand-0.6.5/.cargo-checksum.json b/third_party/cargo/vendor/rand-0.6.5/.cargo-checksum.json new file mode 100644 index 0000000..875021e --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"ddc101ef9368ef83c21ea9e43064307b1c59b0698b78f59ea01cba32c0ef55bf","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"54c97aa3fc80f7482358b32df3fb96dbd63a4b52fb7f2eb06f1707cda7d15f09","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"d442009fc242a0670f6e7a418862c67514e2c544a43c88b24cb7f37695b8ae38","benches/distributions.rs":"fea4337cd3eb6eaa7bb3250bb04b084290a2b081d3f4679510f3e1dab9c9506b","benches/generators.rs":"19286f1022041bca7e9f83ff615534397565246d5cd26c53abcaeaebebad6773","benches/misc.rs":"c0302e0d9ab973ba4463506d90f89f903104b2a42fc11247be2056a2e1cb561f","benches/seq.rs":"188043fe02640c3936da7634517d0bc0bbdbf685739c52d2ec51a95f238aa347","build.rs":"00d4e7d3521f631913001cfaeb5c97f9dab8b550346046deb2683b962a99e9b3","examples/monte-carlo.rs":"2161c9c1ed90af6b72a5b05b6650d5fce6a983873c29c99798957099cd7a5153","examples/monty-hall.rs":"6a1921868c41d4c130a6b098632f2c127d2446ac6a73aeea10b79b845df1cbbc","src/deprecated.rs":"da2a39dfc440a09bdcdf5af93842dce0fbbc179e5e7146dc94ea861c244bf4c5","src/distributions/bernoulli.rs":"02526bdc24fe17f390505779fb38a441c6a1792c1f7e6093d8b86e143bf9e07e","src/distributions/binomial.rs":"5e2cd6ebc0a5411a4af26ff07d05dd30ae91fc47852cd29757b370ce496074b6","src/distributions/cauchy.rs":"b49d4abd1d861e9f9e9a27444680ea0e24779a6a263dce07c400cf43bab9363c","src/distributions/dirichlet.rs":"b6c0273216a05d32ab21320c11f46f80bc6a6173c93f7aa63fd397927fa365fb","src/distributions/exponential.rs":"7e8a98b63a271714c1f982dd15bc21626593691eaa92c7a76bd59af7b37a56a2","src/distributions/float.rs":"6e1e15b47f9efd282a0e7d140c141d35ece4ebbb748ce7ead620782dc492e88f","src/distributions/gamma.rs":"c922a1b7b2f20ee5a7f5241a252b8b947ab998a88a747df488380211b865f9a6","src/distributions/integer.rs":"b615123a814b118f8bc0563cd7615eec7ee171223bf8100416fb7d22e350c8d7","src/distributions/mod.rs":"6824a6a461d84aef22646d6c3ac8af5d2b5dfc90f09d537be2112fde98a9a8ea","src/distributions/normal.rs":"fe5df9d00ff4038ef6e1f6ca22971547aaec57887c700a511806da01bb4a2f17","src/distributions/other.rs":"44abe480bdc2000ca91a9d41c04e3d5fff2b08e81dfc9168d82c90ddc5cbf616","src/distributions/pareto.rs":"8a9d0f6a7b7221c5716f92b4b65dc19954c146eaeeddcc0b9533d01e2b7414ff","src/distributions/poisson.rs":"918f36d9f7b6c9c4a249b49138cf4df5e1498dd894e3856c21d2f82b83d33e53","src/distributions/triangular.rs":"5a3927b4f1306686591c6d6f3df01d774a5dbf9ec2450ee2f3ce6a71b54f744d","src/distributions/uniform.rs":"9536012592e978cda4e72cd936f21b9986704468de531fbe873f25f763afa4da","src/distributions/unit_circle.rs":"007815186a3696a3d835e9004f51e52402557a7cda09219a0ade13122578e1bd","src/distributions/unit_sphere.rs":"24b8dea60bee580378713477235ddac5e8da07e4f9ceb610fe655ec82390abaf","src/distributions/utils.rs":"68a8257290fdbbd1e72c77e55f21aab4420c6ff168ffb82f7cabc3ad815f4803","src/distributions/weibull.rs":"7678c47145bbb8455fb34326e59d05c2564d427b9c13d5d32435119fd37b5eeb","src/distributions/weighted.rs":"2c98d09ed15d204687efce857129742f905e50e96ba0518122a742f3b47753df","src/distributions/ziggurat_tables.rs":"6368acec20801c703ae76dd1e08983793732c5ac221c491f85d719ef75448b6d","src/lib.rs":"5a7c48d633e75c6d9f2598651ac7b754b3b34fec4212bdc50358a0abbc4ffc62","src/prelude.rs":"36f87f720c1ce0c9d0041872b0498e016b5578b96ba4f6152765ac5084d3b5da","src/prng/mod.rs":"e38182ca652acd0f9348e70e6896e2143b11e9cdcdb34fc78ad13b150dbd7da9","src/rngs/adapter/mod.rs":"e8f37aed72eaebc7dff20787f194e3a74da3e824e2b92a6839b7e6f01fcd911c","src/rngs/adapter/read.rs":"f9502c774607b5c3e62b87ea58698db258486b7c0dbb9b01559e3c18b468bb34","src/rngs/adapter/reseeding.rs":"0ce93bd0f00da429459bca7081346bddea85735bf2d617bcde92708907016a0d","src/rngs/entropy.rs":"cd89359f7891e955245279e4848c37733c508a8cf126eee34f2361a228014f4e","src/rngs/mock.rs":"ef812949b98e4f2eea3e62f8b3ee56edaeffc99d17625337efc882b7b2b19f4b","src/rngs/mod.rs":"440870d8066f1fbeb5d3b178bbf62d899f565d3cbc99c9b179ae4bca81b45a4f","src/rngs/small.rs":"eb942851fe2c2ce11eb0fe179efdfe2889dfc9bc72398bddbdfa327882935dd9","src/rngs/std.rs":"8420c2c32f312b2400ed23afdd9019632c2dd61bb5bd935d6d73bacbcbb9a5b2","src/rngs/thread.rs":"82ef4cf043d16d1d3e6f0037b269f817b133833240f866cd8a7b6e82d3c279ff","src/seq/index.rs":"384500a66361d21531db1380474066fa0bafb672ff7c9db00208b30a94664511","src/seq/mod.rs":"5a9938dc2ac75f393b54267abced2c5f7fbba4ffbdeb6ecdc80afe618c28fea6","tests/uniformity.rs":"0b774361f7db445bd910ad2cbac71207d01ace6881b8d501f4ff01bffd16cd68"},"package":"6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand-0.6.5/BUILD b/third_party/cargo/vendor/rand-0.6.5/BUILD new file mode 100644 index 0000000..1d82c58 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/BUILD @@ -0,0 +1,65 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted +# Unsupported target "distributions" with type "bench" omitted +# Unsupported target "generators" with type "bench" omitted +# Unsupported target "misc" with type "bench" omitted +# Unsupported target "monte-carlo" with type "example" omitted +# Unsupported target "monty-hall" with type "example" omitted + +rust_library( + name = "rand", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/rand_chacha-0.1.1:rand_chacha", + "//third_party/cargo/vendor/rand_core-0.4.2:rand_core", + "//third_party/cargo/vendor/rand_hc-0.1.0:rand_hc", + "//third_party/cargo/vendor/rand_isaac-0.1.1:rand_isaac", + "//third_party/cargo/vendor/rand_jitter-0.1.4:rand_jitter", + "//third_party/cargo/vendor/rand_os-0.1.3:rand_os", + "//third_party/cargo/vendor/rand_pcg-0.1.2:rand_pcg", + "//third_party/cargo/vendor/rand_xorshift-0.1.1:rand_xorshift", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.5", + crate_features = [ + "alloc", + "default", + "rand_core", + "rand_jitter", + "rand_os", + "std", + ], +) + +# Unsupported target "seq" with type "bench" omitted +# Unsupported target "uniformity" with type "test" omitted diff --git a/third_party/cargo/vendor/rand-0.6.5/CHANGELOG.md b/third_party/cargo/vendor/rand-0.6.5/CHANGELOG.md new file mode 100644 index 0000000..955e872 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/CHANGELOG.md @@ -0,0 +1,522 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md). + +You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful. + + +## [0.6.5] - 2019-01-28 +### Crates +- Update `rand_core` to 0.4 (#703) +- Move `JitterRng` to its own crate (#685) +- Add a warm-bindgen test crate (#696) + +### Platforms +- Fuchsia: Replaced fuchsia-zircon with fuchsia-cprng + +### Doc +- Use RFC 1946 for doc links (#691) +- Fix some doc links and notes (#711) + +## [0.6.4] - 2019-01-08 +### Fixes +- Move wasm-bindgen shims to correct crate (#686) +- Make `wasm32-unknown-unknown` compile but fail at run-time if missing bindingsg (#686) + +## [0.6.3] - 2019-01-04 +### Fixes +- Make the `std` feature require the optional `rand_os` dependency (#675) +- Re-export the optional WASM dependencies of `rand_os` from `rand` to avoid breakage (#674) + +## [0.6.2] - 2019-01-04 +### Additions +- Add `Default` for `ThreadRng` (#657) +- Move `rngs::OsRng` to `rand_os` sub-crate; clean up code; use as dependency (#643) ##BLOCKER## +- Add `rand_xoshiro` sub-crate, plus benchmarks (#642, #668) + +### Fixes +- Fix bias in `UniformInt::sample_single` (#662) +- Use `autocfg` instead of `rustc_version` for rustc version detection (#664) +- Disable `i128` and `u128` if the `target_os` is `emscripten` (#671: work-around Emscripten limitation) +- CI fixes (#660, #671) + +### Optimisations +- Optimise memory usage of `UnitCircle` and `UnitSphereSurface` distributions (no PR) + +## [0.6.1] - 2018-11-22 +- Support sampling `Duration` also for `no_std` (only since Rust 1.25) (#649) +- Disable default features of `libc` (#647) + +## [0.6.0] - 2018-11-14 + +### Project organisation +- Rand has moved from [rust-lang-nursery](https://github.com/rust-lang-nursery/rand) + to [rust-random](https://github.com/rust-random/rand)! (#578) +- Created [The Rust Random Book](https://rust-random.github.io/book/) + ([source](https://github.com/rust-random/book)) +- Update copyright and licence notices (#591, #611) +- Migrate policy documentation from the wiki (#544) + +### Platforms +- Add fork protection on Unix (#466) +- Added support for wasm-bindgen. (#541, #559, #562, #600) +- Enable `OsRng` for powerpc64, sparc and sparc64 (#609) +- Use `syscall` from `libc` on Linux instead of redefining it (#629) + +### RNGs +- Switch `SmallRng` to use PCG (#623) +- Implement `Pcg32` and `Pcg64Mcg` generators (#632) +- Move ISAAC RNGs to a dedicated crate (#551) +- Move Xorshift RNG to its own crate (#557) +- Move ChaCha and HC128 RNGs to dedicated crates (#607, #636) +- Remove usage of `Rc` from `ThreadRng` (#615) + +### Sampling and distributions +- Implement `Rng.gen_ratio()` and `Bernoulli::new_ratio()` (#491) +- Make `Uniform` strictly respect `f32` / `f64` high/low bounds (#477) +- Allow `gen_range` and `Uniform` to work on non-`Copy` types (#506) +- `Uniform` supports inclusive ranges: `Uniform::from(a..=b)`. This is + automatically enabled for Rust >= 1.27. (#566) +- Implement `TrustedLen` and `FusedIterator` for `DistIter` (#620) + +#### New distributions +- Add the `Dirichlet` distribution (#485) +- Added sampling from the unit sphere and circle. (#567) +- Implement the triangular distribution (#575) +- Implement the Weibull distribution (#576) +- Implement the Beta distribution (#574) + +#### Optimisations + +- Optimise `Bernoulli::new` (#500) +- Optimise `char` sampling (#519) +- Optimise sampling of `std::time::Duration` (#583) + +### Sequences +- Redesign the `seq` module (#483, #515) +- Add `WeightedIndex` and `choose_weighted` (#518, #547) +- Optimised and changed return type of the `sample_indices` function. (#479) +- Use `Iterator::size_hint()` to speed up `IteratorRandom::choose` (#593) + +### SIMD +- Support for generating SIMD types (#523, #542, #561, #630) + +### Other +- Revise CI scripts (#632, #635) +- Remove functionality already deprecated in 0.5 (#499) +- Support for `i128` and `u128` is automatically enabled for Rust >= 1.26. This + renders the `i128_support` feature obsolete. It still exists for backwards + compatibility but does not have any effect. This breaks programs using Rand + with `i128_support` on nightlies older than Rust 1.26. (#571) + + +## [0.5.5] - 2018-08-07 +### Documentation +- Fix links in documentation (#582) + + +## [0.5.4] - 2018-07-11 +### Platform support +- Make `OsRng` work via WASM/stdweb for WebWorkers + + +## [0.5.3] - 2018-06-26 +### Platform support +- OpenBSD, Bitrig: fix compilation (broken in 0.5.1) (#530) + + +## [0.5.2] - 2018-06-18 +### Platform support +- Hide `OsRng` and `JitterRng` on unsupported platforms (#512; fixes #503). + + +## [0.5.1] - 2018-06-08 + +### New distributions +- Added Cauchy distribution. (#474, #486) +- Added Pareto distribution. (#495) + +### Platform support and `OsRng` +- Remove blanket Unix implementation. (#484) +- Remove Wasm unimplemented stub. (#484) +- Dragonfly BSD: read from `/dev/random`. (#484) +- Bitrig: use `getentropy` like OpenBSD. (#484) +- Solaris: (untested) use `getrandom` if available, otherwise `/dev/random`. (#484) +- Emscripten, `stdweb`: split the read up in chunks. (#484) +- Emscripten, Haiku: don't do an extra blocking read from `/dev/random`. (#484) +- Linux, NetBSD, Solaris: read in blocking mode on first use in `fill_bytes`. (#484) +- Fuchsia, CloudABI: fix compilation (broken in Rand 0.5). (#484) + + +## [0.5.0] - 2018-05-21 + +### Crate features and organisation +- Minimum Rust version update: 1.22.0. (#239) +- Create a separate `rand_core` crate. (#288) +- Deprecate `rand_derive`. (#256) +- Add `prelude` (and module reorganisation). (#435) +- Add `log` feature. Logging is now available in `JitterRng`, `OsRng`, `EntropyRng` and `ReseedingRng`. (#246) +- Add `serde1` feature for some PRNGs. (#189) +- `stdweb` feature for `OsRng` support on WASM via stdweb. (#272, #336) + +### `Rng` trait +- Split `Rng` in `RngCore` and `Rng` extension trait. + `next_u32`, `next_u64` and `fill_bytes` are now part of `RngCore`. (#265) +- Add `Rng::sample`. (#256) +- Deprecate `Rng::gen_weighted_bool`. (#308) +- Add `Rng::gen_bool`. (#308) +- Remove `Rng::next_f32` and `Rng::next_f64`. (#273) +- Add optimized `Rng::fill` and `Rng::try_fill` methods. (#247) +- Deprecate `Rng::gen_iter`. (#286) +- Deprecate `Rng::gen_ascii_chars`. (#279) + +### `rand_core` crate +- `rand` now depends on new `rand_core` crate (#288) +- `RngCore` and `SeedableRng` are now part of `rand_core`. (#288) +- Add modules to help implementing RNGs `impl` and `le`. (#209, #228) +- Add `Error` and `ErrorKind`. (#225) +- Add `CryptoRng` marker trait. (#273) +- Add `BlockRngCore` trait. (#281) +- Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325) +- Revise the `SeedableRng` trait. (#233) +- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288) +- Add `RngCore::try_fill_bytes`. (#225) + +### Other traits and types +- Add `FromEntropy` trait. (#233, #375) +- Add `SmallRng` wrapper. (#296) +- Rewrite `ReseedingRng` to only work with `BlockRngCore` (substantial performance improvement). (#281) +- Deprecate `weak_rng`. Use `SmallRng` instead. (#296) +- Deprecate `AsciiGenerator`. (#279) + +### Random number generators +- Switch `StdRng` and `thread_rng` to HC-128. (#277) +- `StdRng` must now be created with `from_entropy` instead of `new` +- Change `thread_rng` reseeding threshold to 32 MiB. (#277) +- PRNGs no longer implement `Copy`. (#209) +- `Debug` implementations no longer show internals. (#209) +- Implement `Clone` for `ReseedingRng`, `JitterRng`, OsRng`. (#383, #384) +- Implement serialization for `XorShiftRng`, `IsaacRng` and `Isaac64Rng` under the `serde1` feature. (#189) +- Implement `BlockRngCore` for `ChaChaCore` and `Hc128Core`. (#281) +- All PRNGs are now portable across big- and little-endian architectures. (#209) +- `Isaac64Rng::next_u32` no longer throws away half the results. (#209) +- Add `IsaacRng::new_from_u64` and `Isaac64Rng::new_from_u64`. (#209) +- Add the HC-128 CSPRNG `Hc128Rng`. (#210) +- Change ChaCha20 to have 64-bit counter and 64-bit stream. (#349) +- Changes to `JitterRng` to get its size down from 2112 to 24 bytes. (#251) +- Various performance improvements to all PRNGs. + +### Platform support and `OsRng` +- Add support for CloudABI. (#224) +- Remove support for NaCl. (#225) +- WASM support for `OsRng` via stdweb, behind the `stdweb` feature. (#272, #336) +- Use `getrandom` on more platforms for Linux, and on Android. (#338) +- Use the `SecRandomCopyBytes` interface on macOS. (#322) +- On systems that do not have a syscall interface, only keep a single file descriptor open for `OsRng`. (#239) +- On Unix, first try a single read from `/dev/random`, then `/dev/urandom`. (#338) +- Better error handling and reporting in `OsRng` (using new error type). (#225) +- `OsRng` now uses non-blocking when available. (#225) +- Add `EntropyRng`, which provides `OsRng`, but has `JitterRng` as a fallback. (#235) + +### Distributions +- New `Distribution` trait. (#256) +- Add `Distribution::sample_iter` and `Rng::::sample_iter`. (#361) +- Deprecate `Rand`, `Sample` and `IndependentSample` traits. (#256) +- Add a `Standard` distribution (replaces most `Rand` implementations). (#256) +- Add `Binomial` and `Poisson` distributions. (#96) +- Add `Bernoulli` dsitribution. (#411) +- Add `Alphanumeric` distribution. (#279) +- Remove `Closed01` distribution, add `OpenClosed01`. (#274, #420) +- Rework `Range` type, making it possible to implement it for user types. (#274) +- Rename `Range` to `Uniform`. (#395) +- Add `Uniform::new_inclusive` for inclusive ranges. (#274) +- Use widening multiply method for much faster integer range reduction. (#274) +- `Standard` distribution for `char` uses `Uniform` internally. (#274) +- `Standard` distribution for `bool` uses sign test. (#274) +- Implement `Standard` distribution for `Wrapping`. (#436) +- Implement `Uniform` distribution for `Duration`. (#427) + + +## [0.4.3] - 2018-08-16 +### Fixed +- Use correct syscall number for PowerPC (#589) + + +## [0.4.2] - 2018-01-06 +### Changed +- Use `winapi` on Windows +- Update for Fuchsia OS +- Remove dev-dependency on `log` + + +## [0.4.1] - 2017-12-17 +### Added +- `no_std` support + + +## [0.4.0-pre.0] - 2017-12-11 +### Added +- `JitterRng` added as a high-quality alternative entropy source using the + system timer +- new `seq` module with `sample_iter`, `sample_slice`, etc. +- WASM support via dummy implementations (fail at run-time) +- Additional benchmarks, covering generators and new seq code + +### Changed +- `thread_rng` uses `JitterRng` if seeding from system time fails + (slower but more secure than previous method) + +### Deprecated + - `sample` function deprecated (replaced by `sample_iter`) + + +## [0.3.20] - 2018-01-06 +### Changed +- Remove dev-dependency on `log` +- Update `fuchsia-zircon` dependency to 0.3.2 + + +## [0.3.19] - 2017-12-27 +### Changed +- Require `log <= 0.3.8` for dev builds +- Update `fuchsia-zircon` dependency to 0.3 +- Fix broken links in docs (to unblock compiler docs testing CI) + + +## [0.3.18] - 2017-11-06 +### Changed +- `thread_rng` is seeded from the system time if `OsRng` fails +- `weak_rng` now uses `thread_rng` internally + + +## [0.3.17] - 2017-10-07 +### Changed + - Fuchsia: Magenta was renamed Zircon + +## [0.3.16] - 2017-07-27 +### Added +- Implement Debug for mote non-public types +- implement `Rand` for (i|u)i128 +- Support for Fuchsia + +### Changed +- Add inline attribute to SampleRange::construct_range. + This improves the benchmark for sample in 11% and for shuffle in 16%. +- Use `RtlGenRandom` instead of `CryptGenRandom` + + +## [0.3.15] - 2016-11-26 +### Added +- Add `Rng` trait method `choose_mut` +- Redox support + +### Changed +- Use `arc4rand` for `OsRng` on FreeBSD. +- Use `arc4random(3)` for `OsRng` on OpenBSD. + +### Fixed +- Fix filling buffers 4 GiB or larger with `OsRng::fill_bytes` on Windows + + +## [0.3.14] - 2016-02-13 +### Fixed +- Inline definitions from winapi/advapi32, wich decreases build times + + +## [0.3.13] - 2016-01-09 +### Fixed +- Compatible with Rust 1.7.0-nightly (needed some extra type annotations) + + +## [0.3.12] - 2015-11-09 +### Changed +- Replaced the methods in `next_f32` and `next_f64` with the technique described + Saito & Matsumoto at MCQMC'08. The new method should exhibit a slightly more + uniform distribution. +- Depend on libc 0.2 + +### Fixed +- Fix iterator protocol issue in `rand::sample` + + +## [0.3.11] - 2015-08-31 +### Added +- Implement `Rand` for arrays with n <= 32 + + +## [0.3.10] - 2015-08-17 +### Added +- Support for NaCl platforms + +### Changed +- Allow `Rng` to be `?Sized`, impl for `&mut R` and `Box` where `R: ?Sized + Rng` + + +## [0.3.9] - 2015-06-18 +### Changed +- Use `winapi` for Windows API things + +### Fixed +- Fixed test on stable/nightly +- Fix `getrandom` syscall number for aarch64-unknown-linux-gnu + + +## [0.3.8] - 2015-04-23 +### Changed +- `log` is a dev dependency + +### Fixed +- Fix race condition of atomics in `is_getrandom_available` + + +## [0.3.7] - 2015-04-03 +### Fixed +- Derive Copy/Clone changes + + +## [0.3.6] - 2015-04-02 +### Changed +- Move to stable Rust! + + +## [0.3.5] - 2015-04-01 +### Fixed +- Compatible with Rust master + + +## [0.3.4] - 2015-03-31 +### Added +- Implement Clone for `Weighted` + +### Fixed +- Compatible with Rust master + + +## [0.3.3] - 2015-03-26 +### Fixed +- Fix compile on Windows + + +## [0.3.2] - 2015-03-26 + + +## [0.3.1] - 2015-03-26 +### Fixed +- Fix compile on Windows + + +## [0.3.0] - 2015-03-25 +### Changed +- Update to use log version 0.3.x + + +## [0.2.1] - 2015-03-22 +### Fixed +- Compatible with Rust master +- Fixed iOS compilation + + +## [0.2.0] - 2015-03-06 +### Fixed +- Compatible with Rust master (move from `old_io` to `std::io`) + + +## [0.1.4] - 2015-03-04 +### Fixed +- Compatible with Rust master (use wrapping ops) + + +## [0.1.3] - 2015-02-20 +### Fixed +- Compatible with Rust master + +### Removed +- Removed Copy implementations from RNGs + + +## [0.1.2] - 2015-02-03 +### Added +- Imported functionality from `std::rand`, including: + - `StdRng`, `SeedableRng`, `TreadRng`, `weak_rng()` + - `ReaderRng`: A wrapper around any Reader to treat it as an RNG. +- Imported documentation from `std::rand` +- Imported tests from `std::rand` + + +## [0.1.1] - 2015-02-03 +### Added +- Migrate to a cargo-compatible directory structure. + +### Fixed +- Do not use entropy during `gen_weighted_bool(1)` + + +## [Rust 0.12.0] - 2014-10-09 +### Added +- Impl Rand for tuples of arity 11 and 12 +- Include ChaCha pseudorandom generator +- Add `next_f64` and `next_f32` to Rng +- Implement Clone for PRNGs + +### Changed +- Rename `TaskRng` to `ThreadRng` and `task_rng` to `thread_rng` (since a + runtime is removed from Rust). + +### Fixed +- Improved performance of ISAAC and ISAAC64 by 30% and 12 % respectively, by + informing the optimiser that indexing is never out-of-bounds. + +### Removed +- Removed the Deprecated `choose_option` + + +## [Rust 0.11.0] - 2014-07-02 +### Added +- document when to use `OSRng` in cryptographic context, and explain why we use `/dev/urandom` instead of `/dev/random` +- `Rng::gen_iter()` which will return an infinite stream of random values +- `Rng::gen_ascii_chars()` which will return an infinite stream of random ascii characters + +### Changed +- Now only depends on libcore! +- Remove `Rng.choose()`, rename `Rng.choose_option()` to `.choose()` +- Rename OSRng to OsRng +- The WeightedChoice structure is no longer built with a `Vec>`, + but rather a `&mut [Weighted]`. This means that the WeightedChoice + structure now has a lifetime associated with it. +- The `sample` method on `Rng` has been moved to a top-level function in the + `rand` module due to its dependence on `Vec`. + +### Removed +- `Rng::gen_vec()` was removed. Previous behavior can be regained with + `rng.gen_iter().take(n).collect()` +- `Rng::gen_ascii_str()` was removed. Previous behavior can be regained with + `rng.gen_ascii_chars().take(n).collect()` +- {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all + relied on being able to use an OSRng for seeding, but this is no longer + available in librand (where these types are defined). To retain the same + functionality, these types now implement the `Rand` trait so they can be + generated with a random seed from another random number generator. This allows + the stdlib to use an OSRng to create seeded instances of these RNGs. +- Rand implementations for `Box` and `@T` were removed. These seemed to be + pretty rare in the codebase, and it allows for librand to not depend on + liballoc. Additionally, other pointer types like Rc and Arc were not + supported. +- Remove a slew of old deprecated functions + + +## [Rust 0.10] - 2014-04-03 +### Changed +- replace `Rng.shuffle's` functionality with `.shuffle_mut` +- bubble up IO errors when creating an OSRng + +### Fixed +- Use `fill()` instead of `read()` +- Rewrite OsRng in Rust for windows + +## [0.10-pre] - 2014-03-02 +### Added +- Seperate `rand` out of the standard library diff --git a/third_party/cargo/vendor/rand-0.6.5/COPYRIGHT b/third_party/cargo/vendor/rand-0.6.5/COPYRIGHT new file mode 100644 index 0000000..468d907 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/COPYRIGHT @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff --git a/third_party/cargo/vendor/rand-0.6.5/Cargo.toml b/third_party/cargo/vendor/rand-0.6.5/Cargo.toml new file mode 100644 index 0000000..fc0313a --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/Cargo.toml @@ -0,0 +1,90 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand" +version = "0.6.5" +authors = ["The Rand Project Developers", "The Rust Project Developers"] +build = "build.rs" +exclude = ["/utils/*", "/.travis.yml", "/appveyor.yml", ".gitignore"] +description = "Random number generators and other randomness functionality.\n" +homepage = "https://crates.io/crates/rand" +documentation = "https://rust-random.github.io/rand" +readme = "README.md" +keywords = ["random", "rng"] +categories = ["algorithms", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-random/rand" +[package.metadata.docs.rs] +all-features = true +[dependencies.log] +version = "0.4" +optional = true + +[dependencies.packed_simd] +version = "0.3" +features = ["into_bits"] +optional = true + +[dependencies.rand_chacha] +version = "0.1" + +[dependencies.rand_core] +version = "0.4" + +[dependencies.rand_hc] +version = "0.1" + +[dependencies.rand_isaac] +version = "0.1" + +[dependencies.rand_jitter] +version = "0.1" + +[dependencies.rand_os] +version = "0.1" +optional = true + +[dependencies.rand_pcg] +version = "0.1" + +[dependencies.rand_xorshift] +version = "0.1" +[dev-dependencies.average] +version = "0.9.2" + +[dev-dependencies.rand_xoshiro] +version = "0.1" +[build-dependencies.autocfg] +version = "0.1" + +[features] +alloc = ["rand_core/alloc"] +default = ["std"] +i128_support = [] +nightly = ["simd_support"] +serde1 = ["rand_core/serde1", "rand_isaac/serde1", "rand_xorshift/serde1"] +simd_support = ["packed_simd"] +std = ["rand_core/std", "alloc", "rand_os", "rand_jitter/std"] +stdweb = ["rand_os/stdweb"] +wasm-bindgen = ["rand_os/wasm-bindgen"] +[target."cfg(unix)".dependencies.libc] +version = "0.2" +default-features = false +[target."cfg(windows)".dependencies.winapi] +version = "0.3" +features = ["minwindef", "ntsecapi", "profileapi", "winnt"] +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff --git a/third_party/cargo/vendor/rand-0.6.5/LICENSE-APACHE b/third_party/cargo/vendor/rand-0.6.5/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand-0.6.5/LICENSE-MIT b/third_party/cargo/vendor/rand-0.6.5/LICENSE-MIT new file mode 100644 index 0000000..d93b5ba --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright 2018 Developers of the Rand project +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand-0.6.5/README.md b/third_party/cargo/vendor/rand-0.6.5/README.md new file mode 100644 index 0000000..314a57f --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/README.md @@ -0,0 +1,122 @@ +# Rand + +[![Build Status](https://travis-ci.org/rust-random/rand.svg?branch=master)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Crate](https://img.shields.io/crates/v/rand.svg)](https://crates.io/crates/rand) +[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand) +[![API](https://docs.rs/rand/badge.svg)](https://docs.rs/rand) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) + +A Rust library for random number generation. + +Rand provides utilities to generate random numbers, to convert them to useful +types and distributions, and some randomness-related algorithms. + +The core random number generation traits of Rand live in the [rand_core]( +https://crates.io/crates/rand_core) crate but are also exposed here; RNG +implementations should prefer to use `rand_core` while most other users should +depend on `rand`. + +Documentation: +- [The Rust Rand Book](https://rust-random.github.io/book) +- [API reference (master)](https://rust-random.github.io/rand) +- [API reference (docs.rs)](https://docs.rs/rand) + + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +rand = "0.6" +``` + +To get started using Rand, see [The Book](https://rust-random.github.io/book). + + +## Versions + +The Rand lib is not yet stable, however we are careful to limit breaking changes +and warn via deprecation wherever possible. Patch versions never introduce +breaking changes. The following minor versions are supported: + +- Version 0.6 was released in November 2018, redesigning the `seq` module, + moving most PRNGs to external crates, and many small changes. +- Version 0.5 was released in May 2018, as a major reorganisation + (introducing `RngCore` and `rand_core`, and deprecating `Rand` and the + previous distribution traits). +- Version 0.4 was released in December 2017, but contained almost no breaking + changes from the 0.3 series. + +A detailed [changelog](CHANGELOG.md) is available. + +When upgrading to the next minor series (especially 0.4 → 0.5), we recommend +reading the [Upgrade Guide](https://rust-random.github.io/book/update.html). + +### Rust version requirements + +Since version 0.5, Rand requires **Rustc version 1.22 or greater**. +Rand 0.4 and 0.3 (since approx. June 2017) require Rustc version 1.15 or +greater. Subsets of the Rand code may work with older Rust versions, but this +is not supported. + +Travis CI always has a build with a pinned version of Rustc matching the oldest +supported Rust release. The current policy is that this can be updated in any +Rand release if required, but the change must be noted in the changelog. + +To avoid bumping the required version unnecessarily, we use a `build.rs` script +to auto-detect the compiler version and enable certain features or change code +paths automatically. Since this makes it easy to unintentionally make use of +features requiring a more recent Rust version, we recommend testing with a +pinned version of Rustc if you require compatibility with a specific version. + +## Crate Features + +Rand is built with the `std` and `rand_os` features enabled by default: + +- `std` enables functionality dependent on the `std` lib and implies `alloc` + and `rand_os` +- `rand_os` enables the `rand_os` crate, `rngs::OsRng` and enables its usage; + the continued existance of this feature is not guaranteed so users are + encouraged to specify `std` instead + +The following optional features are available: + +- `alloc` can be used instead of `std` to provide `Vec` and `Box`. +- `log` enables some logging via the `log` crate. +- `nightly` enables all unstable features (`simd_support`). +- `serde1` enables serialization for some types, via Serde version 1. +- `simd_support` enables uniform sampling of SIMD types (integers and floats). +- `stdweb` enables support for `OsRng` on `wasm32-unknown-unknown` via `stdweb` + combined with `cargo-web`. +- `wasm-bindgen` enables support for `OsRng` on `wasm32-unknown-unknown` via + [`wasm-bindgen`] + +[`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen + +`no_std` mode is activated by setting `default-features = false`; this removes +functionality depending on `std`: + +- `thread_rng()`, and `random()` are not available, as they require thread-local + storage and an entropy source. +- `OsRng` and `EntropyRng` are unavailable. +- `JitterRng` code is still present, but a nanosecond timer must be provided via + `JitterRng::new_with_timer` +- Since no external entropy is available, it is not possible to create + generators with fresh seeds using the `FromEntropy` trait (user must provide + a seed). +- Several non-linear distributions distributions are unavailable since `exp` + and `log` functions are not provided in `core`. +- Large parts of the `seq`-uence module are unavailable, unless the `alloc` + feature is used (several APIs and many implementations require `Vec`). + + +# License + +Rand is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/third_party/cargo/vendor/rand-0.6.5/benches/distributions.rs b/third_party/cargo/vendor/rand-0.6.5/benches/distributions.rs new file mode 100644 index 0000000..069a828 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/benches/distributions.rs @@ -0,0 +1,259 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(test)] + +extern crate test; +extern crate rand; + +const RAND_BENCH_N: u64 = 1000; + +use std::mem::size_of; +use test::Bencher; +use std::time::Duration; + +use rand::{Rng, FromEntropy}; +use rand::rngs::SmallRng; +use rand::distributions::*; + +macro_rules! distr_int { + ($fnn:ident, $ty:ty, $distr:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = SmallRng::from_entropy(); + let distr = $distr; + + b.iter(|| { + let mut accum = 0 as $ty; + for _ in 0..::RAND_BENCH_N { + let x: $ty = distr.sample(&mut rng); + accum = accum.wrapping_add(x); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N; + } + } +} + +macro_rules! distr_float { + ($fnn:ident, $ty:ty, $distr:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = SmallRng::from_entropy(); + let distr = $distr; + + b.iter(|| { + let mut accum = 0.0; + for _ in 0..::RAND_BENCH_N { + let x: $ty = distr.sample(&mut rng); + accum += x; + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N; + } + } +} + +macro_rules! distr_duration { + ($fnn:ident, $distr:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = SmallRng::from_entropy(); + let distr = $distr; + + b.iter(|| { + let mut accum = Duration::new(0, 0); + for _ in 0..::RAND_BENCH_N { + let x: Duration = distr.sample(&mut rng); + accum = accum.checked_add(x).unwrap_or(Duration::new(u64::max_value(), 999_999_999)); + } + accum + }); + b.bytes = size_of::() as u64 * ::RAND_BENCH_N; + } + } +} + +macro_rules! distr { + ($fnn:ident, $ty:ty, $distr:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = SmallRng::from_entropy(); + let distr = $distr; + + b.iter(|| { + let mut accum = 0u32; + for _ in 0..::RAND_BENCH_N { + let x: $ty = distr.sample(&mut rng); + accum = accum.wrapping_add(x as u32); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N; + } + } +} + +macro_rules! distr_arr { + ($fnn:ident, $ty:ty, $distr:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = SmallRng::from_entropy(); + let distr = $distr; + + b.iter(|| { + let mut accum = 0u32; + for _ in 0..::RAND_BENCH_N { + let x: $ty = distr.sample(&mut rng); + accum = accum.wrapping_add(x[0] as u32); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N; + } + } +} + +// uniform +distr_int!(distr_uniform_i8, i8, Uniform::new(20i8, 100)); +distr_int!(distr_uniform_i16, i16, Uniform::new(-500i16, 2000)); +distr_int!(distr_uniform_i32, i32, Uniform::new(-200_000_000i32, 800_000_000)); +distr_int!(distr_uniform_i64, i64, Uniform::new(3i64, 123_456_789_123)); +distr_int!(distr_uniform_i128, i128, Uniform::new(-123_456_789_123i128, 123_456_789_123_456_789)); + +distr_float!(distr_uniform_f32, f32, Uniform::new(2.26f32, 2.319)); +distr_float!(distr_uniform_f64, f64, Uniform::new(2.26f64, 2.319)); + +const LARGE_SEC: u64 = u64::max_value() / 1000; + +distr_duration!(distr_uniform_duration_largest, + Uniform::new_inclusive(Duration::new(0, 0), Duration::new(u64::max_value(), 999_999_999)) +); +distr_duration!(distr_uniform_duration_large, + Uniform::new(Duration::new(0, 0), Duration::new(LARGE_SEC, 1_000_000_000 / 2)) +); +distr_duration!(distr_uniform_duration_one, + Uniform::new(Duration::new(0, 0), Duration::new(1, 0)) +); +distr_duration!(distr_uniform_duration_variety, + Uniform::new(Duration::new(10000, 423423), Duration::new(200000, 6969954)) +); +distr_duration!(distr_uniform_duration_edge, + Uniform::new_inclusive(Duration::new(LARGE_SEC, 999_999_999), Duration::new(LARGE_SEC + 1, 1)) +); + + +// standard +distr_int!(distr_standard_i8, i8, Standard); +distr_int!(distr_standard_i16, i16, Standard); +distr_int!(distr_standard_i32, i32, Standard); +distr_int!(distr_standard_i64, i64, Standard); +distr_int!(distr_standard_i128, i128, Standard); + +distr!(distr_standard_bool, bool, Standard); +distr!(distr_standard_alphanumeric, char, Alphanumeric); +distr!(distr_standard_codepoint, char, Standard); + +distr_float!(distr_standard_f32, f32, Standard); +distr_float!(distr_standard_f64, f64, Standard); +distr_float!(distr_open01_f32, f32, Open01); +distr_float!(distr_open01_f64, f64, Open01); +distr_float!(distr_openclosed01_f32, f32, OpenClosed01); +distr_float!(distr_openclosed01_f64, f64, OpenClosed01); + +// distributions +distr_float!(distr_exp, f64, Exp::new(1.23 * 4.56)); +distr_float!(distr_normal, f64, Normal::new(-1.23, 4.56)); +distr_float!(distr_log_normal, f64, LogNormal::new(-1.23, 4.56)); +distr_float!(distr_gamma_large_shape, f64, Gamma::new(10., 1.0)); +distr_float!(distr_gamma_small_shape, f64, Gamma::new(0.1, 1.0)); +distr_float!(distr_cauchy, f64, Cauchy::new(4.2, 6.9)); +distr_int!(distr_binomial, u64, Binomial::new(20, 0.7)); +distr_int!(distr_poisson, u64, Poisson::new(4.0)); +distr!(distr_bernoulli, bool, Bernoulli::new(0.18)); +distr_arr!(distr_circle, [f64; 2], UnitCircle::new()); +distr_arr!(distr_sphere_surface, [f64; 3], UnitSphereSurface::new()); + +// Weighted +distr_int!(distr_weighted_i8, usize, WeightedIndex::new(&[1i8, 2, 3, 4, 12, 0, 2, 1]).unwrap()); +distr_int!(distr_weighted_u32, usize, WeightedIndex::new(&[1u32, 2, 3, 4, 12, 0, 2, 1]).unwrap()); +distr_int!(distr_weighted_f64, usize, WeightedIndex::new(&[1.0f64, 0.001, 1.0/3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap()); +distr_int!(distr_weighted_large_set, usize, WeightedIndex::new((0..10000).rev().chain(1..10001)).unwrap()); + +// construct and sample from a range +macro_rules! gen_range_int { + ($fnn:ident, $ty:ident, $low:expr, $high:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = SmallRng::from_entropy(); + + b.iter(|| { + let mut high = $high; + let mut accum: $ty = 0; + for _ in 0..::RAND_BENCH_N { + accum = accum.wrapping_add(rng.gen_range($low, high)); + // force recalculation of range each time + high = high.wrapping_add(1) & std::$ty::MAX; + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N; + } + } +} + +gen_range_int!(gen_range_i8, i8, -20i8, 100); +gen_range_int!(gen_range_i16, i16, -500i16, 2000); +gen_range_int!(gen_range_i32, i32, -200_000_000i32, 800_000_000); +gen_range_int!(gen_range_i64, i64, 3i64, 123_456_789_123); +gen_range_int!(gen_range_i128, i128, -12345678901234i128, 123_456_789_123_456_789); + +// construct and sample from a floating-point range +macro_rules! gen_range_float { + ($fnn:ident, $ty:ident, $low:expr, $high:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = SmallRng::from_entropy(); + + b.iter(|| { + let mut high = $high; + let mut low = $low; + let mut accum: $ty = 0.0; + for _ in 0..::RAND_BENCH_N { + accum += rng.gen_range(low, high); + // force recalculation of range each time + low += 0.9; + high += 1.1; + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N; + } + } +} + +gen_range_float!(gen_range_f32, f32, -20000.0f32, 100000.0); +gen_range_float!(gen_range_f64, f64, 123.456f64, 7890.12); + +#[bench] +fn dist_iter(b: &mut Bencher) { + let mut rng = SmallRng::from_entropy(); + let distr = Normal::new(-2.71828, 3.14159); + let mut iter = distr.sample_iter(&mut rng); + + b.iter(|| { + let mut accum = 0.0; + for _ in 0..::RAND_BENCH_N { + accum += iter.next().unwrap(); + } + accum + }); + b.bytes = size_of::() as u64 * ::RAND_BENCH_N; +} diff --git a/third_party/cargo/vendor/rand-0.6.5/benches/generators.rs b/third_party/cargo/vendor/rand-0.6.5/benches/generators.rs new file mode 100644 index 0000000..a6e3a42 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/benches/generators.rs @@ -0,0 +1,240 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(test)] + +extern crate test; +extern crate rand; +extern crate rand_isaac; +extern crate rand_chacha; +extern crate rand_hc; +extern crate rand_pcg; +extern crate rand_xorshift; +extern crate rand_xoshiro; + +const RAND_BENCH_N: u64 = 1000; +const BYTES_LEN: usize = 1024; + +use std::mem::size_of; +use test::{black_box, Bencher}; + +use rand::prelude::*; +use rand::rngs::adapter::ReseedingRng; +use rand::rngs::{OsRng, JitterRng, EntropyRng}; +use rand_isaac::{IsaacRng, Isaac64Rng}; +use rand_chacha::ChaChaRng; +use rand_hc::{Hc128Rng, Hc128Core}; +use rand_pcg::{Lcg64Xsh32, Mcg128Xsl64}; +use rand_xorshift::XorShiftRng; +use rand_xoshiro::{Xoshiro256StarStar, Xoshiro256Plus, Xoshiro128StarStar, + Xoshiro128Plus, Xoroshiro128StarStar, Xoroshiro128Plus, SplitMix64, + Xoroshiro64StarStar, Xoroshiro64Star}; + +macro_rules! gen_bytes { + ($fnn:ident, $gen:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = $gen; + let mut buf = [0u8; BYTES_LEN]; + b.iter(|| { + for _ in 0..RAND_BENCH_N { + rng.fill_bytes(&mut buf); + black_box(buf); + } + }); + b.bytes = BYTES_LEN as u64 * RAND_BENCH_N; + } + } +} + +gen_bytes!(gen_bytes_xorshift, XorShiftRng::from_entropy()); +gen_bytes!(gen_bytes_xoshiro256starstar, Xoshiro256StarStar::from_entropy()); +gen_bytes!(gen_bytes_xoshiro256plus, Xoshiro256Plus::from_entropy()); +gen_bytes!(gen_bytes_xoshiro128starstar, Xoshiro128StarStar::from_entropy()); +gen_bytes!(gen_bytes_xoshiro128plus, Xoshiro128Plus::from_entropy()); +gen_bytes!(gen_bytes_xoroshiro128starstar, Xoroshiro128StarStar::from_entropy()); +gen_bytes!(gen_bytes_xoroshiro128plus, Xoroshiro128Plus::from_entropy()); +gen_bytes!(gen_bytes_xoroshiro64starstar, Xoroshiro64StarStar::from_entropy()); +gen_bytes!(gen_bytes_xoroshiro64star, Xoroshiro64Star::from_entropy()); +gen_bytes!(gen_bytes_splitmix64, SplitMix64::from_entropy()); +gen_bytes!(gen_bytes_lcg64_xsh32, Lcg64Xsh32::from_entropy()); +gen_bytes!(gen_bytes_mcg128_xsh64, Mcg128Xsl64::from_entropy()); +gen_bytes!(gen_bytes_chacha20, ChaChaRng::from_entropy()); +gen_bytes!(gen_bytes_hc128, Hc128Rng::from_entropy()); +gen_bytes!(gen_bytes_isaac, IsaacRng::from_entropy()); +gen_bytes!(gen_bytes_isaac64, Isaac64Rng::from_entropy()); +gen_bytes!(gen_bytes_std, StdRng::from_entropy()); +gen_bytes!(gen_bytes_small, SmallRng::from_entropy()); +gen_bytes!(gen_bytes_os, OsRng::new().unwrap()); + +macro_rules! gen_uint { + ($fnn:ident, $ty:ty, $gen:expr) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = $gen; + b.iter(|| { + let mut accum: $ty = 0; + for _ in 0..RAND_BENCH_N { + accum = accum.wrapping_add(rng.gen::<$ty>()); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N; + } + } +} + +gen_uint!(gen_u32_xorshift, u32, XorShiftRng::from_entropy()); +gen_uint!(gen_u32_xoshiro256starstar, u32, Xoshiro256StarStar::from_entropy()); +gen_uint!(gen_u32_xoshiro256plus, u32, Xoshiro256Plus::from_entropy()); +gen_uint!(gen_u32_xoshiro128starstar, u32, Xoshiro128StarStar::from_entropy()); +gen_uint!(gen_u32_xoshiro128plus, u32, Xoshiro128Plus::from_entropy()); +gen_uint!(gen_u32_xoroshiro128starstar, u32, Xoroshiro128StarStar::from_entropy()); +gen_uint!(gen_u32_xoroshiro128plus, u32, Xoroshiro128Plus::from_entropy()); +gen_uint!(gen_u32_xoroshiro64starstar, u32, Xoroshiro64StarStar::from_entropy()); +gen_uint!(gen_u32_xoroshiro64star, u32, Xoroshiro64Star::from_entropy()); +gen_uint!(gen_u32_splitmix64, u32, SplitMix64::from_entropy()); +gen_uint!(gen_u32_lcg64_xsh32, u32, Lcg64Xsh32::from_entropy()); +gen_uint!(gen_u32_mcg128_xsh64, u32, Mcg128Xsl64::from_entropy()); +gen_uint!(gen_u32_chacha20, u32, ChaChaRng::from_entropy()); +gen_uint!(gen_u32_hc128, u32, Hc128Rng::from_entropy()); +gen_uint!(gen_u32_isaac, u32, IsaacRng::from_entropy()); +gen_uint!(gen_u32_isaac64, u32, Isaac64Rng::from_entropy()); +gen_uint!(gen_u32_std, u32, StdRng::from_entropy()); +gen_uint!(gen_u32_small, u32, SmallRng::from_entropy()); +gen_uint!(gen_u32_os, u32, OsRng::new().unwrap()); + +gen_uint!(gen_u64_xorshift, u64, XorShiftRng::from_entropy()); +gen_uint!(gen_u64_xoshiro256starstar, u64, Xoshiro256StarStar::from_entropy()); +gen_uint!(gen_u64_xoshiro256plus, u64, Xoshiro256Plus::from_entropy()); +gen_uint!(gen_u64_xoshiro128starstar, u64, Xoshiro128StarStar::from_entropy()); +gen_uint!(gen_u64_xoshiro128plus, u64, Xoshiro128Plus::from_entropy()); +gen_uint!(gen_u64_xoroshiro128starstar, u64, Xoroshiro128StarStar::from_entropy()); +gen_uint!(gen_u64_xoroshiro128plus, u64, Xoroshiro128Plus::from_entropy()); +gen_uint!(gen_u64_xoroshiro64starstar, u64, Xoroshiro64StarStar::from_entropy()); +gen_uint!(gen_u64_xoroshiro64star, u64, Xoroshiro64Star::from_entropy()); +gen_uint!(gen_u64_splitmix64, u64, SplitMix64::from_entropy()); +gen_uint!(gen_u64_lcg64_xsh32, u64, Lcg64Xsh32::from_entropy()); +gen_uint!(gen_u64_mcg128_xsh64, u64, Mcg128Xsl64::from_entropy()); +gen_uint!(gen_u64_chacha20, u64, ChaChaRng::from_entropy()); +gen_uint!(gen_u64_hc128, u64, Hc128Rng::from_entropy()); +gen_uint!(gen_u64_isaac, u64, IsaacRng::from_entropy()); +gen_uint!(gen_u64_isaac64, u64, Isaac64Rng::from_entropy()); +gen_uint!(gen_u64_std, u64, StdRng::from_entropy()); +gen_uint!(gen_u64_small, u64, SmallRng::from_entropy()); +gen_uint!(gen_u64_os, u64, OsRng::new().unwrap()); + +// Do not test JitterRng like the others by running it RAND_BENCH_N times per, +// measurement, because it is way too slow. Only run it once. +#[bench] +fn gen_u64_jitter(b: &mut Bencher) { + let mut rng = JitterRng::new().unwrap(); + b.iter(|| { + rng.gen::() + }); + b.bytes = size_of::() as u64; +} + +macro_rules! init_gen { + ($fnn:ident, $gen:ident) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = XorShiftRng::from_entropy(); + b.iter(|| { + let r2 = $gen::from_rng(&mut rng).unwrap(); + r2 + }); + } + } +} + +init_gen!(init_xorshift, XorShiftRng); +init_gen!(init_xoshiro256starstar, Xoshiro256StarStar); +init_gen!(init_xoshiro256plus, Xoshiro256Plus); +init_gen!(init_xoshiro128starstar, Xoshiro128StarStar); +init_gen!(init_xoshiro128plus, Xoshiro128Plus); +init_gen!(init_xoroshiro128starstar, Xoroshiro128StarStar); +init_gen!(init_xoroshiro128plus, Xoroshiro128Plus); +init_gen!(init_xoroshiro64starstar, Xoroshiro64StarStar); +init_gen!(init_xoroshiro64star, Xoroshiro64Star); +init_gen!(init_splitmix64, SplitMix64); +init_gen!(init_lcg64_xsh32, Lcg64Xsh32); +init_gen!(init_mcg128_xsh64, Mcg128Xsl64); +init_gen!(init_hc128, Hc128Rng); +init_gen!(init_isaac, IsaacRng); +init_gen!(init_isaac64, Isaac64Rng); +init_gen!(init_chacha, ChaChaRng); + +#[bench] +fn init_jitter(b: &mut Bencher) { + b.iter(|| { + JitterRng::new().unwrap() + }); +} + + +const RESEEDING_THRESHOLD: u64 = 1024*1024*1024; // something high enough to get + // deterministic measurements + +#[bench] +fn reseeding_hc128_bytes(b: &mut Bencher) { + let mut rng = ReseedingRng::new(Hc128Core::from_entropy(), + RESEEDING_THRESHOLD, + EntropyRng::new()); + let mut buf = [0u8; BYTES_LEN]; + b.iter(|| { + for _ in 0..RAND_BENCH_N { + rng.fill_bytes(&mut buf); + black_box(buf); + } + }); + b.bytes = BYTES_LEN as u64 * RAND_BENCH_N; +} + +macro_rules! reseeding_uint { + ($fnn:ident, $ty:ty) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = ReseedingRng::new(Hc128Core::from_entropy(), + RESEEDING_THRESHOLD, + EntropyRng::new()); + b.iter(|| { + let mut accum: $ty = 0; + for _ in 0..RAND_BENCH_N { + accum = accum.wrapping_add(rng.gen::<$ty>()); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N; + } + } +} + +reseeding_uint!(reseeding_hc128_u32, u32); +reseeding_uint!(reseeding_hc128_u64, u64); + + +macro_rules! threadrng_uint { + ($fnn:ident, $ty:ty) => { + #[bench] + fn $fnn(b: &mut Bencher) { + let mut rng = thread_rng(); + b.iter(|| { + let mut accum: $ty = 0; + for _ in 0..RAND_BENCH_N { + accum = accum.wrapping_add(rng.gen::<$ty>()); + } + accum + }); + b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N; + } + } +} + +threadrng_uint!(thread_rng_u32, u32); +threadrng_uint!(thread_rng_u64, u64); diff --git a/third_party/cargo/vendor/rand-0.6.5/benches/misc.rs b/third_party/cargo/vendor/rand-0.6.5/benches/misc.rs new file mode 100644 index 0000000..8fb3a83 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/benches/misc.rs @@ -0,0 +1,160 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(test)] + +extern crate test; +extern crate rand; + +const RAND_BENCH_N: u64 = 1000; + +use test::Bencher; + +use rand::prelude::*; + +#[bench] +fn misc_gen_bool_const(b: &mut Bencher) { + let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let mut accum = true; + for _ in 0..::RAND_BENCH_N { + accum ^= rng.gen_bool(0.18); + } + accum + }) +} + +#[bench] +fn misc_gen_bool_var(b: &mut Bencher) { + let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let mut accum = true; + let mut p = 0.18; + for _ in 0..::RAND_BENCH_N { + accum ^= rng.gen_bool(p); + p += 0.0001; + } + accum + }) +} + +#[bench] +fn misc_gen_ratio_const(b: &mut Bencher) { + let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let mut accum = true; + for _ in 0..::RAND_BENCH_N { + accum ^= rng.gen_ratio(2, 3); + } + accum + }) +} + +#[bench] +fn misc_gen_ratio_var(b: &mut Bencher) { + let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let mut accum = true; + for i in 2..(::RAND_BENCH_N as u32 + 2) { + accum ^= rng.gen_ratio(i, i + 1); + } + accum + }) +} + +#[bench] +fn misc_bernoulli_const(b: &mut Bencher) { + let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let d = rand::distributions::Bernoulli::new(0.18); + let mut accum = true; + for _ in 0..::RAND_BENCH_N { + accum ^= rng.sample(d); + } + accum + }) +} + +#[bench] +fn misc_bernoulli_var(b: &mut Bencher) { + let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let mut accum = true; + let mut p = 0.18; + for _ in 0..::RAND_BENCH_N { + let d = rand::distributions::Bernoulli::new(p); + accum ^= rng.sample(d); + p += 0.0001; + } + accum + }) +} + +macro_rules! sample_binomial { + ($name:ident, $n:expr, $p:expr) => { + #[bench] + fn $name(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + let (n, p) = ($n, $p); + b.iter(|| { + let d = rand::distributions::Binomial::new(n, p); + rng.sample(d) + }) + } + } +} + +sample_binomial!(misc_binomial_1, 1, 0.9); +sample_binomial!(misc_binomial_10, 10, 0.9); +sample_binomial!(misc_binomial_100, 100, 0.99); +sample_binomial!(misc_binomial_1000, 1000, 0.01); +sample_binomial!(misc_binomial_1e12, 1000_000_000_000, 0.2); + +#[bench] +fn gen_1k_iter_repeat(b: &mut Bencher) { + use std::iter; + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let v: Vec = iter::repeat(()).map(|()| rng.gen()).take(128).collect(); + v + }); + b.bytes = 1024; +} + +#[bench] +fn gen_1k_sample_iter(b: &mut Bencher) { + use rand::distributions::{Distribution, Standard}; + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + let v: Vec = Standard.sample_iter(&mut rng).take(128).collect(); + v + }); + b.bytes = 1024; +} + +#[bench] +fn gen_1k_gen_array(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + b.iter(|| { + // max supported array length is 32! + let v: [[u64; 32]; 4] = rng.gen(); + v + }); + b.bytes = 1024; +} + +#[bench] +fn gen_1k_fill(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap(); + let mut buf = [0u64; 128]; + b.iter(|| { + rng.fill(&mut buf[..]); + buf + }); + b.bytes = 1024; +} diff --git a/third_party/cargo/vendor/rand-0.6.5/benches/seq.rs b/third_party/cargo/vendor/rand-0.6.5/benches/seq.rs new file mode 100644 index 0000000..0ca3398 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/benches/seq.rs @@ -0,0 +1,174 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(test)] +#![allow(non_snake_case)] + +extern crate test; +extern crate rand; + +use test::Bencher; + +use rand::prelude::*; +use rand::seq::*; +use std::mem::size_of; + +const RAND_BENCH_N: u64 = 1000; + +#[bench] +fn seq_shuffle_100(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &mut [usize] = &mut [1; 100]; + b.iter(|| { + x.shuffle(&mut rng); + x[0] + }) +} + +#[bench] +fn seq_slice_choose_1_of_1000(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &mut [usize] = &mut [1; 1000]; + for i in 0..1000 { + x[i] = i; + } + b.iter(|| { + let mut s = 0; + for _ in 0..RAND_BENCH_N { + s += x.choose(&mut rng).unwrap(); + } + s + }); + b.bytes = size_of::() as u64 * ::RAND_BENCH_N; +} + +macro_rules! seq_slice_choose_multiple { + ($name:ident, $amount:expr, $length:expr) => { + #[bench] + fn $name(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &[i32] = &[$amount; $length]; + let mut result = [0i32; $amount]; + b.iter(|| { + // Collect full result to prevent unwanted shortcuts getting + // first element (in case sample_indices returns an iterator). + for (slot, sample) in result.iter_mut().zip( + x.choose_multiple(&mut rng, $amount)) { + *slot = *sample; + } + result[$amount-1] + }) + } + } +} + +seq_slice_choose_multiple!(seq_slice_choose_multiple_1_of_1000, 1, 1000); +seq_slice_choose_multiple!(seq_slice_choose_multiple_950_of_1000, 950, 1000); +seq_slice_choose_multiple!(seq_slice_choose_multiple_10_of_100, 10, 100); +seq_slice_choose_multiple!(seq_slice_choose_multiple_90_of_100, 90, 100); + +#[bench] +fn seq_iter_choose_from_1000(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &mut [usize] = &mut [1; 1000]; + for i in 0..1000 { + x[i] = i; + } + b.iter(|| { + let mut s = 0; + for _ in 0..RAND_BENCH_N { + s += x.iter().choose(&mut rng).unwrap(); + } + s + }); + b.bytes = size_of::() as u64 * ::RAND_BENCH_N; +} + +#[derive(Clone)] +struct UnhintedIterator { + iter: I, +} +impl Iterator for UnhintedIterator { + type Item = I::Item; + fn next(&mut self) -> Option { + self.iter.next() + } +} + +#[derive(Clone)] +struct WindowHintedIterator { + iter: I, + window_size: usize, +} +impl Iterator for WindowHintedIterator { + type Item = I::Item; + fn next(&mut self) -> Option { + self.iter.next() + } + fn size_hint(&self) -> (usize, Option) { + (std::cmp::min(self.iter.len(), self.window_size), None) + } +} + +#[bench] +fn seq_iter_unhinted_choose_from_1000(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &[usize] = &[1; 1000]; + b.iter(|| { + UnhintedIterator { iter: x.iter() }.choose(&mut rng).unwrap() + }) +} + +#[bench] +fn seq_iter_window_hinted_choose_from_1000(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &[usize] = &[1; 1000]; + b.iter(|| { + WindowHintedIterator { iter: x.iter(), window_size: 7 }.choose(&mut rng) + }) +} + +#[bench] +fn seq_iter_choose_multiple_10_of_100(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &[usize] = &[1; 100]; + b.iter(|| { + x.iter().cloned().choose_multiple(&mut rng, 10) + }) +} + +#[bench] +fn seq_iter_choose_multiple_fill_10_of_100(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + let x : &[usize] = &[1; 100]; + let mut buf = [0; 10]; + b.iter(|| { + x.iter().cloned().choose_multiple_fill(&mut rng, &mut buf) + }) +} + +macro_rules! sample_indices { + ($name:ident, $fn:ident, $amount:expr, $length:expr) => { + #[bench] + fn $name(b: &mut Bencher) { + let mut rng = SmallRng::from_rng(thread_rng()).unwrap(); + b.iter(|| { + index::$fn(&mut rng, $length, $amount) + }) + } + } +} + +sample_indices!(misc_sample_indices_1_of_1k, sample, 1, 1000); +sample_indices!(misc_sample_indices_10_of_1k, sample, 10, 1000); +sample_indices!(misc_sample_indices_100_of_1k, sample, 100, 1000); +sample_indices!(misc_sample_indices_100_of_1M, sample, 100, 1000_000); +sample_indices!(misc_sample_indices_100_of_1G, sample, 100, 1000_000_000); +sample_indices!(misc_sample_indices_200_of_1G, sample, 200, 1000_000_000); +sample_indices!(misc_sample_indices_400_of_1G, sample, 400, 1000_000_000); +sample_indices!(misc_sample_indices_600_of_1G, sample, 600, 1000_000_000); diff --git a/third_party/cargo/vendor/rand-0.6.5/build.rs b/third_party/cargo/vendor/rand-0.6.5/build.rs new file mode 100644 index 0000000..a554ad9 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/build.rs @@ -0,0 +1,10 @@ +extern crate autocfg; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let ac = autocfg::new(); + ac.emit_rustc_version(1, 25); + ac.emit_rustc_version(1, 26); + ac.emit_rustc_version(1, 27); +} diff --git a/third_party/cargo/vendor/rand-0.6.5/examples/monte-carlo.rs b/third_party/cargo/vendor/rand-0.6.5/examples/monte-carlo.rs new file mode 100644 index 0000000..9162996 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/examples/monte-carlo.rs @@ -0,0 +1,51 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2018 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! # Monte Carlo estimation of π +//! +//! Imagine that we have a square with sides of length 2 and a unit circle +//! (radius = 1), both centered at the origin. The areas are: +//! +//! ```text +//! area of circle = πr² = π * r * r = π +//! area of square = 2² = 4 +//! ``` +//! +//! The circle is entirely within the square, so if we sample many points +//! randomly from the square, roughly π / 4 of them should be inside the circle. +//! +//! We can use the above fact to estimate the value of π: pick many points in +//! the square at random, calculate the fraction that fall within the circle, +//! and multiply this fraction by 4. + +#![cfg(feature="std")] + + +extern crate rand; + +use rand::distributions::{Distribution, Uniform}; + +fn main() { + let range = Uniform::new(-1.0f64, 1.0); + let mut rng = rand::thread_rng(); + + let total = 1_000_000; + let mut in_circle = 0; + + for _ in 0..total { + let a = range.sample(&mut rng); + let b = range.sample(&mut rng); + if a*a + b*b <= 1.0 { + in_circle += 1; + } + } + + // prints something close to 3.14159... + println!("π is approximately {}", 4. * (in_circle as f64) / (total as f64)); +} diff --git a/third_party/cargo/vendor/rand-0.6.5/examples/monty-hall.rs b/third_party/cargo/vendor/rand-0.6.5/examples/monty-hall.rs new file mode 100644 index 0000000..0932c5e --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/examples/monty-hall.rs @@ -0,0 +1,116 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2018 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! ## Monty Hall Problem +//! +//! This is a simulation of the [Monty Hall Problem][]: +//! +//! > Suppose you're on a game show, and you're given the choice of three doors: +//! > Behind one door is a car; behind the others, goats. You pick a door, say +//! > No. 1, and the host, who knows what's behind the doors, opens another +//! > door, say No. 3, which has a goat. He then says to you, "Do you want to +//! > pick door No. 2?" Is it to your advantage to switch your choice? +//! +//! The rather unintuitive answer is that you will have a 2/3 chance of winning +//! if you switch and a 1/3 chance of winning if you don't, so it's better to +//! switch. +//! +//! This program will simulate the game show and with large enough simulation +//! steps it will indeed confirm that it is better to switch. +//! +//! [Monty Hall Problem]: https://en.wikipedia.org/wiki/Monty_Hall_problem + +#![cfg(feature="std")] + + +extern crate rand; + +use rand::Rng; +use rand::distributions::{Distribution, Uniform}; + +struct SimulationResult { + win: bool, + switch: bool, +} + +// Run a single simulation of the Monty Hall problem. +fn simulate(random_door: &Uniform, rng: &mut R) + -> SimulationResult { + let car = random_door.sample(rng); + + // This is our initial choice + let mut choice = random_door.sample(rng); + + // The game host opens a door + let open = game_host_open(car, choice, rng); + + // Shall we switch? + let switch = rng.gen(); + if switch { + choice = switch_door(choice, open); + } + + SimulationResult { win: choice == car, switch } +} + +// Returns the door the game host opens given our choice and knowledge of +// where the car is. The game host will never open the door with the car. +fn game_host_open(car: u32, choice: u32, rng: &mut R) -> u32 { + use rand::seq::SliceRandom; + *free_doors(&[car, choice]).choose(rng).unwrap() +} + +// Returns the door we switch to, given our current choice and +// the open door. There will only be one valid door. +fn switch_door(choice: u32, open: u32) -> u32 { + free_doors(&[choice, open])[0] +} + +fn free_doors(blocked: &[u32]) -> Vec { + (0..3).filter(|x| !blocked.contains(x)).collect() +} + +fn main() { + // The estimation will be more accurate with more simulations + let num_simulations = 10000; + + let mut rng = rand::thread_rng(); + let random_door = Uniform::new(0u32, 3); + + let (mut switch_wins, mut switch_losses) = (0, 0); + let (mut keep_wins, mut keep_losses) = (0, 0); + + println!("Running {} simulations...", num_simulations); + for _ in 0..num_simulations { + let result = simulate(&random_door, &mut rng); + + match (result.win, result.switch) { + (true, true) => switch_wins += 1, + (true, false) => keep_wins += 1, + (false, true) => switch_losses += 1, + (false, false) => keep_losses += 1, + } + } + + let total_switches = switch_wins + switch_losses; + let total_keeps = keep_wins + keep_losses; + + println!("Switched door {} times with {} wins and {} losses", + total_switches, switch_wins, switch_losses); + + println!("Kept our choice {} times with {} wins and {} losses", + total_keeps, keep_wins, keep_losses); + + // With a large number of simulations, the values should converge to + // 0.667 and 0.333 respectively. + println!("Estimated chance to win if we switch: {}", + switch_wins as f32 / total_switches as f32); + println!("Estimated chance to win if we don't: {}", + keep_wins as f32 / total_keeps as f32); +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/deprecated.rs b/third_party/cargo/vendor/rand-0.6.5/src/deprecated.rs new file mode 100644 index 0000000..88eb09f --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/deprecated.rs @@ -0,0 +1,544 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Deprecated re-exports (we can't add deprecation warnings otherwise) + +#![allow(deprecated)] + +use rngs; +use {RngCore, CryptoRng, SeedableRng, Error}; +use rand_core::block::BlockRngCore; +use rand_isaac; +use rand_chacha; +use rand_hc; + +#[cfg(feature="std")] +use std::io::Read; + +#[derive(Clone, Debug)] +#[deprecated(since="0.6.0", + note="import from rand_isaac crate instead, or use the newer Hc128Rng")] +pub struct IsaacRng(rand_isaac::IsaacRng); + +impl RngCore for IsaacRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for IsaacRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + IsaacRng(rand_isaac::IsaacRng::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + rand_isaac::IsaacRng::from_rng(rng).map(IsaacRng) + } +} + +impl IsaacRng { + pub fn new_from_u64(seed: u64) -> Self { + IsaacRng(rand_isaac::IsaacRng::new_from_u64(seed)) + } +} + + +#[derive(Clone, Debug)] +#[deprecated(since="0.6.0", + note="import from rand_isaac crate instead, or use newer Hc128Rng")] +pub struct Isaac64Rng(rand_isaac::Isaac64Rng); + +impl RngCore for Isaac64Rng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for Isaac64Rng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + Isaac64Rng(rand_isaac::Isaac64Rng::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + rand_isaac::Isaac64Rng::from_rng(rng).map(Isaac64Rng) + } +} + +impl Isaac64Rng { + pub fn new_from_u64(seed: u64) -> Self { + Isaac64Rng(rand_isaac::Isaac64Rng::new_from_u64(seed)) + } +} + + +#[derive(Clone, Debug)] +#[deprecated(since="0.6.0", note="import from rand_chacha crate instead")] +pub struct ChaChaRng(rand_chacha::ChaChaRng); + +impl RngCore for ChaChaRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for ChaChaRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + ChaChaRng(rand_chacha::ChaChaRng::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + rand_chacha::ChaChaRng::from_rng(rng).map(ChaChaRng) + } +} + +impl ChaChaRng { + #[cfg(all(rustc_1_26, not(target_os = "emscripten")))] + pub fn get_word_pos(&self) -> u128 { + self.0.get_word_pos() + } + + #[cfg(all(rustc_1_26, not(target_os = "emscripten")))] + pub fn set_word_pos(&mut self, word_offset: u128) { + self.0.set_word_pos(word_offset) + } + + pub fn set_stream(&mut self, stream: u64) { + self.0.set_stream(stream) + } +} + +impl CryptoRng for ChaChaRng {} + + +#[derive(Clone, Debug)] +#[deprecated(since="0.6.0", note="import from rand_hc crate instead")] +pub struct Hc128Rng(rand_hc::Hc128Rng); + +impl RngCore for Hc128Rng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for Hc128Rng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + Hc128Rng(rand_hc::Hc128Rng::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + rand_hc::Hc128Rng::from_rng(rng).map(Hc128Rng) + } +} + +impl CryptoRng for Hc128Rng {} + + +#[derive(Clone, Debug)] +#[deprecated(since="0.6.0", note="import from rand_xorshift crate instead")] +pub struct XorShiftRng(::rand_xorshift::XorShiftRng); + +impl RngCore for XorShiftRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for XorShiftRng { + type Seed = <::rand_xorshift::XorShiftRng as SeedableRng>::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + XorShiftRng(::rand_xorshift::XorShiftRng::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + ::rand_xorshift::XorShiftRng::from_rng(rng).map(XorShiftRng) + } +} + + +#[derive(Clone, Debug)] +#[deprecated(since="0.6.0", + note="import with rand::prelude::* or rand::rngs::StdRng instead")] +pub struct StdRng(rngs::StdRng); + +impl RngCore for StdRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for StdRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + StdRng(rngs::StdRng::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + rngs::StdRng::from_rng(rng).map(StdRng) + } +} + +impl CryptoRng for StdRng {} + + +#[cfg(feature="rand_os")] +#[derive(Clone, Debug)] +#[deprecated(since="0.6.0", note="import with rand::rngs::OsRng instead")] +pub struct OsRng(rngs::OsRng); + +#[cfg(feature="rand_os")] +impl RngCore for OsRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +#[cfg(feature="rand_os")] +impl OsRng { + pub fn new() -> Result { + rngs::OsRng::new().map(OsRng) + } +} + +#[cfg(feature="rand_os")] +impl CryptoRng for OsRng {} + + +#[cfg(feature="std")] +#[derive(Debug)] +#[deprecated(since="0.6.0", note="import with rand::rngs::EntropyRng instead")] +pub struct EntropyRng(rngs::EntropyRng); + +#[cfg(feature="std")] +impl RngCore for EntropyRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +#[cfg(feature="std")] +impl EntropyRng { + pub fn new() -> Self { + EntropyRng(rngs::EntropyRng::new()) + } +} + +#[cfg(feature="std")] +impl Default for EntropyRng { + fn default() -> Self { + EntropyRng::new() + } +} + +#[cfg(feature="std")] +impl CryptoRng for EntropyRng {} + + +#[derive(Clone, Debug)] +#[deprecated(since="0.6.0", note="import with rand::rngs::JitterRng instead")] +pub struct JitterRng(rngs::JitterRng); + +impl RngCore for JitterRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl JitterRng { + #[cfg(all(feature="std", not(target_arch = "wasm32")))] + pub fn new() -> Result { + rngs::JitterRng::new().map(JitterRng) + } + + pub fn new_with_timer(timer: fn() -> u64) -> JitterRng { + JitterRng(rngs::JitterRng::new_with_timer(timer)) + } + + pub fn set_rounds(&mut self, rounds: u8) { + self.0.set_rounds(rounds) + } + + pub fn test_timer(&mut self) -> Result { + self.0.test_timer() + } + + #[cfg(feature="std")] + pub fn timer_stats(&mut self, var_rounds: bool) -> i64 { + self.0.timer_stats(var_rounds) + } +} + +impl CryptoRng for JitterRng {} + + +#[cfg(feature="std")] +#[derive(Clone, Debug)] +#[deprecated(since="0.6.0", + note="import with rand::prelude::* or rand::rngs::ThreadRng instead")] +pub struct ThreadRng(rngs::ThreadRng); + +#[cfg(feature="std")] +impl RngCore for ThreadRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +#[cfg(feature="std")] +impl CryptoRng for ThreadRng {} + + +#[cfg(feature="std")] +#[derive(Debug)] +#[deprecated(since="0.6.0", note="import with rand::rngs::adapter::ReadRng instead")] +pub struct ReadRng(rngs::adapter::ReadRng); + +#[cfg(feature="std")] +impl RngCore for ReadRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +#[cfg(feature="std")] +impl ReadRng { + pub fn new(r: R) -> ReadRng { + ReadRng(rngs::adapter::ReadRng::new(r)) + } +} + + +#[derive(Clone, Debug)] +pub struct ReseedingRng(rngs::adapter::ReseedingRng) +where R: BlockRngCore + SeedableRng, + Rsdr: RngCore; + +impl RngCore for ReseedingRng +where R: BlockRngCore + SeedableRng, + ::Results: AsRef<[u32]> + AsMut<[u32]> +{ + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl ReseedingRng +where R: BlockRngCore + SeedableRng, + Rsdr: RngCore +{ + pub fn new(rng: R, threshold: u64, reseeder: Rsdr) -> Self { + ReseedingRng(rngs::adapter::ReseedingRng::new(rng, threshold, reseeder)) + } + + pub fn reseed(&mut self) -> Result<(), Error> { + self.0.reseed() + } +} + +impl CryptoRng for ReseedingRng +where R: BlockRngCore + SeedableRng + CryptoRng, + Rsdr: RngCore + CryptoRng {} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/bernoulli.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/bernoulli.rs new file mode 100644 index 0000000..f49618c --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/bernoulli.rs @@ -0,0 +1,165 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Bernoulli distribution. + +use Rng; +use distributions::Distribution; + +/// The Bernoulli distribution. +/// +/// This is a special case of the Binomial distribution where `n = 1`. +/// +/// # Example +/// +/// ```rust +/// use rand::distributions::{Bernoulli, Distribution}; +/// +/// let d = Bernoulli::new(0.3); +/// let v = d.sample(&mut rand::thread_rng()); +/// println!("{} is from a Bernoulli distribution", v); +/// ``` +/// +/// # Precision +/// +/// This `Bernoulli` distribution uses 64 bits from the RNG (a `u64`), +/// so only probabilities that are multiples of 2-64 can be +/// represented. +#[derive(Clone, Copy, Debug)] +pub struct Bernoulli { + /// Probability of success, relative to the maximal integer. + p_int: u64, +} + +// To sample from the Bernoulli distribution we use a method that compares a +// random `u64` value `v < (p * 2^64)`. +// +// If `p == 1.0`, the integer `v` to compare against can not represented as a +// `u64`. We manually set it to `u64::MAX` instead (2^64 - 1 instead of 2^64). +// Note that value of `p < 1.0` can never result in `u64::MAX`, because an +// `f64` only has 53 bits of precision, and the next largest value of `p` will +// result in `2^64 - 2048`. +// +// Also there is a 100% theoretical concern: if someone consistenly wants to +// generate `true` using the Bernoulli distribution (i.e. by using a probability +// of `1.0`), just using `u64::MAX` is not enough. On average it would return +// false once every 2^64 iterations. Some people apparently care about this +// case. +// +// That is why we special-case `u64::MAX` to always return `true`, without using +// the RNG, and pay the performance price for all uses that *are* reasonable. +// Luckily, if `new()` and `sample` are close, the compiler can optimize out the +// extra check. +const ALWAYS_TRUE: u64 = ::core::u64::MAX; + +// This is just `2.0.powi(64)`, but written this way because it is not available +// in `no_std` mode. +const SCALE: f64 = 2.0 * (1u64 << 63) as f64; + +impl Bernoulli { + /// Construct a new `Bernoulli` with the given probability of success `p`. + /// + /// # Panics + /// + /// If `p < 0` or `p > 1`. + /// + /// # Precision + /// + /// For `p = 1.0`, the resulting distribution will always generate true. + /// For `p = 0.0`, the resulting distribution will always generate false. + /// + /// This method is accurate for any input `p` in the range `[0, 1]` which is + /// a multiple of 2-64. (Note that not all multiples of + /// 2-64 in `[0, 1]` can be represented as a `f64`.) + #[inline] + pub fn new(p: f64) -> Bernoulli { + if p < 0.0 || p >= 1.0 { + if p == 1.0 { return Bernoulli { p_int: ALWAYS_TRUE } } + panic!("Bernoulli::new not called with 0.0 <= p <= 1.0"); + } + Bernoulli { p_int: (p * SCALE) as u64 } + } + + /// Construct a new `Bernoulli` with the probability of success of + /// `numerator`-in-`denominator`. I.e. `new_ratio(2, 3)` will return + /// a `Bernoulli` with a 2-in-3 chance, or about 67%, of returning `true`. + /// + /// If `numerator == denominator` then the returned `Bernoulli` will always + /// return `true`. If `numerator == 0` it will always return `false`. + /// + /// # Panics + /// + /// If `denominator == 0` or `numerator > denominator`. + /// + #[inline] + pub fn from_ratio(numerator: u32, denominator: u32) -> Bernoulli { + assert!(numerator <= denominator); + if numerator == denominator { + return Bernoulli { p_int: ::core::u64::MAX } + } + let p_int = ((numerator as f64 / denominator as f64) * SCALE) as u64; + Bernoulli { p_int } + } +} + +impl Distribution for Bernoulli { + #[inline] + fn sample(&self, rng: &mut R) -> bool { + // Make sure to always return true for p = 1.0. + if self.p_int == ALWAYS_TRUE { return true; } + let v: u64 = rng.gen(); + v < self.p_int + } +} + +#[cfg(test)] +mod test { + use Rng; + use distributions::Distribution; + use super::Bernoulli; + + #[test] + fn test_trivial() { + let mut r = ::test::rng(1); + let always_false = Bernoulli::new(0.0); + let always_true = Bernoulli::new(1.0); + for _ in 0..5 { + assert_eq!(r.sample::(&always_false), false); + assert_eq!(r.sample::(&always_true), true); + assert_eq!(Distribution::::sample(&always_false, &mut r), false); + assert_eq!(Distribution::::sample(&always_true, &mut r), true); + } + } + + #[test] + fn test_average() { + const P: f64 = 0.3; + const NUM: u32 = 3; + const DENOM: u32 = 10; + let d1 = Bernoulli::new(P); + let d2 = Bernoulli::from_ratio(NUM, DENOM); + const N: u32 = 100_000; + + let mut sum1: u32 = 0; + let mut sum2: u32 = 0; + let mut rng = ::test::rng(2); + for _ in 0..N { + if d1.sample(&mut rng) { + sum1 += 1; + } + if d2.sample(&mut rng) { + sum2 += 1; + } + } + let avg1 = (sum1 as f64) / (N as f64); + assert!((avg1 - P).abs() < 5e-3); + + let avg2 = (sum2 as f64) / (N as f64); + assert!((avg2 - (NUM as f64)/(DENOM as f64)).abs() < 5e-3); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/binomial.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/binomial.rs new file mode 100644 index 0000000..2df393e --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/binomial.rs @@ -0,0 +1,177 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2016-2017 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The binomial distribution. + +use Rng; +use distributions::{Distribution, Bernoulli, Cauchy}; +use distributions::utils::log_gamma; + +/// The binomial distribution `Binomial(n, p)`. +/// +/// This distribution has density function: +/// `f(k) = n!/(k! (n-k)!) p^k (1-p)^(n-k)` for `k >= 0`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Binomial, Distribution}; +/// +/// let bin = Binomial::new(20, 0.3); +/// let v = bin.sample(&mut rand::thread_rng()); +/// println!("{} is from a binomial distribution", v); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Binomial { + /// Number of trials. + n: u64, + /// Probability of success. + p: f64, +} + +impl Binomial { + /// Construct a new `Binomial` with the given shape parameters `n` (number + /// of trials) and `p` (probability of success). + /// + /// Panics if `p < 0` or `p > 1`. + pub fn new(n: u64, p: f64) -> Binomial { + assert!(p >= 0.0, "Binomial::new called with p < 0"); + assert!(p <= 1.0, "Binomial::new called with p > 1"); + Binomial { n, p } + } +} + +impl Distribution for Binomial { + fn sample(&self, rng: &mut R) -> u64 { + // Handle these values directly. + if self.p == 0.0 { + return 0; + } else if self.p == 1.0 { + return self.n; + } + + // For low n, it is faster to sample directly. For both methods, + // performance is independent of p. On Intel Haswell CPU this method + // appears to be faster for approx n < 300. + if self.n < 300 { + let mut result = 0; + let d = Bernoulli::new(self.p); + for _ in 0 .. self.n { + result += rng.sample(d) as u32; + } + return result as u64; + } + + // binomial distribution is symmetrical with respect to p -> 1-p, k -> n-k + // switch p so that it is less than 0.5 - this allows for lower expected values + // we will just invert the result at the end + let p = if self.p <= 0.5 { + self.p + } else { + 1.0 - self.p + }; + + // prepare some cached values + let float_n = self.n as f64; + let ln_fact_n = log_gamma(float_n + 1.0); + let pc = 1.0 - p; + let log_p = p.ln(); + let log_pc = pc.ln(); + let expected = self.n as f64 * p; + let sq = (expected * (2.0 * pc)).sqrt(); + + let mut lresult; + + // we use the Cauchy distribution as the comparison distribution + // f(x) ~ 1/(1+x^2) + let cauchy = Cauchy::new(0.0, 1.0); + loop { + let mut comp_dev: f64; + loop { + // draw from the Cauchy distribution + comp_dev = rng.sample(cauchy); + // shift the peak of the comparison ditribution + lresult = expected + sq * comp_dev; + // repeat the drawing until we are in the range of possible values + if lresult >= 0.0 && lresult < float_n + 1.0 { + break; + } + } + + // the result should be discrete + lresult = lresult.floor(); + + let log_binomial_dist = ln_fact_n - log_gamma(lresult+1.0) - + log_gamma(float_n - lresult + 1.0) + lresult*log_p + (float_n - lresult)*log_pc; + // this is the binomial probability divided by the comparison probability + // we will generate a uniform random value and if it is larger than this, + // we interpret it as a value falling out of the distribution and repeat + let comparison_coeff = (log_binomial_dist.exp() * sq) * (1.2 * (1.0 + comp_dev*comp_dev)); + + if comparison_coeff >= rng.gen() { + break; + } + } + + // invert the result for p < 0.5 + if p != self.p { + self.n - lresult as u64 + } else { + lresult as u64 + } + } +} + +#[cfg(test)] +mod test { + use Rng; + use distributions::Distribution; + use super::Binomial; + + fn test_binomial_mean_and_variance(n: u64, p: f64, rng: &mut R) { + let binomial = Binomial::new(n, p); + + let expected_mean = n as f64 * p; + let expected_variance = n as f64 * p * (1.0 - p); + + let mut results = [0.0; 1000]; + for i in results.iter_mut() { *i = binomial.sample(rng) as f64; } + + let mean = results.iter().sum::() / results.len() as f64; + assert!((mean as f64 - expected_mean).abs() < expected_mean / 50.0); + + let variance = + results.iter().map(|x| (x - mean) * (x - mean)).sum::() + / results.len() as f64; + assert!((variance - expected_variance).abs() < expected_variance / 10.0); + } + + #[test] + fn test_binomial() { + let mut rng = ::test::rng(351); + test_binomial_mean_and_variance(150, 0.1, &mut rng); + test_binomial_mean_and_variance(70, 0.6, &mut rng); + test_binomial_mean_and_variance(40, 0.5, &mut rng); + test_binomial_mean_and_variance(20, 0.7, &mut rng); + test_binomial_mean_and_variance(20, 0.5, &mut rng); + } + + #[test] + fn test_binomial_end_points() { + let mut rng = ::test::rng(352); + assert_eq!(rng.sample(Binomial::new(20, 0.0)), 0); + assert_eq!(rng.sample(Binomial::new(20, 1.0)), 20); + } + + #[test] + #[should_panic] + fn test_binomial_invalid_lambda_neg() { + Binomial::new(20, -10.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/cauchy.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/cauchy.rs new file mode 100644 index 0000000..feef015 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/cauchy.rs @@ -0,0 +1,115 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2016-2017 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Cauchy distribution. + +use Rng; +use distributions::Distribution; +use std::f64::consts::PI; + +/// The Cauchy distribution `Cauchy(median, scale)`. +/// +/// This distribution has a density function: +/// `f(x) = 1 / (pi * scale * (1 + ((x - median) / scale)^2))` +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Cauchy, Distribution}; +/// +/// let cau = Cauchy::new(2.0, 5.0); +/// let v = cau.sample(&mut rand::thread_rng()); +/// println!("{} is from a Cauchy(2, 5) distribution", v); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Cauchy { + median: f64, + scale: f64 +} + +impl Cauchy { + /// Construct a new `Cauchy` with the given shape parameters + /// `median` the peak location and `scale` the scale factor. + /// Panics if `scale <= 0`. + pub fn new(median: f64, scale: f64) -> Cauchy { + assert!(scale > 0.0, "Cauchy::new called with scale factor <= 0"); + Cauchy { + median, + scale + } + } +} + +impl Distribution for Cauchy { + fn sample(&self, rng: &mut R) -> f64 { + // sample from [0, 1) + let x = rng.gen::(); + // get standard cauchy random number + // note that π/2 is not exactly representable, even if x=0.5 the result is finite + let comp_dev = (PI * x).tan(); + // shift and scale according to parameters + let result = self.median + self.scale * comp_dev; + result + } +} + +#[cfg(test)] +mod test { + use distributions::Distribution; + use super::Cauchy; + + fn median(mut numbers: &mut [f64]) -> f64 { + sort(&mut numbers); + let mid = numbers.len() / 2; + numbers[mid] + } + + fn sort(numbers: &mut [f64]) { + numbers.sort_by(|a, b| a.partial_cmp(b).unwrap()); + } + + #[test] + fn test_cauchy_median() { + let cauchy = Cauchy::new(10.0, 5.0); + let mut rng = ::test::rng(123); + let mut numbers: [f64; 1000] = [0.0; 1000]; + for i in 0..1000 { + numbers[i] = cauchy.sample(&mut rng); + } + let median = median(&mut numbers); + println!("Cauchy median: {}", median); + assert!((median - 10.0).abs() < 0.5); // not 100% certain, but probable enough + } + + #[test] + fn test_cauchy_mean() { + let cauchy = Cauchy::new(10.0, 5.0); + let mut rng = ::test::rng(123); + let mut sum = 0.0; + for _ in 0..1000 { + sum += cauchy.sample(&mut rng); + } + let mean = sum / 1000.0; + println!("Cauchy mean: {}", mean); + // for a Cauchy distribution the mean should not converge + assert!((mean - 10.0).abs() > 0.5); // not 100% certain, but probable enough + } + + #[test] + #[should_panic] + fn test_cauchy_invalid_scale_zero() { + Cauchy::new(0.0, 0.0); + } + + #[test] + #[should_panic] + fn test_cauchy_invalid_scale_neg() { + Cauchy::new(0.0, -10.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/dirichlet.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/dirichlet.rs new file mode 100644 index 0000000..19384b8 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/dirichlet.rs @@ -0,0 +1,137 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The dirichlet distribution. + +use Rng; +use distributions::Distribution; +use distributions::gamma::Gamma; + +/// The dirichelet distribution `Dirichlet(alpha)`. +/// +/// The Dirichlet distribution is a family of continuous multivariate +/// probability distributions parameterized by a vector alpha of positive reals. +/// It is a multivariate generalization of the beta distribution. +/// +/// # Example +/// +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::Dirichlet; +/// +/// let dirichlet = Dirichlet::new(vec![1.0, 2.0, 3.0]); +/// let samples = dirichlet.sample(&mut rand::thread_rng()); +/// println!("{:?} is from a Dirichlet([1.0, 2.0, 3.0]) distribution", samples); +/// ``` + +#[derive(Clone, Debug)] +pub struct Dirichlet { + /// Concentration parameters (alpha) + alpha: Vec, +} + +impl Dirichlet { + /// Construct a new `Dirichlet` with the given alpha parameter `alpha`. + /// + /// # Panics + /// - if `alpha.len() < 2` + /// + #[inline] + pub fn new>>(alpha: V) -> Dirichlet { + let a = alpha.into(); + assert!(a.len() > 1); + for i in 0..a.len() { + assert!(a[i] > 0.0); + } + + Dirichlet { alpha: a } + } + + /// Construct a new `Dirichlet` with the given shape parameter `alpha` and `size`. + /// + /// # Panics + /// - if `alpha <= 0.0` + /// - if `size < 2` + /// + #[inline] + pub fn new_with_param(alpha: f64, size: usize) -> Dirichlet { + assert!(alpha > 0.0); + assert!(size > 1); + Dirichlet { + alpha: vec![alpha; size], + } + } +} + +impl Distribution> for Dirichlet { + fn sample(&self, rng: &mut R) -> Vec { + let n = self.alpha.len(); + let mut samples = vec![0.0f64; n]; + let mut sum = 0.0f64; + + for i in 0..n { + let g = Gamma::new(self.alpha[i], 1.0); + samples[i] = g.sample(rng); + sum += samples[i]; + } + let invacc = 1.0 / sum; + for i in 0..n { + samples[i] *= invacc; + } + samples + } +} + +#[cfg(test)] +mod test { + use super::Dirichlet; + use distributions::Distribution; + + #[test] + fn test_dirichlet() { + let d = Dirichlet::new(vec![1.0, 2.0, 3.0]); + let mut rng = ::test::rng(221); + let samples = d.sample(&mut rng); + let _: Vec = samples + .into_iter() + .map(|x| { + assert!(x > 0.0); + x + }) + .collect(); + } + + #[test] + fn test_dirichlet_with_param() { + let alpha = 0.5f64; + let size = 2; + let d = Dirichlet::new_with_param(alpha, size); + let mut rng = ::test::rng(221); + let samples = d.sample(&mut rng); + let _: Vec = samples + .into_iter() + .map(|x| { + assert!(x > 0.0); + x + }) + .collect(); + } + + #[test] + #[should_panic] + fn test_dirichlet_invalid_length() { + Dirichlet::new_with_param(0.5f64, 1); + } + + #[test] + #[should_panic] + fn test_dirichlet_invalid_alpha() { + Dirichlet::new_with_param(0.0f64, 2); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/exponential.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/exponential.rs new file mode 100644 index 0000000..76752a6 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/exponential.rs @@ -0,0 +1,124 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The exponential distribution. + +use {Rng}; +use distributions::{ziggurat_tables, Distribution}; +use distributions::utils::ziggurat; + +/// Samples floating-point numbers according to the exponential distribution, +/// with rate parameter `λ = 1`. This is equivalent to `Exp::new(1.0)` or +/// sampling with `-rng.gen::().ln()`, but faster. +/// +/// See `Exp` for the general exponential distribution. +/// +/// Implemented via the ZIGNOR variant[^1] of the Ziggurat method. The exact +/// description in the paper was adjusted to use tables for the exponential +/// distribution rather than normal. +/// +/// [^1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to +/// Generate Normal Random Samples*]( +/// https://www.doornik.com/research/ziggurat.pdf). +/// Nuffield College, Oxford +/// +/// # Example +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::Exp1; +/// +/// let val: f64 = SmallRng::from_entropy().sample(Exp1); +/// println!("{}", val); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Exp1; + +// This could be done via `-rng.gen::().ln()` but that is slower. +impl Distribution for Exp1 { + #[inline] + fn sample(&self, rng: &mut R) -> f64 { + #[inline] + fn pdf(x: f64) -> f64 { + (-x).exp() + } + #[inline] + fn zero_case(rng: &mut R, _u: f64) -> f64 { + ziggurat_tables::ZIG_EXP_R - rng.gen::().ln() + } + + ziggurat(rng, false, + &ziggurat_tables::ZIG_EXP_X, + &ziggurat_tables::ZIG_EXP_F, + pdf, zero_case) + } +} + +/// The exponential distribution `Exp(lambda)`. +/// +/// This distribution has density function: `f(x) = lambda * exp(-lambda * x)` +/// for `x > 0`. +/// +/// Note that [`Exp1`][crate::distributions::Exp1] is an optimised implementation for `lambda = 1`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Exp, Distribution}; +/// +/// let exp = Exp::new(2.0); +/// let v = exp.sample(&mut rand::thread_rng()); +/// println!("{} is from a Exp(2) distribution", v); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Exp { + /// `lambda` stored as `1/lambda`, since this is what we scale by. + lambda_inverse: f64 +} + +impl Exp { + /// Construct a new `Exp` with the given shape parameter + /// `lambda`. Panics if `lambda <= 0`. + #[inline] + pub fn new(lambda: f64) -> Exp { + assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0"); + Exp { lambda_inverse: 1.0 / lambda } + } +} + +impl Distribution for Exp { + fn sample(&self, rng: &mut R) -> f64 { + let n: f64 = rng.sample(Exp1); + n * self.lambda_inverse + } +} + +#[cfg(test)] +mod test { + use distributions::Distribution; + use super::Exp; + + #[test] + fn test_exp() { + let exp = Exp::new(10.0); + let mut rng = ::test::rng(221); + for _ in 0..1000 { + assert!(exp.sample(&mut rng) >= 0.0); + } + } + #[test] + #[should_panic] + fn test_exp_invalid_lambda_zero() { + Exp::new(0.0); + } + #[test] + #[should_panic] + fn test_exp_invalid_lambda_neg() { + Exp::new(-10.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/float.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/float.rs new file mode 100644 index 0000000..0dd5caa --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/float.rs @@ -0,0 +1,259 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Basic floating-point number distributions + +use core::mem; +use Rng; +use distributions::{Distribution, Standard}; +use distributions::utils::FloatSIMDUtils; +#[cfg(feature="simd_support")] +use packed_simd::*; + +/// A distribution to sample floating point numbers uniformly in the half-open +/// interval `(0, 1]`, i.e. including 1 but not 0. +/// +/// All values that can be generated are of the form `n * ε/2`. For `f32` +/// the 23 most significant random bits of a `u32` are used and for `f64` the +/// 53 most significant bits of a `u64` are used. The conversion uses the +/// multiplicative method. +/// +/// See also: [`Standard`] which samples from `[0, 1)`, [`Open01`] +/// which samples from `(0, 1)` and [`Uniform`] which samples from arbitrary +/// ranges. +/// +/// # Example +/// ``` +/// use rand::{thread_rng, Rng}; +/// use rand::distributions::OpenClosed01; +/// +/// let val: f32 = thread_rng().sample(OpenClosed01); +/// println!("f32 from (0, 1): {}", val); +/// ``` +/// +/// [`Standard`]: crate::distributions::Standard +/// [`Open01`]: crate::distributions::Open01 +/// [`Uniform`]: crate::distributions::uniform::Uniform +#[derive(Clone, Copy, Debug)] +pub struct OpenClosed01; + +/// A distribution to sample floating point numbers uniformly in the open +/// interval `(0, 1)`, i.e. not including either endpoint. +/// +/// All values that can be generated are of the form `n * ε + ε/2`. For `f32` +/// the 22 most significant random bits of an `u32` are used, for `f64` 52 from +/// an `u64`. The conversion uses a transmute-based method. +/// +/// See also: [`Standard`] which samples from `[0, 1)`, [`OpenClosed01`] +/// which samples from `(0, 1]` and [`Uniform`] which samples from arbitrary +/// ranges. +/// +/// # Example +/// ``` +/// use rand::{thread_rng, Rng}; +/// use rand::distributions::Open01; +/// +/// let val: f32 = thread_rng().sample(Open01); +/// println!("f32 from (0, 1): {}", val); +/// ``` +/// +/// [`Standard`]: crate::distributions::Standard +/// [`OpenClosed01`]: crate::distributions::OpenClosed01 +/// [`Uniform`]: crate::distributions::uniform::Uniform +#[derive(Clone, Copy, Debug)] +pub struct Open01; + + +pub(crate) trait IntoFloat { + type F; + + /// Helper method to combine the fraction and a contant exponent into a + /// float. + /// + /// Only the least significant bits of `self` may be set, 23 for `f32` and + /// 52 for `f64`. + /// The resulting value will fall in a range that depends on the exponent. + /// As an example the range with exponent 0 will be + /// [20..21), which is [1..2). + fn into_float_with_exponent(self, exponent: i32) -> Self::F; +} + +macro_rules! float_impls { + ($ty:ident, $uty:ident, $f_scalar:ident, $u_scalar:ty, + $fraction_bits:expr, $exponent_bias:expr) => { + impl IntoFloat for $uty { + type F = $ty; + #[inline(always)] + fn into_float_with_exponent(self, exponent: i32) -> $ty { + // The exponent is encoded using an offset-binary representation + let exponent_bits: $u_scalar = + (($exponent_bias + exponent) as $u_scalar) << $fraction_bits; + // TODO: use from_bits when min compiler > 1.25 (see #545) + // $ty::from_bits(self | exponent_bits) + unsafe{ mem::transmute(self | exponent_bits) } + } + } + + impl Distribution<$ty> for Standard { + fn sample(&self, rng: &mut R) -> $ty { + // Multiply-based method; 24/53 random bits; [0, 1) interval. + // We use the most significant bits because for simple RNGs + // those are usually more random. + let float_size = mem::size_of::<$f_scalar>() as u32 * 8; + let precision = $fraction_bits + 1; + let scale = 1.0 / ((1 as $u_scalar << precision) as $f_scalar); + + let value: $uty = rng.gen(); + let value = value >> (float_size - precision); + scale * $ty::cast_from_int(value) + } + } + + impl Distribution<$ty> for OpenClosed01 { + fn sample(&self, rng: &mut R) -> $ty { + // Multiply-based method; 24/53 random bits; (0, 1] interval. + // We use the most significant bits because for simple RNGs + // those are usually more random. + let float_size = mem::size_of::<$f_scalar>() as u32 * 8; + let precision = $fraction_bits + 1; + let scale = 1.0 / ((1 as $u_scalar << precision) as $f_scalar); + + let value: $uty = rng.gen(); + let value = value >> (float_size - precision); + // Add 1 to shift up; will not overflow because of right-shift: + scale * $ty::cast_from_int(value + 1) + } + } + + impl Distribution<$ty> for Open01 { + fn sample(&self, rng: &mut R) -> $ty { + // Transmute-based method; 23/52 random bits; (0, 1) interval. + // We use the most significant bits because for simple RNGs + // those are usually more random. + use core::$f_scalar::EPSILON; + let float_size = mem::size_of::<$f_scalar>() as u32 * 8; + + let value: $uty = rng.gen(); + let fraction = value >> (float_size - $fraction_bits); + fraction.into_float_with_exponent(0) - (1.0 - EPSILON / 2.0) + } + } + } +} + +float_impls! { f32, u32, f32, u32, 23, 127 } +float_impls! { f64, u64, f64, u64, 52, 1023 } + +#[cfg(feature="simd_support")] +float_impls! { f32x2, u32x2, f32, u32, 23, 127 } +#[cfg(feature="simd_support")] +float_impls! { f32x4, u32x4, f32, u32, 23, 127 } +#[cfg(feature="simd_support")] +float_impls! { f32x8, u32x8, f32, u32, 23, 127 } +#[cfg(feature="simd_support")] +float_impls! { f32x16, u32x16, f32, u32, 23, 127 } + +#[cfg(feature="simd_support")] +float_impls! { f64x2, u64x2, f64, u64, 52, 1023 } +#[cfg(feature="simd_support")] +float_impls! { f64x4, u64x4, f64, u64, 52, 1023 } +#[cfg(feature="simd_support")] +float_impls! { f64x8, u64x8, f64, u64, 52, 1023 } + + +#[cfg(test)] +mod tests { + use Rng; + use distributions::{Open01, OpenClosed01}; + use rngs::mock::StepRng; + #[cfg(feature="simd_support")] + use packed_simd::*; + + const EPSILON32: f32 = ::core::f32::EPSILON; + const EPSILON64: f64 = ::core::f64::EPSILON; + + macro_rules! test_f32 { + ($fnn:ident, $ty:ident, $ZERO:expr, $EPSILON:expr) => { + #[test] + fn $fnn() { + // Standard + let mut zeros = StepRng::new(0, 0); + assert_eq!(zeros.gen::<$ty>(), $ZERO); + let mut one = StepRng::new(1 << 8 | 1 << (8 + 32), 0); + assert_eq!(one.gen::<$ty>(), $EPSILON / 2.0); + let mut max = StepRng::new(!0, 0); + assert_eq!(max.gen::<$ty>(), 1.0 - $EPSILON / 2.0); + + // OpenClosed01 + let mut zeros = StepRng::new(0, 0); + assert_eq!(zeros.sample::<$ty, _>(OpenClosed01), + 0.0 + $EPSILON / 2.0); + let mut one = StepRng::new(1 << 8 | 1 << (8 + 32), 0); + assert_eq!(one.sample::<$ty, _>(OpenClosed01), $EPSILON); + let mut max = StepRng::new(!0, 0); + assert_eq!(max.sample::<$ty, _>(OpenClosed01), $ZERO + 1.0); + + // Open01 + let mut zeros = StepRng::new(0, 0); + assert_eq!(zeros.sample::<$ty, _>(Open01), 0.0 + $EPSILON / 2.0); + let mut one = StepRng::new(1 << 9 | 1 << (9 + 32), 0); + assert_eq!(one.sample::<$ty, _>(Open01), $EPSILON / 2.0 * 3.0); + let mut max = StepRng::new(!0, 0); + assert_eq!(max.sample::<$ty, _>(Open01), 1.0 - $EPSILON / 2.0); + } + } + } + test_f32! { f32_edge_cases, f32, 0.0, EPSILON32 } + #[cfg(feature="simd_support")] + test_f32! { f32x2_edge_cases, f32x2, f32x2::splat(0.0), f32x2::splat(EPSILON32) } + #[cfg(feature="simd_support")] + test_f32! { f32x4_edge_cases, f32x4, f32x4::splat(0.0), f32x4::splat(EPSILON32) } + #[cfg(feature="simd_support")] + test_f32! { f32x8_edge_cases, f32x8, f32x8::splat(0.0), f32x8::splat(EPSILON32) } + #[cfg(feature="simd_support")] + test_f32! { f32x16_edge_cases, f32x16, f32x16::splat(0.0), f32x16::splat(EPSILON32) } + + macro_rules! test_f64 { + ($fnn:ident, $ty:ident, $ZERO:expr, $EPSILON:expr) => { + #[test] + fn $fnn() { + // Standard + let mut zeros = StepRng::new(0, 0); + assert_eq!(zeros.gen::<$ty>(), $ZERO); + let mut one = StepRng::new(1 << 11, 0); + assert_eq!(one.gen::<$ty>(), $EPSILON / 2.0); + let mut max = StepRng::new(!0, 0); + assert_eq!(max.gen::<$ty>(), 1.0 - $EPSILON / 2.0); + + // OpenClosed01 + let mut zeros = StepRng::new(0, 0); + assert_eq!(zeros.sample::<$ty, _>(OpenClosed01), + 0.0 + $EPSILON / 2.0); + let mut one = StepRng::new(1 << 11, 0); + assert_eq!(one.sample::<$ty, _>(OpenClosed01), $EPSILON); + let mut max = StepRng::new(!0, 0); + assert_eq!(max.sample::<$ty, _>(OpenClosed01), $ZERO + 1.0); + + // Open01 + let mut zeros = StepRng::new(0, 0); + assert_eq!(zeros.sample::<$ty, _>(Open01), 0.0 + $EPSILON / 2.0); + let mut one = StepRng::new(1 << 12, 0); + assert_eq!(one.sample::<$ty, _>(Open01), $EPSILON / 2.0 * 3.0); + let mut max = StepRng::new(!0, 0); + assert_eq!(max.sample::<$ty, _>(Open01), 1.0 - $EPSILON / 2.0); + } + } + } + test_f64! { f64_edge_cases, f64, 0.0, EPSILON64 } + #[cfg(feature="simd_support")] + test_f64! { f64x2_edge_cases, f64x2, f64x2::splat(0.0), f64x2::splat(EPSILON64) } + #[cfg(feature="simd_support")] + test_f64! { f64x4_edge_cases, f64x4, f64x4::splat(0.0), f64x4::splat(EPSILON64) } + #[cfg(feature="simd_support")] + test_f64! { f64x8_edge_cases, f64x8, f64x8::splat(0.0), f64x8::splat(EPSILON64) } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/gamma.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/gamma.rs new file mode 100644 index 0000000..43ac2bc --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/gamma.rs @@ -0,0 +1,413 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Gamma and derived distributions. + +use self::GammaRepr::*; +use self::ChiSquaredRepr::*; + +use Rng; +use distributions::normal::StandardNormal; +use distributions::{Distribution, Exp, Open01}; + +/// The Gamma distribution `Gamma(shape, scale)` distribution. +/// +/// The density function of this distribution is +/// +/// ```text +/// f(x) = x^(k - 1) * exp(-x / θ) / (Γ(k) * θ^k) +/// ``` +/// +/// where `Γ` is the Gamma function, `k` is the shape and `θ` is the +/// scale and both `k` and `θ` are strictly positive. +/// +/// The algorithm used is that described by Marsaglia & Tsang 2000[^1], +/// falling back to directly sampling from an Exponential for `shape +/// == 1`, and using the boosting technique described in that paper for +/// `shape < 1`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Distribution, Gamma}; +/// +/// let gamma = Gamma::new(2.0, 5.0); +/// let v = gamma.sample(&mut rand::thread_rng()); +/// println!("{} is from a Gamma(2, 5) distribution", v); +/// ``` +/// +/// [^1]: George Marsaglia and Wai Wan Tsang. 2000. "A Simple Method for +/// Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3 +/// (September 2000), 363-372. +/// DOI:[10.1145/358407.358414](https://doi.acm.org/10.1145/358407.358414) +#[derive(Clone, Copy, Debug)] +pub struct Gamma { + repr: GammaRepr, +} + +#[derive(Clone, Copy, Debug)] +enum GammaRepr { + Large(GammaLargeShape), + One(Exp), + Small(GammaSmallShape) +} + +// These two helpers could be made public, but saving the +// match-on-Gamma-enum branch from using them directly (e.g. if one +// knows that the shape is always > 1) doesn't appear to be much +// faster. + +/// Gamma distribution where the shape parameter is less than 1. +/// +/// Note, samples from this require a compulsory floating-point `pow` +/// call, which makes it significantly slower than sampling from a +/// gamma distribution where the shape parameter is greater than or +/// equal to 1. +/// +/// See `Gamma` for sampling from a Gamma distribution with general +/// shape parameters. +#[derive(Clone, Copy, Debug)] +struct GammaSmallShape { + inv_shape: f64, + large_shape: GammaLargeShape +} + +/// Gamma distribution where the shape parameter is larger than 1. +/// +/// See `Gamma` for sampling from a Gamma distribution with general +/// shape parameters. +#[derive(Clone, Copy, Debug)] +struct GammaLargeShape { + scale: f64, + c: f64, + d: f64 +} + +impl Gamma { + /// Construct an object representing the `Gamma(shape, scale)` + /// distribution. + /// + /// Panics if `shape <= 0` or `scale <= 0`. + #[inline] + pub fn new(shape: f64, scale: f64) -> Gamma { + assert!(shape > 0.0, "Gamma::new called with shape <= 0"); + assert!(scale > 0.0, "Gamma::new called with scale <= 0"); + + let repr = if shape == 1.0 { + One(Exp::new(1.0 / scale)) + } else if shape < 1.0 { + Small(GammaSmallShape::new_raw(shape, scale)) + } else { + Large(GammaLargeShape::new_raw(shape, scale)) + }; + Gamma { repr } + } +} + +impl GammaSmallShape { + fn new_raw(shape: f64, scale: f64) -> GammaSmallShape { + GammaSmallShape { + inv_shape: 1. / shape, + large_shape: GammaLargeShape::new_raw(shape + 1.0, scale) + } + } +} + +impl GammaLargeShape { + fn new_raw(shape: f64, scale: f64) -> GammaLargeShape { + let d = shape - 1. / 3.; + GammaLargeShape { + scale, + c: 1. / (9. * d).sqrt(), + d + } + } +} + +impl Distribution for Gamma { + fn sample(&self, rng: &mut R) -> f64 { + match self.repr { + Small(ref g) => g.sample(rng), + One(ref g) => g.sample(rng), + Large(ref g) => g.sample(rng), + } + } +} +impl Distribution for GammaSmallShape { + fn sample(&self, rng: &mut R) -> f64 { + let u: f64 = rng.sample(Open01); + + self.large_shape.sample(rng) * u.powf(self.inv_shape) + } +} +impl Distribution for GammaLargeShape { + fn sample(&self, rng: &mut R) -> f64 { + loop { + let x = rng.sample(StandardNormal); + let v_cbrt = 1.0 + self.c * x; + if v_cbrt <= 0.0 { // a^3 <= 0 iff a <= 0 + continue + } + + let v = v_cbrt * v_cbrt * v_cbrt; + let u: f64 = rng.sample(Open01); + + let x_sqr = x * x; + if u < 1.0 - 0.0331 * x_sqr * x_sqr || + u.ln() < 0.5 * x_sqr + self.d * (1.0 - v + v.ln()) { + return self.d * v * self.scale + } + } + } +} + +/// The chi-squared distribution `χ²(k)`, where `k` is the degrees of +/// freedom. +/// +/// For `k > 0` integral, this distribution is the sum of the squares +/// of `k` independent standard normal random variables. For other +/// `k`, this uses the equivalent characterisation +/// `χ²(k) = Gamma(k/2, 2)`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{ChiSquared, Distribution}; +/// +/// let chi = ChiSquared::new(11.0); +/// let v = chi.sample(&mut rand::thread_rng()); +/// println!("{} is from a χ²(11) distribution", v) +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct ChiSquared { + repr: ChiSquaredRepr, +} + +#[derive(Clone, Copy, Debug)] +enum ChiSquaredRepr { + // k == 1, Gamma(alpha, ..) is particularly slow for alpha < 1, + // e.g. when alpha = 1/2 as it would be for this case, so special- + // casing and using the definition of N(0,1)^2 is faster. + DoFExactlyOne, + DoFAnythingElse(Gamma), +} + +impl ChiSquared { + /// Create a new chi-squared distribution with degrees-of-freedom + /// `k`. Panics if `k < 0`. + pub fn new(k: f64) -> ChiSquared { + let repr = if k == 1.0 { + DoFExactlyOne + } else { + assert!(k > 0.0, "ChiSquared::new called with `k` < 0"); + DoFAnythingElse(Gamma::new(0.5 * k, 2.0)) + }; + ChiSquared { repr } + } +} +impl Distribution for ChiSquared { + fn sample(&self, rng: &mut R) -> f64 { + match self.repr { + DoFExactlyOne => { + // k == 1 => N(0,1)^2 + let norm = rng.sample(StandardNormal); + norm * norm + } + DoFAnythingElse(ref g) => g.sample(rng) + } + } +} + +/// The Fisher F distribution `F(m, n)`. +/// +/// This distribution is equivalent to the ratio of two normalised +/// chi-squared distributions, that is, `F(m,n) = (χ²(m)/m) / +/// (χ²(n)/n)`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{FisherF, Distribution}; +/// +/// let f = FisherF::new(2.0, 32.0); +/// let v = f.sample(&mut rand::thread_rng()); +/// println!("{} is from an F(2, 32) distribution", v) +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct FisherF { + numer: ChiSquared, + denom: ChiSquared, + // denom_dof / numer_dof so that this can just be a straight + // multiplication, rather than a division. + dof_ratio: f64, +} + +impl FisherF { + /// Create a new `FisherF` distribution, with the given + /// parameter. Panics if either `m` or `n` are not positive. + pub fn new(m: f64, n: f64) -> FisherF { + assert!(m > 0.0, "FisherF::new called with `m < 0`"); + assert!(n > 0.0, "FisherF::new called with `n < 0`"); + + FisherF { + numer: ChiSquared::new(m), + denom: ChiSquared::new(n), + dof_ratio: n / m + } + } +} +impl Distribution for FisherF { + fn sample(&self, rng: &mut R) -> f64 { + self.numer.sample(rng) / self.denom.sample(rng) * self.dof_ratio + } +} + +/// The Student t distribution, `t(nu)`, where `nu` is the degrees of +/// freedom. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{StudentT, Distribution}; +/// +/// let t = StudentT::new(11.0); +/// let v = t.sample(&mut rand::thread_rng()); +/// println!("{} is from a t(11) distribution", v) +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct StudentT { + chi: ChiSquared, + dof: f64 +} + +impl StudentT { + /// Create a new Student t distribution with `n` degrees of + /// freedom. Panics if `n <= 0`. + pub fn new(n: f64) -> StudentT { + assert!(n > 0.0, "StudentT::new called with `n <= 0`"); + StudentT { + chi: ChiSquared::new(n), + dof: n + } + } +} +impl Distribution for StudentT { + fn sample(&self, rng: &mut R) -> f64 { + let norm = rng.sample(StandardNormal); + norm * (self.dof / self.chi.sample(rng)).sqrt() + } +} + +/// The Beta distribution with shape parameters `alpha` and `beta`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Distribution, Beta}; +/// +/// let beta = Beta::new(2.0, 5.0); +/// let v = beta.sample(&mut rand::thread_rng()); +/// println!("{} is from a Beta(2, 5) distribution", v); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Beta { + gamma_a: Gamma, + gamma_b: Gamma, +} + +impl Beta { + /// Construct an object representing the `Beta(alpha, beta)` + /// distribution. + /// + /// Panics if `shape <= 0` or `scale <= 0`. + pub fn new(alpha: f64, beta: f64) -> Beta { + assert!((alpha > 0.) & (beta > 0.)); + Beta { + gamma_a: Gamma::new(alpha, 1.), + gamma_b: Gamma::new(beta, 1.), + } + } +} + +impl Distribution for Beta { + fn sample(&self, rng: &mut R) -> f64 { + let x = self.gamma_a.sample(rng); + let y = self.gamma_b.sample(rng); + x / (x + y) + } +} + +#[cfg(test)] +mod test { + use distributions::Distribution; + use super::{Beta, ChiSquared, StudentT, FisherF}; + + #[test] + fn test_chi_squared_one() { + let chi = ChiSquared::new(1.0); + let mut rng = ::test::rng(201); + for _ in 0..1000 { + chi.sample(&mut rng); + } + } + #[test] + fn test_chi_squared_small() { + let chi = ChiSquared::new(0.5); + let mut rng = ::test::rng(202); + for _ in 0..1000 { + chi.sample(&mut rng); + } + } + #[test] + fn test_chi_squared_large() { + let chi = ChiSquared::new(30.0); + let mut rng = ::test::rng(203); + for _ in 0..1000 { + chi.sample(&mut rng); + } + } + #[test] + #[should_panic] + fn test_chi_squared_invalid_dof() { + ChiSquared::new(-1.0); + } + + #[test] + fn test_f() { + let f = FisherF::new(2.0, 32.0); + let mut rng = ::test::rng(204); + for _ in 0..1000 { + f.sample(&mut rng); + } + } + + #[test] + fn test_t() { + let t = StudentT::new(11.0); + let mut rng = ::test::rng(205); + for _ in 0..1000 { + t.sample(&mut rng); + } + } + + #[test] + fn test_beta() { + let beta = Beta::new(1.0, 2.0); + let mut rng = ::test::rng(201); + for _ in 0..1000 { + beta.sample(&mut rng); + } + } + + #[test] + #[should_panic] + fn test_beta_invalid_dof() { + Beta::new(0., 0.); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/integer.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/integer.rs new file mode 100644 index 0000000..7e408db --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/integer.rs @@ -0,0 +1,161 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The implementations of the `Standard` distribution for integer types. + +use {Rng}; +use distributions::{Distribution, Standard}; +#[cfg(feature="simd_support")] +use packed_simd::*; +#[cfg(all(target_arch = "x86", feature="nightly"))] +use core::arch::x86::*; +#[cfg(all(target_arch = "x86_64", feature="nightly"))] +use core::arch::x86_64::*; + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> u8 { + rng.next_u32() as u8 + } +} + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> u16 { + rng.next_u32() as u16 + } +} + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> u32 { + rng.next_u32() + } +} + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> u64 { + rng.next_u64() + } +} + +#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> u128 { + // Use LE; we explicitly generate one value before the next. + let x = rng.next_u64() as u128; + let y = rng.next_u64() as u128; + (y << 64) | x + } +} + +impl Distribution for Standard { + #[inline] + #[cfg(any(target_pointer_width = "32", target_pointer_width = "16"))] + fn sample(&self, rng: &mut R) -> usize { + rng.next_u32() as usize + } + + #[inline] + #[cfg(target_pointer_width = "64")] + fn sample(&self, rng: &mut R) -> usize { + rng.next_u64() as usize + } +} + +macro_rules! impl_int_from_uint { + ($ty:ty, $uty:ty) => { + impl Distribution<$ty> for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> $ty { + rng.gen::<$uty>() as $ty + } + } + } +} + +impl_int_from_uint! { i8, u8 } +impl_int_from_uint! { i16, u16 } +impl_int_from_uint! { i32, u32 } +impl_int_from_uint! { i64, u64 } +#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] impl_int_from_uint! { i128, u128 } +impl_int_from_uint! { isize, usize } + +#[cfg(feature="simd_support")] +macro_rules! simd_impl { + ($(($intrinsic:ident, $vec:ty),)+) => {$( + impl Distribution<$intrinsic> for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> $intrinsic { + $intrinsic::from_bits(rng.gen::<$vec>()) + } + } + )+}; + + ($bits:expr,) => {}; + ($bits:expr, $ty:ty, $($ty_more:ty,)*) => { + simd_impl!($bits, $($ty_more,)*); + + impl Distribution<$ty> for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> $ty { + let mut vec: $ty = Default::default(); + unsafe { + let ptr = &mut vec; + let b_ptr = &mut *(ptr as *mut $ty as *mut [u8; $bits/8]); + rng.fill_bytes(b_ptr); + } + vec.to_le() + } + } + }; +} + +#[cfg(feature="simd_support")] +simd_impl!(16, u8x2, i8x2,); +#[cfg(feature="simd_support")] +simd_impl!(32, u8x4, i8x4, u16x2, i16x2,); +#[cfg(feature="simd_support")] +simd_impl!(64, u8x8, i8x8, u16x4, i16x4, u32x2, i32x2,); +#[cfg(feature="simd_support")] +simd_impl!(128, u8x16, i8x16, u16x8, i16x8, u32x4, i32x4, u64x2, i64x2,); +#[cfg(feature="simd_support")] +simd_impl!(256, u8x32, i8x32, u16x16, i16x16, u32x8, i32x8, u64x4, i64x4,); +#[cfg(feature="simd_support")] +simd_impl!(512, u8x64, i8x64, u16x32, i16x32, u32x16, i32x16, u64x8, i64x8,); +#[cfg(all(feature="simd_support", feature="nightly", any(target_arch="x86", target_arch="x86_64")))] +simd_impl!((__m64, u8x8), (__m128i, u8x16), (__m256i, u8x32),); + +#[cfg(test)] +mod tests { + use Rng; + use distributions::{Standard}; + + #[test] + fn test_integers() { + let mut rng = ::test::rng(806); + + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + #[cfg(all(rustc_1_26, not(target_os = "emscripten")))] + rng.sample::(Standard); + + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + rng.sample::(Standard); + #[cfg(all(rustc_1_26, not(target_os = "emscripten")))] + rng.sample::(Standard); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/mod.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/mod.rs new file mode 100644 index 0000000..6e2d6c7 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/mod.rs @@ -0,0 +1,608 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2017 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Generating random samples from probability distributions. +//! +//! This module is the home of the [`Distribution`] trait and several of its +//! implementations. It is the workhorse behind some of the convenient +//! functionality of the [`Rng`] trait, including [`gen`], [`gen_range`] and +//! of course [`sample`]. +//! +//! Abstractly, a [probability distribution] describes the probability of +//! occurance of each value in its sample space. +//! +//! More concretely, an implementation of `Distribution` for type `X` is an +//! algorithm for choosing values from the sample space (a subset of `T`) +//! according to the distribution `X` represents, using an external source of +//! randomness (an RNG supplied to the `sample` function). +//! +//! A type `X` may implement `Distribution` for multiple types `T`. +//! Any type implementing [`Distribution`] is stateless (i.e. immutable), +//! but it may have internal parameters set at construction time (for example, +//! [`Uniform`] allows specification of its sample space as a range within `T`). +//! +//! +//! # The `Standard` distribution +//! +//! The [`Standard`] distribution is important to mention. This is the +//! distribution used by [`Rng::gen()`] and represents the "default" way to +//! produce a random value for many different types, including most primitive +//! types, tuples, arrays, and a few derived types. See the documentation of +//! [`Standard`] for more details. +//! +//! Implementing `Distribution` for [`Standard`] for user types `T` makes it +//! possible to generate type `T` with [`Rng::gen()`], and by extension also +//! with the [`random()`] function. +//! +//! +//! # Distribution to sample from a `Uniform` range +//! +//! The [`Uniform`] distribution is more flexible than [`Standard`], but also +//! more specialised: it supports fewer target types, but allows the sample +//! space to be specified as an arbitrary range within its target type `T`. +//! Both [`Standard`] and [`Uniform`] are in some sense uniform distributions. +//! +//! Values may be sampled from this distribution using [`Rng::gen_range`] or +//! by creating a distribution object with [`Uniform::new`], +//! [`Uniform::new_inclusive`] or `From`. When the range limits are not +//! known at compile time it is typically faster to reuse an existing +//! distribution object than to call [`Rng::gen_range`]. +//! +//! User types `T` may also implement `Distribution` for [`Uniform`], +//! although this is less straightforward than for [`Standard`] (see the +//! documentation in the [`uniform`] module. Doing so enables generation of +//! values of type `T` with [`Rng::gen_range`]. +//! +//! +//! # Other distributions +//! +//! There are surprisingly many ways to uniformly generate random floats. A +//! range between 0 and 1 is standard, but the exact bounds (open vs closed) +//! and accuracy differ. In addition to the [`Standard`] distribution Rand offers +//! [`Open01`] and [`OpenClosed01`]. See "Floating point implementation" section of +//! [`Standard`] documentation for more details. +//! +//! [`Alphanumeric`] is a simple distribution to sample random letters and +//! numbers of the `char` type; in contrast [`Standard`] may sample any valid +//! `char`. +//! +//! [`WeightedIndex`] can be used to do weighted sampling from a set of items, +//! such as from an array. +//! +//! # Non-uniform probability distributions +//! +//! Rand currently provides the following probability distributions: +//! +//! - Related to real-valued quantities that grow linearly +//! (e.g. errors, offsets): +//! - [`Normal`] distribution, and [`StandardNormal`] as a primitive +//! - [`Cauchy`] distribution +//! - Related to Bernoulli trials (yes/no events, with a given probability): +//! - [`Binomial`] distribution +//! - [`Bernoulli`] distribution, similar to [`Rng::gen_bool`]. +//! - Related to positive real-valued quantities that grow exponentially +//! (e.g. prices, incomes, populations): +//! - [`LogNormal`] distribution +//! - Related to the occurrence of independent events at a given rate: +//! - [`Pareto`] distribution +//! - [`Poisson`] distribution +//! - [`Exp`]onential distribution, and [`Exp1`] as a primitive +//! - [`Weibull`] distribution +//! - Gamma and derived distributions: +//! - [`Gamma`] distribution +//! - [`ChiSquared`] distribution +//! - [`StudentT`] distribution +//! - [`FisherF`] distribution +//! - Triangular distribution: +//! - [`Beta`] distribution +//! - [`Triangular`] distribution +//! - Multivariate probability distributions +//! - [`Dirichlet`] distribution +//! - [`UnitSphereSurface`] distribution +//! - [`UnitCircle`] distribution +//! +//! # Examples +//! +//! Sampling from a distribution: +//! +//! ``` +//! use rand::{thread_rng, Rng}; +//! use rand::distributions::Exp; +//! +//! let exp = Exp::new(2.0); +//! let v = thread_rng().sample(exp); +//! println!("{} is from an Exp(2) distribution", v); +//! ``` +//! +//! Implementing the [`Standard`] distribution for a user type: +//! +//! ``` +//! # #![allow(dead_code)] +//! use rand::Rng; +//! use rand::distributions::{Distribution, Standard}; +//! +//! struct MyF32 { +//! x: f32, +//! } +//! +//! impl Distribution for Standard { +//! fn sample(&self, rng: &mut R) -> MyF32 { +//! MyF32 { x: rng.gen() } +//! } +//! } +//! ``` +//! +//! +//! [probability distribution]: https://en.wikipedia.org/wiki/Probability_distribution +//! [`gen_range`]: Rng::gen_range +//! [`gen`]: Rng::gen +//! [`sample`]: Rng::sample +//! [`new_inclusive`]: Uniform::new_inclusive +//! [`Alphanumeric`]: distributions::Alphanumeric +//! [`Bernoulli`]: distributions::Bernoulli +//! [`Beta`]: distributions::Beta +//! [`Binomial`]: distributions::Binomial +//! [`Cauchy`]: distributions::Cauchy +//! [`ChiSquared`]: distributions::ChiSquared +//! [`Dirichlet`]: distributions::Dirichlet +//! [`Exp`]: distributions::Exp +//! [`Exp1`]: distributions::Exp1 +//! [`FisherF`]: distributions::FisherF +//! [`Gamma`]: distributions::Gamma +//! [`LogNormal`]: distributions::LogNormal +//! [`Normal`]: distributions::Normal +//! [`Open01`]: distributions::Open01 +//! [`OpenClosed01`]: distributions::OpenClosed01 +//! [`Pareto`]: distributions::Pareto +//! [`Poisson`]: distributions::Poisson +//! [`Standard`]: distributions::Standard +//! [`StandardNormal`]: distributions::StandardNormal +//! [`StudentT`]: distributions::StudentT +//! [`Triangular`]: distributions::Triangular +//! [`Uniform`]: distributions::Uniform +//! [`Uniform::new`]: distributions::Uniform::new +//! [`Uniform::new_inclusive`]: distributions::Uniform::new_inclusive +//! [`UnitSphereSurface`]: distributions::UnitSphereSurface +//! [`UnitCircle`]: distributions::UnitCircle +//! [`Weibull`]: distributions::Weibull +//! [`WeightedIndex`]: distributions::WeightedIndex + +#[cfg(any(rustc_1_26, features="nightly"))] +use core::iter; +use Rng; + +pub use self::other::Alphanumeric; +#[doc(inline)] pub use self::uniform::Uniform; +pub use self::float::{OpenClosed01, Open01}; +pub use self::bernoulli::Bernoulli; +#[cfg(feature="alloc")] pub use self::weighted::{WeightedIndex, WeightedError}; +#[cfg(feature="std")] pub use self::unit_sphere::UnitSphereSurface; +#[cfg(feature="std")] pub use self::unit_circle::UnitCircle; +#[cfg(feature="std")] pub use self::gamma::{Gamma, ChiSquared, FisherF, + StudentT, Beta}; +#[cfg(feature="std")] pub use self::normal::{Normal, LogNormal, StandardNormal}; +#[cfg(feature="std")] pub use self::exponential::{Exp, Exp1}; +#[cfg(feature="std")] pub use self::pareto::Pareto; +#[cfg(feature="std")] pub use self::poisson::Poisson; +#[cfg(feature="std")] pub use self::binomial::Binomial; +#[cfg(feature="std")] pub use self::cauchy::Cauchy; +#[cfg(feature="std")] pub use self::dirichlet::Dirichlet; +#[cfg(feature="std")] pub use self::triangular::Triangular; +#[cfg(feature="std")] pub use self::weibull::Weibull; + +pub mod uniform; +mod bernoulli; +#[cfg(feature="alloc")] mod weighted; +#[cfg(feature="std")] mod unit_sphere; +#[cfg(feature="std")] mod unit_circle; +#[cfg(feature="std")] mod gamma; +#[cfg(feature="std")] mod normal; +#[cfg(feature="std")] mod exponential; +#[cfg(feature="std")] mod pareto; +#[cfg(feature="std")] mod poisson; +#[cfg(feature="std")] mod binomial; +#[cfg(feature="std")] mod cauchy; +#[cfg(feature="std")] mod dirichlet; +#[cfg(feature="std")] mod triangular; +#[cfg(feature="std")] mod weibull; + +mod float; +mod integer; +mod other; +mod utils; +#[cfg(feature="std")] mod ziggurat_tables; + +/// Types (distributions) that can be used to create a random instance of `T`. +/// +/// It is possible to sample from a distribution through both the +/// `Distribution` and [`Rng`] traits, via `distr.sample(&mut rng)` and +/// `rng.sample(distr)`. They also both offer the [`sample_iter`] method, which +/// produces an iterator that samples from the distribution. +/// +/// All implementations are expected to be immutable; this has the significant +/// advantage of not needing to consider thread safety, and for most +/// distributions efficient state-less sampling algorithms are available. +/// +/// [`sample_iter`]: Distribution::method.sample_iter +pub trait Distribution { + /// Generate a random value of `T`, using `rng` as the source of randomness. + fn sample(&self, rng: &mut R) -> T; + + /// Create an iterator that generates random values of `T`, using `rng` as + /// the source of randomness. + /// + /// # Example + /// + /// ``` + /// use rand::thread_rng; + /// use rand::distributions::{Distribution, Alphanumeric, Uniform, Standard}; + /// + /// let mut rng = thread_rng(); + /// + /// // Vec of 16 x f32: + /// let v: Vec = Standard.sample_iter(&mut rng).take(16).collect(); + /// + /// // String: + /// let s: String = Alphanumeric.sample_iter(&mut rng).take(7).collect(); + /// + /// // Dice-rolling: + /// let die_range = Uniform::new_inclusive(1, 6); + /// let mut roll_die = die_range.sample_iter(&mut rng); + /// while roll_die.next().unwrap() != 6 { + /// println!("Not a 6; rolling again!"); + /// } + /// ``` + fn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> + where Self: Sized, R: Rng + { + DistIter { + distr: self, + rng: rng, + phantom: ::core::marker::PhantomData, + } + } +} + +impl<'a, T, D: Distribution> Distribution for &'a D { + fn sample(&self, rng: &mut R) -> T { + (*self).sample(rng) + } +} + + +/// An iterator that generates random values of `T` with distribution `D`, +/// using `R` as the source of randomness. +/// +/// This `struct` is created by the [`sample_iter`] method on [`Distribution`]. +/// See its documentation for more. +/// +/// [`sample_iter`]: Distribution::sample_iter +#[derive(Debug)] +pub struct DistIter<'a, D: 'a, R: 'a, T> { + distr: &'a D, + rng: &'a mut R, + phantom: ::core::marker::PhantomData, +} + +impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> + where D: Distribution, R: Rng + 'a +{ + type Item = T; + + #[inline(always)] + fn next(&mut self) -> Option { + Some(self.distr.sample(self.rng)) + } + + fn size_hint(&self) -> (usize, Option) { + (usize::max_value(), None) + } +} + +#[cfg(rustc_1_26)] +impl<'a, D, R, T> iter::FusedIterator for DistIter<'a, D, R, T> + where D: Distribution, R: Rng + 'a {} + +#[cfg(features = "nightly")] +impl<'a, D, R, T> iter::TrustedLen for DistIter<'a, D, R, T> + where D: Distribution, R: Rng + 'a {} + + +/// A generic random value distribution, implemented for many primitive types. +/// Usually generates values with a numerically uniform distribution, and with a +/// range appropriate to the type. +/// +/// ## Built-in Implementations +/// +/// Assuming the provided `Rng` is well-behaved, these implementations +/// generate values with the following ranges and distributions: +/// +/// * Integers (`i32`, `u32`, `isize`, `usize`, etc.): Uniformly distributed +/// over all values of the type. +/// * `char`: Uniformly distributed over all Unicode scalar values, i.e. all +/// code points in the range `0...0x10_FFFF`, except for the range +/// `0xD800...0xDFFF` (the surrogate code points). This includes +/// unassigned/reserved code points. +/// * `bool`: Generates `false` or `true`, each with probability 0.5. +/// * Floating point types (`f32` and `f64`): Uniformly distributed in the +/// half-open range `[0, 1)`. See notes below. +/// * Wrapping integers (`Wrapping`), besides the type identical to their +/// normal integer variants. +/// +/// The following aggregate types also implement the distribution `Standard` as +/// long as their component types implement it: +/// +/// * Tuples and arrays: Each element of the tuple or array is generated +/// independently, using the `Standard` distribution recursively. +/// * `Option` where `Standard` is implemented for `T`: Returns `None` with +/// probability 0.5; otherwise generates a random `x: T` and returns `Some(x)`. +/// +/// # Example +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::Standard; +/// +/// let val: f32 = SmallRng::from_entropy().sample(Standard); +/// println!("f32 from [0, 1): {}", val); +/// ``` +/// +/// # Floating point implementation +/// The floating point implementations for `Standard` generate a random value in +/// the half-open interval `[0, 1)`, i.e. including 0 but not 1. +/// +/// All values that can be generated are of the form `n * ε/2`. For `f32` +/// the 23 most significant random bits of a `u32` are used and for `f64` the +/// 53 most significant bits of a `u64` are used. The conversion uses the +/// multiplicative method: `(rng.gen::<$uty>() >> N) as $ty * (ε/2)`. +/// +/// See also: [`Open01`] which samples from `(0, 1)`, [`OpenClosed01`] which +/// samples from `(0, 1]` and `Rng::gen_range(0, 1)` which also samples from +/// `[0, 1)`. Note that `Open01` and `gen_range` (which uses [`Uniform`]) use +/// transmute-based methods which yield 1 bit less precision but may perform +/// faster on some architectures (on modern Intel CPUs all methods have +/// approximately equal performance). +/// +/// [`Uniform`]: uniform::Uniform +#[derive(Clone, Copy, Debug)] +pub struct Standard; + + +/// A value with a particular weight for use with `WeightedChoice`. +#[deprecated(since="0.6.0", note="use WeightedIndex instead")] +#[allow(deprecated)] +#[derive(Copy, Clone, Debug)] +pub struct Weighted { + /// The numerical weight of this item + pub weight: u32, + /// The actual item which is being weighted + pub item: T, +} + +/// A distribution that selects from a finite collection of weighted items. +/// +/// Deprecated: use [`WeightedIndex`] instead. +/// +/// [`WeightedIndex`]: WeightedIndex +#[deprecated(since="0.6.0", note="use WeightedIndex instead")] +#[allow(deprecated)] +#[derive(Debug)] +pub struct WeightedChoice<'a, T:'a> { + items: &'a mut [Weighted], + weight_range: Uniform, +} + +#[deprecated(since="0.6.0", note="use WeightedIndex instead")] +#[allow(deprecated)] +impl<'a, T: Clone> WeightedChoice<'a, T> { + /// Create a new `WeightedChoice`. + /// + /// Panics if: + /// + /// - `items` is empty + /// - the total weight is 0 + /// - the total weight is larger than a `u32` can contain. + pub fn new(items: &'a mut [Weighted]) -> WeightedChoice<'a, T> { + // strictly speaking, this is subsumed by the total weight == 0 case + assert!(!items.is_empty(), "WeightedChoice::new called with no items"); + + let mut running_total: u32 = 0; + + // we convert the list from individual weights to cumulative + // weights so we can binary search. This *could* drop elements + // with weight == 0 as an optimisation. + for item in items.iter_mut() { + running_total = match running_total.checked_add(item.weight) { + Some(n) => n, + None => panic!("WeightedChoice::new called with a total weight \ + larger than a u32 can contain") + }; + + item.weight = running_total; + } + assert!(running_total != 0, "WeightedChoice::new called with a total weight of 0"); + + WeightedChoice { + items, + // we're likely to be generating numbers in this range + // relatively often, so might as well cache it + weight_range: Uniform::new(0, running_total) + } + } +} + +#[deprecated(since="0.6.0", note="use WeightedIndex instead")] +#[allow(deprecated)] +impl<'a, T: Clone> Distribution for WeightedChoice<'a, T> { + fn sample(&self, rng: &mut R) -> T { + // we want to find the first element that has cumulative + // weight > sample_weight, which we do by binary since the + // cumulative weights of self.items are sorted. + + // choose a weight in [0, total_weight) + let sample_weight = self.weight_range.sample(rng); + + // short circuit when it's the first item + if sample_weight < self.items[0].weight { + return self.items[0].item.clone(); + } + + let mut idx = 0; + let mut modifier = self.items.len(); + + // now we know that every possibility has an element to the + // left, so we can just search for the last element that has + // cumulative weight <= sample_weight, then the next one will + // be "it". (Note that this greatest element will never be the + // last element of the vector, since sample_weight is chosen + // in [0, total_weight) and the cumulative weight of the last + // one is exactly the total weight.) + while modifier > 1 { + let i = idx + modifier / 2; + if self.items[i].weight <= sample_weight { + // we're small, so look to the right, but allow this + // exact element still. + idx = i; + // we need the `/ 2` to round up otherwise we'll drop + // the trailing elements when `modifier` is odd. + modifier += 1; + } else { + // otherwise we're too big, so go left. (i.e. do + // nothing) + } + modifier /= 2; + } + self.items[idx + 1].item.clone() + } +} + +#[cfg(test)] +mod tests { + use rngs::mock::StepRng; + #[allow(deprecated)] + use super::{WeightedChoice, Weighted, Distribution}; + + #[test] + #[allow(deprecated)] + fn test_weighted_choice() { + // this makes assumptions about the internal implementation of + // WeightedChoice. It may fail when the implementation in + // `distributions::uniform::UniformInt` changes. + + macro_rules! t { + ($items:expr, $expected:expr) => {{ + let mut items = $items; + let mut total_weight = 0; + for item in &items { total_weight += item.weight; } + + let wc = WeightedChoice::new(&mut items); + let expected = $expected; + + // Use extremely large steps between the random numbers, because + // we test with small ranges and `UniformInt` is designed to prefer + // the most significant bits. + let mut rng = StepRng::new(0, !0 / (total_weight as u64)); + + for &val in expected.iter() { + assert_eq!(wc.sample(&mut rng), val) + } + }} + } + + t!([Weighted { weight: 1, item: 10}], [10]); + + // skip some + t!([Weighted { weight: 0, item: 20}, + Weighted { weight: 2, item: 21}, + Weighted { weight: 0, item: 22}, + Weighted { weight: 1, item: 23}], + [21, 21, 23]); + + // different weights + t!([Weighted { weight: 4, item: 30}, + Weighted { weight: 3, item: 31}], + [30, 31, 30, 31, 30, 31, 30]); + + // check that we're binary searching + // correctly with some vectors of odd + // length. + t!([Weighted { weight: 1, item: 40}, + Weighted { weight: 1, item: 41}, + Weighted { weight: 1, item: 42}, + Weighted { weight: 1, item: 43}, + Weighted { weight: 1, item: 44}], + [40, 41, 42, 43, 44]); + t!([Weighted { weight: 1, item: 50}, + Weighted { weight: 1, item: 51}, + Weighted { weight: 1, item: 52}, + Weighted { weight: 1, item: 53}, + Weighted { weight: 1, item: 54}, + Weighted { weight: 1, item: 55}, + Weighted { weight: 1, item: 56}], + [50, 54, 51, 55, 52, 56, 53]); + } + + #[test] + #[allow(deprecated)] + fn test_weighted_clone_initialization() { + let initial : Weighted = Weighted {weight: 1, item: 1}; + let clone = initial.clone(); + assert_eq!(initial.weight, clone.weight); + assert_eq!(initial.item, clone.item); + } + + #[test] #[should_panic] + #[allow(deprecated)] + fn test_weighted_clone_change_weight() { + let initial : Weighted = Weighted {weight: 1, item: 1}; + let mut clone = initial.clone(); + clone.weight = 5; + assert_eq!(initial.weight, clone.weight); + } + + #[test] #[should_panic] + #[allow(deprecated)] + fn test_weighted_clone_change_item() { + let initial : Weighted = Weighted {weight: 1, item: 1}; + let mut clone = initial.clone(); + clone.item = 5; + assert_eq!(initial.item, clone.item); + + } + + #[test] #[should_panic] + #[allow(deprecated)] + fn test_weighted_choice_no_items() { + WeightedChoice::::new(&mut []); + } + #[test] #[should_panic] + #[allow(deprecated)] + fn test_weighted_choice_zero_weight() { + WeightedChoice::new(&mut [Weighted { weight: 0, item: 0}, + Weighted { weight: 0, item: 1}]); + } + #[test] #[should_panic] + #[allow(deprecated)] + fn test_weighted_choice_weight_overflows() { + let x = ::core::u32::MAX / 2; // x + x + 2 is the overflow + WeightedChoice::new(&mut [Weighted { weight: x, item: 0 }, + Weighted { weight: 1, item: 1 }, + Weighted { weight: x, item: 2 }, + Weighted { weight: 1, item: 3 }]); + } + + #[cfg(feature="std")] + #[test] + fn test_distributions_iter() { + use distributions::Normal; + let mut rng = ::test::rng(210); + let distr = Normal::new(10.0, 10.0); + let results: Vec<_> = distr.sample_iter(&mut rng).take(100).collect(); + println!("{:?}", results); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/normal.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/normal.rs new file mode 100644 index 0000000..089865e --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/normal.rs @@ -0,0 +1,197 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The normal and derived distributions. + +use Rng; +use distributions::{ziggurat_tables, Distribution, Open01}; +use distributions::utils::ziggurat; + +/// Samples floating-point numbers according to the normal distribution +/// `N(0, 1)` (a.k.a. a standard normal, or Gaussian). This is equivalent to +/// `Normal::new(0.0, 1.0)` but faster. +/// +/// See `Normal` for the general normal distribution. +/// +/// Implemented via the ZIGNOR variant[^1] of the Ziggurat method. +/// +/// [^1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to +/// Generate Normal Random Samples*]( +/// https://www.doornik.com/research/ziggurat.pdf). +/// Nuffield College, Oxford +/// +/// # Example +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::StandardNormal; +/// +/// let val: f64 = SmallRng::from_entropy().sample(StandardNormal); +/// println!("{}", val); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct StandardNormal; + +impl Distribution for StandardNormal { + fn sample(&self, rng: &mut R) -> f64 { + #[inline] + fn pdf(x: f64) -> f64 { + (-x*x/2.0).exp() + } + #[inline] + fn zero_case(rng: &mut R, u: f64) -> f64 { + // compute a random number in the tail by hand + + // strange initial conditions, because the loop is not + // do-while, so the condition should be true on the first + // run, they get overwritten anyway (0 < 1, so these are + // good). + let mut x = 1.0f64; + let mut y = 0.0f64; + + while -2.0 * y < x * x { + let x_: f64 = rng.sample(Open01); + let y_: f64 = rng.sample(Open01); + + x = x_.ln() / ziggurat_tables::ZIG_NORM_R; + y = y_.ln(); + } + + if u < 0.0 { x - ziggurat_tables::ZIG_NORM_R } else { ziggurat_tables::ZIG_NORM_R - x } + } + + ziggurat(rng, true, // this is symmetric + &ziggurat_tables::ZIG_NORM_X, + &ziggurat_tables::ZIG_NORM_F, + pdf, zero_case) + } +} + +/// The normal distribution `N(mean, std_dev**2)`. +/// +/// This uses the ZIGNOR variant of the Ziggurat method, see [`StandardNormal`] +/// for more details. +/// +/// Note that [`StandardNormal`] is an optimised implementation for mean 0, and +/// standard deviation 1. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Normal, Distribution}; +/// +/// // mean 2, standard deviation 3 +/// let normal = Normal::new(2.0, 3.0); +/// let v = normal.sample(&mut rand::thread_rng()); +/// println!("{} is from a N(2, 9) distribution", v) +/// ``` +/// +/// [`StandardNormal`]: crate::distributions::StandardNormal +#[derive(Clone, Copy, Debug)] +pub struct Normal { + mean: f64, + std_dev: f64, +} + +impl Normal { + /// Construct a new `Normal` distribution with the given mean and + /// standard deviation. + /// + /// # Panics + /// + /// Panics if `std_dev < 0`. + #[inline] + pub fn new(mean: f64, std_dev: f64) -> Normal { + assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0"); + Normal { + mean, + std_dev + } + } +} +impl Distribution for Normal { + fn sample(&self, rng: &mut R) -> f64 { + let n = rng.sample(StandardNormal); + self.mean + self.std_dev * n + } +} + + +/// The log-normal distribution `ln N(mean, std_dev**2)`. +/// +/// If `X` is log-normal distributed, then `ln(X)` is `N(mean, std_dev**2)` +/// distributed. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{LogNormal, Distribution}; +/// +/// // mean 2, standard deviation 3 +/// let log_normal = LogNormal::new(2.0, 3.0); +/// let v = log_normal.sample(&mut rand::thread_rng()); +/// println!("{} is from an ln N(2, 9) distribution", v) +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct LogNormal { + norm: Normal +} + +impl LogNormal { + /// Construct a new `LogNormal` distribution with the given mean + /// and standard deviation. + /// + /// # Panics + /// + /// Panics if `std_dev < 0`. + #[inline] + pub fn new(mean: f64, std_dev: f64) -> LogNormal { + assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0"); + LogNormal { norm: Normal::new(mean, std_dev) } + } +} +impl Distribution for LogNormal { + fn sample(&self, rng: &mut R) -> f64 { + self.norm.sample(rng).exp() + } +} + +#[cfg(test)] +mod tests { + use distributions::Distribution; + use super::{Normal, LogNormal}; + + #[test] + fn test_normal() { + let norm = Normal::new(10.0, 10.0); + let mut rng = ::test::rng(210); + for _ in 0..1000 { + norm.sample(&mut rng); + } + } + #[test] + #[should_panic] + fn test_normal_invalid_sd() { + Normal::new(10.0, -1.0); + } + + + #[test] + fn test_log_normal() { + let lnorm = LogNormal::new(10.0, 10.0); + let mut rng = ::test::rng(211); + for _ in 0..1000 { + lnorm.sample(&mut rng); + } + } + #[test] + #[should_panic] + fn test_log_normal_invalid_sd() { + LogNormal::new(10.0, -1.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/other.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/other.rs new file mode 100644 index 0000000..2295f79 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/other.rs @@ -0,0 +1,219 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The implementations of the `Standard` distribution for other built-in types. + +use core::char; +use core::num::Wrapping; + +use {Rng}; +use distributions::{Distribution, Standard, Uniform}; + +// ----- Sampling distributions ----- + +/// Sample a `char`, uniformly distributed over ASCII letters and numbers: +/// a-z, A-Z and 0-9. +/// +/// # Example +/// +/// ``` +/// use std::iter; +/// use rand::{Rng, thread_rng}; +/// use rand::distributions::Alphanumeric; +/// +/// let mut rng = thread_rng(); +/// let chars: String = iter::repeat(()) +/// .map(|()| rng.sample(Alphanumeric)) +/// .take(7) +/// .collect(); +/// println!("Random chars: {}", chars); +/// ``` +#[derive(Debug)] +pub struct Alphanumeric; + + +// ----- Implementations of distributions ----- + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> char { + // A valid `char` is either in the interval `[0, 0xD800)` or + // `(0xDFFF, 0x11_0000)`. All `char`s must therefore be in + // `[0, 0x11_0000)` but not in the "gap" `[0xD800, 0xDFFF]` which is + // reserved for surrogates. This is the size of that gap. + const GAP_SIZE: u32 = 0xDFFF - 0xD800 + 1; + + // Uniform::new(0, 0x11_0000 - GAP_SIZE) can also be used but it + // seemed slower. + let range = Uniform::new(GAP_SIZE, 0x11_0000); + + let mut n = range.sample(rng); + if n <= 0xDFFF { + n -= GAP_SIZE; + } + unsafe { char::from_u32_unchecked(n) } + } +} + +impl Distribution for Alphanumeric { + fn sample(&self, rng: &mut R) -> char { + const RANGE: u32 = 26 + 26 + 10; + const GEN_ASCII_STR_CHARSET: &[u8] = + b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ + abcdefghijklmnopqrstuvwxyz\ + 0123456789"; + // We can pick from 62 characters. This is so close to a power of 2, 64, + // that we can do better than `Uniform`. Use a simple bitshift and + // rejection sampling. We do not use a bitmask, because for small RNGs + // the most significant bits are usually of higher quality. + loop { + let var = rng.next_u32() >> (32 - 6); + if var < RANGE { + return GEN_ASCII_STR_CHARSET[var as usize] as char + } + } + } +} + +impl Distribution for Standard { + #[inline] + fn sample(&self, rng: &mut R) -> bool { + // We can compare against an arbitrary bit of an u32 to get a bool. + // Because the least significant bits of a lower quality RNG can have + // simple patterns, we compare against the most significant bit. This is + // easiest done using a sign test. + (rng.next_u32() as i32) < 0 + } +} + +macro_rules! tuple_impl { + // use variables to indicate the arity of the tuple + ($($tyvar:ident),* ) => { + // the trailing commas are for the 1 tuple + impl< $( $tyvar ),* > + Distribution<( $( $tyvar ),* , )> + for Standard + where $( Standard: Distribution<$tyvar> ),* + { + #[inline] + fn sample(&self, _rng: &mut R) -> ( $( $tyvar ),* , ) { + ( + // use the $tyvar's to get the appropriate number of + // repeats (they're not actually needed) + $( + _rng.gen::<$tyvar>() + ),* + , + ) + } + } + } +} + +impl Distribution<()> for Standard { + #[inline] + fn sample(&self, _: &mut R) -> () { () } +} +tuple_impl!{A} +tuple_impl!{A, B} +tuple_impl!{A, B, C} +tuple_impl!{A, B, C, D} +tuple_impl!{A, B, C, D, E} +tuple_impl!{A, B, C, D, E, F} +tuple_impl!{A, B, C, D, E, F, G} +tuple_impl!{A, B, C, D, E, F, G, H} +tuple_impl!{A, B, C, D, E, F, G, H, I} +tuple_impl!{A, B, C, D, E, F, G, H, I, J} +tuple_impl!{A, B, C, D, E, F, G, H, I, J, K} +tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L} + +macro_rules! array_impl { + // recursive, given at least one type parameter: + {$n:expr, $t:ident, $($ts:ident,)*} => { + array_impl!{($n - 1), $($ts,)*} + + impl Distribution<[T; $n]> for Standard where Standard: Distribution { + #[inline] + fn sample(&self, _rng: &mut R) -> [T; $n] { + [_rng.gen::<$t>(), $(_rng.gen::<$ts>()),*] + } + } + }; + // empty case: + {$n:expr,} => { + impl Distribution<[T; $n]> for Standard { + fn sample(&self, _rng: &mut R) -> [T; $n] { [] } + } + }; +} + +array_impl!{32, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,} + +impl Distribution> for Standard where Standard: Distribution { + #[inline] + fn sample(&self, rng: &mut R) -> Option { + // UFCS is needed here: https://github.com/rust-lang/rust/issues/24066 + if rng.gen::() { + Some(rng.gen()) + } else { + None + } + } +} + +impl Distribution> for Standard where Standard: Distribution { + #[inline] + fn sample(&self, rng: &mut R) -> Wrapping { + Wrapping(rng.gen()) + } +} + + +#[cfg(test)] +mod tests { + use {Rng, RngCore, Standard}; + use distributions::Alphanumeric; + #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::string::String; + + #[test] + fn test_misc() { + let rng: &mut RngCore = &mut ::test::rng(820); + + rng.sample::(Standard); + rng.sample::(Standard); + } + + #[cfg(feature="alloc")] + #[test] + fn test_chars() { + use core::iter; + let mut rng = ::test::rng(805); + + // Test by generating a relatively large number of chars, so we also + // take the rejection sampling path. + let word: String = iter::repeat(()) + .map(|()| rng.gen::()).take(1000).collect(); + assert!(word.len() != 0); + } + + #[test] + fn test_alphanumeric() { + let mut rng = ::test::rng(806); + + // Test by generating a relatively large number of chars, so we also + // take the rejection sampling path. + let mut incorrect = false; + for _ in 0..100 { + let c = rng.sample(Alphanumeric); + incorrect |= !((c >= '0' && c <= '9') || + (c >= 'A' && c <= 'Z') || + (c >= 'a' && c <= 'z') ); + } + assert!(incorrect == false); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/pareto.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/pareto.rs new file mode 100644 index 0000000..744a157 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/pareto.rs @@ -0,0 +1,74 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Pareto distribution. + +use Rng; +use distributions::{Distribution, OpenClosed01}; + +/// Samples floating-point numbers according to the Pareto distribution +/// +/// # Example +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::Pareto; +/// +/// let val: f64 = SmallRng::from_entropy().sample(Pareto::new(1., 2.)); +/// println!("{}", val); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Pareto { + scale: f64, + inv_neg_shape: f64, +} + +impl Pareto { + /// Construct a new Pareto distribution with given `scale` and `shape`. + /// + /// In the literature, `scale` is commonly written as xm or k and + /// `shape` is often written as α. + /// + /// # Panics + /// + /// `scale` and `shape` have to be non-zero and positive. + pub fn new(scale: f64, shape: f64) -> Pareto { + assert!((scale > 0.) & (shape > 0.)); + Pareto { scale, inv_neg_shape: -1.0 / shape } + } +} + +impl Distribution for Pareto { + fn sample(&self, rng: &mut R) -> f64 { + let u: f64 = rng.sample(OpenClosed01); + self.scale * u.powf(self.inv_neg_shape) + } +} + +#[cfg(test)] +mod tests { + use distributions::Distribution; + use super::Pareto; + + #[test] + #[should_panic] + fn invalid() { + Pareto::new(0., 0.); + } + + #[test] + fn sample() { + let scale = 1.0; + let shape = 2.0; + let d = Pareto::new(scale, shape); + let mut rng = ::test::rng(1); + for _ in 0..1000 { + let r = d.sample(&mut rng); + assert!(r >= scale); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/poisson.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/poisson.rs new file mode 100644 index 0000000..1244caa --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/poisson.rs @@ -0,0 +1,157 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2016-2017 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Poisson distribution. + +use Rng; +use distributions::{Distribution, Cauchy}; +use distributions::utils::log_gamma; + +/// The Poisson distribution `Poisson(lambda)`. +/// +/// This distribution has a density function: +/// `f(k) = lambda^k * exp(-lambda) / k!` for `k >= 0`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Poisson, Distribution}; +/// +/// let poi = Poisson::new(2.0); +/// let v = poi.sample(&mut rand::thread_rng()); +/// println!("{} is from a Poisson(2) distribution", v); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Poisson { + lambda: f64, + // precalculated values + exp_lambda: f64, + log_lambda: f64, + sqrt_2lambda: f64, + magic_val: f64, +} + +impl Poisson { + /// Construct a new `Poisson` with the given shape parameter + /// `lambda`. Panics if `lambda <= 0`. + pub fn new(lambda: f64) -> Poisson { + assert!(lambda > 0.0, "Poisson::new called with lambda <= 0"); + let log_lambda = lambda.ln(); + Poisson { + lambda, + exp_lambda: (-lambda).exp(), + log_lambda, + sqrt_2lambda: (2.0 * lambda).sqrt(), + magic_val: lambda * log_lambda - log_gamma(1.0 + lambda), + } + } +} + +impl Distribution for Poisson { + fn sample(&self, rng: &mut R) -> u64 { + // using the algorithm from Numerical Recipes in C + + // for low expected values use the Knuth method + if self.lambda < 12.0 { + let mut result = 0; + let mut p = 1.0; + while p > self.exp_lambda { + p *= rng.gen::(); + result += 1; + } + result - 1 + } + // high expected values - rejection method + else { + let mut int_result: u64; + + // we use the Cauchy distribution as the comparison distribution + // f(x) ~ 1/(1+x^2) + let cauchy = Cauchy::new(0.0, 1.0); + + loop { + let mut result; + let mut comp_dev; + + loop { + // draw from the Cauchy distribution + comp_dev = rng.sample(cauchy); + // shift the peak of the comparison ditribution + result = self.sqrt_2lambda * comp_dev + self.lambda; + // repeat the drawing until we are in the range of possible values + if result >= 0.0 { + break; + } + } + // now the result is a random variable greater than 0 with Cauchy distribution + // the result should be an integer value + result = result.floor(); + int_result = result as u64; + + // this is the ratio of the Poisson distribution to the comparison distribution + // the magic value scales the distribution function to a range of approximately 0-1 + // since it is not exact, we multiply the ratio by 0.9 to avoid ratios greater than 1 + // this doesn't change the resulting distribution, only increases the rate of failed drawings + let check = 0.9 * (1.0 + comp_dev * comp_dev) + * (result * self.log_lambda - log_gamma(1.0 + result) - self.magic_val).exp(); + + // check with uniform random value - if below the threshold, we are within the target distribution + if rng.gen::() <= check { + break; + } + } + int_result + } + } +} + +#[cfg(test)] +mod test { + use distributions::Distribution; + use super::Poisson; + + #[test] + fn test_poisson_10() { + let poisson = Poisson::new(10.0); + let mut rng = ::test::rng(123); + let mut sum = 0; + for _ in 0..1000 { + sum += poisson.sample(&mut rng); + } + let avg = (sum as f64) / 1000.0; + println!("Poisson average: {}", avg); + assert!((avg - 10.0).abs() < 0.5); // not 100% certain, but probable enough + } + + #[test] + fn test_poisson_15() { + // Take the 'high expected values' path + let poisson = Poisson::new(15.0); + let mut rng = ::test::rng(123); + let mut sum = 0; + for _ in 0..1000 { + sum += poisson.sample(&mut rng); + } + let avg = (sum as f64) / 1000.0; + println!("Poisson average: {}", avg); + assert!((avg - 15.0).abs() < 0.5); // not 100% certain, but probable enough + } + + #[test] + #[should_panic] + fn test_poisson_invalid_lambda_zero() { + Poisson::new(0.0); + } + + #[test] + #[should_panic] + fn test_poisson_invalid_lambda_neg() { + Poisson::new(-10.0); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/triangular.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/triangular.rs new file mode 100644 index 0000000..a6eef5c --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/triangular.rs @@ -0,0 +1,86 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +//! The triangular distribution. + +use Rng; +use distributions::{Distribution, Standard}; + +/// The triangular distribution. +/// +/// # Example +/// +/// ```rust +/// use rand::distributions::{Triangular, Distribution}; +/// +/// let d = Triangular::new(0., 5., 2.5); +/// let v = d.sample(&mut rand::thread_rng()); +/// println!("{} is from a triangular distribution", v); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Triangular { + min: f64, + max: f64, + mode: f64, +} + +impl Triangular { + /// Construct a new `Triangular` with minimum `min`, maximum `max` and mode + /// `mode`. + /// + /// # Panics + /// + /// If `max < mode`, `mode < max` or `max == min`. + /// + #[inline] + pub fn new(min: f64, max: f64, mode: f64) -> Triangular { + assert!(max >= mode); + assert!(mode >= min); + assert!(max != min); + Triangular { min, max, mode } + } +} + +impl Distribution for Triangular { + #[inline] + fn sample(&self, rng: &mut R) -> f64 { + let f: f64 = rng.sample(Standard); + let diff_mode_min = self.mode - self.min; + let diff_max_min = self.max - self.min; + if f * diff_max_min < diff_mode_min { + self.min + (f * diff_max_min * diff_mode_min).sqrt() + } else { + self.max - ((1. - f) * diff_max_min * (self.max - self.mode)).sqrt() + } + } +} + +#[cfg(test)] +mod test { + use distributions::Distribution; + use super::Triangular; + + #[test] + fn test_new() { + for &(min, max, mode) in &[ + (-1., 1., 0.), (1., 2., 1.), (5., 25., 25.), (1e-5, 1e5, 1e-3), + (0., 1., 0.9), (-4., -0.5, -2.), (-13.039, 8.41, 1.17), + ] { + println!("{} {} {}", min, max, mode); + let _ = Triangular::new(min, max, mode); + } + } + + #[test] + fn test_sample() { + let norm = Triangular::new(0., 1., 0.5); + let mut rng = ::test::rng(1); + for _ in 0..1000 { + norm.sample(&mut rng); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/uniform.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/uniform.rs new file mode 100644 index 0000000..19b4934 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/uniform.rs @@ -0,0 +1,1283 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2017 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A distribution uniformly sampling numbers within a given range. +//! +//! [`Uniform`] is the standard distribution to sample uniformly from a range; +//! e.g. `Uniform::new_inclusive(1, 6)` can sample integers from 1 to 6, like a +//! standard die. [`Rng::gen_range`] supports any type supported by +//! [`Uniform`]. +//! +//! This distribution is provided with support for several primitive types +//! (all integer and floating-point types) as well as [`std::time::Duration`], +//! and supports extension to user-defined types via a type-specific *back-end* +//! implementation. +//! +//! The types [`UniformInt`], [`UniformFloat`] and [`UniformDuration`] are the +//! back-ends supporting sampling from primitive integer and floating-point +//! ranges as well as from [`std::time::Duration`]; these types do not normally +//! need to be used directly (unless implementing a derived back-end). +//! +//! # Example usage +//! +//! ``` +//! use rand::{Rng, thread_rng}; +//! use rand::distributions::Uniform; +//! +//! let mut rng = thread_rng(); +//! let side = Uniform::new(-10.0, 10.0); +//! +//! // sample between 1 and 10 points +//! for _ in 0..rng.gen_range(1, 11) { +//! // sample a point from the square with sides -10 - 10 in two dimensions +//! let (x, y) = (rng.sample(side), rng.sample(side)); +//! println!("Point: {}, {}", x, y); +//! } +//! ``` +//! +//! # Extending `Uniform` to support a custom type +//! +//! To extend [`Uniform`] to support your own types, write a back-end which +//! implements the [`UniformSampler`] trait, then implement the [`SampleUniform`] +//! helper trait to "register" your back-end. See the `MyF32` example below. +//! +//! At a minimum, the back-end needs to store any parameters needed for sampling +//! (e.g. the target range) and implement `new`, `new_inclusive` and `sample`. +//! Those methods should include an assert to check the range is valid (i.e. +//! `low < high`). The example below merely wraps another back-end. +//! +//! The `new`, `new_inclusive` and `sample_single` functions use arguments of +//! type SampleBorrow in order to support passing in values by reference or +//! by value. In the implementation of these functions, you can choose to +//! simply use the reference returned by [`SampleBorrow::borrow`], or you can choose +//! to copy or clone the value, whatever is appropriate for your type. +//! +//! ``` +//! use rand::prelude::*; +//! use rand::distributions::uniform::{Uniform, SampleUniform, +//! UniformSampler, UniformFloat, SampleBorrow}; +//! +//! struct MyF32(f32); +//! +//! #[derive(Clone, Copy, Debug)] +//! struct UniformMyF32 { +//! inner: UniformFloat, +//! } +//! +//! impl UniformSampler for UniformMyF32 { +//! type X = MyF32; +//! fn new(low: B1, high: B2) -> Self +//! where B1: SampleBorrow + Sized, +//! B2: SampleBorrow + Sized +//! { +//! UniformMyF32 { +//! inner: UniformFloat::::new(low.borrow().0, high.borrow().0), +//! } +//! } +//! fn new_inclusive(low: B1, high: B2) -> Self +//! where B1: SampleBorrow + Sized, +//! B2: SampleBorrow + Sized +//! { +//! UniformSampler::new(low, high) +//! } +//! fn sample(&self, rng: &mut R) -> Self::X { +//! MyF32(self.inner.sample(rng)) +//! } +//! } +//! +//! impl SampleUniform for MyF32 { +//! type Sampler = UniformMyF32; +//! } +//! +//! let (low, high) = (MyF32(17.0f32), MyF32(22.0f32)); +//! let uniform = Uniform::new(low, high); +//! let x = uniform.sample(&mut thread_rng()); +//! ``` +//! +//! [`SampleUniform`]: crate::distributions::uniform::SampleUniform +//! [`UniformSampler`]: crate::distributions::uniform::UniformSampler +//! [`UniformInt`]: crate::distributions::uniform::UniformInt +//! [`UniformFloat`]: crate::distributions::uniform::UniformFloat +//! [`UniformDuration`]: crate::distributions::uniform::UniformDuration +//! [`SampleBorrow::borrow`]: crate::distributions::uniform::SampleBorrow::borrow + +#[cfg(feature = "std")] +use std::time::Duration; +#[cfg(all(not(feature = "std"), rustc_1_25))] +use core::time::Duration; + +use Rng; +use distributions::Distribution; +use distributions::float::IntoFloat; +use distributions::utils::{WideningMultiply, FloatSIMDUtils, FloatAsSIMD, BoolAsSIMD}; + +#[cfg(not(feature = "std"))] +#[allow(unused_imports)] // rustc doesn't detect that this is actually used +use distributions::utils::Float; + + +#[cfg(feature="simd_support")] +use packed_simd::*; + +/// Sample values uniformly between two bounds. +/// +/// [`Uniform::new`] and [`Uniform::new_inclusive`] construct a uniform +/// distribution sampling from the given range; these functions may do extra +/// work up front to make sampling of multiple values faster. +/// +/// When sampling from a constant range, many calculations can happen at +/// compile-time and all methods should be fast; for floating-point ranges and +/// the full range of integer types this should have comparable performance to +/// the `Standard` distribution. +/// +/// Steps are taken to avoid bias which might be present in naive +/// implementations; for example `rng.gen::() % 170` samples from the range +/// `[0, 169]` but is twice as likely to select numbers less than 85 than other +/// values. Further, the implementations here give more weight to the high-bits +/// generated by the RNG than the low bits, since with some RNGs the low-bits +/// are of lower quality than the high bits. +/// +/// Implementations must sample in `[low, high)` range for +/// `Uniform::new(low, high)`, i.e., excluding `high`. In particular care must +/// be taken to ensure that rounding never results values `< low` or `>= high`. +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{Distribution, Uniform}; +/// +/// fn main() { +/// let between = Uniform::from(10..10000); +/// let mut rng = rand::thread_rng(); +/// let mut sum = 0; +/// for _ in 0..1000 { +/// sum += between.sample(&mut rng); +/// } +/// println!("{}", sum); +/// } +/// ``` +/// +/// [`new`]: Uniform::new +/// [`new_inclusive`]: Uniform::new_inclusive +#[derive(Clone, Copy, Debug)] +pub struct Uniform { + inner: X::Sampler, +} + +impl Uniform { + /// Create a new `Uniform` instance which samples uniformly from the half + /// open range `[low, high)` (excluding `high`). Panics if `low >= high`. + pub fn new(low: B1, high: B2) -> Uniform + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + Uniform { inner: X::Sampler::new(low, high) } + } + + /// Create a new `Uniform` instance which samples uniformly from the closed + /// range `[low, high]` (inclusive). Panics if `low > high`. + pub fn new_inclusive(low: B1, high: B2) -> Uniform + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + Uniform { inner: X::Sampler::new_inclusive(low, high) } + } +} + +impl Distribution for Uniform { + fn sample(&self, rng: &mut R) -> X { + self.inner.sample(rng) + } +} + +/// Helper trait for creating objects using the correct implementation of +/// [`UniformSampler`] for the sampling type. +/// +/// See the [module documentation] on how to implement [`Uniform`] range +/// sampling for a custom type. +/// +/// [module documentation]: crate::distributions::uniform +pub trait SampleUniform: Sized { + /// The `UniformSampler` implementation supporting type `X`. + type Sampler: UniformSampler; +} + +/// Helper trait handling actual uniform sampling. +/// +/// See the [module documentation] on how to implement [`Uniform`] range +/// sampling for a custom type. +/// +/// Implementation of [`sample_single`] is optional, and is only useful when +/// the implementation can be faster than `Self::new(low, high).sample(rng)`. +/// +/// [module documentation]: crate::distributions::uniform +/// [`sample_single`]: UniformSampler::sample_single +pub trait UniformSampler: Sized { + /// The type sampled by this implementation. + type X; + + /// Construct self, with inclusive lower bound and exclusive upper bound + /// `[low, high)`. + /// + /// Usually users should not call this directly but instead use + /// `Uniform::new`, which asserts that `low < high` before calling this. + fn new(low: B1, high: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized; + + /// Construct self, with inclusive bounds `[low, high]`. + /// + /// Usually users should not call this directly but instead use + /// `Uniform::new_inclusive`, which asserts that `low <= high` before + /// calling this. + fn new_inclusive(low: B1, high: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized; + + /// Sample a value. + fn sample(&self, rng: &mut R) -> Self::X; + + /// Sample a single value uniformly from a range with inclusive lower bound + /// and exclusive upper bound `[low, high)`. + /// + /// Usually users should not call this directly but instead use + /// `Uniform::sample_single`, which asserts that `low < high` before calling + /// this. + /// + /// Via this method, implementations can provide a method optimized for + /// sampling only a single value from the specified range. The default + /// implementation simply calls `UniformSampler::new` then `sample` on the + /// result. + fn sample_single(low: B1, high: B2, rng: &mut R) + -> Self::X + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let uniform: Self = UniformSampler::new(low, high); + uniform.sample(rng) + } +} + +impl From<::core::ops::Range> for Uniform { + fn from(r: ::core::ops::Range) -> Uniform { + Uniform::new(r.start, r.end) + } +} + +#[cfg(rustc_1_27)] +impl From<::core::ops::RangeInclusive> for Uniform { + fn from(r: ::core::ops::RangeInclusive) -> Uniform { + Uniform::new_inclusive(r.start(), r.end()) + } +} + +/// Helper trait similar to [`Borrow`] but implemented +/// only for SampleUniform and references to SampleUniform in +/// order to resolve ambiguity issues. +/// +/// [`Borrow`]: std::borrow::Borrow +pub trait SampleBorrow { + /// Immutably borrows from an owned value. See [`Borrow::borrow`] + /// + /// [`Borrow::borrow`]: std::borrow::Borrow::borrow + fn borrow(&self) -> &Borrowed; +} +impl SampleBorrow for Borrowed where Borrowed: SampleUniform { + #[inline(always)] + fn borrow(&self) -> &Borrowed { self } +} +impl<'a, Borrowed> SampleBorrow for &'a Borrowed where Borrowed: SampleUniform { + #[inline(always)] + fn borrow(&self) -> &Borrowed { *self } +} + +//////////////////////////////////////////////////////////////////////////////// + +// What follows are all back-ends. + + +/// The back-end implementing [`UniformSampler`] for integer types. +/// +/// Unless you are implementing [`UniformSampler`] for your own type, this type +/// should not be used directly, use [`Uniform`] instead. +/// +/// # Implementation notes +/// +/// For a closed range, the number of possible numbers we should generate is +/// `range = (high - low + 1)`. It is not possible to end up with a uniform +/// distribution if we map *all* the random integers that can be generated to +/// this range. We have to map integers from a `zone` that is a multiple of the +/// range. The rest of the integers, that cause a bias, are rejected. +/// +/// The problem with `range` is that to cover the full range of the type, it has +/// to store `unsigned_max + 1`, which can't be represented. But if the range +/// covers the full range of the type, no modulus is needed. A range of size 0 +/// can't exist, so we use that to represent this special case. Wrapping +/// arithmetic even makes representing `unsigned_max + 1` as 0 simple. +/// +/// We don't calculate `zone` directly, but first calculate the number of +/// integers to reject. To handle `unsigned_max + 1` not fitting in the type, +/// we use: +/// `ints_to_reject = (unsigned_max + 1) % range;` +/// `ints_to_reject = (unsigned_max - range + 1) % range;` +/// +/// The smallest integer PRNGs generate is `u32`. That is why for small integer +/// sizes (`i8`/`u8` and `i16`/`u16`) there is an optimization: don't pick the +/// largest zone that can fit in the small type, but pick the largest zone that +/// can fit in an `u32`. `ints_to_reject` is always less than half the size of +/// the small integer. This means the first bit of `zone` is always 1, and so +/// are all the other preceding bits of a larger integer. The easiest way to +/// grow the `zone` for the larger type is to simply sign extend it. +/// +/// An alternative to using a modulus is widening multiply: After a widening +/// multiply by `range`, the result is in the high word. Then comparing the low +/// word against `zone` makes sure our distribution is uniform. +#[derive(Clone, Copy, Debug)] +pub struct UniformInt { + low: X, + range: X, + zone: X, +} + +macro_rules! uniform_int_impl { + ($ty:ty, $signed:ty, $unsigned:ident, + $i_large:ident, $u_large:ident) => { + impl SampleUniform for $ty { + type Sampler = UniformInt<$ty>; + } + + impl UniformSampler for UniformInt<$ty> { + // We play free and fast with unsigned vs signed here + // (when $ty is signed), but that's fine, since the + // contract of this macro is for $ty and $unsigned to be + // "bit-equal", so casting between them is a no-op. + + type X = $ty; + + #[inline] // if the range is constant, this helps LLVM to do the + // calculations at compile-time. + fn new(low_b: B1, high_b: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low < high, "Uniform::new called with `low >= high`"); + UniformSampler::new_inclusive(low, high - 1) + } + + #[inline] // if the range is constant, this helps LLVM to do the + // calculations at compile-time. + fn new_inclusive(low_b: B1, high_b: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low <= high, + "Uniform::new_inclusive called with `low > high`"); + let unsigned_max = ::core::$unsigned::MAX; + + let range = high.wrapping_sub(low).wrapping_add(1) as $unsigned; + let ints_to_reject = + if range > 0 { + (unsigned_max - range + 1) % range + } else { + 0 + }; + let zone = unsigned_max - ints_to_reject; + + UniformInt { + low: low, + // These are really $unsigned values, but store as $ty: + range: range as $ty, + zone: zone as $ty + } + } + + fn sample(&self, rng: &mut R) -> Self::X { + let range = self.range as $unsigned as $u_large; + if range > 0 { + // Grow `zone` to fit a type of at least 32 bits, by + // sign-extending it (the first bit is always 1, so are all + // the preceding bits of the larger type). + // For types that already have the right size, all the + // casting is a no-op. + let zone = self.zone as $signed as $i_large as $u_large; + loop { + let v: $u_large = rng.gen(); + let (hi, lo) = v.wmul(range); + if lo <= zone { + return self.low.wrapping_add(hi as $ty); + } + } + } else { + // Sample from the entire integer range. + rng.gen() + } + } + + fn sample_single(low_b: B1, high_b: B2, rng: &mut R) + -> Self::X + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low < high, + "Uniform::sample_single called with low >= high"); + let range = high.wrapping_sub(low) as $unsigned as $u_large; + let zone = + if ::core::$unsigned::MAX <= ::core::u16::MAX as $unsigned { + // Using a modulus is faster than the approximation for + // i8 and i16. I suppose we trade the cost of one + // modulus for near-perfect branch prediction. + let unsigned_max: $u_large = ::core::$u_large::MAX; + let ints_to_reject = (unsigned_max - range + 1) % range; + unsigned_max - ints_to_reject + } else { + // conservative but fast approximation. `- 1` is necessary to allow the + // same comparison without bias. + (range << range.leading_zeros()).wrapping_sub(1) + }; + + loop { + let v: $u_large = rng.gen(); + let (hi, lo) = v.wmul(range); + if lo <= zone { + return low.wrapping_add(hi as $ty); + } + } + } + } + } +} + +uniform_int_impl! { i8, i8, u8, i32, u32 } +uniform_int_impl! { i16, i16, u16, i32, u32 } +uniform_int_impl! { i32, i32, u32, i32, u32 } +uniform_int_impl! { i64, i64, u64, i64, u64 } +#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] +uniform_int_impl! { i128, i128, u128, u128, u128 } +uniform_int_impl! { isize, isize, usize, isize, usize } +uniform_int_impl! { u8, i8, u8, i32, u32 } +uniform_int_impl! { u16, i16, u16, i32, u32 } +uniform_int_impl! { u32, i32, u32, i32, u32 } +uniform_int_impl! { u64, i64, u64, i64, u64 } +uniform_int_impl! { usize, isize, usize, isize, usize } +#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] +uniform_int_impl! { u128, u128, u128, i128, u128 } + +#[cfg(all(feature = "simd_support", feature = "nightly"))] +macro_rules! uniform_simd_int_impl { + ($ty:ident, $unsigned:ident, $u_scalar:ident) => { + // The "pick the largest zone that can fit in an `u32`" optimization + // is less useful here. Multiple lanes complicate things, we don't + // know the PRNG's minimal output size, and casting to a larger vector + // is generally a bad idea for SIMD performance. The user can still + // implement it manually. + + // TODO: look into `Uniform::::new(0u32, 100)` functionality + // perhaps `impl SampleUniform for $u_scalar`? + impl SampleUniform for $ty { + type Sampler = UniformInt<$ty>; + } + + impl UniformSampler for UniformInt<$ty> { + type X = $ty; + + #[inline] // if the range is constant, this helps LLVM to do the + // calculations at compile-time. + fn new(low_b: B1, high_b: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low.lt(high).all(), "Uniform::new called with `low >= high`"); + UniformSampler::new_inclusive(low, high - 1) + } + + #[inline] // if the range is constant, this helps LLVM to do the + // calculations at compile-time. + fn new_inclusive(low_b: B1, high_b: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low.le(high).all(), + "Uniform::new_inclusive called with `low > high`"); + let unsigned_max = ::core::$u_scalar::MAX; + + // NOTE: these may need to be replaced with explicitly + // wrapping operations if `packed_simd` changes + let range: $unsigned = ((high - low) + 1).cast(); + // `% 0` will panic at runtime. + let not_full_range = range.gt($unsigned::splat(0)); + // replacing 0 with `unsigned_max` allows a faster `select` + // with bitwise OR + let modulo = not_full_range.select(range, $unsigned::splat(unsigned_max)); + // wrapping addition + let ints_to_reject = (unsigned_max - range + 1) % modulo; + // When `range` is 0, `lo` of `v.wmul(range)` will always be + // zero which means only one sample is needed. + let zone = unsigned_max - ints_to_reject; + + UniformInt { + low: low, + // These are really $unsigned values, but store as $ty: + range: range.cast(), + zone: zone.cast(), + } + } + + fn sample(&self, rng: &mut R) -> Self::X { + let range: $unsigned = self.range.cast(); + let zone: $unsigned = self.zone.cast(); + + // This might seem very slow, generating a whole new + // SIMD vector for every sample rejection. For most uses + // though, the chance of rejection is small and provides good + // general performance. With multiple lanes, that chance is + // multiplied. To mitigate this, we replace only the lanes of + // the vector which fail, iteratively reducing the chance of + // rejection. The replacement method does however add a little + // overhead. Benchmarking or calculating probabilities might + // reveal contexts where this replacement method is slower. + let mut v: $unsigned = rng.gen(); + loop { + let (hi, lo) = v.wmul(range); + let mask = lo.le(zone); + if mask.all() { + let hi: $ty = hi.cast(); + // wrapping addition + let result = self.low + hi; + // `select` here compiles to a blend operation + // When `range.eq(0).none()` the compare and blend + // operations are avoided. + let v: $ty = v.cast(); + return range.gt($unsigned::splat(0)).select(result, v); + } + // Replace only the failing lanes + v = mask.select(v, rng.gen()); + } + } + } + }; + + // bulk implementation + ($(($unsigned:ident, $signed:ident),)+ $u_scalar:ident) => { + $( + uniform_simd_int_impl!($unsigned, $unsigned, $u_scalar); + uniform_simd_int_impl!($signed, $unsigned, $u_scalar); + )+ + }; +} + +#[cfg(all(feature = "simd_support", feature = "nightly"))] +uniform_simd_int_impl! { + (u64x2, i64x2), + (u64x4, i64x4), + (u64x8, i64x8), + u64 +} + +#[cfg(all(feature = "simd_support", feature = "nightly"))] +uniform_simd_int_impl! { + (u32x2, i32x2), + (u32x4, i32x4), + (u32x8, i32x8), + (u32x16, i32x16), + u32 +} + +#[cfg(all(feature = "simd_support", feature = "nightly"))] +uniform_simd_int_impl! { + (u16x2, i16x2), + (u16x4, i16x4), + (u16x8, i16x8), + (u16x16, i16x16), + (u16x32, i16x32), + u16 +} + +#[cfg(all(feature = "simd_support", feature = "nightly"))] +uniform_simd_int_impl! { + (u8x2, i8x2), + (u8x4, i8x4), + (u8x8, i8x8), + (u8x16, i8x16), + (u8x32, i8x32), + (u8x64, i8x64), + u8 +} + + +/// The back-end implementing [`UniformSampler`] for floating-point types. +/// +/// Unless you are implementing [`UniformSampler`] for your own type, this type +/// should not be used directly, use [`Uniform`] instead. +/// +/// # Implementation notes +/// +/// Instead of generating a float in the `[0, 1)` range using [`Standard`], the +/// `UniformFloat` implementation converts the output of an PRNG itself. This +/// way one or two steps can be optimized out. +/// +/// The floats are first converted to a value in the `[1, 2)` interval using a +/// transmute-based method, and then mapped to the expected range with a +/// multiply and addition. Values produced this way have what equals 22 bits of +/// random digits for an `f32`, and 52 for an `f64`. +/// +/// [`new`]: UniformSampler::new +/// [`new_inclusive`]: UniformSampler::new_inclusive +/// [`Standard`]: crate::distributions::Standard +#[derive(Clone, Copy, Debug)] +pub struct UniformFloat { + low: X, + scale: X, +} + +macro_rules! uniform_float_impl { + ($ty:ty, $uty:ident, $f_scalar:ident, $u_scalar:ident, $bits_to_discard:expr) => { + impl SampleUniform for $ty { + type Sampler = UniformFloat<$ty>; + } + + impl UniformSampler for UniformFloat<$ty> { + type X = $ty; + + fn new(low_b: B1, high_b: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low.all_lt(high), + "Uniform::new called with `low >= high`"); + assert!(low.all_finite() && high.all_finite(), + "Uniform::new called with non-finite boundaries"); + let max_rand = <$ty>::splat((::core::$u_scalar::MAX >> $bits_to_discard) + .into_float_with_exponent(0) - 1.0); + + let mut scale = high - low; + + loop { + let mask = (scale * max_rand + low).ge_mask(high); + if mask.none() { + break; + } + scale = scale.decrease_masked(mask); + } + + debug_assert!(<$ty>::splat(0.0).all_le(scale)); + + UniformFloat { low, scale } + } + + fn new_inclusive(low_b: B1, high_b: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low.all_le(high), + "Uniform::new_inclusive called with `low > high`"); + assert!(low.all_finite() && high.all_finite(), + "Uniform::new_inclusive called with non-finite boundaries"); + let max_rand = <$ty>::splat((::core::$u_scalar::MAX >> $bits_to_discard) + .into_float_with_exponent(0) - 1.0); + + let mut scale = (high - low) / max_rand; + + loop { + let mask = (scale * max_rand + low).gt_mask(high); + if mask.none() { + break; + } + scale = scale.decrease_masked(mask); + } + + debug_assert!(<$ty>::splat(0.0).all_le(scale)); + + UniformFloat { low, scale } + } + + fn sample(&self, rng: &mut R) -> Self::X { + // Generate a value in the range [1, 2) + let value1_2 = (rng.gen::<$uty>() >> $bits_to_discard) + .into_float_with_exponent(0); + + // Get a value in the range [0, 1) in order to avoid + // overflowing into infinity when multiplying with scale + let value0_1 = value1_2 - 1.0; + + // We don't use `f64::mul_add`, because it is not available with + // `no_std`. Furthermore, it is slower for some targets (but + // faster for others). However, the order of multiplication and + // addition is important, because on some platforms (e.g. ARM) + // it will be optimized to a single (non-FMA) instruction. + value0_1 * self.scale + self.low + } + + #[inline] + fn sample_single(low_b: B1, high_b: B2, rng: &mut R) + -> Self::X + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low.all_lt(high), + "Uniform::sample_single called with low >= high"); + let mut scale = high - low; + + loop { + // Generate a value in the range [1, 2) + let value1_2 = (rng.gen::<$uty>() >> $bits_to_discard) + .into_float_with_exponent(0); + + // Get a value in the range [0, 1) in order to avoid + // overflowing into infinity when multiplying with scale + let value0_1 = value1_2 - 1.0; + + // Doing multiply before addition allows some architectures + // to use a single instruction. + let res = value0_1 * scale + low; + + debug_assert!(low.all_le(res) || !scale.all_finite()); + if res.all_lt(high) { + return res; + } + + // This handles a number of edge cases. + // * `low` or `high` is NaN. In this case `scale` and + // `res` are going to end up as NaN. + // * `low` is negative infinity and `high` is finite. + // `scale` is going to be infinite and `res` will be + // NaN. + // * `high` is positive infinity and `low` is finite. + // `scale` is going to be infinite and `res` will + // be infinite or NaN (if value0_1 is 0). + // * `low` is negative infinity and `high` is positive + // infinity. `scale` will be infinite and `res` will + // be NaN. + // * `low` and `high` are finite, but `high - low` + // overflows to infinite. `scale` will be infinite + // and `res` will be infinite or NaN (if value0_1 is 0). + // So if `high` or `low` are non-finite, we are guaranteed + // to fail the `res < high` check above and end up here. + // + // While we technically should check for non-finite `low` + // and `high` before entering the loop, by doing the checks + // here instead, we allow the common case to avoid these + // checks. But we are still guaranteed that if `low` or + // `high` are non-finite we'll end up here and can do the + // appropriate checks. + // + // Likewise `high - low` overflowing to infinity is also + // rare, so handle it here after the common case. + let mask = !scale.finite_mask(); + if mask.any() { + assert!(low.all_finite() && high.all_finite(), + "Uniform::sample_single called with non-finite boundaries"); + scale = scale.decrease_masked(mask); + } + } + } + } + } +} + +uniform_float_impl! { f32, u32, f32, u32, 32 - 23 } +uniform_float_impl! { f64, u64, f64, u64, 64 - 52 } + +#[cfg(feature="simd_support")] +uniform_float_impl! { f32x2, u32x2, f32, u32, 32 - 23 } +#[cfg(feature="simd_support")] +uniform_float_impl! { f32x4, u32x4, f32, u32, 32 - 23 } +#[cfg(feature="simd_support")] +uniform_float_impl! { f32x8, u32x8, f32, u32, 32 - 23 } +#[cfg(feature="simd_support")] +uniform_float_impl! { f32x16, u32x16, f32, u32, 32 - 23 } + +#[cfg(feature="simd_support")] +uniform_float_impl! { f64x2, u64x2, f64, u64, 64 - 52 } +#[cfg(feature="simd_support")] +uniform_float_impl! { f64x4, u64x4, f64, u64, 64 - 52 } +#[cfg(feature="simd_support")] +uniform_float_impl! { f64x8, u64x8, f64, u64, 64 - 52 } + + + +/// The back-end implementing [`UniformSampler`] for `Duration`. +/// +/// Unless you are implementing [`UniformSampler`] for your own types, this type +/// should not be used directly, use [`Uniform`] instead. +#[cfg(any(feature = "std", rustc_1_25))] +#[derive(Clone, Copy, Debug)] +pub struct UniformDuration { + mode: UniformDurationMode, + offset: u32, +} + +#[cfg(any(feature = "std", rustc_1_25))] +#[derive(Debug, Copy, Clone)] +enum UniformDurationMode { + Small { + secs: u64, + nanos: Uniform, + }, + Medium { + nanos: Uniform, + }, + Large { + max_secs: u64, + max_nanos: u32, + secs: Uniform, + } +} + +#[cfg(any(feature = "std", rustc_1_25))] +impl SampleUniform for Duration { + type Sampler = UniformDuration; +} + +#[cfg(any(feature = "std", rustc_1_25))] +impl UniformSampler for UniformDuration { + type X = Duration; + + #[inline] + fn new(low_b: B1, high_b: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low < high, "Uniform::new called with `low >= high`"); + UniformDuration::new_inclusive(low, high - Duration::new(0, 1)) + } + + #[inline] + fn new_inclusive(low_b: B1, high_b: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low <= high, "Uniform::new_inclusive called with `low > high`"); + + let low_s = low.as_secs(); + let low_n = low.subsec_nanos(); + let mut high_s = high.as_secs(); + let mut high_n = high.subsec_nanos(); + + if high_n < low_n { + high_s = high_s - 1; + high_n = high_n + 1_000_000_000; + } + + let mode = if low_s == high_s { + UniformDurationMode::Small { + secs: low_s, + nanos: Uniform::new_inclusive(low_n, high_n), + } + } else { + let max = high_s + .checked_mul(1_000_000_000) + .and_then(|n| n.checked_add(high_n as u64)); + + if let Some(higher_bound) = max { + let lower_bound = low_s * 1_000_000_000 + low_n as u64; + UniformDurationMode::Medium { + nanos: Uniform::new_inclusive(lower_bound, higher_bound), + } + } else { + // An offset is applied to simplify generation of nanoseconds + let max_nanos = high_n - low_n; + UniformDurationMode::Large { + max_secs: high_s, + max_nanos, + secs: Uniform::new_inclusive(low_s, high_s), + } + } + }; + UniformDuration { + mode, + offset: low_n, + } + } + + #[inline] + fn sample(&self, rng: &mut R) -> Duration { + match self.mode { + UniformDurationMode::Small { secs, nanos } => { + let n = nanos.sample(rng); + Duration::new(secs, n) + } + UniformDurationMode::Medium { nanos } => { + let nanos = nanos.sample(rng); + Duration::new(nanos / 1_000_000_000, (nanos % 1_000_000_000) as u32) + } + UniformDurationMode::Large { max_secs, max_nanos, secs } => { + // constant folding means this is at least as fast as `gen_range` + let nano_range = Uniform::new(0, 1_000_000_000); + loop { + let s = secs.sample(rng); + let n = nano_range.sample(rng); + if !(s == max_secs && n > max_nanos) { + let sum = n + self.offset; + break Duration::new(s, sum); + } + } + } + } + } +} + +#[cfg(test)] +mod tests { + use Rng; + use rngs::mock::StepRng; + use distributions::uniform::Uniform; + use distributions::utils::FloatAsSIMD; + #[cfg(feature="simd_support")] use packed_simd::*; + + #[should_panic] + #[test] + fn test_uniform_bad_limits_equal_int() { + Uniform::new(10, 10); + } + + #[test] + fn test_uniform_good_limits_equal_int() { + let mut rng = ::test::rng(804); + let dist = Uniform::new_inclusive(10, 10); + for _ in 0..20 { + assert_eq!(rng.sample(dist), 10); + } + } + + #[should_panic] + #[test] + fn test_uniform_bad_limits_flipped_int() { + Uniform::new(10, 5); + } + + #[test] + fn test_integers() { + use core::{i8, i16, i32, i64, isize}; + use core::{u8, u16, u32, u64, usize}; + #[cfg(all(rustc_1_26, not(target_os = "emscripten")))] + use core::{i128, u128}; + + let mut rng = ::test::rng(251); + macro_rules! t { + ($ty:ident, $v:expr, $le:expr, $lt:expr) => {{ + for &(low, high) in $v.iter() { + let my_uniform = Uniform::new(low, high); + for _ in 0..1000 { + let v: $ty = rng.sample(my_uniform); + assert!($le(low, v) && $lt(v, high)); + } + + let my_uniform = Uniform::new_inclusive(low, high); + for _ in 0..1000 { + let v: $ty = rng.sample(my_uniform); + assert!($le(low, v) && $le(v, high)); + } + + let my_uniform = Uniform::new(&low, high); + for _ in 0..1000 { + let v: $ty = rng.sample(my_uniform); + assert!($le(low, v) && $lt(v, high)); + } + + let my_uniform = Uniform::new_inclusive(&low, &high); + for _ in 0..1000 { + let v: $ty = rng.sample(my_uniform); + assert!($le(low, v) && $le(v, high)); + } + + for _ in 0..1000 { + let v: $ty = rng.gen_range(low, high); + assert!($le(low, v) && $lt(v, high)); + } + } + }}; + + // scalar bulk + ($($ty:ident),*) => {{ + $(t!( + $ty, + [(0, 10), (10, 127), ($ty::MIN, $ty::MAX)], + |x, y| x <= y, + |x, y| x < y + );)* + }}; + + // simd bulk + ($($ty:ident),* => $scalar:ident) => {{ + $(t!( + $ty, + [ + ($ty::splat(0), $ty::splat(10)), + ($ty::splat(10), $ty::splat(127)), + ($ty::splat($scalar::MIN), $ty::splat($scalar::MAX)), + ], + |x: $ty, y| x.le(y).all(), + |x: $ty, y| x.lt(y).all() + );)* + }}; + } + t!(i8, i16, i32, i64, isize, + u8, u16, u32, u64, usize); + #[cfg(all(rustc_1_26, not(target_os = "emscripten")))] + t!(i128, u128); + + #[cfg(all(feature = "simd_support", feature = "nightly"))] + { + t!(u8x2, u8x4, u8x8, u8x16, u8x32, u8x64 => u8); + t!(i8x2, i8x4, i8x8, i8x16, i8x32, i8x64 => i8); + t!(u16x2, u16x4, u16x8, u16x16, u16x32 => u16); + t!(i16x2, i16x4, i16x8, i16x16, i16x32 => i16); + t!(u32x2, u32x4, u32x8, u32x16 => u32); + t!(i32x2, i32x4, i32x8, i32x16 => i32); + t!(u64x2, u64x4, u64x8 => u64); + t!(i64x2, i64x4, i64x8 => i64); + } + } + + #[test] + fn test_floats() { + let mut rng = ::test::rng(252); + let mut zero_rng = StepRng::new(0, 0); + let mut max_rng = StepRng::new(0xffff_ffff_ffff_ffff, 0); + macro_rules! t { + ($ty:ty, $f_scalar:ident, $bits_shifted:expr) => {{ + let v: &[($f_scalar, $f_scalar)]= + &[(0.0, 100.0), + (-1e35, -1e25), + (1e-35, 1e-25), + (-1e35, 1e35), + (<$f_scalar>::from_bits(0), <$f_scalar>::from_bits(3)), + (-<$f_scalar>::from_bits(10), -<$f_scalar>::from_bits(1)), + (-<$f_scalar>::from_bits(5), 0.0), + (-<$f_scalar>::from_bits(7), -0.0), + (10.0, ::core::$f_scalar::MAX), + (-100.0, ::core::$f_scalar::MAX), + (-::core::$f_scalar::MAX / 5.0, ::core::$f_scalar::MAX), + (-::core::$f_scalar::MAX, ::core::$f_scalar::MAX / 5.0), + (-::core::$f_scalar::MAX * 0.8, ::core::$f_scalar::MAX * 0.7), + (-::core::$f_scalar::MAX, ::core::$f_scalar::MAX), + ]; + for &(low_scalar, high_scalar) in v.iter() { + for lane in 0..<$ty>::lanes() { + let low = <$ty>::splat(0.0 as $f_scalar).replace(lane, low_scalar); + let high = <$ty>::splat(1.0 as $f_scalar).replace(lane, high_scalar); + let my_uniform = Uniform::new(low, high); + let my_incl_uniform = Uniform::new_inclusive(low, high); + for _ in 0..100 { + let v = rng.sample(my_uniform).extract(lane); + assert!(low_scalar <= v && v < high_scalar); + let v = rng.sample(my_incl_uniform).extract(lane); + assert!(low_scalar <= v && v <= high_scalar); + let v = rng.gen_range(low, high).extract(lane); + assert!(low_scalar <= v && v < high_scalar); + } + + assert_eq!(rng.sample(Uniform::new_inclusive(low, low)).extract(lane), low_scalar); + + assert_eq!(zero_rng.sample(my_uniform).extract(lane), low_scalar); + assert_eq!(zero_rng.sample(my_incl_uniform).extract(lane), low_scalar); + assert_eq!(zero_rng.gen_range(low, high).extract(lane), low_scalar); + assert!(max_rng.sample(my_uniform).extract(lane) < high_scalar); + assert!(max_rng.sample(my_incl_uniform).extract(lane) <= high_scalar); + + // Don't run this test for really tiny differences between high and low + // since for those rounding might result in selecting high for a very + // long time. + if (high_scalar - low_scalar) > 0.0001 { + let mut lowering_max_rng = + StepRng::new(0xffff_ffff_ffff_ffff, + (-1i64 << $bits_shifted) as u64); + assert!(lowering_max_rng.gen_range(low, high).extract(lane) < high_scalar); + } + } + } + + assert_eq!(rng.sample(Uniform::new_inclusive(::core::$f_scalar::MAX, + ::core::$f_scalar::MAX)), + ::core::$f_scalar::MAX); + assert_eq!(rng.sample(Uniform::new_inclusive(-::core::$f_scalar::MAX, + -::core::$f_scalar::MAX)), + -::core::$f_scalar::MAX); + }} + } + + t!(f32, f32, 32 - 23); + t!(f64, f64, 64 - 52); + #[cfg(feature="simd_support")] + { + t!(f32x2, f32, 32 - 23); + t!(f32x4, f32, 32 - 23); + t!(f32x8, f32, 32 - 23); + t!(f32x16, f32, 32 - 23); + t!(f64x2, f64, 64 - 52); + t!(f64x4, f64, 64 - 52); + t!(f64x8, f64, 64 - 52); + } + } + + #[test] + #[cfg(all(feature="std", + not(target_arch = "wasm32"), + not(target_arch = "asmjs")))] + fn test_float_assertions() { + use std::panic::catch_unwind; + use super::SampleUniform; + fn range(low: T, high: T) { + let mut rng = ::test::rng(253); + rng.gen_range(low, high); + } + + macro_rules! t { + ($ty:ident, $f_scalar:ident) => {{ + let v: &[($f_scalar, $f_scalar)] = + &[(::std::$f_scalar::NAN, 0.0), + (1.0, ::std::$f_scalar::NAN), + (::std::$f_scalar::NAN, ::std::$f_scalar::NAN), + (1.0, 0.5), + (::std::$f_scalar::MAX, -::std::$f_scalar::MAX), + (::std::$f_scalar::INFINITY, ::std::$f_scalar::INFINITY), + (::std::$f_scalar::NEG_INFINITY, ::std::$f_scalar::NEG_INFINITY), + (::std::$f_scalar::NEG_INFINITY, 5.0), + (5.0, ::std::$f_scalar::INFINITY), + (::std::$f_scalar::NAN, ::std::$f_scalar::INFINITY), + (::std::$f_scalar::NEG_INFINITY, ::std::$f_scalar::NAN), + (::std::$f_scalar::NEG_INFINITY, ::std::$f_scalar::INFINITY), + ]; + for &(low_scalar, high_scalar) in v.iter() { + for lane in 0..<$ty>::lanes() { + let low = <$ty>::splat(0.0 as $f_scalar).replace(lane, low_scalar); + let high = <$ty>::splat(1.0 as $f_scalar).replace(lane, high_scalar); + assert!(catch_unwind(|| range(low, high)).is_err()); + assert!(catch_unwind(|| Uniform::new(low, high)).is_err()); + assert!(catch_unwind(|| Uniform::new_inclusive(low, high)).is_err()); + assert!(catch_unwind(|| range(low, low)).is_err()); + assert!(catch_unwind(|| Uniform::new(low, low)).is_err()); + } + } + }} + } + + t!(f32, f32); + t!(f64, f64); + #[cfg(feature="simd_support")] + { + t!(f32x2, f32); + t!(f32x4, f32); + t!(f32x8, f32); + t!(f32x16, f32); + t!(f64x2, f64); + t!(f64x4, f64); + t!(f64x8, f64); + } + } + + + #[test] + #[cfg(any(feature = "std", rustc_1_25))] + fn test_durations() { + #[cfg(feature = "std")] + use std::time::Duration; + #[cfg(all(not(feature = "std"), rustc_1_25))] + use core::time::Duration; + + let mut rng = ::test::rng(253); + + let v = &[(Duration::new(10, 50000), Duration::new(100, 1234)), + (Duration::new(0, 100), Duration::new(1, 50)), + (Duration::new(0, 0), Duration::new(u64::max_value(), 999_999_999))]; + for &(low, high) in v.iter() { + let my_uniform = Uniform::new(low, high); + for _ in 0..1000 { + let v = rng.sample(my_uniform); + assert!(low <= v && v < high); + } + } + } + + #[test] + fn test_custom_uniform() { + use distributions::uniform::{UniformSampler, UniformFloat, SampleUniform, SampleBorrow}; + #[derive(Clone, Copy, PartialEq, PartialOrd)] + struct MyF32 { + x: f32, + } + #[derive(Clone, Copy, Debug)] + struct UniformMyF32 { + inner: UniformFloat, + } + impl UniformSampler for UniformMyF32 { + type X = MyF32; + fn new(low: B1, high: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + UniformMyF32 { + inner: UniformFloat::::new(low.borrow().x, high.borrow().x), + } + } + fn new_inclusive(low: B1, high: B2) -> Self + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + UniformSampler::new(low, high) + } + fn sample(&self, rng: &mut R) -> Self::X { + MyF32 { x: self.inner.sample(rng) } + } + } + impl SampleUniform for MyF32 { + type Sampler = UniformMyF32; + } + + let (low, high) = (MyF32{ x: 17.0f32 }, MyF32{ x: 22.0f32 }); + let uniform = Uniform::new(low, high); + let mut rng = ::test::rng(804); + for _ in 0..100 { + let x: MyF32 = rng.sample(uniform); + assert!(low <= x && x < high); + } + } + + #[test] + fn test_uniform_from_std_range() { + let r = Uniform::from(2u32..7); + assert_eq!(r.inner.low, 2); + assert_eq!(r.inner.range, 5); + let r = Uniform::from(2.0f64..7.0); + assert_eq!(r.inner.low, 2.0); + assert_eq!(r.inner.scale, 5.0); + } + + #[cfg(rustc_1_27)] + #[test] + fn test_uniform_from_std_range_inclusive() { + let r = Uniform::from(2u32..=6); + assert_eq!(r.inner.low, 2); + assert_eq!(r.inner.range, 5); + let r = Uniform::from(2.0f64..=7.0); + assert_eq!(r.inner.low, 2.0); + assert!(r.inner.scale > 5.0); + assert!(r.inner.scale < 5.0 + 1e-14); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/unit_circle.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/unit_circle.rs new file mode 100644 index 0000000..01ab76a --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/unit_circle.rs @@ -0,0 +1,101 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use Rng; +use distributions::{Distribution, Uniform}; + +/// Samples uniformly from the edge of the unit circle in two dimensions. +/// +/// Implemented via a method by von Neumann[^1]. +/// +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{UnitCircle, Distribution}; +/// +/// let circle = UnitCircle::new(); +/// let v = circle.sample(&mut rand::thread_rng()); +/// println!("{:?} is from the unit circle.", v) +/// ``` +/// +/// [^1]: von Neumann, J. (1951) [*Various Techniques Used in Connection with +/// Random Digits.*](https://mcnp.lanl.gov/pdf_files/nbs_vonneumann.pdf) +/// NBS Appl. Math. Ser., No. 12. Washington, DC: U.S. Government Printing +/// Office, pp. 36-38. +#[derive(Clone, Copy, Debug)] +pub struct UnitCircle; + +impl UnitCircle { + /// Construct a new `UnitCircle` distribution. + #[inline] + pub fn new() -> UnitCircle { + UnitCircle + } +} + +impl Distribution<[f64; 2]> for UnitCircle { + #[inline] + fn sample(&self, rng: &mut R) -> [f64; 2] { + let uniform = Uniform::new(-1., 1.); + let mut x1; + let mut x2; + let mut sum; + loop { + x1 = uniform.sample(rng); + x2 = uniform.sample(rng); + sum = x1*x1 + x2*x2; + if sum < 1. { + break; + } + } + let diff = x1*x1 - x2*x2; + [diff / sum, 2.*x1*x2 / sum] + } +} + +#[cfg(test)] +mod tests { + use distributions::Distribution; + use super::UnitCircle; + + /// Assert that two numbers are almost equal to each other. + /// + /// On panic, this macro will print the values of the expressions with their + /// debug representations. + macro_rules! assert_almost_eq { + ($a:expr, $b:expr, $prec:expr) => ( + let diff = ($a - $b).abs(); + if diff > $prec { + panic!(format!( + "assertion failed: `abs(left - right) = {:.1e} < {:e}`, \ + (left: `{}`, right: `{}`)", + diff, $prec, $a, $b)); + } + ); + } + + #[test] + fn norm() { + let mut rng = ::test::rng(1); + let dist = UnitCircle::new(); + for _ in 0..1000 { + let x = dist.sample(&mut rng); + assert_almost_eq!(x[0]*x[0] + x[1]*x[1], 1., 1e-15); + } + } + + #[test] + fn value_stability() { + let mut rng = ::test::rng(2); + let dist = UnitCircle::new(); + assert_eq!(dist.sample(&mut rng), [-0.8032118336637037, 0.5956935036263119]); + assert_eq!(dist.sample(&mut rng), [-0.4742919588505423, -0.880367615130018]); + assert_eq!(dist.sample(&mut rng), [0.9297328981467168, 0.368234623716601]); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/unit_sphere.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/unit_sphere.rs new file mode 100644 index 0000000..37de88b --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/unit_sphere.rs @@ -0,0 +1,99 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use Rng; +use distributions::{Distribution, Uniform}; + +/// Samples uniformly from the surface of the unit sphere in three dimensions. +/// +/// Implemented via a method by Marsaglia[^1]. +/// +/// +/// # Example +/// +/// ``` +/// use rand::distributions::{UnitSphereSurface, Distribution}; +/// +/// let sphere = UnitSphereSurface::new(); +/// let v = sphere.sample(&mut rand::thread_rng()); +/// println!("{:?} is from the unit sphere surface.", v) +/// ``` +/// +/// [^1]: Marsaglia, George (1972). [*Choosing a Point from the Surface of a +/// Sphere.*](https://doi.org/10.1214/aoms/1177692644) +/// Ann. Math. Statist. 43, no. 2, 645--646. +#[derive(Clone, Copy, Debug)] +pub struct UnitSphereSurface; + +impl UnitSphereSurface { + /// Construct a new `UnitSphereSurface` distribution. + #[inline] + pub fn new() -> UnitSphereSurface { + UnitSphereSurface + } +} + +impl Distribution<[f64; 3]> for UnitSphereSurface { + #[inline] + fn sample(&self, rng: &mut R) -> [f64; 3] { + let uniform = Uniform::new(-1., 1.); + loop { + let (x1, x2) = (uniform.sample(rng), uniform.sample(rng)); + let sum = x1*x1 + x2*x2; + if sum >= 1. { + continue; + } + let factor = 2. * (1.0_f64 - sum).sqrt(); + return [x1 * factor, x2 * factor, 1. - 2.*sum]; + } + } +} + +#[cfg(test)] +mod tests { + use distributions::Distribution; + use super::UnitSphereSurface; + + /// Assert that two numbers are almost equal to each other. + /// + /// On panic, this macro will print the values of the expressions with their + /// debug representations. + macro_rules! assert_almost_eq { + ($a:expr, $b:expr, $prec:expr) => ( + let diff = ($a - $b).abs(); + if diff > $prec { + panic!(format!( + "assertion failed: `abs(left - right) = {:.1e} < {:e}`, \ + (left: `{}`, right: `{}`)", + diff, $prec, $a, $b)); + } + ); + } + + #[test] + fn norm() { + let mut rng = ::test::rng(1); + let dist = UnitSphereSurface::new(); + for _ in 0..1000 { + let x = dist.sample(&mut rng); + assert_almost_eq!(x[0]*x[0] + x[1]*x[1] + x[2]*x[2], 1., 1e-15); + } + } + + #[test] + fn value_stability() { + let mut rng = ::test::rng(2); + let dist = UnitSphereSurface::new(); + assert_eq!(dist.sample(&mut rng), + [-0.24950027180862533, -0.7552572587896719, 0.6060825747478084]); + assert_eq!(dist.sample(&mut rng), + [0.47604534507233487, -0.797200864987207, -0.3712837328763685]); + assert_eq!(dist.sample(&mut rng), + [0.9795722330927367, 0.18692349236651176, 0.07414747571708524]); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/utils.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/utils.rs new file mode 100644 index 0000000..d4d3642 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/utils.rs @@ -0,0 +1,504 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Math helper functions + +#[cfg(feature="simd_support")] +use packed_simd::*; +#[cfg(feature="std")] +use distributions::ziggurat_tables; +#[cfg(feature="std")] +use Rng; + + +pub trait WideningMultiply { + type Output; + + fn wmul(self, x: RHS) -> Self::Output; +} + +macro_rules! wmul_impl { + ($ty:ty, $wide:ty, $shift:expr) => { + impl WideningMultiply for $ty { + type Output = ($ty, $ty); + + #[inline(always)] + fn wmul(self, x: $ty) -> Self::Output { + let tmp = (self as $wide) * (x as $wide); + ((tmp >> $shift) as $ty, tmp as $ty) + } + } + }; + + // simd bulk implementation + ($(($ty:ident, $wide:ident),)+, $shift:expr) => { + $( + impl WideningMultiply for $ty { + type Output = ($ty, $ty); + + #[inline(always)] + fn wmul(self, x: $ty) -> Self::Output { + // For supported vectors, this should compile to a couple + // supported multiply & swizzle instructions (no actual + // casting). + // TODO: optimize + let y: $wide = self.cast(); + let x: $wide = x.cast(); + let tmp = y * x; + let hi: $ty = (tmp >> $shift).cast(); + let lo: $ty = tmp.cast(); + (hi, lo) + } + } + )+ + }; +} +wmul_impl! { u8, u16, 8 } +wmul_impl! { u16, u32, 16 } +wmul_impl! { u32, u64, 32 } +#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] +wmul_impl! { u64, u128, 64 } + +// This code is a translation of the __mulddi3 function in LLVM's +// compiler-rt. It is an optimised variant of the common method +// `(a + b) * (c + d) = ac + ad + bc + bd`. +// +// For some reason LLVM can optimise the C version very well, but +// keeps shuffling registers in this Rust translation. +macro_rules! wmul_impl_large { + ($ty:ty, $half:expr) => { + impl WideningMultiply for $ty { + type Output = ($ty, $ty); + + #[inline(always)] + fn wmul(self, b: $ty) -> Self::Output { + const LOWER_MASK: $ty = !0 >> $half; + let mut low = (self & LOWER_MASK).wrapping_mul(b & LOWER_MASK); + let mut t = low >> $half; + low &= LOWER_MASK; + t += (self >> $half).wrapping_mul(b & LOWER_MASK); + low += (t & LOWER_MASK) << $half; + let mut high = t >> $half; + t = low >> $half; + low &= LOWER_MASK; + t += (b >> $half).wrapping_mul(self & LOWER_MASK); + low += (t & LOWER_MASK) << $half; + high += t >> $half; + high += (self >> $half).wrapping_mul(b >> $half); + + (high, low) + } + } + }; + + // simd bulk implementation + (($($ty:ty,)+) $scalar:ty, $half:expr) => { + $( + impl WideningMultiply for $ty { + type Output = ($ty, $ty); + + #[inline(always)] + fn wmul(self, b: $ty) -> Self::Output { + // needs wrapping multiplication + const LOWER_MASK: $scalar = !0 >> $half; + let mut low = (self & LOWER_MASK) * (b & LOWER_MASK); + let mut t = low >> $half; + low &= LOWER_MASK; + t += (self >> $half) * (b & LOWER_MASK); + low += (t & LOWER_MASK) << $half; + let mut high = t >> $half; + t = low >> $half; + low &= LOWER_MASK; + t += (b >> $half) * (self & LOWER_MASK); + low += (t & LOWER_MASK) << $half; + high += t >> $half; + high += (self >> $half) * (b >> $half); + + (high, low) + } + } + )+ + }; +} +#[cfg(not(all(rustc_1_26, not(target_os = "emscripten"))))] +wmul_impl_large! { u64, 32 } +#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] +wmul_impl_large! { u128, 64 } + +macro_rules! wmul_impl_usize { + ($ty:ty) => { + impl WideningMultiply for usize { + type Output = (usize, usize); + + #[inline(always)] + fn wmul(self, x: usize) -> Self::Output { + let (high, low) = (self as $ty).wmul(x as $ty); + (high as usize, low as usize) + } + } + } +} +#[cfg(target_pointer_width = "32")] +wmul_impl_usize! { u32 } +#[cfg(target_pointer_width = "64")] +wmul_impl_usize! { u64 } + +#[cfg(all(feature = "simd_support", feature = "nightly"))] +mod simd_wmul { + #[cfg(target_arch = "x86")] + use core::arch::x86::*; + #[cfg(target_arch = "x86_64")] + use core::arch::x86_64::*; + use super::*; + + wmul_impl! { + (u8x2, u16x2), + (u8x4, u16x4), + (u8x8, u16x8), + (u8x16, u16x16), + (u8x32, u16x32),, + 8 + } + + wmul_impl! { (u16x2, u32x2),, 16 } + #[cfg(not(target_feature = "sse2"))] + wmul_impl! { (u16x4, u32x4),, 16 } + #[cfg(not(target_feature = "sse4.2"))] + wmul_impl! { (u16x8, u32x8),, 16 } + #[cfg(not(target_feature = "avx2"))] + wmul_impl! { (u16x16, u32x16),, 16 } + + // 16-bit lane widths allow use of the x86 `mulhi` instructions, which + // means `wmul` can be implemented with only two instructions. + #[allow(unused_macros)] + macro_rules! wmul_impl_16 { + ($ty:ident, $intrinsic:ident, $mulhi:ident, $mullo:ident) => { + impl WideningMultiply for $ty { + type Output = ($ty, $ty); + + #[inline(always)] + fn wmul(self, x: $ty) -> Self::Output { + let b = $intrinsic::from_bits(x); + let a = $intrinsic::from_bits(self); + let hi = $ty::from_bits(unsafe { $mulhi(a, b) }); + let lo = $ty::from_bits(unsafe { $mullo(a, b) }); + (hi, lo) + } + } + }; + } + + #[cfg(target_feature = "sse2")] + wmul_impl_16! { u16x4, __m64, _mm_mulhi_pu16, _mm_mullo_pi16 } + #[cfg(target_feature = "sse4.2")] + wmul_impl_16! { u16x8, __m128i, _mm_mulhi_epu16, _mm_mullo_epi16 } + #[cfg(target_feature = "avx2")] + wmul_impl_16! { u16x16, __m256i, _mm256_mulhi_epu16, _mm256_mullo_epi16 } + // FIXME: there are no `__m512i` types in stdsimd yet, so `wmul::` + // cannot use the same implementation. + + wmul_impl! { + (u32x2, u64x2), + (u32x4, u64x4), + (u32x8, u64x8),, + 32 + } + + // TODO: optimize, this seems to seriously slow things down + wmul_impl_large! { (u8x64,) u8, 4 } + wmul_impl_large! { (u16x32,) u16, 8 } + wmul_impl_large! { (u32x16,) u32, 16 } + wmul_impl_large! { (u64x2, u64x4, u64x8,) u64, 32 } +} +#[cfg(all(feature = "simd_support", feature = "nightly"))] +pub use self::simd_wmul::*; + + +/// Helper trait when dealing with scalar and SIMD floating point types. +pub(crate) trait FloatSIMDUtils { + // `PartialOrd` for vectors compares lexicographically. We want to compare all + // the individual SIMD lanes instead, and get the combined result over all + // lanes. This is possible using something like `a.lt(b).all()`, but we + // implement it as a trait so we can write the same code for `f32` and `f64`. + // Only the comparison functions we need are implemented. + fn all_lt(self, other: Self) -> bool; + fn all_le(self, other: Self) -> bool; + fn all_finite(self) -> bool; + + type Mask; + fn finite_mask(self) -> Self::Mask; + fn gt_mask(self, other: Self) -> Self::Mask; + fn ge_mask(self, other: Self) -> Self::Mask; + + // Decrease all lanes where the mask is `true` to the next lower value + // representable by the floating-point type. At least one of the lanes + // must be set. + fn decrease_masked(self, mask: Self::Mask) -> Self; + + // Convert from int value. Conversion is done while retaining the numerical + // value, not by retaining the binary representation. + type UInt; + fn cast_from_int(i: Self::UInt) -> Self; +} + +/// Implement functions available in std builds but missing from core primitives +#[cfg(not(std))] +pub(crate) trait Float : Sized { + type Bits; + + fn is_nan(self) -> bool; + fn is_infinite(self) -> bool; + fn is_finite(self) -> bool; + fn to_bits(self) -> Self::Bits; + fn from_bits(v: Self::Bits) -> Self; +} + +/// Implement functions on f32/f64 to give them APIs similar to SIMD types +pub(crate) trait FloatAsSIMD : Sized { + #[inline(always)] + fn lanes() -> usize { 1 } + #[inline(always)] + fn splat(scalar: Self) -> Self { scalar } + #[inline(always)] + fn extract(self, index: usize) -> Self { debug_assert_eq!(index, 0); self } + #[inline(always)] + fn replace(self, index: usize, new_value: Self) -> Self { debug_assert_eq!(index, 0); new_value } +} + +pub(crate) trait BoolAsSIMD : Sized { + fn any(self) -> bool; + fn all(self) -> bool; + fn none(self) -> bool; +} + +impl BoolAsSIMD for bool { + #[inline(always)] + fn any(self) -> bool { self } + #[inline(always)] + fn all(self) -> bool { self } + #[inline(always)] + fn none(self) -> bool { !self } +} + +macro_rules! scalar_float_impl { + ($ty:ident, $uty:ident) => { + #[cfg(not(std))] + impl Float for $ty { + type Bits = $uty; + + #[inline] + fn is_nan(self) -> bool { + self != self + } + + #[inline] + fn is_infinite(self) -> bool { + self == ::core::$ty::INFINITY || self == ::core::$ty::NEG_INFINITY + } + + #[inline] + fn is_finite(self) -> bool { + !(self.is_nan() || self.is_infinite()) + } + + #[inline] + fn to_bits(self) -> Self::Bits { + unsafe { ::core::mem::transmute(self) } + } + + #[inline] + fn from_bits(v: Self::Bits) -> Self { + // It turns out the safety issues with sNaN were overblown! Hooray! + unsafe { ::core::mem::transmute(v) } + } + } + + impl FloatSIMDUtils for $ty { + type Mask = bool; + #[inline(always)] + fn all_lt(self, other: Self) -> bool { self < other } + #[inline(always)] + fn all_le(self, other: Self) -> bool { self <= other } + #[inline(always)] + fn all_finite(self) -> bool { self.is_finite() } + #[inline(always)] + fn finite_mask(self) -> Self::Mask { self.is_finite() } + #[inline(always)] + fn gt_mask(self, other: Self) -> Self::Mask { self > other } + #[inline(always)] + fn ge_mask(self, other: Self) -> Self::Mask { self >= other } + #[inline(always)] + fn decrease_masked(self, mask: Self::Mask) -> Self { + debug_assert!(mask, "At least one lane must be set"); + <$ty>::from_bits(self.to_bits() - 1) + } + type UInt = $uty; + fn cast_from_int(i: Self::UInt) -> Self { i as $ty } + } + + impl FloatAsSIMD for $ty {} + } +} + +scalar_float_impl!(f32, u32); +scalar_float_impl!(f64, u64); + + +#[cfg(feature="simd_support")] +macro_rules! simd_impl { + ($ty:ident, $f_scalar:ident, $mty:ident, $uty:ident) => { + impl FloatSIMDUtils for $ty { + type Mask = $mty; + #[inline(always)] + fn all_lt(self, other: Self) -> bool { self.lt(other).all() } + #[inline(always)] + fn all_le(self, other: Self) -> bool { self.le(other).all() } + #[inline(always)] + fn all_finite(self) -> bool { self.finite_mask().all() } + #[inline(always)] + fn finite_mask(self) -> Self::Mask { + // This can possibly be done faster by checking bit patterns + let neg_inf = $ty::splat(::core::$f_scalar::NEG_INFINITY); + let pos_inf = $ty::splat(::core::$f_scalar::INFINITY); + self.gt(neg_inf) & self.lt(pos_inf) + } + #[inline(always)] + fn gt_mask(self, other: Self) -> Self::Mask { self.gt(other) } + #[inline(always)] + fn ge_mask(self, other: Self) -> Self::Mask { self.ge(other) } + #[inline(always)] + fn decrease_masked(self, mask: Self::Mask) -> Self { + // Casting a mask into ints will produce all bits set for + // true, and 0 for false. Adding that to the binary + // representation of a float means subtracting one from + // the binary representation, resulting in the next lower + // value representable by $ty. This works even when the + // current value is infinity. + debug_assert!(mask.any(), "At least one lane must be set"); + <$ty>::from_bits(<$uty>::from_bits(self) + <$uty>::from_bits(mask)) + } + type UInt = $uty; + fn cast_from_int(i: Self::UInt) -> Self { i.cast() } + } + } +} + +#[cfg(feature="simd_support")] simd_impl! { f32x2, f32, m32x2, u32x2 } +#[cfg(feature="simd_support")] simd_impl! { f32x4, f32, m32x4, u32x4 } +#[cfg(feature="simd_support")] simd_impl! { f32x8, f32, m32x8, u32x8 } +#[cfg(feature="simd_support")] simd_impl! { f32x16, f32, m32x16, u32x16 } +#[cfg(feature="simd_support")] simd_impl! { f64x2, f64, m64x2, u64x2 } +#[cfg(feature="simd_support")] simd_impl! { f64x4, f64, m64x4, u64x4 } +#[cfg(feature="simd_support")] simd_impl! { f64x8, f64, m64x8, u64x8 } + +/// Calculates ln(gamma(x)) (natural logarithm of the gamma +/// function) using the Lanczos approximation. +/// +/// The approximation expresses the gamma function as: +/// `gamma(z+1) = sqrt(2*pi)*(z+g+0.5)^(z+0.5)*exp(-z-g-0.5)*Ag(z)` +/// `g` is an arbitrary constant; we use the approximation with `g=5`. +/// +/// Noting that `gamma(z+1) = z*gamma(z)` and applying `ln` to both sides: +/// `ln(gamma(z)) = (z+0.5)*ln(z+g+0.5)-(z+g+0.5) + ln(sqrt(2*pi)*Ag(z)/z)` +/// +/// `Ag(z)` is an infinite series with coefficients that can be calculated +/// ahead of time - we use just the first 6 terms, which is good enough +/// for most purposes. +#[cfg(feature="std")] +pub fn log_gamma(x: f64) -> f64 { + // precalculated 6 coefficients for the first 6 terms of the series + let coefficients: [f64; 6] = [ + 76.18009172947146, + -86.50532032941677, + 24.01409824083091, + -1.231739572450155, + 0.1208650973866179e-2, + -0.5395239384953e-5, + ]; + + // (x+0.5)*ln(x+g+0.5)-(x+g+0.5) + let tmp = x + 5.5; + let log = (x + 0.5) * tmp.ln() - tmp; + + // the first few terms of the series for Ag(x) + let mut a = 1.000000000190015; + let mut denom = x; + for coeff in &coefficients { + denom += 1.0; + a += coeff / denom; + } + + // get everything together + // a is Ag(x) + // 2.5066... is sqrt(2pi) + log + (2.5066282746310005 * a / x).ln() +} + +/// Sample a random number using the Ziggurat method (specifically the +/// ZIGNOR variant from Doornik 2005). Most of the arguments are +/// directly from the paper: +/// +/// * `rng`: source of randomness +/// * `symmetric`: whether this is a symmetric distribution, or one-sided with P(x < 0) = 0. +/// * `X`: the $x_i$ abscissae. +/// * `F`: precomputed values of the PDF at the $x_i$, (i.e. $f(x_i)$) +/// * `F_DIFF`: precomputed values of $f(x_i) - f(x_{i+1})$ +/// * `pdf`: the probability density function +/// * `zero_case`: manual sampling from the tail when we chose the +/// bottom box (i.e. i == 0) + +// the perf improvement (25-50%) is definitely worth the extra code +// size from force-inlining. +#[cfg(feature="std")] +#[inline(always)] +pub fn ziggurat( + rng: &mut R, + symmetric: bool, + x_tab: ziggurat_tables::ZigTable, + f_tab: ziggurat_tables::ZigTable, + mut pdf: P, + mut zero_case: Z) + -> f64 where P: FnMut(f64) -> f64, Z: FnMut(&mut R, f64) -> f64 { + use distributions::float::IntoFloat; + loop { + // As an optimisation we re-implement the conversion to a f64. + // From the remaining 12 most significant bits we use 8 to construct `i`. + // This saves us generating a whole extra random number, while the added + // precision of using 64 bits for f64 does not buy us much. + let bits = rng.next_u64(); + let i = bits as usize & 0xff; + + let u = if symmetric { + // Convert to a value in the range [2,4) and substract to get [-1,1) + // We can't convert to an open range directly, that would require + // substracting `3.0 - EPSILON`, which is not representable. + // It is possible with an extra step, but an open range does not + // seem neccesary for the ziggurat algorithm anyway. + (bits >> 12).into_float_with_exponent(1) - 3.0 + } else { + // Convert to a value in the range [1,2) and substract to get (0,1) + (bits >> 12).into_float_with_exponent(0) + - (1.0 - ::core::f64::EPSILON / 2.0) + }; + let x = u * x_tab[i]; + + let test_x = if symmetric { x.abs() } else {x}; + + // algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i]) + if test_x < x_tab[i + 1] { + return x; + } + if i == 0 { + return zero_case(rng, u); + } + // algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1 + if f_tab[i + 1] + (f_tab[i] - f_tab[i + 1]) * rng.gen::() < pdf(x) { + return x; + } + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/weibull.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/weibull.rs new file mode 100644 index 0000000..5fbe10a --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/weibull.rs @@ -0,0 +1,71 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Weibull distribution. + +use Rng; +use distributions::{Distribution, OpenClosed01}; + +/// Samples floating-point numbers according to the Weibull distribution +/// +/// # Example +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::Weibull; +/// +/// let val: f64 = SmallRng::from_entropy().sample(Weibull::new(1., 10.)); +/// println!("{}", val); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Weibull { + inv_shape: f64, + scale: f64, +} + +impl Weibull { + /// Construct a new `Weibull` distribution with given `scale` and `shape`. + /// + /// # Panics + /// + /// `scale` and `shape` have to be non-zero and positive. + pub fn new(scale: f64, shape: f64) -> Weibull { + assert!((scale > 0.) & (shape > 0.)); + Weibull { inv_shape: 1./shape, scale } + } +} + +impl Distribution for Weibull { + fn sample(&self, rng: &mut R) -> f64 { + let x: f64 = rng.sample(OpenClosed01); + self.scale * (-x.ln()).powf(self.inv_shape) + } +} + +#[cfg(test)] +mod tests { + use distributions::Distribution; + use super::Weibull; + + #[test] + #[should_panic] + fn invalid() { + Weibull::new(0., 0.); + } + + #[test] + fn sample() { + let scale = 1.0; + let shape = 2.0; + let d = Weibull::new(scale, shape); + let mut rng = ::test::rng(1); + for _ in 0..1000 { + let r = d.sample(&mut rng); + assert!(r >= 0.); + } + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/weighted.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/weighted.rs new file mode 100644 index 0000000..d749959 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/weighted.rs @@ -0,0 +1,230 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use Rng; +use distributions::Distribution; +use distributions::uniform::{UniformSampler, SampleUniform, SampleBorrow}; +use ::core::cmp::PartialOrd; +use core::fmt; + +// Note that this whole module is only imported if feature="alloc" is enabled. +#[cfg(not(feature="std"))] use alloc::vec::Vec; + +/// A distribution using weighted sampling to pick a discretely selected +/// item. +/// +/// Sampling a `WeightedIndex` distribution returns the index of a randomly +/// selected element from the iterator used when the `WeightedIndex` was +/// created. The chance of a given element being picked is proportional to the +/// value of the element. The weights can use any type `X` for which an +/// implementation of [`Uniform`] exists. +/// +/// # Performance +/// +/// A `WeightedIndex` contains a `Vec` and a [`Uniform`] and so its +/// size is the sum of the size of those objects, possibly plus some alignment. +/// +/// Creating a `WeightedIndex` will allocate enough space to hold `N - 1` +/// weights of type `X`, where `N` is the number of weights. However, since +/// `Vec` doesn't guarantee a particular growth strategy, additional memory +/// might be allocated but not used. Since the `WeightedIndex` object also +/// contains, this might cause additional allocations, though for primitive +/// types, ['Uniform`] doesn't allocate any memory. +/// +/// Time complexity of sampling from `WeightedIndex` is `O(log N)` where +/// `N` is the number of weights. +/// +/// Sampling from `WeightedIndex` will result in a single call to +/// `Uniform::sample` (method of the [`Distribution`] trait), which typically +/// will request a single value from the underlying [`RngCore`], though the +/// exact number depends on the implementaiton of `Uniform::sample`. +/// +/// # Example +/// +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::WeightedIndex; +/// +/// let choices = ['a', 'b', 'c']; +/// let weights = [2, 1, 1]; +/// let dist = WeightedIndex::new(&weights).unwrap(); +/// let mut rng = thread_rng(); +/// for _ in 0..100 { +/// // 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c' +/// println!("{}", choices[dist.sample(&mut rng)]); +/// } +/// +/// let items = [('a', 0), ('b', 3), ('c', 7)]; +/// let dist2 = WeightedIndex::new(items.iter().map(|item| item.1)).unwrap(); +/// for _ in 0..100 { +/// // 0% chance to print 'a', 30% chance to print 'b', 70% chance to print 'c' +/// println!("{}", items[dist2.sample(&mut rng)].0); +/// } +/// ``` +/// +/// [`Uniform`]: crate::distributions::uniform::Uniform +/// [`RngCore`]: rand_core::RngCore +#[derive(Debug, Clone)] +pub struct WeightedIndex { + cumulative_weights: Vec, + weight_distribution: X::Sampler, +} + +impl WeightedIndex { + /// Creates a new a `WeightedIndex` [`Distribution`] using the values + /// in `weights`. The weights can use any type `X` for which an + /// implementation of [`Uniform`] exists. + /// + /// Returns an error if the iterator is empty, if any weight is `< 0`, or + /// if its total value is 0. + /// + /// [`Uniform`]: crate::distributions::uniform::Uniform + pub fn new(weights: I) -> Result, WeightedError> + where I: IntoIterator, + I::Item: SampleBorrow, + X: for<'a> ::core::ops::AddAssign<&'a X> + + Clone + + Default { + let mut iter = weights.into_iter(); + let mut total_weight: X = iter.next() + .ok_or(WeightedError::NoItem)? + .borrow() + .clone(); + + let zero = ::default(); + if total_weight < zero { + return Err(WeightedError::NegativeWeight); + } + + let mut weights = Vec::::with_capacity(iter.size_hint().0); + for w in iter { + if *w.borrow() < zero { + return Err(WeightedError::NegativeWeight); + } + weights.push(total_weight.clone()); + total_weight += w.borrow(); + } + + if total_weight == zero { + return Err(WeightedError::AllWeightsZero); + } + let distr = X::Sampler::new(zero, total_weight); + + Ok(WeightedIndex { cumulative_weights: weights, weight_distribution: distr }) + } +} + +impl Distribution for WeightedIndex where + X: SampleUniform + PartialOrd { + fn sample(&self, rng: &mut R) -> usize { + use ::core::cmp::Ordering; + let chosen_weight = self.weight_distribution.sample(rng); + // Find the first item which has a weight *higher* than the chosen weight. + self.cumulative_weights.binary_search_by( + |w| if *w <= chosen_weight { Ordering::Less } else { Ordering::Greater }).unwrap_err() + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_weightedindex() { + let mut r = ::test::rng(700); + const N_REPS: u32 = 5000; + let weights = [1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7]; + let total_weight = weights.iter().sum::() as f32; + + let verify = |result: [i32; 14]| { + for (i, count) in result.iter().enumerate() { + let exp = (weights[i] * N_REPS) as f32 / total_weight; + let mut err = (*count as f32 - exp).abs(); + if err != 0.0 { + err /= exp; + } + assert!(err <= 0.25); + } + }; + + // WeightedIndex from vec + let mut chosen = [0i32; 14]; + let distr = WeightedIndex::new(weights.to_vec()).unwrap(); + for _ in 0..N_REPS { + chosen[distr.sample(&mut r)] += 1; + } + verify(chosen); + + // WeightedIndex from slice + chosen = [0i32; 14]; + let distr = WeightedIndex::new(&weights[..]).unwrap(); + for _ in 0..N_REPS { + chosen[distr.sample(&mut r)] += 1; + } + verify(chosen); + + // WeightedIndex from iterator + chosen = [0i32; 14]; + let distr = WeightedIndex::new(weights.iter()).unwrap(); + for _ in 0..N_REPS { + chosen[distr.sample(&mut r)] += 1; + } + verify(chosen); + + for _ in 0..5 { + assert_eq!(WeightedIndex::new(&[0, 1]).unwrap().sample(&mut r), 1); + assert_eq!(WeightedIndex::new(&[1, 0]).unwrap().sample(&mut r), 0); + assert_eq!(WeightedIndex::new(&[0, 0, 0, 0, 10, 0]).unwrap().sample(&mut r), 4); + } + + assert_eq!(WeightedIndex::new(&[10][0..0]).unwrap_err(), WeightedError::NoItem); + assert_eq!(WeightedIndex::new(&[0]).unwrap_err(), WeightedError::AllWeightsZero); + assert_eq!(WeightedIndex::new(&[10, 20, -1, 30]).unwrap_err(), WeightedError::NegativeWeight); + assert_eq!(WeightedIndex::new(&[-10, 20, 1, 30]).unwrap_err(), WeightedError::NegativeWeight); + assert_eq!(WeightedIndex::new(&[-10]).unwrap_err(), WeightedError::NegativeWeight); + } +} + +/// Error type returned from `WeightedIndex::new`. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum WeightedError { + /// The provided iterator contained no items. + NoItem, + + /// A weight lower than zero was used. + NegativeWeight, + + /// All items in the provided iterator had a weight of zero. + AllWeightsZero, +} + +impl WeightedError { + fn msg(&self) -> &str { + match *self { + WeightedError::NoItem => "No items found", + WeightedError::NegativeWeight => "Item has negative weight", + WeightedError::AllWeightsZero => "All items had weight zero", + } + } +} + +#[cfg(feature="std")] +impl ::std::error::Error for WeightedError { + fn description(&self) -> &str { + self.msg() + } + fn cause(&self) -> Option<&::std::error::Error> { + None + } +} + +impl fmt::Display for WeightedError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.msg()) + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/distributions/ziggurat_tables.rs b/third_party/cargo/vendor/rand-0.6.5/src/distributions/ziggurat_tables.rs new file mode 100644 index 0000000..ca1ce30 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/distributions/ziggurat_tables.rs @@ -0,0 +1,279 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tables for distributions which are sampled using the ziggurat +// algorithm. Autogenerated by `ziggurat_tables.py`. + +pub type ZigTable = &'static [f64; 257]; +pub const ZIG_NORM_R: f64 = 3.654152885361008796; +pub static ZIG_NORM_X: [f64; 257] = + [3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074, + 3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434, + 2.978603279880844834, 2.934366867207854224, 2.894121053612348060, 2.857138730872132548, + 2.822877396825325125, 2.790921174000785765, 2.760944005278822555, 2.732685359042827056, + 2.705933656121858100, 2.680514643284522158, 2.656283037575502437, 2.633116393630324570, + 2.610910518487548515, 2.589575986706995181, 2.569035452680536569, 2.549221550323460761, + 2.530075232158516929, 2.511544441625342294, 2.493583041269680667, 2.476149939669143318, + 2.459208374333311298, 2.442725318198956774, 2.426670984935725972, 2.411018413899685520, + 2.395743119780480601, 2.380822795170626005, 2.366237056715818632, 2.351967227377659952, + 2.337996148795031370, 2.324308018869623016, 2.310888250599850036, 2.297723348901329565, + 2.284800802722946056, 2.272108990226823888, 2.259637095172217780, 2.247375032945807760, + 2.235313384928327984, 2.223443340090905718, 2.211756642882544366, 2.200245546609647995, + 2.188902771624720689, 2.177721467738641614, 2.166695180352645966, 2.155817819875063268, + 2.145083634046203613, 2.134487182844320152, 2.124023315687815661, 2.113687150684933957, + 2.103474055713146829, 2.093379631137050279, 2.083399693996551783, 2.073530263516978778, + 2.063767547809956415, 2.054107931648864849, 2.044547965215732788, 2.035084353727808715, + 2.025713947862032960, 2.016433734904371722, 2.007240830558684852, 1.998132471356564244, + 1.989106007615571325, 1.980158896898598364, 1.971288697931769640, 1.962493064942461896, + 1.953769742382734043, 1.945116560006753925, 1.936531428273758904, 1.928012334050718257, + 1.919557336591228847, 1.911164563769282232, 1.902832208548446369, 1.894558525668710081, + 1.886341828534776388, 1.878180486290977669, 1.870072921069236838, 1.862017605397632281, + 1.854013059758148119, 1.846057850283119750, 1.838150586580728607, 1.830289919680666566, + 1.822474540091783224, 1.814703175964167636, 1.806974591348693426, 1.799287584547580199, + 1.791640986550010028, 1.784033659547276329, 1.776464495522344977, 1.768932414909077933, + 1.761436365316706665, 1.753975320315455111, 1.746548278279492994, 1.739154261283669012, + 1.731792314050707216, 1.724461502945775715, 1.717160915015540690, 1.709889657069006086, + 1.702646854797613907, 1.695431651932238548, 1.688243209434858727, 1.681080704722823338, + 1.673943330923760353, 1.666830296159286684, 1.659740822855789499, 1.652674147080648526, + 1.645629517902360339, 1.638606196773111146, 1.631603456932422036, 1.624620582830568427, + 1.617656869570534228, 1.610711622367333673, 1.603784156023583041, 1.596873794420261339, + 1.589979870021648534, 1.583101723393471438, 1.576238702733332886, 1.569390163412534456, + 1.562555467528439657, 1.555733983466554893, 1.548925085471535512, 1.542128153226347553, + 1.535342571438843118, 1.528567729435024614, 1.521803020758293101, 1.515047842773992404, + 1.508301596278571965, 1.501563685112706548, 1.494833515777718391, 1.488110497054654369, + 1.481394039625375747, 1.474683555695025516, 1.467978458615230908, 1.461278162507407830, + 1.454582081885523293, 1.447889631277669675, 1.441200224845798017, 1.434513276002946425, + 1.427828197027290358, 1.421144398672323117, 1.414461289772464658, 1.407778276843371534, + 1.401094763676202559, 1.394410150925071257, 1.387723835686884621, 1.381035211072741964, + 1.374343665770030531, 1.367648583594317957, 1.360949343030101844, 1.354245316759430606, + 1.347535871177359290, 1.340820365893152122, 1.334098153216083604, 1.327368577624624679, + 1.320630975217730096, 1.313884673146868964, 1.307128989027353860, 1.300363230327433728, + 1.293586693733517645, 1.286798664489786415, 1.279998415710333237, 1.273185207661843732, + 1.266358287014688333, 1.259516886060144225, 1.252660221891297887, 1.245787495544997903, + 1.238897891102027415, 1.231990574742445110, 1.225064693752808020, 1.218119375481726552, + 1.211153726239911244, 1.204166830140560140, 1.197157747875585931, 1.190125515422801650, + 1.183069142678760732, 1.175987612011489825, 1.168879876726833800, 1.161744859441574240, + 1.154581450355851802, 1.147388505416733873, 1.140164844363995789, 1.132909248648336975, + 1.125620459211294389, 1.118297174115062909, 1.110938046009249502, 1.103541679420268151, + 1.096106627847603487, 1.088631390649514197, 1.081114409698889389, 1.073554065787871714, + 1.065948674757506653, 1.058296483326006454, 1.050595664586207123, 1.042844313139370538, + 1.035040439828605274, 1.027181966030751292, 1.019266717460529215, 1.011292417434978441, + 1.003256679539591412, 0.995156999629943084, 0.986990747093846266, 0.978755155288937750, + 0.970447311058864615, 0.962064143217605250, 0.953602409875572654, 0.945058684462571130, + 0.936429340280896860, 0.927710533396234771, 0.918898183643734989, 0.909987953490768997, + 0.900975224455174528, 0.891855070726792376, 0.882622229578910122, 0.873271068082494550, + 0.863795545546826915, 0.854189171001560554, 0.844444954902423661, 0.834555354079518752, + 0.824512208745288633, 0.814306670128064347, 0.803929116982664893, 0.793369058833152785, + 0.782615023299588763, 0.771654424216739354, 0.760473406422083165, 0.749056662009581653, + 0.737387211425838629, 0.725446140901303549, 0.713212285182022732, 0.700661841097584448, + 0.687767892786257717, 0.674499822827436479, 0.660822574234205984, 0.646695714884388928, + 0.632072236375024632, 0.616896989996235545, 0.601104617743940417, 0.584616766093722262, + 0.567338257040473026, 0.549151702313026790, 0.529909720646495108, 0.509423329585933393, + 0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746, + 0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806, + 0.000000000000000000]; +pub static ZIG_NORM_F: [f64; 257] = + [0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872, + 0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100, + 0.011842757857943104, 0.013497450601780807, 0.015177088307982072, 0.016880083152595839, + 0.018605121275783350, 0.020351096230109354, 0.022117062707379922, 0.023902203305873237, + 0.025705804008632656, 0.027527235669693315, 0.029365939758230111, 0.031221417192023690, + 0.033093219458688698, 0.034980941461833073, 0.036884215688691151, 0.038802707404656918, + 0.040736110656078753, 0.042684144916619378, 0.044646552251446536, 0.046623094902089664, + 0.048613553216035145, 0.050617723861121788, 0.052635418276973649, 0.054666461325077916, + 0.056710690106399467, 0.058767952921137984, 0.060838108349751806, 0.062921024437977854, + 0.065016577971470438, 0.067124653828023989, 0.069245144397250269, 0.071377949059141965, + 0.073522973714240991, 0.075680130359194964, 0.077849336702372207, 0.080030515814947509, + 0.082223595813495684, 0.084428509570654661, 0.086645194450867782, 0.088873592068594229, + 0.091113648066700734, 0.093365311913026619, 0.095628536713353335, 0.097903279039215627, + 0.100189498769172020, 0.102487158942306270, 0.104796225622867056, 0.107116667775072880, + 0.109448457147210021, 0.111791568164245583, 0.114145977828255210, 0.116511665626037014, + 0.118888613443345698, 0.121276805485235437, 0.123676228202051403, 0.126086870220650349, + 0.128508722280473636, 0.130941777174128166, 0.133386029692162844, 0.135841476571757352, + 0.138308116449064322, 0.140785949814968309, 0.143274978974047118, 0.145775208006537926, + 0.148286642733128721, 0.150809290682410169, 0.153343161060837674, 0.155888264725064563, + 0.158444614156520225, 0.161012223438117663, 0.163591108232982951, 0.166181285765110071, + 0.168782774801850333, 0.171395595638155623, 0.174019770082499359, 0.176655321444406654, + 0.179302274523530397, 0.181960655600216487, 0.184630492427504539, 0.187311814224516926, + 0.190004651671193070, 0.192709036904328807, 0.195425003514885592, 0.198152586546538112, + 0.200891822495431333, 0.203642749311121501, 0.206405406398679298, 0.209179834621935651, + 0.211966076307852941, 0.214764175252008499, 0.217574176725178370, 0.220396127481011589, + 0.223230075764789593, 0.226076071323264877, 0.228934165415577484, 0.231804410825248525, + 0.234686861873252689, 0.237581574432173676, 0.240488605941449107, 0.243408015423711988, + 0.246339863502238771, 0.249284212419516704, 0.252241126056943765, 0.255210669955677150, + 0.258192911338648023, 0.261187919133763713, 0.264195763998317568, 0.267216518344631837, + 0.270250256366959984, 0.273297054069675804, 0.276356989296781264, 0.279430141762765316, + 0.282516593084849388, 0.285616426816658109, 0.288729728483353931, 0.291856585618280984, + 0.294997087801162572, 0.298151326697901342, 0.301319396102034120, 0.304501391977896274, + 0.307697412505553769, 0.310907558127563710, 0.314131931597630143, 0.317370638031222396, + 0.320623784958230129, 0.323891482377732021, 0.327173842814958593, 0.330470981380537099, + 0.333783015832108509, 0.337110066638412809, 0.340452257045945450, 0.343809713148291340, + 0.347182563958251478, 0.350570941482881204, 0.353974980801569250, 0.357394820147290515, + 0.360830600991175754, 0.364282468130549597, 0.367750569780596226, 0.371235057669821344, + 0.374736087139491414, 0.378253817247238111, 0.381788410875031348, 0.385340034841733958, + 0.388908860020464597, 0.392495061461010764, 0.396098818517547080, 0.399720314981931668, + 0.403359739222868885, 0.407017284331247953, 0.410693148271983222, 0.414387534042706784, + 0.418100649839684591, 0.421832709231353298, 0.425583931339900579, 0.429354541031341519, + 0.433144769114574058, 0.436954852549929273, 0.440785034667769915, 0.444635565397727750, + 0.448506701509214067, 0.452398706863882505, 0.456311852680773566, 0.460246417814923481, + 0.464202689050278838, 0.468180961407822172, 0.472181538469883255, 0.476204732721683788, + 0.480250865911249714, 0.484320269428911598, 0.488413284707712059, 0.492530263646148658, + 0.496671569054796314, 0.500837575128482149, 0.505028667945828791, 0.509245245998136142, + 0.513487720749743026, 0.517756517232200619, 0.522052074674794864, 0.526374847174186700, + 0.530725304406193921, 0.535103932383019565, 0.539511234259544614, 0.543947731192649941, + 0.548413963257921133, 0.552910490428519918, 0.557437893621486324, 0.561996775817277916, + 0.566587763258951771, 0.571211506738074970, 0.575868682975210544, 0.580559996103683473, + 0.585286179266300333, 0.590047996335791969, 0.594846243770991268, 0.599681752622167719, + 0.604555390700549533, 0.609468064928895381, 0.614420723892076803, 0.619414360609039205, + 0.624450015550274240, 0.629528779928128279, 0.634651799290960050, 0.639820277456438991, + 0.645035480824251883, 0.650298743114294586, 0.655611470583224665, 0.660975147780241357, + 0.666391343912380640, 0.671861719900766374, 0.677388036222513090, 0.682972161648791376, + 0.688616083008527058, 0.694321916130032579, 0.700091918140490099, 0.705928501336797409, + 0.711834248882358467, 0.717811932634901395, 0.723864533472881599, 0.729995264565802437, + 0.736207598131266683, 0.742505296344636245, 0.748892447223726720, 0.755373506511754500, + 0.761953346841546475, 0.768637315803334831, 0.775431304986138326, 0.782341832659861902, + 0.789376143571198563, 0.796542330428254619, 0.803849483176389490, 0.811307874318219935, + 0.818929191609414797, 0.826726833952094231, 0.834716292992930375, 0.842915653118441077, + 0.851346258465123684, 0.860033621203008636, 0.869008688043793165, 0.878309655816146839, + 0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247, + 0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328, + 1.000000000000000000]; +pub const ZIG_EXP_R: f64 = 7.697117470131050077; +pub static ZIG_EXP_X: [f64; 257] = + [8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696, + 6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488, + 5.323090505754398016, 5.181487281301500047, 5.054288489981304089, 4.938777085901250530, + 4.832939741025112035, 4.735242996601741083, 4.644491885420085175, 4.559737061707351380, + 4.480211746528421912, 4.405287693473573185, 4.334443680317273007, 4.267242480277365857, + 4.203313713735184365, 4.142340865664051464, 4.084051310408297830, 4.028208544647936762, + 3.974606066673788796, 3.923062500135489739, 3.873417670399509127, 3.825529418522336744, + 3.779270992411667862, 3.734528894039797375, 3.691201090237418825, 3.649195515760853770, + 3.608428813128909507, 3.568825265648337020, 3.530315889129343354, 3.492837654774059608, + 3.456332821132760191, 3.420748357251119920, 3.386035442460300970, 3.352149030900109405, + 3.319047470970748037, 3.286692171599068679, 3.255047308570449882, 3.224079565286264160, + 3.193757903212240290, 3.164053358025972873, 3.134938858084440394, 3.106389062339824481, + 3.078380215254090224, 3.050890016615455114, 3.023897504455676621, 2.997382949516130601, + 2.971327759921089662, 2.945714394895045718, 2.920526286512740821, 2.895747768600141825, + 2.871364012015536371, 2.847360965635188812, 2.823725302450035279, 2.800444370250737780, + 2.777506146439756574, 2.754899196562344610, 2.732612636194700073, 2.710636095867928752, + 2.688959688741803689, 2.667573980773266573, 2.646469963151809157, 2.625639026797788489, + 2.605072938740835564, 2.584763820214140750, 2.564704126316905253, 2.544886627111869970, + 2.525304390037828028, 2.505950763528594027, 2.486819361740209455, 2.467904050297364815, + 2.449198932978249754, 2.430698339264419694, 2.412396812688870629, 2.394289099921457886, + 2.376370140536140596, 2.358635057409337321, 2.341079147703034380, 2.323697874390196372, + 2.306486858283579799, 2.289441870532269441, 2.272558825553154804, 2.255833774367219213, + 2.239262898312909034, 2.222842503111036816, 2.206569013257663858, 2.190438966723220027, + 2.174449009937774679, 2.158595893043885994, 2.142876465399842001, 2.127287671317368289, + 2.111826546019042183, 2.096490211801715020, 2.081275874393225145, 2.066180819490575526, + 2.051202409468584786, 2.036338080248769611, 2.021585338318926173, 2.006941757894518563, + 1.992404978213576650, 1.977972700957360441, 1.963642687789548313, 1.949412758007184943, + 1.935280786297051359, 1.921244700591528076, 1.907302480018387536, 1.893452152939308242, + 1.879691795072211180, 1.866019527692827973, 1.852433515911175554, 1.838931967018879954, + 1.825513128903519799, 1.812175288526390649, 1.798916770460290859, 1.785735935484126014, + 1.772631179231305643, 1.759600930889074766, 1.746643651946074405, 1.733757834985571566, + 1.720942002521935299, 1.708194705878057773, 1.695514524101537912, 1.682900062917553896, + 1.670349953716452118, 1.657862852574172763, 1.645437439303723659, 1.633072416535991334, + 1.620766508828257901, 1.608518461798858379, 1.596327041286483395, 1.584191032532688892, + 1.572109239386229707, 1.560080483527888084, 1.548103603714513499, 1.536177455041032092, + 1.524300908219226258, 1.512472848872117082, 1.500692176842816750, 1.488957805516746058, + 1.477268661156133867, 1.465623682245745352, 1.454021818848793446, 1.442462031972012504, + 1.430943292938879674, 1.419464582769983219, 1.408024891569535697, 1.396623217917042137, + 1.385258568263121992, 1.373929956328490576, 1.362636402505086775, 1.351376933258335189, + 1.340150580529504643, 1.328956381137116560, 1.317793376176324749, 1.306660610415174117, + 1.295557131686601027, 1.284481990275012642, 1.273434238296241139, 1.262412929069615330, + 1.251417116480852521, 1.240445854334406572, 1.229498195693849105, 1.218573192208790124, + 1.207669893426761121, 1.196787346088403092, 1.185924593404202199, 1.175080674310911677, + 1.164254622705678921, 1.153445466655774743, 1.142652227581672841, 1.131873919411078511, + 1.121109547701330200, 1.110358108727411031, 1.099618588532597308, 1.088889961938546813, + 1.078171191511372307, 1.067461226479967662, 1.056759001602551429, 1.046063435977044209, + 1.035373431790528542, 1.024687873002617211, 1.014005623957096480, 1.003325527915696735, + 0.992646405507275897, 0.981967053085062602, 0.971286240983903260, 0.960602711668666509, + 0.949915177764075969, 0.939222319955262286, 0.928522784747210395, 0.917815182070044311, + 0.907098082715690257, 0.896370015589889935, 0.885629464761751528, 0.874874866291025066, + 0.864104604811004484, 0.853317009842373353, 0.842510351810368485, 0.831682837734273206, + 0.820832606554411814, 0.809957724057418282, 0.799056177355487174, 0.788125868869492430, + 0.777164609759129710, 0.766170112735434672, 0.755139984181982249, 0.744071715500508102, + 0.732962673584365398, 0.721810090308756203, 0.710611050909655040, 0.699362481103231959, + 0.688061132773747808, 0.676703568029522584, 0.665286141392677943, 0.653804979847664947, + 0.642255960424536365, 0.630634684933490286, 0.618936451394876075, 0.607156221620300030, + 0.595288584291502887, 0.583327712748769489, 0.571267316532588332, 0.559100585511540626, + 0.546820125163310577, 0.534417881237165604, 0.521885051592135052, 0.509211982443654398, + 0.496388045518671162, 0.483401491653461857, 0.470239275082169006, 0.456886840931420235, + 0.443327866073552401, 0.429543940225410703, 0.415514169600356364, 0.401214678896277765, + 0.386617977941119573, 0.371692145329917234, 0.356399760258393816, 0.340696481064849122, + 0.324529117016909452, 0.307832954674932158, 0.290527955491230394, 0.272513185478464703, + 0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842, + 0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570, + 0.000000000000000000]; +pub static ZIG_EXP_F: [f64; 257] = + [0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573, + 0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797, + 0.004877655983542396, 0.005619642207205489, 0.006381905937319183, 0.007163353183634991, + 0.007963077438017043, 0.008780314985808977, 0.009614413642502212, 0.010464810181029981, + 0.011331013597834600, 0.012212592426255378, 0.013109164931254991, 0.014020391403181943, + 0.014945968011691148, 0.015885621839973156, 0.016839106826039941, 0.017806200410911355, + 0.018786700744696024, 0.019780424338009740, 0.020787204072578114, 0.021806887504283581, + 0.022839335406385240, 0.023884420511558174, 0.024942026419731787, 0.026012046645134221, + 0.027094383780955803, 0.028188948763978646, 0.029295660224637411, 0.030414443910466622, + 0.031545232172893622, 0.032687963508959555, 0.033842582150874358, 0.035009037697397431, + 0.036187284781931443, 0.037377282772959382, 0.038578995503074871, 0.039792391023374139, + 0.041017441380414840, 0.042254122413316254, 0.043502413568888197, 0.044762297732943289, + 0.046033761076175184, 0.047316792913181561, 0.048611385573379504, 0.049917534282706379, + 0.051235237055126281, 0.052564494593071685, 0.053905310196046080, 0.055257689676697030, + 0.056621641283742870, 0.057997175631200659, 0.059384305633420280, 0.060783046445479660, + 0.062193415408541036, 0.063615431999807376, 0.065049117786753805, 0.066494496385339816, + 0.067951593421936643, 0.069420436498728783, 0.070901055162371843, 0.072393480875708752, + 0.073897746992364746, 0.075413888734058410, 0.076941943170480517, 0.078481949201606435, + 0.080033947542319905, 0.081597980709237419, 0.083174093009632397, 0.084762330532368146, + 0.086362741140756927, 0.087975374467270231, 0.089600281910032886, 0.091237516631040197, + 0.092887133556043569, 0.094549189376055873, 0.096223742550432825, 0.097910853311492213, + 0.099610583670637132, 0.101322997425953631, 0.103048160171257702, 0.104786139306570145, + 0.106537004050001632, 0.108300825451033755, 0.110077676405185357, 0.111867631670056283, + 0.113670767882744286, 0.115487163578633506, 0.117316899211555525, 0.119160057175327641, + 0.121016721826674792, 0.122886979509545108, 0.124770918580830933, 0.126668629437510671, + 0.128580204545228199, 0.130505738468330773, 0.132445327901387494, 0.134399071702213602, + 0.136367070926428829, 0.138349428863580176, 0.140346251074862399, 0.142357645432472146, + 0.144383722160634720, 0.146424593878344889, 0.148480375643866735, 0.150551185001039839, + 0.152637142027442801, 0.154738369384468027, 0.156854992369365148, 0.158987138969314129, + 0.161134939917591952, 0.163298528751901734, 0.165478041874935922, 0.167673618617250081, + 0.169885401302527550, 0.172113535315319977, 0.174358169171353411, 0.176619454590494829, + 0.178897546572478278, 0.181192603475496261, 0.183504787097767436, 0.185834262762197083, + 0.188181199404254262, 0.190545769663195363, 0.192928149976771296, 0.195328520679563189, + 0.197747066105098818, 0.200183974691911210, 0.202639439093708962, 0.205113656293837654, + 0.207606827724221982, 0.210119159388988230, 0.212650861992978224, 0.215202151075378628, + 0.217773247148700472, 0.220364375843359439, 0.222975768058120111, 0.225607660116683956, + 0.228260293930716618, 0.230933917169627356, 0.233628783437433291, 0.236345152457059560, + 0.239083290262449094, 0.241843469398877131, 0.244625969131892024, 0.247431075665327543, + 0.250259082368862240, 0.253110290015629402, 0.255985007030415324, 0.258883549749016173, + 0.261806242689362922, 0.264753418835062149, 0.267725419932044739, 0.270722596799059967, + 0.273745309652802915, 0.276793928448517301, 0.279868833236972869, 0.282970414538780746, + 0.286099073737076826, 0.289255223489677693, 0.292439288161892630, 0.295651704281261252, + 0.298892921015581847, 0.302163400675693528, 0.305463619244590256, 0.308794066934560185, + 0.312155248774179606, 0.315547685227128949, 0.318971912844957239, 0.322428484956089223, + 0.325917972393556354, 0.329440964264136438, 0.332998068761809096, 0.336589914028677717, + 0.340217149066780189, 0.343880444704502575, 0.347580494621637148, 0.351318016437483449, + 0.355093752866787626, 0.358908472948750001, 0.362762973354817997, 0.366658079781514379, + 0.370594648435146223, 0.374573567615902381, 0.378595759409581067, 0.382662181496010056, + 0.386773829084137932, 0.390931736984797384, 0.395136981833290435, 0.399390684475231350, + 0.403694012530530555, 0.408048183152032673, 0.412454465997161457, 0.416914186433003209, + 0.421428728997616908, 0.425999541143034677, 0.430628137288459167, 0.435316103215636907, + 0.440065100842354173, 0.444876873414548846, 0.449753251162755330, 0.454696157474615836, + 0.459707615642138023, 0.464789756250426511, 0.469944825283960310, 0.475175193037377708, + 0.480483363930454543, 0.485871987341885248, 0.491343869594032867, 0.496901987241549881, + 0.502549501841348056, 0.508289776410643213, 0.514126393814748894, 0.520063177368233931, + 0.526104213983620062, 0.532253880263043655, 0.538516872002862246, 0.544898237672440056, + 0.551403416540641733, 0.558038282262587892, 0.564809192912400615, 0.571723048664826150, + 0.578787358602845359, 0.586010318477268366, 0.593400901691733762, 0.600968966365232560, + 0.608725382079622346, 0.616682180915207878, 0.624852738703666200, 0.633251994214366398, + 0.641896716427266423, 0.650805833414571433, 0.660000841079000145, 0.669506316731925177, + 0.679350572264765806, 0.689566496117078431, 0.700192655082788606, 0.711274760805076456, + 0.722867659593572465, 0.735038092431424039, 0.747868621985195658, 0.761463388849896838, + 0.775956852040116218, 0.791527636972496285, 0.808421651523009044, 0.826993296643051101, + 0.847785500623990496, 0.871704332381204705, 0.900469929925747703, 0.938143680862176477, + 1.000000000000000000]; diff --git a/third_party/cargo/vendor/rand-0.6.5/src/lib.rs b/third_party/cargo/vendor/rand-0.6.5/src/lib.rs new file mode 100644 index 0000000..9c0482f --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/lib.rs @@ -0,0 +1,830 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2017 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Utilities for random number generation +//! +//! Rand provides utilities to generate random numbers, to convert them to +//! useful types and distributions, and some randomness-related algorithms. +//! +//! # Quick Start +//! +//! To get you started quickly, the easiest and highest-level way to get +//! a random value is to use [`random()`]; alternatively you can use +//! [`thread_rng()`]. The [`Rng`] trait provides a useful API on all RNGs, while +//! the [`distributions`] and [`seq`] modules provide further +//! functionality on top of RNGs. +//! +//! ``` +//! use rand::prelude::*; +//! +//! if rand::random() { // generates a boolean +//! // Try printing a random unicode code point (probably a bad idea)! +//! println!("char: {}", rand::random::()); +//! } +//! +//! let mut rng = rand::thread_rng(); +//! let y: f64 = rng.gen(); // generates a float between 0 and 1 +//! +//! let mut nums: Vec = (1..100).collect(); +//! nums.shuffle(&mut rng); +//! ``` +//! +//! # The Book +//! +//! For the user guide and futher documentation, please read +//! [The Rust Rand Book](https://rust-random.github.io/book). + + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] + +#![cfg_attr(not(feature="std"), no_std)] +#![cfg_attr(all(feature="alloc", not(feature="std")), feature(alloc))] +#![cfg_attr(all(feature="simd_support", feature="nightly"), feature(stdsimd))] + +#[cfg(feature = "std")] extern crate core; +#[cfg(all(feature = "alloc", not(feature="std")))] #[macro_use] extern crate alloc; + +#[cfg(feature="simd_support")] extern crate packed_simd; + +extern crate rand_jitter; +#[cfg(feature = "rand_os")] +extern crate rand_os; + +extern crate rand_core; +extern crate rand_isaac; // only for deprecations +extern crate rand_chacha; // only for deprecations +extern crate rand_hc; +extern crate rand_pcg; +extern crate rand_xorshift; + +#[cfg(feature = "log")] #[macro_use] extern crate log; +#[allow(unused)] +#[cfg(not(feature = "log"))] macro_rules! trace { ($($x:tt)*) => () } +#[allow(unused)] +#[cfg(not(feature = "log"))] macro_rules! debug { ($($x:tt)*) => () } +#[allow(unused)] +#[cfg(not(feature = "log"))] macro_rules! info { ($($x:tt)*) => () } +#[allow(unused)] +#[cfg(not(feature = "log"))] macro_rules! warn { ($($x:tt)*) => () } +#[allow(unused)] +#[cfg(not(feature = "log"))] macro_rules! error { ($($x:tt)*) => () } + + +// Re-exports from rand_core +pub use rand_core::{RngCore, CryptoRng, SeedableRng}; +pub use rand_core::{ErrorKind, Error}; + +// Public exports +#[cfg(feature="std")] pub use rngs::thread::thread_rng; + +// Public modules +pub mod distributions; +pub mod prelude; +#[deprecated(since="0.6.0")] +pub mod prng; +pub mod rngs; +pub mod seq; + +//////////////////////////////////////////////////////////////////////////////// +// Compatibility re-exports. Documentation is hidden; will be removed eventually. + +#[doc(hidden)] mod deprecated; + +#[allow(deprecated)] +#[doc(hidden)] pub use deprecated::ReseedingRng; + +#[allow(deprecated)] +#[cfg(feature="std")] #[doc(hidden)] pub use deprecated::EntropyRng; + +#[allow(deprecated)] +#[cfg(feature="rand_os")] +#[doc(hidden)] +pub use deprecated::OsRng; + +#[allow(deprecated)] +#[doc(hidden)] pub use deprecated::{ChaChaRng, IsaacRng, Isaac64Rng, XorShiftRng}; +#[allow(deprecated)] +#[doc(hidden)] pub use deprecated::StdRng; + + +#[allow(deprecated)] +#[doc(hidden)] +pub mod jitter { + pub use deprecated::JitterRng; + pub use rngs::TimerError; +} +#[allow(deprecated)] +#[cfg(feature="rand_os")] +#[doc(hidden)] +pub mod os { + pub use deprecated::OsRng; +} +#[allow(deprecated)] +#[doc(hidden)] +pub mod chacha { + pub use deprecated::ChaChaRng; +} +#[allow(deprecated)] +#[doc(hidden)] +pub mod isaac { + pub use deprecated::{IsaacRng, Isaac64Rng}; +} +#[allow(deprecated)] +#[cfg(feature="std")] +#[doc(hidden)] +pub mod read { + pub use deprecated::ReadRng; +} + +#[allow(deprecated)] +#[cfg(feature="std")] #[doc(hidden)] pub use deprecated::ThreadRng; + +//////////////////////////////////////////////////////////////////////////////// + + +use core::{mem, slice}; +use distributions::{Distribution, Standard}; +use distributions::uniform::{SampleUniform, UniformSampler, SampleBorrow}; + +/// An automatically-implemented extension trait on [`RngCore`] providing high-level +/// generic methods for sampling values and other convenience methods. +/// +/// This is the primary trait to use when generating random values. +/// +/// # Generic usage +/// +/// The basic pattern is `fn foo(rng: &mut R)`. Some +/// things are worth noting here: +/// +/// - Since `Rng: RngCore` and every `RngCore` implements `Rng`, it makes no +/// difference whether we use `R: Rng` or `R: RngCore`. +/// - The `+ ?Sized` un-bounding allows functions to be called directly on +/// type-erased references; i.e. `foo(r)` where `r: &mut RngCore`. Without +/// this it would be necessary to write `foo(&mut r)`. +/// +/// An alternative pattern is possible: `fn foo(rng: R)`. This has some +/// trade-offs. It allows the argument to be consumed directly without a `&mut` +/// (which is how `from_rng(thread_rng())` works); also it still works directly +/// on references (including type-erased references). Unfortunately within the +/// function `foo` it is not known whether `rng` is a reference type or not, +/// hence many uses of `rng` require an extra reference, either explicitly +/// (`distr.sample(&mut rng)`) or implicitly (`rng.gen()`); one may hope the +/// optimiser can remove redundant references later. +/// +/// Example: +/// +/// ``` +/// # use rand::thread_rng; +/// use rand::Rng; +/// +/// fn foo(rng: &mut R) -> f32 { +/// rng.gen() +/// } +/// +/// # let v = foo(&mut thread_rng()); +/// ``` +pub trait Rng: RngCore { + /// Return a random value supporting the [`Standard`] distribution. + /// + /// [`Standard`]: distributions::Standard + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// let x: u32 = rng.gen(); + /// println!("{}", x); + /// println!("{:?}", rng.gen::<(f64, bool)>()); + /// ``` + #[inline] + fn gen(&mut self) -> T where Standard: Distribution { + Standard.sample(self) + } + + /// Generate a random value in the range [`low`, `high`), i.e. inclusive of + /// `low` and exclusive of `high`. + /// + /// This function is optimised for the case that only a single sample is + /// made from the given range. See also the [`Uniform`] distribution + /// type which may be faster if sampling from the same range repeatedly. + /// + /// # Panics + /// + /// Panics if `low >= high`. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// let n: u32 = rng.gen_range(0, 10); + /// println!("{}", n); + /// let m: f64 = rng.gen_range(-40.0f64, 1.3e5f64); + /// println!("{}", m); + /// ``` + /// + /// [`Uniform`]: distributions::uniform::Uniform + fn gen_range(&mut self, low: B1, high: B2) -> T + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized { + T::Sampler::sample_single(low, high, self) + } + + /// Sample a new value, using the given distribution. + /// + /// ### Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// use rand::distributions::Uniform; + /// + /// let mut rng = thread_rng(); + /// let x = rng.sample(Uniform::new(10u32, 15)); + /// // Type annotation requires two types, the type and distribution; the + /// // distribution can be inferred. + /// let y = rng.sample::(Uniform::new(10, 15)); + /// ``` + fn sample>(&mut self, distr: D) -> T { + distr.sample(self) + } + + /// Create an iterator that generates values using the given distribution. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// use rand::distributions::{Alphanumeric, Uniform, Standard}; + /// + /// let mut rng = thread_rng(); + /// + /// // Vec of 16 x f32: + /// let v: Vec = thread_rng().sample_iter(&Standard).take(16).collect(); + /// + /// // String: + /// let s: String = rng.sample_iter(&Alphanumeric).take(7).collect(); + /// + /// // Combined values + /// println!("{:?}", thread_rng().sample_iter(&Standard).take(5) + /// .collect::>()); + /// + /// // Dice-rolling: + /// let die_range = Uniform::new_inclusive(1, 6); + /// let mut roll_die = rng.sample_iter(&die_range); + /// while roll_die.next().unwrap() != 6 { + /// println!("Not a 6; rolling again!"); + /// } + /// ``` + fn sample_iter<'a, T, D: Distribution>(&'a mut self, distr: &'a D) + -> distributions::DistIter<'a, D, Self, T> where Self: Sized + { + distr.sample_iter(self) + } + + /// Fill `dest` entirely with random bytes (uniform value distribution), + /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices + /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.). + /// + /// On big-endian platforms this performs byte-swapping to ensure + /// portability of results from reproducible generators. + /// + /// This uses [`fill_bytes`] internally which may handle some RNG errors + /// implicitly (e.g. waiting if the OS generator is not ready), but panics + /// on other errors. See also [`try_fill`] which returns errors. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut arr = [0i8; 20]; + /// thread_rng().fill(&mut arr[..]); + /// ``` + /// + /// [`fill_bytes`]: RngCore::fill_bytes + /// [`try_fill`]: Rng::try_fill + fn fill(&mut self, dest: &mut T) { + self.fill_bytes(dest.as_byte_slice_mut()); + dest.to_le(); + } + + /// Fill `dest` entirely with random bytes (uniform value distribution), + /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices + /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.). + /// + /// On big-endian platforms this performs byte-swapping to ensure + /// portability of results from reproducible generators. + /// + /// This uses [`try_fill_bytes`] internally and forwards all RNG errors. In + /// some cases errors may be resolvable; see [`ErrorKind`] and + /// documentation for the RNG in use. If you do not plan to handle these + /// errors you may prefer to use [`fill`]. + /// + /// # Example + /// + /// ``` + /// # use rand::Error; + /// use rand::{thread_rng, Rng}; + /// + /// # fn try_inner() -> Result<(), Error> { + /// let mut arr = [0u64; 4]; + /// thread_rng().try_fill(&mut arr[..])?; + /// # Ok(()) + /// # } + /// + /// # try_inner().unwrap() + /// ``` + /// + /// [`try_fill_bytes`]: RngCore::try_fill_bytes + /// [`fill`]: Rng::fill + fn try_fill(&mut self, dest: &mut T) -> Result<(), Error> { + self.try_fill_bytes(dest.as_byte_slice_mut())?; + dest.to_le(); + Ok(()) + } + + /// Return a bool with a probability `p` of being true. + /// + /// See also the [`Bernoulli`] distribution, which may be faster if + /// sampling from the same probability repeatedly. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// println!("{}", rng.gen_bool(1.0 / 3.0)); + /// ``` + /// + /// # Panics + /// + /// If `p < 0` or `p > 1`. + /// + /// [`Bernoulli`]: distributions::bernoulli::Bernoulli + #[inline] + fn gen_bool(&mut self, p: f64) -> bool { + let d = distributions::Bernoulli::new(p); + self.sample(d) + } + + /// Return a bool with a probability of `numerator/denominator` of being + /// true. I.e. `gen_ratio(2, 3)` has chance of 2 in 3, or about 67%, of + /// returning true. If `numerator == denominator`, then the returned value + /// is guaranteed to be `true`. If `numerator == 0`, then the returned + /// value is guaranteed to be `false`. + /// + /// See also the [`Bernoulli`] distribution, which may be faster if + /// sampling from the same `numerator` and `denominator` repeatedly. + /// + /// # Panics + /// + /// If `denominator == 0` or `numerator > denominator`. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// println!("{}", rng.gen_ratio(2, 3)); + /// ``` + /// + /// [`Bernoulli`]: distributions::bernoulli::Bernoulli + #[inline] + fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool { + let d = distributions::Bernoulli::from_ratio(numerator, denominator); + self.sample(d) + } + + /// Return a random element from `values`. + /// + /// Deprecated: use [`seq::SliceRandom::choose`] instead. + #[deprecated(since="0.6.0", note="use SliceRandom::choose instead")] + fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> { + use seq::SliceRandom; + values.choose(self) + } + + /// Return a mutable pointer to a random element from `values`. + /// + /// Deprecated: use [`seq::SliceRandom::choose_mut`] instead. + #[deprecated(since="0.6.0", note="use SliceRandom::choose_mut instead")] + fn choose_mut<'a, T>(&mut self, values: &'a mut [T]) -> Option<&'a mut T> { + use seq::SliceRandom; + values.choose_mut(self) + } + + /// Shuffle a mutable slice in place. + /// + /// Deprecated: use [`seq::SliceRandom::shuffle`] instead. + #[deprecated(since="0.6.0", note="use SliceRandom::shuffle instead")] + fn shuffle(&mut self, values: &mut [T]) { + use seq::SliceRandom; + values.shuffle(self) + } +} + +impl Rng for R {} + +/// Trait for casting types to byte slices +/// +/// This is used by the [`Rng::fill`] and [`Rng::try_fill`] methods. +pub trait AsByteSliceMut { + /// Return a mutable reference to self as a byte slice + fn as_byte_slice_mut(&mut self) -> &mut [u8]; + + /// Call `to_le` on each element (i.e. byte-swap on Big Endian platforms). + fn to_le(&mut self); +} + +impl AsByteSliceMut for [u8] { + fn as_byte_slice_mut(&mut self) -> &mut [u8] { + self + } + + fn to_le(&mut self) {} +} + +macro_rules! impl_as_byte_slice { + ($t:ty) => { + impl AsByteSliceMut for [$t] { + fn as_byte_slice_mut(&mut self) -> &mut [u8] { + if self.len() == 0 { + unsafe { + // must not use null pointer + slice::from_raw_parts_mut(0x1 as *mut u8, 0) + } + } else { + unsafe { + slice::from_raw_parts_mut(&mut self[0] + as *mut $t + as *mut u8, + self.len() * mem::size_of::<$t>() + ) + } + } + } + + fn to_le(&mut self) { + for x in self { + *x = x.to_le(); + } + } + } + } +} + +impl_as_byte_slice!(u16); +impl_as_byte_slice!(u32); +impl_as_byte_slice!(u64); +#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] impl_as_byte_slice!(u128); +impl_as_byte_slice!(usize); +impl_as_byte_slice!(i8); +impl_as_byte_slice!(i16); +impl_as_byte_slice!(i32); +impl_as_byte_slice!(i64); +#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] impl_as_byte_slice!(i128); +impl_as_byte_slice!(isize); + +macro_rules! impl_as_byte_slice_arrays { + ($n:expr,) => {}; + ($n:expr, $N:ident, $($NN:ident,)*) => { + impl_as_byte_slice_arrays!($n - 1, $($NN,)*); + + impl AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut { + fn as_byte_slice_mut(&mut self) -> &mut [u8] { + self[..].as_byte_slice_mut() + } + + fn to_le(&mut self) { + self[..].to_le() + } + } + }; + (!div $n:expr,) => {}; + (!div $n:expr, $N:ident, $($NN:ident,)*) => { + impl_as_byte_slice_arrays!(!div $n / 2, $($NN,)*); + + impl AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut { + fn as_byte_slice_mut(&mut self) -> &mut [u8] { + self[..].as_byte_slice_mut() + } + + fn to_le(&mut self) { + self[..].to_le() + } + } + }; +} +impl_as_byte_slice_arrays!(32, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,); +impl_as_byte_slice_arrays!(!div 4096, N,N,N,N,N,N,N,); + + +/// A convenience extension to [`SeedableRng`] allowing construction from fresh +/// entropy. This trait is automatically implemented for any PRNG implementing +/// [`SeedableRng`] and is not intended to be implemented by users. +/// +/// This is equivalent to using `SeedableRng::from_rng(EntropyRng::new())` then +/// unwrapping the result. +/// +/// Since this is convenient and secure, it is the recommended way to create +/// PRNGs, though two alternatives may be considered: +/// +/// * Deterministic creation using [`SeedableRng::from_seed`] with a fixed seed +/// * Seeding from `thread_rng`: `SeedableRng::from_rng(thread_rng())?`; +/// this will usually be faster and should also be secure, but requires +/// trusting one extra component. +/// +/// ## Example +/// +/// ``` +/// use rand::{Rng, FromEntropy}; +/// use rand::rngs::StdRng; +/// +/// let mut rng = StdRng::from_entropy(); +/// println!("Random die roll: {}", rng.gen_range(1, 7)); +/// ``` +/// +/// [`EntropyRng`]: rngs::EntropyRng +#[cfg(feature="std")] +pub trait FromEntropy: SeedableRng { + /// Creates a new instance, automatically seeded with fresh entropy. + /// + /// Normally this will use `OsRng`, but if that fails `JitterRng` will be + /// used instead. Both should be suitable for cryptography. It is possible + /// that both entropy sources will fail though unlikely; failures would + /// almost certainly be platform limitations or build issues, i.e. most + /// applications targetting PC/mobile platforms should not need to worry + /// about this failing. + /// + /// # Panics + /// + /// If all entropy sources fail this will panic. If you need to handle + /// errors, use the following code, equivalent aside from error handling: + /// + /// ``` + /// # use rand::Error; + /// use rand::prelude::*; + /// use rand::rngs::EntropyRng; + /// + /// # fn try_inner() -> Result<(), Error> { + /// // This uses StdRng, but is valid for any R: SeedableRng + /// let mut rng = StdRng::from_rng(EntropyRng::new())?; + /// + /// println!("random number: {}", rng.gen_range(1, 10)); + /// # Ok(()) + /// # } + /// + /// # try_inner().unwrap() + /// ``` + fn from_entropy() -> Self; +} + +#[cfg(feature="std")] +impl FromEntropy for R { + fn from_entropy() -> R { + R::from_rng(rngs::EntropyRng::new()).unwrap_or_else(|err| + panic!("FromEntropy::from_entropy() failed: {}", err)) + } +} + + +/// Generates a random value using the thread-local random number generator. +/// +/// This is simply a shortcut for `thread_rng().gen()`. See [`thread_rng`] for +/// documentation of the entropy source and [`Standard`] for documentation of +/// distributions and type-specific generation. +/// +/// # Examples +/// +/// ``` +/// let x = rand::random::(); +/// println!("{}", x); +/// +/// let y = rand::random::(); +/// println!("{}", y); +/// +/// if rand::random() { // generates a boolean +/// println!("Better lucky than good!"); +/// } +/// ``` +/// +/// If you're calling `random()` in a loop, caching the generator as in the +/// following example can increase performance. +/// +/// ``` +/// use rand::Rng; +/// +/// let mut v = vec![1, 2, 3]; +/// +/// for x in v.iter_mut() { +/// *x = rand::random() +/// } +/// +/// // can be made faster by caching thread_rng +/// +/// let mut rng = rand::thread_rng(); +/// +/// for x in v.iter_mut() { +/// *x = rng.gen(); +/// } +/// ``` +/// +/// [`Standard`]: distributions::Standard +#[cfg(feature="std")] +#[inline] +pub fn random() -> T where Standard: Distribution { + thread_rng().gen() +} + +#[cfg(test)] +mod test { + use rngs::mock::StepRng; + use rngs::StdRng; + use super::*; + #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::boxed::Box; + + pub struct TestRng { inner: R } + + impl RngCore for TestRng { + fn next_u32(&mut self) -> u32 { + self.inner.next_u32() + } + fn next_u64(&mut self) -> u64 { + self.inner.next_u64() + } + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.inner.fill_bytes(dest) + } + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.inner.try_fill_bytes(dest) + } + } + + pub fn rng(seed: u64) -> TestRng { + TestRng { inner: StdRng::seed_from_u64(seed) } + } + + #[test] + fn test_fill_bytes_default() { + let mut r = StepRng::new(0x11_22_33_44_55_66_77_88, 0); + + // check every remainder mod 8, both in small and big vectors. + let lengths = [0, 1, 2, 3, 4, 5, 6, 7, + 80, 81, 82, 83, 84, 85, 86, 87]; + for &n in lengths.iter() { + let mut buffer = [0u8; 87]; + let v = &mut buffer[0..n]; + r.fill_bytes(v); + + // use this to get nicer error messages. + for (i, &byte) in v.iter().enumerate() { + if byte == 0 { + panic!("byte {} of {} is zero", i, n) + } + } + } + } + + #[test] + fn test_fill() { + let x = 9041086907909331047; // a random u64 + let mut rng = StepRng::new(x, 0); + + // Convert to byte sequence and back to u64; byte-swap twice if BE. + let mut array = [0u64; 2]; + rng.fill(&mut array[..]); + assert_eq!(array, [x, x]); + assert_eq!(rng.next_u64(), x); + + // Convert to bytes then u32 in LE order + let mut array = [0u32; 2]; + rng.fill(&mut array[..]); + assert_eq!(array, [x as u32, (x >> 32) as u32]); + assert_eq!(rng.next_u32(), x as u32); + } + + #[test] + fn test_fill_empty() { + let mut array = [0u32; 0]; + let mut rng = StepRng::new(0, 1); + rng.fill(&mut array); + rng.fill(&mut array[..]); + } + + #[test] + fn test_gen_range() { + let mut r = rng(101); + for _ in 0..1000 { + let a = r.gen_range(-4711, 17); + assert!(a >= -4711 && a < 17); + let a = r.gen_range(-3i8, 42); + assert!(a >= -3i8 && a < 42i8); + let a = r.gen_range(&10u16, 99); + assert!(a >= 10u16 && a < 99u16); + let a = r.gen_range(-100i32, &2000); + assert!(a >= -100i32 && a < 2000i32); + let a = r.gen_range(&12u32, &24u32); + assert!(a >= 12u32 && a < 24u32); + + assert_eq!(r.gen_range(0u32, 1), 0u32); + assert_eq!(r.gen_range(-12i64, -11), -12i64); + assert_eq!(r.gen_range(3_000_000, 3_000_001), 3_000_000); + } + } + + #[test] + #[should_panic] + fn test_gen_range_panic_int() { + let mut r = rng(102); + r.gen_range(5, -2); + } + + #[test] + #[should_panic] + fn test_gen_range_panic_usize() { + let mut r = rng(103); + r.gen_range(5, 2); + } + + #[test] + fn test_gen_bool() { + let mut r = rng(105); + for _ in 0..5 { + assert_eq!(r.gen_bool(0.0), false); + assert_eq!(r.gen_bool(1.0), true); + } + } + + #[test] + fn test_rng_trait_object() { + use distributions::{Distribution, Standard}; + let mut rng = rng(109); + let mut r = &mut rng as &mut RngCore; + r.next_u32(); + r.gen::(); + assert_eq!(r.gen_range(0, 1), 0); + let _c: u8 = Standard.sample(&mut r); + } + + #[test] + #[cfg(feature="alloc")] + fn test_rng_boxed_trait() { + use distributions::{Distribution, Standard}; + let rng = rng(110); + let mut r = Box::new(rng) as Box; + r.next_u32(); + r.gen::(); + assert_eq!(r.gen_range(0, 1), 0); + let _c: u8 = Standard.sample(&mut r); + } + + #[test] + #[cfg(feature="std")] + fn test_random() { + // not sure how to test this aside from just getting some values + let _n : usize = random(); + let _f : f32 = random(); + let _o : Option> = random(); + let _many : ((), + (usize, + isize, + Option<(u32, (bool,))>), + (u8, i8, u16, i16, u32, i32, u64, i64), + (f32, (f64, (f64,)))) = random(); + } + + #[test] + fn test_gen_ratio_average() { + const NUM: u32 = 3; + const DENOM: u32 = 10; + const N: u32 = 100_000; + + let mut sum: u32 = 0; + let mut rng = rng(111); + for _ in 0..N { + if rng.gen_ratio(NUM, DENOM) { + sum += 1; + } + } + // Have Binomial(N, NUM/DENOM) distribution + let expected = (NUM * N) / DENOM; // exact integer + assert!(((sum - expected) as i32).abs() < 500); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/prelude.rs b/third_party/cargo/vendor/rand-0.6.5/src/prelude.rs new file mode 100644 index 0000000..5d8a0e9 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/prelude.rs @@ -0,0 +1,27 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Convenience re-export of common members +//! +//! Like the standard library's prelude, this module simplifies importing of +//! common items. Unlike the standard prelude, the contents of this module must +//! be imported manually: +//! +//! ``` +//! use rand::prelude::*; +//! # let _ = StdRng::from_entropy(); +//! # let mut r = SmallRng::from_rng(thread_rng()).unwrap(); +//! # let _: f32 = r.gen(); +//! ``` + +#[doc(no_inline)] pub use distributions::Distribution; +#[doc(no_inline)] pub use rngs::{SmallRng, StdRng}; +#[doc(no_inline)] #[cfg(feature="std")] pub use rngs::ThreadRng; +#[doc(no_inline)] pub use {Rng, RngCore, CryptoRng, SeedableRng}; +#[doc(no_inline)] #[cfg(feature="std")] pub use {FromEntropy, random, thread_rng}; +#[doc(no_inline)] pub use seq::{SliceRandom, IteratorRandom}; diff --git a/third_party/cargo/vendor/rand-0.6.5/src/prng/mod.rs b/third_party/cargo/vendor/rand-0.6.5/src/prng/mod.rs new file mode 100644 index 0000000..3c0d27b --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/prng/mod.rs @@ -0,0 +1,37 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Pseudo-random number generators. +//! +//! This module is deprecated: +//! +//! - documentation has moved to +//! [The Book](https://rust-random.github.io/book/guide-rngs.html), +//! - PRNGs have moved to other `rand_*` crates. + +// Deprecations (to be removed in 0.7) +#[doc(hidden)] #[allow(deprecated)] +pub use deprecated::XorShiftRng; +#[doc(hidden)] pub mod isaac { + // Note: we miss `IsaacCore` here but probably unimportant. + #[allow(deprecated)] pub use deprecated::IsaacRng; +} +#[doc(hidden)] pub mod isaac64 { + #[allow(deprecated)] pub use deprecated::Isaac64Rng; +} +#[doc(hidden)] #[allow(deprecated)] pub use deprecated::{IsaacRng, Isaac64Rng}; +#[doc(hidden)] pub mod chacha { + // Note: we miss `ChaChaCore` here but probably unimportant. + #[allow(deprecated)] pub use deprecated::ChaChaRng; +} +#[doc(hidden)] #[allow(deprecated)] pub use deprecated::ChaChaRng; +#[doc(hidden)] pub mod hc128 { + // Note: we miss `Hc128Core` here but probably unimportant. + #[allow(deprecated)] pub use deprecated::Hc128Rng; +} +#[doc(hidden)] #[allow(deprecated)] pub use deprecated::Hc128Rng; diff --git a/third_party/cargo/vendor/rand-0.6.5/src/rngs/adapter/mod.rs b/third_party/cargo/vendor/rand-0.6.5/src/rngs/adapter/mod.rs new file mode 100644 index 0000000..60b832e --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/rngs/adapter/mod.rs @@ -0,0 +1,15 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Wrappers / adapters forming RNGs + +#[cfg(feature="std")] #[doc(hidden)] pub mod read; +mod reseeding; + +#[cfg(feature="std")] pub use self::read::ReadRng; +pub use self::reseeding::ReseedingRng; diff --git a/third_party/cargo/vendor/rand-0.6.5/src/rngs/adapter/read.rs b/third_party/cargo/vendor/rand-0.6.5/src/rngs/adapter/read.rs new file mode 100644 index 0000000..9b9c18b --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/rngs/adapter/read.rs @@ -0,0 +1,136 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A wrapper around any Read to treat it as an RNG. + +use std::io::Read; + +use rand_core::{RngCore, Error, ErrorKind, impls}; + + +/// An RNG that reads random bytes straight from any type supporting +/// [`std::io::Read`], for example files. +/// +/// This will work best with an infinite reader, but that is not required. +/// +/// This can be used with `/dev/urandom` on Unix but it is recommended to use +/// [`OsRng`] instead. +/// +/// # Panics +/// +/// `ReadRng` uses [`std::io::Read::read_exact`], which retries on interrupts. +/// All other errors from the underlying reader, including when it does not +/// have enough data, will only be reported through [`try_fill_bytes`]. +/// The other [`RngCore`] methods will panic in case of an error. +/// +/// # Example +/// +/// ``` +/// use rand::Rng; +/// use rand::rngs::adapter::ReadRng; +/// +/// let data = vec![1, 2, 3, 4, 5, 6, 7, 8]; +/// let mut rng = ReadRng::new(&data[..]); +/// println!("{:x}", rng.gen::()); +/// ``` +/// +/// [`OsRng`]: rand_os::OsRng +/// [`try_fill_bytes`]: RngCore::try_fill_bytes +#[derive(Debug)] +pub struct ReadRng { + reader: R +} + +impl ReadRng { + /// Create a new `ReadRng` from a `Read`. + pub fn new(r: R) -> ReadRng { + ReadRng { + reader: r + } + } +} + +impl RngCore for ReadRng { + fn next_u32(&mut self) -> u32 { + impls::next_u32_via_fill(self) + } + + fn next_u64(&mut self) -> u64 { + impls::next_u64_via_fill(self) + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.try_fill_bytes(dest).unwrap_or_else(|err| + panic!("reading random bytes from Read implementation failed; error: {}", err)); + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + if dest.len() == 0 { return Ok(()); } + // Use `std::io::read_exact`, which retries on `ErrorKind::Interrupted`. + self.reader.read_exact(dest).map_err(|err| { + match err.kind() { + ::std::io::ErrorKind::UnexpectedEof => Error::with_cause( + ErrorKind::Unavailable, + "not enough bytes available, reached end of source", err), + _ => Error::with_cause(ErrorKind::Unavailable, + "error reading from Read source", err) + } + }) + } +} + +#[cfg(test)] +mod test { + use super::ReadRng; + use {RngCore, ErrorKind}; + + #[test] + fn test_reader_rng_u64() { + // transmute from the target to avoid endianness concerns. + let v = vec![0u8, 0, 0, 0, 0, 0, 0, 1, + 0 , 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3]; + let mut rng = ReadRng::new(&v[..]); + + assert_eq!(rng.next_u64(), 1_u64.to_be()); + assert_eq!(rng.next_u64(), 2_u64.to_be()); + assert_eq!(rng.next_u64(), 3_u64.to_be()); + } + + #[test] + fn test_reader_rng_u32() { + let v = vec![0u8, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3]; + let mut rng = ReadRng::new(&v[..]); + + assert_eq!(rng.next_u32(), 1_u32.to_be()); + assert_eq!(rng.next_u32(), 2_u32.to_be()); + assert_eq!(rng.next_u32(), 3_u32.to_be()); + } + + #[test] + fn test_reader_rng_fill_bytes() { + let v = [1u8, 2, 3, 4, 5, 6, 7, 8]; + let mut w = [0u8; 8]; + + let mut rng = ReadRng::new(&v[..]); + rng.fill_bytes(&mut w); + + assert!(v == w); + } + + #[test] + fn test_reader_rng_insufficient_bytes() { + let v = [1u8, 2, 3, 4, 5, 6, 7, 8]; + let mut w = [0u8; 9]; + + let mut rng = ReadRng::new(&v[..]); + + assert!(rng.try_fill_bytes(&mut w).err().unwrap().kind == ErrorKind::Unavailable); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/rngs/adapter/reseeding.rs b/third_party/cargo/vendor/rand-0.6.5/src/rngs/adapter/reseeding.rs new file mode 100644 index 0000000..ed2aab4 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/rngs/adapter/reseeding.rs @@ -0,0 +1,370 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A wrapper around another PRNG that reseeds it after it +//! generates a certain number of random bytes. + +use core::mem::size_of; + +use rand_core::{RngCore, CryptoRng, SeedableRng, Error, ErrorKind}; +use rand_core::block::{BlockRngCore, BlockRng}; + +/// A wrapper around any PRNG that implements [`BlockRngCore`], that adds the +/// ability to reseed it. +/// +/// `ReseedingRng` reseeds the underlying PRNG in the following cases: +/// +/// - On a manual call to [`reseed()`]. +/// - After `clone()`, the clone will be reseeded on first use. +/// - After a process is forked, the RNG in the child process is reseeded within +/// the next few generated values, depending on the block size of the +/// underlying PRNG. For [`ChaChaCore`] and [`Hc128Core`] this is a maximum of +/// 15 `u32` values before reseeding. +/// - After the PRNG has generated a configurable number of random bytes. +/// +/// # When should reseeding after a fixed number of generated bytes be used? +/// +/// Reseeding after a fixed number of generated bytes is never strictly +/// *necessary*. Cryptographic PRNGs don't have a limited number of bytes they +/// can output, or at least not a limit reachable in any practical way. There is +/// no such thing as 'running out of entropy'. +/// +/// Occasionally reseeding can be seen as some form of 'security in depth'. Even +/// if in the future a cryptographic weakness is found in the CSPRNG being used, +/// or a flaw in the implementation, occasionally reseeding should make +/// exploiting it much more difficult or even impossible. +/// +/// Use [`ReseedingRng::new`] with a `threshold` of `0` to disable reseeding +/// after a fixed number of generated bytes. +/// +/// # Error handling +/// +/// Although unlikely, reseeding the wrapped PRNG can fail. `ReseedingRng` will +/// never panic but try to handle the error intelligently through some +/// combination of retrying and delaying reseeding until later. +/// If handling the source error fails `ReseedingRng` will continue generating +/// data from the wrapped PRNG without reseeding. +/// +/// Manually calling [`reseed()`] will not have this retry or delay logic, but +/// reports the error. +/// +/// # Example +/// +/// ``` +/// # extern crate rand; +/// # extern crate rand_chacha; +/// # fn main() { +/// use rand::prelude::*; +/// use rand_chacha::ChaChaCore; // Internal part of ChaChaRng that +/// // implements BlockRngCore +/// use rand::rngs::OsRng; +/// use rand::rngs::adapter::ReseedingRng; +/// +/// let prng = ChaChaCore::from_entropy(); +// FIXME: it is better to use EntropyRng as reseeder, but that doesn't implement +// clone yet. +/// let reseeder = OsRng::new().unwrap(); +/// let mut reseeding_rng = ReseedingRng::new(prng, 0, reseeder); +/// +/// println!("{}", reseeding_rng.gen::()); +/// +/// let mut cloned_rng = reseeding_rng.clone(); +/// assert!(reseeding_rng.gen::() != cloned_rng.gen::()); +/// # } +/// ``` +/// +/// [`ChaChaCore`]: rand_chacha::ChaChaCore +/// [`Hc128Core`]: rand_hc::Hc128Core +/// [`BlockRngCore`]: rand_core::block::BlockRngCore +/// [`ReseedingRng::new`]: ReseedingRng::new +/// [`reseed()`]: ReseedingRng::reseed +#[derive(Debug)] +pub struct ReseedingRng(BlockRng>) +where R: BlockRngCore + SeedableRng, + Rsdr: RngCore; + +impl ReseedingRng +where R: BlockRngCore + SeedableRng, + Rsdr: RngCore +{ + /// Create a new `ReseedingRng` from an existing PRNG, combined with a RNG + /// to use as reseeder. + /// + /// `threshold` sets the number of generated bytes after which to reseed the + /// PRNG. Set it to zero to never reseed based on the number of generated + /// values. + pub fn new(rng: R, threshold: u64, reseeder: Rsdr) -> Self { + ReseedingRng(BlockRng::new(ReseedingCore::new(rng, threshold, reseeder))) + } + + /// Reseed the internal PRNG. + pub fn reseed(&mut self) -> Result<(), Error> { + self.0.core.reseed() + } +} + +// TODO: this should be implemented for any type where the inner type +// implements RngCore, but we can't specify that because ReseedingCore is private +impl RngCore for ReseedingRng +where R: BlockRngCore + SeedableRng, + ::Results: AsRef<[u32]> + AsMut<[u32]> +{ + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl Clone for ReseedingRng +where R: BlockRngCore + SeedableRng + Clone, + Rsdr: RngCore + Clone +{ + fn clone(&self) -> ReseedingRng { + // Recreating `BlockRng` seems easier than cloning it and resetting + // the index. + ReseedingRng(BlockRng::new(self.0.core.clone())) + } +} + +impl CryptoRng for ReseedingRng +where R: BlockRngCore + SeedableRng + CryptoRng, + Rsdr: RngCore + CryptoRng {} + +#[derive(Debug)] +struct ReseedingCore { + inner: R, + reseeder: Rsdr, + threshold: i64, + bytes_until_reseed: i64, + fork_counter: usize, +} + +impl BlockRngCore for ReseedingCore +where R: BlockRngCore + SeedableRng, + Rsdr: RngCore +{ + type Item = ::Item; + type Results = ::Results; + + fn generate(&mut self, results: &mut Self::Results) { + let global_fork_counter = fork::get_fork_counter(); + if self.bytes_until_reseed <= 0 || + self.is_forked(global_fork_counter) { + // We get better performance by not calling only `reseed` here + // and continuing with the rest of the function, but by directly + // returning from a non-inlined function. + return self.reseed_and_generate(results, global_fork_counter); + } + let num_bytes = results.as_ref().len() * size_of::(); + self.bytes_until_reseed -= num_bytes as i64; + self.inner.generate(results); + } +} + +impl ReseedingCore +where R: BlockRngCore + SeedableRng, + Rsdr: RngCore +{ + /// Create a new `ReseedingCore`. + fn new(rng: R, threshold: u64, reseeder: Rsdr) -> Self { + use ::core::i64::MAX; + fork::register_fork_handler(); + + // Because generating more values than `i64::MAX` takes centuries on + // current hardware, we just clamp to that value. + // Also we set a threshold of 0, which indicates no limit, to that + // value. + let threshold = + if threshold == 0 { MAX } + else if threshold <= MAX as u64 { threshold as i64 } + else { MAX }; + + ReseedingCore { + inner: rng, + reseeder, + threshold: threshold as i64, + bytes_until_reseed: threshold as i64, + fork_counter: 0, + } + } + + /// Reseed the internal PRNG. + fn reseed(&mut self) -> Result<(), Error> { + R::from_rng(&mut self.reseeder).map(|result| { + self.bytes_until_reseed = self.threshold; + self.inner = result + }) + } + + fn is_forked(&self, global_fork_counter: usize) -> bool { + // In theory, on 32-bit platforms, it is possible for + // `global_fork_counter` to wrap around after ~4e9 forks. + // + // This check will detect a fork in the normal case where + // `fork_counter < global_fork_counter`, and also when the difference + // between both is greater than `isize::MAX` (wrapped around). + // + // It will still fail to detect a fork if there have been more than + // `isize::MAX` forks, without any reseed in between. Seems unlikely + // enough. + (self.fork_counter.wrapping_sub(global_fork_counter) as isize) < 0 + } + + #[inline(never)] + fn reseed_and_generate(&mut self, + results: &mut ::Results, + global_fork_counter: usize) + { + if self.is_forked(global_fork_counter) { + info!("Fork detected, reseeding RNG"); + } else { + trace!("Reseeding RNG (periodic reseed)"); + } + + let num_bytes = + results.as_ref().len() * size_of::<::Item>(); + + let threshold = if let Err(e) = self.reseed() { + let delay = match e.kind { + ErrorKind::Transient => num_bytes as i64, + kind @ _ if kind.should_retry() => self.threshold >> 8, + _ => self.threshold, + }; + warn!("Reseeding RNG delayed reseeding by {} bytes due to \ + error from source: {}", delay, e); + delay + } else { + self.fork_counter = global_fork_counter; + self.threshold + }; + + self.bytes_until_reseed = threshold - num_bytes as i64; + self.inner.generate(results); + } +} + +impl Clone for ReseedingCore +where R: BlockRngCore + SeedableRng + Clone, + Rsdr: RngCore + Clone +{ + fn clone(&self) -> ReseedingCore { + ReseedingCore { + inner: self.inner.clone(), + reseeder: self.reseeder.clone(), + threshold: self.threshold, + bytes_until_reseed: 0, // reseed clone on first use + fork_counter: self.fork_counter, + } + } +} + +impl CryptoRng for ReseedingCore +where R: BlockRngCore + SeedableRng + CryptoRng, + Rsdr: RngCore + CryptoRng {} + + +#[cfg(all(feature="std", unix, not(target_os="emscripten")))] +mod fork { + extern crate libc; + + use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; + use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT}; + + // Fork protection + // + // We implement fork protection on Unix using `pthread_atfork`. + // When the process is forked, we increment `RESEEDING_RNG_FORK_COUNTER`. + // Every `ReseedingRng` stores the last known value of the static in + // `fork_counter`. If the cached `fork_counter` is less than + // `RESEEDING_RNG_FORK_COUNTER`, it is time to reseed this RNG. + // + // If reseeding fails, we don't deal with this by setting a delay, but just + // don't update `fork_counter`, so a reseed is attempted as soon as + // possible. + + static RESEEDING_RNG_FORK_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT; + + pub fn get_fork_counter() -> usize { + RESEEDING_RNG_FORK_COUNTER.load(Ordering::Relaxed) + } + + static FORK_HANDLER_REGISTERED: AtomicBool = ATOMIC_BOOL_INIT; + + extern fn fork_handler() { + // Note: fetch_add is defined to wrap on overflow + // (which is what we want). + RESEEDING_RNG_FORK_COUNTER.fetch_add(1, Ordering::Relaxed); + } + + pub fn register_fork_handler() { + if FORK_HANDLER_REGISTERED.load(Ordering::Relaxed) == false { + unsafe { libc::pthread_atfork(None, None, Some(fork_handler)) }; + FORK_HANDLER_REGISTERED.store(true, Ordering::Relaxed); + } + } +} + +#[cfg(not(all(feature="std", unix, not(target_os="emscripten"))))] +mod fork { + pub fn get_fork_counter() -> usize { 0 } + pub fn register_fork_handler() {} +} + + +#[cfg(test)] +mod test { + use {Rng, SeedableRng}; + use rand_chacha::ChaChaCore; + use rngs::mock::StepRng; + use super::ReseedingRng; + + #[test] + fn test_reseeding() { + let mut zero = StepRng::new(0, 0); + let rng = ChaChaCore::from_rng(&mut zero).unwrap(); + let mut reseeding = ReseedingRng::new(rng, 32*4, zero); + + // Currently we only support for arrays up to length 32. + // TODO: cannot generate seq via Rng::gen because it uses different alg + let mut buf = [0u32; 32]; // Needs to be a multiple of the RNGs result + // size to test exactly. + reseeding.fill(&mut buf); + let seq = buf; + for _ in 0..10 { + reseeding.fill(&mut buf); + assert_eq!(buf, seq); + } + } + + #[test] + fn test_clone_reseeding() { + let mut zero = StepRng::new(0, 0); + let rng = ChaChaCore::from_rng(&mut zero).unwrap(); + let mut rng1 = ReseedingRng::new(rng, 32*4, zero); + + let first: u32 = rng1.gen(); + for _ in 0..10 { let _ = rng1.gen::(); } + + let mut rng2 = rng1.clone(); + assert_eq!(first, rng2.gen::()); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/rngs/entropy.rs b/third_party/cargo/vendor/rand-0.6.5/src/rngs/entropy.rs new file mode 100644 index 0000000..9a2affd --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/rngs/entropy.rs @@ -0,0 +1,248 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Entropy generator, or wrapper around external generators + +use rand_core::{RngCore, CryptoRng, Error, ErrorKind, impls}; +#[allow(unused)] +use rngs; + +/// An interface returning random data from external source(s), provided +/// specifically for securely seeding algorithmic generators (PRNGs). +/// +/// Where possible, `EntropyRng` retrieves random data from the operating +/// system's interface for random numbers ([`OsRng`]); if that fails it will +/// fall back to the [`JitterRng`] entropy collector. In the latter case it will +/// still try to use [`OsRng`] on the next usage. +/// +/// If no secure source of entropy is available `EntropyRng` will panic on use; +/// i.e. it should never output predictable data. +/// +/// This is either a little slow ([`OsRng`] requires a system call) or extremely +/// slow ([`JitterRng`] must use significant CPU time to generate sufficient +/// jitter); for better performance it is common to seed a local PRNG from +/// external entropy then primarily use the local PRNG ([`thread_rng`] is +/// provided as a convenient, local, automatically-seeded CSPRNG). +/// +/// # Panics +/// +/// On most systems, like Windows, Linux, macOS and *BSD on common hardware, it +/// is highly unlikely for both [`OsRng`] and [`JitterRng`] to fail. But on +/// combinations like webassembly without Emscripten or stdweb both sources are +/// unavailable. If both sources fail, only [`try_fill_bytes`] is able to +/// report the error, and only the one from `OsRng`. The other [`RngCore`] +/// methods will panic in case of an error. +/// +/// [`OsRng`]: rand_os::OsRng +/// [`thread_rng`]: crate::thread_rng +/// [`JitterRng`]: crate::rngs::JitterRng +/// [`try_fill_bytes`]: RngCore::try_fill_bytes +#[derive(Debug)] +pub struct EntropyRng { + source: Source, +} + +#[derive(Debug)] +enum Source { + Os(Os), + Custom(Custom), + Jitter(Jitter), + None, +} + +impl EntropyRng { + /// Create a new `EntropyRng`. + /// + /// This method will do no system calls or other initialization routines, + /// those are done on first use. This is done to make `new` infallible, + /// and `try_fill_bytes` the only place to report errors. + pub fn new() -> Self { + EntropyRng { source: Source::None } + } +} + +impl Default for EntropyRng { + fn default() -> Self { + EntropyRng::new() + } +} + +impl RngCore for EntropyRng { + fn next_u32(&mut self) -> u32 { + impls::next_u32_via_fill(self) + } + + fn next_u64(&mut self) -> u64 { + impls::next_u64_via_fill(self) + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.try_fill_bytes(dest).unwrap_or_else(|err| + panic!("all entropy sources failed; first error: {}", err)) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let mut reported_error = None; + + if let Source::Os(ref mut os_rng) = self.source { + match os_rng.fill(dest) { + Ok(()) => return Ok(()), + Err(err) => { + warn!("EntropyRng: OsRng failed \ + [trying other entropy sources]: {}", err); + reported_error = Some(err); + }, + } + } else if Os::is_supported() { + match Os::new_and_fill(dest) { + Ok(os_rng) => { + debug!("EntropyRng: using OsRng"); + self.source = Source::Os(os_rng); + return Ok(()); + }, + Err(err) => { reported_error = reported_error.or(Some(err)) }, + } + } + + if let Source::Custom(ref mut rng) = self.source { + match rng.fill(dest) { + Ok(()) => return Ok(()), + Err(err) => { + warn!("EntropyRng: custom entropy source failed \ + [trying other entropy sources]: {}", err); + reported_error = Some(err); + }, + } + } else if Custom::is_supported() { + match Custom::new_and_fill(dest) { + Ok(custom) => { + debug!("EntropyRng: using custom entropy source"); + self.source = Source::Custom(custom); + return Ok(()); + }, + Err(err) => { reported_error = reported_error.or(Some(err)) }, + } + } + + if let Source::Jitter(ref mut jitter_rng) = self.source { + match jitter_rng.fill(dest) { + Ok(()) => return Ok(()), + Err(err) => { + warn!("EntropyRng: JitterRng failed: {}", err); + reported_error = Some(err); + }, + } + } else if Jitter::is_supported() { + match Jitter::new_and_fill(dest) { + Ok(jitter_rng) => { + debug!("EntropyRng: using JitterRng"); + self.source = Source::Jitter(jitter_rng); + return Ok(()); + }, + Err(err) => { reported_error = reported_error.or(Some(err)) }, + } + } + + if let Some(err) = reported_error { + Err(Error::with_cause(ErrorKind::Unavailable, + "All entropy sources failed", + err)) + } else { + Err(Error::new(ErrorKind::Unavailable, + "No entropy sources available")) + } + } +} + +impl CryptoRng for EntropyRng {} + + + +trait EntropySource { + fn new_and_fill(dest: &mut [u8]) -> Result + where Self: Sized; + + fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error>; + + fn is_supported() -> bool { true } +} + +#[allow(unused)] +#[derive(Clone, Debug)] +struct NoSource; + +#[allow(unused)] +impl EntropySource for NoSource { + fn new_and_fill(dest: &mut [u8]) -> Result { + Err(Error::new(ErrorKind::Unavailable, "Source not supported")) + } + + fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error> { + unreachable!() + } + + fn is_supported() -> bool { false } +} + + +#[cfg(feature="rand_os")] +#[derive(Clone, Debug)] +pub struct Os(rngs::OsRng); + +#[cfg(feature="rand_os")] +impl EntropySource for Os { + fn new_and_fill(dest: &mut [u8]) -> Result { + let mut rng = rngs::OsRng::new()?; + rng.try_fill_bytes(dest)?; + Ok(Os(rng)) + } + + fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +#[cfg(not(feature="std"))] +type Os = NoSource; + + +type Custom = NoSource; + + +#[cfg(not(target_arch = "wasm32"))] +#[derive(Clone, Debug)] +pub struct Jitter(rngs::JitterRng); + +#[cfg(not(target_arch = "wasm32"))] +impl EntropySource for Jitter { + fn new_and_fill(dest: &mut [u8]) -> Result { + let mut rng = rngs::JitterRng::new()?; + rng.try_fill_bytes(dest)?; + Ok(Jitter(rng)) + } + + fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +#[cfg(target_arch = "wasm32")] +type Jitter = NoSource; + + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_entropy() { + let mut rng = EntropyRng::new(); + let n = (rng.next_u32() ^ rng.next_u32()).count_ones(); + assert!(n >= 2); // p(failure) approx 1e-7 + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/rngs/mock.rs b/third_party/cargo/vendor/rand-0.6.5/src/rngs/mock.rs new file mode 100644 index 0000000..3c9a994 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/rngs/mock.rs @@ -0,0 +1,59 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Mock random number generator + +use rand_core::{RngCore, Error, impls}; + +/// A simple implementation of `RngCore` for testing purposes. +/// +/// This generates an arithmetic sequence (i.e. adds a constant each step) +/// over a `u64` number, using wrapping arithmetic. If the increment is 0 +/// the generator yields a constant. +/// +/// ``` +/// use rand::Rng; +/// use rand::rngs::mock::StepRng; +/// +/// let mut my_rng = StepRng::new(2, 1); +/// let sample: [u64; 3] = my_rng.gen(); +/// assert_eq!(sample, [2, 3, 4]); +/// ``` +#[derive(Debug, Clone)] +pub struct StepRng { + v: u64, + a: u64, +} + +impl StepRng { + /// Create a `StepRng`, yielding an arithmetic sequence starting with + /// `initial` and incremented by `increment` each time. + pub fn new(initial: u64, increment: u64) -> Self { + StepRng { v: initial, a: increment } + } +} + +impl RngCore for StepRng { + fn next_u32(&mut self) -> u32 { + self.next_u64() as u32 + } + + fn next_u64(&mut self) -> u64 { + let result = self.v; + self.v = self.v.wrapping_add(self.a); + result + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + impls::fill_bytes_via_next(self, dest); + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/rngs/mod.rs b/third_party/cargo/vendor/rand-0.6.5/src/rngs/mod.rs new file mode 100644 index 0000000..b3f05a0 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/rngs/mod.rs @@ -0,0 +1,167 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Random number generators and adapters for common usage: +//! +//! - [`ThreadRng`], a fast, secure, auto-seeded thread-local generator +//! - [`StdRng`] and [`SmallRng`], algorithms to cover typical usage +//! - [`EntropyRng`], [`OsRng`] and [`JitterRng`] as entropy sources +//! - [`mock::StepRng`] as a simple counter for tests +//! - [`adapter::ReadRng`] to read from a file/stream +//! - [`adapter::ReseedingRng`] to reseed a PRNG on clone / process fork etc. +//! +//! # Background — Random number generators (RNGs) +//! +//! Computers are inherently deterministic, so to get *random* numbers one +//! either has to use a hardware generator or collect bits of *entropy* from +//! various sources (e.g. event timestamps, or jitter). This is a relatively +//! slow and complicated operation. +//! +//! Generally the operating system will collect some entropy, remove bias, and +//! use that to seed its own PRNG; [`OsRng`] provides an interface to this. +//! [`JitterRng`] is an entropy collector included with Rand that measures +//! jitter in the CPU execution time, and jitter in memory access time. +//! [`EntropyRng`] is a wrapper that uses the best entropy source that is +//! available. +//! +//! ## Pseudo-random number generators +//! +//! What is commonly used instead of "true" random number renerators, are +//! *pseudo-random number generators* (PRNGs), deterministic algorithms that +//! produce an infinite stream of pseudo-random numbers from a small random +//! seed. PRNGs are faster, and have better provable properties. The numbers +//! produced can be statistically of very high quality and can be impossible to +//! predict. (They can also have obvious correlations and be trivial to predict; +//! quality varies.) +//! +//! There are two different types of PRNGs: those developed for simulations +//! and statistics, and those developed for use in cryptography; the latter are +//! called Cryptographically Secure PRNGs (CSPRNG or CPRNG). Both types can +//! have good statistical quality but the latter also have to be impossible to +//! predict, even after seeing many previous output values. Rand provides a good +//! default algorithm from each class: +//! +//! - [`SmallRng`] is a PRNG chosen for low memory usage, high performance and +//! good statistical quality. +//! - [`StdRng`] is a CSPRNG chosen for good performance and trust of security +//! (based on reviews, maturity and usage). The current algorithm is HC-128, +//! which is one of the recommendations by ECRYPT's eSTREAM project. +//! +//! The above PRNGs do not cover all use-cases; more algorithms can be found in +//! the [`prng`][crate::prng] module, as well as in several other crates. For example, you +//! may wish a CSPRNG with significantly lower memory usage than [`StdRng`] +//! while being less concerned about performance, in which case [`ChaChaRng`] +//! is a good choice. +//! +//! One complexity is that the internal state of a PRNG must change with every +//! generated number. For APIs this generally means a mutable reference to the +//! state of the PRNG has to be passed around. +//! +//! A solution is [`ThreadRng`]. This is a thread-local implementation of +//! [`StdRng`] with automatic seeding on first use. It is the best choice if you +//! "just" want a convenient, secure, fast random number source. Use via the +//! [`thread_rng`] function, which gets a reference to the current thread's +//! local instance. +//! +//! ## Seeding +//! +//! As mentioned above, PRNGs require a random seed in order to produce random +//! output. This is especially important for CSPRNGs, which are still +//! deterministic algorithms, thus can only be secure if their seed value is +//! also secure. To seed a PRNG, use one of: +//! +//! - [`FromEntropy::from_entropy`]; this is the most convenient way to seed +//! with fresh, secure random data. +//! - [`SeedableRng::from_rng`]; this allows seeding from another PRNG or +//! from an entropy source such as [`EntropyRng`]. +//! - [`SeedableRng::from_seed`]; this is mostly useful if you wish to be able +//! to reproduce the output sequence by using a fixed seed. (Don't use +//! [`StdRng`] or [`SmallRng`] in this case since different algorithms may be +//! used by future versions of Rand; use an algorithm from the +//! [`prng`] module.) +//! +//! ## Conclusion +//! +//! - [`thread_rng`] is what you often want to use. +//! - If you want more control, flexibility, or better performance, use +//! [`StdRng`], [`SmallRng`] or an algorithm from the [`prng`] module. +//! - Use [`FromEntropy::from_entropy`] to seed new PRNGs. +//! - If you need reproducibility, use [`SeedableRng::from_seed`] combined with +//! a named PRNG. +//! +//! More information and notes on cryptographic security can be found +//! in the [`prng`] module. +//! +//! ## Examples +//! +//! Examples of seeding PRNGs: +//! +//! ``` +//! use rand::prelude::*; +//! # use rand::Error; +//! +//! // StdRng seeded securely by the OS or local entropy collector: +//! let mut rng = StdRng::from_entropy(); +//! # let v: u32 = rng.gen(); +//! +//! // SmallRng seeded from thread_rng: +//! # fn try_inner() -> Result<(), Error> { +//! let mut rng = SmallRng::from_rng(thread_rng())?; +//! # let v: u32 = rng.gen(); +//! # Ok(()) +//! # } +//! # try_inner().unwrap(); +//! +//! // SmallRng seeded by a constant, for deterministic results: +//! let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16]; // byte array +//! let mut rng = SmallRng::from_seed(seed); +//! # let v: u32 = rng.gen(); +//! ``` +//! +//! +//! # Implementing custom RNGs +//! +//! If you want to implement custom RNG, see the [`rand_core`] crate. The RNG +//! will have to implement the [`RngCore`] trait, where the [`Rng`] trait is +//! build on top of. +//! +//! If the RNG needs seeding, also implement the [`SeedableRng`] trait. +//! +//! [`CryptoRng`] is a marker trait cryptographically secure PRNGs can +//! implement. +//! +//! [`OsRng`]: rand_os::OsRng +//! [`SmallRng`]: rngs::SmallRng +//! [`StdRng`]: rngs::StdRng +//! [`ThreadRng`]: rngs::ThreadRng +//! [`EntropyRng`]: rngs::EntropyRng +//! [`JitterRng`]: rngs::JitterRng +//! [`mock::StepRng`]: rngs::mock::StepRng +//! [`adapter::ReadRng`]: rngs::adapter::ReadRng +//! [`adapter::ReseedingRng`]: rngs::adapter::ReseedingRng +//! [`ChaChaRng`]: rand_chacha::ChaChaRng + +pub mod adapter; + +#[cfg(feature="std")] mod entropy; +pub mod mock; // Public so we don't export `StepRng` directly, making it a bit + // more clear it is intended for testing. +mod small; +mod std; +#[cfg(feature="std")] pub(crate) mod thread; + + +pub use rand_jitter::{JitterRng, TimerError}; +#[cfg(feature="std")] pub use self::entropy::EntropyRng; + +pub use self::small::SmallRng; +pub use self::std::StdRng; +#[cfg(feature="std")] pub use self::thread::ThreadRng; + +#[cfg(feature="rand_os")] +pub use rand_os::OsRng; diff --git a/third_party/cargo/vendor/rand-0.6.5/src/rngs/small.rs b/third_party/cargo/vendor/rand-0.6.5/src/rngs/small.rs new file mode 100644 index 0000000..9874d24 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/rngs/small.rs @@ -0,0 +1,106 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A small fast RNG + +use {RngCore, SeedableRng, Error}; + +#[cfg(all(all(rustc_1_26, not(target_os = "emscripten")), target_pointer_width = "64"))] +type Rng = ::rand_pcg::Pcg64Mcg; +#[cfg(not(all(all(rustc_1_26, not(target_os = "emscripten")), target_pointer_width = "64")))] +type Rng = ::rand_pcg::Pcg32; + +/// An RNG recommended when small state, cheap initialization and good +/// performance are required. The PRNG algorithm in `SmallRng` is chosen to be +/// efficient on the current platform, **without consideration for cryptography +/// or security**. The size of its state is much smaller than for [`StdRng`]. +/// +/// Reproducibility of output from this generator is however not required, thus +/// future library versions may use a different internal generator with +/// different output. Further, this generator may not be portable and can +/// produce different output depending on the architecture. If you require +/// reproducible output, use a named RNG. +/// Refer to [The Book](https://rust-random.github.io/book/guide-rngs.html). +/// +/// +/// The current algorithm is [`Pcg64Mcg`][rand_pcg::Pcg64Mcg] on 64-bit platforms with Rust version +/// 1.26 and later, or [`Pcg32`][rand_pcg::Pcg32] otherwise. Both are found in +/// the [rand_pcg] crate. +/// +/// # Examples +/// +/// Initializing `SmallRng` with a random seed can be done using [`FromEntropy`]: +/// +/// ``` +/// # use rand::Rng; +/// use rand::FromEntropy; +/// use rand::rngs::SmallRng; +/// +/// // Create small, cheap to initialize and fast RNG with a random seed. +/// // The randomness is supplied by the operating system. +/// let mut small_rng = SmallRng::from_entropy(); +/// # let v: u32 = small_rng.gen(); +/// ``` +/// +/// When initializing a lot of `SmallRng`'s, using [`thread_rng`] can be more +/// efficient: +/// +/// ``` +/// use std::iter; +/// use rand::{SeedableRng, thread_rng}; +/// use rand::rngs::SmallRng; +/// +/// // Create a big, expensive to initialize and slower, but unpredictable RNG. +/// // This is cached and done only once per thread. +/// let mut thread_rng = thread_rng(); +/// // Create small, cheap to initialize and fast RNGs with random seeds. +/// // One can generally assume this won't fail. +/// let rngs: Vec = iter::repeat(()) +/// .map(|()| SmallRng::from_rng(&mut thread_rng).unwrap()) +/// .take(10) +/// .collect(); +/// ``` +/// +/// [`FromEntropy`]: crate::FromEntropy +/// [`StdRng`]: crate::rngs::StdRng +/// [`thread_rng`]: crate::thread_rng +/// [rand_pcg]: https://crates.io/crates/rand_pcg +#[derive(Clone, Debug)] +pub struct SmallRng(Rng); + +impl RngCore for SmallRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for SmallRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + SmallRng(Rng::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + Rng::from_rng(rng).map(SmallRng) + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/rngs/std.rs b/third_party/cargo/vendor/rand-0.6.5/src/rngs/std.rs new file mode 100644 index 0000000..e67a76d --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/rngs/std.rs @@ -0,0 +1,85 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The standard RNG + +use {RngCore, CryptoRng, Error, SeedableRng}; +use rand_hc::Hc128Rng; + +/// The standard RNG. The PRNG algorithm in `StdRng` is chosen to be efficient +/// on the current platform, to be statistically strong and unpredictable +/// (meaning a cryptographically secure PRNG). +/// +/// The current algorithm used on all platforms is [HC-128], found in the +/// [rand_hc] crate. +/// +/// Reproducibility of output from this generator is however not required, thus +/// future library versions may use a different internal generator with +/// different output. Further, this generator may not be portable and can +/// produce different output depending on the architecture. If you require +/// reproducible output, use a named RNG, for example [`ChaChaRng`] from the +/// [rand_chacha] crate. +/// +/// [HC-128]: rand_hc::Hc128Rng +/// [`ChaChaRng`]: rand_chacha::ChaChaRng +/// [rand_hc]: https://crates.io/crates/rand_hc +/// [rand_chacha]: https://crates.io/crates/rand_chacha +#[derive(Clone, Debug)] +pub struct StdRng(Hc128Rng); + +impl RngCore for StdRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest); + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for StdRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + StdRng(Hc128Rng::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + Hc128Rng::from_rng(rng).map(StdRng) + } +} + +impl CryptoRng for StdRng {} + + +#[cfg(test)] +mod test { + use {RngCore, SeedableRng}; + use rngs::StdRng; + + #[test] + fn test_stdrng_construction() { + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng1 = StdRng::from_seed(seed); + assert_eq!(rng1.next_u64(), 15759097995037006553); + + let mut rng2 = StdRng::from_rng(rng1).unwrap(); + assert_eq!(rng2.next_u64(), 6766915756997287454); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/rngs/thread.rs b/third_party/cargo/vendor/rand-0.6.5/src/rngs/thread.rs new file mode 100644 index 0000000..f1aa787 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/rngs/thread.rs @@ -0,0 +1,137 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Thread-local random number generator + +use std::cell::UnsafeCell; + +use {RngCore, CryptoRng, SeedableRng, Error}; +use rngs::adapter::ReseedingRng; +use rngs::EntropyRng; +use rand_hc::Hc128Core; + +// Rationale for using `UnsafeCell` in `ThreadRng`: +// +// Previously we used a `RefCell`, with an overhead of ~15%. There will only +// ever be one mutable reference to the interior of the `UnsafeCell`, because +// we only have such a reference inside `next_u32`, `next_u64`, etc. Within a +// single thread (which is the definition of `ThreadRng`), there will only ever +// be one of these methods active at a time. +// +// A possible scenario where there could be multiple mutable references is if +// `ThreadRng` is used inside `next_u32` and co. But the implementation is +// completely under our control. We just have to ensure none of them use +// `ThreadRng` internally, which is nonsensical anyway. We should also never run +// `ThreadRng` in destructors of its implementation, which is also nonsensical. +// +// The additional `Rc` is not strictly neccesary, and could be removed. For now +// it ensures `ThreadRng` stays `!Send` and `!Sync`, and implements `Clone`. + + +// Number of generated bytes after which to reseed `TreadRng`. +// +// The time it takes to reseed HC-128 is roughly equivalent to generating 7 KiB. +// We pick a treshold here that is large enough to not reduce the average +// performance too much, but also small enough to not make reseeding something +// that basically never happens. +const THREAD_RNG_RESEED_THRESHOLD: u64 = 32*1024*1024; // 32 MiB + +/// The type returned by [`thread_rng`], essentially just a reference to the +/// PRNG in thread-local memory. +/// +/// `ThreadRng` uses [`ReseedingRng`] wrapping the same PRNG as [`StdRng`], +/// which is reseeded after generating 32 MiB of random data. A single instance +/// is cached per thread and the returned `ThreadRng` is a reference to this +/// instance — hence `ThreadRng` is neither `Send` nor `Sync` but is safe to use +/// within a single thread. This RNG is seeded and reseeded via [`EntropyRng`] +/// as required. +/// +/// Note that the reseeding is done as an extra precaution against entropy +/// leaks and is in theory unnecessary — to predict `ThreadRng`'s output, an +/// attacker would have to either determine most of the RNG's seed or internal +/// state, or crack the algorithm used. +/// +/// Like [`StdRng`], `ThreadRng` is a cryptographically secure PRNG. The current +/// algorithm used is [HC-128], which is an array-based PRNG that trades memory +/// usage for better performance. This makes it similar to ISAAC, the algorithm +/// used in `ThreadRng` before rand 0.5. +/// +/// Cloning this handle just produces a new reference to the same thread-local +/// generator. +/// +/// [`ReseedingRng`]: crate::rngs::adapter::ReseedingRng +/// [`StdRng`]: crate::rngs::StdRng +/// [HC-128]: rand_hc::Hc128Rng +#[derive(Clone, Debug)] +pub struct ThreadRng { + // use of raw pointer implies type is neither Send nor Sync + rng: *mut ReseedingRng, +} + +thread_local!( + static THREAD_RNG_KEY: UnsafeCell> = { + let mut entropy_source = EntropyRng::new(); + let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err| + panic!("could not initialize thread_rng: {}", err)); + let rng = ReseedingRng::new(r, + THREAD_RNG_RESEED_THRESHOLD, + entropy_source); + UnsafeCell::new(rng) + } +); + +/// Retrieve the lazily-initialized thread-local random number generator, +/// seeded by the system. Intended to be used in method chaining style, +/// e.g. `thread_rng().gen::()`, or cached locally, e.g. +/// `let mut rng = thread_rng();`. Invoked by the `Default` trait, making +/// `ThreadRng::default()` equivelent. +/// +/// For more information see [`ThreadRng`]. +pub fn thread_rng() -> ThreadRng { + ThreadRng { rng: THREAD_RNG_KEY.with(|t| t.get()) } +} + +impl Default for ThreadRng { + fn default() -> ThreadRng { + ::prelude::thread_rng() + } +} + +impl RngCore for ThreadRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + unsafe { (*self.rng).next_u32() } + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + unsafe { (*self.rng).next_u64() } + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + unsafe { (*self.rng).fill_bytes(dest) } + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + unsafe { (*self.rng).try_fill_bytes(dest) } + } +} + +impl CryptoRng for ThreadRng {} + + +#[cfg(test)] +mod test { + #[test] + fn test_thread_rng() { + use Rng; + let mut r = ::thread_rng(); + r.gen::(); + assert_eq!(r.gen_range(0, 1), 0); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/seq/index.rs b/third_party/cargo/vendor/rand-0.6.5/src/seq/index.rs new file mode 100644 index 0000000..a70c736 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/seq/index.rs @@ -0,0 +1,378 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Index sampling + +#[cfg(feature="alloc")] use core::slice; + +#[cfg(feature="std")] use std::vec; +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::vec::{self, Vec}; +// BTreeMap is not as fast in tests, but better than nothing. +#[cfg(feature="std")] use std::collections::{HashSet}; +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::collections::BTreeSet; + +#[cfg(feature="alloc")] use distributions::{Distribution, Uniform}; +use Rng; + +/// A vector of indices. +/// +/// Multiple internal representations are possible. +#[derive(Clone, Debug)] +pub enum IndexVec { + #[doc(hidden)] U32(Vec), + #[doc(hidden)] USize(Vec), +} + +impl IndexVec { + /// Returns the number of indices + pub fn len(&self) -> usize { + match self { + &IndexVec::U32(ref v) => v.len(), + &IndexVec::USize(ref v) => v.len(), + } + } + + /// Return the value at the given `index`. + /// + /// (Note: we cannot implement [`std::ops::Index`] because of lifetime + /// restrictions.) + pub fn index(&self, index: usize) -> usize { + match self { + &IndexVec::U32(ref v) => v[index] as usize, + &IndexVec::USize(ref v) => v[index], + } + } + + /// Return result as a `Vec`. Conversion may or may not be trivial. + pub fn into_vec(self) -> Vec { + match self { + IndexVec::U32(v) => v.into_iter().map(|i| i as usize).collect(), + IndexVec::USize(v) => v, + } + } + + /// Iterate over the indices as a sequence of `usize` values + pub fn iter<'a>(&'a self) -> IndexVecIter<'a> { + match self { + &IndexVec::U32(ref v) => IndexVecIter::U32(v.iter()), + &IndexVec::USize(ref v) => IndexVecIter::USize(v.iter()), + } + } + + /// Convert into an iterator over the indices as a sequence of `usize` values + pub fn into_iter(self) -> IndexVecIntoIter { + match self { + IndexVec::U32(v) => IndexVecIntoIter::U32(v.into_iter()), + IndexVec::USize(v) => IndexVecIntoIter::USize(v.into_iter()), + } + } +} + +impl PartialEq for IndexVec { + fn eq(&self, other: &IndexVec) -> bool { + use self::IndexVec::*; + match (self, other) { + (&U32(ref v1), &U32(ref v2)) => v1 == v2, + (&USize(ref v1), &USize(ref v2)) => v1 == v2, + (&U32(ref v1), &USize(ref v2)) => (v1.len() == v2.len()) + && (v1.iter().zip(v2.iter()).all(|(x, y)| *x as usize == *y)), + (&USize(ref v1), &U32(ref v2)) => (v1.len() == v2.len()) + && (v1.iter().zip(v2.iter()).all(|(x, y)| *x == *y as usize)), + } + } +} + +impl From> for IndexVec { + fn from(v: Vec) -> Self { + IndexVec::U32(v) + } +} + +impl From> for IndexVec { + fn from(v: Vec) -> Self { + IndexVec::USize(v) + } +} + +/// Return type of `IndexVec::iter`. +#[derive(Debug)] +pub enum IndexVecIter<'a> { + #[doc(hidden)] U32(slice::Iter<'a, u32>), + #[doc(hidden)] USize(slice::Iter<'a, usize>), +} + +impl<'a> Iterator for IndexVecIter<'a> { + type Item = usize; + fn next(&mut self) -> Option { + use self::IndexVecIter::*; + match self { + &mut U32(ref mut iter) => iter.next().map(|i| *i as usize), + &mut USize(ref mut iter) => iter.next().cloned(), + } + } + + fn size_hint(&self) -> (usize, Option) { + match self { + &IndexVecIter::U32(ref v) => v.size_hint(), + &IndexVecIter::USize(ref v) => v.size_hint(), + } + } +} + +impl<'a> ExactSizeIterator for IndexVecIter<'a> {} + +/// Return type of `IndexVec::into_iter`. +#[derive(Clone, Debug)] +pub enum IndexVecIntoIter { + #[doc(hidden)] U32(vec::IntoIter), + #[doc(hidden)] USize(vec::IntoIter), +} + +impl Iterator for IndexVecIntoIter { + type Item = usize; + + fn next(&mut self) -> Option { + use self::IndexVecIntoIter::*; + match self { + &mut U32(ref mut v) => v.next().map(|i| i as usize), + &mut USize(ref mut v) => v.next(), + } + } + + fn size_hint(&self) -> (usize, Option) { + use self::IndexVecIntoIter::*; + match self { + &U32(ref v) => v.size_hint(), + &USize(ref v) => v.size_hint(), + } + } +} + +impl ExactSizeIterator for IndexVecIntoIter {} + + +/// Randomly sample exactly `amount` distinct indices from `0..length`, and +/// return them in random order (fully shuffled). +/// +/// This method is used internally by the slice sampling methods, but it can +/// sometimes be useful to have the indices themselves so this is provided as +/// an alternative. +/// +/// The implementation used is not specified; we automatically select the +/// fastest available algorithm for the `length` and `amount` parameters +/// (based on detailed profiling on an Intel Haswell CPU). Roughly speaking, +/// complexity is `O(amount)`, except that when `amount` is small, performance +/// is closer to `O(amount^2)`, and when `length` is close to `amount` then +/// `O(length)`. +/// +/// Note that performance is significantly better over `u32` indices than over +/// `u64` indices. Because of this we hide the underlying type behind an +/// abstraction, `IndexVec`. +/// +/// If an allocation-free `no_std` function is required, it is suggested +/// to adapt the internal `sample_floyd` implementation. +/// +/// Panics if `amount > length`. +pub fn sample(rng: &mut R, length: usize, amount: usize) -> IndexVec + where R: Rng + ?Sized, +{ + if amount > length { + panic!("`amount` of samples must be less than or equal to `length`"); + } + if length > (::core::u32::MAX as usize) { + // We never want to use inplace here, but could use floyd's alg + // Lazy version: always use the cache alg. + return sample_rejection(rng, length, amount); + } + let amount = amount as u32; + let length = length as u32; + + // Choice of algorithm here depends on both length and amount. See: + // https://github.com/rust-random/rand/pull/479 + // We do some calculations with f32. Accuracy is not very important. + + if amount < 163 { + const C: [[f32; 2]; 2] = [[1.6, 8.0/45.0], [10.0, 70.0/9.0]]; + let j = if length < 500_000 { 0 } else { 1 }; + let amount_fp = amount as f32; + let m4 = C[0][j] * amount_fp; + // Short-cut: when amount < 12, floyd's is always faster + if amount > 11 && (length as f32) < (C[1][j] + m4) * amount_fp { + sample_inplace(rng, length, amount) + } else { + sample_floyd(rng, length, amount) + } + } else { + const C: [f32; 2] = [270.0, 330.0/9.0]; + let j = if length < 500_000 { 0 } else { 1 }; + if (length as f32) < C[j] * (amount as f32) { + sample_inplace(rng, length, amount) + } else { + // note: could have a specific u32 impl, but I'm lazy and + // generics don't have usable conversions + sample_rejection(rng, length as usize, amount as usize) + } + } +} + +/// Randomly sample exactly `amount` indices from `0..length`, using Floyd's +/// combination algorithm. +/// +/// The output values are fully shuffled. (Overhead is under 50%.) +/// +/// This implementation uses `O(amount)` memory and `O(amount^2)` time. +fn sample_floyd(rng: &mut R, length: u32, amount: u32) -> IndexVec + where R: Rng + ?Sized, +{ + // For small amount we use Floyd's fully-shuffled variant. For larger + // amounts this is slow due to Vec::insert performance, so we shuffle + // afterwards. Benchmarks show little overhead from extra logic. + let floyd_shuffle = amount < 50; + + debug_assert!(amount <= length); + let mut indices = Vec::with_capacity(amount as usize); + for j in length - amount .. length { + let t = rng.gen_range(0, j + 1); + if floyd_shuffle { + if let Some(pos) = indices.iter().position(|&x| x == t) { + indices.insert(pos, j); + continue; + } + } else { + if indices.contains(&t) { + indices.push(j); + continue; + } + } + indices.push(t); + } + if !floyd_shuffle { + // Reimplement SliceRandom::shuffle with smaller indices + for i in (1..amount).rev() { + // invariant: elements with index > i have been locked in place. + indices.swap(i as usize, rng.gen_range(0, i + 1) as usize); + } + } + IndexVec::from(indices) +} + +/// Randomly sample exactly `amount` indices from `0..length`, using an inplace +/// partial Fisher-Yates method. +/// Sample an amount of indices using an inplace partial fisher yates method. +/// +/// This allocates the entire `length` of indices and randomizes only the first `amount`. +/// It then truncates to `amount` and returns. +/// +/// This method is not appropriate for large `length` and potentially uses a lot +/// of memory; because of this we only implement for `u32` index (which improves +/// performance in all cases). +/// +/// Set-up is `O(length)` time and memory and shuffling is `O(amount)` time. +fn sample_inplace(rng: &mut R, length: u32, amount: u32) -> IndexVec + where R: Rng + ?Sized, +{ + debug_assert!(amount <= length); + let mut indices: Vec = Vec::with_capacity(length as usize); + indices.extend(0..length); + for i in 0..amount { + let j: u32 = rng.gen_range(i, length); + indices.swap(i as usize, j as usize); + } + indices.truncate(amount as usize); + debug_assert_eq!(indices.len(), amount as usize); + IndexVec::from(indices) +} + +/// Randomly sample exactly `amount` indices from `0..length`, using rejection +/// sampling. +/// +/// Since `amount <<< length` there is a low chance of a random sample in +/// `0..length` being a duplicate. We test for duplicates and resample where +/// necessary. The algorithm is `O(amount)` time and memory. +fn sample_rejection(rng: &mut R, length: usize, amount: usize) -> IndexVec + where R: Rng + ?Sized, +{ + debug_assert!(amount < length); + #[cfg(feature="std")] let mut cache = HashSet::with_capacity(amount); + #[cfg(not(feature="std"))] let mut cache = BTreeSet::new(); + let distr = Uniform::new(0, length); + let mut indices = Vec::with_capacity(amount); + for _ in 0..amount { + let mut pos = distr.sample(rng); + while !cache.insert(pos) { + pos = distr.sample(rng); + } + indices.push(pos); + } + + debug_assert_eq!(indices.len(), amount); + IndexVec::from(indices) +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_sample_boundaries() { + let mut r = ::test::rng(404); + + assert_eq!(sample_inplace(&mut r, 0, 0).len(), 0); + assert_eq!(sample_inplace(&mut r, 1, 0).len(), 0); + assert_eq!(sample_inplace(&mut r, 1, 1).into_vec(), vec![0]); + + assert_eq!(sample_rejection(&mut r, 1, 0).len(), 0); + + assert_eq!(sample_floyd(&mut r, 0, 0).len(), 0); + assert_eq!(sample_floyd(&mut r, 1, 0).len(), 0); + assert_eq!(sample_floyd(&mut r, 1, 1).into_vec(), vec![0]); + + // These algorithms should be fast with big numbers. Test average. + let sum: usize = sample_rejection(&mut r, 1 << 25, 10) + .into_iter().sum(); + assert!(1 << 25 < sum && sum < (1 << 25) * 25); + + let sum: usize = sample_floyd(&mut r, 1 << 25, 10) + .into_iter().sum(); + assert!(1 << 25 < sum && sum < (1 << 25) * 25); + } + + #[test] + fn test_sample_alg() { + let seed_rng = ::test::rng; + + // We can't test which algorithm is used directly, but Floyd's alg + // should produce different results from the others. (Also, `inplace` + // and `cached` currently use different sizes thus produce different results.) + + // A small length and relatively large amount should use inplace + let (length, amount): (usize, usize) = (100, 50); + let v1 = sample(&mut seed_rng(420), length, amount); + let v2 = sample_inplace(&mut seed_rng(420), length as u32, amount as u32); + assert!(v1.iter().all(|e| e < length)); + assert_eq!(v1, v2); + + // Test Floyd's alg does produce different results + let v3 = sample_floyd(&mut seed_rng(420), length as u32, amount as u32); + assert!(v1 != v3); + + // A large length and small amount should use Floyd + let (length, amount): (usize, usize) = (1<<20, 50); + let v1 = sample(&mut seed_rng(421), length, amount); + let v2 = sample_floyd(&mut seed_rng(421), length as u32, amount as u32); + assert!(v1.iter().all(|e| e < length)); + assert_eq!(v1, v2); + + // A large length and larger amount should use cache + let (length, amount): (usize, usize) = (1<<20, 600); + let v1 = sample(&mut seed_rng(422), length, amount); + let v2 = sample_rejection(&mut seed_rng(422), length, amount); + assert!(v1.iter().all(|e| e < length)); + assert_eq!(v1, v2); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/src/seq/mod.rs b/third_party/cargo/vendor/rand-0.6.5/src/seq/mod.rs new file mode 100644 index 0000000..d0f8308 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/src/seq/mod.rs @@ -0,0 +1,829 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Functions for randomly accessing and sampling sequences. +//! +//! TODO: module doc + + +#[cfg(feature="alloc")] pub mod index; + +#[cfg(feature="alloc")] use core::ops::Index; + +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::vec::Vec; + +use Rng; +#[cfg(feature="alloc")] use distributions::WeightedError; +#[cfg(feature="alloc")] use distributions::uniform::{SampleUniform, SampleBorrow}; + +/// Extension trait on slices, providing random mutation and sampling methods. +/// +/// An implementation is provided for slices. This may also be implementable for +/// other types. +pub trait SliceRandom { + /// The element type. + type Item; + + /// Returns a reference to one random element of the slice, or `None` if the + /// slice is empty. + /// + /// Depending on the implementation, complexity is expected to be `O(1)`. + /// + /// # Example + /// + /// ``` + /// use rand::thread_rng; + /// use rand::seq::SliceRandom; + /// + /// let choices = [1, 2, 4, 8, 16, 32]; + /// let mut rng = thread_rng(); + /// println!("{:?}", choices.choose(&mut rng)); + /// assert_eq!(choices[..0].choose(&mut rng), None); + /// ``` + fn choose(&self, rng: &mut R) -> Option<&Self::Item> + where R: Rng + ?Sized; + + /// Returns a mutable reference to one random element of the slice, or + /// `None` if the slice is empty. + /// + /// Depending on the implementation, complexity is expected to be `O(1)`. + fn choose_mut(&mut self, rng: &mut R) -> Option<&mut Self::Item> + where R: Rng + ?Sized; + + /// Produces an iterator that chooses `amount` elements from the slice at + /// random without repeating any, and returns them in random order. + /// + /// In case this API is not sufficiently flexible, use `index::sample` then + /// apply the indices to the slice. + /// + /// Complexity is expected to be the same as `index::sample`. + /// + /// # Example + /// ``` + /// use rand::seq::SliceRandom; + /// + /// let mut rng = &mut rand::thread_rng(); + /// let sample = "Hello, audience!".as_bytes(); + /// + /// // collect the results into a vector: + /// let v: Vec = sample.choose_multiple(&mut rng, 3).cloned().collect(); + /// + /// // store in a buffer: + /// let mut buf = [0u8; 5]; + /// for (b, slot) in sample.choose_multiple(&mut rng, buf.len()).zip(buf.iter_mut()) { + /// *slot = *b; + /// } + /// ``` + #[cfg(feature = "alloc")] + fn choose_multiple(&self, rng: &mut R, amount: usize) -> SliceChooseIter + where R: Rng + ?Sized; + + /// Similar to [`choose`], where the likelihood of each outcome may be + /// specified. The specified function `weight` maps items `x` to a relative + /// likelihood `weight(x)`. The probability of each item being selected is + /// therefore `weight(x) / s`, where `s` is the sum of all `weight(x)`. + /// + /// # Example + /// + /// ``` + /// use rand::prelude::*; + /// + /// let choices = [('a', 2), ('b', 1), ('c', 1)]; + /// let mut rng = thread_rng(); + /// // 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c' + /// println!("{:?}", choices.choose_weighted(&mut rng, |item| item.1).unwrap().0); + /// ``` + /// [`choose`]: SliceRandom::choose + #[cfg(feature = "alloc")] + fn choose_weighted(&self, rng: &mut R, weight: F) -> Result<&Self::Item, WeightedError> + where R: Rng + ?Sized, + F: Fn(&Self::Item) -> B, + B: SampleBorrow, + X: SampleUniform + + for<'a> ::core::ops::AddAssign<&'a X> + + ::core::cmp::PartialOrd + + Clone + + Default; + + /// Similar to [`choose_mut`], where the likelihood of each outcome may be + /// specified. The specified function `weight` maps items `x` to a relative + /// likelihood `weight(x)`. The probability of each item being selected is + /// therefore `weight(x) / s`, where `s` is the sum of all `weight(x)`. + /// + /// See also [`choose_weighted`]. + /// + /// [`choose_mut`]: SliceRandom::choose_mut + /// [`choose_weighted`]: SliceRandom::choose_weighted + #[cfg(feature = "alloc")] + fn choose_weighted_mut(&mut self, rng: &mut R, weight: F) -> Result<&mut Self::Item, WeightedError> + where R: Rng + ?Sized, + F: Fn(&Self::Item) -> B, + B: SampleBorrow, + X: SampleUniform + + for<'a> ::core::ops::AddAssign<&'a X> + + ::core::cmp::PartialOrd + + Clone + + Default; + + /// Shuffle a mutable slice in place. + /// + /// Depending on the implementation, complexity is expected to be `O(1)`. + /// + /// # Example + /// + /// ``` + /// use rand::thread_rng; + /// use rand::seq::SliceRandom; + /// + /// let mut rng = thread_rng(); + /// let mut y = [1, 2, 3, 4, 5]; + /// println!("Unshuffled: {:?}", y); + /// y.shuffle(&mut rng); + /// println!("Shuffled: {:?}", y); + /// ``` + fn shuffle(&mut self, rng: &mut R) where R: Rng + ?Sized; + + /// Shuffle a slice in place, but exit early. + /// + /// Returns two mutable slices from the source slice. The first contains + /// `amount` elements randomly permuted. The second has the remaining + /// elements that are not fully shuffled. + /// + /// This is an efficient method to select `amount` elements at random from + /// the slice, provided the slice may be mutated. + /// + /// If you only need to choose elements randomly and `amount > self.len()/2` + /// then you may improve performance by taking + /// `amount = values.len() - amount` and using only the second slice. + /// + /// If `amount` is greater than the number of elements in the slice, this + /// will perform a full shuffle. + /// + /// Complexity is expected to be `O(m)` where `m = amount`. + fn partial_shuffle(&mut self, rng: &mut R, amount: usize) + -> (&mut [Self::Item], &mut [Self::Item]) where R: Rng + ?Sized; +} + +/// Extension trait on iterators, providing random sampling methods. +pub trait IteratorRandom: Iterator + Sized { + /// Choose one element at random from the iterator. If you have a slice, + /// it's significantly faster to call the [`choose`] or [`choose_mut`] + /// functions using the slice instead. + /// + /// Returns `None` if and only if the iterator is empty. + /// + /// Complexity is `O(n)`, where `n` is the length of the iterator. + /// This likely consumes multiple random numbers, but the exact number + /// is unspecified. + /// + /// [`choose`]: SliceRandom::method.choose + /// [`choose_mut`]: SliceRandom::choose_mut + fn choose(mut self, rng: &mut R) -> Option + where R: Rng + ?Sized + { + let (mut lower, mut upper) = self.size_hint(); + let mut consumed = 0; + let mut result = None; + + if upper == Some(lower) { + return if lower == 0 { None } else { self.nth(rng.gen_range(0, lower)) }; + } + + // Continue until the iterator is exhausted + loop { + if lower > 1 { + let ix = rng.gen_range(0, lower + consumed); + let skip; + if ix < lower { + result = self.nth(ix); + skip = lower - (ix + 1); + } else { + skip = lower; + } + if upper == Some(lower) { + return result; + } + consumed += lower; + if skip > 0 { + self.nth(skip - 1); + } + } else { + let elem = self.next(); + if elem.is_none() { + return result; + } + consumed += 1; + let denom = consumed as f64; // accurate to 2^53 elements + if rng.gen_bool(1.0 / denom) { + result = elem; + } + } + + let hint = self.size_hint(); + lower = hint.0; + upper = hint.1; + } + } + + /// Collects `amount` values at random from the iterator into a supplied + /// buffer. + /// + /// Although the elements are selected randomly, the order of elements in + /// the buffer is neither stable nor fully random. If random ordering is + /// desired, shuffle the result. + /// + /// Returns the number of elements added to the buffer. This equals `amount` + /// unless the iterator contains insufficient elements, in which case this + /// equals the number of elements available. + /// + /// Complexity is `O(n)` where `n` is the length of the iterator. + fn choose_multiple_fill(mut self, rng: &mut R, buf: &mut [Self::Item]) + -> usize where R: Rng + ?Sized + { + let amount = buf.len(); + let mut len = 0; + while len < amount { + if let Some(elem) = self.next() { + buf[len] = elem; + len += 1; + } else { + // Iterator exhausted; stop early + return len; + } + } + + // Continue, since the iterator was not exhausted + for (i, elem) in self.enumerate() { + let k = rng.gen_range(0, i + 1 + amount); + if let Some(slot) = buf.get_mut(k) { + *slot = elem; + } + } + len + } + + /// Collects `amount` values at random from the iterator into a vector. + /// + /// This is equivalent to `choose_multiple_fill` except for the result type. + /// + /// Although the elements are selected randomly, the order of elements in + /// the buffer is neither stable nor fully random. If random ordering is + /// desired, shuffle the result. + /// + /// The length of the returned vector equals `amount` unless the iterator + /// contains insufficient elements, in which case it equals the number of + /// elements available. + /// + /// Complexity is `O(n)` where `n` is the length of the iterator. + #[cfg(feature = "alloc")] + fn choose_multiple(mut self, rng: &mut R, amount: usize) -> Vec + where R: Rng + ?Sized + { + let mut reservoir = Vec::with_capacity(amount); + reservoir.extend(self.by_ref().take(amount)); + + // Continue unless the iterator was exhausted + // + // note: this prevents iterators that "restart" from causing problems. + // If the iterator stops once, then so do we. + if reservoir.len() == amount { + for (i, elem) in self.enumerate() { + let k = rng.gen_range(0, i + 1 + amount); + if let Some(slot) = reservoir.get_mut(k) { + *slot = elem; + } + } + } else { + // Don't hang onto extra memory. There is a corner case where + // `amount` was much less than `self.len()`. + reservoir.shrink_to_fit(); + } + reservoir + } +} + + +impl SliceRandom for [T] { + type Item = T; + + fn choose(&self, rng: &mut R) -> Option<&Self::Item> + where R: Rng + ?Sized + { + if self.is_empty() { + None + } else { + Some(&self[rng.gen_range(0, self.len())]) + } + } + + fn choose_mut(&mut self, rng: &mut R) -> Option<&mut Self::Item> + where R: Rng + ?Sized + { + if self.is_empty() { + None + } else { + let len = self.len(); + Some(&mut self[rng.gen_range(0, len)]) + } + } + + #[cfg(feature = "alloc")] + fn choose_multiple(&self, rng: &mut R, amount: usize) + -> SliceChooseIter + where R: Rng + ?Sized + { + let amount = ::core::cmp::min(amount, self.len()); + SliceChooseIter { + slice: self, + _phantom: Default::default(), + indices: index::sample(rng, self.len(), amount).into_iter(), + } + } + + #[cfg(feature = "alloc")] + fn choose_weighted(&self, rng: &mut R, weight: F) -> Result<&Self::Item, WeightedError> + where R: Rng + ?Sized, + F: Fn(&Self::Item) -> B, + B: SampleBorrow, + X: SampleUniform + + for<'a> ::core::ops::AddAssign<&'a X> + + ::core::cmp::PartialOrd + + Clone + + Default { + use distributions::{Distribution, WeightedIndex}; + let distr = WeightedIndex::new(self.iter().map(weight))?; + Ok(&self[distr.sample(rng)]) + } + + #[cfg(feature = "alloc")] + fn choose_weighted_mut(&mut self, rng: &mut R, weight: F) -> Result<&mut Self::Item, WeightedError> + where R: Rng + ?Sized, + F: Fn(&Self::Item) -> B, + B: SampleBorrow, + X: SampleUniform + + for<'a> ::core::ops::AddAssign<&'a X> + + ::core::cmp::PartialOrd + + Clone + + Default { + use distributions::{Distribution, WeightedIndex}; + let distr = WeightedIndex::new(self.iter().map(weight))?; + Ok(&mut self[distr.sample(rng)]) + } + + fn shuffle(&mut self, rng: &mut R) where R: Rng + ?Sized + { + for i in (1..self.len()).rev() { + // invariant: elements with index > i have been locked in place. + self.swap(i, rng.gen_range(0, i + 1)); + } + } + + fn partial_shuffle(&mut self, rng: &mut R, amount: usize) + -> (&mut [Self::Item], &mut [Self::Item]) where R: Rng + ?Sized + { + // This applies Durstenfeld's algorithm for the + // [Fisher–Yates shuffle](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm) + // for an unbiased permutation, but exits early after choosing `amount` + // elements. + + let len = self.len(); + let end = if amount >= len { 0 } else { len - amount }; + + for i in (end..len).rev() { + // invariant: elements with index > i have been locked in place. + self.swap(i, rng.gen_range(0, i + 1)); + } + let r = self.split_at_mut(end); + (r.1, r.0) + } +} + +impl IteratorRandom for I where I: Iterator + Sized {} + + +/// Iterator over multiple choices, as returned by [`SliceRandom::choose_multiple] +#[cfg(feature = "alloc")] +#[derive(Debug)] +pub struct SliceChooseIter<'a, S: ?Sized + 'a, T: 'a> { + slice: &'a S, + _phantom: ::core::marker::PhantomData, + indices: index::IndexVecIntoIter, +} + +#[cfg(feature = "alloc")] +impl<'a, S: Index + ?Sized + 'a, T: 'a> Iterator for SliceChooseIter<'a, S, T> { + type Item = &'a T; + + fn next(&mut self) -> Option { + // TODO: investigate using SliceIndex::get_unchecked when stable + self.indices.next().map(|i| &self.slice[i as usize]) + } + + fn size_hint(&self) -> (usize, Option) { + (self.indices.len(), Some(self.indices.len())) + } +} + +#[cfg(feature = "alloc")] +impl<'a, S: Index + ?Sized + 'a, T: 'a> ExactSizeIterator + for SliceChooseIter<'a, S, T> +{ + fn len(&self) -> usize { + self.indices.len() + } +} + + +/// Randomly sample `amount` elements from a finite iterator. +/// +/// Deprecated: use [`IteratorRandom::choose_multiple`] instead. +#[cfg(feature = "alloc")] +#[deprecated(since="0.6.0", note="use IteratorRandom::choose_multiple instead")] +pub fn sample_iter(rng: &mut R, iterable: I, amount: usize) -> Result, Vec> + where I: IntoIterator, + R: Rng + ?Sized, +{ + use seq::IteratorRandom; + let iter = iterable.into_iter(); + let result = iter.choose_multiple(rng, amount); + if result.len() == amount { + Ok(result) + } else { + Err(result) + } +} + +/// Randomly sample exactly `amount` values from `slice`. +/// +/// The values are non-repeating and in random order. +/// +/// This implementation uses `O(amount)` time and memory. +/// +/// Panics if `amount > slice.len()` +/// +/// Deprecated: use [`SliceRandom::choose_multiple`] instead. +#[cfg(feature = "alloc")] +#[deprecated(since="0.6.0", note="use SliceRandom::choose_multiple instead")] +pub fn sample_slice(rng: &mut R, slice: &[T], amount: usize) -> Vec + where R: Rng + ?Sized, + T: Clone +{ + let indices = index::sample(rng, slice.len(), amount).into_iter(); + + let mut out = Vec::with_capacity(amount); + out.extend(indices.map(|i| slice[i].clone())); + out +} + +/// Randomly sample exactly `amount` references from `slice`. +/// +/// The references are non-repeating and in random order. +/// +/// This implementation uses `O(amount)` time and memory. +/// +/// Panics if `amount > slice.len()` +/// +/// Deprecated: use [`SliceRandom::choose_multiple`] instead. +#[cfg(feature = "alloc")] +#[deprecated(since="0.6.0", note="use SliceRandom::choose_multiple instead")] +pub fn sample_slice_ref<'a, R, T>(rng: &mut R, slice: &'a [T], amount: usize) -> Vec<&'a T> + where R: Rng + ?Sized +{ + let indices = index::sample(rng, slice.len(), amount).into_iter(); + + let mut out = Vec::with_capacity(amount); + out.extend(indices.map(|i| &slice[i])); + out +} + +#[cfg(test)] +mod test { + use super::*; + #[cfg(feature = "alloc")] use {Rng, SeedableRng}; + #[cfg(feature = "alloc")] use rngs::SmallRng; + #[cfg(all(feature="alloc", not(feature="std")))] + use alloc::vec::Vec; + + #[test] + fn test_slice_choose() { + let mut r = ::test::rng(107); + let chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n']; + let mut chosen = [0i32; 14]; + for _ in 0..1000 { + let picked = *chars.choose(&mut r).unwrap(); + chosen[(picked as usize) - ('a' as usize)] += 1; + } + for count in chosen.iter() { + let err = *count - (1000 / (chars.len() as i32)); + assert!(-20 <= err && err <= 20); + } + + chosen.iter_mut().for_each(|x| *x = 0); + for _ in 0..1000 { + *chosen.choose_mut(&mut r).unwrap() += 1; + } + for count in chosen.iter() { + let err = *count - (1000 / (chosen.len() as i32)); + assert!(-20 <= err && err <= 20); + } + + let mut v: [isize; 0] = []; + assert_eq!(v.choose(&mut r), None); + assert_eq!(v.choose_mut(&mut r), None); + } + + #[derive(Clone)] + struct UnhintedIterator { + iter: I, + } + impl Iterator for UnhintedIterator { + type Item = I::Item; + fn next(&mut self) -> Option { + self.iter.next() + } + } + + #[derive(Clone)] + struct ChunkHintedIterator { + iter: I, + chunk_remaining: usize, + chunk_size: usize, + hint_total_size: bool, + } + impl Iterator for ChunkHintedIterator { + type Item = I::Item; + fn next(&mut self) -> Option { + if self.chunk_remaining == 0 { + self.chunk_remaining = ::core::cmp::min(self.chunk_size, + self.iter.len()); + } + self.chunk_remaining = self.chunk_remaining.saturating_sub(1); + + self.iter.next() + } + fn size_hint(&self) -> (usize, Option) { + (self.chunk_remaining, + if self.hint_total_size { Some(self.iter.len()) } else { None }) + } + } + + #[derive(Clone)] + struct WindowHintedIterator { + iter: I, + window_size: usize, + hint_total_size: bool, + } + impl Iterator for WindowHintedIterator { + type Item = I::Item; + fn next(&mut self) -> Option { + self.iter.next() + } + fn size_hint(&self) -> (usize, Option) { + (::core::cmp::min(self.iter.len(), self.window_size), + if self.hint_total_size { Some(self.iter.len()) } else { None }) + } + } + + #[test] + fn test_iterator_choose() { + let r = &mut ::test::rng(109); + fn test_iter + Clone>(r: &mut R, iter: Iter) { + let mut chosen = [0i32; 9]; + for _ in 0..1000 { + let picked = iter.clone().choose(r).unwrap(); + chosen[picked] += 1; + } + for count in chosen.iter() { + // Samples should follow Binomial(1000, 1/9) + // Octave: binopdf(x, 1000, 1/9) gives the prob of *count == x + // Note: have seen 153, which is unlikely but not impossible. + assert!(72 < *count && *count < 154, "count not close to 1000/9: {}", count); + } + } + + test_iter(r, 0..9); + test_iter(r, [0, 1, 2, 3, 4, 5, 6, 7, 8].iter().cloned()); + #[cfg(feature = "alloc")] + test_iter(r, (0..9).collect::>().into_iter()); + test_iter(r, UnhintedIterator { iter: 0..9 }); + test_iter(r, ChunkHintedIterator { iter: 0..9, chunk_size: 4, chunk_remaining: 4, hint_total_size: false }); + test_iter(r, ChunkHintedIterator { iter: 0..9, chunk_size: 4, chunk_remaining: 4, hint_total_size: true }); + test_iter(r, WindowHintedIterator { iter: 0..9, window_size: 2, hint_total_size: false }); + test_iter(r, WindowHintedIterator { iter: 0..9, window_size: 2, hint_total_size: true }); + + assert_eq!((0..0).choose(r), None); + assert_eq!(UnhintedIterator{ iter: 0..0 }.choose(r), None); + } + + #[test] + fn test_shuffle() { + let mut r = ::test::rng(108); + let empty: &mut [isize] = &mut []; + empty.shuffle(&mut r); + let mut one = [1]; + one.shuffle(&mut r); + let b: &[_] = &[1]; + assert_eq!(one, b); + + let mut two = [1, 2]; + two.shuffle(&mut r); + assert!(two == [1, 2] || two == [2, 1]); + + fn move_last(slice: &mut [usize], pos: usize) { + // use slice[pos..].rotate_left(1); once we can use that + let last_val = slice[pos]; + for i in pos..slice.len() - 1 { + slice[i] = slice[i + 1]; + } + *slice.last_mut().unwrap() = last_val; + } + let mut counts = [0i32; 24]; + for _ in 0..10000 { + let mut arr: [usize; 4] = [0, 1, 2, 3]; + arr.shuffle(&mut r); + let mut permutation = 0usize; + let mut pos_value = counts.len(); + for i in 0..4 { + pos_value /= 4 - i; + let pos = arr.iter().position(|&x| x == i).unwrap(); + assert!(pos < (4 - i)); + permutation += pos * pos_value; + move_last(&mut arr, pos); + assert_eq!(arr[3], i); + } + for i in 0..4 { + assert_eq!(arr[i], i); + } + counts[permutation] += 1; + } + for count in counts.iter() { + let err = *count - 10000i32 / 24; + assert!(-50 <= err && err <= 50); + } + } + + #[test] + fn test_partial_shuffle() { + let mut r = ::test::rng(118); + + let mut empty: [u32; 0] = []; + let res = empty.partial_shuffle(&mut r, 10); + assert_eq!((res.0.len(), res.1.len()), (0, 0)); + + let mut v = [1, 2, 3, 4, 5]; + let res = v.partial_shuffle(&mut r, 2); + assert_eq!((res.0.len(), res.1.len()), (2, 3)); + assert!(res.0[0] != res.0[1]); + // First elements are only modified if selected, so at least one isn't modified: + assert!(res.1[0] == 1 || res.1[1] == 2 || res.1[2] == 3); + } + + #[test] + #[cfg(feature = "alloc")] + fn test_sample_iter() { + let min_val = 1; + let max_val = 100; + + let mut r = ::test::rng(401); + let vals = (min_val..max_val).collect::>(); + let small_sample = vals.iter().choose_multiple(&mut r, 5); + let large_sample = vals.iter().choose_multiple(&mut r, vals.len() + 5); + + assert_eq!(small_sample.len(), 5); + assert_eq!(large_sample.len(), vals.len()); + // no randomization happens when amount >= len + assert_eq!(large_sample, vals.iter().collect::>()); + + assert!(small_sample.iter().all(|e| { + **e >= min_val && **e <= max_val + })); + } + + #[test] + #[cfg(feature = "alloc")] + #[allow(deprecated)] + fn test_sample_slice_boundaries() { + let empty: &[u8] = &[]; + + let mut r = ::test::rng(402); + + // sample 0 items + assert_eq!(&sample_slice(&mut r, empty, 0)[..], [0u8; 0]); + assert_eq!(&sample_slice(&mut r, &[42, 2, 42], 0)[..], [0u8; 0]); + + // sample 1 item + assert_eq!(&sample_slice(&mut r, &[42], 1)[..], [42]); + let v = sample_slice(&mut r, &[1, 42], 1)[0]; + assert!(v == 1 || v == 42); + + // sample "all" the items + let v = sample_slice(&mut r, &[42, 133], 2); + assert!(&v[..] == [42, 133] || v[..] == [133, 42]); + + // Make sure lucky 777's aren't lucky + let slice = &[42, 777]; + let mut num_42 = 0; + let total = 1000; + for _ in 0..total { + let v = sample_slice(&mut r, slice, 1); + assert_eq!(v.len(), 1); + let v = v[0]; + assert!(v == 42 || v == 777); + if v == 42 { + num_42 += 1; + } + } + let ratio_42 = num_42 as f64 / 1000 as f64; + assert!(0.4 <= ratio_42 || ratio_42 <= 0.6, "{}", ratio_42); + } + + #[test] + #[cfg(feature = "alloc")] + #[allow(deprecated)] + fn test_sample_slice() { + let seeded_rng = SmallRng::from_seed; + + let mut r = ::test::rng(403); + + for n in 1..20 { + let length = 5*n - 4; // 1, 6, ... + let amount = r.gen_range(0, length); + let mut seed = [0u8; 16]; + r.fill(&mut seed); + + // assert the basics work + let regular = index::sample(&mut seeded_rng(seed), length, amount); + assert_eq!(regular.len(), amount); + assert!(regular.iter().all(|e| e < length)); + + // also test that sampling the slice works + let vec: Vec = (0..(length as u32)).collect(); + let result = sample_slice(&mut seeded_rng(seed), &vec, amount); + assert_eq!(result, regular.iter().map(|i| i as u32).collect::>()); + + let result = sample_slice_ref(&mut seeded_rng(seed), &vec, amount); + assert!(result.iter().zip(regular.iter()).all(|(i,j)| **i == j as u32)); + } + } + + #[test] + #[cfg(feature = "alloc")] + fn test_weighted() { + let mut r = ::test::rng(406); + const N_REPS: u32 = 3000; + let weights = [1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7]; + let total_weight = weights.iter().sum::() as f32; + + let verify = |result: [i32; 14]| { + for (i, count) in result.iter().enumerate() { + let exp = (weights[i] * N_REPS) as f32 / total_weight; + let mut err = (*count as f32 - exp).abs(); + if err != 0.0 { + err /= exp; + } + assert!(err <= 0.25); + } + }; + + // choose_weighted + fn get_weight(item: &(u32, T)) -> u32 { + item.0 + } + let mut chosen = [0i32; 14]; + let mut items = [(0u32, 0usize); 14]; // (weight, index) + for (i, item) in items.iter_mut().enumerate() { + *item = (weights[i], i); + } + for _ in 0..N_REPS { + let item = items.choose_weighted(&mut r, get_weight).unwrap(); + chosen[item.1] += 1; + } + verify(chosen); + + // choose_weighted_mut + let mut items = [(0u32, 0i32); 14]; // (weight, count) + for (i, item) in items.iter_mut().enumerate() { + *item = (weights[i], 0); + } + for _ in 0..N_REPS { + items.choose_weighted_mut(&mut r, get_weight).unwrap().1 += 1; + } + for (ch, item) in chosen.iter_mut().zip(items.iter()) { + *ch = item.1; + } + verify(chosen); + + // Check error cases + let empty_slice = &mut [10][0..0]; + assert_eq!(empty_slice.choose_weighted(&mut r, |_| 1), Err(WeightedError::NoItem)); + assert_eq!(empty_slice.choose_weighted_mut(&mut r, |_| 1), Err(WeightedError::NoItem)); + assert_eq!(['x'].choose_weighted_mut(&mut r, |_| 0), Err(WeightedError::AllWeightsZero)); + assert_eq!([0, -1].choose_weighted_mut(&mut r, |x| *x), Err(WeightedError::NegativeWeight)); + assert_eq!([-1, 0].choose_weighted_mut(&mut r, |x| *x), Err(WeightedError::NegativeWeight)); + } +} diff --git a/third_party/cargo/vendor/rand-0.6.5/tests/uniformity.rs b/third_party/cargo/vendor/rand-0.6.5/tests/uniformity.rs new file mode 100644 index 0000000..b8f74a6 --- /dev/null +++ b/third_party/cargo/vendor/rand-0.6.5/tests/uniformity.rs @@ -0,0 +1,67 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![cfg(feature = "std")] + +#[macro_use] +extern crate average; +extern crate rand; + +use std as core; +use rand::FromEntropy; +use rand::distributions::Distribution; +use average::Histogram; + +const N_BINS: usize = 100; +const N_SAMPLES: u32 = 1_000_000; +const TOL: f64 = 1e-3; +define_histogram!(hist, 100); +use hist::Histogram as Histogram100; + +#[test] +fn unit_sphere() { + const N_DIM: usize = 3; + let h = Histogram100::with_const_width(-1., 1.); + let mut histograms = [h.clone(), h.clone(), h]; + let dist = rand::distributions::UnitSphereSurface::new(); + let mut rng = rand::rngs::SmallRng::from_entropy(); + for _ in 0..N_SAMPLES { + let v = dist.sample(&mut rng); + for i in 0..N_DIM { + histograms[i].add(v[i]).map_err( + |e| { println!("v: {}", v[i]); e } + ).unwrap(); + } + } + for h in &histograms { + let sum: u64 = h.bins().iter().sum(); + println!("{:?}", h); + for &b in h.bins() { + let p = (b as f64) / (sum as f64); + assert!((p - 1.0 / (N_BINS as f64)).abs() < TOL, "{}", p); + } + } +} + +#[test] +fn unit_circle() { + use ::std::f64::consts::PI; + let mut h = Histogram100::with_const_width(-PI, PI); + let dist = rand::distributions::UnitCircle::new(); + let mut rng = rand::rngs::SmallRng::from_entropy(); + for _ in 0..N_SAMPLES { + let v = dist.sample(&mut rng); + h.add(v[0].atan2(v[1])).unwrap(); + } + let sum: u64 = h.bins().iter().sum(); + println!("{:?}", h); + for &b in h.bins() { + let p = (b as f64) / (sum as f64); + assert!((p - 1.0 / (N_BINS as f64)).abs() < TOL, "{}", p); + } +} diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/.cargo-checksum.json b/third_party/cargo/vendor/rand_chacha-0.1.1/.cargo-checksum.json new file mode 100644 index 0000000..42ac082 --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"66b938cf98ad5c5305ef4cc07886b0f64d9985189f6b32630bf32712a0395e5d","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"020a747006ee14a2faae021077d5f2d1b41c90a79f97a79bd33a6fc2b256206f","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"2c4782326824e620912d671f1903722c60ada94c440817ff5e6f83e784f472bf","build.rs":"003108281c4f4bd7a40a93529012acc9d2555c7a4f4b3bfc3ab81d0ed92b8864","src/chacha.rs":"ea9bc97d0fec99d627fcd5ee57f3e187571efdea752ef4b514d1ae0c00476801","src/lib.rs":"ff1162b8836ccc23763cf7f64fa92c2d91b09d1b9ac80960a1486dca6d8a23ca"},"package":"556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/BUILD b/third_party/cargo/vendor/rand_chacha-0.1.1/BUILD new file mode 100644 index 0000000..1f5eada --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "rand_chacha", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/rand_core-0.3.1:rand_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/CHANGELOG.md b/third_party/cargo/vendor/rand_chacha-0.1.1/CHANGELOG.md new file mode 100644 index 0000000..a1979f6 --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.1] - 2019-01-04 +- Disable `i128` and `u128` if the `target_os` is `emscripten` (#671: work-around Emscripten limitation) +- Update readme and doc links + +## [0.1.0] - 2018-10-17 +- Pulled out of the Rand crate diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/COPYRIGHT b/third_party/cargo/vendor/rand_chacha-0.1.1/COPYRIGHT new file mode 100644 index 0000000..468d907 --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/COPYRIGHT @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/Cargo.toml b/third_party/cargo/vendor/rand_chacha-0.1.1/Cargo.toml new file mode 100644 index 0000000..e6d5523 --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/Cargo.toml @@ -0,0 +1,35 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand_chacha" +version = "0.1.1" +authors = ["The Rand Project Developers", "The Rust Project Developers"] +build = "build.rs" +description = "ChaCha random number generator\n" +homepage = "https://crates.io/crates/rand_chacha" +documentation = "https://rust-random.github.io/rand/rand_chacha" +readme = "README.md" +keywords = ["random", "rng", "chacha"] +categories = ["algorithms", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-random/rand" +[dependencies.rand_core] +version = ">=0.2, <0.4" +default-features = false +[build-dependencies.autocfg] +version = "0.1" +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/LICENSE-APACHE b/third_party/cargo/vendor/rand_chacha-0.1.1/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/LICENSE-MIT b/third_party/cargo/vendor/rand_chacha-0.1.1/LICENSE-MIT new file mode 100644 index 0000000..d93b5ba --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright 2018 Developers of the Rand project +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/README.md b/third_party/cargo/vendor/rand_chacha-0.1.1/README.md new file mode 100644 index 0000000..5a1dbac --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/README.md @@ -0,0 +1,45 @@ +# rand_chacha + +[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Latest version](https://img.shields.io/crates/v/rand_chacha.svg)](https://crates.io/crates/rand_chacha) +[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_chacha) +[![API](https://docs.rs/rand_chacha/badge.svg)](https://docs.rs/rand_chacha) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) + +A cryptographically secure random number generator that uses the ChaCha +algorithm. + +ChaCha is a stream cipher designed by Daniel J. Bernstein[^1], that we use +as an RNG. It is an improved variant of the Salsa20 cipher family, which was +selected as one of the "stream ciphers suitable for widespread adoption" by +eSTREAM[^2]. + +Links: + +- [API documentation (master)](https://rust-random.github.io/rand/rand_chacha) +- [API documentation (docs.rs)](https://docs.rs/rand_chacha) +- [Changelog](CHANGELOG.md) + +[rand]: https://crates.io/crates/rand +[^1]: D. J. Bernstein, [*ChaCha, a variant of Salsa20*]( + https://cr.yp.to/chacha.html) + +[^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( + http://www.ecrypt.eu.org/stream/) + + +## Crate Features + +`rand_chacha` is `no_std` compatible. It does not require any functionality +outside of the `core` lib, thus there are no features to configure. + + +# License + +`rand_chacha` is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/build.rs b/third_party/cargo/vendor/rand_chacha-0.1.1/build.rs new file mode 100644 index 0000000..06e12a4 --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/build.rs @@ -0,0 +1,7 @@ +extern crate autocfg; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + let ac = autocfg::new(); + ac.emit_rustc_version(1, 26); +} diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/src/chacha.rs b/third_party/cargo/vendor/rand_chacha-0.1.1/src/chacha.rs new file mode 100644 index 0000000..86f191e --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/src/chacha.rs @@ -0,0 +1,449 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2014 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The ChaCha random number generator. + +use core::fmt; +use rand_core::{CryptoRng, RngCore, SeedableRng, Error, le}; +use rand_core::block::{BlockRngCore, BlockRng}; + +const SEED_WORDS: usize = 8; // 8 words for the 256-bit key +const STATE_WORDS: usize = 16; + +/// A cryptographically secure random number generator that uses the ChaCha +/// algorithm. +/// +/// ChaCha is a stream cipher designed by Daniel J. Bernstein[^1], that we use +/// as an RNG. It is an improved variant of the Salsa20 cipher family, which was +/// selected as one of the "stream ciphers suitable for widespread adoption" by +/// eSTREAM[^2]. +/// +/// ChaCha uses add-rotate-xor (ARX) operations as its basis. These are safe +/// against timing attacks, although that is mostly a concern for ciphers and +/// not for RNGs. Also it is very suitable for SIMD implementation. +/// Here we do not provide a SIMD implementation yet, except for what is +/// provided by auto-vectorisation. +/// +/// With the ChaCha algorithm it is possible to choose the number of rounds the +/// core algorithm should run. The number of rounds is a tradeoff between +/// performance and security, where 8 rounds is the minimum potentially +/// secure configuration, and 20 rounds is widely used as a conservative choice. +/// We use 20 rounds in this implementation, but hope to allow type-level +/// configuration in the future. +/// +/// We use a 64-bit counter and 64-bit stream identifier as in Bernstein's +/// implementation[^1] except that we use a stream identifier in place of a +/// nonce. A 64-bit counter over 64-byte (16 word) blocks allows 1 ZiB of output +/// before cycling, and the stream identifier allows 264 unique +/// streams of output per seed. Both counter and stream are initialized to zero +/// but may be set via [`set_word_pos`] and [`set_stream`]. +/// +/// The word layout is: +/// +/// ```text +/// constant constant constant constant +/// seed seed seed seed +/// seed seed seed seed +/// counter counter stream_id stream_id +/// ``` +/// +/// This implementation uses an output buffer of sixteen `u32` words, and uses +/// [`BlockRng`] to implement the [`RngCore`] methods. +/// +/// [^1]: D. J. Bernstein, [*ChaCha, a variant of Salsa20*]( +/// https://cr.yp.to/chacha.html) +/// +/// [^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( +/// http://www.ecrypt.eu.org/stream/) +/// +/// [`set_word_pos`]: #method.set_word_pos +/// [`set_stream`]: #method.set_stream +/// [`BlockRng`]: ../rand_core/block/struct.BlockRng.html +/// [`RngCore`]: ../rand_core/trait.RngCore.html +#[derive(Clone, Debug)] +pub struct ChaChaRng(BlockRng); + +impl RngCore for ChaChaRng { + #[inline] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + #[inline] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for ChaChaRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + ChaChaRng(BlockRng::::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + BlockRng::::from_rng(rng).map(ChaChaRng) + } +} + +impl CryptoRng for ChaChaRng {} + +impl ChaChaRng { + /// Get the offset from the start of the stream, in 32-bit words. + /// + /// Since the generated blocks are 16 words (24) long and the + /// counter is 64-bits, the offset is a 68-bit number. Sub-word offsets are + /// not supported, hence the result can simply be multiplied by 4 to get a + /// byte-offset. + /// + /// Note: this function is currently only available with Rust 1.26 or later. + #[cfg(all(rustc_1_26, not(target_os = "emscripten")))] + pub fn get_word_pos(&self) -> u128 { + let mut c = (self.0.core.state[13] as u64) << 32 + | (self.0.core.state[12] as u64); + let mut index = self.0.index(); + // c is the end of the last block generated, unless index is at end + if index >= STATE_WORDS { + index = 0; + } else { + c = c.wrapping_sub(1); + } + ((c as u128) << 4) | (index as u128) + } + + /// Set the offset from the start of the stream, in 32-bit words. + /// + /// As with `get_word_pos`, we use a 68-bit number. Since the generator + /// simply cycles at the end of its period (1 ZiB), we ignore the upper + /// 60 bits. + /// + /// Note: this function is currently only available with Rust 1.26 or later. + #[cfg(all(rustc_1_26, not(target_os = "emscripten")))] + pub fn set_word_pos(&mut self, word_offset: u128) { + let index = (word_offset as usize) & 0xF; + let counter = (word_offset >> 4) as u64; + self.0.core.state[12] = counter as u32; + self.0.core.state[13] = (counter >> 32) as u32; + if index != 0 { + self.0.generate_and_set(index); // also increments counter + } else { + self.0.reset(); + } + } + + /// Set the stream number. + /// + /// This is initialized to zero; 264 unique streams of output + /// are available per seed/key. + /// + /// Note that in order to reproduce ChaCha output with a specific 64-bit + /// nonce, one can convert that nonce to a `u64` in little-endian fashion + /// and pass to this function. In theory a 96-bit nonce can be used by + /// passing the last 64-bits to this function and using the first 32-bits as + /// the most significant half of the 64-bit counter (which may be set + /// indirectly via `set_word_pos`), but this is not directly supported. + pub fn set_stream(&mut self, stream: u64) { + let index = self.0.index(); + self.0.core.state[14] = stream as u32; + self.0.core.state[15] = (stream >> 32) as u32; + if index < STATE_WORDS { + // we need to regenerate a partial result buffer + { + // reverse of counter adjustment in generate() + if self.0.core.state[12] == 0 { + self.0.core.state[13] = self.0.core.state[13].wrapping_sub(1); + } + self.0.core.state[12] = self.0.core.state[12].wrapping_sub(1); + } + self.0.generate_and_set(index); + } + } +} + +/// The core of `ChaChaRng`, used with `BlockRng`. +#[derive(Clone)] +pub struct ChaChaCore { + state: [u32; STATE_WORDS], +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for ChaChaCore { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ChaChaCore {{}}") + } +} + +macro_rules! quarter_round{ + ($a: expr, $b: expr, $c: expr, $d: expr) => {{ + $a = $a.wrapping_add($b); $d ^= $a; $d = $d.rotate_left(16); + $c = $c.wrapping_add($d); $b ^= $c; $b = $b.rotate_left(12); + $a = $a.wrapping_add($b); $d ^= $a; $d = $d.rotate_left( 8); + $c = $c.wrapping_add($d); $b ^= $c; $b = $b.rotate_left( 7); + }} +} + +macro_rules! double_round{ + ($x: expr) => {{ + // Column round + quarter_round!($x[ 0], $x[ 4], $x[ 8], $x[12]); + quarter_round!($x[ 1], $x[ 5], $x[ 9], $x[13]); + quarter_round!($x[ 2], $x[ 6], $x[10], $x[14]); + quarter_round!($x[ 3], $x[ 7], $x[11], $x[15]); + // Diagonal round + quarter_round!($x[ 0], $x[ 5], $x[10], $x[15]); + quarter_round!($x[ 1], $x[ 6], $x[11], $x[12]); + quarter_round!($x[ 2], $x[ 7], $x[ 8], $x[13]); + quarter_round!($x[ 3], $x[ 4], $x[ 9], $x[14]); + }} +} + +impl BlockRngCore for ChaChaCore { + type Item = u32; + type Results = [u32; STATE_WORDS]; + + fn generate(&mut self, results: &mut Self::Results) { + // For some reason extracting this part into a separate function + // improves performance by 50%. + fn core(results: &mut [u32; STATE_WORDS], + state: &[u32; STATE_WORDS]) + { + let mut tmp = *state; + let rounds = 20; + for _ in 0..rounds / 2 { + double_round!(tmp); + } + for i in 0..STATE_WORDS { + results[i] = tmp[i].wrapping_add(state[i]); + } + } + + core(results, &self.state); + + // update 64-bit counter + self.state[12] = self.state[12].wrapping_add(1); + if self.state[12] != 0 { return; }; + self.state[13] = self.state[13].wrapping_add(1); + } +} + +impl SeedableRng for ChaChaCore { + type Seed = [u8; SEED_WORDS*4]; + + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_le = [0u32; SEED_WORDS]; + le::read_u32_into(&seed, &mut seed_le); + Self { + state: [0x61707865, 0x3320646E, 0x79622D32, 0x6B206574, // constants + seed_le[0], seed_le[1], seed_le[2], seed_le[3], // seed + seed_le[4], seed_le[5], seed_le[6], seed_le[7], // seed + 0, 0, 0, 0], // counter + } + } +} + +impl CryptoRng for ChaChaCore {} + +impl From for ChaChaRng { + fn from(core: ChaChaCore) -> Self { + ChaChaRng(BlockRng::new(core)) + } +} + +#[cfg(test)] +mod test { + use ::rand_core::{RngCore, SeedableRng}; + use super::ChaChaRng; + + #[test] + fn test_chacha_construction() { + let seed = [0,0,0,0,0,0,0,0, + 1,0,0,0,0,0,0,0, + 2,0,0,0,0,0,0,0, + 3,0,0,0,0,0,0,0]; + let mut rng1 = ChaChaRng::from_seed(seed); + assert_eq!(rng1.next_u32(), 137206642); + + let mut rng2 = ChaChaRng::from_rng(rng1).unwrap(); + assert_eq!(rng2.next_u32(), 1325750369); + } + + #[test] + fn test_chacha_true_values_a() { + // Test vectors 1 and 2 from + // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 + let seed = [0u8; 32]; + let mut rng = ChaChaRng::from_seed(seed); + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653, + 0xb819d2bd, 0x1aed8da0, 0xccef36a8, 0xc70d778b, + 0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8, + 0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2]; + assert_eq!(results, expected); + + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0xbee7079f, 0x7a385155, 0x7c97ba98, 0x0d082d73, + 0xa0290fcb, 0x6965e348, 0x3e53c612, 0xed7aee32, + 0x7621b729, 0x434ee69c, 0xb03371d5, 0xd539d874, + 0x281fed31, 0x45fb0a51, 0x1f0ae1ac, 0x6f4d794b]; + assert_eq!(results, expected); + } + + #[test] + fn test_chacha_true_values_b() { + // Test vector 3 from + // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 + let seed = [0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1]; + let mut rng = ChaChaRng::from_seed(seed); + + // Skip block 0 + for _ in 0..16 { rng.next_u32(); } + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0x2452eb3a, 0x9249f8ec, 0x8d829d9b, 0xddd4ceb1, + 0xe8252083, 0x60818b01, 0xf38422b8, 0x5aaa49c9, + 0xbb00ca8e, 0xda3ba7b4, 0xc4b592d1, 0xfdf2732f, + 0x4436274e, 0x2561b3c8, 0xebdd4aa6, 0xa0136c00]; + assert_eq!(results, expected); + } + + #[test] + #[cfg(all(rustc_1_26, not(target_os = "emscripten")))] + fn test_chacha_true_values_c() { + // Test vector 4 from + // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 + let seed = [0, 0xff, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0]; + let expected = [0xfb4dd572, 0x4bc42ef1, 0xdf922636, 0x327f1394, + 0xa78dea8f, 0x5e269039, 0xa1bebbc1, 0xcaf09aae, + 0xa25ab213, 0x48a6b46c, 0x1b9d9bcb, 0x092c5be6, + 0x546ca624, 0x1bec45d5, 0x87f47473, 0x96f0992e]; + let expected_end = 3 * 16; + let mut results = [0u32; 16]; + + // Test block 2 by skipping block 0 and 1 + let mut rng1 = ChaChaRng::from_seed(seed); + for _ in 0..32 { rng1.next_u32(); } + for i in results.iter_mut() { *i = rng1.next_u32(); } + assert_eq!(results, expected); + assert_eq!(rng1.get_word_pos(), expected_end); + + // Test block 2 by using `set_word_pos` + let mut rng2 = ChaChaRng::from_seed(seed); + rng2.set_word_pos(2 * 16); + for i in results.iter_mut() { *i = rng2.next_u32(); } + assert_eq!(results, expected); + assert_eq!(rng2.get_word_pos(), expected_end); + + // Test skipping behaviour with other types + let mut buf = [0u8; 32]; + rng2.fill_bytes(&mut buf[..]); + assert_eq!(rng2.get_word_pos(), expected_end + 8); + rng2.fill_bytes(&mut buf[0..25]); + assert_eq!(rng2.get_word_pos(), expected_end + 15); + rng2.next_u64(); + assert_eq!(rng2.get_word_pos(), expected_end + 17); + rng2.next_u32(); + rng2.next_u64(); + assert_eq!(rng2.get_word_pos(), expected_end + 20); + rng2.fill_bytes(&mut buf[0..1]); + assert_eq!(rng2.get_word_pos(), expected_end + 21); + } + + #[test] + fn test_chacha_multiple_blocks() { + let seed = [0,0,0,0, 1,0,0,0, 2,0,0,0, 3,0,0,0, 4,0,0,0, 5,0,0,0, 6,0,0,0, 7,0,0,0]; + let mut rng = ChaChaRng::from_seed(seed); + + // Store the 17*i-th 32-bit word, + // i.e., the i-th word of the i-th 16-word block + let mut results = [0u32; 16]; + for i in results.iter_mut() { + *i = rng.next_u32(); + for _ in 0..16 { + rng.next_u32(); + } + } + let expected = [0xf225c81a, 0x6ab1be57, 0x04d42951, 0x70858036, + 0x49884684, 0x64efec72, 0x4be2d186, 0x3615b384, + 0x11cfa18e, 0xd3c50049, 0x75c775f6, 0x434c6530, + 0x2c5bad8f, 0x898881dc, 0x5f1c86d9, 0xc1f8e7f4]; + assert_eq!(results, expected); + } + + #[test] + fn test_chacha_true_bytes() { + let seed = [0u8; 32]; + let mut rng = ChaChaRng::from_seed(seed); + let mut results = [0u8; 32]; + rng.fill_bytes(&mut results); + let expected = [118, 184, 224, 173, 160, 241, 61, 144, + 64, 93, 106, 229, 83, 134, 189, 40, + 189, 210, 25, 184, 160, 141, 237, 26, + 168, 54, 239, 204, 139, 119, 13, 199]; + assert_eq!(results, expected); + } + + #[test] + fn test_chacha_nonce() { + // Test vector 5 from + // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 + // Although we do not support setting a nonce, we try it here anyway so + // we can use this test vector. + let seed = [0u8; 32]; + let mut rng = ChaChaRng::from_seed(seed); + // 96-bit nonce in LE order is: 0,0,0,0, 0,0,0,0, 0,0,0,2 + rng.set_stream(2u64 << (24 + 32)); + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0x374dc6c2, 0x3736d58c, 0xb904e24a, 0xcd3f93ef, + 0x88228b1a, 0x96a4dfb3, 0x5b76ab72, 0xc727ee54, + 0x0e0e978a, 0xf3145c95, 0x1b748ea8, 0xf786c297, + 0x99c28f5f, 0x628314e8, 0x398a19fa, 0x6ded1b53]; + assert_eq!(results, expected); + } + + #[test] + fn test_chacha_clone_streams() { + let seed = [0,0,0,0, 1,0,0,0, 2,0,0,0, 3,0,0,0, 4,0,0,0, 5,0,0,0, 6,0,0,0, 7,0,0,0]; + let mut rng = ChaChaRng::from_seed(seed); + let mut clone = rng.clone(); + for _ in 0..16 { + assert_eq!(rng.next_u64(), clone.next_u64()); + } + + rng.set_stream(51); + for _ in 0..7 { + assert!(rng.next_u32() != clone.next_u32()); + } + clone.set_stream(51); // switch part way through block + for _ in 7..16 { + assert_eq!(rng.next_u32(), clone.next_u32()); + } + } +} diff --git a/third_party/cargo/vendor/rand_chacha-0.1.1/src/lib.rs b/third_party/cargo/vendor/rand_chacha-0.1.1/src/lib.rs new file mode 100644 index 0000000..8cff03a --- /dev/null +++ b/third_party/cargo/vendor/rand_chacha-0.1.1/src/lib.rs @@ -0,0 +1,25 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The ChaCha random number generator. + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] + +#![no_std] + +extern crate rand_core; + +mod chacha; + +pub use chacha::{ChaChaRng, ChaChaCore}; diff --git a/third_party/cargo/vendor/rand_core-0.3.1/.cargo-checksum.json b/third_party/cargo/vendor/rand_core-0.3.1/.cargo-checksum.json new file mode 100644 index 0000000..1fd20d4 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"35b32c8dc19610e66f7c6967e93f5a0f49e5a021c633da72e7219571cfb7b457","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"38f22c1be27541f74b322a721c95aaacd622cddfa02cfa22f7976d613453dc78","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"2781af9ae12e434bb3f43c5a3b16b330eea7a8c80065e28e967333a82be7a507","src/block.rs":"43778ab70f0b650c3203a6da70b40bc33afa845a5e14ef88dd26c18a07b70f88","src/error.rs":"8403a968d7c9bd95cc9f23d9dc5cc4771ede8e81dda5a8fdd59d347590345d14","src/impls.rs":"c248ddd04a65c974768baaec028fa0d2a6117525fa27bce8a98f2ba2f352700a","src/le.rs":"cb187f58f7514877918f7f47633397e08e20392dcf072bc245d62c9e5238198c","src/lib.rs":"4452ea591ce26f69e6a3dd1341795faeec5c14af35eb4a17aaf2b5d342753cf0"},"package":"7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand_core-0.3.1/BUILD b/third_party/cargo/vendor/rand_core-0.3.1/BUILD new file mode 100644 index 0000000..9f4346a --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/BUILD @@ -0,0 +1,46 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "rand_core", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/rand_core-0.4.2:rand_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.3.1", + crate_features = [ + "alloc", + "rand_core", + "std", + ], +) + diff --git a/third_party/cargo/vendor/rand_core-0.3.1/CHANGELOG.md b/third_party/cargo/vendor/rand_core-0.3.1/CHANGELOG.md new file mode 100644 index 0000000..e375536 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/CHANGELOG.md @@ -0,0 +1,36 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.3.1] - 2019-01-25 +- Compatibility shim around version 0.4 + +## [0.3.0] - 2018-09-24 +- Add `SeedableRng::seed_from_u64` for convenient seeding. (#537) + +## [0.2.1] - 2018-06-08 +- References to a `CryptoRng` now also implement `CryptoRng`. (#470) + +## [0.2.0] - 2018-05-21 +- Enable the `std` feature by default. (#409) +- Remove `BlockRng{64}::inner` and `BlockRng::inner_mut`; instead making `core` public +- Add `BlockRng{64}::index` and `BlockRng{64}::generate_and_set`. (#374, #419) +- Change `BlockRngCore::Results` bound to also require `AsMut<[Self::Item]>`. (#419) +- Implement `std::io::Read` for RngCore. (#434) + +## [0.1.0] - 2018-04-17 +(Split out of the Rand crate, changes here are relative to rand 0.4.2) +- `RngCore` and `SeedableRng` are now part of `rand_core`. (#288) +- Add modules to help implementing RNGs `impl` and `le`. (#209, #228) +- Add `Error` and `ErrorKind`. (#225) +- Add `CryptoRng` marker trait. (#273) +- Add `BlockRngCore` trait. (#281) +- Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325) +- Revise the `SeedableRng` trait. (#233) +- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288) +- Add `RngCore::try_fill_bytes`. (#225) + +## [0.0.1] - 2017-09-14 (yanked) +Experimental version as part of the rand crate refactor. diff --git a/third_party/cargo/vendor/rand_core-0.3.1/COPYRIGHT b/third_party/cargo/vendor/rand_core-0.3.1/COPYRIGHT new file mode 100644 index 0000000..468d907 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/COPYRIGHT @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff --git a/third_party/cargo/vendor/rand_core-0.3.1/Cargo.toml b/third_party/cargo/vendor/rand_core-0.3.1/Cargo.toml new file mode 100644 index 0000000..439b7d1 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/Cargo.toml @@ -0,0 +1,37 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand_core" +version = "0.3.1" +authors = ["The Rand Project Developers", "The Rust Project Developers"] +description = "Core random number generator traits and tools for implementation.\n" +homepage = "https://crates.io/crates/rand_core" +documentation = "https://rust-random.github.io/rand/rand_core" +readme = "README.md" +keywords = ["random", "rng"] +categories = ["algorithms", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-random/rand" +[dependencies.rand_core] +version = "0.4" + +[features] +alloc = ["rand_core/alloc"] +default = ["std"] +serde1 = ["rand_core/serde1"] +std = ["rand_core/std"] +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff --git a/third_party/cargo/vendor/rand_core-0.3.1/LICENSE-APACHE b/third_party/cargo/vendor/rand_core-0.3.1/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand_core-0.3.1/LICENSE-MIT b/third_party/cargo/vendor/rand_core-0.3.1/LICENSE-MIT new file mode 100644 index 0000000..d93b5ba --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright 2018 Developers of the Rand project +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand_core-0.3.1/README.md b/third_party/cargo/vendor/rand_core-0.3.1/README.md new file mode 100644 index 0000000..dee6504 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/README.md @@ -0,0 +1,65 @@ +# rand_core + +[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Latest version](https://img.shields.io/crates/v/rand_core.svg)](https://crates.io/crates/rand_core) +[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_core) +[![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) + +Core traits and error types of the [rand] library, plus tools for implementing +RNGs. + +This crate is intended for use when implementing the core trait, `RngCore`; it +defines the core traits to be implemented as well as several small functions to +aid in their implementation and types required for error handling. + +The main [rand] crate re-exports most items defined in this crate, along with +tools to convert the integer samples generated by `RngCore` to many different +applications (including sampling from restricted ranges, conversion to floating +point, list permutations and secure initialisation of RNGs). Most users should +prefer to use the main [rand] crate. + +Links: + +- [API documentation (master)](https://rust-random.github.io/rand/rand_core) +- [API documentation (docs.rs)](https://docs.rs/rand_core) +- [Changelog](CHANGELOG.md) + +[rand]: https://crates.io/crates/rand + + +## Functionality + +The `rand_core` crate provides: + +- base random number generator traits +- error-reporting types +- functionality to aid implementation of RNGs + +The traits and error types are also available via `rand`. + +## Crate Features + +`rand_core` supports `no_std` and `alloc`-only configurations, as well as full +`std` functionality. The differences between `no_std` and full `std` are small, +comprising `RngCore` support for `Box` types where `R: RngCore`, as well as +extensions to the `Error` type's functionality. + +Due to [rust-lang/cargo#1596](https://github.com/rust-lang/cargo/issues/1596), +`rand_core` is built without `std` support by default. Since features are +unioned across the whole dependency tree, any crate using `rand` with its +default features will also enable `std` support in `rand_core`. + +The `serde1` feature can be used to derive `Serialize` and `Deserialize` for RNG +implementations that use the `BlockRng` or `BlockRng64` wrappers. + + +# License + +`rand_core` is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/third_party/cargo/vendor/rand_core-0.3.1/src/block.rs b/third_party/cargo/vendor/rand_core-0.3.1/src/block.rs new file mode 100644 index 0000000..3045b94 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/src/block.rs @@ -0,0 +1,499 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `BlockRngCore` trait and implementation helpers +//! +//! The [`BlockRngCore`] trait exists to assist in the implementation of RNGs +//! which generate a block of data in a cache instead of returning generated +//! values directly. +//! +//! Usage of this trait is optional, but provides two advantages: +//! implementations only need to concern themselves with generation of the +//! block, not the various [`RngCore`] methods (especially [`fill_bytes`], where +//! the optimal implementations are not trivial), and this allows +//! `ReseedingRng` (see [`rand`](https://docs.rs/rand) crate) perform periodic +//! reseeding with very low overhead. +//! +//! # Example +//! +//! ```norun +//! use rand_core::block::{BlockRngCore, BlockRng}; +//! +//! struct MyRngCore; +//! +//! impl BlockRngCore for MyRngCore { +//! type Results = [u32; 16]; +//! +//! fn generate(&mut self, results: &mut Self::Results) { +//! unimplemented!() +//! } +//! } +//! +//! impl SeedableRng for MyRngCore { +//! type Seed = unimplemented!(); +//! fn from_seed(seed: Self::Seed) -> Self { +//! unimplemented!() +//! } +//! } +//! +//! // optionally, also implement CryptoRng for MyRngCore +//! +//! // Final RNG. +//! type MyRng = BlockRng; +//! ``` +//! +//! [`BlockRngCore`]: crate::block::BlockRngCore +//! [`fill_bytes`]: RngCore::fill_bytes + +use core::convert::AsRef; +use core::fmt; +use {RngCore, CryptoRng, SeedableRng, Error}; +use impls::{fill_via_u32_chunks, fill_via_u64_chunks}; + +/// A trait for RNGs which do not generate random numbers individually, but in +/// blocks (typically `[u32; N]`). This technique is commonly used by +/// cryptographic RNGs to improve performance. +/// +/// See the [module][crate::block] documentation for details. +pub trait BlockRngCore { + /// Results element type, e.g. `u32`. + type Item; + + /// Results type. This is the 'block' an RNG implementing `BlockRngCore` + /// generates, which will usually be an array like `[u32; 16]`. + type Results: AsRef<[Self::Item]> + AsMut<[Self::Item]> + Default; + + /// Generate a new block of results. + fn generate(&mut self, results: &mut Self::Results); +} + + +/// A wrapper type implementing [`RngCore`] for some type implementing +/// [`BlockRngCore`] with `u32` array buffer; i.e. this can be used to implement +/// a full RNG from just a `generate` function. +/// +/// The `core` field may be accessed directly but the results buffer may not. +/// PRNG implementations can simply use a type alias +/// (`pub type MyRng = BlockRng;`) but might prefer to use a +/// wrapper type (`pub struct MyRng(BlockRng);`); the latter must +/// re-implement `RngCore` but hides the implementation details and allows +/// extra functionality to be defined on the RNG +/// (e.g. `impl MyRng { fn set_stream(...){...} }`). +/// +/// `BlockRng` has heavily optimized implementations of the [`RngCore`] methods +/// reading values from the results buffer, as well as +/// calling [`BlockRngCore::generate`] directly on the output array when +/// [`fill_bytes`] / [`try_fill_bytes`] is called on a large array. These methods +/// also handle the bookkeeping of when to generate a new batch of values. +/// +/// No whole generated `u32` values are thown away and all values are consumed +/// in-order. [`next_u32`] simply takes the next available `u32` value. +/// [`next_u64`] is implemented by combining two `u32` values, least +/// significant first. [`fill_bytes`] and [`try_fill_bytes`] consume a whole +/// number of `u32` values, converting each `u32` to a byte slice in +/// little-endian order. If the requested byte length is not a multiple of 4, +/// some bytes will be discarded. +/// +/// See also [`BlockRng64`] which uses `u64` array buffers. Currently there is +/// no direct support for other buffer types. +/// +/// For easy initialization `BlockRng` also implements [`SeedableRng`]. +/// +/// [`next_u32`]: RngCore::next_u32 +/// [`next_u64`]: RngCore::next_u64 +/// [`fill_bytes`]: RngCore::fill_bytes +/// [`try_fill_bytes`]: RngCore::try_fill_bytes +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct BlockRng { + results: R::Results, + index: usize, + /// The *core* part of the RNG, implementing the `generate` function. + pub core: R, +} + +// Custom Debug implementation that does not expose the contents of `results`. +impl fmt::Debug for BlockRng { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BlockRng") + .field("core", &self.core) + .field("result_len", &self.results.as_ref().len()) + .field("index", &self.index) + .finish() + } +} + +impl BlockRng { + /// Create a new `BlockRng` from an existing RNG implementing + /// `BlockRngCore`. Results will be generated on first use. + pub fn new(core: R) -> BlockRng{ + let results_empty = R::Results::default(); + BlockRng { + core, + index: results_empty.as_ref().len(), + results: results_empty, + } + } + + /// Get the index into the result buffer. + /// + /// If this is equal to or larger than the size of the result buffer then + /// the buffer is "empty" and `generate()` must be called to produce new + /// results. + pub fn index(&self) -> usize { + self.index + } + + /// Reset the number of available results. + /// This will force a new set of results to be generated on next use. + pub fn reset(&mut self) { + self.index = self.results.as_ref().len(); + } + + /// Generate a new set of results immediately, setting the index to the + /// given value. + pub fn generate_and_set(&mut self, index: usize) { + assert!(index < self.results.as_ref().len()); + self.core.generate(&mut self.results); + self.index = index; + } +} + +impl> RngCore for BlockRng +where ::Results: AsRef<[u32]> + AsMut<[u32]> +{ + #[inline(always)] + fn next_u32(&mut self) -> u32 { + if self.index >= self.results.as_ref().len() { + self.generate_and_set(0); + } + + let value = self.results.as_ref()[self.index]; + self.index += 1; + value + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + let read_u64 = |results: &[u32], index| { + if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { + // requires little-endian CPU supporting unaligned reads: + unsafe { *(&results[index] as *const u32 as *const u64) } + } else { + let x = u64::from(results[index]); + let y = u64::from(results[index + 1]); + (y << 32) | x + } + }; + + let len = self.results.as_ref().len(); + + let index = self.index; + if index < len-1 { + self.index += 2; + // Read an u64 from the current index + read_u64(self.results.as_ref(), index) + } else if index >= len { + self.generate_and_set(2); + read_u64(self.results.as_ref(), 0) + } else { + let x = u64::from(self.results.as_ref()[len-1]); + self.generate_and_set(1); + let y = u64::from(self.results.as_ref()[0]); + (y << 32) | x + } + } + + // As an optimization we try to write directly into the output buffer. + // This is only enabled for little-endian platforms where unaligned writes + // are known to be safe and fast. + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + fn fill_bytes(&mut self, dest: &mut [u8]) { + let mut filled = 0; + + // Continue filling from the current set of results + if self.index < self.results.as_ref().len() { + let (consumed_u32, filled_u8) = + fill_via_u32_chunks(&self.results.as_ref()[self.index..], + dest); + + self.index += consumed_u32; + filled += filled_u8; + } + + let len_remainder = + (dest.len() - filled) % (self.results.as_ref().len() * 4); + let end_direct = dest.len() - len_remainder; + + while filled < end_direct { + let dest_u32: &mut R::Results = unsafe { + &mut *(dest[filled..].as_mut_ptr() as + *mut ::Results) + }; + self.core.generate(dest_u32); + filled += self.results.as_ref().len() * 4; + self.index = self.results.as_ref().len(); + } + + if len_remainder > 0 { + self.core.generate(&mut self.results); + let (consumed_u32, _) = + fill_via_u32_chunks(self.results.as_ref(), + &mut dest[filled..]); + + self.index = consumed_u32; + } + } + + #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] + fn fill_bytes(&mut self, dest: &mut [u8]) { + let mut read_len = 0; + while read_len < dest.len() { + if self.index >= self.results.as_ref().len() { + self.generate_and_set(0); + } + let (consumed_u32, filled_u8) = + fill_via_u32_chunks(&self.results.as_ref()[self.index..], + &mut dest[read_len..]); + + self.index += consumed_u32; + read_len += filled_u8; + } + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.fill_bytes(dest); + Ok(()) + } +} + +impl SeedableRng for BlockRng { + type Seed = R::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + Self::new(R::from_seed(seed)) + } + + fn seed_from_u64(seed: u64) -> Self { + Self::new(R::seed_from_u64(seed)) + } + + fn from_rng(rng: S) -> Result { + Ok(Self::new(R::from_rng(rng)?)) + } +} + + + +/// A wrapper type implementing [`RngCore`] for some type implementing +/// [`BlockRngCore`] with `u64` array buffer; i.e. this can be used to implement +/// a full RNG from just a `generate` function. +/// +/// This is similar to [`BlockRng`], but specialized for algorithms that operate +/// on `u64` values. +/// +/// No whole generated `u64` values are thrown away and all values are consumed +/// in-order. [`next_u64`] simply takes the next available `u64` value. +/// [`next_u32`] is however a bit special: half of a `u64` is consumed, leaving +/// the other half in the buffer. If the next function called is [`next_u32`] +/// then the other half is then consumed, however both [`next_u64`] and +/// [`fill_bytes`] discard the rest of any half-consumed `u64`s when called. +/// +/// [`fill_bytes`] and [`try_fill_bytes`] consume a whole number of `u64` +/// values. If the requested length is not a multiple of 8, some bytes will be +/// discarded. +/// +/// [`next_u32`]: RngCore::next_u32 +/// [`next_u64`]: RngCore::next_u64 +/// [`fill_bytes`]: RngCore::fill_bytes +/// [`try_fill_bytes`]: RngCore::try_fill_bytes +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct BlockRng64 { + results: R::Results, + index: usize, + half_used: bool, // true if only half of the previous result is used + /// The *core* part of the RNG, implementing the `generate` function. + pub core: R, +} + +// Custom Debug implementation that does not expose the contents of `results`. +impl fmt::Debug for BlockRng64 { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BlockRng64") + .field("core", &self.core) + .field("result_len", &self.results.as_ref().len()) + .field("index", &self.index) + .field("half_used", &self.half_used) + .finish() + } +} + +impl BlockRng64 { + /// Create a new `BlockRng` from an existing RNG implementing + /// `BlockRngCore`. Results will be generated on first use. + pub fn new(core: R) -> BlockRng64{ + let results_empty = R::Results::default(); + BlockRng64 { + core, + index: results_empty.as_ref().len(), + half_used: false, + results: results_empty, + } + } + + /// Get the index into the result buffer. + /// + /// If this is equal to or larger than the size of the result buffer then + /// the buffer is "empty" and `generate()` must be called to produce new + /// results. + pub fn index(&self) -> usize { + self.index + } + + /// Reset the number of available results. + /// This will force a new set of results to be generated on next use. + pub fn reset(&mut self) { + self.index = self.results.as_ref().len(); + self.half_used = false; + } + + /// Generate a new set of results immediately, setting the index to the + /// given value. + pub fn generate_and_set(&mut self, index: usize) { + assert!(index < self.results.as_ref().len()); + self.core.generate(&mut self.results); + self.index = index; + self.half_used = false; + } +} + +impl> RngCore for BlockRng64 +where ::Results: AsRef<[u64]> + AsMut<[u64]> +{ + #[inline(always)] + fn next_u32(&mut self) -> u32 { + let mut index = self.index * 2 - self.half_used as usize; + if index >= self.results.as_ref().len() * 2 { + self.core.generate(&mut self.results); + self.index = 0; + // `self.half_used` is by definition `false` + self.half_used = false; + index = 0; + } + + self.half_used = !self.half_used; + self.index += self.half_used as usize; + + // Index as if this is a u32 slice. + unsafe { + let results = + &*(self.results.as_ref() as *const [u64] as *const [u32]); + if cfg!(target_endian = "little") { + *results.get_unchecked(index) + } else { + *results.get_unchecked(index ^ 1) + } + } + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + if self.index >= self.results.as_ref().len() { + self.core.generate(&mut self.results); + self.index = 0; + } + + let value = self.results.as_ref()[self.index]; + self.index += 1; + self.half_used = false; + value + } + + // As an optimization we try to write directly into the output buffer. + // This is only enabled for little-endian platforms where unaligned writes + // are known to be safe and fast. + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + fn fill_bytes(&mut self, dest: &mut [u8]) { + let mut filled = 0; + self.half_used = false; + + // Continue filling from the current set of results + if self.index < self.results.as_ref().len() { + let (consumed_u64, filled_u8) = + fill_via_u64_chunks(&self.results.as_ref()[self.index..], + dest); + + self.index += consumed_u64; + filled += filled_u8; + } + + let len_remainder = + (dest.len() - filled) % (self.results.as_ref().len() * 8); + let end_direct = dest.len() - len_remainder; + + while filled < end_direct { + let dest_u64: &mut R::Results = unsafe { + ::core::mem::transmute(dest[filled..].as_mut_ptr()) + }; + self.core.generate(dest_u64); + filled += self.results.as_ref().len() * 8; + self.index = self.results.as_ref().len(); + } + + if len_remainder > 0 { + self.core.generate(&mut self.results); + let (consumed_u64, _) = + fill_via_u64_chunks(&mut self.results.as_ref(), + &mut dest[filled..]); + + self.index = consumed_u64; + } + } + + #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] + fn fill_bytes(&mut self, dest: &mut [u8]) { + let mut read_len = 0; + self.half_used = false; + while read_len < dest.len() { + if self.index as usize >= self.results.as_ref().len() { + self.core.generate(&mut self.results); + self.index = 0; + } + + let (consumed_u64, filled_u8) = + fill_via_u64_chunks(&self.results.as_ref()[self.index as usize..], + &mut dest[read_len..]); + + self.index += consumed_u64; + read_len += filled_u8; + } + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} + +impl SeedableRng for BlockRng64 { + type Seed = R::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + Self::new(R::from_seed(seed)) + } + + fn seed_from_u64(seed: u64) -> Self { + Self::new(R::seed_from_u64(seed)) + } + + fn from_rng(rng: S) -> Result { + Ok(Self::new(R::from_rng(rng)?)) + } +} + +impl CryptoRng for BlockRng {} diff --git a/third_party/cargo/vendor/rand_core-0.3.1/src/error.rs b/third_party/cargo/vendor/rand_core-0.3.1/src/error.rs new file mode 100644 index 0000000..5a8459e --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/src/error.rs @@ -0,0 +1,177 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Error types + +use core::fmt; + +#[cfg(feature="std")] +use std::error::Error as stdError; +#[cfg(feature="std")] +use std::io; + +/// Error kind which can be matched over. +#[derive(PartialEq, Eq, Debug, Copy, Clone)] +pub enum ErrorKind { + /// Feature is not available; not recoverable. + /// + /// This is the most permanent failure type and implies the error cannot be + /// resolved simply by retrying (e.g. the feature may not exist in this + /// build of the application or on the current platform). + Unavailable, + /// General failure; there may be a chance of recovery on retry. + /// + /// This is the catch-all kind for errors from known and unknown sources + /// which do not have a more specific kind / handling method. + /// + /// It is suggested to retry a couple of times or retry later when + /// handling; some error sources may be able to resolve themselves, + /// although this is not likely. + Unexpected, + /// A transient failure which likely can be resolved or worked around. + /// + /// This error kind exists for a few specific cases where it is known that + /// the error likely can be resolved internally, but is reported anyway. + Transient, + /// Not ready yet: recommended to try again a little later. + /// + /// This error kind implies the generator needs more time or needs some + /// other part of the application to do something else first before it is + /// ready for use; for example this may be used by external generators + /// which require time for initialization. + NotReady, + #[doc(hidden)] + __Nonexhaustive, +} + +impl ErrorKind { + /// True if this kind of error may resolve itself on retry. + /// + /// See also `should_wait()`. + pub fn should_retry(self) -> bool { + self != ErrorKind::Unavailable + } + + /// True if we should retry but wait before retrying + /// + /// This implies `should_retry()` is true. + pub fn should_wait(self) -> bool { + self == ErrorKind::NotReady + } + + /// A description of this error kind + pub fn description(self) -> &'static str { + match self { + ErrorKind::Unavailable => "permanently unavailable", + ErrorKind::Unexpected => "unexpected failure", + ErrorKind::Transient => "transient failure", + ErrorKind::NotReady => "not ready yet", + ErrorKind::__Nonexhaustive => unreachable!(), + } + } +} + + +/// Error type of random number generators +/// +/// This is a relatively simple error type, designed for compatibility with and +/// without the Rust `std` library. It embeds a "kind" code, a message (static +/// string only), and an optional chained cause (`std` only). The `kind` and +/// `msg` fields can be accessed directly; cause can be accessed via +/// `std::error::Error::cause` or `Error::take_cause`. Construction can only be +/// done via `Error::new` or `Error::with_cause`. +#[derive(Debug)] +pub struct Error { + /// The error kind + pub kind: ErrorKind, + /// The error message + pub msg: &'static str, + #[cfg(feature="std")] + cause: Option>, +} + +impl Error { + /// Create a new instance, with specified kind and a message. + pub fn new(kind: ErrorKind, msg: &'static str) -> Self { + #[cfg(feature="std")] { + Error { kind, msg, cause: None } + } + #[cfg(not(feature="std"))] { + Error { kind, msg } + } + } + + /// Create a new instance, with specified kind, message, and a + /// chained cause. + /// + /// Note: `stdError` is an alias for `std::error::Error`. + /// + /// If not targetting `std` (i.e. `no_std`), this function is replaced by + /// another with the same prototype, except that there are no bounds on the + /// type `E` (because both `Box` and `stdError` are unavailable), and the + /// `cause` is ignored. + #[cfg(feature="std")] + pub fn with_cause(kind: ErrorKind, msg: &'static str, cause: E) -> Self + where E: Into> + { + Error { kind, msg, cause: Some(cause.into()) } + } + + /// Create a new instance, with specified kind, message, and a + /// chained cause. + /// + /// In `no_std` mode the *cause* is ignored. + #[cfg(not(feature="std"))] + pub fn with_cause(kind: ErrorKind, msg: &'static str, _cause: E) -> Self { + Error { kind, msg } + } + + /// Take the cause, if any. This allows the embedded cause to be extracted. + /// This uses `Option::take`, leaving `self` with no cause. + #[cfg(feature="std")] + pub fn take_cause(&mut self) -> Option> { + self.cause.take() + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[cfg(feature="std")] { + if let Some(ref cause) = self.cause { + return write!(f, "{} ({}); cause: {}", + self.msg, self.kind.description(), cause); + } + } + write!(f, "{} ({})", self.msg, self.kind.description()) + } +} + +#[cfg(feature="std")] +impl stdError for Error { + fn description(&self) -> &str { + self.msg + } + + fn cause(&self) -> Option<&stdError> { + self.cause.as_ref().map(|e| e.as_ref() as &stdError) + } +} + +#[cfg(feature="std")] +impl From for io::Error { + fn from(error: Error) -> Self { + use std::io::ErrorKind::*; + match error.kind { + ErrorKind::Unavailable => io::Error::new(NotFound, error), + ErrorKind::Unexpected | + ErrorKind::Transient => io::Error::new(Other, error), + ErrorKind::NotReady => io::Error::new(WouldBlock, error), + ErrorKind::__Nonexhaustive => unreachable!(), + } + } +} diff --git a/third_party/cargo/vendor/rand_core-0.3.1/src/impls.rs b/third_party/cargo/vendor/rand_core-0.3.1/src/impls.rs new file mode 100644 index 0000000..57bdd07 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/src/impls.rs @@ -0,0 +1,165 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Helper functions for implementing `RngCore` functions. +//! +//! For cross-platform reproducibility, these functions all use Little Endian: +//! least-significant part first. For example, `next_u64_via_u32` takes `u32` +//! values `x, y`, then outputs `(y << 32) | x`. To implement `next_u32` +//! from `next_u64` in little-endian order, one should use `next_u64() as u32`. +//! +//! Byte-swapping (like the std `to_le` functions) is only needed to convert +//! to/from byte sequences, and since its purpose is reproducibility, +//! non-reproducible sources (e.g. `OsRng`) need not bother with it. + +use core::intrinsics::transmute; +use core::ptr::copy_nonoverlapping; +use core::slice; +use core::cmp::min; +use core::mem::size_of; +use RngCore; + + +/// Implement `next_u64` via `next_u32`, little-endian order. +pub fn next_u64_via_u32(rng: &mut R) -> u64 { + // Use LE; we explicitly generate one value before the next. + let x = u64::from(rng.next_u32()); + let y = u64::from(rng.next_u32()); + (y << 32) | x +} + +/// Implement `fill_bytes` via `next_u64` and `next_u32`, little-endian order. +/// +/// The fastest way to fill a slice is usually to work as long as possible with +/// integers. That is why this method mostly uses `next_u64`, and only when +/// there are 4 or less bytes remaining at the end of the slice it uses +/// `next_u32` once. +pub fn fill_bytes_via_next(rng: &mut R, dest: &mut [u8]) { + let mut left = dest; + while left.len() >= 8 { + let (l, r) = {left}.split_at_mut(8); + left = r; + let chunk: [u8; 8] = unsafe { + transmute(rng.next_u64().to_le()) + }; + l.copy_from_slice(&chunk); + } + let n = left.len(); + if n > 4 { + let chunk: [u8; 8] = unsafe { + transmute(rng.next_u64().to_le()) + }; + left.copy_from_slice(&chunk[..n]); + } else if n > 0 { + let chunk: [u8; 4] = unsafe { + transmute(rng.next_u32().to_le()) + }; + left.copy_from_slice(&chunk[..n]); + } +} + +macro_rules! impl_uint_from_fill { + ($rng:expr, $ty:ty, $N:expr) => ({ + debug_assert!($N == size_of::<$ty>()); + + let mut int: $ty = 0; + unsafe { + let ptr = &mut int as *mut $ty as *mut u8; + let slice = slice::from_raw_parts_mut(ptr, $N); + $rng.fill_bytes(slice); + } + int + }); +} + +macro_rules! fill_via_chunks { + ($src:expr, $dst:expr, $ty:ty, $size:expr) => ({ + let chunk_size_u8 = min($src.len() * $size, $dst.len()); + let chunk_size = (chunk_size_u8 + $size - 1) / $size; + if cfg!(target_endian="little") { + unsafe { + copy_nonoverlapping( + $src.as_ptr() as *const u8, + $dst.as_mut_ptr(), + chunk_size_u8); + } + } else { + for (&n, chunk) in $src.iter().zip($dst.chunks_mut($size)) { + let tmp = n.to_le(); + let src_ptr = &tmp as *const $ty as *const u8; + unsafe { + copy_nonoverlapping(src_ptr, + chunk.as_mut_ptr(), + chunk.len()); + } + } + } + + (chunk_size, chunk_size_u8) + }); +} + +/// Implement `fill_bytes` by reading chunks from the output buffer of a block +/// based RNG. +/// +/// The return values are `(consumed_u32, filled_u8)`. +/// +/// `filled_u8` is the number of filled bytes in `dest`, which may be less than +/// the length of `dest`. +/// `consumed_u32` is the number of words consumed from `src`, which is the same +/// as `filled_u8 / 4` rounded up. +/// +/// # Example +/// (from `IsaacRng`) +/// +/// ```ignore +/// fn fill_bytes(&mut self, dest: &mut [u8]) { +/// let mut read_len = 0; +/// while read_len < dest.len() { +/// if self.index >= self.rsl.len() { +/// self.isaac(); +/// } +/// +/// let (consumed_u32, filled_u8) = +/// impls::fill_via_u32_chunks(&mut self.rsl[self.index..], +/// &mut dest[read_len..]); +/// +/// self.index += consumed_u32; +/// read_len += filled_u8; +/// } +/// } +/// ``` +pub fn fill_via_u32_chunks(src: &[u32], dest: &mut [u8]) -> (usize, usize) { + fill_via_chunks!(src, dest, u32, 4) +} + +/// Implement `fill_bytes` by reading chunks from the output buffer of a block +/// based RNG. +/// +/// The return values are `(consumed_u64, filled_u8)`. +/// `filled_u8` is the number of filled bytes in `dest`, which may be less than +/// the length of `dest`. +/// `consumed_u64` is the number of words consumed from `src`, which is the same +/// as `filled_u8 / 8` rounded up. +/// +/// See `fill_via_u32_chunks` for an example. +pub fn fill_via_u64_chunks(src: &[u64], dest: &mut [u8]) -> (usize, usize) { + fill_via_chunks!(src, dest, u64, 8) +} + +/// Implement `next_u32` via `fill_bytes`, little-endian order. +pub fn next_u32_via_fill(rng: &mut R) -> u32 { + impl_uint_from_fill!(rng, u32, 4) +} + +/// Implement `next_u64` via `fill_bytes`, little-endian order. +pub fn next_u64_via_fill(rng: &mut R) -> u64 { + impl_uint_from_fill!(rng, u64, 8) +} + +// TODO: implement tests for the above diff --git a/third_party/cargo/vendor/rand_core-0.3.1/src/le.rs b/third_party/cargo/vendor/rand_core-0.3.1/src/le.rs new file mode 100644 index 0000000..266651f --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/src/le.rs @@ -0,0 +1,68 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Little-Endian utilities +//! +//! Little-Endian order has been chosen for internal usage; this makes some +//! useful functions available. + +use core::ptr; + +macro_rules! read_slice { + ($src:expr, $dst:expr, $size:expr, $which:ident) => {{ + assert_eq!($src.len(), $size * $dst.len()); + + unsafe { + ptr::copy_nonoverlapping( + $src.as_ptr(), + $dst.as_mut_ptr() as *mut u8, + $src.len()); + } + for v in $dst.iter_mut() { + *v = v.$which(); + } + }}; +} + +/// Reads unsigned 32 bit integers from `src` into `dst`. +/// Borrowed from the `byteorder` crate. +#[inline] +pub fn read_u32_into(src: &[u8], dst: &mut [u32]) { + read_slice!(src, dst, 4, to_le); +} + +/// Reads unsigned 64 bit integers from `src` into `dst`. +/// Borrowed from the `byteorder` crate. +#[inline] +pub fn read_u64_into(src: &[u8], dst: &mut [u64]) { + read_slice!(src, dst, 8, to_le); +} + +#[test] +fn test_read() { + let bytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; + + let mut buf = [0u32; 4]; + read_u32_into(&bytes, &mut buf); + assert_eq!(buf[0], 0x04030201); + assert_eq!(buf[3], 0x100F0E0D); + + let mut buf = [0u32; 3]; + read_u32_into(&bytes[1..13], &mut buf); // unaligned + assert_eq!(buf[0], 0x05040302); + assert_eq!(buf[2], 0x0D0C0B0A); + + let mut buf = [0u64; 2]; + read_u64_into(&bytes, &mut buf); + assert_eq!(buf[0], 0x0807060504030201); + assert_eq!(buf[1], 0x100F0E0D0C0B0A09); + + let mut buf = [0u64; 1]; + read_u64_into(&bytes[7..15], &mut buf); // unaligned + assert_eq!(buf[0], 0x0F0E0D0C0B0A0908); +} diff --git a/third_party/cargo/vendor/rand_core-0.3.1/src/lib.rs b/third_party/cargo/vendor/rand_core-0.3.1/src/lib.rs new file mode 100644 index 0000000..8923142 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.3.1/src/lib.rs @@ -0,0 +1,46 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2017-2018 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Random number generation traits +//! +//! This version of `rand_core` is a compatibility shim around version 0.3. +//! +//! This crate is mainly of interest to crates publishing implementations of +//! [`RngCore`]. Other users are encouraged to use the [`rand`] crate instead +//! which re-exports the main traits and error types. +//! +//! [`RngCore`] is the core trait implemented by algorithmic pseudo-random number +//! generators and external random-number sources. +//! +//! [`SeedableRng`] is an extension trait for construction from fixed seeds and +//! other random number generators. +//! +//! [`Error`] is provided for error-handling. It is safe to use in `no_std` +//! environments. +//! +//! The [`impls`] and [`le`] sub-modules include a few small functions to assist +//! implementation of [`RngCore`]. +//! +//! [`rand`]: https://docs.rs/rand + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] + +#![no_std] + +extern crate rand_core as core4; + +pub use core4::{ErrorKind, Error}; +pub use core4::{block, impls, le}; +pub use core4::{RngCore, CryptoRng, SeedableRng}; diff --git a/third_party/cargo/vendor/rand_core-0.4.2/.cargo-checksum.json b/third_party/cargo/vendor/rand_core-0.4.2/.cargo-checksum.json new file mode 100644 index 0000000..958d0a4 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"41e587d62ec904ec1bf97a8137a74fd5f502beb30dc0d03c0db380d136d92b3a","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"9b2e5c9dd0041a4ab2f887a7054c7fe0e03715899cc55a8250a9fd296aa4fb5b","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"ec960eb9636ab8278e80815603187f7c8f0d8f6bc0683ebf86ad9963b9a6da97","src/block.rs":"1cd85e129bf8bf0653244dcf129b916aa5b2fa510fd0199f838c754e113c7ce3","src/error.rs":"8403a968d7c9bd95cc9f23d9dc5cc4771ede8e81dda5a8fdd59d347590345d14","src/impls.rs":"c248ddd04a65c974768baaec028fa0d2a6117525fa27bce8a98f2ba2f352700a","src/le.rs":"cb187f58f7514877918f7f47633397e08e20392dcf072bc245d62c9e5238198c","src/lib.rs":"65ef1545f6054eb19b6fb5ef8aced95acff51cc252fb0d032af49161493f3c8c"},"package":"9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand_core-0.4.2/BUILD b/third_party/cargo/vendor/rand_core-0.4.2/BUILD new file mode 100644 index 0000000..e8d86c2 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "rand_core", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.2", + crate_features = [ + "alloc", + "std", + ], +) + diff --git a/third_party/cargo/vendor/rand_core-0.4.2/CHANGELOG.md b/third_party/cargo/vendor/rand_core-0.4.2/CHANGELOG.md new file mode 100644 index 0000000..356f4d1 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/CHANGELOG.md @@ -0,0 +1,41 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.4.2] - 2019-08-01 +Back-port non-API changes from version 0.5.0: +- Enable testing with Miri and fix incorrect pointer usages (#779, #780, #781, #783, #784) +- Adjust usage of `#[inline]` for `BlockRng` and `BlockRng64` + +## [0.4.0] - 2019-01-24 +- Disable the `std` feature by default (#702) + +## [0.3.0] - 2018-09-24 +- Add `SeedableRng::seed_from_u64` for convenient seeding. (#537) + +## [0.2.1] - 2018-06-08 +- References to a `CryptoRng` now also implement `CryptoRng`. (#470) + +## [0.2.0] - 2018-05-21 +- Enable the `std` feature by default. (#409) +- Remove `BlockRng{64}::inner` and `BlockRng::inner_mut`; instead making `core` public +- Add `BlockRng{64}::index` and `BlockRng{64}::generate_and_set`. (#374, #419) +- Change `BlockRngCore::Results` bound to also require `AsMut<[Self::Item]>`. (#419) +- Implement `std::io::Read` for RngCore. (#434) + +## [0.1.0] - 2018-04-17 +(Split out of the Rand crate, changes here are relative to rand 0.4.2) +- `RngCore` and `SeedableRng` are now part of `rand_core`. (#288) +- Add modules to help implementing RNGs `impl` and `le`. (#209, #228) +- Add `Error` and `ErrorKind`. (#225) +- Add `CryptoRng` marker trait. (#273) +- Add `BlockRngCore` trait. (#281) +- Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325) +- Revise the `SeedableRng` trait. (#233) +- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288) +- Add `RngCore::try_fill_bytes`. (#225) + +## [0.0.1] - 2017-09-14 (yanked) +Experimental version as part of the rand crate refactor. diff --git a/third_party/cargo/vendor/rand_core-0.4.2/COPYRIGHT b/third_party/cargo/vendor/rand_core-0.4.2/COPYRIGHT new file mode 100644 index 0000000..468d907 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/COPYRIGHT @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff --git a/third_party/cargo/vendor/rand_core-0.4.2/Cargo.toml b/third_party/cargo/vendor/rand_core-0.4.2/Cargo.toml new file mode 100644 index 0000000..01d8ced --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/Cargo.toml @@ -0,0 +1,41 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand_core" +version = "0.4.2" +authors = ["The Rand Project Developers", "The Rust Project Developers"] +description = "Core random number generator traits and tools for implementation.\n" +homepage = "https://crates.io/crates/rand_core" +documentation = "https://rust-random.github.io/rand/rand_core/" +readme = "README.md" +keywords = ["random", "rng"] +categories = ["algorithms", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-random/rand" +[dependencies.serde] +version = "1" +optional = true + +[dependencies.serde_derive] +version = "^1.0.38" +optional = true + +[features] +alloc = [] +serde1 = ["serde", "serde_derive"] +std = ["alloc"] +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff --git a/third_party/cargo/vendor/rand_core-0.4.2/LICENSE-APACHE b/third_party/cargo/vendor/rand_core-0.4.2/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand_core-0.4.2/LICENSE-MIT b/third_party/cargo/vendor/rand_core-0.4.2/LICENSE-MIT new file mode 100644 index 0000000..d93b5ba --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright 2018 Developers of the Rand project +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand_core-0.4.2/README.md b/third_party/cargo/vendor/rand_core-0.4.2/README.md new file mode 100644 index 0000000..0ac8b91 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/README.md @@ -0,0 +1,77 @@ +# rand_core + +[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Latest version](https://img.shields.io/crates/v/rand_core.svg)](https://crates.io/crates/rand_core) +[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_core) +[![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) + +Core traits and error types of the [rand] library, plus tools for implementing +RNGs. + +This crate is intended for use when implementing the core trait, `RngCore`; it +defines the core traits to be implemented as well as several small functions to +aid in their implementation and types required for error handling. + +The main [rand] crate re-exports most items defined in this crate, along with +tools to convert the integer samples generated by `RngCore` to many different +applications (including sampling from restricted ranges, conversion to floating +point, list permutations and secure initialisation of RNGs). Most users should +prefer to use the main [rand] crate. + +Links: + +- [API documentation (master)](https://rust-random.github.io/rand/rand_core) +- [API documentation (docs.rs)](https://docs.rs/rand_core) +- [Changelog](CHANGELOG.md) + +[rand]: https://crates.io/crates/rand + + +## Functionality + +The `rand_core` crate provides: + +- base random number generator traits +- error-reporting types +- functionality to aid implementation of RNGs + +The traits and error types are also available via `rand`. + +## Versions + +Rand libs have inter-dependencies and make use of the +[semver trick](https://github.com/dtolnay/semver-trick/) in order to make traits +compatible across crate versions. (This is especially important for `RngCore` +and `SeedableRng`.) A few crate releases are thus compatibility shims, +depending on the *next* lib version (e.g. `rand_core` versions `0.2.2` and +`0.3.1`). This means, for example, that `rand_core_0_4_0::SeedableRng` and +`rand_core_0_3_0::SeedableRng` are distinct, incompatible traits, which can +cause build errors. Usually, running `cargo update` is enough to fix any issues. + +## Crate Features + +`rand_core` supports `no_std` and `alloc`-only configurations, as well as full +`std` functionality. The differences between `no_std` and full `std` are small, +comprising `RngCore` support for `Box` types where `R: RngCore`, +`std::io::Read` support for types supporting `RngCore`, and +extensions to the `Error` type's functionality. + +The `std` feature is *not enabled by default*. This is primarily to avoid build +problems where one crate implicitly requires `rand_core` with `std` support and +another crate requires `rand` *without* `std` support. However, the `rand` crate +continues to enable `std` support by default, both for itself and `rand_core`. + +The `serde1` feature can be used to derive `Serialize` and `Deserialize` for RNG +implementations that use the `BlockRng` or `BlockRng64` wrappers. + + +# License + +`rand_core` is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/third_party/cargo/vendor/rand_core-0.4.2/src/block.rs b/third_party/cargo/vendor/rand_core-0.4.2/src/block.rs new file mode 100644 index 0000000..7d91263 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/src/block.rs @@ -0,0 +1,433 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `BlockRngCore` trait and implementation helpers +//! +//! The [`BlockRngCore`] trait exists to assist in the implementation of RNGs +//! which generate a block of data in a cache instead of returning generated +//! values directly. +//! +//! Usage of this trait is optional, but provides two advantages: +//! implementations only need to concern themselves with generation of the +//! block, not the various [`RngCore`] methods (especially [`fill_bytes`], where +//! the optimal implementations are not trivial), and this allows +//! `ReseedingRng` (see [`rand`](https://docs.rs/rand) crate) perform periodic +//! reseeding with very low overhead. +//! +//! # Example +//! +//! ```norun +//! use rand_core::block::{BlockRngCore, BlockRng}; +//! +//! struct MyRngCore; +//! +//! impl BlockRngCore for MyRngCore { +//! type Results = [u32; 16]; +//! +//! fn generate(&mut self, results: &mut Self::Results) { +//! unimplemented!() +//! } +//! } +//! +//! impl SeedableRng for MyRngCore { +//! type Seed = unimplemented!(); +//! fn from_seed(seed: Self::Seed) -> Self { +//! unimplemented!() +//! } +//! } +//! +//! // optionally, also implement CryptoRng for MyRngCore +//! +//! // Final RNG. +//! type MyRng = BlockRng; +//! ``` +//! +//! [`BlockRngCore`]: crate::block::BlockRngCore +//! [`fill_bytes`]: RngCore::fill_bytes + +use core::convert::AsRef; +use core::{fmt, ptr}; +use {RngCore, CryptoRng, SeedableRng, Error}; +use impls::{fill_via_u32_chunks, fill_via_u64_chunks}; + +/// A trait for RNGs which do not generate random numbers individually, but in +/// blocks (typically `[u32; N]`). This technique is commonly used by +/// cryptographic RNGs to improve performance. +/// +/// See the [module][crate::block] documentation for details. +pub trait BlockRngCore { + /// Results element type, e.g. `u32`. + type Item; + + /// Results type. This is the 'block' an RNG implementing `BlockRngCore` + /// generates, which will usually be an array like `[u32; 16]`. + type Results: AsRef<[Self::Item]> + AsMut<[Self::Item]> + Default; + + /// Generate a new block of results. + fn generate(&mut self, results: &mut Self::Results); +} + + +/// A wrapper type implementing [`RngCore`] for some type implementing +/// [`BlockRngCore`] with `u32` array buffer; i.e. this can be used to implement +/// a full RNG from just a `generate` function. +/// +/// The `core` field may be accessed directly but the results buffer may not. +/// PRNG implementations can simply use a type alias +/// (`pub type MyRng = BlockRng;`) but might prefer to use a +/// wrapper type (`pub struct MyRng(BlockRng);`); the latter must +/// re-implement `RngCore` but hides the implementation details and allows +/// extra functionality to be defined on the RNG +/// (e.g. `impl MyRng { fn set_stream(...){...} }`). +/// +/// `BlockRng` has heavily optimized implementations of the [`RngCore`] methods +/// reading values from the results buffer, as well as +/// calling [`BlockRngCore::generate`] directly on the output array when +/// [`fill_bytes`] / [`try_fill_bytes`] is called on a large array. These methods +/// also handle the bookkeeping of when to generate a new batch of values. +/// +/// No whole generated `u32` values are thown away and all values are consumed +/// in-order. [`next_u32`] simply takes the next available `u32` value. +/// [`next_u64`] is implemented by combining two `u32` values, least +/// significant first. [`fill_bytes`] and [`try_fill_bytes`] consume a whole +/// number of `u32` values, converting each `u32` to a byte slice in +/// little-endian order. If the requested byte length is not a multiple of 4, +/// some bytes will be discarded. +/// +/// See also [`BlockRng64`] which uses `u64` array buffers. Currently there is +/// no direct support for other buffer types. +/// +/// For easy initialization `BlockRng` also implements [`SeedableRng`]. +/// +/// [`next_u32`]: RngCore::next_u32 +/// [`next_u64`]: RngCore::next_u64 +/// [`fill_bytes`]: RngCore::fill_bytes +/// [`try_fill_bytes`]: RngCore::try_fill_bytes +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct BlockRng { + results: R::Results, + index: usize, + /// The *core* part of the RNG, implementing the `generate` function. + pub core: R, +} + +// Custom Debug implementation that does not expose the contents of `results`. +impl fmt::Debug for BlockRng { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BlockRng") + .field("core", &self.core) + .field("result_len", &self.results.as_ref().len()) + .field("index", &self.index) + .finish() + } +} + +impl BlockRng { + /// Create a new `BlockRng` from an existing RNG implementing + /// `BlockRngCore`. Results will be generated on first use. + #[inline] + pub fn new(core: R) -> BlockRng{ + let results_empty = R::Results::default(); + BlockRng { + core, + index: results_empty.as_ref().len(), + results: results_empty, + } + } + + /// Get the index into the result buffer. + /// + /// If this is equal to or larger than the size of the result buffer then + /// the buffer is "empty" and `generate()` must be called to produce new + /// results. + #[inline(always)] + pub fn index(&self) -> usize { + self.index + } + + /// Reset the number of available results. + /// This will force a new set of results to be generated on next use. + #[inline] + pub fn reset(&mut self) { + self.index = self.results.as_ref().len(); + } + + /// Generate a new set of results immediately, setting the index to the + /// given value. + #[inline] + pub fn generate_and_set(&mut self, index: usize) { + assert!(index < self.results.as_ref().len()); + self.core.generate(&mut self.results); + self.index = index; + } +} + +impl> RngCore for BlockRng +where ::Results: AsRef<[u32]> + AsMut<[u32]> +{ + #[inline] + fn next_u32(&mut self) -> u32 { + if self.index >= self.results.as_ref().len() { + self.generate_and_set(0); + } + + let value = self.results.as_ref()[self.index]; + self.index += 1; + value + } + + #[inline] + fn next_u64(&mut self) -> u64 { + let read_u64 = |results: &[u32], index| { + if cfg!(any(target_endian = "little")) { + // requires little-endian CPU + let ptr: *const u64 = results[index..index+2].as_ptr() as *const u64; + unsafe { ptr::read_unaligned(ptr) } + } else { + let x = u64::from(results[index]); + let y = u64::from(results[index + 1]); + (y << 32) | x + } + }; + + let len = self.results.as_ref().len(); + + let index = self.index; + if index < len-1 { + self.index += 2; + // Read an u64 from the current index + read_u64(self.results.as_ref(), index) + } else if index >= len { + self.generate_and_set(2); + read_u64(self.results.as_ref(), 0) + } else { + let x = u64::from(self.results.as_ref()[len-1]); + self.generate_and_set(1); + let y = u64::from(self.results.as_ref()[0]); + (y << 32) | x + } + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + let mut read_len = 0; + while read_len < dest.len() { + if self.index >= self.results.as_ref().len() { + self.generate_and_set(0); + } + let (consumed_u32, filled_u8) = + fill_via_u32_chunks(&self.results.as_ref()[self.index..], + &mut dest[read_len..]); + + self.index += consumed_u32; + read_len += filled_u8; + } + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} + +impl SeedableRng for BlockRng { + type Seed = R::Seed; + + #[inline(always)] + fn from_seed(seed: Self::Seed) -> Self { + Self::new(R::from_seed(seed)) + } + + #[inline(always)] + fn seed_from_u64(seed: u64) -> Self { + Self::new(R::seed_from_u64(seed)) + } + + #[inline(always)] + fn from_rng(rng: S) -> Result { + Ok(Self::new(R::from_rng(rng)?)) + } +} + + + +/// A wrapper type implementing [`RngCore`] for some type implementing +/// [`BlockRngCore`] with `u64` array buffer; i.e. this can be used to implement +/// a full RNG from just a `generate` function. +/// +/// This is similar to [`BlockRng`], but specialized for algorithms that operate +/// on `u64` values. +/// +/// No whole generated `u64` values are thrown away and all values are consumed +/// in-order. [`next_u64`] simply takes the next available `u64` value. +/// [`next_u32`] is however a bit special: half of a `u64` is consumed, leaving +/// the other half in the buffer. If the next function called is [`next_u32`] +/// then the other half is then consumed, however both [`next_u64`] and +/// [`fill_bytes`] discard the rest of any half-consumed `u64`s when called. +/// +/// [`fill_bytes`] and [`try_fill_bytes`] consume a whole number of `u64` +/// values. If the requested length is not a multiple of 8, some bytes will be +/// discarded. +/// +/// [`next_u32`]: RngCore::next_u32 +/// [`next_u64`]: RngCore::next_u64 +/// [`fill_bytes`]: RngCore::fill_bytes +/// [`try_fill_bytes`]: RngCore::try_fill_bytes +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct BlockRng64 { + results: R::Results, + index: usize, + half_used: bool, // true if only half of the previous result is used + /// The *core* part of the RNG, implementing the `generate` function. + pub core: R, +} + +// Custom Debug implementation that does not expose the contents of `results`. +impl fmt::Debug for BlockRng64 { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BlockRng64") + .field("core", &self.core) + .field("result_len", &self.results.as_ref().len()) + .field("index", &self.index) + .field("half_used", &self.half_used) + .finish() + } +} + +impl BlockRng64 { + /// Create a new `BlockRng` from an existing RNG implementing + /// `BlockRngCore`. Results will be generated on first use. + #[inline] + pub fn new(core: R) -> BlockRng64{ + let results_empty = R::Results::default(); + BlockRng64 { + core, + index: results_empty.as_ref().len(), + half_used: false, + results: results_empty, + } + } + + /// Get the index into the result buffer. + /// + /// If this is equal to or larger than the size of the result buffer then + /// the buffer is "empty" and `generate()` must be called to produce new + /// results. + #[inline(always)] + pub fn index(&self) -> usize { + self.index + } + + /// Reset the number of available results. + /// This will force a new set of results to be generated on next use. + #[inline] + pub fn reset(&mut self) { + self.index = self.results.as_ref().len(); + self.half_used = false; + } + + /// Generate a new set of results immediately, setting the index to the + /// given value. + #[inline] + pub fn generate_and_set(&mut self, index: usize) { + assert!(index < self.results.as_ref().len()); + self.core.generate(&mut self.results); + self.index = index; + self.half_used = false; + } +} + +impl> RngCore for BlockRng64 +where ::Results: AsRef<[u64]> + AsMut<[u64]> +{ + #[inline] + fn next_u32(&mut self) -> u32 { + let mut index = self.index * 2 - self.half_used as usize; + if index >= self.results.as_ref().len() * 2 { + self.core.generate(&mut self.results); + self.index = 0; + // `self.half_used` is by definition `false` + self.half_used = false; + index = 0; + } + + self.half_used = !self.half_used; + self.index += self.half_used as usize; + + // Index as if this is a u32 slice. + unsafe { + let results = + &*(self.results.as_ref() as *const [u64] as *const [u32]); + if cfg!(target_endian = "little") { + *results.get_unchecked(index) + } else { + *results.get_unchecked(index ^ 1) + } + } + } + + #[inline] + fn next_u64(&mut self) -> u64 { + if self.index >= self.results.as_ref().len() { + self.core.generate(&mut self.results); + self.index = 0; + } + + let value = self.results.as_ref()[self.index]; + self.index += 1; + self.half_used = false; + value + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + let mut read_len = 0; + self.half_used = false; + while read_len < dest.len() { + if self.index as usize >= self.results.as_ref().len() { + self.core.generate(&mut self.results); + self.index = 0; + } + + let (consumed_u64, filled_u8) = + fill_via_u64_chunks(&self.results.as_ref()[self.index as usize..], + &mut dest[read_len..]); + + self.index += consumed_u64; + read_len += filled_u8; + } + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} + +impl SeedableRng for BlockRng64 { + type Seed = R::Seed; + + #[inline(always)] + fn from_seed(seed: Self::Seed) -> Self { + Self::new(R::from_seed(seed)) + } + + #[inline(always)] + fn seed_from_u64(seed: u64) -> Self { + Self::new(R::seed_from_u64(seed)) + } + + #[inline(always)] + fn from_rng(rng: S) -> Result { + Ok(Self::new(R::from_rng(rng)?)) + } +} + +impl CryptoRng for BlockRng {} diff --git a/third_party/cargo/vendor/rand_core-0.4.2/src/error.rs b/third_party/cargo/vendor/rand_core-0.4.2/src/error.rs new file mode 100644 index 0000000..5a8459e --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/src/error.rs @@ -0,0 +1,177 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Error types + +use core::fmt; + +#[cfg(feature="std")] +use std::error::Error as stdError; +#[cfg(feature="std")] +use std::io; + +/// Error kind which can be matched over. +#[derive(PartialEq, Eq, Debug, Copy, Clone)] +pub enum ErrorKind { + /// Feature is not available; not recoverable. + /// + /// This is the most permanent failure type and implies the error cannot be + /// resolved simply by retrying (e.g. the feature may not exist in this + /// build of the application or on the current platform). + Unavailable, + /// General failure; there may be a chance of recovery on retry. + /// + /// This is the catch-all kind for errors from known and unknown sources + /// which do not have a more specific kind / handling method. + /// + /// It is suggested to retry a couple of times or retry later when + /// handling; some error sources may be able to resolve themselves, + /// although this is not likely. + Unexpected, + /// A transient failure which likely can be resolved or worked around. + /// + /// This error kind exists for a few specific cases where it is known that + /// the error likely can be resolved internally, but is reported anyway. + Transient, + /// Not ready yet: recommended to try again a little later. + /// + /// This error kind implies the generator needs more time or needs some + /// other part of the application to do something else first before it is + /// ready for use; for example this may be used by external generators + /// which require time for initialization. + NotReady, + #[doc(hidden)] + __Nonexhaustive, +} + +impl ErrorKind { + /// True if this kind of error may resolve itself on retry. + /// + /// See also `should_wait()`. + pub fn should_retry(self) -> bool { + self != ErrorKind::Unavailable + } + + /// True if we should retry but wait before retrying + /// + /// This implies `should_retry()` is true. + pub fn should_wait(self) -> bool { + self == ErrorKind::NotReady + } + + /// A description of this error kind + pub fn description(self) -> &'static str { + match self { + ErrorKind::Unavailable => "permanently unavailable", + ErrorKind::Unexpected => "unexpected failure", + ErrorKind::Transient => "transient failure", + ErrorKind::NotReady => "not ready yet", + ErrorKind::__Nonexhaustive => unreachable!(), + } + } +} + + +/// Error type of random number generators +/// +/// This is a relatively simple error type, designed for compatibility with and +/// without the Rust `std` library. It embeds a "kind" code, a message (static +/// string only), and an optional chained cause (`std` only). The `kind` and +/// `msg` fields can be accessed directly; cause can be accessed via +/// `std::error::Error::cause` or `Error::take_cause`. Construction can only be +/// done via `Error::new` or `Error::with_cause`. +#[derive(Debug)] +pub struct Error { + /// The error kind + pub kind: ErrorKind, + /// The error message + pub msg: &'static str, + #[cfg(feature="std")] + cause: Option>, +} + +impl Error { + /// Create a new instance, with specified kind and a message. + pub fn new(kind: ErrorKind, msg: &'static str) -> Self { + #[cfg(feature="std")] { + Error { kind, msg, cause: None } + } + #[cfg(not(feature="std"))] { + Error { kind, msg } + } + } + + /// Create a new instance, with specified kind, message, and a + /// chained cause. + /// + /// Note: `stdError` is an alias for `std::error::Error`. + /// + /// If not targetting `std` (i.e. `no_std`), this function is replaced by + /// another with the same prototype, except that there are no bounds on the + /// type `E` (because both `Box` and `stdError` are unavailable), and the + /// `cause` is ignored. + #[cfg(feature="std")] + pub fn with_cause(kind: ErrorKind, msg: &'static str, cause: E) -> Self + where E: Into> + { + Error { kind, msg, cause: Some(cause.into()) } + } + + /// Create a new instance, with specified kind, message, and a + /// chained cause. + /// + /// In `no_std` mode the *cause* is ignored. + #[cfg(not(feature="std"))] + pub fn with_cause(kind: ErrorKind, msg: &'static str, _cause: E) -> Self { + Error { kind, msg } + } + + /// Take the cause, if any. This allows the embedded cause to be extracted. + /// This uses `Option::take`, leaving `self` with no cause. + #[cfg(feature="std")] + pub fn take_cause(&mut self) -> Option> { + self.cause.take() + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[cfg(feature="std")] { + if let Some(ref cause) = self.cause { + return write!(f, "{} ({}); cause: {}", + self.msg, self.kind.description(), cause); + } + } + write!(f, "{} ({})", self.msg, self.kind.description()) + } +} + +#[cfg(feature="std")] +impl stdError for Error { + fn description(&self) -> &str { + self.msg + } + + fn cause(&self) -> Option<&stdError> { + self.cause.as_ref().map(|e| e.as_ref() as &stdError) + } +} + +#[cfg(feature="std")] +impl From for io::Error { + fn from(error: Error) -> Self { + use std::io::ErrorKind::*; + match error.kind { + ErrorKind::Unavailable => io::Error::new(NotFound, error), + ErrorKind::Unexpected | + ErrorKind::Transient => io::Error::new(Other, error), + ErrorKind::NotReady => io::Error::new(WouldBlock, error), + ErrorKind::__Nonexhaustive => unreachable!(), + } + } +} diff --git a/third_party/cargo/vendor/rand_core-0.4.2/src/impls.rs b/third_party/cargo/vendor/rand_core-0.4.2/src/impls.rs new file mode 100644 index 0000000..57bdd07 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/src/impls.rs @@ -0,0 +1,165 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Helper functions for implementing `RngCore` functions. +//! +//! For cross-platform reproducibility, these functions all use Little Endian: +//! least-significant part first. For example, `next_u64_via_u32` takes `u32` +//! values `x, y`, then outputs `(y << 32) | x`. To implement `next_u32` +//! from `next_u64` in little-endian order, one should use `next_u64() as u32`. +//! +//! Byte-swapping (like the std `to_le` functions) is only needed to convert +//! to/from byte sequences, and since its purpose is reproducibility, +//! non-reproducible sources (e.g. `OsRng`) need not bother with it. + +use core::intrinsics::transmute; +use core::ptr::copy_nonoverlapping; +use core::slice; +use core::cmp::min; +use core::mem::size_of; +use RngCore; + + +/// Implement `next_u64` via `next_u32`, little-endian order. +pub fn next_u64_via_u32(rng: &mut R) -> u64 { + // Use LE; we explicitly generate one value before the next. + let x = u64::from(rng.next_u32()); + let y = u64::from(rng.next_u32()); + (y << 32) | x +} + +/// Implement `fill_bytes` via `next_u64` and `next_u32`, little-endian order. +/// +/// The fastest way to fill a slice is usually to work as long as possible with +/// integers. That is why this method mostly uses `next_u64`, and only when +/// there are 4 or less bytes remaining at the end of the slice it uses +/// `next_u32` once. +pub fn fill_bytes_via_next(rng: &mut R, dest: &mut [u8]) { + let mut left = dest; + while left.len() >= 8 { + let (l, r) = {left}.split_at_mut(8); + left = r; + let chunk: [u8; 8] = unsafe { + transmute(rng.next_u64().to_le()) + }; + l.copy_from_slice(&chunk); + } + let n = left.len(); + if n > 4 { + let chunk: [u8; 8] = unsafe { + transmute(rng.next_u64().to_le()) + }; + left.copy_from_slice(&chunk[..n]); + } else if n > 0 { + let chunk: [u8; 4] = unsafe { + transmute(rng.next_u32().to_le()) + }; + left.copy_from_slice(&chunk[..n]); + } +} + +macro_rules! impl_uint_from_fill { + ($rng:expr, $ty:ty, $N:expr) => ({ + debug_assert!($N == size_of::<$ty>()); + + let mut int: $ty = 0; + unsafe { + let ptr = &mut int as *mut $ty as *mut u8; + let slice = slice::from_raw_parts_mut(ptr, $N); + $rng.fill_bytes(slice); + } + int + }); +} + +macro_rules! fill_via_chunks { + ($src:expr, $dst:expr, $ty:ty, $size:expr) => ({ + let chunk_size_u8 = min($src.len() * $size, $dst.len()); + let chunk_size = (chunk_size_u8 + $size - 1) / $size; + if cfg!(target_endian="little") { + unsafe { + copy_nonoverlapping( + $src.as_ptr() as *const u8, + $dst.as_mut_ptr(), + chunk_size_u8); + } + } else { + for (&n, chunk) in $src.iter().zip($dst.chunks_mut($size)) { + let tmp = n.to_le(); + let src_ptr = &tmp as *const $ty as *const u8; + unsafe { + copy_nonoverlapping(src_ptr, + chunk.as_mut_ptr(), + chunk.len()); + } + } + } + + (chunk_size, chunk_size_u8) + }); +} + +/// Implement `fill_bytes` by reading chunks from the output buffer of a block +/// based RNG. +/// +/// The return values are `(consumed_u32, filled_u8)`. +/// +/// `filled_u8` is the number of filled bytes in `dest`, which may be less than +/// the length of `dest`. +/// `consumed_u32` is the number of words consumed from `src`, which is the same +/// as `filled_u8 / 4` rounded up. +/// +/// # Example +/// (from `IsaacRng`) +/// +/// ```ignore +/// fn fill_bytes(&mut self, dest: &mut [u8]) { +/// let mut read_len = 0; +/// while read_len < dest.len() { +/// if self.index >= self.rsl.len() { +/// self.isaac(); +/// } +/// +/// let (consumed_u32, filled_u8) = +/// impls::fill_via_u32_chunks(&mut self.rsl[self.index..], +/// &mut dest[read_len..]); +/// +/// self.index += consumed_u32; +/// read_len += filled_u8; +/// } +/// } +/// ``` +pub fn fill_via_u32_chunks(src: &[u32], dest: &mut [u8]) -> (usize, usize) { + fill_via_chunks!(src, dest, u32, 4) +} + +/// Implement `fill_bytes` by reading chunks from the output buffer of a block +/// based RNG. +/// +/// The return values are `(consumed_u64, filled_u8)`. +/// `filled_u8` is the number of filled bytes in `dest`, which may be less than +/// the length of `dest`. +/// `consumed_u64` is the number of words consumed from `src`, which is the same +/// as `filled_u8 / 8` rounded up. +/// +/// See `fill_via_u32_chunks` for an example. +pub fn fill_via_u64_chunks(src: &[u64], dest: &mut [u8]) -> (usize, usize) { + fill_via_chunks!(src, dest, u64, 8) +} + +/// Implement `next_u32` via `fill_bytes`, little-endian order. +pub fn next_u32_via_fill(rng: &mut R) -> u32 { + impl_uint_from_fill!(rng, u32, 4) +} + +/// Implement `next_u64` via `fill_bytes`, little-endian order. +pub fn next_u64_via_fill(rng: &mut R) -> u64 { + impl_uint_from_fill!(rng, u64, 8) +} + +// TODO: implement tests for the above diff --git a/third_party/cargo/vendor/rand_core-0.4.2/src/le.rs b/third_party/cargo/vendor/rand_core-0.4.2/src/le.rs new file mode 100644 index 0000000..266651f --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/src/le.rs @@ -0,0 +1,68 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Little-Endian utilities +//! +//! Little-Endian order has been chosen for internal usage; this makes some +//! useful functions available. + +use core::ptr; + +macro_rules! read_slice { + ($src:expr, $dst:expr, $size:expr, $which:ident) => {{ + assert_eq!($src.len(), $size * $dst.len()); + + unsafe { + ptr::copy_nonoverlapping( + $src.as_ptr(), + $dst.as_mut_ptr() as *mut u8, + $src.len()); + } + for v in $dst.iter_mut() { + *v = v.$which(); + } + }}; +} + +/// Reads unsigned 32 bit integers from `src` into `dst`. +/// Borrowed from the `byteorder` crate. +#[inline] +pub fn read_u32_into(src: &[u8], dst: &mut [u32]) { + read_slice!(src, dst, 4, to_le); +} + +/// Reads unsigned 64 bit integers from `src` into `dst`. +/// Borrowed from the `byteorder` crate. +#[inline] +pub fn read_u64_into(src: &[u8], dst: &mut [u64]) { + read_slice!(src, dst, 8, to_le); +} + +#[test] +fn test_read() { + let bytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; + + let mut buf = [0u32; 4]; + read_u32_into(&bytes, &mut buf); + assert_eq!(buf[0], 0x04030201); + assert_eq!(buf[3], 0x100F0E0D); + + let mut buf = [0u32; 3]; + read_u32_into(&bytes[1..13], &mut buf); // unaligned + assert_eq!(buf[0], 0x05040302); + assert_eq!(buf[2], 0x0D0C0B0A); + + let mut buf = [0u64; 2]; + read_u64_into(&bytes, &mut buf); + assert_eq!(buf[0], 0x0807060504030201); + assert_eq!(buf[1], 0x100F0E0D0C0B0A09); + + let mut buf = [0u64; 1]; + read_u64_into(&bytes[7..15], &mut buf); // unaligned + assert_eq!(buf[0], 0x0F0E0D0C0B0A0908); +} diff --git a/third_party/cargo/vendor/rand_core-0.4.2/src/lib.rs b/third_party/cargo/vendor/rand_core-0.4.2/src/lib.rs new file mode 100644 index 0000000..28e7ac1 --- /dev/null +++ b/third_party/cargo/vendor/rand_core-0.4.2/src/lib.rs @@ -0,0 +1,477 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2017-2018 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Random number generation traits +//! +//! This crate is mainly of interest to crates publishing implementations of +//! [`RngCore`]. Other users are encouraged to use the [`rand`] crate instead +//! which re-exports the main traits and error types. +//! +//! [`RngCore`] is the core trait implemented by algorithmic pseudo-random number +//! generators and external random-number sources. +//! +//! [`SeedableRng`] is an extension trait for construction from fixed seeds and +//! other random number generators. +//! +//! [`Error`] is provided for error-handling. It is safe to use in `no_std` +//! environments. +//! +//! The [`impls`] and [`le`] sub-modules include a few small functions to assist +//! implementation of [`RngCore`]. +//! +//! [`rand`]: https://docs.rs/rand + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] + +#![cfg_attr(not(feature="std"), no_std)] +#![cfg_attr(all(feature="alloc", not(feature="std")), feature(alloc))] + +#[cfg(feature="std")] extern crate core; +#[cfg(all(feature = "alloc", not(feature="std")))] extern crate alloc; +#[cfg(feature="serde1")] extern crate serde; +#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive; + + +use core::default::Default; +use core::convert::AsMut; +use core::ptr::copy_nonoverlapping; + +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::boxed::Box; + +pub use error::{ErrorKind, Error}; + + +mod error; +pub mod block; +pub mod impls; +pub mod le; + + +/// The core of a random number generator. +/// +/// This trait encapsulates the low-level functionality common to all +/// generators, and is the "back end", to be implemented by generators. +/// End users should normally use the `Rng` trait from the [`rand`] crate, +/// which is automatically implemented for every type implementing `RngCore`. +/// +/// Three different methods for generating random data are provided since the +/// optimal implementation of each is dependent on the type of generator. There +/// is no required relationship between the output of each; e.g. many +/// implementations of [`fill_bytes`] consume a whole number of `u32` or `u64` +/// values and drop any remaining unused bytes. +/// +/// The [`try_fill_bytes`] method is a variant of [`fill_bytes`] allowing error +/// handling; it is not deemed sufficiently useful to add equivalents for +/// [`next_u32`] or [`next_u64`] since the latter methods are almost always used +/// with algorithmic generators (PRNGs), which are normally infallible. +/// +/// Algorithmic generators implementing [`SeedableRng`] should normally have +/// *portable, reproducible* output, i.e. fix Endianness when converting values +/// to avoid platform differences, and avoid making any changes which affect +/// output (except by communicating that the release has breaking changes). +/// +/// Typically implementators will implement only one of the methods available +/// in this trait directly, then use the helper functions from the +/// [`impls`] module to implement the other methods. +/// +/// It is recommended that implementations also implement: +/// +/// - `Debug` with a custom implementation which *does not* print any internal +/// state (at least, [`CryptoRng`]s should not risk leaking state through +/// `Debug`). +/// - `Serialize` and `Deserialize` (from Serde), preferably making Serde +/// support optional at the crate level in PRNG libs. +/// - `Clone`, if possible. +/// - *never* implement `Copy` (accidental copies may cause repeated values). +/// - *do not* implement `Default` for pseudorandom generators, but instead +/// implement [`SeedableRng`], to guide users towards proper seeding. +/// External / hardware RNGs can choose to implement `Default`. +/// - `Eq` and `PartialEq` could be implemented, but are probably not useful. +/// +/// # Example +/// +/// A simple example, obviously not generating very *random* output: +/// +/// ``` +/// #![allow(dead_code)] +/// use rand_core::{RngCore, Error, impls}; +/// +/// struct CountingRng(u64); +/// +/// impl RngCore for CountingRng { +/// fn next_u32(&mut self) -> u32 { +/// self.next_u64() as u32 +/// } +/// +/// fn next_u64(&mut self) -> u64 { +/// self.0 += 1; +/// self.0 +/// } +/// +/// fn fill_bytes(&mut self, dest: &mut [u8]) { +/// impls::fill_bytes_via_next(self, dest) +/// } +/// +/// fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { +/// Ok(self.fill_bytes(dest)) +/// } +/// } +/// ``` +/// +/// [`rand`]: https://docs.rs/rand +/// [`try_fill_bytes`]: RngCore::try_fill_bytes +/// [`fill_bytes`]: RngCore::fill_bytes +/// [`next_u32`]: RngCore::next_u32 +/// [`next_u64`]: RngCore::next_u64 +pub trait RngCore { + /// Return the next random `u32`. + /// + /// RNGs must implement at least one method from this trait directly. In + /// the case this method is not implemented directly, it can be implemented + /// using `self.next_u64() as u32` or via + /// [`fill_bytes`](impls::next_u32_via_fill). + fn next_u32(&mut self) -> u32; + + /// Return the next random `u64`. + /// + /// RNGs must implement at least one method from this trait directly. In + /// the case this method is not implemented directly, it can be implemented + /// via [`next_u32`](impls::next_u64_via_u32) or via + /// [`fill_bytes`](impls::next_u64_via_fill). + fn next_u64(&mut self) -> u64; + + /// Fill `dest` with random data. + /// + /// RNGs must implement at least one method from this trait directly. In + /// the case this method is not implemented directly, it can be implemented + /// via [`next_u*`](impls::fill_bytes_via_next) or + /// via [`try_fill_bytes`](RngCore::try_fill_bytes); if this generator can + /// fail the implementation must choose how best to handle errors here + /// (e.g. panic with a descriptive message or log a warning and retry a few + /// times). + /// + /// This method should guarantee that `dest` is entirely filled + /// with new data, and may panic if this is impossible + /// (e.g. reading past the end of a file that is being used as the + /// source of randomness). + fn fill_bytes(&mut self, dest: &mut [u8]); + + /// Fill `dest` entirely with random data. + /// + /// This is the only method which allows an RNG to report errors while + /// generating random data thus making this the primary method implemented + /// by external (true) RNGs (e.g. `OsRng`) which can fail. It may be used + /// directly to generate keys and to seed (infallible) PRNGs. + /// + /// Other than error handling, this method is identical to [`fill_bytes`]; + /// thus this may be implemented using `Ok(self.fill_bytes(dest))` or + /// `fill_bytes` may be implemented with + /// `self.try_fill_bytes(dest).unwrap()` or more specific error handling. + /// + /// [`fill_bytes`]: RngCore::fill_bytes + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>; +} + +/// A marker trait used to indicate that an [`RngCore`] or [`BlockRngCore`] +/// implementation is supposed to be cryptographically secure. +/// +/// *Cryptographically secure generators*, also known as *CSPRNGs*, should +/// satisfy an additional properties over other generators: given the first +/// *k* bits of an algorithm's output +/// sequence, it should not be possible using polynomial-time algorithms to +/// predict the next bit with probability significantly greater than 50%. +/// +/// Some generators may satisfy an additional property, however this is not +/// required by this trait: if the CSPRNG's state is revealed, it should not be +/// computationally-feasible to reconstruct output prior to this. Some other +/// generators allow backwards-computation and are consided *reversible*. +/// +/// Note that this trait is provided for guidance only and cannot guarantee +/// suitability for cryptographic applications. In general it should only be +/// implemented for well-reviewed code implementing well-regarded algorithms. +/// +/// Note also that use of a `CryptoRng` does not protect against other +/// weaknesses such as seeding from a weak entropy source or leaking state. +/// +/// [`BlockRngCore`]: block::BlockRngCore +pub trait CryptoRng {} + +/// A random number generator that can be explicitly seeded. +/// +/// This trait encapsulates the low-level functionality common to all +/// pseudo-random number generators (PRNGs, or algorithmic generators). +/// +/// The `FromEntropy` trait from the [`rand`] crate is automatically +/// implemented for every type implementing `SeedableRng`, providing +/// a convenient `from_entropy()` constructor. +/// +/// [`rand`]: https://docs.rs/rand +pub trait SeedableRng: Sized { + /// Seed type, which is restricted to types mutably-dereferencable as `u8` + /// arrays (we recommend `[u8; N]` for some `N`). + /// + /// It is recommended to seed PRNGs with a seed of at least circa 100 bits, + /// which means an array of `[u8; 12]` or greater to avoid picking RNGs with + /// partially overlapping periods. + /// + /// For cryptographic RNG's a seed of 256 bits is recommended, `[u8; 32]`. + /// + /// + /// # Implementing `SeedableRng` for RNGs with large seeds + /// + /// Note that the required traits `core::default::Default` and + /// `core::convert::AsMut` are not implemented for large arrays + /// `[u8; N]` with `N` > 32. To be able to implement the traits required by + /// `SeedableRng` for RNGs with such large seeds, the newtype pattern can be + /// used: + /// + /// ``` + /// use rand_core::SeedableRng; + /// + /// const N: usize = 64; + /// pub struct MyRngSeed(pub [u8; N]); + /// pub struct MyRng(MyRngSeed); + /// + /// impl Default for MyRngSeed { + /// fn default() -> MyRngSeed { + /// MyRngSeed([0; N]) + /// } + /// } + /// + /// impl AsMut<[u8]> for MyRngSeed { + /// fn as_mut(&mut self) -> &mut [u8] { + /// &mut self.0 + /// } + /// } + /// + /// impl SeedableRng for MyRng { + /// type Seed = MyRngSeed; + /// + /// fn from_seed(seed: MyRngSeed) -> MyRng { + /// MyRng(seed) + /// } + /// } + /// ``` + type Seed: Sized + Default + AsMut<[u8]>; + + /// Create a new PRNG using the given seed. + /// + /// PRNG implementations are allowed to assume that bits in the seed are + /// well distributed. That means usually that the number of one and zero + /// bits are about equal, and values like 0, 1 and (size - 1) are unlikely. + /// + /// PRNG implementations are recommended to be reproducible. A PRNG seeded + /// using this function with a fixed seed should produce the same sequence + /// of output in the future and on different architectures (with for example + /// different endianness). + /// + /// It is however not required that this function yield the same state as a + /// reference implementation of the PRNG given equivalent seed; if necessary + /// another constructor replicating behaviour from a reference + /// implementation can be added. + /// + /// PRNG implementations should make sure `from_seed` never panics. In the + /// case that some special values (like an all zero seed) are not viable + /// seeds it is preferable to map these to alternative constant value(s), + /// for example `0xBAD5EEDu32` or `0x0DDB1A5E5BAD5EEDu64` ("odd biases? bad + /// seed"). This is assuming only a small number of values must be rejected. + fn from_seed(seed: Self::Seed) -> Self; + + /// Create a new PRNG using a `u64` seed. + /// + /// This is a convenience-wrapper around `from_seed` to allow construction + /// of any `SeedableRng` from a simple `u64` value. It is designed such that + /// low Hamming Weight numbers like 0 and 1 can be used and should still + /// result in good, independent seeds to the PRNG which is returned. + /// + /// This **is not suitable for cryptography**, as should be clear given that + /// the input size is only 64 bits. + /// + /// Implementations for PRNGs *may* provide their own implementations of + /// this function, but the default implementation should be good enough for + /// all purposes. *Changing* the implementation of this function should be + /// considered a value-breaking change. + fn seed_from_u64(mut state: u64) -> Self { + // We use PCG32 to generate a u32 sequence, and copy to the seed + const MUL: u64 = 6364136223846793005; + const INC: u64 = 11634580027462260723; + + let mut seed = Self::Seed::default(); + for chunk in seed.as_mut().chunks_mut(4) { + // We advance the state first (to get away from the input value, + // in case it has low Hamming Weight). + state = state.wrapping_mul(MUL).wrapping_add(INC); + + // Use PCG output function with to_le to generate x: + let xorshifted = (((state >> 18) ^ state) >> 27) as u32; + let rot = (state >> 59) as u32; + let x = xorshifted.rotate_right(rot).to_le(); + + unsafe { + let p = &x as *const u32 as *const u8; + copy_nonoverlapping(p, chunk.as_mut_ptr(), chunk.len()); + } + } + + Self::from_seed(seed) + } + + /// Create a new PRNG seeded from another `Rng`. + /// + /// This is the recommended way to initialize PRNGs with fresh entropy. The + /// `FromEntropy` trait from the [`rand`] crate provides a convenient + /// `from_entropy` method based on `from_rng`. + /// + /// Usage of this method is not recommended when reproducibility is required + /// since implementing PRNGs are not required to fix Endianness and are + /// allowed to modify implementations in new releases. + /// + /// It is important to use a good source of randomness to initialize the + /// PRNG. Cryptographic PRNG may be rendered insecure when seeded from a + /// non-cryptographic PRNG or with insufficient entropy. + /// Many non-cryptographic PRNGs will show statistical bias in their first + /// results if their seed numbers are small or if there is a simple pattern + /// between them. + /// + /// Prefer to seed from a strong external entropy source like `OsRng` from + /// the [`rand_os`] crate or from a cryptographic PRNG; if creating a new + /// generator for cryptographic uses you *must* seed from a strong source. + /// + /// Seeding a small PRNG from another small PRNG is possible, but + /// something to be careful with. An extreme example of how this can go + /// wrong is seeding an Xorshift RNG from another Xorshift RNG, which + /// will effectively clone the generator. In general seeding from a + /// generator which is hard to predict is probably okay. + /// + /// PRNG implementations are allowed to assume that a good RNG is provided + /// for seeding, and that it is cryptographically secure when appropriate. + /// + /// [`rand`]: https://docs.rs/rand + /// [`rand_os`]: https://docs.rs/rand_os + fn from_rng(mut rng: R) -> Result { + let mut seed = Self::Seed::default(); + rng.try_fill_bytes(seed.as_mut())?; + Ok(Self::from_seed(seed)) + } +} + +// Implement `RngCore` for references to an `RngCore`. +// Force inlining all functions, so that it is up to the `RngCore` +// implementation and the optimizer to decide on inlining. +impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + (**self).next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + (**self).next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + (**self).fill_bytes(dest) + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + (**self).try_fill_bytes(dest) + } +} + +// Implement `RngCore` for boxed references to an `RngCore`. +// Force inlining all functions, so that it is up to the `RngCore` +// implementation and the optimizer to decide on inlining. +#[cfg(feature="alloc")] +impl RngCore for Box { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + (**self).next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + (**self).next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + (**self).fill_bytes(dest) + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + (**self).try_fill_bytes(dest) + } +} + +#[cfg(feature="std")] +impl std::io::Read for RngCore { + fn read(&mut self, buf: &mut [u8]) -> Result { + self.try_fill_bytes(buf)?; + Ok(buf.len()) + } +} + +// Implement `CryptoRng` for references to an `CryptoRng`. +impl<'a, R: CryptoRng + ?Sized> CryptoRng for &'a mut R {} + +// Implement `CryptoRng` for boxed references to an `CryptoRng`. +#[cfg(feature="alloc")] +impl CryptoRng for Box {} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_seed_from_u64() { + struct SeedableNum(u64); + impl SeedableRng for SeedableNum { + type Seed = [u8; 8]; + fn from_seed(seed: Self::Seed) -> Self { + let mut x = [0u64; 1]; + le::read_u64_into(&seed, &mut x); + SeedableNum(x[0]) + } + } + + const N: usize = 8; + const SEEDS: [u64; N] = [0u64, 1, 2, 3, 4, 8, 16, -1i64 as u64]; + let mut results = [0u64; N]; + for (i, seed) in SEEDS.iter().enumerate() { + let SeedableNum(x) = SeedableNum::seed_from_u64(*seed); + results[i] = x; + } + + for (i1, r1) in results.iter().enumerate() { + let weight = r1.count_ones(); + // This is the binomial distribution B(64, 0.5), so chance of + // weight < 20 is binocdf(19, 64, 0.5) = 7.8e-4, and same for + // weight > 44. + assert!(weight >= 20 && weight <= 44); + + for (i2, r2) in results.iter().enumerate() { + if i1 == i2 { continue; } + let diff_weight = (r1 ^ r2).count_ones(); + assert!(diff_weight >= 20); + } + } + + // value-breakage test: + assert_eq!(results[0], 5029875928683246316); + } +} diff --git a/third_party/cargo/vendor/rand_hc-0.1.0/.cargo-checksum.json b/third_party/cargo/vendor/rand_hc-0.1.0/.cargo-checksum.json new file mode 100644 index 0000000..562cce3 --- /dev/null +++ b/third_party/cargo/vendor/rand_hc-0.1.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"f6dd960de06e087466066cd3e05bfd51288d144f917a62c591238697d7db1f49","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"467a2ecd73f7b32471fe00fe8042ef4dff756c05e6e4e6dd3a2e48d25867ef07","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"a771e4354f6b3ad4c92da1a5c9a239b6c291527db869632ecea4f20e24ca1135","README.md":"98a46c583c11b36bf3cc30ba646c9598a7d051b22c10e6d408aa0b1aefc6062d","src/hc128.rs":"ec8a1122eff5d1b79efa721d97d8aabaadd3f9af504336ecd928c082a9a40b45","src/lib.rs":"959f8d7280fac5683e4d2bf1713b3742a0a3685bb0b7e19d06875d254751cffb"},"package":"7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand_hc-0.1.0/BUILD b/third_party/cargo/vendor/rand_hc-0.1.0/BUILD new file mode 100644 index 0000000..89de231 --- /dev/null +++ b/third_party/cargo/vendor/rand_hc-0.1.0/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "rand_hc", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/rand_core-0.3.1:rand_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/rand_hc-0.1.0/CHANGELOG.md b/third_party/cargo/vendor/rand_hc-0.1.0/CHANGELOG.md new file mode 100644 index 0000000..d0c4a2f --- /dev/null +++ b/third_party/cargo/vendor/rand_hc-0.1.0/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.0] - 2018-10-17 +- Pulled out of the Rand crate diff --git a/third_party/cargo/vendor/rand_hc-0.1.0/COPYRIGHT b/third_party/cargo/vendor/rand_hc-0.1.0/COPYRIGHT new file mode 100644 index 0000000..468d907 --- /dev/null +++ b/third_party/cargo/vendor/rand_hc-0.1.0/COPYRIGHT @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff --git a/third_party/cargo/vendor/rand_hc-0.1.0/Cargo.toml b/third_party/cargo/vendor/rand_hc-0.1.0/Cargo.toml new file mode 100644 index 0000000..e080274 --- /dev/null +++ b/third_party/cargo/vendor/rand_hc-0.1.0/Cargo.toml @@ -0,0 +1,32 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand_hc" +version = "0.1.0" +authors = ["The Rand Project Developers"] +description = "HC128 random number generator\n" +homepage = "https://crates.io/crates/rand_hc" +documentation = "https://docs.rs/rand_hc" +readme = "README.md" +keywords = ["random", "rng", "hc128"] +categories = ["algorithms", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-random/rand" +[dependencies.rand_core] +version = ">=0.2, <0.4" +default-features = false +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff --git a/third_party/cargo/vendor/rand_hc-0.1.0/LICENSE-APACHE b/third_party/cargo/vendor/rand_hc-0.1.0/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand_hc-0.1.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand_hc-0.1.0/LICENSE-MIT b/third_party/cargo/vendor/rand_hc-0.1.0/LICENSE-MIT new file mode 100644 index 0000000..cf65607 --- /dev/null +++ b/third_party/cargo/vendor/rand_hc-0.1.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright 2018 Developers of the Rand project + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand_hc-0.1.0/README.md b/third_party/cargo/vendor/rand_hc-0.1.0/README.md new file mode 100644 index 0000000..9c1f5e1 --- /dev/null +++ b/third_party/cargo/vendor/rand_hc-0.1.0/README.md @@ -0,0 +1,44 @@ +# rand_hc + +[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Latest version](https://img.shields.io/crates/v/rand_hc.svg)](https://crates.io/crates/rand_hc) +[![Documentation](https://docs.rs/rand_hc/badge.svg)](https://docs.rs/rand_hc) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-yellow.svg)](https://github.com/rust-random/rand#rust-version-requirements) +[![License](https://img.shields.io/crates/l/rand_hc.svg)](https://github.com/rust-random/rand/tree/master/rand_hc#license) + +A cryptographically secure random number generator that uses the HC-128 +algorithm. + +HC-128 is a stream cipher designed by Hongjun Wu[^1], that we use as an +RNG. It is selected as one of the "stream ciphers suitable for widespread +adoption" by eSTREAM[^2]. + +Documentation: +[master branch](https://rust-random.github.io/rand/rand_hc/index.html), +[by release](https://docs.rs/rand_hc) + +[Changelog](CHANGELOG.md) + +[rand]: https://crates.io/crates/rand +[^1]: Hongjun Wu (2008). ["The Stream Cipher HC-128"]( + http://www.ecrypt.eu.org/stream/p3ciphers/hc/hc128_p3.pdf). + *The eSTREAM Finalists*, LNCS 4986, pp. 39–47, Springer-Verlag. + +[^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( + http://www.ecrypt.eu.org/stream/) + + +## Crate Features + +`rand_hc` is `no_std` compatible. It does not require any functionality +outside of the `core` lib, thus there are no features to configure. + + +# License + +`rand_hc` is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/third_party/cargo/vendor/rand_hc-0.1.0/src/hc128.rs b/third_party/cargo/vendor/rand_hc-0.1.0/src/hc128.rs new file mode 100644 index 0000000..d1dadcc --- /dev/null +++ b/third_party/cargo/vendor/rand_hc-0.1.0/src/hc128.rs @@ -0,0 +1,462 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The HC-128 random number generator. + +use core::fmt; +use rand_core::{CryptoRng, RngCore, SeedableRng, Error, le}; +use rand_core::block::{BlockRngCore, BlockRng}; + +const SEED_WORDS: usize = 8; // 128 bit key followed by 128 bit iv + +/// A cryptographically secure random number generator that uses the HC-128 +/// algorithm. +/// +/// HC-128 is a stream cipher designed by Hongjun Wu[^1], that we use as an +/// RNG. It is selected as one of the "stream ciphers suitable for widespread +/// adoption" by eSTREAM[^2]. +/// +/// HC-128 is an array based RNG. In this it is similar to RC-4 and ISAAC before +/// it, but those have never been proven cryptographically secure (or have even +/// been significantly compromised, as in the case of RC-4[^5]). +/// +/// Because HC-128 works with simple indexing into a large array and with a few +/// operations that parallelize well, it has very good performance. The size of +/// the array it needs, 4kb, can however be a disadvantage. +/// +/// This implementation is not based on the version of HC-128 submitted to the +/// eSTREAM contest, but on a later version by the author with a few small +/// improvements from December 15, 2009[^3]. +/// +/// HC-128 has no known weaknesses that are easier to exploit than doing a +/// brute-force search of 2128. A very comprehensive analysis of the +/// current state of known attacks / weaknesses of HC-128 is given in *Some +/// Results On Analysis And Implementation Of HC-128 Stream Cipher*[^4]. +/// +/// The average cycle length is expected to be +/// 21024*32+10-1 = 232777. +/// We support seeding with a 256-bit array, which matches the 128-bit key +/// concatenated with a 128-bit IV from the stream cipher. +/// +/// This implementation uses an output buffer of sixteen `u32` words, and uses +/// [`BlockRng`] to implement the [`RngCore`] methods. +/// +/// ## References +/// [^1]: Hongjun Wu (2008). ["The Stream Cipher HC-128"]( +/// http://www.ecrypt.eu.org/stream/p3ciphers/hc/hc128_p3.pdf). +/// *The eSTREAM Finalists*, LNCS 4986, pp. 39–47, Springer-Verlag. +/// +/// [^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( +/// http://www.ecrypt.eu.org/stream/) +/// +/// [^3]: Hongjun Wu, [Stream Ciphers HC-128 and HC-256]( +/// https://www.ntu.edu.sg/home/wuhj/research/hc/index.html) +/// +/// [^4]: Shashwat Raizada (January 2015),["Some Results On Analysis And +/// Implementation Of HC-128 Stream Cipher"]( +/// http://library.isical.ac.in:8080/jspui/bitstream/123456789/6636/1/TH431.pdf). +/// +/// [^5]: Internet Engineering Task Force (February 2015), +/// ["Prohibiting RC4 Cipher Suites"](https://tools.ietf.org/html/rfc7465). +/// +/// [`BlockRng`]: ../rand_core/block/struct.BlockRng.html +/// [`RngCore`]: ../rand_core/trait.RngCore.html +#[derive(Clone, Debug)] +pub struct Hc128Rng(BlockRng); + +impl RngCore for Hc128Rng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for Hc128Rng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + Hc128Rng(BlockRng::::from_seed(seed)) + } + + fn from_rng(rng: R) -> Result { + BlockRng::::from_rng(rng).map(Hc128Rng) + } +} + +impl CryptoRng for Hc128Rng {} + +/// The core of `Hc128Rng`, used with `BlockRng`. +#[derive(Clone)] +pub struct Hc128Core { + t: [u32; 1024], + counter1024: usize, +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for Hc128Core { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Hc128Core {{}}") + } +} + +impl BlockRngCore for Hc128Core { + type Item = u32; + type Results = [u32; 16]; + + fn generate(&mut self, results: &mut Self::Results) { + assert!(self.counter1024 % 16 == 0); + + let cc = self.counter1024 % 512; + let dd = (cc + 16) % 512; + let ee = cc.wrapping_sub(16) % 512; + + if self.counter1024 & 512 == 0 { + // P block + results[0] = self.step_p(cc+0, cc+1, ee+13, ee+6, ee+4); + results[1] = self.step_p(cc+1, cc+2, ee+14, ee+7, ee+5); + results[2] = self.step_p(cc+2, cc+3, ee+15, ee+8, ee+6); + results[3] = self.step_p(cc+3, cc+4, cc+0, ee+9, ee+7); + results[4] = self.step_p(cc+4, cc+5, cc+1, ee+10, ee+8); + results[5] = self.step_p(cc+5, cc+6, cc+2, ee+11, ee+9); + results[6] = self.step_p(cc+6, cc+7, cc+3, ee+12, ee+10); + results[7] = self.step_p(cc+7, cc+8, cc+4, ee+13, ee+11); + results[8] = self.step_p(cc+8, cc+9, cc+5, ee+14, ee+12); + results[9] = self.step_p(cc+9, cc+10, cc+6, ee+15, ee+13); + results[10] = self.step_p(cc+10, cc+11, cc+7, cc+0, ee+14); + results[11] = self.step_p(cc+11, cc+12, cc+8, cc+1, ee+15); + results[12] = self.step_p(cc+12, cc+13, cc+9, cc+2, cc+0); + results[13] = self.step_p(cc+13, cc+14, cc+10, cc+3, cc+1); + results[14] = self.step_p(cc+14, cc+15, cc+11, cc+4, cc+2); + results[15] = self.step_p(cc+15, dd+0, cc+12, cc+5, cc+3); + } else { + // Q block + results[0] = self.step_q(cc+0, cc+1, ee+13, ee+6, ee+4); + results[1] = self.step_q(cc+1, cc+2, ee+14, ee+7, ee+5); + results[2] = self.step_q(cc+2, cc+3, ee+15, ee+8, ee+6); + results[3] = self.step_q(cc+3, cc+4, cc+0, ee+9, ee+7); + results[4] = self.step_q(cc+4, cc+5, cc+1, ee+10, ee+8); + results[5] = self.step_q(cc+5, cc+6, cc+2, ee+11, ee+9); + results[6] = self.step_q(cc+6, cc+7, cc+3, ee+12, ee+10); + results[7] = self.step_q(cc+7, cc+8, cc+4, ee+13, ee+11); + results[8] = self.step_q(cc+8, cc+9, cc+5, ee+14, ee+12); + results[9] = self.step_q(cc+9, cc+10, cc+6, ee+15, ee+13); + results[10] = self.step_q(cc+10, cc+11, cc+7, cc+0, ee+14); + results[11] = self.step_q(cc+11, cc+12, cc+8, cc+1, ee+15); + results[12] = self.step_q(cc+12, cc+13, cc+9, cc+2, cc+0); + results[13] = self.step_q(cc+13, cc+14, cc+10, cc+3, cc+1); + results[14] = self.step_q(cc+14, cc+15, cc+11, cc+4, cc+2); + results[15] = self.step_q(cc+15, dd+0, cc+12, cc+5, cc+3); + } + self.counter1024 = self.counter1024.wrapping_add(16); + } +} + +impl Hc128Core { + // One step of HC-128, update P and generate 32 bits keystream + #[inline(always)] + fn step_p(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) + -> u32 + { + let (p, q) = self.t.split_at_mut(512); + // FIXME: it would be great if we the bounds checks here could be + // optimized out, and we would not need unsafe. + // This improves performance by about 7%. + unsafe { + let temp0 = p.get_unchecked(i511).rotate_right(23); + let temp1 = p.get_unchecked(i3).rotate_right(10); + let temp2 = p.get_unchecked(i10).rotate_right(8); + *p.get_unchecked_mut(i) = p.get_unchecked(i) + .wrapping_add(temp2) + .wrapping_add(temp0 ^ temp1); + let temp3 = { + // The h1 function in HC-128 + let a = *p.get_unchecked(i12) as u8; + let c = (p.get_unchecked(i12) >> 16) as u8; + q[a as usize].wrapping_add(q[256 + c as usize]) + }; + temp3 ^ p.get_unchecked(i) + } + } + + // One step of HC-128, update Q and generate 32 bits keystream + // Similar to `step_p`, but `p` and `q` are swapped, and the rotates are to + // the left instead of to the right. + #[inline(always)] + fn step_q(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) + -> u32 + { + let (p, q) = self.t.split_at_mut(512); + unsafe { + let temp0 = q.get_unchecked(i511).rotate_left(23); + let temp1 = q.get_unchecked(i3).rotate_left(10); + let temp2 = q.get_unchecked(i10).rotate_left(8); + *q.get_unchecked_mut(i) = q.get_unchecked(i) + .wrapping_add(temp2) + .wrapping_add(temp0 ^ temp1); + let temp3 = { + // The h2 function in HC-128 + let a = *q.get_unchecked(i12) as u8; + let c = (q.get_unchecked(i12) >> 16) as u8; + p[a as usize].wrapping_add(p[256 + c as usize]) + }; + temp3 ^ q.get_unchecked(i) + } + } + + fn sixteen_steps(&mut self) { + assert!(self.counter1024 % 16 == 0); + + let cc = self.counter1024 % 512; + let dd = (cc + 16) % 512; + let ee = cc.wrapping_sub(16) % 512; + + if self.counter1024 < 512 { + // P block + self.t[cc+0] = self.step_p(cc+0, cc+1, ee+13, ee+6, ee+4); + self.t[cc+1] = self.step_p(cc+1, cc+2, ee+14, ee+7, ee+5); + self.t[cc+2] = self.step_p(cc+2, cc+3, ee+15, ee+8, ee+6); + self.t[cc+3] = self.step_p(cc+3, cc+4, cc+0, ee+9, ee+7); + self.t[cc+4] = self.step_p(cc+4, cc+5, cc+1, ee+10, ee+8); + self.t[cc+5] = self.step_p(cc+5, cc+6, cc+2, ee+11, ee+9); + self.t[cc+6] = self.step_p(cc+6, cc+7, cc+3, ee+12, ee+10); + self.t[cc+7] = self.step_p(cc+7, cc+8, cc+4, ee+13, ee+11); + self.t[cc+8] = self.step_p(cc+8, cc+9, cc+5, ee+14, ee+12); + self.t[cc+9] = self.step_p(cc+9, cc+10, cc+6, ee+15, ee+13); + self.t[cc+10] = self.step_p(cc+10, cc+11, cc+7, cc+0, ee+14); + self.t[cc+11] = self.step_p(cc+11, cc+12, cc+8, cc+1, ee+15); + self.t[cc+12] = self.step_p(cc+12, cc+13, cc+9, cc+2, cc+0); + self.t[cc+13] = self.step_p(cc+13, cc+14, cc+10, cc+3, cc+1); + self.t[cc+14] = self.step_p(cc+14, cc+15, cc+11, cc+4, cc+2); + self.t[cc+15] = self.step_p(cc+15, dd+0, cc+12, cc+5, cc+3); + } else { + // Q block + self.t[cc+512+0] = self.step_q(cc+0, cc+1, ee+13, ee+6, ee+4); + self.t[cc+512+1] = self.step_q(cc+1, cc+2, ee+14, ee+7, ee+5); + self.t[cc+512+2] = self.step_q(cc+2, cc+3, ee+15, ee+8, ee+6); + self.t[cc+512+3] = self.step_q(cc+3, cc+4, cc+0, ee+9, ee+7); + self.t[cc+512+4] = self.step_q(cc+4, cc+5, cc+1, ee+10, ee+8); + self.t[cc+512+5] = self.step_q(cc+5, cc+6, cc+2, ee+11, ee+9); + self.t[cc+512+6] = self.step_q(cc+6, cc+7, cc+3, ee+12, ee+10); + self.t[cc+512+7] = self.step_q(cc+7, cc+8, cc+4, ee+13, ee+11); + self.t[cc+512+8] = self.step_q(cc+8, cc+9, cc+5, ee+14, ee+12); + self.t[cc+512+9] = self.step_q(cc+9, cc+10, cc+6, ee+15, ee+13); + self.t[cc+512+10] = self.step_q(cc+10, cc+11, cc+7, cc+0, ee+14); + self.t[cc+512+11] = self.step_q(cc+11, cc+12, cc+8, cc+1, ee+15); + self.t[cc+512+12] = self.step_q(cc+12, cc+13, cc+9, cc+2, cc+0); + self.t[cc+512+13] = self.step_q(cc+13, cc+14, cc+10, cc+3, cc+1); + self.t[cc+512+14] = self.step_q(cc+14, cc+15, cc+11, cc+4, cc+2); + self.t[cc+512+15] = self.step_q(cc+15, dd+0, cc+12, cc+5, cc+3); + } + self.counter1024 += 16; + } + + // Initialize an HC-128 random number generator. The seed has to be + // 256 bits in length (`[u32; 8]`), matching the 128 bit `key` followed by + // 128 bit `iv` when HC-128 where to be used as a stream cipher. + fn init(seed: [u32; SEED_WORDS]) -> Self { + #[inline] + fn f1(x: u32) -> u32 { + x.rotate_right(7) ^ x.rotate_right(18) ^ (x >> 3) + } + + #[inline] + fn f2(x: u32) -> u32 { + x.rotate_right(17) ^ x.rotate_right(19) ^ (x >> 10) + } + + let mut t = [0u32; 1024]; + + // Expand the key and iv into P and Q + let (key, iv) = seed.split_at(4); + t[..4].copy_from_slice(key); + t[4..8].copy_from_slice(key); + t[8..12].copy_from_slice(iv); + t[12..16].copy_from_slice(iv); + + // Generate the 256 intermediate values W[16] ... W[256+16-1], and + // copy the last 16 generated values to the start op P. + for i in 16..256+16 { + t[i] = f2(t[i-2]).wrapping_add(t[i-7]).wrapping_add(f1(t[i-15])) + .wrapping_add(t[i-16]).wrapping_add(i as u32); + } + { + let (p1, p2) = t.split_at_mut(256); + p1[0..16].copy_from_slice(&p2[0..16]); + } + + // Generate both the P and Q tables + for i in 16..1024 { + t[i] = f2(t[i-2]).wrapping_add(t[i-7]).wrapping_add(f1(t[i-15])) + .wrapping_add(t[i-16]).wrapping_add(256 + i as u32); + } + + let mut core = Self { t, counter1024: 0 }; + + // run the cipher 1024 steps + for _ in 0..64 { core.sixteen_steps() }; + core.counter1024 = 0; + core + } +} + +impl SeedableRng for Hc128Core { + type Seed = [u8; SEED_WORDS*4]; + + /// Create an HC-128 random number generator with a seed. The seed has to be + /// 256 bits in length, matching the 128 bit `key` followed by 128 bit `iv` + /// when HC-128 where to be used as a stream cipher. + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_u32 = [0u32; SEED_WORDS]; + le::read_u32_into(&seed, &mut seed_u32); + Self::init(seed_u32) + } +} + +impl CryptoRng for Hc128Core {} + +#[cfg(test)] +mod test { + use ::rand_core::{RngCore, SeedableRng}; + use super::Hc128Rng; + + #[test] + // Test vector 1 from the paper "The Stream Cipher HC-128" + fn test_hc128_true_values_a() { + let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng = Hc128Rng::from_seed(seed); + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0x73150082, 0x3bfd03a0, 0xfb2fd77f, 0xaa63af0e, + 0xde122fc6, 0xa7dc29b6, 0x62a68527, 0x8b75ec68, + 0x9036db1e, 0x81896005, 0x00ade078, 0x491fbf9a, + 0x1cdc3013, 0x6c3d6e24, 0x90f664b2, 0x9cd57102]; + assert_eq!(results, expected); + } + + #[test] + // Test vector 2 from the paper "The Stream Cipher HC-128" + fn test_hc128_true_values_b() { + let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 1,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng = Hc128Rng::from_seed(seed); + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0xc01893d5, 0xb7dbe958, 0x8f65ec98, 0x64176604, + 0x36fc6724, 0xc82c6eec, 0x1b1c38a7, 0xc9b42a95, + 0x323ef123, 0x0a6a908b, 0xce757b68, 0x9f14f7bb, + 0xe4cde011, 0xaeb5173f, 0x89608c94, 0xb5cf46ca]; + assert_eq!(results, expected); + } + + #[test] + // Test vector 3 from the paper "The Stream Cipher HC-128" + fn test_hc128_true_values_c() { + let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng = Hc128Rng::from_seed(seed); + + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected = [0x518251a4, 0x04b4930a, 0xb02af931, 0x0639f032, + 0xbcb4a47a, 0x5722480b, 0x2bf99f72, 0xcdc0e566, + 0x310f0c56, 0xd3cc83e8, 0x663db8ef, 0x62dfe07f, + 0x593e1790, 0xc5ceaa9c, 0xab03806f, 0xc9a6e5a0]; + assert_eq!(results, expected); + } + + #[test] + fn test_hc128_true_values_u64() { + let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng = Hc128Rng::from_seed(seed); + + let mut results = [0u64; 8]; + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected = [0x3bfd03a073150082, 0xaa63af0efb2fd77f, + 0xa7dc29b6de122fc6, 0x8b75ec6862a68527, + 0x818960059036db1e, 0x491fbf9a00ade078, + 0x6c3d6e241cdc3013, 0x9cd5710290f664b2]; + assert_eq!(results, expected); + + // The RNG operates in a P block of 512 results and next a Q block. + // After skipping 2*800 u32 results we end up somewhere in the Q block + // of the second round + for _ in 0..800 { rng.next_u64(); } + + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected = [0xd8c4d6ca84d0fc10, 0xf16a5d91dc66e8e7, + 0xd800de5bc37a8653, 0x7bae1f88c0dfbb4c, + 0x3bfe1f374e6d4d14, 0x424b55676be3fa06, + 0xe3a1e8758cbff579, 0x417f7198c5652bcd]; + assert_eq!(results, expected); + } + + #[test] + fn test_hc128_true_values_bytes() { + let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng = Hc128Rng::from_seed(seed); + let expected = [0x31, 0xf9, 0x2a, 0xb0, 0x32, 0xf0, 0x39, 0x06, + 0x7a, 0xa4, 0xb4, 0xbc, 0x0b, 0x48, 0x22, 0x57, + 0x72, 0x9f, 0xf9, 0x2b, 0x66, 0xe5, 0xc0, 0xcd, + 0x56, 0x0c, 0x0f, 0x31, 0xe8, 0x83, 0xcc, 0xd3, + 0xef, 0xb8, 0x3d, 0x66, 0x7f, 0xe0, 0xdf, 0x62, + 0x90, 0x17, 0x3e, 0x59, 0x9c, 0xaa, 0xce, 0xc5, + 0x6f, 0x80, 0x03, 0xab, 0xa0, 0xe5, 0xa6, 0xc9, + 0x60, 0x95, 0x84, 0x7a, 0xa5, 0x68, 0x5a, 0x84, + 0xea, 0xd5, 0xf3, 0xea, 0x73, 0xa9, 0xad, 0x01, + 0x79, 0x7d, 0xbe, 0x9f, 0xea, 0xe3, 0xf9, 0x74, + 0x0e, 0xda, 0x2f, 0xa0, 0xe4, 0x7b, 0x4b, 0x1b, + 0xdd, 0x17, 0x69, 0x4a, 0xfe, 0x9f, 0x56, 0x95, + 0xad, 0x83, 0x6b, 0x9d, 0x60, 0xa1, 0x99, 0x96, + 0x90, 0x00, 0x66, 0x7f, 0xfa, 0x7e, 0x65, 0xe9, + 0xac, 0x8b, 0x92, 0x34, 0x77, 0xb4, 0x23, 0xd0, + 0xb9, 0xab, 0xb1, 0x47, 0x7d, 0x4a, 0x13, 0x0a]; + + // Pick a somewhat large buffer so we can test filling with the + // remainder from `state.results`, directly filling the buffer, and + // filling the remainder of the buffer. + let mut buffer = [0u8; 16*4*2]; + // Consume a value so that we have a remainder. + assert!(rng.next_u64() == 0x04b4930a518251a4); + rng.fill_bytes(&mut buffer); + + // [u8; 128] doesn't implement PartialEq + assert_eq!(buffer.len(), expected.len()); + for (b, e) in buffer.iter().zip(expected.iter()) { + assert_eq!(b, e); + } + } + + #[test] + fn test_hc128_clone() { + let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv + let mut rng1 = Hc128Rng::from_seed(seed); + let mut rng2 = rng1.clone(); + for _ in 0..16 { + assert_eq!(rng1.next_u32(), rng2.next_u32()); + } + } +} diff --git a/third_party/cargo/vendor/rand_hc-0.1.0/src/lib.rs b/third_party/cargo/vendor/rand_hc-0.1.0/src/lib.rs new file mode 100644 index 0000000..15ca34e --- /dev/null +++ b/third_party/cargo/vendor/rand_hc-0.1.0/src/lib.rs @@ -0,0 +1,25 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The HC128 random number generator. + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://docs.rs/rand_hc/0.1.0")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] + +#![no_std] + +extern crate rand_core; + +mod hc128; + +pub use hc128::{Hc128Rng, Hc128Core}; diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/.cargo-checksum.json b/third_party/cargo/vendor/rand_isaac-0.1.1/.cargo-checksum.json new file mode 100644 index 0000000..c552718 --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"1f98689d52278352079e5235ffe00537bd3b64c1807a87d5707e3e74c7fce1d8","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"c3fb66104a60aa0dd91b83645be897023e7eb001aa6be108a1948999e86d2512","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"9a1c416b5930337e94fe559673a32a136d3ddd513f19dbd1b37039f8fc3501a1","src/isaac.rs":"40b00c02dc1ce29786c2e5e4c4d642588709397d6bf276a1610743b9b76ab9c6","src/isaac64.rs":"61a11f4a34dc2f009771d41c8d200c1c4815cdc23dfbe96aec03219cfeee4daa","src/isaac_array.rs":"89d20f07eb4dacd42f4cdc25b59796d51bca708f218e6e6dd4a445113b5123d6","src/lib.rs":"840a9c5a5ef2150cc4fb4a3edf34bda7e48bfaa49a3ee7ef8b182743aeaf73dd"},"package":"ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/BUILD b/third_party/cargo/vendor/rand_isaac-0.1.1/BUILD new file mode 100644 index 0000000..34a3052 --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "rand_isaac", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/rand_core-0.3.1:rand_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/CHANGELOG.md b/third_party/cargo/vendor/rand_isaac-0.1.1/CHANGELOG.md new file mode 100644 index 0000000..fb1ab3f --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.1] - 2018-11-26 +- Fix `rand_core` version requirement +- Fix doc links + +## [0.1.0] - 2018-10-17 +- Pulled out of the Rand crate diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/COPYRIGHT b/third_party/cargo/vendor/rand_isaac-0.1.1/COPYRIGHT new file mode 100644 index 0000000..468d907 --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/COPYRIGHT @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/Cargo.toml b/third_party/cargo/vendor/rand_isaac-0.1.1/Cargo.toml new file mode 100644 index 0000000..79a541d --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/Cargo.toml @@ -0,0 +1,45 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand_isaac" +version = "0.1.1" +authors = ["The Rand Project Developers", "The Rust Project Developers"] +description = "ISAAC random number generator\n" +homepage = "https://crates.io/crates/rand_isaac" +documentation = "https://rust-random.github.io/rand/rand_isaac" +readme = "README.md" +keywords = ["random", "rng", "isaac"] +categories = ["algorithms", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-random/rand" +[dependencies.rand_core] +version = "0.3" +default-features = false + +[dependencies.serde] +version = "1" +optional = true + +[dependencies.serde_derive] +version = "^1.0.38" +optional = true +[dev-dependencies.bincode] +version = "1" + +[features] +serde1 = ["serde", "serde_derive", "rand_core/serde1"] +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/LICENSE-APACHE b/third_party/cargo/vendor/rand_isaac-0.1.1/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/LICENSE-MIT b/third_party/cargo/vendor/rand_isaac-0.1.1/LICENSE-MIT new file mode 100644 index 0000000..d93b5ba --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright 2018 Developers of the Rand project +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/README.md b/third_party/cargo/vendor/rand_isaac-0.1.1/README.md new file mode 100644 index 0000000..02d1230 --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/README.md @@ -0,0 +1,47 @@ +# rand_isaac + +[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Latest version](https://img.shields.io/crates/v/rand_isaac.svg)](https://crates.io/crates/rand_isaac) +[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_isaac) +[![API](https://docs.rs/rand_isaac/badge.svg)](https://docs.rs/rand_isaac) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) + +Implements the ISAAC and ISAAC-64 random number generators. + +ISAAC stands for "Indirection, Shift, Accumulate, Add, and Count" which are +the principal bitwise operations employed. It is the most advanced of a +series of array based random number generator designed by Robert Jenkins +in 1996[^1][^2]. + +ISAAC is notably fast and produces excellent quality random numbers for +non-cryptographic applications. + +Links: + +- [API documentation (master)](https://rust-random.github.io/rand/rand_isaac) +- [API documentation (docs.rs)](https://docs.rs/rand_isaac) +- [Changelog](CHANGELOG.md) + +[rand]: https://crates.io/crates/rand +[^1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number generator*](http://burtleburtle.net/bob/rand/isaacafa.html) +[^2]: Bob Jenkins, [*ISAAC and RC4*](http://burtleburtle.net/bob/rand/isaac.html) + + +## Crate Features + +`rand_isaac` is `no_std` compatible. It does not require any functionality +outside of the `core` lib, thus there are no features to configure. + +The `serde1` feature includes implementations of `Serialize` and `Deserialize` +for the included RNGs. + + +# License + +`rand_isaac` is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/src/isaac.rs b/third_party/cargo/vendor/rand_isaac-0.1.1/src/isaac.rs new file mode 100644 index 0000000..2bfdd94 --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/src/isaac.rs @@ -0,0 +1,484 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2018 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The ISAAC random number generator. + +use core::{fmt, slice}; +use core::num::Wrapping as w; +use rand_core::{RngCore, SeedableRng, Error, le}; +use rand_core::block::{BlockRngCore, BlockRng}; +use isaac_array::IsaacArray; + +#[allow(non_camel_case_types)] +type w32 = w; + +const RAND_SIZE_LEN: usize = 8; +const RAND_SIZE: usize = 1 << RAND_SIZE_LEN; + +/// A random number generator that uses the ISAAC algorithm. +/// +/// ISAAC stands for "Indirection, Shift, Accumulate, Add, and Count" which are +/// the principal bitwise operations employed. It is the most advanced of a +/// series of array based random number generator designed by Robert Jenkins +/// in 1996[^1][^2]. +/// +/// ISAAC is notably fast and produces excellent quality random numbers for +/// non-cryptographic applications. +/// +/// In spite of being designed with cryptographic security in mind, ISAAC hasn't +/// been stringently cryptanalyzed and thus cryptographers do not not +/// consensually trust it to be secure. When looking for a secure RNG, prefer +/// [`Hc128Rng`] instead, which, like ISAAC, is an array-based RNG and one of +/// the stream-ciphers selected the by eSTREAM contest. +/// +/// In 2006 an improvement to ISAAC was suggested by Jean-Philippe Aumasson, +/// named ISAAC+[^3]. But because the specification is not complete, because +/// there is no good implementation, and because the suggested bias may not +/// exist, it is not implemented here. +/// +/// ## Overview of the ISAAC algorithm: +/// (in pseudo-code) +/// +/// ```text +/// Input: a, b, c, s[256] // state +/// Output: r[256] // results +/// +/// mix(a,i) = a ^ a << 13 if i = 0 mod 4 +/// a ^ a >> 6 if i = 1 mod 4 +/// a ^ a << 2 if i = 2 mod 4 +/// a ^ a >> 16 if i = 3 mod 4 +/// +/// c = c + 1 +/// b = b + c +/// +/// for i in 0..256 { +/// x = s_[i] +/// a = f(a,i) + s[i+128 mod 256] +/// y = a + b + s[x>>2 mod 256] +/// s[i] = y +/// b = x + s[y>>10 mod 256] +/// r[i] = b +/// } +/// ``` +/// +/// Numbers are generated in blocks of 256. This means the function above only +/// runs once every 256 times you ask for a next random number. In all other +/// circumstances the last element of the results array is returned. +/// +/// ISAAC therefore needs a lot of memory, relative to other non-crypto RNGs. +/// 2 * 256 * 4 = 2 kb to hold the state and results. +/// +/// This implementation uses [`BlockRng`] to implement the [`RngCore`] methods. +/// +/// ## References +/// [^1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number generator*]( +/// http://burtleburtle.net/bob/rand/isaacafa.html) +/// +/// [^2]: Bob Jenkins, [*ISAAC and RC4*]( +/// http://burtleburtle.net/bob/rand/isaac.html) +/// +/// [^3]: Jean-Philippe Aumasson, [*On the pseudo-random generator ISAAC*]( +/// https://eprint.iacr.org/2006/438) +/// +/// [`Hc128Rng`]: ../../rand_hc/struct.Hc128Rng.html +/// [`BlockRng`]: ../../rand_core/block/struct.BlockRng.html +/// [`RngCore`]: ../../rand_core/trait.RngCore.html +#[derive(Clone, Debug)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct IsaacRng(BlockRng); + +impl RngCore for IsaacRng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for IsaacRng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + IsaacRng(BlockRng::::from_seed(seed)) + } + + /// Create an ISAAC random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + fn seed_from_u64(seed: u64) -> Self { + IsaacRng(BlockRng::::seed_from_u64(seed)) + } + + fn from_rng(rng: S) -> Result { + BlockRng::::from_rng(rng).map(|rng| IsaacRng(rng)) + } +} + +impl IsaacRng { + /// Create an ISAAC random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + #[deprecated(since="0.6.0", note="use SeedableRng::seed_from_u64 instead")] + pub fn new_from_u64(seed: u64) -> Self { + Self::seed_from_u64(seed) + } +} + +/// The core of `IsaacRng`, used with `BlockRng`. +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct IsaacCore { + #[cfg_attr(feature="serde1",serde(with="super::isaac_array::isaac_array_serde"))] + mem: [w32; RAND_SIZE], + a: w32, + b: w32, + c: w32, +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for IsaacCore { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "IsaacCore {{}}") + } +} + +impl BlockRngCore for IsaacCore { + type Item = u32; + type Results = IsaacArray; + + /// Refills the output buffer, `results`. See also the pseudocode desciption + /// of the algorithm in the [`IsaacRng`] documentation. + /// + /// Optimisations used (similar to the reference implementation): + /// + /// - The loop is unrolled 4 times, once for every constant of mix(). + /// - The contents of the main loop are moved to a function `rngstep`, to + /// reduce code duplication. + /// - We use local variables for a and b, which helps with optimisations. + /// - We split the main loop in two, one that operates over 0..128 and one + /// over 128..256. This way we can optimise out the addition and modulus + /// from `s[i+128 mod 256]`. + /// - We maintain one index `i` and add `m` or `m2` as base (m2 for the + /// `s[i+128 mod 256]`), relying on the optimizer to turn it into pointer + /// arithmetic. + /// - We fill `results` backwards. The reference implementation reads values + /// from `results` in reverse. We read them in the normal direction, to + /// make `fill_bytes` a memcopy. To maintain compatibility we fill in + /// reverse. + /// + /// [`IsaacRng`]: struct.IsaacRng.html + fn generate(&mut self, results: &mut IsaacArray) { + self.c += w(1); + // abbreviations + let mut a = self.a; + let mut b = self.b + self.c; + const MIDPOINT: usize = RAND_SIZE / 2; + + #[inline] + fn ind(mem:&[w32; RAND_SIZE], v: w32, amount: usize) -> w32 { + let index = (v >> amount).0 as usize % RAND_SIZE; + mem[index] + } + + #[inline] + fn rngstep(mem: &mut [w32; RAND_SIZE], + results: &mut [u32; RAND_SIZE], + mix: w32, + a: &mut w32, + b: &mut w32, + base: usize, + m: usize, + m2: usize) { + let x = mem[base + m]; + *a = mix + mem[base + m2]; + let y = *a + *b + ind(&mem, x, 2); + mem[base + m] = y; + *b = x + ind(&mem, y, 2 + RAND_SIZE_LEN); + results[RAND_SIZE - 1 - base - m] = (*b).0; + } + + let mut m = 0; + let mut m2 = MIDPOINT; + for i in (0..MIDPOINT/4).map(|i| i * 4) { + rngstep(&mut self.mem, results, a ^ (a << 13), &mut a, &mut b, i + 0, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 6 ), &mut a, &mut b, i + 1, m, m2); + rngstep(&mut self.mem, results, a ^ (a << 2 ), &mut a, &mut b, i + 2, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 16), &mut a, &mut b, i + 3, m, m2); + } + + m = MIDPOINT; + m2 = 0; + for i in (0..MIDPOINT/4).map(|i| i * 4) { + rngstep(&mut self.mem, results, a ^ (a << 13), &mut a, &mut b, i + 0, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 6 ), &mut a, &mut b, i + 1, m, m2); + rngstep(&mut self.mem, results, a ^ (a << 2 ), &mut a, &mut b, i + 2, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 16), &mut a, &mut b, i + 3, m, m2); + } + + self.a = a; + self.b = b; + } +} + +impl IsaacCore { + /// Create a new ISAAC random number generator. + /// + /// The author Bob Jenkins describes how to best initialize ISAAC here: + /// + /// The answer is included here just in case: + /// + /// "No, you don't need a full 8192 bits of seed data. Normal key sizes will + /// do fine, and they should have their expected strength (eg a 40-bit key + /// will take as much time to brute force as 40-bit keys usually will). You + /// could fill the remainder with 0, but set the last array element to the + /// length of the key provided (to distinguish keys that differ only by + /// different amounts of 0 padding). You do still need to call `randinit()` + /// to make sure the initial state isn't uniform-looking." + /// "After publishing ISAAC, I wanted to limit the key to half the size of + /// `r[]`, and repeat it twice. That would have made it hard to provide a + /// key that sets the whole internal state to anything convenient. But I'd + /// already published it." + /// + /// And his answer to the question "For my code, would repeating the key + /// over and over to fill 256 integers be a better solution than + /// zero-filling, or would they essentially be the same?": + /// "If the seed is under 32 bytes, they're essentially the same, otherwise + /// repeating the seed would be stronger. randinit() takes a chunk of 32 + /// bytes, mixes it, and combines that with the next 32 bytes, et cetera. + /// Then loops over all the elements the same way a second time." + #[inline] + fn init(mut mem: [w32; RAND_SIZE], rounds: u32) -> Self { + fn mix(a: &mut w32, b: &mut w32, c: &mut w32, d: &mut w32, + e: &mut w32, f: &mut w32, g: &mut w32, h: &mut w32) { + *a ^= *b << 11; *d += *a; *b += *c; + *b ^= *c >> 2; *e += *b; *c += *d; + *c ^= *d << 8; *f += *c; *d += *e; + *d ^= *e >> 16; *g += *d; *e += *f; + *e ^= *f << 10; *h += *e; *f += *g; + *f ^= *g >> 4; *a += *f; *g += *h; + *g ^= *h << 8; *b += *g; *h += *a; + *h ^= *a >> 9; *c += *h; *a += *b; + } + + // These numbers are the result of initializing a...h with the + // fractional part of the golden ratio in binary (0x9e3779b9) + // and applying mix() 4 times. + let mut a = w(0x1367df5a); + let mut b = w(0x95d90059); + let mut c = w(0xc3163e4b); + let mut d = w(0x0f421ad8); + let mut e = w(0xd92a4a78); + let mut f = w(0xa51a3c49); + let mut g = w(0xc4efea1b); + let mut h = w(0x30609119); + + // Normally this should do two passes, to make all of the seed effect + // all of `mem` + for _ in 0..rounds { + for i in (0..RAND_SIZE/8).map(|i| i * 8) { + a += mem[i ]; b += mem[i+1]; + c += mem[i+2]; d += mem[i+3]; + e += mem[i+4]; f += mem[i+5]; + g += mem[i+6]; h += mem[i+7]; + mix(&mut a, &mut b, &mut c, &mut d, + &mut e, &mut f, &mut g, &mut h); + mem[i ] = a; mem[i+1] = b; + mem[i+2] = c; mem[i+3] = d; + mem[i+4] = e; mem[i+5] = f; + mem[i+6] = g; mem[i+7] = h; + } + } + + Self { mem, a: w(0), b: w(0), c: w(0) } + } +} + +impl SeedableRng for IsaacCore { + type Seed = [u8; 32]; + + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_u32 = [0u32; 8]; + le::read_u32_into(&seed, &mut seed_u32); + // Convert the seed to `Wrapping` and zero-extend to `RAND_SIZE`. + let mut seed_extended = [w(0); RAND_SIZE]; + for (x, y) in seed_extended.iter_mut().zip(seed_u32.iter()) { + *x = w(*y); + } + Self::init(seed_extended, 2) + } + + /// Create an ISAAC random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + fn seed_from_u64(seed: u64) -> Self { + let mut key = [w(0); RAND_SIZE]; + key[0] = w(seed as u32); + key[1] = w((seed >> 32) as u32); + // Initialize with only one pass. + // A second pass does not improve the quality here, because all of the + // seed was already available in the first round. + // Not doing the second pass has the small advantage that if + // `seed == 0` this method produces exactly the same state as the + // reference implementation when used unseeded. + Self::init(key, 1) + } + + fn from_rng(mut rng: R) -> Result { + // Custom `from_rng` implementation that fills a seed with the same size + // as the entire state. + let mut seed = [w(0u32); RAND_SIZE]; + unsafe { + let ptr = seed.as_mut_ptr() as *mut u8; + + let slice = slice::from_raw_parts_mut(ptr, RAND_SIZE * 4); + rng.try_fill_bytes(slice)?; + } + for i in seed.iter_mut() { + *i = w(i.0.to_le()); + } + + Ok(Self::init(seed, 2)) + } +} + +#[cfg(test)] +mod test { + use rand_core::{RngCore, SeedableRng}; + use super::IsaacRng; + + #[test] + fn test_isaac_construction() { + // Test that various construction techniques produce a working RNG. + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng1 = IsaacRng::from_seed(seed); + assert_eq!(rng1.next_u32(), 2869442790); + + let mut rng2 = IsaacRng::from_rng(rng1).unwrap(); + assert_eq!(rng2.next_u32(), 3094074039); + } + + #[test] + fn test_isaac_true_values_32() { + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng1 = IsaacRng::from_seed(seed); + let mut results = [0u32; 10]; + for i in results.iter_mut() { *i = rng1.next_u32(); } + let expected = [ + 2558573138, 873787463, 263499565, 2103644246, 3595684709, + 4203127393, 264982119, 2765226902, 2737944514, 3900253796]; + assert_eq!(results, expected); + + let seed = [57,48,0,0, 50,9,1,0, 49,212,0,0, 148,38,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng2 = IsaacRng::from_seed(seed); + // skip forward to the 10000th number + for _ in 0..10000 { rng2.next_u32(); } + + for i in results.iter_mut() { *i = rng2.next_u32(); } + let expected = [ + 3676831399, 3183332890, 2834741178, 3854698763, 2717568474, + 1576568959, 3507990155, 179069555, 141456972, 2478885421]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac_true_values_64() { + // As above, using little-endian versions of above values + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng = IsaacRng::from_seed(seed); + let mut results = [0u64; 5]; + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected = [ + 3752888579798383186, 9035083239252078381,18052294697452424037, + 11876559110374379111, 16751462502657800130]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac_true_bytes() { + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng = IsaacRng::from_seed(seed); + let mut results = [0u8; 32]; + rng.fill_bytes(&mut results); + // Same as first values in test_isaac_true_values as bytes in LE order + let expected = [82, 186, 128, 152, 71, 240, 20, 52, + 45, 175, 180, 15, 86, 16, 99, 125, + 101, 203, 81, 214, 97, 162, 134, 250, + 103, 78, 203, 15, 150, 3, 210, 164]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac_new_uninitialized() { + // Compare the results from initializing `IsaacRng` with + // `seed_from_u64(0)`, to make sure it is the same as the reference + // implementation when used uninitialized. + // Note: We only test the first 16 integers, not the full 256 of the + // first block. + let mut rng = IsaacRng::seed_from_u64(0); + let mut results = [0u32; 16]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected: [u32; 16] = [ + 0x71D71FD2, 0xB54ADAE7, 0xD4788559, 0xC36129FA, + 0x21DC1EA9, 0x3CB879CA, 0xD83B237F, 0xFA3CE5BD, + 0x8D048509, 0xD82E9489, 0xDB452848, 0xCA20E846, + 0x500F972E, 0x0EEFF940, 0x00D6B993, 0xBC12C17F]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac_clone() { + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng1 = IsaacRng::from_seed(seed); + let mut rng2 = rng1.clone(); + for _ in 0..16 { + assert_eq!(rng1.next_u32(), rng2.next_u32()); + } + } + + #[test] + #[cfg(feature="serde1")] + fn test_isaac_serde() { + use bincode; + use std::io::{BufWriter, BufReader}; + + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng = IsaacRng::from_seed(seed); + + let buf: Vec = Vec::new(); + let mut buf = BufWriter::new(buf); + bincode::serialize_into(&mut buf, &rng).expect("Could not serialize"); + + let buf = buf.into_inner().unwrap(); + let mut read = BufReader::new(&buf[..]); + let mut deserialized: IsaacRng = bincode::deserialize_from(&mut read).expect("Could not deserialize"); + + for _ in 0..300 { // more than the 256 buffered results + assert_eq!(rng.next_u32(), deserialized.next_u32()); + } + } +} diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/src/isaac64.rs b/third_party/cargo/vendor/rand_isaac-0.1.1/src/isaac64.rs new file mode 100644 index 0000000..2712762 --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/src/isaac64.rs @@ -0,0 +1,481 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2018 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The ISAAC-64 random number generator. + +use core::{fmt, slice}; +use core::num::Wrapping as w; +use rand_core::{RngCore, SeedableRng, Error, le}; +use rand_core::block::{BlockRngCore, BlockRng64}; +use isaac_array::IsaacArray; + +#[allow(non_camel_case_types)] +type w64 = w; + +const RAND_SIZE_LEN: usize = 8; +const RAND_SIZE: usize = 1 << RAND_SIZE_LEN; + +/// A random number generator that uses ISAAC-64, the 64-bit variant of the +/// ISAAC algorithm. +/// +/// ISAAC stands for "Indirection, Shift, Accumulate, Add, and Count" which are +/// the principal bitwise operations employed. It is the most advanced of a +/// series of array based random number generator designed by Robert Jenkins +/// in 1996[^1]. +/// +/// ISAAC-64 is mostly similar to ISAAC. Because it operates on 64-bit integers +/// instead of 32-bit, it uses twice as much memory to hold its state and +/// results. Also it uses different constants for shifts and indirect indexing, +/// optimized to give good results for 64bit arithmetic. +/// +/// ISAAC-64 is notably fast and produces excellent quality random numbers for +/// non-cryptographic applications. +/// +/// In spite of being designed with cryptographic security in mind, ISAAC hasn't +/// been stringently cryptanalyzed and thus cryptographers do not not +/// consensually trust it to be secure. When looking for a secure RNG, prefer +/// [`Hc128Rng`] instead, which, like ISAAC, is an array-based RNG and one of +/// the stream-ciphers selected the by eSTREAM contest. +/// +/// ## Overview of the ISAAC-64 algorithm: +/// (in pseudo-code) +/// +/// ```text +/// Input: a, b, c, s[256] // state +/// Output: r[256] // results +/// +/// mix(a,i) = !(a ^ a << 21) if i = 0 mod 4 +/// a ^ a >> 5 if i = 1 mod 4 +/// a ^ a << 12 if i = 2 mod 4 +/// a ^ a >> 33 if i = 3 mod 4 +/// +/// c = c + 1 +/// b = b + c +/// +/// for i in 0..256 { +/// x = s_[i] +/// a = mix(a,i) + s[i+128 mod 256] +/// y = a + b + s[x>>3 mod 256] +/// s[i] = y +/// b = x + s[y>>11 mod 256] +/// r[i] = b +/// } +/// ``` +/// +/// This implementation uses [`BlockRng64`] to implement the [`RngCore`] methods. +/// +/// See for more information the documentation of [`IsaacRng`]. +/// +/// [^1]: Bob Jenkins, [*ISAAC and RC4*]( +/// http://burtleburtle.net/bob/rand/isaac.html) +/// +/// [`IsaacRng`]: ../isaac/struct.IsaacRng.html +/// [`Hc128Rng`]: ../../rand_hc/struct.Hc128Rng.html +/// [`BlockRng64`]: ../../rand_core/block/struct.BlockRng64.html +/// [`RngCore`]: ../../rand_core/trait.RngCore.html +#[derive(Clone, Debug)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct Isaac64Rng(BlockRng64); + +impl RngCore for Isaac64Rng { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + self.0.next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + self.0.next_u64() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + self.0.fill_bytes(dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.0.try_fill_bytes(dest) + } +} + +impl SeedableRng for Isaac64Rng { + type Seed = ::Seed; + + fn from_seed(seed: Self::Seed) -> Self { + Isaac64Rng(BlockRng64::::from_seed(seed)) + } + + /// Create an ISAAC random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + fn seed_from_u64(seed: u64) -> Self { + Isaac64Rng(BlockRng64::::seed_from_u64(seed)) + } + + fn from_rng(rng: S) -> Result { + BlockRng64::::from_rng(rng).map(|rng| Isaac64Rng(rng)) + } +} + +impl Isaac64Rng { + /// Create an ISAAC-64 random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + #[deprecated(since="0.6.0", note="use SeedableRng::seed_from_u64 instead")] + pub fn new_from_u64(seed: u64) -> Self { + Self::seed_from_u64(seed) + } +} + +/// The core of `Isaac64Rng`, used with `BlockRng`. +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct Isaac64Core { + #[cfg_attr(feature="serde1",serde(with="super::isaac_array::isaac_array_serde"))] + mem: [w64; RAND_SIZE], + a: w64, + b: w64, + c: w64, +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for Isaac64Core { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Isaac64Core {{}}") + } +} + +impl BlockRngCore for Isaac64Core { + type Item = u64; + type Results = IsaacArray; + + /// Refills the output buffer, `results`. See also the pseudocode desciption + /// of the algorithm in the [`Isaac64Rng`] documentation. + /// + /// Optimisations used (similar to the reference implementation): + /// + /// - The loop is unrolled 4 times, once for every constant of mix(). + /// - The contents of the main loop are moved to a function `rngstep`, to + /// reduce code duplication. + /// - We use local variables for a and b, which helps with optimisations. + /// - We split the main loop in two, one that operates over 0..128 and one + /// over 128..256. This way we can optimise out the addition and modulus + /// from `s[i+128 mod 256]`. + /// - We maintain one index `i` and add `m` or `m2` as base (m2 for the + /// `s[i+128 mod 256]`), relying on the optimizer to turn it into pointer + /// arithmetic. + /// - We fill `results` backwards. The reference implementation reads values + /// from `results` in reverse. We read them in the normal direction, to + /// make `fill_bytes` a memcopy. To maintain compatibility we fill in + /// reverse. + /// + /// [`Isaac64Rng`]: struct.Isaac64Rng.html + fn generate(&mut self, results: &mut IsaacArray) { + self.c += w(1); + // abbreviations + let mut a = self.a; + let mut b = self.b + self.c; + const MIDPOINT: usize = RAND_SIZE / 2; + + #[inline] + fn ind(mem:&[w64; RAND_SIZE], v: w64, amount: usize) -> w64 { + let index = (v >> amount).0 as usize % RAND_SIZE; + mem[index] + } + + #[inline] + fn rngstep(mem: &mut [w64; RAND_SIZE], + results: &mut [u64; RAND_SIZE], + mix: w64, + a: &mut w64, + b: &mut w64, + base: usize, + m: usize, + m2: usize) { + let x = mem[base + m]; + *a = mix + mem[base + m2]; + let y = *a + *b + ind(&mem, x, 3); + mem[base + m] = y; + *b = x + ind(&mem, y, 3 + RAND_SIZE_LEN); + results[RAND_SIZE - 1 - base - m] = (*b).0; + } + + let mut m = 0; + let mut m2 = MIDPOINT; + for i in (0..MIDPOINT/4).map(|i| i * 4) { + rngstep(&mut self.mem, results, !(a ^ (a << 21)), &mut a, &mut b, i + 0, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 5 ), &mut a, &mut b, i + 1, m, m2); + rngstep(&mut self.mem, results, a ^ (a << 12), &mut a, &mut b, i + 2, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 33), &mut a, &mut b, i + 3, m, m2); + } + + m = MIDPOINT; + m2 = 0; + for i in (0..MIDPOINT/4).map(|i| i * 4) { + rngstep(&mut self.mem, results, !(a ^ (a << 21)), &mut a, &mut b, i + 0, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 5 ), &mut a, &mut b, i + 1, m, m2); + rngstep(&mut self.mem, results, a ^ (a << 12), &mut a, &mut b, i + 2, m, m2); + rngstep(&mut self.mem, results, a ^ (a >> 33), &mut a, &mut b, i + 3, m, m2); + } + + self.a = a; + self.b = b; + } +} + +impl Isaac64Core { + /// Create a new ISAAC-64 random number generator. + fn init(mut mem: [w64; RAND_SIZE], rounds: u32) -> Self { + fn mix(a: &mut w64, b: &mut w64, c: &mut w64, d: &mut w64, + e: &mut w64, f: &mut w64, g: &mut w64, h: &mut w64) { + *a -= *e; *f ^= *h >> 9; *h += *a; + *b -= *f; *g ^= *a << 9; *a += *b; + *c -= *g; *h ^= *b >> 23; *b += *c; + *d -= *h; *a ^= *c << 15; *c += *d; + *e -= *a; *b ^= *d >> 14; *d += *e; + *f -= *b; *c ^= *e << 20; *e += *f; + *g -= *c; *d ^= *f >> 17; *f += *g; + *h -= *d; *e ^= *g << 14; *g += *h; + } + + // These numbers are the result of initializing a...h with the + // fractional part of the golden ratio in binary (0x9e3779b97f4a7c13) + // and applying mix() 4 times. + let mut a = w(0x647c4677a2884b7c); + let mut b = w(0xb9f8b322c73ac862); + let mut c = w(0x8c0ea5053d4712a0); + let mut d = w(0xb29b2e824a595524); + let mut e = w(0x82f053db8355e0ce); + let mut f = w(0x48fe4a0fa5a09315); + let mut g = w(0xae985bf2cbfc89ed); + let mut h = w(0x98f5704f6c44c0ab); + + // Normally this should do two passes, to make all of the seed effect + // all of `mem` + for _ in 0..rounds { + for i in (0..RAND_SIZE/8).map(|i| i * 8) { + a += mem[i ]; b += mem[i+1]; + c += mem[i+2]; d += mem[i+3]; + e += mem[i+4]; f += mem[i+5]; + g += mem[i+6]; h += mem[i+7]; + mix(&mut a, &mut b, &mut c, &mut d, + &mut e, &mut f, &mut g, &mut h); + mem[i ] = a; mem[i+1] = b; + mem[i+2] = c; mem[i+3] = d; + mem[i+4] = e; mem[i+5] = f; + mem[i+6] = g; mem[i+7] = h; + } + } + + Self { mem, a: w(0), b: w(0), c: w(0) } + } + + /// Create an ISAAC-64 random number generator using an `u64` as seed. + /// If `seed == 0` this will produce the same stream of random numbers as + /// the reference implementation when used unseeded. + #[deprecated(since="0.6.0", note="use SeedableRng::seed_from_u64 instead")] + pub fn new_from_u64(seed: u64) -> Self { + Self::seed_from_u64(seed) + } +} + +impl SeedableRng for Isaac64Core { + type Seed = [u8; 32]; + + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_u64 = [0u64; 4]; + le::read_u64_into(&seed, &mut seed_u64); + // Convert the seed to `Wrapping` and zero-extend to `RAND_SIZE`. + let mut seed_extended = [w(0); RAND_SIZE]; + for (x, y) in seed_extended.iter_mut().zip(seed_u64.iter()) { + *x = w(*y); + } + Self::init(seed_extended, 2) + } + + fn seed_from_u64(seed: u64) -> Self { + let mut key = [w(0); RAND_SIZE]; + key[0] = w(seed); + // Initialize with only one pass. + // A second pass does not improve the quality here, because all of the + // seed was already available in the first round. + // Not doing the second pass has the small advantage that if + // `seed == 0` this method produces exactly the same state as the + // reference implementation when used unseeded. + Self::init(key, 1) + } + + fn from_rng(mut rng: R) -> Result { + // Custom `from_rng` implementation that fills a seed with the same size + // as the entire state. + let mut seed = [w(0u64); RAND_SIZE]; + unsafe { + let ptr = seed.as_mut_ptr() as *mut u8; + let slice = slice::from_raw_parts_mut(ptr, RAND_SIZE * 8); + rng.try_fill_bytes(slice)?; + } + for i in seed.iter_mut() { + *i = w(i.0.to_le()); + } + + Ok(Self::init(seed, 2)) + } +} + +#[cfg(test)] +mod test { + use rand_core::{RngCore, SeedableRng}; + use super::Isaac64Rng; + + #[test] + fn test_isaac64_construction() { + // Test that various construction techniques produce a working RNG. + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng1 = Isaac64Rng::from_seed(seed); + assert_eq!(rng1.next_u64(), 14964555543728284049); + + let mut rng2 = Isaac64Rng::from_rng(rng1).unwrap(); + assert_eq!(rng2.next_u64(), 919595328260451758); + } + + #[test] + fn test_isaac64_true_values_64() { + let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0, + 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0]; + let mut rng1 = Isaac64Rng::from_seed(seed); + let mut results = [0u64; 10]; + for i in results.iter_mut() { *i = rng1.next_u64(); } + let expected = [ + 15071495833797886820, 7720185633435529318, + 10836773366498097981, 5414053799617603544, + 12890513357046278984, 17001051845652595546, + 9240803642279356310, 12558996012687158051, + 14673053937227185542, 1677046725350116783]; + assert_eq!(results, expected); + + let seed = [57,48,0,0, 0,0,0,0, 50,9,1,0, 0,0,0,0, + 49,212,0,0, 0,0,0,0, 148,38,0,0, 0,0,0,0]; + let mut rng2 = Isaac64Rng::from_seed(seed); + // skip forward to the 10000th number + for _ in 0..10000 { rng2.next_u64(); } + + for i in results.iter_mut() { *i = rng2.next_u64(); } + let expected = [ + 18143823860592706164, 8491801882678285927, 2699425367717515619, + 17196852593171130876, 2606123525235546165, 15790932315217671084, + 596345674630742204, 9947027391921273664, 11788097613744130851, + 10391409374914919106]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac64_true_values_32() { + let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0, + 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0]; + let mut rng = Isaac64Rng::from_seed(seed); + let mut results = [0u32; 12]; + for i in results.iter_mut() { *i = rng.next_u32(); } + // Subset of above values, as an LE u32 sequence + let expected = [ + 3477963620, 3509106075, + 687845478, 1797495790, + 227048253, 2523132918, + 4044335064, 1260557630, + 4079741768, 3001306521, + 69157722, 3958365844]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac64_true_values_mixed() { + let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0, + 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0]; + let mut rng = Isaac64Rng::from_seed(seed); + // Test alternating between `next_u64` and `next_u32` works as expected. + // Values are the same as `test_isaac64_true_values` and + // `test_isaac64_true_values_32`. + assert_eq!(rng.next_u64(), 15071495833797886820); + assert_eq!(rng.next_u32(), 687845478); + assert_eq!(rng.next_u32(), 1797495790); + assert_eq!(rng.next_u64(), 10836773366498097981); + assert_eq!(rng.next_u32(), 4044335064); + // Skip one u32 + assert_eq!(rng.next_u64(), 12890513357046278984); + assert_eq!(rng.next_u32(), 69157722); + } + + #[test] + fn test_isaac64_true_bytes() { + let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0, + 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0]; + let mut rng = Isaac64Rng::from_seed(seed); + let mut results = [0u8; 32]; + rng.fill_bytes(&mut results); + // Same as first values in test_isaac64_true_values as bytes in LE order + let expected = [100, 131, 77, 207, 155, 181, 40, 209, + 102, 176, 255, 40, 238, 155, 35, 107, + 61, 123, 136, 13, 246, 243, 99, 150, + 216, 167, 15, 241, 62, 149, 34, 75]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac64_new_uninitialized() { + // Compare the results from initializing `IsaacRng` with + // `seed_from_u64(0)`, to make sure it is the same as the reference + // implementation when used uninitialized. + // Note: We only test the first 16 integers, not the full 256 of the + // first block. + let mut rng = Isaac64Rng::seed_from_u64(0); + let mut results = [0u64; 16]; + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected: [u64; 16] = [ + 0xF67DFBA498E4937C, 0x84A5066A9204F380, 0xFEE34BD5F5514DBB, + 0x4D1664739B8F80D6, 0x8607459AB52A14AA, 0x0E78BC5A98529E49, + 0xFE5332822AD13777, 0x556C27525E33D01A, 0x08643CA615F3149F, + 0xD0771FAF3CB04714, 0x30E86F68A37B008D, 0x3074EBC0488A3ADF, + 0x270645EA7A2790BC, 0x5601A0A8D3763C6A, 0x2F83071F53F325DD, + 0xB9090F3D42D2D2EA]; + assert_eq!(results, expected); + } + + #[test] + fn test_isaac64_clone() { + let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0, + 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0]; + let mut rng1 = Isaac64Rng::from_seed(seed); + let mut rng2 = rng1.clone(); + for _ in 0..16 { + assert_eq!(rng1.next_u64(), rng2.next_u64()); + } + } + + #[test] + #[cfg(feature="serde1")] + fn test_isaac64_serde() { + use bincode; + use std::io::{BufWriter, BufReader}; + + let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, + 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng = Isaac64Rng::from_seed(seed); + + let buf: Vec = Vec::new(); + let mut buf = BufWriter::new(buf); + bincode::serialize_into(&mut buf, &rng).expect("Could not serialize"); + + let buf = buf.into_inner().unwrap(); + let mut read = BufReader::new(&buf[..]); + let mut deserialized: Isaac64Rng = bincode::deserialize_from(&mut read).expect("Could not deserialize"); + + for _ in 0..300 { // more than the 256 buffered results + assert_eq!(rng.next_u64(), deserialized.next_u64()); + } + } +} diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/src/isaac_array.rs b/third_party/cargo/vendor/rand_isaac-0.1.1/src/isaac_array.rs new file mode 100644 index 0000000..0fa6147 --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/src/isaac_array.rs @@ -0,0 +1,136 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2017-2018 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! ISAAC helper functions for 256-element arrays. + +// Terrible workaround because arrays with more than 32 elements do not +// implement `AsRef`, `Default`, `Serialize`, `Deserialize`, or any other +// traits for that matter. + +#[cfg(feature="serde1")] use serde::{Serialize, Deserialize}; + +const RAND_SIZE_LEN: usize = 8; +const RAND_SIZE: usize = 1 << RAND_SIZE_LEN; + + +#[derive(Copy, Clone)] +#[allow(missing_debug_implementations)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct IsaacArray { + #[cfg_attr(feature="serde1",serde(with="isaac_array_serde"))] + #[cfg_attr(feature="serde1", serde(bound( + serialize = "T: Serialize", + deserialize = "T: Deserialize<'de> + Copy + Default")))] + inner: [T; RAND_SIZE] +} + +impl ::core::convert::AsRef<[T]> for IsaacArray { + #[inline(always)] + fn as_ref(&self) -> &[T] { + &self.inner[..] + } +} + +impl ::core::convert::AsMut<[T]> for IsaacArray { + #[inline(always)] + fn as_mut(&mut self) -> &mut [T] { + &mut self.inner[..] + } +} + +impl ::core::ops::Deref for IsaacArray { + type Target = [T; RAND_SIZE]; + #[inline(always)] + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl ::core::ops::DerefMut for IsaacArray { + #[inline(always)] + fn deref_mut(&mut self) -> &mut [T; RAND_SIZE] { + &mut self.inner + } +} + +impl ::core::default::Default for IsaacArray where T: Copy + Default { + fn default() -> IsaacArray { + IsaacArray { inner: [T::default(); RAND_SIZE] } + } +} + + +#[cfg(feature="serde1")] +pub(super) mod isaac_array_serde { + const RAND_SIZE_LEN: usize = 8; + const RAND_SIZE: usize = 1 << RAND_SIZE_LEN; + + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + use serde::de::{Visitor,SeqAccess}; + use serde::de; + + use core::fmt; + + pub fn serialize(arr: &[T;RAND_SIZE], ser: S) -> Result + where + T: Serialize, + S: Serializer + { + use serde::ser::SerializeTuple; + + let mut seq = ser.serialize_tuple(RAND_SIZE)?; + + for e in arr.iter() { + seq.serialize_element(&e)?; + } + + seq.end() + } + + #[inline] + pub fn deserialize<'de, T, D>(de: D) -> Result<[T;RAND_SIZE], D::Error> + where + T: Deserialize<'de>+Default+Copy, + D: Deserializer<'de>, + { + use core::marker::PhantomData; + struct ArrayVisitor { + _pd: PhantomData, + }; + impl<'de,T> Visitor<'de> for ArrayVisitor + where + T: Deserialize<'de>+Default+Copy + { + type Value = [T; RAND_SIZE]; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Isaac state array") + } + + #[inline] + fn visit_seq(self, mut seq: A) -> Result<[T; RAND_SIZE], A::Error> + where + A: SeqAccess<'de>, + { + let mut out = [Default::default();RAND_SIZE]; + + for i in 0..RAND_SIZE { + match seq.next_element()? { + Some(val) => out[i] = val, + None => return Err(de::Error::invalid_length(i, &self)), + }; + } + + Ok(out) + } + } + + de.deserialize_tuple(RAND_SIZE, ArrayVisitor{_pd: PhantomData}) + } +} diff --git a/third_party/cargo/vendor/rand_isaac-0.1.1/src/lib.rs b/third_party/cargo/vendor/rand_isaac-0.1.1/src/lib.rs new file mode 100644 index 0000000..ec82d8e --- /dev/null +++ b/third_party/cargo/vendor/rand_isaac-0.1.1/src/lib.rs @@ -0,0 +1,36 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The ISAAC and ISAAC-64 random number generators. + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] + +#![cfg_attr(not(all(feature="serde1", test)), no_std)] + +extern crate rand_core; + +#[cfg(feature="serde1")] extern crate serde; +#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive; + +// To test serialization we need bincode and the standard library +#[cfg(all(feature="serde1", test))] extern crate bincode; +#[cfg(all(feature="serde1", test))] extern crate std as core; + +pub mod isaac; +pub mod isaac64; + +mod isaac_array; + +pub use self::isaac::IsaacRng; +pub use self::isaac64::Isaac64Rng; diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/.cargo-checksum.json b/third_party/cargo/vendor/rand_jitter-0.1.4/.cargo-checksum.json new file mode 100644 index 0000000..bf96336 --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"dd1714225c7cca47c349ddbca2b5ab8a546e0c7b1c52cf05cafca1e05c48f2b0","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"d524ddfe62a9ca58ff86d9ad37532081bae35bfcca2a1e68ca0ffaf0e981d477","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"7b685b3204fc1bb9a09b40eb586bf55358f076b276866c1c2afb20f57e8357b2","benches/mod.rs":"caea9aa8c327d4af18eeabe798cf7919d5f64225c3e5f4685814592a1595b9bf","src/dummy_log.rs":"4e26589c18de568b7da7f0ccc9b77bb430961739a6510c2b043a43dee300c6fa","src/error.rs":"e632a67e30528bed8c2a74b04b04e4e67f6c184d21234d74cc28f5f292e47666","src/lib.rs":"6655eb8d1fba653dda788c885ae380b017e6482baa6e2885019d33dbd829b0e6","src/platform.rs":"8c7b75567a28391176de17a3df2a8c6b3517f2c1f044b792db50de19844e9660","tests/mod.rs":"f3f99c64b250b2ddea43e724c47497de3d68cbaf05a0a8a255d360861cd979ec"},"package":"1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/BUILD b/third_party/cargo/vendor/rand_jitter-0.1.4/BUILD new file mode 100644 index 0000000..ad86408 --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "MIT OR Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "mod" with type "bench" omitted +# Unsupported target "mod" with type "test" omitted + +rust_library( + name = "rand_jitter", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/rand_core-0.4.2:rand_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.4", + crate_features = [ + "rand_core", + "std", + ], +) + diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/CHANGELOG.md b/third_party/cargo/vendor/rand_jitter-0.1.4/CHANGELOG.md new file mode 100644 index 0000000..bbb21dc --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.4] - 2019-05-02 +- Change error conversion code to partially fix #738 + +## [0.1.3] - 2019-02-05 +- Use libc in `no_std` mode to fix #723 + +## [0.1.2] - 2019-01-31 +- Fix for older rustc compilers on Windows (#722) + +## [0.1.1] - 2019-01-29 +- Fix for older rustc compilers on Mac OSX / iOS (#720) +- Misc. doc fixes + +## [0.1.0] - 2019-01-24 +Initial release. diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/COPYRIGHT b/third_party/cargo/vendor/rand_jitter-0.1.4/COPYRIGHT new file mode 100644 index 0000000..468d907 --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/COPYRIGHT @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/Cargo.toml b/third_party/cargo/vendor/rand_jitter-0.1.4/Cargo.toml new file mode 100644 index 0000000..387b807 --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/Cargo.toml @@ -0,0 +1,42 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand_jitter" +version = "0.1.4" +authors = ["The Rand Project Developers"] +description = "Random number generator based on timing jitter" +documentation = "https://docs.rs/rand_jitter" +readme = "README.md" +keywords = ["random", "rng", "os"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-random/rand" +[dependencies.log] +version = "0.4" +optional = true + +[dependencies.rand_core] +version = "0.4" + +[features] +std = ["rand_core/std"] +[target."cfg(any(target_os = \"macos\", target_os = \"ios\"))".dependencies.libc] +version = "0.2" +default_features = false +[target."cfg(target_os = \"windows\")".dependencies.winapi] +version = "0.3" +features = ["profileapi"] +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/LICENSE-APACHE b/third_party/cargo/vendor/rand_jitter-0.1.4/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/LICENSE-MIT b/third_party/cargo/vendor/rand_jitter-0.1.4/LICENSE-MIT new file mode 100644 index 0000000..d93b5ba --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright 2018 Developers of the Rand project +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/README.md b/third_party/cargo/vendor/rand_jitter-0.1.4/README.md new file mode 100644 index 0000000..8e0805f --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/README.md @@ -0,0 +1,104 @@ +# rand_jitter +[![Build Status](https://travis-ci.org/rust-random/rand.svg?branch=master)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Latest version](https://img.shields.io/crates/v/rand_jitter.svg)](https://crates.io/crates/rand_jitter) +[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_jitter) +[![API](https://docs.rs/rand_jitter/badge.svg)](https://docs.rs/rand_jitter) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) + +Non-physical true random number generator based on timing jitter. + +This crate depends on [rand_core](https://crates.io/crates/rand_core) and is +part of the [Rand project](https://github.com/rust-random/rand). + +This crate aims to support all of Rust's `std` platforms with a system-provided +entropy source. Unlike other Rand crates, this crate does not support `no_std` +(handling this gracefully is a current discussion topic). + +Links: + +- [API documentation (master)](https://rust-random.github.io/rand/rand_jitter) +- [API documentation (docs.rs)](https://docs.rs/rand_jitter) +- [Changelog](CHANGELOG.md) + +## Features + +This crate has optional `std` support which is *disabled by default*; +this feature is required to provide the `JitterRng::new` function; +without `std` support a timer must be supplied via `JitterRng::new_with_timer`. + +## Quality testing + +`JitterRng::new()` has build-in, but limited, quality testing, however +before using `JitterRng` on untested hardware, or after changes that could +effect how the code is optimized (such as a new LLVM version), it is +recommend to run the much more stringent +[NIST SP 800-90B Entropy Estimation Suite](https://github.com/usnistgov/SP800-90B_EntropyAssessment). + +Use the following code using `timer_stats` to collect the data: + +```rust +use rand_jitter::JitterRng; + +use std::error::Error; +use std::fs::File; +use std::io::Write; + +fn main() -> Result<(), Box> { + let mut rng = JitterRng::new()?; + + // 1_000_000 results are required for the + // NIST SP 800-90B Entropy Estimation Suite + const ROUNDS: usize = 1_000_000; + let mut deltas_variable: Vec = Vec::with_capacity(ROUNDS); + let mut deltas_minimal: Vec = Vec::with_capacity(ROUNDS); + + for _ in 0..ROUNDS { + deltas_variable.push(rng.timer_stats(true) as u8); + deltas_minimal.push(rng.timer_stats(false) as u8); + } + + // Write out after the statistics collection loop, to not disturb the + // test results. + File::create("jitter_rng_var.bin")?.write(&deltas_variable)?; + File::create("jitter_rng_min.bin")?.write(&deltas_minimal)?; + Ok(()) +} +``` + +This will produce two files: `jitter_rng_var.bin` and `jitter_rng_min.bin`. +Run the Entropy Estimation Suite in three configurations, as outlined below. +Every run has two steps. One step to produce an estimation, another to +validate the estimation. + +1. Estimate the expected amount of entropy that is at least available with + each round of the entropy collector. This number should be greater than + the amount estimated with `64 / test_timer()`. + ```sh + python noniid_main.py -v jitter_rng_var.bin 8 + restart.py -v jitter_rng_var.bin 8 + ``` +2. Estimate the expected amount of entropy that is available in the last 4 + bits of the timer delta after running noice sources. Note that a value of + `3.70` is the minimum estimated entropy for true randomness. + ```sh + python noniid_main.py -v -u 4 jitter_rng_var.bin 4 + restart.py -v -u 4 jitter_rng_var.bin 4 + ``` +3. Estimate the expected amount of entropy that is available to the entropy + collector if both noise sources only run their minimal number of times. + This measures the absolute worst-case, and gives a lower bound for the + available entropy. + ```sh + python noniid_main.py -v -u 4 jitter_rng_min.bin 4 + restart.py -v -u 4 jitter_rng_min.bin 4 + ``` + +## License + +`rand_jitter` is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/benches/mod.rs b/third_party/cargo/vendor/rand_jitter-0.1.4/benches/mod.rs new file mode 100644 index 0000000..23b3447 --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/benches/mod.rs @@ -0,0 +1,18 @@ +#![feature(test)] +extern crate test; +extern crate rand_jitter; + +use test::Bencher; +use rand_jitter::rand_core::RngCore; + +#[bench] +fn bench_add_two(b: &mut Bencher) { + let mut rng = rand_jitter::JitterRng::new().unwrap(); + let mut buf = [0u8; 1024]; + b.iter(|| { + rng.fill_bytes(&mut buf[..]); + test::black_box(&buf); + }); + b.bytes = buf.len() as u64; +} + diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/src/dummy_log.rs b/third_party/cargo/vendor/rand_jitter-0.1.4/src/dummy_log.rs new file mode 100644 index 0000000..ccfe4ba --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/src/dummy_log.rs @@ -0,0 +1,10 @@ +#[allow(unused)] +macro_rules! trace { ($($x:tt)*) => () } +#[allow(unused)] +macro_rules! debug { ($($x:tt)*) => () } +#[allow(unused)] +macro_rules! info { ($($x:tt)*) => () } +#[allow(unused)] +macro_rules! warn { ($($x:tt)*) => () } +#[allow(unused)] +macro_rules! error { ($($x:tt)*) => () } diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/src/error.rs b/third_party/cargo/vendor/rand_jitter-0.1.4/src/error.rs new file mode 100644 index 0000000..a3483e8 --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/src/error.rs @@ -0,0 +1,70 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2015 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use rand_core::{Error, ErrorKind}; +use core::fmt; + +/// An error that can occur when [`JitterRng::test_timer`] fails. +/// +/// [`JitterRng::test_timer`]: crate::JitterRng::test_timer +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum TimerError { + /// No timer available. + NoTimer, + /// Timer too coarse to use as an entropy source. + CoarseTimer, + /// Timer is not monotonically increasing. + NotMonotonic, + /// Variations of deltas of time too small. + TinyVariantions, + /// Too many stuck results (indicating no added entropy). + TooManyStuck, + #[doc(hidden)] + __Nonexhaustive, +} + +impl TimerError { + fn description(&self) -> &'static str { + match *self { + TimerError::NoTimer => "no timer available", + TimerError::CoarseTimer => "coarse timer", + TimerError::NotMonotonic => "timer not monotonic", + TimerError::TinyVariantions => "time delta variations too small", + TimerError::TooManyStuck => "too many stuck results", + TimerError::__Nonexhaustive => unreachable!(), + } + } +} + +impl fmt::Display for TimerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.description()) + } +} + +#[cfg(feature = "std")] +impl ::std::error::Error for TimerError { + fn description(&self) -> &str { + self.description() + } +} + +impl From for Error { + fn from(err: TimerError) -> Error { + // Timer check is already quite permissive of failures so we don't + // expect false-positive failures, i.e. any error is irrecoverable. + #[cfg(feature = "std")] { + Error::with_cause(ErrorKind::Unavailable, "timer jitter failed basic quality tests", err) + } + #[cfg(not(feature = "std"))] { + Error::new(ErrorKind::Unavailable, "timer jitter failed basic quality tests") + } + } +} + diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/src/lib.rs b/third_party/cargo/vendor/rand_jitter-0.1.4/src/lib.rs new file mode 100644 index 0000000..338a6b9 --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/src/lib.rs @@ -0,0 +1,718 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// Based on jitterentropy-library, http://www.chronox.de/jent.html. +// Copyright Stephan Mueller , 2014 - 2017. +// +// With permission from Stephan Mueller to relicense the Rust translation under +// the MIT license. + +//! Non-physical true random number generator based on timing jitter. +//! +//! This is a true random number generator, as opposed to pseudo-random +//! generators. Random numbers generated by `JitterRng` can be seen as fresh +//! entropy. A consequence is that it is orders of magnitude slower than `OsRng` +//! and PRNGs (about 103..106 slower). +//! +//! There are very few situations where using this RNG is appropriate. Only very +//! few applications require true entropy. A normal PRNG can be statistically +//! indistinguishable, and a cryptographic PRNG should also be as impossible to +//! predict. +//! +//! Use of `JitterRng` is recommended for initializing cryptographic PRNGs when +//! `OsRng` is not available. +//! +//! `JitterRng` can be used without the standard library, but not conveniently, +//! you must provide a high-precision timer and carefully have to follow the +//! instructions of [`JitterRng::new_with_timer`]. +//! +//! This implementation is based on [Jitterentropy] version 2.1.0. +//! +//! Note: There is no accurate timer available on WASM platforms, to help +//! prevent fingerprinting or timing side-channel attacks. Therefore +//! [`JitterRng::new()`] is not available on WASM. It is also unavailable +//! with disabled `std` feature. +//! +//! [Jitterentropy]: http://www.chronox.de/jent.html + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] + +// Note: the C implementation of `Jitterentropy` relies on being compiled +// without optimizations. This implementation goes through lengths to make the +// compiler not optimize out code which does influence timing jitter, but is +// technically dead code. +#![no_std] +pub extern crate rand_core; +#[cfg(feature = "std")] +extern crate std; +#[cfg(feature = "log")] +#[macro_use] extern crate log; +#[cfg(any(target_os = "macos", target_os = "ios"))] +extern crate libc; +#[cfg(target_os = "windows")] +extern crate winapi; + + +#[cfg(not(feature = "log"))] +#[macro_use] mod dummy_log; +#[cfg(feature = "std")] +mod platform; +mod error; + +use rand_core::{RngCore, CryptoRng, Error, impls}; +pub use error::TimerError; + +use core::{fmt, mem, ptr}; +#[cfg(feature = "std")] +use std::sync::atomic::{AtomicUsize, Ordering}; +#[cfg(feature = "std")] +#[allow(deprecated)] // Required for compatibility with Rust < 1.24. +use std::sync::atomic::ATOMIC_USIZE_INIT; + +const MEMORY_BLOCKS: usize = 64; +const MEMORY_BLOCKSIZE: usize = 32; +const MEMORY_SIZE: usize = MEMORY_BLOCKS * MEMORY_BLOCKSIZE; + +/// A true random number generator based on jitter in the CPU execution time, +/// and jitter in memory access time. +pub struct JitterRng { + data: u64, // Actual random number + // Number of rounds to run the entropy collector per 64 bits + rounds: u8, + // Timer used by `measure_jitter` + timer: fn() -> u64, + // Memory for the Memory Access noise source + mem_prev_index: u16, + // Make `next_u32` not waste 32 bits + data_half_used: bool, +} + +// Note: `JitterRng` maintains a small 64-bit entropy pool. With every +// `generate` 64 new bits should be integrated in the pool. If a round of +// `generate` were to collect less than the expected 64 bit, then the returned +// value, and the new state of the entropy pool, would be in some way related to +// the initial state. It is therefore better if the initial state of the entropy +// pool is different on each call to `generate`. This has a few implications: +// - `generate` should be called once before using `JitterRng` to produce the +// first usable value (this is done by default in `new`); +// - We do not zero the entropy pool after generating a result. The reference +// implementation also does not support zeroing, but recommends generating a +// new value without using it if you want to protect a previously generated +// 'secret' value from someone inspecting the memory; +// - Implementing `Clone` seems acceptable, as it would not cause the systematic +// bias a constant might cause. Only instead of one value that could be +// potentially related to the same initial state, there are now two. + +// Entropy collector state. +// These values are not necessary to preserve across runs. +struct EcState { + // Previous time stamp to determine the timer delta + prev_time: u64, + // Deltas used for the stuck test + last_delta: i32, + last_delta2: i32, + // Memory for the Memory Access noise source + mem: [u8; MEMORY_SIZE], +} + +impl EcState { + // Stuck test by checking the: + // - 1st derivation of the jitter measurement (time delta) + // - 2nd derivation of the jitter measurement (delta of time deltas) + // - 3rd derivation of the jitter measurement (delta of delta of time + // deltas) + // + // All values must always be non-zero. + // This test is a heuristic to see whether the last measurement holds + // entropy. + fn stuck(&mut self, current_delta: i32) -> bool { + let delta2 = self.last_delta - current_delta; + let delta3 = delta2 - self.last_delta2; + + self.last_delta = current_delta; + self.last_delta2 = delta2; + + current_delta == 0 || delta2 == 0 || delta3 == 0 + } +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for JitterRng { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "JitterRng {{}}") + } +} + +impl Clone for JitterRng { + fn clone(&self) -> JitterRng { + JitterRng { + data: self.data, + rounds: self.rounds, + timer: self.timer, + mem_prev_index: self.mem_prev_index, + // The 32 bits that may still be unused from the previous round are + // for the original to use, not for the clone. + data_half_used: false, + } + } +} + +// Initialise to zero; must be positive +#[cfg(all(feature = "std", not(target_arch = "wasm32")))] +#[allow(deprecated)] +static JITTER_ROUNDS: AtomicUsize = ATOMIC_USIZE_INIT; + +impl JitterRng { + /// Create a new `JitterRng`. Makes use of `std::time` for a timer, or a + /// platform-specific function with higher accuracy if necessary and + /// available. + /// + /// During initialization CPU execution timing jitter is measured a few + /// hundred times. If this does not pass basic quality tests, an error is + /// returned. The test result is cached to make subsequent calls faster. + #[cfg(all(feature = "std", not(target_arch = "wasm32")))] + pub fn new() -> Result { + if cfg!(target_arch = "wasm32") { + return Err(TimerError::NoTimer); + } + let mut state = JitterRng::new_with_timer(platform::get_nstime); + let mut rounds = JITTER_ROUNDS.load(Ordering::Relaxed) as u8; + if rounds == 0 { + // No result yet: run test. + // This allows the timer test to run multiple times; we don't care. + rounds = state.test_timer()?; + JITTER_ROUNDS.store(rounds as usize, Ordering::Relaxed); + info!("JitterRng: using {} rounds per u64 output", rounds); + } + state.set_rounds(rounds); + + // Fill `data` with a non-zero value. + state.gen_entropy(); + Ok(state) + } + + /// Create a new `JitterRng`. + /// A custom timer can be supplied, making it possible to use `JitterRng` in + /// `no_std` environments. + /// + /// The timer must have nanosecond precision. + /// + /// This method is more low-level than `new()`. It is the responsibility of + /// the caller to run [`test_timer`] before using any numbers generated with + /// `JitterRng`, and optionally call [`set_rounds`]. Also it is important to + /// consume at least one `u64` before using the first result to initialize + /// the entropy collection pool. + /// + /// # Example + /// + /// ``` + /// # use rand_jitter::rand_core::{RngCore, Error}; + /// use rand_jitter::JitterRng; + /// + /// # fn try_inner() -> Result<(), Error> { + /// fn get_nstime() -> u64 { + /// use std::time::{SystemTime, UNIX_EPOCH}; + /// + /// let dur = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); + /// // The correct way to calculate the current time is + /// // `dur.as_secs() * 1_000_000_000 + dur.subsec_nanos() as u64` + /// // But this is faster, and the difference in terms of entropy is + /// // negligible (log2(10^9) == 29.9). + /// dur.as_secs() << 30 | dur.subsec_nanos() as u64 + /// } + /// + /// let mut rng = JitterRng::new_with_timer(get_nstime); + /// let rounds = rng.test_timer()?; + /// rng.set_rounds(rounds); // optional + /// let _ = rng.next_u64(); + /// + /// // Ready for use + /// let v: u64 = rng.next_u64(); + /// # Ok(()) + /// # } + /// + /// # let _ = try_inner(); + /// ``` + /// + /// [`test_timer`]: JitterRng::test_timer + /// [`set_rounds`]: JitterRng::set_rounds + pub fn new_with_timer(timer: fn() -> u64) -> JitterRng { + JitterRng { + data: 0, + rounds: 64, + timer, + mem_prev_index: 0, + data_half_used: false, + } + } + + /// Configures how many rounds are used to generate each 64-bit value. + /// This must be greater than zero, and has a big impact on performance + /// and output quality. + /// + /// [`new_with_timer`] conservatively uses 64 rounds, but often less rounds + /// can be used. The `test_timer()` function returns the minimum number of + /// rounds required for full strength (platform dependent), so one may use + /// `rng.set_rounds(rng.test_timer()?);` or cache the value. + /// + /// [`new_with_timer`]: JitterRng::new_with_timer + pub fn set_rounds(&mut self, rounds: u8) { + assert!(rounds > 0); + self.rounds = rounds; + } + + // Calculate a random loop count used for the next round of an entropy + // collection, based on bits from a fresh value from the timer. + // + // The timer is folded to produce a number that contains at most `n_bits` + // bits. + // + // Note: A constant should be added to the resulting random loop count to + // prevent loops that run 0 times. + #[inline(never)] + fn random_loop_cnt(&mut self, n_bits: u32) -> u32 { + let mut rounds = 0; + + let mut time = (self.timer)(); + // Mix with the current state of the random number balance the random + // loop counter a bit more. + time ^= self.data; + + // We fold the time value as much as possible to ensure that as many + // bits of the time stamp are included as possible. + let folds = (64 + n_bits - 1) / n_bits; + let mask = (1 << n_bits) - 1; + for _ in 0..folds { + rounds ^= time & mask; + time >>= n_bits; + } + + rounds as u32 + } + + // CPU jitter noise source + // Noise source based on the CPU execution time jitter + // + // This function injects the individual bits of the time value into the + // entropy pool using an LFSR. + // + // The code is deliberately inefficient with respect to the bit shifting. + // This function not only acts as folding operation, but this function's + // execution is used to measure the CPU execution time jitter. Any change to + // the loop in this function implies that careful retesting must be done. + #[inline(never)] + fn lfsr_time(&mut self, time: u64, var_rounds: bool) { + fn lfsr(mut data: u64, time: u64) -> u64{ + for i in 1..65 { + let mut tmp = time << (64 - i); + tmp >>= 64 - 1; + + // Fibonacci LSFR with polynomial of + // x^64 + x^61 + x^56 + x^31 + x^28 + x^23 + 1 which is + // primitive according to + // http://poincare.matf.bg.ac.rs/~ezivkovm/publications/primpol1.pdf + // (the shift values are the polynomial values minus one + // due to counting bits from 0 to 63). As the current + // position is always the LSB, the polynomial only needs + // to shift data in from the left without wrap. + data ^= tmp; + data ^= (data >> 63) & 1; + data ^= (data >> 60) & 1; + data ^= (data >> 55) & 1; + data ^= (data >> 30) & 1; + data ^= (data >> 27) & 1; + data ^= (data >> 22) & 1; + data = data.rotate_left(1); + } + data + } + + // Note: in the reference implementation only the last round effects + // `self.data`, all the other results are ignored. To make sure the + // other rounds are not optimised out, we first run all but the last + // round on a throw-away value instead of the real `self.data`. + let mut lfsr_loop_cnt = 0; + if var_rounds { lfsr_loop_cnt = self.random_loop_cnt(4) }; + + let mut throw_away: u64 = 0; + for _ in 0..lfsr_loop_cnt { + throw_away = lfsr(throw_away, time); + } + black_box(throw_away); + + self.data = lfsr(self.data, time); + } + + // Memory Access noise source + // This is a noise source based on variations in memory access times + // + // This function performs memory accesses which will add to the timing + // variations due to an unknown amount of CPU wait states that need to be + // added when accessing memory. The memory size should be larger than the L1 + // caches as outlined in the documentation and the associated testing. + // + // The L1 cache has a very high bandwidth, albeit its access rate is usually + // slower than accessing CPU registers. Therefore, L1 accesses only add + // minimal variations as the CPU has hardly to wait. Starting with L2, + // significant variations are added because L2 typically does not belong to + // the CPU any more and therefore a wider range of CPU wait states is + // necessary for accesses. L3 and real memory accesses have even a wider + // range of wait states. However, to reliably access either L3 or memory, + // the `self.mem` memory must be quite large which is usually not desirable. + #[inline(never)] + fn memaccess(&mut self, mem: &mut [u8; MEMORY_SIZE], var_rounds: bool) { + let mut acc_loop_cnt = 128; + if var_rounds { acc_loop_cnt += self.random_loop_cnt(4) }; + + let mut index = self.mem_prev_index as usize; + for _ in 0..acc_loop_cnt { + // Addition of memblocksize - 1 to index with wrap around logic to + // ensure that every memory location is hit evenly. + // The modulus also allows the compiler to remove the indexing + // bounds check. + index = (index + MEMORY_BLOCKSIZE - 1) % MEMORY_SIZE; + + // memory access: just add 1 to one byte + // memory access implies read from and write to memory location + mem[index] = mem[index].wrapping_add(1); + } + self.mem_prev_index = index as u16; + } + + // This is the heart of the entropy generation: calculate time deltas and + // use the CPU jitter in the time deltas. The jitter is injected into the + // entropy pool. + // + // Ensure that `ec.prev_time` is primed before using the output of this + // function. This can be done by calling this function and not using its + // result. + fn measure_jitter(&mut self, ec: &mut EcState) -> Option<()> { + // Invoke one noise source before time measurement to add variations + self.memaccess(&mut ec.mem, true); + + // Get time stamp and calculate time delta to previous + // invocation to measure the timing variations + let time = (self.timer)(); + // Note: wrapping_sub combined with a cast to `i64` generates a correct + // delta, even in the unlikely case this is a timer that is not strictly + // monotonic. + let current_delta = time.wrapping_sub(ec.prev_time) as i64 as i32; + ec.prev_time = time; + + // Call the next noise source which also injects the data + self.lfsr_time(current_delta as u64, true); + + // Check whether we have a stuck measurement (i.e. does the last + // measurement holds entropy?). + if ec.stuck(current_delta) { return None }; + + // Rotate the data buffer by a prime number (any odd number would + // do) to ensure that every bit position of the input time stamp + // has an even chance of being merged with a bit position in the + // entropy pool. We do not use one here as the adjacent bits in + // successive time deltas may have some form of dependency. The + // chosen value of 7 implies that the low 7 bits of the next + // time delta value is concatenated with the current time delta. + self.data = self.data.rotate_left(7); + + Some(()) + } + + // Shuffle the pool a bit by mixing some value with a bijective function + // (XOR) into the pool. + // + // The function generates a mixer value that depends on the bits set and + // the location of the set bits in the random number generated by the + // entropy source. Therefore, based on the generated random number, this + // mixer value can have 2^64 different values. That mixer value is + // initialized with the first two SHA-1 constants. After obtaining the + // mixer value, it is XORed into the random number. + // + // The mixer value is not assumed to contain any entropy. But due to the + // XOR operation, it can also not destroy any entropy present in the + // entropy pool. + #[inline(never)] + fn stir_pool(&mut self) { + // This constant is derived from the first two 32 bit initialization + // vectors of SHA-1 as defined in FIPS 180-4 section 5.3.1 + // The order does not really matter as we do not rely on the specific + // numbers. We just pick the SHA-1 constants as they have a good mix of + // bit set and unset. + const CONSTANT: u64 = 0x67452301efcdab89; + + // The start value of the mixer variable is derived from the third + // and fourth 32 bit initialization vector of SHA-1 as defined in + // FIPS 180-4 section 5.3.1 + let mut mixer = 0x98badcfe10325476; + + // This is a constant time function to prevent leaking timing + // information about the random number. + // The normal code is: + // ``` + // for i in 0..64 { + // if ((self.data >> i) & 1) == 1 { mixer ^= CONSTANT; } + // } + // ``` + // This is a bit fragile, as LLVM really wants to use branches here, and + // we rely on it to not recognise the opportunity. + for i in 0..64 { + let apply = (self.data >> i) & 1; + let mask = !apply.wrapping_sub(1); + mixer ^= CONSTANT & mask; + mixer = mixer.rotate_left(1); + } + + self.data ^= mixer; + } + + fn gen_entropy(&mut self) -> u64 { + trace!("JitterRng: collecting entropy"); + + // Prime `ec.prev_time`, and run the noice sources to make sure the + // first loop round collects the expected entropy. + let mut ec = EcState { + prev_time: (self.timer)(), + last_delta: 0, + last_delta2: 0, + mem: [0; MEMORY_SIZE], + }; + let _ = self.measure_jitter(&mut ec); + + for _ in 0..self.rounds { + // If a stuck measurement is received, repeat measurement + // Note: we do not guard against an infinite loop, that would mean + // the timer suddenly became broken. + while self.measure_jitter(&mut ec).is_none() {} + } + + // Do a single read from `self.mem` to make sure the Memory Access noise + // source is not optimised out. + black_box(ec.mem[0]); + + self.stir_pool(); + self.data + } + + /// Basic quality tests on the timer, by measuring CPU timing jitter a few + /// hundred times. + /// + /// If successful, this will return the estimated number of rounds necessary + /// to collect 64 bits of entropy. Otherwise a [`TimerError`] with the cause + /// of the failure will be returned. + pub fn test_timer(&mut self) -> Result { + debug!("JitterRng: testing timer ..."); + // We could add a check for system capabilities such as `clock_getres` + // or check for `CONFIG_X86_TSC`, but it does not make much sense as the + // following sanity checks verify that we have a high-resolution timer. + + let mut delta_sum = 0; + let mut old_delta = 0; + + let mut time_backwards = 0; + let mut count_mod = 0; + let mut count_stuck = 0; + + let mut ec = EcState { + prev_time: (self.timer)(), + last_delta: 0, + last_delta2: 0, + mem: [0; MEMORY_SIZE], + }; + + // TESTLOOPCOUNT needs some loops to identify edge systems. + // 100 is definitely too little. + const TESTLOOPCOUNT: u64 = 300; + const CLEARCACHE: u64 = 100; + + for i in 0..(CLEARCACHE + TESTLOOPCOUNT) { + // Measure time delta of core entropy collection logic + let time = (self.timer)(); + self.memaccess(&mut ec.mem, true); + self.lfsr_time(time, true); + let time2 = (self.timer)(); + + // Test whether timer works + if time == 0 || time2 == 0 { + return Err(TimerError::NoTimer); + } + let delta = time2.wrapping_sub(time) as i64 as i32; + + // Test whether timer is fine grained enough to provide delta even + // when called shortly after each other -- this implies that we also + // have a high resolution timer + if delta == 0 { + return Err(TimerError::CoarseTimer); + } + + // Up to here we did not modify any variable that will be + // evaluated later, but we already performed some work. Thus we + // already have had an impact on the caches, branch prediction, + // etc. with the goal to clear it to get the worst case + // measurements. + if i < CLEARCACHE { continue; } + + if ec.stuck(delta) { count_stuck += 1; } + + // Test whether we have an increasing timer. + if !(time2 > time) { time_backwards += 1; } + + // Count the number of times the counter increases in steps of 100ns + // or greater. + if (delta % 100) == 0 { count_mod += 1; } + + // Ensure that we have a varying delta timer which is necessary for + // the calculation of entropy -- perform this check only after the + // first loop is executed as we need to prime the old_delta value + delta_sum += (delta - old_delta).abs() as u64; + old_delta = delta; + } + + // Do a single read from `self.mem` to make sure the Memory Access noise + // source is not optimised out. + black_box(ec.mem[0]); + + // We allow the time to run backwards for up to three times. + // This can happen if the clock is being adjusted by NTP operations. + // If such an operation just happens to interfere with our test, it + // should not fail. The value of 3 should cover the NTP case being + // performed during our test run. + if time_backwards > 3 { + return Err(TimerError::NotMonotonic); + } + + // Test that the available amount of entropy per round does not get to + // low. We expect 1 bit of entropy per round as a reasonable minimum + // (although less is possible, it means the collector loop has to run + // much more often). + // `assert!(delta_average >= log2(1))` + // `assert!(delta_sum / TESTLOOPCOUNT >= 1)` + // `assert!(delta_sum >= TESTLOOPCOUNT)` + if delta_sum < TESTLOOPCOUNT { + return Err(TimerError::TinyVariantions); + } + + // Ensure that we have variations in the time stamp below 100 for at + // least 10% of all checks -- on some platforms, the counter increments + // in multiples of 100, but not always + if count_mod > (TESTLOOPCOUNT * 9 / 10) { + return Err(TimerError::CoarseTimer); + } + + // If we have more than 90% stuck results, then this Jitter RNG is + // likely to not work well. + if count_stuck > (TESTLOOPCOUNT * 9 / 10) { + return Err(TimerError::TooManyStuck); + } + + // Estimate the number of `measure_jitter` rounds necessary for 64 bits + // of entropy. + // + // We don't try very hard to come up with a good estimate of the + // available bits of entropy per round here for two reasons: + // 1. Simple estimates of the available bits (like Shannon entropy) are + // too optimistic. + // 2. Unless we want to waste a lot of time during intialization, there + // only a small number of samples are available. + // + // Therefore we use a very simple and conservative estimate: + // `let bits_of_entropy = log2(delta_average) / 2`. + // + // The number of rounds `measure_jitter` should run to collect 64 bits + // of entropy is `64 / bits_of_entropy`. + let delta_average = delta_sum / TESTLOOPCOUNT; + + if delta_average >= 16 { + let log2 = 64 - delta_average.leading_zeros(); + // Do something similar to roundup(64/(log2/2)): + Ok( ((64u32 * 2 + log2 - 1) / log2) as u8) + } else { + // For values < 16 the rounding error becomes too large, use a + // lookup table. + // Values 0 and 1 are invalid, and filtered out by the + // `delta_sum < TESTLOOPCOUNT` test above. + let log2_lookup = [0, 0, 128, 81, 64, 56, 50, 46, + 43, 41, 39, 38, 36, 35, 34, 33]; + Ok(log2_lookup[delta_average as usize]) + } + } + + /// Statistical test: return the timer delta of one normal run of the + /// `JitterRng` entropy collector. + /// + /// Setting `var_rounds` to `true` will execute the memory access and the + /// CPU jitter noice sources a variable amount of times (just like a real + /// `JitterRng` round). + /// + /// Setting `var_rounds` to `false` will execute the noice sources the + /// minimal number of times. This can be used to measure the minimum amount + /// of entropy one round of the entropy collector can collect in the worst + /// case. + /// + /// See this crate's README on how to use `timer_stats` to test the quality + /// of `JitterRng`. + pub fn timer_stats(&mut self, var_rounds: bool) -> i64 { + let mut mem = [0; MEMORY_SIZE]; + + let time = (self.timer)(); + self.memaccess(&mut mem, var_rounds); + self.lfsr_time(time, var_rounds); + let time2 = (self.timer)(); + time2.wrapping_sub(time) as i64 + } +} + +// A function that is opaque to the optimizer to assist in avoiding dead-code +// elimination. Taken from `bencher`. +fn black_box(dummy: T) -> T { + unsafe { + let ret = ptr::read_volatile(&dummy); + mem::forget(dummy); + ret + } +} + +impl RngCore for JitterRng { + fn next_u32(&mut self) -> u32 { + // We want to use both parts of the generated entropy + if self.data_half_used { + self.data_half_used = false; + (self.data >> 32) as u32 + } else { + self.data = self.next_u64(); + self.data_half_used = true; + self.data as u32 + } + } + + fn next_u64(&mut self) -> u64 { + self.data_half_used = false; + self.gen_entropy() + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + // Fill using `next_u32`. This is faster for filling small slices (four + // bytes or less), while the overhead is negligible. + // + // This is done especially for wrappers that implement `next_u32` + // themselves via `fill_bytes`. + impls::fill_bytes_via_next(self, dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} + +impl CryptoRng for JitterRng {} + diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/src/platform.rs b/third_party/cargo/vendor/rand_jitter-0.1.4/src/platform.rs new file mode 100644 index 0000000..8e3d0fb --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/src/platform.rs @@ -0,0 +1,44 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2015 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows")))] +pub fn get_nstime() -> u64 { + use std::time::{SystemTime, UNIX_EPOCH}; + + let dur = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); + // The correct way to calculate the current time is + // `dur.as_secs() * 1_000_000_000 + dur.subsec_nanos() as u64` + // But this is faster, and the difference in terms of entropy is + // negligible (log2(10^9) == 29.9). + dur.as_secs() << 30 | dur.subsec_nanos() as u64 +} + +#[cfg(any(target_os = "macos", target_os = "ios"))] +pub fn get_nstime() -> u64 { + use libc; + + // On Mac OS and iOS std::time::SystemTime only has 1000ns resolution. + // We use `mach_absolute_time` instead. This provides a CPU dependent + // unit, to get real nanoseconds the result should by multiplied by + // numer/denom from `mach_timebase_info`. + // But we are not interested in the exact nanoseconds, just entropy. So + // we use the raw result. + unsafe { libc::mach_absolute_time() } +} + +#[cfg(target_os = "windows")] +pub fn get_nstime() -> u64 { + use winapi; + + unsafe { + let mut t = super::mem::zeroed(); + winapi::um::profileapi::QueryPerformanceCounter(&mut t); + *t.QuadPart() as u64 + } +} diff --git a/third_party/cargo/vendor/rand_jitter-0.1.4/tests/mod.rs b/third_party/cargo/vendor/rand_jitter-0.1.4/tests/mod.rs new file mode 100644 index 0000000..6820c20 --- /dev/null +++ b/third_party/cargo/vendor/rand_jitter-0.1.4/tests/mod.rs @@ -0,0 +1,31 @@ +extern crate rand_jitter; +extern crate rand_core; + +use rand_jitter::JitterRng; +#[cfg(feature = "std")] +use rand_core::RngCore; + +#[cfg(feature = "std")] +#[test] +fn test_jitter_init() { + // Because this is a debug build, measurements here are not representive + // of the final release build. + // Don't fail this test if initializing `JitterRng` fails because of a + // bad timer (the timer from the standard library may not have enough + // accuracy on all platforms). + match JitterRng::new() { + Ok(ref mut rng) => { + // false positives are possible, but extremely unlikely + assert!(rng.next_u32() | rng.next_u32() != 0); + }, + Err(_) => {}, + } +} + +#[test] +fn test_jitter_bad_timer() { + fn bad_timer() -> u64 { 0 } + let mut rng = JitterRng::new_with_timer(bad_timer); + assert!(rng.test_timer().is_err()); +} + diff --git a/third_party/cargo/vendor/rand_os-0.1.3/.cargo-checksum.json b/third_party/cargo/vendor/rand_os-0.1.3/.cargo-checksum.json new file mode 100644 index 0000000..6adb38d --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"b109ac9f2501be2151402585c5278ba9db30d1b880139f0f67aadcd7a9f85506","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"cb81ac6d2ae3ccec84cb897d1c2c4fe53986065424b46fea3ca4e15bca47db05","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"91ccce04b8ea75d26b78f155b578b92be283b2e740d94192ade9eaa3d59c8c27","src/cloudabi.rs":"4f9f9991a1ef7dc330e81ee5208fcc23ad6acc2c73c257b019a3aa488f3a1291","src/dragonfly_haiku_emscripten.rs":"8e693952f38b2576ce7c454cc51d0209917ec40f2a3224ff0f138f798d2c82b3","src/dummy_log.rs":"4e26589c18de568b7da7f0ccc9b77bb430961739a6510c2b043a43dee300c6fa","src/freebsd.rs":"6b1e0a3735d798d8297a9426721e01672424cc289707dae86e336a207cd43436","src/fuchsia.rs":"61159ae3fa469a40214b7ad2f9b0445ed952944c0d5738cd3b7c045eb3e5034a","src/lib.rs":"7d5bd0b5565f7dff4dc352608ab2fb95737dba9b5576fe70b57dcd90e1f11411","src/linux_android.rs":"24b113ef388a2b734ac7a47e045527edac4fe5f29e5ca7948c9a6edf3f69a111","src/macos.rs":"17ccfd5a69068db0580480f680398e20d9ed5219abd726c90e5d9db509539608","src/netbsd.rs":"1b00923bd48673e709cc3f4efd47111093d5bfb86643c8647dd30aeaf5aa6fce","src/openbsd_bitrig.rs":"b9601aa0c6cc0129913341adba838aa0fadd698563eca7f0b046e31c97f0ac92","src/random_device.rs":"bc9cf2470619a90bb8444a632a873e431f801cc3230977851e20d54d86093321","src/redox.rs":"c3fd6f418f085d3b5ffaa6ff4540380cf437cbd65c8b87f89c1dbe16222539e4","src/sgx.rs":"140cf6529ebbf28a19c112e6f325ecd9d84427cc962895795e427cb5b1fa8500","src/solarish.rs":"2c39d2b28a4b9568a378b78b2021bf633fef505d9c5fed2e0a50e90ed9711359","src/wasm32_bindgen.rs":"befe5b8a90ed23c2b3adf40281651966a5ee15ae520101704b68890ec4fb4529","src/wasm32_stdweb.rs":"8684b8ce392941c9d7864d45f82e5a4577fc63b0f0bb709fa627f8b9c9e154a6","src/windows.rs":"d72d555013440aeffe764d961a0a095f8a11417d28a13c2a8882abce2dc000f0","tests/mod.rs":"b8a6caeb5aafd13de775488168b0b46592336568ded37be713e422f724f6f086"},"package":"7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand_os-0.1.3/BUILD b/third_party/cargo/vendor/rand_os-0.1.3/BUILD new file mode 100644 index 0000000..c73a540 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/BUILD @@ -0,0 +1,45 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "mod" with type "test" omitted + +rust_library( + name = "rand_os", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/rand_core-0.4.2:rand_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.3", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/rand_os-0.1.3/CHANGELOG.md b/third_party/cargo/vendor/rand_os-0.1.3/CHANGELOG.md new file mode 100644 index 0000000..1ce36fc --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/CHANGELOG.md @@ -0,0 +1,22 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [0.1.3] - 2019-03-05 +### Changes +- Fix support for Illumos (#730) +- Fix deprecation warnings from atomic init (#739) + +## [0.1.2] - 2019-01-28 +### Changes +- Fuchsia: Replaced fuchsia-zircon with fuchsia-cprng + +## [0.1.1] - 2019-01-08 +### Additions +- Add support for x86_64-fortanix-unknown-sgx target (#670) + +## [0.1.0] - 2019-01-04 +Initial release. diff --git a/third_party/cargo/vendor/rand_os-0.1.3/COPYRIGHT b/third_party/cargo/vendor/rand_os-0.1.3/COPYRIGHT new file mode 100644 index 0000000..468d907 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/COPYRIGHT @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff --git a/third_party/cargo/vendor/rand_os-0.1.3/Cargo.toml b/third_party/cargo/vendor/rand_os-0.1.3/Cargo.toml new file mode 100644 index 0000000..d0f1dfe --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/Cargo.toml @@ -0,0 +1,53 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand_os" +version = "0.1.3" +authors = ["The Rand Project Developers"] +description = "OS backed Random Number Generator" +homepage = "https://crates.io/crates/rand_os" +documentation = "https://docs.rs/rand_os" +readme = "README.md" +keywords = ["random", "rng", "os"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-random/rand" +[dependencies.log] +version = "0.4" +optional = true + +[dependencies.rand_core] +version = "0.4" +features = ["std"] +[target."cfg(target_env = \"sgx\")".dependencies.rdrand] +version = "0.4.0" +[target."cfg(target_os = \"cloudabi\")".dependencies.cloudabi] +version = "0.0.3" +[target."cfg(target_os = \"fuchsia\")".dependencies.fuchsia-cprng] +version = "0.1.0" +[target."cfg(unix)".dependencies.libc] +version = "0.2" +[target."cfg(windows)".dependencies.winapi] +version = "0.3" +features = ["minwindef", "ntsecapi", "winnt"] +[target.wasm32-unknown-unknown.dependencies.stdweb] +version = "0.4" +optional = true + +[target.wasm32-unknown-unknown.dependencies.wasm-bindgen] +version = "0.2.12" +optional = true +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff --git a/third_party/cargo/vendor/rand_os-0.1.3/LICENSE-APACHE b/third_party/cargo/vendor/rand_os-0.1.3/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand_os-0.1.3/LICENSE-MIT b/third_party/cargo/vendor/rand_os-0.1.3/LICENSE-MIT new file mode 100644 index 0000000..d93b5ba --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright 2018 Developers of the Rand project +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand_os-0.1.3/README.md b/third_party/cargo/vendor/rand_os-0.1.3/README.md new file mode 100644 index 0000000..4f48b63 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/README.md @@ -0,0 +1,33 @@ +# rand_os + +[![Build Status](https://travis-ci.org/rust-random/rand.svg?branch=master)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Latest version](https://img.shields.io/crates/v/rand_os.svg)](https://crates.io/crates/rand_os) +[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_os) +[![API](https://docs.rs/rand_os/badge.svg)](https://docs.rs/rand_os) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) + +A random number generator that retrieves randomness straight from the +operating system. + +This crate depends on [rand_core](https://crates.io/crates/rand_core) and is +part of the [Rand project](https://github.com/rust-random/rand). + +This crate aims to support all of Rust's `std` platforms with a system-provided +entropy source. Unlike other Rand crates, this crate does not support `no_std` +(handling this gracefully is a current discussion topic). + +Links: + +- [API documentation (master)](https://rust-random.github.io/rand/rand_os) +- [API documentation (docs.rs)](https://docs.rs/rand_os) +- [Changelog](CHANGELOG.md) + +## License + +`rand_os` is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/cloudabi.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/cloudabi.rs new file mode 100644 index 0000000..8b96a2b --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/cloudabi.rs @@ -0,0 +1,39 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for CloudABI + +extern crate cloudabi; + +use std::io; +use rand_core::{Error, ErrorKind}; +use super::OsRngImpl; + +#[derive(Clone, Debug)] +pub struct OsRng; + +impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let errno = unsafe { cloudabi::random_get(dest) }; + if errno == cloudabi::errno::SUCCESS { + Ok(()) + } else { + // Cloudlibc provides its own `strerror` implementation so we + // can use `from_raw_os_error` here. + Err(Error::with_cause( + ErrorKind::Unavailable, + "random_get() system call failed", + io::Error::from_raw_os_error(errno as i32), + )) + } + } + + fn method_str(&self) -> &'static str { "cloudabi::random_get" } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/dragonfly_haiku_emscripten.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/dragonfly_haiku_emscripten.rs new file mode 100644 index 0000000..6132d7a --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/dragonfly_haiku_emscripten.rs @@ -0,0 +1,39 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for DragonFly / Haiku / Emscripten + +use rand_core::Error; +use super::random_device; +use super::OsRngImpl; +use std::fs::File; + +#[derive(Clone, Debug)] +pub struct OsRng(); + +impl OsRngImpl for OsRng { + fn new() -> Result { + random_device::open("/dev/random", &|p| File::open(p))?; + Ok(OsRng()) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + random_device::read(dest) + } + + #[cfg(target_os = "emscripten")] + fn max_chunk_size(&self) -> usize { + // `Crypto.getRandomValues` documents `dest` should be at most 65536 + // bytes. `crypto.randomBytes` documents: "To minimize threadpool + // task length variation, partition large randomBytes requests when + // doing so as part of fulfilling a client request. + 65536 + } + + fn method_str(&self) -> &'static str { "/dev/random" } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/dummy_log.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/dummy_log.rs new file mode 100644 index 0000000..ccfe4ba --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/dummy_log.rs @@ -0,0 +1,10 @@ +#[allow(unused)] +macro_rules! trace { ($($x:tt)*) => () } +#[allow(unused)] +macro_rules! debug { ($($x:tt)*) => () } +#[allow(unused)] +macro_rules! info { ($($x:tt)*) => () } +#[allow(unused)] +macro_rules! warn { ($($x:tt)*) => () } +#[allow(unused)] +macro_rules! error { ($($x:tt)*) => () } diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/freebsd.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/freebsd.rs new file mode 100644 index 0000000..6b8e672 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/freebsd.rs @@ -0,0 +1,45 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for FreeBSD + +extern crate libc; + +use rand_core::{Error, ErrorKind}; +use super::OsRngImpl; + +use std::ptr; +use std::io; + +#[derive(Clone, Debug)] +pub struct OsRng; + +impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let mib = [libc::CTL_KERN, libc::KERN_ARND]; + let mut len = dest.len(); + let ret = unsafe { + libc::sysctl(mib.as_ptr(), mib.len() as libc::c_uint, + dest.as_mut_ptr() as *mut _, &mut len, + ptr::null(), 0) + }; + if ret == -1 || len != dest.len() { + return Err(Error::with_cause( + ErrorKind::Unavailable, + "kern.arandom sysctl failed", + io::Error::last_os_error())); + } + Ok(()) + } + + fn max_chunk_size(&self) -> usize { 256 } + + fn method_str(&self) -> &'static str { "kern.arandom" } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/fuchsia.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/fuchsia.rs new file mode 100644 index 0000000..ada3677 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/fuchsia.rs @@ -0,0 +1,28 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for Fuchsia Zircon + +extern crate fuchsia_cprng; + +use rand_core::Error; +use super::OsRngImpl; + +#[derive(Clone, Debug)] +pub struct OsRng; + +impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + fuchsia_cprng::cprng_draw(dest); + Ok(()) + } + + fn method_str(&self) -> &'static str { "cprng_draw" } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/lib.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/lib.rs new file mode 100644 index 0000000..1b9cb25 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/lib.rs @@ -0,0 +1,440 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2015 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Interface to the random number generator of the operating system. +//! +//! [`OsRng`] is the preferred external source of entropy for most applications. +//! Commonly it is used to initialize a user-space RNG, which can then be used +//! to generate random values with much less overhead than `OsRng`. +//! +//! You may prefer to use [`EntropyRng`] instead of `OsRng`. It is unlikely, but +//! not entirely theoretical, for `OsRng` to fail. In such cases [`EntropyRng`] +//! falls back on a good alternative entropy source. +//! +//! [`OsRng::new()`] is guaranteed to be very cheap (after the first successful +//! call), and will never consume more than one file handle per process. +//! +//! # Usage example +//! ``` +//! use rand_os::OsRng; +//! use rand_os::rand_core::RngCore; +//! +//! let mut os_rng = OsRng::new().unwrap(); +//! let mut key = [0u8; 16]; +//! os_rng.fill_bytes(&mut key); +//! let random_u64 = os_rng.next_u64(); +//! ``` +//! +//! # Platform sources +//! +//! | OS | interface +//! |------------------|--------------------------------------------------------- +//! | Linux, Android | [`getrandom`][1] system call if available, otherwise [`/dev/urandom`][2] after reading from `/dev/random` once +//! | Windows | [`RtlGenRandom`][3] +//! | macOS, iOS | [`SecRandomCopyBytes`][4] +//! | FreeBSD | [`kern.arandom`][5] +//! | OpenBSD, Bitrig | [`getentropy`][6] +//! | NetBSD | [`/dev/urandom`][7] after reading from `/dev/random` once +//! | Dragonfly BSD | [`/dev/random`][8] +//! | Solaris, illumos | [`getrandom`][9] system call if available, otherwise [`/dev/random`][10] +//! | Fuchsia OS | [`cprng_draw`][11] +//! | Redox | [`rand:`][12] +//! | CloudABI | [`random_get`][13] +//! | Haiku | `/dev/random` (identical to `/dev/urandom`) +//! | Web browsers | [`Crypto.getRandomValues`][14] (see [Support for WebAssembly and ams.js][14]) +//! | Node.js | [`crypto.randomBytes`][15] (see [Support for WebAssembly and ams.js][16]) +//! +//! Rand doesn't have a blanket implementation for all Unix-like operating +//! systems that reads from `/dev/urandom`. This ensures all supported operating +//! systems are using the recommended interface and respect maximum buffer +//! sizes. +//! +//! ## Support for WebAssembly and ams.js +//! +//! The three Emscripten targets `asmjs-unknown-emscripten`, +//! `wasm32-unknown-emscripten` and `wasm32-experimental-emscripten` use +//! Emscripten's emulation of `/dev/random` on web browsers and Node.js. +//! +//! The bare WASM target `wasm32-unknown-unknown` tries to call the javascript +//! methods directly, using either `stdweb` or `wasm-bindgen` depending on what +//! features are activated for this crate. Note that if both features are +//! enabled `wasm-bindgen` will be used. +//! +//! ## Early boot +//! +//! It is possible that early in the boot process the OS hasn't had enough time +//! yet to collect entropy to securely seed its RNG, especially on virtual +//! machines. +//! +//! Some operating systems always block the thread until the RNG is securely +//! seeded. This can take anywhere from a few seconds to more than a minute. +//! Others make a best effort to use a seed from before the shutdown and don't +//! document much. +//! +//! A few, Linux, NetBSD and Solaris, offer a choice between blocking, and +//! getting an error. With `try_fill_bytes` we choose to get the error +//! ([`ErrorKind::NotReady`]), while the other methods use a blocking interface. +//! +//! On Linux (when the `genrandom` system call is not available) and on NetBSD +//! reading from `/dev/urandom` never blocks, even when the OS hasn't collected +//! enough entropy yet. As a countermeasure we try to do a single read from +//! `/dev/random` until we know the OS RNG is initialized (and store this in a +//! global static). +//! +//! # Panics and error handling +//! +//! We cannot guarantee that `OsRng` will fail, but if it does, it will likely +//! be either when `OsRng::new()` is first called or when data is first read. +//! If you wish to catch errors early, then test reading of at least one byte +//! from `OsRng` via [`try_fill_bytes`]. If this succeeds, it is extremely +//! unlikely that any further errors will occur. +//! +//! Only [`try_fill_bytes`] is able to report the cause of an error; the other +//! [`RngCore`] methods may (depending on the error kind) retry several times, +//! but must eventually panic if the error persists. +//! +//! [`EntropyRng`]: ../rand/rngs/struct.EntropyRng.html +//! [`try_fill_bytes`]: RngCore::try_fill_bytes +//! [`ErrorKind::NotReady`]: rand_core::ErrorKind +//! +//! [1]: http://man7.org/linux/man-pages/man2/getrandom.2.html +//! [2]: http://man7.org/linux/man-pages/man4/urandom.4.html +//! [3]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx +//! [4]: https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc +//! [5]: https://www.freebsd.org/cgi/man.cgi?query=random&sektion=4 +//! [6]: https://man.openbsd.org/getentropy.2 +//! [7]: http://netbsd.gw.com/cgi-bin/man-cgi?random+4+NetBSD-current +//! [8]: https://leaf.dragonflybsd.org/cgi/web-man?command=random§ion=4 +//! [9]: https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html +//! [10]: https://docs.oracle.com/cd/E86824_01/html/E54777/random-7d.html +//! [11]: https://fuchsia.googlesource.com/zircon/+/HEAD/docs/syscalls/cprng_draw.md +//! [12]: https://github.com/redox-os/randd/blob/master/src/main.rs +//! [13]: https://github.com/NuxiNL/cloudabi/blob/v0.20/cloudabi.txt#L1826 +//! [14]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues +//! [15]: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback +//! [16]: #support-for-webassembly-and-amsjs +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] + +#![cfg_attr(feature = "stdweb", recursion_limit="128")] + +pub extern crate rand_core; +#[cfg(feature = "log")] +#[macro_use] extern crate log; + +// We have to do it here because we load macros +#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten"), + feature = "wasm-bindgen"))] +extern crate wasm_bindgen; +#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten"), + not(feature = "wasm-bindgen"), + feature = "stdweb"))] +#[macro_use] extern crate stdweb; + +#[cfg(target_env = "sgx")] +extern crate rdrand; + +#[cfg(not(feature = "log"))] +#[macro_use] +mod dummy_log; + +use std::fmt; +use rand_core::{CryptoRng, RngCore, Error, impls}; + +/// A random number generator that retrieves randomness straight from the +/// operating system. +#[derive(Clone)] +pub struct OsRng(imp::OsRng); + +impl fmt::Debug for OsRng { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + +impl OsRng { + /// Create a new `OsRng`. + pub fn new() -> Result { + imp::OsRng::new().map(OsRng) + } +} + +impl CryptoRng for OsRng {} + +impl RngCore for OsRng { + fn next_u32(&mut self) -> u32 { + impls::next_u32_via_fill(self) + } + + fn next_u64(&mut self) -> u64 { + impls::next_u64_via_fill(self) + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + use std::{time, thread}; + + // We cannot return Err(..), so we try to handle before panicking. + const MAX_RETRY_PERIOD: u32 = 10; // max 10s + const WAIT_DUR_MS: u32 = 100; // retry every 100ms + let wait_dur = time::Duration::from_millis(WAIT_DUR_MS as u64); + const RETRY_LIMIT: u32 = (MAX_RETRY_PERIOD * 1000) / WAIT_DUR_MS; + const TRANSIENT_RETRIES: u32 = 8; + let mut err_count = 0; + let mut error_logged = false; + + // Maybe block until the OS RNG is initialized + let mut read = 0; + if let Ok(n) = self.0.test_initialized(dest, true) { read = n }; + let dest = &mut dest[read..]; + + loop { + if let Err(e) = self.try_fill_bytes(dest) { + if err_count >= RETRY_LIMIT { + error!("OsRng failed too many times; last error: {}", e); + panic!("OsRng failed too many times; last error: {}", e); + } + + if e.kind.should_wait() { + if !error_logged { + warn!("OsRng failed; waiting up to {}s and retrying. Error: {}", + MAX_RETRY_PERIOD, e); + error_logged = true; + } + err_count += 1; + thread::sleep(wait_dur); + continue; + } else if e.kind.should_retry() { + if !error_logged { + warn!("OsRng failed; retrying up to {} times. Error: {}", + TRANSIENT_RETRIES, e); + error_logged = true; + } + err_count += (RETRY_LIMIT + TRANSIENT_RETRIES - 1) + / TRANSIENT_RETRIES; // round up + continue; + } else { + error!("OsRng failed: {}", e); + panic!("OsRng fatal error: {}", e); + } + } + + break; + } + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + // Some systems do not support reading 0 random bytes. + // (And why waste a system call?) + if dest.len() == 0 { return Ok(()); } + + let read = self.0.test_initialized(dest, false)?; + let dest = &mut dest[read..]; + + let max = self.0.max_chunk_size(); + if dest.len() <= max { + trace!("OsRng: reading {} bytes via {}", + dest.len(), self.0.method_str()); + } else { + trace!("OsRng: reading {} bytes via {} in {} chunks of {} bytes", + dest.len(), self.0.method_str(), (dest.len() + max) / max, max); + } + for slice in dest.chunks_mut(max) { + self.0.fill_chunk(slice)?; + } + Ok(()) + } +} + +trait OsRngImpl where Self: Sized { + // Create a new `OsRng` platform interface. + fn new() -> Result; + + // Fill a chunk with random bytes. + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error>; + + // Test whether the OS RNG is initialized. This method may not be possible + // to support cheaply (or at all) on all operating systems. + // + // If `blocking` is set, this will cause the OS the block execution until + // its RNG is initialized. + // + // Random values that are read while this are stored in `dest`, the amount + // of read bytes is returned. + fn test_initialized(&mut self, _dest: &mut [u8], _blocking: bool) + -> Result { Ok(0) } + + // Maximum chunk size supported. + fn max_chunk_size(&self) -> usize { ::std::usize::MAX } + + // Name of the OS interface (used for logging). + fn method_str(&self) -> &'static str; +} + +#[cfg(any(target_os = "linux", target_os = "android", + target_os = "netbsd", target_os = "dragonfly", + target_os = "solaris", target_os = "redox", + target_os = "haiku", target_os = "emscripten", + target_os = "illumos"))] +mod random_device; + +macro_rules! mod_use { + ($cond:meta, $module:ident) => { + #[$cond] + mod $module; + #[$cond] + use $module as imp; + } +} + +mod_use!(cfg(target_os = "android"), linux_android); +mod_use!(cfg(target_os = "bitrig"), openbsd_bitrig); +mod_use!(cfg(target_os = "cloudabi"), cloudabi); +mod_use!(cfg(target_os = "dragonfly"), dragonfly_haiku_emscripten); +mod_use!(cfg(target_os = "emscripten"), dragonfly_haiku_emscripten); +mod_use!(cfg(target_os = "freebsd"), freebsd); +mod_use!(cfg(target_os = "fuchsia"), fuchsia); +mod_use!(cfg(target_os = "haiku"), dragonfly_haiku_emscripten); +mod_use!(cfg(target_os = "ios"), macos); +mod_use!(cfg(target_os = "linux"), linux_android); +mod_use!(cfg(target_os = "macos"), macos); +mod_use!(cfg(target_os = "netbsd"), netbsd); +mod_use!(cfg(target_os = "openbsd"), openbsd_bitrig); +mod_use!(cfg(target_os = "redox"), redox); +mod_use!(cfg(any(target_os = "solaris", target_os = "illumos")), solarish); +mod_use!(cfg(windows), windows); +mod_use!(cfg(target_env = "sgx"), sgx); + +mod_use!( + cfg(all( + target_arch = "wasm32", + not(target_os = "emscripten"), + feature = "wasm-bindgen" + )), + wasm32_bindgen +); + +mod_use!( + cfg(all( + target_arch = "wasm32", + not(target_os = "emscripten"), + not(feature = "wasm-bindgen"), + feature = "stdweb", + )), + wasm32_stdweb +); + +/// Per #678 we use run-time failure where WASM bindings are missing +#[cfg(all( + target_arch = "wasm32", + not(target_os = "emscripten"), + not(feature = "wasm-bindgen"), + not(feature = "stdweb"), +))] +mod imp { + use rand_core::{Error, ErrorKind}; + use super::OsRngImpl; + + #[derive(Clone, Debug)] + pub struct OsRng; + + impl OsRngImpl for OsRng { + fn new() -> Result { + Err(Error::new(ErrorKind::Unavailable, + "OsRng: support for wasm32 requires emscripten, stdweb or wasm-bindgen")) + } + + fn fill_chunk(&mut self, _dest: &mut [u8]) -> Result<(), Error> { + unimplemented!() + } + + fn method_str(&self) -> &'static str { unimplemented!() } + } +} + +#[cfg(not(any( + target_os = "android", + target_os = "bitrig", + target_os = "cloudabi", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "redox", + target_os = "solaris", + target_os = "illumos", + windows, + target_arch = "wasm32", + target_env = "sgx" +)))] +compile_error!("OS RNG support is not available for this platform"); + +// Due to rustwasm/wasm-bindgen#201 this can't be defined in the inner os +// modules, so hack around it for now and place it at the root. +#[cfg(all(feature = "wasm-bindgen", target_arch = "wasm32"))] +#[doc(hidden)] +#[allow(missing_debug_implementations)] +pub mod __wbg_shims { + + // `extern { type Foo; }` isn't supported on 1.22 syntactically, so use a + // macro to work around that. + macro_rules! rust_122_compat { + ($($t:tt)*) => ($($t)*) + } + + rust_122_compat! { + extern crate wasm_bindgen; + + pub use wasm_bindgen::prelude::*; + + #[wasm_bindgen] + extern "C" { + pub type Function; + #[wasm_bindgen(constructor)] + pub fn new(s: &str) -> Function; + #[wasm_bindgen(method)] + pub fn call(this: &Function, self_: &JsValue) -> JsValue; + + pub type This; + #[wasm_bindgen(method, getter, structural, js_name = self)] + pub fn self_(me: &This) -> JsValue; + #[wasm_bindgen(method, getter, structural)] + pub fn crypto(me: &This) -> JsValue; + + #[derive(Clone, Debug)] + pub type BrowserCrypto; + + // TODO: these `structural` annotations here ideally wouldn't be here to + // avoid a JS shim, but for now with feature detection they're + // unavoidable. + #[wasm_bindgen(method, js_name = getRandomValues, structural, getter)] + pub fn get_random_values_fn(me: &BrowserCrypto) -> JsValue; + #[wasm_bindgen(method, js_name = getRandomValues, structural)] + pub fn get_random_values(me: &BrowserCrypto, buf: &mut [u8]); + + #[wasm_bindgen(js_name = require)] + pub fn node_require(s: &str) -> NodeCrypto; + + #[derive(Clone, Debug)] + pub type NodeCrypto; + + #[wasm_bindgen(method, js_name = randomFillSync, structural)] + pub fn random_fill_sync(me: &NodeCrypto, buf: &mut [u8]); + } + } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/linux_android.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/linux_android.rs new file mode 100644 index 0000000..255c220 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/linux_android.rs @@ -0,0 +1,186 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for Linux / Android + +extern crate libc; + +use rand_core::{Error, ErrorKind}; +use super::random_device; +use super::OsRngImpl; + +use std::io; +use std::io::Read; +use std::fs::{File, OpenOptions}; +use std::os::unix::fs::OpenOptionsExt; +use std::sync::atomic::{AtomicBool, Ordering}; +#[allow(deprecated)] // Required for compatibility with Rust < 1.24. +use std::sync::atomic::ATOMIC_BOOL_INIT; +use std::sync::{Once, ONCE_INIT}; + +#[derive(Clone, Debug)] +pub struct OsRng { + method: OsRngMethod, + initialized: bool, +} + +#[derive(Clone, Debug)] +enum OsRngMethod { + GetRandom, + RandomDevice, +} + +impl OsRngImpl for OsRng { + fn new() -> Result { + if is_getrandom_available() { + return Ok(OsRng { method: OsRngMethod::GetRandom, + initialized: false }); + } + random_device::open("/dev/urandom", &|p| File::open(p))?; + Ok(OsRng { method: OsRngMethod::RandomDevice, initialized: false }) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + match self.method { + OsRngMethod::GetRandom => getrandom_try_fill(dest, false), + OsRngMethod::RandomDevice => random_device::read(dest), + } + } + + fn test_initialized(&mut self, dest: &mut [u8], blocking: bool) + -> Result + { + #[allow(deprecated)] + static OS_RNG_INITIALIZED: AtomicBool = ATOMIC_BOOL_INIT; + if !self.initialized { + self.initialized = OS_RNG_INITIALIZED.load(Ordering::Relaxed); + } + if self.initialized { return Ok(0); } + + let result = match self.method { + OsRngMethod::GetRandom => { + getrandom_try_fill(dest, blocking)?; + Ok(dest.len()) + } + OsRngMethod::RandomDevice => { + info!("OsRng: testing random device /dev/random"); + let mut file = OpenOptions::new() + .read(true) + .custom_flags(if blocking { 0 } else { libc::O_NONBLOCK }) + .open("/dev/random") + .map_err(random_device::map_err)?; + file.read(&mut dest[..1]).map_err(random_device::map_err)?; + Ok(1) + } + }; + OS_RNG_INITIALIZED.store(true, Ordering::Relaxed); + self.initialized = true; + result + } + + fn method_str(&self) -> &'static str { + match self.method { + OsRngMethod::GetRandom => "getrandom", + OsRngMethod::RandomDevice => "/dev/urandom", + } + } +} + +#[cfg(target_arch = "x86_64")] +const NR_GETRANDOM: libc::c_long = 318; +#[cfg(target_arch = "x86")] +const NR_GETRANDOM: libc::c_long = 355; +#[cfg(target_arch = "arm")] +const NR_GETRANDOM: libc::c_long = 384; +#[cfg(target_arch = "aarch64")] +const NR_GETRANDOM: libc::c_long = 278; + #[cfg(target_arch = "s390x")] +const NR_GETRANDOM: libc::c_long = 349; +#[cfg(target_arch = "powerpc")] +const NR_GETRANDOM: libc::c_long = 359; +#[cfg(target_arch = "powerpc64")] +const NR_GETRANDOM: libc::c_long = 359; +#[cfg(target_arch = "mips")] // old ABI +const NR_GETRANDOM: libc::c_long = 4353; +#[cfg(target_arch = "mips64")] +const NR_GETRANDOM: libc::c_long = 5313; +#[cfg(target_arch = "sparc")] +const NR_GETRANDOM: libc::c_long = 347; +#[cfg(target_arch = "sparc64")] +const NR_GETRANDOM: libc::c_long = 347; +#[cfg(not(any(target_arch = "x86_64", target_arch = "x86", + target_arch = "arm", target_arch = "aarch64", + target_arch = "s390x", target_arch = "powerpc", + target_arch = "powerpc64", target_arch = "mips", + target_arch = "mips64", target_arch = "sparc", + target_arch = "sparc64")))] +const NR_GETRANDOM: libc::c_long = 0; + +fn getrandom(buf: &mut [u8], blocking: bool) -> libc::c_long { + const GRND_NONBLOCK: libc::c_uint = 0x0001; + + if NR_GETRANDOM == 0 { return -1 }; + + unsafe { + libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), + if blocking { 0 } else { GRND_NONBLOCK }) + } +} + +fn getrandom_try_fill(dest: &mut [u8], blocking: bool) -> Result<(), Error> { + let mut read = 0; + while read < dest.len() { + let result = getrandom(&mut dest[read..], blocking); + if result == -1 { + let err = io::Error::last_os_error(); + let kind = err.kind(); + if kind == io::ErrorKind::Interrupted { + continue; + } else if kind == io::ErrorKind::WouldBlock { + return Err(Error::with_cause( + ErrorKind::NotReady, + "getrandom not ready", + err, + )); + } else { + return Err(Error::with_cause( + ErrorKind::Unavailable, + "unexpected getrandom error", + err, + )); + } + } else { + read += result as usize; + } + } + Ok(()) +} + +fn is_getrandom_available() -> bool { + static CHECKER: Once = ONCE_INIT; + #[allow(deprecated)] + static AVAILABLE: AtomicBool = ATOMIC_BOOL_INIT; + + if NR_GETRANDOM == 0 { return false }; + + CHECKER.call_once(|| { + debug!("OsRng: testing getrandom"); + let mut buf: [u8; 0] = []; + let result = getrandom(&mut buf, false); + let available = if result == -1 { + let err = io::Error::last_os_error().raw_os_error(); + err != Some(libc::ENOSYS) + } else { + true + }; + AVAILABLE.store(available, Ordering::Relaxed); + info!("OsRng: using {}", if available { "getrandom" } else { "/dev/urandom" }); + }); + + AVAILABLE.load(Ordering::Relaxed) +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/macos.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/macos.rs new file mode 100644 index 0000000..6c67251 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/macos.rs @@ -0,0 +1,53 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for MacOS / iOS + +extern crate libc; + +use rand_core::{Error, ErrorKind}; +use super::OsRngImpl; + +use std::io; +use self::libc::{c_int, size_t}; + +#[derive(Clone, Debug)] +pub struct OsRng; + +enum SecRandom {} + +#[allow(non_upper_case_globals)] +const kSecRandomDefault: *const SecRandom = 0 as *const SecRandom; + +#[link(name = "Security", kind = "framework")] +extern { + fn SecRandomCopyBytes(rnd: *const SecRandom, + count: size_t, bytes: *mut u8) -> c_int; +} + +impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let ret = unsafe { + SecRandomCopyBytes(kSecRandomDefault, + dest.len() as size_t, + dest.as_mut_ptr()) + }; + if ret == -1 { + Err(Error::with_cause( + ErrorKind::Unavailable, + "couldn't generate random bytes", + io::Error::last_os_error())) + } else { + Ok(()) + } + } + + fn method_str(&self) -> &'static str { "SecRandomCopyBytes" } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/netbsd.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/netbsd.rs new file mode 100644 index 0000000..34517bf --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/netbsd.rs @@ -0,0 +1,57 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for NetBSD + +use rand_core::Error; +use super::random_device; +use super::OsRngImpl; + +use std::fs::File; +use std::io::Read; +use std::sync::atomic::{AtomicBool, Ordering}; +#[allow(deprecated)] // Required for compatibility with Rust < 1.24. +use std::sync::atomic::ATOMIC_BOOL_INIT; + +#[derive(Clone, Debug)] +pub struct OsRng { initialized: bool } + +impl OsRngImpl for OsRng { + fn new() -> Result { + random_device::open("/dev/urandom", &|p| File::open(p))?; + Ok(OsRng { initialized: false }) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + random_device::read(dest) + } + + // Read a single byte from `/dev/random` to determine if the OS RNG is + // already seeded. NetBSD always blocks if not yet ready. + fn test_initialized(&mut self, dest: &mut [u8], _blocking: bool) + -> Result + { + #[allow(deprecated)] + static OS_RNG_INITIALIZED: AtomicBool = ATOMIC_BOOL_INIT; + if !self.initialized { + self.initialized = OS_RNG_INITIALIZED.load(Ordering::Relaxed); + } + if self.initialized { return Ok(0); } + + info!("OsRng: testing random device /dev/random"); + let mut file = + File::open("/dev/random").map_err(random_device::map_err)?; + file.read(&mut dest[..1]).map_err(random_device::map_err)?; + + OS_RNG_INITIALIZED.store(true, Ordering::Relaxed); + self.initialized = true; + Ok(1) + } + + fn method_str(&self) -> &'static str { "/dev/urandom" } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/openbsd_bitrig.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/openbsd_bitrig.rs new file mode 100644 index 0000000..c9b35a6 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/openbsd_bitrig.rs @@ -0,0 +1,40 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for OpenBSD / Bitrig + +extern crate libc; + +use rand_core::{Error, ErrorKind}; +use super::OsRngImpl; + +use std::io; + +#[derive(Clone, Debug)] +pub struct OsRng; + +impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let ret = unsafe { + libc::getentropy(dest.as_mut_ptr() as *mut libc::c_void, dest.len()) + }; + if ret == -1 { + return Err(Error::with_cause( + ErrorKind::Unavailable, + "getentropy failed", + io::Error::last_os_error())); + } + Ok(()) + } + + fn max_chunk_size(&self) -> usize { 256 } + + fn method_str(&self) -> &'static str { "getentropy" } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/random_device.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/random_device.rs new file mode 100644 index 0000000..5da9194 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/random_device.rs @@ -0,0 +1,70 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Helper functions to read from a random device such as `/dev/urandom`. +//! +//! All instances use a single internal file handle, to prevent possible +//! exhaustion of file descriptors. +use rand_core::{Error, ErrorKind}; +use std::fs::File; +use std::io; +use std::io::Read; +use std::sync::{Once, Mutex, ONCE_INIT}; + +// TODO: remove outer Option when `Mutex::new(None)` is a constant expression +static mut READ_RNG_FILE: Option>> = None; +static READ_RNG_ONCE: Once = ONCE_INIT; + +#[allow(unused)] +pub fn open(path: &'static str, open_fn: F) -> Result<(), Error> + where F: Fn(&'static str) -> Result +{ + READ_RNG_ONCE.call_once(|| { + unsafe { READ_RNG_FILE = Some(Mutex::new(None)) } + }); + + // We try opening the file outside the `call_once` fn because we cannot + // clone the error, thus we must retry on failure. + + let mutex = unsafe { READ_RNG_FILE.as_ref().unwrap() }; + let mut guard = mutex.lock().unwrap(); + if (*guard).is_none() { + info!("OsRng: opening random device {}", path); + let file = open_fn(path).map_err(map_err)?; + *guard = Some(file); + }; + Ok(()) +} + +pub fn read(dest: &mut [u8]) -> Result<(), Error> { + // We expect this function only to be used after `random_device::open` + // was succesful. Therefore we can assume that our memory was set with a + // valid object. + let mutex = unsafe { READ_RNG_FILE.as_ref().unwrap() }; + let mut guard = mutex.lock().unwrap(); + let file = (*guard).as_mut().unwrap(); + + // Use `std::io::read_exact`, which retries on `ErrorKind::Interrupted`. + file.read_exact(dest).map_err(|err| { + Error::with_cause(ErrorKind::Unavailable, + "error reading random device", err) + }) + +} + +pub fn map_err(err: io::Error) -> Error { + match err.kind() { + io::ErrorKind::Interrupted => + Error::new(ErrorKind::Transient, "interrupted"), + io::ErrorKind::WouldBlock => + Error::with_cause(ErrorKind::NotReady, + "OS RNG not yet seeded", err), + _ => Error::with_cause(ErrorKind::Unavailable, + "error while opening random device", err) + } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/redox.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/redox.rs new file mode 100644 index 0000000..36fae26 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/redox.rs @@ -0,0 +1,30 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for Redox + +use rand_core::Error; +use super::random_device; +use super::OsRngImpl; +use std::fs::File; + +#[derive(Clone, Debug)] +pub struct OsRng(); + +impl OsRngImpl for OsRng { + fn new() -> Result { + random_device::open("rand:", &|p| File::open(p))?; + Ok(OsRng()) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + random_device::read(dest) + } + + fn method_str(&self) -> &'static str { "'rand:'" } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/sgx.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/sgx.rs new file mode 100644 index 0000000..43ae0ef --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/sgx.rs @@ -0,0 +1,38 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::OsRngImpl; +use Error; +use rdrand::RdRand; +use rand_core::RngCore; +use std::fmt::{Debug, Formatter, Result as FmtResult}; + +#[derive(Clone)] +pub struct OsRng{ + gen: RdRand +} + +impl OsRngImpl for OsRng { + fn new() -> Result { + let rng = RdRand::new()?; + Ok(OsRng{ gen: rng }) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.gen.try_fill_bytes(dest) + } + + fn method_str(&self) -> &'static str { "RDRAND" } +} + +impl Debug for OsRng { + fn fmt(&self, f: &mut Formatter) -> FmtResult { + f.debug_struct("OsRng") + .finish() + } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/solarish.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/solarish.rs new file mode 100644 index 0000000..471768a --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/solarish.rs @@ -0,0 +1,195 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for the Solaris family +//! +//! Read from `/dev/random`, with chunks of limited size (1040 bytes). +//! `/dev/random` uses the Hash_DRBG with SHA512 algorithm from NIST SP 800-90A. +//! `/dev/urandom` uses the FIPS 186-2 algorithm, which is considered less +//! secure. We choose to read from `/dev/random`. +//! +//! Since Solaris 11.3 the `getrandom` syscall is available. To make sure we can +//! compile on both Solaris and on OpenSolaris derivatives, that do not have the +//! function, we do a direct syscall instead of calling a library function. +//! +//! We have no way to differentiate between Solaris, illumos, SmartOS, etc. +extern crate libc; + +use rand_core::{Error, ErrorKind}; +use super::random_device; +use super::OsRngImpl; + +use std::io; +use std::io::Read; +use std::fs::{File, OpenOptions}; +use std::os::unix::fs::OpenOptionsExt; +use std::sync::atomic::{AtomicBool, Ordering, AtomicUsize}; +#[allow(deprecated)] // Required for compatibility with Rust < 1.24. +use std::sync::atomic::ATOMIC_BOOL_INIT; +use std::cmp; +use std::mem; + +#[derive(Clone, Debug)] +pub struct OsRng { + method: OsRngMethod, + initialized: bool, +} + +#[derive(Clone, Debug)] +enum OsRngMethod { + GetRandom, + RandomDevice, +} + +impl OsRngImpl for OsRng { + fn new() -> Result { + if is_getrandom_available() { + return Ok(OsRng { method: OsRngMethod::GetRandom, + initialized: false }); + } + let open = |p| OpenOptions::new() + .read(true) + .custom_flags(libc::O_NONBLOCK) + .open(p); + random_device::open("/dev/random", &open)?; + Ok(OsRng { method: OsRngMethod::RandomDevice, initialized: false }) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + match self.method { + OsRngMethod::GetRandom => getrandom_try_fill(dest, false), + OsRngMethod::RandomDevice => random_device::read(dest), + } + } + + fn test_initialized(&mut self, dest: &mut [u8], blocking: bool) + -> Result + { + #[allow(deprecated)] + static OS_RNG_INITIALIZED: AtomicBool = ATOMIC_BOOL_INIT; + if !self.initialized { + self.initialized = OS_RNG_INITIALIZED.load(Ordering::Relaxed); + } + if self.initialized { return Ok(0); } + + let chunk_len = cmp::min(1024, dest.len()); + let dest = &mut dest[..chunk_len]; + + match self.method { + OsRngMethod::GetRandom => getrandom_try_fill(dest, blocking)?, + OsRngMethod::RandomDevice => { + if blocking { + info!("OsRng: testing random device /dev/random"); + // We already have a non-blocking handle, but now need a + // blocking one. Not much choice except opening it twice + let mut file = File::open("/dev/random") + .map_err(random_device::map_err)?; + file.read(dest).map_err(random_device::map_err)?; + } else { + self.fill_chunk(dest)?; + } + } + }; + OS_RNG_INITIALIZED.store(true, Ordering::Relaxed); + self.initialized = true; + Ok(chunk_len) + } + + fn max_chunk_size(&self) -> usize { + // This is the largest size that's guaranteed to not block across + // all the Solarish platforms, though some may allow for larger + // sizes. + 256 + } + + fn method_str(&self) -> &'static str { + match self.method { + OsRngMethod::GetRandom => "getrandom", + OsRngMethod::RandomDevice => "/dev/random", + } + } +} + +#[cfg(target_os = "illumos")] +type GetRandomFn = unsafe extern fn(*mut u8, libc::size_t, libc::c_uint) + -> libc::ssize_t; +#[cfg(target_os = "solaris")] +type GetRandomFn = unsafe extern fn(*mut u8, libc::size_t, libc::c_uint) + -> libc::c_int; + +// Use dlsym to determine if getrandom(2) is present in libc. On Solarish +// systems, the syscall interface is not stable and can change between +// updates. Even worse, issuing unsupported syscalls will cause the system +// to generate a SIGSYS signal (usually terminating the program). +// Instead the stable APIs are exposed via libc. Cache the result of the +// lookup for future calls. This is loosely modeled after the +// libstd::sys::unix::weak macro which unfortunately is not exported. +fn fetch() -> Option { + static FPTR: AtomicUsize = AtomicUsize::new(1); + + if FPTR.load(Ordering::SeqCst) == 1 { + let name = "getrandom\0"; + let addr = unsafe { + libc::dlsym(libc::RTLD_DEFAULT, name.as_ptr() as *const _) as usize + }; + FPTR.store(addr, Ordering::SeqCst); + } + + let ptr = FPTR.load(Ordering::SeqCst); + unsafe { + mem::transmute::>(ptr) + } +} + +fn getrandom(buf: &mut [u8], blocking: bool) -> libc::ssize_t { + const GRND_NONBLOCK: libc::c_uint = 0x0001; + const GRND_RANDOM: libc::c_uint = 0x0002; + + if let Some(rand) = fetch() { + let flag = if blocking { 0 } else { GRND_NONBLOCK } | GRND_RANDOM; + unsafe { + rand(buf.as_mut_ptr(), buf.len(), flag) as libc::ssize_t + } + } else { + -1 + } +} + +fn getrandom_try_fill(dest: &mut [u8], blocking: bool) -> Result<(), Error> { + let result = getrandom(dest, blocking); + if result == -1 || result == 0 { + let err = io::Error::last_os_error(); + let kind = err.kind(); + if kind == io::ErrorKind::WouldBlock { + return Err(Error::with_cause( + ErrorKind::NotReady, + "getrandom not ready", + err, + )); + } else { + return Err(Error::with_cause( + ErrorKind::Unavailable, + "unexpected getrandom error", + err, + )); + } + } else if result != dest.len() as libc::ssize_t { + return Err(Error::new(ErrorKind::Unavailable, + "unexpected getrandom error")); + } + Ok(()) +} + +fn is_getrandom_available() -> bool { + let available = match fetch() { + Some(_) => true, + None => false, + }; + info!("OsRng: using {}", if available { "getrandom" } else { "/dev/random" }); + available +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/wasm32_bindgen.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/wasm32_bindgen.rs new file mode 100644 index 0000000..5ab2d84 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/wasm32_bindgen.rs @@ -0,0 +1,92 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for WASM via wasm-bindgen + +use rand_core::{Error, ErrorKind}; +use super::OsRngImpl; +use super::__wbg_shims::*; + +use wasm_bindgen::prelude::*; + + +#[derive(Clone, Debug)] +pub enum OsRng { + Node(NodeCrypto), + Browser(BrowserCrypto), +} + +impl OsRngImpl for OsRng { + fn new() -> Result { + // First up we need to detect if we're running in node.js or a + // browser. To do this we get ahold of the `this` object (in a bit + // of a roundabout fashion). + // + // Once we have `this` we look at its `self` property, which is + // only defined on the web (either a main window or web worker). + let this = Function::new("return this").call(&JsValue::undefined()); + assert!(this != JsValue::undefined()); + let this = This::from(this); + let is_browser = this.self_() != JsValue::undefined(); + + if !is_browser { + return Ok(OsRng::Node(node_require("crypto"))) + } + + // If `self` is defined then we're in a browser somehow (main window + // or web worker). Here we want to try to use + // `crypto.getRandomValues`, but if `crypto` isn't defined we assume + // we're in an older web browser and the OS RNG isn't available. + let crypto = this.crypto(); + if crypto.is_undefined() { + let msg = "self.crypto is undefined"; + return Err(Error::new(ErrorKind::Unavailable, msg)) + } + + // Test if `crypto.getRandomValues` is undefined as well + let crypto: BrowserCrypto = crypto.into(); + if crypto.get_random_values_fn().is_undefined() { + let msg = "crypto.getRandomValues is undefined"; + return Err(Error::new(ErrorKind::Unavailable, msg)) + } + + // Ok! `self.crypto.getRandomValues` is a defined value, so let's + // assume we can do browser crypto. + Ok(OsRng::Browser(crypto)) + } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + match *self { + OsRng::Node(ref n) => n.random_fill_sync(dest), + OsRng::Browser(ref n) => n.get_random_values(dest), + } + Ok(()) + } + + fn max_chunk_size(&self) -> usize { + match *self { + OsRng::Node(_) => usize::max_value(), + OsRng::Browser(_) => { + // see https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues + // + // where it says: + // + // > A QuotaExceededError DOMException is thrown if the + // > requested length is greater than 65536 bytes. + 65536 + } + } + } + + fn method_str(&self) -> &'static str { + match *self { + OsRng::Node(_) => "crypto.randomFillSync", + OsRng::Browser(_) => "crypto.getRandomValues", + } + } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/wasm32_stdweb.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/wasm32_stdweb.rs new file mode 100644 index 0000000..3be0ce6 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/wasm32_stdweb.rs @@ -0,0 +1,107 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for WASM via stdweb + +use std::mem; +use stdweb::unstable::TryInto; +use stdweb::web::error::Error as WebError; +use rand_core::{Error, ErrorKind}; +use super::OsRngImpl; + +#[derive(Clone, Debug)] +enum OsRngMethod { + Browser, + Node +} + +#[derive(Clone, Debug)] +pub struct OsRng(OsRngMethod); + +impl OsRngImpl for OsRng { + fn new() -> Result { + let result = js! { + try { + if ( + typeof self === "object" && + typeof self.crypto === "object" && + typeof self.crypto.getRandomValues === "function" + ) { + return { success: true, ty: 1 }; + } + + if (typeof require("crypto").randomBytes === "function") { + return { success: true, ty: 2 }; + } + + return { success: false, error: new Error("not supported") }; + } catch(err) { + return { success: false, error: err }; + } + }; + + if js!{ return @{ result.as_ref() }.success } == true { + let ty = js!{ return @{ result }.ty }; + + if ty == 1 { Ok(OsRng(OsRngMethod::Browser)) } + else if ty == 2 { Ok(OsRng(OsRngMethod::Node)) } + else { unreachable!() } + } else { + let err: WebError = js!{ return @{ result }.error }.try_into().unwrap(); + Err(Error::with_cause(ErrorKind::Unavailable, "WASM Error", err)) + } + } + + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + assert_eq!(mem::size_of::(), 4); + + let len = dest.len() as u32; + let ptr = dest.as_mut_ptr() as i32; + + let result = match self.0 { + OsRngMethod::Browser => js! { + try { + let array = new Uint8Array(@{ len }); + self.crypto.getRandomValues(array); + HEAPU8.set(array, @{ ptr }); + + return { success: true }; + } catch(err) { + return { success: false, error: err }; + } + }, + OsRngMethod::Node => js! { + try { + let bytes = require("crypto").randomBytes(@{ len }); + HEAPU8.set(new Uint8Array(bytes), @{ ptr }); + + return { success: true }; + } catch(err) { + return { success: false, error: err }; + } + } + }; + + if js!{ return @{ result.as_ref() }.success } == true { + Ok(()) + } else { + let err: WebError = js!{ return @{ result }.error }.try_into().unwrap(); + Err(Error::with_cause(ErrorKind::Unexpected, "WASM Error", err)) + } + } + + fn max_chunk_size(&self) -> usize { 65536 } + + fn method_str(&self) -> &'static str { + match self.0 { + OsRngMethod::Browser => "Crypto.getRandomValues", + OsRngMethod::Node => "crypto.randomBytes", + } + } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/src/windows.rs b/third_party/cargo/vendor/rand_os-0.1.3/src/windows.rs new file mode 100644 index 0000000..6b06c7a --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/src/windows.rs @@ -0,0 +1,44 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementation for Windows + +extern crate winapi; + +use rand_core::{Error, ErrorKind}; +use super::OsRngImpl; + +use std::io; + +use self::winapi::shared::minwindef::ULONG; +use self::winapi::um::ntsecapi::RtlGenRandom; +use self::winapi::um::winnt::PVOID; + +#[derive(Clone, Debug)] +pub struct OsRng; + +impl OsRngImpl for OsRng { + fn new() -> Result { Ok(OsRng) } + + fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> { + let ret = unsafe { + RtlGenRandom(dest.as_mut_ptr() as PVOID, dest.len() as ULONG) + }; + if ret == 0 { + return Err(Error::with_cause( + ErrorKind::Unavailable, + "couldn't generate random bytes", + io::Error::last_os_error())); + } + Ok(()) + } + + fn max_chunk_size(&self) -> usize { ::max_value() as usize } + + fn method_str(&self) -> &'static str { "RtlGenRandom" } +} diff --git a/third_party/cargo/vendor/rand_os-0.1.3/tests/mod.rs b/third_party/cargo/vendor/rand_os-0.1.3/tests/mod.rs new file mode 100644 index 0000000..2130e16 --- /dev/null +++ b/third_party/cargo/vendor/rand_os-0.1.3/tests/mod.rs @@ -0,0 +1,80 @@ +extern crate rand_os; + +use rand_os::rand_core::RngCore; +use rand_os::OsRng; + +#[test] +fn test_os_rng() { + let mut r = OsRng::new().unwrap(); + + r.next_u32(); + r.next_u64(); + + let mut v1 = [0u8; 1000]; + r.fill_bytes(&mut v1); + + let mut v2 = [0u8; 1000]; + r.fill_bytes(&mut v2); + + let mut n_diff_bits = 0; + for i in 0..v1.len() { + n_diff_bits += (v1[i] ^ v2[i]).count_ones(); + } + + // Check at least 1 bit per byte differs. p(failure) < 1e-1000 with random input. + assert!(n_diff_bits >= v1.len() as u32); +} + +#[test] +fn test_os_rng_empty() { + let mut r = OsRng::new().unwrap(); + + let mut empty = [0u8; 0]; + r.fill_bytes(&mut empty); +} + +#[test] +fn test_os_rng_huge() { + let mut r = OsRng::new().unwrap(); + + let mut huge = [0u8; 100_000]; + r.fill_bytes(&mut huge); +} + +#[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))] +#[test] +fn test_os_rng_tasks() { + use std::sync::mpsc::channel; + use std::thread; + + let mut txs = vec!(); + for _ in 0..20 { + let (tx, rx) = channel(); + txs.push(tx); + + thread::spawn(move|| { + // wait until all the tasks are ready to go. + rx.recv().unwrap(); + + // deschedule to attempt to interleave things as much + // as possible (XXX: is this a good test?) + let mut r = OsRng::new().unwrap(); + thread::yield_now(); + let mut v = [0u8; 1000]; + + for _ in 0..100 { + r.next_u32(); + thread::yield_now(); + r.next_u64(); + thread::yield_now(); + r.fill_bytes(&mut v); + thread::yield_now(); + } + }); + } + + // start all the tasks + for tx in txs.iter() { + tx.send(()).unwrap(); + } +} diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/.cargo-checksum.json b/third_party/cargo/vendor/rand_pcg-0.1.2/.cargo-checksum.json new file mode 100644 index 0000000..a21533e --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"f95c32b93b4ba4aac59fcf1d28b1818a8551a450198c075cf5720e71a5db17ef","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"82101af38b08afd05d0b09aae70b578f3d08d7fdc98ed643498e52175d85c09c","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"2234e3cefee876aeb686ad89e978bdb07bf118a1186ab1cf161bcdf69d4b4f57","README.md":"8da8a3dce4abed17df07963b65637cc150093d04d1d7354450afdcee26b0af4f","build.rs":"003108281c4f4bd7a40a93529012acc9d2555c7a4f4b3bfc3ab81d0ed92b8864","src/lib.rs":"443c6e23da72f86d4c0b24698c0d188ee984fce69e4f52d633191399b0051c6c","src/pcg128.rs":"71bc1063e56b0b906aab333438178bb3e636dd1fcdbae2c2452af9143aea5855","src/pcg64.rs":"0b36d28ec2e1cdd630473530785b3143966a4657e52f032e020bb5524be2e044","tests/lcg64xsh32.rs":"5770fb1dd2cce4843de89dccb05f79ffce9c0b8dc68487d09b30b376e8e982e3","tests/mcg128xsl64.rs":"8276f9ce83df0f76b0a242ec35fbbd6a6fcd5aacd9cd9a3b0812b538dc5a70f0"},"package":"abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/BUILD b/third_party/cargo/vendor/rand_pcg-0.1.2/BUILD new file mode 100644 index 0000000..a0040ed --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/BUILD @@ -0,0 +1,46 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted +# Unsupported target "lcg64xsh32" with type "test" omitted +# Unsupported target "mcg128xsl64" with type "test" omitted + +rust_library( + name = "rand_pcg", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/rand_core-0.4.2:rand_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.2", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/CHANGELOG.md b/third_party/cargo/vendor/rand_pcg-0.1.2/CHANGELOG.md new file mode 100644 index 0000000..6957224 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.2] - 2019-02-23 +- require `bincode` 1.1.2 for i128 auto-detection +- make `bincode` a dev-dependency again #663 +- clean up tests and Serde support + +## [0.1.1] - 2018-10-04 +- make `bincode` an explicit dependency when using Serde + +## [0.1.0] - 2018-10-04 +Initial release, including: + +- `Lcg64Xsh32` aka `Pcg32` +- `Mcg128Xsl64` aka `Pcg64Mcg` diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/COPYRIGHT b/third_party/cargo/vendor/rand_pcg-0.1.2/COPYRIGHT new file mode 100644 index 0000000..468d907 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/COPYRIGHT @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/Cargo.toml b/third_party/cargo/vendor/rand_pcg-0.1.2/Cargo.toml new file mode 100644 index 0000000..346f2f7 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/Cargo.toml @@ -0,0 +1,47 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand_pcg" +version = "0.1.2" +authors = ["The Rand Project Developers"] +build = "build.rs" +description = "Selected PCG random number generators\n" +homepage = "https://crates.io/crates/rand_pcg" +documentation = "https://rust-random.github.io/rand/rand_pcg" +readme = "README.md" +keywords = ["random", "rng", "pcg"] +categories = ["algorithms", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-random/rand" +[dependencies.rand_core] +version = "0.4" + +[dependencies.serde] +version = "1" +optional = true + +[dependencies.serde_derive] +version = "^1.0.38" +optional = true +[dev-dependencies.bincode] +version = "1.1.2" +[build-dependencies.autocfg] +version = "0.1" + +[features] +serde1 = ["serde", "serde_derive"] +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/LICENSE-APACHE b/third_party/cargo/vendor/rand_pcg-0.1.2/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/LICENSE-MIT b/third_party/cargo/vendor/rand_pcg-0.1.2/LICENSE-MIT new file mode 100644 index 0000000..d46f058 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors +Copyright 2018 Developers of the Rand project + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/README.md b/third_party/cargo/vendor/rand_pcg-0.1.2/README.md new file mode 100644 index 0000000..ae583a1 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/README.md @@ -0,0 +1,43 @@ +# rand_pcg + +[![Build Status](https://travis-ci.org/rust-random/rand.svg?branch=master)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Latest version](https://img.shields.io/crates/v/rand_pcg.svg)](https://crates.io/crates/rand_pcg) +[[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_pcg) +[![API](https://docs.rs/rand_pcg/badge.svg)](https://docs.rs/rand_pcg) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) + +Implements a selection of PCG random number generators. + +> PCG is a family of simple fast space-efficient statistically good algorithms +> for random number generation. [Melissa O'Neill, Harvey Mudd College, 2014]. + +The PCG algorithms are not suitable for cryptographic uses, but perform well +in statistical tests, use little memory and are fairly fast. +See the [pcg-random website](http://www.pcg-random.org/). + +This crate depends on [rand_core](https://crates.io/crates/rand_core) and is +part of the [Rand project](https://github.com/rust-random/rand). + +Links: + +- [API documentation (master)](https://rust-random.github.io/rand/rand_pcg) +- [API documentation (docs.rs)](https://docs.rs/rand_pcg) +- [Changelog](CHANGELOG.md) + + +## Crate Features + +`rand_pcg` is `no_std` compatible by default. + +The `serde1` feature includes implementations of `Serialize` and `Deserialize` +for the included RNGs. + +## License + +`rand_pcg` is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/build.rs b/third_party/cargo/vendor/rand_pcg-0.1.2/build.rs new file mode 100644 index 0000000..06e12a4 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/build.rs @@ -0,0 +1,7 @@ +extern crate autocfg; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + let ac = autocfg::new(); + ac.emit_rustc_version(1, 26); +} diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/src/lib.rs b/third_party/cargo/vendor/rand_pcg-0.1.2/src/lib.rs new file mode 100644 index 0000000..9648e85 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/src/lib.rs @@ -0,0 +1,48 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The PCG random number generators. +//! +//! This is a native Rust implementation of a small selection of PCG generators. +//! The primary goal of this crate is simple, minimal, well-tested code; in +//! other words it is explicitly not a goal to re-implement all of PCG. +//! +//! This crate provides: +//! +//! - `Pcg32` aka `Lcg64Xsh32`, officially known as `pcg32`, a general +//! purpose RNG. This is a good choice on both 32-bit and 64-bit CPUs +//! (for 32-bit output). +//! - `Pcg64Mcg` aka `Mcg128Xsl64`, officially known as `mcg_xsl_rr_128_64`, +//! a general purpose RNG using 128-bit multiplications. This has poor +//! performance on 32-bit CPUs but is a good choice on 64-bit CPUs for +//! both 32-bit and 64-bit output. (Note: this RNG is only available using +//! Rust 1.26 or later.) +//! +//! Both of these use 16 bytes of state and 128-bit seeds, and are considered +//! value-stable (i.e. any change affecting the output given a fixed seed would +//! be considered a breaking change to the crate). + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] + +#![no_std] + +pub extern crate rand_core; + +#[cfg(feature="serde1")] extern crate serde; +#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive; + +mod pcg64; +#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] mod pcg128; + +pub use self::pcg64::{Pcg32, Lcg64Xsh32}; +#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] pub use self::pcg128::{Pcg64Mcg, Mcg128Xsl64}; diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/src/pcg128.rs b/third_party/cargo/vendor/rand_pcg-0.1.2/src/pcg128.rs new file mode 100644 index 0000000..9aff506 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/src/pcg128.rs @@ -0,0 +1,122 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2017 Paul Dicker. +// Copyright 2014-2017 Melissa O'Neill and PCG Project contributors +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! PCG random number generators + +// This is the default multiplier used by PCG for 64-bit state. +const MULTIPLIER: u128 = 0x2360_ED05_1FC6_5DA4_4385_DF64_9FCC_F645; + +use core::fmt; +use core::mem::transmute; +use rand_core::{RngCore, SeedableRng, Error, le}; + +/// A PCG random number generator (XSL 128/64 (MCG) variant). +/// +/// Permuted Congruential Generator with 128-bit state, internal Multiplicative +/// Congruential Generator, and 64-bit output via "xorshift low (bits), +/// random rotation" output function. +/// +/// This is a 128-bit MCG with the PCG-XSL-RR output function. +/// Note that compared to the standard `pcg64` (128-bit LCG with PCG-XSL-RR +/// output function), this RNG is faster, also has a long cycle, and still has +/// good performance on statistical tests. +/// +/// Note: this RNG is only available using Rust 1.26 or later. +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))] +pub struct Mcg128Xsl64 { + state: u128, +} + +/// A friendly name for `Mcg128Xsl64`. +pub type Pcg64Mcg = Mcg128Xsl64; + +impl Mcg128Xsl64 { + /// Construct an instance compatible with PCG seed. + /// + /// Note that PCG specifies a default value for the parameter: + /// + /// - `state = 0xcafef00dd15ea5e5` + pub fn new(state: u128) -> Self { + // Force low bit to 1, as in C version (C++ uses `state | 3` instead). + Mcg128Xsl64 { state: state | 1 } + } +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for Mcg128Xsl64 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Mcg128Xsl64 {{}}") + } +} + +/// We use a single 126-bit seed to initialise the state and select a stream. +/// Two `seed` bits (lowest order of last byte) are ignored. +impl SeedableRng for Mcg128Xsl64 { + type Seed = [u8; 16]; + + fn from_seed(seed: Self::Seed) -> Self { + // Read as if a little-endian u128 value: + let mut seed_u64 = [0u64; 2]; + le::read_u64_into(&seed, &mut seed_u64); + let state = (seed_u64[0] as u128) | + (seed_u64[1] as u128) << 64; + Mcg128Xsl64::new(state) + } +} + +impl RngCore for Mcg128Xsl64 { + #[inline] + fn next_u32(&mut self) -> u32 { + self.next_u64() as u32 + } + + #[inline] + fn next_u64(&mut self) -> u64 { + // prepare the LCG for the next round + let state = self.state.wrapping_mul(MULTIPLIER); + self.state = state; + + // Output function XSL RR ("xorshift low (bits), random rotation") + // Constants are for 128-bit state, 64-bit output + const XSHIFT: u32 = 64; // (128 - 64 + 64) / 2 + const ROTATE: u32 = 122; // 128 - 6 + + let rot = (state >> ROTATE) as u32; + let xsl = ((state >> XSHIFT) as u64) ^ (state as u64); + xsl.rotate_right(rot) + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + // specialisation of impls::fill_bytes_via_next; approx 3x faster + let mut left = dest; + while left.len() >= 8 { + let (l, r) = {left}.split_at_mut(8); + left = r; + let chunk: [u8; 8] = unsafe { + transmute(self.next_u64().to_le()) + }; + l.copy_from_slice(&chunk); + } + let n = left.len(); + if n > 0 { + let chunk: [u8; 8] = unsafe { + transmute(self.next_u64().to_le()) + }; + left.copy_from_slice(&chunk[..n]); + } + } + + #[inline] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/src/pcg64.rs b/third_party/cargo/vendor/rand_pcg-0.1.2/src/pcg64.rs new file mode 100644 index 0000000..9177ec2 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/src/pcg64.rs @@ -0,0 +1,141 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2017 Paul Dicker. +// Copyright 2014-2017 Melissa O'Neill and PCG Project contributors +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! PCG random number generators + +use core::fmt; +use core::mem::transmute; +use rand_core::{RngCore, SeedableRng, Error, le, impls}; + +// This is the default multiplier used by PCG for 64-bit state. +const MULTIPLIER: u64 = 6364136223846793005; + +/// A PCG random number generator (XSH RR 64/32 (LCG) variant). +/// +/// Permuted Congruential Generator with 64-bit state, internal Linear +/// Congruential Generator, and 32-bit output via "xorshift high (bits), +/// random rotation" output function. +/// +/// This is a 64-bit LCG with explicitly chosen stream with the PCG-XSH-RR +/// output function. This combination is the standard `pcg32`. +/// +/// Despite the name, this implementation uses 16 bytes (128 bit) space +/// comprising 64 bits of state and 64 bits stream selector. These are both set +/// by `SeedableRng`, using a 128-bit seed. +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))] +pub struct Lcg64Xsh32 { + state: u64, + increment: u64, +} + +/// `Lcg64Xsh32` is also officially known as `pcg32`. +pub type Pcg32 = Lcg64Xsh32; + +impl Lcg64Xsh32 { + /// Construct an instance compatible with PCG seed and stream. + /// + /// Note that PCG specifies default values for both parameters: + /// + /// - `state = 0xcafef00dd15ea5e5` + /// - `stream = 721347520444481703` + pub fn new(state: u64, stream: u64) -> Self { + // The increment must be odd, hence we discard one bit: + let increment = (stream << 1) | 1; + Lcg64Xsh32::from_state_incr(state, increment) + } + + #[inline] + fn from_state_incr(state: u64, increment: u64) -> Self { + let mut pcg = Lcg64Xsh32 { state, increment }; + // Move away from inital value: + pcg.state = pcg.state.wrapping_add(pcg.increment); + pcg.step(); + pcg + } + + #[inline] + fn step(&mut self) { + // prepare the LCG for the next round + self.state = self.state + .wrapping_mul(MULTIPLIER) + .wrapping_add(self.increment); + } +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for Lcg64Xsh32 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Lcg64Xsh32 {{}}") + } +} + +/// We use a single 127-bit seed to initialise the state and select a stream. +/// One `seed` bit (lowest bit of `seed[8]`) is ignored. +impl SeedableRng for Lcg64Xsh32 { + type Seed = [u8; 16]; + + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_u64 = [0u64; 2]; + le::read_u64_into(&seed, &mut seed_u64); + + // The increment must be odd, hence we discard one bit: + Lcg64Xsh32::from_state_incr(seed_u64[0], seed_u64[1] | 1) + } +} + +impl RngCore for Lcg64Xsh32 { + #[inline] + fn next_u32(&mut self) -> u32 { + let state = self.state; + self.step(); + + // Output function XSH RR: xorshift high (bits), followed by a random rotate + // Constants are for 64-bit state, 32-bit output + const ROTATE: u32 = 59; // 64 - 5 + const XSHIFT: u32 = 18; // (5 + 32) / 2 + const SPARE: u32 = 27; // 64 - 32 - 5 + + let rot = (state >> ROTATE) as u32; + let xsh = (((state >> XSHIFT) ^ state) >> SPARE) as u32; + xsh.rotate_right(rot) + } + + #[inline] + fn next_u64(&mut self) -> u64 { + impls::next_u64_via_u32(self) + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + // specialisation of impls::fill_bytes_via_next; approx 40% faster + let mut left = dest; + while left.len() >= 4 { + let (l, r) = {left}.split_at_mut(4); + left = r; + let chunk: [u8; 4] = unsafe { + transmute(self.next_u32().to_le()) + }; + l.copy_from_slice(&chunk); + } + let n = left.len(); + if n > 0 { + let chunk: [u8; 4] = unsafe { + transmute(self.next_u32().to_le()) + }; + left.copy_from_slice(&chunk[..n]); + } + } + + #[inline] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/tests/lcg64xsh32.rs b/third_party/cargo/vendor/rand_pcg-0.1.2/tests/lcg64xsh32.rs new file mode 100644 index 0000000..775b12c --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/tests/lcg64xsh32.rs @@ -0,0 +1,58 @@ +extern crate rand_pcg; +extern crate rand_core; +#[cfg(all(feature="serde1", test))] extern crate bincode; + +use rand_core::{RngCore, SeedableRng}; +use rand_pcg::{Lcg64Xsh32, Pcg32}; + +#[test] +fn test_lcg64xsh32_construction() { + // Test that various construction techniques produce a working RNG. + let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16]; + let mut rng1 = Lcg64Xsh32::from_seed(seed); + assert_eq!(rng1.next_u64(), 1204678643940597513); + + let mut rng2 = Lcg64Xsh32::from_rng(&mut rng1).unwrap(); + assert_eq!(rng2.next_u64(), 12384929573776311845); + + let mut rng3 = Lcg64Xsh32::seed_from_u64(0); + assert_eq!(rng3.next_u64(), 18195738587432868099); + + // This is the same as Lcg64Xsh32, so we only have a single test: + let mut rng4 = Pcg32::seed_from_u64(0); + assert_eq!(rng4.next_u64(), 18195738587432868099); +} + +#[test] +fn test_lcg64xsh32_true_values() { + // Numbers copied from official test suite. + let mut rng = Lcg64Xsh32::new(42, 54); + + let mut results = [0u32; 6]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected: [u32; 6] = [0xa15c02b7, 0x7b47f409, 0xba1d3330, + 0x83d2f293, 0xbfa4784b, 0xcbed606e]; + assert_eq!(results, expected); +} + +#[cfg(feature="serde1")] +#[test] +fn test_lcg64xsh32_serde() { + use bincode; + use std::io::{BufWriter, BufReader}; + + let mut rng = Lcg64Xsh32::seed_from_u64(0); + + let buf: Vec = Vec::new(); + let mut buf = BufWriter::new(buf); + bincode::serialize_into(&mut buf, &rng).expect("Could not serialize"); + + let buf = buf.into_inner().unwrap(); + let mut read = BufReader::new(&buf[..]); + let mut deserialized: Lcg64Xsh32 = bincode::deserialize_from(&mut read) + .expect("Could not deserialize"); + + for _ in 0..16 { + assert_eq!(rng.next_u64(), deserialized.next_u64()); + } +} diff --git a/third_party/cargo/vendor/rand_pcg-0.1.2/tests/mcg128xsl64.rs b/third_party/cargo/vendor/rand_pcg-0.1.2/tests/mcg128xsl64.rs new file mode 100644 index 0000000..3279536 --- /dev/null +++ b/third_party/cargo/vendor/rand_pcg-0.1.2/tests/mcg128xsl64.rs @@ -0,0 +1,59 @@ +#![cfg(rustc_1_26)] +extern crate rand_pcg; +extern crate rand_core; +#[cfg(all(feature="serde1", test))] extern crate bincode; + +use rand_core::{RngCore, SeedableRng}; +use rand_pcg::{Mcg128Xsl64, Pcg64Mcg}; + +#[test] +fn test_mcg128xsl64_construction() { + // Test that various construction techniques produce a working RNG. + let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16]; + let mut rng1 = Mcg128Xsl64::from_seed(seed); + assert_eq!(rng1.next_u64(), 7071994460355047496); + + let mut rng2 = Mcg128Xsl64::from_rng(&mut rng1).unwrap(); + assert_eq!(rng2.next_u64(), 12300796107712034932); + + let mut rng3 = Mcg128Xsl64::seed_from_u64(0); + assert_eq!(rng3.next_u64(), 6198063878555692194); + + // This is the same as Mcg128Xsl64, so we only have a single test: + let mut rng4 = Pcg64Mcg::seed_from_u64(0); + assert_eq!(rng4.next_u64(), 6198063878555692194); +} + +#[test] +fn test_mcg128xsl64_true_values() { + // Numbers copied from official test suite (C version). + let mut rng = Mcg128Xsl64::new(42); + + let mut results = [0u64; 6]; + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected: [u64; 6] = [0x63b4a3a813ce700a, 0x382954200617ab24, + 0xa7fd85ae3fe950ce, 0xd715286aa2887737, 0x60c92fee2e59f32c, 0x84c4e96beff30017]; + assert_eq!(results, expected); +} + +#[cfg(feature="serde1")] +#[test] +fn test_mcg128xsl64_serde() { + use bincode; + use std::io::{BufWriter, BufReader}; + + let mut rng = Mcg128Xsl64::seed_from_u64(0); + + let buf: Vec = Vec::new(); + let mut buf = BufWriter::new(buf); + bincode::serialize_into(&mut buf, &rng).expect("Could not serialize"); + + let buf = buf.into_inner().unwrap(); + let mut read = BufReader::new(&buf[..]); + let mut deserialized: Mcg128Xsl64 = bincode::deserialize_from(&mut read) + .expect("Could not deserialize"); + + for _ in 0..16 { + assert_eq!(rng.next_u64(), deserialized.next_u64()); + } +} diff --git a/third_party/cargo/vendor/rand_xorshift-0.1.1/.cargo-checksum.json b/third_party/cargo/vendor/rand_xorshift-0.1.1/.cargo-checksum.json new file mode 100644 index 0000000..ce75b59 --- /dev/null +++ b/third_party/cargo/vendor/rand_xorshift-0.1.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"8b36d20dea31334f1dabb3c4ef2c5d4f373432e5fc4f16ea247f0c8550f21e1a","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"3fdcb1949fd24244fb3e608a0bb950f3466799207f6f93759addc26fa89cea68","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"d15ff53ca6f8a7d4791343836e29fe86ce7528029a05f9f327064aaaa01a5368","src/lib.rs":"642ec47c3419708550926cc03f26ca4915e6471dd796d1f1e83b675fb5633649","tests/mod.rs":"533eb0d703ff6154c21d9655c863223e79f81da026dc4abf79c24d2705ae3813"},"package":"cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rand_xorshift-0.1.1/BUILD b/third_party/cargo/vendor/rand_xorshift-0.1.1/BUILD new file mode 100644 index 0000000..ad785fd --- /dev/null +++ b/third_party/cargo/vendor/rand_xorshift-0.1.1/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "mod" with type "test" omitted + +rust_library( + name = "rand_xorshift", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/rand_core-0.3.1:rand_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/rand_xorshift-0.1.1/CHANGELOG.md b/third_party/cargo/vendor/rand_xorshift-0.1.1/CHANGELOG.md new file mode 100644 index 0000000..539af41 --- /dev/null +++ b/third_party/cargo/vendor/rand_xorshift-0.1.1/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.1] - 2019-01-04 +- Reorganise code and tests; tweak doc + +## [0.1.0] - 2018-07-16 +- Pulled out of the Rand crate diff --git a/third_party/cargo/vendor/rand_xorshift-0.1.1/COPYRIGHT b/third_party/cargo/vendor/rand_xorshift-0.1.1/COPYRIGHT new file mode 100644 index 0000000..468d907 --- /dev/null +++ b/third_party/cargo/vendor/rand_xorshift-0.1.1/COPYRIGHT @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff --git a/third_party/cargo/vendor/rand_xorshift-0.1.1/Cargo.toml b/third_party/cargo/vendor/rand_xorshift-0.1.1/Cargo.toml new file mode 100644 index 0000000..26aa481 --- /dev/null +++ b/third_party/cargo/vendor/rand_xorshift-0.1.1/Cargo.toml @@ -0,0 +1,45 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rand_xorshift" +version = "0.1.1" +authors = ["The Rand Project Developers", "The Rust Project Developers"] +description = "Xorshift random number generator\n" +homepage = "https://crates.io/crates/rand_xorshift" +documentation = "https://rust-random.github.io/rand/rand_xorshift" +readme = "README.md" +keywords = ["random", "rng", "xorshift"] +categories = ["algorithms", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-random/rand" +[dependencies.rand_core] +version = ">=0.2, <0.4" +default-features = false + +[dependencies.serde] +version = "1" +optional = true + +[dependencies.serde_derive] +version = "^1.0.38" +optional = true +[dev-dependencies.bincode] +version = "1" + +[features] +serde1 = ["serde", "serde_derive"] +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff --git a/third_party/cargo/vendor/rand_xorshift-0.1.1/LICENSE-APACHE b/third_party/cargo/vendor/rand_xorshift-0.1.1/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/third_party/cargo/vendor/rand_xorshift-0.1.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rand_xorshift-0.1.1/LICENSE-MIT b/third_party/cargo/vendor/rand_xorshift-0.1.1/LICENSE-MIT new file mode 100644 index 0000000..d93b5ba --- /dev/null +++ b/third_party/cargo/vendor/rand_xorshift-0.1.1/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright 2018 Developers of the Rand project +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rand_xorshift-0.1.1/README.md b/third_party/cargo/vendor/rand_xorshift-0.1.1/README.md new file mode 100644 index 0000000..573ee12 --- /dev/null +++ b/third_party/cargo/vendor/rand_xorshift-0.1.1/README.md @@ -0,0 +1,45 @@ +# rand_xorshift + +[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Latest version](https://img.shields.io/crates/v/rand_xorshift.svg)](https://crates.io/crates/rand_xorshift) +[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_xorshift) +[![API](https://docs.rs/rand_xorshift/badge.svg)](https://docs.rs/rand_xorshift) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) + +Implements the Xorshift random number generator. + +The Xorshift[^1] algorithm is not suitable for cryptographic purposes +but is very fast. If you do not know for sure that it fits your +requirements, use a more secure one such as `StdRng` or `OsRng`. + +[^1]: Marsaglia, George (July 2003). + ["Xorshift RNGs"](https://www.jstatsoft.org/v08/i14/paper). + *Journal of Statistical Software*. Vol. 8 (Issue 14). + +Links: + +- [API documentation (master)](https://rust-random.github.io/rand/rand_xorshift) +- [API documentation (docs.rs)](https://docs.rs/rand_xorshift) +- [Changelog](CHANGELOG.md) + +[rand]: https://crates.io/crates/rand + + +## Crate Features + +`rand_xorshift` is `no_std` compatible. It does not require any functionality +outside of the `core` lib, thus there are no features to configure. + +The `serde1` feature includes implementations of `Serialize` and `Deserialize` +for the included RNGs. + + +## License + +`rand_xorshift` is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/third_party/cargo/vendor/rand_xorshift-0.1.1/src/lib.rs b/third_party/cargo/vendor/rand_xorshift-0.1.1/src/lib.rs new file mode 100644 index 0000000..aad74e4 --- /dev/null +++ b/third_party/cargo/vendor/rand_xorshift-0.1.1/src/lib.rs @@ -0,0 +1,123 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The xorshift random number generator. + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] + +#![no_std] + +extern crate rand_core; + +#[cfg(feature="serde1")] extern crate serde; +#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive; + +use core::num::Wrapping as w; +use core::{fmt, slice}; +use rand_core::{RngCore, SeedableRng, Error, impls, le}; + +/// An Xorshift random number generator. +/// +/// The Xorshift[^1] algorithm is not suitable for cryptographic purposes +/// but is very fast. If you do not know for sure that it fits your +/// requirements, use a more secure one such as `StdRng` or `OsRng`. +/// +/// [^1]: Marsaglia, George (July 2003). +/// ["Xorshift RNGs"](https://www.jstatsoft.org/v08/i14/paper). +/// *Journal of Statistical Software*. Vol. 8 (Issue 14). +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))] +pub struct XorShiftRng { + x: w, + y: w, + z: w, + w: w, +} + +// Custom Debug implementation that does not expose the internal state +impl fmt::Debug for XorShiftRng { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "XorShiftRng {{}}") + } +} + +impl RngCore for XorShiftRng { + #[inline] + fn next_u32(&mut self) -> u32 { + let x = self.x; + let t = x ^ (x << 11); + self.x = self.y; + self.y = self.z; + self.z = self.w; + let w_ = self.w; + self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8)); + self.w.0 + } + + #[inline] + fn next_u64(&mut self) -> u64 { + impls::next_u64_via_u32(self) + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + impls::fill_bytes_via_next(self, dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +} + +impl SeedableRng for XorShiftRng { + type Seed = [u8; 16]; + + fn from_seed(seed: Self::Seed) -> Self { + let mut seed_u32 = [0u32; 4]; + le::read_u32_into(&seed, &mut seed_u32); + + // Xorshift cannot be seeded with 0 and we cannot return an Error, but + // also do not wish to panic (because a random seed can legitimately be + // 0); our only option is therefore to use a preset value. + if seed_u32.iter().all(|&x| x == 0) { + seed_u32 = [0xBAD_5EED, 0xBAD_5EED, 0xBAD_5EED, 0xBAD_5EED]; + } + + XorShiftRng { + x: w(seed_u32[0]), + y: w(seed_u32[1]), + z: w(seed_u32[2]), + w: w(seed_u32[3]), + } + } + + fn from_rng(mut rng: R) -> Result { + let mut seed_u32 = [0u32; 4]; + loop { + unsafe { + let ptr = seed_u32.as_mut_ptr() as *mut u8; + + let slice = slice::from_raw_parts_mut(ptr, 4 * 4); + rng.try_fill_bytes(slice)?; + } + if !seed_u32.iter().all(|&x| x == 0) { break; } + } + + Ok(XorShiftRng { + x: w(seed_u32[0]), + y: w(seed_u32[1]), + z: w(seed_u32[2]), + w: w(seed_u32[3]), + }) + } +} diff --git a/third_party/cargo/vendor/rand_xorshift-0.1.1/tests/mod.rs b/third_party/cargo/vendor/rand_xorshift-0.1.1/tests/mod.rs new file mode 100644 index 0000000..8374b64 --- /dev/null +++ b/third_party/cargo/vendor/rand_xorshift-0.1.1/tests/mod.rs @@ -0,0 +1,92 @@ +extern crate rand_core; +extern crate rand_xorshift; +#[cfg(all(feature="serde1", test))] extern crate bincode; + +use rand_core::{RngCore, SeedableRng}; +use rand_xorshift::XorShiftRng; + +#[test] +fn test_xorshift_construction() { + // Test that various construction techniques produce a working RNG. + let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16]; + let mut rng1 = XorShiftRng::from_seed(seed); + assert_eq!(rng1.next_u64(), 4325440999699518727); + + let _rng2 = XorShiftRng::from_rng(rng1).unwrap(); + // Note: we cannot test the state of _rng2 because from_rng does not + // fix Endianness. This is allowed in the trait specification. +} + +#[test] +fn test_xorshift_true_values() { + let seed = [16,15,14,13, 12,11,10,9, 8,7,6,5, 4,3,2,1]; + let mut rng = XorShiftRng::from_seed(seed); + + let mut results = [0u32; 9]; + for i in results.iter_mut() { *i = rng.next_u32(); } + let expected: [u32; 9] = [ + 2081028795, 620940381, 269070770, 16943764, 854422573, 29242889, + 1550291885, 1227154591, 271695242]; + assert_eq!(results, expected); + + let mut results = [0u64; 9]; + for i in results.iter_mut() { *i = rng.next_u64(); } + let expected: [u64; 9] = [ + 9247529084182843387, 8321512596129439293, 14104136531997710878, + 6848554330849612046, 343577296533772213, 17828467390962600268, + 9847333257685787782, 7717352744383350108, 1133407547287910111]; + assert_eq!(results, expected); + + let mut results = [0u8; 32]; + rng.fill_bytes(&mut results); + let expected = [102, 57, 212, 16, 233, 130, 49, 183, + 158, 187, 44, 203, 63, 149, 45, 17, + 117, 129, 131, 160, 70, 121, 158, 155, + 224, 209, 192, 53, 10, 62, 57, 72]; + assert_eq!(results, expected); +} + +#[test] +fn test_xorshift_zero_seed() { + // Xorshift does not work with an all zero seed. + // Assert it does not panic. + let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + let mut rng = XorShiftRng::from_seed(seed); + let a = rng.next_u64(); + let b = rng.next_u64(); + assert!(a != 0); + assert!(b != a); +} + +#[test] +fn test_xorshift_clone() { + let seed = [1,2,3,4, 5,5,7,8, 8,7,6,5, 4,3,2,1]; + let mut rng1 = XorShiftRng::from_seed(seed); + let mut rng2 = rng1.clone(); + for _ in 0..16 { + assert_eq!(rng1.next_u64(), rng2.next_u64()); + } +} + +#[cfg(feature="serde1")] +#[test] +fn test_xorshift_serde() { + use bincode; + use std::io::{BufWriter, BufReader}; + + let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16]; + let mut rng = XorShiftRng::from_seed(seed); + + let buf: Vec = Vec::new(); + let mut buf = BufWriter::new(buf); + bincode::serialize_into(&mut buf, &rng).expect("Could not serialize"); + + let buf = buf.into_inner().unwrap(); + let mut read = BufReader::new(&buf[..]); + let mut deserialized: XorShiftRng = bincode::deserialize_from(&mut read) + .expect("Could not deserialize"); + + for _ in 0..16 { + assert_eq!(rng.next_u64(), deserialized.next_u64()); + } +} diff --git a/third_party/cargo/vendor/rdrand-0.4.0/.cargo-checksum.json b/third_party/cargo/vendor/rdrand-0.4.0/.cargo-checksum.json new file mode 100644 index 0000000..c7b5a11 --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"f11ed31fc1b481c7d0e24251d7d60d34442f1d25747c887c49dc9fbad7e13e59","LICENSE":"00d7b0c8bf95ea93162fccc84da96b906b15add708eade04f7ee6141f7b53141","README.mkd":"93853e9e773543ed0d0cf696b5fb151b15bddc1ad9c39996c9eb11b20a3c7ff6","appveyor.yml":"f502d8a0755b98e904a40b07e8ba270bccd729045b03c24a7db0dfbb4047b515","benches/rdrand.rs":"f3684c360d43bc8a780868c0a3af43b20d56975e03575122cee87277787cc8d0","benches/rdseed.rs":"520097b15a3f11c0c6a357e6cd23add598be22f37839bbc71040b827b05d1064","benches/std.rs":"6a5b52b070b2a594e735aa617f16fc6a861e64534634cdb61801c3297444f6fe","src/changelog.rs":"644e08c06836ecdf94f9a43aec109e9f05f9d85f00541683c72d0d3893ff8d6a","src/lib.rs":"8fc306db8a304d24c28fcefaec1849c0d8bbca97417420af7b81449c352b2e92"},"package":"678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rdrand-0.4.0/BUILD b/third_party/cargo/vendor/rdrand-0.4.0/BUILD new file mode 100644 index 0000000..d4d2392 --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/BUILD @@ -0,0 +1,48 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "ISC" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "rdrand" with type "bench" omitted + +rust_library( + name = "rdrand", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/rand_core-0.3.1:rand_core", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.0", + crate_features = [ + "default", + "std", + ], +) + +# Unsupported target "rdseed" with type "bench" omitted +# Unsupported target "std" with type "bench" omitted diff --git a/third_party/cargo/vendor/rdrand-0.4.0/Cargo.toml b/third_party/cargo/vendor/rdrand-0.4.0/Cargo.toml new file mode 100644 index 0000000..6b3c80a --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/Cargo.toml @@ -0,0 +1,28 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rdrand" +version = "0.4.0" +authors = ["Simonas Kazlauskas "] +description = "An implementation of random number generator based on rdrand and rdseed instructions" +documentation = "https://docs.rs/rdrand/0.4.0/" +keywords = ["rand", "rdrand", "rdseed", "random"] +license = "ISC" +repository = "https://github.com/nagisa/rust_rdrand/" +[dependencies.rand_core] +version = "0.3" +default-features = false + +[features] +default = ["std"] +std = [] diff --git a/third_party/cargo/vendor/rdrand-0.4.0/LICENSE b/third_party/cargo/vendor/rdrand-0.4.0/LICENSE new file mode 100644 index 0000000..4d6f40d --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/LICENSE @@ -0,0 +1,12 @@ +Copyright © 2014, Simonas Kazlauskas + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without +fee is hereby granted, provided that the above copyright notice and this permission notice appear +in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. diff --git a/third_party/cargo/vendor/rdrand-0.4.0/README.mkd b/third_party/cargo/vendor/rdrand-0.4.0/README.mkd new file mode 100644 index 0000000..55ab48b --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/README.mkd @@ -0,0 +1,8 @@ +An implementation of random number generators based on `rdrand` and `rdseed` instructions. + +The random number generators provided by this crate are fairly slow (the latency for these +instructions is pretty high), but provide high quality random bits. Caveat is: neither AMD’s +nor Intel’s designs are public and therefore are not verifiable for lack of backdoors. + +Unless you know what you are doing, use the random number generators provided by the `rand` +crate (such as `EntropyRng`) instead. diff --git a/third_party/cargo/vendor/rdrand-0.4.0/appveyor.yml b/third_party/cargo/vendor/rdrand-0.4.0/appveyor.yml new file mode 100644 index 0000000..2e915cf --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/appveyor.yml @@ -0,0 +1,27 @@ +environment: + matrix: + - TARGET: 1.30.0-x86_64-pc-windows-msvc + - TARGET: 1.30.0-i686-pc-windows-msvc + - TARGET: 1.30.0-x86_64-pc-windows-gnu + - TARGET: 1.30.0-i686-pc-windows-gnu + - TARGET: nightly-x86_64-pc-windows-msvc + - TARGET: nightly-i686-pc-windows-msvc +install: + - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:TARGET}.exe" -FileName "rust.exe" + - ps: .\rust.exe /VERYSILENT /NORESTART /DIR="C:\rust" | Out-Null + - ps: $env:PATH="$env:PATH;C:\rust\bin" + - rustc -vV + - cargo -vV +build: off + +test_script: +- cargo test +- cargo test --no-default-features + +for: +- matrix: + only: + - TARGET: nightly-x86_64-pc-windows-msvc + - TARGET: nightly-i686-pc-windows-msvc + test_script: + - cargo bench diff --git a/third_party/cargo/vendor/rdrand-0.4.0/benches/rdrand.rs b/third_party/cargo/vendor/rdrand-0.4.0/benches/rdrand.rs new file mode 100644 index 0000000..7e70c23 --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/benches/rdrand.rs @@ -0,0 +1,49 @@ +#![feature(test)] +extern crate rand_core; +extern crate rdrand; +extern crate test; + +use rand_core::RngCore; +use test::Bencher; + +#[bench] +fn bench_u16(b : &mut Bencher) { + if let Ok(gen) = rdrand::RdRand::new() { + b.bytes = 2; + b.iter(|| { + gen.try_next_u16().unwrap() + }); + } +} + +#[bench] +fn bench_u32(b : &mut Bencher) { + if let Ok(mut gen) = rdrand::RdRand::new() { + b.bytes = 4; + b.iter(|| { + gen.next_u32() + }); + } +} + +#[bench] +fn bench_u64(b : &mut Bencher) { + if let Ok(mut gen) = rdrand::RdRand::new() { + b.bytes = 8; + b.iter(|| { + gen.next_u64() + }); + } +} + +#[bench] +fn bench_fill(b : &mut Bencher) { + if let Ok(mut gen) = rdrand::RdRand::new() { + let mut buffer = [0; 128]; + b.bytes = 128; + b.iter(|| { + gen.fill_bytes(&mut buffer); + buffer + }); + } +} diff --git a/third_party/cargo/vendor/rdrand-0.4.0/benches/rdseed.rs b/third_party/cargo/vendor/rdrand-0.4.0/benches/rdseed.rs new file mode 100644 index 0000000..6bf8ceb --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/benches/rdseed.rs @@ -0,0 +1,49 @@ +#![feature(test)] +extern crate rand_core; +extern crate rdrand; +extern crate test; + +use rand_core::RngCore; +use test::Bencher; + +#[bench] +fn bench_rdseed_u16(b : &mut Bencher) { + if let Ok(gen) = rdrand::RdSeed::new() { + b.bytes = 2; + b.iter(|| { + gen.try_next_u16().unwrap() + }); + } +} + +#[bench] +fn bench_rdseed_u32(b : &mut Bencher) { + if let Ok(mut gen) = rdrand::RdSeed::new() { + b.bytes = 4; + b.iter(|| { + gen.next_u32() + }); + } +} + +#[bench] +fn bench_rdseed_u64(b : &mut Bencher) { + if let Ok(mut gen) = rdrand::RdSeed::new() { + b.bytes = 8; + b.iter(|| { + gen.next_u64() + }); + } +} + +#[bench] +fn bench_fill(b : &mut Bencher) { + if let Ok(mut gen) = rdrand::RdSeed::new() { + let mut buffer = [0; 128]; + b.bytes = 128; + b.iter(|| { + gen.fill_bytes(&mut buffer); + buffer + }); + } +} diff --git a/third_party/cargo/vendor/rdrand-0.4.0/benches/std.rs b/third_party/cargo/vendor/rdrand-0.4.0/benches/std.rs new file mode 100644 index 0000000..3fa8fad --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/benches/std.rs @@ -0,0 +1,31 @@ +// #![feature(test)] +// extern crate rand; +// extern crate test; +// +// use test::Bencher; +// use test::black_box; +// use rand::Rng; +// use rand::StdRng; +// use rand::OsRng; +// +// // OsRng is supposed to be the default for crypto uses. +// #[bench] +// fn bench_osrng_u64(b : &mut Bencher) { +// if let Ok(mut gen) = OsRng::new() { +// b.bytes = 8; +// b.iter(|| { +// black_box(gen.next_u64()); +// }); +// } +// } +// +// // StdRng is the default for everything else. +// #[bench] +// fn bench_stdrng_u64(b : &mut Bencher) { +// if let Ok(mut gen) = StdRng::new() { +// b.bytes = 8; +// b.iter(|| { +// gen.next_u64(); +// }); +// } +// } diff --git a/third_party/cargo/vendor/rdrand-0.4.0/src/changelog.rs b/third_party/cargo/vendor/rdrand-0.4.0/src/changelog.rs new file mode 100644 index 0000000..503f738 --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/src/changelog.rs @@ -0,0 +1,25 @@ +//! Project changelog + +/// ## Breaking changes +/// +/// Crate gained an enabled-by-default `std` feature. If you relied on rdrand being `core`-able +/// change your dependency to appear as such: +/// +/// ```toml +/// rdrand = { version = "0.4", default-features = false } +/// ``` +/// +/// This is done so that an advantage of the common feature detection functionality could be +/// employed by users that are not constrained by `core`. This functionality is faster, caches the +/// results and is shared between all users of the functionality. +/// +/// For `core` usage the feature detection has also been improved and will not be done if e.g. +/// crate is built with `rdrand` instructions enabled globally. +pub mod r0_4_0 {} + +/// Crate now works on stable! +/// +/// ## Breaking changes +/// +/// * Updated to `rand_core = ^0.3`. +pub mod r0_3_0 {} diff --git a/third_party/cargo/vendor/rdrand-0.4.0/src/lib.rs b/third_party/cargo/vendor/rdrand-0.4.0/src/lib.rs new file mode 100644 index 0000000..423ae21 --- /dev/null +++ b/third_party/cargo/vendor/rdrand-0.4.0/src/lib.rs @@ -0,0 +1,472 @@ +// Copyright © 2014, Simonas Kazlauskas +// +// Permission to use, copy, modify, and/or distribute this software for any purpose with or without +// fee is hereby granted, provided that the above copyright notice and this permission notice +// appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +// SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +// AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +// NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +// OF THIS SOFTWARE. +//! An implementation of random number generators based on `rdrand` and `rdseed` instructions. +//! +//! The random number generators provided by this crate are fairly slow (the latency for these +//! instructions is pretty high), but provide high quality random bits. Caveat is: neither AMD’s +//! nor Intel’s designs are public and therefore are not verifiable for lack of backdoors. +//! +//! Unless you know what you are doing, use the random number generators provided by the `rand` +//! crate (such as `OsRng`) instead. +//! +//! Here are a measurements for select processor architectures. Check [Agner’s instruction tables] +//! for up-to-date listings. +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//! +//!
ArchitectureLatency (cycles)Maximum throughput (per core)
u16u32u64
AMD Ryzen~1200~1200~2500~12MB/s @ 3.7GHz
Intel Skylake460460460~72MB/s @ 4.2GHz
Intel Haswell320320320~110MB/s @ 4.4GHz
+//! +//! [Agner’s instruction tables]: http://agner.org/optimize/ +#![cfg_attr(not(feature = "std"), no_std)] + +extern crate rand_core; + +#[cfg(feature = "std")] +extern crate core; + +pub mod changelog; + +use rand_core::{RngCore, CryptoRng, Error, ErrorKind}; +use core::slice; + +const RETRY_LIMIT: u8 = 127; + +#[cold] +#[inline(never)] +pub(crate) fn busy_loop_fail() -> ! { + panic!("hardware generator failure"); +} + +/// A cryptographically secure statistically uniform, non-periodic and non-deterministic random bit +/// generator. +/// +/// Note that this generator may be implemented using a deterministic algorithm that is reseeded +/// routinely from a non-deterministic entropy source to achieve the desirable properties. +/// +/// This generator is a viable replacement to any generator, however, since nobody has audited +/// Intel or AMD hardware yet, the usual disclaimers as to their suitability apply. +/// +/// It is potentially faster than `OsRng`, but is only supported on more recent Intel (Ivy Bridge +/// and later) and AMD (Ryzen and later) processors. +#[derive(Clone, Copy)] +pub struct RdRand(()); + +/// A cryptographically secure non-deterministic random bit generator. +/// +/// This generator produces high-entropy output and is suited to seed other pseudo-random +/// generators. +/// +/// This instruction currently is only available in Intel Broadwell (and later) and AMD Ryzen +/// processors. +/// +/// This generator is not intended for general random number generation purposes and should be used +/// to seed other generators implementing [rand_core::SeedableRng]. +#[derive(Clone, Copy)] +pub struct RdSeed(()); + +impl CryptoRng for RdRand {} +impl CryptoRng for RdSeed {} + +mod arch { + #[cfg(target_arch = "x86_64")] + pub use core::arch::x86_64::*; + #[cfg(target_arch = "x86")] + pub use core::arch::x86::*; + + #[cfg(target_arch = "x86")] + pub(crate) unsafe fn _rdrand64_step(dest: &mut u64) -> i32 { + let mut ret1: u32 = ::core::mem::uninitialized(); + let mut ret2: u32 = ::core::mem::uninitialized(); + if _rdrand32_step(&mut ret1) != 0 && _rdrand32_step(&mut ret2) != 0 { + *dest = (ret1 as u64) << 32 | (ret2 as u64); + 1 + } else { + 0 + } + } + + #[cfg(target_arch = "x86")] + pub(crate) unsafe fn _rdseed64_step(dest: &mut u64) -> i32 { + let mut ret1: u32 = ::core::mem::uninitialized(); + let mut ret2: u32 = ::core::mem::uninitialized(); + if _rdseed32_step(&mut ret1) != 0 && _rdseed32_step(&mut ret2) != 0 { + *dest = (ret1 as u64) << 32 | (ret2 as u64); + 1 + } else { + 0 + } + } +} + +#[cfg(not(feature = "std"))] +macro_rules! is_x86_feature_detected { + ("rdrand") => {{ + if cfg!(target_feature="rdrand") { + true + } else if cfg!(target_env = "sgx") { + false + } else { + const FLAG : u32 = 1 << 30; + unsafe { ::arch::__cpuid(1).ecx & FLAG == FLAG } + } + }}; + ("rdseed") => {{ + if cfg!(target_feature = "rdseed") { + true + } else if cfg!(target_env = "sgx") { + false + } else { + const FLAG : u32 = 1 << 18; + unsafe { ::arch::__cpuid(7).ebx & FLAG == FLAG } + } + }}; +} + +macro_rules! loop_rand { + ($el: ty, $step: path) => { { + let mut idx = 0; + loop { + let mut el: $el = ::core::mem::uninitialized(); + if $step(&mut el) != 0 { + break Some(el); + } else if idx == RETRY_LIMIT { + break None; + } + idx += 1; + } + } } +} + +macro_rules! impl_rand { + ($gen:ident, $feat:tt, $step16: path, $step32:path, $step64:path, + maxstep = $maxstep:path, maxty = $maxty: ty) => { + impl $gen { + /// Create a new instance of the random number generator. + /// + /// This constructor checks whether the CPU the program is running on supports the + /// instruction necessary for this generator to operate. If the instruction is not + /// supported, an error is returned. + pub fn new() -> Result { + if is_x86_feature_detected!($feat) { + Ok($gen(())) + } else { + Err(Error::new(rand_core::ErrorKind::Unavailable, + "the instruction is not supported")) + } + } + + /// Generate a single random `u16` value. + /// + /// The underlying instruction may fail for variety reasons (such as actual hardware + /// failure or exhausted entropy), however the exact reason for the failure is not + /// usually exposed. + /// + /// This method will retry calling the instruction a few times, however if all the + /// attempts fail, it will return `None`. + /// + /// In case `None` is returned, the caller should assume that an non-recoverable + /// hardware failure has occured and use another random number genrator instead. + #[inline(always)] + pub fn try_next_u16(&self) -> Option { + #[target_feature(enable = $feat)] + unsafe fn imp() + -> Option { + loop_rand!(u16, $step16) + } + unsafe { imp() } + } + + /// Generate a single random `u32` value. + /// + /// The underlying instruction may fail for variety reasons (such as actual hardware + /// failure or exhausted entropy), however the exact reason for the failure is not + /// usually exposed. + /// + /// This method will retry calling the instruction a few times, however if all the + /// attempts fail, it will return `None`. + /// + /// In case `None` is returned, the caller should assume that an non-recoverable + /// hardware failure has occured and use another random number genrator instead. + #[inline(always)] + pub fn try_next_u32(&self) -> Option { + #[target_feature(enable = $feat)] + unsafe fn imp() + -> Option { + loop_rand!(u32, $step32) + } + unsafe { imp() } + } + + /// Generate a single random `u64` value. + /// + /// The underlying instruction may fail for variety reasons (such as actual hardware + /// failure or exhausted entropy), however the exact reason for the failure is not + /// usually exposed. + /// + /// This method will retry calling the instruction a few times, however if all the + /// attempts fail, it will return `None`. + /// + /// In case `None` is returned, the caller should assume that an non-recoverable + /// hardware failure has occured and use another random number genrator instead. + /// + /// Note, that on 32-bit targets, there’s no underlying instruction to generate a + /// 64-bit number, so it is emulated with the 32-bit version of the instruction. + #[inline(always)] + pub fn try_next_u64(&self) -> Option { + #[target_feature(enable = $feat)] + unsafe fn imp() + -> Option { + loop_rand!(u64, $step64) + } + unsafe { imp() } + } + } + + impl RngCore for $gen { + /// Generate a single random `u32` value. + /// + /// The underlying instruction may fail for variety reasons (such as actual hardware + /// failure or exhausted entropy), however the exact reason for the failure is not + /// usually exposed. + /// + /// # Panic + /// + /// This method will retry calling the instruction a few times, however if all the + /// attempts fail, it will `panic`. + /// + /// In case `panic` occurs, the caller should assume that an non-recoverable + /// hardware failure has occured and use another random number genrator instead. + #[inline(always)] + fn next_u32(&mut self) -> u32 { + if let Some(result) = self.try_next_u32() { + result + } else { + busy_loop_fail() + } + } + + /// Generate a single random `u64` value. + /// + /// The underlying instruction may fail for variety reasons (such as actual hardware + /// failure or exhausted entropy), however the exact reason for the failure is not + /// usually exposed. + /// + /// Note, that on 32-bit targets, there’s no underlying instruction to generate a + /// 64-bit number, so it is emulated with the 32-bit version of the instruction. + /// + /// # Panic + /// + /// This method will retry calling the instruction a few times, however if all the + /// attempts fail, it will `panic`. + /// + /// In case `panic` occurs, the caller should assume that an non-recoverable + /// hardware failure has occured and use another random number genrator instead. + #[inline(always)] + fn next_u64(&mut self) -> u64 { + if let Some(result) = self.try_next_u64() { + result + } else { + busy_loop_fail() + } + } + + /// Fill a buffer `dest` with random data. + /// + /// See `try_fill_bytes` for a more extensive documentation. + /// + /// # Panic + /// + /// This method will panic any time `try_fill_bytes` would return an error. + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + if let Err(_) = self.try_fill_bytes(dest) { + busy_loop_fail() + } + } + + /// Fill a buffer `dest` with random data. + /// + /// This method will use the most appropriate variant of the instruction available on + /// the machine to achieve the greatest single-core throughput, however it has a + /// slightly higher setup cost than the plain `next_u32` or `next_u64` methods. + /// + /// The underlying instruction may fail for variety reasons (such as actual hardware + /// failure or exhausted entropy), however the exact reason for the failure is not + /// usually exposed. + /// + /// This method will retry calling the instruction a few times, however if all the + /// attempts fail, it will return an error. + /// + /// If an error is returned, the caller should assume that an non-recoverable hardware + /// failure has occured and use another random number genrator instead. + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) + -> Result<(), Error> { + #[target_feature(enable = $feat)] + unsafe fn imp(dest: &mut [u8]) + -> Result<(), Error> + { + unsafe fn imp_less_fast(mut dest: &mut [u8], word: &mut $maxty, + buffer: &mut &[u8]) + -> Result<(), Error> + { + while !dest.is_empty() { + if buffer.is_empty() { + if let Some(w) = loop_rand!($maxty, $maxstep) { + *word = w; + *buffer = slice::from_raw_parts( + word as *const _ as *const u8, + ::core::mem::size_of::<$maxty>() + ); + } else { + return Err(Error::new(ErrorKind::Unexpected, + "hardware generator failure")); + } + } + + let len = dest.len().min(buffer.len()); + let (copy_src, leftover) = buffer.split_at(len); + let (copy_dest, dest_leftover) = { dest }.split_at_mut(len); + *buffer = leftover; + dest = dest_leftover; + ::core::ptr::copy_nonoverlapping( + copy_src.as_ptr(), copy_dest.as_mut_ptr(), len + ); + } + Ok(()) + } + + let destlen = dest.len(); + if destlen > ::core::mem::size_of::<$maxty>() { + let (left, mid, right) = dest.align_to_mut(); + let mut word = 0; + let mut buffer: &[u8] = &[]; + + for el in mid { + if let Some(val) = loop_rand!($maxty, $maxstep) { + *el = val; + } else { + return Err(Error::new(ErrorKind::Unexpected, + "hardware generator failure")); + } + } + + imp_less_fast(left, &mut word, &mut buffer)?; + imp_less_fast(right, &mut word, &mut buffer) + } else { + let mut word = 0; + let mut buffer: &[u8] = &[]; + imp_less_fast(dest, &mut word, &mut buffer) + } + } + unsafe { imp(dest) } + } + } + } +} + +#[cfg(target_arch = "x86_64")] +impl_rand!(RdRand, "rdrand", + ::arch::_rdrand16_step, ::arch::_rdrand32_step, ::arch::_rdrand64_step, + maxstep = ::arch::_rdrand64_step, maxty = u64); +#[cfg(target_arch = "x86_64")] +impl_rand!(RdSeed, "rdseed", + ::arch::_rdseed16_step, ::arch::_rdseed32_step, ::arch::_rdseed64_step, + maxstep = ::arch::_rdseed64_step, maxty = u64); +#[cfg(target_arch = "x86")] +impl_rand!(RdRand, "rdrand", + ::arch::_rdrand16_step, ::arch::_rdrand32_step, ::arch::_rdrand64_step, + maxstep = ::arch::_rdrand32_step, maxty = u32); +#[cfg(target_arch = "x86")] +impl_rand!(RdSeed, "rdseed", + ::arch::_rdseed16_step, ::arch::_rdseed32_step, ::arch::_rdseed64_step, + maxstep = ::arch::_rdseed32_step, maxty = u32); + +#[test] +fn rdrand_works() { + let _ = RdRand::new().map(|mut r| { + r.next_u32(); + r.next_u64(); + }); +} + +#[test] +fn fill_fills_all_bytes() { + let _ = RdRand::new().map(|mut r| { + let mut peach; + let mut banana; + let mut start = 0; + let mut end = 128; + 'outer: while start < end { + banana = [0; 128]; + for _ in 0..512 { + peach = [0; 128]; + r.fill_bytes(&mut peach[start..end]); + for (b, p) in banana.iter_mut().zip(peach.iter()) { + *b = *b | *p; + } + if (&banana[start..end]).iter().all(|x| *x != 0) { + assert!(banana[..start].iter().all(|x| *x == 0), "all other values must be 0"); + assert!(banana[end..].iter().all(|x| *x == 0), "all other values must be 0"); + if start < 17 { + start += 1; + } else { + end -= 3; + } + continue 'outer; + } + } + panic!("wow, we broke it? {} {} {:?}", start, end, &banana[..]) + } + }); +} + +#[test] +fn rdseed_works() { + let _ = RdSeed::new().map(|mut r| { + r.next_u32(); + r.next_u64(); + }); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/.cargo-checksum.json b/third_party/cargo/vendor/regex-1.3.3/.cargo-checksum.json new file mode 100644 index 0000000..64f88d5 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"3d2c376a75a686c9dc6b50dcb2334008bc3228c3f75f01368d4cc8f16ff1f284","Cargo.toml":"a661a3a159a0838f517a26bb0ba82aa80e61e50acbfc458890d14a9dcc2afa61","HACKING.md":"17818f7a17723608f6bdbe6388ad0a913d4f96f76a16649aaf4e274b1fa0ea97","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","PERFORMANCE.md":"c776b18758b6dc8f2f9d37e9a95261f75c5f744925e8ddf216b83953bf7467b7","README.md":"105087e75c7d1ef789508e2d28d0e38f9591449c576870eca96c852a46b8c1fe","UNICODE.md":"27be97e94d0819ae18ae71029559c3de21c8ffd343d4a791959d0fc22b06dfe6","examples/regexdna-input.txt":"156a49710bb3e1ed4bc2bbb0af0f383b747b3d0281453cfff39c296124c598f8","examples/regexdna-output.txt":"35e85b19b70a893d752fd43e54e1e9da08bac43559191cea85b33387c24c4cc1","examples/shootout-regex-dna-bytes.rs":"e4f0d94e6d9cd4c7f6e340ed51b163f3331ce616dba4539d09f40919548d81d3","examples/shootout-regex-dna-cheat.rs":"bd5f4832c9a2e6f175d79064b2c4ee28dcae4b971f9618586664f99963bd0f8e","examples/shootout-regex-dna-replace.rs":"056e9ee51327a1cf9bd1da007e8c0af9c80a3e7fc2b3a3f63d0cf1b6b244ac74","examples/shootout-regex-dna-single-cheat.rs":"0beeb210972597db3a5c41901c78d78635681a833eba059064b28902e41d6f86","examples/shootout-regex-dna-single.rs":"a5d1ad8ebcfe9dd58bddc0d1ad838112cbce780f8f93c46892a70a1e25fd7c7f","examples/shootout-regex-dna.rs":"7724deec3d94cc5b55077380f7b9664edb5a49eaaa4cc7ba8356579c2ade7129","rustfmt.toml":"1ca600239a27401c4a43f363cf3f38183a212affc1f31bff3ae93234bbaec228","src/backtrack.rs":"bb24a32bc0d2f2f1c94439d8d0879ad8d15c910d4b9ab86c2833d93945cb088c","src/cache.rs":"df7b83b4f7278705ad1ecdf1284b962cc3b145797f1676c9a59e32c5944c848c","src/compile.rs":"a582b97efaf0fedca0b116c3124e067f2b28ff9b0e6240c905359cd7d5d8f5e9","src/dfa.rs":"69cd7ec8e766f4c7f056a4525aa28d102068f68d03da1d0e6aa98d40fe5c7d44","src/error.rs":"4d03ca3205e373125a0c9a4270fc1c5aa7b5a661b11db3508b563945a0827301","src/exec.rs":"a27ed0cb907dab6540fdf8cc785c799d7ea17f15f1236b80341934586874cd58","src/expand.rs":"f34190d84ea59b7aee07ad2e3c9b09a3fdeef29b5e99443223397402cc68a6b4","src/find_byte.rs":"b387247b77e3269f057c3399aefe5a815032c3af918c876f80eb4b282e4eb95e","src/freqs.rs":"255555f3d95b08a5bb3bc2f38d5a06cc100a39c0f0127fe4f50c33afa1cadc65","src/input.rs":"0bb20717cb630803f78b921260c96984a38a57685f07d9aee16b12deaa1d233b","src/lib.rs":"58290928047bdd668b335cee0fe2bd1ae6213192cedc7f4cd1d07bda850c92e7","src/literal/imp.rs":"f242b29261423342e8cd941bdeb26b95eed73357fc313f8a019032374b77e056","src/literal/mod.rs":"46739643baa0cd5d1b8fc4521df3d727815c61e583af2ffca8b7b63bad3fa50e","src/pattern.rs":"e6124b403c18344675aa341faf9ae2f592193ef89f1c4a5e1cee135b8b34dd21","src/pikevm.rs":"1de81a5e785167d63a0a53e339c85b31ed323ac88d8ef117d57b03082b83175f","src/prog.rs":"f47ac3accf7bd3456bd20902c6315f4063bbb6d9570c9b2f8309a0a1566d6323","src/re_builder.rs":"3ee35fa798c824be941c03e40e5dbeef47c96c2d19aeac2e2f7ca59727ff213b","src/re_bytes.rs":"68cac90eda08b9eda8068b3fe9cd3dbbc87673b415850fd5b8c76bc4b2d2dfe6","src/re_set.rs":"b8abdd3bab254ad53a74d114feec8f7a728ef03c3b213b02efd863649e1fb92a","src/re_trait.rs":"ad63982bf34cde29038be8c9113e0681f49df455eac3de36e2d3a8a974d59048","src/re_unicode.rs":"106c86f116e1c8db77efebf4d727822e16448fa45911c8e0c071485522246ab3","src/sparse.rs":"55db5a233eb266a1d4ffc611529d90e99369282854e9153ed39d7b650573295f","src/testdata/LICENSE":"58cf078acc03da3e280a938c2bd9943f554fc9b6ced89ad93ba35ca436872899","src/testdata/README":"45f869e37f798905c773bfbe0ef19a5fb7e585cbf0b7c21b5b5a784e8cec3c14","src/testdata/basic.dat":"b5b33aa89d48a61cd67cb1fbfd8f70e62c83e30b86256f9f915a5190dd38ff06","src/testdata/nullsubexpr.dat":"496ac0278eec3b6d9170faace14554569032dd3d909618364d9326156de39ecf","src/testdata/repetition.dat":"1f7959063015b284b18a4a2c1c8b416d438a2d6c4b1a362da43406b865f50e69","src/utf8.rs":"708615a4859110cc9766b342a9c1da6c5c4a8a04ad239046b2725385db977efe","test":"bd7ca64a788d1f622ae10c5ac77160b10fc5f0d6adb7f3ba1828637f0ca68c81","tests/api.rs":"f814376a0fdc79a95d915137ba0d80e85a6b25d253870d4b9ca4e1d9ae90f317","tests/api_str.rs":"2ae38c04e7e8fac008b609a820d0b1561ba75f39b0edc0987d6d3d06132da77f","tests/bytes.rs":"edc50f526c5fee43df89d639ef18b237e4eb91e9d533bfc43f3cbab7417d38ba","tests/consistent.rs":"8dadc60727306de8a539325d1d2af84172e5da2cbf50a71bb0c53eafe8039912","tests/crates_regex.rs":"91a59d470e0700b4bcb3ff735d06799f3107b8ef4875a2e9904607b164be0326","tests/crazy.rs":"5f1e925ed35ffa0b3c7e3bde691a7ae7ca75133a8956f5cab4ece01de1ba28b5","tests/flags.rs":"05caace2c81a99d2168037f3a38035d4dffe9f85ef3ebd7ef18b1bc6612f1ea8","tests/fowler.rs":"d78cf914de40b1e125cc92b65ccb444d462586bd07b5e05de4e4a1b5de16aa76","tests/macros.rs":"6db70c16fc90df13e6b30d2b606f8b6dd4dc976697967f6ee001b15aab6d0b19","tests/macros_bytes.rs":"73e2979f60acb009066c3a9a6c5809a0069a60c67fff7db675ea4e59299a7292","tests/macros_str.rs":"4c79ff4f2f5c379503794dd7e4116b3e7d4ac7679e47b81959fa054110a76c1a","tests/misc.rs":"395f52793fa022e4cdda78675b6a6fba1a3106b4b99c834c39f7801574054bd1","tests/multiline.rs":"1b1a3326ed976437c1357f01d81833ece7ea244f38826246eab55cacd5d0862a","tests/noparse.rs":"8850d31cb95e413e3a67edecce8590cd158f49779abcc2e5722381113346179c","tests/regression.rs":"a0f48b457c606eb572816730e41f473bbe1bfcd699bd4fdac1c98fa6477ee522","tests/replace.rs":"fb3dd97c2877b71973065a74916cdef40d65a19a92c1ecfc117edfcd9eab3ced","tests/searcher.rs":"ce35e47b0a276a7e8c9060c6a0b225ffba163aebc61fbc15555a6897fa0e552c","tests/set.rs":"cc1c5431d81b43eb7d89bf786d32657c32d7c73098c1df7dc998416c81b84591","tests/shortest_match.rs":"a2c94390c0d61bc24796b4c1288c924e90c8c9c6156fdebb858175177a194a42","tests/suffix_reverse.rs":"b95f89397404871227d9efe6df23b9ded147f183db81597e608f693955c668b5","tests/test_backtrack.rs":"1e286679d643887f7b78ef5a74f5392ff27fa462b99891ce31938db1eacb3842","tests/test_backtrack_bytes.rs":"f66f2ed407795e92ae66eaa3b4b946acfe00d9ea422944c86353dd28812df5bb","tests/test_backtrack_utf8bytes.rs":"9d8c236fbdfa5092230f19ca4d2a7d647f68811d9ffa0813899d924e11d8fc0b","tests/test_crates_regex.rs":"b385d7ca10ed308b8d57074adb9525e18d3faadb5aa883e831dfa4f6669ba58d","tests/test_default.rs":"ea1049e7bc9e40fb0da31a584aeb7f0e2b5dfd61ad10fb58184de2bd44b542cd","tests/test_default_bytes.rs":"fb3310fc315f7282358dcd98d156c31d66ca2432199afe012cf8921f459167a2","tests/test_nfa.rs":"97266c5edb15e5cde1496049a3ad0be4de33352dc32492f086d5351411ebe1ab","tests/test_nfa_bytes.rs":"9aa510e9583f847467c26ce902bd7e1c66cdd610cd50da4a1c1379afa35d4a53","tests/test_nfa_utf8bytes.rs":"2c22e16fa75edb5dbd278f2b8619404404a95b0792b31c440c9751c4aa2f7086","tests/unicode.rs":"7127b140a00cdcc46b57a59139d13bda57675a55a6604bcd10e134c32e84fa52","tests/word_boundary.rs":"7081317ddcec1e82dd4a2090a571c6abf2ff4bbfa8cd10395e1eb3f386157fae","tests/word_boundary_ascii.rs":"cd0be5b5b485de0ba7994b42e2864585556c3d2d8bf5eab05b58931d9aaf4b87","tests/word_boundary_unicode.rs":"75dbcc35d3abc0f9795c2ea99e216dc227b0a5b58e9ca5eef767815ff0513921"},"package":"b5508c1941e4e7cb19965abef075d35a9a8b5cdf0846f30b4050e9b55dc55e87"} \ No newline at end of file diff --git a/third_party/cargo/vendor/regex-1.3.3/BUILD b/third_party/cargo/vendor/regex-1.3.3/BUILD new file mode 100644 index 0000000..3f09cd2 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/BUILD @@ -0,0 +1,80 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "MIT OR Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "backtrack" with type "test" omitted +# Unsupported target "backtrack-bytes" with type "test" omitted +# Unsupported target "backtrack-utf8bytes" with type "test" omitted +# Unsupported target "crates-regex" with type "test" omitted +# Unsupported target "default" with type "test" omitted +# Unsupported target "default-bytes" with type "test" omitted +# Unsupported target "nfa" with type "test" omitted +# Unsupported target "nfa-bytes" with type "test" omitted +# Unsupported target "nfa-utf8bytes" with type "test" omitted + +rust_library( + name = "regex", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/aho-corasick-0.7.6:aho_corasick", + "//third_party/cargo/vendor/memchr-2.3.0:memchr", + "//third_party/cargo/vendor/regex-syntax-0.6.13:regex_syntax", + "//third_party/cargo/vendor/thread_local-1.0.1:thread_local", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.3.3", + crate_features = [ + "aho-corasick", + "default", + "memchr", + "perf", + "perf-cache", + "perf-dfa", + "perf-inline", + "perf-literal", + "regex-syntax", + "std", + "thread_local", + "unicode", + "unicode-age", + "unicode-bool", + "unicode-case", + "unicode-gencat", + "unicode-perl", + "unicode-script", + "unicode-segment", + ], +) + +# Unsupported target "shootout-regex-dna" with type "example" omitted +# Unsupported target "shootout-regex-dna-bytes" with type "example" omitted +# Unsupported target "shootout-regex-dna-cheat" with type "example" omitted +# Unsupported target "shootout-regex-dna-replace" with type "example" omitted +# Unsupported target "shootout-regex-dna-single" with type "example" omitted +# Unsupported target "shootout-regex-dna-single-cheat" with type "example" omitted diff --git a/third_party/cargo/vendor/regex-1.3.3/CHANGELOG.md b/third_party/cargo/vendor/regex-1.3.3/CHANGELOG.md new file mode 100644 index 0000000..33d90bf --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/CHANGELOG.md @@ -0,0 +1,789 @@ +1.3.3 (2020-01-09) +================== +This is a small maintenance release that upgrades the dependency on +`thread_local` from `0.3` to `1.0`. The minimum supported Rust version remains +at Rust 1.28. + + +1.3.2 (2020-01-09) +================== +This is a small maintenance release with some house cleaning and bug fixes. + +New features: + +* [FEATURE #631](https://github.com/rust-lang/regex/issues/631): + Add a `Match::range` method an a `From for Range` impl. + +Bug fixes: + +* [BUG #521](https://github.com/rust-lang/regex/issues/521): + Corrects `/-/.splitn("a", 2)` to return `["a"]` instead of `["a", ""]`. +* [BUG #594](https://github.com/rust-lang/regex/pull/594): + Improve error reporting when writing `\p\`. +* [BUG #627](https://github.com/rust-lang/regex/issues/627): + Corrects `/-/.split("a-")` to return `["a", ""]` instead of `["a"]`. +* [BUG #633](https://github.com/rust-lang/regex/pull/633): + Squash deprecation warnings for the `std::error::Error::description` method. + + +1.3.1 (2019-09-04) +================== +This is a maintenance release with no changes in order to try to work-around +a [docs.rs/Cargo issue](https://github.com/rust-lang/docs.rs/issues/400). + + +1.3.0 (2019-09-03) +================== +This release adds a plethora of new crate features that permit users of regex +to shrink its size considerably, in exchange for giving up either functionality +(such as Unicode support) or runtime performance. When all such features are +disabled, the dependency tree for `regex` shrinks to exactly 1 crate +(`regex-syntax`). More information about the new crate features can be +[found in the docs](https://docs.rs/regex/*/#crate-features). + +Note that while this is a new minor version release, the minimum supported +Rust version for this crate remains at `1.28.0`. + +New features: + +* [FEATURE #474](https://github.com/rust-lang/regex/issues/474): + The `use_std` feature has been deprecated in favor of the `std` feature. + The `use_std` feature will be removed in regex 2. Until then, `use_std` will + remain as an alias for the `std` feature. +* [FEATURE #583](https://github.com/rust-lang/regex/issues/583): + Add a substantial number of crate features shrinking `regex`. + + +1.2.1 (2019-08-03) +================== +This release does a bit of house cleaning. Namely: + +* This repository is now using rustfmt. +* License headers have been removed from all files, in following suit with the + Rust project. +* Teddy has been removed from the `regex` crate, and is now part of the + `aho-corasick` crate. + [See `aho-corasick`'s new `packed` sub-module for details](https://docs.rs/aho-corasick/0.7.6/aho_corasick/packed/index.html). +* The `utf8-ranges` crate has been deprecated, with its functionality moving + into the + [`utf8` sub-module of `regex-syntax`](https://docs.rs/regex-syntax/0.6.11/regex_syntax/utf8/index.html). +* The `ucd-util` dependency has been dropped, in favor of implementing what + little we need inside of `regex-syntax` itself. + +In general, this is part of an ongoing (long term) effort to make optimizations +in the regex engine easier to reason about. The current code is too convoluted +and thus it is very easy to introduce new bugs. This simplification effort is +the primary motivation behind re-working the `aho-corasick` crate to not only +bundle algorithms like Teddy, but to also provide regex-like match semantics +automatically. + +Moving forward, the plan is to join up with the `bstr` and `regex-automata` +crates, with the former providing more sophisticated substring search +algorithms (thereby deleting existing code in `regex`) and the latter providing +ahead-of-time compiled DFAs for cases where they are inexpensive to compute. + + +1.2.0 (2019-07-20) +================== +This release updates regex's minimum supported Rust version to 1.28, which was +release almost 1 year ago. This release also updates regex's Unicode data +tables to 12.1.0. + + +1.1.9 (2019-07-06) +================== +This release contains a bug fix that caused regex's tests to fail, due to a +dependency on an unreleased behavior in regex-syntax. + +* [BUG #593](https://github.com/rust-lang/regex/issues/593): + Move an integration-style test on error messages into regex-syntax. + + +1.1.8 (2019-07-04) +================== +This release contains a few small internal refactorings. One of which fixes +an instance of undefined behavior in a part of the SIMD code. + +Bug fixes: + +* [BUG #545](https://github.com/rust-lang/regex/issues/545): + Improves error messages when a repetition operator is used without a number. +* [BUG #588](https://github.com/rust-lang/regex/issues/588): + Removes use of a repr(Rust) union used for type punning in the Teddy matcher. +* [BUG #591](https://github.com/rust-lang/regex/issues/591): + Update docs for running benchmarks and improve failure modes. + + +1.1.7 (2019-06-09) +================== +This release fixes up a few warnings as a result of recent deprecations. + + +1.1.6 (2019-04-16) +================== +This release fixes a regression introduced by a bug fix (for +[BUG #557](https://github.com/rust-lang/regex/issues/557)) which could cause +the regex engine to enter an infinite loop. This bug was originally +[reported against ripgrep](https://github.com/BurntSushi/ripgrep/issues/1247). + + +1.1.5 (2019-04-01) +================== +This release fixes a bug in regex's dependency specification where it requires +a newer version of regex-syntax, but this wasn't communicated correctly in the +Cargo.toml. This would have been caught by a minimal version check, but this +check was disabled because the `rand` crate itself advertises incorrect +dependency specifications. + +Bug fixes: + +* [BUG #570](https://github.com/rust-lang/regex/pull/570): + Fix regex-syntax minimal version. + + +1.1.4 (2019-03-31) +================== +This release fixes a backwards compatibility regression where Regex was no +longer UnwindSafe. This was caused by the upgrade to aho-corasick 0.7, whose +AhoCorasick type was itself not UnwindSafe. This has been fixed in aho-corasick +0.7.4, which we now require. + +Bug fixes: + +* [BUG #568](https://github.com/rust-lang/regex/pull/568): + Fix an API regression where Regex was no longer UnwindSafe. + + +1.1.3 (2019-03-30) +================== +This releases fixes a few bugs and adds a performance improvement when a regex +is a simple alternation of literals. + +Performance improvements: + +* [OPT #566](https://github.com/rust-lang/regex/pull/566): + Upgrades `aho-corasick` to 0.7 and uses it for `foo|bar|...|quux` regexes. + +Bug fixes: + +* [BUG #527](https://github.com/rust-lang/regex/issues/527): + Fix a bug where the parser would panic on patterns like `((?x))`. +* [BUG #555](https://github.com/rust-lang/regex/issues/555): + Fix a bug where the parser would panic on patterns like `(?m){1,1}`. +* [BUG #557](https://github.com/rust-lang/regex/issues/557): + Fix a bug where captures could lead to an incorrect match. + + +1.1.2 (2019-02-27) +================== +This release fixes a bug found in the fix introduced in 1.1.1. + +Bug fixes: + +* [BUG edf45e6f](https://github.com/rust-lang/regex/commit/edf45e6f): + Fix bug introduced in reverse suffix literal matcher in the 1.1.1 release. + + +1.1.1 (2019-02-27) +================== +This is a small release with one fix for a bug caused by literal optimizations. + +Bug fixes: + +* [BUG 661bf53d](https://github.com/rust-lang/regex/commit/661bf53d): + Fixes a bug in the reverse suffix literal optimization. This was originally + reported + [against ripgrep](https://github.com/BurntSushi/ripgrep/issues/1203). + + +1.1.0 (2018-11-30) +================== +This is a small release with a couple small enhancements. This release also +increases the minimal supported Rust version (MSRV) to 1.24.1 (from 1.20.0). In +accordance with this crate's MSRV policy, this release bumps the minor version +number. + +Performance improvements: + +* [OPT #511](https://github.com/rust-lang/regex/pull/511), + [OPT #540](https://github.com/rust-lang/regex/pull/540): + Improve lazy DFA construction for large regex sets. + +New features: + +* [FEATURE #538](https://github.com/rust-lang/regex/pull/538): + Add Emoji and "break" Unicode properties. See [UNICODE.md](UNICODE.md). + +Bug fixes: + +* [BUG #530](https://github.com/rust-lang/regex/pull/530): + Add Unicode license (for data tables). +* Various typo/doc fixups. + + +1.0.6 (2018-11-06) +================== +This is a small release. + +Performance improvements: + +* [OPT #513](https://github.com/rust-lang/regex/pull/513): + Improve performance of compiling large Unicode classes by 8-10%. + +Bug fixes: + +* [BUG #533](https://github.com/rust-lang/regex/issues/533): + Fix definition of `[[:blank:]]` class that regressed in `regex-syntax 0.5`. + + +1.0.5 (2018-09-06) +================== +This is a small release with an API enhancement. + +New features: + +* [FEATURE #509](https://github.com/rust-lang/regex/pull/509): + Generalize impls of the `Replacer` trait. + + +1.0.4 (2018-08-25) +================== +This is a small release that bumps the quickcheck dependency. + + +1.0.3 (2018-08-24) +================== +This is a small bug fix release. + +Bug fixes: + +* [BUG #504](https://github.com/rust-lang/regex/pull/504): + Fix for Cargo's "minimal version" support. +* [BUG 1e39165f](https://github.com/rust-lang/regex/commit/1e39165f): + Fix doc examples for byte regexes. + + +1.0.2 (2018-07-18) +================== +This release exposes some new lower level APIs on `Regex` that permit +amortizing allocation and controlling the location at which a search is +performed in a more granular way. Most users of the regex crate will not +need or want to use these APIs. + +New features: + +* [FEATURE #493](https://github.com/rust-lang/regex/pull/493): + Add a few lower level APIs for amortizing allocation and more fine grained + searching. + +Bug fixes: + +* [BUG 3981d2ad](https://github.com/rust-lang/regex/commit/3981d2ad): + Correct outdated documentation on `RegexBuilder::dot_matches_new_line`. +* [BUG 7ebe4ae0](https://github.com/rust-lang/regex/commit/7ebe4ae0): + Correct outdated documentation on `Parser::allow_invalid_utf8` in the + `regex-syntax` crate. +* [BUG 24c7770b](https://github.com/rust-lang/regex/commit/24c7770b): + Fix a bug in the HIR printer where it wouldn't correctly escape meta + characters in character classes. + + +1.0.1 (2018-06-19) +================== +This release upgrades regex's Unicode tables to Unicode 11, and enables SIMD +optimizations automatically on Rust stable (1.27 or newer). + +New features: + +* [FEATURE #486](https://github.com/rust-lang/regex/pull/486): + Implement `size_hint` on `RegexSet` match iterators. +* [FEATURE #488](https://github.com/rust-lang/regex/pull/488): + Update Unicode tables for Unicode 11. +* [FEATURE #490](https://github.com/rust-lang/regex/pull/490): + SIMD optimizations are now enabled automatically in Rust stable, for versions + 1.27 and up. No compilation flags or features need to be set. CPU support + SIMD is detected automatically at runtime. + +Bug fixes: + +* [BUG #482](https://github.com/rust-lang/regex/pull/482): + Present a better compilation error when the `use_std` feature isn't used. + + +1.0.0 (2018-05-01) +================== +This release marks the 1.0 release of regex. + +While this release includes some breaking changes, most users of older versions +of the regex library should be able to migrate to 1.0 by simply bumping the +version number. The important changes are as follows: + +* We adopt Rust 1.20 as the new minimum supported version of Rust for regex. + We also tentativley adopt a policy that permits bumping the minimum supported + version of Rust in minor version releases of regex, but no patch releases. + That is, with respect to semver, we do not strictly consider bumping the + minimum version of Rust to be a breaking change, but adopt a conservative + stance as a compromise. +* Octal syntax in regular expressions has been disabled by default. This + permits better error messages that inform users that backreferences aren't + available. Octal syntax can be re-enabled via the corresponding option on + `RegexBuilder`. +* `(?-u:\B)` is no longer allowed in Unicode regexes since it can match at + invalid UTF-8 code unit boundaries. `(?-u:\b)` is still allowed in Unicode + regexes. +* The `From` impl has been removed. This formally removes + the public dependency on `regex-syntax`. +* A new feature, `use_std`, has been added and enabled by default. Disabling + the feature will result in a compilation error. In the future, this may + permit us to support `no_std` environments (w/ `alloc`) in a backwards + compatible way. + +For more information and discussion, please see +[1.0 release tracking issue](https://github.com/rust-lang/regex/issues/457). + + +0.2.11 (2018-05-01) +=================== +This release primarily contains bug fixes. Some of them resolve bugs where +the parser could panic. + +New features: + +* [FEATURE #459](https://github.com/rust-lang/regex/pull/459): + Include C++'s standard regex library and Boost's regex library in the + benchmark harness. We now include D/libphobos, C++/std, C++/boost, Oniguruma, + PCRE1, PCRE2, RE2 and Tcl in the harness. + +Bug fixes: + +* [BUG #445](https://github.com/rust-lang/regex/issues/445): + Clarify order of indices returned by RegexSet match iterator. +* [BUG #461](https://github.com/rust-lang/regex/issues/461): + Improve error messages for invalid regexes like `[\d-a]`. +* [BUG #464](https://github.com/rust-lang/regex/issues/464): + Fix a bug in the error message pretty printer that could cause a panic when + a regex contained a literal `\n` character. +* [BUG #465](https://github.com/rust-lang/regex/issues/465): + Fix a panic in the parser that was caused by applying a repetition operator + to `(?flags)`. +* [BUG #466](https://github.com/rust-lang/regex/issues/466): + Fix a bug where `\pC` was not recognized as an alias for `\p{Other}`. +* [BUG #470](https://github.com/rust-lang/regex/pull/470): + Fix a bug where literal searches did more work than necessary for anchored + regexes. + + +0.2.10 (2018-03-16) +=================== +This release primarily updates the regex crate to changes made in `std::arch` +on nightly Rust. + +New features: + +* [FEATURE #458](https://github.com/rust-lang/regex/pull/458): + The `Hir` type in `regex-syntax` now has a printer. + + +0.2.9 (2018-03-12) +================== +This release introduces a new nightly only feature, `unstable`, which enables +SIMD optimizations for certain types of regexes. No additional compile time +options are necessary, and the regex crate will automatically choose the +best CPU features at run time. As a result, the `simd` (nightly only) crate +dependency has been dropped. + +New features: + +* [FEATURE #456](https://github.com/rust-lang/regex/pull/456): + The regex crate now includes AVX2 optimizations in addition to the extant + SSSE3 optimization. + +Bug fixes: + +* [BUG #455](https://github.com/rust-lang/regex/pull/455): + Fix a bug where `(?x)[ / - ]` failed to parse. + + +0.2.8 (2018-03-12) +================== +Bug gixes: + +* [BUG #454](https://github.com/rust-lang/regex/pull/454): + Fix a bug in the nest limit checker being too aggressive. + + +0.2.7 (2018-03-07) +================== +This release includes a ground-up rewrite of the regex-syntax crate, which has +been in development for over a year. + +New features: + +* Error messages for invalid regexes have been greatly improved. You get these + automatically; you don't need to do anything. In addition to better + formatting, error messages will now explicitly call out the use of look + around. When regex 1.0 is released, this will happen for backreferences as + well. +* Full support for intersection, difference and symmetric difference of + character classes. These can be used via the `&&`, `--` and `~~` binary + operators within classes. +* A Unicode Level 1 conformat implementation of `\p{..}` character classes. + Things like `\p{scx:Hira}`, `\p{age:3.2}` or `\p{Changes_When_Casefolded}` + now work. All property name and value aliases are supported, and properties + are selected via loose matching. e.g., `\p{Greek}` is the same as + `\p{G r E e K}`. +* A new `UNICODE.md` document has been added to this repository that + exhaustively documents support for UTS#18. +* Empty sub-expressions are now permitted in most places. That is, `()+` is + now a valid regex. +* Almost everything in regex-syntax now uses constant stack space, even when + performing anaylsis that requires structural induction. This reduces the risk + of a user provided regular expression causing a stack overflow. +* [FEATURE #174](https://github.com/rust-lang/regex/issues/174): + The `Ast` type in `regex-syntax` now contains span information. +* [FEATURE #424](https://github.com/rust-lang/regex/issues/424): + Support `\u`, `\u{...}`, `\U` and `\U{...}` syntax for specifying code points + in a regular expression. +* [FEATURE #449](https://github.com/rust-lang/regex/pull/449): + Add a `Replace::by_ref` adapter for use of a replacer without consuming it. + +Bug fixes: + +* [BUG #446](https://github.com/rust-lang/regex/issues/446): + We re-enable the Boyer-Moore literal matcher. + + +0.2.6 (2018-02-08) +================== +Bug fixes: + +* [BUG #446](https://github.com/rust-lang/regex/issues/446): + Fixes a bug in the new Boyer-Moore searcher that results in a match failure. + We fix this bug by temporarily disabling Boyer-Moore. + + +0.2.5 (2017-12-30) +================== +Bug fixes: + +* [BUG #437](https://github.com/rust-lang/regex/issues/437): + Fixes a bug in the new Boyer-Moore searcher that results in a panic. + + +0.2.4 (2017-12-30) +================== +New features: + +* [FEATURE #348](https://github.com/rust-lang/regex/pull/348): + Improve performance for capture searches on anchored regex. + (Contributed by @ethanpailes. Nice work!) +* [FEATURE #419](https://github.com/rust-lang/regex/pull/419): + Expand literal searching to include Tuned Boyer-Moore in some cases. + (Contributed by @ethanpailes. Nice work!) + +Bug fixes: + +* [BUG](https://github.com/rust-lang/regex/pull/436): + The regex compiler plugin has been removed. +* [BUG](https://github.com/rust-lang/regex/pull/436): + `simd` has been bumped to `0.2.1`, which fixes a Rust nightly build error. +* [BUG](https://github.com/rust-lang/regex/pull/436): + Bring the benchmark harness up to date. + + +0.2.3 (2017-11-30) +================== +New features: + +* [FEATURE #374](https://github.com/rust-lang/regex/pull/374): + Add `impl From for &str`. +* [FEATURE #380](https://github.com/rust-lang/regex/pull/380): + Derive `Clone` and `PartialEq` on `Error`. +* [FEATURE #400](https://github.com/rust-lang/regex/pull/400): + Update to Unicode 10. + +Bug fixes: + +* [BUG #375](https://github.com/rust-lang/regex/issues/375): + Fix a bug that prevented the bounded backtracker from terminating. +* [BUG #393](https://github.com/rust-lang/regex/issues/393), + [BUG #394](https://github.com/rust-lang/regex/issues/394): + Fix bug with `replace` methods for empty matches. + + +0.2.2 (2017-05-21) +================== +New features: + +* [FEATURE #341](https://github.com/rust-lang/regex/issues/341): + Support nested character classes and intersection operation. + For example, `[\p{Greek}&&\pL]` matches greek letters and + `[[0-9]&&[^4]]` matches every decimal digit except `4`. + (Much thanks to @robinst, who contributed this awesome feature.) + +Bug fixes: + +* [BUG #321](https://github.com/rust-lang/regex/issues/321): + Fix bug in literal extraction and UTF-8 decoding. +* [BUG #326](https://github.com/rust-lang/regex/issues/326): + Add documentation tip about the `(?x)` flag. +* [BUG #333](https://github.com/rust-lang/regex/issues/333): + Show additional replacement example using curly braces. +* [BUG #334](https://github.com/rust-lang/regex/issues/334): + Fix bug when resolving captures after a match. +* [BUG #338](https://github.com/rust-lang/regex/issues/338): + Add example that uses `Captures::get` to API documentation. +* [BUG #353](https://github.com/rust-lang/regex/issues/353): + Fix RegexSet bug that caused match failure in some cases. +* [BUG #354](https://github.com/rust-lang/regex/pull/354): + Fix panic in parser when `(?x)` is used. +* [BUG #358](https://github.com/rust-lang/regex/issues/358): + Fix literal optimization bug with RegexSet. +* [BUG #359](https://github.com/rust-lang/regex/issues/359): + Fix example code in README. +* [BUG #365](https://github.com/rust-lang/regex/pull/365): + Fix bug in `rure_captures_len` in the C binding. +* [BUG #367](https://github.com/rust-lang/regex/issues/367): + Fix byte class bug that caused a panic. + + +0.2.1 +===== +One major bug with `replace_all` has been fixed along with a couple of other +touchups. + +* [BUG #312](https://github.com/rust-lang/regex/issues/312): + Fix documentation for `NoExpand` to reference correct lifetime parameter. +* [BUG #314](https://github.com/rust-lang/regex/issues/314): + Fix a bug with `replace_all` when replacing a match with the empty string. +* [BUG #316](https://github.com/rust-lang/regex/issues/316): + Note a missing breaking change from the `0.2.0` CHANGELOG entry. + (`RegexBuilder::compile` was renamed to `RegexBuilder::build`.) +* [BUG #324](https://github.com/rust-lang/regex/issues/324): + Compiling `regex` should only require one version of `memchr` crate. + + +0.2.0 +===== +This is a new major release of the regex crate, and is an implementation of the +[regex 1.0 RFC](https://github.com/rust-lang/rfcs/blob/master/text/1620-regex-1.0.md). +We are releasing a `0.2` first, and if there are no major problems, we will +release a `1.0` shortly. For `0.2`, the minimum *supported* Rust version is +1.12. + +There are a number of **breaking changes** in `0.2`. They are split into two +types. The first type correspond to breaking changes in regular expression +syntax. The second type correspond to breaking changes in the API. + +Breaking changes for regex syntax: + +* POSIX character classes now require double bracketing. Previously, the regex + `[:upper:]` would parse as the `upper` POSIX character class. Now it parses + as the character class containing the characters `:upper:`. The fix to this + change is to use `[[:upper:]]` instead. Note that variants like + `[[:upper:][:blank:]]` continue to work. +* The character `[` must always be escaped inside a character class. +* The characters `&`, `-` and `~` must be escaped if any one of them are + repeated consecutively. For example, `[&]`, `[\&]`, `[\&\&]`, `[&-&]` are all + equivalent while `[&&]` is illegal. (The motivation for this and the prior + change is to provide a backwards compatible path for adding character class + set notation.) +* A `bytes::Regex` now has Unicode mode enabled by default (like the main + `Regex` type). This means regexes compiled with `bytes::Regex::new` that + don't have the Unicode flag set should add `(?-u)` to recover the original + behavior. + +Breaking changes for the regex API: + +* `find` and `find_iter` now **return `Match` values instead of + `(usize, usize)`.** `Match` values have `start` and `end` methods, which + return the match offsets. `Match` values also have an `as_str` method, + which returns the text of the match itself. +* The `Captures` type now only provides a single iterator over all capturing + matches, which should replace uses of `iter` and `iter_pos`. Uses of + `iter_named` should use the `capture_names` method on `Regex`. +* The `at` method on the `Captures` type has been renamed to `get`, and it + now returns a `Match`. Similarly, the `name` method on `Captures` now returns + a `Match`. +* The `replace` methods now return `Cow` values. The `Cow::Borrowed` variant + is returned when no replacements are made. +* The `Replacer` trait has been completely overhauled. This should only + impact clients that implement this trait explicitly. Standard uses of + the `replace` methods should continue to work unchanged. If you implement + the `Replacer` trait, please consult the new documentation. +* The `quote` free function has been renamed to `escape`. +* The `Regex::with_size_limit` method has been removed. It is replaced by + `RegexBuilder::size_limit`. +* The `RegexBuilder` type has switched from owned `self` method receivers to + `&mut self` method receivers. Most uses will continue to work unchanged, but + some code may require naming an intermediate variable to hold the builder. +* The `compile` method on `RegexBuilder` has been renamed to `build`. +* The free `is_match` function has been removed. It is replaced by compiling + a `Regex` and calling its `is_match` method. +* The `PartialEq` and `Eq` impls on `Regex` have been dropped. If you relied + on these impls, the fix is to define a wrapper type around `Regex`, impl + `Deref` on it and provide the necessary impls. +* The `is_empty` method on `Captures` has been removed. This always returns + `false`, so its use is superfluous. +* The `Syntax` variant of the `Error` type now contains a string instead of + a `regex_syntax::Error`. If you were examining syntax errors more closely, + you'll need to explicitly use the `regex_syntax` crate to re-parse the regex. +* The `InvalidSet` variant of the `Error` type has been removed since it is + no longer used. +* Most of the iterator types have been renamed to match conventions. If you + were using these iterator types explicitly, please consult the documentation + for its new name. For example, `RegexSplits` has been renamed to `Split`. + +A number of bugs have been fixed: + +* [BUG #151](https://github.com/rust-lang/regex/issues/151): + The `Replacer` trait has been changed to permit the caller to control + allocation. +* [BUG #165](https://github.com/rust-lang/regex/issues/165): + Remove the free `is_match` function. +* [BUG #166](https://github.com/rust-lang/regex/issues/166): + Expose more knobs (available in `0.1`) and remove `with_size_limit`. +* [BUG #168](https://github.com/rust-lang/regex/issues/168): + Iterators produced by `Captures` now have the correct lifetime parameters. +* [BUG #175](https://github.com/rust-lang/regex/issues/175): + Fix a corner case in the parsing of POSIX character classes. +* [BUG #178](https://github.com/rust-lang/regex/issues/178): + Drop the `PartialEq` and `Eq` impls on `Regex`. +* [BUG #179](https://github.com/rust-lang/regex/issues/179): + Remove `is_empty` from `Captures` since it always returns false. +* [BUG #276](https://github.com/rust-lang/regex/issues/276): + Position of named capture can now be retrieved from a `Captures`. +* [BUG #296](https://github.com/rust-lang/regex/issues/296): + Remove winapi/kernel32-sys dependency on UNIX. +* [BUG #307](https://github.com/rust-lang/regex/issues/307): + Fix error on emscripten. + + +0.1.80 +====== +* [PR #292](https://github.com/rust-lang/regex/pull/292): + Fixes bug #291, which was introduced by PR #290. + +0.1.79 +====== +* Require regex-syntax 0.3.8. + +0.1.78 +====== +* [PR #290](https://github.com/rust-lang/regex/pull/290): + Fixes bug #289, which caused some regexes with a certain combination + of literals to match incorrectly. + +0.1.77 +====== +* [PR #281](https://github.com/rust-lang/regex/pull/281): + Fixes bug #280 by disabling all literal optimizations when a pattern + is partially anchored. + +0.1.76 +====== +* Tweak criteria for using the Teddy literal matcher. + +0.1.75 +====== +* [PR #275](https://github.com/rust-lang/regex/pull/275): + Improves match verification performance in the Teddy SIMD searcher. +* [PR #278](https://github.com/rust-lang/regex/pull/278): + Replaces slow substring loop in the Teddy SIMD searcher with Aho-Corasick. +* Implemented DoubleEndedIterator on regex set match iterators. + +0.1.74 +====== +* Release regex-syntax 0.3.5 with a minor bug fix. +* Fix bug #272. +* Fix bug #277. +* [PR #270](https://github.com/rust-lang/regex/pull/270): + Fixes bugs #264, #268 and an unreported where the DFA cache size could be + drastically under estimated in some cases (leading to high unexpected memory + usage). + +0.1.73 +====== +* Release `regex-syntax 0.3.4`. +* Bump `regex-syntax` dependency version for `regex` to `0.3.4`. + +0.1.72 +====== +* [PR #262](https://github.com/rust-lang/regex/pull/262): + Fixes a number of small bugs caught by fuzz testing (AFL). + +0.1.71 +====== +* [PR #236](https://github.com/rust-lang/regex/pull/236): + Fix a bug in how suffix literals were extracted, which could lead + to invalid match behavior in some cases. + +0.1.70 +====== +* [PR #231](https://github.com/rust-lang/regex/pull/231): + Add SIMD accelerated multiple pattern search. +* [PR #228](https://github.com/rust-lang/regex/pull/228): + Reintroduce the reverse suffix literal optimization. +* [PR #226](https://github.com/rust-lang/regex/pull/226): + Implements NFA state compression in the lazy DFA. +* [PR #223](https://github.com/rust-lang/regex/pull/223): + A fully anchored RegexSet can now short-circuit. + +0.1.69 +====== +* [PR #216](https://github.com/rust-lang/regex/pull/216): + Tweak the threshold for running backtracking. +* [PR #217](https://github.com/rust-lang/regex/pull/217): + Add upper limit (from the DFA) to capture search (for the NFA). +* [PR #218](https://github.com/rust-lang/regex/pull/218): + Add rure, a C API. + +0.1.68 +====== +* [PR #210](https://github.com/rust-lang/regex/pull/210): + Fixed a performance bug in `bytes::Regex::replace` where `extend` was used + instead of `extend_from_slice`. +* [PR #211](https://github.com/rust-lang/regex/pull/211): + Fixed a bug in the handling of word boundaries in the DFA. +* [PR #213](https://github.com/rust-lang/pull/213): + Added RE2 and Tcl to the benchmark harness. Also added a CLI utility from + running regexes using any of the following regex engines: PCRE1, PCRE2, + Oniguruma, RE2, Tcl and of course Rust's own regexes. + +0.1.67 +====== +* [PR #201](https://github.com/rust-lang/regex/pull/201): + Fix undefined behavior in the `regex!` compiler plugin macro. +* [PR #205](https://github.com/rust-lang/regex/pull/205): + More improvements to DFA performance. Competitive with RE2. See PR for + benchmarks. +* [PR #209](https://github.com/rust-lang/regex/pull/209): + Release 0.1.66 was semver incompatible since it required a newer version + of Rust than previous releases. This PR fixes that. (And `0.1.66` was + yanked.) + +0.1.66 +====== +* Speculative support for Unicode word boundaries was added to the DFA. This + should remove the last common case that disqualified use of the DFA. +* An optimization that scanned for suffix literals and then matched the regular + expression in reverse was removed because it had worst case quadratic time + complexity. It was replaced with a more limited optimization where, given any + regex of the form `re$`, it will be matched in reverse from the end of the + haystack. +* [PR #202](https://github.com/rust-lang/regex/pull/202): + The inner loop of the DFA was heavily optimized to improve cache locality + and reduce the overall number of instructions run on each iteration. This + represents the first use of `unsafe` in `regex` (to elide bounds checks). +* [PR #200](https://github.com/rust-lang/regex/pull/200): + Use of the `mempool` crate (which used thread local storage) was replaced + with a faster version of a similar API in @Amanieu's `thread_local` crate. + It should reduce contention when using a regex from multiple threads + simultaneously. +* PCRE2 JIT benchmarks were added. A benchmark comparison can be found + [here](https://gist.github.com/anonymous/14683c01993e91689f7206a18675901b). + (Includes a comparison with PCRE1's JIT and Oniguruma.) +* A bug where word boundaries weren't being matched correctly in the DFA was + fixed. This only affected use of `bytes::Regex`. +* [#160](https://github.com/rust-lang/regex/issues/160): + `Captures` now has a `Debug` impl. diff --git a/third_party/cargo/vendor/regex-1.3.3/Cargo.toml b/third_party/cargo/vendor/regex-1.3.3/Cargo.toml new file mode 100644 index 0000000..e156805 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/Cargo.toml @@ -0,0 +1,125 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "regex" +version = "1.3.3" +authors = ["The Rust Project Developers"] +exclude = ["/.travis.yml", "/appveyor.yml", "/ci/*", "/scripts/*"] +autotests = false +description = "An implementation of regular expressions for Rust. This implementation uses\nfinite automata and guarantees linear time matching on all inputs.\n" +homepage = "https://github.com/rust-lang/regex" +documentation = "https://docs.rs/regex" +readme = "README.md" +categories = ["text-processing"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/regex" +[profile.bench] +debug = true + +[profile.release] +debug = true + +[profile.test] +debug = true + +[lib] +doctest = false +bench = false + +[[test]] +name = "default" +path = "tests/test_default.rs" + +[[test]] +name = "default-bytes" +path = "tests/test_default_bytes.rs" + +[[test]] +name = "nfa" +path = "tests/test_nfa.rs" + +[[test]] +name = "nfa-utf8bytes" +path = "tests/test_nfa_utf8bytes.rs" + +[[test]] +name = "nfa-bytes" +path = "tests/test_nfa_bytes.rs" + +[[test]] +name = "backtrack" +path = "tests/test_backtrack.rs" + +[[test]] +name = "backtrack-utf8bytes" +path = "tests/test_backtrack_utf8bytes.rs" + +[[test]] +name = "backtrack-bytes" +path = "tests/test_backtrack_bytes.rs" + +[[test]] +name = "crates-regex" +path = "tests/test_crates_regex.rs" +[dependencies.aho-corasick] +version = "0.7.6" +optional = true + +[dependencies.memchr] +version = "2.2.1" +optional = true + +[dependencies.regex-syntax] +version = "0.6.12" +default-features = false + +[dependencies.thread_local] +version = "1" +optional = true +[dev-dependencies.doc-comment] +version = "0.3" + +[dev-dependencies.lazy_static] +version = "1" + +[dev-dependencies.quickcheck] +version = "0.8" +default-features = false + +[dev-dependencies.rand] +version = "0.6.5" + +[features] +default = ["std", "perf", "unicode"] +pattern = [] +perf = ["perf-cache", "perf-dfa", "perf-inline", "perf-literal"] +perf-cache = ["thread_local"] +perf-dfa = [] +perf-inline = [] +perf-literal = ["aho-corasick", "memchr"] +std = [] +unicode = ["unicode-age", "unicode-bool", "unicode-case", "unicode-gencat", "unicode-perl", "unicode-script", "unicode-segment"] +unicode-age = ["regex-syntax/unicode-age"] +unicode-bool = ["regex-syntax/unicode-bool"] +unicode-case = ["regex-syntax/unicode-case"] +unicode-gencat = ["regex-syntax/unicode-gencat"] +unicode-perl = ["regex-syntax/unicode-perl"] +unicode-script = ["regex-syntax/unicode-script"] +unicode-segment = ["regex-syntax/unicode-segment"] +unstable = ["pattern"] +use_std = ["std"] +[badges.appveyor] +repository = "rust-lang-libs/regex" + +[badges.travis-ci] +repository = "rust-lang/regex" diff --git a/third_party/cargo/vendor/regex-1.3.3/HACKING.md b/third_party/cargo/vendor/regex-1.3.3/HACKING.md new file mode 100644 index 0000000..34af5b5 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/HACKING.md @@ -0,0 +1,341 @@ +Your friendly guide to hacking and navigating the regex library. + +This guide assumes familiarity with Rust and Cargo, and at least a perusal of +the user facing documentation for this crate. + +If you're looking for background on the implementation in this library, then +you can do no better than Russ Cox's article series on implementing regular +expressions using finite automata: https://swtch.com/~rsc/regexp/ + + +## Architecture overview + +As you probably already know, this library executes regular expressions using +finite automata. In particular, a design goal is to make searching linear +with respect to both the regular expression and the text being searched. +Meeting that design goal on its own is not so hard and can be done with an +implementation of the Pike VM (similar to Thompson's construction, but supports +capturing groups), as described in: https://swtch.com/~rsc/regexp/regexp2.html +--- This library contains such an implementation in src/pikevm.rs. + +Making it fast is harder. One of the key problems with the Pike VM is that it +can be in more than one state at any point in time, and must shuffle capture +positions between them. The Pike VM also spends a lot of time following the +same epsilon transitions over and over again. We can employ one trick to +speed up the Pike VM: extract one or more literal prefixes from the regular +expression and execute specialized code to quickly find matches of those +prefixes in the search text. The Pike VM can then be avoided for most the +search, and instead only executed when a prefix is found. The code to find +prefixes is in the regex-syntax crate (in this repository). The code to search +for literals is in src/literals.rs. When more than one literal prefix is found, +we fall back to an Aho-Corasick DFA using the aho-corasick crate. For one +literal, we use a variant of the Boyer-Moore algorithm. Both Aho-Corasick and +Boyer-Moore use `memchr` when appropriate. The Boyer-Moore variant in this +library also uses elementary frequency analysis to choose the right byte to run +`memchr` with. + +Of course, detecting prefix literals can only take us so far. Not all regular +expressions have literal prefixes. To remedy this, we try another approach +to executing the Pike VM: backtracking, whose implementation can be found in +src/backtrack.rs. One reason why backtracking can be faster is that it avoids +excessive shuffling of capture groups. Of course, backtracking is susceptible +to exponential runtimes, so we keep track of every state we've visited to make +sure we never visit it again. This guarantees linear time execution, but we +pay for it with the memory required to track visited states. Because of the +memory requirement, we only use this engine on small search strings *and* small +regular expressions. + +Lastly, the real workhorse of this library is the "lazy" DFA in src/dfa.rs. +It is distinct from the Pike VM in that the DFA is explicitly represented in +memory and is only ever in one state at a time. It is said to be "lazy" because +the DFA is computed as text is searched, where each byte in the search text +results in at most one new DFA state. It is made fast by caching states. DFAs +are susceptible to exponential state blow up (where the worst case is computing +a new state for every input byte, regardless of what's in the state cache). To +avoid using a lot of memory, the lazy DFA uses a bounded cache. Once the cache +is full, it is wiped and state computation starts over again. If the cache is +wiped too frequently, then the DFA gives up and searching falls back to one of +the aforementioned algorithms. + +All of the above matching engines expose precisely the same matching semantics. +This is indeed tested. (See the section below about testing.) + +The following sub-sections describe the rest of the library and how each of the +matching engines are actually used. + +### Parsing + +Regular expressions are parsed using the regex-syntax crate, which is +maintained in this repository. The regex-syntax crate defines an abstract +syntax and provides very detailed error messages when a parse error is +encountered. Parsing is done in a separate crate so that others may benefit +from its existence, and because it is relatively divorced from the rest of the +regex library. + +The regex-syntax crate also provides sophisticated support for extracting +prefix and suffix literals from regular expressions. + +### Compilation + +The compiler is in src/compile.rs. The input to the compiler is some abstract +syntax for a regular expression and the output is a sequence of opcodes that +matching engines use to execute a search. (One can think of matching engines as +mini virtual machines.) The sequence of opcodes is a particular encoding of a +non-deterministic finite automaton. In particular, the opcodes explicitly rely +on epsilon transitions. + +Consider a simple regular expression like `a|b`. Its compiled form looks like +this: + + 000 Save(0) + 001 Split(2, 3) + 002 'a' (goto: 4) + 003 'b' + 004 Save(1) + 005 Match + +The first column is the instruction pointer and the second column is the +instruction. Save instructions indicate that the current position in the input +should be stored in a captured location. Split instructions represent a binary +branch in the program (i.e., epsilon transitions). The instructions `'a'` and +`'b'` indicate that the literal bytes `'a'` or `'b'` should match. + +In older versions of this library, the compilation looked like this: + + 000 Save(0) + 001 Split(2, 3) + 002 'a' + 003 Jump(5) + 004 'b' + 005 Save(1) + 006 Match + +In particular, empty instructions that merely served to move execution from one +point in the program to another were removed. Instead, every instruction has a +`goto` pointer embedded into it. This resulted in a small performance boost for +the Pike VM, because it was one fewer epsilon transition that it had to follow. + +There exist more instructions and they are defined and documented in +src/prog.rs. + +Compilation has several knobs and a few unfortunately complicated invariants. +Namely, the output of compilation can be one of two types of programs: a +program that executes on Unicode scalar values or a program that executes +on raw bytes. In the former case, the matching engine is responsible for +performing UTF-8 decoding and executing instructions using Unicode codepoints. +In the latter case, the program handles UTF-8 decoding implicitly, so that the +matching engine can execute on raw bytes. All matching engines can execute +either Unicode or byte based programs except for the lazy DFA, which requires +byte based programs. In general, both representations were kept because (1) the +lazy DFA requires byte based programs so that states can be encoded in a memory +efficient manner and (2) the Pike VM benefits greatly from inlining Unicode +character classes into fewer instructions as it results in fewer epsilon +transitions. + +N.B. UTF-8 decoding is built into the compiled program by making use of the +utf8-ranges crate. The compiler in this library factors out common suffixes to +reduce the size of huge character classes (e.g., `\pL`). + +A regrettable consequence of this split in instruction sets is we generally +need to compile two programs; one for NFA execution and one for the lazy DFA. + +In fact, it is worse than that: the lazy DFA is not capable of finding the +starting location of a match in a single scan, and must instead execute a +backwards search after finding the end location. To execute a backwards search, +we must have compiled the regular expression *in reverse*. + +This means that every compilation of a regular expression generally results in +three distinct programs. It would be possible to lazily compile the Unicode +program, since it is never needed if (1) the regular expression uses no word +boundary assertions and (2) the caller never asks for sub-capture locations. + +### Execution + +At the time of writing, there are four matching engines in this library: + +1. The Pike VM (supports captures). +2. Bounded backtracking (supports captures). +3. Literal substring or multi-substring search. +4. Lazy DFA (no support for Unicode word boundary assertions). + +Only the first two matching engines are capable of executing every regular +expression program. They also happen to be the slowest, which means we need +some logic that (1) knows various facts about the regular expression and (2) +knows what the caller wants. Using this information, we can determine which +engine (or engines) to use. + +The logic for choosing which engine to execute is in src/exec.rs and is +documented on the Exec type. Exec values contain regular expression Programs +(defined in src/prog.rs), which contain all the necessary tidbits for actually +executing a regular expression on search text. + +For the most part, the execution logic is straight-forward and follows the +limitations of each engine described above pretty faithfully. The hairiest +part of src/exec.rs by far is the execution of the lazy DFA, since it requires +a forwards and backwards search, and then falls back to either the Pike VM or +backtracking if the caller requested capture locations. + +The Exec type also contains mutable scratch space for each type of matching +engine. This scratch space is used during search (for example, for the lazy +DFA, it contains compiled states that are reused on subsequent searches). + +### Programs + +A regular expression program is essentially a sequence of opcodes produced by +the compiler plus various facts about the regular expression (such as whether +it is anchored, its capture names, etc.). + +### The regex! macro + +The `regex!` macro no longer exists. It was developed in a bygone era as a +compiler plugin during the infancy of the regex crate. Back then, then only +matching engine in the crate was the Pike VM. The `regex!` macro was, itself, +also a Pike VM. The only advantages it offered over the dynamic Pike VM that +was built at runtime were the following: + + 1. Syntax checking was done at compile time. Your Rust program wouldn't + compile if your regex didn't compile. + 2. Reduction of overhead that was proportional to the size of the regex. + For the most part, this overhead consisted of heap allocation, which + was nearly eliminated in the compiler plugin. + +The main takeaway here is that the compiler plugin was a marginally faster +version of a slow regex engine. As the regex crate evolved, it grew other regex +engines (DFA, bounded backtracker) and sophisticated literal optimizations. +The regex macro didn't keep pace, and it therefore became (dramatically) slower +than the dynamic engines. The only reason left to use it was for the compile +time guarantee that your regex is correct. Fortunately, Clippy (the Rust lint +tool) has a lint that checks your regular expression validity, which mostly +replaces that use case. + +Additionally, the regex compiler plugin stopped receiving maintenance. Nobody +complained. At that point, it seemed prudent to just remove it. + +Will a compiler plugin be brought back? The future is murky, but there is +definitely an opportunity there to build something that is faster than the +dynamic engines in some cases. But it will be challenging! As of now, there +are no plans to work on this. + + +## Testing + +A key aspect of any mature regex library is its test suite. A subset of the +tests in this library come from Glenn Fowler's AT&T test suite (its online +presence seems gone at the time of writing). The source of the test suite is +located in src/testdata. The scripts/regex-match-tests.py takes the test suite +in src/testdata and generates tests/matches.rs. + +There are also many other manually crafted tests and regression tests in +tests/tests.rs. Some of these tests were taken from RE2. + +The biggest source of complexity in the tests is related to answering this +question: how can we reuse the tests to check all of our matching engines? One +approach would have been to encode every test into some kind of format (like +the AT&T test suite) and code generate tests for each matching engine. The +approach we use in this library is to create a Cargo.toml entry point for each +matching engine we want to test. The entry points are: + +* `tests/test_default.rs` - tests `Regex::new` +* `tests/test_default_bytes.rs` - tests `bytes::Regex::new` +* `tests/test_nfa.rs` - tests `Regex::new`, forced to use the NFA + algorithm on every regex. +* `tests/test_nfa_bytes.rs` - tests `Regex::new`, forced to use the NFA + algorithm on every regex and use *arbitrary* byte based programs. +* `tests/test_nfa_utf8bytes.rs` - tests `Regex::new`, forced to use the NFA + algorithm on every regex and use *UTF-8* byte based programs. +* `tests/test_backtrack.rs` - tests `Regex::new`, forced to use + backtracking on every regex. +* `tests/test_backtrack_bytes.rs` - tests `Regex::new`, forced to use + backtracking on every regex and use *arbitrary* byte based programs. +* `tests/test_backtrack_utf8bytes.rs` - tests `Regex::new`, forced to use + backtracking on every regex and use *UTF-8* byte based programs. +* `tests/test_crates_regex.rs` - tests to make sure that all of the + backends behave in the same way against a number of quickcheck + generated random inputs. These tests need to be enabled through + the `RUST_REGEX_RANDOM_TEST` environment variable (see + below). + +The lazy DFA and pure literal engines are absent from this list because +they cannot be used on every regular expression. Instead, we rely on +`tests/test_dynamic.rs` to test the lazy DFA and literal engines when possible. + +Since the tests are repeated several times, and because `cargo test` runs all +entry points, it can take a while to compile everything. To reduce compile +times slightly, try using `cargo test --test default`, which will only use the +`tests/test_default.rs` entry point. + +The random testing takes quite a while, so it is not enabled by default. +In order to run the random testing you can set the +`RUST_REGEX_RANDOM_TEST` environment variable to anything before +invoking `cargo test`. Note that this variable is inspected at compile +time, so if the tests don't seem to be running, you may need to run +`cargo clean`. + +## Benchmarking + +The benchmarking in this crate is made up of many micro-benchmarks. Currently, +there are two primary sets of benchmarks: the benchmarks that were adopted +at this library's inception (in `bench/src/misc.rs`) and a newer set of +benchmarks meant to test various optimizations. Specifically, the latter set +contain some analysis and are in `bench/src/sherlock.rs`. Also, the latter +set are all executed on the same lengthy input whereas the former benchmarks +are executed on strings of varying length. + +There is also a smattering of benchmarks for parsing and compilation. + +Benchmarks are in a separate crate so that its dependencies can be managed +separately from the main regex crate. + +Benchmarking follows a similarly wonky setup as tests. There are multiple entry +points: + +* `bench_rust.rs` - benchmarks `Regex::new` +* `bench_rust_bytes.rs` benchmarks `bytes::Regex::new` +* `bench_pcre.rs` - benchmarks PCRE +* `bench_onig.rs` - benchmarks Oniguruma + +The PCRE and Oniguruma benchmarks exist as a comparison point to a mature +regular expression library. In general, this regex library compares favorably +(there are even a few benchmarks that PCRE simply runs too slowly on or +outright can't execute at all). I would love to add other regular expression +library benchmarks (especially RE2). + +If you're hacking on one of the matching engines and just want to see +benchmarks, then all you need to run is: + + $ (cd bench && ./run rust) + +If you want to compare your results with older benchmarks, then try: + + $ (cd bench && ./run rust | tee old) + $ ... make it faster + $ (cd bench && ./run rust | tee new) + $ cargo benchcmp old new --improvements + +The `cargo-benchcmp` utility is available here: +https://github.com/BurntSushi/cargo-benchcmp + +The `./bench/run` utility can run benchmarks for PCRE and Oniguruma too. See +`./bench/bench --help`. + +## Dev Docs + +When digging your teeth into the codebase for the first time, the +crate documentation can be a great resource. By default `rustdoc` +will strip out all documentation of private crate members in an +effort to help consumers of the crate focus on the *interface* +without having to concern themselves with the *implementation*. +Normally this is a great thing, but if you want to start hacking +on regex internals it is not what you want. Many of the private members +of this crate are well documented with rustdoc style comments, and +it would be a shame to miss out on the opportunity that presents. +You can generate the private docs with: + +``` +$ rustdoc --crate-name docs src/lib.rs -o target/doc -L target/debug/deps --no-defaults --passes collapse-docs --passes unindent-comments +``` + +Then just point your browser at `target/doc/regex/index.html`. + +See https://github.com/rust-lang/rust/issues/15347 for more info +about generating developer docs for internal use. diff --git a/third_party/cargo/vendor/regex-1.3.3/LICENSE-APACHE b/third_party/cargo/vendor/regex-1.3.3/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/regex-1.3.3/LICENSE-MIT b/third_party/cargo/vendor/regex-1.3.3/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/regex-1.3.3/PERFORMANCE.md b/third_party/cargo/vendor/regex-1.3.3/PERFORMANCE.md new file mode 100644 index 0000000..b4aeb89 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/PERFORMANCE.md @@ -0,0 +1,279 @@ +Your friendly guide to understanding the performance characteristics of this +crate. + +This guide assumes some familiarity with the public API of this crate, which +can be found here: https://docs.rs/regex + +## Theory vs. Practice + +One of the design goals of this crate is to provide worst case linear time +behavior with respect to the text searched using finite state automata. This +means that, *in theory*, the performance of this crate is much better than most +regex implementations, which typically use backtracking which has worst case +exponential time. + +For example, try opening a Python interpreter and typing this: + + >>> import re + >>> re.search('(a*)*c', 'a' * 30).span() + +I'll wait. + +At some point, you'll figure out that it won't terminate any time soon. ^C it. + +The promise of this crate is that *this pathological behavior can't happen*. + +With that said, just because we have protected ourselves against worst case +exponential behavior doesn't mean we are immune from large constant factors +or places where the current regex engine isn't quite optimal. This guide will +detail those cases and provide guidance on how to avoid them, among other +bits of general advice. + +## Thou Shalt Not Compile Regular Expressions In A Loop + +**Advice**: Use `lazy_static` to amortize the cost of `Regex` compilation. + +Don't do it unless you really don't mind paying for it. Compiling a regular +expression in this crate is quite expensive. It is conceivable that it may get +faster some day, but I wouldn't hold out hope for, say, an order of magnitude +improvement. In particular, compilation can take any where from a few dozen +microseconds to a few dozen milliseconds. Yes, milliseconds. Unicode character +classes, in particular, have the largest impact on compilation performance. At +the time of writing, for example, `\pL{100}` takes around 44ms to compile. This +is because `\pL` corresponds to every letter in Unicode and compilation must +turn it into a proper automaton that decodes a subset of UTF-8 which +corresponds to those letters. Compilation also spends some cycles shrinking the +size of the automaton. + +This means that in order to realize efficient regex matching, one must +*amortize the cost of compilation*. Trivially, if a call to `is_match` is +inside a loop, then make sure your call to `Regex::new` is *outside* that loop. + +In many programming languages, regular expressions can be conveniently defined +and compiled in a global scope, and code can reach out and use them as if +they were global static variables. In Rust, there is really no concept of +life-before-main, and therefore, one cannot utter this: + + static MY_REGEX: Regex = Regex::new("...").unwrap(); + +Unfortunately, this would seem to imply that one must pass `Regex` objects +around to everywhere they are used, which can be especially painful depending +on how your program is structured. Thankfully, the +[`lazy_static`](https://crates.io/crates/lazy_static) +crate provides an answer that works well: + + #[macro_use] extern crate lazy_static; + extern crate regex; + + use regex::Regex; + + fn some_helper_function(text: &str) -> bool { + lazy_static! { + static ref MY_REGEX: Regex = Regex::new("...").unwrap(); + } + MY_REGEX.is_match(text) + } + +In other words, the `lazy_static!` macro enables us to define a `Regex` *as if* +it were a global static value. What is actually happening under the covers is +that the code inside the macro (i.e., `Regex::new(...)`) is run on *first use* +of `MY_REGEX` via a `Deref` impl. The implementation is admittedly magical, but +it's self contained and everything works exactly as you expect. In particular, +`MY_REGEX` can be used from multiple threads without wrapping it in an `Arc` or +a `Mutex`. On that note... + +## Using a regex from multiple threads + +**Advice**: The performance impact from using a `Regex` from multiple threads +is likely negligible. If necessary, clone the `Regex` so that each thread gets +its own copy. Cloning a regex does not incur any additional memory overhead +than what would be used by using a `Regex` from multiple threads +simultaneously. *Its only cost is ergonomics.* + +It is supported and encouraged to define your regexes using `lazy_static!` as +if they were global static values, and then use them to search text from +multiple threads simultaneously. + +One might imagine that this is possible because a `Regex` represents a +*compiled* program, so that any allocation or mutation is already done, and is +therefore read-only. Unfortunately, this is not true. Each type of search +strategy in this crate requires some kind of mutable scratch space to use +*during search*. For example, when executing a DFA, its states are computed +lazily and reused on subsequent searches. Those states go into that mutable +scratch space. + +The mutable scratch space is an implementation detail, and in general, its +mutation should not be observable from users of this crate. Therefore, it uses +interior mutability. This implies that `Regex` can either only be used from one +thread, or it must do some sort of synchronization. Either choice is +reasonable, but this crate chooses the latter, in particular because it is +ergonomic and makes use with `lazy_static!` straight forward. + +Synchronization implies *some* amount of overhead. When a `Regex` is used from +a single thread, this overhead is negligible. When a `Regex` is used from +multiple threads simultaneously, it is possible for the overhead of +synchronization from contention to impact performance. The specific cases where +contention may happen is if you are calling any of these methods repeatedly +from multiple threads simultaneously: + +* shortest_match +* is_match +* find +* captures + +In particular, every invocation of one of these methods must synchronize with +other threads to retrieve its mutable scratch space before searching can start. +If, however, you are using one of these methods: + +* find_iter +* captures_iter + +Then you may not suffer from contention since the cost of synchronization is +amortized on *construction of the iterator*. That is, the mutable scratch space +is obtained when the iterator is created and retained throughout its lifetime. + +## Only ask for what you need + +**Advice**: Prefer in this order: `is_match`, `find`, `captures`. + +There are three primary search methods on a `Regex`: + +* is_match +* find +* captures + +In general, these are ordered from fastest to slowest. + +`is_match` is fastest because it doesn't actually need to find the start or the +end of the leftmost-first match. It can quit immediately after it knows there +is a match. For example, given the regex `a+` and the haystack, `aaaaa`, the +search will quit after examing the first byte. + +In constrast, `find` must return both the start and end location of the +leftmost-first match. It can use the DFA matcher for this, but must run it +forwards once to find the end of the match *and then run it backwards* to find +the start of the match. The two scans and the cost of finding the real end of +the leftmost-first match make this more expensive than `is_match`. + +`captures` is the most expensive of them all because it must do what `find` +does, and then run either the bounded backtracker or the Pike VM to fill in the +capture group locations. Both of these are simulations of an NFA, which must +spend a lot of time shuffling states around. The DFA limits the performance hit +somewhat by restricting the amount of text that must be searched via an NFA +simulation. + +One other method not mentioned is `shortest_match`. This method has precisely +the same performance characteristics as `is_match`, except it will return the +end location of when it discovered a match. For example, given the regex `a+` +and the haystack `aaaaa`, `shortest_match` may return `1` as opposed to `5`, +the latter of which being the correct end location of the leftmost-first match. + +## Literals in your regex may make it faster + +**Advice**: Literals can reduce the work that the regex engine needs to do. Use +them if you can, especially as prefixes. + +In particular, if your regex starts with a prefix literal, the prefix is +quickly searched before entering the (much slower) regex engine. For example, +given the regex `foo\w+`, the literal `foo` will be searched for using +Boyer-Moore. If there's no match, then no regex engine is ever used. Only when +there's a match is the regex engine invoked at the location of the match, which +effectively permits the regex engine to skip large portions of a haystack. +If a regex is comprised entirely of literals (possibly more than one), then +it's possible that the regex engine can be avoided entirely even when there's a +match. + +When one literal is found, Boyer-Moore is used. When multiple literals are +found, then an optimized version of Aho-Corasick is used. + +This optimization is in particular extended quite a bit in this crate. Here are +a few examples of regexes that get literal prefixes detected: + +* `(foo|bar)` detects `foo` and `bar` +* `(a|b)c` detects `ac` and `bc` +* `[ab]foo[yz]` detects `afooy`, `afooz`, `bfooy` and `bfooz` +* `a?b` detects `a` and `b` +* `a*b` detects `a` and `b` +* `(ab){3,6}` detects `ababab` + +Literals in anchored regexes can also be used for detecting non-matches very +quickly. For example, `^foo\w+` and `\w+foo$` may be able to detect a non-match +just by examing the first (or last) three bytes of the haystack. + +## Unicode word boundaries may prevent the DFA from being used + +**Advice**: In most cases, `\b` should work well. If not, use `(?-u:\b)` +instead of `\b` if you care about consistent performance more than correctness. + +It's a sad state of the current implementation. At the moment, the DFA will try +to interpret Unicode word boundaries as if they were ASCII word boundaries. +If the DFA comes across any non-ASCII byte, it will quit and fall back to an +alternative matching engine that can handle Unicode word boundaries correctly. +The alternate matching engine is generally quite a bit slower (perhaps by an +order of magnitude). If necessary, this can be ameliorated in two ways. + +The first way is to add some number of literal prefixes to your regular +expression. Even though the DFA may not be used, specialized routines will +still kick in to find prefix literals quickly, which limits how much work the +NFA simulation will need to do. + +The second way is to give up on Unicode and use an ASCII word boundary instead. +One can use an ASCII word boundary by disabling Unicode support. That is, +instead of using `\b`, use `(?-u:\b)`. Namely, given the regex `\b.+\b`, it +can be transformed into a regex that uses the DFA with `(?-u:\b).+(?-u:\b)`. It +is important to limit the scope of disabling the `u` flag, since it might lead +to a syntax error if the regex could match arbitrary bytes. For example, if one +wrote `(?-u)\b.+\b`, then a syntax error would be returned because `.` matches +any *byte* when the Unicode flag is disabled. + +The second way isn't appreciably different than just using a Unicode word +boundary in the first place, since the DFA will speculatively interpret it as +an ASCII word boundary anyway. The key difference is that if an ASCII word +boundary is used explicitly, then the DFA won't quit in the presence of +non-ASCII UTF-8 bytes. This results in giving up correctness in exchange for +more consistent performance. + +N.B. When using `bytes::Regex`, Unicode support is disabled by default, so one +can simply write `\b` to get an ASCII word boundary. + +## Excessive counting can lead to exponential state blow up in the DFA + +**Advice**: Don't write regexes that cause DFA state blow up if you care about +match performance. + +Wait, didn't I say that this crate guards against exponential worst cases? +Well, it turns out that the process of converting an NFA to a DFA can lead to +an exponential blow up in the number of states. This crate specifically guards +against exponential blow up by doing two things: + +1. The DFA is computed lazily. That is, a state in the DFA only exists in + memory if it is visited. In particular, the lazy DFA guarantees that *at + most* one state is created for every byte of input. This, on its own, + guarantees linear time complexity. +2. Of course, creating a new state for *every* byte of input means that search + will go incredibly slow because of very large constant factors. On top of + that, creating a state for every byte in a large haystack could result in + exorbitant memory usage. To ameliorate this, the DFA bounds the number of + states it can store. Once it reaches its limit, it flushes its cache. This + prevents reuse of states that it already computed. If the cache is flushed + too frequently, then the DFA will give up and execution will fall back to + one of the NFA simulations. + +In effect, this crate will detect exponential state blow up and fall back to +a search routine with fixed memory requirements. This does, however, mean that +searching will be much slower than one might expect. Regexes that rely on +counting in particular are strong aggravators of this behavior. For example, +matching `[01]*1[01]{20}$` against a random sequence of `0`s and `1`s. + +In the future, it may be possible to increase the bound that the DFA uses, +which would allow the caller to choose how much memory they're willing to +spend. + +## Resist the temptation to "optimize" regexes + +**Advice**: This ain't a backtracking engine. + +An entire book was written on how to optimize Perl-style regular expressions. +Most of those techniques are not applicable for this library. For example, +there is no problem with using non-greedy matching or having lots of +alternations in your regex. diff --git a/third_party/cargo/vendor/regex-1.3.3/README.md b/third_party/cargo/vendor/regex-1.3.3/README.md new file mode 100644 index 0000000..5043649 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/README.md @@ -0,0 +1,258 @@ +regex +===== +A Rust library for parsing, compiling, and executing regular expressions. Its +syntax is similar to Perl-style regular expressions, but lacks a few features +like look around and backreferences. In exchange, all searches execute in +linear time with respect to the size of the regular expression and search text. +Much of the syntax and implementation is inspired +by [RE2](https://github.com/google/re2). + +[![Build status](https://travis-ci.com/rust-lang/regex.svg?branch=master)](https://travis-ci.com/rust-lang/regex) +[![Build status](https://ci.appveyor.com/api/projects/status/github/rust-lang/regex?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/regex) +[![Coverage Status](https://coveralls.io/repos/github/rust-lang/regex/badge.svg?branch=master)](https://coveralls.io/github/rust-lang/regex?branch=master) +[![](https://meritbadge.herokuapp.com/regex)](https://crates.io/crates/regex) +[![Rust](https://img.shields.io/badge/rust-1.28.0%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/regex) + +### Documentation + +[Module documentation with examples](https://docs.rs/regex). +The module documentation also includes a comprehensive description of the +syntax supported. + +Documentation with examples for the various matching functions and iterators +can be found on the +[`Regex` type](https://docs.rs/regex/*/regex/struct.Regex.html). + +### Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +regex = "1" +``` + +and this to your crate root (if you're using Rust 2015): + +```rust +extern crate regex; +``` + +Here's a simple example that matches a date in YYYY-MM-DD format and prints the +year, month and day: + +```rust +use regex::Regex; + +fn main() { + let re = Regex::new(r"(?x) +(?P\d{4}) # the year +- +(?P\d{2}) # the month +- +(?P\d{2}) # the day +").unwrap(); + let caps = re.captures("2010-03-14").unwrap(); + + assert_eq!("2010", &caps["year"]); + assert_eq!("03", &caps["month"]); + assert_eq!("14", &caps["day"]); +} +``` + +If you have lots of dates in text that you'd like to iterate over, then it's +easy to adapt the above example with an iterator: + +```rust +use regex::Regex; + +const TO_SEARCH: &'static str = " +On 2010-03-14, foo happened. On 2014-10-14, bar happened. +"; + +fn main() { + let re = Regex::new(r"(\d{4})-(\d{2})-(\d{2})").unwrap(); + + for caps in re.captures_iter(TO_SEARCH) { + // Note that all of the unwraps are actually OK for this regex + // because the only way for the regex to match is if all of the + // capture groups match. This is not true in general though! + println!("year: {}, month: {}, day: {}", + caps.get(1).unwrap().as_str(), + caps.get(2).unwrap().as_str(), + caps.get(3).unwrap().as_str()); + } +} +``` + +This example outputs: + +```text +year: 2010, month: 03, day: 14 +year: 2014, month: 10, day: 14 +``` + +### Usage: Avoid compiling the same regex in a loop + +It is an anti-pattern to compile the same regular expression in a loop since +compilation is typically expensive. (It takes anywhere from a few microseconds +to a few **milliseconds** depending on the size of the regex.) Not only is +compilation itself expensive, but this also prevents optimizations that reuse +allocations internally to the matching engines. + +In Rust, it can sometimes be a pain to pass regular expressions around if +they're used from inside a helper function. Instead, we recommend using the +[`lazy_static`](https://crates.io/crates/lazy_static) crate to ensure that +regular expressions are compiled exactly once. + +For example: + +```rust,ignore +use regex::Regex; + +fn some_helper_function(text: &str) -> bool { + lazy_static! { + static ref RE: Regex = Regex::new("...").unwrap(); + } + RE.is_match(text) +} +``` + +Specifically, in this example, the regex will be compiled when it is used for +the first time. On subsequent uses, it will reuse the previous compilation. + +### Usage: match regular expressions on `&[u8]` + +The main API of this crate (`regex::Regex`) requires the caller to pass a +`&str` for searching. In Rust, an `&str` is required to be valid UTF-8, which +means the main API can't be used for searching arbitrary bytes. + +To match on arbitrary bytes, use the `regex::bytes::Regex` API. The API +is identical to the main API, except that it takes an `&[u8]` to search +on instead of an `&str`. By default, `.` will match any *byte* using +`regex::bytes::Regex`, while `.` will match any *UTF-8 encoded Unicode scalar +value* using the main API. + +This example shows how to find all null-terminated strings in a slice of bytes: + +```rust +use regex::bytes::Regex; + +let re = Regex::new(r"(?P[^\x00]+)\x00").unwrap(); +let text = b"foo\x00bar\x00baz\x00"; + +// Extract all of the strings without the null terminator from each match. +// The unwrap is OK here since a match requires the `cstr` capture to match. +let cstrs: Vec<&[u8]> = + re.captures_iter(text) + .map(|c| c.name("cstr").unwrap().as_bytes()) + .collect(); +assert_eq!(vec![&b"foo"[..], &b"bar"[..], &b"baz"[..]], cstrs); +``` + +Notice here that the `[^\x00]+` will match any *byte* except for `NUL`. When +using the main API, `[^\x00]+` would instead match any valid UTF-8 sequence +except for `NUL`. + +### Usage: match multiple regular expressions simultaneously + +This demonstrates how to use a `RegexSet` to match multiple (possibly +overlapping) regular expressions in a single scan of the search text: + +```rust +use regex::RegexSet; + +let set = RegexSet::new(&[ + r"\w+", + r"\d+", + r"\pL+", + r"foo", + r"bar", + r"barfoo", + r"foobar", +]).unwrap(); + +// Iterate over and collect all of the matches. +let matches: Vec<_> = set.matches("foobar").into_iter().collect(); +assert_eq!(matches, vec![0, 2, 3, 4, 6]); + +// You can also test whether a particular regex matched: +let matches = set.matches("foobar"); +assert!(!matches.matched(5)); +assert!(matches.matched(6)); +``` + +### Usage: enable SIMD optimizations + +SIMD optimizations are enabled automatically on Rust stable 1.27 and newer. +For nightly versions of Rust, this requires a recent version with the SIMD +features stabilized. + + +### Usage: a regular expression parser + +This repository contains a crate that provides a well tested regular expression +parser, abstract syntax and a high-level intermediate representation for +convenient analysis. It provides no facilities for compilation or execution. +This may be useful if you're implementing your own regex engine or otherwise +need to do analysis on the syntax of a regular expression. It is otherwise not +recommended for general use. + +[Documentation `regex-syntax`.](https://docs.rs/regex-syntax) + + +### Crate features + +This crate comes with several features that permit tweaking the trade off +between binary size, compilation time and runtime performance. Users of this +crate can selectively disable Unicode tables, or choose from a variety of +optimizations performed by this crate to disable. + +When all of these features are disabled, runtime match performance may be much +worse, but if you're matching on short strings, or if high performance isn't +necessary, then such a configuration is perfectly serviceable. To disable +all such features, use the following `Cargo.toml` dependency configuration: + +```toml +[dependencies.regex] +version = "1.3" +default-features = false +# regex currently requires the standard library, you must re-enable it. +features = ["std"] +``` + +This will reduce the dependency tree of `regex` down to a single crate +(`regex-syntax`). + +The full set of features one can disable are +[in the "Crate features" section of the documentation](https://docs.rs/regex/*/#crate-features). + + +### Minimum Rust version policy + +This crate's minimum supported `rustc` version is `1.28.0`. + +The current **tentative** policy is that the minimum Rust version required +to use this crate can be increased in minor version updates. For example, if +regex 1.0 requires Rust 1.20.0, then regex 1.0.z for all values of `z` will +also require Rust 1.20.0 or newer. However, regex 1.y for `y > 0` may require a +newer minimum version of Rust. + +In general, this crate will be conservative with respect to the minimum +supported version of Rust. + + +### License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +The data in `regex-syntax/src/unicode_tables/` is licensed under the Unicode +License Agreement +([LICENSE-UNICODE](http://www.unicode.org/copyright.html#License)). diff --git a/third_party/cargo/vendor/regex-1.3.3/UNICODE.md b/third_party/cargo/vendor/regex-1.3.3/UNICODE.md new file mode 100644 index 0000000..18fa9b1 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/UNICODE.md @@ -0,0 +1,259 @@ +# Unicode conformance + +This document describes the regex crate's conformance to Unicode's +[UTS#18](http://unicode.org/reports/tr18/) +report, which lays out 3 levels of support: Basic, Extended and Tailored. + +Full support for Level 1 ("Basic Unicode Support") is provided with two +exceptions: + +1. Line boundaries are not Unicode aware. Namely, only the `\n` + (`END OF LINE`) character is recognized as a line boundary. +2. The compatibility properties specified by + [RL1.2a](http://unicode.org/reports/tr18/#RL1.2a) + are ASCII-only definitions. + +Little to no support is provided for either Level 2 or Level 3. For the most +part, this is because the features are either complex/hard to implement, or at +the very least, very difficult to implement without sacrificing performance. +For example, tackling canonical equivalence such that matching worked as one +would expect regardless of normalization form would be a significant +undertaking. This is at least partially a result of the fact that this regex +engine is based on finite automata, which admits less flexibility normally +associated with backtracking implementations. + + +## RL1.1 Hex Notation + +[UTS#18 RL1.1](https://unicode.org/reports/tr18/#Hex_notation) + +Hex Notation refers to the ability to specify a Unicode code point in a regular +expression via its hexadecimal code point representation. This is useful in +environments that have poor Unicode font rendering or if you need to express a +code point that is not normally displayable. All forms of hexadecimal notation +are supported + + \x7F hex character code (exactly two digits) + \x{10FFFF} any hex character code corresponding to a Unicode code point + \u007F hex character code (exactly four digits) + \u{7F} any hex character code corresponding to a Unicode code point + \U0000007F hex character code (exactly eight digits) + \U{7F} any hex character code corresponding to a Unicode code point + +Briefly, the `\x{...}`, `\u{...}` and `\U{...}` are all exactly equivalent ways +of expressing hexadecimal code points. Any number of digits can be written +within the brackets. In contrast, `\xNN`, `\uNNNN`, `\UNNNNNNNN` are all +fixed-width variants of the same idea. + +Note that when Unicode mode is disabled, any non-ASCII Unicode codepoint is +banned. Additionally, the `\xNN` syntax represents arbitrary bytes when Unicode +mode is disabled. That is, the regex `\xFF` matches the Unicode codepoint +U+00FF (encoded as `\xC3\xBF` in UTF-8) while the regex `(?-u)\xFF` matches +the literal byte `\xFF`. + + +## RL1.2 Properties + +[UTS#18 RL1.2](https://unicode.org/reports/tr18/#Categories) + +Full support for Unicode property syntax is provided. Unicode properties +provide a convenient way to construct character classes of groups of code +points specified by Unicode. The regex crate does not provide exhaustive +support, but covers a useful subset. In particular: + +* [General categories](http://unicode.org/reports/tr18/#General_Category_Property) +* [Scripts and Script Extensions](http://unicode.org/reports/tr18/#Script_Property) +* [Age](http://unicode.org/reports/tr18/#Age) +* A smattering of boolean properties, including all of those specified by + [RL1.2](http://unicode.org/reports/tr18/#RL1.2) explicitly. + +In all cases, property name and value abbreviations are supported, and all +names/values are matched loosely without regard for case, whitespace or +underscores. Property name aliases can be found in Unicode's +[`PropertyAliases.txt`](http://www.unicode.org/Public/UCD/latest/ucd/PropertyAliases.txt) +file, while property value aliases can be found in Unicode's +[`PropertyValueAliases.txt`](http://www.unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt) +file. + +The syntax supported is also consistent with the UTS#18 recommendation: + +* `\p{Greek}` selects the `Greek` script. Equivalent expressions follow: + `\p{sc:Greek}`, `\p{Script:Greek}`, `\p{Sc=Greek}`, `\p{script=Greek}`, + `\P{sc!=Greek}`. Similarly for `General_Category` (or `gc` for short) and + `Script_Extensions` (or `scx` for short). +* `\p{age:3.2}` selects all code points in Unicode 3.2. +* `\p{Alphabetic}` selects the "alphabetic" property and can be abbreviated + via `\p{alpha}` (for example). +* Single letter variants for properties with single letter abbreviations. + For example, `\p{Letter}` can be equivalently written as `\pL`. + +The following is a list of all properties supported by the regex crate (starred +properties correspond to properties required by RL1.2): + +* `General_Category` \* (including `Any`, `ASCII` and `Assigned`) +* `Script` \* +* `Script_Extensions` \* +* `Age` +* `ASCII_Hex_Digit` +* `Alphabetic` \* +* `Bidi_Control` +* `Case_Ignorable` +* `Cased` +* `Changes_When_Casefolded` +* `Changes_When_Casemapped` +* `Changes_When_Lowercased` +* `Changes_When_Titlecased` +* `Changes_When_Uppercased` +* `Dash` +* `Default_Ignorable_Code_Point` \* +* `Deprecated` +* `Diacritic` +* `Emoji` +* `Emoji_Presentation` +* `Emoji_Modifier` +* `Emoji_Modifier_Base` +* `Emoji_Component` +* `Extended_Pictographic` +* `Extender` +* `Grapheme_Base` +* `Grapheme_Cluster_Break` +* `Grapheme_Extend` +* `Hex_Digit` +* `IDS_Binary_Operator` +* `IDS_Trinary_Operator` +* `ID_Continue` +* `ID_Start` +* `Join_Control` +* `Logical_Order_Exception` +* `Lowercase` \* +* `Math` +* `Noncharacter_Code_Point` \* +* `Pattern_Syntax` +* `Pattern_White_Space` +* `Prepended_Concatenation_Mark` +* `Quotation_Mark` +* `Radical` +* `Regional_Indicator` +* `Sentence_Break` +* `Sentence_Terminal` +* `Soft_Dotted` +* `Terminal_Punctuation` +* `Unified_Ideograph` +* `Uppercase` \* +* `Variation_Selector` +* `White_Space` \* +* `Word_Break` +* `XID_Continue` +* `XID_Start` + + +## RL1.2a Compatibility Properties + +[UTS#18 RL1.2a](http://unicode.org/reports/tr18/#RL1.2a) + +The regex crate only provides ASCII definitions of the +[compatibility properties documented in UTS#18 Annex C](http://unicode.org/reports/tr18/#Compatibility_Properties) +(sans the `\X` class, for matching grapheme clusters, which isn't provided +at all). This is because it seems to be consistent with most other regular +expression engines, and in particular, because these are often referred to as +"ASCII" or "POSIX" character classes. + +Note that the `\w`, `\s` and `\d` character classes **are** Unicode aware. +Their traditional ASCII definition can be used by disabling Unicode. That is, +`[[:word:]]` and `(?-u)\w` are equivalent. + + +## RL1.3 Subtraction and Intersection + +[UTS#18 RL1.3](http://unicode.org/reports/tr18/#Subtraction_and_Intersection) + +The regex crate provides full support for nested character classes, along with +union, intersection (`&&`), difference (`--`) and symmetric difference (`~~`) +operations on arbitrary character classes. + +For example, to match all non-ASCII letters, you could use either +`[\p{Letter}--\p{Ascii}]` (difference) or `[\p{Letter}&&[^\p{Ascii}]]` +(intersecting the negation). + + +## RL1.4 Simple Word Boundaries + +[UTS#18 RL1.4](http://unicode.org/reports/tr18/#Simple_Word_Boundaries) + +The regex crate provides basic Unicode aware word boundary assertions. A word +boundary assertion can be written as `\b`, or `\B` as its negation. A word +boundary negation corresponds to a zero-width match, where its adjacent +characters correspond to word and non-word, or non-word and word characters. + +Conformance in this case chooses to define word character in the same way that +the `\w` character class is defined: a code point that is a member of one of +the following classes: + +* `\p{Alphabetic}` +* `\p{Join_Control}` +* `\p{gc:Mark}` +* `\p{gc:Decimal_Number}` +* `\p{gc:Connector_Punctuation}` + +In particular, this differs slightly from the +[prescription given in RL1.4](http://unicode.org/reports/tr18/#Simple_Word_Boundaries) +but is permissible according to +[UTS#18 Annex C](http://unicode.org/reports/tr18/#Compatibility_Properties). +Namely, it is convenient and simpler to have `\w` and `\b` be in sync with +one another. + +Finally, Unicode word boundaries can be disabled, which will cause ASCII word +boundaries to be used instead. That is, `\b` is a Unicode word boundary while +`(?-u)\b` is an ASCII-only word boundary. This can occasionally be beneficial +if performance is important, since the implementation of Unicode word +boundaries is currently sub-optimal on non-ASCII text. + + +## RL1.5 Simple Loose Matches + +[UTS#18 RL1.5](http://unicode.org/reports/tr18/#Simple_Loose_Matches) + +The regex crate provides full support for case insensitive matching in +accordance with RL1.5. That is, it uses the "simple" case folding mapping. The +"simple" mapping was chosen because of a key convenient property: every +"simple" mapping is a mapping from exactly one code point to exactly one other +code point. This makes case insensitive matching of character classes, for +example, straight-forward to implement. + +When case insensitive mode is enabled (e.g., `(?i)[a]` is equivalent to `a|A`), +then all characters classes are case folded as well. + + +## RL1.6 Line Boundaries + +[UTS#18 RL1.6](http://unicode.org/reports/tr18/#Line_Boundaries) + +The regex crate only provides support for recognizing the `\n` (`END OF LINE`) +character as a line boundary. This choice was made mostly for implementation +convenience, and to avoid performance cliffs that Unicode word boundaries are +subject to. + +Ideally, it would be nice to at least support `\r\n` as a line boundary as +well, and in theory, this could be done efficiently. + + +## RL1.7 Code Points + +[UTS#18 RL1.7](http://unicode.org/reports/tr18/#Supplementary_Characters) + +The regex crate provides full support for Unicode code point matching. Namely, +the fundamental atom of any match is always a single code point. + +Given Rust's strong ties to UTF-8, the following guarantees are also provided: + +* All matches are reported on valid UTF-8 code unit boundaries. That is, any + match range returned by the public regex API is guaranteed to successfully + slice the string that was searched. +* By consequence of the above, it is impossible to match surrogode code points. + No support for UTF-16 is provided, so this is never necessary. + +Note that when Unicode mode is disabled, the fundamental atom of matching is +no longer a code point but a single byte. When Unicode mode is disabled, many +Unicode features are disabled as well. For example, `(?-u)\pL` is not a valid +regex but `\pL(?-u)\xFF` (matches any Unicode `Letter` followed by the literal +byte `\xFF`) is, for example. diff --git a/third_party/cargo/vendor/regex-1.3.3/examples/regexdna-input.txt b/third_party/cargo/vendor/regex-1.3.3/examples/regexdna-input.txt new file mode 100644 index 0000000..fb23263 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/examples/regexdna-input.txt @@ -0,0 +1,1671 @@ +>ONE Homo sapiens alu +GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA +TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT +AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG +GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG +CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT +GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA +GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA +TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG +AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA +GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT +AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC +AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG +GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC +CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG +AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT +TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA +TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT +GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG +TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT +CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG +CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG +TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA +CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG +AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG +GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC +TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA +TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA +GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT +GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC +ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT +TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC +CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG +CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG +GGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCC +CAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCT +GGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGC +GCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGA +GGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGA +GACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGA +GGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTG +AAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAAT +CCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCA +GTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAA +AAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGC +GGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCT +ACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGG +GAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATC +GCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGC +GGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGG +TCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAA +AAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAG +GAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACT +CCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCC +TGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAG +ACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGC +GTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGA +ACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGA +CAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCA +CTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCA +ACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCG +CCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGG +AGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTC +CGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCG +AGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACC +CCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAG +CTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAG +CCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGG +CCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATC +ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAA +AAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGC +TGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCC +ACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGG +CTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGG +AGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATT +AGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAA +TCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGC +CTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAA +TCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAG +CCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGT +GGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCG +GGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAG +CGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTG +GGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATG +GTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGT +AATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTT +GCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCT +CAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCG +GGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTC +TCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACT +CGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAG +ATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGG +CGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTG +AGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATA +CAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGG +CAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGC +ACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCAC +GCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTC +GAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCG +GGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCT +TGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGG +CGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCA +GCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGG +CCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGC +GCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGG +CGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGA +CTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGG +CCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAA +ACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCC +CAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGT +GAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAA +AGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGG +ATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTAC +TAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGA +GGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGC +GCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGG +TGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTC +AGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAA +ATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGA +GAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC +AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTG +TAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGAC +CAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGT +GGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAAC +CCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACA +GAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACT +TTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAAC +ATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCC +TGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAG +GTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCG +TCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAG +GCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCC +GTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCT +ACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCC +GAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCC +GGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCAC +CTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAA +ATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTG +AGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCAC +TGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCT +CACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAG +TTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAG +CCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATC +GCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCT +GGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATC +CCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCC +TGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGG +CGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG +AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCG +AGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGG +AGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGT +GAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAA +TCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGC +AGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCA +AAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGG +CGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTC +TACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCG +GGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGAT +CGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCG +CGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAG +GTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACA +AAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCA +GGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCAC +TCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGC +CTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGA +GACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGG +CGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTG +AACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCG +ACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGC +ACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCC +AACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGC +GCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCG +GAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACT +CCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCC +GAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAAC +CCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA +GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGA +GCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAG +GCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGAT +CACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTA +AAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGG +CTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGC +CACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTG +GCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAG +GAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAAT +TAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGA +ATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAG +CCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTA +ATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCA +GCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGG +TGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCC +GGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGA +GCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTT +GGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACAT +GGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTG +TAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGT +TGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTC +TCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGC +GGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGT +CTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTAC +TCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGA +GATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGG +GCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCT +GAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT +ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAG +GCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTG +CACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCA +CGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTT +CGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCC +GGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGC +TTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGG +GCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCC +AGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTG +GCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCG +CGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAG +GCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAG +ACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAG +GCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGA +AACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATC +CCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAG +TGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAA +AAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCG +GATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTA +CTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGG +AGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCG +CGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCG +GTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGT +CAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAA +AATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGG +AGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTC +CAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCT +GTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA +CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCG +TGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAA +CCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGAC +AGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCAC +TTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAA +CATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGC +CTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGA +GGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCC +GTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGA +GGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCC +CGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGC +TACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGC +CGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGC +CGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCA +CCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAA +AATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCT +GAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCA +CTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGC +TCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGA +GTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTA +GCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAAT +CGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCC +TGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAAT +CCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGC +CTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTG +GCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGG +GAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGC +GAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG +GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGG +TGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTA +ATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTG +CAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTC +AAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGG +GCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCT +CTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTC +GGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGA +TCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGC +GCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGA +GGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATAC +AAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGC +AGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCA +CTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACG +CCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCG +AGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGG +GCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTT +GAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGC +GACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAG +CACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGC +CAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCG +CGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGC +GGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGAC +TCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGC +CGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAA +CCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCC +AGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTG +AGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA +GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA +TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT +AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG +GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG +CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT +GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA +GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA +TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG +AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA +GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT +AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC +AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG +GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC +CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG +AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT +TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA +TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT +GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG +TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT +CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG +CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG +TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA +CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG +AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG +GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC +TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA +TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA +GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT +GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC +ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT +TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC +CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG +CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG +GGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCC +CAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCT +GGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGC +GCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGA +GGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGA +GACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGA +GGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTG +AAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAAT +CCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCA +GTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAA +AAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGC +GGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCT +ACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGG +GAGGCTGAGGCAGGAGAATC +>TWO IUB ambiguity codes +cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg +tactDtDagcctatttSVHtHttKtgtHMaSattgWaHKHttttagacatWatgtRgaaa +NtactMcSMtYtcMgRtacttctWBacgaaatatagScDtttgaagacacatagtVgYgt +cattHWtMMWcStgttaggKtSgaYaaccWStcgBttgcgaMttBYatcWtgacaYcaga +gtaBDtRacttttcWatMttDBcatWtatcttactaBgaYtcttgttttttttYaaScYa +HgtgttNtSatcMtcVaaaStccRcctDaataataStcYtRDSaMtDttgttSagtRRca +tttHatSttMtWgtcgtatSSagactYaaattcaMtWatttaSgYttaRgKaRtccactt +tattRggaMcDaWaWagttttgacatgttctacaaaRaatataataaMttcgDacgaSSt +acaStYRctVaNMtMgtaggcKatcttttattaaaaagVWaHKYagtttttatttaacct +tacgtVtcVaattVMBcttaMtttaStgacttagattWWacVtgWYagWVRctDattBYt +gtttaagaagattattgacVatMaacattVctgtBSgaVtgWWggaKHaatKWcBScSWa +accRVacacaaactaccScattRatatKVtactatatttHttaagtttSKtRtacaaagt +RDttcaaaaWgcacatWaDgtDKacgaacaattacaRNWaatHtttStgttattaaMtgt +tgDcgtMgcatBtgcttcgcgaDWgagctgcgaggggVtaaScNatttacttaatgacag +cccccacatYScaMgtaggtYaNgttctgaMaacNaMRaacaaacaKctacatagYWctg +ttWaaataaaataRattagHacacaagcgKatacBttRttaagtatttccgatctHSaat +actcNttMaagtattMtgRtgaMgcataatHcMtaBSaRattagttgatHtMttaaKagg +YtaaBataSaVatactWtataVWgKgttaaaacagtgcgRatatacatVtHRtVYataSa +KtWaStVcNKHKttactatccctcatgWHatWaRcttactaggatctataDtDHBttata +aaaHgtacVtagaYttYaKcctattcttcttaataNDaaggaaaDYgcggctaaWSctBa +aNtgctggMBaKctaMVKagBaactaWaDaMaccYVtNtaHtVWtKgRtcaaNtYaNacg +gtttNattgVtttctgtBaWgtaattcaagtcaVWtactNggattctttaYtaaagccgc +tcttagHVggaYtgtNcDaVagctctctKgacgtatagYcctRYHDtgBattDaaDgccK +tcHaaStttMcctagtattgcRgWBaVatHaaaataYtgtttagMDMRtaataaggatMt +ttctWgtNtgtgaaaaMaatatRtttMtDgHHtgtcattttcWattRSHcVagaagtacg +ggtaKVattKYagactNaatgtttgKMMgYNtcccgSKttctaStatatNVataYHgtNa +BKRgNacaactgatttcctttaNcgatttctctataScaHtataRagtcRVttacDSDtt +aRtSatacHgtSKacYagttMHtWataggatgactNtatSaNctataVtttRNKtgRacc +tttYtatgttactttttcctttaaacatacaHactMacacggtWataMtBVacRaSaatc +cgtaBVttccagccBcttaRKtgtgcctttttRtgtcagcRttKtaaacKtaaatctcac +aattgcaNtSBaaccgggttattaaBcKatDagttactcttcattVtttHaaggctKKga +tacatcBggScagtVcacattttgaHaDSgHatRMaHWggtatatRgccDttcgtatcga +aacaHtaagttaRatgaVacttagattVKtaaYttaaatcaNatccRttRRaMScNaaaD +gttVHWgtcHaaHgacVaWtgttScactaagSgttatcttagggDtaccagWattWtRtg +ttHWHacgattBtgVcaYatcggttgagKcWtKKcaVtgaYgWctgYggVctgtHgaNcV +taBtWaaYatcDRaaRtSctgaHaYRttagatMatgcatttNattaDttaattgttctaa +ccctcccctagaWBtttHtBccttagaVaatMcBHagaVcWcagBVttcBtaYMccagat +gaaaaHctctaacgttagNWRtcggattNatcRaNHttcagtKttttgWatWttcSaNgg +gaWtactKKMaacatKatacNattgctWtatctaVgagctatgtRaHtYcWcttagccaa +tYttWttaWSSttaHcaaaaagVacVgtaVaRMgattaVcDactttcHHggHRtgNcctt +tYatcatKgctcctctatVcaaaaKaaaagtatatctgMtWtaaaacaStttMtcgactt +taSatcgDataaactaaacaagtaaVctaggaSccaatMVtaaSKNVattttgHccatca +cBVctgcaVatVttRtactgtVcaattHgtaaattaaattttYtatattaaRSgYtgBag +aHSBDgtagcacRHtYcBgtcacttacactaYcgctWtattgSHtSatcataaatataHt +cgtYaaMNgBaatttaRgaMaatatttBtttaaaHHKaatctgatWatYaacttMctctt +ttVctagctDaaagtaVaKaKRtaacBgtatccaaccactHHaagaagaaggaNaaatBW +attccgStaMSaMatBttgcatgRSacgttVVtaaDMtcSgVatWcaSatcttttVatag +ttactttacgatcaccNtaDVgSRcgVcgtgaacgaNtaNatatagtHtMgtHcMtagaa +attBgtataRaaaacaYKgtRccYtatgaagtaataKgtaaMttgaaRVatgcagaKStc +tHNaaatctBBtcttaYaBWHgtVtgacagcaRcataWctcaBcYacYgatDgtDHccta +aagacYRcaggattHaYgtKtaatgcVcaataMYacccatatcacgWDBtgaatcBaata +cKcttRaRtgatgaBDacggtaattaaYtataStgVHDtDctgactcaaatKtacaatgc +gYatBtRaDatHaactgtttatatDttttaaaKVccYcaaccNcBcgHaaVcattHctcg +attaaatBtatgcaaaaatYMctSactHatacgaWacattacMBgHttcgaatVaaaaca +BatatVtctgaaaaWtctRacgBMaatSgRgtgtcgactatcRtattaScctaStagKga +DcWgtYtDDWKRgRtHatRtggtcgaHgggcgtattaMgtcagccaBggWVcWctVaaat +tcgNaatcKWagcNaHtgaaaSaaagctcYctttRVtaaaatNtataaccKtaRgtttaM +tgtKaBtRtNaggaSattHatatWactcagtgtactaKctatttgRYYatKatgtccgtR +tttttatttaatatVgKtttgtatgtNtataRatWYNgtRtHggtaaKaYtKSDcatcKg +taaYatcSRctaVtSMWtVtRWHatttagataDtVggacagVcgKWagBgatBtaaagNc +aRtagcataBggactaacacRctKgttaatcctHgDgttKHHagttgttaatgHBtatHc +DaagtVaBaRccctVgtgDtacRHSctaagagcggWYaBtSaKtHBtaaactYacgNKBa +VYgtaacttagtVttcttaatgtBtatMtMtttaattaatBWccatRtttcatagVgMMt +agctStKctaMactacDNYgKYHgaWcgaHgagattacVgtttgtRaSttaWaVgataat +gtgtYtaStattattMtNgWtgttKaccaatagNYttattcgtatHcWtctaaaNVYKKt +tWtggcDtcgaagtNcagatacgcattaagaccWctgcagcttggNSgaNcHggatgtVt +catNtRaaBNcHVagagaaBtaaSggDaatWaatRccaVgggStctDaacataKttKatt +tggacYtattcSatcttagcaatgaVBMcttDattctYaaRgatgcattttNgVHtKcYR +aatRKctgtaaacRatVSagctgtWacBtKVatctgttttKcgtctaaDcaagtatcSat +aWVgcKKataWaYttcccSaatgaaaacccWgcRctWatNcWtBRttYaattataaNgac +acaatagtttVNtataNaYtaatRaVWKtBatKagtaatataDaNaaaaataMtaagaaS +tccBcaatNgaataWtHaNactgtcDtRcYaaVaaaaaDgtttRatctatgHtgttKtga +aNSgatactttcgagWaaatctKaaDaRttgtggKKagcDgataaattgSaacWaVtaNM +acKtcaDaaatttctRaaVcagNacaScRBatatctRatcctaNatWgRtcDcSaWSgtt +RtKaRtMtKaatgttBHcYaaBtgatSgaSWaScMgatNtctcctatttctYtatMatMt +RRtSaattaMtagaaaaStcgVgRttSVaScagtgDtttatcatcatacRcatatDctta +tcatVRtttataaHtattcYtcaaaatactttgVctagtaaYttagatagtSYacKaaac +gaaKtaaatagataatSatatgaaatSgKtaatVtttatcctgKHaatHattagaaccgt +YaaHactRcggSBNgtgctaaBagBttgtRttaaattYtVRaaaattgtaatVatttctc +ttcatgBcVgtgKgaHaaatattYatagWacNctgaaMcgaattStagWaSgtaaKagtt +ttaagaDgatKcctgtaHtcatggKttVDatcaaggtYcgccagNgtgcVttttagagat +gctaccacggggtNttttaSHaNtatNcctcatSaaVgtactgBHtagcaYggYVKNgta +KBcRttgaWatgaatVtagtcgattYgatgtaatttacDacSctgctaaaStttaWMagD +aaatcaVYctccgggcgaVtaaWtStaKMgDtttcaaMtVgBaatccagNaaatcYRMBg +gttWtaaScKttMWtYataRaDBMaDataatHBcacDaaKDactaMgagttDattaHatH +taYatDtattDcRNStgaatattSDttggtattaaNSYacttcDMgYgBatWtaMagact +VWttctttgYMaYaacRgHWaattgRtaagcattctMKVStatactacHVtatgatcBtV +NataaBttYtSttacKgggWgYDtgaVtYgatDaacattYgatggtRDaVDttNactaSa +MtgNttaacaaSaBStcDctaccacagacgcaHatMataWKYtaYattMcaMtgSttDag +cHacgatcaHttYaKHggagttccgatYcaatgatRaVRcaagatcagtatggScctata +ttaNtagcgacgtgKaaWaactSgagtMYtcttccaKtStaacggMtaagNttattatcg +tctaRcactctctDtaacWYtgaYaSaagaWtNtatttRacatgNaatgttattgWDDcN +aHcctgaaHacSgaataaRaataMHttatMtgaSDSKatatHHaNtacagtccaYatWtc +actaactatKDacSaStcggataHgYatagKtaatKagStaNgtatactatggRHacttg +tattatgtDVagDVaRctacMYattDgtttYgtctatggtKaRSttRccRtaaccttaga +gRatagSaaMaacgcaNtatgaaatcaRaagataatagatactcHaaYKBctccaagaRa +BaStNagataggcgaatgaMtagaatgtcaKttaaatgtaWcaBttaatRcggtgNcaca +aKtttScRtWtgcatagtttWYaagBttDKgcctttatMggNttattBtctagVtacata +aaYttacacaaRttcYtWttgHcaYYtaMgBaBatctNgcDtNttacgacDcgataaSat +YaSttWtcctatKaatgcagHaVaacgctgcatDtgttaSataaaaYSNttatagtaNYt +aDaaaNtggggacttaBggcHgcgtNtaaMcctggtVtaKcgNacNtatVaSWctWtgaW +cggNaBagctctgaYataMgaagatBSttctatacttgtgtKtaattttRagtDtacata +tatatgatNHVgBMtKtaKaNttDHaagatactHaccHtcatttaaagttVaMcNgHata +tKtaNtgYMccttatcaaNagctggacStttcNtggcaVtattactHaSttatgNMVatt +MMDtMactattattgWMSgtHBttStStgatatRaDaagattttctatMtaaaaaggtac +taaVttaSacNaatactgMttgacHaHRttgMacaaaatagttaatatWKRgacDgaRta +tatttattatcYttaWtgtBRtWatgHaaattHataagtVaDtWaVaWtgStcgtMSgaS +RgMKtaaataVacataatgtaSaatttagtcgaaHtaKaatgcacatcggRaggSKctDc +agtcSttcccStYtccRtctctYtcaaKcgagtaMttttcRaYDttgttatctaatcata +NctctgctatcaMatactataggDaHaaSttMtaDtcNatataattctMcStaaBYtaNa +gatgtaatHagagSttgWHVcttatKaYgDctcttggtgttMcRaVgSgggtagacaata +aDtaattSaDaNaHaBctattgNtaccaaRgaVtKNtaaYggHtaKKgHcatctWtctDt +ttctttggSDtNtaStagttataaacaattgcaBaBWggHgcaaaBtYgctaatgaaatW +cDcttHtcMtWWattBHatcatcaaatctKMagtDNatttWaBtHaaaNgMttaaStagt +tctctaatDtcRVaYttgttMtRtgtcaSaaYVgSWDRtaatagctcagDgcWWaaaBaa +RaBctgVgggNgDWStNaNBKcBctaaKtttDcttBaaggBttgaccatgaaaNgttttt +tttatctatgttataccaaDRaaSagtaVtDtcaWatBtacattaWacttaSgtattggD +gKaaatScaattacgWcagKHaaccaYcRcaRttaDttRtttHgaHVggcttBaRgtccc +tDatKaVtKtcRgYtaKttacgtatBtStaagcaattaagaRgBagSaattccSWYttta +ttVaataNctgHgttaaNBgcVYgtRtcccagWNaaaacaDNaBcaaaaRVtcWMgBagM +tttattacgDacttBtactatcattggaaatVccggttRttcatagttVYcatYaSHaHc +ttaaagcNWaHataaaRWtctVtRYtagHtaaaYMataHYtNBctNtKaatattStgaMc +BtRgctaKtgcScSttDgYatcVtggaaKtaagatWccHccgKYctaNNctacaWctttt +gcRtgtVcgaKttcMRHgctaHtVaataaDtatgKDcttatBtDttggNtacttttMtga +acRattaaNagaactcaaaBBVtcDtcgaStaDctgaaaSgttMaDtcgttcaccaaaag +gWtcKcgSMtcDtatgtttStaaBtatagDcatYatWtaaaBacaKgcaDatgRggaaYc +taRtccagattDaWtttggacBaVcHtHtaacDacYgtaatataMagaatgHMatcttat +acgtatttttatattacHactgttataMgStYaattYaccaattgagtcaaattaYtgta +tcatgMcaDcgggtcttDtKgcatgWRtataatatRacacNRBttcHtBgcRttgtgcgt +catacMtttBctatctBaatcattMttMYgattaaVYatgDaatVagtattDacaacDMa +tcMtHcccataagatgBggaccattVWtRtSacatgctcaaggggYtttDtaaNgNtaaB +atggaatgtctRtaBgBtcNYatatNRtagaacMgagSaSDDSaDcctRagtVWSHtVSR +ggaacaBVaccgtttaStagaacaMtactccagtttVctaaRaaHttNcttagcaattta +ttaatRtaaaatctaacDaBttggSagagctacHtaaRWgattcaaBtctRtSHaNtgta +cattVcaHaNaagtataccacaWtaRtaaVKgMYaWgttaKggKMtKcgWatcaDatYtK +SttgtacgaccNctSaattcDcatcttcaaaDKttacHtggttHggRRaRcaWacaMtBW +VHSHgaaMcKattgtaRWttScNattBBatYtaNRgcggaagacHSaattRtttcYgacc +BRccMacccKgatgaacttcgDgHcaaaaaRtatatDtatYVtttttHgSHaSaatagct +NYtaHYaVYttattNtttgaaaYtaKttWtctaNtgagaaaNctNDctaaHgttagDcRt +tatagccBaacgcaRBtRctRtggtaMYYttWtgataatcgaataattattataVaaaaa +ttacNRVYcaaMacNatRttcKatMctgaagactaattataaYgcKcaSYaatMNctcaa +cgtgatttttBacNtgatDccaattattKWWcattttatatatgatBcDtaaaagttgaa +VtaHtaHHtBtataRBgtgDtaataMttRtDgDcttattNtggtctatctaaBcatctaR +atgNacWtaatgaagtcMNaacNgHttatactaWgcNtaStaRgttaaHacccgaYStac +aaaatWggaYaWgaattattcMaactcBKaaaRVNcaNRDcYcgaBctKaacaaaaaSgc +tccYBBHYaVagaatagaaaacagYtctVccaMtcgtttVatcaatttDRtgWctagtac +RttMctgtDctttcKtWttttataaatgVttgBKtgtKWDaWagMtaaagaaattDVtag +gttacatcatttatgtcgMHaVcttaBtVRtcgtaYgBRHatttHgaBcKaYWaatcNSc +tagtaaaaatttacaatcactSWacgtaatgKttWattagttttNaggtctcaagtcact +attcttctaagKggaataMgtttcataagataaaaatagattatDgcBVHWgaBKttDgc +atRHaagcaYcRaattattatgtMatatattgHDtcaDtcaaaHctStattaatHaccga +cNattgatatattttgtgtDtRatagSacaMtcRtcattcccgacacSattgttKaWatt +NHcaacttccgtttSRtgtctgDcgctcaaMagVtBctBMcMcWtgtaacgactctcttR +ggRKSttgYtYatDccagttDgaKccacgVatWcataVaaagaataMgtgataaKYaaat +cHDaacgataYctRtcYatcgcaMgtNttaBttttgatttaRtStgcaacaaaataccVg +aaDgtVgDcStctatatttattaaaaRKDatagaaagaKaaYYcaYSgKStctccSttac +agtcNactttDVttagaaagMHttRaNcSaRaMgBttattggtttaRMggatggcKDgWR +tNaataataWKKacttcKWaaagNaBttaBatMHtccattaacttccccYtcBcYRtaga +ttaagctaaYBDttaNtgaaaccHcaRMtKtaaHMcNBttaNaNcVcgVttWNtDaBatg +ataaVtcWKcttRggWatcattgaRagHgaattNtatttctctattaattaatgaDaaMa +tacgttgggcHaYVaaNaDDttHtcaaHtcVVDgBVagcMacgtgttaaBRNtatRtcag +taagaggtttaagacaVaaggttaWatctccgtVtaDtcDatttccVatgtacNtttccg +tHttatKgScBatgtVgHtYcWagcaKtaMYaaHgtaattaSaHcgcagtWNaatNccNN +YcacgVaagaRacttctcattcccRtgtgtaattagcSttaaStWaMtctNNcSMacatt +ataaactaDgtatWgtagtttaagaaaattgtagtNagtcaataaatttgatMMYactaa +tatcggBWDtVcYttcDHtVttatacYaRgaMaacaStaatcRttttVtagaDtcacWat +ttWtgaaaagaaagNRacDtttStVatBaDNtaactatatcBSMcccaSttccggaMatg +attaaWatKMaBaBatttgataNctgttKtVaagtcagScgaaaDggaWgtgttttKtWt +atttHaatgtagttcactaaKMagttSYBtKtaYgaactcagagRtatagtVtatcaaaW +YagcgNtaDagtacNSaaYDgatBgtcgataacYDtaaactacagWDcYKaagtttatta +gcatcgagttKcatDaattgattatDtcagRtWSKtcgNtMaaaaacaMttKcaWcaaSV +MaaaccagMVtaMaDtMaHaBgaacataBBVtaatVYaNSWcSgNtDNaaKacacBttta +tKtgtttcaaHaMctcagtaacgtcgYtactDcgcctaNgagagcYgatattttaaattt +ccattttacatttDaaRctattttWctttacgtDatYtttcagacgcaaVttagtaaKaa +aRtgVtccataBggacttatttgtttaWNtgttVWtaWNVDaattgtatttBaagcBtaa +BttaaVatcHcaVgacattccNggtcgacKttaaaRtagRtctWagaYggtgMtataatM +tgaaRttattttgWcttNtDRRgMDKacagaaaaggaaaRStcccagtYccVattaNaaK +StNWtgacaVtagaagcttSaaDtcacaacgDYacWDYtgtttKatcVtgcMaDaSKStV +cgtagaaWaKaagtttcHaHgMgMtctataagBtKaaaKKcactggagRRttaagaBaaN +atVVcgRcKSttDaactagtSttSattgttgaaRYatggttVttaataaHttccaagDtg +atNWtaagHtgcYtaactRgcaatgMgtgtRaatRaNaacHKtagactactggaatttcg +ccataacgMctRgatgttaccctaHgtgWaYcactcacYaattcttaBtgacttaaacct +gYgaWatgBttcttVttcgttWttMcNYgtaaaatctYgMgaaattacNgaHgaacDVVM +tttggtHtctaaRgtacagacgHtVtaBMNBgattagcttaRcttacaHcRctgttcaaD +BggttKaacatgKtttYataVaNattccgMcgcgtagtRaVVaattaKaatggttRgaMc +agtatcWBttNtHagctaatctagaaNaaacaYBctatcgcVctBtgcaaagDgttVtga +HtactSNYtaaNccatgtgDacgaVtDcgKaRtacDcttgctaagggcagMDagggtBWR +tttSgccttttttaacgtcHctaVtVDtagatcaNMaVtcVacatHctDWNaataRgcgt +aVHaggtaaaaSgtttMtattDgBtctgatSgtRagagYtctSaKWaataMgattRKtaa +catttYcgtaacacattRWtBtcggtaaatMtaaacBatttctKagtcDtttgcBtKYYB +aKttctVttgttaDtgattttcttccacttgSaaacggaaaNDaattcYNNaWcgaaYat +tttMgcBtcatRtgtaaagatgaWtgaccaYBHgaatagataVVtHtttVgYBtMctaMt +cctgaDcYttgtccaaaRNtacagcMctKaaaggatttacatgtttaaWSaYaKttBtag +DacactagctMtttNaKtctttcNcSattNacttggaacaatDagtattRtgSHaataat +gccVgacccgatactatccctgtRctttgagaSgatcatatcgDcagWaaHSgctYYWta +tHttggttctttatVattatcgactaagtgtagcatVgtgHMtttgtttcgttaKattcM +atttgtttWcaaStNatgtHcaaaDtaagBaKBtRgaBgDtSagtatMtaacYaatYtVc +KatgtgcaacVaaaatactKcRgtaYtgtNgBBNcKtcttaccttKgaRaYcaNKtactt +tgagSBtgtRagaNgcaaaNcacagtVtttHWatgttaNatBgtttaatNgVtctgaata +tcaRtattcttttttttRaaKcRStctcggDgKagattaMaaaKtcaHacttaataataK +taRgDtKVBttttcgtKaggHHcatgttagHggttNctcgtatKKagVagRaaaggaaBt +NatttVKcRttaHctaHtcaaatgtaggHccaBataNaNaggttgcWaatctgatYcaaa +HaatWtaVgaaBttagtaagaKKtaaaKtRHatMaDBtBctagcatWtatttgWttVaaa +ScMNattRactttgtYtttaaaagtaagtMtaMaSttMBtatgaBtttaKtgaatgagYg +tNNacMtcNRacMMHcttWtgtRtctttaacaacattattcYaMagBaacYttMatcttK +cRMtgMNccattaRttNatHaHNaSaaHMacacaVaatacaKaSttHatattMtVatWga +ttttttaYctttKttHgScWaacgHtttcaVaaMgaacagNatcgttaacaaaaagtaca +HBNaattgttKtcttVttaaBtctgctacgBgcWtttcaggacacatMgacatcccagcg +gMgaVKaBattgacttaatgacacacaaaaaatRKaaBctacgtRaDcgtagcVBaacDS +BHaaaaSacatatacagacRNatcttNaaVtaaaataHattagtaaaaSWccgtatWatg +gDttaactattgcccatcttHaSgYataBttBaactattBtcHtgatcaataSttaBtat +KSHYttWggtcYtttBttaataccRgVatStaHaKagaatNtagRMNgtcttYaaSaact +cagDSgagaaYtMttDtMRVgWKWtgMaKtKaDttttgactatacataatcNtatNaHat +tVagacgYgatatatttttgtStWaaatctWaMgagaRttRatacgStgattcttaagaD +taWccaaatRcagcagaaNKagtaaDggcgccBtYtagSBMtactaaataMataBSacRM +gDgattMMgtcHtcaYDtRaDaacggttDaggcMtttatgttaNctaattaVacgaaMMt +aatDccSgtattgaRtWWaccaccgagtactMcgVNgctDctaMScatagcgtcaactat +acRacgHRttgctatttaatgaattataYKttgtaagWgtYttgcHgMtaMattWaWVta +RgcttgYgttBHtYataSccStBtgtagMgtDtggcVaaSBaatagDttgBgtctttctc +attttaNagtHKtaMWcYactVcgcgtatMVtttRacVagDaatcttgctBBcRDgcaac +KttgatSKtYtagBMagaRtcgBattHcBWcaactgatttaatttWDccatttatcgagS +KaWttataHactaHMttaatHtggaHtHagaatgtKtaaRactgtttMatacgatcaagD +gatKaDctataMggtHDtggHacctttRtatcttYattttgacttgaaSaataaatYcgB +aaaaccgNatVBttMacHaKaataagtatKgtcaagactcttaHttcggaattgttDtct +aaccHttttWaaatgaaatataaaWattccYDtKtaaaacggtgaggWVtctattagtga +ctattaagtMgtttaagcatttgSgaaatatccHaaggMaaaattttcWtatKctagDtY +tMcctagagHcactttactatacaaacattaacttaHatcVMYattYgVgtMttaaRtga +aataaDatcaHgtHHatKcDYaatcttMtNcgatYatgSaMaNtcttKcWataScKggta +tcttacgcttWaaagNatgMgHtctttNtaacVtgttcMaaRatccggggactcMtttaY +MtcWRgNctgNccKatcttgYDcMgattNYaRagatHaaHgKctcataRDttacatBatc +cattgDWttatttaWgtcggagaaaaatacaatacSNtgggtttccttacSMaagBatta +caMaNcactMttatgaRBacYcYtcaaaWtagctSaacttWgDMHgaggatgBVgcHaDt +ggaactttggtcNatNgtaKaBcccaNtaagttBaacagtatacDYttcctNgWgcgSMc +acatStctHatgRcNcgtacacaatRttMggaNKKggataaaSaYcMVcMgtaMaHtgat +tYMatYcggtcttcctHtcDccgtgRatcattgcgccgatatMaaYaataaYSggatagc +gcBtNtaaaScaKgttBgagVagttaKagagtatVaactaSacWactSaKatWccaKaaa +atBKgaaKtDMattttgtaaatcRctMatcaaMagMttDgVatggMaaWgttcgaWatga +aatttgRtYtattaWHKcRgctacatKttctaccaaHttRatctaYattaaWatVNccat +NgagtcKttKataStRaatatattcctRWatDctVagttYDgSBaatYgttttgtVaatt +taatagcagMatRaacttBctattgtMagagattaaactaMatVtHtaaatctRgaaaaa +aaatttWacaacaYccYDSaattMatgaccKtaBKWBattgtcaagcHKaagttMMtaat +ttcKcMagNaaKagattggMagaggtaatttYacatcWaaDgatMgKHacMacgcVaaca +DtaDatatYggttBcgtatgWgaSatttgtagaHYRVacaRtctHaaRtatgaactaata +tctSSBgggaaHMWtcaagatKgagtDaSatagttgattVRatNtctMtcSaagaSHaat +aNataataRaaRgattctttaataaagWaRHcYgcatgtWRcttgaaggaMcaataBRaa +ccagStaaacNtttcaatataYtaatatgHaDgcStcWttaacctaRgtYaRtataKtgM +ttttatgactaaaatttacYatcccRWtttHRtattaaatgtttatatttgttYaatMca +RcSVaaDatcgtaYMcatgtagacatgaaattgRtcaaYaaYtRBatKacttataccaNa +aattVaBtctggacaagKaaYaaatatWtMtatcYaaVNtcgHaactBaagKcHgtctac +aatWtaDtSgtaHcataHtactgataNctRgttMtDcDttatHtcgtacatcccaggStt +aBgtcacacWtccNMcNatMVaVgtccDYStatMaccDatggYaRKaaagataRatttHK +tSaaatDgataaacttaHgttgVBtcttVttHgDacgaKatgtatatNYataactctSat +atatattgcHRRYttStggaactHgttttYtttaWtatMcttttctatctDtagVHYgMR +BgtHttcctaatYRttKtaagatggaVRataKDctaMtKBNtMtHNtWtttYcVtattMc +gRaacMcctNSctcatttaaagDcaHtYccSgatgcaatYaaaaDcttcgtaWtaattct +cgttttScttggtaatctttYgtctaactKataHacctMctcttacHtKataacacagcN +RatgKatttttSaaatRYcgDttaMRcgaaattactMtgcgtaagcgttatBtttttaat +taagtNacatHgttcRgacKcBBtVgatKttcgaBaatactDRgtRtgaNacWtcacYtt +aaKcgttctHaKttaNaMgWgWaggtctRgaKgWttSttBtDcNtgtttacaaatYcDRt +gVtgcctattcNtctaaaDMNttttNtggctgagaVctDaacVtWccaagtaacacaNct +gaScattccDHcVBatcgatgtMtaatBgHaatDctMYgagaatgYWKcctaatNaStHa +aaKccgHgcgtYaaYtattgtStgtgcaaRtattaKatattagaWVtcaMtBagttatta +gNaWHcVgcaattttDcMtgtaRHVYtHtctgtaaaaHVtMKacatcgNaatttMatatg +ttgttactagWYtaRacgataKagYNKcattataNaRtgaacKaYgcaaYYacaNccHat +MatDcNgtHttRaWttagaaDcaaaaaatagggtKDtStaDaRtaVtHWKNtgtattVct +SVgRgataDaRaWataBgaagaaKtaataaYgDcaStaNgtaDaaggtattHaRaWMYaY +aWtggttHYgagVtgtgcttttcaaDKcagVcgttagacNaaWtagtaataDttctggtt +VcatcataaagtgKaaaNaMtaBBaattaatWaattgctHaVKaSgDaaVKaHtatatat +HatcatSBagNgHtatcHYMHgttDgtaHtBttWatcgtttaRaattgStKgSKNWKatc +agDtctcagatttctRtYtBatBgHHtKaWtgYBgacVVWaKtacKcDttKMaKaVcggt +gttataagaataaHaatattagtataatMHgttYgaRttagtaRtcaaVatacggtcMcg +agtaaRttacWgactKRYataaaagSattYaWgagatYagKagatgSaagKgttaatMgg +tataatgttWYttatgagaaacctNVataatHcccKtDctcctaatactggctHggaSag +gRtKHaWaattcgSatMatttagaggcYtctaMcgctcataSatatgRagacNaaDagga +VBagaYttKtacNaKgtSYtagttggaWcatcWttaatctatgaVtcgtgtMtatcaYcg +tRccaaYgDctgcMgtgtWgacWtgataacacgcgctBtgttaKtYDtatDcatcagKaV +MctaatcttgVcaaRgcRMtDcgattaHttcaNatgaatMtactacVgtRgatggaWttt +actaaKatgagSaaKggtaNtactVaYtaaKRagaacccacaMtaaMtKtatBcttgtaa +WBtMctaataaVcDaaYtcRHBtcgttNtaaHatttBNgRStVDattBatVtaagttaYa +tVattaagaBcacggtSgtVtatttaRattgatgtaHDKgcaatattKtggcctatgaWD +KRYcggattgRctatNgatacaatMNttctgtcRBYRaaaHctNYattcHtaWcaattct +BtMKtVgYataatMgYtcagcttMDataVtggRtKtgaatgccNcRttcaMtRgattaac +attRcagcctHtWMtgtDRagaKaBtgDttYaaaaKatKgatctVaaYaacWcgcatagB +VtaNtRtYRaggBaaBtgKgttacataagagcatgtRattccacttaccatRaaatgWgD +aMHaYVgVtaSctatcgKaatatattaDgacccYagtgtaYNaaatKcagtBRgagtcca +tgKgaaaccBgaagBtgSttWtacgatWHaYatcgatttRaaNRgcaNaKVacaNtDgat +tgHVaatcDaagcgtatgcNttaDataatcSataaKcaataaHWataBtttatBtcaKtK +tatagttaDgSaYctacaRatNtaWctSaatatttYaKaKtaccWtatcRagacttaYtt +VcKgSDcgagaagatccHtaattctSttatggtKYgtMaHagVaBRatttctgtRgtcta +tgggtaHKgtHacHtSYacgtacacHatacKaaBaVaccaDtatcSaataaHaagagaat +ScagactataaRttagcaaVcaHataKgDacatWccccaagcaBgagWatctaYttgaaa +tctVNcYtttWagHcgcgcDcVaaatgttKcHtNtcaatagtgtNRaactttttcaatgg +WgBcgDtgVgtttctacMtaaataaaRggaaacWaHttaRtNtgctaaRRtVBctYtVta +tDcattDtgaccYatagatYRKatNYKttNgcctagtaWtgaactaMVaacctgaStttc +tgaKVtaaVaRKDttVtVctaDNtataaaDtccccaagtWtcgatcactDgYaBcatcct +MtVtacDaaBtYtMaKNatNtcaNacgDatYcatcgcaRatWBgaacWttKttagYtaat +tcggttgSWttttDWctttacYtatatWtcatDtMgtBttgRtVDggttaacYtacgtac +atgaattgaaWcttMStaDgtatattgaDtcRBcattSgaaVBRgagccaaKtttcDgcg +aSMtatgWattaKttWtgDBMaggBBttBaatWttRtgcNtHcgttttHtKtcWtagHSt +aacagttgatatBtaWSaWggtaataaMttaKacDaatactcBttcaatatHttcBaaSa +aatYggtaRtatNtHcaatcaHtagVtgtattataNggaMtcttHtNagctaaaggtaga +YctMattNaMVNtcKtactBKcaHHcBttaSagaKacataYgctaKaYgttYcgacWVtt +WtSagcaacatcccHaccKtcttaacgaKttcacKtNtacHtatatRtaaatacactaBt +ttgaHaRttggttWtatYagcatYDatcggagagcWBataagRtacctataRKgtBgatg +aDatataSttagBaHtaatNtaDWcWtgtaattacagKttcNtMagtattaNgtctcgtc +ctcttBaHaKcKccgtRcaaYagSattaagtKataDatatatagtcDtaacaWHcaKttD +gaaRcgtgYttgtcatatNtatttttatggccHtgDtYHtWgttatYaacaattcaWtat +NgctcaaaSttRgctaatcaaatNatcgtttaBtNNVtgttataagcaaagattBacgtD +atttNatttaaaDcBgtaSKgacgtagataatttcHMVNttgttBtDtgtaWKaaRMcKM +tHtaVtagataWctccNNaSWtVaHatctcMgggDgtNHtDaDttatatVWttgttattt +aacctttcacaaggaSaDcggttttttatatVtctgVtaacaStDVaKactaMtttaSNa +gtgaaattaNacttSKctattcctctaSagKcaVttaagNaVcttaVaaRNaHaaHttat +gtHttgtgatMccaggtaDcgaccgtWgtWMtttaHcRtattgScctatttKtaaccaag +tYagaHgtWcHaatgccKNRtttagtMYSgaDatctgtgaWDtccMNcgHgcaaacNDaa +aRaStDWtcaaaaHKtaNBctagBtgtattaactaattttVctagaatggcWSatMaccc +ttHttaSgSgtgMRcatRVKtatctgaaaccDNatYgaaVHNgatMgHRtacttaaaRta +tStRtDtatDttYatattHggaBcttHgcgattgaKcKtttcRataMtcgaVttWacatN +catacctRataDDatVaWNcggttgaHtgtMacVtttaBHtgagVttMaataattatgtt +cttagtttgtgcDtSatttgBtcaacHattaaBagVWcgcaSYttMgcttacYKtVtatc +aYaKctgBatgcgggcYcaaaaacgNtctagKBtattatctttKtaVttatagtaYtRag +NtaYataaVtgaatatcHgcaaRataHtacacatgtaNtgtcgYatWMatttgaactacR +ctaWtWtatacaatctBatatgYtaagtatgtgtatSttactVatcttYtaBcKgRaSgg +RaaaaatgcagtaaaWgtaRgcgataatcBaataccgtatttttccatcNHtatWYgatH +SaaaDHttgctgtccHtggggcctaataatttttctatattYWtcattBtgBRcVttaVM +RSgctaatMagtYtttaaaaatBRtcBttcaaVtaacagctccSaaSttKNtHtKYcagc +agaaaccccRtttttaaDcDtaStatccaagcgctHtatcttaDRYgatDHtWcaaaBcW +gKWHttHataagHacgMNKttMKHccaYcatMVaacgttaKgYcaVaaBtacgcaacttt +MctaaHaatgtBatgagaSatgtatgSRgHgWaVWgataaatatttccKagVgataattW +aHNcYggaaatgctHtKtaDtctaaagtMaatVDVactWtSaaWaaMtaHtaSKtcBRaN +cttStggtBttacNagcatagRgtKtgcgaacaacBcgKaatgataagatgaaaattgta +ctgcgggtccHHWHaaNacaBttNKtKtcaaBatatgctaHNgtKcDWgtttatNgVDHg +accaacWctKaaggHttgaRgYaatHcaBacaatgagcaaattactgtaVaaYaDtagat +tgagNKggtggtgKtWKaatacagDRtatRaMRtgattDggtcaaYRtatttNtagaDtc +acaaSDctDtataatcgtactaHttatacaatYaacaaHttHatHtgcgatRRttNgcat +SVtacWWgaaggagtatVMaVaaattScDDKNcaYBYaDatHgtctatBagcaacaagaa +tgagaaRcataaKNaRtBDatcaaacgcattttttaaBtcSgtacaRggatgtMNaattg +gatatWtgagtattaaaVctgcaYMtatgatttttYgaHtgtcttaagWBttHttgtctt +attDtcgtatWtataataSgctaHagcDVcNtaatcaagtaBDaWaDgtttagYctaNcc +DtaKtaHcttaataacccaRKtacaVaatNgcWRaMgaattatgaBaaagattVYaHMDc +aDHtcRcgYtcttaaaWaaaVKgatacRtttRRKYgaatacaWVacVcRtatMacaBtac +tggMataaattttHggNagSctacHgtBagcgtcgtgattNtttgatSaaggMttctttc +ttNtYNagBtaaacaaatttMgaccttacataattgYtcgacBtVMctgStgMDtagtaR +ctHtatgttcatatVRNWataDKatWcgaaaaagttaaaagcacgHNacgtaatctttMR +tgacttttDacctataaacgaaatatgattagaactccSYtaBctttaataacWgaaaYa +tagatgWttcatKtNgatttttcaagHtaYgaaRaDaagtaggagcttatVtagtctttc +attaaaatcgKtattaRttacagVaDatgcatVgattgggtctttHVtagKaaRBtaHta +aggccccaaaaKatggtttaMWgtBtaaacttcactttKHtcgatctccctaYaBacMgt +cttBaBaNgcgaaacaatctagtHccHtKttcRtRVttccVctttcatacYagMVtMcag +aMaaacaataBctgYtaatRaaagattaaccatVRatHtaRagcgcaBcgDttStttttc +VtttaDtKgcaaWaaaaatSccMcVatgtKgtaKgcgatatgtagtSaaaDttatacaaa +catYaRRcVRHctKtcgacKttaaVctaDaatgttMggRcWaacttttHaDaKaDaBctg +taggcgtttaHBccatccattcNHtDaYtaataMttacggctNVaacDattgatatttta +cVttSaattacaaRtataNDgacVtgaacataVRttttaDtcaaacataYDBtttaatBa +DtttYDaDaMccMttNBttatatgagaaMgaNtattHccNataattcaHagtgaaggDga +tgtatatatgYatgaStcataaBStWacgtcccataRMaaDattggttaaattcMKtctM +acaBSactcggaatDDgatDgcWctaacaccgggaVcacWKVacggtaNatatacctMta +tgatagtgcaKagggVaDtgtaacttggagtcKatatcgMcttRaMagcattaBRaStct +YSggaHYtacaactMBaagDcaBDRaaacMYacaHaattagcattaaaHgcgctaaggSc +cKtgaaKtNaBtatDDcKBSaVtgatVYaagVtctSgMctacgttaacWaaattctSgtD +actaaStaaattgcagBBRVctaatatacctNttMcRggctttMttagacRaHcaBaacV +KgaataHttttMgYgattcYaNRgttMgcVaaacaVVcDHaatttgKtMYgtatBtVVct +WgVtatHtacaaHttcacgatagcagtaaNattBatatatttcVgaDagcggttMaagtc +ScHagaaatgcYNggcgtttttMtStggtRatctacttaaatVVtBacttHNttttaRca +aatcacagHgagagtMgatcSWaNRacagDtatactaaDKaSRtgattctccatSaaRtt +aaYctacacNtaRtaactggatgaccYtacactttaattaattgattYgttcagDtNKtt +agDttaaaaaaaBtttaaNaYWKMBaaaacVcBMtatWtgBatatgaacVtattMtYatM +NYDKNcKgDttDaVtaaaatgggatttctgtaaatWtctcWgtVVagtcgRgacttcccc +taDcacagcRcagagtgtWSatgtacatgttaaSttgtaaHcgatgggMagtgaacttat +RtttaVcaccaWaMgtactaatSSaHtcMgaaYtatcgaaggYgggcgtgaNDtgttMNg +aNDMtaattcgVttttaacatgVatgtWVMatatcaKgaaattcaBcctccWcttgaaWH +tWgHtcgNWgaRgctcBgSgaattgcaaHtgattgtgNagtDttHHgBttaaWcaaWagc +aSaHHtaaaVctRaaMagtaDaatHtDMtcVaWMtagSagcttHSattaacaaagtRacM +tRtctgttagcMtcaBatVKtKtKacgagaSNatSactgtatatcBctgagVtYactgta +aattaaaggcYgDHgtaacatSRDatMMccHatKgttaacgactKtgKagtcttcaaHRV +tccttKgtSataatttacaactggatDNgaacttcaRtVaagDcaWatcBctctHYatHa +DaaatttagYatSatccaWtttagaaatVaacBatHcatcgtacaatatcgcNYRcaata +YaRaYtgattVttgaatgaVaactcRcaNStgtgtattMtgaggtNttBaDRcgaaaagc +tNgBcWaWgtSaDcVtgVaatMKBtttcgtttctaaHctaaagYactgMtatBDtcStga +ccgtSDattYaataHctgggaYYttcggttaWaatctggtRagWMaDagtaacBccacta +cgHWMKaatgatWatcctgHcaBaSctVtcMtgtDttacctaVgatYcWaDRaaaaRtag +atcgaMagtggaRaWctctgMgcWttaagKBRtaaDaaWtctgtaagYMttactaHtaat +cttcataacggcacBtSgcgttNHtgtHccatgttttaaagtatcgaKtMttVcataYBB +aKtaMVaVgtattNDSataHcagtWMtaggtaSaaKgttgBtVtttgttatcatKcgHac +acRtctHatNVagSBgatgHtgaRaSgttRcctaacaaattDNttgacctaaYtBgaaaa +tagttattactcttttgatgtNNtVtgtatMgtcttRttcatttgatgacacttcHSaaa +ccaWWDtWagtaRDDVNacVaRatgttBccttaatHtgtaaacStcVNtcacaSRttcYa +gacagaMMttttgMcNttBcgWBtactgVtaRttctccaaYHBtaaagaBattaYacgat +ttacatctgtaaMKaRYtttttactaaVatWgctBtttDVttctggcDaHaggDaagtcg +aWcaagtagtWttHtgKtVataStccaMcWcaagataagatcactctHatgtcYgaKcat +cagatactaagNSStHcctRRNtattgtccttagttagMVgtatagactaactctVcaat +MctgtttgtgttgccttatWgtaBVtttctggMcaaKgDWtcgtaaYStgSactatttHg +atctgKagtagBtVacRaagRtMctatgggcaaaKaaaatacttcHctaRtgtDcttDat +taggaaatttcYHaRaaBttaatggcacKtgctHVcaDcaaaVDaaaVcgMttgtNagcg +taDWgtcgttaatDgKgagcSatatcSHtagtagttggtgtHaWtaHKtatagctgtVga +ttaBVaatgaataagtaatVatSttaHctttKtttgtagttaccttaatcgtagtcctgB +cgactatttVcMacHaaaggaatgDatggKtaHtgStatattaaSagctWcctccRtata +BaDYcgttgcNaagaggatRaaaYtaWgNtSMcaatttactaacatttaaWttHtatBat +tgtcgacaatNgattgcNgtMaaaKaBDattHacttggtRtttaYaacgVactBtaBaKt +gBttatgVttgtVttcaatcWcNctDBaaBgaDHacBttattNtgtDtatttVSaaacag +gatgcRatSgtaSaNtgBatagttcHBgcBBaaattaHgtDattatDaKaatBaaYaaMa +ataaataKtttYtagtBgMatNcatgtttgaNagtgttgtgKaNaSagtttgaSMaYBca +aaacDStagttVacaaaaactaaWttBaagtctgtgcgtMgtaattctcctacctcaNtt +taaccaaaaVtBcacataacaccccBcWMtatVtggaatgaWtcaaWaaaaaaaaWtDta +atatRcctDWtcctaccMtVVatKttaWaaKaaatataaagScHBagaggBaSMtaWaVt +atattactSaaaKNaactatNatccttgaYctattcaaaVgatttYHcRagattttaSat +aggttattcVtaaagaKgtattattKtRttNcggcRgtgtgtWYtaacHgKatKgatYta +cYagDtWcHBDctctgRaYKaYagcactKcacSaRtBttttBHKcMtNtcBatttatttt +tgSatVgaaagaWtcDtagDatatgMacaacRgatatatgtttgtKtNRaatatNatgYc +aHtgHataacKtgagtagtaacYttaNccaaatHcacaacaVDtagtaYtccagcattNt +acKtBtactaaagaBatVtKaaHBctgStgtBgtatgaSNtgDataaccctgtagcaBgt +gatcttaDataStgaMaccaSBBgWagtacKcgattgaDgNNaaaacacagtSatBacKD +gcgtataBKcatacactaSaatYtYcDaactHttcatRtttaatcaattataRtttgtaa +gMcgNttcatcBtYBagtNWNMtSHcattcRctttttRWgaKacKttgggagBcgttcgc +MaWHtaatactgtctctatttataVgtttaBScttttaBMaNaatMacactYtBMggtHa +cMagtaRtctgcatttaHtcaaaatttgagKtgNtactBacaHtcgtatttctMaSRagc +agttaatgtNtaaattgagagWcKtaNttagVtacgatttgaatttcgRtgtWcVatcgt +taaDVctgtttBWgaccagaaagtcSgtVtatagaBccttttcctaaattgHtatcggRa +ttttcaaggcYSKaagWaWtRactaaaacccBatMtttBaatYtaagaactSttcgaaSc +aatagtattgaccaagtgttttctaacatgtttNVaatcaaagagaaaNattaaRtttta +VaaaccgcaggNMtatattVctcaagaggaacgBgtttaacaagttcKcYaatatactaa +ccBaaaSggttcNtattctagttRtBacgScVctcaatttaatYtaaaaaaatgSaatga +tagaMBRatgRcMcgttgaWHtcaVYgaatYtaatctttYttatRaWtctgBtDcgatNa +tcKaBaDgatgtaNatWKctccgatattaacattNaaacDatgBgttctgtDtaaaMggt +gaBaSHataacgccSctaBtttaRBtcNHcDatcDcctagagtcRtaBgWttDRVHagat +tYatgtatcWtaHtttYcattWtaaagtctNgtStggRNcgcggagSSaaagaaaatYcH +DtcgctttaatgYcKBVSgtattRaYBaDaaatBgtatgaHtaaRaRgcaSWNtagatHa +acttNctBtcaccatctMcatattccaSatttgcgaDagDgtatYtaaaVDtaagtttWV +aagtagYatRttaagDcNgacKBcScagHtattatcDaDactaaaaaYgHttBcgaDttg +gataaaKSRcBMaBcgaBSttcWtgNBatRaccgattcatttataacggHVtaattcaca +agagVttaaRaatVVRKcgWtVgacctgDgYaaHaWtctttcacMagggatVgactagMa +aataKaaNWagKatagNaaWtaaaatttgaattttatttgctaaVgaHatBatcaaBWcB +gttcMatcgBaaNgttcgSNaggSaRtttgHtRtattaNttcDcatSaVttttcgaaaaa +ttgHatctaRaggSaNatMDaaatDcacgattttagaHgHaWtYgattaatHNSttatMS +gggNtcKtYatRggtttgtMWVtttaYtagcagBagHaYagttatatggtBacYcattaR +SataBatMtttaaatctHcaaaSaaaagttNSaaWcWRccRtKaagtBWtcaaattSttM +tattggaaaccttaacgttBtWatttatatWcDaatagattcctScacctaagggRaaYt +aNaatgVtBcttaaBaacaMVaaattatStYgRcctgtactatcMcVKatttcgSgatRH +MaaaHtagtaaHtVgcaaataatatcgKKtgccaatBNgaaWcVttgagttaKatagttc +aggKDatDtattgaKaVcaKtaataDataataHSaHcattagttaatRVYcNaHtaRcaa +ggtNHcgtcaaccaBaaagYtHWaaaRcKgaYaaDttgcWYtataRgaatatgtYtgcKt +aNttWacatYHctRaDtYtattcBttttatcSataYaYgttWaRagcacHMgtttHtYtt +YaatcggtatStttcgtRSattaaDaKMaatatactaNBaWgctacacYtgaYVgtgHta +aaRaaRgHtagtWattataaaSDaaWtgMattatcgaaaagtaYRSaWtSgNtBgagcRY +aMDtactaacttaWgtatctagacaagNtattHggataatYttYatcataDcgHgttBtt +ctttVttgccgaaWtaaaacgKgtatctaaaaaNtccDtaDatBMaMggaatNKtatBaa +atVtccRaHtaSacataHattgtttKVYattcataVaattWtcgtgMttcttKtgtctaa +cVtatctatatBRataactcgKatStatattcatHHRttKtccaacgtgggtgRgtgaMt +attattggctatcgtgacMtRcBDtcttgtactaatRHttttaagatcgVMDStattatY +BtttDttgtBtNttgRcMtYtgBacHaWaBaatDKctaagtgaaactaatgRaaKgatcc +aagNaaaatattaggWNtaagtatacttttKcgtcggSYtcttgRctataYcttatataa +agtatattaatttataVaacacaDHatctatttttKYVatHRactttaBHccaWagtact +BtcacgaVgcgttRtttttttSVgtSagtBaaattctgaHgactcttgMcattttagVta +agaattHctHtcaDaaNtaacRggWatagttcgtSttgaDatcNgNagctagDgatcNtt +KgttgtaDtctttRaaYStRatDtgMggactSttaDtagSaVtBDttgtDgccatcacaM +attaaaMtNacaVcgSWcVaaDatcaHaatgaattaMtatccVtctBtaattgtWattat +BRcWcaatgNNtactWYtDaKttaaatcactcagtRaaRgatggtKgcgccaaHgaggat +StattYcaNMtcaBttacttatgagDaNtaMgaaWtgtttcttctaHtMNgttatctaWW +atMtBtaaatagDVatgtBYtatcggcttaagacMRtaHScgatatYgRDtcattatSDa +HggaaataNgaWSRRaaaBaatagBattaDctttgHWNttacaataaaaaaatacggttt +gHgVtaHtWMttNtBtctagtMcgKMgHgYtataHaNagWtcaacYattaataYRgtaWK +gaBctataaccgatttaHaNBRaRaMtccggtNgacMtctcatttgcaattcWgMactta +caaDaaNtactWatVtttagccttMaatcagVaagtctVaaDaBtattaattaYtNaYtg +gattaKtaKctYaMtattYgatattataatKtVgDcttatatNBtcgttgtStttttMag +aggttaHYSttcKgtcKtDNtataagttataagSgttatDtRttattgttttSNggRtca +aKMNatgaatattgtBWtaMacctgggYgaSgaagYataagattacgagaatBtggtRcV +HtgYggaDgaYaKagWagctatagacgaaHgtWaNgacttHRatVaWacKYtgRVNgVcS +gRWctacatcKSactctgWYtBggtataagcttNRttVtgRcaWaaatDMatYattaact +ttcgaagRatSctgccttgcRKaccHtttSNVagtagHagBagttagaccaRtataBcca +taatSHatRtcHagacBWatagcaMtacaRtgtgaaBatctKRtScttccaNaatcNgta +atatWtcaMgactctBtWtaaNactHaaaaRctcgcatggctMcaaNtcagaaaaacaca +gtggggWttRttagtaagaVctVMtcgaatcttcMaaaHcaHBttcgattatgtcaDagc +YRtBtYcgacMgtDcagcgaNgttaataatagcagKYYtcgtaBtYctMaRtaRtDagaa +aacacatgYaBttgattattcgaaNttBctSataaMataWRgaHtttccgtDgaYtatgg +tDgHKgMtatttVtMtVagttaRatMattRagataaccctKctMtSttgaHagtcStcta +tttccSagatgttccacgaggYNttHRacgattcDatatDcataaaatBBttatcgaHtN +HaaatatDNaggctgaNcaaggagttBttMgRagVatBcRtaWgatgBtSgaKtcgHttt +gaatcaaDaHttcSBgHcagtVaaSttDcagccgttNBtgttHagYtattctttRWaaVt +SttcatatKaaRaaaNacaVtVctMtSDtDtRHRcgtaatgctcttaaatSacacaatcg +HattcaWcttaaaatHaaatcNctWttaNMcMtaKctVtcctaagYgatgatcYaaaRac +tctaRDaYagtaacgtDgaggaaatctcaaacatcaScttcKttNtaccatNtaNataca +tttHaaDHgcaDatMWaaBttcRggctMaagctVYcacgatcaDttatYtaatcKatWat +caatVYtNagatttgattgaYttttYgacttVtcKaRagaaaHVgDtaMatKYagagttN +atWttaccNtYtcDWgSatgaRgtMatgKtcgacaagWtacttaagtcgKtgatccttNc +ttatagMatHVggtagcgHctatagccctYttggtaattKNaacgaaYatatVctaataM +aaaYtgVtcKaYtaataacagaatHcacVagatYWHttagaaSMaatWtYtgtaaagNaa +acaVgaWtcacNWgataNttcaSagctMDaRttgNactaccgataMaaatgtttattDtc +aagacgctDHYYatggttcaagccNctccttcMctttagacBtaaWtaWVHggaaaaNat +ttaDtDtgctaaHHtMtatNtMtagtcatttgcaaaRatacagRHtatDNtgtDgaatVg +tVNtcaaatYBMaaaagcaKgtgatgatMgWWMaHttttMgMagatDtataaattaacca +actMtacataaattgRataatacgBtKtaataattRgtatDagDtcRDacctatRcagag +cSHatNtcaScNtttggacNtaaggaccgtgKNttgttNcttgaaRgYgRtNtcagttBc +ttttcHtKtgcttYaaNgYagtaaatgaatggWaMattBHtatctatSgtcYtgcHtaat +tHgaaMtHcagaaSatggtatgccaHBtYtcNattWtgtNgctttaggtttgtWatNtgH +tgcDttactttttttgcNtactKtWRaVcttcatagtgSNKaNccgaataaBttataata +YtSagctttaaatSttggctaaKSaatRccgWHgagDttaaatcatgagMtcgagtVtaD +ggaBtatttgDacataaacgtagYRagBWtgDStKDgatgaagttcattatttaKWcata +aatWRgatataRgttRacaaNKttNtKagaaYaStaactScattattaacgatttaaatg +DtaattagatHgaYataaactatggggatVHtgccgtNgatNYcaStRtagaccacWcaM +tatRagHgVactYtWHtcttcatgatWgagaKggagtatgaWtDtVtNaNtcgYYgtaaa +ctttaDtBactagtaDctatagtaatatttatatataacgHaaaRagKattSagttYtSt +>THREE Homo sapiens frequency +agagagacgatgaaaattaatcgtcaatacgctggcgaacactgagggggacccaatgct +cttctcggtctaaaaaggaatgtgtcagaaattggtcagttcaaaagtagaccggatctt +tgcggagaacaattcacggaacgtagcgttgggaaatatcctttctaccacacatcggat +tttcgccctctcccattatttattgtgttctcacatagaattattgtttagacatccctc +gttgtatggagagttgcccgagcgtaaaggcataatccatataccgccgggtgagtgacc +tgaaattgtttttagttgggatttcgctatggattagcttacacgaagagattctaatgg +tactataggataattataatgctgcgtggcgcagtacaccgttacaaacgtcgttcgcat +atgtggctaacacggtgaaaatacctacatcgtatttgcaatttcggtcgtttcatagag +cgcattgaattactcaaaaattatatatgttgattatttgattagactgcgtggaaagaa +ggggtactcaagccatttgtaaaagctgcatctcgcttaagtttgagagcttacattagt +ctatttcagtcttctaggaaatgtctgtgtgagtggttgtcgtccataggtcactggcat +atgcgattcatgacatgctaaactaagaaagtagattactattaccggcatgcctaatgc +gattgcactgctatgaaggtgcggacgtcgcgcccatgtagccctgataataccaatact +tacatttggtcagcaattctgacattatacctagcacccataaatttactcagacttgag +gacaggctcttggagtcgatcttctgtttgtatgcatgtgatcatatagatgaataagcg +atgcgactagttagggcatagtatagatctgtgtatacagttcagctgaacgtccgcgag +tggaagtacagctgagatctatcctaaaatgcaaccatatcgttcacacatgatatgaac +ccagggggaaacattgagttcagttaaattggcagcgaatcccccaagaagaaggcggag +tgacgttgaacgggcttatggtttttcagtacttcctccgtataagttgagcgaaatgta +aacagaataatcgttgtgttaacaacattaaaatcgcggaatatgatgagaatacacagt +gtgagcatttcacttgtaaaatatctttggtagaacttactttgctttaaatatgttaaa +ccgatctaataatctacaaaacggtagattttgcctagcacattgcgtccttctctattc +agatagaggcaatactcagaaggttttatccaaagcactgtgttgactaacctaagtttt +agtctaataatcatgattgattataggtgccgtggactacatgactcgtccacaaataat +acttagcagatcagcaattggccaagcacccgacttttatttaatggttgtgcaatagtc +cagattcgtattcgggactctttcaaataatagtttcctggcatctaagtaagaaaagct +cataaggaagcgatattatgacacgctcttccgccgctgttttgaaacttgagtattgct +cgtccgaaattgagggtcacttcaaaatttactgagaagacgaagatcgactaaagttaa +aatgctagtccacagttggtcaagttgaattcatccacgagttatatagctattttaatt +tatagtcgagtgtacaaaaaacatccacaataagatttatcttagaataacaacccccgt +atcatcgaaatcctccgttatggcctgactcctcgagcttatagcatttgtgctggcgct +cttgccaggaacttgctcgcgaggtggtgacgagtgagatgatcagtttcattatgatga +tacgattttatcgcgactagttaatcatcatagcaagtaaaatttgaattatgtcattat +catgctccattaacaggttatttaattgatactgacgaaattttttcacaatgggttttc +tagaatttaatatcagtaattgaagccttcataggggtcctactagtatcctacacgacg +caggtccgcagtatcctggagggacgtgttactgattaaaagggtcaaaggaatgaaggc +tcacaatgttacctgcttcaccatagtgagccgatgagttttacattagtactaaatccc +aaatcatactttacgatgaggcttgctagcgctaaagagaatacatacaccaccacatag +aattgttagcgatgatatcaaatagactcctggaagtgtcagggggaaactgttcaatat +ttcgtccacaggactgaccaggcatggaaaagactgacgttggaaactataccatctcac +gcccgacgcttcactaattgatgatccaaaaaatatagcccggattcctgattagcaaag +ggttcacagagaaagatattatcgacgtatatcccaaaaaacagacgtaatgtgcatctt +cgaatcgggatgaatacttgtatcataaaaatgtgacctctagtatacaggttaatgtta +gtgatacacaatactcgtgggccatgggttctcaaataaaatgtaatattgcgtcgatca +ctcacccacgtatttggtctaattatgttttatttagtgacaatccaatagataaccggt +cctattaagggctatatttttagcgaccacgcgtttaaacaaaggattgtatgtagatgg +taccagtttaattgccagtgggcaatcctaagcaaaatgagattctatcctaaagtttgg +gcttgatataagatttcggatgtatgggttttataatcgttggagagctcaatcatgagc +taatacatggatttcgctacctcaccgagagaccttgcatgaagaattctaaccaaaagt +ttaataggccggattggattgagttaattaagaccttgttcagtcatagtaaaaaccctt +aaattttaccgattgacaaagtgagcagtcgcaataccctatgcgaaacgcctcgatagt +gactaggtatacaaggtttttgagttcctttgaaatagttaactaatttaaaattaatta +acgacatggaaatcacagaacctaatgctttgtaggagttatttatgctgtttactgcct +ctacaaccctaataaagcagtcctaagaatgaaacgcatcttttagttcagaaagtggta +tccagggtggtcaatttaataaattcaacatcgggtctcaggatattcggtcatataatt +tattaagggctcttcgagtcttactctgagtgaaattggaaacagtcatccttttcgttg +tgaggcatcttacaccgctatcgatatacaatgcattccaccgcggtgtcccgtacacaa +ggaaacttgttaccttggggatataagaaaactcacacgtctcattattaaactgagtac +aatttttgcacgagaaagtaatgcaatacaatatgatgaaagccagctaatgaaaaggga +tggaacgcacctcggatctgttgcactggattaaaatccgattatttttaaaaatattca +gtgctagagcatatcaggtctacttttttatctggtatgtaaagcccacggagcgatagt +gagatccttacgactcaacgaaaagttataacataactcccgttagccaaagcccaatcc +cgattactgccctaccctaacgtctgccatctaaatatcgaacttgttatgatcaatgtg +actacctcccaccctttccccttcatttgttccactggggataagctagcgttttcagaa +tcaatgcaataagaatagccaattgtctcacttcatcagagctcttggcaattccaggcg +ctacgtggttctggaatatattcatttttcaaatagtaatacgtttagtgttgctattgt +ctacacgtttggatattacgttatgtgagcggacatcaatagttgtctaactctttagta +agccagagatagcactcttagcgaatggataccatcttccataagtttagttaatagtcc +gaaacaactgcttcgagcatatttgaacctccttgtaggcaaatagcctcttcaaagcaa +tcttactaatagatagagtttgttttaagggactactagaaatgggacaatcttaatagt +atgacctaaactgacatttaaagatatatccaggtggcaagcataaagatcattgcgcca +cctccaccgtgggattacttatcagtcgatatcctatatgctaagtttgcgacggcagaa +tacaaactaagctgagttgatgctaaccttacctatgataccccattggaccggttaaca +gccctacttattccaaataaaagaacttttatgctgtagaagctattatagtgatgcctg +gtaacttcagtatattaaaatgacacacatacgccatatagagctcctggaactttgaat +aatgagcgaacttcgaagttgaagagcaagaaaccatatgtcacggttgcctaaagcccg +gtaaccagacatgtgctatcattgatcattatcgaggttttcataaccttgacccattat +cggctgtgcgcggacaagtacttaaatcactagtttcttcacctgcttatcggtaagaaa +taaggttggcaaagaatcgcataagacggacgtagagccgcagcgttgtgcgagtccagg +tgcatgcgcagcaataggattttaaattttgttccatttttaatttagccgtaaggatgt +ccgtaaatgattgaaaattggattcaatctttgggcctatgctactggaacctgatcgac +aaaatttcaaacatacgttaactccgaaagaccgtatttttgcggctagaatagtcagtc +gcttggagccatataccttaccacttaaacgacgtgctcctgtagttgaaatataaacag +aacacaaagactaccgatcatatcaactgaagatctttgtaactttgaggcgaagcaccc +tcttcgagacaactaagagtaaagtaccgggcgccgcaaggagtcgattgggaccctaaa +tcttgacgaattgctaagaggctcagagctaccactgtaatttctctagagcccataata +aatgaacgatacatccgtaggtagcacctaagggattataatggaagccaaatgcagtta +ataatattatatactggcgtacacgattcgacggatctctcacatagtgattcacgaccc +ccccctttgattgacacagcgtcagcattttgcaagaacgatcttctgcatagggtgcgc +caccgtaaggatgacgtcgaagctacaactgggtataatttaccatgcttccctgatgct +gagtgcaatacactaagaatgagtttttaccccatatcaccagtatttgttctgttattg +cgaagaaatggctatgctgagttggcgactaaagtcacccatcctttttattaggtaacc +ccctcccttaaactaactgatttgctggagctgccctgcatacatatactttatcattta +tggacgtccgtgacgcttattatccaccatagtcgatatgctacacggattcattaatgg +atcgtaggagtttaagttatatttactaagatcggtctcggctactatcccgccttaccc +ggcgctatttacggccatttttaatatattgacggtaattattcctatggtttcgaccgc +acgtccttggacaagaaagaatggcaaaaaaaatgtaaaagaaaaaaaatattgagtccc +taccatcatataaaaaatatgtgatgagtaacttgacgaaatgttagtggttattaaaga +ctatctattacaccttttgttttctgtcgtagtatattaaagtctagaagccttacagga +aaatcagggttatacagccgatactccgcagcatgaatcatcgaggaggtgtcctaccat +cgcgccttgtaatcttgtctgtgtatactgtatttagaccttttatacaaagtaaatatc +tcggctttatgtgattgggaggggcctactcaaacatgatgacttgacctaataatcact +gtgcgggcgtcttatgactagctattccttgaaatccaccaccaaatggttaatatgtaa +aaactttgacgatgaaacaaggtgaatgtgtagttactttgtgtaattagctgcgtcgag +cattgcttgtaaaaccgtcaatcgcacacgttacttccataaaatttctacgaatacacc +cttcttaaaaaaaacgtaggaattcacgagtttaacaaacgataactgtataaagtggaa +gtccgaagaaagcagatgcccgaactactcgaagatgtttcgttttcttaaccatagggg +cttcttaatggcccactacgcacattttgttcaagcccgagagggacatccccattacgg +gagtattactaaaactgttccgtaatacgttcagcaagggatgaaaaaggccactgctca +agttattgacgtgggagtattacatcggaagcctgaatcccacactatgatggtctgtac +aggcctagggactgcgtctagacggtattaccggcttctaatcatacgatcgtgagtctt +aacgggaagtaaggctcacacctaccccaaaccatttatctatgtaagtataaaattgtg +cgtaagtgttcaaagtggacaataaagacgtggcaaaaacccccgcacataagccgcttt +agatttcacaaataccaatgcggttaaaaacatccttgagtcgtacatacaccatactcg +cgttaaacggatataacagaagataataaatccggatgtggagtcggtgtaactatagaa +agccaagtgaaataatgcttaccagtcatttagctatacggctttcatttcatgtcaaga +gggtggagtttgacctgtacagttgatatatcaccgatacttagaactcacctaaagcta +aaattgctcgcagcgtgtaatccgcatattacaaacaatagatgggattcattatacata +agacacgatgatctgctttttcaggttgcgagatgttgcctatcgtcaatcgagtcctgc +cttacaccacttaaacaaaagtattgacagggaacctattttcgaggtattatatagtcc +agcttgaatatcaatttgacagttaacctagtgaaaatcagtaagaggaaatacgccaca +ttctccagtgaaattctacgggttatcgtctagtccaactatcaattataactcacgaga +tataagtaaattctcgtacttggcctgatttttattatactttggatccttagtaaacag +gaagggagaaaccttcaacgaaaaacactggattttgttttactctcaaagctcttatat +gacggaaataccctgtcaagtcttaactttattactagactaatgaaatgggcttggggt +ggccagaatcatagtacaatttagcggatacactattcggactttcctatcggctgtctg +gttggataagtatggggactaataggctagacatacctatacttaaactatacaggcgtc +atctatctctgcaactttggagttccctgatgttctcccgccctttgggttcacatcttc +tataccgacacccctaataacgattagtttgtgggttagagtaaattaatacggttaata +ttaatgtatcgttgaaaagctggtgtcgccaataaggtaaccggctaggcagagtatatg +tcacgaagtataactaccctaatgataagctgtaggaataaaattaatgctgtctctaag +cgaagagatatttccgactctgttttaatgacgaatctcattacttctgacttgcaaatg +ttcaatatggcacggtttcacggcacctttgtgacgcatataatgaacttagaagattat +aacgacggaactttatatgataatccgttacgattaaagaatctgttaaatatcataatg +gcattcagttctagaccgtgcatcatggtaaacttactttctctgcatggcgacatacat +ttcgctattcaaattcgcgtgtggttacacccactcgcacctttggaatattaagagaag +atgatcagaaaatccattcgctcaatttttctgacgtacgtctaatttatcctaggagac +aaatcgttttatgtctctcacatttttgaagaaaggttcgagagacaatactcaggtcct +gaactgctagaagatactcggtggagcgtggcaacaatgaaaaactcgtgacataaatga +atgatacttttccaagttcagttaagtgaatatgtttaacatacccggcttttcgatctt +aagctgacgctggacgtgcgagtaatgtcagtctcttacatacactagtgactccaagtt +tcgtcaaaaacgccccctcccttctcgagcccactcacgctatgtattgacgcgaacttg +ttcgggatcagacttttcaggagttcggtcgcgtgtccctatgtgctaatatataagtta +gatcgcattagatgctaatctgaatacttatagacgaccttcaacgagaacgggtaccac +cttgaggctagagttaggtgtgaaacgacaggtagggacatataaaatttgagtgcggct +ttagttaagggtttaattacctactcaaacatcacgctcgcgcccttcgtacgtaatcga +ccatctagaggctaaggggactgtactaggtagtgattaatgatatcctagacgcacgtg +ccttagatcttcagactctgatggtccgcgatcaccgtaattgtagtcctccaactcgat +cactttgttggcgtcaaagaaattacgatatctaaatacttataatacaataaccaagga +tgagaatgactcatcgcgttggagttatattgcttgaagttctatggaatgaaagcacgt +tatctgccgtcccaatatctccagtgagctaattcattggacggtccactttgatcaatc +cccgaggagatgttcggacactttagtctgtaacacttagcgttgagaccacgaacaatt +gattactcagtcttgaaggtgttttccaaagttcattttaaataagactacgataggcct +ttcctattgatataaactacccggctctgttgttcgtgtgagtcgtacttctctgtgttt +ttctgattatagcaagattcgattcttagtgtaaacagcgatttttatttgacccgtcaa +tgagaagcgcataggatctaagcaaaattatcaagttgtgccacaaggtaagatctttcc +agttattgcaggtaggatgtatcccacgttgatagtatgaggtctgacgtcaactgtcta +ggagagttgaccgcgtgcgggtacaccggatttgcatcgatgttgagaacgcagaactcc +cactgtcgtggcggcgttcctgatatttagcaagaggcgttgataaagccctcatcatct +agatctcgacctcatctgccctcttgctccatcattttctacacagactactttcctatc +tacgttagtataattgctttctatcttagtatcatttagagcttctccgtcaacaggttc +gtgctattaaagttagtacgaaagggacaacttgtagcaacgcatttaatcggttttcga +ctacttcgcacaaaatcagataaagaagtttgtcattctattagacattgaattgcgcaa +ttgacttgtaccacttatgatcgaacactgaatcaagactgtgattaactaaaatagaca +agccactatatcaactaataaaaacgcccctggtggtcgaacatagttgactacaggata +attaattggactggagccattacattctctacaatcgtatcacttcccaagtagacaact +ttgaccttgtagtttcatgtacaaaaaaatgctttcgcaggagcacattggtagttcaat +agtttcatgggaacctcttgagccgtcttctgtgggtgtgttcggatagtaggtactgat +aaagtcgtgtcgctttcgatgagagggaattcaccggaaaacaccttggttaacaggata +gtctatgtaaacttcgagacatgtttaagagttaccagcttaatccacggtgctctacta +gtatcatcagctgtcttgcctcgcctagaaatatgcattctatcgttatcctatcaacgg +ttgccgtactgagcagccttattgtggaagagtaatatataaatgtagtcttgtctttac +gaagcagacgtaagtaataatgacttggaataccaaaactaaacatagtggattatcata +ctcaagaactctccagataaataacagtttttacgatacgtcaccaatgagcttaaagat +taggatcctcaaaactgatacaaacgctaattcatttgttattggatccagtatcagtta +aactgaatggagtgaagattgtagaatgttgttctggcctcgcatggggtctaggtgata +tacaatttctcatacttacacggtagtggaaatctgattctagcttcgtagctgactata +ctcaaggaaccactgctcaaggtaggagactagttccgaccctacagtcaaagtggccga +agcttaaactatagactagttgttaaatgctgatttcaagatatcatctatatacagttt +ggacaattatgtgtgcgaaactaaaattcatgctattcagatggatttcacttatgcctt +agaaacagatattgcccgagctcaatcaacagttttagccggaaacaatcgaagcatagg +gacaatgtatcttttcctaaattgccatgtgcagatttctgagtgtcacgaagcgcataa +tagaatcttgtgttgcctcaactcgttgaaaagtttaaaacaatcgcagcagtctttttg +gggtctactgtgtgtttgcaaaataactgaaagaaacgcttgaacaactctgaagtagct +cgagtactcattaaagtgtaacacattagtgaatatcggccaatgaaccaaacgcttccc +ggtacgctatctctctcatcgggaggcgatgtgcaggttatctacgaaagcatcccttta +cgttgagagtgtcgatgcatgaacctcattgtaacaatagcccagcaaattctcatacgt +gcctcagggtccgggcgtactcctccatggaagggcgcgcatctagtgttataccaactc +gctttttaactactatgctgtagttctacaggcatagtggccagtattttctaacttctc +tggatagatgctctcactcctcatccatcacggcttcagtttacgtcttacttgcttgtt +cagcaacggatggaggcattaagtatcttcactgttccctaaaattgctgttcaatatca +aagtaaggacgatacagggaaagctcaagcacactcattgaatactgccccagttgcaac +ctcacttaatctgacaaaaataatgactactctaagtgttgcggaagcagtctcttccac +gagcttgtctgtatcacttcgtataggcatgtaactcgatagacacgaacaccgagtgag +aaactatattcttgcttccgtgtgtgtgacaccaggtaattgatgcggatataagctgga +gatcactcacgcccacacaaggcgctgctacctctttattccaatgtgtaagaatttgct +aacttcatttctagaccgcagctttgcggtcataatttcacggtacggacccttgggtta +gagacttgataacacacttcgcagtttccaccgcgcacatgttttagtggcttctaacat +agaatttttgttgtgacataaagagtgcgtgggagacttgcccgaccgttaagccataat +caattgaaagccccgtgagtcacatctaattggttgtactgcgcatttagctatccttta +gctgactcgaagagattcgattcctaatataggttaattagatggctgccgcgcgaagta +aaacgtgaaaaacgtagtgcgcagatctgcataactcgcgcttaattacttatgagtagt +tccaagttcgctacgttatgagagagattggaattaagcaaatatgttttatggtgattt +tgggatgagaaggactgctaagtacggctactaaacaaatttctaaaaccgccatctacc +ttatcttggagacatttaagttgtatatgtcactagtctagcttttgtctgtgggacgcg +ttctcggaatgagggaaatgcaagagccgattcatcaaatgcttatctaagaaagtagtg +gactattacaccaagcacgaatgccagggaactgctttcttgctcaggacctcgcgacaa +ggtaccccgcataagtcctagaattacatttggtcagcaatgctgacatttgaccgtgaa +aacataattttaatcagaaggcagctcacccgcttgctctagatcttatctttgtatgaa +tgtcagaatttactgcaatatccgttccgaatagtgagggcttagtatagttctctgtat +acaggtcacatcaaactccccctgtcctagtacagctctgagctttaattaattgcatac +atttccttcaatcatcagatgaaaacaccgcgaatcatgctcttctcgtatagggcaaga +gaagcaacaaacaactagcccgactcacgttcatccgccgtatccttgttcagttcttac +tccgtattaggtcagcgaaatctaatcagaataatcggtcgcgtatcaaaattaaaatcc +cgcttgaggttgacaattaaaacgctgagcagttatcggctattagatagtggggtgaaa +gtaattggctggaattatgttaaaacgtgatattaagctaaaatacgctacttgttgccg +acctaattcagtcattcgatattcagttagagccaagaataacaagcttgtataaattga +acggggtgcactaaacgatgtgttactctaatattcagcttggagtatacctgaaggcga +attcatgtatcggccaataataagacgttgaagatcacaatttggactagcaaaagaagg +tgatttatgcgtggggattgagtccactgtacgagtacggtctctggaaaattataggtt +cagggaatataaggaagtaaagataattaccaagagatttttggtatcgctatgacccag +aggtgttctaacgtctgttttgatccgcagaatttctgcctcaatgcatatttgacggac +ttgaactagagcctctaaagttaaatggcgacgcaactgttcctaaacttcaattattac +tactctttttttcctagggtattgtagaggccagtggacaaaataaatcaaatttaagat +gtttcggacattaacatcccccgtagcatagaaatcatcagttatccaatctctcatcga +gcttttacaatttctgctggcgctatggacagcatatgccgcgagacctccgcaagactc +acttgatcactgtaagtatcttcattagaggttagagcctatagttaagctgctgaccta +gtaaaattggtattttctaattttattgctcaagttaaaggttagtgaagggataatgac +gttatttttgaacaatgggttgtattcaattttatatcacgaatggaacccttcattccc +ggcataatactagacgacacgaacaagctccgatctatcagccaggcacgtgttaaggtt +taattccggcaaaccaatgaagcatcaaaaggtgacctgatgcaacttagggtcacgatg +agtttttcaggactacttattacctattaataagttaacatgagccttcataccccgtaa +gacaatacatactccaccaattagaattctgagccatcttatctttttgtatcatcgaag +ggtatggccgaataggttaattagttactcctaacgtctctacaggcatgcatttgacgc +accttcgaaaatagtcaatctctcgccacacgcgtctagtatgcagcatcaaaaatatag +tccacggtttccggattaccaaacgcggcaaagagaaacattgtatcgacggagataact +taatacagaaggaaggggcatcttcgaatacggatgaataattctatctgtttattctga +catcttgttttcaggttaatcttacgcattcaaatgacgcctgccccatgcgtgcgcaat +tattttctaatattgacgagagcaatctcactccttttgggtctatttatgttttattga +ggcacaagcctatacagaacaggtactattaaggccgtgagtgtgagactcaaaccgtgg +aaacaaaggatgggttgttcttggtacaagttttagtgcatgtgggcaatccttaccaaa +atcagatgctatccttaactttgggctgcatttaagatggcggttggaggcctgtgagaa +tcctgcgtgtcatctttaatgaccgaattcatccatgtagattcagatcacacactcatt +ccttgatgttgtctaaacaaaagttgttgtggacgcattggagggagttaagtaacaact +tgggatcgcatacttataaaaattatatgttaaactttcacaaacgctgaagtccaaagt +aactagcccaaacgcctcgagagtcactaggtattaatggtgtttgagttcctgtgaaat +agtgttcgaaggtaaaatttatgtaccaaatcgaaagaacacttaataaggcttgcttgc +acggaggtatgatgtttactgactctacaaccctaattttccagtacgtacattcattcc +aataggttagttctcaaagtgctatacaggctcctcaattgatgatatgcttcagccgct +ctatggatattagctcattttatttaggaagcccgcttagaggcttactatgagggaaat +gccaaaatgtcatacttttcggtgtgtcccatatgacaccgctttacatagaatttgaat +taaaacgcgctctcccgttcactaccatacttggtaccgtgcgcatattacatatagata +taggatcattttttaaagctgtactaggtttgatcgacaatcttatgctatactatatga +tgtaaccctcataatcaataccgatcgtacgatcctagcataggtggcaagcgattttat +gccgattattgtgttaaatagtctgtgagtgtgattatcagggctacgttggtagagggg +ttgtatagacctcgcacacattgtgacatacttaacaatatacgaaaactgatataataa +atccccttacccaaacaccaatcccgttgaatcaactaccataacgtctcccatataaat +tgcctacttgtttgcataaatctgaatacataacaccattgcaccttcttgtgttccaat +cccgttaagattgccttgtcagatgatatgcaagaacaatagcatttgctagcaattatt +aacagctcttcgaattgcctccacataacgcgggagggtatattttaatttggcaaatac +taagtactgttggcgtcatatgctattaacggttggatattaagttatgtcagccgtaag +caagagtgggcgaaatattttgttacccagtgagagcactcttagagtttggatacaata +ggccatatgttgacttaagaggacgtaactacgccgtacaccattgttcaaccgacttct +tggcaaatagaatcgtattagcaatcttaagaatagagacacgttcgtgttagggtatac +tacaaatccgaaaatcttaagaggatcacctaaactgaaatttatacatatttcaacgtg +gatagatttaacataattcagccacctccaacctgggagtaattttcagtagatttacta +gatgattagtggcccaacgcacttgactatataagatctggggatcctaacctgacctat +gagacaaaattggaaacgttaacagcccttatgtgtacaaagaaaagtaagttgttgctg +ttcaacagatgatagtcatgacgcgtaacttcactatagtaaattgaaacaaatacgcaa +tttagacagaatggtacggtcatgaatgacagtaattcgaagtgctagaccaacttaaaa +taggtaaacgtgcccgaaaccccccttaacagaaagctgctatcatggtgcagtatcgac +gtgttcagaaacttgtaacttttgagcaggtccgagcacatggaagtatatcacgtgttt +ctgaaccggcttatccctaagatatatccgtcgcaaactttcgatttagtcccacgtaga +gcccaagcgttgtgcgactccacgtgcatgcccagaaatacgagtttaaatttggttaca +tggttaattttgaccgaagcatcgcactttatgattgataattggattcaatatgtcgcc +ctatgcgaatgcaacatgatccacaatttggctataagacgtttaatccgtatcacactt +tgtttgcggctagtatagtaacgcccgtgcaccaagagtcagtaacaattataagtactc +cgcaggtacttcaaatataaaaactaatcaaacacgacccatatgatcatctgaagatat +ttggaactttctcgacaaccaccctcgtactcaatacttacactaatcgacaggcacacg +caacgtgtacagtcgcaccatattgagtcaagatttgcttagtggcgatgagcgtacacg +cttatttctctagtcacaattagttatctacgagacatcacgagggagcaaataagcgat +gttatggctacacataggcacgtatgaatatgatataagccagttaaacagtcgaaccat +cgagcaaattctcatgcaccaacccacacgttgaggcacaaagagtaagctgtttgaatg +taacttcttctgctgagcgggccccaacgtaaggatcaactagaagagaaaactcggtat +tagtttaaatgcgtcacggagcatgagtgcatttcactaagaatgtctgtgtaaccaata +taacatctatttgttatctgattgcctacttatggctttgcggtcgtggcgactaatgtc +tccaatccttttgaggtcggtaccaactccctttaaattacgctgtgcaggctcatgcac +tgcatacatatacggtagcaggtagggacctcacgcacccttattataatcaatagtagt +tatcagtcaacgaggcaggaatgctgaggtcgaggtgttggtatattttctatgtgccgt +ctaggcgactatcacgcattaccaggcgagatttaagccaattttgaatatagtcaacgt +aatttttactatgggttccaccgaaacgccttgcacaactaagaatcccataaaatatcg +atatcaaataaaagattgtgtcaataccttcatatatattttttcggttgactaacgtga +actaaggttaggggttttgtatgtctatataggaaacagtttcttttctgtcctacttta +gtaaagtcttcaagccttactccaaaatcacggtgattaagccgttactcagcagcatga +ttctgcctgctcgggtcctaaaatccagccttgtaagagtcgctgtgtattagctaggga +gacctttgttaaaaaggatatatcgcggcgggatgtgagtgcgtggcgcatactcaatct +tcagctcgtgtcattataatatctctcccccacgcttttcactagatatgccgtgtaagc +aaacaccttatgcttaatttcgaaaatattggtacttgaaaaaagctgtaggggtactta +atgtctggtaggagatcaggagagaattgagtgtaaaaccgtaaagccctcacctgactt +catgtaaatggcttagaagactccatgatttaataaatactacgaaggaaagactggatc +taaagataactctagtaaggccaactcccttcaatgctgttgccagttataatccaagag +ctgtccttttctgaaccatagcggcttctgaagcgaactagaagcaaagttggttctagc +cagacagccacataccctgtacgggtgtattactaaaactggtccggtattagttcacca +agggaggaattaggcaaaggatctaggtatgcaagtcggagtattacatccctaccctga +atccatcaataggttcctctgtactggccttcgcaatgagtattcaaggttgtacagccg +tataataataagatagtgactatgaacgggaagtaacccgctcaccttccccaaaacatt +gttatatctaagtattaaagtctgccgtagtgttaatactcgaaaataaacaactggcaa +attacaccgcacttaagccgcttttgatttatatttttccaatgcgcttttaaaaataat +tcagtcctacatactaattaagacccttaaacggagatatcacaagttaagttttaacca +tctcgactaggtggaactatagatacccaactcaatttatcattacctgtaatgttccta +gaaggattgcatttcatgtcaagacggtggagtttcacagcgaaacttcagtgtgaacag +attctgagaaatcacctaaacctattagtcagagcacccggttagaaccagttgtcaaaa +aatagagcggttgcatgagacagaagtaacgatgagatccgttgtaacgttgagacatct +ggcctatcgtcaatacagtcctcccttaaaaatatttttaaatactaggcaaacccaaca +taggttagtcctatgtgatacgccacatggtatatcattttgtaacgttacctagggata +atcaggaagtggaattacgcaaaagtagacagtgaaatgcttagggttatagtctagtcc +aaagataaaggataaagcacgtcagagaactatattagccgaatgggaatcattgttagg +agactgtggatcatgtctaaaaagcaacgcagaaacagtcatcgaaaaaatctcgttttt +gtttgaatctaaaagagctttgatgaccgatagtacctgtatactagttactgtattacg +tgtctaatgatttcggattggggtccccagaatcagacgtcattgtagacgattcaagtt +taccaatttaatttcccagctctccttggagaactatcgccaataattgcagtcactttc +cttttctgaaacgataaagccgtcagagttctctgcaacgttggacttacctgaggttct +aacccactttcggttctaatagtagttaacgacacaacgaataacctttactgtggggct +ttcacgatattttttcgcttattattaatggttacgtcataagctggtgtccaaattaag +gttaccggcttcgcagagtagttgtatccaagtataacttccctaatcataagatcgagg +tagaaaattaatgctgtctctaaccgaacagatatgtcccactatgtggtatggacgttg +ctaattacttctgaagggaaattggtcattatggatacgtgtctaccatcaggtcggacg +cagatatggttctgtcttcagttgatccaccgttctttataggataataactgacgatta +aagattatggtaaatagattaagccaattctcttcttgtcagtgaagcatccttaactga +cttgctctgcagcccctcatacatttagctattcaaagtaccggctcgtttcaaactctc +ccacctttggaagaggttgtcaacttgataagtatatcatttacagcattttttcggacg +tacctctaatgtttcattgcagaaaattagttttttctatcgcacattttgcaagtaacg +ttagagacacaattatctgcgaatgaactgctagatctgacgaccgggagcctcgcaaat +atcaaaaaagactgacatatatcaaggagtcgttgacaagtgctggtaagtcaattggtt +tatctgtcccggcgtttcgatcttaagctgaccatgcacggcagagtaatgtcactctcg +ttcttacaagtctgtctccaagggtcggcaaaaaagacccctccattctcgagcccactc +acgatatgtagggacgacaacttgtgcggcttatgaattgtctggactgcgggcgagggt +ccatatctccgaagttagaagggacatacctttagatgataagatcaattcttattgacg +aaattcatccacaacggggaacaacttcaccctagacttacgtctgaaaagacacctagc +gtcttataaaaggtcagtgccccgtttcgtaaggctggaattacctacgcaaacttaaac +ctcgcgcccttccttacgtatcgacaagatagaggctatcgcgaatgtactacggaggca +tgaatcatatactagaaccaagtgcctgtgatattaacaagatgatccgacgcgagcacc +gtaattctaggcataaaactccagcaatttgggggccgaaaacaaatgacgttagctaat +taattatatgacatgatcaaaggaggtcaatcacgcatcgagttcgacgtatattcattg +aacttcgtgcgtttgaaagaaacttttatgaaggcaaaattgatcctgtctcctatttca +tgcgtacctcctagttgataattccccgagcagtggttaggacacttttgtcggtatcaa +gttccggtctcaaaacgtaaaattctgtaatctgtatggatggtctgtgaattagttaat +ttttatgaagtcgtcgagacgcagttcctattgatttattctaaacggagatgtgcttcg +tgggactcggaagtagatctgtgtttatgattattgctactttagatgctgactgttaac +tccgtgttgtttttcaaccgtatatcacaaccgaattggatagaacctatagtttcaagt +tctgccacaaggtatcatatttacagttagtgctggttgcttctttcaaacgtggtgagt +ttgtgctatcacgtcaacggtagagctcagtggaccgagtgcgcgttcaaccctgttcca +gagagggtgtgatagcacatataccacgctcgtcgaggcgttcatgatagtttgcaagag +ccggtgttaaacacatattattattgttatccaactaatcggacctatgcataaagcatt +gtctaaacagaataattgcctatatacggtagttttagtgatttatatcttagtatcagt +tagagcttcgaactcttcaggttcctcatatttaacgttcttcgaaagcgaaaacttcta +caaacgaatgtaagcggttttccaagtagtacctataaatcacagaaagatctgtctcag +tatagttgaaatggtattcagctagtgacgtgtaccaattatcatagttcactcaagcaa +gacgctcattaacgaatatagacaagacactatatcatataataaaaaagaacatggtgc +tcgaacatagttgaattcaccatattgaaggggaatgctgacatgtaattcgctactaga +cgatcaattccctacttgtcaaagttgaactggtacgttcttggaattaaatatgattgc +gctggaccaaattgcgacttcttgagtttcagggcaaacgattgagccggaggatgtccg +tctcttacctttcttgcttatgataaacgacggtccctgtacatcactgggaattctcag +caaaaataattgggtaaatcgagactcgatgtattcggccacaaaggtgttagacgttaa +agattattcaacggggcgataataggatcataaccggtatgcaagcgcattgaaagagcc +atgagatccttatccgataaacgctgcacggtatgtgcagccttattgtcgatcacgaat +ttataaatgtagtctgggctgtaagttgaagacctaagttataatgaagtgcaataccaa +atcgattcatagtggattatcagactcaagatatctcctgataaattacagttgttaaga +tacggataaaatgagatttaagattagcagcctctaatctgtttcaatcccgttggaatg +tggtatgcgatcaaggttaagttaaaatcaagcctgtcttcagtcttgattcttgttctg +ccatcgcatgcggtctacgtgagttaatatgtagcttacgttctagcttgtgctaatctg +agtatagattcgtagaggaatattatcaagcttccacgcctcaacgtacgtgtattggtc +acacaagacactaaaagtggaagtagcgtaaactatagtctagttgttaaatgctcagtt +cttgttatattcgatatactcttggctaatttatgtctgagtatataaaattaatgatat +taacttgcatttcacggatcccttagaaaaagattttgaccgagcgcattataaacggtt +acaccgaatcaatagaagcatacccaatagctttctttgaatttattgcctgcgcaactt +ggctgactctctagatccgaataattctatatggtcgtgacgaaactagttcattactgt +ttaaaatgccaacatgtcttttgggccgataatggctctttgcaaaattactcaatgata +cgattgatcaaagcggtagttgctagtggtagcatgtaagtctatcaaatgtctgattat +ccgaaaatcttccaaaagagtccacgtaccatatctatctcatagcgacgcgaggggaac +cttatctaactatcattccatttaccgggtgactctcgatgcaggatccgattgggataa +attgcccagaaatggctcattcctgactaagggtaaggccgttctcagcaagggaacccc +gcgaatctaggcttataccatctagattgttaactacttgcctgtagttctacagccata +ctggacagttgtttctaaatgatcgggattcatgctagcactcctctgaatgcaccgcgt +aagtttaactattacgtccgtgggcagataaggatggaggctgtatgtatcttaactgtt +acctaatatggctggtaattatcaaagtaaggaccttaatgccatagcgctagcaatcgc +tttgtatactgaccatgtgccaacctctcttaatctgtaaaatataatgtcttagctaac +tgtggacgatcatgtctctgcctagagcttcgctgtatcaattcctatagccagcgtact +agtgacacaacaacaccgtgtgagaaaagatattagtccttacgtctgtctctctacagc +ttattgatgaggattgaacatggacatatagctccccctcaaaagcagatgctacctctt +tattccattctcgaacatttgccgaacttaatttcgacaaacctgaggtcacgtcttaat +ttatcggtaacgtcacgtccctttgagactggataaatatattaccaggggccaacgagc +aattgttggaggcgcttctataatacaaggtgtcttgtcaaagaaagacggcgtgcgtct +cgtgcaactcacttaaccaatattaatgtgaaacccccctctctcacatcttatgcggtg +tactgccctggtacatttcctgtacaggactccaacagtgtagattcctaagatagctgt +tggagttgcctcacgccagatcgaaaaactgaataaactagtgagctgagctgcagaaat +accgcttaattacttatgactagttcaaagggacctacgtgatgtcagacattgcaagga +agaaattaggtttgtgcgtcattttggctggactagcactccttacttcccctactattc +aaatgtcgtaaacagcatgagacaggatcgtgctgacatttaaggtctattgggaacgag +gctacctttggtcgcgcgctcgcgttctccgaatgaccgaaatgcatgagcacagtatgc +aattgcttatagatctaaggtctggtcgttgaaaccaagcacgtaggcctgggaaatcag +ttcttcctcagcaactacacaaaagcgtccaagcattagtacttgtagtaaatgtccgaa +cctatgcgctcatttgaaagtcaaaaaatatttttaagcagtaggcacctaacccgattc +ctctacttagtagctttctttgattctcagaattgactgcaatatcactgcacaattctg +tgccattactagacttctctgtattaacgtctcatcttactaacactcgcctaggacaca +tctgagagtgaagtatttcaatacatttactgaaatcttcagttctaaaatccccgaata +aggctcttatcggtttggccaacacaagaaaaaaacttcttgcaccactcaccttcatac +gcaggagcctggggaacttagtaataactatttcggcagacaaagcttataacaagttgc +cggcgcgtataatatttaaaagaccccttgagctgctcaattaaaacgctcacctggtat +aggctattagatagtgccgtcttagtaaggggcgggaattatcggataaactgatatttt +gataaaataaccgacttgttcacgacataagtcactaaggagattttatctttctccaaa +gtatatcttccttggataatttcaaagcgctgcaatttaagttctgttactagtttatgc +tgctgggaggtgaccggaaggcgtagtaatctagaggcaaattataagaagttcatcata +tcattttcgactacaaaaacaaggtgttgtatgccggcgcattgtgtaaactggacgagt +accctagatggaaaattatacgttaagccaagatttcgatgtaatgataattacctacac +atttttgctatccataggaacaagagctgttctataggctcgtggcatacgaacatttgc +tgccgctatgaatattggaagctcttcaactacagactctattcttaattgccgtcgaaa +atgggccgaatcggctattattaatactcggtttttccgaggggattgttgtcgacagtc +gtaattattattaatattgatgttggtgaggtcatttaaatacaaccttgcagacaatga +ataagggatccaatctctcatactccttttacaattgctcatgcccctatgcaaacctta +tgccgccacacctccgcaactctctcttctgaactgtaagtagcttcattactggtttga +gactatactgaagctgatgacattctaaaatggctattttcgaatgtgattcataatgtt +tatcgtttgggatggcagaatcacgttatttttgatatagcccgggtattctattgtata +gaacgtatgctacaagtcattccccgaagaagactagaagtaaacaacatgcgaccatcg +ttaagccacgcaaggctgtagctttatttcccgataacctatcttccataaatagcggac +agcaggatactgacgctcaacatcagtggttatggtctaatttttaacttttaataaggt +aacttcagcaggcatacacagtaactctttaatttataatcaaattagaagtctgacact +tcttatatttttctatcatccaacgcgatcgcccattagcttattgtgttactaataacg +tatctaaaccaatccttttcaagctactgcctatattgtcaatatatacaaacaacagga +tagtaggctgcttaaaaaatattgtcaaccgtgtacgctttacaatacccggaaatcaca +aactttgtagacaacgagtgaaatttatacactacgaagggccagcgtacaagacccatg +aattaggcgatatgtttattctgacatattggtttatccttaatctgtcgctgtaaaatg +aagccgcccccatccctgcgaattttttttcgaagattcacgactgaaatataaatacgt +ttggctatatttatgttggagggaggcaatagcctttactgttaaccgaagatttagcca +gtgagtgtgacactaaaacactggaataaatgcaggcgttcttctgggtaaaaggtttag +tcaatctcgcctataagttcatatagctctggatataattatctggcccatgcatttatc +atggcgcttggtgccctgtgtgaagccggcctctcatattgaaggtccgaagtattccat +gtacattaagatcactctctcattcatgcatcttggcttaacaaatctggttgtccaagc +tttccaggcacgtatggtacaaattcggatcgaatacttataaaaatgatatgttaaact +gtctaaaacgctcatctacaaagtaaagtgcactaaccaatagagtctcaagaccgtgta +atgctggtgcactgaatgtgtaatacggttagaagggattagttatgttacaaatccatt +gaaaacttaagaagcattgcgtgctcggagggtgcatcttttatcaagagactaacatta +ttttcaacgacgtacatgctttacaatagggtacttatcaaacgccgagaaacgcgccta +tagtgatgttatgattatgacccgatatccattggaccgaattttatgtaggttcccagc +gtactcgcgtaatatctcggtattgccataatgtaatacttgtcggtctctcccagatga +aaaagcgttacagagtatttcaatgaaaaacagcgcgcaacgtcaatacctttaggggta +acggccgctgatttcatatagatatacgataagttggtatagctctactaggtggcatcc +acaatcgttgcatttactatagctggttacaatcataatctataccgttccttacatact +accatagcgggatagcgtttttttgccgttgattgggtttaagaggatgtcagtctcatt +atatccgattcggtgggagagccgttgttttcaaatcgcacactttgtgacataatgtac +aagataacaaaactgatataagatataaactgtcaatatcaccttgacacttgaatcaaa +gtaaattaactcgcaaatataatttgactaattgggtgcagatttctcaattaataaaaa +aatggcaccggatgggcttacaagccccttatcattcacttgtatcatgatttccaagaa +caatagaatttgctagcaagtatgaacagagattcgaattgcatccacagtacgccggag +cgtttattttaatgtggatatgacgatgtactgttggcggcatttgctagtaaccggtcc +ttatttacgtagcgcacacgtaagcatgtctgggagaaatatggtggtacaatctcagag +aaagattacagtttggtttaaataggacttatcgggtcggaagtggaacttaataagcag +tacacaattgggcaacagacgtcttgcctattacaataggattacaatgcgttagatttc +agacacgttcgtgtttggctattcgtcaattccctaaatagttagacgatcaactattat +caaagtgattctttgttcatcctccattcatgtaacagatggcacactacgcataacgcc +gaggaattttaacgagatttaagagagcagttcgggcacaacccacttgactttataaca +gctcggcagcataaacggtaatatgtgacaaatttccaaacgttataagaacgtatgtgt +acttagaaaactaagtggttcatgttcaacagatgtgacgcagcaagcctaacttatcta +ttggttttgctataaaagaacaaagttacacagaatcctaagggcttgtttcacacttat +gcctagtgcttcaccatcttaaaatagcgaaaccggcacgaatcaaaccttaaaacaatg +cgcagatattggtgatggtgactccgggtatgataatggtaactgttgaccagcgcccac +ctcatcgaagtatagaaagtggttaggataaggatgagaccgaacttatttccggccata +actttagattttctacctagtacacaacatcagggcggacacgaaaccgccatcacatca +tataccaggtttaatttgcttaatgggggaagtgtcaacgaaccttcgaactttagcagg +catatggccattatatatggccccagagcagaatgctacagcagacaaaatttggattta +tgtagtttaatacctatcaaacttggtgtgaccatacttgtctaacgacagtgcacaaag +tgtaagttacaattattactactcagcagcttctgcaatgataaaatcttatcatacacg +tcacatatgataatatctacttagggggaacgggctccacaacctacatagtactcaata +cttacactattcgacaggcacaccaaacctgtacagtcccaaaagattgagtcaactttg +cagtactgcagatcacagtaatagcttagttagcgagtcaaaattagttttctacgagac +tgcacgaccgtgcaaatttccgatgtgttggctacaaatagcaacgtatgaatttgtttg +aagccacgtaaactgtacaaccttagagataagtctcaggctactaaaaacacgttgtgg +cactaacaggatcatggttgattcttacttattcggctgaccggcccaataagtaacctt +caactagaacagaataatcgggagtagtttaattcagtcaaggtgcaggtctcattgtaa +ctaacaagctctgtgtaaccaagttaaaatcgttttcttagcggattccctacttatgga +tttgagctcgtccacaatattcgatacaagaagtttgtggtccgtaacaacgaaatttta +attacgctgtgcagcctcatccaaggaattaatagaaggttgatggtaggctccgaacgc +tccatgattataatcaagtggactgtgcagtaaacgaggaaggtatcctgacgtcgtggt +gttcgtttttgttatttgtgccctatacgagtagataaaccatgaacagcacagtgtgaa +cccatggttgattttaggctaccttatttttaatttccgttacacagaaacgaattccac +aactaacatgccattaatttttcgatatcttataaaagatggtcgaaattcattcattta +ttttttttcggttctcgaaagtcaactaagctgtcgcgttttgtttctctttagaggtaa +aagtggctttgatctcctacgtttggatactagtcaaccattactccatttgatccgtga +gtatcacctgtctaacatccagcattatgactcctcggcgaagaaaagacacacttctta +gagtcgatgtgtattagctagggacacagttgtttaatacgatagtgagcccagggaggg +cagtgcgtcccccagtagatttattcagctagtgtaagtataagatatctcacccacgag +gttcaagtgatatgcagtcttagaataatacttatcctgaatttcgatattatgggtact +tcaataatccgctagcgctactttatgtctcgttggacagcaggacacatggcagtctta +aacactaaagacatcacctgaatgaatgtaatgggattacaagaatcaatgaggtattat +atacgacgtaggaaactctggatatatacagtaatctagttacgccatcgcacttcattc +ctctggaaacttagaagacatcagctgtacgtggaggaaccagacccccgtatgtagcca +aatagaaccaaagttgcttatacaaacacacccaatgacaatggaccgctggagttcgta +aactcggaacgtagtactgcacaaacccagcatttagcaataggagctacgtatgcaact +cccacgtggtaataccttcaagctatcaatatataggtgcctagctaatcgcattcgcaa +gcagtattcaagcttgtaaaccagtataataattacagaggctctatgaaacccaacttt +ccagctaaaagtcccaattaaatggttatttcgtacttttaaagtcgcccgttctgttat +tacgcgaattgattctactccaaaattaaacacaaattatcaaccgtttcatttatattt +gtcaatgcagctgtttaaaataaggctctactaaattataattaagacacttattaccag +atttctctagttaagtttgaaccagctcgactaccgcgaaagatacattcccttctctat +ttttcagttcatctatgggtcagagaagcattgaatttattctattcaccctcgtcgttc +acagcgaatcgtcagtgtgatcagtgtatgagaaatatcctaaaccgtttagtcagacca +cacgcttagaacaagtggtctaaaaagactgccctggaaggagtaagaagtatacagctg +atccggtgtatccttcagtcatctgccctatactaattacacgacgcaaggaaaaatagg +tttattttctaggcaaacccttcataggtgactccgatgtgttacgaatcatgcttgaga +atgtgctatcgttaccgacggataataacgatctccaatgaaccaaatgtagaatgtcta +ttgattacccttttactattcgacttagagataggagatagaacctcagtgtactttttt +agccgaatgggaatctttgggaggtgaatggccataaggtcgtaaatccaaccctcttaa +agtcttccatattatatcgttgttcgtggaatcgataacagatttgttgacccatagtaa +atgtatactagtttatgttgtaagtgtagattgttttccgattgccgtccaaactttatg +tcgtaattgtagaccagtaaagttgaccaaggtaagtgcccagcgatcctgcgagatcga +tcgccaatttttccagtcactgtaagtgtaggtttagataaagccgtatgagttatatca +taagggcctcggaaagcagcttcgaaccaaagttcccttataatagtagtttaactataa +aagtatatactggtctgtcgccctttcacgatttgttttaccggtttatgaagcgttacg +tcattagagcggctccaatttaaggttaacggcttccatgtgtagttgtatacaaggata +acttaaagtatctgttcagcgagctagttaagttatcctcgatagaacacaactcagagg +tcccaagatcgggtttgcaacttgctaatttattctcaaggcaaattgggaattatcgat +acctgtataccataaggtcgctcgatgtgatgcttatgtcttctggtgatcctaccttag +ttagtgctgattaacggaacattaatgtttatcgttttgagatttagccaattctctgat +tctaactcaagatgccttatctgacgtgctatgcagcccctaagtattttacattgtaat +aggacacgctcctttaaaactcgccaaaaggtcgttgtggttctctactggttaactata +taatttacagctttgttgagctagttcctctttggtttaagtcctcaatattagttggtt +cgagcgataagttggctagttaccttagtcactatattagatccgaatgttatgcttcat +ctgaagaccgccaccctccaaaatttcttttaagactcacttattgcaaggtgtaggtga +attcggctcgtttctcaagtggtgtatctgtacacgagtttccatattttcatcaacagc +caccgcacacttatgtcactctaggtattaaaagtcgctctacaaggggacgcaattaag +aaacagacatgctagtcaaaaataaacatagcgaggcaccactaattcggccgcttatca +atgggatgctctgcgcgagacgcgccagagctcagtagttagttcggacatacatttact +tcagatgatcaattagttttctacaaatgcttactctaccccgaaaaaagtcaccagact +cttacgtctctttagtatccttccgtcttatataaggtcagtcccccgtttcggtaccct +ggaatttactaagaataatgaaacagcccccaaggacgtacgtttacaaatgatagacca +gatcgcctagcttattccgacgcatgttgcatagaattgaaccaacggaatgtgagagta +actagatgagccgaccacagcacccgtttgcgtcgcagaatacgcctgatagttcggcca +cgaaatcatatgtcctttgagtattaagtatttgtaatgatcaatcgagctcaagcaagc +ttacacttcctcggatattcagggaacttagtgcctttgaaagatacgttgatcaacgaa +aaattgataatggctcatatggaatgcctacctcatagtgctgaattaacacagcactgc +ggacctaacttttcgaggtttcaagttcacgtctcaaaacctaataggctggaatatgta +gggatcctcggtgaatttgtgattgggtttgttgtagtactgaccaagtgaatattcttt +ttttctaaaagcagatctgctgccgggcactacgaaggagatctctgtgtatcattattg +cttcttgacatgatgactcttaaatcactgtgggtgtgcaaaacgatagcacaacccaat +tcgatagtacatattgttgatacttcgcactaaaccgttcatatttaaaggttgtgctcc +ttccttcgttaaatactggtgacttggtcctatctactattagctagacctctggggaac +cacgcccccgtaaaacctgtgcaagagagggggtcatacatcttagacatcgcgcctcca +ccagggaagcattgggtgattgaccaggtgtgtaacaaatatgattattcttatactaat +attagcaaagatgcataatgatttgtattaaatgtataattgaattgataagggtctttt +agtcagtgatagagtagtataaggtagacattagaactcttaaccggacgcagatttttc +ggtcttagtaagccaattagtcgacaaaacaaggtaagagcggttactagtagtacctat +aatgcactgaatcttcggtcgaagtatagttctaatgctatgcagattgtgacggcgaca +aatgttcagacttatatcatgaaacaagctcttgtaagtattgacaaatgaaaagattga +atatttttaaatacaaaatgcgcctacttattaggggaattaaccagattgaaggccaat +cctcacatgtaatgagataatagacgataaatgaaattcttgtaatagttgaactgctac +gtgatgggtattatatatgattgagatcctccaattgccgacgtcttgtcttgatgccca +aaagattgtcaacgaggagctccctcgcgtacctgtcgtccgtatcataaacgacgcgac +atgtacagcactccgaagtataagcaataataatgcgggtaatccagactagatcttttc +ggactcaatgcggtttcacggtaaacatgattaataccggagagtagtcgagcttatcag +cgatgcaagcgaattcattgtgccaggagatacgttgcagataaaaccggcaacgtatgt +caacaagttttggcgatctcgttgtttgtattcgacgaggcgcgggaacttcaagaacta +tcgtatattcaagtccattaccttttagtttcagactggtggagctgactaaagttatat +catcattttgtacactggtttagttaacgataatttcagatttaacatgaccagacgata +atcgctgtatatccagttggaatgtggtttgccagaaaggttaacttataatcaagcctc +tcttcagtcttgattcgtcgtatcccatccattgcgctatacctcagtgtatttggagct +gtagttataccgtgtgctaagatcagtagacatgacgagagcaatattatctaccttaca +agcatcaacggacgtctagtcggaacaaaagactctaaaactcgaacttcaggttaatat +actatagttctgtattcagcagttattcttatattcgatattatcttgcctattggatgt +ctgactttagtatattaatcatagtatctgccatgtaaaggtgccagtactaaatctgtt +tcacagtgcgaattataaacggttacaaccattaaagacaacaagaccctatagctttat +ttgaattttgtcaatgcgcaacttggagctcgcgatacatcccaattagtctatagggtc +gggacgattctacggcatttctggttataatgacaacatggattgtggcccgagaatcgc +tctttcattaattaagcaatcattacagtcttataagcgctacttccgagtggtagcagg +taactcgatataaggtcgcatgagccgaatagcttaaaaaacaggccaccgaacattgat +agagaataccgaccacagcgcaacctttgattactttcattaaattgtacggctcactcg +acatcaagcttaagattgcgataatgtgaactcaaatggatcagtactgaagaaccgtaa +cccacttcgcagaaagcgtacccagagaagatacgctgttacaatatacagggtgaaatt +attgcctgttcttcgtaaccatttcgccaaacttggttagaaatgatagccattcatgat +agaaataagctgaatgataccagtatctttaactatgtagtcagggggaagataacgatg +gtccatgtatgtttctgatatgtgacagtattggccgcgtaatttgctaacgaagctact +taatgcctttgagcttcatatagatttctttaatcaaaatcggcaaaaagatagtatgag +ctataatatatgctagtagagaactctggaccatcatctatatgaatactgattcgagcg +tgcaattactttagcctgcgtactactgactctacaaaacactctgagataagtttgtag +tcagtaagtcgctctctataaaccttttggatgaccattgtacagccacttatagatccc +aataaatagcacaggagacagagtttttcaatgctcgatcatttgccgatagtattttcg +tctaacctcagggcacctattatttgatacctaacctaacggccctttcacaatggagaa +atatatgacatcgggacaaacacaaatggtgggtggccaggagatatgacatggtggcgt +ctctaagaaacacggactccctctaggcaaactcacgtaaccaattttaatgtcaaacaa +aacgctcgaaaagattttgccgtgtaatgacctggtacattgactggtcaggaatacatc +actgtagttgccgtagtgtcctgttggtgttccatcaagacacatcgtataacgcaattt +acgacggacatcagatcaagttatacagattatttaagtatcacgtgtgcattgggacat +aagggatctcacacatgccttggaacatttttgctttgtgccgctttttcgctgcactac +caatccttacttaccagtatattcaaaggtcgttaacagaatgagaaaggttagggctct +aagttatcgtcgattgggatagacgagacatttgcgagcgccctccacggatacgaatct +cccatatcaatgtgaactggatgctatgcagtttagttcttacgtctcctagtggtaaaa +atcaaagtagcactcgcatagcagttattcagaacctaatacacaaaaccgtcaaacatt +ttctaattctaggtatgggccgatcataggagctaaggtgaaactcataaatgttttgtt +agatctagcatcctaaaaagatgcatatactgagtagctggcgtgcattctctcaattgt +atcctttttaactgaactagtcggtcccatttcgtgactgagatctattaaccgataaga +ttaataacactcgcattcgtatcagctcagagtgaagtttttcaataatttgactgatat +attaacttctaaaataaccctttaagcctcggatccgtttcccaatcacatcaaaaattc +ttattccaactatctacggattaacaacgtgcatggggatcgtagtaagaacttgttccg +atcactttgagtatatcaagttgacggcccggttattattgaatagaaacattcacctgc +taaattaaataccgcacatcggatacccgatttcagagggccgtcttactaagggcaggc +tttgttcggtttaactgagatgttcattattttacagtatgcttcaactaatatgtaacg +aaggacagtggatctgtctccatagtagatcttcagtcgtgaatttcataccgctcctat +ttaagttcgcgttcgagttgttgatcatggcacgtgaaagcaacccctagtattctagac +gaaaattttttctagttcatctgataatttgccaattcaaaaacaaccgctggtttcccg +gcgcattctctaaaatggaagtcgaacctagagccattatttgtcggtaacccatgagtt +ccttcttttcagaagttaatacactgtggtcctatacagaggaaaaacagcggttatata +cgatcgtggcataacaacattggatcaagatagcaatttggctacctattctaattctca +ctagattcggtattccactacaatatcggcagattaggattggatgaataatcggtgttt +aagtccggttgcgtctccaatctcctaatttttattaatattgatcttggtgacctattg +taaataaaaacttcaagactttgaataacggtgaaaagatagaagactcatttgaaaatg +gatcatccacagatccaaacattagcaagacactaatccccaactagctattctgatcgc +gatcgtgctgcagtactcctgtcacaatagtctgttcatgatctaattctttttgggctt +tgttcgatggtgattcagaatctttatccggtcgcttccctgtagctactttgtggggat +attgcccggggattatagggttgagatcgtttcctaaaagtatttaaaccaagtagactt +caactaaactacatcagaacatcgtgaagacaccatacgcggtacctttatttaccgata +acatttcttcaagaaataccggtaagcagcataatgaccctaaacagctcggggtatcgt +cgtagttttaaattttatttaggttactgctcaaggaataaaaactaactatttaattta +taataatattacaaggctcacactgattagatttgtctataagacttcgcgatcccccat +taccggattgtcttaagaataaactagataaaccatgcattttctagataaggcctttag +tctaattagatacaaaaaacacgatagttgcatccttaatttattgtgtcaaacctggaa +ccttttaattacccgcaaatcactttatgtcgagactacctctgaaatttattatctacc +taccgcatgaggacttgaaccatcttgtaggagttatgtttattagctaagattcgttta +tcctgtagcggtccatgtatattcaacaagcaaaaagcactcagaattgtttttagttga +gtcaagactgatatataaataagtttccctagttttttcgtggtgggacgatattgaatt +gaatcttaaccgaagagtttcccactctgtcgcacaataatacacgccaatatttccagc +cctgcttatgccttaatcggttactcaatctcccattgaagttcattttgatctgcatag +aagtttcgggcccagccttttttctgccaccttcctccaagctctgtagacgcactctaa +gattgatgctcacatgtattaattctacattaacataaatatataagtcatgcatcttcg +agtaaaatatctggttctccaacatgtcctggcacgtatcgttataatgcccatacatgt +agtattaaaatgattgggttaactggatattaagatcatcgaaattgtaaagtcaaatta +acaatactgtctcaagaccgtgtattcctcgtgctcggaagggctattacgcttacttcc +gttttggtatcttaatatgactttcaaaaattaagttgcagtgagtcctacctgcgtgca +tcggttagcaagagtataaaagttgtttaaacgaactacttgctttacaataccggtcgt +atatatcgccgtgaatccagaagattgtcttctttggattatcaaccgagatcctgtgga +ccgatgttttgggaccttcacagaggactccaggtagagctcgcttttgcattaatctaa +gaattgtacctctctaaaagatctaaaacagtgaatgtgtatttcatggaaaaacacaga +gaaacgtaaattactttaggccgaaaggcacatgagttattatacatatacgagatggtg +gtatacatcgaattcggggcatacactatagttgcattgtatttagctgctttaaataat +atgatattaccttccttacataagacattaccggcataccctggttttcaacttgtgggg +ctttttgacgatcgcactctcatttgatccgagtagggcggtgacccctgcttttcaaat +acaaaaatttcgctatgaaggtaatagattacttttcgctgttatgatagaaacggtaaa +tttaaaattgaaacttctagaaaagtaaagtaacgagaaatgattttgtgaataatgcgg +tcatgattgcgcaagtaagaaaaaaaggcaaaaggatgcgcggaatagaaacttatcagt +cacgggtatcttgatttcattcttcttgtcaattgccgacataggatgaaatcagattcc +aatgcaatacacagtaacccccacccttgattgtaatgtcgatttgaagttgtacgcgtc +gacgaagtggatagtatacgggccttttgtacggtgcgatcaactatgaatctcggcgag +ttagatggtcgtacaatctcacacatagaggtcacttgcctgtaatgacgaattttcggc +taggtactcgaactttattagaagtaaaaatgtgggcaaaagaaggattccattttacaa +gacgattacaatgagttacatgtctctcaacgtagtctttccctagtagtctttgaacta +tttaggtactccagaaaattttagcaaagggtttctgtgtgaatccgccattcatgttta +tgatggaacaataagaataacgccctcgtatgttatcgacagtgaagtcagcagttcggc +caaaaacatattcaatttagtacagatccccagaagttaagctaagtgctctaaaatggc +ctaaacggttatcaaagtaggtctaattactatactaacgggtgcatcgtaataactgct +gtcgatgcaacactatatgatagtgtcgttttgctatatatgtacaatgtgacaaagaag +ccttagcgattcttgcaaacttaggacttcggattctcaatcttaaatgtccgaaaacgc +aaagattcaaaaatttaatctatgagcagatatgcctgatggtgactacgcgtatgttaa +ggctaaatgttgacaaccgcacacataatcgaactattgatagtcgggagcataaccagg +tgaacgtactttgttcacgacatttattgacatgttctaaatacgtctcaaaatcacggc +gcactagaaaacgcaatcaaatcattgtcctggtttaagggccgtaatgccggtagtgtc +aaacttcatgagaactttagctggcttttggccagtatttagggaccaagagcactagcc +ttaagctgaatattttgccatttatctactgttataactttaaaacttggtggcaccaga +cttgtcgatacacacgcatcaatctgtaacgtaaaaggtttactaagaacaagcgtagga +attgagtttatattatatttaaactaaaagatgatattagcttctgagggcgatagggct +ccaaatcataaagaggaatatattattacacgattagaaacccacaacatacctcgaatc +gcccaaaagtttgacgaaacttggcagtactccacatctcagtaatacagttgggagagt +ctcaaatgttgttttattactcaatgaaccaccctcataatttcactgctgttccattaa +atttgcaaacgatcatttgctttgaagaaacgtaaaatcgacaaaattacagataagtag +atgcataataaaaaaaactgctcgctataacacgatcatcgtgcattcttacttaggagc +atcacccgcacaataacgtaccttaaactacaacactattagaccgagtactgtaattca +cgaaagctcaagctcgcattgtaaagaacttgctctctcgtaaaatgtgataatagtttg +cggagaggattcaattattttccattgcacctactccactagattcgataaaagaaggtg +gtcctcccttaaaaagaaatgttaagtaacatcggaaccataagcaaagcatgtaagtga +accgtcatccttccctaagaaacataaaggtttttaataatgtcgactgtgaactataac +tgcatcctttcctgacctactccggttccttgttgttatttctgaacgagaccagtagat +aaacaatgtaaaccacagtgggtaccaatggtgcatgtgacgctaccgttgttttaagtg +cccgtacaaacataagaagtcataatcttacttgaaattaattttgccttttattttttt +tcaggctcgaaattaatgatttgttttttttgaccttctagttacgctaatatgcggtcg +cctgtggtttctattgagtcctataacgggatgggatctaatacgtttggttactagtaa +acaaggtataaatttgataccggagtatcaactgtataacatcaagctttatgactcata +cgcgaagtaatgacacaaggctttcaggagatcgcgagtacagagccactaaggggtgta +ttacgatagtgacaccaccgagcgcactcactccccaagtagatttatgatcctacgcta +agtattagatatataaccaaagaggttctagtcagtgcaactcttagaataataattagc +cggttttgcctttttaggcctaatgcaatattcagctagcccttatgtatctcgcgttcc +acagcaccactcatggcacgcgtttaaactaatcaaatataatctatgaatgttatgcca +gtacttgaataaatcaggttttttataagtccttgcatactctcgttatatactgttaga +gtcttaccccatagaaattctttcatctgcaaacttagaagaattctcagctacggggag +cataaagtccccaggatgttgacaaatacaacaaatgtggcttatacaaacactccatat +gaaaatcgaaccctcgtggtagttttagccgaaccttgtacggataaatccctccatttt +ccaatagcagatacctatcctactacctcgtggtattaaattaaagcttgaaatatagag +ctgcatagcttatccaattcccaagcacgagtctaccgtcgtaaccacgatttgatttac +agacgctagagcaaacccatctttaaacatataagtaaaaattaaagggtgagtgcgtac +gtgtttactagcaacttcgcttattaagacaattgtttataagccataattaaaaacata +tgttcaacaggttcattgatatttgtaattgcacaggtttttaataaggatctacgtaag +tataatgaacaaactttttaccagagttatattctgtactttgaaaatgctcctctaccg +ccttagagactttcaattagattttttgcagttaatctatgcgtaagtgaaccatgcaag +ggatgcgattcaaccgcctcgtgctaaccctatcgtctgtctcataactgtaggtctaat +ataattttcagttttcgaacacataaccctttgaaaatctgctatttaatgtctcacctg +catgcactatcttctatactgctcagaacggctatacgtcactatgctccaagtgacgat +ttaaacgaagcaaggaataataggtttattttagtgcaaaacaattaagtgcggactacg +tgctctttacaataagccttgtgattgggctataggttaagtcccatattaacgatctcc +aatgtacaaaatcgacaatcgctttgcattacccggttactagtcgaattacagatagct +gttagatactcactctaattttggacaacaatcccaatcttggggtcgtctatcgcctga +agctcgtaaatccttccatcttaaacgattacatattatagacttgttcggggtagagat +atcacagttgtgcaaacattgtaaatcgatactagtttatgttggtagtctagttgcttt +taccattccccgaaaaacttgatctactatttcgacaacagtaaacttgaactaggtaag +tgaaaacagagaatgcctcatagtgccactatttgtccactatatgtaagtgtagcttta +cataatccactatgactgagatcattacggcctaggaaagcagcgtagaaaaaaagggcc +cggatattacgactgtaactataaaactagttactggtagcgcgccatgtatagatttgt +tttaccggttgtggttgcgttaacgaatttcagccgcgaaaattgatccgttaaccagtc +catctcgacttctataaaacgataaagtaaagttgatgttcagcctccttcttatggttg +catcgagagtacactactcagtgggaaatagatcggggttcctacttcagattgtattat +ctaggcaattgccgattgtgccatacctggataaaataagctacctacatgtgatgctta +tctattatcgtcatactaccttagggtgtcctgttgaacgctacattaatctttagccgt +ttgagatgttccaatggataggagtctaacgcatgatgaagtttaggaaggcagagcatc +ccactaagtatgtgacagtgtatttcgaaacgagacgttataaatagaaaaaaggtcctt +ctggttctattctgctgaactattgaatggaaagattggttgacctacgtactatttgct +tgaagtcatcaatttgacggggtgagagacatatggtgcatactttacggactctatatt +ttagatcagaagcttagcagtcttctctacaccccctcacgacataattgcttttaagaa +tctatgtttgattcctctacgggaattcggatccgttcgcatgtgcggtttatctaaacc +aggggacatatgttcagctaaagcatacgaacactttgctaactagacgtatgtatagta +gctataaatcccgacgatatttacaaaaagaaatgagactcaaatatatacatagcgacc +ctacacttattcgcaccctgatctaggcgatcctagcacccacacccgaaagtgagcact +agtgtcttccgtattaaatttactgcagttgagattttagttgtctactaaggattactc +taacccgtaataaggatcaagactcggtactagctttactatcattccctatgtgttttc +ctaactcacaagggtacgtaccagcctatgtaattacaataatgataaagacacaaagga +agtaactttacaaatgagtctccagttacactagcttagtccctcccatcttgctttgaa +gtctaaatacgcaatctctgaggatatacagcagaagaacactcataacgttggagtcca +agaattagactcatagggcccccaacatttaatatgtactgtgagtttgaaggtgttcta +ttgttaattcctgctcttgatacatgacacgtactccgtgtttaaggcttcggactgact +ttctttcataagttgagcaacgaaaatttcagaatcgataagttggattcactaactaat +acggctgattgaaaactccactccggacctatatggtcgacctttatacgtaaccgatat +aaaacttataggctggtatatcgagccttcctagcgcaatttcggatggggtttcttcta +ctactcaacaacggaatagtctttgtttagtaaaccagagctcaggacgcccaatacgta +ggagagcgctgtggagcatgtgtcattatggactggagcactcttaaatcactctgcgtg +tgctaaacgatagatcataacatgtcctgagtaaattttcttgatacgtcgcaatatacc +gttattagttaaacgttctcatccgtcatgcgtgaaatacggctgtcgtgctcagatata +ctattagcgactcatctcgcctaacacgcacacgtataaactcggaatgactgccgctct +tacatattagaaatacagactacaccacggaagcattgggtcattctcaaccgctgtata +aaagatgattagtcttataataagattaccaaagaggcagaatcatgggtagtaaatcta +ttattcaagtgattaccgtcgtgtaggcagggagtgaggacgagatggtactcaggacaa +atattaaccggacgaagtggtttacgtcgtactttcactattagtagtaaatacaaggta +acaccggggaatagtactaaatataatgatatctatcttcgggagaacgagtcgtctatt +gctttgaacattctcaaggcgtaaaatgtgctgacttatagcatgatacaaccgattgtt +acttttgtctattcaaaagattgaatagttttttatacaaaagccgcatacttatgacgg +ctagtatacagtttcatcccctagcatcaatgctatggacagtattgaacttataggaaa +ttcttctaatagggcaaatccgtcgtgatgcctattttttttcagtcacatcctcaaatg +gcactagtattgtcgggatcccattaacaggctcaaccacgagctcacgcgaggacatgt +agtccgtatctttaacgaagcgacagcgacagaactcccatggataaccaattataaggc +ccgtaatcctctagacatcgtttaccaataaatccgctttctccgtaatcatgttgaata +ccccagagtagtccagatgataaccgatgaaacacaagtctttctcaatgcacttacggt +gaacttattaccgccaacgtagctcatcaaggttgcgacatctagttgtgtgtttgcgac +gagcccagcgaacttcatcaactttcgtatattcaacgccttgtaattttactttaagac +gcctggtgatgtagattcttagataatcagtttgttatcggctgtactttaccataattt +cacaggtttcaggtcaagaagattatagctgtatatacagttccatgctcggtgcacaga +aacgtgatcggataataatcaatcgcttatgtcgtctttaggcgtatccaatacatgccc +cgataccgcagtgtatttcgacatgtaggtataccgtcgcatttgagctcgagtcaggac +gtcagctagattagattccttaatagaatataccgacctctagtccgaactaaactatag +ataacgccaacttcaggttaattgtctagtcgtctgtttgcagatgggattcttagatga +gtgagtatcggccatattggttcgagcactttagtttttgatgcataggatatgcaatgt +atagctgaaagtactttatctgtttcaaactcacattgattaaaccggtaaacctttaaa +gactacaagaaaatattcagtgagggcaattttgtcaatcacaatcttccagctagagat +acttcacaatttgtcttgaggctacgcaacattagacggattttcgcgttttattgaaat +aatcgaggggcccaagagtatccatagttcattttgtaagatttctttacaggcttatta +cagcttcttcagactcctacatgcttacgagttatatgctagcatgtgaacaatagatta +atatacaggaaaacgtacattgagagagatgaccctacacagcgcaaccgttgagtactt +tcattaaagggtaacgctctcgagacagcatccttaagatggccttattgtcaaatcatt +tgcagaagtacgcaagatccctaaccaacgtagaagaatccctacaaacacatgagacgc +ggtgaaaatagacagggtgttagtattcaatcttcggagtatcaatttcgccaatcttgg +tgagaaagcataccctttcttcagagaaagaagatcaatcataacactatctttaacgag +gtacgcacgcgcatcattacctgcctccatggatctttaggatagcggaaagtattggca +gcgtattgtgatttcgttcctactttatcaatttcacattcatatacatgtcttttatca +aaatcgccaataagataggatgagctatattagatgctagtagagttcgcgccaacatca +tcgataggaatactcaggacagcgtgataggacttttcaatccctaatactctctataat +tataactctctcttaagtttggaggcagtaacgcgctctatataatcagtttgctgcacc +attcttcagcctctgatacatacaaataaattccacagcagtaagagggtttaattgaga +catcttgggaacttaggattttactctaacatcaccgaaacgattattggataccgtacc +taaacgaactttctcaaggcagtaatataggacatccgcaataacacaaatgctgcctcc +ccaggagttatgtcttcctggaggctatatcttacacccactcactataggcaaactaaa +gtttaaatgttgattgtctaaaaaaaagatagataagagttggccggcgtagcacatgcg +aaagtgaatcgtaagctataattctctggacttgaagttctgtcctgttcctctgcaaga +aacaaacttcctttaaagctatttacgacgcacatctcagcaagttataaacatgttgga +agtttctagtcggaattcccaaagaacggatctatctaatgcattcctacatttttcctg +tctgccgatggtgccatcctattcaaagaatttcttaaaagtagattaaatgggactttt +aacaatgagtaaccttacgcctctaagggttcctcgagtgccatacaccagtcaggtccg +agccacatacacggagaacattctaacatagcattctcaactcgatcatttgcaggttac +ttctttcctatcctagtgctaaaaatcatacttgcaatcccatagcacggattaagaacc +taagaaacaattcagtaaaacatgttcgaattcttggtatgggaacatcattgcagctat +ggtctaacgcattaatgtttgggtacatcttccatcatataaacaggaagagtctgacga +cagggagtgcttgcgatcatgtctatcattgtgaaatcaaattgtagctcacatgtcgtc +tatgagagcgtgtatccgataagatttagaaaaatagaagtcgtataagatctcactgaa +cttttgaatgaatgtgaagcatatatgatctgctttaataaaactttatccataggatac +gtttccaaatcaattcaataattattagtcaaaatagataaggatgaacaacctgaaggc +cgatcggacgtagaaagtggtcccatcactttgagttgatattgttgaaccacacgttat +tatggttttcaaacagtctcaggatattgtatatacagataatccgataccagttgtctg +acgcccctcttacgtaccccaccctttgtgacgtttaaagcagttgttcagtattttaaa +ctaggcggcaactaatttggaaagaagcacagtggatatgtctaaattcttgttattcag +gcctgaatttaatacaccgcatagttaacttcgcggtagagttgttcatcatgcctcctc +taagctaccacttctatgatacaccaatagttgttctacggaatctgataattggccaag +tcataaacttccgctgcgttcaacccccttgctcgaatatccaactcgaaaagacagcct +tttggtgtccggaacaaatcagttacttcttttctgatgttaattctctgtggtcagata +cagaccaaaaactccgcggatttaccatcctccaagaacaaatttgcatcaacatagcat +tttggctacatattctaagtctcaatagtttaggttttcaactacattatcccaacatta +ggattggaggaataatagctgggtaagtccccttgcgtctacaatcgactattttttatg +aatatgcttctgccgcacctatggttattaaaaaagtcatgactttgaagaaccctgaaa +agatagatgaatcaggtgtaatggcagcagccaaagagcatataattagcaacactctaa +gaacattatagatatgatgatagcgatcgtcatgatgttatccggtcacaatagtagctt +catcagctaattcgttttgccagtggtgacttgcgctggaagaatcgttatacggtccct +tccctcttgatacggtgggggcttattcaaccgcgtggattgggttgtcatacttgcatt +aaacgatgtaaaccatctagtagtcaactatactaaatcacaaaatagtgatcaatacat +acccgcttcatggttttaaccatttaattgattaaagatattccgctaagaaccattatc +tacctaaactgatcgccgtatcctagtagtttgaaatttgatgtaccgtaatgatcaacg +aagtaaaacgttatattgtatgtagaataataggtcttggagctaaatgatgtgattggt +agtgaagacttacccttacaactttaccggtttctcggaagaatatactagagaatcaat +gcatgggctacataagcactttagtctaatgagataaaaaatacacgagtcttccatcat +gaattttttgtcgaaaaactcgaacctggtaatttaaaccatatatctttatgtcgtcaa +taactctcatatgttttatataacttcccaatcacgacttgtaactgcttgttcgactga +gctgtttgagctatgaggccgggatccggttgagctacatctatttgctacaagaaaaat +gaaagcacatttgttgggagttctggctacactcatagagaaataagtggcccgagtggg +tgcggcctgcctccatattcaagtgtatcttaaaccaagtggttccaacgctcgcgctaa +agaattaaagcctttatttcctccacggagtagcccgtaatccggttcgaaagagaccat +tgaagttaattttcatatccagtgaagtttaggcacaagcatgtgttctgccacatgcct +caaagcgctcttcaaccaagatatgattcatcctaacttcgatgaatgcgtctgtaacat +aaatatagaaggaatgattcggcgagttaattttcgccttctccaacatggcatccctac +gttcgttataaggaccatacatgtaggttttaaaggtttgcggttaatcgatatttacat +catagaaattctatagtcaaatttacaagactctagatactcactcgttgcagccggcta +ggaagcgctttgtaccttacttcccttttcgttgcgtaatatgaatttcatatagtaagt +tcaaggcactcatacctccgtgaagagggtagatagactattaaagttgtttaatagtac +gtattgatggaaatgacccgtaggagatttaccactcaatccacaagattcgctgctgtg +cattatcaaaacagtgcatgtcgaaacatgggttgggtccttcaaacacgaatccaggta +gagatacctttgcaattttt diff --git a/third_party/cargo/vendor/regex-1.3.3/examples/regexdna-output.txt b/third_party/cargo/vendor/regex-1.3.3/examples/regexdna-output.txt new file mode 100644 index 0000000..d36baa5 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/examples/regexdna-output.txt @@ -0,0 +1,13 @@ +agggtaaa|tttaccct 0 +[cgt]gggtaaa|tttaccc[acg] 3 +a[act]ggtaaa|tttacc[agt]t 9 +ag[act]gtaaa|tttac[agt]ct 8 +agg[act]taaa|ttta[agt]cct 10 +aggg[acg]aaa|ttt[cgt]ccct 3 +agggt[cgt]aa|tt[acg]accct 4 +agggta[cgt]a|t[acg]taccct 3 +agggtaa[cgt]|[acg]ttaccct 5 + +101745 +100000 +133640 diff --git a/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-bytes.rs b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-bytes.rs new file mode 100644 index 0000000..a763385 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-bytes.rs @@ -0,0 +1,70 @@ +// The Computer Language Benchmarks Game +// http://benchmarksgame.alioth.debian.org/ +// +// contributed by the Rust Project Developers +// contributed by TeXitoi +// contributed by BurntSushi + +extern crate regex; + +use std::io::{self, Read}; +use std::sync::Arc; +use std::thread; + +macro_rules! regex { + ($re:expr) => { + ::regex::bytes::Regex::new($re).unwrap() + }; +} + +fn main() { + let mut seq = Vec::with_capacity(51 * (1 << 20)); + io::stdin().read_to_end(&mut seq).unwrap(); + let ilen = seq.len(); + + seq = regex!(">[^\n]*\n|\n").replace_all(&seq, &b""[..]).into_owned(); + let clen = seq.len(); + let seq_arc = Arc::new(seq.clone()); + + let variants = vec![ + regex!("agggtaaa|tttaccct"), + regex!("[cgt]gggtaaa|tttaccc[acg]"), + regex!("a[act]ggtaaa|tttacc[agt]t"), + regex!("ag[act]gtaaa|tttac[agt]ct"), + regex!("agg[act]taaa|ttta[agt]cct"), + regex!("aggg[acg]aaa|ttt[cgt]ccct"), + regex!("agggt[cgt]aa|tt[acg]accct"), + regex!("agggta[cgt]a|t[acg]taccct"), + regex!("agggtaa[cgt]|[acg]ttaccct"), + ]; + let mut counts = vec![]; + for variant in variants { + let seq = seq_arc.clone(); + let restr = variant.to_string(); + let future = thread::spawn(move || variant.find_iter(&seq).count()); + counts.push((restr, future)); + } + + let substs = vec![ + (regex!("B"), &b"(c|g|t)"[..]), + (regex!("D"), &b"(a|g|t)"[..]), + (regex!("H"), &b"(a|c|t)"[..]), + (regex!("K"), &b"(g|t)"[..]), + (regex!("M"), &b"(a|c)"[..]), + (regex!("N"), &b"(a|c|g|t)"[..]), + (regex!("R"), &b"(a|g)"[..]), + (regex!("S"), &b"(c|g)"[..]), + (regex!("V"), &b"(a|c|g)"[..]), + (regex!("W"), &b"(a|t)"[..]), + (regex!("Y"), &b"(c|t)"[..]), + ]; + let mut seq = seq; + for (re, replacement) in substs { + seq = re.replace_all(&seq, replacement).into_owned(); + } + + for (variant, count) in counts { + println!("{} {}", variant, count.join().unwrap()); + } + println!("\n{}\n{}\n{}", ilen, clen, seq.len()); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-cheat.rs b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-cheat.rs new file mode 100644 index 0000000..27c5308 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-cheat.rs @@ -0,0 +1,92 @@ +// The Computer Language Benchmarks Game +// http://benchmarksgame.alioth.debian.org/ +// +// contributed by the Rust Project Developers +// contributed by TeXitoi +// contributed by BurntSushi + +// This technically solves the problem posed in the `regex-dna` benchmark, but +// it cheats by combining all of the replacements into a single regex and +// replacing them with a single linear scan. i.e., it re-implements +// `replace_all`. As a result, this is around 25% faster. ---AG + +extern crate regex; + +use std::io::{self, Read}; +use std::sync::Arc; +use std::thread; + +macro_rules! regex { + ($re:expr) => { + ::regex::Regex::new($re).unwrap() + }; +} + +fn main() { + let mut seq = String::with_capacity(50 * (1 << 20)); + io::stdin().read_to_string(&mut seq).unwrap(); + let ilen = seq.len(); + + seq = regex!(">[^\n]*\n|\n").replace_all(&seq, "").into_owned(); + let clen = seq.len(); + let seq_arc = Arc::new(seq.clone()); + + let variants = vec![ + regex!("agggtaaa|tttaccct"), + regex!("[cgt]gggtaaa|tttaccc[acg]"), + regex!("a[act]ggtaaa|tttacc[agt]t"), + regex!("ag[act]gtaaa|tttac[agt]ct"), + regex!("agg[act]taaa|ttta[agt]cct"), + regex!("aggg[acg]aaa|ttt[cgt]ccct"), + regex!("agggt[cgt]aa|tt[acg]accct"), + regex!("agggta[cgt]a|t[acg]taccct"), + regex!("agggtaa[cgt]|[acg]ttaccct"), + ]; + let mut counts = vec![]; + for variant in variants { + let seq = seq_arc.clone(); + let restr = variant.to_string(); + let future = thread::spawn(move || variant.find_iter(&seq).count()); + counts.push((restr, future)); + } + + let substs = vec![ + (b'B', "(c|g|t)"), + (b'D', "(a|g|t)"), + (b'H', "(a|c|t)"), + (b'K', "(g|t)"), + (b'M', "(a|c)"), + (b'N', "(a|c|g|t)"), + (b'R', "(a|g)"), + (b'S', "(c|g)"), + (b'V', "(a|c|g)"), + (b'W', "(a|t)"), + (b'Y', "(c|t)"), + ]; // combined into one regex in `replace_all` + let seq = replace_all(&seq, substs); + + for (variant, count) in counts { + println!("{} {}", variant, count.join().unwrap()); + } + println!("\n{}\n{}\n{}", ilen, clen, seq.len()); +} + +fn replace_all(text: &str, substs: Vec<(u8, &str)>) -> String { + let mut replacements = vec![""; 256]; + let mut alternates = vec![]; + for (re, replacement) in substs { + replacements[re as usize] = replacement; + alternates.push((re as char).to_string()); + } + + let re = regex!(&alternates.join("|")); + let mut new = String::with_capacity(text.len()); + let mut last_match = 0; + for m in re.find_iter(text) { + new.push_str(&text[last_match..m.start()]); + new.push_str(replacements[text.as_bytes()[m.start()] as usize]); + last_match = m.end(); + } + new.push_str(&text[last_match..]); + new +} diff --git a/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-replace.rs b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-replace.rs new file mode 100644 index 0000000..681e077 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-replace.rs @@ -0,0 +1,19 @@ +extern crate regex; + +use std::io::{self, Read}; + +macro_rules! regex { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new($re).build().unwrap().into_regex() + }}; +} + +fn main() { + let mut seq = String::with_capacity(50 * (1 << 20)); + io::stdin().read_to_string(&mut seq).unwrap(); + let ilen = seq.len(); + + seq = regex!(">[^\n]*\n|\n").replace_all(&seq, "").into_owned(); + println!("original: {}, replaced: {}", ilen, seq.len()); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-single-cheat.rs b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-single-cheat.rs new file mode 100644 index 0000000..ec444b4 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-single-cheat.rs @@ -0,0 +1,77 @@ +// The Computer Language Benchmarks Game +// http://benchmarksgame.alioth.debian.org/ +// +// contributed by the Rust Project Developers +// contributed by TeXitoi +// contributed by BurntSushi + +extern crate regex; + +use std::io::{self, Read}; + +macro_rules! regex { + ($re:expr) => { + ::regex::Regex::new($re).unwrap() + }; +} + +fn main() { + let mut seq = String::with_capacity(50 * (1 << 20)); + io::stdin().read_to_string(&mut seq).unwrap(); + let ilen = seq.len(); + + seq = regex!(">[^\n]*\n|\n").replace_all(&seq, "").into_owned(); + let clen = seq.len(); + + let variants = vec![ + regex!("agggtaaa|tttaccct"), + regex!("[cgt]gggtaaa|tttaccc[acg]"), + regex!("a[act]ggtaaa|tttacc[agt]t"), + regex!("ag[act]gtaaa|tttac[agt]ct"), + regex!("agg[act]taaa|ttta[agt]cct"), + regex!("aggg[acg]aaa|ttt[cgt]ccct"), + regex!("agggt[cgt]aa|tt[acg]accct"), + regex!("agggta[cgt]a|t[acg]taccct"), + regex!("agggtaa[cgt]|[acg]ttaccct"), + ]; + for re in variants { + println!("{} {}", re.to_string(), re.find_iter(&seq).count()); + } + + let substs = vec![ + (b'B', "(c|g|t)"), + (b'D', "(a|g|t)"), + (b'H', "(a|c|t)"), + (b'K', "(g|t)"), + (b'M', "(a|c)"), + (b'N', "(a|c|g|t)"), + (b'R', "(a|g)"), + (b'S', "(c|g)"), + (b'V', "(a|c|g)"), + (b'W', "(a|t)"), + (b'Y', "(c|t)"), + ]; // combined into one regex in `replace_all` + let seq = replace_all(&seq, substs); + + println!("\n{}\n{}\n{}", ilen, clen, seq.len()); +} + +fn replace_all(text: &str, substs: Vec<(u8, &str)>) -> String { + let mut replacements = vec![""; 256]; + let mut alternates = vec![]; + for (re, replacement) in substs { + replacements[re as usize] = replacement; + alternates.push((re as char).to_string()); + } + + let re = regex!(&alternates.join("|")); + let mut new = String::with_capacity(text.len()); + let mut last_match = 0; + for m in re.find_iter(text) { + new.push_str(&text[last_match..m.start()]); + new.push_str(replacements[text.as_bytes()[m.start()] as usize]); + last_match = m.end(); + } + new.push_str(&text[last_match..]); + new +} diff --git a/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-single.rs b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-single.rs new file mode 100644 index 0000000..ab34107 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna-single.rs @@ -0,0 +1,59 @@ +// The Computer Language Benchmarks Game +// http://benchmarksgame.alioth.debian.org/ +// +// contributed by the Rust Project Developers +// contributed by TeXitoi +// contributed by BurntSushi + +extern crate regex; + +use std::io::{self, Read}; + +macro_rules! regex { + ($re:expr) => { + ::regex::Regex::new($re).unwrap() + }; +} + +fn main() { + let mut seq = String::with_capacity(50 * (1 << 20)); + io::stdin().read_to_string(&mut seq).unwrap(); + let ilen = seq.len(); + + seq = regex!(">[^\n]*\n|\n").replace_all(&seq, "").into_owned(); + let clen = seq.len(); + + let variants = vec![ + regex!("agggtaaa|tttaccct"), + regex!("[cgt]gggtaaa|tttaccc[acg]"), + regex!("a[act]ggtaaa|tttacc[agt]t"), + regex!("ag[act]gtaaa|tttac[agt]ct"), + regex!("agg[act]taaa|ttta[agt]cct"), + regex!("aggg[acg]aaa|ttt[cgt]ccct"), + regex!("agggt[cgt]aa|tt[acg]accct"), + regex!("agggta[cgt]a|t[acg]taccct"), + regex!("agggtaa[cgt]|[acg]ttaccct"), + ]; + for re in variants { + println!("{} {}", re.to_string(), re.find_iter(&seq).count()); + } + + let substs = vec![ + (regex!("B"), "(c|g|t)"), + (regex!("D"), "(a|g|t)"), + (regex!("H"), "(a|c|t)"), + (regex!("K"), "(g|t)"), + (regex!("M"), "(a|c)"), + (regex!("N"), "(a|c|g|t)"), + (regex!("R"), "(a|g)"), + (regex!("S"), "(c|g)"), + (regex!("V"), "(a|c|g)"), + (regex!("W"), "(a|t)"), + (regex!("Y"), "(c|t)"), + ]; + let mut seq = seq; + for (re, replacement) in substs { + seq = re.replace_all(&seq, replacement).into_owned(); + } + println!("\n{}\n{}\n{}", ilen, clen, seq.len()); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna.rs b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna.rs new file mode 100644 index 0000000..ece7ca5 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/examples/shootout-regex-dna.rs @@ -0,0 +1,70 @@ +// The Computer Language Benchmarks Game +// http://benchmarksgame.alioth.debian.org/ +// +// contributed by the Rust Project Developers +// contributed by TeXitoi +// contributed by BurntSushi + +extern crate regex; + +use std::io::{self, Read}; +use std::sync::Arc; +use std::thread; + +macro_rules! regex { + ($re:expr) => { + ::regex::Regex::new($re).unwrap() + }; +} + +fn main() { + let mut seq = String::with_capacity(51 * (1 << 20)); + io::stdin().read_to_string(&mut seq).unwrap(); + let ilen = seq.len(); + + seq = regex!(">[^\n]*\n|\n").replace_all(&seq, "").into_owned(); + let clen = seq.len(); + let seq_arc = Arc::new(seq.clone()); + + let variants = vec![ + regex!("agggtaaa|tttaccct"), + regex!("[cgt]gggtaaa|tttaccc[acg]"), + regex!("a[act]ggtaaa|tttacc[agt]t"), + regex!("ag[act]gtaaa|tttac[agt]ct"), + regex!("agg[act]taaa|ttta[agt]cct"), + regex!("aggg[acg]aaa|ttt[cgt]ccct"), + regex!("agggt[cgt]aa|tt[acg]accct"), + regex!("agggta[cgt]a|t[acg]taccct"), + regex!("agggtaa[cgt]|[acg]ttaccct"), + ]; + let mut counts = vec![]; + for variant in variants { + let seq = seq_arc.clone(); + let restr = variant.to_string(); + let future = thread::spawn(move || variant.find_iter(&seq).count()); + counts.push((restr, future)); + } + + let substs = vec![ + (regex!("B"), "(c|g|t)"), + (regex!("D"), "(a|g|t)"), + (regex!("H"), "(a|c|t)"), + (regex!("K"), "(g|t)"), + (regex!("M"), "(a|c)"), + (regex!("N"), "(a|c|g|t)"), + (regex!("R"), "(a|g)"), + (regex!("S"), "(c|g)"), + (regex!("V"), "(a|c|g)"), + (regex!("W"), "(a|t)"), + (regex!("Y"), "(c|t)"), + ]; + let mut seq = seq; + for (re, replacement) in substs { + seq = re.replace_all(&seq, replacement).into_owned(); + } + + for (variant, count) in counts { + println!("{} {}", variant, count.join().unwrap()); + } + println!("\n{}\n{}\n{}", ilen, clen, seq.len()); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/rustfmt.toml b/third_party/cargo/vendor/regex-1.3.3/rustfmt.toml new file mode 100644 index 0000000..aa37a21 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/rustfmt.toml @@ -0,0 +1,2 @@ +max_width = 79 +use_small_heuristics = "max" diff --git a/third_party/cargo/vendor/regex-1.3.3/src/backtrack.rs b/third_party/cargo/vendor/regex-1.3.3/src/backtrack.rs new file mode 100644 index 0000000..2eaeb72 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/backtrack.rs @@ -0,0 +1,288 @@ +// This is the backtracking matching engine. It has the same exact capability +// as the full NFA simulation, except it is artificially restricted to small +// regexes on small inputs because of its memory requirements. +// +// In particular, this is a *bounded* backtracking engine. It retains worst +// case linear time by keeping track of the states that it has visited (using a +// bitmap). Namely, once a state is visited, it is never visited again. Since a +// state is keyed by `(instruction index, input index)`, we have that its time +// complexity is `O(mn)` (i.e., linear in the size of the search text). +// +// The backtracking engine can beat out the NFA simulation on small +// regexes/inputs because it doesn't have to keep track of multiple copies of +// the capture groups. In benchmarks, the backtracking engine is roughly twice +// as fast as the full NFA simulation. Note though that its performance doesn't +// scale, even if you're willing to live with the memory requirements. Namely, +// the bitset has to be zeroed on each execution, which becomes quite expensive +// on large bitsets. + +use exec::ProgramCache; +use input::{Input, InputAt}; +use prog::{InstPtr, Program}; +use re_trait::Slot; + +type Bits = u32; + +const BIT_SIZE: usize = 32; +const MAX_SIZE_BYTES: usize = 256 * (1 << 10); // 256 KB + +/// Returns true iff the given regex and input should be executed by this +/// engine with reasonable memory usage. +pub fn should_exec(num_insts: usize, text_len: usize) -> bool { + // Total memory usage in bytes is determined by: + // + // ((len(insts) * (len(input) + 1) + bits - 1) / bits) * (size_of(u32)) + // + // The actual limit picked is pretty much a heuristic. + // See: https://github.com/rust-lang/regex/issues/215 + let size = ((num_insts * (text_len + 1) + BIT_SIZE - 1) / BIT_SIZE) * 4; + size <= MAX_SIZE_BYTES +} + +/// A backtracking matching engine. +#[derive(Debug)] +pub struct Bounded<'a, 'm, 'r, 's, I> { + prog: &'r Program, + input: I, + matches: &'m mut [bool], + slots: &'s mut [Slot], + m: &'a mut Cache, +} + +/// Shared cached state between multiple invocations of a backtracking engine +/// in the same thread. +#[derive(Clone, Debug)] +pub struct Cache { + jobs: Vec, + visited: Vec, +} + +impl Cache { + /// Create new empty cache for the backtracking engine. + pub fn new(_prog: &Program) -> Self { + Cache { jobs: vec![], visited: vec![] } + } +} + +/// A job is an explicit unit of stack space in the backtracking engine. +/// +/// The "normal" representation is a single state transition, which corresponds +/// to an NFA state and a character in the input. However, the backtracking +/// engine must keep track of old capture group values. We use the explicit +/// stack to do it. +#[derive(Clone, Copy, Debug)] +enum Job { + Inst { ip: InstPtr, at: InputAt }, + SaveRestore { slot: usize, old_pos: Option }, +} + +impl<'a, 'm, 'r, 's, I: Input> Bounded<'a, 'm, 'r, 's, I> { + /// Execute the backtracking matching engine. + /// + /// If there's a match, `exec` returns `true` and populates the given + /// captures accordingly. + pub fn exec( + prog: &'r Program, + cache: &ProgramCache, + matches: &'m mut [bool], + slots: &'s mut [Slot], + input: I, + start: usize, + end: usize, + ) -> bool { + let mut cache = cache.borrow_mut(); + let cache = &mut cache.backtrack; + let start = input.at(start); + let mut b = Bounded { + prog: prog, + input: input, + matches: matches, + slots: slots, + m: cache, + }; + b.exec_(start, end) + } + + /// Clears the cache such that the backtracking engine can be executed + /// on some input of fixed length. + fn clear(&mut self) { + // Reset the job memory so that we start fresh. + self.m.jobs.clear(); + + // Now we need to clear the bit state set. + // We do this by figuring out how much space we need to keep track + // of the states we've visited. + // Then we reset all existing allocated space to 0. + // Finally, we request more space if we need it. + // + // This is all a little circuitous, but doing this unsafely + // doesn't seem to have a measurable impact on performance. + // (Probably because backtracking is limited to such small + // inputs/regexes in the first place.) + let visited_len = + (self.prog.len() * (self.input.len() + 1) + BIT_SIZE - 1) + / BIT_SIZE; + self.m.visited.truncate(visited_len); + for v in &mut self.m.visited { + *v = 0; + } + if visited_len > self.m.visited.len() { + let len = self.m.visited.len(); + self.m.visited.reserve_exact(visited_len - len); + for _ in 0..(visited_len - len) { + self.m.visited.push(0); + } + } + } + + /// Start backtracking at the given position in the input, but also look + /// for literal prefixes. + fn exec_(&mut self, mut at: InputAt, end: usize) -> bool { + self.clear(); + // If this is an anchored regex at the beginning of the input, then + // we're either already done or we only need to try backtracking once. + if self.prog.is_anchored_start { + return if !at.is_start() { false } else { self.backtrack(at) }; + } + let mut matched = false; + loop { + if !self.prog.prefixes.is_empty() { + at = match self.input.prefix_at(&self.prog.prefixes, at) { + None => break, + Some(at) => at, + }; + } + matched = self.backtrack(at) || matched; + if matched && self.prog.matches.len() == 1 { + return true; + } + if at.pos() >= end { + break; + } + at = self.input.at(at.next_pos()); + } + matched + } + + /// The main backtracking loop starting at the given input position. + fn backtrack(&mut self, start: InputAt) -> bool { + // N.B. We use an explicit stack to avoid recursion. + // To avoid excessive pushing and popping, most transitions are handled + // in the `step` helper function, which only pushes to the stack when + // there's a capture or a branch. + let mut matched = false; + self.m.jobs.push(Job::Inst { ip: 0, at: start }); + while let Some(job) = self.m.jobs.pop() { + match job { + Job::Inst { ip, at } => { + if self.step(ip, at) { + // Only quit if we're matching one regex. + // If we're matching a regex set, then mush on and + // try to find other matches (if we want them). + if self.prog.matches.len() == 1 { + return true; + } + matched = true; + } + } + Job::SaveRestore { slot, old_pos } => { + if slot < self.slots.len() { + self.slots[slot] = old_pos; + } + } + } + } + matched + } + + fn step(&mut self, mut ip: InstPtr, mut at: InputAt) -> bool { + use prog::Inst::*; + loop { + // This loop is an optimization to avoid constantly pushing/popping + // from the stack. Namely, if we're pushing a job only to run it + // next, avoid the push and just mutate `ip` (and possibly `at`) + // in place. + if self.has_visited(ip, at) { + return false; + } + match self.prog[ip] { + Match(slot) => { + if slot < self.matches.len() { + self.matches[slot] = true; + } + return true; + } + Save(ref inst) => { + if let Some(&old_pos) = self.slots.get(inst.slot) { + // If this path doesn't work out, then we save the old + // capture index (if one exists) in an alternate + // job. If the next path fails, then the alternate + // job is popped and the old capture index is restored. + self.m.jobs.push(Job::SaveRestore { + slot: inst.slot, + old_pos: old_pos, + }); + self.slots[inst.slot] = Some(at.pos()); + } + ip = inst.goto; + } + Split(ref inst) => { + self.m.jobs.push(Job::Inst { ip: inst.goto2, at: at }); + ip = inst.goto1; + } + EmptyLook(ref inst) => { + if self.input.is_empty_match(at, inst) { + ip = inst.goto; + } else { + return false; + } + } + Char(ref inst) => { + if inst.c == at.char() { + ip = inst.goto; + at = self.input.at(at.next_pos()); + } else { + return false; + } + } + Ranges(ref inst) => { + if inst.matches(at.char()) { + ip = inst.goto; + at = self.input.at(at.next_pos()); + } else { + return false; + } + } + Bytes(ref inst) => { + if let Some(b) = at.byte() { + if inst.matches(b) { + ip = inst.goto; + at = self.input.at(at.next_pos()); + continue; + } + } + return false; + } + } + } + } + + fn has_visited(&mut self, ip: InstPtr, at: InputAt) -> bool { + let k = ip * (self.input.len() + 1) + at.pos(); + let k1 = k / BIT_SIZE; + let k2 = usize_to_u32(1 << (k & (BIT_SIZE - 1))); + if self.m.visited[k1] & k2 == 0 { + self.m.visited[k1] |= k2; + false + } else { + true + } + } +} + +fn usize_to_u32(n: usize) -> u32 { + if (n as u64) > (::std::u32::MAX as u64) { + panic!("BUG: {} is too big to fit into u32", n) + } + n as u32 +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/cache.rs b/third_party/cargo/vendor/regex-1.3.3/src/cache.rs new file mode 100644 index 0000000..dbb7e64 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/cache.rs @@ -0,0 +1,100 @@ +// This module defines a common API for caching internal runtime state. +// The `thread_local` crate provides an extremely optimized version of this. +// However, if the perf-cache feature is disabled, then we drop the +// thread_local dependency and instead use a pretty naive caching mechanism +// with a mutex. +// +// Strictly speaking, the CachedGuard isn't necessary for the much more +// flexible thread_local API, but implementing thread_local's API doesn't +// seem possible in purely safe code. + +pub use self::imp::{Cached, CachedGuard}; + +#[cfg(feature = "perf-cache")] +mod imp { + use thread_local::CachedThreadLocal; + + #[derive(Debug)] + pub struct Cached(CachedThreadLocal); + + #[derive(Debug)] + pub struct CachedGuard<'a, T: 'a>(&'a T); + + impl Cached { + pub fn new() -> Cached { + Cached(CachedThreadLocal::new()) + } + + pub fn get_or(&self, create: impl FnOnce() -> T) -> CachedGuard { + CachedGuard(self.0.get_or(|| create())) + } + } + + impl<'a, T: Send> CachedGuard<'a, T> { + pub fn value(&self) -> &T { + self.0 + } + } +} + +#[cfg(not(feature = "perf-cache"))] +mod imp { + use std::marker::PhantomData; + use std::panic::UnwindSafe; + use std::sync::Mutex; + + #[derive(Debug)] + pub struct Cached { + stack: Mutex>, + /// When perf-cache is enabled, the thread_local crate is used, and + /// its CachedThreadLocal impls Send, Sync and UnwindSafe, but NOT + /// RefUnwindSafe. However, a Mutex impls RefUnwindSafe. So in order + /// to keep the APIs consistent regardless of whether perf-cache is + /// enabled, we force this type to NOT impl RefUnwindSafe too. + /// + /// Ideally, we should always impl RefUnwindSafe, but it seems a little + /// tricky to do that right now. + /// + /// See also: https://github.com/rust-lang/regex/issues/576 + _phantom: PhantomData>, + } + + #[derive(Debug)] + pub struct CachedGuard<'a, T: 'a + Send> { + cache: &'a Cached, + value: Option, + } + + impl Cached { + pub fn new() -> Cached { + Cached { stack: Mutex::new(vec![]), _phantom: PhantomData } + } + + pub fn get_or(&self, create: impl FnOnce() -> T) -> CachedGuard { + let mut stack = self.stack.lock().unwrap(); + match stack.pop() { + None => CachedGuard { cache: self, value: Some(create()) }, + Some(value) => CachedGuard { cache: self, value: Some(value) }, + } + } + + fn put(&self, value: T) { + let mut stack = self.stack.lock().unwrap(); + stack.push(value); + } + } + + impl<'a, T: Send> CachedGuard<'a, T> { + pub fn value(&self) -> &T { + self.value.as_ref().unwrap() + } + } + + impl<'a, T: Send> Drop for CachedGuard<'a, T> { + fn drop(&mut self) { + if let Some(value) = self.value.take() { + self.cache.put(value); + } + } + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/compile.rs b/third_party/cargo/vendor/regex-1.3.3/src/compile.rs new file mode 100644 index 0000000..ac706f8 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/compile.rs @@ -0,0 +1,1120 @@ +use std::collections::HashMap; +use std::iter; +use std::result; +use std::sync::Arc; + +use syntax::hir::{self, Hir}; +use syntax::is_word_byte; +use syntax::utf8::{Utf8Range, Utf8Sequence, Utf8Sequences}; + +use prog::{ + EmptyLook, Inst, InstBytes, InstChar, InstEmptyLook, InstPtr, InstRanges, + InstSave, InstSplit, Program, +}; + +use Error; + +type Result = result::Result; + +#[derive(Debug)] +struct Patch { + hole: Hole, + entry: InstPtr, +} + +/// A compiler translates a regular expression AST to a sequence of +/// instructions. The sequence of instructions represents an NFA. +pub struct Compiler { + insts: Vec, + compiled: Program, + capture_name_idx: HashMap, + num_exprs: usize, + size_limit: usize, + suffix_cache: SuffixCache, + utf8_seqs: Option, + byte_classes: ByteClassSet, +} + +impl Compiler { + /// Create a new regular expression compiler. + /// + /// Various options can be set before calling `compile` on an expression. + pub fn new() -> Self { + Compiler { + insts: vec![], + compiled: Program::new(), + capture_name_idx: HashMap::new(), + num_exprs: 0, + size_limit: 10 * (1 << 20), + suffix_cache: SuffixCache::new(1000), + utf8_seqs: Some(Utf8Sequences::new('\x00', '\x00')), + byte_classes: ByteClassSet::new(), + } + } + + /// The size of the resulting program is limited by size_limit. If + /// the program approximately exceeds the given size (in bytes), then + /// compilation will stop and return an error. + pub fn size_limit(mut self, size_limit: usize) -> Self { + self.size_limit = size_limit; + self + } + + /// If bytes is true, then the program is compiled as a byte based + /// automaton, which incorporates UTF-8 decoding into the machine. If it's + /// false, then the automaton is Unicode scalar value based, e.g., an + /// engine utilizing such an automaton is responsible for UTF-8 decoding. + /// + /// The specific invariant is that when returning a byte based machine, + /// the neither the `Char` nor `Ranges` instructions are produced. + /// Conversely, when producing a Unicode scalar value machine, the `Bytes` + /// instruction is never produced. + /// + /// Note that `dfa(true)` implies `bytes(true)`. + pub fn bytes(mut self, yes: bool) -> Self { + self.compiled.is_bytes = yes; + self + } + + /// When disabled, the program compiled may match arbitrary bytes. + /// + /// When enabled (the default), all compiled programs exclusively match + /// valid UTF-8 bytes. + pub fn only_utf8(mut self, yes: bool) -> Self { + self.compiled.only_utf8 = yes; + self + } + + /// When set, the machine returned is suitable for use in the DFA matching + /// engine. + /// + /// In particular, this ensures that if the regex is not anchored in the + /// beginning, then a preceding `.*?` is included in the program. (The NFA + /// based engines handle the preceding `.*?` explicitly, which is difficult + /// or impossible in the DFA engine.) + pub fn dfa(mut self, yes: bool) -> Self { + self.compiled.is_dfa = yes; + self + } + + /// When set, the machine returned is suitable for matching text in + /// reverse. In particular, all concatenations are flipped. + pub fn reverse(mut self, yes: bool) -> Self { + self.compiled.is_reverse = yes; + self + } + + /// Compile a regular expression given its AST. + /// + /// The compiler is guaranteed to succeed unless the program exceeds the + /// specified size limit. If the size limit is exceeded, then compilation + /// stops and returns an error. + pub fn compile(mut self, exprs: &[Hir]) -> result::Result { + debug_assert!(!exprs.is_empty()); + self.num_exprs = exprs.len(); + if exprs.len() == 1 { + self.compile_one(&exprs[0]) + } else { + self.compile_many(exprs) + } + } + + fn compile_one(mut self, expr: &Hir) -> result::Result { + // If we're compiling a forward DFA and we aren't anchored, then + // add a `.*?` before the first capture group. + // Other matching engines handle this by baking the logic into the + // matching engine itself. + let mut dotstar_patch = Patch { hole: Hole::None, entry: 0 }; + self.compiled.is_anchored_start = expr.is_anchored_start(); + self.compiled.is_anchored_end = expr.is_anchored_end(); + if self.compiled.needs_dotstar() { + dotstar_patch = self.c_dotstar()?; + self.compiled.start = dotstar_patch.entry; + } + self.compiled.captures = vec![None]; + let patch = self.c_capture(0, expr)?; + if self.compiled.needs_dotstar() { + self.fill(dotstar_patch.hole, patch.entry); + } else { + self.compiled.start = patch.entry; + } + self.fill_to_next(patch.hole); + self.compiled.matches = vec![self.insts.len()]; + self.push_compiled(Inst::Match(0)); + self.compile_finish() + } + + fn compile_many( + mut self, + exprs: &[Hir], + ) -> result::Result { + debug_assert!(exprs.len() > 1); + + self.compiled.is_anchored_start = + exprs.iter().all(|e| e.is_anchored_start()); + self.compiled.is_anchored_end = + exprs.iter().all(|e| e.is_anchored_end()); + let mut dotstar_patch = Patch { hole: Hole::None, entry: 0 }; + if self.compiled.needs_dotstar() { + dotstar_patch = self.c_dotstar()?; + self.compiled.start = dotstar_patch.entry; + } else { + self.compiled.start = 0; // first instruction is always split + } + self.fill_to_next(dotstar_patch.hole); + + let mut prev_hole = Hole::None; + for (i, expr) in exprs[0..exprs.len() - 1].iter().enumerate() { + self.fill_to_next(prev_hole); + let split = self.push_split_hole(); + let Patch { hole, entry } = self.c_capture(0, expr)?; + self.fill_to_next(hole); + self.compiled.matches.push(self.insts.len()); + self.push_compiled(Inst::Match(i)); + prev_hole = self.fill_split(split, Some(entry), None); + } + let i = exprs.len() - 1; + let Patch { hole, entry } = self.c_capture(0, &exprs[i])?; + self.fill(prev_hole, entry); + self.fill_to_next(hole); + self.compiled.matches.push(self.insts.len()); + self.push_compiled(Inst::Match(i)); + self.compile_finish() + } + + fn compile_finish(mut self) -> result::Result { + self.compiled.insts = + self.insts.into_iter().map(|inst| inst.unwrap()).collect(); + self.compiled.byte_classes = self.byte_classes.byte_classes(); + self.compiled.capture_name_idx = Arc::new(self.capture_name_idx); + Ok(self.compiled) + } + + /// Compile expr into self.insts, returning a patch on success, + /// or an error if we run out of memory. + /// + /// All of the c_* methods of the compiler share the contract outlined + /// here. + /// + /// The main thing that a c_* method does is mutate `self.insts` + /// to add a list of mostly compiled instructions required to execute + /// the given expression. `self.insts` contains MaybeInsts rather than + /// Insts because there is some backpatching required. + /// + /// The `Patch` value returned by each c_* method provides metadata + /// about the compiled instructions emitted to `self.insts`. The + /// `entry` member of the patch refers to the first instruction + /// (the entry point), while the `hole` member contains zero or + /// more offsets to partial instructions that need to be backpatched. + /// The c_* routine can't know where its list of instructions are going to + /// jump to after execution, so it is up to the caller to patch + /// these jumps to point to the right place. So compiling some + /// expression, e, we would end up with a situation that looked like: + /// + /// ```text + /// self.insts = [ ..., i1, i2, ..., iexit1, ..., iexitn, ...] + /// ^ ^ ^ + /// | \ / + /// entry \ / + /// hole + /// ``` + /// + /// To compile two expressions, e1 and e2, concatinated together we + /// would do: + /// + /// ```ignore + /// let patch1 = self.c(e1); + /// let patch2 = self.c(e2); + /// ``` + /// + /// while leaves us with a situation that looks like + /// + /// ```text + /// self.insts = [ ..., i1, ..., iexit1, ..., i2, ..., iexit2 ] + /// ^ ^ ^ ^ + /// | | | | + /// entry1 hole1 entry2 hole2 + /// ``` + /// + /// Then to merge the two patches together into one we would backpatch + /// hole1 with entry2 and return a new patch that enters at entry1 + /// and has hole2 for a hole. In fact, if you look at the c_concat + /// method you will see that it does exactly this, though it handles + /// a list of expressions rather than just the two that we use for + /// an example. + fn c(&mut self, expr: &Hir) -> Result { + use prog; + use syntax::hir::HirKind::*; + + self.check_size()?; + match *expr.kind() { + Empty => Ok(Patch { hole: Hole::None, entry: self.insts.len() }), + Literal(hir::Literal::Unicode(c)) => self.c_char(c), + Literal(hir::Literal::Byte(b)) => { + assert!(self.compiled.uses_bytes()); + self.c_byte(b) + } + Class(hir::Class::Unicode(ref cls)) => self.c_class(cls.ranges()), + Class(hir::Class::Bytes(ref cls)) => { + if self.compiled.uses_bytes() { + self.c_class_bytes(cls.ranges()) + } else { + assert!(cls.is_all_ascii()); + let mut char_ranges = vec![]; + for r in cls.iter() { + let (s, e) = (r.start() as char, r.end() as char); + char_ranges.push(hir::ClassUnicodeRange::new(s, e)); + } + self.c_class(&char_ranges) + } + } + Anchor(hir::Anchor::StartLine) if self.compiled.is_reverse => { + self.byte_classes.set_range(b'\n', b'\n'); + self.c_empty_look(prog::EmptyLook::EndLine) + } + Anchor(hir::Anchor::StartLine) => { + self.byte_classes.set_range(b'\n', b'\n'); + self.c_empty_look(prog::EmptyLook::StartLine) + } + Anchor(hir::Anchor::EndLine) if self.compiled.is_reverse => { + self.byte_classes.set_range(b'\n', b'\n'); + self.c_empty_look(prog::EmptyLook::StartLine) + } + Anchor(hir::Anchor::EndLine) => { + self.byte_classes.set_range(b'\n', b'\n'); + self.c_empty_look(prog::EmptyLook::EndLine) + } + Anchor(hir::Anchor::StartText) if self.compiled.is_reverse => { + self.c_empty_look(prog::EmptyLook::EndText) + } + Anchor(hir::Anchor::StartText) => { + self.c_empty_look(prog::EmptyLook::StartText) + } + Anchor(hir::Anchor::EndText) if self.compiled.is_reverse => { + self.c_empty_look(prog::EmptyLook::StartText) + } + Anchor(hir::Anchor::EndText) => { + self.c_empty_look(prog::EmptyLook::EndText) + } + WordBoundary(hir::WordBoundary::Unicode) => { + if !cfg!(feature = "unicode-perl") { + return Err(Error::Syntax( + "Unicode word boundaries are unavailable when \ + the unicode-perl feature is disabled" + .to_string(), + )); + } + self.compiled.has_unicode_word_boundary = true; + self.byte_classes.set_word_boundary(); + self.c_empty_look(prog::EmptyLook::WordBoundary) + } + WordBoundary(hir::WordBoundary::UnicodeNegate) => { + if !cfg!(feature = "unicode-perl") { + return Err(Error::Syntax( + "Unicode word boundaries are unavailable when \ + the unicode-perl feature is disabled" + .to_string(), + )); + } + self.compiled.has_unicode_word_boundary = true; + self.byte_classes.set_word_boundary(); + self.c_empty_look(prog::EmptyLook::NotWordBoundary) + } + WordBoundary(hir::WordBoundary::Ascii) => { + self.byte_classes.set_word_boundary(); + self.c_empty_look(prog::EmptyLook::WordBoundaryAscii) + } + WordBoundary(hir::WordBoundary::AsciiNegate) => { + self.byte_classes.set_word_boundary(); + self.c_empty_look(prog::EmptyLook::NotWordBoundaryAscii) + } + Group(ref g) => match g.kind { + hir::GroupKind::NonCapturing => self.c(&g.hir), + hir::GroupKind::CaptureIndex(index) => { + if index as usize >= self.compiled.captures.len() { + self.compiled.captures.push(None); + } + self.c_capture(2 * index as usize, &g.hir) + } + hir::GroupKind::CaptureName { index, ref name } => { + if index as usize >= self.compiled.captures.len() { + let n = name.to_string(); + self.compiled.captures.push(Some(n.clone())); + self.capture_name_idx.insert(n, index as usize); + } + self.c_capture(2 * index as usize, &g.hir) + } + }, + Concat(ref es) => { + if self.compiled.is_reverse { + self.c_concat(es.iter().rev()) + } else { + self.c_concat(es) + } + } + Alternation(ref es) => self.c_alternate(&**es), + Repetition(ref rep) => self.c_repeat(rep), + } + } + + fn c_capture(&mut self, first_slot: usize, expr: &Hir) -> Result { + if self.num_exprs > 1 || self.compiled.is_dfa { + // Don't ever compile Save instructions for regex sets because + // they are never used. They are also never used in DFA programs + // because DFAs can't handle captures. + self.c(expr) + } else { + let entry = self.insts.len(); + let hole = self.push_hole(InstHole::Save { slot: first_slot }); + let patch = self.c(expr)?; + self.fill(hole, patch.entry); + self.fill_to_next(patch.hole); + let hole = self.push_hole(InstHole::Save { slot: first_slot + 1 }); + Ok(Patch { hole: hole, entry: entry }) + } + } + + fn c_dotstar(&mut self) -> Result { + Ok(if !self.compiled.only_utf8() { + self.c(&Hir::repetition(hir::Repetition { + kind: hir::RepetitionKind::ZeroOrMore, + greedy: false, + hir: Box::new(Hir::any(true)), + }))? + } else { + self.c(&Hir::repetition(hir::Repetition { + kind: hir::RepetitionKind::ZeroOrMore, + greedy: false, + hir: Box::new(Hir::any(false)), + }))? + }) + } + + fn c_char(&mut self, c: char) -> Result { + self.c_class(&[hir::ClassUnicodeRange::new(c, c)]) + } + + fn c_class(&mut self, ranges: &[hir::ClassUnicodeRange]) -> Result { + assert!(!ranges.is_empty()); + if self.compiled.uses_bytes() { + CompileClass { c: self, ranges: ranges }.compile() + } else { + let ranges: Vec<(char, char)> = + ranges.iter().map(|r| (r.start(), r.end())).collect(); + let hole = if ranges.len() == 1 && ranges[0].0 == ranges[0].1 { + self.push_hole(InstHole::Char { c: ranges[0].0 }) + } else { + self.push_hole(InstHole::Ranges { ranges: ranges }) + }; + Ok(Patch { hole: hole, entry: self.insts.len() - 1 }) + } + } + + fn c_byte(&mut self, b: u8) -> Result { + self.c_class_bytes(&[hir::ClassBytesRange::new(b, b)]) + } + + fn c_class_bytes(&mut self, ranges: &[hir::ClassBytesRange]) -> Result { + debug_assert!(!ranges.is_empty()); + + let first_split_entry = self.insts.len(); + let mut holes = vec![]; + let mut prev_hole = Hole::None; + for r in &ranges[0..ranges.len() - 1] { + self.fill_to_next(prev_hole); + let split = self.push_split_hole(); + let next = self.insts.len(); + self.byte_classes.set_range(r.start(), r.end()); + holes.push(self.push_hole(InstHole::Bytes { + start: r.start(), + end: r.end(), + })); + prev_hole = self.fill_split(split, Some(next), None); + } + let next = self.insts.len(); + let r = &ranges[ranges.len() - 1]; + self.byte_classes.set_range(r.start(), r.end()); + holes.push( + self.push_hole(InstHole::Bytes { start: r.start(), end: r.end() }), + ); + self.fill(prev_hole, next); + Ok(Patch { hole: Hole::Many(holes), entry: first_split_entry }) + } + + fn c_empty_look(&mut self, look: EmptyLook) -> Result { + let hole = self.push_hole(InstHole::EmptyLook { look: look }); + Ok(Patch { hole: hole, entry: self.insts.len() - 1 }) + } + + fn c_concat<'a, I>(&mut self, exprs: I) -> Result + where + I: IntoIterator, + { + let mut exprs = exprs.into_iter(); + let first = match exprs.next() { + Some(expr) => expr, + None => { + return Ok(Patch { hole: Hole::None, entry: self.insts.len() }) + } + }; + let Patch { mut hole, entry } = self.c(first)?; + for e in exprs { + let p = self.c(e)?; + self.fill(hole, p.entry); + hole = p.hole; + } + Ok(Patch { hole: hole, entry: entry }) + } + + fn c_alternate(&mut self, exprs: &[Hir]) -> Result { + debug_assert!( + exprs.len() >= 2, + "alternates must have at least 2 exprs" + ); + + // Initial entry point is always the first split. + let first_split_entry = self.insts.len(); + + // Save up all of the holes from each alternate. They will all get + // patched to point to the same location. + let mut holes = vec![]; + + let mut prev_hole = Hole::None; + for e in &exprs[0..exprs.len() - 1] { + self.fill_to_next(prev_hole); + let split = self.push_split_hole(); + let prev_entry = self.insts.len(); + let Patch { hole, entry } = self.c(e)?; + if prev_entry == self.insts.len() { + // TODO(burntsushi): It is kind of silly that we don't support + // empty-subexpressions in alternates, but it is supremely + // awkward to support them in the existing compiler + // infrastructure. This entire compiler needs to be thrown out + // anyway, so don't feel too bad. + return Err(Error::Syntax( + "alternations cannot currently contain \ + empty sub-expressions" + .to_string(), + )); + } + holes.push(hole); + prev_hole = self.fill_split(split, Some(entry), None); + } + let prev_entry = self.insts.len(); + let Patch { hole, entry } = self.c(&exprs[exprs.len() - 1])?; + if prev_entry == self.insts.len() { + // TODO(burntsushi): See TODO above. + return Err(Error::Syntax( + "alternations cannot currently contain \ + empty sub-expressions" + .to_string(), + )); + } + holes.push(hole); + self.fill(prev_hole, entry); + Ok(Patch { hole: Hole::Many(holes), entry: first_split_entry }) + } + + fn c_repeat(&mut self, rep: &hir::Repetition) -> Result { + use syntax::hir::RepetitionKind::*; + match rep.kind { + ZeroOrOne => self.c_repeat_zero_or_one(&rep.hir, rep.greedy), + ZeroOrMore => self.c_repeat_zero_or_more(&rep.hir, rep.greedy), + OneOrMore => self.c_repeat_one_or_more(&rep.hir, rep.greedy), + Range(hir::RepetitionRange::Exactly(min_max)) => { + self.c_repeat_range(&rep.hir, rep.greedy, min_max, min_max) + } + Range(hir::RepetitionRange::AtLeast(min)) => { + self.c_repeat_range_min_or_more(&rep.hir, rep.greedy, min) + } + Range(hir::RepetitionRange::Bounded(min, max)) => { + self.c_repeat_range(&rep.hir, rep.greedy, min, max) + } + } + } + + fn c_repeat_zero_or_one(&mut self, expr: &Hir, greedy: bool) -> Result { + let split_entry = self.insts.len(); + let split = self.push_split_hole(); + let Patch { hole: hole_rep, entry: entry_rep } = self.c(expr)?; + + let split_hole = if greedy { + self.fill_split(split, Some(entry_rep), None) + } else { + self.fill_split(split, None, Some(entry_rep)) + }; + let holes = vec![hole_rep, split_hole]; + Ok(Patch { hole: Hole::Many(holes), entry: split_entry }) + } + + fn c_repeat_zero_or_more(&mut self, expr: &Hir, greedy: bool) -> Result { + let split_entry = self.insts.len(); + let split = self.push_split_hole(); + let Patch { hole: hole_rep, entry: entry_rep } = self.c(expr)?; + + self.fill(hole_rep, split_entry); + let split_hole = if greedy { + self.fill_split(split, Some(entry_rep), None) + } else { + self.fill_split(split, None, Some(entry_rep)) + }; + Ok(Patch { hole: split_hole, entry: split_entry }) + } + + fn c_repeat_one_or_more(&mut self, expr: &Hir, greedy: bool) -> Result { + let Patch { hole: hole_rep, entry: entry_rep } = self.c(expr)?; + self.fill_to_next(hole_rep); + let split = self.push_split_hole(); + + let split_hole = if greedy { + self.fill_split(split, Some(entry_rep), None) + } else { + self.fill_split(split, None, Some(entry_rep)) + }; + Ok(Patch { hole: split_hole, entry: entry_rep }) + } + + fn c_repeat_range_min_or_more( + &mut self, + expr: &Hir, + greedy: bool, + min: u32, + ) -> Result { + let min = u32_to_usize(min); + let patch_concat = self.c_concat(iter::repeat(expr).take(min))?; + let patch_rep = self.c_repeat_zero_or_more(expr, greedy)?; + self.fill(patch_concat.hole, patch_rep.entry); + Ok(Patch { hole: patch_rep.hole, entry: patch_concat.entry }) + } + + fn c_repeat_range( + &mut self, + expr: &Hir, + greedy: bool, + min: u32, + max: u32, + ) -> Result { + let (min, max) = (u32_to_usize(min), u32_to_usize(max)); + let patch_concat = self.c_concat(iter::repeat(expr).take(min))?; + let initial_entry = patch_concat.entry; + if min == max { + return Ok(patch_concat); + } + // It is much simpler to compile, e.g., `a{2,5}` as: + // + // aaa?a?a? + // + // But you end up with a sequence of instructions like this: + // + // 0: 'a' + // 1: 'a', + // 2: split(3, 4) + // 3: 'a' + // 4: split(5, 6) + // 5: 'a' + // 6: split(7, 8) + // 7: 'a' + // 8: MATCH + // + // This is *incredibly* inefficient because the splits end + // up forming a chain, which has to be resolved everything a + // transition is followed. + let mut holes = vec![]; + let mut prev_hole = patch_concat.hole; + for _ in min..max { + self.fill_to_next(prev_hole); + let split = self.push_split_hole(); + let Patch { hole, entry } = self.c(expr)?; + prev_hole = hole; + if greedy { + holes.push(self.fill_split(split, Some(entry), None)); + } else { + holes.push(self.fill_split(split, None, Some(entry))); + } + } + holes.push(prev_hole); + Ok(Patch { hole: Hole::Many(holes), entry: initial_entry }) + } + + fn fill(&mut self, hole: Hole, goto: InstPtr) { + match hole { + Hole::None => {} + Hole::One(pc) => { + self.insts[pc].fill(goto); + } + Hole::Many(holes) => { + for hole in holes { + self.fill(hole, goto); + } + } + } + } + + fn fill_to_next(&mut self, hole: Hole) { + let next = self.insts.len(); + self.fill(hole, next); + } + + fn fill_split( + &mut self, + hole: Hole, + goto1: Option, + goto2: Option, + ) -> Hole { + match hole { + Hole::None => Hole::None, + Hole::One(pc) => match (goto1, goto2) { + (Some(goto1), Some(goto2)) => { + self.insts[pc].fill_split(goto1, goto2); + Hole::None + } + (Some(goto1), None) => { + self.insts[pc].half_fill_split_goto1(goto1); + Hole::One(pc) + } + (None, Some(goto2)) => { + self.insts[pc].half_fill_split_goto2(goto2); + Hole::One(pc) + } + (None, None) => unreachable!( + "at least one of the split \ + holes must be filled" + ), + }, + Hole::Many(holes) => { + let mut new_holes = vec![]; + for hole in holes { + new_holes.push(self.fill_split(hole, goto1, goto2)); + } + if new_holes.is_empty() { + Hole::None + } else if new_holes.len() == 1 { + new_holes.pop().unwrap() + } else { + Hole::Many(new_holes) + } + } + } + } + + fn push_compiled(&mut self, inst: Inst) { + self.insts.push(MaybeInst::Compiled(inst)); + } + + fn push_hole(&mut self, inst: InstHole) -> Hole { + let hole = self.insts.len(); + self.insts.push(MaybeInst::Uncompiled(inst)); + Hole::One(hole) + } + + fn push_split_hole(&mut self) -> Hole { + let hole = self.insts.len(); + self.insts.push(MaybeInst::Split); + Hole::One(hole) + } + + fn check_size(&self) -> result::Result<(), Error> { + use std::mem::size_of; + + if self.insts.len() * size_of::() > self.size_limit { + Err(Error::CompiledTooBig(self.size_limit)) + } else { + Ok(()) + } + } +} + +#[derive(Debug)] +enum Hole { + None, + One(InstPtr), + Many(Vec), +} + +#[derive(Clone, Debug)] +enum MaybeInst { + Compiled(Inst), + Uncompiled(InstHole), + Split, + Split1(InstPtr), + Split2(InstPtr), +} + +impl MaybeInst { + fn fill(&mut self, goto: InstPtr) { + let filled = match *self { + MaybeInst::Uncompiled(ref inst) => inst.fill(goto), + MaybeInst::Split1(goto1) => { + Inst::Split(InstSplit { goto1: goto1, goto2: goto }) + } + MaybeInst::Split2(goto2) => { + Inst::Split(InstSplit { goto1: goto, goto2: goto2 }) + } + _ => unreachable!( + "not all instructions were compiled! \ + found uncompiled instruction: {:?}", + self + ), + }; + *self = MaybeInst::Compiled(filled); + } + + fn fill_split(&mut self, goto1: InstPtr, goto2: InstPtr) { + let filled = match *self { + MaybeInst::Split => { + Inst::Split(InstSplit { goto1: goto1, goto2: goto2 }) + } + _ => unreachable!( + "must be called on Split instruction, \ + instead it was called on: {:?}", + self + ), + }; + *self = MaybeInst::Compiled(filled); + } + + fn half_fill_split_goto1(&mut self, goto1: InstPtr) { + let half_filled = match *self { + MaybeInst::Split => goto1, + _ => unreachable!( + "must be called on Split instruction, \ + instead it was called on: {:?}", + self + ), + }; + *self = MaybeInst::Split1(half_filled); + } + + fn half_fill_split_goto2(&mut self, goto2: InstPtr) { + let half_filled = match *self { + MaybeInst::Split => goto2, + _ => unreachable!( + "must be called on Split instruction, \ + instead it was called on: {:?}", + self + ), + }; + *self = MaybeInst::Split2(half_filled); + } + + fn unwrap(self) -> Inst { + match self { + MaybeInst::Compiled(inst) => inst, + _ => unreachable!( + "must be called on a compiled instruction, \ + instead it was called on: {:?}", + self + ), + } + } +} + +#[derive(Clone, Debug)] +enum InstHole { + Save { slot: usize }, + EmptyLook { look: EmptyLook }, + Char { c: char }, + Ranges { ranges: Vec<(char, char)> }, + Bytes { start: u8, end: u8 }, +} + +impl InstHole { + fn fill(&self, goto: InstPtr) -> Inst { + match *self { + InstHole::Save { slot } => { + Inst::Save(InstSave { goto: goto, slot: slot }) + } + InstHole::EmptyLook { look } => { + Inst::EmptyLook(InstEmptyLook { goto: goto, look: look }) + } + InstHole::Char { c } => Inst::Char(InstChar { goto: goto, c: c }), + InstHole::Ranges { ref ranges } => { + Inst::Ranges(InstRanges { goto: goto, ranges: ranges.clone() }) + } + InstHole::Bytes { start, end } => { + Inst::Bytes(InstBytes { goto: goto, start: start, end: end }) + } + } + } +} + +struct CompileClass<'a, 'b> { + c: &'a mut Compiler, + ranges: &'b [hir::ClassUnicodeRange], +} + +impl<'a, 'b> CompileClass<'a, 'b> { + fn compile(mut self) -> Result { + let mut holes = vec![]; + let mut initial_entry = None; + let mut last_split = Hole::None; + let mut utf8_seqs = self.c.utf8_seqs.take().unwrap(); + self.c.suffix_cache.clear(); + + for (i, range) in self.ranges.iter().enumerate() { + let is_last_range = i + 1 == self.ranges.len(); + utf8_seqs.reset(range.start(), range.end()); + let mut it = (&mut utf8_seqs).peekable(); + loop { + let utf8_seq = match it.next() { + None => break, + Some(utf8_seq) => utf8_seq, + }; + if is_last_range && it.peek().is_none() { + let Patch { hole, entry } = self.c_utf8_seq(&utf8_seq)?; + holes.push(hole); + self.c.fill(last_split, entry); + last_split = Hole::None; + if initial_entry.is_none() { + initial_entry = Some(entry); + } + } else { + if initial_entry.is_none() { + initial_entry = Some(self.c.insts.len()); + } + self.c.fill_to_next(last_split); + last_split = self.c.push_split_hole(); + let Patch { hole, entry } = self.c_utf8_seq(&utf8_seq)?; + holes.push(hole); + last_split = + self.c.fill_split(last_split, Some(entry), None); + } + } + } + self.c.utf8_seqs = Some(utf8_seqs); + Ok(Patch { hole: Hole::Many(holes), entry: initial_entry.unwrap() }) + } + + fn c_utf8_seq(&mut self, seq: &Utf8Sequence) -> Result { + if self.c.compiled.is_reverse { + self.c_utf8_seq_(seq) + } else { + self.c_utf8_seq_(seq.into_iter().rev()) + } + } + + fn c_utf8_seq_<'r, I>(&mut self, seq: I) -> Result + where + I: IntoIterator, + { + // The initial instruction for each UTF-8 sequence should be the same. + let mut from_inst = ::std::usize::MAX; + let mut last_hole = Hole::None; + for byte_range in seq { + let key = SuffixCacheKey { + from_inst: from_inst, + start: byte_range.start, + end: byte_range.end, + }; + { + let pc = self.c.insts.len(); + if let Some(cached_pc) = self.c.suffix_cache.get(key, pc) { + from_inst = cached_pc; + continue; + } + } + self.c.byte_classes.set_range(byte_range.start, byte_range.end); + if from_inst == ::std::usize::MAX { + last_hole = self.c.push_hole(InstHole::Bytes { + start: byte_range.start, + end: byte_range.end, + }); + } else { + self.c.push_compiled(Inst::Bytes(InstBytes { + goto: from_inst, + start: byte_range.start, + end: byte_range.end, + })); + } + from_inst = self.c.insts.len().checked_sub(1).unwrap(); + debug_assert!(from_inst < ::std::usize::MAX); + } + debug_assert!(from_inst < ::std::usize::MAX); + Ok(Patch { hole: last_hole, entry: from_inst }) + } +} + +/// `SuffixCache` is a simple bounded hash map for caching suffix entries in +/// UTF-8 automata. For example, consider the Unicode range \u{0}-\u{FFFF}. +/// The set of byte ranges looks like this: +/// +/// [0-7F] +/// [C2-DF][80-BF] +/// [E0][A0-BF][80-BF] +/// [E1-EC][80-BF][80-BF] +/// [ED][80-9F][80-BF] +/// [EE-EF][80-BF][80-BF] +/// +/// Each line above translates to one alternate in the compiled regex program. +/// However, all but one of the alternates end in the same suffix, which is +/// a waste of an instruction. The suffix cache facilitates reusing them across +/// alternates. +/// +/// Note that a HashMap could be trivially used for this, but we don't need its +/// overhead. Some small bounded space (LRU style) is more than enough. +/// +/// This uses similar idea to [`SparseSet`](../sparse/struct.SparseSet.html), +/// except it uses hashes as original indices and then compares full keys for +/// validation against `dense` array. +struct SuffixCache { + sparse: Box<[usize]>, + dense: Vec, +} + +#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)] +struct SuffixCacheEntry { + key: SuffixCacheKey, + pc: InstPtr, +} + +#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)] +struct SuffixCacheKey { + from_inst: InstPtr, + start: u8, + end: u8, +} + +impl SuffixCache { + fn new(size: usize) -> Self { + SuffixCache { + sparse: vec![0usize; size].into(), + dense: Vec::with_capacity(size), + } + } + + fn get(&mut self, key: SuffixCacheKey, pc: InstPtr) -> Option { + let hash = self.hash(&key); + let pos = &mut self.sparse[hash]; + if let Some(entry) = self.dense.get(*pos) { + if entry.key == key { + return Some(entry.pc); + } + } + *pos = self.dense.len(); + self.dense.push(SuffixCacheEntry { key: key, pc: pc }); + None + } + + fn clear(&mut self) { + self.dense.clear(); + } + + fn hash(&self, suffix: &SuffixCacheKey) -> usize { + // Basic FNV-1a hash as described: + // https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function + const FNV_PRIME: u64 = 1099511628211; + let mut h = 14695981039346656037; + h = (h ^ (suffix.from_inst as u64)).wrapping_mul(FNV_PRIME); + h = (h ^ (suffix.start as u64)).wrapping_mul(FNV_PRIME); + h = (h ^ (suffix.end as u64)).wrapping_mul(FNV_PRIME); + (h as usize) % self.sparse.len() + } +} + +struct ByteClassSet([bool; 256]); + +impl ByteClassSet { + fn new() -> Self { + ByteClassSet([false; 256]) + } + + fn set_range(&mut self, start: u8, end: u8) { + debug_assert!(start <= end); + if start > 0 { + self.0[start as usize - 1] = true; + } + self.0[end as usize] = true; + } + + fn set_word_boundary(&mut self) { + // We need to mark all ranges of bytes whose pairs result in + // evaluating \b differently. + let iswb = is_word_byte; + let mut b1: u16 = 0; + let mut b2: u16; + while b1 <= 255 { + b2 = b1 + 1; + while b2 <= 255 && iswb(b1 as u8) == iswb(b2 as u8) { + b2 += 1; + } + self.set_range(b1 as u8, (b2 - 1) as u8); + b1 = b2; + } + } + + fn byte_classes(&self) -> Vec { + // N.B. If you're debugging the DFA, it's useful to simply return + // `(0..256).collect()`, which effectively removes the byte classes + // and makes the transitions easier to read. + // (0usize..256).map(|x| x as u8).collect() + let mut byte_classes = vec![0; 256]; + let mut class = 0u8; + let mut i = 0; + loop { + byte_classes[i] = class as u8; + if i >= 255 { + break; + } + if self.0[i] { + class = class.checked_add(1).unwrap(); + } + i += 1; + } + byte_classes + } +} + +fn u32_to_usize(n: u32) -> usize { + // In case usize is less than 32 bits, we need to guard against overflow. + // On most platforms this compiles to nothing. + // TODO Use `std::convert::TryFrom` once it's stable. + if (n as u64) > (::std::usize::MAX as u64) { + panic!("BUG: {} is too big to be pointer sized", n) + } + n as usize +} + +#[cfg(test)] +mod tests { + use super::ByteClassSet; + + #[test] + fn byte_classes() { + let mut set = ByteClassSet::new(); + set.set_range(b'a', b'z'); + let classes = set.byte_classes(); + assert_eq!(classes[0], 0); + assert_eq!(classes[1], 0); + assert_eq!(classes[2], 0); + assert_eq!(classes[b'a' as usize - 1], 0); + assert_eq!(classes[b'a' as usize], 1); + assert_eq!(classes[b'm' as usize], 1); + assert_eq!(classes[b'z' as usize], 1); + assert_eq!(classes[b'z' as usize + 1], 2); + assert_eq!(classes[254], 2); + assert_eq!(classes[255], 2); + + let mut set = ByteClassSet::new(); + set.set_range(0, 2); + set.set_range(4, 6); + let classes = set.byte_classes(); + assert_eq!(classes[0], 0); + assert_eq!(classes[1], 0); + assert_eq!(classes[2], 0); + assert_eq!(classes[3], 1); + assert_eq!(classes[4], 2); + assert_eq!(classes[5], 2); + assert_eq!(classes[6], 2); + assert_eq!(classes[7], 3); + assert_eq!(classes[255], 3); + } + + #[test] + fn full_byte_classes() { + let mut set = ByteClassSet::new(); + for i in 0..256u16 { + set.set_range(i as u8, i as u8); + } + assert_eq!(set.byte_classes().len(), 256); + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/dfa.rs b/third_party/cargo/vendor/regex-1.3.3/src/dfa.rs new file mode 100644 index 0000000..decc3b9 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/dfa.rs @@ -0,0 +1,1942 @@ +/*! +The DFA matching engine. + +A DFA provides faster matching because the engine is in exactly one state at +any point in time. In the NFA, there may be multiple active states, and +considerable CPU cycles are spent shuffling them around. In finite automata +speak, the DFA follows epsilon transitions in the regex far less than the NFA. + +A DFA is a classic trade off between time and space. The NFA is slower, but +its memory requirements are typically small and predictable. The DFA is faster, +but given the right regex and the right input, the number of states in the +DFA can grow exponentially. To mitigate this space problem, we do two things: + +1. We implement an *online* DFA. That is, the DFA is constructed from the NFA + during a search. When a new state is computed, it is stored in a cache so + that it may be reused. An important consequence of this implementation + is that states that are never reached for a particular input are never + computed. (This is impossible in an "offline" DFA which needs to compute + all possible states up front.) +2. If the cache gets too big, we wipe it and continue matching. + +In pathological cases, a new state can be created for every byte of input. +(e.g., The regex `(a|b)*a(a|b){20}` on a long sequence of a's and b's.) +In this case, performance regresses to slightly slower than the full NFA +simulation, in large part because the cache becomes useless. If the cache +is wiped too frequently, the DFA quits and control falls back to one of the +NFA simulations. + +Because of the "lazy" nature of this DFA, the inner matching loop is +considerably more complex than one might expect out of a DFA. A number of +tricks are employed to make it fast. Tread carefully. + +N.B. While this implementation is heavily commented, Russ Cox's series of +articles on regexes is strongly recommended: https://swtch.com/~rsc/regexp/ +(As is the DFA implementation in RE2, which heavily influenced this +implementation.) +*/ + +use std::collections::HashMap; +use std::fmt; +use std::iter::repeat; +use std::mem; +use std::sync::Arc; + +use exec::ProgramCache; +use prog::{Inst, Program}; +use sparse::SparseSet; + +/// Return true if and only if the given program can be executed by a DFA. +/// +/// Generally, a DFA is always possible. A pathological case where it is not +/// possible is if the number of NFA states exceeds `u32::MAX`, in which case, +/// this function will return false. +/// +/// This function will also return false if the given program has any Unicode +/// instructions (Char or Ranges) since the DFA operates on bytes only. +pub fn can_exec(insts: &Program) -> bool { + use prog::Inst::*; + // If for some reason we manage to allocate a regex program with more + // than i32::MAX instructions, then we can't execute the DFA because we + // use 32 bit instruction pointer deltas for memory savings. + // If i32::MAX is the largest positive delta, + // then -i32::MAX == i32::MIN + 1 is the largest negative delta, + // and we are OK to use 32 bits. + if insts.dfa_size_limit == 0 || insts.len() > ::std::i32::MAX as usize { + return false; + } + for inst in insts { + match *inst { + Char(_) | Ranges(_) => return false, + EmptyLook(_) | Match(_) | Save(_) | Split(_) | Bytes(_) => {} + } + } + true +} + +/// A reusable cache of DFA states. +/// +/// This cache is reused between multiple invocations of the same regex +/// program. (It is not shared simultaneously between threads. If there is +/// contention, then new caches are created.) +#[derive(Debug)] +pub struct Cache { + /// Group persistent DFA related cache state together. The sparse sets + /// listed below are used as scratch space while computing uncached states. + inner: CacheInner, + /// qcur and qnext are ordered sets with constant time + /// addition/membership/clearing-whole-set and linear time iteration. They + /// are used to manage the sets of NFA states in DFA states when computing + /// cached DFA states. In particular, the order of the NFA states matters + /// for leftmost-first style matching. Namely, when computing a cached + /// state, the set of NFA states stops growing as soon as the first Match + /// instruction is observed. + qcur: SparseSet, + qnext: SparseSet, +} + +/// `CacheInner` is logically just a part of Cache, but groups together fields +/// that aren't passed as function parameters throughout search. (This split +/// is mostly an artifact of the borrow checker. It is happily paid.) +#[derive(Debug)] +struct CacheInner { + /// A cache of pre-compiled DFA states, keyed by the set of NFA states + /// and the set of empty-width flags set at the byte in the input when the + /// state was observed. + /// + /// A StatePtr is effectively a `*State`, but to avoid various inconvenient + /// things, we just pass indexes around manually. The performance impact of + /// this is probably an instruction or two in the inner loop. However, on + /// 64 bit, each StatePtr is half the size of a *State. + compiled: StateMap, + /// The transition table. + /// + /// The transition table is laid out in row-major order, where states are + /// rows and the transitions for each state are columns. At a high level, + /// given state `s` and byte `b`, the next state can be found at index + /// `s * 256 + b`. + /// + /// This is, of course, a lie. A StatePtr is actually a pointer to the + /// *start* of a row in this table. When indexing in the DFA's inner loop, + /// this removes the need to multiply the StatePtr by the stride. Yes, it + /// matters. This reduces the number of states we can store, but: the + /// stride is rarely 256 since we define transitions in terms of + /// *equivalence classes* of bytes. Each class corresponds to a set of + /// bytes that never discriminate a distinct path through the DFA from each + /// other. + trans: Transitions, + /// A set of cached start states, which are limited to the number of + /// permutations of flags set just before the initial byte of input. (The + /// index into this vec is a `EmptyFlags`.) + /// + /// N.B. A start state can be "dead" (i.e., no possible match), so we + /// represent it with a StatePtr. + start_states: Vec, + /// Stack scratch space used to follow epsilon transitions in the NFA. + /// (This permits us to avoid recursion.) + /// + /// The maximum stack size is the number of NFA states. + stack: Vec, + /// The total number of times this cache has been flushed by the DFA + /// because of space constraints. + flush_count: u64, + /// The total heap size of the DFA's cache. We use this to determine when + /// we should flush the cache. + size: usize, + /// Scratch space used when building instruction pointer lists for new + /// states. This helps amortize allocation. + insts_scratch_space: Vec, +} + +/// The transition table. +/// +/// It is laid out in row-major order, with states as rows and byte class +/// transitions as columns. +/// +/// The transition table is responsible for producing valid `StatePtrs`. A +/// `StatePtr` points to the start of a particular row in this table. When +/// indexing to find the next state this allows us to avoid a multiplication +/// when computing an index into the table. +#[derive(Clone)] +struct Transitions { + /// The table. + table: Vec, + /// The stride. + num_byte_classes: usize, +} + +/// Fsm encapsulates the actual execution of the DFA. +#[derive(Debug)] +pub struct Fsm<'a> { + /// prog contains the NFA instruction opcodes. DFA execution uses either + /// the `dfa` instructions or the `dfa_reverse` instructions from + /// `exec::ExecReadOnly`. (It never uses `ExecReadOnly.nfa`, which may have + /// Unicode opcodes that cannot be executed by the DFA.) + prog: &'a Program, + /// The start state. We record it here because the pointer may change + /// when the cache is wiped. + start: StatePtr, + /// The current position in the input. + at: usize, + /// Should we quit after seeing the first match? e.g., When the caller + /// uses `is_match` or `shortest_match`. + quit_after_match: bool, + /// The last state that matched. + /// + /// When no match has occurred, this is set to STATE_UNKNOWN. + /// + /// This is only useful when matching regex sets. The last match state + /// is useful because it contains all of the match instructions seen, + /// thereby allowing us to enumerate which regexes in the set matched. + last_match_si: StatePtr, + /// The input position of the last cache flush. We use this to determine + /// if we're thrashing in the cache too often. If so, the DFA quits so + /// that we can fall back to the NFA algorithm. + last_cache_flush: usize, + /// All cached DFA information that is persisted between searches. + cache: &'a mut CacheInner, +} + +/// The result of running the DFA. +/// +/// Generally, the result is either a match or not a match, but sometimes the +/// DFA runs too slowly because the cache size is too small. In that case, it +/// gives up with the intent of falling back to the NFA algorithm. +/// +/// The DFA can also give up if it runs out of room to create new states, or if +/// it sees non-ASCII bytes in the presence of a Unicode word boundary. +#[derive(Clone, Debug)] +pub enum Result { + Match(T), + NoMatch(usize), + Quit, +} + +impl Result { + /// Returns true if this result corresponds to a match. + pub fn is_match(&self) -> bool { + match *self { + Result::Match(_) => true, + Result::NoMatch(_) | Result::Quit => false, + } + } + + /// Maps the given function onto T and returns the result. + /// + /// If this isn't a match, then this is a no-op. + #[cfg(feature = "perf-literal")] + pub fn map U>(self, mut f: F) -> Result { + match self { + Result::Match(t) => Result::Match(f(t)), + Result::NoMatch(x) => Result::NoMatch(x), + Result::Quit => Result::Quit, + } + } + + /// Sets the non-match position. + /// + /// If this isn't a non-match, then this is a no-op. + fn set_non_match(self, at: usize) -> Result { + match self { + Result::NoMatch(_) => Result::NoMatch(at), + r => r, + } + } +} + +/// `State` is a DFA state. It contains an ordered set of NFA states (not +/// necessarily complete) and a smattering of flags. +/// +/// The flags are packed into the first byte of data. +/// +/// States don't carry their transitions. Instead, transitions are stored in +/// a single row-major table. +/// +/// Delta encoding is used to store the instruction pointers. +/// The first instruction pointer is stored directly starting +/// at data[1], and each following pointer is stored as an offset +/// to the previous one. If a delta is in the range -127..127, +/// it is packed into a single byte; Otherwise the byte 128 (-128 as an i8) +/// is coded as a flag, followed by 4 bytes encoding the delta. +#[derive(Clone, Eq, Hash, PartialEq)] +struct State { + data: Arc<[u8]>, +} + +/// `InstPtr` is a 32 bit pointer into a sequence of opcodes (i.e., it indexes +/// an NFA state). +/// +/// Throughout this library, this is usually set to `usize`, but we force a +/// `u32` here for the DFA to save on space. +type InstPtr = u32; + +/// Adds ip to data using delta encoding with respect to prev. +/// +/// After completion, `data` will contain `ip` and `prev` will be set to `ip`. +fn push_inst_ptr(data: &mut Vec, prev: &mut InstPtr, ip: InstPtr) { + let delta = (ip as i32) - (*prev as i32); + write_vari32(data, delta); + *prev = ip; +} + +struct InstPtrs<'a> { + base: usize, + data: &'a [u8], +} + +impl<'a> Iterator for InstPtrs<'a> { + type Item = usize; + + fn next(&mut self) -> Option { + if self.data.is_empty() { + return None; + } + let (delta, nread) = read_vari32(self.data); + let base = self.base as i32 + delta; + debug_assert!(base >= 0); + debug_assert!(nread > 0); + self.data = &self.data[nread..]; + self.base = base as usize; + Some(self.base) + } +} + +impl State { + fn flags(&self) -> StateFlags { + StateFlags(self.data[0]) + } + + fn inst_ptrs(&self) -> InstPtrs { + InstPtrs { base: 0, data: &self.data[1..] } + } +} + +/// `StatePtr` is a 32 bit pointer to the start of a row in the transition +/// table. +/// +/// It has many special values. There are two types of special values: +/// sentinels and flags. +/// +/// Sentinels corresponds to special states that carry some kind of +/// significance. There are three such states: unknown, dead and quit states. +/// +/// Unknown states are states that haven't been computed yet. They indicate +/// that a transition should be filled in that points to either an existing +/// cached state or a new state altogether. In general, an unknown state means +/// "follow the NFA's epsilon transitions." +/// +/// Dead states are states that can never lead to a match, no matter what +/// subsequent input is observed. This means that the DFA should quit +/// immediately and return the longest match it has found thus far. +/// +/// Quit states are states that imply the DFA is not capable of matching the +/// regex correctly. Currently, this is only used when a Unicode word boundary +/// exists in the regex *and* a non-ASCII byte is observed. +/// +/// The other type of state pointer is a state pointer with special flag bits. +/// There are two flags: a start flag and a match flag. The lower bits of both +/// kinds always contain a "valid" `StatePtr` (indicated by the `STATE_MAX` +/// mask). +/// +/// The start flag means that the state is a start state, and therefore may be +/// subject to special prefix scanning optimizations. +/// +/// The match flag means that the state is a match state, and therefore the +/// current position in the input (while searching) should be recorded. +/// +/// The above exists mostly in the service of making the inner loop fast. +/// In particular, the inner *inner* loop looks something like this: +/// +/// ```ignore +/// while state <= STATE_MAX and i < len(text): +/// state = state.next[i] +/// ``` +/// +/// This is nice because it lets us execute a lazy DFA as if it were an +/// entirely offline DFA (i.e., with very few instructions). The loop will +/// quit only when we need to examine a case that needs special attention. +type StatePtr = u32; + +/// An unknown state means that the state has not been computed yet, and that +/// the only way to progress is to compute it. +const STATE_UNKNOWN: StatePtr = 1 << 31; + +/// A dead state means that the state has been computed and it is known that +/// once it is entered, no future match can ever occur. +const STATE_DEAD: StatePtr = STATE_UNKNOWN + 1; + +/// A quit state means that the DFA came across some input that it doesn't +/// know how to process correctly. The DFA should quit and another matching +/// engine should be run in its place. +const STATE_QUIT: StatePtr = STATE_DEAD + 1; + +/// A start state is a state that the DFA can start in. +/// +/// Note that start states have their lower bits set to a state pointer. +const STATE_START: StatePtr = 1 << 30; + +/// A match state means that the regex has successfully matched. +/// +/// Note that match states have their lower bits set to a state pointer. +const STATE_MATCH: StatePtr = 1 << 29; + +/// The maximum state pointer. This is useful to mask out the "valid" state +/// pointer from a state with the "start" or "match" bits set. +/// +/// It doesn't make sense to use this with unknown, dead or quit state +/// pointers, since those pointers are sentinels and never have their lower +/// bits set to anything meaningful. +const STATE_MAX: StatePtr = STATE_MATCH - 1; + +/// Byte is a u8 in spirit, but a u16 in practice so that we can represent the +/// special EOF sentinel value. +#[derive(Copy, Clone, Debug)] +struct Byte(u16); + +/// A set of flags for zero-width assertions. +#[derive(Clone, Copy, Eq, Debug, Default, Hash, PartialEq)] +struct EmptyFlags { + start: bool, + end: bool, + start_line: bool, + end_line: bool, + word_boundary: bool, + not_word_boundary: bool, +} + +/// A set of flags describing various configurations of a DFA state. This is +/// represented by a `u8` so that it is compact. +#[derive(Clone, Copy, Eq, Default, Hash, PartialEq)] +struct StateFlags(u8); + +impl Cache { + /// Create new empty cache for the DFA engine. + pub fn new(prog: &Program) -> Self { + // We add 1 to account for the special EOF byte. + let num_byte_classes = (prog.byte_classes[255] as usize + 1) + 1; + let starts = vec![STATE_UNKNOWN; 256]; + let mut cache = Cache { + inner: CacheInner { + compiled: StateMap::new(num_byte_classes), + trans: Transitions::new(num_byte_classes), + start_states: starts, + stack: vec![], + flush_count: 0, + size: 0, + insts_scratch_space: vec![], + }, + qcur: SparseSet::new(prog.insts.len()), + qnext: SparseSet::new(prog.insts.len()), + }; + cache.inner.reset_size(); + cache + } +} + +impl CacheInner { + /// Resets the cache size to account for fixed costs, such as the program + /// and stack sizes. + fn reset_size(&mut self) { + self.size = (self.start_states.len() * mem::size_of::()) + + (self.stack.len() * mem::size_of::()); + } +} + +impl<'a> Fsm<'a> { + #[cfg_attr(feature = "perf-inline", inline(always))] + pub fn forward( + prog: &'a Program, + cache: &ProgramCache, + quit_after_match: bool, + text: &[u8], + at: usize, + ) -> Result { + let mut cache = cache.borrow_mut(); + let cache = &mut cache.dfa; + let mut dfa = Fsm { + prog: prog, + start: 0, // filled in below + at: at, + quit_after_match: quit_after_match, + last_match_si: STATE_UNKNOWN, + last_cache_flush: at, + cache: &mut cache.inner, + }; + let (empty_flags, state_flags) = dfa.start_flags(text, at); + dfa.start = + match dfa.start_state(&mut cache.qcur, empty_flags, state_flags) { + None => return Result::Quit, + Some(STATE_DEAD) => return Result::NoMatch(at), + Some(si) => si, + }; + debug_assert!(dfa.start != STATE_UNKNOWN); + dfa.exec_at(&mut cache.qcur, &mut cache.qnext, text) + } + + #[cfg_attr(feature = "perf-inline", inline(always))] + pub fn reverse( + prog: &'a Program, + cache: &ProgramCache, + quit_after_match: bool, + text: &[u8], + at: usize, + ) -> Result { + let mut cache = cache.borrow_mut(); + let cache = &mut cache.dfa_reverse; + let mut dfa = Fsm { + prog: prog, + start: 0, // filled in below + at: at, + quit_after_match: quit_after_match, + last_match_si: STATE_UNKNOWN, + last_cache_flush: at, + cache: &mut cache.inner, + }; + let (empty_flags, state_flags) = dfa.start_flags_reverse(text, at); + dfa.start = + match dfa.start_state(&mut cache.qcur, empty_flags, state_flags) { + None => return Result::Quit, + Some(STATE_DEAD) => return Result::NoMatch(at), + Some(si) => si, + }; + debug_assert!(dfa.start != STATE_UNKNOWN); + dfa.exec_at_reverse(&mut cache.qcur, &mut cache.qnext, text) + } + + #[cfg_attr(feature = "perf-inline", inline(always))] + pub fn forward_many( + prog: &'a Program, + cache: &ProgramCache, + matches: &mut [bool], + text: &[u8], + at: usize, + ) -> Result { + debug_assert!(matches.len() == prog.matches.len()); + let mut cache = cache.borrow_mut(); + let cache = &mut cache.dfa; + let mut dfa = Fsm { + prog: prog, + start: 0, // filled in below + at: at, + quit_after_match: false, + last_match_si: STATE_UNKNOWN, + last_cache_flush: at, + cache: &mut cache.inner, + }; + let (empty_flags, state_flags) = dfa.start_flags(text, at); + dfa.start = + match dfa.start_state(&mut cache.qcur, empty_flags, state_flags) { + None => return Result::Quit, + Some(STATE_DEAD) => return Result::NoMatch(at), + Some(si) => si, + }; + debug_assert!(dfa.start != STATE_UNKNOWN); + let result = dfa.exec_at(&mut cache.qcur, &mut cache.qnext, text); + if result.is_match() { + if matches.len() == 1 { + matches[0] = true; + } else { + debug_assert!(dfa.last_match_si != STATE_UNKNOWN); + debug_assert!(dfa.last_match_si != STATE_DEAD); + for ip in dfa.state(dfa.last_match_si).inst_ptrs() { + if let Inst::Match(slot) = dfa.prog[ip] { + matches[slot] = true; + } + } + } + } + result + } + + /// Executes the DFA on a forward NFA. + /// + /// {qcur,qnext} are scratch ordered sets which may be non-empty. + #[cfg_attr(feature = "perf-inline", inline(always))] + fn exec_at( + &mut self, + qcur: &mut SparseSet, + qnext: &mut SparseSet, + text: &[u8], + ) -> Result { + // For the most part, the DFA is basically: + // + // last_match = null + // while current_byte != EOF: + // si = current_state.next[current_byte] + // if si is match + // last_match = si + // return last_match + // + // However, we need to deal with a few things: + // + // 1. This is an *online* DFA, so the current state's next list + // may not point to anywhere yet, so we must go out and compute + // them. (They are then cached into the current state's next list + // to avoid re-computation.) + // 2. If we come across a state that is known to be dead (i.e., never + // leads to a match), then we can quit early. + // 3. If the caller just wants to know if a match occurs, then we + // can quit as soon as we know we have a match. (Full leftmost + // first semantics require continuing on.) + // 4. If we're in the start state, then we can use a pre-computed set + // of prefix literals to skip quickly along the input. + // 5. After the input is exhausted, we run the DFA on one symbol + // that stands for EOF. This is useful for handling empty width + // assertions. + // 6. We can't actually do state.next[byte]. Instead, we have to do + // state.next[byte_classes[byte]], which permits us to keep the + // 'next' list very small. + // + // Since there's a bunch of extra stuff we need to consider, we do some + // pretty hairy tricks to get the inner loop to run as fast as + // possible. + debug_assert!(!self.prog.is_reverse); + + // The last match is the currently known ending match position. It is + // reported as an index to the most recent byte that resulted in a + // transition to a match state and is always stored in capture slot `1` + // when searching forwards. Its maximum value is `text.len()`. + let mut result = Result::NoMatch(self.at); + let (mut prev_si, mut next_si) = (self.start, self.start); + let mut at = self.at; + while at < text.len() { + // This is the real inner loop. We take advantage of special bits + // set in the state pointer to determine whether a state is in the + // "common" case or not. Specifically, the common case is a + // non-match non-start non-dead state that has already been + // computed. So long as we remain in the common case, this inner + // loop will chew through the input. + // + // We also unroll the loop 4 times to amortize the cost of checking + // whether we've consumed the entire input. We are also careful + // to make sure that `prev_si` always represents the previous state + // and `next_si` always represents the next state after the loop + // exits, even if it isn't always true inside the loop. + while next_si <= STATE_MAX && at < text.len() { + // Argument for safety is in the definition of next_si. + prev_si = unsafe { self.next_si(next_si, text, at) }; + at += 1; + if prev_si > STATE_MAX || at + 2 >= text.len() { + mem::swap(&mut prev_si, &mut next_si); + break; + } + next_si = unsafe { self.next_si(prev_si, text, at) }; + at += 1; + if next_si > STATE_MAX { + break; + } + prev_si = unsafe { self.next_si(next_si, text, at) }; + at += 1; + if prev_si > STATE_MAX { + mem::swap(&mut prev_si, &mut next_si); + break; + } + next_si = unsafe { self.next_si(prev_si, text, at) }; + at += 1; + } + if next_si & STATE_MATCH > 0 { + // A match state is outside of the common case because it needs + // special case analysis. In particular, we need to record the + // last position as having matched and possibly quit the DFA if + // we don't need to keep matching. + next_si &= !STATE_MATCH; + result = Result::Match(at - 1); + if self.quit_after_match { + return result; + } + self.last_match_si = next_si; + prev_si = next_si; + + // This permits short-circuiting when matching a regex set. + // In particular, if this DFA state contains only match states, + // then it's impossible to extend the set of matches since + // match states are final. Therefore, we can quit. + if self.prog.matches.len() > 1 { + let state = self.state(next_si); + let just_matches = + state.inst_ptrs().all(|ip| self.prog[ip].is_match()); + if just_matches { + return result; + } + } + + // Another inner loop! If the DFA stays in this particular + // match state, then we can rip through all of the input + // very quickly, and only recording the match location once + // we've left this particular state. + let cur = at; + while (next_si & !STATE_MATCH) == prev_si + && at + 2 < text.len() + { + // Argument for safety is in the definition of next_si. + next_si = unsafe { + self.next_si(next_si & !STATE_MATCH, text, at) + }; + at += 1; + } + if at > cur { + result = Result::Match(at - 2); + } + } else if next_si & STATE_START > 0 { + // A start state isn't in the common case because we may + // what to do quick prefix scanning. If the program doesn't + // have a detected prefix, then start states are actually + // considered common and this case is never reached. + debug_assert!(self.has_prefix()); + next_si &= !STATE_START; + prev_si = next_si; + at = match self.prefix_at(text, at) { + None => return Result::NoMatch(text.len()), + Some(i) => i, + }; + } else if next_si >= STATE_UNKNOWN { + if next_si == STATE_QUIT { + return Result::Quit; + } + // Finally, this corresponds to the case where the transition + // entered a state that can never lead to a match or a state + // that hasn't been computed yet. The latter being the "slow" + // path. + let byte = Byte::byte(text[at - 1]); + // We no longer care about the special bits in the state + // pointer. + prev_si &= STATE_MAX; + // Record where we are. This is used to track progress for + // determining whether we should quit if we've flushed the + // cache too much. + self.at = at; + next_si = match self.next_state(qcur, qnext, prev_si, byte) { + None => return Result::Quit, + Some(STATE_DEAD) => return result.set_non_match(at), + Some(si) => si, + }; + debug_assert!(next_si != STATE_UNKNOWN); + if next_si & STATE_MATCH > 0 { + next_si &= !STATE_MATCH; + result = Result::Match(at - 1); + if self.quit_after_match { + return result; + } + self.last_match_si = next_si; + } + prev_si = next_si; + } else { + prev_si = next_si; + } + } + + // Run the DFA once more on the special EOF senitnel value. + // We don't care about the special bits in the state pointer any more, + // so get rid of them. + prev_si &= STATE_MAX; + prev_si = match self.next_state(qcur, qnext, prev_si, Byte::eof()) { + None => return Result::Quit, + Some(STATE_DEAD) => return result.set_non_match(text.len()), + Some(si) => si & !STATE_START, + }; + debug_assert!(prev_si != STATE_UNKNOWN); + if prev_si & STATE_MATCH > 0 { + prev_si &= !STATE_MATCH; + self.last_match_si = prev_si; + result = Result::Match(text.len()); + } + result + } + + /// Executes the DFA on a reverse NFA. + #[cfg_attr(feature = "perf-inline", inline(always))] + fn exec_at_reverse( + &mut self, + qcur: &mut SparseSet, + qnext: &mut SparseSet, + text: &[u8], + ) -> Result { + // The comments in `exec_at` above mostly apply here too. The main + // difference is that we move backwards over the input and we look for + // the longest possible match instead of the leftmost-first match. + // + // N.B. The code duplication here is regrettable. Efforts to improve + // it without sacrificing performance are welcome. ---AG + debug_assert!(self.prog.is_reverse); + let mut result = Result::NoMatch(self.at); + let (mut prev_si, mut next_si) = (self.start, self.start); + let mut at = self.at; + while at > 0 { + while next_si <= STATE_MAX && at > 0 { + // Argument for safety is in the definition of next_si. + at -= 1; + prev_si = unsafe { self.next_si(next_si, text, at) }; + if prev_si > STATE_MAX || at <= 4 { + mem::swap(&mut prev_si, &mut next_si); + break; + } + at -= 1; + next_si = unsafe { self.next_si(prev_si, text, at) }; + if next_si > STATE_MAX { + break; + } + at -= 1; + prev_si = unsafe { self.next_si(next_si, text, at) }; + if prev_si > STATE_MAX { + mem::swap(&mut prev_si, &mut next_si); + break; + } + at -= 1; + next_si = unsafe { self.next_si(prev_si, text, at) }; + } + if next_si & STATE_MATCH > 0 { + next_si &= !STATE_MATCH; + result = Result::Match(at + 1); + if self.quit_after_match { + return result; + } + self.last_match_si = next_si; + prev_si = next_si; + let cur = at; + while (next_si & !STATE_MATCH) == prev_si && at >= 2 { + // Argument for safety is in the definition of next_si. + at -= 1; + next_si = unsafe { + self.next_si(next_si & !STATE_MATCH, text, at) + }; + } + if at < cur { + result = Result::Match(at + 2); + } + } else if next_si >= STATE_UNKNOWN { + if next_si == STATE_QUIT { + return Result::Quit; + } + let byte = Byte::byte(text[at]); + prev_si &= STATE_MAX; + self.at = at; + next_si = match self.next_state(qcur, qnext, prev_si, byte) { + None => return Result::Quit, + Some(STATE_DEAD) => return result.set_non_match(at), + Some(si) => si, + }; + debug_assert!(next_si != STATE_UNKNOWN); + if next_si & STATE_MATCH > 0 { + next_si &= !STATE_MATCH; + result = Result::Match(at + 1); + if self.quit_after_match { + return result; + } + self.last_match_si = next_si; + } + prev_si = next_si; + } else { + prev_si = next_si; + } + } + + // Run the DFA once more on the special EOF senitnel value. + prev_si = match self.next_state(qcur, qnext, prev_si, Byte::eof()) { + None => return Result::Quit, + Some(STATE_DEAD) => return result.set_non_match(0), + Some(si) => si, + }; + debug_assert!(prev_si != STATE_UNKNOWN); + if prev_si & STATE_MATCH > 0 { + prev_si &= !STATE_MATCH; + self.last_match_si = prev_si; + result = Result::Match(0); + } + result + } + + /// next_si transitions to the next state, where the transition input + /// corresponds to text[i]. + /// + /// This elides bounds checks, and is therefore unsafe. + #[cfg_attr(feature = "perf-inline", inline(always))] + unsafe fn next_si(&self, si: StatePtr, text: &[u8], i: usize) -> StatePtr { + // What is the argument for safety here? + // We have three unchecked accesses that could possibly violate safety: + // + // 1. The given byte of input (`text[i]`). + // 2. The class of the byte of input (`classes[text[i]]`). + // 3. The transition for the class (`trans[si + cls]`). + // + // (1) is only safe when calling next_si is guarded by + // `i < text.len()`. + // + // (2) is the easiest case to guarantee since `text[i]` is always a + // `u8` and `self.prog.byte_classes` always has length `u8::MAX`. + // (See `ByteClassSet.byte_classes` in `compile.rs`.) + // + // (3) is only safe if (1)+(2) are safe. Namely, the transitions + // of every state are defined to have length equal to the number of + // byte classes in the program. Therefore, a valid class leads to a + // valid transition. (All possible transitions are valid lookups, even + // if it points to a state that hasn't been computed yet.) (3) also + // relies on `si` being correct, but StatePtrs should only ever be + // retrieved from the transition table, which ensures they are correct. + debug_assert!(i < text.len()); + let b = *text.get_unchecked(i); + debug_assert!((b as usize) < self.prog.byte_classes.len()); + let cls = *self.prog.byte_classes.get_unchecked(b as usize); + self.cache.trans.next_unchecked(si, cls as usize) + } + + /// Computes the next state given the current state and the current input + /// byte (which may be EOF). + /// + /// If STATE_DEAD is returned, then there is no valid state transition. + /// This implies that no permutation of future input can lead to a match + /// state. + /// + /// STATE_UNKNOWN can never be returned. + fn exec_byte( + &mut self, + qcur: &mut SparseSet, + qnext: &mut SparseSet, + mut si: StatePtr, + b: Byte, + ) -> Option { + use prog::Inst::*; + + // Initialize a queue with the current DFA state's NFA states. + qcur.clear(); + for ip in self.state(si).inst_ptrs() { + qcur.insert(ip); + } + + // Before inspecting the current byte, we may need to also inspect + // whether the position immediately preceding the current byte + // satisfies the empty assertions found in the current state. + // + // We only need to do this step if there are any empty assertions in + // the current state. + let is_word_last = self.state(si).flags().is_word(); + let is_word = b.is_ascii_word(); + if self.state(si).flags().has_empty() { + // Compute the flags immediately preceding the current byte. + // This means we only care about the "end" or "end line" flags. + // (The "start" flags are computed immediately proceding the + // current byte and is handled below.) + let mut flags = EmptyFlags::default(); + if b.is_eof() { + flags.end = true; + flags.end_line = true; + } else if b.as_byte().map_or(false, |b| b == b'\n') { + flags.end_line = true; + } + if is_word_last == is_word { + flags.not_word_boundary = true; + } else { + flags.word_boundary = true; + } + // Now follow epsilon transitions from every NFA state, but make + // sure we only follow transitions that satisfy our flags. + qnext.clear(); + for &ip in &*qcur { + self.follow_epsilons(usize_to_u32(ip), qnext, flags); + } + mem::swap(qcur, qnext); + } + + // Now we set flags for immediately after the current byte. Since start + // states are processed separately, and are the only states that can + // have the StartText flag set, we therefore only need to worry about + // the StartLine flag here. + // + // We do also keep track of whether this DFA state contains a NFA state + // that is a matching state. This is precisely how we delay the DFA + // matching by one byte in order to process the special EOF sentinel + // byte. Namely, if this DFA state containing a matching NFA state, + // then it is the *next* DFA state that is marked as a match. + let mut empty_flags = EmptyFlags::default(); + let mut state_flags = StateFlags::default(); + empty_flags.start_line = b.as_byte().map_or(false, |b| b == b'\n'); + if b.is_ascii_word() { + state_flags.set_word(); + } + // Now follow all epsilon transitions again, but only after consuming + // the current byte. + qnext.clear(); + for &ip in &*qcur { + match self.prog[ip as usize] { + // These states never happen in a byte-based program. + Char(_) | Ranges(_) => unreachable!(), + // These states are handled when following epsilon transitions. + Save(_) | Split(_) | EmptyLook(_) => {} + Match(_) => { + state_flags.set_match(); + if !self.continue_past_first_match() { + break; + } else if self.prog.matches.len() > 1 + && !qnext.contains(ip as usize) + { + // If we are continuing on to find other matches, + // then keep a record of the match states we've seen. + qnext.insert(ip); + } + } + Bytes(ref inst) => { + if b.as_byte().map_or(false, |b| inst.matches(b)) { + self.follow_epsilons( + inst.goto as InstPtr, + qnext, + empty_flags, + ); + } + } + } + } + + let cache = if b.is_eof() && self.prog.matches.len() > 1 { + // If we're processing the last byte of the input and we're + // matching a regex set, then make the next state contain the + // previous states transitions. We do this so that the main + // matching loop can extract all of the match instructions. + mem::swap(qcur, qnext); + // And don't cache this state because it's totally bunk. + false + } else { + true + }; + + // We've now built up the set of NFA states that ought to comprise the + // next DFA state, so try to find it in the cache, and if it doesn't + // exist, cache it. + // + // N.B. We pass `&mut si` here because the cache may clear itself if + // it has gotten too full. When that happens, the location of the + // current state may change. + let mut next = + match self.cached_state(qnext, state_flags, Some(&mut si)) { + None => return None, + Some(next) => next, + }; + if (self.start & !STATE_START) == next { + // Start states can never be match states since all matches are + // delayed by one byte. + debug_assert!(!self.state(next).flags().is_match()); + next = self.start_ptr(next); + } + if next <= STATE_MAX && self.state(next).flags().is_match() { + next |= STATE_MATCH; + } + debug_assert!(next != STATE_UNKNOWN); + // And now store our state in the current state's next list. + if cache { + let cls = self.byte_class(b); + self.cache.trans.set_next(si, cls, next); + } + Some(next) + } + + /// Follows the epsilon transitions starting at (and including) `ip`. The + /// resulting states are inserted into the ordered set `q`. + /// + /// Conditional epsilon transitions (i.e., empty width assertions) are only + /// followed if they are satisfied by the given flags, which should + /// represent the flags set at the current location in the input. + /// + /// If the current location corresponds to the empty string, then only the + /// end line and/or end text flags may be set. If the current location + /// corresponds to a real byte in the input, then only the start line + /// and/or start text flags may be set. + /// + /// As an exception to the above, when finding the initial state, any of + /// the above flags may be set: + /// + /// If matching starts at the beginning of the input, then start text and + /// start line should be set. If the input is empty, then end text and end + /// line should also be set. + /// + /// If matching starts after the beginning of the input, then only start + /// line should be set if the preceding byte is `\n`. End line should never + /// be set in this case. (Even if the proceding byte is a `\n`, it will + /// be handled in a subsequent DFA state.) + fn follow_epsilons( + &mut self, + ip: InstPtr, + q: &mut SparseSet, + flags: EmptyFlags, + ) { + use prog::EmptyLook::*; + use prog::Inst::*; + + // We need to traverse the NFA to follow epsilon transitions, so avoid + // recursion with an explicit stack. + self.cache.stack.push(ip); + while let Some(mut ip) = self.cache.stack.pop() { + // Try to munch through as many states as possible without + // pushes/pops to the stack. + loop { + // Don't visit states we've already added. + if q.contains(ip as usize) { + break; + } + q.insert(ip as usize); + match self.prog[ip as usize] { + Char(_) | Ranges(_) => unreachable!(), + Match(_) | Bytes(_) => { + break; + } + EmptyLook(ref inst) => { + // Only follow empty assertion states if our flags + // satisfy the assertion. + match inst.look { + StartLine if flags.start_line => { + ip = inst.goto as InstPtr; + } + EndLine if flags.end_line => { + ip = inst.goto as InstPtr; + } + StartText if flags.start => { + ip = inst.goto as InstPtr; + } + EndText if flags.end => { + ip = inst.goto as InstPtr; + } + WordBoundaryAscii if flags.word_boundary => { + ip = inst.goto as InstPtr; + } + NotWordBoundaryAscii + if flags.not_word_boundary => + { + ip = inst.goto as InstPtr; + } + WordBoundary if flags.word_boundary => { + ip = inst.goto as InstPtr; + } + NotWordBoundary if flags.not_word_boundary => { + ip = inst.goto as InstPtr; + } + StartLine | EndLine | StartText | EndText + | WordBoundaryAscii | NotWordBoundaryAscii + | WordBoundary | NotWordBoundary => { + break; + } + } + } + Save(ref inst) => { + ip = inst.goto as InstPtr; + } + Split(ref inst) => { + self.cache.stack.push(inst.goto2 as InstPtr); + ip = inst.goto1 as InstPtr; + } + } + } + } + } + + /// Find a previously computed state matching the given set of instructions + /// and is_match bool. + /// + /// The given set of instructions should represent a single state in the + /// NFA along with all states reachable without consuming any input. + /// + /// The is_match bool should be true if and only if the preceding DFA state + /// contains an NFA matching state. The cached state produced here will + /// then signify a match. (This enables us to delay a match by one byte, + /// in order to account for the EOF sentinel byte.) + /// + /// If the cache is full, then it is wiped before caching a new state. + /// + /// The current state should be specified if it exists, since it will need + /// to be preserved if the cache clears itself. (Start states are + /// always saved, so they should not be passed here.) It takes a mutable + /// pointer to the index because if the cache is cleared, the state's + /// location may change. + fn cached_state( + &mut self, + q: &SparseSet, + mut state_flags: StateFlags, + current_state: Option<&mut StatePtr>, + ) -> Option { + // If we couldn't come up with a non-empty key to represent this state, + // then it is dead and can never lead to a match. + // + // Note that inst_flags represent the set of empty width assertions + // in q. We use this as an optimization in exec_byte to determine when + // we should follow epsilon transitions at the empty string preceding + // the current byte. + let key = match self.cached_state_key(q, &mut state_flags) { + None => return Some(STATE_DEAD), + Some(v) => v, + }; + // In the cache? Cool. Done. + if let Some(si) = self.cache.compiled.get_ptr(&key) { + return Some(si); + } + // If the cache has gotten too big, wipe it. + if self.approximate_size() > self.prog.dfa_size_limit + && !self.clear_cache_and_save(current_state) + { + // Ooops. DFA is giving up. + return None; + } + // Allocate room for our state and add it. + self.add_state(key) + } + + /// Produces a key suitable for describing a state in the DFA cache. + /// + /// The key invariant here is that equivalent keys are produced for any two + /// sets of ordered NFA states (and toggling of whether the previous NFA + /// states contain a match state) that do not discriminate a match for any + /// input. + /// + /// Specifically, q should be an ordered set of NFA states and is_match + /// should be true if and only if the previous NFA states contained a match + /// state. + fn cached_state_key( + &mut self, + q: &SparseSet, + state_flags: &mut StateFlags, + ) -> Option { + use prog::Inst::*; + + // We need to build up enough information to recognize pre-built states + // in the DFA. Generally speaking, this includes every instruction + // except for those which are purely epsilon transitions, e.g., the + // Save and Split instructions. + // + // Empty width assertions are also epsilon transitions, but since they + // are conditional, we need to make them part of a state's key in the + // cache. + + let mut insts = + mem::replace(&mut self.cache.insts_scratch_space, vec![]); + insts.clear(); + // Reserve 1 byte for flags. + insts.push(0); + + let mut prev = 0; + for &ip in q { + let ip = usize_to_u32(ip); + match self.prog[ip as usize] { + Char(_) | Ranges(_) => unreachable!(), + Save(_) | Split(_) => {} + Bytes(_) => push_inst_ptr(&mut insts, &mut prev, ip), + EmptyLook(_) => { + state_flags.set_empty(); + push_inst_ptr(&mut insts, &mut prev, ip) + } + Match(_) => { + push_inst_ptr(&mut insts, &mut prev, ip); + if !self.continue_past_first_match() { + break; + } + } + } + } + // If we couldn't transition to any other instructions and we didn't + // see a match when expanding NFA states previously, then this is a + // dead state and no amount of additional input can transition out + // of this state. + let opt_state = if insts.len() == 1 && !state_flags.is_match() { + None + } else { + let StateFlags(f) = *state_flags; + insts[0] = f; + Some(State { data: Arc::from(&*insts) }) + }; + self.cache.insts_scratch_space = insts; + opt_state + } + + /// Clears the cache, but saves and restores current_state if it is not + /// none. + /// + /// The current state must be provided here in case its location in the + /// cache changes. + /// + /// This returns false if the cache is not cleared and the DFA should + /// give up. + fn clear_cache_and_save( + &mut self, + current_state: Option<&mut StatePtr>, + ) -> bool { + if self.cache.compiled.is_empty() { + // Nothing to clear... + return true; + } + match current_state { + None => self.clear_cache(), + Some(si) => { + let cur = self.state(*si).clone(); + if !self.clear_cache() { + return false; + } + // The unwrap is OK because we just cleared the cache and + // therefore know that the next state pointer won't exceed + // STATE_MAX. + *si = self.restore_state(cur).unwrap(); + true + } + } + } + + /// Wipes the state cache, but saves and restores the current start state. + /// + /// This returns false if the cache is not cleared and the DFA should + /// give up. + fn clear_cache(&mut self) -> bool { + // Bail out of the DFA if we're moving too "slowly." + // A heuristic from RE2: assume the DFA is too slow if it is processing + // 10 or fewer bytes per state. + // Additionally, we permit the cache to be flushed a few times before + // caling it quits. + let nstates = self.cache.compiled.len(); + if self.cache.flush_count >= 3 + && self.at >= self.last_cache_flush + && (self.at - self.last_cache_flush) <= 10 * nstates + { + return false; + } + // Update statistics tracking cache flushes. + self.last_cache_flush = self.at; + self.cache.flush_count += 1; + + // OK, actually flush the cache. + let start = self.state(self.start & !STATE_START).clone(); + let last_match = if self.last_match_si <= STATE_MAX { + Some(self.state(self.last_match_si).clone()) + } else { + None + }; + self.cache.reset_size(); + self.cache.trans.clear(); + self.cache.compiled.clear(); + for s in &mut self.cache.start_states { + *s = STATE_UNKNOWN; + } + // The unwraps are OK because we just cleared the cache and therefore + // know that the next state pointer won't exceed STATE_MAX. + let start_ptr = self.restore_state(start).unwrap(); + self.start = self.start_ptr(start_ptr); + if let Some(last_match) = last_match { + self.last_match_si = self.restore_state(last_match).unwrap(); + } + true + } + + /// Restores the given state back into the cache, and returns a pointer + /// to it. + fn restore_state(&mut self, state: State) -> Option { + // If we've already stored this state, just return a pointer to it. + // None will be the wiser. + if let Some(si) = self.cache.compiled.get_ptr(&state) { + return Some(si); + } + self.add_state(state) + } + + /// Returns the next state given the current state si and current byte + /// b. {qcur,qnext} are used as scratch space for storing ordered NFA + /// states. + /// + /// This tries to fetch the next state from the cache, but if that fails, + /// it computes the next state, caches it and returns a pointer to it. + /// + /// The pointer can be to a real state, or it can be STATE_DEAD. + /// STATE_UNKNOWN cannot be returned. + /// + /// None is returned if a new state could not be allocated (i.e., the DFA + /// ran out of space and thinks it's running too slowly). + fn next_state( + &mut self, + qcur: &mut SparseSet, + qnext: &mut SparseSet, + si: StatePtr, + b: Byte, + ) -> Option { + if si == STATE_DEAD { + return Some(STATE_DEAD); + } + match self.cache.trans.next(si, self.byte_class(b)) { + STATE_UNKNOWN => self.exec_byte(qcur, qnext, si, b), + STATE_QUIT => None, + STATE_DEAD => Some(STATE_DEAD), + nsi => Some(nsi), + } + } + + /// Computes and returns the start state, where searching begins at + /// position `at` in `text`. If the state has already been computed, + /// then it is pulled from the cache. If the state hasn't been cached, + /// then it is computed, cached and a pointer to it is returned. + /// + /// This may return STATE_DEAD but never STATE_UNKNOWN. + #[cfg_attr(feature = "perf-inline", inline(always))] + fn start_state( + &mut self, + q: &mut SparseSet, + empty_flags: EmptyFlags, + state_flags: StateFlags, + ) -> Option { + // Compute an index into our cache of start states based on the set + // of empty/state flags set at the current position in the input. We + // don't use every flag since not all flags matter. For example, since + // matches are delayed by one byte, start states can never be match + // states. + let flagi = { + (((empty_flags.start as u8) << 0) + | ((empty_flags.end as u8) << 1) + | ((empty_flags.start_line as u8) << 2) + | ((empty_flags.end_line as u8) << 3) + | ((empty_flags.word_boundary as u8) << 4) + | ((empty_flags.not_word_boundary as u8) << 5) + | ((state_flags.is_word() as u8) << 6)) as usize + }; + match self.cache.start_states[flagi] { + STATE_UNKNOWN => {} + STATE_DEAD => return Some(STATE_DEAD), + si => return Some(si), + } + q.clear(); + let start = usize_to_u32(self.prog.start); + self.follow_epsilons(start, q, empty_flags); + // Start states can never be match states because we delay every match + // by one byte. Given an empty string and an empty match, the match + // won't actually occur until the DFA processes the special EOF + // sentinel byte. + let sp = match self.cached_state(q, state_flags, None) { + None => return None, + Some(sp) => self.start_ptr(sp), + }; + self.cache.start_states[flagi] = sp; + Some(sp) + } + + /// Computes the set of starting flags for the given position in text. + /// + /// This should only be used when executing the DFA forwards over the + /// input. + fn start_flags(&self, text: &[u8], at: usize) -> (EmptyFlags, StateFlags) { + let mut empty_flags = EmptyFlags::default(); + let mut state_flags = StateFlags::default(); + empty_flags.start = at == 0; + empty_flags.end = text.is_empty(); + empty_flags.start_line = at == 0 || text[at - 1] == b'\n'; + empty_flags.end_line = text.is_empty(); + + let is_word_last = at > 0 && Byte::byte(text[at - 1]).is_ascii_word(); + let is_word = at < text.len() && Byte::byte(text[at]).is_ascii_word(); + if is_word_last { + state_flags.set_word(); + } + if is_word == is_word_last { + empty_flags.not_word_boundary = true; + } else { + empty_flags.word_boundary = true; + } + (empty_flags, state_flags) + } + + /// Computes the set of starting flags for the given position in text. + /// + /// This should only be used when executing the DFA in reverse over the + /// input. + fn start_flags_reverse( + &self, + text: &[u8], + at: usize, + ) -> (EmptyFlags, StateFlags) { + let mut empty_flags = EmptyFlags::default(); + let mut state_flags = StateFlags::default(); + empty_flags.start = at == text.len(); + empty_flags.end = text.is_empty(); + empty_flags.start_line = at == text.len() || text[at] == b'\n'; + empty_flags.end_line = text.is_empty(); + + let is_word_last = + at < text.len() && Byte::byte(text[at]).is_ascii_word(); + let is_word = at > 0 && Byte::byte(text[at - 1]).is_ascii_word(); + if is_word_last { + state_flags.set_word(); + } + if is_word == is_word_last { + empty_flags.not_word_boundary = true; + } else { + empty_flags.word_boundary = true; + } + (empty_flags, state_flags) + } + + /// Returns a reference to a State given a pointer to it. + fn state(&self, si: StatePtr) -> &State { + self.cache.compiled.get_state(si).unwrap() + } + + /// Adds the given state to the DFA. + /// + /// This allocates room for transitions out of this state in + /// self.cache.trans. The transitions can be set with the returned + /// StatePtr. + /// + /// If None is returned, then the state limit was reached and the DFA + /// should quit. + fn add_state(&mut self, state: State) -> Option { + // This will fail if the next state pointer exceeds STATE_PTR. In + // practice, the cache limit will prevent us from ever getting here, + // but maybe callers will set the cache size to something ridiculous... + let si = match self.cache.trans.add() { + None => return None, + Some(si) => si, + }; + // If the program has a Unicode word boundary, then set any transitions + // for non-ASCII bytes to STATE_QUIT. If the DFA stumbles over such a + // transition, then it will quit and an alternative matching engine + // will take over. + if self.prog.has_unicode_word_boundary { + for b in 128..256 { + let cls = self.byte_class(Byte::byte(b as u8)); + self.cache.trans.set_next(si, cls, STATE_QUIT); + } + } + // Finally, put our actual state on to our heap of states and index it + // so we can find it later. + self.cache.size += self.cache.trans.state_heap_size() + + state.data.len() + + (2 * mem::size_of::()) + + mem::size_of::(); + self.cache.compiled.insert(state, si); + // Transition table and set of states and map should all be in sync. + debug_assert!( + self.cache.compiled.len() == self.cache.trans.num_states() + ); + Some(si) + } + + /// Quickly finds the next occurrence of any literal prefixes in the regex. + /// If there are no literal prefixes, then the current position is + /// returned. If there are literal prefixes and one could not be found, + /// then None is returned. + /// + /// This should only be called when the DFA is in a start state. + fn prefix_at(&self, text: &[u8], at: usize) -> Option { + self.prog.prefixes.find(&text[at..]).map(|(s, _)| at + s) + } + + /// Returns the number of byte classes required to discriminate transitions + /// in each state. + /// + /// invariant: num_byte_classes() == len(State.next) + fn num_byte_classes(&self) -> usize { + // We add 1 to account for the special EOF byte. + (self.prog.byte_classes[255] as usize + 1) + 1 + } + + /// Given an input byte or the special EOF sentinel, return its + /// corresponding byte class. + #[cfg_attr(feature = "perf-inline", inline(always))] + fn byte_class(&self, b: Byte) -> usize { + match b.as_byte() { + None => self.num_byte_classes() - 1, + Some(b) => self.u8_class(b), + } + } + + /// Like byte_class, but explicitly for u8s. + #[cfg_attr(feature = "perf-inline", inline(always))] + fn u8_class(&self, b: u8) -> usize { + self.prog.byte_classes[b as usize] as usize + } + + /// Returns true if the DFA should continue searching past the first match. + /// + /// Leftmost first semantics in the DFA are preserved by not following NFA + /// transitions after the first match is seen. + /// + /// On occasion, we want to avoid leftmost first semantics to find either + /// the longest match (for reverse search) or all possible matches (for + /// regex sets). + fn continue_past_first_match(&self) -> bool { + self.prog.is_reverse || self.prog.matches.len() > 1 + } + + /// Returns true if there is a prefix we can quickly search for. + fn has_prefix(&self) -> bool { + !self.prog.is_reverse + && !self.prog.prefixes.is_empty() + && !self.prog.is_anchored_start + } + + /// Sets the STATE_START bit in the given state pointer if and only if + /// we have a prefix to scan for. + /// + /// If there's no prefix, then it's a waste to treat the start state + /// specially. + fn start_ptr(&self, si: StatePtr) -> StatePtr { + if self.has_prefix() { + si | STATE_START + } else { + si + } + } + + /// Approximate size returns the approximate heap space currently used by + /// the DFA. It is used to determine whether the DFA's state cache needs to + /// be wiped. Namely, it is possible that for certain regexes on certain + /// inputs, a new state could be created for every byte of input. (This is + /// bad for memory use, so we bound it with a cache.) + fn approximate_size(&self) -> usize { + self.cache.size + self.prog.approximate_size() + } +} + +/// An abstraction for representing a map of states. The map supports two +/// different ways of state lookup. One is fast constant time access via a +/// state pointer. The other is a hashmap lookup based on the DFA's +/// constituent NFA states. +/// +/// A DFA state internally uses an Arc such that we only need to store the +/// set of NFA states on the heap once, even though we support looking up +/// states by two different means. A more natural way to express this might +/// use raw pointers, but an Arc is safe and effectively achieves the same +/// thing. +#[derive(Debug)] +struct StateMap { + /// The keys are not actually static but rely on always pointing to a + /// buffer in `states` which will never be moved except when clearing + /// the map or on drop, in which case the keys of this map will be + /// removed before + map: HashMap, + /// Our set of states. Note that `StatePtr / num_byte_classes` indexes + /// this Vec rather than just a `StatePtr`. + states: Vec, + /// The number of byte classes in the DFA. Used to index `states`. + num_byte_classes: usize, +} + +impl StateMap { + fn new(num_byte_classes: usize) -> StateMap { + StateMap { + map: HashMap::new(), + states: vec![], + num_byte_classes: num_byte_classes, + } + } + + fn len(&self) -> usize { + self.states.len() + } + + fn is_empty(&self) -> bool { + self.states.is_empty() + } + + fn get_ptr(&self, state: &State) -> Option { + self.map.get(state).cloned() + } + + fn get_state(&self, si: StatePtr) -> Option<&State> { + self.states.get(si as usize / self.num_byte_classes) + } + + fn insert(&mut self, state: State, si: StatePtr) { + self.map.insert(state.clone(), si); + self.states.push(state); + } + + fn clear(&mut self) { + self.map.clear(); + self.states.clear(); + } +} + +impl Transitions { + /// Create a new transition table. + /// + /// The number of byte classes corresponds to the stride. Every state will + /// have `num_byte_classes` slots for transitions. + fn new(num_byte_classes: usize) -> Transitions { + Transitions { table: vec![], num_byte_classes: num_byte_classes } + } + + /// Returns the total number of states currently in this table. + fn num_states(&self) -> usize { + self.table.len() / self.num_byte_classes + } + + /// Allocates room for one additional state and returns a pointer to it. + /// + /// If there's no more room, None is returned. + fn add(&mut self) -> Option { + let si = self.table.len(); + if si > STATE_MAX as usize { + return None; + } + self.table.extend(repeat(STATE_UNKNOWN).take(self.num_byte_classes)); + Some(usize_to_u32(si)) + } + + /// Clears the table of all states. + fn clear(&mut self) { + self.table.clear(); + } + + /// Sets the transition from (si, cls) to next. + fn set_next(&mut self, si: StatePtr, cls: usize, next: StatePtr) { + self.table[si as usize + cls] = next; + } + + /// Returns the transition corresponding to (si, cls). + fn next(&self, si: StatePtr, cls: usize) -> StatePtr { + self.table[si as usize + cls] + } + + /// The heap size, in bytes, of a single state in the transition table. + fn state_heap_size(&self) -> usize { + self.num_byte_classes * mem::size_of::() + } + + /// Like `next`, but uses unchecked access and is therefore unsafe. + unsafe fn next_unchecked(&self, si: StatePtr, cls: usize) -> StatePtr { + debug_assert!((si as usize) < self.table.len()); + debug_assert!(cls < self.num_byte_classes); + *self.table.get_unchecked(si as usize + cls) + } +} + +impl StateFlags { + fn is_match(&self) -> bool { + self.0 & 0b0000000_1 > 0 + } + + fn set_match(&mut self) { + self.0 |= 0b0000000_1; + } + + fn is_word(&self) -> bool { + self.0 & 0b000000_1_0 > 0 + } + + fn set_word(&mut self) { + self.0 |= 0b000000_1_0; + } + + fn has_empty(&self) -> bool { + self.0 & 0b00000_1_00 > 0 + } + + fn set_empty(&mut self) { + self.0 |= 0b00000_1_00; + } +} + +impl Byte { + fn byte(b: u8) -> Self { + Byte(b as u16) + } + fn eof() -> Self { + Byte(256) + } + fn is_eof(&self) -> bool { + self.0 == 256 + } + + fn is_ascii_word(&self) -> bool { + let b = match self.as_byte() { + None => return false, + Some(b) => b, + }; + match b { + b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'_' => true, + _ => false, + } + } + + fn as_byte(&self) -> Option { + if self.is_eof() { + None + } else { + Some(self.0 as u8) + } + } +} + +impl fmt::Debug for State { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let ips: Vec = self.inst_ptrs().collect(); + f.debug_struct("State") + .field("flags", &self.flags()) + .field("insts", &ips) + .finish() + } +} + +impl fmt::Debug for Transitions { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut fmtd = f.debug_map(); + for si in 0..self.num_states() { + let s = si * self.num_byte_classes; + let e = s + self.num_byte_classes; + fmtd.entry(&si.to_string(), &TransitionsRow(&self.table[s..e])); + } + fmtd.finish() + } +} + +struct TransitionsRow<'a>(&'a [StatePtr]); + +impl<'a> fmt::Debug for TransitionsRow<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut fmtd = f.debug_map(); + for (b, si) in self.0.iter().enumerate() { + match *si { + STATE_UNKNOWN => {} + STATE_DEAD => { + fmtd.entry(&vb(b as usize), &"DEAD"); + } + si => { + fmtd.entry(&vb(b as usize), &si.to_string()); + } + } + } + fmtd.finish() + } +} + +impl fmt::Debug for StateFlags { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("StateFlags") + .field("is_match", &self.is_match()) + .field("is_word", &self.is_word()) + .field("has_empty", &self.has_empty()) + .finish() + } +} + +/// Helper function for formatting a byte as a nice-to-read escaped string. +fn vb(b: usize) -> String { + use std::ascii::escape_default; + + if b > ::std::u8::MAX as usize { + "EOF".to_owned() + } else { + let escaped = escape_default(b as u8).collect::>(); + String::from_utf8_lossy(&escaped).into_owned() + } +} + +fn usize_to_u32(n: usize) -> u32 { + if (n as u64) > (::std::u32::MAX as u64) { + panic!("BUG: {} is too big to fit into u32", n) + } + n as u32 +} + +#[allow(dead_code)] // useful for debugging +fn show_state_ptr(si: StatePtr) -> String { + let mut s = format!("{:?}", si & STATE_MAX); + if si == STATE_UNKNOWN { + s = format!("{} (unknown)", s); + } + if si == STATE_DEAD { + s = format!("{} (dead)", s); + } + if si == STATE_QUIT { + s = format!("{} (quit)", s); + } + if si & STATE_START > 0 { + s = format!("{} (start)", s); + } + if si & STATE_MATCH > 0 { + s = format!("{} (match)", s); + } + s +} + +/// https://developers.google.com/protocol-buffers/docs/encoding#varints +fn write_vari32(data: &mut Vec, n: i32) { + let mut un = (n as u32) << 1; + if n < 0 { + un = !un; + } + write_varu32(data, un) +} + +/// https://developers.google.com/protocol-buffers/docs/encoding#varints +fn read_vari32(data: &[u8]) -> (i32, usize) { + let (un, i) = read_varu32(data); + let mut n = (un >> 1) as i32; + if un & 1 != 0 { + n = !n; + } + (n, i) +} + +/// https://developers.google.com/protocol-buffers/docs/encoding#varints +fn write_varu32(data: &mut Vec, mut n: u32) { + while n >= 0b1000_0000 { + data.push((n as u8) | 0b1000_0000); + n >>= 7; + } + data.push(n as u8); +} + +/// https://developers.google.com/protocol-buffers/docs/encoding#varints +fn read_varu32(data: &[u8]) -> (u32, usize) { + let mut n: u32 = 0; + let mut shift: u32 = 0; + for (i, &b) in data.iter().enumerate() { + if b < 0b1000_0000 { + return (n | ((b as u32) << shift), i + 1); + } + n |= ((b as u32) & 0b0111_1111) << shift; + shift += 7; + } + (0, 0) +} + +#[cfg(test)] +mod tests { + extern crate rand; + + use super::{ + push_inst_ptr, read_vari32, read_varu32, write_vari32, write_varu32, + State, StateFlags, + }; + use quickcheck::{quickcheck, QuickCheck, StdGen}; + use std::sync::Arc; + + #[test] + fn prop_state_encode_decode() { + fn p(ips: Vec, flags: u8) -> bool { + let mut data = vec![flags]; + let mut prev = 0; + for &ip in ips.iter() { + push_inst_ptr(&mut data, &mut prev, ip); + } + let state = State { data: Arc::from(&data[..]) }; + + let expected: Vec = + ips.into_iter().map(|ip| ip as usize).collect(); + let got: Vec = state.inst_ptrs().collect(); + expected == got && state.flags() == StateFlags(flags) + } + QuickCheck::new() + .gen(StdGen::new(self::rand::thread_rng(), 10_000)) + .quickcheck(p as fn(Vec, u8) -> bool); + } + + #[test] + fn prop_read_write_u32() { + fn p(n: u32) -> bool { + let mut buf = vec![]; + write_varu32(&mut buf, n); + let (got, nread) = read_varu32(&buf); + nread == buf.len() && got == n + } + quickcheck(p as fn(u32) -> bool); + } + + #[test] + fn prop_read_write_i32() { + fn p(n: i32) -> bool { + let mut buf = vec![]; + write_vari32(&mut buf, n); + let (got, nread) = read_vari32(&buf); + nread == buf.len() && got == n + } + quickcheck(p as fn(i32) -> bool); + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/error.rs b/third_party/cargo/vendor/regex-1.3.3/src/error.rs new file mode 100644 index 0000000..1c32c85 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/error.rs @@ -0,0 +1,71 @@ +use std::fmt; +use std::iter::repeat; + +/// An error that occurred during parsing or compiling a regular expression. +#[derive(Clone, PartialEq)] +pub enum Error { + /// A syntax error. + Syntax(String), + /// The compiled program exceeded the set size limit. + /// The argument is the size limit imposed. + CompiledTooBig(usize), + /// Hints that destructuring should not be exhaustive. + /// + /// This enum may grow additional variants, so this makes sure clients + /// don't count on exhaustive matching. (Otherwise, adding a new variant + /// could break existing code.) + #[doc(hidden)] + __Nonexhaustive, +} + +impl ::std::error::Error for Error { + // TODO: Remove this method entirely on the next breaking semver release. + #[allow(deprecated)] + fn description(&self) -> &str { + match *self { + Error::Syntax(ref err) => err, + Error::CompiledTooBig(_) => "compiled program too big", + Error::__Nonexhaustive => unreachable!(), + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Error::Syntax(ref err) => err.fmt(f), + Error::CompiledTooBig(limit) => write!( + f, + "Compiled regex exceeds size limit of {} bytes.", + limit + ), + Error::__Nonexhaustive => unreachable!(), + } + } +} + +// We implement our own Debug implementation so that we show nicer syntax +// errors when people use `Regex::new(...).unwrap()`. It's a little weird, +// but the `Syntax` variant is already storing a `String` anyway, so we might +// as well format it nicely. +impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Error::Syntax(ref err) => { + let hr: String = repeat('~').take(79).collect(); + writeln!(f, "Syntax(")?; + writeln!(f, "{}", hr)?; + writeln!(f, "{}", err)?; + writeln!(f, "{}", hr)?; + write!(f, ")")?; + Ok(()) + } + Error::CompiledTooBig(limit) => { + f.debug_tuple("CompiledTooBig").field(&limit).finish() + } + Error::__Nonexhaustive => { + f.debug_tuple("__Nonexhaustive").finish() + } + } + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/exec.rs b/third_party/cargo/vendor/regex-1.3.3/src/exec.rs new file mode 100644 index 0000000..acca2dc --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/exec.rs @@ -0,0 +1,1632 @@ +use std::cell::RefCell; +use std::collections::HashMap; +use std::sync::Arc; + +#[cfg(feature = "perf-literal")] +use aho_corasick::{AhoCorasick, AhoCorasickBuilder, MatchKind}; +use syntax::hir::literal::Literals; +use syntax::hir::Hir; +use syntax::ParserBuilder; + +use backtrack; +use cache::{Cached, CachedGuard}; +use compile::Compiler; +#[cfg(feature = "perf-dfa")] +use dfa; +use error::Error; +use input::{ByteInput, CharInput}; +use literal::LiteralSearcher; +use pikevm; +use prog::Program; +use re_builder::RegexOptions; +use re_bytes; +use re_set; +use re_trait::{Locations, RegularExpression, Slot}; +use re_unicode; +use utf8::next_utf8; + +/// `Exec` manages the execution of a regular expression. +/// +/// In particular, this manages the various compiled forms of a single regular +/// expression and the choice of which matching engine to use to execute a +/// regular expression. +pub struct Exec { + /// All read only state. + ro: Arc, + /// Caches for the various matching engines. + cache: Cached, +} + +/// `ExecNoSync` is like `Exec`, except it embeds a reference to a cache. This +/// means it is no longer Sync, but we can now avoid the overhead of +/// synchronization to fetch the cache. +#[derive(Debug)] +pub struct ExecNoSync<'c> { + /// All read only state. + ro: &'c Arc, + /// Caches for the various matching engines. + cache: CachedGuard<'c, ProgramCache>, +} + +/// `ExecNoSyncStr` is like `ExecNoSync`, but matches on &str instead of &[u8]. +pub struct ExecNoSyncStr<'c>(ExecNoSync<'c>); + +/// `ExecReadOnly` comprises all read only state for a regex. Namely, all such +/// state is determined at compile time and never changes during search. +#[derive(Debug)] +struct ExecReadOnly { + /// The original regular expressions given by the caller to compile. + res: Vec, + /// A compiled program that is used in the NFA simulation and backtracking. + /// It can be byte-based or Unicode codepoint based. + /// + /// N.B. It is not possibly to make this byte-based from the public API. + /// It is only used for testing byte based programs in the NFA simulations. + nfa: Program, + /// A compiled byte based program for DFA execution. This is only used + /// if a DFA can be executed. (Currently, only word boundary assertions are + /// not supported.) Note that this program contains an embedded `.*?` + /// preceding the first capture group, unless the regex is anchored at the + /// beginning. + dfa: Program, + /// The same as above, except the program is reversed (and there is no + /// preceding `.*?`). This is used by the DFA to find the starting location + /// of matches. + dfa_reverse: Program, + /// A set of suffix literals extracted from the regex. + /// + /// Prefix literals are stored on the `Program`, since they are used inside + /// the matching engines. + suffixes: LiteralSearcher, + /// An Aho-Corasick automaton with leftmost-first match semantics. + /// + /// This is only set when the entire regex is a simple unanchored + /// alternation of literals. We could probably use it more circumstances, + /// but this is already hacky enough in this architecture. + /// + /// N.B. We use u32 as a state ID representation under the assumption that + /// if we were to exhaust the ID space, we probably would have long + /// surpassed the compilation size limit. + #[cfg(feature = "perf-literal")] + ac: Option>, + /// match_type encodes as much upfront knowledge about how we're going to + /// execute a search as possible. + match_type: MatchType, +} + +/// Facilitates the construction of an executor by exposing various knobs +/// to control how a regex is executed and what kinds of resources it's +/// permitted to use. +pub struct ExecBuilder { + options: RegexOptions, + match_type: Option, + bytes: bool, + only_utf8: bool, +} + +/// Parsed represents a set of parsed regular expressions and their detected +/// literals. +struct Parsed { + exprs: Vec, + prefixes: Literals, + suffixes: Literals, + bytes: bool, +} + +impl ExecBuilder { + /// Create a regex execution builder. + /// + /// This uses default settings for everything except the regex itself, + /// which must be provided. Further knobs can be set by calling methods, + /// and then finally, `build` to actually create the executor. + pub fn new(re: &str) -> Self { + Self::new_many(&[re]) + } + + /// Like new, but compiles the union of the given regular expressions. + /// + /// Note that when compiling 2 or more regular expressions, capture groups + /// are completely unsupported. (This means both `find` and `captures` + /// wont work.) + pub fn new_many(res: I) -> Self + where + S: AsRef, + I: IntoIterator, + { + let mut opts = RegexOptions::default(); + opts.pats = res.into_iter().map(|s| s.as_ref().to_owned()).collect(); + Self::new_options(opts) + } + + /// Create a regex execution builder. + pub fn new_options(opts: RegexOptions) -> Self { + ExecBuilder { + options: opts, + match_type: None, + bytes: false, + only_utf8: true, + } + } + + /// Set the matching engine to be automatically determined. + /// + /// This is the default state and will apply whatever optimizations are + /// possible, such as running a DFA. + /// + /// This overrides whatever was previously set via the `nfa` or + /// `bounded_backtracking` methods. + pub fn automatic(mut self) -> Self { + self.match_type = None; + self + } + + /// Sets the matching engine to use the NFA algorithm no matter what + /// optimizations are possible. + /// + /// This overrides whatever was previously set via the `automatic` or + /// `bounded_backtracking` methods. + pub fn nfa(mut self) -> Self { + self.match_type = Some(MatchType::Nfa(MatchNfaType::PikeVM)); + self + } + + /// Sets the matching engine to use a bounded backtracking engine no + /// matter what optimizations are possible. + /// + /// One must use this with care, since the bounded backtracking engine + /// uses memory proportion to `len(regex) * len(text)`. + /// + /// This overrides whatever was previously set via the `automatic` or + /// `nfa` methods. + pub fn bounded_backtracking(mut self) -> Self { + self.match_type = Some(MatchType::Nfa(MatchNfaType::Backtrack)); + self + } + + /// Compiles byte based programs for use with the NFA matching engines. + /// + /// By default, the NFA engines match on Unicode scalar values. They can + /// be made to use byte based programs instead. In general, the byte based + /// programs are slower because of a less efficient encoding of character + /// classes. + /// + /// Note that this does not impact DFA matching engines, which always + /// execute on bytes. + pub fn bytes(mut self, yes: bool) -> Self { + self.bytes = yes; + self + } + + /// When disabled, the program compiled may match arbitrary bytes. + /// + /// When enabled (the default), all compiled programs exclusively match + /// valid UTF-8 bytes. + pub fn only_utf8(mut self, yes: bool) -> Self { + self.only_utf8 = yes; + self + } + + /// Set the Unicode flag. + pub fn unicode(mut self, yes: bool) -> Self { + self.options.unicode = yes; + self + } + + /// Parse the current set of patterns into their AST and extract literals. + fn parse(&self) -> Result { + let mut exprs = Vec::with_capacity(self.options.pats.len()); + let mut prefixes = Some(Literals::empty()); + let mut suffixes = Some(Literals::empty()); + let mut bytes = false; + let is_set = self.options.pats.len() > 1; + // If we're compiling a regex set and that set has any anchored + // expressions, then disable all literal optimizations. + for pat in &self.options.pats { + let mut parser = ParserBuilder::new() + .octal(self.options.octal) + .case_insensitive(self.options.case_insensitive) + .multi_line(self.options.multi_line) + .dot_matches_new_line(self.options.dot_matches_new_line) + .swap_greed(self.options.swap_greed) + .ignore_whitespace(self.options.ignore_whitespace) + .unicode(self.options.unicode) + .allow_invalid_utf8(!self.only_utf8) + .nest_limit(self.options.nest_limit) + .build(); + let expr = + parser.parse(pat).map_err(|e| Error::Syntax(e.to_string()))?; + bytes = bytes || !expr.is_always_utf8(); + + if cfg!(feature = "perf-literal") { + if !expr.is_anchored_start() && expr.is_any_anchored_start() { + // Partial anchors unfortunately make it hard to use + // prefixes, so disable them. + prefixes = None; + } else if is_set && expr.is_anchored_start() { + // Regex sets with anchors do not go well with literal + // optimizations. + prefixes = None; + } + prefixes = prefixes.and_then(|mut prefixes| { + if !prefixes.union_prefixes(&expr) { + None + } else { + Some(prefixes) + } + }); + + if !expr.is_anchored_end() && expr.is_any_anchored_end() { + // Partial anchors unfortunately make it hard to use + // suffixes, so disable them. + suffixes = None; + } else if is_set && expr.is_anchored_end() { + // Regex sets with anchors do not go well with literal + // optimizations. + suffixes = None; + } + suffixes = suffixes.and_then(|mut suffixes| { + if !suffixes.union_suffixes(&expr) { + None + } else { + Some(suffixes) + } + }); + } + exprs.push(expr); + } + Ok(Parsed { + exprs: exprs, + prefixes: prefixes.unwrap_or_else(Literals::empty), + suffixes: suffixes.unwrap_or_else(Literals::empty), + bytes: bytes, + }) + } + + /// Build an executor that can run a regular expression. + pub fn build(self) -> Result { + // Special case when we have no patterns to compile. + // This can happen when compiling a regex set. + if self.options.pats.is_empty() { + let ro = Arc::new(ExecReadOnly { + res: vec![], + nfa: Program::new(), + dfa: Program::new(), + dfa_reverse: Program::new(), + suffixes: LiteralSearcher::empty(), + #[cfg(feature = "perf-literal")] + ac: None, + match_type: MatchType::Nothing, + }); + return Ok(Exec { ro: ro, cache: Cached::new() }); + } + let parsed = self.parse()?; + let mut nfa = Compiler::new() + .size_limit(self.options.size_limit) + .bytes(self.bytes || parsed.bytes) + .only_utf8(self.only_utf8) + .compile(&parsed.exprs)?; + let mut dfa = Compiler::new() + .size_limit(self.options.size_limit) + .dfa(true) + .only_utf8(self.only_utf8) + .compile(&parsed.exprs)?; + let mut dfa_reverse = Compiler::new() + .size_limit(self.options.size_limit) + .dfa(true) + .only_utf8(self.only_utf8) + .reverse(true) + .compile(&parsed.exprs)?; + + #[cfg(feature = "perf-literal")] + let ac = self.build_aho_corasick(&parsed); + nfa.prefixes = LiteralSearcher::prefixes(parsed.prefixes); + dfa.prefixes = nfa.prefixes.clone(); + dfa.dfa_size_limit = self.options.dfa_size_limit; + dfa_reverse.dfa_size_limit = self.options.dfa_size_limit; + + let mut ro = ExecReadOnly { + res: self.options.pats, + nfa: nfa, + dfa: dfa, + dfa_reverse: dfa_reverse, + suffixes: LiteralSearcher::suffixes(parsed.suffixes), + #[cfg(feature = "perf-literal")] + ac: ac, + match_type: MatchType::Nothing, + }; + ro.match_type = ro.choose_match_type(self.match_type); + + let ro = Arc::new(ro); + Ok(Exec { ro: ro, cache: Cached::new() }) + } + + #[cfg(feature = "perf-literal")] + fn build_aho_corasick(&self, parsed: &Parsed) -> Option> { + if parsed.exprs.len() != 1 { + return None; + } + let lits = match alternation_literals(&parsed.exprs[0]) { + None => return None, + Some(lits) => lits, + }; + // If we have a small number of literals, then let Teddy handle + // things (see literal/mod.rs). + if lits.len() <= 32 { + return None; + } + Some( + AhoCorasickBuilder::new() + .match_kind(MatchKind::LeftmostFirst) + .auto_configure(&lits) + // We always want this to reduce size, regardless + // of what auto-configure does. + .byte_classes(true) + .build_with_size::(&lits) + // This should never happen because we'd long exceed the + // compilation limit for regexes first. + .expect("AC automaton too big"), + ) + } +} + +impl<'c> RegularExpression for ExecNoSyncStr<'c> { + type Text = str; + + fn slots_len(&self) -> usize { + self.0.slots_len() + } + + fn next_after_empty(&self, text: &str, i: usize) -> usize { + next_utf8(text.as_bytes(), i) + } + + #[cfg_attr(feature = "perf-inline", inline(always))] + fn shortest_match_at(&self, text: &str, start: usize) -> Option { + self.0.shortest_match_at(text.as_bytes(), start) + } + + #[cfg_attr(feature = "perf-inline", inline(always))] + fn is_match_at(&self, text: &str, start: usize) -> bool { + self.0.is_match_at(text.as_bytes(), start) + } + + #[cfg_attr(feature = "perf-inline", inline(always))] + fn find_at(&self, text: &str, start: usize) -> Option<(usize, usize)> { + self.0.find_at(text.as_bytes(), start) + } + + #[cfg_attr(feature = "perf-inline", inline(always))] + fn captures_read_at( + &self, + locs: &mut Locations, + text: &str, + start: usize, + ) -> Option<(usize, usize)> { + self.0.captures_read_at(locs, text.as_bytes(), start) + } +} + +impl<'c> RegularExpression for ExecNoSync<'c> { + type Text = [u8]; + + /// Returns the number of capture slots in the regular expression. (There + /// are two slots for every capture group, corresponding to possibly empty + /// start and end locations of the capture.) + fn slots_len(&self) -> usize { + self.ro.nfa.captures.len() * 2 + } + + fn next_after_empty(&self, _text: &[u8], i: usize) -> usize { + i + 1 + } + + /// Returns the end of a match location, possibly occurring before the + /// end location of the correct leftmost-first match. + #[cfg_attr(feature = "perf-inline", inline(always))] + fn shortest_match_at(&self, text: &[u8], start: usize) -> Option { + if !self.is_anchor_end_match(text) { + return None; + } + match self.ro.match_type { + #[cfg(feature = "perf-literal")] + MatchType::Literal(ty) => { + self.find_literals(ty, text, start).map(|(_, e)| e) + } + #[cfg(feature = "perf-dfa")] + MatchType::Dfa | MatchType::DfaMany => { + match self.shortest_dfa(text, start) { + dfa::Result::Match(end) => Some(end), + dfa::Result::NoMatch(_) => None, + dfa::Result::Quit => self.shortest_nfa(text, start), + } + } + #[cfg(feature = "perf-dfa")] + MatchType::DfaAnchoredReverse => { + match dfa::Fsm::reverse( + &self.ro.dfa_reverse, + self.cache.value(), + true, + &text[start..], + text.len(), + ) { + dfa::Result::Match(_) => Some(text.len()), + dfa::Result::NoMatch(_) => None, + dfa::Result::Quit => self.shortest_nfa(text, start), + } + } + #[cfg(all(feature = "perf-dfa", feature = "perf-literal"))] + MatchType::DfaSuffix => { + match self.shortest_dfa_reverse_suffix(text, start) { + dfa::Result::Match(e) => Some(e), + dfa::Result::NoMatch(_) => None, + dfa::Result::Quit => self.shortest_nfa(text, start), + } + } + MatchType::Nfa(ty) => self.shortest_nfa_type(ty, text, start), + MatchType::Nothing => None, + } + } + + /// Returns true if and only if the regex matches text. + /// + /// For single regular expressions, this is equivalent to calling + /// shortest_match(...).is_some(). + #[cfg_attr(feature = "perf-inline", inline(always))] + fn is_match_at(&self, text: &[u8], start: usize) -> bool { + if !self.is_anchor_end_match(text) { + return false; + } + // We need to do this dance because shortest_match relies on the NFA + // filling in captures[1], but a RegexSet has no captures. In other + // words, a RegexSet can't (currently) use shortest_match. ---AG + match self.ro.match_type { + #[cfg(feature = "perf-literal")] + MatchType::Literal(ty) => { + self.find_literals(ty, text, start).is_some() + } + #[cfg(feature = "perf-dfa")] + MatchType::Dfa | MatchType::DfaMany => { + match self.shortest_dfa(text, start) { + dfa::Result::Match(_) => true, + dfa::Result::NoMatch(_) => false, + dfa::Result::Quit => self.match_nfa(text, start), + } + } + #[cfg(feature = "perf-dfa")] + MatchType::DfaAnchoredReverse => { + match dfa::Fsm::reverse( + &self.ro.dfa_reverse, + self.cache.value(), + true, + &text[start..], + text.len(), + ) { + dfa::Result::Match(_) => true, + dfa::Result::NoMatch(_) => false, + dfa::Result::Quit => self.match_nfa(text, start), + } + } + #[cfg(all(feature = "perf-dfa", feature = "perf-literal"))] + MatchType::DfaSuffix => { + match self.shortest_dfa_reverse_suffix(text, start) { + dfa::Result::Match(_) => true, + dfa::Result::NoMatch(_) => false, + dfa::Result::Quit => self.match_nfa(text, start), + } + } + MatchType::Nfa(ty) => self.match_nfa_type(ty, text, start), + MatchType::Nothing => false, + } + } + + /// Finds the start and end location of the leftmost-first match, starting + /// at the given location. + #[cfg_attr(feature = "perf-inline", inline(always))] + fn find_at(&self, text: &[u8], start: usize) -> Option<(usize, usize)> { + if !self.is_anchor_end_match(text) { + return None; + } + match self.ro.match_type { + #[cfg(feature = "perf-literal")] + MatchType::Literal(ty) => self.find_literals(ty, text, start), + #[cfg(feature = "perf-dfa")] + MatchType::Dfa => match self.find_dfa_forward(text, start) { + dfa::Result::Match((s, e)) => Some((s, e)), + dfa::Result::NoMatch(_) => None, + dfa::Result::Quit => { + self.find_nfa(MatchNfaType::Auto, text, start) + } + }, + #[cfg(feature = "perf-dfa")] + MatchType::DfaAnchoredReverse => { + match self.find_dfa_anchored_reverse(text, start) { + dfa::Result::Match((s, e)) => Some((s, e)), + dfa::Result::NoMatch(_) => None, + dfa::Result::Quit => { + self.find_nfa(MatchNfaType::Auto, text, start) + } + } + } + #[cfg(all(feature = "perf-dfa", feature = "perf-literal"))] + MatchType::DfaSuffix => { + match self.find_dfa_reverse_suffix(text, start) { + dfa::Result::Match((s, e)) => Some((s, e)), + dfa::Result::NoMatch(_) => None, + dfa::Result::Quit => { + self.find_nfa(MatchNfaType::Auto, text, start) + } + } + } + MatchType::Nfa(ty) => self.find_nfa(ty, text, start), + MatchType::Nothing => None, + #[cfg(feature = "perf-dfa")] + MatchType::DfaMany => { + unreachable!("BUG: RegexSet cannot be used with find") + } + } + } + + /// Finds the start and end location of the leftmost-first match and also + /// fills in all matching capture groups. + /// + /// The number of capture slots given should be equal to the total number + /// of capture slots in the compiled program. + /// + /// Note that the first two slots always correspond to the start and end + /// locations of the overall match. + fn captures_read_at( + &self, + locs: &mut Locations, + text: &[u8], + start: usize, + ) -> Option<(usize, usize)> { + let slots = locs.as_slots(); + for slot in slots.iter_mut() { + *slot = None; + } + // If the caller unnecessarily uses this, then we try to save them + // from themselves. + match slots.len() { + 0 => return self.find_at(text, start), + 2 => { + return self.find_at(text, start).map(|(s, e)| { + slots[0] = Some(s); + slots[1] = Some(e); + (s, e) + }); + } + _ => {} // fallthrough + } + if !self.is_anchor_end_match(text) { + return None; + } + match self.ro.match_type { + #[cfg(feature = "perf-literal")] + MatchType::Literal(ty) => { + self.find_literals(ty, text, start).and_then(|(s, e)| { + self.captures_nfa_type( + MatchNfaType::Auto, + slots, + text, + s, + e, + ) + }) + } + #[cfg(feature = "perf-dfa")] + MatchType::Dfa => { + if self.ro.nfa.is_anchored_start { + self.captures_nfa(slots, text, start) + } else { + match self.find_dfa_forward(text, start) { + dfa::Result::Match((s, e)) => self.captures_nfa_type( + MatchNfaType::Auto, + slots, + text, + s, + e, + ), + dfa::Result::NoMatch(_) => None, + dfa::Result::Quit => { + self.captures_nfa(slots, text, start) + } + } + } + } + #[cfg(feature = "perf-dfa")] + MatchType::DfaAnchoredReverse => { + match self.find_dfa_anchored_reverse(text, start) { + dfa::Result::Match((s, e)) => self.captures_nfa_type( + MatchNfaType::Auto, + slots, + text, + s, + e, + ), + dfa::Result::NoMatch(_) => None, + dfa::Result::Quit => self.captures_nfa(slots, text, start), + } + } + #[cfg(all(feature = "perf-dfa", feature = "perf-literal"))] + MatchType::DfaSuffix => { + match self.find_dfa_reverse_suffix(text, start) { + dfa::Result::Match((s, e)) => self.captures_nfa_type( + MatchNfaType::Auto, + slots, + text, + s, + e, + ), + dfa::Result::NoMatch(_) => None, + dfa::Result::Quit => self.captures_nfa(slots, text, start), + } + } + MatchType::Nfa(ty) => { + self.captures_nfa_type(ty, slots, text, start, text.len()) + } + MatchType::Nothing => None, + #[cfg(feature = "perf-dfa")] + MatchType::DfaMany => { + unreachable!("BUG: RegexSet cannot be used with captures") + } + } + } +} + +impl<'c> ExecNoSync<'c> { + /// Finds the leftmost-first match using only literal search. + #[cfg(feature = "perf-literal")] + #[cfg_attr(feature = "perf-inline", inline(always))] + fn find_literals( + &self, + ty: MatchLiteralType, + text: &[u8], + start: usize, + ) -> Option<(usize, usize)> { + use self::MatchLiteralType::*; + match ty { + Unanchored => { + let lits = &self.ro.nfa.prefixes; + lits.find(&text[start..]).map(|(s, e)| (start + s, start + e)) + } + AnchoredStart => { + let lits = &self.ro.nfa.prefixes; + if start == 0 || !self.ro.nfa.is_anchored_start { + lits.find_start(&text[start..]) + .map(|(s, e)| (start + s, start + e)) + } else { + None + } + } + AnchoredEnd => { + let lits = &self.ro.suffixes; + lits.find_end(&text[start..]) + .map(|(s, e)| (start + s, start + e)) + } + AhoCorasick => self + .ro + .ac + .as_ref() + .unwrap() + .find(&text[start..]) + .map(|m| (start + m.start(), start + m.end())), + } + } + + /// Finds the leftmost-first match (start and end) using only the DFA. + /// + /// If the result returned indicates that the DFA quit, then another + /// matching engine should be used. + #[cfg(feature = "perf-dfa")] + #[cfg_attr(feature = "perf-inline", inline(always))] + fn find_dfa_forward( + &self, + text: &[u8], + start: usize, + ) -> dfa::Result<(usize, usize)> { + use dfa::Result::*; + let end = match dfa::Fsm::forward( + &self.ro.dfa, + self.cache.value(), + false, + text, + start, + ) { + NoMatch(i) => return NoMatch(i), + Quit => return Quit, + Match(end) if start == end => return Match((start, start)), + Match(end) => end, + }; + // Now run the DFA in reverse to find the start of the match. + match dfa::Fsm::reverse( + &self.ro.dfa_reverse, + self.cache.value(), + false, + &text[start..], + end - start, + ) { + Match(s) => Match((start + s, end)), + NoMatch(i) => NoMatch(i), + Quit => Quit, + } + } + + /// Finds the leftmost-first match (start and end) using only the DFA, + /// but assumes the regex is anchored at the end and therefore starts at + /// the end of the regex and matches in reverse. + /// + /// If the result returned indicates that the DFA quit, then another + /// matching engine should be used. + #[cfg(feature = "perf-dfa")] + #[cfg_attr(feature = "perf-inline", inline(always))] + fn find_dfa_anchored_reverse( + &self, + text: &[u8], + start: usize, + ) -> dfa::Result<(usize, usize)> { + use dfa::Result::*; + match dfa::Fsm::reverse( + &self.ro.dfa_reverse, + self.cache.value(), + false, + &text[start..], + text.len() - start, + ) { + Match(s) => Match((start + s, text.len())), + NoMatch(i) => NoMatch(i), + Quit => Quit, + } + } + + /// Finds the end of the shortest match using only the DFA. + #[cfg(feature = "perf-dfa")] + #[cfg_attr(feature = "perf-inline", inline(always))] + fn shortest_dfa(&self, text: &[u8], start: usize) -> dfa::Result { + dfa::Fsm::forward(&self.ro.dfa, self.cache.value(), true, text, start) + } + + /// Finds the end of the shortest match using only the DFA by scanning for + /// suffix literals. + #[cfg(all(feature = "perf-dfa", feature = "perf-literal"))] + #[cfg_attr(feature = "perf-inline", inline(always))] + fn shortest_dfa_reverse_suffix( + &self, + text: &[u8], + start: usize, + ) -> dfa::Result { + match self.exec_dfa_reverse_suffix(text, start) { + None => self.shortest_dfa(text, start), + Some(r) => r.map(|(_, end)| end), + } + } + + /// Finds the end of the shortest match using only the DFA by scanning for + /// suffix literals. It also reports the start of the match. + /// + /// Note that if None is returned, then the optimization gave up to avoid + /// worst case quadratic behavior. A forward scanning DFA should be tried + /// next. + /// + /// If a match is returned and the full leftmost-first match is desired, + /// then a forward scan starting from the beginning of the match must be + /// done. + /// + /// If the result returned indicates that the DFA quit, then another + /// matching engine should be used. + #[cfg(all(feature = "perf-dfa", feature = "perf-literal"))] + #[cfg_attr(feature = "perf-inline", inline(always))] + fn exec_dfa_reverse_suffix( + &self, + text: &[u8], + original_start: usize, + ) -> Option> { + use dfa::Result::*; + + let lcs = self.ro.suffixes.lcs(); + debug_assert!(lcs.len() >= 1); + let mut start = original_start; + let mut end = start; + let mut last_literal = start; + while end <= text.len() { + last_literal += match lcs.find(&text[last_literal..]) { + None => return Some(NoMatch(text.len())), + Some(i) => i, + }; + end = last_literal + lcs.len(); + match dfa::Fsm::reverse( + &self.ro.dfa_reverse, + self.cache.value(), + false, + &text[start..end], + end - start, + ) { + Match(0) | NoMatch(0) => return None, + Match(i) => return Some(Match((start + i, end))), + NoMatch(i) => { + start += i; + last_literal += 1; + continue; + } + Quit => return Some(Quit), + }; + } + Some(NoMatch(text.len())) + } + + /// Finds the leftmost-first match (start and end) using only the DFA + /// by scanning for suffix literals. + /// + /// If the result returned indicates that the DFA quit, then another + /// matching engine should be used. + #[cfg(all(feature = "perf-dfa", feature = "perf-literal"))] + #[cfg_attr(feature = "perf-inline", inline(always))] + fn find_dfa_reverse_suffix( + &self, + text: &[u8], + start: usize, + ) -> dfa::Result<(usize, usize)> { + use dfa::Result::*; + + let match_start = match self.exec_dfa_reverse_suffix(text, start) { + None => return self.find_dfa_forward(text, start), + Some(Match((start, _))) => start, + Some(r) => return r, + }; + // At this point, we've found a match. The only way to quit now + // without a match is if the DFA gives up (seems unlikely). + // + // Now run the DFA forwards to find the proper end of the match. + // (The suffix literal match can only indicate the earliest + // possible end location, which may appear before the end of the + // leftmost-first match.) + match dfa::Fsm::forward( + &self.ro.dfa, + self.cache.value(), + false, + text, + match_start, + ) { + NoMatch(_) => panic!("BUG: reverse match implies forward match"), + Quit => Quit, + Match(e) => Match((match_start, e)), + } + } + + /// Executes the NFA engine to return whether there is a match or not. + /// + /// Ideally, we could use shortest_nfa(...).is_some() and get the same + /// performance characteristics, but regex sets don't have captures, which + /// shortest_nfa depends on. + #[cfg(feature = "perf-dfa")] + fn match_nfa(&self, text: &[u8], start: usize) -> bool { + self.match_nfa_type(MatchNfaType::Auto, text, start) + } + + /// Like match_nfa, but allows specification of the type of NFA engine. + fn match_nfa_type( + &self, + ty: MatchNfaType, + text: &[u8], + start: usize, + ) -> bool { + self.exec_nfa( + ty, + &mut [false], + &mut [], + true, + false, + text, + start, + text.len(), + ) + } + + /// Finds the shortest match using an NFA. + #[cfg(feature = "perf-dfa")] + fn shortest_nfa(&self, text: &[u8], start: usize) -> Option { + self.shortest_nfa_type(MatchNfaType::Auto, text, start) + } + + /// Like shortest_nfa, but allows specification of the type of NFA engine. + fn shortest_nfa_type( + &self, + ty: MatchNfaType, + text: &[u8], + start: usize, + ) -> Option { + let mut slots = [None, None]; + if self.exec_nfa( + ty, + &mut [false], + &mut slots, + true, + true, + text, + start, + text.len(), + ) { + slots[1] + } else { + None + } + } + + /// Like find, but executes an NFA engine. + fn find_nfa( + &self, + ty: MatchNfaType, + text: &[u8], + start: usize, + ) -> Option<(usize, usize)> { + let mut slots = [None, None]; + if self.exec_nfa( + ty, + &mut [false], + &mut slots, + false, + false, + text, + start, + text.len(), + ) { + match (slots[0], slots[1]) { + (Some(s), Some(e)) => Some((s, e)), + _ => None, + } + } else { + None + } + } + + /// Like find_nfa, but fills in captures. + /// + /// `slots` should have length equal to `2 * nfa.captures.len()`. + #[cfg(feature = "perf-dfa")] + fn captures_nfa( + &self, + slots: &mut [Slot], + text: &[u8], + start: usize, + ) -> Option<(usize, usize)> { + self.captures_nfa_type( + MatchNfaType::Auto, + slots, + text, + start, + text.len(), + ) + } + + /// Like captures_nfa, but allows specification of type of NFA engine. + fn captures_nfa_type( + &self, + ty: MatchNfaType, + slots: &mut [Slot], + text: &[u8], + start: usize, + end: usize, + ) -> Option<(usize, usize)> { + if self.exec_nfa( + ty, + &mut [false], + slots, + false, + false, + text, + start, + end, + ) { + match (slots[0], slots[1]) { + (Some(s), Some(e)) => Some((s, e)), + _ => None, + } + } else { + None + } + } + + fn exec_nfa( + &self, + mut ty: MatchNfaType, + matches: &mut [bool], + slots: &mut [Slot], + quit_after_match: bool, + quit_after_match_with_pos: bool, + text: &[u8], + start: usize, + end: usize, + ) -> bool { + use self::MatchNfaType::*; + if let Auto = ty { + if backtrack::should_exec(self.ro.nfa.len(), text.len()) { + ty = Backtrack; + } else { + ty = PikeVM; + } + } + // The backtracker can't return the shortest match position as it is + // implemented today. So if someone calls `shortest_match` and we need + // to run an NFA, then use the PikeVM. + if quit_after_match_with_pos || ty == PikeVM { + self.exec_pikevm( + matches, + slots, + quit_after_match, + text, + start, + end, + ) + } else { + self.exec_backtrack(matches, slots, text, start, end) + } + } + + /// Always run the NFA algorithm. + fn exec_pikevm( + &self, + matches: &mut [bool], + slots: &mut [Slot], + quit_after_match: bool, + text: &[u8], + start: usize, + end: usize, + ) -> bool { + if self.ro.nfa.uses_bytes() { + pikevm::Fsm::exec( + &self.ro.nfa, + self.cache.value(), + matches, + slots, + quit_after_match, + ByteInput::new(text, self.ro.nfa.only_utf8), + start, + end, + ) + } else { + pikevm::Fsm::exec( + &self.ro.nfa, + self.cache.value(), + matches, + slots, + quit_after_match, + CharInput::new(text), + start, + end, + ) + } + } + + /// Always runs the NFA using bounded backtracking. + fn exec_backtrack( + &self, + matches: &mut [bool], + slots: &mut [Slot], + text: &[u8], + start: usize, + end: usize, + ) -> bool { + if self.ro.nfa.uses_bytes() { + backtrack::Bounded::exec( + &self.ro.nfa, + self.cache.value(), + matches, + slots, + ByteInput::new(text, self.ro.nfa.only_utf8), + start, + end, + ) + } else { + backtrack::Bounded::exec( + &self.ro.nfa, + self.cache.value(), + matches, + slots, + CharInput::new(text), + start, + end, + ) + } + } + + /// Finds which regular expressions match the given text. + /// + /// `matches` should have length equal to the number of regexes being + /// searched. + /// + /// This is only useful when one wants to know which regexes in a set + /// match some text. + pub fn many_matches_at( + &self, + matches: &mut [bool], + text: &[u8], + start: usize, + ) -> bool { + use self::MatchType::*; + if !self.is_anchor_end_match(text) { + return false; + } + match self.ro.match_type { + #[cfg(feature = "perf-literal")] + Literal(ty) => { + debug_assert_eq!(matches.len(), 1); + matches[0] = self.find_literals(ty, text, start).is_some(); + matches[0] + } + #[cfg(feature = "perf-dfa")] + Dfa | DfaAnchoredReverse | DfaMany => { + match dfa::Fsm::forward_many( + &self.ro.dfa, + self.cache.value(), + matches, + text, + start, + ) { + dfa::Result::Match(_) => true, + dfa::Result::NoMatch(_) => false, + dfa::Result::Quit => self.exec_nfa( + MatchNfaType::Auto, + matches, + &mut [], + false, + false, + text, + start, + text.len(), + ), + } + } + #[cfg(all(feature = "perf-dfa", feature = "perf-literal"))] + DfaSuffix => { + match dfa::Fsm::forward_many( + &self.ro.dfa, + self.cache.value(), + matches, + text, + start, + ) { + dfa::Result::Match(_) => true, + dfa::Result::NoMatch(_) => false, + dfa::Result::Quit => self.exec_nfa( + MatchNfaType::Auto, + matches, + &mut [], + false, + false, + text, + start, + text.len(), + ), + } + } + Nfa(ty) => self.exec_nfa( + ty, + matches, + &mut [], + false, + false, + text, + start, + text.len(), + ), + Nothing => false, + } + } + + #[cfg_attr(feature = "perf-inline", inline(always))] + fn is_anchor_end_match(&self, text: &[u8]) -> bool { + #[cfg(not(feature = "perf-literal"))] + fn imp(_: &ExecReadOnly, _: &[u8]) -> bool { + true + } + + #[cfg(feature = "perf-literal")] + fn imp(ro: &ExecReadOnly, text: &[u8]) -> bool { + // Only do this check if the haystack is big (>1MB). + if text.len() > (1 << 20) && ro.nfa.is_anchored_end { + let lcs = ro.suffixes.lcs(); + if lcs.len() >= 1 && !lcs.is_suffix(text) { + return false; + } + } + true + } + + imp(&self.ro, text) + } + + pub fn capture_name_idx(&self) -> &Arc> { + &self.ro.nfa.capture_name_idx + } +} + +impl<'c> ExecNoSyncStr<'c> { + pub fn capture_name_idx(&self) -> &Arc> { + self.0.capture_name_idx() + } +} + +impl Exec { + /// Get a searcher that isn't Sync. + #[cfg_attr(feature = "perf-inline", inline(always))] + pub fn searcher(&self) -> ExecNoSync { + let create = || RefCell::new(ProgramCacheInner::new(&self.ro)); + ExecNoSync { + ro: &self.ro, // a clone is too expensive here! (and not needed) + cache: self.cache.get_or(create), + } + } + + /// Get a searcher that isn't Sync and can match on &str. + #[cfg_attr(feature = "perf-inline", inline(always))] + pub fn searcher_str(&self) -> ExecNoSyncStr { + ExecNoSyncStr(self.searcher()) + } + + /// Build a Regex from this executor. + pub fn into_regex(self) -> re_unicode::Regex { + re_unicode::Regex::from(self) + } + + /// Build a RegexSet from this executor. + pub fn into_regex_set(self) -> re_set::unicode::RegexSet { + re_set::unicode::RegexSet::from(self) + } + + /// Build a Regex from this executor that can match arbitrary bytes. + pub fn into_byte_regex(self) -> re_bytes::Regex { + re_bytes::Regex::from(self) + } + + /// Build a RegexSet from this executor that can match arbitrary bytes. + pub fn into_byte_regex_set(self) -> re_set::bytes::RegexSet { + re_set::bytes::RegexSet::from(self) + } + + /// The original regular expressions given by the caller that were + /// compiled. + pub fn regex_strings(&self) -> &[String] { + &self.ro.res + } + + /// Return a slice of capture names. + /// + /// Any capture that isn't named is None. + pub fn capture_names(&self) -> &[Option] { + &self.ro.nfa.captures + } + + /// Return a reference to named groups mapping (from group name to + /// group position). + pub fn capture_name_idx(&self) -> &Arc> { + &self.ro.nfa.capture_name_idx + } +} + +impl Clone for Exec { + fn clone(&self) -> Exec { + Exec { ro: self.ro.clone(), cache: Cached::new() } + } +} + +impl ExecReadOnly { + fn choose_match_type(&self, hint: Option) -> MatchType { + if let Some(MatchType::Nfa(_)) = hint { + return hint.unwrap(); + } + // If the NFA is empty, then we'll never match anything. + if self.nfa.insts.is_empty() { + return MatchType::Nothing; + } + if let Some(literalty) = self.choose_literal_match_type() { + return literalty; + } + if let Some(dfaty) = self.choose_dfa_match_type() { + return dfaty; + } + // We're so totally hosed. + MatchType::Nfa(MatchNfaType::Auto) + } + + /// If a plain literal scan can be used, then a corresponding literal + /// search type is returned. + fn choose_literal_match_type(&self) -> Option { + #[cfg(not(feature = "perf-literal"))] + fn imp(_: &ExecReadOnly) -> Option { + None + } + + #[cfg(feature = "perf-literal")] + fn imp(ro: &ExecReadOnly) -> Option { + // If our set of prefixes is complete, then we can use it to find + // a match in lieu of a regex engine. This doesn't quite work well + // in the presence of multiple regexes, so only do it when there's + // one. + // + // TODO(burntsushi): Also, don't try to match literals if the regex + // is partially anchored. We could technically do it, but we'd need + // to create two sets of literals: all of them and then the subset + // that aren't anchored. We would then only search for all of them + // when at the beginning of the input and use the subset in all + // other cases. + if ro.res.len() != 1 { + return None; + } + if ro.ac.is_some() { + return Some(MatchType::Literal( + MatchLiteralType::AhoCorasick, + )); + } + if ro.nfa.prefixes.complete() { + return if ro.nfa.is_anchored_start { + Some(MatchType::Literal(MatchLiteralType::AnchoredStart)) + } else { + Some(MatchType::Literal(MatchLiteralType::Unanchored)) + }; + } + if ro.suffixes.complete() { + return if ro.nfa.is_anchored_end { + Some(MatchType::Literal(MatchLiteralType::AnchoredEnd)) + } else { + // This case shouldn't happen. When the regex isn't + // anchored, then complete prefixes should imply complete + // suffixes. + Some(MatchType::Literal(MatchLiteralType::Unanchored)) + }; + } + None + } + + imp(self) + } + + /// If a DFA scan can be used, then choose the appropriate DFA strategy. + fn choose_dfa_match_type(&self) -> Option { + #[cfg(not(feature = "perf-dfa"))] + fn imp(_: &ExecReadOnly) -> Option { + None + } + + #[cfg(feature = "perf-dfa")] + fn imp(ro: &ExecReadOnly) -> Option { + if !dfa::can_exec(&ro.dfa) { + return None; + } + // Regex sets require a slightly specialized path. + if ro.res.len() >= 2 { + return Some(MatchType::DfaMany); + } + // If the regex is anchored at the end but not the start, then + // just match in reverse from the end of the haystack. + if !ro.nfa.is_anchored_start && ro.nfa.is_anchored_end { + return Some(MatchType::DfaAnchoredReverse); + } + #[cfg(feature = "perf-literal")] + { + // If there's a longish suffix literal, then it might be faster + // to look for that first. + if ro.should_suffix_scan() { + return Some(MatchType::DfaSuffix); + } + } + // Fall back to your garden variety forward searching lazy DFA. + Some(MatchType::Dfa) + } + + imp(self) + } + + /// Returns true if the program is amenable to suffix scanning. + /// + /// When this is true, as a heuristic, we assume it is OK to quickly scan + /// for suffix literals and then do a *reverse* DFA match from any matches + /// produced by the literal scan. (And then followed by a forward DFA + /// search, since the previously found suffix literal maybe not actually be + /// the end of a match.) + /// + /// This is a bit of a specialized optimization, but can result in pretty + /// big performance wins if 1) there are no prefix literals and 2) the + /// suffix literals are pretty rare in the text. (1) is obviously easy to + /// account for but (2) is harder. As a proxy, we assume that longer + /// strings are generally rarer, so we only enable this optimization when + /// we have a meaty suffix. + #[cfg(all(feature = "perf-dfa", feature = "perf-literal"))] + fn should_suffix_scan(&self) -> bool { + if self.suffixes.is_empty() { + return false; + } + let lcs_len = self.suffixes.lcs().char_len(); + lcs_len >= 3 && lcs_len > self.dfa.prefixes.lcp().char_len() + } +} + +#[derive(Clone, Copy, Debug)] +enum MatchType { + /// A single or multiple literal search. This is only used when the regex + /// can be decomposed into a literal search. + #[cfg(feature = "perf-literal")] + Literal(MatchLiteralType), + /// A normal DFA search. + #[cfg(feature = "perf-dfa")] + Dfa, + /// A reverse DFA search starting from the end of a haystack. + #[cfg(feature = "perf-dfa")] + DfaAnchoredReverse, + /// A reverse DFA search with suffix literal scanning. + #[cfg(all(feature = "perf-dfa", feature = "perf-literal"))] + DfaSuffix, + /// Use the DFA on two or more regular expressions. + #[cfg(feature = "perf-dfa")] + DfaMany, + /// An NFA variant. + Nfa(MatchNfaType), + /// No match is ever possible, so don't ever try to search. + Nothing, +} + +#[derive(Clone, Copy, Debug)] +#[cfg(feature = "perf-literal")] +enum MatchLiteralType { + /// Match literals anywhere in text. + Unanchored, + /// Match literals only at the start of text. + AnchoredStart, + /// Match literals only at the end of text. + AnchoredEnd, + /// Use an Aho-Corasick automaton. This requires `ac` to be Some on + /// ExecReadOnly. + AhoCorasick, +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +enum MatchNfaType { + /// Choose between Backtrack and PikeVM. + Auto, + /// NFA bounded backtracking. + /// + /// (This is only set by tests, since it never makes sense to always want + /// backtracking.) + Backtrack, + /// The Pike VM. + /// + /// (This is only set by tests, since it never makes sense to always want + /// the Pike VM.) + PikeVM, +} + +/// `ProgramCache` maintains reusable allocations for each matching engine +/// available to a particular program. +pub type ProgramCache = RefCell; + +#[derive(Debug)] +pub struct ProgramCacheInner { + pub pikevm: pikevm::Cache, + pub backtrack: backtrack::Cache, + #[cfg(feature = "perf-dfa")] + pub dfa: dfa::Cache, + #[cfg(feature = "perf-dfa")] + pub dfa_reverse: dfa::Cache, +} + +impl ProgramCacheInner { + fn new(ro: &ExecReadOnly) -> Self { + ProgramCacheInner { + pikevm: pikevm::Cache::new(&ro.nfa), + backtrack: backtrack::Cache::new(&ro.nfa), + #[cfg(feature = "perf-dfa")] + dfa: dfa::Cache::new(&ro.dfa), + #[cfg(feature = "perf-dfa")] + dfa_reverse: dfa::Cache::new(&ro.dfa_reverse), + } + } +} + +/// Alternation literals checks if the given HIR is a simple alternation of +/// literals, and if so, returns them. Otherwise, this returns None. +#[cfg(feature = "perf-literal")] +fn alternation_literals(expr: &Hir) -> Option>> { + use syntax::hir::{HirKind, Literal}; + + // This is pretty hacky, but basically, if `is_alternation_literal` is + // true, then we can make several assumptions about the structure of our + // HIR. This is what justifies the `unreachable!` statements below. + // + // This code should be refactored once we overhaul this crate's + // optimization pipeline, because this is a terribly inflexible way to go + // about things. + + if !expr.is_alternation_literal() { + return None; + } + let alts = match *expr.kind() { + HirKind::Alternation(ref alts) => alts, + _ => return None, // one literal isn't worth it + }; + + let extendlit = |lit: &Literal, dst: &mut Vec| match *lit { + Literal::Unicode(c) => { + let mut buf = [0; 4]; + dst.extend_from_slice(c.encode_utf8(&mut buf).as_bytes()); + } + Literal::Byte(b) => { + dst.push(b); + } + }; + + let mut lits = vec![]; + for alt in alts { + let mut lit = vec![]; + match *alt.kind() { + HirKind::Literal(ref x) => extendlit(x, &mut lit), + HirKind::Concat(ref exprs) => { + for e in exprs { + match *e.kind() { + HirKind::Literal(ref x) => extendlit(x, &mut lit), + _ => unreachable!("expected literal, got {:?}", e), + } + } + } + _ => unreachable!("expected literal or concat, got {:?}", alt), + } + lits.push(lit); + } + Some(lits) +} + +#[cfg(test)] +mod test { + #[test] + fn uppercut_s_backtracking_bytes_default_bytes_mismatch() { + use internal::ExecBuilder; + + let backtrack_bytes_re = ExecBuilder::new("^S") + .bounded_backtracking() + .only_utf8(false) + .build() + .map(|exec| exec.into_byte_regex()) + .map_err(|err| format!("{}", err)) + .unwrap(); + + let default_bytes_re = ExecBuilder::new("^S") + .only_utf8(false) + .build() + .map(|exec| exec.into_byte_regex()) + .map_err(|err| format!("{}", err)) + .unwrap(); + + let input = vec![83, 83]; + + let s1 = backtrack_bytes_re.split(&input); + let s2 = default_bytes_re.split(&input); + for (chunk1, chunk2) in s1.zip(s2) { + assert_eq!(chunk1, chunk2); + } + } + + #[test] + fn unicode_lit_star_backtracking_utf8bytes_default_utf8bytes_mismatch() { + use internal::ExecBuilder; + + let backtrack_bytes_re = ExecBuilder::new(r"^(?u:\*)") + .bounded_backtracking() + .bytes(true) + .build() + .map(|exec| exec.into_regex()) + .map_err(|err| format!("{}", err)) + .unwrap(); + + let default_bytes_re = ExecBuilder::new(r"^(?u:\*)") + .bytes(true) + .build() + .map(|exec| exec.into_regex()) + .map_err(|err| format!("{}", err)) + .unwrap(); + + let input = "**"; + + let s1 = backtrack_bytes_re.split(input); + let s2 = default_bytes_re.split(input); + for (chunk1, chunk2) in s1.zip(s2) { + assert_eq!(chunk1, chunk2); + } + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/expand.rs b/third_party/cargo/vendor/regex-1.3.3/src/expand.rs new file mode 100644 index 0000000..528f55e --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/expand.rs @@ -0,0 +1,220 @@ +use std::str; + +use find_byte::find_byte; + +use re_bytes; +use re_unicode; + +pub fn expand_str( + caps: &re_unicode::Captures, + mut replacement: &str, + dst: &mut String, +) { + while !replacement.is_empty() { + match find_byte(b'$', replacement.as_bytes()) { + None => break, + Some(i) => { + dst.push_str(&replacement[..i]); + replacement = &replacement[i..]; + } + } + if replacement.as_bytes().get(1).map_or(false, |&b| b == b'$') { + dst.push_str("$"); + replacement = &replacement[2..]; + continue; + } + debug_assert!(!replacement.is_empty()); + let cap_ref = match find_cap_ref(replacement) { + Some(cap_ref) => cap_ref, + None => { + dst.push_str("$"); + replacement = &replacement[1..]; + continue; + } + }; + replacement = &replacement[cap_ref.end..]; + match cap_ref.cap { + Ref::Number(i) => { + dst.push_str(caps.get(i).map(|m| m.as_str()).unwrap_or("")); + } + Ref::Named(name) => { + dst.push_str( + caps.name(name).map(|m| m.as_str()).unwrap_or(""), + ); + } + } + } + dst.push_str(replacement); +} + +pub fn expand_bytes( + caps: &re_bytes::Captures, + mut replacement: &[u8], + dst: &mut Vec, +) { + while !replacement.is_empty() { + match find_byte(b'$', replacement) { + None => break, + Some(i) => { + dst.extend(&replacement[..i]); + replacement = &replacement[i..]; + } + } + if replacement.get(1).map_or(false, |&b| b == b'$') { + dst.push(b'$'); + replacement = &replacement[2..]; + continue; + } + debug_assert!(!replacement.is_empty()); + let cap_ref = match find_cap_ref(replacement) { + Some(cap_ref) => cap_ref, + None => { + dst.push(b'$'); + replacement = &replacement[1..]; + continue; + } + }; + replacement = &replacement[cap_ref.end..]; + match cap_ref.cap { + Ref::Number(i) => { + dst.extend(caps.get(i).map(|m| m.as_bytes()).unwrap_or(b"")); + } + Ref::Named(name) => { + dst.extend( + caps.name(name).map(|m| m.as_bytes()).unwrap_or(b""), + ); + } + } + } + dst.extend(replacement); +} + +/// `CaptureRef` represents a reference to a capture group inside some text. +/// The reference is either a capture group name or a number. +/// +/// It is also tagged with the position in the text following the +/// capture reference. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +struct CaptureRef<'a> { + cap: Ref<'a>, + end: usize, +} + +/// A reference to a capture group in some text. +/// +/// e.g., `$2`, `$foo`, `${foo}`. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +enum Ref<'a> { + Named(&'a str), + Number(usize), +} + +impl<'a> From<&'a str> for Ref<'a> { + fn from(x: &'a str) -> Ref<'a> { + Ref::Named(x) + } +} + +impl From for Ref<'static> { + fn from(x: usize) -> Ref<'static> { + Ref::Number(x) + } +} + +/// Parses a possible reference to a capture group name in the given text, +/// starting at the beginning of `replacement`. +/// +/// If no such valid reference could be found, None is returned. +fn find_cap_ref>( + replacement: &T, +) -> Option { + let mut i = 0; + let rep: &[u8] = replacement.as_ref(); + if rep.len() <= 1 || rep[0] != b'$' { + return None; + } + let mut brace = false; + i += 1; + if rep[i] == b'{' { + brace = true; + i += 1; + } + let mut cap_end = i; + while rep.get(cap_end).map_or(false, is_valid_cap_letter) { + cap_end += 1; + } + if cap_end == i { + return None; + } + // We just verified that the range 0..cap_end is valid ASCII, so it must + // therefore be valid UTF-8. If we really cared, we could avoid this UTF-8 + // check with either unsafe or by parsing the number straight from &[u8]. + let cap = + str::from_utf8(&rep[i..cap_end]).expect("valid UTF-8 capture name"); + if brace { + if !rep.get(cap_end).map_or(false, |&b| b == b'}') { + return None; + } + cap_end += 1; + } + Some(CaptureRef { + cap: match cap.parse::() { + Ok(i) => Ref::Number(i as usize), + Err(_) => Ref::Named(cap), + }, + end: cap_end, + }) +} + +/// Returns true if and only if the given byte is allowed in a capture name. +fn is_valid_cap_letter(b: &u8) -> bool { + match *b { + b'0'..=b'9' | b'a'..=b'z' | b'A'..=b'Z' | b'_' => true, + _ => false, + } +} + +#[cfg(test)] +mod tests { + use super::{find_cap_ref, CaptureRef}; + + macro_rules! find { + ($name:ident, $text:expr) => { + #[test] + fn $name() { + assert_eq!(None, find_cap_ref($text)); + } + }; + ($name:ident, $text:expr, $capref:expr) => { + #[test] + fn $name() { + assert_eq!(Some($capref), find_cap_ref($text)); + } + }; + } + + macro_rules! c { + ($name_or_number:expr, $pos:expr) => { + CaptureRef { cap: $name_or_number.into(), end: $pos } + }; + } + + find!(find_cap_ref1, "$foo", c!("foo", 4)); + find!(find_cap_ref2, "${foo}", c!("foo", 6)); + find!(find_cap_ref3, "$0", c!(0, 2)); + find!(find_cap_ref4, "$5", c!(5, 2)); + find!(find_cap_ref5, "$10", c!(10, 3)); + // see https://github.com/rust-lang/regex/pull/585 for more on characters following numbers + find!(find_cap_ref6, "$42a", c!("42a", 4)); + find!(find_cap_ref7, "${42}a", c!(42, 5)); + find!(find_cap_ref8, "${42"); + find!(find_cap_ref9, "${42 "); + find!(find_cap_ref10, " $0 "); + find!(find_cap_ref11, "$"); + find!(find_cap_ref12, " "); + find!(find_cap_ref13, ""); + find!(find_cap_ref14, "$1-$2", c!(1, 2)); + find!(find_cap_ref15, "$1_$2", c!("1_", 3)); + find!(find_cap_ref16, "$x-$y", c!("x", 2)); + find!(find_cap_ref17, "$x_$y", c!("x_", 3)); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/find_byte.rs b/third_party/cargo/vendor/regex-1.3.3/src/find_byte.rs new file mode 100644 index 0000000..e95f72a --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/find_byte.rs @@ -0,0 +1,18 @@ +/// Searches for the given needle in the given haystack. +/// +/// If the perf-literal feature is enabled, then this uses the super optimized +/// memchr crate. Otherwise, it uses the naive byte-at-a-time implementation. +pub fn find_byte(needle: u8, haystack: &[u8]) -> Option { + #[cfg(not(feature = "perf-literal"))] + fn imp(needle: u8, haystack: &[u8]) -> Option { + haystack.iter().position(|&b| b == needle) + } + + #[cfg(feature = "perf-literal")] + fn imp(needle: u8, haystack: &[u8]) -> Option { + use memchr::memchr; + memchr(needle, haystack) + } + + imp(needle, haystack) +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/freqs.rs b/third_party/cargo/vendor/regex-1.3.3/src/freqs.rs new file mode 100644 index 0000000..fcffa95 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/freqs.rs @@ -0,0 +1,261 @@ +// NOTE: The following code was generated by "scripts/frequencies.py", do not +// edit directly + +pub const BYTE_FREQUENCIES: [u8; 256] = [ + 55, // '\x00' + 52, // '\x01' + 51, // '\x02' + 50, // '\x03' + 49, // '\x04' + 48, // '\x05' + 47, // '\x06' + 46, // '\x07' + 45, // '\x08' + 103, // '\t' + 242, // '\n' + 66, // '\x0b' + 67, // '\x0c' + 229, // '\r' + 44, // '\x0e' + 43, // '\x0f' + 42, // '\x10' + 41, // '\x11' + 40, // '\x12' + 39, // '\x13' + 38, // '\x14' + 37, // '\x15' + 36, // '\x16' + 35, // '\x17' + 34, // '\x18' + 33, // '\x19' + 56, // '\x1a' + 32, // '\x1b' + 31, // '\x1c' + 30, // '\x1d' + 29, // '\x1e' + 28, // '\x1f' + 255, // ' ' + 148, // '!' + 164, // '"' + 149, // '#' + 136, // '$' + 160, // '%' + 155, // '&' + 173, // "'" + 221, // '(' + 222, // ')' + 134, // '*' + 122, // '+' + 232, // ',' + 202, // '-' + 215, // '.' + 224, // '/' + 208, // '0' + 220, // '1' + 204, // '2' + 187, // '3' + 183, // '4' + 179, // '5' + 177, // '6' + 168, // '7' + 178, // '8' + 200, // '9' + 226, // ':' + 195, // ';' + 154, // '<' + 184, // '=' + 174, // '>' + 126, // '?' + 120, // '@' + 191, // 'A' + 157, // 'B' + 194, // 'C' + 170, // 'D' + 189, // 'E' + 162, // 'F' + 161, // 'G' + 150, // 'H' + 193, // 'I' + 142, // 'J' + 137, // 'K' + 171, // 'L' + 176, // 'M' + 185, // 'N' + 167, // 'O' + 186, // 'P' + 112, // 'Q' + 175, // 'R' + 192, // 'S' + 188, // 'T' + 156, // 'U' + 140, // 'V' + 143, // 'W' + 123, // 'X' + 133, // 'Y' + 128, // 'Z' + 147, // '[' + 138, // '\\' + 146, // ']' + 114, // '^' + 223, // '_' + 151, // '`' + 249, // 'a' + 216, // 'b' + 238, // 'c' + 236, // 'd' + 253, // 'e' + 227, // 'f' + 218, // 'g' + 230, // 'h' + 247, // 'i' + 135, // 'j' + 180, // 'k' + 241, // 'l' + 233, // 'm' + 246, // 'n' + 244, // 'o' + 231, // 'p' + 139, // 'q' + 245, // 'r' + 243, // 's' + 251, // 't' + 235, // 'u' + 201, // 'v' + 196, // 'w' + 240, // 'x' + 214, // 'y' + 152, // 'z' + 182, // '{' + 205, // '|' + 181, // '}' + 127, // '~' + 27, // '\x7f' + 212, // '\x80' + 211, // '\x81' + 210, // '\x82' + 213, // '\x83' + 228, // '\x84' + 197, // '\x85' + 169, // '\x86' + 159, // '\x87' + 131, // '\x88' + 172, // '\x89' + 105, // '\x8a' + 80, // '\x8b' + 98, // '\x8c' + 96, // '\x8d' + 97, // '\x8e' + 81, // '\x8f' + 207, // '\x90' + 145, // '\x91' + 116, // '\x92' + 115, // '\x93' + 144, // '\x94' + 130, // '\x95' + 153, // '\x96' + 121, // '\x97' + 107, // '\x98' + 132, // '\x99' + 109, // '\x9a' + 110, // '\x9b' + 124, // '\x9c' + 111, // '\x9d' + 82, // '\x9e' + 108, // '\x9f' + 118, // '\xa0' + 141, // '¡' + 113, // '¢' + 129, // '£' + 119, // '¤' + 125, // '¥' + 165, // '¦' + 117, // '§' + 92, // '¨' + 106, // '©' + 83, // 'ª' + 72, // '«' + 99, // '¬' + 93, // '\xad' + 65, // '®' + 79, // '¯' + 166, // '°' + 237, // '±' + 163, // '²' + 199, // '³' + 190, // '´' + 225, // 'µ' + 209, // '¶' + 203, // '·' + 198, // '¸' + 217, // '¹' + 219, // 'º' + 206, // '»' + 234, // '¼' + 248, // '½' + 158, // '¾' + 239, // '¿' + 255, // 'À' + 255, // 'Á' + 255, // 'Â' + 255, // 'Ã' + 255, // 'Ä' + 255, // 'Å' + 255, // 'Æ' + 255, // 'Ç' + 255, // 'È' + 255, // 'É' + 255, // 'Ê' + 255, // 'Ë' + 255, // 'Ì' + 255, // 'Í' + 255, // 'Î' + 255, // 'Ï' + 255, // 'Ð' + 255, // 'Ñ' + 255, // 'Ò' + 255, // 'Ó' + 255, // 'Ô' + 255, // 'Õ' + 255, // 'Ö' + 255, // '×' + 255, // 'Ø' + 255, // 'Ù' + 255, // 'Ú' + 255, // 'Û' + 255, // 'Ü' + 255, // 'Ý' + 255, // 'Þ' + 255, // 'ß' + 255, // 'à' + 255, // 'á' + 255, // 'â' + 255, // 'ã' + 255, // 'ä' + 255, // 'å' + 255, // 'æ' + 255, // 'ç' + 255, // 'è' + 255, // 'é' + 255, // 'ê' + 255, // 'ë' + 255, // 'ì' + 255, // 'í' + 255, // 'î' + 255, // 'ï' + 255, // 'ð' + 255, // 'ñ' + 255, // 'ò' + 255, // 'ó' + 255, // 'ô' + 255, // 'õ' + 255, // 'ö' + 255, // '÷' + 255, // 'ø' + 255, // 'ù' + 255, // 'ú' + 255, // 'û' + 255, // 'ü' + 255, // 'ý' + 255, // 'þ' + 255, // 'ÿ' +]; diff --git a/third_party/cargo/vendor/regex-1.3.3/src/input.rs b/third_party/cargo/vendor/regex-1.3.3/src/input.rs new file mode 100644 index 0000000..3afa2d0 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/input.rs @@ -0,0 +1,434 @@ +use std::char; +use std::cmp::Ordering; +use std::fmt; +use std::ops; +use std::u32; + +use syntax; + +use literal::LiteralSearcher; +use prog::InstEmptyLook; +use utf8::{decode_last_utf8, decode_utf8}; + +/// Represents a location in the input. +#[derive(Clone, Copy, Debug)] +pub struct InputAt { + pos: usize, + c: Char, + byte: Option, + len: usize, +} + +impl InputAt { + /// Returns true iff this position is at the beginning of the input. + pub fn is_start(&self) -> bool { + self.pos == 0 + } + + /// Returns true iff this position is past the end of the input. + pub fn is_end(&self) -> bool { + self.c.is_none() && self.byte.is_none() + } + + /// Returns the character at this position. + /// + /// If this position is just before or after the input, then an absent + /// character is returned. + pub fn char(&self) -> Char { + self.c + } + + /// Returns the byte at this position. + pub fn byte(&self) -> Option { + self.byte + } + + /// Returns the UTF-8 width of the character at this position. + pub fn len(&self) -> usize { + self.len + } + + /// Returns whether the UTF-8 width of the character at this position + /// is zero. + pub fn is_empty(&self) -> bool { + self.len == 0 + } + + /// Returns the byte offset of this position. + pub fn pos(&self) -> usize { + self.pos + } + + /// Returns the byte offset of the next position in the input. + pub fn next_pos(&self) -> usize { + self.pos + self.len + } +} + +/// An abstraction over input used in the matching engines. +pub trait Input: fmt::Debug { + /// Return an encoding of the position at byte offset `i`. + fn at(&self, i: usize) -> InputAt; + + /// Return the Unicode character occurring next to `at`. + /// + /// If no such character could be decoded, then `Char` is absent. + fn next_char(&self, at: InputAt) -> Char; + + /// Return the Unicode character occurring previous to `at`. + /// + /// If no such character could be decoded, then `Char` is absent. + fn previous_char(&self, at: InputAt) -> Char; + + /// Return true if the given empty width instruction matches at the + /// input position given. + fn is_empty_match(&self, at: InputAt, empty: &InstEmptyLook) -> bool; + + /// Scan the input for a matching prefix. + fn prefix_at( + &self, + prefixes: &LiteralSearcher, + at: InputAt, + ) -> Option; + + /// The number of bytes in the input. + fn len(&self) -> usize; + + /// Whether the input is empty. + fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Return the given input as a sequence of bytes. + fn as_bytes(&self) -> &[u8]; +} + +impl<'a, T: Input> Input for &'a T { + fn at(&self, i: usize) -> InputAt { + (**self).at(i) + } + + fn next_char(&self, at: InputAt) -> Char { + (**self).next_char(at) + } + + fn previous_char(&self, at: InputAt) -> Char { + (**self).previous_char(at) + } + + fn is_empty_match(&self, at: InputAt, empty: &InstEmptyLook) -> bool { + (**self).is_empty_match(at, empty) + } + + fn prefix_at( + &self, + prefixes: &LiteralSearcher, + at: InputAt, + ) -> Option { + (**self).prefix_at(prefixes, at) + } + + fn len(&self) -> usize { + (**self).len() + } + + fn as_bytes(&self) -> &[u8] { + (**self).as_bytes() + } +} + +/// An input reader over characters. +#[derive(Clone, Copy, Debug)] +pub struct CharInput<'t>(&'t [u8]); + +impl<'t> CharInput<'t> { + /// Return a new character input reader for the given string. + pub fn new(s: &'t [u8]) -> CharInput<'t> { + CharInput(s) + } +} + +impl<'t> ops::Deref for CharInput<'t> { + type Target = [u8]; + + fn deref(&self) -> &[u8] { + self.0 + } +} + +impl<'t> Input for CharInput<'t> { + fn at(&self, i: usize) -> InputAt { + if i >= self.len() { + InputAt { pos: self.len(), c: None.into(), byte: None, len: 0 } + } else { + let c = decode_utf8(&self[i..]).map(|(c, _)| c).into(); + InputAt { pos: i, c: c, byte: None, len: c.len_utf8() } + } + } + + fn next_char(&self, at: InputAt) -> Char { + at.char() + } + + fn previous_char(&self, at: InputAt) -> Char { + decode_last_utf8(&self[..at.pos()]).map(|(c, _)| c).into() + } + + fn is_empty_match(&self, at: InputAt, empty: &InstEmptyLook) -> bool { + use prog::EmptyLook::*; + match empty.look { + StartLine => { + let c = self.previous_char(at); + at.pos() == 0 || c == '\n' + } + EndLine => { + let c = self.next_char(at); + at.pos() == self.len() || c == '\n' + } + StartText => at.pos() == 0, + EndText => at.pos() == self.len(), + WordBoundary => { + let (c1, c2) = (self.previous_char(at), self.next_char(at)); + c1.is_word_char() != c2.is_word_char() + } + NotWordBoundary => { + let (c1, c2) = (self.previous_char(at), self.next_char(at)); + c1.is_word_char() == c2.is_word_char() + } + WordBoundaryAscii => { + let (c1, c2) = (self.previous_char(at), self.next_char(at)); + c1.is_word_byte() != c2.is_word_byte() + } + NotWordBoundaryAscii => { + let (c1, c2) = (self.previous_char(at), self.next_char(at)); + c1.is_word_byte() == c2.is_word_byte() + } + } + } + + fn prefix_at( + &self, + prefixes: &LiteralSearcher, + at: InputAt, + ) -> Option { + prefixes.find(&self[at.pos()..]).map(|(s, _)| self.at(at.pos() + s)) + } + + fn len(&self) -> usize { + self.0.len() + } + + fn as_bytes(&self) -> &[u8] { + self.0 + } +} + +/// An input reader over bytes. +#[derive(Clone, Copy, Debug)] +pub struct ByteInput<'t> { + text: &'t [u8], + only_utf8: bool, +} + +impl<'t> ByteInput<'t> { + /// Return a new byte-based input reader for the given string. + pub fn new(text: &'t [u8], only_utf8: bool) -> ByteInput<'t> { + ByteInput { text: text, only_utf8: only_utf8 } + } +} + +impl<'t> ops::Deref for ByteInput<'t> { + type Target = [u8]; + + fn deref(&self) -> &[u8] { + self.text + } +} + +impl<'t> Input for ByteInput<'t> { + fn at(&self, i: usize) -> InputAt { + if i >= self.len() { + InputAt { pos: self.len(), c: None.into(), byte: None, len: 0 } + } else { + InputAt { + pos: i, + c: None.into(), + byte: self.get(i).cloned(), + len: 1, + } + } + } + + fn next_char(&self, at: InputAt) -> Char { + decode_utf8(&self[at.pos()..]).map(|(c, _)| c).into() + } + + fn previous_char(&self, at: InputAt) -> Char { + decode_last_utf8(&self[..at.pos()]).map(|(c, _)| c).into() + } + + fn is_empty_match(&self, at: InputAt, empty: &InstEmptyLook) -> bool { + use prog::EmptyLook::*; + match empty.look { + StartLine => { + let c = self.previous_char(at); + at.pos() == 0 || c == '\n' + } + EndLine => { + let c = self.next_char(at); + at.pos() == self.len() || c == '\n' + } + StartText => at.pos() == 0, + EndText => at.pos() == self.len(), + WordBoundary => { + let (c1, c2) = (self.previous_char(at), self.next_char(at)); + c1.is_word_char() != c2.is_word_char() + } + NotWordBoundary => { + let (c1, c2) = (self.previous_char(at), self.next_char(at)); + c1.is_word_char() == c2.is_word_char() + } + WordBoundaryAscii => { + let (c1, c2) = (self.previous_char(at), self.next_char(at)); + if self.only_utf8 { + // If we must match UTF-8, then we can't match word + // boundaries at invalid UTF-8. + if c1.is_none() && !at.is_start() { + return false; + } + if c2.is_none() && !at.is_end() { + return false; + } + } + c1.is_word_byte() != c2.is_word_byte() + } + NotWordBoundaryAscii => { + let (c1, c2) = (self.previous_char(at), self.next_char(at)); + if self.only_utf8 { + // If we must match UTF-8, then we can't match word + // boundaries at invalid UTF-8. + if c1.is_none() && !at.is_start() { + return false; + } + if c2.is_none() && !at.is_end() { + return false; + } + } + c1.is_word_byte() == c2.is_word_byte() + } + } + } + + fn prefix_at( + &self, + prefixes: &LiteralSearcher, + at: InputAt, + ) -> Option { + prefixes.find(&self[at.pos()..]).map(|(s, _)| self.at(at.pos() + s)) + } + + fn len(&self) -> usize { + self.text.len() + } + + fn as_bytes(&self) -> &[u8] { + self.text + } +} + +/// An inline representation of `Option`. +/// +/// This eliminates the need to do case analysis on `Option` to determine +/// ordinality with other characters. +/// +/// (The `Option` is not related to encoding. Instead, it is used in the +/// matching engines to represent the beginning and ending boundaries of the +/// search text.) +#[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub struct Char(u32); + +impl fmt::Debug for Char { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match char::from_u32(self.0) { + None => write!(f, "Empty"), + Some(c) => write!(f, "{:?}", c), + } + } +} + +impl Char { + /// Returns true iff the character is absent. + #[inline] + pub fn is_none(self) -> bool { + self.0 == u32::MAX + } + + /// Returns the length of the character's UTF-8 encoding. + /// + /// If the character is absent, then `1` is returned. + #[inline] + pub fn len_utf8(self) -> usize { + char::from_u32(self.0).map_or(1, |c| c.len_utf8()) + } + + /// Returns true iff the character is a word character. + /// + /// If the character is absent, then false is returned. + pub fn is_word_char(self) -> bool { + // is_word_character can panic if the Unicode data for \w isn't + // available. However, our compiler ensures that if a Unicode word + // boundary is used, then the data must also be available. If it isn't, + // then the compiler returns an error. + char::from_u32(self.0).map_or(false, syntax::is_word_character) + } + + /// Returns true iff the byte is a word byte. + /// + /// If the byte is absent, then false is returned. + pub fn is_word_byte(self) -> bool { + match char::from_u32(self.0) { + Some(c) if c <= '\u{7F}' => syntax::is_word_byte(c as u8), + None | Some(_) => false, + } + } +} + +impl From for Char { + fn from(c: char) -> Char { + Char(c as u32) + } +} + +impl From> for Char { + fn from(c: Option) -> Char { + c.map_or(Char(u32::MAX), |c| c.into()) + } +} + +impl PartialEq for Char { + #[inline] + fn eq(&self, other: &char) -> bool { + self.0 == *other as u32 + } +} + +impl PartialEq for char { + #[inline] + fn eq(&self, other: &Char) -> bool { + *self as u32 == other.0 + } +} + +impl PartialOrd for Char { + #[inline] + fn partial_cmp(&self, other: &char) -> Option { + self.0.partial_cmp(&(*other as u32)) + } +} + +impl PartialOrd for char { + #[inline] + fn partial_cmp(&self, other: &Char) -> Option { + (*self as u32).partial_cmp(&other.0) + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/lib.rs b/third_party/cargo/vendor/regex-1.3.3/src/lib.rs new file mode 100644 index 0000000..2a74bf8 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/lib.rs @@ -0,0 +1,785 @@ +/*! +This crate provides a library for parsing, compiling, and executing regular +expressions. Its syntax is similar to Perl-style regular expressions, but lacks +a few features like look around and backreferences. In exchange, all searches +execute in linear time with respect to the size of the regular expression and +search text. + +This crate's documentation provides some simple examples, describes +[Unicode support](#unicode) and exhaustively lists the +[supported syntax](#syntax). + +For more specific details on the API for regular expressions, please see the +documentation for the [`Regex`](struct.Regex.html) type. + +# Usage + +This crate is [on crates.io](https://crates.io/crates/regex) and can be +used by adding `regex` to your dependencies in your project's `Cargo.toml`. + +```toml +[dependencies] +regex = "1" +``` + +If you're using Rust 2015, then you'll also need to add it to your crate root: + +```rust +extern crate regex; +``` + +# Example: find a date + +General use of regular expressions in this package involves compiling an +expression and then using it to search, split or replace text. For example, +to confirm that some text resembles a date: + +```rust +use regex::Regex; +let re = Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap(); +assert!(re.is_match("2014-01-01")); +``` + +Notice the use of the `^` and `$` anchors. In this crate, every expression +is executed with an implicit `.*?` at the beginning and end, which allows +it to match anywhere in the text. Anchors can be used to ensure that the +full text matches an expression. + +This example also demonstrates the utility of +[raw strings](https://doc.rust-lang.org/stable/reference/tokens.html#raw-string-literals) +in Rust, which +are just like regular strings except they are prefixed with an `r` and do +not process any escape sequences. For example, `"\\d"` is the same +expression as `r"\d"`. + +# Example: Avoid compiling the same regex in a loop + +It is an anti-pattern to compile the same regular expression in a loop +since compilation is typically expensive. (It takes anywhere from a few +microseconds to a few **milliseconds** depending on the size of the +regex.) Not only is compilation itself expensive, but this also prevents +optimizations that reuse allocations internally to the matching engines. + +In Rust, it can sometimes be a pain to pass regular expressions around if +they're used from inside a helper function. Instead, we recommend using the +[`lazy_static`](https://crates.io/crates/lazy_static) crate to ensure that +regular expressions are compiled exactly once. + +For example: + +```rust +#[macro_use] extern crate lazy_static; +extern crate regex; + +use regex::Regex; + +fn some_helper_function(text: &str) -> bool { + lazy_static! { + static ref RE: Regex = Regex::new("...").unwrap(); + } + RE.is_match(text) +} + +fn main() {} +``` + +Specifically, in this example, the regex will be compiled when it is used for +the first time. On subsequent uses, it will reuse the previous compilation. + +# Example: iterating over capture groups + +This crate provides convenient iterators for matching an expression +repeatedly against a search string to find successive non-overlapping +matches. For example, to find all dates in a string and be able to access +them by their component pieces: + +```rust +# extern crate regex; use regex::Regex; +# fn main() { +let re = Regex::new(r"(\d{4})-(\d{2})-(\d{2})").unwrap(); +let text = "2012-03-14, 2013-01-01 and 2014-07-05"; +for cap in re.captures_iter(text) { + println!("Month: {} Day: {} Year: {}", &cap[2], &cap[3], &cap[1]); +} +// Output: +// Month: 03 Day: 14 Year: 2012 +// Month: 01 Day: 01 Year: 2013 +// Month: 07 Day: 05 Year: 2014 +# } +``` + +Notice that the year is in the capture group indexed at `1`. This is +because the *entire match* is stored in the capture group at index `0`. + +# Example: replacement with named capture groups + +Building on the previous example, perhaps we'd like to rearrange the date +formats. This can be done with text replacement. But to make the code +clearer, we can *name* our capture groups and use those names as variables +in our replacement text: + +```rust +# extern crate regex; use regex::Regex; +# fn main() { +let re = Regex::new(r"(?P\d{4})-(?P\d{2})-(?P\d{2})").unwrap(); +let before = "2012-03-14, 2013-01-01 and 2014-07-05"; +let after = re.replace_all(before, "$m/$d/$y"); +assert_eq!(after, "03/14/2012, 01/01/2013 and 07/05/2014"); +# } +``` + +The `replace` methods are actually polymorphic in the replacement, which +provides more flexibility than is seen here. (See the documentation for +`Regex::replace` for more details.) + +Note that if your regex gets complicated, you can use the `x` flag to +enable insignificant whitespace mode, which also lets you write comments: + +```rust +# extern crate regex; use regex::Regex; +# fn main() { +let re = Regex::new(r"(?x) + (?P\d{4}) # the year + - + (?P\d{2}) # the month + - + (?P\d{2}) # the day +").unwrap(); +let before = "2012-03-14, 2013-01-01 and 2014-07-05"; +let after = re.replace_all(before, "$m/$d/$y"); +assert_eq!(after, "03/14/2012, 01/01/2013 and 07/05/2014"); +# } +``` + +If you wish to match against whitespace in this mode, you can still use `\s`, +`\n`, `\t`, etc. For escaping a single space character, you can use its hex +character code `\x20` or temporarily disable the `x` flag, e.g., `(?-x: )`. + +# Example: match multiple regular expressions simultaneously + +This demonstrates how to use a `RegexSet` to match multiple (possibly +overlapping) regular expressions in a single scan of the search text: + +```rust +use regex::RegexSet; + +let set = RegexSet::new(&[ + r"\w+", + r"\d+", + r"\pL+", + r"foo", + r"bar", + r"barfoo", + r"foobar", +]).unwrap(); + +// Iterate over and collect all of the matches. +let matches: Vec<_> = set.matches("foobar").into_iter().collect(); +assert_eq!(matches, vec![0, 2, 3, 4, 6]); + +// You can also test whether a particular regex matched: +let matches = set.matches("foobar"); +assert!(!matches.matched(5)); +assert!(matches.matched(6)); +``` + +# Pay for what you use + +With respect to searching text with a regular expression, there are three +questions that can be asked: + +1. Does the text match this expression? +2. If so, where does it match? +3. Where did the capturing groups match? + +Generally speaking, this crate could provide a function to answer only #3, +which would subsume #1 and #2 automatically. However, it can be significantly +more expensive to compute the location of capturing group matches, so it's best +not to do it if you don't need to. + +Therefore, only use what you need. For example, don't use `find` if you +only need to test if an expression matches a string. (Use `is_match` +instead.) + +# Unicode + +This implementation executes regular expressions **only** on valid UTF-8 +while exposing match locations as byte indices into the search string. (To +relax this restriction, use the [`bytes`](bytes/index.html) sub-module.) + +Only simple case folding is supported. Namely, when matching +case-insensitively, the characters are first mapped using the "simple" case +folding rules defined by Unicode. + +Regular expressions themselves are **only** interpreted as a sequence of +Unicode scalar values. This means you can use Unicode characters directly +in your expression: + +```rust +# extern crate regex; use regex::Regex; +# fn main() { +let re = Regex::new(r"(?i)Δ+").unwrap(); +let mat = re.find("ΔδΔ").unwrap(); +assert_eq!((mat.start(), mat.end()), (0, 6)); +# } +``` + +Most features of the regular expressions in this crate are Unicode aware. Here +are some examples: + +* `.` will match any valid UTF-8 encoded Unicode scalar value except for `\n`. + (To also match `\n`, enable the `s` flag, e.g., `(?s:.)`.) +* `\w`, `\d` and `\s` are Unicode aware. For example, `\s` will match all forms + of whitespace categorized by Unicode. +* `\b` matches a Unicode word boundary. +* Negated character classes like `[^a]` match all Unicode scalar values except + for `a`. +* `^` and `$` are **not** Unicode aware in multi-line mode. Namely, they only + recognize `\n` and not any of the other forms of line terminators defined + by Unicode. + +Unicode general categories, scripts, script extensions, ages and a smattering +of boolean properties are available as character classes. For example, you can +match a sequence of numerals, Greek or Cherokee letters: + +```rust +# extern crate regex; use regex::Regex; +# fn main() { +let re = Regex::new(r"[\pN\p{Greek}\p{Cherokee}]+").unwrap(); +let mat = re.find("abcΔᎠβⅠᏴγδⅡxyz").unwrap(); +assert_eq!((mat.start(), mat.end()), (3, 23)); +# } +``` + +For a more detailed breakdown of Unicode support with respect to +[UTS#18](http://unicode.org/reports/tr18/), +please see the +[UNICODE](https://github.com/rust-lang/regex/blob/master/UNICODE.md) +document in the root of the regex repository. + +# Opt out of Unicode support + +The `bytes` sub-module provides a `Regex` type that can be used to match +on `&[u8]`. By default, text is interpreted as UTF-8 just like it is with +the main `Regex` type. However, this behavior can be disabled by turning +off the `u` flag, even if doing so could result in matching invalid UTF-8. +For example, when the `u` flag is disabled, `.` will match any byte instead +of any Unicode scalar value. + +Disabling the `u` flag is also possible with the standard `&str`-based `Regex` +type, but it is only allowed where the UTF-8 invariant is maintained. For +example, `(?-u:\w)` is an ASCII-only `\w` character class and is legal in an +`&str`-based `Regex`, but `(?-u:\xFF)` will attempt to match the raw byte +`\xFF`, which is invalid UTF-8 and therefore is illegal in `&str`-based +regexes. + +Finally, since Unicode support requires bundling large Unicode data +tables, this crate exposes knobs to disable the compilation of those +data tables, which can be useful for shrinking binary size and reducing +compilation times. For details on how to do that, see the section on [crate +features](#crate-features). + +# Syntax + +The syntax supported in this crate is documented below. + +Note that the regular expression parser and abstract syntax are exposed in +a separate crate, [`regex-syntax`](https://docs.rs/regex-syntax). + +## Matching one character + +
+.             any character except new line (includes new line with s flag)
+\d            digit (\p{Nd})
+\D            not digit
+\pN           One-letter name Unicode character class
+\p{Greek}     Unicode character class (general category or script)
+\PN           Negated one-letter name Unicode character class
+\P{Greek}     negated Unicode character class (general category or script)
+
+ +### Character classes + +
+[xyz]         A character class matching either x, y or z (union).
+[^xyz]        A character class matching any character except x, y and z.
+[a-z]         A character class matching any character in range a-z.
+[[:alpha:]]   ASCII character class ([A-Za-z])
+[[:^alpha:]]  Negated ASCII character class ([^A-Za-z])
+[x[^xyz]]     Nested/grouping character class (matching any character except y and z)
+[a-y&&xyz]    Intersection (matching x or y)
+[0-9&&[^4]]   Subtraction using intersection and negation (matching 0-9 except 4)
+[0-9--4]      Direct subtraction (matching 0-9 except 4)
+[a-g~~b-h]    Symmetric difference (matching `a` and `h` only)
+[\[\]]        Escaping in character classes (matching [ or ])
+
+ +Any named character class may appear inside a bracketed `[...]` character +class. For example, `[\p{Greek}[:digit:]]` matches any Greek or ASCII +digit. `[\p{Greek}&&\pL]` matches Greek letters. + +Precedence in character classes, from most binding to least: + +1. Ranges: `a-cd` == `[a-c]d` +2. Union: `ab&&bc` == `[ab]&&[bc]` +3. Intersection: `^a-z&&b` == `^[a-z&&b]` +4. Negation + +## Composites + +
+xy    concatenation (x followed by y)
+x|y   alternation (x or y, prefer x)
+
+ +## Repetitions + +
+x*        zero or more of x (greedy)
+x+        one or more of x (greedy)
+x?        zero or one of x (greedy)
+x*?       zero or more of x (ungreedy/lazy)
+x+?       one or more of x (ungreedy/lazy)
+x??       zero or one of x (ungreedy/lazy)
+x{n,m}    at least n x and at most m x (greedy)
+x{n,}     at least n x (greedy)
+x{n}      exactly n x
+x{n,m}?   at least n x and at most m x (ungreedy/lazy)
+x{n,}?    at least n x (ungreedy/lazy)
+x{n}?     exactly n x
+
+ +## Empty matches + +
+^     the beginning of text (or start-of-line with multi-line mode)
+$     the end of text (or end-of-line with multi-line mode)
+\A    only the beginning of text (even with multi-line mode enabled)
+\z    only the end of text (even with multi-line mode enabled)
+\b    a Unicode word boundary (\w on one side and \W, \A, or \z on other)
+\B    not a Unicode word boundary
+
+ +## Grouping and flags + +
+(exp)          numbered capture group (indexed by opening parenthesis)
+(?P<name>exp)  named (also numbered) capture group (allowed chars: [_0-9a-zA-Z])
+(?:exp)        non-capturing group
+(?flags)       set flags within current group
+(?flags:exp)   set flags for exp (non-capturing)
+
+ +Flags are each a single character. For example, `(?x)` sets the flag `x` +and `(?-x)` clears the flag `x`. Multiple flags can be set or cleared at +the same time: `(?xy)` sets both the `x` and `y` flags and `(?x-y)` sets +the `x` flag and clears the `y` flag. + +All flags are by default disabled unless stated otherwise. They are: + +
+i     case-insensitive: letters match both upper and lower case
+m     multi-line mode: ^ and $ match begin/end of line
+s     allow . to match \n
+U     swap the meaning of x* and x*?
+u     Unicode support (enabled by default)
+x     ignore whitespace and allow line comments (starting with `#`)
+
+ +Flags can be toggled within a pattern. Here's an example that matches +case-insensitively for the first part but case-sensitively for the second part: + +```rust +# extern crate regex; use regex::Regex; +# fn main() { +let re = Regex::new(r"(?i)a+(?-i)b+").unwrap(); +let cap = re.captures("AaAaAbbBBBb").unwrap(); +assert_eq!(&cap[0], "AaAaAbb"); +# } +``` + +Notice that the `a+` matches either `a` or `A`, but the `b+` only matches +`b`. + +Multi-line mode means `^` and `$` no longer match just at the beginning/end of +the input, but at the beginning/end of lines: + +``` +# use regex::Regex; +let re = Regex::new(r"(?m)^line \d+").unwrap(); +let m = re.find("line one\nline 2\n").unwrap(); +assert_eq!(m.as_str(), "line 2"); +``` + +Note that `^` matches after new lines, even at the end of input: + +``` +# use regex::Regex; +let re = Regex::new(r"(?m)^").unwrap(); +let m = re.find_iter("test\n").last().unwrap(); +assert_eq!((m.start(), m.end()), (5, 5)); +``` + +Here is an example that uses an ASCII word boundary instead of a Unicode +word boundary: + +```rust +# extern crate regex; use regex::Regex; +# fn main() { +let re = Regex::new(r"(?-u:\b).+(?-u:\b)").unwrap(); +let cap = re.captures("$$abc$$").unwrap(); +assert_eq!(&cap[0], "abc"); +# } +``` + +## Escape sequences + +
+\*          literal *, works for any punctuation character: \.+*?()|[]{}^$
+\a          bell (\x07)
+\f          form feed (\x0C)
+\t          horizontal tab
+\n          new line
+\r          carriage return
+\v          vertical tab (\x0B)
+\123        octal character code (up to three digits) (when enabled)
+\x7F        hex character code (exactly two digits)
+\x{10FFFF}  any hex character code corresponding to a Unicode code point
+\u007F      hex character code (exactly four digits)
+\u{7F}      any hex character code corresponding to a Unicode code point
+\U0000007F  hex character code (exactly eight digits)
+\U{7F}      any hex character code corresponding to a Unicode code point
+
+ +## Perl character classes (Unicode friendly) + +These classes are based on the definitions provided in +[UTS#18](http://www.unicode.org/reports/tr18/#Compatibility_Properties): + +
+\d     digit (\p{Nd})
+\D     not digit
+\s     whitespace (\p{White_Space})
+\S     not whitespace
+\w     word character (\p{Alphabetic} + \p{M} + \d + \p{Pc} + \p{Join_Control})
+\W     not word character
+
+ +## ASCII character classes + +
+[[:alnum:]]    alphanumeric ([0-9A-Za-z])
+[[:alpha:]]    alphabetic ([A-Za-z])
+[[:ascii:]]    ASCII ([\x00-\x7F])
+[[:blank:]]    blank ([\t ])
+[[:cntrl:]]    control ([\x00-\x1F\x7F])
+[[:digit:]]    digits ([0-9])
+[[:graph:]]    graphical ([!-~])
+[[:lower:]]    lower case ([a-z])
+[[:print:]]    printable ([ -~])
+[[:punct:]]    punctuation ([!-/:-@\[-`{-~])
+[[:space:]]    whitespace ([\t\n\v\f\r ])
+[[:upper:]]    upper case ([A-Z])
+[[:word:]]     word characters ([0-9A-Za-z_])
+[[:xdigit:]]   hex digit ([0-9A-Fa-f])
+
+ +# Crate features + +By default, this crate tries pretty hard to make regex matching both as fast +as possible and as correct as it can be, within reason. This means that there +is a lot of code dedicated to performance, the handling of Unicode data and the +Unicode data itself. Overall, this leads to more dependencies, larger binaries +and longer compile times. This trade off may not be appropriate in all cases, +and indeed, even when all Unicode and performance features are disabled, one +is still left with a perfectly serviceable regex engine that will work well +in many cases. + +This crate exposes a number of features for controlling that trade off. Some +of these features are strictly performance oriented, such that disabling them +won't result in a loss of functionality, but may result in worse performance. +Other features, such as the ones controlling the presence or absence of Unicode +data, can result in a loss of functionality. For example, if one disables the +`unicode-case` feature (described below), then compiling the regex `(?i)a` +will fail since Unicode case insensitivity is enabled by default. Instead, +callers must use `(?i-u)a` instead to disable Unicode case folding. Stated +differently, enabling or disabling any of the features below can only add or +subtract from the total set of valid regular expressions. Enabling or disabling +a feature will never modify the match semantics of a regular expression. + +All features below are enabled by default. + +### Ecosystem features + +* **std** - + When enabled, this will cause `regex` to use the standard library. Currently, + disabling this feature will always result in a compilation error. It is + intended to add `alloc`-only support to regex in the future. + +### Performance features + +* **perf** - + Enables all performance related features. This feature is enabled by default + and will always cover all features that improve performance, even if more + are added in the future. +* **perf-cache** - + Enables the use of very fast thread safe caching for internal match state. + When this is disabled, caching is still used, but with a slower and simpler + implementation. Disabling this drops the `thread_local` and `lazy_static` + dependencies. +* **perf-dfa** - + Enables the use of a lazy DFA for matching. The lazy DFA is used to compile + portions of a regex to a very fast DFA on an as-needed basis. This can + result in substantial speedups, usually by an order of magnitude on large + haystacks. The lazy DFA does not bring in any new dependencies, but it can + make compile times longer. +* **perf-inline** - + Enables the use of aggressive inlining inside match routines. This reduces + the overhead of each match. The aggressive inlining, however, increases + compile times and binary size. +* **perf-literal** - + Enables the use of literal optimizations for speeding up matches. In some + cases, literal optimizations can result in speedups of _several_ orders of + magnitude. Disabling this drops the `aho-corasick` and `memchr` dependencies. + +### Unicode features + +* **unicode** - + Enables all Unicode features. This feature is enabled by default, and will + always cover all Unicode features, even if more are added in the future. +* **unicode-age** - + Provide the data for the + [Unicode `Age` property](https://www.unicode.org/reports/tr44/tr44-24.html#Character_Age). + This makes it possible to use classes like `\p{Age:6.0}` to refer to all + codepoints first introduced in Unicode 6.0 +* **unicode-bool** - + Provide the data for numerous Unicode boolean properties. The full list + is not included here, but contains properties like `Alphabetic`, `Emoji`, + `Lowercase`, `Math`, `Uppercase` and `White_Space`. +* **unicode-case** - + Provide the data for case insensitive matching using + [Unicode's "simple loose matches" specification](https://www.unicode.org/reports/tr18/#Simple_Loose_Matches). +* **unicode-gencat** - + Provide the data for + [Uncode general categories](https://www.unicode.org/reports/tr44/tr44-24.html#General_Category_Values). + This includes, but is not limited to, `Decimal_Number`, `Letter`, + `Math_Symbol`, `Number` and `Punctuation`. +* **unicode-perl** - + Provide the data for supporting the Unicode-aware Perl character classes, + corresponding to `\w`, `\s` and `\d`. This is also necessary for using + Unicode-aware word boundary assertions. Note that if this feature is + disabled, the `\s` and `\d` character classes are still available if the + `unicode-bool` and `unicode-gencat` features are enabled, respectively. +* **unicode-script** - + Provide the data for + [Unicode scripts and script extensions](https://www.unicode.org/reports/tr24/). + This includes, but is not limited to, `Arabic`, `Cyrillic`, `Hebrew`, + `Latin` and `Thai`. +* **unicode-segment** - + Provide the data necessary to provide the properties used to implement the + [Unicode text segmentation algorithms](https://www.unicode.org/reports/tr29/). + This enables using classes like `\p{gcb=Extend}`, `\p{wb=Katakana}` and + `\p{sb=ATerm}`. + + +# Untrusted input + +This crate can handle both untrusted regular expressions and untrusted +search text. + +Untrusted regular expressions are handled by capping the size of a compiled +regular expression. +(See [`RegexBuilder::size_limit`](struct.RegexBuilder.html#method.size_limit).) +Without this, it would be trivial for an attacker to exhaust your system's +memory with expressions like `a{100}{100}{100}`. + +Untrusted search text is allowed because the matching engine(s) in this +crate have time complexity `O(mn)` (with `m ~ regex` and `n ~ search +text`), which means there's no way to cause exponential blow-up like with +some other regular expression engines. (We pay for this by disallowing +features like arbitrary look-ahead and backreferences.) + +When a DFA is used, pathological cases with exponential state blow-up are +avoided by constructing the DFA lazily or in an "online" manner. Therefore, +at most one new state can be created for each byte of input. This satisfies +our time complexity guarantees, but can lead to memory growth +proportional to the size of the input. As a stopgap, the DFA is only +allowed to store a fixed number of states. When the limit is reached, its +states are wiped and continues on, possibly duplicating previous work. If +the limit is reached too frequently, it gives up and hands control off to +another matching engine with fixed memory requirements. +(The DFA size limit can also be tweaked. See +[`RegexBuilder::dfa_size_limit`](struct.RegexBuilder.html#method.dfa_size_limit).) +*/ + +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] +#![cfg_attr(feature = "pattern", feature(pattern))] + +#[cfg(not(feature = "std"))] +compile_error!("`std` feature is currently required to build this crate"); + +#[cfg(feature = "perf-literal")] +extern crate aho_corasick; +#[cfg(test)] +extern crate doc_comment; +#[cfg(feature = "perf-literal")] +extern crate memchr; +#[cfg(test)] +#[cfg_attr(feature = "perf-literal", macro_use)] +extern crate quickcheck; +extern crate regex_syntax as syntax; +#[cfg(feature = "perf-cache")] +extern crate thread_local; + +#[cfg(test)] +doc_comment::doctest!("../README.md"); + +#[cfg(feature = "std")] +pub use error::Error; +#[cfg(feature = "std")] +pub use re_builder::set_unicode::*; +#[cfg(feature = "std")] +pub use re_builder::unicode::*; +#[cfg(feature = "std")] +pub use re_set::unicode::*; +#[cfg(feature = "std")] +#[cfg(feature = "std")] +pub use re_unicode::{ + escape, CaptureLocations, CaptureMatches, CaptureNames, Captures, + Locations, Match, Matches, NoExpand, Regex, Replacer, ReplacerRef, Split, + SplitN, SubCaptureMatches, +}; + +/** +Match regular expressions on arbitrary bytes. + +This module provides a nearly identical API to the one found in the +top-level of this crate. There are two important differences: + +1. Matching is done on `&[u8]` instead of `&str`. Additionally, `Vec` +is used where `String` would have been used. +2. Unicode support can be disabled even when disabling it would result in +matching invalid UTF-8 bytes. + +# Example: match null terminated string + +This shows how to find all null-terminated strings in a slice of bytes: + +```rust +# use regex::bytes::Regex; +let re = Regex::new(r"(?-u)(?P[^\x00]+)\x00").unwrap(); +let text = b"foo\x00bar\x00baz\x00"; + +// Extract all of the strings without the null terminator from each match. +// The unwrap is OK here since a match requires the `cstr` capture to match. +let cstrs: Vec<&[u8]> = + re.captures_iter(text) + .map(|c| c.name("cstr").unwrap().as_bytes()) + .collect(); +assert_eq!(vec![&b"foo"[..], &b"bar"[..], &b"baz"[..]], cstrs); +``` + +# Example: selectively enable Unicode support + +This shows how to match an arbitrary byte pattern followed by a UTF-8 encoded +string (e.g., to extract a title from a Matroska file): + +```rust +# use std::str; +# use regex::bytes::Regex; +let re = Regex::new( + r"(?-u)\x7b\xa9(?:[\x80-\xfe]|[\x40-\xff].)(?u:(.*))" +).unwrap(); +let text = b"\x12\xd0\x3b\x5f\x7b\xa9\x85\xe2\x98\x83\x80\x98\x54\x76\x68\x65"; +let caps = re.captures(text).unwrap(); + +// Notice that despite the `.*` at the end, it will only match valid UTF-8 +// because Unicode mode was enabled with the `u` flag. Without the `u` flag, +// the `.*` would match the rest of the bytes. +let mat = caps.get(1).unwrap(); +assert_eq!((7, 10), (mat.start(), mat.end())); + +// If there was a match, Unicode mode guarantees that `title` is valid UTF-8. +let title = str::from_utf8(&caps[1]).unwrap(); +assert_eq!("☃", title); +``` + +In general, if the Unicode flag is enabled in a capture group and that capture +is part of the overall match, then the capture is *guaranteed* to be valid +UTF-8. + +# Syntax + +The supported syntax is pretty much the same as the syntax for Unicode +regular expressions with a few changes that make sense for matching arbitrary +bytes: + +1. The `u` flag can be disabled even when disabling it might cause the regex to +match invalid UTF-8. When the `u` flag is disabled, the regex is said to be in +"ASCII compatible" mode. +2. In ASCII compatible mode, neither Unicode scalar values nor Unicode +character classes are allowed. +3. In ASCII compatible mode, Perl character classes (`\w`, `\d` and `\s`) +revert to their typical ASCII definition. `\w` maps to `[[:word:]]`, `\d` maps +to `[[:digit:]]` and `\s` maps to `[[:space:]]`. +4. In ASCII compatible mode, word boundaries use the ASCII compatible `\w` to +determine whether a byte is a word byte or not. +5. Hexadecimal notation can be used to specify arbitrary bytes instead of +Unicode codepoints. For example, in ASCII compatible mode, `\xFF` matches the +literal byte `\xFF`, while in Unicode mode, `\xFF` is a Unicode codepoint that +matches its UTF-8 encoding of `\xC3\xBF`. Similarly for octal notation when +enabled. +6. `.` matches any *byte* except for `\n` instead of any Unicode scalar value. +When the `s` flag is enabled, `.` matches any byte. + +# Performance + +In general, one should expect performance on `&[u8]` to be roughly similar to +performance on `&str`. +*/ +#[cfg(feature = "std")] +pub mod bytes { + pub use re_builder::bytes::*; + pub use re_builder::set_bytes::*; + pub use re_bytes::*; + pub use re_set::bytes::*; +} + +mod backtrack; +mod cache; +mod compile; +#[cfg(feature = "perf-dfa")] +mod dfa; +mod error; +mod exec; +mod expand; +mod find_byte; +#[cfg(feature = "perf-literal")] +mod freqs; +mod input; +mod literal; +#[cfg(feature = "pattern")] +mod pattern; +mod pikevm; +mod prog; +mod re_builder; +mod re_bytes; +mod re_set; +mod re_trait; +mod re_unicode; +mod sparse; +mod utf8; + +/// The `internal` module exists to support suspicious activity, such as +/// testing different matching engines and supporting the `regex-debug` CLI +/// utility. +#[doc(hidden)] +#[cfg(feature = "std")] +pub mod internal { + pub use compile::Compiler; + pub use exec::{Exec, ExecBuilder}; + pub use input::{Char, CharInput, Input, InputAt}; + pub use literal::LiteralSearcher; + pub use prog::{EmptyLook, Inst, InstRanges, Program}; +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/literal/imp.rs b/third_party/cargo/vendor/regex-1.3.3/src/literal/imp.rs new file mode 100644 index 0000000..fe07ffc --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/literal/imp.rs @@ -0,0 +1,1121 @@ +use std::cmp; +use std::mem; + +use aho_corasick::{self, packed, AhoCorasick, AhoCorasickBuilder}; +use memchr::{memchr, memchr2, memchr3}; +use syntax::hir::literal::{Literal, Literals}; + +use freqs::BYTE_FREQUENCIES; + +/// A prefix extracted from a compiled regular expression. +/// +/// A regex prefix is a set of literal strings that *must* be matched at the +/// beginning of a regex in order for the entire regex to match. Similarly +/// for a regex suffix. +#[derive(Clone, Debug)] +pub struct LiteralSearcher { + complete: bool, + lcp: FreqyPacked, + lcs: FreqyPacked, + matcher: Matcher, +} + +#[derive(Clone, Debug)] +enum Matcher { + /// No literals. (Never advances through the input.) + Empty, + /// A set of four or more single byte literals. + Bytes(SingleByteSet), + /// A single substring, find using memchr and frequency analysis. + FreqyPacked(FreqyPacked), + /// A single substring, find using Boyer-Moore. + BoyerMoore(BoyerMooreSearch), + /// An Aho-Corasick automaton. + AC { ac: AhoCorasick, lits: Vec }, + /// A packed multiple substring searcher, using SIMD. + /// + /// Note that Aho-Corasick will actually use this packed searcher + /// internally automatically, however, there is some overhead associated + /// with going through the Aho-Corasick machinery. So using the packed + /// searcher directly results in some gains. + Packed { s: packed::Searcher, lits: Vec }, +} + +impl LiteralSearcher { + /// Returns a matcher that never matches and never advances the input. + pub fn empty() -> Self { + Self::new(Literals::empty(), Matcher::Empty) + } + + /// Returns a matcher for literal prefixes from the given set. + pub fn prefixes(lits: Literals) -> Self { + let matcher = Matcher::prefixes(&lits); + Self::new(lits, matcher) + } + + /// Returns a matcher for literal suffixes from the given set. + pub fn suffixes(lits: Literals) -> Self { + let matcher = Matcher::suffixes(&lits); + Self::new(lits, matcher) + } + + fn new(lits: Literals, matcher: Matcher) -> Self { + let complete = lits.all_complete(); + LiteralSearcher { + complete: complete, + lcp: FreqyPacked::new(lits.longest_common_prefix().to_vec()), + lcs: FreqyPacked::new(lits.longest_common_suffix().to_vec()), + matcher: matcher, + } + } + + /// Returns true if all matches comprise the entire regular expression. + /// + /// This does not necessarily mean that a literal match implies a match + /// of the regular expression. For example, the regular expresison `^a` + /// is comprised of a single complete literal `a`, but the regular + /// expression demands that it only match at the beginning of a string. + pub fn complete(&self) -> bool { + self.complete && !self.is_empty() + } + + /// Find the position of a literal in `haystack` if it exists. + #[cfg_attr(feature = "perf-inline", inline(always))] + pub fn find(&self, haystack: &[u8]) -> Option<(usize, usize)> { + use self::Matcher::*; + match self.matcher { + Empty => Some((0, 0)), + Bytes(ref sset) => sset.find(haystack).map(|i| (i, i + 1)), + FreqyPacked(ref s) => s.find(haystack).map(|i| (i, i + s.len())), + BoyerMoore(ref s) => s.find(haystack).map(|i| (i, i + s.len())), + AC { ref ac, .. } => { + ac.find(haystack).map(|m| (m.start(), m.end())) + } + Packed { ref s, .. } => { + s.find(haystack).map(|m| (m.start(), m.end())) + } + } + } + + /// Like find, except matches must start at index `0`. + pub fn find_start(&self, haystack: &[u8]) -> Option<(usize, usize)> { + for lit in self.iter() { + if lit.len() > haystack.len() { + continue; + } + if lit == &haystack[0..lit.len()] { + return Some((0, lit.len())); + } + } + None + } + + /// Like find, except matches must end at index `haystack.len()`. + pub fn find_end(&self, haystack: &[u8]) -> Option<(usize, usize)> { + for lit in self.iter() { + if lit.len() > haystack.len() { + continue; + } + if lit == &haystack[haystack.len() - lit.len()..] { + return Some((haystack.len() - lit.len(), haystack.len())); + } + } + None + } + + /// Returns an iterator over all literals to be matched. + pub fn iter(&self) -> LiteralIter { + match self.matcher { + Matcher::Empty => LiteralIter::Empty, + Matcher::Bytes(ref sset) => LiteralIter::Bytes(&sset.dense), + Matcher::FreqyPacked(ref s) => LiteralIter::Single(&s.pat), + Matcher::BoyerMoore(ref s) => LiteralIter::Single(&s.pattern), + Matcher::AC { ref lits, .. } => LiteralIter::AC(lits), + Matcher::Packed { ref lits, .. } => LiteralIter::Packed(lits), + } + } + + /// Returns a matcher for the longest common prefix of this matcher. + pub fn lcp(&self) -> &FreqyPacked { + &self.lcp + } + + /// Returns a matcher for the longest common suffix of this matcher. + pub fn lcs(&self) -> &FreqyPacked { + &self.lcs + } + + /// Returns true iff this prefix is empty. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Returns the number of prefixes in this machine. + pub fn len(&self) -> usize { + use self::Matcher::*; + match self.matcher { + Empty => 0, + Bytes(ref sset) => sset.dense.len(), + FreqyPacked(_) => 1, + BoyerMoore(_) => 1, + AC { ref ac, .. } => ac.pattern_count(), + Packed { ref lits, .. } => lits.len(), + } + } + + /// Return the approximate heap usage of literals in bytes. + pub fn approximate_size(&self) -> usize { + use self::Matcher::*; + match self.matcher { + Empty => 0, + Bytes(ref sset) => sset.approximate_size(), + FreqyPacked(ref single) => single.approximate_size(), + BoyerMoore(ref single) => single.approximate_size(), + AC { ref ac, .. } => ac.heap_bytes(), + Packed { ref s, .. } => s.heap_bytes(), + } + } +} + +impl Matcher { + fn prefixes(lits: &Literals) -> Self { + let sset = SingleByteSet::prefixes(lits); + Matcher::new(lits, sset) + } + + fn suffixes(lits: &Literals) -> Self { + let sset = SingleByteSet::suffixes(lits); + Matcher::new(lits, sset) + } + + fn new(lits: &Literals, sset: SingleByteSet) -> Self { + if lits.literals().is_empty() { + return Matcher::Empty; + } + if sset.dense.len() >= 26 { + // Avoid trying to match a large number of single bytes. + // This is *very* sensitive to a frequency analysis comparison + // between the bytes in sset and the composition of the haystack. + // No matter the size of sset, if its members all are rare in the + // haystack, then it'd be worth using it. How to tune this... IDK. + // ---AG + return Matcher::Empty; + } + if sset.complete { + return Matcher::Bytes(sset); + } + if lits.literals().len() == 1 { + let lit = lits.literals()[0].to_vec(); + if BoyerMooreSearch::should_use(lit.as_slice()) { + return Matcher::BoyerMoore(BoyerMooreSearch::new(lit)); + } else { + return Matcher::FreqyPacked(FreqyPacked::new(lit)); + } + } + + let pats = lits.literals().to_owned(); + let is_aho_corasick_fast = sset.dense.len() <= 1 && sset.all_ascii; + if lits.literals().len() <= 100 && !is_aho_corasick_fast { + let mut builder = packed::Config::new() + .match_kind(packed::MatchKind::LeftmostFirst) + .builder(); + if let Some(s) = builder.extend(&pats).build() { + return Matcher::Packed { s, lits: pats }; + } + } + let ac = AhoCorasickBuilder::new() + .match_kind(aho_corasick::MatchKind::LeftmostFirst) + .dfa(true) + .build_with_size::(&pats) + .unwrap(); + Matcher::AC { ac, lits: pats } + } +} + +pub enum LiteralIter<'a> { + Empty, + Bytes(&'a [u8]), + Single(&'a [u8]), + AC(&'a [Literal]), + Packed(&'a [Literal]), +} + +impl<'a> Iterator for LiteralIter<'a> { + type Item = &'a [u8]; + + fn next(&mut self) -> Option { + match *self { + LiteralIter::Empty => None, + LiteralIter::Bytes(ref mut many) => { + if many.is_empty() { + None + } else { + let next = &many[0..1]; + *many = &many[1..]; + Some(next) + } + } + LiteralIter::Single(ref mut one) => { + if one.is_empty() { + None + } else { + let next = &one[..]; + *one = &[]; + Some(next) + } + } + LiteralIter::AC(ref mut lits) => { + if lits.is_empty() { + None + } else { + let next = &lits[0]; + *lits = &lits[1..]; + Some(&**next) + } + } + LiteralIter::Packed(ref mut lits) => { + if lits.is_empty() { + None + } else { + let next = &lits[0]; + *lits = &lits[1..]; + Some(&**next) + } + } + } + } +} + +#[derive(Clone, Debug)] +struct SingleByteSet { + sparse: Vec, + dense: Vec, + complete: bool, + all_ascii: bool, +} + +impl SingleByteSet { + fn new() -> SingleByteSet { + SingleByteSet { + sparse: vec![false; 256], + dense: vec![], + complete: true, + all_ascii: true, + } + } + + fn prefixes(lits: &Literals) -> SingleByteSet { + let mut sset = SingleByteSet::new(); + for lit in lits.literals() { + sset.complete = sset.complete && lit.len() == 1; + if let Some(&b) = lit.get(0) { + if !sset.sparse[b as usize] { + if b > 0x7F { + sset.all_ascii = false; + } + sset.dense.push(b); + sset.sparse[b as usize] = true; + } + } + } + sset + } + + fn suffixes(lits: &Literals) -> SingleByteSet { + let mut sset = SingleByteSet::new(); + for lit in lits.literals() { + sset.complete = sset.complete && lit.len() == 1; + if let Some(&b) = lit.get(lit.len().checked_sub(1).unwrap()) { + if !sset.sparse[b as usize] { + if b > 0x7F { + sset.all_ascii = false; + } + sset.dense.push(b); + sset.sparse[b as usize] = true; + } + } + } + sset + } + + /// Faster find that special cases certain sizes to use memchr. + #[cfg_attr(feature = "perf-inline", inline(always))] + fn find(&self, text: &[u8]) -> Option { + match self.dense.len() { + 0 => None, + 1 => memchr(self.dense[0], text), + 2 => memchr2(self.dense[0], self.dense[1], text), + 3 => memchr3(self.dense[0], self.dense[1], self.dense[2], text), + _ => self._find(text), + } + } + + /// Generic find that works on any sized set. + fn _find(&self, haystack: &[u8]) -> Option { + for (i, &b) in haystack.iter().enumerate() { + if self.sparse[b as usize] { + return Some(i); + } + } + None + } + + fn approximate_size(&self) -> usize { + (self.dense.len() * mem::size_of::()) + + (self.sparse.len() * mem::size_of::()) + } +} + +/// Provides an implementation of fast subtring search using frequency +/// analysis. +/// +/// memchr is so fast that we do everything we can to keep the loop in memchr +/// for as long as possible. The easiest way to do this is to intelligently +/// pick the byte to send to memchr. The best byte is the byte that occurs +/// least frequently in the haystack. Since doing frequency analysis on the +/// haystack is far too expensive, we compute a set of fixed frequencies up +/// front and hard code them in src/freqs.rs. Frequency analysis is done via +/// scripts/frequencies.py. +#[derive(Clone, Debug)] +pub struct FreqyPacked { + /// The pattern. + pat: Vec, + /// The number of Unicode characters in the pattern. This is useful for + /// determining the effective length of a pattern when deciding which + /// optimizations to perform. A trailing incomplete UTF-8 sequence counts + /// as one character. + char_len: usize, + /// The rarest byte in the pattern, according to pre-computed frequency + /// analysis. + rare1: u8, + /// The offset of the rarest byte in `pat`. + rare1i: usize, + /// The second rarest byte in the pattern, according to pre-computed + /// frequency analysis. (This may be equivalent to the rarest byte.) + /// + /// The second rarest byte is used as a type of guard for quickly detecting + /// a mismatch after memchr locates an instance of the rarest byte. This + /// is a hedge against pathological cases where the pre-computed frequency + /// analysis may be off. (But of course, does not prevent *all* + /// pathological cases.) + rare2: u8, + /// The offset of the second rarest byte in `pat`. + rare2i: usize, +} + +impl FreqyPacked { + fn new(pat: Vec) -> FreqyPacked { + if pat.is_empty() { + return FreqyPacked::empty(); + } + + // Find the rarest two bytes. Try to make them distinct (but it's not + // required). + let mut rare1 = pat[0]; + let mut rare2 = pat[0]; + for b in pat[1..].iter().cloned() { + if freq_rank(b) < freq_rank(rare1) { + rare1 = b; + } + } + for &b in &pat { + if rare1 == rare2 { + rare2 = b + } else if b != rare1 && freq_rank(b) < freq_rank(rare2) { + rare2 = b; + } + } + + // And find the offsets of their last occurrences. + let rare1i = pat.iter().rposition(|&b| b == rare1).unwrap(); + let rare2i = pat.iter().rposition(|&b| b == rare2).unwrap(); + + let char_len = char_len_lossy(&pat); + FreqyPacked { + pat: pat, + char_len: char_len, + rare1: rare1, + rare1i: rare1i, + rare2: rare2, + rare2i: rare2i, + } + } + + fn empty() -> FreqyPacked { + FreqyPacked { + pat: vec![], + char_len: 0, + rare1: 0, + rare1i: 0, + rare2: 0, + rare2i: 0, + } + } + + #[cfg_attr(feature = "perf-inline", inline(always))] + pub fn find(&self, haystack: &[u8]) -> Option { + let pat = &*self.pat; + if haystack.len() < pat.len() || pat.is_empty() { + return None; + } + let mut i = self.rare1i; + while i < haystack.len() { + i += match memchr(self.rare1, &haystack[i..]) { + None => return None, + Some(i) => i, + }; + let start = i - self.rare1i; + let end = start + pat.len(); + if end > haystack.len() { + return None; + } + let aligned = &haystack[start..end]; + if aligned[self.rare2i] == self.rare2 && aligned == &*self.pat { + return Some(start); + } + i += 1; + } + None + } + + #[cfg_attr(feature = "perf-inline", inline(always))] + pub fn is_suffix(&self, text: &[u8]) -> bool { + if text.len() < self.len() { + return false; + } + text[text.len() - self.len()..] == *self.pat + } + + pub fn len(&self) -> usize { + self.pat.len() + } + + pub fn char_len(&self) -> usize { + self.char_len + } + + fn approximate_size(&self) -> usize { + self.pat.len() * mem::size_of::() + } +} + +fn char_len_lossy(bytes: &[u8]) -> usize { + String::from_utf8_lossy(bytes).chars().count() +} + +/// An implementation of Tuned Boyer-Moore as laid out by +/// Andrew Hume and Daniel Sunday in "Fast String Searching". +/// O(n) in the size of the input. +/// +/// Fast string searching algorithms come in many variations, +/// but they can generally be described in terms of three main +/// components. +/// +/// The skip loop is where the string searcher wants to spend +/// as much time as possible. Exactly which character in the +/// pattern the skip loop examines varies from algorithm to +/// algorithm, but in the simplest case this loop repeated +/// looks at the last character in the pattern and jumps +/// forward in the input if it is not in the pattern. +/// Robert Boyer and J Moore called this the "fast" loop in +/// their original paper. +/// +/// The match loop is responsible for actually examining the +/// whole potentially matching substring. In order to fail +/// faster, the match loop sometimes has a guard test attached. +/// The guard test uses frequency analysis of the different +/// characters in the pattern to choose the least frequency +/// occurring character and use it to find match failures +/// as quickly as possible. +/// +/// The shift rule governs how the algorithm will shuffle its +/// test window in the event of a failure during the match loop. +/// Certain shift rules allow the worst-case run time of the +/// algorithm to be shown to be O(n) in the size of the input +/// rather than O(nm) in the size of the input and the size +/// of the pattern (as naive Boyer-Moore is). +/// +/// "Fast String Searching", in addition to presenting a tuned +/// algorithm, provides a comprehensive taxonomy of the many +/// different flavors of string searchers. Under that taxonomy +/// TBM, the algorithm implemented here, uses an unrolled fast +/// skip loop with memchr fallback, a forward match loop with guard, +/// and the mini Sunday's delta shift rule. To unpack that you'll have to +/// read the paper. +#[derive(Clone, Debug)] +pub struct BoyerMooreSearch { + /// The pattern we are going to look for in the haystack. + pattern: Vec, + + /// The skip table for the skip loop. + /// + /// Maps the character at the end of the input + /// to a shift. + skip_table: Vec, + + /// The guard character (least frequently occurring char). + guard: u8, + /// The reverse-index of the guard character in the pattern. + guard_reverse_idx: usize, + + /// Daniel Sunday's mini generalized delta2 shift table. + /// + /// We use a skip loop, so we only have to provide a shift + /// for the skip char (last char). This is why it is a mini + /// shift rule. + md2_shift: usize, +} + +impl BoyerMooreSearch { + /// Create a new string searcher, performing whatever + /// compilation steps are required. + fn new(pattern: Vec) -> Self { + debug_assert!(!pattern.is_empty()); + + let (g, gi) = Self::select_guard(pattern.as_slice()); + let skip_table = Self::compile_skip_table(pattern.as_slice()); + let md2_shift = Self::compile_md2_shift(pattern.as_slice()); + BoyerMooreSearch { + pattern: pattern, + skip_table: skip_table, + guard: g, + guard_reverse_idx: gi, + md2_shift: md2_shift, + } + } + + /// Find the pattern in `haystack`, returning the offset + /// of the start of the first occurrence of the pattern + /// in `haystack`. + #[inline] + fn find(&self, haystack: &[u8]) -> Option { + if haystack.len() < self.pattern.len() { + return None; + } + + let mut window_end = self.pattern.len() - 1; + + // Inspired by the grep source. It is a way + // to do correct loop unrolling without having to place + // a crashpad of terminating charicters at the end in + // the way described in the Fast String Searching paper. + const NUM_UNROLL: usize = 10; + // 1 for the initial position, and 1 for the md2 shift + let short_circut = (NUM_UNROLL + 2) * self.pattern.len(); + + if haystack.len() > short_circut { + // just 1 for the md2 shift + let backstop = + haystack.len() - ((NUM_UNROLL + 1) * self.pattern.len()); + loop { + window_end = + match self.skip_loop(haystack, window_end, backstop) { + Some(i) => i, + None => return None, + }; + if window_end >= backstop { + break; + } + + if self.check_match(haystack, window_end) { + return Some(window_end - (self.pattern.len() - 1)); + } else { + let skip = self.skip_table[haystack[window_end] as usize]; + window_end += + if skip == 0 { self.md2_shift } else { skip }; + continue; + } + } + } + + // now process the input after the backstop + while window_end < haystack.len() { + let mut skip = self.skip_table[haystack[window_end] as usize]; + if skip == 0 { + if self.check_match(haystack, window_end) { + return Some(window_end - (self.pattern.len() - 1)); + } else { + skip = self.md2_shift; + } + } + window_end += skip; + } + + None + } + + fn len(&self) -> usize { + return self.pattern.len(); + } + + /// The key heuristic behind which the BoyerMooreSearch lives. + /// + /// See `rust-lang/regex/issues/408`. + /// + /// Tuned Boyer-Moore is actually pretty slow! It turns out a handrolled + /// platform-specific memchr routine with a bit of frequency + /// analysis sprinkled on top actually wins most of the time. + /// However, there are a few cases where Tuned Boyer-Moore still + /// wins. + /// + /// If the haystack is random, frequency analysis doesn't help us, + /// so Boyer-Moore will win for sufficiently large needles. + /// Unfortunately, there is no obvious way to determine this + /// ahead of time. + /// + /// If the pattern itself consists of very common characters, + /// frequency analysis won't get us anywhere. The most extreme + /// example of this is a pattern like `eeeeeeeeeeeeeeee`. Fortunately, + /// this case is wholly determined by the pattern, so we can actually + /// implement the heuristic. + /// + /// A third case is if the pattern is sufficiently long. The idea + /// here is that once the pattern gets long enough the Tuned + /// Boyer-Moore skip loop will start making strides long enough + /// to beat the asm deep magic that is memchr. + fn should_use(pattern: &[u8]) -> bool { + // The minimum pattern length required to use TBM. + const MIN_LEN: usize = 9; + // The minimum frequency rank (lower is rarer) that every byte in the + // pattern must have in order to use TBM. That is, if the pattern + // contains _any_ byte with a lower rank, then TBM won't be used. + const MIN_CUTOFF: usize = 150; + // The maximum frequency rank for any byte. + const MAX_CUTOFF: usize = 255; + // The scaling factor used to determine the actual cutoff frequency + // to use (keeping in mind that the minimum frequency rank is bounded + // by MIN_CUTOFF). This scaling factor is an attempt to make TBM more + // likely to be used as the pattern grows longer. That is, longer + // patterns permit somewhat less frequent bytes than shorter patterns, + // under the assumption that TBM gets better as the pattern gets + // longer. + const LEN_CUTOFF_PROPORTION: usize = 4; + + let scaled_rank = pattern.len().wrapping_mul(LEN_CUTOFF_PROPORTION); + let cutoff = cmp::max( + MIN_CUTOFF, + MAX_CUTOFF - cmp::min(MAX_CUTOFF, scaled_rank), + ); + // The pattern must be long enough to be worthwhile. e.g., memchr will + // be faster on `e` because it is short even though e is quite common. + pattern.len() > MIN_LEN + // all the bytes must be more common than the cutoff. + && pattern.iter().all(|c| freq_rank(*c) >= cutoff) + } + + /// Check to see if there is a match at the given position + #[inline] + fn check_match(&self, haystack: &[u8], window_end: usize) -> bool { + // guard test + if haystack[window_end - self.guard_reverse_idx] != self.guard { + return false; + } + + // match loop + let window_start = window_end - (self.pattern.len() - 1); + for i in 0..self.pattern.len() { + if self.pattern[i] != haystack[window_start + i] { + return false; + } + } + + true + } + + /// Skip forward according to the shift table. + /// + /// Returns the offset of the next occurrence + /// of the last char in the pattern, or the none + /// if it never reappears. If `skip_loop` hits the backstop + /// it will leave early. + #[inline] + fn skip_loop( + &self, + haystack: &[u8], + mut window_end: usize, + backstop: usize, + ) -> Option { + let window_end_snapshot = window_end; + let skip_of = |we: usize| -> usize { + // Unsafe might make this faster, but the benchmarks + // were hard to interpret. + self.skip_table[haystack[we] as usize] + }; + + loop { + let mut skip = skip_of(window_end); + window_end += skip; + skip = skip_of(window_end); + window_end += skip; + if skip != 0 { + skip = skip_of(window_end); + window_end += skip; + skip = skip_of(window_end); + window_end += skip; + skip = skip_of(window_end); + window_end += skip; + if skip != 0 { + skip = skip_of(window_end); + window_end += skip; + skip = skip_of(window_end); + window_end += skip; + skip = skip_of(window_end); + window_end += skip; + if skip != 0 { + skip = skip_of(window_end); + window_end += skip; + skip = skip_of(window_end); + window_end += skip; + + // If ten iterations did not make at least 16 words + // worth of progress, we just fall back on memchr. + if window_end - window_end_snapshot + > 16 * mem::size_of::() + { + // Returning a window_end >= backstop will + // immediatly break us out of the inner loop in + // `find`. + if window_end >= backstop { + return Some(window_end); + } + + continue; // we made enough progress + } else { + // In case we are already there, and so that + // we will catch the guard char. + window_end = window_end + .checked_sub(1 + self.guard_reverse_idx) + .unwrap_or(0); + + match memchr(self.guard, &haystack[window_end..]) { + None => return None, + Some(g_idx) => { + return Some( + window_end + + g_idx + + self.guard_reverse_idx, + ); + } + } + } + } + } + } + + return Some(window_end); + } + } + + /// Compute the ufast skip table. + fn compile_skip_table(pattern: &[u8]) -> Vec { + let mut tab = vec![pattern.len(); 256]; + + // For every char in the pattern, we write a skip + // that will line us up with the rightmost occurrence. + // + // N.B. the sentinel (0) is written by the last + // loop iteration. + for (i, c) in pattern.iter().enumerate() { + tab[*c as usize] = (pattern.len() - 1) - i; + } + + tab + } + + /// Select the guard character based off of the precomputed + /// frequency table. + fn select_guard(pattern: &[u8]) -> (u8, usize) { + let mut rarest = pattern[0]; + let mut rarest_rev_idx = pattern.len() - 1; + for (i, c) in pattern.iter().enumerate() { + if freq_rank(*c) < freq_rank(rarest) { + rarest = *c; + rarest_rev_idx = (pattern.len() - 1) - i; + } + } + + (rarest, rarest_rev_idx) + } + + /// If there is another occurrence of the skip + /// char, shift to it, otherwise just shift to + /// the next window. + fn compile_md2_shift(pattern: &[u8]) -> usize { + let shiftc = *pattern.last().unwrap(); + + // For a pattern of length 1 we will never apply the + // shift rule, so we use a poison value on the principle + // that failing fast is a good thing. + if pattern.len() == 1 { + return 0xDEADBEAF; + } + + let mut i = pattern.len() - 2; + while i > 0 { + if pattern[i] == shiftc { + return (pattern.len() - 1) - i; + } + i -= 1; + } + + // The skip char never re-occurs in the pattern, so + // we can just shift the whole window length. + pattern.len() - 1 + } + + fn approximate_size(&self) -> usize { + (self.pattern.len() * mem::size_of::()) + + (256 * mem::size_of::()) // skip table + } +} + +fn freq_rank(b: u8) -> usize { + BYTE_FREQUENCIES[b as usize] as usize +} + +#[cfg(test)] +mod tests { + use super::{BoyerMooreSearch, FreqyPacked}; + + // + // Unit Tests + // + + // The "hello, world" of string searching + #[test] + fn bm_find_subs() { + let searcher = BoyerMooreSearch::new(Vec::from(&b"pattern"[..])); + let haystack = b"I keep seeing patterns in this text"; + assert_eq!(14, searcher.find(haystack).unwrap()); + } + + #[test] + fn bm_find_no_subs() { + let searcher = BoyerMooreSearch::new(Vec::from(&b"pattern"[..])); + let haystack = b"I keep seeing needles in this text"; + assert_eq!(None, searcher.find(haystack)); + } + + // + // Regression Tests + // + + #[test] + fn bm_skip_reset_bug() { + let haystack = vec![0, 0, 0, 0, 0, 1, 1, 0]; + let needle = vec![0, 1, 1, 0]; + + let searcher = BoyerMooreSearch::new(needle); + let offset = searcher.find(haystack.as_slice()).unwrap(); + assert_eq!(4, offset); + } + + #[test] + fn bm_backstop_underflow_bug() { + let haystack = vec![0, 0]; + let needle = vec![0, 0]; + + let searcher = BoyerMooreSearch::new(needle); + let offset = searcher.find(haystack.as_slice()).unwrap(); + assert_eq!(0, offset); + } + + #[test] + fn bm_naive_off_by_one_bug() { + let haystack = vec![91]; + let needle = vec![91]; + + let naive_offset = naive_find(&needle, &haystack).unwrap(); + assert_eq!(0, naive_offset); + } + + #[test] + fn bm_memchr_fallback_indexing_bug() { + let mut haystack = vec![ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ]; + let needle = vec![1, 1, 1, 1, 32, 32, 87]; + let needle_start = haystack.len(); + haystack.extend(needle.clone()); + + let searcher = BoyerMooreSearch::new(needle); + assert_eq!(needle_start, searcher.find(haystack.as_slice()).unwrap()); + } + + #[test] + fn bm_backstop_boundary() { + let haystack = b"\ +// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +e_data.clone_created(entity_id, entity_to_add.entity_id); +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +" + .to_vec(); + let needle = b"clone_created".to_vec(); + + let searcher = BoyerMooreSearch::new(needle); + let result = searcher.find(&haystack); + assert_eq!(Some(43), result); + } + + #[test] + fn bm_win_gnu_indexing_bug() { + let haystack_raw = vec![ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ]; + let needle = vec![1, 1, 1, 1, 1, 1, 1]; + let haystack = haystack_raw.as_slice(); + + BoyerMooreSearch::new(needle.clone()).find(haystack); + } + + // + // QuickCheck Properties + // + + use quickcheck::TestResult; + + fn naive_find(needle: &[u8], haystack: &[u8]) -> Option { + assert!(needle.len() <= haystack.len()); + + for i in 0..(haystack.len() - (needle.len() - 1)) { + if haystack[i] == needle[0] + && &haystack[i..(i + needle.len())] == needle + { + return Some(i); + } + } + + None + } + + quickcheck! { + fn qc_bm_equals_nieve_find(pile1: Vec, pile2: Vec) -> TestResult { + if pile1.len() == 0 || pile2.len() == 0 { + return TestResult::discard(); + } + + let (needle, haystack) = if pile1.len() < pile2.len() { + (pile1, pile2.as_slice()) + } else { + (pile2, pile1.as_slice()) + }; + + let searcher = BoyerMooreSearch::new(needle.clone()); + TestResult::from_bool( + searcher.find(haystack) == naive_find(&needle, haystack)) + } + + fn qc_bm_equals_single(pile1: Vec, pile2: Vec) -> TestResult { + if pile1.len() == 0 || pile2.len() == 0 { + return TestResult::discard(); + } + + let (needle, haystack) = if pile1.len() < pile2.len() { + (pile1, pile2.as_slice()) + } else { + (pile2, pile1.as_slice()) + }; + + let bm_searcher = BoyerMooreSearch::new(needle.clone()); + let freqy_memchr = FreqyPacked::new(needle); + TestResult::from_bool( + bm_searcher.find(haystack) == freqy_memchr.find(haystack)) + } + + fn qc_bm_finds_trailing_needle( + haystack_pre: Vec, + needle: Vec + ) -> TestResult { + if needle.len() == 0 { + return TestResult::discard(); + } + + let mut haystack = haystack_pre.clone(); + let searcher = BoyerMooreSearch::new(needle.clone()); + + if haystack.len() >= needle.len() && + searcher.find(haystack.as_slice()).is_some() { + return TestResult::discard(); + } + + haystack.extend(needle.clone()); + + // What if the the tail of the haystack can start the + // needle? + let start = haystack_pre.len() + .checked_sub(needle.len()) + .unwrap_or(0); + for i in 0..(needle.len() - 1) { + if searcher.find(&haystack[(i + start)..]).is_some() { + return TestResult::discard(); + } + } + + TestResult::from_bool( + searcher.find(haystack.as_slice()) + .map(|x| x == haystack_pre.len()) + .unwrap_or(false)) + } + + // qc_equals_* is only testing the negative case as @burntsushi + // pointed out in https://github.com/rust-lang/regex/issues/446. + // This quickcheck prop represents an effort to force testing of + // the positive case. qc_bm_finds_first and qc_bm_finds_trailing_needle + // already check some of the positive cases, but they don't cover + // cases where the needle is in the middle of haystack. This prop + // fills that hole. + fn qc_bm_finds_subslice( + haystack: Vec, + needle_start: usize, + needle_length: usize + ) -> TestResult { + if haystack.len() == 0 { + return TestResult::discard(); + } + + let needle_start = needle_start % haystack.len(); + let needle_length = needle_length % (haystack.len() - needle_start); + + if needle_length == 0 { + return TestResult::discard(); + } + + let needle = &haystack[needle_start..(needle_start + needle_length)]; + + let bm_searcher = BoyerMooreSearch::new(needle.to_vec()); + + let start = naive_find(&needle, &haystack); + match start { + None => TestResult::from_bool(false), + Some(nf_start) => + TestResult::from_bool( + nf_start <= needle_start + && bm_searcher.find(&haystack) == start + ) + } + } + + fn qc_bm_finds_first(needle: Vec) -> TestResult { + if needle.len() == 0 { + return TestResult::discard(); + } + + let mut haystack = needle.clone(); + let searcher = BoyerMooreSearch::new(needle.clone()); + haystack.extend(needle); + + TestResult::from_bool( + searcher.find(haystack.as_slice()) + .map(|x| x == 0) + .unwrap_or(false)) + } + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/literal/mod.rs b/third_party/cargo/vendor/regex-1.3.3/src/literal/mod.rs new file mode 100644 index 0000000..783c63b --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/literal/mod.rs @@ -0,0 +1,55 @@ +pub use self::imp::*; + +#[cfg(feature = "perf-literal")] +mod imp; + +#[allow(missing_docs)] +#[cfg(not(feature = "perf-literal"))] +mod imp { + use syntax::hir::literal::Literals; + + #[derive(Clone, Debug)] + pub struct LiteralSearcher(()); + + impl LiteralSearcher { + pub fn empty() -> Self { + LiteralSearcher(()) + } + + pub fn prefixes(_: Literals) -> Self { + LiteralSearcher(()) + } + + pub fn suffixes(_: Literals) -> Self { + LiteralSearcher(()) + } + + pub fn complete(&self) -> bool { + false + } + + pub fn find(&self, _: &[u8]) -> Option<(usize, usize)> { + unreachable!() + } + + pub fn find_start(&self, _: &[u8]) -> Option<(usize, usize)> { + unreachable!() + } + + pub fn find_end(&self, _: &[u8]) -> Option<(usize, usize)> { + unreachable!() + } + + pub fn is_empty(&self) -> bool { + true + } + + pub fn len(&self) -> usize { + 0 + } + + pub fn approximate_size(&self) -> usize { + 0 + } + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/pattern.rs b/third_party/cargo/vendor/regex-1.3.3/src/pattern.rs new file mode 100644 index 0000000..e942667 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/pattern.rs @@ -0,0 +1,62 @@ +use std::str::pattern::{Pattern, SearchStep, Searcher}; + +use re_unicode::{Matches, Regex}; + +pub struct RegexSearcher<'r, 't> { + haystack: &'t str, + it: Matches<'r, 't>, + last_step_end: usize, + next_match: Option<(usize, usize)>, +} + +impl<'r, 't> Pattern<'t> for &'r Regex { + type Searcher = RegexSearcher<'r, 't>; + + fn into_searcher(self, haystack: &'t str) -> RegexSearcher<'r, 't> { + RegexSearcher { + haystack: haystack, + it: self.find_iter(haystack), + last_step_end: 0, + next_match: None, + } + } +} + +unsafe impl<'r, 't> Searcher<'t> for RegexSearcher<'r, 't> { + #[inline] + fn haystack(&self) -> &'t str { + self.haystack + } + + #[inline] + fn next(&mut self) -> SearchStep { + if let Some((s, e)) = self.next_match { + self.next_match = None; + self.last_step_end = e; + return SearchStep::Match(s, e); + } + match self.it.next() { + None => { + if self.last_step_end < self.haystack().len() { + let last = self.last_step_end; + self.last_step_end = self.haystack().len(); + SearchStep::Reject(last, self.haystack().len()) + } else { + SearchStep::Done + } + } + Some(m) => { + let (s, e) = (m.start(), m.end()); + if s == self.last_step_end { + self.last_step_end = e; + SearchStep::Match(s, e) + } else { + self.next_match = Some((s, e)); + let last = self.last_step_end; + self.last_step_end = s; + SearchStep::Reject(last, s) + } + } + } + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/pikevm.rs b/third_party/cargo/vendor/regex-1.3.3/src/pikevm.rs new file mode 100644 index 0000000..c106c76 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/pikevm.rs @@ -0,0 +1,360 @@ +// This module implements the Pike VM. That is, it guarantees linear time +// search of a regex on any text with memory use proportional to the size of +// the regex. +// +// It is equal in power to the backtracking engine in this crate, except the +// backtracking engine is typically faster on small regexes/texts at the +// expense of a bigger memory footprint. +// +// It can do more than the DFA can (specifically, record capture locations +// and execute Unicode word boundary assertions), but at a slower speed. +// Specifically, the Pike VM exectues a DFA implicitly by repeatedly expanding +// epsilon transitions. That is, the Pike VM engine can be in multiple states +// at once where as the DFA is only ever in one state at a time. +// +// Therefore, the Pike VM is generally treated as the fallback when the other +// matching engines either aren't feasible to run or are insufficient. + +use std::mem; + +use exec::ProgramCache; +use input::{Input, InputAt}; +use prog::{InstPtr, Program}; +use re_trait::Slot; +use sparse::SparseSet; + +/// An NFA simulation matching engine. +#[derive(Debug)] +pub struct Fsm<'r, I> { + /// The sequence of opcodes (among other things) that is actually executed. + /// + /// The program may be byte oriented or Unicode codepoint oriented. + prog: &'r Program, + /// An explicit stack used for following epsilon transitions. (This is + /// borrowed from the cache.) + stack: &'r mut Vec, + /// The input to search. + input: I, +} + +/// A cached allocation that can be reused on each execution. +#[derive(Clone, Debug)] +pub struct Cache { + /// A pair of ordered sets for tracking NFA states. + clist: Threads, + nlist: Threads, + /// An explicit stack used for following epsilon transitions. + stack: Vec, +} + +/// An ordered set of NFA states and their captures. +#[derive(Clone, Debug)] +struct Threads { + /// An ordered set of opcodes (each opcode is an NFA state). + set: SparseSet, + /// Captures for every NFA state. + /// + /// It is stored in row-major order, where the columns are the capture + /// slots and the rows are the states. + caps: Vec, + /// The number of capture slots stored per thread. (Every capture has + /// two slots.) + slots_per_thread: usize, +} + +/// A representation of an explicit stack frame when following epsilon +/// transitions. This is used to avoid recursion. +#[derive(Clone, Debug)] +enum FollowEpsilon { + /// Follow transitions at the given instruction pointer. + IP(InstPtr), + /// Restore the capture slot with the given position in the input. + Capture { slot: usize, pos: Slot }, +} + +impl Cache { + /// Create a new allocation used by the NFA machine to record execution + /// and captures. + pub fn new(_prog: &Program) -> Self { + Cache { clist: Threads::new(), nlist: Threads::new(), stack: vec![] } + } +} + +impl<'r, I: Input> Fsm<'r, I> { + /// Execute the NFA matching engine. + /// + /// If there's a match, `exec` returns `true` and populates the given + /// captures accordingly. + pub fn exec( + prog: &'r Program, + cache: &ProgramCache, + matches: &mut [bool], + slots: &mut [Slot], + quit_after_match: bool, + input: I, + start: usize, + end: usize, + ) -> bool { + let mut cache = cache.borrow_mut(); + let cache = &mut cache.pikevm; + cache.clist.resize(prog.len(), prog.captures.len()); + cache.nlist.resize(prog.len(), prog.captures.len()); + let at = input.at(start); + Fsm { prog: prog, stack: &mut cache.stack, input: input }.exec_( + &mut cache.clist, + &mut cache.nlist, + matches, + slots, + quit_after_match, + at, + end, + ) + } + + fn exec_( + &mut self, + mut clist: &mut Threads, + mut nlist: &mut Threads, + matches: &mut [bool], + slots: &mut [Slot], + quit_after_match: bool, + mut at: InputAt, + end: usize, + ) -> bool { + let mut matched = false; + let mut all_matched = false; + clist.set.clear(); + nlist.set.clear(); + 'LOOP: loop { + if clist.set.is_empty() { + // Three ways to bail out when our current set of threads is + // empty. + // + // 1. We have a match---so we're done exploring any possible + // alternatives. Time to quit. (We can't do this if we're + // looking for matches for multiple regexes, unless we know + // they all matched.) + // + // 2. If the expression starts with a '^' we can terminate as + // soon as the last thread dies. + if (matched && matches.len() <= 1) + || all_matched + || (!at.is_start() && self.prog.is_anchored_start) + { + break; + } + + // 3. If there's a literal prefix for the program, try to + // jump ahead quickly. If it can't be found, then we can + // bail out early. + if !self.prog.prefixes.is_empty() { + at = match self.input.prefix_at(&self.prog.prefixes, at) { + None => break, + Some(at) => at, + }; + } + } + + // This simulates a preceding '.*?' for every regex by adding + // a state starting at the current position in the input for the + // beginning of the program only if we don't already have a match. + if clist.set.is_empty() + || (!self.prog.is_anchored_start && !all_matched) + { + self.add(&mut clist, slots, 0, at); + } + // The previous call to "add" actually inspects the position just + // before the current character. For stepping through the machine, + // we can to look at the current character, so we advance the + // input. + let at_next = self.input.at(at.next_pos()); + for i in 0..clist.set.len() { + let ip = clist.set[i]; + if self.step( + &mut nlist, + matches, + slots, + clist.caps(ip), + ip, + at, + at_next, + ) { + matched = true; + all_matched = all_matched || matches.iter().all(|&b| b); + if quit_after_match { + // If we only care if a match occurs (not its + // position), then we can quit right now. + break 'LOOP; + } + if self.prog.matches.len() == 1 { + // We don't need to check the rest of the threads + // in this set because we've matched something + // ("leftmost-first"). However, we still need to check + // threads in the next set to support things like + // greedy matching. + // + // This is only true on normal regexes. For regex sets, + // we need to mush on to observe other matches. + break; + } + } + } + if at.pos() >= end { + break; + } + at = at_next; + mem::swap(clist, nlist); + nlist.set.clear(); + } + matched + } + + /// Step through the input, one token (byte or codepoint) at a time. + /// + /// nlist is the set of states that will be processed on the next token + /// in the input. + /// + /// caps is the set of captures passed by the caller of the NFA. They are + /// written to only when a match state is visited. + /// + /// thread_caps is the set of captures set for the current NFA state, ip. + /// + /// at and at_next are the current and next positions in the input. at or + /// at_next may be EOF. + fn step( + &mut self, + nlist: &mut Threads, + matches: &mut [bool], + slots: &mut [Slot], + thread_caps: &mut [Option], + ip: usize, + at: InputAt, + at_next: InputAt, + ) -> bool { + use prog::Inst::*; + match self.prog[ip] { + Match(match_slot) => { + if match_slot < matches.len() { + matches[match_slot] = true; + } + for (slot, val) in slots.iter_mut().zip(thread_caps.iter()) { + *slot = *val; + } + true + } + Char(ref inst) => { + if inst.c == at.char() { + self.add(nlist, thread_caps, inst.goto, at_next); + } + false + } + Ranges(ref inst) => { + if inst.matches(at.char()) { + self.add(nlist, thread_caps, inst.goto, at_next); + } + false + } + Bytes(ref inst) => { + if let Some(b) = at.byte() { + if inst.matches(b) { + self.add(nlist, thread_caps, inst.goto, at_next); + } + } + false + } + EmptyLook(_) | Save(_) | Split(_) => false, + } + } + + /// Follows epsilon transitions and adds them for processing to nlist, + /// starting at and including ip. + fn add( + &mut self, + nlist: &mut Threads, + thread_caps: &mut [Option], + ip: usize, + at: InputAt, + ) { + self.stack.push(FollowEpsilon::IP(ip)); + while let Some(frame) = self.stack.pop() { + match frame { + FollowEpsilon::IP(ip) => { + self.add_step(nlist, thread_caps, ip, at); + } + FollowEpsilon::Capture { slot, pos } => { + thread_caps[slot] = pos; + } + } + } + } + + /// A helper function for add that avoids excessive pushing to the stack. + fn add_step( + &mut self, + nlist: &mut Threads, + thread_caps: &mut [Option], + mut ip: usize, + at: InputAt, + ) { + // Instead of pushing and popping to the stack, we mutate ip as we + // traverse the set of states. We only push to the stack when we + // absolutely need recursion (restoring captures or following a + // branch). + use prog::Inst::*; + loop { + // Don't visit states we've already added. + if nlist.set.contains(ip) { + return; + } + nlist.set.insert(ip); + match self.prog[ip] { + EmptyLook(ref inst) => { + if self.input.is_empty_match(at, inst) { + ip = inst.goto; + } + } + Save(ref inst) => { + if inst.slot < thread_caps.len() { + self.stack.push(FollowEpsilon::Capture { + slot: inst.slot, + pos: thread_caps[inst.slot], + }); + thread_caps[inst.slot] = Some(at.pos()); + } + ip = inst.goto; + } + Split(ref inst) => { + self.stack.push(FollowEpsilon::IP(inst.goto2)); + ip = inst.goto1; + } + Match(_) | Char(_) | Ranges(_) | Bytes(_) => { + let t = &mut nlist.caps(ip); + for (slot, val) in t.iter_mut().zip(thread_caps.iter()) { + *slot = *val; + } + return; + } + } + } + } +} + +impl Threads { + fn new() -> Self { + Threads { set: SparseSet::new(0), caps: vec![], slots_per_thread: 0 } + } + + fn resize(&mut self, num_insts: usize, ncaps: usize) { + if num_insts == self.set.capacity() { + return; + } + self.slots_per_thread = ncaps * 2; + self.set = SparseSet::new(num_insts); + self.caps = vec![None; self.slots_per_thread * num_insts]; + } + + fn caps(&mut self, pc: usize) -> &mut [Option] { + let i = pc * self.slots_per_thread; + &mut self.caps[i..i + self.slots_per_thread] + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/prog.rs b/third_party/cargo/vendor/regex-1.3.3/src/prog.rs new file mode 100644 index 0000000..74e5f2f --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/prog.rs @@ -0,0 +1,434 @@ +use std::cmp::Ordering; +use std::collections::HashMap; +use std::fmt; +use std::mem; +use std::ops::Deref; +use std::slice; +use std::sync::Arc; + +use input::Char; +use literal::LiteralSearcher; + +/// `InstPtr` represents the index of an instruction in a regex program. +pub type InstPtr = usize; + +/// Program is a sequence of instructions and various facts about thos +/// instructions. +#[derive(Clone)] +pub struct Program { + /// A sequence of instructions that represents an NFA. + pub insts: Vec, + /// Pointers to each Match instruction in the sequence. + /// + /// This is always length 1 unless this program represents a regex set. + pub matches: Vec, + /// The ordered sequence of all capture groups extracted from the AST. + /// Unnamed groups are `None`. + pub captures: Vec>, + /// Pointers to all named capture groups into `captures`. + pub capture_name_idx: Arc>, + /// A pointer to the start instruction. This can vary depending on how + /// the program was compiled. For example, programs for use with the DFA + /// engine have a `.*?` inserted at the beginning of unanchored regular + /// expressions. The actual starting point of the program is after the + /// `.*?`. + pub start: InstPtr, + /// A set of equivalence classes for discriminating bytes in the compiled + /// program. + pub byte_classes: Vec, + /// When true, this program can only match valid UTF-8. + pub only_utf8: bool, + /// When true, this program uses byte range instructions instead of Unicode + /// range instructions. + pub is_bytes: bool, + /// When true, the program is compiled for DFA matching. For example, this + /// implies `is_bytes` and also inserts a preceding `.*?` for unanchored + /// regexes. + pub is_dfa: bool, + /// When true, the program matches text in reverse (for use only in the + /// DFA). + pub is_reverse: bool, + /// Whether the regex must match from the start of the input. + pub is_anchored_start: bool, + /// Whether the regex must match at the end of the input. + pub is_anchored_end: bool, + /// Whether this program contains a Unicode word boundary instruction. + pub has_unicode_word_boundary: bool, + /// A possibly empty machine for very quickly matching prefix literals. + pub prefixes: LiteralSearcher, + /// A limit on the size of the cache that the DFA is allowed to use while + /// matching. + /// + /// The cache limit specifies approximately how much space we're willing to + /// give to the state cache. Once the state cache exceeds the size, it is + /// wiped and all states must be re-computed. + /// + /// Note that this value does not impact correctness. It can be set to 0 + /// and the DFA will run just fine. (It will only ever store exactly one + /// state in the cache, and will likely run very slowly, but it will work.) + /// + /// Also note that this limit is *per thread of execution*. That is, + /// if the same regex is used to search text across multiple threads + /// simultaneously, then the DFA cache is not shared. Instead, copies are + /// made. + pub dfa_size_limit: usize, +} + +impl Program { + /// Creates an empty instruction sequence. Fields are given default + /// values. + pub fn new() -> Self { + Program { + insts: vec![], + matches: vec![], + captures: vec![], + capture_name_idx: Arc::new(HashMap::new()), + start: 0, + byte_classes: vec![0; 256], + only_utf8: true, + is_bytes: false, + is_dfa: false, + is_reverse: false, + is_anchored_start: false, + is_anchored_end: false, + has_unicode_word_boundary: false, + prefixes: LiteralSearcher::empty(), + dfa_size_limit: 2 * (1 << 20), + } + } + + /// If pc is an index to a no-op instruction (like Save), then return the + /// next pc that is not a no-op instruction. + pub fn skip(&self, mut pc: usize) -> usize { + loop { + match self[pc] { + Inst::Save(ref i) => pc = i.goto, + _ => return pc, + } + } + } + + /// Return true if and only if an execution engine at instruction `pc` will + /// always lead to a match. + pub fn leads_to_match(&self, pc: usize) -> bool { + if self.matches.len() > 1 { + // If we have a regex set, then we have more than one ending + // state, so leading to one of those states is generally + // meaningless. + return false; + } + match self[self.skip(pc)] { + Inst::Match(_) => true, + _ => false, + } + } + + /// Returns true if the current configuration demands that an implicit + /// `.*?` be prepended to the instruction sequence. + pub fn needs_dotstar(&self) -> bool { + self.is_dfa && !self.is_reverse && !self.is_anchored_start + } + + /// Returns true if this program uses Byte instructions instead of + /// Char/Range instructions. + pub fn uses_bytes(&self) -> bool { + self.is_bytes || self.is_dfa + } + + /// Returns true if this program exclusively matches valid UTF-8 bytes. + /// + /// That is, if an invalid UTF-8 byte is seen, then no match is possible. + pub fn only_utf8(&self) -> bool { + self.only_utf8 + } + + /// Return the approximate heap usage of this instruction sequence in + /// bytes. + pub fn approximate_size(&self) -> usize { + // The only instruction that uses heap space is Ranges (for + // Unicode codepoint programs) to store non-overlapping codepoint + // ranges. To keep this operation constant time, we ignore them. + (self.len() * mem::size_of::()) + + (self.matches.len() * mem::size_of::()) + + (self.captures.len() * mem::size_of::>()) + + (self.capture_name_idx.len() + * (mem::size_of::() + mem::size_of::())) + + (self.byte_classes.len() * mem::size_of::()) + + self.prefixes.approximate_size() + } +} + +impl Deref for Program { + type Target = [Inst]; + + #[cfg_attr(feature = "perf-inline", inline(always))] + fn deref(&self) -> &Self::Target { + &*self.insts + } +} + +impl fmt::Debug for Program { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use self::Inst::*; + + fn with_goto(cur: usize, goto: usize, fmtd: String) -> String { + if goto == cur + 1 { + fmtd + } else { + format!("{} (goto: {})", fmtd, goto) + } + } + + fn visible_byte(b: u8) -> String { + use std::ascii::escape_default; + let escaped = escape_default(b).collect::>(); + String::from_utf8_lossy(&escaped).into_owned() + } + + for (pc, inst) in self.iter().enumerate() { + match *inst { + Match(slot) => write!(f, "{:04} Match({:?})", pc, slot)?, + Save(ref inst) => { + let s = format!("{:04} Save({})", pc, inst.slot); + write!(f, "{}", with_goto(pc, inst.goto, s))?; + } + Split(ref inst) => { + write!( + f, + "{:04} Split({}, {})", + pc, inst.goto1, inst.goto2 + )?; + } + EmptyLook(ref inst) => { + let s = format!("{:?}", inst.look); + write!(f, "{:04} {}", pc, with_goto(pc, inst.goto, s))?; + } + Char(ref inst) => { + let s = format!("{:?}", inst.c); + write!(f, "{:04} {}", pc, with_goto(pc, inst.goto, s))?; + } + Ranges(ref inst) => { + let ranges = inst + .ranges + .iter() + .map(|r| format!("{:?}-{:?}", r.0, r.1)) + .collect::>() + .join(", "); + write!( + f, + "{:04} {}", + pc, + with_goto(pc, inst.goto, ranges) + )?; + } + Bytes(ref inst) => { + let s = format!( + "Bytes({}, {})", + visible_byte(inst.start), + visible_byte(inst.end) + ); + write!(f, "{:04} {}", pc, with_goto(pc, inst.goto, s))?; + } + } + if pc == self.start { + write!(f, " (start)")?; + } + write!(f, "\n")?; + } + Ok(()) + } +} + +impl<'a> IntoIterator for &'a Program { + type Item = &'a Inst; + type IntoIter = slice::Iter<'a, Inst>; + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + +/// Inst is an instruction code in a Regex program. +/// +/// Regrettably, a regex program either contains Unicode codepoint +/// instructions (Char and Ranges) or it contains byte instructions (Bytes). +/// A regex program can never contain both. +/// +/// It would be worth investigating splitting this into two distinct types and +/// then figuring out how to make the matching engines polymorphic over those +/// types without sacrificing performance. +/// +/// Other than the benefit of moving invariants into the type system, another +/// benefit is the decreased size. If we remove the `Char` and `Ranges` +/// instructions from the `Inst` enum, then its size shrinks from 40 bytes to +/// 24 bytes. (This is because of the removal of a `Vec` in the `Ranges` +/// variant.) Given that byte based machines are typically much bigger than +/// their Unicode analogues (because they can decode UTF-8 directly), this ends +/// up being a pretty significant savings. +#[derive(Clone, Debug)] +pub enum Inst { + /// Match indicates that the program has reached a match state. + /// + /// The number in the match corresponds to the Nth logical regular + /// expression in this program. This index is always 0 for normal regex + /// programs. Values greater than 0 appear when compiling regex sets, and + /// each match instruction gets its own unique value. The value corresponds + /// to the Nth regex in the set. + Match(usize), + /// Save causes the program to save the current location of the input in + /// the slot indicated by InstSave. + Save(InstSave), + /// Split causes the program to diverge to one of two paths in the + /// program, preferring goto1 in InstSplit. + Split(InstSplit), + /// EmptyLook represents a zero-width assertion in a regex program. A + /// zero-width assertion does not consume any of the input text. + EmptyLook(InstEmptyLook), + /// Char requires the regex program to match the character in InstChar at + /// the current position in the input. + Char(InstChar), + /// Ranges requires the regex program to match the character at the current + /// position in the input with one of the ranges specified in InstRanges. + Ranges(InstRanges), + /// Bytes is like Ranges, except it expresses a single byte range. It is + /// used in conjunction with Split instructions to implement multi-byte + /// character classes. + Bytes(InstBytes), +} + +impl Inst { + /// Returns true if and only if this is a match instruction. + pub fn is_match(&self) -> bool { + match *self { + Inst::Match(_) => true, + _ => false, + } + } +} + +/// Representation of the Save instruction. +#[derive(Clone, Debug)] +pub struct InstSave { + /// The next location to execute in the program. + pub goto: InstPtr, + /// The capture slot (there are two slots for every capture in a regex, + /// including the zeroth capture for the entire match). + pub slot: usize, +} + +/// Representation of the Split instruction. +#[derive(Clone, Debug)] +pub struct InstSplit { + /// The first instruction to try. A match resulting from following goto1 + /// has precedence over a match resulting from following goto2. + pub goto1: InstPtr, + /// The second instruction to try. A match resulting from following goto1 + /// has precedence over a match resulting from following goto2. + pub goto2: InstPtr, +} + +/// Representation of the `EmptyLook` instruction. +#[derive(Clone, Debug)] +pub struct InstEmptyLook { + /// The next location to execute in the program if this instruction + /// succeeds. + pub goto: InstPtr, + /// The type of zero-width assertion to check. + pub look: EmptyLook, +} + +/// The set of zero-width match instructions. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum EmptyLook { + /// Start of line or input. + StartLine, + /// End of line or input. + EndLine, + /// Start of input. + StartText, + /// End of input. + EndText, + /// Word character on one side and non-word character on other. + WordBoundary, + /// Word character on both sides or non-word character on both sides. + NotWordBoundary, + /// ASCII word boundary. + WordBoundaryAscii, + /// Not ASCII word boundary. + NotWordBoundaryAscii, +} + +/// Representation of the Char instruction. +#[derive(Clone, Debug)] +pub struct InstChar { + /// The next location to execute in the program if this instruction + /// succeeds. + pub goto: InstPtr, + /// The character to test. + pub c: char, +} + +/// Representation of the Ranges instruction. +#[derive(Clone, Debug)] +pub struct InstRanges { + /// The next location to execute in the program if this instruction + /// succeeds. + pub goto: InstPtr, + /// The set of Unicode scalar value ranges to test. + pub ranges: Vec<(char, char)>, +} + +impl InstRanges { + /// Tests whether the given input character matches this instruction. + pub fn matches(&self, c: Char) -> bool { + // This speeds up the `match_class_unicode` benchmark by checking + // some common cases quickly without binary search. e.g., Matching + // a Unicode class on predominantly ASCII text. + for r in self.ranges.iter().take(4) { + if c < r.0 { + return false; + } + if c <= r.1 { + return true; + } + } + self.ranges + .binary_search_by(|r| { + if r.1 < c { + Ordering::Less + } else if r.0 > c { + Ordering::Greater + } else { + Ordering::Equal + } + }) + .is_ok() + } + + /// Return the number of distinct characters represented by all of the + /// ranges. + pub fn num_chars(&self) -> usize { + self.ranges + .iter() + .map(|&(s, e)| 1 + (e as u32) - (s as u32)) + .sum::() as usize + } +} + +/// Representation of the Bytes instruction. +#[derive(Clone, Debug)] +pub struct InstBytes { + /// The next location to execute in the program if this instruction + /// succeeds. + pub goto: InstPtr, + /// The start (inclusive) of this byte range. + pub start: u8, + /// The end (inclusive) of this byte range. + pub end: u8, +} + +impl InstBytes { + /// Returns true if and only if the given byte is in this range. + pub fn matches(&self, byte: u8) -> bool { + self.start <= byte && byte <= self.end + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/re_builder.rs b/third_party/cargo/vendor/regex-1.3.3/src/re_builder.rs new file mode 100644 index 0000000..3fef99d --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/re_builder.rs @@ -0,0 +1,419 @@ +/// The set of user configurable options for compiling zero or more regexes. +#[derive(Clone, Debug)] +#[allow(missing_docs)] +pub struct RegexOptions { + pub pats: Vec, + pub size_limit: usize, + pub dfa_size_limit: usize, + pub nest_limit: u32, + pub case_insensitive: bool, + pub multi_line: bool, + pub dot_matches_new_line: bool, + pub swap_greed: bool, + pub ignore_whitespace: bool, + pub unicode: bool, + pub octal: bool, +} + +impl Default for RegexOptions { + fn default() -> Self { + RegexOptions { + pats: vec![], + size_limit: 10 * (1 << 20), + dfa_size_limit: 2 * (1 << 20), + nest_limit: 250, + case_insensitive: false, + multi_line: false, + dot_matches_new_line: false, + swap_greed: false, + ignore_whitespace: false, + unicode: true, + octal: false, + } + } +} + +macro_rules! define_builder { + ($name:ident, $regex_mod:ident, $only_utf8:expr) => { + pub mod $name { + use super::RegexOptions; + use error::Error; + use exec::ExecBuilder; + + use $regex_mod::Regex; + + /// A configurable builder for a regular expression. + /// + /// A builder can be used to configure how the regex is built, for example, by + /// setting the default flags (which can be overridden in the expression + /// itself) or setting various limits. + pub struct RegexBuilder(RegexOptions); + + impl RegexBuilder { + /// Create a new regular expression builder with the given pattern. + /// + /// If the pattern is invalid, then an error will be returned when + /// `build` is called. + pub fn new(pattern: &str) -> RegexBuilder { + let mut builder = RegexBuilder(RegexOptions::default()); + builder.0.pats.push(pattern.to_owned()); + builder + } + + /// Consume the builder and compile the regular expression. + /// + /// Note that calling `as_str` on the resulting `Regex` will produce the + /// pattern given to `new` verbatim. Notably, it will not incorporate any + /// of the flags set on this builder. + pub fn build(&self) -> Result { + ExecBuilder::new_options(self.0.clone()) + .only_utf8($only_utf8) + .build() + .map(Regex::from) + } + + /// Set the value for the case insensitive (`i`) flag. + /// + /// When enabled, letters in the pattern will match both upper case and + /// lower case variants. + pub fn case_insensitive( + &mut self, + yes: bool, + ) -> &mut RegexBuilder { + self.0.case_insensitive = yes; + self + } + + /// Set the value for the multi-line matching (`m`) flag. + /// + /// When enabled, `^` matches the beginning of lines and `$` matches the + /// end of lines. + /// + /// By default, they match beginning/end of the input. + pub fn multi_line(&mut self, yes: bool) -> &mut RegexBuilder { + self.0.multi_line = yes; + self + } + + /// Set the value for the any character (`s`) flag, where in `.` matches + /// anything when `s` is set and matches anything except for new line when + /// it is not set (the default). + /// + /// N.B. "matches anything" means "any byte" when Unicode is disabled and + /// means "any valid UTF-8 encoding of any Unicode scalar value" when + /// Unicode is enabled. + pub fn dot_matches_new_line( + &mut self, + yes: bool, + ) -> &mut RegexBuilder { + self.0.dot_matches_new_line = yes; + self + } + + /// Set the value for the greedy swap (`U`) flag. + /// + /// When enabled, a pattern like `a*` is lazy (tries to find shortest + /// match) and `a*?` is greedy (tries to find longest match). + /// + /// By default, `a*` is greedy and `a*?` is lazy. + pub fn swap_greed(&mut self, yes: bool) -> &mut RegexBuilder { + self.0.swap_greed = yes; + self + } + + /// Set the value for the ignore whitespace (`x`) flag. + /// + /// When enabled, whitespace such as new lines and spaces will be ignored + /// between expressions of the pattern, and `#` can be used to start a + /// comment until the next new line. + pub fn ignore_whitespace( + &mut self, + yes: bool, + ) -> &mut RegexBuilder { + self.0.ignore_whitespace = yes; + self + } + + /// Set the value for the Unicode (`u`) flag. + /// + /// Enabled by default. When disabled, character classes such as `\w` only + /// match ASCII word characters instead of all Unicode word characters. + pub fn unicode(&mut self, yes: bool) -> &mut RegexBuilder { + self.0.unicode = yes; + self + } + + /// Whether to support octal syntax or not. + /// + /// Octal syntax is a little-known way of uttering Unicode codepoints in + /// a regular expression. For example, `a`, `\x61`, `\u0061` and + /// `\141` are all equivalent regular expressions, where the last example + /// shows octal syntax. + /// + /// While supporting octal syntax isn't in and of itself a problem, it does + /// make good error messages harder. That is, in PCRE based regex engines, + /// syntax like `\0` invokes a backreference, which is explicitly + /// unsupported in Rust's regex engine. However, many users expect it to + /// be supported. Therefore, when octal support is disabled, the error + /// message will explicitly mention that backreferences aren't supported. + /// + /// Octal syntax is disabled by default. + pub fn octal(&mut self, yes: bool) -> &mut RegexBuilder { + self.0.octal = yes; + self + } + + /// Set the approximate size limit of the compiled regular expression. + /// + /// This roughly corresponds to the number of bytes occupied by a single + /// compiled program. If the program exceeds this number, then a + /// compilation error is returned. + pub fn size_limit( + &mut self, + limit: usize, + ) -> &mut RegexBuilder { + self.0.size_limit = limit; + self + } + + /// Set the approximate size of the cache used by the DFA. + /// + /// This roughly corresponds to the number of bytes that the DFA will + /// use while searching. + /// + /// Note that this is a *per thread* limit. There is no way to set a global + /// limit. In particular, if a regex is used from multiple threads + /// simultaneously, then each thread may use up to the number of bytes + /// specified here. + pub fn dfa_size_limit( + &mut self, + limit: usize, + ) -> &mut RegexBuilder { + self.0.dfa_size_limit = limit; + self + } + + /// Set the nesting limit for this parser. + /// + /// The nesting limit controls how deep the abstract syntax tree is allowed + /// to be. If the AST exceeds the given limit (e.g., with too many nested + /// groups), then an error is returned by the parser. + /// + /// The purpose of this limit is to act as a heuristic to prevent stack + /// overflow for consumers that do structural induction on an `Ast` using + /// explicit recursion. While this crate never does this (instead using + /// constant stack space and moving the call stack to the heap), other + /// crates may. + /// + /// This limit is not checked until the entire Ast is parsed. Therefore, + /// if callers want to put a limit on the amount of heap space used, then + /// they should impose a limit on the length, in bytes, of the concrete + /// pattern string. In particular, this is viable since this parser + /// implementation will limit itself to heap space proportional to the + /// length of the pattern string. + /// + /// Note that a nest limit of `0` will return a nest limit error for most + /// patterns but not all. For example, a nest limit of `0` permits `a` but + /// not `ab`, since `ab` requires a concatenation, which results in a nest + /// depth of `1`. In general, a nest limit is not something that manifests + /// in an obvious way in the concrete syntax, therefore, it should not be + /// used in a granular way. + pub fn nest_limit(&mut self, limit: u32) -> &mut RegexBuilder { + self.0.nest_limit = limit; + self + } + } + } + }; +} + +define_builder!(bytes, re_bytes, false); +define_builder!(unicode, re_unicode, true); + +macro_rules! define_set_builder { + ($name:ident, $regex_mod:ident, $only_utf8:expr) => { + pub mod $name { + use super::RegexOptions; + use error::Error; + use exec::ExecBuilder; + + use re_set::$regex_mod::RegexSet; + + /// A configurable builder for a set of regular expressions. + /// + /// A builder can be used to configure how the regexes are built, for example, + /// by setting the default flags (which can be overridden in the expression + /// itself) or setting various limits. + pub struct RegexSetBuilder(RegexOptions); + + impl RegexSetBuilder { + /// Create a new regular expression builder with the given pattern. + /// + /// If the pattern is invalid, then an error will be returned when + /// `build` is called. + pub fn new(patterns: I) -> RegexSetBuilder + where + S: AsRef, + I: IntoIterator, + { + let mut builder = RegexSetBuilder(RegexOptions::default()); + for pat in patterns { + builder.0.pats.push(pat.as_ref().to_owned()); + } + builder + } + + /// Consume the builder and compile the regular expressions into a set. + pub fn build(&self) -> Result { + ExecBuilder::new_options(self.0.clone()) + .only_utf8($only_utf8) + .build() + .map(RegexSet::from) + } + + /// Set the value for the case insensitive (`i`) flag. + pub fn case_insensitive( + &mut self, + yes: bool, + ) -> &mut RegexSetBuilder { + self.0.case_insensitive = yes; + self + } + + /// Set the value for the multi-line matching (`m`) flag. + pub fn multi_line( + &mut self, + yes: bool, + ) -> &mut RegexSetBuilder { + self.0.multi_line = yes; + self + } + + /// Set the value for the any character (`s`) flag, where in `.` matches + /// anything when `s` is set and matches anything except for new line when + /// it is not set (the default). + /// + /// N.B. "matches anything" means "any byte" for `regex::bytes::RegexSet` + /// expressions and means "any Unicode scalar value" for `regex::RegexSet` + /// expressions. + pub fn dot_matches_new_line( + &mut self, + yes: bool, + ) -> &mut RegexSetBuilder { + self.0.dot_matches_new_line = yes; + self + } + + /// Set the value for the greedy swap (`U`) flag. + pub fn swap_greed( + &mut self, + yes: bool, + ) -> &mut RegexSetBuilder { + self.0.swap_greed = yes; + self + } + + /// Set the value for the ignore whitespace (`x`) flag. + pub fn ignore_whitespace( + &mut self, + yes: bool, + ) -> &mut RegexSetBuilder { + self.0.ignore_whitespace = yes; + self + } + + /// Set the value for the Unicode (`u`) flag. + pub fn unicode(&mut self, yes: bool) -> &mut RegexSetBuilder { + self.0.unicode = yes; + self + } + + /// Whether to support octal syntax or not. + /// + /// Octal syntax is a little-known way of uttering Unicode codepoints in + /// a regular expression. For example, `a`, `\x61`, `\u0061` and + /// `\141` are all equivalent regular expressions, where the last example + /// shows octal syntax. + /// + /// While supporting octal syntax isn't in and of itself a problem, it does + /// make good error messages harder. That is, in PCRE based regex engines, + /// syntax like `\0` invokes a backreference, which is explicitly + /// unsupported in Rust's regex engine. However, many users expect it to + /// be supported. Therefore, when octal support is disabled, the error + /// message will explicitly mention that backreferences aren't supported. + /// + /// Octal syntax is disabled by default. + pub fn octal(&mut self, yes: bool) -> &mut RegexSetBuilder { + self.0.octal = yes; + self + } + + /// Set the approximate size limit of the compiled regular expression. + /// + /// This roughly corresponds to the number of bytes occupied by a single + /// compiled program. If the program exceeds this number, then a + /// compilation error is returned. + pub fn size_limit( + &mut self, + limit: usize, + ) -> &mut RegexSetBuilder { + self.0.size_limit = limit; + self + } + + /// Set the approximate size of the cache used by the DFA. + /// + /// This roughly corresponds to the number of bytes that the DFA will + /// use while searching. + /// + /// Note that this is a *per thread* limit. There is no way to set a global + /// limit. In particular, if a regex is used from multiple threads + /// simultaneously, then each thread may use up to the number of bytes + /// specified here. + pub fn dfa_size_limit( + &mut self, + limit: usize, + ) -> &mut RegexSetBuilder { + self.0.dfa_size_limit = limit; + self + } + + /// Set the nesting limit for this parser. + /// + /// The nesting limit controls how deep the abstract syntax tree is allowed + /// to be. If the AST exceeds the given limit (e.g., with too many nested + /// groups), then an error is returned by the parser. + /// + /// The purpose of this limit is to act as a heuristic to prevent stack + /// overflow for consumers that do structural induction on an `Ast` using + /// explicit recursion. While this crate never does this (instead using + /// constant stack space and moving the call stack to the heap), other + /// crates may. + /// + /// This limit is not checked until the entire Ast is parsed. Therefore, + /// if callers want to put a limit on the amount of heap space used, then + /// they should impose a limit on the length, in bytes, of the concrete + /// pattern string. In particular, this is viable since this parser + /// implementation will limit itself to heap space proportional to the + /// length of the pattern string. + /// + /// Note that a nest limit of `0` will return a nest limit error for most + /// patterns but not all. For example, a nest limit of `0` permits `a` but + /// not `ab`, since `ab` requires a concatenation, which results in a nest + /// depth of `1`. In general, a nest limit is not something that manifests + /// in an obvious way in the concrete syntax, therefore, it should not be + /// used in a granular way. + pub fn nest_limit( + &mut self, + limit: u32, + ) -> &mut RegexSetBuilder { + self.0.nest_limit = limit; + self + } + } + } + }; +} + +define_set_builder!(set_bytes, bytes, false); +define_set_builder!(set_unicode, unicode, true); diff --git a/third_party/cargo/vendor/regex-1.3.3/src/re_bytes.rs b/third_party/cargo/vendor/regex-1.3.3/src/re_bytes.rs new file mode 100644 index 0000000..69f0b33 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/re_bytes.rs @@ -0,0 +1,1179 @@ +use std::borrow::Cow; +use std::collections::HashMap; +use std::fmt; +use std::ops::{Index, Range}; +use std::str::FromStr; +use std::sync::Arc; + +use find_byte::find_byte; + +use error::Error; +use exec::{Exec, ExecNoSync}; +use expand::expand_bytes; +use re_builder::bytes::RegexBuilder; +use re_trait::{self, RegularExpression, SubCapturesPosIter}; + +/// Match represents a single match of a regex in a haystack. +/// +/// The lifetime parameter `'t` refers to the lifetime of the matched text. +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub struct Match<'t> { + text: &'t [u8], + start: usize, + end: usize, +} + +impl<'t> Match<'t> { + /// Returns the starting byte offset of the match in the haystack. + #[inline] + pub fn start(&self) -> usize { + self.start + } + + /// Returns the ending byte offset of the match in the haystack. + #[inline] + pub fn end(&self) -> usize { + self.end + } + + /// Returns the range over the starting and ending byte offsets of the + /// match in the haystack. + #[inline] + pub fn range(&self) -> Range { + self.start..self.end + } + + /// Returns the matched text. + #[inline] + pub fn as_bytes(&self) -> &'t [u8] { + &self.text[self.range()] + } + + /// Creates a new match from the given haystack and byte offsets. + #[inline] + fn new(haystack: &'t [u8], start: usize, end: usize) -> Match<'t> { + Match { text: haystack, start: start, end: end } + } +} + +impl<'t> From> for Range { + fn from(m: Match<'t>) -> Range { + m.range() + } +} + +/// A compiled regular expression for matching arbitrary bytes. +/// +/// It can be used to search, split or replace text. All searching is done with +/// an implicit `.*?` at the beginning and end of an expression. To force an +/// expression to match the whole string (or a prefix or a suffix), you must +/// use an anchor like `^` or `$` (or `\A` and `\z`). +/// +/// Like the `Regex` type in the parent module, matches with this regex return +/// byte offsets into the search text. **Unlike** the parent `Regex` type, +/// these byte offsets may not correspond to UTF-8 sequence boundaries since +/// the regexes in this module can match arbitrary bytes. +#[derive(Clone)] +pub struct Regex(Exec); + +impl fmt::Display for Regex { + /// Shows the original regular expression. + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.as_str()) + } +} + +impl fmt::Debug for Regex { + /// Shows the original regular expression. + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +/// A constructor for Regex from an Exec. +/// +/// This is hidden because Exec isn't actually part of the public API. +#[doc(hidden)] +impl From for Regex { + fn from(exec: Exec) -> Regex { + Regex(exec) + } +} + +impl FromStr for Regex { + type Err = Error; + + /// Attempts to parse a string into a regular expression + fn from_str(s: &str) -> Result { + Regex::new(s) + } +} + +/// Core regular expression methods. +impl Regex { + /// Compiles a regular expression. Once compiled, it can be used repeatedly + /// to search, split or replace text in a string. + /// + /// If an invalid expression is given, then an error is returned. + pub fn new(re: &str) -> Result { + RegexBuilder::new(re).build() + } + + /// Returns true if and only if the regex matches the string given. + /// + /// It is recommended to use this method if all you need to do is test + /// a match, since the underlying matching engine may be able to do less + /// work. + /// + /// # Example + /// + /// Test if some text contains at least one word with exactly 13 ASCII word + /// bytes: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let text = b"I categorically deny having triskaidekaphobia."; + /// assert!(Regex::new(r"\b\w{13}\b").unwrap().is_match(text)); + /// # } + /// ``` + pub fn is_match(&self, text: &[u8]) -> bool { + self.is_match_at(text, 0) + } + + /// Returns the start and end byte range of the leftmost-first match in + /// `text`. If no match exists, then `None` is returned. + /// + /// Note that this should only be used if you want to discover the position + /// of the match. Testing the existence of a match is faster if you use + /// `is_match`. + /// + /// # Example + /// + /// Find the start and end location of the first word with exactly 13 + /// ASCII word bytes: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let text = b"I categorically deny having triskaidekaphobia."; + /// let mat = Regex::new(r"\b\w{13}\b").unwrap().find(text).unwrap(); + /// assert_eq!((mat.start(), mat.end()), (2, 15)); + /// # } + /// ``` + pub fn find<'t>(&self, text: &'t [u8]) -> Option> { + self.find_at(text, 0) + } + + /// Returns an iterator for each successive non-overlapping match in + /// `text`, returning the start and end byte indices with respect to + /// `text`. + /// + /// # Example + /// + /// Find the start and end location of every word with exactly 13 ASCII + /// word bytes: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let text = b"Retroactively relinquishing remunerations is reprehensible."; + /// for mat in Regex::new(r"\b\w{13}\b").unwrap().find_iter(text) { + /// println!("{:?}", mat); + /// } + /// # } + /// ``` + pub fn find_iter<'r, 't>(&'r self, text: &'t [u8]) -> Matches<'r, 't> { + Matches(self.0.searcher().find_iter(text)) + } + + /// Returns the capture groups corresponding to the leftmost-first + /// match in `text`. Capture group `0` always corresponds to the entire + /// match. If no match is found, then `None` is returned. + /// + /// You should only use `captures` if you need access to the location of + /// capturing group matches. Otherwise, `find` is faster for discovering + /// the location of the overall match. + /// + /// # Examples + /// + /// Say you have some text with movie names and their release years, + /// like "'Citizen Kane' (1941)". It'd be nice if we could search for text + /// looking like that, while also extracting the movie name and its release + /// year separately. + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let re = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap(); + /// let text = b"Not my favorite movie: 'Citizen Kane' (1941)."; + /// let caps = re.captures(text).unwrap(); + /// assert_eq!(caps.get(1).unwrap().as_bytes(), &b"Citizen Kane"[..]); + /// assert_eq!(caps.get(2).unwrap().as_bytes(), &b"1941"[..]); + /// assert_eq!(caps.get(0).unwrap().as_bytes(), &b"'Citizen Kane' (1941)"[..]); + /// // You can also access the groups by index using the Index notation. + /// // Note that this will panic on an invalid index. + /// assert_eq!(&caps[1], b"Citizen Kane"); + /// assert_eq!(&caps[2], b"1941"); + /// assert_eq!(&caps[0], b"'Citizen Kane' (1941)"); + /// # } + /// ``` + /// + /// Note that the full match is at capture group `0`. Each subsequent + /// capture group is indexed by the order of its opening `(`. + /// + /// We can make this example a bit clearer by using *named* capture groups: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let re = Regex::new(r"'(?P[^']+)'\s+\((?P<year>\d{4})\)") + /// .unwrap(); + /// let text = b"Not my favorite movie: 'Citizen Kane' (1941)."; + /// let caps = re.captures(text).unwrap(); + /// assert_eq!(caps.name("title").unwrap().as_bytes(), b"Citizen Kane"); + /// assert_eq!(caps.name("year").unwrap().as_bytes(), b"1941"); + /// assert_eq!(caps.get(0).unwrap().as_bytes(), &b"'Citizen Kane' (1941)"[..]); + /// // You can also access the groups by name using the Index notation. + /// // Note that this will panic on an invalid group name. + /// assert_eq!(&caps["title"], b"Citizen Kane"); + /// assert_eq!(&caps["year"], b"1941"); + /// assert_eq!(&caps[0], b"'Citizen Kane' (1941)"); + /// + /// # } + /// ``` + /// + /// Here we name the capture groups, which we can access with the `name` + /// method or the `Index` notation with a `&str`. Note that the named + /// capture groups are still accessible with `get` or the `Index` notation + /// with a `usize`. + /// + /// The `0`th capture group is always unnamed, so it must always be + /// accessed with `get(0)` or `[0]`. + pub fn captures<'t>(&self, text: &'t [u8]) -> Option<Captures<'t>> { + let mut locs = self.capture_locations(); + self.captures_read_at(&mut locs, text, 0).map(move |_| Captures { + text: text, + locs: locs.0, + named_groups: self.0.capture_name_idx().clone(), + }) + } + + /// Returns an iterator over all the non-overlapping capture groups matched + /// in `text`. This is operationally the same as `find_iter`, except it + /// yields information about capturing group matches. + /// + /// # Example + /// + /// We can use this to find all movie titles and their release years in + /// some text, where the movie is formatted like "'Title' (xxxx)": + /// + /// ```rust + /// # extern crate regex; use std::str; use regex::bytes::Regex; + /// # fn main() { + /// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)") + /// .unwrap(); + /// let text = b"'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931)."; + /// for caps in re.captures_iter(text) { + /// let title = str::from_utf8(&caps["title"]).unwrap(); + /// let year = str::from_utf8(&caps["year"]).unwrap(); + /// println!("Movie: {:?}, Released: {:?}", title, year); + /// } + /// // Output: + /// // Movie: Citizen Kane, Released: 1941 + /// // Movie: The Wizard of Oz, Released: 1939 + /// // Movie: M, Released: 1931 + /// # } + /// ``` + pub fn captures_iter<'r, 't>( + &'r self, + text: &'t [u8], + ) -> CaptureMatches<'r, 't> { + CaptureMatches(self.0.searcher().captures_iter(text)) + } + + /// Returns an iterator of substrings of `text` delimited by a match of the + /// regular expression. Namely, each element of the iterator corresponds to + /// text that *isn't* matched by the regular expression. + /// + /// This method will *not* copy the text given. + /// + /// # Example + /// + /// To split a string delimited by arbitrary amounts of spaces or tabs: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let re = Regex::new(r"[ \t]+").unwrap(); + /// let fields: Vec<&[u8]> = re.split(b"a b \t c\td e").collect(); + /// assert_eq!(fields, vec![ + /// &b"a"[..], &b"b"[..], &b"c"[..], &b"d"[..], &b"e"[..], + /// ]); + /// # } + /// ``` + pub fn split<'r, 't>(&'r self, text: &'t [u8]) -> Split<'r, 't> { + Split { finder: self.find_iter(text), last: 0 } + } + + /// Returns an iterator of at most `limit` substrings of `text` delimited + /// by a match of the regular expression. (A `limit` of `0` will return no + /// substrings.) Namely, each element of the iterator corresponds to text + /// that *isn't* matched by the regular expression. The remainder of the + /// string that is not split will be the last element in the iterator. + /// + /// This method will *not* copy the text given. + /// + /// # Example + /// + /// Get the first two words in some text: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let re = Regex::new(r"\W+").unwrap(); + /// let fields: Vec<&[u8]> = re.splitn(b"Hey! How are you?", 3).collect(); + /// assert_eq!(fields, vec![&b"Hey"[..], &b"How"[..], &b"are you?"[..]]); + /// # } + /// ``` + pub fn splitn<'r, 't>( + &'r self, + text: &'t [u8], + limit: usize, + ) -> SplitN<'r, 't> { + SplitN { splits: self.split(text), n: limit } + } + + /// Replaces the leftmost-first match with the replacement provided. The + /// replacement can be a regular byte string (where `$N` and `$name` are + /// expanded to match capture groups) or a function that takes the matches' + /// `Captures` and returns the replaced byte string. + /// + /// If no match is found, then a copy of the byte string is returned + /// unchanged. + /// + /// # Replacement string syntax + /// + /// All instances of `$name` in the replacement text is replaced with the + /// corresponding capture group `name`. + /// + /// `name` may be an integer corresponding to the index of the + /// capture group (counted by order of opening parenthesis where `0` is the + /// entire match) or it can be a name (consisting of letters, digits or + /// underscores) corresponding to a named capture group. + /// + /// If `name` isn't a valid capture group (whether the name doesn't exist + /// or isn't a valid index), then it is replaced with the empty string. + /// + /// The longest possible name is used. e.g., `$1a` looks up the capture + /// group named `1a` and not the capture group at index `1`. To exert more + /// precise control over the name, use braces, e.g., `${1}a`. + /// + /// To write a literal `$` use `$$`. + /// + /// # Examples + /// + /// Note that this function is polymorphic with respect to the replacement. + /// In typical usage, this can just be a normal byte string: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let re = Regex::new("[^01]+").unwrap(); + /// assert_eq!(re.replace(b"1078910", &b""[..]), &b"1010"[..]); + /// # } + /// ``` + /// + /// But anything satisfying the `Replacer` trait will work. For example, a + /// closure of type `|&Captures| -> Vec<u8>` provides direct access to the + /// captures corresponding to a match. This allows one to access capturing + /// group matches easily: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # use regex::bytes::Captures; fn main() { + /// let re = Regex::new(r"([^,\s]+),\s+(\S+)").unwrap(); + /// let result = re.replace(b"Springsteen, Bruce", |caps: &Captures| { + /// let mut replacement = caps[2].to_owned(); + /// replacement.push(b' '); + /// replacement.extend(&caps[1]); + /// replacement + /// }); + /// assert_eq!(result, &b"Bruce Springsteen"[..]); + /// # } + /// ``` + /// + /// But this is a bit cumbersome to use all the time. Instead, a simple + /// syntax is supported that expands `$name` into the corresponding capture + /// group. Here's the last example, but using this expansion technique + /// with named capture groups: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(?P<first>\S+)").unwrap(); + /// let result = re.replace(b"Springsteen, Bruce", &b"$first $last"[..]); + /// assert_eq!(result, &b"Bruce Springsteen"[..]); + /// # } + /// ``` + /// + /// Note that using `$2` instead of `$first` or `$1` instead of `$last` + /// would produce the same result. To write a literal `$` use `$$`. + /// + /// Sometimes the replacement string requires use of curly braces to + /// delineate a capture group replacement and surrounding literal text. + /// For example, if we wanted to join two words together with an + /// underscore: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let re = Regex::new(r"(?P<first>\w+)\s+(?P<second>\w+)").unwrap(); + /// let result = re.replace(b"deep fried", &b"${first}_$second"[..]); + /// assert_eq!(result, &b"deep_fried"[..]); + /// # } + /// ``` + /// + /// Without the curly braces, the capture group name `first_` would be + /// used, and since it doesn't exist, it would be replaced with the empty + /// string. + /// + /// Finally, sometimes you just want to replace a literal string with no + /// regard for capturing group expansion. This can be done by wrapping a + /// byte string with `NoExpand`: + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// use regex::bytes::NoExpand; + /// + /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(\S+)").unwrap(); + /// let result = re.replace(b"Springsteen, Bruce", NoExpand(b"$2 $last")); + /// assert_eq!(result, &b"$2 $last"[..]); + /// # } + /// ``` + pub fn replace<'t, R: Replacer>( + &self, + text: &'t [u8], + rep: R, + ) -> Cow<'t, [u8]> { + self.replacen(text, 1, rep) + } + + /// Replaces all non-overlapping matches in `text` with the replacement + /// provided. This is the same as calling `replacen` with `limit` set to + /// `0`. + /// + /// See the documentation for `replace` for details on how to access + /// capturing group matches in the replacement text. + pub fn replace_all<'t, R: Replacer>( + &self, + text: &'t [u8], + rep: R, + ) -> Cow<'t, [u8]> { + self.replacen(text, 0, rep) + } + + /// Replaces at most `limit` non-overlapping matches in `text` with the + /// replacement provided. If `limit` is 0, then all non-overlapping matches + /// are replaced. + /// + /// See the documentation for `replace` for details on how to access + /// capturing group matches in the replacement text. + pub fn replacen<'t, R: Replacer>( + &self, + text: &'t [u8], + limit: usize, + mut rep: R, + ) -> Cow<'t, [u8]> { + if let Some(rep) = rep.no_expansion() { + let mut it = self.find_iter(text).enumerate().peekable(); + if it.peek().is_none() { + return Cow::Borrowed(text); + } + let mut new = Vec::with_capacity(text.len()); + let mut last_match = 0; + for (i, m) in it { + if limit > 0 && i >= limit { + break; + } + new.extend_from_slice(&text[last_match..m.start()]); + new.extend_from_slice(&rep); + last_match = m.end(); + } + new.extend_from_slice(&text[last_match..]); + return Cow::Owned(new); + } + + // The slower path, which we use if the replacement needs access to + // capture groups. + let mut it = self.captures_iter(text).enumerate().peekable(); + if it.peek().is_none() { + return Cow::Borrowed(text); + } + let mut new = Vec::with_capacity(text.len()); + let mut last_match = 0; + for (i, cap) in it { + if limit > 0 && i >= limit { + break; + } + // unwrap on 0 is OK because captures only reports matches + let m = cap.get(0).unwrap(); + new.extend_from_slice(&text[last_match..m.start()]); + rep.replace_append(&cap, &mut new); + last_match = m.end(); + } + new.extend_from_slice(&text[last_match..]); + Cow::Owned(new) + } +} + +/// Advanced or "lower level" search methods. +impl Regex { + /// Returns the end location of a match in the text given. + /// + /// This method may have the same performance characteristics as + /// `is_match`, except it provides an end location for a match. In + /// particular, the location returned *may be shorter* than the proper end + /// of the leftmost-first match. + /// + /// # Example + /// + /// Typically, `a+` would match the entire first sequence of `a` in some + /// text, but `shortest_match` can give up as soon as it sees the first + /// `a`. + /// + /// ```rust + /// # extern crate regex; use regex::bytes::Regex; + /// # fn main() { + /// let text = b"aaaaa"; + /// let pos = Regex::new(r"a+").unwrap().shortest_match(text); + /// assert_eq!(pos, Some(1)); + /// # } + /// ``` + pub fn shortest_match(&self, text: &[u8]) -> Option<usize> { + self.shortest_match_at(text, 0) + } + + /// Returns the same as shortest_match, but starts the search at the given + /// offset. + /// + /// The significance of the starting point is that it takes the surrounding + /// context into consideration. For example, the `\A` anchor can only + /// match when `start == 0`. + pub fn shortest_match_at( + &self, + text: &[u8], + start: usize, + ) -> Option<usize> { + self.0.searcher().shortest_match_at(text, start) + } + + /// Returns the same as is_match, but starts the search at the given + /// offset. + /// + /// The significance of the starting point is that it takes the surrounding + /// context into consideration. For example, the `\A` anchor can only + /// match when `start == 0`. + pub fn is_match_at(&self, text: &[u8], start: usize) -> bool { + self.shortest_match_at(text, start).is_some() + } + + /// Returns the same as find, but starts the search at the given + /// offset. + /// + /// The significance of the starting point is that it takes the surrounding + /// context into consideration. For example, the `\A` anchor can only + /// match when `start == 0`. + pub fn find_at<'t>( + &self, + text: &'t [u8], + start: usize, + ) -> Option<Match<'t>> { + self.0 + .searcher() + .find_at(text, start) + .map(|(s, e)| Match::new(text, s, e)) + } + + /// This is like `captures`, but uses + /// [`CaptureLocations`](struct.CaptureLocations.html) + /// instead of + /// [`Captures`](struct.Captures.html) in order to amortize allocations. + /// + /// To create a `CaptureLocations` value, use the + /// `Regex::capture_locations` method. + /// + /// This returns the overall match if this was successful, which is always + /// equivalence to the `0`th capture group. + pub fn captures_read<'t>( + &self, + locs: &mut CaptureLocations, + text: &'t [u8], + ) -> Option<Match<'t>> { + self.captures_read_at(locs, text, 0) + } + + /// Returns the same as `captures_read`, but starts the search at the given + /// offset and populates the capture locations given. + /// + /// The significance of the starting point is that it takes the surrounding + /// context into consideration. For example, the `\A` anchor can only + /// match when `start == 0`. + pub fn captures_read_at<'t>( + &self, + locs: &mut CaptureLocations, + text: &'t [u8], + start: usize, + ) -> Option<Match<'t>> { + self.0 + .searcher() + .captures_read_at(&mut locs.0, text, start) + .map(|(s, e)| Match::new(text, s, e)) + } + + /// An undocumented alias for `captures_read_at`. + /// + /// The `regex-capi` crate previously used this routine, so to avoid + /// breaking that crate, we continue to provide the name as an undocumented + /// alias. + #[doc(hidden)] + pub fn read_captures_at<'t>( + &self, + locs: &mut CaptureLocations, + text: &'t [u8], + start: usize, + ) -> Option<Match<'t>> { + self.captures_read_at(locs, text, start) + } +} + +/// Auxiliary methods. +impl Regex { + /// Returns the original string of this regex. + pub fn as_str(&self) -> &str { + &self.0.regex_strings()[0] + } + + /// Returns an iterator over the capture names. + pub fn capture_names(&self) -> CaptureNames { + CaptureNames(self.0.capture_names().iter()) + } + + /// Returns the number of captures. + pub fn captures_len(&self) -> usize { + self.0.capture_names().len() + } + + /// Returns an empty set of capture locations that can be reused in + /// multiple calls to `captures_read` or `captures_read_at`. + pub fn capture_locations(&self) -> CaptureLocations { + CaptureLocations(self.0.searcher().locations()) + } + + /// An alias for `capture_locations` to preserve backward compatibility. + /// + /// The `regex-capi` crate uses this method, so to avoid breaking that + /// crate, we continue to export it as an undocumented API. + #[doc(hidden)] + pub fn locations(&self) -> CaptureLocations { + CaptureLocations(self.0.searcher().locations()) + } +} + +/// An iterator over all non-overlapping matches for a particular string. +/// +/// The iterator yields a tuple of integers corresponding to the start and end +/// of the match. The indices are byte offsets. The iterator stops when no more +/// matches can be found. +/// +/// `'r` is the lifetime of the compiled regular expression and `'t` is the +/// lifetime of the matched byte string. +pub struct Matches<'r, 't>(re_trait::Matches<'t, ExecNoSync<'r>>); + +impl<'r, 't> Iterator for Matches<'r, 't> { + type Item = Match<'t>; + + fn next(&mut self) -> Option<Match<'t>> { + let text = self.0.text(); + self.0.next().map(|(s, e)| Match::new(text, s, e)) + } +} + +/// An iterator that yields all non-overlapping capture groups matching a +/// particular regular expression. +/// +/// The iterator stops when no more matches can be found. +/// +/// `'r` is the lifetime of the compiled regular expression and `'t` is the +/// lifetime of the matched byte string. +pub struct CaptureMatches<'r, 't>( + re_trait::CaptureMatches<'t, ExecNoSync<'r>>, +); + +impl<'r, 't> Iterator for CaptureMatches<'r, 't> { + type Item = Captures<'t>; + + fn next(&mut self) -> Option<Captures<'t>> { + self.0.next().map(|locs| Captures { + text: self.0.text(), + locs: locs, + named_groups: self.0.regex().capture_name_idx().clone(), + }) + } +} + +/// Yields all substrings delimited by a regular expression match. +/// +/// `'r` is the lifetime of the compiled regular expression and `'t` is the +/// lifetime of the byte string being split. +pub struct Split<'r, 't> { + finder: Matches<'r, 't>, + last: usize, +} + +impl<'r, 't> Iterator for Split<'r, 't> { + type Item = &'t [u8]; + + fn next(&mut self) -> Option<&'t [u8]> { + let text = self.finder.0.text(); + match self.finder.next() { + None => { + if self.last > text.len() { + None + } else { + let s = &text[self.last..]; + self.last = text.len() + 1; // Next call will return None + Some(s) + } + } + Some(m) => { + let matched = &text[self.last..m.start()]; + self.last = m.end(); + Some(matched) + } + } + } +} + +/// Yields at most `N` substrings delimited by a regular expression match. +/// +/// The last substring will be whatever remains after splitting. +/// +/// `'r` is the lifetime of the compiled regular expression and `'t` is the +/// lifetime of the byte string being split. +pub struct SplitN<'r, 't> { + splits: Split<'r, 't>, + n: usize, +} + +impl<'r, 't> Iterator for SplitN<'r, 't> { + type Item = &'t [u8]; + + fn next(&mut self) -> Option<&'t [u8]> { + if self.n == 0 { + return None; + } + + self.n -= 1; + if self.n > 0 { + return self.splits.next(); + } + + let text = self.splits.finder.0.text(); + if self.splits.last > text.len() { + // We've already returned all substrings. + None + } else { + // self.n == 0, so future calls will return None immediately + Some(&text[self.splits.last..]) + } + } +} + +/// An iterator over the names of all possible captures. +/// +/// `None` indicates an unnamed capture; the first element (capture 0, the +/// whole matched region) is always unnamed. +/// +/// `'r` is the lifetime of the compiled regular expression. +pub struct CaptureNames<'r>(::std::slice::Iter<'r, Option<String>>); + +impl<'r> Iterator for CaptureNames<'r> { + type Item = Option<&'r str>; + + fn next(&mut self) -> Option<Option<&'r str>> { + self.0 + .next() + .as_ref() + .map(|slot| slot.as_ref().map(|name| name.as_ref())) + } + + fn size_hint(&self) -> (usize, Option<usize>) { + self.0.size_hint() + } +} + +/// CaptureLocations is a low level representation of the raw offsets of each +/// submatch. +/// +/// You can think of this as a lower level +/// [`Captures`](struct.Captures.html), where this type does not support +/// named capturing groups directly and it does not borrow the text that these +/// offsets were matched on. +/// +/// Primarily, this type is useful when using the lower level `Regex` APIs +/// such as `read_captures`, which permits amortizing the allocation in which +/// capture match locations are stored. +/// +/// In order to build a value of this type, you'll need to call the +/// `capture_locations` method on the `Regex` being used to execute the search. +/// The value returned can then be reused in subsequent searches. +#[derive(Clone, Debug)] +pub struct CaptureLocations(re_trait::Locations); + +/// A type alias for `CaptureLocations` for backwards compatibility. +/// +/// Previously, we exported `CaptureLocations` as `Locations` in an +/// undocumented API. To prevent breaking that code (e.g., in `regex-capi`), +/// we continue re-exporting the same undocumented API. +#[doc(hidden)] +pub type Locations = CaptureLocations; + +impl CaptureLocations { + /// Returns the start and end positions of the Nth capture group. Returns + /// `None` if `i` is not a valid capture group or if the capture group did + /// not match anything. The positions returned are *always* byte indices + /// with respect to the original string matched. + #[inline] + pub fn get(&self, i: usize) -> Option<(usize, usize)> { + self.0.pos(i) + } + + /// Returns the total number of capturing groups. + /// + /// This is always at least `1` since every regex has at least `1` + /// capturing group that corresponds to the entire match. + #[inline] + pub fn len(&self) -> usize { + self.0.len() + } + + /// An alias for the `get` method for backwards compatibility. + /// + /// Previously, we exported `get` as `pos` in an undocumented API. To + /// prevent breaking that code (e.g., in `regex-capi`), we continue + /// re-exporting the same undocumented API. + #[doc(hidden)] + #[inline] + pub fn pos(&self, i: usize) -> Option<(usize, usize)> { + self.get(i) + } +} + +/// Captures represents a group of captured byte strings for a single match. +/// +/// The 0th capture always corresponds to the entire match. Each subsequent +/// index corresponds to the next capture group in the regex. If a capture +/// group is named, then the matched byte string is *also* available via the +/// `name` method. (Note that the 0th capture is always unnamed and so must be +/// accessed with the `get` method.) +/// +/// Positions returned from a capture group are always byte indices. +/// +/// `'t` is the lifetime of the matched text. +pub struct Captures<'t> { + text: &'t [u8], + locs: re_trait::Locations, + named_groups: Arc<HashMap<String, usize>>, +} + +impl<'t> Captures<'t> { + /// Returns the match associated with the capture group at index `i`. If + /// `i` does not correspond to a capture group, or if the capture group + /// did not participate in the match, then `None` is returned. + /// + /// # Examples + /// + /// Get the text of the match with a default of an empty string if this + /// group didn't participate in the match: + /// + /// ```rust + /// # use regex::bytes::Regex; + /// let re = Regex::new(r"[a-z]+(?:([0-9]+)|([A-Z]+))").unwrap(); + /// let caps = re.captures(b"abc123").unwrap(); + /// + /// let text1 = caps.get(1).map_or(&b""[..], |m| m.as_bytes()); + /// let text2 = caps.get(2).map_or(&b""[..], |m| m.as_bytes()); + /// assert_eq!(text1, &b"123"[..]); + /// assert_eq!(text2, &b""[..]); + /// ``` + pub fn get(&self, i: usize) -> Option<Match<'t>> { + self.locs.pos(i).map(|(s, e)| Match::new(self.text, s, e)) + } + + /// Returns the match for the capture group named `name`. If `name` isn't a + /// valid capture group or didn't match anything, then `None` is returned. + pub fn name(&self, name: &str) -> Option<Match<'t>> { + self.named_groups.get(name).and_then(|&i| self.get(i)) + } + + /// An iterator that yields all capturing matches in the order in which + /// they appear in the regex. If a particular capture group didn't + /// participate in the match, then `None` is yielded for that capture. + /// + /// The first match always corresponds to the overall match of the regex. + pub fn iter<'c>(&'c self) -> SubCaptureMatches<'c, 't> { + SubCaptureMatches { caps: self, it: self.locs.iter() } + } + + /// Expands all instances of `$name` in `replacement` to the corresponding + /// capture group `name`, and writes them to the `dst` buffer given. + /// + /// `name` may be an integer corresponding to the index of the + /// capture group (counted by order of opening parenthesis where `0` is the + /// entire match) or it can be a name (consisting of letters, digits or + /// underscores) corresponding to a named capture group. + /// + /// If `name` isn't a valid capture group (whether the name doesn't exist + /// or isn't a valid index), then it is replaced with the empty string. + /// + /// The longest possible name is used. e.g., `$1a` looks up the capture + /// group named `1a` and not the capture group at index `1`. To exert more + /// precise control over the name, use braces, e.g., `${1}a`. + /// + /// To write a literal `$` use `$$`. + pub fn expand(&self, replacement: &[u8], dst: &mut Vec<u8>) { + expand_bytes(self, replacement, dst) + } + + /// Returns the number of captured groups. + /// + /// This is always at least `1`, since every regex has at least one capture + /// group that corresponds to the full match. + #[inline] + pub fn len(&self) -> usize { + self.locs.len() + } +} + +impl<'t> fmt::Debug for Captures<'t> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_tuple("Captures").field(&CapturesDebug(self)).finish() + } +} + +struct CapturesDebug<'c, 't: 'c>(&'c Captures<'t>); + +impl<'c, 't> fmt::Debug for CapturesDebug<'c, 't> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn escape_bytes(bytes: &[u8]) -> String { + let mut s = String::new(); + for &b in bytes { + s.push_str(&escape_byte(b)); + } + s + } + + fn escape_byte(byte: u8) -> String { + use std::ascii::escape_default; + + let escaped: Vec<u8> = escape_default(byte).collect(); + String::from_utf8_lossy(&escaped).into_owned() + } + + // We'd like to show something nice here, even if it means an + // allocation to build a reverse index. + let slot_to_name: HashMap<&usize, &String> = + self.0.named_groups.iter().map(|(a, b)| (b, a)).collect(); + let mut map = f.debug_map(); + for (slot, m) in self.0.locs.iter().enumerate() { + let m = m.map(|(s, e)| escape_bytes(&self.0.text[s..e])); + if let Some(name) = slot_to_name.get(&slot) { + map.entry(&name, &m); + } else { + map.entry(&slot, &m); + } + } + map.finish() + } +} + +/// Get a group by index. +/// +/// `'t` is the lifetime of the matched text. +/// +/// The text can't outlive the `Captures` object if this method is +/// used, because of how `Index` is defined (normally `a[i]` is part +/// of `a` and can't outlive it); to do that, use `get()` instead. +/// +/// # Panics +/// +/// If there is no group at the given index. +impl<'t> Index<usize> for Captures<'t> { + type Output = [u8]; + + fn index(&self, i: usize) -> &[u8] { + self.get(i) + .map(|m| m.as_bytes()) + .unwrap_or_else(|| panic!("no group at index '{}'", i)) + } +} + +/// Get a group by name. +/// +/// `'t` is the lifetime of the matched text and `'i` is the lifetime +/// of the group name (the index). +/// +/// The text can't outlive the `Captures` object if this method is +/// used, because of how `Index` is defined (normally `a[i]` is part +/// of `a` and can't outlive it); to do that, use `name` instead. +/// +/// # Panics +/// +/// If there is no group named by the given value. +impl<'t, 'i> Index<&'i str> for Captures<'t> { + type Output = [u8]; + + fn index<'a>(&'a self, name: &'i str) -> &'a [u8] { + self.name(name) + .map(|m| m.as_bytes()) + .unwrap_or_else(|| panic!("no group named '{}'", name)) + } +} + +/// An iterator that yields all capturing matches in the order in which they +/// appear in the regex. +/// +/// If a particular capture group didn't participate in the match, then `None` +/// is yielded for that capture. The first match always corresponds to the +/// overall match of the regex. +/// +/// The lifetime `'c` corresponds to the lifetime of the `Captures` value, and +/// the lifetime `'t` corresponds to the originally matched text. +pub struct SubCaptureMatches<'c, 't: 'c> { + caps: &'c Captures<'t>, + it: SubCapturesPosIter<'c>, +} + +impl<'c, 't> Iterator for SubCaptureMatches<'c, 't> { + type Item = Option<Match<'t>>; + + fn next(&mut self) -> Option<Option<Match<'t>>> { + self.it + .next() + .map(|cap| cap.map(|(s, e)| Match::new(self.caps.text, s, e))) + } +} + +/// Replacer describes types that can be used to replace matches in a byte +/// string. +/// +/// In general, users of this crate shouldn't need to implement this trait, +/// since implementations are already provided for `&[u8]` and +/// `FnMut(&Captures) -> Vec<u8>` (or any `FnMut(&Captures) -> T` +/// where `T: AsRef<[u8]>`), which covers most use cases. +pub trait Replacer { + /// Appends text to `dst` to replace the current match. + /// + /// The current match is represented by `caps`, which is guaranteed to + /// have a match at capture group `0`. + /// + /// For example, a no-op replacement would be + /// `dst.extend(&caps[0])`. + fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>); + + /// Return a fixed unchanging replacement byte string. + /// + /// When doing replacements, if access to `Captures` is not needed (e.g., + /// the replacement byte string does not need `$` expansion), then it can + /// be beneficial to avoid finding sub-captures. + /// + /// In general, this is called once for every call to `replacen`. + fn no_expansion<'r>(&'r mut self) -> Option<Cow<'r, [u8]>> { + None + } + + /// Return a `Replacer` that borrows and wraps this `Replacer`. + /// + /// This is useful when you want to take a generic `Replacer` (which might + /// not be cloneable) and use it without consuming it, so it can be used + /// more than once. + /// + /// # Example + /// + /// ``` + /// use regex::bytes::{Regex, Replacer}; + /// + /// fn replace_all_twice<R: Replacer>( + /// re: Regex, + /// src: &[u8], + /// mut rep: R, + /// ) -> Vec<u8> { + /// let dst = re.replace_all(src, rep.by_ref()); + /// let dst = re.replace_all(&dst, rep.by_ref()); + /// dst.into_owned() + /// } + /// ``` + fn by_ref<'r>(&'r mut self) -> ReplacerRef<'r, Self> { + ReplacerRef(self) + } +} + +/// By-reference adaptor for a `Replacer` +/// +/// Returned by [`Replacer::by_ref`](trait.Replacer.html#method.by_ref). +#[derive(Debug)] +pub struct ReplacerRef<'a, R: ?Sized + 'a>(&'a mut R); + +impl<'a, R: Replacer + ?Sized + 'a> Replacer for ReplacerRef<'a, R> { + fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) { + self.0.replace_append(caps, dst) + } + fn no_expansion<'r>(&'r mut self) -> Option<Cow<'r, [u8]>> { + self.0.no_expansion() + } +} + +impl<'a> Replacer for &'a [u8] { + fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) { + caps.expand(*self, dst); + } + + fn no_expansion(&mut self) -> Option<Cow<[u8]>> { + match find_byte(b'$', *self) { + Some(_) => None, + None => Some(Cow::Borrowed(*self)), + } + } +} + +impl<F, T> Replacer for F +where + F: FnMut(&Captures) -> T, + T: AsRef<[u8]>, +{ + fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) { + dst.extend_from_slice((*self)(caps).as_ref()); + } +} + +/// `NoExpand` indicates literal byte string replacement. +/// +/// It can be used with `replace` and `replace_all` to do a literal byte string +/// replacement without expanding `$name` to their corresponding capture +/// groups. This can be both convenient (to avoid escaping `$`, for example) +/// and performant (since capture groups don't need to be found). +/// +/// `'t` is the lifetime of the literal text. +pub struct NoExpand<'t>(pub &'t [u8]); + +impl<'t> Replacer for NoExpand<'t> { + fn replace_append(&mut self, _: &Captures, dst: &mut Vec<u8>) { + dst.extend_from_slice(self.0); + } + + fn no_expansion(&mut self) -> Option<Cow<[u8]>> { + Some(Cow::Borrowed(self.0)) + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/re_set.rs b/third_party/cargo/vendor/regex-1.3.3/src/re_set.rs new file mode 100644 index 0000000..fc2b61a --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/re_set.rs @@ -0,0 +1,452 @@ +macro_rules! define_set { + ($name:ident, $builder_mod:ident, $text_ty:ty, $as_bytes:expr, + $(#[$doc_regexset_example:meta])* ) => { + pub mod $name { + use std::fmt; + use std::iter; + use std::slice; + use std::vec; + + use error::Error; + use exec::Exec; + use re_builder::$builder_mod::RegexSetBuilder; + use re_trait::RegularExpression; + +/// Match multiple (possibly overlapping) regular expressions in a single scan. +/// +/// A regex set corresponds to the union of two or more regular expressions. +/// That is, a regex set will match text where at least one of its +/// constituent regular expressions matches. A regex set as its formulated here +/// provides a touch more power: it will also report *which* regular +/// expressions in the set match. Indeed, this is the key difference between +/// regex sets and a single `Regex` with many alternates, since only one +/// alternate can match at a time. +/// +/// For example, consider regular expressions to match email addresses and +/// domains: `[a-z]+@[a-z]+\.(com|org|net)` and `[a-z]+\.(com|org|net)`. If a +/// regex set is constructed from those regexes, then searching the text +/// `foo@example.com` will report both regexes as matching. Of course, one +/// could accomplish this by compiling each regex on its own and doing two +/// searches over the text. The key advantage of using a regex set is that it +/// will report the matching regexes using a *single pass through the text*. +/// If one has hundreds or thousands of regexes to match repeatedly (like a URL +/// router for a complex web application or a user agent matcher), then a regex +/// set can realize huge performance gains. +/// +/// # Example +/// +/// This shows how the above two regexes (for matching email addresses and +/// domains) might work: +/// +$(#[$doc_regexset_example])* +/// +/// Note that it would be possible to adapt the above example to using `Regex` +/// with an expression like: +/// +/// ```ignore +/// (?P<email>[a-z]+@(?P<email_domain>[a-z]+[.](com|org|net)))|(?P<domain>[a-z]+[.](com|org|net)) +/// ``` +/// +/// After a match, one could then inspect the capture groups to figure out +/// which alternates matched. The problem is that it is hard to make this +/// approach scale when there are many regexes since the overlap between each +/// alternate isn't always obvious to reason about. +/// +/// # Limitations +/// +/// Regex sets are limited to answering the following two questions: +/// +/// 1. Does any regex in the set match? +/// 2. If so, which regexes in the set match? +/// +/// As with the main `Regex` type, it is cheaper to ask (1) instead of (2) +/// since the matching engines can stop after the first match is found. +/// +/// Other features like finding the location of successive matches or their +/// sub-captures aren't supported. If you need this functionality, the +/// recommended approach is to compile each regex in the set independently and +/// selectively match them based on which regexes in the set matched. +/// +/// # Performance +/// +/// A `RegexSet` has the same performance characteristics as `Regex`. Namely, +/// search takes `O(mn)` time, where `m` is proportional to the size of the +/// regex set and `n` is proportional to the length of the search text. +#[derive(Clone)] +pub struct RegexSet(Exec); + +impl RegexSet { + /// Create a new regex set with the given regular expressions. + /// + /// This takes an iterator of `S`, where `S` is something that can produce + /// a `&str`. If any of the strings in the iterator are not valid regular + /// expressions, then an error is returned. + /// + /// # Example + /// + /// Create a new regex set from an iterator of strings: + /// + /// ```rust + /// # use regex::RegexSet; + /// let set = RegexSet::new(&[r"\w+", r"\d+"]).unwrap(); + /// assert!(set.is_match("foo")); + /// ``` + pub fn new<I, S>(exprs: I) -> Result<RegexSet, Error> + where S: AsRef<str>, I: IntoIterator<Item=S> { + RegexSetBuilder::new(exprs).build() + } + + /// Returns true if and only if one of the regexes in this set matches + /// the text given. + /// + /// This method should be preferred if you only need to test whether any + /// of the regexes in the set should match, but don't care about *which* + /// regexes matched. This is because the underlying matching engine will + /// quit immediately after seeing the first match instead of continuing to + /// find all matches. + /// + /// Note that as with searches using `Regex`, the expression is unanchored + /// by default. That is, if the regex does not start with `^` or `\A`, or + /// end with `$` or `\z`, then it is permitted to match anywhere in the + /// text. + /// + /// # Example + /// + /// Tests whether a set matches some text: + /// + /// ```rust + /// # use regex::RegexSet; + /// let set = RegexSet::new(&[r"\w+", r"\d+"]).unwrap(); + /// assert!(set.is_match("foo")); + /// assert!(!set.is_match("☃")); + /// ``` + pub fn is_match(&self, text: $text_ty) -> bool { + self.is_match_at(text, 0) + } + + /// Returns the same as is_match, but starts the search at the given + /// offset. + /// + /// The significance of the starting point is that it takes the surrounding + /// context into consideration. For example, the `\A` anchor can only + /// match when `start == 0`. + #[doc(hidden)] + pub fn is_match_at(&self, text: $text_ty, start: usize) -> bool { + self.0.searcher().is_match_at($as_bytes(text), start) + } + + /// Returns the set of regular expressions that match in the given text. + /// + /// The set returned contains the index of each regular expression that + /// matches in the given text. The index is in correspondence with the + /// order of regular expressions given to `RegexSet`'s constructor. + /// + /// The set can also be used to iterate over the matched indices. + /// + /// Note that as with searches using `Regex`, the expression is unanchored + /// by default. That is, if the regex does not start with `^` or `\A`, or + /// end with `$` or `\z`, then it is permitted to match anywhere in the + /// text. + /// + /// # Example + /// + /// Tests which regular expressions match the given text: + /// + /// ```rust + /// # use regex::RegexSet; + /// let set = RegexSet::new(&[ + /// r"\w+", + /// r"\d+", + /// r"\pL+", + /// r"foo", + /// r"bar", + /// r"barfoo", + /// r"foobar", + /// ]).unwrap(); + /// let matches: Vec<_> = set.matches("foobar").into_iter().collect(); + /// assert_eq!(matches, vec![0, 2, 3, 4, 6]); + /// + /// // You can also test whether a particular regex matched: + /// let matches = set.matches("foobar"); + /// assert!(!matches.matched(5)); + /// assert!(matches.matched(6)); + /// ``` + pub fn matches(&self, text: $text_ty) -> SetMatches { + let mut matches = vec![false; self.0.regex_strings().len()]; + let any = self.read_matches_at(&mut matches, text, 0); + SetMatches { + matched_any: any, + matches: matches, + } + } + + /// Returns the same as matches, but starts the search at the given + /// offset and stores the matches into the slice given. + /// + /// The significance of the starting point is that it takes the surrounding + /// context into consideration. For example, the `\A` anchor can only + /// match when `start == 0`. + /// + /// `matches` must have a length that is at least the number of regexes + /// in this set. + /// + /// This method returns true if and only if at least one member of + /// `matches` is true after executing the set against `text`. + #[doc(hidden)] + pub fn read_matches_at( + &self, + matches: &mut [bool], + text: $text_ty, + start: usize, + ) -> bool { + self.0.searcher().many_matches_at(matches, $as_bytes(text), start) + } + + /// Returns the total number of regular expressions in this set. + pub fn len(&self) -> usize { + self.0.regex_strings().len() + } + + /// Returns the patterns that this set will match on. + /// + /// This function can be used to determine the pattern for a match. The + /// slice returned has exactly as many patterns givens to this regex set, + /// and the order of the slice is the same as the order of the patterns + /// provided to the set. + /// + /// # Example + /// + /// ```rust + /// # use regex::RegexSet; + /// let set = RegexSet::new(&[ + /// r"\w+", + /// r"\d+", + /// r"\pL+", + /// r"foo", + /// r"bar", + /// r"barfoo", + /// r"foobar", + /// ]).unwrap(); + /// let matches: Vec<_> = set + /// .matches("foobar") + /// .into_iter() + /// .map(|match_idx| &set.patterns()[match_idx]) + /// .collect(); + /// assert_eq!(matches, vec![r"\w+", r"\pL+", r"foo", r"bar", r"foobar"]); + /// ``` + pub fn patterns(&self) -> &[String] { + self.0.regex_strings() + } +} + +/// A set of matches returned by a regex set. +#[derive(Clone, Debug)] +pub struct SetMatches { + matched_any: bool, + matches: Vec<bool>, +} + +impl SetMatches { + /// Whether this set contains any matches. + pub fn matched_any(&self) -> bool { + self.matched_any + } + + /// Whether the regex at the given index matched. + /// + /// The index for a regex is determined by its insertion order upon the + /// initial construction of a `RegexSet`, starting at `0`. + /// + /// # Panics + /// + /// If `regex_index` is greater than or equal to `self.len()`. + pub fn matched(&self, regex_index: usize) -> bool { + self.matches[regex_index] + } + + /// The total number of regexes in the set that created these matches. + pub fn len(&self) -> usize { + self.matches.len() + } + + /// Returns an iterator over indexes in the regex that matched. + /// + /// This will always produces matches in ascending order of index, where + /// the index corresponds to the index of the regex that matched with + /// respect to its position when initially building the set. + pub fn iter(&self) -> SetMatchesIter { + SetMatchesIter((&*self.matches).into_iter().enumerate()) + } +} + +impl IntoIterator for SetMatches { + type IntoIter = SetMatchesIntoIter; + type Item = usize; + + fn into_iter(self) -> Self::IntoIter { + SetMatchesIntoIter(self.matches.into_iter().enumerate()) + } +} + +impl<'a> IntoIterator for &'a SetMatches { + type IntoIter = SetMatchesIter<'a>; + type Item = usize; + + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + +/// An owned iterator over the set of matches from a regex set. +/// +/// This will always produces matches in ascending order of index, where the +/// index corresponds to the index of the regex that matched with respect to +/// its position when initially building the set. +pub struct SetMatchesIntoIter(iter::Enumerate<vec::IntoIter<bool>>); + +impl Iterator for SetMatchesIntoIter { + type Item = usize; + + fn next(&mut self) -> Option<usize> { + loop { + match self.0.next() { + None => return None, + Some((_, false)) => {} + Some((i, true)) => return Some(i), + } + } + } + + fn size_hint(&self) -> (usize, Option<usize>) { + self.0.size_hint() + } +} + +impl DoubleEndedIterator for SetMatchesIntoIter { + fn next_back(&mut self) -> Option<usize> { + loop { + match self.0.next_back() { + None => return None, + Some((_, false)) => {} + Some((i, true)) => return Some(i), + } + } + } +} + +/// A borrowed iterator over the set of matches from a regex set. +/// +/// The lifetime `'a` refers to the lifetime of a `SetMatches` value. +/// +/// This will always produces matches in ascending order of index, where the +/// index corresponds to the index of the regex that matched with respect to +/// its position when initially building the set. +#[derive(Clone)] +pub struct SetMatchesIter<'a>(iter::Enumerate<slice::Iter<'a, bool>>); + +impl<'a> Iterator for SetMatchesIter<'a> { + type Item = usize; + + fn next(&mut self) -> Option<usize> { + loop { + match self.0.next() { + None => return None, + Some((_, &false)) => {} + Some((i, &true)) => return Some(i), + } + } + } + + fn size_hint(&self) -> (usize, Option<usize>) { + self.0.size_hint() + } +} + +impl<'a> DoubleEndedIterator for SetMatchesIter<'a> { + fn next_back(&mut self) -> Option<usize> { + loop { + match self.0.next_back() { + None => return None, + Some((_, &false)) => {} + Some((i, &true)) => return Some(i), + } + } + } +} + +#[doc(hidden)] +impl From<Exec> for RegexSet { + fn from(exec: Exec) -> Self { + RegexSet(exec) + } +} + +impl fmt::Debug for RegexSet { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "RegexSet({:?})", self.0.regex_strings()) + } +} + +#[allow(dead_code)] fn as_bytes_str(text: &str) -> &[u8] { text.as_bytes() } +#[allow(dead_code)] fn as_bytes_bytes(text: &[u8]) -> &[u8] { text } + } + } +} + +define_set! { + unicode, + set_unicode, + &str, + as_bytes_str, +/// ```rust +/// # use regex::RegexSet; +/// let set = RegexSet::new(&[ +/// r"[a-z]+@[a-z]+\.(com|org|net)", +/// r"[a-z]+\.(com|org|net)", +/// ]).unwrap(); +/// +/// // Ask whether any regexes in the set match. +/// assert!(set.is_match("foo@example.com")); +/// +/// // Identify which regexes in the set match. +/// let matches: Vec<_> = set.matches("foo@example.com").into_iter().collect(); +/// assert_eq!(vec![0, 1], matches); +/// +/// // Try again, but with text that only matches one of the regexes. +/// let matches: Vec<_> = set.matches("example.com").into_iter().collect(); +/// assert_eq!(vec![1], matches); +/// +/// // Try again, but with text that doesn't match any regex in the set. +/// let matches: Vec<_> = set.matches("example").into_iter().collect(); +/// assert!(matches.is_empty()); +/// ``` +} + +define_set! { + bytes, + set_bytes, + &[u8], + as_bytes_bytes, +/// ```rust +/// # use regex::bytes::RegexSet; +/// let set = RegexSet::new(&[ +/// r"[a-z]+@[a-z]+\.(com|org|net)", +/// r"[a-z]+\.(com|org|net)", +/// ]).unwrap(); +/// +/// // Ask whether any regexes in the set match. +/// assert!(set.is_match(b"foo@example.com")); +/// +/// // Identify which regexes in the set match. +/// let matches: Vec<_> = set.matches(b"foo@example.com").into_iter().collect(); +/// assert_eq!(vec![0, 1], matches); +/// +/// // Try again, but with text that only matches one of the regexes. +/// let matches: Vec<_> = set.matches(b"example.com").into_iter().collect(); +/// assert_eq!(vec![1], matches); +/// +/// // Try again, but with text that doesn't match any regex in the set. +/// let matches: Vec<_> = set.matches(b"example").into_iter().collect(); +/// assert!(matches.is_empty()); +/// ``` +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/re_trait.rs b/third_party/cargo/vendor/regex-1.3.3/src/re_trait.rs new file mode 100644 index 0000000..b56804e --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/re_trait.rs @@ -0,0 +1,261 @@ +/// Slot is a single saved capture location. Note that there are two slots for +/// every capture in a regular expression (one slot each for the start and end +/// of the capture). +pub type Slot = Option<usize>; + +/// Locations represents the offsets of each capturing group in a regex for +/// a single match. +/// +/// Unlike `Captures`, a `Locations` value only stores offsets. +#[doc(hidden)] +#[derive(Clone, Debug)] +pub struct Locations(Vec<Slot>); + +impl Locations { + /// Returns the start and end positions of the Nth capture group. Returns + /// `None` if `i` is not a valid capture group or if the capture group did + /// not match anything. The positions returned are *always* byte indices + /// with respect to the original string matched. + pub fn pos(&self, i: usize) -> Option<(usize, usize)> { + let (s, e) = (i * 2, i * 2 + 1); + match (self.0.get(s), self.0.get(e)) { + (Some(&Some(s)), Some(&Some(e))) => Some((s, e)), + _ => None, + } + } + + /// Creates an iterator of all the capture group positions in order of + /// appearance in the regular expression. Positions are byte indices + /// in terms of the original string matched. + pub fn iter(&self) -> SubCapturesPosIter { + SubCapturesPosIter { idx: 0, locs: self } + } + + /// Returns the total number of capturing groups. + /// + /// This is always at least `1` since every regex has at least `1` + /// capturing group that corresponds to the entire match. + pub fn len(&self) -> usize { + self.0.len() / 2 + } + + /// Return the individual slots as a slice. + pub(crate) fn as_slots(&mut self) -> &mut [Slot] { + &mut self.0 + } +} + +/// An iterator over capture group positions for a particular match of a +/// regular expression. +/// +/// Positions are byte indices in terms of the original string matched. +/// +/// `'c` is the lifetime of the captures. +pub struct SubCapturesPosIter<'c> { + idx: usize, + locs: &'c Locations, +} + +impl<'c> Iterator for SubCapturesPosIter<'c> { + type Item = Option<(usize, usize)>; + + fn next(&mut self) -> Option<Option<(usize, usize)>> { + if self.idx >= self.locs.len() { + return None; + } + let x = match self.locs.pos(self.idx) { + None => Some(None), + Some((s, e)) => Some(Some((s, e))), + }; + self.idx += 1; + x + } +} + +/// `RegularExpression` describes types that can implement regex searching. +/// +/// This trait is my attempt at reducing code duplication and to standardize +/// the internal API. Specific duplication that is avoided are the `find` +/// and `capture` iterators, which are slightly tricky. +/// +/// It's not clear whether this trait is worth it, and it also isn't +/// clear whether it's useful as a public trait or not. Methods like +/// `next_after_empty` reak of bad design, but the rest of the methods seem +/// somewhat reasonable. One particular thing this trait would expose would be +/// the ability to start the search of a regex anywhere in a haystack, which +/// isn't possible in the current public API. +pub trait RegularExpression: Sized { + /// The type of the haystack. + type Text: ?Sized; + + /// The number of capture slots in the compiled regular expression. This is + /// always two times the number of capture groups (two slots per group). + fn slots_len(&self) -> usize; + + /// Allocates fresh space for all capturing groups in this regex. + fn locations(&self) -> Locations { + Locations(vec![None; self.slots_len()]) + } + + /// Returns the position of the next character after `i`. + /// + /// For example, a haystack with type `&[u8]` probably returns `i+1`, + /// whereas a haystack with type `&str` probably returns `i` plus the + /// length of the next UTF-8 sequence. + fn next_after_empty(&self, text: &Self::Text, i: usize) -> usize; + + /// Returns the location of the shortest match. + fn shortest_match_at( + &self, + text: &Self::Text, + start: usize, + ) -> Option<usize>; + + /// Returns whether the regex matches the text given. + fn is_match_at(&self, text: &Self::Text, start: usize) -> bool; + + /// Returns the leftmost-first match location if one exists. + fn find_at( + &self, + text: &Self::Text, + start: usize, + ) -> Option<(usize, usize)>; + + /// Returns the leftmost-first match location if one exists, and also + /// fills in any matching capture slot locations. + fn captures_read_at( + &self, + locs: &mut Locations, + text: &Self::Text, + start: usize, + ) -> Option<(usize, usize)>; + + /// Returns an iterator over all non-overlapping successive leftmost-first + /// matches. + fn find_iter(self, text: &Self::Text) -> Matches<Self> { + Matches { re: self, text: text, last_end: 0, last_match: None } + } + + /// Returns an iterator over all non-overlapping successive leftmost-first + /// matches with captures. + fn captures_iter(self, text: &Self::Text) -> CaptureMatches<Self> { + CaptureMatches(self.find_iter(text)) + } +} + +/// An iterator over all non-overlapping successive leftmost-first matches. +pub struct Matches<'t, R> +where + R: RegularExpression, + R::Text: 't, +{ + re: R, + text: &'t R::Text, + last_end: usize, + last_match: Option<usize>, +} + +impl<'t, R> Matches<'t, R> +where + R: RegularExpression, + R::Text: 't, +{ + /// Return the text being searched. + pub fn text(&self) -> &'t R::Text { + self.text + } + + /// Return the underlying regex. + pub fn regex(&self) -> &R { + &self.re + } +} + +impl<'t, R> Iterator for Matches<'t, R> +where + R: RegularExpression, + R::Text: 't + AsRef<[u8]>, +{ + type Item = (usize, usize); + + fn next(&mut self) -> Option<(usize, usize)> { + if self.last_end > self.text.as_ref().len() { + return None; + } + let (s, e) = match self.re.find_at(self.text, self.last_end) { + None => return None, + Some((s, e)) => (s, e), + }; + if s == e { + // This is an empty match. To ensure we make progress, start + // the next search at the smallest possible starting position + // of the next match following this one. + self.last_end = self.re.next_after_empty(self.text, e); + // Don't accept empty matches immediately following a match. + // Just move on to the next match. + if Some(e) == self.last_match { + return self.next(); + } + } else { + self.last_end = e; + } + self.last_match = Some(e); + Some((s, e)) + } +} + +/// An iterator over all non-overlapping successive leftmost-first matches with +/// captures. +pub struct CaptureMatches<'t, R>(Matches<'t, R>) +where + R: RegularExpression, + R::Text: 't; + +impl<'t, R> CaptureMatches<'t, R> +where + R: RegularExpression, + R::Text: 't, +{ + /// Return the text being searched. + pub fn text(&self) -> &'t R::Text { + self.0.text() + } + + /// Return the underlying regex. + pub fn regex(&self) -> &R { + self.0.regex() + } +} + +impl<'t, R> Iterator for CaptureMatches<'t, R> +where + R: RegularExpression, + R::Text: 't + AsRef<[u8]>, +{ + type Item = Locations; + + fn next(&mut self) -> Option<Locations> { + if self.0.last_end > self.0.text.as_ref().len() { + return None; + } + let mut locs = self.0.re.locations(); + let (s, e) = match self.0.re.captures_read_at( + &mut locs, + self.0.text, + self.0.last_end, + ) { + None => return None, + Some((s, e)) => (s, e), + }; + if s == e { + self.0.last_end = self.0.re.next_after_empty(self.0.text, e); + if Some(e) == self.0.last_match { + return self.next(); + } + } else { + self.0.last_end = e; + } + self.0.last_match = Some(e); + Some(locs) + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/re_unicode.rs b/third_party/cargo/vendor/regex-1.3.3/src/re_unicode.rs new file mode 100644 index 0000000..b746599 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/re_unicode.rs @@ -0,0 +1,1221 @@ +use std::borrow::Cow; +use std::collections::HashMap; +use std::fmt; +use std::ops::{Index, Range}; +use std::str::FromStr; +use std::sync::Arc; + +use find_byte::find_byte; +use syntax; + +use error::Error; +use exec::{Exec, ExecNoSyncStr}; +use expand::expand_str; +use re_builder::unicode::RegexBuilder; +use re_trait::{self, RegularExpression, SubCapturesPosIter}; + +/// Escapes all regular expression meta characters in `text`. +/// +/// The string returned may be safely used as a literal in a regular +/// expression. +pub fn escape(text: &str) -> String { + syntax::escape(text) +} + +/// Match represents a single match of a regex in a haystack. +/// +/// The lifetime parameter `'t` refers to the lifetime of the matched text. +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub struct Match<'t> { + text: &'t str, + start: usize, + end: usize, +} + +impl<'t> Match<'t> { + /// Returns the starting byte offset of the match in the haystack. + #[inline] + pub fn start(&self) -> usize { + self.start + } + + /// Returns the ending byte offset of the match in the haystack. + #[inline] + pub fn end(&self) -> usize { + self.end + } + + /// Returns the range over the starting and ending byte offsets of the + /// match in the haystack. + #[inline] + pub fn range(&self) -> Range<usize> { + self.start..self.end + } + + /// Returns the matched text. + #[inline] + pub fn as_str(&self) -> &'t str { + &self.text[self.range()] + } + + /// Creates a new match from the given haystack and byte offsets. + #[inline] + fn new(haystack: &'t str, start: usize, end: usize) -> Match<'t> { + Match { text: haystack, start: start, end: end } + } +} + +impl<'t> From<Match<'t>> for &'t str { + fn from(m: Match<'t>) -> &'t str { + m.as_str() + } +} + +impl<'t> From<Match<'t>> for Range<usize> { + fn from(m: Match<'t>) -> Range<usize> { + m.range() + } +} + +/// A compiled regular expression for matching Unicode strings. +/// +/// It is represented as either a sequence of bytecode instructions (dynamic) +/// or as a specialized Rust function (native). It can be used to search, split +/// or replace text. All searching is done with an implicit `.*?` at the +/// beginning and end of an expression. To force an expression to match the +/// whole string (or a prefix or a suffix), you must use an anchor like `^` or +/// `$` (or `\A` and `\z`). +/// +/// While this crate will handle Unicode strings (whether in the regular +/// expression or in the search text), all positions returned are **byte +/// indices**. Every byte index is guaranteed to be at a Unicode code point +/// boundary. +/// +/// The lifetimes `'r` and `'t` in this crate correspond to the lifetime of a +/// compiled regular expression and text to search, respectively. +/// +/// The only methods that allocate new strings are the string replacement +/// methods. All other methods (searching and splitting) return borrowed +/// pointers into the string given. +/// +/// # Examples +/// +/// Find the location of a US phone number: +/// +/// ```rust +/// # use regex::Regex; +/// let re = Regex::new("[0-9]{3}-[0-9]{3}-[0-9]{4}").unwrap(); +/// let mat = re.find("phone: 111-222-3333").unwrap(); +/// assert_eq!((mat.start(), mat.end()), (7, 19)); +/// ``` +/// +/// # Using the `std::str::pattern` methods with `Regex` +/// +/// > **Note**: This section requires that this crate is compiled with the +/// > `pattern` Cargo feature enabled, which **requires nightly Rust**. +/// +/// Since `Regex` implements `Pattern`, you can use regexes with methods +/// defined on `&str`. For example, `is_match`, `find`, `find_iter` +/// and `split` can be replaced with `str::contains`, `str::find`, +/// `str::match_indices` and `str::split`. +/// +/// Here are some examples: +/// +/// ```rust,ignore +/// # use regex::Regex; +/// let re = Regex::new(r"\d+").unwrap(); +/// let haystack = "a111b222c"; +/// +/// assert!(haystack.contains(&re)); +/// assert_eq!(haystack.find(&re), Some(1)); +/// assert_eq!(haystack.match_indices(&re).collect::<Vec<_>>(), +/// vec![(1, 4), (5, 8)]); +/// assert_eq!(haystack.split(&re).collect::<Vec<_>>(), vec!["a", "b", "c"]); +/// ``` +#[derive(Clone)] +pub struct Regex(Exec); + +impl fmt::Display for Regex { + /// Shows the original regular expression. + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.as_str()) + } +} + +impl fmt::Debug for Regex { + /// Shows the original regular expression. + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +#[doc(hidden)] +impl From<Exec> for Regex { + fn from(exec: Exec) -> Regex { + Regex(exec) + } +} + +impl FromStr for Regex { + type Err = Error; + + /// Attempts to parse a string into a regular expression + fn from_str(s: &str) -> Result<Regex, Error> { + Regex::new(s) + } +} + +/// Core regular expression methods. +impl Regex { + /// Compiles a regular expression. Once compiled, it can be used repeatedly + /// to search, split or replace text in a string. + /// + /// If an invalid expression is given, then an error is returned. + pub fn new(re: &str) -> Result<Regex, Error> { + RegexBuilder::new(re).build() + } + + /// Returns true if and only if the regex matches the string given. + /// + /// It is recommended to use this method if all you need to do is test + /// a match, since the underlying matching engine may be able to do less + /// work. + /// + /// # Example + /// + /// Test if some text contains at least one word with exactly 13 + /// Unicode word characters: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let text = "I categorically deny having triskaidekaphobia."; + /// assert!(Regex::new(r"\b\w{13}\b").unwrap().is_match(text)); + /// # } + /// ``` + pub fn is_match(&self, text: &str) -> bool { + self.is_match_at(text, 0) + } + + /// Returns the start and end byte range of the leftmost-first match in + /// `text`. If no match exists, then `None` is returned. + /// + /// Note that this should only be used if you want to discover the position + /// of the match. Testing the existence of a match is faster if you use + /// `is_match`. + /// + /// # Example + /// + /// Find the start and end location of the first word with exactly 13 + /// Unicode word characters: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let text = "I categorically deny having triskaidekaphobia."; + /// let mat = Regex::new(r"\b\w{13}\b").unwrap().find(text).unwrap(); + /// assert_eq!(mat.start(), 2); + /// assert_eq!(mat.end(), 15); + /// # } + /// ``` + pub fn find<'t>(&self, text: &'t str) -> Option<Match<'t>> { + self.find_at(text, 0) + } + + /// Returns an iterator for each successive non-overlapping match in + /// `text`, returning the start and end byte indices with respect to + /// `text`. + /// + /// # Example + /// + /// Find the start and end location of every word with exactly 13 Unicode + /// word characters: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let text = "Retroactively relinquishing remunerations is reprehensible."; + /// for mat in Regex::new(r"\b\w{13}\b").unwrap().find_iter(text) { + /// println!("{:?}", mat); + /// } + /// # } + /// ``` + pub fn find_iter<'r, 't>(&'r self, text: &'t str) -> Matches<'r, 't> { + Matches(self.0.searcher_str().find_iter(text)) + } + + /// Returns the capture groups corresponding to the leftmost-first + /// match in `text`. Capture group `0` always corresponds to the entire + /// match. If no match is found, then `None` is returned. + /// + /// You should only use `captures` if you need access to the location of + /// capturing group matches. Otherwise, `find` is faster for discovering + /// the location of the overall match. + /// + /// # Examples + /// + /// Say you have some text with movie names and their release years, + /// like "'Citizen Kane' (1941)". It'd be nice if we could search for text + /// looking like that, while also extracting the movie name and its release + /// year separately. + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap(); + /// let text = "Not my favorite movie: 'Citizen Kane' (1941)."; + /// let caps = re.captures(text).unwrap(); + /// assert_eq!(caps.get(1).unwrap().as_str(), "Citizen Kane"); + /// assert_eq!(caps.get(2).unwrap().as_str(), "1941"); + /// assert_eq!(caps.get(0).unwrap().as_str(), "'Citizen Kane' (1941)"); + /// // You can also access the groups by index using the Index notation. + /// // Note that this will panic on an invalid index. + /// assert_eq!(&caps[1], "Citizen Kane"); + /// assert_eq!(&caps[2], "1941"); + /// assert_eq!(&caps[0], "'Citizen Kane' (1941)"); + /// # } + /// ``` + /// + /// Note that the full match is at capture group `0`. Each subsequent + /// capture group is indexed by the order of its opening `(`. + /// + /// We can make this example a bit clearer by using *named* capture groups: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)") + /// .unwrap(); + /// let text = "Not my favorite movie: 'Citizen Kane' (1941)."; + /// let caps = re.captures(text).unwrap(); + /// assert_eq!(caps.name("title").unwrap().as_str(), "Citizen Kane"); + /// assert_eq!(caps.name("year").unwrap().as_str(), "1941"); + /// assert_eq!(caps.get(0).unwrap().as_str(), "'Citizen Kane' (1941)"); + /// // You can also access the groups by name using the Index notation. + /// // Note that this will panic on an invalid group name. + /// assert_eq!(&caps["title"], "Citizen Kane"); + /// assert_eq!(&caps["year"], "1941"); + /// assert_eq!(&caps[0], "'Citizen Kane' (1941)"); + /// + /// # } + /// ``` + /// + /// Here we name the capture groups, which we can access with the `name` + /// method or the `Index` notation with a `&str`. Note that the named + /// capture groups are still accessible with `get` or the `Index` notation + /// with a `usize`. + /// + /// The `0`th capture group is always unnamed, so it must always be + /// accessed with `get(0)` or `[0]`. + pub fn captures<'t>(&self, text: &'t str) -> Option<Captures<'t>> { + let mut locs = self.capture_locations(); + self.captures_read_at(&mut locs, text, 0).map(move |_| Captures { + text: text, + locs: locs.0, + named_groups: self.0.capture_name_idx().clone(), + }) + } + + /// Returns an iterator over all the non-overlapping capture groups matched + /// in `text`. This is operationally the same as `find_iter`, except it + /// yields information about capturing group matches. + /// + /// # Example + /// + /// We can use this to find all movie titles and their release years in + /// some text, where the movie is formatted like "'Title' (xxxx)": + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)") + /// .unwrap(); + /// let text = "'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931)."; + /// for caps in re.captures_iter(text) { + /// println!("Movie: {:?}, Released: {:?}", + /// &caps["title"], &caps["year"]); + /// } + /// // Output: + /// // Movie: Citizen Kane, Released: 1941 + /// // Movie: The Wizard of Oz, Released: 1939 + /// // Movie: M, Released: 1931 + /// # } + /// ``` + pub fn captures_iter<'r, 't>( + &'r self, + text: &'t str, + ) -> CaptureMatches<'r, 't> { + CaptureMatches(self.0.searcher_str().captures_iter(text)) + } + + /// Returns an iterator of substrings of `text` delimited by a match of the + /// regular expression. Namely, each element of the iterator corresponds to + /// text that *isn't* matched by the regular expression. + /// + /// This method will *not* copy the text given. + /// + /// # Example + /// + /// To split a string delimited by arbitrary amounts of spaces or tabs: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"[ \t]+").unwrap(); + /// let fields: Vec<&str> = re.split("a b \t c\td e").collect(); + /// assert_eq!(fields, vec!["a", "b", "c", "d", "e"]); + /// # } + /// ``` + pub fn split<'r, 't>(&'r self, text: &'t str) -> Split<'r, 't> { + Split { finder: self.find_iter(text), last: 0 } + } + + /// Returns an iterator of at most `limit` substrings of `text` delimited + /// by a match of the regular expression. (A `limit` of `0` will return no + /// substrings.) Namely, each element of the iterator corresponds to text + /// that *isn't* matched by the regular expression. The remainder of the + /// string that is not split will be the last element in the iterator. + /// + /// This method will *not* copy the text given. + /// + /// # Example + /// + /// Get the first two words in some text: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"\W+").unwrap(); + /// let fields: Vec<&str> = re.splitn("Hey! How are you?", 3).collect(); + /// assert_eq!(fields, vec!("Hey", "How", "are you?")); + /// # } + /// ``` + pub fn splitn<'r, 't>( + &'r self, + text: &'t str, + limit: usize, + ) -> SplitN<'r, 't> { + SplitN { splits: self.split(text), n: limit } + } + + /// Replaces the leftmost-first match with the replacement provided. + /// The replacement can be a regular string (where `$N` and `$name` are + /// expanded to match capture groups) or a function that takes the matches' + /// `Captures` and returns the replaced string. + /// + /// If no match is found, then a copy of the string is returned unchanged. + /// + /// # Replacement string syntax + /// + /// All instances of `$name` in the replacement text is replaced with the + /// corresponding capture group `name`. + /// + /// `name` may be an integer corresponding to the index of the + /// capture group (counted by order of opening parenthesis where `0` is the + /// entire match) or it can be a name (consisting of letters, digits or + /// underscores) corresponding to a named capture group. + /// + /// If `name` isn't a valid capture group (whether the name doesn't exist + /// or isn't a valid index), then it is replaced with the empty string. + /// + /// The longest possible name is used. e.g., `$1a` looks up the capture + /// group named `1a` and not the capture group at index `1`. To exert more + /// precise control over the name, use braces, e.g., `${1}a`. + /// + /// To write a literal `$` use `$$`. + /// + /// # Examples + /// + /// Note that this function is polymorphic with respect to the replacement. + /// In typical usage, this can just be a normal string: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new("[^01]+").unwrap(); + /// assert_eq!(re.replace("1078910", ""), "1010"); + /// # } + /// ``` + /// + /// But anything satisfying the `Replacer` trait will work. For example, + /// a closure of type `|&Captures| -> String` provides direct access to the + /// captures corresponding to a match. This allows one to access + /// capturing group matches easily: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # use regex::Captures; fn main() { + /// let re = Regex::new(r"([^,\s]+),\s+(\S+)").unwrap(); + /// let result = re.replace("Springsteen, Bruce", |caps: &Captures| { + /// format!("{} {}", &caps[2], &caps[1]) + /// }); + /// assert_eq!(result, "Bruce Springsteen"); + /// # } + /// ``` + /// + /// But this is a bit cumbersome to use all the time. Instead, a simple + /// syntax is supported that expands `$name` into the corresponding capture + /// group. Here's the last example, but using this expansion technique + /// with named capture groups: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(?P<first>\S+)").unwrap(); + /// let result = re.replace("Springsteen, Bruce", "$first $last"); + /// assert_eq!(result, "Bruce Springsteen"); + /// # } + /// ``` + /// + /// Note that using `$2` instead of `$first` or `$1` instead of `$last` + /// would produce the same result. To write a literal `$` use `$$`. + /// + /// Sometimes the replacement string requires use of curly braces to + /// delineate a capture group replacement and surrounding literal text. + /// For example, if we wanted to join two words together with an + /// underscore: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let re = Regex::new(r"(?P<first>\w+)\s+(?P<second>\w+)").unwrap(); + /// let result = re.replace("deep fried", "${first}_$second"); + /// assert_eq!(result, "deep_fried"); + /// # } + /// ``` + /// + /// Without the curly braces, the capture group name `first_` would be + /// used, and since it doesn't exist, it would be replaced with the empty + /// string. + /// + /// Finally, sometimes you just want to replace a literal string with no + /// regard for capturing group expansion. This can be done by wrapping a + /// byte string with `NoExpand`: + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// use regex::NoExpand; + /// + /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(\S+)").unwrap(); + /// let result = re.replace("Springsteen, Bruce", NoExpand("$2 $last")); + /// assert_eq!(result, "$2 $last"); + /// # } + /// ``` + pub fn replace<'t, R: Replacer>( + &self, + text: &'t str, + rep: R, + ) -> Cow<'t, str> { + self.replacen(text, 1, rep) + } + + /// Replaces all non-overlapping matches in `text` with the replacement + /// provided. This is the same as calling `replacen` with `limit` set to + /// `0`. + /// + /// See the documentation for `replace` for details on how to access + /// capturing group matches in the replacement string. + pub fn replace_all<'t, R: Replacer>( + &self, + text: &'t str, + rep: R, + ) -> Cow<'t, str> { + self.replacen(text, 0, rep) + } + + /// Replaces at most `limit` non-overlapping matches in `text` with the + /// replacement provided. If `limit` is 0, then all non-overlapping matches + /// are replaced. + /// + /// See the documentation for `replace` for details on how to access + /// capturing group matches in the replacement string. + pub fn replacen<'t, R: Replacer>( + &self, + text: &'t str, + limit: usize, + mut rep: R, + ) -> Cow<'t, str> { + // If we know that the replacement doesn't have any capture expansions, + // then we can fast path. The fast path can make a tremendous + // difference: + // + // 1) We use `find_iter` instead of `captures_iter`. Not asking for + // captures generally makes the regex engines faster. + // 2) We don't need to look up all of the capture groups and do + // replacements inside the replacement string. We just push it + // at each match and be done with it. + if let Some(rep) = rep.no_expansion() { + let mut it = self.find_iter(text).enumerate().peekable(); + if it.peek().is_none() { + return Cow::Borrowed(text); + } + let mut new = String::with_capacity(text.len()); + let mut last_match = 0; + for (i, m) in it { + if limit > 0 && i >= limit { + break; + } + new.push_str(&text[last_match..m.start()]); + new.push_str(&rep); + last_match = m.end(); + } + new.push_str(&text[last_match..]); + return Cow::Owned(new); + } + + // The slower path, which we use if the replacement needs access to + // capture groups. + let mut it = self.captures_iter(text).enumerate().peekable(); + if it.peek().is_none() { + return Cow::Borrowed(text); + } + let mut new = String::with_capacity(text.len()); + let mut last_match = 0; + for (i, cap) in it { + if limit > 0 && i >= limit { + break; + } + // unwrap on 0 is OK because captures only reports matches + let m = cap.get(0).unwrap(); + new.push_str(&text[last_match..m.start()]); + rep.replace_append(&cap, &mut new); + last_match = m.end(); + } + new.push_str(&text[last_match..]); + Cow::Owned(new) + } +} + +/// Advanced or "lower level" search methods. +impl Regex { + /// Returns the end location of a match in the text given. + /// + /// This method may have the same performance characteristics as + /// `is_match`, except it provides an end location for a match. In + /// particular, the location returned *may be shorter* than the proper end + /// of the leftmost-first match. + /// + /// # Example + /// + /// Typically, `a+` would match the entire first sequence of `a` in some + /// text, but `shortest_match` can give up as soon as it sees the first + /// `a`. + /// + /// ```rust + /// # extern crate regex; use regex::Regex; + /// # fn main() { + /// let text = "aaaaa"; + /// let pos = Regex::new(r"a+").unwrap().shortest_match(text); + /// assert_eq!(pos, Some(1)); + /// # } + /// ``` + pub fn shortest_match(&self, text: &str) -> Option<usize> { + self.shortest_match_at(text, 0) + } + + /// Returns the same as shortest_match, but starts the search at the given + /// offset. + /// + /// The significance of the starting point is that it takes the surrounding + /// context into consideration. For example, the `\A` anchor can only + /// match when `start == 0`. + pub fn shortest_match_at( + &self, + text: &str, + start: usize, + ) -> Option<usize> { + self.0.searcher_str().shortest_match_at(text, start) + } + + /// Returns the same as is_match, but starts the search at the given + /// offset. + /// + /// The significance of the starting point is that it takes the surrounding + /// context into consideration. For example, the `\A` anchor can only + /// match when `start == 0`. + pub fn is_match_at(&self, text: &str, start: usize) -> bool { + self.shortest_match_at(text, start).is_some() + } + + /// Returns the same as find, but starts the search at the given + /// offset. + /// + /// The significance of the starting point is that it takes the surrounding + /// context into consideration. For example, the `\A` anchor can only + /// match when `start == 0`. + pub fn find_at<'t>( + &self, + text: &'t str, + start: usize, + ) -> Option<Match<'t>> { + self.0 + .searcher_str() + .find_at(text, start) + .map(|(s, e)| Match::new(text, s, e)) + } + + /// This is like `captures`, but uses + /// [`CaptureLocations`](struct.CaptureLocations.html) + /// instead of + /// [`Captures`](struct.Captures.html) in order to amortize allocations. + /// + /// To create a `CaptureLocations` value, use the + /// `Regex::capture_locations` method. + /// + /// This returns the overall match if this was successful, which is always + /// equivalence to the `0`th capture group. + pub fn captures_read<'t>( + &self, + locs: &mut CaptureLocations, + text: &'t str, + ) -> Option<Match<'t>> { + self.captures_read_at(locs, text, 0) + } + + /// Returns the same as captures, but starts the search at the given + /// offset and populates the capture locations given. + /// + /// The significance of the starting point is that it takes the surrounding + /// context into consideration. For example, the `\A` anchor can only + /// match when `start == 0`. + pub fn captures_read_at<'t>( + &self, + locs: &mut CaptureLocations, + text: &'t str, + start: usize, + ) -> Option<Match<'t>> { + self.0 + .searcher_str() + .captures_read_at(&mut locs.0, text, start) + .map(|(s, e)| Match::new(text, s, e)) + } + + /// An undocumented alias for `captures_read_at`. + /// + /// The `regex-capi` crate previously used this routine, so to avoid + /// breaking that crate, we continue to provide the name as an undocumented + /// alias. + #[doc(hidden)] + pub fn read_captures_at<'t>( + &self, + locs: &mut CaptureLocations, + text: &'t str, + start: usize, + ) -> Option<Match<'t>> { + self.captures_read_at(locs, text, start) + } +} + +/// Auxiliary methods. +impl Regex { + /// Returns the original string of this regex. + pub fn as_str(&self) -> &str { + &self.0.regex_strings()[0] + } + + /// Returns an iterator over the capture names. + pub fn capture_names(&self) -> CaptureNames { + CaptureNames(self.0.capture_names().iter()) + } + + /// Returns the number of captures. + pub fn captures_len(&self) -> usize { + self.0.capture_names().len() + } + + /// Returns an empty set of capture locations that can be reused in + /// multiple calls to `captures_read` or `captures_read_at`. + pub fn capture_locations(&self) -> CaptureLocations { + CaptureLocations(self.0.searcher_str().locations()) + } + + /// An alias for `capture_locations` to preserve backward compatibility. + /// + /// The `regex-capi` crate uses this method, so to avoid breaking that + /// crate, we continue to export it as an undocumented API. + #[doc(hidden)] + pub fn locations(&self) -> CaptureLocations { + CaptureLocations(self.0.searcher_str().locations()) + } +} + +/// An iterator over the names of all possible captures. +/// +/// `None` indicates an unnamed capture; the first element (capture 0, the +/// whole matched region) is always unnamed. +/// +/// `'r` is the lifetime of the compiled regular expression. +pub struct CaptureNames<'r>(::std::slice::Iter<'r, Option<String>>); + +impl<'r> Iterator for CaptureNames<'r> { + type Item = Option<&'r str>; + + fn next(&mut self) -> Option<Option<&'r str>> { + self.0 + .next() + .as_ref() + .map(|slot| slot.as_ref().map(|name| name.as_ref())) + } + + fn size_hint(&self) -> (usize, Option<usize>) { + self.0.size_hint() + } +} + +/// Yields all substrings delimited by a regular expression match. +/// +/// `'r` is the lifetime of the compiled regular expression and `'t` is the +/// lifetime of the string being split. +pub struct Split<'r, 't> { + finder: Matches<'r, 't>, + last: usize, +} + +impl<'r, 't> Iterator for Split<'r, 't> { + type Item = &'t str; + + fn next(&mut self) -> Option<&'t str> { + let text = self.finder.0.text(); + match self.finder.next() { + None => { + if self.last > text.len() { + None + } else { + let s = &text[self.last..]; + self.last = text.len() + 1; // Next call will return None + Some(s) + } + } + Some(m) => { + let matched = &text[self.last..m.start()]; + self.last = m.end(); + Some(matched) + } + } + } +} + +/// Yields at most `N` substrings delimited by a regular expression match. +/// +/// The last substring will be whatever remains after splitting. +/// +/// `'r` is the lifetime of the compiled regular expression and `'t` is the +/// lifetime of the string being split. +pub struct SplitN<'r, 't> { + splits: Split<'r, 't>, + n: usize, +} + +impl<'r, 't> Iterator for SplitN<'r, 't> { + type Item = &'t str; + + fn next(&mut self) -> Option<&'t str> { + if self.n == 0 { + return None; + } + + self.n -= 1; + if self.n > 0 { + return self.splits.next(); + } + + let text = self.splits.finder.0.text(); + if self.splits.last > text.len() { + // We've already returned all substrings. + None + } else { + // self.n == 0, so future calls will return None immediately + Some(&text[self.splits.last..]) + } + } +} + +/// CaptureLocations is a low level representation of the raw offsets of each +/// submatch. +/// +/// You can think of this as a lower level +/// [`Captures`](struct.Captures.html), where this type does not support +/// named capturing groups directly and it does not borrow the text that these +/// offsets were matched on. +/// +/// Primarily, this type is useful when using the lower level `Regex` APIs +/// such as `read_captures`, which permits amortizing the allocation in which +/// capture match locations are stored. +/// +/// In order to build a value of this type, you'll need to call the +/// `capture_locations` method on the `Regex` being used to execute the search. +/// The value returned can then be reused in subsequent searches. +#[derive(Clone, Debug)] +pub struct CaptureLocations(re_trait::Locations); + +/// A type alias for `CaptureLocations` for backwards compatibility. +/// +/// Previously, we exported `CaptureLocations` as `Locations` in an +/// undocumented API. To prevent breaking that code (e.g., in `regex-capi`), +/// we continue re-exporting the same undocumented API. +#[doc(hidden)] +pub type Locations = CaptureLocations; + +impl CaptureLocations { + /// Returns the start and end positions of the Nth capture group. Returns + /// `None` if `i` is not a valid capture group or if the capture group did + /// not match anything. The positions returned are *always* byte indices + /// with respect to the original string matched. + #[inline] + pub fn get(&self, i: usize) -> Option<(usize, usize)> { + self.0.pos(i) + } + + /// Returns the total number of capturing groups. + /// + /// This is always at least `1` since every regex has at least `1` + /// capturing group that corresponds to the entire match. + #[inline] + pub fn len(&self) -> usize { + self.0.len() + } + + /// An alias for the `get` method for backwards compatibility. + /// + /// Previously, we exported `get` as `pos` in an undocumented API. To + /// prevent breaking that code (e.g., in `regex-capi`), we continue + /// re-exporting the same undocumented API. + #[doc(hidden)] + #[inline] + pub fn pos(&self, i: usize) -> Option<(usize, usize)> { + self.get(i) + } +} + +/// Captures represents a group of captured strings for a single match. +/// +/// The 0th capture always corresponds to the entire match. Each subsequent +/// index corresponds to the next capture group in the regex. If a capture +/// group is named, then the matched string is *also* available via the `name` +/// method. (Note that the 0th capture is always unnamed and so must be +/// accessed with the `get` method.) +/// +/// Positions returned from a capture group are always byte indices. +/// +/// `'t` is the lifetime of the matched text. +pub struct Captures<'t> { + text: &'t str, + locs: re_trait::Locations, + named_groups: Arc<HashMap<String, usize>>, +} + +impl<'t> Captures<'t> { + /// Returns the match associated with the capture group at index `i`. If + /// `i` does not correspond to a capture group, or if the capture group + /// did not participate in the match, then `None` is returned. + /// + /// # Examples + /// + /// Get the text of the match with a default of an empty string if this + /// group didn't participate in the match: + /// + /// ```rust + /// # use regex::Regex; + /// let re = Regex::new(r"[a-z]+(?:([0-9]+)|([A-Z]+))").unwrap(); + /// let caps = re.captures("abc123").unwrap(); + /// + /// let text1 = caps.get(1).map_or("", |m| m.as_str()); + /// let text2 = caps.get(2).map_or("", |m| m.as_str()); + /// assert_eq!(text1, "123"); + /// assert_eq!(text2, ""); + /// ``` + pub fn get(&self, i: usize) -> Option<Match<'t>> { + self.locs.pos(i).map(|(s, e)| Match::new(self.text, s, e)) + } + + /// Returns the match for the capture group named `name`. If `name` isn't a + /// valid capture group or didn't match anything, then `None` is returned. + pub fn name(&self, name: &str) -> Option<Match<'t>> { + self.named_groups.get(name).and_then(|&i| self.get(i)) + } + + /// An iterator that yields all capturing matches in the order in which + /// they appear in the regex. If a particular capture group didn't + /// participate in the match, then `None` is yielded for that capture. + /// + /// The first match always corresponds to the overall match of the regex. + pub fn iter<'c>(&'c self) -> SubCaptureMatches<'c, 't> { + SubCaptureMatches { caps: self, it: self.locs.iter() } + } + + /// Expands all instances of `$name` in `replacement` to the corresponding + /// capture group `name`, and writes them to the `dst` buffer given. + /// + /// `name` may be an integer corresponding to the index of the + /// capture group (counted by order of opening parenthesis where `0` is the + /// entire match) or it can be a name (consisting of letters, digits or + /// underscores) corresponding to a named capture group. + /// + /// If `name` isn't a valid capture group (whether the name doesn't exist + /// or isn't a valid index), then it is replaced with the empty string. + /// + /// The longest possible name is used. e.g., `$1a` looks up the capture + /// group named `1a` and not the capture group at index `1`. To exert more + /// precise control over the name, use braces, e.g., `${1}a`. + /// + /// To write a literal `$` use `$$`. + pub fn expand(&self, replacement: &str, dst: &mut String) { + expand_str(self, replacement, dst) + } + + /// Returns the number of captured groups. + /// + /// This is always at least `1`, since every regex has at least one capture + /// group that corresponds to the full match. + #[inline] + pub fn len(&self) -> usize { + self.locs.len() + } +} + +impl<'t> fmt::Debug for Captures<'t> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_tuple("Captures").field(&CapturesDebug(self)).finish() + } +} + +struct CapturesDebug<'c, 't: 'c>(&'c Captures<'t>); + +impl<'c, 't> fmt::Debug for CapturesDebug<'c, 't> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // We'd like to show something nice here, even if it means an + // allocation to build a reverse index. + let slot_to_name: HashMap<&usize, &String> = + self.0.named_groups.iter().map(|(a, b)| (b, a)).collect(); + let mut map = f.debug_map(); + for (slot, m) in self.0.locs.iter().enumerate() { + let m = m.map(|(s, e)| &self.0.text[s..e]); + if let Some(name) = slot_to_name.get(&slot) { + map.entry(&name, &m); + } else { + map.entry(&slot, &m); + } + } + map.finish() + } +} + +/// Get a group by index. +/// +/// `'t` is the lifetime of the matched text. +/// +/// The text can't outlive the `Captures` object if this method is +/// used, because of how `Index` is defined (normally `a[i]` is part +/// of `a` and can't outlive it); to do that, use `get()` instead. +/// +/// # Panics +/// +/// If there is no group at the given index. +impl<'t> Index<usize> for Captures<'t> { + type Output = str; + + fn index(&self, i: usize) -> &str { + self.get(i) + .map(|m| m.as_str()) + .unwrap_or_else(|| panic!("no group at index '{}'", i)) + } +} + +/// Get a group by name. +/// +/// `'t` is the lifetime of the matched text and `'i` is the lifetime +/// of the group name (the index). +/// +/// The text can't outlive the `Captures` object if this method is +/// used, because of how `Index` is defined (normally `a[i]` is part +/// of `a` and can't outlive it); to do that, use `name` instead. +/// +/// # Panics +/// +/// If there is no group named by the given value. +impl<'t, 'i> Index<&'i str> for Captures<'t> { + type Output = str; + + fn index<'a>(&'a self, name: &'i str) -> &'a str { + self.name(name) + .map(|m| m.as_str()) + .unwrap_or_else(|| panic!("no group named '{}'", name)) + } +} + +/// An iterator that yields all capturing matches in the order in which they +/// appear in the regex. +/// +/// If a particular capture group didn't participate in the match, then `None` +/// is yielded for that capture. The first match always corresponds to the +/// overall match of the regex. +/// +/// The lifetime `'c` corresponds to the lifetime of the `Captures` value, and +/// the lifetime `'t` corresponds to the originally matched text. +pub struct SubCaptureMatches<'c, 't: 'c> { + caps: &'c Captures<'t>, + it: SubCapturesPosIter<'c>, +} + +impl<'c, 't> Iterator for SubCaptureMatches<'c, 't> { + type Item = Option<Match<'t>>; + + fn next(&mut self) -> Option<Option<Match<'t>>> { + self.it + .next() + .map(|cap| cap.map(|(s, e)| Match::new(self.caps.text, s, e))) + } +} + +/// An iterator that yields all non-overlapping capture groups matching a +/// particular regular expression. +/// +/// The iterator stops when no more matches can be found. +/// +/// `'r` is the lifetime of the compiled regular expression and `'t` is the +/// lifetime of the matched string. +pub struct CaptureMatches<'r, 't>( + re_trait::CaptureMatches<'t, ExecNoSyncStr<'r>>, +); + +impl<'r, 't> Iterator for CaptureMatches<'r, 't> { + type Item = Captures<'t>; + + fn next(&mut self) -> Option<Captures<'t>> { + self.0.next().map(|locs| Captures { + text: self.0.text(), + locs: locs, + named_groups: self.0.regex().capture_name_idx().clone(), + }) + } +} + +/// An iterator over all non-overlapping matches for a particular string. +/// +/// The iterator yields a `Match` value. The iterator stops when no more +/// matches can be found. +/// +/// `'r` is the lifetime of the compiled regular expression and `'t` is the +/// lifetime of the matched string. +pub struct Matches<'r, 't>(re_trait::Matches<'t, ExecNoSyncStr<'r>>); + +impl<'r, 't> Iterator for Matches<'r, 't> { + type Item = Match<'t>; + + fn next(&mut self) -> Option<Match<'t>> { + let text = self.0.text(); + self.0.next().map(|(s, e)| Match::new(text, s, e)) + } +} + +/// Replacer describes types that can be used to replace matches in a string. +/// +/// In general, users of this crate shouldn't need to implement this trait, +/// since implementations are already provided for `&str` and +/// `FnMut(&Captures) -> String` (or any `FnMut(&Captures) -> T` +/// where `T: AsRef<str>`), which covers most use cases. +pub trait Replacer { + /// Appends text to `dst` to replace the current match. + /// + /// The current match is represented by `caps`, which is guaranteed to + /// have a match at capture group `0`. + /// + /// For example, a no-op replacement would be + /// `dst.extend(caps.get(0).unwrap().as_str())`. + fn replace_append(&mut self, caps: &Captures, dst: &mut String); + + /// Return a fixed unchanging replacement string. + /// + /// When doing replacements, if access to `Captures` is not needed (e.g., + /// the replacement byte string does not need `$` expansion), then it can + /// be beneficial to avoid finding sub-captures. + /// + /// In general, this is called once for every call to `replacen`. + fn no_expansion<'r>(&'r mut self) -> Option<Cow<'r, str>> { + None + } + + /// Return a `Replacer` that borrows and wraps this `Replacer`. + /// + /// This is useful when you want to take a generic `Replacer` (which might + /// not be cloneable) and use it without consuming it, so it can be used + /// more than once. + /// + /// # Example + /// + /// ``` + /// use regex::{Regex, Replacer}; + /// + /// fn replace_all_twice<R: Replacer>( + /// re: Regex, + /// src: &str, + /// mut rep: R, + /// ) -> String { + /// let dst = re.replace_all(src, rep.by_ref()); + /// let dst = re.replace_all(&dst, rep.by_ref()); + /// dst.into_owned() + /// } + /// ``` + fn by_ref<'r>(&'r mut self) -> ReplacerRef<'r, Self> { + ReplacerRef(self) + } +} + +/// By-reference adaptor for a `Replacer` +/// +/// Returned by [`Replacer::by_ref`](trait.Replacer.html#method.by_ref). +#[derive(Debug)] +pub struct ReplacerRef<'a, R: ?Sized + 'a>(&'a mut R); + +impl<'a, R: Replacer + ?Sized + 'a> Replacer for ReplacerRef<'a, R> { + fn replace_append(&mut self, caps: &Captures, dst: &mut String) { + self.0.replace_append(caps, dst) + } + fn no_expansion(&mut self) -> Option<Cow<str>> { + self.0.no_expansion() + } +} + +impl<'a> Replacer for &'a str { + fn replace_append(&mut self, caps: &Captures, dst: &mut String) { + caps.expand(*self, dst); + } + + fn no_expansion(&mut self) -> Option<Cow<str>> { + match find_byte(b'$', self.as_bytes()) { + Some(_) => None, + None => Some(Cow::Borrowed(*self)), + } + } +} + +impl<F, T> Replacer for F +where + F: FnMut(&Captures) -> T, + T: AsRef<str>, +{ + fn replace_append(&mut self, caps: &Captures, dst: &mut String) { + dst.push_str((*self)(caps).as_ref()); + } +} + +/// `NoExpand` indicates literal string replacement. +/// +/// It can be used with `replace` and `replace_all` to do a literal string +/// replacement without expanding `$name` to their corresponding capture +/// groups. This can be both convenient (to avoid escaping `$`, for example) +/// and performant (since capture groups don't need to be found). +/// +/// `'t` is the lifetime of the literal text. +pub struct NoExpand<'t>(pub &'t str); + +impl<'t> Replacer for NoExpand<'t> { + fn replace_append(&mut self, _: &Captures, dst: &mut String) { + dst.push_str(self.0); + } + + fn no_expansion(&mut self) -> Option<Cow<str>> { + Some(Cow::Borrowed(self.0)) + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/sparse.rs b/third_party/cargo/vendor/regex-1.3.3/src/sparse.rs new file mode 100644 index 0000000..9d48eee --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/sparse.rs @@ -0,0 +1,77 @@ +use std::ops::Deref; +use std::slice; + +/// A sparse set used for representing ordered NFA states. +/// +/// This supports constant time addition and membership testing. Clearing an +/// entire set can also be done in constant time. Iteration yields elements +/// in the order in which they were inserted. +/// +/// The data structure is based on: http://research.swtch.com/sparse +/// Note though that we don't actually use uninitialized memory. We generally +/// reuse allocations, so the initial allocation cost is bareable. However, +/// its other properties listed above are extremely useful. +#[derive(Clone, Debug)] +pub struct SparseSet { + /// Dense contains the instruction pointers in the order in which they + /// were inserted. + dense: Vec<usize>, + /// Sparse maps instruction pointers to their location in dense. + /// + /// An instruction pointer is in the set if and only if + /// sparse[ip] < dense.len() && ip == dense[sparse[ip]]. + sparse: Box<[usize]>, +} + +impl SparseSet { + pub fn new(size: usize) -> SparseSet { + SparseSet { + dense: Vec::with_capacity(size), + sparse: vec![0; size].into_boxed_slice(), + } + } + + pub fn len(&self) -> usize { + self.dense.len() + } + + pub fn is_empty(&self) -> bool { + self.dense.is_empty() + } + + pub fn capacity(&self) -> usize { + self.dense.capacity() + } + + pub fn insert(&mut self, value: usize) { + let i = self.len(); + assert!(i < self.capacity()); + self.dense.push(value); + self.sparse[value] = i; + } + + pub fn contains(&self, value: usize) -> bool { + let i = self.sparse[value]; + self.dense.get(i) == Some(&value) + } + + pub fn clear(&mut self) { + self.dense.clear(); + } +} + +impl Deref for SparseSet { + type Target = [usize]; + + fn deref(&self) -> &Self::Target { + &self.dense + } +} + +impl<'a> IntoIterator for &'a SparseSet { + type Item = &'a usize; + type IntoIter = slice::Iter<'a, usize>; + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/src/testdata/LICENSE b/third_party/cargo/vendor/regex-1.3.3/src/testdata/LICENSE new file mode 100644 index 0000000..f47dbf4 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/testdata/LICENSE @@ -0,0 +1,19 @@ +The following license covers testregex.c and all associated test data. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of THIS SOFTWARE FILE (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do +so, subject to the following disclaimer: + +THIS SOFTWARE IS PROVIDED BY AT&T ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL AT&T BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/third_party/cargo/vendor/regex-1.3.3/src/testdata/README b/third_party/cargo/vendor/regex-1.3.3/src/testdata/README new file mode 100644 index 0000000..6efc2da --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/testdata/README @@ -0,0 +1,17 @@ +Test data was taken from the Go distribution, which was in turn taken from the +testregex test suite: + + http://www2.research.att.com/~astopen/testregex/testregex.html + +The LICENSE in this directory corresponds to the LICENSE that the data was +released under. + +The tests themselves were modified for RE2/Go. A couple were modified further +by me (Andrew Gallant) (only in repetition.dat) so that RE2/Go would pass them. +(Yes, it seems like RE2/Go includes failing test cases.) This may or may not +have been a bad idea, but I think being consistent with an established Regex +library is worth something. + +Note that these files are read by 'scripts/regex-match-tests.py' and turned +into Rust tests found in 'regex_macros/tests/matches.rs'. + diff --git a/third_party/cargo/vendor/regex-1.3.3/src/testdata/basic.dat b/third_party/cargo/vendor/regex-1.3.3/src/testdata/basic.dat new file mode 100644 index 0000000..632e1bb --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/testdata/basic.dat @@ -0,0 +1,221 @@ +NOTE all standard compliant implementations should pass these : 2002-05-31 + +BE abracadabra$ abracadabracadabra (7,18) +BE a...b abababbb (2,7) +BE XXXXXX ..XXXXXX (2,8) +E \) () (1,2) +BE a] a]a (0,2) +B } } (0,1) +E \} } (0,1) +BE \] ] (0,1) +B ] ] (0,1) +E ] ] (0,1) +B { { (0,1) +B } } (0,1) +BE ^a ax (0,1) +BE \^a a^a (1,3) +BE a\^ a^ (0,2) +BE a$ aa (1,2) +BE a\$ a$ (0,2) +BE ^$ NULL (0,0) +E $^ NULL (0,0) +E a($) aa (1,2)(2,2) +E a*(^a) aa (0,1)(0,1) +E (..)*(...)* a (0,0) +E (..)*(...)* abcd (0,4)(2,4) +E (ab|a)(bc|c) abc (0,3)(0,2)(2,3) +E (ab)c|abc abc (0,3)(0,2) +E a{0}b ab (1,2) +E (a*)(b?)(b+)b{3} aaabbbbbbb (0,10)(0,3)(3,4)(4,7) +E (a*)(b{0,1})(b{1,})b{3} aaabbbbbbb (0,10)(0,3)(3,4)(4,7) +E a{9876543210} NULL BADBR +E ((a|a)|a) a (0,1)(0,1)(0,1) +E (a*)(a|aa) aaaa (0,4)(0,3)(3,4) +E a*(a.|aa) aaaa (0,4)(2,4) +E a(b)|c(d)|a(e)f aef (0,3)(?,?)(?,?)(1,2) +E (a|b)?.* b (0,1)(0,1) +E (a|b)c|a(b|c) ac (0,2)(0,1) +E (a|b)c|a(b|c) ab (0,2)(?,?)(1,2) +E (a|b)*c|(a|ab)*c abc (0,3)(1,2) +E (a|b)*c|(a|ab)*c xc (1,2) +E (.a|.b).*|.*(.a|.b) xa (0,2)(0,2) +E a?(ab|ba)ab abab (0,4)(0,2) +E a?(ac{0}b|ba)ab abab (0,4)(0,2) +E ab|abab abbabab (0,2) +E aba|bab|bba baaabbbaba (5,8) +E aba|bab baaabbbaba (6,9) +E (aa|aaa)*|(a|aaaaa) aa (0,2)(0,2) +E (a.|.a.)*|(a|.a...) aa (0,2)(0,2) +E ab|a xabc (1,3) +E ab|a xxabc (2,4) +Ei (?-u)(Ab|cD)* aBcD (0,4)(2,4) +BE [^-] --a (2,3) +BE [a-]* --a (0,3) +BE [a-m-]* --amoma-- (0,4) +E :::1:::0:|:::1:1:0: :::0:::1:::1:::0: (8,17) +E :::1:::0:|:::1:1:1: :::0:::1:::1:::0: (8,17) +{E [[:upper:]] A (0,1) [[<element>]] not supported +E [[:lower:]]+ `az{ (1,3) +E [[:upper:]]+ @AZ[ (1,3) +# No collation in Go +#BE [[-]] [[-]] (2,4) +#BE [[.NIL.]] NULL ECOLLATE +#BE [[=aleph=]] NULL ECOLLATE +} +BE$ \n \n (0,1) +BEn$ \n \n (0,1) +BE$ [^a] \n (0,1) +BE$ \na \na (0,2) +E (a)(b)(c) abc (0,3)(0,1)(1,2)(2,3) +BE xxx xxx (0,3) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) feb 6, (0,6) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) 2/7 (0,3) +E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) feb 1,Feb 6 (5,11) +E3 ((((((((((((((((((((((((((((((x)))))))))))))))))))))))))))))) x (0,1)(0,1)(0,1) +E3 ((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))* xx (0,2)(1,2)(1,2) +E a?(ab|ba)* ababababababababababababababababababababababababababababababababababababababababa (0,81)(79,81) +E abaa|abbaa|abbbaa|abbbbaa ababbabbbabbbabbbbabbbbaa (18,25) +E abaa|abbaa|abbbaa|abbbbaa ababbabbbabbbabbbbabaa (18,22) +E aaac|aabc|abac|abbc|baac|babc|bbac|bbbc baaabbbabac (7,11) +BE$ .* \x01\x7f (0,2) +E aaaa|bbbb|cccc|ddddd|eeeeee|fffffff|gggg|hhhh|iiiii|jjjjj|kkkkk|llll XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa (53,57) +L aaaa\nbbbb\ncccc\nddddd\neeeeee\nfffffff\ngggg\nhhhh\niiiii\njjjjj\nkkkkk\nllll XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa NOMATCH +E a*a*a*a*a*b aaaaaaaaab (0,10) +BE ^ NULL (0,0) +BE $ NULL (0,0) +BE ^$ NULL (0,0) +BE ^a$ a (0,1) +BE abc abc (0,3) +BE abc xabcy (1,4) +BE abc ababc (2,5) +BE ab*c abc (0,3) +BE ab*bc abc (0,3) +BE ab*bc abbc (0,4) +BE ab*bc abbbbc (0,6) +E ab+bc abbc (0,4) +E ab+bc abbbbc (0,6) +E ab?bc abbc (0,4) +E ab?bc abc (0,3) +E ab?c abc (0,3) +BE ^abc$ abc (0,3) +BE ^abc abcc (0,3) +BE abc$ aabc (1,4) +BE ^ abc (0,0) +BE $ abc (3,3) +BE a.c abc (0,3) +BE a.c axc (0,3) +BE a.*c axyzc (0,5) +BE a[bc]d abd (0,3) +BE a[b-d]e ace (0,3) +BE a[b-d] aac (1,3) +BE a[-b] a- (0,2) +BE a[b-] a- (0,2) +BE a] a] (0,2) +BE a[]]b a]b (0,3) +BE a[^bc]d aed (0,3) +BE a[^-b]c adc (0,3) +BE a[^]b]c adc (0,3) +E ab|cd abc (0,2) +E ab|cd abcd (0,2) +E a\(b a(b (0,3) +E a\(*b ab (0,2) +E a\(*b a((b (0,4) +E ((a)) abc (0,1)(0,1)(0,1) +E (a)b(c) abc (0,3)(0,1)(2,3) +E a+b+c aabbabc (4,7) +E a* aaa (0,3) +#E (a*)* - (0,0)(0,0) +E (a*)* - (0,0)(?,?) RE2/Go +E (a*)+ - (0,0)(0,0) +#E (a*|b)* - (0,0)(0,0) +E (a*|b)* - (0,0)(?,?) RE2/Go +E (a+|b)* ab (0,2)(1,2) +E (a+|b)+ ab (0,2)(1,2) +E (a+|b)? ab (0,1)(0,1) +BE [^ab]* cde (0,3) +#E (^)* - (0,0)(0,0) +E (^)* - (0,0)(?,?) RE2/Go +BE a* NULL (0,0) +E ([abc])*d abbbcd (0,6)(4,5) +E ([abc])*bcd abcd (0,4)(0,1) +E a|b|c|d|e e (0,1) +E (a|b|c|d|e)f ef (0,2)(0,1) +#E ((a*|b))* - (0,0)(0,0)(0,0) +E ((a*|b))* - (0,0)(?,?)(?,?) RE2/Go +BE abcd*efg abcdefg (0,7) +BE ab* xabyabbbz (1,3) +BE ab* xayabbbz (1,2) +E (ab|cd)e abcde (2,5)(2,4) +BE [abhgefdc]ij hij (0,3) +E (a|b)c*d abcd (1,4)(1,2) +E (ab|ab*)bc abc (0,3)(0,1) +E a([bc]*)c* abc (0,3)(1,3) +E a([bc]*)(c*d) abcd (0,4)(1,3)(3,4) +E a([bc]+)(c*d) abcd (0,4)(1,3)(3,4) +E a([bc]*)(c+d) abcd (0,4)(1,2)(2,4) +E a[bcd]*dcdcde adcdcde (0,7) +E (ab|a)b*c abc (0,3)(0,2) +E ((a)(b)c)(d) abcd (0,4)(0,3)(0,1)(1,2)(3,4) +BE [A-Za-z_][A-Za-z0-9_]* alpha (0,5) +E ^a(bc+|b[eh])g|.h$ abh (1,3) +E (bc+d$|ef*g.|h?i(j|k)) effgz (0,5)(0,5) +E (bc+d$|ef*g.|h?i(j|k)) ij (0,2)(0,2)(1,2) +E (bc+d$|ef*g.|h?i(j|k)) reffgz (1,6)(1,6) +E (((((((((a))))))))) a (0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1) +BE multiple words multiple words yeah (0,14) +E (.*)c(.*) abcde (0,5)(0,2)(3,5) +BE abcd abcd (0,4) +E a(bc)d abcd (0,4)(1,3) +E a[-]?c ac (0,3) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Qaddafi (0,15)(?,?)(10,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Mo'ammar Gadhafi (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Kaddafi (0,15)(?,?)(10,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Qadhafi (0,15)(?,?)(10,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Gadafi (0,14)(?,?)(10,11) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Mu'ammar Qadafi (0,15)(?,?)(11,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Moamar Gaddafi (0,14)(?,?)(9,11) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Mu'ammar Qadhdhafi (0,18)(?,?)(13,15) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Khaddafi (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Ghaddafy (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Ghadafi (0,15)(?,?)(11,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Ghaddafi (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muamar Kaddafi (0,14)(?,?)(9,11) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Quathafi (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Gheddafi (0,16)(?,?)(11,13) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Moammar Khadafy (0,15)(?,?)(11,12) +E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Moammar Qudhafi (0,15)(?,?)(10,12) +E a+(b|c)*d+ aabcdd (0,6)(3,4) +E ^.+$ vivi (0,4) +E ^(.+)$ vivi (0,4)(0,4) +E ^([^!.]+).att.com!(.+)$ gryphon.att.com!eby (0,19)(0,7)(16,19) +E ^([^!]+!)?([^!]+)$ bas (0,3)(?,?)(0,3) +E ^([^!]+!)?([^!]+)$ bar!bas (0,7)(0,4)(4,7) +E ^([^!]+!)?([^!]+)$ foo!bas (0,7)(0,4)(4,7) +E ^.+!([^!]+!)([^!]+)$ foo!bar!bas (0,11)(4,8)(8,11) +E ((foo)|(bar))!bas bar!bas (0,7)(0,3)(?,?)(0,3) +E ((foo)|(bar))!bas foo!bar!bas (4,11)(4,7)(?,?)(4,7) +E ((foo)|(bar))!bas foo!bas (0,7)(0,3)(0,3) +E ((foo)|bar)!bas bar!bas (0,7)(0,3) +E ((foo)|bar)!bas foo!bar!bas (4,11)(4,7) +E ((foo)|bar)!bas foo!bas (0,7)(0,3)(0,3) +E (foo|(bar))!bas bar!bas (0,7)(0,3)(0,3) +E (foo|(bar))!bas foo!bar!bas (4,11)(4,7)(4,7) +E (foo|(bar))!bas foo!bas (0,7)(0,3) +E (foo|bar)!bas bar!bas (0,7)(0,3) +E (foo|bar)!bas foo!bar!bas (4,11)(4,7) +E (foo|bar)!bas foo!bas (0,7)(0,3) +E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ foo!bar!bas (0,11)(0,11)(?,?)(?,?)(4,8)(8,11) +E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ bas (0,3)(?,?)(0,3) +E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ bar!bas (0,7)(0,4)(4,7) +E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ foo!bar!bas (0,11)(?,?)(?,?)(4,8)(8,11) +E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ foo!bas (0,7)(0,4)(4,7) +E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ bas (0,3)(0,3)(?,?)(0,3) +E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ bar!bas (0,7)(0,7)(0,4)(4,7) +E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ foo!bar!bas (0,11)(0,11)(?,?)(?,?)(4,8)(8,11) +E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ foo!bas (0,7)(0,7)(0,4)(4,7) +E .*(/XXX).* /XXX (0,4)(0,4) +E .*(\\XXX).* \XXX (0,4)(0,4) +E \\XXX \XXX (0,4) +E .*(/000).* /000 (0,4)(0,4) +E .*(\\000).* \000 (0,4)(0,4) +E \\000 \000 (0,4) diff --git a/third_party/cargo/vendor/regex-1.3.3/src/testdata/nullsubexpr.dat b/third_party/cargo/vendor/regex-1.3.3/src/testdata/nullsubexpr.dat new file mode 100644 index 0000000..2e18fbb --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/testdata/nullsubexpr.dat @@ -0,0 +1,79 @@ +NOTE null subexpression matches : 2002-06-06 + +E (a*)* a (0,1)(0,1) +#E SAME x (0,0)(0,0) +E SAME x (0,0)(?,?) RE2/Go +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) +E (a*)+ a (0,1)(0,1) +E SAME x (0,0)(0,0) +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) +E (a+)* a (0,1)(0,1) +E SAME x (0,0) +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) +E (a+)+ a (0,1)(0,1) +E SAME x NOMATCH +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) + +E ([a]*)* a (0,1)(0,1) +#E SAME x (0,0)(0,0) +E SAME x (0,0)(?,?) RE2/Go +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) +E ([a]*)+ a (0,1)(0,1) +E SAME x (0,0)(0,0) +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaax (0,6)(0,6) +E ([^b]*)* a (0,1)(0,1) +#E SAME b (0,0)(0,0) +E SAME b (0,0)(?,?) RE2/Go +E SAME aaaaaa (0,6)(0,6) +E SAME aaaaaab (0,6)(0,6) +E ([ab]*)* a (0,1)(0,1) +E SAME aaaaaa (0,6)(0,6) +E SAME ababab (0,6)(0,6) +E SAME bababa (0,6)(0,6) +E SAME b (0,1)(0,1) +E SAME bbbbbb (0,6)(0,6) +E SAME aaaabcde (0,5)(0,5) +E ([^a]*)* b (0,1)(0,1) +E SAME bbbbbb (0,6)(0,6) +#E SAME aaaaaa (0,0)(0,0) +E SAME aaaaaa (0,0)(?,?) RE2/Go +E ([^ab]*)* ccccxx (0,6)(0,6) +#E SAME ababab (0,0)(0,0) +E SAME ababab (0,0)(?,?) RE2/Go + +E ((z)+|a)* zabcde (0,2)(1,2) + +#{E a+? aaaaaa (0,1) no *? +? mimimal match ops +#E (a) aaa (0,1)(0,1) +#E (a*?) aaa (0,0)(0,0) +#E (a)*? aaa (0,0) +#E (a*?)*? aaa (0,0) +#} + +B \(a*\)*\(x\) x (0,1)(0,0)(0,1) +B \(a*\)*\(x\) ax (0,2)(0,1)(1,2) +B \(a*\)*\(x\) axa (0,2)(0,1)(1,2) +B \(a*\)*\(x\)\(\1\) x (0,1)(0,0)(0,1)(1,1) +B \(a*\)*\(x\)\(\1\) ax (0,2)(1,1)(1,2)(2,2) +B \(a*\)*\(x\)\(\1\) axa (0,3)(0,1)(1,2)(2,3) +B \(a*\)*\(x\)\(\1\)\(x\) axax (0,4)(0,1)(1,2)(2,3)(3,4) +B \(a*\)*\(x\)\(\1\)\(x\) axxa (0,3)(1,1)(1,2)(2,2)(2,3) + +#E (a*)*(x) x (0,1)(0,0)(0,1) +E (a*)*(x) x (0,1)(?,?)(0,1) RE2/Go +E (a*)*(x) ax (0,2)(0,1)(1,2) +E (a*)*(x) axa (0,2)(0,1)(1,2) + +E (a*)+(x) x (0,1)(0,0)(0,1) +E (a*)+(x) ax (0,2)(0,1)(1,2) +E (a*)+(x) axa (0,2)(0,1)(1,2) + +E (a*){2}(x) x (0,1)(0,0)(0,1) +E (a*){2}(x) ax (0,2)(1,1)(1,2) +E (a*){2}(x) axa (0,2)(1,1)(1,2) diff --git a/third_party/cargo/vendor/regex-1.3.3/src/testdata/repetition.dat b/third_party/cargo/vendor/regex-1.3.3/src/testdata/repetition.dat new file mode 100644 index 0000000..3bb2121 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/testdata/repetition.dat @@ -0,0 +1,163 @@ +NOTE implicit vs. explicit repetitions : 2009-02-02 + +# Glenn Fowler <gsf@research.att.com> +# conforming matches (column 4) must match one of the following BREs +# NOMATCH +# (0,.)\((\(.\),\(.\))(?,?)(\2,\3)\)* +# (0,.)\((\(.\),\(.\))(\2,\3)(?,?)\)* +# i.e., each 3-tuple has two identical elements and one (?,?) + +E ((..)|(.)) NULL NOMATCH +E ((..)|(.))((..)|(.)) NULL NOMATCH +E ((..)|(.))((..)|(.))((..)|(.)) NULL NOMATCH + +E ((..)|(.)){1} NULL NOMATCH +E ((..)|(.)){2} NULL NOMATCH +E ((..)|(.)){3} NULL NOMATCH + +E ((..)|(.))* NULL (0,0) + +E ((..)|(.)) a (0,1)(0,1)(?,?)(0,1) +E ((..)|(.))((..)|(.)) a NOMATCH +E ((..)|(.))((..)|(.))((..)|(.)) a NOMATCH + +E ((..)|(.)){1} a (0,1)(0,1)(?,?)(0,1) +E ((..)|(.)){2} a NOMATCH +E ((..)|(.)){3} a NOMATCH + +E ((..)|(.))* a (0,1)(0,1)(?,?)(0,1) + +E ((..)|(.)) aa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.))((..)|(.)) aa (0,2)(0,1)(?,?)(0,1)(1,2)(?,?)(1,2) +E ((..)|(.))((..)|(.))((..)|(.)) aa NOMATCH + +E ((..)|(.)){1} aa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.)){2} aa (0,2)(1,2)(?,?)(1,2) +E ((..)|(.)){3} aa NOMATCH + +E ((..)|(.))* aa (0,2)(0,2)(0,2)(?,?) + +E ((..)|(.)) aaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.))((..)|(.)) aaa (0,3)(0,2)(0,2)(?,?)(2,3)(?,?)(2,3) +E ((..)|(.))((..)|(.))((..)|(.)) aaa (0,3)(0,1)(?,?)(0,1)(1,2)(?,?)(1,2)(2,3)(?,?)(2,3) + +E ((..)|(.)){1} aaa (0,2)(0,2)(0,2)(?,?) +#E ((..)|(.)){2} aaa (0,3)(2,3)(?,?)(2,3) +E ((..)|(.)){2} aaa (0,3)(2,3)(0,2)(2,3) RE2/Go +E ((..)|(.)){3} aaa (0,3)(2,3)(?,?)(2,3) + +#E ((..)|(.))* aaa (0,3)(2,3)(?,?)(2,3) +E ((..)|(.))* aaa (0,3)(2,3)(0,2)(2,3) RE2/Go + +E ((..)|(.)) aaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.))((..)|(.)) aaaa (0,4)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?) +E ((..)|(.))((..)|(.))((..)|(.)) aaaa (0,4)(0,2)(0,2)(?,?)(2,3)(?,?)(2,3)(3,4)(?,?)(3,4) + +E ((..)|(.)){1} aaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.)){2} aaaa (0,4)(2,4)(2,4)(?,?) +#E ((..)|(.)){3} aaaa (0,4)(3,4)(?,?)(3,4) +E ((..)|(.)){3} aaaa (0,4)(3,4)(0,2)(3,4) RE2/Go + +E ((..)|(.))* aaaa (0,4)(2,4)(2,4)(?,?) + +E ((..)|(.)) aaaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.))((..)|(.)) aaaaa (0,4)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?) +E ((..)|(.))((..)|(.))((..)|(.)) aaaaa (0,5)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?)(4,5)(?,?)(4,5) + +E ((..)|(.)){1} aaaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.)){2} aaaaa (0,4)(2,4)(2,4)(?,?) +#E ((..)|(.)){3} aaaaa (0,5)(4,5)(?,?)(4,5) +E ((..)|(.)){3} aaaaa (0,5)(4,5)(2,4)(4,5) RE2/Go + +#E ((..)|(.))* aaaaa (0,5)(4,5)(?,?)(4,5) +E ((..)|(.))* aaaaa (0,5)(4,5)(2,4)(4,5) RE2/Go + +E ((..)|(.)) aaaaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.))((..)|(.)) aaaaaa (0,4)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?) +E ((..)|(.))((..)|(.))((..)|(.)) aaaaaa (0,6)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?)(4,6)(4,6)(?,?) + +E ((..)|(.)){1} aaaaaa (0,2)(0,2)(0,2)(?,?) +E ((..)|(.)){2} aaaaaa (0,4)(2,4)(2,4)(?,?) +E ((..)|(.)){3} aaaaaa (0,6)(4,6)(4,6)(?,?) + +E ((..)|(.))* aaaaaa (0,6)(4,6)(4,6)(?,?) + +NOTE additional repetition tests graciously provided by Chris Kuklewicz www.haskell.org 2009-02-02 + +# These test a bug in OS X / FreeBSD / NetBSD, and libtree. +# Linux/GLIBC gets the {8,} and {8,8} wrong. + +:HA#100:E X(.?){0,}Y X1234567Y (0,9)(7,8) +:HA#101:E X(.?){1,}Y X1234567Y (0,9)(7,8) +:HA#102:E X(.?){2,}Y X1234567Y (0,9)(7,8) +:HA#103:E X(.?){3,}Y X1234567Y (0,9)(7,8) +:HA#104:E X(.?){4,}Y X1234567Y (0,9)(7,8) +:HA#105:E X(.?){5,}Y X1234567Y (0,9)(7,8) +:HA#106:E X(.?){6,}Y X1234567Y (0,9)(7,8) +:HA#107:E X(.?){7,}Y X1234567Y (0,9)(7,8) +:HA#108:E X(.?){8,}Y X1234567Y (0,9)(8,8) +#:HA#110:E X(.?){0,8}Y X1234567Y (0,9)(7,8) +:HA#110:E X(.?){0,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#111:E X(.?){1,8}Y X1234567Y (0,9)(7,8) +:HA#111:E X(.?){1,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#112:E X(.?){2,8}Y X1234567Y (0,9)(7,8) +:HA#112:E X(.?){2,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#113:E X(.?){3,8}Y X1234567Y (0,9)(7,8) +:HA#113:E X(.?){3,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#114:E X(.?){4,8}Y X1234567Y (0,9)(7,8) +:HA#114:E X(.?){4,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#115:E X(.?){5,8}Y X1234567Y (0,9)(7,8) +:HA#115:E X(.?){5,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#116:E X(.?){6,8}Y X1234567Y (0,9)(7,8) +:HA#116:E X(.?){6,8}Y X1234567Y (0,9)(8,8) RE2/Go +#:HA#117:E X(.?){7,8}Y X1234567Y (0,9)(7,8) +:HA#117:E X(.?){7,8}Y X1234567Y (0,9)(8,8) RE2/Go +:HA#118:E X(.?){8,8}Y X1234567Y (0,9)(8,8) + +# These test a fixed bug in my regex-tdfa that did not keep the expanded +# form properly grouped, so right association did the wrong thing with +# these ambiguous patterns (crafted just to test my code when I became +# suspicious of my implementation). The first subexpression should use +# "ab" then "a" then "bcd". + +# OS X / FreeBSD / NetBSD badly fail many of these, with impossible +# results like (0,6)(4,5)(6,6). + +:HA#260:E (a|ab|c|bcd){0,}(d*) ababcd (0,1)(0,1)(1,1) +:HA#261:E (a|ab|c|bcd){1,}(d*) ababcd (0,1)(0,1)(1,1) +:HA#262:E (a|ab|c|bcd){2,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#263:E (a|ab|c|bcd){3,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#264:E (a|ab|c|bcd){4,}(d*) ababcd NOMATCH +:HA#265:E (a|ab|c|bcd){0,10}(d*) ababcd (0,1)(0,1)(1,1) +:HA#266:E (a|ab|c|bcd){1,10}(d*) ababcd (0,1)(0,1)(1,1) +:HA#267:E (a|ab|c|bcd){2,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#268:E (a|ab|c|bcd){3,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#269:E (a|ab|c|bcd){4,10}(d*) ababcd NOMATCH +:HA#270:E (a|ab|c|bcd)*(d*) ababcd (0,1)(0,1)(1,1) +:HA#271:E (a|ab|c|bcd)+(d*) ababcd (0,1)(0,1)(1,1) + +# The above worked on Linux/GLIBC but the following often fail. +# They also trip up OS X / FreeBSD / NetBSD: + +#:HA#280:E (ab|a|c|bcd){0,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#280:E (ab|a|c|bcd){0,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#281:E (ab|a|c|bcd){1,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#281:E (ab|a|c|bcd){1,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#282:E (ab|a|c|bcd){2,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#282:E (ab|a|c|bcd){2,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#283:E (ab|a|c|bcd){3,}(d*) ababcd (0,6)(3,6)(6,6) +:HA#283:E (ab|a|c|bcd){3,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +:HA#284:E (ab|a|c|bcd){4,}(d*) ababcd NOMATCH +#:HA#285:E (ab|a|c|bcd){0,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#285:E (ab|a|c|bcd){0,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#286:E (ab|a|c|bcd){1,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#286:E (ab|a|c|bcd){1,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#287:E (ab|a|c|bcd){2,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#287:E (ab|a|c|bcd){2,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#288:E (ab|a|c|bcd){3,10}(d*) ababcd (0,6)(3,6)(6,6) +:HA#288:E (ab|a|c|bcd){3,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +:HA#289:E (ab|a|c|bcd){4,10}(d*) ababcd NOMATCH +#:HA#290:E (ab|a|c|bcd)*(d*) ababcd (0,6)(3,6)(6,6) +:HA#290:E (ab|a|c|bcd)*(d*) ababcd (0,6)(4,5)(5,6) RE2/Go +#:HA#291:E (ab|a|c|bcd)+(d*) ababcd (0,6)(3,6)(6,6) +:HA#291:E (ab|a|c|bcd)+(d*) ababcd (0,6)(4,5)(5,6) RE2/Go diff --git a/third_party/cargo/vendor/regex-1.3.3/src/utf8.rs b/third_party/cargo/vendor/regex-1.3.3/src/utf8.rs new file mode 100644 index 0000000..6e0608f --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/src/utf8.rs @@ -0,0 +1,264 @@ +/// A few elementary UTF-8 encoding and decoding functions used by the matching +/// engines. +/// +/// In an ideal world, the matching engines operate on `&str` and we can just +/// lean on the standard library for all our UTF-8 needs. However, to support +/// byte based regexes (that can match on arbitrary bytes which may contain +/// UTF-8), we need to be capable of searching and decoding UTF-8 on a `&[u8]`. +/// The standard library doesn't really recognize this use case, so we have +/// to build it out ourselves. +/// +/// Should this be factored out into a separate crate? It seems independently +/// useful. There are other crates that already exist (e.g., `utf-8`) that have +/// overlapping use cases. Not sure what to do. +use std::char; + +const TAG_CONT: u8 = 0b1000_0000; +const TAG_TWO: u8 = 0b1100_0000; +const TAG_THREE: u8 = 0b1110_0000; +const TAG_FOUR: u8 = 0b1111_0000; + +/// Returns the smallest possible index of the next valid UTF-8 sequence +/// starting after `i`. +pub fn next_utf8(text: &[u8], i: usize) -> usize { + let b = match text.get(i) { + None => return i + 1, + Some(&b) => b, + }; + let inc = if b <= 0x7F { + 1 + } else if b <= 0b110_11111 { + 2 + } else if b <= 0b1110_1111 { + 3 + } else { + 4 + }; + i + inc +} + +/// Decode a single UTF-8 sequence into a single Unicode codepoint from `src`. +/// +/// If no valid UTF-8 sequence could be found, then `None` is returned. +/// Otherwise, the decoded codepoint and the number of bytes read is returned. +/// The number of bytes read (for a valid UTF-8 sequence) is guaranteed to be +/// 1, 2, 3 or 4. +/// +/// Note that a UTF-8 sequence is invalid if it is incorrect UTF-8, encodes a +/// codepoint that is out of range (surrogate codepoints are out of range) or +/// is not the shortest possible UTF-8 sequence for that codepoint. +#[inline] +pub fn decode_utf8(src: &[u8]) -> Option<(char, usize)> { + let b0 = match src.get(0) { + None => return None, + Some(&b) if b <= 0x7F => return Some((b as char, 1)), + Some(&b) => b, + }; + match b0 { + 0b110_00000..=0b110_11111 => { + if src.len() < 2 { + return None; + } + let b1 = src[1]; + if 0b11_000000 & b1 != TAG_CONT { + return None; + } + let cp = ((b0 & !TAG_TWO) as u32) << 6 | ((b1 & !TAG_CONT) as u32); + match cp { + 0x80..=0x7FF => char::from_u32(cp).map(|cp| (cp, 2)), + _ => None, + } + } + 0b1110_0000..=0b1110_1111 => { + if src.len() < 3 { + return None; + } + let (b1, b2) = (src[1], src[2]); + if 0b11_000000 & b1 != TAG_CONT { + return None; + } + if 0b11_000000 & b2 != TAG_CONT { + return None; + } + let cp = ((b0 & !TAG_THREE) as u32) << 12 + | ((b1 & !TAG_CONT) as u32) << 6 + | ((b2 & !TAG_CONT) as u32); + match cp { + // char::from_u32 will disallow surrogate codepoints. + 0x800..=0xFFFF => char::from_u32(cp).map(|cp| (cp, 3)), + _ => None, + } + } + 0b11110_000..=0b11110_111 => { + if src.len() < 4 { + return None; + } + let (b1, b2, b3) = (src[1], src[2], src[3]); + if 0b11_000000 & b1 != TAG_CONT { + return None; + } + if 0b11_000000 & b2 != TAG_CONT { + return None; + } + if 0b11_000000 & b3 != TAG_CONT { + return None; + } + let cp = ((b0 & !TAG_FOUR) as u32) << 18 + | ((b1 & !TAG_CONT) as u32) << 12 + | ((b2 & !TAG_CONT) as u32) << 6 + | ((b3 & !TAG_CONT) as u32); + match cp { + 0x10000..=0x10FFFF => char::from_u32(cp).map(|cp| (cp, 4)), + _ => None, + } + } + _ => None, + } +} + +/// Like `decode_utf8`, but decodes the last UTF-8 sequence in `src` instead +/// of the first. +pub fn decode_last_utf8(src: &[u8]) -> Option<(char, usize)> { + if src.is_empty() { + return None; + } + let mut start = src.len() - 1; + if src[start] <= 0x7F { + return Some((src[start] as char, 1)); + } + while start > src.len().saturating_sub(4) { + start -= 1; + if is_start_byte(src[start]) { + break; + } + } + match decode_utf8(&src[start..]) { + None => None, + Some((_, n)) if n < src.len() - start => None, + Some((cp, n)) => Some((cp, n)), + } +} + +fn is_start_byte(b: u8) -> bool { + b & 0b11_000000 != 0b1_0000000 +} + +#[cfg(test)] +mod tests { + use std::str; + + use quickcheck::quickcheck; + + use super::{ + decode_last_utf8, decode_utf8, TAG_CONT, TAG_FOUR, TAG_THREE, TAG_TWO, + }; + + #[test] + fn prop_roundtrip() { + fn p(given_cp: char) -> bool { + let mut tmp = [0; 4]; + let encoded_len = given_cp.encode_utf8(&mut tmp).len(); + let (got_cp, got_len) = decode_utf8(&tmp[..encoded_len]).unwrap(); + encoded_len == got_len && given_cp == got_cp + } + quickcheck(p as fn(char) -> bool) + } + + #[test] + fn prop_roundtrip_last() { + fn p(given_cp: char) -> bool { + let mut tmp = [0; 4]; + let encoded_len = given_cp.encode_utf8(&mut tmp).len(); + let (got_cp, got_len) = + decode_last_utf8(&tmp[..encoded_len]).unwrap(); + encoded_len == got_len && given_cp == got_cp + } + quickcheck(p as fn(char) -> bool) + } + + #[test] + fn prop_encode_matches_std() { + fn p(cp: char) -> bool { + let mut got = [0; 4]; + let n = cp.encode_utf8(&mut got).len(); + let expected = cp.to_string(); + &got[..n] == expected.as_bytes() + } + quickcheck(p as fn(char) -> bool) + } + + #[test] + fn prop_decode_matches_std() { + fn p(given_cp: char) -> bool { + let mut tmp = [0; 4]; + let n = given_cp.encode_utf8(&mut tmp).len(); + let (got_cp, _) = decode_utf8(&tmp[..n]).unwrap(); + let expected_cp = + str::from_utf8(&tmp[..n]).unwrap().chars().next().unwrap(); + got_cp == expected_cp + } + quickcheck(p as fn(char) -> bool) + } + + #[test] + fn prop_decode_last_matches_std() { + fn p(given_cp: char) -> bool { + let mut tmp = [0; 4]; + let n = given_cp.encode_utf8(&mut tmp).len(); + let (got_cp, _) = decode_last_utf8(&tmp[..n]).unwrap(); + let expected_cp = str::from_utf8(&tmp[..n]) + .unwrap() + .chars() + .rev() + .next() + .unwrap(); + got_cp == expected_cp + } + quickcheck(p as fn(char) -> bool) + } + + #[test] + fn reject_invalid() { + // Invalid start byte + assert_eq!(decode_utf8(&[0xFF]), None); + // Surrogate pair + assert_eq!(decode_utf8(&[0xED, 0xA0, 0x81]), None); + // Invalid continuation byte. + assert_eq!(decode_utf8(&[0xD4, 0xC2]), None); + // Bad lengths + assert_eq!(decode_utf8(&[0xC3]), None); // 2 bytes + assert_eq!(decode_utf8(&[0xEF, 0xBF]), None); // 3 bytes + assert_eq!(decode_utf8(&[0xF4, 0x8F, 0xBF]), None); // 4 bytes + // Not a minimal UTF-8 sequence + assert_eq!(decode_utf8(&[TAG_TWO, TAG_CONT | b'a']), None); + assert_eq!(decode_utf8(&[TAG_THREE, TAG_CONT, TAG_CONT | b'a']), None); + assert_eq!( + decode_utf8(&[TAG_FOUR, TAG_CONT, TAG_CONT, TAG_CONT | b'a',]), + None + ); + } + + #[test] + fn reject_invalid_last() { + // Invalid start byte + assert_eq!(decode_last_utf8(&[0xFF]), None); + // Surrogate pair + assert_eq!(decode_last_utf8(&[0xED, 0xA0, 0x81]), None); + // Bad lengths + assert_eq!(decode_last_utf8(&[0xC3]), None); // 2 bytes + assert_eq!(decode_last_utf8(&[0xEF, 0xBF]), None); // 3 bytes + assert_eq!(decode_last_utf8(&[0xF4, 0x8F, 0xBF]), None); // 4 bytes + // Not a minimal UTF-8 sequence + assert_eq!(decode_last_utf8(&[TAG_TWO, TAG_CONT | b'a']), None); + assert_eq!( + decode_last_utf8(&[TAG_THREE, TAG_CONT, TAG_CONT | b'a',]), + None + ); + assert_eq!( + decode_last_utf8( + &[TAG_FOUR, TAG_CONT, TAG_CONT, TAG_CONT | b'a',] + ), + None + ); + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/test b/third_party/cargo/vendor/regex-1.3.3/test new file mode 100755 index 0000000..3d1351c --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/test @@ -0,0 +1,28 @@ +#!/bin/bash + +# This is a convenience script for running a broad swath of tests across +# features. We don't test the complete space, since the complete space is quite +# large. Hopefully once we migrate the test suite to better infrastructure +# (like regex-automata), we'll be able to test more of the space. +echo "===== DEFAULT FEATURES ===" +cargo test + +echo "===== DOC TESTS ===" +cargo test --doc + +features=( + "std" + "std unicode" + "std unicode-perl" + "std perf" + "std perf-cache" + "std perf-dfa" + "std perf-inline" + "std perf-literal" +) +for f in "${features[@]}"; do + echo "===== FEATURE: $f (default) ===" + cargo test --test default --no-default-features --features "$f" + echo "===== FEATURE: $f (default-bytes) ===" + cargo test --test default-bytes --no-default-features --features "$f" +done diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/api.rs b/third_party/cargo/vendor/regex-1.3.3/tests/api.rs new file mode 100644 index 0000000..0d4962c --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/api.rs @@ -0,0 +1,222 @@ +#[test] +fn empty_regex_empty_match() { + let re = regex!(""); + assert_eq!(vec![(0, 0)], findall!(re, "")); +} + +#[test] +fn empty_regex_nonempty_match() { + let re = regex!(""); + assert_eq!(vec![(0, 0), (1, 1), (2, 2), (3, 3)], findall!(re, "abc")); +} + +#[test] +fn one_zero_length_match() { + let re = regex!(r"[0-9]*"); + assert_eq!(vec![(0, 0), (1, 2), (3, 4)], findall!(re, "a1b2")); +} + +#[test] +fn many_zero_length_match() { + let re = regex!(r"[0-9]*"); + assert_eq!( + vec![(0, 0), (1, 2), (3, 3), (4, 4), (5, 6)], + findall!(re, "a1bbb2") + ); +} + +#[test] +fn many_sequential_zero_length_match() { + let re = regex!(r"[0-9]?"); + assert_eq!( + vec![(0, 0), (1, 2), (2, 3), (4, 5), (6, 6)], + findall!(re, "a12b3c") + ); +} + +#[test] +fn quoted_bracket_set() { + let re = regex!(r"([\x{5b}\x{5d}])"); + assert_eq!(vec![(0, 1), (1, 2)], findall!(re, "[]")); + let re = regex!(r"([\[\]])"); + assert_eq!(vec![(0, 1), (1, 2)], findall!(re, "[]")); +} + +#[test] +fn first_range_starts_with_left_bracket() { + let re = regex!(r"([\[-z])"); + assert_eq!(vec![(0, 1), (1, 2)], findall!(re, "[]")); +} + +#[test] +fn range_ends_with_escape() { + let re = regex!(r"([\[-\x{5d}])"); + assert_eq!(vec![(0, 1), (1, 2)], findall!(re, "[]")); +} + +#[test] +fn empty_match_find_iter() { + let re = regex!(r".*?"); + assert_eq!(vec![(0, 0), (1, 1), (2, 2), (3, 3)], findall!(re, "abc")); +} + +#[test] +fn empty_match_captures_iter() { + let re = regex!(r".*?"); + let ms: Vec<_> = re + .captures_iter(text!("abc")) + .map(|c| c.get(0).unwrap()) + .map(|m| (m.start(), m.end())) + .collect(); + assert_eq!(ms, vec![(0, 0), (1, 1), (2, 2), (3, 3)]); +} + +#[test] +fn capture_names() { + let re = regex!(r"(.)(?P<a>.)"); + assert_eq!(3, re.captures_len()); + assert_eq!((3, Some(3)), re.capture_names().size_hint()); + assert_eq!( + vec![None, None, Some("a")], + re.capture_names().collect::<Vec<_>>() + ); +} + +#[test] +fn regex_string() { + assert_eq!(r"[a-zA-Z0-9]+", regex!(r"[a-zA-Z0-9]+").as_str()); + assert_eq!(r"[a-zA-Z0-9]+", &format!("{}", regex!(r"[a-zA-Z0-9]+"))); + assert_eq!(r"[a-zA-Z0-9]+", &format!("{:?}", regex!(r"[a-zA-Z0-9]+"))); +} + +#[test] +fn capture_index() { + let re = regex!(r"^(?P<name>.+)$"); + let cap = re.captures(t!("abc")).unwrap(); + assert_eq!(&cap[0], t!("abc")); + assert_eq!(&cap[1], t!("abc")); + assert_eq!(&cap["name"], t!("abc")); +} + +#[test] +#[should_panic] +#[cfg_attr(all(target_env = "msvc", target_pointer_width = "32"), ignore)] +fn capture_index_panic_usize() { + let re = regex!(r"^(?P<name>.+)$"); + let cap = re.captures(t!("abc")).unwrap(); + let _ = cap[2]; +} + +#[test] +#[should_panic] +#[cfg_attr(all(target_env = "msvc", target_pointer_width = "32"), ignore)] +fn capture_index_panic_name() { + let re = regex!(r"^(?P<name>.+)$"); + let cap = re.captures(t!("abc")).unwrap(); + let _ = cap["bad name"]; +} + +#[test] +fn capture_index_lifetime() { + // This is a test of whether the types on `caps["..."]` are general + // enough. If not, this will fail to typecheck. + fn inner(s: &str) -> usize { + let re = regex!(r"(?P<number>[0-9]+)"); + let caps = re.captures(t!(s)).unwrap(); + caps["number"].len() + } + assert_eq!(3, inner("123")); +} + +#[test] +fn capture_misc() { + let re = regex!(r"(.)(?P<a>a)?(.)(?P<b>.)"); + let cap = re.captures(t!("abc")).unwrap(); + + assert_eq!(5, cap.len()); + + assert_eq!((0, 3), { + let m = cap.get(0).unwrap(); + (m.start(), m.end()) + }); + assert_eq!(None, cap.get(2)); + assert_eq!((2, 3), { + let m = cap.get(4).unwrap(); + (m.start(), m.end()) + }); + + assert_eq!(t!("abc"), match_text!(cap.get(0).unwrap())); + assert_eq!(None, cap.get(2)); + assert_eq!(t!("c"), match_text!(cap.get(4).unwrap())); + + assert_eq!(None, cap.name("a")); + assert_eq!(t!("c"), match_text!(cap.name("b").unwrap())); +} + +#[test] +fn sub_capture_matches() { + let re = regex!(r"([a-z])(([a-z])|([0-9]))"); + let cap = re.captures(t!("a5")).unwrap(); + let subs: Vec<_> = cap.iter().collect(); + + assert_eq!(5, subs.len()); + assert!(subs[0].is_some()); + assert!(subs[1].is_some()); + assert!(subs[2].is_some()); + assert!(subs[3].is_none()); + assert!(subs[4].is_some()); + + assert_eq!(t!("a5"), match_text!(subs[0].unwrap())); + assert_eq!(t!("a"), match_text!(subs[1].unwrap())); + assert_eq!(t!("5"), match_text!(subs[2].unwrap())); + assert_eq!(t!("5"), match_text!(subs[4].unwrap())); +} + +expand!(expand1, r"(?-u)(?P<foo>\w+)", "abc", "$foo", "abc"); +expand!(expand2, r"(?-u)(?P<foo>\w+)", "abc", "$0", "abc"); +expand!(expand3, r"(?-u)(?P<foo>\w+)", "abc", "$1", "abc"); +expand!(expand4, r"(?-u)(?P<foo>\w+)", "abc", "$$1", "$1"); +expand!(expand5, r"(?-u)(?P<foo>\w+)", "abc", "$$foo", "$foo"); +expand!(expand6, r"(?-u)(?P<a>\w+)\s+(?P<b>\d+)", "abc 123", "$b$a", "123abc"); +expand!(expand7, r"(?-u)(?P<a>\w+)\s+(?P<b>\d+)", "abc 123", "z$bz$az", "z"); +expand!( + expand8, + r"(?-u)(?P<a>\w+)\s+(?P<b>\d+)", + "abc 123", + ".$b.$a.", + ".123.abc." +); +expand!( + expand9, + r"(?-u)(?P<a>\w+)\s+(?P<b>\d+)", + "abc 123", + " $b $a ", + " 123 abc " +); +expand!(expand10, r"(?-u)(?P<a>\w+)\s+(?P<b>\d+)", "abc 123", "$bz$az", ""); + +split!( + split1, + r"(?-u)\s+", + "a b\nc\td\n\t e", + &[t!("a"), t!("b"), t!("c"), t!("d"), t!("e")] +); +split!( + split2, + r"(?-u)\b", + "a b c", + &[t!(""), t!("a"), t!(" "), t!("b"), t!(" "), t!("c"), t!("")] +); +split!(split3, r"a$", "a", &[t!(""), t!("")]); +split!(split_none, r"-", r"a", &[t!("a")]); +split!(split_trailing_blank, r"-", r"a-", &[t!("a"), t!("")]); +split!(split_trailing_blanks, r"-", r"a--", &[t!("a"), t!(""), t!("")]); +split!(split_empty, r"-", r"", &[t!("")]); + +splitn!(splitn_below_limit, r"-", r"a", 2, &[t!("a")]); +splitn!(splitn_at_limit, r"-", r"a-b", 2, &[t!("a"), t!("b")]); +splitn!(splitn_above_limit, r"-", r"a-b-c", 2, &[t!("a"), t!("b-c")]); +splitn!(splitn_zero_limit, r"-", r"a-b", 0, empty_vec!()); +splitn!(splitn_trailing_blank, r"-", r"a-", 2, &[t!("a"), t!("")]); +splitn!(splitn_trailing_separator, r"-", r"a--", 2, &[t!("a"), t!("-")]); +splitn!(splitn_empty, r"-", r"", 1, &[t!("")]); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/api_str.rs b/third_party/cargo/vendor/regex-1.3.3/tests/api_str.rs new file mode 100644 index 0000000..480116d --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/api_str.rs @@ -0,0 +1,34 @@ +// These tests don't really make sense with the bytes API, so we only test them +// on the Unicode API. + +#[test] +fn empty_match_unicode_find_iter() { + // Tests that we still yield byte ranges at valid UTF-8 sequence boundaries + // even when we're susceptible to empty width matches. + let re = regex!(r".*?"); + assert_eq!( + vec![(0, 0), (3, 3), (4, 4), (7, 7), (8, 8)], + findall!(re, "Ⅰ1Ⅱ2") + ); +} + +#[test] +fn empty_match_unicode_captures_iter() { + // Same as empty_match_unicode_find_iter, but tests capture iteration. + let re = regex!(r".*?"); + let ms: Vec<_> = re + .captures_iter(text!("Ⅰ1Ⅱ2")) + .map(|c| c.get(0).unwrap()) + .map(|m| (m.start(), m.end())) + .collect(); + assert_eq!(vec![(0, 0), (3, 3), (4, 4), (7, 7), (8, 8)], ms); +} + +#[test] +fn match_as_str() { + let re = regex!(r"fo+"); + let caps = re.captures("barfoobar").unwrap(); + assert_eq!(caps.get(0).map(|m| m.as_str()), Some("foo")); + assert_eq!(caps.get(0).map(From::from), Some("foo")); + assert_eq!(caps.get(0).map(Into::into), Some("foo")); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/bytes.rs b/third_party/cargo/vendor/regex-1.3.3/tests/bytes.rs new file mode 100644 index 0000000..d05f138 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/bytes.rs @@ -0,0 +1,107 @@ +// These are tests specifically crafted for regexes that can match arbitrary +// bytes. + +// A silly wrapper to make it possible to write and match raw bytes. +struct R<'a>(&'a [u8]); +impl<'a> R<'a> { + fn as_bytes(&self) -> &'a [u8] { + self.0 + } +} + +mat!(word_boundary, r"(?-u) \b", " δ", None); +#[cfg(feature = "unicode-perl")] +mat!(word_boundary_unicode, r" \b", " δ", Some((0, 1))); +mat!(word_not_boundary, r"(?-u) \B", " δ", Some((0, 1))); +#[cfg(feature = "unicode-perl")] +mat!(word_not_boundary_unicode, r" \B", " δ", None); + +mat!(perl_w_ascii, r"(?-u)\w+", "aδ", Some((0, 1))); +#[cfg(feature = "unicode-perl")] +mat!(perl_w_unicode, r"\w+", "aδ", Some((0, 3))); +mat!(perl_d_ascii, r"(?-u)\d+", "1२३9", Some((0, 1))); +#[cfg(feature = "unicode-perl")] +mat!(perl_d_unicode, r"\d+", "1२३9", Some((0, 8))); +mat!(perl_s_ascii, r"(?-u)\s+", " \u{1680}", Some((0, 1))); +#[cfg(feature = "unicode-perl")] +mat!(perl_s_unicode, r"\s+", " \u{1680}", Some((0, 4))); + +// The first `(.+)` matches two Unicode codepoints, but can't match the 5th +// byte, which isn't valid UTF-8. The second (byte based) `(.+)` takes over and +// matches. +mat!( + mixed1, + r"(.+)(?-u)(.+)", + R(b"\xCE\x93\xCE\x94\xFF"), + Some((0, 5)), + Some((0, 4)), + Some((4, 5)) +); + +mat!(case_ascii_one, r"(?i-u)a", "A", Some((0, 1))); +mat!(case_ascii_class, r"(?i-u)[a-z]+", "AaAaA", Some((0, 5))); +#[cfg(feature = "unicode-case")] +mat!(case_unicode, r"(?i)[a-z]+", "aA\u{212A}aA", Some((0, 7))); +mat!(case_not_unicode, r"(?i-u)[a-z]+", "aA\u{212A}aA", Some((0, 2))); + +mat!(negate_unicode, r"[^a]", "δ", Some((0, 2))); +mat!(negate_not_unicode, r"(?-u)[^a]", "δ", Some((0, 1))); + +// This doesn't match in a normal Unicode regex because the implicit preceding +// `.*?` is Unicode aware. +mat!(dotstar_prefix_not_unicode1, r"(?-u)a", R(b"\xFFa"), Some((1, 2))); +mat!(dotstar_prefix_not_unicode2, r"a", R(b"\xFFa"), Some((1, 2))); + +// Have fun with null bytes. +mat!( + null_bytes, + r"(?-u)(?P<cstr>[^\x00]+)\x00", + R(b"foo\x00"), + Some((0, 4)), + Some((0, 3)) +); + +// Test that lookahead operators work properly in the face of invalid UTF-8. +// See: https://github.com/rust-lang/regex/issues/277 +matiter!( + invalidutf8_anchor1, + r"(?-u)\xcc?^", + R(b"\x8d#;\x1a\xa4s3\x05foobarX\\\x0f0t\xe4\x9b\xa4"), + (0, 0) +); +matiter!( + invalidutf8_anchor2, + r"(?-u)^\xf7|4\xff\d\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a##########[] d\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a##########\[] #####\x80\S7|$", + R(b"\x8d#;\x1a\xa4s3\x05foobarX\\\x0f0t\xe4\x9b\xa4"), + (22, 22) +); +matiter!( + invalidutf8_anchor3, + r"(?-u)^|ddp\xff\xffdddddlQd@\x80", + R(b"\x8d#;\x1a\xa4s3\x05foobarX\\\x0f0t\xe4\x9b\xa4"), + (0, 0) +); + +// See https://github.com/rust-lang/regex/issues/303 +#[test] +fn negated_full_byte_range() { + assert!(::regex::bytes::Regex::new(r#"(?-u)[^\x00-\xff]"#).is_err()); +} + +matiter!(word_boundary_ascii1, r"(?-u:\B)x(?-u:\B)", "áxβ"); +matiter!( + word_boundary_ascii2, + r"(?-u:\B)", + "0\u{7EF5E}", + (2, 2), + (3, 3), + (4, 4), + (5, 5) +); + +// See: https://github.com/rust-lang/regex/issues/264 +mat!(ascii_boundary_no_capture, r"(?-u)\B", "\u{28f3e}", Some((0, 0))); +mat!(ascii_boundary_capture, r"(?-u)(\B)", "\u{28f3e}", Some((0, 0))); + +// See: https://github.com/rust-lang/regex/issues/271 +mat!(end_not_wb, r"$(?-u:\B)", "\u{5c124}\u{b576c}", Some((8, 8))); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/consistent.rs b/third_party/cargo/vendor/regex-1.3.3/tests/consistent.rs new file mode 100644 index 0000000..0f9ea53 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/consistent.rs @@ -0,0 +1,241 @@ +use regex::internal::ExecBuilder; + +/// Given a regex, check if all of the backends produce the same +/// results on a number of different inputs. +/// +/// For now this just throws quickcheck at the problem, which +/// is not very good because it only really tests half of the +/// problem space. It is pretty unlikely that a random string +/// will match any given regex, so this will probably just +/// be checking that the different backends fail in the same +/// way. This is still worthwhile to test, but is definitely not +/// the whole story. +/// +/// TODO(ethan): In order to cover the other half of the problem +/// space, we should generate a random matching string by inspecting +/// the AST of the input regex. The right way to do this probably +/// involves adding a custom Arbitrary instance around a couple +/// of newtypes. That way we can respect the quickcheck size hinting +/// and shrinking and whatnot. +pub fn backends_are_consistent(re: &str) -> Result<u64, String> { + let standard_backends = vec![ + ( + "bounded_backtracking_re", + ExecBuilder::new(re) + .bounded_backtracking() + .build() + .map(|exec| exec.into_regex()) + .map_err(|err| format!("{}", err))?, + ), + ( + "pikevm_re", + ExecBuilder::new(re) + .nfa() + .build() + .map(|exec| exec.into_regex()) + .map_err(|err| format!("{}", err))?, + ), + ( + "default_re", + ExecBuilder::new(re) + .build() + .map(|exec| exec.into_regex()) + .map_err(|err| format!("{}", err))?, + ), + ]; + + let utf8bytes_backends = vec![ + ( + "bounded_backtracking_utf8bytes_re", + ExecBuilder::new(re) + .bounded_backtracking() + .bytes(true) + .build() + .map(|exec| exec.into_regex()) + .map_err(|err| format!("{}", err))?, + ), + ( + "pikevm_utf8bytes_re", + ExecBuilder::new(re) + .nfa() + .bytes(true) + .build() + .map(|exec| exec.into_regex()) + .map_err(|err| format!("{}", err))?, + ), + ( + "default_utf8bytes_re", + ExecBuilder::new(re) + .bytes(true) + .build() + .map(|exec| exec.into_regex()) + .map_err(|err| format!("{}", err))?, + ), + ]; + + let bytes_backends = vec![ + ( + "bounded_backtracking_bytes_re", + ExecBuilder::new(re) + .bounded_backtracking() + .only_utf8(false) + .build() + .map(|exec| exec.into_byte_regex()) + .map_err(|err| format!("{}", err))?, + ), + ( + "pikevm_bytes_re", + ExecBuilder::new(re) + .nfa() + .only_utf8(false) + .build() + .map(|exec| exec.into_byte_regex()) + .map_err(|err| format!("{}", err))?, + ), + ( + "default_bytes_re", + ExecBuilder::new(re) + .only_utf8(false) + .build() + .map(|exec| exec.into_byte_regex()) + .map_err(|err| format!("{}", err))?, + ), + ]; + + Ok(string_checker::check_backends(&standard_backends)? + + string_checker::check_backends(&utf8bytes_backends)? + + bytes_checker::check_backends(&bytes_backends)?) +} + +// +// A consistency checker parameterized by the input type (&str or &[u8]). +// + +macro_rules! checker { + ($module_name:ident, $regex_type:path, $mk_input:expr) => { + mod $module_name { + use quickcheck; + use quickcheck::{Arbitrary, TestResult}; + + pub fn check_backends( + backends: &[(&str, $regex_type)], + ) -> Result<u64, String> { + let mut total_passed = 0; + for regex in backends[1..].iter() { + total_passed += quickcheck_regex_eq(&backends[0], regex)?; + } + + Ok(total_passed) + } + + fn quickcheck_regex_eq( + &(name1, ref re1): &(&str, $regex_type), + &(name2, ref re2): &(&str, $regex_type), + ) -> Result<u64, String> { + quickcheck::QuickCheck::new() + .quicktest(RegexEqualityTest::new( + re1.clone(), + re2.clone(), + )) + .map_err(|err| { + format!( + "{}(/{}/) and {}(/{}/) are inconsistent.\ + QuickCheck Err: {:?}", + name1, re1, name2, re2, err + ) + }) + } + + struct RegexEqualityTest { + re1: $regex_type, + re2: $regex_type, + } + impl RegexEqualityTest { + fn new(re1: $regex_type, re2: $regex_type) -> Self { + RegexEqualityTest { re1: re1, re2: re2 } + } + } + + impl quickcheck::Testable for RegexEqualityTest { + fn result<G: quickcheck::Gen>( + &self, + gen: &mut G, + ) -> TestResult { + let input = $mk_input(gen); + let input = &input; + + if self.re1.find(&input) != self.re2.find(input) { + return TestResult::error(format!( + "find mismatch input={:?}", + input + )); + } + + let cap1 = self.re1.captures(input); + let cap2 = self.re2.captures(input); + match (cap1, cap2) { + (None, None) => {} + (Some(cap1), Some(cap2)) => { + for (c1, c2) in cap1.iter().zip(cap2.iter()) { + if c1 != c2 { + return TestResult::error(format!( + "captures mismatch input={:?}", + input + )); + } + } + } + _ => { + return TestResult::error(format!( + "captures mismatch input={:?}", + input + )) + } + } + + let fi1 = self.re1.find_iter(input); + let fi2 = self.re2.find_iter(input); + for (m1, m2) in fi1.zip(fi2) { + if m1 != m2 { + return TestResult::error(format!( + "find_iter mismatch input={:?}", + input + )); + } + } + + let ci1 = self.re1.captures_iter(input); + let ci2 = self.re2.captures_iter(input); + for (cap1, cap2) in ci1.zip(ci2) { + for (c1, c2) in cap1.iter().zip(cap2.iter()) { + if c1 != c2 { + return TestResult::error(format!( + "captures_iter mismatch input={:?}", + input + )); + } + } + } + + let s1 = self.re1.split(input); + let s2 = self.re2.split(input); + for (chunk1, chunk2) in s1.zip(s2) { + if chunk1 != chunk2 { + return TestResult::error(format!( + "split mismatch input={:?}", + input + )); + } + } + + TestResult::from_bool(true) + } + } + } // mod + }; // rule case +} // macro_rules! + +checker!(string_checker, ::regex::Regex, |gen| String::arbitrary(gen)); +checker!(bytes_checker, ::regex::bytes::Regex, |gen| Vec::<u8>::arbitrary( + gen +)); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/crates_regex.rs b/third_party/cargo/vendor/regex-1.3.3/tests/crates_regex.rs new file mode 100644 index 0000000..200ec27 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/crates_regex.rs @@ -0,0 +1,3287 @@ +// DO NOT EDIT. Automatically generated by 'scripts/scrape_crates_io.py' +// on 2018-06-20 09:56:32.820354. + +// autoshutdown-0.1.0: r"\s*(\d+)(\w)\s*" +consistent!(autoshutdown_0, r"\s*(\d+)(\w)\s*"); + +// epub-1.1.1: r"/" +consistent!(epub_0, r"/"); + +// rpi-info-0.2.0: "^Revision\t+: ([0-9a-fA-F]+)" +consistent!(rpi_info_0, "^Revision\t+: ([0-9a-fA-F]+)"); + +// rpi-info-0.2.0: "Serial\t+: ([0-9a-fA-F]+)" +consistent!(rpi_info_1, "Serial\t+: ([0-9a-fA-F]+)"); + +// pnet_macros-0.21.0: r"^u([0-9]+)(be|le|he)?$" +consistent!(pnet_macros_0, r"^u([0-9]+)(be|le|he)?$"); + +// iban_validate-1.0.3: r"^[A-Z]{2}\d{2}[A-Z\d]{1,30}$" +consistent!(iban_validate_0, r"^[A-Z]{2}\d{2}[A-Z\d]{1,30}$"); + +// markifier-0.1.0: r".*\[(?P<percent>.+)%.*\].*" +consistent!(markifier_0, r".*\[(?P<percent>.+)%.*\].*"); + +// mallumo-0.3.0: r"(#include) (\S*)(.*)" +consistent!(mallumo_0, r"(#include) (\S*)(.*)"); + +// mallumo-0.3.0: r"(ERROR: \d+:)(\d+)(: )(.+)" +consistent!(mallumo_1, r"(ERROR: \d+:)(\d+)(: )(.+)"); + +// mallumo-0.3.0: r"(\d+\()(\d+)(?:\) : )(.+)" +consistent!(mallumo_2, r"(\d+\()(\d+)(?:\) : )(.+)"); + +// magnet_more-0.0.1: r"(.+?)(\[.*?\])?" +consistent!(magnet_more_0, r"(.+?)(\[.*?\])?"); + +// magnet_app-0.0.1: r":(?P<k>[a-zA-Z_]+)" +consistent!(magnet_app_0, r":(?P<k>[a-zA-Z_]+)"); + +// yubibomb-0.2.0: r"^\d{6}(?:\s*,\s*\d{6})*$" +consistent!(yubibomb_0, r"^\d{6}(?:\s*,\s*\d{6})*$"); + +// multirust-rs-0.0.4: r"[\\/]([^\\/?]+)(\?.*)?$" +consistent!(multirust_rs_0, r"[\\/]([^\\/?]+)(\?.*)?$"); + +// hueclient-0.3.2: "\"[a-z]*\":null" +consistent!(hueclient_0, "\"[a-z]*\":null"); + +// hueclient-0.3.2: ",+" +consistent!(hueclient_1, ",+"); + +// hueclient-0.3.2: ",\\}" +consistent!(hueclient_2, ",\\}"); + +// hueclient-0.3.2: "\\{," +consistent!(hueclient_3, "\\{,"); + +// aerial-0.1.0: r"[a-zA-Z_\$][a-zA-Z_0-9]*" +consistent!(aerial_0, r"[a-zA-Z_\$][a-zA-Z_0-9]*"); + +// aerial-0.1.0: r"thi[sng]+" +consistent!(aerial_1, r"thi[sng]+"); + +// rvue-0.1.0: r"(.+)\s+\((.+?)\)" +consistent!(rvue_0, r"(.+)\s+\((.+?)\)"); + +// rvue-0.1.0: r"([\d\.]+)\s*out\s*of\s*([\d\.]+)" +consistent!(rvue_1, r"([\d\.]+)\s*out\s*of\s*([\d\.]+)"); + +// rvue-0.1.0: r"^([\d\.]+)\s*(?:\(\))?$" +consistent!(rvue_2, r"^([\d\.]+)\s*(?:\(\))?$"); + +// rvue-0.1.0: r"([\d\.]+)\s*Points\s*Possible" +consistent!(rvue_3, r"([\d\.]+)\s*Points\s*Possible"); + +// rvue-0.1.0: r"([\d\.]+)\s*/\s*([\d\.]+)" +consistent!(rvue_4, r"([\d\.]+)\s*/\s*([\d\.]+)"); + +// rvsim-0.1.0: r"_?([_a-z0-9]+)\s*:\s*([_a-z0-9]+)\s*[,)]" +consistent!(rvsim_0, r"_?([_a-z0-9]+)\s*:\s*([_a-z0-9]+)\s*[,)]"); + +// nereon-0.1.4: "(.*[^\\\\])\\{\\}(.*)" +consistent!(nereon_0, "(.*[^\\\\])\\{\\}(.*)"); + +// next_episode-0.3.0: r"((?i)^(.+).s(\d+)e(\d+).*)$" +consistent!(next_episode_0, r"((?i)^(.+).s(\d+)e(\d+).*)$"); + +// migrant_lib-0.19.2: r"[^a-z0-9-]+" +consistent!(migrant_lib_0, r"[^a-z0-9-]+"); + +// migrant_lib-0.19.2: r"[0-9]{14}_[a-z0-9-]+" +consistent!(migrant_lib_1, r"[0-9]{14}_[a-z0-9-]+"); + +// migrant_lib-0.19.2: r"([0-9]{14}_)?[a-z0-9-]+" +consistent!(migrant_lib_2, r"([0-9]{14}_)?[a-z0-9-]+"); + +// minipre-0.2.0: "$_" +consistent!(minipre_0, "$_"); + +// minifier-0.0.13: r">\s+<" +consistent!(minifier_0, r">\s+<"); + +// minifier-0.0.13: r"\s{2,}|[\r\n]" +consistent!(minifier_1, r"\s{2,}|[\r\n]"); + +// minifier-0.0.13: r"<(style|script)[\w|\s].*?>" +consistent!(minifier_2, r"<(style|script)[\w|\s].*?>"); + +// minifier-0.0.13: "<!--(.|\n)*?-->" +consistent!(minifier_3, "<!--(.|\n)*?-->"); + +// minifier-0.0.13: r"<\w.*?>" +consistent!(minifier_4, r"<\w.*?>"); + +// minifier-0.0.13: r" \s+|\s +" +consistent!(minifier_5, r" \s+|\s +"); + +// minifier-0.0.13: r"\w\s+\w" +consistent!(minifier_6, r"\w\s+\w"); + +// minifier-0.0.13: r"'\s+>" +consistent!(minifier_7, r"'\s+>"); + +// minifier-0.0.13: r"\d\s+>" +consistent!(minifier_8, r"\d\s+>"); + +// ggp-rs-0.1.2: r"(?P<relation>\([^)]+\))|(?P<prop>[a-zA-Z0-9_]+)" +consistent!(ggp_rs_0, r"(?P<relation>\([^)]+\))|(?P<prop>[a-zA-Z0-9_]+)"); + +// ggp-rs-0.1.2: r"\((.*)\)." +consistent!(ggp_rs_1, r"\((.*)\)."); + +// poe-superfilter-0.2.0: "[A-Za-z0-9_]" +consistent!(poe_superfilter_0, "[A-Za-z0-9_]"); + +// poke-a-mango-0.5.0: r"(\d+)x(\d+)" +consistent!(poke_a_mango_0, r"(\d+)x(\d+)"); + +// pop3-rs-0.1.0: r"(?P<nmsg>\d+) (?P<size>\d+)" +consistent!(pop3_rs_0, r"(?P<nmsg>\d+) (?P<size>\d+)"); + +// pop3-rs-0.1.0: r"(?P<msgid>\d+) (?P<uidl>[\x21-\x7E]{1,70})" +consistent!(pop3_rs_1, r"(?P<msgid>\d+) (?P<uidl>[\x21-\x7E]{1,70})"); + +// pop3-rs-0.1.0: r"(<.*>)\r\n$" +consistent!(pop3_rs_2, r"(<.*>)\r\n$"); + +// pop3-rs-0.1.0: r"^(?P<status>\+OK|-ERR) (?P<statustext>.*)" +consistent!(pop3_rs_3, r"^(?P<status>\+OK|-ERR) (?P<statustext>.*)"); + +// pop3-1.0.6: r"^\.\r\n$" +consistent!(pop3_0, r"^\.\r\n$"); + +// pop3-1.0.6: r"\+OK(.*)" +consistent!(pop3_1, r"\+OK(.*)"); + +// pop3-1.0.6: r"-ERR(.*)" +consistent!(pop3_2, r"-ERR(.*)"); + +// pop3-1.0.6: r"\+OK (\d+) (\d+)\r\n" +consistent!(pop3_3, r"\+OK (\d+) (\d+)\r\n"); + +// pop3-1.0.6: r"(\d+) ([\x21-\x7e]+)\r\n" +consistent!(pop3_4, r"(\d+) ([\x21-\x7e]+)\r\n"); + +// pop3-1.0.6: r"\+OK (\d+) ([\x21-\x7e]+)\r\n" +consistent!(pop3_5, r"\+OK (\d+) ([\x21-\x7e]+)\r\n"); + +// pop3-1.0.6: r"(\d+) (\d+)\r\n" +consistent!(pop3_6, r"(\d+) (\d+)\r\n"); + +// pop3-1.0.6: r"\+OK (\d+) (\d+)\r\n" +consistent!(pop3_7, r"\+OK (\d+) (\d+)\r\n"); + +// polk-1.1.3: "github:(\\w+)/?(\\w+)?" +consistent!(polk_0, "github:(\\w+)/?(\\w+)?"); + +// geochunk-0.1.5: "^[0-9]{5}" +consistent!(geochunk_0, "^[0-9]{5}"); + +// generic-dns-update-1.1.4: r"((?:(?:0|1[\d]{0,2}|2(?:[0-4]\d?|5[0-5]?|[6-9])?|[3-9]\d?)\.){3}(?:0|1[\d]{0,2}|2(?:[0-4]\d?|5[0-5]?|[6-9])?|[3-9]\d?))" +consistent!(generic_dns_update_0, r"((?:(?:0|1[\d]{0,2}|2(?:[0-4]\d?|5[0-5]?|[6-9])?|[3-9]\d?)\.){3}(?:0|1[\d]{0,2}|2(?:[0-4]\d?|5[0-5]?|[6-9])?|[3-9]\d?))"); + +// generic-dns-update-1.1.4: r"((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d)\.){3}(\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d))|(([0-9A-Fa-f]{1,4}:){0,5}:((\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d)\.){3}(\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d))|(::([0-9A-Fa-f]{1,4}:){0,5}((\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d)\.){3}(\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))" +consistent!(generic_dns_update_1, r"((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d)\.){3}(\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d))|(([0-9A-Fa-f]{1,4}:){0,5}:((\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d)\.){3}(\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d))|(::([0-9A-Fa-f]{1,4}:){0,5}((\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d)\.){3}(\d((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\d))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))"); + +// generic-dns-update-1.1.4: r"<value><string>([0-9.]*)</string></value>" +consistent!( + generic_dns_update_2, + r"<value><string>([0-9.]*)</string></value>" +); + +// generic-dns-update-1.1.4: r"<int>([0-9]+)</int>" +consistent!(generic_dns_update_3, r"<int>([0-9]+)</int>"); + +// generic-dns-update-1.1.4: r"<int>([0-9]+)</int>" +consistent!(generic_dns_update_4, r"<int>([0-9]+)</int>"); + +// generic-dns-update-1.1.4: r"<boolean>([0-1]*)</boolean>" +consistent!(generic_dns_update_5, r"<boolean>([0-1]*)</boolean>"); + +// generate-nix-pkg-0.3.0: r"(\d*)\.(\d*)\.(\d*)(-(\S*))?" +consistent!(generate_nix_pkg_0, r"(\d*)\.(\d*)\.(\d*)(-(\S*))?"); + +// generate-nix-pkg-0.3.0: r"^(\S*) (\d*)\.(\d*)\.(\d*)(-(\S*))?" +consistent!(generate_nix_pkg_1, r"^(\S*) (\d*)\.(\d*)\.(\d*)(-(\S*))?"); + +// genact-0.6.0: r"arch/([a-z0-9_])+/" +consistent!(genact_0, r"arch/([a-z0-9_])+/"); + +// genact-0.6.0: r"arch/([a-z0-9_])+/" +consistent!(genact_1, r"arch/([a-z0-9_])+/"); + +// cron_rs-0.1.6: r"^\s*((\*(/\d+)?)|[0-9-,/]+)(\s+((\*(/\d+)?)|[0-9-,/]+)){4,5}\s*$" +consistent!( + cron_rs_0, + r"^\s*((\*(/\d+)?)|[0-9-,/]+)(\s+((\*(/\d+)?)|[0-9-,/]+)){4,5}\s*$" +); + +// systemfd-0.3.0: r"^([a-zA-Z]+)::(.+)$" +consistent!(systemfd_0, r"^([a-zA-Z]+)::(.+)$"); + +// symbolic-debuginfo-5.0.2: "__?hidden#\\d+_" +consistent!(symbolic_debuginfo_0, "__?hidden#\\d+_"); + +// symbolic-minidump-5.0.2: r"^Linux ([^ ]+) (.*) \w+(?: GNU/Linux)?$" +consistent!(symbolic_minidump_0, r"^Linux ([^ ]+) (.*) \w+(?: GNU/Linux)?$"); + +// graphql-idl-parser-0.1.1: "^(?u:\\#)(?u:[\t-\r - \u{85}-\u{85}\u{a0}-\u{a0}\u{1680}-\u{1680}\u{2000}-\u{200a}\u{2028}-\u{2029}\u{202f}-\u{202f}\u{205f}-\u{205f}\u{3000}-\u{3000}])*(?u:.)+" +consistent!(graphql_idl_parser_0, "^(?u:\\#)(?u:[\t-\r - \u{85}-\u{85}\u{a0}-\u{a0}\u{1680}-\u{1680}\u{2000}-\u{200a}\u{2028}-\u{2029}\u{202f}-\u{202f}\u{205f}-\u{205f}\u{3000}-\u{3000}])*(?u:.)+"); + +// graphql-idl-parser-0.1.1: "^(?u:=)(?u:[\t-\r - \u{85}-\u{85}\u{a0}-\u{a0}\u{1680}-\u{1680}\u{2000}-\u{200a}\u{2028}-\u{2029}\u{202f}-\u{202f}\u{205f}-\u{205f}\u{3000}-\u{3000}])*(?u:.)+" +consistent!(graphql_idl_parser_1, "^(?u:=)(?u:[\t-\r - \u{85}-\u{85}\u{a0}-\u{a0}\u{1680}-\u{1680}\u{2000}-\u{200a}\u{2028}-\u{2029}\u{202f}-\u{202f}\u{205f}-\u{205f}\u{3000}-\u{3000}])*(?u:.)+"); + +// graphql-idl-parser-0.1.1: "^(?u:[A-Z_-_a-z])(?u:[0-9A-Z_-_a-z])*" +consistent!(graphql_idl_parser_2, "^(?u:[A-Z_-_a-z])(?u:[0-9A-Z_-_a-z])*"); + +// graphql-idl-parser-0.1.1: "^(?u:!)" +consistent!(graphql_idl_parser_3, "^(?u:!)"); + +// graphql-idl-parser-0.1.1: "^(?u:\\()" +consistent!(graphql_idl_parser_4, "^(?u:\\()"); + +// graphql-idl-parser-0.1.1: "^(?u:\\))" +consistent!(graphql_idl_parser_5, "^(?u:\\))"); + +// graphql-idl-parser-0.1.1: "^(?u:,)" +consistent!(graphql_idl_parser_6, "^(?u:,)"); + +// graphql-idl-parser-0.1.1: "^(?u::)" +consistent!(graphql_idl_parser_7, "^(?u::)"); + +// graphql-idl-parser-0.1.1: "^(?u:@)" +consistent!(graphql_idl_parser_8, "^(?u:@)"); + +// graphql-idl-parser-0.1.1: "^(?u:\\[)" +consistent!(graphql_idl_parser_9, "^(?u:\\[)"); + +// graphql-idl-parser-0.1.1: "^(?u:\\])" +consistent!(graphql_idl_parser_10, "^(?u:\\])"); + +// graphql-idl-parser-0.1.1: "^(?u:enum)" +consistent!(graphql_idl_parser_11, "^(?u:enum)"); + +// graphql-idl-parser-0.1.1: "^(?u:implements)" +consistent!(graphql_idl_parser_12, "^(?u:implements)"); + +// graphql-idl-parser-0.1.1: "^(?u:input)" +consistent!(graphql_idl_parser_13, "^(?u:input)"); + +// graphql-idl-parser-0.1.1: "^(?u:interface)" +consistent!(graphql_idl_parser_14, "^(?u:interface)"); + +// graphql-idl-parser-0.1.1: "^(?u:scalar)" +consistent!(graphql_idl_parser_15, "^(?u:scalar)"); + +// graphql-idl-parser-0.1.1: "^(?u:type)" +consistent!(graphql_idl_parser_16, "^(?u:type)"); + +// graphql-idl-parser-0.1.1: "^(?u:union)" +consistent!(graphql_idl_parser_17, "^(?u:union)"); + +// graphql-idl-parser-0.1.1: "^(?u:\\{)" +consistent!(graphql_idl_parser_18, "^(?u:\\{)"); + +// graphql-idl-parser-0.1.1: "^(?u:\\})" +consistent!(graphql_idl_parser_19, "^(?u:\\})"); + +// grimoire-0.1.0: r"(?s)/\*(?P<config>.*?)\*/" +consistent!(grimoire_0, r"(?s)/\*(?P<config>.*?)\*/"); + +// phonenumber-0.2.0+8.9.0: r"[\d]+(?:[~\x{2053}\x{223C}\x{FF5E}][\d]+)?" +consistent!(phonenumber_0, r"[\d]+(?:[~\x{2053}\x{223C}\x{FF5E}][\d]+)?"); + +// phonenumber-0.2.0+8.9.0: r"[, \[\]]" +consistent!(phonenumber_1, r"[, \[\]]"); + +// phonenumber-0.2.0+8.9.0: r"[\\/] *x" +consistent!(phonenumber_2, r"[\\/] *x"); + +// phonenumber-0.2.0+8.9.0: r"[[\P{N}&&\P{L}]&&[^#]]+$" +consistent!(phonenumber_3, r"[[\P{N}&&\P{L}]&&[^#]]+$"); + +// phonenumber-0.2.0+8.9.0: r"(?:.*?[A-Za-z]){3}.*" +consistent!(phonenumber_4, r"(?:.*?[A-Za-z]){3}.*"); + +// phonenumber-0.2.0+8.9.0: r"(\D+)" +consistent!(phonenumber_5, r"(\D+)"); + +// phonenumber-0.2.0+8.9.0: r"(\$\d)" +consistent!(phonenumber_6, r"(\$\d)"); + +// phonenumber-0.2.0+8.9.0: r"\(?\$1\)?" +consistent!(phonenumber_7, r"\(?\$1\)?"); + +// phone_number-0.1.0: r"\D" +consistent!(phone_number_0, r"\D"); + +// phone_number-0.1.0: r"^0+" +consistent!(phone_number_1, r"^0+"); + +// phone_number-0.1.0: r"^89" +consistent!(phone_number_2, r"^89"); + +// phone_number-0.1.0: r"^8+" +consistent!(phone_number_3, r"^8+"); + +// phile-0.1.4: r"^ *(\^_*\^) *$" +consistent!(phile_0, r"^ *(\^_*\^) *$"); + +// phile-0.1.4: r"^[_\p{XID_Start}]$" +consistent!(phile_1, r"^[_\p{XID_Start}]$"); + +// phile-0.1.4: r"^\p{XID_Continue}$" +consistent!(phile_2, r"^\p{XID_Continue}$"); + +// uritemplate-0.1.2: "%25(?P<hex>[0-9a-fA-F][0-9a-fA-F])" +consistent!(uritemplate_0, "%25(?P<hex>[0-9a-fA-F][0-9a-fA-F])"); + +// urdf-rs-0.4.2: "^package://(\\w+)/" +consistent!(urdf_rs_0, "^package://(\\w+)/"); + +// url-match-0.1.7: r"(?P<key>[?&.])" +consistent!(url_match_0, r"(?P<key>[?&.])"); + +// url-match-0.1.7: r":(?P<key>[a-zA-Z0-9_-]+)" +consistent!(url_match_1, r":(?P<key>[a-zA-Z0-9_-]+)"); + +// tsm-sys-0.1.0: r"hello world" +consistent!(tsm_sys_0, r"hello world"); + +// deb-version-0.1.0: "^(?:(?:(?:\\d+:).+)|(?:[^:]+))$" +consistent!(deb_version_0, "^(?:(?:(?:\\d+:).+)|(?:[^:]+))$"); + +// debcargo-2.1.0: r"^(?i)(a|an|the)\s+" +consistent!(debcargo_0, r"^(?i)(a|an|the)\s+"); + +// debcargo-2.1.0: r"^(?i)(rust\s+)?(implementation|library|tool|crate)\s+(of|to|for)\s+" +consistent!( + debcargo_1, + r"^(?i)(rust\s+)?(implementation|library|tool|crate)\s+(of|to|for)\s+" +); + +// feaders-0.2.0: r"^.*\.h$" +consistent!(feaders_0, r"^.*\.h$"); + +// feaders-0.2.0: r"^.*\.c$" +consistent!(feaders_1, r"^.*\.c$"); + +// feaders-0.2.0: r"^.*\.hpp$" +consistent!(feaders_2, r"^.*\.hpp$"); + +// feaders-0.2.0: r"^.*\.cc$" +consistent!(feaders_3, r"^.*\.cc$"); + +// feaders-0.2.0: r"^.*\.cpp$" +consistent!(feaders_4, r"^.*\.cpp$"); + +// hyperscan-0.1.6: r"CPtr\(\w+\)" +consistent!(hyperscan_0, r"CPtr\(\w+\)"); + +// hyperscan-0.1.6: r"^Version:\s(\d\.\d\.\d)\sFeatures:\s+(\w+)?\sMode:\s(\w+)$" +consistent!( + hyperscan_1, + r"^Version:\s(\d\.\d\.\d)\sFeatures:\s+(\w+)?\sMode:\s(\w+)$" +); + +// hyperscan-0.1.6: r"RawDatabase<Block>\{db: \w+\}" +consistent!(hyperscan_2, r"RawDatabase<Block>\{db: \w+\}"); + +// hyperscan-0.1.6: r"RawSerializedDatabase\{p: \w+, len: \d+\}" +consistent!(hyperscan_3, r"RawSerializedDatabase\{p: \w+, len: \d+\}"); + +// ucd-parse-0.1.1: r"[0-9A-F]+" +consistent!(ucd_parse_0, r"[0-9A-F]+"); + +// afsort-0.2.0: r".*" +consistent!(afsort_0, r".*"); + +// afsort-0.2.0: r".*" +consistent!(afsort_1, r".*"); + +// afsort-0.2.0: r".*" +consistent!(afsort_2, r".*"); + +// afsort-0.2.0: r".*" +consistent!(afsort_3, r".*"); + +// afsort-0.2.0: r".*" +consistent!(afsort_4, r".*"); + +// afsort-0.2.0: r".*" +consistent!(afsort_5, r".*"); + +// afsort-0.2.0: r"^[a-z]+$" +consistent!(afsort_6, r"^[a-z]+$"); + +// afsort-0.2.0: r"^[a-z]+$" +consistent!(afsort_7, r"^[a-z]+$"); + +// tin-summer-1.21.4: r"(\.git|\.pijul|_darcs|\.hg)$" +consistent!(tin_summer_0, r"(\.git|\.pijul|_darcs|\.hg)$"); + +// tin-drummer-1.0.1: r".*?\.(a|la|lo|o|ll|keter|bc|dyn_o|d|rlib|crate|min\.js|hi|dyn_hi|S|jsexe|webapp|js\.externs|ibc|toc|aux|fdb_latexmk|fls|egg-info|whl|js_a|js_hi|jld|ji|js_o|so.*|dump-.*|vmb|crx|orig|elmo|elmi|pyc|mod|p_hi|p_o|prof|tix)$" +consistent!(tin_drummer_0, r".*?\.(a|la|lo|o|ll|keter|bc|dyn_o|d|rlib|crate|min\.js|hi|dyn_hi|S|jsexe|webapp|js\.externs|ibc|toc|aux|fdb_latexmk|fls|egg-info|whl|js_a|js_hi|jld|ji|js_o|so.*|dump-.*|vmb|crx|orig|elmo|elmi|pyc|mod|p_hi|p_o|prof|tix)$"); + +// tin-drummer-1.0.1: r".*?\.(stats|conf|h|out|cache.*|dat|pc|info|\.js)$" +consistent!( + tin_drummer_1, + r".*?\.(stats|conf|h|out|cache.*|dat|pc|info|\.js)$" +); + +// tin-drummer-1.0.1: r".*?\.(exe|a|la|o|ll|keter|bc|dyn_o|d|rlib|crate|min\.js|hi|dyn_hi|jsexe|webapp|js\.externs|ibc|toc|aux|fdb_latexmk|fls|egg-info|whl|js_a|js_hi|jld|ji|js_o|so.*|dump-.*|vmb|crx|orig|elmo|elmi|pyc|mod|p_hi|p_o|prof|tix)$" +consistent!(tin_drummer_2, r".*?\.(exe|a|la|o|ll|keter|bc|dyn_o|d|rlib|crate|min\.js|hi|dyn_hi|jsexe|webapp|js\.externs|ibc|toc|aux|fdb_latexmk|fls|egg-info|whl|js_a|js_hi|jld|ji|js_o|so.*|dump-.*|vmb|crx|orig|elmo|elmi|pyc|mod|p_hi|p_o|prof|tix)$"); + +// tin-drummer-1.0.1: r".*?\.(stats|conf|h|out|cache.*|\.js)$" +consistent!(tin_drummer_3, r".*?\.(stats|conf|h|out|cache.*|\.js)$"); + +// tin-drummer-1.0.1: r"(\.git|\.pijul|_darcs|\.hg)$" +consistent!(tin_drummer_4, r"(\.git|\.pijul|_darcs|\.hg)$"); + +// tin-drummer-1.0.1: r".*?\.(dyn_o|out|d|hi|dyn_hi|dump-.*|p_hi|p_o|prof|tix)$" +consistent!( + tin_drummer_5, + r".*?\.(dyn_o|out|d|hi|dyn_hi|dump-.*|p_hi|p_o|prof|tix)$" +); + +// tin-drummer-1.0.1: r".*?\.(ibc)$" +consistent!(tin_drummer_6, r".*?\.(ibc)$"); + +// tin-drummer-1.0.1: r"\.stack-work|dist-newstyle" +consistent!(tin_drummer_7, r"\.stack-work|dist-newstyle"); + +// timmy-0.3.0: r"_NET_WM_PID\(CARDINAL\) = (\d+)" +consistent!(timmy_0, r"_NET_WM_PID\(CARDINAL\) = (\d+)"); + +// timmy-0.3.0: r"today|yesterday|now" +consistent!(timmy_1, r"today|yesterday|now"); + +// timmy-0.3.0: r"(?P<day>\d{1,2})/(?P<month>\d{1,2})(/(?P<year>\d{4}|\d{2}))?" +consistent!( + timmy_2, + r"(?P<day>\d{1,2})/(?P<month>\d{1,2})(/(?P<year>\d{4}|\d{2}))?" +); + +// timmy-0.3.0: r"(?P<n>\d+) (days?|ds?)(?P<ago>( ago)?)" +consistent!(timmy_3, r"(?P<n>\d+) (days?|ds?)(?P<ago>( ago)?)"); + +// timmy-0.3.0: r"(?P<hr>\d{2}):(?P<mins>\d{2})" +consistent!(timmy_4, r"(?P<hr>\d{2}):(?P<mins>\d{2})"); + +// tinfo-0.5.0: r"^(\d+): \d+ windows \(.*\) \[\d+x\d+\]( \(attached\))?" +consistent!( + tinfo_0, + r"^(\d+): \d+ windows \(.*\) \[\d+x\d+\]( \(attached\))?" +); + +// tinfo-0.5.0: r"^(\d+):(\d+): (.*) \((\d+) panes\) \[(\d+)x(\d+)\]" +consistent!(tinfo_1, r"^(\d+):(\d+): (.*) \((\d+) panes\) \[(\d+)x(\d+)\]"); + +// timespan-0.0.4: r"(?:\\\{start\\\}|\\\{end\\\})" +consistent!(timespan_0, r"(?:\\\{start\\\}|\\\{end\\\})"); + +// timespan-0.0.4: r"(.*)\s+-\s+(.*)" +consistent!(timespan_1, r"(.*)\s+-\s+(.*)"); + +// timespan-0.0.4: r"(.*)\s+(\w+)$" +consistent!(timespan_2, r"(.*)\s+(\w+)$"); + +// timespan-0.0.4: r"(.*)\s+(\w+)$" +consistent!(timespan_3, r"(.*)\s+(\w+)$"); + +// timespan-0.0.4: r"(.*)\s+-\s+(.*)" +consistent!(timespan_4, r"(.*)\s+-\s+(.*)"); + +// titlecase-0.10.0: r"[[:lower:]]" +consistent!(titlecase_0, r"[[:lower:]]"); + +// tight-0.1.3: r"^\d+ (day|week|month|year)s?$" +consistent!(tight_0, r"^\d+ (day|week|month|year)s?$"); + +// tight-0.1.3: r"^\d+ (day|week|month|year)s?$" +consistent!(tight_1, r"^\d+ (day|week|month|year)s?$"); + +// yaml-0.2.1: r"^[-+]?(0|[1-9][0-9_]*)$" +consistent!(yaml_0, r"^[-+]?(0|[1-9][0-9_]*)$"); + +// yaml-0.2.1: r"^([-+]?)0o?([0-7_]+)$" +consistent!(yaml_1, r"^([-+]?)0o?([0-7_]+)$"); + +// yaml-0.2.1: r"^([-+]?)0x([0-9a-fA-F_]+)$" +consistent!(yaml_2, r"^([-+]?)0x([0-9a-fA-F_]+)$"); + +// yaml-0.2.1: r"^([-+]?)0b([0-1_]+)$" +consistent!(yaml_3, r"^([-+]?)0b([0-1_]+)$"); + +// yaml-0.2.1: r"^([-+]?)(\.[0-9]+|[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)?)$" +consistent!( + yaml_4, + r"^([-+]?)(\.[0-9]+|[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)?)$" +); + +// yaml-0.2.1: r"^[+]?(\.inf|\.Inf|\.INF)$" +consistent!(yaml_5, r"^[+]?(\.inf|\.Inf|\.INF)$"); + +// yaml-0.2.1: r"^-(\.inf|\.Inf|\.INF)$" +consistent!(yaml_6, r"^-(\.inf|\.Inf|\.INF)$"); + +// yaml-0.2.1: r"^(\.nan|\.NaN|\.NAN)$" +consistent!(yaml_7, r"^(\.nan|\.NaN|\.NAN)$"); + +// yaml-0.2.1: r"^(null|Null|NULL|~)$" +consistent!(yaml_8, r"^(null|Null|NULL|~)$"); + +// yaml-0.2.1: r"^(true|True|TRUE|yes|Yes|YES)$" +consistent!(yaml_9, r"^(true|True|TRUE|yes|Yes|YES)$"); + +// yaml-0.2.1: r"^(false|False|FALSE|no|No|NO)$" +consistent!(yaml_10, r"^(false|False|FALSE|no|No|NO)$"); + +// kefia-0.1.0: r"(?m)^(\S+)/(\S+) (\S+)(?: \((.*)\))?$" +consistent!(kefia_0, r"(?m)^(\S+)/(\S+) (\S+)(?: \((.*)\))?$"); + +// risp-0.7.0: "^(\\s+|;.*?(\n|$))+" +consistent!(risp_0, "^(\\s+|;.*?(\n|$))+"); + +// risp-0.7.0: "^\".*?\"" +consistent!(risp_1, "^\".*?\""); + +// risp-0.7.0: r"^[^\s\{\}()\[\]]+" +consistent!(risp_2, r"^[^\s\{\}()\[\]]+"); + +// risp-0.7.0: r"^-?\d+" +consistent!(risp_3, r"^-?\d+"); + +// ripgrep-0.8.1: "^([0-9]+)([KMG])?$" +consistent!(ripgrep_0, "^([0-9]+)([KMG])?$"); + +// riquid-0.0.1: r"^\w+" +consistent!(riquid_0, r"^\w+"); + +// riquid-0.0.1: r"^\d+" +consistent!(riquid_1, r"^\d+"); + +// recursive_disassembler-2.1.2: r"\A(0x)?([a-fA-F0-9]+)\z" +consistent!(recursive_disassembler_0, r"\A(0x)?([a-fA-F0-9]+)\z"); + +// remake-0.1.0: r"^[a-zA-Z_][a-zA-Z0-9_]*" +consistent!(remake_0, r"^[a-zA-Z_][a-zA-Z0-9_]*"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)" +consistent!(regex_decode_0, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)" +consistent!(regex_decode_1, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)" +consistent!(regex_decode_2, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)" +consistent!(regex_decode_3, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)" +consistent!(regex_decode_4, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)" +consistent!(regex_decode_5, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{2})\)" +consistent!(regex_decode_6, r"'(?P<title>[^']+)'\s+\((?P<year>\d{2})\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)" +consistent!(regex_decode_7, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)" +consistent!(regex_decode_8, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})?\)" +consistent!(regex_decode_9, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})?\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})?\)" +consistent!(regex_decode_10, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})?\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})?\)" +consistent!(regex_decode_11, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})?\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})?\)" +consistent!(regex_decode_12, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})?\)"); + +// regex-decode-0.1.0: r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})?\)" +consistent!(regex_decode_13, r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})?\)"); + +// regex-cache-0.2.0: "[0-9]{3}-[0-9]{3}-[0-9]{4}" +consistent!(regex_cache_0, "[0-9]{3}-[0-9]{3}-[0-9]{4}"); + +// regex-cache-0.2.0: r"^\d+$" +consistent!(regex_cache_1, r"^\d+$"); + +// regex-cache-0.2.0: r"^[a-z]+$" +consistent!(regex_cache_2, r"^[a-z]+$"); + +// regex-cache-0.2.0: r"^\d+$" +consistent!(regex_cache_3, r"^\d+$"); + +// regex-cache-0.2.0: r"^\d+$" +consistent!(regex_cache_4, r"^\d+$"); + +// regex_dfa-0.5.0: r"\d{4}-\d{2}-\d{2}" +consistent!(regex_dfa_0, r"\d{4}-\d{2}-\d{2}"); + +// reaper-2.0.0: r"^[0-9\p{L} _\\.]{3,16}$" +consistent!(reaper_0, r"^[0-9\p{L} _\\.]{3,16}$"); + +// retdec-0.1.0: r"^attachment; filename=(.+)$" +consistent!(retdec_0, r"^attachment; filename=(.+)$"); + +// renvsubst-0.1.2: r"(\\)(?P<head>\$[0-9A-Za-z_{])" +consistent!(renvsubst_0, r"(\\)(?P<head>\$[0-9A-Za-z_{])"); + +// renvsubst-0.1.2: r"\$([[:word:]]+)" +consistent!(renvsubst_1, r"\$([[:word:]]+)"); + +// renvsubst-0.1.2: r"\$\{([[:word:]]+)\}" +consistent!(renvsubst_2, r"\$\{([[:word:]]+)\}"); + +// rexpect-0.3.0: r"'[a-z]+'" +consistent!(rexpect_0, r"'[a-z]+'"); + +// rexpect-0.3.0: r"^\d{4}-\d{2}-\d{2}$" +consistent!(rexpect_1, r"^\d{4}-\d{2}-\d{2}$"); + +// rexpect-0.3.0: r"-\d{2}-" +consistent!(rexpect_2, r"-\d{2}-"); + +// luther-0.1.0: "^a(b|c)c*$" +consistent!(luther_0, "^a(b|c)c*$"); + +// little_boxes-1.6.0: r"(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]" +consistent!(little_boxes_0, r"(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]"); + +// libimagentrytag-0.8.0: "^[a-zA-Z]([a-zA-Z0-9_-]*)$" +consistent!(libimagentrytag_0, "^[a-zA-Z]([a-zA-Z0-9_-]*)$"); + +// libimaginteraction-0.8.0: r"^[Yy](\n?)$" +consistent!(libimaginteraction_0, r"^[Yy](\n?)$"); + +// libimaginteraction-0.8.0: r"^[Nn](\n?)$" +consistent!(libimaginteraction_1, r"^[Nn](\n?)$"); + +// libimagutil-0.8.0: "^(?P<KEY>([^=]*))=(.*)$" +consistent!(libimagutil_0, "^(?P<KEY>([^=]*))=(.*)$"); + +// libimagutil-0.8.0: "(.*)=(\"(?P<QVALUE>([^\"]*))\"|(?P<VALUE>(.*)))$" +consistent!(libimagutil_1, "(.*)=(\"(?P<QVALUE>([^\"]*))\"|(?P<VALUE>(.*)))$"); + +// linux_ip-0.1.0: r"\s+" +consistent!(linux_ip_0, r"\s+"); + +// linux_ip-0.1.0: r"\s*[\n\r]+\s*" +consistent!(linux_ip_1, r"\s*[\n\r]+\s*"); + +// linux_ip-0.1.0: r"^([0-9a-fA-F\.:/]+)\s+dev\s+([a-z0-9\.]+)\s*(.*)$" +consistent!(linux_ip_2, r"^([0-9a-fA-F\.:/]+)\s+dev\s+([a-z0-9\.]+)\s*(.*)$"); + +// linux_ip-0.1.0: r"^([0-9a-fA-F\.:/]+|default)\s+via\s+([a-z0-9\.:]+)\s+dev\s+([a-z0-9\.]+)\s*(.*)$" +consistent!(linux_ip_3, r"^([0-9a-fA-F\.:/]+|default)\s+via\s+([a-z0-9\.:]+)\s+dev\s+([a-z0-9\.]+)\s*(.*)$"); + +// linux_ip-0.1.0: r"^(blackhole)\s+([0-9a-fA-F\.:/]+)$" +consistent!(linux_ip_4, r"^(blackhole)\s+([0-9a-fA-F\.:/]+)$"); + +// linux_ip-0.1.0: r"^(unreachable)\s+([0-9a-fA-F\.:/]+)\s+dev\s+([a-z0-9\.]+)\s+(.*)$" +consistent!( + linux_ip_5, + r"^(unreachable)\s+([0-9a-fA-F\.:/]+)\s+dev\s+([a-z0-9\.]+)\s+(.*)$" +); + +// linux_ip-0.1.0: r"\s*[\n\r]+\s*" +consistent!(linux_ip_6, r"\s*[\n\r]+\s*"); + +// linux_ip-0.1.0: r"^\d+:\s+([a-zA-Z0-9\.-]+)(@\S+)*:\s+(.*)$" +consistent!(linux_ip_7, r"^\d+:\s+([a-zA-Z0-9\.-]+)(@\S+)*:\s+(.*)$"); + +// linux_ip-0.1.0: r"\s*link/ether\s+([a-f0-9:]+)\s+.*" +consistent!(linux_ip_8, r"\s*link/ether\s+([a-f0-9:]+)\s+.*"); + +// linux_ip-0.1.0: r"\s*inet[6]*\s+([0-9a-f:\./]+)\s+.*" +consistent!(linux_ip_9, r"\s*inet[6]*\s+([0-9a-f:\./]+)\s+.*"); + +// linky-0.1.4: r"[^\w -]" +consistent!(linky_0, r"[^\w -]"); + +// linky-0.1.4: r"^(.*):(\d+): [^ ]* ([^ ]*)$" +consistent!(linky_1, r"^(.*):(\d+): [^ ]* ([^ ]*)$"); + +// limonite-0.2.1: r"^(\d{4}-\d{2}-\d{2})-(\d{3})-(.+)$" +consistent!(limonite_0, r"^(\d{4}-\d{2}-\d{2})-(\d{3})-(.+)$"); + +// process-queue-0.1.1: r"^[a-zA-Z]+$" +consistent!(process_queue_0, r"^[a-zA-Z]+$"); + +// pronghorn-0.1.2: r"^\{([a-zA-Z_]+)\}$" +consistent!(pronghorn_0, r"^\{([a-zA-Z_]+)\}$"); + +// protocol-ftp-client-0.1.1: "(?m:^(\\d{3}) (.+)\r$)" +consistent!(protocol_ftp_client_0, "(?m:^(\\d{3}) (.+)\r$)"); + +// protocol-ftp-client-0.1.1: "\"(.+)\"" +consistent!(protocol_ftp_client_1, "\"(.+)\""); + +// protocol-ftp-client-0.1.1: "(\\w+) [Tt]ype: (\\w+)" +consistent!(protocol_ftp_client_2, "(\\w+) [Tt]ype: (\\w+)"); + +// protocol-ftp-client-0.1.1: "(?m:^(\\d{3})-.+\r$)" +consistent!(protocol_ftp_client_3, "(?m:^(\\d{3})-.+\r$)"); + +// protocol-ftp-client-0.1.1: "Entering Passive Mode \\((\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)\\)" +consistent!( + protocol_ftp_client_4, + "Entering Passive Mode \\((\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)\\)" +); + +// protocol-ftp-client-0.1.1: "(?m:^(.+)\r$)" +consistent!(protocol_ftp_client_5, "(?m:^(.+)\r$)"); + +// protocol-ftp-client-0.1.1: "^([d-])(?:[rwx-]{3}){3} +\\d+ +\\w+ +\\w+ +(\\d+) +(.+) +(.+)$" +consistent!( + protocol_ftp_client_6, + "^([d-])(?:[rwx-]{3}){3} +\\d+ +\\w+ +\\w+ +(\\d+) +(.+) +(.+)$" +); + +// article-date-extractor-0.1.1: r"([\./\-_]{0,1}(19|20)\d{2})[\./\-_]{0,1}(([0-3]{0,1}[0-9][\./\-_])|(\w{3,5}[\./\-_]))([0-3]{0,1}[0-9][\./\-]{0,1})" +consistent!(article_date_extractor_0, r"([\./\-_]{0,1}(19|20)\d{2})[\./\-_]{0,1}(([0-3]{0,1}[0-9][\./\-_])|(\w{3,5}[\./\-_]))([0-3]{0,1}[0-9][\./\-]{0,1})"); + +// article-date-extractor-0.1.1: r"(?i)publishdate|pubdate|timestamp|article_date|articledate|date" +consistent!( + article_date_extractor_1, + r"(?i)publishdate|pubdate|timestamp|article_date|articledate|date" +); + +// arthas_plugin-0.1.1: r"type\((.*)\)" +consistent!(arthas_plugin_0, r"type\((.*)\)"); + +// arthas_plugin-0.1.1: r"Vec<(.*)>" +consistent!(arthas_plugin_1, r"Vec<(.*)>"); + +// arthas_plugin-0.1.1: r"Option<(.*)>" +consistent!(arthas_plugin_2, r"Option<(.*)>"); + +// arthas_plugin-0.1.1: r"HashMap<[a-z0-9A-Z]+, *(.*)>" +consistent!(arthas_plugin_3, r"HashMap<[a-z0-9A-Z]+, *(.*)>"); + +// arthas_derive-0.1.0: "Vec *< *(.*) *>" +consistent!(arthas_derive_0, "Vec *< *(.*) *>"); + +// arthas_derive-0.1.0: r"Option *< *(.*) *>" +consistent!(arthas_derive_1, r"Option *< *(.*) *>"); + +// arthas_derive-0.1.0: r"HashMap *< *[a-z0-9A-Z]+ *, *(.*) *>" +consistent!(arthas_derive_2, r"HashMap *< *[a-z0-9A-Z]+ *, *(.*) *>"); + +// arpabet-0.2.0: r"^([\w\-\(\)\.']+)\s+([^\s].*)\s*$" +consistent!(arpabet_0, r"^([\w\-\(\)\.']+)\s+([^\s].*)\s*$"); + +// arpabet-0.2.0: r"^;;;\s+" +consistent!(arpabet_1, r"^;;;\s+"); + +// glossy_codegen-0.2.0: r"/\*.*?\*/|//.*" +consistent!(glossy_codegen_0, r"/\*.*?\*/|//.*"); + +// glossy_codegen-0.2.0: "^\\s*#\\s*include\\s+<([:print:]+)>\\s*$" +consistent!(glossy_codegen_1, "^\\s*#\\s*include\\s+<([:print:]+)>\\s*$"); + +// glossy_codegen-0.2.0: "^\\s*#\\s*include\\s+\"([:print:]+)\"\\s*$" +consistent!(glossy_codegen_2, "^\\s*#\\s*include\\s+\"([:print:]+)\"\\s*$"); + +// glossy_codegen-0.2.0: r"^\s*#\s*version\s+(\d+)" +consistent!(glossy_codegen_3, r"^\s*#\s*version\s+(\d+)"); + +// glossy_codegen-0.2.0: r"^\s*$" +consistent!(glossy_codegen_4, r"^\s*$"); + +// gluster-1.0.1: r"(?P<addr>via \S+)" +consistent!(gluster_0, r"(?P<addr>via \S+)"); + +// gluster-1.0.1: r"(?P<src>src \S+)" +consistent!(gluster_1, r"(?P<src>src \S+)"); + +// gl_helpers-0.1.7: r"(.*)\[\d+\]" +consistent!(gl_helpers_0, r"(.*)\[\d+\]"); + +// gl_helpers-0.1.7: r"(\d+).(\d+)" +consistent!(gl_helpers_1, r"(\d+).(\d+)"); + +// glr-parser-0.0.1: r"(?P<c>[\\\.\+\*\?\(\)\|\[\]\{\}\^\$])" +consistent!(glr_parser_0, r"(?P<c>[\\\.\+\*\?\(\)\|\[\]\{\}\^\$])"); + +// glr-parser-0.0.1: r"^\w+$" +consistent!(glr_parser_1, r"^\w+$"); + +// glr-parser-0.0.1: "'[^']+'" +consistent!(glr_parser_2, "'[^']+'"); + +// hoodlum-0.5.0: r"(?m)//.*" +consistent!(hoodlum_0, r"(?m)//.*"); + +// form-checker-0.2.2: r"^1\d{10}$" +consistent!(form_checker_0, r"^1\d{10}$"); + +// form-checker-0.2.2: r"(?i)^[\w.%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$" +consistent!(form_checker_1, r"(?i)^[\w.%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$"); + +// wikibase-0.2.0: r"(?P<user_agent>[a-zA-Z0-9-_]+/[0-9\.]+)" +consistent!(wikibase_0, r"(?P<user_agent>[a-zA-Z0-9-_]+/[0-9\.]+)"); + +// wifiscanner-0.3.6: r"Cell [0-9]{2,} - Address:" +consistent!(wifiscanner_0, r"Cell [0-9]{2,} - Address:"); + +// wifiscanner-0.3.6: r"([0-9a-zA-Z]{1}[0-9a-zA-Z]{1}[:]{1}){5}[0-9a-zA-Z]{1}[0-9a-zA-Z]{1}" +consistent!( + wifiscanner_1, + r"([0-9a-zA-Z]{1}[0-9a-zA-Z]{1}[:]{1}){5}[0-9a-zA-Z]{1}[0-9a-zA-Z]{1}" +); + +// wifiscanner-0.3.6: r"Signal level=(\d+)/100" +consistent!(wifiscanner_2, r"Signal level=(\d+)/100"); + +// bbcode-1.0.2: r"(?s)\[b\](.*?)\[/b\]" +consistent!(bbcode_0, r"(?s)\[b\](.*?)\[/b\]"); + +// bbcode-1.0.2: r"(?s)\[i\](.*?)\[/i\]" +consistent!(bbcode_1, r"(?s)\[i\](.*?)\[/i\]"); + +// bbcode-1.0.2: r"(?s)\[u\](.*?)\[/u\]" +consistent!(bbcode_2, r"(?s)\[u\](.*?)\[/u\]"); + +// bbcode-1.0.2: r"(?s)\[s\](.*?)\[/s\]" +consistent!(bbcode_3, r"(?s)\[s\](.*?)\[/s\]"); + +// bbcode-1.0.2: r"(?s)\[size=(\d+)](.*?)\[/size\]" +consistent!(bbcode_4, r"(?s)\[size=(\d+)](.*?)\[/size\]"); + +// bbcode-1.0.2: r"(?s)\[color=(.+)](.*?)\[/color\]" +consistent!(bbcode_5, r"(?s)\[color=(.+)](.*?)\[/color\]"); + +// bbcode-1.0.2: r"(?s)\[center\](.*?)\[/center\]" +consistent!(bbcode_6, r"(?s)\[center\](.*?)\[/center\]"); + +// bbcode-1.0.2: r"(?s)\[left\](.*?)\[/left\]" +consistent!(bbcode_7, r"(?s)\[left\](.*?)\[/left\]"); + +// bbcode-1.0.2: r"(?s)\[right\](.*?)\[/right\]" +consistent!(bbcode_8, r"(?s)\[right\](.*?)\[/right\]"); + +// bbcode-1.0.2: r"(?s)\[table\](.*?)\[/table\]" +consistent!(bbcode_9, r"(?s)\[table\](.*?)\[/table\]"); + +// bbcode-1.0.2: r"(?s)\[td\](.*?)\[/td\]" +consistent!(bbcode_10, r"(?s)\[td\](.*?)\[/td\]"); + +// bbcode-1.0.2: r"(?s)\[tr\](.*?)\[/tr\]" +consistent!(bbcode_11, r"(?s)\[tr\](.*?)\[/tr\]"); + +// bbcode-1.0.2: r"(?s)\[th\](.*?)\[/th\]" +consistent!(bbcode_12, r"(?s)\[th\](.*?)\[/th\]"); + +// bbcode-1.0.2: r"(?s)\[url\](.*?)\[/url\]" +consistent!(bbcode_13, r"(?s)\[url\](.*?)\[/url\]"); + +// bbcode-1.0.2: r"(?s)\[url=(.+)\](.*?)\[/url\]" +consistent!(bbcode_14, r"(?s)\[url=(.+)\](.*?)\[/url\]"); + +// bbcode-1.0.2: r"(?s)\[quote\](.*?)\[/quote\]" +consistent!(bbcode_15, r"(?s)\[quote\](.*?)\[/quote\]"); + +// bbcode-1.0.2: r"(?s)\[quote=(.+)\](.*?)\[/quote\]" +consistent!(bbcode_16, r"(?s)\[quote=(.+)\](.*?)\[/quote\]"); + +// bbcode-1.0.2: r"(?s)\[img=(\d+)x(\d+)(\b.*)?\](.*?)\[/img\]" +consistent!(bbcode_17, r"(?s)\[img=(\d+)x(\d+)(\b.*)?\](.*?)\[/img\]"); + +// bbcode-1.0.2: r"(?s)\[img=(.+)(\b.*)?\](.*?)\[/img\]" +consistent!(bbcode_18, r"(?s)\[img=(.+)(\b.*)?\](.*?)\[/img\]"); + +// bbcode-1.0.2: r"(?s)\[img(\b.*)?\](.*?)\[/img\]" +consistent!(bbcode_19, r"(?s)\[img(\b.*)?\](.*?)\[/img\]"); + +// bbcode-1.0.2: r"(?s)\[ol\](.*?)\[/ol\]" +consistent!(bbcode_20, r"(?s)\[ol\](.*?)\[/ol\]"); + +// bbcode-1.0.2: r"(?s)\[ul\](.*?)\[/ul\]" +consistent!(bbcode_21, r"(?s)\[ul\](.*?)\[/ul\]"); + +// bbcode-1.0.2: r"(?s)\[list\](.*?)\[/list\]" +consistent!(bbcode_22, r"(?s)\[list\](.*?)\[/list\]"); + +// bbcode-1.0.2: r"(?s)\[youtube\](.*?)\[/youtube\]" +consistent!(bbcode_23, r"(?s)\[youtube\](.*?)\[/youtube\]"); + +// bbcode-1.0.2: r"(?s)\[youtube=(\d+)x(\d+)\](.*?)\[/youtube\]" +consistent!(bbcode_24, r"(?s)\[youtube=(\d+)x(\d+)\](.*?)\[/youtube\]"); + +// bbcode-1.0.2: r"(?s)\[li\](.*?)\[/li\]" +consistent!(bbcode_25, r"(?s)\[li\](.*?)\[/li\]"); + +// block-utils-0.5.0: r"loop\d+" +consistent!(block_utils_0, r"loop\d+"); + +// block-utils-0.5.0: r"ram\d+" +consistent!(block_utils_1, r"ram\d+"); + +// block-utils-0.5.0: r"md\d+" +consistent!(block_utils_2, r"md\d+"); + +// kvvliveapi-0.1.0: r"^([1-9]) min$" +consistent!(kvvliveapi_0, r"^([1-9]) min$"); + +// rfc822_sanitizer-0.3.3: r"(\d{2}):(\d{2}):(\d{2})" +consistent!(rfc822_sanitizer_0, r"(\d{2}):(\d{2}):(\d{2})"); + +// rfc822_sanitizer-0.3.3: r"(\d{1,2}):(\d{1,2}):(\d{1,2})" +consistent!(rfc822_sanitizer_1, r"(\d{1,2}):(\d{1,2}):(\d{1,2})"); + +// faker-0.0.4: r"[2-9]" +consistent!(faker_0, r"[2-9]"); + +// faker-0.0.4: r"[1-9]" +consistent!(faker_1, r"[1-9]"); + +// faker-0.0.4: r"[0-9]" +consistent!(faker_2, r"[0-9]"); + +// faker-0.0.4: r"\d{10}" +consistent!(faker_3, r"\d{10}"); + +// faker-0.0.4: r"\d{1}" +consistent!(faker_4, r"\d{1}"); + +// faker-0.0.4: r"^\w+" +consistent!(faker_5, r"^\w+"); + +// faker-0.0.4: r"^\w+" +consistent!(faker_6, r"^\w+"); + +// faker-0.0.4: r"^(\w+\.? ?){2,3}$" +consistent!(faker_7, r"^(\w+\.? ?){2,3}$"); + +// faker-0.0.4: r"^[A-Z][a-z]+\.?$" +consistent!(faker_8, r"^[A-Z][a-z]+\.?$"); + +// faker-0.0.4: r"^[A-Z][A-Za-z]*\.?$" +consistent!(faker_9, r"^[A-Z][A-Za-z]*\.?$"); + +// faker-0.0.4: r"http://lorempixel.com/100/100/\w+" +consistent!(faker_10, r"http://lorempixel.com/100/100/\w+"); + +// faker-0.0.4: r"http://lorempixel.com/100/100/cats" +consistent!(faker_11, r"http://lorempixel.com/100/100/cats"); + +// fancy-regex-0.1.0: "(?i:ß)" +consistent!(fancy_regex_0, "(?i:ß)"); + +// fancy-regex-0.1.0: "(?i:\\x{0587})" +consistent!(fancy_regex_1, "(?i:\\x{0587})"); + +// fancy-regex-0.1.0: "^\\\\([!-/:-@\\[-`\\{-~aftnrv]|[0-7]{1,3}|x[0-9a-fA-F]{2}|x\\{[0-9a-fA-F]{1,6}\\})" +consistent!(fancy_regex_2, "^\\\\([!-/:-@\\[-`\\{-~aftnrv]|[0-7]{1,3}|x[0-9a-fA-F]{2}|x\\{[0-9a-fA-F]{1,6}\\})"); + +// fancy-prompt-0.1.5: r"/([^/])[^/]+/" +consistent!(fancy_prompt_0, r"/([^/])[^/]+/"); + +// fancy-prompt-0.1.5: r"^([^:]+):.*?(?::([^:]+))?$" +consistent!(fancy_prompt_1, r"^([^:]+):.*?(?::([^:]+))?$"); + +// fanta-0.2.0: r"^(/?__\w+__)/(.*)" +consistent!(fanta_0, r"^(/?__\w+__)/(.*)"); + +// fanta-cli-0.1.1: r"(.)([A-Z])" +consistent!(fanta_cli_0, r"(.)([A-Z])"); + +// fanta-cli-0.1.1: "\\{:[^\\s]+\\}" +consistent!(fanta_cli_1, "\\{:[^\\s]+\\}"); + +// amethyst_tools-0.7.1: "(?P<last>[^\r])\n" +consistent!(amethyst_tools_0, "(?P<last>[^\r])\n"); + +// amigo-0.3.1: r"^-?\d+(\.\d)?" +consistent!(amigo_0, r"^-?\d+(\.\d)?"); + +// amigo-0.3.1: r"^[a-zA-Z_]+[\w-]*[!?_]?" +consistent!(amigo_1, r"^[a-zA-Z_]+[\w-]*[!?_]?"); + +// amigo-0.3.1: r"^\(" +consistent!(amigo_2, r"^\("); + +// amigo-0.3.1: r"^\)" +consistent!(amigo_3, r"^\)"); + +// amigo-0.3.1: r"^\s+" +consistent!(amigo_4, r"^\s+"); + +// ethcore-logger-1.12.0: "\x1b\\[[^m]+m" +consistent!(ethcore_logger_0, "\x1b\\[[^m]+m"); + +// dash2html-1.0.1: r"__.*?__" +consistent!(dash2html_0, r"__.*?__"); + +// dash2html-1.0.1: r"(?i)@(?:time|clipboard|cursor|date)" +consistent!(dash2html_1, r"(?i)@(?:time|clipboard|cursor|date)"); + +// os_type-2.0.0: r"^Microsoft Windows \[Version\s(\d+\.\d+\.\d+)\]$" +consistent!(os_type_0, r"^Microsoft Windows \[Version\s(\d+\.\d+\.\d+)\]$"); + +// os_type-2.0.0: r"ProductName:\s([\w\s]+)\n" +consistent!(os_type_1, r"ProductName:\s([\w\s]+)\n"); + +// os_type-2.0.0: r"ProductVersion:\s(\w+\.\w+\.\w+)" +consistent!(os_type_2, r"ProductVersion:\s(\w+\.\w+\.\w+)"); + +// os_type-2.0.0: r"BuildVersion:\s(\w+)" +consistent!(os_type_3, r"BuildVersion:\s(\w+)"); + +// os_type-2.0.0: r"(\w+) Linux release" +consistent!(os_type_4, r"(\w+) Linux release"); + +// os_type-2.0.0: r"release\s([\w\.]+)" +consistent!(os_type_5, r"release\s([\w\.]+)"); + +// os_type-2.0.0: r"Distributor ID:\s(\w+)" +consistent!(os_type_6, r"Distributor ID:\s(\w+)"); + +// os_type-2.0.0: r"Release:\s([\w\.]+)" +consistent!(os_type_7, r"Release:\s([\w\.]+)"); + +// bindgen-0.37.0: r"typename type\-parameter\-\d+\-\d+::.+" +consistent!(bindgen_0, r"typename type\-parameter\-\d+\-\d+::.+"); + +// imap-0.8.1: "^+(.*)\r\n" +consistent!(imap_0, "^+(.*)\r\n"); + +// image-base64-0.1.0: r"^ffd8ffe0" +consistent!(image_base64_0, r"^ffd8ffe0"); + +// image-base64-0.1.0: r"^89504e47" +consistent!(image_base64_1, r"^89504e47"); + +// image-base64-0.1.0: r"^47494638" +consistent!(image_base64_2, r"^47494638"); + +// json-pointer-0.3.2: "^(/([^/~]|~[01])*)*$" +consistent!(json_pointer_0, "^(/([^/~]|~[01])*)*$"); + +// json-pointer-0.3.2: "^#(/([^/~%]|~[01]|%[0-9a-fA-F]{2})*)*$" +consistent!(json_pointer_1, "^#(/([^/~%]|~[01]|%[0-9a-fA-F]{2})*)*$"); + +// mysql_common-0.7.0: r"^5.5.5-(\d{1,2})\.(\d{1,2})\.(\d{1,3})-MariaDB" +consistent!(mysql_common_0, r"^5.5.5-(\d{1,2})\.(\d{1,2})\.(\d{1,3})-MariaDB"); + +// mysql_common-0.7.0: r"^(\d{1,2})\.(\d{1,2})\.(\d{1,3})(.*)" +consistent!(mysql_common_1, r"^(\d{1,2})\.(\d{1,2})\.(\d{1,3})(.*)"); + +// government_id-0.1.0: r"^[0-9]{4}[0-9A-Z]{2}[0-9]{3}$" +consistent!(government_id_0, r"^[0-9]{4}[0-9A-Z]{2}[0-9]{3}$"); + +// ohmers-0.1.1: r"UniqueIndexViolation: (\w+)" +consistent!(ohmers_0, r"UniqueIndexViolation: (\w+)"); + +// eliza-1.0.0: r"(.*) you are (.*)" +consistent!(eliza_0, r"(.*) you are (.*)"); + +// eliza-1.0.0: r"(.*) you are (.*)" +consistent!(eliza_1, r"(.*) you are (.*)"); + +// eliza-1.0.0: r"(.*) you are (.*)" +consistent!(eliza_2, r"(.*) you are (.*)"); + +// chema-0.0.5: "^\\s*\\*" +consistent!(chema_0, "^\\s*\\*"); + +// chema-0.0.5: "^\\s*@(\\w+)\\s+(.*)" +consistent!(chema_1, "^\\s*@(\\w+)\\s+(.*)"); + +// chord3-0.3.0: r"^\s*#" +consistent!(chord3_0, r"^\s*#"); + +// chord3-0.3.0: r"\{(?P<cmd>\w+)(?::?\s*(?P<arg>.*))?\}" +consistent!(chord3_1, r"\{(?P<cmd>\w+)(?::?\s*(?P<arg>.*))?\}"); + +// chord3-0.3.0: r"\{(eot|end_of_tab):?\s*" +consistent!(chord3_2, r"\{(eot|end_of_tab):?\s*"); + +// chord3-0.3.0: r"([^\[]*)(?:\[([^\]]*)\])?" +consistent!(chord3_3, r"([^\[]*)(?:\[([^\]]*)\])?"); + +// checkmail-0.1.1: "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$" +consistent!(checkmail_0, "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"); + +// cntk-0.2.1: r"\b\w\w+\b" +consistent!(cntk_0, r"\b\w\w+\b"); + +// cntk-0.2.1: r"\b\w\w+\b" +consistent!(cntk_1, r"\b\w\w+\b"); + +// cniguru-0.1.0: r"\(id: (\d+)\)" +consistent!(cniguru_0, r"\(id: (\d+)\)"); + +// upm_lib-0.3.0: r"^(\d+)\.(\d+)\.(\d+)(?:-([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$" +consistent!(upm_lib_0, r"^(\d+)\.(\d+)\.(\d+)(?:-([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$"); + +// avro-0.2.1: r"^\s*(\*+(\s+))?" +consistent!(avro_0, r"^\s*(\*+(\s+))?"); + +// avro-0.2.1: r"^\s*(\*+)?" +consistent!(avro_1, r"^\s*(\*+)?"); + +// nomi-0.0.2: "[0-9]+" +consistent!(nomi_0, "[0-9]+"); + +// nodes-0.1.0: "([0-9]+)@(?:nodes|n)?:([^@]+)?" +consistent!(nodes_0, "([0-9]+)@(?:nodes|n)?:([^@]+)?"); + +// not-stakkr-1.0.0: r"(?i)in (\d+) (second|minute|hour|day|week)s?" +consistent!(not_stakkr_0, r"(?i)in (\d+) (second|minute|hour|day|week)s?"); + +// notetxt-0.0.1: "^([A-Za-z0-9 -_:]+)\n-+\n" +consistent!(notetxt_0, "^([A-Za-z0-9 -_:]+)\n-+\n"); + +// nail-0.1.0-pre.0: r"^-?[0-9]+(\.[0-9]+)?([eE]-?[0-9]+)?$" +consistent!(nail_0, r"^-?[0-9]+(\.[0-9]+)?([eE]-?[0-9]+)?$"); + +// nail-0.1.0-pre.0: r"^-?[0-9]+$" +consistent!(nail_1, r"^-?[0-9]+$"); + +// askalono-0.2.0: r"[^\w\s\pP]+" +consistent!(askalono_0, r"[^\w\s\pP]+"); + +// askalono-0.2.0: r"(?x)[ \t\p{Zs} \\ / \| \x2044 ]+" +consistent!(askalono_1, r"(?x)[ \t\p{Zs} \\ / \| \x2044 ]+"); + +// askalono-0.2.0: r"\p{Pd}+" +consistent!(askalono_2, r"\p{Pd}+"); + +// askalono-0.2.0: r"\p{Ps}+" +consistent!(askalono_3, r"\p{Ps}+"); + +// askalono-0.2.0: r"\p{Pe}+" +consistent!(askalono_4, r"\p{Pe}+"); + +// askalono-0.2.0: r"\p{Pc}+" +consistent!(askalono_5, r"\p{Pc}+"); + +// askalono-0.2.0: r"[©Ⓒⓒ]" +consistent!(askalono_6, r"[©Ⓒⓒ]"); + +// askalono-0.2.0: r"[\r\n\v\f]" +consistent!(askalono_7, r"[\r\n\v\f]"); + +// askalono-0.2.0: r"\n{3,}" +consistent!(askalono_8, r"\n{3,}"); + +// askalono-0.2.0: r"[^\w\s]+" +consistent!(askalono_9, r"[^\w\s]+"); + +// askalono-0.2.0: r"\s+" +consistent!(askalono_10, r"\s+"); + +// assembunny_plus-0.0.3: r"[^0-9a-zA-Z_]" +consistent!(assembunny_plus_0, r"[^0-9a-zA-Z_]"); + +// assembunny_plus-0.0.3: r"[0-9]" +consistent!(assembunny_plus_1, r"[0-9]"); + +// salt-compressor-0.4.0: r"(?m)^Minion (\S*) did not respond\. No job will be sent\.$" +consistent!( + salt_compressor_0, + r"(?m)^Minion (\S*) did not respond\. No job will be sent\.$" +); + +// sabisabi-0.4.1: r"</?[^>]+?>" +consistent!(sabisabi_0, r"</?[^>]+?>"); + +// sabisabi-0.4.1: r"\([^)]*\)" +consistent!(sabisabi_1, r"\([^)]*\)"); + +// sassers-0.13.5-h28: "@import \"([^\"]*)\";" +consistent!(sassers_0, "@import \"([^\"]*)\";"); + +// shadowsocks-0.6.2: r"[A-Za-z\d-]{1,63}$" +consistent!(shadowsocks_0, r"[A-Za-z\d-]{1,63}$"); + +// shkeleton-0.1.5: "[abc]+" +consistent!(shkeleton_0, "[abc]+"); + +// shellwords-0.1.0: r"([^A-Za-z0-9_\-.,:/@\n])" +consistent!(shellwords_0, r"([^A-Za-z0-9_\-.,:/@\n])"); + +// shellwords-0.1.0: r"\n" +consistent!(shellwords_1, r"\n"); + +// shush-0.1.5: "(?P<num>[0-9]+)(?P<units>[dhms])" +consistent!(shush_0, "(?P<num>[0-9]+)(?P<units>[dhms])"); + +// woothee-0.8.0: r"(?:Chrome|CrMo|CriOS)/([.0-9]+)" +consistent!(woothee_0, r"(?:Chrome|CrMo|CriOS)/([.0-9]+)"); + +// woothee-0.8.0: r"Vivaldi/([.0-9]+)" +consistent!(woothee_1, r"Vivaldi/([.0-9]+)"); + +// woothee-0.8.0: r"Firefox/([.0-9]+)" +consistent!(woothee_2, r"Firefox/([.0-9]+)"); + +// woothee-0.8.0: r"^Mozilla/[.0-9]+ \((?:Mobile|Tablet);(?:.*;)? rv:([.0-9]+)\) Gecko/[.0-9]+ Firefox/[.0-9]+$" +consistent!(woothee_3, r"^Mozilla/[.0-9]+ \((?:Mobile|Tablet);(?:.*;)? rv:([.0-9]+)\) Gecko/[.0-9]+ Firefox/[.0-9]+$"); + +// woothee-0.8.0: r"FxiOS/([.0-9]+)" +consistent!(woothee_4, r"FxiOS/([.0-9]+)"); + +// woothee-0.8.0: r"\(([^;)]+);FOMA;" +consistent!(woothee_5, r"\(([^;)]+);FOMA;"); + +// woothee-0.8.0: r"jig browser[^;]+; ([^);]+)" +consistent!(woothee_6, r"jig browser[^;]+; ([^);]+)"); + +// woothee-0.8.0: r"(?i)rss(?:reader|bar|[-_ /;()]|[ +]*/)" +consistent!(woothee_7, r"(?i)rss(?:reader|bar|[-_ /;()]|[ +]*/)"); + +// woothee-0.8.0: r"(?i)(?:bot|crawler|spider)(?:[-_ ./;@()]|$)" +consistent!(woothee_8, r"(?i)(?:bot|crawler|spider)(?:[-_ ./;@()]|$)"); + +// woothee-0.8.0: r"(?i)(?:feed|web) ?parser" +consistent!(woothee_9, r"(?i)(?:feed|web) ?parser"); + +// woothee-0.8.0: r"(?i)watch ?dog" +consistent!(woothee_10, r"(?i)watch ?dog"); + +// woothee-0.8.0: r"Edge/([.0-9]+)" +consistent!(woothee_11, r"Edge/([.0-9]+)"); + +// woothee-0.8.0: r"MSIE ([.0-9]+);" +consistent!(woothee_12, r"MSIE ([.0-9]+);"); + +// woothee-0.8.0: r"Version/([.0-9]+)" +consistent!(woothee_13, r"Version/([.0-9]+)"); + +// woothee-0.8.0: r"Opera[/ ]([.0-9]+)" +consistent!(woothee_14, r"Opera[/ ]([.0-9]+)"); + +// woothee-0.8.0: r"OPR/([.0-9]+)" +consistent!(woothee_15, r"OPR/([.0-9]+)"); + +// woothee-0.8.0: r"Version/([.0-9]+)" +consistent!(woothee_16, r"Version/([.0-9]+)"); + +// woothee-0.8.0: r"(?:SoftBank|Vodafone|J-PHONE)/[.0-9]+/([^ /;()]+)" +consistent!(woothee_17, r"(?:SoftBank|Vodafone|J-PHONE)/[.0-9]+/([^ /;()]+)"); + +// woothee-0.8.0: r"Trident/([.0-9]+);" +consistent!(woothee_18, r"Trident/([.0-9]+);"); + +// woothee-0.8.0: r" rv:([.0-9]+)" +consistent!(woothee_19, r" rv:([.0-9]+)"); + +// woothee-0.8.0: r"IEMobile/([.0-9]+);" +consistent!(woothee_20, r"IEMobile/([.0-9]+);"); + +// woothee-0.8.0: r"(?:WILLCOM|DDIPOCKET);[^/]+/([^ /;()]+)" +consistent!(woothee_21, r"(?:WILLCOM|DDIPOCKET);[^/]+/([^ /;()]+)"); + +// woothee-0.8.0: r"Windows ([ .a-zA-Z0-9]+)[;\\)]" +consistent!(woothee_22, r"Windows ([ .a-zA-Z0-9]+)[;\\)]"); + +// woothee-0.8.0: r"^Phone(?: OS)? ([.0-9]+)" +consistent!(woothee_23, r"^Phone(?: OS)? ([.0-9]+)"); + +// woothee-0.8.0: r"iP(hone;|ad;|od) .*like Mac OS X" +consistent!(woothee_24, r"iP(hone;|ad;|od) .*like Mac OS X"); + +// woothee-0.8.0: r"Version/([.0-9]+)" +consistent!(woothee_25, r"Version/([.0-9]+)"); + +// woothee-0.8.0: r"rv:(\d+\.\d+\.\d+)" +consistent!(woothee_26, r"rv:(\d+\.\d+\.\d+)"); + +// woothee-0.8.0: r"FreeBSD ([^;\)]+);" +consistent!(woothee_27, r"FreeBSD ([^;\)]+);"); + +// woothee-0.8.0: r"CrOS ([^\)]+)\)" +consistent!(woothee_28, r"CrOS ([^\)]+)\)"); + +// woothee-0.8.0: r"Android[- ](\d+\.\d+(?:\.\d+)?)" +consistent!(woothee_29, r"Android[- ](\d+\.\d+(?:\.\d+)?)"); + +// woothee-0.8.0: r"PSP \(PlayStation Portable\); ([.0-9]+)\)" +consistent!(woothee_30, r"PSP \(PlayStation Portable\); ([.0-9]+)\)"); + +// woothee-0.8.0: r"PLAYSTATION 3;? ([.0-9]+)\)" +consistent!(woothee_31, r"PLAYSTATION 3;? ([.0-9]+)\)"); + +// woothee-0.8.0: r"PlayStation Vita ([.0-9]+)\)" +consistent!(woothee_32, r"PlayStation Vita ([.0-9]+)\)"); + +// woothee-0.8.0: r"PlayStation 4 ([.0-9]+)\)" +consistent!(woothee_33, r"PlayStation 4 ([.0-9]+)\)"); + +// woothee-0.8.0: r"BB10(?:.+)Version/([.0-9]+) " +consistent!(woothee_34, r"BB10(?:.+)Version/([.0-9]+) "); + +// woothee-0.8.0: r"BlackBerry(?:\d+)/([.0-9]+) " +consistent!(woothee_35, r"BlackBerry(?:\d+)/([.0-9]+) "); + +// woothee-0.8.0: r"; CPU(?: iPhone)? OS (\d+_\d+(?:_\d+)?) like Mac OS X" +consistent!( + woothee_36, + r"; CPU(?: iPhone)? OS (\d+_\d+(?:_\d+)?) like Mac OS X" +); + +// woothee-0.8.0: r"Mac OS X (10[._]\d+(?:[._]\d+)?)(?:\)|;)" +consistent!(woothee_37, r"Mac OS X (10[._]\d+(?:[._]\d+)?)(?:\)|;)"); + +// woothee-0.8.0: r"^(?:Apache-HttpClient/|Jakarta Commons-HttpClient/|Java/)" +consistent!( + woothee_38, + r"^(?:Apache-HttpClient/|Jakarta Commons-HttpClient/|Java/)" +); + +// woothee-0.8.0: r"[- ]HttpClient(/|$)" +consistent!(woothee_39, r"[- ]HttpClient(/|$)"); + +// woothee-0.8.0: r"^(?:PHP|WordPress|CakePHP|PukiWiki|PECL::HTTP)(?:/| |$)" +consistent!( + woothee_40, + r"^(?:PHP|WordPress|CakePHP|PukiWiki|PECL::HTTP)(?:/| |$)" +); + +// woothee-0.8.0: r"(?:PEAR HTTP_Request|HTTP_Request)(?: class|2)" +consistent!(woothee_41, r"(?:PEAR HTTP_Request|HTTP_Request)(?: class|2)"); + +// woothee-0.8.0: r"(?:Rome Client |UnwindFetchor/|ia_archiver |Summify |PostRank/)" +consistent!( + woothee_42, + r"(?:Rome Client |UnwindFetchor/|ia_archiver |Summify |PostRank/)" +); + +// woothee-0.8.0: r"Sleipnir/([.0-9]+)" +consistent!(woothee_43, r"Sleipnir/([.0-9]+)"); + +// word_replace-0.0.3: r"@@[a-z|A-Z|\d]+@@" +consistent!(word_replace_0, r"@@[a-z|A-Z|\d]+@@"); + +// wordcount-0.1.0: r"\w+" +consistent!(wordcount_0, r"\w+"); + +// just-0.3.12: "^([^=]+)=(.*)$" +consistent!(just_0, "^([^=]+)=(.*)$"); + +// emote-0.1.0: r":[a-zA-Z_]+?:" +consistent!(emote_0, r":[a-zA-Z_]+?:"); + +// emojicons-1.0.1: r":([a-zA-Z0-9_+-]+):" +consistent!(emojicons_0, r":([a-zA-Z0-9_+-]+):"); + +// git2_codecommit-0.1.2: r"git-codecommit\.([a-z0-9-]+)\.amazonaws\.com" +consistent!( + git2_codecommit_0, + r"git-codecommit\.([a-z0-9-]+)\.amazonaws\.com" +); + +// git-workarea-3.1.2: r"^submodule\.(?P<name>.*)\.(?P<key>[^=]*)=(?P<value>.*)$" +consistent!( + git_workarea_0, + r"^submodule\.(?P<name>.*)\.(?P<key>[^=]*)=(?P<value>.*)$" +); + +// git-shell-enforce-directory-1.0.0: r"^(?P<command>git-(?:receive|upload)-pack) '(?P<path>.+)'$" +consistent!( + git_shell_enforce_directory_0, + r"^(?P<command>git-(?:receive|upload)-pack) '(?P<path>.+)'$" +); + +// git-journal-1.6.3: r"[ \n]:(.*?):" +consistent!(git_journal_0, r"[ \n]:(.*?):"); + +// git-find-0.3.2: r"^git@(?P<host>[[:alnum:]\._-]+):(?P<path>[[:alnum:]\._\-/]+).git$" +consistent!( + git_find_0, + r"^git@(?P<host>[[:alnum:]\._-]+):(?P<path>[[:alnum:]\._\-/]+).git$" +); + +// gitlab-api-0.6.0: r"private_token=\w{20}" +consistent!(gitlab_api_0, r"private_token=\w{20}"); + +// td-client-0.7.0: "^(http://|https://)" +consistent!(td_client_0, "^(http://|https://)"); + +// karaconv-0.3.0: r"--(?P<type>[a-zA-Z]+)-- (?P<contents>.*)" +consistent!(karaconv_0, r"--(?P<type>[a-zA-Z]+)-- (?P<contents>.*)"); + +// katana-1.0.2: r"(?P<comp>et al\.)(?:\.)" +consistent!(katana_0, r"(?P<comp>et al\.)(?:\.)"); + +// katana-1.0.2: r"\.{3}" +consistent!(katana_1, r"\.{3}"); + +// katana-1.0.2: r"(?P<number>[0-9]+)\.(?P<decimal>[0-9]+)" +consistent!(katana_2, r"(?P<number>[0-9]+)\.(?P<decimal>[0-9]+)"); + +// katana-1.0.2: r"\s\.(?P<nums>[0-9]+)" +consistent!(katana_3, r"\s\.(?P<nums>[0-9]+)"); + +// katana-1.0.2: r"(?:[A-Za-z]\.){2,}" +consistent!(katana_4, r"(?:[A-Za-z]\.){2,}"); + +// katana-1.0.2: r"(?P<init>[A-Z])(?P<point>\.)" +consistent!(katana_5, r"(?P<init>[A-Z])(?P<point>\.)"); + +// katana-1.0.2: r"(?P<title>[A-Z][a-z]{1,3})(\.)" +consistent!(katana_6, r"(?P<title>[A-Z][a-z]{1,3})(\.)"); + +// katana-1.0.2: r"&==&(?P<p>[.!?])" +consistent!(katana_7, r"&==&(?P<p>[.!?])"); + +// katana-1.0.2: r"&\^&(?P<p>[.!?])" +consistent!(katana_8, r"&\^&(?P<p>[.!?])"); + +// katana-1.0.2: r"&\*\*&(?P<p>[.!?])" +consistent!(katana_9, r"&\*\*&(?P<p>[.!?])"); + +// katana-1.0.2: r"&=&(?P<p>[.!?])" +consistent!(katana_10, r"&=&(?P<p>[.!?])"); + +// katana-1.0.2: r"&##&(?P<p>[.!?])" +consistent!(katana_11, r"&##&(?P<p>[.!?])"); + +// katana-1.0.2: r"&\$&(?P<p>[.!?])" +consistent!(katana_12, r"&\$&(?P<p>[.!?])"); + +// kailua_syntax-1.1.0: r"@(?:_|\d+(?:/\d+(?:-\d+)?)?)" +consistent!(kailua_syntax_0, r"@(?:_|\d+(?:/\d+(?:-\d+)?)?)"); + +// kailua_syntax-1.1.0: r"<(\d+)>" +consistent!(kailua_syntax_1, r"<(\d+)>"); + +// ftp-3.0.1: r"\((\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\)" +consistent!(ftp_0, r"\((\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\)"); + +// ftp-3.0.1: r"\b(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\b" +consistent!(ftp_1, r"\b(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\b"); + +// ftp-3.0.1: r"\s+(\d+)\s*$" +consistent!(ftp_2, r"\s+(\d+)\s*$"); + +// vat-0.1.0: r"<countryCode>(.*?)</countryCode>" +consistent!(vat_0, r"<countryCode>(.*?)</countryCode>"); + +// vat-0.1.0: r"<vatNumber>(.*?)</vatNumber>" +consistent!(vat_1, r"<vatNumber>(.*?)</vatNumber>"); + +// vat-0.1.0: r"<name>(.*?)</name>" +consistent!(vat_2, r"<name>(.*?)</name>"); + +// vat-0.1.0: r"<address>(?s)(.*?)(?-s)</address>" +consistent!(vat_3, r"<address>(?s)(.*?)(?-s)</address>"); + +// vat-0.1.0: r"<valid>(true|false)</valid>" +consistent!(vat_4, r"<valid>(true|false)</valid>"); + +// vat-0.1.0: r"^ATU\d{8}$" +consistent!(vat_5, r"^ATU\d{8}$"); + +// vat-0.1.0: r"^BE0?\d{9, 10}$" +consistent!(vat_6, r"^BE0?\d{9, 10}$"); + +// vat-0.1.0: r"^BG\d{9,10}$" +consistent!(vat_7, r"^BG\d{9,10}$"); + +// vat-0.1.0: r"^HR\d{11}$" +consistent!(vat_8, r"^HR\d{11}$"); + +// vat-0.1.0: r"^CY\d{8}[A-Z]$" +consistent!(vat_9, r"^CY\d{8}[A-Z]$"); + +// vat-0.1.0: r"^CZ\d{8,10}$" +consistent!(vat_10, r"^CZ\d{8,10}$"); + +// vat-0.1.0: r"^DK\d{8}$" +consistent!(vat_11, r"^DK\d{8}$"); + +// vat-0.1.0: r"^EE\d{9}$" +consistent!(vat_12, r"^EE\d{9}$"); + +// vat-0.1.0: r"^FI\d{8}$" +consistent!(vat_13, r"^FI\d{8}$"); + +// vat-0.1.0: r"^FR[A-HJ-NP-Z0-9][A-HJ-NP-Z0-9]\d{9}$" +consistent!(vat_14, r"^FR[A-HJ-NP-Z0-9][A-HJ-NP-Z0-9]\d{9}$"); + +// vat-0.1.0: r"^DE\d{9}$" +consistent!(vat_15, r"^DE\d{9}$"); + +// vat-0.1.0: r"^EL\d{9}$" +consistent!(vat_16, r"^EL\d{9}$"); + +// vat-0.1.0: r"^HU\d{8}$" +consistent!(vat_17, r"^HU\d{8}$"); + +// vat-0.1.0: r"^IE\d[A-Z0-9\+\*]\d{5}[A-Z]{1,2}$" +consistent!(vat_18, r"^IE\d[A-Z0-9\+\*]\d{5}[A-Z]{1,2}$"); + +// vat-0.1.0: r"^IT\d{11}$" +consistent!(vat_19, r"^IT\d{11}$"); + +// vat-0.1.0: r"^LV\d{11}$" +consistent!(vat_20, r"^LV\d{11}$"); + +// vat-0.1.0: r"^LT(\d{9}|\d{12})$" +consistent!(vat_21, r"^LT(\d{9}|\d{12})$"); + +// vat-0.1.0: r"^LU\d{8}$" +consistent!(vat_22, r"^LU\d{8}$"); + +// vat-0.1.0: r"^MT\d{8}$" +consistent!(vat_23, r"^MT\d{8}$"); + +// vat-0.1.0: r"^NL\d{9}B\d{2}$" +consistent!(vat_24, r"^NL\d{9}B\d{2}$"); + +// vat-0.1.0: r"^PL\d{10}$" +consistent!(vat_25, r"^PL\d{10}$"); + +// vat-0.1.0: r"^PT\d{9}$" +consistent!(vat_26, r"^PT\d{9}$"); + +// vat-0.1.0: r"^RO\d{2,10}$" +consistent!(vat_27, r"^RO\d{2,10}$"); + +// vat-0.1.0: r"^SK\d{10}$" +consistent!(vat_28, r"^SK\d{10}$"); + +// vat-0.1.0: r"^SI\d{8}$" +consistent!(vat_29, r"^SI\d{8}$"); + +// vat-0.1.0: r"^ES[A-Z0-9]\d{7}[A-Z0-9]$" +consistent!(vat_30, r"^ES[A-Z0-9]\d{7}[A-Z0-9]$"); + +// vat-0.1.0: r"^SE\d{10}01$" +consistent!(vat_31, r"^SE\d{10}01$"); + +// vat-0.1.0: r"^(GB(GD|HA)\d{3}|GB\d{9}|GB\d{12})$" +consistent!(vat_32, r"^(GB(GD|HA)\d{3}|GB\d{9}|GB\d{12})$"); + +// eve-0.1.1: r"\{\{(.*)\}\}" +consistent!(eve_0, r"\{\{(.*)\}\}"); + +// egc-0.1.2: "^mio" +consistent!(egc_0, "^mio"); + +// pew-0.2.3: "" +consistent!(pew_0, ""); + +// pew-0.2.3: "" +consistent!(pew_1, ""); + +// mob-0.4.3: "y" +consistent!(mob_0, "y"); + +// lit-0.2.8: "@([a-z]+)" +consistent!(lit_0, "@([a-z]+)"); + +// lit-0.2.8: "([A-Z-]+):(.*)" +consistent!(lit_1, "([A-Z-]+):(.*)"); + +// lit-0.2.8: "^[a-zA-Z_][a-zA-Z0-9_]*$" +consistent!(lit_2, "^[a-zA-Z_][a-zA-Z0-9_]*$"); + +// avm-1.0.1: r"\d+\.\d+\.\d+" +consistent!(avm_0, r"\d+\.\d+\.\d+"); + +// avm-1.0.1: r"\d+\.\d+\.\d+" +consistent!(avm_1, r"\d+\.\d+\.\d+"); + +// orm-0.2.0: r"^Vec<(.+)>$" +consistent!(orm_0, r"^Vec<(.+)>$"); + +// sgf-0.1.5: r"\\(\r\n|\n\r|\n|\r)" +consistent!(sgf_0, r"\\(\r\n|\n\r|\n|\r)"); + +// sgf-0.1.5: r"\\(.)" +consistent!(sgf_1, r"\\(.)"); + +// sgf-0.1.5: r"\r\n|\n\r|\n|\r" +consistent!(sgf_2, r"\r\n|\n\r|\n|\r"); + +// sgf-0.1.5: r"([\]\\:])" +consistent!(sgf_3, r"([\]\\:])"); + +// dok-0.2.0: "^Bearer realm=\"(.+?)\",service=\"(.+?)\",scope=\"(.+?)\"$" +consistent!( + dok_0, + "^Bearer realm=\"(.+?)\",service=\"(.+?)\",scope=\"(.+?)\"$" +); + +// d20-0.1.0: r"([+-]?\s*\d+[dD]\d+|[+-]?\s*\d+)" +consistent!(d20_0, r"([+-]?\s*\d+[dD]\d+|[+-]?\s*\d+)"); + +// dvb-0.3.0: "E" +consistent!(dvb_0, "E"); + +// dvb-0.3.0: "^F" +consistent!(dvb_1, "^F"); + +// dvb-0.3.0: "^S" +consistent!(dvb_2, "^S"); + +// ger-0.2.0: r"Change-Id: (I[a-f0-9]{40})$" +consistent!(ger_0, r"Change-Id: (I[a-f0-9]{40})$"); + +// ger-0.2.0: r"(refs|ref|fix|fixes|close|closes)\s+([A-Z]{2,5}-[0-9]{1,5})$" +consistent!( + ger_1, + r"(refs|ref|fix|fixes|close|closes)\s+([A-Z]{2,5}-[0-9]{1,5})$" +); + +// n5-0.2.1: r"(\d+)(\.(\d+))?(\.(\d+))?(.*)" +consistent!(n5_0, r"(\d+)(\.(\d+))?(\.(\d+))?(.*)"); + +// po-0.1.4: r"[A-Za-z0-9]" +consistent!(po_0, r"[A-Za-z0-9]"); + +// carnix-0.8.5: "path is (‘|')?([^’'\n]*)(’|')?" +consistent!(carnix_0, "path is (‘|')?([^’'\n]*)(’|')?"); + +// carnix-0.8.5: r"^(\S*) (\d*)\.(\d*)\.(\d*)(-(\S*))?(.*)?" +consistent!(carnix_1, r"^(\S*) (\d*)\.(\d*)\.(\d*)(-(\S*))?(.*)?"); + +// carnix-0.8.5: r"(\d*)\.(\d*)\.(\d*)(-(\S*))?" +consistent!(carnix_2, r"(\d*)\.(\d*)\.(\d*)(-(\S*))?"); + +// carnix-0.8.5: r"(\S*)-(\d*)\.(\d*)\.(\d*)(-(\S*))?" +consistent!(carnix_3, r"(\S*)-(\d*)\.(\d*)\.(\d*)(-(\S*))?"); + +// caseless-0.2.1: r"^# CaseFolding-(\d+)\.(\d+)\.(\d+).txt$" +consistent!(caseless_0, r"^# CaseFolding-(\d+)\.(\d+)\.(\d+).txt$"); + +// caseless-0.2.1: r"^([0-9A-F]+); [CF]; ([0-9A-F ]+);" +consistent!(caseless_1, r"^([0-9A-F]+); [CF]; ([0-9A-F ]+);"); + +// cabot-0.2.0: "\r?\n\r?\n" +consistent!(cabot_0, "\r?\n\r?\n"); + +// cabot-0.2.0: "\r?\n" +consistent!(cabot_1, "\r?\n"); + +// card-validate-2.2.1: r"^600" +consistent!(card_validate_0, r"^600"); + +// card-validate-2.2.1: r"^5019" +consistent!(card_validate_1, r"^5019"); + +// card-validate-2.2.1: r"^4" +consistent!(card_validate_2, r"^4"); + +// card-validate-2.2.1: r"^(5[1-5]|2[2-7])" +consistent!(card_validate_3, r"^(5[1-5]|2[2-7])"); + +// card-validate-2.2.1: r"^3[47]" +consistent!(card_validate_4, r"^3[47]"); + +// card-validate-2.2.1: r"^3[0689]" +consistent!(card_validate_5, r"^3[0689]"); + +// card-validate-2.2.1: r"^6([045]|22)" +consistent!(card_validate_6, r"^6([045]|22)"); + +// card-validate-2.2.1: r"^(62|88)" +consistent!(card_validate_7, r"^(62|88)"); + +// card-validate-2.2.1: r"^35" +consistent!(card_validate_8, r"^35"); + +// card-validate-2.2.1: r"^[0-9]+$" +consistent!(card_validate_9, r"^[0-9]+$"); + +// cargo-testify-0.3.0: r"\d{1,} passed.*filtered out" +consistent!(cargo_testify_0, r"\d{1,} passed.*filtered out"); + +// cargo-testify-0.3.0: r"error(:|\[).*" +consistent!(cargo_testify_1, r"error(:|\[).*"); + +// cargo-wix-0.0.5: r"<(.*?)>" +consistent!(cargo_wix_0, r"<(.*?)>"); + +// cargo-wix-0.0.5: r"<(.*?)>" +consistent!(cargo_wix_1, r"<(.*?)>"); + +// cargo-wix-0.0.5: r"<(.*?)>" +consistent!(cargo_wix_2, r"<(.*?)>"); + +// cargo-wix-0.0.5: r"<(.*?)>" +consistent!(cargo_wix_3, r"<(.*?)>"); + +// cargo-incremental-0.1.23: r"(?m)^incremental: re-using (\d+) out of (\d+) modules$" +consistent!( + cargo_incremental_0, + r"(?m)^incremental: re-using (\d+) out of (\d+) modules$" +); + +// cargo-incremental-0.1.23: "(?m)(warning|error): (.*)\n --> ([^:]:\\d+:\\d+)$" +consistent!( + cargo_incremental_1, + "(?m)(warning|error): (.*)\n --> ([^:]:\\d+:\\d+)$" +); + +// cargo-incremental-0.1.23: r"(?m)^test (.*) \.\.\. (\w+)" +consistent!(cargo_incremental_2, r"(?m)^test (.*) \.\.\. (\w+)"); + +// cargo-incremental-0.1.23: r"(?m)(\d+) passed; (\d+) failed; (\d+) ignored; \d+ measured" +consistent!( + cargo_incremental_3, + r"(?m)(\d+) passed; (\d+) failed; (\d+) ignored; \d+ measured" +); + +// cargo-testjs-0.1.2: r"^[^-]+-[0-9a-f]+\.js$" +consistent!(cargo_testjs_0, r"^[^-]+-[0-9a-f]+\.js$"); + +// cargo-tarpaulin-0.6.2: r"\s*//" +consistent!(cargo_tarpaulin_0, r"\s*//"); + +// cargo-tarpaulin-0.6.2: r"/\*" +consistent!(cargo_tarpaulin_1, r"/\*"); + +// cargo-tarpaulin-0.6.2: r"\*/" +consistent!(cargo_tarpaulin_2, r"\*/"); + +// cargo-culture-kit-0.1.0: r"^fo" +consistent!(cargo_culture_kit_0, r"^fo"); + +// cargo-screeps-0.1.3: "\\s+" +consistent!(cargo_screeps_0, "\\s+"); + +// cargo-brew-0.1.4: r"`(\S+) v([0-9.]+)" +consistent!(cargo_brew_0, r"`(\S+) v([0-9.]+)"); + +// cargo-release-0.10.2: "^\\[.+\\]" +consistent!(cargo_release_0, "^\\[.+\\]"); + +// cargo-release-0.10.2: "^\\[\\[.+\\]\\]" +consistent!(cargo_release_1, "^\\[\\[.+\\]\\]"); + +// cargo-edit-0.3.0-beta.1: r"^https://github.com/([-_0-9a-zA-Z]+)/([-_0-9a-zA-Z]+)(/|.git)?$" +consistent!( + cargo_edit_0, + r"^https://github.com/([-_0-9a-zA-Z]+)/([-_0-9a-zA-Z]+)(/|.git)?$" +); + +// cargo-edit-0.3.0-beta.1: r"^https://gitlab.com/([-_0-9a-zA-Z]+)/([-_0-9a-zA-Z]+)(/|.git)?$" +consistent!( + cargo_edit_1, + r"^https://gitlab.com/([-_0-9a-zA-Z]+)/([-_0-9a-zA-Z]+)(/|.git)?$" +); + +// cargo-disassemble-0.1.1: ".*" +consistent!(cargo_disassemble_0, ".*"); + +// cargo-demangle-0.1.2: r"(?m)(?P<symbol>_ZN[0-9]+.*E)" +consistent!(cargo_demangle_0, r"(?m)(?P<symbol>_ZN[0-9]+.*E)"); + +// cargo-coverage-annotations-0.1.5: r"^\s*\}(?:\)*;?|\s*else\s*\{)$" +consistent!(cargo_coverage_annotations_0, r"^\s*\}(?:\)*;?|\s*else\s*\{)$"); + +// cargo-urlcrate-1.0.1: "[\u{001b}\u{009b}][\\[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]" +consistent!(cargo_urlcrate_0, "[\u{001b}\u{009b}][\\[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]"); + +// cargo-script-0.2.8: r"^\s*\*( |$)" +consistent!(cargo_script_0, r"^\s*\*( |$)"); + +// cargo-script-0.2.8: r"^(\s+)" +consistent!(cargo_script_1, r"^(\s+)"); + +// cargo-script-0.2.8: r"/\*|\*/" +consistent!(cargo_script_2, r"/\*|\*/"); + +// cargo-script-0.2.8: r"^\s*//!" +consistent!(cargo_script_3, r"^\s*//!"); + +// cargo-script-0.2.8: r"^#![^\[].*?(\r\n|\n)" +consistent!(cargo_script_4, r"^#![^\[].*?(\r\n|\n)"); + +// cargo-update-1.5.2: r"cargo-install-update\.exe-v.+" +consistent!(cargo_update_0, r"cargo-install-update\.exe-v.+"); + +// canteen-0.4.1: r"^<(?:(int|uint|str|float|path):)?([\w_][a-zA-Z0-9_]*)>$" +consistent!( + canteen_0, + r"^<(?:(int|uint|str|float|path):)?([\w_][a-zA-Z0-9_]*)>$" +); + +// thruster-cli-0.1.3: r"(.)([A-Z])" +consistent!(thruster_cli_0, r"(.)([A-Z])"); + +// thieves-cant-0.1.0: "([Z]+)$" +consistent!(thieves_cant_0, "([Z]+)$"); + +// codeowners-0.1.3: r"^@\S+/\S+" +consistent!(codeowners_0, r"^@\S+/\S+"); + +// codeowners-0.1.3: r"^@\S+" +consistent!(codeowners_1, r"^@\S+"); + +// codeowners-0.1.3: r"^\S+@\S+" +consistent!(codeowners_2, r"^\S+@\S+"); + +// conserve-0.4.2: r"^b0000 {21} complete 20[-0-9T:+]+\s +\d+s\n$" +consistent!(conserve_0, r"^b0000 {21} complete 20[-0-9T:+]+\s +\d+s\n$"); + +// commodore-0.3.0: r"(?P<greeting>\S+?) (?P<name>\S+?)$" +consistent!(commodore_0, r"(?P<greeting>\S+?) (?P<name>\S+?)$"); + +// corollary-0.3.0: r"([ \t]*)```haskell([\s\S]*?)```" +consistent!(corollary_0, r"([ \t]*)```haskell([\s\S]*?)```"); + +// corollary-0.3.0: r"\b((?:a|b|t)\d*)\b" +consistent!(corollary_1, r"\b((?:a|b|t)\d*)\b"); + +// colorizex-0.1.3: "NB" +consistent!(colorizex_0, "NB"); + +// colorstring-0.0.1: r"(?i)\[[a-z0-9_-]+\]" +consistent!(colorstring_0, r"(?i)\[[a-z0-9_-]+\]"); + +// colorstring-0.0.1: r"^(?i)(\[[a-z0-9_-]+\])+" +consistent!(colorstring_1, r"^(?i)(\[[a-z0-9_-]+\])+"); + +// cosmogony-0.3.0: "name:(.+)" +consistent!(cosmogony_0, "name:(.+)"); + +// cobalt-bin-0.12.1: r"(?m:^ {0,3}\[[^\]]+\]:.+$)" +consistent!(cobalt_bin_0, r"(?m:^ {0,3}\[[^\]]+\]:.+$)"); + +// comrak-0.2.12: r"[^\p{L}\p{M}\p{N}\p{Pc} -]" +consistent!(comrak_0, r"[^\p{L}\p{M}\p{N}\p{Pc} -]"); + +// content-blocker-0.2.3: "" +consistent!(content_blocker_0, ""); + +// content-blocker-0.2.3: "(?i)hi" +consistent!(content_blocker_1, "(?i)hi"); + +// content-blocker-0.2.3: "http[s]?://domain.org" +consistent!(content_blocker_2, "http[s]?://domain.org"); + +// content-blocker-0.2.3: "(?i)http[s]?://domain.org" +consistent!(content_blocker_3, "(?i)http[s]?://domain.org"); + +// content-blocker-0.2.3: "http://domain.org" +consistent!(content_blocker_4, "http://domain.org"); + +// content-blocker-0.2.3: "http://domain.org" +consistent!(content_blocker_5, "http://domain.org"); + +// content-blocker-0.2.3: "ad.html" +consistent!(content_blocker_6, "ad.html"); + +// content-blocker-0.2.3: "ad.html" +consistent!(content_blocker_7, "ad.html"); + +// content-blocker-0.2.3: "http://domain.org" +consistent!(content_blocker_8, "http://domain.org"); + +// content-blocker-0.2.3: "http://domain.org/nocookies.sjs" +consistent!(content_blocker_9, "http://domain.org/nocookies.sjs"); + +// content-blocker-0.2.3: "http://domain.org/nocookies.sjs" +consistent!(content_blocker_10, "http://domain.org/nocookies.sjs"); + +// content-blocker-0.2.3: "http://domain.org/hideme.jpg" +consistent!(content_blocker_11, "http://domain.org/hideme.jpg"); + +// content-blocker-0.2.3: "http://domain.org/ok.html" +consistent!(content_blocker_12, "http://domain.org/ok.html"); + +// content-blocker-0.2.3: "http://domain.org/ok.html\\?except_this=1" +consistent!(content_blocker_13, "http://domain.org/ok.html\\?except_this=1"); + +// victoria-dom-0.1.2: "[A-Za-z0-9=]" +consistent!(victoria_dom_0, "[A-Za-z0-9=]"); + +// numbat-1.0.0: r"^nsq://" +consistent!(numbat_0, r"^nsq://"); + +// airkorea-0.1.2: r"[\s\t\r\n]" +consistent!(airkorea_0, r"[\s\t\r\n]"); + +// airkorea-0.1.2: r"([\{\[,])|([\}\]])" +consistent!(airkorea_1, r"([\{\[,])|([\}\]])"); + +// airkorea-0.1.2: r"[^.\d]+$" +consistent!(airkorea_2, r"[^.\d]+$"); + +// rofl-0.0.1: r"\b" +// consistent!(rofl_0, r"\b"); + +// rogcat-0.2.15: r"--------- beginning of.*" +consistent!(rogcat_0, r"--------- beginning of.*"); + +// rogcat-0.2.15: r"a|e|i|o|u" +consistent!(rogcat_1, r"a|e|i|o|u"); + +// rogcat-0.2.15: r"^(\d+)([kMG])$" +consistent!(rogcat_2, r"^(\d+)([kMG])$"); + +// media_filename-0.1.4: "\\.([A-Za-z0-9]{2,4})$" +consistent!(media_filename_0, "\\.([A-Za-z0-9]{2,4})$"); + +// media_filename-0.1.4: "([0-9]{3,4}p|[0-9]{3,4}x[0-9]{3,4})" +consistent!(media_filename_1, "([0-9]{3,4}p|[0-9]{3,4}x[0-9]{3,4})"); + +// media_filename-0.1.4: "(?:^\\[([^]]+)\\]|- ?([^-]+)$)" +consistent!(media_filename_2, "(?:^\\[([^]]+)\\]|- ?([^-]+)$)"); + +// media_filename-0.1.4: "(?:[eE]([0-9]{2,3})|[^0-9A-Za-z]([0-9]{2,3})(?:v[0-9])?[^0-9A-Za-z])" +consistent!( + media_filename_3, + "(?:[eE]([0-9]{2,3})|[^0-9A-Za-z]([0-9]{2,3})(?:v[0-9])?[^0-9A-Za-z])" +); + +// media_filename-0.1.4: "[sS]([0-9]{1,2})" +consistent!(media_filename_4, "[sS]([0-9]{1,2})"); + +// media_filename-0.1.4: "((?i)(?:PPV.)?[HP]DTV|(?:HD)?CAM|BRRIP|[^a-z]TS[^a-z]|(?:PPV )?WEB.?DL(?: DVDRip)?|HDRip|DVDRip|CamRip|W[EB]BRip|BluRay|BD|DVD|DvDScr|hdtv)" +consistent!(media_filename_5, "((?i)(?:PPV.)?[HP]DTV|(?:HD)?CAM|BRRIP|[^a-z]TS[^a-z]|(?:PPV )?WEB.?DL(?: DVDRip)?|HDRip|DVDRip|CamRip|W[EB]BRip|BluRay|BD|DVD|DvDScr|hdtv)"); + +// media_filename-0.1.4: "((19[0-9]|20[01])[0-9])" +consistent!(media_filename_6, "((19[0-9]|20[01])[0-9])"); + +// media_filename-0.1.4: "((?i)xvid|x264|h\\.?264)" +consistent!(media_filename_7, "((?i)xvid|x264|h\\.?264)"); + +// media_filename-0.1.4: "((?i)MP3|DD5\\.?1|Dual[- ]Audio|LiNE|DTS|AAC(?:\\.?2\\.0)?|AC3(?:\\.5\\.1)?)" +consistent!(media_filename_8, "((?i)MP3|DD5\\.?1|Dual[- ]Audio|LiNE|DTS|AAC(?:\\.?2\\.0)?|AC3(?:\\.5\\.1)?)"); + +// media_filename-0.1.4: "\\[([0-9A-F]{8})\\]" +consistent!(media_filename_9, "\\[([0-9A-F]{8})\\]"); + +// termimage-0.3.2: r"(\d+)[xX](\d+)" +consistent!(termimage_0, r"(\d+)[xX](\d+)"); + +// teensy-0.1.0: r".*(\d{4}-\d{2}-\d{2}).*" +consistent!(teensy_0, r".*(\d{4}-\d{2}-\d{2}).*"); + +// telescreen-0.1.3: r"<@(.+)>" +consistent!(telescreen_0, r"<@(.+)>"); + +// tempus_fugit-0.4.4: r"^(\d+)" +consistent!(tempus_fugit_0, r"^(\d+)"); + +// fselect-0.4.1: "(\\?|\\.|\\*|\\[|\\]|\\(|\\)|\\^|\\$)" +consistent!(fselect_0, "(\\?|\\.|\\*|\\[|\\]|\\(|\\)|\\^|\\$)"); + +// fselect-0.4.1: "(%|_|\\?|\\.|\\*|\\[|\\]|\\(|\\)|\\^|\\$)" +consistent!(fselect_1, "(%|_|\\?|\\.|\\*|\\[|\\]|\\(|\\)|\\^|\\$)"); + +// fs_eventbridge-0.1.0: r"^([A-Z]+)(?:\s(.+))?\s*" +consistent!(fs_eventbridge_0, r"^([A-Z]+)(?:\s(.+))?\s*"); + +// joseki-0.0.1: r"(\w{1,2})\[(.+?)\]" +consistent!(joseki_0, r"(\w{1,2})\[(.+?)\]"); + +// tweetr-0.2.1: r"(?i)in (\d+) (second|minute|hour|day|week)s?" +consistent!(tweetr_0, r"(?i)in (\d+) (second|minute|hour|day|week)s?"); + +// bullet_core-0.1.1: "^(?u:[0-9])+" +consistent!(bullet_core_0, "^(?u:[0-9])+"); + +// bullet_core-0.1.1: "^(?u:[0-9])+(?u:\\.)(?u:[0-9])+" +consistent!(bullet_core_1, "^(?u:[0-9])+(?u:\\.)(?u:[0-9])+"); + +// bullet_core-0.1.1: "^(?u:[A-Za-zª-ªµ-µº-ºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬ-ˬˮ-ˮͰ-ʹͶ-ͷͺ-ͽͿ-ͿΆ-ΆΈ-ΊΌ-ΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙ-ՙա-ևא-תװ-ײؠ-يٮ-ٯٱ-ۓە-ەۥ-ۦۮ-ۯۺ-ۼۿ-ۿܐ-ܐܒ-ܯݍ-ޥޱ-ޱߊ-ߪߴ-ߵߺ-ߺࠀ-ࠕࠚ-ࠚࠤ-ࠤࠨ-ࠨࡀ-ࡘࢠ-ࢴऄ-हऽ-ऽॐ-ॐक़-ॡॱ-ঀঅ-ঌএ-ঐও-নপ-রল-লশ-হঽ-ঽৎ-ৎড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼-ਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલ-ળવ-હઽ-ઽૐ-ૐૠ-ૡૹ-ૹଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଵ-ହଽ-ଽଡ଼-ଢ଼ୟ-ୡୱ-ୱஃ-ஃஅ-ஊஎ-ஐஒ-கங-சஜ-ஜஞ-டண-தந-பம-ஹௐ-ௐఅ-ఌఎ-ఐఒ-నప-హఽ-ఽౘ-ౚౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ಽೞ-ೞೠ-ೡೱ-ೲഅ-ഌഎ-ഐഒ-ഺഽ-ഽൎ-ൎൟ-ൡൺ-ൿඅ-ඖක-නඳ-රල-ලව-ෆก-ะา-ำเ-ๆກ-ຂຄ-ຄງ-ຈຊ-ຊຍ-ຍດ-ທນ-ຟມ-ຣລ-ລວ-ວສ-ຫອ-ະາ-ຳຽ-ຽເ-ໄໆ-ໆໜ-ໟༀ-ༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿ-ဿၐ-ၕၚ-ၝၡ-ၡၥ-ၦၮ-ၰၵ-ႁႎ-ႎႠ-ჅჇ-ჇჍ-Ⴭა-ჺჼ-ቈቊ-ቍቐ-ቖቘ-ቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀ-ዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛱ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗ-ៗៜ-ៜᠠ-ᡷᢀ-ᢨᢪ-ᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧ-ᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮ-ᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵ-ᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙ-ὙὛ-ὛὝ-ὝὟ-ώᾀ-ᾴᾶ-ᾼι-ιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱ-ⁱⁿ-ⁿₐ-ₜℂ-ℂℇ-ℇℊ-ℓℕ-ℕℙ-ℝℤ-ℤΩ-Ωℨ-ℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎ-ⅎↃ-ↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲ-ⳳⴀ-ⴥⴧ-ⴧⴭ-ⴭⴰ-ⵧⵯ-ⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ-ⸯ々-〆〱-〵〻-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪ-ꘫꙀ-ꙮꙿ-ꚝꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞭꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻ-ꣻꣽ-ꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏ-ꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺ-ꩺꩾ-ꪯꪱ-ꪱꪵ-ꪶꪹ-ꪽꫀ-ꫀꫂ-ꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-יִײַ-ﬨשׁ-זּטּ-לּמּ-מּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ𐀀-𐀋𐀍-𐀦𐀨-𐀺𐀼-𐀽𐀿-𐁍𐁐-𐁝𐂀-𐃺𐊀-𐊜𐊠-𐋐𐌀-𐌟𐌰-𐍀𐍂-𐍉𐍐-𐍵𐎀-𐎝𐎠-𐏃𐏈-𐏏𐐀-𐒝𐔀-𐔧𐔰-𐕣𐘀-𐜶𐝀-𐝕𐝠-𐝧𐠀-𐠅𐠈-𐠈𐠊-𐠵𐠷-𐠸𐠼-𐠼𐠿-𐡕𐡠-𐡶𐢀-𐢞𐣠-𐣲𐣴-𐣵𐤀-𐤕𐤠-𐤹𐦀-𐦷𐦾-𐦿𐨀-𐨀𐨐-𐨓𐨕-𐨗𐨙-𐨳𐩠-𐩼𐪀-𐪜𐫀-𐫇𐫉-𐫤𐬀-𐬵𐭀-𐭕𐭠-𐭲𐮀-𐮑𐰀-𐱈𐲀-𐲲𐳀-𐳲𑀃-𑀷𑂃-𑂯𑃐-𑃨𑄃-𑄦𑅐-𑅲𑅶-𑅶𑆃-𑆲𑇁-𑇄𑇚-𑇚𑇜-𑇜𑈀-𑈑𑈓-𑈫𑊀-𑊆𑊈-𑊈𑊊-𑊍𑊏-𑊝𑊟-𑊨𑊰-𑋞𑌅-𑌌𑌏-𑌐𑌓-𑌨𑌪-𑌰𑌲-𑌳𑌵-𑌹𑌽-𑌽𑍐-𑍐𑍝-𑍡𑒀-𑒯𑓄-𑓅𑓇-𑓇𑖀-𑖮𑗘-𑗛𑘀-𑘯𑙄-𑙄𑚀-𑚪𑜀-𑜙𑢠-𑣟𑣿-𑣿𑫀-𑫸𒀀-𒎙𒒀-𒕃𓀀-𓐮𔐀-𔙆𖠀-𖨸𖩀-𖩞𖫐-𖫭𖬀-𖬯𖭀-𖭃𖭣-𖭷𖭽-𖮏𖼀-𖽄𖽐-𖽐𖾓-𖾟𛀀-𛀁𛰀-𛱪𛱰-𛱼𛲀-𛲈𛲐-𛲙𝐀-𝑔𝑖-𝒜𝒞-𝒟𝒢-𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒹𝒻-𝒻𝒽-𝓃𝓅-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔞-𝔹𝔻-𝔾𝕀-𝕄𝕆-𝕆𝕊-𝕐𝕒-𝚥𝚨-𝛀𝛂-𝛚𝛜-𝛺𝛼-𝜔𝜖-𝜴𝜶-𝝎𝝐-𝝮𝝰-𝞈𝞊-𝞨𝞪-𝟂𝟄-𝟋𞠀-𞣄𞸀-𞸃𞸅-𞸟𞸡-𞸢𞸤-𞸤𞸧-𞸧𞸩-𞸲𞸴-𞸷𞸹-𞸹𞸻-𞸻𞹂-𞹂𞹇-𞹇𞹉-𞹉𞹋-𞹋𞹍-𞹏𞹑-𞹒𞹔-𞹔𞹗-𞹗𞹙-𞹙𞹛-𞹛𞹝-𞹝𞹟-𞹟𞹡-𞹢𞹤-𞹤𞹧-𞹪𞹬-𞹲𞹴-𞹷𞹹-𞹼𞹾-𞹾𞺀-𞺉𞺋-𞺛𞺡-𞺣𞺥-𞺩𞺫-𞺻𠀀-𪛖𪜀-𫜴𫝀-𫠝𫠠-𬺡丽-𪘀])+" +consistent!(bullet_core_2, "^(?u:[A-Za-zª-ªµ-µº-ºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬ-ˬˮ-ˮͰ-ʹͶ-ͷͺ-ͽͿ-ͿΆ-ΆΈ-ΊΌ-ΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙ-ՙա-ևא-תװ-ײؠ-يٮ-ٯٱ-ۓە-ەۥ-ۦۮ-ۯۺ-ۼۿ-ۿܐ-ܐܒ-ܯݍ-ޥޱ-ޱߊ-ߪߴ-ߵߺ-ߺࠀ-ࠕࠚ-ࠚࠤ-ࠤࠨ-ࠨࡀ-ࡘࢠ-ࢴऄ-हऽ-ऽॐ-ॐक़-ॡॱ-ঀঅ-ঌএ-ঐও-নপ-রল-লশ-হঽ-ঽৎ-ৎড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼-ਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલ-ળવ-હઽ-ઽૐ-ૐૠ-ૡૹ-ૹଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଵ-ହଽ-ଽଡ଼-ଢ଼ୟ-ୡୱ-ୱஃ-ஃஅ-ஊஎ-ஐஒ-கங-சஜ-ஜஞ-டண-தந-பம-ஹௐ-ௐఅ-ఌఎ-ఐఒ-నప-హఽ-ఽౘ-ౚౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ಽೞ-ೞೠ-ೡೱ-ೲഅ-ഌഎ-ഐഒ-ഺഽ-ഽൎ-ൎൟ-ൡൺ-ൿඅ-ඖක-නඳ-රල-ලව-ෆก-ะา-ำเ-ๆກ-ຂຄ-ຄງ-ຈຊ-ຊຍ-ຍດ-ທນ-ຟມ-ຣລ-ລວ-ວສ-ຫອ-ະາ-ຳຽ-ຽເ-ໄໆ-ໆໜ-ໟༀ-ༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿ-ဿၐ-ၕၚ-ၝၡ-ၡၥ-ၦၮ-ၰၵ-ႁႎ-ႎႠ-ჅჇ-ჇჍ-Ⴭა-ჺჼ-ቈቊ-ቍቐ-ቖቘ-ቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀ-ዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛱ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗ-ៗៜ-ៜᠠ-ᡷᢀ-ᢨᢪ-ᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧ-ᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮ-ᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵ-ᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙ-ὙὛ-ὛὝ-ὝὟ-ώᾀ-ᾴᾶ-ᾼι-ιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱ-ⁱⁿ-ⁿₐ-ₜℂ-ℂℇ-ℇℊ-ℓℕ-ℕℙ-ℝℤ-ℤΩ-Ωℨ-ℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎ-ⅎↃ-ↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲ-ⳳⴀ-ⴥⴧ-ⴧⴭ-ⴭⴰ-ⵧⵯ-ⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ-ⸯ々-〆〱-〵〻-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪ-ꘫꙀ-ꙮꙿ-ꚝꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞭꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻ-ꣻꣽ-ꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏ-ꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺ-ꩺꩾ-ꪯꪱ-ꪱꪵ-ꪶꪹ-ꪽꫀ-ꫀꫂ-ꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-יִײַ-ﬨשׁ-זּטּ-לּמּ-מּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ𐀀-𐀋𐀍-𐀦𐀨-𐀺𐀼-𐀽𐀿-𐁍𐁐-𐁝𐂀-𐃺𐊀-𐊜𐊠-𐋐𐌀-𐌟𐌰-𐍀𐍂-𐍉𐍐-𐍵𐎀-𐎝𐎠-𐏃𐏈-𐏏𐐀-𐒝𐔀-𐔧𐔰-𐕣𐘀-𐜶𐝀-𐝕𐝠-𐝧𐠀-𐠅𐠈-𐠈𐠊-𐠵𐠷-𐠸𐠼-𐠼𐠿-𐡕𐡠-𐡶𐢀-𐢞𐣠-𐣲𐣴-𐣵𐤀-𐤕𐤠-𐤹𐦀-𐦷𐦾-𐦿𐨀-𐨀𐨐-𐨓𐨕-𐨗𐨙-𐨳𐩠-𐩼𐪀-𐪜𐫀-𐫇𐫉-𐫤𐬀-𐬵𐭀-𐭕𐭠-𐭲𐮀-𐮑𐰀-𐱈𐲀-𐲲𐳀-𐳲𑀃-𑀷𑂃-𑂯𑃐-𑃨𑄃-𑄦𑅐-𑅲𑅶-𑅶𑆃-𑆲𑇁-𑇄𑇚-𑇚𑇜-𑇜𑈀-𑈑𑈓-𑈫𑊀-𑊆𑊈-𑊈𑊊-𑊍𑊏-𑊝𑊟-𑊨𑊰-𑋞𑌅-𑌌𑌏-𑌐𑌓-𑌨𑌪-𑌰𑌲-𑌳𑌵-𑌹𑌽-𑌽𑍐-𑍐𑍝-𑍡𑒀-𑒯𑓄-𑓅𑓇-𑓇𑖀-𑖮𑗘-𑗛𑘀-𑘯𑙄-𑙄𑚀-𑚪𑜀-𑜙𑢠-𑣟𑣿-𑣿𑫀-𑫸𒀀-𒎙𒒀-𒕃𓀀-𓐮𔐀-𔙆𖠀-𖨸𖩀-𖩞𖫐-𖫭𖬀-𖬯𖭀-𖭃𖭣-𖭷𖭽-𖮏𖼀-𖽄𖽐-𖽐𖾓-𖾟𛀀-𛀁𛰀-𛱪𛱰-𛱼𛲀-𛲈𛲐-𛲙𝐀-𝑔𝑖-𝒜𝒞-𝒟𝒢-𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒹𝒻-𝒻𝒽-𝓃𝓅-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔞-𝔹𝔻-𝔾𝕀-𝕄𝕆-𝕆𝕊-𝕐𝕒-𝚥𝚨-𝛀𝛂-𝛚𝛜-𝛺𝛼-𝜔𝜖-𝜴𝜶-𝝎𝝐-𝝮𝝰-𝞈𝞊-𝞨𝞪-𝟂𝟄-𝟋𞠀-𞣄𞸀-𞸃𞸅-𞸟𞸡-𞸢𞸤-𞸤𞸧-𞸧𞸩-𞸲𞸴-𞸷𞸹-𞸹𞸻-𞸻𞹂-𞹂𞹇-𞹇𞹉-𞹉𞹋-𞹋𞹍-𞹏𞹑-𞹒𞹔-𞹔𞹗-𞹗𞹙-𞹙𞹛-𞹛𞹝-𞹝𞹟-𞹟𞹡-𞹢𞹤-𞹤𞹧-𞹪𞹬-𞹲𞹴-𞹷𞹹-𞹼𞹾-𞹾𞺀-𞺉𞺋-𞺛𞺡-𞺣𞺥-𞺩𞺫-𞺻𠀀-𪛖𪜀-𫜴𫝀-𫠝𫠠-𬺡丽-𪘀])+"); + +// bullet_core-0.1.1: "^(?u:d/d)((?u:[A-Za-zª-ªµ-µº-ºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬ-ˬˮ-ˮͰ-ʹͶ-ͷͺ-ͽͿ-ͿΆ-ΆΈ-ΊΌ-ΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙ-ՙա-ևא-תװ-ײؠ-يٮ-ٯٱ-ۓە-ەۥ-ۦۮ-ۯۺ-ۼۿ-ۿܐ-ܐܒ-ܯݍ-ޥޱ-ޱߊ-ߪߴ-ߵߺ-ߺࠀ-ࠕࠚ-ࠚࠤ-ࠤࠨ-ࠨࡀ-ࡘࢠ-ࢴऄ-हऽ-ऽॐ-ॐक़-ॡॱ-ঀঅ-ঌএ-ঐও-নপ-রল-লশ-হঽ-ঽৎ-ৎড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼-ਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલ-ળવ-હઽ-ઽૐ-ૐૠ-ૡૹ-ૹଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଵ-ହଽ-ଽଡ଼-ଢ଼ୟ-ୡୱ-ୱஃ-ஃஅ-ஊஎ-ஐஒ-கங-சஜ-ஜஞ-டண-தந-பம-ஹௐ-ௐఅ-ఌఎ-ఐఒ-నప-హఽ-ఽౘ-ౚౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ಽೞ-ೞೠ-ೡೱ-ೲഅ-ഌഎ-ഐഒ-ഺഽ-ഽൎ-ൎൟ-ൡൺ-ൿඅ-ඖක-නඳ-රල-ලව-ෆก-ะา-ำเ-ๆກ-ຂຄ-ຄງ-ຈຊ-ຊຍ-ຍດ-ທນ-ຟມ-ຣລ-ລວ-ວສ-ຫອ-ະາ-ຳຽ-ຽເ-ໄໆ-ໆໜ-ໟༀ-ༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿ-ဿၐ-ၕၚ-ၝၡ-ၡၥ-ၦၮ-ၰၵ-ႁႎ-ႎႠ-ჅჇ-ჇჍ-Ⴭა-ჺჼ-ቈቊ-ቍቐ-ቖቘ-ቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀ-ዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛱ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗ-ៗៜ-ៜᠠ-ᡷᢀ-ᢨᢪ-ᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧ-ᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮ-ᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵ-ᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙ-ὙὛ-ὛὝ-ὝὟ-ώᾀ-ᾴᾶ-ᾼι-ιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱ-ⁱⁿ-ⁿₐ-ₜℂ-ℂℇ-ℇℊ-ℓℕ-ℕℙ-ℝℤ-ℤΩ-Ωℨ-ℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎ-ⅎↃ-ↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲ-ⳳⴀ-ⴥⴧ-ⴧⴭ-ⴭⴰ-ⵧⵯ-ⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ-ⸯ々-〆〱-〵〻-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪ-ꘫꙀ-ꙮꙿ-ꚝꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞭꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻ-ꣻꣽ-ꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏ-ꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺ-ꩺꩾ-ꪯꪱ-ꪱꪵ-ꪶꪹ-ꪽꫀ-ꫀꫂ-ꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-יִײַ-ﬨשׁ-זּטּ-לּמּ-מּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ𐀀-𐀋𐀍-𐀦𐀨-𐀺𐀼-𐀽𐀿-𐁍𐁐-𐁝𐂀-𐃺𐊀-𐊜𐊠-𐋐𐌀-𐌟𐌰-𐍀𐍂-𐍉𐍐-𐍵𐎀-𐎝𐎠-𐏃𐏈-𐏏𐐀-𐒝𐔀-𐔧𐔰-𐕣𐘀-𐜶𐝀-𐝕𐝠-𐝧𐠀-𐠅𐠈-𐠈𐠊-𐠵𐠷-𐠸𐠼-𐠼𐠿-𐡕𐡠-𐡶𐢀-𐢞𐣠-𐣲𐣴-𐣵𐤀-𐤕𐤠-𐤹𐦀-𐦷𐦾-𐦿𐨀-𐨀𐨐-𐨓𐨕-𐨗𐨙-𐨳𐩠-𐩼𐪀-𐪜𐫀-𐫇𐫉-𐫤𐬀-𐬵𐭀-𐭕𐭠-𐭲𐮀-𐮑𐰀-𐱈𐲀-𐲲𐳀-𐳲𑀃-𑀷𑂃-𑂯𑃐-𑃨𑄃-𑄦𑅐-𑅲𑅶-𑅶𑆃-𑆲𑇁-𑇄𑇚-𑇚𑇜-𑇜𑈀-𑈑𑈓-𑈫𑊀-𑊆𑊈-𑊈𑊊-𑊍𑊏-𑊝𑊟-𑊨𑊰-𑋞𑌅-𑌌𑌏-𑌐𑌓-𑌨𑌪-𑌰𑌲-𑌳𑌵-𑌹𑌽-𑌽𑍐-𑍐𑍝-𑍡𑒀-𑒯𑓄-𑓅𑓇-𑓇𑖀-𑖮𑗘-𑗛𑘀-𑘯𑙄-𑙄𑚀-𑚪𑜀-𑜙𑢠-𑣟𑣿-𑣿𑫀-𑫸𒀀-𒎙𒒀-𒕃𓀀-𓐮𔐀-𔙆𖠀-𖨸𖩀-𖩞𖫐-𖫭𖬀-𖬯𖭀-𖭃𖭣-𖭷𖭽-𖮏𖼀-𖽄𖽐-𖽐𖾓-𖾟𛀀-𛀁𛰀-𛱪𛱰-𛱼𛲀-𛲈𛲐-𛲙𝐀-𝑔𝑖-𝒜𝒞-𝒟𝒢-𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒹𝒻-𝒻𝒽-𝓃𝓅-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔞-𝔹𝔻-𝔾𝕀-𝕄𝕆-𝕆𝕊-𝕐𝕒-𝚥𝚨-𝛀𝛂-𝛚𝛜-𝛺𝛼-𝜔𝜖-𝜴𝜶-𝝎𝝐-𝝮𝝰-𝞈𝞊-𝞨𝞪-𝟂𝟄-𝟋𞠀-𞣄𞸀-𞸃𞸅-𞸟𞸡-𞸢𞸤-𞸤𞸧-𞸧𞸩-𞸲𞸴-𞸷𞸹-𞸹𞸻-𞸻𞹂-𞹂𞹇-𞹇𞹉-𞹉𞹋-𞹋𞹍-𞹏𞹑-𞹒𞹔-𞹔𞹗-𞹗𞹙-𞹙𞹛-𞹛𞹝-𞹝𞹟-𞹟𞹡-𞹢𞹤-𞹤𞹧-𞹪𞹬-𞹲𞹴-𞹷𞹹-𞹼𞹾-𞹾𞺀-𞺉𞺋-𞺛𞺡-𞺣𞺥-𞺩𞺫-𞺻𠀀-𪛖𪜀-𫜴𫝀-𫠝𫠠-𬺡丽-𪘀])+)" +consistent!(bullet_core_3, "^(?u:d/d)((?u:[A-Za-zª-ªµ-µº-ºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬ-ˬˮ-ˮͰ-ʹͶ-ͷͺ-ͽͿ-ͿΆ-ΆΈ-ΊΌ-ΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙ-ՙա-ևא-תװ-ײؠ-يٮ-ٯٱ-ۓە-ەۥ-ۦۮ-ۯۺ-ۼۿ-ۿܐ-ܐܒ-ܯݍ-ޥޱ-ޱߊ-ߪߴ-ߵߺ-ߺࠀ-ࠕࠚ-ࠚࠤ-ࠤࠨ-ࠨࡀ-ࡘࢠ-ࢴऄ-हऽ-ऽॐ-ॐक़-ॡॱ-ঀঅ-ঌএ-ঐও-নপ-রল-লশ-হঽ-ঽৎ-ৎড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼-ਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલ-ળવ-હઽ-ઽૐ-ૐૠ-ૡૹ-ૹଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଵ-ହଽ-ଽଡ଼-ଢ଼ୟ-ୡୱ-ୱஃ-ஃஅ-ஊஎ-ஐஒ-கங-சஜ-ஜஞ-டண-தந-பம-ஹௐ-ௐఅ-ఌఎ-ఐఒ-నప-హఽ-ఽౘ-ౚౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ಽೞ-ೞೠ-ೡೱ-ೲഅ-ഌഎ-ഐഒ-ഺഽ-ഽൎ-ൎൟ-ൡൺ-ൿඅ-ඖක-නඳ-රල-ලව-ෆก-ะา-ำเ-ๆກ-ຂຄ-ຄງ-ຈຊ-ຊຍ-ຍດ-ທນ-ຟມ-ຣລ-ລວ-ວສ-ຫອ-ະາ-ຳຽ-ຽເ-ໄໆ-ໆໜ-ໟༀ-ༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿ-ဿၐ-ၕၚ-ၝၡ-ၡၥ-ၦၮ-ၰၵ-ႁႎ-ႎႠ-ჅჇ-ჇჍ-Ⴭა-ჺჼ-ቈቊ-ቍቐ-ቖቘ-ቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀ-ዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛱ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗ-ៗៜ-ៜᠠ-ᡷᢀ-ᢨᢪ-ᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧ-ᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮ-ᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵ-ᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙ-ὙὛ-ὛὝ-ὝὟ-ώᾀ-ᾴᾶ-ᾼι-ιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱ-ⁱⁿ-ⁿₐ-ₜℂ-ℂℇ-ℇℊ-ℓℕ-ℕℙ-ℝℤ-ℤΩ-Ωℨ-ℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎ-ⅎↃ-ↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲ-ⳳⴀ-ⴥⴧ-ⴧⴭ-ⴭⴰ-ⵧⵯ-ⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ-ⸯ々-〆〱-〵〻-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪ-ꘫꙀ-ꙮꙿ-ꚝꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞭꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻ-ꣻꣽ-ꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏ-ꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺ-ꩺꩾ-ꪯꪱ-ꪱꪵ-ꪶꪹ-ꪽꫀ-ꫀꫂ-ꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-יִײַ-ﬨשׁ-זּטּ-לּמּ-מּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ𐀀-𐀋𐀍-𐀦𐀨-𐀺𐀼-𐀽𐀿-𐁍𐁐-𐁝𐂀-𐃺𐊀-𐊜𐊠-𐋐𐌀-𐌟𐌰-𐍀𐍂-𐍉𐍐-𐍵𐎀-𐎝𐎠-𐏃𐏈-𐏏𐐀-𐒝𐔀-𐔧𐔰-𐕣𐘀-𐜶𐝀-𐝕𐝠-𐝧𐠀-𐠅𐠈-𐠈𐠊-𐠵𐠷-𐠸𐠼-𐠼𐠿-𐡕𐡠-𐡶𐢀-𐢞𐣠-𐣲𐣴-𐣵𐤀-𐤕𐤠-𐤹𐦀-𐦷𐦾-𐦿𐨀-𐨀𐨐-𐨓𐨕-𐨗𐨙-𐨳𐩠-𐩼𐪀-𐪜𐫀-𐫇𐫉-𐫤𐬀-𐬵𐭀-𐭕𐭠-𐭲𐮀-𐮑𐰀-𐱈𐲀-𐲲𐳀-𐳲𑀃-𑀷𑂃-𑂯𑃐-𑃨𑄃-𑄦𑅐-𑅲𑅶-𑅶𑆃-𑆲𑇁-𑇄𑇚-𑇚𑇜-𑇜𑈀-𑈑𑈓-𑈫𑊀-𑊆𑊈-𑊈𑊊-𑊍𑊏-𑊝𑊟-𑊨𑊰-𑋞𑌅-𑌌𑌏-𑌐𑌓-𑌨𑌪-𑌰𑌲-𑌳𑌵-𑌹𑌽-𑌽𑍐-𑍐𑍝-𑍡𑒀-𑒯𑓄-𑓅𑓇-𑓇𑖀-𑖮𑗘-𑗛𑘀-𑘯𑙄-𑙄𑚀-𑚪𑜀-𑜙𑢠-𑣟𑣿-𑣿𑫀-𑫸𒀀-𒎙𒒀-𒕃𓀀-𓐮𔐀-𔙆𖠀-𖨸𖩀-𖩞𖫐-𖫭𖬀-𖬯𖭀-𖭃𖭣-𖭷𖭽-𖮏𖼀-𖽄𖽐-𖽐𖾓-𖾟𛀀-𛀁𛰀-𛱪𛱰-𛱼𛲀-𛲈𛲐-𛲙𝐀-𝑔𝑖-𝒜𝒞-𝒟𝒢-𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒹𝒻-𝒻𝒽-𝓃𝓅-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔞-𝔹𝔻-𝔾𝕀-𝕄𝕆-𝕆𝕊-𝕐𝕒-𝚥𝚨-𝛀𝛂-𝛚𝛜-𝛺𝛼-𝜔𝜖-𝜴𝜶-𝝎𝝐-𝝮𝝰-𝞈𝞊-𝞨𝞪-𝟂𝟄-𝟋𞠀-𞣄𞸀-𞸃𞸅-𞸟𞸡-𞸢𞸤-𞸤𞸧-𞸧𞸩-𞸲𞸴-𞸷𞸹-𞸹𞸻-𞸻𞹂-𞹂𞹇-𞹇𞹉-𞹉𞹋-𞹋𞹍-𞹏𞹑-𞹒𞹔-𞹔𞹗-𞹗𞹙-𞹙𞹛-𞹛𞹝-𞹝𞹟-𞹟𞹡-𞹢𞹤-𞹤𞹧-𞹪𞹬-𞹲𞹴-𞹷𞹹-𞹼𞹾-𞹾𞺀-𞺉𞺋-𞺛𞺡-𞺣𞺥-𞺩𞺫-𞺻𠀀-𪛖𪜀-𫜴𫝀-𫠝𫠠-𬺡丽-𪘀])+)"); + +// bullet_core-0.1.1: "^(?u:\\()" +consistent!(bullet_core_4, "^(?u:\\()"); + +// bullet_core-0.1.1: "^(?u:\\))" +consistent!(bullet_core_5, "^(?u:\\))"); + +// bullet_core-0.1.1: "^(?u:\\*)" +consistent!(bullet_core_6, "^(?u:\\*)"); + +// bullet_core-0.1.1: "^(?u:\\+)" +consistent!(bullet_core_7, "^(?u:\\+)"); + +// bullet_core-0.1.1: "^(?u:,)" +consistent!(bullet_core_8, "^(?u:,)"); + +// bullet_core-0.1.1: "^(?u:\\-)" +consistent!(bullet_core_9, "^(?u:\\-)"); + +// bullet_core-0.1.1: "^(?u:/)" +consistent!(bullet_core_10, "^(?u:/)"); + +// bullet_core-0.1.1: "^(?u:\\[)" +consistent!(bullet_core_11, "^(?u:\\[)"); + +// bullet_core-0.1.1: "^(?u:\\])" +consistent!(bullet_core_12, "^(?u:\\])"); + +// bullet_core-0.1.1: "^(?u:\\^)" +consistent!(bullet_core_13, "^(?u:\\^)"); + +// bullet_core-0.1.1: "^(?u:·)" +consistent!(bullet_core_14, "^(?u:·)"); + +// actix-web-0.6.13: "//+" +consistent!(actix_web_0, "//+"); + +// actix-web-0.6.13: "//+" +consistent!(actix_web_1, "//+"); + +// althea_kernel_interface-0.1.0: r"(\S*) .* (\S*) (REACHABLE|STALE|DELAY)" +consistent!( + althea_kernel_interface_0, + r"(\S*) .* (\S*) (REACHABLE|STALE|DELAY)" +); + +// althea_kernel_interface-0.1.0: r"-s (.*) --ip6-dst (.*)/.* bcnt = (.*)" +consistent!( + althea_kernel_interface_1, + r"-s (.*) --ip6-dst (.*)/.* bcnt = (.*)" +); + +// alcibiades-0.3.0: r"\buci(?:\s|$)" +consistent!(alcibiades_0, r"\buci(?:\s|$)"); + +// ruma-identifiers-0.11.0: r"\A[a-z0-9._=-]+\z" +consistent!(ruma_identifiers_0, r"\A[a-z0-9._=-]+\z"); + +// rusqbin-0.2.3: r"/rusqbins/((?i)[A-F0-9]{8}\-[A-F0-9]{4}\-4[A-F0-9]{3}\-[89AB][A-F0-9]{3}\-[A-F0-9]{12})$" +consistent!(rusqbin_0, r"/rusqbins/((?i)[A-F0-9]{8}\-[A-F0-9]{4}\-4[A-F0-9]{3}\-[89AB][A-F0-9]{3}\-[A-F0-9]{12})$"); + +// rusqbin-0.2.3: r"/rusqbins/((?i)[A-F0-9]{8}\-[A-F0-9]{4}\-4[A-F0-9]{3}\-[89AB][A-F0-9]{3}\-[A-F0-9]{12})/requests/?$" +consistent!(rusqbin_1, r"/rusqbins/((?i)[A-F0-9]{8}\-[A-F0-9]{4}\-4[A-F0-9]{3}\-[89AB][A-F0-9]{3}\-[A-F0-9]{12})/requests/?$"); + +// rust-install-0.0.4: r"^(nightly|beta|stable)(?:-(\d{4}-\d{2}-\d{2}))?$" +consistent!( + rust_install_0, + r"^(nightly|beta|stable)(?:-(\d{4}-\d{2}-\d{2}))?$" +); + +// rust_inbox-0.0.5: "^+(.*)\r\n" +consistent!(rust_inbox_0, "^+(.*)\r\n"); + +// rust_inbox-0.0.5: r"^\* CAPABILITY (.*)\r\n" +consistent!(rust_inbox_1, r"^\* CAPABILITY (.*)\r\n"); + +// rust_inbox-0.0.5: r"^([a-zA-Z0-9]+) (OK|NO|BAD)(.*)" +consistent!(rust_inbox_2, r"^([a-zA-Z0-9]+) (OK|NO|BAD)(.*)"); + +// rust_inbox-0.0.5: r"^\* (\d+) EXISTS\r\n" +consistent!(rust_inbox_3, r"^\* (\d+) EXISTS\r\n"); + +// rust_inbox-0.0.5: r"^\* (\d+) RECENT\r\n" +consistent!(rust_inbox_4, r"^\* (\d+) RECENT\r\n"); + +// rust_inbox-0.0.5: r"^\* FLAGS (.+)\r\n" +consistent!(rust_inbox_5, r"^\* FLAGS (.+)\r\n"); + +// rust_inbox-0.0.5: r"^\* OK \[UNSEEN (\d+)\](.*)\r\n" +consistent!(rust_inbox_6, r"^\* OK \[UNSEEN (\d+)\](.*)\r\n"); + +// rust_inbox-0.0.5: r"^\* OK \[UIDVALIDITY (\d+)\](.*)\r\n" +consistent!(rust_inbox_7, r"^\* OK \[UIDVALIDITY (\d+)\](.*)\r\n"); + +// rust_inbox-0.0.5: r"^\* OK \[UIDNEXT (\d+)\](.*)\r\n" +consistent!(rust_inbox_8, r"^\* OK \[UIDNEXT (\d+)\](.*)\r\n"); + +// rust_inbox-0.0.5: r"^\* OK \[PERMANENTFLAGS (.+)\](.*)\r\n" +consistent!(rust_inbox_9, r"^\* OK \[PERMANENTFLAGS (.+)\](.*)\r\n"); + +// rustml-0.0.7: r"^[a-z]+ (\d+)$" +consistent!(rustml_0, r"^[a-z]+ (\d+)$"); + +// rustml-0.0.7: r"^[a-z]+ (\d+)$" +consistent!(rustml_1, r"^[a-z]+ (\d+)$"); + +// rustml-0.0.7: r"^[a-z]+ (\d+)$" +consistent!(rustml_2, r"^[a-z]+ (\d+)$"); + +// rustfmt-0.10.0: r"([^\\](\\\\)*)\\[\n\r][[:space:]]*" +consistent!(rustfmt_0, r"([^\\](\\\\)*)\\[\n\r][[:space:]]*"); + +// rustfmt-core-0.4.0: r"(^\s*$)|(^\s*//\s*rustfmt-[^:]+:\s*\S+)" +consistent!(rustfmt_core_0, r"(^\s*$)|(^\s*//\s*rustfmt-[^:]+:\s*\S+)"); + +// rustfmt-core-0.4.0: r"^## `([^`]+)`" +consistent!(rustfmt_core_1, r"^## `([^`]+)`"); + +// rustfmt-core-0.4.0: r"([^\\](\\\\)*)\\[\n\r][[:space:]]*" +consistent!(rustfmt_core_2, r"([^\\](\\\\)*)\\[\n\r][[:space:]]*"); + +// rustfmt-core-0.4.0: r"\s;" +consistent!(rustfmt_core_3, r"\s;"); + +// rust-enum-derive-0.4.0: r"^(0x)?([:digit:]+)$" +consistent!(rust_enum_derive_0, r"^(0x)?([:digit:]+)$"); + +// rust-enum-derive-0.4.0: r"^([:digit:]+)[:space:]*<<[:space:]*([:digit:]+)$" +consistent!( + rust_enum_derive_1, + r"^([:digit:]+)[:space:]*<<[:space:]*([:digit:]+)$" +); + +// rust-enum-derive-0.4.0: r"^[:space:]*([[:alnum:]_]+)([:space:]*=[:space:]*([:graph:]+))?[:space:]*," +consistent!(rust_enum_derive_2, r"^[:space:]*([[:alnum:]_]+)([:space:]*=[:space:]*([:graph:]+))?[:space:]*,"); + +// rust-enum-derive-0.4.0: r"^#define[:space:]+([:graph:]+)[:space:]+([:graph:]+)" +consistent!( + rust_enum_derive_3, + r"^#define[:space:]+([:graph:]+)[:space:]+([:graph:]+)" +); + +// rustsourcebundler-0.2.0: r"^\s*pub mod (.+);$" +consistent!(rustsourcebundler_0, r"^\s*pub mod (.+);$"); + +// rustsourcebundler-0.2.0: r"^\s*pub mod (.+);$" +consistent!(rustsourcebundler_1, r"^\s*pub mod (.+);$"); + +// rustfmt-nightly-0.8.2: r"([^\\](\\\\)*)\\[\n\r][[:space:]]*" +consistent!(rustfmt_nightly_0, r"([^\\](\\\\)*)\\[\n\r][[:space:]]*"); + +// rustfmt-nightly-0.8.2: r"\s;" +consistent!(rustfmt_nightly_1, r"\s;"); + +// rustache-0.1.0: r"(?s)(.*?)([ \t\r\n]*)(\{\{(\{?\S?\s*?[\w\.\s]*.*?\s*?\}?)\}\})([ \t\r\n]*)" +consistent!(rustache_0, r"(?s)(.*?)([ \t\r\n]*)(\{\{(\{?\S?\s*?[\w\.\s]*.*?\s*?\}?)\}\})([ \t\r\n]*)"); + +// rustfilt-0.2.0: r"_ZN[\$\._[:alnum:]]*" +consistent!(rustfilt_0, r"_ZN[\$\._[:alnum:]]*"); + +// rustache-lists-0.1.2: r"(?s)(.*?)([ \t\r\n]*)(\{\{(\{?\S?\s*?[\w\.\s]*.*?\s*?\}?)\}\})([ \t\r\n]*)" +consistent!(rustache_lists_0, r"(?s)(.*?)([ \t\r\n]*)(\{\{(\{?\S?\s*?[\w\.\s]*.*?\s*?\}?)\}\})([ \t\r\n]*)"); + +// rural-0.7.3: "(.+)=(.+)" +consistent!(rural_0, "(.+)=(.+)"); + +// rural-0.7.3: "(.*):(.+)" +consistent!(rural_1, "(.*):(.+)"); + +// rural-0.7.3: "(.+):=(.+)" +consistent!(rural_2, "(.+):=(.+)"); + +// rural-0.7.3: "(.*)==(.+)" +consistent!(rural_3, "(.*)==(.+)"); + +// rusoto_credential-0.11.0: r"^\[([^\]]+)\]$" +consistent!(rusoto_credential_0, r"^\[([^\]]+)\]$"); + +// rumblebars-0.3.0: "([:blank:]*)$" +consistent!(rumblebars_0, "([:blank:]*)$"); + +// rumblebars-0.3.0: "(\r?\n)[:blank:]*(\\{\\{~?[#!/](?:\\}?[^}])*\\}\\})[:blank:]*(:?\r?\n)?\\z" +consistent!(rumblebars_1, "(\r?\n)[:blank:]*(\\{\\{~?[#!/](?:\\}?[^}])*\\}\\})[:blank:]*(:?\r?\n)?\\z"); + +// rumblebars-0.3.0: "(\r?\n[:blank:]*)(\\{\\{~?>(?:\\}?[^}])*\\}\\})[:blank:]*(:?\r?\n)?\\z" +consistent!( + rumblebars_2, + "(\r?\n[:blank:]*)(\\{\\{~?>(?:\\}?[^}])*\\}\\})[:blank:]*(:?\r?\n)?\\z" +); + +// rumblebars-0.3.0: "((?:[:blank:]|\r?\n)*)(\r?\n)[:blank:]*$" +consistent!(rumblebars_3, "((?:[:blank:]|\r?\n)*)(\r?\n)[:blank:]*$"); + +// rumblebars-0.3.0: "^([:blank:]*\r?\n)(.*)" +consistent!(rumblebars_4, "^([:blank:]*\r?\n)(.*)"); + +// diesel_cli-1.3.1: r"(?P<stamp>[\d-]*)_hello" +consistent!(diesel_cli_0, r"(?P<stamp>[\d-]*)_hello"); + +// dishub-0.1.1: r"(\d+)s" +consistent!(dishub_0, r"(\d+)s"); + +// spreadsheet_textconv-0.1.0: r"\n" +consistent!(spreadsheet_textconv_0, r"\n"); + +// spreadsheet_textconv-0.1.0: r"\r" +consistent!(spreadsheet_textconv_1, r"\r"); + +// spreadsheet_textconv-0.1.0: r"\t" +consistent!(spreadsheet_textconv_2, r"\t"); + +// split_aud-0.1.0: r"DELAY (-?\d+)ms" +consistent!(split_aud_0, r"DELAY (-?\d+)ms"); + +// split_aud-0.1.0: r"Trim\((\d+), ?(\d+)\)" +consistent!(split_aud_1, r"Trim\((\d+), ?(\d+)\)"); + +// spotrust-0.0.5: r"spotify:[a-z]+:[a-zA-Z0-9]+" +consistent!(spotrust_0, r"spotify:[a-z]+:[a-zA-Z0-9]+"); + +// spaceslugs-0.1.0: r"[^\x00-\x7F]" +consistent!(spaceslugs_0, r"[^\x00-\x7F]"); + +// spaceslugs-0.1.0: r"[']+" +consistent!(spaceslugs_1, r"[']+"); + +// spaceslugs-0.1.0: r"\W+" +consistent!(spaceslugs_2, r"\W+"); + +// spaceslugs-0.1.0: r"[ ]+" +consistent!(spaceslugs_3, r"[ ]+"); + +// space_email_api-0.1.1: "PHPSESSID=([0-9a-f]+)" +consistent!(space_email_api_0, "PHPSESSID=([0-9a-f]+)"); + +// lorikeet-0.7.0: "[^0-9.,]" +consistent!(lorikeet_0, "[^0-9.,]"); + +// claude-0.3.0: r"^(?:\b|(-)?)(\p{Currency_Symbol})?((?:(?:\d{1,3}[\.,])+\d{3})|\d+)(?:[\.,](\d{2}))?\b$" +consistent!(claude_0, r"^(?:\b|(-)?)(\p{Currency_Symbol})?((?:(?:\d{1,3}[\.,])+\d{3})|\d+)(?:[\.,](\d{2}))?\b$"); + +// clam-0.1.6: r"<%=\s*(.+?)\s*%>" +consistent!(clam_0, r"<%=\s*(.+?)\s*%>"); + +// classifier-0.0.3: r"(\s)" +consistent!(classifier_0, r"(\s)"); + +// click-0.3.2: r"(-----BEGIN .*-----\n)((?:(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)*\n)+)(-----END .*-----)" +consistent!(click_0, r"(-----BEGIN .*-----\n)((?:(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)*\n)+)(-----END .*-----)"); + +// click-0.3.2: r"-----BEGIN PRIVATE KEY-----" +consistent!(click_1, r"-----BEGIN PRIVATE KEY-----"); + +// ultrastar-txt-0.1.2: r"#([A-Z3a-z]*):(.*)" +consistent!(ultrastar_txt_0, r"#([A-Z3a-z]*):(.*)"); + +// ultrastar-txt-0.1.2: "^-\\s?(-?[0-9]+)\\s*$" +consistent!(ultrastar_txt_1, "^-\\s?(-?[0-9]+)\\s*$"); + +// ultrastar-txt-0.1.2: "^-\\s?(-?[0-9]+)\\s+(-?[0-9]+)" +consistent!(ultrastar_txt_2, "^-\\s?(-?[0-9]+)\\s+(-?[0-9]+)"); + +// ultrastar-txt-0.1.2: "^(.)\\s*(-?[0-9]+)\\s+(-?[0-9]+)\\s+(-?[0-9]+)\\s?(.*)" +consistent!( + ultrastar_txt_3, + "^(.)\\s*(-?[0-9]+)\\s+(-?[0-9]+)\\s+(-?[0-9]+)\\s?(.*)" +); + +// ultrastar-txt-0.1.2: "^P\\s?(-?[0-9]+)" +consistent!(ultrastar_txt_4, "^P\\s?(-?[0-9]+)"); + +// db-accelerate-2.0.0: r"^template\.add($|\..+$)" +consistent!(db_accelerate_0, r"^template\.add($|\..+$)"); + +// db-accelerate-2.0.0: r"^template\.sub($|\..+$)" +consistent!(db_accelerate_1, r"^template\.sub($|\..+$)"); + +// sterling-0.3.0: r"(\d+)([cegps])" +consistent!(sterling_0, r"(\d+)([cegps])"); + +// stache-0.2.0: r"[^\w]" +consistent!(stache_0, r"[^\w]"); + +// strukt-0.1.0: "\"([<>]?)([xcbB\\?hHiIlLqQfdspP]*)\"" +consistent!(strukt_0, "\"([<>]?)([xcbB\\?hHiIlLqQfdspP]*)\""); + +// steamid-ng-0.3.1: r"^STEAM_([0-4]):([0-1]):([0-9]{1,10})$" +consistent!(steamid_ng_0, r"^STEAM_([0-4]):([0-1]):([0-9]{1,10})$"); + +// steamid-ng-0.3.1: r"^\[([AGMPCgcLTIUai]):([0-4]):([0-9]{1,10})(:([0-9]+))?\]$" +consistent!( + steamid_ng_1, + r"^\[([AGMPCgcLTIUai]):([0-4]):([0-9]{1,10})(:([0-9]+))?\]$" +); + +// strscan-0.1.1: r"^\w+" +consistent!(strscan_0, r"^\w+"); + +// strscan-0.1.1: r"^\s+" +consistent!(strscan_1, r"^\s+"); + +// strscan-0.1.1: r"^\w+" +consistent!(strscan_2, r"^\w+"); + +// strscan-0.1.1: r"^\s+" +consistent!(strscan_3, r"^\s+"); + +// strscan-0.1.1: r"^(\w+)\s+" +consistent!(strscan_4, r"^(\w+)\s+"); + +// tk-carbon-0.2.0: r"^([a-zA-Z0-9\.-]+)(?:\s+(\d+))$" +consistent!(tk_carbon_0, r"^([a-zA-Z0-9\.-]+)(?:\s+(\d+))$"); + +// tk-carbon-0.2.0: r"^([a-zA-Z0-9\.-]+)(?:\s+(\d+))$" +consistent!(tk_carbon_1, r"^([a-zA-Z0-9\.-]+)(?:\s+(\d+))$"); + +// evalrs-0.0.10: r"extern\s+crate\s+([a-z0-9_]+)\s*;(\s*//(.+))?" +consistent!(evalrs_0, r"extern\s+crate\s+([a-z0-9_]+)\s*;(\s*//(.+))?"); + +// evalrs-0.0.10: r"(?m)^# " +consistent!(evalrs_1, r"(?m)^# "); + +// evalrs-0.0.10: r"(?m)^\s*fn +main *\( *\)" +consistent!(evalrs_2, r"(?m)^\s*fn +main *\( *\)"); + +// evalrs-0.0.10: r"(extern\s+crate\s+[a-z0-9_]+\s*;)" +consistent!(evalrs_3, r"(extern\s+crate\s+[a-z0-9_]+\s*;)"); + +// gate_build-0.5.0: "(.*)_t([0-9]+)" +consistent!(gate_build_0, "(.*)_t([0-9]+)"); + +// rake-0.1.1: r"[^\P{P}-]|\s+-\s+" +consistent!(rake_0, r"[^\P{P}-]|\s+-\s+"); + +// rafy-0.2.1: r"^.*(?:(?:youtu\.be/|v/|vi/|u/w/|embed/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*" +consistent!(rafy_0, r"^.*(?:(?:youtu\.be/|v/|vi/|u/w/|embed/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*"); + +// raven-0.2.1: r"^(?P<protocol>.*?)://(?P<public_key>.*?):(?P<secret_key>.*?)@(?P<host>.*?)/(?P<path>.*/)?(?P<project_id>.*)$" +consistent!(raven_0, r"^(?P<protocol>.*?)://(?P<public_key>.*?):(?P<secret_key>.*?)@(?P<host>.*?)/(?P<path>.*/)?(?P<project_id>.*)$"); + +// rargs-0.2.0: r"\{[[:space:]]*[^{}]*[[:space:]]*\}" +consistent!(rargs_0, r"\{[[:space:]]*[^{}]*[[:space:]]*\}"); + +// rargs-0.2.0: r"^\{[[:space:]]*(?P<name>[[:word:]]*)[[:space:]]*\}$" +consistent!(rargs_1, r"^\{[[:space:]]*(?P<name>[[:word:]]*)[[:space:]]*\}$"); + +// rargs-0.2.0: r"^\{[[:space:]]*(?P<num>-?\d+)[[:space:]]*\}$" +consistent!(rargs_2, r"^\{[[:space:]]*(?P<num>-?\d+)[[:space:]]*\}$"); + +// rargs-0.2.0: r"^\{(?P<left>-?\d*)?\.\.(?P<right>-?\d*)?(?::(?P<sep>.*))?\}$" +consistent!( + rargs_3, + r"^\{(?P<left>-?\d*)?\.\.(?P<right>-?\d*)?(?::(?P<sep>.*))?\}$" +); + +// rargs-0.2.0: r"(.*?)[[:space:]]+|(.*?)$" +consistent!(rargs_4, r"(.*?)[[:space:]]+|(.*?)$"); + +// indradb-lib-0.15.0: r"[a-zA-Z0-9]{8}" +consistent!(indradb_lib_0, r"[a-zA-Z0-9]{8}"); + +// fungi-lang-0.1.50: r"::" +consistent!(fungi_lang_0, r"::"); + +// nickel-0.10.1: "/hello/(?P<name>[a-zA-Z]+)" +consistent!(nickel_0, "/hello/(?P<name>[a-zA-Z]+)"); + +// nickel-0.10.1: "/hello/(?P<name>[a-zA-Z]+)" +consistent!(nickel_1, "/hello/(?P<name>[a-zA-Z]+)"); + +// pact_verifier-0.4.0: r"\{(\w+)\}" +consistent!(pact_verifier_0, r"\{(\w+)\}"); + +// pact_matching-0.4.1: "application/.*json" +consistent!(pact_matching_0, "application/.*json"); + +// pact_matching-0.4.1: "application/json.*" +consistent!(pact_matching_1, "application/json.*"); + +// pact_matching-0.4.1: "application/.*xml" +consistent!(pact_matching_2, "application/.*xml"); + +// pangu-0.2.0: "([\"'\\(\\[\\{{<\u{201c}])(\\s*)(.+?)(\\s*)([\"'\\)\\]\\}}>\u{201d}])" +consistent!( + pangu_0, + "([\"'\\(\\[\\{{<\u{201c}])(\\s*)(.+?)(\\s*)([\"'\\)\\]\\}}>\u{201d}])" +); + +// pangu-0.2.0: "([\\(\\[\\{{<\u{201c}]+)(\\s*)(.+?)(\\s*)([\\)\\]\\}}>\u{201d}]+)" +consistent!( + pangu_1, + "([\\(\\[\\{{<\u{201c}]+)(\\s*)(.+?)(\\s*)([\\)\\]\\}}>\u{201d}]+)" +); + +// parser-haskell-0.2.0: r"\{-[\s\S]*?-\}" +consistent!(parser_haskell_0, r"\{-[\s\S]*?-\}"); + +// parser-haskell-0.2.0: r"(?m);+\s*$" +consistent!(parser_haskell_1, r"(?m);+\s*$"); + +// parser-haskell-0.2.0: r"(?m)^#(if|ifn?def|endif|else|include|elif).*" +consistent!(parser_haskell_2, r"(?m)^#(if|ifn?def|endif|else|include|elif).*"); + +// parser-haskell-0.2.0: r"'([^'\\]|\\[A-Z]{1,3}|\\.)'" +consistent!(parser_haskell_3, r"'([^'\\]|\\[A-Z]{1,3}|\\.)'"); + +// parser-haskell-0.2.0: r"forall\s+(.*?)\." +consistent!(parser_haskell_4, r"forall\s+(.*?)\."); + +// html2md-0.2.1: "\\s{2,}" +consistent!(html2md_0, "\\s{2,}"); + +// html2md-0.2.1: "\\n{2,}" +consistent!(html2md_1, "\\n{2,}"); + +// html2md-0.2.1: "(?m)(\\S) $" +consistent!(html2md_2, "(?m)(\\S) $"); + +// html2md-0.2.1: "(?m)^[-*] " +consistent!(html2md_3, "(?m)^[-*] "); + +// ovpnfile-0.1.2: r"#.*$" +consistent!(ovpnfile_0, r"#.*$"); + +// ovpnfile-0.1.2: r"^<(\S+)>" +consistent!(ovpnfile_1, r"^<(\S+)>"); + +// ovpnfile-0.1.2: r"^</(\S+)>" +consistent!(ovpnfile_2, r"^</(\S+)>"); + +// screenruster-saver-fractal-0.1.1: r"#([:xdigit:]{2})([:xdigit:]{2})([:xdigit:]{2})" +consistent!( + screenruster_saver_fractal_0, + r"#([:xdigit:]{2})([:xdigit:]{2})([:xdigit:]{2})" +); + +// scarlet-0.2.2: r"rgb\((?: *(\d{1,3}),)(?: *(\d{1,3}),)(?: *(\d{1,3}))\)" +consistent!( + scarlet_0, + r"rgb\((?: *(\d{1,3}),)(?: *(\d{1,3}),)(?: *(\d{1,3}))\)" +); + +// cpp_to_rust_generator-0.2.0: r"^([\w:]+)<(.+)>$" +consistent!(cpp_to_rust_generator_0, r"^([\w:]+)<(.+)>$"); + +// cpp_to_rust_generator-0.2.0: r"^type-parameter-(\d+)-(\d+)$" +consistent!(cpp_to_rust_generator_1, r"^type-parameter-(\d+)-(\d+)$"); + +// cpp_to_rust_generator-0.2.0: r"^([\w~]+)<[^<>]+>$" +consistent!(cpp_to_rust_generator_2, r"^([\w~]+)<[^<>]+>$"); + +// cpp_to_rust_generator-0.2.0: r"(signals|Q_SIGNALS)\s*:" +consistent!(cpp_to_rust_generator_3, r"(signals|Q_SIGNALS)\s*:"); + +// cpp_to_rust_generator-0.2.0: r"(slots|Q_SLOTS)\s*:" +consistent!(cpp_to_rust_generator_4, r"(slots|Q_SLOTS)\s*:"); + +// cpp_to_rust_generator-0.2.0: r"(public|protected|private)\s*:" +consistent!(cpp_to_rust_generator_5, r"(public|protected|private)\s*:"); + +// cpp_to_rust-0.5.3: r"^([\w:]+)<(.+)>$" +consistent!(cpp_to_rust_0, r"^([\w:]+)<(.+)>$"); + +// cpp_to_rust-0.5.3: r"^type-parameter-(\d+)-(\d+)$" +consistent!(cpp_to_rust_1, r"^type-parameter-(\d+)-(\d+)$"); + +// cpp_to_rust-0.5.3: r"^([\w~]+)<[^<>]+>$" +consistent!(cpp_to_rust_2, r"^([\w~]+)<[^<>]+>$"); + +// cpp_to_rust-0.5.3: r"(signals|Q_SIGNALS)\s*:" +consistent!(cpp_to_rust_3, r"(signals|Q_SIGNALS)\s*:"); + +// cpp_to_rust-0.5.3: r"(slots|Q_SLOTS)\s*:" +consistent!(cpp_to_rust_4, r"(slots|Q_SLOTS)\s*:"); + +// cpp_to_rust-0.5.3: r"(public|protected|private)\s*:" +consistent!(cpp_to_rust_5, r"(public|protected|private)\s*:"); + +// fritzbox_logs-0.2.0: "(\\d{2}\\.\\d{2}\\.\\d{2}) (\\d{2}:\\d{2}:\\d{2}) (.*)" +consistent!( + fritzbox_logs_0, + "(\\d{2}\\.\\d{2}\\.\\d{2}) (\\d{2}:\\d{2}:\\d{2}) (.*)" +); + +// fractal-matrix-api-3.29.0: r"mxc://(?P<server>[^/]+)/(?P<media>.+)" +consistent!(fractal_matrix_api_0, r"mxc://(?P<server>[^/]+)/(?P<media>.+)"); + +// smtp2go-0.1.4: r"^api-[a-zA-Z0-9]{32}$" +consistent!(smtp2go_0, r"^api-[a-zA-Z0-9]{32}$"); + +// pusher-0.3.1: r"^[-a-zA-Z0-9_=@,.;]+$" +consistent!(pusher_0, r"^[-a-zA-Z0-9_=@,.;]+$"); + +// pusher-0.3.1: r"\A\d+\.\d+\z" +consistent!(pusher_1, r"\A\d+\.\d+\z"); + +// bakervm-0.9.0: r"^\.(.+?) +?(.+)$" +consistent!(bakervm_0, r"^\.(.+?) +?(.+)$"); + +// bakervm-0.9.0: r"^\.([^\s]+)$" +consistent!(bakervm_1, r"^\.([^\s]+)$"); + +// bakervm-0.9.0: r"^include! +([^\s]+)$" +consistent!(bakervm_2, r"^include! +([^\s]+)$"); + +// bakervm-0.9.0: r"^@(\d+)$" +consistent!(bakervm_3, r"^@(\d+)$"); + +// bakervm-0.9.0: r"^true|false$" +consistent!(bakervm_4, r"^true|false$"); + +// bakervm-0.9.0: r"^(-?\d+)?\.[0-9]+$" +consistent!(bakervm_5, r"^(-?\d+)?\.[0-9]+$"); + +// bakervm-0.9.0: r"^(-?\d+)?$" +consistent!(bakervm_6, r"^(-?\d+)?$"); + +// bakervm-0.9.0: r"^#([0-9abcdefABCDEF]{6})$" +consistent!(bakervm_7, r"^#([0-9abcdefABCDEF]{6})$"); + +// bakervm-0.9.0: r"^'(.)'$" +consistent!(bakervm_8, r"^'(.)'$"); + +// bakervm-0.9.0: r"^\$vi\((\d+)\)$" +consistent!(bakervm_9, r"^\$vi\((\d+)\)$"); + +// bakervm-0.9.0: r"^\$key\((\d+)\)$" +consistent!(bakervm_10, r"^\$key\((\d+)\)$"); + +// banana-0.0.2: "(?P<type>[A-Z^']+) (?P<route>[^']+) HTTP/(?P<http>[^']+)" +consistent!( + banana_0, + "(?P<type>[A-Z^']+) (?P<route>[^']+) HTTP/(?P<http>[^']+)" +); + +// serial-key-2.0.0: r"[A-F0-9]{8}" +consistent!(serial_key_0, r"[A-F0-9]{8}"); + +// serde-hjson-0.8.1: "[\\\\\"\x00-\x1f\x7f-\u{9f}\u{00ad}\u{0600}-\u{0604}\u{070f}\u{17b4}\u{17b5}\u{200c}-\u{200f}\u{2028}-\u{202f}\u{2060}-\u{206f}\u{feff}\u{fff0}-\u{ffff}]" +consistent!(serde_hjson_0, "[\\\\\"\x00-\x1f\x7f-\u{9f}\u{00ad}\u{0600}-\u{0604}\u{070f}\u{17b4}\u{17b5}\u{200c}-\u{200f}\u{2028}-\u{202f}\u{2060}-\u{206f}\u{feff}\u{fff0}-\u{ffff}]"); + +// serde-hjson-0.8.1: "[\x00-\x1f\x7f-\u{9f}\u{00ad}\u{0600}-\u{0604}\u{070f}\u{17b4}\u{17b5}\u{200c}-\u{200f}\u{2028}-\u{202f}\u{2060}-\u{206f}\u{feff}\u{fff0}-\u{ffff}]" +consistent!(serde_hjson_1, "[\x00-\x1f\x7f-\u{9f}\u{00ad}\u{0600}-\u{0604}\u{070f}\u{17b4}\u{17b5}\u{200c}-\u{200f}\u{2028}-\u{202f}\u{2060}-\u{206f}\u{feff}\u{fff0}-\u{ffff}]"); + +// serde-hjson-0.8.1: "'''|[\x00-\x09\x0b\x0c\x0e-\x1f\x7f-\u{9f}\u{00ad}\u{0600}-\u{0604}\u{070f}\u{17b4}\u{17b5}\u{200c}-\u{200f}\u{2028}-\u{202f}\u{2060}-\u{206f}\u{feff}\u{fff0}-\u{ffff}]" +consistent!(serde_hjson_2, "'''|[\x00-\x09\x0b\x0c\x0e-\x1f\x7f-\u{9f}\u{00ad}\u{0600}-\u{0604}\u{070f}\u{17b4}\u{17b5}\u{200c}-\u{200f}\u{2028}-\u{202f}\u{2060}-\u{206f}\u{feff}\u{fff0}-\u{ffff}]"); + +// serde-odbc-0.1.0: r"/todos/(?P<id>\d+)" +consistent!(serde_odbc_0, r"/todos/(?P<id>\d+)"); + +// sentry-0.6.0: r"^(?:_<)?([a-zA-Z0-9_]+?)(?:\.\.|::)" +consistent!(sentry_0, r"^(?:_<)?([a-zA-Z0-9_]+?)(?:\.\.|::)"); + +// sentiment-0.1.1: r"[^a-zA-Z0 -]+" +consistent!(sentiment_0, r"[^a-zA-Z0 -]+"); + +// sentiment-0.1.1: r" {2,}" +consistent!(sentiment_1, r" {2,}"); + +// verilog-0.0.1: r"(?m)//.*" +consistent!(verilog_0, r"(?m)//.*"); + +// verex-0.2.2: "(?P<robot>C3PO)" +consistent!(verex_0, "(?P<robot>C3PO)"); + +// handlebars-0.32.4: ">|<|\"|&" +consistent!(handlebars_0, ">|<|\"|&"); + +// haikunator-0.1.2: r"^\w+-\w+-[0123456789]{4}$" +consistent!(haikunator_0, r"^\w+-\w+-[0123456789]{4}$"); + +// haikunator-0.1.2: r"^\w+@\w+@[0123456789]{4}$" +consistent!(haikunator_1, r"^\w+@\w+@[0123456789]{4}$"); + +// haikunator-0.1.2: r"^\w+-\w+-[0123456789abcdef]{4}$" +consistent!(haikunator_2, r"^\w+-\w+-[0123456789abcdef]{4}$"); + +// haikunator-0.1.2: r"^\w+-\w+-[0123456789忠犬ハチ公]{10}$" +consistent!(haikunator_3, r"^\w+-\w+-[0123456789忠犬ハチ公]{10}$"); + +// haikunator-0.1.2: r"^\w+-\w+$" +consistent!(haikunator_4, r"^\w+-\w+$"); + +// haikunator-0.1.2: r"^\w+-\w+-[foo]{4}$" +consistent!(haikunator_5, r"^\w+-\w+-[foo]{4}$"); + +// haikunator-0.1.2: r"^\w+-\w+-[0123456789忠犬ハチ公]{5}$" +consistent!(haikunator_6, r"^\w+-\w+-[0123456789忠犬ハチ公]{5}$"); + +// bobbin-cli-0.8.3: r"(.*)" +consistent!(bobbin_cli_0, r"(.*)"); + +// bobbin-cli-0.8.3: r"rustc (.*)" +consistent!(bobbin_cli_1, r"rustc (.*)"); + +// bobbin-cli-0.8.3: r"cargo (.*)" +consistent!(bobbin_cli_2, r"cargo (.*)"); + +// bobbin-cli-0.8.3: r"xargo (.*)\n" +consistent!(bobbin_cli_3, r"xargo (.*)\n"); + +// bobbin-cli-0.8.3: r"Open On-Chip Debugger (.*)" +consistent!(bobbin_cli_4, r"Open On-Chip Debugger (.*)"); + +// bobbin-cli-0.8.3: r"arm-none-eabi-gcc \(GNU Tools for ARM Embedded Processors[^\)]*\) (.*)" +consistent!( + bobbin_cli_5, + r"arm-none-eabi-gcc \(GNU Tools for ARM Embedded Processors[^\)]*\) (.*)" +); + +// bobbin-cli-0.8.3: r"(?m).*\nBasic Open Source SAM-BA Application \(BOSSA\) Version (.*)\n" +consistent!( + bobbin_cli_6, + r"(?m).*\nBasic Open Source SAM-BA Application \(BOSSA\) Version (.*)\n" +); + +// bobbin-cli-0.8.3: r"(?m)SEGGER J-Link Commander (.*)\n" +consistent!(bobbin_cli_7, r"(?m)SEGGER J-Link Commander (.*)\n"); + +// bobbin-cli-0.8.3: r"(?m)Teensy Loader, Command Line, Version (.*)\n" +consistent!(bobbin_cli_8, r"(?m)Teensy Loader, Command Line, Version (.*)\n"); + +// bobbin-cli-0.8.3: r"dfu-util (.*)\n" +consistent!(bobbin_cli_9, r"dfu-util (.*)\n"); + +// borsholder-0.9.1: r"^/static/[\w.]+$" +consistent!(borsholder_0, r"^/static/[\w.]+$"); + +// borsholder-0.9.1: r"^/timeline/([0-9]+)$" +consistent!(borsholder_1, r"^/timeline/([0-9]+)$"); + +// fblog-1.0.1: "\u{001B}\\[[\\d;]*[^\\d;]" +consistent!(fblog_0, "\u{001B}\\[[\\d;]*[^\\d;]"); + +// fblog-1.0.1: "\u{001B}\\[[\\d;]*[^\\d;]" +consistent!(fblog_1, "\u{001B}\\[[\\d;]*[^\\d;]"); + +// toml-query-0.6.0: r"^\[\d+\]$" +consistent!(toml_query_0, r"^\[\d+\]$"); + +// todo-txt-1.1.0: r" (?P<key>[^\s]+):(?P<value>[^\s^/]+)" +consistent!(todo_txt_0, r" (?P<key>[^\s]+):(?P<value>[^\s^/]+)"); + +// findr-0.1.5: r"\band\b" +consistent!(findr_0, r"\band\b"); + +// findr-0.1.5: r"\bor\b" +consistent!(findr_1, r"\bor\b"); + +// findr-0.1.5: r"\bnot\b" +consistent!(findr_2, r"\bnot\b"); + +// file-sniffer-3.0.1: r".*?\.(a|la|lo|o|ll|keter|bc|dyn_o|out|d|rlib|crate|min\.js|hi|dyn_hi|S|jsexe|webapp|js\.externs|ibc|toc|aux|fdb_latexmk|fls|egg-info|whl|js_a|js_hi|jld|ji|js_o|so.*|dump-.*|vmb|crx|orig|elmo|elmi|pyc|mod|p_hi|p_o|prof|tix)$" +consistent!(file_sniffer_0, r".*?\.(a|la|lo|o|ll|keter|bc|dyn_o|out|d|rlib|crate|min\.js|hi|dyn_hi|S|jsexe|webapp|js\.externs|ibc|toc|aux|fdb_latexmk|fls|egg-info|whl|js_a|js_hi|jld|ji|js_o|so.*|dump-.*|vmb|crx|orig|elmo|elmi|pyc|mod|p_hi|p_o|prof|tix)$"); + +// file-sniffer-3.0.1: r".*?\.(stats|conf|h|cache.*|dat|pc|info)$" +consistent!(file_sniffer_1, r".*?\.(stats|conf|h|cache.*|dat|pc|info)$"); + +// file-sniffer-3.0.1: r".*?\.(exe|a|la|o|ll|keter|bc|dyn_o|out|d|rlib|crate|min\.js|hi|dyn_hi|jsexe|webapp|js\.externs|ibc|toc|aux|fdb_latexmk|fls|egg-info|whl|js_a|js_hi|jld|ji|js_o|so.*|dump-.*|vmb|crx|orig|elmo|elmi|pyc|mod|p_hi|p_o|prof|tix)$" +consistent!(file_sniffer_2, r".*?\.(exe|a|la|o|ll|keter|bc|dyn_o|out|d|rlib|crate|min\.js|hi|dyn_hi|jsexe|webapp|js\.externs|ibc|toc|aux|fdb_latexmk|fls|egg-info|whl|js_a|js_hi|jld|ji|js_o|so.*|dump-.*|vmb|crx|orig|elmo|elmi|pyc|mod|p_hi|p_o|prof|tix)$"); + +// file-sniffer-3.0.1: r".*?\.(stats|conf|h|cache.*)$" +consistent!(file_sniffer_3, r".*?\.(stats|conf|h|cache.*)$"); + +// file-sniffer-3.0.1: r"(\.git|\.pijul|_darcs|\.hg)$" +consistent!(file_sniffer_4, r"(\.git|\.pijul|_darcs|\.hg)$"); + +// file_logger-0.1.0: "test" +consistent!(file_logger_0, "test"); + +// file_scanner-0.2.0: r"foo" +consistent!(file_scanner_0, r"foo"); + +// file_scanner-0.2.0: r"a+b" +consistent!(file_scanner_1, r"a+b"); + +// file_scanner-0.2.0: r"a[ab]*b" +consistent!(file_scanner_2, r"a[ab]*b"); + +// file_scanner-0.2.0: r"\s+" +consistent!(file_scanner_3, r"\s+"); + +// file_scanner-0.2.0: r"\s+" +consistent!(file_scanner_4, r"\s+"); + +// cellsplit-0.2.1: r"^\s*([^\s]+) %cellsplit<\d+>$" +consistent!(cellsplit_0, r"^\s*([^\s]+) %cellsplit<\d+>$"); + +// cellsplit-0.2.1: r"^\s*([^\s]+) %cellsplit<\d+>$" +consistent!(cellsplit_1, r"^\s*([^\s]+) %cellsplit<\d+>$"); + +// aterm-0.20.0: r"^[+\-]?[0-9]+" +consistent!(aterm_0, r"^[+\-]?[0-9]+"); + +// aterm-0.20.0: r"^[+\-]?[0-9]+\.[0-9]*([eE][+\-]?[0-9]+)?" +consistent!(aterm_1, r"^[+\-]?[0-9]+\.[0-9]*([eE][+\-]?[0-9]+)?"); + +// atarashii_imap-0.3.0: r"^[*] OK" +consistent!(atarashii_imap_0, r"^[*] OK"); + +// atarashii_imap-0.3.0: r"FLAGS\s\((.+)\)" +consistent!(atarashii_imap_1, r"FLAGS\s\((.+)\)"); + +// atarashii_imap-0.3.0: r"\[PERMANENTFLAGS\s\((.+)\)\]" +consistent!(atarashii_imap_2, r"\[PERMANENTFLAGS\s\((.+)\)\]"); + +// atarashii_imap-0.3.0: r"\[UIDVALIDITY\s(\d+)\]" +consistent!(atarashii_imap_3, r"\[UIDVALIDITY\s(\d+)\]"); + +// atarashii_imap-0.3.0: r"(\d+)\sEXISTS" +consistent!(atarashii_imap_4, r"(\d+)\sEXISTS"); + +// atarashii_imap-0.3.0: r"(\d+)\sRECENT" +consistent!(atarashii_imap_5, r"(\d+)\sRECENT"); + +// atarashii_imap-0.3.0: r"\[UNSEEN\s(\d+)\]" +consistent!(atarashii_imap_6, r"\[UNSEEN\s(\d+)\]"); + +// atarashii_imap-0.3.0: r"\[UIDNEXT\s(\d+)\]" +consistent!(atarashii_imap_7, r"\[UIDNEXT\s(\d+)\]"); + +// editorconfig-1.0.0: r"\\(\{|\})" +consistent!(editorconfig_0, r"\\(\{|\})"); + +// editorconfig-1.0.0: r"(^|[^\\])\\\|" +consistent!(editorconfig_1, r"(^|[^\\])\\\|"); + +// editorconfig-1.0.0: r"\[([^\]]*)$" +consistent!(editorconfig_2, r"\[([^\]]*)$"); + +// editorconfig-1.0.0: r"\[(.*/.*)\]" +consistent!(editorconfig_3, r"\[(.*/.*)\]"); + +// editorconfig-1.0.0: r"\{(-?\d+\\\.\\\.-?\d+)\}" +consistent!(editorconfig_4, r"\{(-?\d+\\\.\\\.-?\d+)\}"); + +// editorconfig-1.0.0: r"\{([^,]+)\}" +consistent!(editorconfig_5, r"\{([^,]+)\}"); + +// editorconfig-1.0.0: r"\{(([^\}].*)?(,|\|)(.*[^\\])?)\}" +consistent!(editorconfig_6, r"\{(([^\}].*)?(,|\|)(.*[^\\])?)\}"); + +// editorconfig-1.0.0: r"^/" +consistent!(editorconfig_7, r"^/"); + +// editorconfig-1.0.0: r"(^|[^\\])(\{|\})" +consistent!(editorconfig_8, r"(^|[^\\])(\{|\})"); + +// edmunge-1.0.0: "^#!.*\n" +consistent!(edmunge_0, "^#!.*\n"); + +// unicode_names2_macros-0.2.0: r"\\N\{(.*?)(?:\}|$)" +consistent!(unicode_names2_macros_0, r"\\N\{(.*?)(?:\}|$)"); + +// unidiff-0.2.1: r"^--- (?P<filename>[^\t\n]+)(?:\t(?P<timestamp>[^\n]+))?" +consistent!( + unidiff_0, + r"^--- (?P<filename>[^\t\n]+)(?:\t(?P<timestamp>[^\n]+))?" +); + +// unidiff-0.2.1: r"^\+\+\+ (?P<filename>[^\t\n]+)(?:\t(?P<timestamp>[^\n]+))?" +consistent!( + unidiff_1, + r"^\+\+\+ (?P<filename>[^\t\n]+)(?:\t(?P<timestamp>[^\n]+))?" +); + +// unidiff-0.2.1: r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@[ ]?(.*)" +consistent!(unidiff_2, r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@[ ]?(.*)"); + +// unidiff-0.2.1: r"^(?P<line_type>[- \n\+\\]?)(?P<value>.*)" +consistent!(unidiff_3, r"^(?P<line_type>[- \n\+\\]?)(?P<value>.*)"); + +// slippy-map-tiles-0.13.1: "/?(?P<zoom>[0-9]?[0-9])/(?P<x>[0-9]{1,10})/(?P<y>[0-9]{1,10})(\\.[a-zA-Z]{3,4})?$" +consistent!(slippy_map_tiles_0, "/?(?P<zoom>[0-9]?[0-9])/(?P<x>[0-9]{1,10})/(?P<y>[0-9]{1,10})(\\.[a-zA-Z]{3,4})?$"); + +// slippy-map-tiles-0.13.1: r"^(?P<minlon>-?[0-9]{1,3}(\.[0-9]{1,10})?) (?P<minlat>-?[0-9]{1,3}(\.[0-9]{1,10})?) (?P<maxlon>-?[0-9]{1,3}(\.[0-9]{1,10})?) (?P<maxlat>-?[0-9]{1,3}(\.[0-9]{1,10})?)$" +consistent!(slippy_map_tiles_1, r"^(?P<minlon>-?[0-9]{1,3}(\.[0-9]{1,10})?) (?P<minlat>-?[0-9]{1,3}(\.[0-9]{1,10})?) (?P<maxlon>-?[0-9]{1,3}(\.[0-9]{1,10})?) (?P<maxlat>-?[0-9]{1,3}(\.[0-9]{1,10})?)$"); + +// slippy-map-tiles-0.13.1: r"^(?P<minlon>-?[0-9]{1,3}(\.[0-9]{1,10})?),(?P<minlat>-?[0-9]{1,3}(\.[0-9]{1,10})?),(?P<maxlon>-?[0-9]{1,3}(\.[0-9]{1,10})?),(?P<maxlat>-?[0-9]{1,3}(\.[0-9]{1,10})?)$" +consistent!(slippy_map_tiles_2, r"^(?P<minlon>-?[0-9]{1,3}(\.[0-9]{1,10})?),(?P<minlat>-?[0-9]{1,3}(\.[0-9]{1,10})?),(?P<maxlon>-?[0-9]{1,3}(\.[0-9]{1,10})?),(?P<maxlat>-?[0-9]{1,3}(\.[0-9]{1,10})?)$"); + +// sonos-0.1.2: r"^https?://(.+?):1400/xml" +consistent!(sonos_0, r"^https?://(.+?):1400/xml"); + +// validator_derive-0.7.0: r"^[a-z]{2}$" +consistent!(validator_derive_0, r"^[a-z]{2}$"); + +// validator_derive-0.7.0: r"[a-z]{2}" +consistent!(validator_derive_1, r"[a-z]{2}"); + +// validator_derive-0.7.0: r"[a-z]{2}" +consistent!(validator_derive_2, r"[a-z]{2}"); + +// nginx-config-0.8.0: r"one of \d+ options" +consistent!(nginx_config_0, r"one of \d+ options"); + +// waltz-0.4.0: r"[\s,]" +consistent!(waltz_0, r"[\s,]"); + +// warheadhateus-0.2.1: r"^aws_access_key_id = (.*)" +consistent!(warheadhateus_0, r"^aws_access_key_id = (.*)"); + +// warheadhateus-0.2.1: r"^aws_secret_access_key = (.*)" +consistent!(warheadhateus_1, r"^aws_secret_access_key = (.*)"); + +// warheadhateus-0.2.1: r"^aws_access_key_id = (.*)" +consistent!(warheadhateus_2, r"^aws_access_key_id = (.*)"); + +// warheadhateus-0.2.1: r"^aws_secret_access_key = (.*)" +consistent!(warheadhateus_3, r"^aws_secret_access_key = (.*)"); + +// jieba-rs-0.2.2: r"([\u{4E00}-\u{9FD5}a-zA-Z0-9+#&\._%]+)" +consistent!(jieba_rs_0, r"([\u{4E00}-\u{9FD5}a-zA-Z0-9+#&\._%]+)"); + +// jieba-rs-0.2.2: r"(\r\n|\s)" +consistent!(jieba_rs_1, r"(\r\n|\s)"); + +// jieba-rs-0.2.2: "([\u{4E00}-\u{9FD5}]+)" +consistent!(jieba_rs_2, "([\u{4E00}-\u{9FD5}]+)"); + +// jieba-rs-0.2.2: r"[^a-zA-Z0-9+#\n]" +consistent!(jieba_rs_3, r"[^a-zA-Z0-9+#\n]"); + +// jieba-rs-0.2.2: r"([\u{4E00}-\u{9FD5}]+)" +consistent!(jieba_rs_4, r"([\u{4E00}-\u{9FD5}]+)"); + +// jieba-rs-0.2.2: r"([a-zA-Z0-9]+(?:.\d+)?%?)" +consistent!(jieba_rs_5, r"([a-zA-Z0-9]+(?:.\d+)?%?)"); + +// lalrpop-0.15.2: r"Span\([0-9 ,]*\)" +consistent!(lalrpop_0, r"Span\([0-9 ,]*\)"); + +// lalrpop-snap-0.15.2: r"Span\([0-9 ,]*\)" +consistent!(lalrpop_snap_0, r"Span\([0-9 ,]*\)"); + +// nlp-tokenize-0.1.0: r"[\S]+" +consistent!(nlp_tokenize_0, r"[\S]+"); + +// kbgpg-0.1.2: "[[:xdigit:]][70]" +consistent!(kbgpg_0, "[[:xdigit:]][70]"); + +// cdbd-0.1.1: r"^((?P<address>.*):)?(?P<port>\d+)$" +consistent!(cdbd_0, r"^((?P<address>.*):)?(?P<port>\d+)$"); + +// mbutiles-0.1.1: r"[\w\s=+-/]+\((\{(.|\n)*\})\);?" +consistent!(mbutiles_0, r"[\w\s=+-/]+\((\{(.|\n)*\})\);?"); + +// extrahop-0.2.5: r"^-\d+(?:ms|s|m|h|d|w|y)?$" +consistent!(extrahop_0, r"^-\d+(?:ms|s|m|h|d|w|y)?$"); + +// pippin-0.1.0: "^((?:.*)-)?ss(0|[1-9][0-9]*)\\.pip$" +consistent!(pippin_0, "^((?:.*)-)?ss(0|[1-9][0-9]*)\\.pip$"); + +// pippin-0.1.0: "^((?:.*)-)?ss(0|[1-9][0-9]*)-cl(0|[1-9][0-9]*)\\.piplog$" +consistent!( + pippin_1, + "^((?:.*)-)?ss(0|[1-9][0-9]*)-cl(0|[1-9][0-9]*)\\.piplog$" +); + +// pippin-0.1.0: "^((?:.*)-)?ss(0|[1-9][0-9]*)\\.pip$" +consistent!(pippin_2, "^((?:.*)-)?ss(0|[1-9][0-9]*)\\.pip$"); + +// pippin-0.1.0: "^((?:.*)-)?ss(0|[1-9][0-9]*)-cl(0|[1-9][0-9]*)\\.piplog$" +consistent!( + pippin_3, + "^((?:.*)-)?ss(0|[1-9][0-9]*)-cl(0|[1-9][0-9]*)\\.piplog$" +); + +// pippin-0.1.0: "^.*pn(0|[1-9][0-9]*)(-ss(0|[1-9][0-9]*)(\\.pip|-cl(0|[1-9][0-9]*)\\.piplog))?$" +consistent!(pippin_4, "^.*pn(0|[1-9][0-9]*)(-ss(0|[1-9][0-9]*)(\\.pip|-cl(0|[1-9][0-9]*)\\.piplog))?$"); + +// pippin-0.1.0: "^(.*)-ss(?:0|[1-9][0-9]*)(?:\\.pip|-cl(?:0|[1-9][0-9]*)\\.piplog)$" +consistent!( + pippin_5, + "^(.*)-ss(?:0|[1-9][0-9]*)(?:\\.pip|-cl(?:0|[1-9][0-9]*)\\.piplog)$" +); + +// pinyin-0.3.0: r"(?i)[āáǎàēéěèōóǒòīíǐìūúǔùüǘǚǜńň]" +consistent!( + pinyin_0, + r"(?i)[āáǎàēéěèōóǒòīíǐìūúǔùüǘǚǜńň]" +); + +// pinyin-0.3.0: r"([aeoiuvnm])([0-4])$" +consistent!(pinyin_1, r"([aeoiuvnm])([0-4])$"); + +// duration-parser-0.2.0: r"(?P<value>\d+)(?P<units>[a-z])" +consistent!(duration_parser_0, r"(?P<value>\d+)(?P<units>[a-z])"); + +// dutree-0.2.7: r"^\d+\D?$" +consistent!(dutree_0, r"^\d+\D?$"); + +// djangohashers-0.3.0: r"^[A-Za-z0-9]*$" +consistent!(djangohashers_0, r"^[A-Za-z0-9]*$"); + +// rtag-0.3.5: r"^[A-Z][A-Z0-9]{2,}$" +consistent!(rtag_0, r"^[A-Z][A-Z0-9]{2,}$"); + +// rtag-0.3.5: r"^http://www\.emusic\.com" +consistent!(rtag_1, r"^http://www\.emusic\.com"); + +// rtag-0.3.5: r"^[A-Z][A-Z0-9]{2,}" +consistent!(rtag_2, r"^[A-Z][A-Z0-9]{2,}"); + +// rtag-0.3.5: r"(^[\x{0}|\x{feff}|\x{fffe}]*|[\x{0}|\x{feff}|\x{fffe}]*$)" +consistent!( + rtag_3, + r"(^[\x{0}|\x{feff}|\x{fffe}]*|[\x{0}|\x{feff}|\x{fffe}]*$)" +); + +// rtow-0.1.0: r"(\d+)[xX](\d+)" +consistent!(rtow_0, r"(\d+)[xX](\d+)"); + +// pleingres-sql-plugin-0.1.0: r"\$([a-zA-Z0-9_]+)" +consistent!(pleingres_sql_plugin_0, r"\$([a-zA-Z0-9_]+)"); + +// dono-2.0.0: "[\\n]+" +consistent!(dono_0, "[\\n]+"); + +// dono-2.0.0: "(?m)^\\n" +consistent!(dono_1, "(?m)^\\n"); + +// dono-2.0.0: "(?m)^\\n" +consistent!(dono_2, "(?m)^\\n"); + +// ssb-common-0.3.0: r"^[0-9A-Za-z\+/]{43}=\.ed25519$" +consistent!(ssb_common_0, r"^[0-9A-Za-z\+/]{43}=\.ed25519$"); + +// ssb-common-0.3.0: r"^[0-9A-Za-z\+/]{86}==\.ed25519$" +consistent!(ssb_common_1, r"^[0-9A-Za-z\+/]{86}==\.ed25519$"); + +// ssb-common-0.3.0: r"^[0-9A-Za-z\+/]{43}=\.sha256$" +consistent!(ssb_common_2, r"^[0-9A-Za-z\+/]{43}=\.sha256$"); + +// mozversion-0.1.3: r"^(?P<major>\d+)\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?(?:(?P<pre0>[a-z]+)(?P<pre1>\d*))?$" +consistent!(mozversion_0, r"^(?P<major>\d+)\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?(?:(?P<pre0>[a-z]+)(?P<pre1>\d*))?$"); + +// monger-0.5.6: r"^(\d+)\.(\d+)$" +consistent!(monger_0, r"^(\d+)\.(\d+)$"); + +// mongo_rub-0.0.2: r"^[rv]2\.6" +consistent!(mongo_rub_0, r"^[rv]2\.6"); + +// flow-0.3.5: "body value" +consistent!(flow_0, "body value"); + +// flow-0.3.5: "start marker" +consistent!(flow_1, "start marker"); + +// flow-0.3.5: "end marker" +consistent!(flow_2, "end marker"); + +// flow-0.3.5: "body value" +consistent!(flow_3, "body value"); + +// vobsub-0.2.3: "^([A-Za-z/ ]+): (.*)" +consistent!(vobsub_0, "^([A-Za-z/ ]+): (.*)"); + +// voidmap-1.1.2: r"#([^\s=]+)*" +consistent!(voidmap_0, r"#([^\s=]+)*"); + +// voidmap-1.1.2: r"#(\S+)*" +consistent!(voidmap_1, r"#(\S+)*"); + +// voidmap-1.1.2: r"#prio=(\d+)" +consistent!(voidmap_2, r"#prio=(\d+)"); + +// voidmap-1.1.2: r"\[(\S+)\]" +consistent!(voidmap_3, r"\[(\S+)\]"); + +// voidmap-1.1.2: r"#limit=(\d+)" +consistent!(voidmap_4, r"#limit=(\d+)"); + +// voidmap-1.1.2: r"#tagged=(\S+)" +consistent!(voidmap_5, r"#tagged=(\S+)"); + +// voidmap-1.1.2: r"#rev\b" +consistent!(voidmap_6, r"#rev\b"); + +// voidmap-1.1.2: r"#done\b" +consistent!(voidmap_7, r"#done\b"); + +// voidmap-1.1.2: r"#open\b" +consistent!(voidmap_8, r"#open\b"); + +// voidmap-1.1.2: r"#since=(\S+)" +consistent!(voidmap_9, r"#since=(\S+)"); + +// voidmap-1.1.2: r"#until=(\S+)" +consistent!(voidmap_10, r"#until=(\S+)"); + +// voidmap-1.1.2: r"#plot=(\S+)" +consistent!(voidmap_11, r"#plot=(\S+)"); + +// voidmap-1.1.2: r"#n=(\d+)" +consistent!(voidmap_12, r"#n=(\d+)"); + +// voidmap-1.1.2: r"(\S+)" +consistent!(voidmap_13, r"(\S+)"); + +// voidmap-1.1.2: r"(?P<y>\d+)y" +consistent!(voidmap_14, r"(?P<y>\d+)y"); + +// voidmap-1.1.2: r"(?P<m>\d+)m" +consistent!(voidmap_15, r"(?P<m>\d+)m"); + +// voidmap-1.1.2: r"(?P<w>\d+)w" +consistent!(voidmap_16, r"(?P<w>\d+)w"); + +// voidmap-1.1.2: r"(?P<d>\d+)d" +consistent!(voidmap_17, r"(?P<d>\d+)d"); + +// voidmap-1.1.2: r"(?P<h>\d+)h" +consistent!(voidmap_18, r"(?P<h>\d+)h"); + +// voidmap-1.1.2: r"C-(.)" +consistent!(voidmap_19, r"C-(.)"); + +// qt_generator-0.2.0: r"^\.\./qt[^/]+/" +consistent!(qt_generator_0, r"^\.\./qt[^/]+/"); + +// qt_generator-0.2.0: "(href|src)=\"([^\"]*)\"" +consistent!(qt_generator_1, "(href|src)=\"([^\"]*)\""); + +// kryptos-0.6.1: r"[01]{5}" +consistent!(kryptos_0, r"[01]{5}"); + +// cifar_10_loader-0.2.0: "data_batch_[1-5].bin" +consistent!(cifar_10_loader_0, "data_batch_[1-5].bin"); + +// cifar_10_loader-0.2.0: "test_batch.bin" +consistent!(cifar_10_loader_1, "test_batch.bin"); + +// circadian-0.6.0: r"^\d+.\d+s$" +consistent!(circadian_0, r"^\d+.\d+s$"); + +// circadian-0.6.0: r"^\d+:\d+$" +consistent!(circadian_1, r"^\d+:\d+$"); + +// circadian-0.6.0: r"^\d+:\d+m$" +consistent!(circadian_2, r"^\d+:\d+m$"); + +// cicada-0.8.1: r"!!" +consistent!(cicada_0, r"!!"); + +// cicada-0.8.1: r"^([^`]*)`([^`]+)`(.*)$" +consistent!(cicada_1, r"^([^`]*)`([^`]+)`(.*)$"); + +// cicada-0.8.1: r"\*+" +consistent!(cicada_2, r"\*+"); + +// cicada-0.8.1: r"([^\$]*)\$\{?([A-Za-z0-9\?\$_]+)\}?(.*)" +consistent!(cicada_3, r"([^\$]*)\$\{?([A-Za-z0-9\?\$_]+)\}?(.*)"); + +// cicada-0.8.1: r"^ *alias +([a-zA-Z0-9_\.-]+)=(.*)$" +consistent!(cicada_4, r"^ *alias +([a-zA-Z0-9_\.-]+)=(.*)$"); + +// vterm-sys-0.1.0: r"hi" +consistent!(vterm_sys_0, r"hi"); + +// skim-0.5.0: r".*?\t" +consistent!(skim_0, r".*?\t"); + +// skim-0.5.0: r".*?[\t ]" +consistent!(skim_1, r".*?[\t ]"); + +// skim-0.5.0: r"(\{-?[0-9.,q]*?})" +consistent!(skim_2, r"(\{-?[0-9.,q]*?})"); + +// skim-0.5.0: r"[ \t\n]+" +consistent!(skim_3, r"[ \t\n]+"); + +// skim-0.5.0: r"[ \t\n]+" +consistent!(skim_4, r"[ \t\n]+"); + +// skim-0.5.0: r"([^ |]+( +\| +[^ |]*)+)|( +)" +consistent!(skim_5, r"([^ |]+( +\| +[^ |]*)+)|( +)"); + +// skim-0.5.0: r" +\| +" +consistent!(skim_6, r" +\| +"); + +// skim-0.5.0: r"^(?P<left>-?\d+)?(?P<sep>\.\.)?(?P<right>-?\d+)?$" +consistent!(skim_7, r"^(?P<left>-?\d+)?(?P<sep>\.\.)?(?P<right>-?\d+)?$"); + +// skim-0.5.0: "," +consistent!(skim_8, ","); + +// skim-0.5.0: ".*?," +consistent!(skim_9, ".*?,"); + +// skim-0.5.0: ".*?," +consistent!(skim_10, ".*?,"); + +// skim-0.5.0: "," +consistent!(skim_11, ","); + +// skim-0.5.0: r"\x1B\[(?:([0-9]+;[0-9]+[Hf])|([0-9]+[ABCD])|(s|u|2J|K)|([0-9;]*m)|(=[0-9]+[hI]))" +consistent!(skim_12, r"\x1B\[(?:([0-9]+;[0-9]+[Hf])|([0-9]+[ABCD])|(s|u|2J|K)|([0-9;]*m)|(=[0-9]+[hI]))"); + +// egg-mode-text-1.14.7: r"[-_./]\z" +consistent!(egg_mode_text_0, r"[-_./]\z"); + +// java-properties-1.1.1: "^[ \t\r\n\x0c]*[#!]" +consistent!(java_properties_0, "^[ \t\r\n\x0c]*[#!]"); + +// java-properties-1.1.1: r"^[ \t\x0c]*[#!][^\r\n]*$" +consistent!(java_properties_1, r"^[ \t\x0c]*[#!][^\r\n]*$"); + +// java-properties-1.1.1: r"^([ \t\x0c]*[:=][ \t\x0c]*|[ \t\x0c]+)$" +consistent!(java_properties_2, r"^([ \t\x0c]*[:=][ \t\x0c]*|[ \t\x0c]+)$"); + +// ipaddress-0.1.2: r":.+\." +consistent!(ipaddress_0, r":.+\."); + +// ipaddress-0.1.2: r"\." +consistent!(ipaddress_1, r"\."); + +// ipaddress-0.1.2: r":" +consistent!(ipaddress_2, r":"); + +// iptables-0.2.2: r"v(\d+)\.(\d+)\.(\d+)" +consistent!(iptables_0, r"v(\d+)\.(\d+)\.(\d+)"); + +// rsure-0.8.1: r"^([^-]+)-(.*)\.dat\.gz$" +consistent!(rsure_0, r"^([^-]+)-(.*)\.dat\.gz$"); + +// rs-jsonpath-0.1.0: "^(.*?)(<=|<|==|>=|>)(.*?)$" +consistent!(rs_jsonpath_0, "^(.*?)(<=|<|==|>=|>)(.*?)$"); + +// oatie-0.3.0: r"(\n|^)(\w+):([\n\w\W]+?)(\n(?:\w)|(\n\]))" +consistent!(oatie_0, r"(\n|^)(\w+):([\n\w\W]+?)(\n(?:\w)|(\n\]))"); + +// weld-0.2.0: "#.*$" +consistent!(weld_0, "#.*$"); + +// weld-0.2.0: r"^[A-Za-z$_][A-Za-z0-9$_]*$" +consistent!(weld_1, r"^[A-Za-z$_][A-Za-z0-9$_]*$"); + +// weld-0.2.0: r"^[0-9]+[cC]$" +consistent!(weld_2, r"^[0-9]+[cC]$"); + +// weld-0.2.0: r"^0b[0-1]+[cC]$" +consistent!(weld_3, r"^0b[0-1]+[cC]$"); + +// weld-0.2.0: r"^0x[0-9a-fA-F]+[cC]$" +consistent!(weld_4, r"^0x[0-9a-fA-F]+[cC]$"); + +// weld-0.2.0: r"^[0-9]+$" +consistent!(weld_5, r"^[0-9]+$"); + +// weld-0.2.0: r"^0b[0-1]+$" +consistent!(weld_6, r"^0b[0-1]+$"); + +// weld-0.2.0: r"^0x[0-9a-fA-F]+$" +consistent!(weld_7, r"^0x[0-9a-fA-F]+$"); + +// weld-0.2.0: r"^[0-9]+[lL]$" +consistent!(weld_8, r"^[0-9]+[lL]$"); + +// weld-0.2.0: r"^0b[0-1]+[lL]$" +consistent!(weld_9, r"^0b[0-1]+[lL]$"); + +// weld-0.2.0: r"^0x[0-9a-fA-F]+[lL]$" +consistent!(weld_10, r"^0x[0-9a-fA-F]+[lL]$"); + +// webgl_generator-0.1.0: "([(, ])enum\\b" +consistent!(webgl_generator_0, "([(, ])enum\\b"); + +// webgl_generator-0.1.0: "\\bAcquireResourcesCallback\\b" +consistent!(webgl_generator_1, "\\bAcquireResourcesCallback\\b"); + +// weave-0.2.0: r"^(\d+)(,(\d+))?([acd]).*$" +consistent!(weave_0, r"^(\d+)(,(\d+))?([acd]).*$"); + +// wemo-0.0.12: r"<BinaryState>(\d)(\|-?\d+)*</BinaryState>" +consistent!(wemo_0, r"<BinaryState>(\d)(\|-?\d+)*</BinaryState>"); + +// webscale-0.9.4: r"(http[s]?://[^\s]+)" +consistent!(webscale_0, r"(http[s]?://[^\s]+)"); + +// svgrep-1.1.0: r"^\d+.*$" +consistent!(svgrep_0, r"^\d+.*$"); + +// ignore-0.4.2: r"^[\pL\pN]+$" +consistent!(ignore_0, r"^[\pL\pN]+$"); + +// ommui_string_patterns-0.1.2: r"^([A-Za-z][0-9A-Za-z_]*)?$" +consistent!(ommui_string_patterns_0, r"^([A-Za-z][0-9A-Za-z_]*)?$"); + +// ommui_string_patterns-0.1.2: r"^(\S+(?:.*\S)?)?$" +consistent!(ommui_string_patterns_1, r"^(\S+(?:.*\S)?)?$"); + +// opcua-types-0.3.0: "^(?P<min>[0-9]{1,10})(:(?P<max>[0-9]{1,10}))?$" +consistent!(opcua_types_0, "^(?P<min>[0-9]{1,10})(:(?P<max>[0-9]{1,10}))?$"); + +// opcua-types-0.3.0: r"^(ns=(?P<ns>[0-9]+);)?(?P<t>[isgb])=(?P<v>.+)$" +consistent!(opcua_types_1, r"^(ns=(?P<ns>[0-9]+);)?(?P<t>[isgb])=(?P<v>.+)$"); + +// open_read_later-1.1.1: r"^(.+?)\s*:\s*(.+)$" +consistent!(open_read_later_0, r"^(.+?)\s*:\s*(.+)$"); + +// youtube-downloader-0.1.0: r"^.*(?:(?:youtu\.be/|v/|vi/|u/w/|embed/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*" +consistent!(youtube_downloader_0, r"^.*(?:(?:youtu\.be/|v/|vi/|u/w/|embed/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*"); + +// yobot-0.1.1: "." +consistent!(yobot_0, "."); + +// yobot-0.1.1: r"." +consistent!(yobot_1, r"."); + +// yobot-0.1.1: r".+" +consistent!(yobot_2, r".+"); + +// yobot-0.1.1: r"." +consistent!(yobot_3, r"."); + +// ubiquity-0.1.5: r"foo" +consistent!(ubiquity_0, r"foo"); + +// ubiquity-0.1.5: r"/target/" +consistent!(ubiquity_1, r"/target/"); + +// ubiquity-0.1.5: r".DS_Store" +consistent!(ubiquity_2, r".DS_Store"); + +// qasm-1.0.0: r"//.*" +consistent!(qasm_0, r"//.*"); + +// drill-0.3.5: r"\{\{ *([a-z\._]+) *\}\}" +consistent!(drill_0, r"\{\{ *([a-z\._]+) *\}\}"); + +// queryst-2.0.0: r"^([^\]\[]+)" +consistent!(queryst_0, r"^([^\]\[]+)"); + +// queryst-2.0.0: r"(\[[^\]\[]*\])" +consistent!(queryst_1, r"(\[[^\]\[]*\])"); + +// qui-vive-0.1.0: r"^/(\w+)$" +consistent!(qui_vive_0, r"^/(\w+)$"); + +// qui-vive-0.1.0: r"^/key$" +consistent!(qui_vive_1, r"^/key$"); + +// qui-vive-0.1.0: r"^/key/(\w+)$" +consistent!(qui_vive_2, r"^/key/(\w+)$"); + +// qui-vive-0.1.0: r"^/url$" +consistent!(qui_vive_3, r"^/url$"); + +// qui-vive-0.1.0: r"^/url/(\w+)$" +consistent!(qui_vive_4, r"^/url/(\w+)$"); + +// qui-vive-0.1.0: r"^/inv$" +consistent!(qui_vive_5, r"^/inv$"); + +// qui-vive-0.1.0: r"^/inv/(\w+)$" +consistent!(qui_vive_6, r"^/inv/(\w+)$"); + +// subdiff-0.1.0: r"\b" +// consistent!(subdiff_0, r"\b"); + +// substudy-0.4.5: r"^(\d+)/(\d+)$" +consistent!(substudy_0, r"^(\d+)/(\d+)$"); + +// substudy-0.4.5: r"\s+" +consistent!(substudy_1, r"\s+"); + +// substudy-0.4.5: r"<[a-z/][^>]*>" +consistent!(substudy_2, r"<[a-z/][^>]*>"); + +// substudy-0.4.5: r"(\([^)]*\)|♪[^♪]*♪|[A-Z]{2,} ?:)" +consistent!(substudy_3, r"(\([^)]*\)|♪[^♪]*♪|[A-Z]{2,} ?:)"); + +// substudy-0.4.5: r"\s+" +consistent!(substudy_4, r"\s+"); + +// isbnid-0.1.3: r"^(\d(-| )?){9}(x|X|\d|(\d(-| )?){3}\d)$" +consistent!(isbnid_0, r"^(\d(-| )?){9}(x|X|\d|(\d(-| )?){3}\d)$"); + +// isbnid-0.1.3: r"[^0-9X]" +consistent!(isbnid_1, r"[^0-9X]"); + +// ispc-0.3.5: r"Intel\(r\) SPMD Program Compiler \(ispc\), (\d+\.\d+\.\d+)" +consistent!( + ispc_0, + r"Intel\(r\) SPMD Program Compiler \(ispc\), (\d+\.\d+\.\d+)" +); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/crazy.rs b/third_party/cargo/vendor/regex-1.3.3/tests/crazy.rs new file mode 100644 index 0000000..8c72273 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/crazy.rs @@ -0,0 +1,446 @@ +mat!(ascii_literal, r"a", "a", Some((0, 1))); + +// Some crazy expressions from regular-expressions.info. +mat!( + match_ranges, + r"(?-u)\b(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b", + "num: 255", + Some((5, 8)) +); +mat!( + match_ranges_not, + r"(?-u)\b(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b", + "num: 256", + None +); +mat!(match_float1, r"[-+]?[0-9]*\.?[0-9]+", "0.1", Some((0, 3))); +mat!(match_float2, r"[-+]?[0-9]*\.?[0-9]+", "0.1.2", Some((0, 3))); +mat!(match_float3, r"[-+]?[0-9]*\.?[0-9]+", "a1.2", Some((1, 4))); +mat!(match_float4, r"^[-+]?[0-9]*\.?[0-9]+$", "1.a", None); +mat!( + match_email, + r"(?i-u)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b", + "mine is jam.slam@gmail.com ", + Some((8, 26)) +); +mat!( + match_email_not, + r"(?i-u)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b", + "mine is jam.slam@gmail ", + None +); +mat!( + match_email_big, + r"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", + "mine is jam.slam@gmail.com ", + Some((8, 26)) +); +mat!( + match_date1, + r"(?-u)^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$", + "1900-01-01", + Some((0, 10)) +); +mat!( + match_date2, + r"(?-u)^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$", + "1900-00-01", + None +); +mat!( + match_date3, + r"(?-u)^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$", + "1900-13-01", + None +); + +// Do some crazy dancing with the start/end assertions. +matiter!(match_start_end_empty, r"^$", "", (0, 0)); +matiter!(match_start_end_empty_many_1, r"^$^$^$", "", (0, 0)); +matiter!(match_start_end_empty_many_2, r"^^^$$$", "", (0, 0)); +matiter!(match_start_end_empty_rev, r"$^", "", (0, 0)); +matiter!( + match_start_end_empty_rep, + r"(?:^$)*", + "a\nb\nc", + (0, 0), + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5) +); +matiter!( + match_start_end_empty_rep_rev, + r"(?:$^)*", + "a\nb\nc", + (0, 0), + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5) +); + +// Test negated character classes. +mat!(negclass_letters, r"[^ac]", "acx", Some((2, 3))); +mat!(negclass_letter_comma, r"[^a,]", "a,x", Some((2, 3))); +mat!(negclass_letter_space, r"[^a[:space:]]", "a x", Some((2, 3))); +mat!(negclass_comma, r"[^,]", ",,x", Some((2, 3))); +mat!(negclass_space, r"[^[:space:]]", " a", Some((1, 2))); +mat!(negclass_space_comma, r"[^,[:space:]]", ", a", Some((2, 3))); +mat!(negclass_comma_space, r"[^[:space:],]", " ,a", Some((2, 3))); +mat!(negclass_ascii, r"[^[:alpha:]Z]", "A1", Some((1, 2))); + +// Test that repeated empty expressions don't loop forever. +mat!(lazy_many_many, r"((?:.*)*?)=", "a=b", Some((0, 2))); +mat!(lazy_many_optional, r"((?:.?)*?)=", "a=b", Some((0, 2))); +mat!(lazy_one_many_many, r"((?:.*)+?)=", "a=b", Some((0, 2))); +mat!(lazy_one_many_optional, r"((?:.?)+?)=", "a=b", Some((0, 2))); +mat!(lazy_range_min_many, r"((?:.*){1,}?)=", "a=b", Some((0, 2))); +mat!(lazy_range_many, r"((?:.*){1,2}?)=", "a=b", Some((0, 2))); +mat!(greedy_many_many, r"((?:.*)*)=", "a=b", Some((0, 2))); +mat!(greedy_many_optional, r"((?:.?)*)=", "a=b", Some((0, 2))); +mat!(greedy_one_many_many, r"((?:.*)+)=", "a=b", Some((0, 2))); +mat!(greedy_one_many_optional, r"((?:.?)+)=", "a=b", Some((0, 2))); +mat!(greedy_range_min_many, r"((?:.*){1,})=", "a=b", Some((0, 2))); +mat!(greedy_range_many, r"((?:.*){1,2})=", "a=b", Some((0, 2))); + +// Test that we handle various flavors of empty expressions. +matiter!(match_empty1, r"", "", (0, 0)); +matiter!(match_empty2, r"", "abc", (0, 0), (1, 1), (2, 2), (3, 3)); +matiter!(match_empty3, r"()", "abc", (0, 0), (1, 1), (2, 2), (3, 3)); +matiter!(match_empty4, r"()*", "abc", (0, 0), (1, 1), (2, 2), (3, 3)); +matiter!(match_empty5, r"()+", "abc", (0, 0), (1, 1), (2, 2), (3, 3)); +matiter!(match_empty6, r"()?", "abc", (0, 0), (1, 1), (2, 2), (3, 3)); +matiter!(match_empty7, r"()()", "abc", (0, 0), (1, 1), (2, 2), (3, 3)); +matiter!(match_empty8, r"()+|z", "abc", (0, 0), (1, 1), (2, 2), (3, 3)); +matiter!(match_empty9, r"z|()+", "abc", (0, 0), (1, 1), (2, 2), (3, 3)); +matiter!(match_empty10, r"()+|b", "abc", (0, 0), (1, 1), (2, 2), (3, 3)); +matiter!(match_empty11, r"b|()+", "abc", (0, 0), (1, 2), (3, 3)); + +// Test that the DFA can handle pathological cases. +// (This should result in the DFA's cache being flushed too frequently, which +// should cause it to quit and fall back to the NFA algorithm.) +#[test] +fn dfa_handles_pathological_case() { + fn ones_and_zeroes(count: usize) -> String { + use rand::{thread_rng, Rng}; + + let mut rng = thread_rng(); + let mut s = String::new(); + for _ in 0..count { + if rng.gen() { + s.push('1'); + } else { + s.push('0'); + } + } + s + } + + let re = regex!(r"[01]*1[01]{20}$"); + let text = { + let mut pieces = ones_and_zeroes(100_000); + pieces.push('1'); + pieces.push_str(&ones_and_zeroes(20)); + pieces + }; + assert!(re.is_match(text!(&*text))); +} + +#[test] +fn nest_limit_makes_it_parse() { + use regex::RegexBuilder; + + RegexBuilder::new( + r#"(?-u) + 2(?: + [45]\d{3}| + 7(?: + 1[0-267]| + 2[0-289]| + 3[0-29]| + 4[01]| + 5[1-3]| + 6[013]| + 7[0178]| + 91 + )| + 8(?: + 0[125]| + [139][1-6]| + 2[0157-9]| + 41| + 6[1-35]| + 7[1-5]| + 8[1-8]| + 90 + )| + 9(?: + 0[0-2]| + 1[0-4]| + 2[568]| + 3[3-6]| + 5[5-7]| + 6[0167]| + 7[15]| + 8[0146-9] + ) + )\d{4}| + 3(?: + 12?[5-7]\d{2}| + 0(?: + 2(?: + [025-79]\d| + [348]\d{1,2} + )| + 3(?: + [2-4]\d| + [56]\d? + ) + )| + 2(?: + 1\d{2}| + 2(?: + [12]\d| + [35]\d{1,2}| + 4\d? + ) + )| + 3(?: + 1\d{2}| + 2(?: + [2356]\d| + 4\d{1,2} + ) + )| + 4(?: + 1\d{2}| + 2(?: + 2\d{1,2}| + [47]| + 5\d{2} + ) + )| + 5(?: + 1\d{2}| + 29 + )| + [67]1\d{2}| + 8(?: + 1\d{2}| + 2(?: + 2\d{2}| + 3| + 4\d + ) + ) + )\d{3}| + 4(?: + 0(?: + 2(?: + [09]\d| + 7 + )| + 33\d{2} + )| + 1\d{3}| + 2(?: + 1\d{2}| + 2(?: + [25]\d?| + [348]\d| + [67]\d{1,2} + ) + )| + 3(?: + 1\d{2}(?: + \d{2} + )?| + 2(?: + [045]\d| + [236-9]\d{1,2} + )| + 32\d{2} + )| + 4(?: + [18]\d{2}| + 2(?: + [2-46]\d{2}| + 3 + )| + 5[25]\d{2} + )| + 5(?: + 1\d{2}| + 2(?: + 3\d| + 5 + ) + )| + 6(?: + [18]\d{2}| + 2(?: + 3(?: + \d{2} + )?| + [46]\d{1,2}| + 5\d{2}| + 7\d + )| + 5(?: + 3\d?| + 4\d| + [57]\d{1,2}| + 6\d{2}| + 8 + ) + )| + 71\d{2}| + 8(?: + [18]\d{2}| + 23\d{2}| + 54\d{2} + )| + 9(?: + [18]\d{2}| + 2[2-5]\d{2}| + 53\d{1,2} + ) + )\d{3}| + 5(?: + 02[03489]\d{2}| + 1\d{2}| + 2(?: + 1\d{2}| + 2(?: + 2(?: + \d{2} + )?| + [457]\d{2} + ) + )| + 3(?: + 1\d{2}| + 2(?: + [37](?: + \d{2} + )?| + [569]\d{2} + ) + )| + 4(?: + 1\d{2}| + 2[46]\d{2} + )| + 5(?: + 1\d{2}| + 26\d{1,2} + )| + 6(?: + [18]\d{2}| + 2| + 53\d{2} + )| + 7(?: + 1| + 24 + )\d{2}| + 8(?: + 1| + 26 + )\d{2}| + 91\d{2} + )\d{3}| + 6(?: + 0(?: + 1\d{2}| + 2(?: + 3\d{2}| + 4\d{1,2} + ) + )| + 2(?: + 2[2-5]\d{2}| + 5(?: + [3-5]\d{2}| + 7 + )| + 8\d{2} + )| + 3(?: + 1| + 2[3478] + )\d{2}| + 4(?: + 1| + 2[34] + )\d{2}| + 5(?: + 1| + 2[47] + )\d{2}| + 6(?: + [18]\d{2}| + 6(?: + 2(?: + 2\d| + [34]\d{2} + )| + 5(?: + [24]\d{2}| + 3\d| + 5\d{1,2} + ) + ) + )| + 72[2-5]\d{2}| + 8(?: + 1\d{2}| + 2[2-5]\d{2} + )| + 9(?: + 1\d{2}| + 2[2-6]\d{2} + ) + )\d{3}| + 7(?: + (?: + 02| + [3-589]1| + 6[12]| + 72[24] + )\d{2}| + 21\d{3}| + 32 + )\d{3}| + 8(?: + (?: + 4[12]| + [5-7]2| + 1\d? + )| + (?: + 0| + 3[12]| + [5-7]1| + 217 + )\d + )\d{4}| + 9(?: + [35]1| + (?: + [024]2| + 81 + )\d| + (?: + 1| + [24]1 + )\d{2} + )\d{3} + "#, + ) + .build() + .unwrap(); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/flags.rs b/third_party/cargo/vendor/regex-1.3.3/tests/flags.rs new file mode 100644 index 0000000..c33b82d --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/flags.rs @@ -0,0 +1,31 @@ +mat!(match_flag_case, "(?-u)(?i)abc", "ABC", Some((0, 3))); +mat!(match_flag_weird_case, "(?-u)(?i)a(?-i)bc", "Abc", Some((0, 3))); +mat!(match_flag_weird_case_not, "(?-u)(?i)a(?-i)bc", "ABC", None); +mat!(match_flag_case_dotnl, "(?-u)(?is)a(?u:.)", "A\n", Some((0, 2))); +mat!( + match_flag_case_dotnl_toggle, + "(?-u)(?is)a(?u:.)(?-is)a(?u:.)", + "A\nab", + Some((0, 4)) +); +mat!( + match_flag_case_dotnl_toggle_not, + "(?-u)(?is)a(?u:.)(?-is)a(?u:.)", + "A\na\n", + None +); +mat!( + match_flag_case_dotnl_toggle_ok, + "(?-u)(?is)a(?u:.)(?-is:a(?u:.))?", + "A\na\n", + Some((0, 2)) +); +mat!( + match_flag_multi, + r"(?-u)(?m)(?:^\d+$\n?)+", + "123\n456\n789", + Some((0, 11)) +); +mat!(match_flag_ungreedy, "(?U)a+", "aa", Some((0, 1))); +mat!(match_flag_ungreedy_greedy, "(?U)a+?", "aa", Some((0, 2))); +mat!(match_flag_ungreedy_noop, "(?U)(?-U)a+", "aa", Some((0, 2))); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/fowler.rs b/third_party/cargo/vendor/regex-1.3.3/tests/fowler.rs new file mode 100644 index 0000000..7f56a75 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/fowler.rs @@ -0,0 +1,1588 @@ +// DO NOT EDIT. Automatically generated by 'scripts/regex-match-tests.py' +// on 2019-09-02 11:07:37.849994. + +// Tests from basic.dat +mat!(match_basic_3, r"abracadabra$", r"abracadabracadabra", Some((7, 18))); +mat!(match_basic_4, r"a...b", r"abababbb", Some((2, 7))); +mat!(match_basic_5, r"XXXXXX", r"..XXXXXX", Some((2, 8))); +mat!(match_basic_6, r"\)", r"()", Some((1, 2))); +mat!(match_basic_7, r"a]", r"a]a", Some((0, 2))); +mat!(match_basic_9, r"\}", r"}", Some((0, 1))); +mat!(match_basic_10, r"\]", r"]", Some((0, 1))); +mat!(match_basic_12, r"]", r"]", Some((0, 1))); +mat!(match_basic_15, r"^a", r"ax", Some((0, 1))); +mat!(match_basic_16, r"\^a", r"a^a", Some((1, 3))); +mat!(match_basic_17, r"a\^", r"a^", Some((0, 2))); +mat!(match_basic_18, r"a$", r"aa", Some((1, 2))); +mat!(match_basic_19, r"a\$", r"a$", Some((0, 2))); +mat!(match_basic_20, r"^$", r"", Some((0, 0))); +mat!(match_basic_21, r"$^", r"", Some((0, 0))); +mat!(match_basic_22, r"a($)", r"aa", Some((1, 2)), Some((2, 2))); +mat!(match_basic_23, r"a*(^a)", r"aa", Some((0, 1)), Some((0, 1))); +mat!(match_basic_24, r"(..)*(...)*", r"a", Some((0, 0))); +mat!(match_basic_25, r"(..)*(...)*", r"abcd", Some((0, 4)), Some((2, 4))); +mat!( + match_basic_26, + r"(ab|a)(bc|c)", + r"abc", + Some((0, 3)), + Some((0, 2)), + Some((2, 3)) +); +mat!(match_basic_27, r"(ab)c|abc", r"abc", Some((0, 3)), Some((0, 2))); +mat!(match_basic_28, r"a{0}b", r"ab", Some((1, 2))); +mat!( + match_basic_29, + r"(a*)(b?)(b+)b{3}", + r"aaabbbbbbb", + Some((0, 10)), + Some((0, 3)), + Some((3, 4)), + Some((4, 7)) +); +mat!( + match_basic_30, + r"(a*)(b{0,1})(b{1,})b{3}", + r"aaabbbbbbb", + Some((0, 10)), + Some((0, 3)), + Some((3, 4)), + Some((4, 7)) +); +mat!( + match_basic_32, + r"((a|a)|a)", + r"a", + Some((0, 1)), + Some((0, 1)), + Some((0, 1)) +); +mat!( + match_basic_33, + r"(a*)(a|aa)", + r"aaaa", + Some((0, 4)), + Some((0, 3)), + Some((3, 4)) +); +mat!(match_basic_34, r"a*(a.|aa)", r"aaaa", Some((0, 4)), Some((2, 4))); +mat!( + match_basic_35, + r"a(b)|c(d)|a(e)f", + r"aef", + Some((0, 3)), + None, + None, + Some((1, 2)) +); +mat!(match_basic_36, r"(a|b)?.*", r"b", Some((0, 1)), Some((0, 1))); +mat!(match_basic_37, r"(a|b)c|a(b|c)", r"ac", Some((0, 2)), Some((0, 1))); +mat!( + match_basic_38, + r"(a|b)c|a(b|c)", + r"ab", + Some((0, 2)), + None, + Some((1, 2)) +); +mat!(match_basic_39, r"(a|b)*c|(a|ab)*c", r"abc", Some((0, 3)), Some((1, 2))); +mat!(match_basic_40, r"(a|b)*c|(a|ab)*c", r"xc", Some((1, 2))); +mat!( + match_basic_41, + r"(.a|.b).*|.*(.a|.b)", + r"xa", + Some((0, 2)), + Some((0, 2)) +); +mat!(match_basic_42, r"a?(ab|ba)ab", r"abab", Some((0, 4)), Some((0, 2))); +mat!(match_basic_43, r"a?(ac{0}b|ba)ab", r"abab", Some((0, 4)), Some((0, 2))); +mat!(match_basic_44, r"ab|abab", r"abbabab", Some((0, 2))); +mat!(match_basic_45, r"aba|bab|bba", r"baaabbbaba", Some((5, 8))); +mat!(match_basic_46, r"aba|bab", r"baaabbbaba", Some((6, 9))); +mat!( + match_basic_47, + r"(aa|aaa)*|(a|aaaaa)", + r"aa", + Some((0, 2)), + Some((0, 2)) +); +mat!( + match_basic_48, + r"(a.|.a.)*|(a|.a...)", + r"aa", + Some((0, 2)), + Some((0, 2)) +); +mat!(match_basic_49, r"ab|a", r"xabc", Some((1, 3))); +mat!(match_basic_50, r"ab|a", r"xxabc", Some((2, 4))); +mat!( + match_basic_51, + r"(?i)(?-u)(Ab|cD)*", + r"aBcD", + Some((0, 4)), + Some((2, 4)) +); +mat!(match_basic_52, r"[^-]", r"--a", Some((2, 3))); +mat!(match_basic_53, r"[a-]*", r"--a", Some((0, 3))); +mat!(match_basic_54, r"[a-m-]*", r"--amoma--", Some((0, 4))); +mat!( + match_basic_55, + r":::1:::0:|:::1:1:0:", + r":::0:::1:::1:::0:", + Some((8, 17)) +); +mat!( + match_basic_56, + r":::1:::0:|:::1:1:1:", + r":::0:::1:::1:::0:", + Some((8, 17)) +); +mat!(match_basic_57, r"[[:upper:]]", r"A", Some((0, 1))); +mat!(match_basic_58, r"[[:lower:]]+", r"`az{", Some((1, 3))); +mat!(match_basic_59, r"[[:upper:]]+", r"@AZ[", Some((1, 3))); +mat!( + match_basic_65, + r" +", + r" +", + Some((0, 1)) +); +mat!( + match_basic_66, + r" +", + r" +", + Some((0, 1)) +); +mat!( + match_basic_67, + r"[^a]", + r" +", + Some((0, 1)) +); +mat!( + match_basic_68, + r" +a", + r" +a", + Some((0, 2)) +); +mat!( + match_basic_69, + r"(a)(b)(c)", + r"abc", + Some((0, 3)), + Some((0, 1)), + Some((1, 2)), + Some((2, 3)) +); +mat!(match_basic_70, r"xxx", r"xxx", Some((0, 3))); +mat!( + match_basic_71, + r"(^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$)", + r"feb 6,", + Some((0, 6)) +); +mat!( + match_basic_72, + r"(^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$)", + r"2/7", + Some((0, 3)) +); +mat!( + match_basic_73, + r"(^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$)", + r"feb 1,Feb 6", + Some((5, 11)) +); +mat!( + match_basic_74, + r"((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))", + r"x", + Some((0, 1)), + Some((0, 1)), + Some((0, 1)) +); +mat!( + match_basic_75, + r"((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))*", + r"xx", + Some((0, 2)), + Some((1, 2)), + Some((1, 2)) +); +mat!( + match_basic_76, + r"a?(ab|ba)*", + r"ababababababababababababababababababababababababababababababababababababababababa", + Some((0, 81)), + Some((79, 81)) +); +mat!( + match_basic_77, + r"abaa|abbaa|abbbaa|abbbbaa", + r"ababbabbbabbbabbbbabbbbaa", + Some((18, 25)) +); +mat!( + match_basic_78, + r"abaa|abbaa|abbbaa|abbbbaa", + r"ababbabbbabbbabbbbabaa", + Some((18, 22)) +); +mat!( + match_basic_79, + r"aaac|aabc|abac|abbc|baac|babc|bbac|bbbc", + r"baaabbbabac", + Some((7, 11)) +); +mat!(match_basic_80, r".*", r"", Some((0, 2))); +mat!( + match_basic_81, + r"aaaa|bbbb|cccc|ddddd|eeeeee|fffffff|gggg|hhhh|iiiii|jjjjj|kkkkk|llll", + r"XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa", + Some((53, 57)) +); +mat!(match_basic_83, r"a*a*a*a*a*b", r"aaaaaaaaab", Some((0, 10))); +mat!(match_basic_84, r"^", r"", Some((0, 0))); +mat!(match_basic_85, r"$", r"", Some((0, 0))); +mat!(match_basic_86, r"^$", r"", Some((0, 0))); +mat!(match_basic_87, r"^a$", r"a", Some((0, 1))); +mat!(match_basic_88, r"abc", r"abc", Some((0, 3))); +mat!(match_basic_89, r"abc", r"xabcy", Some((1, 4))); +mat!(match_basic_90, r"abc", r"ababc", Some((2, 5))); +mat!(match_basic_91, r"ab*c", r"abc", Some((0, 3))); +mat!(match_basic_92, r"ab*bc", r"abc", Some((0, 3))); +mat!(match_basic_93, r"ab*bc", r"abbc", Some((0, 4))); +mat!(match_basic_94, r"ab*bc", r"abbbbc", Some((0, 6))); +mat!(match_basic_95, r"ab+bc", r"abbc", Some((0, 4))); +mat!(match_basic_96, r"ab+bc", r"abbbbc", Some((0, 6))); +mat!(match_basic_97, r"ab?bc", r"abbc", Some((0, 4))); +mat!(match_basic_98, r"ab?bc", r"abc", Some((0, 3))); +mat!(match_basic_99, r"ab?c", r"abc", Some((0, 3))); +mat!(match_basic_100, r"^abc$", r"abc", Some((0, 3))); +mat!(match_basic_101, r"^abc", r"abcc", Some((0, 3))); +mat!(match_basic_102, r"abc$", r"aabc", Some((1, 4))); +mat!(match_basic_103, r"^", r"abc", Some((0, 0))); +mat!(match_basic_104, r"$", r"abc", Some((3, 3))); +mat!(match_basic_105, r"a.c", r"abc", Some((0, 3))); +mat!(match_basic_106, r"a.c", r"axc", Some((0, 3))); +mat!(match_basic_107, r"a.*c", r"axyzc", Some((0, 5))); +mat!(match_basic_108, r"a[bc]d", r"abd", Some((0, 3))); +mat!(match_basic_109, r"a[b-d]e", r"ace", Some((0, 3))); +mat!(match_basic_110, r"a[b-d]", r"aac", Some((1, 3))); +mat!(match_basic_111, r"a[-b]", r"a-", Some((0, 2))); +mat!(match_basic_112, r"a[b-]", r"a-", Some((0, 2))); +mat!(match_basic_113, r"a]", r"a]", Some((0, 2))); +mat!(match_basic_114, r"a[]]b", r"a]b", Some((0, 3))); +mat!(match_basic_115, r"a[^bc]d", r"aed", Some((0, 3))); +mat!(match_basic_116, r"a[^-b]c", r"adc", Some((0, 3))); +mat!(match_basic_117, r"a[^]b]c", r"adc", Some((0, 3))); +mat!(match_basic_118, r"ab|cd", r"abc", Some((0, 2))); +mat!(match_basic_119, r"ab|cd", r"abcd", Some((0, 2))); +mat!(match_basic_120, r"a\(b", r"a(b", Some((0, 3))); +mat!(match_basic_121, r"a\(*b", r"ab", Some((0, 2))); +mat!(match_basic_122, r"a\(*b", r"a((b", Some((0, 4))); +mat!( + match_basic_123, + r"((a))", + r"abc", + Some((0, 1)), + Some((0, 1)), + Some((0, 1)) +); +mat!( + match_basic_124, + r"(a)b(c)", + r"abc", + Some((0, 3)), + Some((0, 1)), + Some((2, 3)) +); +mat!(match_basic_125, r"a+b+c", r"aabbabc", Some((4, 7))); +mat!(match_basic_126, r"a*", r"aaa", Some((0, 3))); +mat!(match_basic_128, r"(a*)*", r"-", Some((0, 0)), None); +mat!(match_basic_129, r"(a*)+", r"-", Some((0, 0)), Some((0, 0))); +mat!(match_basic_131, r"(a*|b)*", r"-", Some((0, 0)), None); +mat!(match_basic_132, r"(a+|b)*", r"ab", Some((0, 2)), Some((1, 2))); +mat!(match_basic_133, r"(a+|b)+", r"ab", Some((0, 2)), Some((1, 2))); +mat!(match_basic_134, r"(a+|b)?", r"ab", Some((0, 1)), Some((0, 1))); +mat!(match_basic_135, r"[^ab]*", r"cde", Some((0, 3))); +mat!(match_basic_137, r"(^)*", r"-", Some((0, 0)), None); +mat!(match_basic_138, r"a*", r"", Some((0, 0))); +mat!(match_basic_139, r"([abc])*d", r"abbbcd", Some((0, 6)), Some((4, 5))); +mat!(match_basic_140, r"([abc])*bcd", r"abcd", Some((0, 4)), Some((0, 1))); +mat!(match_basic_141, r"a|b|c|d|e", r"e", Some((0, 1))); +mat!(match_basic_142, r"(a|b|c|d|e)f", r"ef", Some((0, 2)), Some((0, 1))); +mat!(match_basic_144, r"((a*|b))*", r"-", Some((0, 0)), None, None); +mat!(match_basic_145, r"abcd*efg", r"abcdefg", Some((0, 7))); +mat!(match_basic_146, r"ab*", r"xabyabbbz", Some((1, 3))); +mat!(match_basic_147, r"ab*", r"xayabbbz", Some((1, 2))); +mat!(match_basic_148, r"(ab|cd)e", r"abcde", Some((2, 5)), Some((2, 4))); +mat!(match_basic_149, r"[abhgefdc]ij", r"hij", Some((0, 3))); +mat!(match_basic_150, r"(a|b)c*d", r"abcd", Some((1, 4)), Some((1, 2))); +mat!(match_basic_151, r"(ab|ab*)bc", r"abc", Some((0, 3)), Some((0, 1))); +mat!(match_basic_152, r"a([bc]*)c*", r"abc", Some((0, 3)), Some((1, 3))); +mat!( + match_basic_153, + r"a([bc]*)(c*d)", + r"abcd", + Some((0, 4)), + Some((1, 3)), + Some((3, 4)) +); +mat!( + match_basic_154, + r"a([bc]+)(c*d)", + r"abcd", + Some((0, 4)), + Some((1, 3)), + Some((3, 4)) +); +mat!( + match_basic_155, + r"a([bc]*)(c+d)", + r"abcd", + Some((0, 4)), + Some((1, 2)), + Some((2, 4)) +); +mat!(match_basic_156, r"a[bcd]*dcdcde", r"adcdcde", Some((0, 7))); +mat!(match_basic_157, r"(ab|a)b*c", r"abc", Some((0, 3)), Some((0, 2))); +mat!( + match_basic_158, + r"((a)(b)c)(d)", + r"abcd", + Some((0, 4)), + Some((0, 3)), + Some((0, 1)), + Some((1, 2)), + Some((3, 4)) +); +mat!(match_basic_159, r"[A-Za-z_][A-Za-z0-9_]*", r"alpha", Some((0, 5))); +mat!(match_basic_160, r"^a(bc+|b[eh])g|.h$", r"abh", Some((1, 3))); +mat!( + match_basic_161, + r"(bc+d$|ef*g.|h?i(j|k))", + r"effgz", + Some((0, 5)), + Some((0, 5)) +); +mat!( + match_basic_162, + r"(bc+d$|ef*g.|h?i(j|k))", + r"ij", + Some((0, 2)), + Some((0, 2)), + Some((1, 2)) +); +mat!( + match_basic_163, + r"(bc+d$|ef*g.|h?i(j|k))", + r"reffgz", + Some((1, 6)), + Some((1, 6)) +); +mat!( + match_basic_164, + r"(((((((((a)))))))))", + r"a", + Some((0, 1)), + Some((0, 1)), + Some((0, 1)), + Some((0, 1)), + Some((0, 1)), + Some((0, 1)), + Some((0, 1)), + Some((0, 1)), + Some((0, 1)), + Some((0, 1)) +); +mat!( + match_basic_165, + r"multiple words", + r"multiple words yeah", + Some((0, 14)) +); +mat!( + match_basic_166, + r"(.*)c(.*)", + r"abcde", + Some((0, 5)), + Some((0, 2)), + Some((3, 5)) +); +mat!(match_basic_167, r"abcd", r"abcd", Some((0, 4))); +mat!(match_basic_168, r"a(bc)d", r"abcd", Some((0, 4)), Some((1, 3))); +mat!(match_basic_169, r"a[-]?c", r"ac", Some((0, 3))); +mat!( + match_basic_170, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muammar Qaddafi", + Some((0, 15)), + None, + Some((10, 12)) +); +mat!( + match_basic_171, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Mo'ammar Gadhafi", + Some((0, 16)), + None, + Some((11, 13)) +); +mat!( + match_basic_172, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muammar Kaddafi", + Some((0, 15)), + None, + Some((10, 12)) +); +mat!( + match_basic_173, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muammar Qadhafi", + Some((0, 15)), + None, + Some((10, 12)) +); +mat!( + match_basic_174, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muammar Gadafi", + Some((0, 14)), + None, + Some((10, 11)) +); +mat!( + match_basic_175, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Mu'ammar Qadafi", + Some((0, 15)), + None, + Some((11, 12)) +); +mat!( + match_basic_176, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Moamar Gaddafi", + Some((0, 14)), + None, + Some((9, 11)) +); +mat!( + match_basic_177, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Mu'ammar Qadhdhafi", + Some((0, 18)), + None, + Some((13, 15)) +); +mat!( + match_basic_178, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muammar Khaddafi", + Some((0, 16)), + None, + Some((11, 13)) +); +mat!( + match_basic_179, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muammar Ghaddafy", + Some((0, 16)), + None, + Some((11, 13)) +); +mat!( + match_basic_180, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muammar Ghadafi", + Some((0, 15)), + None, + Some((11, 12)) +); +mat!( + match_basic_181, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muammar Ghaddafi", + Some((0, 16)), + None, + Some((11, 13)) +); +mat!( + match_basic_182, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muamar Kaddafi", + Some((0, 14)), + None, + Some((9, 11)) +); +mat!( + match_basic_183, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muammar Quathafi", + Some((0, 16)), + None, + Some((11, 13)) +); +mat!( + match_basic_184, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Muammar Gheddafi", + Some((0, 16)), + None, + Some((11, 13)) +); +mat!( + match_basic_185, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Moammar Khadafy", + Some((0, 15)), + None, + Some((11, 12)) +); +mat!( + match_basic_186, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + r"Moammar Qudhafi", + Some((0, 15)), + None, + Some((10, 12)) +); +mat!(match_basic_187, r"a+(b|c)*d+", r"aabcdd", Some((0, 6)), Some((3, 4))); +mat!(match_basic_188, r"^.+$", r"vivi", Some((0, 4))); +mat!(match_basic_189, r"^(.+)$", r"vivi", Some((0, 4)), Some((0, 4))); +mat!( + match_basic_190, + r"^([^!.]+).att.com!(.+)$", + r"gryphon.att.com!eby", + Some((0, 19)), + Some((0, 7)), + Some((16, 19)) +); +mat!( + match_basic_191, + r"^([^!]+!)?([^!]+)$", + r"bas", + Some((0, 3)), + None, + Some((0, 3)) +); +mat!( + match_basic_192, + r"^([^!]+!)?([^!]+)$", + r"bar!bas", + Some((0, 7)), + Some((0, 4)), + Some((4, 7)) +); +mat!( + match_basic_193, + r"^([^!]+!)?([^!]+)$", + r"foo!bas", + Some((0, 7)), + Some((0, 4)), + Some((4, 7)) +); +mat!( + match_basic_194, + r"^.+!([^!]+!)([^!]+)$", + r"foo!bar!bas", + Some((0, 11)), + Some((4, 8)), + Some((8, 11)) +); +mat!( + match_basic_195, + r"((foo)|(bar))!bas", + r"bar!bas", + Some((0, 7)), + Some((0, 3)), + None, + Some((0, 3)) +); +mat!( + match_basic_196, + r"((foo)|(bar))!bas", + r"foo!bar!bas", + Some((4, 11)), + Some((4, 7)), + None, + Some((4, 7)) +); +mat!( + match_basic_197, + r"((foo)|(bar))!bas", + r"foo!bas", + Some((0, 7)), + Some((0, 3)), + Some((0, 3)) +); +mat!( + match_basic_198, + r"((foo)|bar)!bas", + r"bar!bas", + Some((0, 7)), + Some((0, 3)) +); +mat!( + match_basic_199, + r"((foo)|bar)!bas", + r"foo!bar!bas", + Some((4, 11)), + Some((4, 7)) +); +mat!( + match_basic_200, + r"((foo)|bar)!bas", + r"foo!bas", + Some((0, 7)), + Some((0, 3)), + Some((0, 3)) +); +mat!( + match_basic_201, + r"(foo|(bar))!bas", + r"bar!bas", + Some((0, 7)), + Some((0, 3)), + Some((0, 3)) +); +mat!( + match_basic_202, + r"(foo|(bar))!bas", + r"foo!bar!bas", + Some((4, 11)), + Some((4, 7)), + Some((4, 7)) +); +mat!( + match_basic_203, + r"(foo|(bar))!bas", + r"foo!bas", + Some((0, 7)), + Some((0, 3)) +); +mat!( + match_basic_204, + r"(foo|bar)!bas", + r"bar!bas", + Some((0, 7)), + Some((0, 3)) +); +mat!( + match_basic_205, + r"(foo|bar)!bas", + r"foo!bar!bas", + Some((4, 11)), + Some((4, 7)) +); +mat!( + match_basic_206, + r"(foo|bar)!bas", + r"foo!bas", + Some((0, 7)), + Some((0, 3)) +); +mat!( + match_basic_207, + r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", + r"foo!bar!bas", + Some((0, 11)), + Some((0, 11)), + None, + None, + Some((4, 8)), + Some((8, 11)) +); +mat!( + match_basic_208, + r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", + r"bas", + Some((0, 3)), + None, + Some((0, 3)) +); +mat!( + match_basic_209, + r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", + r"bar!bas", + Some((0, 7)), + Some((0, 4)), + Some((4, 7)) +); +mat!( + match_basic_210, + r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", + r"foo!bar!bas", + Some((0, 11)), + None, + None, + Some((4, 8)), + Some((8, 11)) +); +mat!( + match_basic_211, + r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", + r"foo!bas", + Some((0, 7)), + Some((0, 4)), + Some((4, 7)) +); +mat!( + match_basic_212, + r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", + r"bas", + Some((0, 3)), + Some((0, 3)), + None, + Some((0, 3)) +); +mat!( + match_basic_213, + r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", + r"bar!bas", + Some((0, 7)), + Some((0, 7)), + Some((0, 4)), + Some((4, 7)) +); +mat!( + match_basic_214, + r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", + r"foo!bar!bas", + Some((0, 11)), + Some((0, 11)), + None, + None, + Some((4, 8)), + Some((8, 11)) +); +mat!( + match_basic_215, + r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", + r"foo!bas", + Some((0, 7)), + Some((0, 7)), + Some((0, 4)), + Some((4, 7)) +); +mat!(match_basic_216, r".*(/XXX).*", r"/XXX", Some((0, 4)), Some((0, 4))); +mat!(match_basic_217, r".*(\\XXX).*", r"\XXX", Some((0, 4)), Some((0, 4))); +mat!(match_basic_218, r"\\XXX", r"\XXX", Some((0, 4))); +mat!(match_basic_219, r".*(/000).*", r"/000", Some((0, 4)), Some((0, 4))); +mat!(match_basic_220, r".*(\\000).*", r"\000", Some((0, 4)), Some((0, 4))); +mat!(match_basic_221, r"\\000", r"\000", Some((0, 4))); + +// Tests from nullsubexpr.dat +mat!(match_nullsubexpr_3, r"(a*)*", r"a", Some((0, 1)), Some((0, 1))); +mat!(match_nullsubexpr_5, r"(a*)*", r"x", Some((0, 0)), None); +mat!(match_nullsubexpr_6, r"(a*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_7, r"(a*)*", r"aaaaaax", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_8, r"(a*)+", r"a", Some((0, 1)), Some((0, 1))); +mat!(match_nullsubexpr_9, r"(a*)+", r"x", Some((0, 0)), Some((0, 0))); +mat!(match_nullsubexpr_10, r"(a*)+", r"aaaaaa", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_11, r"(a*)+", r"aaaaaax", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_12, r"(a+)*", r"a", Some((0, 1)), Some((0, 1))); +mat!(match_nullsubexpr_13, r"(a+)*", r"x", Some((0, 0))); +mat!(match_nullsubexpr_14, r"(a+)*", r"aaaaaa", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_15, r"(a+)*", r"aaaaaax", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_16, r"(a+)+", r"a", Some((0, 1)), Some((0, 1))); +mat!(match_nullsubexpr_17, r"(a+)+", r"x", None); +mat!(match_nullsubexpr_18, r"(a+)+", r"aaaaaa", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_19, r"(a+)+", r"aaaaaax", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_21, r"([a]*)*", r"a", Some((0, 1)), Some((0, 1))); +mat!(match_nullsubexpr_23, r"([a]*)*", r"x", Some((0, 0)), None); +mat!(match_nullsubexpr_24, r"([a]*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_25, r"([a]*)*", r"aaaaaax", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_26, r"([a]*)+", r"a", Some((0, 1)), Some((0, 1))); +mat!(match_nullsubexpr_27, r"([a]*)+", r"x", Some((0, 0)), Some((0, 0))); +mat!(match_nullsubexpr_28, r"([a]*)+", r"aaaaaa", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_29, r"([a]*)+", r"aaaaaax", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_30, r"([^b]*)*", r"a", Some((0, 1)), Some((0, 1))); +mat!(match_nullsubexpr_32, r"([^b]*)*", r"b", Some((0, 0)), None); +mat!(match_nullsubexpr_33, r"([^b]*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))); +mat!( + match_nullsubexpr_34, + r"([^b]*)*", + r"aaaaaab", + Some((0, 6)), + Some((0, 6)) +); +mat!(match_nullsubexpr_35, r"([ab]*)*", r"a", Some((0, 1)), Some((0, 1))); +mat!(match_nullsubexpr_36, r"([ab]*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_37, r"([ab]*)*", r"ababab", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_38, r"([ab]*)*", r"bababa", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_39, r"([ab]*)*", r"b", Some((0, 1)), Some((0, 1))); +mat!(match_nullsubexpr_40, r"([ab]*)*", r"bbbbbb", Some((0, 6)), Some((0, 6))); +mat!( + match_nullsubexpr_41, + r"([ab]*)*", + r"aaaabcde", + Some((0, 5)), + Some((0, 5)) +); +mat!(match_nullsubexpr_42, r"([^a]*)*", r"b", Some((0, 1)), Some((0, 1))); +mat!(match_nullsubexpr_43, r"([^a]*)*", r"bbbbbb", Some((0, 6)), Some((0, 6))); +mat!(match_nullsubexpr_45, r"([^a]*)*", r"aaaaaa", Some((0, 0)), None); +mat!( + match_nullsubexpr_46, + r"([^ab]*)*", + r"ccccxx", + Some((0, 6)), + Some((0, 6)) +); +mat!(match_nullsubexpr_48, r"([^ab]*)*", r"ababab", Some((0, 0)), None); +mat!( + match_nullsubexpr_50, + r"((z)+|a)*", + r"zabcde", + Some((0, 2)), + Some((1, 2)) +); +mat!( + match_nullsubexpr_69, + r"(a*)*(x)", + r"x", + Some((0, 1)), + None, + Some((0, 1)) +); +mat!( + match_nullsubexpr_70, + r"(a*)*(x)", + r"ax", + Some((0, 2)), + Some((0, 1)), + Some((1, 2)) +); +mat!( + match_nullsubexpr_71, + r"(a*)*(x)", + r"axa", + Some((0, 2)), + Some((0, 1)), + Some((1, 2)) +); +mat!( + match_nullsubexpr_73, + r"(a*)+(x)", + r"x", + Some((0, 1)), + Some((0, 0)), + Some((0, 1)) +); +mat!( + match_nullsubexpr_74, + r"(a*)+(x)", + r"ax", + Some((0, 2)), + Some((0, 1)), + Some((1, 2)) +); +mat!( + match_nullsubexpr_75, + r"(a*)+(x)", + r"axa", + Some((0, 2)), + Some((0, 1)), + Some((1, 2)) +); +mat!( + match_nullsubexpr_77, + r"(a*){2}(x)", + r"x", + Some((0, 1)), + Some((0, 0)), + Some((0, 1)) +); +mat!( + match_nullsubexpr_78, + r"(a*){2}(x)", + r"ax", + Some((0, 2)), + Some((1, 1)), + Some((1, 2)) +); +mat!( + match_nullsubexpr_79, + r"(a*){2}(x)", + r"axa", + Some((0, 2)), + Some((1, 1)), + Some((1, 2)) +); + +// Tests from repetition.dat +mat!(match_repetition_10, r"((..)|(.))", r"", None); +mat!(match_repetition_11, r"((..)|(.))((..)|(.))", r"", None); +mat!(match_repetition_12, r"((..)|(.))((..)|(.))((..)|(.))", r"", None); +mat!(match_repetition_14, r"((..)|(.)){1}", r"", None); +mat!(match_repetition_15, r"((..)|(.)){2}", r"", None); +mat!(match_repetition_16, r"((..)|(.)){3}", r"", None); +mat!(match_repetition_18, r"((..)|(.))*", r"", Some((0, 0))); +mat!( + match_repetition_20, + r"((..)|(.))", + r"a", + Some((0, 1)), + Some((0, 1)), + None, + Some((0, 1)) +); +mat!(match_repetition_21, r"((..)|(.))((..)|(.))", r"a", None); +mat!(match_repetition_22, r"((..)|(.))((..)|(.))((..)|(.))", r"a", None); +mat!( + match_repetition_24, + r"((..)|(.)){1}", + r"a", + Some((0, 1)), + Some((0, 1)), + None, + Some((0, 1)) +); +mat!(match_repetition_25, r"((..)|(.)){2}", r"a", None); +mat!(match_repetition_26, r"((..)|(.)){3}", r"a", None); +mat!( + match_repetition_28, + r"((..)|(.))*", + r"a", + Some((0, 1)), + Some((0, 1)), + None, + Some((0, 1)) +); +mat!( + match_repetition_30, + r"((..)|(.))", + r"aa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_31, + r"((..)|(.))((..)|(.))", + r"aa", + Some((0, 2)), + Some((0, 1)), + None, + Some((0, 1)), + Some((1, 2)), + None, + Some((1, 2)) +); +mat!(match_repetition_32, r"((..)|(.))((..)|(.))((..)|(.))", r"aa", None); +mat!( + match_repetition_34, + r"((..)|(.)){1}", + r"aa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_35, + r"((..)|(.)){2}", + r"aa", + Some((0, 2)), + Some((1, 2)), + None, + Some((1, 2)) +); +mat!(match_repetition_36, r"((..)|(.)){3}", r"aa", None); +mat!( + match_repetition_38, + r"((..)|(.))*", + r"aa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_40, + r"((..)|(.))", + r"aaa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_41, + r"((..)|(.))((..)|(.))", + r"aaa", + Some((0, 3)), + Some((0, 2)), + Some((0, 2)), + None, + Some((2, 3)), + None, + Some((2, 3)) +); +mat!( + match_repetition_42, + r"((..)|(.))((..)|(.))((..)|(.))", + r"aaa", + Some((0, 3)), + Some((0, 1)), + None, + Some((0, 1)), + Some((1, 2)), + None, + Some((1, 2)), + Some((2, 3)), + None, + Some((2, 3)) +); +mat!( + match_repetition_44, + r"((..)|(.)){1}", + r"aaa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_46, + r"((..)|(.)){2}", + r"aaa", + Some((0, 3)), + Some((2, 3)), + Some((0, 2)), + Some((2, 3)) +); +mat!( + match_repetition_47, + r"((..)|(.)){3}", + r"aaa", + Some((0, 3)), + Some((2, 3)), + None, + Some((2, 3)) +); +mat!( + match_repetition_50, + r"((..)|(.))*", + r"aaa", + Some((0, 3)), + Some((2, 3)), + Some((0, 2)), + Some((2, 3)) +); +mat!( + match_repetition_52, + r"((..)|(.))", + r"aaaa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_53, + r"((..)|(.))((..)|(.))", + r"aaaa", + Some((0, 4)), + Some((0, 2)), + Some((0, 2)), + None, + Some((2, 4)), + Some((2, 4)), + None +); +mat!( + match_repetition_54, + r"((..)|(.))((..)|(.))((..)|(.))", + r"aaaa", + Some((0, 4)), + Some((0, 2)), + Some((0, 2)), + None, + Some((2, 3)), + None, + Some((2, 3)), + Some((3, 4)), + None, + Some((3, 4)) +); +mat!( + match_repetition_56, + r"((..)|(.)){1}", + r"aaaa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_57, + r"((..)|(.)){2}", + r"aaaa", + Some((0, 4)), + Some((2, 4)), + Some((2, 4)), + None +); +mat!( + match_repetition_59, + r"((..)|(.)){3}", + r"aaaa", + Some((0, 4)), + Some((3, 4)), + Some((0, 2)), + Some((3, 4)) +); +mat!( + match_repetition_61, + r"((..)|(.))*", + r"aaaa", + Some((0, 4)), + Some((2, 4)), + Some((2, 4)), + None +); +mat!( + match_repetition_63, + r"((..)|(.))", + r"aaaaa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_64, + r"((..)|(.))((..)|(.))", + r"aaaaa", + Some((0, 4)), + Some((0, 2)), + Some((0, 2)), + None, + Some((2, 4)), + Some((2, 4)), + None +); +mat!( + match_repetition_65, + r"((..)|(.))((..)|(.))((..)|(.))", + r"aaaaa", + Some((0, 5)), + Some((0, 2)), + Some((0, 2)), + None, + Some((2, 4)), + Some((2, 4)), + None, + Some((4, 5)), + None, + Some((4, 5)) +); +mat!( + match_repetition_67, + r"((..)|(.)){1}", + r"aaaaa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_68, + r"((..)|(.)){2}", + r"aaaaa", + Some((0, 4)), + Some((2, 4)), + Some((2, 4)), + None +); +mat!( + match_repetition_70, + r"((..)|(.)){3}", + r"aaaaa", + Some((0, 5)), + Some((4, 5)), + Some((2, 4)), + Some((4, 5)) +); +mat!( + match_repetition_73, + r"((..)|(.))*", + r"aaaaa", + Some((0, 5)), + Some((4, 5)), + Some((2, 4)), + Some((4, 5)) +); +mat!( + match_repetition_75, + r"((..)|(.))", + r"aaaaaa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_76, + r"((..)|(.))((..)|(.))", + r"aaaaaa", + Some((0, 4)), + Some((0, 2)), + Some((0, 2)), + None, + Some((2, 4)), + Some((2, 4)), + None +); +mat!( + match_repetition_77, + r"((..)|(.))((..)|(.))((..)|(.))", + r"aaaaaa", + Some((0, 6)), + Some((0, 2)), + Some((0, 2)), + None, + Some((2, 4)), + Some((2, 4)), + None, + Some((4, 6)), + Some((4, 6)), + None +); +mat!( + match_repetition_79, + r"((..)|(.)){1}", + r"aaaaaa", + Some((0, 2)), + Some((0, 2)), + Some((0, 2)), + None +); +mat!( + match_repetition_80, + r"((..)|(.)){2}", + r"aaaaaa", + Some((0, 4)), + Some((2, 4)), + Some((2, 4)), + None +); +mat!( + match_repetition_81, + r"((..)|(.)){3}", + r"aaaaaa", + Some((0, 6)), + Some((4, 6)), + Some((4, 6)), + None +); +mat!( + match_repetition_83, + r"((..)|(.))*", + r"aaaaaa", + Some((0, 6)), + Some((4, 6)), + Some((4, 6)), + None +); +mat!( + match_repetition_90, + r"X(.?){0,}Y", + r"X1234567Y", + Some((0, 9)), + Some((7, 8)) +); +mat!( + match_repetition_91, + r"X(.?){1,}Y", + r"X1234567Y", + Some((0, 9)), + Some((7, 8)) +); +mat!( + match_repetition_92, + r"X(.?){2,}Y", + r"X1234567Y", + Some((0, 9)), + Some((7, 8)) +); +mat!( + match_repetition_93, + r"X(.?){3,}Y", + r"X1234567Y", + Some((0, 9)), + Some((7, 8)) +); +mat!( + match_repetition_94, + r"X(.?){4,}Y", + r"X1234567Y", + Some((0, 9)), + Some((7, 8)) +); +mat!( + match_repetition_95, + r"X(.?){5,}Y", + r"X1234567Y", + Some((0, 9)), + Some((7, 8)) +); +mat!( + match_repetition_96, + r"X(.?){6,}Y", + r"X1234567Y", + Some((0, 9)), + Some((7, 8)) +); +mat!( + match_repetition_97, + r"X(.?){7,}Y", + r"X1234567Y", + Some((0, 9)), + Some((7, 8)) +); +mat!( + match_repetition_98, + r"X(.?){8,}Y", + r"X1234567Y", + Some((0, 9)), + Some((8, 8)) +); +mat!( + match_repetition_100, + r"X(.?){0,8}Y", + r"X1234567Y", + Some((0, 9)), + Some((8, 8)) +); +mat!( + match_repetition_102, + r"X(.?){1,8}Y", + r"X1234567Y", + Some((0, 9)), + Some((8, 8)) +); +mat!( + match_repetition_104, + r"X(.?){2,8}Y", + r"X1234567Y", + Some((0, 9)), + Some((8, 8)) +); +mat!( + match_repetition_106, + r"X(.?){3,8}Y", + r"X1234567Y", + Some((0, 9)), + Some((8, 8)) +); +mat!( + match_repetition_108, + r"X(.?){4,8}Y", + r"X1234567Y", + Some((0, 9)), + Some((8, 8)) +); +mat!( + match_repetition_110, + r"X(.?){5,8}Y", + r"X1234567Y", + Some((0, 9)), + Some((8, 8)) +); +mat!( + match_repetition_112, + r"X(.?){6,8}Y", + r"X1234567Y", + Some((0, 9)), + Some((8, 8)) +); +mat!( + match_repetition_114, + r"X(.?){7,8}Y", + r"X1234567Y", + Some((0, 9)), + Some((8, 8)) +); +mat!( + match_repetition_115, + r"X(.?){8,8}Y", + r"X1234567Y", + Some((0, 9)), + Some((8, 8)) +); +mat!( + match_repetition_126, + r"(a|ab|c|bcd){0,}(d*)", + r"ababcd", + Some((0, 1)), + Some((0, 1)), + Some((1, 1)) +); +mat!( + match_repetition_127, + r"(a|ab|c|bcd){1,}(d*)", + r"ababcd", + Some((0, 1)), + Some((0, 1)), + Some((1, 1)) +); +mat!( + match_repetition_128, + r"(a|ab|c|bcd){2,}(d*)", + r"ababcd", + Some((0, 6)), + Some((3, 6)), + Some((6, 6)) +); +mat!( + match_repetition_129, + r"(a|ab|c|bcd){3,}(d*)", + r"ababcd", + Some((0, 6)), + Some((3, 6)), + Some((6, 6)) +); +mat!(match_repetition_130, r"(a|ab|c|bcd){4,}(d*)", r"ababcd", None); +mat!( + match_repetition_131, + r"(a|ab|c|bcd){0,10}(d*)", + r"ababcd", + Some((0, 1)), + Some((0, 1)), + Some((1, 1)) +); +mat!( + match_repetition_132, + r"(a|ab|c|bcd){1,10}(d*)", + r"ababcd", + Some((0, 1)), + Some((0, 1)), + Some((1, 1)) +); +mat!( + match_repetition_133, + r"(a|ab|c|bcd){2,10}(d*)", + r"ababcd", + Some((0, 6)), + Some((3, 6)), + Some((6, 6)) +); +mat!( + match_repetition_134, + r"(a|ab|c|bcd){3,10}(d*)", + r"ababcd", + Some((0, 6)), + Some((3, 6)), + Some((6, 6)) +); +mat!(match_repetition_135, r"(a|ab|c|bcd){4,10}(d*)", r"ababcd", None); +mat!( + match_repetition_136, + r"(a|ab|c|bcd)*(d*)", + r"ababcd", + Some((0, 1)), + Some((0, 1)), + Some((1, 1)) +); +mat!( + match_repetition_137, + r"(a|ab|c|bcd)+(d*)", + r"ababcd", + Some((0, 1)), + Some((0, 1)), + Some((1, 1)) +); +mat!( + match_repetition_143, + r"(ab|a|c|bcd){0,}(d*)", + r"ababcd", + Some((0, 6)), + Some((4, 5)), + Some((5, 6)) +); +mat!( + match_repetition_145, + r"(ab|a|c|bcd){1,}(d*)", + r"ababcd", + Some((0, 6)), + Some((4, 5)), + Some((5, 6)) +); +mat!( + match_repetition_147, + r"(ab|a|c|bcd){2,}(d*)", + r"ababcd", + Some((0, 6)), + Some((4, 5)), + Some((5, 6)) +); +mat!( + match_repetition_149, + r"(ab|a|c|bcd){3,}(d*)", + r"ababcd", + Some((0, 6)), + Some((4, 5)), + Some((5, 6)) +); +mat!(match_repetition_150, r"(ab|a|c|bcd){4,}(d*)", r"ababcd", None); +mat!( + match_repetition_152, + r"(ab|a|c|bcd){0,10}(d*)", + r"ababcd", + Some((0, 6)), + Some((4, 5)), + Some((5, 6)) +); +mat!( + match_repetition_154, + r"(ab|a|c|bcd){1,10}(d*)", + r"ababcd", + Some((0, 6)), + Some((4, 5)), + Some((5, 6)) +); +mat!( + match_repetition_156, + r"(ab|a|c|bcd){2,10}(d*)", + r"ababcd", + Some((0, 6)), + Some((4, 5)), + Some((5, 6)) +); +mat!( + match_repetition_158, + r"(ab|a|c|bcd){3,10}(d*)", + r"ababcd", + Some((0, 6)), + Some((4, 5)), + Some((5, 6)) +); +mat!(match_repetition_159, r"(ab|a|c|bcd){4,10}(d*)", r"ababcd", None); +mat!( + match_repetition_161, + r"(ab|a|c|bcd)*(d*)", + r"ababcd", + Some((0, 6)), + Some((4, 5)), + Some((5, 6)) +); +mat!( + match_repetition_163, + r"(ab|a|c|bcd)+(d*)", + r"ababcd", + Some((0, 6)), + Some((4, 5)), + Some((5, 6)) +); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/macros.rs b/third_party/cargo/vendor/regex-1.3.3/tests/macros.rs new file mode 100644 index 0000000..e70e948 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/macros.rs @@ -0,0 +1,160 @@ +// Convenience macros. + +macro_rules! findall { + ($re:expr, $text:expr) => {{ + $re.find_iter(text!($text)) + .map(|m| (m.start(), m.end())).collect::<Vec<_>>() + }} +} + +// Macros for automatically producing tests. + +macro_rules! ismatch { + ($name:ident, $re:expr, $text:expr, $ismatch:expr) => { + #[test] + fn $name() { + let re = regex!($re); + assert_eq!($ismatch, re.is_match(text!($text))); + } + }; +} + +macro_rules! mat( + ($name:ident, $re:expr, $text:expr, $($loc:tt)+) => ( + #[test] + fn $name() { + let text = text!($text); + let expected: Vec<Option<_>> = vec![$($loc)+]; + let r = regex!($re); + let got: Vec<Option<_>> = match r.captures(text) { + Some(c) => { + assert!(r.is_match(text)); + assert!(r.shortest_match(text).is_some()); + r.capture_names() + .enumerate() + .map(|(i, _)| c.get(i).map(|m| (m.start(), m.end()))) + .collect() + } + None => vec![None], + }; + // The test set sometimes leave out capture groups, so truncate + // actual capture groups to match test set. + let mut sgot = &got[..]; + if sgot.len() > expected.len() { + sgot = &sgot[0..expected.len()] + } + if expected != sgot { + panic!("For RE '{}' against '{:?}', \ + expected '{:?}' but got '{:?}'", + $re, text, expected, sgot); + } + } + ); +); + +macro_rules! matiter( + ($name:ident, $re:expr, $text:expr) => ( + #[test] + fn $name() { + let text = text!($text); + let expected: Vec<(usize, usize)> = vec![]; + let r = regex!($re); + let got: Vec<_> = + r.find_iter(text).map(|m| (m.start(), m.end())).collect(); + if expected != got { + panic!("For RE '{}' against '{:?}', \ + expected '{:?}' but got '{:?}'", + $re, text, expected, got); + } + let captures_got: Vec<_> = + r.captures_iter(text) + .map(|c| c.get(0).unwrap()) + .map(|m| (m.start(), m.end())) + .collect(); + if captures_got != got { + panic!("For RE '{}' against '{:?}', \ + got '{:?}' using find_iter but got '{:?}' \ + using captures_iter", + $re, text, got, captures_got); + } + } + ); + ($name:ident, $re:expr, $text:expr, $($loc:tt)+) => ( + #[test] + fn $name() { + let text = text!($text); + let expected: Vec<_> = vec![$($loc)+]; + let r = regex!($re); + let got: Vec<_> = + r.find_iter(text).map(|m| (m.start(), m.end())).collect(); + if expected != got { + panic!("For RE '{}' against '{:?}', \ + expected '{:?}' but got '{:?}'", + $re, text, expected, got); + } + let captures_got: Vec<_> = + r.captures_iter(text) + .map(|c| c.get(0).unwrap()) + .map(|m| (m.start(), m.end())) + .collect(); + if captures_got != got { + panic!("For RE '{}' against '{:?}', \ + got '{:?}' using find_iter but got '{:?}' \ + using captures_iter", + $re, text, got, captures_got); + } + } + ); +); + +macro_rules! matset { + ($name:ident, $res:expr, $text:expr, $($match_index:expr),*) => { + #[test] + fn $name() { + let text = text!($text); + let set = regex_set!($res); + assert!(set.is_match(text)); + let expected = vec![$($match_index),*]; + let matches = set.matches(text); + assert!(matches.matched_any()); + let got: Vec<_> = matches.into_iter().collect(); + assert_eq!(expected, got); + } + } +} + +macro_rules! nomatset { + ($name:ident, $res:expr, $text:expr) => { + #[test] + fn $name() { + let text = text!($text); + let set = regex_set!($res); + assert!(!set.is_match(text)); + let matches = set.matches(text); + assert!(!matches.matched_any()); + assert_eq!(0, matches.into_iter().count()); + } + } +} + +macro_rules! split { + ($name:ident, $re:expr, $text:expr, $expected:expr) => { + #[test] + fn $name() { + let re = regex!($re); + let splitted: Vec<_> = re.split(t!($text)).collect(); + assert_eq!($expected, &*splitted); + } + } +} + +macro_rules! splitn { + ($name:ident, $re:expr, $text:expr, $limit:expr, $expected:expr) => { + #[test] + fn $name() { + let re = regex!($re); + let splitted: Vec<_> = re.splitn(t!($text), $limit).collect(); + assert_eq!($expected, &*splitted); + } + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/macros_bytes.rs b/third_party/cargo/vendor/regex-1.3.3/tests/macros_bytes.rs new file mode 100644 index 0000000..03c370d --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/macros_bytes.rs @@ -0,0 +1,40 @@ +// Macros for use in writing tests generic over &str/&[u8]. +macro_rules! text { ($text:expr) => { $text.as_bytes() } } +macro_rules! t { ($re:expr) => { text!($re) } } +macro_rules! match_text { ($text:expr) => { $text.as_bytes() } } +macro_rules! use_ { ($($path: tt)*) => { use regex::bytes::$($path)*; } } +macro_rules! empty_vec { () => { <Vec<&[u8]>>::new() } } + +macro_rules! bytes { ($text:expr) => { $text } } + +macro_rules! no_expand { + ($text:expr) => {{ + use regex::bytes::NoExpand; + NoExpand(text!($text)) + }} +} + +macro_rules! show { + ($text:expr) => {{ + use std::ascii::escape_default; + let mut s = vec![]; + for &b in bytes!($text) { + s.extend(escape_default(b)); + } + String::from_utf8(s).unwrap() + }} +} + +macro_rules! expand { + ($name:ident, $re:expr, $text:expr, $expand:expr, $expected:expr) => { + #[test] + fn $name() { + let re = regex!($re); + let cap = re.captures(t!($text)).unwrap(); + + let mut got = vec![]; + cap.expand(t!($expand), &mut got); + assert_eq!(show!(t!($expected)), show!(&*got)); + } + } +} diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/macros_str.rs b/third_party/cargo/vendor/regex-1.3.3/tests/macros_str.rs new file mode 100644 index 0000000..9b996b3 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/macros_str.rs @@ -0,0 +1,37 @@ +// Macros for use in writing tests generic over &str/&[u8]. +macro_rules! text { ($text:expr) => { $text } } +macro_rules! t { ($text:expr) => { text!($text) } } +macro_rules! match_text { ($text:expr) => { $text.as_str() } } +macro_rules! use_ { ($($path: tt)*) => { use regex::$($path)*; } } +macro_rules! empty_vec { () => { <Vec<&str>>::new() } } + +macro_rules! no_expand { + ($text:expr) => {{ + use regex::NoExpand; + NoExpand(text!($text)) + }} +} + +macro_rules! show { ($text:expr) => { $text } } + +// N.B. The expansion API for &str and &[u8] APIs differs slightly for now, +// but they should be unified in 1.0. Then we can move this macro back into +// tests/api.rs where it is used. ---AG +macro_rules! expand { + ($name:ident, $re:expr, $text:expr, $expand:expr, $expected:expr) => { + #[test] + fn $name() { + let re = regex!($re); + let cap = re.captures(t!($text)).unwrap(); + + let mut got = String::new(); + cap.expand(t!($expand), &mut got); + assert_eq!(show!(t!($expected)), show!(&*got)); + } + } +} + +#[cfg(feature = "pattern")] +macro_rules! searcher_expr { ($e:expr) => ($e) } +#[cfg(not(feature = "pattern"))] +macro_rules! searcher_expr { ($e:expr) => ({}) } diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/misc.rs b/third_party/cargo/vendor/regex-1.3.3/tests/misc.rs new file mode 100644 index 0000000..314811e --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/misc.rs @@ -0,0 +1,4 @@ +mat!(prefix_literal_match, r"^abc", r"abc", Some((0, 3))); +mat!(prefix_literal_nomatch, r"^abc", r"zabc", None); +mat!(one_literal_edge, r"abc", r"xxxxxab", None); +matiter!(terminates, r"a$", r"a", (0, 1)); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/multiline.rs b/third_party/cargo/vendor/regex-1.3.3/tests/multiline.rs new file mode 100644 index 0000000..62ee47b --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/multiline.rs @@ -0,0 +1,144 @@ +matiter!( + match_multi_1, + r"(?m)^[a-z]+$", + "abc\ndef\nxyz", + (0, 3), + (4, 7), + (8, 11) +); +matiter!(match_multi_2, r"(?m)^$", "abc\ndef\nxyz"); +matiter!(match_multi_3, r"(?m)^", "abc\ndef\nxyz", (0, 0), (4, 4), (8, 8)); +matiter!(match_multi_4, r"(?m)$", "abc\ndef\nxyz", (3, 3), (7, 7), (11, 11)); +matiter!( + match_multi_5, + r"(?m)^[a-z]", + "abc\ndef\nxyz", + (0, 1), + (4, 5), + (8, 9) +); +matiter!(match_multi_6, r"(?m)[a-z]^", "abc\ndef\nxyz"); +matiter!( + match_multi_7, + r"(?m)[a-z]$", + "abc\ndef\nxyz", + (2, 3), + (6, 7), + (10, 11) +); +matiter!(match_multi_8, r"(?m)$[a-z]", "abc\ndef\nxyz"); +matiter!(match_multi_9, r"(?m)^$", "", (0, 0)); + +matiter!( + match_multi_rep_1, + r"(?m)(?:^$)*", + "a\nb\nc", + (0, 0), + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5) +); +matiter!( + match_multi_rep_2, + r"(?m)(?:^|a)+", + "a\naaa\n", + (0, 0), + (2, 2), + (3, 5), + (6, 6) +); +matiter!( + match_multi_rep_3, + r"(?m)(?:^|a)*", + "a\naaa\n", + (0, 1), + (2, 5), + (6, 6) +); +matiter!( + match_multi_rep_4, + r"(?m)(?:^[a-z])+", + "abc\ndef\nxyz", + (0, 1), + (4, 5), + (8, 9) +); +matiter!( + match_multi_rep_5, + r"(?m)(?:^[a-z]{3}\n?)+", + "abc\ndef\nxyz", + (0, 11) +); +matiter!( + match_multi_rep_6, + r"(?m)(?:^[a-z]{3}\n?)*", + "abc\ndef\nxyz", + (0, 11) +); +matiter!( + match_multi_rep_7, + r"(?m)(?:\n?[a-z]{3}$)+", + "abc\ndef\nxyz", + (0, 11) +); +matiter!( + match_multi_rep_8, + r"(?m)(?:\n?[a-z]{3}$)*", + "abc\ndef\nxyz", + (0, 11) +); +matiter!( + match_multi_rep_9, + r"(?m)^*", + "\naa\n", + (0, 0), + (1, 1), + (2, 2), + (3, 3), + (4, 4) +); +matiter!(match_multi_rep_10, r"(?m)^+", "\naa\n", (0, 0), (1, 1), (4, 4)); +matiter!( + match_multi_rep_11, + r"(?m)$*", + "\naa\n", + (0, 0), + (1, 1), + (2, 2), + (3, 3), + (4, 4) +); +matiter!(match_multi_rep_12, r"(?m)$+", "\naa\n", (0, 0), (3, 3), (4, 4)); +matiter!(match_multi_rep_13, r"(?m)(?:$\n)+", "\n\naaa\n\n", (0, 2), (5, 7)); +matiter!( + match_multi_rep_14, + r"(?m)(?:$\n)*", + "\n\naaa\n\n", + (0, 2), + (3, 3), + (4, 4), + (5, 7) +); +matiter!(match_multi_rep_15, r"(?m)(?:$\n^)+", "\n\naaa\n\n", (0, 2), (5, 7)); +matiter!( + match_multi_rep_16, + r"(?m)(?:^|$)+", + "\n\naaa\n\n", + (0, 0), + (1, 1), + (2, 2), + (5, 5), + (6, 6), + (7, 7) +); +matiter!( + match_multi_rep_17, + r"(?m)(?:$\n)*", + "\n\naaa\n\n", + (0, 2), + (3, 3), + (4, 4), + (5, 7) +); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/noparse.rs b/third_party/cargo/vendor/regex-1.3.3/tests/noparse.rs new file mode 100644 index 0000000..62eb5be --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/noparse.rs @@ -0,0 +1,50 @@ +macro_rules! noparse( + ($name:ident, $re:expr) => ( + #[test] + fn $name() { + let re = $re; + match regex_new!(re) { + Err(_) => {}, + Ok(_) => panic!("Regex '{}' should cause a parse error.", re), + } + } + ); +); + +noparse!(fail_no_repeat_arg, "*"); +noparse!(fail_incomplete_escape, "\\"); +noparse!(fail_class_incomplete, "[A-"); +noparse!(fail_class_not_closed, "[A"); +noparse!(fail_class_no_begin, r"[\A]"); +noparse!(fail_class_no_end, r"[\z]"); +noparse!(fail_class_no_boundary, r"[\b]"); +noparse!(fail_open_paren, "("); +noparse!(fail_close_paren, ")"); +noparse!(fail_invalid_range, "[a-Z]"); +noparse!(fail_empty_capture_name, "(?P<>a)"); +noparse!(fail_bad_capture_name, "(?P<na-me>)"); +noparse!(fail_bad_flag, "(?a)a"); +noparse!(fail_too_big, "a{10000000}"); +noparse!(fail_counted_no_close, "a{1001"); +noparse!(fail_unfinished_cap, "(?"); +noparse!(fail_unfinished_escape, "\\"); +noparse!(fail_octal_digit, r"\8"); +noparse!(fail_hex_digit, r"\xG0"); +noparse!(fail_hex_short, r"\xF"); +noparse!(fail_hex_long_digits, r"\x{fffg}"); +noparse!(fail_flag_bad, "(?a)"); +noparse!(fail_flag_empty, "(?)"); +noparse!(fail_double_neg, "(?-i-i)"); +noparse!(fail_neg_empty, "(?i-)"); +noparse!(fail_dupe_named, "(?P<a>.)(?P<a>.)"); +noparse!(fail_range_end_no_class, "[a-[:lower:]]"); +noparse!(fail_range_end_no_begin, r"[a-\A]"); +noparse!(fail_range_end_no_end, r"[a-\z]"); +noparse!(fail_range_end_no_boundary, r"[a-\b]"); +noparse!(fail_empty_alt1, r"|z"); +noparse!(fail_empty_alt2, r"z|"); +noparse!(fail_empty_alt3, r"|"); +noparse!(fail_empty_alt4, r"||"); +noparse!(fail_empty_alt5, r"()|z"); +noparse!(fail_empty_alt6, r"z|()"); +noparse!(fail_empty_alt7, r"(|)"); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/regression.rs b/third_party/cargo/vendor/regex-1.3.3/tests/regression.rs new file mode 100644 index 0000000..4ab8c73 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/regression.rs @@ -0,0 +1,201 @@ +// See: https://github.com/rust-lang/regex/issues/48 +#[test] +fn invalid_regexes_no_crash() { + assert!(regex_new!("(*)").is_err()); + assert!(regex_new!("(?:?)").is_err()); + assert!(regex_new!("(?)").is_err()); + assert!(regex_new!("*").is_err()); +} + +// See: https://github.com/rust-lang/regex/issues/98 +#[test] +fn regression_many_repeat_stack_overflow() { + let re = regex!("^.{1,2500}"); + assert_eq!(vec![(0, 1)], findall!(re, "a")); +} + +// See: https://github.com/rust-lang/regex/issues/555 +#[test] +fn regression_invalid_repetition_expr() { + assert!(regex_new!("(?m){1,1}").is_err()); +} + +// See: https://github.com/rust-lang/regex/issues/527 +#[test] +fn regression_invalid_flags_expression() { + assert!(regex_new!("(((?x)))").is_ok()); +} + +// See: https://github.com/rust-lang/regex/issues/75 +mat!(regression_unsorted_binary_search_1, r"(?i-u)[a_]+", "A_", Some((0, 2))); +mat!(regression_unsorted_binary_search_2, r"(?i-u)[A_]+", "a_", Some((0, 2))); + +// See: https://github.com/rust-lang/regex/issues/99 +#[cfg(feature = "unicode-case")] +mat!(regression_negated_char_class_1, r"(?i)[^x]", "x", None); +#[cfg(feature = "unicode-case")] +mat!(regression_negated_char_class_2, r"(?i)[^x]", "X", None); + +// See: https://github.com/rust-lang/regex/issues/101 +mat!(regression_ascii_word_underscore, r"[[:word:]]", "_", Some((0, 1))); + +// See: https://github.com/rust-lang/regex/issues/129 +#[test] +fn regression_captures_rep() { + let re = regex!(r"([a-f]){2}(?P<foo>[x-z])"); + let caps = re.captures(text!("abx")).unwrap(); + assert_eq!(match_text!(caps.name("foo").unwrap()), text!("x")); +} + +// See: https://github.com/rust-lang/regex/issues/153 +mat!(regression_alt_in_alt1, r"ab?|$", "az", Some((0, 1))); +mat!(regression_alt_in_alt2, r"^(.*?)(\n|\r\n?|$)", "ab\rcd", Some((0, 3))); + +// See: https://github.com/rust-lang/regex/issues/169 +mat!(regression_leftmost_first_prefix, r"z*azb", "azb", Some((0, 3))); + +// See: https://github.com/rust-lang/regex/issues/76 +#[cfg(all(feature = "unicode-case", feature = "unicode-gencat"))] +mat!(uni_case_lower_nocase_flag, r"(?i)\p{Ll}+", "ΛΘΓΔα", Some((0, 10))); + +// See: https://github.com/rust-lang/regex/issues/191 +mat!(many_alternates, r"1|2|3|4|5|6|7|8|9|10|int", "int", Some((0, 3))); + +// burntsushi was bad and didn't create an issue for this bug. +mat!(anchored_prefix1, r"^a[[:^space:]]", "a ", None); +mat!(anchored_prefix2, r"^a[[:^space:]]", "foo boo a ", None); +mat!(anchored_prefix3, r"^-[a-z]", "r-f", None); + +// See: https://github.com/rust-lang/regex/issues/204 +#[cfg(feature = "unicode-perl")] +split!( + split_on_word_boundary, + r"\b", + r"Should this (work?)", + &[ + t!(""), + t!("Should"), + t!(" "), + t!("this"), + t!(" ("), + t!("work"), + t!("?)") + ] +); +#[cfg(feature = "unicode-perl")] +matiter!( + word_boundary_dfa, + r"\b", + "a b c", + (0, 0), + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5) +); + +// See: https://github.com/rust-lang/regex/issues/268 +matiter!(partial_anchor, r"^a|b", "ba", (0, 1)); + +// See: https://github.com/rust-lang/regex/issues/280 +ismatch!(partial_anchor_alternate_begin, r"^a|z", "yyyyya", false); +ismatch!(partial_anchor_alternate_end, r"a$|z", "ayyyyy", false); + +// See: https://github.com/rust-lang/regex/issues/289 +mat!(lits_unambiguous1, r"(ABC|CDA|BC)X", "CDAX", Some((0, 4))); + +// See: https://github.com/rust-lang/regex/issues/291 +mat!( + lits_unambiguous2, + r"((IMG|CAM|MG|MB2)_|(DSCN|CIMG))(?P<n>[0-9]+)$", + "CIMG2341", + Some((0, 8)), + Some((0, 4)), + None, + Some((0, 4)), + Some((4, 8)) +); + +// See: https://github.com/rust-lang/regex/issues/271 +mat!(endl_or_wb, r"(?m:$)|(?-u:\b)", "\u{6084e}", Some((4, 4))); +mat!(zero_or_end, r"(?i-u:\x00)|$", "\u{e682f}", Some((4, 4))); +mat!(y_or_endl, r"(?i-u:y)|(?m:$)", "\u{b4331}", Some((4, 4))); +#[cfg(feature = "unicode-perl")] +mat!(wb_start_x, r"(?u:\b)^(?-u:X)", "X", Some((0, 1))); + +// See: https://github.com/rust-lang/regex/issues/321 +ismatch!(strange_anchor_non_complete_prefix, r"a^{2}", "", false); +ismatch!(strange_anchor_non_complete_suffix, r"${2}a", "", false); + +// See: https://github.com/BurntSushi/ripgrep/issues/1203 +ismatch!(reverse_suffix1, r"[0-4][0-4][0-4]000", "153.230000", true); +ismatch!(reverse_suffix2, r"[0-9][0-9][0-9]000", "153.230000\n", true); +matiter!(reverse_suffix3, r"[0-9][0-9][0-9]000", "153.230000\n", (4, 10)); + +// See: https://github.com/rust-lang/regex/issues/334 +// See: https://github.com/rust-lang/regex/issues/557 +mat!( + captures_after_dfa_premature_end1, + r"a(b*(X|$))?", + "abcbX", + Some((0, 1)), + None, + None +); +mat!( + captures_after_dfa_premature_end2, + r"a(bc*(X|$))?", + "abcbX", + Some((0, 1)), + None, + None +); +mat!(captures_after_dfa_premature_end3, r"(aa$)?", "aaz", Some((0, 0))); + +// See: https://github.com/rust-lang/regex/issues/437 +ismatch!( + literal_panic, + r"typename type\-parameter\-[0-9]+\-[0-9]+::.+", + "test", + false +); + +// See: https://github.com/rust-lang/regex/issues/533 +ismatch!( + blank_matches_nothing_between_space_and_tab, + r"[[:blank:]]", + "\u{a}\u{b}\u{c}\u{d}\u{e}\u{f}\ + \u{10}\u{11}\u{12}\u{13}\u{14}\u{15}\u{16}\u{17}\ + \u{18}\u{19}\u{1a}\u{1b}\u{1c}\u{1d}\u{1e}\u{1f}", + false +); + +ismatch!( + inverted_blank_matches_everything_between_space_and_tab, + r"^[[:^blank:]]+$", + "\u{a}\u{b}\u{c}\u{d}\u{e}\u{f}\ + \u{10}\u{11}\u{12}\u{13}\u{14}\u{15}\u{16}\u{17}\ + \u{18}\u{19}\u{1a}\u{1b}\u{1c}\u{1d}\u{1e}\u{1f}", + true +); + +// Tests that our Aho-Corasick optimization works correctly. It only +// kicks in when we have >32 literals. By "works correctly," we mean that +// leftmost-first match semantics are properly respected. That is, samwise +// should match, not sam. +mat!( + ahocorasick1, + "samwise|sam|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|\ + A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", + "samwise", + Some((0, 7)) +); + +// See: https://github.com/BurntSushi/ripgrep/issues/1247 +#[test] +#[cfg(feature = "unicode-perl")] +fn regression_nfa_stops1() { + let re = ::regex::bytes::Regex::new(r"\bs(?:[ab])").unwrap(); + assert_eq!(0, re.find_iter(b"s\xE4").count()); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/replace.rs b/third_party/cargo/vendor/regex-1.3.3/tests/replace.rs new file mode 100644 index 0000000..c156a39 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/replace.rs @@ -0,0 +1,132 @@ +macro_rules! replace( + ($name:ident, $which:ident, $re:expr, + $search:expr, $replace:expr, $result:expr) => ( + #[test] + fn $name() { + let re = regex!($re); + assert_eq!(re.$which(text!($search), $replace), text!($result)); + } + ); +); + +replace!(first, replace, r"[0-9]", "age: 26", t!("Z"), "age: Z6"); +replace!(plus, replace, r"[0-9]+", "age: 26", t!("Z"), "age: Z"); +replace!(all, replace_all, r"[0-9]", "age: 26", t!("Z"), "age: ZZ"); +replace!( + groups, + replace, + r"(?-u)(\S+)\s+(\S+)", + "w1 w2", + t!("$2 $1"), + "w2 w1" +); +replace!( + double_dollar, + replace, + r"(?-u)(\S+)\s+(\S+)", + "w1 w2", + t!("$2 $$1"), + "w2 $1" +); +// replace!(adjacent_index, replace, +// r"([^aeiouy])ies$", "skies", t!("$1y"), "sky"); +replace!( + named, + replace_all, + r"(?-u)(?P<first>\S+)\s+(?P<last>\S+)(?P<space>\s*)", + "w1 w2 w3 w4", + t!("$last $first$space"), + "w2 w1 w4 w3" +); +replace!( + trim, + replace_all, + "^[ \t]+|[ \t]+$", + " \t trim me\t \t", + t!(""), + "trim me" +); +replace!(number_hypen, replace, r"(.)(.)", "ab", t!("$1-$2"), "a-b"); +// replace!(number_underscore, replace, r"(.)(.)", "ab", t!("$1_$2"), "a_b"); +replace!( + simple_expand, + replace_all, + r"(?-u)(\w) (\w)", + "a b", + t!("$2 $1"), + "b a" +); +replace!( + literal_dollar1, + replace_all, + r"(?-u)(\w+) (\w+)", + "a b", + t!("$$1"), + "$1" +); +replace!( + literal_dollar2, + replace_all, + r"(?-u)(\w+) (\w+)", + "a b", + t!("$2 $$c $1"), + "b $c a" +); +replace!( + no_expand1, + replace, + r"(?-u)(\S+)\s+(\S+)", + "w1 w2", + no_expand!("$2 $1"), + "$2 $1" +); +replace!( + no_expand2, + replace, + r"(?-u)(\S+)\s+(\S+)", + "w1 w2", + no_expand!("$$1"), + "$$1" +); +use_!(Captures); +replace!( + closure_returning_reference, + replace, + r"([0-9]+)", + "age: 26", + |captures: &Captures| { + match_text!(captures.get(1).unwrap())[0..1].to_owned() + }, + "age: 2" +); +replace!( + closure_returning_value, + replace, + r"[0-9]+", + "age: 26", + |_captures: &Captures| t!("Z").to_owned(), + "age: Z" +); + +// See https://github.com/rust-lang/regex/issues/314 +replace!( + match_at_start_replace_with_empty, + replace_all, + r"foo", + "foobar", + t!(""), + "bar" +); + +// See https://github.com/rust-lang/regex/issues/393 +replace!(single_empty_match, replace, r"^", "bar", t!("foo"), "foobar"); + +// See https://github.com/rust-lang/regex/issues/399 +replace!( + capture_longest_possible_name, + replace_all, + r"(.)", + "b", + t!("${1}a $1a"), + "ba " +); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/searcher.rs b/third_party/cargo/vendor/regex-1.3.3/tests/searcher.rs new file mode 100644 index 0000000..3779f54 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/searcher.rs @@ -0,0 +1,95 @@ +macro_rules! searcher { + ($name:ident, $re:expr, $haystack:expr) => ( + searcher!($name, $re, $haystack, vec vec![]); + ); + ($name:ident, $re:expr, $haystack:expr, $($steps:expr,)*) => ( + searcher!($name, $re, $haystack, vec vec![$($steps),*]); + ); + ($name:ident, $re:expr, $haystack:expr, $($steps:expr),*) => ( + searcher!($name, $re, $haystack, vec vec![$($steps),*]); + ); + ($name:ident, $re:expr, $haystack:expr, vec $expect_steps:expr) => ( + #[test] + #[allow(unused_imports)] + fn $name() { + searcher_expr! {{ + use std::str::pattern::{Pattern, Searcher}; + use std::str::pattern::SearchStep::{Match, Reject, Done}; + let re = regex!($re); + let mut se = re.into_searcher($haystack); + let mut got_steps = vec![]; + loop { + match se.next() { + Done => break, + step => { got_steps.push(step); } + } + } + assert_eq!(got_steps, $expect_steps); + }} + } + ); +} + +searcher!(searcher_empty_regex_empty_haystack, r"", "", Match(0, 0)); +searcher!( + searcher_empty_regex, + r"", + "ab", + Match(0, 0), + Reject(0, 1), + Match(1, 1), + Reject(1, 2), + Match(2, 2) +); +searcher!(searcher_empty_haystack, r"\d", ""); +searcher!(searcher_one_match, r"\d", "5", Match(0, 1)); +searcher!(searcher_no_match, r"\d", "a", Reject(0, 1)); +searcher!( + searcher_two_adjacent_matches, + r"\d", + "56", + Match(0, 1), + Match(1, 2) +); +searcher!( + searcher_two_non_adjacent_matches, + r"\d", + "5a6", + Match(0, 1), + Reject(1, 2), + Match(2, 3) +); +searcher!(searcher_reject_first, r"\d", "a6", Reject(0, 1), Match(1, 2)); +searcher!( + searcher_one_zero_length_matches, + r"\d*", + "a1b2", + Match(0, 0), // ^ + Reject(0, 1), // a + Match(1, 2), // a1 + Reject(2, 3), // a1b + Match(3, 4), // a1b2 +); +searcher!( + searcher_many_zero_length_matches, + r"\d*", + "a1bbb2", + Match(0, 0), // ^ + Reject(0, 1), // a + Match(1, 2), // a1 + Reject(2, 3), // a1b + Match(3, 3), // a1bb + Reject(3, 4), // a1bb + Match(4, 4), // a1bbb + Reject(4, 5), // a1bbb + Match(5, 6), // a1bbba +); +searcher!( + searcher_unicode, + r".+?", + "Ⅰ1Ⅱ2", + Match(0, 3), + Match(3, 4), + Match(4, 7), + Match(7, 8) +); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/set.rs b/third_party/cargo/vendor/regex-1.3.3/tests/set.rs new file mode 100644 index 0000000..3e9755c --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/set.rs @@ -0,0 +1,45 @@ +matset!(set1, &["a", "a"], "a", 0, 1); +matset!(set2, &["a", "a"], "ba", 0, 1); +matset!(set3, &["a", "b"], "a", 0); +matset!(set4, &["a", "b"], "b", 1); +matset!(set5, &["a|b", "b|a"], "b", 0, 1); +matset!(set6, &["foo", "oo"], "foo", 0, 1); +matset!(set7, &["^foo", "bar$"], "foo", 0); +matset!(set8, &["^foo", "bar$"], "foo bar", 0, 1); +matset!(set9, &["^foo", "bar$"], "bar", 1); +matset!(set10, &[r"[a-z]+$", "foo"], "01234 foo", 0, 1); +matset!(set11, &[r"[a-z]+$", "foo"], "foo 01234", 1); +matset!(set12, &[r".*?", "a"], "zzzzzza", 0, 1); +matset!(set13, &[r".*", "a"], "zzzzzza", 0, 1); +matset!(set14, &[r".*", "a"], "zzzzzz", 0); +matset!(set15, &[r"(?-u)\ba\b"], "hello a bye", 0); +matset!(set16, &["a"], "a", 0); +matset!(set17, &[".*a"], "a", 0); +matset!(set18, &["a", "β"], "β", 1); + +nomatset!(nset1, &["a", "a"], "b"); +nomatset!(nset2, &["^foo", "bar$"], "bar foo"); +nomatset!( + nset3, + { + let xs: &[&str] = &[]; + xs + }, + "a" +); +nomatset!(nset4, &[r"^rooted$", r"\.log$"], "notrooted"); + +// See: https://github.com/rust-lang/regex/issues/187 +#[test] +fn regression_subsequent_matches() { + let set = regex_set!(&["ab", "b"]); + let text = text!("ba"); + assert!(set.matches(text).matched(1)); + assert!(set.matches(text).matched(1)); +} + +#[test] +fn get_set_patterns() { + let set = regex_set!(&["a", "b"]); + assert_eq!(vec!["a", "b"], set.patterns()); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/shortest_match.rs b/third_party/cargo/vendor/regex-1.3.3/tests/shortest_match.rs new file mode 100644 index 0000000..f8b4fed --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/shortest_match.rs @@ -0,0 +1,14 @@ +macro_rules! shortmat { + ($name:ident, $re:expr, $text:expr, $shortest_match:expr) => { + #[test] + fn $name() { + let text = text!($text); + let re = regex!($re); + assert_eq!($shortest_match, re.shortest_match(text)); + } + }; +} + +shortmat!(t01, r"a+", r"aa", Some(1)); +// Test that the reverse suffix optimization gets it right. +shortmat!(t02, r".*(?:abcd)+", r"abcdabcd", Some(4)); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/suffix_reverse.rs b/third_party/cargo/vendor/regex-1.3.3/tests/suffix_reverse.rs new file mode 100644 index 0000000..774c9e8 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/suffix_reverse.rs @@ -0,0 +1,6 @@ +mat!(t01, r".*abcd", r"abcd", Some((0, 4))); +mat!(t02, r".*(?:abcd)+", r"abcd", Some((0, 4))); +mat!(t03, r".*(?:abcd)+", r"abcdabcd", Some((0, 8))); +mat!(t04, r".*(?:abcd)+", r"abcdxabcd", Some((0, 9))); +mat!(t05, r".*x(?:abcd)+", r"abcdxabcd", Some((0, 9))); +mat!(t06, r"[^abcd]*x(?:abcd)+", r"abcdxabcd", Some((4, 9))); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/test_backtrack.rs b/third_party/cargo/vendor/regex-1.3.3/tests/test_backtrack.rs new file mode 100644 index 0000000..617185f --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/test_backtrack.rs @@ -0,0 +1,59 @@ +#![cfg_attr(feature = "pattern", feature(pattern))] + +extern crate rand; +extern crate regex; + +macro_rules! regex_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new($re) + .bounded_backtracking() + .build() + .map(|e| e.into_regex()) + }}; +} + +macro_rules! regex { + ($re:expr) => { + regex_new!($re).unwrap() + }; +} + +macro_rules! regex_set_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new_many($re) + .bounded_backtracking() + .build() + .map(|e| e.into_regex_set()) + }}; +} + +macro_rules! regex_set { + ($res:expr) => { + regex_set_new!($res).unwrap() + }; +} + +// Must come before other module definitions. +include!("macros_str.rs"); +include!("macros.rs"); + +mod api; +mod api_str; +mod crazy; +mod flags; +mod fowler; +mod multiline; +mod noparse; +mod regression; +mod replace; +mod searcher; +mod set; +mod suffix_reverse; +#[cfg(feature = "unicode")] +mod unicode; +#[cfg(feature = "unicode-perl")] +mod word_boundary; +#[cfg(feature = "unicode-perl")] +mod word_boundary_unicode; diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/test_backtrack_bytes.rs b/third_party/cargo/vendor/regex-1.3.3/tests/test_backtrack_bytes.rs new file mode 100644 index 0000000..17df4d8 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/test_backtrack_bytes.rs @@ -0,0 +1,58 @@ +extern crate rand; +extern crate regex; + +macro_rules! regex_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new($re) + .bounded_backtracking() + .only_utf8(false) + .build() + .map(|e| e.into_byte_regex()) + }}; +} + +macro_rules! regex { + ($re:expr) => { + regex_new!($re).unwrap() + }; +} + +macro_rules! regex_set_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new_many($re) + .bounded_backtracking() + .only_utf8(false) + .build() + .map(|e| e.into_byte_regex_set()) + }}; +} + +macro_rules! regex_set { + ($res:expr) => { + regex_set_new!($res).unwrap() + }; +} + +// Must come before other module definitions. +include!("macros_bytes.rs"); +include!("macros.rs"); + +mod api; +mod bytes; +mod crazy; +mod flags; +mod fowler; +mod multiline; +mod noparse; +mod regression; +mod replace; +mod set; +mod suffix_reverse; +#[cfg(feature = "unicode")] +mod unicode; +#[cfg(feature = "unicode-perl")] +mod word_boundary; +#[cfg(feature = "unicode-perl")] +mod word_boundary_ascii; diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/test_backtrack_utf8bytes.rs b/third_party/cargo/vendor/regex-1.3.3/tests/test_backtrack_utf8bytes.rs new file mode 100644 index 0000000..78a0135 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/test_backtrack_utf8bytes.rs @@ -0,0 +1,61 @@ +#![cfg_attr(feature = "pattern", feature(pattern))] + +extern crate rand; +extern crate regex; + +macro_rules! regex_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new($re) + .bounded_backtracking() + .bytes(true) + .build() + .map(|e| e.into_regex()) + }}; +} + +macro_rules! regex { + ($re:expr) => { + regex_new!($re).unwrap() + }; +} + +macro_rules! regex_set_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new_many($re) + .bounded_backtracking() + .bytes(true) + .build() + .map(|e| e.into_regex_set()) + }}; +} + +macro_rules! regex_set { + ($res:expr) => { + regex_set_new!($res).unwrap() + }; +} + +// Must come before other module definitions. +include!("macros_str.rs"); +include!("macros.rs"); + +mod api; +mod api_str; +mod crazy; +mod flags; +mod fowler; +mod multiline; +mod noparse; +mod regression; +mod replace; +mod searcher; +mod set; +mod suffix_reverse; +#[cfg(feature = "unicode")] +mod unicode; +#[cfg(feature = "unicode-perl")] +mod word_boundary; +#[cfg(feature = "unicode-perl")] +mod word_boundary_unicode; diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/test_crates_regex.rs b/third_party/cargo/vendor/regex-1.3.3/tests/test_crates_regex.rs new file mode 100644 index 0000000..d697683 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/test_crates_regex.rs @@ -0,0 +1,57 @@ +extern crate quickcheck; +extern crate regex; + +/* + * This test is a minimal version of <rofl_0> and <subdiff_0> + * + * Once this bug gets fixed, uncomment rofl_0 and subdiff_0 + * (in `tests/crates_regex.rs`). +#[test] +fn word_boundary_backtracking_default_mismatch() { + use regex::internal::ExecBuilder; + + let backtrack_re = ExecBuilder::new(r"\b") + .bounded_backtracking() + .build() + .map(|exec| exec.into_regex()) + .map_err(|err| format!("{}", err)) + .unwrap(); + + let default_re = ExecBuilder::new(r"\b") + .build() + .map(|exec| exec.into_regex()) + .map_err(|err| format!("{}", err)) + .unwrap(); + + let input = "䅅\\u{a0}"; + + let fi1 = backtrack_re.find_iter(input); + let fi2 = default_re.find_iter(input); + for (m1, m2) in fi1.zip(fi2) { + assert_eq!(m1, m2); + } +} +*/ + +mod consistent; + +mod crates_regex { + + macro_rules! consistent { + ($test_name:ident, $regex_src:expr) => { + #[test] + fn $test_name() { + use super::consistent::backends_are_consistent; + + if option_env!("RUST_REGEX_RANDOM_TEST").is_some() { + match backends_are_consistent($regex_src) { + Ok(_) => {} + Err(err) => panic!("{}", err), + } + } + } + }; + } + + include!("crates_regex.rs"); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/test_default.rs b/third_party/cargo/vendor/regex-1.3.3/tests/test_default.rs new file mode 100644 index 0000000..c0979c1 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/test_default.rs @@ -0,0 +1,114 @@ +#![cfg_attr(feature = "pattern", feature(pattern))] + +extern crate rand; +extern crate regex; + +// Due to macro scoping rules, this definition only applies for the modules +// defined below. Effectively, it allows us to use the same tests for both +// native and dynamic regexes. +// +// This is also used to test the various matching engines. This one exercises +// the normal code path which automatically chooses the engine based on the +// regex and the input. Other dynamic tests explicitly set the engine to use. +macro_rules! regex_new { + ($re:expr) => {{ + use regex::Regex; + Regex::new($re) + }}; +} + +macro_rules! regex { + ($re:expr) => { + regex_new!($re).unwrap() + }; +} + +macro_rules! regex_set_new { + ($re:expr) => {{ + use regex::RegexSet; + RegexSet::new($re) + }}; +} + +macro_rules! regex_set { + ($res:expr) => { + regex_set_new!($res).unwrap() + }; +} + +// Must come before other module definitions. +include!("macros_str.rs"); +include!("macros.rs"); + +mod api; +mod api_str; +mod crazy; +mod flags; +mod fowler; +mod misc; +mod multiline; +mod noparse; +mod regression; +mod replace; +mod searcher; +mod set; +mod shortest_match; +mod suffix_reverse; +#[cfg(feature = "unicode")] +mod unicode; +#[cfg(feature = "unicode-perl")] +mod word_boundary; +#[cfg(feature = "unicode-perl")] +mod word_boundary_unicode; + +#[test] +fn disallow_non_utf8() { + assert!(regex::Regex::new(r"(?-u)\xFF").is_err()); + assert!(regex::Regex::new(r"(?-u).").is_err()); + assert!(regex::Regex::new(r"(?-u)[\xFF]").is_err()); + assert!(regex::Regex::new(r"(?-u)☃").is_err()); +} + +#[test] +fn disallow_octal() { + assert!(regex::Regex::new(r"\0").is_err()); +} + +#[test] +fn allow_octal() { + assert!(regex::RegexBuilder::new(r"\0").octal(true).build().is_ok()); +} + +#[test] +fn oibits() { + use regex::bytes; + use regex::{Regex, RegexBuilder}; + use std::panic::UnwindSafe; + + fn assert_send<T: Send>() {} + fn assert_sync<T: Sync>() {} + fn assert_unwind_safe<T: UnwindSafe>() {} + + assert_send::<Regex>(); + assert_sync::<Regex>(); + assert_unwind_safe::<Regex>(); + assert_send::<RegexBuilder>(); + assert_sync::<RegexBuilder>(); + assert_unwind_safe::<RegexBuilder>(); + + assert_send::<bytes::Regex>(); + assert_sync::<bytes::Regex>(); + assert_unwind_safe::<bytes::Regex>(); + assert_send::<bytes::RegexBuilder>(); + assert_sync::<bytes::RegexBuilder>(); + assert_unwind_safe::<bytes::RegexBuilder>(); +} + +// See: https://github.com/rust-lang/regex/issues/568 +#[test] +fn oibits_regression() { + use regex::Regex; + use std::panic; + + let _ = panic::catch_unwind(|| Regex::new("a").unwrap()); +} diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/test_default_bytes.rs b/third_party/cargo/vendor/regex-1.3.3/tests/test_default_bytes.rs new file mode 100644 index 0000000..e4a25dc --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/test_default_bytes.rs @@ -0,0 +1,78 @@ +extern crate rand; +extern crate regex; + +macro_rules! regex_new { + ($re:expr) => {{ + use regex::bytes::Regex; + Regex::new($re) + }}; +} + +macro_rules! regex_set_new { + ($res:expr) => {{ + use regex::bytes::RegexSet; + RegexSet::new($res) + }}; +} + +macro_rules! regex { + ($re:expr) => { + regex_new!($re).unwrap() + }; +} + +macro_rules! regex_set { + ($res:expr) => { + regex_set_new!($res).unwrap() + }; +} + +// Must come before other module definitions. +include!("macros_bytes.rs"); +include!("macros.rs"); + +// A silly wrapper to make it possible to write and match raw bytes. +struct R<'a>(&'a [u8]); +impl<'a> R<'a> { + fn as_bytes(&self) -> &'a [u8] { + self.0 + } +} + +// See: https://github.com/rust-lang/regex/issues/321 +// +// These tests are here because they do not have the same behavior in every +// regex engine. +mat!(invalid_utf8_nfa1, r".", R(b"\xD4\xC2\x65\x2B\x0E\xFE"), Some((2, 3))); +mat!(invalid_utf8_nfa2, r"${2}ä", R(b"\xD4\xC2\x65\x2B\x0E\xFE"), None); +mat!( + invalid_utf8_nfa3, + r".", + R(b"\x0A\xDB\x82\x6E\x33\x01\xDD\x33\xCD"), + Some((1, 3)) +); +mat!( + invalid_utf8_nfa4, + r"${2}ä", + R(b"\x0A\xDB\x82\x6E\x33\x01\xDD\x33\xCD"), + None +); + +mod api; +mod bytes; +mod crazy; +mod flags; +mod fowler; +mod multiline; +mod noparse; +mod regression; +mod replace; +mod set; +mod shortest_match; +mod suffix_reverse; +#[cfg(feature = "unicode")] +mod unicode; +#[cfg(feature = "unicode-perl")] +mod word_boundary; +#[cfg(feature = "unicode-perl")] +mod word_boundary_unicode; diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/test_nfa.rs b/third_party/cargo/vendor/regex-1.3.3/tests/test_nfa.rs new file mode 100644 index 0000000..05dad23 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/test_nfa.rs @@ -0,0 +1,53 @@ +#![cfg_attr(feature = "pattern", feature(pattern))] + +extern crate rand; +extern crate regex; + +macro_rules! regex_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new($re).nfa().build().map(|e| e.into_regex()) + }}; +} + +macro_rules! regex { + ($re:expr) => { + regex_new!($re).unwrap() + }; +} + +macro_rules! regex_set_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new_many($re).nfa().build().map(|e| e.into_regex_set()) + }}; +} + +macro_rules! regex_set { + ($res:expr) => { + regex_set_new!($res).unwrap() + }; +} + +// Must come before other module definitions. +include!("macros_str.rs"); +include!("macros.rs"); + +mod api; +mod api_str; +mod crazy; +mod flags; +mod fowler; +mod multiline; +mod noparse; +mod regression; +mod replace; +mod searcher; +mod set; +mod suffix_reverse; +#[cfg(feature = "unicode")] +mod unicode; +#[cfg(feature = "unicode-perl")] +mod word_boundary; +#[cfg(feature = "unicode-perl")] +mod word_boundary_unicode; diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/test_nfa_bytes.rs b/third_party/cargo/vendor/regex-1.3.3/tests/test_nfa_bytes.rs new file mode 100644 index 0000000..1042318 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/test_nfa_bytes.rs @@ -0,0 +1,58 @@ +extern crate rand; +extern crate regex; + +macro_rules! regex_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new($re) + .nfa() + .only_utf8(false) + .build() + .map(|e| e.into_byte_regex()) + }}; +} + +macro_rules! regex { + ($re:expr) => { + regex_new!($re).unwrap() + }; +} + +macro_rules! regex_set_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new_many($re) + .nfa() + .only_utf8(false) + .build() + .map(|e| e.into_byte_regex_set()) + }}; +} + +macro_rules! regex_set { + ($res:expr) => { + regex_set_new!($res).unwrap() + }; +} + +// Must come before other module definitions. +include!("macros_bytes.rs"); +include!("macros.rs"); + +mod api; +mod bytes; +mod crazy; +mod flags; +mod fowler; +mod multiline; +mod noparse; +mod regression; +mod replace; +mod set; +mod suffix_reverse; +#[cfg(feature = "unicode")] +mod unicode; +#[cfg(feature = "unicode-perl")] +mod word_boundary; +#[cfg(feature = "unicode-perl")] +mod word_boundary_unicode; diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/test_nfa_utf8bytes.rs b/third_party/cargo/vendor/regex-1.3.3/tests/test_nfa_utf8bytes.rs new file mode 100644 index 0000000..86487a1 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/test_nfa_utf8bytes.rs @@ -0,0 +1,57 @@ +#![cfg_attr(feature = "pattern", feature(pattern))] + +extern crate rand; +extern crate regex; + +macro_rules! regex_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new($re).nfa().bytes(true).build().map(|e| e.into_regex()) + }}; +} + +macro_rules! regex { + ($re:expr) => { + regex_new!($re).unwrap() + }; +} + +macro_rules! regex_set_new { + ($re:expr) => {{ + use regex::internal::ExecBuilder; + ExecBuilder::new_many($re) + .nfa() + .bytes(true) + .build() + .map(|e| e.into_regex_set()) + }}; +} + +macro_rules! regex_set { + ($res:expr) => { + regex_set_new!($res).unwrap() + }; +} + +// Must come before other module definitions. +include!("macros_str.rs"); +include!("macros.rs"); + +mod api; +mod api_str; +mod crazy; +mod flags; +mod fowler; +mod multiline; +mod noparse; +mod regression; +mod replace; +mod searcher; +mod set; +mod suffix_reverse; +#[cfg(feature = "unicode")] +mod unicode; +#[cfg(feature = "unicode-perl")] +mod word_boundary; +#[cfg(feature = "unicode-perl")] +mod word_boundary_unicode; diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/unicode.rs b/third_party/cargo/vendor/regex-1.3.3/tests/unicode.rs new file mode 100644 index 0000000..52522f4 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/unicode.rs @@ -0,0 +1,231 @@ +mat!(uni_literal, r"☃", "☃", Some((0, 3))); +mat!(uni_literal_plus, r"☃+", "☃", Some((0, 3))); +mat!(uni_literal_casei_plus, r"(?i)☃+", "☃", Some((0, 3))); +mat!(uni_class_plus, r"[☃Ⅰ]+", "☃", Some((0, 3))); +mat!(uni_one, r"\pN", "Ⅰ", Some((0, 3))); +mat!(uni_mixed, r"\pN+", "Ⅰ1Ⅱ2", Some((0, 8))); +mat!(uni_not, r"\PN+", "abⅠ", Some((0, 2))); +mat!(uni_not_class, r"[\PN]+", "abⅠ", Some((0, 2))); +mat!(uni_not_class_neg, r"[^\PN]+", "abⅠ", Some((2, 5))); +mat!(uni_case, r"(?i)Δ", "δ", Some((0, 2))); +mat!(uni_case_upper, r"\p{Lu}+", "ΛΘΓΔα", Some((0, 8))); +mat!(uni_case_upper_nocase_flag, r"(?i)\p{Lu}+", "ΛΘΓΔα", Some((0, 10))); +mat!(uni_case_upper_nocase, r"\p{L}+", "ΛΘΓΔα", Some((0, 10))); +mat!(uni_case_lower, r"\p{Ll}+", "ΛΘΓΔα", Some((8, 10))); + +// Test the Unicode friendliness of Perl character classes. +mat!(uni_perl_w, r"\w+", "dδd", Some((0, 4))); +mat!(uni_perl_w_not, r"\w+", "⥡", None); +mat!(uni_perl_w_neg, r"\W+", "⥡", Some((0, 3))); +mat!(uni_perl_d, r"\d+", "1२३9", Some((0, 8))); +mat!(uni_perl_d_not, r"\d+", "Ⅱ", None); +mat!(uni_perl_d_neg, r"\D+", "Ⅱ", Some((0, 3))); +mat!(uni_perl_s, r"\s+", " ", Some((0, 3))); +mat!(uni_perl_s_not, r"\s+", "☃", None); +mat!(uni_perl_s_neg, r"\S+", "☃", Some((0, 3))); + +// And do the same for word boundaries. +mat!(uni_boundary_none, r"\d\b", "6δ", None); +mat!(uni_boundary_ogham, r"\d\b", "6 ", Some((0, 1))); +mat!(uni_not_boundary_none, r"\d\B", "6δ", Some((0, 1))); +mat!(uni_not_boundary_ogham, r"\d\B", "6 ", None); + +// Test general categories. +// +// We should test more, but there's a lot. Write a script to generate more of +// these tests. +mat!(uni_class_gencat_cased_letter, r"\p{Cased_Letter}", "A", Some((0, 3))); +mat!( + uni_class_gencat_close_punctuation, + r"\p{Close_Punctuation}", + "❯", + Some((0, 3)) +); +mat!( + uni_class_gencat_connector_punctuation, + r"\p{Connector_Punctuation}", + "⁀", + Some((0, 3)) +); +mat!(uni_class_gencat_control, r"\p{Control}", "\u{9f}", Some((0, 2))); +mat!( + uni_class_gencat_currency_symbol, + r"\p{Currency_Symbol}", + "£", + Some((0, 3)) +); +mat!( + uni_class_gencat_dash_punctuation, + r"\p{Dash_Punctuation}", + "〰", + Some((0, 3)) +); +mat!(uni_class_gencat_decimal_numer, r"\p{Decimal_Number}", "𑓙", Some((0, 4))); +mat!( + uni_class_gencat_enclosing_mark, + r"\p{Enclosing_Mark}", + "\u{A672}", + Some((0, 3)) +); +mat!( + uni_class_gencat_final_punctuation, + r"\p{Final_Punctuation}", + "⸡", + Some((0, 3)) +); +mat!(uni_class_gencat_format, r"\p{Format}", "\u{E007F}", Some((0, 4))); +mat!( + uni_class_gencat_initial_punctuation, + r"\p{Initial_Punctuation}", + "⸜", + Some((0, 3)) +); +mat!(uni_class_gencat_letter, r"\p{Letter}", "Έ", Some((0, 2))); +mat!(uni_class_gencat_letter_number, r"\p{Letter_Number}", "ↂ", Some((0, 3))); +mat!( + uni_class_gencat_line_separator, + r"\p{Line_Separator}", + "\u{2028}", + Some((0, 3)) +); +mat!( + uni_class_gencat_lowercase_letter, + r"\p{Lowercase_Letter}", + "ϛ", + Some((0, 2)) +); +mat!(uni_class_gencat_mark, r"\p{Mark}", "\u{E01EF}", Some((0, 4))); +mat!(uni_class_gencat_math, r"\p{Math}", "⋿", Some((0, 3))); +mat!( + uni_class_gencat_modifier_letter, + r"\p{Modifier_Letter}", + "𖭃", + Some((0, 4)) +); +mat!( + uni_class_gencat_modifier_symbol, + r"\p{Modifier_Symbol}", + "🏿", + Some((0, 4)) +); +mat!( + uni_class_gencat_nonspacing_mark, + r"\p{Nonspacing_Mark}", + "\u{1E94A}", + Some((0, 4)) +); +mat!(uni_class_gencat_number, r"\p{Number}", "⓿", Some((0, 3))); +mat!( + uni_class_gencat_open_punctuation, + r"\p{Open_Punctuation}", + "⦅", + Some((0, 3)) +); +mat!(uni_class_gencat_other, r"\p{Other}", "\u{bc9}", Some((0, 3))); +mat!(uni_class_gencat_other_letter, r"\p{Other_Letter}", "ꓷ", Some((0, 3))); +mat!(uni_class_gencat_other_number, r"\p{Other_Number}", "㉏", Some((0, 3))); +mat!( + uni_class_gencat_other_punctuation, + r"\p{Other_Punctuation}", + "𞥞", + Some((0, 4)) +); +mat!(uni_class_gencat_other_symbol, r"\p{Other_Symbol}", "⅌", Some((0, 3))); +mat!( + uni_class_gencat_paragraph_separator, + r"\p{Paragraph_Separator}", + "\u{2029}", + Some((0, 3)) +); +mat!( + uni_class_gencat_private_use, + r"\p{Private_Use}", + "\u{10FFFD}", + Some((0, 4)) +); +mat!(uni_class_gencat_punctuation, r"\p{Punctuation}", "𑁍", Some((0, 4))); +mat!(uni_class_gencat_separator, r"\p{Separator}", "\u{3000}", Some((0, 3))); +mat!( + uni_class_gencat_space_separator, + r"\p{Space_Separator}", + "\u{205F}", + Some((0, 3)) +); +mat!( + uni_class_gencat_spacing_mark, + r"\p{Spacing_Mark}", + "\u{16F7E}", + Some((0, 4)) +); +mat!(uni_class_gencat_symbol, r"\p{Symbol}", "⯈", Some((0, 3))); +mat!( + uni_class_gencat_titlecase_letter, + r"\p{Titlecase_Letter}", + "ῼ", + Some((0, 3)) +); +mat!( + uni_class_gencat_unassigned, + r"\p{Unassigned}", + "\u{10FFFF}", + Some((0, 4)) +); +mat!( + uni_class_gencat_uppercase_letter, + r"\p{Uppercase_Letter}", + "Ꝋ", + Some((0, 3)) +); + +// Test a smattering of properties. +mat!(uni_class_prop_emoji1, r"\p{Emoji}", "\u{23E9}", Some((0, 3))); +mat!(uni_class_prop_emoji2, r"\p{emoji}", "\u{1F21A}", Some((0, 4))); +mat!( + uni_class_prop_picto1, + r"\p{extendedpictographic}", + "\u{1FA6E}", + Some((0, 4)) +); +mat!( + uni_class_prop_picto2, + r"\p{extendedpictographic}", + "\u{1FFFD}", + Some((0, 4)) +); + +// grapheme_cluster_break +mat!( + uni_class_gcb_prepend, + r"\p{grapheme_cluster_break=prepend}", + "\u{11D46}", + Some((0, 4)) +); +mat!( + uni_class_gcb_ri1, + r"\p{gcb=regional_indicator}", + "\u{1F1E6}", + Some((0, 4)) +); +mat!(uni_class_gcb_ri2, r"\p{gcb=ri}", "\u{1F1E7}", Some((0, 4))); +mat!( + uni_class_gcb_ri3, + r"\p{gcb=regionalindicator}", + "\u{1F1FF}", + Some((0, 4)) +); +mat!(uni_class_gcb_lvt, r"\p{gcb=lvt}", "\u{C989}", Some((0, 3))); +mat!(uni_class_gcb_zwj, r"\p{gcb=zwj}", "\u{200D}", Some((0, 3))); + +// word_break +mat!(uni_class_wb1, r"\p{word_break=Hebrew_Letter}", "\u{FB46}", Some((0, 3))); +mat!(uni_class_wb2, r"\p{wb=hebrewletter}", "\u{FB46}", Some((0, 3))); +mat!(uni_class_wb3, r"\p{wb=ExtendNumLet}", "\u{FF3F}", Some((0, 3))); +mat!(uni_class_wb4, r"\p{wb=WSegSpace}", "\u{3000}", Some((0, 3))); +mat!(uni_class_wb5, r"\p{wb=numeric}", "\u{1E950}", Some((0, 4))); + +// sentence_break +mat!(uni_class_sb1, r"\p{sentence_break=Lower}", "\u{0469}", Some((0, 2))); +mat!(uni_class_sb2, r"\p{sb=lower}", "\u{0469}", Some((0, 2))); +mat!(uni_class_sb3, r"\p{sb=Close}", "\u{FF60}", Some((0, 3))); +mat!(uni_class_sb4, r"\p{sb=Close}", "\u{1F677}", Some((0, 4))); +mat!(uni_class_sb5, r"\p{sb=SContinue}", "\u{FF64}", Some((0, 3))); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/word_boundary.rs b/third_party/cargo/vendor/regex-1.3.3/tests/word_boundary.rs new file mode 100644 index 0000000..7fe97a2 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/word_boundary.rs @@ -0,0 +1,89 @@ +// Many of these are cribbed from RE2's test suite. + +matiter!(wb1, r"\b", ""); +matiter!(wb2, r"\b", "a", (0, 0), (1, 1)); +matiter!(wb3, r"\b", "ab", (0, 0), (2, 2)); +matiter!(wb4, r"^\b", "ab", (0, 0)); +matiter!(wb5, r"\b$", "ab", (2, 2)); +matiter!(wb6, r"^\b$", "ab"); +matiter!(wb7, r"\bbar\b", "nobar bar foo bar", (6, 9), (14, 17)); +matiter!(wb8, r"a\b", "faoa x", (3, 4)); +matiter!(wb9, r"\bbar", "bar x", (0, 3)); +matiter!(wb10, r"\bbar", "foo\nbar x", (4, 7)); +matiter!(wb11, r"bar\b", "foobar", (3, 6)); +matiter!(wb12, r"bar\b", "foobar\nxxx", (3, 6)); +matiter!(wb13, r"(foo|bar|[A-Z])\b", "foo", (0, 3)); +matiter!(wb14, r"(foo|bar|[A-Z])\b", "foo\n", (0, 3)); +matiter!(wb15, r"\b(foo|bar|[A-Z])", "foo", (0, 3)); +matiter!(wb16, r"\b(foo|bar|[A-Z])\b", "X", (0, 1)); +matiter!(wb17, r"\b(foo|bar|[A-Z])\b", "XY"); +matiter!(wb18, r"\b(foo|bar|[A-Z])\b", "bar", (0, 3)); +matiter!(wb19, r"\b(foo|bar|[A-Z])\b", "foo", (0, 3)); +matiter!(wb20, r"\b(foo|bar|[A-Z])\b", "foo\n", (0, 3)); +matiter!(wb21, r"\b(foo|bar|[A-Z])\b", "ffoo bbar N x", (10, 11)); +matiter!(wb22, r"\b(fo|foo)\b", "fo", (0, 2)); +matiter!(wb23, r"\b(fo|foo)\b", "foo", (0, 3)); +matiter!(wb24, r"\b\b", ""); +matiter!(wb25, r"\b\b", "a", (0, 0), (1, 1)); +matiter!(wb26, r"\b$", ""); +matiter!(wb27, r"\b$", "x", (1, 1)); +matiter!(wb28, r"\b$", "y x", (3, 3)); +matiter!(wb29, r"\b.$", "x", (0, 1)); +matiter!(wb30, r"^\b(fo|foo)\b", "fo", (0, 2)); +matiter!(wb31, r"^\b(fo|foo)\b", "foo", (0, 3)); +matiter!(wb32, r"^\b$", ""); +matiter!(wb33, r"^\b$", "x"); +matiter!(wb34, r"^\b.$", "x", (0, 1)); +matiter!(wb35, r"^\b.\b$", "x", (0, 1)); +matiter!(wb36, r"^^^^^\b$$$$$", ""); +matiter!(wb37, r"^^^^^\b.$$$$$", "x", (0, 1)); +matiter!(wb38, r"^^^^^\b$$$$$", "x"); +matiter!(wb39, r"^^^^^\b\b\b.\b\b\b$$$$$", "x", (0, 1)); +matiter!(wb40, r"\b.+\b", "$$abc$$", (2, 5)); +matiter!(wb41, r"\b", "a b c", (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)); + +matiter!(nb1, r"\Bfoo\B", "n foo xfoox that", (7, 10)); +matiter!(nb2, r"a\B", "faoa x", (1, 2)); +matiter!(nb3, r"\Bbar", "bar x"); +matiter!(nb4, r"\Bbar", "foo\nbar x"); +matiter!(nb5, r"bar\B", "foobar"); +matiter!(nb6, r"bar\B", "foobar\nxxx"); +matiter!(nb7, r"(foo|bar|[A-Z])\B", "foox", (0, 3)); +matiter!(nb8, r"(foo|bar|[A-Z])\B", "foo\n"); +matiter!(nb9, r"\B", "", (0, 0)); +matiter!(nb10, r"\B", "x"); +matiter!(nb11, r"\B(foo|bar|[A-Z])", "foo"); +matiter!(nb12, r"\B(foo|bar|[A-Z])\B", "xXy", (1, 2)); +matiter!(nb13, r"\B(foo|bar|[A-Z])\B", "XY"); +matiter!(nb14, r"\B(foo|bar|[A-Z])\B", "XYZ", (1, 2)); +matiter!(nb15, r"\B(foo|bar|[A-Z])\B", "abara", (1, 4)); +matiter!(nb16, r"\B(foo|bar|[A-Z])\B", "xfoo_", (1, 4)); +matiter!(nb17, r"\B(foo|bar|[A-Z])\B", "xfoo\n"); +matiter!(nb18, r"\B(foo|bar|[A-Z])\B", "foo bar vNX", (9, 10)); +matiter!(nb19, r"\B(fo|foo)\B", "xfoo", (1, 3)); +matiter!(nb20, r"\B(foo|fo)\B", "xfooo", (1, 4)); +matiter!(nb21, r"\B\B", "", (0, 0)); +matiter!(nb22, r"\B\B", "x"); +matiter!(nb23, r"\B$", "", (0, 0)); +matiter!(nb24, r"\B$", "x"); +matiter!(nb25, r"\B$", "y x"); +matiter!(nb26, r"\B.$", "x"); +matiter!(nb27, r"^\B(fo|foo)\B", "fo"); +matiter!(nb28, r"^\B(fo|foo)\B", "foo"); +matiter!(nb29, r"^\B", "", (0, 0)); +matiter!(nb30, r"^\B", "x"); +matiter!(nb31, r"^\B\B", "", (0, 0)); +matiter!(nb32, r"^\B\B", "x"); +matiter!(nb33, r"^\B$", "", (0, 0)); +matiter!(nb34, r"^\B$", "x"); +matiter!(nb35, r"^\B.$", "x"); +matiter!(nb36, r"^\B.\B$", "x"); +matiter!(nb37, r"^^^^^\B$$$$$", "", (0, 0)); +matiter!(nb38, r"^^^^^\B.$$$$$", "x"); +matiter!(nb39, r"^^^^^\B$$$$$", "x"); + +// These work for both Unicode and ASCII because all matches are reported as +// byte offsets, and « and » do not correspond to word boundaries at either +// the character or byte level. +matiter!(unicode1, r"\bx\b", "«x", (2, 3)); +matiter!(unicode2, r"\bx\b", "x»", (0, 1)); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/word_boundary_ascii.rs b/third_party/cargo/vendor/regex-1.3.3/tests/word_boundary_ascii.rs new file mode 100644 index 0000000..5a3cf11 --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/word_boundary_ascii.rs @@ -0,0 +1,9 @@ +// ASCII word boundaries are completely oblivious to Unicode characters. +// For Unicode word boundaries, the tests are precisely inverted. +matiter!(ascii1, r"(?-u:\b)x(?-u:\b)", "áxβ", (2, 3)); +matiter!(ascii2, r"(?-u:\B)x(?-u:\B)", "áxβ"); +matiter!(ascii3, r"(?-u:\B)", "0\u{7EF5E}", (2, 2), (3, 3), (4, 4), (5, 5)); + +// We still get Unicode word boundaries by default in byte regexes. +matiter!(unicode1, r"\bx\b", "áxβ"); +matiter!(unicode2, r"\Bx\B", "áxβ", (2, 3)); diff --git a/third_party/cargo/vendor/regex-1.3.3/tests/word_boundary_unicode.rs b/third_party/cargo/vendor/regex-1.3.3/tests/word_boundary_unicode.rs new file mode 100644 index 0000000..c41355f --- /dev/null +++ b/third_party/cargo/vendor/regex-1.3.3/tests/word_boundary_unicode.rs @@ -0,0 +1,6 @@ +// Unicode word boundaries know about Unicode characters. +// For ASCII word boundaries, the tests are precisely inverted. +matiter!(unicode1, r"\bx\b", "áxβ"); +matiter!(unicode2, r"\Bx\B", "áxβ", (2, 3)); + +matiter!(ascii1, r"(?-u:\b)x(?-u:\b)", "áxβ", (2, 3)); diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/.cargo-checksum.json b/third_party/cargo/vendor/regex-syntax-0.6.13/.cargo-checksum.json new file mode 100644 index 0000000..1dfd7f0 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"260c7075765456f51f028ab975f4d0746ad0e5d29fc26f66c3ca329d3f12aa1f","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"7e9a134c72b09540e6f81f02133c5ae7d35067ea6fec44a94a1ebd20af47b151","benches/bench.rs":"f04160a876ee69bc9938bf51227513d6dbf3608643bc8ae422200f7ffc5ca85f","src/ast/mod.rs":"ff7e81186be4f7dea848363622bcd13cd8bf5b0826ea0fd7784a46547d9cf7c0","src/ast/parse.rs":"e1c4bea2fdc4b8eed84b8c3778a37b1d507f92e5a1cabc23b97796416e55ac0f","src/ast/print.rs":"b075392a6d5b48713e09aa510199bb7380aca2cf09fa4bc0efb5c49782630dda","src/ast/visitor.rs":"fb1489ed5ce019091dde244acd8b027e391be442aef3a9033c785c81a4c251fb","src/either.rs":"1758e3edd056884eccadd995708d1e374ba9aa65846bd0e13b1aae852607c560","src/error.rs":"dd937a59d5caed6ca430b884ca4d26116a57ba4c74e4f11797b255d1ac6ace51","src/hir/interval.rs":"fcd0babe3bddbe411e04adff7f4d8855db1d6aaa7d8e2180bba819abad576736","src/hir/literal/mod.rs":"b0a01a3d7e524277ada88d5b58efcced498a53addfac69355fcc368c4c4dfb0f","src/hir/mod.rs":"5c30d2bda19e464c48bc732dcd7e539e32f5af3c7101e7e12fa126222d5b9fe6","src/hir/print.rs":"1bd12a70e5876d85eb2188d83c4b71c9533dc6fff0c1ab5c2b0e4701de7e7a90","src/hir/translate.rs":"bdc82b7aa6e71b9a12092e5e136f4cb2f4965c13183001e7994724bf39eafa8f","src/hir/visitor.rs":"203dbe93e4a8cde395c6ff5a0eb98c9c3737bc5ea11fe7163f5e7bf1babc1f69","src/lib.rs":"db6fd6a65ea30a5b3b1b45c68c17f521302d3408bfe4cec77115913dd25ae072","src/parser.rs":"10cc145d79c275c7e19b8cc9078754f23fc1da9a2c3a2e56041a8616d5f85dea","src/unicode.rs":"a3e354b4d0a496a72c6f4143dc258cc26b3b65d1c90f4bc28981941dc10c7661","src/unicode_tables/LICENSE-UNICODE":"74db5baf44a41b1000312c673544b3374e4198af5605c7f9080a402cec42cfa3","src/unicode_tables/age.rs":"752194f2cb98c483cd98affcbface39431b8039645cc59e8f584a8dde34b34ff","src/unicode_tables/case_folding_simple.rs":"5f4fa71e8abdd01a711247b2c00b46cb4b12e0139b1abcee4be557d127e705fb","src/unicode_tables/general_category.rs":"59423c66260e21c505a901507d6bdd4288f1a1d76362bfae7d7478b943894fe5","src/unicode_tables/grapheme_cluster_break.rs":"d40127918f6015c46b6060c387a5fc2ee083f8d4c2e5ece5bff57ea1d6d031ef","src/unicode_tables/mod.rs":"26c837099cd934c8062e24bc9a0aaecf15fe1de03f9c6da3f3e1e5ac3ca24bee","src/unicode_tables/perl_decimal.rs":"f3ea734f43b123996f8a2c66d54c2b70ded9d333e2e8338bf895ef0f9ec7578e","src/unicode_tables/perl_space.rs":"3304ab6555e950198f9b1714c9a293c7ad80659c2389edb6b56df174a7d317e5","src/unicode_tables/perl_word.rs":"9b493901ebd3d80ed7b26389e9f2a244108ab7eb8a219418e19d5dc040ff52b1","src/unicode_tables/property_bool.rs":"a0f53920fbc491649eeed514f6877b97f2c23b110242483872fe538c8511046a","src/unicode_tables/property_names.rs":"849ff2209af572ef3edeb8a84653098bd38c2497a06758a92ef798b7ffbfb4c8","src/unicode_tables/property_values.rs":"2af9239fbb3ec2458b17a7ed16f3a27a11ae574ee6c9366d3b6768e0560ba134","src/unicode_tables/script.rs":"be1566695ad253d29b2405b8620a78d6af6670912452441dfb0f018fc0a74d24","src/unicode_tables/script_extension.rs":"193d3ae1a19c140de2f72b1b42f146deab2e157b89978a35797c431fbf84db3c","src/unicode_tables/sentence_break.rs":"314401cbbb1afb77b1b2ebcc0e44cb0e4cb7571469d288336d43812c4eeb3d90","src/unicode_tables/word_break.rs":"d03974a4b557670c9d0ac7a3e46175f036bcd258cd188e94af5798dea48cf082","src/utf8.rs":"68353f4303364d058426311893c786ea4b89076978abd11448e5bb4b8cc04a29","test":"9d0bc68616c249f317e783e5083102d2645a6ade3de735e8d8a414e97eaa76d0"},"package":"e734e891f5b408a29efbf8309e656876276f49ab6a6ac208600b4419bd893d90"} \ No newline at end of file diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/BUILD b/third_party/cargo/vendor/regex-syntax-0.6.13/BUILD new file mode 100644 index 0000000..283d242 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/BUILD @@ -0,0 +1,50 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "bench" with type "bench" omitted + +rust_library( + name = "regex_syntax", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.13", + crate_features = [ + "unicode-age", + "unicode-bool", + "unicode-case", + "unicode-gencat", + "unicode-perl", + "unicode-script", + "unicode-segment", + ], +) + diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/Cargo.toml b/third_party/cargo/vendor/regex-syntax-0.6.13/Cargo.toml new file mode 100644 index 0000000..5d5b574 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/Cargo.toml @@ -0,0 +1,32 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "regex-syntax" +version = "0.6.13" +authors = ["The Rust Project Developers"] +description = "A regular expression parser." +homepage = "https://github.com/rust-lang/regex" +documentation = "https://docs.rs/regex-syntax" +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-lang/regex" + +[features] +default = ["unicode"] +unicode = ["unicode-age", "unicode-bool", "unicode-case", "unicode-gencat", "unicode-perl", "unicode-script", "unicode-segment"] +unicode-age = [] +unicode-bool = [] +unicode-case = [] +unicode-gencat = [] +unicode-perl = [] +unicode-script = [] +unicode-segment = [] diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/LICENSE-APACHE b/third_party/cargo/vendor/regex-syntax-0.6.13/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/LICENSE-MIT b/third_party/cargo/vendor/regex-syntax-0.6.13/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/README.md b/third_party/cargo/vendor/regex-syntax-0.6.13/README.md new file mode 100644 index 0000000..e904601 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/README.md @@ -0,0 +1,99 @@ +regex-syntax +============ +This crate provides a robust regular expression parser. + +[![Build status](https://travis-ci.com/rust-lang/regex.svg?branch=master)](https://travis-ci.com/rust-lang/regex) +[![Build status](https://ci.appveyor.com/api/projects/status/github/rust-lang/regex?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/regex) +[![](https://meritbadge.herokuapp.com/regex-syntax)](https://crates.io/crates/regex-syntax) +[![Rust](https://img.shields.io/badge/rust-1.28.0%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/regex) + + +### Documentation + +https://docs.rs/regex-syntax + + +### Overview + +There are two primary types exported by this crate: `Ast` and `Hir`. The former +is a faithful abstract syntax of a regular expression, and can convert regular +expressions back to their concrete syntax while mostly preserving its original +form. The latter type is a high level intermediate representation of a regular +expression that is amenable to analysis and compilation into byte codes or +automata. An `Hir` achieves this by drastically simplifying the syntactic +structure of the regular expression. While an `Hir` can be converted back to +its equivalent concrete syntax, the result is unlikely to resemble the original +concrete syntax that produced the `Hir`. + + +### Example + +This example shows how to parse a pattern string into its HIR: + +```rust +use regex_syntax::Parser; +use regex_syntax::hir::{self, Hir}; + +let hir = Parser::new().parse("a|b").unwrap(); +assert_eq!(hir, Hir::alternation(vec![ + Hir::literal(hir::Literal::Unicode('a')), + Hir::literal(hir::Literal::Unicode('b')), +])); +``` + + +### Safety + +This crate has no `unsafe` code and sets `forbid(unsafe_code)`. While it's +possible this crate could use `unsafe` code in the future, the standard +for doing so is extremely high. In general, most code in this crate is not +performance critical, since it tends to be dwarfed by the time it takes to +compile a regular expression into an automaton. Therefore, there is little need +for extreme optimization, and therefore, use of `unsafe`. + +The standard for using `unsafe` in this crate is extremely high because this +crate is intended to be reasonably safe to use with user supplied regular +expressions. Therefore, while their may be bugs in the regex parser itself, +they should _never_ result in memory unsafety unless there is either a bug +in the compiler or the standard library. (Since `regex-syntax` has zero +dependencies.) + + +### Crate features + +By default, this crate bundles a fairly large amount of Unicode data tables +(a source size of ~750KB). Because of their large size, one can disable some +or all of these data tables. If a regular expression attempts to use Unicode +data that is not available, then an error will occur when translating the `Ast` +to the `Hir`. + +The full set of features one can disable are +[in the "Crate features" section of the documentation](https://docs.rs/regex-syntax/*/#crate-features). + + +### Testing + +Simply running `cargo test` will give you very good coverage. However, because +of the large number of features exposed by this crate, a `test` script is +included in this directory which will test several feature combinations. This +is the same script that is run in CI. + + +### Motivation + +The primary purpose of this crate is to provide the parser used by `regex`. +Specifically, this crate is treated as an implementation detail of the `regex`, +and is primarily developed for the needs of `regex`. + +Since this crate is an implementation detail of `regex`, it may experience +breaking change releases at a different cadence from `regex`. This is only +possible because this crate is _not_ a public dependency of `regex`. + +Another consequence of this de-coupling is that there is no direct way to +compile a `regex::Regex` from a `regex_syntax::hir::Hir`. Instead, one must +first convert the `Hir` to a string (via its `std::fmt::Display`) and then +compile that via `Regex::new`. While this does repeat some work, compilation +typically takes much longer than parsing. + +Stated differently, the coupling between `regex` and `regex-syntax` exists only +at the level of the concrete syntax. diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/benches/bench.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/benches/bench.rs new file mode 100644 index 0000000..ba7f81c --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/benches/bench.rs @@ -0,0 +1,64 @@ +#![feature(test)] + +extern crate regex_syntax; +extern crate test; + +use regex_syntax::Parser; +use test::Bencher; + +#[bench] +fn parse_simple1(b: &mut Bencher) { + b.iter(|| { + let re = r"^bc(d|e)*$"; + Parser::new().parse(re).unwrap() + }); +} + +#[bench] +fn parse_simple2(b: &mut Bencher) { + b.iter(|| { + let re = r"'[a-zA-Z_][a-zA-Z0-9_]*(')\b"; + Parser::new().parse(re).unwrap() + }); +} + +#[bench] +fn parse_small1(b: &mut Bencher) { + b.iter(|| { + let re = r"\p{L}|\p{N}|\s|.|\d"; + Parser::new().parse(re).unwrap() + }); +} + +#[bench] +fn parse_medium1(b: &mut Bencher) { + b.iter(|| { + let re = r"\pL\p{Greek}\p{Hiragana}\p{Alphabetic}\p{Hebrew}\p{Arabic}"; + Parser::new().parse(re).unwrap() + }); +} + +#[bench] +fn parse_medium2(b: &mut Bencher) { + b.iter(|| { + let re = r"\s\S\w\W\d\D"; + Parser::new().parse(re).unwrap() + }); +} + +#[bench] +fn parse_medium3(b: &mut Bencher) { + b.iter(|| { + let re = + r"\p{age:3.2}\p{hira}\p{scx:hira}\p{alphabetic}\p{sc:Greek}\pL"; + Parser::new().parse(re).unwrap() + }); +} + +#[bench] +fn parse_huge(b: &mut Bencher) { + b.iter(|| { + let re = r"\p{L}{100}"; + Parser::new().parse(re).unwrap() + }); +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/mod.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/mod.rs new file mode 100644 index 0000000..7179f2d --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/mod.rs @@ -0,0 +1,1502 @@ +/*! +Defines an abstract syntax for regular expressions. +*/ + +use std::cmp::Ordering; +use std::error; +use std::fmt; + +pub use ast::visitor::{visit, Visitor}; + +pub mod parse; +pub mod print; +mod visitor; + +/// An error that occurred while parsing a regular expression into an abstract +/// syntax tree. +/// +/// Note that note all ASTs represents a valid regular expression. For example, +/// an AST is constructed without error for `\p{Quux}`, but `Quux` is not a +/// valid Unicode property name. That particular error is reported when +/// translating an AST to the high-level intermediate representation (`HIR`). +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Error { + /// The kind of error. + kind: ErrorKind, + /// The original pattern that the parser generated the error from. Every + /// span in an error is a valid range into this string. + pattern: String, + /// The span of this error. + span: Span, +} + +impl Error { + /// Return the type of this error. + pub fn kind(&self) -> &ErrorKind { + &self.kind + } + + /// The original pattern string in which this error occurred. + /// + /// Every span reported by this error is reported in terms of this string. + pub fn pattern(&self) -> &str { + &self.pattern + } + + /// Return the span at which this error occurred. + pub fn span(&self) -> &Span { + &self.span + } + + /// Return an auxiliary span. This span exists only for some errors that + /// benefit from being able to point to two locations in the original + /// regular expression. For example, "duplicate" errors will have the + /// main error position set to the duplicate occurrence while its + /// auxiliary span will be set to the initial occurrence. + pub fn auxiliary_span(&self) -> Option<&Span> { + use self::ErrorKind::*; + match self.kind { + FlagDuplicate { ref original } => Some(original), + FlagRepeatedNegation { ref original, .. } => Some(original), + GroupNameDuplicate { ref original, .. } => Some(original), + _ => None, + } + } +} + +/// The type of an error that occurred while building an AST. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ErrorKind { + /// The capturing group limit was exceeded. + /// + /// Note that this represents a limit on the total number of capturing + /// groups in a regex and not necessarily the number of nested capturing + /// groups. That is, the nest limit can be low and it is still possible for + /// this error to occur. + CaptureLimitExceeded, + /// An invalid escape sequence was found in a character class set. + ClassEscapeInvalid, + /// An invalid character class range was found. An invalid range is any + /// range where the start is greater than the end. + ClassRangeInvalid, + /// An invalid range boundary was found in a character class. Range + /// boundaries must be a single literal codepoint, but this error indicates + /// that something else was found, such as a nested class. + ClassRangeLiteral, + /// An opening `[` was found with no corresponding closing `]`. + ClassUnclosed, + /// Note that this error variant is no longer used. Namely, a decimal + /// number can only appear as a repetition quantifier. When the number + /// in a repetition quantifier is empty, then it gets its own specialized + /// error, `RepetitionCountDecimalEmpty`. + DecimalEmpty, + /// An invalid decimal number was given where one was expected. + DecimalInvalid, + /// A bracketed hex literal was empty. + EscapeHexEmpty, + /// A bracketed hex literal did not correspond to a Unicode scalar value. + EscapeHexInvalid, + /// An invalid hexadecimal digit was found. + EscapeHexInvalidDigit, + /// EOF was found before an escape sequence was completed. + EscapeUnexpectedEof, + /// An unrecognized escape sequence. + EscapeUnrecognized, + /// A dangling negation was used when setting flags, e.g., `i-`. + FlagDanglingNegation, + /// A flag was used twice, e.g., `i-i`. + FlagDuplicate { + /// The position of the original flag. The error position + /// points to the duplicate flag. + original: Span, + }, + /// The negation operator was used twice, e.g., `-i-s`. + FlagRepeatedNegation { + /// The position of the original negation operator. The error position + /// points to the duplicate negation operator. + original: Span, + }, + /// Expected a flag but got EOF, e.g., `(?`. + FlagUnexpectedEof, + /// Unrecognized flag, e.g., `a`. + FlagUnrecognized, + /// A duplicate capture name was found. + GroupNameDuplicate { + /// The position of the initial occurrence of the capture name. The + /// error position itself points to the duplicate occurrence. + original: Span, + }, + /// A capture group name is empty, e.g., `(?P<>abc)`. + GroupNameEmpty, + /// An invalid character was seen for a capture group name. This includes + /// errors where the first character is a digit (even though subsequent + /// characters are allowed to be digits). + GroupNameInvalid, + /// A closing `>` could not be found for a capture group name. + GroupNameUnexpectedEof, + /// An unclosed group, e.g., `(ab`. + /// + /// The span of this error corresponds to the unclosed parenthesis. + GroupUnclosed, + /// An unopened group, e.g., `ab)`. + GroupUnopened, + /// The nest limit was exceeded. The limit stored here is the limit + /// configured in the parser. + NestLimitExceeded(u32), + /// The range provided in a counted repetition operator is invalid. The + /// range is invalid if the start is greater than the end. + RepetitionCountInvalid, + /// An opening `{` was not followed by a valid decimal value. + /// For example, `x{}` or `x{]}` would fail. + RepetitionCountDecimalEmpty, + /// An opening `{` was found with no corresponding closing `}`. + RepetitionCountUnclosed, + /// A repetition operator was applied to a missing sub-expression. This + /// occurs, for example, in the regex consisting of just a `*` or even + /// `(?i)*`. It is, however, possible to create a repetition operating on + /// an empty sub-expression. For example, `()*` is still considered valid. + RepetitionMissing, + /// The Unicode class is not valid. This typically occurs when a `\p` is + /// followed by something other than a `{`. + UnicodeClassInvalid, + /// When octal support is disabled, this error is produced when an octal + /// escape is used. The octal escape is assumed to be an invocation of + /// a backreference, which is the common case. + UnsupportedBackreference, + /// When syntax similar to PCRE's look-around is used, this error is + /// returned. Some example syntaxes that are rejected include, but are + /// not necessarily limited to, `(?=re)`, `(?!re)`, `(?<=re)` and + /// `(?<!re)`. Note that all of these syntaxes are otherwise invalid; this + /// error is used to improve the user experience. + UnsupportedLookAround, + /// Hints that destructuring should not be exhaustive. + /// + /// This enum may grow additional variants, so this makes sure clients + /// don't count on exhaustive matching. (Otherwise, adding a new variant + /// could break existing code.) + #[doc(hidden)] + __Nonexhaustive, +} + +impl error::Error for Error { + // TODO: Remove this method entirely on the next breaking semver release. + #[allow(deprecated)] + fn description(&self) -> &str { + use self::ErrorKind::*; + match self.kind { + CaptureLimitExceeded => "capture group limit exceeded", + ClassEscapeInvalid => "invalid escape sequence in character class", + ClassRangeInvalid => "invalid character class range", + ClassRangeLiteral => "invalid range boundary, must be a literal", + ClassUnclosed => "unclosed character class", + DecimalEmpty => "empty decimal literal", + DecimalInvalid => "invalid decimal literal", + EscapeHexEmpty => "empty hexadecimal literal", + EscapeHexInvalid => "invalid hexadecimal literal", + EscapeHexInvalidDigit => "invalid hexadecimal digit", + EscapeUnexpectedEof => "unexpected eof (escape sequence)", + EscapeUnrecognized => "unrecognized escape sequence", + FlagDanglingNegation => "dangling flag negation operator", + FlagDuplicate { .. } => "duplicate flag", + FlagRepeatedNegation { .. } => "repeated negation", + FlagUnexpectedEof => "unexpected eof (flag)", + FlagUnrecognized => "unrecognized flag", + GroupNameDuplicate { .. } => "duplicate capture group name", + GroupNameEmpty => "empty capture group name", + GroupNameInvalid => "invalid capture group name", + GroupNameUnexpectedEof => "unclosed capture group name", + GroupUnclosed => "unclosed group", + GroupUnopened => "unopened group", + NestLimitExceeded(_) => "nest limit exceeded", + RepetitionCountInvalid => "invalid repetition count range", + RepetitionCountUnclosed => "unclosed counted repetition", + RepetitionMissing => "repetition operator missing expression", + UnicodeClassInvalid => "invalid Unicode character class", + UnsupportedBackreference => "backreferences are not supported", + UnsupportedLookAround => "look-around is not supported", + _ => unreachable!(), + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + ::error::Formatter::from(self).fmt(f) + } +} + +impl fmt::Display for ErrorKind { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use self::ErrorKind::*; + match *self { + CaptureLimitExceeded => write!( + f, + "exceeded the maximum number of \ + capturing groups ({})", + ::std::u32::MAX + ), + ClassEscapeInvalid => { + write!(f, "invalid escape sequence found in character class") + } + ClassRangeInvalid => write!( + f, + "invalid character class range, \ + the start must be <= the end" + ), + ClassRangeLiteral => { + write!(f, "invalid range boundary, must be a literal") + } + ClassUnclosed => write!(f, "unclosed character class"), + DecimalEmpty => write!(f, "decimal literal empty"), + DecimalInvalid => write!(f, "decimal literal invalid"), + EscapeHexEmpty => write!(f, "hexadecimal literal empty"), + EscapeHexInvalid => { + write!(f, "hexadecimal literal is not a Unicode scalar value") + } + EscapeHexInvalidDigit => write!(f, "invalid hexadecimal digit"), + EscapeUnexpectedEof => write!( + f, + "incomplete escape sequence, \ + reached end of pattern prematurely" + ), + EscapeUnrecognized => write!(f, "unrecognized escape sequence"), + FlagDanglingNegation => { + write!(f, "dangling flag negation operator") + } + FlagDuplicate { .. } => write!(f, "duplicate flag"), + FlagRepeatedNegation { .. } => { + write!(f, "flag negation operator repeated") + } + FlagUnexpectedEof => { + write!(f, "expected flag but got end of regex") + } + FlagUnrecognized => write!(f, "unrecognized flag"), + GroupNameDuplicate { .. } => { + write!(f, "duplicate capture group name") + } + GroupNameEmpty => write!(f, "empty capture group name"), + GroupNameInvalid => write!(f, "invalid capture group character"), + GroupNameUnexpectedEof => write!(f, "unclosed capture group name"), + GroupUnclosed => write!(f, "unclosed group"), + GroupUnopened => write!(f, "unopened group"), + NestLimitExceeded(limit) => write!( + f, + "exceed the maximum number of \ + nested parentheses/brackets ({})", + limit + ), + RepetitionCountInvalid => write!( + f, + "invalid repetition count range, \ + the start must be <= the end" + ), + RepetitionCountDecimalEmpty => { + write!(f, "repetition quantifier expects a valid decimal") + } + RepetitionCountUnclosed => { + write!(f, "unclosed counted repetition") + } + RepetitionMissing => { + write!(f, "repetition operator missing expression") + } + UnicodeClassInvalid => { + write!(f, "invalid Unicode character class") + } + UnsupportedBackreference => { + write!(f, "backreferences are not supported") + } + UnsupportedLookAround => write!( + f, + "look-around, including look-ahead and look-behind, \ + is not supported" + ), + _ => unreachable!(), + } + } +} + +/// Span represents the position information of a single AST item. +/// +/// All span positions are absolute byte offsets that can be used on the +/// original regular expression that was parsed. +#[derive(Clone, Copy, Eq, PartialEq)] +pub struct Span { + /// The start byte offset. + pub start: Position, + /// The end byte offset. + pub end: Position, +} + +impl fmt::Debug for Span { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Span({:?}, {:?})", self.start, self.end) + } +} + +impl Ord for Span { + fn cmp(&self, other: &Span) -> Ordering { + (&self.start, &self.end).cmp(&(&other.start, &other.end)) + } +} + +impl PartialOrd for Span { + fn partial_cmp(&self, other: &Span) -> Option<Ordering> { + Some(self.cmp(other)) + } +} + +/// A single position in a regular expression. +/// +/// A position encodes one half of a span, and include the byte offset, line +/// number and column number. +#[derive(Clone, Copy, Eq, PartialEq)] +pub struct Position { + /// The absolute offset of this position, starting at `0` from the + /// beginning of the regular expression pattern string. + pub offset: usize, + /// The line number, starting at `1`. + pub line: usize, + /// The approximate column number, starting at `1`. + pub column: usize, +} + +impl fmt::Debug for Position { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "Position(o: {:?}, l: {:?}, c: {:?})", + self.offset, self.line, self.column + ) + } +} + +impl Ord for Position { + fn cmp(&self, other: &Position) -> Ordering { + self.offset.cmp(&other.offset) + } +} + +impl PartialOrd for Position { + fn partial_cmp(&self, other: &Position) -> Option<Ordering> { + Some(self.cmp(other)) + } +} + +impl Span { + /// Create a new span with the given positions. + pub fn new(start: Position, end: Position) -> Span { + Span { start: start, end: end } + } + + /// Create a new span using the given position as the start and end. + pub fn splat(pos: Position) -> Span { + Span::new(pos, pos) + } + + /// Create a new span by replacing the starting the position with the one + /// given. + pub fn with_start(self, pos: Position) -> Span { + Span { start: pos, ..self } + } + + /// Create a new span by replacing the ending the position with the one + /// given. + pub fn with_end(self, pos: Position) -> Span { + Span { end: pos, ..self } + } + + /// Returns true if and only if this span occurs on a single line. + pub fn is_one_line(&self) -> bool { + self.start.line == self.end.line + } + + /// Returns true if and only if this span is empty. That is, it points to + /// a single position in the concrete syntax of a regular expression. + pub fn is_empty(&self) -> bool { + self.start.offset == self.end.offset + } +} + +impl Position { + /// Create a new position with the given information. + /// + /// `offset` is the absolute offset of the position, starting at `0` from + /// the beginning of the regular expression pattern string. + /// + /// `line` is the line number, starting at `1`. + /// + /// `column` is the approximate column number, starting at `1`. + pub fn new(offset: usize, line: usize, column: usize) -> Position { + Position { offset: offset, line: line, column: column } + } +} + +/// An abstract syntax tree for a singular expression along with comments +/// found. +/// +/// Comments are not stored in the tree itself to avoid complexity. Each +/// comment contains a span of precisely where it occurred in the original +/// regular expression. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct WithComments { + /// The actual ast. + pub ast: Ast, + /// All comments found in the original regular expression. + pub comments: Vec<Comment>, +} + +/// A comment from a regular expression with an associated span. +/// +/// A regular expression can only contain comments when the `x` flag is +/// enabled. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Comment { + /// The span of this comment, including the beginning `#` and ending `\n`. + pub span: Span, + /// The comment text, starting with the first character following the `#` + /// and ending with the last character preceding the `\n`. + pub comment: String, +} + +/// An abstract syntax tree for a single regular expression. +/// +/// An `Ast`'s `fmt::Display` implementation uses constant stack space and heap +/// space proportional to the size of the `Ast`. +/// +/// This type defines its own destructor that uses constant stack space and +/// heap space proportional to the size of the `Ast`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Ast { + /// An empty regex that matches everything. + Empty(Span), + /// A set of flags, e.g., `(?is)`. + Flags(SetFlags), + /// A single character literal, which includes escape sequences. + Literal(Literal), + /// The "any character" class. + Dot(Span), + /// A single zero-width assertion. + Assertion(Assertion), + /// A single character class. This includes all forms of character classes + /// except for `.`. e.g., `\d`, `\pN`, `[a-z]` and `[[:alpha:]]`. + Class(Class), + /// A repetition operator applied to an arbitrary regular expression. + Repetition(Repetition), + /// A grouped regular expression. + Group(Group), + /// An alternation of regular expressions. + Alternation(Alternation), + /// A concatenation of regular expressions. + Concat(Concat), +} + +impl Ast { + /// Return the span of this abstract syntax tree. + pub fn span(&self) -> &Span { + match *self { + Ast::Empty(ref span) => span, + Ast::Flags(ref x) => &x.span, + Ast::Literal(ref x) => &x.span, + Ast::Dot(ref span) => span, + Ast::Assertion(ref x) => &x.span, + Ast::Class(ref x) => x.span(), + Ast::Repetition(ref x) => &x.span, + Ast::Group(ref x) => &x.span, + Ast::Alternation(ref x) => &x.span, + Ast::Concat(ref x) => &x.span, + } + } + + /// Return true if and only if this Ast is empty. + pub fn is_empty(&self) -> bool { + match *self { + Ast::Empty(_) => true, + _ => false, + } + } + + /// Returns true if and only if this AST has any (including possibly empty) + /// subexpressions. + fn has_subexprs(&self) -> bool { + match *self { + Ast::Empty(_) + | Ast::Flags(_) + | Ast::Literal(_) + | Ast::Dot(_) + | Ast::Assertion(_) => false, + Ast::Class(_) + | Ast::Repetition(_) + | Ast::Group(_) + | Ast::Alternation(_) + | Ast::Concat(_) => true, + } + } +} + +/// Print a display representation of this Ast. +/// +/// This does not preserve any of the original whitespace formatting that may +/// have originally been present in the concrete syntax from which this Ast +/// was generated. +/// +/// This implementation uses constant stack space and heap space proportional +/// to the size of the `Ast`. +impl fmt::Display for Ast { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use ast::print::Printer; + Printer::new().print(self, f) + } +} + +/// An alternation of regular expressions. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Alternation { + /// The span of this alternation. + pub span: Span, + /// The alternate regular expressions. + pub asts: Vec<Ast>, +} + +impl Alternation { + /// Return this alternation as an AST. + /// + /// If this alternation contains zero ASTs, then Ast::Empty is + /// returned. If this alternation contains exactly 1 AST, then the + /// corresponding AST is returned. Otherwise, Ast::Alternation is returned. + pub fn into_ast(mut self) -> Ast { + match self.asts.len() { + 0 => Ast::Empty(self.span), + 1 => self.asts.pop().unwrap(), + _ => Ast::Alternation(self), + } + } +} + +/// A concatenation of regular expressions. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Concat { + /// The span of this concatenation. + pub span: Span, + /// The concatenation regular expressions. + pub asts: Vec<Ast>, +} + +impl Concat { + /// Return this concatenation as an AST. + /// + /// If this concatenation contains zero ASTs, then Ast::Empty is + /// returned. If this concatenation contains exactly 1 AST, then the + /// corresponding AST is returned. Otherwise, Ast::Concat is returned. + pub fn into_ast(mut self) -> Ast { + match self.asts.len() { + 0 => Ast::Empty(self.span), + 1 => self.asts.pop().unwrap(), + _ => Ast::Concat(self), + } + } +} + +/// A single literal expression. +/// +/// A literal corresponds to a single Unicode scalar value. Literals may be +/// represented in their literal form, e.g., `a` or in their escaped form, +/// e.g., `\x61`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Literal { + /// The span of this literal. + pub span: Span, + /// The kind of this literal. + pub kind: LiteralKind, + /// The Unicode scalar value corresponding to this literal. + pub c: char, +} + +impl Literal { + /// If this literal was written as a `\x` hex escape, then this returns + /// the corresponding byte value. Otherwise, this returns `None`. + pub fn byte(&self) -> Option<u8> { + let short_hex = LiteralKind::HexFixed(HexLiteralKind::X); + if self.c as u32 <= 255 && self.kind == short_hex { + Some(self.c as u8) + } else { + None + } + } +} + +/// The kind of a single literal expression. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum LiteralKind { + /// The literal is written verbatim, e.g., `a` or `☃`. + Verbatim, + /// The literal is written as an escape because it is punctuation, e.g., + /// `\*` or `\[`. + Punctuation, + /// The literal is written as an octal escape, e.g., `\141`. + Octal, + /// The literal is written as a hex code with a fixed number of digits + /// depending on the type of the escape, e.g., `\x61` or or `\u0061` or + /// `\U00000061`. + HexFixed(HexLiteralKind), + /// The literal is written as a hex code with a bracketed number of + /// digits. The only restriction is that the bracketed hex code must refer + /// to a valid Unicode scalar value. + HexBrace(HexLiteralKind), + /// The literal is written as a specially recognized escape, e.g., `\f` + /// or `\n`. + Special(SpecialLiteralKind), +} + +/// The type of a special literal. +/// +/// A special literal is a special escape sequence recognized by the regex +/// parser, e.g., `\f` or `\n`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum SpecialLiteralKind { + /// Bell, spelled `\a` (`\x07`). + Bell, + /// Form feed, spelled `\f` (`\x0C`). + FormFeed, + /// Tab, spelled `\t` (`\x09`). + Tab, + /// Line feed, spelled `\n` (`\x0A`). + LineFeed, + /// Carriage return, spelled `\r` (`\x0D`). + CarriageReturn, + /// Vertical tab, spelled `\v` (`\x0B`). + VerticalTab, + /// Space, spelled `\ ` (`\x20`). Note that this can only appear when + /// parsing in verbose mode. + Space, +} + +/// The type of a Unicode hex literal. +/// +/// Note that all variants behave the same when used with brackets. They only +/// differ when used without brackets in the number of hex digits that must +/// follow. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum HexLiteralKind { + /// A `\x` prefix. When used without brackets, this form is limited to + /// two digits. + X, + /// A `\u` prefix. When used without brackets, this form is limited to + /// four digits. + UnicodeShort, + /// A `\U` prefix. When used without brackets, this form is limited to + /// eight digits. + UnicodeLong, +} + +impl HexLiteralKind { + /// The number of digits that must be used with this literal form when + /// used without brackets. When used with brackets, there is no + /// restriction on the number of digits. + pub fn digits(&self) -> u32 { + match *self { + HexLiteralKind::X => 2, + HexLiteralKind::UnicodeShort => 4, + HexLiteralKind::UnicodeLong => 8, + } + } +} + +/// A single character class expression. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Class { + /// A Unicode character class, e.g., `\pL` or `\p{Greek}`. + Unicode(ClassUnicode), + /// A perl character class, e.g., `\d` or `\W`. + Perl(ClassPerl), + /// A bracketed character class set, which may contain zero or more + /// character ranges and/or zero or more nested classes. e.g., + /// `[a-zA-Z\pL]`. + Bracketed(ClassBracketed), +} + +impl Class { + /// Return the span of this character class. + pub fn span(&self) -> &Span { + match *self { + Class::Perl(ref x) => &x.span, + Class::Unicode(ref x) => &x.span, + Class::Bracketed(ref x) => &x.span, + } + } +} + +/// A Perl character class. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ClassPerl { + /// The span of this class. + pub span: Span, + /// The kind of Perl class. + pub kind: ClassPerlKind, + /// Whether the class is negated or not. e.g., `\d` is not negated but + /// `\D` is. + pub negated: bool, +} + +/// The available Perl character classes. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ClassPerlKind { + /// Decimal numbers. + Digit, + /// Whitespace. + Space, + /// Word characters. + Word, +} + +/// An ASCII character class. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ClassAscii { + /// The span of this class. + pub span: Span, + /// The kind of ASCII class. + pub kind: ClassAsciiKind, + /// Whether the class is negated or not. e.g., `[[:alpha:]]` is not negated + /// but `[[:^alpha:]]` is. + pub negated: bool, +} + +/// The available ASCII character classes. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ClassAsciiKind { + /// `[0-9A-Za-z]` + Alnum, + /// `[A-Za-z]` + Alpha, + /// `[\x00-\x7F]` + Ascii, + /// `[ \t]` + Blank, + /// `[\x00-\x1F\x7F]` + Cntrl, + /// `[0-9]` + Digit, + /// `[!-~]` + Graph, + /// `[a-z]` + Lower, + /// `[ -~]` + Print, + /// `[!-/:-@\[-`{-~]` + Punct, + /// `[\t\n\v\f\r ]` + Space, + /// `[A-Z]` + Upper, + /// `[0-9A-Za-z_]` + Word, + /// `[0-9A-Fa-f]` + Xdigit, +} + +impl ClassAsciiKind { + /// Return the corresponding ClassAsciiKind variant for the given name. + /// + /// The name given should correspond to the lowercase version of the + /// variant name. e.g., `cntrl` is the name for `ClassAsciiKind::Cntrl`. + /// + /// If no variant with the corresponding name exists, then `None` is + /// returned. + pub fn from_name(name: &str) -> Option<ClassAsciiKind> { + use self::ClassAsciiKind::*; + match name { + "alnum" => Some(Alnum), + "alpha" => Some(Alpha), + "ascii" => Some(Ascii), + "blank" => Some(Blank), + "cntrl" => Some(Cntrl), + "digit" => Some(Digit), + "graph" => Some(Graph), + "lower" => Some(Lower), + "print" => Some(Print), + "punct" => Some(Punct), + "space" => Some(Space), + "upper" => Some(Upper), + "word" => Some(Word), + "xdigit" => Some(Xdigit), + _ => None, + } + } +} + +/// A Unicode character class. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ClassUnicode { + /// The span of this class. + pub span: Span, + /// Whether this class is negated or not. + /// + /// Note: be careful when using this attribute. This specifically refers + /// to whether the class is written as `\p` or `\P`, where the latter + /// is `negated = true`. However, it also possible to write something like + /// `\P{scx!=Katakana}` which is actually equivalent to + /// `\p{scx=Katakana}` and is therefore not actually negated even though + /// `negated = true` here. To test whether this class is truly negated + /// or not, use the `is_negated` method. + pub negated: bool, + /// The kind of Unicode class. + pub kind: ClassUnicodeKind, +} + +impl ClassUnicode { + /// Returns true if this class has been negated. + /// + /// Note that this takes the Unicode op into account, if it's present. + /// e.g., `is_negated` for `\P{scx!=Katakana}` will return `false`. + pub fn is_negated(&self) -> bool { + match self.kind { + ClassUnicodeKind::NamedValue { + op: ClassUnicodeOpKind::NotEqual, + .. + } => !self.negated, + _ => self.negated, + } + } +} + +/// The available forms of Unicode character classes. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ClassUnicodeKind { + /// A one letter abbreviated class, e.g., `\pN`. + OneLetter(char), + /// A binary property, general category or script. The string may be + /// empty. + Named(String), + /// A property name and an associated value. + NamedValue { + /// The type of Unicode op used to associate `name` with `value`. + op: ClassUnicodeOpKind, + /// The property name (which may be empty). + name: String, + /// The property value (which may be empty). + value: String, + }, +} + +/// The type of op used in a Unicode character class. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ClassUnicodeOpKind { + /// A property set to a specific value, e.g., `\p{scx=Katakana}`. + Equal, + /// A property set to a specific value using a colon, e.g., + /// `\p{scx:Katakana}`. + Colon, + /// A property that isn't a particular value, e.g., `\p{scx!=Katakana}`. + NotEqual, +} + +impl ClassUnicodeOpKind { + /// Whether the op is an equality op or not. + pub fn is_equal(&self) -> bool { + match *self { + ClassUnicodeOpKind::Equal | ClassUnicodeOpKind::Colon => true, + _ => false, + } + } +} + +/// A bracketed character class, e.g., `[a-z0-9]`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ClassBracketed { + /// The span of this class. + pub span: Span, + /// Whether this class is negated or not. e.g., `[a]` is not negated but + /// `[^a]` is. + pub negated: bool, + /// The type of this set. A set is either a normal union of things, e.g., + /// `[abc]` or a result of applying set operations, e.g., `[\pL--c]`. + pub kind: ClassSet, +} + +/// A character class set. +/// +/// This type corresponds to the internal structure of a bracketed character +/// class. That is, every bracketed character is one of two types: a union of +/// items (literals, ranges, other bracketed classes) or a tree of binary set +/// operations. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ClassSet { + /// An item, which can be a single literal, range, nested character class + /// or a union of items. + Item(ClassSetItem), + /// A single binary operation (i.e., &&, -- or ~~). + BinaryOp(ClassSetBinaryOp), +} + +impl ClassSet { + /// Build a set from a union. + pub fn union(ast: ClassSetUnion) -> ClassSet { + ClassSet::Item(ClassSetItem::Union(ast)) + } + + /// Return the span of this character class set. + pub fn span(&self) -> &Span { + match *self { + ClassSet::Item(ref x) => x.span(), + ClassSet::BinaryOp(ref x) => &x.span, + } + } + + /// Return true if and only if this class set is empty. + fn is_empty(&self) -> bool { + match *self { + ClassSet::Item(ClassSetItem::Empty(_)) => true, + _ => false, + } + } +} + +/// A single component of a character class set. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ClassSetItem { + /// An empty item. + /// + /// Note that a bracketed character class cannot contain a single empty + /// item. Empty items can appear when using one of the binary operators. + /// For example, `[&&]` is the intersection of two empty classes. + Empty(Span), + /// A single literal. + Literal(Literal), + /// A range between two literals. + Range(ClassSetRange), + /// An ASCII character class, e.g., `[:alnum:]` or `[:punct:]`. + Ascii(ClassAscii), + /// A Unicode character class, e.g., `\pL` or `\p{Greek}`. + Unicode(ClassUnicode), + /// A perl character class, e.g., `\d` or `\W`. + Perl(ClassPerl), + /// A bracketed character class set, which may contain zero or more + /// character ranges and/or zero or more nested classes. e.g., + /// `[a-zA-Z\pL]`. + Bracketed(Box<ClassBracketed>), + /// A union of items. + Union(ClassSetUnion), +} + +impl ClassSetItem { + /// Return the span of this character class set item. + pub fn span(&self) -> &Span { + match *self { + ClassSetItem::Empty(ref span) => span, + ClassSetItem::Literal(ref x) => &x.span, + ClassSetItem::Range(ref x) => &x.span, + ClassSetItem::Ascii(ref x) => &x.span, + ClassSetItem::Perl(ref x) => &x.span, + ClassSetItem::Unicode(ref x) => &x.span, + ClassSetItem::Bracketed(ref x) => &x.span, + ClassSetItem::Union(ref x) => &x.span, + } + } +} + +/// A single character class range in a set. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ClassSetRange { + /// The span of this range. + pub span: Span, + /// The start of this range. + pub start: Literal, + /// The end of this range. + pub end: Literal, +} + +impl ClassSetRange { + /// Returns true if and only if this character class range is valid. + /// + /// The only case where a range is invalid is if its start is greater than + /// its end. + pub fn is_valid(&self) -> bool { + self.start.c <= self.end.c + } +} + +/// A union of items inside a character class set. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ClassSetUnion { + /// The span of the items in this operation. e.g., the `a-z0-9` in + /// `[^a-z0-9]` + pub span: Span, + /// The sequence of items that make up this union. + pub items: Vec<ClassSetItem>, +} + +impl ClassSetUnion { + /// Push a new item in this union. + /// + /// The ending position of this union's span is updated to the ending + /// position of the span of the item given. If the union is empty, then + /// the starting position of this union is set to the starting position + /// of this item. + /// + /// In other words, if you only use this method to add items to a union + /// and you set the spans on each item correctly, then you should never + /// need to adjust the span of the union directly. + pub fn push(&mut self, item: ClassSetItem) { + if self.items.is_empty() { + self.span.start = item.span().start; + } + self.span.end = item.span().end; + self.items.push(item); + } + + /// Return this union as a character class set item. + /// + /// If this union contains zero items, then an empty union is + /// returned. If this concatenation contains exactly 1 item, then the + /// corresponding item is returned. Otherwise, ClassSetItem::Union is + /// returned. + pub fn into_item(mut self) -> ClassSetItem { + match self.items.len() { + 0 => ClassSetItem::Empty(self.span), + 1 => self.items.pop().unwrap(), + _ => ClassSetItem::Union(self), + } + } +} + +/// A Unicode character class set operation. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ClassSetBinaryOp { + /// The span of this operation. e.g., the `a-z--[h-p]` in `[a-z--h-p]`. + pub span: Span, + /// The type of this set operation. + pub kind: ClassSetBinaryOpKind, + /// The left hand side of the operation. + pub lhs: Box<ClassSet>, + /// The right hand side of the operation. + pub rhs: Box<ClassSet>, +} + +/// The type of a Unicode character class set operation. +/// +/// Note that this doesn't explicitly represent union since there is no +/// explicit union operator. Concatenation inside a character class corresponds +/// to the union operation. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum ClassSetBinaryOpKind { + /// The intersection of two sets, e.g., `\pN&&[a-z]`. + Intersection, + /// The difference of two sets, e.g., `\pN--[0-9]`. + Difference, + /// The symmetric difference of two sets. The symmetric difference is the + /// set of elements belonging to one but not both sets. + /// e.g., `[\pL~~[:ascii:]]`. + SymmetricDifference, +} + +/// A single zero-width assertion. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Assertion { + /// The span of this assertion. + pub span: Span, + /// The assertion kind, e.g., `\b` or `^`. + pub kind: AssertionKind, +} + +/// An assertion kind. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum AssertionKind { + /// `^` + StartLine, + /// `$` + EndLine, + /// `\A` + StartText, + /// `\z` + EndText, + /// `\b` + WordBoundary, + /// `\B` + NotWordBoundary, +} + +/// A repetition operation applied to a regular expression. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Repetition { + /// The span of this operation. + pub span: Span, + /// The actual operation. + pub op: RepetitionOp, + /// Whether this operation was applied greedily or not. + pub greedy: bool, + /// The regular expression under repetition. + pub ast: Box<Ast>, +} + +/// The repetition operator itself. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct RepetitionOp { + /// The span of this operator. This includes things like `+`, `*?` and + /// `{m,n}`. + pub span: Span, + /// The type of operation. + pub kind: RepetitionKind, +} + +/// The kind of a repetition operator. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum RepetitionKind { + /// `?` + ZeroOrOne, + /// `*` + ZeroOrMore, + /// `+` + OneOrMore, + /// `{m,n}` + Range(RepetitionRange), +} + +/// A range repetition operator. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum RepetitionRange { + /// `{m}` + Exactly(u32), + /// `{m,}` + AtLeast(u32), + /// `{m,n}` + Bounded(u32, u32), +} + +impl RepetitionRange { + /// Returns true if and only if this repetition range is valid. + /// + /// The only case where a repetition range is invalid is if it is bounded + /// and its start is greater than its end. + pub fn is_valid(&self) -> bool { + match *self { + RepetitionRange::Bounded(s, e) if s > e => false, + _ => true, + } + } +} + +/// A grouped regular expression. +/// +/// This includes both capturing and non-capturing groups. This does **not** +/// include flag-only groups like `(?is)`, but does contain any group that +/// contains a sub-expression, e.g., `(a)`, `(?P<name>a)`, `(?:a)` and +/// `(?is:a)`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Group { + /// The span of this group. + pub span: Span, + /// The kind of this group. + pub kind: GroupKind, + /// The regular expression in this group. + pub ast: Box<Ast>, +} + +impl Group { + /// If this group is non-capturing, then this returns the (possibly empty) + /// set of flags. Otherwise, `None` is returned. + pub fn flags(&self) -> Option<&Flags> { + match self.kind { + GroupKind::NonCapturing(ref flags) => Some(flags), + _ => None, + } + } + + /// Returns true if and only if this group is capturing. + pub fn is_capturing(&self) -> bool { + match self.kind { + GroupKind::CaptureIndex(_) | GroupKind::CaptureName(_) => true, + GroupKind::NonCapturing(_) => false, + } + } + + /// Returns the capture index of this group, if this is a capturing group. + /// + /// This returns a capture index precisely when `is_capturing` is `true`. + pub fn capture_index(&self) -> Option<u32> { + match self.kind { + GroupKind::CaptureIndex(i) => Some(i), + GroupKind::CaptureName(ref x) => Some(x.index), + GroupKind::NonCapturing(_) => None, + } + } +} + +/// The kind of a group. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum GroupKind { + /// `(a)` + CaptureIndex(u32), + /// `(?P<name>a)` + CaptureName(CaptureName), + /// `(?:a)` and `(?i:a)` + NonCapturing(Flags), +} + +/// A capture name. +/// +/// This corresponds to the name itself between the angle brackets in, e.g., +/// `(?P<foo>expr)`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CaptureName { + /// The span of this capture name. + pub span: Span, + /// The capture name. + pub name: String, + /// The capture index. + pub index: u32, +} + +/// A group of flags that is not applied to a particular regular expression. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct SetFlags { + /// The span of these flags, including the grouping parentheses. + pub span: Span, + /// The actual sequence of flags. + pub flags: Flags, +} + +/// A group of flags. +/// +/// This corresponds only to the sequence of flags themselves, e.g., `is-u`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Flags { + /// The span of this group of flags. + pub span: Span, + /// A sequence of flag items. Each item is either a flag or a negation + /// operator. + pub items: Vec<FlagsItem>, +} + +impl Flags { + /// Add the given item to this sequence of flags. + /// + /// If the item was added successfully, then `None` is returned. If the + /// given item is a duplicate, then `Some(i)` is returned, where + /// `items[i].kind == item.kind`. + pub fn add_item(&mut self, item: FlagsItem) -> Option<usize> { + for (i, x) in self.items.iter().enumerate() { + if x.kind == item.kind { + return Some(i); + } + } + self.items.push(item); + None + } + + /// Returns the state of the given flag in this set. + /// + /// If the given flag is in the set but is negated, then `Some(false)` is + /// returned. + /// + /// If the given flag is in the set and is not negated, then `Some(true)` + /// is returned. + /// + /// Otherwise, `None` is returned. + pub fn flag_state(&self, flag: Flag) -> Option<bool> { + let mut negated = false; + for x in &self.items { + match x.kind { + FlagsItemKind::Negation => { + negated = true; + } + FlagsItemKind::Flag(ref xflag) if xflag == &flag => { + return Some(!negated); + } + _ => {} + } + } + None + } +} + +/// A single item in a group of flags. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct FlagsItem { + /// The span of this item. + pub span: Span, + /// The kind of this item. + pub kind: FlagsItemKind, +} + +/// The kind of an item in a group of flags. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum FlagsItemKind { + /// A negation operator applied to all subsequent flags in the enclosing + /// group. + Negation, + /// A single flag in a group. + Flag(Flag), +} + +impl FlagsItemKind { + /// Returns true if and only if this item is a negation operator. + pub fn is_negation(&self) -> bool { + match *self { + FlagsItemKind::Negation => true, + _ => false, + } + } +} + +/// A single flag. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum Flag { + /// `i` + CaseInsensitive, + /// `m` + MultiLine, + /// `s` + DotMatchesNewLine, + /// `U` + SwapGreed, + /// `u` + Unicode, + /// `x` + IgnoreWhitespace, +} + +/// A custom `Drop` impl is used for `Ast` such that it uses constant stack +/// space but heap space proportional to the depth of the `Ast`. +impl Drop for Ast { + fn drop(&mut self) { + use std::mem; + + match *self { + Ast::Empty(_) + | Ast::Flags(_) + | Ast::Literal(_) + | Ast::Dot(_) + | Ast::Assertion(_) + // Classes are recursive, so they get their own Drop impl. + | Ast::Class(_) => return, + Ast::Repetition(ref x) if !x.ast.has_subexprs() => return, + Ast::Group(ref x) if !x.ast.has_subexprs() => return, + Ast::Alternation(ref x) if x.asts.is_empty() => return, + Ast::Concat(ref x) if x.asts.is_empty() => return, + _ => {} + } + + let empty_span = || Span::splat(Position::new(0, 0, 0)); + let empty_ast = || Ast::Empty(empty_span()); + let mut stack = vec![mem::replace(self, empty_ast())]; + while let Some(mut ast) = stack.pop() { + match ast { + Ast::Empty(_) + | Ast::Flags(_) + | Ast::Literal(_) + | Ast::Dot(_) + | Ast::Assertion(_) + // Classes are recursive, so they get their own Drop impl. + | Ast::Class(_) => {} + Ast::Repetition(ref mut x) => { + stack.push(mem::replace(&mut x.ast, empty_ast())); + } + Ast::Group(ref mut x) => { + stack.push(mem::replace(&mut x.ast, empty_ast())); + } + Ast::Alternation(ref mut x) => { + stack.extend(x.asts.drain(..)); + } + Ast::Concat(ref mut x) => { + stack.extend(x.asts.drain(..)); + } + } + } + } +} + +/// A custom `Drop` impl is used for `ClassSet` such that it uses constant +/// stack space but heap space proportional to the depth of the `ClassSet`. +impl Drop for ClassSet { + fn drop(&mut self) { + use std::mem; + + match *self { + ClassSet::Item(ref item) => match *item { + ClassSetItem::Empty(_) + | ClassSetItem::Literal(_) + | ClassSetItem::Range(_) + | ClassSetItem::Ascii(_) + | ClassSetItem::Unicode(_) + | ClassSetItem::Perl(_) => return, + ClassSetItem::Bracketed(ref x) => { + if x.kind.is_empty() { + return; + } + } + ClassSetItem::Union(ref x) => { + if x.items.is_empty() { + return; + } + } + }, + ClassSet::BinaryOp(ref op) => { + if op.lhs.is_empty() && op.rhs.is_empty() { + return; + } + } + } + + let empty_span = || Span::splat(Position::new(0, 0, 0)); + let empty_set = || ClassSet::Item(ClassSetItem::Empty(empty_span())); + let mut stack = vec![mem::replace(self, empty_set())]; + while let Some(mut set) = stack.pop() { + match set { + ClassSet::Item(ref mut item) => match *item { + ClassSetItem::Empty(_) + | ClassSetItem::Literal(_) + | ClassSetItem::Range(_) + | ClassSetItem::Ascii(_) + | ClassSetItem::Unicode(_) + | ClassSetItem::Perl(_) => {} + ClassSetItem::Bracketed(ref mut x) => { + stack.push(mem::replace(&mut x.kind, empty_set())); + } + ClassSetItem::Union(ref mut x) => { + stack.extend(x.items.drain(..).map(ClassSet::Item)); + } + }, + ClassSet::BinaryOp(ref mut op) => { + stack.push(mem::replace(&mut op.lhs, empty_set())); + stack.push(mem::replace(&mut op.rhs, empty_set())); + } + } + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + // We use a thread with an explicit stack size to test that our destructor + // for Ast can handle arbitrarily sized expressions in constant stack + // space. In case we run on a platform without threads (WASM?), we limit + // this test to Windows/Unix. + #[test] + #[cfg(any(unix, windows))] + fn no_stack_overflow_on_drop() { + use std::thread; + + let run = || { + let span = || Span::splat(Position::new(0, 0, 0)); + let mut ast = Ast::Empty(span()); + for i in 0..200 { + ast = Ast::Group(Group { + span: span(), + kind: GroupKind::CaptureIndex(i), + ast: Box::new(ast), + }); + } + assert!(!ast.is_empty()); + }; + + // We run our test on a thread with a small stack size so we can + // force the issue more easily. + thread::Builder::new() + .stack_size(1 << 10) + .spawn(run) + .unwrap() + .join() + .unwrap(); + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/parse.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/parse.rs new file mode 100644 index 0000000..f5b4548 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/parse.rs @@ -0,0 +1,5901 @@ +/*! +This module provides a regular expression parser. +*/ + +use std::borrow::Borrow; +use std::cell::{Cell, RefCell}; +use std::mem; +use std::result; + +use ast::{self, Ast, Position, Span}; +use either::Either; + +use is_meta_character; + +type Result<T> = result::Result<T, ast::Error>; + +/// A primitive is an expression with no sub-expressions. This includes +/// literals, assertions and non-set character classes. This representation +/// is used as intermediate state in the parser. +/// +/// This does not include ASCII character classes, since they can only appear +/// within a set character class. +#[derive(Clone, Debug, Eq, PartialEq)] +enum Primitive { + Literal(ast::Literal), + Assertion(ast::Assertion), + Dot(Span), + Perl(ast::ClassPerl), + Unicode(ast::ClassUnicode), +} + +impl Primitive { + /// Return the span of this primitive. + fn span(&self) -> &Span { + match *self { + Primitive::Literal(ref x) => &x.span, + Primitive::Assertion(ref x) => &x.span, + Primitive::Dot(ref span) => span, + Primitive::Perl(ref x) => &x.span, + Primitive::Unicode(ref x) => &x.span, + } + } + + /// Convert this primitive into a proper AST. + fn into_ast(self) -> Ast { + match self { + Primitive::Literal(lit) => Ast::Literal(lit), + Primitive::Assertion(assert) => Ast::Assertion(assert), + Primitive::Dot(span) => Ast::Dot(span), + Primitive::Perl(cls) => Ast::Class(ast::Class::Perl(cls)), + Primitive::Unicode(cls) => Ast::Class(ast::Class::Unicode(cls)), + } + } + + /// Convert this primitive into an item in a character class. + /// + /// If this primitive is not a legal item (i.e., an assertion or a dot), + /// then return an error. + fn into_class_set_item<P: Borrow<Parser>>( + self, + p: &ParserI<P>, + ) -> Result<ast::ClassSetItem> { + use self::Primitive::*; + use ast::ClassSetItem; + + match self { + Literal(lit) => Ok(ClassSetItem::Literal(lit)), + Perl(cls) => Ok(ClassSetItem::Perl(cls)), + Unicode(cls) => Ok(ClassSetItem::Unicode(cls)), + x => Err(p.error(*x.span(), ast::ErrorKind::ClassEscapeInvalid)), + } + } + + /// Convert this primitive into a literal in a character class. In + /// particular, literals are the only valid items that can appear in + /// ranges. + /// + /// If this primitive is not a legal item (i.e., a class, assertion or a + /// dot), then return an error. + fn into_class_literal<P: Borrow<Parser>>( + self, + p: &ParserI<P>, + ) -> Result<ast::Literal> { + use self::Primitive::*; + + match self { + Literal(lit) => Ok(lit), + x => Err(p.error(*x.span(), ast::ErrorKind::ClassRangeLiteral)), + } + } +} + +/// Returns true if the given character is a hexadecimal digit. +fn is_hex(c: char) -> bool { + ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') +} + +/// Returns true if the given character is a valid in a capture group name. +/// +/// If `first` is true, then `c` is treated as the first character in the +/// group name (which is not allowed to be a digit). +fn is_capture_char(c: char, first: bool) -> bool { + c == '_' + || (!first && c >= '0' && c <= '9') + || (c >= 'a' && c <= 'z') + || (c >= 'A' && c <= 'Z') +} + +/// A builder for a regular expression parser. +/// +/// This builder permits modifying configuration options for the parser. +#[derive(Clone, Debug)] +pub struct ParserBuilder { + ignore_whitespace: bool, + nest_limit: u32, + octal: bool, +} + +impl Default for ParserBuilder { + fn default() -> ParserBuilder { + ParserBuilder::new() + } +} + +impl ParserBuilder { + /// Create a new parser builder with a default configuration. + pub fn new() -> ParserBuilder { + ParserBuilder { + ignore_whitespace: false, + nest_limit: 250, + octal: false, + } + } + + /// Build a parser from this configuration with the given pattern. + pub fn build(&self) -> Parser { + Parser { + pos: Cell::new(Position { offset: 0, line: 1, column: 1 }), + capture_index: Cell::new(0), + nest_limit: self.nest_limit, + octal: self.octal, + initial_ignore_whitespace: self.ignore_whitespace, + ignore_whitespace: Cell::new(self.ignore_whitespace), + comments: RefCell::new(vec![]), + stack_group: RefCell::new(vec![]), + stack_class: RefCell::new(vec![]), + capture_names: RefCell::new(vec![]), + scratch: RefCell::new(String::new()), + } + } + + /// Set the nesting limit for this parser. + /// + /// The nesting limit controls how deep the abstract syntax tree is allowed + /// to be. If the AST exceeds the given limit (e.g., with too many nested + /// groups), then an error is returned by the parser. + /// + /// The purpose of this limit is to act as a heuristic to prevent stack + /// overflow for consumers that do structural induction on an `Ast` using + /// explicit recursion. While this crate never does this (instead using + /// constant stack space and moving the call stack to the heap), other + /// crates may. + /// + /// This limit is not checked until the entire Ast is parsed. Therefore, + /// if callers want to put a limit on the amount of heap space used, then + /// they should impose a limit on the length, in bytes, of the concrete + /// pattern string. In particular, this is viable since this parser + /// implementation will limit itself to heap space proportional to the + /// lenth of the pattern string. + /// + /// Note that a nest limit of `0` will return a nest limit error for most + /// patterns but not all. For example, a nest limit of `0` permits `a` but + /// not `ab`, since `ab` requires a concatenation, which results in a nest + /// depth of `1`. In general, a nest limit is not something that manifests + /// in an obvious way in the concrete syntax, therefore, it should not be + /// used in a granular way. + pub fn nest_limit(&mut self, limit: u32) -> &mut ParserBuilder { + self.nest_limit = limit; + self + } + + /// Whether to support octal syntax or not. + /// + /// Octal syntax is a little-known way of uttering Unicode codepoints in + /// a regular expression. For example, `a`, `\x61`, `\u0061` and + /// `\141` are all equivalent regular expressions, where the last example + /// shows octal syntax. + /// + /// While supporting octal syntax isn't in and of itself a problem, it does + /// make good error messages harder. That is, in PCRE based regex engines, + /// syntax like `\0` invokes a backreference, which is explicitly + /// unsupported in Rust's regex engine. However, many users expect it to + /// be supported. Therefore, when octal support is disabled, the error + /// message will explicitly mention that backreferences aren't supported. + /// + /// Octal syntax is disabled by default. + pub fn octal(&mut self, yes: bool) -> &mut ParserBuilder { + self.octal = yes; + self + } + + /// Enable verbose mode in the regular expression. + /// + /// When enabled, verbose mode permits insigificant whitespace in many + /// places in the regular expression, as well as comments. Comments are + /// started using `#` and continue until the end of the line. + /// + /// By default, this is disabled. It may be selectively enabled in the + /// regular expression by using the `x` flag regardless of this setting. + pub fn ignore_whitespace(&mut self, yes: bool) -> &mut ParserBuilder { + self.ignore_whitespace = yes; + self + } +} + +/// A regular expression parser. +/// +/// This parses a string representation of a regular expression into an +/// abstract syntax tree. The size of the tree is proportional to the length +/// of the regular expression pattern. +/// +/// A `Parser` can be configured in more detail via a +/// [`ParserBuilder`](struct.ParserBuilder.html). +#[derive(Clone, Debug)] +pub struct Parser { + /// The current position of the parser. + pos: Cell<Position>, + /// The current capture index. + capture_index: Cell<u32>, + /// The maximum number of open parens/brackets allowed. If the parser + /// exceeds this number, then an error is returned. + nest_limit: u32, + /// Whether to support octal syntax or not. When `false`, the parser will + /// return an error helpfully pointing out that backreferences are not + /// supported. + octal: bool, + /// The initial setting for `ignore_whitespace` as provided by + /// Th`ParserBuilder`. is is used when reseting the parser's state. + initial_ignore_whitespace: bool, + /// Whether whitespace should be ignored. When enabled, comments are + /// also permitted. + ignore_whitespace: Cell<bool>, + /// A list of comments, in order of appearance. + comments: RefCell<Vec<ast::Comment>>, + /// A stack of grouped sub-expressions, including alternations. + stack_group: RefCell<Vec<GroupState>>, + /// A stack of nested character classes. This is only non-empty when + /// parsing a class. + stack_class: RefCell<Vec<ClassState>>, + /// A sorted sequence of capture names. This is used to detect duplicate + /// capture names and report an error if one is detected. + capture_names: RefCell<Vec<ast::CaptureName>>, + /// A scratch buffer used in various places. Mostly this is used to + /// accumulate relevant characters from parts of a pattern. + scratch: RefCell<String>, +} + +/// ParserI is the internal parser implementation. +/// +/// We use this separate type so that we can carry the provided pattern string +/// along with us. In particular, a `Parser` internal state is not tied to any +/// one pattern, but `ParserI` is. +/// +/// This type also lets us use `ParserI<&Parser>` in production code while +/// retaining the convenience of `ParserI<Parser>` for tests, which sometimes +/// work against the internal interface of the parser. +#[derive(Clone, Debug)] +struct ParserI<'s, P> { + /// The parser state/configuration. + parser: P, + /// The full regular expression provided by the user. + pattern: &'s str, +} + +/// GroupState represents a single stack frame while parsing nested groups +/// and alternations. Each frame records the state up to an opening parenthesis +/// or a alternating bracket `|`. +#[derive(Clone, Debug)] +enum GroupState { + /// This state is pushed whenever an opening group is found. + Group { + /// The concatenation immediately preceding the opening group. + concat: ast::Concat, + /// The group that has been opened. Its sub-AST is always empty. + group: ast::Group, + /// Whether this group has the `x` flag enabled or not. + ignore_whitespace: bool, + }, + /// This state is pushed whenever a new alternation branch is found. If + /// an alternation branch is found and this state is at the top of the + /// stack, then this state should be modified to include the new + /// alternation. + Alternation(ast::Alternation), +} + +/// ClassState represents a single stack frame while parsing character classes. +/// Each frame records the state up to an intersection, difference, symmetric +/// difference or nested class. +/// +/// Note that a parser's character class stack is only non-empty when parsing +/// a character class. In all other cases, it is empty. +#[derive(Clone, Debug)] +enum ClassState { + /// This state is pushed whenever an opening bracket is found. + Open { + /// The union of class items immediately preceding this class. + union: ast::ClassSetUnion, + /// The class that has been opened. Typically this just corresponds + /// to the `[`, but it can also include `[^` since `^` indicates + /// negation of the class. + set: ast::ClassBracketed, + }, + /// This state is pushed when a operator is seen. When popped, the stored + /// set becomes the left hand side of the operator. + Op { + /// The type of the operation, i.e., &&, -- or ~~. + kind: ast::ClassSetBinaryOpKind, + /// The left-hand side of the operator. + lhs: ast::ClassSet, + }, +} + +impl Parser { + /// Create a new parser with a default configuration. + /// + /// The parser can be run with either the `parse` or `parse_with_comments` + /// methods. The parse methods return an abstract syntax tree. + /// + /// To set configuration options on the parser, use + /// [`ParserBuilder`](struct.ParserBuilder.html). + pub fn new() -> Parser { + ParserBuilder::new().build() + } + + /// Parse the regular expression into an abstract syntax tree. + pub fn parse(&mut self, pattern: &str) -> Result<Ast> { + ParserI::new(self, pattern).parse() + } + + /// Parse the regular expression and return an abstract syntax tree with + /// all of the comments found in the pattern. + pub fn parse_with_comments( + &mut self, + pattern: &str, + ) -> Result<ast::WithComments> { + ParserI::new(self, pattern).parse_with_comments() + } + + /// Reset the internal state of a parser. + /// + /// This is called at the beginning of every parse. This prevents the + /// parser from running with inconsistent state (say, if a previous + /// invocation returned an error and the parser is reused). + fn reset(&self) { + // These settings should be in line with the construction + // in `ParserBuilder::build`. + self.pos.set(Position { offset: 0, line: 1, column: 1 }); + self.ignore_whitespace.set(self.initial_ignore_whitespace); + self.comments.borrow_mut().clear(); + self.stack_group.borrow_mut().clear(); + self.stack_class.borrow_mut().clear(); + } +} + +impl<'s, P: Borrow<Parser>> ParserI<'s, P> { + /// Build an internal parser from a parser configuration and a pattern. + fn new(parser: P, pattern: &'s str) -> ParserI<'s, P> { + ParserI { parser: parser, pattern: pattern } + } + + /// Return a reference to the parser state. + fn parser(&self) -> &Parser { + self.parser.borrow() + } + + /// Return a reference to the pattern being parsed. + fn pattern(&self) -> &str { + self.pattern.borrow() + } + + /// Create a new error with the given span and error type. + fn error(&self, span: Span, kind: ast::ErrorKind) -> ast::Error { + ast::Error { + kind: kind, + pattern: self.pattern().to_string(), + span: span, + } + } + + /// Return the current offset of the parser. + /// + /// The offset starts at `0` from the beginning of the regular expression + /// pattern string. + fn offset(&self) -> usize { + self.parser().pos.get().offset + } + + /// Return the current line number of the parser. + /// + /// The line number starts at `1`. + fn line(&self) -> usize { + self.parser().pos.get().line + } + + /// Return the current column of the parser. + /// + /// The column number starts at `1` and is reset whenever a `\n` is seen. + fn column(&self) -> usize { + self.parser().pos.get().column + } + + /// Return the next capturing index. Each subsequent call increments the + /// internal index. + /// + /// The span given should correspond to the location of the opening + /// parenthesis. + /// + /// If the capture limit is exceeded, then an error is returned. + fn next_capture_index(&self, span: Span) -> Result<u32> { + let current = self.parser().capture_index.get(); + let i = current.checked_add(1).ok_or_else(|| { + self.error(span, ast::ErrorKind::CaptureLimitExceeded) + })?; + self.parser().capture_index.set(i); + Ok(i) + } + + /// Adds the given capture name to this parser. If this capture name has + /// already been used, then an error is returned. + fn add_capture_name(&self, cap: &ast::CaptureName) -> Result<()> { + let mut names = self.parser().capture_names.borrow_mut(); + match names + .binary_search_by_key(&cap.name.as_str(), |c| c.name.as_str()) + { + Err(i) => { + names.insert(i, cap.clone()); + Ok(()) + } + Ok(i) => Err(self.error( + cap.span, + ast::ErrorKind::GroupNameDuplicate { original: names[i].span }, + )), + } + } + + /// Return whether the parser should ignore whitespace or not. + fn ignore_whitespace(&self) -> bool { + self.parser().ignore_whitespace.get() + } + + /// Return the character at the current position of the parser. + /// + /// This panics if the current position does not point to a valid char. + fn char(&self) -> char { + self.char_at(self.offset()) + } + + /// Return the character at the given position. + /// + /// This panics if the given position does not point to a valid char. + fn char_at(&self, i: usize) -> char { + self.pattern()[i..] + .chars() + .next() + .unwrap_or_else(|| panic!("expected char at offset {}", i)) + } + + /// Bump the parser to the next Unicode scalar value. + /// + /// If the end of the input has been reached, then `false` is returned. + fn bump(&self) -> bool { + if self.is_eof() { + return false; + } + let Position { mut offset, mut line, mut column } = self.pos(); + if self.char() == '\n' { + line = line.checked_add(1).unwrap(); + column = 1; + } else { + column = column.checked_add(1).unwrap(); + } + offset += self.char().len_utf8(); + self.parser().pos.set(Position { + offset: offset, + line: line, + column: column, + }); + self.pattern()[self.offset()..].chars().next().is_some() + } + + /// If the substring starting at the current position of the parser has + /// the given prefix, then bump the parser to the character immediately + /// following the prefix and return true. Otherwise, don't bump the parser + /// and return false. + fn bump_if(&self, prefix: &str) -> bool { + if self.pattern()[self.offset()..].starts_with(prefix) { + for _ in 0..prefix.chars().count() { + self.bump(); + } + true + } else { + false + } + } + + /// Returns true if and only if the parser is positioned at a look-around + /// prefix. The conditions under which this returns true must always + /// correspond to a regular expression that would otherwise be consider + /// invalid. + /// + /// This should only be called immediately after parsing the opening of + /// a group or a set of flags. + fn is_lookaround_prefix(&self) -> bool { + self.bump_if("?=") + || self.bump_if("?!") + || self.bump_if("?<=") + || self.bump_if("?<!") + } + + /// Bump the parser, and if the `x` flag is enabled, bump through any + /// subsequent spaces. Return true if and only if the parser is not at + /// EOF. + fn bump_and_bump_space(&self) -> bool { + if !self.bump() { + return false; + } + self.bump_space(); + !self.is_eof() + } + + /// If the `x` flag is enabled (i.e., whitespace insensitivity with + /// comments), then this will advance the parser through all whitespace + /// and comments to the next non-whitespace non-comment byte. + /// + /// If the `x` flag is disabled, then this is a no-op. + /// + /// This should be used selectively throughout the parser where + /// arbitrary whitespace is permitted when the `x` flag is enabled. For + /// example, `{ 5 , 6}` is equivalent to `{5,6}`. + fn bump_space(&self) { + if !self.ignore_whitespace() { + return; + } + while !self.is_eof() { + if self.char().is_whitespace() { + self.bump(); + } else if self.char() == '#' { + let start = self.pos(); + let mut comment_text = String::new(); + self.bump(); + while !self.is_eof() { + let c = self.char(); + self.bump(); + if c == '\n' { + break; + } + comment_text.push(c); + } + let comment = ast::Comment { + span: Span::new(start, self.pos()), + comment: comment_text, + }; + self.parser().comments.borrow_mut().push(comment); + } else { + break; + } + } + } + + /// Peek at the next character in the input without advancing the parser. + /// + /// If the input has been exhausted, then this returns `None`. + fn peek(&self) -> Option<char> { + if self.is_eof() { + return None; + } + self.pattern()[self.offset() + self.char().len_utf8()..].chars().next() + } + + /// Like peek, but will ignore spaces when the parser is in whitespace + /// insensitive mode. + fn peek_space(&self) -> Option<char> { + if !self.ignore_whitespace() { + return self.peek(); + } + if self.is_eof() { + return None; + } + let mut start = self.offset() + self.char().len_utf8(); + let mut in_comment = false; + for (i, c) in self.pattern()[start..].char_indices() { + if c.is_whitespace() { + continue; + } else if !in_comment && c == '#' { + in_comment = true; + } else if in_comment && c == '\n' { + in_comment = false; + } else { + start += i; + break; + } + } + self.pattern()[start..].chars().next() + } + + /// Returns true if the next call to `bump` would return false. + fn is_eof(&self) -> bool { + self.offset() == self.pattern().len() + } + + /// Return the current position of the parser, which includes the offset, + /// line and column. + fn pos(&self) -> Position { + self.parser().pos.get() + } + + /// Create a span at the current position of the parser. Both the start + /// and end of the span are set. + fn span(&self) -> Span { + Span::splat(self.pos()) + } + + /// Create a span that covers the current character. + fn span_char(&self) -> Span { + let mut next = Position { + offset: self.offset().checked_add(self.char().len_utf8()).unwrap(), + line: self.line(), + column: self.column().checked_add(1).unwrap(), + }; + if self.char() == '\n' { + next.line += 1; + next.column = 1; + } + Span::new(self.pos(), next) + } + + /// Parse and push a single alternation on to the parser's internal stack. + /// If the top of the stack already has an alternation, then add to that + /// instead of pushing a new one. + /// + /// The concatenation given corresponds to a single alternation branch. + /// The concatenation returned starts the next branch and is empty. + /// + /// This assumes the parser is currently positioned at `|` and will advance + /// the parser to the character following `|`. + #[inline(never)] + fn push_alternate(&self, mut concat: ast::Concat) -> Result<ast::Concat> { + assert_eq!(self.char(), '|'); + concat.span.end = self.pos(); + self.push_or_add_alternation(concat); + self.bump(); + Ok(ast::Concat { span: self.span(), asts: vec![] }) + } + + /// Pushes or adds the given branch of an alternation to the parser's + /// internal stack of state. + fn push_or_add_alternation(&self, concat: ast::Concat) { + use self::GroupState::*; + + let mut stack = self.parser().stack_group.borrow_mut(); + if let Some(&mut Alternation(ref mut alts)) = stack.last_mut() { + alts.asts.push(concat.into_ast()); + return; + } + stack.push(Alternation(ast::Alternation { + span: Span::new(concat.span.start, self.pos()), + asts: vec![concat.into_ast()], + })); + } + + /// Parse and push a group AST (and its parent concatenation) on to the + /// parser's internal stack. Return a fresh concatenation corresponding + /// to the group's sub-AST. + /// + /// If a set of flags was found (with no group), then the concatenation + /// is returned with that set of flags added. + /// + /// This assumes that the parser is currently positioned on the opening + /// parenthesis. It advances the parser to the character at the start + /// of the sub-expression (or adjoining expression). + /// + /// If there was a problem parsing the start of the group, then an error + /// is returned. + #[inline(never)] + fn push_group(&self, mut concat: ast::Concat) -> Result<ast::Concat> { + assert_eq!(self.char(), '('); + match self.parse_group()? { + Either::Left(set) => { + let ignore = set.flags.flag_state(ast::Flag::IgnoreWhitespace); + if let Some(v) = ignore { + self.parser().ignore_whitespace.set(v); + } + + concat.asts.push(Ast::Flags(set)); + Ok(concat) + } + Either::Right(group) => { + let old_ignore_whitespace = self.ignore_whitespace(); + let new_ignore_whitespace = group + .flags() + .and_then(|f| f.flag_state(ast::Flag::IgnoreWhitespace)) + .unwrap_or(old_ignore_whitespace); + self.parser().stack_group.borrow_mut().push( + GroupState::Group { + concat: concat, + group: group, + ignore_whitespace: old_ignore_whitespace, + }, + ); + self.parser().ignore_whitespace.set(new_ignore_whitespace); + Ok(ast::Concat { span: self.span(), asts: vec![] }) + } + } + } + + /// Pop a group AST from the parser's internal stack and set the group's + /// AST to the given concatenation. Return the concatenation containing + /// the group. + /// + /// This assumes that the parser is currently positioned on the closing + /// parenthesis and advances the parser to the character following the `)`. + /// + /// If no such group could be popped, then an unopened group error is + /// returned. + #[inline(never)] + fn pop_group(&self, mut group_concat: ast::Concat) -> Result<ast::Concat> { + use self::GroupState::*; + + assert_eq!(self.char(), ')'); + let mut stack = self.parser().stack_group.borrow_mut(); + let (mut prior_concat, mut group, ignore_whitespace, alt) = match stack + .pop() + { + Some(Group { concat, group, ignore_whitespace }) => { + (concat, group, ignore_whitespace, None) + } + Some(Alternation(alt)) => match stack.pop() { + Some(Group { concat, group, ignore_whitespace }) => { + (concat, group, ignore_whitespace, Some(alt)) + } + None | Some(Alternation(_)) => { + return Err(self.error( + self.span_char(), + ast::ErrorKind::GroupUnopened, + )); + } + }, + None => { + return Err(self + .error(self.span_char(), ast::ErrorKind::GroupUnopened)); + } + }; + self.parser().ignore_whitespace.set(ignore_whitespace); + group_concat.span.end = self.pos(); + self.bump(); + group.span.end = self.pos(); + match alt { + Some(mut alt) => { + alt.span.end = group_concat.span.end; + alt.asts.push(group_concat.into_ast()); + group.ast = Box::new(alt.into_ast()); + } + None => { + group.ast = Box::new(group_concat.into_ast()); + } + } + prior_concat.asts.push(Ast::Group(group)); + Ok(prior_concat) + } + + /// Pop the last state from the parser's internal stack, if it exists, and + /// add the given concatenation to it. There either must be no state or a + /// single alternation item on the stack. Any other scenario produces an + /// error. + /// + /// This assumes that the parser has advanced to the end. + #[inline(never)] + fn pop_group_end(&self, mut concat: ast::Concat) -> Result<Ast> { + concat.span.end = self.pos(); + let mut stack = self.parser().stack_group.borrow_mut(); + let ast = match stack.pop() { + None => Ok(concat.into_ast()), + Some(GroupState::Alternation(mut alt)) => { + alt.span.end = self.pos(); + alt.asts.push(concat.into_ast()); + Ok(Ast::Alternation(alt)) + } + Some(GroupState::Group { group, .. }) => { + return Err( + self.error(group.span, ast::ErrorKind::GroupUnclosed) + ); + } + }; + // If we try to pop again, there should be nothing. + match stack.pop() { + None => ast, + Some(GroupState::Alternation(_)) => { + // This unreachable is unfortunate. This case can't happen + // because the only way we can be here is if there were two + // `GroupState::Alternation`s adjacent in the parser's stack, + // which we guarantee to never happen because we never push a + // `GroupState::Alternation` if one is already at the top of + // the stack. + unreachable!() + } + Some(GroupState::Group { group, .. }) => { + Err(self.error(group.span, ast::ErrorKind::GroupUnclosed)) + } + } + } + + /// Parse the opening of a character class and push the current class + /// parsing context onto the parser's stack. This assumes that the parser + /// is positioned at an opening `[`. The given union should correspond to + /// the union of set items built up before seeing the `[`. + /// + /// If there was a problem parsing the opening of the class, then an error + /// is returned. Otherwise, a new union of set items for the class is + /// returned (which may be populated with either a `]` or a `-`). + #[inline(never)] + fn push_class_open( + &self, + parent_union: ast::ClassSetUnion, + ) -> Result<ast::ClassSetUnion> { + assert_eq!(self.char(), '['); + + let (nested_set, nested_union) = self.parse_set_class_open()?; + self.parser() + .stack_class + .borrow_mut() + .push(ClassState::Open { union: parent_union, set: nested_set }); + Ok(nested_union) + } + + /// Parse the end of a character class set and pop the character class + /// parser stack. The union given corresponds to the last union built + /// before seeing the closing `]`. The union returned corresponds to the + /// parent character class set with the nested class added to it. + /// + /// This assumes that the parser is positioned at a `]` and will advance + /// the parser to the byte immediately following the `]`. + /// + /// If the stack is empty after popping, then this returns the final + /// "top-level" character class AST (where a "top-level" character class + /// is one that is not nested inside any other character class). + /// + /// If there is no corresponding opening bracket on the parser's stack, + /// then an error is returned. + #[inline(never)] + fn pop_class( + &self, + nested_union: ast::ClassSetUnion, + ) -> Result<Either<ast::ClassSetUnion, ast::Class>> { + assert_eq!(self.char(), ']'); + + let item = ast::ClassSet::Item(nested_union.into_item()); + let prevset = self.pop_class_op(item); + let mut stack = self.parser().stack_class.borrow_mut(); + match stack.pop() { + None => { + // We can never observe an empty stack: + // + // 1) We are guaranteed to start with a non-empty stack since + // the character class parser is only initiated when it sees + // a `[`. + // 2) If we ever observe an empty stack while popping after + // seeing a `]`, then we signal the character class parser + // to terminate. + panic!("unexpected empty character class stack") + } + Some(ClassState::Op { .. }) => { + // This panic is unfortunate, but this case is impossible + // since we already popped the Op state if one exists above. + // Namely, every push to the class parser stack is guarded by + // whether an existing Op is already on the top of the stack. + // If it is, the existing Op is modified. That is, the stack + // can never have consecutive Op states. + panic!("unexpected ClassState::Op") + } + Some(ClassState::Open { mut union, mut set }) => { + self.bump(); + set.span.end = self.pos(); + set.kind = prevset; + if stack.is_empty() { + Ok(Either::Right(ast::Class::Bracketed(set))) + } else { + union.push(ast::ClassSetItem::Bracketed(Box::new(set))); + Ok(Either::Left(union)) + } + } + } + } + + /// Return an "unclosed class" error whose span points to the most + /// recently opened class. + /// + /// This should only be called while parsing a character class. + #[inline(never)] + fn unclosed_class_error(&self) -> ast::Error { + for state in self.parser().stack_class.borrow().iter().rev() { + match *state { + ClassState::Open { ref set, .. } => { + return self + .error(set.span, ast::ErrorKind::ClassUnclosed); + } + _ => {} + } + } + // We are guaranteed to have a non-empty stack with at least + // one open bracket, so we should never get here. + panic!("no open character class found") + } + + /// Push the current set of class items on to the class parser's stack as + /// the left hand side of the given operator. + /// + /// A fresh set union is returned, which should be used to build the right + /// hand side of this operator. + #[inline(never)] + fn push_class_op( + &self, + next_kind: ast::ClassSetBinaryOpKind, + next_union: ast::ClassSetUnion, + ) -> ast::ClassSetUnion { + let item = ast::ClassSet::Item(next_union.into_item()); + let new_lhs = self.pop_class_op(item); + self.parser() + .stack_class + .borrow_mut() + .push(ClassState::Op { kind: next_kind, lhs: new_lhs }); + ast::ClassSetUnion { span: self.span(), items: vec![] } + } + + /// Pop a character class set from the character class parser stack. If the + /// top of the stack is just an item (not an operation), then return the + /// given set unchanged. If the top of the stack is an operation, then the + /// given set will be used as the rhs of the operation on the top of the + /// stack. In that case, the binary operation is returned as a set. + #[inline(never)] + fn pop_class_op(&self, rhs: ast::ClassSet) -> ast::ClassSet { + let mut stack = self.parser().stack_class.borrow_mut(); + let (kind, lhs) = match stack.pop() { + Some(ClassState::Op { kind, lhs }) => (kind, lhs), + Some(state @ ClassState::Open { .. }) => { + stack.push(state); + return rhs; + } + None => unreachable!(), + }; + let span = Span::new(lhs.span().start, rhs.span().end); + ast::ClassSet::BinaryOp(ast::ClassSetBinaryOp { + span: span, + kind: kind, + lhs: Box::new(lhs), + rhs: Box::new(rhs), + }) + } +} + +impl<'s, P: Borrow<Parser>> ParserI<'s, P> { + /// Parse the regular expression into an abstract syntax tree. + fn parse(&self) -> Result<Ast> { + self.parse_with_comments().map(|astc| astc.ast) + } + + /// Parse the regular expression and return an abstract syntax tree with + /// all of the comments found in the pattern. + fn parse_with_comments(&self) -> Result<ast::WithComments> { + assert_eq!(self.offset(), 0, "parser can only be used once"); + self.parser().reset(); + let mut concat = ast::Concat { span: self.span(), asts: vec![] }; + loop { + self.bump_space(); + if self.is_eof() { + break; + } + match self.char() { + '(' => concat = self.push_group(concat)?, + ')' => concat = self.pop_group(concat)?, + '|' => concat = self.push_alternate(concat)?, + '[' => { + let class = self.parse_set_class()?; + concat.asts.push(Ast::Class(class)); + } + '?' => { + concat = self.parse_uncounted_repetition( + concat, + ast::RepetitionKind::ZeroOrOne, + )?; + } + '*' => { + concat = self.parse_uncounted_repetition( + concat, + ast::RepetitionKind::ZeroOrMore, + )?; + } + '+' => { + concat = self.parse_uncounted_repetition( + concat, + ast::RepetitionKind::OneOrMore, + )?; + } + '{' => { + concat = self.parse_counted_repetition(concat)?; + } + _ => concat.asts.push(self.parse_primitive()?.into_ast()), + } + } + let ast = self.pop_group_end(concat)?; + NestLimiter::new(self).check(&ast)?; + Ok(ast::WithComments { + ast: ast, + comments: mem::replace( + &mut *self.parser().comments.borrow_mut(), + vec![], + ), + }) + } + + /// Parses an uncounted repetition operation. An uncounted repetition + /// operator includes ?, * and +, but does not include the {m,n} syntax. + /// The given `kind` should correspond to the operator observed by the + /// caller. + /// + /// This assumes that the paser is currently positioned at the repetition + /// operator and advances the parser to the first character after the + /// operator. (Note that the operator may include a single additional `?`, + /// which makes the operator ungreedy.) + /// + /// The caller should include the concatenation that is being built. The + /// concatenation returned includes the repetition operator applied to the + /// last expression in the given concatenation. + #[inline(never)] + fn parse_uncounted_repetition( + &self, + mut concat: ast::Concat, + kind: ast::RepetitionKind, + ) -> Result<ast::Concat> { + assert!( + self.char() == '?' || self.char() == '*' || self.char() == '+' + ); + let op_start = self.pos(); + let ast = match concat.asts.pop() { + Some(ast) => ast, + None => { + return Err( + self.error(self.span(), ast::ErrorKind::RepetitionMissing) + ) + } + }; + match ast { + Ast::Empty(_) | Ast::Flags(_) => { + return Err( + self.error(self.span(), ast::ErrorKind::RepetitionMissing) + ) + } + _ => {} + } + let mut greedy = true; + if self.bump() && self.char() == '?' { + greedy = false; + self.bump(); + } + concat.asts.push(Ast::Repetition(ast::Repetition { + span: ast.span().with_end(self.pos()), + op: ast::RepetitionOp { + span: Span::new(op_start, self.pos()), + kind: kind, + }, + greedy: greedy, + ast: Box::new(ast), + })); + Ok(concat) + } + + /// Parses a counted repetition operation. A counted repetition operator + /// corresponds to the {m,n} syntax, and does not include the ?, * or + + /// operators. + /// + /// This assumes that the paser is currently positioned at the opening `{` + /// and advances the parser to the first character after the operator. + /// (Note that the operator may include a single additional `?`, which + /// makes the operator ungreedy.) + /// + /// The caller should include the concatenation that is being built. The + /// concatenation returned includes the repetition operator applied to the + /// last expression in the given concatenation. + #[inline(never)] + fn parse_counted_repetition( + &self, + mut concat: ast::Concat, + ) -> Result<ast::Concat> { + assert!(self.char() == '{'); + let start = self.pos(); + let ast = match concat.asts.pop() { + Some(ast) => ast, + None => { + return Err( + self.error(self.span(), ast::ErrorKind::RepetitionMissing) + ) + } + }; + match ast { + Ast::Empty(_) | Ast::Flags(_) => { + return Err( + self.error(self.span(), ast::ErrorKind::RepetitionMissing) + ) + } + _ => {} + } + if !self.bump_and_bump_space() { + return Err(self.error( + Span::new(start, self.pos()), + ast::ErrorKind::RepetitionCountUnclosed, + )); + } + let count_start = specialize_err( + self.parse_decimal(), + ast::ErrorKind::DecimalEmpty, + ast::ErrorKind::RepetitionCountDecimalEmpty, + )?; + let mut range = ast::RepetitionRange::Exactly(count_start); + if self.is_eof() { + return Err(self.error( + Span::new(start, self.pos()), + ast::ErrorKind::RepetitionCountUnclosed, + )); + } + if self.char() == ',' { + if !self.bump_and_bump_space() { + return Err(self.error( + Span::new(start, self.pos()), + ast::ErrorKind::RepetitionCountUnclosed, + )); + } + if self.char() != '}' { + let count_end = specialize_err( + self.parse_decimal(), + ast::ErrorKind::DecimalEmpty, + ast::ErrorKind::RepetitionCountDecimalEmpty, + )?; + range = ast::RepetitionRange::Bounded(count_start, count_end); + } else { + range = ast::RepetitionRange::AtLeast(count_start); + } + } + if self.is_eof() || self.char() != '}' { + return Err(self.error( + Span::new(start, self.pos()), + ast::ErrorKind::RepetitionCountUnclosed, + )); + } + + let mut greedy = true; + if self.bump_and_bump_space() && self.char() == '?' { + greedy = false; + self.bump(); + } + + let op_span = Span::new(start, self.pos()); + if !range.is_valid() { + return Err( + self.error(op_span, ast::ErrorKind::RepetitionCountInvalid) + ); + } + concat.asts.push(Ast::Repetition(ast::Repetition { + span: ast.span().with_end(self.pos()), + op: ast::RepetitionOp { + span: op_span, + kind: ast::RepetitionKind::Range(range), + }, + greedy: greedy, + ast: Box::new(ast), + })); + Ok(concat) + } + + /// Parse a group (which contains a sub-expression) or a set of flags. + /// + /// If a group was found, then it is returned with an empty AST. If a set + /// of flags is found, then that set is returned. + /// + /// The parser should be positioned at the opening parenthesis. + /// + /// This advances the parser to the character before the start of the + /// sub-expression (in the case of a group) or to the closing parenthesis + /// immediately following the set of flags. + /// + /// # Errors + /// + /// If flags are given and incorrectly specified, then a corresponding + /// error is returned. + /// + /// If a capture name is given and it is incorrectly specified, then a + /// corresponding error is returned. + #[inline(never)] + fn parse_group(&self) -> Result<Either<ast::SetFlags, ast::Group>> { + assert_eq!(self.char(), '('); + let open_span = self.span_char(); + self.bump(); + self.bump_space(); + if self.is_lookaround_prefix() { + return Err(self.error( + Span::new(open_span.start, self.span().end), + ast::ErrorKind::UnsupportedLookAround, + )); + } + let inner_span = self.span(); + if self.bump_if("?P<") { + let capture_index = self.next_capture_index(open_span)?; + let cap = self.parse_capture_name(capture_index)?; + Ok(Either::Right(ast::Group { + span: open_span, + kind: ast::GroupKind::CaptureName(cap), + ast: Box::new(Ast::Empty(self.span())), + })) + } else if self.bump_if("?") { + if self.is_eof() { + return Err( + self.error(open_span, ast::ErrorKind::GroupUnclosed) + ); + } + let flags = self.parse_flags()?; + let char_end = self.char(); + self.bump(); + if char_end == ')' { + // We don't allow empty flags, e.g., `(?)`. We instead + // interpret it as a repetition operator missing its argument. + if flags.items.is_empty() { + return Err(self.error( + inner_span, + ast::ErrorKind::RepetitionMissing, + )); + } + Ok(Either::Left(ast::SetFlags { + span: Span { end: self.pos(), ..open_span }, + flags: flags, + })) + } else { + assert_eq!(char_end, ':'); + Ok(Either::Right(ast::Group { + span: open_span, + kind: ast::GroupKind::NonCapturing(flags), + ast: Box::new(Ast::Empty(self.span())), + })) + } + } else { + let capture_index = self.next_capture_index(open_span)?; + Ok(Either::Right(ast::Group { + span: open_span, + kind: ast::GroupKind::CaptureIndex(capture_index), + ast: Box::new(Ast::Empty(self.span())), + })) + } + } + + /// Parses a capture group name. Assumes that the parser is positioned at + /// the first character in the name following the opening `<` (and may + /// possibly be EOF). This advances the parser to the first character + /// following the closing `>`. + /// + /// The caller must provide the capture index of the group for this name. + #[inline(never)] + fn parse_capture_name( + &self, + capture_index: u32, + ) -> Result<ast::CaptureName> { + if self.is_eof() { + return Err(self + .error(self.span(), ast::ErrorKind::GroupNameUnexpectedEof)); + } + let start = self.pos(); + loop { + if self.char() == '>' { + break; + } + if !is_capture_char(self.char(), self.pos() == start) { + return Err(self.error( + self.span_char(), + ast::ErrorKind::GroupNameInvalid, + )); + } + if !self.bump() { + break; + } + } + let end = self.pos(); + if self.is_eof() { + return Err(self + .error(self.span(), ast::ErrorKind::GroupNameUnexpectedEof)); + } + assert_eq!(self.char(), '>'); + self.bump(); + let name = &self.pattern()[start.offset..end.offset]; + if name.is_empty() { + return Err(self.error( + Span::new(start, start), + ast::ErrorKind::GroupNameEmpty, + )); + } + let capname = ast::CaptureName { + span: Span::new(start, end), + name: name.to_string(), + index: capture_index, + }; + self.add_capture_name(&capname)?; + Ok(capname) + } + + /// Parse a sequence of flags starting at the current character. + /// + /// This advances the parser to the character immediately following the + /// flags, which is guaranteed to be either `:` or `)`. + /// + /// # Errors + /// + /// If any flags are duplicated, then an error is returned. + /// + /// If the negation operator is used more than once, then an error is + /// returned. + /// + /// If no flags could be found or if the negation operation is not followed + /// by any flags, then an error is returned. + #[inline(never)] + fn parse_flags(&self) -> Result<ast::Flags> { + let mut flags = ast::Flags { span: self.span(), items: vec![] }; + let mut last_was_negation = None; + while self.char() != ':' && self.char() != ')' { + if self.char() == '-' { + last_was_negation = Some(self.span_char()); + let item = ast::FlagsItem { + span: self.span_char(), + kind: ast::FlagsItemKind::Negation, + }; + if let Some(i) = flags.add_item(item) { + return Err(self.error( + self.span_char(), + ast::ErrorKind::FlagRepeatedNegation { + original: flags.items[i].span, + }, + )); + } + } else { + last_was_negation = None; + let item = ast::FlagsItem { + span: self.span_char(), + kind: ast::FlagsItemKind::Flag(self.parse_flag()?), + }; + if let Some(i) = flags.add_item(item) { + return Err(self.error( + self.span_char(), + ast::ErrorKind::FlagDuplicate { + original: flags.items[i].span, + }, + )); + } + } + if !self.bump() { + return Err( + self.error(self.span(), ast::ErrorKind::FlagUnexpectedEof) + ); + } + } + if let Some(span) = last_was_negation { + return Err(self.error(span, ast::ErrorKind::FlagDanglingNegation)); + } + flags.span.end = self.pos(); + Ok(flags) + } + + /// Parse the current character as a flag. Do not advance the parser. + /// + /// # Errors + /// + /// If the flag is not recognized, then an error is returned. + #[inline(never)] + fn parse_flag(&self) -> Result<ast::Flag> { + match self.char() { + 'i' => Ok(ast::Flag::CaseInsensitive), + 'm' => Ok(ast::Flag::MultiLine), + 's' => Ok(ast::Flag::DotMatchesNewLine), + 'U' => Ok(ast::Flag::SwapGreed), + 'u' => Ok(ast::Flag::Unicode), + 'x' => Ok(ast::Flag::IgnoreWhitespace), + _ => { + Err(self + .error(self.span_char(), ast::ErrorKind::FlagUnrecognized)) + } + } + } + + /// Parse a primitive AST. e.g., A literal, non-set character class or + /// assertion. + /// + /// This assumes that the parser expects a primitive at the current + /// location. i.e., All other non-primitive cases have been handled. + /// For example, if the parser's position is at `|`, then `|` will be + /// treated as a literal (e.g., inside a character class). + /// + /// This advances the parser to the first character immediately following + /// the primitive. + fn parse_primitive(&self) -> Result<Primitive> { + match self.char() { + '\\' => self.parse_escape(), + '.' => { + let ast = Primitive::Dot(self.span_char()); + self.bump(); + Ok(ast) + } + '^' => { + let ast = Primitive::Assertion(ast::Assertion { + span: self.span_char(), + kind: ast::AssertionKind::StartLine, + }); + self.bump(); + Ok(ast) + } + '$' => { + let ast = Primitive::Assertion(ast::Assertion { + span: self.span_char(), + kind: ast::AssertionKind::EndLine, + }); + self.bump(); + Ok(ast) + } + c => { + let ast = Primitive::Literal(ast::Literal { + span: self.span_char(), + kind: ast::LiteralKind::Verbatim, + c: c, + }); + self.bump(); + Ok(ast) + } + } + } + + /// Parse an escape sequence as a primitive AST. + /// + /// This assumes the parser is positioned at the start of the escape + /// sequence, i.e., `\`. It advances the parser to the first position + /// immediately following the escape sequence. + #[inline(never)] + fn parse_escape(&self) -> Result<Primitive> { + assert_eq!(self.char(), '\\'); + let start = self.pos(); + if !self.bump() { + return Err(self.error( + Span::new(start, self.pos()), + ast::ErrorKind::EscapeUnexpectedEof, + )); + } + let c = self.char(); + // Put some of the more complicated routines into helpers. + match c { + '0'..='7' => { + if !self.parser().octal { + return Err(self.error( + Span::new(start, self.span_char().end), + ast::ErrorKind::UnsupportedBackreference, + )); + } + let mut lit = self.parse_octal(); + lit.span.start = start; + return Ok(Primitive::Literal(lit)); + } + '8'..='9' if !self.parser().octal => { + return Err(self.error( + Span::new(start, self.span_char().end), + ast::ErrorKind::UnsupportedBackreference, + )); + } + 'x' | 'u' | 'U' => { + let mut lit = self.parse_hex()?; + lit.span.start = start; + return Ok(Primitive::Literal(lit)); + } + 'p' | 'P' => { + let mut cls = self.parse_unicode_class()?; + cls.span.start = start; + return Ok(Primitive::Unicode(cls)); + } + 'd' | 's' | 'w' | 'D' | 'S' | 'W' => { + let mut cls = self.parse_perl_class(); + cls.span.start = start; + return Ok(Primitive::Perl(cls)); + } + _ => {} + } + + // Handle all of the one letter sequences inline. + self.bump(); + let span = Span::new(start, self.pos()); + if is_meta_character(c) { + return Ok(Primitive::Literal(ast::Literal { + span: span, + kind: ast::LiteralKind::Punctuation, + c: c, + })); + } + let special = |kind, c| { + Ok(Primitive::Literal(ast::Literal { + span: span, + kind: ast::LiteralKind::Special(kind), + c: c, + })) + }; + match c { + 'a' => special(ast::SpecialLiteralKind::Bell, '\x07'), + 'f' => special(ast::SpecialLiteralKind::FormFeed, '\x0C'), + 't' => special(ast::SpecialLiteralKind::Tab, '\t'), + 'n' => special(ast::SpecialLiteralKind::LineFeed, '\n'), + 'r' => special(ast::SpecialLiteralKind::CarriageReturn, '\r'), + 'v' => special(ast::SpecialLiteralKind::VerticalTab, '\x0B'), + ' ' if self.ignore_whitespace() => { + special(ast::SpecialLiteralKind::Space, ' ') + } + 'A' => Ok(Primitive::Assertion(ast::Assertion { + span: span, + kind: ast::AssertionKind::StartText, + })), + 'z' => Ok(Primitive::Assertion(ast::Assertion { + span: span, + kind: ast::AssertionKind::EndText, + })), + 'b' => Ok(Primitive::Assertion(ast::Assertion { + span: span, + kind: ast::AssertionKind::WordBoundary, + })), + 'B' => Ok(Primitive::Assertion(ast::Assertion { + span: span, + kind: ast::AssertionKind::NotWordBoundary, + })), + _ => Err(self.error(span, ast::ErrorKind::EscapeUnrecognized)), + } + } + + /// Parse an octal representation of a Unicode codepoint up to 3 digits + /// long. This expects the parser to be positioned at the first octal + /// digit and advances the parser to the first character immediately + /// following the octal number. This also assumes that parsing octal + /// escapes is enabled. + /// + /// Assuming the preconditions are met, this routine can never fail. + #[inline(never)] + fn parse_octal(&self) -> ast::Literal { + use std::char; + use std::u32; + + assert!(self.parser().octal); + assert!('0' <= self.char() && self.char() <= '7'); + let start = self.pos(); + // Parse up to two more digits. + while self.bump() + && '0' <= self.char() + && self.char() <= '7' + && self.pos().offset - start.offset <= 2 + {} + let end = self.pos(); + let octal = &self.pattern()[start.offset..end.offset]; + // Parsing the octal should never fail since the above guarantees a + // valid number. + let codepoint = + u32::from_str_radix(octal, 8).expect("valid octal number"); + // The max value for 3 digit octal is 0777 = 511 and [0, 511] has no + // invalid Unicode scalar values. + let c = char::from_u32(codepoint).expect("Unicode scalar value"); + ast::Literal { + span: Span::new(start, end), + kind: ast::LiteralKind::Octal, + c: c, + } + } + + /// Parse a hex representation of a Unicode codepoint. This handles both + /// hex notations, i.e., `\xFF` and `\x{FFFF}`. This expects the parser to + /// be positioned at the `x`, `u` or `U` prefix. The parser is advanced to + /// the first character immediately following the hexadecimal literal. + #[inline(never)] + fn parse_hex(&self) -> Result<ast::Literal> { + assert!( + self.char() == 'x' || self.char() == 'u' || self.char() == 'U' + ); + + let hex_kind = match self.char() { + 'x' => ast::HexLiteralKind::X, + 'u' => ast::HexLiteralKind::UnicodeShort, + _ => ast::HexLiteralKind::UnicodeLong, + }; + if !self.bump_and_bump_space() { + return Err( + self.error(self.span(), ast::ErrorKind::EscapeUnexpectedEof) + ); + } + if self.char() == '{' { + self.parse_hex_brace(hex_kind) + } else { + self.parse_hex_digits(hex_kind) + } + } + + /// Parse an N-digit hex representation of a Unicode codepoint. This + /// expects the parser to be positioned at the first digit and will advance + /// the parser to the first character immediately following the escape + /// sequence. + /// + /// The number of digits given must be 2 (for `\xNN`), 4 (for `\uNNNN`) + /// or 8 (for `\UNNNNNNNN`). + #[inline(never)] + fn parse_hex_digits( + &self, + kind: ast::HexLiteralKind, + ) -> Result<ast::Literal> { + use std::char; + use std::u32; + + let mut scratch = self.parser().scratch.borrow_mut(); + scratch.clear(); + + let start = self.pos(); + for i in 0..kind.digits() { + if i > 0 && !self.bump_and_bump_space() { + return Err(self + .error(self.span(), ast::ErrorKind::EscapeUnexpectedEof)); + } + if !is_hex(self.char()) { + return Err(self.error( + self.span_char(), + ast::ErrorKind::EscapeHexInvalidDigit, + )); + } + scratch.push(self.char()); + } + // The final bump just moves the parser past the literal, which may + // be EOF. + self.bump_and_bump_space(); + let end = self.pos(); + let hex = scratch.as_str(); + match u32::from_str_radix(hex, 16).ok().and_then(char::from_u32) { + None => Err(self.error( + Span::new(start, end), + ast::ErrorKind::EscapeHexInvalid, + )), + Some(c) => Ok(ast::Literal { + span: Span::new(start, end), + kind: ast::LiteralKind::HexFixed(kind), + c: c, + }), + } + } + + /// Parse a hex representation of any Unicode scalar value. This expects + /// the parser to be positioned at the opening brace `{` and will advance + /// the parser to the first character following the closing brace `}`. + #[inline(never)] + fn parse_hex_brace( + &self, + kind: ast::HexLiteralKind, + ) -> Result<ast::Literal> { + use std::char; + use std::u32; + + let mut scratch = self.parser().scratch.borrow_mut(); + scratch.clear(); + + let brace_pos = self.pos(); + let start = self.span_char().end; + while self.bump_and_bump_space() && self.char() != '}' { + if !is_hex(self.char()) { + return Err(self.error( + self.span_char(), + ast::ErrorKind::EscapeHexInvalidDigit, + )); + } + scratch.push(self.char()); + } + if self.is_eof() { + return Err(self.error( + Span::new(brace_pos, self.pos()), + ast::ErrorKind::EscapeUnexpectedEof, + )); + } + let end = self.pos(); + let hex = scratch.as_str(); + assert_eq!(self.char(), '}'); + self.bump_and_bump_space(); + + if hex.is_empty() { + return Err(self.error( + Span::new(brace_pos, self.pos()), + ast::ErrorKind::EscapeHexEmpty, + )); + } + match u32::from_str_radix(hex, 16).ok().and_then(char::from_u32) { + None => Err(self.error( + Span::new(start, end), + ast::ErrorKind::EscapeHexInvalid, + )), + Some(c) => Ok(ast::Literal { + span: Span::new(start, self.pos()), + kind: ast::LiteralKind::HexBrace(kind), + c: c, + }), + } + } + + /// Parse a decimal number into a u32 while trimming leading and trailing + /// whitespace. + /// + /// This expects the parser to be positioned at the first position where + /// a decimal digit could occur. This will advance the parser to the byte + /// immediately following the last contiguous decimal digit. + /// + /// If no decimal digit could be found or if there was a problem parsing + /// the complete set of digits into a u32, then an error is returned. + fn parse_decimal(&self) -> Result<u32> { + let mut scratch = self.parser().scratch.borrow_mut(); + scratch.clear(); + + while !self.is_eof() && self.char().is_whitespace() { + self.bump(); + } + let start = self.pos(); + while !self.is_eof() && '0' <= self.char() && self.char() <= '9' { + scratch.push(self.char()); + self.bump_and_bump_space(); + } + let span = Span::new(start, self.pos()); + while !self.is_eof() && self.char().is_whitespace() { + self.bump_and_bump_space(); + } + let digits = scratch.as_str(); + if digits.is_empty() { + return Err(self.error(span, ast::ErrorKind::DecimalEmpty)); + } + match u32::from_str_radix(digits, 10).ok() { + Some(n) => Ok(n), + None => Err(self.error(span, ast::ErrorKind::DecimalInvalid)), + } + } + + /// Parse a standard character class consisting primarily of characters or + /// character ranges, but can also contain nested character classes of + /// any type (sans `.`). + /// + /// This assumes the parser is positioned at the opening `[`. If parsing + /// is successful, then the parser is advanced to the position immediately + /// following the closing `]`. + #[inline(never)] + fn parse_set_class(&self) -> Result<ast::Class> { + assert_eq!(self.char(), '['); + + let mut union = + ast::ClassSetUnion { span: self.span(), items: vec![] }; + loop { + self.bump_space(); + if self.is_eof() { + return Err(self.unclosed_class_error()); + } + match self.char() { + '[' => { + // If we've already parsed the opening bracket, then + // attempt to treat this as the beginning of an ASCII + // class. If ASCII class parsing fails, then the parser + // backs up to `[`. + if !self.parser().stack_class.borrow().is_empty() { + if let Some(cls) = self.maybe_parse_ascii_class() { + union.push(ast::ClassSetItem::Ascii(cls)); + continue; + } + } + union = self.push_class_open(union)?; + } + ']' => match self.pop_class(union)? { + Either::Left(nested_union) => { + union = nested_union; + } + Either::Right(class) => return Ok(class), + }, + '&' if self.peek() == Some('&') => { + assert!(self.bump_if("&&")); + union = self.push_class_op( + ast::ClassSetBinaryOpKind::Intersection, + union, + ); + } + '-' if self.peek() == Some('-') => { + assert!(self.bump_if("--")); + union = self.push_class_op( + ast::ClassSetBinaryOpKind::Difference, + union, + ); + } + '~' if self.peek() == Some('~') => { + assert!(self.bump_if("~~")); + union = self.push_class_op( + ast::ClassSetBinaryOpKind::SymmetricDifference, + union, + ); + } + _ => { + union.push(self.parse_set_class_range()?); + } + } + } + } + + /// Parse a single primitive item in a character class set. The item to + /// be parsed can either be one of a simple literal character, a range + /// between two simple literal characters or a "primitive" character + /// class like \w or \p{Greek}. + /// + /// If an invalid escape is found, or if a character class is found where + /// a simple literal is expected (e.g., in a range), then an error is + /// returned. + #[inline(never)] + fn parse_set_class_range(&self) -> Result<ast::ClassSetItem> { + let prim1 = self.parse_set_class_item()?; + self.bump_space(); + if self.is_eof() { + return Err(self.unclosed_class_error()); + } + // If the next char isn't a `-`, then we don't have a range. + // There are two exceptions. If the char after a `-` is a `]`, then + // `-` is interpreted as a literal `-`. Alternatively, if the char + // after a `-` is a `-`, then `--` corresponds to a "difference" + // operation. + if self.char() != '-' + || self.peek_space() == Some(']') + || self.peek_space() == Some('-') + { + return prim1.into_class_set_item(self); + } + // OK, now we're parsing a range, so bump past the `-` and parse the + // second half of the range. + if !self.bump_and_bump_space() { + return Err(self.unclosed_class_error()); + } + let prim2 = self.parse_set_class_item()?; + let range = ast::ClassSetRange { + span: Span::new(prim1.span().start, prim2.span().end), + start: prim1.into_class_literal(self)?, + end: prim2.into_class_literal(self)?, + }; + if !range.is_valid() { + return Err( + self.error(range.span, ast::ErrorKind::ClassRangeInvalid) + ); + } + Ok(ast::ClassSetItem::Range(range)) + } + + /// Parse a single item in a character class as a primitive, where the + /// primitive either consists of a verbatim literal or a single escape + /// sequence. + /// + /// This assumes the parser is positioned at the beginning of a primitive, + /// and advances the parser to the first position after the primitive if + /// successful. + /// + /// Note that it is the caller's responsibility to report an error if an + /// illegal primitive was parsed. + #[inline(never)] + fn parse_set_class_item(&self) -> Result<Primitive> { + if self.char() == '\\' { + self.parse_escape() + } else { + let x = Primitive::Literal(ast::Literal { + span: self.span_char(), + kind: ast::LiteralKind::Verbatim, + c: self.char(), + }); + self.bump(); + Ok(x) + } + } + + /// Parses the opening of a character class set. This includes the opening + /// bracket along with `^` if present to indicate negation. This also + /// starts parsing the opening set of unioned items if applicable, since + /// there are special rules applied to certain characters in the opening + /// of a character class. For example, `[^]]` is the class of all + /// characters not equal to `]`. (`]` would need to be escaped in any other + /// position.) Similarly for `-`. + /// + /// In all cases, the op inside the returned `ast::ClassBracketed` is an + /// empty union. This empty union should be replaced with the actual item + /// when it is popped from the parser's stack. + /// + /// This assumes the parser is positioned at the opening `[` and advances + /// the parser to the first non-special byte of the character class. + /// + /// An error is returned if EOF is found. + #[inline(never)] + fn parse_set_class_open( + &self, + ) -> Result<(ast::ClassBracketed, ast::ClassSetUnion)> { + assert_eq!(self.char(), '['); + let start = self.pos(); + if !self.bump_and_bump_space() { + return Err(self.error( + Span::new(start, self.pos()), + ast::ErrorKind::ClassUnclosed, + )); + } + + let negated = if self.char() != '^' { + false + } else { + if !self.bump_and_bump_space() { + return Err(self.error( + Span::new(start, self.pos()), + ast::ErrorKind::ClassUnclosed, + )); + } + true + }; + // Accept any number of `-` as literal `-`. + let mut union = + ast::ClassSetUnion { span: self.span(), items: vec![] }; + while self.char() == '-' { + union.push(ast::ClassSetItem::Literal(ast::Literal { + span: self.span_char(), + kind: ast::LiteralKind::Verbatim, + c: '-', + })); + if !self.bump_and_bump_space() { + return Err(self.error( + Span::new(start, self.pos()), + ast::ErrorKind::ClassUnclosed, + )); + } + } + // If `]` is the *first* char in a set, then interpret it as a literal + // `]`. That is, an empty class is impossible to write. + if union.items.is_empty() && self.char() == ']' { + union.push(ast::ClassSetItem::Literal(ast::Literal { + span: self.span_char(), + kind: ast::LiteralKind::Verbatim, + c: ']', + })); + if !self.bump_and_bump_space() { + return Err(self.error( + Span::new(start, self.pos()), + ast::ErrorKind::ClassUnclosed, + )); + } + } + let set = ast::ClassBracketed { + span: Span::new(start, self.pos()), + negated: negated, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: Span::new(union.span.start, union.span.start), + items: vec![], + }), + }; + Ok((set, union)) + } + + /// Attempt to parse an ASCII character class, e.g., `[:alnum:]`. + /// + /// This assumes the parser is positioned at the opening `[`. + /// + /// If no valid ASCII character class could be found, then this does not + /// advance the parser and `None` is returned. Otherwise, the parser is + /// advanced to the first byte following the closing `]` and the + /// corresponding ASCII class is returned. + #[inline(never)] + fn maybe_parse_ascii_class(&self) -> Option<ast::ClassAscii> { + // ASCII character classes are interesting from a parsing perspective + // because parsing cannot fail with any interesting error. For example, + // in order to use an ASCII character class, it must be enclosed in + // double brackets, e.g., `[[:alnum:]]`. Alternatively, you might think + // of it as "ASCII character characters have the syntax `[:NAME:]` + // which can only appear within character brackets." This means that + // things like `[[:lower:]A]` are legal constructs. + // + // However, if one types an incorrect ASCII character class, e.g., + // `[[:loower:]]`, then we treat that as a normal nested character + // class containing the characters `:elorw`. One might argue that we + // should return an error instead since the repeated colons give away + // the intent to write an ASCII class. But what if the user typed + // `[[:lower]]` instead? How can we tell that was intended to be an + // ASCII class and not just a normal nested class? + // + // Reasonable people can probably disagree over this, but for better + // or worse, we implement semantics that never fails at the expense + // of better failure modes. + assert_eq!(self.char(), '['); + // If parsing fails, then we back up the parser to this starting point. + let start = self.pos(); + let mut negated = false; + if !self.bump() || self.char() != ':' { + self.parser().pos.set(start); + return None; + } + if !self.bump() { + self.parser().pos.set(start); + return None; + } + if self.char() == '^' { + negated = true; + if !self.bump() { + self.parser().pos.set(start); + return None; + } + } + let name_start = self.offset(); + while self.char() != ':' && self.bump() {} + if self.is_eof() { + self.parser().pos.set(start); + return None; + } + let name = &self.pattern()[name_start..self.offset()]; + if !self.bump_if(":]") { + self.parser().pos.set(start); + return None; + } + let kind = match ast::ClassAsciiKind::from_name(name) { + Some(kind) => kind, + None => { + self.parser().pos.set(start); + return None; + } + }; + Some(ast::ClassAscii { + span: Span::new(start, self.pos()), + kind: kind, + negated: negated, + }) + } + + /// Parse a Unicode class in either the single character notation, `\pN` + /// or the multi-character bracketed notation, `\p{Greek}`. This assumes + /// the parser is positioned at the `p` (or `P` for negation) and will + /// advance the parser to the character immediately following the class. + /// + /// Note that this does not check whether the class name is valid or not. + #[inline(never)] + fn parse_unicode_class(&self) -> Result<ast::ClassUnicode> { + assert!(self.char() == 'p' || self.char() == 'P'); + + let mut scratch = self.parser().scratch.borrow_mut(); + scratch.clear(); + + let negated = self.char() == 'P'; + if !self.bump_and_bump_space() { + return Err( + self.error(self.span(), ast::ErrorKind::EscapeUnexpectedEof) + ); + } + let (start, kind) = if self.char() == '{' { + let start = self.span_char().end; + while self.bump_and_bump_space() && self.char() != '}' { + scratch.push(self.char()); + } + if self.is_eof() { + return Err(self + .error(self.span(), ast::ErrorKind::EscapeUnexpectedEof)); + } + assert_eq!(self.char(), '}'); + self.bump(); + + let name = scratch.as_str(); + if let Some(i) = name.find("!=") { + ( + start, + ast::ClassUnicodeKind::NamedValue { + op: ast::ClassUnicodeOpKind::NotEqual, + name: name[..i].to_string(), + value: name[i + 2..].to_string(), + }, + ) + } else if let Some(i) = name.find(':') { + ( + start, + ast::ClassUnicodeKind::NamedValue { + op: ast::ClassUnicodeOpKind::Colon, + name: name[..i].to_string(), + value: name[i + 1..].to_string(), + }, + ) + } else if let Some(i) = name.find('=') { + ( + start, + ast::ClassUnicodeKind::NamedValue { + op: ast::ClassUnicodeOpKind::Equal, + name: name[..i].to_string(), + value: name[i + 1..].to_string(), + }, + ) + } else { + (start, ast::ClassUnicodeKind::Named(name.to_string())) + } + } else { + let start = self.pos(); + let c = self.char(); + if c == '\\' { + return Err(self.error( + self.span_char(), + ast::ErrorKind::UnicodeClassInvalid, + )); + } + self.bump_and_bump_space(); + let kind = ast::ClassUnicodeKind::OneLetter(c); + (start, kind) + }; + Ok(ast::ClassUnicode { + span: Span::new(start, self.pos()), + negated: negated, + kind: kind, + }) + } + + /// Parse a Perl character class, e.g., `\d` or `\W`. This assumes the + /// parser is currently at a valid character class name and will be + /// advanced to the character immediately following the class. + #[inline(never)] + fn parse_perl_class(&self) -> ast::ClassPerl { + let c = self.char(); + let span = self.span_char(); + self.bump(); + let (negated, kind) = match c { + 'd' => (false, ast::ClassPerlKind::Digit), + 'D' => (true, ast::ClassPerlKind::Digit), + 's' => (false, ast::ClassPerlKind::Space), + 'S' => (true, ast::ClassPerlKind::Space), + 'w' => (false, ast::ClassPerlKind::Word), + 'W' => (true, ast::ClassPerlKind::Word), + c => panic!("expected valid Perl class but got '{}'", c), + }; + ast::ClassPerl { span: span, kind: kind, negated: negated } + } +} + +/// A type that traverses a fully parsed Ast and checks whether its depth +/// exceeds the specified nesting limit. If it does, then an error is returned. +#[derive(Debug)] +struct NestLimiter<'p, 's: 'p, P: 'p + 's> { + /// The parser that is checking the nest limit. + p: &'p ParserI<'s, P>, + /// The current depth while walking an Ast. + depth: u32, +} + +impl<'p, 's, P: Borrow<Parser>> NestLimiter<'p, 's, P> { + fn new(p: &'p ParserI<'s, P>) -> NestLimiter<'p, 's, P> { + NestLimiter { p: p, depth: 0 } + } + + #[inline(never)] + fn check(self, ast: &Ast) -> Result<()> { + ast::visit(ast, self) + } + + fn increment_depth(&mut self, span: &Span) -> Result<()> { + let new = self.depth.checked_add(1).ok_or_else(|| { + self.p.error( + span.clone(), + ast::ErrorKind::NestLimitExceeded(::std::u32::MAX), + ) + })?; + let limit = self.p.parser().nest_limit; + if new > limit { + return Err(self.p.error( + span.clone(), + ast::ErrorKind::NestLimitExceeded(limit), + )); + } + self.depth = new; + Ok(()) + } + + fn decrement_depth(&mut self) { + // Assuming the correctness of the visitor, this should never drop + // below 0. + self.depth = self.depth.checked_sub(1).unwrap(); + } +} + +impl<'p, 's, P: Borrow<Parser>> ast::Visitor for NestLimiter<'p, 's, P> { + type Output = (); + type Err = ast::Error; + + fn finish(self) -> Result<()> { + Ok(()) + } + + fn visit_pre(&mut self, ast: &Ast) -> Result<()> { + let span = match *ast { + Ast::Empty(_) + | Ast::Flags(_) + | Ast::Literal(_) + | Ast::Dot(_) + | Ast::Assertion(_) + | Ast::Class(ast::Class::Unicode(_)) + | Ast::Class(ast::Class::Perl(_)) => { + // These are all base cases, so we don't increment depth. + return Ok(()); + } + Ast::Class(ast::Class::Bracketed(ref x)) => &x.span, + Ast::Repetition(ref x) => &x.span, + Ast::Group(ref x) => &x.span, + Ast::Alternation(ref x) => &x.span, + Ast::Concat(ref x) => &x.span, + }; + self.increment_depth(span) + } + + fn visit_post(&mut self, ast: &Ast) -> Result<()> { + match *ast { + Ast::Empty(_) + | Ast::Flags(_) + | Ast::Literal(_) + | Ast::Dot(_) + | Ast::Assertion(_) + | Ast::Class(ast::Class::Unicode(_)) + | Ast::Class(ast::Class::Perl(_)) => { + // These are all base cases, so we don't decrement depth. + Ok(()) + } + Ast::Class(ast::Class::Bracketed(_)) + | Ast::Repetition(_) + | Ast::Group(_) + | Ast::Alternation(_) + | Ast::Concat(_) => { + self.decrement_depth(); + Ok(()) + } + } + } + + fn visit_class_set_item_pre( + &mut self, + ast: &ast::ClassSetItem, + ) -> Result<()> { + let span = match *ast { + ast::ClassSetItem::Empty(_) + | ast::ClassSetItem::Literal(_) + | ast::ClassSetItem::Range(_) + | ast::ClassSetItem::Ascii(_) + | ast::ClassSetItem::Unicode(_) + | ast::ClassSetItem::Perl(_) => { + // These are all base cases, so we don't increment depth. + return Ok(()); + } + ast::ClassSetItem::Bracketed(ref x) => &x.span, + ast::ClassSetItem::Union(ref x) => &x.span, + }; + self.increment_depth(span) + } + + fn visit_class_set_item_post( + &mut self, + ast: &ast::ClassSetItem, + ) -> Result<()> { + match *ast { + ast::ClassSetItem::Empty(_) + | ast::ClassSetItem::Literal(_) + | ast::ClassSetItem::Range(_) + | ast::ClassSetItem::Ascii(_) + | ast::ClassSetItem::Unicode(_) + | ast::ClassSetItem::Perl(_) => { + // These are all base cases, so we don't decrement depth. + Ok(()) + } + ast::ClassSetItem::Bracketed(_) | ast::ClassSetItem::Union(_) => { + self.decrement_depth(); + Ok(()) + } + } + } + + fn visit_class_set_binary_op_pre( + &mut self, + ast: &ast::ClassSetBinaryOp, + ) -> Result<()> { + self.increment_depth(&ast.span) + } + + fn visit_class_set_binary_op_post( + &mut self, + _ast: &ast::ClassSetBinaryOp, + ) -> Result<()> { + self.decrement_depth(); + Ok(()) + } +} + +/// When the result is an error, transforms the ast::ErrorKind from the source +/// Result into another one. This function is used to return clearer error +/// messages when possible. +fn specialize_err<T>( + result: Result<T>, + from: ast::ErrorKind, + to: ast::ErrorKind, +) -> Result<T> { + if let Err(e) = result { + if e.kind == from { + Err(ast::Error { kind: to, pattern: e.pattern, span: e.span }) + } else { + Err(e) + } + } else { + result + } +} + +#[cfg(test)] +mod tests { + use std::ops::Range; + + use super::{Parser, ParserBuilder, ParserI, Primitive}; + use ast::{self, Ast, Position, Span}; + + // Our own assert_eq, which has slightly better formatting (but honestly + // still kind of crappy). + macro_rules! assert_eq { + ($left:expr, $right:expr) => {{ + match (&$left, &$right) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + panic!( + "assertion failed: `(left == right)`\n\n\ + left: `{:?}`\nright: `{:?}`\n\n", + left_val, right_val + ) + } + } + } + }}; + } + + // We create these errors to compare with real ast::Errors in the tests. + // We define equality between TestError and ast::Error to disregard the + // pattern string in ast::Error, which is annoying to provide in tests. + #[derive(Clone, Debug)] + struct TestError { + span: Span, + kind: ast::ErrorKind, + } + + impl PartialEq<ast::Error> for TestError { + fn eq(&self, other: &ast::Error) -> bool { + self.span == other.span && self.kind == other.kind + } + } + + impl PartialEq<TestError> for ast::Error { + fn eq(&self, other: &TestError) -> bool { + self.span == other.span && self.kind == other.kind + } + } + + fn s(str: &str) -> String { + str.to_string() + } + + fn parser(pattern: &str) -> ParserI<Parser> { + ParserI::new(Parser::new(), pattern) + } + + fn parser_octal(pattern: &str) -> ParserI<Parser> { + let parser = ParserBuilder::new().octal(true).build(); + ParserI::new(parser, pattern) + } + + fn parser_nest_limit(pattern: &str, nest_limit: u32) -> ParserI<Parser> { + let p = ParserBuilder::new().nest_limit(nest_limit).build(); + ParserI::new(p, pattern) + } + + fn parser_ignore_whitespace(pattern: &str) -> ParserI<Parser> { + let p = ParserBuilder::new().ignore_whitespace(true).build(); + ParserI::new(p, pattern) + } + + /// Short alias for creating a new span. + fn nspan(start: Position, end: Position) -> Span { + Span::new(start, end) + } + + /// Short alias for creating a new position. + fn npos(offset: usize, line: usize, column: usize) -> Position { + Position::new(offset, line, column) + } + + /// Create a new span from the given offset range. This assumes a single + /// line and sets the columns based on the offsets. i.e., This only works + /// out of the box for ASCII, which is fine for most tests. + fn span(range: Range<usize>) -> Span { + let start = Position::new(range.start, 1, range.start + 1); + let end = Position::new(range.end, 1, range.end + 1); + Span::new(start, end) + } + + /// Create a new span for the corresponding byte range in the given string. + fn span_range(subject: &str, range: Range<usize>) -> Span { + let start = Position { + offset: range.start, + line: 1 + subject[..range.start].matches('\n').count(), + column: 1 + subject[..range.start] + .chars() + .rev() + .position(|c| c == '\n') + .unwrap_or(subject[..range.start].chars().count()), + }; + let end = Position { + offset: range.end, + line: 1 + subject[..range.end].matches('\n').count(), + column: 1 + subject[..range.end] + .chars() + .rev() + .position(|c| c == '\n') + .unwrap_or(subject[..range.end].chars().count()), + }; + Span::new(start, end) + } + + /// Create a verbatim literal starting at the given position. + fn lit(c: char, start: usize) -> Ast { + lit_with(c, span(start..start + c.len_utf8())) + } + + /// Create a punctuation literal starting at the given position. + fn punct_lit(c: char, span: Span) -> Ast { + Ast::Literal(ast::Literal { + span: span, + kind: ast::LiteralKind::Punctuation, + c: c, + }) + } + + /// Create a verbatim literal with the given span. + fn lit_with(c: char, span: Span) -> Ast { + Ast::Literal(ast::Literal { + span: span, + kind: ast::LiteralKind::Verbatim, + c: c, + }) + } + + /// Create a concatenation with the given range. + fn concat(range: Range<usize>, asts: Vec<Ast>) -> Ast { + concat_with(span(range), asts) + } + + /// Create a concatenation with the given span. + fn concat_with(span: Span, asts: Vec<Ast>) -> Ast { + Ast::Concat(ast::Concat { span: span, asts: asts }) + } + + /// Create an alternation with the given span. + fn alt(range: Range<usize>, asts: Vec<Ast>) -> Ast { + Ast::Alternation(ast::Alternation { span: span(range), asts: asts }) + } + + /// Create a capturing group with the given span. + fn group(range: Range<usize>, index: u32, ast: Ast) -> Ast { + Ast::Group(ast::Group { + span: span(range), + kind: ast::GroupKind::CaptureIndex(index), + ast: Box::new(ast), + }) + } + + /// Create an ast::SetFlags. + /// + /// The given pattern should be the full pattern string. The range given + /// should correspond to the byte offsets where the flag set occurs. + /// + /// If negated is true, then the set is interpreted as beginning with a + /// negation. + fn flag_set( + pat: &str, + range: Range<usize>, + flag: ast::Flag, + negated: bool, + ) -> Ast { + let mut items = vec![ast::FlagsItem { + span: span_range(pat, (range.end - 2)..(range.end - 1)), + kind: ast::FlagsItemKind::Flag(flag), + }]; + if negated { + items.insert( + 0, + ast::FlagsItem { + span: span_range(pat, (range.start + 2)..(range.end - 2)), + kind: ast::FlagsItemKind::Negation, + }, + ); + } + Ast::Flags(ast::SetFlags { + span: span_range(pat, range.clone()), + flags: ast::Flags { + span: span_range(pat, (range.start + 2)..(range.end - 1)), + items: items, + }, + }) + } + + #[test] + fn parse_nest_limit() { + // A nest limit of 0 still allows some types of regexes. + assert_eq!( + parser_nest_limit("", 0).parse(), + Ok(Ast::Empty(span(0..0))) + ); + assert_eq!(parser_nest_limit("a", 0).parse(), Ok(lit('a', 0))); + + // Test repetition operations, which require one level of nesting. + assert_eq!( + parser_nest_limit("a+", 0).parse().unwrap_err(), + TestError { + span: span(0..2), + kind: ast::ErrorKind::NestLimitExceeded(0), + } + ); + assert_eq!( + parser_nest_limit("a+", 1).parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..2), + op: ast::RepetitionOp { + span: span(1..2), + kind: ast::RepetitionKind::OneOrMore, + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser_nest_limit("(a)+", 1).parse().unwrap_err(), + TestError { + span: span(0..3), + kind: ast::ErrorKind::NestLimitExceeded(1), + } + ); + assert_eq!( + parser_nest_limit("a+*", 1).parse().unwrap_err(), + TestError { + span: span(0..2), + kind: ast::ErrorKind::NestLimitExceeded(1), + } + ); + assert_eq!( + parser_nest_limit("a+*", 2).parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..3), + op: ast::RepetitionOp { + span: span(2..3), + kind: ast::RepetitionKind::ZeroOrMore, + }, + greedy: true, + ast: Box::new(Ast::Repetition(ast::Repetition { + span: span(0..2), + op: ast::RepetitionOp { + span: span(1..2), + kind: ast::RepetitionKind::OneOrMore, + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })), + })) + ); + + // Test concatenations. A concatenation requires one level of nesting. + assert_eq!( + parser_nest_limit("ab", 0).parse().unwrap_err(), + TestError { + span: span(0..2), + kind: ast::ErrorKind::NestLimitExceeded(0), + } + ); + assert_eq!( + parser_nest_limit("ab", 1).parse(), + Ok(concat(0..2, vec![lit('a', 0), lit('b', 1)])) + ); + assert_eq!( + parser_nest_limit("abc", 1).parse(), + Ok(concat(0..3, vec![lit('a', 0), lit('b', 1), lit('c', 2)])) + ); + + // Test alternations. An alternation requires one level of nesting. + assert_eq!( + parser_nest_limit("a|b", 0).parse().unwrap_err(), + TestError { + span: span(0..3), + kind: ast::ErrorKind::NestLimitExceeded(0), + } + ); + assert_eq!( + parser_nest_limit("a|b", 1).parse(), + Ok(alt(0..3, vec![lit('a', 0), lit('b', 2)])) + ); + assert_eq!( + parser_nest_limit("a|b|c", 1).parse(), + Ok(alt(0..5, vec![lit('a', 0), lit('b', 2), lit('c', 4)])) + ); + + // Test character classes. Classes form their own mini-recursive + // syntax! + assert_eq!( + parser_nest_limit("[a]", 0).parse().unwrap_err(), + TestError { + span: span(0..3), + kind: ast::ErrorKind::NestLimitExceeded(0), + } + ); + assert_eq!( + parser_nest_limit("[a]", 1).parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..3), + negated: false, + kind: ast::ClassSet::Item(ast::ClassSetItem::Literal( + ast::Literal { + span: span(1..2), + kind: ast::LiteralKind::Verbatim, + c: 'a', + } + )), + }))) + ); + assert_eq!( + parser_nest_limit("[ab]", 1).parse().unwrap_err(), + TestError { + span: span(1..3), + kind: ast::ErrorKind::NestLimitExceeded(1), + } + ); + assert_eq!( + parser_nest_limit("[ab[cd]]", 2).parse().unwrap_err(), + TestError { + span: span(3..7), + kind: ast::ErrorKind::NestLimitExceeded(2), + } + ); + assert_eq!( + parser_nest_limit("[ab[cd]]", 3).parse().unwrap_err(), + TestError { + span: span(4..6), + kind: ast::ErrorKind::NestLimitExceeded(3), + } + ); + assert_eq!( + parser_nest_limit("[a--b]", 1).parse().unwrap_err(), + TestError { + span: span(1..5), + kind: ast::ErrorKind::NestLimitExceeded(1), + } + ); + assert_eq!( + parser_nest_limit("[a--bc]", 2).parse().unwrap_err(), + TestError { + span: span(4..6), + kind: ast::ErrorKind::NestLimitExceeded(2), + } + ); + } + + #[test] + fn parse_comments() { + let pat = "(?x) +# This is comment 1. +foo # This is comment 2. + # This is comment 3. +bar +# This is comment 4."; + let astc = parser(pat).parse_with_comments().unwrap(); + assert_eq!( + astc.ast, + concat_with( + span_range(pat, 0..pat.len()), + vec![ + flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false), + lit_with('f', span_range(pat, 26..27)), + lit_with('o', span_range(pat, 27..28)), + lit_with('o', span_range(pat, 28..29)), + lit_with('b', span_range(pat, 74..75)), + lit_with('a', span_range(pat, 75..76)), + lit_with('r', span_range(pat, 76..77)), + ] + ) + ); + assert_eq!( + astc.comments, + vec![ + ast::Comment { + span: span_range(pat, 5..26), + comment: s(" This is comment 1."), + }, + ast::Comment { + span: span_range(pat, 30..51), + comment: s(" This is comment 2."), + }, + ast::Comment { + span: span_range(pat, 53..74), + comment: s(" This is comment 3."), + }, + ast::Comment { + span: span_range(pat, 78..98), + comment: s(" This is comment 4."), + }, + ] + ); + } + + #[test] + fn parse_holistic() { + assert_eq!(parser("]").parse(), Ok(lit(']', 0))); + assert_eq!( + parser(r"\\\.\+\*\?\(\)\|\[\]\{\}\^\$\#\&\-\~").parse(), + Ok(concat( + 0..36, + vec![ + punct_lit('\\', span(0..2)), + punct_lit('.', span(2..4)), + punct_lit('+', span(4..6)), + punct_lit('*', span(6..8)), + punct_lit('?', span(8..10)), + punct_lit('(', span(10..12)), + punct_lit(')', span(12..14)), + punct_lit('|', span(14..16)), + punct_lit('[', span(16..18)), + punct_lit(']', span(18..20)), + punct_lit('{', span(20..22)), + punct_lit('}', span(22..24)), + punct_lit('^', span(24..26)), + punct_lit('$', span(26..28)), + punct_lit('#', span(28..30)), + punct_lit('&', span(30..32)), + punct_lit('-', span(32..34)), + punct_lit('~', span(34..36)), + ] + )) + ); + } + + #[test] + fn parse_ignore_whitespace() { + // Test that basic whitespace insensitivity works. + let pat = "(?x)a b"; + assert_eq!( + parser(pat).parse(), + Ok(concat_with( + nspan(npos(0, 1, 1), npos(7, 1, 8)), + vec![ + flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false), + lit_with('a', nspan(npos(4, 1, 5), npos(5, 1, 6))), + lit_with('b', nspan(npos(6, 1, 7), npos(7, 1, 8))), + ] + )) + ); + + // Test that we can toggle whitespace insensitivity. + let pat = "(?x)a b(?-x)a b"; + assert_eq!( + parser(pat).parse(), + Ok(concat_with( + nspan(npos(0, 1, 1), npos(15, 1, 16)), + vec![ + flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false), + lit_with('a', nspan(npos(4, 1, 5), npos(5, 1, 6))), + lit_with('b', nspan(npos(6, 1, 7), npos(7, 1, 8))), + flag_set(pat, 7..12, ast::Flag::IgnoreWhitespace, true), + lit_with('a', nspan(npos(12, 1, 13), npos(13, 1, 14))), + lit_with(' ', nspan(npos(13, 1, 14), npos(14, 1, 15))), + lit_with('b', nspan(npos(14, 1, 15), npos(15, 1, 16))), + ] + )) + ); + + // Test that nesting whitespace insensitive flags works. + let pat = "a (?x:a )a "; + assert_eq!( + parser(pat).parse(), + Ok(concat_with( + span_range(pat, 0..11), + vec![ + lit_with('a', span_range(pat, 0..1)), + lit_with(' ', span_range(pat, 1..2)), + Ast::Group(ast::Group { + span: span_range(pat, 2..9), + kind: ast::GroupKind::NonCapturing(ast::Flags { + span: span_range(pat, 4..5), + items: vec![ast::FlagsItem { + span: span_range(pat, 4..5), + kind: ast::FlagsItemKind::Flag( + ast::Flag::IgnoreWhitespace + ), + },], + }), + ast: Box::new(lit_with('a', span_range(pat, 6..7))), + }), + lit_with('a', span_range(pat, 9..10)), + lit_with(' ', span_range(pat, 10..11)), + ] + )) + ); + + // Test that whitespace after an opening paren is insignificant. + let pat = "(?x)( ?P<foo> a )"; + assert_eq!( + parser(pat).parse(), + Ok(concat_with( + span_range(pat, 0..pat.len()), + vec![ + flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false), + Ast::Group(ast::Group { + span: span_range(pat, 4..pat.len()), + kind: ast::GroupKind::CaptureName(ast::CaptureName { + span: span_range(pat, 9..12), + name: s("foo"), + index: 1, + }), + ast: Box::new(lit_with('a', span_range(pat, 14..15))), + }), + ] + )) + ); + let pat = "(?x)( a )"; + assert_eq!( + parser(pat).parse(), + Ok(concat_with( + span_range(pat, 0..pat.len()), + vec![ + flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false), + Ast::Group(ast::Group { + span: span_range(pat, 4..pat.len()), + kind: ast::GroupKind::CaptureIndex(1), + ast: Box::new(lit_with('a', span_range(pat, 7..8))), + }), + ] + )) + ); + let pat = "(?x)( ?: a )"; + assert_eq!( + parser(pat).parse(), + Ok(concat_with( + span_range(pat, 0..pat.len()), + vec![ + flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false), + Ast::Group(ast::Group { + span: span_range(pat, 4..pat.len()), + kind: ast::GroupKind::NonCapturing(ast::Flags { + span: span_range(pat, 8..8), + items: vec![], + }), + ast: Box::new(lit_with('a', span_range(pat, 11..12))), + }), + ] + )) + ); + let pat = r"(?x)\x { 53 }"; + assert_eq!( + parser(pat).parse(), + Ok(concat_with( + span_range(pat, 0..pat.len()), + vec![ + flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false), + Ast::Literal(ast::Literal { + span: span(4..13), + kind: ast::LiteralKind::HexBrace( + ast::HexLiteralKind::X + ), + c: 'S', + }), + ] + )) + ); + + // Test that whitespace after an escape is OK. + let pat = r"(?x)\ "; + assert_eq!( + parser(pat).parse(), + Ok(concat_with( + span_range(pat, 0..pat.len()), + vec![ + flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false), + Ast::Literal(ast::Literal { + span: span_range(pat, 4..6), + kind: ast::LiteralKind::Special( + ast::SpecialLiteralKind::Space + ), + c: ' ', + }), + ] + )) + ); + // ... but only when `x` mode is enabled. + let pat = r"\ "; + assert_eq!( + parser(pat).parse().unwrap_err(), + TestError { + span: span_range(pat, 0..2), + kind: ast::ErrorKind::EscapeUnrecognized, + } + ); + } + + #[test] + fn parse_newlines() { + let pat = ".\n."; + assert_eq!( + parser(pat).parse(), + Ok(concat_with( + span_range(pat, 0..3), + vec![ + Ast::Dot(span_range(pat, 0..1)), + lit_with('\n', span_range(pat, 1..2)), + Ast::Dot(span_range(pat, 2..3)), + ] + )) + ); + + let pat = "foobar\nbaz\nquux\n"; + assert_eq!( + parser(pat).parse(), + Ok(concat_with( + span_range(pat, 0..pat.len()), + vec![ + lit_with('f', nspan(npos(0, 1, 1), npos(1, 1, 2))), + lit_with('o', nspan(npos(1, 1, 2), npos(2, 1, 3))), + lit_with('o', nspan(npos(2, 1, 3), npos(3, 1, 4))), + lit_with('b', nspan(npos(3, 1, 4), npos(4, 1, 5))), + lit_with('a', nspan(npos(4, 1, 5), npos(5, 1, 6))), + lit_with('r', nspan(npos(5, 1, 6), npos(6, 1, 7))), + lit_with('\n', nspan(npos(6, 1, 7), npos(7, 2, 1))), + lit_with('b', nspan(npos(7, 2, 1), npos(8, 2, 2))), + lit_with('a', nspan(npos(8, 2, 2), npos(9, 2, 3))), + lit_with('z', nspan(npos(9, 2, 3), npos(10, 2, 4))), + lit_with('\n', nspan(npos(10, 2, 4), npos(11, 3, 1))), + lit_with('q', nspan(npos(11, 3, 1), npos(12, 3, 2))), + lit_with('u', nspan(npos(12, 3, 2), npos(13, 3, 3))), + lit_with('u', nspan(npos(13, 3, 3), npos(14, 3, 4))), + lit_with('x', nspan(npos(14, 3, 4), npos(15, 3, 5))), + lit_with('\n', nspan(npos(15, 3, 5), npos(16, 4, 1))), + ] + )) + ); + } + + #[test] + fn parse_uncounted_repetition() { + assert_eq!( + parser(r"a*").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..2), + op: ast::RepetitionOp { + span: span(1..2), + kind: ast::RepetitionKind::ZeroOrMore, + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser(r"a+").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..2), + op: ast::RepetitionOp { + span: span(1..2), + kind: ast::RepetitionKind::OneOrMore, + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })) + ); + + assert_eq!( + parser(r"a?").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..2), + op: ast::RepetitionOp { + span: span(1..2), + kind: ast::RepetitionKind::ZeroOrOne, + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser(r"a??").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..3), + op: ast::RepetitionOp { + span: span(1..3), + kind: ast::RepetitionKind::ZeroOrOne, + }, + greedy: false, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser(r"a?").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..2), + op: ast::RepetitionOp { + span: span(1..2), + kind: ast::RepetitionKind::ZeroOrOne, + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser(r"a?b").parse(), + Ok(concat( + 0..3, + vec![ + Ast::Repetition(ast::Repetition { + span: span(0..2), + op: ast::RepetitionOp { + span: span(1..2), + kind: ast::RepetitionKind::ZeroOrOne, + }, + greedy: true, + ast: Box::new(lit('a', 0)), + }), + lit('b', 2), + ] + )) + ); + assert_eq!( + parser(r"a??b").parse(), + Ok(concat( + 0..4, + vec![ + Ast::Repetition(ast::Repetition { + span: span(0..3), + op: ast::RepetitionOp { + span: span(1..3), + kind: ast::RepetitionKind::ZeroOrOne, + }, + greedy: false, + ast: Box::new(lit('a', 0)), + }), + lit('b', 3), + ] + )) + ); + assert_eq!( + parser(r"ab?").parse(), + Ok(concat( + 0..3, + vec![ + lit('a', 0), + Ast::Repetition(ast::Repetition { + span: span(1..3), + op: ast::RepetitionOp { + span: span(2..3), + kind: ast::RepetitionKind::ZeroOrOne, + }, + greedy: true, + ast: Box::new(lit('b', 1)), + }), + ] + )) + ); + assert_eq!( + parser(r"(ab)?").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..5), + op: ast::RepetitionOp { + span: span(4..5), + kind: ast::RepetitionKind::ZeroOrOne, + }, + greedy: true, + ast: Box::new(group( + 0..4, + 1, + concat(1..3, vec![lit('a', 1), lit('b', 2),]) + )), + })) + ); + assert_eq!( + parser(r"|a?").parse(), + Ok(alt( + 0..3, + vec![ + Ast::Empty(span(0..0)), + Ast::Repetition(ast::Repetition { + span: span(1..3), + op: ast::RepetitionOp { + span: span(2..3), + kind: ast::RepetitionKind::ZeroOrOne, + }, + greedy: true, + ast: Box::new(lit('a', 1)), + }), + ] + )) + ); + + assert_eq!( + parser(r"*").parse().unwrap_err(), + TestError { + span: span(0..0), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"(?i)*").parse().unwrap_err(), + TestError { + span: span(4..4), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"(*)").parse().unwrap_err(), + TestError { + span: span(1..1), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"(?:?)").parse().unwrap_err(), + TestError { + span: span(3..3), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"+").parse().unwrap_err(), + TestError { + span: span(0..0), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"?").parse().unwrap_err(), + TestError { + span: span(0..0), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"(?)").parse().unwrap_err(), + TestError { + span: span(1..1), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"|*").parse().unwrap_err(), + TestError { + span: span(1..1), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"|+").parse().unwrap_err(), + TestError { + span: span(1..1), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"|?").parse().unwrap_err(), + TestError { + span: span(1..1), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + } + + #[test] + fn parse_counted_repetition() { + assert_eq!( + parser(r"a{5}").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..4), + op: ast::RepetitionOp { + span: span(1..4), + kind: ast::RepetitionKind::Range( + ast::RepetitionRange::Exactly(5) + ), + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser(r"a{5,}").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..5), + op: ast::RepetitionOp { + span: span(1..5), + kind: ast::RepetitionKind::Range( + ast::RepetitionRange::AtLeast(5) + ), + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser(r"a{5,9}").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..6), + op: ast::RepetitionOp { + span: span(1..6), + kind: ast::RepetitionKind::Range( + ast::RepetitionRange::Bounded(5, 9) + ), + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser(r"a{5}?").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..5), + op: ast::RepetitionOp { + span: span(1..5), + kind: ast::RepetitionKind::Range( + ast::RepetitionRange::Exactly(5) + ), + }, + greedy: false, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser(r"ab{5}").parse(), + Ok(concat( + 0..5, + vec![ + lit('a', 0), + Ast::Repetition(ast::Repetition { + span: span(1..5), + op: ast::RepetitionOp { + span: span(2..5), + kind: ast::RepetitionKind::Range( + ast::RepetitionRange::Exactly(5) + ), + }, + greedy: true, + ast: Box::new(lit('b', 1)), + }), + ] + )) + ); + assert_eq!( + parser(r"ab{5}c").parse(), + Ok(concat( + 0..6, + vec![ + lit('a', 0), + Ast::Repetition(ast::Repetition { + span: span(1..5), + op: ast::RepetitionOp { + span: span(2..5), + kind: ast::RepetitionKind::Range( + ast::RepetitionRange::Exactly(5) + ), + }, + greedy: true, + ast: Box::new(lit('b', 1)), + }), + lit('c', 5), + ] + )) + ); + + assert_eq!( + parser(r"a{ 5 }").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..6), + op: ast::RepetitionOp { + span: span(1..6), + kind: ast::RepetitionKind::Range( + ast::RepetitionRange::Exactly(5) + ), + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser(r"a{ 5 , 9 }").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..10), + op: ast::RepetitionOp { + span: span(1..10), + kind: ast::RepetitionKind::Range( + ast::RepetitionRange::Bounded(5, 9) + ), + }, + greedy: true, + ast: Box::new(lit('a', 0)), + })) + ); + assert_eq!( + parser_ignore_whitespace(r"a{5,9} ?").parse(), + Ok(Ast::Repetition(ast::Repetition { + span: span(0..8), + op: ast::RepetitionOp { + span: span(1..8), + kind: ast::RepetitionKind::Range( + ast::RepetitionRange::Bounded(5, 9) + ), + }, + greedy: false, + ast: Box::new(lit('a', 0)), + })) + ); + + assert_eq!( + parser(r"(?i){0}").parse().unwrap_err(), + TestError { + span: span(4..4), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"(?m){1,1}").parse().unwrap_err(), + TestError { + span: span(4..4), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"a{]}").parse().unwrap_err(), + TestError { + span: span(2..2), + kind: ast::ErrorKind::RepetitionCountDecimalEmpty, + } + ); + assert_eq!( + parser(r"a{1,]}").parse().unwrap_err(), + TestError { + span: span(4..4), + kind: ast::ErrorKind::RepetitionCountDecimalEmpty, + } + ); + assert_eq!( + parser(r"a{").parse().unwrap_err(), + TestError { + span: span(1..2), + kind: ast::ErrorKind::RepetitionCountUnclosed, + } + ); + assert_eq!( + parser(r"a{}").parse().unwrap_err(), + TestError { + span: span(2..2), + kind: ast::ErrorKind::RepetitionCountDecimalEmpty, + } + ); + assert_eq!( + parser(r"a{a").parse().unwrap_err(), + TestError { + span: span(2..2), + kind: ast::ErrorKind::RepetitionCountDecimalEmpty, + } + ); + assert_eq!( + parser(r"a{9999999999}").parse().unwrap_err(), + TestError { + span: span(2..12), + kind: ast::ErrorKind::DecimalInvalid, + } + ); + assert_eq!( + parser(r"a{9").parse().unwrap_err(), + TestError { + span: span(1..3), + kind: ast::ErrorKind::RepetitionCountUnclosed, + } + ); + assert_eq!( + parser(r"a{9,a").parse().unwrap_err(), + TestError { + span: span(4..4), + kind: ast::ErrorKind::RepetitionCountDecimalEmpty, + } + ); + assert_eq!( + parser(r"a{9,9999999999}").parse().unwrap_err(), + TestError { + span: span(4..14), + kind: ast::ErrorKind::DecimalInvalid, + } + ); + assert_eq!( + parser(r"a{9,").parse().unwrap_err(), + TestError { + span: span(1..4), + kind: ast::ErrorKind::RepetitionCountUnclosed, + } + ); + assert_eq!( + parser(r"a{9,11").parse().unwrap_err(), + TestError { + span: span(1..6), + kind: ast::ErrorKind::RepetitionCountUnclosed, + } + ); + assert_eq!( + parser(r"a{2,1}").parse().unwrap_err(), + TestError { + span: span(1..6), + kind: ast::ErrorKind::RepetitionCountInvalid, + } + ); + assert_eq!( + parser(r"{5}").parse().unwrap_err(), + TestError { + span: span(0..0), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + assert_eq!( + parser(r"|{5}").parse().unwrap_err(), + TestError { + span: span(1..1), + kind: ast::ErrorKind::RepetitionMissing, + } + ); + } + + #[test] + fn parse_alternate() { + assert_eq!( + parser(r"a|b").parse(), + Ok(Ast::Alternation(ast::Alternation { + span: span(0..3), + asts: vec![lit('a', 0), lit('b', 2)], + })) + ); + assert_eq!( + parser(r"(a|b)").parse(), + Ok(group( + 0..5, + 1, + Ast::Alternation(ast::Alternation { + span: span(1..4), + asts: vec![lit('a', 1), lit('b', 3)], + }) + )) + ); + + assert_eq!( + parser(r"a|b|c").parse(), + Ok(Ast::Alternation(ast::Alternation { + span: span(0..5), + asts: vec![lit('a', 0), lit('b', 2), lit('c', 4)], + })) + ); + assert_eq!( + parser(r"ax|by|cz").parse(), + Ok(Ast::Alternation(ast::Alternation { + span: span(0..8), + asts: vec![ + concat(0..2, vec![lit('a', 0), lit('x', 1)]), + concat(3..5, vec![lit('b', 3), lit('y', 4)]), + concat(6..8, vec![lit('c', 6), lit('z', 7)]), + ], + })) + ); + assert_eq!( + parser(r"(ax|by|cz)").parse(), + Ok(group( + 0..10, + 1, + Ast::Alternation(ast::Alternation { + span: span(1..9), + asts: vec![ + concat(1..3, vec![lit('a', 1), lit('x', 2)]), + concat(4..6, vec![lit('b', 4), lit('y', 5)]), + concat(7..9, vec![lit('c', 7), lit('z', 8)]), + ], + }) + )) + ); + assert_eq!( + parser(r"(ax|(by|(cz)))").parse(), + Ok(group( + 0..14, + 1, + alt( + 1..13, + vec![ + concat(1..3, vec![lit('a', 1), lit('x', 2)]), + group( + 4..13, + 2, + alt( + 5..12, + vec![ + concat( + 5..7, + vec![lit('b', 5), lit('y', 6)] + ), + group( + 8..12, + 3, + concat( + 9..11, + vec![lit('c', 9), lit('z', 10),] + ) + ), + ] + ) + ), + ] + ) + )) + ); + + assert_eq!( + parser(r"|").parse(), + Ok(alt( + 0..1, + vec![Ast::Empty(span(0..0)), Ast::Empty(span(1..1)),] + )) + ); + assert_eq!( + parser(r"||").parse(), + Ok(alt( + 0..2, + vec![ + Ast::Empty(span(0..0)), + Ast::Empty(span(1..1)), + Ast::Empty(span(2..2)), + ] + )) + ); + assert_eq!( + parser(r"a|").parse(), + Ok(alt(0..2, vec![lit('a', 0), Ast::Empty(span(2..2)),])) + ); + assert_eq!( + parser(r"|a").parse(), + Ok(alt(0..2, vec![Ast::Empty(span(0..0)), lit('a', 1),])) + ); + + assert_eq!( + parser(r"(|)").parse(), + Ok(group( + 0..3, + 1, + alt( + 1..2, + vec![Ast::Empty(span(1..1)), Ast::Empty(span(2..2)),] + ) + )) + ); + assert_eq!( + parser(r"(a|)").parse(), + Ok(group( + 0..4, + 1, + alt(1..3, vec![lit('a', 1), Ast::Empty(span(3..3)),]) + )) + ); + assert_eq!( + parser(r"(|a)").parse(), + Ok(group( + 0..4, + 1, + alt(1..3, vec![Ast::Empty(span(1..1)), lit('a', 2),]) + )) + ); + + assert_eq!( + parser(r"a|b)").parse().unwrap_err(), + TestError { + span: span(3..4), + kind: ast::ErrorKind::GroupUnopened, + } + ); + assert_eq!( + parser(r"(a|b").parse().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::GroupUnclosed, + } + ); + } + + #[test] + fn parse_unsupported_lookaround() { + assert_eq!( + parser(r"(?=a)").parse().unwrap_err(), + TestError { + span: span(0..3), + kind: ast::ErrorKind::UnsupportedLookAround, + } + ); + assert_eq!( + parser(r"(?!a)").parse().unwrap_err(), + TestError { + span: span(0..3), + kind: ast::ErrorKind::UnsupportedLookAround, + } + ); + assert_eq!( + parser(r"(?<=a)").parse().unwrap_err(), + TestError { + span: span(0..4), + kind: ast::ErrorKind::UnsupportedLookAround, + } + ); + assert_eq!( + parser(r"(?<!a)").parse().unwrap_err(), + TestError { + span: span(0..4), + kind: ast::ErrorKind::UnsupportedLookAround, + } + ); + } + + #[test] + fn parse_group() { + assert_eq!( + parser("(?i)").parse(), + Ok(Ast::Flags(ast::SetFlags { + span: span(0..4), + flags: ast::Flags { + span: span(2..3), + items: vec![ast::FlagsItem { + span: span(2..3), + kind: ast::FlagsItemKind::Flag( + ast::Flag::CaseInsensitive + ), + }], + }, + })) + ); + assert_eq!( + parser("(?iU)").parse(), + Ok(Ast::Flags(ast::SetFlags { + span: span(0..5), + flags: ast::Flags { + span: span(2..4), + items: vec![ + ast::FlagsItem { + span: span(2..3), + kind: ast::FlagsItemKind::Flag( + ast::Flag::CaseInsensitive + ), + }, + ast::FlagsItem { + span: span(3..4), + kind: ast::FlagsItemKind::Flag( + ast::Flag::SwapGreed + ), + }, + ], + }, + })) + ); + assert_eq!( + parser("(?i-U)").parse(), + Ok(Ast::Flags(ast::SetFlags { + span: span(0..6), + flags: ast::Flags { + span: span(2..5), + items: vec![ + ast::FlagsItem { + span: span(2..3), + kind: ast::FlagsItemKind::Flag( + ast::Flag::CaseInsensitive + ), + }, + ast::FlagsItem { + span: span(3..4), + kind: ast::FlagsItemKind::Negation, + }, + ast::FlagsItem { + span: span(4..5), + kind: ast::FlagsItemKind::Flag( + ast::Flag::SwapGreed + ), + }, + ], + }, + })) + ); + + assert_eq!( + parser("()").parse(), + Ok(Ast::Group(ast::Group { + span: span(0..2), + kind: ast::GroupKind::CaptureIndex(1), + ast: Box::new(Ast::Empty(span(1..1))), + })) + ); + assert_eq!( + parser("(a)").parse(), + Ok(Ast::Group(ast::Group { + span: span(0..3), + kind: ast::GroupKind::CaptureIndex(1), + ast: Box::new(lit('a', 1)), + })) + ); + assert_eq!( + parser("(())").parse(), + Ok(Ast::Group(ast::Group { + span: span(0..4), + kind: ast::GroupKind::CaptureIndex(1), + ast: Box::new(Ast::Group(ast::Group { + span: span(1..3), + kind: ast::GroupKind::CaptureIndex(2), + ast: Box::new(Ast::Empty(span(2..2))), + })), + })) + ); + + assert_eq!( + parser("(?:a)").parse(), + Ok(Ast::Group(ast::Group { + span: span(0..5), + kind: ast::GroupKind::NonCapturing(ast::Flags { + span: span(2..2), + items: vec![], + }), + ast: Box::new(lit('a', 3)), + })) + ); + + assert_eq!( + parser("(?i:a)").parse(), + Ok(Ast::Group(ast::Group { + span: span(0..6), + kind: ast::GroupKind::NonCapturing(ast::Flags { + span: span(2..3), + items: vec![ast::FlagsItem { + span: span(2..3), + kind: ast::FlagsItemKind::Flag( + ast::Flag::CaseInsensitive + ), + },], + }), + ast: Box::new(lit('a', 4)), + })) + ); + assert_eq!( + parser("(?i-U:a)").parse(), + Ok(Ast::Group(ast::Group { + span: span(0..8), + kind: ast::GroupKind::NonCapturing(ast::Flags { + span: span(2..5), + items: vec![ + ast::FlagsItem { + span: span(2..3), + kind: ast::FlagsItemKind::Flag( + ast::Flag::CaseInsensitive + ), + }, + ast::FlagsItem { + span: span(3..4), + kind: ast::FlagsItemKind::Negation, + }, + ast::FlagsItem { + span: span(4..5), + kind: ast::FlagsItemKind::Flag( + ast::Flag::SwapGreed + ), + }, + ], + }), + ast: Box::new(lit('a', 6)), + })) + ); + + assert_eq!( + parser("(").parse().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::GroupUnclosed, + } + ); + assert_eq!( + parser("(?").parse().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::GroupUnclosed, + } + ); + assert_eq!( + parser("(?P").parse().unwrap_err(), + TestError { + span: span(2..3), + kind: ast::ErrorKind::FlagUnrecognized, + } + ); + assert_eq!( + parser("(?P<").parse().unwrap_err(), + TestError { + span: span(4..4), + kind: ast::ErrorKind::GroupNameUnexpectedEof, + } + ); + assert_eq!( + parser("(a").parse().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::GroupUnclosed, + } + ); + assert_eq!( + parser("(()").parse().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::GroupUnclosed, + } + ); + assert_eq!( + parser(")").parse().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::GroupUnopened, + } + ); + assert_eq!( + parser("a)").parse().unwrap_err(), + TestError { + span: span(1..2), + kind: ast::ErrorKind::GroupUnopened, + } + ); + } + + #[test] + fn parse_capture_name() { + assert_eq!( + parser("(?P<a>z)").parse(), + Ok(Ast::Group(ast::Group { + span: span(0..8), + kind: ast::GroupKind::CaptureName(ast::CaptureName { + span: span(4..5), + name: s("a"), + index: 1, + }), + ast: Box::new(lit('z', 6)), + })) + ); + assert_eq!( + parser("(?P<abc>z)").parse(), + Ok(Ast::Group(ast::Group { + span: span(0..10), + kind: ast::GroupKind::CaptureName(ast::CaptureName { + span: span(4..7), + name: s("abc"), + index: 1, + }), + ast: Box::new(lit('z', 8)), + })) + ); + + assert_eq!( + parser("(?P<").parse().unwrap_err(), + TestError { + span: span(4..4), + kind: ast::ErrorKind::GroupNameUnexpectedEof, + } + ); + assert_eq!( + parser("(?P<>z)").parse().unwrap_err(), + TestError { + span: span(4..4), + kind: ast::ErrorKind::GroupNameEmpty, + } + ); + assert_eq!( + parser("(?P<a").parse().unwrap_err(), + TestError { + span: span(5..5), + kind: ast::ErrorKind::GroupNameUnexpectedEof, + } + ); + assert_eq!( + parser("(?P<ab").parse().unwrap_err(), + TestError { + span: span(6..6), + kind: ast::ErrorKind::GroupNameUnexpectedEof, + } + ); + assert_eq!( + parser("(?P<0a").parse().unwrap_err(), + TestError { + span: span(4..5), + kind: ast::ErrorKind::GroupNameInvalid, + } + ); + assert_eq!( + parser("(?P<~").parse().unwrap_err(), + TestError { + span: span(4..5), + kind: ast::ErrorKind::GroupNameInvalid, + } + ); + assert_eq!( + parser("(?P<abc~").parse().unwrap_err(), + TestError { + span: span(7..8), + kind: ast::ErrorKind::GroupNameInvalid, + } + ); + assert_eq!( + parser("(?P<a>y)(?P<a>z)").parse().unwrap_err(), + TestError { + span: span(12..13), + kind: ast::ErrorKind::GroupNameDuplicate { + original: span(4..5), + }, + } + ); + } + + #[test] + fn parse_flags() { + assert_eq!( + parser("i:").parse_flags(), + Ok(ast::Flags { + span: span(0..1), + items: vec![ast::FlagsItem { + span: span(0..1), + kind: ast::FlagsItemKind::Flag(ast::Flag::CaseInsensitive), + }], + }) + ); + assert_eq!( + parser("i)").parse_flags(), + Ok(ast::Flags { + span: span(0..1), + items: vec![ast::FlagsItem { + span: span(0..1), + kind: ast::FlagsItemKind::Flag(ast::Flag::CaseInsensitive), + }], + }) + ); + + assert_eq!( + parser("isU:").parse_flags(), + Ok(ast::Flags { + span: span(0..3), + items: vec![ + ast::FlagsItem { + span: span(0..1), + kind: ast::FlagsItemKind::Flag( + ast::Flag::CaseInsensitive + ), + }, + ast::FlagsItem { + span: span(1..2), + kind: ast::FlagsItemKind::Flag( + ast::Flag::DotMatchesNewLine + ), + }, + ast::FlagsItem { + span: span(2..3), + kind: ast::FlagsItemKind::Flag(ast::Flag::SwapGreed), + }, + ], + }) + ); + + assert_eq!( + parser("-isU:").parse_flags(), + Ok(ast::Flags { + span: span(0..4), + items: vec![ + ast::FlagsItem { + span: span(0..1), + kind: ast::FlagsItemKind::Negation, + }, + ast::FlagsItem { + span: span(1..2), + kind: ast::FlagsItemKind::Flag( + ast::Flag::CaseInsensitive + ), + }, + ast::FlagsItem { + span: span(2..3), + kind: ast::FlagsItemKind::Flag( + ast::Flag::DotMatchesNewLine + ), + }, + ast::FlagsItem { + span: span(3..4), + kind: ast::FlagsItemKind::Flag(ast::Flag::SwapGreed), + }, + ], + }) + ); + assert_eq!( + parser("i-sU:").parse_flags(), + Ok(ast::Flags { + span: span(0..4), + items: vec![ + ast::FlagsItem { + span: span(0..1), + kind: ast::FlagsItemKind::Flag( + ast::Flag::CaseInsensitive + ), + }, + ast::FlagsItem { + span: span(1..2), + kind: ast::FlagsItemKind::Negation, + }, + ast::FlagsItem { + span: span(2..3), + kind: ast::FlagsItemKind::Flag( + ast::Flag::DotMatchesNewLine + ), + }, + ast::FlagsItem { + span: span(3..4), + kind: ast::FlagsItemKind::Flag(ast::Flag::SwapGreed), + }, + ], + }) + ); + + assert_eq!( + parser("isU").parse_flags().unwrap_err(), + TestError { + span: span(3..3), + kind: ast::ErrorKind::FlagUnexpectedEof, + } + ); + assert_eq!( + parser("isUa:").parse_flags().unwrap_err(), + TestError { + span: span(3..4), + kind: ast::ErrorKind::FlagUnrecognized, + } + ); + assert_eq!( + parser("isUi:").parse_flags().unwrap_err(), + TestError { + span: span(3..4), + kind: ast::ErrorKind::FlagDuplicate { original: span(0..1) }, + } + ); + assert_eq!( + parser("i-sU-i:").parse_flags().unwrap_err(), + TestError { + span: span(4..5), + kind: ast::ErrorKind::FlagRepeatedNegation { + original: span(1..2), + }, + } + ); + assert_eq!( + parser("-)").parse_flags().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::FlagDanglingNegation, + } + ); + assert_eq!( + parser("i-)").parse_flags().unwrap_err(), + TestError { + span: span(1..2), + kind: ast::ErrorKind::FlagDanglingNegation, + } + ); + assert_eq!( + parser("iU-)").parse_flags().unwrap_err(), + TestError { + span: span(2..3), + kind: ast::ErrorKind::FlagDanglingNegation, + } + ); + } + + #[test] + fn parse_flag() { + assert_eq!(parser("i").parse_flag(), Ok(ast::Flag::CaseInsensitive)); + assert_eq!(parser("m").parse_flag(), Ok(ast::Flag::MultiLine)); + assert_eq!(parser("s").parse_flag(), Ok(ast::Flag::DotMatchesNewLine)); + assert_eq!(parser("U").parse_flag(), Ok(ast::Flag::SwapGreed)); + assert_eq!(parser("u").parse_flag(), Ok(ast::Flag::Unicode)); + assert_eq!(parser("x").parse_flag(), Ok(ast::Flag::IgnoreWhitespace)); + + assert_eq!( + parser("a").parse_flag().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::FlagUnrecognized, + } + ); + assert_eq!( + parser("☃").parse_flag().unwrap_err(), + TestError { + span: span_range("☃", 0..3), + kind: ast::ErrorKind::FlagUnrecognized, + } + ); + } + + #[test] + fn parse_primitive_non_escape() { + assert_eq!( + parser(r".").parse_primitive(), + Ok(Primitive::Dot(span(0..1))) + ); + assert_eq!( + parser(r"^").parse_primitive(), + Ok(Primitive::Assertion(ast::Assertion { + span: span(0..1), + kind: ast::AssertionKind::StartLine, + })) + ); + assert_eq!( + parser(r"$").parse_primitive(), + Ok(Primitive::Assertion(ast::Assertion { + span: span(0..1), + kind: ast::AssertionKind::EndLine, + })) + ); + + assert_eq!( + parser(r"a").parse_primitive(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..1), + kind: ast::LiteralKind::Verbatim, + c: 'a', + })) + ); + assert_eq!( + parser(r"|").parse_primitive(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..1), + kind: ast::LiteralKind::Verbatim, + c: '|', + })) + ); + assert_eq!( + parser(r"☃").parse_primitive(), + Ok(Primitive::Literal(ast::Literal { + span: span_range("☃", 0..3), + kind: ast::LiteralKind::Verbatim, + c: '☃', + })) + ); + } + + #[test] + fn parse_escape() { + assert_eq!( + parser(r"\|").parse_primitive(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..2), + kind: ast::LiteralKind::Punctuation, + c: '|', + })) + ); + let specials = &[ + (r"\a", '\x07', ast::SpecialLiteralKind::Bell), + (r"\f", '\x0C', ast::SpecialLiteralKind::FormFeed), + (r"\t", '\t', ast::SpecialLiteralKind::Tab), + (r"\n", '\n', ast::SpecialLiteralKind::LineFeed), + (r"\r", '\r', ast::SpecialLiteralKind::CarriageReturn), + (r"\v", '\x0B', ast::SpecialLiteralKind::VerticalTab), + ]; + for &(pat, c, ref kind) in specials { + assert_eq!( + parser(pat).parse_primitive(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..2), + kind: ast::LiteralKind::Special(kind.clone()), + c: c, + })) + ); + } + assert_eq!( + parser(r"\A").parse_primitive(), + Ok(Primitive::Assertion(ast::Assertion { + span: span(0..2), + kind: ast::AssertionKind::StartText, + })) + ); + assert_eq!( + parser(r"\z").parse_primitive(), + Ok(Primitive::Assertion(ast::Assertion { + span: span(0..2), + kind: ast::AssertionKind::EndText, + })) + ); + assert_eq!( + parser(r"\b").parse_primitive(), + Ok(Primitive::Assertion(ast::Assertion { + span: span(0..2), + kind: ast::AssertionKind::WordBoundary, + })) + ); + assert_eq!( + parser(r"\B").parse_primitive(), + Ok(Primitive::Assertion(ast::Assertion { + span: span(0..2), + kind: ast::AssertionKind::NotWordBoundary, + })) + ); + + assert_eq!( + parser(r"\").parse_escape().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + assert_eq!( + parser(r"\y").parse_escape().unwrap_err(), + TestError { + span: span(0..2), + kind: ast::ErrorKind::EscapeUnrecognized, + } + ); + } + + #[test] + fn parse_unsupported_backreference() { + assert_eq!( + parser(r"\0").parse_escape().unwrap_err(), + TestError { + span: span(0..2), + kind: ast::ErrorKind::UnsupportedBackreference, + } + ); + assert_eq!( + parser(r"\9").parse_escape().unwrap_err(), + TestError { + span: span(0..2), + kind: ast::ErrorKind::UnsupportedBackreference, + } + ); + } + + #[test] + fn parse_octal() { + for i in 0..511 { + let pat = format!(r"\{:o}", i); + assert_eq!( + parser_octal(&pat).parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..pat.len()), + kind: ast::LiteralKind::Octal, + c: ::std::char::from_u32(i).unwrap(), + })) + ); + } + assert_eq!( + parser_octal(r"\778").parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..3), + kind: ast::LiteralKind::Octal, + c: '?', + })) + ); + assert_eq!( + parser_octal(r"\7777").parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..4), + kind: ast::LiteralKind::Octal, + c: '\u{01FF}', + })) + ); + assert_eq!( + parser_octal(r"\778").parse(), + Ok(Ast::Concat(ast::Concat { + span: span(0..4), + asts: vec![ + Ast::Literal(ast::Literal { + span: span(0..3), + kind: ast::LiteralKind::Octal, + c: '?', + }), + Ast::Literal(ast::Literal { + span: span(3..4), + kind: ast::LiteralKind::Verbatim, + c: '8', + }), + ], + })) + ); + assert_eq!( + parser_octal(r"\7777").parse(), + Ok(Ast::Concat(ast::Concat { + span: span(0..5), + asts: vec![ + Ast::Literal(ast::Literal { + span: span(0..4), + kind: ast::LiteralKind::Octal, + c: '\u{01FF}', + }), + Ast::Literal(ast::Literal { + span: span(4..5), + kind: ast::LiteralKind::Verbatim, + c: '7', + }), + ], + })) + ); + + assert_eq!( + parser_octal(r"\8").parse_escape().unwrap_err(), + TestError { + span: span(0..2), + kind: ast::ErrorKind::EscapeUnrecognized, + } + ); + } + + #[test] + fn parse_hex_two() { + for i in 0..256 { + let pat = format!(r"\x{:02x}", i); + assert_eq!( + parser(&pat).parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..pat.len()), + kind: ast::LiteralKind::HexFixed(ast::HexLiteralKind::X), + c: ::std::char::from_u32(i).unwrap(), + })) + ); + } + + assert_eq!( + parser(r"\xF").parse_escape().unwrap_err(), + TestError { + span: span(3..3), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + assert_eq!( + parser(r"\xG").parse_escape().unwrap_err(), + TestError { + span: span(2..3), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\xFG").parse_escape().unwrap_err(), + TestError { + span: span(3..4), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + } + + #[test] + fn parse_hex_four() { + for i in 0..65536 { + let c = match ::std::char::from_u32(i) { + None => continue, + Some(c) => c, + }; + let pat = format!(r"\u{:04x}", i); + assert_eq!( + parser(&pat).parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..pat.len()), + kind: ast::LiteralKind::HexFixed( + ast::HexLiteralKind::UnicodeShort + ), + c: c, + })) + ); + } + + assert_eq!( + parser(r"\uF").parse_escape().unwrap_err(), + TestError { + span: span(3..3), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + assert_eq!( + parser(r"\uG").parse_escape().unwrap_err(), + TestError { + span: span(2..3), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\uFG").parse_escape().unwrap_err(), + TestError { + span: span(3..4), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\uFFG").parse_escape().unwrap_err(), + TestError { + span: span(4..5), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\uFFFG").parse_escape().unwrap_err(), + TestError { + span: span(5..6), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\uD800").parse_escape().unwrap_err(), + TestError { + span: span(2..6), + kind: ast::ErrorKind::EscapeHexInvalid, + } + ); + } + + #[test] + fn parse_hex_eight() { + for i in 0..65536 { + let c = match ::std::char::from_u32(i) { + None => continue, + Some(c) => c, + }; + let pat = format!(r"\U{:08x}", i); + assert_eq!( + parser(&pat).parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..pat.len()), + kind: ast::LiteralKind::HexFixed( + ast::HexLiteralKind::UnicodeLong + ), + c: c, + })) + ); + } + + assert_eq!( + parser(r"\UF").parse_escape().unwrap_err(), + TestError { + span: span(3..3), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + assert_eq!( + parser(r"\UG").parse_escape().unwrap_err(), + TestError { + span: span(2..3), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\UFG").parse_escape().unwrap_err(), + TestError { + span: span(3..4), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\UFFG").parse_escape().unwrap_err(), + TestError { + span: span(4..5), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\UFFFG").parse_escape().unwrap_err(), + TestError { + span: span(5..6), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\UFFFFG").parse_escape().unwrap_err(), + TestError { + span: span(6..7), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\UFFFFFG").parse_escape().unwrap_err(), + TestError { + span: span(7..8), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\UFFFFFFG").parse_escape().unwrap_err(), + TestError { + span: span(8..9), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\UFFFFFFFG").parse_escape().unwrap_err(), + TestError { + span: span(9..10), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + } + + #[test] + fn parse_hex_brace() { + assert_eq!( + parser(r"\u{26c4}").parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..8), + kind: ast::LiteralKind::HexBrace( + ast::HexLiteralKind::UnicodeShort + ), + c: '⛄', + })) + ); + assert_eq!( + parser(r"\U{26c4}").parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..8), + kind: ast::LiteralKind::HexBrace( + ast::HexLiteralKind::UnicodeLong + ), + c: '⛄', + })) + ); + assert_eq!( + parser(r"\x{26c4}").parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..8), + kind: ast::LiteralKind::HexBrace(ast::HexLiteralKind::X), + c: '⛄', + })) + ); + assert_eq!( + parser(r"\x{26C4}").parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..8), + kind: ast::LiteralKind::HexBrace(ast::HexLiteralKind::X), + c: '⛄', + })) + ); + assert_eq!( + parser(r"\x{10fFfF}").parse_escape(), + Ok(Primitive::Literal(ast::Literal { + span: span(0..10), + kind: ast::LiteralKind::HexBrace(ast::HexLiteralKind::X), + c: '\u{10FFFF}', + })) + ); + + assert_eq!( + parser(r"\x").parse_escape().unwrap_err(), + TestError { + span: span(2..2), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + assert_eq!( + parser(r"\x{").parse_escape().unwrap_err(), + TestError { + span: span(2..3), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + assert_eq!( + parser(r"\x{FF").parse_escape().unwrap_err(), + TestError { + span: span(2..5), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + assert_eq!( + parser(r"\x{}").parse_escape().unwrap_err(), + TestError { + span: span(2..4), + kind: ast::ErrorKind::EscapeHexEmpty, + } + ); + assert_eq!( + parser(r"\x{FGF}").parse_escape().unwrap_err(), + TestError { + span: span(4..5), + kind: ast::ErrorKind::EscapeHexInvalidDigit, + } + ); + assert_eq!( + parser(r"\x{FFFFFF}").parse_escape().unwrap_err(), + TestError { + span: span(3..9), + kind: ast::ErrorKind::EscapeHexInvalid, + } + ); + assert_eq!( + parser(r"\x{D800}").parse_escape().unwrap_err(), + TestError { + span: span(3..7), + kind: ast::ErrorKind::EscapeHexInvalid, + } + ); + assert_eq!( + parser(r"\x{FFFFFFFFF}").parse_escape().unwrap_err(), + TestError { + span: span(3..12), + kind: ast::ErrorKind::EscapeHexInvalid, + } + ); + } + + #[test] + fn parse_decimal() { + assert_eq!(parser("123").parse_decimal(), Ok(123)); + assert_eq!(parser("0").parse_decimal(), Ok(0)); + assert_eq!(parser("01").parse_decimal(), Ok(1)); + + assert_eq!( + parser("-1").parse_decimal().unwrap_err(), + TestError { span: span(0..0), kind: ast::ErrorKind::DecimalEmpty } + ); + assert_eq!( + parser("").parse_decimal().unwrap_err(), + TestError { span: span(0..0), kind: ast::ErrorKind::DecimalEmpty } + ); + assert_eq!( + parser("9999999999").parse_decimal().unwrap_err(), + TestError { + span: span(0..10), + kind: ast::ErrorKind::DecimalInvalid, + } + ); + } + + #[test] + fn parse_set_class() { + fn union(span: Span, items: Vec<ast::ClassSetItem>) -> ast::ClassSet { + ast::ClassSet::union(ast::ClassSetUnion { + span: span, + items: items, + }) + } + + fn intersection( + span: Span, + lhs: ast::ClassSet, + rhs: ast::ClassSet, + ) -> ast::ClassSet { + ast::ClassSet::BinaryOp(ast::ClassSetBinaryOp { + span: span, + kind: ast::ClassSetBinaryOpKind::Intersection, + lhs: Box::new(lhs), + rhs: Box::new(rhs), + }) + } + + fn difference( + span: Span, + lhs: ast::ClassSet, + rhs: ast::ClassSet, + ) -> ast::ClassSet { + ast::ClassSet::BinaryOp(ast::ClassSetBinaryOp { + span: span, + kind: ast::ClassSetBinaryOpKind::Difference, + lhs: Box::new(lhs), + rhs: Box::new(rhs), + }) + } + + fn symdifference( + span: Span, + lhs: ast::ClassSet, + rhs: ast::ClassSet, + ) -> ast::ClassSet { + ast::ClassSet::BinaryOp(ast::ClassSetBinaryOp { + span: span, + kind: ast::ClassSetBinaryOpKind::SymmetricDifference, + lhs: Box::new(lhs), + rhs: Box::new(rhs), + }) + } + + fn itemset(item: ast::ClassSetItem) -> ast::ClassSet { + ast::ClassSet::Item(item) + } + + fn item_ascii(cls: ast::ClassAscii) -> ast::ClassSetItem { + ast::ClassSetItem::Ascii(cls) + } + + fn item_unicode(cls: ast::ClassUnicode) -> ast::ClassSetItem { + ast::ClassSetItem::Unicode(cls) + } + + fn item_perl(cls: ast::ClassPerl) -> ast::ClassSetItem { + ast::ClassSetItem::Perl(cls) + } + + fn item_bracket(cls: ast::ClassBracketed) -> ast::ClassSetItem { + ast::ClassSetItem::Bracketed(Box::new(cls)) + } + + fn lit(span: Span, c: char) -> ast::ClassSetItem { + ast::ClassSetItem::Literal(ast::Literal { + span: span, + kind: ast::LiteralKind::Verbatim, + c: c, + }) + } + + fn empty(span: Span) -> ast::ClassSetItem { + ast::ClassSetItem::Empty(span) + } + + fn range(span: Span, start: char, end: char) -> ast::ClassSetItem { + let pos1 = Position { + offset: span.start.offset + start.len_utf8(), + column: span.start.column + 1, + ..span.start + }; + let pos2 = Position { + offset: span.end.offset - end.len_utf8(), + column: span.end.column - 1, + ..span.end + }; + ast::ClassSetItem::Range(ast::ClassSetRange { + span: span, + start: ast::Literal { + span: Span { end: pos1, ..span }, + kind: ast::LiteralKind::Verbatim, + c: start, + }, + end: ast::Literal { + span: Span { start: pos2, ..span }, + kind: ast::LiteralKind::Verbatim, + c: end, + }, + }) + } + + fn alnum(span: Span, negated: bool) -> ast::ClassAscii { + ast::ClassAscii { + span: span, + kind: ast::ClassAsciiKind::Alnum, + negated: negated, + } + } + + fn lower(span: Span, negated: bool) -> ast::ClassAscii { + ast::ClassAscii { + span: span, + kind: ast::ClassAsciiKind::Lower, + negated: negated, + } + } + + assert_eq!( + parser("[[:alnum:]]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..11), + negated: false, + kind: itemset(item_ascii(alnum(span(1..10), false))), + }))) + ); + assert_eq!( + parser("[[[:alnum:]]]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..13), + negated: false, + kind: itemset(item_bracket(ast::ClassBracketed { + span: span(1..12), + negated: false, + kind: itemset(item_ascii(alnum(span(2..11), false))), + })), + }))) + ); + assert_eq!( + parser("[[:alnum:]&&[:lower:]]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..22), + negated: false, + kind: intersection( + span(1..21), + itemset(item_ascii(alnum(span(1..10), false))), + itemset(item_ascii(lower(span(12..21), false))), + ), + }))) + ); + assert_eq!( + parser("[[:alnum:]--[:lower:]]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..22), + negated: false, + kind: difference( + span(1..21), + itemset(item_ascii(alnum(span(1..10), false))), + itemset(item_ascii(lower(span(12..21), false))), + ), + }))) + ); + assert_eq!( + parser("[[:alnum:]~~[:lower:]]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..22), + negated: false, + kind: symdifference( + span(1..21), + itemset(item_ascii(alnum(span(1..10), false))), + itemset(item_ascii(lower(span(12..21), false))), + ), + }))) + ); + + assert_eq!( + parser("[a]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..3), + negated: false, + kind: itemset(lit(span(1..2), 'a')), + }))) + ); + assert_eq!( + parser(r"[a\]]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..5), + negated: false, + kind: union( + span(1..4), + vec![ + lit(span(1..2), 'a'), + ast::ClassSetItem::Literal(ast::Literal { + span: span(2..4), + kind: ast::LiteralKind::Punctuation, + c: ']', + }), + ] + ), + }))) + ); + assert_eq!( + parser(r"[a\-z]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..6), + negated: false, + kind: union( + span(1..5), + vec![ + lit(span(1..2), 'a'), + ast::ClassSetItem::Literal(ast::Literal { + span: span(2..4), + kind: ast::LiteralKind::Punctuation, + c: '-', + }), + lit(span(4..5), 'z'), + ] + ), + }))) + ); + assert_eq!( + parser("[ab]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..4), + negated: false, + kind: union( + span(1..3), + vec![lit(span(1..2), 'a'), lit(span(2..3), 'b'),] + ), + }))) + ); + assert_eq!( + parser("[a-]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..4), + negated: false, + kind: union( + span(1..3), + vec![lit(span(1..2), 'a'), lit(span(2..3), '-'),] + ), + }))) + ); + assert_eq!( + parser("[-a]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..4), + negated: false, + kind: union( + span(1..3), + vec![lit(span(1..2), '-'), lit(span(2..3), 'a'),] + ), + }))) + ); + assert_eq!( + parser(r"[\pL]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..5), + negated: false, + kind: itemset(item_unicode(ast::ClassUnicode { + span: span(1..4), + negated: false, + kind: ast::ClassUnicodeKind::OneLetter('L'), + })), + }))) + ); + assert_eq!( + parser(r"[\w]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..4), + negated: false, + kind: itemset(item_perl(ast::ClassPerl { + span: span(1..3), + kind: ast::ClassPerlKind::Word, + negated: false, + })), + }))) + ); + assert_eq!( + parser(r"[a\wz]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..6), + negated: false, + kind: union( + span(1..5), + vec![ + lit(span(1..2), 'a'), + item_perl(ast::ClassPerl { + span: span(2..4), + kind: ast::ClassPerlKind::Word, + negated: false, + }), + lit(span(4..5), 'z'), + ] + ), + }))) + ); + + assert_eq!( + parser("[a-z]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..5), + negated: false, + kind: itemset(range(span(1..4), 'a', 'z')), + }))) + ); + assert_eq!( + parser("[a-cx-z]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..8), + negated: false, + kind: union( + span(1..7), + vec![ + range(span(1..4), 'a', 'c'), + range(span(4..7), 'x', 'z'), + ] + ), + }))) + ); + assert_eq!( + parser(r"[\w&&a-cx-z]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..12), + negated: false, + kind: intersection( + span(1..11), + itemset(item_perl(ast::ClassPerl { + span: span(1..3), + kind: ast::ClassPerlKind::Word, + negated: false, + })), + union( + span(5..11), + vec![ + range(span(5..8), 'a', 'c'), + range(span(8..11), 'x', 'z'), + ] + ), + ), + }))) + ); + assert_eq!( + parser(r"[a-cx-z&&\w]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..12), + negated: false, + kind: intersection( + span(1..11), + union( + span(1..7), + vec![ + range(span(1..4), 'a', 'c'), + range(span(4..7), 'x', 'z'), + ] + ), + itemset(item_perl(ast::ClassPerl { + span: span(9..11), + kind: ast::ClassPerlKind::Word, + negated: false, + })), + ), + }))) + ); + assert_eq!( + parser(r"[a--b--c]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..9), + negated: false, + kind: difference( + span(1..8), + difference( + span(1..5), + itemset(lit(span(1..2), 'a')), + itemset(lit(span(4..5), 'b')), + ), + itemset(lit(span(7..8), 'c')), + ), + }))) + ); + assert_eq!( + parser(r"[a~~b~~c]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..9), + negated: false, + kind: symdifference( + span(1..8), + symdifference( + span(1..5), + itemset(lit(span(1..2), 'a')), + itemset(lit(span(4..5), 'b')), + ), + itemset(lit(span(7..8), 'c')), + ), + }))) + ); + assert_eq!( + parser(r"[\^&&^]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..7), + negated: false, + kind: intersection( + span(1..6), + itemset(ast::ClassSetItem::Literal(ast::Literal { + span: span(1..3), + kind: ast::LiteralKind::Punctuation, + c: '^', + })), + itemset(lit(span(5..6), '^')), + ), + }))) + ); + assert_eq!( + parser(r"[\&&&&]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..7), + negated: false, + kind: intersection( + span(1..6), + itemset(ast::ClassSetItem::Literal(ast::Literal { + span: span(1..3), + kind: ast::LiteralKind::Punctuation, + c: '&', + })), + itemset(lit(span(5..6), '&')), + ), + }))) + ); + assert_eq!( + parser(r"[&&&&]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..6), + negated: false, + kind: intersection( + span(1..5), + intersection( + span(1..3), + itemset(empty(span(1..1))), + itemset(empty(span(3..3))), + ), + itemset(empty(span(5..5))), + ), + }))) + ); + + let pat = "[☃-⛄]"; + assert_eq!( + parser(pat).parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span_range(pat, 0..9), + negated: false, + kind: itemset(ast::ClassSetItem::Range(ast::ClassSetRange { + span: span_range(pat, 1..8), + start: ast::Literal { + span: span_range(pat, 1..4), + kind: ast::LiteralKind::Verbatim, + c: '☃', + }, + end: ast::Literal { + span: span_range(pat, 5..8), + kind: ast::LiteralKind::Verbatim, + c: '⛄', + }, + })), + }))) + ); + + assert_eq!( + parser(r"[]]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..3), + negated: false, + kind: itemset(lit(span(1..2), ']')), + }))) + ); + assert_eq!( + parser(r"[]\[]").parse(), + Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..5), + negated: false, + kind: union( + span(1..4), + vec![ + lit(span(1..2), ']'), + ast::ClassSetItem::Literal(ast::Literal { + span: span(2..4), + kind: ast::LiteralKind::Punctuation, + c: '[', + }), + ] + ), + }))) + ); + assert_eq!( + parser(r"[\[]]").parse(), + Ok(concat( + 0..5, + vec![ + Ast::Class(ast::Class::Bracketed(ast::ClassBracketed { + span: span(0..4), + negated: false, + kind: itemset(ast::ClassSetItem::Literal( + ast::Literal { + span: span(1..3), + kind: ast::LiteralKind::Punctuation, + c: '[', + } + )), + })), + Ast::Literal(ast::Literal { + span: span(4..5), + kind: ast::LiteralKind::Verbatim, + c: ']', + }), + ] + )) + ); + + assert_eq!( + parser("[").parse().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + assert_eq!( + parser("[[").parse().unwrap_err(), + TestError { + span: span(1..2), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + assert_eq!( + parser("[[-]").parse().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + assert_eq!( + parser("[[[:alnum:]").parse().unwrap_err(), + TestError { + span: span(1..2), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + assert_eq!( + parser(r"[\b]").parse().unwrap_err(), + TestError { + span: span(1..3), + kind: ast::ErrorKind::ClassEscapeInvalid, + } + ); + assert_eq!( + parser(r"[\w-a]").parse().unwrap_err(), + TestError { + span: span(1..3), + kind: ast::ErrorKind::ClassRangeLiteral, + } + ); + assert_eq!( + parser(r"[a-\w]").parse().unwrap_err(), + TestError { + span: span(3..5), + kind: ast::ErrorKind::ClassRangeLiteral, + } + ); + assert_eq!( + parser(r"[z-a]").parse().unwrap_err(), + TestError { + span: span(1..4), + kind: ast::ErrorKind::ClassRangeInvalid, + } + ); + + assert_eq!( + parser_ignore_whitespace("[a ").parse().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + assert_eq!( + parser_ignore_whitespace("[a- ").parse().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + } + + #[test] + fn parse_set_class_open() { + assert_eq!(parser("[a]").parse_set_class_open(), { + let set = ast::ClassBracketed { + span: span(0..1), + negated: false, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(1..1), + items: vec![], + }), + }; + let union = ast::ClassSetUnion { span: span(1..1), items: vec![] }; + Ok((set, union)) + }); + assert_eq!( + parser_ignore_whitespace("[ a]").parse_set_class_open(), + { + let set = ast::ClassBracketed { + span: span(0..4), + negated: false, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(4..4), + items: vec![], + }), + }; + let union = + ast::ClassSetUnion { span: span(4..4), items: vec![] }; + Ok((set, union)) + } + ); + assert_eq!(parser("[^a]").parse_set_class_open(), { + let set = ast::ClassBracketed { + span: span(0..2), + negated: true, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(2..2), + items: vec![], + }), + }; + let union = ast::ClassSetUnion { span: span(2..2), items: vec![] }; + Ok((set, union)) + }); + assert_eq!( + parser_ignore_whitespace("[ ^ a]").parse_set_class_open(), + { + let set = ast::ClassBracketed { + span: span(0..4), + negated: true, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(4..4), + items: vec![], + }), + }; + let union = + ast::ClassSetUnion { span: span(4..4), items: vec![] }; + Ok((set, union)) + } + ); + assert_eq!(parser("[-a]").parse_set_class_open(), { + let set = ast::ClassBracketed { + span: span(0..2), + negated: false, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(1..1), + items: vec![], + }), + }; + let union = ast::ClassSetUnion { + span: span(1..2), + items: vec![ast::ClassSetItem::Literal(ast::Literal { + span: span(1..2), + kind: ast::LiteralKind::Verbatim, + c: '-', + })], + }; + Ok((set, union)) + }); + assert_eq!( + parser_ignore_whitespace("[ - a]").parse_set_class_open(), + { + let set = ast::ClassBracketed { + span: span(0..4), + negated: false, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(2..2), + items: vec![], + }), + }; + let union = ast::ClassSetUnion { + span: span(2..3), + items: vec![ast::ClassSetItem::Literal(ast::Literal { + span: span(2..3), + kind: ast::LiteralKind::Verbatim, + c: '-', + })], + }; + Ok((set, union)) + } + ); + assert_eq!(parser("[^-a]").parse_set_class_open(), { + let set = ast::ClassBracketed { + span: span(0..3), + negated: true, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(2..2), + items: vec![], + }), + }; + let union = ast::ClassSetUnion { + span: span(2..3), + items: vec![ast::ClassSetItem::Literal(ast::Literal { + span: span(2..3), + kind: ast::LiteralKind::Verbatim, + c: '-', + })], + }; + Ok((set, union)) + }); + assert_eq!(parser("[--a]").parse_set_class_open(), { + let set = ast::ClassBracketed { + span: span(0..3), + negated: false, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(1..1), + items: vec![], + }), + }; + let union = ast::ClassSetUnion { + span: span(1..3), + items: vec![ + ast::ClassSetItem::Literal(ast::Literal { + span: span(1..2), + kind: ast::LiteralKind::Verbatim, + c: '-', + }), + ast::ClassSetItem::Literal(ast::Literal { + span: span(2..3), + kind: ast::LiteralKind::Verbatim, + c: '-', + }), + ], + }; + Ok((set, union)) + }); + assert_eq!(parser("[]a]").parse_set_class_open(), { + let set = ast::ClassBracketed { + span: span(0..2), + negated: false, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(1..1), + items: vec![], + }), + }; + let union = ast::ClassSetUnion { + span: span(1..2), + items: vec![ast::ClassSetItem::Literal(ast::Literal { + span: span(1..2), + kind: ast::LiteralKind::Verbatim, + c: ']', + })], + }; + Ok((set, union)) + }); + assert_eq!( + parser_ignore_whitespace("[ ] a]").parse_set_class_open(), + { + let set = ast::ClassBracketed { + span: span(0..4), + negated: false, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(2..2), + items: vec![], + }), + }; + let union = ast::ClassSetUnion { + span: span(2..3), + items: vec![ast::ClassSetItem::Literal(ast::Literal { + span: span(2..3), + kind: ast::LiteralKind::Verbatim, + c: ']', + })], + }; + Ok((set, union)) + } + ); + assert_eq!(parser("[^]a]").parse_set_class_open(), { + let set = ast::ClassBracketed { + span: span(0..3), + negated: true, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(2..2), + items: vec![], + }), + }; + let union = ast::ClassSetUnion { + span: span(2..3), + items: vec![ast::ClassSetItem::Literal(ast::Literal { + span: span(2..3), + kind: ast::LiteralKind::Verbatim, + c: ']', + })], + }; + Ok((set, union)) + }); + assert_eq!(parser("[-]a]").parse_set_class_open(), { + let set = ast::ClassBracketed { + span: span(0..2), + negated: false, + kind: ast::ClassSet::union(ast::ClassSetUnion { + span: span(1..1), + items: vec![], + }), + }; + let union = ast::ClassSetUnion { + span: span(1..2), + items: vec![ast::ClassSetItem::Literal(ast::Literal { + span: span(1..2), + kind: ast::LiteralKind::Verbatim, + c: '-', + })], + }; + Ok((set, union)) + }); + + assert_eq!( + parser("[").parse_set_class_open().unwrap_err(), + TestError { + span: span(0..1), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + assert_eq!( + parser_ignore_whitespace("[ ") + .parse_set_class_open() + .unwrap_err(), + TestError { + span: span(0..5), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + assert_eq!( + parser("[^").parse_set_class_open().unwrap_err(), + TestError { + span: span(0..2), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + assert_eq!( + parser("[]").parse_set_class_open().unwrap_err(), + TestError { + span: span(0..2), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + assert_eq!( + parser("[-").parse_set_class_open().unwrap_err(), + TestError { + span: span(0..2), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + assert_eq!( + parser("[--").parse_set_class_open().unwrap_err(), + TestError { + span: span(0..3), + kind: ast::ErrorKind::ClassUnclosed, + } + ); + } + + #[test] + fn maybe_parse_ascii_class() { + assert_eq!( + parser(r"[:alnum:]").maybe_parse_ascii_class(), + Some(ast::ClassAscii { + span: span(0..9), + kind: ast::ClassAsciiKind::Alnum, + negated: false, + }) + ); + assert_eq!( + parser(r"[:alnum:]A").maybe_parse_ascii_class(), + Some(ast::ClassAscii { + span: span(0..9), + kind: ast::ClassAsciiKind::Alnum, + negated: false, + }) + ); + assert_eq!( + parser(r"[:^alnum:]").maybe_parse_ascii_class(), + Some(ast::ClassAscii { + span: span(0..10), + kind: ast::ClassAsciiKind::Alnum, + negated: true, + }) + ); + + let p = parser(r"[:"); + assert_eq!(p.maybe_parse_ascii_class(), None); + assert_eq!(p.offset(), 0); + + let p = parser(r"[:^"); + assert_eq!(p.maybe_parse_ascii_class(), None); + assert_eq!(p.offset(), 0); + + let p = parser(r"[^:alnum:]"); + assert_eq!(p.maybe_parse_ascii_class(), None); + assert_eq!(p.offset(), 0); + + let p = parser(r"[:alnnum:]"); + assert_eq!(p.maybe_parse_ascii_class(), None); + assert_eq!(p.offset(), 0); + + let p = parser(r"[:alnum]"); + assert_eq!(p.maybe_parse_ascii_class(), None); + assert_eq!(p.offset(), 0); + + let p = parser(r"[:alnum:"); + assert_eq!(p.maybe_parse_ascii_class(), None); + assert_eq!(p.offset(), 0); + } + + #[test] + fn parse_unicode_class() { + assert_eq!( + parser(r"\pN").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..3), + negated: false, + kind: ast::ClassUnicodeKind::OneLetter('N'), + })) + ); + assert_eq!( + parser(r"\PN").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..3), + negated: true, + kind: ast::ClassUnicodeKind::OneLetter('N'), + })) + ); + assert_eq!( + parser(r"\p{N}").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..5), + negated: false, + kind: ast::ClassUnicodeKind::Named(s("N")), + })) + ); + assert_eq!( + parser(r"\P{N}").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..5), + negated: true, + kind: ast::ClassUnicodeKind::Named(s("N")), + })) + ); + assert_eq!( + parser(r"\p{Greek}").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..9), + negated: false, + kind: ast::ClassUnicodeKind::Named(s("Greek")), + })) + ); + + assert_eq!( + parser(r"\p{scx:Katakana}").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..16), + negated: false, + kind: ast::ClassUnicodeKind::NamedValue { + op: ast::ClassUnicodeOpKind::Colon, + name: s("scx"), + value: s("Katakana"), + }, + })) + ); + assert_eq!( + parser(r"\p{scx=Katakana}").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..16), + negated: false, + kind: ast::ClassUnicodeKind::NamedValue { + op: ast::ClassUnicodeOpKind::Equal, + name: s("scx"), + value: s("Katakana"), + }, + })) + ); + assert_eq!( + parser(r"\p{scx!=Katakana}").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..17), + negated: false, + kind: ast::ClassUnicodeKind::NamedValue { + op: ast::ClassUnicodeOpKind::NotEqual, + name: s("scx"), + value: s("Katakana"), + }, + })) + ); + + assert_eq!( + parser(r"\p{:}").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..5), + negated: false, + kind: ast::ClassUnicodeKind::NamedValue { + op: ast::ClassUnicodeOpKind::Colon, + name: s(""), + value: s(""), + }, + })) + ); + assert_eq!( + parser(r"\p{=}").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..5), + negated: false, + kind: ast::ClassUnicodeKind::NamedValue { + op: ast::ClassUnicodeOpKind::Equal, + name: s(""), + value: s(""), + }, + })) + ); + assert_eq!( + parser(r"\p{!=}").parse_escape(), + Ok(Primitive::Unicode(ast::ClassUnicode { + span: span(0..6), + negated: false, + kind: ast::ClassUnicodeKind::NamedValue { + op: ast::ClassUnicodeOpKind::NotEqual, + name: s(""), + value: s(""), + }, + })) + ); + + assert_eq!( + parser(r"\p").parse_escape().unwrap_err(), + TestError { + span: span(2..2), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + assert_eq!( + parser(r"\p{").parse_escape().unwrap_err(), + TestError { + span: span(3..3), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + assert_eq!( + parser(r"\p{N").parse_escape().unwrap_err(), + TestError { + span: span(4..4), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + assert_eq!( + parser(r"\p{Greek").parse_escape().unwrap_err(), + TestError { + span: span(8..8), + kind: ast::ErrorKind::EscapeUnexpectedEof, + } + ); + + assert_eq!( + parser(r"\pNz").parse(), + Ok(Ast::Concat(ast::Concat { + span: span(0..4), + asts: vec![ + Ast::Class(ast::Class::Unicode(ast::ClassUnicode { + span: span(0..3), + negated: false, + kind: ast::ClassUnicodeKind::OneLetter('N'), + })), + Ast::Literal(ast::Literal { + span: span(3..4), + kind: ast::LiteralKind::Verbatim, + c: 'z', + }), + ], + })) + ); + assert_eq!( + parser(r"\p{Greek}z").parse(), + Ok(Ast::Concat(ast::Concat { + span: span(0..10), + asts: vec![ + Ast::Class(ast::Class::Unicode(ast::ClassUnicode { + span: span(0..9), + negated: false, + kind: ast::ClassUnicodeKind::Named(s("Greek")), + })), + Ast::Literal(ast::Literal { + span: span(9..10), + kind: ast::LiteralKind::Verbatim, + c: 'z', + }), + ], + })) + ); + assert_eq!( + parser(r"\p\{").parse().unwrap_err(), + TestError { + span: span(2..3), + kind: ast::ErrorKind::UnicodeClassInvalid, + } + ); + assert_eq!( + parser(r"\P\{").parse().unwrap_err(), + TestError { + span: span(2..3), + kind: ast::ErrorKind::UnicodeClassInvalid, + } + ); + } + + #[test] + fn parse_perl_class() { + assert_eq!( + parser(r"\d").parse_escape(), + Ok(Primitive::Perl(ast::ClassPerl { + span: span(0..2), + kind: ast::ClassPerlKind::Digit, + negated: false, + })) + ); + assert_eq!( + parser(r"\D").parse_escape(), + Ok(Primitive::Perl(ast::ClassPerl { + span: span(0..2), + kind: ast::ClassPerlKind::Digit, + negated: true, + })) + ); + assert_eq!( + parser(r"\s").parse_escape(), + Ok(Primitive::Perl(ast::ClassPerl { + span: span(0..2), + kind: ast::ClassPerlKind::Space, + negated: false, + })) + ); + assert_eq!( + parser(r"\S").parse_escape(), + Ok(Primitive::Perl(ast::ClassPerl { + span: span(0..2), + kind: ast::ClassPerlKind::Space, + negated: true, + })) + ); + assert_eq!( + parser(r"\w").parse_escape(), + Ok(Primitive::Perl(ast::ClassPerl { + span: span(0..2), + kind: ast::ClassPerlKind::Word, + negated: false, + })) + ); + assert_eq!( + parser(r"\W").parse_escape(), + Ok(Primitive::Perl(ast::ClassPerl { + span: span(0..2), + kind: ast::ClassPerlKind::Word, + negated: true, + })) + ); + + assert_eq!( + parser(r"\d").parse(), + Ok(Ast::Class(ast::Class::Perl(ast::ClassPerl { + span: span(0..2), + kind: ast::ClassPerlKind::Digit, + negated: false, + }))) + ); + assert_eq!( + parser(r"\dz").parse(), + Ok(Ast::Concat(ast::Concat { + span: span(0..3), + asts: vec![ + Ast::Class(ast::Class::Perl(ast::ClassPerl { + span: span(0..2), + kind: ast::ClassPerlKind::Digit, + negated: false, + })), + Ast::Literal(ast::Literal { + span: span(2..3), + kind: ast::LiteralKind::Verbatim, + c: 'z', + }), + ], + })) + ); + } + + // This tests a bug fix where the nest limit checker wasn't decrementing + // its depth during post-traversal, which causes long regexes to trip + // the default limit too aggressively. + #[test] + fn regression_454_nest_too_big() { + let pattern = r#" + 2(?: + [45]\d{3}| + 7(?: + 1[0-267]| + 2[0-289]| + 3[0-29]| + 4[01]| + 5[1-3]| + 6[013]| + 7[0178]| + 91 + )| + 8(?: + 0[125]| + [139][1-6]| + 2[0157-9]| + 41| + 6[1-35]| + 7[1-5]| + 8[1-8]| + 90 + )| + 9(?: + 0[0-2]| + 1[0-4]| + 2[568]| + 3[3-6]| + 5[5-7]| + 6[0167]| + 7[15]| + 8[0146-9] + ) + )\d{4} + "#; + assert!(parser_nest_limit(pattern, 50).parse().is_ok()); + } + + // This tests that we treat a trailing `-` in a character class as a + // literal `-` even when whitespace mode is enabled and there is whitespace + // after the trailing `-`. + #[test] + fn regression_455_trailing_dash_ignore_whitespace() { + assert!(parser("(?x)[ / - ]").parse().is_ok()); + assert!(parser("(?x)[ a - ]").parse().is_ok()); + assert!(parser( + "(?x)[ + a + - ] + " + ) + .parse() + .is_ok()); + assert!(parser( + "(?x)[ + a # wat + - ] + " + ) + .parse() + .is_ok()); + + assert!(parser("(?x)[ / -").parse().is_err()); + assert!(parser("(?x)[ / - ").parse().is_err()); + assert!(parser( + "(?x)[ + / - + " + ) + .parse() + .is_err()); + assert!(parser( + "(?x)[ + / - # wat + " + ) + .parse() + .is_err()); + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/print.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/print.rs new file mode 100644 index 0000000..1b9bc41 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/print.rs @@ -0,0 +1,569 @@ +/*! +This module provides a regular expression printer for `Ast`. +*/ + +use std::fmt; + +use ast::visitor::{self, Visitor}; +use ast::{self, Ast}; + +/// A builder for constructing a printer. +/// +/// Note that since a printer doesn't have any configuration knobs, this type +/// remains unexported. +#[derive(Clone, Debug)] +struct PrinterBuilder { + _priv: (), +} + +impl Default for PrinterBuilder { + fn default() -> PrinterBuilder { + PrinterBuilder::new() + } +} + +impl PrinterBuilder { + fn new() -> PrinterBuilder { + PrinterBuilder { _priv: () } + } + + fn build(&self) -> Printer { + Printer { _priv: () } + } +} + +/// A printer for a regular expression abstract syntax tree. +/// +/// A printer converts an abstract syntax tree (AST) to a regular expression +/// pattern string. This particular printer uses constant stack space and heap +/// space proportional to the size of the AST. +/// +/// This printer will not necessarily preserve the original formatting of the +/// regular expression pattern string. For example, all whitespace and comments +/// are ignored. +#[derive(Debug)] +pub struct Printer { + _priv: (), +} + +impl Printer { + /// Create a new printer. + pub fn new() -> Printer { + PrinterBuilder::new().build() + } + + /// Print the given `Ast` to the given writer. The writer must implement + /// `fmt::Write`. Typical implementations of `fmt::Write` that can be used + /// here are a `fmt::Formatter` (which is available in `fmt::Display` + /// implementations) or a `&mut String`. + pub fn print<W: fmt::Write>(&mut self, ast: &Ast, wtr: W) -> fmt::Result { + visitor::visit(ast, Writer { printer: self, wtr: wtr }) + } +} + +#[derive(Debug)] +struct Writer<'p, W> { + printer: &'p mut Printer, + wtr: W, +} + +impl<'p, W: fmt::Write> Visitor for Writer<'p, W> { + type Output = (); + type Err = fmt::Error; + + fn finish(self) -> fmt::Result { + Ok(()) + } + + fn visit_pre(&mut self, ast: &Ast) -> fmt::Result { + match *ast { + Ast::Group(ref x) => self.fmt_group_pre(x), + Ast::Class(ast::Class::Bracketed(ref x)) => { + self.fmt_class_bracketed_pre(x) + } + _ => Ok(()), + } + } + + fn visit_post(&mut self, ast: &Ast) -> fmt::Result { + use ast::Class; + + match *ast { + Ast::Empty(_) => Ok(()), + Ast::Flags(ref x) => self.fmt_set_flags(x), + Ast::Literal(ref x) => self.fmt_literal(x), + Ast::Dot(_) => self.wtr.write_str("."), + Ast::Assertion(ref x) => self.fmt_assertion(x), + Ast::Class(Class::Perl(ref x)) => self.fmt_class_perl(x), + Ast::Class(Class::Unicode(ref x)) => self.fmt_class_unicode(x), + Ast::Class(Class::Bracketed(ref x)) => { + self.fmt_class_bracketed_post(x) + } + Ast::Repetition(ref x) => self.fmt_repetition(x), + Ast::Group(ref x) => self.fmt_group_post(x), + Ast::Alternation(_) => Ok(()), + Ast::Concat(_) => Ok(()), + } + } + + fn visit_alternation_in(&mut self) -> fmt::Result { + self.wtr.write_str("|") + } + + fn visit_class_set_item_pre( + &mut self, + ast: &ast::ClassSetItem, + ) -> Result<(), Self::Err> { + match *ast { + ast::ClassSetItem::Bracketed(ref x) => { + self.fmt_class_bracketed_pre(x) + } + _ => Ok(()), + } + } + + fn visit_class_set_item_post( + &mut self, + ast: &ast::ClassSetItem, + ) -> Result<(), Self::Err> { + use ast::ClassSetItem::*; + + match *ast { + Empty(_) => Ok(()), + Literal(ref x) => self.fmt_literal(x), + Range(ref x) => { + self.fmt_literal(&x.start)?; + self.wtr.write_str("-")?; + self.fmt_literal(&x.end)?; + Ok(()) + } + Ascii(ref x) => self.fmt_class_ascii(x), + Unicode(ref x) => self.fmt_class_unicode(x), + Perl(ref x) => self.fmt_class_perl(x), + Bracketed(ref x) => self.fmt_class_bracketed_post(x), + Union(_) => Ok(()), + } + } + + fn visit_class_set_binary_op_in( + &mut self, + ast: &ast::ClassSetBinaryOp, + ) -> Result<(), Self::Err> { + self.fmt_class_set_binary_op_kind(&ast.kind) + } +} + +impl<'p, W: fmt::Write> Writer<'p, W> { + fn fmt_group_pre(&mut self, ast: &ast::Group) -> fmt::Result { + use ast::GroupKind::*; + match ast.kind { + CaptureIndex(_) => self.wtr.write_str("("), + CaptureName(ref x) => { + self.wtr.write_str("(?P<")?; + self.wtr.write_str(&x.name)?; + self.wtr.write_str(">")?; + Ok(()) + } + NonCapturing(ref flags) => { + self.wtr.write_str("(?")?; + self.fmt_flags(flags)?; + self.wtr.write_str(":")?; + Ok(()) + } + } + } + + fn fmt_group_post(&mut self, _ast: &ast::Group) -> fmt::Result { + self.wtr.write_str(")") + } + + fn fmt_repetition(&mut self, ast: &ast::Repetition) -> fmt::Result { + use ast::RepetitionKind::*; + match ast.op.kind { + ZeroOrOne if ast.greedy => self.wtr.write_str("?"), + ZeroOrOne => self.wtr.write_str("??"), + ZeroOrMore if ast.greedy => self.wtr.write_str("*"), + ZeroOrMore => self.wtr.write_str("*?"), + OneOrMore if ast.greedy => self.wtr.write_str("+"), + OneOrMore => self.wtr.write_str("+?"), + Range(ref x) => { + self.fmt_repetition_range(x)?; + if !ast.greedy { + self.wtr.write_str("?")?; + } + Ok(()) + } + } + } + + fn fmt_repetition_range( + &mut self, + ast: &ast::RepetitionRange, + ) -> fmt::Result { + use ast::RepetitionRange::*; + match *ast { + Exactly(x) => write!(self.wtr, "{{{}}}", x), + AtLeast(x) => write!(self.wtr, "{{{},}}", x), + Bounded(x, y) => write!(self.wtr, "{{{},{}}}", x, y), + } + } + + fn fmt_literal(&mut self, ast: &ast::Literal) -> fmt::Result { + use ast::LiteralKind::*; + + match ast.kind { + Verbatim => self.wtr.write_char(ast.c), + Punctuation => write!(self.wtr, r"\{}", ast.c), + Octal => write!(self.wtr, r"\{:o}", ast.c as u32), + HexFixed(ast::HexLiteralKind::X) => { + write!(self.wtr, r"\x{:02X}", ast.c as u32) + } + HexFixed(ast::HexLiteralKind::UnicodeShort) => { + write!(self.wtr, r"\u{:04X}", ast.c as u32) + } + HexFixed(ast::HexLiteralKind::UnicodeLong) => { + write!(self.wtr, r"\U{:08X}", ast.c as u32) + } + HexBrace(ast::HexLiteralKind::X) => { + write!(self.wtr, r"\x{{{:X}}}", ast.c as u32) + } + HexBrace(ast::HexLiteralKind::UnicodeShort) => { + write!(self.wtr, r"\u{{{:X}}}", ast.c as u32) + } + HexBrace(ast::HexLiteralKind::UnicodeLong) => { + write!(self.wtr, r"\U{{{:X}}}", ast.c as u32) + } + Special(ast::SpecialLiteralKind::Bell) => { + self.wtr.write_str(r"\a") + } + Special(ast::SpecialLiteralKind::FormFeed) => { + self.wtr.write_str(r"\f") + } + Special(ast::SpecialLiteralKind::Tab) => self.wtr.write_str(r"\t"), + Special(ast::SpecialLiteralKind::LineFeed) => { + self.wtr.write_str(r"\n") + } + Special(ast::SpecialLiteralKind::CarriageReturn) => { + self.wtr.write_str(r"\r") + } + Special(ast::SpecialLiteralKind::VerticalTab) => { + self.wtr.write_str(r"\v") + } + Special(ast::SpecialLiteralKind::Space) => { + self.wtr.write_str(r"\ ") + } + } + } + + fn fmt_assertion(&mut self, ast: &ast::Assertion) -> fmt::Result { + use ast::AssertionKind::*; + match ast.kind { + StartLine => self.wtr.write_str("^"), + EndLine => self.wtr.write_str("$"), + StartText => self.wtr.write_str(r"\A"), + EndText => self.wtr.write_str(r"\z"), + WordBoundary => self.wtr.write_str(r"\b"), + NotWordBoundary => self.wtr.write_str(r"\B"), + } + } + + fn fmt_set_flags(&mut self, ast: &ast::SetFlags) -> fmt::Result { + self.wtr.write_str("(?")?; + self.fmt_flags(&ast.flags)?; + self.wtr.write_str(")")?; + Ok(()) + } + + fn fmt_flags(&mut self, ast: &ast::Flags) -> fmt::Result { + use ast::{Flag, FlagsItemKind}; + + for item in &ast.items { + match item.kind { + FlagsItemKind::Negation => self.wtr.write_str("-"), + FlagsItemKind::Flag(ref flag) => match *flag { + Flag::CaseInsensitive => self.wtr.write_str("i"), + Flag::MultiLine => self.wtr.write_str("m"), + Flag::DotMatchesNewLine => self.wtr.write_str("s"), + Flag::SwapGreed => self.wtr.write_str("U"), + Flag::Unicode => self.wtr.write_str("u"), + Flag::IgnoreWhitespace => self.wtr.write_str("x"), + }, + }?; + } + Ok(()) + } + + fn fmt_class_bracketed_pre( + &mut self, + ast: &ast::ClassBracketed, + ) -> fmt::Result { + if ast.negated { + self.wtr.write_str("[^") + } else { + self.wtr.write_str("[") + } + } + + fn fmt_class_bracketed_post( + &mut self, + _ast: &ast::ClassBracketed, + ) -> fmt::Result { + self.wtr.write_str("]") + } + + fn fmt_class_set_binary_op_kind( + &mut self, + ast: &ast::ClassSetBinaryOpKind, + ) -> fmt::Result { + use ast::ClassSetBinaryOpKind::*; + match *ast { + Intersection => self.wtr.write_str("&&"), + Difference => self.wtr.write_str("--"), + SymmetricDifference => self.wtr.write_str("~~"), + } + } + + fn fmt_class_perl(&mut self, ast: &ast::ClassPerl) -> fmt::Result { + use ast::ClassPerlKind::*; + match ast.kind { + Digit if ast.negated => self.wtr.write_str(r"\D"), + Digit => self.wtr.write_str(r"\d"), + Space if ast.negated => self.wtr.write_str(r"\S"), + Space => self.wtr.write_str(r"\s"), + Word if ast.negated => self.wtr.write_str(r"\W"), + Word => self.wtr.write_str(r"\w"), + } + } + + fn fmt_class_ascii(&mut self, ast: &ast::ClassAscii) -> fmt::Result { + use ast::ClassAsciiKind::*; + match ast.kind { + Alnum if ast.negated => self.wtr.write_str("[:^alnum:]"), + Alnum => self.wtr.write_str("[:alnum:]"), + Alpha if ast.negated => self.wtr.write_str("[:^alpha:]"), + Alpha => self.wtr.write_str("[:alpha:]"), + Ascii if ast.negated => self.wtr.write_str("[:^ascii:]"), + Ascii => self.wtr.write_str("[:ascii:]"), + Blank if ast.negated => self.wtr.write_str("[:^blank:]"), + Blank => self.wtr.write_str("[:blank:]"), + Cntrl if ast.negated => self.wtr.write_str("[:^cntrl:]"), + Cntrl => self.wtr.write_str("[:cntrl:]"), + Digit if ast.negated => self.wtr.write_str("[:^digit:]"), + Digit => self.wtr.write_str("[:digit:]"), + Graph if ast.negated => self.wtr.write_str("[:^graph:]"), + Graph => self.wtr.write_str("[:graph:]"), + Lower if ast.negated => self.wtr.write_str("[:^lower:]"), + Lower => self.wtr.write_str("[:lower:]"), + Print if ast.negated => self.wtr.write_str("[:^print:]"), + Print => self.wtr.write_str("[:print:]"), + Punct if ast.negated => self.wtr.write_str("[:^punct:]"), + Punct => self.wtr.write_str("[:punct:]"), + Space if ast.negated => self.wtr.write_str("[:^space:]"), + Space => self.wtr.write_str("[:space:]"), + Upper if ast.negated => self.wtr.write_str("[:^upper:]"), + Upper => self.wtr.write_str("[:upper:]"), + Word if ast.negated => self.wtr.write_str("[:^word:]"), + Word => self.wtr.write_str("[:word:]"), + Xdigit if ast.negated => self.wtr.write_str("[:^xdigit:]"), + Xdigit => self.wtr.write_str("[:xdigit:]"), + } + } + + fn fmt_class_unicode(&mut self, ast: &ast::ClassUnicode) -> fmt::Result { + use ast::ClassUnicodeKind::*; + use ast::ClassUnicodeOpKind::*; + + if ast.negated { + self.wtr.write_str(r"\P")?; + } else { + self.wtr.write_str(r"\p")?; + } + match ast.kind { + OneLetter(c) => self.wtr.write_char(c), + Named(ref x) => write!(self.wtr, "{{{}}}", x), + NamedValue { op: Equal, ref name, ref value } => { + write!(self.wtr, "{{{}={}}}", name, value) + } + NamedValue { op: Colon, ref name, ref value } => { + write!(self.wtr, "{{{}:{}}}", name, value) + } + NamedValue { op: NotEqual, ref name, ref value } => { + write!(self.wtr, "{{{}!={}}}", name, value) + } + } + } +} + +#[cfg(test)] +mod tests { + use super::Printer; + use ast::parse::ParserBuilder; + + fn roundtrip(given: &str) { + roundtrip_with(|b| b, given); + } + + fn roundtrip_with<F>(mut f: F, given: &str) + where + F: FnMut(&mut ParserBuilder) -> &mut ParserBuilder, + { + let mut builder = ParserBuilder::new(); + f(&mut builder); + let ast = builder.build().parse(given).unwrap(); + + let mut printer = Printer::new(); + let mut dst = String::new(); + printer.print(&ast, &mut dst).unwrap(); + assert_eq!(given, dst); + } + + #[test] + fn print_literal() { + roundtrip("a"); + roundtrip(r"\["); + roundtrip_with(|b| b.octal(true), r"\141"); + roundtrip(r"\x61"); + roundtrip(r"\x7F"); + roundtrip(r"\u0061"); + roundtrip(r"\U00000061"); + roundtrip(r"\x{61}"); + roundtrip(r"\x{7F}"); + roundtrip(r"\u{61}"); + roundtrip(r"\U{61}"); + + roundtrip(r"\a"); + roundtrip(r"\f"); + roundtrip(r"\t"); + roundtrip(r"\n"); + roundtrip(r"\r"); + roundtrip(r"\v"); + roundtrip(r"(?x)\ "); + } + + #[test] + fn print_dot() { + roundtrip("."); + } + + #[test] + fn print_concat() { + roundtrip("ab"); + roundtrip("abcde"); + roundtrip("a(bcd)ef"); + } + + #[test] + fn print_alternation() { + roundtrip("a|b"); + roundtrip("a|b|c|d|e"); + roundtrip("|a|b|c|d|e"); + roundtrip("|a|b|c|d|e|"); + roundtrip("a(b|c|d)|e|f"); + } + + #[test] + fn print_assertion() { + roundtrip(r"^"); + roundtrip(r"$"); + roundtrip(r"\A"); + roundtrip(r"\z"); + roundtrip(r"\b"); + roundtrip(r"\B"); + } + + #[test] + fn print_repetition() { + roundtrip("a?"); + roundtrip("a??"); + roundtrip("a*"); + roundtrip("a*?"); + roundtrip("a+"); + roundtrip("a+?"); + roundtrip("a{5}"); + roundtrip("a{5}?"); + roundtrip("a{5,}"); + roundtrip("a{5,}?"); + roundtrip("a{5,10}"); + roundtrip("a{5,10}?"); + } + + #[test] + fn print_flags() { + roundtrip("(?i)"); + roundtrip("(?-i)"); + roundtrip("(?s-i)"); + roundtrip("(?-si)"); + roundtrip("(?siUmux)"); + } + + #[test] + fn print_group() { + roundtrip("(?i:a)"); + roundtrip("(?P<foo>a)"); + roundtrip("(a)"); + } + + #[test] + fn print_class() { + roundtrip(r"[abc]"); + roundtrip(r"[a-z]"); + roundtrip(r"[^a-z]"); + roundtrip(r"[a-z0-9]"); + roundtrip(r"[-a-z0-9]"); + roundtrip(r"[-a-z0-9]"); + roundtrip(r"[a-z0-9---]"); + roundtrip(r"[a-z&&m-n]"); + roundtrip(r"[[a-z&&m-n]]"); + roundtrip(r"[a-z--m-n]"); + roundtrip(r"[a-z~~m-n]"); + roundtrip(r"[a-z[0-9]]"); + roundtrip(r"[a-z[^0-9]]"); + + roundtrip(r"\d"); + roundtrip(r"\D"); + roundtrip(r"\s"); + roundtrip(r"\S"); + roundtrip(r"\w"); + roundtrip(r"\W"); + + roundtrip(r"[[:alnum:]]"); + roundtrip(r"[[:^alnum:]]"); + roundtrip(r"[[:alpha:]]"); + roundtrip(r"[[:^alpha:]]"); + roundtrip(r"[[:ascii:]]"); + roundtrip(r"[[:^ascii:]]"); + roundtrip(r"[[:blank:]]"); + roundtrip(r"[[:^blank:]]"); + roundtrip(r"[[:cntrl:]]"); + roundtrip(r"[[:^cntrl:]]"); + roundtrip(r"[[:digit:]]"); + roundtrip(r"[[:^digit:]]"); + roundtrip(r"[[:graph:]]"); + roundtrip(r"[[:^graph:]]"); + roundtrip(r"[[:lower:]]"); + roundtrip(r"[[:^lower:]]"); + roundtrip(r"[[:print:]]"); + roundtrip(r"[[:^print:]]"); + roundtrip(r"[[:punct:]]"); + roundtrip(r"[[:^punct:]]"); + roundtrip(r"[[:space:]]"); + roundtrip(r"[[:^space:]]"); + roundtrip(r"[[:upper:]]"); + roundtrip(r"[[:^upper:]]"); + roundtrip(r"[[:word:]]"); + roundtrip(r"[[:^word:]]"); + roundtrip(r"[[:xdigit:]]"); + roundtrip(r"[[:^xdigit:]]"); + + roundtrip(r"\pL"); + roundtrip(r"\PL"); + roundtrip(r"\p{L}"); + roundtrip(r"\P{L}"); + roundtrip(r"\p{X=Y}"); + roundtrip(r"\P{X=Y}"); + roundtrip(r"\p{X:Y}"); + roundtrip(r"\P{X:Y}"); + roundtrip(r"\p{X!=Y}"); + roundtrip(r"\P{X!=Y}"); + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/visitor.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/visitor.rs new file mode 100644 index 0000000..3eaa4b0 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/ast/visitor.rs @@ -0,0 +1,519 @@ +use std::fmt; + +use ast::{self, Ast}; + +/// A trait for visiting an abstract syntax tree (AST) in depth first order. +/// +/// The principle aim of this trait is to enable callers to perform case +/// analysis on an abstract syntax tree without necessarily using recursion. +/// In particular, this permits callers to do case analysis with constant stack +/// usage, which can be important since the size of an abstract syntax tree +/// may be proportional to end user input. +/// +/// Typical usage of this trait involves providing an implementation and then +/// running it using the [`visit`](fn.visit.html) function. +/// +/// Note that the abstract syntax tree for a regular expression is quite +/// complex. Unless you specifically need it, you might be able to use the +/// much simpler +/// [high-level intermediate representation](../hir/struct.Hir.html) +/// and its +/// [corresponding `Visitor` trait](../hir/trait.Visitor.html) +/// instead. +pub trait Visitor { + /// The result of visiting an AST. + type Output; + /// An error that visiting an AST might return. + type Err; + + /// All implementors of `Visitor` must provide a `finish` method, which + /// yields the result of visiting the AST or an error. + fn finish(self) -> Result<Self::Output, Self::Err>; + + /// This method is called before beginning traversal of the AST. + fn start(&mut self) {} + + /// This method is called on an `Ast` before descending into child `Ast` + /// nodes. + fn visit_pre(&mut self, _ast: &Ast) -> Result<(), Self::Err> { + Ok(()) + } + + /// This method is called on an `Ast` after descending all of its child + /// `Ast` nodes. + fn visit_post(&mut self, _ast: &Ast) -> Result<(), Self::Err> { + Ok(()) + } + + /// This method is called between child nodes of an + /// [`Alternation`](struct.Alternation.html). + fn visit_alternation_in(&mut self) -> Result<(), Self::Err> { + Ok(()) + } + + /// This method is called on every + /// [`ClassSetItem`](enum.ClassSetItem.html) + /// before descending into child nodes. + fn visit_class_set_item_pre( + &mut self, + _ast: &ast::ClassSetItem, + ) -> Result<(), Self::Err> { + Ok(()) + } + + /// This method is called on every + /// [`ClassSetItem`](enum.ClassSetItem.html) + /// after descending into child nodes. + fn visit_class_set_item_post( + &mut self, + _ast: &ast::ClassSetItem, + ) -> Result<(), Self::Err> { + Ok(()) + } + + /// This method is called on every + /// [`ClassSetBinaryOp`](struct.ClassSetBinaryOp.html) + /// before descending into child nodes. + fn visit_class_set_binary_op_pre( + &mut self, + _ast: &ast::ClassSetBinaryOp, + ) -> Result<(), Self::Err> { + Ok(()) + } + + /// This method is called on every + /// [`ClassSetBinaryOp`](struct.ClassSetBinaryOp.html) + /// after descending into child nodes. + fn visit_class_set_binary_op_post( + &mut self, + _ast: &ast::ClassSetBinaryOp, + ) -> Result<(), Self::Err> { + Ok(()) + } + + /// This method is called between the left hand and right hand child nodes + /// of a [`ClassSetBinaryOp`](struct.ClassSetBinaryOp.html). + fn visit_class_set_binary_op_in( + &mut self, + _ast: &ast::ClassSetBinaryOp, + ) -> Result<(), Self::Err> { + Ok(()) + } +} + +/// Executes an implementation of `Visitor` in constant stack space. +/// +/// This function will visit every node in the given `Ast` while calling the +/// appropriate methods provided by the +/// [`Visitor`](trait.Visitor.html) trait. +/// +/// The primary use case for this method is when one wants to perform case +/// analysis over an `Ast` without using a stack size proportional to the depth +/// of the `Ast`. Namely, this method will instead use constant stack size, but +/// will use heap space proportional to the size of the `Ast`. This may be +/// desirable in cases where the size of `Ast` is proportional to end user +/// input. +/// +/// If the visitor returns an error at any point, then visiting is stopped and +/// the error is returned. +pub fn visit<V: Visitor>(ast: &Ast, visitor: V) -> Result<V::Output, V::Err> { + HeapVisitor::new().visit(ast, visitor) +} + +/// HeapVisitor visits every item in an `Ast` recursively using constant stack +/// size and a heap size proportional to the size of the `Ast`. +struct HeapVisitor<'a> { + /// A stack of `Ast` nodes. This is roughly analogous to the call stack + /// used in a typical recursive visitor. + stack: Vec<(&'a Ast, Frame<'a>)>, + /// Similar to the `Ast` stack above, but is used only for character + /// classes. In particular, character classes embed their own mini + /// recursive syntax. + stack_class: Vec<(ClassInduct<'a>, ClassFrame<'a>)>, +} + +/// Represents a single stack frame while performing structural induction over +/// an `Ast`. +enum Frame<'a> { + /// A stack frame allocated just before descending into a repetition + /// operator's child node. + Repetition(&'a ast::Repetition), + /// A stack frame allocated just before descending into a group's child + /// node. + Group(&'a ast::Group), + /// The stack frame used while visiting every child node of a concatenation + /// of expressions. + Concat { + /// The child node we are currently visiting. + head: &'a Ast, + /// The remaining child nodes to visit (which may be empty). + tail: &'a [Ast], + }, + /// The stack frame used while visiting every child node of an alternation + /// of expressions. + Alternation { + /// The child node we are currently visiting. + head: &'a Ast, + /// The remaining child nodes to visit (which may be empty). + tail: &'a [Ast], + }, +} + +/// Represents a single stack frame while performing structural induction over +/// a character class. +enum ClassFrame<'a> { + /// The stack frame used while visiting every child node of a union of + /// character class items. + Union { + /// The child node we are currently visiting. + head: &'a ast::ClassSetItem, + /// The remaining child nodes to visit (which may be empty). + tail: &'a [ast::ClassSetItem], + }, + /// The stack frame used while a binary class operation. + Binary { op: &'a ast::ClassSetBinaryOp }, + /// A stack frame allocated just before descending into a binary operator's + /// left hand child node. + BinaryLHS { + op: &'a ast::ClassSetBinaryOp, + lhs: &'a ast::ClassSet, + rhs: &'a ast::ClassSet, + }, + /// A stack frame allocated just before descending into a binary operator's + /// right hand child node. + BinaryRHS { op: &'a ast::ClassSetBinaryOp, rhs: &'a ast::ClassSet }, +} + +/// A representation of the inductive step when performing structural induction +/// over a character class. +/// +/// Note that there is no analogous explicit type for the inductive step for +/// `Ast` nodes because the inductive step is just an `Ast`. For character +/// classes, the inductive step can produce one of two possible child nodes: +/// an item or a binary operation. (An item cannot be a binary operation +/// because that would imply binary operations can be unioned in the concrete +/// syntax, which is not possible.) +enum ClassInduct<'a> { + Item(&'a ast::ClassSetItem), + BinaryOp(&'a ast::ClassSetBinaryOp), +} + +impl<'a> HeapVisitor<'a> { + fn new() -> HeapVisitor<'a> { + HeapVisitor { stack: vec![], stack_class: vec![] } + } + + fn visit<V: Visitor>( + &mut self, + mut ast: &'a Ast, + mut visitor: V, + ) -> Result<V::Output, V::Err> { + self.stack.clear(); + self.stack_class.clear(); + + visitor.start(); + loop { + visitor.visit_pre(ast)?; + if let Some(x) = self.induct(ast, &mut visitor)? { + let child = x.child(); + self.stack.push((ast, x)); + ast = child; + continue; + } + // No induction means we have a base case, so we can post visit + // it now. + visitor.visit_post(ast)?; + + // At this point, we now try to pop our call stack until it is + // either empty or we hit another inductive case. + loop { + let (post_ast, frame) = match self.stack.pop() { + None => return visitor.finish(), + Some((post_ast, frame)) => (post_ast, frame), + }; + // If this is a concat/alternate, then we might have additional + // inductive steps to process. + if let Some(x) = self.pop(frame) { + if let Frame::Alternation { .. } = x { + visitor.visit_alternation_in()?; + } + ast = x.child(); + self.stack.push((post_ast, x)); + break; + } + // Otherwise, we've finished visiting all the child nodes for + // this AST, so we can post visit it now. + visitor.visit_post(post_ast)?; + } + } + } + + /// Build a stack frame for the given AST if one is needed (which occurs if + /// and only if there are child nodes in the AST). Otherwise, return None. + /// + /// If this visits a class, then the underlying visitor implementation may + /// return an error which will be passed on here. + fn induct<V: Visitor>( + &mut self, + ast: &'a Ast, + visitor: &mut V, + ) -> Result<Option<Frame<'a>>, V::Err> { + Ok(match *ast { + Ast::Class(ast::Class::Bracketed(ref x)) => { + self.visit_class(x, visitor)?; + None + } + Ast::Repetition(ref x) => Some(Frame::Repetition(x)), + Ast::Group(ref x) => Some(Frame::Group(x)), + Ast::Concat(ref x) if x.asts.is_empty() => None, + Ast::Concat(ref x) => { + Some(Frame::Concat { head: &x.asts[0], tail: &x.asts[1..] }) + } + Ast::Alternation(ref x) if x.asts.is_empty() => None, + Ast::Alternation(ref x) => Some(Frame::Alternation { + head: &x.asts[0], + tail: &x.asts[1..], + }), + _ => None, + }) + } + + /// Pops the given frame. If the frame has an additional inductive step, + /// then return it, otherwise return `None`. + fn pop(&self, induct: Frame<'a>) -> Option<Frame<'a>> { + match induct { + Frame::Repetition(_) => None, + Frame::Group(_) => None, + Frame::Concat { tail, .. } => { + if tail.is_empty() { + None + } else { + Some(Frame::Concat { head: &tail[0], tail: &tail[1..] }) + } + } + Frame::Alternation { tail, .. } => { + if tail.is_empty() { + None + } else { + Some(Frame::Alternation { + head: &tail[0], + tail: &tail[1..], + }) + } + } + } + } + + fn visit_class<V: Visitor>( + &mut self, + ast: &'a ast::ClassBracketed, + visitor: &mut V, + ) -> Result<(), V::Err> { + let mut ast = ClassInduct::from_bracketed(ast); + loop { + self.visit_class_pre(&ast, visitor)?; + if let Some(x) = self.induct_class(&ast) { + let child = x.child(); + self.stack_class.push((ast, x)); + ast = child; + continue; + } + self.visit_class_post(&ast, visitor)?; + + // At this point, we now try to pop our call stack until it is + // either empty or we hit another inductive case. + loop { + let (post_ast, frame) = match self.stack_class.pop() { + None => return Ok(()), + Some((post_ast, frame)) => (post_ast, frame), + }; + // If this is a union or a binary op, then we might have + // additional inductive steps to process. + if let Some(x) = self.pop_class(frame) { + if let ClassFrame::BinaryRHS { ref op, .. } = x { + visitor.visit_class_set_binary_op_in(op)?; + } + ast = x.child(); + self.stack_class.push((post_ast, x)); + break; + } + // Otherwise, we've finished visiting all the child nodes for + // this class node, so we can post visit it now. + self.visit_class_post(&post_ast, visitor)?; + } + } + } + + /// Call the appropriate `Visitor` methods given an inductive step. + fn visit_class_pre<V: Visitor>( + &self, + ast: &ClassInduct<'a>, + visitor: &mut V, + ) -> Result<(), V::Err> { + match *ast { + ClassInduct::Item(item) => { + visitor.visit_class_set_item_pre(item)?; + } + ClassInduct::BinaryOp(op) => { + visitor.visit_class_set_binary_op_pre(op)?; + } + } + Ok(()) + } + + /// Call the appropriate `Visitor` methods given an inductive step. + fn visit_class_post<V: Visitor>( + &self, + ast: &ClassInduct<'a>, + visitor: &mut V, + ) -> Result<(), V::Err> { + match *ast { + ClassInduct::Item(item) => { + visitor.visit_class_set_item_post(item)?; + } + ClassInduct::BinaryOp(op) => { + visitor.visit_class_set_binary_op_post(op)?; + } + } + Ok(()) + } + + /// Build a stack frame for the given class node if one is needed (which + /// occurs if and only if there are child nodes). Otherwise, return None. + fn induct_class(&self, ast: &ClassInduct<'a>) -> Option<ClassFrame<'a>> { + match *ast { + ClassInduct::Item(&ast::ClassSetItem::Bracketed(ref x)) => { + match x.kind { + ast::ClassSet::Item(ref item) => { + Some(ClassFrame::Union { head: item, tail: &[] }) + } + ast::ClassSet::BinaryOp(ref op) => { + Some(ClassFrame::Binary { op: op }) + } + } + } + ClassInduct::Item(&ast::ClassSetItem::Union(ref x)) => { + if x.items.is_empty() { + None + } else { + Some(ClassFrame::Union { + head: &x.items[0], + tail: &x.items[1..], + }) + } + } + ClassInduct::BinaryOp(op) => Some(ClassFrame::BinaryLHS { + op: op, + lhs: &op.lhs, + rhs: &op.rhs, + }), + _ => None, + } + } + + /// Pops the given frame. If the frame has an additional inductive step, + /// then return it, otherwise return `None`. + fn pop_class(&self, induct: ClassFrame<'a>) -> Option<ClassFrame<'a>> { + match induct { + ClassFrame::Union { tail, .. } => { + if tail.is_empty() { + None + } else { + Some(ClassFrame::Union { + head: &tail[0], + tail: &tail[1..], + }) + } + } + ClassFrame::Binary { .. } => None, + ClassFrame::BinaryLHS { op, rhs, .. } => { + Some(ClassFrame::BinaryRHS { op: op, rhs: rhs }) + } + ClassFrame::BinaryRHS { .. } => None, + } + } +} + +impl<'a> Frame<'a> { + /// Perform the next inductive step on this frame and return the next + /// child AST node to visit. + fn child(&self) -> &'a Ast { + match *self { + Frame::Repetition(rep) => &rep.ast, + Frame::Group(group) => &group.ast, + Frame::Concat { head, .. } => head, + Frame::Alternation { head, .. } => head, + } + } +} + +impl<'a> ClassFrame<'a> { + /// Perform the next inductive step on this frame and return the next + /// child class node to visit. + fn child(&self) -> ClassInduct<'a> { + match *self { + ClassFrame::Union { head, .. } => ClassInduct::Item(head), + ClassFrame::Binary { op, .. } => ClassInduct::BinaryOp(op), + ClassFrame::BinaryLHS { ref lhs, .. } => { + ClassInduct::from_set(lhs) + } + ClassFrame::BinaryRHS { ref rhs, .. } => { + ClassInduct::from_set(rhs) + } + } + } +} + +impl<'a> ClassInduct<'a> { + fn from_bracketed(ast: &'a ast::ClassBracketed) -> ClassInduct<'a> { + ClassInduct::from_set(&ast.kind) + } + + fn from_set(ast: &'a ast::ClassSet) -> ClassInduct<'a> { + match *ast { + ast::ClassSet::Item(ref item) => ClassInduct::Item(item), + ast::ClassSet::BinaryOp(ref op) => ClassInduct::BinaryOp(op), + } + } +} + +impl<'a> fmt::Debug for ClassFrame<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let x = match *self { + ClassFrame::Union { .. } => "Union", + ClassFrame::Binary { .. } => "Binary", + ClassFrame::BinaryLHS { .. } => "BinaryLHS", + ClassFrame::BinaryRHS { .. } => "BinaryRHS", + }; + write!(f, "{}", x) + } +} + +impl<'a> fmt::Debug for ClassInduct<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let x = match *self { + ClassInduct::Item(it) => match *it { + ast::ClassSetItem::Empty(_) => "Item(Empty)", + ast::ClassSetItem::Literal(_) => "Item(Literal)", + ast::ClassSetItem::Range(_) => "Item(Range)", + ast::ClassSetItem::Ascii(_) => "Item(Ascii)", + ast::ClassSetItem::Perl(_) => "Item(Perl)", + ast::ClassSetItem::Unicode(_) => "Item(Unicode)", + ast::ClassSetItem::Bracketed(_) => "Item(Bracketed)", + ast::ClassSetItem::Union(_) => "Item(Union)", + }, + ClassInduct::BinaryOp(it) => match it.kind { + ast::ClassSetBinaryOpKind::Intersection => { + "BinaryOp(Intersection)" + } + ast::ClassSetBinaryOpKind::Difference => { + "BinaryOp(Difference)" + } + ast::ClassSetBinaryOpKind::SymmetricDifference => { + "BinaryOp(SymmetricDifference)" + } + }, + }; + write!(f, "{}", x) + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/either.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/either.rs new file mode 100644 index 0000000..7ae41e4 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/either.rs @@ -0,0 +1,8 @@ +/// A simple binary sum type. +/// +/// This is occasionally useful in an ad hoc fashion. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Either<Left, Right> { + Left(Left), + Right(Right), +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/error.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/error.rs new file mode 100644 index 0000000..93c2b0d --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/error.rs @@ -0,0 +1,324 @@ +use std::cmp; +use std::error; +use std::fmt; +use std::result; + +use ast; +use hir; + +/// A type alias for dealing with errors returned by this crate. +pub type Result<T> = result::Result<T, Error>; + +/// This error type encompasses any error that can be returned by this crate. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Error { + /// An error that occurred while translating concrete syntax into abstract + /// syntax (AST). + Parse(ast::Error), + /// An error that occurred while translating abstract syntax into a high + /// level intermediate representation (HIR). + Translate(hir::Error), + /// Hints that destructuring should not be exhaustive. + /// + /// This enum may grow additional variants, so this makes sure clients + /// don't count on exhaustive matching. (Otherwise, adding a new variant + /// could break existing code.) + #[doc(hidden)] + __Nonexhaustive, +} + +impl From<ast::Error> for Error { + fn from(err: ast::Error) -> Error { + Error::Parse(err) + } +} + +impl From<hir::Error> for Error { + fn from(err: hir::Error) -> Error { + Error::Translate(err) + } +} + +impl error::Error for Error { + // TODO: Remove this method entirely on the next breaking semver release. + #[allow(deprecated)] + fn description(&self) -> &str { + match *self { + Error::Parse(ref x) => x.description(), + Error::Translate(ref x) => x.description(), + _ => unreachable!(), + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Error::Parse(ref x) => x.fmt(f), + Error::Translate(ref x) => x.fmt(f), + _ => unreachable!(), + } + } +} + +/// A helper type for formatting nice error messages. +/// +/// This type is responsible for reporting regex parse errors in a nice human +/// readable format. Most of its complexity is from interspersing notational +/// markers pointing out the position where an error occurred. +#[derive(Debug)] +pub struct Formatter<'e, E: 'e> { + /// The original regex pattern in which the error occurred. + pattern: &'e str, + /// The error kind. It must impl fmt::Display. + err: &'e E, + /// The primary span of the error. + span: &'e ast::Span, + /// An auxiliary and optional span, in case the error needs to point to + /// two locations (e.g., when reporting a duplicate capture group name). + aux_span: Option<&'e ast::Span>, +} + +impl<'e> From<&'e ast::Error> for Formatter<'e, ast::ErrorKind> { + fn from(err: &'e ast::Error) -> Self { + Formatter { + pattern: err.pattern(), + err: err.kind(), + span: err.span(), + aux_span: err.auxiliary_span(), + } + } +} + +impl<'e> From<&'e hir::Error> for Formatter<'e, hir::ErrorKind> { + fn from(err: &'e hir::Error) -> Self { + Formatter { + pattern: err.pattern(), + err: err.kind(), + span: err.span(), + aux_span: None, + } + } +} + +impl<'e, E: fmt::Display> fmt::Display for Formatter<'e, E> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let spans = Spans::from_formatter(self); + if self.pattern.contains('\n') { + let divider = repeat_char('~', 79); + + writeln!(f, "regex parse error:")?; + writeln!(f, "{}", divider)?; + let notated = spans.notate(); + write!(f, "{}", notated)?; + writeln!(f, "{}", divider)?; + // If we have error spans that cover multiple lines, then we just + // note the line numbers. + if !spans.multi_line.is_empty() { + let mut notes = vec![]; + for span in &spans.multi_line { + notes.push(format!( + "on line {} (column {}) through line {} (column {})", + span.start.line, + span.start.column, + span.end.line, + span.end.column - 1 + )); + } + writeln!(f, "{}", notes.join("\n"))?; + } + write!(f, "error: {}", self.err)?; + } else { + writeln!(f, "regex parse error:")?; + let notated = Spans::from_formatter(self).notate(); + write!(f, "{}", notated)?; + write!(f, "error: {}", self.err)?; + } + Ok(()) + } +} + +/// This type represents an arbitrary number of error spans in a way that makes +/// it convenient to notate the regex pattern. ("Notate" means "point out +/// exactly where the error occurred in the regex pattern.") +/// +/// Technically, we can only ever have two spans given our current error +/// structure. However, after toiling with a specific algorithm for handling +/// two spans, it became obvious that an algorithm to handle an arbitrary +/// number of spans was actually much simpler. +struct Spans<'p> { + /// The original regex pattern string. + pattern: &'p str, + /// The total width that should be used for line numbers. The width is + /// used for left padding the line numbers for alignment. + /// + /// A value of `0` means line numbers should not be displayed. That is, + /// the pattern is itself only one line. + line_number_width: usize, + /// All error spans that occur on a single line. This sequence always has + /// length equivalent to the number of lines in `pattern`, where the index + /// of the sequence represents a line number, starting at `0`. The spans + /// in each line are sorted in ascending order. + by_line: Vec<Vec<ast::Span>>, + /// All error spans that occur over one or more lines. That is, the start + /// and end position of the span have different line numbers. The spans are + /// sorted in ascending order. + multi_line: Vec<ast::Span>, +} + +impl<'p> Spans<'p> { + /// Build a sequence of spans from a formatter. + fn from_formatter<'e, E: fmt::Display>( + fmter: &'p Formatter<'e, E>, + ) -> Spans<'p> { + let mut line_count = fmter.pattern.lines().count(); + // If the pattern ends with a `\n` literal, then our line count is + // off by one, since a span can occur immediately after the last `\n`, + // which is consider to be an additional line. + if fmter.pattern.ends_with('\n') { + line_count += 1; + } + let line_number_width = + if line_count <= 1 { 0 } else { line_count.to_string().len() }; + let mut spans = Spans { + pattern: &fmter.pattern, + line_number_width: line_number_width, + by_line: vec![vec![]; line_count], + multi_line: vec![], + }; + spans.add(fmter.span.clone()); + if let Some(span) = fmter.aux_span { + spans.add(span.clone()); + } + spans + } + + /// Add the given span to this sequence, putting it in the right place. + fn add(&mut self, span: ast::Span) { + // This is grossly inefficient since we sort after each add, but right + // now, we only ever add two spans at most. + if span.is_one_line() { + let i = span.start.line - 1; // because lines are 1-indexed + self.by_line[i].push(span); + self.by_line[i].sort(); + } else { + self.multi_line.push(span); + self.multi_line.sort(); + } + } + + /// Notate the pattern string with carents (`^`) pointing at each span + /// location. This only applies to spans that occur within a single line. + fn notate(&self) -> String { + let mut notated = String::new(); + for (i, line) in self.pattern.lines().enumerate() { + if self.line_number_width > 0 { + notated.push_str(&self.left_pad_line_number(i + 1)); + notated.push_str(": "); + } else { + notated.push_str(" "); + } + notated.push_str(line); + notated.push('\n'); + if let Some(notes) = self.notate_line(i) { + notated.push_str(¬es); + notated.push('\n'); + } + } + notated + } + + /// Return notes for the line indexed at `i` (zero-based). If there are no + /// spans for the given line, then `None` is returned. Otherwise, an + /// appropriately space padded string with correctly positioned `^` is + /// returned, accounting for line numbers. + fn notate_line(&self, i: usize) -> Option<String> { + let spans = &self.by_line[i]; + if spans.is_empty() { + return None; + } + let mut notes = String::new(); + for _ in 0..self.line_number_padding() { + notes.push(' '); + } + let mut pos = 0; + for span in spans { + for _ in pos..(span.start.column - 1) { + notes.push(' '); + pos += 1; + } + let note_len = span.end.column.saturating_sub(span.start.column); + for _ in 0..cmp::max(1, note_len) { + notes.push('^'); + pos += 1; + } + } + Some(notes) + } + + /// Left pad the given line number with spaces such that it is aligned with + /// other line numbers. + fn left_pad_line_number(&self, n: usize) -> String { + let n = n.to_string(); + let pad = self.line_number_width.checked_sub(n.len()).unwrap(); + let mut result = repeat_char(' ', pad); + result.push_str(&n); + result + } + + /// Return the line number padding beginning at the start of each line of + /// the pattern. + /// + /// If the pattern is only one line, then this returns a fixed padding + /// for visual indentation. + fn line_number_padding(&self) -> usize { + if self.line_number_width == 0 { + 4 + } else { + 2 + self.line_number_width + } + } +} + +fn repeat_char(c: char, count: usize) -> String { + ::std::iter::repeat(c).take(count).collect() +} + +#[cfg(test)] +mod tests { + use ast::parse::Parser; + + fn assert_panic_message(pattern: &str, expected_msg: &str) -> () { + let result = Parser::new().parse(pattern); + match result { + Ok(_) => { + panic!("regex should not have parsed"); + } + Err(err) => { + assert_eq!(err.to_string(), expected_msg.trim()); + } + } + } + + // See: https://github.com/rust-lang/regex/issues/464 + #[test] + fn regression_464() { + let err = Parser::new().parse("a{\n").unwrap_err(); + // This test checks that the error formatter doesn't panic. + assert!(!err.to_string().is_empty()); + } + + // See: https://github.com/rust-lang/regex/issues/545 + #[test] + fn repetition_quantifier_expects_a_valid_decimal() { + assert_panic_message( + r"\\u{[^}]*}", + r#" +regex parse error: + \\u{[^}]*} + ^ +error: repetition quantifier expects a valid decimal +"#, + ); + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/interval.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/interval.rs new file mode 100644 index 0000000..51eed52 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/interval.rs @@ -0,0 +1,520 @@ +use std::char; +use std::cmp; +use std::fmt::Debug; +use std::slice; +use std::u8; + +use unicode; + +// This module contains an *internal* implementation of interval sets. +// +// The primary invariant that interval sets guards is canonical ordering. That +// is, every interval set contains an ordered sequence of intervals where +// no two intervals are overlapping or adjacent. While this invariant is +// occasionally broken within the implementation, it should be impossible for +// callers to observe it. +// +// Since case folding (as implemented below) breaks that invariant, we roll +// that into this API even though it is a little out of place in an otherwise +// generic interval set. (Hence the reason why the `unicode` module is imported +// here.) +// +// Some of the implementation complexity here is a result of me wanting to +// preserve the sequential representation without using additional memory. +// In many cases, we do use linear extra memory, but it is at most 2x and it +// is amortized. If we relaxed the memory requirements, this implementation +// could become much simpler. The extra memory is honestly probably OK, but +// character classes (especially of the Unicode variety) can become quite +// large, and it would be nice to keep regex compilation snappy even in debug +// builds. (In the past, I have been careless with this area of code and it has +// caused slow regex compilations in debug mode, so this isn't entirely +// unwarranted.) +// +// Tests on this are relegated to the public API of HIR in src/hir.rs. + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct IntervalSet<I> { + ranges: Vec<I>, +} + +impl<I: Interval> IntervalSet<I> { + /// Create a new set from a sequence of intervals. Each interval is + /// specified as a pair of bounds, where both bounds are inclusive. + /// + /// The given ranges do not need to be in any specific order, and ranges + /// may overlap. + pub fn new<T: IntoIterator<Item = I>>(intervals: T) -> IntervalSet<I> { + let mut set = IntervalSet { ranges: intervals.into_iter().collect() }; + set.canonicalize(); + set + } + + /// Add a new interval to this set. + pub fn push(&mut self, interval: I) { + // TODO: This could be faster. e.g., Push the interval such that + // it preserves canonicalization. + self.ranges.push(interval); + self.canonicalize(); + } + + /// Return an iterator over all intervals in this set. + /// + /// The iterator yields intervals in ascending order. + pub fn iter(&self) -> IntervalSetIter<I> { + IntervalSetIter(self.ranges.iter()) + } + + /// Return an immutable slice of intervals in this set. + /// + /// The sequence returned is in canonical ordering. + pub fn intervals(&self) -> &[I] { + &self.ranges + } + + /// Expand this interval set such that it contains all case folded + /// characters. For example, if this class consists of the range `a-z`, + /// then applying case folding will result in the class containing both the + /// ranges `a-z` and `A-Z`. + /// + /// This returns an error if the necessary case mapping data is not + /// available. + pub fn case_fold_simple(&mut self) -> Result<(), unicode::CaseFoldError> { + let len = self.ranges.len(); + for i in 0..len { + let range = self.ranges[i]; + if let Err(err) = range.case_fold_simple(&mut self.ranges) { + self.canonicalize(); + return Err(err); + } + } + self.canonicalize(); + Ok(()) + } + + /// Union this set with the given set, in place. + pub fn union(&mut self, other: &IntervalSet<I>) { + // This could almost certainly be done more efficiently. + self.ranges.extend(&other.ranges); + self.canonicalize(); + } + + /// Intersect this set with the given set, in place. + pub fn intersect(&mut self, other: &IntervalSet<I>) { + if self.ranges.is_empty() { + return; + } + if other.ranges.is_empty() { + self.ranges.clear(); + return; + } + + // There should be a way to do this in-place with constant memory, + // but I couldn't figure out a simple way to do it. So just append + // the intersection to the end of this range, and then drain it before + // we're done. + let drain_end = self.ranges.len(); + + let mut ita = (0..drain_end).into_iter(); + let mut itb = (0..other.ranges.len()).into_iter(); + let mut a = ita.next().unwrap(); + let mut b = itb.next().unwrap(); + loop { + if let Some(ab) = self.ranges[a].intersect(&other.ranges[b]) { + self.ranges.push(ab); + } + let (it, aorb) = + if self.ranges[a].upper() < other.ranges[b].upper() { + (&mut ita, &mut a) + } else { + (&mut itb, &mut b) + }; + match it.next() { + Some(v) => *aorb = v, + None => break, + } + } + self.ranges.drain(..drain_end); + } + + /// Subtract the given set from this set, in place. + pub fn difference(&mut self, other: &IntervalSet<I>) { + if self.ranges.is_empty() || other.ranges.is_empty() { + return; + } + + // This algorithm is (to me) surprisingly complex. A search of the + // interwebs indicate that this is a potentially interesting problem. + // Folks seem to suggest interval or segment trees, but I'd like to + // avoid the overhead (both runtime and conceptual) of that. + // + // The following is basically my Shitty First Draft. Therefore, in + // order to grok it, you probably need to read each line carefully. + // Simplifications are most welcome! + // + // Remember, we can assume the canonical format invariant here, which + // says that all ranges are sorted, not overlapping and not adjacent in + // each class. + let drain_end = self.ranges.len(); + let (mut a, mut b) = (0, 0); + 'LOOP: while a < drain_end && b < other.ranges.len() { + // Basically, the easy cases are when neither range overlaps with + // each other. If the `b` range is less than our current `a` + // range, then we can skip it and move on. + if other.ranges[b].upper() < self.ranges[a].lower() { + b += 1; + continue; + } + // ... similarly for the `a` range. If it's less than the smallest + // `b` range, then we can add it as-is. + if self.ranges[a].upper() < other.ranges[b].lower() { + let range = self.ranges[a]; + self.ranges.push(range); + a += 1; + continue; + } + // Otherwise, we have overlapping ranges. + assert!(!self.ranges[a].is_intersection_empty(&other.ranges[b])); + + // This part is tricky and was non-obvious to me without looking + // at explicit examples (see the tests). The trickiness stems from + // two things: 1) subtracting a range from another range could + // yield two ranges and 2) after subtracting a range, it's possible + // that future ranges can have an impact. The loop below advances + // the `b` ranges until they can't possible impact the current + // range. + // + // For example, if our `a` range is `a-t` and our next three `b` + // ranges are `a-c`, `g-i`, `r-t` and `x-z`, then we need to apply + // subtraction three times before moving on to the next `a` range. + let mut range = self.ranges[a]; + while b < other.ranges.len() + && !range.is_intersection_empty(&other.ranges[b]) + { + let old_range = range; + range = match range.difference(&other.ranges[b]) { + (None, None) => { + // We lost the entire range, so move on to the next + // without adding this one. + a += 1; + continue 'LOOP; + } + (Some(range1), None) | (None, Some(range1)) => range1, + (Some(range1), Some(range2)) => { + self.ranges.push(range1); + range2 + } + }; + // It's possible that the `b` range has more to contribute + // here. In particular, if it is greater than the original + // range, then it might impact the next `a` range *and* it + // has impacted the current `a` range as much as possible, + // so we can quit. We don't bump `b` so that the next `a` + // range can apply it. + if other.ranges[b].upper() > old_range.upper() { + break; + } + // Otherwise, the next `b` range might apply to the current + // `a` range. + b += 1; + } + self.ranges.push(range); + a += 1; + } + while a < drain_end { + let range = self.ranges[a]; + self.ranges.push(range); + a += 1; + } + self.ranges.drain(..drain_end); + } + + /// Compute the symmetric difference of the two sets, in place. + /// + /// This computes the symmetric difference of two interval sets. This + /// removes all elements in this set that are also in the given set, + /// but also adds all elements from the given set that aren't in this + /// set. That is, the set will contain all elements in either set, + /// but will not contain any elements that are in both sets. + pub fn symmetric_difference(&mut self, other: &IntervalSet<I>) { + // TODO(burntsushi): Fix this so that it amortizes allocation. + let mut intersection = self.clone(); + intersection.intersect(other); + self.union(other); + self.difference(&intersection); + } + + /// Negate this interval set. + /// + /// For all `x` where `x` is any element, if `x` was in this set, then it + /// will not be in this set after negation. + pub fn negate(&mut self) { + if self.ranges.is_empty() { + let (min, max) = (I::Bound::min_value(), I::Bound::max_value()); + self.ranges.push(I::create(min, max)); + return; + } + + // There should be a way to do this in-place with constant memory, + // but I couldn't figure out a simple way to do it. So just append + // the negation to the end of this range, and then drain it before + // we're done. + let drain_end = self.ranges.len(); + + // We do checked arithmetic below because of the canonical ordering + // invariant. + if self.ranges[0].lower() > I::Bound::min_value() { + let upper = self.ranges[0].lower().decrement(); + self.ranges.push(I::create(I::Bound::min_value(), upper)); + } + for i in 1..drain_end { + let lower = self.ranges[i - 1].upper().increment(); + let upper = self.ranges[i].lower().decrement(); + self.ranges.push(I::create(lower, upper)); + } + if self.ranges[drain_end - 1].upper() < I::Bound::max_value() { + let lower = self.ranges[drain_end - 1].upper().increment(); + self.ranges.push(I::create(lower, I::Bound::max_value())); + } + self.ranges.drain(..drain_end); + } + + /// Converts this set into a canonical ordering. + fn canonicalize(&mut self) { + if self.is_canonical() { + return; + } + self.ranges.sort(); + assert!(!self.ranges.is_empty()); + + // Is there a way to do this in-place with constant memory? I couldn't + // figure out a way to do it. So just append the canonicalization to + // the end of this range, and then drain it before we're done. + let drain_end = self.ranges.len(); + for oldi in 0..drain_end { + // If we've added at least one new range, then check if we can + // merge this range in the previously added range. + if self.ranges.len() > drain_end { + let (last, rest) = self.ranges.split_last_mut().unwrap(); + if let Some(union) = last.union(&rest[oldi]) { + *last = union; + continue; + } + } + let range = self.ranges[oldi]; + self.ranges.push(range); + } + self.ranges.drain(..drain_end); + } + + /// Returns true if and only if this class is in a canonical ordering. + fn is_canonical(&self) -> bool { + for pair in self.ranges.windows(2) { + if pair[0] >= pair[1] { + return false; + } + if pair[0].is_contiguous(&pair[1]) { + return false; + } + } + true + } +} + +/// An iterator over intervals. +#[derive(Debug)] +pub struct IntervalSetIter<'a, I: 'a>(slice::Iter<'a, I>); + +impl<'a, I> Iterator for IntervalSetIter<'a, I> { + type Item = &'a I; + + fn next(&mut self) -> Option<&'a I> { + self.0.next() + } +} + +pub trait Interval: + Clone + Copy + Debug + Default + Eq + PartialEq + PartialOrd + Ord +{ + type Bound: Bound; + + fn lower(&self) -> Self::Bound; + fn upper(&self) -> Self::Bound; + fn set_lower(&mut self, bound: Self::Bound); + fn set_upper(&mut self, bound: Self::Bound); + fn case_fold_simple( + &self, + intervals: &mut Vec<Self>, + ) -> Result<(), unicode::CaseFoldError>; + + /// Create a new interval. + fn create(lower: Self::Bound, upper: Self::Bound) -> Self { + let mut int = Self::default(); + if lower <= upper { + int.set_lower(lower); + int.set_upper(upper); + } else { + int.set_lower(upper); + int.set_upper(lower); + } + int + } + + /// Union the given overlapping range into this range. + /// + /// If the two ranges aren't contiguous, then this returns `None`. + fn union(&self, other: &Self) -> Option<Self> { + if !self.is_contiguous(other) { + return None; + } + let lower = cmp::min(self.lower(), other.lower()); + let upper = cmp::max(self.upper(), other.upper()); + Some(Self::create(lower, upper)) + } + + /// Intersect this range with the given range and return the result. + /// + /// If the intersection is empty, then this returns `None`. + fn intersect(&self, other: &Self) -> Option<Self> { + let lower = cmp::max(self.lower(), other.lower()); + let upper = cmp::min(self.upper(), other.upper()); + if lower <= upper { + Some(Self::create(lower, upper)) + } else { + None + } + } + + /// Subtract the given range from this range and return the resulting + /// ranges. + /// + /// If subtraction would result in an empty range, then no ranges are + /// returned. + fn difference(&self, other: &Self) -> (Option<Self>, Option<Self>) { + if self.is_subset(other) { + return (None, None); + } + if self.is_intersection_empty(other) { + return (Some(self.clone()), None); + } + let add_lower = other.lower() > self.lower(); + let add_upper = other.upper() < self.upper(); + // We know this because !self.is_subset(other) and the ranges have + // a non-empty intersection. + assert!(add_lower || add_upper); + let mut ret = (None, None); + if add_lower { + let upper = other.lower().decrement(); + ret.0 = Some(Self::create(self.lower(), upper)); + } + if add_upper { + let lower = other.upper().increment(); + let range = Self::create(lower, self.upper()); + if ret.0.is_none() { + ret.0 = Some(range); + } else { + ret.1 = Some(range); + } + } + ret + } + + /// Compute the symmetric difference the given range from this range. This + /// returns the union of the two ranges minus its intersection. + fn symmetric_difference( + &self, + other: &Self, + ) -> (Option<Self>, Option<Self>) { + let union = match self.union(other) { + None => return (Some(self.clone()), Some(other.clone())), + Some(union) => union, + }; + let intersection = match self.intersect(other) { + None => return (Some(self.clone()), Some(other.clone())), + Some(intersection) => intersection, + }; + union.difference(&intersection) + } + + /// Returns true if and only if the two ranges are contiguous. Two ranges + /// are contiguous if and only if the ranges are either overlapping or + /// adjacent. + fn is_contiguous(&self, other: &Self) -> bool { + let lower1 = self.lower().as_u32(); + let upper1 = self.upper().as_u32(); + let lower2 = other.lower().as_u32(); + let upper2 = other.upper().as_u32(); + cmp::max(lower1, lower2) <= cmp::min(upper1, upper2).saturating_add(1) + } + + /// Returns true if and only if the intersection of this range and the + /// other range is empty. + fn is_intersection_empty(&self, other: &Self) -> bool { + let (lower1, upper1) = (self.lower(), self.upper()); + let (lower2, upper2) = (other.lower(), other.upper()); + cmp::max(lower1, lower2) > cmp::min(upper1, upper2) + } + + /// Returns true if and only if this range is a subset of the other range. + fn is_subset(&self, other: &Self) -> bool { + let (lower1, upper1) = (self.lower(), self.upper()); + let (lower2, upper2) = (other.lower(), other.upper()); + (lower2 <= lower1 && lower1 <= upper2) + && (lower2 <= upper1 && upper1 <= upper2) + } +} + +pub trait Bound: + Copy + Clone + Debug + Eq + PartialEq + PartialOrd + Ord +{ + fn min_value() -> Self; + fn max_value() -> Self; + fn as_u32(self) -> u32; + fn increment(self) -> Self; + fn decrement(self) -> Self; +} + +impl Bound for u8 { + fn min_value() -> Self { + u8::MIN + } + fn max_value() -> Self { + u8::MAX + } + fn as_u32(self) -> u32 { + self as u32 + } + fn increment(self) -> Self { + self.checked_add(1).unwrap() + } + fn decrement(self) -> Self { + self.checked_sub(1).unwrap() + } +} + +impl Bound for char { + fn min_value() -> Self { + '\x00' + } + fn max_value() -> Self { + '\u{10FFFF}' + } + fn as_u32(self) -> u32 { + self as u32 + } + + fn increment(self) -> Self { + match self { + '\u{D7FF}' => '\u{E000}', + c => char::from_u32((c as u32).checked_add(1).unwrap()).unwrap(), + } + } + + fn decrement(self) -> Self { + match self { + '\u{E000}' => '\u{D7FF}', + c => char::from_u32((c as u32).checked_sub(1).unwrap()).unwrap(), + } + } +} + +// Tests for interval sets are written in src/hir.rs against the public API. diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/literal/mod.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/literal/mod.rs new file mode 100644 index 0000000..3ba225c --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/literal/mod.rs @@ -0,0 +1,1685 @@ +/*! +Provides routines for extracting literal prefixes and suffixes from an `Hir`. +*/ + +use std::cmp; +use std::fmt; +use std::iter; +use std::mem; +use std::ops; + +use hir::{self, Hir, HirKind}; + +/// A set of literal byte strings extracted from a regular expression. +/// +/// Every member of the set is a `Literal`, which is represented by a +/// `Vec<u8>`. (Notably, it may contain invalid UTF-8.) Every member is +/// said to be either *complete* or *cut*. A complete literal means that +/// it extends until the beginning (or end) of the regular expression. In +/// some circumstances, this can be used to indicate a match in the regular +/// expression. +/// +/// A key aspect of literal extraction is knowing when to stop. It is not +/// feasible to blindly extract all literals from a regular expression, even if +/// there are finitely many. For example, the regular expression `[0-9]{10}` +/// has `10^10` distinct literals. For this reason, literal extraction is +/// bounded to some low number by default using heuristics, but the limits can +/// be tweaked. +/// +/// **WARNING**: Literal extraction uses stack space proportional to the size +/// of the `Hir` expression. At some point, this drawback will be eliminated. +/// To protect yourself, set a reasonable +/// [`nest_limit` on your `Parser`](../../struct.ParserBuilder.html#method.nest_limit). +/// This is done for you by default. +#[derive(Clone, Eq, PartialEq)] +pub struct Literals { + lits: Vec<Literal>, + limit_size: usize, + limit_class: usize, +} + +/// A single member of a set of literals extracted from a regular expression. +/// +/// This type has `Deref` and `DerefMut` impls to `Vec<u8>` so that all slice +/// and `Vec` operations are available. +#[derive(Clone, Eq, Ord)] +pub struct Literal { + v: Vec<u8>, + cut: bool, +} + +impl Literals { + /// Returns a new empty set of literals using default limits. + pub fn empty() -> Literals { + Literals { lits: vec![], limit_size: 250, limit_class: 10 } + } + + /// Returns a set of literal prefixes extracted from the given `Hir`. + pub fn prefixes(expr: &Hir) -> Literals { + let mut lits = Literals::empty(); + lits.union_prefixes(expr); + lits + } + + /// Returns a set of literal suffixes extracted from the given `Hir`. + pub fn suffixes(expr: &Hir) -> Literals { + let mut lits = Literals::empty(); + lits.union_suffixes(expr); + lits + } + + /// Get the approximate size limit (in bytes) of this set. + pub fn limit_size(&self) -> usize { + self.limit_size + } + + /// Set the approximate size limit (in bytes) of this set. + /// + /// If extracting a literal would put the set over this limit, then + /// extraction stops. + /// + /// The new limits will only apply to additions to this set. Existing + /// members remain unchanged, even if the set exceeds the new limit. + pub fn set_limit_size(&mut self, size: usize) -> &mut Literals { + self.limit_size = size; + self + } + + /// Get the character class size limit for this set. + pub fn limit_class(&self) -> usize { + self.limit_class + } + + /// Limits the size of character(or byte) classes considered. + /// + /// A value of `0` prevents all character classes from being considered. + /// + /// This limit also applies to case insensitive literals, since each + /// character in the case insensitive literal is converted to a class, and + /// then case folded. + /// + /// The new limits will only apply to additions to this set. Existing + /// members remain unchanged, even if the set exceeds the new limit. + pub fn set_limit_class(&mut self, size: usize) -> &mut Literals { + self.limit_class = size; + self + } + + /// Returns the set of literals as a slice. Its order is unspecified. + pub fn literals(&self) -> &[Literal] { + &self.lits + } + + /// Returns the length of the smallest literal. + /// + /// Returns None is there are no literals in the set. + pub fn min_len(&self) -> Option<usize> { + let mut min = None; + for lit in &self.lits { + match min { + None => min = Some(lit.len()), + Some(m) if lit.len() < m => min = Some(lit.len()), + _ => {} + } + } + min + } + + /// Returns true if all members in this set are complete. + pub fn all_complete(&self) -> bool { + !self.lits.is_empty() && self.lits.iter().all(|l| !l.is_cut()) + } + + /// Returns true if any member in this set is complete. + pub fn any_complete(&self) -> bool { + self.lits.iter().any(|lit| !lit.is_cut()) + } + + /// Returns true if this set contains an empty literal. + pub fn contains_empty(&self) -> bool { + self.lits.iter().any(|lit| lit.is_empty()) + } + + /// Returns true if this set is empty or if all of its members is empty. + pub fn is_empty(&self) -> bool { + self.lits.is_empty() || self.lits.iter().all(|lit| lit.is_empty()) + } + + /// Returns a new empty set of literals using this set's limits. + pub fn to_empty(&self) -> Literals { + let mut lits = Literals::empty(); + lits.set_limit_size(self.limit_size).set_limit_class(self.limit_class); + lits + } + + /// Returns the longest common prefix of all members in this set. + pub fn longest_common_prefix(&self) -> &[u8] { + if self.is_empty() { + return &[]; + } + let lit0 = &*self.lits[0]; + let mut len = lit0.len(); + for lit in &self.lits[1..] { + len = cmp::min( + len, + lit.iter().zip(lit0).take_while(|&(a, b)| a == b).count(), + ); + } + &self.lits[0][..len] + } + + /// Returns the longest common suffix of all members in this set. + pub fn longest_common_suffix(&self) -> &[u8] { + if self.is_empty() { + return &[]; + } + let lit0 = &*self.lits[0]; + let mut len = lit0.len(); + for lit in &self.lits[1..] { + len = cmp::min( + len, + lit.iter() + .rev() + .zip(lit0.iter().rev()) + .take_while(|&(a, b)| a == b) + .count(), + ); + } + &self.lits[0][self.lits[0].len() - len..] + } + + /// Returns a new set of literals with the given number of bytes trimmed + /// from the suffix of each literal. + /// + /// If any literal would be cut out completely by trimming, then None is + /// returned. + /// + /// Any duplicates that are created as a result of this transformation are + /// removed. + pub fn trim_suffix(&self, num_bytes: usize) -> Option<Literals> { + if self.min_len().map(|len| len <= num_bytes).unwrap_or(true) { + return None; + } + let mut new = self.to_empty(); + for mut lit in self.lits.iter().cloned() { + let new_len = lit.len() - num_bytes; + lit.truncate(new_len); + lit.cut(); + new.lits.push(lit); + } + new.lits.sort(); + new.lits.dedup(); + Some(new) + } + + /// Returns a new set of prefixes of this set of literals that are + /// guaranteed to be unambiguous. + /// + /// Any substring match with a member of the set is returned is guaranteed + /// to never overlap with a substring match of another member of the set + /// at the same starting position. + /// + /// Given any two members of the returned set, neither is a substring of + /// the other. + pub fn unambiguous_prefixes(&self) -> Literals { + if self.lits.is_empty() { + return self.to_empty(); + } + let mut old: Vec<Literal> = self.lits.iter().cloned().collect(); + let mut new = self.to_empty(); + 'OUTER: while let Some(mut candidate) = old.pop() { + if candidate.is_empty() { + continue; + } + if new.lits.is_empty() { + new.lits.push(candidate); + continue; + } + for lit2 in &mut new.lits { + if lit2.is_empty() { + continue; + } + if &candidate == lit2 { + // If the literal is already in the set, then we can + // just drop it. But make sure that cut literals are + // infectious! + candidate.cut = candidate.cut || lit2.cut; + lit2.cut = candidate.cut; + continue 'OUTER; + } + if candidate.len() < lit2.len() { + if let Some(i) = position(&candidate, &lit2) { + candidate.cut(); + let mut lit3 = lit2.clone(); + lit3.truncate(i); + lit3.cut(); + old.push(lit3); + lit2.clear(); + } + } else { + if let Some(i) = position(&lit2, &candidate) { + lit2.cut(); + let mut new_candidate = candidate.clone(); + new_candidate.truncate(i); + new_candidate.cut(); + old.push(new_candidate); + candidate.clear(); + } + } + // Oops, the candidate is already represented in the set. + if candidate.is_empty() { + continue 'OUTER; + } + } + new.lits.push(candidate); + } + new.lits.retain(|lit| !lit.is_empty()); + new.lits.sort(); + new.lits.dedup(); + new + } + + /// Returns a new set of suffixes of this set of literals that are + /// guaranteed to be unambiguous. + /// + /// Any substring match with a member of the set is returned is guaranteed + /// to never overlap with a substring match of another member of the set + /// at the same ending position. + /// + /// Given any two members of the returned set, neither is a substring of + /// the other. + pub fn unambiguous_suffixes(&self) -> Literals { + // This is a touch wasteful... + let mut lits = self.clone(); + lits.reverse(); + let mut unamb = lits.unambiguous_prefixes(); + unamb.reverse(); + unamb + } + + /// Unions the prefixes from the given expression to this set. + /// + /// If prefixes could not be added (for example, this set would exceed its + /// size limits or the set of prefixes from `expr` includes the empty + /// string), then false is returned. + /// + /// Note that prefix literals extracted from `expr` are said to be complete + /// if and only if the literal extends from the beginning of `expr` to the + /// end of `expr`. + pub fn union_prefixes(&mut self, expr: &Hir) -> bool { + let mut lits = self.to_empty(); + prefixes(expr, &mut lits); + !lits.is_empty() && !lits.contains_empty() && self.union(lits) + } + + /// Unions the suffixes from the given expression to this set. + /// + /// If suffixes could not be added (for example, this set would exceed its + /// size limits or the set of suffixes from `expr` includes the empty + /// string), then false is returned. + /// + /// Note that prefix literals extracted from `expr` are said to be complete + /// if and only if the literal extends from the end of `expr` to the + /// beginning of `expr`. + pub fn union_suffixes(&mut self, expr: &Hir) -> bool { + let mut lits = self.to_empty(); + suffixes(expr, &mut lits); + lits.reverse(); + !lits.is_empty() && !lits.contains_empty() && self.union(lits) + } + + /// Unions this set with another set. + /// + /// If the union would cause the set to exceed its limits, then the union + /// is skipped and it returns false. Otherwise, if the union succeeds, it + /// returns true. + pub fn union(&mut self, lits: Literals) -> bool { + if self.num_bytes() + lits.num_bytes() > self.limit_size { + return false; + } + if lits.is_empty() { + self.lits.push(Literal::empty()); + } else { + self.lits.extend(lits.lits); + } + true + } + + /// Extends this set with another set. + /// + /// The set of literals is extended via a cross product. + /// + /// If a cross product would cause this set to exceed its limits, then the + /// cross product is skipped and it returns false. Otherwise, if the cross + /// product succeeds, it returns true. + pub fn cross_product(&mut self, lits: &Literals) -> bool { + if lits.is_empty() { + return true; + } + // Check that we make sure we stay in our limits. + let mut size_after; + if self.is_empty() || !self.any_complete() { + size_after = self.num_bytes(); + for lits_lit in lits.literals() { + size_after += lits_lit.len(); + } + } else { + size_after = self.lits.iter().fold(0, |accum, lit| { + accum + if lit.is_cut() { lit.len() } else { 0 } + }); + for lits_lit in lits.literals() { + for self_lit in self.literals() { + if !self_lit.is_cut() { + size_after += self_lit.len() + lits_lit.len(); + } + } + } + } + if size_after > self.limit_size { + return false; + } + + let mut base = self.remove_complete(); + if base.is_empty() { + base = vec![Literal::empty()]; + } + for lits_lit in lits.literals() { + for mut self_lit in base.clone() { + self_lit.extend(&**lits_lit); + self_lit.cut = lits_lit.cut; + self.lits.push(self_lit); + } + } + true + } + + /// Extends each literal in this set with the bytes given. + /// + /// If the set is empty, then the given literal is added to the set. + /// + /// If adding any number of bytes to all members of this set causes a limit + /// to be exceeded, then no bytes are added and false is returned. If a + /// prefix of `bytes` can be fit into this set, then it is used and all + /// resulting literals are cut. + pub fn cross_add(&mut self, bytes: &[u8]) -> bool { + // N.B. This could be implemented by simply calling cross_product with + // a literal set containing just `bytes`, but we can be smarter about + // taking shorter prefixes of `bytes` if they'll fit. + if bytes.is_empty() { + return true; + } + if self.lits.is_empty() { + let i = cmp::min(self.limit_size, bytes.len()); + self.lits.push(Literal::new(bytes[..i].to_owned())); + self.lits[0].cut = i < bytes.len(); + return !self.lits[0].is_cut(); + } + let size = self.num_bytes(); + if size + self.lits.len() >= self.limit_size { + return false; + } + let mut i = 1; + while size + (i * self.lits.len()) <= self.limit_size + && i < bytes.len() + { + i += 1; + } + for lit in &mut self.lits { + if !lit.is_cut() { + lit.extend(&bytes[..i]); + if i < bytes.len() { + lit.cut(); + } + } + } + true + } + + /// Adds the given literal to this set. + /// + /// Returns false if adding this literal would cause the class to be too + /// big. + pub fn add(&mut self, lit: Literal) -> bool { + if self.num_bytes() + lit.len() > self.limit_size { + return false; + } + self.lits.push(lit); + true + } + + /// Extends each literal in this set with the character class given. + /// + /// Returns false if the character class was too big to add. + pub fn add_char_class(&mut self, cls: &hir::ClassUnicode) -> bool { + self._add_char_class(cls, false) + } + + /// Extends each literal in this set with the character class given, + /// writing the bytes of each character in reverse. + /// + /// Returns false if the character class was too big to add. + fn add_char_class_reverse(&mut self, cls: &hir::ClassUnicode) -> bool { + self._add_char_class(cls, true) + } + + fn _add_char_class( + &mut self, + cls: &hir::ClassUnicode, + reverse: bool, + ) -> bool { + use std::char; + + if self.class_exceeds_limits(cls_char_count(cls)) { + return false; + } + let mut base = self.remove_complete(); + if base.is_empty() { + base = vec![Literal::empty()]; + } + for r in cls.iter() { + let (s, e) = (r.start as u32, r.end as u32 + 1); + for c in (s..e).filter_map(char::from_u32) { + for mut lit in base.clone() { + let mut bytes = c.to_string().into_bytes(); + if reverse { + bytes.reverse(); + } + lit.extend(&bytes); + self.lits.push(lit); + } + } + } + true + } + + /// Extends each literal in this set with the byte class given. + /// + /// Returns false if the byte class was too big to add. + pub fn add_byte_class(&mut self, cls: &hir::ClassBytes) -> bool { + if self.class_exceeds_limits(cls_byte_count(cls)) { + return false; + } + let mut base = self.remove_complete(); + if base.is_empty() { + base = vec![Literal::empty()]; + } + for r in cls.iter() { + let (s, e) = (r.start as u32, r.end as u32 + 1); + for b in (s..e).map(|b| b as u8) { + for mut lit in base.clone() { + lit.push(b); + self.lits.push(lit); + } + } + } + true + } + + /// Cuts every member of this set. When a member is cut, it can never + /// be extended. + pub fn cut(&mut self) { + for lit in &mut self.lits { + lit.cut(); + } + } + + /// Reverses all members in place. + pub fn reverse(&mut self) { + for lit in &mut self.lits { + lit.reverse(); + } + } + + /// Clears this set of all members. + pub fn clear(&mut self) { + self.lits.clear(); + } + + /// Pops all complete literals out of this set. + fn remove_complete(&mut self) -> Vec<Literal> { + let mut base = vec![]; + for lit in mem::replace(&mut self.lits, vec![]) { + if lit.is_cut() { + self.lits.push(lit); + } else { + base.push(lit); + } + } + base + } + + /// Returns the total number of bytes in this set. + fn num_bytes(&self) -> usize { + self.lits.iter().fold(0, |accum, lit| accum + lit.len()) + } + + /// Returns true if a character class with the given size would cause this + /// set to exceed its limits. + /// + /// The size given should correspond to the number of items in the class. + fn class_exceeds_limits(&self, size: usize) -> bool { + if size > self.limit_class { + return true; + } + // This is an approximation since codepoints in a char class can encode + // to 1-4 bytes. + let new_byte_count = if self.lits.is_empty() { + size + } else { + self.lits.iter().fold(0, |accum, lit| { + accum + + if lit.is_cut() { + // If the literal is cut, then we'll never add + // anything to it, so don't count it. + 0 + } else { + (lit.len() + 1) * size + } + }) + }; + new_byte_count > self.limit_size + } +} + +fn prefixes(expr: &Hir, lits: &mut Literals) { + match *expr.kind() { + HirKind::Literal(hir::Literal::Unicode(c)) => { + let mut buf = [0; 4]; + lits.cross_add(c.encode_utf8(&mut buf).as_bytes()); + } + HirKind::Literal(hir::Literal::Byte(b)) => { + lits.cross_add(&[b]); + } + HirKind::Class(hir::Class::Unicode(ref cls)) => { + if !lits.add_char_class(cls) { + lits.cut(); + } + } + HirKind::Class(hir::Class::Bytes(ref cls)) => { + if !lits.add_byte_class(cls) { + lits.cut(); + } + } + HirKind::Group(hir::Group { ref hir, .. }) => { + prefixes(&**hir, lits); + } + HirKind::Repetition(ref x) => match x.kind { + hir::RepetitionKind::ZeroOrOne => { + repeat_zero_or_one_literals(&x.hir, lits, prefixes); + } + hir::RepetitionKind::ZeroOrMore => { + repeat_zero_or_more_literals(&x.hir, lits, prefixes); + } + hir::RepetitionKind::OneOrMore => { + repeat_one_or_more_literals(&x.hir, lits, prefixes); + } + hir::RepetitionKind::Range(ref rng) => { + let (min, max) = match *rng { + hir::RepetitionRange::Exactly(m) => (m, Some(m)), + hir::RepetitionRange::AtLeast(m) => (m, None), + hir::RepetitionRange::Bounded(m, n) => (m, Some(n)), + }; + repeat_range_literals( + &x.hir, min, max, x.greedy, lits, prefixes, + ) + } + }, + HirKind::Concat(ref es) if es.is_empty() => {} + HirKind::Concat(ref es) if es.len() == 1 => prefixes(&es[0], lits), + HirKind::Concat(ref es) => { + for e in es { + if let HirKind::Anchor(hir::Anchor::StartText) = *e.kind() { + if !lits.is_empty() { + lits.cut(); + break; + } + lits.add(Literal::empty()); + continue; + } + let mut lits2 = lits.to_empty(); + prefixes(e, &mut lits2); + if !lits.cross_product(&lits2) || !lits2.any_complete() { + // If this expression couldn't yield any literal that + // could be extended, then we need to quit. Since we're + // short-circuiting, we also need to freeze every member. + lits.cut(); + break; + } + } + } + HirKind::Alternation(ref es) => { + alternate_literals(es, lits, prefixes); + } + _ => lits.cut(), + } +} + +fn suffixes(expr: &Hir, lits: &mut Literals) { + match *expr.kind() { + HirKind::Literal(hir::Literal::Unicode(c)) => { + let mut buf = [0u8; 4]; + let i = c.encode_utf8(&mut buf).len(); + let buf = &mut buf[..i]; + buf.reverse(); + lits.cross_add(buf); + } + HirKind::Literal(hir::Literal::Byte(b)) => { + lits.cross_add(&[b]); + } + HirKind::Class(hir::Class::Unicode(ref cls)) => { + if !lits.add_char_class_reverse(cls) { + lits.cut(); + } + } + HirKind::Class(hir::Class::Bytes(ref cls)) => { + if !lits.add_byte_class(cls) { + lits.cut(); + } + } + HirKind::Group(hir::Group { ref hir, .. }) => { + suffixes(&**hir, lits); + } + HirKind::Repetition(ref x) => match x.kind { + hir::RepetitionKind::ZeroOrOne => { + repeat_zero_or_one_literals(&x.hir, lits, suffixes); + } + hir::RepetitionKind::ZeroOrMore => { + repeat_zero_or_more_literals(&x.hir, lits, suffixes); + } + hir::RepetitionKind::OneOrMore => { + repeat_one_or_more_literals(&x.hir, lits, suffixes); + } + hir::RepetitionKind::Range(ref rng) => { + let (min, max) = match *rng { + hir::RepetitionRange::Exactly(m) => (m, Some(m)), + hir::RepetitionRange::AtLeast(m) => (m, None), + hir::RepetitionRange::Bounded(m, n) => (m, Some(n)), + }; + repeat_range_literals( + &x.hir, min, max, x.greedy, lits, suffixes, + ) + } + }, + HirKind::Concat(ref es) if es.is_empty() => {} + HirKind::Concat(ref es) if es.len() == 1 => suffixes(&es[0], lits), + HirKind::Concat(ref es) => { + for e in es.iter().rev() { + if let HirKind::Anchor(hir::Anchor::EndText) = *e.kind() { + if !lits.is_empty() { + lits.cut(); + break; + } + lits.add(Literal::empty()); + continue; + } + let mut lits2 = lits.to_empty(); + suffixes(e, &mut lits2); + if !lits.cross_product(&lits2) || !lits2.any_complete() { + // If this expression couldn't yield any literal that + // could be extended, then we need to quit. Since we're + // short-circuiting, we also need to freeze every member. + lits.cut(); + break; + } + } + } + HirKind::Alternation(ref es) => { + alternate_literals(es, lits, suffixes); + } + _ => lits.cut(), + } +} + +fn repeat_zero_or_one_literals<F: FnMut(&Hir, &mut Literals)>( + e: &Hir, + lits: &mut Literals, + mut f: F, +) { + let (mut lits2, mut lits3) = (lits.clone(), lits.to_empty()); + lits3.set_limit_size(lits.limit_size() / 2); + f(e, &mut lits3); + + if lits3.is_empty() || !lits2.cross_product(&lits3) { + lits.cut(); + return; + } + lits2.add(Literal::empty()); + if !lits.union(lits2) { + lits.cut(); + } +} + +fn repeat_zero_or_more_literals<F: FnMut(&Hir, &mut Literals)>( + e: &Hir, + lits: &mut Literals, + mut f: F, +) { + let (mut lits2, mut lits3) = (lits.clone(), lits.to_empty()); + lits3.set_limit_size(lits.limit_size() / 2); + f(e, &mut lits3); + + if lits3.is_empty() || !lits2.cross_product(&lits3) { + lits.cut(); + return; + } + lits2.cut(); + lits2.add(Literal::empty()); + if !lits.union(lits2) { + lits.cut(); + } +} + +fn repeat_one_or_more_literals<F: FnMut(&Hir, &mut Literals)>( + e: &Hir, + lits: &mut Literals, + mut f: F, +) { + f(e, lits); + lits.cut(); +} + +fn repeat_range_literals<F: FnMut(&Hir, &mut Literals)>( + e: &Hir, + min: u32, + max: Option<u32>, + greedy: bool, + lits: &mut Literals, + mut f: F, +) { + if min == 0 { + // This is a bit conservative. If `max` is set, then we could + // treat this as a finite set of alternations. For now, we + // just treat it as `e*`. + f( + &Hir::repetition(hir::Repetition { + kind: hir::RepetitionKind::ZeroOrMore, + greedy: greedy, + hir: Box::new(e.clone()), + }), + lits, + ); + } else { + if min > 0 { + let n = cmp::min(lits.limit_size, min as usize); + let es = iter::repeat(e.clone()).take(n).collect(); + f(&Hir::concat(es), lits); + if n < min as usize || lits.contains_empty() { + lits.cut(); + } + } + if max.map_or(true, |max| min < max) { + lits.cut(); + } + } +} + +fn alternate_literals<F: FnMut(&Hir, &mut Literals)>( + es: &[Hir], + lits: &mut Literals, + mut f: F, +) { + let mut lits2 = lits.to_empty(); + for e in es { + let mut lits3 = lits.to_empty(); + lits3.set_limit_size(lits.limit_size() / 5); + f(e, &mut lits3); + if lits3.is_empty() || !lits2.union(lits3) { + // If we couldn't find suffixes for *any* of the + // alternates, then the entire alternation has to be thrown + // away and any existing members must be frozen. Similarly, + // if the union couldn't complete, stop and freeze. + lits.cut(); + return; + } + } + if !lits.cross_product(&lits2) { + lits.cut(); + } +} + +impl fmt::Debug for Literals { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Literals") + .field("lits", &self.lits) + .field("limit_size", &self.limit_size) + .field("limit_class", &self.limit_class) + .finish() + } +} + +impl Literal { + /// Returns a new complete literal with the bytes given. + pub fn new(bytes: Vec<u8>) -> Literal { + Literal { v: bytes, cut: false } + } + + /// Returns a new complete empty literal. + pub fn empty() -> Literal { + Literal { v: vec![], cut: false } + } + + /// Returns true if this literal was "cut." + pub fn is_cut(&self) -> bool { + self.cut + } + + /// Cuts this literal. + pub fn cut(&mut self) { + self.cut = true; + } +} + +impl PartialEq for Literal { + fn eq(&self, other: &Literal) -> bool { + self.v == other.v + } +} + +impl PartialOrd for Literal { + fn partial_cmp(&self, other: &Literal) -> Option<cmp::Ordering> { + self.v.partial_cmp(&other.v) + } +} + +impl fmt::Debug for Literal { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.is_cut() { + write!(f, "Cut({})", escape_unicode(&self.v)) + } else { + write!(f, "Complete({})", escape_unicode(&self.v)) + } + } +} + +impl AsRef<[u8]> for Literal { + fn as_ref(&self) -> &[u8] { + &self.v + } +} + +impl ops::Deref for Literal { + type Target = Vec<u8>; + fn deref(&self) -> &Vec<u8> { + &self.v + } +} + +impl ops::DerefMut for Literal { + fn deref_mut(&mut self) -> &mut Vec<u8> { + &mut self.v + } +} + +fn position(needle: &[u8], mut haystack: &[u8]) -> Option<usize> { + let mut i = 0; + while haystack.len() >= needle.len() { + if needle == &haystack[..needle.len()] { + return Some(i); + } + i += 1; + haystack = &haystack[1..]; + } + None +} + +fn escape_unicode(bytes: &[u8]) -> String { + let show = match ::std::str::from_utf8(bytes) { + Ok(v) => v.to_string(), + Err(_) => escape_bytes(bytes), + }; + let mut space_escaped = String::new(); + for c in show.chars() { + if c.is_whitespace() { + let escaped = if c as u32 <= 0x7F { + escape_byte(c as u8) + } else { + if c as u32 <= 0xFFFF { + format!(r"\u{{{:04x}}}", c as u32) + } else { + format!(r"\U{{{:08x}}}", c as u32) + } + }; + space_escaped.push_str(&escaped); + } else { + space_escaped.push(c); + } + } + space_escaped +} + +fn escape_bytes(bytes: &[u8]) -> String { + let mut s = String::new(); + for &b in bytes { + s.push_str(&escape_byte(b)); + } + s +} + +fn escape_byte(byte: u8) -> String { + use std::ascii::escape_default; + + let escaped: Vec<u8> = escape_default(byte).collect(); + String::from_utf8_lossy(&escaped).into_owned() +} + +fn cls_char_count(cls: &hir::ClassUnicode) -> usize { + cls.iter().map(|&r| 1 + (r.end as u32) - (r.start as u32)).sum::<u32>() + as usize +} + +fn cls_byte_count(cls: &hir::ClassBytes) -> usize { + cls.iter().map(|&r| 1 + (r.end as u32) - (r.start as u32)).sum::<u32>() + as usize +} + +#[cfg(test)] +mod tests { + use std::fmt; + + use super::{escape_bytes, Literal, Literals}; + use hir::Hir; + use ParserBuilder; + + // To make test failures easier to read. + #[derive(Debug, Eq, PartialEq)] + struct Bytes(Vec<ULiteral>); + #[derive(Debug, Eq, PartialEq)] + struct Unicode(Vec<ULiteral>); + + fn escape_lits(blits: &[Literal]) -> Vec<ULiteral> { + let mut ulits = vec![]; + for blit in blits { + ulits + .push(ULiteral { v: escape_bytes(&blit), cut: blit.is_cut() }); + } + ulits + } + + fn create_lits<I: IntoIterator<Item = Literal>>(it: I) -> Literals { + Literals { + lits: it.into_iter().collect(), + limit_size: 0, + limit_class: 0, + } + } + + // Needs to be pub for 1.3? + #[derive(Clone, Eq, PartialEq)] + pub struct ULiteral { + v: String, + cut: bool, + } + + impl ULiteral { + fn is_cut(&self) -> bool { + self.cut + } + } + + impl fmt::Debug for ULiteral { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.is_cut() { + write!(f, "Cut({})", self.v) + } else { + write!(f, "Complete({})", self.v) + } + } + } + + impl PartialEq<Literal> for ULiteral { + fn eq(&self, other: &Literal) -> bool { + self.v.as_bytes() == &*other.v && self.is_cut() == other.is_cut() + } + } + + impl PartialEq<ULiteral> for Literal { + fn eq(&self, other: &ULiteral) -> bool { + &*self.v == other.v.as_bytes() && self.is_cut() == other.is_cut() + } + } + + #[allow(non_snake_case)] + fn C(s: &'static str) -> ULiteral { + ULiteral { v: s.to_owned(), cut: true } + } + #[allow(non_snake_case)] + fn M(s: &'static str) -> ULiteral { + ULiteral { v: s.to_owned(), cut: false } + } + + fn prefixes(lits: &mut Literals, expr: &Hir) { + lits.union_prefixes(expr); + } + + fn suffixes(lits: &mut Literals, expr: &Hir) { + lits.union_suffixes(expr); + } + + macro_rules! assert_lit_eq { + ($which:ident, $got_lits:expr, $($expected_lit:expr),*) => {{ + let expected: Vec<ULiteral> = vec![$($expected_lit),*]; + let lits = $got_lits; + assert_eq!( + $which(expected.clone()), + $which(escape_lits(lits.literals()))); + assert_eq!( + !expected.is_empty() && expected.iter().all(|l| !l.is_cut()), + lits.all_complete()); + assert_eq!( + expected.iter().any(|l| !l.is_cut()), + lits.any_complete()); + }}; + } + + macro_rules! test_lit { + ($name:ident, $which:ident, $re:expr) => { + test_lit!($name, $which, $re,); + }; + ($name:ident, $which:ident, $re:expr, $($lit:expr),*) => { + #[test] + fn $name() { + let expr = ParserBuilder::new() + .build() + .parse($re) + .unwrap(); + let lits = Literals::$which(&expr); + assert_lit_eq!(Unicode, lits, $($lit),*); + + let expr = ParserBuilder::new() + .allow_invalid_utf8(true) + .unicode(false) + .build() + .parse($re) + .unwrap(); + let lits = Literals::$which(&expr); + assert_lit_eq!(Bytes, lits, $($lit),*); + } + }; + } + + // ************************************************************************ + // Tests for prefix literal extraction. + // ************************************************************************ + + // Elementary tests. + test_lit!(pfx_one_lit1, prefixes, "a", M("a")); + test_lit!(pfx_one_lit2, prefixes, "abc", M("abc")); + test_lit!(pfx_one_lit3, prefixes, "(?u)☃", M("\\xe2\\x98\\x83")); + #[cfg(feature = "unicode-case")] + test_lit!(pfx_one_lit4, prefixes, "(?ui)☃", M("\\xe2\\x98\\x83")); + test_lit!(pfx_class1, prefixes, "[1-4]", M("1"), M("2"), M("3"), M("4")); + test_lit!( + pfx_class2, + prefixes, + "(?u)[☃Ⅰ]", + M("\\xe2\\x85\\xa0"), + M("\\xe2\\x98\\x83") + ); + #[cfg(feature = "unicode-case")] + test_lit!( + pfx_class3, + prefixes, + "(?ui)[☃Ⅰ]", + M("\\xe2\\x85\\xa0"), + M("\\xe2\\x85\\xb0"), + M("\\xe2\\x98\\x83") + ); + test_lit!(pfx_one_lit_casei1, prefixes, "(?i-u)a", M("A"), M("a")); + test_lit!( + pfx_one_lit_casei2, + prefixes, + "(?i-u)abc", + M("ABC"), + M("aBC"), + M("AbC"), + M("abC"), + M("ABc"), + M("aBc"), + M("Abc"), + M("abc") + ); + test_lit!(pfx_group1, prefixes, "(a)", M("a")); + test_lit!(pfx_rep_zero_or_one1, prefixes, "a?"); + test_lit!(pfx_rep_zero_or_one2, prefixes, "(?:abc)?"); + test_lit!(pfx_rep_zero_or_more1, prefixes, "a*"); + test_lit!(pfx_rep_zero_or_more2, prefixes, "(?:abc)*"); + test_lit!(pfx_rep_one_or_more1, prefixes, "a+", C("a")); + test_lit!(pfx_rep_one_or_more2, prefixes, "(?:abc)+", C("abc")); + test_lit!(pfx_rep_nested_one_or_more, prefixes, "(?:a+)+", C("a")); + test_lit!(pfx_rep_range1, prefixes, "a{0}"); + test_lit!(pfx_rep_range2, prefixes, "a{0,}"); + test_lit!(pfx_rep_range3, prefixes, "a{0,1}"); + test_lit!(pfx_rep_range4, prefixes, "a{1}", M("a")); + test_lit!(pfx_rep_range5, prefixes, "a{2}", M("aa")); + test_lit!(pfx_rep_range6, prefixes, "a{1,2}", C("a")); + test_lit!(pfx_rep_range7, prefixes, "a{2,3}", C("aa")); + + // Test regexes with concatenations. + test_lit!(pfx_cat1, prefixes, "(?:a)(?:b)", M("ab")); + test_lit!(pfx_cat2, prefixes, "[ab]z", M("az"), M("bz")); + test_lit!( + pfx_cat3, + prefixes, + "(?i-u)[ab]z", + M("AZ"), + M("BZ"), + M("aZ"), + M("bZ"), + M("Az"), + M("Bz"), + M("az"), + M("bz") + ); + test_lit!( + pfx_cat4, + prefixes, + "[ab][yz]", + M("ay"), + M("by"), + M("az"), + M("bz") + ); + test_lit!(pfx_cat5, prefixes, "a*b", C("a"), M("b")); + test_lit!(pfx_cat6, prefixes, "a*b*c", C("a"), C("b"), M("c")); + test_lit!(pfx_cat7, prefixes, "a*b*c+", C("a"), C("b"), C("c")); + test_lit!(pfx_cat8, prefixes, "a*b+c", C("a"), C("b")); + test_lit!(pfx_cat9, prefixes, "a*b+c*", C("a"), C("b")); + test_lit!(pfx_cat10, prefixes, "ab*", C("ab"), M("a")); + test_lit!(pfx_cat11, prefixes, "ab*c", C("ab"), M("ac")); + test_lit!(pfx_cat12, prefixes, "ab+", C("ab")); + test_lit!(pfx_cat13, prefixes, "ab+c", C("ab")); + test_lit!(pfx_cat14, prefixes, "a^", C("a")); + test_lit!(pfx_cat15, prefixes, "$a"); + test_lit!(pfx_cat16, prefixes, r"ab*c", C("ab"), M("ac")); + test_lit!(pfx_cat17, prefixes, r"ab+c", C("ab")); + test_lit!(pfx_cat18, prefixes, r"z*azb", C("z"), M("azb")); + test_lit!(pfx_cat19, prefixes, "a.z", C("a")); + + // Test regexes with alternations. + test_lit!(pfx_alt1, prefixes, "a|b", M("a"), M("b")); + test_lit!(pfx_alt2, prefixes, "[1-3]|b", M("1"), M("2"), M("3"), M("b")); + test_lit!(pfx_alt3, prefixes, "y(?:a|b)z", M("yaz"), M("ybz")); + test_lit!(pfx_alt4, prefixes, "a|b*"); + test_lit!(pfx_alt5, prefixes, "a|b+", M("a"), C("b")); + test_lit!(pfx_alt6, prefixes, "a|(?:b|c*)"); + test_lit!( + pfx_alt7, + prefixes, + "(a|b)*c|(a|ab)*c", + C("a"), + C("b"), + M("c"), + C("a"), + C("ab"), + M("c") + ); + test_lit!(pfx_alt8, prefixes, "a*b|c", C("a"), M("b"), M("c")); + + // Test regexes with empty assertions. + test_lit!(pfx_empty1, prefixes, "^a", M("a")); + test_lit!(pfx_empty2, prefixes, "a${2}", C("a")); + test_lit!(pfx_empty3, prefixes, "^abc", M("abc")); + test_lit!(pfx_empty4, prefixes, "(?:^abc)|(?:^z)", M("abc"), M("z")); + + // Make sure some curious regexes have no prefixes. + test_lit!(pfx_nothing1, prefixes, "."); + test_lit!(pfx_nothing2, prefixes, "(?s)."); + test_lit!(pfx_nothing3, prefixes, "^"); + test_lit!(pfx_nothing4, prefixes, "$"); + test_lit!(pfx_nothing6, prefixes, "(?m)$"); + test_lit!(pfx_nothing7, prefixes, r"\b"); + test_lit!(pfx_nothing8, prefixes, r"\B"); + + // Test a few regexes that defeat any prefix literal detection. + test_lit!(pfx_defeated1, prefixes, ".a"); + test_lit!(pfx_defeated2, prefixes, "(?s).a"); + test_lit!(pfx_defeated3, prefixes, "a*b*c*"); + test_lit!(pfx_defeated4, prefixes, "a|."); + test_lit!(pfx_defeated5, prefixes, ".|a"); + test_lit!(pfx_defeated6, prefixes, "a|^"); + test_lit!(pfx_defeated7, prefixes, ".(?:a(?:b)(?:c))"); + test_lit!(pfx_defeated8, prefixes, "$a"); + test_lit!(pfx_defeated9, prefixes, "(?m)$a"); + test_lit!(pfx_defeated10, prefixes, r"\ba"); + test_lit!(pfx_defeated11, prefixes, r"\Ba"); + test_lit!(pfx_defeated12, prefixes, "^*a"); + test_lit!(pfx_defeated13, prefixes, "^+a"); + + test_lit!( + pfx_crazy1, + prefixes, + r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", + C("Mo\\'am"), + C("Mu\\'am"), + C("Moam"), + C("Muam") + ); + + // ************************************************************************ + // Tests for quiting prefix literal search. + // ************************************************************************ + + macro_rules! test_exhausted { + ($name:ident, $which:ident, $re:expr) => { + test_exhausted!($name, $which, $re,); + }; + ($name:ident, $which:ident, $re:expr, $($lit:expr),*) => { + #[test] + fn $name() { + let expr = ParserBuilder::new() + .build() + .parse($re) + .unwrap(); + let mut lits = Literals::empty(); + lits.set_limit_size(20).set_limit_class(10); + $which(&mut lits, &expr); + assert_lit_eq!(Unicode, lits, $($lit),*); + + let expr = ParserBuilder::new() + .allow_invalid_utf8(true) + .unicode(false) + .build() + .parse($re) + .unwrap(); + let mut lits = Literals::empty(); + lits.set_limit_size(20).set_limit_class(10); + $which(&mut lits, &expr); + assert_lit_eq!(Bytes, lits, $($lit),*); + } + }; + } + + // These test use a much lower limit than the default so that we can + // write test cases of reasonable size. + test_exhausted!(pfx_exhausted1, prefixes, "[a-z]"); + test_exhausted!(pfx_exhausted2, prefixes, "[a-z]*A"); + test_exhausted!(pfx_exhausted3, prefixes, "A[a-z]Z", C("A")); + test_exhausted!( + pfx_exhausted4, + prefixes, + "(?i-u)foobar", + C("FO"), + C("fO"), + C("Fo"), + C("fo") + ); + test_exhausted!( + pfx_exhausted5, + prefixes, + "(?:ab){100}", + C("abababababababababab") + ); + test_exhausted!( + pfx_exhausted6, + prefixes, + "(?:(?:ab){100})*cd", + C("ababababab"), + M("cd") + ); + test_exhausted!( + pfx_exhausted7, + prefixes, + "z(?:(?:ab){100})*cd", + C("zababababab"), + M("zcd") + ); + test_exhausted!( + pfx_exhausted8, + prefixes, + "aaaaaaaaaaaaaaaaaaaaz", + C("aaaaaaaaaaaaaaaaaaaa") + ); + + // ************************************************************************ + // Tests for suffix literal extraction. + // ************************************************************************ + + // Elementary tests. + test_lit!(sfx_one_lit1, suffixes, "a", M("a")); + test_lit!(sfx_one_lit2, suffixes, "abc", M("abc")); + test_lit!(sfx_one_lit3, suffixes, "(?u)☃", M("\\xe2\\x98\\x83")); + #[cfg(feature = "unicode-case")] + test_lit!(sfx_one_lit4, suffixes, "(?ui)☃", M("\\xe2\\x98\\x83")); + test_lit!(sfx_class1, suffixes, "[1-4]", M("1"), M("2"), M("3"), M("4")); + test_lit!( + sfx_class2, + suffixes, + "(?u)[☃Ⅰ]", + M("\\xe2\\x85\\xa0"), + M("\\xe2\\x98\\x83") + ); + #[cfg(feature = "unicode-case")] + test_lit!( + sfx_class3, + suffixes, + "(?ui)[☃Ⅰ]", + M("\\xe2\\x85\\xa0"), + M("\\xe2\\x85\\xb0"), + M("\\xe2\\x98\\x83") + ); + test_lit!(sfx_one_lit_casei1, suffixes, "(?i-u)a", M("A"), M("a")); + test_lit!( + sfx_one_lit_casei2, + suffixes, + "(?i-u)abc", + M("ABC"), + M("ABc"), + M("AbC"), + M("Abc"), + M("aBC"), + M("aBc"), + M("abC"), + M("abc") + ); + test_lit!(sfx_group1, suffixes, "(a)", M("a")); + test_lit!(sfx_rep_zero_or_one1, suffixes, "a?"); + test_lit!(sfx_rep_zero_or_one2, suffixes, "(?:abc)?"); + test_lit!(sfx_rep_zero_or_more1, suffixes, "a*"); + test_lit!(sfx_rep_zero_or_more2, suffixes, "(?:abc)*"); + test_lit!(sfx_rep_one_or_more1, suffixes, "a+", C("a")); + test_lit!(sfx_rep_one_or_more2, suffixes, "(?:abc)+", C("abc")); + test_lit!(sfx_rep_nested_one_or_more, suffixes, "(?:a+)+", C("a")); + test_lit!(sfx_rep_range1, suffixes, "a{0}"); + test_lit!(sfx_rep_range2, suffixes, "a{0,}"); + test_lit!(sfx_rep_range3, suffixes, "a{0,1}"); + test_lit!(sfx_rep_range4, suffixes, "a{1}", M("a")); + test_lit!(sfx_rep_range5, suffixes, "a{2}", M("aa")); + test_lit!(sfx_rep_range6, suffixes, "a{1,2}", C("a")); + test_lit!(sfx_rep_range7, suffixes, "a{2,3}", C("aa")); + + // Test regexes with concatenations. + test_lit!(sfx_cat1, suffixes, "(?:a)(?:b)", M("ab")); + test_lit!(sfx_cat2, suffixes, "[ab]z", M("az"), M("bz")); + test_lit!( + sfx_cat3, + suffixes, + "(?i-u)[ab]z", + M("AZ"), + M("Az"), + M("BZ"), + M("Bz"), + M("aZ"), + M("az"), + M("bZ"), + M("bz") + ); + test_lit!( + sfx_cat4, + suffixes, + "[ab][yz]", + M("ay"), + M("az"), + M("by"), + M("bz") + ); + test_lit!(sfx_cat5, suffixes, "a*b", C("ab"), M("b")); + test_lit!(sfx_cat6, suffixes, "a*b*c", C("bc"), C("ac"), M("c")); + test_lit!(sfx_cat7, suffixes, "a*b*c+", C("c")); + test_lit!(sfx_cat8, suffixes, "a*b+c", C("bc")); + test_lit!(sfx_cat9, suffixes, "a*b+c*", C("c"), C("b")); + test_lit!(sfx_cat10, suffixes, "ab*", C("b"), M("a")); + test_lit!(sfx_cat11, suffixes, "ab*c", C("bc"), M("ac")); + test_lit!(sfx_cat12, suffixes, "ab+", C("b")); + test_lit!(sfx_cat13, suffixes, "ab+c", C("bc")); + test_lit!(sfx_cat14, suffixes, "a^"); + test_lit!(sfx_cat15, suffixes, "$a", C("a")); + test_lit!(sfx_cat16, suffixes, r"ab*c", C("bc"), M("ac")); + test_lit!(sfx_cat17, suffixes, r"ab+c", C("bc")); + test_lit!(sfx_cat18, suffixes, r"z*azb", C("zazb"), M("azb")); + test_lit!(sfx_cat19, suffixes, "a.z", C("z")); + + // Test regexes with alternations. + test_lit!(sfx_alt1, suffixes, "a|b", M("a"), M("b")); + test_lit!(sfx_alt2, suffixes, "[1-3]|b", M("1"), M("2"), M("3"), M("b")); + test_lit!(sfx_alt3, suffixes, "y(?:a|b)z", M("yaz"), M("ybz")); + test_lit!(sfx_alt4, suffixes, "a|b*"); + test_lit!(sfx_alt5, suffixes, "a|b+", M("a"), C("b")); + test_lit!(sfx_alt6, suffixes, "a|(?:b|c*)"); + test_lit!( + sfx_alt7, + suffixes, + "(a|b)*c|(a|ab)*c", + C("ac"), + C("bc"), + M("c"), + C("ac"), + C("abc"), + M("c") + ); + test_lit!(sfx_alt8, suffixes, "a*b|c", C("ab"), M("b"), M("c")); + + // Test regexes with empty assertions. + test_lit!(sfx_empty1, suffixes, "a$", M("a")); + test_lit!(sfx_empty2, suffixes, "${2}a", C("a")); + + // Make sure some curious regexes have no suffixes. + test_lit!(sfx_nothing1, suffixes, "."); + test_lit!(sfx_nothing2, suffixes, "(?s)."); + test_lit!(sfx_nothing3, suffixes, "^"); + test_lit!(sfx_nothing4, suffixes, "$"); + test_lit!(sfx_nothing6, suffixes, "(?m)$"); + test_lit!(sfx_nothing7, suffixes, r"\b"); + test_lit!(sfx_nothing8, suffixes, r"\B"); + + // Test a few regexes that defeat any suffix literal detection. + test_lit!(sfx_defeated1, suffixes, "a."); + test_lit!(sfx_defeated2, suffixes, "(?s)a."); + test_lit!(sfx_defeated3, suffixes, "a*b*c*"); + test_lit!(sfx_defeated4, suffixes, "a|."); + test_lit!(sfx_defeated5, suffixes, ".|a"); + test_lit!(sfx_defeated6, suffixes, "a|^"); + test_lit!(sfx_defeated7, suffixes, "(?:a(?:b)(?:c))."); + test_lit!(sfx_defeated8, suffixes, "a^"); + test_lit!(sfx_defeated9, suffixes, "(?m)a$"); + test_lit!(sfx_defeated10, suffixes, r"a\b"); + test_lit!(sfx_defeated11, suffixes, r"a\B"); + test_lit!(sfx_defeated12, suffixes, "a^*"); + test_lit!(sfx_defeated13, suffixes, "a^+"); + + // These test use a much lower limit than the default so that we can + // write test cases of reasonable size. + test_exhausted!(sfx_exhausted1, suffixes, "[a-z]"); + test_exhausted!(sfx_exhausted2, suffixes, "A[a-z]*"); + test_exhausted!(sfx_exhausted3, suffixes, "A[a-z]Z", C("Z")); + test_exhausted!( + sfx_exhausted4, + suffixes, + "(?i-u)foobar", + C("AR"), + C("Ar"), + C("aR"), + C("ar") + ); + test_exhausted!( + sfx_exhausted5, + suffixes, + "(?:ab){100}", + C("abababababababababab") + ); + test_exhausted!( + sfx_exhausted6, + suffixes, + "cd(?:(?:ab){100})*", + C("ababababab"), + M("cd") + ); + test_exhausted!( + sfx_exhausted7, + suffixes, + "cd(?:(?:ab){100})*z", + C("abababababz"), + M("cdz") + ); + test_exhausted!( + sfx_exhausted8, + suffixes, + "zaaaaaaaaaaaaaaaaaaaa", + C("aaaaaaaaaaaaaaaaaaaa") + ); + + // ************************************************************************ + // Tests for generating unambiguous literal sets. + // ************************************************************************ + + macro_rules! test_unamb { + ($name:ident, $given:expr, $expected:expr) => { + #[test] + fn $name() { + let given: Vec<Literal> = $given + .into_iter() + .map(|ul| { + let cut = ul.is_cut(); + Literal { v: ul.v.into_bytes(), cut: cut } + }) + .collect(); + let lits = create_lits(given); + let got = lits.unambiguous_prefixes(); + assert_eq!($expected, escape_lits(got.literals())); + } + }; + } + + test_unamb!(unambiguous1, vec![M("z"), M("azb")], vec![C("a"), C("z")]); + test_unamb!( + unambiguous2, + vec![M("zaaaaaa"), M("aa")], + vec![C("aa"), C("z")] + ); + test_unamb!( + unambiguous3, + vec![M("Sherlock"), M("Watson")], + vec![M("Sherlock"), M("Watson")] + ); + test_unamb!(unambiguous4, vec![M("abc"), M("bc")], vec![C("a"), C("bc")]); + test_unamb!(unambiguous5, vec![M("bc"), M("abc")], vec![C("a"), C("bc")]); + test_unamb!(unambiguous6, vec![M("a"), M("aa")], vec![C("a")]); + test_unamb!(unambiguous7, vec![M("aa"), M("a")], vec![C("a")]); + test_unamb!(unambiguous8, vec![M("ab"), M("a")], vec![C("a")]); + test_unamb!( + unambiguous9, + vec![M("ac"), M("bc"), M("c"), M("ac"), M("abc"), M("c")], + vec![C("a"), C("b"), C("c")] + ); + test_unamb!( + unambiguous10, + vec![M("Mo'"), M("Mu'"), M("Mo"), M("Mu")], + vec![C("Mo"), C("Mu")] + ); + test_unamb!( + unambiguous11, + vec![M("zazb"), M("azb")], + vec![C("a"), C("z")] + ); + test_unamb!(unambiguous12, vec![M("foo"), C("foo")], vec![C("foo")]); + test_unamb!( + unambiguous13, + vec![M("ABCX"), M("CDAX"), M("BCX")], + vec![C("A"), C("BCX"), C("CD")] + ); + test_unamb!( + unambiguous14, + vec![M("IMGX"), M("MVIX"), M("MGX"), M("DSX")], + vec![M("DSX"), C("I"), C("MGX"), C("MV")] + ); + test_unamb!( + unambiguous15, + vec![M("IMG_"), M("MG_"), M("CIMG")], + vec![C("C"), C("I"), C("MG_")] + ); + + // ************************************************************************ + // Tests for suffix trimming. + // ************************************************************************ + macro_rules! test_trim { + ($name:ident, $trim:expr, $given:expr, $expected:expr) => { + #[test] + fn $name() { + let given: Vec<Literal> = $given + .into_iter() + .map(|ul| { + let cut = ul.is_cut(); + Literal { v: ul.v.into_bytes(), cut: cut } + }) + .collect(); + let lits = create_lits(given); + let got = lits.trim_suffix($trim).unwrap(); + assert_eq!($expected, escape_lits(got.literals())); + } + }; + } + + test_trim!(trim1, 1, vec![M("ab"), M("yz")], vec![C("a"), C("y")]); + test_trim!(trim2, 1, vec![M("abc"), M("abd")], vec![C("ab")]); + test_trim!(trim3, 2, vec![M("abc"), M("abd")], vec![C("a")]); + test_trim!(trim4, 2, vec![M("abc"), M("ghij")], vec![C("a"), C("gh")]); + + // ************************************************************************ + // Tests for longest common prefix. + // ************************************************************************ + + macro_rules! test_lcp { + ($name:ident, $given:expr, $expected:expr) => { + #[test] + fn $name() { + let given: Vec<Literal> = $given + .into_iter() + .map(|s: &str| Literal { + v: s.to_owned().into_bytes(), + cut: false, + }) + .collect(); + let lits = create_lits(given); + let got = lits.longest_common_prefix(); + assert_eq!($expected, escape_bytes(got)); + } + }; + } + + test_lcp!(lcp1, vec!["a"], "a"); + test_lcp!(lcp2, vec![], ""); + test_lcp!(lcp3, vec!["a", "b"], ""); + test_lcp!(lcp4, vec!["ab", "ab"], "ab"); + test_lcp!(lcp5, vec!["ab", "a"], "a"); + test_lcp!(lcp6, vec!["a", "ab"], "a"); + test_lcp!(lcp7, vec!["ab", "b"], ""); + test_lcp!(lcp8, vec!["b", "ab"], ""); + test_lcp!(lcp9, vec!["foobar", "foobaz"], "fooba"); + test_lcp!(lcp10, vec!["foobar", "foobaz", "a"], ""); + test_lcp!(lcp11, vec!["a", "foobar", "foobaz"], ""); + test_lcp!(lcp12, vec!["foo", "flub", "flab", "floo"], "f"); + + // ************************************************************************ + // Tests for longest common suffix. + // ************************************************************************ + + macro_rules! test_lcs { + ($name:ident, $given:expr, $expected:expr) => { + #[test] + fn $name() { + let given: Vec<Literal> = $given + .into_iter() + .map(|s: &str| Literal { + v: s.to_owned().into_bytes(), + cut: false, + }) + .collect(); + let lits = create_lits(given); + let got = lits.longest_common_suffix(); + assert_eq!($expected, escape_bytes(got)); + } + }; + } + + test_lcs!(lcs1, vec!["a"], "a"); + test_lcs!(lcs2, vec![], ""); + test_lcs!(lcs3, vec!["a", "b"], ""); + test_lcs!(lcs4, vec!["ab", "ab"], "ab"); + test_lcs!(lcs5, vec!["ab", "a"], ""); + test_lcs!(lcs6, vec!["a", "ab"], ""); + test_lcs!(lcs7, vec!["ab", "b"], "b"); + test_lcs!(lcs8, vec!["b", "ab"], "b"); + test_lcs!(lcs9, vec!["barfoo", "bazfoo"], "foo"); + test_lcs!(lcs10, vec!["barfoo", "bazfoo", "a"], ""); + test_lcs!(lcs11, vec!["a", "barfoo", "bazfoo"], ""); + test_lcs!(lcs12, vec!["flub", "bub", "boob", "dub"], "b"); +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/mod.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/mod.rs new file mode 100644 index 0000000..67411fc --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/mod.rs @@ -0,0 +1,2288 @@ +/*! +Defines a high-level intermediate representation for regular expressions. +*/ +use std::char; +use std::cmp; +use std::error; +use std::fmt; +use std::result; +use std::u8; + +use ast::Span; +use hir::interval::{Interval, IntervalSet, IntervalSetIter}; +use unicode; + +pub use hir::visitor::{visit, Visitor}; +pub use unicode::CaseFoldError; + +mod interval; +pub mod literal; +pub mod print; +pub mod translate; +mod visitor; + +/// An error that can occur while translating an `Ast` to a `Hir`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Error { + /// The kind of error. + kind: ErrorKind, + /// The original pattern that the translator's Ast was parsed from. Every + /// span in an error is a valid range into this string. + pattern: String, + /// The span of this error, derived from the Ast given to the translator. + span: Span, +} + +impl Error { + /// Return the type of this error. + pub fn kind(&self) -> &ErrorKind { + &self.kind + } + + /// The original pattern string in which this error occurred. + /// + /// Every span reported by this error is reported in terms of this string. + pub fn pattern(&self) -> &str { + &self.pattern + } + + /// Return the span at which this error occurred. + pub fn span(&self) -> &Span { + &self.span + } +} + +/// The type of an error that occurred while building an `Hir`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ErrorKind { + /// This error occurs when a Unicode feature is used when Unicode + /// support is disabled. For example `(?-u:\pL)` would trigger this error. + UnicodeNotAllowed, + /// This error occurs when translating a pattern that could match a byte + /// sequence that isn't UTF-8 and `allow_invalid_utf8` was disabled. + InvalidUtf8, + /// This occurs when an unrecognized Unicode property name could not + /// be found. + UnicodePropertyNotFound, + /// This occurs when an unrecognized Unicode property value could not + /// be found. + UnicodePropertyValueNotFound, + /// This occurs when a Unicode-aware Perl character class (`\w`, `\s` or + /// `\d`) could not be found. This can occur when the `unicode-perl` + /// crate feature is not enabled. + UnicodePerlClassNotFound, + /// This occurs when the Unicode simple case mapping tables are not + /// available, and the regular expression required Unicode aware case + /// insensitivity. + UnicodeCaseUnavailable, + /// This occurs when the translator attempts to construct a character class + /// that is empty. + /// + /// Note that this restriction in the translator may be removed in the + /// future. + EmptyClassNotAllowed, + /// Hints that destructuring should not be exhaustive. + /// + /// This enum may grow additional variants, so this makes sure clients + /// don't count on exhaustive matching. (Otherwise, adding a new variant + /// could break existing code.) + #[doc(hidden)] + __Nonexhaustive, +} + +impl ErrorKind { + // TODO: Remove this method entirely on the next breaking semver release. + #[allow(deprecated)] + fn description(&self) -> &str { + use self::ErrorKind::*; + match *self { + UnicodeNotAllowed => "Unicode not allowed here", + InvalidUtf8 => "pattern can match invalid UTF-8", + UnicodePropertyNotFound => "Unicode property not found", + UnicodePropertyValueNotFound => "Unicode property value not found", + UnicodePerlClassNotFound => { + "Unicode-aware Perl class not found \ + (make sure the unicode-perl feature is enabled)" + } + UnicodeCaseUnavailable => { + "Unicode-aware case insensitivity matching is not available \ + (make sure the unicode-case feature is enabled)" + } + EmptyClassNotAllowed => "empty character classes are not allowed", + __Nonexhaustive => unreachable!(), + } + } +} + +impl error::Error for Error { + // TODO: Remove this method entirely on the next breaking semver release. + #[allow(deprecated)] + fn description(&self) -> &str { + self.kind.description() + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + ::error::Formatter::from(self).fmt(f) + } +} + +impl fmt::Display for ErrorKind { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // TODO: Remove this on the next breaking semver release. + #[allow(deprecated)] + f.write_str(self.description()) + } +} + +/// A high-level intermediate representation (HIR) for a regular expression. +/// +/// The HIR of a regular expression represents an intermediate step between its +/// abstract syntax (a structured description of the concrete syntax) and +/// compiled byte codes. The purpose of HIR is to make regular expressions +/// easier to analyze. In particular, the AST is much more complex than the +/// HIR. For example, while an AST supports arbitrarily nested character +/// classes, the HIR will flatten all nested classes into a single set. The HIR +/// will also "compile away" every flag present in the concrete syntax. For +/// example, users of HIR expressions never need to worry about case folding; +/// it is handled automatically by the translator (e.g., by translating `(?i)A` +/// to `[aA]`). +/// +/// If the HIR was produced by a translator that disallows invalid UTF-8, then +/// the HIR is guaranteed to match UTF-8 exclusively. +/// +/// This type defines its own destructor that uses constant stack space and +/// heap space proportional to the size of the HIR. +/// +/// The specific type of an HIR expression can be accessed via its `kind` +/// or `into_kind` methods. This extra level of indirection exists for two +/// reasons: +/// +/// 1. Construction of an HIR expression *must* use the constructor methods +/// on this `Hir` type instead of building the `HirKind` values directly. +/// This permits construction to enforce invariants like "concatenations +/// always consist of two or more sub-expressions." +/// 2. Every HIR expression contains attributes that are defined inductively, +/// and can be computed cheaply during the construction process. For +/// example, one such attribute is whether the expression must match at the +/// beginning of the text. +/// +/// Also, an `Hir`'s `fmt::Display` implementation prints an HIR as a regular +/// expression pattern string, and uses constant stack space and heap space +/// proportional to the size of the `Hir`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Hir { + /// The underlying HIR kind. + kind: HirKind, + /// Analysis info about this HIR, computed during construction. + info: HirInfo, +} + +/// The kind of an arbitrary `Hir` expression. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum HirKind { + /// The empty regular expression, which matches everything, including the + /// empty string. + Empty, + /// A single literal character that matches exactly this character. + Literal(Literal), + /// A single character class that matches any of the characters in the + /// class. A class can either consist of Unicode scalar values as + /// characters, or it can use bytes. + Class(Class), + /// An anchor assertion. An anchor assertion match always has zero length. + Anchor(Anchor), + /// A word boundary assertion, which may or may not be Unicode aware. A + /// word boundary assertion match always has zero length. + WordBoundary(WordBoundary), + /// A repetition operation applied to a child expression. + Repetition(Repetition), + /// A possibly capturing group, which contains a child expression. + Group(Group), + /// A concatenation of expressions. A concatenation always has at least two + /// child expressions. + /// + /// A concatenation matches only if each of its child expression matches + /// one after the other. + Concat(Vec<Hir>), + /// An alternation of expressions. An alternation always has at least two + /// child expressions. + /// + /// An alternation matches only if at least one of its child expression + /// matches. If multiple expressions match, then the leftmost is preferred. + Alternation(Vec<Hir>), +} + +impl Hir { + /// Returns a reference to the underlying HIR kind. + pub fn kind(&self) -> &HirKind { + &self.kind + } + + /// Consumes ownership of this HIR expression and returns its underlying + /// `HirKind`. + pub fn into_kind(mut self) -> HirKind { + use std::mem; + mem::replace(&mut self.kind, HirKind::Empty) + } + + /// Returns an empty HIR expression. + /// + /// An empty HIR expression always matches, including the empty string. + pub fn empty() -> Hir { + let mut info = HirInfo::new(); + info.set_always_utf8(true); + info.set_all_assertions(true); + info.set_anchored_start(false); + info.set_anchored_end(false); + info.set_line_anchored_start(false); + info.set_line_anchored_end(false); + info.set_any_anchored_start(false); + info.set_any_anchored_end(false); + info.set_match_empty(true); + info.set_literal(true); + info.set_alternation_literal(true); + Hir { kind: HirKind::Empty, info: info } + } + + /// Creates a literal HIR expression. + /// + /// If the given literal has a `Byte` variant with an ASCII byte, then this + /// method panics. This enforces the invariant that `Byte` variants are + /// only used to express matching of invalid UTF-8. + pub fn literal(lit: Literal) -> Hir { + if let Literal::Byte(b) = lit { + assert!(b > 0x7F); + } + + let mut info = HirInfo::new(); + info.set_always_utf8(lit.is_unicode()); + info.set_all_assertions(false); + info.set_anchored_start(false); + info.set_anchored_end(false); + info.set_line_anchored_start(false); + info.set_line_anchored_end(false); + info.set_any_anchored_start(false); + info.set_any_anchored_end(false); + info.set_match_empty(false); + info.set_literal(true); + info.set_alternation_literal(true); + Hir { kind: HirKind::Literal(lit), info: info } + } + + /// Creates a class HIR expression. + pub fn class(class: Class) -> Hir { + let mut info = HirInfo::new(); + info.set_always_utf8(class.is_always_utf8()); + info.set_all_assertions(false); + info.set_anchored_start(false); + info.set_anchored_end(false); + info.set_line_anchored_start(false); + info.set_line_anchored_end(false); + info.set_any_anchored_start(false); + info.set_any_anchored_end(false); + info.set_match_empty(false); + info.set_literal(false); + info.set_alternation_literal(false); + Hir { kind: HirKind::Class(class), info: info } + } + + /// Creates an anchor assertion HIR expression. + pub fn anchor(anchor: Anchor) -> Hir { + let mut info = HirInfo::new(); + info.set_always_utf8(true); + info.set_all_assertions(true); + info.set_anchored_start(false); + info.set_anchored_end(false); + info.set_line_anchored_start(false); + info.set_line_anchored_end(false); + info.set_any_anchored_start(false); + info.set_any_anchored_end(false); + info.set_match_empty(true); + info.set_literal(false); + info.set_alternation_literal(false); + if let Anchor::StartText = anchor { + info.set_anchored_start(true); + info.set_line_anchored_start(true); + info.set_any_anchored_start(true); + } + if let Anchor::EndText = anchor { + info.set_anchored_end(true); + info.set_line_anchored_end(true); + info.set_any_anchored_end(true); + } + if let Anchor::StartLine = anchor { + info.set_line_anchored_start(true); + } + if let Anchor::EndLine = anchor { + info.set_line_anchored_end(true); + } + Hir { kind: HirKind::Anchor(anchor), info: info } + } + + /// Creates a word boundary assertion HIR expression. + pub fn word_boundary(word_boundary: WordBoundary) -> Hir { + let mut info = HirInfo::new(); + info.set_always_utf8(true); + info.set_all_assertions(true); + info.set_anchored_start(false); + info.set_anchored_end(false); + info.set_line_anchored_start(false); + info.set_line_anchored_end(false); + info.set_any_anchored_start(false); + info.set_any_anchored_end(false); + info.set_literal(false); + info.set_alternation_literal(false); + // A negated word boundary matches the empty string, but a normal + // word boundary does not! + info.set_match_empty(word_boundary.is_negated()); + // Negated ASCII word boundaries can match invalid UTF-8. + if let WordBoundary::AsciiNegate = word_boundary { + info.set_always_utf8(false); + } + Hir { kind: HirKind::WordBoundary(word_boundary), info: info } + } + + /// Creates a repetition HIR expression. + pub fn repetition(rep: Repetition) -> Hir { + let mut info = HirInfo::new(); + info.set_always_utf8(rep.hir.is_always_utf8()); + info.set_all_assertions(rep.hir.is_all_assertions()); + // If this operator can match the empty string, then it can never + // be anchored. + info.set_anchored_start( + !rep.is_match_empty() && rep.hir.is_anchored_start(), + ); + info.set_anchored_end( + !rep.is_match_empty() && rep.hir.is_anchored_end(), + ); + info.set_line_anchored_start( + !rep.is_match_empty() && rep.hir.is_anchored_start(), + ); + info.set_line_anchored_end( + !rep.is_match_empty() && rep.hir.is_anchored_end(), + ); + info.set_any_anchored_start(rep.hir.is_any_anchored_start()); + info.set_any_anchored_end(rep.hir.is_any_anchored_end()); + info.set_match_empty(rep.is_match_empty() || rep.hir.is_match_empty()); + info.set_literal(false); + info.set_alternation_literal(false); + Hir { kind: HirKind::Repetition(rep), info: info } + } + + /// Creates a group HIR expression. + pub fn group(group: Group) -> Hir { + let mut info = HirInfo::new(); + info.set_always_utf8(group.hir.is_always_utf8()); + info.set_all_assertions(group.hir.is_all_assertions()); + info.set_anchored_start(group.hir.is_anchored_start()); + info.set_anchored_end(group.hir.is_anchored_end()); + info.set_line_anchored_start(group.hir.is_line_anchored_start()); + info.set_line_anchored_end(group.hir.is_line_anchored_end()); + info.set_any_anchored_start(group.hir.is_any_anchored_start()); + info.set_any_anchored_end(group.hir.is_any_anchored_end()); + info.set_match_empty(group.hir.is_match_empty()); + info.set_literal(false); + info.set_alternation_literal(false); + Hir { kind: HirKind::Group(group), info: info } + } + + /// Returns the concatenation of the given expressions. + /// + /// This flattens the concatenation as appropriate. + pub fn concat(mut exprs: Vec<Hir>) -> Hir { + match exprs.len() { + 0 => Hir::empty(), + 1 => exprs.pop().unwrap(), + _ => { + let mut info = HirInfo::new(); + info.set_always_utf8(true); + info.set_all_assertions(true); + info.set_any_anchored_start(false); + info.set_any_anchored_end(false); + info.set_match_empty(true); + info.set_literal(true); + info.set_alternation_literal(true); + + // Some attributes require analyzing all sub-expressions. + for e in &exprs { + let x = info.is_always_utf8() && e.is_always_utf8(); + info.set_always_utf8(x); + + let x = info.is_all_assertions() && e.is_all_assertions(); + info.set_all_assertions(x); + + let x = info.is_any_anchored_start() + || e.is_any_anchored_start(); + info.set_any_anchored_start(x); + + let x = + info.is_any_anchored_end() || e.is_any_anchored_end(); + info.set_any_anchored_end(x); + + let x = info.is_match_empty() && e.is_match_empty(); + info.set_match_empty(x); + + let x = info.is_literal() && e.is_literal(); + info.set_literal(x); + + let x = info.is_alternation_literal() + && e.is_alternation_literal(); + info.set_alternation_literal(x); + } + // Anchored attributes require something slightly more + // sophisticated. Normally, WLOG, to determine whether an + // expression is anchored to the start, we'd only need to check + // the first expression of a concatenation. However, + // expressions like `$\b^` are still anchored to the start, + // but the first expression in the concatenation *isn't* + // anchored to the start. So the "first" expression to look at + // is actually one that is either not an assertion or is + // specifically the StartText assertion. + info.set_anchored_start( + exprs + .iter() + .take_while(|e| { + e.is_anchored_start() || e.is_all_assertions() + }) + .any(|e| e.is_anchored_start()), + ); + // Similarly for the end anchor, but in reverse. + info.set_anchored_end( + exprs + .iter() + .rev() + .take_while(|e| { + e.is_anchored_end() || e.is_all_assertions() + }) + .any(|e| e.is_anchored_end()), + ); + // Repeat the process for line anchors. + info.set_line_anchored_start( + exprs + .iter() + .take_while(|e| { + e.is_line_anchored_start() || e.is_all_assertions() + }) + .any(|e| e.is_line_anchored_start()), + ); + info.set_line_anchored_end( + exprs + .iter() + .rev() + .take_while(|e| { + e.is_line_anchored_end() || e.is_all_assertions() + }) + .any(|e| e.is_line_anchored_end()), + ); + Hir { kind: HirKind::Concat(exprs), info: info } + } + } + } + + /// Returns the alternation of the given expressions. + /// + /// This flattens the alternation as appropriate. + pub fn alternation(mut exprs: Vec<Hir>) -> Hir { + match exprs.len() { + 0 => Hir::empty(), + 1 => exprs.pop().unwrap(), + _ => { + let mut info = HirInfo::new(); + info.set_always_utf8(true); + info.set_all_assertions(true); + info.set_anchored_start(true); + info.set_anchored_end(true); + info.set_line_anchored_start(true); + info.set_line_anchored_end(true); + info.set_any_anchored_start(false); + info.set_any_anchored_end(false); + info.set_match_empty(false); + info.set_literal(false); + info.set_alternation_literal(true); + + // Some attributes require analyzing all sub-expressions. + for e in &exprs { + let x = info.is_always_utf8() && e.is_always_utf8(); + info.set_always_utf8(x); + + let x = info.is_all_assertions() && e.is_all_assertions(); + info.set_all_assertions(x); + + let x = info.is_anchored_start() && e.is_anchored_start(); + info.set_anchored_start(x); + + let x = info.is_anchored_end() && e.is_anchored_end(); + info.set_anchored_end(x); + + let x = info.is_line_anchored_start() + && e.is_line_anchored_start(); + info.set_line_anchored_start(x); + + let x = info.is_line_anchored_end() + && e.is_line_anchored_end(); + info.set_line_anchored_end(x); + + let x = info.is_any_anchored_start() + || e.is_any_anchored_start(); + info.set_any_anchored_start(x); + + let x = + info.is_any_anchored_end() || e.is_any_anchored_end(); + info.set_any_anchored_end(x); + + let x = info.is_match_empty() || e.is_match_empty(); + info.set_match_empty(x); + + let x = info.is_alternation_literal() && e.is_literal(); + info.set_alternation_literal(x); + } + Hir { kind: HirKind::Alternation(exprs), info: info } + } + } + } + + /// Build an HIR expression for `.`. + /// + /// A `.` expression matches any character except for `\n`. To build an + /// expression that matches any character, including `\n`, use the `any` + /// method. + /// + /// If `bytes` is `true`, then this assumes characters are limited to a + /// single byte. + pub fn dot(bytes: bool) -> Hir { + if bytes { + let mut cls = ClassBytes::empty(); + cls.push(ClassBytesRange::new(b'\0', b'\x09')); + cls.push(ClassBytesRange::new(b'\x0B', b'\xFF')); + Hir::class(Class::Bytes(cls)) + } else { + let mut cls = ClassUnicode::empty(); + cls.push(ClassUnicodeRange::new('\0', '\x09')); + cls.push(ClassUnicodeRange::new('\x0B', '\u{10FFFF}')); + Hir::class(Class::Unicode(cls)) + } + } + + /// Build an HIR expression for `(?s).`. + /// + /// A `(?s).` expression matches any character, including `\n`. To build an + /// expression that matches any character except for `\n`, then use the + /// `dot` method. + /// + /// If `bytes` is `true`, then this assumes characters are limited to a + /// single byte. + pub fn any(bytes: bool) -> Hir { + if bytes { + let mut cls = ClassBytes::empty(); + cls.push(ClassBytesRange::new(b'\0', b'\xFF')); + Hir::class(Class::Bytes(cls)) + } else { + let mut cls = ClassUnicode::empty(); + cls.push(ClassUnicodeRange::new('\0', '\u{10FFFF}')); + Hir::class(Class::Unicode(cls)) + } + } + + /// Return true if and only if this HIR will always match valid UTF-8. + /// + /// When this returns false, then it is possible for this HIR expression + /// to match invalid UTF-8. + pub fn is_always_utf8(&self) -> bool { + self.info.is_always_utf8() + } + + /// Returns true if and only if this entire HIR expression is made up of + /// zero-width assertions. + /// + /// This includes expressions like `^$\b\A\z` and even `((\b)+())*^`, but + /// not `^a`. + pub fn is_all_assertions(&self) -> bool { + self.info.is_all_assertions() + } + + /// Return true if and only if this HIR is required to match from the + /// beginning of text. This includes expressions like `^foo`, `^(foo|bar)`, + /// `^foo|^bar` but not `^foo|bar`. + pub fn is_anchored_start(&self) -> bool { + self.info.is_anchored_start() + } + + /// Return true if and only if this HIR is required to match at the end + /// of text. This includes expressions like `foo$`, `(foo|bar)$`, + /// `foo$|bar$` but not `foo$|bar`. + pub fn is_anchored_end(&self) -> bool { + self.info.is_anchored_end() + } + + /// Return true if and only if this HIR is required to match from the + /// beginning of text or the beginning of a line. This includes expressions + /// like `^foo`, `(?m)^foo`, `^(foo|bar)`, `^(foo|bar)`, `(?m)^foo|^bar` + /// but not `^foo|bar` or `(?m)^foo|bar`. + /// + /// Note that if `is_anchored_start` is `true`, then + /// `is_line_anchored_start` will also be `true`. The reverse implication + /// is not true. For example, `(?m)^foo` is line anchored, but not + /// `is_anchored_start`. + pub fn is_line_anchored_start(&self) -> bool { + self.info.is_line_anchored_start() + } + + /// Return true if and only if this HIR is required to match at the + /// end of text or the end of a line. This includes expressions like + /// `foo$`, `(?m)foo$`, `(foo|bar)$`, `(?m)(foo|bar)$`, `foo$|bar$`, + /// `(?m)(foo|bar)$`, but not `foo$|bar` or `(?m)foo$|bar`. + /// + /// Note that if `is_anchored_end` is `true`, then + /// `is_line_anchored_end` will also be `true`. The reverse implication + /// is not true. For example, `(?m)foo$` is line anchored, but not + /// `is_anchored_end`. + pub fn is_line_anchored_end(&self) -> bool { + self.info.is_line_anchored_end() + } + + /// Return true if and only if this HIR contains any sub-expression that + /// is required to match at the beginning of text. Specifically, this + /// returns true if the `^` symbol (when multiline mode is disabled) or the + /// `\A` escape appear anywhere in the regex. + pub fn is_any_anchored_start(&self) -> bool { + self.info.is_any_anchored_start() + } + + /// Return true if and only if this HIR contains any sub-expression that is + /// required to match at the end of text. Specifically, this returns true + /// if the `$` symbol (when multiline mode is disabled) or the `\z` escape + /// appear anywhere in the regex. + pub fn is_any_anchored_end(&self) -> bool { + self.info.is_any_anchored_end() + } + + /// Return true if and only if the empty string is part of the language + /// matched by this regular expression. + /// + /// This includes `a*`, `a?b*`, `a{0}`, `()`, `()+`, `^$`, `a|b?`, `\B`, + /// but not `a`, `a+` or `\b`. + pub fn is_match_empty(&self) -> bool { + self.info.is_match_empty() + } + + /// Return true if and only if this HIR is a simple literal. This is only + /// true when this HIR expression is either itself a `Literal` or a + /// concatenation of only `Literal`s. + /// + /// For example, `f` and `foo` are literals, but `f+`, `(foo)`, `foo()` + /// are not (even though that contain sub-expressions that are literals). + pub fn is_literal(&self) -> bool { + self.info.is_literal() + } + + /// Return true if and only if this HIR is either a simple literal or an + /// alternation of simple literals. This is only + /// true when this HIR expression is either itself a `Literal` or a + /// concatenation of only `Literal`s or an alternation of only `Literal`s. + /// + /// For example, `f`, `foo`, `a|b|c`, and `foo|bar|baz` are alternaiton + /// literals, but `f+`, `(foo)`, `foo()` + /// are not (even though that contain sub-expressions that are literals). + pub fn is_alternation_literal(&self) -> bool { + self.info.is_alternation_literal() + } +} + +impl HirKind { + /// Return true if and only if this HIR is the empty regular expression. + /// + /// Note that this is not defined inductively. That is, it only tests if + /// this kind is the `Empty` variant. To get the inductive definition, + /// use the `is_match_empty` method on [`Hir`](struct.Hir.html). + pub fn is_empty(&self) -> bool { + match *self { + HirKind::Empty => true, + _ => false, + } + } + + /// Returns true if and only if this kind has any (including possibly + /// empty) subexpressions. + pub fn has_subexprs(&self) -> bool { + match *self { + HirKind::Empty + | HirKind::Literal(_) + | HirKind::Class(_) + | HirKind::Anchor(_) + | HirKind::WordBoundary(_) => false, + HirKind::Group(_) + | HirKind::Repetition(_) + | HirKind::Concat(_) + | HirKind::Alternation(_) => true, + } + } +} + +/// Print a display representation of this Hir. +/// +/// The result of this is a valid regular expression pattern string. +/// +/// This implementation uses constant stack space and heap space proportional +/// to the size of the `Hir`. +impl fmt::Display for Hir { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use hir::print::Printer; + Printer::new().print(self, f) + } +} + +/// The high-level intermediate representation of a literal. +/// +/// A literal corresponds to a single character, where a character is either +/// defined by a Unicode scalar value or an arbitrary byte. Unicode characters +/// are preferred whenever possible. In particular, a `Byte` variant is only +/// ever produced when it could match invalid UTF-8. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Literal { + /// A single character represented by a Unicode scalar value. + Unicode(char), + /// A single character represented by an arbitrary byte. + Byte(u8), +} + +impl Literal { + /// Returns true if and only if this literal corresponds to a Unicode + /// scalar value. + pub fn is_unicode(&self) -> bool { + match *self { + Literal::Unicode(_) => true, + Literal::Byte(b) if b <= 0x7F => true, + Literal::Byte(_) => false, + } + } +} + +/// The high-level intermediate representation of a character class. +/// +/// A character class corresponds to a set of characters. A character is either +/// defined by a Unicode scalar value or a byte. Unicode characters are used +/// by default, while bytes are used when Unicode mode (via the `u` flag) is +/// disabled. +/// +/// A character class, regardless of its character type, is represented by a +/// sequence of non-overlapping non-adjacent ranges of characters. +/// +/// Note that unlike [`Literal`](enum.Literal.html), a `Bytes` variant may +/// be produced even when it exclusively matches valid UTF-8. This is because +/// a `Bytes` variant represents an intention by the author of the regular +/// expression to disable Unicode mode, which in turn impacts the semantics of +/// case insensitive matching. For example, `(?i)k` and `(?i-u)k` will not +/// match the same set of strings. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Class { + /// A set of characters represented by Unicode scalar values. + Unicode(ClassUnicode), + /// A set of characters represented by arbitrary bytes (one byte per + /// character). + Bytes(ClassBytes), +} + +impl Class { + /// Apply Unicode simple case folding to this character class, in place. + /// The character class will be expanded to include all simple case folded + /// character variants. + /// + /// If this is a byte oriented character class, then this will be limited + /// to the ASCII ranges `A-Z` and `a-z`. + pub fn case_fold_simple(&mut self) { + match *self { + Class::Unicode(ref mut x) => x.case_fold_simple(), + Class::Bytes(ref mut x) => x.case_fold_simple(), + } + } + + /// Negate this character class in place. + /// + /// After completion, this character class will contain precisely the + /// characters that weren't previously in the class. + pub fn negate(&mut self) { + match *self { + Class::Unicode(ref mut x) => x.negate(), + Class::Bytes(ref mut x) => x.negate(), + } + } + + /// Returns true if and only if this character class will only ever match + /// valid UTF-8. + /// + /// A character class can match invalid UTF-8 only when the following + /// conditions are met: + /// + /// 1. The translator was configured to permit generating an expression + /// that can match invalid UTF-8. (By default, this is disabled.) + /// 2. Unicode mode (via the `u` flag) was disabled either in the concrete + /// syntax or in the parser builder. By default, Unicode mode is + /// enabled. + pub fn is_always_utf8(&self) -> bool { + match *self { + Class::Unicode(_) => true, + Class::Bytes(ref x) => x.is_all_ascii(), + } + } +} + +/// A set of characters represented by Unicode scalar values. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ClassUnicode { + set: IntervalSet<ClassUnicodeRange>, +} + +impl ClassUnicode { + /// Create a new class from a sequence of ranges. + /// + /// The given ranges do not need to be in any specific order, and ranges + /// may overlap. + pub fn new<I>(ranges: I) -> ClassUnicode + where + I: IntoIterator<Item = ClassUnicodeRange>, + { + ClassUnicode { set: IntervalSet::new(ranges) } + } + + /// Create a new class with no ranges. + pub fn empty() -> ClassUnicode { + ClassUnicode::new(vec![]) + } + + /// Add a new range to this set. + pub fn push(&mut self, range: ClassUnicodeRange) { + self.set.push(range); + } + + /// Return an iterator over all ranges in this class. + /// + /// The iterator yields ranges in ascending order. + pub fn iter(&self) -> ClassUnicodeIter { + ClassUnicodeIter(self.set.iter()) + } + + /// Return the underlying ranges as a slice. + pub fn ranges(&self) -> &[ClassUnicodeRange] { + self.set.intervals() + } + + /// Expand this character class such that it contains all case folded + /// characters, according to Unicode's "simple" mapping. For example, if + /// this class consists of the range `a-z`, then applying case folding will + /// result in the class containing both the ranges `a-z` and `A-Z`. + /// + /// # Panics + /// + /// This routine panics when the case mapping data necessary for this + /// routine to complete is unavailable. This occurs when the `unicode-case` + /// feature is not enabled. + /// + /// Callers should prefer using `try_case_fold_simple` instead, which will + /// return an error instead of panicking. + pub fn case_fold_simple(&mut self) { + self.set + .case_fold_simple() + .expect("unicode-case feature must be enabled"); + } + + /// Expand this character class such that it contains all case folded + /// characters, according to Unicode's "simple" mapping. For example, if + /// this class consists of the range `a-z`, then applying case folding will + /// result in the class containing both the ranges `a-z` and `A-Z`. + /// + /// # Panics + /// + /// This routine panics when the case mapping data necessary for this + /// routine to complete is unavailable. This occurs when the `unicode-case` + /// feature is not enabled. + /// + /// Callers should prefer using `try_case_fold_simple` instead, which will + /// return an error instead of panicking. + pub fn try_case_fold_simple( + &mut self, + ) -> result::Result<(), CaseFoldError> { + self.set.case_fold_simple() + } + + /// Negate this character class. + /// + /// For all `c` where `c` is a Unicode scalar value, if `c` was in this + /// set, then it will not be in this set after negation. + pub fn negate(&mut self) { + self.set.negate(); + } + + /// Union this character class with the given character class, in place. + pub fn union(&mut self, other: &ClassUnicode) { + self.set.union(&other.set); + } + + /// Intersect this character class with the given character class, in + /// place. + pub fn intersect(&mut self, other: &ClassUnicode) { + self.set.intersect(&other.set); + } + + /// Subtract the given character class from this character class, in place. + pub fn difference(&mut self, other: &ClassUnicode) { + self.set.difference(&other.set); + } + + /// Compute the symmetric difference of the given character classes, in + /// place. + /// + /// This computes the symmetric difference of two character classes. This + /// removes all elements in this class that are also in the given class, + /// but all adds all elements from the given class that aren't in this + /// class. That is, the class will contain all elements in either class, + /// but will not contain any elements that are in both classes. + pub fn symmetric_difference(&mut self, other: &ClassUnicode) { + self.set.symmetric_difference(&other.set); + } +} + +/// An iterator over all ranges in a Unicode character class. +/// +/// The lifetime `'a` refers to the lifetime of the underlying class. +#[derive(Debug)] +pub struct ClassUnicodeIter<'a>(IntervalSetIter<'a, ClassUnicodeRange>); + +impl<'a> Iterator for ClassUnicodeIter<'a> { + type Item = &'a ClassUnicodeRange; + + fn next(&mut self) -> Option<&'a ClassUnicodeRange> { + self.0.next() + } +} + +/// A single range of characters represented by Unicode scalar values. +/// +/// The range is closed. That is, the start and end of the range are included +/// in the range. +#[derive(Clone, Copy, Default, Eq, PartialEq, PartialOrd, Ord)] +pub struct ClassUnicodeRange { + start: char, + end: char, +} + +impl fmt::Debug for ClassUnicodeRange { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let start = if !self.start.is_whitespace() && !self.start.is_control() + { + self.start.to_string() + } else { + format!("0x{:X}", self.start as u32) + }; + let end = if !self.end.is_whitespace() && !self.end.is_control() { + self.end.to_string() + } else { + format!("0x{:X}", self.end as u32) + }; + f.debug_struct("ClassUnicodeRange") + .field("start", &start) + .field("end", &end) + .finish() + } +} + +impl Interval for ClassUnicodeRange { + type Bound = char; + + #[inline] + fn lower(&self) -> char { + self.start + } + #[inline] + fn upper(&self) -> char { + self.end + } + #[inline] + fn set_lower(&mut self, bound: char) { + self.start = bound; + } + #[inline] + fn set_upper(&mut self, bound: char) { + self.end = bound; + } + + /// Apply simple case folding to this Unicode scalar value range. + /// + /// Additional ranges are appended to the given vector. Canonical ordering + /// is *not* maintained in the given vector. + fn case_fold_simple( + &self, + ranges: &mut Vec<ClassUnicodeRange>, + ) -> Result<(), unicode::CaseFoldError> { + if !unicode::contains_simple_case_mapping(self.start, self.end)? { + return Ok(()); + } + let start = self.start as u32; + let end = (self.end as u32).saturating_add(1); + let mut next_simple_cp = None; + for cp in (start..end).filter_map(char::from_u32) { + if next_simple_cp.map_or(false, |next| cp < next) { + continue; + } + let it = match unicode::simple_fold(cp)? { + Ok(it) => it, + Err(next) => { + next_simple_cp = next; + continue; + } + }; + for cp_folded in it { + ranges.push(ClassUnicodeRange::new(cp_folded, cp_folded)); + } + } + Ok(()) + } +} + +impl ClassUnicodeRange { + /// Create a new Unicode scalar value range for a character class. + /// + /// The returned range is always in a canonical form. That is, the range + /// returned always satisfies the invariant that `start <= end`. + pub fn new(start: char, end: char) -> ClassUnicodeRange { + ClassUnicodeRange::create(start, end) + } + + /// Return the start of this range. + /// + /// The start of a range is always less than or equal to the end of the + /// range. + pub fn start(&self) -> char { + self.start + } + + /// Return the end of this range. + /// + /// The end of a range is always greater than or equal to the start of the + /// range. + pub fn end(&self) -> char { + self.end + } +} + +/// A set of characters represented by arbitrary bytes (where one byte +/// corresponds to one character). +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ClassBytes { + set: IntervalSet<ClassBytesRange>, +} + +impl ClassBytes { + /// Create a new class from a sequence of ranges. + /// + /// The given ranges do not need to be in any specific order, and ranges + /// may overlap. + pub fn new<I>(ranges: I) -> ClassBytes + where + I: IntoIterator<Item = ClassBytesRange>, + { + ClassBytes { set: IntervalSet::new(ranges) } + } + + /// Create a new class with no ranges. + pub fn empty() -> ClassBytes { + ClassBytes::new(vec![]) + } + + /// Add a new range to this set. + pub fn push(&mut self, range: ClassBytesRange) { + self.set.push(range); + } + + /// Return an iterator over all ranges in this class. + /// + /// The iterator yields ranges in ascending order. + pub fn iter(&self) -> ClassBytesIter { + ClassBytesIter(self.set.iter()) + } + + /// Return the underlying ranges as a slice. + pub fn ranges(&self) -> &[ClassBytesRange] { + self.set.intervals() + } + + /// Expand this character class such that it contains all case folded + /// characters. For example, if this class consists of the range `a-z`, + /// then applying case folding will result in the class containing both the + /// ranges `a-z` and `A-Z`. + /// + /// Note that this only applies ASCII case folding, which is limited to the + /// characters `a-z` and `A-Z`. + pub fn case_fold_simple(&mut self) { + self.set.case_fold_simple().expect("ASCII case folding never fails"); + } + + /// Negate this byte class. + /// + /// For all `b` where `b` is a any byte, if `b` was in this set, then it + /// will not be in this set after negation. + pub fn negate(&mut self) { + self.set.negate(); + } + + /// Union this byte class with the given byte class, in place. + pub fn union(&mut self, other: &ClassBytes) { + self.set.union(&other.set); + } + + /// Intersect this byte class with the given byte class, in place. + pub fn intersect(&mut self, other: &ClassBytes) { + self.set.intersect(&other.set); + } + + /// Subtract the given byte class from this byte class, in place. + pub fn difference(&mut self, other: &ClassBytes) { + self.set.difference(&other.set); + } + + /// Compute the symmetric difference of the given byte classes, in place. + /// + /// This computes the symmetric difference of two byte classes. This + /// removes all elements in this class that are also in the given class, + /// but all adds all elements from the given class that aren't in this + /// class. That is, the class will contain all elements in either class, + /// but will not contain any elements that are in both classes. + pub fn symmetric_difference(&mut self, other: &ClassBytes) { + self.set.symmetric_difference(&other.set); + } + + /// Returns true if and only if this character class will either match + /// nothing or only ASCII bytes. Stated differently, this returns false + /// if and only if this class contains a non-ASCII byte. + pub fn is_all_ascii(&self) -> bool { + self.set.intervals().last().map_or(true, |r| r.end <= 0x7F) + } +} + +/// An iterator over all ranges in a byte character class. +/// +/// The lifetime `'a` refers to the lifetime of the underlying class. +#[derive(Debug)] +pub struct ClassBytesIter<'a>(IntervalSetIter<'a, ClassBytesRange>); + +impl<'a> Iterator for ClassBytesIter<'a> { + type Item = &'a ClassBytesRange; + + fn next(&mut self) -> Option<&'a ClassBytesRange> { + self.0.next() + } +} + +/// A single range of characters represented by arbitrary bytes. +/// +/// The range is closed. That is, the start and end of the range are included +/// in the range. +#[derive(Clone, Copy, Default, Eq, PartialEq, PartialOrd, Ord)] +pub struct ClassBytesRange { + start: u8, + end: u8, +} + +impl Interval for ClassBytesRange { + type Bound = u8; + + #[inline] + fn lower(&self) -> u8 { + self.start + } + #[inline] + fn upper(&self) -> u8 { + self.end + } + #[inline] + fn set_lower(&mut self, bound: u8) { + self.start = bound; + } + #[inline] + fn set_upper(&mut self, bound: u8) { + self.end = bound; + } + + /// Apply simple case folding to this byte range. Only ASCII case mappings + /// (for a-z) are applied. + /// + /// Additional ranges are appended to the given vector. Canonical ordering + /// is *not* maintained in the given vector. + fn case_fold_simple( + &self, + ranges: &mut Vec<ClassBytesRange>, + ) -> Result<(), unicode::CaseFoldError> { + if !ClassBytesRange::new(b'a', b'z').is_intersection_empty(self) { + let lower = cmp::max(self.start, b'a'); + let upper = cmp::min(self.end, b'z'); + ranges.push(ClassBytesRange::new(lower - 32, upper - 32)); + } + if !ClassBytesRange::new(b'A', b'Z').is_intersection_empty(self) { + let lower = cmp::max(self.start, b'A'); + let upper = cmp::min(self.end, b'Z'); + ranges.push(ClassBytesRange::new(lower + 32, upper + 32)); + } + Ok(()) + } +} + +impl ClassBytesRange { + /// Create a new byte range for a character class. + /// + /// The returned range is always in a canonical form. That is, the range + /// returned always satisfies the invariant that `start <= end`. + pub fn new(start: u8, end: u8) -> ClassBytesRange { + ClassBytesRange::create(start, end) + } + + /// Return the start of this range. + /// + /// The start of a range is always less than or equal to the end of the + /// range. + pub fn start(&self) -> u8 { + self.start + } + + /// Return the end of this range. + /// + /// The end of a range is always greater than or equal to the start of the + /// range. + pub fn end(&self) -> u8 { + self.end + } +} + +impl fmt::Debug for ClassBytesRange { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut debug = f.debug_struct("ClassBytesRange"); + if self.start <= 0x7F { + debug.field("start", &(self.start as char)); + } else { + debug.field("start", &self.start); + } + if self.end <= 0x7F { + debug.field("end", &(self.end as char)); + } else { + debug.field("end", &self.end); + } + debug.finish() + } +} + +/// The high-level intermediate representation for an anchor assertion. +/// +/// A matching anchor assertion is always zero-length. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Anchor { + /// Match the beginning of a line or the beginning of text. Specifically, + /// this matches at the starting position of the input, or at the position + /// immediately following a `\n` character. + StartLine, + /// Match the end of a line or the end of text. Specifically, + /// this matches at the end position of the input, or at the position + /// immediately preceding a `\n` character. + EndLine, + /// Match the beginning of text. Specifically, this matches at the starting + /// position of the input. + StartText, + /// Match the end of text. Specifically, this matches at the ending + /// position of the input. + EndText, +} + +/// The high-level intermediate representation for a word-boundary assertion. +/// +/// A matching word boundary assertion is always zero-length. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum WordBoundary { + /// Match a Unicode-aware word boundary. That is, this matches a position + /// where the left adjacent character and right adjacent character + /// correspond to a word and non-word or a non-word and word character. + Unicode, + /// Match a Unicode-aware negation of a word boundary. + UnicodeNegate, + /// Match an ASCII-only word boundary. That is, this matches a position + /// where the left adjacent character and right adjacent character + /// correspond to a word and non-word or a non-word and word character. + Ascii, + /// Match an ASCII-only negation of a word boundary. + AsciiNegate, +} + +impl WordBoundary { + /// Returns true if and only if this word boundary assertion is negated. + pub fn is_negated(&self) -> bool { + match *self { + WordBoundary::Unicode | WordBoundary::Ascii => false, + WordBoundary::UnicodeNegate | WordBoundary::AsciiNegate => true, + } + } +} + +/// The high-level intermediate representation for a group. +/// +/// This represents one of three possible group types: +/// +/// 1. A non-capturing group (e.g., `(?:expr)`). +/// 2. A capturing group (e.g., `(expr)`). +/// 3. A named capturing group (e.g., `(?P<name>expr)`). +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Group { + /// The kind of this group. If it is a capturing group, then the kind + /// contains the capture group index (and the name, if it is a named + /// group). + pub kind: GroupKind, + /// The expression inside the capturing group, which may be empty. + pub hir: Box<Hir>, +} + +/// The kind of group. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum GroupKind { + /// A normal unnamed capturing group. + /// + /// The value is the capture index of the group. + CaptureIndex(u32), + /// A named capturing group. + CaptureName { + /// The name of the group. + name: String, + /// The capture index of the group. + index: u32, + }, + /// A non-capturing group. + NonCapturing, +} + +/// The high-level intermediate representation of a repetition operator. +/// +/// A repetition operator permits the repetition of an arbitrary +/// sub-expression. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Repetition { + /// The kind of this repetition operator. + pub kind: RepetitionKind, + /// Whether this repetition operator is greedy or not. A greedy operator + /// will match as much as it can. A non-greedy operator will match as + /// little as it can. + /// + /// Typically, operators are greedy by default and are only non-greedy when + /// a `?` suffix is used, e.g., `(expr)*` is greedy while `(expr)*?` is + /// not. However, this can be inverted via the `U` "ungreedy" flag. + pub greedy: bool, + /// The expression being repeated. + pub hir: Box<Hir>, +} + +impl Repetition { + /// Returns true if and only if this repetition operator makes it possible + /// to match the empty string. + /// + /// Note that this is not defined inductively. For example, while `a*` + /// will report `true`, `()+` will not, even though `()` matches the empty + /// string and one or more occurrences of something that matches the empty + /// string will always match the empty string. In order to get the + /// inductive definition, see the corresponding method on + /// [`Hir`](struct.Hir.html). + pub fn is_match_empty(&self) -> bool { + match self.kind { + RepetitionKind::ZeroOrOne => true, + RepetitionKind::ZeroOrMore => true, + RepetitionKind::OneOrMore => false, + RepetitionKind::Range(RepetitionRange::Exactly(m)) => m == 0, + RepetitionKind::Range(RepetitionRange::AtLeast(m)) => m == 0, + RepetitionKind::Range(RepetitionRange::Bounded(m, _)) => m == 0, + } + } +} + +/// The kind of a repetition operator. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum RepetitionKind { + /// Matches a sub-expression zero or one times. + ZeroOrOne, + /// Matches a sub-expression zero or more times. + ZeroOrMore, + /// Matches a sub-expression one or more times. + OneOrMore, + /// Matches a sub-expression within a bounded range of times. + Range(RepetitionRange), +} + +/// The kind of a counted repetition operator. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum RepetitionRange { + /// Matches a sub-expression exactly this many times. + Exactly(u32), + /// Matches a sub-expression at least this many times. + AtLeast(u32), + /// Matches a sub-expression at least `m` times and at most `n` times. + Bounded(u32, u32), +} + +/// A custom `Drop` impl is used for `HirKind` such that it uses constant stack +/// space but heap space proportional to the depth of the total `Hir`. +impl Drop for Hir { + fn drop(&mut self) { + use std::mem; + + match *self.kind() { + HirKind::Empty + | HirKind::Literal(_) + | HirKind::Class(_) + | HirKind::Anchor(_) + | HirKind::WordBoundary(_) => return, + HirKind::Group(ref x) if !x.hir.kind.has_subexprs() => return, + HirKind::Repetition(ref x) if !x.hir.kind.has_subexprs() => return, + HirKind::Concat(ref x) if x.is_empty() => return, + HirKind::Alternation(ref x) if x.is_empty() => return, + _ => {} + } + + let mut stack = vec![mem::replace(self, Hir::empty())]; + while let Some(mut expr) = stack.pop() { + match expr.kind { + HirKind::Empty + | HirKind::Literal(_) + | HirKind::Class(_) + | HirKind::Anchor(_) + | HirKind::WordBoundary(_) => {} + HirKind::Group(ref mut x) => { + stack.push(mem::replace(&mut x.hir, Hir::empty())); + } + HirKind::Repetition(ref mut x) => { + stack.push(mem::replace(&mut x.hir, Hir::empty())); + } + HirKind::Concat(ref mut x) => { + stack.extend(x.drain(..)); + } + HirKind::Alternation(ref mut x) => { + stack.extend(x.drain(..)); + } + } + } + } +} + +/// A type that documents various attributes of an HIR expression. +/// +/// These attributes are typically defined inductively on the HIR. +#[derive(Clone, Debug, Eq, PartialEq)] +struct HirInfo { + /// Represent yes/no questions by a bitfield to conserve space, since + /// this is included in every HIR expression. + /// + /// If more attributes need to be added, it is OK to increase the size of + /// this as appropriate. + bools: u16, +} + +// A simple macro for defining bitfield accessors/mutators. +macro_rules! define_bool { + ($bit:expr, $is_fn_name:ident, $set_fn_name:ident) => { + fn $is_fn_name(&self) -> bool { + self.bools & (0b1 << $bit) > 0 + } + + fn $set_fn_name(&mut self, yes: bool) { + if yes { + self.bools |= 1 << $bit; + } else { + self.bools &= !(1 << $bit); + } + } + } +} + +impl HirInfo { + fn new() -> HirInfo { + HirInfo { bools: 0 } + } + + define_bool!(0, is_always_utf8, set_always_utf8); + define_bool!(1, is_all_assertions, set_all_assertions); + define_bool!(2, is_anchored_start, set_anchored_start); + define_bool!(3, is_anchored_end, set_anchored_end); + define_bool!(4, is_line_anchored_start, set_line_anchored_start); + define_bool!(5, is_line_anchored_end, set_line_anchored_end); + define_bool!(6, is_any_anchored_start, set_any_anchored_start); + define_bool!(7, is_any_anchored_end, set_any_anchored_end); + define_bool!(8, is_match_empty, set_match_empty); + define_bool!(9, is_literal, set_literal); + define_bool!(10, is_alternation_literal, set_alternation_literal); +} + +#[cfg(test)] +mod tests { + use super::*; + + fn uclass(ranges: &[(char, char)]) -> ClassUnicode { + let ranges: Vec<ClassUnicodeRange> = ranges + .iter() + .map(|&(s, e)| ClassUnicodeRange::new(s, e)) + .collect(); + ClassUnicode::new(ranges) + } + + fn bclass(ranges: &[(u8, u8)]) -> ClassBytes { + let ranges: Vec<ClassBytesRange> = + ranges.iter().map(|&(s, e)| ClassBytesRange::new(s, e)).collect(); + ClassBytes::new(ranges) + } + + fn uranges(cls: &ClassUnicode) -> Vec<(char, char)> { + cls.iter().map(|x| (x.start(), x.end())).collect() + } + + #[cfg(feature = "unicode-case")] + fn ucasefold(cls: &ClassUnicode) -> ClassUnicode { + let mut cls_ = cls.clone(); + cls_.case_fold_simple(); + cls_ + } + + fn uunion(cls1: &ClassUnicode, cls2: &ClassUnicode) -> ClassUnicode { + let mut cls_ = cls1.clone(); + cls_.union(cls2); + cls_ + } + + fn uintersect(cls1: &ClassUnicode, cls2: &ClassUnicode) -> ClassUnicode { + let mut cls_ = cls1.clone(); + cls_.intersect(cls2); + cls_ + } + + fn udifference(cls1: &ClassUnicode, cls2: &ClassUnicode) -> ClassUnicode { + let mut cls_ = cls1.clone(); + cls_.difference(cls2); + cls_ + } + + fn usymdifference( + cls1: &ClassUnicode, + cls2: &ClassUnicode, + ) -> ClassUnicode { + let mut cls_ = cls1.clone(); + cls_.symmetric_difference(cls2); + cls_ + } + + fn unegate(cls: &ClassUnicode) -> ClassUnicode { + let mut cls_ = cls.clone(); + cls_.negate(); + cls_ + } + + fn branges(cls: &ClassBytes) -> Vec<(u8, u8)> { + cls.iter().map(|x| (x.start(), x.end())).collect() + } + + fn bcasefold(cls: &ClassBytes) -> ClassBytes { + let mut cls_ = cls.clone(); + cls_.case_fold_simple(); + cls_ + } + + fn bunion(cls1: &ClassBytes, cls2: &ClassBytes) -> ClassBytes { + let mut cls_ = cls1.clone(); + cls_.union(cls2); + cls_ + } + + fn bintersect(cls1: &ClassBytes, cls2: &ClassBytes) -> ClassBytes { + let mut cls_ = cls1.clone(); + cls_.intersect(cls2); + cls_ + } + + fn bdifference(cls1: &ClassBytes, cls2: &ClassBytes) -> ClassBytes { + let mut cls_ = cls1.clone(); + cls_.difference(cls2); + cls_ + } + + fn bsymdifference(cls1: &ClassBytes, cls2: &ClassBytes) -> ClassBytes { + let mut cls_ = cls1.clone(); + cls_.symmetric_difference(cls2); + cls_ + } + + fn bnegate(cls: &ClassBytes) -> ClassBytes { + let mut cls_ = cls.clone(); + cls_.negate(); + cls_ + } + + #[test] + fn class_range_canonical_unicode() { + let range = ClassUnicodeRange::new('\u{00FF}', '\0'); + assert_eq!('\0', range.start()); + assert_eq!('\u{00FF}', range.end()); + } + + #[test] + fn class_range_canonical_bytes() { + let range = ClassBytesRange::new(b'\xFF', b'\0'); + assert_eq!(b'\0', range.start()); + assert_eq!(b'\xFF', range.end()); + } + + #[test] + fn class_canonicalize_unicode() { + let cls = uclass(&[('a', 'c'), ('x', 'z')]); + let expected = vec![('a', 'c'), ('x', 'z')]; + assert_eq!(expected, uranges(&cls)); + + let cls = uclass(&[('x', 'z'), ('a', 'c')]); + let expected = vec![('a', 'c'), ('x', 'z')]; + assert_eq!(expected, uranges(&cls)); + + let cls = uclass(&[('x', 'z'), ('w', 'y')]); + let expected = vec![('w', 'z')]; + assert_eq!(expected, uranges(&cls)); + + let cls = uclass(&[ + ('c', 'f'), + ('a', 'g'), + ('d', 'j'), + ('a', 'c'), + ('m', 'p'), + ('l', 's'), + ]); + let expected = vec![('a', 'j'), ('l', 's')]; + assert_eq!(expected, uranges(&cls)); + + let cls = uclass(&[('x', 'z'), ('u', 'w')]); + let expected = vec![('u', 'z')]; + assert_eq!(expected, uranges(&cls)); + + let cls = uclass(&[('\x00', '\u{10FFFF}'), ('\x00', '\u{10FFFF}')]); + let expected = vec![('\x00', '\u{10FFFF}')]; + assert_eq!(expected, uranges(&cls)); + + let cls = uclass(&[('a', 'a'), ('b', 'b')]); + let expected = vec![('a', 'b')]; + assert_eq!(expected, uranges(&cls)); + } + + #[test] + fn class_canonicalize_bytes() { + let cls = bclass(&[(b'a', b'c'), (b'x', b'z')]); + let expected = vec![(b'a', b'c'), (b'x', b'z')]; + assert_eq!(expected, branges(&cls)); + + let cls = bclass(&[(b'x', b'z'), (b'a', b'c')]); + let expected = vec![(b'a', b'c'), (b'x', b'z')]; + assert_eq!(expected, branges(&cls)); + + let cls = bclass(&[(b'x', b'z'), (b'w', b'y')]); + let expected = vec![(b'w', b'z')]; + assert_eq!(expected, branges(&cls)); + + let cls = bclass(&[ + (b'c', b'f'), + (b'a', b'g'), + (b'd', b'j'), + (b'a', b'c'), + (b'm', b'p'), + (b'l', b's'), + ]); + let expected = vec![(b'a', b'j'), (b'l', b's')]; + assert_eq!(expected, branges(&cls)); + + let cls = bclass(&[(b'x', b'z'), (b'u', b'w')]); + let expected = vec![(b'u', b'z')]; + assert_eq!(expected, branges(&cls)); + + let cls = bclass(&[(b'\x00', b'\xFF'), (b'\x00', b'\xFF')]); + let expected = vec![(b'\x00', b'\xFF')]; + assert_eq!(expected, branges(&cls)); + + let cls = bclass(&[(b'a', b'a'), (b'b', b'b')]); + let expected = vec![(b'a', b'b')]; + assert_eq!(expected, branges(&cls)); + } + + #[test] + #[cfg(feature = "unicode-case")] + fn class_case_fold_unicode() { + let cls = uclass(&[ + ('C', 'F'), + ('A', 'G'), + ('D', 'J'), + ('A', 'C'), + ('M', 'P'), + ('L', 'S'), + ('c', 'f'), + ]); + let expected = uclass(&[ + ('A', 'J'), + ('L', 'S'), + ('a', 'j'), + ('l', 's'), + ('\u{17F}', '\u{17F}'), + ]); + assert_eq!(expected, ucasefold(&cls)); + + let cls = uclass(&[('A', 'Z')]); + let expected = uclass(&[ + ('A', 'Z'), + ('a', 'z'), + ('\u{17F}', '\u{17F}'), + ('\u{212A}', '\u{212A}'), + ]); + assert_eq!(expected, ucasefold(&cls)); + + let cls = uclass(&[('a', 'z')]); + let expected = uclass(&[ + ('A', 'Z'), + ('a', 'z'), + ('\u{17F}', '\u{17F}'), + ('\u{212A}', '\u{212A}'), + ]); + assert_eq!(expected, ucasefold(&cls)); + + let cls = uclass(&[('A', 'A'), ('_', '_')]); + let expected = uclass(&[('A', 'A'), ('_', '_'), ('a', 'a')]); + assert_eq!(expected, ucasefold(&cls)); + + let cls = uclass(&[('A', 'A'), ('=', '=')]); + let expected = uclass(&[('=', '='), ('A', 'A'), ('a', 'a')]); + assert_eq!(expected, ucasefold(&cls)); + + let cls = uclass(&[('\x00', '\x10')]); + assert_eq!(cls, ucasefold(&cls)); + + let cls = uclass(&[('k', 'k')]); + let expected = + uclass(&[('K', 'K'), ('k', 'k'), ('\u{212A}', '\u{212A}')]); + assert_eq!(expected, ucasefold(&cls)); + + let cls = uclass(&[('@', '@')]); + assert_eq!(cls, ucasefold(&cls)); + } + + #[test] + #[cfg(not(feature = "unicode-case"))] + fn class_case_fold_unicode_disabled() { + let mut cls = uclass(&[ + ('C', 'F'), + ('A', 'G'), + ('D', 'J'), + ('A', 'C'), + ('M', 'P'), + ('L', 'S'), + ('c', 'f'), + ]); + assert!(cls.try_case_fold_simple().is_err()); + } + + #[test] + #[should_panic] + #[cfg(not(feature = "unicode-case"))] + fn class_case_fold_unicode_disabled_panics() { + let mut cls = uclass(&[ + ('C', 'F'), + ('A', 'G'), + ('D', 'J'), + ('A', 'C'), + ('M', 'P'), + ('L', 'S'), + ('c', 'f'), + ]); + cls.case_fold_simple(); + } + + #[test] + fn class_case_fold_bytes() { + let cls = bclass(&[ + (b'C', b'F'), + (b'A', b'G'), + (b'D', b'J'), + (b'A', b'C'), + (b'M', b'P'), + (b'L', b'S'), + (b'c', b'f'), + ]); + let expected = + bclass(&[(b'A', b'J'), (b'L', b'S'), (b'a', b'j'), (b'l', b's')]); + assert_eq!(expected, bcasefold(&cls)); + + let cls = bclass(&[(b'A', b'Z')]); + let expected = bclass(&[(b'A', b'Z'), (b'a', b'z')]); + assert_eq!(expected, bcasefold(&cls)); + + let cls = bclass(&[(b'a', b'z')]); + let expected = bclass(&[(b'A', b'Z'), (b'a', b'z')]); + assert_eq!(expected, bcasefold(&cls)); + + let cls = bclass(&[(b'A', b'A'), (b'_', b'_')]); + let expected = bclass(&[(b'A', b'A'), (b'_', b'_'), (b'a', b'a')]); + assert_eq!(expected, bcasefold(&cls)); + + let cls = bclass(&[(b'A', b'A'), (b'=', b'=')]); + let expected = bclass(&[(b'=', b'='), (b'A', b'A'), (b'a', b'a')]); + assert_eq!(expected, bcasefold(&cls)); + + let cls = bclass(&[(b'\x00', b'\x10')]); + assert_eq!(cls, bcasefold(&cls)); + + let cls = bclass(&[(b'k', b'k')]); + let expected = bclass(&[(b'K', b'K'), (b'k', b'k')]); + assert_eq!(expected, bcasefold(&cls)); + + let cls = bclass(&[(b'@', b'@')]); + assert_eq!(cls, bcasefold(&cls)); + } + + #[test] + fn class_negate_unicode() { + let cls = uclass(&[('a', 'a')]); + let expected = uclass(&[('\x00', '\x60'), ('\x62', '\u{10FFFF}')]); + assert_eq!(expected, unegate(&cls)); + + let cls = uclass(&[('a', 'a'), ('b', 'b')]); + let expected = uclass(&[('\x00', '\x60'), ('\x63', '\u{10FFFF}')]); + assert_eq!(expected, unegate(&cls)); + + let cls = uclass(&[('a', 'c'), ('x', 'z')]); + let expected = uclass(&[ + ('\x00', '\x60'), + ('\x64', '\x77'), + ('\x7B', '\u{10FFFF}'), + ]); + assert_eq!(expected, unegate(&cls)); + + let cls = uclass(&[('\x00', 'a')]); + let expected = uclass(&[('\x62', '\u{10FFFF}')]); + assert_eq!(expected, unegate(&cls)); + + let cls = uclass(&[('a', '\u{10FFFF}')]); + let expected = uclass(&[('\x00', '\x60')]); + assert_eq!(expected, unegate(&cls)); + + let cls = uclass(&[('\x00', '\u{10FFFF}')]); + let expected = uclass(&[]); + assert_eq!(expected, unegate(&cls)); + + let cls = uclass(&[]); + let expected = uclass(&[('\x00', '\u{10FFFF}')]); + assert_eq!(expected, unegate(&cls)); + + let cls = + uclass(&[('\x00', '\u{10FFFD}'), ('\u{10FFFF}', '\u{10FFFF}')]); + let expected = uclass(&[('\u{10FFFE}', '\u{10FFFE}')]); + assert_eq!(expected, unegate(&cls)); + + let cls = uclass(&[('\x00', '\u{D7FF}')]); + let expected = uclass(&[('\u{E000}', '\u{10FFFF}')]); + assert_eq!(expected, unegate(&cls)); + + let cls = uclass(&[('\x00', '\u{D7FE}')]); + let expected = uclass(&[('\u{D7FF}', '\u{10FFFF}')]); + assert_eq!(expected, unegate(&cls)); + + let cls = uclass(&[('\u{E000}', '\u{10FFFF}')]); + let expected = uclass(&[('\x00', '\u{D7FF}')]); + assert_eq!(expected, unegate(&cls)); + + let cls = uclass(&[('\u{E001}', '\u{10FFFF}')]); + let expected = uclass(&[('\x00', '\u{E000}')]); + assert_eq!(expected, unegate(&cls)); + } + + #[test] + fn class_negate_bytes() { + let cls = bclass(&[(b'a', b'a')]); + let expected = bclass(&[(b'\x00', b'\x60'), (b'\x62', b'\xFF')]); + assert_eq!(expected, bnegate(&cls)); + + let cls = bclass(&[(b'a', b'a'), (b'b', b'b')]); + let expected = bclass(&[(b'\x00', b'\x60'), (b'\x63', b'\xFF')]); + assert_eq!(expected, bnegate(&cls)); + + let cls = bclass(&[(b'a', b'c'), (b'x', b'z')]); + let expected = bclass(&[ + (b'\x00', b'\x60'), + (b'\x64', b'\x77'), + (b'\x7B', b'\xFF'), + ]); + assert_eq!(expected, bnegate(&cls)); + + let cls = bclass(&[(b'\x00', b'a')]); + let expected = bclass(&[(b'\x62', b'\xFF')]); + assert_eq!(expected, bnegate(&cls)); + + let cls = bclass(&[(b'a', b'\xFF')]); + let expected = bclass(&[(b'\x00', b'\x60')]); + assert_eq!(expected, bnegate(&cls)); + + let cls = bclass(&[(b'\x00', b'\xFF')]); + let expected = bclass(&[]); + assert_eq!(expected, bnegate(&cls)); + + let cls = bclass(&[]); + let expected = bclass(&[(b'\x00', b'\xFF')]); + assert_eq!(expected, bnegate(&cls)); + + let cls = bclass(&[(b'\x00', b'\xFD'), (b'\xFF', b'\xFF')]); + let expected = bclass(&[(b'\xFE', b'\xFE')]); + assert_eq!(expected, bnegate(&cls)); + } + + #[test] + fn class_union_unicode() { + let cls1 = uclass(&[('a', 'g'), ('m', 't'), ('A', 'C')]); + let cls2 = uclass(&[('a', 'z')]); + let expected = uclass(&[('a', 'z'), ('A', 'C')]); + assert_eq!(expected, uunion(&cls1, &cls2)); + } + + #[test] + fn class_union_bytes() { + let cls1 = bclass(&[(b'a', b'g'), (b'm', b't'), (b'A', b'C')]); + let cls2 = bclass(&[(b'a', b'z')]); + let expected = bclass(&[(b'a', b'z'), (b'A', b'C')]); + assert_eq!(expected, bunion(&cls1, &cls2)); + } + + #[test] + fn class_intersect_unicode() { + let cls1 = uclass(&[]); + let cls2 = uclass(&[('a', 'a')]); + let expected = uclass(&[]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'a')]); + let cls2 = uclass(&[('a', 'a')]); + let expected = uclass(&[('a', 'a')]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'a')]); + let cls2 = uclass(&[('b', 'b')]); + let expected = uclass(&[]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'a')]); + let cls2 = uclass(&[('a', 'c')]); + let expected = uclass(&[('a', 'a')]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'b')]); + let cls2 = uclass(&[('a', 'c')]); + let expected = uclass(&[('a', 'b')]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'b')]); + let cls2 = uclass(&[('b', 'c')]); + let expected = uclass(&[('b', 'b')]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'b')]); + let cls2 = uclass(&[('c', 'd')]); + let expected = uclass(&[]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('b', 'c')]); + let cls2 = uclass(&[('a', 'd')]); + let expected = uclass(&[('b', 'c')]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'b'), ('d', 'e'), ('g', 'h')]); + let cls2 = uclass(&[('a', 'h')]); + let expected = uclass(&[('a', 'b'), ('d', 'e'), ('g', 'h')]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'b'), ('d', 'e'), ('g', 'h')]); + let cls2 = uclass(&[('a', 'b'), ('d', 'e'), ('g', 'h')]); + let expected = uclass(&[('a', 'b'), ('d', 'e'), ('g', 'h')]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'b'), ('g', 'h')]); + let cls2 = uclass(&[('d', 'e'), ('k', 'l')]); + let expected = uclass(&[]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'b'), ('d', 'e'), ('g', 'h')]); + let cls2 = uclass(&[('h', 'h')]); + let expected = uclass(&[('h', 'h')]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'b'), ('e', 'f'), ('i', 'j')]); + let cls2 = uclass(&[('c', 'd'), ('g', 'h'), ('k', 'l')]); + let expected = uclass(&[]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'b'), ('c', 'd'), ('e', 'f')]); + let cls2 = uclass(&[('b', 'c'), ('d', 'e'), ('f', 'g')]); + let expected = uclass(&[('b', 'f')]); + assert_eq!(expected, uintersect(&cls1, &cls2)); + } + + #[test] + fn class_intersect_bytes() { + let cls1 = bclass(&[]); + let cls2 = bclass(&[(b'a', b'a')]); + let expected = bclass(&[]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'a')]); + let cls2 = bclass(&[(b'a', b'a')]); + let expected = bclass(&[(b'a', b'a')]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'a')]); + let cls2 = bclass(&[(b'b', b'b')]); + let expected = bclass(&[]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'a')]); + let cls2 = bclass(&[(b'a', b'c')]); + let expected = bclass(&[(b'a', b'a')]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'b')]); + let cls2 = bclass(&[(b'a', b'c')]); + let expected = bclass(&[(b'a', b'b')]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'b')]); + let cls2 = bclass(&[(b'b', b'c')]); + let expected = bclass(&[(b'b', b'b')]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'b')]); + let cls2 = bclass(&[(b'c', b'd')]); + let expected = bclass(&[]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'b', b'c')]); + let cls2 = bclass(&[(b'a', b'd')]); + let expected = bclass(&[(b'b', b'c')]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'b'), (b'd', b'e'), (b'g', b'h')]); + let cls2 = bclass(&[(b'a', b'h')]); + let expected = bclass(&[(b'a', b'b'), (b'd', b'e'), (b'g', b'h')]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'b'), (b'd', b'e'), (b'g', b'h')]); + let cls2 = bclass(&[(b'a', b'b'), (b'd', b'e'), (b'g', b'h')]); + let expected = bclass(&[(b'a', b'b'), (b'd', b'e'), (b'g', b'h')]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'b'), (b'g', b'h')]); + let cls2 = bclass(&[(b'd', b'e'), (b'k', b'l')]); + let expected = bclass(&[]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'b'), (b'd', b'e'), (b'g', b'h')]); + let cls2 = bclass(&[(b'h', b'h')]); + let expected = bclass(&[(b'h', b'h')]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'b'), (b'e', b'f'), (b'i', b'j')]); + let cls2 = bclass(&[(b'c', b'd'), (b'g', b'h'), (b'k', b'l')]); + let expected = bclass(&[]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'b'), (b'c', b'd'), (b'e', b'f')]); + let cls2 = bclass(&[(b'b', b'c'), (b'd', b'e'), (b'f', b'g')]); + let expected = bclass(&[(b'b', b'f')]); + assert_eq!(expected, bintersect(&cls1, &cls2)); + } + + #[test] + fn class_difference_unicode() { + let cls1 = uclass(&[('a', 'a')]); + let cls2 = uclass(&[('a', 'a')]); + let expected = uclass(&[]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'a')]); + let cls2 = uclass(&[]); + let expected = uclass(&[('a', 'a')]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[]); + let cls2 = uclass(&[('a', 'a')]); + let expected = uclass(&[]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'z')]); + let cls2 = uclass(&[('a', 'a')]); + let expected = uclass(&[('b', 'z')]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'z')]); + let cls2 = uclass(&[('z', 'z')]); + let expected = uclass(&[('a', 'y')]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'z')]); + let cls2 = uclass(&[('m', 'm')]); + let expected = uclass(&[('a', 'l'), ('n', 'z')]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'c'), ('g', 'i'), ('r', 't')]); + let cls2 = uclass(&[('a', 'z')]); + let expected = uclass(&[]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'c'), ('g', 'i'), ('r', 't')]); + let cls2 = uclass(&[('d', 'v')]); + let expected = uclass(&[('a', 'c')]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'c'), ('g', 'i'), ('r', 't')]); + let cls2 = uclass(&[('b', 'g'), ('s', 'u')]); + let expected = uclass(&[('a', 'a'), ('h', 'i'), ('r', 'r')]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'c'), ('g', 'i'), ('r', 't')]); + let cls2 = uclass(&[('b', 'd'), ('e', 'g'), ('s', 'u')]); + let expected = uclass(&[('a', 'a'), ('h', 'i'), ('r', 'r')]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[('x', 'z')]); + let cls2 = uclass(&[('a', 'c'), ('e', 'g'), ('s', 'u')]); + let expected = uclass(&[('x', 'z')]); + assert_eq!(expected, udifference(&cls1, &cls2)); + + let cls1 = uclass(&[('a', 'z')]); + let cls2 = uclass(&[('a', 'c'), ('e', 'g'), ('s', 'u')]); + let expected = uclass(&[('d', 'd'), ('h', 'r'), ('v', 'z')]); + assert_eq!(expected, udifference(&cls1, &cls2)); + } + + #[test] + fn class_difference_bytes() { + let cls1 = bclass(&[(b'a', b'a')]); + let cls2 = bclass(&[(b'a', b'a')]); + let expected = bclass(&[]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'a')]); + let cls2 = bclass(&[]); + let expected = bclass(&[(b'a', b'a')]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[]); + let cls2 = bclass(&[(b'a', b'a')]); + let expected = bclass(&[]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'z')]); + let cls2 = bclass(&[(b'a', b'a')]); + let expected = bclass(&[(b'b', b'z')]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'z')]); + let cls2 = bclass(&[(b'z', b'z')]); + let expected = bclass(&[(b'a', b'y')]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'z')]); + let cls2 = bclass(&[(b'm', b'm')]); + let expected = bclass(&[(b'a', b'l'), (b'n', b'z')]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'c'), (b'g', b'i'), (b'r', b't')]); + let cls2 = bclass(&[(b'a', b'z')]); + let expected = bclass(&[]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'c'), (b'g', b'i'), (b'r', b't')]); + let cls2 = bclass(&[(b'd', b'v')]); + let expected = bclass(&[(b'a', b'c')]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'c'), (b'g', b'i'), (b'r', b't')]); + let cls2 = bclass(&[(b'b', b'g'), (b's', b'u')]); + let expected = bclass(&[(b'a', b'a'), (b'h', b'i'), (b'r', b'r')]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'c'), (b'g', b'i'), (b'r', b't')]); + let cls2 = bclass(&[(b'b', b'd'), (b'e', b'g'), (b's', b'u')]); + let expected = bclass(&[(b'a', b'a'), (b'h', b'i'), (b'r', b'r')]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[(b'x', b'z')]); + let cls2 = bclass(&[(b'a', b'c'), (b'e', b'g'), (b's', b'u')]); + let expected = bclass(&[(b'x', b'z')]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + + let cls1 = bclass(&[(b'a', b'z')]); + let cls2 = bclass(&[(b'a', b'c'), (b'e', b'g'), (b's', b'u')]); + let expected = bclass(&[(b'd', b'd'), (b'h', b'r'), (b'v', b'z')]); + assert_eq!(expected, bdifference(&cls1, &cls2)); + } + + #[test] + fn class_symmetric_difference_unicode() { + let cls1 = uclass(&[('a', 'm')]); + let cls2 = uclass(&[('g', 't')]); + let expected = uclass(&[('a', 'f'), ('n', 't')]); + assert_eq!(expected, usymdifference(&cls1, &cls2)); + } + + #[test] + fn class_symmetric_difference_bytes() { + let cls1 = bclass(&[(b'a', b'm')]); + let cls2 = bclass(&[(b'g', b't')]); + let expected = bclass(&[(b'a', b'f'), (b'n', b't')]); + assert_eq!(expected, bsymdifference(&cls1, &cls2)); + } + + #[test] + #[should_panic] + fn hir_byte_literal_non_ascii() { + Hir::literal(Literal::Byte(b'a')); + } + + // We use a thread with an explicit stack size to test that our destructor + // for Hir can handle arbitrarily sized expressions in constant stack + // space. In case we run on a platform without threads (WASM?), we limit + // this test to Windows/Unix. + #[test] + #[cfg(any(unix, windows))] + fn no_stack_overflow_on_drop() { + use std::thread; + + let run = || { + let mut expr = Hir::empty(); + for _ in 0..100 { + expr = Hir::group(Group { + kind: GroupKind::NonCapturing, + hir: Box::new(expr), + }); + expr = Hir::repetition(Repetition { + kind: RepetitionKind::ZeroOrOne, + greedy: true, + hir: Box::new(expr), + }); + + expr = Hir { + kind: HirKind::Concat(vec![expr]), + info: HirInfo::new(), + }; + expr = Hir { + kind: HirKind::Alternation(vec![expr]), + info: HirInfo::new(), + }; + } + assert!(!expr.kind.is_empty()); + }; + + // We run our test on a thread with a small stack size so we can + // force the issue more easily. + thread::Builder::new() + .stack_size(1 << 10) + .spawn(run) + .unwrap() + .join() + .unwrap(); + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/print.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/print.rs new file mode 100644 index 0000000..eb44b93 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/print.rs @@ -0,0 +1,368 @@ +/*! +This module provides a regular expression printer for `Hir`. +*/ + +use std::fmt; + +use hir::visitor::{self, Visitor}; +use hir::{self, Hir, HirKind}; +use is_meta_character; + +/// A builder for constructing a printer. +/// +/// Note that since a printer doesn't have any configuration knobs, this type +/// remains unexported. +#[derive(Clone, Debug)] +struct PrinterBuilder { + _priv: (), +} + +impl Default for PrinterBuilder { + fn default() -> PrinterBuilder { + PrinterBuilder::new() + } +} + +impl PrinterBuilder { + fn new() -> PrinterBuilder { + PrinterBuilder { _priv: () } + } + + fn build(&self) -> Printer { + Printer { _priv: () } + } +} + +/// A printer for a regular expression's high-level intermediate +/// representation. +/// +/// A printer converts a high-level intermediate representation (HIR) to a +/// regular expression pattern string. This particular printer uses constant +/// stack space and heap space proportional to the size of the HIR. +/// +/// Since this printer is only using the HIR, the pattern it prints will likely +/// not resemble the original pattern at all. For example, a pattern like +/// `\pL` will have its entire class written out. +/// +/// The purpose of this printer is to provide a means to mutate an HIR and then +/// build a regular expression from the result of that mutation. (A regex +/// library could provide a constructor from this HIR explicitly, but that +/// creates an unnecessary public coupling between the regex library and this +/// specific HIR representation.) +#[derive(Debug)] +pub struct Printer { + _priv: (), +} + +impl Printer { + /// Create a new printer. + pub fn new() -> Printer { + PrinterBuilder::new().build() + } + + /// Print the given `Ast` to the given writer. The writer must implement + /// `fmt::Write`. Typical implementations of `fmt::Write` that can be used + /// here are a `fmt::Formatter` (which is available in `fmt::Display` + /// implementations) or a `&mut String`. + pub fn print<W: fmt::Write>(&mut self, hir: &Hir, wtr: W) -> fmt::Result { + visitor::visit(hir, Writer { printer: self, wtr: wtr }) + } +} + +#[derive(Debug)] +struct Writer<'p, W> { + printer: &'p mut Printer, + wtr: W, +} + +impl<'p, W: fmt::Write> Visitor for Writer<'p, W> { + type Output = (); + type Err = fmt::Error; + + fn finish(self) -> fmt::Result { + Ok(()) + } + + fn visit_pre(&mut self, hir: &Hir) -> fmt::Result { + match *hir.kind() { + HirKind::Empty + | HirKind::Repetition(_) + | HirKind::Concat(_) + | HirKind::Alternation(_) => {} + HirKind::Literal(hir::Literal::Unicode(c)) => { + self.write_literal_char(c)?; + } + HirKind::Literal(hir::Literal::Byte(b)) => { + self.write_literal_byte(b)?; + } + HirKind::Class(hir::Class::Unicode(ref cls)) => { + self.wtr.write_str("[")?; + for range in cls.iter() { + if range.start() == range.end() { + self.write_literal_char(range.start())?; + } else { + self.write_literal_char(range.start())?; + self.wtr.write_str("-")?; + self.write_literal_char(range.end())?; + } + } + self.wtr.write_str("]")?; + } + HirKind::Class(hir::Class::Bytes(ref cls)) => { + self.wtr.write_str("(?-u:[")?; + for range in cls.iter() { + if range.start() == range.end() { + self.write_literal_class_byte(range.start())?; + } else { + self.write_literal_class_byte(range.start())?; + self.wtr.write_str("-")?; + self.write_literal_class_byte(range.end())?; + } + } + self.wtr.write_str("])")?; + } + HirKind::Anchor(hir::Anchor::StartLine) => { + self.wtr.write_str("(?m:^)")?; + } + HirKind::Anchor(hir::Anchor::EndLine) => { + self.wtr.write_str("(?m:$)")?; + } + HirKind::Anchor(hir::Anchor::StartText) => { + self.wtr.write_str(r"\A")?; + } + HirKind::Anchor(hir::Anchor::EndText) => { + self.wtr.write_str(r"\z")?; + } + HirKind::WordBoundary(hir::WordBoundary::Unicode) => { + self.wtr.write_str(r"\b")?; + } + HirKind::WordBoundary(hir::WordBoundary::UnicodeNegate) => { + self.wtr.write_str(r"\B")?; + } + HirKind::WordBoundary(hir::WordBoundary::Ascii) => { + self.wtr.write_str(r"(?-u:\b)")?; + } + HirKind::WordBoundary(hir::WordBoundary::AsciiNegate) => { + self.wtr.write_str(r"(?-u:\B)")?; + } + HirKind::Group(ref x) => match x.kind { + hir::GroupKind::CaptureIndex(_) => { + self.wtr.write_str("(")?; + } + hir::GroupKind::CaptureName { ref name, .. } => { + write!(self.wtr, "(?P<{}>", name)?; + } + hir::GroupKind::NonCapturing => { + self.wtr.write_str("(?:")?; + } + }, + } + Ok(()) + } + + fn visit_post(&mut self, hir: &Hir) -> fmt::Result { + match *hir.kind() { + // Handled during visit_pre + HirKind::Empty + | HirKind::Literal(_) + | HirKind::Class(_) + | HirKind::Anchor(_) + | HirKind::WordBoundary(_) + | HirKind::Concat(_) + | HirKind::Alternation(_) => {} + HirKind::Repetition(ref x) => { + match x.kind { + hir::RepetitionKind::ZeroOrOne => { + self.wtr.write_str("?")?; + } + hir::RepetitionKind::ZeroOrMore => { + self.wtr.write_str("*")?; + } + hir::RepetitionKind::OneOrMore => { + self.wtr.write_str("+")?; + } + hir::RepetitionKind::Range(ref x) => match *x { + hir::RepetitionRange::Exactly(m) => { + write!(self.wtr, "{{{}}}", m)?; + } + hir::RepetitionRange::AtLeast(m) => { + write!(self.wtr, "{{{},}}", m)?; + } + hir::RepetitionRange::Bounded(m, n) => { + write!(self.wtr, "{{{},{}}}", m, n)?; + } + }, + } + if !x.greedy { + self.wtr.write_str("?")?; + } + } + HirKind::Group(_) => { + self.wtr.write_str(")")?; + } + } + Ok(()) + } + + fn visit_alternation_in(&mut self) -> fmt::Result { + self.wtr.write_str("|") + } +} + +impl<'p, W: fmt::Write> Writer<'p, W> { + fn write_literal_char(&mut self, c: char) -> fmt::Result { + if is_meta_character(c) { + self.wtr.write_str("\\")?; + } + self.wtr.write_char(c) + } + + fn write_literal_byte(&mut self, b: u8) -> fmt::Result { + let c = b as char; + if c <= 0x7F as char && !c.is_control() && !c.is_whitespace() { + self.write_literal_char(c) + } else { + write!(self.wtr, "(?-u:\\x{:02X})", b) + } + } + + fn write_literal_class_byte(&mut self, b: u8) -> fmt::Result { + let c = b as char; + if c <= 0x7F as char && !c.is_control() && !c.is_whitespace() { + self.write_literal_char(c) + } else { + write!(self.wtr, "\\x{:02X}", b) + } + } +} + +#[cfg(test)] +mod tests { + use super::Printer; + use ParserBuilder; + + fn roundtrip(given: &str, expected: &str) { + roundtrip_with(|b| b, given, expected); + } + + fn roundtrip_bytes(given: &str, expected: &str) { + roundtrip_with(|b| b.allow_invalid_utf8(true), given, expected); + } + + fn roundtrip_with<F>(mut f: F, given: &str, expected: &str) + where + F: FnMut(&mut ParserBuilder) -> &mut ParserBuilder, + { + let mut builder = ParserBuilder::new(); + f(&mut builder); + let hir = builder.build().parse(given).unwrap(); + + let mut printer = Printer::new(); + let mut dst = String::new(); + printer.print(&hir, &mut dst).unwrap(); + + // Check that the result is actually valid. + builder.build().parse(&dst).unwrap(); + + assert_eq!(expected, dst); + } + + #[test] + fn print_literal() { + roundtrip("a", "a"); + roundtrip(r"\xff", "\u{FF}"); + roundtrip_bytes(r"\xff", "\u{FF}"); + roundtrip_bytes(r"(?-u)\xff", r"(?-u:\xFF)"); + roundtrip("☃", "☃"); + } + + #[test] + fn print_class() { + roundtrip(r"[a]", r"[a]"); + roundtrip(r"[a-z]", r"[a-z]"); + roundtrip(r"[a-z--b-c--x-y]", r"[ad-wz]"); + roundtrip(r"[^\x01-\u{10FFFF}]", "[\u{0}]"); + roundtrip(r"[-]", r"[\-]"); + roundtrip(r"[☃-⛄]", r"[☃-⛄]"); + + roundtrip(r"(?-u)[a]", r"(?-u:[a])"); + roundtrip(r"(?-u)[a-z]", r"(?-u:[a-z])"); + roundtrip_bytes(r"(?-u)[a-\xFF]", r"(?-u:[a-\xFF])"); + + // The following test that the printer escapes meta characters + // in character classes. + roundtrip(r"[\[]", r"[\[]"); + roundtrip(r"[Z-_]", r"[Z-_]"); + roundtrip(r"[Z-_--Z]", r"[\[-_]"); + + // The following test that the printer escapes meta characters + // in byte oriented character classes. + roundtrip_bytes(r"(?-u)[\[]", r"(?-u:[\[])"); + roundtrip_bytes(r"(?-u)[Z-_]", r"(?-u:[Z-_])"); + roundtrip_bytes(r"(?-u)[Z-_--Z]", r"(?-u:[\[-_])"); + } + + #[test] + fn print_anchor() { + roundtrip(r"^", r"\A"); + roundtrip(r"$", r"\z"); + roundtrip(r"(?m)^", r"(?m:^)"); + roundtrip(r"(?m)$", r"(?m:$)"); + } + + #[test] + fn print_word_boundary() { + roundtrip(r"\b", r"\b"); + roundtrip(r"\B", r"\B"); + roundtrip(r"(?-u)\b", r"(?-u:\b)"); + roundtrip_bytes(r"(?-u)\B", r"(?-u:\B)"); + } + + #[test] + fn print_repetition() { + roundtrip("a?", "a?"); + roundtrip("a??", "a??"); + roundtrip("(?U)a?", "a??"); + + roundtrip("a*", "a*"); + roundtrip("a*?", "a*?"); + roundtrip("(?U)a*", "a*?"); + + roundtrip("a+", "a+"); + roundtrip("a+?", "a+?"); + roundtrip("(?U)a+", "a+?"); + + roundtrip("a{1}", "a{1}"); + roundtrip("a{1,}", "a{1,}"); + roundtrip("a{1,5}", "a{1,5}"); + roundtrip("a{1}?", "a{1}?"); + roundtrip("a{1,}?", "a{1,}?"); + roundtrip("a{1,5}?", "a{1,5}?"); + roundtrip("(?U)a{1}", "a{1}?"); + roundtrip("(?U)a{1,}", "a{1,}?"); + roundtrip("(?U)a{1,5}", "a{1,5}?"); + } + + #[test] + fn print_group() { + roundtrip("()", "()"); + roundtrip("(?P<foo>)", "(?P<foo>)"); + roundtrip("(?:)", "(?:)"); + + roundtrip("(a)", "(a)"); + roundtrip("(?P<foo>a)", "(?P<foo>a)"); + roundtrip("(?:a)", "(?:a)"); + + roundtrip("((((a))))", "((((a))))"); + } + + #[test] + fn print_alternation() { + roundtrip("|", "|"); + roundtrip("||", "||"); + + roundtrip("a|b", "a|b"); + roundtrip("a|b|c", "a|b|c"); + roundtrip("foo|bar|quux", "foo|bar|quux"); + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/translate.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/translate.rs new file mode 100644 index 0000000..3db8796 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/translate.rs @@ -0,0 +1,3132 @@ +/*! +Defines a translator that converts an `Ast` to an `Hir`. +*/ + +use std::cell::{Cell, RefCell}; +use std::result; + +use ast::{self, Ast, Span, Visitor}; +use hir::{self, Error, ErrorKind, Hir}; +use unicode::{self, ClassQuery}; + +type Result<T> = result::Result<T, Error>; + +/// A builder for constructing an AST->HIR translator. +#[derive(Clone, Debug)] +pub struct TranslatorBuilder { + allow_invalid_utf8: bool, + flags: Flags, +} + +impl Default for TranslatorBuilder { + fn default() -> TranslatorBuilder { + TranslatorBuilder::new() + } +} + +impl TranslatorBuilder { + /// Create a new translator builder with a default c onfiguration. + pub fn new() -> TranslatorBuilder { + TranslatorBuilder { + allow_invalid_utf8: false, + flags: Flags::default(), + } + } + + /// Build a translator using the current configuration. + pub fn build(&self) -> Translator { + Translator { + stack: RefCell::new(vec![]), + flags: Cell::new(self.flags), + allow_invalid_utf8: self.allow_invalid_utf8, + } + } + + /// When enabled, translation will permit the construction of a regular + /// expression that may match invalid UTF-8. + /// + /// When disabled (the default), the translator is guaranteed to produce + /// an expression that will only ever match valid UTF-8 (otherwise, the + /// translator will return an error). + /// + /// Perhaps surprisingly, when invalid UTF-8 isn't allowed, a negated ASCII + /// word boundary (uttered as `(?-u:\B)` in the concrete syntax) will cause + /// the parser to return an error. Namely, a negated ASCII word boundary + /// can result in matching positions that aren't valid UTF-8 boundaries. + pub fn allow_invalid_utf8(&mut self, yes: bool) -> &mut TranslatorBuilder { + self.allow_invalid_utf8 = yes; + self + } + + /// Enable or disable the case insensitive flag (`i`) by default. + pub fn case_insensitive(&mut self, yes: bool) -> &mut TranslatorBuilder { + self.flags.case_insensitive = if yes { Some(true) } else { None }; + self + } + + /// Enable or disable the multi-line matching flag (`m`) by default. + pub fn multi_line(&mut self, yes: bool) -> &mut TranslatorBuilder { + self.flags.multi_line = if yes { Some(true) } else { None }; + self + } + + /// Enable or disable the "dot matches any character" flag (`s`) by + /// default. + pub fn dot_matches_new_line( + &mut self, + yes: bool, + ) -> &mut TranslatorBuilder { + self.flags.dot_matches_new_line = if yes { Some(true) } else { None }; + self + } + + /// Enable or disable the "swap greed" flag (`U`) by default. + pub fn swap_greed(&mut self, yes: bool) -> &mut TranslatorBuilder { + self.flags.swap_greed = if yes { Some(true) } else { None }; + self + } + + /// Enable or disable the Unicode flag (`u`) by default. + pub fn unicode(&mut self, yes: bool) -> &mut TranslatorBuilder { + self.flags.unicode = if yes { None } else { Some(false) }; + self + } +} + +/// A translator maps abstract syntax to a high level intermediate +/// representation. +/// +/// A translator may be benefit from reuse. That is, a translator can translate +/// many abstract syntax trees. +/// +/// A `Translator` can be configured in more detail via a +/// [`TranslatorBuilder`](struct.TranslatorBuilder.html). +#[derive(Clone, Debug)] +pub struct Translator { + /// Our call stack, but on the heap. + stack: RefCell<Vec<HirFrame>>, + /// The current flag settings. + flags: Cell<Flags>, + /// Whether we're allowed to produce HIR that can match arbitrary bytes. + allow_invalid_utf8: bool, +} + +impl Translator { + /// Create a new translator using the default configuration. + pub fn new() -> Translator { + TranslatorBuilder::new().build() + } + + /// Translate the given abstract syntax tree (AST) into a high level + /// intermediate representation (HIR). + /// + /// If there was a problem doing the translation, then an HIR-specific + /// error is returned. + /// + /// The original pattern string used to produce the `Ast` *must* also be + /// provided. The translator does not use the pattern string during any + /// correct translation, but is used for error reporting. + pub fn translate(&mut self, pattern: &str, ast: &Ast) -> Result<Hir> { + ast::visit(ast, TranslatorI::new(self, pattern)) + } +} + +/// An HirFrame is a single stack frame, represented explicitly, which is +/// created for each item in the Ast that we traverse. +/// +/// Note that technically, this type doesn't represent our entire stack +/// frame. In particular, the Ast visitor represents any state associated with +/// traversing the Ast itself. +#[derive(Clone, Debug)] +enum HirFrame { + /// An arbitrary HIR expression. These get pushed whenever we hit a base + /// case in the Ast. They get popped after an inductive (i.e., recursive) + /// step is complete. + Expr(Hir), + /// A Unicode character class. This frame is mutated as we descend into + /// the Ast of a character class (which is itself its own mini recursive + /// structure). + ClassUnicode(hir::ClassUnicode), + /// A byte-oriented character class. This frame is mutated as we descend + /// into the Ast of a character class (which is itself its own mini + /// recursive structure). + /// + /// Byte character classes are created when Unicode mode (`u`) is disabled. + /// If `allow_invalid_utf8` is disabled (the default), then a byte + /// character is only permitted to match ASCII text. + ClassBytes(hir::ClassBytes), + /// This is pushed on to the stack upon first seeing any kind of group, + /// indicated by parentheses (including non-capturing groups). It is popped + /// upon leaving a group. + Group { + /// The old active flags, if any, when this group was opened. + /// + /// If this group sets flags, then the new active flags are set to the + /// result of merging the old flags with the flags introduced by this + /// group. + /// + /// When this group is popped, the active flags should be restored to + /// the flags set here. + /// + /// The "active" flags correspond to whatever flags are set in the + /// Translator. + old_flags: Option<Flags>, + }, + /// This is pushed whenever a concatenation is observed. After visiting + /// every sub-expression in the concatenation, the translator's stack is + /// popped until it sees a Concat frame. + Concat, + /// This is pushed whenever an alternation is observed. After visiting + /// every sub-expression in the alternation, the translator's stack is + /// popped until it sees an Alternation frame. + Alternation, +} + +impl HirFrame { + /// Assert that the current stack frame is an Hir expression and return it. + fn unwrap_expr(self) -> Hir { + match self { + HirFrame::Expr(expr) => expr, + _ => panic!("tried to unwrap expr from HirFrame, got: {:?}", self), + } + } + + /// Assert that the current stack frame is a Unicode class expression and + /// return it. + fn unwrap_class_unicode(self) -> hir::ClassUnicode { + match self { + HirFrame::ClassUnicode(cls) => cls, + _ => panic!( + "tried to unwrap Unicode class \ + from HirFrame, got: {:?}", + self + ), + } + } + + /// Assert that the current stack frame is a byte class expression and + /// return it. + fn unwrap_class_bytes(self) -> hir::ClassBytes { + match self { + HirFrame::ClassBytes(cls) => cls, + _ => panic!( + "tried to unwrap byte class \ + from HirFrame, got: {:?}", + self + ), + } + } + + /// Assert that the current stack frame is a group indicator and return + /// its corresponding flags (the flags that were active at the time the + /// group was entered) if they exist. + fn unwrap_group(self) -> Option<Flags> { + match self { + HirFrame::Group { old_flags } => old_flags, + _ => { + panic!("tried to unwrap group from HirFrame, got: {:?}", self) + } + } + } +} + +impl<'t, 'p> Visitor for TranslatorI<'t, 'p> { + type Output = Hir; + type Err = Error; + + fn finish(self) -> Result<Hir> { + // ... otherwise, we should have exactly one HIR on the stack. + assert_eq!(self.trans().stack.borrow().len(), 1); + Ok(self.pop().unwrap().unwrap_expr()) + } + + fn visit_pre(&mut self, ast: &Ast) -> Result<()> { + match *ast { + Ast::Class(ast::Class::Bracketed(_)) => { + if self.flags().unicode() { + let cls = hir::ClassUnicode::empty(); + self.push(HirFrame::ClassUnicode(cls)); + } else { + let cls = hir::ClassBytes::empty(); + self.push(HirFrame::ClassBytes(cls)); + } + } + Ast::Group(ref x) => { + let old_flags = x.flags().map(|ast| self.set_flags(ast)); + self.push(HirFrame::Group { old_flags: old_flags }); + } + Ast::Concat(ref x) if x.asts.is_empty() => {} + Ast::Concat(_) => { + self.push(HirFrame::Concat); + } + Ast::Alternation(ref x) if x.asts.is_empty() => {} + Ast::Alternation(_) => { + self.push(HirFrame::Alternation); + } + _ => {} + } + Ok(()) + } + + fn visit_post(&mut self, ast: &Ast) -> Result<()> { + match *ast { + Ast::Empty(_) => { + self.push(HirFrame::Expr(Hir::empty())); + } + Ast::Flags(ref x) => { + self.set_flags(&x.flags); + // Flags in the AST are generally considered directives and + // not actual sub-expressions. However, they can be used in + // the concrete syntax like `((?i))`, and we need some kind of + // indication of an expression there, and Empty is the correct + // choice. + // + // There can also be things like `(?i)+`, but we rule those out + // in the parser. In the future, we might allow them for + // consistency sake. + self.push(HirFrame::Expr(Hir::empty())); + } + Ast::Literal(ref x) => { + self.push(HirFrame::Expr(self.hir_literal(x)?)); + } + Ast::Dot(span) => { + self.push(HirFrame::Expr(self.hir_dot(span)?)); + } + Ast::Assertion(ref x) => { + self.push(HirFrame::Expr(self.hir_assertion(x)?)); + } + Ast::Class(ast::Class::Perl(ref x)) => { + if self.flags().unicode() { + let cls = self.hir_perl_unicode_class(x)?; + let hcls = hir::Class::Unicode(cls); + self.push(HirFrame::Expr(Hir::class(hcls))); + } else { + let cls = self.hir_perl_byte_class(x); + let hcls = hir::Class::Bytes(cls); + self.push(HirFrame::Expr(Hir::class(hcls))); + } + } + Ast::Class(ast::Class::Unicode(ref x)) => { + let cls = hir::Class::Unicode(self.hir_unicode_class(x)?); + self.push(HirFrame::Expr(Hir::class(cls))); + } + Ast::Class(ast::Class::Bracketed(ref ast)) => { + if self.flags().unicode() { + let mut cls = self.pop().unwrap().unwrap_class_unicode(); + self.unicode_fold_and_negate( + &ast.span, + ast.negated, + &mut cls, + )?; + if cls.iter().next().is_none() { + return Err(self.error( + ast.span, + ErrorKind::EmptyClassNotAllowed, + )); + } + let expr = Hir::class(hir::Class::Unicode(cls)); + self.push(HirFrame::Expr(expr)); + } else { + let mut cls = self.pop().unwrap().unwrap_class_bytes(); + self.bytes_fold_and_negate( + &ast.span, + ast.negated, + &mut cls, + )?; + if cls.iter().next().is_none() { + return Err(self.error( + ast.span, + ErrorKind::EmptyClassNotAllowed, + )); + } + + let expr = Hir::class(hir::Class::Bytes(cls)); + self.push(HirFrame::Expr(expr)); + } + } + Ast::Repetition(ref x) => { + let expr = self.pop().unwrap().unwrap_expr(); + self.push(HirFrame::Expr(self.hir_repetition(x, expr))); + } + Ast::Group(ref x) => { + let expr = self.pop().unwrap().unwrap_expr(); + if let Some(flags) = self.pop().unwrap().unwrap_group() { + self.trans().flags.set(flags); + } + self.push(HirFrame::Expr(self.hir_group(x, expr))); + } + Ast::Concat(_) => { + let mut exprs = vec![]; + while let Some(HirFrame::Expr(expr)) = self.pop() { + if !expr.kind().is_empty() { + exprs.push(expr); + } + } + exprs.reverse(); + self.push(HirFrame::Expr(Hir::concat(exprs))); + } + Ast::Alternation(_) => { + let mut exprs = vec![]; + while let Some(HirFrame::Expr(expr)) = self.pop() { + exprs.push(expr); + } + exprs.reverse(); + self.push(HirFrame::Expr(Hir::alternation(exprs))); + } + } + Ok(()) + } + + fn visit_class_set_item_pre( + &mut self, + ast: &ast::ClassSetItem, + ) -> Result<()> { + match *ast { + ast::ClassSetItem::Bracketed(_) => { + if self.flags().unicode() { + let cls = hir::ClassUnicode::empty(); + self.push(HirFrame::ClassUnicode(cls)); + } else { + let cls = hir::ClassBytes::empty(); + self.push(HirFrame::ClassBytes(cls)); + } + } + // We needn't handle the Union case here since the visitor will + // do it for us. + _ => {} + } + Ok(()) + } + + fn visit_class_set_item_post( + &mut self, + ast: &ast::ClassSetItem, + ) -> Result<()> { + match *ast { + ast::ClassSetItem::Empty(_) => {} + ast::ClassSetItem::Literal(ref x) => { + if self.flags().unicode() { + let mut cls = self.pop().unwrap().unwrap_class_unicode(); + cls.push(hir::ClassUnicodeRange::new(x.c, x.c)); + self.push(HirFrame::ClassUnicode(cls)); + } else { + let mut cls = self.pop().unwrap().unwrap_class_bytes(); + let byte = self.class_literal_byte(x)?; + cls.push(hir::ClassBytesRange::new(byte, byte)); + self.push(HirFrame::ClassBytes(cls)); + } + } + ast::ClassSetItem::Range(ref x) => { + if self.flags().unicode() { + let mut cls = self.pop().unwrap().unwrap_class_unicode(); + cls.push(hir::ClassUnicodeRange::new(x.start.c, x.end.c)); + self.push(HirFrame::ClassUnicode(cls)); + } else { + let mut cls = self.pop().unwrap().unwrap_class_bytes(); + let start = self.class_literal_byte(&x.start)?; + let end = self.class_literal_byte(&x.end)?; + cls.push(hir::ClassBytesRange::new(start, end)); + self.push(HirFrame::ClassBytes(cls)); + } + } + ast::ClassSetItem::Ascii(ref x) => { + if self.flags().unicode() { + let mut cls = self.pop().unwrap().unwrap_class_unicode(); + for &(s, e) in ascii_class(&x.kind) { + cls.push(hir::ClassUnicodeRange::new(s, e)); + } + self.unicode_fold_and_negate( + &x.span, x.negated, &mut cls, + )?; + self.push(HirFrame::ClassUnicode(cls)); + } else { + let mut cls = self.pop().unwrap().unwrap_class_bytes(); + for &(s, e) in ascii_class(&x.kind) { + cls.push(hir::ClassBytesRange::new(s as u8, e as u8)); + } + self.bytes_fold_and_negate(&x.span, x.negated, &mut cls)?; + self.push(HirFrame::ClassBytes(cls)); + } + } + ast::ClassSetItem::Unicode(ref x) => { + let xcls = self.hir_unicode_class(x)?; + let mut cls = self.pop().unwrap().unwrap_class_unicode(); + cls.union(&xcls); + self.push(HirFrame::ClassUnicode(cls)); + } + ast::ClassSetItem::Perl(ref x) => { + if self.flags().unicode() { + let xcls = self.hir_perl_unicode_class(x)?; + let mut cls = self.pop().unwrap().unwrap_class_unicode(); + cls.union(&xcls); + self.push(HirFrame::ClassUnicode(cls)); + } else { + let xcls = self.hir_perl_byte_class(x); + let mut cls = self.pop().unwrap().unwrap_class_bytes(); + cls.union(&xcls); + self.push(HirFrame::ClassBytes(cls)); + } + } + ast::ClassSetItem::Bracketed(ref ast) => { + if self.flags().unicode() { + let mut cls1 = self.pop().unwrap().unwrap_class_unicode(); + self.unicode_fold_and_negate( + &ast.span, + ast.negated, + &mut cls1, + )?; + + let mut cls2 = self.pop().unwrap().unwrap_class_unicode(); + cls2.union(&cls1); + self.push(HirFrame::ClassUnicode(cls2)); + } else { + let mut cls1 = self.pop().unwrap().unwrap_class_bytes(); + self.bytes_fold_and_negate( + &ast.span, + ast.negated, + &mut cls1, + )?; + + let mut cls2 = self.pop().unwrap().unwrap_class_bytes(); + cls2.union(&cls1); + self.push(HirFrame::ClassBytes(cls2)); + } + } + // This is handled automatically by the visitor. + ast::ClassSetItem::Union(_) => {} + } + Ok(()) + } + + fn visit_class_set_binary_op_pre( + &mut self, + _op: &ast::ClassSetBinaryOp, + ) -> Result<()> { + if self.flags().unicode() { + let cls = hir::ClassUnicode::empty(); + self.push(HirFrame::ClassUnicode(cls)); + } else { + let cls = hir::ClassBytes::empty(); + self.push(HirFrame::ClassBytes(cls)); + } + Ok(()) + } + + fn visit_class_set_binary_op_in( + &mut self, + _op: &ast::ClassSetBinaryOp, + ) -> Result<()> { + if self.flags().unicode() { + let cls = hir::ClassUnicode::empty(); + self.push(HirFrame::ClassUnicode(cls)); + } else { + let cls = hir::ClassBytes::empty(); + self.push(HirFrame::ClassBytes(cls)); + } + Ok(()) + } + + fn visit_class_set_binary_op_post( + &mut self, + op: &ast::ClassSetBinaryOp, + ) -> Result<()> { + use ast::ClassSetBinaryOpKind::*; + + if self.flags().unicode() { + let mut rhs = self.pop().unwrap().unwrap_class_unicode(); + let mut lhs = self.pop().unwrap().unwrap_class_unicode(); + let mut cls = self.pop().unwrap().unwrap_class_unicode(); + if self.flags().case_insensitive() { + rhs.try_case_fold_simple().map_err(|_| { + self.error( + op.rhs.span().clone(), + ErrorKind::UnicodeCaseUnavailable, + ) + })?; + lhs.try_case_fold_simple().map_err(|_| { + self.error( + op.lhs.span().clone(), + ErrorKind::UnicodeCaseUnavailable, + ) + })?; + } + match op.kind { + Intersection => lhs.intersect(&rhs), + Difference => lhs.difference(&rhs), + SymmetricDifference => lhs.symmetric_difference(&rhs), + } + cls.union(&lhs); + self.push(HirFrame::ClassUnicode(cls)); + } else { + let mut rhs = self.pop().unwrap().unwrap_class_bytes(); + let mut lhs = self.pop().unwrap().unwrap_class_bytes(); + let mut cls = self.pop().unwrap().unwrap_class_bytes(); + if self.flags().case_insensitive() { + rhs.case_fold_simple(); + lhs.case_fold_simple(); + } + match op.kind { + Intersection => lhs.intersect(&rhs), + Difference => lhs.difference(&rhs), + SymmetricDifference => lhs.symmetric_difference(&rhs), + } + cls.union(&lhs); + self.push(HirFrame::ClassBytes(cls)); + } + Ok(()) + } +} + +/// The internal implementation of a translator. +/// +/// This type is responsible for carrying around the original pattern string, +/// which is not tied to the internal state of a translator. +/// +/// A TranslatorI exists for the time it takes to translate a single Ast. +#[derive(Clone, Debug)] +struct TranslatorI<'t, 'p> { + trans: &'t Translator, + pattern: &'p str, +} + +impl<'t, 'p> TranslatorI<'t, 'p> { + /// Build a new internal translator. + fn new(trans: &'t Translator, pattern: &'p str) -> TranslatorI<'t, 'p> { + TranslatorI { trans: trans, pattern: pattern } + } + + /// Return a reference to the underlying translator. + fn trans(&self) -> &Translator { + &self.trans + } + + /// Push the given frame on to the call stack. + fn push(&self, frame: HirFrame) { + self.trans().stack.borrow_mut().push(frame); + } + + /// Pop the top of the call stack. If the call stack is empty, return None. + fn pop(&self) -> Option<HirFrame> { + self.trans().stack.borrow_mut().pop() + } + + /// Create a new error with the given span and error type. + fn error(&self, span: Span, kind: ErrorKind) -> Error { + Error { kind: kind, pattern: self.pattern.to_string(), span: span } + } + + /// Return a copy of the active flags. + fn flags(&self) -> Flags { + self.trans().flags.get() + } + + /// Set the flags of this translator from the flags set in the given AST. + /// Then, return the old flags. + fn set_flags(&self, ast_flags: &ast::Flags) -> Flags { + let old_flags = self.flags(); + let mut new_flags = Flags::from_ast(ast_flags); + new_flags.merge(&old_flags); + self.trans().flags.set(new_flags); + old_flags + } + + fn hir_literal(&self, lit: &ast::Literal) -> Result<Hir> { + let ch = match self.literal_to_char(lit)? { + byte @ hir::Literal::Byte(_) => return Ok(Hir::literal(byte)), + hir::Literal::Unicode(ch) => ch, + }; + if self.flags().case_insensitive() { + self.hir_from_char_case_insensitive(lit.span, ch) + } else { + self.hir_from_char(lit.span, ch) + } + } + + /// Convert an Ast literal to its scalar representation. + /// + /// When Unicode mode is enabled, then this always succeeds and returns a + /// `char` (Unicode scalar value). + /// + /// When Unicode mode is disabled, then a raw byte is returned. If that + /// byte is not ASCII and invalid UTF-8 is not allowed, then this returns + /// an error. + fn literal_to_char(&self, lit: &ast::Literal) -> Result<hir::Literal> { + if self.flags().unicode() { + return Ok(hir::Literal::Unicode(lit.c)); + } + let byte = match lit.byte() { + None => return Ok(hir::Literal::Unicode(lit.c)), + Some(byte) => byte, + }; + if byte <= 0x7F { + return Ok(hir::Literal::Unicode(byte as char)); + } + if !self.trans().allow_invalid_utf8 { + return Err(self.error(lit.span, ErrorKind::InvalidUtf8)); + } + Ok(hir::Literal::Byte(byte)) + } + + fn hir_from_char(&self, span: Span, c: char) -> Result<Hir> { + if !self.flags().unicode() && c.len_utf8() > 1 { + return Err(self.error(span, ErrorKind::UnicodeNotAllowed)); + } + Ok(Hir::literal(hir::Literal::Unicode(c))) + } + + fn hir_from_char_case_insensitive( + &self, + span: Span, + c: char, + ) -> Result<Hir> { + if self.flags().unicode() { + // If case folding won't do anything, then don't bother trying. + let map = + unicode::contains_simple_case_mapping(c, c).map_err(|_| { + self.error(span, ErrorKind::UnicodeCaseUnavailable) + })?; + if !map { + return self.hir_from_char(span, c); + } + let mut cls = + hir::ClassUnicode::new(vec![hir::ClassUnicodeRange::new( + c, c, + )]); + cls.try_case_fold_simple().map_err(|_| { + self.error(span, ErrorKind::UnicodeCaseUnavailable) + })?; + Ok(Hir::class(hir::Class::Unicode(cls))) + } else { + if c.len_utf8() > 1 { + return Err(self.error(span, ErrorKind::UnicodeNotAllowed)); + } + // If case folding won't do anything, then don't bother trying. + match c { + 'A'..='Z' | 'a'..='z' => {} + _ => return self.hir_from_char(span, c), + } + let mut cls = + hir::ClassBytes::new(vec![hir::ClassBytesRange::new( + c as u8, c as u8, + )]); + cls.case_fold_simple(); + Ok(Hir::class(hir::Class::Bytes(cls))) + } + } + + fn hir_dot(&self, span: Span) -> Result<Hir> { + let unicode = self.flags().unicode(); + if !unicode && !self.trans().allow_invalid_utf8 { + return Err(self.error(span, ErrorKind::InvalidUtf8)); + } + Ok(if self.flags().dot_matches_new_line() { + Hir::any(!unicode) + } else { + Hir::dot(!unicode) + }) + } + + fn hir_assertion(&self, asst: &ast::Assertion) -> Result<Hir> { + let unicode = self.flags().unicode(); + let multi_line = self.flags().multi_line(); + Ok(match asst.kind { + ast::AssertionKind::StartLine => Hir::anchor(if multi_line { + hir::Anchor::StartLine + } else { + hir::Anchor::StartText + }), + ast::AssertionKind::EndLine => Hir::anchor(if multi_line { + hir::Anchor::EndLine + } else { + hir::Anchor::EndText + }), + ast::AssertionKind::StartText => { + Hir::anchor(hir::Anchor::StartText) + } + ast::AssertionKind::EndText => Hir::anchor(hir::Anchor::EndText), + ast::AssertionKind::WordBoundary => { + Hir::word_boundary(if unicode { + hir::WordBoundary::Unicode + } else { + hir::WordBoundary::Ascii + }) + } + ast::AssertionKind::NotWordBoundary => { + Hir::word_boundary(if unicode { + hir::WordBoundary::UnicodeNegate + } else { + // It is possible for negated ASCII word boundaries to + // match at invalid UTF-8 boundaries, even when searching + // valid UTF-8. + if !self.trans().allow_invalid_utf8 { + return Err( + self.error(asst.span, ErrorKind::InvalidUtf8) + ); + } + hir::WordBoundary::AsciiNegate + }) + } + }) + } + + fn hir_group(&self, group: &ast::Group, expr: Hir) -> Hir { + let kind = match group.kind { + ast::GroupKind::CaptureIndex(idx) => { + hir::GroupKind::CaptureIndex(idx) + } + ast::GroupKind::CaptureName(ref capname) => { + hir::GroupKind::CaptureName { + name: capname.name.clone(), + index: capname.index, + } + } + ast::GroupKind::NonCapturing(_) => hir::GroupKind::NonCapturing, + }; + Hir::group(hir::Group { kind: kind, hir: Box::new(expr) }) + } + + fn hir_repetition(&self, rep: &ast::Repetition, expr: Hir) -> Hir { + let kind = match rep.op.kind { + ast::RepetitionKind::ZeroOrOne => hir::RepetitionKind::ZeroOrOne, + ast::RepetitionKind::ZeroOrMore => hir::RepetitionKind::ZeroOrMore, + ast::RepetitionKind::OneOrMore => hir::RepetitionKind::OneOrMore, + ast::RepetitionKind::Range(ast::RepetitionRange::Exactly(m)) => { + hir::RepetitionKind::Range(hir::RepetitionRange::Exactly(m)) + } + ast::RepetitionKind::Range(ast::RepetitionRange::AtLeast(m)) => { + hir::RepetitionKind::Range(hir::RepetitionRange::AtLeast(m)) + } + ast::RepetitionKind::Range(ast::RepetitionRange::Bounded( + m, + n, + )) => { + hir::RepetitionKind::Range(hir::RepetitionRange::Bounded(m, n)) + } + }; + let greedy = + if self.flags().swap_greed() { !rep.greedy } else { rep.greedy }; + Hir::repetition(hir::Repetition { + kind: kind, + greedy: greedy, + hir: Box::new(expr), + }) + } + + fn hir_unicode_class( + &self, + ast_class: &ast::ClassUnicode, + ) -> Result<hir::ClassUnicode> { + use ast::ClassUnicodeKind::*; + + if !self.flags().unicode() { + return Err( + self.error(ast_class.span, ErrorKind::UnicodeNotAllowed) + ); + } + let query = match ast_class.kind { + OneLetter(name) => ClassQuery::OneLetter(name), + Named(ref name) => ClassQuery::Binary(name), + NamedValue { ref name, ref value, .. } => ClassQuery::ByValue { + property_name: name, + property_value: value, + }, + }; + let mut result = self.convert_unicode_class_error( + &ast_class.span, + unicode::class(query), + ); + if let Ok(ref mut class) = result { + self.unicode_fold_and_negate( + &ast_class.span, + ast_class.negated, + class, + )?; + } + result + } + + fn hir_perl_unicode_class( + &self, + ast_class: &ast::ClassPerl, + ) -> Result<hir::ClassUnicode> { + use ast::ClassPerlKind::*; + + assert!(self.flags().unicode()); + let result = match ast_class.kind { + Digit => unicode::perl_digit(), + Space => unicode::perl_space(), + Word => unicode::perl_word(), + }; + let mut class = + self.convert_unicode_class_error(&ast_class.span, result)?; + // We needn't apply case folding here because the Perl Unicode classes + // are already closed under Unicode simple case folding. + if ast_class.negated { + class.negate(); + } + Ok(class) + } + + fn hir_perl_byte_class( + &self, + ast_class: &ast::ClassPerl, + ) -> hir::ClassBytes { + use ast::ClassPerlKind::*; + + assert!(!self.flags().unicode()); + let mut class = match ast_class.kind { + Digit => hir_ascii_class_bytes(&ast::ClassAsciiKind::Digit), + Space => hir_ascii_class_bytes(&ast::ClassAsciiKind::Space), + Word => hir_ascii_class_bytes(&ast::ClassAsciiKind::Word), + }; + // We needn't apply case folding here because the Perl ASCII classes + // are already closed (under ASCII case folding). + if ast_class.negated { + class.negate(); + } + class + } + + /// Converts the given Unicode specific error to an HIR translation error. + /// + /// The span given should approximate the position at which an error would + /// occur. + fn convert_unicode_class_error( + &self, + span: &Span, + result: unicode::Result<hir::ClassUnicode>, + ) -> Result<hir::ClassUnicode> { + result.map_err(|err| { + let sp = span.clone(); + match err { + unicode::Error::PropertyNotFound => { + self.error(sp, ErrorKind::UnicodePropertyNotFound) + } + unicode::Error::PropertyValueNotFound => { + self.error(sp, ErrorKind::UnicodePropertyValueNotFound) + } + unicode::Error::PerlClassNotFound => { + self.error(sp, ErrorKind::UnicodePerlClassNotFound) + } + } + }) + } + + fn unicode_fold_and_negate( + &self, + span: &Span, + negated: bool, + class: &mut hir::ClassUnicode, + ) -> Result<()> { + // Note that we must apply case folding before negation! + // Consider `(?i)[^x]`. If we applied negation field, then + // the result would be the character class that matched any + // Unicode scalar value. + if self.flags().case_insensitive() { + class.try_case_fold_simple().map_err(|_| { + self.error(span.clone(), ErrorKind::UnicodeCaseUnavailable) + })?; + } + if negated { + class.negate(); + } + Ok(()) + } + + fn bytes_fold_and_negate( + &self, + span: &Span, + negated: bool, + class: &mut hir::ClassBytes, + ) -> Result<()> { + // Note that we must apply case folding before negation! + // Consider `(?i)[^x]`. If we applied negation field, then + // the result would be the character class that matched any + // Unicode scalar value. + if self.flags().case_insensitive() { + class.case_fold_simple(); + } + if negated { + class.negate(); + } + if !self.trans().allow_invalid_utf8 && !class.is_all_ascii() { + return Err(self.error(span.clone(), ErrorKind::InvalidUtf8)); + } + Ok(()) + } + + /// Return a scalar byte value suitable for use as a literal in a byte + /// character class. + fn class_literal_byte(&self, ast: &ast::Literal) -> Result<u8> { + match self.literal_to_char(ast)? { + hir::Literal::Byte(byte) => Ok(byte), + hir::Literal::Unicode(ch) => { + if ch <= 0x7F as char { + Ok(ch as u8) + } else { + // We can't feasibly support Unicode in + // byte oriented classes. Byte classes don't + // do Unicode case folding. + Err(self.error(ast.span, ErrorKind::UnicodeNotAllowed)) + } + } + } + } +} + +/// A translator's representation of a regular expression's flags at any given +/// moment in time. +/// +/// Each flag can be in one of three states: absent, present but disabled or +/// present but enabled. +#[derive(Clone, Copy, Debug, Default)] +struct Flags { + case_insensitive: Option<bool>, + multi_line: Option<bool>, + dot_matches_new_line: Option<bool>, + swap_greed: Option<bool>, + unicode: Option<bool>, + // Note that `ignore_whitespace` is omitted here because it is handled + // entirely in the parser. +} + +impl Flags { + fn from_ast(ast: &ast::Flags) -> Flags { + let mut flags = Flags::default(); + let mut enable = true; + for item in &ast.items { + match item.kind { + ast::FlagsItemKind::Negation => { + enable = false; + } + ast::FlagsItemKind::Flag(ast::Flag::CaseInsensitive) => { + flags.case_insensitive = Some(enable); + } + ast::FlagsItemKind::Flag(ast::Flag::MultiLine) => { + flags.multi_line = Some(enable); + } + ast::FlagsItemKind::Flag(ast::Flag::DotMatchesNewLine) => { + flags.dot_matches_new_line = Some(enable); + } + ast::FlagsItemKind::Flag(ast::Flag::SwapGreed) => { + flags.swap_greed = Some(enable); + } + ast::FlagsItemKind::Flag(ast::Flag::Unicode) => { + flags.unicode = Some(enable); + } + ast::FlagsItemKind::Flag(ast::Flag::IgnoreWhitespace) => {} + } + } + flags + } + + fn merge(&mut self, previous: &Flags) { + if self.case_insensitive.is_none() { + self.case_insensitive = previous.case_insensitive; + } + if self.multi_line.is_none() { + self.multi_line = previous.multi_line; + } + if self.dot_matches_new_line.is_none() { + self.dot_matches_new_line = previous.dot_matches_new_line; + } + if self.swap_greed.is_none() { + self.swap_greed = previous.swap_greed; + } + if self.unicode.is_none() { + self.unicode = previous.unicode; + } + } + + fn case_insensitive(&self) -> bool { + self.case_insensitive.unwrap_or(false) + } + + fn multi_line(&self) -> bool { + self.multi_line.unwrap_or(false) + } + + fn dot_matches_new_line(&self) -> bool { + self.dot_matches_new_line.unwrap_or(false) + } + + fn swap_greed(&self) -> bool { + self.swap_greed.unwrap_or(false) + } + + fn unicode(&self) -> bool { + self.unicode.unwrap_or(true) + } +} + +fn hir_ascii_class_bytes(kind: &ast::ClassAsciiKind) -> hir::ClassBytes { + let ranges: Vec<_> = ascii_class(kind) + .iter() + .cloned() + .map(|(s, e)| hir::ClassBytesRange::new(s as u8, e as u8)) + .collect(); + hir::ClassBytes::new(ranges) +} + +fn ascii_class(kind: &ast::ClassAsciiKind) -> &'static [(char, char)] { + use ast::ClassAsciiKind::*; + match *kind { + Alnum => &[('0', '9'), ('A', 'Z'), ('a', 'z')], + Alpha => &[('A', 'Z'), ('a', 'z')], + Ascii => &[('\x00', '\x7F')], + Blank => &[('\t', '\t'), (' ', ' ')], + Cntrl => &[('\x00', '\x1F'), ('\x7F', '\x7F')], + Digit => &[('0', '9')], + Graph => &[('!', '~')], + Lower => &[('a', 'z')], + Print => &[(' ', '~')], + Punct => &[('!', '/'), (':', '@'), ('[', '`'), ('{', '~')], + Space => &[ + ('\t', '\t'), + ('\n', '\n'), + ('\x0B', '\x0B'), + ('\x0C', '\x0C'), + ('\r', '\r'), + (' ', ' '), + ], + Upper => &[('A', 'Z')], + Word => &[('0', '9'), ('A', 'Z'), ('_', '_'), ('a', 'z')], + Xdigit => &[('0', '9'), ('A', 'F'), ('a', 'f')], + } +} + +#[cfg(test)] +mod tests { + use ast::parse::ParserBuilder; + use ast::{self, Ast, Position, Span}; + use hir::{self, Hir, HirKind}; + use unicode::{self, ClassQuery}; + + use super::{ascii_class, TranslatorBuilder}; + + // We create these errors to compare with real hir::Errors in the tests. + // We define equality between TestError and hir::Error to disregard the + // pattern string in hir::Error, which is annoying to provide in tests. + #[derive(Clone, Debug)] + struct TestError { + span: Span, + kind: hir::ErrorKind, + } + + impl PartialEq<hir::Error> for TestError { + fn eq(&self, other: &hir::Error) -> bool { + self.span == other.span && self.kind == other.kind + } + } + + impl PartialEq<TestError> for hir::Error { + fn eq(&self, other: &TestError) -> bool { + self.span == other.span && self.kind == other.kind + } + } + + fn parse(pattern: &str) -> Ast { + ParserBuilder::new().octal(true).build().parse(pattern).unwrap() + } + + fn t(pattern: &str) -> Hir { + TranslatorBuilder::new() + .allow_invalid_utf8(false) + .build() + .translate(pattern, &parse(pattern)) + .unwrap() + } + + fn t_err(pattern: &str) -> hir::Error { + TranslatorBuilder::new() + .allow_invalid_utf8(false) + .build() + .translate(pattern, &parse(pattern)) + .unwrap_err() + } + + fn t_bytes(pattern: &str) -> Hir { + TranslatorBuilder::new() + .allow_invalid_utf8(true) + .build() + .translate(pattern, &parse(pattern)) + .unwrap() + } + + fn hir_lit(s: &str) -> Hir { + match s.len() { + 0 => Hir::empty(), + _ => { + let lits = s + .chars() + .map(hir::Literal::Unicode) + .map(Hir::literal) + .collect(); + Hir::concat(lits) + } + } + } + + fn hir_blit(s: &[u8]) -> Hir { + match s.len() { + 0 => Hir::empty(), + 1 => Hir::literal(hir::Literal::Byte(s[0])), + _ => { + let lits = s + .iter() + .cloned() + .map(hir::Literal::Byte) + .map(Hir::literal) + .collect(); + Hir::concat(lits) + } + } + } + + fn hir_group(i: u32, expr: Hir) -> Hir { + Hir::group(hir::Group { + kind: hir::GroupKind::CaptureIndex(i), + hir: Box::new(expr), + }) + } + + fn hir_group_name(i: u32, name: &str, expr: Hir) -> Hir { + Hir::group(hir::Group { + kind: hir::GroupKind::CaptureName { + name: name.to_string(), + index: i, + }, + hir: Box::new(expr), + }) + } + + fn hir_group_nocap(expr: Hir) -> Hir { + Hir::group(hir::Group { + kind: hir::GroupKind::NonCapturing, + hir: Box::new(expr), + }) + } + + fn hir_quest(greedy: bool, expr: Hir) -> Hir { + Hir::repetition(hir::Repetition { + kind: hir::RepetitionKind::ZeroOrOne, + greedy: greedy, + hir: Box::new(expr), + }) + } + + fn hir_star(greedy: bool, expr: Hir) -> Hir { + Hir::repetition(hir::Repetition { + kind: hir::RepetitionKind::ZeroOrMore, + greedy: greedy, + hir: Box::new(expr), + }) + } + + fn hir_plus(greedy: bool, expr: Hir) -> Hir { + Hir::repetition(hir::Repetition { + kind: hir::RepetitionKind::OneOrMore, + greedy: greedy, + hir: Box::new(expr), + }) + } + + fn hir_range(greedy: bool, range: hir::RepetitionRange, expr: Hir) -> Hir { + Hir::repetition(hir::Repetition { + kind: hir::RepetitionKind::Range(range), + greedy: greedy, + hir: Box::new(expr), + }) + } + + fn hir_alt(alts: Vec<Hir>) -> Hir { + Hir::alternation(alts) + } + + fn hir_cat(exprs: Vec<Hir>) -> Hir { + Hir::concat(exprs) + } + + #[allow(dead_code)] + fn hir_uclass_query(query: ClassQuery) -> Hir { + Hir::class(hir::Class::Unicode(unicode::class(query).unwrap())) + } + + #[allow(dead_code)] + fn hir_uclass_perl_word() -> Hir { + Hir::class(hir::Class::Unicode(unicode::perl_word().unwrap())) + } + + fn hir_uclass(ranges: &[(char, char)]) -> Hir { + let ranges: Vec<hir::ClassUnicodeRange> = ranges + .iter() + .map(|&(s, e)| hir::ClassUnicodeRange::new(s, e)) + .collect(); + Hir::class(hir::Class::Unicode(hir::ClassUnicode::new(ranges))) + } + + fn hir_bclass(ranges: &[(u8, u8)]) -> Hir { + let ranges: Vec<hir::ClassBytesRange> = ranges + .iter() + .map(|&(s, e)| hir::ClassBytesRange::new(s, e)) + .collect(); + Hir::class(hir::Class::Bytes(hir::ClassBytes::new(ranges))) + } + + fn hir_bclass_from_char(ranges: &[(char, char)]) -> Hir { + let ranges: Vec<hir::ClassBytesRange> = ranges + .iter() + .map(|&(s, e)| { + assert!(s as u32 <= 0x7F); + assert!(e as u32 <= 0x7F); + hir::ClassBytesRange::new(s as u8, e as u8) + }) + .collect(); + Hir::class(hir::Class::Bytes(hir::ClassBytes::new(ranges))) + } + + fn hir_case_fold(expr: Hir) -> Hir { + match expr.into_kind() { + HirKind::Class(mut cls) => { + cls.case_fold_simple(); + Hir::class(cls) + } + _ => panic!("cannot case fold non-class Hir expr"), + } + } + + fn hir_negate(expr: Hir) -> Hir { + match expr.into_kind() { + HirKind::Class(mut cls) => { + cls.negate(); + Hir::class(cls) + } + _ => panic!("cannot negate non-class Hir expr"), + } + } + + #[allow(dead_code)] + fn hir_union(expr1: Hir, expr2: Hir) -> Hir { + use hir::Class::{Bytes, Unicode}; + + match (expr1.into_kind(), expr2.into_kind()) { + (HirKind::Class(Unicode(mut c1)), HirKind::Class(Unicode(c2))) => { + c1.union(&c2); + Hir::class(hir::Class::Unicode(c1)) + } + (HirKind::Class(Bytes(mut c1)), HirKind::Class(Bytes(c2))) => { + c1.union(&c2); + Hir::class(hir::Class::Bytes(c1)) + } + _ => panic!("cannot union non-class Hir exprs"), + } + } + + #[allow(dead_code)] + fn hir_difference(expr1: Hir, expr2: Hir) -> Hir { + use hir::Class::{Bytes, Unicode}; + + match (expr1.into_kind(), expr2.into_kind()) { + (HirKind::Class(Unicode(mut c1)), HirKind::Class(Unicode(c2))) => { + c1.difference(&c2); + Hir::class(hir::Class::Unicode(c1)) + } + (HirKind::Class(Bytes(mut c1)), HirKind::Class(Bytes(c2))) => { + c1.difference(&c2); + Hir::class(hir::Class::Bytes(c1)) + } + _ => panic!("cannot difference non-class Hir exprs"), + } + } + + fn hir_anchor(anchor: hir::Anchor) -> Hir { + Hir::anchor(anchor) + } + + fn hir_word(wb: hir::WordBoundary) -> Hir { + Hir::word_boundary(wb) + } + + #[test] + fn empty() { + assert_eq!(t(""), Hir::empty()); + assert_eq!(t("(?i)"), Hir::empty()); + assert_eq!(t("()"), hir_group(1, Hir::empty())); + assert_eq!(t("(?:)"), hir_group_nocap(Hir::empty())); + assert_eq!(t("(?P<wat>)"), hir_group_name(1, "wat", Hir::empty())); + assert_eq!(t("|"), hir_alt(vec![Hir::empty(), Hir::empty()])); + assert_eq!( + t("()|()"), + hir_alt(vec![ + hir_group(1, Hir::empty()), + hir_group(2, Hir::empty()), + ]) + ); + assert_eq!( + t("(|b)"), + hir_group(1, hir_alt(vec![Hir::empty(), hir_lit("b"),])) + ); + assert_eq!( + t("(a|)"), + hir_group(1, hir_alt(vec![hir_lit("a"), Hir::empty(),])) + ); + assert_eq!( + t("(a||c)"), + hir_group( + 1, + hir_alt(vec![hir_lit("a"), Hir::empty(), hir_lit("c"),]) + ) + ); + assert_eq!( + t("(||)"), + hir_group( + 1, + hir_alt(vec![Hir::empty(), Hir::empty(), Hir::empty(),]) + ) + ); + } + + #[test] + fn literal() { + assert_eq!(t("a"), hir_lit("a")); + assert_eq!(t("(?-u)a"), hir_lit("a")); + assert_eq!(t("☃"), hir_lit("☃")); + assert_eq!(t("abcd"), hir_lit("abcd")); + + assert_eq!(t_bytes("(?-u)a"), hir_lit("a")); + assert_eq!(t_bytes("(?-u)\x61"), hir_lit("a")); + assert_eq!(t_bytes(r"(?-u)\x61"), hir_lit("a")); + assert_eq!(t_bytes(r"(?-u)\xFF"), hir_blit(b"\xFF")); + + assert_eq!( + t_err("(?-u)☃"), + TestError { + kind: hir::ErrorKind::UnicodeNotAllowed, + span: Span::new( + Position::new(5, 1, 6), + Position::new(8, 1, 7) + ), + } + ); + assert_eq!( + t_err(r"(?-u)\xFF"), + TestError { + kind: hir::ErrorKind::InvalidUtf8, + span: Span::new( + Position::new(5, 1, 6), + Position::new(9, 1, 10) + ), + } + ); + } + + #[test] + fn literal_case_insensitive() { + #[cfg(feature = "unicode-case")] + assert_eq!(t("(?i)a"), hir_uclass(&[('A', 'A'), ('a', 'a'),])); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i:a)"), + hir_group_nocap(hir_uclass(&[('A', 'A'), ('a', 'a')],)) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("a(?i)a(?-i)a"), + hir_cat(vec![ + hir_lit("a"), + hir_uclass(&[('A', 'A'), ('a', 'a')]), + hir_lit("a"), + ]) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)ab@c"), + hir_cat(vec![ + hir_uclass(&[('A', 'A'), ('a', 'a')]), + hir_uclass(&[('B', 'B'), ('b', 'b')]), + hir_lit("@"), + hir_uclass(&[('C', 'C'), ('c', 'c')]), + ]) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)β"), + hir_uclass(&[('Β', 'Β'), ('β', 'β'), ('ϐ', 'ϐ'),]) + ); + + assert_eq!(t("(?i-u)a"), hir_bclass(&[(b'A', b'A'), (b'a', b'a'),])); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?-u)a(?i)a(?-i)a"), + hir_cat(vec![ + hir_lit("a"), + hir_bclass(&[(b'A', b'A'), (b'a', b'a')]), + hir_lit("a"), + ]) + ); + assert_eq!( + t("(?i-u)ab@c"), + hir_cat(vec![ + hir_bclass(&[(b'A', b'A'), (b'a', b'a')]), + hir_bclass(&[(b'B', b'B'), (b'b', b'b')]), + hir_lit("@"), + hir_bclass(&[(b'C', b'C'), (b'c', b'c')]), + ]) + ); + + assert_eq!( + t_bytes("(?i-u)a"), + hir_bclass(&[(b'A', b'A'), (b'a', b'a'),]) + ); + assert_eq!( + t_bytes("(?i-u)\x61"), + hir_bclass(&[(b'A', b'A'), (b'a', b'a'),]) + ); + assert_eq!( + t_bytes(r"(?i-u)\x61"), + hir_bclass(&[(b'A', b'A'), (b'a', b'a'),]) + ); + assert_eq!(t_bytes(r"(?i-u)\xFF"), hir_blit(b"\xFF")); + + assert_eq!( + t_err("(?i-u)β"), + TestError { + kind: hir::ErrorKind::UnicodeNotAllowed, + span: Span::new( + Position::new(6, 1, 7), + Position::new(8, 1, 8), + ), + } + ); + } + + #[test] + fn dot() { + assert_eq!( + t("."), + hir_uclass(&[('\0', '\t'), ('\x0B', '\u{10FFFF}'),]) + ); + assert_eq!(t("(?s)."), hir_uclass(&[('\0', '\u{10FFFF}'),])); + assert_eq!( + t_bytes("(?-u)."), + hir_bclass(&[(b'\0', b'\t'), (b'\x0B', b'\xFF'),]) + ); + assert_eq!(t_bytes("(?s-u)."), hir_bclass(&[(b'\0', b'\xFF'),])); + + // If invalid UTF-8 isn't allowed, then non-Unicode `.` isn't allowed. + assert_eq!( + t_err("(?-u)."), + TestError { + kind: hir::ErrorKind::InvalidUtf8, + span: Span::new( + Position::new(5, 1, 6), + Position::new(6, 1, 7) + ), + } + ); + assert_eq!( + t_err("(?s-u)."), + TestError { + kind: hir::ErrorKind::InvalidUtf8, + span: Span::new( + Position::new(6, 1, 7), + Position::new(7, 1, 8) + ), + } + ); + } + + #[test] + fn assertions() { + assert_eq!(t("^"), hir_anchor(hir::Anchor::StartText)); + assert_eq!(t("$"), hir_anchor(hir::Anchor::EndText)); + assert_eq!(t(r"\A"), hir_anchor(hir::Anchor::StartText)); + assert_eq!(t(r"\z"), hir_anchor(hir::Anchor::EndText)); + assert_eq!(t("(?m)^"), hir_anchor(hir::Anchor::StartLine)); + assert_eq!(t("(?m)$"), hir_anchor(hir::Anchor::EndLine)); + assert_eq!(t(r"(?m)\A"), hir_anchor(hir::Anchor::StartText)); + assert_eq!(t(r"(?m)\z"), hir_anchor(hir::Anchor::EndText)); + + assert_eq!(t(r"\b"), hir_word(hir::WordBoundary::Unicode)); + assert_eq!(t(r"\B"), hir_word(hir::WordBoundary::UnicodeNegate)); + assert_eq!(t(r"(?-u)\b"), hir_word(hir::WordBoundary::Ascii)); + assert_eq!( + t_bytes(r"(?-u)\B"), + hir_word(hir::WordBoundary::AsciiNegate) + ); + + assert_eq!( + t_err(r"(?-u)\B"), + TestError { + kind: hir::ErrorKind::InvalidUtf8, + span: Span::new( + Position::new(5, 1, 6), + Position::new(7, 1, 8) + ), + } + ); + } + + #[test] + fn group() { + assert_eq!(t("(a)"), hir_group(1, hir_lit("a"))); + assert_eq!( + t("(a)(b)"), + hir_cat(vec![ + hir_group(1, hir_lit("a")), + hir_group(2, hir_lit("b")), + ]) + ); + assert_eq!( + t("(a)|(b)"), + hir_alt(vec![ + hir_group(1, hir_lit("a")), + hir_group(2, hir_lit("b")), + ]) + ); + assert_eq!(t("(?P<foo>)"), hir_group_name(1, "foo", Hir::empty())); + assert_eq!(t("(?P<foo>a)"), hir_group_name(1, "foo", hir_lit("a"))); + assert_eq!( + t("(?P<foo>a)(?P<bar>b)"), + hir_cat(vec![ + hir_group_name(1, "foo", hir_lit("a")), + hir_group_name(2, "bar", hir_lit("b")), + ]) + ); + assert_eq!(t("(?:)"), hir_group_nocap(Hir::empty())); + assert_eq!(t("(?:a)"), hir_group_nocap(hir_lit("a"))); + assert_eq!( + t("(?:a)(b)"), + hir_cat(vec![ + hir_group_nocap(hir_lit("a")), + hir_group(1, hir_lit("b")), + ]) + ); + assert_eq!( + t("(a)(?:b)(c)"), + hir_cat(vec![ + hir_group(1, hir_lit("a")), + hir_group_nocap(hir_lit("b")), + hir_group(2, hir_lit("c")), + ]) + ); + assert_eq!( + t("(a)(?P<foo>b)(c)"), + hir_cat(vec![ + hir_group(1, hir_lit("a")), + hir_group_name(2, "foo", hir_lit("b")), + hir_group(3, hir_lit("c")), + ]) + ); + assert_eq!(t("()"), hir_group(1, Hir::empty())); + assert_eq!(t("((?i))"), hir_group(1, Hir::empty())); + assert_eq!(t("((?x))"), hir_group(1, Hir::empty())); + assert_eq!(t("(((?x)))"), hir_group(1, hir_group(2, Hir::empty()))); + } + + #[test] + fn flags() { + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i:a)a"), + hir_cat(vec![ + hir_group_nocap(hir_uclass(&[('A', 'A'), ('a', 'a')])), + hir_lit("a"), + ]) + ); + assert_eq!( + t("(?i-u:a)β"), + hir_cat(vec![ + hir_group_nocap(hir_bclass(&[(b'A', b'A'), (b'a', b'a')])), + hir_lit("β"), + ]) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)(?-i:a)a"), + hir_cat(vec![ + hir_group_nocap(hir_lit("a")), + hir_uclass(&[('A', 'A'), ('a', 'a')]), + ]) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?im)a^"), + hir_cat(vec![ + hir_uclass(&[('A', 'A'), ('a', 'a')]), + hir_anchor(hir::Anchor::StartLine), + ]) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?im)a^(?i-m)a^"), + hir_cat(vec![ + hir_uclass(&[('A', 'A'), ('a', 'a')]), + hir_anchor(hir::Anchor::StartLine), + hir_uclass(&[('A', 'A'), ('a', 'a')]), + hir_anchor(hir::Anchor::StartText), + ]) + ); + assert_eq!( + t("(?U)a*a*?(?-U)a*a*?"), + hir_cat(vec![ + hir_star(false, hir_lit("a")), + hir_star(true, hir_lit("a")), + hir_star(true, hir_lit("a")), + hir_star(false, hir_lit("a")), + ]) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?:a(?i)a)a"), + hir_cat(vec![ + hir_group_nocap(hir_cat(vec![ + hir_lit("a"), + hir_uclass(&[('A', 'A'), ('a', 'a')]), + ])), + hir_lit("a"), + ]) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)(?:a(?-i)a)a"), + hir_cat(vec![ + hir_group_nocap(hir_cat(vec![ + hir_uclass(&[('A', 'A'), ('a', 'a')]), + hir_lit("a"), + ])), + hir_uclass(&[('A', 'A'), ('a', 'a')]), + ]) + ); + } + + #[test] + fn escape() { + assert_eq!( + t(r"\\\.\+\*\?\(\)\|\[\]\{\}\^\$\#"), + hir_lit(r"\.+*?()|[]{}^$#") + ); + } + + #[test] + fn repetition() { + assert_eq!(t("a?"), hir_quest(true, hir_lit("a"))); + assert_eq!(t("a*"), hir_star(true, hir_lit("a"))); + assert_eq!(t("a+"), hir_plus(true, hir_lit("a"))); + assert_eq!(t("a??"), hir_quest(false, hir_lit("a"))); + assert_eq!(t("a*?"), hir_star(false, hir_lit("a"))); + assert_eq!(t("a+?"), hir_plus(false, hir_lit("a"))); + + assert_eq!( + t("a{1}"), + hir_range(true, hir::RepetitionRange::Exactly(1), hir_lit("a"),) + ); + assert_eq!( + t("a{1,}"), + hir_range(true, hir::RepetitionRange::AtLeast(1), hir_lit("a"),) + ); + assert_eq!( + t("a{1,2}"), + hir_range(true, hir::RepetitionRange::Bounded(1, 2), hir_lit("a"),) + ); + assert_eq!( + t("a{1}?"), + hir_range(false, hir::RepetitionRange::Exactly(1), hir_lit("a"),) + ); + assert_eq!( + t("a{1,}?"), + hir_range(false, hir::RepetitionRange::AtLeast(1), hir_lit("a"),) + ); + assert_eq!( + t("a{1,2}?"), + hir_range( + false, + hir::RepetitionRange::Bounded(1, 2), + hir_lit("a"), + ) + ); + + assert_eq!( + t("ab?"), + hir_cat(vec![hir_lit("a"), hir_quest(true, hir_lit("b")),]) + ); + assert_eq!( + t("(ab)?"), + hir_quest( + true, + hir_group(1, hir_cat(vec![hir_lit("a"), hir_lit("b"),])) + ) + ); + assert_eq!( + t("a|b?"), + hir_alt(vec![hir_lit("a"), hir_quest(true, hir_lit("b")),]) + ); + } + + #[test] + fn cat_alt() { + assert_eq!( + t("(ab)"), + hir_group(1, hir_cat(vec![hir_lit("a"), hir_lit("b"),])) + ); + assert_eq!(t("a|b"), hir_alt(vec![hir_lit("a"), hir_lit("b"),])); + assert_eq!( + t("a|b|c"), + hir_alt(vec![hir_lit("a"), hir_lit("b"), hir_lit("c"),]) + ); + assert_eq!( + t("ab|bc|cd"), + hir_alt(vec![hir_lit("ab"), hir_lit("bc"), hir_lit("cd"),]) + ); + assert_eq!( + t("(a|b)"), + hir_group(1, hir_alt(vec![hir_lit("a"), hir_lit("b"),])) + ); + assert_eq!( + t("(a|b|c)"), + hir_group( + 1, + hir_alt(vec![hir_lit("a"), hir_lit("b"), hir_lit("c"),]) + ) + ); + assert_eq!( + t("(ab|bc|cd)"), + hir_group( + 1, + hir_alt(vec![hir_lit("ab"), hir_lit("bc"), hir_lit("cd"),]) + ) + ); + assert_eq!( + t("(ab|(bc|(cd)))"), + hir_group( + 1, + hir_alt(vec![ + hir_lit("ab"), + hir_group( + 2, + hir_alt(vec![ + hir_lit("bc"), + hir_group(3, hir_lit("cd")), + ]) + ), + ]) + ) + ); + } + + #[test] + fn class_ascii() { + assert_eq!( + t("[[:alnum:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Alnum)) + ); + assert_eq!( + t("[[:alpha:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Alpha)) + ); + assert_eq!( + t("[[:ascii:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Ascii)) + ); + assert_eq!( + t("[[:blank:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Blank)) + ); + assert_eq!( + t("[[:cntrl:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Cntrl)) + ); + assert_eq!( + t("[[:digit:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Digit)) + ); + assert_eq!( + t("[[:graph:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Graph)) + ); + assert_eq!( + t("[[:lower:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Lower)) + ); + assert_eq!( + t("[[:print:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Print)) + ); + assert_eq!( + t("[[:punct:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Punct)) + ); + assert_eq!( + t("[[:space:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Space)) + ); + assert_eq!( + t("[[:upper:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Upper)) + ); + assert_eq!( + t("[[:word:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Word)) + ); + assert_eq!( + t("[[:xdigit:]]"), + hir_uclass(ascii_class(&ast::ClassAsciiKind::Xdigit)) + ); + + assert_eq!( + t("[[:^lower:]]"), + hir_negate(hir_uclass(ascii_class(&ast::ClassAsciiKind::Lower))) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)[[:lower:]]"), + hir_uclass(&[ + ('A', 'Z'), + ('a', 'z'), + ('\u{17F}', '\u{17F}'), + ('\u{212A}', '\u{212A}'), + ]) + ); + + assert_eq!( + t("(?-u)[[:lower:]]"), + hir_bclass_from_char(ascii_class(&ast::ClassAsciiKind::Lower)) + ); + assert_eq!( + t("(?i-u)[[:lower:]]"), + hir_case_fold(hir_bclass_from_char(ascii_class( + &ast::ClassAsciiKind::Lower + ))) + ); + + assert_eq!( + t_err("(?-u)[[:^lower:]]"), + TestError { + kind: hir::ErrorKind::InvalidUtf8, + span: Span::new( + Position::new(6, 1, 7), + Position::new(16, 1, 17) + ), + } + ); + assert_eq!( + t_err("(?i-u)[[:^lower:]]"), + TestError { + kind: hir::ErrorKind::InvalidUtf8, + span: Span::new( + Position::new(7, 1, 8), + Position::new(17, 1, 18) + ), + } + ); + } + + #[test] + #[cfg(feature = "unicode-perl")] + fn class_perl() { + // Unicode + assert_eq!(t(r"\d"), hir_uclass_query(ClassQuery::Binary("digit"))); + assert_eq!(t(r"\s"), hir_uclass_query(ClassQuery::Binary("space"))); + assert_eq!(t(r"\w"), hir_uclass_perl_word()); + #[cfg(feature = "unicode-case")] + assert_eq!( + t(r"(?i)\d"), + hir_uclass_query(ClassQuery::Binary("digit")) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t(r"(?i)\s"), + hir_uclass_query(ClassQuery::Binary("space")) + ); + #[cfg(feature = "unicode-case")] + assert_eq!(t(r"(?i)\w"), hir_uclass_perl_word()); + + // Unicode, negated + assert_eq!( + t(r"\D"), + hir_negate(hir_uclass_query(ClassQuery::Binary("digit"))) + ); + assert_eq!( + t(r"\S"), + hir_negate(hir_uclass_query(ClassQuery::Binary("space"))) + ); + assert_eq!(t(r"\W"), hir_negate(hir_uclass_perl_word())); + #[cfg(feature = "unicode-case")] + assert_eq!( + t(r"(?i)\D"), + hir_negate(hir_uclass_query(ClassQuery::Binary("digit"))) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t(r"(?i)\S"), + hir_negate(hir_uclass_query(ClassQuery::Binary("space"))) + ); + #[cfg(feature = "unicode-case")] + assert_eq!(t(r"(?i)\W"), hir_negate(hir_uclass_perl_word())); + + // ASCII only + assert_eq!( + t(r"(?-u)\d"), + hir_bclass_from_char(ascii_class(&ast::ClassAsciiKind::Digit)) + ); + assert_eq!( + t(r"(?-u)\s"), + hir_bclass_from_char(ascii_class(&ast::ClassAsciiKind::Space)) + ); + assert_eq!( + t(r"(?-u)\w"), + hir_bclass_from_char(ascii_class(&ast::ClassAsciiKind::Word)) + ); + assert_eq!( + t(r"(?i-u)\d"), + hir_bclass_from_char(ascii_class(&ast::ClassAsciiKind::Digit)) + ); + assert_eq!( + t(r"(?i-u)\s"), + hir_bclass_from_char(ascii_class(&ast::ClassAsciiKind::Space)) + ); + assert_eq!( + t(r"(?i-u)\w"), + hir_bclass_from_char(ascii_class(&ast::ClassAsciiKind::Word)) + ); + + // ASCII only, negated + assert_eq!( + t(r"(?-u)\D"), + hir_negate(hir_bclass_from_char(ascii_class( + &ast::ClassAsciiKind::Digit + ))) + ); + assert_eq!( + t(r"(?-u)\S"), + hir_negate(hir_bclass_from_char(ascii_class( + &ast::ClassAsciiKind::Space + ))) + ); + assert_eq!( + t(r"(?-u)\W"), + hir_negate(hir_bclass_from_char(ascii_class( + &ast::ClassAsciiKind::Word + ))) + ); + assert_eq!( + t(r"(?i-u)\D"), + hir_negate(hir_bclass_from_char(ascii_class( + &ast::ClassAsciiKind::Digit + ))) + ); + assert_eq!( + t(r"(?i-u)\S"), + hir_negate(hir_bclass_from_char(ascii_class( + &ast::ClassAsciiKind::Space + ))) + ); + assert_eq!( + t(r"(?i-u)\W"), + hir_negate(hir_bclass_from_char(ascii_class( + &ast::ClassAsciiKind::Word + ))) + ); + } + + #[test] + #[cfg(not(feature = "unicode-perl"))] + fn class_perl_word_disabled() { + assert_eq!( + t_err(r"\w"), + TestError { + kind: hir::ErrorKind::UnicodePerlClassNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(2, 1, 3) + ), + } + ); + } + + #[test] + #[cfg(all(not(feature = "unicode-perl"), not(feature = "unicode-bool")))] + fn class_perl_space_disabled() { + assert_eq!( + t_err(r"\s"), + TestError { + kind: hir::ErrorKind::UnicodePerlClassNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(2, 1, 3) + ), + } + ); + } + + #[test] + #[cfg(all( + not(feature = "unicode-perl"), + not(feature = "unicode-gencat") + ))] + fn class_perl_digit_disabled() { + assert_eq!( + t_err(r"\d"), + TestError { + kind: hir::ErrorKind::UnicodePerlClassNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(2, 1, 3) + ), + } + ); + } + + #[test] + #[cfg(feature = "unicode-gencat")] + fn class_unicode_gencat() { + assert_eq!(t(r"\pZ"), hir_uclass_query(ClassQuery::Binary("Z"))); + assert_eq!(t(r"\pz"), hir_uclass_query(ClassQuery::Binary("Z"))); + assert_eq!( + t(r"\p{Separator}"), + hir_uclass_query(ClassQuery::Binary("Z")) + ); + assert_eq!( + t(r"\p{se PaRa ToR}"), + hir_uclass_query(ClassQuery::Binary("Z")) + ); + assert_eq!( + t(r"\p{gc:Separator}"), + hir_uclass_query(ClassQuery::Binary("Z")) + ); + assert_eq!( + t(r"\p{gc=Separator}"), + hir_uclass_query(ClassQuery::Binary("Z")) + ); + assert_eq!( + t(r"\p{Other}"), + hir_uclass_query(ClassQuery::Binary("Other")) + ); + assert_eq!(t(r"\pC"), hir_uclass_query(ClassQuery::Binary("Other"))); + + assert_eq!( + t(r"\PZ"), + hir_negate(hir_uclass_query(ClassQuery::Binary("Z"))) + ); + assert_eq!( + t(r"\P{separator}"), + hir_negate(hir_uclass_query(ClassQuery::Binary("Z"))) + ); + assert_eq!( + t(r"\P{gc!=separator}"), + hir_negate(hir_uclass_query(ClassQuery::Binary("Z"))) + ); + + assert_eq!(t(r"\p{any}"), hir_uclass_query(ClassQuery::Binary("Any"))); + assert_eq!( + t(r"\p{assigned}"), + hir_uclass_query(ClassQuery::Binary("Assigned")) + ); + assert_eq!( + t(r"\p{ascii}"), + hir_uclass_query(ClassQuery::Binary("ASCII")) + ); + assert_eq!( + t(r"\p{gc:any}"), + hir_uclass_query(ClassQuery::Binary("Any")) + ); + assert_eq!( + t(r"\p{gc:assigned}"), + hir_uclass_query(ClassQuery::Binary("Assigned")) + ); + assert_eq!( + t(r"\p{gc:ascii}"), + hir_uclass_query(ClassQuery::Binary("ASCII")) + ); + + assert_eq!( + t_err(r"(?-u)\pZ"), + TestError { + kind: hir::ErrorKind::UnicodeNotAllowed, + span: Span::new( + Position::new(5, 1, 6), + Position::new(8, 1, 9) + ), + } + ); + assert_eq!( + t_err(r"(?-u)\p{Separator}"), + TestError { + kind: hir::ErrorKind::UnicodeNotAllowed, + span: Span::new( + Position::new(5, 1, 6), + Position::new(18, 1, 19) + ), + } + ); + assert_eq!( + t_err(r"\pE"), + TestError { + kind: hir::ErrorKind::UnicodePropertyNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(3, 1, 4) + ), + } + ); + assert_eq!( + t_err(r"\p{Foo}"), + TestError { + kind: hir::ErrorKind::UnicodePropertyNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(7, 1, 8) + ), + } + ); + assert_eq!( + t_err(r"\p{gc:Foo}"), + TestError { + kind: hir::ErrorKind::UnicodePropertyValueNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(10, 1, 11) + ), + } + ); + } + + #[test] + #[cfg(not(feature = "unicode-gencat"))] + fn class_unicode_gencat_disabled() { + assert_eq!( + t_err(r"\p{Separator}"), + TestError { + kind: hir::ErrorKind::UnicodePropertyNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(13, 1, 14) + ), + } + ); + + assert_eq!( + t_err(r"\p{Any}"), + TestError { + kind: hir::ErrorKind::UnicodePropertyNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(7, 1, 8) + ), + } + ); + } + + #[test] + #[cfg(feature = "unicode-script")] + fn class_unicode_script() { + assert_eq!( + t(r"\p{Greek}"), + hir_uclass_query(ClassQuery::Binary("Greek")) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t(r"(?i)\p{Greek}"), + hir_case_fold(hir_uclass_query(ClassQuery::Binary("Greek"))) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t(r"(?i)\P{Greek}"), + hir_negate(hir_case_fold(hir_uclass_query(ClassQuery::Binary( + "Greek" + )))) + ); + + assert_eq!( + t_err(r"\p{sc:Foo}"), + TestError { + kind: hir::ErrorKind::UnicodePropertyValueNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(10, 1, 11) + ), + } + ); + assert_eq!( + t_err(r"\p{scx:Foo}"), + TestError { + kind: hir::ErrorKind::UnicodePropertyValueNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(11, 1, 12) + ), + } + ); + } + + #[test] + #[cfg(not(feature = "unicode-script"))] + fn class_unicode_script_disabled() { + assert_eq!( + t_err(r"\p{Greek}"), + TestError { + kind: hir::ErrorKind::UnicodePropertyNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(9, 1, 10) + ), + } + ); + + assert_eq!( + t_err(r"\p{scx:Greek}"), + TestError { + kind: hir::ErrorKind::UnicodePropertyNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(13, 1, 14) + ), + } + ); + } + + #[test] + #[cfg(feature = "unicode-age")] + fn class_unicode_age() { + assert_eq!( + t_err(r"\p{age:Foo}"), + TestError { + kind: hir::ErrorKind::UnicodePropertyValueNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(11, 1, 12) + ), + } + ); + } + + #[test] + #[cfg(not(feature = "unicode-age"))] + fn class_unicode_age_disabled() { + assert_eq!( + t_err(r"\p{age:3.0}"), + TestError { + kind: hir::ErrorKind::UnicodePropertyNotFound, + span: Span::new( + Position::new(0, 1, 1), + Position::new(11, 1, 12) + ), + } + ); + } + + #[test] + fn class_bracketed() { + assert_eq!(t("[a]"), hir_uclass(&[('a', 'a')])); + assert_eq!(t("[^[a]]"), hir_negate(hir_uclass(&[('a', 'a')]))); + assert_eq!(t("[a-z]"), hir_uclass(&[('a', 'z')])); + assert_eq!(t("[a-fd-h]"), hir_uclass(&[('a', 'h')])); + assert_eq!(t("[a-fg-m]"), hir_uclass(&[('a', 'm')])); + assert_eq!(t(r"[\x00]"), hir_uclass(&[('\0', '\0')])); + assert_eq!(t(r"[\n]"), hir_uclass(&[('\n', '\n')])); + assert_eq!(t("[\n]"), hir_uclass(&[('\n', '\n')])); + #[cfg(any(feature = "unicode-perl", feature = "unicode-gencat"))] + assert_eq!(t(r"[\d]"), hir_uclass_query(ClassQuery::Binary("digit"))); + #[cfg(feature = "unicode-gencat")] + assert_eq!( + t(r"[\pZ]"), + hir_uclass_query(ClassQuery::Binary("separator")) + ); + #[cfg(feature = "unicode-gencat")] + assert_eq!( + t(r"[\p{separator}]"), + hir_uclass_query(ClassQuery::Binary("separator")) + ); + #[cfg(any(feature = "unicode-perl", feature = "unicode-gencat"))] + assert_eq!(t(r"[^\D]"), hir_uclass_query(ClassQuery::Binary("digit"))); + #[cfg(feature = "unicode-gencat")] + assert_eq!( + t(r"[^\PZ]"), + hir_uclass_query(ClassQuery::Binary("separator")) + ); + #[cfg(feature = "unicode-gencat")] + assert_eq!( + t(r"[^\P{separator}]"), + hir_uclass_query(ClassQuery::Binary("separator")) + ); + #[cfg(all( + feature = "unicode-case", + any(feature = "unicode-perl", feature = "unicode-gencat") + ))] + assert_eq!( + t(r"(?i)[^\D]"), + hir_uclass_query(ClassQuery::Binary("digit")) + ); + #[cfg(all(feature = "unicode-case", feature = "unicode-script"))] + assert_eq!( + t(r"(?i)[^\P{greek}]"), + hir_case_fold(hir_uclass_query(ClassQuery::Binary("greek"))) + ); + + assert_eq!(t("(?-u)[a]"), hir_bclass(&[(b'a', b'a')])); + assert_eq!(t(r"(?-u)[\x00]"), hir_bclass(&[(b'\0', b'\0')])); + assert_eq!(t_bytes(r"(?-u)[\xFF]"), hir_bclass(&[(b'\xFF', b'\xFF')])); + + #[cfg(feature = "unicode-case")] + assert_eq!(t("(?i)[a]"), hir_uclass(&[('A', 'A'), ('a', 'a')])); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)[k]"), + hir_uclass(&[('K', 'K'), ('k', 'k'), ('\u{212A}', '\u{212A}'),]) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)[β]"), + hir_uclass(&[('Β', 'Β'), ('β', 'β'), ('ϐ', 'ϐ'),]) + ); + assert_eq!(t("(?i-u)[k]"), hir_bclass(&[(b'K', b'K'), (b'k', b'k'),])); + + assert_eq!(t("[^a]"), hir_negate(hir_uclass(&[('a', 'a')]))); + assert_eq!(t(r"[^\x00]"), hir_negate(hir_uclass(&[('\0', '\0')]))); + assert_eq!( + t_bytes("(?-u)[^a]"), + hir_negate(hir_bclass(&[(b'a', b'a')])) + ); + #[cfg(any(feature = "unicode-perl", feature = "unicode-gencat"))] + assert_eq!( + t(r"[^\d]"), + hir_negate(hir_uclass_query(ClassQuery::Binary("digit"))) + ); + #[cfg(feature = "unicode-gencat")] + assert_eq!( + t(r"[^\pZ]"), + hir_negate(hir_uclass_query(ClassQuery::Binary("separator"))) + ); + #[cfg(feature = "unicode-gencat")] + assert_eq!( + t(r"[^\p{separator}]"), + hir_negate(hir_uclass_query(ClassQuery::Binary("separator"))) + ); + #[cfg(all(feature = "unicode-case", feature = "unicode-script"))] + assert_eq!( + t(r"(?i)[^\p{greek}]"), + hir_negate(hir_case_fold(hir_uclass_query(ClassQuery::Binary( + "greek" + )))) + ); + #[cfg(all(feature = "unicode-case", feature = "unicode-script"))] + assert_eq!( + t(r"(?i)[\P{greek}]"), + hir_negate(hir_case_fold(hir_uclass_query(ClassQuery::Binary( + "greek" + )))) + ); + + // Test some weird cases. + assert_eq!(t(r"[\[]"), hir_uclass(&[('[', '[')])); + + assert_eq!(t(r"[&]"), hir_uclass(&[('&', '&')])); + assert_eq!(t(r"[\&]"), hir_uclass(&[('&', '&')])); + assert_eq!(t(r"[\&\&]"), hir_uclass(&[('&', '&')])); + assert_eq!(t(r"[\x00-&]"), hir_uclass(&[('\0', '&')])); + assert_eq!(t(r"[&-\xFF]"), hir_uclass(&[('&', '\u{FF}')])); + + assert_eq!(t(r"[~]"), hir_uclass(&[('~', '~')])); + assert_eq!(t(r"[\~]"), hir_uclass(&[('~', '~')])); + assert_eq!(t(r"[\~\~]"), hir_uclass(&[('~', '~')])); + assert_eq!(t(r"[\x00-~]"), hir_uclass(&[('\0', '~')])); + assert_eq!(t(r"[~-\xFF]"), hir_uclass(&[('~', '\u{FF}')])); + + assert_eq!(t(r"[-]"), hir_uclass(&[('-', '-')])); + assert_eq!(t(r"[\-]"), hir_uclass(&[('-', '-')])); + assert_eq!(t(r"[\-\-]"), hir_uclass(&[('-', '-')])); + assert_eq!(t(r"[\x00-\-]"), hir_uclass(&[('\0', '-')])); + assert_eq!(t(r"[\--\xFF]"), hir_uclass(&[('-', '\u{FF}')])); + + assert_eq!( + t_err("(?-u)[^a]"), + TestError { + kind: hir::ErrorKind::InvalidUtf8, + span: Span::new( + Position::new(5, 1, 6), + Position::new(9, 1, 10) + ), + } + ); + #[cfg(any(feature = "unicode-perl", feature = "unicode-bool"))] + assert_eq!( + t_err(r"[^\s\S]"), + TestError { + kind: hir::ErrorKind::EmptyClassNotAllowed, + span: Span::new( + Position::new(0, 1, 1), + Position::new(7, 1, 8) + ), + } + ); + #[cfg(any(feature = "unicode-perl", feature = "unicode-bool"))] + assert_eq!( + t_err(r"(?-u)[^\s\S]"), + TestError { + kind: hir::ErrorKind::EmptyClassNotAllowed, + span: Span::new( + Position::new(5, 1, 6), + Position::new(12, 1, 13) + ), + } + ); + } + + #[test] + fn class_bracketed_union() { + assert_eq!(t("[a-zA-Z]"), hir_uclass(&[('A', 'Z'), ('a', 'z')])); + #[cfg(feature = "unicode-gencat")] + assert_eq!( + t(r"[a\pZb]"), + hir_union( + hir_uclass(&[('a', 'b')]), + hir_uclass_query(ClassQuery::Binary("separator")) + ) + ); + #[cfg(all(feature = "unicode-gencat", feature = "unicode-script"))] + assert_eq!( + t(r"[\pZ\p{Greek}]"), + hir_union( + hir_uclass_query(ClassQuery::Binary("greek")), + hir_uclass_query(ClassQuery::Binary("separator")) + ) + ); + #[cfg(all( + feature = "unicode-age", + feature = "unicode-gencat", + feature = "unicode-script" + ))] + assert_eq!( + t(r"[\p{age:3.0}\pZ\p{Greek}]"), + hir_union( + hir_uclass_query(ClassQuery::ByValue { + property_name: "age", + property_value: "3.0", + }), + hir_union( + hir_uclass_query(ClassQuery::Binary("greek")), + hir_uclass_query(ClassQuery::Binary("separator")) + ) + ) + ); + #[cfg(all( + feature = "unicode-age", + feature = "unicode-gencat", + feature = "unicode-script" + ))] + assert_eq!( + t(r"[[[\p{age:3.0}\pZ]\p{Greek}][\p{Cyrillic}]]"), + hir_union( + hir_uclass_query(ClassQuery::ByValue { + property_name: "age", + property_value: "3.0", + }), + hir_union( + hir_uclass_query(ClassQuery::Binary("cyrillic")), + hir_union( + hir_uclass_query(ClassQuery::Binary("greek")), + hir_uclass_query(ClassQuery::Binary("separator")) + ) + ) + ) + ); + + #[cfg(all( + feature = "unicode-age", + feature = "unicode-case", + feature = "unicode-gencat", + feature = "unicode-script" + ))] + assert_eq!( + t(r"(?i)[\p{age:3.0}\pZ\p{Greek}]"), + hir_case_fold(hir_union( + hir_uclass_query(ClassQuery::ByValue { + property_name: "age", + property_value: "3.0", + }), + hir_union( + hir_uclass_query(ClassQuery::Binary("greek")), + hir_uclass_query(ClassQuery::Binary("separator")) + ) + )) + ); + #[cfg(all( + feature = "unicode-age", + feature = "unicode-gencat", + feature = "unicode-script" + ))] + assert_eq!( + t(r"[^\p{age:3.0}\pZ\p{Greek}]"), + hir_negate(hir_union( + hir_uclass_query(ClassQuery::ByValue { + property_name: "age", + property_value: "3.0", + }), + hir_union( + hir_uclass_query(ClassQuery::Binary("greek")), + hir_uclass_query(ClassQuery::Binary("separator")) + ) + )) + ); + #[cfg(all( + feature = "unicode-age", + feature = "unicode-case", + feature = "unicode-gencat", + feature = "unicode-script" + ))] + assert_eq!( + t(r"(?i)[^\p{age:3.0}\pZ\p{Greek}]"), + hir_negate(hir_case_fold(hir_union( + hir_uclass_query(ClassQuery::ByValue { + property_name: "age", + property_value: "3.0", + }), + hir_union( + hir_uclass_query(ClassQuery::Binary("greek")), + hir_uclass_query(ClassQuery::Binary("separator")) + ) + ))) + ); + } + + #[test] + fn class_bracketed_nested() { + assert_eq!(t(r"[a[^c]]"), hir_negate(hir_uclass(&[('c', 'c')]))); + assert_eq!(t(r"[a-b[^c]]"), hir_negate(hir_uclass(&[('c', 'c')]))); + assert_eq!(t(r"[a-c[^c]]"), hir_negate(hir_uclass(&[]))); + + assert_eq!(t(r"[^a[^c]]"), hir_uclass(&[('c', 'c')])); + assert_eq!(t(r"[^a-b[^c]]"), hir_uclass(&[('c', 'c')])); + + #[cfg(feature = "unicode-case")] + assert_eq!( + t(r"(?i)[a[^c]]"), + hir_negate(hir_case_fold(hir_uclass(&[('c', 'c')]))) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t(r"(?i)[a-b[^c]]"), + hir_negate(hir_case_fold(hir_uclass(&[('c', 'c')]))) + ); + + #[cfg(feature = "unicode-case")] + assert_eq!(t(r"(?i)[^a[^c]]"), hir_uclass(&[('C', 'C'), ('c', 'c')])); + #[cfg(feature = "unicode-case")] + assert_eq!( + t(r"(?i)[^a-b[^c]]"), + hir_uclass(&[('C', 'C'), ('c', 'c')]) + ); + + assert_eq!( + t_err(r"[^a-c[^c]]"), + TestError { + kind: hir::ErrorKind::EmptyClassNotAllowed, + span: Span::new( + Position::new(0, 1, 1), + Position::new(10, 1, 11) + ), + } + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t_err(r"(?i)[^a-c[^c]]"), + TestError { + kind: hir::ErrorKind::EmptyClassNotAllowed, + span: Span::new( + Position::new(4, 1, 5), + Position::new(14, 1, 15) + ), + } + ); + } + + #[test] + fn class_bracketed_intersect() { + assert_eq!(t("[abc&&b-c]"), hir_uclass(&[('b', 'c')])); + assert_eq!(t("[abc&&[b-c]]"), hir_uclass(&[('b', 'c')])); + assert_eq!(t("[[abc]&&[b-c]]"), hir_uclass(&[('b', 'c')])); + assert_eq!(t("[a-z&&b-y&&c-x]"), hir_uclass(&[('c', 'x')])); + assert_eq!(t("[c-da-b&&a-d]"), hir_uclass(&[('a', 'd')])); + assert_eq!(t("[a-d&&c-da-b]"), hir_uclass(&[('a', 'd')])); + assert_eq!(t(r"[a-z&&a-c]"), hir_uclass(&[('a', 'c')])); + assert_eq!(t(r"[[a-z&&a-c]]"), hir_uclass(&[('a', 'c')])); + assert_eq!(t(r"[^[a-z&&a-c]]"), hir_negate(hir_uclass(&[('a', 'c')]))); + + assert_eq!(t("(?-u)[abc&&b-c]"), hir_bclass(&[(b'b', b'c')])); + assert_eq!(t("(?-u)[abc&&[b-c]]"), hir_bclass(&[(b'b', b'c')])); + assert_eq!(t("(?-u)[[abc]&&[b-c]]"), hir_bclass(&[(b'b', b'c')])); + assert_eq!(t("(?-u)[a-z&&b-y&&c-x]"), hir_bclass(&[(b'c', b'x')])); + assert_eq!(t("(?-u)[c-da-b&&a-d]"), hir_bclass(&[(b'a', b'd')])); + assert_eq!(t("(?-u)[a-d&&c-da-b]"), hir_bclass(&[(b'a', b'd')])); + + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)[abc&&b-c]"), + hir_case_fold(hir_uclass(&[('b', 'c')])) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)[abc&&[b-c]]"), + hir_case_fold(hir_uclass(&[('b', 'c')])) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)[[abc]&&[b-c]]"), + hir_case_fold(hir_uclass(&[('b', 'c')])) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)[a-z&&b-y&&c-x]"), + hir_case_fold(hir_uclass(&[('c', 'x')])) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)[c-da-b&&a-d]"), + hir_case_fold(hir_uclass(&[('a', 'd')])) + ); + #[cfg(feature = "unicode-case")] + assert_eq!( + t("(?i)[a-d&&c-da-b]"), + hir_case_fold(hir_uclass(&[('a', 'd')])) + ); + + assert_eq!( + t("(?i-u)[abc&&b-c]"), + hir_case_fold(hir_bclass(&[(b'b', b'c')])) + ); + assert_eq!( + t("(?i-u)[abc&&[b-c]]"), + hir_case_fold(hir_bclass(&[(b'b', b'c')])) + ); + assert_eq!( + t("(?i-u)[[abc]&&[b-c]]"), + hir_case_fold(hir_bclass(&[(b'b', b'c')])) + ); + assert_eq!( + t("(?i-u)[a-z&&b-y&&c-x]"), + hir_case_fold(hir_bclass(&[(b'c', b'x')])) + ); + assert_eq!( + t("(?i-u)[c-da-b&&a-d]"), + hir_case_fold(hir_bclass(&[(b'a', b'd')])) + ); + assert_eq!( + t("(?i-u)[a-d&&c-da-b]"), + hir_case_fold(hir_bclass(&[(b'a', b'd')])) + ); + + // In `[a^]`, `^` does not need to be escaped, so it makes sense that + // `^` is also allowed to be unescaped after `&&`. + assert_eq!(t(r"[\^&&^]"), hir_uclass(&[('^', '^')])); + // `]` needs to be escaped after `&&` since it's not at start of class. + assert_eq!(t(r"[]&&\]]"), hir_uclass(&[(']', ']')])); + assert_eq!(t(r"[-&&-]"), hir_uclass(&[('-', '-')])); + assert_eq!(t(r"[\&&&&]"), hir_uclass(&[('&', '&')])); + assert_eq!(t(r"[\&&&\&]"), hir_uclass(&[('&', '&')])); + // Test precedence. + assert_eq!( + t(r"[a-w&&[^c-g]z]"), + hir_uclass(&[('a', 'b'), ('h', 'w')]) + ); + } + + #[test] + fn class_bracketed_intersect_negate() { + #[cfg(feature = "unicode-perl")] + assert_eq!( + t(r"[^\w&&\d]"), + hir_negate(hir_uclass_query(ClassQuery::Binary("digit"))) + ); + assert_eq!(t(r"[^[a-z&&a-c]]"), hir_negate(hir_uclass(&[('a', 'c')]))); + #[cfg(feature = "unicode-perl")] + assert_eq!( + t(r"[^[\w&&\d]]"), + hir_negate(hir_uclass_query(ClassQuery::Binary("digit"))) + ); + #[cfg(feature = "unicode-perl")] + assert_eq!( + t(r"[^[^\w&&\d]]"), + hir_uclass_query(ClassQuery::Binary("digit")) + ); + #[cfg(feature = "unicode-perl")] + assert_eq!(t(r"[[[^\w]&&[^\d]]]"), hir_negate(hir_uclass_perl_word())); + + #[cfg(feature = "unicode-perl")] + assert_eq!( + t_bytes(r"(?-u)[^\w&&\d]"), + hir_negate(hir_bclass_from_char(ascii_class( + &ast::ClassAsciiKind::Digit + ))) + ); + assert_eq!( + t_bytes(r"(?-u)[^[a-z&&a-c]]"), + hir_negate(hir_bclass(&[(b'a', b'c')])) + ); + assert_eq!( + t_bytes(r"(?-u)[^[\w&&\d]]"), + hir_negate(hir_bclass_from_char(ascii_class( + &ast::ClassAsciiKind::Digit + ))) + ); + assert_eq!( + t_bytes(r"(?-u)[^[^\w&&\d]]"), + hir_bclass_from_char(ascii_class(&ast::ClassAsciiKind::Digit)) + ); + assert_eq!( + t_bytes(r"(?-u)[[[^\w]&&[^\d]]]"), + hir_negate(hir_bclass_from_char(ascii_class( + &ast::ClassAsciiKind::Word + ))) + ); + } + + #[test] + fn class_bracketed_difference() { + #[cfg(feature = "unicode-gencat")] + assert_eq!( + t(r"[\pL--[:ascii:]]"), + hir_difference( + hir_uclass_query(ClassQuery::Binary("letter")), + hir_uclass(&[('\0', '\x7F')]) + ) + ); + + assert_eq!( + t(r"(?-u)[[:alpha:]--[:lower:]]"), + hir_bclass(&[(b'A', b'Z')]) + ); + } + + #[test] + fn class_bracketed_symmetric_difference() { + #[cfg(feature = "unicode-script")] + assert_eq!( + t(r"[\p{sc:Greek}~~\p{scx:Greek}]"), + hir_uclass(&[ + ('\u{0342}', '\u{0342}'), + ('\u{0345}', '\u{0345}'), + ('\u{1DC0}', '\u{1DC1}'), + ]) + ); + assert_eq!(t(r"[a-g~~c-j]"), hir_uclass(&[('a', 'b'), ('h', 'j')])); + + assert_eq!( + t(r"(?-u)[a-g~~c-j]"), + hir_bclass(&[(b'a', b'b'), (b'h', b'j')]) + ); + } + + #[test] + fn ignore_whitespace() { + assert_eq!(t(r"(?x)\12 3"), hir_lit("\n3")); + assert_eq!(t(r"(?x)\x { 53 }"), hir_lit("S")); + assert_eq!( + t(r"(?x)\x # comment +{ # comment + 53 # comment +} #comment"), + hir_lit("S") + ); + + assert_eq!(t(r"(?x)\x 53"), hir_lit("S")); + assert_eq!( + t(r"(?x)\x # comment + 53 # comment"), + hir_lit("S") + ); + assert_eq!(t(r"(?x)\x5 3"), hir_lit("S")); + + #[cfg(feature = "unicode-gencat")] + assert_eq!( + t(r"(?x)\p # comment +{ # comment + Separator # comment +} # comment"), + hir_uclass_query(ClassQuery::Binary("separator")) + ); + + assert_eq!( + t(r"(?x)a # comment +{ # comment + 5 # comment + , # comment + 10 # comment +} # comment"), + hir_range( + true, + hir::RepetitionRange::Bounded(5, 10), + hir_lit("a") + ) + ); + + assert_eq!(t(r"(?x)a\ # hi there"), hir_lit("a ")); + } + + #[test] + fn analysis_is_always_utf8() { + // Positive examples. + assert!(t_bytes(r"a").is_always_utf8()); + assert!(t_bytes(r"ab").is_always_utf8()); + assert!(t_bytes(r"(?-u)a").is_always_utf8()); + assert!(t_bytes(r"(?-u)ab").is_always_utf8()); + assert!(t_bytes(r"\xFF").is_always_utf8()); + assert!(t_bytes(r"\xFF\xFF").is_always_utf8()); + assert!(t_bytes(r"[^a]").is_always_utf8()); + assert!(t_bytes(r"[^a][^a]").is_always_utf8()); + assert!(t_bytes(r"\b").is_always_utf8()); + assert!(t_bytes(r"\B").is_always_utf8()); + assert!(t_bytes(r"(?-u)\b").is_always_utf8()); + + // Negative examples. + assert!(!t_bytes(r"(?-u)\xFF").is_always_utf8()); + assert!(!t_bytes(r"(?-u)\xFF\xFF").is_always_utf8()); + assert!(!t_bytes(r"(?-u)[^a]").is_always_utf8()); + assert!(!t_bytes(r"(?-u)[^a][^a]").is_always_utf8()); + assert!(!t_bytes(r"(?-u)\B").is_always_utf8()); + } + + #[test] + fn analysis_is_all_assertions() { + // Positive examples. + assert!(t(r"\b").is_all_assertions()); + assert!(t(r"\B").is_all_assertions()); + assert!(t(r"^").is_all_assertions()); + assert!(t(r"$").is_all_assertions()); + assert!(t(r"\A").is_all_assertions()); + assert!(t(r"\z").is_all_assertions()); + assert!(t(r"$^\z\A\b\B").is_all_assertions()); + assert!(t(r"$|^|\z|\A|\b|\B").is_all_assertions()); + assert!(t(r"^$|$^").is_all_assertions()); + assert!(t(r"((\b)+())*^").is_all_assertions()); + + // Negative examples. + assert!(!t(r"^a").is_all_assertions()); + } + + #[test] + fn analysis_is_anchored() { + // Positive examples. + assert!(t(r"^").is_anchored_start()); + assert!(t(r"$").is_anchored_end()); + assert!(t(r"^").is_line_anchored_start()); + assert!(t(r"$").is_line_anchored_end()); + + assert!(t(r"^^").is_anchored_start()); + assert!(t(r"$$").is_anchored_end()); + assert!(t(r"^^").is_line_anchored_start()); + assert!(t(r"$$").is_line_anchored_end()); + + assert!(t(r"^$").is_anchored_start()); + assert!(t(r"^$").is_anchored_end()); + assert!(t(r"^$").is_line_anchored_start()); + assert!(t(r"^$").is_line_anchored_end()); + + assert!(t(r"^foo").is_anchored_start()); + assert!(t(r"foo$").is_anchored_end()); + assert!(t(r"^foo").is_line_anchored_start()); + assert!(t(r"foo$").is_line_anchored_end()); + + assert!(t(r"^foo|^bar").is_anchored_start()); + assert!(t(r"foo$|bar$").is_anchored_end()); + assert!(t(r"^foo|^bar").is_line_anchored_start()); + assert!(t(r"foo$|bar$").is_line_anchored_end()); + + assert!(t(r"^(foo|bar)").is_anchored_start()); + assert!(t(r"(foo|bar)$").is_anchored_end()); + assert!(t(r"^(foo|bar)").is_line_anchored_start()); + assert!(t(r"(foo|bar)$").is_line_anchored_end()); + + assert!(t(r"^+").is_anchored_start()); + assert!(t(r"$+").is_anchored_end()); + assert!(t(r"^+").is_line_anchored_start()); + assert!(t(r"$+").is_line_anchored_end()); + assert!(t(r"^++").is_anchored_start()); + assert!(t(r"$++").is_anchored_end()); + assert!(t(r"^++").is_line_anchored_start()); + assert!(t(r"$++").is_line_anchored_end()); + assert!(t(r"(^)+").is_anchored_start()); + assert!(t(r"($)+").is_anchored_end()); + assert!(t(r"(^)+").is_line_anchored_start()); + assert!(t(r"($)+").is_line_anchored_end()); + + assert!(t(r"$^").is_anchored_start()); + assert!(t(r"$^").is_anchored_start()); + assert!(t(r"$^").is_line_anchored_end()); + assert!(t(r"$^").is_line_anchored_end()); + assert!(t(r"$^|^$").is_anchored_start()); + assert!(t(r"$^|^$").is_anchored_end()); + assert!(t(r"$^|^$").is_line_anchored_start()); + assert!(t(r"$^|^$").is_line_anchored_end()); + + assert!(t(r"\b^").is_anchored_start()); + assert!(t(r"$\b").is_anchored_end()); + assert!(t(r"\b^").is_line_anchored_start()); + assert!(t(r"$\b").is_line_anchored_end()); + assert!(t(r"^(?m:^)").is_anchored_start()); + assert!(t(r"(?m:$)$").is_anchored_end()); + assert!(t(r"^(?m:^)").is_line_anchored_start()); + assert!(t(r"(?m:$)$").is_line_anchored_end()); + assert!(t(r"(?m:^)^").is_anchored_start()); + assert!(t(r"$(?m:$)").is_anchored_end()); + assert!(t(r"(?m:^)^").is_line_anchored_start()); + assert!(t(r"$(?m:$)").is_line_anchored_end()); + + // Negative examples. + assert!(!t(r"(?m)^").is_anchored_start()); + assert!(!t(r"(?m)$").is_anchored_end()); + assert!(!t(r"(?m:^$)|$^").is_anchored_start()); + assert!(!t(r"(?m:^$)|$^").is_anchored_end()); + assert!(!t(r"$^|(?m:^$)").is_anchored_start()); + assert!(!t(r"$^|(?m:^$)").is_anchored_end()); + + assert!(!t(r"a^").is_anchored_start()); + assert!(!t(r"$a").is_anchored_start()); + assert!(!t(r"a^").is_line_anchored_start()); + assert!(!t(r"$a").is_line_anchored_start()); + + assert!(!t(r"a^").is_anchored_end()); + assert!(!t(r"$a").is_anchored_end()); + assert!(!t(r"a^").is_line_anchored_end()); + assert!(!t(r"$a").is_line_anchored_end()); + + assert!(!t(r"^foo|bar").is_anchored_start()); + assert!(!t(r"foo|bar$").is_anchored_end()); + assert!(!t(r"^foo|bar").is_line_anchored_start()); + assert!(!t(r"foo|bar$").is_line_anchored_end()); + + assert!(!t(r"^*").is_anchored_start()); + assert!(!t(r"$*").is_anchored_end()); + assert!(!t(r"^*").is_line_anchored_start()); + assert!(!t(r"$*").is_line_anchored_end()); + assert!(!t(r"^*+").is_anchored_start()); + assert!(!t(r"$*+").is_anchored_end()); + assert!(!t(r"^*+").is_line_anchored_start()); + assert!(!t(r"$*+").is_line_anchored_end()); + assert!(!t(r"^+*").is_anchored_start()); + assert!(!t(r"$+*").is_anchored_end()); + assert!(!t(r"^+*").is_line_anchored_start()); + assert!(!t(r"$+*").is_line_anchored_end()); + assert!(!t(r"(^)*").is_anchored_start()); + assert!(!t(r"($)*").is_anchored_end()); + assert!(!t(r"(^)*").is_line_anchored_start()); + assert!(!t(r"($)*").is_line_anchored_end()); + } + + #[test] + fn analysis_is_line_anchored() { + assert!(t(r"(?m)^(foo|bar)").is_line_anchored_start()); + assert!(t(r"(?m)(foo|bar)$").is_line_anchored_end()); + + assert!(t(r"(?m)^foo|^bar").is_line_anchored_start()); + assert!(t(r"(?m)foo$|bar$").is_line_anchored_end()); + + assert!(t(r"(?m)^").is_line_anchored_start()); + assert!(t(r"(?m)$").is_line_anchored_end()); + + assert!(t(r"(?m:^$)|$^").is_line_anchored_start()); + assert!(t(r"(?m:^$)|$^").is_line_anchored_end()); + + assert!(t(r"$^|(?m:^$)").is_line_anchored_start()); + assert!(t(r"$^|(?m:^$)").is_line_anchored_end()); + } + + #[test] + fn analysis_is_any_anchored() { + // Positive examples. + assert!(t(r"^").is_any_anchored_start()); + assert!(t(r"$").is_any_anchored_end()); + assert!(t(r"\A").is_any_anchored_start()); + assert!(t(r"\z").is_any_anchored_end()); + + // Negative examples. + assert!(!t(r"(?m)^").is_any_anchored_start()); + assert!(!t(r"(?m)$").is_any_anchored_end()); + assert!(!t(r"$").is_any_anchored_start()); + assert!(!t(r"^").is_any_anchored_end()); + } + + #[test] + fn analysis_is_match_empty() { + // Positive examples. + assert!(t(r"").is_match_empty()); + assert!(t(r"()").is_match_empty()); + assert!(t(r"()*").is_match_empty()); + assert!(t(r"()+").is_match_empty()); + assert!(t(r"()?").is_match_empty()); + assert!(t(r"a*").is_match_empty()); + assert!(t(r"a?").is_match_empty()); + assert!(t(r"a{0}").is_match_empty()); + assert!(t(r"a{0,}").is_match_empty()); + assert!(t(r"a{0,1}").is_match_empty()); + assert!(t(r"a{0,10}").is_match_empty()); + #[cfg(feature = "unicode-gencat")] + assert!(t(r"\pL*").is_match_empty()); + assert!(t(r"a*|b").is_match_empty()); + assert!(t(r"b|a*").is_match_empty()); + assert!(t(r"a*a?(abcd)*").is_match_empty()); + assert!(t(r"^").is_match_empty()); + assert!(t(r"$").is_match_empty()); + assert!(t(r"(?m)^").is_match_empty()); + assert!(t(r"(?m)$").is_match_empty()); + assert!(t(r"\A").is_match_empty()); + assert!(t(r"\z").is_match_empty()); + assert!(t(r"\B").is_match_empty()); + assert!(t_bytes(r"(?-u)\B").is_match_empty()); + + // Negative examples. + assert!(!t(r"a+").is_match_empty()); + assert!(!t(r"a{1}").is_match_empty()); + assert!(!t(r"a{1,}").is_match_empty()); + assert!(!t(r"a{1,2}").is_match_empty()); + assert!(!t(r"a{1,10}").is_match_empty()); + assert!(!t(r"b|a").is_match_empty()); + assert!(!t(r"a*a+(abcd)*").is_match_empty()); + assert!(!t(r"\b").is_match_empty()); + assert!(!t(r"(?-u)\b").is_match_empty()); + } + + #[test] + fn analysis_is_literal() { + // Positive examples. + assert!(t(r"").is_literal()); + assert!(t(r"a").is_literal()); + assert!(t(r"ab").is_literal()); + assert!(t(r"abc").is_literal()); + assert!(t(r"(?m)abc").is_literal()); + + // Negative examples. + assert!(!t(r"^").is_literal()); + assert!(!t(r"a|b").is_literal()); + assert!(!t(r"(a)").is_literal()); + assert!(!t(r"a+").is_literal()); + assert!(!t(r"foo(a)").is_literal()); + assert!(!t(r"(a)foo").is_literal()); + assert!(!t(r"[a]").is_literal()); + } + + #[test] + fn analysis_is_alternation_literal() { + // Positive examples. + assert!(t(r"").is_alternation_literal()); + assert!(t(r"a").is_alternation_literal()); + assert!(t(r"ab").is_alternation_literal()); + assert!(t(r"abc").is_alternation_literal()); + assert!(t(r"(?m)abc").is_alternation_literal()); + assert!(t(r"a|b").is_alternation_literal()); + assert!(t(r"a|b|c").is_alternation_literal()); + assert!(t(r"foo|bar").is_alternation_literal()); + assert!(t(r"foo|bar|baz").is_alternation_literal()); + + // Negative examples. + assert!(!t(r"^").is_alternation_literal()); + assert!(!t(r"(a)").is_alternation_literal()); + assert!(!t(r"a+").is_alternation_literal()); + assert!(!t(r"foo(a)").is_alternation_literal()); + assert!(!t(r"(a)foo").is_alternation_literal()); + assert!(!t(r"[a]").is_alternation_literal()); + assert!(!t(r"[a]|b").is_alternation_literal()); + assert!(!t(r"a|[b]").is_alternation_literal()); + assert!(!t(r"(a)|b").is_alternation_literal()); + assert!(!t(r"a|(b)").is_alternation_literal()); + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/visitor.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/visitor.rs new file mode 100644 index 0000000..81a9e98 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/hir/visitor.rs @@ -0,0 +1,203 @@ +use hir::{self, Hir, HirKind}; + +/// A trait for visiting the high-level IR (HIR) in depth first order. +/// +/// The principle aim of this trait is to enable callers to perform case +/// analysis on a high-level intermediate representation of a regular +/// expression without necessarily using recursion. In particular, this permits +/// callers to do case analysis with constant stack usage, which can be +/// important since the size of an HIR may be proportional to end user input. +/// +/// Typical usage of this trait involves providing an implementation and then +/// running it using the [`visit`](fn.visit.html) function. +pub trait Visitor { + /// The result of visiting an HIR. + type Output; + /// An error that visiting an HIR might return. + type Err; + + /// All implementors of `Visitor` must provide a `finish` method, which + /// yields the result of visiting the HIR or an error. + fn finish(self) -> Result<Self::Output, Self::Err>; + + /// This method is called before beginning traversal of the HIR. + fn start(&mut self) {} + + /// This method is called on an `Hir` before descending into child `Hir` + /// nodes. + fn visit_pre(&mut self, _hir: &Hir) -> Result<(), Self::Err> { + Ok(()) + } + + /// This method is called on an `Hir` after descending all of its child + /// `Hir` nodes. + fn visit_post(&mut self, _hir: &Hir) -> Result<(), Self::Err> { + Ok(()) + } + + /// This method is called between child nodes of an alternation. + fn visit_alternation_in(&mut self) -> Result<(), Self::Err> { + Ok(()) + } +} + +/// Executes an implementation of `Visitor` in constant stack space. +/// +/// This function will visit every node in the given `Hir` while calling +/// appropriate methods provided by the +/// [`Visitor`](trait.Visitor.html) trait. +/// +/// The primary use case for this method is when one wants to perform case +/// analysis over an `Hir` without using a stack size proportional to the depth +/// of the `Hir`. Namely, this method will instead use constant stack space, +/// but will use heap space proportional to the size of the `Hir`. This may be +/// desirable in cases where the size of `Hir` is proportional to end user +/// input. +/// +/// If the visitor returns an error at any point, then visiting is stopped and +/// the error is returned. +pub fn visit<V: Visitor>(hir: &Hir, visitor: V) -> Result<V::Output, V::Err> { + HeapVisitor::new().visit(hir, visitor) +} + +/// HeapVisitor visits every item in an `Hir` recursively using constant stack +/// size and a heap size proportional to the size of the `Hir`. +struct HeapVisitor<'a> { + /// A stack of `Hir` nodes. This is roughly analogous to the call stack + /// used in a typical recursive visitor. + stack: Vec<(&'a Hir, Frame<'a>)>, +} + +/// Represents a single stack frame while performing structural induction over +/// an `Hir`. +enum Frame<'a> { + /// A stack frame allocated just before descending into a repetition + /// operator's child node. + Repetition(&'a hir::Repetition), + /// A stack frame allocated just before descending into a group's child + /// node. + Group(&'a hir::Group), + /// The stack frame used while visiting every child node of a concatenation + /// of expressions. + Concat { + /// The child node we are currently visiting. + head: &'a Hir, + /// The remaining child nodes to visit (which may be empty). + tail: &'a [Hir], + }, + /// The stack frame used while visiting every child node of an alternation + /// of expressions. + Alternation { + /// The child node we are currently visiting. + head: &'a Hir, + /// The remaining child nodes to visit (which may be empty). + tail: &'a [Hir], + }, +} + +impl<'a> HeapVisitor<'a> { + fn new() -> HeapVisitor<'a> { + HeapVisitor { stack: vec![] } + } + + fn visit<V: Visitor>( + &mut self, + mut hir: &'a Hir, + mut visitor: V, + ) -> Result<V::Output, V::Err> { + self.stack.clear(); + + visitor.start(); + loop { + visitor.visit_pre(hir)?; + if let Some(x) = self.induct(hir) { + let child = x.child(); + self.stack.push((hir, x)); + hir = child; + continue; + } + // No induction means we have a base case, so we can post visit + // it now. + visitor.visit_post(hir)?; + + // At this point, we now try to pop our call stack until it is + // either empty or we hit another inductive case. + loop { + let (post_hir, frame) = match self.stack.pop() { + None => return visitor.finish(), + Some((post_hir, frame)) => (post_hir, frame), + }; + // If this is a concat/alternate, then we might have additional + // inductive steps to process. + if let Some(x) = self.pop(frame) { + if let Frame::Alternation { .. } = x { + visitor.visit_alternation_in()?; + } + hir = x.child(); + self.stack.push((post_hir, x)); + break; + } + // Otherwise, we've finished visiting all the child nodes for + // this HIR, so we can post visit it now. + visitor.visit_post(post_hir)?; + } + } + } + + /// Build a stack frame for the given HIR if one is needed (which occurs if + /// and only if there are child nodes in the HIR). Otherwise, return None. + fn induct(&mut self, hir: &'a Hir) -> Option<Frame<'a>> { + match *hir.kind() { + HirKind::Repetition(ref x) => Some(Frame::Repetition(x)), + HirKind::Group(ref x) => Some(Frame::Group(x)), + HirKind::Concat(ref x) if x.is_empty() => None, + HirKind::Concat(ref x) => { + Some(Frame::Concat { head: &x[0], tail: &x[1..] }) + } + HirKind::Alternation(ref x) if x.is_empty() => None, + HirKind::Alternation(ref x) => { + Some(Frame::Alternation { head: &x[0], tail: &x[1..] }) + } + _ => None, + } + } + + /// Pops the given frame. If the frame has an additional inductive step, + /// then return it, otherwise return `None`. + fn pop(&self, induct: Frame<'a>) -> Option<Frame<'a>> { + match induct { + Frame::Repetition(_) => None, + Frame::Group(_) => None, + Frame::Concat { tail, .. } => { + if tail.is_empty() { + None + } else { + Some(Frame::Concat { head: &tail[0], tail: &tail[1..] }) + } + } + Frame::Alternation { tail, .. } => { + if tail.is_empty() { + None + } else { + Some(Frame::Alternation { + head: &tail[0], + tail: &tail[1..], + }) + } + } + } + } +} + +impl<'a> Frame<'a> { + /// Perform the next inductive step on this frame and return the next + /// child HIR node to visit. + fn child(&self) -> &'a Hir { + match *self { + Frame::Repetition(rep) => &rep.hir, + Frame::Group(group) => &group.hir, + Frame::Concat { head, .. } => head, + Frame::Alternation { head, .. } => head, + } + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/lib.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/lib.rs new file mode 100644 index 0000000..e9f59d8 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/lib.rs @@ -0,0 +1,310 @@ +/*! +This crate provides a robust regular expression parser. + +This crate defines two primary types: + +* [`Ast`](ast/enum.Ast.html) is the abstract syntax of a regular expression. + An abstract syntax corresponds to a *structured representation* of the + concrete syntax of a regular expression, where the concrete syntax is the + pattern string itself (e.g., `foo(bar)+`). Given some abstract syntax, it + can be converted back to the original concrete syntax (modulo some details, + like whitespace). To a first approximation, the abstract syntax is complex + and difficult to analyze. +* [`Hir`](hir/struct.Hir.html) is the high-level intermediate representation + ("HIR" or "high-level IR" for short) of regular expression. It corresponds to + an intermediate state of a regular expression that sits between the abstract + syntax and the low level compiled opcodes that are eventually responsible for + executing a regular expression search. Given some high-level IR, it is not + possible to produce the original concrete syntax (although it is possible to + produce an equivalent concrete syntax, but it will likely scarcely resemble + the original pattern). To a first approximation, the high-level IR is simple + and easy to analyze. + +These two types come with conversion routines: + +* An [`ast::parse::Parser`](ast/parse/struct.Parser.html) converts concrete + syntax (a `&str`) to an [`Ast`](ast/enum.Ast.html). +* A [`hir::translate::Translator`](hir/translate/struct.Translator.html) + converts an [`Ast`](ast/enum.Ast.html) to a [`Hir`](hir/struct.Hir.html). + +As a convenience, the above two conversion routines are combined into one via +the top-level [`Parser`](struct.Parser.html) type. This `Parser` will first +convert your pattern to an `Ast` and then convert the `Ast` to an `Hir`. + + +# Example + +This example shows how to parse a pattern string into its HIR: + +``` +use regex_syntax::Parser; +use regex_syntax::hir::{self, Hir}; + +let hir = Parser::new().parse("a|b").unwrap(); +assert_eq!(hir, Hir::alternation(vec![ + Hir::literal(hir::Literal::Unicode('a')), + Hir::literal(hir::Literal::Unicode('b')), +])); +``` + + +# Concrete syntax supported + +The concrete syntax is documented as part of the public API of the +[`regex` crate](https://docs.rs/regex/%2A/regex/#syntax). + + +# Input safety + +A key feature of this library is that it is safe to use with end user facing +input. This plays a significant role in the internal implementation. In +particular: + +1. Parsers provide a `nest_limit` option that permits callers to control how + deeply nested a regular expression is allowed to be. This makes it possible + to do case analysis over an `Ast` or an `Hir` using recursion without + worrying about stack overflow. +2. Since relying on a particular stack size is brittle, this crate goes to + great lengths to ensure that all interactions with both the `Ast` and the + `Hir` do not use recursion. Namely, they use constant stack space and heap + space proportional to the size of the original pattern string (in bytes). + This includes the type's corresponding destructors. (One exception to this + is literal extraction, but this will eventually get fixed.) + + +# Error reporting + +The `Display` implementations on all `Error` types exposed in this library +provide nice human readable errors that are suitable for showing to end users +in a monospace font. + + +# Literal extraction + +This crate provides limited support for +[literal extraction from `Hir` values](hir/literal/struct.Literals.html). +Be warned that literal extraction currently uses recursion, and therefore, +stack size proportional to the size of the `Hir`. + +The purpose of literal extraction is to speed up searches. That is, if you +know a regular expression must match a prefix or suffix literal, then it is +often quicker to search for instances of that literal, and then confirm or deny +the match using the full regular expression engine. These optimizations are +done automatically in the `regex` crate. + + +# Crate features + +An important feature provided by this crate is its Unicode support. This +includes things like case folding, boolean properties, general categories, +scripts and Unicode-aware support for the Perl classes `\w`, `\s` and `\d`. +However, a downside of this support is that it requires bundling several +Unicode data tables that are substantial in size. + +A fair number of use cases do not require full Unicode support. For this +reason, this crate exposes a number of features to control which Unicode +data is available. + +If a regular expression attempts to use a Unicode feature that is not available +because the corresponding crate feature was disabled, then translating that +regular expression to an `Hir` will return an error. (It is still possible +construct an `Ast` for such a regular expression, since Unicode data is not +used until translation to an `Hir`.) Stated differently, enabling or disabling +any of the features below can only add or subtract from the total set of valid +regular expressions. Enabling or disabling a feature will never modify the +match semantics of a regular expression. + +The following features are available: + +* **unicode** - + Enables all Unicode features. This feature is enabled by default, and will + always cover all Unicode features, even if more are added in the future. +* **unicode-age** - + Provide the data for the + [Unicode `Age` property](https://www.unicode.org/reports/tr44/tr44-24.html#Character_Age). + This makes it possible to use classes like `\p{Age:6.0}` to refer to all + codepoints first introduced in Unicode 6.0 +* **unicode-bool** - + Provide the data for numerous Unicode boolean properties. The full list + is not included here, but contains properties like `Alphabetic`, `Emoji`, + `Lowercase`, `Math`, `Uppercase` and `White_Space`. +* **unicode-case** - + Provide the data for case insensitive matching using + [Unicode's "simple loose matches" specification](https://www.unicode.org/reports/tr18/#Simple_Loose_Matches). +* **unicode-gencat** - + Provide the data for + [Uncode general categories](https://www.unicode.org/reports/tr44/tr44-24.html#General_Category_Values). + This includes, but is not limited to, `Decimal_Number`, `Letter`, + `Math_Symbol`, `Number` and `Punctuation`. +* **unicode-perl** - + Provide the data for supporting the Unicode-aware Perl character classes, + corresponding to `\w`, `\s` and `\d`. This is also necessary for using + Unicode-aware word boundary assertions. Note that if this feature is + disabled, the `\s` and `\d` character classes are still available if the + `unicode-bool` and `unicode-gencat` features are enabled, respectively. +* **unicode-script** - + Provide the data for + [Unicode scripts and script extensions](https://www.unicode.org/reports/tr24/). + This includes, but is not limited to, `Arabic`, `Cyrillic`, `Hebrew`, + `Latin` and `Thai`. +* **unicode-segment** - + Provide the data necessary to provide the properties used to implement the + [Unicode text segmentation algorithms](https://www.unicode.org/reports/tr29/). + This enables using classes like `\p{gcb=Extend}`, `\p{wb=Katakana}` and + `\p{sb=ATerm}`. +*/ + +#![deny(missing_docs)] +#![forbid(unsafe_code)] + +pub use error::{Error, Result}; +pub use parser::{Parser, ParserBuilder}; +pub use unicode::UnicodeWordError; + +pub mod ast; +mod either; +mod error; +pub mod hir; +mod parser; +mod unicode; +mod unicode_tables; +pub mod utf8; + +/// Escapes all regular expression meta characters in `text`. +/// +/// The string returned may be safely used as a literal in a regular +/// expression. +pub fn escape(text: &str) -> String { + let mut quoted = String::with_capacity(text.len()); + escape_into(text, &mut quoted); + quoted +} + +/// Escapes all meta characters in `text` and writes the result into `buf`. +/// +/// This will append escape characters into the given buffer. The characters +/// that are appended are safe to use as a literal in a regular expression. +pub fn escape_into(text: &str, buf: &mut String) { + for c in text.chars() { + if is_meta_character(c) { + buf.push('\\'); + } + buf.push(c); + } +} + +/// Returns true if the give character has significance in a regex. +/// +/// These are the only characters that are allowed to be escaped, with one +/// exception: an ASCII space character may be escaped when extended mode (with +/// the `x` flag) is enabld. In particular, `is_meta_character(' ')` returns +/// `false`. +/// +/// Note that the set of characters for which this function returns `true` or +/// `false` is fixed and won't change in a semver compatible release. +pub fn is_meta_character(c: char) -> bool { + match c { + '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | '{' + | '}' | '^' | '$' | '#' | '&' | '-' | '~' => true, + _ => false, + } +} + +/// Returns true if and only if the given character is a Unicode word +/// character. +/// +/// A Unicode word character is defined by +/// [UTS#18 Annex C](http://unicode.org/reports/tr18/#Compatibility_Properties). +/// In particular, a character +/// is considered a word character if it is in either of the `Alphabetic` or +/// `Join_Control` properties, or is in one of the `Decimal_Number`, `Mark` +/// or `Connector_Punctuation` general categories. +/// +/// # Panics +/// +/// If the `unicode-perl` feature is not enabled, then this function panics. +/// For this reason, it is recommended that callers use +/// [`try_is_word_character`](fn.try_is_word_character.html) +/// instead. +pub fn is_word_character(c: char) -> bool { + try_is_word_character(c).expect("unicode-perl feature must be enabled") +} + +/// Returns true if and only if the given character is a Unicode word +/// character. +/// +/// A Unicode word character is defined by +/// [UTS#18 Annex C](http://unicode.org/reports/tr18/#Compatibility_Properties). +/// In particular, a character +/// is considered a word character if it is in either of the `Alphabetic` or +/// `Join_Control` properties, or is in one of the `Decimal_Number`, `Mark` +/// or `Connector_Punctuation` general categories. +/// +/// # Errors +/// +/// If the `unicode-perl` feature is not enabled, then this function always +/// returns an error. +pub fn try_is_word_character( + c: char, +) -> std::result::Result<bool, UnicodeWordError> { + unicode::is_word_character(c) +} + +/// Returns true if and only if the given character is an ASCII word character. +/// +/// An ASCII word character is defined by the following character class: +/// `[_0-9a-zA-Z]'. +pub fn is_word_byte(c: u8) -> bool { + match c { + b'_' | b'0'..=b'9' | b'a'..=b'z' | b'A'..=b'Z' => true, + _ => false, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn escape_meta() { + assert_eq!( + escape(r"\.+*?()|[]{}^$#&-~"), + r"\\\.\+\*\?\(\)\|\[\]\{\}\^\$\#\&\-\~".to_string() + ); + } + + #[test] + fn word_byte() { + assert!(is_word_byte(b'a')); + assert!(!is_word_byte(b'-')); + } + + #[test] + #[cfg(feature = "unicode-perl")] + fn word_char() { + assert!(is_word_character('a'), "ASCII"); + assert!(is_word_character('à'), "Latin-1"); + assert!(is_word_character('β'), "Greek"); + assert!(is_word_character('\u{11011}'), "Brahmi (Unicode 6.0)"); + assert!(is_word_character('\u{11611}'), "Modi (Unicode 7.0)"); + assert!(is_word_character('\u{11711}'), "Ahom (Unicode 8.0)"); + assert!(is_word_character('\u{17828}'), "Tangut (Unicode 9.0)"); + assert!(is_word_character('\u{1B1B1}'), "Nushu (Unicode 10.0)"); + assert!(is_word_character('\u{16E40}'), "Medefaidrin (Unicode 11.0)"); + assert!(!is_word_character('-')); + assert!(!is_word_character('☃')); + } + + #[test] + #[should_panic] + #[cfg(not(feature = "unicode-perl"))] + fn word_char_disabled_panic() { + assert!(is_word_character('a')); + } + + #[test] + #[cfg(not(feature = "unicode-perl"))] + fn word_char_disabled_error() { + assert!(try_is_word_character('a').is_err()); + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/parser.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/parser.rs new file mode 100644 index 0000000..00f1391 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/parser.rs @@ -0,0 +1,200 @@ +use ast; +use hir; + +use Result; + +/// A builder for a regular expression parser. +/// +/// This builder permits modifying configuration options for the parser. +/// +/// This type combines the builder options for both the +/// [AST `ParserBuilder`](ast/parse/struct.ParserBuilder.html) +/// and the +/// [HIR `TranslatorBuilder`](hir/translate/struct.TranslatorBuilder.html). +#[derive(Clone, Debug, Default)] +pub struct ParserBuilder { + ast: ast::parse::ParserBuilder, + hir: hir::translate::TranslatorBuilder, +} + +impl ParserBuilder { + /// Create a new parser builder with a default configuration. + pub fn new() -> ParserBuilder { + ParserBuilder::default() + } + + /// Build a parser from this configuration with the given pattern. + pub fn build(&self) -> Parser { + Parser { ast: self.ast.build(), hir: self.hir.build() } + } + + /// Set the nesting limit for this parser. + /// + /// The nesting limit controls how deep the abstract syntax tree is allowed + /// to be. If the AST exceeds the given limit (e.g., with too many nested + /// groups), then an error is returned by the parser. + /// + /// The purpose of this limit is to act as a heuristic to prevent stack + /// overflow for consumers that do structural induction on an `Ast` using + /// explicit recursion. While this crate never does this (instead using + /// constant stack space and moving the call stack to the heap), other + /// crates may. + /// + /// This limit is not checked until the entire Ast is parsed. Therefore, + /// if callers want to put a limit on the amount of heap space used, then + /// they should impose a limit on the length, in bytes, of the concrete + /// pattern string. In particular, this is viable since this parser + /// implementation will limit itself to heap space proportional to the + /// lenth of the pattern string. + /// + /// Note that a nest limit of `0` will return a nest limit error for most + /// patterns but not all. For example, a nest limit of `0` permits `a` but + /// not `ab`, since `ab` requires a concatenation, which results in a nest + /// depth of `1`. In general, a nest limit is not something that manifests + /// in an obvious way in the concrete syntax, therefore, it should not be + /// used in a granular way. + pub fn nest_limit(&mut self, limit: u32) -> &mut ParserBuilder { + self.ast.nest_limit(limit); + self + } + + /// Whether to support octal syntax or not. + /// + /// Octal syntax is a little-known way of uttering Unicode codepoints in + /// a regular expression. For example, `a`, `\x61`, `\u0061` and + /// `\141` are all equivalent regular expressions, where the last example + /// shows octal syntax. + /// + /// While supporting octal syntax isn't in and of itself a problem, it does + /// make good error messages harder. That is, in PCRE based regex engines, + /// syntax like `\0` invokes a backreference, which is explicitly + /// unsupported in Rust's regex engine. However, many users expect it to + /// be supported. Therefore, when octal support is disabled, the error + /// message will explicitly mention that backreferences aren't supported. + /// + /// Octal syntax is disabled by default. + pub fn octal(&mut self, yes: bool) -> &mut ParserBuilder { + self.ast.octal(yes); + self + } + + /// When enabled, the parser will permit the construction of a regular + /// expression that may match invalid UTF-8. + /// + /// When disabled (the default), the parser is guaranteed to produce + /// an expression that will only ever match valid UTF-8 (otherwise, the + /// parser will return an error). + /// + /// Perhaps surprisingly, when invalid UTF-8 isn't allowed, a negated ASCII + /// word boundary (uttered as `(?-u:\B)` in the concrete syntax) will cause + /// the parser to return an error. Namely, a negated ASCII word boundary + /// can result in matching positions that aren't valid UTF-8 boundaries. + pub fn allow_invalid_utf8(&mut self, yes: bool) -> &mut ParserBuilder { + self.hir.allow_invalid_utf8(yes); + self + } + + /// Enable verbose mode in the regular expression. + /// + /// When enabled, verbose mode permits insigificant whitespace in many + /// places in the regular expression, as well as comments. Comments are + /// started using `#` and continue until the end of the line. + /// + /// By default, this is disabled. It may be selectively enabled in the + /// regular expression by using the `x` flag regardless of this setting. + pub fn ignore_whitespace(&mut self, yes: bool) -> &mut ParserBuilder { + self.ast.ignore_whitespace(yes); + self + } + + /// Enable or disable the case insensitive flag by default. + /// + /// By default this is disabled. It may alternatively be selectively + /// enabled in the regular expression itself via the `i` flag. + pub fn case_insensitive(&mut self, yes: bool) -> &mut ParserBuilder { + self.hir.case_insensitive(yes); + self + } + + /// Enable or disable the multi-line matching flag by default. + /// + /// By default this is disabled. It may alternatively be selectively + /// enabled in the regular expression itself via the `m` flag. + pub fn multi_line(&mut self, yes: bool) -> &mut ParserBuilder { + self.hir.multi_line(yes); + self + } + + /// Enable or disable the "dot matches any character" flag by default. + /// + /// By default this is disabled. It may alternatively be selectively + /// enabled in the regular expression itself via the `s` flag. + pub fn dot_matches_new_line(&mut self, yes: bool) -> &mut ParserBuilder { + self.hir.dot_matches_new_line(yes); + self + } + + /// Enable or disable the "swap greed" flag by default. + /// + /// By default this is disabled. It may alternatively be selectively + /// enabled in the regular expression itself via the `U` flag. + pub fn swap_greed(&mut self, yes: bool) -> &mut ParserBuilder { + self.hir.swap_greed(yes); + self + } + + /// Enable or disable the Unicode flag (`u`) by default. + /// + /// By default this is **enabled**. It may alternatively be selectively + /// disabled in the regular expression itself via the `u` flag. + /// + /// Note that unless `allow_invalid_utf8` is enabled (it's disabled by + /// default), a regular expression will fail to parse if Unicode mode is + /// disabled and a sub-expression could possibly match invalid UTF-8. + pub fn unicode(&mut self, yes: bool) -> &mut ParserBuilder { + self.hir.unicode(yes); + self + } +} + +/// A convenience parser for regular expressions. +/// +/// This parser takes as input a regular expression pattern string (the +/// "concrete syntax") and returns a high-level intermediate representation +/// (the HIR) suitable for most types of analysis. In particular, this parser +/// hides the intermediate state of producing an AST (the "abstract syntax"). +/// The AST is itself far more complex than the HIR, so this parser serves as a +/// convenience for never having to deal with it at all. +/// +/// If callers have more fine grained use cases that need an AST, then please +/// see the [`ast::parse`](ast/parse/index.html) module. +/// +/// A `Parser` can be configured in more detail via a +/// [`ParserBuilder`](struct.ParserBuilder.html). +#[derive(Clone, Debug)] +pub struct Parser { + ast: ast::parse::Parser, + hir: hir::translate::Translator, +} + +impl Parser { + /// Create a new parser with a default configuration. + /// + /// The parser can be run with `parse` method. The parse method returns + /// a high level intermediate representation of the given regular + /// expression. + /// + /// To set configuration options on the parser, use + /// [`ParserBuilder`](struct.ParserBuilder.html). + pub fn new() -> Parser { + ParserBuilder::new().build() + } + + /// Parse the regular expression into a high level intermediate + /// representation. + pub fn parse(&mut self, pattern: &str) -> Result<hir::Hir> { + let ast = self.ast.parse(pattern)?; + let hir = self.hir.translate(pattern, &ast)?; + Ok(hir) + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode.rs new file mode 100644 index 0000000..506529d --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode.rs @@ -0,0 +1,990 @@ +use std::error; +use std::fmt; +use std::result; + +use hir; + +/// A type alias for errors specific to Unicode handling of classes. +pub type Result<T> = result::Result<T, Error>; + +/// An inclusive range of codepoints from a generated file (hence the static +/// lifetime). +type Range = &'static [(char, char)]; + +/// An error that occurs when dealing with Unicode. +/// +/// We don't impl the Error trait here because these always get converted +/// into other public errors. (This error type isn't exported.) +#[derive(Debug)] +pub enum Error { + PropertyNotFound, + PropertyValueNotFound, + // Not used when unicode-perl is enabled. + #[allow(dead_code)] + PerlClassNotFound, +} + +/// A type alias for errors specific to Unicode case folding. +pub type FoldResult<T> = result::Result<T, CaseFoldError>; + +/// An error that occurs when Unicode-aware simple case folding fails. +/// +/// This error can occur when the case mapping tables necessary for Unicode +/// aware case folding are unavailable. This only occurs when the +/// `unicode-case` feature is disabled. (The feature is enabled by default.) +#[derive(Debug)] +pub struct CaseFoldError(()); + +impl error::Error for CaseFoldError {} + +impl fmt::Display for CaseFoldError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "Unicode-aware case folding is not available \ + (probably because the unicode-case feature is not enabled)" + ) + } +} + +/// An error that occurs when the Unicode-aware `\w` class is unavailable. +/// +/// This error can occur when the data tables necessary for the Unicode aware +/// Perl character class `\w` are unavailable. This only occurs when the +/// `unicode-perl` feature is disabled. (The feature is enabled by default.) +#[derive(Debug)] +pub struct UnicodeWordError(()); + +impl error::Error for UnicodeWordError {} + +impl fmt::Display for UnicodeWordError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "Unicode-aware \\w class is not available \ + (probably because the unicode-perl feature is not enabled)" + ) + } +} + +/// Return an iterator over the equivalence class of simple case mappings +/// for the given codepoint. The equivalence class does not include the +/// given codepoint. +/// +/// If the equivalence class is empty, then this returns the next scalar +/// value that has a non-empty equivalence class, if it exists. If no such +/// scalar value exists, then `None` is returned. The point of this behavior +/// is to permit callers to avoid calling `simple_fold` more than they need +/// to, since there is some cost to fetching the equivalence class. +/// +/// This returns an error if the Unicode case folding tables are not available. +pub fn simple_fold( + c: char, +) -> FoldResult<result::Result<impl Iterator<Item = char>, Option<char>>> { + #[cfg(not(feature = "unicode-case"))] + fn imp( + _: char, + ) -> FoldResult<result::Result<impl Iterator<Item = char>, Option<char>>> + { + use std::option::IntoIter; + Err::<result::Result<IntoIter<char>, _>, _>(CaseFoldError(())) + } + + #[cfg(feature = "unicode-case")] + fn imp( + c: char, + ) -> FoldResult<result::Result<impl Iterator<Item = char>, Option<char>>> + { + use unicode_tables::case_folding_simple::CASE_FOLDING_SIMPLE; + + Ok(CASE_FOLDING_SIMPLE + .binary_search_by_key(&c, |&(c1, _)| c1) + .map(|i| CASE_FOLDING_SIMPLE[i].1.iter().map(|&c| c)) + .map_err(|i| { + if i >= CASE_FOLDING_SIMPLE.len() { + None + } else { + Some(CASE_FOLDING_SIMPLE[i].0) + } + })) + } + + imp(c) +} + +/// Returns true if and only if the given (inclusive) range contains at least +/// one Unicode scalar value that has a non-empty non-trivial simple case +/// mapping. +/// +/// This function panics if `end < start`. +/// +/// This returns an error if the Unicode case folding tables are not available. +pub fn contains_simple_case_mapping( + start: char, + end: char, +) -> FoldResult<bool> { + #[cfg(not(feature = "unicode-case"))] + fn imp(_: char, _: char) -> FoldResult<bool> { + Err(CaseFoldError(())) + } + + #[cfg(feature = "unicode-case")] + fn imp(start: char, end: char) -> FoldResult<bool> { + use std::cmp::Ordering; + use unicode_tables::case_folding_simple::CASE_FOLDING_SIMPLE; + + assert!(start <= end); + Ok(CASE_FOLDING_SIMPLE + .binary_search_by(|&(c, _)| { + if start <= c && c <= end { + Ordering::Equal + } else if c > end { + Ordering::Greater + } else { + Ordering::Less + } + }) + .is_ok()) + } + + imp(start, end) +} + +/// A query for finding a character class defined by Unicode. This supports +/// either use of a property name directly, or lookup by property value. The +/// former generally refers to Binary properties (see UTS#44, Table 8), but +/// as a special exception (see UTS#18, Section 1.2) both general categories +/// (an enumeration) and scripts (a catalog) are supported as if each of their +/// possible values were a binary property. +/// +/// In all circumstances, property names and values are normalized and +/// canonicalized. That is, `GC == gc == GeneralCategory == general_category`. +/// +/// The lifetime `'a` refers to the shorter of the lifetimes of property name +/// and property value. +#[derive(Debug)] +pub enum ClassQuery<'a> { + /// Return a class corresponding to a Unicode binary property, named by + /// a single letter. + OneLetter(char), + /// Return a class corresponding to a Unicode binary property. + /// + /// Note that, by special exception (see UTS#18, Section 1.2), both + /// general category values and script values are permitted here as if + /// they were a binary property. + Binary(&'a str), + /// Return a class corresponding to all codepoints whose property + /// (identified by `property_name`) corresponds to the given value + /// (identified by `property_value`). + ByValue { + /// A property name. + property_name: &'a str, + /// A property value. + property_value: &'a str, + }, +} + +impl<'a> ClassQuery<'a> { + fn canonicalize(&self) -> Result<CanonicalClassQuery> { + match *self { + ClassQuery::OneLetter(c) => self.canonical_binary(&c.to_string()), + ClassQuery::Binary(name) => self.canonical_binary(name), + ClassQuery::ByValue { property_name, property_value } => { + let property_name = symbolic_name_normalize(property_name); + let property_value = symbolic_name_normalize(property_value); + + let canon_name = match canonical_prop(&property_name)? { + None => return Err(Error::PropertyNotFound), + Some(canon_name) => canon_name, + }; + Ok(match canon_name { + "General_Category" => { + let canon = match canonical_gencat(&property_value)? { + None => return Err(Error::PropertyValueNotFound), + Some(canon) => canon, + }; + CanonicalClassQuery::GeneralCategory(canon) + } + "Script" => { + let canon = match canonical_script(&property_value)? { + None => return Err(Error::PropertyValueNotFound), + Some(canon) => canon, + }; + CanonicalClassQuery::Script(canon) + } + _ => { + let vals = match property_values(canon_name)? { + None => return Err(Error::PropertyValueNotFound), + Some(vals) => vals, + }; + let canon_val = + match canonical_value(vals, &property_value) { + None => { + return Err(Error::PropertyValueNotFound) + } + Some(canon_val) => canon_val, + }; + CanonicalClassQuery::ByValue { + property_name: canon_name, + property_value: canon_val, + } + } + }) + } + } + } + + fn canonical_binary(&self, name: &str) -> Result<CanonicalClassQuery> { + let norm = symbolic_name_normalize(name); + + if let Some(canon) = canonical_prop(&norm)? { + return Ok(CanonicalClassQuery::Binary(canon)); + } + if let Some(canon) = canonical_gencat(&norm)? { + return Ok(CanonicalClassQuery::GeneralCategory(canon)); + } + if let Some(canon) = canonical_script(&norm)? { + return Ok(CanonicalClassQuery::Script(canon)); + } + Err(Error::PropertyNotFound) + } +} + +/// Like ClassQuery, but its parameters have been canonicalized. This also +/// differentiates binary properties from flattened general categories and +/// scripts. +#[derive(Debug, Eq, PartialEq)] +enum CanonicalClassQuery { + /// The canonical binary property name. + Binary(&'static str), + /// The canonical general category name. + GeneralCategory(&'static str), + /// The canonical script name. + Script(&'static str), + /// An arbitrary association between property and value, both of which + /// have been canonicalized. + /// + /// Note that by construction, the property name of ByValue will never + /// be General_Category or Script. Those two cases are subsumed by the + /// eponymous variants. + ByValue { + /// The canonical property name. + property_name: &'static str, + /// The canonical property value. + property_value: &'static str, + }, +} + +/// Looks up a Unicode class given a query. If one doesn't exist, then +/// `None` is returned. +pub fn class(query: ClassQuery) -> Result<hir::ClassUnicode> { + use self::CanonicalClassQuery::*; + + match query.canonicalize()? { + Binary(name) => bool_property(name), + GeneralCategory(name) => gencat(name), + Script(name) => script(name), + ByValue { property_name: "Age", property_value } => { + let mut class = hir::ClassUnicode::empty(); + for set in ages(property_value)? { + class.union(&hir_class(set)); + } + Ok(class) + } + ByValue { property_name: "Script_Extensions", property_value } => { + script_extension(property_value) + } + ByValue { + property_name: "Grapheme_Cluster_Break", + property_value, + } => gcb(property_value), + ByValue { property_name: "Sentence_Break", property_value } => { + sb(property_value) + } + ByValue { property_name: "Word_Break", property_value } => { + wb(property_value) + } + _ => { + // What else should we support? + Err(Error::PropertyNotFound) + } + } +} + +/// Returns a Unicode aware class for \w. +/// +/// This returns an error if the data is not available for \w. +pub fn perl_word() -> Result<hir::ClassUnicode> { + #[cfg(not(feature = "unicode-perl"))] + fn imp() -> Result<hir::ClassUnicode> { + Err(Error::PerlClassNotFound) + } + + #[cfg(feature = "unicode-perl")] + fn imp() -> Result<hir::ClassUnicode> { + use unicode_tables::perl_word::PERL_WORD; + Ok(hir_class(PERL_WORD)) + } + + imp() +} + +/// Returns a Unicode aware class for \s. +/// +/// This returns an error if the data is not available for \s. +pub fn perl_space() -> Result<hir::ClassUnicode> { + #[cfg(not(any(feature = "unicode-perl", feature = "unicode-bool")))] + fn imp() -> Result<hir::ClassUnicode> { + Err(Error::PerlClassNotFound) + } + + #[cfg(all(feature = "unicode-perl", not(feature = "unicode-bool")))] + fn imp() -> Result<hir::ClassUnicode> { + use unicode_tables::perl_space::WHITE_SPACE; + Ok(hir_class(WHITE_SPACE)) + } + + #[cfg(feature = "unicode-bool")] + fn imp() -> Result<hir::ClassUnicode> { + use unicode_tables::property_bool::WHITE_SPACE; + Ok(hir_class(WHITE_SPACE)) + } + + imp() +} + +/// Returns a Unicode aware class for \d. +/// +/// This returns an error if the data is not available for \d. +pub fn perl_digit() -> Result<hir::ClassUnicode> { + #[cfg(not(any(feature = "unicode-perl", feature = "unicode-gencat")))] + fn imp() -> Result<hir::ClassUnicode> { + Err(Error::PerlClassNotFound) + } + + #[cfg(all(feature = "unicode-perl", not(feature = "unicode-gencat")))] + fn imp() -> Result<hir::ClassUnicode> { + use unicode_tables::perl_decimal::DECIMAL_NUMBER; + Ok(hir_class(DECIMAL_NUMBER)) + } + + #[cfg(feature = "unicode-gencat")] + fn imp() -> Result<hir::ClassUnicode> { + use unicode_tables::general_category::DECIMAL_NUMBER; + Ok(hir_class(DECIMAL_NUMBER)) + } + + imp() +} + +/// Build a Unicode HIR class from a sequence of Unicode scalar value ranges. +pub fn hir_class(ranges: &[(char, char)]) -> hir::ClassUnicode { + let hir_ranges: Vec<hir::ClassUnicodeRange> = ranges + .iter() + .map(|&(s, e)| hir::ClassUnicodeRange::new(s, e)) + .collect(); + hir::ClassUnicode::new(hir_ranges) +} + +/// Returns true only if the given codepoint is in the `\w` character class. +/// +/// If the `unicode-perl` feature is not enabled, then this returns an error. +pub fn is_word_character(c: char) -> result::Result<bool, UnicodeWordError> { + #[cfg(not(feature = "unicode-perl"))] + fn imp(_: char) -> result::Result<bool, UnicodeWordError> { + Err(UnicodeWordError(())) + } + + #[cfg(feature = "unicode-perl")] + fn imp(c: char) -> result::Result<bool, UnicodeWordError> { + use is_word_byte; + use std::cmp::Ordering; + use unicode_tables::perl_word::PERL_WORD; + + if c <= 0x7F as char && is_word_byte(c as u8) { + return Ok(true); + } + Ok(PERL_WORD + .binary_search_by(|&(start, end)| { + if start <= c && c <= end { + Ordering::Equal + } else if start > c { + Ordering::Greater + } else { + Ordering::Less + } + }) + .is_ok()) + } + + imp(c) +} + +/// A mapping of property values for a specific property. +/// +/// The first element of each tuple is a normalized property value while the +/// second element of each tuple is the corresponding canonical property +/// value. +type PropertyValues = &'static [(&'static str, &'static str)]; + +fn canonical_gencat(normalized_value: &str) -> Result<Option<&'static str>> { + Ok(match normalized_value { + "any" => Some("Any"), + "assigned" => Some("Assigned"), + "ascii" => Some("ASCII"), + _ => { + let gencats = property_values("General_Category")?.unwrap(); + canonical_value(gencats, normalized_value) + } + }) +} + +fn canonical_script(normalized_value: &str) -> Result<Option<&'static str>> { + let scripts = property_values("Script")?.unwrap(); + Ok(canonical_value(scripts, normalized_value)) +} + +/// Find the canonical property name for the given normalized property name. +/// +/// If no such property exists, then `None` is returned. +/// +/// The normalized property name must have been normalized according to +/// UAX44 LM3, which can be done using `symbolic_name_normalize`. +/// +/// If the property names data is not available, then an error is returned. +fn canonical_prop(normalized_name: &str) -> Result<Option<&'static str>> { + #[cfg(not(any( + feature = "unicode-age", + feature = "unicode-bool", + feature = "unicode-gencat", + feature = "unicode-perl", + feature = "unicode-script", + feature = "unicode-segment", + )))] + fn imp(_: &str) -> Result<Option<&'static str>> { + Err(Error::PropertyNotFound) + } + + #[cfg(any( + feature = "unicode-age", + feature = "unicode-bool", + feature = "unicode-gencat", + feature = "unicode-perl", + feature = "unicode-script", + feature = "unicode-segment", + ))] + fn imp(name: &str) -> Result<Option<&'static str>> { + use unicode_tables::property_names::PROPERTY_NAMES; + + Ok(PROPERTY_NAMES + .binary_search_by_key(&name, |&(n, _)| n) + .ok() + .map(|i| PROPERTY_NAMES[i].1)) + } + + imp(normalized_name) +} + +/// Find the canonical property value for the given normalized property +/// value. +/// +/// The given property values should correspond to the values for the property +/// under question, which can be found using `property_values`. +/// +/// If no such property value exists, then `None` is returned. +/// +/// The normalized property value must have been normalized according to +/// UAX44 LM3, which can be done using `symbolic_name_normalize`. +fn canonical_value( + vals: PropertyValues, + normalized_value: &str, +) -> Option<&'static str> { + vals.binary_search_by_key(&normalized_value, |&(n, _)| n) + .ok() + .map(|i| vals[i].1) +} + +/// Return the table of property values for the given property name. +/// +/// If the property values data is not available, then an error is returned. +fn property_values( + canonical_property_name: &'static str, +) -> Result<Option<PropertyValues>> { + #[cfg(not(any( + feature = "unicode-age", + feature = "unicode-bool", + feature = "unicode-gencat", + feature = "unicode-perl", + feature = "unicode-script", + feature = "unicode-segment", + )))] + fn imp(_: &'static str) -> Result<Option<PropertyValues>> { + Err(Error::PropertyValueNotFound) + } + + #[cfg(any( + feature = "unicode-age", + feature = "unicode-bool", + feature = "unicode-gencat", + feature = "unicode-perl", + feature = "unicode-script", + feature = "unicode-segment", + ))] + fn imp(name: &'static str) -> Result<Option<PropertyValues>> { + use unicode_tables::property_values::PROPERTY_VALUES; + + Ok(PROPERTY_VALUES + .binary_search_by_key(&name, |&(n, _)| n) + .ok() + .map(|i| PROPERTY_VALUES[i].1)) + } + + imp(canonical_property_name) +} + +// This is only used in some cases, but small enough to just let it be dead +// instead of figuring out (and maintaining) the right set of features. +#[allow(dead_code)] +fn property_set( + name_map: &'static [(&'static str, Range)], + canonical: &'static str, +) -> Option<Range> { + name_map + .binary_search_by_key(&canonical, |x| x.0) + .ok() + .map(|i| name_map[i].1) +} + +/// Returns an iterator over Unicode Age sets. Each item corresponds to a set +/// of codepoints that were added in a particular revision of Unicode. The +/// iterator yields items in chronological order. +/// +/// If the given age value isn't valid or if the data isn't available, then an +/// error is returned instead. +fn ages(canonical_age: &str) -> Result<impl Iterator<Item = Range>> { + #[cfg(not(feature = "unicode-age"))] + fn imp(_: &str) -> Result<impl Iterator<Item = Range>> { + use std::option::IntoIter; + Err::<IntoIter<Range>, _>(Error::PropertyNotFound) + } + + #[cfg(feature = "unicode-age")] + fn imp(canonical_age: &str) -> Result<impl Iterator<Item = Range>> { + use unicode_tables::age; + + const AGES: &'static [(&'static str, Range)] = &[ + ("V1_1", age::V1_1), + ("V2_0", age::V2_0), + ("V2_1", age::V2_1), + ("V3_0", age::V3_0), + ("V3_1", age::V3_1), + ("V3_2", age::V3_2), + ("V4_0", age::V4_0), + ("V4_1", age::V4_1), + ("V5_0", age::V5_0), + ("V5_1", age::V5_1), + ("V5_2", age::V5_2), + ("V6_0", age::V6_0), + ("V6_1", age::V6_1), + ("V6_2", age::V6_2), + ("V6_3", age::V6_3), + ("V7_0", age::V7_0), + ("V8_0", age::V8_0), + ("V9_0", age::V9_0), + ("V10_0", age::V10_0), + ("V11_0", age::V11_0), + ("V12_0", age::V12_0), + ("V12_1", age::V12_1), + ]; + assert_eq!(AGES.len(), age::BY_NAME.len(), "ages are out of sync"); + + let pos = AGES.iter().position(|&(age, _)| canonical_age == age); + match pos { + None => Err(Error::PropertyValueNotFound), + Some(i) => Ok(AGES[..i + 1].iter().map(|&(_, classes)| classes)), + } + } + + imp(canonical_age) +} + +/// Returns the Unicode HIR class corresponding to the given general category. +/// +/// Name canonicalization is assumed to be performed by the caller. +/// +/// If the given general category could not be found, or if the general +/// category data is not available, then an error is returned. +fn gencat(canonical_name: &'static str) -> Result<hir::ClassUnicode> { + #[cfg(not(feature = "unicode-gencat"))] + fn imp(_: &'static str) -> Result<hir::ClassUnicode> { + Err(Error::PropertyNotFound) + } + + #[cfg(feature = "unicode-gencat")] + fn imp(name: &'static str) -> Result<hir::ClassUnicode> { + use unicode_tables::general_category::BY_NAME; + match name { + "ASCII" => Ok(hir_class(&[('\0', '\x7F')])), + "Any" => Ok(hir_class(&[('\0', '\u{10FFFF}')])), + "Assigned" => { + let mut cls = gencat("Unassigned")?; + cls.negate(); + Ok(cls) + } + name => property_set(BY_NAME, name) + .map(hir_class) + .ok_or(Error::PropertyValueNotFound), + } + } + + match canonical_name { + "Decimal_Number" => perl_digit(), + name => imp(name), + } +} + +/// Returns the Unicode HIR class corresponding to the given script. +/// +/// Name canonicalization is assumed to be performed by the caller. +/// +/// If the given script could not be found, or if the script data is not +/// available, then an error is returned. +fn script(canonical_name: &'static str) -> Result<hir::ClassUnicode> { + #[cfg(not(feature = "unicode-script"))] + fn imp(_: &'static str) -> Result<hir::ClassUnicode> { + Err(Error::PropertyNotFound) + } + + #[cfg(feature = "unicode-script")] + fn imp(name: &'static str) -> Result<hir::ClassUnicode> { + use unicode_tables::script::BY_NAME; + property_set(BY_NAME, name) + .map(hir_class) + .ok_or(Error::PropertyValueNotFound) + } + + imp(canonical_name) +} + +/// Returns the Unicode HIR class corresponding to the given script extension. +/// +/// Name canonicalization is assumed to be performed by the caller. +/// +/// If the given script extension could not be found, or if the script data is +/// not available, then an error is returned. +fn script_extension( + canonical_name: &'static str, +) -> Result<hir::ClassUnicode> { + #[cfg(not(feature = "unicode-script"))] + fn imp(_: &'static str) -> Result<hir::ClassUnicode> { + Err(Error::PropertyNotFound) + } + + #[cfg(feature = "unicode-script")] + fn imp(name: &'static str) -> Result<hir::ClassUnicode> { + use unicode_tables::script_extension::BY_NAME; + property_set(BY_NAME, name) + .map(hir_class) + .ok_or(Error::PropertyValueNotFound) + } + + imp(canonical_name) +} + +/// Returns the Unicode HIR class corresponding to the given Unicode boolean +/// property. +/// +/// Name canonicalization is assumed to be performed by the caller. +/// +/// If the given boolean property could not be found, or if the boolean +/// property data is not available, then an error is returned. +fn bool_property(canonical_name: &'static str) -> Result<hir::ClassUnicode> { + #[cfg(not(feature = "unicode-bool"))] + fn imp(_: &'static str) -> Result<hir::ClassUnicode> { + Err(Error::PropertyNotFound) + } + + #[cfg(feature = "unicode-bool")] + fn imp(name: &'static str) -> Result<hir::ClassUnicode> { + use unicode_tables::property_bool::BY_NAME; + property_set(BY_NAME, name) + .map(hir_class) + .ok_or(Error::PropertyNotFound) + } + + match canonical_name { + "Decimal_Number" => perl_digit(), + "White_Space" => perl_space(), + name => imp(name), + } +} + +/// Returns the Unicode HIR class corresponding to the given grapheme cluster +/// break property. +/// +/// Name canonicalization is assumed to be performed by the caller. +/// +/// If the given property could not be found, or if the corresponding data is +/// not available, then an error is returned. +fn gcb(canonical_name: &'static str) -> Result<hir::ClassUnicode> { + #[cfg(not(feature = "unicode-segment"))] + fn imp(_: &'static str) -> Result<hir::ClassUnicode> { + Err(Error::PropertyNotFound) + } + + #[cfg(feature = "unicode-segment")] + fn imp(name: &'static str) -> Result<hir::ClassUnicode> { + use unicode_tables::grapheme_cluster_break::BY_NAME; + property_set(BY_NAME, name) + .map(hir_class) + .ok_or(Error::PropertyValueNotFound) + } + + imp(canonical_name) +} + +/// Returns the Unicode HIR class corresponding to the given word break +/// property. +/// +/// Name canonicalization is assumed to be performed by the caller. +/// +/// If the given property could not be found, or if the corresponding data is +/// not available, then an error is returned. +fn wb(canonical_name: &'static str) -> Result<hir::ClassUnicode> { + #[cfg(not(feature = "unicode-segment"))] + fn imp(_: &'static str) -> Result<hir::ClassUnicode> { + Err(Error::PropertyNotFound) + } + + #[cfg(feature = "unicode-segment")] + fn imp(name: &'static str) -> Result<hir::ClassUnicode> { + use unicode_tables::word_break::BY_NAME; + property_set(BY_NAME, name) + .map(hir_class) + .ok_or(Error::PropertyValueNotFound) + } + + imp(canonical_name) +} + +/// Returns the Unicode HIR class corresponding to the given sentence +/// break property. +/// +/// Name canonicalization is assumed to be performed by the caller. +/// +/// If the given property could not be found, or if the corresponding data is +/// not available, then an error is returned. +fn sb(canonical_name: &'static str) -> Result<hir::ClassUnicode> { + #[cfg(not(feature = "unicode-segment"))] + fn imp(_: &'static str) -> Result<hir::ClassUnicode> { + Err(Error::PropertyNotFound) + } + + #[cfg(feature = "unicode-segment")] + fn imp(name: &'static str) -> Result<hir::ClassUnicode> { + use unicode_tables::sentence_break::BY_NAME; + property_set(BY_NAME, name) + .map(hir_class) + .ok_or(Error::PropertyValueNotFound) + } + + imp(canonical_name) +} + +/// Like symbolic_name_normalize_bytes, but operates on a string. +fn symbolic_name_normalize(x: &str) -> String { + let mut tmp = x.as_bytes().to_vec(); + let len = symbolic_name_normalize_bytes(&mut tmp).len(); + tmp.truncate(len); + // This should always succeed because `symbolic_name_normalize_bytes` + // guarantees that `&tmp[..len]` is always valid UTF-8. + // + // N.B. We could avoid the additional UTF-8 check here, but it's unlikely + // to be worth skipping the additional safety check. A benchmark must + // justify it first. + String::from_utf8(tmp).unwrap() +} + +/// Normalize the given symbolic name in place according to UAX44-LM3. +/// +/// A "symbolic name" typically corresponds to property names and property +/// value aliases. Note, though, that it should not be applied to property +/// string values. +/// +/// The slice returned is guaranteed to be valid UTF-8 for all possible values +/// of `slice`. +/// +/// See: http://unicode.org/reports/tr44/#UAX44-LM3 +fn symbolic_name_normalize_bytes(slice: &mut [u8]) -> &mut [u8] { + // I couldn't find a place in the standard that specified that property + // names/aliases had a particular structure (unlike character names), but + // we assume that it's ASCII only and drop anything that isn't ASCII. + let mut start = 0; + let mut starts_with_is = false; + if slice.len() >= 2 { + // Ignore any "is" prefix. + starts_with_is = slice[0..2] == b"is"[..] + || slice[0..2] == b"IS"[..] + || slice[0..2] == b"iS"[..] + || slice[0..2] == b"Is"[..]; + if starts_with_is { + start = 2; + } + } + let mut next_write = 0; + for i in start..slice.len() { + // VALIDITY ARGUMENT: To guarantee that the resulting slice is valid + // UTF-8, we ensure that the slice contains only ASCII bytes. In + // particular, we drop every non-ASCII byte from the normalized string. + let b = slice[i]; + if b == b' ' || b == b'_' || b == b'-' { + continue; + } else if b'A' <= b && b <= b'Z' { + slice[next_write] = b + (b'a' - b'A'); + next_write += 1; + } else if b <= 0x7F { + slice[next_write] = b; + next_write += 1; + } + } + // Special case: ISO_Comment has a 'isc' abbreviation. Since we generally + // ignore 'is' prefixes, the 'isc' abbreviation gets caught in the cross + // fire and ends up creating an alias for 'c' to 'ISO_Comment', but it + // is actually an alias for the 'Other' general category. + if starts_with_is && next_write == 1 && slice[0] == b'c' { + slice[0] = b'i'; + slice[1] = b's'; + slice[2] = b'c'; + next_write = 3; + } + &mut slice[..next_write] +} + +#[cfg(test)] +mod tests { + use super::{ + contains_simple_case_mapping, simple_fold, symbolic_name_normalize, + symbolic_name_normalize_bytes, + }; + + #[cfg(feature = "unicode-case")] + fn simple_fold_ok(c: char) -> impl Iterator<Item = char> { + simple_fold(c).unwrap().unwrap() + } + + #[cfg(feature = "unicode-case")] + fn simple_fold_err(c: char) -> Option<char> { + match simple_fold(c).unwrap() { + Ok(_) => unreachable!("simple_fold returned Ok iterator"), + Err(next) => next, + } + } + + #[cfg(feature = "unicode-case")] + fn contains_case_map(start: char, end: char) -> bool { + contains_simple_case_mapping(start, end).unwrap() + } + + #[test] + #[cfg(feature = "unicode-case")] + fn simple_fold_k() { + let xs: Vec<char> = simple_fold_ok('k').collect(); + assert_eq!(xs, vec!['K', 'K']); + + let xs: Vec<char> = simple_fold_ok('K').collect(); + assert_eq!(xs, vec!['k', 'K']); + + let xs: Vec<char> = simple_fold_ok('K').collect(); + assert_eq!(xs, vec!['K', 'k']); + } + + #[test] + #[cfg(feature = "unicode-case")] + fn simple_fold_a() { + let xs: Vec<char> = simple_fold_ok('a').collect(); + assert_eq!(xs, vec!['A']); + + let xs: Vec<char> = simple_fold_ok('A').collect(); + assert_eq!(xs, vec!['a']); + } + + #[test] + #[cfg(feature = "unicode-case")] + fn simple_fold_empty() { + assert_eq!(Some('A'), simple_fold_err('?')); + assert_eq!(Some('A'), simple_fold_err('@')); + assert_eq!(Some('a'), simple_fold_err('[')); + assert_eq!(Some('Ⰰ'), simple_fold_err('☃')); + } + + #[test] + #[cfg(feature = "unicode-case")] + fn simple_fold_max() { + assert_eq!(None, simple_fold_err('\u{10FFFE}')); + assert_eq!(None, simple_fold_err('\u{10FFFF}')); + } + + #[test] + #[cfg(not(feature = "unicode-case"))] + fn simple_fold_disabled() { + assert!(simple_fold('a').is_err()); + } + + #[test] + #[cfg(feature = "unicode-case")] + fn range_contains() { + assert!(contains_case_map('A', 'A')); + assert!(contains_case_map('Z', 'Z')); + assert!(contains_case_map('A', 'Z')); + assert!(contains_case_map('@', 'A')); + assert!(contains_case_map('Z', '[')); + assert!(contains_case_map('☃', 'Ⰰ')); + + assert!(!contains_case_map('[', '[')); + assert!(!contains_case_map('[', '`')); + + assert!(!contains_case_map('☃', '☃')); + } + + #[test] + #[cfg(not(feature = "unicode-case"))] + fn range_contains_disabled() { + assert!(contains_simple_case_mapping('a', 'a').is_err()); + } + + #[test] + #[cfg(feature = "unicode-gencat")] + fn regression_466() { + use super::{CanonicalClassQuery, ClassQuery}; + + let q = ClassQuery::OneLetter('C'); + assert_eq!( + q.canonicalize().unwrap(), + CanonicalClassQuery::GeneralCategory("Other") + ); + } + + #[test] + fn sym_normalize() { + let sym_norm = symbolic_name_normalize; + + assert_eq!(sym_norm("Line_Break"), "linebreak"); + assert_eq!(sym_norm("Line-break"), "linebreak"); + assert_eq!(sym_norm("linebreak"), "linebreak"); + assert_eq!(sym_norm("BA"), "ba"); + assert_eq!(sym_norm("ba"), "ba"); + assert_eq!(sym_norm("Greek"), "greek"); + assert_eq!(sym_norm("isGreek"), "greek"); + assert_eq!(sym_norm("IS_Greek"), "greek"); + assert_eq!(sym_norm("isc"), "isc"); + assert_eq!(sym_norm("is c"), "isc"); + assert_eq!(sym_norm("is_c"), "isc"); + } + + #[test] + fn valid_utf8_symbolic() { + let mut x = b"abc\xFFxyz".to_vec(); + let y = symbolic_name_normalize_bytes(&mut x); + assert_eq!(y, b"abcxyz"); + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/LICENSE-UNICODE b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/LICENSE-UNICODE new file mode 100644 index 0000000..b82826b --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/LICENSE-UNICODE @@ -0,0 +1,57 @@ +UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE + +Unicode Data Files include all data files under the directories +http://www.unicode.org/Public/, http://www.unicode.org/reports/, +http://www.unicode.org/cldr/data/, http://source.icu-project.org/repos/icu/, and +http://www.unicode.org/utility/trac/browser/. + +Unicode Data Files do not include PDF online code charts under the +directory http://www.unicode.org/Public/. + +Software includes any source code published in the Unicode Standard +or under the directories +http://www.unicode.org/Public/, http://www.unicode.org/reports/, +http://www.unicode.org/cldr/data/, http://source.icu-project.org/repos/icu/, and +http://www.unicode.org/utility/trac/browser/. + +NOTICE TO USER: Carefully read the following legal agreement. +BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S +DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), +YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE +TERMS AND CONDITIONS OF THIS AGREEMENT. +IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE +THE DATA FILES OR SOFTWARE. + +COPYRIGHT AND PERMISSION NOTICE + +Copyright © 1991-2018 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in http://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/age.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/age.rs new file mode 100644 index 0000000..30e6ee1 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/age.rs @@ -0,0 +1,1608 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate age /tmp/ucd/12.1.0/ --chars +// +// ucd-generate is available on crates.io. + +pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] = &[ + ("V10_0", V10_0), + ("V11_0", V11_0), + ("V12_0", V12_0), + ("V12_1", V12_1), + ("V1_1", V1_1), + ("V2_0", V2_0), + ("V2_1", V2_1), + ("V3_0", V3_0), + ("V3_1", V3_1), + ("V3_2", V3_2), + ("V4_0", V4_0), + ("V4_1", V4_1), + ("V5_0", V5_0), + ("V5_1", V5_1), + ("V5_2", V5_2), + ("V6_0", V6_0), + ("V6_1", V6_1), + ("V6_2", V6_2), + ("V6_3", V6_3), + ("V7_0", V7_0), + ("V8_0", V8_0), + ("V9_0", V9_0), +]; + +pub const V10_0: &'static [(char, char)] = &[ + ('ࡠ', 'ࡪ'), + ('ৼ', '৽'), + ('\u{afa}', '\u{aff}'), + ('\u{d00}', '\u{d00}'), + ('\u{d3b}', '\u{d3c}'), + ('᳷', '᳷'), + ('\u{1df6}', '\u{1df9}'), + ('₿', '₿'), + ('⏿', '⏿'), + ('⯒', '⯒'), + ('⹅', '⹉'), + ('ㄮ', 'ㄮ'), + ('鿖', '鿪'), + ('𐌭', '𐌯'), + ('𑨀', '\u{11a47}'), + ('𑩐', '𑪃'), + ('𑪆', '𑪜'), + ('𑪞', '𑪢'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d47}'), + ('𑵐', '𑵙'), + ('𖿡', '𖿡'), + ('𛀂', '𛄞'), + ('𛅰', '𛋻'), + ('🉠', '🉥'), + ('🛓', '🛔'), + ('🛷', '🛸'), + ('🤀', '🤋'), + ('🤟', '🤟'), + ('🤨', '🤯'), + ('🤱', '🤲'), + ('🥌', '🥌'), + ('🥟', '🥫'), + ('🦒', '🦗'), + ('🧐', '🧦'), + ('𬺰', '𮯠'), +]; + +pub const V11_0: &'static [(char, char)] = &[ + ('ՠ', 'ՠ'), + ('ֈ', 'ֈ'), + ('ׯ', 'ׯ'), + ('\u{7fd}', '߿'), + ('\u{8d3}', '\u{8d3}'), + ('\u{9fe}', '\u{9fe}'), + ('੶', '੶'), + ('\u{c04}', '\u{c04}'), + ('಄', '಄'), + ('ᡸ', 'ᡸ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('⮺', '⮼'), + ('⯓', '⯫'), + ('⯰', '⯾'), + ('⹊', '⹎'), + ('ㄯ', 'ㄯ'), + ('鿫', '鿯'), + ('ꞯ', 'ꞯ'), + ('Ꞹ', 'ꞹ'), + ('ꣾ', '\u{a8ff}'), + ('𐨴', '𐨵'), + ('𐩈', '𐩈'), + ('𐴀', '\u{10d27}'), + ('𐴰', '𐴹'), + ('𐼀', '𐼧'), + ('𐼰', '𐽙'), + ('\u{110cd}', '\u{110cd}'), + ('𑅄', '𑅆'), + ('\u{1133b}', '\u{1133b}'), + ('\u{1145e}', '\u{1145e}'), + ('𑜚', '𑜚'), + ('𑠀', '𑠻'), + ('𑪝', '𑪝'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '𑶘'), + ('𑶠', '𑶩'), + ('𑻠', '𑻸'), + ('𖹀', '𖺚'), + ('𘟭', '𘟱'), + ('𝋠', '𝋳'), + ('𝍲', '𝍸'), + ('𞱱', '𞲴'), + ('🄯', '🄯'), + ('🛹', '🛹'), + ('🟕', '🟘'), + ('🥍', '🥏'), + ('🥬', '🥰'), + ('🥳', '🥶'), + ('🥺', '🥺'), + ('🥼', '🥿'), + ('🦘', '🦢'), + ('🦰', '🦹'), + ('🧁', '🧂'), + ('🧧', '🧿'), + ('🩠', '🩭'), +]; + +pub const V12_0: &'static [(char, char)] = &[ + ('\u{c77}', '\u{c77}'), + ('\u{e86}', '\u{e86}'), + ('\u{e89}', '\u{e89}'), + ('\u{e8c}', '\u{e8c}'), + ('\u{e8e}', '\u{e93}'), + ('\u{e98}', '\u{e98}'), + ('\u{ea0}', '\u{ea0}'), + ('\u{ea8}', '\u{ea9}'), + ('\u{eac}', '\u{eac}'), + ('\u{eba}', '\u{eba}'), + ('\u{1cfa}', '\u{1cfa}'), + ('\u{2bc9}', '\u{2bc9}'), + ('\u{2bff}', '\u{2bff}'), + ('\u{2e4f}', '\u{2e4f}'), + ('\u{a7ba}', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('\u{ab66}', '\u{ab67}'), + ('\u{10fe0}', '\u{10ff6}'), + ('\u{1145f}', '\u{1145f}'), + ('\u{116b8}', '\u{116b8}'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d7}'), + ('\u{119da}', '\u{119e4}'), + ('\u{11a84}', '\u{11a85}'), + ('\u{11fc0}', '\u{11ff1}'), + ('\u{11fff}', '\u{11fff}'), + ('\u{13430}', '\u{13438}'), + ('\u{16f45}', '\u{16f4a}'), + ('\u{16f4f}', '\u{16f4f}'), + ('\u{16f7f}', '\u{16f87}'), + ('\u{16fe2}', '\u{16fe3}'), + ('\u{187f2}', '\u{187f7}'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e130}', '\u{1e13d}'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e14e}', '\u{1e14f}'), + ('\u{1e2c0}', '\u{1e2f9}'), + ('\u{1e2ff}', '\u{1e2ff}'), + ('\u{1e94b}', '\u{1e94b}'), + ('\u{1ed01}', '\u{1ed3d}'), + ('\u{1f16c}', '\u{1f16c}'), + ('\u{1f6d5}', '\u{1f6d5}'), + ('\u{1f6fa}', '\u{1f6fa}'), + ('\u{1f7e0}', '\u{1f7eb}'), + ('\u{1f90d}', '\u{1f90f}'), + ('\u{1f93f}', '\u{1f93f}'), + ('\u{1f971}', '\u{1f971}'), + ('\u{1f97b}', '\u{1f97b}'), + ('\u{1f9a5}', '\u{1f9aa}'), + ('\u{1f9ae}', '\u{1f9af}'), + ('\u{1f9ba}', '\u{1f9bf}'), + ('\u{1f9c3}', '\u{1f9ca}'), + ('\u{1f9cd}', '\u{1f9cf}'), + ('\u{1fa00}', '\u{1fa53}'), + ('\u{1fa70}', '\u{1fa73}'), + ('\u{1fa78}', '\u{1fa7a}'), + ('\u{1fa80}', '\u{1fa82}'), + ('\u{1fa90}', '\u{1fa95}'), +]; + +pub const V12_1: &'static [(char, char)] = &[('\u{32ff}', '\u{32ff}')]; + +pub const V1_1: &'static [(char, char)] = &[ + ('\u{0}', 'ǵ'), + ('Ǻ', 'ȗ'), + ('ɐ', 'ʨ'), + ('ʰ', '˞'), + ('ˠ', '˩'), + ('\u{300}', '\u{345}'), + ('\u{360}', '\u{361}'), + ('ʹ', '͵'), + ('ͺ', 'ͺ'), + (';', ';'), + ('΄', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ώ'), + ('ϐ', 'ϖ'), + ('Ϛ', 'Ϛ'), + ('Ϝ', 'Ϝ'), + ('Ϟ', 'Ϟ'), + ('Ϡ', 'Ϡ'), + ('Ϣ', 'ϳ'), + ('Ё', 'Ќ'), + ('Ў', 'я'), + ('ё', 'ќ'), + ('ў', '\u{486}'), + ('Ґ', 'ӄ'), + ('Ӈ', 'ӈ'), + ('Ӌ', 'ӌ'), + ('Ӑ', 'ӫ'), + ('Ӯ', 'ӵ'), + ('Ӹ', 'ӹ'), + ('Ա', 'Ֆ'), + ('ՙ', '՟'), + ('ա', 'և'), + ('։', '։'), + ('\u{5b0}', '\u{5b9}'), + ('\u{5bb}', '׃'), + ('א', 'ת'), + ('װ', '״'), + ('،', '،'), + ('؛', '؛'), + ('؟', '؟'), + ('ء', 'غ'), + ('ـ', '\u{652}'), + ('٠', '٭'), + ('\u{670}', 'ڷ'), + ('ں', 'ھ'), + ('ۀ', 'ێ'), + ('ې', '\u{6ed}'), + ('۰', '۹'), + ('\u{901}', 'ः'), + ('अ', 'ह'), + ('\u{93c}', '\u{94d}'), + ('ॐ', '\u{954}'), + ('क़', '॰'), + ('\u{981}', 'ঃ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('\u{9bc}', '\u{9bc}'), + ('\u{9be}', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', '\u{9cd}'), + ('\u{9d7}', '\u{9d7}'), + ('ড়', 'ঢ়'), + ('য়', '\u{9e3}'), + ('০', '৺'), + ('\u{a02}', '\u{a02}'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('\u{a3c}', '\u{a3c}'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('੦', 'ੴ'), + ('\u{a81}', 'ઃ'), + ('અ', 'ઋ'), + ('ઍ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('\u{abc}', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', '\u{acd}'), + ('ૐ', 'ૐ'), + ('ૠ', 'ૠ'), + ('૦', '૯'), + ('\u{b01}', 'ଃ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଶ', 'ହ'), + ('\u{b3c}', '\u{b43}'), + ('େ', 'ୈ'), + ('ୋ', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', 'ୡ'), + ('୦', '୰'), + ('\u{b82}', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'வ'), + ('ஷ', 'ஹ'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', '\u{bcd}'), + ('\u{bd7}', '\u{bd7}'), + ('௧', '௲'), + ('ఁ', 'ః'), + ('అ', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'ళ'), + ('వ', 'హ'), + ('\u{c3e}', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('ౠ', 'ౡ'), + ('౦', '౯'), + ('ಂ', 'ಃ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('ಾ', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('ೞ', 'ೞ'), + ('ೠ', 'ೡ'), + ('೦', '೯'), + ('ം', 'ഃ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', 'ന'), + ('പ', 'ഹ'), + ('\u{d3e}', '\u{d43}'), + ('െ', 'ൈ'), + ('ൊ', '\u{d4d}'), + ('\u{d57}', '\u{d57}'), + ('ൠ', 'ൡ'), + ('൦', '൯'), + ('ก', '\u{e3a}'), + ('฿', '๛'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('ງ', 'ຈ'), + ('ຊ', 'ຊ'), + ('ຍ', 'ຍ'), + ('ດ', 'ທ'), + ('ນ', 'ຟ'), + ('ມ', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ວ'), + ('ສ', 'ຫ'), + ('ອ', '\u{eb9}'), + ('\u{ebb}', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('\u{ec8}', '\u{ecd}'), + ('໐', '໙'), + ('ໜ', 'ໝ'), + ('Ⴀ', 'Ⴥ'), + ('ა', 'ჶ'), + ('჻', '჻'), + ('ᄀ', 'ᅙ'), + ('ᅟ', 'ᆢ'), + ('ᆨ', 'ᇹ'), + ('Ḁ', 'ẚ'), + ('Ạ', 'ỹ'), + ('ἀ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ῄ'), + ('ῆ', 'ΐ'), + ('ῖ', 'Ί'), + ('῝', '`'), + ('ῲ', 'ῴ'), + ('ῶ', '῾'), + ('\u{2000}', '\u{202e}'), + ('‰', '⁆'), + ('\u{206a}', '⁰'), + ('⁴', '₎'), + ('₠', '₪'), + ('\u{20d0}', '\u{20e1}'), + ('℀', 'ℸ'), + ('⅓', 'ↂ'), + ('←', '⇪'), + ('∀', '⋱'), + ('⌀', '⌀'), + ('⌂', '⍺'), + ('␀', '␤'), + ('⑀', '⑊'), + ('①', '⓪'), + ('─', '▕'), + ('■', '◯'), + ('☀', '☓'), + ('☚', '♯'), + ('✁', '✄'), + ('✆', '✉'), + ('✌', '✧'), + ('✩', '❋'), + ('❍', '❍'), + ('❏', '❒'), + ('❖', '❖'), + ('❘', '❞'), + ('❡', '❧'), + ('❶', '➔'), + ('➘', '➯'), + ('➱', '➾'), + ('\u{3000}', '〷'), + ('〿', '〿'), + ('ぁ', 'ゔ'), + ('\u{3099}', 'ゞ'), + ('ァ', 'ヾ'), + ('ㄅ', 'ㄬ'), + ('ㄱ', 'ㆎ'), + ('㆐', '㆟'), + ('㈀', '㈜'), + ('㈠', '㉃'), + ('㉠', '㉻'), + ('㉿', '㊰'), + ('㋀', '㋋'), + ('㋐', '㋾'), + ('㌀', '㍶'), + ('㍻', '㏝'), + ('㏠', '㏾'), + ('一', '龥'), + ('\u{e000}', '鶴'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('\u{fb1e}', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﮱ'), + ('ﯓ', '﴿'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷻ'), + ('\u{fe20}', '\u{fe23}'), + ('︰', '﹄'), + ('﹉', '﹒'), + ('﹔', '﹦'), + ('﹨', '﹫'), + ('ﹰ', 'ﹲ'), + ('ﹴ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('\u{feff}', '\u{feff}'), + ('!', '~'), + ('。', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('¢', '₩'), + ('│', '○'), + ('�', '\u{ffff}'), +]; + +pub const V2_0: &'static [(char, char)] = &[ + ('\u{591}', '\u{5a1}'), + ('\u{5a3}', '\u{5af}'), + ('\u{5c4}', '\u{5c4}'), + ('ༀ', 'ཇ'), + ('ཉ', 'ཀྵ'), + ('\u{f71}', 'ྋ'), + ('\u{f90}', '\u{f95}'), + ('\u{f97}', '\u{f97}'), + ('\u{f99}', '\u{fad}'), + ('\u{fb1}', '\u{fb7}'), + ('\u{fb9}', '\u{fb9}'), + ('ẛ', 'ẛ'), + ('₫', '₫'), + ('가', '힣'), + ('\u{1fffe}', '\u{1ffff}'), + ('\u{2fffe}', '\u{2ffff}'), + ('\u{3fffe}', '\u{3ffff}'), + ('\u{4fffe}', '\u{4ffff}'), + ('\u{5fffe}', '\u{5ffff}'), + ('\u{6fffe}', '\u{6ffff}'), + ('\u{7fffe}', '\u{7ffff}'), + ('\u{8fffe}', '\u{8ffff}'), + ('\u{9fffe}', '\u{9ffff}'), + ('\u{afffe}', '\u{affff}'), + ('\u{bfffe}', '\u{bffff}'), + ('\u{cfffe}', '\u{cffff}'), + ('\u{dfffe}', '\u{dffff}'), + ('\u{efffe}', '\u{10ffff}'), +]; + +pub const V2_1: &'static [(char, char)] = &[('€', '€'), ('', '')]; + +pub const V3_0: &'static [(char, char)] = &[ + ('Ƕ', 'ǹ'), + ('Ș', 'ȟ'), + ('Ȣ', 'ȳ'), + ('ʩ', 'ʭ'), + ('˟', '˟'), + ('˪', 'ˮ'), + ('\u{346}', '\u{34e}'), + ('\u{362}', '\u{362}'), + ('ϗ', 'ϗ'), + ('ϛ', 'ϛ'), + ('ϝ', 'ϝ'), + ('ϟ', 'ϟ'), + ('ϡ', 'ϡ'), + ('Ѐ', 'Ѐ'), + ('Ѝ', 'Ѝ'), + ('ѐ', 'ѐ'), + ('ѝ', 'ѝ'), + ('\u{488}', '\u{489}'), + ('Ҍ', 'ҏ'), + ('Ӭ', 'ӭ'), + ('֊', '֊'), + ('\u{653}', '\u{655}'), + ('ڸ', 'ڹ'), + ('ڿ', 'ڿ'), + ('ۏ', 'ۏ'), + ('ۺ', '۾'), + ('܀', '܍'), + ('\u{70f}', 'ܬ'), + ('\u{730}', '\u{74a}'), + ('ހ', '\u{7b0}'), + ('ං', 'ඃ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('ෲ', '෴'), + ('ཪ', 'ཪ'), + ('\u{f96}', '\u{f96}'), + ('\u{fae}', '\u{fb0}'), + ('\u{fb8}', '\u{fb8}'), + ('\u{fba}', '\u{fbc}'), + ('྾', '࿌'), + ('࿏', '࿏'), + ('က', 'အ'), + ('ဣ', 'ဧ'), + ('ဩ', 'ဪ'), + ('ာ', '\u{1032}'), + ('\u{1036}', '\u{1039}'), + ('၀', '\u{1059}'), + ('ሀ', 'ሆ'), + ('ለ', 'ቆ'), + ('ቈ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኆ'), + ('ኈ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኮ'), + ('ኰ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዎ'), + ('ዐ', 'ዖ'), + ('ዘ', 'ዮ'), + ('ደ', 'ጎ'), + ('ጐ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ጞ'), + ('ጠ', 'ፆ'), + ('ፈ', 'ፚ'), + ('፡', '፼'), + ('Ꭰ', 'Ᏼ'), + ('ᐁ', 'ᙶ'), + ('\u{1680}', '᚜'), + ('ᚠ', 'ᛰ'), + ('ក', 'ៜ'), + ('០', '៩'), + ('᠀', '\u{180e}'), + ('᠐', '᠙'), + ('ᠠ', 'ᡷ'), + ('ᢀ', '\u{18a9}'), + ('\u{202f}', '\u{202f}'), + ('⁈', '⁍'), + ('₭', '₯'), + ('\u{20e2}', '\u{20e3}'), + ('ℹ', '℺'), + ('Ↄ', 'Ↄ'), + ('⇫', '⇳'), + ('⌁', '⌁'), + ('⍻', '⍻'), + ('⍽', '⎚'), + ('␥', '␦'), + ('◰', '◷'), + ('☙', '☙'), + ('♰', '♱'), + ('⠀', '⣿'), + ('⺀', '⺙'), + ('⺛', '⻳'), + ('⼀', '⿕'), + ('⿰', '⿻'), + ('〸', '〺'), + ('〾', '〾'), + ('ㆠ', 'ㆷ'), + ('㐀', '䶵'), + ('ꀀ', 'ꒌ'), + ('꒐', '꒡'), + ('꒤', '꒳'), + ('꒵', '꓀'), + ('꓂', '꓄'), + ('꓆', '꓆'), + ('יִ', 'יִ'), + ('\u{fff9}', '\u{fffb}'), +]; + +pub const V3_1: &'static [(char, char)] = &[ + ('ϴ', 'ϵ'), + ('\u{fdd0}', '\u{fdef}'), + ('𐌀', '𐌞'), + ('𐌠', '𐌣'), + ('𐌰', '𐍊'), + ('𐐀', '𐐥'), + ('𐐨', '𐑍'), + ('𝀀', '𝃵'), + ('𝄀', '𝄦'), + ('𝄪', '𝇝'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓀'), + ('𝓂', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚣'), + ('𝚨', '𝟉'), + ('𝟎', '𝟿'), + ('𠀀', '𪛖'), + ('丽', '𪘀'), + ('\u{e0001}', '\u{e0001}'), + ('\u{e0020}', '\u{e007f}'), +]; + +pub const V3_2: &'static [(char, char)] = &[ + ('Ƞ', 'Ƞ'), + ('\u{34f}', '\u{34f}'), + ('\u{363}', '\u{36f}'), + ('Ϙ', 'ϙ'), + ('϶', '϶'), + ('Ҋ', 'ҋ'), + ('Ӆ', 'ӆ'), + ('Ӊ', 'ӊ'), + ('Ӎ', 'ӎ'), + ('Ԁ', 'ԏ'), + ('ٮ', 'ٯ'), + ('ޱ', 'ޱ'), + ('ჷ', 'ჸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', '\u{1714}'), + ('ᜠ', '᜶'), + ('ᝀ', '\u{1753}'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('\u{1772}', '\u{1773}'), + ('⁇', '⁇'), + ('⁎', '⁒'), + ('⁗', '⁗'), + ('\u{205f}', '\u{2063}'), + ('ⁱ', 'ⁱ'), + ('₰', '₱'), + ('\u{20e4}', '\u{20ea}'), + ('ℽ', '⅋'), + ('⇴', '⇿'), + ('⋲', '⋿'), + ('⍼', '⍼'), + ('⎛', '⏎'), + ('⓫', '⓾'), + ('▖', '▟'), + ('◸', '◿'), + ('☖', '☗'), + ('♲', '♽'), + ('⚀', '⚉'), + ('❨', '❵'), + ('⟐', '⟫'), + ('⟰', '⟿'), + ('⤀', '⫿'), + ('〻', '〽'), + ('ゕ', 'ゖ'), + ('ゟ', '゠'), + ('ヿ', 'ヿ'), + ('ㇰ', 'ㇿ'), + ('㉑', '㉟'), + ('㊱', '㊿'), + ('꒢', '꒣'), + ('꒴', '꒴'), + ('꓁', '꓁'), + ('꓅', '꓅'), + ('侮', '頻'), + ('﷼', '﷼'), + ('\u{fe00}', '\u{fe0f}'), + ('﹅', '﹆'), + ('ﹳ', 'ﹳ'), + ('⦅', '⦆'), +]; + +pub const V4_0: &'static [(char, char)] = &[ + ('ȡ', 'ȡ'), + ('ȴ', 'ȶ'), + ('ʮ', 'ʯ'), + ('˯', '˿'), + ('\u{350}', '\u{357}'), + ('\u{35d}', '\u{35f}'), + ('Ϸ', 'ϻ'), + ('\u{600}', '\u{603}'), + ('؍', '\u{615}'), + ('\u{656}', '\u{658}'), + ('ۮ', 'ۯ'), + ('ۿ', 'ۿ'), + ('ܭ', 'ܯ'), + ('ݍ', 'ݏ'), + ('ऄ', 'ऄ'), + ('ঽ', 'ঽ'), + ('\u{a01}', '\u{a01}'), + ('ਃ', 'ਃ'), + ('ઌ', 'ઌ'), + ('ૡ', '\u{ae3}'), + ('૱', '૱'), + ('ଵ', 'ଵ'), + ('ୱ', 'ୱ'), + ('௳', '௺'), + ('\u{cbc}', 'ಽ'), + ('\u{17dd}', '\u{17dd}'), + ('៰', '៹'), + ('ᤀ', 'ᤜ'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', '\u{193b}'), + ('᥀', '᥀'), + ('᥄', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('᧠', '᧿'), + ('ᴀ', 'ᵫ'), + ('⁓', '⁔'), + ('℻', '℻'), + ('⏏', '⏐'), + ('⓿', '⓿'), + ('☔', '☕'), + ('⚊', '⚑'), + ('⚠', '⚡'), + ('⬀', '⬍'), + ('㈝', '㈞'), + ('㉐', '㉐'), + ('㉼', '㉽'), + ('㋌', '㋏'), + ('㍷', '㍺'), + ('㏞', '㏟'), + ('㏿', '㏿'), + ('䷀', '䷿'), + ('﷽', '﷽'), + ('﹇', '﹈'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐄀', '𐄂'), + ('𐄇', '𐄳'), + ('𐄷', '𐄿'), + ('𐎀', '𐎝'), + ('𐎟', '𐎟'), + ('𐐦', '𐐧'), + ('𐑎', '𐒝'), + ('𐒠', '𐒩'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐠿'), + ('𝌀', '𝍖'), + ('𝓁', '𝓁'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const V4_1: &'static [(char, char)] = &[ + ('ȷ', 'Ɂ'), + ('\u{358}', '\u{35c}'), + ('ϼ', 'Ͽ'), + ('Ӷ', 'ӷ'), + ('\u{5a2}', '\u{5a2}'), + ('\u{5c5}', '\u{5c7}'), + ('؋', '؋'), + ('؞', '؞'), + ('\u{659}', '\u{65e}'), + ('ݐ', 'ݭ'), + ('ॽ', 'ॽ'), + ('ৎ', 'ৎ'), + ('ஶ', 'ஶ'), + ('௦', '௦'), + ('࿐', '࿑'), + ('ჹ', 'ჺ'), + ('ჼ', 'ჼ'), + ('ሇ', 'ሇ'), + ('ቇ', 'ቇ'), + ('ኇ', 'ኇ'), + ('ኯ', 'ኯ'), + ('ዏ', 'ዏ'), + ('ዯ', 'ዯ'), + ('ጏ', 'ጏ'), + ('ጟ', 'ጟ'), + ('ፇ', 'ፇ'), + ('\u{135f}', '፠'), + ('ᎀ', '᎙'), + ('ᦀ', 'ᦩ'), + ('ᦰ', 'ᧉ'), + ('᧐', '᧙'), + ('᧞', '᧟'), + ('ᨀ', '\u{1a1b}'), + ('᨞', '᨟'), + ('ᵬ', '\u{1dc3}'), + ('⁕', '⁖'), + ('⁘', '⁞'), + ('ₐ', 'ₔ'), + ('₲', '₵'), + ('\u{20eb}', '\u{20eb}'), + ('ℼ', 'ℼ'), + ('⅌', '⅌'), + ('⏑', '⏛'), + ('☘', '☘'), + ('♾', '♿'), + ('⚒', '⚜'), + ('⚢', '⚱'), + ('⟀', '⟆'), + ('⬎', '⬓'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⲁ', '⳪'), + ('⳹', 'ⴥ'), + ('ⴰ', 'ⵥ'), + ('ⵯ', 'ⵯ'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('⸀', '⸗'), + ('⸜', '⸝'), + ('㇀', '㇏'), + ('㉾', '㉾'), + ('龦', '龻'), + ('꜀', '꜖'), + ('ꠀ', '꠫'), + ('並', '龎'), + ('︐', '︙'), + ('𐅀', '𐆊'), + ('𐎠', '𐏃'), + ('𐏈', '𐏕'), + ('𐨀', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨳'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '𐩇'), + ('𐩐', '𐩘'), + ('𝈀', '𝉅'), + ('𝚤', '𝚥'), +]; + +pub const V5_0: &'static [(char, char)] = &[ + ('ɂ', 'ɏ'), + ('ͻ', 'ͽ'), + ('ӏ', 'ӏ'), + ('Ӻ', 'ӿ'), + ('Ԑ', 'ԓ'), + ('\u{5ba}', '\u{5ba}'), + ('߀', 'ߺ'), + ('ॻ', 'ॼ'), + ('ॾ', 'ॿ'), + ('\u{ce2}', '\u{ce3}'), + ('ೱ', 'ೲ'), + ('\u{1b00}', 'ᭋ'), + ('᭐', '᭼'), + ('\u{1dc4}', '\u{1dca}'), + ('\u{1dfe}', '\u{1dff}'), + ('\u{20ec}', '\u{20ef}'), + ('⅍', 'ⅎ'), + ('ↄ', 'ↄ'), + ('⏜', '⏧'), + ('⚲', '⚲'), + ('⟇', '⟊'), + ('⬔', '⬚'), + ('⬠', '⬣'), + ('Ⱡ', 'ⱬ'), + ('ⱴ', 'ⱷ'), + ('ꜗ', 'ꜚ'), + ('꜠', '꜡'), + ('ꡀ', '꡷'), + ('𐤀', '𐤙'), + ('𐤟', '𐤟'), + ('𒀀', '𒍮'), + ('𒐀', '𒑢'), + ('𒑰', '𒑳'), + ('𝍠', '𝍱'), + ('𝟊', '𝟋'), +]; + +pub const V5_1: &'static [(char, char)] = &[ + ('Ͱ', 'ͳ'), + ('Ͷ', 'ͷ'), + ('Ϗ', 'Ϗ'), + ('\u{487}', '\u{487}'), + ('Ԕ', 'ԣ'), + ('؆', '؊'), + ('\u{616}', '\u{61a}'), + ('ػ', 'ؿ'), + ('ݮ', 'ݿ'), + ('ॱ', 'ॲ'), + ('\u{a51}', '\u{a51}'), + ('\u{a75}', '\u{a75}'), + ('\u{b44}', '\u{b44}'), + ('\u{b62}', '\u{b63}'), + ('ௐ', 'ௐ'), + ('ఽ', 'ఽ'), + ('ౘ', 'ౙ'), + ('\u{c62}', '\u{c63}'), + ('౸', '౿'), + ('ഽ', 'ഽ'), + ('\u{d44}', '\u{d44}'), + ('\u{d62}', '\u{d63}'), + ('൰', '൵'), + ('൹', 'ൿ'), + ('ཫ', 'ཬ'), + ('࿎', '࿎'), + ('࿒', '࿔'), + ('ဢ', 'ဢ'), + ('ဨ', 'ဨ'), + ('ါ', 'ါ'), + ('\u{1033}', '\u{1035}'), + ('\u{103a}', 'ဿ'), + ('ၚ', '႙'), + ('႞', '႟'), + ('ᢪ', 'ᢪ'), + ('\u{1b80}', '᮪'), + ('ᮮ', '᮹'), + ('ᰀ', '\u{1c37}'), + ('᰻', '᱉'), + ('ᱍ', '᱿'), + ('\u{1dcb}', '\u{1de6}'), + ('ẜ', 'ẟ'), + ('Ỻ', 'ỿ'), + ('\u{2064}', '\u{2064}'), + ('\u{20f0}', '\u{20f0}'), + ('⅏', '⅏'), + ('ↅ', 'ↈ'), + ('⚝', '⚝'), + ('⚳', '⚼'), + ('⛀', '⛃'), + ('⟌', '⟌'), + ('⟬', '⟯'), + ('⬛', '⬟'), + ('⬤', '⭌'), + ('⭐', '⭔'), + ('Ɑ', 'Ɐ'), + ('ⱱ', 'ⱳ'), + ('ⱸ', 'ⱽ'), + ('\u{2de0}', '\u{2dff}'), + ('⸘', '⸛'), + ('⸞', '⸰'), + ('ㄭ', 'ㄭ'), + ('㇐', '㇣'), + ('龼', '鿃'), + ('ꔀ', 'ꘫ'), + ('Ꙁ', 'ꙟ'), + ('Ꙣ', '꙳'), + ('\u{a67c}', 'ꚗ'), + ('ꜛ', 'ꜟ'), + ('Ꜣ', 'ꞌ'), + ('ꟻ', 'ꟿ'), + ('ꢀ', '\u{a8c4}'), + ('꣎', '꣙'), + ('꤀', '꥓'), + ('꥟', '꥟'), + ('ꨀ', '\u{aa36}'), + ('ꩀ', 'ꩍ'), + ('꩐', '꩙'), + ('꩜', '꩟'), + ('\u{fe24}', '\u{fe26}'), + ('𐆐', '𐆛'), + ('𐇐', '\u{101fd}'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('𐤠', '𐤹'), + ('𐤿', '𐤿'), + ('𝄩', '𝄩'), + ('🀀', '🀫'), + ('🀰', '🂓'), +]; + +pub const V5_2: &'static [(char, char)] = &[ + ('Ԥ', 'ԥ'), + ('ࠀ', '\u{82d}'), + ('࠰', '࠾'), + ('\u{900}', '\u{900}'), + ('ॎ', 'ॎ'), + ('\u{955}', '\u{955}'), + ('ॹ', 'ॺ'), + ('৻', '৻'), + ('࿕', '࿘'), + ('ႚ', '\u{109d}'), + ('ᅚ', 'ᅞ'), + ('ᆣ', 'ᆧ'), + ('ᇺ', 'ᇿ'), + ('᐀', '᐀'), + ('ᙷ', 'ᙿ'), + ('ᢰ', 'ᣵ'), + ('ᦪ', 'ᦫ'), + ('᧚', '᧚'), + ('ᨠ', '\u{1a5e}'), + ('\u{1a60}', '\u{1a7c}'), + ('\u{1a7f}', '᪉'), + ('᪐', '᪙'), + ('᪠', '᪭'), + ('\u{1cd0}', 'ᳲ'), + ('\u{1dfd}', '\u{1dfd}'), + ('₶', '₸'), + ('⅐', '⅒'), + ('↉', '↉'), + ('⏨', '⏨'), + ('⚞', '⚟'), + ('⚽', '⚿'), + ('⛄', '⛍'), + ('⛏', '⛡'), + ('⛣', '⛣'), + ('⛨', '⛿'), + ('❗', '❗'), + ('⭕', '⭙'), + ('Ɒ', 'Ɒ'), + ('Ȿ', 'Ɀ'), + ('Ⳬ', '\u{2cf1}'), + ('⸱', '⸱'), + ('㉄', '㉏'), + ('鿄', '鿋'), + ('ꓐ', '꓿'), + ('ꚠ', '꛷'), + ('꠰', '꠹'), + ('\u{a8e0}', 'ꣻ'), + ('ꥠ', 'ꥼ'), + ('\u{a980}', '꧍'), + ('ꧏ', '꧙'), + ('꧞', '꧟'), + ('ꩠ', 'ꩻ'), + ('ꪀ', 'ꫂ'), + ('ꫛ', '꫟'), + ('ꯀ', '\u{abed}'), + ('꯰', '꯹'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('恵', '舘'), + ('𐡀', '𐡕'), + ('𐡗', '𐡟'), + ('𐤚', '𐤛'), + ('𐩠', '𐩿'), + ('𐬀', '𐬵'), + ('𐬹', '𐭕'), + ('𐭘', '𐭲'), + ('𐭸', '𐭿'), + ('𐰀', '𐱈'), + ('𐹠', '𐹾'), + ('\u{11080}', '𑃁'), + ('𓀀', '𓐮'), + ('🄀', '🄊'), + ('🄐', '🄮'), + ('🄱', '🄱'), + ('🄽', '🄽'), + ('🄿', '🄿'), + ('🅂', '🅂'), + ('🅆', '🅆'), + ('🅊', '🅎'), + ('🅗', '🅗'), + ('🅟', '🅟'), + ('🅹', '🅹'), + ('🅻', '🅼'), + ('🅿', '🅿'), + ('🆊', '🆍'), + ('🆐', '🆐'), + ('🈀', '🈀'), + ('🈐', '🈱'), + ('🉀', '🉈'), + ('𪜀', '𫜴'), +]; + +pub const V6_0: &'static [(char, char)] = &[ + ('Ԧ', 'ԧ'), + ('ؠ', 'ؠ'), + ('\u{65f}', '\u{65f}'), + ('ࡀ', '\u{85b}'), + ('࡞', '࡞'), + ('\u{93a}', 'ऻ'), + ('ॏ', 'ॏ'), + ('\u{956}', '\u{957}'), + ('ॳ', 'ॷ'), + ('୲', '୷'), + ('ഩ', 'ഩ'), + ('ഺ', 'ഺ'), + ('ൎ', 'ൎ'), + ('ྌ', '\u{f8f}'), + ('࿙', '࿚'), + ('\u{135d}', '\u{135e}'), + ('ᯀ', '᯳'), + ('᯼', '᯿'), + ('\u{1dfc}', '\u{1dfc}'), + ('ₕ', 'ₜ'), + ('₹', '₹'), + ('⏩', '⏳'), + ('⛎', '⛎'), + ('⛢', '⛢'), + ('⛤', '⛧'), + ('✅', '✅'), + ('✊', '✋'), + ('✨', '✨'), + ('❌', '❌'), + ('❎', '❎'), + ('❓', '❕'), + ('❟', '❠'), + ('➕', '➗'), + ('➰', '➰'), + ('➿', '➿'), + ('⟎', '⟏'), + ('⵰', '⵰'), + ('\u{2d7f}', '\u{2d7f}'), + ('ㆸ', 'ㆺ'), + ('Ꙡ', 'ꙡ'), + ('Ɥ', 'ꞎ'), + ('Ꞑ', 'ꞑ'), + ('Ꞡ', 'ꞩ'), + ('ꟺ', 'ꟺ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('﮲', '﯁'), + ('𑀀', '𑁍'), + ('𑁒', '𑁯'), + ('𖠀', '𖨸'), + ('𛀀', '𛀁'), + ('🂠', '🂮'), + ('🂱', '🂾'), + ('🃁', '🃏'), + ('🃑', '🃟'), + ('🄰', '🄰'), + ('🄲', '🄼'), + ('🄾', '🄾'), + ('🅀', '🅁'), + ('🅃', '🅅'), + ('🅇', '🅉'), + ('🅏', '🅖'), + ('🅘', '🅞'), + ('🅠', '🅩'), + ('🅰', '🅸'), + ('🅺', '🅺'), + ('🅽', '🅾'), + ('🆀', '🆉'), + ('🆎', '🆏'), + ('🆑', '🆚'), + ('🇦', '🇿'), + ('🈁', '🈂'), + ('🈲', '🈺'), + ('🉐', '🉑'), + ('🌀', '🌠'), + ('🌰', '🌵'), + ('🌷', '🍼'), + ('🎀', '🎓'), + ('🎠', '🏄'), + ('🏆', '🏊'), + ('🏠', '🏰'), + ('🐀', '🐾'), + ('👀', '👀'), + ('👂', '📷'), + ('📹', '📼'), + ('🔀', '🔽'), + ('🕐', '🕧'), + ('🗻', '🗿'), + ('😁', '😐'), + ('😒', '😔'), + ('😖', '😖'), + ('😘', '😘'), + ('😚', '😚'), + ('😜', '😞'), + ('😠', '😥'), + ('😨', '😫'), + ('😭', '😭'), + ('😰', '😳'), + ('😵', '🙀'), + ('🙅', '🙏'), + ('🚀', '🛅'), + ('🜀', '🝳'), + ('𫝀', '𫠝'), +]; + +pub const V6_1: &'static [(char, char)] = &[ + ('֏', '֏'), + ('\u{604}', '\u{604}'), + ('ࢠ', 'ࢠ'), + ('ࢢ', 'ࢬ'), + ('\u{8e4}', '\u{8fe}'), + ('૰', '૰'), + ('ໞ', 'ໟ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ჽ', 'ჿ'), + ('\u{1bab}', '\u{1bad}'), + ('ᮺ', 'ᮿ'), + ('᳀', '᳇'), + ('ᳳ', 'ᳶ'), + ('⟋', '⟋'), + ('⟍', '⟍'), + ('Ⳳ', 'ⳳ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ⵦ', 'ⵧ'), + ('⸲', '⸻'), + ('鿌', '鿌'), + ('\u{a674}', '\u{a67b}'), + ('\u{a69f}', '\u{a69f}'), + ('Ꞓ', 'ꞓ'), + ('Ɦ', 'Ɦ'), + ('ꟸ', 'ꟹ'), + ('ꫠ', '\u{aaf6}'), + ('郞', '隷'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𑃐', '𑃨'), + ('𑃰', '𑃹'), + ('\u{11100}', '\u{11134}'), + ('𑄶', '𑅃'), + ('\u{11180}', '𑇈'), + ('𑇐', '𑇙'), + ('𑚀', '\u{116b7}'), + ('𑛀', '𑛉'), + ('𖼀', '𖽄'), + ('𖽐', '𖽾'), + ('\u{16f8f}', '𖾟'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𞻰', '𞻱'), + ('🅪', '🅫'), + ('🕀', '🕃'), + ('😀', '😀'), + ('😑', '😑'), + ('😕', '😕'), + ('😗', '😗'), + ('😙', '😙'), + ('😛', '😛'), + ('😟', '😟'), + ('😦', '😧'), + ('😬', '😬'), + ('😮', '😯'), + ('😴', '😴'), +]; + +pub const V6_2: &'static [(char, char)] = &[('₺', '₺')]; + +pub const V6_3: &'static [(char, char)] = + &[('\u{61c}', '\u{61c}'), ('\u{2066}', '\u{2069}')]; + +pub const V7_0: &'static [(char, char)] = &[ + ('Ϳ', 'Ϳ'), + ('Ԩ', 'ԯ'), + ('֍', '֎'), + ('\u{605}', '\u{605}'), + ('ࢡ', 'ࢡ'), + ('ࢭ', 'ࢲ'), + ('\u{8ff}', '\u{8ff}'), + ('ॸ', 'ॸ'), + ('ঀ', 'ঀ'), + ('\u{c00}', '\u{c00}'), + ('ఴ', 'ఴ'), + ('\u{c81}', '\u{c81}'), + ('\u{d01}', '\u{d01}'), + ('෦', '෯'), + ('ᛱ', 'ᛸ'), + ('ᤝ', 'ᤞ'), + ('\u{1ab0}', '\u{1abe}'), + ('\u{1cf8}', '\u{1cf9}'), + ('\u{1de7}', '\u{1df5}'), + ('₻', '₽'), + ('⏴', '⏺'), + ('✀', '✀'), + ('⭍', '⭏'), + ('⭚', '⭳'), + ('⭶', '⮕'), + ('⮘', '⮹'), + ('⮽', '⯈'), + ('⯊', '⯑'), + ('⸼', '⹂'), + ('Ꚙ', 'ꚝ'), + ('ꞔ', 'ꞟ'), + ('Ɜ', 'Ɬ'), + ('Ʞ', 'Ʇ'), + ('ꟷ', 'ꟷ'), + ('ꧠ', 'ꧾ'), + ('\u{aa7c}', 'ꩿ'), + ('ꬰ', 'ꭟ'), + ('ꭤ', 'ꭥ'), + ('\u{fe27}', '\u{fe2d}'), + ('𐆋', '𐆌'), + ('𐆠', '𐆠'), + ('\u{102e0}', '𐋻'), + ('𐌟', '𐌟'), + ('𐍐', '\u{1037a}'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐕯', '𐕯'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐡠', '𐢞'), + ('𐢧', '𐢯'), + ('𐪀', '𐪟'), + ('𐫀', '\u{10ae6}'), + ('𐫫', '𐫶'), + ('𐮀', '𐮑'), + ('𐮙', '𐮜'), + ('𐮩', '𐮯'), + ('\u{1107f}', '\u{1107f}'), + ('𑅐', '𑅶'), + ('𑇍', '𑇍'), + ('𑇚', '𑇚'), + ('𑇡', '𑇴'), + ('𑈀', '𑈑'), + ('𑈓', '𑈽'), + ('𑊰', '\u{112ea}'), + ('𑋰', '𑋹'), + ('\u{11301}', '𑌃'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('\u{1133c}', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('\u{11357}', '\u{11357}'), + ('𑍝', '𑍣'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('𑒀', '𑓇'), + ('𑓐', '𑓙'), + ('𑖀', '\u{115b5}'), + ('𑖸', '𑗉'), + ('𑘀', '𑙄'), + ('𑙐', '𑙙'), + ('𑢠', '𑣲'), + ('𑣿', '𑣿'), + ('𑫀', '𑫸'), + ('𒍯', '𒎘'), + ('𒑣', '𒑮'), + ('𒑴', '𒑴'), + ('𖩀', '𖩞'), + ('𖩠', '𖩩'), + ('𖩮', '𖩯'), + ('𖫐', '𖫭'), + ('\u{16af0}', '𖫵'), + ('𖬀', '𖭅'), + ('𖭐', '𖭙'), + ('𖭛', '𖭡'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('𛲜', '\u{1bca3}'), + ('𞠀', '𞣄'), + ('𞣇', '\u{1e8d6}'), + ('🂿', '🂿'), + ('🃠', '🃵'), + ('🄋', '🄌'), + ('🌡', '🌬'), + ('🌶', '🌶'), + ('🍽', '🍽'), + ('🎔', '🎟'), + ('🏅', '🏅'), + ('🏋', '🏎'), + ('🏔', '🏟'), + ('🏱', '🏷'), + ('🐿', '🐿'), + ('👁', '👁'), + ('📸', '📸'), + ('📽', '📾'), + ('🔾', '🔿'), + ('🕄', '🕊'), + ('🕨', '🕹'), + ('🕻', '🖣'), + ('🖥', '🗺'), + ('🙁', '🙂'), + ('🙐', '🙿'), + ('🛆', '🛏'), + ('🛠', '🛬'), + ('🛰', '🛳'), + ('🞀', '🟔'), + ('🠀', '🠋'), + ('🠐', '🡇'), + ('🡐', '🡙'), + ('🡠', '🢇'), + ('🢐', '🢭'), +]; + +pub const V8_0: &'static [(char, char)] = &[ + ('ࢳ', 'ࢴ'), + ('\u{8e3}', '\u{8e3}'), + ('ૹ', 'ૹ'), + ('ౚ', 'ౚ'), + ('ൟ', 'ൟ'), + ('Ᏽ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('₾', '₾'), + ('↊', '↋'), + ('⯬', '⯯'), + ('鿍', '鿕'), + ('\u{a69e}', '\u{a69e}'), + ('ꞏ', 'ꞏ'), + ('Ʝ', 'ꞷ'), + ('꣼', 'ꣽ'), + ('ꭠ', 'ꭣ'), + ('ꭰ', 'ꮿ'), + ('\u{fe2e}', '\u{fe2f}'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐣻', '𐣿'), + ('𐦼', '𐦽'), + ('𐧀', '𐧏'), + ('𐧒', '𐧿'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𐳺', '𐳿'), + ('\u{111c9}', '\u{111cc}'), + ('𑇛', '𑇟'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊩'), + ('\u{11300}', '\u{11300}'), + ('𑍐', '𑍐'), + ('𑗊', '\u{115dd}'), + ('𑜀', '𑜙'), + ('\u{1171d}', '\u{1172b}'), + ('𑜰', '𑜿'), + ('𒎙', '𒎙'), + ('𒒀', '𒕃'), + ('𔐀', '𔙆'), + ('𝇞', '𝇨'), + ('𝠀', '𝪋'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('🌭', '🌯'), + ('🍾', '🍿'), + ('🏏', '🏓'), + ('🏸', '🏿'), + ('📿', '📿'), + ('🕋', '🕏'), + ('🙃', '🙄'), + ('🛐', '🛐'), + ('🤐', '🤘'), + ('🦀', '🦄'), + ('🧀', '🧀'), + ('𫠠', '𬺡'), +]; + +pub const V9_0: &'static [(char, char)] = &[ + ('ࢶ', 'ࢽ'), + ('\u{8d4}', '\u{8e2}'), + ('ಀ', 'ಀ'), + ('൏', '൏'), + ('ൔ', 'ൖ'), + ('൘', '൞'), + ('൶', '൸'), + ('ᲀ', 'ᲈ'), + ('\u{1dfb}', '\u{1dfb}'), + ('⏻', '⏾'), + ('⹃', '⹄'), + ('Ɪ', 'Ɪ'), + ('\u{a8c5}', '\u{a8c5}'), + ('𐆍', '𐆎'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('\u{1123e}', '\u{1123e}'), + ('𑐀', '𑑙'), + ('𑑛', '𑑛'), + ('𑑝', '𑑝'), + ('𑙠', '𑙬'), + ('𑰀', '𑰈'), + ('𑰊', '\u{11c36}'), + ('\u{11c38}', '𑱅'), + ('𑱐', '𑱬'), + ('𑱰', '𑲏'), + ('\u{11c92}', '\u{11ca7}'), + ('𑲩', '\u{11cb6}'), + ('𖿠', '𖿠'), + ('𗀀', '𘟬'), + ('𘠀', '𘫲'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('𞤀', '\u{1e94a}'), + ('𞥐', '𞥙'), + ('𞥞', '𞥟'), + ('🆛', '🆬'), + ('🈻', '🈻'), + ('🕺', '🕺'), + ('🖤', '🖤'), + ('🛑', '🛒'), + ('🛴', '🛶'), + ('🤙', '🤞'), + ('🤠', '🤧'), + ('🤰', '🤰'), + ('🤳', '🤾'), + ('🥀', '🥋'), + ('🥐', '🥞'), + ('🦅', '🦑'), +]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/case_folding_simple.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/case_folding_simple.rs new file mode 100644 index 0000000..39f4176 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/case_folding_simple.rs @@ -0,0 +1,2800 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate case-folding-simple /tmp/ucd/12.1.0/ --chars --all-pairs +// +// ucd-generate is available on crates.io. + +pub const CASE_FOLDING_SIMPLE: &'static [(char, &'static [char])] = &[ + ('A', &['a']), + ('B', &['b']), + ('C', &['c']), + ('D', &['d']), + ('E', &['e']), + ('F', &['f']), + ('G', &['g']), + ('H', &['h']), + ('I', &['i']), + ('J', &['j']), + ('K', &['k', 'K']), + ('L', &['l']), + ('M', &['m']), + ('N', &['n']), + ('O', &['o']), + ('P', &['p']), + ('Q', &['q']), + ('R', &['r']), + ('S', &['s', 'ſ']), + ('T', &['t']), + ('U', &['u']), + ('V', &['v']), + ('W', &['w']), + ('X', &['x']), + ('Y', &['y']), + ('Z', &['z']), + ('a', &['A']), + ('b', &['B']), + ('c', &['C']), + ('d', &['D']), + ('e', &['E']), + ('f', &['F']), + ('g', &['G']), + ('h', &['H']), + ('i', &['I']), + ('j', &['J']), + ('k', &['K', 'K']), + ('l', &['L']), + ('m', &['M']), + ('n', &['N']), + ('o', &['O']), + ('p', &['P']), + ('q', &['Q']), + ('r', &['R']), + ('s', &['S', 'ſ']), + ('t', &['T']), + ('u', &['U']), + ('v', &['V']), + ('w', &['W']), + ('x', &['X']), + ('y', &['Y']), + ('z', &['Z']), + ('µ', &['Μ', 'μ']), + ('À', &['à']), + ('Á', &['á']), + ('Â', &['â']), + ('Ã', &['ã']), + ('Ä', &['ä']), + ('Å', &['å', 'Å']), + ('Æ', &['æ']), + ('Ç', &['ç']), + ('È', &['è']), + ('É', &['é']), + ('Ê', &['ê']), + ('Ë', &['ë']), + ('Ì', &['ì']), + ('Í', &['í']), + ('Î', &['î']), + ('Ï', &['ï']), + ('Ð', &['ð']), + ('Ñ', &['ñ']), + ('Ò', &['ò']), + ('Ó', &['ó']), + ('Ô', &['ô']), + ('Õ', &['õ']), + ('Ö', &['ö']), + ('Ø', &['ø']), + ('Ù', &['ù']), + ('Ú', &['ú']), + ('Û', &['û']), + ('Ü', &['ü']), + ('Ý', &['ý']), + ('Þ', &['þ']), + ('ß', &['ẞ']), + ('à', &['À']), + ('á', &['Á']), + ('â', &['Â']), + ('ã', &['Ã']), + ('ä', &['Ä']), + ('å', &['Å', 'Å']), + ('æ', &['Æ']), + ('ç', &['Ç']), + ('è', &['È']), + ('é', &['É']), + ('ê', &['Ê']), + ('ë', &['Ë']), + ('ì', &['Ì']), + ('í', &['Í']), + ('î', &['Î']), + ('ï', &['Ï']), + ('ð', &['Ð']), + ('ñ', &['Ñ']), + ('ò', &['Ò']), + ('ó', &['Ó']), + ('ô', &['Ô']), + ('õ', &['Õ']), + ('ö', &['Ö']), + ('ø', &['Ø']), + ('ù', &['Ù']), + ('ú', &['Ú']), + ('û', &['Û']), + ('ü', &['Ü']), + ('ý', &['Ý']), + ('þ', &['Þ']), + ('ÿ', &['Ÿ']), + ('Ā', &['ā']), + ('ā', &['Ā']), + ('Ă', &['ă']), + ('ă', &['Ă']), + ('Ą', &['ą']), + ('ą', &['Ą']), + ('Ć', &['ć']), + ('ć', &['Ć']), + ('Ĉ', &['ĉ']), + ('ĉ', &['Ĉ']), + ('Ċ', &['ċ']), + ('ċ', &['Ċ']), + ('Č', &['č']), + ('č', &['Č']), + ('Ď', &['ď']), + ('ď', &['Ď']), + ('Đ', &['đ']), + ('đ', &['Đ']), + ('Ē', &['ē']), + ('ē', &['Ē']), + ('Ĕ', &['ĕ']), + ('ĕ', &['Ĕ']), + ('Ė', &['ė']), + ('ė', &['Ė']), + ('Ę', &['ę']), + ('ę', &['Ę']), + ('Ě', &['ě']), + ('ě', &['Ě']), + ('Ĝ', &['ĝ']), + ('ĝ', &['Ĝ']), + ('Ğ', &['ğ']), + ('ğ', &['Ğ']), + ('Ġ', &['ġ']), + ('ġ', &['Ġ']), + ('Ģ', &['ģ']), + ('ģ', &['Ģ']), + ('Ĥ', &['ĥ']), + ('ĥ', &['Ĥ']), + ('Ħ', &['ħ']), + ('ħ', &['Ħ']), + ('Ĩ', &['ĩ']), + ('ĩ', &['Ĩ']), + ('Ī', &['ī']), + ('ī', &['Ī']), + ('Ĭ', &['ĭ']), + ('ĭ', &['Ĭ']), + ('Į', &['į']), + ('į', &['Į']), + ('IJ', &['ij']), + ('ij', &['IJ']), + ('Ĵ', &['ĵ']), + ('ĵ', &['Ĵ']), + ('Ķ', &['ķ']), + ('ķ', &['Ķ']), + ('Ĺ', &['ĺ']), + ('ĺ', &['Ĺ']), + ('Ļ', &['ļ']), + ('ļ', &['Ļ']), + ('Ľ', &['ľ']), + ('ľ', &['Ľ']), + ('Ŀ', &['ŀ']), + ('ŀ', &['Ŀ']), + ('Ł', &['ł']), + ('ł', &['Ł']), + ('Ń', &['ń']), + ('ń', &['Ń']), + ('Ņ', &['ņ']), + ('ņ', &['Ņ']), + ('Ň', &['ň']), + ('ň', &['Ň']), + ('Ŋ', &['ŋ']), + ('ŋ', &['Ŋ']), + ('Ō', &['ō']), + ('ō', &['Ō']), + ('Ŏ', &['ŏ']), + ('ŏ', &['Ŏ']), + ('Ő', &['ő']), + ('ő', &['Ő']), + ('Œ', &['œ']), + ('œ', &['Œ']), + ('Ŕ', &['ŕ']), + ('ŕ', &['Ŕ']), + ('Ŗ', &['ŗ']), + ('ŗ', &['Ŗ']), + ('Ř', &['ř']), + ('ř', &['Ř']), + ('Ś', &['ś']), + ('ś', &['Ś']), + ('Ŝ', &['ŝ']), + ('ŝ', &['Ŝ']), + ('Ş', &['ş']), + ('ş', &['Ş']), + ('Š', &['š']), + ('š', &['Š']), + ('Ţ', &['ţ']), + ('ţ', &['Ţ']), + ('Ť', &['ť']), + ('ť', &['Ť']), + ('Ŧ', &['ŧ']), + ('ŧ', &['Ŧ']), + ('Ũ', &['ũ']), + ('ũ', &['Ũ']), + ('Ū', &['ū']), + ('ū', &['Ū']), + ('Ŭ', &['ŭ']), + ('ŭ', &['Ŭ']), + ('Ů', &['ů']), + ('ů', &['Ů']), + ('Ű', &['ű']), + ('ű', &['Ű']), + ('Ų', &['ų']), + ('ų', &['Ų']), + ('Ŵ', &['ŵ']), + ('ŵ', &['Ŵ']), + ('Ŷ', &['ŷ']), + ('ŷ', &['Ŷ']), + ('Ÿ', &['ÿ']), + ('Ź', &['ź']), + ('ź', &['Ź']), + ('Ż', &['ż']), + ('ż', &['Ż']), + ('Ž', &['ž']), + ('ž', &['Ž']), + ('ſ', &['S', 's']), + ('ƀ', &['Ƀ']), + ('Ɓ', &['ɓ']), + ('Ƃ', &['ƃ']), + ('ƃ', &['Ƃ']), + ('Ƅ', &['ƅ']), + ('ƅ', &['Ƅ']), + ('Ɔ', &['ɔ']), + ('Ƈ', &['ƈ']), + ('ƈ', &['Ƈ']), + ('Ɖ', &['ɖ']), + ('Ɗ', &['ɗ']), + ('Ƌ', &['ƌ']), + ('ƌ', &['Ƌ']), + ('Ǝ', &['ǝ']), + ('Ə', &['ə']), + ('Ɛ', &['ɛ']), + ('Ƒ', &['ƒ']), + ('ƒ', &['Ƒ']), + ('Ɠ', &['ɠ']), + ('Ɣ', &['ɣ']), + ('ƕ', &['Ƕ']), + ('Ɩ', &['ɩ']), + ('Ɨ', &['ɨ']), + ('Ƙ', &['ƙ']), + ('ƙ', &['Ƙ']), + ('ƚ', &['Ƚ']), + ('Ɯ', &['ɯ']), + ('Ɲ', &['ɲ']), + ('ƞ', &['Ƞ']), + ('Ɵ', &['ɵ']), + ('Ơ', &['ơ']), + ('ơ', &['Ơ']), + ('Ƣ', &['ƣ']), + ('ƣ', &['Ƣ']), + ('Ƥ', &['ƥ']), + ('ƥ', &['Ƥ']), + ('Ʀ', &['ʀ']), + ('Ƨ', &['ƨ']), + ('ƨ', &['Ƨ']), + ('Ʃ', &['ʃ']), + ('Ƭ', &['ƭ']), + ('ƭ', &['Ƭ']), + ('Ʈ', &['ʈ']), + ('Ư', &['ư']), + ('ư', &['Ư']), + ('Ʊ', &['ʊ']), + ('Ʋ', &['ʋ']), + ('Ƴ', &['ƴ']), + ('ƴ', &['Ƴ']), + ('Ƶ', &['ƶ']), + ('ƶ', &['Ƶ']), + ('Ʒ', &['ʒ']), + ('Ƹ', &['ƹ']), + ('ƹ', &['Ƹ']), + ('Ƽ', &['ƽ']), + ('ƽ', &['Ƽ']), + ('ƿ', &['Ƿ']), + ('DŽ', &['Dž', 'dž']), + ('Dž', &['DŽ', 'dž']), + ('dž', &['DŽ', 'Dž']), + ('LJ', &['Lj', 'lj']), + ('Lj', &['LJ', 'lj']), + ('lj', &['LJ', 'Lj']), + ('NJ', &['Nj', 'nj']), + ('Nj', &['NJ', 'nj']), + ('nj', &['NJ', 'Nj']), + ('Ǎ', &['ǎ']), + ('ǎ', &['Ǎ']), + ('Ǐ', &['ǐ']), + ('ǐ', &['Ǐ']), + ('Ǒ', &['ǒ']), + ('ǒ', &['Ǒ']), + ('Ǔ', &['ǔ']), + ('ǔ', &['Ǔ']), + ('Ǖ', &['ǖ']), + ('ǖ', &['Ǖ']), + ('Ǘ', &['ǘ']), + ('ǘ', &['Ǘ']), + ('Ǚ', &['ǚ']), + ('ǚ', &['Ǚ']), + ('Ǜ', &['ǜ']), + ('ǜ', &['Ǜ']), + ('ǝ', &['Ǝ']), + ('Ǟ', &['ǟ']), + ('ǟ', &['Ǟ']), + ('Ǡ', &['ǡ']), + ('ǡ', &['Ǡ']), + ('Ǣ', &['ǣ']), + ('ǣ', &['Ǣ']), + ('Ǥ', &['ǥ']), + ('ǥ', &['Ǥ']), + ('Ǧ', &['ǧ']), + ('ǧ', &['Ǧ']), + ('Ǩ', &['ǩ']), + ('ǩ', &['Ǩ']), + ('Ǫ', &['ǫ']), + ('ǫ', &['Ǫ']), + ('Ǭ', &['ǭ']), + ('ǭ', &['Ǭ']), + ('Ǯ', &['ǯ']), + ('ǯ', &['Ǯ']), + ('DZ', &['Dz', 'dz']), + ('Dz', &['DZ', 'dz']), + ('dz', &['DZ', 'Dz']), + ('Ǵ', &['ǵ']), + ('ǵ', &['Ǵ']), + ('Ƕ', &['ƕ']), + ('Ƿ', &['ƿ']), + ('Ǹ', &['ǹ']), + ('ǹ', &['Ǹ']), + ('Ǻ', &['ǻ']), + ('ǻ', &['Ǻ']), + ('Ǽ', &['ǽ']), + ('ǽ', &['Ǽ']), + ('Ǿ', &['ǿ']), + ('ǿ', &['Ǿ']), + ('Ȁ', &['ȁ']), + ('ȁ', &['Ȁ']), + ('Ȃ', &['ȃ']), + ('ȃ', &['Ȃ']), + ('Ȅ', &['ȅ']), + ('ȅ', &['Ȅ']), + ('Ȇ', &['ȇ']), + ('ȇ', &['Ȇ']), + ('Ȉ', &['ȉ']), + ('ȉ', &['Ȉ']), + ('Ȋ', &['ȋ']), + ('ȋ', &['Ȋ']), + ('Ȍ', &['ȍ']), + ('ȍ', &['Ȍ']), + ('Ȏ', &['ȏ']), + ('ȏ', &['Ȏ']), + ('Ȑ', &['ȑ']), + ('ȑ', &['Ȑ']), + ('Ȓ', &['ȓ']), + ('ȓ', &['Ȓ']), + ('Ȕ', &['ȕ']), + ('ȕ', &['Ȕ']), + ('Ȗ', &['ȗ']), + ('ȗ', &['Ȗ']), + ('Ș', &['ș']), + ('ș', &['Ș']), + ('Ț', &['ț']), + ('ț', &['Ț']), + ('Ȝ', &['ȝ']), + ('ȝ', &['Ȝ']), + ('Ȟ', &['ȟ']), + ('ȟ', &['Ȟ']), + ('Ƞ', &['ƞ']), + ('Ȣ', &['ȣ']), + ('ȣ', &['Ȣ']), + ('Ȥ', &['ȥ']), + ('ȥ', &['Ȥ']), + ('Ȧ', &['ȧ']), + ('ȧ', &['Ȧ']), + ('Ȩ', &['ȩ']), + ('ȩ', &['Ȩ']), + ('Ȫ', &['ȫ']), + ('ȫ', &['Ȫ']), + ('Ȭ', &['ȭ']), + ('ȭ', &['Ȭ']), + ('Ȯ', &['ȯ']), + ('ȯ', &['Ȯ']), + ('Ȱ', &['ȱ']), + ('ȱ', &['Ȱ']), + ('Ȳ', &['ȳ']), + ('ȳ', &['Ȳ']), + ('Ⱥ', &['ⱥ']), + ('Ȼ', &['ȼ']), + ('ȼ', &['Ȼ']), + ('Ƚ', &['ƚ']), + ('Ⱦ', &['ⱦ']), + ('ȿ', &['Ȿ']), + ('ɀ', &['Ɀ']), + ('Ɂ', &['ɂ']), + ('ɂ', &['Ɂ']), + ('Ƀ', &['ƀ']), + ('Ʉ', &['ʉ']), + ('Ʌ', &['ʌ']), + ('Ɇ', &['ɇ']), + ('ɇ', &['Ɇ']), + ('Ɉ', &['ɉ']), + ('ɉ', &['Ɉ']), + ('Ɋ', &['ɋ']), + ('ɋ', &['Ɋ']), + ('Ɍ', &['ɍ']), + ('ɍ', &['Ɍ']), + ('Ɏ', &['ɏ']), + ('ɏ', &['Ɏ']), + ('ɐ', &['Ɐ']), + ('ɑ', &['Ɑ']), + ('ɒ', &['Ɒ']), + ('ɓ', &['Ɓ']), + ('ɔ', &['Ɔ']), + ('ɖ', &['Ɖ']), + ('ɗ', &['Ɗ']), + ('ə', &['Ə']), + ('ɛ', &['Ɛ']), + ('ɜ', &['Ɜ']), + ('ɠ', &['Ɠ']), + ('ɡ', &['Ɡ']), + ('ɣ', &['Ɣ']), + ('ɥ', &['Ɥ']), + ('ɦ', &['Ɦ']), + ('ɨ', &['Ɨ']), + ('ɩ', &['Ɩ']), + ('ɪ', &['Ɪ']), + ('ɫ', &['Ɫ']), + ('ɬ', &['Ɬ']), + ('ɯ', &['Ɯ']), + ('ɱ', &['Ɱ']), + ('ɲ', &['Ɲ']), + ('ɵ', &['Ɵ']), + ('ɽ', &['Ɽ']), + ('ʀ', &['Ʀ']), + ('ʂ', &['\u{a7c5}']), + ('ʃ', &['Ʃ']), + ('ʇ', &['Ʇ']), + ('ʈ', &['Ʈ']), + ('ʉ', &['Ʉ']), + ('ʊ', &['Ʊ']), + ('ʋ', &['Ʋ']), + ('ʌ', &['Ʌ']), + ('ʒ', &['Ʒ']), + ('ʝ', &['Ʝ']), + ('ʞ', &['Ʞ']), + ('\u{345}', &['Ι', 'ι', 'ι']), + ('Ͱ', &['ͱ']), + ('ͱ', &['Ͱ']), + ('Ͳ', &['ͳ']), + ('ͳ', &['Ͳ']), + ('Ͷ', &['ͷ']), + ('ͷ', &['Ͷ']), + ('ͻ', &['Ͻ']), + ('ͼ', &['Ͼ']), + ('ͽ', &['Ͽ']), + ('Ϳ', &['ϳ']), + ('Ά', &['ά']), + ('Έ', &['έ']), + ('Ή', &['ή']), + ('Ί', &['ί']), + ('Ό', &['ό']), + ('Ύ', &['ύ']), + ('Ώ', &['ώ']), + ('Α', &['α']), + ('Β', &['β', 'ϐ']), + ('Γ', &['γ']), + ('Δ', &['δ']), + ('Ε', &['ε', 'ϵ']), + ('Ζ', &['ζ']), + ('Η', &['η']), + ('Θ', &['θ', 'ϑ', 'ϴ']), + ('Ι', &['\u{345}', 'ι', 'ι']), + ('Κ', &['κ', 'ϰ']), + ('Λ', &['λ']), + ('Μ', &['µ', 'μ']), + ('Ν', &['ν']), + ('Ξ', &['ξ']), + ('Ο', &['ο']), + ('Π', &['π', 'ϖ']), + ('Ρ', &['ρ', 'ϱ']), + ('Σ', &['ς', 'σ']), + ('Τ', &['τ']), + ('Υ', &['υ']), + ('Φ', &['φ', 'ϕ']), + ('Χ', &['χ']), + ('Ψ', &['ψ']), + ('Ω', &['ω', 'Ω']), + ('Ϊ', &['ϊ']), + ('Ϋ', &['ϋ']), + ('ά', &['Ά']), + ('έ', &['Έ']), + ('ή', &['Ή']), + ('ί', &['Ί']), + ('α', &['Α']), + ('β', &['Β', 'ϐ']), + ('γ', &['Γ']), + ('δ', &['Δ']), + ('ε', &['Ε', 'ϵ']), + ('ζ', &['Ζ']), + ('η', &['Η']), + ('θ', &['Θ', 'ϑ', 'ϴ']), + ('ι', &['\u{345}', 'Ι', 'ι']), + ('κ', &['Κ', 'ϰ']), + ('λ', &['Λ']), + ('μ', &['µ', 'Μ']), + ('ν', &['Ν']), + ('ξ', &['Ξ']), + ('ο', &['Ο']), + ('π', &['Π', 'ϖ']), + ('ρ', &['Ρ', 'ϱ']), + ('ς', &['Σ', 'σ']), + ('σ', &['Σ', 'ς']), + ('τ', &['Τ']), + ('υ', &['Υ']), + ('φ', &['Φ', 'ϕ']), + ('χ', &['Χ']), + ('ψ', &['Ψ']), + ('ω', &['Ω', 'Ω']), + ('ϊ', &['Ϊ']), + ('ϋ', &['Ϋ']), + ('ό', &['Ό']), + ('ύ', &['Ύ']), + ('ώ', &['Ώ']), + ('Ϗ', &['ϗ']), + ('ϐ', &['Β', 'β']), + ('ϑ', &['Θ', 'θ', 'ϴ']), + ('ϕ', &['Φ', 'φ']), + ('ϖ', &['Π', 'π']), + ('ϗ', &['Ϗ']), + ('Ϙ', &['ϙ']), + ('ϙ', &['Ϙ']), + ('Ϛ', &['ϛ']), + ('ϛ', &['Ϛ']), + ('Ϝ', &['ϝ']), + ('ϝ', &['Ϝ']), + ('Ϟ', &['ϟ']), + ('ϟ', &['Ϟ']), + ('Ϡ', &['ϡ']), + ('ϡ', &['Ϡ']), + ('Ϣ', &['ϣ']), + ('ϣ', &['Ϣ']), + ('Ϥ', &['ϥ']), + ('ϥ', &['Ϥ']), + ('Ϧ', &['ϧ']), + ('ϧ', &['Ϧ']), + ('Ϩ', &['ϩ']), + ('ϩ', &['Ϩ']), + ('Ϫ', &['ϫ']), + ('ϫ', &['Ϫ']), + ('Ϭ', &['ϭ']), + ('ϭ', &['Ϭ']), + ('Ϯ', &['ϯ']), + ('ϯ', &['Ϯ']), + ('ϰ', &['Κ', 'κ']), + ('ϱ', &['Ρ', 'ρ']), + ('ϲ', &['Ϲ']), + ('ϳ', &['Ϳ']), + ('ϴ', &['Θ', 'θ', 'ϑ']), + ('ϵ', &['Ε', 'ε']), + ('Ϸ', &['ϸ']), + ('ϸ', &['Ϸ']), + ('Ϲ', &['ϲ']), + ('Ϻ', &['ϻ']), + ('ϻ', &['Ϻ']), + ('Ͻ', &['ͻ']), + ('Ͼ', &['ͼ']), + ('Ͽ', &['ͽ']), + ('Ѐ', &['ѐ']), + ('Ё', &['ё']), + ('Ђ', &['ђ']), + ('Ѓ', &['ѓ']), + ('Є', &['є']), + ('Ѕ', &['ѕ']), + ('І', &['і']), + ('Ї', &['ї']), + ('Ј', &['ј']), + ('Љ', &['љ']), + ('Њ', &['њ']), + ('Ћ', &['ћ']), + ('Ќ', &['ќ']), + ('Ѝ', &['ѝ']), + ('Ў', &['ў']), + ('Џ', &['џ']), + ('А', &['а']), + ('Б', &['б']), + ('В', &['в', 'ᲀ']), + ('Г', &['г']), + ('Д', &['д', 'ᲁ']), + ('Е', &['е']), + ('Ж', &['ж']), + ('З', &['з']), + ('И', &['и']), + ('Й', &['й']), + ('К', &['к']), + ('Л', &['л']), + ('М', &['м']), + ('Н', &['н']), + ('О', &['о', 'ᲂ']), + ('П', &['п']), + ('Р', &['р']), + ('С', &['с', 'ᲃ']), + ('Т', &['т', 'ᲄ', 'ᲅ']), + ('У', &['у']), + ('Ф', &['ф']), + ('Х', &['х']), + ('Ц', &['ц']), + ('Ч', &['ч']), + ('Ш', &['ш']), + ('Щ', &['щ']), + ('Ъ', &['ъ', 'ᲆ']), + ('Ы', &['ы']), + ('Ь', &['ь']), + ('Э', &['э']), + ('Ю', &['ю']), + ('Я', &['я']), + ('а', &['А']), + ('б', &['Б']), + ('в', &['В', 'ᲀ']), + ('г', &['Г']), + ('д', &['Д', 'ᲁ']), + ('е', &['Е']), + ('ж', &['Ж']), + ('з', &['З']), + ('и', &['И']), + ('й', &['Й']), + ('к', &['К']), + ('л', &['Л']), + ('м', &['М']), + ('н', &['Н']), + ('о', &['О', 'ᲂ']), + ('п', &['П']), + ('р', &['Р']), + ('с', &['С', 'ᲃ']), + ('т', &['Т', 'ᲄ', 'ᲅ']), + ('у', &['У']), + ('ф', &['Ф']), + ('х', &['Х']), + ('ц', &['Ц']), + ('ч', &['Ч']), + ('ш', &['Ш']), + ('щ', &['Щ']), + ('ъ', &['Ъ', 'ᲆ']), + ('ы', &['Ы']), + ('ь', &['Ь']), + ('э', &['Э']), + ('ю', &['Ю']), + ('я', &['Я']), + ('ѐ', &['Ѐ']), + ('ё', &['Ё']), + ('ђ', &['Ђ']), + ('ѓ', &['Ѓ']), + ('є', &['Є']), + ('ѕ', &['Ѕ']), + ('і', &['І']), + ('ї', &['Ї']), + ('ј', &['Ј']), + ('љ', &['Љ']), + ('њ', &['Њ']), + ('ћ', &['Ћ']), + ('ќ', &['Ќ']), + ('ѝ', &['Ѝ']), + ('ў', &['Ў']), + ('џ', &['Џ']), + ('Ѡ', &['ѡ']), + ('ѡ', &['Ѡ']), + ('Ѣ', &['ѣ', 'ᲇ']), + ('ѣ', &['Ѣ', 'ᲇ']), + ('Ѥ', &['ѥ']), + ('ѥ', &['Ѥ']), + ('Ѧ', &['ѧ']), + ('ѧ', &['Ѧ']), + ('Ѩ', &['ѩ']), + ('ѩ', &['Ѩ']), + ('Ѫ', &['ѫ']), + ('ѫ', &['Ѫ']), + ('Ѭ', &['ѭ']), + ('ѭ', &['Ѭ']), + ('Ѯ', &['ѯ']), + ('ѯ', &['Ѯ']), + ('Ѱ', &['ѱ']), + ('ѱ', &['Ѱ']), + ('Ѳ', &['ѳ']), + ('ѳ', &['Ѳ']), + ('Ѵ', &['ѵ']), + ('ѵ', &['Ѵ']), + ('Ѷ', &['ѷ']), + ('ѷ', &['Ѷ']), + ('Ѹ', &['ѹ']), + ('ѹ', &['Ѹ']), + ('Ѻ', &['ѻ']), + ('ѻ', &['Ѻ']), + ('Ѽ', &['ѽ']), + ('ѽ', &['Ѽ']), + ('Ѿ', &['ѿ']), + ('ѿ', &['Ѿ']), + ('Ҁ', &['ҁ']), + ('ҁ', &['Ҁ']), + ('Ҋ', &['ҋ']), + ('ҋ', &['Ҋ']), + ('Ҍ', &['ҍ']), + ('ҍ', &['Ҍ']), + ('Ҏ', &['ҏ']), + ('ҏ', &['Ҏ']), + ('Ґ', &['ґ']), + ('ґ', &['Ґ']), + ('Ғ', &['ғ']), + ('ғ', &['Ғ']), + ('Ҕ', &['ҕ']), + ('ҕ', &['Ҕ']), + ('Җ', &['җ']), + ('җ', &['Җ']), + ('Ҙ', &['ҙ']), + ('ҙ', &['Ҙ']), + ('Қ', &['қ']), + ('қ', &['Қ']), + ('Ҝ', &['ҝ']), + ('ҝ', &['Ҝ']), + ('Ҟ', &['ҟ']), + ('ҟ', &['Ҟ']), + ('Ҡ', &['ҡ']), + ('ҡ', &['Ҡ']), + ('Ң', &['ң']), + ('ң', &['Ң']), + ('Ҥ', &['ҥ']), + ('ҥ', &['Ҥ']), + ('Ҧ', &['ҧ']), + ('ҧ', &['Ҧ']), + ('Ҩ', &['ҩ']), + ('ҩ', &['Ҩ']), + ('Ҫ', &['ҫ']), + ('ҫ', &['Ҫ']), + ('Ҭ', &['ҭ']), + ('ҭ', &['Ҭ']), + ('Ү', &['ү']), + ('ү', &['Ү']), + ('Ұ', &['ұ']), + ('ұ', &['Ұ']), + ('Ҳ', &['ҳ']), + ('ҳ', &['Ҳ']), + ('Ҵ', &['ҵ']), + ('ҵ', &['Ҵ']), + ('Ҷ', &['ҷ']), + ('ҷ', &['Ҷ']), + ('Ҹ', &['ҹ']), + ('ҹ', &['Ҹ']), + ('Һ', &['һ']), + ('һ', &['Һ']), + ('Ҽ', &['ҽ']), + ('ҽ', &['Ҽ']), + ('Ҿ', &['ҿ']), + ('ҿ', &['Ҿ']), + ('Ӏ', &['ӏ']), + ('Ӂ', &['ӂ']), + ('ӂ', &['Ӂ']), + ('Ӄ', &['ӄ']), + ('ӄ', &['Ӄ']), + ('Ӆ', &['ӆ']), + ('ӆ', &['Ӆ']), + ('Ӈ', &['ӈ']), + ('ӈ', &['Ӈ']), + ('Ӊ', &['ӊ']), + ('ӊ', &['Ӊ']), + ('Ӌ', &['ӌ']), + ('ӌ', &['Ӌ']), + ('Ӎ', &['ӎ']), + ('ӎ', &['Ӎ']), + ('ӏ', &['Ӏ']), + ('Ӑ', &['ӑ']), + ('ӑ', &['Ӑ']), + ('Ӓ', &['ӓ']), + ('ӓ', &['Ӓ']), + ('Ӕ', &['ӕ']), + ('ӕ', &['Ӕ']), + ('Ӗ', &['ӗ']), + ('ӗ', &['Ӗ']), + ('Ә', &['ә']), + ('ә', &['Ә']), + ('Ӛ', &['ӛ']), + ('ӛ', &['Ӛ']), + ('Ӝ', &['ӝ']), + ('ӝ', &['Ӝ']), + ('Ӟ', &['ӟ']), + ('ӟ', &['Ӟ']), + ('Ӡ', &['ӡ']), + ('ӡ', &['Ӡ']), + ('Ӣ', &['ӣ']), + ('ӣ', &['Ӣ']), + ('Ӥ', &['ӥ']), + ('ӥ', &['Ӥ']), + ('Ӧ', &['ӧ']), + ('ӧ', &['Ӧ']), + ('Ө', &['ө']), + ('ө', &['Ө']), + ('Ӫ', &['ӫ']), + ('ӫ', &['Ӫ']), + ('Ӭ', &['ӭ']), + ('ӭ', &['Ӭ']), + ('Ӯ', &['ӯ']), + ('ӯ', &['Ӯ']), + ('Ӱ', &['ӱ']), + ('ӱ', &['Ӱ']), + ('Ӳ', &['ӳ']), + ('ӳ', &['Ӳ']), + ('Ӵ', &['ӵ']), + ('ӵ', &['Ӵ']), + ('Ӷ', &['ӷ']), + ('ӷ', &['Ӷ']), + ('Ӹ', &['ӹ']), + ('ӹ', &['Ӹ']), + ('Ӻ', &['ӻ']), + ('ӻ', &['Ӻ']), + ('Ӽ', &['ӽ']), + ('ӽ', &['Ӽ']), + ('Ӿ', &['ӿ']), + ('ӿ', &['Ӿ']), + ('Ԁ', &['ԁ']), + ('ԁ', &['Ԁ']), + ('Ԃ', &['ԃ']), + ('ԃ', &['Ԃ']), + ('Ԅ', &['ԅ']), + ('ԅ', &['Ԅ']), + ('Ԇ', &['ԇ']), + ('ԇ', &['Ԇ']), + ('Ԉ', &['ԉ']), + ('ԉ', &['Ԉ']), + ('Ԋ', &['ԋ']), + ('ԋ', &['Ԋ']), + ('Ԍ', &['ԍ']), + ('ԍ', &['Ԍ']), + ('Ԏ', &['ԏ']), + ('ԏ', &['Ԏ']), + ('Ԑ', &['ԑ']), + ('ԑ', &['Ԑ']), + ('Ԓ', &['ԓ']), + ('ԓ', &['Ԓ']), + ('Ԕ', &['ԕ']), + ('ԕ', &['Ԕ']), + ('Ԗ', &['ԗ']), + ('ԗ', &['Ԗ']), + ('Ԙ', &['ԙ']), + ('ԙ', &['Ԙ']), + ('Ԛ', &['ԛ']), + ('ԛ', &['Ԛ']), + ('Ԝ', &['ԝ']), + ('ԝ', &['Ԝ']), + ('Ԟ', &['ԟ']), + ('ԟ', &['Ԟ']), + ('Ԡ', &['ԡ']), + ('ԡ', &['Ԡ']), + ('Ԣ', &['ԣ']), + ('ԣ', &['Ԣ']), + ('Ԥ', &['ԥ']), + ('ԥ', &['Ԥ']), + ('Ԧ', &['ԧ']), + ('ԧ', &['Ԧ']), + ('Ԩ', &['ԩ']), + ('ԩ', &['Ԩ']), + ('Ԫ', &['ԫ']), + ('ԫ', &['Ԫ']), + ('Ԭ', &['ԭ']), + ('ԭ', &['Ԭ']), + ('Ԯ', &['ԯ']), + ('ԯ', &['Ԯ']), + ('Ա', &['ա']), + ('Բ', &['բ']), + ('Գ', &['գ']), + ('Դ', &['դ']), + ('Ե', &['ե']), + ('Զ', &['զ']), + ('Է', &['է']), + ('Ը', &['ը']), + ('Թ', &['թ']), + ('Ժ', &['ժ']), + ('Ի', &['ի']), + ('Լ', &['լ']), + ('Խ', &['խ']), + ('Ծ', &['ծ']), + ('Կ', &['կ']), + ('Հ', &['հ']), + ('Ձ', &['ձ']), + ('Ղ', &['ղ']), + ('Ճ', &['ճ']), + ('Մ', &['մ']), + ('Յ', &['յ']), + ('Ն', &['ն']), + ('Շ', &['շ']), + ('Ո', &['ո']), + ('Չ', &['չ']), + ('Պ', &['պ']), + ('Ջ', &['ջ']), + ('Ռ', &['ռ']), + ('Ս', &['ս']), + ('Վ', &['վ']), + ('Տ', &['տ']), + ('Ր', &['ր']), + ('Ց', &['ց']), + ('Ւ', &['ւ']), + ('Փ', &['փ']), + ('Ք', &['ք']), + ('Օ', &['օ']), + ('Ֆ', &['ֆ']), + ('ա', &['Ա']), + ('բ', &['Բ']), + ('գ', &['Գ']), + ('դ', &['Դ']), + ('ե', &['Ե']), + ('զ', &['Զ']), + ('է', &['Է']), + ('ը', &['Ը']), + ('թ', &['Թ']), + ('ժ', &['Ժ']), + ('ի', &['Ի']), + ('լ', &['Լ']), + ('խ', &['Խ']), + ('ծ', &['Ծ']), + ('կ', &['Կ']), + ('հ', &['Հ']), + ('ձ', &['Ձ']), + ('ղ', &['Ղ']), + ('ճ', &['Ճ']), + ('մ', &['Մ']), + ('յ', &['Յ']), + ('ն', &['Ն']), + ('շ', &['Շ']), + ('ո', &['Ո']), + ('չ', &['Չ']), + ('պ', &['Պ']), + ('ջ', &['Ջ']), + ('ռ', &['Ռ']), + ('ս', &['Ս']), + ('վ', &['Վ']), + ('տ', &['Տ']), + ('ր', &['Ր']), + ('ց', &['Ց']), + ('ւ', &['Ւ']), + ('փ', &['Փ']), + ('ք', &['Ք']), + ('օ', &['Օ']), + ('ֆ', &['Ֆ']), + ('Ⴀ', &['ⴀ']), + ('Ⴁ', &['ⴁ']), + ('Ⴂ', &['ⴂ']), + ('Ⴃ', &['ⴃ']), + ('Ⴄ', &['ⴄ']), + ('Ⴅ', &['ⴅ']), + ('Ⴆ', &['ⴆ']), + ('Ⴇ', &['ⴇ']), + ('Ⴈ', &['ⴈ']), + ('Ⴉ', &['ⴉ']), + ('Ⴊ', &['ⴊ']), + ('Ⴋ', &['ⴋ']), + ('Ⴌ', &['ⴌ']), + ('Ⴍ', &['ⴍ']), + ('Ⴎ', &['ⴎ']), + ('Ⴏ', &['ⴏ']), + ('Ⴐ', &['ⴐ']), + ('Ⴑ', &['ⴑ']), + ('Ⴒ', &['ⴒ']), + ('Ⴓ', &['ⴓ']), + ('Ⴔ', &['ⴔ']), + ('Ⴕ', &['ⴕ']), + ('Ⴖ', &['ⴖ']), + ('Ⴗ', &['ⴗ']), + ('Ⴘ', &['ⴘ']), + ('Ⴙ', &['ⴙ']), + ('Ⴚ', &['ⴚ']), + ('Ⴛ', &['ⴛ']), + ('Ⴜ', &['ⴜ']), + ('Ⴝ', &['ⴝ']), + ('Ⴞ', &['ⴞ']), + ('Ⴟ', &['ⴟ']), + ('Ⴠ', &['ⴠ']), + ('Ⴡ', &['ⴡ']), + ('Ⴢ', &['ⴢ']), + ('Ⴣ', &['ⴣ']), + ('Ⴤ', &['ⴤ']), + ('Ⴥ', &['ⴥ']), + ('Ⴧ', &['ⴧ']), + ('Ⴭ', &['ⴭ']), + ('ა', &['Ა']), + ('ბ', &['Ბ']), + ('გ', &['Გ']), + ('დ', &['Დ']), + ('ე', &['Ე']), + ('ვ', &['Ვ']), + ('ზ', &['Ზ']), + ('თ', &['Თ']), + ('ი', &['Ი']), + ('კ', &['Კ']), + ('ლ', &['Ლ']), + ('მ', &['Მ']), + ('ნ', &['Ნ']), + ('ო', &['Ო']), + ('პ', &['Პ']), + ('ჟ', &['Ჟ']), + ('რ', &['Რ']), + ('ს', &['Ს']), + ('ტ', &['Ტ']), + ('უ', &['Უ']), + ('ფ', &['Ფ']), + ('ქ', &['Ქ']), + ('ღ', &['Ღ']), + ('ყ', &['Ყ']), + ('შ', &['Შ']), + ('ჩ', &['Ჩ']), + ('ც', &['Ც']), + ('ძ', &['Ძ']), + ('წ', &['Წ']), + ('ჭ', &['Ჭ']), + ('ხ', &['Ხ']), + ('ჯ', &['Ჯ']), + ('ჰ', &['Ჰ']), + ('ჱ', &['Ჱ']), + ('ჲ', &['Ჲ']), + ('ჳ', &['Ჳ']), + ('ჴ', &['Ჴ']), + ('ჵ', &['Ჵ']), + ('ჶ', &['Ჶ']), + ('ჷ', &['Ჷ']), + ('ჸ', &['Ჸ']), + ('ჹ', &['Ჹ']), + ('ჺ', &['Ჺ']), + ('ჽ', &['Ჽ']), + ('ჾ', &['Ჾ']), + ('ჿ', &['Ჿ']), + ('Ꭰ', &['ꭰ']), + ('Ꭱ', &['ꭱ']), + ('Ꭲ', &['ꭲ']), + ('Ꭳ', &['ꭳ']), + ('Ꭴ', &['ꭴ']), + ('Ꭵ', &['ꭵ']), + ('Ꭶ', &['ꭶ']), + ('Ꭷ', &['ꭷ']), + ('Ꭸ', &['ꭸ']), + ('Ꭹ', &['ꭹ']), + ('Ꭺ', &['ꭺ']), + ('Ꭻ', &['ꭻ']), + ('Ꭼ', &['ꭼ']), + ('Ꭽ', &['ꭽ']), + ('Ꭾ', &['ꭾ']), + ('Ꭿ', &['ꭿ']), + ('Ꮀ', &['ꮀ']), + ('Ꮁ', &['ꮁ']), + ('Ꮂ', &['ꮂ']), + ('Ꮃ', &['ꮃ']), + ('Ꮄ', &['ꮄ']), + ('Ꮅ', &['ꮅ']), + ('Ꮆ', &['ꮆ']), + ('Ꮇ', &['ꮇ']), + ('Ꮈ', &['ꮈ']), + ('Ꮉ', &['ꮉ']), + ('Ꮊ', &['ꮊ']), + ('Ꮋ', &['ꮋ']), + ('Ꮌ', &['ꮌ']), + ('Ꮍ', &['ꮍ']), + ('Ꮎ', &['ꮎ']), + ('Ꮏ', &['ꮏ']), + ('Ꮐ', &['ꮐ']), + ('Ꮑ', &['ꮑ']), + ('Ꮒ', &['ꮒ']), + ('Ꮓ', &['ꮓ']), + ('Ꮔ', &['ꮔ']), + ('Ꮕ', &['ꮕ']), + ('Ꮖ', &['ꮖ']), + ('Ꮗ', &['ꮗ']), + ('Ꮘ', &['ꮘ']), + ('Ꮙ', &['ꮙ']), + ('Ꮚ', &['ꮚ']), + ('Ꮛ', &['ꮛ']), + ('Ꮜ', &['ꮜ']), + ('Ꮝ', &['ꮝ']), + ('Ꮞ', &['ꮞ']), + ('Ꮟ', &['ꮟ']), + ('Ꮠ', &['ꮠ']), + ('Ꮡ', &['ꮡ']), + ('Ꮢ', &['ꮢ']), + ('Ꮣ', &['ꮣ']), + ('Ꮤ', &['ꮤ']), + ('Ꮥ', &['ꮥ']), + ('Ꮦ', &['ꮦ']), + ('Ꮧ', &['ꮧ']), + ('Ꮨ', &['ꮨ']), + ('Ꮩ', &['ꮩ']), + ('Ꮪ', &['ꮪ']), + ('Ꮫ', &['ꮫ']), + ('Ꮬ', &['ꮬ']), + ('Ꮭ', &['ꮭ']), + ('Ꮮ', &['ꮮ']), + ('Ꮯ', &['ꮯ']), + ('Ꮰ', &['ꮰ']), + ('Ꮱ', &['ꮱ']), + ('Ꮲ', &['ꮲ']), + ('Ꮳ', &['ꮳ']), + ('Ꮴ', &['ꮴ']), + ('Ꮵ', &['ꮵ']), + ('Ꮶ', &['ꮶ']), + ('Ꮷ', &['ꮷ']), + ('Ꮸ', &['ꮸ']), + ('Ꮹ', &['ꮹ']), + ('Ꮺ', &['ꮺ']), + ('Ꮻ', &['ꮻ']), + ('Ꮼ', &['ꮼ']), + ('Ꮽ', &['ꮽ']), + ('Ꮾ', &['ꮾ']), + ('Ꮿ', &['ꮿ']), + ('Ᏸ', &['ᏸ']), + ('Ᏹ', &['ᏹ']), + ('Ᏺ', &['ᏺ']), + ('Ᏻ', &['ᏻ']), + ('Ᏼ', &['ᏼ']), + ('Ᏽ', &['ᏽ']), + ('ᏸ', &['Ᏸ']), + ('ᏹ', &['Ᏹ']), + ('ᏺ', &['Ᏺ']), + ('ᏻ', &['Ᏻ']), + ('ᏼ', &['Ᏼ']), + ('ᏽ', &['Ᏽ']), + ('ᲀ', &['В', 'в']), + ('ᲁ', &['Д', 'д']), + ('ᲂ', &['О', 'о']), + ('ᲃ', &['С', 'с']), + ('ᲄ', &['Т', 'т', 'ᲅ']), + ('ᲅ', &['Т', 'т', 'ᲄ']), + ('ᲆ', &['Ъ', 'ъ']), + ('ᲇ', &['Ѣ', 'ѣ']), + ('ᲈ', &['Ꙋ', 'ꙋ']), + ('Ა', &['ა']), + ('Ბ', &['ბ']), + ('Გ', &['გ']), + ('Დ', &['დ']), + ('Ე', &['ე']), + ('Ვ', &['ვ']), + ('Ზ', &['ზ']), + ('Თ', &['თ']), + ('Ი', &['ი']), + ('Კ', &['კ']), + ('Ლ', &['ლ']), + ('Მ', &['მ']), + ('Ნ', &['ნ']), + ('Ო', &['ო']), + ('Პ', &['პ']), + ('Ჟ', &['ჟ']), + ('Რ', &['რ']), + ('Ს', &['ს']), + ('Ტ', &['ტ']), + ('Უ', &['უ']), + ('Ფ', &['ფ']), + ('Ქ', &['ქ']), + ('Ღ', &['ღ']), + ('Ყ', &['ყ']), + ('Შ', &['შ']), + ('Ჩ', &['ჩ']), + ('Ც', &['ც']), + ('Ძ', &['ძ']), + ('Წ', &['წ']), + ('Ჭ', &['ჭ']), + ('Ხ', &['ხ']), + ('Ჯ', &['ჯ']), + ('Ჰ', &['ჰ']), + ('Ჱ', &['ჱ']), + ('Ჲ', &['ჲ']), + ('Ჳ', &['ჳ']), + ('Ჴ', &['ჴ']), + ('Ჵ', &['ჵ']), + ('Ჶ', &['ჶ']), + ('Ჷ', &['ჷ']), + ('Ჸ', &['ჸ']), + ('Ჹ', &['ჹ']), + ('Ჺ', &['ჺ']), + ('Ჽ', &['ჽ']), + ('Ჾ', &['ჾ']), + ('Ჿ', &['ჿ']), + ('ᵹ', &['Ᵹ']), + ('ᵽ', &['Ᵽ']), + ('ᶎ', &['\u{a7c6}']), + ('Ḁ', &['ḁ']), + ('ḁ', &['Ḁ']), + ('Ḃ', &['ḃ']), + ('ḃ', &['Ḃ']), + ('Ḅ', &['ḅ']), + ('ḅ', &['Ḅ']), + ('Ḇ', &['ḇ']), + ('ḇ', &['Ḇ']), + ('Ḉ', &['ḉ']), + ('ḉ', &['Ḉ']), + ('Ḋ', &['ḋ']), + ('ḋ', &['Ḋ']), + ('Ḍ', &['ḍ']), + ('ḍ', &['Ḍ']), + ('Ḏ', &['ḏ']), + ('ḏ', &['Ḏ']), + ('Ḑ', &['ḑ']), + ('ḑ', &['Ḑ']), + ('Ḓ', &['ḓ']), + ('ḓ', &['Ḓ']), + ('Ḕ', &['ḕ']), + ('ḕ', &['Ḕ']), + ('Ḗ', &['ḗ']), + ('ḗ', &['Ḗ']), + ('Ḙ', &['ḙ']), + ('ḙ', &['Ḙ']), + ('Ḛ', &['ḛ']), + ('ḛ', &['Ḛ']), + ('Ḝ', &['ḝ']), + ('ḝ', &['Ḝ']), + ('Ḟ', &['ḟ']), + ('ḟ', &['Ḟ']), + ('Ḡ', &['ḡ']), + ('ḡ', &['Ḡ']), + ('Ḣ', &['ḣ']), + ('ḣ', &['Ḣ']), + ('Ḥ', &['ḥ']), + ('ḥ', &['Ḥ']), + ('Ḧ', &['ḧ']), + ('ḧ', &['Ḧ']), + ('Ḩ', &['ḩ']), + ('ḩ', &['Ḩ']), + ('Ḫ', &['ḫ']), + ('ḫ', &['Ḫ']), + ('Ḭ', &['ḭ']), + ('ḭ', &['Ḭ']), + ('Ḯ', &['ḯ']), + ('ḯ', &['Ḯ']), + ('Ḱ', &['ḱ']), + ('ḱ', &['Ḱ']), + ('Ḳ', &['ḳ']), + ('ḳ', &['Ḳ']), + ('Ḵ', &['ḵ']), + ('ḵ', &['Ḵ']), + ('Ḷ', &['ḷ']), + ('ḷ', &['Ḷ']), + ('Ḹ', &['ḹ']), + ('ḹ', &['Ḹ']), + ('Ḻ', &['ḻ']), + ('ḻ', &['Ḻ']), + ('Ḽ', &['ḽ']), + ('ḽ', &['Ḽ']), + ('Ḿ', &['ḿ']), + ('ḿ', &['Ḿ']), + ('Ṁ', &['ṁ']), + ('ṁ', &['Ṁ']), + ('Ṃ', &['ṃ']), + ('ṃ', &['Ṃ']), + ('Ṅ', &['ṅ']), + ('ṅ', &['Ṅ']), + ('Ṇ', &['ṇ']), + ('ṇ', &['Ṇ']), + ('Ṉ', &['ṉ']), + ('ṉ', &['Ṉ']), + ('Ṋ', &['ṋ']), + ('ṋ', &['Ṋ']), + ('Ṍ', &['ṍ']), + ('ṍ', &['Ṍ']), + ('Ṏ', &['ṏ']), + ('ṏ', &['Ṏ']), + ('Ṑ', &['ṑ']), + ('ṑ', &['Ṑ']), + ('Ṓ', &['ṓ']), + ('ṓ', &['Ṓ']), + ('Ṕ', &['ṕ']), + ('ṕ', &['Ṕ']), + ('Ṗ', &['ṗ']), + ('ṗ', &['Ṗ']), + ('Ṙ', &['ṙ']), + ('ṙ', &['Ṙ']), + ('Ṛ', &['ṛ']), + ('ṛ', &['Ṛ']), + ('Ṝ', &['ṝ']), + ('ṝ', &['Ṝ']), + ('Ṟ', &['ṟ']), + ('ṟ', &['Ṟ']), + ('Ṡ', &['ṡ', 'ẛ']), + ('ṡ', &['Ṡ', 'ẛ']), + ('Ṣ', &['ṣ']), + ('ṣ', &['Ṣ']), + ('Ṥ', &['ṥ']), + ('ṥ', &['Ṥ']), + ('Ṧ', &['ṧ']), + ('ṧ', &['Ṧ']), + ('Ṩ', &['ṩ']), + ('ṩ', &['Ṩ']), + ('Ṫ', &['ṫ']), + ('ṫ', &['Ṫ']), + ('Ṭ', &['ṭ']), + ('ṭ', &['Ṭ']), + ('Ṯ', &['ṯ']), + ('ṯ', &['Ṯ']), + ('Ṱ', &['ṱ']), + ('ṱ', &['Ṱ']), + ('Ṳ', &['ṳ']), + ('ṳ', &['Ṳ']), + ('Ṵ', &['ṵ']), + ('ṵ', &['Ṵ']), + ('Ṷ', &['ṷ']), + ('ṷ', &['Ṷ']), + ('Ṹ', &['ṹ']), + ('ṹ', &['Ṹ']), + ('Ṻ', &['ṻ']), + ('ṻ', &['Ṻ']), + ('Ṽ', &['ṽ']), + ('ṽ', &['Ṽ']), + ('Ṿ', &['ṿ']), + ('ṿ', &['Ṿ']), + ('Ẁ', &['ẁ']), + ('ẁ', &['Ẁ']), + ('Ẃ', &['ẃ']), + ('ẃ', &['Ẃ']), + ('Ẅ', &['ẅ']), + ('ẅ', &['Ẅ']), + ('Ẇ', &['ẇ']), + ('ẇ', &['Ẇ']), + ('Ẉ', &['ẉ']), + ('ẉ', &['Ẉ']), + ('Ẋ', &['ẋ']), + ('ẋ', &['Ẋ']), + ('Ẍ', &['ẍ']), + ('ẍ', &['Ẍ']), + ('Ẏ', &['ẏ']), + ('ẏ', &['Ẏ']), + ('Ẑ', &['ẑ']), + ('ẑ', &['Ẑ']), + ('Ẓ', &['ẓ']), + ('ẓ', &['Ẓ']), + ('Ẕ', &['ẕ']), + ('ẕ', &['Ẕ']), + ('ẛ', &['Ṡ', 'ṡ']), + ('ẞ', &['ß']), + ('Ạ', &['ạ']), + ('ạ', &['Ạ']), + ('Ả', &['ả']), + ('ả', &['Ả']), + ('Ấ', &['ấ']), + ('ấ', &['Ấ']), + ('Ầ', &['ầ']), + ('ầ', &['Ầ']), + ('Ẩ', &['ẩ']), + ('ẩ', &['Ẩ']), + ('Ẫ', &['ẫ']), + ('ẫ', &['Ẫ']), + ('Ậ', &['ậ']), + ('ậ', &['Ậ']), + ('Ắ', &['ắ']), + ('ắ', &['Ắ']), + ('Ằ', &['ằ']), + ('ằ', &['Ằ']), + ('Ẳ', &['ẳ']), + ('ẳ', &['Ẳ']), + ('Ẵ', &['ẵ']), + ('ẵ', &['Ẵ']), + ('Ặ', &['ặ']), + ('ặ', &['Ặ']), + ('Ẹ', &['ẹ']), + ('ẹ', &['Ẹ']), + ('Ẻ', &['ẻ']), + ('ẻ', &['Ẻ']), + ('Ẽ', &['ẽ']), + ('ẽ', &['Ẽ']), + ('Ế', &['ế']), + ('ế', &['Ế']), + ('Ề', &['ề']), + ('ề', &['Ề']), + ('Ể', &['ể']), + ('ể', &['Ể']), + ('Ễ', &['ễ']), + ('ễ', &['Ễ']), + ('Ệ', &['ệ']), + ('ệ', &['Ệ']), + ('Ỉ', &['ỉ']), + ('ỉ', &['Ỉ']), + ('Ị', &['ị']), + ('ị', &['Ị']), + ('Ọ', &['ọ']), + ('ọ', &['Ọ']), + ('Ỏ', &['ỏ']), + ('ỏ', &['Ỏ']), + ('Ố', &['ố']), + ('ố', &['Ố']), + ('Ồ', &['ồ']), + ('ồ', &['Ồ']), + ('Ổ', &['ổ']), + ('ổ', &['Ổ']), + ('Ỗ', &['ỗ']), + ('ỗ', &['Ỗ']), + ('Ộ', &['ộ']), + ('ộ', &['Ộ']), + ('Ớ', &['ớ']), + ('ớ', &['Ớ']), + ('Ờ', &['ờ']), + ('ờ', &['Ờ']), + ('Ở', &['ở']), + ('ở', &['Ở']), + ('Ỡ', &['ỡ']), + ('ỡ', &['Ỡ']), + ('Ợ', &['ợ']), + ('ợ', &['Ợ']), + ('Ụ', &['ụ']), + ('ụ', &['Ụ']), + ('Ủ', &['ủ']), + ('ủ', &['Ủ']), + ('Ứ', &['ứ']), + ('ứ', &['Ứ']), + ('Ừ', &['ừ']), + ('ừ', &['Ừ']), + ('Ử', &['ử']), + ('ử', &['Ử']), + ('Ữ', &['ữ']), + ('ữ', &['Ữ']), + ('Ự', &['ự']), + ('ự', &['Ự']), + ('Ỳ', &['ỳ']), + ('ỳ', &['Ỳ']), + ('Ỵ', &['ỵ']), + ('ỵ', &['Ỵ']), + ('Ỷ', &['ỷ']), + ('ỷ', &['Ỷ']), + ('Ỹ', &['ỹ']), + ('ỹ', &['Ỹ']), + ('Ỻ', &['ỻ']), + ('ỻ', &['Ỻ']), + ('Ỽ', &['ỽ']), + ('ỽ', &['Ỽ']), + ('Ỿ', &['ỿ']), + ('ỿ', &['Ỿ']), + ('ἀ', &['Ἀ']), + ('ἁ', &['Ἁ']), + ('ἂ', &['Ἂ']), + ('ἃ', &['Ἃ']), + ('ἄ', &['Ἄ']), + ('ἅ', &['Ἅ']), + ('ἆ', &['Ἆ']), + ('ἇ', &['Ἇ']), + ('Ἀ', &['ἀ']), + ('Ἁ', &['ἁ']), + ('Ἂ', &['ἂ']), + ('Ἃ', &['ἃ']), + ('Ἄ', &['ἄ']), + ('Ἅ', &['ἅ']), + ('Ἆ', &['ἆ']), + ('Ἇ', &['ἇ']), + ('ἐ', &['Ἐ']), + ('ἑ', &['Ἑ']), + ('ἒ', &['Ἒ']), + ('ἓ', &['Ἓ']), + ('ἔ', &['Ἔ']), + ('ἕ', &['Ἕ']), + ('Ἐ', &['ἐ']), + ('Ἑ', &['ἑ']), + ('Ἒ', &['ἒ']), + ('Ἓ', &['ἓ']), + ('Ἔ', &['ἔ']), + ('Ἕ', &['ἕ']), + ('ἠ', &['Ἠ']), + ('ἡ', &['Ἡ']), + ('ἢ', &['Ἢ']), + ('ἣ', &['Ἣ']), + ('ἤ', &['Ἤ']), + ('ἥ', &['Ἥ']), + ('ἦ', &['Ἦ']), + ('ἧ', &['Ἧ']), + ('Ἠ', &['ἠ']), + ('Ἡ', &['ἡ']), + ('Ἢ', &['ἢ']), + ('Ἣ', &['ἣ']), + ('Ἤ', &['ἤ']), + ('Ἥ', &['ἥ']), + ('Ἦ', &['ἦ']), + ('Ἧ', &['ἧ']), + ('ἰ', &['Ἰ']), + ('ἱ', &['Ἱ']), + ('ἲ', &['Ἲ']), + ('ἳ', &['Ἳ']), + ('ἴ', &['Ἴ']), + ('ἵ', &['Ἵ']), + ('ἶ', &['Ἶ']), + ('ἷ', &['Ἷ']), + ('Ἰ', &['ἰ']), + ('Ἱ', &['ἱ']), + ('Ἲ', &['ἲ']), + ('Ἳ', &['ἳ']), + ('Ἴ', &['ἴ']), + ('Ἵ', &['ἵ']), + ('Ἶ', &['ἶ']), + ('Ἷ', &['ἷ']), + ('ὀ', &['Ὀ']), + ('ὁ', &['Ὁ']), + ('ὂ', &['Ὂ']), + ('ὃ', &['Ὃ']), + ('ὄ', &['Ὄ']), + ('ὅ', &['Ὅ']), + ('Ὀ', &['ὀ']), + ('Ὁ', &['ὁ']), + ('Ὂ', &['ὂ']), + ('Ὃ', &['ὃ']), + ('Ὄ', &['ὄ']), + ('Ὅ', &['ὅ']), + ('ὑ', &['Ὑ']), + ('ὓ', &['Ὓ']), + ('ὕ', &['Ὕ']), + ('ὗ', &['Ὗ']), + ('Ὑ', &['ὑ']), + ('Ὓ', &['ὓ']), + ('Ὕ', &['ὕ']), + ('Ὗ', &['ὗ']), + ('ὠ', &['Ὠ']), + ('ὡ', &['Ὡ']), + ('ὢ', &['Ὢ']), + ('ὣ', &['Ὣ']), + ('ὤ', &['Ὤ']), + ('ὥ', &['Ὥ']), + ('ὦ', &['Ὦ']), + ('ὧ', &['Ὧ']), + ('Ὠ', &['ὠ']), + ('Ὡ', &['ὡ']), + ('Ὢ', &['ὢ']), + ('Ὣ', &['ὣ']), + ('Ὤ', &['ὤ']), + ('Ὥ', &['ὥ']), + ('Ὦ', &['ὦ']), + ('Ὧ', &['ὧ']), + ('ὰ', &['Ὰ']), + ('ά', &['Ά']), + ('ὲ', &['Ὲ']), + ('έ', &['Έ']), + ('ὴ', &['Ὴ']), + ('ή', &['Ή']), + ('ὶ', &['Ὶ']), + ('ί', &['Ί']), + ('ὸ', &['Ὸ']), + ('ό', &['Ό']), + ('ὺ', &['Ὺ']), + ('ύ', &['Ύ']), + ('ὼ', &['Ὼ']), + ('ώ', &['Ώ']), + ('ᾀ', &['ᾈ']), + ('ᾁ', &['ᾉ']), + ('ᾂ', &['ᾊ']), + ('ᾃ', &['ᾋ']), + ('ᾄ', &['ᾌ']), + ('ᾅ', &['ᾍ']), + ('ᾆ', &['ᾎ']), + ('ᾇ', &['ᾏ']), + ('ᾈ', &['ᾀ']), + ('ᾉ', &['ᾁ']), + ('ᾊ', &['ᾂ']), + ('ᾋ', &['ᾃ']), + ('ᾌ', &['ᾄ']), + ('ᾍ', &['ᾅ']), + ('ᾎ', &['ᾆ']), + ('ᾏ', &['ᾇ']), + ('ᾐ', &['ᾘ']), + ('ᾑ', &['ᾙ']), + ('ᾒ', &['ᾚ']), + ('ᾓ', &['ᾛ']), + ('ᾔ', &['ᾜ']), + ('ᾕ', &['ᾝ']), + ('ᾖ', &['ᾞ']), + ('ᾗ', &['ᾟ']), + ('ᾘ', &['ᾐ']), + ('ᾙ', &['ᾑ']), + ('ᾚ', &['ᾒ']), + ('ᾛ', &['ᾓ']), + ('ᾜ', &['ᾔ']), + ('ᾝ', &['ᾕ']), + ('ᾞ', &['ᾖ']), + ('ᾟ', &['ᾗ']), + ('ᾠ', &['ᾨ']), + ('ᾡ', &['ᾩ']), + ('ᾢ', &['ᾪ']), + ('ᾣ', &['ᾫ']), + ('ᾤ', &['ᾬ']), + ('ᾥ', &['ᾭ']), + ('ᾦ', &['ᾮ']), + ('ᾧ', &['ᾯ']), + ('ᾨ', &['ᾠ']), + ('ᾩ', &['ᾡ']), + ('ᾪ', &['ᾢ']), + ('ᾫ', &['ᾣ']), + ('ᾬ', &['ᾤ']), + ('ᾭ', &['ᾥ']), + ('ᾮ', &['ᾦ']), + ('ᾯ', &['ᾧ']), + ('ᾰ', &['Ᾰ']), + ('ᾱ', &['Ᾱ']), + ('ᾳ', &['ᾼ']), + ('Ᾰ', &['ᾰ']), + ('Ᾱ', &['ᾱ']), + ('Ὰ', &['ὰ']), + ('Ά', &['ά']), + ('ᾼ', &['ᾳ']), + ('ι', &['\u{345}', 'Ι', 'ι']), + ('ῃ', &['ῌ']), + ('Ὲ', &['ὲ']), + ('Έ', &['έ']), + ('Ὴ', &['ὴ']), + ('Ή', &['ή']), + ('ῌ', &['ῃ']), + ('ῐ', &['Ῐ']), + ('ῑ', &['Ῑ']), + ('Ῐ', &['ῐ']), + ('Ῑ', &['ῑ']), + ('Ὶ', &['ὶ']), + ('Ί', &['ί']), + ('ῠ', &['Ῠ']), + ('ῡ', &['Ῡ']), + ('ῥ', &['Ῥ']), + ('Ῠ', &['ῠ']), + ('Ῡ', &['ῡ']), + ('Ὺ', &['ὺ']), + ('Ύ', &['ύ']), + ('Ῥ', &['ῥ']), + ('ῳ', &['ῼ']), + ('Ὸ', &['ὸ']), + ('Ό', &['ό']), + ('Ὼ', &['ὼ']), + ('Ώ', &['ώ']), + ('ῼ', &['ῳ']), + ('Ω', &['Ω', 'ω']), + ('K', &['K', 'k']), + ('Å', &['Å', 'å']), + ('Ⅎ', &['ⅎ']), + ('ⅎ', &['Ⅎ']), + ('Ⅰ', &['ⅰ']), + ('Ⅱ', &['ⅱ']), + ('Ⅲ', &['ⅲ']), + ('Ⅳ', &['ⅳ']), + ('Ⅴ', &['ⅴ']), + ('Ⅵ', &['ⅵ']), + ('Ⅶ', &['ⅶ']), + ('Ⅷ', &['ⅷ']), + ('Ⅸ', &['ⅸ']), + ('Ⅹ', &['ⅹ']), + ('Ⅺ', &['ⅺ']), + ('Ⅻ', &['ⅻ']), + ('Ⅼ', &['ⅼ']), + ('Ⅽ', &['ⅽ']), + ('Ⅾ', &['ⅾ']), + ('Ⅿ', &['ⅿ']), + ('ⅰ', &['Ⅰ']), + ('ⅱ', &['Ⅱ']), + ('ⅲ', &['Ⅲ']), + ('ⅳ', &['Ⅳ']), + ('ⅴ', &['Ⅴ']), + ('ⅵ', &['Ⅵ']), + ('ⅶ', &['Ⅶ']), + ('ⅷ', &['Ⅷ']), + ('ⅸ', &['Ⅸ']), + ('ⅹ', &['Ⅹ']), + ('ⅺ', &['Ⅺ']), + ('ⅻ', &['Ⅻ']), + ('ⅼ', &['Ⅼ']), + ('ⅽ', &['Ⅽ']), + ('ⅾ', &['Ⅾ']), + ('ⅿ', &['Ⅿ']), + ('Ↄ', &['ↄ']), + ('ↄ', &['Ↄ']), + ('Ⓐ', &['ⓐ']), + ('Ⓑ', &['ⓑ']), + ('Ⓒ', &['ⓒ']), + ('Ⓓ', &['ⓓ']), + ('Ⓔ', &['ⓔ']), + ('Ⓕ', &['ⓕ']), + ('Ⓖ', &['ⓖ']), + ('Ⓗ', &['ⓗ']), + ('Ⓘ', &['ⓘ']), + ('Ⓙ', &['ⓙ']), + ('Ⓚ', &['ⓚ']), + ('Ⓛ', &['ⓛ']), + ('Ⓜ', &['ⓜ']), + ('Ⓝ', &['ⓝ']), + ('Ⓞ', &['ⓞ']), + ('Ⓟ', &['ⓟ']), + ('Ⓠ', &['ⓠ']), + ('Ⓡ', &['ⓡ']), + ('Ⓢ', &['ⓢ']), + ('Ⓣ', &['ⓣ']), + ('Ⓤ', &['ⓤ']), + ('Ⓥ', &['ⓥ']), + ('Ⓦ', &['ⓦ']), + ('Ⓧ', &['ⓧ']), + ('Ⓨ', &['ⓨ']), + ('Ⓩ', &['ⓩ']), + ('ⓐ', &['Ⓐ']), + ('ⓑ', &['Ⓑ']), + ('ⓒ', &['Ⓒ']), + ('ⓓ', &['Ⓓ']), + ('ⓔ', &['Ⓔ']), + ('ⓕ', &['Ⓕ']), + ('ⓖ', &['Ⓖ']), + ('ⓗ', &['Ⓗ']), + ('ⓘ', &['Ⓘ']), + ('ⓙ', &['Ⓙ']), + ('ⓚ', &['Ⓚ']), + ('ⓛ', &['Ⓛ']), + ('ⓜ', &['Ⓜ']), + ('ⓝ', &['Ⓝ']), + ('ⓞ', &['Ⓞ']), + ('ⓟ', &['Ⓟ']), + ('ⓠ', &['Ⓠ']), + ('ⓡ', &['Ⓡ']), + ('ⓢ', &['Ⓢ']), + ('ⓣ', &['Ⓣ']), + ('ⓤ', &['Ⓤ']), + ('ⓥ', &['Ⓥ']), + ('ⓦ', &['Ⓦ']), + ('ⓧ', &['Ⓧ']), + ('ⓨ', &['Ⓨ']), + ('ⓩ', &['Ⓩ']), + ('Ⰰ', &['ⰰ']), + ('Ⰱ', &['ⰱ']), + ('Ⰲ', &['ⰲ']), + ('Ⰳ', &['ⰳ']), + ('Ⰴ', &['ⰴ']), + ('Ⰵ', &['ⰵ']), + ('Ⰶ', &['ⰶ']), + ('Ⰷ', &['ⰷ']), + ('Ⰸ', &['ⰸ']), + ('Ⰹ', &['ⰹ']), + ('Ⰺ', &['ⰺ']), + ('Ⰻ', &['ⰻ']), + ('Ⰼ', &['ⰼ']), + ('Ⰽ', &['ⰽ']), + ('Ⰾ', &['ⰾ']), + ('Ⰿ', &['ⰿ']), + ('Ⱀ', &['ⱀ']), + ('Ⱁ', &['ⱁ']), + ('Ⱂ', &['ⱂ']), + ('Ⱃ', &['ⱃ']), + ('Ⱄ', &['ⱄ']), + ('Ⱅ', &['ⱅ']), + ('Ⱆ', &['ⱆ']), + ('Ⱇ', &['ⱇ']), + ('Ⱈ', &['ⱈ']), + ('Ⱉ', &['ⱉ']), + ('Ⱊ', &['ⱊ']), + ('Ⱋ', &['ⱋ']), + ('Ⱌ', &['ⱌ']), + ('Ⱍ', &['ⱍ']), + ('Ⱎ', &['ⱎ']), + ('Ⱏ', &['ⱏ']), + ('Ⱐ', &['ⱐ']), + ('Ⱑ', &['ⱑ']), + ('Ⱒ', &['ⱒ']), + ('Ⱓ', &['ⱓ']), + ('Ⱔ', &['ⱔ']), + ('Ⱕ', &['ⱕ']), + ('Ⱖ', &['ⱖ']), + ('Ⱗ', &['ⱗ']), + ('Ⱘ', &['ⱘ']), + ('Ⱙ', &['ⱙ']), + ('Ⱚ', &['ⱚ']), + ('Ⱛ', &['ⱛ']), + ('Ⱜ', &['ⱜ']), + ('Ⱝ', &['ⱝ']), + ('Ⱞ', &['ⱞ']), + ('ⰰ', &['Ⰰ']), + ('ⰱ', &['Ⰱ']), + ('ⰲ', &['Ⰲ']), + ('ⰳ', &['Ⰳ']), + ('ⰴ', &['Ⰴ']), + ('ⰵ', &['Ⰵ']), + ('ⰶ', &['Ⰶ']), + ('ⰷ', &['Ⰷ']), + ('ⰸ', &['Ⰸ']), + ('ⰹ', &['Ⰹ']), + ('ⰺ', &['Ⰺ']), + ('ⰻ', &['Ⰻ']), + ('ⰼ', &['Ⰼ']), + ('ⰽ', &['Ⰽ']), + ('ⰾ', &['Ⰾ']), + ('ⰿ', &['Ⰿ']), + ('ⱀ', &['Ⱀ']), + ('ⱁ', &['Ⱁ']), + ('ⱂ', &['Ⱂ']), + ('ⱃ', &['Ⱃ']), + ('ⱄ', &['Ⱄ']), + ('ⱅ', &['Ⱅ']), + ('ⱆ', &['Ⱆ']), + ('ⱇ', &['Ⱇ']), + ('ⱈ', &['Ⱈ']), + ('ⱉ', &['Ⱉ']), + ('ⱊ', &['Ⱊ']), + ('ⱋ', &['Ⱋ']), + ('ⱌ', &['Ⱌ']), + ('ⱍ', &['Ⱍ']), + ('ⱎ', &['Ⱎ']), + ('ⱏ', &['Ⱏ']), + ('ⱐ', &['Ⱐ']), + ('ⱑ', &['Ⱑ']), + ('ⱒ', &['Ⱒ']), + ('ⱓ', &['Ⱓ']), + ('ⱔ', &['Ⱔ']), + ('ⱕ', &['Ⱕ']), + ('ⱖ', &['Ⱖ']), + ('ⱗ', &['Ⱗ']), + ('ⱘ', &['Ⱘ']), + ('ⱙ', &['Ⱙ']), + ('ⱚ', &['Ⱚ']), + ('ⱛ', &['Ⱛ']), + ('ⱜ', &['Ⱜ']), + ('ⱝ', &['Ⱝ']), + ('ⱞ', &['Ⱞ']), + ('Ⱡ', &['ⱡ']), + ('ⱡ', &['Ⱡ']), + ('Ɫ', &['ɫ']), + ('Ᵽ', &['ᵽ']), + ('Ɽ', &['ɽ']), + ('ⱥ', &['Ⱥ']), + ('ⱦ', &['Ⱦ']), + ('Ⱨ', &['ⱨ']), + ('ⱨ', &['Ⱨ']), + ('Ⱪ', &['ⱪ']), + ('ⱪ', &['Ⱪ']), + ('Ⱬ', &['ⱬ']), + ('ⱬ', &['Ⱬ']), + ('Ɑ', &['ɑ']), + ('Ɱ', &['ɱ']), + ('Ɐ', &['ɐ']), + ('Ɒ', &['ɒ']), + ('Ⱳ', &['ⱳ']), + ('ⱳ', &['Ⱳ']), + ('Ⱶ', &['ⱶ']), + ('ⱶ', &['Ⱶ']), + ('Ȿ', &['ȿ']), + ('Ɀ', &['ɀ']), + ('Ⲁ', &['ⲁ']), + ('ⲁ', &['Ⲁ']), + ('Ⲃ', &['ⲃ']), + ('ⲃ', &['Ⲃ']), + ('Ⲅ', &['ⲅ']), + ('ⲅ', &['Ⲅ']), + ('Ⲇ', &['ⲇ']), + ('ⲇ', &['Ⲇ']), + ('Ⲉ', &['ⲉ']), + ('ⲉ', &['Ⲉ']), + ('Ⲋ', &['ⲋ']), + ('ⲋ', &['Ⲋ']), + ('Ⲍ', &['ⲍ']), + ('ⲍ', &['Ⲍ']), + ('Ⲏ', &['ⲏ']), + ('ⲏ', &['Ⲏ']), + ('Ⲑ', &['ⲑ']), + ('ⲑ', &['Ⲑ']), + ('Ⲓ', &['ⲓ']), + ('ⲓ', &['Ⲓ']), + ('Ⲕ', &['ⲕ']), + ('ⲕ', &['Ⲕ']), + ('Ⲗ', &['ⲗ']), + ('ⲗ', &['Ⲗ']), + ('Ⲙ', &['ⲙ']), + ('ⲙ', &['Ⲙ']), + ('Ⲛ', &['ⲛ']), + ('ⲛ', &['Ⲛ']), + ('Ⲝ', &['ⲝ']), + ('ⲝ', &['Ⲝ']), + ('Ⲟ', &['ⲟ']), + ('ⲟ', &['Ⲟ']), + ('Ⲡ', &['ⲡ']), + ('ⲡ', &['Ⲡ']), + ('Ⲣ', &['ⲣ']), + ('ⲣ', &['Ⲣ']), + ('Ⲥ', &['ⲥ']), + ('ⲥ', &['Ⲥ']), + ('Ⲧ', &['ⲧ']), + ('ⲧ', &['Ⲧ']), + ('Ⲩ', &['ⲩ']), + ('ⲩ', &['Ⲩ']), + ('Ⲫ', &['ⲫ']), + ('ⲫ', &['Ⲫ']), + ('Ⲭ', &['ⲭ']), + ('ⲭ', &['Ⲭ']), + ('Ⲯ', &['ⲯ']), + ('ⲯ', &['Ⲯ']), + ('Ⲱ', &['ⲱ']), + ('ⲱ', &['Ⲱ']), + ('Ⲳ', &['ⲳ']), + ('ⲳ', &['Ⲳ']), + ('Ⲵ', &['ⲵ']), + ('ⲵ', &['Ⲵ']), + ('Ⲷ', &['ⲷ']), + ('ⲷ', &['Ⲷ']), + ('Ⲹ', &['ⲹ']), + ('ⲹ', &['Ⲹ']), + ('Ⲻ', &['ⲻ']), + ('ⲻ', &['Ⲻ']), + ('Ⲽ', &['ⲽ']), + ('ⲽ', &['Ⲽ']), + ('Ⲿ', &['ⲿ']), + ('ⲿ', &['Ⲿ']), + ('Ⳁ', &['ⳁ']), + ('ⳁ', &['Ⳁ']), + ('Ⳃ', &['ⳃ']), + ('ⳃ', &['Ⳃ']), + ('Ⳅ', &['ⳅ']), + ('ⳅ', &['Ⳅ']), + ('Ⳇ', &['ⳇ']), + ('ⳇ', &['Ⳇ']), + ('Ⳉ', &['ⳉ']), + ('ⳉ', &['Ⳉ']), + ('Ⳋ', &['ⳋ']), + ('ⳋ', &['Ⳋ']), + ('Ⳍ', &['ⳍ']), + ('ⳍ', &['Ⳍ']), + ('Ⳏ', &['ⳏ']), + ('ⳏ', &['Ⳏ']), + ('Ⳑ', &['ⳑ']), + ('ⳑ', &['Ⳑ']), + ('Ⳓ', &['ⳓ']), + ('ⳓ', &['Ⳓ']), + ('Ⳕ', &['ⳕ']), + ('ⳕ', &['Ⳕ']), + ('Ⳗ', &['ⳗ']), + ('ⳗ', &['Ⳗ']), + ('Ⳙ', &['ⳙ']), + ('ⳙ', &['Ⳙ']), + ('Ⳛ', &['ⳛ']), + ('ⳛ', &['Ⳛ']), + ('Ⳝ', &['ⳝ']), + ('ⳝ', &['Ⳝ']), + ('Ⳟ', &['ⳟ']), + ('ⳟ', &['Ⳟ']), + ('Ⳡ', &['ⳡ']), + ('ⳡ', &['Ⳡ']), + ('Ⳣ', &['ⳣ']), + ('ⳣ', &['Ⳣ']), + ('Ⳬ', &['ⳬ']), + ('ⳬ', &['Ⳬ']), + ('Ⳮ', &['ⳮ']), + ('ⳮ', &['Ⳮ']), + ('Ⳳ', &['ⳳ']), + ('ⳳ', &['Ⳳ']), + ('ⴀ', &['Ⴀ']), + ('ⴁ', &['Ⴁ']), + ('ⴂ', &['Ⴂ']), + ('ⴃ', &['Ⴃ']), + ('ⴄ', &['Ⴄ']), + ('ⴅ', &['Ⴅ']), + ('ⴆ', &['Ⴆ']), + ('ⴇ', &['Ⴇ']), + ('ⴈ', &['Ⴈ']), + ('ⴉ', &['Ⴉ']), + ('ⴊ', &['Ⴊ']), + ('ⴋ', &['Ⴋ']), + ('ⴌ', &['Ⴌ']), + ('ⴍ', &['Ⴍ']), + ('ⴎ', &['Ⴎ']), + ('ⴏ', &['Ⴏ']), + ('ⴐ', &['Ⴐ']), + ('ⴑ', &['Ⴑ']), + ('ⴒ', &['Ⴒ']), + ('ⴓ', &['Ⴓ']), + ('ⴔ', &['Ⴔ']), + ('ⴕ', &['Ⴕ']), + ('ⴖ', &['Ⴖ']), + ('ⴗ', &['Ⴗ']), + ('ⴘ', &['Ⴘ']), + ('ⴙ', &['Ⴙ']), + ('ⴚ', &['Ⴚ']), + ('ⴛ', &['Ⴛ']), + ('ⴜ', &['Ⴜ']), + ('ⴝ', &['Ⴝ']), + ('ⴞ', &['Ⴞ']), + ('ⴟ', &['Ⴟ']), + ('ⴠ', &['Ⴠ']), + ('ⴡ', &['Ⴡ']), + ('ⴢ', &['Ⴢ']), + ('ⴣ', &['Ⴣ']), + ('ⴤ', &['Ⴤ']), + ('ⴥ', &['Ⴥ']), + ('ⴧ', &['Ⴧ']), + ('ⴭ', &['Ⴭ']), + ('Ꙁ', &['ꙁ']), + ('ꙁ', &['Ꙁ']), + ('Ꙃ', &['ꙃ']), + ('ꙃ', &['Ꙃ']), + ('Ꙅ', &['ꙅ']), + ('ꙅ', &['Ꙅ']), + ('Ꙇ', &['ꙇ']), + ('ꙇ', &['Ꙇ']), + ('Ꙉ', &['ꙉ']), + ('ꙉ', &['Ꙉ']), + ('Ꙋ', &['ᲈ', 'ꙋ']), + ('ꙋ', &['ᲈ', 'Ꙋ']), + ('Ꙍ', &['ꙍ']), + ('ꙍ', &['Ꙍ']), + ('Ꙏ', &['ꙏ']), + ('ꙏ', &['Ꙏ']), + ('Ꙑ', &['ꙑ']), + ('ꙑ', &['Ꙑ']), + ('Ꙓ', &['ꙓ']), + ('ꙓ', &['Ꙓ']), + ('Ꙕ', &['ꙕ']), + ('ꙕ', &['Ꙕ']), + ('Ꙗ', &['ꙗ']), + ('ꙗ', &['Ꙗ']), + ('Ꙙ', &['ꙙ']), + ('ꙙ', &['Ꙙ']), + ('Ꙛ', &['ꙛ']), + ('ꙛ', &['Ꙛ']), + ('Ꙝ', &['ꙝ']), + ('ꙝ', &['Ꙝ']), + ('Ꙟ', &['ꙟ']), + ('ꙟ', &['Ꙟ']), + ('Ꙡ', &['ꙡ']), + ('ꙡ', &['Ꙡ']), + ('Ꙣ', &['ꙣ']), + ('ꙣ', &['Ꙣ']), + ('Ꙥ', &['ꙥ']), + ('ꙥ', &['Ꙥ']), + ('Ꙧ', &['ꙧ']), + ('ꙧ', &['Ꙧ']), + ('Ꙩ', &['ꙩ']), + ('ꙩ', &['Ꙩ']), + ('Ꙫ', &['ꙫ']), + ('ꙫ', &['Ꙫ']), + ('Ꙭ', &['ꙭ']), + ('ꙭ', &['Ꙭ']), + ('Ꚁ', &['ꚁ']), + ('ꚁ', &['Ꚁ']), + ('Ꚃ', &['ꚃ']), + ('ꚃ', &['Ꚃ']), + ('Ꚅ', &['ꚅ']), + ('ꚅ', &['Ꚅ']), + ('Ꚇ', &['ꚇ']), + ('ꚇ', &['Ꚇ']), + ('Ꚉ', &['ꚉ']), + ('ꚉ', &['Ꚉ']), + ('Ꚋ', &['ꚋ']), + ('ꚋ', &['Ꚋ']), + ('Ꚍ', &['ꚍ']), + ('ꚍ', &['Ꚍ']), + ('Ꚏ', &['ꚏ']), + ('ꚏ', &['Ꚏ']), + ('Ꚑ', &['ꚑ']), + ('ꚑ', &['Ꚑ']), + ('Ꚓ', &['ꚓ']), + ('ꚓ', &['Ꚓ']), + ('Ꚕ', &['ꚕ']), + ('ꚕ', &['Ꚕ']), + ('Ꚗ', &['ꚗ']), + ('ꚗ', &['Ꚗ']), + ('Ꚙ', &['ꚙ']), + ('ꚙ', &['Ꚙ']), + ('Ꚛ', &['ꚛ']), + ('ꚛ', &['Ꚛ']), + ('Ꜣ', &['ꜣ']), + ('ꜣ', &['Ꜣ']), + ('Ꜥ', &['ꜥ']), + ('ꜥ', &['Ꜥ']), + ('Ꜧ', &['ꜧ']), + ('ꜧ', &['Ꜧ']), + ('Ꜩ', &['ꜩ']), + ('ꜩ', &['Ꜩ']), + ('Ꜫ', &['ꜫ']), + ('ꜫ', &['Ꜫ']), + ('Ꜭ', &['ꜭ']), + ('ꜭ', &['Ꜭ']), + ('Ꜯ', &['ꜯ']), + ('ꜯ', &['Ꜯ']), + ('Ꜳ', &['ꜳ']), + ('ꜳ', &['Ꜳ']), + ('Ꜵ', &['ꜵ']), + ('ꜵ', &['Ꜵ']), + ('Ꜷ', &['ꜷ']), + ('ꜷ', &['Ꜷ']), + ('Ꜹ', &['ꜹ']), + ('ꜹ', &['Ꜹ']), + ('Ꜻ', &['ꜻ']), + ('ꜻ', &['Ꜻ']), + ('Ꜽ', &['ꜽ']), + ('ꜽ', &['Ꜽ']), + ('Ꜿ', &['ꜿ']), + ('ꜿ', &['Ꜿ']), + ('Ꝁ', &['ꝁ']), + ('ꝁ', &['Ꝁ']), + ('Ꝃ', &['ꝃ']), + ('ꝃ', &['Ꝃ']), + ('Ꝅ', &['ꝅ']), + ('ꝅ', &['Ꝅ']), + ('Ꝇ', &['ꝇ']), + ('ꝇ', &['Ꝇ']), + ('Ꝉ', &['ꝉ']), + ('ꝉ', &['Ꝉ']), + ('Ꝋ', &['ꝋ']), + ('ꝋ', &['Ꝋ']), + ('Ꝍ', &['ꝍ']), + ('ꝍ', &['Ꝍ']), + ('Ꝏ', &['ꝏ']), + ('ꝏ', &['Ꝏ']), + ('Ꝑ', &['ꝑ']), + ('ꝑ', &['Ꝑ']), + ('Ꝓ', &['ꝓ']), + ('ꝓ', &['Ꝓ']), + ('Ꝕ', &['ꝕ']), + ('ꝕ', &['Ꝕ']), + ('Ꝗ', &['ꝗ']), + ('ꝗ', &['Ꝗ']), + ('Ꝙ', &['ꝙ']), + ('ꝙ', &['Ꝙ']), + ('Ꝛ', &['ꝛ']), + ('ꝛ', &['Ꝛ']), + ('Ꝝ', &['ꝝ']), + ('ꝝ', &['Ꝝ']), + ('Ꝟ', &['ꝟ']), + ('ꝟ', &['Ꝟ']), + ('Ꝡ', &['ꝡ']), + ('ꝡ', &['Ꝡ']), + ('Ꝣ', &['ꝣ']), + ('ꝣ', &['Ꝣ']), + ('Ꝥ', &['ꝥ']), + ('ꝥ', &['Ꝥ']), + ('Ꝧ', &['ꝧ']), + ('ꝧ', &['Ꝧ']), + ('Ꝩ', &['ꝩ']), + ('ꝩ', &['Ꝩ']), + ('Ꝫ', &['ꝫ']), + ('ꝫ', &['Ꝫ']), + ('Ꝭ', &['ꝭ']), + ('ꝭ', &['Ꝭ']), + ('Ꝯ', &['ꝯ']), + ('ꝯ', &['Ꝯ']), + ('Ꝺ', &['ꝺ']), + ('ꝺ', &['Ꝺ']), + ('Ꝼ', &['ꝼ']), + ('ꝼ', &['Ꝼ']), + ('Ᵹ', &['ᵹ']), + ('Ꝿ', &['ꝿ']), + ('ꝿ', &['Ꝿ']), + ('Ꞁ', &['ꞁ']), + ('ꞁ', &['Ꞁ']), + ('Ꞃ', &['ꞃ']), + ('ꞃ', &['Ꞃ']), + ('Ꞅ', &['ꞅ']), + ('ꞅ', &['Ꞅ']), + ('Ꞇ', &['ꞇ']), + ('ꞇ', &['Ꞇ']), + ('Ꞌ', &['ꞌ']), + ('ꞌ', &['Ꞌ']), + ('Ɥ', &['ɥ']), + ('Ꞑ', &['ꞑ']), + ('ꞑ', &['Ꞑ']), + ('Ꞓ', &['ꞓ']), + ('ꞓ', &['Ꞓ']), + ('ꞔ', &['\u{a7c4}']), + ('Ꞗ', &['ꞗ']), + ('ꞗ', &['Ꞗ']), + ('Ꞙ', &['ꞙ']), + ('ꞙ', &['Ꞙ']), + ('Ꞛ', &['ꞛ']), + ('ꞛ', &['Ꞛ']), + ('Ꞝ', &['ꞝ']), + ('ꞝ', &['Ꞝ']), + ('Ꞟ', &['ꞟ']), + ('ꞟ', &['Ꞟ']), + ('Ꞡ', &['ꞡ']), + ('ꞡ', &['Ꞡ']), + ('Ꞣ', &['ꞣ']), + ('ꞣ', &['Ꞣ']), + ('Ꞥ', &['ꞥ']), + ('ꞥ', &['Ꞥ']), + ('Ꞧ', &['ꞧ']), + ('ꞧ', &['Ꞧ']), + ('Ꞩ', &['ꞩ']), + ('ꞩ', &['Ꞩ']), + ('Ɦ', &['ɦ']), + ('Ɜ', &['ɜ']), + ('Ɡ', &['ɡ']), + ('Ɬ', &['ɬ']), + ('Ɪ', &['ɪ']), + ('Ʞ', &['ʞ']), + ('Ʇ', &['ʇ']), + ('Ʝ', &['ʝ']), + ('Ꭓ', &['ꭓ']), + ('Ꞵ', &['ꞵ']), + ('ꞵ', &['Ꞵ']), + ('Ꞷ', &['ꞷ']), + ('ꞷ', &['Ꞷ']), + ('Ꞹ', &['ꞹ']), + ('ꞹ', &['Ꞹ']), + ('\u{a7ba}', &['\u{a7bb}']), + ('\u{a7bb}', &['\u{a7ba}']), + ('\u{a7bc}', &['\u{a7bd}']), + ('\u{a7bd}', &['\u{a7bc}']), + ('\u{a7be}', &['\u{a7bf}']), + ('\u{a7bf}', &['\u{a7be}']), + ('\u{a7c2}', &['\u{a7c3}']), + ('\u{a7c3}', &['\u{a7c2}']), + ('\u{a7c4}', &['ꞔ']), + ('\u{a7c5}', &['ʂ']), + ('\u{a7c6}', &['ᶎ']), + ('ꭓ', &['Ꭓ']), + ('ꭰ', &['Ꭰ']), + ('ꭱ', &['Ꭱ']), + ('ꭲ', &['Ꭲ']), + ('ꭳ', &['Ꭳ']), + ('ꭴ', &['Ꭴ']), + ('ꭵ', &['Ꭵ']), + ('ꭶ', &['Ꭶ']), + ('ꭷ', &['Ꭷ']), + ('ꭸ', &['Ꭸ']), + ('ꭹ', &['Ꭹ']), + ('ꭺ', &['Ꭺ']), + ('ꭻ', &['Ꭻ']), + ('ꭼ', &['Ꭼ']), + ('ꭽ', &['Ꭽ']), + ('ꭾ', &['Ꭾ']), + ('ꭿ', &['Ꭿ']), + ('ꮀ', &['Ꮀ']), + ('ꮁ', &['Ꮁ']), + ('ꮂ', &['Ꮂ']), + ('ꮃ', &['Ꮃ']), + ('ꮄ', &['Ꮄ']), + ('ꮅ', &['Ꮅ']), + ('ꮆ', &['Ꮆ']), + ('ꮇ', &['Ꮇ']), + ('ꮈ', &['Ꮈ']), + ('ꮉ', &['Ꮉ']), + ('ꮊ', &['Ꮊ']), + ('ꮋ', &['Ꮋ']), + ('ꮌ', &['Ꮌ']), + ('ꮍ', &['Ꮍ']), + ('ꮎ', &['Ꮎ']), + ('ꮏ', &['Ꮏ']), + ('ꮐ', &['Ꮐ']), + ('ꮑ', &['Ꮑ']), + ('ꮒ', &['Ꮒ']), + ('ꮓ', &['Ꮓ']), + ('ꮔ', &['Ꮔ']), + ('ꮕ', &['Ꮕ']), + ('ꮖ', &['Ꮖ']), + ('ꮗ', &['Ꮗ']), + ('ꮘ', &['Ꮘ']), + ('ꮙ', &['Ꮙ']), + ('ꮚ', &['Ꮚ']), + ('ꮛ', &['Ꮛ']), + ('ꮜ', &['Ꮜ']), + ('ꮝ', &['Ꮝ']), + ('ꮞ', &['Ꮞ']), + ('ꮟ', &['Ꮟ']), + ('ꮠ', &['Ꮠ']), + ('ꮡ', &['Ꮡ']), + ('ꮢ', &['Ꮢ']), + ('ꮣ', &['Ꮣ']), + ('ꮤ', &['Ꮤ']), + ('ꮥ', &['Ꮥ']), + ('ꮦ', &['Ꮦ']), + ('ꮧ', &['Ꮧ']), + ('ꮨ', &['Ꮨ']), + ('ꮩ', &['Ꮩ']), + ('ꮪ', &['Ꮪ']), + ('ꮫ', &['Ꮫ']), + ('ꮬ', &['Ꮬ']), + ('ꮭ', &['Ꮭ']), + ('ꮮ', &['Ꮮ']), + ('ꮯ', &['Ꮯ']), + ('ꮰ', &['Ꮰ']), + ('ꮱ', &['Ꮱ']), + ('ꮲ', &['Ꮲ']), + ('ꮳ', &['Ꮳ']), + ('ꮴ', &['Ꮴ']), + ('ꮵ', &['Ꮵ']), + ('ꮶ', &['Ꮶ']), + ('ꮷ', &['Ꮷ']), + ('ꮸ', &['Ꮸ']), + ('ꮹ', &['Ꮹ']), + ('ꮺ', &['Ꮺ']), + ('ꮻ', &['Ꮻ']), + ('ꮼ', &['Ꮼ']), + ('ꮽ', &['Ꮽ']), + ('ꮾ', &['Ꮾ']), + ('ꮿ', &['Ꮿ']), + ('A', &['a']), + ('B', &['b']), + ('C', &['c']), + ('D', &['d']), + ('E', &['e']), + ('F', &['f']), + ('G', &['g']), + ('H', &['h']), + ('I', &['i']), + ('J', &['j']), + ('K', &['k']), + ('L', &['l']), + ('M', &['m']), + ('N', &['n']), + ('O', &['o']), + ('P', &['p']), + ('Q', &['q']), + ('R', &['r']), + ('S', &['s']), + ('T', &['t']), + ('U', &['u']), + ('V', &['v']), + ('W', &['w']), + ('X', &['x']), + ('Y', &['y']), + ('Z', &['z']), + ('a', &['A']), + ('b', &['B']), + ('c', &['C']), + ('d', &['D']), + ('e', &['E']), + ('f', &['F']), + ('g', &['G']), + ('h', &['H']), + ('i', &['I']), + ('j', &['J']), + ('k', &['K']), + ('l', &['L']), + ('m', &['M']), + ('n', &['N']), + ('o', &['O']), + ('p', &['P']), + ('q', &['Q']), + ('r', &['R']), + ('s', &['S']), + ('t', &['T']), + ('u', &['U']), + ('v', &['V']), + ('w', &['W']), + ('x', &['X']), + ('y', &['Y']), + ('z', &['Z']), + ('𐐀', &['𐐨']), + ('𐐁', &['𐐩']), + ('𐐂', &['𐐪']), + ('𐐃', &['𐐫']), + ('𐐄', &['𐐬']), + ('𐐅', &['𐐭']), + ('𐐆', &['𐐮']), + ('𐐇', &['𐐯']), + ('𐐈', &['𐐰']), + ('𐐉', &['𐐱']), + ('𐐊', &['𐐲']), + ('𐐋', &['𐐳']), + ('𐐌', &['𐐴']), + ('𐐍', &['𐐵']), + ('𐐎', &['𐐶']), + ('𐐏', &['𐐷']), + ('𐐐', &['𐐸']), + ('𐐑', &['𐐹']), + ('𐐒', &['𐐺']), + ('𐐓', &['𐐻']), + ('𐐔', &['𐐼']), + ('𐐕', &['𐐽']), + ('𐐖', &['𐐾']), + ('𐐗', &['𐐿']), + ('𐐘', &['𐑀']), + ('𐐙', &['𐑁']), + ('𐐚', &['𐑂']), + ('𐐛', &['𐑃']), + ('𐐜', &['𐑄']), + ('𐐝', &['𐑅']), + ('𐐞', &['𐑆']), + ('𐐟', &['𐑇']), + ('𐐠', &['𐑈']), + ('𐐡', &['𐑉']), + ('𐐢', &['𐑊']), + ('𐐣', &['𐑋']), + ('𐐤', &['𐑌']), + ('𐐥', &['𐑍']), + ('𐐦', &['𐑎']), + ('𐐧', &['𐑏']), + ('𐐨', &['𐐀']), + ('𐐩', &['𐐁']), + ('𐐪', &['𐐂']), + ('𐐫', &['𐐃']), + ('𐐬', &['𐐄']), + ('𐐭', &['𐐅']), + ('𐐮', &['𐐆']), + ('𐐯', &['𐐇']), + ('𐐰', &['𐐈']), + ('𐐱', &['𐐉']), + ('𐐲', &['𐐊']), + ('𐐳', &['𐐋']), + ('𐐴', &['𐐌']), + ('𐐵', &['𐐍']), + ('𐐶', &['𐐎']), + ('𐐷', &['𐐏']), + ('𐐸', &['𐐐']), + ('𐐹', &['𐐑']), + ('𐐺', &['𐐒']), + ('𐐻', &['𐐓']), + ('𐐼', &['𐐔']), + ('𐐽', &['𐐕']), + ('𐐾', &['𐐖']), + ('𐐿', &['𐐗']), + ('𐑀', &['𐐘']), + ('𐑁', &['𐐙']), + ('𐑂', &['𐐚']), + ('𐑃', &['𐐛']), + ('𐑄', &['𐐜']), + ('𐑅', &['𐐝']), + ('𐑆', &['𐐞']), + ('𐑇', &['𐐟']), + ('𐑈', &['𐐠']), + ('𐑉', &['𐐡']), + ('𐑊', &['𐐢']), + ('𐑋', &['𐐣']), + ('𐑌', &['𐐤']), + ('𐑍', &['𐐥']), + ('𐑎', &['𐐦']), + ('𐑏', &['𐐧']), + ('𐒰', &['𐓘']), + ('𐒱', &['𐓙']), + ('𐒲', &['𐓚']), + ('𐒳', &['𐓛']), + ('𐒴', &['𐓜']), + ('𐒵', &['𐓝']), + ('𐒶', &['𐓞']), + ('𐒷', &['𐓟']), + ('𐒸', &['𐓠']), + ('𐒹', &['𐓡']), + ('𐒺', &['𐓢']), + ('𐒻', &['𐓣']), + ('𐒼', &['𐓤']), + ('𐒽', &['𐓥']), + ('𐒾', &['𐓦']), + ('𐒿', &['𐓧']), + ('𐓀', &['𐓨']), + ('𐓁', &['𐓩']), + ('𐓂', &['𐓪']), + ('𐓃', &['𐓫']), + ('𐓄', &['𐓬']), + ('𐓅', &['𐓭']), + ('𐓆', &['𐓮']), + ('𐓇', &['𐓯']), + ('𐓈', &['𐓰']), + ('𐓉', &['𐓱']), + ('𐓊', &['𐓲']), + ('𐓋', &['𐓳']), + ('𐓌', &['𐓴']), + ('𐓍', &['𐓵']), + ('𐓎', &['𐓶']), + ('𐓏', &['𐓷']), + ('𐓐', &['𐓸']), + ('𐓑', &['𐓹']), + ('𐓒', &['𐓺']), + ('𐓓', &['𐓻']), + ('𐓘', &['𐒰']), + ('𐓙', &['𐒱']), + ('𐓚', &['𐒲']), + ('𐓛', &['𐒳']), + ('𐓜', &['𐒴']), + ('𐓝', &['𐒵']), + ('𐓞', &['𐒶']), + ('𐓟', &['𐒷']), + ('𐓠', &['𐒸']), + ('𐓡', &['𐒹']), + ('𐓢', &['𐒺']), + ('𐓣', &['𐒻']), + ('𐓤', &['𐒼']), + ('𐓥', &['𐒽']), + ('𐓦', &['𐒾']), + ('𐓧', &['𐒿']), + ('𐓨', &['𐓀']), + ('𐓩', &['𐓁']), + ('𐓪', &['𐓂']), + ('𐓫', &['𐓃']), + ('𐓬', &['𐓄']), + ('𐓭', &['𐓅']), + ('𐓮', &['𐓆']), + ('𐓯', &['𐓇']), + ('𐓰', &['𐓈']), + ('𐓱', &['𐓉']), + ('𐓲', &['𐓊']), + ('𐓳', &['𐓋']), + ('𐓴', &['𐓌']), + ('𐓵', &['𐓍']), + ('𐓶', &['𐓎']), + ('𐓷', &['𐓏']), + ('𐓸', &['𐓐']), + ('𐓹', &['𐓑']), + ('𐓺', &['𐓒']), + ('𐓻', &['𐓓']), + ('𐲀', &['𐳀']), + ('𐲁', &['𐳁']), + ('𐲂', &['𐳂']), + ('𐲃', &['𐳃']), + ('𐲄', &['𐳄']), + ('𐲅', &['𐳅']), + ('𐲆', &['𐳆']), + ('𐲇', &['𐳇']), + ('𐲈', &['𐳈']), + ('𐲉', &['𐳉']), + ('𐲊', &['𐳊']), + ('𐲋', &['𐳋']), + ('𐲌', &['𐳌']), + ('𐲍', &['𐳍']), + ('𐲎', &['𐳎']), + ('𐲏', &['𐳏']), + ('𐲐', &['𐳐']), + ('𐲑', &['𐳑']), + ('𐲒', &['𐳒']), + ('𐲓', &['𐳓']), + ('𐲔', &['𐳔']), + ('𐲕', &['𐳕']), + ('𐲖', &['𐳖']), + ('𐲗', &['𐳗']), + ('𐲘', &['𐳘']), + ('𐲙', &['𐳙']), + ('𐲚', &['𐳚']), + ('𐲛', &['𐳛']), + ('𐲜', &['𐳜']), + ('𐲝', &['𐳝']), + ('𐲞', &['𐳞']), + ('𐲟', &['𐳟']), + ('𐲠', &['𐳠']), + ('𐲡', &['𐳡']), + ('𐲢', &['𐳢']), + ('𐲣', &['𐳣']), + ('𐲤', &['𐳤']), + ('𐲥', &['𐳥']), + ('𐲦', &['𐳦']), + ('𐲧', &['𐳧']), + ('𐲨', &['𐳨']), + ('𐲩', &['𐳩']), + ('𐲪', &['𐳪']), + ('𐲫', &['𐳫']), + ('𐲬', &['𐳬']), + ('𐲭', &['𐳭']), + ('𐲮', &['𐳮']), + ('𐲯', &['𐳯']), + ('𐲰', &['𐳰']), + ('𐲱', &['𐳱']), + ('𐲲', &['𐳲']), + ('𐳀', &['𐲀']), + ('𐳁', &['𐲁']), + ('𐳂', &['𐲂']), + ('𐳃', &['𐲃']), + ('𐳄', &['𐲄']), + ('𐳅', &['𐲅']), + ('𐳆', &['𐲆']), + ('𐳇', &['𐲇']), + ('𐳈', &['𐲈']), + ('𐳉', &['𐲉']), + ('𐳊', &['𐲊']), + ('𐳋', &['𐲋']), + ('𐳌', &['𐲌']), + ('𐳍', &['𐲍']), + ('𐳎', &['𐲎']), + ('𐳏', &['𐲏']), + ('𐳐', &['𐲐']), + ('𐳑', &['𐲑']), + ('𐳒', &['𐲒']), + ('𐳓', &['𐲓']), + ('𐳔', &['𐲔']), + ('𐳕', &['𐲕']), + ('𐳖', &['𐲖']), + ('𐳗', &['𐲗']), + ('𐳘', &['𐲘']), + ('𐳙', &['𐲙']), + ('𐳚', &['𐲚']), + ('𐳛', &['𐲛']), + ('𐳜', &['𐲜']), + ('𐳝', &['𐲝']), + ('𐳞', &['𐲞']), + ('𐳟', &['𐲟']), + ('𐳠', &['𐲠']), + ('𐳡', &['𐲡']), + ('𐳢', &['𐲢']), + ('𐳣', &['𐲣']), + ('𐳤', &['𐲤']), + ('𐳥', &['𐲥']), + ('𐳦', &['𐲦']), + ('𐳧', &['𐲧']), + ('𐳨', &['𐲨']), + ('𐳩', &['𐲩']), + ('𐳪', &['𐲪']), + ('𐳫', &['𐲫']), + ('𐳬', &['𐲬']), + ('𐳭', &['𐲭']), + ('𐳮', &['𐲮']), + ('𐳯', &['𐲯']), + ('𐳰', &['𐲰']), + ('𐳱', &['𐲱']), + ('𐳲', &['𐲲']), + ('𑢠', &['𑣀']), + ('𑢡', &['𑣁']), + ('𑢢', &['𑣂']), + ('𑢣', &['𑣃']), + ('𑢤', &['𑣄']), + ('𑢥', &['𑣅']), + ('𑢦', &['𑣆']), + ('𑢧', &['𑣇']), + ('𑢨', &['𑣈']), + ('𑢩', &['𑣉']), + ('𑢪', &['𑣊']), + ('𑢫', &['𑣋']), + ('𑢬', &['𑣌']), + ('𑢭', &['𑣍']), + ('𑢮', &['𑣎']), + ('𑢯', &['𑣏']), + ('𑢰', &['𑣐']), + ('𑢱', &['𑣑']), + ('𑢲', &['𑣒']), + ('𑢳', &['𑣓']), + ('𑢴', &['𑣔']), + ('𑢵', &['𑣕']), + ('𑢶', &['𑣖']), + ('𑢷', &['𑣗']), + ('𑢸', &['𑣘']), + ('𑢹', &['𑣙']), + ('𑢺', &['𑣚']), + ('𑢻', &['𑣛']), + ('𑢼', &['𑣜']), + ('𑢽', &['𑣝']), + ('𑢾', &['𑣞']), + ('𑢿', &['𑣟']), + ('𑣀', &['𑢠']), + ('𑣁', &['𑢡']), + ('𑣂', &['𑢢']), + ('𑣃', &['𑢣']), + ('𑣄', &['𑢤']), + ('𑣅', &['𑢥']), + ('𑣆', &['𑢦']), + ('𑣇', &['𑢧']), + ('𑣈', &['𑢨']), + ('𑣉', &['𑢩']), + ('𑣊', &['𑢪']), + ('𑣋', &['𑢫']), + ('𑣌', &['𑢬']), + ('𑣍', &['𑢭']), + ('𑣎', &['𑢮']), + ('𑣏', &['𑢯']), + ('𑣐', &['𑢰']), + ('𑣑', &['𑢱']), + ('𑣒', &['𑢲']), + ('𑣓', &['𑢳']), + ('𑣔', &['𑢴']), + ('𑣕', &['𑢵']), + ('𑣖', &['𑢶']), + ('𑣗', &['𑢷']), + ('𑣘', &['𑢸']), + ('𑣙', &['𑢹']), + ('𑣚', &['𑢺']), + ('𑣛', &['𑢻']), + ('𑣜', &['𑢼']), + ('𑣝', &['𑢽']), + ('𑣞', &['𑢾']), + ('𑣟', &['𑢿']), + ('𖹀', &['𖹠']), + ('𖹁', &['𖹡']), + ('𖹂', &['𖹢']), + ('𖹃', &['𖹣']), + ('𖹄', &['𖹤']), + ('𖹅', &['𖹥']), + ('𖹆', &['𖹦']), + ('𖹇', &['𖹧']), + ('𖹈', &['𖹨']), + ('𖹉', &['𖹩']), + ('𖹊', &['𖹪']), + ('𖹋', &['𖹫']), + ('𖹌', &['𖹬']), + ('𖹍', &['𖹭']), + ('𖹎', &['𖹮']), + ('𖹏', &['𖹯']), + ('𖹐', &['𖹰']), + ('𖹑', &['𖹱']), + ('𖹒', &['𖹲']), + ('𖹓', &['𖹳']), + ('𖹔', &['𖹴']), + ('𖹕', &['𖹵']), + ('𖹖', &['𖹶']), + ('𖹗', &['𖹷']), + ('𖹘', &['𖹸']), + ('𖹙', &['𖹹']), + ('𖹚', &['𖹺']), + ('𖹛', &['𖹻']), + ('𖹜', &['𖹼']), + ('𖹝', &['𖹽']), + ('𖹞', &['𖹾']), + ('𖹟', &['𖹿']), + ('𖹠', &['𖹀']), + ('𖹡', &['𖹁']), + ('𖹢', &['𖹂']), + ('𖹣', &['𖹃']), + ('𖹤', &['𖹄']), + ('𖹥', &['𖹅']), + ('𖹦', &['𖹆']), + ('𖹧', &['𖹇']), + ('𖹨', &['𖹈']), + ('𖹩', &['𖹉']), + ('𖹪', &['𖹊']), + ('𖹫', &['𖹋']), + ('𖹬', &['𖹌']), + ('𖹭', &['𖹍']), + ('𖹮', &['𖹎']), + ('𖹯', &['𖹏']), + ('𖹰', &['𖹐']), + ('𖹱', &['𖹑']), + ('𖹲', &['𖹒']), + ('𖹳', &['𖹓']), + ('𖹴', &['𖹔']), + ('𖹵', &['𖹕']), + ('𖹶', &['𖹖']), + ('𖹷', &['𖹗']), + ('𖹸', &['𖹘']), + ('𖹹', &['𖹙']), + ('𖹺', &['𖹚']), + ('𖹻', &['𖹛']), + ('𖹼', &['𖹜']), + ('𖹽', &['𖹝']), + ('𖹾', &['𖹞']), + ('𖹿', &['𖹟']), + ('𞤀', &['𞤢']), + ('𞤁', &['𞤣']), + ('𞤂', &['𞤤']), + ('𞤃', &['𞤥']), + ('𞤄', &['𞤦']), + ('𞤅', &['𞤧']), + ('𞤆', &['𞤨']), + ('𞤇', &['𞤩']), + ('𞤈', &['𞤪']), + ('𞤉', &['𞤫']), + ('𞤊', &['𞤬']), + ('𞤋', &['𞤭']), + ('𞤌', &['𞤮']), + ('𞤍', &['𞤯']), + ('𞤎', &['𞤰']), + ('𞤏', &['𞤱']), + ('𞤐', &['𞤲']), + ('𞤑', &['𞤳']), + ('𞤒', &['𞤴']), + ('𞤓', &['𞤵']), + ('𞤔', &['𞤶']), + ('𞤕', &['𞤷']), + ('𞤖', &['𞤸']), + ('𞤗', &['𞤹']), + ('𞤘', &['𞤺']), + ('𞤙', &['𞤻']), + ('𞤚', &['𞤼']), + ('𞤛', &['𞤽']), + ('𞤜', &['𞤾']), + ('𞤝', &['𞤿']), + ('𞤞', &['𞥀']), + ('𞤟', &['𞥁']), + ('𞤠', &['𞥂']), + ('𞤡', &['𞥃']), + ('𞤢', &['𞤀']), + ('𞤣', &['𞤁']), + ('𞤤', &['𞤂']), + ('𞤥', &['𞤃']), + ('𞤦', &['𞤄']), + ('𞤧', &['𞤅']), + ('𞤨', &['𞤆']), + ('𞤩', &['𞤇']), + ('𞤪', &['𞤈']), + ('𞤫', &['𞤉']), + ('𞤬', &['𞤊']), + ('𞤭', &['𞤋']), + ('𞤮', &['𞤌']), + ('𞤯', &['𞤍']), + ('𞤰', &['𞤎']), + ('𞤱', &['𞤏']), + ('𞤲', &['𞤐']), + ('𞤳', &['𞤑']), + ('𞤴', &['𞤒']), + ('𞤵', &['𞤓']), + ('𞤶', &['𞤔']), + ('𞤷', &['𞤕']), + ('𞤸', &['𞤖']), + ('𞤹', &['𞤗']), + ('𞤺', &['𞤘']), + ('𞤻', &['𞤙']), + ('𞤼', &['𞤚']), + ('𞤽', &['𞤛']), + ('𞤾', &['𞤜']), + ('𞤿', &['𞤝']), + ('𞥀', &['𞤞']), + ('𞥁', &['𞤟']), + ('𞥂', &['𞤠']), + ('𞥃', &['𞤡']), +]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/general_category.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/general_category.rs new file mode 100644 index 0000000..7662c46 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/general_category.rs @@ -0,0 +1,6206 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate general-category /tmp/ucd/12.1.0/ --chars --exclude surrogate +// +// ucd-generate is available on crates.io. + +pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] = &[ + ("Cased_Letter", CASED_LETTER), + ("Close_Punctuation", CLOSE_PUNCTUATION), + ("Connector_Punctuation", CONNECTOR_PUNCTUATION), + ("Control", CONTROL), + ("Currency_Symbol", CURRENCY_SYMBOL), + ("Dash_Punctuation", DASH_PUNCTUATION), + ("Decimal_Number", DECIMAL_NUMBER), + ("Enclosing_Mark", ENCLOSING_MARK), + ("Final_Punctuation", FINAL_PUNCTUATION), + ("Format", FORMAT), + ("Initial_Punctuation", INITIAL_PUNCTUATION), + ("Letter", LETTER), + ("Letter_Number", LETTER_NUMBER), + ("Line_Separator", LINE_SEPARATOR), + ("Lowercase_Letter", LOWERCASE_LETTER), + ("Mark", MARK), + ("Math_Symbol", MATH_SYMBOL), + ("Modifier_Letter", MODIFIER_LETTER), + ("Modifier_Symbol", MODIFIER_SYMBOL), + ("Nonspacing_Mark", NONSPACING_MARK), + ("Number", NUMBER), + ("Open_Punctuation", OPEN_PUNCTUATION), + ("Other", OTHER), + ("Other_Letter", OTHER_LETTER), + ("Other_Number", OTHER_NUMBER), + ("Other_Punctuation", OTHER_PUNCTUATION), + ("Other_Symbol", OTHER_SYMBOL), + ("Paragraph_Separator", PARAGRAPH_SEPARATOR), + ("Private_Use", PRIVATE_USE), + ("Punctuation", PUNCTUATION), + ("Separator", SEPARATOR), + ("Space_Separator", SPACE_SEPARATOR), + ("Spacing_Mark", SPACING_MARK), + ("Symbol", SYMBOL), + ("Titlecase_Letter", TITLECASE_LETTER), + ("Unassigned", UNASSIGNED), + ("Uppercase_Letter", UPPERCASE_LETTER), +]; + +pub const CASED_LETTER: &'static [(char, char)] = &[ + ('A', 'Z'), + ('a', 'z'), + ('µ', 'µ'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ƺ'), + ('Ƽ', 'ƿ'), + ('DŽ', 'ʓ'), + ('ʕ', 'ʯ'), + ('Ͱ', 'ͳ'), + ('Ͷ', 'ͷ'), + ('ͻ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϵ'), + ('Ϸ', 'ҁ'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՠ', 'ֈ'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჽ', 'ჿ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ᴀ', 'ᴫ'), + ('ᵫ', 'ᵷ'), + ('ᵹ', 'ᶚ'), + ('Ḁ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('ℙ', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℭ'), + ('ℯ', 'ℴ'), + ('ℹ', 'ℹ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('Ↄ', 'ↄ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⱻ'), + ('Ȿ', 'ⳤ'), + ('Ⳬ', 'ⳮ'), + ('Ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('Ꙁ', 'ꙭ'), + ('Ꚁ', 'ꚛ'), + ('Ꜣ', 'ꝯ'), + ('ꝱ', 'ꞇ'), + ('Ꞌ', 'ꞎ'), + ('Ꞑ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟺ', 'ꟺ'), + ('ꬰ', 'ꭚ'), + ('ꭠ', '\u{ab67}'), + ('ꭰ', 'ꮿ'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('A', 'Z'), + ('a', 'z'), + ('𐐀', '𐑏'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𑢠', '𑣟'), + ('𖹀', '𖹿'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('𞤀', '𞥃'), +]; + +pub const CLOSE_PUNCTUATION: &'static [(char, char)] = &[ + (')', ')'), + (']', ']'), + ('}', '}'), + ('༻', '༻'), + ('༽', '༽'), + ('᚜', '᚜'), + ('⁆', '⁆'), + ('⁾', '⁾'), + ('₎', '₎'), + ('⌉', '⌉'), + ('⌋', '⌋'), + ('〉', '〉'), + ('❩', '❩'), + ('❫', '❫'), + ('❭', '❭'), + ('❯', '❯'), + ('❱', '❱'), + ('❳', '❳'), + ('❵', '❵'), + ('⟆', '⟆'), + ('⟧', '⟧'), + ('⟩', '⟩'), + ('⟫', '⟫'), + ('⟭', '⟭'), + ('⟯', '⟯'), + ('⦄', '⦄'), + ('⦆', '⦆'), + ('⦈', '⦈'), + ('⦊', '⦊'), + ('⦌', '⦌'), + ('⦎', '⦎'), + ('⦐', '⦐'), + ('⦒', '⦒'), + ('⦔', '⦔'), + ('⦖', '⦖'), + ('⦘', '⦘'), + ('⧙', '⧙'), + ('⧛', '⧛'), + ('⧽', '⧽'), + ('⸣', '⸣'), + ('⸥', '⸥'), + ('⸧', '⸧'), + ('⸩', '⸩'), + ('〉', '〉'), + ('》', '》'), + ('」', '」'), + ('』', '』'), + ('】', '】'), + ('〕', '〕'), + ('〗', '〗'), + ('〙', '〙'), + ('〛', '〛'), + ('〞', '〟'), + ('﴾', '﴾'), + ('︘', '︘'), + ('︶', '︶'), + ('︸', '︸'), + ('︺', '︺'), + ('︼', '︼'), + ('︾', '︾'), + ('﹀', '﹀'), + ('﹂', '﹂'), + ('﹄', '﹄'), + ('﹈', '﹈'), + ('﹚', '﹚'), + ('﹜', '﹜'), + ('﹞', '﹞'), + (')', ')'), + (']', ']'), + ('}', '}'), + ('⦆', '⦆'), + ('」', '」'), +]; + +pub const CONNECTOR_PUNCTUATION: &'static [(char, char)] = &[ + ('_', '_'), + ('‿', '⁀'), + ('⁔', '⁔'), + ('︳', '︴'), + ('﹍', '﹏'), + ('_', '_'), +]; + +pub const CONTROL: &'static [(char, char)] = + &[('\u{0}', '\u{1f}'), ('\u{7f}', '\u{9f}')]; + +pub const CURRENCY_SYMBOL: &'static [(char, char)] = &[ + ('$', '$'), + ('¢', '¥'), + ('֏', '֏'), + ('؋', '؋'), + ('߾', '߿'), + ('৲', '৳'), + ('৻', '৻'), + ('૱', '૱'), + ('௹', '௹'), + ('฿', '฿'), + ('៛', '៛'), + ('₠', '₿'), + ('꠸', '꠸'), + ('﷼', '﷼'), + ('﹩', '﹩'), + ('$', '$'), + ('¢', '£'), + ('¥', '₩'), + ('\u{11fdd}', '\u{11fe0}'), + ('\u{1e2ff}', '\u{1e2ff}'), + ('𞲰', '𞲰'), +]; + +pub const DASH_PUNCTUATION: &'static [(char, char)] = &[ + ('-', '-'), + ('֊', '֊'), + ('־', '־'), + ('᐀', '᐀'), + ('᠆', '᠆'), + ('‐', '―'), + ('⸗', '⸗'), + ('⸚', '⸚'), + ('⸺', '⸻'), + ('⹀', '⹀'), + ('〜', '〜'), + ('〰', '〰'), + ('゠', '゠'), + ('︱', '︲'), + ('﹘', '﹘'), + ('﹣', '﹣'), + ('-', '-'), +]; + +pub const DECIMAL_NUMBER: &'static [(char, char)] = &[ + ('0', '9'), + ('٠', '٩'), + ('۰', '۹'), + ('߀', '߉'), + ('०', '९'), + ('০', '৯'), + ('੦', '੯'), + ('૦', '૯'), + ('୦', '୯'), + ('௦', '௯'), + ('౦', '౯'), + ('೦', '೯'), + ('൦', '൯'), + ('෦', '෯'), + ('๐', '๙'), + ('໐', '໙'), + ('༠', '༩'), + ('၀', '၉'), + ('႐', '႙'), + ('០', '៩'), + ('᠐', '᠙'), + ('᥆', '᥏'), + ('᧐', '᧙'), + ('᪀', '᪉'), + ('᪐', '᪙'), + ('᭐', '᭙'), + ('᮰', '᮹'), + ('᱀', '᱉'), + ('᱐', '᱙'), + ('꘠', '꘩'), + ('꣐', '꣙'), + ('꤀', '꤉'), + ('꧐', '꧙'), + ('꧰', '꧹'), + ('꩐', '꩙'), + ('꯰', '꯹'), + ('0', '9'), + ('𐒠', '𐒩'), + ('𐴰', '𐴹'), + ('𑁦', '𑁯'), + ('𑃰', '𑃹'), + ('𑄶', '𑄿'), + ('𑇐', '𑇙'), + ('𑋰', '𑋹'), + ('𑑐', '𑑙'), + ('𑓐', '𑓙'), + ('𑙐', '𑙙'), + ('𑛀', '𑛉'), + ('𑜰', '𑜹'), + ('𑣠', '𑣩'), + ('𑱐', '𑱙'), + ('𑵐', '𑵙'), + ('𑶠', '𑶩'), + ('𖩠', '𖩩'), + ('𖭐', '𖭙'), + ('𝟎', '𝟿'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e2f0}', '\u{1e2f9}'), + ('𞥐', '𞥙'), +]; + +pub const ENCLOSING_MARK: &'static [(char, char)] = &[ + ('\u{488}', '\u{489}'), + ('\u{1abe}', '\u{1abe}'), + ('\u{20dd}', '\u{20e0}'), + ('\u{20e2}', '\u{20e4}'), + ('\u{a670}', '\u{a672}'), +]; + +pub const FINAL_PUNCTUATION: &'static [(char, char)] = &[ + ('»', '»'), + ('’', '’'), + ('”', '”'), + ('›', '›'), + ('⸃', '⸃'), + ('⸅', '⸅'), + ('⸊', '⸊'), + ('⸍', '⸍'), + ('⸝', '⸝'), + ('⸡', '⸡'), +]; + +pub const FORMAT: &'static [(char, char)] = &[ + ('\u{ad}', '\u{ad}'), + ('\u{600}', '\u{605}'), + ('\u{61c}', '\u{61c}'), + ('\u{6dd}', '\u{6dd}'), + ('\u{70f}', '\u{70f}'), + ('\u{8e2}', '\u{8e2}'), + ('\u{180e}', '\u{180e}'), + ('\u{200b}', '\u{200f}'), + ('\u{202a}', '\u{202e}'), + ('\u{2060}', '\u{2064}'), + ('\u{2066}', '\u{206f}'), + ('\u{feff}', '\u{feff}'), + ('\u{fff9}', '\u{fffb}'), + ('\u{110bd}', '\u{110bd}'), + ('\u{110cd}', '\u{110cd}'), + ('\u{13430}', '\u{13438}'), + ('\u{1bca0}', '\u{1bca3}'), + ('\u{1d173}', '\u{1d17a}'), + ('\u{e0001}', '\u{e0001}'), + ('\u{e0020}', '\u{e007f}'), +]; + +pub const INITIAL_PUNCTUATION: &'static [(char, char)] = &[ + ('«', '«'), + ('‘', '‘'), + ('‛', '“'), + ('‟', '‟'), + ('‹', '‹'), + ('⸂', '⸂'), + ('⸄', '⸄'), + ('⸉', '⸉'), + ('⸌', '⸌'), + ('⸜', '⸜'), + ('⸠', '⸠'), +]; + +pub const LETTER: &'static [(char, char)] = &[ + ('A', 'Z'), + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ˁ'), + ('ˆ', 'ˑ'), + ('ˠ', 'ˤ'), + ('ˬ', 'ˬ'), + ('ˮ', 'ˮ'), + ('Ͱ', 'ʹ'), + ('Ͷ', 'ͷ'), + ('ͺ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϵ'), + ('Ϸ', 'ҁ'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՙ', 'ՙ'), + ('ՠ', 'ֈ'), + ('א', 'ת'), + ('ׯ', 'ײ'), + ('ؠ', 'ي'), + ('ٮ', 'ٯ'), + ('ٱ', 'ۓ'), + ('ە', 'ە'), + ('ۥ', 'ۦ'), + ('ۮ', 'ۯ'), + ('ۺ', 'ۼ'), + ('ۿ', 'ۿ'), + ('ܐ', 'ܐ'), + ('ܒ', 'ܯ'), + ('ݍ', 'ޥ'), + ('ޱ', 'ޱ'), + ('ߊ', 'ߪ'), + ('ߴ', 'ߵ'), + ('ߺ', 'ߺ'), + ('ࠀ', 'ࠕ'), + ('ࠚ', 'ࠚ'), + ('ࠤ', 'ࠤ'), + ('ࠨ', 'ࠨ'), + ('ࡀ', 'ࡘ'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('ऄ', 'ह'), + ('ऽ', 'ऽ'), + ('ॐ', 'ॐ'), + ('क़', 'ॡ'), + ('ॱ', 'ঀ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('ঽ', 'ঽ'), + ('ৎ', 'ৎ'), + ('ড়', 'ঢ়'), + ('য়', 'ৡ'), + ('ৰ', 'ৱ'), + ('ৼ', 'ৼ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('ੲ', 'ੴ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('ઽ', 'ઽ'), + ('ૐ', 'ૐ'), + ('ૠ', 'ૡ'), + ('ૹ', 'ૹ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('ଽ', 'ଽ'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', 'ୡ'), + ('ୱ', 'ୱ'), + ('ஃ', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('ௐ', 'ௐ'), + ('అ', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ఽ'), + ('ౘ', 'ౚ'), + ('ౠ', 'ౡ'), + ('ಀ', 'ಀ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('ಽ', 'ಽ'), + ('ೞ', 'ೞ'), + ('ೠ', 'ೡ'), + ('ೱ', 'ೲ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', 'ഺ'), + ('ഽ', 'ഽ'), + ('ൎ', 'ൎ'), + ('ൔ', 'ൖ'), + ('ൟ', 'ൡ'), + ('ൺ', 'ൿ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('ก', 'ะ'), + ('า', 'ำ'), + ('เ', 'ๆ'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ະ'), + ('າ', 'ຳ'), + ('ຽ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('ໜ', 'ໟ'), + ('ༀ', 'ༀ'), + ('ཀ', 'ཇ'), + ('ཉ', 'ཬ'), + ('ྈ', 'ྌ'), + ('က', 'ဪ'), + ('ဿ', 'ဿ'), + ('ၐ', 'ၕ'), + ('ၚ', 'ၝ'), + ('ၡ', 'ၡ'), + ('ၥ', 'ၦ'), + ('ၮ', 'ၰ'), + ('ၵ', 'ႁ'), + ('ႎ', 'ႎ'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჼ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('ᎀ', 'ᎏ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᐁ', 'ᙬ'), + ('ᙯ', 'ᙿ'), + ('ᚁ', 'ᚚ'), + ('ᚠ', 'ᛪ'), + ('ᛱ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', 'ᜑ'), + ('ᜠ', 'ᜱ'), + ('ᝀ', 'ᝑ'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('ក', 'ឳ'), + ('ៗ', 'ៗ'), + ('ៜ', 'ៜ'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢄ'), + ('ᢇ', 'ᢨ'), + ('ᢪ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('ᥐ', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('ᦀ', 'ᦫ'), + ('ᦰ', 'ᧉ'), + ('ᨀ', 'ᨖ'), + ('ᨠ', 'ᩔ'), + ('ᪧ', 'ᪧ'), + ('ᬅ', 'ᬳ'), + ('ᭅ', 'ᭋ'), + ('ᮃ', 'ᮠ'), + ('ᮮ', 'ᮯ'), + ('ᮺ', 'ᯥ'), + ('ᰀ', 'ᰣ'), + ('ᱍ', 'ᱏ'), + ('ᱚ', 'ᱽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ᳩ', 'ᳬ'), + ('ᳮ', 'ᳳ'), + ('ᳵ', 'ᳶ'), + ('\u{1cfa}', '\u{1cfa}'), + ('ᴀ', 'ᶿ'), + ('Ḁ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('ℙ', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℭ'), + ('ℯ', 'ℹ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('Ↄ', 'ↄ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⳤ'), + ('Ⳬ', 'ⳮ'), + ('Ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ⴰ', 'ⵧ'), + ('ⵯ', 'ⵯ'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('ⸯ', 'ⸯ'), + ('々', '〆'), + ('〱', '〵'), + ('〻', '〼'), + ('ぁ', 'ゖ'), + ('ゝ', 'ゟ'), + ('ァ', 'ヺ'), + ('ー', 'ヿ'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('ㆠ', 'ㆺ'), + ('ㇰ', 'ㇿ'), + ('㐀', '䶵'), + ('一', '鿯'), + ('ꀀ', 'ꒌ'), + ('ꓐ', 'ꓽ'), + ('ꔀ', 'ꘌ'), + ('ꘐ', 'ꘟ'), + ('ꘪ', 'ꘫ'), + ('Ꙁ', 'ꙮ'), + ('ꙿ', 'ꚝ'), + ('ꚠ', 'ꛥ'), + ('ꜗ', 'ꜟ'), + ('Ꜣ', 'ꞈ'), + ('Ꞌ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꠁ'), + ('ꠃ', 'ꠅ'), + ('ꠇ', 'ꠊ'), + ('ꠌ', 'ꠢ'), + ('ꡀ', 'ꡳ'), + ('ꢂ', 'ꢳ'), + ('ꣲ', 'ꣷ'), + ('ꣻ', 'ꣻ'), + ('ꣽ', 'ꣾ'), + ('ꤊ', 'ꤥ'), + ('ꤰ', 'ꥆ'), + ('ꥠ', 'ꥼ'), + ('ꦄ', 'ꦲ'), + ('ꧏ', 'ꧏ'), + ('ꧠ', 'ꧤ'), + ('ꧦ', 'ꧯ'), + ('ꧺ', 'ꧾ'), + ('ꨀ', 'ꨨ'), + ('ꩀ', 'ꩂ'), + ('ꩄ', 'ꩋ'), + ('ꩠ', 'ꩶ'), + ('ꩺ', 'ꩺ'), + ('ꩾ', 'ꪯ'), + ('ꪱ', 'ꪱ'), + ('ꪵ', 'ꪶ'), + ('ꪹ', 'ꪽ'), + ('ꫀ', 'ꫀ'), + ('ꫂ', 'ꫂ'), + ('ꫛ', 'ꫝ'), + ('ꫠ', 'ꫪ'), + ('ꫲ', 'ꫴ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', '\u{ab67}'), + ('ꭰ', 'ꯢ'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('豈', '舘'), + ('並', '龎'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('יִ', 'יִ'), + ('ײַ', 'ﬨ'), + ('שׁ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﮱ'), + ('ﯓ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷻ'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('A', 'Z'), + ('a', 'z'), + ('ヲ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('𐌀', '𐌟'), + ('𐌭', '𐍀'), + ('𐍂', '𐍉'), + ('𐍐', '𐍵'), + ('𐎀', '𐎝'), + ('𐎠', '𐏃'), + ('𐏈', '𐏏'), + ('𐐀', '𐒝'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡠', '𐡶'), + ('𐢀', '𐢞'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐤀', '𐤕'), + ('𐤠', '𐤹'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𐨀', '𐨀'), + ('𐨐', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('𐩠', '𐩼'), + ('𐪀', '𐪜'), + ('𐫀', '𐫇'), + ('𐫉', '𐫤'), + ('𐬀', '𐬵'), + ('𐭀', '𐭕'), + ('𐭠', '𐭲'), + ('𐮀', '𐮑'), + ('𐰀', '𐱈'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𐴀', '𐴣'), + ('𐼀', '𐼜'), + ('𐼧', '𐼧'), + ('𐼰', '𐽅'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀃', '𑀷'), + ('𑂃', '𑂯'), + ('𑃐', '𑃨'), + ('𑄃', '𑄦'), + ('𑅄', '𑅄'), + ('𑅐', '𑅲'), + ('𑅶', '𑅶'), + ('𑆃', '𑆲'), + ('𑇁', '𑇄'), + ('𑇚', '𑇚'), + ('𑇜', '𑇜'), + ('𑈀', '𑈑'), + ('𑈓', '𑈫'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊨'), + ('𑊰', '𑋞'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('𑌽', '𑌽'), + ('𑍐', '𑍐'), + ('𑍝', '𑍡'), + ('𑐀', '𑐴'), + ('𑑇', '𑑊'), + ('\u{1145f}', '\u{1145f}'), + ('𑒀', '𑒯'), + ('𑓄', '𑓅'), + ('𑓇', '𑓇'), + ('𑖀', '𑖮'), + ('𑗘', '𑗛'), + ('𑘀', '𑘯'), + ('𑙄', '𑙄'), + ('𑚀', '𑚪'), + ('\u{116b8}', '\u{116b8}'), + ('𑜀', '𑜚'), + ('𑠀', '𑠫'), + ('𑢠', '𑣟'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d0}'), + ('\u{119e1}', '\u{119e1}'), + ('\u{119e3}', '\u{119e3}'), + ('𑨀', '𑨀'), + ('𑨋', '𑨲'), + ('𑨺', '𑨺'), + ('𑩐', '𑩐'), + ('𑩜', '𑪉'), + ('𑪝', '𑪝'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '𑰮'), + ('𑱀', '𑱀'), + ('𑱲', '𑲏'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '𑴰'), + ('𑵆', '𑵆'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶉'), + ('𑶘', '𑶘'), + ('𑻠', '𑻲'), + ('𒀀', '𒎙'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖫐', '𖫭'), + ('𖬀', '𖬯'), + ('𖭀', '𖭃'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖹀', '𖹿'), + ('𖼀', '\u{16f4a}'), + ('𖽐', '𖽐'), + ('𖾓', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛀀', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('𛅰', '𛋻'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e137}', '\u{1e13d}'), + ('\u{1e14e}', '\u{1e14e}'), + ('\u{1e2c0}', '\u{1e2eb}'), + ('𞠀', '𞣄'), + ('𞤀', '𞥃'), + ('\u{1e94b}', '\u{1e94b}'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), +]; + +pub const LETTER_NUMBER: &'static [(char, char)] = &[ + ('ᛮ', 'ᛰ'), + ('Ⅰ', 'ↂ'), + ('ↅ', 'ↈ'), + ('〇', '〇'), + ('〡', '〩'), + ('〸', '〺'), + ('ꛦ', 'ꛯ'), + ('𐅀', '𐅴'), + ('𐍁', '𐍁'), + ('𐍊', '𐍊'), + ('𐏑', '𐏕'), + ('𒐀', '𒑮'), +]; + +pub const LINE_SEPARATOR: &'static [(char, char)] = + &[('\u{2028}', '\u{2028}')]; + +pub const LOWERCASE_LETTER: &'static [(char, char)] = &[ + ('a', 'z'), + ('µ', 'µ'), + ('ß', 'ö'), + ('ø', 'ÿ'), + ('ā', 'ā'), + ('ă', 'ă'), + ('ą', 'ą'), + ('ć', 'ć'), + ('ĉ', 'ĉ'), + ('ċ', 'ċ'), + ('č', 'č'), + ('ď', 'ď'), + ('đ', 'đ'), + ('ē', 'ē'), + ('ĕ', 'ĕ'), + ('ė', 'ė'), + ('ę', 'ę'), + ('ě', 'ě'), + ('ĝ', 'ĝ'), + ('ğ', 'ğ'), + ('ġ', 'ġ'), + ('ģ', 'ģ'), + ('ĥ', 'ĥ'), + ('ħ', 'ħ'), + ('ĩ', 'ĩ'), + ('ī', 'ī'), + ('ĭ', 'ĭ'), + ('į', 'į'), + ('ı', 'ı'), + ('ij', 'ij'), + ('ĵ', 'ĵ'), + ('ķ', 'ĸ'), + ('ĺ', 'ĺ'), + ('ļ', 'ļ'), + ('ľ', 'ľ'), + ('ŀ', 'ŀ'), + ('ł', 'ł'), + ('ń', 'ń'), + ('ņ', 'ņ'), + ('ň', 'ʼn'), + ('ŋ', 'ŋ'), + ('ō', 'ō'), + ('ŏ', 'ŏ'), + ('ő', 'ő'), + ('œ', 'œ'), + ('ŕ', 'ŕ'), + ('ŗ', 'ŗ'), + ('ř', 'ř'), + ('ś', 'ś'), + ('ŝ', 'ŝ'), + ('ş', 'ş'), + ('š', 'š'), + ('ţ', 'ţ'), + ('ť', 'ť'), + ('ŧ', 'ŧ'), + ('ũ', 'ũ'), + ('ū', 'ū'), + ('ŭ', 'ŭ'), + ('ů', 'ů'), + ('ű', 'ű'), + ('ų', 'ų'), + ('ŵ', 'ŵ'), + ('ŷ', 'ŷ'), + ('ź', 'ź'), + ('ż', 'ż'), + ('ž', 'ƀ'), + ('ƃ', 'ƃ'), + ('ƅ', 'ƅ'), + ('ƈ', 'ƈ'), + ('ƌ', 'ƍ'), + ('ƒ', 'ƒ'), + ('ƕ', 'ƕ'), + ('ƙ', 'ƛ'), + ('ƞ', 'ƞ'), + ('ơ', 'ơ'), + ('ƣ', 'ƣ'), + ('ƥ', 'ƥ'), + ('ƨ', 'ƨ'), + ('ƪ', 'ƫ'), + ('ƭ', 'ƭ'), + ('ư', 'ư'), + ('ƴ', 'ƴ'), + ('ƶ', 'ƶ'), + ('ƹ', 'ƺ'), + ('ƽ', 'ƿ'), + ('dž', 'dž'), + ('lj', 'lj'), + ('nj', 'nj'), + ('ǎ', 'ǎ'), + ('ǐ', 'ǐ'), + ('ǒ', 'ǒ'), + ('ǔ', 'ǔ'), + ('ǖ', 'ǖ'), + ('ǘ', 'ǘ'), + ('ǚ', 'ǚ'), + ('ǜ', 'ǝ'), + ('ǟ', 'ǟ'), + ('ǡ', 'ǡ'), + ('ǣ', 'ǣ'), + ('ǥ', 'ǥ'), + ('ǧ', 'ǧ'), + ('ǩ', 'ǩ'), + ('ǫ', 'ǫ'), + ('ǭ', 'ǭ'), + ('ǯ', 'ǰ'), + ('dz', 'dz'), + ('ǵ', 'ǵ'), + ('ǹ', 'ǹ'), + ('ǻ', 'ǻ'), + ('ǽ', 'ǽ'), + ('ǿ', 'ǿ'), + ('ȁ', 'ȁ'), + ('ȃ', 'ȃ'), + ('ȅ', 'ȅ'), + ('ȇ', 'ȇ'), + ('ȉ', 'ȉ'), + ('ȋ', 'ȋ'), + ('ȍ', 'ȍ'), + ('ȏ', 'ȏ'), + ('ȑ', 'ȑ'), + ('ȓ', 'ȓ'), + ('ȕ', 'ȕ'), + ('ȗ', 'ȗ'), + ('ș', 'ș'), + ('ț', 'ț'), + ('ȝ', 'ȝ'), + ('ȟ', 'ȟ'), + ('ȡ', 'ȡ'), + ('ȣ', 'ȣ'), + ('ȥ', 'ȥ'), + ('ȧ', 'ȧ'), + ('ȩ', 'ȩ'), + ('ȫ', 'ȫ'), + ('ȭ', 'ȭ'), + ('ȯ', 'ȯ'), + ('ȱ', 'ȱ'), + ('ȳ', 'ȹ'), + ('ȼ', 'ȼ'), + ('ȿ', 'ɀ'), + ('ɂ', 'ɂ'), + ('ɇ', 'ɇ'), + ('ɉ', 'ɉ'), + ('ɋ', 'ɋ'), + ('ɍ', 'ɍ'), + ('ɏ', 'ʓ'), + ('ʕ', 'ʯ'), + ('ͱ', 'ͱ'), + ('ͳ', 'ͳ'), + ('ͷ', 'ͷ'), + ('ͻ', 'ͽ'), + ('ΐ', 'ΐ'), + ('ά', 'ώ'), + ('ϐ', 'ϑ'), + ('ϕ', 'ϗ'), + ('ϙ', 'ϙ'), + ('ϛ', 'ϛ'), + ('ϝ', 'ϝ'), + ('ϟ', 'ϟ'), + ('ϡ', 'ϡ'), + ('ϣ', 'ϣ'), + ('ϥ', 'ϥ'), + ('ϧ', 'ϧ'), + ('ϩ', 'ϩ'), + ('ϫ', 'ϫ'), + ('ϭ', 'ϭ'), + ('ϯ', 'ϳ'), + ('ϵ', 'ϵ'), + ('ϸ', 'ϸ'), + ('ϻ', 'ϼ'), + ('а', 'џ'), + ('ѡ', 'ѡ'), + ('ѣ', 'ѣ'), + ('ѥ', 'ѥ'), + ('ѧ', 'ѧ'), + ('ѩ', 'ѩ'), + ('ѫ', 'ѫ'), + ('ѭ', 'ѭ'), + ('ѯ', 'ѯ'), + ('ѱ', 'ѱ'), + ('ѳ', 'ѳ'), + ('ѵ', 'ѵ'), + ('ѷ', 'ѷ'), + ('ѹ', 'ѹ'), + ('ѻ', 'ѻ'), + ('ѽ', 'ѽ'), + ('ѿ', 'ѿ'), + ('ҁ', 'ҁ'), + ('ҋ', 'ҋ'), + ('ҍ', 'ҍ'), + ('ҏ', 'ҏ'), + ('ґ', 'ґ'), + ('ғ', 'ғ'), + ('ҕ', 'ҕ'), + ('җ', 'җ'), + ('ҙ', 'ҙ'), + ('қ', 'қ'), + ('ҝ', 'ҝ'), + ('ҟ', 'ҟ'), + ('ҡ', 'ҡ'), + ('ң', 'ң'), + ('ҥ', 'ҥ'), + ('ҧ', 'ҧ'), + ('ҩ', 'ҩ'), + ('ҫ', 'ҫ'), + ('ҭ', 'ҭ'), + ('ү', 'ү'), + ('ұ', 'ұ'), + ('ҳ', 'ҳ'), + ('ҵ', 'ҵ'), + ('ҷ', 'ҷ'), + ('ҹ', 'ҹ'), + ('һ', 'һ'), + ('ҽ', 'ҽ'), + ('ҿ', 'ҿ'), + ('ӂ', 'ӂ'), + ('ӄ', 'ӄ'), + ('ӆ', 'ӆ'), + ('ӈ', 'ӈ'), + ('ӊ', 'ӊ'), + ('ӌ', 'ӌ'), + ('ӎ', 'ӏ'), + ('ӑ', 'ӑ'), + ('ӓ', 'ӓ'), + ('ӕ', 'ӕ'), + ('ӗ', 'ӗ'), + ('ә', 'ә'), + ('ӛ', 'ӛ'), + ('ӝ', 'ӝ'), + ('ӟ', 'ӟ'), + ('ӡ', 'ӡ'), + ('ӣ', 'ӣ'), + ('ӥ', 'ӥ'), + ('ӧ', 'ӧ'), + ('ө', 'ө'), + ('ӫ', 'ӫ'), + ('ӭ', 'ӭ'), + ('ӯ', 'ӯ'), + ('ӱ', 'ӱ'), + ('ӳ', 'ӳ'), + ('ӵ', 'ӵ'), + ('ӷ', 'ӷ'), + ('ӹ', 'ӹ'), + ('ӻ', 'ӻ'), + ('ӽ', 'ӽ'), + ('ӿ', 'ӿ'), + ('ԁ', 'ԁ'), + ('ԃ', 'ԃ'), + ('ԅ', 'ԅ'), + ('ԇ', 'ԇ'), + ('ԉ', 'ԉ'), + ('ԋ', 'ԋ'), + ('ԍ', 'ԍ'), + ('ԏ', 'ԏ'), + ('ԑ', 'ԑ'), + ('ԓ', 'ԓ'), + ('ԕ', 'ԕ'), + ('ԗ', 'ԗ'), + ('ԙ', 'ԙ'), + ('ԛ', 'ԛ'), + ('ԝ', 'ԝ'), + ('ԟ', 'ԟ'), + ('ԡ', 'ԡ'), + ('ԣ', 'ԣ'), + ('ԥ', 'ԥ'), + ('ԧ', 'ԧ'), + ('ԩ', 'ԩ'), + ('ԫ', 'ԫ'), + ('ԭ', 'ԭ'), + ('ԯ', 'ԯ'), + ('ՠ', 'ֈ'), + ('ა', 'ჺ'), + ('ჽ', 'ჿ'), + ('ᏸ', 'ᏽ'), + ('ᲀ', 'ᲈ'), + ('ᴀ', 'ᴫ'), + ('ᵫ', 'ᵷ'), + ('ᵹ', 'ᶚ'), + ('ḁ', 'ḁ'), + ('ḃ', 'ḃ'), + ('ḅ', 'ḅ'), + ('ḇ', 'ḇ'), + ('ḉ', 'ḉ'), + ('ḋ', 'ḋ'), + ('ḍ', 'ḍ'), + ('ḏ', 'ḏ'), + ('ḑ', 'ḑ'), + ('ḓ', 'ḓ'), + ('ḕ', 'ḕ'), + ('ḗ', 'ḗ'), + ('ḙ', 'ḙ'), + ('ḛ', 'ḛ'), + ('ḝ', 'ḝ'), + ('ḟ', 'ḟ'), + ('ḡ', 'ḡ'), + ('ḣ', 'ḣ'), + ('ḥ', 'ḥ'), + ('ḧ', 'ḧ'), + ('ḩ', 'ḩ'), + ('ḫ', 'ḫ'), + ('ḭ', 'ḭ'), + ('ḯ', 'ḯ'), + ('ḱ', 'ḱ'), + ('ḳ', 'ḳ'), + ('ḵ', 'ḵ'), + ('ḷ', 'ḷ'), + ('ḹ', 'ḹ'), + ('ḻ', 'ḻ'), + ('ḽ', 'ḽ'), + ('ḿ', 'ḿ'), + ('ṁ', 'ṁ'), + ('ṃ', 'ṃ'), + ('ṅ', 'ṅ'), + ('ṇ', 'ṇ'), + ('ṉ', 'ṉ'), + ('ṋ', 'ṋ'), + ('ṍ', 'ṍ'), + ('ṏ', 'ṏ'), + ('ṑ', 'ṑ'), + ('ṓ', 'ṓ'), + ('ṕ', 'ṕ'), + ('ṗ', 'ṗ'), + ('ṙ', 'ṙ'), + ('ṛ', 'ṛ'), + ('ṝ', 'ṝ'), + ('ṟ', 'ṟ'), + ('ṡ', 'ṡ'), + ('ṣ', 'ṣ'), + ('ṥ', 'ṥ'), + ('ṧ', 'ṧ'), + ('ṩ', 'ṩ'), + ('ṫ', 'ṫ'), + ('ṭ', 'ṭ'), + ('ṯ', 'ṯ'), + ('ṱ', 'ṱ'), + ('ṳ', 'ṳ'), + ('ṵ', 'ṵ'), + ('ṷ', 'ṷ'), + ('ṹ', 'ṹ'), + ('ṻ', 'ṻ'), + ('ṽ', 'ṽ'), + ('ṿ', 'ṿ'), + ('ẁ', 'ẁ'), + ('ẃ', 'ẃ'), + ('ẅ', 'ẅ'), + ('ẇ', 'ẇ'), + ('ẉ', 'ẉ'), + ('ẋ', 'ẋ'), + ('ẍ', 'ẍ'), + ('ẏ', 'ẏ'), + ('ẑ', 'ẑ'), + ('ẓ', 'ẓ'), + ('ẕ', 'ẝ'), + ('ẟ', 'ẟ'), + ('ạ', 'ạ'), + ('ả', 'ả'), + ('ấ', 'ấ'), + ('ầ', 'ầ'), + ('ẩ', 'ẩ'), + ('ẫ', 'ẫ'), + ('ậ', 'ậ'), + ('ắ', 'ắ'), + ('ằ', 'ằ'), + ('ẳ', 'ẳ'), + ('ẵ', 'ẵ'), + ('ặ', 'ặ'), + ('ẹ', 'ẹ'), + ('ẻ', 'ẻ'), + ('ẽ', 'ẽ'), + ('ế', 'ế'), + ('ề', 'ề'), + ('ể', 'ể'), + ('ễ', 'ễ'), + ('ệ', 'ệ'), + ('ỉ', 'ỉ'), + ('ị', 'ị'), + ('ọ', 'ọ'), + ('ỏ', 'ỏ'), + ('ố', 'ố'), + ('ồ', 'ồ'), + ('ổ', 'ổ'), + ('ỗ', 'ỗ'), + ('ộ', 'ộ'), + ('ớ', 'ớ'), + ('ờ', 'ờ'), + ('ở', 'ở'), + ('ỡ', 'ỡ'), + ('ợ', 'ợ'), + ('ụ', 'ụ'), + ('ủ', 'ủ'), + ('ứ', 'ứ'), + ('ừ', 'ừ'), + ('ử', 'ử'), + ('ữ', 'ữ'), + ('ự', 'ự'), + ('ỳ', 'ỳ'), + ('ỵ', 'ỵ'), + ('ỷ', 'ỷ'), + ('ỹ', 'ỹ'), + ('ỻ', 'ỻ'), + ('ỽ', 'ỽ'), + ('ỿ', 'ἇ'), + ('ἐ', 'ἕ'), + ('ἠ', 'ἧ'), + ('ἰ', 'ἷ'), + ('ὀ', 'ὅ'), + ('ὐ', 'ὗ'), + ('ὠ', 'ὧ'), + ('ὰ', 'ώ'), + ('ᾀ', 'ᾇ'), + ('ᾐ', 'ᾗ'), + ('ᾠ', 'ᾧ'), + ('ᾰ', 'ᾴ'), + ('ᾶ', 'ᾷ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῇ'), + ('ῐ', 'ΐ'), + ('ῖ', 'ῗ'), + ('ῠ', 'ῧ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῷ'), + ('ℊ', 'ℊ'), + ('ℎ', 'ℏ'), + ('ℓ', 'ℓ'), + ('ℯ', 'ℯ'), + ('ℴ', 'ℴ'), + ('ℹ', 'ℹ'), + ('ℼ', 'ℽ'), + ('ⅆ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('ↄ', 'ↄ'), + ('ⰰ', 'ⱞ'), + ('ⱡ', 'ⱡ'), + ('ⱥ', 'ⱦ'), + ('ⱨ', 'ⱨ'), + ('ⱪ', 'ⱪ'), + ('ⱬ', 'ⱬ'), + ('ⱱ', 'ⱱ'), + ('ⱳ', 'ⱴ'), + ('ⱶ', 'ⱻ'), + ('ⲁ', 'ⲁ'), + ('ⲃ', 'ⲃ'), + ('ⲅ', 'ⲅ'), + ('ⲇ', 'ⲇ'), + ('ⲉ', 'ⲉ'), + ('ⲋ', 'ⲋ'), + ('ⲍ', 'ⲍ'), + ('ⲏ', 'ⲏ'), + ('ⲑ', 'ⲑ'), + ('ⲓ', 'ⲓ'), + ('ⲕ', 'ⲕ'), + ('ⲗ', 'ⲗ'), + ('ⲙ', 'ⲙ'), + ('ⲛ', 'ⲛ'), + ('ⲝ', 'ⲝ'), + ('ⲟ', 'ⲟ'), + ('ⲡ', 'ⲡ'), + ('ⲣ', 'ⲣ'), + ('ⲥ', 'ⲥ'), + ('ⲧ', 'ⲧ'), + ('ⲩ', 'ⲩ'), + ('ⲫ', 'ⲫ'), + ('ⲭ', 'ⲭ'), + ('ⲯ', 'ⲯ'), + ('ⲱ', 'ⲱ'), + ('ⲳ', 'ⲳ'), + ('ⲵ', 'ⲵ'), + ('ⲷ', 'ⲷ'), + ('ⲹ', 'ⲹ'), + ('ⲻ', 'ⲻ'), + ('ⲽ', 'ⲽ'), + ('ⲿ', 'ⲿ'), + ('ⳁ', 'ⳁ'), + ('ⳃ', 'ⳃ'), + ('ⳅ', 'ⳅ'), + ('ⳇ', 'ⳇ'), + ('ⳉ', 'ⳉ'), + ('ⳋ', 'ⳋ'), + ('ⳍ', 'ⳍ'), + ('ⳏ', 'ⳏ'), + ('ⳑ', 'ⳑ'), + ('ⳓ', 'ⳓ'), + ('ⳕ', 'ⳕ'), + ('ⳗ', 'ⳗ'), + ('ⳙ', 'ⳙ'), + ('ⳛ', 'ⳛ'), + ('ⳝ', 'ⳝ'), + ('ⳟ', 'ⳟ'), + ('ⳡ', 'ⳡ'), + ('ⳣ', 'ⳤ'), + ('ⳬ', 'ⳬ'), + ('ⳮ', 'ⳮ'), + ('ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ꙁ', 'ꙁ'), + ('ꙃ', 'ꙃ'), + ('ꙅ', 'ꙅ'), + ('ꙇ', 'ꙇ'), + ('ꙉ', 'ꙉ'), + ('ꙋ', 'ꙋ'), + ('ꙍ', 'ꙍ'), + ('ꙏ', 'ꙏ'), + ('ꙑ', 'ꙑ'), + ('ꙓ', 'ꙓ'), + ('ꙕ', 'ꙕ'), + ('ꙗ', 'ꙗ'), + ('ꙙ', 'ꙙ'), + ('ꙛ', 'ꙛ'), + ('ꙝ', 'ꙝ'), + ('ꙟ', 'ꙟ'), + ('ꙡ', 'ꙡ'), + ('ꙣ', 'ꙣ'), + ('ꙥ', 'ꙥ'), + ('ꙧ', 'ꙧ'), + ('ꙩ', 'ꙩ'), + ('ꙫ', 'ꙫ'), + ('ꙭ', 'ꙭ'), + ('ꚁ', 'ꚁ'), + ('ꚃ', 'ꚃ'), + ('ꚅ', 'ꚅ'), + ('ꚇ', 'ꚇ'), + ('ꚉ', 'ꚉ'), + ('ꚋ', 'ꚋ'), + ('ꚍ', 'ꚍ'), + ('ꚏ', 'ꚏ'), + ('ꚑ', 'ꚑ'), + ('ꚓ', 'ꚓ'), + ('ꚕ', 'ꚕ'), + ('ꚗ', 'ꚗ'), + ('ꚙ', 'ꚙ'), + ('ꚛ', 'ꚛ'), + ('ꜣ', 'ꜣ'), + ('ꜥ', 'ꜥ'), + ('ꜧ', 'ꜧ'), + ('ꜩ', 'ꜩ'), + ('ꜫ', 'ꜫ'), + ('ꜭ', 'ꜭ'), + ('ꜯ', 'ꜱ'), + ('ꜳ', 'ꜳ'), + ('ꜵ', 'ꜵ'), + ('ꜷ', 'ꜷ'), + ('ꜹ', 'ꜹ'), + ('ꜻ', 'ꜻ'), + ('ꜽ', 'ꜽ'), + ('ꜿ', 'ꜿ'), + ('ꝁ', 'ꝁ'), + ('ꝃ', 'ꝃ'), + ('ꝅ', 'ꝅ'), + ('ꝇ', 'ꝇ'), + ('ꝉ', 'ꝉ'), + ('ꝋ', 'ꝋ'), + ('ꝍ', 'ꝍ'), + ('ꝏ', 'ꝏ'), + ('ꝑ', 'ꝑ'), + ('ꝓ', 'ꝓ'), + ('ꝕ', 'ꝕ'), + ('ꝗ', 'ꝗ'), + ('ꝙ', 'ꝙ'), + ('ꝛ', 'ꝛ'), + ('ꝝ', 'ꝝ'), + ('ꝟ', 'ꝟ'), + ('ꝡ', 'ꝡ'), + ('ꝣ', 'ꝣ'), + ('ꝥ', 'ꝥ'), + ('ꝧ', 'ꝧ'), + ('ꝩ', 'ꝩ'), + ('ꝫ', 'ꝫ'), + ('ꝭ', 'ꝭ'), + ('ꝯ', 'ꝯ'), + ('ꝱ', 'ꝸ'), + ('ꝺ', 'ꝺ'), + ('ꝼ', 'ꝼ'), + ('ꝿ', 'ꝿ'), + ('ꞁ', 'ꞁ'), + ('ꞃ', 'ꞃ'), + ('ꞅ', 'ꞅ'), + ('ꞇ', 'ꞇ'), + ('ꞌ', 'ꞌ'), + ('ꞎ', 'ꞎ'), + ('ꞑ', 'ꞑ'), + ('ꞓ', 'ꞕ'), + ('ꞗ', 'ꞗ'), + ('ꞙ', 'ꞙ'), + ('ꞛ', 'ꞛ'), + ('ꞝ', 'ꞝ'), + ('ꞟ', 'ꞟ'), + ('ꞡ', 'ꞡ'), + ('ꞣ', 'ꞣ'), + ('ꞥ', 'ꞥ'), + ('ꞧ', 'ꞧ'), + ('ꞩ', 'ꞩ'), + ('ꞯ', 'ꞯ'), + ('ꞵ', 'ꞵ'), + ('ꞷ', 'ꞷ'), + ('ꞹ', 'ꞹ'), + ('\u{a7bb}', '\u{a7bb}'), + ('\u{a7bd}', '\u{a7bd}'), + ('\u{a7bf}', '\u{a7bf}'), + ('\u{a7c3}', '\u{a7c3}'), + ('ꟺ', 'ꟺ'), + ('ꬰ', 'ꭚ'), + ('ꭠ', '\u{ab67}'), + ('ꭰ', 'ꮿ'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('a', 'z'), + ('𐐨', '𐑏'), + ('𐓘', '𐓻'), + ('𐳀', '𐳲'), + ('𑣀', '𑣟'), + ('𖹠', '𖹿'), + ('𝐚', '𝐳'), + ('𝑎', '𝑔'), + ('𝑖', '𝑧'), + ('𝒂', '𝒛'), + ('𝒶', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝓏'), + ('𝓪', '𝔃'), + ('𝔞', '𝔷'), + ('𝕒', '𝕫'), + ('𝖆', '𝖟'), + ('𝖺', '𝗓'), + ('𝗮', '𝘇'), + ('𝘢', '𝘻'), + ('𝙖', '𝙯'), + ('𝚊', '𝚥'), + ('𝛂', '𝛚'), + ('𝛜', '𝛡'), + ('𝛼', '𝜔'), + ('𝜖', '𝜛'), + ('𝜶', '𝝎'), + ('𝝐', '𝝕'), + ('𝝰', '𝞈'), + ('𝞊', '𝞏'), + ('𝞪', '𝟂'), + ('𝟄', '𝟉'), + ('𝟋', '𝟋'), + ('𞤢', '𞥃'), +]; + +pub const MARK: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), + ('\u{483}', '\u{489}'), + ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('\u{610}', '\u{61a}'), + ('\u{64b}', '\u{65f}'), + ('\u{670}', '\u{670}'), + ('\u{6d6}', '\u{6dc}'), + ('\u{6df}', '\u{6e4}'), + ('\u{6e7}', '\u{6e8}'), + ('\u{6ea}', '\u{6ed}'), + ('\u{711}', '\u{711}'), + ('\u{730}', '\u{74a}'), + ('\u{7a6}', '\u{7b0}'), + ('\u{7eb}', '\u{7f3}'), + ('\u{7fd}', '\u{7fd}'), + ('\u{816}', '\u{819}'), + ('\u{81b}', '\u{823}'), + ('\u{825}', '\u{827}'), + ('\u{829}', '\u{82d}'), + ('\u{859}', '\u{85b}'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', 'ः'), + ('\u{93a}', '\u{93c}'), + ('ा', 'ॏ'), + ('\u{951}', '\u{957}'), + ('\u{962}', '\u{963}'), + ('\u{981}', 'ঃ'), + ('\u{9bc}', '\u{9bc}'), + ('\u{9be}', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', '\u{9cd}'), + ('\u{9d7}', '\u{9d7}'), + ('\u{9e2}', '\u{9e3}'), + ('\u{9fe}', '\u{9fe}'), + ('\u{a01}', 'ਃ'), + ('\u{a3c}', '\u{a3c}'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('\u{a70}', '\u{a71}'), + ('\u{a75}', '\u{a75}'), + ('\u{a81}', 'ઃ'), + ('\u{abc}', '\u{abc}'), + ('ા', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', '\u{acd}'), + ('\u{ae2}', '\u{ae3}'), + ('\u{afa}', '\u{aff}'), + ('\u{b01}', 'ଃ'), + ('\u{b3c}', '\u{b3c}'), + ('\u{b3e}', '\u{b44}'), + ('େ', 'ୈ'), + ('ୋ', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('\u{b62}', '\u{b63}'), + ('\u{b82}', '\u{b82}'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', '\u{bcd}'), + ('\u{bd7}', '\u{bd7}'), + ('\u{c00}', '\u{c04}'), + ('\u{c3e}', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('\u{c62}', '\u{c63}'), + ('\u{c81}', 'ಃ'), + ('\u{cbc}', '\u{cbc}'), + ('ಾ', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('\u{ce2}', '\u{ce3}'), + ('\u{d00}', 'ഃ'), + ('\u{d3b}', '\u{d3c}'), + ('\u{d3e}', '\u{d44}'), + ('െ', 'ൈ'), + ('ൊ', '\u{d4d}'), + ('\u{d57}', '\u{d57}'), + ('\u{d62}', '\u{d63}'), + ('ං', 'ඃ'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('ෲ', 'ෳ'), + ('\u{e31}', '\u{e31}'), + ('\u{e34}', '\u{e3a}'), + ('\u{e47}', '\u{e4e}'), + ('\u{eb1}', '\u{eb1}'), + ('\u{eb4}', '\u{ebc}'), + ('\u{ec8}', '\u{ecd}'), + ('\u{f18}', '\u{f19}'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('༾', '༿'), + ('\u{f71}', '\u{f84}'), + ('\u{f86}', '\u{f87}'), + ('\u{f8d}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), + ('ါ', '\u{103e}'), + ('ၖ', '\u{1059}'), + ('\u{105e}', '\u{1060}'), + ('ၢ', 'ၤ'), + ('ၧ', 'ၭ'), + ('\u{1071}', '\u{1074}'), + ('\u{1082}', '\u{108d}'), + ('ႏ', 'ႏ'), + ('ႚ', '\u{109d}'), + ('\u{135d}', '\u{135f}'), + ('\u{1712}', '\u{1714}'), + ('\u{1732}', '\u{1734}'), + ('\u{1752}', '\u{1753}'), + ('\u{1772}', '\u{1773}'), + ('\u{17b4}', '\u{17d3}'), + ('\u{17dd}', '\u{17dd}'), + ('\u{180b}', '\u{180d}'), + ('\u{1885}', '\u{1886}'), + ('\u{18a9}', '\u{18a9}'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', '\u{193b}'), + ('\u{1a17}', '\u{1a1b}'), + ('ᩕ', '\u{1a5e}'), + ('\u{1a60}', '\u{1a7c}'), + ('\u{1a7f}', '\u{1a7f}'), + ('\u{1ab0}', '\u{1abe}'), + ('\u{1b00}', 'ᬄ'), + ('\u{1b34}', '᭄'), + ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', 'ᮂ'), + ('ᮡ', '\u{1bad}'), + ('\u{1be6}', '᯳'), + ('ᰤ', '\u{1c37}'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1ce8}'), + ('\u{1ced}', '\u{1ced}'), + ('\u{1cf4}', '\u{1cf4}'), + ('᳷', '\u{1cf9}'), + ('\u{1dc0}', '\u{1df9}'), + ('\u{1dfb}', '\u{1dff}'), + ('\u{20d0}', '\u{20f0}'), + ('\u{2cef}', '\u{2cf1}'), + ('\u{2d7f}', '\u{2d7f}'), + ('\u{2de0}', '\u{2dff}'), + ('\u{302a}', '\u{302f}'), + ('\u{3099}', '\u{309a}'), + ('\u{a66f}', '\u{a672}'), + ('\u{a674}', '\u{a67d}'), + ('\u{a69e}', '\u{a69f}'), + ('\u{a6f0}', '\u{a6f1}'), + ('\u{a802}', '\u{a802}'), + ('\u{a806}', '\u{a806}'), + ('\u{a80b}', '\u{a80b}'), + ('ꠣ', 'ꠧ'), + ('ꢀ', 'ꢁ'), + ('ꢴ', '\u{a8c5}'), + ('\u{a8e0}', '\u{a8f1}'), + ('\u{a8ff}', '\u{a8ff}'), + ('\u{a926}', '\u{a92d}'), + ('\u{a947}', '꥓'), + ('\u{a980}', 'ꦃ'), + ('\u{a9b3}', '꧀'), + ('\u{a9e5}', '\u{a9e5}'), + ('\u{aa29}', '\u{aa36}'), + ('\u{aa43}', '\u{aa43}'), + ('\u{aa4c}', 'ꩍ'), + ('ꩻ', 'ꩽ'), + ('\u{aab0}', '\u{aab0}'), + ('\u{aab2}', '\u{aab4}'), + ('\u{aab7}', '\u{aab8}'), + ('\u{aabe}', '\u{aabf}'), + ('\u{aac1}', '\u{aac1}'), + ('ꫫ', 'ꫯ'), + ('ꫵ', '\u{aaf6}'), + ('ꯣ', 'ꯪ'), + ('꯬', '\u{abed}'), + ('\u{fb1e}', '\u{fb1e}'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2f}'), + ('\u{101fd}', '\u{101fd}'), + ('\u{102e0}', '\u{102e0}'), + ('\u{10376}', '\u{1037a}'), + ('\u{10a01}', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a0f}'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), + ('\u{10ae5}', '\u{10ae6}'), + ('\u{10d24}', '\u{10d27}'), + ('\u{10f46}', '\u{10f50}'), + ('𑀀', '𑀂'), + ('\u{11038}', '\u{11046}'), + ('\u{1107f}', '𑂂'), + ('𑂰', '\u{110ba}'), + ('\u{11100}', '\u{11102}'), + ('\u{11127}', '\u{11134}'), + ('𑅅', '𑅆'), + ('\u{11173}', '\u{11173}'), + ('\u{11180}', '𑆂'), + ('𑆳', '𑇀'), + ('\u{111c9}', '\u{111cc}'), + ('𑈬', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('\u{112df}', '\u{112ea}'), + ('\u{11300}', '𑌃'), + ('\u{1133b}', '\u{1133c}'), + ('\u{1133e}', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('\u{11357}', '\u{11357}'), + ('𑍢', '𑍣'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('𑐵', '\u{11446}'), + ('\u{1145e}', '\u{1145e}'), + ('\u{114b0}', '\u{114c3}'), + ('\u{115af}', '\u{115b5}'), + ('𑖸', '\u{115c0}'), + ('\u{115dc}', '\u{115dd}'), + ('𑘰', '\u{11640}'), + ('\u{116ab}', '\u{116b7}'), + ('\u{1171d}', '\u{1172b}'), + ('𑠬', '\u{1183a}'), + ('\u{119d1}', '\u{119d7}'), + ('\u{119da}', '\u{119e0}'), + ('\u{119e4}', '\u{119e4}'), + ('\u{11a01}', '\u{11a0a}'), + ('\u{11a33}', '𑨹'), + ('\u{11a3b}', '\u{11a3e}'), + ('\u{11a47}', '\u{11a47}'), + ('\u{11a51}', '\u{11a5b}'), + ('\u{11a8a}', '\u{11a99}'), + ('𑰯', '\u{11c36}'), + ('\u{11c38}', '\u{11c3f}'), + ('\u{11c92}', '\u{11ca7}'), + ('𑲩', '\u{11cb6}'), + ('\u{11d31}', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d45}'), + ('\u{11d47}', '\u{11d47}'), + ('𑶊', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '\u{11d97}'), + ('\u{11ef3}', '𑻶'), + ('\u{16af0}', '\u{16af4}'), + ('\u{16b30}', '\u{16b36}'), + ('\u{16f4f}', '\u{16f4f}'), + ('𖽑', '\u{16f87}'), + ('\u{16f8f}', '\u{16f92}'), + ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d165}', '\u{1d169}'), + ('𝅭', '\u{1d172}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1d242}', '\u{1d244}'), + ('\u{1da00}', '\u{1da36}'), + ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), + ('\u{1da84}', '\u{1da84}'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e130}', '\u{1e136}'), + ('\u{1e2ec}', '\u{1e2ef}'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('\u{1e944}', '\u{1e94a}'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const MATH_SYMBOL: &'static [(char, char)] = &[ + ('+', '+'), + ('<', '>'), + ('|', '|'), + ('~', '~'), + ('¬', '¬'), + ('±', '±'), + ('×', '×'), + ('÷', '÷'), + ('϶', '϶'), + ('؆', '؈'), + ('⁄', '⁄'), + ('⁒', '⁒'), + ('⁺', '⁼'), + ('₊', '₌'), + ('℘', '℘'), + ('⅀', '⅄'), + ('⅋', '⅋'), + ('←', '↔'), + ('↚', '↛'), + ('↠', '↠'), + ('↣', '↣'), + ('↦', '↦'), + ('↮', '↮'), + ('⇎', '⇏'), + ('⇒', '⇒'), + ('⇔', '⇔'), + ('⇴', '⋿'), + ('⌠', '⌡'), + ('⍼', '⍼'), + ('⎛', '⎳'), + ('⏜', '⏡'), + ('▷', '▷'), + ('◁', '◁'), + ('◸', '◿'), + ('♯', '♯'), + ('⟀', '⟄'), + ('⟇', '⟥'), + ('⟰', '⟿'), + ('⤀', '⦂'), + ('⦙', '⧗'), + ('⧜', '⧻'), + ('⧾', '⫿'), + ('⬰', '⭄'), + ('⭇', '⭌'), + ('﬩', '﬩'), + ('﹢', '﹢'), + ('﹤', '﹦'), + ('+', '+'), + ('<', '>'), + ('|', '|'), + ('~', '~'), + ('¬', '¬'), + ('←', '↓'), + ('𝛁', '𝛁'), + ('𝛛', '𝛛'), + ('𝛻', '𝛻'), + ('𝜕', '𝜕'), + ('𝜵', '𝜵'), + ('𝝏', '𝝏'), + ('𝝯', '𝝯'), + ('𝞉', '𝞉'), + ('𝞩', '𝞩'), + ('𝟃', '𝟃'), + ('𞻰', '𞻱'), +]; + +pub const MODIFIER_LETTER: &'static [(char, char)] = &[ + ('ʰ', 'ˁ'), + ('ˆ', 'ˑ'), + ('ˠ', 'ˤ'), + ('ˬ', 'ˬ'), + ('ˮ', 'ˮ'), + ('ʹ', 'ʹ'), + ('ͺ', 'ͺ'), + ('ՙ', 'ՙ'), + ('ـ', 'ـ'), + ('ۥ', 'ۦ'), + ('ߴ', 'ߵ'), + ('ߺ', 'ߺ'), + ('ࠚ', 'ࠚ'), + ('ࠤ', 'ࠤ'), + ('ࠨ', 'ࠨ'), + ('ॱ', 'ॱ'), + ('ๆ', 'ๆ'), + ('ໆ', 'ໆ'), + ('ჼ', 'ჼ'), + ('ៗ', 'ៗ'), + ('ᡃ', 'ᡃ'), + ('ᪧ', 'ᪧ'), + ('ᱸ', 'ᱽ'), + ('ᴬ', 'ᵪ'), + ('ᵸ', 'ᵸ'), + ('ᶛ', 'ᶿ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('ⱼ', 'ⱽ'), + ('ⵯ', 'ⵯ'), + ('ⸯ', 'ⸯ'), + ('々', '々'), + ('〱', '〵'), + ('〻', '〻'), + ('ゝ', 'ゞ'), + ('ー', 'ヾ'), + ('ꀕ', 'ꀕ'), + ('ꓸ', 'ꓽ'), + ('ꘌ', 'ꘌ'), + ('ꙿ', 'ꙿ'), + ('ꚜ', 'ꚝ'), + ('ꜗ', 'ꜟ'), + ('ꝰ', 'ꝰ'), + ('ꞈ', 'ꞈ'), + ('ꟸ', 'ꟹ'), + ('ꧏ', 'ꧏ'), + ('ꧦ', 'ꧦ'), + ('ꩰ', 'ꩰ'), + ('ꫝ', 'ꫝ'), + ('ꫳ', 'ꫴ'), + ('ꭜ', 'ꭟ'), + ('ー', 'ー'), + ('\u{ff9e}', '\u{ff9f}'), + ('𖭀', '𖭃'), + ('𖾓', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('\u{1e137}', '\u{1e13d}'), + ('\u{1e94b}', '\u{1e94b}'), +]; + +pub const MODIFIER_SYMBOL: &'static [(char, char)] = &[ + ('^', '^'), + ('`', '`'), + ('¨', '¨'), + ('¯', '¯'), + ('´', '´'), + ('¸', '¸'), + ('˂', '˅'), + ('˒', '˟'), + ('˥', '˫'), + ('˭', '˭'), + ('˯', '˿'), + ('͵', '͵'), + ('΄', '΅'), + ('᾽', '᾽'), + ('᾿', '῁'), + ('῍', '῏'), + ('῝', '῟'), + ('῭', '`'), + ('´', '῾'), + ('゛', '゜'), + ('꜀', '꜖'), + ('꜠', '꜡'), + ('꞉', '꞊'), + ('꭛', '꭛'), + ('﮲', '﯁'), + ('^', '^'), + ('`', '`'), + (' ̄', ' ̄'), + ('🏻', '🏿'), +]; + +pub const NONSPACING_MARK: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), + ('\u{483}', '\u{487}'), + ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('\u{610}', '\u{61a}'), + ('\u{64b}', '\u{65f}'), + ('\u{670}', '\u{670}'), + ('\u{6d6}', '\u{6dc}'), + ('\u{6df}', '\u{6e4}'), + ('\u{6e7}', '\u{6e8}'), + ('\u{6ea}', '\u{6ed}'), + ('\u{711}', '\u{711}'), + ('\u{730}', '\u{74a}'), + ('\u{7a6}', '\u{7b0}'), + ('\u{7eb}', '\u{7f3}'), + ('\u{7fd}', '\u{7fd}'), + ('\u{816}', '\u{819}'), + ('\u{81b}', '\u{823}'), + ('\u{825}', '\u{827}'), + ('\u{829}', '\u{82d}'), + ('\u{859}', '\u{85b}'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', '\u{902}'), + ('\u{93a}', '\u{93a}'), + ('\u{93c}', '\u{93c}'), + ('\u{941}', '\u{948}'), + ('\u{94d}', '\u{94d}'), + ('\u{951}', '\u{957}'), + ('\u{962}', '\u{963}'), + ('\u{981}', '\u{981}'), + ('\u{9bc}', '\u{9bc}'), + ('\u{9c1}', '\u{9c4}'), + ('\u{9cd}', '\u{9cd}'), + ('\u{9e2}', '\u{9e3}'), + ('\u{9fe}', '\u{9fe}'), + ('\u{a01}', '\u{a02}'), + ('\u{a3c}', '\u{a3c}'), + ('\u{a41}', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('\u{a70}', '\u{a71}'), + ('\u{a75}', '\u{a75}'), + ('\u{a81}', '\u{a82}'), + ('\u{abc}', '\u{abc}'), + ('\u{ac1}', '\u{ac5}'), + ('\u{ac7}', '\u{ac8}'), + ('\u{acd}', '\u{acd}'), + ('\u{ae2}', '\u{ae3}'), + ('\u{afa}', '\u{aff}'), + ('\u{b01}', '\u{b01}'), + ('\u{b3c}', '\u{b3c}'), + ('\u{b3f}', '\u{b3f}'), + ('\u{b41}', '\u{b44}'), + ('\u{b4d}', '\u{b4d}'), + ('\u{b56}', '\u{b56}'), + ('\u{b62}', '\u{b63}'), + ('\u{b82}', '\u{b82}'), + ('\u{bc0}', '\u{bc0}'), + ('\u{bcd}', '\u{bcd}'), + ('\u{c00}', '\u{c00}'), + ('\u{c04}', '\u{c04}'), + ('\u{c3e}', '\u{c40}'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('\u{c62}', '\u{c63}'), + ('\u{c81}', '\u{c81}'), + ('\u{cbc}', '\u{cbc}'), + ('\u{cbf}', '\u{cbf}'), + ('\u{cc6}', '\u{cc6}'), + ('\u{ccc}', '\u{ccd}'), + ('\u{ce2}', '\u{ce3}'), + ('\u{d00}', '\u{d01}'), + ('\u{d3b}', '\u{d3c}'), + ('\u{d41}', '\u{d44}'), + ('\u{d4d}', '\u{d4d}'), + ('\u{d62}', '\u{d63}'), + ('\u{dca}', '\u{dca}'), + ('\u{dd2}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('\u{e31}', '\u{e31}'), + ('\u{e34}', '\u{e3a}'), + ('\u{e47}', '\u{e4e}'), + ('\u{eb1}', '\u{eb1}'), + ('\u{eb4}', '\u{ebc}'), + ('\u{ec8}', '\u{ecd}'), + ('\u{f18}', '\u{f19}'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('\u{f71}', '\u{f7e}'), + ('\u{f80}', '\u{f84}'), + ('\u{f86}', '\u{f87}'), + ('\u{f8d}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), + ('\u{102d}', '\u{1030}'), + ('\u{1032}', '\u{1037}'), + ('\u{1039}', '\u{103a}'), + ('\u{103d}', '\u{103e}'), + ('\u{1058}', '\u{1059}'), + ('\u{105e}', '\u{1060}'), + ('\u{1071}', '\u{1074}'), + ('\u{1082}', '\u{1082}'), + ('\u{1085}', '\u{1086}'), + ('\u{108d}', '\u{108d}'), + ('\u{109d}', '\u{109d}'), + ('\u{135d}', '\u{135f}'), + ('\u{1712}', '\u{1714}'), + ('\u{1732}', '\u{1734}'), + ('\u{1752}', '\u{1753}'), + ('\u{1772}', '\u{1773}'), + ('\u{17b4}', '\u{17b5}'), + ('\u{17b7}', '\u{17bd}'), + ('\u{17c6}', '\u{17c6}'), + ('\u{17c9}', '\u{17d3}'), + ('\u{17dd}', '\u{17dd}'), + ('\u{180b}', '\u{180d}'), + ('\u{1885}', '\u{1886}'), + ('\u{18a9}', '\u{18a9}'), + ('\u{1920}', '\u{1922}'), + ('\u{1927}', '\u{1928}'), + ('\u{1932}', '\u{1932}'), + ('\u{1939}', '\u{193b}'), + ('\u{1a17}', '\u{1a18}'), + ('\u{1a1b}', '\u{1a1b}'), + ('\u{1a56}', '\u{1a56}'), + ('\u{1a58}', '\u{1a5e}'), + ('\u{1a60}', '\u{1a60}'), + ('\u{1a62}', '\u{1a62}'), + ('\u{1a65}', '\u{1a6c}'), + ('\u{1a73}', '\u{1a7c}'), + ('\u{1a7f}', '\u{1a7f}'), + ('\u{1ab0}', '\u{1abd}'), + ('\u{1b00}', '\u{1b03}'), + ('\u{1b34}', '\u{1b34}'), + ('\u{1b36}', '\u{1b3a}'), + ('\u{1b3c}', '\u{1b3c}'), + ('\u{1b42}', '\u{1b42}'), + ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', '\u{1b81}'), + ('\u{1ba2}', '\u{1ba5}'), + ('\u{1ba8}', '\u{1ba9}'), + ('\u{1bab}', '\u{1bad}'), + ('\u{1be6}', '\u{1be6}'), + ('\u{1be8}', '\u{1be9}'), + ('\u{1bed}', '\u{1bed}'), + ('\u{1bef}', '\u{1bf1}'), + ('\u{1c2c}', '\u{1c33}'), + ('\u{1c36}', '\u{1c37}'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1ce0}'), + ('\u{1ce2}', '\u{1ce8}'), + ('\u{1ced}', '\u{1ced}'), + ('\u{1cf4}', '\u{1cf4}'), + ('\u{1cf8}', '\u{1cf9}'), + ('\u{1dc0}', '\u{1df9}'), + ('\u{1dfb}', '\u{1dff}'), + ('\u{20d0}', '\u{20dc}'), + ('\u{20e1}', '\u{20e1}'), + ('\u{20e5}', '\u{20f0}'), + ('\u{2cef}', '\u{2cf1}'), + ('\u{2d7f}', '\u{2d7f}'), + ('\u{2de0}', '\u{2dff}'), + ('\u{302a}', '\u{302d}'), + ('\u{3099}', '\u{309a}'), + ('\u{a66f}', '\u{a66f}'), + ('\u{a674}', '\u{a67d}'), + ('\u{a69e}', '\u{a69f}'), + ('\u{a6f0}', '\u{a6f1}'), + ('\u{a802}', '\u{a802}'), + ('\u{a806}', '\u{a806}'), + ('\u{a80b}', '\u{a80b}'), + ('\u{a825}', '\u{a826}'), + ('\u{a8c4}', '\u{a8c5}'), + ('\u{a8e0}', '\u{a8f1}'), + ('\u{a8ff}', '\u{a8ff}'), + ('\u{a926}', '\u{a92d}'), + ('\u{a947}', '\u{a951}'), + ('\u{a980}', '\u{a982}'), + ('\u{a9b3}', '\u{a9b3}'), + ('\u{a9b6}', '\u{a9b9}'), + ('\u{a9bc}', 'ꦽ'), + ('\u{a9e5}', '\u{a9e5}'), + ('\u{aa29}', '\u{aa2e}'), + ('\u{aa31}', '\u{aa32}'), + ('\u{aa35}', '\u{aa36}'), + ('\u{aa43}', '\u{aa43}'), + ('\u{aa4c}', '\u{aa4c}'), + ('\u{aa7c}', '\u{aa7c}'), + ('\u{aab0}', '\u{aab0}'), + ('\u{aab2}', '\u{aab4}'), + ('\u{aab7}', '\u{aab8}'), + ('\u{aabe}', '\u{aabf}'), + ('\u{aac1}', '\u{aac1}'), + ('\u{aaec}', '\u{aaed}'), + ('\u{aaf6}', '\u{aaf6}'), + ('\u{abe5}', '\u{abe5}'), + ('\u{abe8}', '\u{abe8}'), + ('\u{abed}', '\u{abed}'), + ('\u{fb1e}', '\u{fb1e}'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2f}'), + ('\u{101fd}', '\u{101fd}'), + ('\u{102e0}', '\u{102e0}'), + ('\u{10376}', '\u{1037a}'), + ('\u{10a01}', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a0f}'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), + ('\u{10ae5}', '\u{10ae6}'), + ('\u{10d24}', '\u{10d27}'), + ('\u{10f46}', '\u{10f50}'), + ('\u{11001}', '\u{11001}'), + ('\u{11038}', '\u{11046}'), + ('\u{1107f}', '\u{11081}'), + ('\u{110b3}', '\u{110b6}'), + ('\u{110b9}', '\u{110ba}'), + ('\u{11100}', '\u{11102}'), + ('\u{11127}', '\u{1112b}'), + ('\u{1112d}', '\u{11134}'), + ('\u{11173}', '\u{11173}'), + ('\u{11180}', '\u{11181}'), + ('\u{111b6}', '\u{111be}'), + ('\u{111c9}', '\u{111cc}'), + ('\u{1122f}', '\u{11231}'), + ('\u{11234}', '\u{11234}'), + ('\u{11236}', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('\u{112df}', '\u{112df}'), + ('\u{112e3}', '\u{112ea}'), + ('\u{11300}', '\u{11301}'), + ('\u{1133b}', '\u{1133c}'), + ('\u{11340}', '\u{11340}'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('\u{11438}', '\u{1143f}'), + ('\u{11442}', '\u{11444}'), + ('\u{11446}', '\u{11446}'), + ('\u{1145e}', '\u{1145e}'), + ('\u{114b3}', '\u{114b8}'), + ('\u{114ba}', '\u{114ba}'), + ('\u{114bf}', '\u{114c0}'), + ('\u{114c2}', '\u{114c3}'), + ('\u{115b2}', '\u{115b5}'), + ('\u{115bc}', '\u{115bd}'), + ('\u{115bf}', '\u{115c0}'), + ('\u{115dc}', '\u{115dd}'), + ('\u{11633}', '\u{1163a}'), + ('\u{1163d}', '\u{1163d}'), + ('\u{1163f}', '\u{11640}'), + ('\u{116ab}', '\u{116ab}'), + ('\u{116ad}', '\u{116ad}'), + ('\u{116b0}', '\u{116b5}'), + ('\u{116b7}', '\u{116b7}'), + ('\u{1171d}', '\u{1171f}'), + ('\u{11722}', '\u{11725}'), + ('\u{11727}', '\u{1172b}'), + ('\u{1182f}', '\u{11837}'), + ('\u{11839}', '\u{1183a}'), + ('\u{119d4}', '\u{119d7}'), + ('\u{119da}', '\u{119db}'), + ('\u{119e0}', '\u{119e0}'), + ('\u{11a01}', '\u{11a0a}'), + ('\u{11a33}', '\u{11a38}'), + ('\u{11a3b}', '\u{11a3e}'), + ('\u{11a47}', '\u{11a47}'), + ('\u{11a51}', '\u{11a56}'), + ('\u{11a59}', '\u{11a5b}'), + ('\u{11a8a}', '\u{11a96}'), + ('\u{11a98}', '\u{11a99}'), + ('\u{11c30}', '\u{11c36}'), + ('\u{11c38}', '\u{11c3d}'), + ('\u{11c3f}', '\u{11c3f}'), + ('\u{11c92}', '\u{11ca7}'), + ('\u{11caa}', '\u{11cb0}'), + ('\u{11cb2}', '\u{11cb3}'), + ('\u{11cb5}', '\u{11cb6}'), + ('\u{11d31}', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d45}'), + ('\u{11d47}', '\u{11d47}'), + ('\u{11d90}', '\u{11d91}'), + ('\u{11d95}', '\u{11d95}'), + ('\u{11d97}', '\u{11d97}'), + ('\u{11ef3}', '\u{11ef4}'), + ('\u{16af0}', '\u{16af4}'), + ('\u{16b30}', '\u{16b36}'), + ('\u{16f4f}', '\u{16f4f}'), + ('\u{16f8f}', '\u{16f92}'), + ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d167}', '\u{1d169}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1d242}', '\u{1d244}'), + ('\u{1da00}', '\u{1da36}'), + ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), + ('\u{1da84}', '\u{1da84}'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e130}', '\u{1e136}'), + ('\u{1e2ec}', '\u{1e2ef}'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('\u{1e944}', '\u{1e94a}'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const NUMBER: &'static [(char, char)] = &[ + ('0', '9'), + ('²', '³'), + ('¹', '¹'), + ('¼', '¾'), + ('٠', '٩'), + ('۰', '۹'), + ('߀', '߉'), + ('०', '९'), + ('০', '৯'), + ('৴', '৹'), + ('੦', '੯'), + ('૦', '૯'), + ('୦', '୯'), + ('୲', '୷'), + ('௦', '௲'), + ('౦', '౯'), + ('౸', '౾'), + ('೦', '೯'), + ('൘', '൞'), + ('൦', '൸'), + ('෦', '෯'), + ('๐', '๙'), + ('໐', '໙'), + ('༠', '༳'), + ('၀', '၉'), + ('႐', '႙'), + ('፩', '፼'), + ('ᛮ', 'ᛰ'), + ('០', '៩'), + ('៰', '៹'), + ('᠐', '᠙'), + ('᥆', '᥏'), + ('᧐', '᧚'), + ('᪀', '᪉'), + ('᪐', '᪙'), + ('᭐', '᭙'), + ('᮰', '᮹'), + ('᱀', '᱉'), + ('᱐', '᱙'), + ('⁰', '⁰'), + ('⁴', '⁹'), + ('₀', '₉'), + ('⅐', 'ↂ'), + ('ↅ', '↉'), + ('①', '⒛'), + ('⓪', '⓿'), + ('❶', '➓'), + ('⳽', '⳽'), + ('〇', '〇'), + ('〡', '〩'), + ('〸', '〺'), + ('㆒', '㆕'), + ('㈠', '㈩'), + ('㉈', '㉏'), + ('㉑', '㉟'), + ('㊀', '㊉'), + ('㊱', '㊿'), + ('꘠', '꘩'), + ('ꛦ', 'ꛯ'), + ('꠰', '꠵'), + ('꣐', '꣙'), + ('꤀', '꤉'), + ('꧐', '꧙'), + ('꧰', '꧹'), + ('꩐', '꩙'), + ('꯰', '꯹'), + ('0', '9'), + ('𐄇', '𐄳'), + ('𐅀', '𐅸'), + ('𐆊', '𐆋'), + ('𐋡', '𐋻'), + ('𐌠', '𐌣'), + ('𐍁', '𐍁'), + ('𐍊', '𐍊'), + ('𐏑', '𐏕'), + ('𐒠', '𐒩'), + ('𐡘', '𐡟'), + ('𐡹', '𐡿'), + ('𐢧', '𐢯'), + ('𐣻', '𐣿'), + ('𐤖', '𐤛'), + ('𐦼', '𐦽'), + ('𐧀', '𐧏'), + ('𐧒', '𐧿'), + ('𐩀', '𐩈'), + ('𐩽', '𐩾'), + ('𐪝', '𐪟'), + ('𐫫', '𐫯'), + ('𐭘', '𐭟'), + ('𐭸', '𐭿'), + ('𐮩', '𐮯'), + ('𐳺', '𐳿'), + ('𐴰', '𐴹'), + ('𐹠', '𐹾'), + ('𐼝', '𐼦'), + ('𐽑', '𐽔'), + ('𑁒', '𑁯'), + ('𑃰', '𑃹'), + ('𑄶', '𑄿'), + ('𑇐', '𑇙'), + ('𑇡', '𑇴'), + ('𑋰', '𑋹'), + ('𑑐', '𑑙'), + ('𑓐', '𑓙'), + ('𑙐', '𑙙'), + ('𑛀', '𑛉'), + ('𑜰', '𑜻'), + ('𑣠', '𑣲'), + ('𑱐', '𑱬'), + ('𑵐', '𑵙'), + ('𑶠', '𑶩'), + ('\u{11fc0}', '\u{11fd4}'), + ('𒐀', '𒑮'), + ('𖩠', '𖩩'), + ('𖭐', '𖭙'), + ('𖭛', '𖭡'), + ('𖺀', '𖺖'), + ('𝋠', '𝋳'), + ('𝍠', '𝍸'), + ('𝟎', '𝟿'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e2f0}', '\u{1e2f9}'), + ('𞣇', '𞣏'), + ('𞥐', '𞥙'), + ('𞱱', '𞲫'), + ('𞲭', '𞲯'), + ('𞲱', '𞲴'), + ('\u{1ed01}', '\u{1ed2d}'), + ('\u{1ed2f}', '\u{1ed3d}'), + ('🄀', '🄌'), +]; + +pub const OPEN_PUNCTUATION: &'static [(char, char)] = &[ + ('(', '('), + ('[', '['), + ('{', '{'), + ('༺', '༺'), + ('༼', '༼'), + ('᚛', '᚛'), + ('‚', '‚'), + ('„', '„'), + ('⁅', '⁅'), + ('⁽', '⁽'), + ('₍', '₍'), + ('⌈', '⌈'), + ('⌊', '⌊'), + ('〈', '〈'), + ('❨', '❨'), + ('❪', '❪'), + ('❬', '❬'), + ('❮', '❮'), + ('❰', '❰'), + ('❲', '❲'), + ('❴', '❴'), + ('⟅', '⟅'), + ('⟦', '⟦'), + ('⟨', '⟨'), + ('⟪', '⟪'), + ('⟬', '⟬'), + ('⟮', '⟮'), + ('⦃', '⦃'), + ('⦅', '⦅'), + ('⦇', '⦇'), + ('⦉', '⦉'), + ('⦋', '⦋'), + ('⦍', '⦍'), + ('⦏', '⦏'), + ('⦑', '⦑'), + ('⦓', '⦓'), + ('⦕', '⦕'), + ('⦗', '⦗'), + ('⧘', '⧘'), + ('⧚', '⧚'), + ('⧼', '⧼'), + ('⸢', '⸢'), + ('⸤', '⸤'), + ('⸦', '⸦'), + ('⸨', '⸨'), + ('⹂', '⹂'), + ('〈', '〈'), + ('《', '《'), + ('「', '「'), + ('『', '『'), + ('【', '【'), + ('〔', '〔'), + ('〖', '〖'), + ('〘', '〘'), + ('〚', '〚'), + ('〝', '〝'), + ('﴿', '﴿'), + ('︗', '︗'), + ('︵', '︵'), + ('︷', '︷'), + ('︹', '︹'), + ('︻', '︻'), + ('︽', '︽'), + ('︿', '︿'), + ('﹁', '﹁'), + ('﹃', '﹃'), + ('﹇', '﹇'), + ('﹙', '﹙'), + ('﹛', '﹛'), + ('﹝', '﹝'), + ('(', '('), + ('[', '['), + ('{', '{'), + ('⦅', '⦅'), + ('「', '「'), +]; + +pub const OTHER: &'static [(char, char)] = &[ + ('\u{0}', '\u{1f}'), + ('\u{7f}', '\u{9f}'), + ('\u{ad}', '\u{ad}'), + ('\u{378}', '\u{379}'), + ('\u{380}', '\u{383}'), + ('\u{38b}', '\u{38b}'), + ('\u{38d}', '\u{38d}'), + ('\u{3a2}', '\u{3a2}'), + ('\u{530}', '\u{530}'), + ('\u{557}', '\u{558}'), + ('\u{58b}', '\u{58c}'), + ('\u{590}', '\u{590}'), + ('\u{5c8}', '\u{5cf}'), + ('\u{5eb}', '\u{5ee}'), + ('\u{5f5}', '\u{605}'), + ('\u{61c}', '\u{61d}'), + ('\u{6dd}', '\u{6dd}'), + ('\u{70e}', '\u{70f}'), + ('\u{74b}', '\u{74c}'), + ('\u{7b2}', '\u{7bf}'), + ('\u{7fb}', '\u{7fc}'), + ('\u{82e}', '\u{82f}'), + ('\u{83f}', '\u{83f}'), + ('\u{85c}', '\u{85d}'), + ('\u{85f}', '\u{85f}'), + ('\u{86b}', '\u{89f}'), + ('\u{8b5}', '\u{8b5}'), + ('\u{8be}', '\u{8d2}'), + ('\u{8e2}', '\u{8e2}'), + ('\u{984}', '\u{984}'), + ('\u{98d}', '\u{98e}'), + ('\u{991}', '\u{992}'), + ('\u{9a9}', '\u{9a9}'), + ('\u{9b1}', '\u{9b1}'), + ('\u{9b3}', '\u{9b5}'), + ('\u{9ba}', '\u{9bb}'), + ('\u{9c5}', '\u{9c6}'), + ('\u{9c9}', '\u{9ca}'), + ('\u{9cf}', '\u{9d6}'), + ('\u{9d8}', '\u{9db}'), + ('\u{9de}', '\u{9de}'), + ('\u{9e4}', '\u{9e5}'), + ('\u{9ff}', '\u{a00}'), + ('\u{a04}', '\u{a04}'), + ('\u{a0b}', '\u{a0e}'), + ('\u{a11}', '\u{a12}'), + ('\u{a29}', '\u{a29}'), + ('\u{a31}', '\u{a31}'), + ('\u{a34}', '\u{a34}'), + ('\u{a37}', '\u{a37}'), + ('\u{a3a}', '\u{a3b}'), + ('\u{a3d}', '\u{a3d}'), + ('\u{a43}', '\u{a46}'), + ('\u{a49}', '\u{a4a}'), + ('\u{a4e}', '\u{a50}'), + ('\u{a52}', '\u{a58}'), + ('\u{a5d}', '\u{a5d}'), + ('\u{a5f}', '\u{a65}'), + ('\u{a77}', '\u{a80}'), + ('\u{a84}', '\u{a84}'), + ('\u{a8e}', '\u{a8e}'), + ('\u{a92}', '\u{a92}'), + ('\u{aa9}', '\u{aa9}'), + ('\u{ab1}', '\u{ab1}'), + ('\u{ab4}', '\u{ab4}'), + ('\u{aba}', '\u{abb}'), + ('\u{ac6}', '\u{ac6}'), + ('\u{aca}', '\u{aca}'), + ('\u{ace}', '\u{acf}'), + ('\u{ad1}', '\u{adf}'), + ('\u{ae4}', '\u{ae5}'), + ('\u{af2}', '\u{af8}'), + ('\u{b00}', '\u{b00}'), + ('\u{b04}', '\u{b04}'), + ('\u{b0d}', '\u{b0e}'), + ('\u{b11}', '\u{b12}'), + ('\u{b29}', '\u{b29}'), + ('\u{b31}', '\u{b31}'), + ('\u{b34}', '\u{b34}'), + ('\u{b3a}', '\u{b3b}'), + ('\u{b45}', '\u{b46}'), + ('\u{b49}', '\u{b4a}'), + ('\u{b4e}', '\u{b55}'), + ('\u{b58}', '\u{b5b}'), + ('\u{b5e}', '\u{b5e}'), + ('\u{b64}', '\u{b65}'), + ('\u{b78}', '\u{b81}'), + ('\u{b84}', '\u{b84}'), + ('\u{b8b}', '\u{b8d}'), + ('\u{b91}', '\u{b91}'), + ('\u{b96}', '\u{b98}'), + ('\u{b9b}', '\u{b9b}'), + ('\u{b9d}', '\u{b9d}'), + ('\u{ba0}', '\u{ba2}'), + ('\u{ba5}', '\u{ba7}'), + ('\u{bab}', '\u{bad}'), + ('\u{bba}', '\u{bbd}'), + ('\u{bc3}', '\u{bc5}'), + ('\u{bc9}', '\u{bc9}'), + ('\u{bce}', '\u{bcf}'), + ('\u{bd1}', '\u{bd6}'), + ('\u{bd8}', '\u{be5}'), + ('\u{bfb}', '\u{bff}'), + ('\u{c0d}', '\u{c0d}'), + ('\u{c11}', '\u{c11}'), + ('\u{c29}', '\u{c29}'), + ('\u{c3a}', '\u{c3c}'), + ('\u{c45}', '\u{c45}'), + ('\u{c49}', '\u{c49}'), + ('\u{c4e}', '\u{c54}'), + ('\u{c57}', '\u{c57}'), + ('\u{c5b}', '\u{c5f}'), + ('\u{c64}', '\u{c65}'), + ('\u{c70}', '\u{c76}'), + ('\u{c8d}', '\u{c8d}'), + ('\u{c91}', '\u{c91}'), + ('\u{ca9}', '\u{ca9}'), + ('\u{cb4}', '\u{cb4}'), + ('\u{cba}', '\u{cbb}'), + ('\u{cc5}', '\u{cc5}'), + ('\u{cc9}', '\u{cc9}'), + ('\u{cce}', '\u{cd4}'), + ('\u{cd7}', '\u{cdd}'), + ('\u{cdf}', '\u{cdf}'), + ('\u{ce4}', '\u{ce5}'), + ('\u{cf0}', '\u{cf0}'), + ('\u{cf3}', '\u{cff}'), + ('\u{d04}', '\u{d04}'), + ('\u{d0d}', '\u{d0d}'), + ('\u{d11}', '\u{d11}'), + ('\u{d45}', '\u{d45}'), + ('\u{d49}', '\u{d49}'), + ('\u{d50}', '\u{d53}'), + ('\u{d64}', '\u{d65}'), + ('\u{d80}', '\u{d81}'), + ('\u{d84}', '\u{d84}'), + ('\u{d97}', '\u{d99}'), + ('\u{db2}', '\u{db2}'), + ('\u{dbc}', '\u{dbc}'), + ('\u{dbe}', '\u{dbf}'), + ('\u{dc7}', '\u{dc9}'), + ('\u{dcb}', '\u{dce}'), + ('\u{dd5}', '\u{dd5}'), + ('\u{dd7}', '\u{dd7}'), + ('\u{de0}', '\u{de5}'), + ('\u{df0}', '\u{df1}'), + ('\u{df5}', '\u{e00}'), + ('\u{e3b}', '\u{e3e}'), + ('\u{e5c}', '\u{e80}'), + ('\u{e83}', '\u{e83}'), + ('\u{e85}', '\u{e85}'), + ('\u{e8b}', '\u{e8b}'), + ('\u{ea4}', '\u{ea4}'), + ('\u{ea6}', '\u{ea6}'), + ('\u{ebe}', '\u{ebf}'), + ('\u{ec5}', '\u{ec5}'), + ('\u{ec7}', '\u{ec7}'), + ('\u{ece}', '\u{ecf}'), + ('\u{eda}', '\u{edb}'), + ('\u{ee0}', '\u{eff}'), + ('\u{f48}', '\u{f48}'), + ('\u{f6d}', '\u{f70}'), + ('\u{f98}', '\u{f98}'), + ('\u{fbd}', '\u{fbd}'), + ('\u{fcd}', '\u{fcd}'), + ('\u{fdb}', '\u{fff}'), + ('\u{10c6}', '\u{10c6}'), + ('\u{10c8}', '\u{10cc}'), + ('\u{10ce}', '\u{10cf}'), + ('\u{1249}', '\u{1249}'), + ('\u{124e}', '\u{124f}'), + ('\u{1257}', '\u{1257}'), + ('\u{1259}', '\u{1259}'), + ('\u{125e}', '\u{125f}'), + ('\u{1289}', '\u{1289}'), + ('\u{128e}', '\u{128f}'), + ('\u{12b1}', '\u{12b1}'), + ('\u{12b6}', '\u{12b7}'), + ('\u{12bf}', '\u{12bf}'), + ('\u{12c1}', '\u{12c1}'), + ('\u{12c6}', '\u{12c7}'), + ('\u{12d7}', '\u{12d7}'), + ('\u{1311}', '\u{1311}'), + ('\u{1316}', '\u{1317}'), + ('\u{135b}', '\u{135c}'), + ('\u{137d}', '\u{137f}'), + ('\u{139a}', '\u{139f}'), + ('\u{13f6}', '\u{13f7}'), + ('\u{13fe}', '\u{13ff}'), + ('\u{169d}', '\u{169f}'), + ('\u{16f9}', '\u{16ff}'), + ('\u{170d}', '\u{170d}'), + ('\u{1715}', '\u{171f}'), + ('\u{1737}', '\u{173f}'), + ('\u{1754}', '\u{175f}'), + ('\u{176d}', '\u{176d}'), + ('\u{1771}', '\u{1771}'), + ('\u{1774}', '\u{177f}'), + ('\u{17de}', '\u{17df}'), + ('\u{17ea}', '\u{17ef}'), + ('\u{17fa}', '\u{17ff}'), + ('\u{180e}', '\u{180f}'), + ('\u{181a}', '\u{181f}'), + ('\u{1879}', '\u{187f}'), + ('\u{18ab}', '\u{18af}'), + ('\u{18f6}', '\u{18ff}'), + ('\u{191f}', '\u{191f}'), + ('\u{192c}', '\u{192f}'), + ('\u{193c}', '\u{193f}'), + ('\u{1941}', '\u{1943}'), + ('\u{196e}', '\u{196f}'), + ('\u{1975}', '\u{197f}'), + ('\u{19ac}', '\u{19af}'), + ('\u{19ca}', '\u{19cf}'), + ('\u{19db}', '\u{19dd}'), + ('\u{1a1c}', '\u{1a1d}'), + ('\u{1a5f}', '\u{1a5f}'), + ('\u{1a7d}', '\u{1a7e}'), + ('\u{1a8a}', '\u{1a8f}'), + ('\u{1a9a}', '\u{1a9f}'), + ('\u{1aae}', '\u{1aaf}'), + ('\u{1abf}', '\u{1aff}'), + ('\u{1b4c}', '\u{1b4f}'), + ('\u{1b7d}', '\u{1b7f}'), + ('\u{1bf4}', '\u{1bfb}'), + ('\u{1c38}', '\u{1c3a}'), + ('\u{1c4a}', '\u{1c4c}'), + ('\u{1c89}', '\u{1c8f}'), + ('\u{1cbb}', '\u{1cbc}'), + ('\u{1cc8}', '\u{1ccf}'), + ('\u{1cfb}', '\u{1cff}'), + ('\u{1dfa}', '\u{1dfa}'), + ('\u{1f16}', '\u{1f17}'), + ('\u{1f1e}', '\u{1f1f}'), + ('\u{1f46}', '\u{1f47}'), + ('\u{1f4e}', '\u{1f4f}'), + ('\u{1f58}', '\u{1f58}'), + ('\u{1f5a}', '\u{1f5a}'), + ('\u{1f5c}', '\u{1f5c}'), + ('\u{1f5e}', '\u{1f5e}'), + ('\u{1f7e}', '\u{1f7f}'), + ('\u{1fb5}', '\u{1fb5}'), + ('\u{1fc5}', '\u{1fc5}'), + ('\u{1fd4}', '\u{1fd5}'), + ('\u{1fdc}', '\u{1fdc}'), + ('\u{1ff0}', '\u{1ff1}'), + ('\u{1ff5}', '\u{1ff5}'), + ('\u{1fff}', '\u{1fff}'), + ('\u{200b}', '\u{200f}'), + ('\u{202a}', '\u{202e}'), + ('\u{2060}', '\u{206f}'), + ('\u{2072}', '\u{2073}'), + ('\u{208f}', '\u{208f}'), + ('\u{209d}', '\u{209f}'), + ('\u{20c0}', '\u{20cf}'), + ('\u{20f1}', '\u{20ff}'), + ('\u{218c}', '\u{218f}'), + ('\u{2427}', '\u{243f}'), + ('\u{244b}', '\u{245f}'), + ('\u{2b74}', '\u{2b75}'), + ('\u{2b96}', '\u{2b97}'), + ('\u{2c2f}', '\u{2c2f}'), + ('\u{2c5f}', '\u{2c5f}'), + ('\u{2cf4}', '\u{2cf8}'), + ('\u{2d26}', '\u{2d26}'), + ('\u{2d28}', '\u{2d2c}'), + ('\u{2d2e}', '\u{2d2f}'), + ('\u{2d68}', '\u{2d6e}'), + ('\u{2d71}', '\u{2d7e}'), + ('\u{2d97}', '\u{2d9f}'), + ('\u{2da7}', '\u{2da7}'), + ('\u{2daf}', '\u{2daf}'), + ('\u{2db7}', '\u{2db7}'), + ('\u{2dbf}', '\u{2dbf}'), + ('\u{2dc7}', '\u{2dc7}'), + ('\u{2dcf}', '\u{2dcf}'), + ('\u{2dd7}', '\u{2dd7}'), + ('\u{2ddf}', '\u{2ddf}'), + ('\u{2e50}', '\u{2e7f}'), + ('\u{2e9a}', '\u{2e9a}'), + ('\u{2ef4}', '\u{2eff}'), + ('\u{2fd6}', '\u{2fef}'), + ('\u{2ffc}', '\u{2fff}'), + ('\u{3040}', '\u{3040}'), + ('\u{3097}', '\u{3098}'), + ('\u{3100}', '\u{3104}'), + ('\u{3130}', '\u{3130}'), + ('\u{318f}', '\u{318f}'), + ('\u{31bb}', '\u{31bf}'), + ('\u{31e4}', '\u{31ef}'), + ('\u{321f}', '\u{321f}'), + ('\u{4db6}', '\u{4dbf}'), + ('\u{9ff0}', '\u{9fff}'), + ('\u{a48d}', '\u{a48f}'), + ('\u{a4c7}', '\u{a4cf}'), + ('\u{a62c}', '\u{a63f}'), + ('\u{a6f8}', '\u{a6ff}'), + ('\u{a7c0}', '\u{a7c1}'), + ('\u{a7c7}', '\u{a7f6}'), + ('\u{a82c}', '\u{a82f}'), + ('\u{a83a}', '\u{a83f}'), + ('\u{a878}', '\u{a87f}'), + ('\u{a8c6}', '\u{a8cd}'), + ('\u{a8da}', '\u{a8df}'), + ('\u{a954}', '\u{a95e}'), + ('\u{a97d}', '\u{a97f}'), + ('\u{a9ce}', '\u{a9ce}'), + ('\u{a9da}', '\u{a9dd}'), + ('\u{a9ff}', '\u{a9ff}'), + ('\u{aa37}', '\u{aa3f}'), + ('\u{aa4e}', '\u{aa4f}'), + ('\u{aa5a}', '\u{aa5b}'), + ('\u{aac3}', '\u{aada}'), + ('\u{aaf7}', '\u{ab00}'), + ('\u{ab07}', '\u{ab08}'), + ('\u{ab0f}', '\u{ab10}'), + ('\u{ab17}', '\u{ab1f}'), + ('\u{ab27}', '\u{ab27}'), + ('\u{ab2f}', '\u{ab2f}'), + ('\u{ab68}', '\u{ab6f}'), + ('\u{abee}', '\u{abef}'), + ('\u{abfa}', '\u{abff}'), + ('\u{d7a4}', '\u{d7af}'), + ('\u{d7c7}', '\u{d7ca}'), + ('\u{d7fc}', '\u{f8ff}'), + ('\u{fa6e}', '\u{fa6f}'), + ('\u{fada}', '\u{faff}'), + ('\u{fb07}', '\u{fb12}'), + ('\u{fb18}', '\u{fb1c}'), + ('\u{fb37}', '\u{fb37}'), + ('\u{fb3d}', '\u{fb3d}'), + ('\u{fb3f}', '\u{fb3f}'), + ('\u{fb42}', '\u{fb42}'), + ('\u{fb45}', '\u{fb45}'), + ('\u{fbc2}', '\u{fbd2}'), + ('\u{fd40}', '\u{fd4f}'), + ('\u{fd90}', '\u{fd91}'), + ('\u{fdc8}', '\u{fdef}'), + ('\u{fdfe}', '\u{fdff}'), + ('\u{fe1a}', '\u{fe1f}'), + ('\u{fe53}', '\u{fe53}'), + ('\u{fe67}', '\u{fe67}'), + ('\u{fe6c}', '\u{fe6f}'), + ('\u{fe75}', '\u{fe75}'), + ('\u{fefd}', '\u{ff00}'), + ('\u{ffbf}', '\u{ffc1}'), + ('\u{ffc8}', '\u{ffc9}'), + ('\u{ffd0}', '\u{ffd1}'), + ('\u{ffd8}', '\u{ffd9}'), + ('\u{ffdd}', '\u{ffdf}'), + ('\u{ffe7}', '\u{ffe7}'), + ('\u{ffef}', '\u{fffb}'), + ('\u{fffe}', '\u{ffff}'), + ('\u{1000c}', '\u{1000c}'), + ('\u{10027}', '\u{10027}'), + ('\u{1003b}', '\u{1003b}'), + ('\u{1003e}', '\u{1003e}'), + ('\u{1004e}', '\u{1004f}'), + ('\u{1005e}', '\u{1007f}'), + ('\u{100fb}', '\u{100ff}'), + ('\u{10103}', '\u{10106}'), + ('\u{10134}', '\u{10136}'), + ('\u{1018f}', '\u{1018f}'), + ('\u{1019c}', '\u{1019f}'), + ('\u{101a1}', '\u{101cf}'), + ('\u{101fe}', '\u{1027f}'), + ('\u{1029d}', '\u{1029f}'), + ('\u{102d1}', '\u{102df}'), + ('\u{102fc}', '\u{102ff}'), + ('\u{10324}', '\u{1032c}'), + ('\u{1034b}', '\u{1034f}'), + ('\u{1037b}', '\u{1037f}'), + ('\u{1039e}', '\u{1039e}'), + ('\u{103c4}', '\u{103c7}'), + ('\u{103d6}', '\u{103ff}'), + ('\u{1049e}', '\u{1049f}'), + ('\u{104aa}', '\u{104af}'), + ('\u{104d4}', '\u{104d7}'), + ('\u{104fc}', '\u{104ff}'), + ('\u{10528}', '\u{1052f}'), + ('\u{10564}', '\u{1056e}'), + ('\u{10570}', '\u{105ff}'), + ('\u{10737}', '\u{1073f}'), + ('\u{10756}', '\u{1075f}'), + ('\u{10768}', '\u{107ff}'), + ('\u{10806}', '\u{10807}'), + ('\u{10809}', '\u{10809}'), + ('\u{10836}', '\u{10836}'), + ('\u{10839}', '\u{1083b}'), + ('\u{1083d}', '\u{1083e}'), + ('\u{10856}', '\u{10856}'), + ('\u{1089f}', '\u{108a6}'), + ('\u{108b0}', '\u{108df}'), + ('\u{108f3}', '\u{108f3}'), + ('\u{108f6}', '\u{108fa}'), + ('\u{1091c}', '\u{1091e}'), + ('\u{1093a}', '\u{1093e}'), + ('\u{10940}', '\u{1097f}'), + ('\u{109b8}', '\u{109bb}'), + ('\u{109d0}', '\u{109d1}'), + ('\u{10a04}', '\u{10a04}'), + ('\u{10a07}', '\u{10a0b}'), + ('\u{10a14}', '\u{10a14}'), + ('\u{10a18}', '\u{10a18}'), + ('\u{10a36}', '\u{10a37}'), + ('\u{10a3b}', '\u{10a3e}'), + ('\u{10a49}', '\u{10a4f}'), + ('\u{10a59}', '\u{10a5f}'), + ('\u{10aa0}', '\u{10abf}'), + ('\u{10ae7}', '\u{10aea}'), + ('\u{10af7}', '\u{10aff}'), + ('\u{10b36}', '\u{10b38}'), + ('\u{10b56}', '\u{10b57}'), + ('\u{10b73}', '\u{10b77}'), + ('\u{10b92}', '\u{10b98}'), + ('\u{10b9d}', '\u{10ba8}'), + ('\u{10bb0}', '\u{10bff}'), + ('\u{10c49}', '\u{10c7f}'), + ('\u{10cb3}', '\u{10cbf}'), + ('\u{10cf3}', '\u{10cf9}'), + ('\u{10d28}', '\u{10d2f}'), + ('\u{10d3a}', '\u{10e5f}'), + ('\u{10e7f}', '\u{10eff}'), + ('\u{10f28}', '\u{10f2f}'), + ('\u{10f5a}', '\u{10fdf}'), + ('\u{10ff7}', '\u{10fff}'), + ('\u{1104e}', '\u{11051}'), + ('\u{11070}', '\u{1107e}'), + ('\u{110bd}', '\u{110bd}'), + ('\u{110c2}', '\u{110cf}'), + ('\u{110e9}', '\u{110ef}'), + ('\u{110fa}', '\u{110ff}'), + ('\u{11135}', '\u{11135}'), + ('\u{11147}', '\u{1114f}'), + ('\u{11177}', '\u{1117f}'), + ('\u{111ce}', '\u{111cf}'), + ('\u{111e0}', '\u{111e0}'), + ('\u{111f5}', '\u{111ff}'), + ('\u{11212}', '\u{11212}'), + ('\u{1123f}', '\u{1127f}'), + ('\u{11287}', '\u{11287}'), + ('\u{11289}', '\u{11289}'), + ('\u{1128e}', '\u{1128e}'), + ('\u{1129e}', '\u{1129e}'), + ('\u{112aa}', '\u{112af}'), + ('\u{112eb}', '\u{112ef}'), + ('\u{112fa}', '\u{112ff}'), + ('\u{11304}', '\u{11304}'), + ('\u{1130d}', '\u{1130e}'), + ('\u{11311}', '\u{11312}'), + ('\u{11329}', '\u{11329}'), + ('\u{11331}', '\u{11331}'), + ('\u{11334}', '\u{11334}'), + ('\u{1133a}', '\u{1133a}'), + ('\u{11345}', '\u{11346}'), + ('\u{11349}', '\u{1134a}'), + ('\u{1134e}', '\u{1134f}'), + ('\u{11351}', '\u{11356}'), + ('\u{11358}', '\u{1135c}'), + ('\u{11364}', '\u{11365}'), + ('\u{1136d}', '\u{1136f}'), + ('\u{11375}', '\u{113ff}'), + ('\u{1145a}', '\u{1145a}'), + ('\u{1145c}', '\u{1145c}'), + ('\u{11460}', '\u{1147f}'), + ('\u{114c8}', '\u{114cf}'), + ('\u{114da}', '\u{1157f}'), + ('\u{115b6}', '\u{115b7}'), + ('\u{115de}', '\u{115ff}'), + ('\u{11645}', '\u{1164f}'), + ('\u{1165a}', '\u{1165f}'), + ('\u{1166d}', '\u{1167f}'), + ('\u{116b9}', '\u{116bf}'), + ('\u{116ca}', '\u{116ff}'), + ('\u{1171b}', '\u{1171c}'), + ('\u{1172c}', '\u{1172f}'), + ('\u{11740}', '\u{117ff}'), + ('\u{1183c}', '\u{1189f}'), + ('\u{118f3}', '\u{118fe}'), + ('\u{11900}', '\u{1199f}'), + ('\u{119a8}', '\u{119a9}'), + ('\u{119d8}', '\u{119d9}'), + ('\u{119e5}', '\u{119ff}'), + ('\u{11a48}', '\u{11a4f}'), + ('\u{11aa3}', '\u{11abf}'), + ('\u{11af9}', '\u{11bff}'), + ('\u{11c09}', '\u{11c09}'), + ('\u{11c37}', '\u{11c37}'), + ('\u{11c46}', '\u{11c4f}'), + ('\u{11c6d}', '\u{11c6f}'), + ('\u{11c90}', '\u{11c91}'), + ('\u{11ca8}', '\u{11ca8}'), + ('\u{11cb7}', '\u{11cff}'), + ('\u{11d07}', '\u{11d07}'), + ('\u{11d0a}', '\u{11d0a}'), + ('\u{11d37}', '\u{11d39}'), + ('\u{11d3b}', '\u{11d3b}'), + ('\u{11d3e}', '\u{11d3e}'), + ('\u{11d48}', '\u{11d4f}'), + ('\u{11d5a}', '\u{11d5f}'), + ('\u{11d66}', '\u{11d66}'), + ('\u{11d69}', '\u{11d69}'), + ('\u{11d8f}', '\u{11d8f}'), + ('\u{11d92}', '\u{11d92}'), + ('\u{11d99}', '\u{11d9f}'), + ('\u{11daa}', '\u{11edf}'), + ('\u{11ef9}', '\u{11fbf}'), + ('\u{11ff2}', '\u{11ffe}'), + ('\u{1239a}', '\u{123ff}'), + ('\u{1246f}', '\u{1246f}'), + ('\u{12475}', '\u{1247f}'), + ('\u{12544}', '\u{12fff}'), + ('\u{1342f}', '\u{143ff}'), + ('\u{14647}', '\u{167ff}'), + ('\u{16a39}', '\u{16a3f}'), + ('\u{16a5f}', '\u{16a5f}'), + ('\u{16a6a}', '\u{16a6d}'), + ('\u{16a70}', '\u{16acf}'), + ('\u{16aee}', '\u{16aef}'), + ('\u{16af6}', '\u{16aff}'), + ('\u{16b46}', '\u{16b4f}'), + ('\u{16b5a}', '\u{16b5a}'), + ('\u{16b62}', '\u{16b62}'), + ('\u{16b78}', '\u{16b7c}'), + ('\u{16b90}', '\u{16e3f}'), + ('\u{16e9b}', '\u{16eff}'), + ('\u{16f4b}', '\u{16f4e}'), + ('\u{16f88}', '\u{16f8e}'), + ('\u{16fa0}', '\u{16fdf}'), + ('\u{16fe4}', '\u{16fff}'), + ('\u{187f8}', '\u{187ff}'), + ('\u{18af3}', '\u{1afff}'), + ('\u{1b11f}', '\u{1b14f}'), + ('\u{1b153}', '\u{1b163}'), + ('\u{1b168}', '\u{1b16f}'), + ('\u{1b2fc}', '\u{1bbff}'), + ('\u{1bc6b}', '\u{1bc6f}'), + ('\u{1bc7d}', '\u{1bc7f}'), + ('\u{1bc89}', '\u{1bc8f}'), + ('\u{1bc9a}', '\u{1bc9b}'), + ('\u{1bca0}', '\u{1cfff}'), + ('\u{1d0f6}', '\u{1d0ff}'), + ('\u{1d127}', '\u{1d128}'), + ('\u{1d173}', '\u{1d17a}'), + ('\u{1d1e9}', '\u{1d1ff}'), + ('\u{1d246}', '\u{1d2df}'), + ('\u{1d2f4}', '\u{1d2ff}'), + ('\u{1d357}', '\u{1d35f}'), + ('\u{1d379}', '\u{1d3ff}'), + ('\u{1d455}', '\u{1d455}'), + ('\u{1d49d}', '\u{1d49d}'), + ('\u{1d4a0}', '\u{1d4a1}'), + ('\u{1d4a3}', '\u{1d4a4}'), + ('\u{1d4a7}', '\u{1d4a8}'), + ('\u{1d4ad}', '\u{1d4ad}'), + ('\u{1d4ba}', '\u{1d4ba}'), + ('\u{1d4bc}', '\u{1d4bc}'), + ('\u{1d4c4}', '\u{1d4c4}'), + ('\u{1d506}', '\u{1d506}'), + ('\u{1d50b}', '\u{1d50c}'), + ('\u{1d515}', '\u{1d515}'), + ('\u{1d51d}', '\u{1d51d}'), + ('\u{1d53a}', '\u{1d53a}'), + ('\u{1d53f}', '\u{1d53f}'), + ('\u{1d545}', '\u{1d545}'), + ('\u{1d547}', '\u{1d549}'), + ('\u{1d551}', '\u{1d551}'), + ('\u{1d6a6}', '\u{1d6a7}'), + ('\u{1d7cc}', '\u{1d7cd}'), + ('\u{1da8c}', '\u{1da9a}'), + ('\u{1daa0}', '\u{1daa0}'), + ('\u{1dab0}', '\u{1dfff}'), + ('\u{1e007}', '\u{1e007}'), + ('\u{1e019}', '\u{1e01a}'), + ('\u{1e022}', '\u{1e022}'), + ('\u{1e025}', '\u{1e025}'), + ('\u{1e02b}', '\u{1e0ff}'), + ('\u{1e12d}', '\u{1e12f}'), + ('\u{1e13e}', '\u{1e13f}'), + ('\u{1e14a}', '\u{1e14d}'), + ('\u{1e150}', '\u{1e2bf}'), + ('\u{1e2fa}', '\u{1e2fe}'), + ('\u{1e300}', '\u{1e7ff}'), + ('\u{1e8c5}', '\u{1e8c6}'), + ('\u{1e8d7}', '\u{1e8ff}'), + ('\u{1e94c}', '\u{1e94f}'), + ('\u{1e95a}', '\u{1e95d}'), + ('\u{1e960}', '\u{1ec70}'), + ('\u{1ecb5}', '\u{1ed00}'), + ('\u{1ed3e}', '\u{1edff}'), + ('\u{1ee04}', '\u{1ee04}'), + ('\u{1ee20}', '\u{1ee20}'), + ('\u{1ee23}', '\u{1ee23}'), + ('\u{1ee25}', '\u{1ee26}'), + ('\u{1ee28}', '\u{1ee28}'), + ('\u{1ee33}', '\u{1ee33}'), + ('\u{1ee38}', '\u{1ee38}'), + ('\u{1ee3a}', '\u{1ee3a}'), + ('\u{1ee3c}', '\u{1ee41}'), + ('\u{1ee43}', '\u{1ee46}'), + ('\u{1ee48}', '\u{1ee48}'), + ('\u{1ee4a}', '\u{1ee4a}'), + ('\u{1ee4c}', '\u{1ee4c}'), + ('\u{1ee50}', '\u{1ee50}'), + ('\u{1ee53}', '\u{1ee53}'), + ('\u{1ee55}', '\u{1ee56}'), + ('\u{1ee58}', '\u{1ee58}'), + ('\u{1ee5a}', '\u{1ee5a}'), + ('\u{1ee5c}', '\u{1ee5c}'), + ('\u{1ee5e}', '\u{1ee5e}'), + ('\u{1ee60}', '\u{1ee60}'), + ('\u{1ee63}', '\u{1ee63}'), + ('\u{1ee65}', '\u{1ee66}'), + ('\u{1ee6b}', '\u{1ee6b}'), + ('\u{1ee73}', '\u{1ee73}'), + ('\u{1ee78}', '\u{1ee78}'), + ('\u{1ee7d}', '\u{1ee7d}'), + ('\u{1ee7f}', '\u{1ee7f}'), + ('\u{1ee8a}', '\u{1ee8a}'), + ('\u{1ee9c}', '\u{1eea0}'), + ('\u{1eea4}', '\u{1eea4}'), + ('\u{1eeaa}', '\u{1eeaa}'), + ('\u{1eebc}', '\u{1eeef}'), + ('\u{1eef2}', '\u{1efff}'), + ('\u{1f02c}', '\u{1f02f}'), + ('\u{1f094}', '\u{1f09f}'), + ('\u{1f0af}', '\u{1f0b0}'), + ('\u{1f0c0}', '\u{1f0c0}'), + ('\u{1f0d0}', '\u{1f0d0}'), + ('\u{1f0f6}', '\u{1f0ff}'), + ('\u{1f10d}', '\u{1f10f}'), + ('\u{1f16d}', '\u{1f16f}'), + ('\u{1f1ad}', '\u{1f1e5}'), + ('\u{1f203}', '\u{1f20f}'), + ('\u{1f23c}', '\u{1f23f}'), + ('\u{1f249}', '\u{1f24f}'), + ('\u{1f252}', '\u{1f25f}'), + ('\u{1f266}', '\u{1f2ff}'), + ('\u{1f6d6}', '\u{1f6df}'), + ('\u{1f6ed}', '\u{1f6ef}'), + ('\u{1f6fb}', '\u{1f6ff}'), + ('\u{1f774}', '\u{1f77f}'), + ('\u{1f7d9}', '\u{1f7df}'), + ('\u{1f7ec}', '\u{1f7ff}'), + ('\u{1f80c}', '\u{1f80f}'), + ('\u{1f848}', '\u{1f84f}'), + ('\u{1f85a}', '\u{1f85f}'), + ('\u{1f888}', '\u{1f88f}'), + ('\u{1f8ae}', '\u{1f8ff}'), + ('\u{1f90c}', '\u{1f90c}'), + ('\u{1f972}', '\u{1f972}'), + ('\u{1f977}', '\u{1f979}'), + ('\u{1f9a3}', '\u{1f9a4}'), + ('\u{1f9ab}', '\u{1f9ad}'), + ('\u{1f9cb}', '\u{1f9cc}'), + ('\u{1fa54}', '\u{1fa5f}'), + ('\u{1fa6e}', '\u{1fa6f}'), + ('\u{1fa74}', '\u{1fa77}'), + ('\u{1fa7b}', '\u{1fa7f}'), + ('\u{1fa83}', '\u{1fa8f}'), + ('\u{1fa96}', '\u{1ffff}'), + ('\u{2a6d7}', '\u{2a6ff}'), + ('\u{2b735}', '\u{2b73f}'), + ('\u{2b81e}', '\u{2b81f}'), + ('\u{2cea2}', '\u{2ceaf}'), + ('\u{2ebe1}', '\u{2f7ff}'), + ('\u{2fa1e}', '\u{e00ff}'), + ('\u{e01f0}', '\u{10ffff}'), +]; + +pub const OTHER_LETTER: &'static [(char, char)] = &[ + ('ª', 'ª'), + ('º', 'º'), + ('ƻ', 'ƻ'), + ('ǀ', 'ǃ'), + ('ʔ', 'ʔ'), + ('א', 'ת'), + ('ׯ', 'ײ'), + ('ؠ', 'ؿ'), + ('ف', 'ي'), + ('ٮ', 'ٯ'), + ('ٱ', 'ۓ'), + ('ە', 'ە'), + ('ۮ', 'ۯ'), + ('ۺ', 'ۼ'), + ('ۿ', 'ۿ'), + ('ܐ', 'ܐ'), + ('ܒ', 'ܯ'), + ('ݍ', 'ޥ'), + ('ޱ', 'ޱ'), + ('ߊ', 'ߪ'), + ('ࠀ', 'ࠕ'), + ('ࡀ', 'ࡘ'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('ऄ', 'ह'), + ('ऽ', 'ऽ'), + ('ॐ', 'ॐ'), + ('क़', 'ॡ'), + ('ॲ', 'ঀ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('ঽ', 'ঽ'), + ('ৎ', 'ৎ'), + ('ড়', 'ঢ়'), + ('য়', 'ৡ'), + ('ৰ', 'ৱ'), + ('ৼ', 'ৼ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('ੲ', 'ੴ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('ઽ', 'ઽ'), + ('ૐ', 'ૐ'), + ('ૠ', 'ૡ'), + ('ૹ', 'ૹ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('ଽ', 'ଽ'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', 'ୡ'), + ('ୱ', 'ୱ'), + ('ஃ', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('ௐ', 'ௐ'), + ('అ', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ఽ'), + ('ౘ', 'ౚ'), + ('ౠ', 'ౡ'), + ('ಀ', 'ಀ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('ಽ', 'ಽ'), + ('ೞ', 'ೞ'), + ('ೠ', 'ೡ'), + ('ೱ', 'ೲ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', 'ഺ'), + ('ഽ', 'ഽ'), + ('ൎ', 'ൎ'), + ('ൔ', 'ൖ'), + ('ൟ', 'ൡ'), + ('ൺ', 'ൿ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('ก', 'ะ'), + ('า', 'ำ'), + ('เ', 'ๅ'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ະ'), + ('າ', 'ຳ'), + ('ຽ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໜ', 'ໟ'), + ('ༀ', 'ༀ'), + ('ཀ', 'ཇ'), + ('ཉ', 'ཬ'), + ('ྈ', 'ྌ'), + ('က', 'ဪ'), + ('ဿ', 'ဿ'), + ('ၐ', 'ၕ'), + ('ၚ', 'ၝ'), + ('ၡ', 'ၡ'), + ('ၥ', 'ၦ'), + ('ၮ', 'ၰ'), + ('ၵ', 'ႁ'), + ('ႎ', 'ႎ'), + ('ᄀ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('ᎀ', 'ᎏ'), + ('ᐁ', 'ᙬ'), + ('ᙯ', 'ᙿ'), + ('ᚁ', 'ᚚ'), + ('ᚠ', 'ᛪ'), + ('ᛱ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', 'ᜑ'), + ('ᜠ', 'ᜱ'), + ('ᝀ', 'ᝑ'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('ក', 'ឳ'), + ('ៜ', 'ៜ'), + ('ᠠ', 'ᡂ'), + ('ᡄ', 'ᡸ'), + ('ᢀ', 'ᢄ'), + ('ᢇ', 'ᢨ'), + ('ᢪ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('ᥐ', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('ᦀ', 'ᦫ'), + ('ᦰ', 'ᧉ'), + ('ᨀ', 'ᨖ'), + ('ᨠ', 'ᩔ'), + ('ᬅ', 'ᬳ'), + ('ᭅ', 'ᭋ'), + ('ᮃ', 'ᮠ'), + ('ᮮ', 'ᮯ'), + ('ᮺ', 'ᯥ'), + ('ᰀ', 'ᰣ'), + ('ᱍ', 'ᱏ'), + ('ᱚ', 'ᱷ'), + ('ᳩ', 'ᳬ'), + ('ᳮ', 'ᳳ'), + ('ᳵ', 'ᳶ'), + ('\u{1cfa}', '\u{1cfa}'), + ('ℵ', 'ℸ'), + ('ⴰ', 'ⵧ'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('〆', '〆'), + ('〼', '〼'), + ('ぁ', 'ゖ'), + ('ゟ', 'ゟ'), + ('ァ', 'ヺ'), + ('ヿ', 'ヿ'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('ㆠ', 'ㆺ'), + ('ㇰ', 'ㇿ'), + ('㐀', '䶵'), + ('一', '鿯'), + ('ꀀ', 'ꀔ'), + ('ꀖ', 'ꒌ'), + ('ꓐ', 'ꓷ'), + ('ꔀ', 'ꘋ'), + ('ꘐ', 'ꘟ'), + ('ꘪ', 'ꘫ'), + ('ꙮ', 'ꙮ'), + ('ꚠ', 'ꛥ'), + ('ꞏ', 'ꞏ'), + ('ꟷ', 'ꟷ'), + ('ꟻ', 'ꠁ'), + ('ꠃ', 'ꠅ'), + ('ꠇ', 'ꠊ'), + ('ꠌ', 'ꠢ'), + ('ꡀ', 'ꡳ'), + ('ꢂ', 'ꢳ'), + ('ꣲ', 'ꣷ'), + ('ꣻ', 'ꣻ'), + ('ꣽ', 'ꣾ'), + ('ꤊ', 'ꤥ'), + ('ꤰ', 'ꥆ'), + ('ꥠ', 'ꥼ'), + ('ꦄ', 'ꦲ'), + ('ꧠ', 'ꧤ'), + ('ꧧ', 'ꧯ'), + ('ꧺ', 'ꧾ'), + ('ꨀ', 'ꨨ'), + ('ꩀ', 'ꩂ'), + ('ꩄ', 'ꩋ'), + ('ꩠ', 'ꩯ'), + ('ꩱ', 'ꩶ'), + ('ꩺ', 'ꩺ'), + ('ꩾ', 'ꪯ'), + ('ꪱ', 'ꪱ'), + ('ꪵ', 'ꪶ'), + ('ꪹ', 'ꪽ'), + ('ꫀ', 'ꫀ'), + ('ꫂ', 'ꫂ'), + ('ꫛ', 'ꫜ'), + ('ꫠ', 'ꫪ'), + ('ꫲ', 'ꫲ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꯀ', 'ꯢ'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('豈', '舘'), + ('並', '龎'), + ('יִ', 'יִ'), + ('ײַ', 'ﬨ'), + ('שׁ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﮱ'), + ('ﯓ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷻ'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('ヲ', 'ッ'), + ('ア', 'ン'), + ('ᅠ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('𐌀', '𐌟'), + ('𐌭', '𐍀'), + ('𐍂', '𐍉'), + ('𐍐', '𐍵'), + ('𐎀', '𐎝'), + ('𐎠', '𐏃'), + ('𐏈', '𐏏'), + ('𐑐', '𐒝'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡠', '𐡶'), + ('𐢀', '𐢞'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐤀', '𐤕'), + ('𐤠', '𐤹'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𐨀', '𐨀'), + ('𐨐', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('𐩠', '𐩼'), + ('𐪀', '𐪜'), + ('𐫀', '𐫇'), + ('𐫉', '𐫤'), + ('𐬀', '𐬵'), + ('𐭀', '𐭕'), + ('𐭠', '𐭲'), + ('𐮀', '𐮑'), + ('𐰀', '𐱈'), + ('𐴀', '𐴣'), + ('𐼀', '𐼜'), + ('𐼧', '𐼧'), + ('𐼰', '𐽅'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀃', '𑀷'), + ('𑂃', '𑂯'), + ('𑃐', '𑃨'), + ('𑄃', '𑄦'), + ('𑅄', '𑅄'), + ('𑅐', '𑅲'), + ('𑅶', '𑅶'), + ('𑆃', '𑆲'), + ('𑇁', '𑇄'), + ('𑇚', '𑇚'), + ('𑇜', '𑇜'), + ('𑈀', '𑈑'), + ('𑈓', '𑈫'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊨'), + ('𑊰', '𑋞'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('𑌽', '𑌽'), + ('𑍐', '𑍐'), + ('𑍝', '𑍡'), + ('𑐀', '𑐴'), + ('𑑇', '𑑊'), + ('\u{1145f}', '\u{1145f}'), + ('𑒀', '𑒯'), + ('𑓄', '𑓅'), + ('𑓇', '𑓇'), + ('𑖀', '𑖮'), + ('𑗘', '𑗛'), + ('𑘀', '𑘯'), + ('𑙄', '𑙄'), + ('𑚀', '𑚪'), + ('\u{116b8}', '\u{116b8}'), + ('𑜀', '𑜚'), + ('𑠀', '𑠫'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d0}'), + ('\u{119e1}', '\u{119e1}'), + ('\u{119e3}', '\u{119e3}'), + ('𑨀', '𑨀'), + ('𑨋', '𑨲'), + ('𑨺', '𑨺'), + ('𑩐', '𑩐'), + ('𑩜', '𑪉'), + ('𑪝', '𑪝'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '𑰮'), + ('𑱀', '𑱀'), + ('𑱲', '𑲏'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '𑴰'), + ('𑵆', '𑵆'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶉'), + ('𑶘', '𑶘'), + ('𑻠', '𑻲'), + ('𒀀', '𒎙'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖫐', '𖫭'), + ('𖬀', '𖬯'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖼀', '\u{16f4a}'), + ('𖽐', '𖽐'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛀀', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('𛅰', '𛋻'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e14e}', '\u{1e14e}'), + ('\u{1e2c0}', '\u{1e2eb}'), + ('𞠀', '𞣄'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), +]; + +pub const OTHER_NUMBER: &'static [(char, char)] = &[ + ('²', '³'), + ('¹', '¹'), + ('¼', '¾'), + ('৴', '৹'), + ('୲', '୷'), + ('௰', '௲'), + ('౸', '౾'), + ('൘', '൞'), + ('൰', '൸'), + ('༪', '༳'), + ('፩', '፼'), + ('៰', '៹'), + ('᧚', '᧚'), + ('⁰', '⁰'), + ('⁴', '⁹'), + ('₀', '₉'), + ('⅐', '⅟'), + ('↉', '↉'), + ('①', '⒛'), + ('⓪', '⓿'), + ('❶', '➓'), + ('⳽', '⳽'), + ('㆒', '㆕'), + ('㈠', '㈩'), + ('㉈', '㉏'), + ('㉑', '㉟'), + ('㊀', '㊉'), + ('㊱', '㊿'), + ('꠰', '꠵'), + ('𐄇', '𐄳'), + ('𐅵', '𐅸'), + ('𐆊', '𐆋'), + ('𐋡', '𐋻'), + ('𐌠', '𐌣'), + ('𐡘', '𐡟'), + ('𐡹', '𐡿'), + ('𐢧', '𐢯'), + ('𐣻', '𐣿'), + ('𐤖', '𐤛'), + ('𐦼', '𐦽'), + ('𐧀', '𐧏'), + ('𐧒', '𐧿'), + ('𐩀', '𐩈'), + ('𐩽', '𐩾'), + ('𐪝', '𐪟'), + ('𐫫', '𐫯'), + ('𐭘', '𐭟'), + ('𐭸', '𐭿'), + ('𐮩', '𐮯'), + ('𐳺', '𐳿'), + ('𐹠', '𐹾'), + ('𐼝', '𐼦'), + ('𐽑', '𐽔'), + ('𑁒', '𑁥'), + ('𑇡', '𑇴'), + ('𑜺', '𑜻'), + ('𑣪', '𑣲'), + ('𑱚', '𑱬'), + ('\u{11fc0}', '\u{11fd4}'), + ('𖭛', '𖭡'), + ('𖺀', '𖺖'), + ('𝋠', '𝋳'), + ('𝍠', '𝍸'), + ('𞣇', '𞣏'), + ('𞱱', '𞲫'), + ('𞲭', '𞲯'), + ('𞲱', '𞲴'), + ('\u{1ed01}', '\u{1ed2d}'), + ('\u{1ed2f}', '\u{1ed3d}'), + ('🄀', '🄌'), +]; + +pub const OTHER_PUNCTUATION: &'static [(char, char)] = &[ + ('!', '#'), + ('%', '\''), + ('*', '*'), + (',', ','), + ('.', '/'), + (':', ';'), + ('?', '@'), + ('\\', '\\'), + ('¡', '¡'), + ('§', '§'), + ('¶', '·'), + ('¿', '¿'), + (';', ';'), + ('·', '·'), + ('՚', '՟'), + ('։', '։'), + ('׀', '׀'), + ('׃', '׃'), + ('׆', '׆'), + ('׳', '״'), + ('؉', '؊'), + ('،', '؍'), + ('؛', '؛'), + ('؞', '؟'), + ('٪', '٭'), + ('۔', '۔'), + ('܀', '܍'), + ('߷', '߹'), + ('࠰', '࠾'), + ('࡞', '࡞'), + ('।', '॥'), + ('॰', '॰'), + ('৽', '৽'), + ('੶', '੶'), + ('૰', '૰'), + ('\u{c77}', '\u{c77}'), + ('಄', '಄'), + ('෴', '෴'), + ('๏', '๏'), + ('๚', '๛'), + ('༄', '༒'), + ('༔', '༔'), + ('྅', '྅'), + ('࿐', '࿔'), + ('࿙', '࿚'), + ('၊', '၏'), + ('჻', '჻'), + ('፠', '፨'), + ('᙮', '᙮'), + ('᛫', '᛭'), + ('᜵', '᜶'), + ('។', '៖'), + ('៘', '៚'), + ('᠀', '᠅'), + ('᠇', '᠊'), + ('᥄', '᥅'), + ('᨞', '᨟'), + ('᪠', '᪦'), + ('᪨', '᪭'), + ('᭚', '᭠'), + ('᯼', '᯿'), + ('᰻', '᰿'), + ('᱾', '᱿'), + ('᳀', '᳇'), + ('᳓', '᳓'), + ('‖', '‗'), + ('†', '‧'), + ('‰', '‸'), + ('※', '‾'), + ('⁁', '⁃'), + ('⁇', '⁑'), + ('⁓', '⁓'), + ('⁕', '⁞'), + ('⳹', '⳼'), + ('⳾', '⳿'), + ('⵰', '⵰'), + ('⸀', '⸁'), + ('⸆', '⸈'), + ('⸋', '⸋'), + ('⸎', '⸖'), + ('⸘', '⸙'), + ('⸛', '⸛'), + ('⸞', '⸟'), + ('⸪', '⸮'), + ('⸰', '⸹'), + ('⸼', '⸿'), + ('⹁', '⹁'), + ('⹃', '\u{2e4f}'), + ('、', '〃'), + ('〽', '〽'), + ('・', '・'), + ('꓾', '꓿'), + ('꘍', '꘏'), + ('꙳', '꙳'), + ('꙾', '꙾'), + ('꛲', '꛷'), + ('꡴', '꡷'), + ('꣎', '꣏'), + ('꣸', '꣺'), + ('꣼', '꣼'), + ('꤮', '꤯'), + ('꥟', '꥟'), + ('꧁', '꧍'), + ('꧞', '꧟'), + ('꩜', '꩟'), + ('꫞', '꫟'), + ('꫰', '꫱'), + ('꯫', '꯫'), + ('︐', '︖'), + ('︙', '︙'), + ('︰', '︰'), + ('﹅', '﹆'), + ('﹉', '﹌'), + ('﹐', '﹒'), + ('﹔', '﹗'), + ('﹟', '﹡'), + ('﹨', '﹨'), + ('﹪', '﹫'), + ('!', '#'), + ('%', '''), + ('*', '*'), + (',', ','), + ('.', '/'), + (':', ';'), + ('?', '@'), + ('\', '\'), + ('。', '。'), + ('、', '・'), + ('𐄀', '𐄂'), + ('𐎟', '𐎟'), + ('𐏐', '𐏐'), + ('𐕯', '𐕯'), + ('𐡗', '𐡗'), + ('𐤟', '𐤟'), + ('𐤿', '𐤿'), + ('𐩐', '𐩘'), + ('𐩿', '𐩿'), + ('𐫰', '𐫶'), + ('𐬹', '𐬿'), + ('𐮙', '𐮜'), + ('𐽕', '𐽙'), + ('𑁇', '𑁍'), + ('𑂻', '𑂼'), + ('𑂾', '𑃁'), + ('𑅀', '𑅃'), + ('𑅴', '𑅵'), + ('𑇅', '𑇈'), + ('𑇍', '𑇍'), + ('𑇛', '𑇛'), + ('𑇝', '𑇟'), + ('𑈸', '𑈽'), + ('𑊩', '𑊩'), + ('𑑋', '𑑏'), + ('𑑛', '𑑛'), + ('𑑝', '𑑝'), + ('𑓆', '𑓆'), + ('𑗁', '𑗗'), + ('𑙁', '𑙃'), + ('𑙠', '𑙬'), + ('𑜼', '𑜾'), + ('𑠻', '𑠻'), + ('\u{119e2}', '\u{119e2}'), + ('𑨿', '𑩆'), + ('𑪚', '𑪜'), + ('𑪞', '𑪢'), + ('𑱁', '𑱅'), + ('𑱰', '𑱱'), + ('𑻷', '𑻸'), + ('\u{11fff}', '\u{11fff}'), + ('𒑰', '𒑴'), + ('𖩮', '𖩯'), + ('𖫵', '𖫵'), + ('𖬷', '𖬻'), + ('𖭄', '𖭄'), + ('𖺗', '𖺚'), + ('\u{16fe2}', '\u{16fe2}'), + ('𛲟', '𛲟'), + ('𝪇', '𝪋'), + ('𞥞', '𞥟'), +]; + +pub const OTHER_SYMBOL: &'static [(char, char)] = &[ + ('¦', '¦'), + ('©', '©'), + ('®', '®'), + ('°', '°'), + ('҂', '҂'), + ('֍', '֎'), + ('؎', '؏'), + ('۞', '۞'), + ('۩', '۩'), + ('۽', '۾'), + ('߶', '߶'), + ('৺', '৺'), + ('୰', '୰'), + ('௳', '௸'), + ('௺', '௺'), + ('౿', '౿'), + ('൏', '൏'), + ('൹', '൹'), + ('༁', '༃'), + ('༓', '༓'), + ('༕', '༗'), + ('༚', '༟'), + ('༴', '༴'), + ('༶', '༶'), + ('༸', '༸'), + ('྾', '࿅'), + ('࿇', '࿌'), + ('࿎', '࿏'), + ('࿕', '࿘'), + ('႞', '႟'), + ('᎐', '᎙'), + ('᙭', '᙭'), + ('᥀', '᥀'), + ('᧞', '᧿'), + ('᭡', '᭪'), + ('᭴', '᭼'), + ('℀', '℁'), + ('℃', '℆'), + ('℈', '℉'), + ('℔', '℔'), + ('№', '℗'), + ('℞', '℣'), + ('℥', '℥'), + ('℧', '℧'), + ('℩', '℩'), + ('℮', '℮'), + ('℺', '℻'), + ('⅊', '⅊'), + ('⅌', '⅍'), + ('⅏', '⅏'), + ('↊', '↋'), + ('↕', '↙'), + ('↜', '↟'), + ('↡', '↢'), + ('↤', '↥'), + ('↧', '↭'), + ('↯', '⇍'), + ('⇐', '⇑'), + ('⇓', '⇓'), + ('⇕', '⇳'), + ('⌀', '⌇'), + ('⌌', '⌟'), + ('⌢', '⌨'), + ('⌫', '⍻'), + ('⍽', '⎚'), + ('⎴', '⏛'), + ('⏢', '␦'), + ('⑀', '⑊'), + ('⒜', 'ⓩ'), + ('─', '▶'), + ('▸', '◀'), + ('◂', '◷'), + ('☀', '♮'), + ('♰', '❧'), + ('➔', '➿'), + ('⠀', '⣿'), + ('⬀', '⬯'), + ('⭅', '⭆'), + ('⭍', '⭳'), + ('⭶', '⮕'), + ('⮘', '\u{2bff}'), + ('⳥', '⳪'), + ('⺀', '⺙'), + ('⺛', '⻳'), + ('⼀', '⿕'), + ('⿰', '⿻'), + ('〄', '〄'), + ('〒', '〓'), + ('〠', '〠'), + ('〶', '〷'), + ('〾', '〿'), + ('㆐', '㆑'), + ('㆖', '㆟'), + ('㇀', '㇣'), + ('㈀', '㈞'), + ('㈪', '㉇'), + ('㉐', '㉐'), + ('㉠', '㉿'), + ('㊊', '㊰'), + ('㋀', '㏿'), + ('䷀', '䷿'), + ('꒐', '꓆'), + ('꠨', '꠫'), + ('꠶', '꠷'), + ('꠹', '꠹'), + ('꩷', '꩹'), + ('﷽', '﷽'), + ('¦', '¦'), + ('│', '│'), + ('■', '○'), + ('', '�'), + ('𐄷', '𐄿'), + ('𐅹', '𐆉'), + ('𐆌', '𐆎'), + ('𐆐', '𐆛'), + ('𐆠', '𐆠'), + ('𐇐', '𐇼'), + ('𐡷', '𐡸'), + ('𐫈', '𐫈'), + ('𑜿', '𑜿'), + ('\u{11fd5}', '\u{11fdc}'), + ('\u{11fe1}', '\u{11ff1}'), + ('𖬼', '𖬿'), + ('𖭅', '𖭅'), + ('𛲜', '𛲜'), + ('𝀀', '𝃵'), + ('𝄀', '𝄦'), + ('𝄩', '𝅘𝅥𝅲'), + ('𝅪', '𝅬'), + ('𝆃', '𝆄'), + ('𝆌', '𝆩'), + ('𝆮', '𝇨'), + ('𝈀', '𝉁'), + ('𝉅', '𝉅'), + ('𝌀', '𝍖'), + ('𝠀', '𝧿'), + ('𝨷', '𝨺'), + ('𝩭', '𝩴'), + ('𝩶', '𝪃'), + ('𝪅', '𝪆'), + ('\u{1e14f}', '\u{1e14f}'), + ('𞲬', '𞲬'), + ('\u{1ed2e}', '\u{1ed2e}'), + ('🀀', '🀫'), + ('🀰', '🂓'), + ('🂠', '🂮'), + ('🂱', '🂿'), + ('🃁', '🃏'), + ('🃑', '🃵'), + ('🄐', '\u{1f16c}'), + ('🅰', '🆬'), + ('🇦', '🈂'), + ('🈐', '🈻'), + ('🉀', '🉈'), + ('🉐', '🉑'), + ('🉠', '🉥'), + ('🌀', '🏺'), + ('🐀', '\u{1f6d5}'), + ('🛠', '🛬'), + ('🛰', '\u{1f6fa}'), + ('🜀', '🝳'), + ('🞀', '🟘'), + ('\u{1f7e0}', '\u{1f7eb}'), + ('🠀', '🠋'), + ('🠐', '🡇'), + ('🡐', '🡙'), + ('🡠', '🢇'), + ('🢐', '🢭'), + ('🤀', '🤋'), + ('\u{1f90d}', '\u{1f971}'), + ('🥳', '🥶'), + ('🥺', '🦢'), + ('\u{1f9a5}', '\u{1f9aa}'), + ('\u{1f9ae}', '\u{1f9ca}'), + ('\u{1f9cd}', '\u{1fa53}'), + ('🩠', '🩭'), + ('\u{1fa70}', '\u{1fa73}'), + ('\u{1fa78}', '\u{1fa7a}'), + ('\u{1fa80}', '\u{1fa82}'), + ('\u{1fa90}', '\u{1fa95}'), +]; + +pub const PARAGRAPH_SEPARATOR: &'static [(char, char)] = + &[('\u{2029}', '\u{2029}')]; + +pub const PRIVATE_USE: &'static [(char, char)] = &[ + ('\u{e000}', '\u{f8ff}'), + ('\u{f0000}', '\u{ffffd}'), + ('\u{100000}', '\u{10fffd}'), +]; + +pub const PUNCTUATION: &'static [(char, char)] = &[ + ('!', '#'), + ('%', '*'), + (',', '/'), + (':', ';'), + ('?', '@'), + ('[', ']'), + ('_', '_'), + ('{', '{'), + ('}', '}'), + ('¡', '¡'), + ('§', '§'), + ('«', '«'), + ('¶', '·'), + ('»', '»'), + ('¿', '¿'), + (';', ';'), + ('·', '·'), + ('՚', '՟'), + ('։', '֊'), + ('־', '־'), + ('׀', '׀'), + ('׃', '׃'), + ('׆', '׆'), + ('׳', '״'), + ('؉', '؊'), + ('،', '؍'), + ('؛', '؛'), + ('؞', '؟'), + ('٪', '٭'), + ('۔', '۔'), + ('܀', '܍'), + ('߷', '߹'), + ('࠰', '࠾'), + ('࡞', '࡞'), + ('।', '॥'), + ('॰', '॰'), + ('৽', '৽'), + ('੶', '੶'), + ('૰', '૰'), + ('\u{c77}', '\u{c77}'), + ('಄', '಄'), + ('෴', '෴'), + ('๏', '๏'), + ('๚', '๛'), + ('༄', '༒'), + ('༔', '༔'), + ('༺', '༽'), + ('྅', '྅'), + ('࿐', '࿔'), + ('࿙', '࿚'), + ('၊', '၏'), + ('჻', '჻'), + ('፠', '፨'), + ('᐀', '᐀'), + ('᙮', '᙮'), + ('᚛', '᚜'), + ('᛫', '᛭'), + ('᜵', '᜶'), + ('។', '៖'), + ('៘', '៚'), + ('᠀', '᠊'), + ('᥄', '᥅'), + ('᨞', '᨟'), + ('᪠', '᪦'), + ('᪨', '᪭'), + ('᭚', '᭠'), + ('᯼', '᯿'), + ('᰻', '᰿'), + ('᱾', '᱿'), + ('᳀', '᳇'), + ('᳓', '᳓'), + ('‐', '‧'), + ('‰', '⁃'), + ('⁅', '⁑'), + ('⁓', '⁞'), + ('⁽', '⁾'), + ('₍', '₎'), + ('⌈', '⌋'), + ('〈', '〉'), + ('❨', '❵'), + ('⟅', '⟆'), + ('⟦', '⟯'), + ('⦃', '⦘'), + ('⧘', '⧛'), + ('⧼', '⧽'), + ('⳹', '⳼'), + ('⳾', '⳿'), + ('⵰', '⵰'), + ('⸀', '⸮'), + ('⸰', '\u{2e4f}'), + ('、', '〃'), + ('〈', '】'), + ('〔', '〟'), + ('〰', '〰'), + ('〽', '〽'), + ('゠', '゠'), + ('・', '・'), + ('꓾', '꓿'), + ('꘍', '꘏'), + ('꙳', '꙳'), + ('꙾', '꙾'), + ('꛲', '꛷'), + ('꡴', '꡷'), + ('꣎', '꣏'), + ('꣸', '꣺'), + ('꣼', '꣼'), + ('꤮', '꤯'), + ('꥟', '꥟'), + ('꧁', '꧍'), + ('꧞', '꧟'), + ('꩜', '꩟'), + ('꫞', '꫟'), + ('꫰', '꫱'), + ('꯫', '꯫'), + ('﴾', '﴿'), + ('︐', '︙'), + ('︰', '﹒'), + ('﹔', '﹡'), + ('﹣', '﹣'), + ('﹨', '﹨'), + ('﹪', '﹫'), + ('!', '#'), + ('%', '*'), + (',', '/'), + (':', ';'), + ('?', '@'), + ('[', ']'), + ('_', '_'), + ('{', '{'), + ('}', '}'), + ('⦅', '・'), + ('𐄀', '𐄂'), + ('𐎟', '𐎟'), + ('𐏐', '𐏐'), + ('𐕯', '𐕯'), + ('𐡗', '𐡗'), + ('𐤟', '𐤟'), + ('𐤿', '𐤿'), + ('𐩐', '𐩘'), + ('𐩿', '𐩿'), + ('𐫰', '𐫶'), + ('𐬹', '𐬿'), + ('𐮙', '𐮜'), + ('𐽕', '𐽙'), + ('𑁇', '𑁍'), + ('𑂻', '𑂼'), + ('𑂾', '𑃁'), + ('𑅀', '𑅃'), + ('𑅴', '𑅵'), + ('𑇅', '𑇈'), + ('𑇍', '𑇍'), + ('𑇛', '𑇛'), + ('𑇝', '𑇟'), + ('𑈸', '𑈽'), + ('𑊩', '𑊩'), + ('𑑋', '𑑏'), + ('𑑛', '𑑛'), + ('𑑝', '𑑝'), + ('𑓆', '𑓆'), + ('𑗁', '𑗗'), + ('𑙁', '𑙃'), + ('𑙠', '𑙬'), + ('𑜼', '𑜾'), + ('𑠻', '𑠻'), + ('\u{119e2}', '\u{119e2}'), + ('𑨿', '𑩆'), + ('𑪚', '𑪜'), + ('𑪞', '𑪢'), + ('𑱁', '𑱅'), + ('𑱰', '𑱱'), + ('𑻷', '𑻸'), + ('\u{11fff}', '\u{11fff}'), + ('𒑰', '𒑴'), + ('𖩮', '𖩯'), + ('𖫵', '𖫵'), + ('𖬷', '𖬻'), + ('𖭄', '𖭄'), + ('𖺗', '𖺚'), + ('\u{16fe2}', '\u{16fe2}'), + ('𛲟', '𛲟'), + ('𝪇', '𝪋'), + ('𞥞', '𞥟'), +]; + +pub const SEPARATOR: &'static [(char, char)] = &[ + (' ', ' '), + ('\u{a0}', '\u{a0}'), + ('\u{1680}', '\u{1680}'), + ('\u{2000}', '\u{200a}'), + ('\u{2028}', '\u{2029}'), + ('\u{202f}', '\u{202f}'), + ('\u{205f}', '\u{205f}'), + ('\u{3000}', '\u{3000}'), +]; + +pub const SPACE_SEPARATOR: &'static [(char, char)] = &[ + (' ', ' '), + ('\u{a0}', '\u{a0}'), + ('\u{1680}', '\u{1680}'), + ('\u{2000}', '\u{200a}'), + ('\u{202f}', '\u{202f}'), + ('\u{205f}', '\u{205f}'), + ('\u{3000}', '\u{3000}'), +]; + +pub const SPACING_MARK: &'static [(char, char)] = &[ + ('ः', 'ः'), + ('ऻ', 'ऻ'), + ('ा', 'ी'), + ('ॉ', 'ौ'), + ('ॎ', 'ॏ'), + ('ং', 'ঃ'), + ('\u{9be}', 'ী'), + ('ে', 'ৈ'), + ('ো', 'ৌ'), + ('\u{9d7}', '\u{9d7}'), + ('ਃ', 'ਃ'), + ('ਾ', 'ੀ'), + ('ઃ', 'ઃ'), + ('ા', 'ી'), + ('ૉ', 'ૉ'), + ('ો', 'ૌ'), + ('ଂ', 'ଃ'), + ('\u{b3e}', '\u{b3e}'), + ('ୀ', 'ୀ'), + ('େ', 'ୈ'), + ('ୋ', 'ୌ'), + ('\u{b57}', '\u{b57}'), + ('\u{bbe}', 'ி'), + ('ு', 'ூ'), + ('ெ', 'ை'), + ('ொ', 'ௌ'), + ('\u{bd7}', '\u{bd7}'), + ('ఁ', 'ః'), + ('ు', 'ౄ'), + ('ಂ', 'ಃ'), + ('ಾ', 'ಾ'), + ('ೀ', 'ೄ'), + ('ೇ', 'ೈ'), + ('ೊ', 'ೋ'), + ('\u{cd5}', '\u{cd6}'), + ('ം', 'ഃ'), + ('\u{d3e}', 'ീ'), + ('െ', 'ൈ'), + ('ൊ', 'ൌ'), + ('\u{d57}', '\u{d57}'), + ('ං', 'ඃ'), + ('\u{dcf}', 'ෑ'), + ('ෘ', '\u{ddf}'), + ('ෲ', 'ෳ'), + ('༾', '༿'), + ('ཿ', 'ཿ'), + ('ါ', 'ာ'), + ('ေ', 'ေ'), + ('း', 'း'), + ('ျ', 'ြ'), + ('ၖ', 'ၗ'), + ('ၢ', 'ၤ'), + ('ၧ', 'ၭ'), + ('ႃ', 'ႄ'), + ('ႇ', 'ႌ'), + ('ႏ', 'ႏ'), + ('ႚ', 'ႜ'), + ('ា', 'ា'), + ('ើ', 'ៅ'), + ('ះ', 'ៈ'), + ('ᤣ', 'ᤦ'), + ('ᤩ', 'ᤫ'), + ('ᤰ', 'ᤱ'), + ('ᤳ', 'ᤸ'), + ('ᨙ', 'ᨚ'), + ('ᩕ', 'ᩕ'), + ('ᩗ', 'ᩗ'), + ('ᩡ', 'ᩡ'), + ('ᩣ', 'ᩤ'), + ('ᩭ', 'ᩲ'), + ('ᬄ', 'ᬄ'), + ('ᬵ', 'ᬵ'), + ('ᬻ', 'ᬻ'), + ('ᬽ', 'ᭁ'), + ('ᭃ', '᭄'), + ('ᮂ', 'ᮂ'), + ('ᮡ', 'ᮡ'), + ('ᮦ', 'ᮧ'), + ('᮪', '᮪'), + ('ᯧ', 'ᯧ'), + ('ᯪ', 'ᯬ'), + ('ᯮ', 'ᯮ'), + ('᯲', '᯳'), + ('ᰤ', 'ᰫ'), + ('ᰴ', 'ᰵ'), + ('᳡', '᳡'), + ('᳷', '᳷'), + ('\u{302e}', '\u{302f}'), + ('ꠣ', 'ꠤ'), + ('ꠧ', 'ꠧ'), + ('ꢀ', 'ꢁ'), + ('ꢴ', 'ꣃ'), + ('ꥒ', '꥓'), + ('ꦃ', 'ꦃ'), + ('ꦴ', 'ꦵ'), + ('ꦺ', 'ꦻ'), + ('ꦾ', '꧀'), + ('ꨯ', 'ꨰ'), + ('ꨳ', 'ꨴ'), + ('ꩍ', 'ꩍ'), + ('ꩻ', 'ꩻ'), + ('ꩽ', 'ꩽ'), + ('ꫫ', 'ꫫ'), + ('ꫮ', 'ꫯ'), + ('ꫵ', 'ꫵ'), + ('ꯣ', 'ꯤ'), + ('ꯦ', 'ꯧ'), + ('ꯩ', 'ꯪ'), + ('꯬', '꯬'), + ('𑀀', '𑀀'), + ('𑀂', '𑀂'), + ('𑂂', '𑂂'), + ('𑂰', '𑂲'), + ('𑂷', '𑂸'), + ('𑄬', '𑄬'), + ('𑅅', '𑅆'), + ('𑆂', '𑆂'), + ('𑆳', '𑆵'), + ('𑆿', '𑇀'), + ('𑈬', '𑈮'), + ('𑈲', '𑈳'), + ('𑈵', '𑈵'), + ('𑋠', '𑋢'), + ('𑌂', '𑌃'), + ('\u{1133e}', '𑌿'), + ('𑍁', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('\u{11357}', '\u{11357}'), + ('𑍢', '𑍣'), + ('𑐵', '𑐷'), + ('𑑀', '𑑁'), + ('𑑅', '𑑅'), + ('\u{114b0}', '𑒲'), + ('𑒹', '𑒹'), + ('𑒻', '𑒾'), + ('𑓁', '𑓁'), + ('\u{115af}', '𑖱'), + ('𑖸', '𑖻'), + ('𑖾', '𑖾'), + ('𑘰', '𑘲'), + ('𑘻', '𑘼'), + ('𑘾', '𑘾'), + ('𑚬', '𑚬'), + ('𑚮', '𑚯'), + ('𑚶', '𑚶'), + ('𑜠', '𑜡'), + ('𑜦', '𑜦'), + ('𑠬', '𑠮'), + ('𑠸', '𑠸'), + ('\u{119d1}', '\u{119d3}'), + ('\u{119dc}', '\u{119df}'), + ('\u{119e4}', '\u{119e4}'), + ('𑨹', '𑨹'), + ('𑩗', '𑩘'), + ('𑪗', '𑪗'), + ('𑰯', '𑰯'), + ('𑰾', '𑰾'), + ('𑲩', '𑲩'), + ('𑲱', '𑲱'), + ('𑲴', '𑲴'), + ('𑶊', '𑶎'), + ('𑶓', '𑶔'), + ('𑶖', '𑶖'), + ('𑻵', '𑻶'), + ('𖽑', '\u{16f87}'), + ('\u{1d165}', '𝅦'), + ('𝅭', '\u{1d172}'), +]; + +pub const SYMBOL: &'static [(char, char)] = &[ + ('$', '$'), + ('+', '+'), + ('<', '>'), + ('^', '^'), + ('`', '`'), + ('|', '|'), + ('~', '~'), + ('¢', '¦'), + ('¨', '©'), + ('¬', '¬'), + ('®', '±'), + ('´', '´'), + ('¸', '¸'), + ('×', '×'), + ('÷', '÷'), + ('˂', '˅'), + ('˒', '˟'), + ('˥', '˫'), + ('˭', '˭'), + ('˯', '˿'), + ('͵', '͵'), + ('΄', '΅'), + ('϶', '϶'), + ('҂', '҂'), + ('֍', '֏'), + ('؆', '؈'), + ('؋', '؋'), + ('؎', '؏'), + ('۞', '۞'), + ('۩', '۩'), + ('۽', '۾'), + ('߶', '߶'), + ('߾', '߿'), + ('৲', '৳'), + ('৺', '৻'), + ('૱', '૱'), + ('୰', '୰'), + ('௳', '௺'), + ('౿', '౿'), + ('൏', '൏'), + ('൹', '൹'), + ('฿', '฿'), + ('༁', '༃'), + ('༓', '༓'), + ('༕', '༗'), + ('༚', '༟'), + ('༴', '༴'), + ('༶', '༶'), + ('༸', '༸'), + ('྾', '࿅'), + ('࿇', '࿌'), + ('࿎', '࿏'), + ('࿕', '࿘'), + ('႞', '႟'), + ('᎐', '᎙'), + ('᙭', '᙭'), + ('៛', '៛'), + ('᥀', '᥀'), + ('᧞', '᧿'), + ('᭡', '᭪'), + ('᭴', '᭼'), + ('᾽', '᾽'), + ('᾿', '῁'), + ('῍', '῏'), + ('῝', '῟'), + ('῭', '`'), + ('´', '῾'), + ('⁄', '⁄'), + ('⁒', '⁒'), + ('⁺', '⁼'), + ('₊', '₌'), + ('₠', '₿'), + ('℀', '℁'), + ('℃', '℆'), + ('℈', '℉'), + ('℔', '℔'), + ('№', '℘'), + ('℞', '℣'), + ('℥', '℥'), + ('℧', '℧'), + ('℩', '℩'), + ('℮', '℮'), + ('℺', '℻'), + ('⅀', '⅄'), + ('⅊', '⅍'), + ('⅏', '⅏'), + ('↊', '↋'), + ('←', '⌇'), + ('⌌', '⌨'), + ('⌫', '␦'), + ('⑀', '⑊'), + ('⒜', 'ⓩ'), + ('─', '❧'), + ('➔', '⟄'), + ('⟇', '⟥'), + ('⟰', '⦂'), + ('⦙', '⧗'), + ('⧜', '⧻'), + ('⧾', '⭳'), + ('⭶', '⮕'), + ('⮘', '\u{2bff}'), + ('⳥', '⳪'), + ('⺀', '⺙'), + ('⺛', '⻳'), + ('⼀', '⿕'), + ('⿰', '⿻'), + ('〄', '〄'), + ('〒', '〓'), + ('〠', '〠'), + ('〶', '〷'), + ('〾', '〿'), + ('゛', '゜'), + ('㆐', '㆑'), + ('㆖', '㆟'), + ('㇀', '㇣'), + ('㈀', '㈞'), + ('㈪', '㉇'), + ('㉐', '㉐'), + ('㉠', '㉿'), + ('㊊', '㊰'), + ('㋀', '㏿'), + ('䷀', '䷿'), + ('꒐', '꓆'), + ('꜀', '꜖'), + ('꜠', '꜡'), + ('꞉', '꞊'), + ('꠨', '꠫'), + ('꠶', '꠹'), + ('꩷', '꩹'), + ('꭛', '꭛'), + ('﬩', '﬩'), + ('﮲', '﯁'), + ('﷼', '﷽'), + ('﹢', '﹢'), + ('﹤', '﹦'), + ('﹩', '﹩'), + ('$', '$'), + ('+', '+'), + ('<', '>'), + ('^', '^'), + ('`', '`'), + ('|', '|'), + ('~', '~'), + ('¢', '₩'), + ('│', '○'), + ('', '�'), + ('𐄷', '𐄿'), + ('𐅹', '𐆉'), + ('𐆌', '𐆎'), + ('𐆐', '𐆛'), + ('𐆠', '𐆠'), + ('𐇐', '𐇼'), + ('𐡷', '𐡸'), + ('𐫈', '𐫈'), + ('𑜿', '𑜿'), + ('\u{11fd5}', '\u{11ff1}'), + ('𖬼', '𖬿'), + ('𖭅', '𖭅'), + ('𛲜', '𛲜'), + ('𝀀', '𝃵'), + ('𝄀', '𝄦'), + ('𝄩', '𝅘𝅥𝅲'), + ('𝅪', '𝅬'), + ('𝆃', '𝆄'), + ('𝆌', '𝆩'), + ('𝆮', '𝇨'), + ('𝈀', '𝉁'), + ('𝉅', '𝉅'), + ('𝌀', '𝍖'), + ('𝛁', '𝛁'), + ('𝛛', '𝛛'), + ('𝛻', '𝛻'), + ('𝜕', '𝜕'), + ('𝜵', '𝜵'), + ('𝝏', '𝝏'), + ('𝝯', '𝝯'), + ('𝞉', '𝞉'), + ('𝞩', '𝞩'), + ('𝟃', '𝟃'), + ('𝠀', '𝧿'), + ('𝨷', '𝨺'), + ('𝩭', '𝩴'), + ('𝩶', '𝪃'), + ('𝪅', '𝪆'), + ('\u{1e14f}', '\u{1e14f}'), + ('\u{1e2ff}', '\u{1e2ff}'), + ('𞲬', '𞲬'), + ('𞲰', '𞲰'), + ('\u{1ed2e}', '\u{1ed2e}'), + ('𞻰', '𞻱'), + ('🀀', '🀫'), + ('🀰', '🂓'), + ('🂠', '🂮'), + ('🂱', '🂿'), + ('🃁', '🃏'), + ('🃑', '🃵'), + ('🄐', '\u{1f16c}'), + ('🅰', '🆬'), + ('🇦', '🈂'), + ('🈐', '🈻'), + ('🉀', '🉈'), + ('🉐', '🉑'), + ('🉠', '🉥'), + ('🌀', '\u{1f6d5}'), + ('🛠', '🛬'), + ('🛰', '\u{1f6fa}'), + ('🜀', '🝳'), + ('🞀', '🟘'), + ('\u{1f7e0}', '\u{1f7eb}'), + ('🠀', '🠋'), + ('🠐', '🡇'), + ('🡐', '🡙'), + ('🡠', '🢇'), + ('🢐', '🢭'), + ('🤀', '🤋'), + ('\u{1f90d}', '\u{1f971}'), + ('🥳', '🥶'), + ('🥺', '🦢'), + ('\u{1f9a5}', '\u{1f9aa}'), + ('\u{1f9ae}', '\u{1f9ca}'), + ('\u{1f9cd}', '\u{1fa53}'), + ('🩠', '🩭'), + ('\u{1fa70}', '\u{1fa73}'), + ('\u{1fa78}', '\u{1fa7a}'), + ('\u{1fa80}', '\u{1fa82}'), + ('\u{1fa90}', '\u{1fa95}'), +]; + +pub const TITLECASE_LETTER: &'static [(char, char)] = &[ + ('Dž', 'Dž'), + ('Lj', 'Lj'), + ('Nj', 'Nj'), + ('Dz', 'Dz'), + ('ᾈ', 'ᾏ'), + ('ᾘ', 'ᾟ'), + ('ᾨ', 'ᾯ'), + ('ᾼ', 'ᾼ'), + ('ῌ', 'ῌ'), + ('ῼ', 'ῼ'), +]; + +pub const UNASSIGNED: &'static [(char, char)] = &[ + ('\u{378}', '\u{379}'), + ('\u{380}', '\u{383}'), + ('\u{38b}', '\u{38b}'), + ('\u{38d}', '\u{38d}'), + ('\u{3a2}', '\u{3a2}'), + ('\u{530}', '\u{530}'), + ('\u{557}', '\u{558}'), + ('\u{58b}', '\u{58c}'), + ('\u{590}', '\u{590}'), + ('\u{5c8}', '\u{5cf}'), + ('\u{5eb}', '\u{5ee}'), + ('\u{5f5}', '\u{5ff}'), + ('\u{61d}', '\u{61d}'), + ('\u{70e}', '\u{70e}'), + ('\u{74b}', '\u{74c}'), + ('\u{7b2}', '\u{7bf}'), + ('\u{7fb}', '\u{7fc}'), + ('\u{82e}', '\u{82f}'), + ('\u{83f}', '\u{83f}'), + ('\u{85c}', '\u{85d}'), + ('\u{85f}', '\u{85f}'), + ('\u{86b}', '\u{89f}'), + ('\u{8b5}', '\u{8b5}'), + ('\u{8be}', '\u{8d2}'), + ('\u{984}', '\u{984}'), + ('\u{98d}', '\u{98e}'), + ('\u{991}', '\u{992}'), + ('\u{9a9}', '\u{9a9}'), + ('\u{9b1}', '\u{9b1}'), + ('\u{9b3}', '\u{9b5}'), + ('\u{9ba}', '\u{9bb}'), + ('\u{9c5}', '\u{9c6}'), + ('\u{9c9}', '\u{9ca}'), + ('\u{9cf}', '\u{9d6}'), + ('\u{9d8}', '\u{9db}'), + ('\u{9de}', '\u{9de}'), + ('\u{9e4}', '\u{9e5}'), + ('\u{9ff}', '\u{a00}'), + ('\u{a04}', '\u{a04}'), + ('\u{a0b}', '\u{a0e}'), + ('\u{a11}', '\u{a12}'), + ('\u{a29}', '\u{a29}'), + ('\u{a31}', '\u{a31}'), + ('\u{a34}', '\u{a34}'), + ('\u{a37}', '\u{a37}'), + ('\u{a3a}', '\u{a3b}'), + ('\u{a3d}', '\u{a3d}'), + ('\u{a43}', '\u{a46}'), + ('\u{a49}', '\u{a4a}'), + ('\u{a4e}', '\u{a50}'), + ('\u{a52}', '\u{a58}'), + ('\u{a5d}', '\u{a5d}'), + ('\u{a5f}', '\u{a65}'), + ('\u{a77}', '\u{a80}'), + ('\u{a84}', '\u{a84}'), + ('\u{a8e}', '\u{a8e}'), + ('\u{a92}', '\u{a92}'), + ('\u{aa9}', '\u{aa9}'), + ('\u{ab1}', '\u{ab1}'), + ('\u{ab4}', '\u{ab4}'), + ('\u{aba}', '\u{abb}'), + ('\u{ac6}', '\u{ac6}'), + ('\u{aca}', '\u{aca}'), + ('\u{ace}', '\u{acf}'), + ('\u{ad1}', '\u{adf}'), + ('\u{ae4}', '\u{ae5}'), + ('\u{af2}', '\u{af8}'), + ('\u{b00}', '\u{b00}'), + ('\u{b04}', '\u{b04}'), + ('\u{b0d}', '\u{b0e}'), + ('\u{b11}', '\u{b12}'), + ('\u{b29}', '\u{b29}'), + ('\u{b31}', '\u{b31}'), + ('\u{b34}', '\u{b34}'), + ('\u{b3a}', '\u{b3b}'), + ('\u{b45}', '\u{b46}'), + ('\u{b49}', '\u{b4a}'), + ('\u{b4e}', '\u{b55}'), + ('\u{b58}', '\u{b5b}'), + ('\u{b5e}', '\u{b5e}'), + ('\u{b64}', '\u{b65}'), + ('\u{b78}', '\u{b81}'), + ('\u{b84}', '\u{b84}'), + ('\u{b8b}', '\u{b8d}'), + ('\u{b91}', '\u{b91}'), + ('\u{b96}', '\u{b98}'), + ('\u{b9b}', '\u{b9b}'), + ('\u{b9d}', '\u{b9d}'), + ('\u{ba0}', '\u{ba2}'), + ('\u{ba5}', '\u{ba7}'), + ('\u{bab}', '\u{bad}'), + ('\u{bba}', '\u{bbd}'), + ('\u{bc3}', '\u{bc5}'), + ('\u{bc9}', '\u{bc9}'), + ('\u{bce}', '\u{bcf}'), + ('\u{bd1}', '\u{bd6}'), + ('\u{bd8}', '\u{be5}'), + ('\u{bfb}', '\u{bff}'), + ('\u{c0d}', '\u{c0d}'), + ('\u{c11}', '\u{c11}'), + ('\u{c29}', '\u{c29}'), + ('\u{c3a}', '\u{c3c}'), + ('\u{c45}', '\u{c45}'), + ('\u{c49}', '\u{c49}'), + ('\u{c4e}', '\u{c54}'), + ('\u{c57}', '\u{c57}'), + ('\u{c5b}', '\u{c5f}'), + ('\u{c64}', '\u{c65}'), + ('\u{c70}', '\u{c76}'), + ('\u{c8d}', '\u{c8d}'), + ('\u{c91}', '\u{c91}'), + ('\u{ca9}', '\u{ca9}'), + ('\u{cb4}', '\u{cb4}'), + ('\u{cba}', '\u{cbb}'), + ('\u{cc5}', '\u{cc5}'), + ('\u{cc9}', '\u{cc9}'), + ('\u{cce}', '\u{cd4}'), + ('\u{cd7}', '\u{cdd}'), + ('\u{cdf}', '\u{cdf}'), + ('\u{ce4}', '\u{ce5}'), + ('\u{cf0}', '\u{cf0}'), + ('\u{cf3}', '\u{cff}'), + ('\u{d04}', '\u{d04}'), + ('\u{d0d}', '\u{d0d}'), + ('\u{d11}', '\u{d11}'), + ('\u{d45}', '\u{d45}'), + ('\u{d49}', '\u{d49}'), + ('\u{d50}', '\u{d53}'), + ('\u{d64}', '\u{d65}'), + ('\u{d80}', '\u{d81}'), + ('\u{d84}', '\u{d84}'), + ('\u{d97}', '\u{d99}'), + ('\u{db2}', '\u{db2}'), + ('\u{dbc}', '\u{dbc}'), + ('\u{dbe}', '\u{dbf}'), + ('\u{dc7}', '\u{dc9}'), + ('\u{dcb}', '\u{dce}'), + ('\u{dd5}', '\u{dd5}'), + ('\u{dd7}', '\u{dd7}'), + ('\u{de0}', '\u{de5}'), + ('\u{df0}', '\u{df1}'), + ('\u{df5}', '\u{e00}'), + ('\u{e3b}', '\u{e3e}'), + ('\u{e5c}', '\u{e80}'), + ('\u{e83}', '\u{e83}'), + ('\u{e85}', '\u{e85}'), + ('\u{e8b}', '\u{e8b}'), + ('\u{ea4}', '\u{ea4}'), + ('\u{ea6}', '\u{ea6}'), + ('\u{ebe}', '\u{ebf}'), + ('\u{ec5}', '\u{ec5}'), + ('\u{ec7}', '\u{ec7}'), + ('\u{ece}', '\u{ecf}'), + ('\u{eda}', '\u{edb}'), + ('\u{ee0}', '\u{eff}'), + ('\u{f48}', '\u{f48}'), + ('\u{f6d}', '\u{f70}'), + ('\u{f98}', '\u{f98}'), + ('\u{fbd}', '\u{fbd}'), + ('\u{fcd}', '\u{fcd}'), + ('\u{fdb}', '\u{fff}'), + ('\u{10c6}', '\u{10c6}'), + ('\u{10c8}', '\u{10cc}'), + ('\u{10ce}', '\u{10cf}'), + ('\u{1249}', '\u{1249}'), + ('\u{124e}', '\u{124f}'), + ('\u{1257}', '\u{1257}'), + ('\u{1259}', '\u{1259}'), + ('\u{125e}', '\u{125f}'), + ('\u{1289}', '\u{1289}'), + ('\u{128e}', '\u{128f}'), + ('\u{12b1}', '\u{12b1}'), + ('\u{12b6}', '\u{12b7}'), + ('\u{12bf}', '\u{12bf}'), + ('\u{12c1}', '\u{12c1}'), + ('\u{12c6}', '\u{12c7}'), + ('\u{12d7}', '\u{12d7}'), + ('\u{1311}', '\u{1311}'), + ('\u{1316}', '\u{1317}'), + ('\u{135b}', '\u{135c}'), + ('\u{137d}', '\u{137f}'), + ('\u{139a}', '\u{139f}'), + ('\u{13f6}', '\u{13f7}'), + ('\u{13fe}', '\u{13ff}'), + ('\u{169d}', '\u{169f}'), + ('\u{16f9}', '\u{16ff}'), + ('\u{170d}', '\u{170d}'), + ('\u{1715}', '\u{171f}'), + ('\u{1737}', '\u{173f}'), + ('\u{1754}', '\u{175f}'), + ('\u{176d}', '\u{176d}'), + ('\u{1771}', '\u{1771}'), + ('\u{1774}', '\u{177f}'), + ('\u{17de}', '\u{17df}'), + ('\u{17ea}', '\u{17ef}'), + ('\u{17fa}', '\u{17ff}'), + ('\u{180f}', '\u{180f}'), + ('\u{181a}', '\u{181f}'), + ('\u{1879}', '\u{187f}'), + ('\u{18ab}', '\u{18af}'), + ('\u{18f6}', '\u{18ff}'), + ('\u{191f}', '\u{191f}'), + ('\u{192c}', '\u{192f}'), + ('\u{193c}', '\u{193f}'), + ('\u{1941}', '\u{1943}'), + ('\u{196e}', '\u{196f}'), + ('\u{1975}', '\u{197f}'), + ('\u{19ac}', '\u{19af}'), + ('\u{19ca}', '\u{19cf}'), + ('\u{19db}', '\u{19dd}'), + ('\u{1a1c}', '\u{1a1d}'), + ('\u{1a5f}', '\u{1a5f}'), + ('\u{1a7d}', '\u{1a7e}'), + ('\u{1a8a}', '\u{1a8f}'), + ('\u{1a9a}', '\u{1a9f}'), + ('\u{1aae}', '\u{1aaf}'), + ('\u{1abf}', '\u{1aff}'), + ('\u{1b4c}', '\u{1b4f}'), + ('\u{1b7d}', '\u{1b7f}'), + ('\u{1bf4}', '\u{1bfb}'), + ('\u{1c38}', '\u{1c3a}'), + ('\u{1c4a}', '\u{1c4c}'), + ('\u{1c89}', '\u{1c8f}'), + ('\u{1cbb}', '\u{1cbc}'), + ('\u{1cc8}', '\u{1ccf}'), + ('\u{1cfb}', '\u{1cff}'), + ('\u{1dfa}', '\u{1dfa}'), + ('\u{1f16}', '\u{1f17}'), + ('\u{1f1e}', '\u{1f1f}'), + ('\u{1f46}', '\u{1f47}'), + ('\u{1f4e}', '\u{1f4f}'), + ('\u{1f58}', '\u{1f58}'), + ('\u{1f5a}', '\u{1f5a}'), + ('\u{1f5c}', '\u{1f5c}'), + ('\u{1f5e}', '\u{1f5e}'), + ('\u{1f7e}', '\u{1f7f}'), + ('\u{1fb5}', '\u{1fb5}'), + ('\u{1fc5}', '\u{1fc5}'), + ('\u{1fd4}', '\u{1fd5}'), + ('\u{1fdc}', '\u{1fdc}'), + ('\u{1ff0}', '\u{1ff1}'), + ('\u{1ff5}', '\u{1ff5}'), + ('\u{1fff}', '\u{1fff}'), + ('\u{2065}', '\u{2065}'), + ('\u{2072}', '\u{2073}'), + ('\u{208f}', '\u{208f}'), + ('\u{209d}', '\u{209f}'), + ('\u{20c0}', '\u{20cf}'), + ('\u{20f1}', '\u{20ff}'), + ('\u{218c}', '\u{218f}'), + ('\u{2427}', '\u{243f}'), + ('\u{244b}', '\u{245f}'), + ('\u{2b74}', '\u{2b75}'), + ('\u{2b96}', '\u{2b97}'), + ('\u{2c2f}', '\u{2c2f}'), + ('\u{2c5f}', '\u{2c5f}'), + ('\u{2cf4}', '\u{2cf8}'), + ('\u{2d26}', '\u{2d26}'), + ('\u{2d28}', '\u{2d2c}'), + ('\u{2d2e}', '\u{2d2f}'), + ('\u{2d68}', '\u{2d6e}'), + ('\u{2d71}', '\u{2d7e}'), + ('\u{2d97}', '\u{2d9f}'), + ('\u{2da7}', '\u{2da7}'), + ('\u{2daf}', '\u{2daf}'), + ('\u{2db7}', '\u{2db7}'), + ('\u{2dbf}', '\u{2dbf}'), + ('\u{2dc7}', '\u{2dc7}'), + ('\u{2dcf}', '\u{2dcf}'), + ('\u{2dd7}', '\u{2dd7}'), + ('\u{2ddf}', '\u{2ddf}'), + ('\u{2e50}', '\u{2e7f}'), + ('\u{2e9a}', '\u{2e9a}'), + ('\u{2ef4}', '\u{2eff}'), + ('\u{2fd6}', '\u{2fef}'), + ('\u{2ffc}', '\u{2fff}'), + ('\u{3040}', '\u{3040}'), + ('\u{3097}', '\u{3098}'), + ('\u{3100}', '\u{3104}'), + ('\u{3130}', '\u{3130}'), + ('\u{318f}', '\u{318f}'), + ('\u{31bb}', '\u{31bf}'), + ('\u{31e4}', '\u{31ef}'), + ('\u{321f}', '\u{321f}'), + ('\u{4db6}', '\u{4dbf}'), + ('\u{9ff0}', '\u{9fff}'), + ('\u{a48d}', '\u{a48f}'), + ('\u{a4c7}', '\u{a4cf}'), + ('\u{a62c}', '\u{a63f}'), + ('\u{a6f8}', '\u{a6ff}'), + ('\u{a7c0}', '\u{a7c1}'), + ('\u{a7c7}', '\u{a7f6}'), + ('\u{a82c}', '\u{a82f}'), + ('\u{a83a}', '\u{a83f}'), + ('\u{a878}', '\u{a87f}'), + ('\u{a8c6}', '\u{a8cd}'), + ('\u{a8da}', '\u{a8df}'), + ('\u{a954}', '\u{a95e}'), + ('\u{a97d}', '\u{a97f}'), + ('\u{a9ce}', '\u{a9ce}'), + ('\u{a9da}', '\u{a9dd}'), + ('\u{a9ff}', '\u{a9ff}'), + ('\u{aa37}', '\u{aa3f}'), + ('\u{aa4e}', '\u{aa4f}'), + ('\u{aa5a}', '\u{aa5b}'), + ('\u{aac3}', '\u{aada}'), + ('\u{aaf7}', '\u{ab00}'), + ('\u{ab07}', '\u{ab08}'), + ('\u{ab0f}', '\u{ab10}'), + ('\u{ab17}', '\u{ab1f}'), + ('\u{ab27}', '\u{ab27}'), + ('\u{ab2f}', '\u{ab2f}'), + ('\u{ab68}', '\u{ab6f}'), + ('\u{abee}', '\u{abef}'), + ('\u{abfa}', '\u{abff}'), + ('\u{d7a4}', '\u{d7af}'), + ('\u{d7c7}', '\u{d7ca}'), + ('\u{d7fc}', '\u{d7ff}'), + ('\u{fa6e}', '\u{fa6f}'), + ('\u{fada}', '\u{faff}'), + ('\u{fb07}', '\u{fb12}'), + ('\u{fb18}', '\u{fb1c}'), + ('\u{fb37}', '\u{fb37}'), + ('\u{fb3d}', '\u{fb3d}'), + ('\u{fb3f}', '\u{fb3f}'), + ('\u{fb42}', '\u{fb42}'), + ('\u{fb45}', '\u{fb45}'), + ('\u{fbc2}', '\u{fbd2}'), + ('\u{fd40}', '\u{fd4f}'), + ('\u{fd90}', '\u{fd91}'), + ('\u{fdc8}', '\u{fdef}'), + ('\u{fdfe}', '\u{fdff}'), + ('\u{fe1a}', '\u{fe1f}'), + ('\u{fe53}', '\u{fe53}'), + ('\u{fe67}', '\u{fe67}'), + ('\u{fe6c}', '\u{fe6f}'), + ('\u{fe75}', '\u{fe75}'), + ('\u{fefd}', '\u{fefe}'), + ('\u{ff00}', '\u{ff00}'), + ('\u{ffbf}', '\u{ffc1}'), + ('\u{ffc8}', '\u{ffc9}'), + ('\u{ffd0}', '\u{ffd1}'), + ('\u{ffd8}', '\u{ffd9}'), + ('\u{ffdd}', '\u{ffdf}'), + ('\u{ffe7}', '\u{ffe7}'), + ('\u{ffef}', '\u{fff8}'), + ('\u{fffe}', '\u{ffff}'), + ('\u{1000c}', '\u{1000c}'), + ('\u{10027}', '\u{10027}'), + ('\u{1003b}', '\u{1003b}'), + ('\u{1003e}', '\u{1003e}'), + ('\u{1004e}', '\u{1004f}'), + ('\u{1005e}', '\u{1007f}'), + ('\u{100fb}', '\u{100ff}'), + ('\u{10103}', '\u{10106}'), + ('\u{10134}', '\u{10136}'), + ('\u{1018f}', '\u{1018f}'), + ('\u{1019c}', '\u{1019f}'), + ('\u{101a1}', '\u{101cf}'), + ('\u{101fe}', '\u{1027f}'), + ('\u{1029d}', '\u{1029f}'), + ('\u{102d1}', '\u{102df}'), + ('\u{102fc}', '\u{102ff}'), + ('\u{10324}', '\u{1032c}'), + ('\u{1034b}', '\u{1034f}'), + ('\u{1037b}', '\u{1037f}'), + ('\u{1039e}', '\u{1039e}'), + ('\u{103c4}', '\u{103c7}'), + ('\u{103d6}', '\u{103ff}'), + ('\u{1049e}', '\u{1049f}'), + ('\u{104aa}', '\u{104af}'), + ('\u{104d4}', '\u{104d7}'), + ('\u{104fc}', '\u{104ff}'), + ('\u{10528}', '\u{1052f}'), + ('\u{10564}', '\u{1056e}'), + ('\u{10570}', '\u{105ff}'), + ('\u{10737}', '\u{1073f}'), + ('\u{10756}', '\u{1075f}'), + ('\u{10768}', '\u{107ff}'), + ('\u{10806}', '\u{10807}'), + ('\u{10809}', '\u{10809}'), + ('\u{10836}', '\u{10836}'), + ('\u{10839}', '\u{1083b}'), + ('\u{1083d}', '\u{1083e}'), + ('\u{10856}', '\u{10856}'), + ('\u{1089f}', '\u{108a6}'), + ('\u{108b0}', '\u{108df}'), + ('\u{108f3}', '\u{108f3}'), + ('\u{108f6}', '\u{108fa}'), + ('\u{1091c}', '\u{1091e}'), + ('\u{1093a}', '\u{1093e}'), + ('\u{10940}', '\u{1097f}'), + ('\u{109b8}', '\u{109bb}'), + ('\u{109d0}', '\u{109d1}'), + ('\u{10a04}', '\u{10a04}'), + ('\u{10a07}', '\u{10a0b}'), + ('\u{10a14}', '\u{10a14}'), + ('\u{10a18}', '\u{10a18}'), + ('\u{10a36}', '\u{10a37}'), + ('\u{10a3b}', '\u{10a3e}'), + ('\u{10a49}', '\u{10a4f}'), + ('\u{10a59}', '\u{10a5f}'), + ('\u{10aa0}', '\u{10abf}'), + ('\u{10ae7}', '\u{10aea}'), + ('\u{10af7}', '\u{10aff}'), + ('\u{10b36}', '\u{10b38}'), + ('\u{10b56}', '\u{10b57}'), + ('\u{10b73}', '\u{10b77}'), + ('\u{10b92}', '\u{10b98}'), + ('\u{10b9d}', '\u{10ba8}'), + ('\u{10bb0}', '\u{10bff}'), + ('\u{10c49}', '\u{10c7f}'), + ('\u{10cb3}', '\u{10cbf}'), + ('\u{10cf3}', '\u{10cf9}'), + ('\u{10d28}', '\u{10d2f}'), + ('\u{10d3a}', '\u{10e5f}'), + ('\u{10e7f}', '\u{10eff}'), + ('\u{10f28}', '\u{10f2f}'), + ('\u{10f5a}', '\u{10fdf}'), + ('\u{10ff7}', '\u{10fff}'), + ('\u{1104e}', '\u{11051}'), + ('\u{11070}', '\u{1107e}'), + ('\u{110c2}', '\u{110cc}'), + ('\u{110ce}', '\u{110cf}'), + ('\u{110e9}', '\u{110ef}'), + ('\u{110fa}', '\u{110ff}'), + ('\u{11135}', '\u{11135}'), + ('\u{11147}', '\u{1114f}'), + ('\u{11177}', '\u{1117f}'), + ('\u{111ce}', '\u{111cf}'), + ('\u{111e0}', '\u{111e0}'), + ('\u{111f5}', '\u{111ff}'), + ('\u{11212}', '\u{11212}'), + ('\u{1123f}', '\u{1127f}'), + ('\u{11287}', '\u{11287}'), + ('\u{11289}', '\u{11289}'), + ('\u{1128e}', '\u{1128e}'), + ('\u{1129e}', '\u{1129e}'), + ('\u{112aa}', '\u{112af}'), + ('\u{112eb}', '\u{112ef}'), + ('\u{112fa}', '\u{112ff}'), + ('\u{11304}', '\u{11304}'), + ('\u{1130d}', '\u{1130e}'), + ('\u{11311}', '\u{11312}'), + ('\u{11329}', '\u{11329}'), + ('\u{11331}', '\u{11331}'), + ('\u{11334}', '\u{11334}'), + ('\u{1133a}', '\u{1133a}'), + ('\u{11345}', '\u{11346}'), + ('\u{11349}', '\u{1134a}'), + ('\u{1134e}', '\u{1134f}'), + ('\u{11351}', '\u{11356}'), + ('\u{11358}', '\u{1135c}'), + ('\u{11364}', '\u{11365}'), + ('\u{1136d}', '\u{1136f}'), + ('\u{11375}', '\u{113ff}'), + ('\u{1145a}', '\u{1145a}'), + ('\u{1145c}', '\u{1145c}'), + ('\u{11460}', '\u{1147f}'), + ('\u{114c8}', '\u{114cf}'), + ('\u{114da}', '\u{1157f}'), + ('\u{115b6}', '\u{115b7}'), + ('\u{115de}', '\u{115ff}'), + ('\u{11645}', '\u{1164f}'), + ('\u{1165a}', '\u{1165f}'), + ('\u{1166d}', '\u{1167f}'), + ('\u{116b9}', '\u{116bf}'), + ('\u{116ca}', '\u{116ff}'), + ('\u{1171b}', '\u{1171c}'), + ('\u{1172c}', '\u{1172f}'), + ('\u{11740}', '\u{117ff}'), + ('\u{1183c}', '\u{1189f}'), + ('\u{118f3}', '\u{118fe}'), + ('\u{11900}', '\u{1199f}'), + ('\u{119a8}', '\u{119a9}'), + ('\u{119d8}', '\u{119d9}'), + ('\u{119e5}', '\u{119ff}'), + ('\u{11a48}', '\u{11a4f}'), + ('\u{11aa3}', '\u{11abf}'), + ('\u{11af9}', '\u{11bff}'), + ('\u{11c09}', '\u{11c09}'), + ('\u{11c37}', '\u{11c37}'), + ('\u{11c46}', '\u{11c4f}'), + ('\u{11c6d}', '\u{11c6f}'), + ('\u{11c90}', '\u{11c91}'), + ('\u{11ca8}', '\u{11ca8}'), + ('\u{11cb7}', '\u{11cff}'), + ('\u{11d07}', '\u{11d07}'), + ('\u{11d0a}', '\u{11d0a}'), + ('\u{11d37}', '\u{11d39}'), + ('\u{11d3b}', '\u{11d3b}'), + ('\u{11d3e}', '\u{11d3e}'), + ('\u{11d48}', '\u{11d4f}'), + ('\u{11d5a}', '\u{11d5f}'), + ('\u{11d66}', '\u{11d66}'), + ('\u{11d69}', '\u{11d69}'), + ('\u{11d8f}', '\u{11d8f}'), + ('\u{11d92}', '\u{11d92}'), + ('\u{11d99}', '\u{11d9f}'), + ('\u{11daa}', '\u{11edf}'), + ('\u{11ef9}', '\u{11fbf}'), + ('\u{11ff2}', '\u{11ffe}'), + ('\u{1239a}', '\u{123ff}'), + ('\u{1246f}', '\u{1246f}'), + ('\u{12475}', '\u{1247f}'), + ('\u{12544}', '\u{12fff}'), + ('\u{1342f}', '\u{1342f}'), + ('\u{13439}', '\u{143ff}'), + ('\u{14647}', '\u{167ff}'), + ('\u{16a39}', '\u{16a3f}'), + ('\u{16a5f}', '\u{16a5f}'), + ('\u{16a6a}', '\u{16a6d}'), + ('\u{16a70}', '\u{16acf}'), + ('\u{16aee}', '\u{16aef}'), + ('\u{16af6}', '\u{16aff}'), + ('\u{16b46}', '\u{16b4f}'), + ('\u{16b5a}', '\u{16b5a}'), + ('\u{16b62}', '\u{16b62}'), + ('\u{16b78}', '\u{16b7c}'), + ('\u{16b90}', '\u{16e3f}'), + ('\u{16e9b}', '\u{16eff}'), + ('\u{16f4b}', '\u{16f4e}'), + ('\u{16f88}', '\u{16f8e}'), + ('\u{16fa0}', '\u{16fdf}'), + ('\u{16fe4}', '\u{16fff}'), + ('\u{187f8}', '\u{187ff}'), + ('\u{18af3}', '\u{1afff}'), + ('\u{1b11f}', '\u{1b14f}'), + ('\u{1b153}', '\u{1b163}'), + ('\u{1b168}', '\u{1b16f}'), + ('\u{1b2fc}', '\u{1bbff}'), + ('\u{1bc6b}', '\u{1bc6f}'), + ('\u{1bc7d}', '\u{1bc7f}'), + ('\u{1bc89}', '\u{1bc8f}'), + ('\u{1bc9a}', '\u{1bc9b}'), + ('\u{1bca4}', '\u{1cfff}'), + ('\u{1d0f6}', '\u{1d0ff}'), + ('\u{1d127}', '\u{1d128}'), + ('\u{1d1e9}', '\u{1d1ff}'), + ('\u{1d246}', '\u{1d2df}'), + ('\u{1d2f4}', '\u{1d2ff}'), + ('\u{1d357}', '\u{1d35f}'), + ('\u{1d379}', '\u{1d3ff}'), + ('\u{1d455}', '\u{1d455}'), + ('\u{1d49d}', '\u{1d49d}'), + ('\u{1d4a0}', '\u{1d4a1}'), + ('\u{1d4a3}', '\u{1d4a4}'), + ('\u{1d4a7}', '\u{1d4a8}'), + ('\u{1d4ad}', '\u{1d4ad}'), + ('\u{1d4ba}', '\u{1d4ba}'), + ('\u{1d4bc}', '\u{1d4bc}'), + ('\u{1d4c4}', '\u{1d4c4}'), + ('\u{1d506}', '\u{1d506}'), + ('\u{1d50b}', '\u{1d50c}'), + ('\u{1d515}', '\u{1d515}'), + ('\u{1d51d}', '\u{1d51d}'), + ('\u{1d53a}', '\u{1d53a}'), + ('\u{1d53f}', '\u{1d53f}'), + ('\u{1d545}', '\u{1d545}'), + ('\u{1d547}', '\u{1d549}'), + ('\u{1d551}', '\u{1d551}'), + ('\u{1d6a6}', '\u{1d6a7}'), + ('\u{1d7cc}', '\u{1d7cd}'), + ('\u{1da8c}', '\u{1da9a}'), + ('\u{1daa0}', '\u{1daa0}'), + ('\u{1dab0}', '\u{1dfff}'), + ('\u{1e007}', '\u{1e007}'), + ('\u{1e019}', '\u{1e01a}'), + ('\u{1e022}', '\u{1e022}'), + ('\u{1e025}', '\u{1e025}'), + ('\u{1e02b}', '\u{1e0ff}'), + ('\u{1e12d}', '\u{1e12f}'), + ('\u{1e13e}', '\u{1e13f}'), + ('\u{1e14a}', '\u{1e14d}'), + ('\u{1e150}', '\u{1e2bf}'), + ('\u{1e2fa}', '\u{1e2fe}'), + ('\u{1e300}', '\u{1e7ff}'), + ('\u{1e8c5}', '\u{1e8c6}'), + ('\u{1e8d7}', '\u{1e8ff}'), + ('\u{1e94c}', '\u{1e94f}'), + ('\u{1e95a}', '\u{1e95d}'), + ('\u{1e960}', '\u{1ec70}'), + ('\u{1ecb5}', '\u{1ed00}'), + ('\u{1ed3e}', '\u{1edff}'), + ('\u{1ee04}', '\u{1ee04}'), + ('\u{1ee20}', '\u{1ee20}'), + ('\u{1ee23}', '\u{1ee23}'), + ('\u{1ee25}', '\u{1ee26}'), + ('\u{1ee28}', '\u{1ee28}'), + ('\u{1ee33}', '\u{1ee33}'), + ('\u{1ee38}', '\u{1ee38}'), + ('\u{1ee3a}', '\u{1ee3a}'), + ('\u{1ee3c}', '\u{1ee41}'), + ('\u{1ee43}', '\u{1ee46}'), + ('\u{1ee48}', '\u{1ee48}'), + ('\u{1ee4a}', '\u{1ee4a}'), + ('\u{1ee4c}', '\u{1ee4c}'), + ('\u{1ee50}', '\u{1ee50}'), + ('\u{1ee53}', '\u{1ee53}'), + ('\u{1ee55}', '\u{1ee56}'), + ('\u{1ee58}', '\u{1ee58}'), + ('\u{1ee5a}', '\u{1ee5a}'), + ('\u{1ee5c}', '\u{1ee5c}'), + ('\u{1ee5e}', '\u{1ee5e}'), + ('\u{1ee60}', '\u{1ee60}'), + ('\u{1ee63}', '\u{1ee63}'), + ('\u{1ee65}', '\u{1ee66}'), + ('\u{1ee6b}', '\u{1ee6b}'), + ('\u{1ee73}', '\u{1ee73}'), + ('\u{1ee78}', '\u{1ee78}'), + ('\u{1ee7d}', '\u{1ee7d}'), + ('\u{1ee7f}', '\u{1ee7f}'), + ('\u{1ee8a}', '\u{1ee8a}'), + ('\u{1ee9c}', '\u{1eea0}'), + ('\u{1eea4}', '\u{1eea4}'), + ('\u{1eeaa}', '\u{1eeaa}'), + ('\u{1eebc}', '\u{1eeef}'), + ('\u{1eef2}', '\u{1efff}'), + ('\u{1f02c}', '\u{1f02f}'), + ('\u{1f094}', '\u{1f09f}'), + ('\u{1f0af}', '\u{1f0b0}'), + ('\u{1f0c0}', '\u{1f0c0}'), + ('\u{1f0d0}', '\u{1f0d0}'), + ('\u{1f0f6}', '\u{1f0ff}'), + ('\u{1f10d}', '\u{1f10f}'), + ('\u{1f16d}', '\u{1f16f}'), + ('\u{1f1ad}', '\u{1f1e5}'), + ('\u{1f203}', '\u{1f20f}'), + ('\u{1f23c}', '\u{1f23f}'), + ('\u{1f249}', '\u{1f24f}'), + ('\u{1f252}', '\u{1f25f}'), + ('\u{1f266}', '\u{1f2ff}'), + ('\u{1f6d6}', '\u{1f6df}'), + ('\u{1f6ed}', '\u{1f6ef}'), + ('\u{1f6fb}', '\u{1f6ff}'), + ('\u{1f774}', '\u{1f77f}'), + ('\u{1f7d9}', '\u{1f7df}'), + ('\u{1f7ec}', '\u{1f7ff}'), + ('\u{1f80c}', '\u{1f80f}'), + ('\u{1f848}', '\u{1f84f}'), + ('\u{1f85a}', '\u{1f85f}'), + ('\u{1f888}', '\u{1f88f}'), + ('\u{1f8ae}', '\u{1f8ff}'), + ('\u{1f90c}', '\u{1f90c}'), + ('\u{1f972}', '\u{1f972}'), + ('\u{1f977}', '\u{1f979}'), + ('\u{1f9a3}', '\u{1f9a4}'), + ('\u{1f9ab}', '\u{1f9ad}'), + ('\u{1f9cb}', '\u{1f9cc}'), + ('\u{1fa54}', '\u{1fa5f}'), + ('\u{1fa6e}', '\u{1fa6f}'), + ('\u{1fa74}', '\u{1fa77}'), + ('\u{1fa7b}', '\u{1fa7f}'), + ('\u{1fa83}', '\u{1fa8f}'), + ('\u{1fa96}', '\u{1ffff}'), + ('\u{2a6d7}', '\u{2a6ff}'), + ('\u{2b735}', '\u{2b73f}'), + ('\u{2b81e}', '\u{2b81f}'), + ('\u{2cea2}', '\u{2ceaf}'), + ('\u{2ebe1}', '\u{2f7ff}'), + ('\u{2fa1e}', '\u{e0000}'), + ('\u{e0002}', '\u{e001f}'), + ('\u{e0080}', '\u{e00ff}'), + ('\u{e01f0}', '\u{effff}'), + ('\u{ffffe}', '\u{fffff}'), + ('\u{10fffe}', '\u{10ffff}'), +]; + +pub const UPPERCASE_LETTER: &'static [(char, char)] = &[ + ('A', 'Z'), + ('À', 'Ö'), + ('Ø', 'Þ'), + ('Ā', 'Ā'), + ('Ă', 'Ă'), + ('Ą', 'Ą'), + ('Ć', 'Ć'), + ('Ĉ', 'Ĉ'), + ('Ċ', 'Ċ'), + ('Č', 'Č'), + ('Ď', 'Ď'), + ('Đ', 'Đ'), + ('Ē', 'Ē'), + ('Ĕ', 'Ĕ'), + ('Ė', 'Ė'), + ('Ę', 'Ę'), + ('Ě', 'Ě'), + ('Ĝ', 'Ĝ'), + ('Ğ', 'Ğ'), + ('Ġ', 'Ġ'), + ('Ģ', 'Ģ'), + ('Ĥ', 'Ĥ'), + ('Ħ', 'Ħ'), + ('Ĩ', 'Ĩ'), + ('Ī', 'Ī'), + ('Ĭ', 'Ĭ'), + ('Į', 'Į'), + ('İ', 'İ'), + ('IJ', 'IJ'), + ('Ĵ', 'Ĵ'), + ('Ķ', 'Ķ'), + ('Ĺ', 'Ĺ'), + ('Ļ', 'Ļ'), + ('Ľ', 'Ľ'), + ('Ŀ', 'Ŀ'), + ('Ł', 'Ł'), + ('Ń', 'Ń'), + ('Ņ', 'Ņ'), + ('Ň', 'Ň'), + ('Ŋ', 'Ŋ'), + ('Ō', 'Ō'), + ('Ŏ', 'Ŏ'), + ('Ő', 'Ő'), + ('Œ', 'Œ'), + ('Ŕ', 'Ŕ'), + ('Ŗ', 'Ŗ'), + ('Ř', 'Ř'), + ('Ś', 'Ś'), + ('Ŝ', 'Ŝ'), + ('Ş', 'Ş'), + ('Š', 'Š'), + ('Ţ', 'Ţ'), + ('Ť', 'Ť'), + ('Ŧ', 'Ŧ'), + ('Ũ', 'Ũ'), + ('Ū', 'Ū'), + ('Ŭ', 'Ŭ'), + ('Ů', 'Ů'), + ('Ű', 'Ű'), + ('Ų', 'Ų'), + ('Ŵ', 'Ŵ'), + ('Ŷ', 'Ŷ'), + ('Ÿ', 'Ź'), + ('Ż', 'Ż'), + ('Ž', 'Ž'), + ('Ɓ', 'Ƃ'), + ('Ƅ', 'Ƅ'), + ('Ɔ', 'Ƈ'), + ('Ɖ', 'Ƌ'), + ('Ǝ', 'Ƒ'), + ('Ɠ', 'Ɣ'), + ('Ɩ', 'Ƙ'), + ('Ɯ', 'Ɲ'), + ('Ɵ', 'Ơ'), + ('Ƣ', 'Ƣ'), + ('Ƥ', 'Ƥ'), + ('Ʀ', 'Ƨ'), + ('Ʃ', 'Ʃ'), + ('Ƭ', 'Ƭ'), + ('Ʈ', 'Ư'), + ('Ʊ', 'Ƴ'), + ('Ƶ', 'Ƶ'), + ('Ʒ', 'Ƹ'), + ('Ƽ', 'Ƽ'), + ('DŽ', 'DŽ'), + ('LJ', 'LJ'), + ('NJ', 'NJ'), + ('Ǎ', 'Ǎ'), + ('Ǐ', 'Ǐ'), + ('Ǒ', 'Ǒ'), + ('Ǔ', 'Ǔ'), + ('Ǖ', 'Ǖ'), + ('Ǘ', 'Ǘ'), + ('Ǚ', 'Ǚ'), + ('Ǜ', 'Ǜ'), + ('Ǟ', 'Ǟ'), + ('Ǡ', 'Ǡ'), + ('Ǣ', 'Ǣ'), + ('Ǥ', 'Ǥ'), + ('Ǧ', 'Ǧ'), + ('Ǩ', 'Ǩ'), + ('Ǫ', 'Ǫ'), + ('Ǭ', 'Ǭ'), + ('Ǯ', 'Ǯ'), + ('DZ', 'DZ'), + ('Ǵ', 'Ǵ'), + ('Ƕ', 'Ǹ'), + ('Ǻ', 'Ǻ'), + ('Ǽ', 'Ǽ'), + ('Ǿ', 'Ǿ'), + ('Ȁ', 'Ȁ'), + ('Ȃ', 'Ȃ'), + ('Ȅ', 'Ȅ'), + ('Ȇ', 'Ȇ'), + ('Ȉ', 'Ȉ'), + ('Ȋ', 'Ȋ'), + ('Ȍ', 'Ȍ'), + ('Ȏ', 'Ȏ'), + ('Ȑ', 'Ȑ'), + ('Ȓ', 'Ȓ'), + ('Ȕ', 'Ȕ'), + ('Ȗ', 'Ȗ'), + ('Ș', 'Ș'), + ('Ț', 'Ț'), + ('Ȝ', 'Ȝ'), + ('Ȟ', 'Ȟ'), + ('Ƞ', 'Ƞ'), + ('Ȣ', 'Ȣ'), + ('Ȥ', 'Ȥ'), + ('Ȧ', 'Ȧ'), + ('Ȩ', 'Ȩ'), + ('Ȫ', 'Ȫ'), + ('Ȭ', 'Ȭ'), + ('Ȯ', 'Ȯ'), + ('Ȱ', 'Ȱ'), + ('Ȳ', 'Ȳ'), + ('Ⱥ', 'Ȼ'), + ('Ƚ', 'Ⱦ'), + ('Ɂ', 'Ɂ'), + ('Ƀ', 'Ɇ'), + ('Ɉ', 'Ɉ'), + ('Ɋ', 'Ɋ'), + ('Ɍ', 'Ɍ'), + ('Ɏ', 'Ɏ'), + ('Ͱ', 'Ͱ'), + ('Ͳ', 'Ͳ'), + ('Ͷ', 'Ͷ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ώ'), + ('Α', 'Ρ'), + ('Σ', 'Ϋ'), + ('Ϗ', 'Ϗ'), + ('ϒ', 'ϔ'), + ('Ϙ', 'Ϙ'), + ('Ϛ', 'Ϛ'), + ('Ϝ', 'Ϝ'), + ('Ϟ', 'Ϟ'), + ('Ϡ', 'Ϡ'), + ('Ϣ', 'Ϣ'), + ('Ϥ', 'Ϥ'), + ('Ϧ', 'Ϧ'), + ('Ϩ', 'Ϩ'), + ('Ϫ', 'Ϫ'), + ('Ϭ', 'Ϭ'), + ('Ϯ', 'Ϯ'), + ('ϴ', 'ϴ'), + ('Ϸ', 'Ϸ'), + ('Ϲ', 'Ϻ'), + ('Ͻ', 'Я'), + ('Ѡ', 'Ѡ'), + ('Ѣ', 'Ѣ'), + ('Ѥ', 'Ѥ'), + ('Ѧ', 'Ѧ'), + ('Ѩ', 'Ѩ'), + ('Ѫ', 'Ѫ'), + ('Ѭ', 'Ѭ'), + ('Ѯ', 'Ѯ'), + ('Ѱ', 'Ѱ'), + ('Ѳ', 'Ѳ'), + ('Ѵ', 'Ѵ'), + ('Ѷ', 'Ѷ'), + ('Ѹ', 'Ѹ'), + ('Ѻ', 'Ѻ'), + ('Ѽ', 'Ѽ'), + ('Ѿ', 'Ѿ'), + ('Ҁ', 'Ҁ'), + ('Ҋ', 'Ҋ'), + ('Ҍ', 'Ҍ'), + ('Ҏ', 'Ҏ'), + ('Ґ', 'Ґ'), + ('Ғ', 'Ғ'), + ('Ҕ', 'Ҕ'), + ('Җ', 'Җ'), + ('Ҙ', 'Ҙ'), + ('Қ', 'Қ'), + ('Ҝ', 'Ҝ'), + ('Ҟ', 'Ҟ'), + ('Ҡ', 'Ҡ'), + ('Ң', 'Ң'), + ('Ҥ', 'Ҥ'), + ('Ҧ', 'Ҧ'), + ('Ҩ', 'Ҩ'), + ('Ҫ', 'Ҫ'), + ('Ҭ', 'Ҭ'), + ('Ү', 'Ү'), + ('Ұ', 'Ұ'), + ('Ҳ', 'Ҳ'), + ('Ҵ', 'Ҵ'), + ('Ҷ', 'Ҷ'), + ('Ҹ', 'Ҹ'), + ('Һ', 'Һ'), + ('Ҽ', 'Ҽ'), + ('Ҿ', 'Ҿ'), + ('Ӏ', 'Ӂ'), + ('Ӄ', 'Ӄ'), + ('Ӆ', 'Ӆ'), + ('Ӈ', 'Ӈ'), + ('Ӊ', 'Ӊ'), + ('Ӌ', 'Ӌ'), + ('Ӎ', 'Ӎ'), + ('Ӑ', 'Ӑ'), + ('Ӓ', 'Ӓ'), + ('Ӕ', 'Ӕ'), + ('Ӗ', 'Ӗ'), + ('Ә', 'Ә'), + ('Ӛ', 'Ӛ'), + ('Ӝ', 'Ӝ'), + ('Ӟ', 'Ӟ'), + ('Ӡ', 'Ӡ'), + ('Ӣ', 'Ӣ'), + ('Ӥ', 'Ӥ'), + ('Ӧ', 'Ӧ'), + ('Ө', 'Ө'), + ('Ӫ', 'Ӫ'), + ('Ӭ', 'Ӭ'), + ('Ӯ', 'Ӯ'), + ('Ӱ', 'Ӱ'), + ('Ӳ', 'Ӳ'), + ('Ӵ', 'Ӵ'), + ('Ӷ', 'Ӷ'), + ('Ӹ', 'Ӹ'), + ('Ӻ', 'Ӻ'), + ('Ӽ', 'Ӽ'), + ('Ӿ', 'Ӿ'), + ('Ԁ', 'Ԁ'), + ('Ԃ', 'Ԃ'), + ('Ԅ', 'Ԅ'), + ('Ԇ', 'Ԇ'), + ('Ԉ', 'Ԉ'), + ('Ԋ', 'Ԋ'), + ('Ԍ', 'Ԍ'), + ('Ԏ', 'Ԏ'), + ('Ԑ', 'Ԑ'), + ('Ԓ', 'Ԓ'), + ('Ԕ', 'Ԕ'), + ('Ԗ', 'Ԗ'), + ('Ԙ', 'Ԙ'), + ('Ԛ', 'Ԛ'), + ('Ԝ', 'Ԝ'), + ('Ԟ', 'Ԟ'), + ('Ԡ', 'Ԡ'), + ('Ԣ', 'Ԣ'), + ('Ԥ', 'Ԥ'), + ('Ԧ', 'Ԧ'), + ('Ԩ', 'Ԩ'), + ('Ԫ', 'Ԫ'), + ('Ԭ', 'Ԭ'), + ('Ԯ', 'Ԯ'), + ('Ա', 'Ֆ'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('Ꭰ', 'Ᏽ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('Ḁ', 'Ḁ'), + ('Ḃ', 'Ḃ'), + ('Ḅ', 'Ḅ'), + ('Ḇ', 'Ḇ'), + ('Ḉ', 'Ḉ'), + ('Ḋ', 'Ḋ'), + ('Ḍ', 'Ḍ'), + ('Ḏ', 'Ḏ'), + ('Ḑ', 'Ḑ'), + ('Ḓ', 'Ḓ'), + ('Ḕ', 'Ḕ'), + ('Ḗ', 'Ḗ'), + ('Ḙ', 'Ḙ'), + ('Ḛ', 'Ḛ'), + ('Ḝ', 'Ḝ'), + ('Ḟ', 'Ḟ'), + ('Ḡ', 'Ḡ'), + ('Ḣ', 'Ḣ'), + ('Ḥ', 'Ḥ'), + ('Ḧ', 'Ḧ'), + ('Ḩ', 'Ḩ'), + ('Ḫ', 'Ḫ'), + ('Ḭ', 'Ḭ'), + ('Ḯ', 'Ḯ'), + ('Ḱ', 'Ḱ'), + ('Ḳ', 'Ḳ'), + ('Ḵ', 'Ḵ'), + ('Ḷ', 'Ḷ'), + ('Ḹ', 'Ḹ'), + ('Ḻ', 'Ḻ'), + ('Ḽ', 'Ḽ'), + ('Ḿ', 'Ḿ'), + ('Ṁ', 'Ṁ'), + ('Ṃ', 'Ṃ'), + ('Ṅ', 'Ṅ'), + ('Ṇ', 'Ṇ'), + ('Ṉ', 'Ṉ'), + ('Ṋ', 'Ṋ'), + ('Ṍ', 'Ṍ'), + ('Ṏ', 'Ṏ'), + ('Ṑ', 'Ṑ'), + ('Ṓ', 'Ṓ'), + ('Ṕ', 'Ṕ'), + ('Ṗ', 'Ṗ'), + ('Ṙ', 'Ṙ'), + ('Ṛ', 'Ṛ'), + ('Ṝ', 'Ṝ'), + ('Ṟ', 'Ṟ'), + ('Ṡ', 'Ṡ'), + ('Ṣ', 'Ṣ'), + ('Ṥ', 'Ṥ'), + ('Ṧ', 'Ṧ'), + ('Ṩ', 'Ṩ'), + ('Ṫ', 'Ṫ'), + ('Ṭ', 'Ṭ'), + ('Ṯ', 'Ṯ'), + ('Ṱ', 'Ṱ'), + ('Ṳ', 'Ṳ'), + ('Ṵ', 'Ṵ'), + ('Ṷ', 'Ṷ'), + ('Ṹ', 'Ṹ'), + ('Ṻ', 'Ṻ'), + ('Ṽ', 'Ṽ'), + ('Ṿ', 'Ṿ'), + ('Ẁ', 'Ẁ'), + ('Ẃ', 'Ẃ'), + ('Ẅ', 'Ẅ'), + ('Ẇ', 'Ẇ'), + ('Ẉ', 'Ẉ'), + ('Ẋ', 'Ẋ'), + ('Ẍ', 'Ẍ'), + ('Ẏ', 'Ẏ'), + ('Ẑ', 'Ẑ'), + ('Ẓ', 'Ẓ'), + ('Ẕ', 'Ẕ'), + ('ẞ', 'ẞ'), + ('Ạ', 'Ạ'), + ('Ả', 'Ả'), + ('Ấ', 'Ấ'), + ('Ầ', 'Ầ'), + ('Ẩ', 'Ẩ'), + ('Ẫ', 'Ẫ'), + ('Ậ', 'Ậ'), + ('Ắ', 'Ắ'), + ('Ằ', 'Ằ'), + ('Ẳ', 'Ẳ'), + ('Ẵ', 'Ẵ'), + ('Ặ', 'Ặ'), + ('Ẹ', 'Ẹ'), + ('Ẻ', 'Ẻ'), + ('Ẽ', 'Ẽ'), + ('Ế', 'Ế'), + ('Ề', 'Ề'), + ('Ể', 'Ể'), + ('Ễ', 'Ễ'), + ('Ệ', 'Ệ'), + ('Ỉ', 'Ỉ'), + ('Ị', 'Ị'), + ('Ọ', 'Ọ'), + ('Ỏ', 'Ỏ'), + ('Ố', 'Ố'), + ('Ồ', 'Ồ'), + ('Ổ', 'Ổ'), + ('Ỗ', 'Ỗ'), + ('Ộ', 'Ộ'), + ('Ớ', 'Ớ'), + ('Ờ', 'Ờ'), + ('Ở', 'Ở'), + ('Ỡ', 'Ỡ'), + ('Ợ', 'Ợ'), + ('Ụ', 'Ụ'), + ('Ủ', 'Ủ'), + ('Ứ', 'Ứ'), + ('Ừ', 'Ừ'), + ('Ử', 'Ử'), + ('Ữ', 'Ữ'), + ('Ự', 'Ự'), + ('Ỳ', 'Ỳ'), + ('Ỵ', 'Ỵ'), + ('Ỷ', 'Ỷ'), + ('Ỹ', 'Ỹ'), + ('Ỻ', 'Ỻ'), + ('Ỽ', 'Ỽ'), + ('Ỿ', 'Ỿ'), + ('Ἀ', 'Ἇ'), + ('Ἐ', 'Ἕ'), + ('Ἠ', 'Ἧ'), + ('Ἰ', 'Ἷ'), + ('Ὀ', 'Ὅ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'Ὗ'), + ('Ὠ', 'Ὧ'), + ('Ᾰ', 'Ά'), + ('Ὲ', 'Ή'), + ('Ῐ', 'Ί'), + ('Ῠ', 'Ῥ'), + ('Ὸ', 'Ώ'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℋ', 'ℍ'), + ('ℐ', 'ℒ'), + ('ℕ', 'ℕ'), + ('ℙ', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℭ'), + ('ℰ', 'ℳ'), + ('ℾ', 'ℿ'), + ('ⅅ', 'ⅅ'), + ('Ↄ', 'Ↄ'), + ('Ⰰ', 'Ⱞ'), + ('Ⱡ', 'Ⱡ'), + ('Ɫ', 'Ɽ'), + ('Ⱨ', 'Ⱨ'), + ('Ⱪ', 'Ⱪ'), + ('Ⱬ', 'Ⱬ'), + ('Ɑ', 'Ɒ'), + ('Ⱳ', 'Ⱳ'), + ('Ⱶ', 'Ⱶ'), + ('Ȿ', 'Ⲁ'), + ('Ⲃ', 'Ⲃ'), + ('Ⲅ', 'Ⲅ'), + ('Ⲇ', 'Ⲇ'), + ('Ⲉ', 'Ⲉ'), + ('Ⲋ', 'Ⲋ'), + ('Ⲍ', 'Ⲍ'), + ('Ⲏ', 'Ⲏ'), + ('Ⲑ', 'Ⲑ'), + ('Ⲓ', 'Ⲓ'), + ('Ⲕ', 'Ⲕ'), + ('Ⲗ', 'Ⲗ'), + ('Ⲙ', 'Ⲙ'), + ('Ⲛ', 'Ⲛ'), + ('Ⲝ', 'Ⲝ'), + ('Ⲟ', 'Ⲟ'), + ('Ⲡ', 'Ⲡ'), + ('Ⲣ', 'Ⲣ'), + ('Ⲥ', 'Ⲥ'), + ('Ⲧ', 'Ⲧ'), + ('Ⲩ', 'Ⲩ'), + ('Ⲫ', 'Ⲫ'), + ('Ⲭ', 'Ⲭ'), + ('Ⲯ', 'Ⲯ'), + ('Ⲱ', 'Ⲱ'), + ('Ⲳ', 'Ⲳ'), + ('Ⲵ', 'Ⲵ'), + ('Ⲷ', 'Ⲷ'), + ('Ⲹ', 'Ⲹ'), + ('Ⲻ', 'Ⲻ'), + ('Ⲽ', 'Ⲽ'), + ('Ⲿ', 'Ⲿ'), + ('Ⳁ', 'Ⳁ'), + ('Ⳃ', 'Ⳃ'), + ('Ⳅ', 'Ⳅ'), + ('Ⳇ', 'Ⳇ'), + ('Ⳉ', 'Ⳉ'), + ('Ⳋ', 'Ⳋ'), + ('Ⳍ', 'Ⳍ'), + ('Ⳏ', 'Ⳏ'), + ('Ⳑ', 'Ⳑ'), + ('Ⳓ', 'Ⳓ'), + ('Ⳕ', 'Ⳕ'), + ('Ⳗ', 'Ⳗ'), + ('Ⳙ', 'Ⳙ'), + ('Ⳛ', 'Ⳛ'), + ('Ⳝ', 'Ⳝ'), + ('Ⳟ', 'Ⳟ'), + ('Ⳡ', 'Ⳡ'), + ('Ⳣ', 'Ⳣ'), + ('Ⳬ', 'Ⳬ'), + ('Ⳮ', 'Ⳮ'), + ('Ⳳ', 'Ⳳ'), + ('Ꙁ', 'Ꙁ'), + ('Ꙃ', 'Ꙃ'), + ('Ꙅ', 'Ꙅ'), + ('Ꙇ', 'Ꙇ'), + ('Ꙉ', 'Ꙉ'), + ('Ꙋ', 'Ꙋ'), + ('Ꙍ', 'Ꙍ'), + ('Ꙏ', 'Ꙏ'), + ('Ꙑ', 'Ꙑ'), + ('Ꙓ', 'Ꙓ'), + ('Ꙕ', 'Ꙕ'), + ('Ꙗ', 'Ꙗ'), + ('Ꙙ', 'Ꙙ'), + ('Ꙛ', 'Ꙛ'), + ('Ꙝ', 'Ꙝ'), + ('Ꙟ', 'Ꙟ'), + ('Ꙡ', 'Ꙡ'), + ('Ꙣ', 'Ꙣ'), + ('Ꙥ', 'Ꙥ'), + ('Ꙧ', 'Ꙧ'), + ('Ꙩ', 'Ꙩ'), + ('Ꙫ', 'Ꙫ'), + ('Ꙭ', 'Ꙭ'), + ('Ꚁ', 'Ꚁ'), + ('Ꚃ', 'Ꚃ'), + ('Ꚅ', 'Ꚅ'), + ('Ꚇ', 'Ꚇ'), + ('Ꚉ', 'Ꚉ'), + ('Ꚋ', 'Ꚋ'), + ('Ꚍ', 'Ꚍ'), + ('Ꚏ', 'Ꚏ'), + ('Ꚑ', 'Ꚑ'), + ('Ꚓ', 'Ꚓ'), + ('Ꚕ', 'Ꚕ'), + ('Ꚗ', 'Ꚗ'), + ('Ꚙ', 'Ꚙ'), + ('Ꚛ', 'Ꚛ'), + ('Ꜣ', 'Ꜣ'), + ('Ꜥ', 'Ꜥ'), + ('Ꜧ', 'Ꜧ'), + ('Ꜩ', 'Ꜩ'), + ('Ꜫ', 'Ꜫ'), + ('Ꜭ', 'Ꜭ'), + ('Ꜯ', 'Ꜯ'), + ('Ꜳ', 'Ꜳ'), + ('Ꜵ', 'Ꜵ'), + ('Ꜷ', 'Ꜷ'), + ('Ꜹ', 'Ꜹ'), + ('Ꜻ', 'Ꜻ'), + ('Ꜽ', 'Ꜽ'), + ('Ꜿ', 'Ꜿ'), + ('Ꝁ', 'Ꝁ'), + ('Ꝃ', 'Ꝃ'), + ('Ꝅ', 'Ꝅ'), + ('Ꝇ', 'Ꝇ'), + ('Ꝉ', 'Ꝉ'), + ('Ꝋ', 'Ꝋ'), + ('Ꝍ', 'Ꝍ'), + ('Ꝏ', 'Ꝏ'), + ('Ꝑ', 'Ꝑ'), + ('Ꝓ', 'Ꝓ'), + ('Ꝕ', 'Ꝕ'), + ('Ꝗ', 'Ꝗ'), + ('Ꝙ', 'Ꝙ'), + ('Ꝛ', 'Ꝛ'), + ('Ꝝ', 'Ꝝ'), + ('Ꝟ', 'Ꝟ'), + ('Ꝡ', 'Ꝡ'), + ('Ꝣ', 'Ꝣ'), + ('Ꝥ', 'Ꝥ'), + ('Ꝧ', 'Ꝧ'), + ('Ꝩ', 'Ꝩ'), + ('Ꝫ', 'Ꝫ'), + ('Ꝭ', 'Ꝭ'), + ('Ꝯ', 'Ꝯ'), + ('Ꝺ', 'Ꝺ'), + ('Ꝼ', 'Ꝼ'), + ('Ᵹ', 'Ꝿ'), + ('Ꞁ', 'Ꞁ'), + ('Ꞃ', 'Ꞃ'), + ('Ꞅ', 'Ꞅ'), + ('Ꞇ', 'Ꞇ'), + ('Ꞌ', 'Ꞌ'), + ('Ɥ', 'Ɥ'), + ('Ꞑ', 'Ꞑ'), + ('Ꞓ', 'Ꞓ'), + ('Ꞗ', 'Ꞗ'), + ('Ꞙ', 'Ꞙ'), + ('Ꞛ', 'Ꞛ'), + ('Ꞝ', 'Ꞝ'), + ('Ꞟ', 'Ꞟ'), + ('Ꞡ', 'Ꞡ'), + ('Ꞣ', 'Ꞣ'), + ('Ꞥ', 'Ꞥ'), + ('Ꞧ', 'Ꞧ'), + ('Ꞩ', 'Ꞩ'), + ('Ɦ', 'Ɪ'), + ('Ʞ', 'Ꞵ'), + ('Ꞷ', 'Ꞷ'), + ('Ꞹ', 'Ꞹ'), + ('\u{a7ba}', '\u{a7ba}'), + ('\u{a7bc}', '\u{a7bc}'), + ('\u{a7be}', '\u{a7be}'), + ('\u{a7c2}', '\u{a7c2}'), + ('\u{a7c4}', '\u{a7c6}'), + ('A', 'Z'), + ('𐐀', '𐐧'), + ('𐒰', '𐓓'), + ('𐲀', '𐲲'), + ('𑢠', '𑢿'), + ('𖹀', '𖹟'), + ('𝐀', '𝐙'), + ('𝐴', '𝑍'), + ('𝑨', '𝒁'), + ('𝒜', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒵'), + ('𝓐', '𝓩'), + ('𝔄', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔸', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕬', '𝖅'), + ('𝖠', '𝖹'), + ('𝗔', '𝗭'), + ('𝘈', '𝘡'), + ('𝘼', '𝙕'), + ('𝙰', '𝚉'), + ('𝚨', '𝛀'), + ('𝛢', '𝛺'), + ('𝜜', '𝜴'), + ('𝝖', '𝝮'), + ('𝞐', '𝞨'), + ('𝟊', '𝟊'), + ('𞤀', '𞤡'), +]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/grapheme_cluster_break.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/grapheme_cluster_break.rs new file mode 100644 index 0000000..2855ead --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/grapheme_cluster_break.rs @@ -0,0 +1,1369 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate grapheme-cluster-break /tmp/ucd/12.1.0/ --chars +// +// ucd-generate is available on crates.io. + +pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] = &[ + ("CR", CR), + ("Control", CONTROL), + ("Extend", EXTEND), + ("L", L), + ("LF", LF), + ("LV", LV), + ("LVT", LVT), + ("Prepend", PREPEND), + ("Regional_Indicator", REGIONAL_INDICATOR), + ("SpacingMark", SPACINGMARK), + ("T", T), + ("V", V), + ("ZWJ", ZWJ), +]; + +pub const CR: &'static [(char, char)] = &[('\r', '\r')]; + +pub const CONTROL: &'static [(char, char)] = &[ + ('\u{0}', '\t'), + ('\u{b}', '\u{c}'), + ('\u{e}', '\u{1f}'), + ('\u{7f}', '\u{9f}'), + ('\u{ad}', '\u{ad}'), + ('\u{61c}', '\u{61c}'), + ('\u{180e}', '\u{180e}'), + ('\u{200b}', '\u{200b}'), + ('\u{200e}', '\u{200f}'), + ('\u{2028}', '\u{202e}'), + ('\u{2060}', '\u{206f}'), + ('\u{feff}', '\u{feff}'), + ('\u{fff0}', '\u{fffb}'), + ('\u{13430}', '\u{13438}'), + ('\u{1bca0}', '\u{1bca3}'), + ('\u{1d173}', '\u{1d17a}'), + ('\u{e0000}', '\u{e001f}'), + ('\u{e0080}', '\u{e00ff}'), + ('\u{e01f0}', '\u{e0fff}'), +]; + +pub const EXTEND: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), + ('\u{483}', '\u{489}'), + ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('\u{610}', '\u{61a}'), + ('\u{64b}', '\u{65f}'), + ('\u{670}', '\u{670}'), + ('\u{6d6}', '\u{6dc}'), + ('\u{6df}', '\u{6e4}'), + ('\u{6e7}', '\u{6e8}'), + ('\u{6ea}', '\u{6ed}'), + ('\u{711}', '\u{711}'), + ('\u{730}', '\u{74a}'), + ('\u{7a6}', '\u{7b0}'), + ('\u{7eb}', '\u{7f3}'), + ('\u{7fd}', '\u{7fd}'), + ('\u{816}', '\u{819}'), + ('\u{81b}', '\u{823}'), + ('\u{825}', '\u{827}'), + ('\u{829}', '\u{82d}'), + ('\u{859}', '\u{85b}'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', '\u{902}'), + ('\u{93a}', '\u{93a}'), + ('\u{93c}', '\u{93c}'), + ('\u{941}', '\u{948}'), + ('\u{94d}', '\u{94d}'), + ('\u{951}', '\u{957}'), + ('\u{962}', '\u{963}'), + ('\u{981}', '\u{981}'), + ('\u{9bc}', '\u{9bc}'), + ('\u{9be}', '\u{9be}'), + ('\u{9c1}', '\u{9c4}'), + ('\u{9cd}', '\u{9cd}'), + ('\u{9d7}', '\u{9d7}'), + ('\u{9e2}', '\u{9e3}'), + ('\u{9fe}', '\u{9fe}'), + ('\u{a01}', '\u{a02}'), + ('\u{a3c}', '\u{a3c}'), + ('\u{a41}', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('\u{a70}', '\u{a71}'), + ('\u{a75}', '\u{a75}'), + ('\u{a81}', '\u{a82}'), + ('\u{abc}', '\u{abc}'), + ('\u{ac1}', '\u{ac5}'), + ('\u{ac7}', '\u{ac8}'), + ('\u{acd}', '\u{acd}'), + ('\u{ae2}', '\u{ae3}'), + ('\u{afa}', '\u{aff}'), + ('\u{b01}', '\u{b01}'), + ('\u{b3c}', '\u{b3c}'), + ('\u{b3e}', '\u{b3f}'), + ('\u{b41}', '\u{b44}'), + ('\u{b4d}', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('\u{b62}', '\u{b63}'), + ('\u{b82}', '\u{b82}'), + ('\u{bbe}', '\u{bbe}'), + ('\u{bc0}', '\u{bc0}'), + ('\u{bcd}', '\u{bcd}'), + ('\u{bd7}', '\u{bd7}'), + ('\u{c00}', '\u{c00}'), + ('\u{c04}', '\u{c04}'), + ('\u{c3e}', '\u{c40}'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('\u{c62}', '\u{c63}'), + ('\u{c81}', '\u{c81}'), + ('\u{cbc}', '\u{cbc}'), + ('\u{cbf}', '\u{cbf}'), + ('\u{cc2}', '\u{cc2}'), + ('\u{cc6}', '\u{cc6}'), + ('\u{ccc}', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('\u{ce2}', '\u{ce3}'), + ('\u{d00}', '\u{d01}'), + ('\u{d3b}', '\u{d3c}'), + ('\u{d3e}', '\u{d3e}'), + ('\u{d41}', '\u{d44}'), + ('\u{d4d}', '\u{d4d}'), + ('\u{d57}', '\u{d57}'), + ('\u{d62}', '\u{d63}'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dcf}'), + ('\u{dd2}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('\u{ddf}', '\u{ddf}'), + ('\u{e31}', '\u{e31}'), + ('\u{e34}', '\u{e3a}'), + ('\u{e47}', '\u{e4e}'), + ('\u{eb1}', '\u{eb1}'), + ('\u{eb4}', '\u{ebc}'), + ('\u{ec8}', '\u{ecd}'), + ('\u{f18}', '\u{f19}'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('\u{f71}', '\u{f7e}'), + ('\u{f80}', '\u{f84}'), + ('\u{f86}', '\u{f87}'), + ('\u{f8d}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), + ('\u{102d}', '\u{1030}'), + ('\u{1032}', '\u{1037}'), + ('\u{1039}', '\u{103a}'), + ('\u{103d}', '\u{103e}'), + ('\u{1058}', '\u{1059}'), + ('\u{105e}', '\u{1060}'), + ('\u{1071}', '\u{1074}'), + ('\u{1082}', '\u{1082}'), + ('\u{1085}', '\u{1086}'), + ('\u{108d}', '\u{108d}'), + ('\u{109d}', '\u{109d}'), + ('\u{135d}', '\u{135f}'), + ('\u{1712}', '\u{1714}'), + ('\u{1732}', '\u{1734}'), + ('\u{1752}', '\u{1753}'), + ('\u{1772}', '\u{1773}'), + ('\u{17b4}', '\u{17b5}'), + ('\u{17b7}', '\u{17bd}'), + ('\u{17c6}', '\u{17c6}'), + ('\u{17c9}', '\u{17d3}'), + ('\u{17dd}', '\u{17dd}'), + ('\u{180b}', '\u{180d}'), + ('\u{1885}', '\u{1886}'), + ('\u{18a9}', '\u{18a9}'), + ('\u{1920}', '\u{1922}'), + ('\u{1927}', '\u{1928}'), + ('\u{1932}', '\u{1932}'), + ('\u{1939}', '\u{193b}'), + ('\u{1a17}', '\u{1a18}'), + ('\u{1a1b}', '\u{1a1b}'), + ('\u{1a56}', '\u{1a56}'), + ('\u{1a58}', '\u{1a5e}'), + ('\u{1a60}', '\u{1a60}'), + ('\u{1a62}', '\u{1a62}'), + ('\u{1a65}', '\u{1a6c}'), + ('\u{1a73}', '\u{1a7c}'), + ('\u{1a7f}', '\u{1a7f}'), + ('\u{1ab0}', '\u{1abe}'), + ('\u{1b00}', '\u{1b03}'), + ('\u{1b34}', '\u{1b3a}'), + ('\u{1b3c}', '\u{1b3c}'), + ('\u{1b42}', '\u{1b42}'), + ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', '\u{1b81}'), + ('\u{1ba2}', '\u{1ba5}'), + ('\u{1ba8}', '\u{1ba9}'), + ('\u{1bab}', '\u{1bad}'), + ('\u{1be6}', '\u{1be6}'), + ('\u{1be8}', '\u{1be9}'), + ('\u{1bed}', '\u{1bed}'), + ('\u{1bef}', '\u{1bf1}'), + ('\u{1c2c}', '\u{1c33}'), + ('\u{1c36}', '\u{1c37}'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1ce0}'), + ('\u{1ce2}', '\u{1ce8}'), + ('\u{1ced}', '\u{1ced}'), + ('\u{1cf4}', '\u{1cf4}'), + ('\u{1cf8}', '\u{1cf9}'), + ('\u{1dc0}', '\u{1df9}'), + ('\u{1dfb}', '\u{1dff}'), + ('\u{200c}', '\u{200c}'), + ('\u{20d0}', '\u{20f0}'), + ('\u{2cef}', '\u{2cf1}'), + ('\u{2d7f}', '\u{2d7f}'), + ('\u{2de0}', '\u{2dff}'), + ('\u{302a}', '\u{302f}'), + ('\u{3099}', '\u{309a}'), + ('\u{a66f}', '\u{a672}'), + ('\u{a674}', '\u{a67d}'), + ('\u{a69e}', '\u{a69f}'), + ('\u{a6f0}', '\u{a6f1}'), + ('\u{a802}', '\u{a802}'), + ('\u{a806}', '\u{a806}'), + ('\u{a80b}', '\u{a80b}'), + ('\u{a825}', '\u{a826}'), + ('\u{a8c4}', '\u{a8c5}'), + ('\u{a8e0}', '\u{a8f1}'), + ('\u{a8ff}', '\u{a8ff}'), + ('\u{a926}', '\u{a92d}'), + ('\u{a947}', '\u{a951}'), + ('\u{a980}', '\u{a982}'), + ('\u{a9b3}', '\u{a9b3}'), + ('\u{a9b6}', '\u{a9b9}'), + ('\u{a9bc}', 'ꦽ'), + ('\u{a9e5}', '\u{a9e5}'), + ('\u{aa29}', '\u{aa2e}'), + ('\u{aa31}', '\u{aa32}'), + ('\u{aa35}', '\u{aa36}'), + ('\u{aa43}', '\u{aa43}'), + ('\u{aa4c}', '\u{aa4c}'), + ('\u{aa7c}', '\u{aa7c}'), + ('\u{aab0}', '\u{aab0}'), + ('\u{aab2}', '\u{aab4}'), + ('\u{aab7}', '\u{aab8}'), + ('\u{aabe}', '\u{aabf}'), + ('\u{aac1}', '\u{aac1}'), + ('\u{aaec}', '\u{aaed}'), + ('\u{aaf6}', '\u{aaf6}'), + ('\u{abe5}', '\u{abe5}'), + ('\u{abe8}', '\u{abe8}'), + ('\u{abed}', '\u{abed}'), + ('\u{fb1e}', '\u{fb1e}'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2f}'), + ('\u{ff9e}', '\u{ff9f}'), + ('\u{101fd}', '\u{101fd}'), + ('\u{102e0}', '\u{102e0}'), + ('\u{10376}', '\u{1037a}'), + ('\u{10a01}', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a0f}'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), + ('\u{10ae5}', '\u{10ae6}'), + ('\u{10d24}', '\u{10d27}'), + ('\u{10f46}', '\u{10f50}'), + ('\u{11001}', '\u{11001}'), + ('\u{11038}', '\u{11046}'), + ('\u{1107f}', '\u{11081}'), + ('\u{110b3}', '\u{110b6}'), + ('\u{110b9}', '\u{110ba}'), + ('\u{11100}', '\u{11102}'), + ('\u{11127}', '\u{1112b}'), + ('\u{1112d}', '\u{11134}'), + ('\u{11173}', '\u{11173}'), + ('\u{11180}', '\u{11181}'), + ('\u{111b6}', '\u{111be}'), + ('\u{111c9}', '\u{111cc}'), + ('\u{1122f}', '\u{11231}'), + ('\u{11234}', '\u{11234}'), + ('\u{11236}', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('\u{112df}', '\u{112df}'), + ('\u{112e3}', '\u{112ea}'), + ('\u{11300}', '\u{11301}'), + ('\u{1133b}', '\u{1133c}'), + ('\u{1133e}', '\u{1133e}'), + ('\u{11340}', '\u{11340}'), + ('\u{11357}', '\u{11357}'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('\u{11438}', '\u{1143f}'), + ('\u{11442}', '\u{11444}'), + ('\u{11446}', '\u{11446}'), + ('\u{1145e}', '\u{1145e}'), + ('\u{114b0}', '\u{114b0}'), + ('\u{114b3}', '\u{114b8}'), + ('\u{114ba}', '\u{114ba}'), + ('\u{114bd}', '\u{114bd}'), + ('\u{114bf}', '\u{114c0}'), + ('\u{114c2}', '\u{114c3}'), + ('\u{115af}', '\u{115af}'), + ('\u{115b2}', '\u{115b5}'), + ('\u{115bc}', '\u{115bd}'), + ('\u{115bf}', '\u{115c0}'), + ('\u{115dc}', '\u{115dd}'), + ('\u{11633}', '\u{1163a}'), + ('\u{1163d}', '\u{1163d}'), + ('\u{1163f}', '\u{11640}'), + ('\u{116ab}', '\u{116ab}'), + ('\u{116ad}', '\u{116ad}'), + ('\u{116b0}', '\u{116b5}'), + ('\u{116b7}', '\u{116b7}'), + ('\u{1171d}', '\u{1171f}'), + ('\u{11722}', '\u{11725}'), + ('\u{11727}', '\u{1172b}'), + ('\u{1182f}', '\u{11837}'), + ('\u{11839}', '\u{1183a}'), + ('\u{119d4}', '\u{119d7}'), + ('\u{119da}', '\u{119db}'), + ('\u{119e0}', '\u{119e0}'), + ('\u{11a01}', '\u{11a0a}'), + ('\u{11a33}', '\u{11a38}'), + ('\u{11a3b}', '\u{11a3e}'), + ('\u{11a47}', '\u{11a47}'), + ('\u{11a51}', '\u{11a56}'), + ('\u{11a59}', '\u{11a5b}'), + ('\u{11a8a}', '\u{11a96}'), + ('\u{11a98}', '\u{11a99}'), + ('\u{11c30}', '\u{11c36}'), + ('\u{11c38}', '\u{11c3d}'), + ('\u{11c3f}', '\u{11c3f}'), + ('\u{11c92}', '\u{11ca7}'), + ('\u{11caa}', '\u{11cb0}'), + ('\u{11cb2}', '\u{11cb3}'), + ('\u{11cb5}', '\u{11cb6}'), + ('\u{11d31}', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d45}'), + ('\u{11d47}', '\u{11d47}'), + ('\u{11d90}', '\u{11d91}'), + ('\u{11d95}', '\u{11d95}'), + ('\u{11d97}', '\u{11d97}'), + ('\u{11ef3}', '\u{11ef4}'), + ('\u{16af0}', '\u{16af4}'), + ('\u{16b30}', '\u{16b36}'), + ('\u{16f4f}', '\u{16f4f}'), + ('\u{16f8f}', '\u{16f92}'), + ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d165}', '\u{1d165}'), + ('\u{1d167}', '\u{1d169}'), + ('\u{1d16e}', '\u{1d172}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1d242}', '\u{1d244}'), + ('\u{1da00}', '\u{1da36}'), + ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), + ('\u{1da84}', '\u{1da84}'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e130}', '\u{1e136}'), + ('\u{1e2ec}', '\u{1e2ef}'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('\u{1e944}', '\u{1e94a}'), + ('🏻', '🏿'), + ('\u{e0020}', '\u{e007f}'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const L: &'static [(char, char)] = &[('ᄀ', 'ᅟ'), ('ꥠ', 'ꥼ')]; + +pub const LF: &'static [(char, char)] = &[('\n', '\n')]; + +pub const LV: &'static [(char, char)] = &[ + ('가', '가'), + ('개', '개'), + ('갸', '갸'), + ('걔', '걔'), + ('거', '거'), + ('게', '게'), + ('겨', '겨'), + ('계', '계'), + ('고', '고'), + ('과', '과'), + ('괘', '괘'), + ('괴', '괴'), + ('교', '교'), + ('구', '구'), + ('궈', '궈'), + ('궤', '궤'), + ('귀', '귀'), + ('규', '규'), + ('그', '그'), + ('긔', '긔'), + ('기', '기'), + ('까', '까'), + ('깨', '깨'), + ('꺄', '꺄'), + ('꺠', '꺠'), + ('꺼', '꺼'), + ('께', '께'), + ('껴', '껴'), + ('꼐', '꼐'), + ('꼬', '꼬'), + ('꽈', '꽈'), + ('꽤', '꽤'), + ('꾀', '꾀'), + ('꾜', '꾜'), + ('꾸', '꾸'), + ('꿔', '꿔'), + ('꿰', '꿰'), + ('뀌', '뀌'), + ('뀨', '뀨'), + ('끄', '끄'), + ('끠', '끠'), + ('끼', '끼'), + ('나', '나'), + ('내', '내'), + ('냐', '냐'), + ('냬', '냬'), + ('너', '너'), + ('네', '네'), + ('녀', '녀'), + ('녜', '녜'), + ('노', '노'), + ('놔', '놔'), + ('놰', '놰'), + ('뇌', '뇌'), + ('뇨', '뇨'), + ('누', '누'), + ('눠', '눠'), + ('눼', '눼'), + ('뉘', '뉘'), + ('뉴', '뉴'), + ('느', '느'), + ('늬', '늬'), + ('니', '니'), + ('다', '다'), + ('대', '대'), + ('댜', '댜'), + ('댸', '댸'), + ('더', '더'), + ('데', '데'), + ('뎌', '뎌'), + ('뎨', '뎨'), + ('도', '도'), + ('돠', '돠'), + ('돼', '돼'), + ('되', '되'), + ('됴', '됴'), + ('두', '두'), + ('둬', '둬'), + ('뒈', '뒈'), + ('뒤', '뒤'), + ('듀', '듀'), + ('드', '드'), + ('듸', '듸'), + ('디', '디'), + ('따', '따'), + ('때', '때'), + ('땨', '땨'), + ('떄', '떄'), + ('떠', '떠'), + ('떼', '떼'), + ('뗘', '뗘'), + ('뗴', '뗴'), + ('또', '또'), + ('똬', '똬'), + ('뙈', '뙈'), + ('뙤', '뙤'), + ('뚀', '뚀'), + ('뚜', '뚜'), + ('뚸', '뚸'), + ('뛔', '뛔'), + ('뛰', '뛰'), + ('뜌', '뜌'), + ('뜨', '뜨'), + ('띄', '띄'), + ('띠', '띠'), + ('라', '라'), + ('래', '래'), + ('랴', '랴'), + ('럐', '럐'), + ('러', '러'), + ('레', '레'), + ('려', '려'), + ('례', '례'), + ('로', '로'), + ('롸', '롸'), + ('뢔', '뢔'), + ('뢰', '뢰'), + ('료', '료'), + ('루', '루'), + ('뤄', '뤄'), + ('뤠', '뤠'), + ('뤼', '뤼'), + ('류', '류'), + ('르', '르'), + ('릐', '릐'), + ('리', '리'), + ('마', '마'), + ('매', '매'), + ('먀', '먀'), + ('먜', '먜'), + ('머', '머'), + ('메', '메'), + ('며', '며'), + ('몌', '몌'), + ('모', '모'), + ('뫄', '뫄'), + ('뫠', '뫠'), + ('뫼', '뫼'), + ('묘', '묘'), + ('무', '무'), + ('뭐', '뭐'), + ('뭬', '뭬'), + ('뮈', '뮈'), + ('뮤', '뮤'), + ('므', '므'), + ('믜', '믜'), + ('미', '미'), + ('바', '바'), + ('배', '배'), + ('뱌', '뱌'), + ('뱨', '뱨'), + ('버', '버'), + ('베', '베'), + ('벼', '벼'), + ('볘', '볘'), + ('보', '보'), + ('봐', '봐'), + ('봬', '봬'), + ('뵈', '뵈'), + ('뵤', '뵤'), + ('부', '부'), + ('붜', '붜'), + ('붸', '붸'), + ('뷔', '뷔'), + ('뷰', '뷰'), + ('브', '브'), + ('븨', '븨'), + ('비', '비'), + ('빠', '빠'), + ('빼', '빼'), + ('뺘', '뺘'), + ('뺴', '뺴'), + ('뻐', '뻐'), + ('뻬', '뻬'), + ('뼈', '뼈'), + ('뼤', '뼤'), + ('뽀', '뽀'), + ('뽜', '뽜'), + ('뽸', '뽸'), + ('뾔', '뾔'), + ('뾰', '뾰'), + ('뿌', '뿌'), + ('뿨', '뿨'), + ('쀄', '쀄'), + ('쀠', '쀠'), + ('쀼', '쀼'), + ('쁘', '쁘'), + ('쁴', '쁴'), + ('삐', '삐'), + ('사', '사'), + ('새', '새'), + ('샤', '샤'), + ('섀', '섀'), + ('서', '서'), + ('세', '세'), + ('셔', '셔'), + ('셰', '셰'), + ('소', '소'), + ('솨', '솨'), + ('쇄', '쇄'), + ('쇠', '쇠'), + ('쇼', '쇼'), + ('수', '수'), + ('숴', '숴'), + ('쉐', '쉐'), + ('쉬', '쉬'), + ('슈', '슈'), + ('스', '스'), + ('싀', '싀'), + ('시', '시'), + ('싸', '싸'), + ('쌔', '쌔'), + ('쌰', '쌰'), + ('썌', '썌'), + ('써', '써'), + ('쎄', '쎄'), + ('쎠', '쎠'), + ('쎼', '쎼'), + ('쏘', '쏘'), + ('쏴', '쏴'), + ('쐐', '쐐'), + ('쐬', '쐬'), + ('쑈', '쑈'), + ('쑤', '쑤'), + ('쒀', '쒀'), + ('쒜', '쒜'), + ('쒸', '쒸'), + ('쓔', '쓔'), + ('쓰', '쓰'), + ('씌', '씌'), + ('씨', '씨'), + ('아', '아'), + ('애', '애'), + ('야', '야'), + ('얘', '얘'), + ('어', '어'), + ('에', '에'), + ('여', '여'), + ('예', '예'), + ('오', '오'), + ('와', '와'), + ('왜', '왜'), + ('외', '외'), + ('요', '요'), + ('우', '우'), + ('워', '워'), + ('웨', '웨'), + ('위', '위'), + ('유', '유'), + ('으', '으'), + ('의', '의'), + ('이', '이'), + ('자', '자'), + ('재', '재'), + ('쟈', '쟈'), + ('쟤', '쟤'), + ('저', '저'), + ('제', '제'), + ('져', '져'), + ('졔', '졔'), + ('조', '조'), + ('좌', '좌'), + ('좨', '좨'), + ('죄', '죄'), + ('죠', '죠'), + ('주', '주'), + ('줘', '줘'), + ('줴', '줴'), + ('쥐', '쥐'), + ('쥬', '쥬'), + ('즈', '즈'), + ('즤', '즤'), + ('지', '지'), + ('짜', '짜'), + ('째', '째'), + ('쨔', '쨔'), + ('쨰', '쨰'), + ('쩌', '쩌'), + ('쩨', '쩨'), + ('쪄', '쪄'), + ('쪠', '쪠'), + ('쪼', '쪼'), + ('쫘', '쫘'), + ('쫴', '쫴'), + ('쬐', '쬐'), + ('쬬', '쬬'), + ('쭈', '쭈'), + ('쭤', '쭤'), + ('쮀', '쮀'), + ('쮜', '쮜'), + ('쮸', '쮸'), + ('쯔', '쯔'), + ('쯰', '쯰'), + ('찌', '찌'), + ('차', '차'), + ('채', '채'), + ('챠', '챠'), + ('챼', '챼'), + ('처', '처'), + ('체', '체'), + ('쳐', '쳐'), + ('쳬', '쳬'), + ('초', '초'), + ('촤', '촤'), + ('쵀', '쵀'), + ('최', '최'), + ('쵸', '쵸'), + ('추', '추'), + ('춰', '춰'), + ('췌', '췌'), + ('취', '취'), + ('츄', '츄'), + ('츠', '츠'), + ('츼', '츼'), + ('치', '치'), + ('카', '카'), + ('캐', '캐'), + ('캬', '캬'), + ('컈', '컈'), + ('커', '커'), + ('케', '케'), + ('켜', '켜'), + ('켸', '켸'), + ('코', '코'), + ('콰', '콰'), + ('쾌', '쾌'), + ('쾨', '쾨'), + ('쿄', '쿄'), + ('쿠', '쿠'), + ('쿼', '쿼'), + ('퀘', '퀘'), + ('퀴', '퀴'), + ('큐', '큐'), + ('크', '크'), + ('킈', '킈'), + ('키', '키'), + ('타', '타'), + ('태', '태'), + ('탸', '탸'), + ('턔', '턔'), + ('터', '터'), + ('테', '테'), + ('텨', '텨'), + ('톄', '톄'), + ('토', '토'), + ('톼', '톼'), + ('퇘', '퇘'), + ('퇴', '퇴'), + ('툐', '툐'), + ('투', '투'), + ('퉈', '퉈'), + ('퉤', '퉤'), + ('튀', '튀'), + ('튜', '튜'), + ('트', '트'), + ('틔', '틔'), + ('티', '티'), + ('파', '파'), + ('패', '패'), + ('퍄', '퍄'), + ('퍠', '퍠'), + ('퍼', '퍼'), + ('페', '페'), + ('펴', '펴'), + ('폐', '폐'), + ('포', '포'), + ('퐈', '퐈'), + ('퐤', '퐤'), + ('푀', '푀'), + ('표', '표'), + ('푸', '푸'), + ('풔', '풔'), + ('풰', '풰'), + ('퓌', '퓌'), + ('퓨', '퓨'), + ('프', '프'), + ('픠', '픠'), + ('피', '피'), + ('하', '하'), + ('해', '해'), + ('햐', '햐'), + ('햬', '햬'), + ('허', '허'), + ('헤', '헤'), + ('혀', '혀'), + ('혜', '혜'), + ('호', '호'), + ('화', '화'), + ('홰', '홰'), + ('회', '회'), + ('효', '효'), + ('후', '후'), + ('훠', '훠'), + ('훼', '훼'), + ('휘', '휘'), + ('휴', '휴'), + ('흐', '흐'), + ('희', '희'), + ('히', '히'), +]; + +pub const LVT: &'static [(char, char)] = &[ + ('각', '갛'), + ('객', '갷'), + ('갹', '걓'), + ('걕', '걯'), + ('걱', '겋'), + ('겍', '겧'), + ('격', '곃'), + ('곅', '곟'), + ('곡', '곻'), + ('곽', '괗'), + ('괙', '괳'), + ('괵', '굏'), + ('굑', '굫'), + ('국', '궇'), + ('궉', '궣'), + ('궥', '궿'), + ('귁', '귛'), + ('귝', '귷'), + ('극', '긓'), + ('긕', '긯'), + ('긱', '깋'), + ('깍', '깧'), + ('깩', '꺃'), + ('꺅', '꺟'), + ('꺡', '꺻'), + ('꺽', '껗'), + ('껙', '껳'), + ('껵', '꼏'), + ('꼑', '꼫'), + ('꼭', '꽇'), + ('꽉', '꽣'), + ('꽥', '꽿'), + ('꾁', '꾛'), + ('꾝', '꾷'), + ('꾹', '꿓'), + ('꿕', '꿯'), + ('꿱', '뀋'), + ('뀍', '뀧'), + ('뀩', '끃'), + ('끅', '끟'), + ('끡', '끻'), + ('끽', '낗'), + ('낙', '낳'), + ('낵', '냏'), + ('냑', '냫'), + ('냭', '넇'), + ('넉', '넣'), + ('넥', '넿'), + ('녁', '녛'), + ('녝', '녷'), + ('녹', '놓'), + ('놕', '놯'), + ('놱', '뇋'), + ('뇍', '뇧'), + ('뇩', '눃'), + ('눅', '눟'), + ('눡', '눻'), + ('눽', '뉗'), + ('뉙', '뉳'), + ('뉵', '늏'), + ('늑', '늫'), + ('늭', '닇'), + ('닉', '닣'), + ('닥', '닿'), + ('댁', '댛'), + ('댝', '댷'), + ('댹', '덓'), + ('덕', '덯'), + ('덱', '뎋'), + ('뎍', '뎧'), + ('뎩', '돃'), + ('독', '돟'), + ('돡', '돻'), + ('돽', '됗'), + ('됙', '됳'), + ('됵', '둏'), + ('둑', '둫'), + ('둭', '뒇'), + ('뒉', '뒣'), + ('뒥', '뒿'), + ('듁', '듛'), + ('득', '듷'), + ('듹', '딓'), + ('딕', '딯'), + ('딱', '땋'), + ('땍', '땧'), + ('땩', '떃'), + ('떅', '떟'), + ('떡', '떻'), + ('떽', '뗗'), + ('뗙', '뗳'), + ('뗵', '똏'), + ('똑', '똫'), + ('똭', '뙇'), + ('뙉', '뙣'), + ('뙥', '뙿'), + ('뚁', '뚛'), + ('뚝', '뚷'), + ('뚹', '뛓'), + ('뛕', '뛯'), + ('뛱', '뜋'), + ('뜍', '뜧'), + ('뜩', '띃'), + ('띅', '띟'), + ('띡', '띻'), + ('락', '랗'), + ('랙', '랳'), + ('략', '럏'), + ('럑', '럫'), + ('럭', '렇'), + ('렉', '렣'), + ('력', '렿'), + ('롁', '롛'), + ('록', '롷'), + ('롹', '뢓'), + ('뢕', '뢯'), + ('뢱', '룋'), + ('룍', '룧'), + ('룩', '뤃'), + ('뤅', '뤟'), + ('뤡', '뤻'), + ('뤽', '륗'), + ('륙', '륳'), + ('륵', '릏'), + ('릑', '릫'), + ('릭', '맇'), + ('막', '맣'), + ('맥', '맿'), + ('먁', '먛'), + ('먝', '먷'), + ('먹', '멓'), + ('멕', '멯'), + ('멱', '몋'), + ('몍', '몧'), + ('목', '뫃'), + ('뫅', '뫟'), + ('뫡', '뫻'), + ('뫽', '묗'), + ('묙', '묳'), + ('묵', '뭏'), + ('뭑', '뭫'), + ('뭭', '뮇'), + ('뮉', '뮣'), + ('뮥', '뮿'), + ('믁', '믛'), + ('믝', '믷'), + ('믹', '밓'), + ('박', '밯'), + ('백', '뱋'), + ('뱍', '뱧'), + ('뱩', '벃'), + ('벅', '벟'), + ('벡', '벻'), + ('벽', '볗'), + ('볙', '볳'), + ('복', '봏'), + ('봑', '봫'), + ('봭', '뵇'), + ('뵉', '뵣'), + ('뵥', '뵿'), + ('북', '붛'), + ('붝', '붷'), + ('붹', '뷓'), + ('뷕', '뷯'), + ('뷱', '븋'), + ('븍', '븧'), + ('븩', '빃'), + ('빅', '빟'), + ('빡', '빻'), + ('빽', '뺗'), + ('뺙', '뺳'), + ('뺵', '뻏'), + ('뻑', '뻫'), + ('뻭', '뼇'), + ('뼉', '뼣'), + ('뼥', '뼿'), + ('뽁', '뽛'), + ('뽝', '뽷'), + ('뽹', '뾓'), + ('뾕', '뾯'), + ('뾱', '뿋'), + ('뿍', '뿧'), + ('뿩', '쀃'), + ('쀅', '쀟'), + ('쀡', '쀻'), + ('쀽', '쁗'), + ('쁙', '쁳'), + ('쁵', '삏'), + ('삑', '삫'), + ('삭', '샇'), + ('색', '샣'), + ('샥', '샿'), + ('섁', '섛'), + ('석', '섷'), + ('섹', '셓'), + ('셕', '셯'), + ('셱', '솋'), + ('속', '솧'), + ('솩', '쇃'), + ('쇅', '쇟'), + ('쇡', '쇻'), + ('쇽', '숗'), + ('숙', '숳'), + ('숵', '쉏'), + ('쉑', '쉫'), + ('쉭', '슇'), + ('슉', '슣'), + ('슥', '슿'), + ('싁', '싛'), + ('식', '싷'), + ('싹', '쌓'), + ('쌕', '쌯'), + ('쌱', '썋'), + ('썍', '썧'), + ('썩', '쎃'), + ('쎅', '쎟'), + ('쎡', '쎻'), + ('쎽', '쏗'), + ('쏙', '쏳'), + ('쏵', '쐏'), + ('쐑', '쐫'), + ('쐭', '쑇'), + ('쑉', '쑣'), + ('쑥', '쑿'), + ('쒁', '쒛'), + ('쒝', '쒷'), + ('쒹', '쓓'), + ('쓕', '쓯'), + ('쓱', '씋'), + ('씍', '씧'), + ('씩', '앃'), + ('악', '앟'), + ('액', '앻'), + ('약', '얗'), + ('얙', '얳'), + ('억', '엏'), + ('엑', '엫'), + ('역', '옇'), + ('옉', '옣'), + ('옥', '옿'), + ('왁', '왛'), + ('왝', '왷'), + ('왹', '욓'), + ('욕', '욯'), + ('욱', '웋'), + ('웍', '웧'), + ('웩', '윃'), + ('윅', '윟'), + ('육', '윻'), + ('윽', '읗'), + ('읙', '읳'), + ('익', '잏'), + ('작', '잫'), + ('잭', '쟇'), + ('쟉', '쟣'), + ('쟥', '쟿'), + ('적', '젛'), + ('젝', '젷'), + ('젹', '졓'), + ('졕', '졯'), + ('족', '좋'), + ('좍', '좧'), + ('좩', '죃'), + ('죅', '죟'), + ('죡', '죻'), + ('죽', '줗'), + ('줙', '줳'), + ('줵', '쥏'), + ('쥑', '쥫'), + ('쥭', '즇'), + ('즉', '즣'), + ('즥', '즿'), + ('직', '짛'), + ('짝', '짷'), + ('짹', '쨓'), + ('쨕', '쨯'), + ('쨱', '쩋'), + ('쩍', '쩧'), + ('쩩', '쪃'), + ('쪅', '쪟'), + ('쪡', '쪻'), + ('쪽', '쫗'), + ('쫙', '쫳'), + ('쫵', '쬏'), + ('쬑', '쬫'), + ('쬭', '쭇'), + ('쭉', '쭣'), + ('쭥', '쭿'), + ('쮁', '쮛'), + ('쮝', '쮷'), + ('쮹', '쯓'), + ('쯕', '쯯'), + ('쯱', '찋'), + ('찍', '찧'), + ('착', '챃'), + ('책', '챟'), + ('챡', '챻'), + ('챽', '첗'), + ('척', '첳'), + ('첵', '쳏'), + ('쳑', '쳫'), + ('쳭', '촇'), + ('촉', '촣'), + ('촥', '촿'), + ('쵁', '쵛'), + ('쵝', '쵷'), + ('쵹', '춓'), + ('축', '춯'), + ('춱', '췋'), + ('췍', '췧'), + ('췩', '츃'), + ('츅', '츟'), + ('측', '츻'), + ('츽', '칗'), + ('칙', '칳'), + ('칵', '캏'), + ('캑', '캫'), + ('캭', '컇'), + ('컉', '컣'), + ('컥', '컿'), + ('켁', '켛'), + ('켝', '켷'), + ('켹', '콓'), + ('콕', '콯'), + ('콱', '쾋'), + ('쾍', '쾧'), + ('쾩', '쿃'), + ('쿅', '쿟'), + ('쿡', '쿻'), + ('쿽', '퀗'), + ('퀙', '퀳'), + ('퀵', '큏'), + ('큑', '큫'), + ('큭', '킇'), + ('킉', '킣'), + ('킥', '킿'), + ('탁', '탛'), + ('택', '탷'), + ('탹', '턓'), + ('턕', '턯'), + ('턱', '텋'), + ('텍', '텧'), + ('텩', '톃'), + ('톅', '톟'), + ('톡', '톻'), + ('톽', '퇗'), + ('퇙', '퇳'), + ('퇵', '툏'), + ('툑', '툫'), + ('툭', '퉇'), + ('퉉', '퉣'), + ('퉥', '퉿'), + ('튁', '튛'), + ('튝', '튷'), + ('특', '틓'), + ('틕', '틯'), + ('틱', '팋'), + ('팍', '팧'), + ('팩', '퍃'), + ('퍅', '퍟'), + ('퍡', '퍻'), + ('퍽', '펗'), + ('펙', '펳'), + ('펵', '폏'), + ('폑', '폫'), + ('폭', '퐇'), + ('퐉', '퐣'), + ('퐥', '퐿'), + ('푁', '푛'), + ('푝', '푷'), + ('푹', '풓'), + ('풕', '풯'), + ('풱', '퓋'), + ('퓍', '퓧'), + ('퓩', '픃'), + ('픅', '픟'), + ('픡', '픻'), + ('픽', '핗'), + ('학', '핳'), + ('핵', '햏'), + ('햑', '햫'), + ('햭', '헇'), + ('헉', '헣'), + ('헥', '헿'), + ('혁', '혛'), + ('혝', '혷'), + ('혹', '홓'), + ('확', '홯'), + ('홱', '횋'), + ('획', '횧'), + ('횩', '훃'), + ('훅', '훟'), + ('훡', '훻'), + ('훽', '휗'), + ('휙', '휳'), + ('휵', '흏'), + ('흑', '흫'), + ('흭', '힇'), + ('힉', '힣'), +]; + +pub const PREPEND: &'static [(char, char)] = &[ + ('\u{600}', '\u{605}'), + ('\u{6dd}', '\u{6dd}'), + ('\u{70f}', '\u{70f}'), + ('\u{8e2}', '\u{8e2}'), + ('ൎ', 'ൎ'), + ('\u{110bd}', '\u{110bd}'), + ('\u{110cd}', '\u{110cd}'), + ('𑇂', '𑇃'), + ('𑨺', '𑨺'), + ('\u{11a84}', '𑪉'), + ('𑵆', '𑵆'), +]; + +pub const REGIONAL_INDICATOR: &'static [(char, char)] = &[('🇦', '🇿')]; + +pub const SPACINGMARK: &'static [(char, char)] = &[ + ('ः', 'ः'), + ('ऻ', 'ऻ'), + ('ा', 'ी'), + ('ॉ', 'ौ'), + ('ॎ', 'ॏ'), + ('ং', 'ঃ'), + ('ি', 'ী'), + ('ে', 'ৈ'), + ('ো', 'ৌ'), + ('ਃ', 'ਃ'), + ('ਾ', 'ੀ'), + ('ઃ', 'ઃ'), + ('ા', 'ી'), + ('ૉ', 'ૉ'), + ('ો', 'ૌ'), + ('ଂ', 'ଃ'), + ('ୀ', 'ୀ'), + ('େ', 'ୈ'), + ('ୋ', 'ୌ'), + ('ி', 'ி'), + ('ு', 'ூ'), + ('ெ', 'ை'), + ('ொ', 'ௌ'), + ('ఁ', 'ః'), + ('ు', 'ౄ'), + ('ಂ', 'ಃ'), + ('ಾ', 'ಾ'), + ('ೀ', 'ು'), + ('ೃ', 'ೄ'), + ('ೇ', 'ೈ'), + ('ೊ', 'ೋ'), + ('ം', 'ഃ'), + ('ി', 'ീ'), + ('െ', 'ൈ'), + ('ൊ', 'ൌ'), + ('ං', 'ඃ'), + ('ැ', 'ෑ'), + ('ෘ', 'ෞ'), + ('ෲ', 'ෳ'), + ('ำ', 'ำ'), + ('ຳ', 'ຳ'), + ('༾', '༿'), + ('ཿ', 'ཿ'), + ('ေ', 'ေ'), + ('ျ', 'ြ'), + ('ၖ', 'ၗ'), + ('ႄ', 'ႄ'), + ('ា', 'ា'), + ('ើ', 'ៅ'), + ('ះ', 'ៈ'), + ('ᤣ', 'ᤦ'), + ('ᤩ', 'ᤫ'), + ('ᤰ', 'ᤱ'), + ('ᤳ', 'ᤸ'), + ('ᨙ', 'ᨚ'), + ('ᩕ', 'ᩕ'), + ('ᩗ', 'ᩗ'), + ('ᩭ', 'ᩲ'), + ('ᬄ', 'ᬄ'), + ('ᬻ', 'ᬻ'), + ('ᬽ', 'ᭁ'), + ('ᭃ', '᭄'), + ('ᮂ', 'ᮂ'), + ('ᮡ', 'ᮡ'), + ('ᮦ', 'ᮧ'), + ('᮪', '᮪'), + ('ᯧ', 'ᯧ'), + ('ᯪ', 'ᯬ'), + ('ᯮ', 'ᯮ'), + ('᯲', '᯳'), + ('ᰤ', 'ᰫ'), + ('ᰴ', 'ᰵ'), + ('᳡', '᳡'), + ('᳷', '᳷'), + ('ꠣ', 'ꠤ'), + ('ꠧ', 'ꠧ'), + ('ꢀ', 'ꢁ'), + ('ꢴ', 'ꣃ'), + ('ꥒ', '꥓'), + ('ꦃ', 'ꦃ'), + ('ꦴ', 'ꦵ'), + ('ꦺ', 'ꦻ'), + ('ꦾ', '꧀'), + ('ꨯ', 'ꨰ'), + ('ꨳ', 'ꨴ'), + ('ꩍ', 'ꩍ'), + ('ꫫ', 'ꫫ'), + ('ꫮ', 'ꫯ'), + ('ꫵ', 'ꫵ'), + ('ꯣ', 'ꯤ'), + ('ꯦ', 'ꯧ'), + ('ꯩ', 'ꯪ'), + ('꯬', '꯬'), + ('𑀀', '𑀀'), + ('𑀂', '𑀂'), + ('𑂂', '𑂂'), + ('𑂰', '𑂲'), + ('𑂷', '𑂸'), + ('𑄬', '𑄬'), + ('𑅅', '𑅆'), + ('𑆂', '𑆂'), + ('𑆳', '𑆵'), + ('𑆿', '𑇀'), + ('𑈬', '𑈮'), + ('𑈲', '𑈳'), + ('𑈵', '𑈵'), + ('𑋠', '𑋢'), + ('𑌂', '𑌃'), + ('𑌿', '𑌿'), + ('𑍁', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('𑍢', '𑍣'), + ('𑐵', '𑐷'), + ('𑑀', '𑑁'), + ('𑑅', '𑑅'), + ('𑒱', '𑒲'), + ('𑒹', '𑒹'), + ('𑒻', '𑒼'), + ('𑒾', '𑒾'), + ('𑓁', '𑓁'), + ('𑖰', '𑖱'), + ('𑖸', '𑖻'), + ('𑖾', '𑖾'), + ('𑘰', '𑘲'), + ('𑘻', '𑘼'), + ('𑘾', '𑘾'), + ('𑚬', '𑚬'), + ('𑚮', '𑚯'), + ('𑚶', '𑚶'), + ('𑜠', '𑜡'), + ('𑜦', '𑜦'), + ('𑠬', '𑠮'), + ('𑠸', '𑠸'), + ('\u{119d1}', '\u{119d3}'), + ('\u{119dc}', '\u{119df}'), + ('\u{119e4}', '\u{119e4}'), + ('𑨹', '𑨹'), + ('𑩗', '𑩘'), + ('𑪗', '𑪗'), + ('𑰯', '𑰯'), + ('𑰾', '𑰾'), + ('𑲩', '𑲩'), + ('𑲱', '𑲱'), + ('𑲴', '𑲴'), + ('𑶊', '𑶎'), + ('𑶓', '𑶔'), + ('𑶖', '𑶖'), + ('𑻵', '𑻶'), + ('𖽑', '\u{16f87}'), + ('𝅦', '𝅦'), + ('𝅭', '𝅭'), +]; + +pub const T: &'static [(char, char)] = &[('ᆨ', 'ᇿ'), ('ퟋ', 'ퟻ')]; + +pub const V: &'static [(char, char)] = &[('ᅠ', 'ᆧ'), ('ힰ', 'ퟆ')]; + +pub const ZWJ: &'static [(char, char)] = &[('\u{200d}', '\u{200d}')]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/mod.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/mod.rs new file mode 100644 index 0000000..20736c7 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/mod.rs @@ -0,0 +1,57 @@ +#[cfg(feature = "unicode-age")] +pub mod age; + +#[cfg(feature = "unicode-case")] +pub mod case_folding_simple; + +#[cfg(feature = "unicode-gencat")] +pub mod general_category; + +#[cfg(feature = "unicode-segment")] +pub mod grapheme_cluster_break; + +#[cfg(all(feature = "unicode-perl", not(feature = "unicode-gencat")))] +#[allow(dead_code)] +pub mod perl_decimal; + +#[cfg(all(feature = "unicode-perl", not(feature = "unicode-bool")))] +#[allow(dead_code)] +pub mod perl_space; + +#[cfg(feature = "unicode-perl")] +pub mod perl_word; + +#[cfg(feature = "unicode-bool")] +pub mod property_bool; + +#[cfg(any( + feature = "unicode-age", + feature = "unicode-bool", + feature = "unicode-gencat", + feature = "unicode-perl", + feature = "unicode-script", + feature = "unicode-segment", +))] +pub mod property_names; + +#[cfg(any( + feature = "unicode-age", + feature = "unicode-bool", + feature = "unicode-gencat", + feature = "unicode-perl", + feature = "unicode-script", + feature = "unicode-segment", +))] +pub mod property_values; + +#[cfg(feature = "unicode-script")] +pub mod script; + +#[cfg(feature = "unicode-script")] +pub mod script_extension; + +#[cfg(feature = "unicode-segment")] +pub mod sentence_break; + +#[cfg(feature = "unicode-segment")] +pub mod word_break; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/perl_decimal.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/perl_decimal.rs new file mode 100644 index 0000000..8f6a046 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/perl_decimal.rs @@ -0,0 +1,70 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate general-category /tmp/ucd/12.1.0/ --chars --include decimalnumber +// +// ucd-generate is available on crates.io. + +pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] = + &[("Decimal_Number", DECIMAL_NUMBER)]; + +pub const DECIMAL_NUMBER: &'static [(char, char)] = &[ + ('0', '9'), + ('٠', '٩'), + ('۰', '۹'), + ('߀', '߉'), + ('०', '९'), + ('০', '৯'), + ('੦', '੯'), + ('૦', '૯'), + ('୦', '୯'), + ('௦', '௯'), + ('౦', '౯'), + ('೦', '೯'), + ('൦', '൯'), + ('෦', '෯'), + ('๐', '๙'), + ('໐', '໙'), + ('༠', '༩'), + ('၀', '၉'), + ('႐', '႙'), + ('០', '៩'), + ('᠐', '᠙'), + ('᥆', '᥏'), + ('᧐', '᧙'), + ('᪀', '᪉'), + ('᪐', '᪙'), + ('᭐', '᭙'), + ('᮰', '᮹'), + ('᱀', '᱉'), + ('᱐', '᱙'), + ('꘠', '꘩'), + ('꣐', '꣙'), + ('꤀', '꤉'), + ('꧐', '꧙'), + ('꧰', '꧹'), + ('꩐', '꩙'), + ('꯰', '꯹'), + ('0', '9'), + ('𐒠', '𐒩'), + ('𐴰', '𐴹'), + ('𑁦', '𑁯'), + ('𑃰', '𑃹'), + ('𑄶', '𑄿'), + ('𑇐', '𑇙'), + ('𑋰', '𑋹'), + ('𑑐', '𑑙'), + ('𑓐', '𑓙'), + ('𑙐', '𑙙'), + ('𑛀', '𑛉'), + ('𑜰', '𑜹'), + ('𑣠', '𑣩'), + ('𑱐', '𑱙'), + ('𑵐', '𑵙'), + ('𑶠', '𑶩'), + ('𖩠', '𖩩'), + ('𖭐', '𖭙'), + ('𝟎', '𝟿'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e2f0}', '\u{1e2f9}'), + ('𞥐', '𞥙'), +]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/perl_space.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/perl_space.rs new file mode 100644 index 0000000..5157245 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/perl_space.rs @@ -0,0 +1,21 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate property-bool /tmp/ucd/12.1.0/ --chars --include whitespace +// +// ucd-generate is available on crates.io. + +pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] = + &[("White_Space", WHITE_SPACE)]; + +pub const WHITE_SPACE: &'static [(char, char)] = &[ + ('\t', '\r'), + (' ', ' '), + ('\u{85}', '\u{85}'), + ('\u{a0}', '\u{a0}'), + ('\u{1680}', '\u{1680}'), + ('\u{2000}', '\u{200a}'), + ('\u{2028}', '\u{2029}'), + ('\u{202f}', '\u{202f}'), + ('\u{205f}', '\u{205f}'), + ('\u{3000}', '\u{3000}'), +]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/perl_word.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/perl_word.rs new file mode 100644 index 0000000..f4f5706 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/perl_word.rs @@ -0,0 +1,725 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate perl-word /tmp/ucd/12.1.0/ --chars +// +// ucd-generate is available on crates.io. + +pub const PERL_WORD: &'static [(char, char)] = &[ + ('0', '9'), + ('A', 'Z'), + ('_', '_'), + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ˁ'), + ('ˆ', 'ˑ'), + ('ˠ', 'ˤ'), + ('ˬ', 'ˬ'), + ('ˮ', 'ˮ'), + ('\u{300}', 'ʹ'), + ('Ͷ', 'ͷ'), + ('ͺ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϵ'), + ('Ϸ', 'ҁ'), + ('\u{483}', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՙ', 'ՙ'), + ('ՠ', 'ֈ'), + ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('א', 'ת'), + ('ׯ', 'ײ'), + ('\u{610}', '\u{61a}'), + ('ؠ', '٩'), + ('ٮ', 'ۓ'), + ('ە', '\u{6dc}'), + ('\u{6df}', '\u{6e8}'), + ('\u{6ea}', 'ۼ'), + ('ۿ', 'ۿ'), + ('ܐ', '\u{74a}'), + ('ݍ', 'ޱ'), + ('߀', 'ߵ'), + ('ߺ', 'ߺ'), + ('\u{7fd}', '\u{7fd}'), + ('ࠀ', '\u{82d}'), + ('ࡀ', '\u{85b}'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', '\u{963}'), + ('०', '९'), + ('ॱ', 'ঃ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('\u{9bc}', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', 'ৎ'), + ('\u{9d7}', '\u{9d7}'), + ('ড়', 'ঢ়'), + ('য়', '\u{9e3}'), + ('০', 'ৱ'), + ('ৼ', 'ৼ'), + ('\u{9fe}', '\u{9fe}'), + ('\u{a01}', 'ਃ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('\u{a3c}', '\u{a3c}'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('੦', '\u{a75}'), + ('\u{a81}', 'ઃ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('\u{abc}', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', '\u{acd}'), + ('ૐ', 'ૐ'), + ('ૠ', '\u{ae3}'), + ('૦', '૯'), + ('ૹ', '\u{aff}'), + ('\u{b01}', 'ଃ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('\u{b3c}', '\u{b44}'), + ('େ', 'ୈ'), + ('ୋ', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', '\u{b63}'), + ('୦', '୯'), + ('ୱ', 'ୱ'), + ('\u{b82}', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', '\u{bcd}'), + ('ௐ', 'ௐ'), + ('\u{bd7}', '\u{bd7}'), + ('௦', '௯'), + ('\u{c00}', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('ౘ', 'ౚ'), + ('ౠ', '\u{c63}'), + ('౦', '౯'), + ('ಀ', 'ಃ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('\u{cbc}', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('ೞ', 'ೞ'), + ('ೠ', '\u{ce3}'), + ('೦', '೯'), + ('ೱ', 'ೲ'), + ('\u{d00}', 'ഃ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', '\u{d44}'), + ('െ', 'ൈ'), + ('ൊ', 'ൎ'), + ('ൔ', '\u{d57}'), + ('ൟ', '\u{d63}'), + ('൦', '൯'), + ('ൺ', 'ൿ'), + ('ං', 'ඃ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('෦', '෯'), + ('ෲ', 'ෳ'), + ('ก', '\u{e3a}'), + ('เ', '\u{e4e}'), + ('๐', '๙'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('\u{ec8}', '\u{ecd}'), + ('໐', '໙'), + ('ໜ', 'ໟ'), + ('ༀ', 'ༀ'), + ('\u{f18}', '\u{f19}'), + ('༠', '༩'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('༾', 'ཇ'), + ('ཉ', 'ཬ'), + ('\u{f71}', '\u{f84}'), + ('\u{f86}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), + ('က', '၉'), + ('ၐ', '\u{109d}'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჼ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('\u{135d}', '\u{135f}'), + ('ᎀ', 'ᎏ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᐁ', 'ᙬ'), + ('ᙯ', 'ᙿ'), + ('ᚁ', 'ᚚ'), + ('ᚠ', 'ᛪ'), + ('ᛮ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', '\u{1714}'), + ('ᜠ', '\u{1734}'), + ('ᝀ', '\u{1753}'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('\u{1772}', '\u{1773}'), + ('ក', '\u{17d3}'), + ('ៗ', 'ៗ'), + ('ៜ', '\u{17dd}'), + ('០', '៩'), + ('\u{180b}', '\u{180d}'), + ('᠐', '᠙'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', '\u{193b}'), + ('᥆', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('ᦀ', 'ᦫ'), + ('ᦰ', 'ᧉ'), + ('᧐', '᧙'), + ('ᨀ', '\u{1a1b}'), + ('ᨠ', '\u{1a5e}'), + ('\u{1a60}', '\u{1a7c}'), + ('\u{1a7f}', '᪉'), + ('᪐', '᪙'), + ('ᪧ', 'ᪧ'), + ('\u{1ab0}', '\u{1abe}'), + ('\u{1b00}', 'ᭋ'), + ('᭐', '᭙'), + ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', '᯳'), + ('ᰀ', '\u{1c37}'), + ('᱀', '᱉'), + ('ᱍ', 'ᱽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1cfa}'), + ('ᴀ', '\u{1df9}'), + ('\u{1dfb}', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('\u{200c}', '\u{200d}'), + ('‿', '⁀'), + ('⁔', '⁔'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('\u{20d0}', '\u{20f0}'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('ℙ', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℭ'), + ('ℯ', 'ℹ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ↈ'), + ('Ⓐ', 'ⓩ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⳤ'), + ('Ⳬ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ⴰ', 'ⵧ'), + ('ⵯ', 'ⵯ'), + ('\u{2d7f}', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('\u{2de0}', '\u{2dff}'), + ('ⸯ', 'ⸯ'), + ('々', '〇'), + ('〡', '\u{302f}'), + ('〱', '〵'), + ('〸', '〼'), + ('ぁ', 'ゖ'), + ('\u{3099}', '\u{309a}'), + ('ゝ', 'ゟ'), + ('ァ', 'ヺ'), + ('ー', 'ヿ'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('ㆠ', 'ㆺ'), + ('ㇰ', 'ㇿ'), + ('㐀', '䶵'), + ('一', '鿯'), + ('ꀀ', 'ꒌ'), + ('ꓐ', 'ꓽ'), + ('ꔀ', 'ꘌ'), + ('ꘐ', 'ꘫ'), + ('Ꙁ', '\u{a672}'), + ('\u{a674}', '\u{a67d}'), + ('ꙿ', '\u{a6f1}'), + ('ꜗ', 'ꜟ'), + ('Ꜣ', 'ꞈ'), + ('Ꞌ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꠧ'), + ('ꡀ', 'ꡳ'), + ('ꢀ', '\u{a8c5}'), + ('꣐', '꣙'), + ('\u{a8e0}', 'ꣷ'), + ('ꣻ', 'ꣻ'), + ('ꣽ', '\u{a92d}'), + ('ꤰ', '꥓'), + ('ꥠ', 'ꥼ'), + ('\u{a980}', '꧀'), + ('ꧏ', '꧙'), + ('ꧠ', 'ꧾ'), + ('ꨀ', '\u{aa36}'), + ('ꩀ', 'ꩍ'), + ('꩐', '꩙'), + ('ꩠ', 'ꩶ'), + ('ꩺ', 'ꫂ'), + ('ꫛ', 'ꫝ'), + ('ꫠ', 'ꫯ'), + ('ꫲ', '\u{aaf6}'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', '\u{ab67}'), + ('ꭰ', 'ꯪ'), + ('꯬', '\u{abed}'), + ('꯰', '꯹'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('豈', '舘'), + ('並', '龎'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('יִ', 'ﬨ'), + ('שׁ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﮱ'), + ('ﯓ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷻ'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2f}'), + ('︳', '︴'), + ('﹍', '﹏'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('0', '9'), + ('A', 'Z'), + ('_', '_'), + ('a', 'z'), + ('ヲ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐅀', '𐅴'), + ('\u{101fd}', '\u{101fd}'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('\u{102e0}', '\u{102e0}'), + ('𐌀', '𐌟'), + ('𐌭', '𐍊'), + ('𐍐', '\u{1037a}'), + ('𐎀', '𐎝'), + ('𐎠', '𐏃'), + ('𐏈', '𐏏'), + ('𐏑', '𐏕'), + ('𐐀', '𐒝'), + ('𐒠', '𐒩'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡠', '𐡶'), + ('𐢀', '𐢞'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐤀', '𐤕'), + ('𐤠', '𐤹'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𐨀', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), + ('𐩠', '𐩼'), + ('𐪀', '𐪜'), + ('𐫀', '𐫇'), + ('𐫉', '\u{10ae6}'), + ('𐬀', '𐬵'), + ('𐭀', '𐭕'), + ('𐭠', '𐭲'), + ('𐮀', '𐮑'), + ('𐰀', '𐱈'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𐴀', '\u{10d27}'), + ('𐴰', '𐴹'), + ('𐼀', '𐼜'), + ('𐼧', '𐼧'), + ('𐼰', '\u{10f50}'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀀', '\u{11046}'), + ('𑁦', '𑁯'), + ('\u{1107f}', '\u{110ba}'), + ('𑃐', '𑃨'), + ('𑃰', '𑃹'), + ('\u{11100}', '\u{11134}'), + ('𑄶', '𑄿'), + ('𑅄', '𑅆'), + ('𑅐', '\u{11173}'), + ('𑅶', '𑅶'), + ('\u{11180}', '𑇄'), + ('\u{111c9}', '\u{111cc}'), + ('𑇐', '𑇚'), + ('𑇜', '𑇜'), + ('𑈀', '𑈑'), + ('𑈓', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊨'), + ('𑊰', '\u{112ea}'), + ('𑋰', '𑋹'), + ('\u{11300}', '𑌃'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('\u{1133b}', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('𑍐', '𑍐'), + ('\u{11357}', '\u{11357}'), + ('𑍝', '𑍣'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('𑐀', '𑑊'), + ('𑑐', '𑑙'), + ('\u{1145e}', '\u{1145f}'), + ('𑒀', '𑓅'), + ('𑓇', '𑓇'), + ('𑓐', '𑓙'), + ('𑖀', '\u{115b5}'), + ('𑖸', '\u{115c0}'), + ('𑗘', '\u{115dd}'), + ('𑘀', '\u{11640}'), + ('𑙄', '𑙄'), + ('𑙐', '𑙙'), + ('𑚀', '\u{116b8}'), + ('𑛀', '𑛉'), + ('𑜀', '𑜚'), + ('\u{1171d}', '\u{1172b}'), + ('𑜰', '𑜹'), + ('𑠀', '\u{1183a}'), + ('𑢠', '𑣩'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d7}'), + ('\u{119da}', '\u{119e1}'), + ('\u{119e3}', '\u{119e4}'), + ('𑨀', '\u{11a3e}'), + ('\u{11a47}', '\u{11a47}'), + ('𑩐', '\u{11a99}'), + ('𑪝', '𑪝'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '\u{11c36}'), + ('\u{11c38}', '𑱀'), + ('𑱐', '𑱙'), + ('𑱲', '𑲏'), + ('\u{11c92}', '\u{11ca7}'), + ('𑲩', '\u{11cb6}'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d47}'), + ('𑵐', '𑵙'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '𑶘'), + ('𑶠', '𑶩'), + ('𑻠', '𑻶'), + ('𒀀', '𒎙'), + ('𒐀', '𒑮'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖩠', '𖩩'), + ('𖫐', '𖫭'), + ('\u{16af0}', '\u{16af4}'), + ('𖬀', '\u{16b36}'), + ('𖭀', '𖭃'), + ('𖭐', '𖭙'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖹀', '𖹿'), + ('𖼀', '\u{16f4a}'), + ('\u{16f4f}', '\u{16f87}'), + ('\u{16f8f}', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛀀', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('𛅰', '𛋻'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d165}', '\u{1d169}'), + ('𝅭', '\u{1d172}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1d242}', '\u{1d244}'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('𝟎', '𝟿'), + ('\u{1da00}', '\u{1da36}'), + ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), + ('\u{1da84}', '\u{1da84}'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e130}', '\u{1e13d}'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e14e}', '\u{1e14e}'), + ('\u{1e2c0}', '\u{1e2f9}'), + ('𞠀', '𞣄'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('𞤀', '\u{1e94b}'), + ('𞥐', '𞥙'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('🄰', '🅉'), + ('🅐', '🅩'), + ('🅰', '🆉'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), + ('\u{e0100}', '\u{e01ef}'), +]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/property_bool.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/property_bool.rs new file mode 100644 index 0000000..efe6eb3 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/property_bool.rs @@ -0,0 +1,10677 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate property-bool /tmp/ucd/12.1.0/ --chars +// +// ucd-generate is available on crates.io. + +pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] = &[ + ("ASCII_Hex_Digit", ASCII_HEX_DIGIT), + ("Alphabetic", ALPHABETIC), + ("Bidi_Control", BIDI_CONTROL), + ("Case_Ignorable", CASE_IGNORABLE), + ("Cased", CASED), + ("Changes_When_Casefolded", CHANGES_WHEN_CASEFOLDED), + ("Changes_When_Casemapped", CHANGES_WHEN_CASEMAPPED), + ("Changes_When_Lowercased", CHANGES_WHEN_LOWERCASED), + ("Changes_When_Titlecased", CHANGES_WHEN_TITLECASED), + ("Changes_When_Uppercased", CHANGES_WHEN_UPPERCASED), + ("Dash", DASH), + ("Default_Ignorable_Code_Point", DEFAULT_IGNORABLE_CODE_POINT), + ("Deprecated", DEPRECATED), + ("Diacritic", DIACRITIC), + ("Emoji", EMOJI), + ("Emoji_Component", EMOJI_COMPONENT), + ("Emoji_Modifier", EMOJI_MODIFIER), + ("Emoji_Modifier_Base", EMOJI_MODIFIER_BASE), + ("Emoji_Presentation", EMOJI_PRESENTATION), + ("Extended_Pictographic", EXTENDED_PICTOGRAPHIC), + ("Extender", EXTENDER), + ("Grapheme_Base", GRAPHEME_BASE), + ("Grapheme_Extend", GRAPHEME_EXTEND), + ("Grapheme_Link", GRAPHEME_LINK), + ("Hex_Digit", HEX_DIGIT), + ("Hyphen", HYPHEN), + ("IDS_Binary_Operator", IDS_BINARY_OPERATOR), + ("IDS_Trinary_Operator", IDS_TRINARY_OPERATOR), + ("ID_Continue", ID_CONTINUE), + ("ID_Start", ID_START), + ("Ideographic", IDEOGRAPHIC), + ("Join_Control", JOIN_CONTROL), + ("Logical_Order_Exception", LOGICAL_ORDER_EXCEPTION), + ("Lowercase", LOWERCASE), + ("Math", MATH), + ("Noncharacter_Code_Point", NONCHARACTER_CODE_POINT), + ("Other_Alphabetic", OTHER_ALPHABETIC), + ("Other_Default_Ignorable_Code_Point", OTHER_DEFAULT_IGNORABLE_CODE_POINT), + ("Other_Grapheme_Extend", OTHER_GRAPHEME_EXTEND), + ("Other_ID_Continue", OTHER_ID_CONTINUE), + ("Other_ID_Start", OTHER_ID_START), + ("Other_Lowercase", OTHER_LOWERCASE), + ("Other_Math", OTHER_MATH), + ("Other_Uppercase", OTHER_UPPERCASE), + ("Pattern_Syntax", PATTERN_SYNTAX), + ("Pattern_White_Space", PATTERN_WHITE_SPACE), + ("Prepended_Concatenation_Mark", PREPENDED_CONCATENATION_MARK), + ("Quotation_Mark", QUOTATION_MARK), + ("Radical", RADICAL), + ("Regional_Indicator", REGIONAL_INDICATOR), + ("Sentence_Terminal", SENTENCE_TERMINAL), + ("Soft_Dotted", SOFT_DOTTED), + ("Terminal_Punctuation", TERMINAL_PUNCTUATION), + ("Unified_Ideograph", UNIFIED_IDEOGRAPH), + ("Uppercase", UPPERCASE), + ("Variation_Selector", VARIATION_SELECTOR), + ("White_Space", WHITE_SPACE), + ("XID_Continue", XID_CONTINUE), + ("XID_Start", XID_START), +]; + +pub const ASCII_HEX_DIGIT: &'static [(char, char)] = + &[('0', '9'), ('A', 'F'), ('a', 'f')]; + +pub const ALPHABETIC: &'static [(char, char)] = &[ + ('A', 'Z'), + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ˁ'), + ('ˆ', 'ˑ'), + ('ˠ', 'ˤ'), + ('ˬ', 'ˬ'), + ('ˮ', 'ˮ'), + ('\u{345}', '\u{345}'), + ('Ͱ', 'ʹ'), + ('Ͷ', 'ͷ'), + ('ͺ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϵ'), + ('Ϸ', 'ҁ'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՙ', 'ՙ'), + ('ՠ', 'ֈ'), + ('\u{5b0}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('א', 'ת'), + ('ׯ', 'ײ'), + ('\u{610}', '\u{61a}'), + ('ؠ', '\u{657}'), + ('\u{659}', '\u{65f}'), + ('ٮ', 'ۓ'), + ('ە', '\u{6dc}'), + ('\u{6e1}', '\u{6e8}'), + ('\u{6ed}', 'ۯ'), + ('ۺ', 'ۼ'), + ('ۿ', 'ۿ'), + ('ܐ', '\u{73f}'), + ('ݍ', 'ޱ'), + ('ߊ', 'ߪ'), + ('ߴ', 'ߵ'), + ('ߺ', 'ߺ'), + ('ࠀ', '\u{817}'), + ('ࠚ', '\u{82c}'), + ('ࡀ', 'ࡘ'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('\u{8d4}', '\u{8df}'), + ('\u{8e3}', '\u{8e9}'), + ('\u{8f0}', 'ऻ'), + ('ऽ', 'ौ'), + ('ॎ', 'ॐ'), + ('\u{955}', '\u{963}'), + ('ॱ', 'ঃ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('ঽ', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', 'ৌ'), + ('ৎ', 'ৎ'), + ('\u{9d7}', '\u{9d7}'), + ('ড়', 'ঢ়'), + ('য়', '\u{9e3}'), + ('ৰ', 'ৱ'), + ('ৼ', 'ৼ'), + ('\u{a01}', 'ਃ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4c}'), + ('\u{a51}', '\u{a51}'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('\u{a70}', '\u{a75}'), + ('\u{a81}', 'ઃ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('ઽ', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', 'ૌ'), + ('ૐ', 'ૐ'), + ('ૠ', '\u{ae3}'), + ('ૹ', '\u{afc}'), + ('\u{b01}', 'ଃ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('ଽ', '\u{b44}'), + ('େ', 'ୈ'), + ('ୋ', 'ୌ'), + ('\u{b56}', '\u{b57}'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', '\u{b63}'), + ('ୱ', 'ୱ'), + ('\u{b82}', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', 'ௌ'), + ('ௐ', 'ௐ'), + ('\u{bd7}', '\u{bd7}'), + ('\u{c00}', 'ః'), + ('అ', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4c}'), + ('\u{c55}', '\u{c56}'), + ('ౘ', 'ౚ'), + ('ౠ', '\u{c63}'), + ('ಀ', 'ಃ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('ಽ', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccc}'), + ('\u{cd5}', '\u{cd6}'), + ('ೞ', 'ೞ'), + ('ೠ', '\u{ce3}'), + ('ೱ', 'ೲ'), + ('\u{d00}', 'ഃ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', 'ഺ'), + ('ഽ', '\u{d44}'), + ('െ', 'ൈ'), + ('ൊ', 'ൌ'), + ('ൎ', 'ൎ'), + ('ൔ', '\u{d57}'), + ('ൟ', '\u{d63}'), + ('ൺ', 'ൿ'), + ('ං', 'ඃ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('ෲ', 'ෳ'), + ('ก', '\u{e3a}'), + ('เ', 'ๆ'), + ('\u{e4d}', '\u{e4d}'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', '\u{eb9}'), + ('\u{ebb}', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('\u{ecd}', '\u{ecd}'), + ('ໜ', 'ໟ'), + ('ༀ', 'ༀ'), + ('ཀ', 'ཇ'), + ('ཉ', 'ཬ'), + ('\u{f71}', '\u{f81}'), + ('ྈ', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('က', '\u{1036}'), + ('း', 'း'), + ('ျ', 'ဿ'), + ('ၐ', 'ႏ'), + ('ႚ', '\u{109d}'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჼ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('ᎀ', 'ᎏ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᐁ', 'ᙬ'), + ('ᙯ', 'ᙿ'), + ('ᚁ', 'ᚚ'), + ('ᚠ', 'ᛪ'), + ('ᛮ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', '\u{1713}'), + ('ᜠ', '\u{1733}'), + ('ᝀ', '\u{1753}'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('\u{1772}', '\u{1773}'), + ('ក', 'ឳ'), + ('ា', 'ៈ'), + ('ៗ', 'ៗ'), + ('ៜ', 'ៜ'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', 'ᤸ'), + ('ᥐ', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('ᦀ', 'ᦫ'), + ('ᦰ', 'ᧉ'), + ('ᨀ', '\u{1a1b}'), + ('ᨠ', '\u{1a5e}'), + ('ᩡ', '\u{1a74}'), + ('ᪧ', 'ᪧ'), + ('\u{1b00}', 'ᬳ'), + ('ᬵ', 'ᭃ'), + ('ᭅ', 'ᭋ'), + ('\u{1b80}', '\u{1ba9}'), + ('\u{1bac}', 'ᮯ'), + ('ᮺ', 'ᯥ'), + ('ᯧ', '\u{1bf1}'), + ('ᰀ', '\u{1c36}'), + ('ᱍ', 'ᱏ'), + ('ᱚ', 'ᱽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ᳩ', 'ᳬ'), + ('ᳮ', 'ᳳ'), + ('ᳵ', 'ᳶ'), + ('\u{1cfa}', '\u{1cfa}'), + ('ᴀ', 'ᶿ'), + ('\u{1de7}', '\u{1df4}'), + ('Ḁ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('ℙ', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℭ'), + ('ℯ', 'ℹ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ↈ'), + ('Ⓐ', 'ⓩ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⳤ'), + ('Ⳬ', 'ⳮ'), + ('Ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ⴰ', 'ⵧ'), + ('ⵯ', 'ⵯ'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('\u{2de0}', '\u{2dff}'), + ('ⸯ', 'ⸯ'), + ('々', '〇'), + ('〡', '〩'), + ('〱', '〵'), + ('〸', '〼'), + ('ぁ', 'ゖ'), + ('ゝ', 'ゟ'), + ('ァ', 'ヺ'), + ('ー', 'ヿ'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('ㆠ', 'ㆺ'), + ('ㇰ', 'ㇿ'), + ('㐀', '䶵'), + ('一', '鿯'), + ('ꀀ', 'ꒌ'), + ('ꓐ', 'ꓽ'), + ('ꔀ', 'ꘌ'), + ('ꘐ', 'ꘟ'), + ('ꘪ', 'ꘫ'), + ('Ꙁ', 'ꙮ'), + ('\u{a674}', '\u{a67b}'), + ('ꙿ', 'ꛯ'), + ('ꜗ', 'ꜟ'), + ('Ꜣ', 'ꞈ'), + ('Ꞌ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꠅ'), + ('ꠇ', 'ꠧ'), + ('ꡀ', 'ꡳ'), + ('ꢀ', 'ꣃ'), + ('\u{a8c5}', '\u{a8c5}'), + ('ꣲ', 'ꣷ'), + ('ꣻ', 'ꣻ'), + ('ꣽ', '\u{a8ff}'), + ('ꤊ', '\u{a92a}'), + ('ꤰ', 'ꥒ'), + ('ꥠ', 'ꥼ'), + ('\u{a980}', 'ꦲ'), + ('ꦴ', 'ꦿ'), + ('ꧏ', 'ꧏ'), + ('ꧠ', 'ꧯ'), + ('ꧺ', 'ꧾ'), + ('ꨀ', '\u{aa36}'), + ('ꩀ', 'ꩍ'), + ('ꩠ', 'ꩶ'), + ('ꩺ', '\u{aabe}'), + ('ꫀ', 'ꫀ'), + ('ꫂ', 'ꫂ'), + ('ꫛ', 'ꫝ'), + ('ꫠ', 'ꫯ'), + ('ꫲ', 'ꫵ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', '\u{ab67}'), + ('ꭰ', 'ꯪ'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('豈', '舘'), + ('並', '龎'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('יִ', 'ﬨ'), + ('שׁ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﮱ'), + ('ﯓ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷻ'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('A', 'Z'), + ('a', 'z'), + ('ヲ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐅀', '𐅴'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('𐌀', '𐌟'), + ('𐌭', '𐍊'), + ('𐍐', '\u{1037a}'), + ('𐎀', '𐎝'), + ('𐎠', '𐏃'), + ('𐏈', '𐏏'), + ('𐏑', '𐏕'), + ('𐐀', '𐒝'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡠', '𐡶'), + ('𐢀', '𐢞'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐤀', '𐤕'), + ('𐤠', '𐤹'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𐨀', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('𐩠', '𐩼'), + ('𐪀', '𐪜'), + ('𐫀', '𐫇'), + ('𐫉', '𐫤'), + ('𐬀', '𐬵'), + ('𐭀', '𐭕'), + ('𐭠', '𐭲'), + ('𐮀', '𐮑'), + ('𐰀', '𐱈'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𐴀', '\u{10d27}'), + ('𐼀', '𐼜'), + ('𐼧', '𐼧'), + ('𐼰', '𐽅'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀀', '\u{11045}'), + ('𑂂', '𑂸'), + ('𑃐', '𑃨'), + ('\u{11100}', '\u{11132}'), + ('𑅄', '𑅆'), + ('𑅐', '𑅲'), + ('𑅶', '𑅶'), + ('\u{11180}', '𑆿'), + ('𑇁', '𑇄'), + ('𑇚', '𑇚'), + ('𑇜', '𑇜'), + ('𑈀', '𑈑'), + ('𑈓', '\u{11234}'), + ('\u{11237}', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊨'), + ('𑊰', '\u{112e8}'), + ('\u{11300}', '𑌃'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('𑌽', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍌'), + ('𑍐', '𑍐'), + ('\u{11357}', '\u{11357}'), + ('𑍝', '𑍣'), + ('𑐀', '𑑁'), + ('\u{11443}', '𑑅'), + ('𑑇', '𑑊'), + ('\u{1145f}', '\u{1145f}'), + ('𑒀', '𑓁'), + ('𑓄', '𑓅'), + ('𑓇', '𑓇'), + ('𑖀', '\u{115b5}'), + ('𑖸', '𑖾'), + ('𑗘', '\u{115dd}'), + ('𑘀', '𑘾'), + ('\u{11640}', '\u{11640}'), + ('𑙄', '𑙄'), + ('𑚀', '\u{116b5}'), + ('\u{116b8}', '\u{116b8}'), + ('𑜀', '𑜚'), + ('\u{1171d}', '\u{1172a}'), + ('𑠀', '𑠸'), + ('𑢠', '𑣟'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d7}'), + ('\u{119da}', '\u{119df}'), + ('\u{119e1}', '\u{119e1}'), + ('\u{119e3}', '\u{119e4}'), + ('𑨀', '𑨲'), + ('\u{11a35}', '\u{11a3e}'), + ('𑩐', '𑪗'), + ('𑪝', '𑪝'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '\u{11c36}'), + ('\u{11c38}', '𑰾'), + ('𑱀', '𑱀'), + ('𑱲', '𑲏'), + ('\u{11c92}', '\u{11ca7}'), + ('𑲩', '\u{11cb6}'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d41}'), + ('\u{11d43}', '\u{11d43}'), + ('𑵆', '\u{11d47}'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '𑶖'), + ('𑶘', '𑶘'), + ('𑻠', '𑻶'), + ('𒀀', '𒎙'), + ('𒐀', '𒑮'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖫐', '𖫭'), + ('𖬀', '𖬯'), + ('𖭀', '𖭃'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖹀', '𖹿'), + ('𖼀', '\u{16f4a}'), + ('\u{16f4f}', '\u{16f87}'), + ('\u{16f8f}', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛀀', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('𛅰', '𛋻'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('\u{1bc9e}', '\u{1bc9e}'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e137}', '\u{1e13d}'), + ('\u{1e14e}', '\u{1e14e}'), + ('\u{1e2c0}', '\u{1e2eb}'), + ('𞠀', '𞣄'), + ('𞤀', '𞥃'), + ('\u{1e947}', '\u{1e947}'), + ('\u{1e94b}', '\u{1e94b}'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('🄰', '🅉'), + ('🅐', '🅩'), + ('🅰', '🆉'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), +]; + +pub const BIDI_CONTROL: &'static [(char, char)] = &[ + ('\u{61c}', '\u{61c}'), + ('\u{200e}', '\u{200f}'), + ('\u{202a}', '\u{202e}'), + ('\u{2066}', '\u{2069}'), +]; + +pub const CASE_IGNORABLE: &'static [(char, char)] = &[ + ('\'', '\''), + ('.', '.'), + (':', ':'), + ('^', '^'), + ('`', '`'), + ('¨', '¨'), + ('\u{ad}', '\u{ad}'), + ('¯', '¯'), + ('´', '´'), + ('·', '¸'), + ('ʰ', '\u{36f}'), + ('ʹ', '͵'), + ('ͺ', 'ͺ'), + ('΄', '΅'), + ('·', '·'), + ('\u{483}', '\u{489}'), + ('ՙ', 'ՙ'), + ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('״', '״'), + ('\u{600}', '\u{605}'), + ('\u{610}', '\u{61a}'), + ('\u{61c}', '\u{61c}'), + ('ـ', 'ـ'), + ('\u{64b}', '\u{65f}'), + ('\u{670}', '\u{670}'), + ('\u{6d6}', '\u{6dd}'), + ('\u{6df}', '\u{6e8}'), + ('\u{6ea}', '\u{6ed}'), + ('\u{70f}', '\u{70f}'), + ('\u{711}', '\u{711}'), + ('\u{730}', '\u{74a}'), + ('\u{7a6}', '\u{7b0}'), + ('\u{7eb}', 'ߵ'), + ('ߺ', 'ߺ'), + ('\u{7fd}', '\u{7fd}'), + ('\u{816}', '\u{82d}'), + ('\u{859}', '\u{85b}'), + ('\u{8d3}', '\u{902}'), + ('\u{93a}', '\u{93a}'), + ('\u{93c}', '\u{93c}'), + ('\u{941}', '\u{948}'), + ('\u{94d}', '\u{94d}'), + ('\u{951}', '\u{957}'), + ('\u{962}', '\u{963}'), + ('ॱ', 'ॱ'), + ('\u{981}', '\u{981}'), + ('\u{9bc}', '\u{9bc}'), + ('\u{9c1}', '\u{9c4}'), + ('\u{9cd}', '\u{9cd}'), + ('\u{9e2}', '\u{9e3}'), + ('\u{9fe}', '\u{9fe}'), + ('\u{a01}', '\u{a02}'), + ('\u{a3c}', '\u{a3c}'), + ('\u{a41}', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('\u{a70}', '\u{a71}'), + ('\u{a75}', '\u{a75}'), + ('\u{a81}', '\u{a82}'), + ('\u{abc}', '\u{abc}'), + ('\u{ac1}', '\u{ac5}'), + ('\u{ac7}', '\u{ac8}'), + ('\u{acd}', '\u{acd}'), + ('\u{ae2}', '\u{ae3}'), + ('\u{afa}', '\u{aff}'), + ('\u{b01}', '\u{b01}'), + ('\u{b3c}', '\u{b3c}'), + ('\u{b3f}', '\u{b3f}'), + ('\u{b41}', '\u{b44}'), + ('\u{b4d}', '\u{b4d}'), + ('\u{b56}', '\u{b56}'), + ('\u{b62}', '\u{b63}'), + ('\u{b82}', '\u{b82}'), + ('\u{bc0}', '\u{bc0}'), + ('\u{bcd}', '\u{bcd}'), + ('\u{c00}', '\u{c00}'), + ('\u{c04}', '\u{c04}'), + ('\u{c3e}', '\u{c40}'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('\u{c62}', '\u{c63}'), + ('\u{c81}', '\u{c81}'), + ('\u{cbc}', '\u{cbc}'), + ('\u{cbf}', '\u{cbf}'), + ('\u{cc6}', '\u{cc6}'), + ('\u{ccc}', '\u{ccd}'), + ('\u{ce2}', '\u{ce3}'), + ('\u{d00}', '\u{d01}'), + ('\u{d3b}', '\u{d3c}'), + ('\u{d41}', '\u{d44}'), + ('\u{d4d}', '\u{d4d}'), + ('\u{d62}', '\u{d63}'), + ('\u{dca}', '\u{dca}'), + ('\u{dd2}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('\u{e31}', '\u{e31}'), + ('\u{e34}', '\u{e3a}'), + ('ๆ', '\u{e4e}'), + ('\u{eb1}', '\u{eb1}'), + ('\u{eb4}', '\u{ebc}'), + ('ໆ', 'ໆ'), + ('\u{ec8}', '\u{ecd}'), + ('\u{f18}', '\u{f19}'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('\u{f71}', '\u{f7e}'), + ('\u{f80}', '\u{f84}'), + ('\u{f86}', '\u{f87}'), + ('\u{f8d}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), + ('\u{102d}', '\u{1030}'), + ('\u{1032}', '\u{1037}'), + ('\u{1039}', '\u{103a}'), + ('\u{103d}', '\u{103e}'), + ('\u{1058}', '\u{1059}'), + ('\u{105e}', '\u{1060}'), + ('\u{1071}', '\u{1074}'), + ('\u{1082}', '\u{1082}'), + ('\u{1085}', '\u{1086}'), + ('\u{108d}', '\u{108d}'), + ('\u{109d}', '\u{109d}'), + ('ჼ', 'ჼ'), + ('\u{135d}', '\u{135f}'), + ('\u{1712}', '\u{1714}'), + ('\u{1732}', '\u{1734}'), + ('\u{1752}', '\u{1753}'), + ('\u{1772}', '\u{1773}'), + ('\u{17b4}', '\u{17b5}'), + ('\u{17b7}', '\u{17bd}'), + ('\u{17c6}', '\u{17c6}'), + ('\u{17c9}', '\u{17d3}'), + ('ៗ', 'ៗ'), + ('\u{17dd}', '\u{17dd}'), + ('\u{180b}', '\u{180e}'), + ('ᡃ', 'ᡃ'), + ('\u{1885}', '\u{1886}'), + ('\u{18a9}', '\u{18a9}'), + ('\u{1920}', '\u{1922}'), + ('\u{1927}', '\u{1928}'), + ('\u{1932}', '\u{1932}'), + ('\u{1939}', '\u{193b}'), + ('\u{1a17}', '\u{1a18}'), + ('\u{1a1b}', '\u{1a1b}'), + ('\u{1a56}', '\u{1a56}'), + ('\u{1a58}', '\u{1a5e}'), + ('\u{1a60}', '\u{1a60}'), + ('\u{1a62}', '\u{1a62}'), + ('\u{1a65}', '\u{1a6c}'), + ('\u{1a73}', '\u{1a7c}'), + ('\u{1a7f}', '\u{1a7f}'), + ('ᪧ', 'ᪧ'), + ('\u{1ab0}', '\u{1abe}'), + ('\u{1b00}', '\u{1b03}'), + ('\u{1b34}', '\u{1b34}'), + ('\u{1b36}', '\u{1b3a}'), + ('\u{1b3c}', '\u{1b3c}'), + ('\u{1b42}', '\u{1b42}'), + ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', '\u{1b81}'), + ('\u{1ba2}', '\u{1ba5}'), + ('\u{1ba8}', '\u{1ba9}'), + ('\u{1bab}', '\u{1bad}'), + ('\u{1be6}', '\u{1be6}'), + ('\u{1be8}', '\u{1be9}'), + ('\u{1bed}', '\u{1bed}'), + ('\u{1bef}', '\u{1bf1}'), + ('\u{1c2c}', '\u{1c33}'), + ('\u{1c36}', '\u{1c37}'), + ('ᱸ', 'ᱽ'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1ce0}'), + ('\u{1ce2}', '\u{1ce8}'), + ('\u{1ced}', '\u{1ced}'), + ('\u{1cf4}', '\u{1cf4}'), + ('\u{1cf8}', '\u{1cf9}'), + ('ᴬ', 'ᵪ'), + ('ᵸ', 'ᵸ'), + ('ᶛ', '\u{1df9}'), + ('\u{1dfb}', '\u{1dff}'), + ('᾽', '᾽'), + ('᾿', '῁'), + ('῍', '῏'), + ('῝', '῟'), + ('῭', '`'), + ('´', '῾'), + ('\u{200b}', '\u{200f}'), + ('‘', '’'), + ('․', '․'), + ('‧', '‧'), + ('\u{202a}', '\u{202e}'), + ('\u{2060}', '\u{2064}'), + ('\u{2066}', '\u{206f}'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('\u{20d0}', '\u{20f0}'), + ('ⱼ', 'ⱽ'), + ('\u{2cef}', '\u{2cf1}'), + ('ⵯ', 'ⵯ'), + ('\u{2d7f}', '\u{2d7f}'), + ('\u{2de0}', '\u{2dff}'), + ('ⸯ', 'ⸯ'), + ('々', '々'), + ('\u{302a}', '\u{302d}'), + ('〱', '〵'), + ('〻', '〻'), + ('\u{3099}', 'ゞ'), + ('ー', 'ヾ'), + ('ꀕ', 'ꀕ'), + ('ꓸ', 'ꓽ'), + ('ꘌ', 'ꘌ'), + ('\u{a66f}', '\u{a672}'), + ('\u{a674}', '\u{a67d}'), + ('ꙿ', 'ꙿ'), + ('ꚜ', '\u{a69f}'), + ('\u{a6f0}', '\u{a6f1}'), + ('꜀', '꜡'), + ('ꝰ', 'ꝰ'), + ('ꞈ', '꞊'), + ('ꟸ', 'ꟹ'), + ('\u{a802}', '\u{a802}'), + ('\u{a806}', '\u{a806}'), + ('\u{a80b}', '\u{a80b}'), + ('\u{a825}', '\u{a826}'), + ('\u{a8c4}', '\u{a8c5}'), + ('\u{a8e0}', '\u{a8f1}'), + ('\u{a8ff}', '\u{a8ff}'), + ('\u{a926}', '\u{a92d}'), + ('\u{a947}', '\u{a951}'), + ('\u{a980}', '\u{a982}'), + ('\u{a9b3}', '\u{a9b3}'), + ('\u{a9b6}', '\u{a9b9}'), + ('\u{a9bc}', 'ꦽ'), + ('ꧏ', 'ꧏ'), + ('\u{a9e5}', 'ꧦ'), + ('\u{aa29}', '\u{aa2e}'), + ('\u{aa31}', '\u{aa32}'), + ('\u{aa35}', '\u{aa36}'), + ('\u{aa43}', '\u{aa43}'), + ('\u{aa4c}', '\u{aa4c}'), + ('ꩰ', 'ꩰ'), + ('\u{aa7c}', '\u{aa7c}'), + ('\u{aab0}', '\u{aab0}'), + ('\u{aab2}', '\u{aab4}'), + ('\u{aab7}', '\u{aab8}'), + ('\u{aabe}', '\u{aabf}'), + ('\u{aac1}', '\u{aac1}'), + ('ꫝ', 'ꫝ'), + ('\u{aaec}', '\u{aaed}'), + ('ꫳ', 'ꫴ'), + ('\u{aaf6}', '\u{aaf6}'), + ('꭛', 'ꭟ'), + ('\u{abe5}', '\u{abe5}'), + ('\u{abe8}', '\u{abe8}'), + ('\u{abed}', '\u{abed}'), + ('\u{fb1e}', '\u{fb1e}'), + ('﮲', '﯁'), + ('\u{fe00}', '\u{fe0f}'), + ('︓', '︓'), + ('\u{fe20}', '\u{fe2f}'), + ('﹒', '﹒'), + ('﹕', '﹕'), + ('\u{feff}', '\u{feff}'), + (''', '''), + ('.', '.'), + (':', ':'), + ('^', '^'), + ('`', '`'), + ('ー', 'ー'), + ('\u{ff9e}', '\u{ff9f}'), + (' ̄', ' ̄'), + ('\u{fff9}', '\u{fffb}'), + ('\u{101fd}', '\u{101fd}'), + ('\u{102e0}', '\u{102e0}'), + ('\u{10376}', '\u{1037a}'), + ('\u{10a01}', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a0f}'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), + ('\u{10ae5}', '\u{10ae6}'), + ('\u{10d24}', '\u{10d27}'), + ('\u{10f46}', '\u{10f50}'), + ('\u{11001}', '\u{11001}'), + ('\u{11038}', '\u{11046}'), + ('\u{1107f}', '\u{11081}'), + ('\u{110b3}', '\u{110b6}'), + ('\u{110b9}', '\u{110ba}'), + ('\u{110bd}', '\u{110bd}'), + ('\u{110cd}', '\u{110cd}'), + ('\u{11100}', '\u{11102}'), + ('\u{11127}', '\u{1112b}'), + ('\u{1112d}', '\u{11134}'), + ('\u{11173}', '\u{11173}'), + ('\u{11180}', '\u{11181}'), + ('\u{111b6}', '\u{111be}'), + ('\u{111c9}', '\u{111cc}'), + ('\u{1122f}', '\u{11231}'), + ('\u{11234}', '\u{11234}'), + ('\u{11236}', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('\u{112df}', '\u{112df}'), + ('\u{112e3}', '\u{112ea}'), + ('\u{11300}', '\u{11301}'), + ('\u{1133b}', '\u{1133c}'), + ('\u{11340}', '\u{11340}'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('\u{11438}', '\u{1143f}'), + ('\u{11442}', '\u{11444}'), + ('\u{11446}', '\u{11446}'), + ('\u{1145e}', '\u{1145e}'), + ('\u{114b3}', '\u{114b8}'), + ('\u{114ba}', '\u{114ba}'), + ('\u{114bf}', '\u{114c0}'), + ('\u{114c2}', '\u{114c3}'), + ('\u{115b2}', '\u{115b5}'), + ('\u{115bc}', '\u{115bd}'), + ('\u{115bf}', '\u{115c0}'), + ('\u{115dc}', '\u{115dd}'), + ('\u{11633}', '\u{1163a}'), + ('\u{1163d}', '\u{1163d}'), + ('\u{1163f}', '\u{11640}'), + ('\u{116ab}', '\u{116ab}'), + ('\u{116ad}', '\u{116ad}'), + ('\u{116b0}', '\u{116b5}'), + ('\u{116b7}', '\u{116b7}'), + ('\u{1171d}', '\u{1171f}'), + ('\u{11722}', '\u{11725}'), + ('\u{11727}', '\u{1172b}'), + ('\u{1182f}', '\u{11837}'), + ('\u{11839}', '\u{1183a}'), + ('\u{119d4}', '\u{119d7}'), + ('\u{119da}', '\u{119db}'), + ('\u{119e0}', '\u{119e0}'), + ('\u{11a01}', '\u{11a0a}'), + ('\u{11a33}', '\u{11a38}'), + ('\u{11a3b}', '\u{11a3e}'), + ('\u{11a47}', '\u{11a47}'), + ('\u{11a51}', '\u{11a56}'), + ('\u{11a59}', '\u{11a5b}'), + ('\u{11a8a}', '\u{11a96}'), + ('\u{11a98}', '\u{11a99}'), + ('\u{11c30}', '\u{11c36}'), + ('\u{11c38}', '\u{11c3d}'), + ('\u{11c3f}', '\u{11c3f}'), + ('\u{11c92}', '\u{11ca7}'), + ('\u{11caa}', '\u{11cb0}'), + ('\u{11cb2}', '\u{11cb3}'), + ('\u{11cb5}', '\u{11cb6}'), + ('\u{11d31}', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d45}'), + ('\u{11d47}', '\u{11d47}'), + ('\u{11d90}', '\u{11d91}'), + ('\u{11d95}', '\u{11d95}'), + ('\u{11d97}', '\u{11d97}'), + ('\u{11ef3}', '\u{11ef4}'), + ('\u{13430}', '\u{13438}'), + ('\u{16af0}', '\u{16af4}'), + ('\u{16b30}', '\u{16b36}'), + ('𖭀', '𖭃'), + ('\u{16f4f}', '\u{16f4f}'), + ('\u{16f8f}', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1bca0}', '\u{1bca3}'), + ('\u{1d167}', '\u{1d169}'), + ('\u{1d173}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1d242}', '\u{1d244}'), + ('\u{1da00}', '\u{1da36}'), + ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), + ('\u{1da84}', '\u{1da84}'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e130}', '\u{1e13d}'), + ('\u{1e2ec}', '\u{1e2ef}'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('\u{1e944}', '\u{1e94b}'), + ('🏻', '🏿'), + ('\u{e0001}', '\u{e0001}'), + ('\u{e0020}', '\u{e007f}'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const CASED: &'static [(char, char)] = &[ + ('A', 'Z'), + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ƺ'), + ('Ƽ', 'ƿ'), + ('DŽ', 'ʓ'), + ('ʕ', 'ʸ'), + ('ˀ', 'ˁ'), + ('ˠ', 'ˤ'), + ('\u{345}', '\u{345}'), + ('Ͱ', 'ͳ'), + ('Ͷ', 'ͷ'), + ('ͺ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϵ'), + ('Ϸ', 'ҁ'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՠ', 'ֈ'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჽ', 'ჿ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ᴀ', 'ᶿ'), + ('Ḁ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('ℙ', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℭ'), + ('ℯ', 'ℴ'), + ('ℹ', 'ℹ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ⅿ'), + ('Ↄ', 'ↄ'), + ('Ⓐ', 'ⓩ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⳤ'), + ('Ⳬ', 'ⳮ'), + ('Ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('Ꙁ', 'ꙭ'), + ('Ꚁ', 'ꚝ'), + ('Ꜣ', 'ꞇ'), + ('Ꞌ', 'ꞎ'), + ('Ꞑ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟸ', 'ꟺ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', '\u{ab67}'), + ('ꭰ', 'ꮿ'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('A', 'Z'), + ('a', 'z'), + ('𐐀', '𐑏'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𑢠', '𑣟'), + ('𖹀', '𖹿'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('𞤀', '𞥃'), + ('🄰', '🅉'), + ('🅐', '🅩'), + ('🅰', '🆉'), +]; + +pub const CHANGES_WHEN_CASEFOLDED: &'static [(char, char)] = &[ + ('A', 'Z'), + ('µ', 'µ'), + ('À', 'Ö'), + ('Ø', 'ß'), + ('Ā', 'Ā'), + ('Ă', 'Ă'), + ('Ą', 'Ą'), + ('Ć', 'Ć'), + ('Ĉ', 'Ĉ'), + ('Ċ', 'Ċ'), + ('Č', 'Č'), + ('Ď', 'Ď'), + ('Đ', 'Đ'), + ('Ē', 'Ē'), + ('Ĕ', 'Ĕ'), + ('Ė', 'Ė'), + ('Ę', 'Ę'), + ('Ě', 'Ě'), + ('Ĝ', 'Ĝ'), + ('Ğ', 'Ğ'), + ('Ġ', 'Ġ'), + ('Ģ', 'Ģ'), + ('Ĥ', 'Ĥ'), + ('Ħ', 'Ħ'), + ('Ĩ', 'Ĩ'), + ('Ī', 'Ī'), + ('Ĭ', 'Ĭ'), + ('Į', 'Į'), + ('İ', 'İ'), + ('IJ', 'IJ'), + ('Ĵ', 'Ĵ'), + ('Ķ', 'Ķ'), + ('Ĺ', 'Ĺ'), + ('Ļ', 'Ļ'), + ('Ľ', 'Ľ'), + ('Ŀ', 'Ŀ'), + ('Ł', 'Ł'), + ('Ń', 'Ń'), + ('Ņ', 'Ņ'), + ('Ň', 'Ň'), + ('ʼn', 'Ŋ'), + ('Ō', 'Ō'), + ('Ŏ', 'Ŏ'), + ('Ő', 'Ő'), + ('Œ', 'Œ'), + ('Ŕ', 'Ŕ'), + ('Ŗ', 'Ŗ'), + ('Ř', 'Ř'), + ('Ś', 'Ś'), + ('Ŝ', 'Ŝ'), + ('Ş', 'Ş'), + ('Š', 'Š'), + ('Ţ', 'Ţ'), + ('Ť', 'Ť'), + ('Ŧ', 'Ŧ'), + ('Ũ', 'Ũ'), + ('Ū', 'Ū'), + ('Ŭ', 'Ŭ'), + ('Ů', 'Ů'), + ('Ű', 'Ű'), + ('Ų', 'Ų'), + ('Ŵ', 'Ŵ'), + ('Ŷ', 'Ŷ'), + ('Ÿ', 'Ź'), + ('Ż', 'Ż'), + ('Ž', 'Ž'), + ('ſ', 'ſ'), + ('Ɓ', 'Ƃ'), + ('Ƅ', 'Ƅ'), + ('Ɔ', 'Ƈ'), + ('Ɖ', 'Ƌ'), + ('Ǝ', 'Ƒ'), + ('Ɠ', 'Ɣ'), + ('Ɩ', 'Ƙ'), + ('Ɯ', 'Ɲ'), + ('Ɵ', 'Ơ'), + ('Ƣ', 'Ƣ'), + ('Ƥ', 'Ƥ'), + ('Ʀ', 'Ƨ'), + ('Ʃ', 'Ʃ'), + ('Ƭ', 'Ƭ'), + ('Ʈ', 'Ư'), + ('Ʊ', 'Ƴ'), + ('Ƶ', 'Ƶ'), + ('Ʒ', 'Ƹ'), + ('Ƽ', 'Ƽ'), + ('DŽ', 'Dž'), + ('LJ', 'Lj'), + ('NJ', 'Nj'), + ('Ǎ', 'Ǎ'), + ('Ǐ', 'Ǐ'), + ('Ǒ', 'Ǒ'), + ('Ǔ', 'Ǔ'), + ('Ǖ', 'Ǖ'), + ('Ǘ', 'Ǘ'), + ('Ǚ', 'Ǚ'), + ('Ǜ', 'Ǜ'), + ('Ǟ', 'Ǟ'), + ('Ǡ', 'Ǡ'), + ('Ǣ', 'Ǣ'), + ('Ǥ', 'Ǥ'), + ('Ǧ', 'Ǧ'), + ('Ǩ', 'Ǩ'), + ('Ǫ', 'Ǫ'), + ('Ǭ', 'Ǭ'), + ('Ǯ', 'Ǯ'), + ('DZ', 'Dz'), + ('Ǵ', 'Ǵ'), + ('Ƕ', 'Ǹ'), + ('Ǻ', 'Ǻ'), + ('Ǽ', 'Ǽ'), + ('Ǿ', 'Ǿ'), + ('Ȁ', 'Ȁ'), + ('Ȃ', 'Ȃ'), + ('Ȅ', 'Ȅ'), + ('Ȇ', 'Ȇ'), + ('Ȉ', 'Ȉ'), + ('Ȋ', 'Ȋ'), + ('Ȍ', 'Ȍ'), + ('Ȏ', 'Ȏ'), + ('Ȑ', 'Ȑ'), + ('Ȓ', 'Ȓ'), + ('Ȕ', 'Ȕ'), + ('Ȗ', 'Ȗ'), + ('Ș', 'Ș'), + ('Ț', 'Ț'), + ('Ȝ', 'Ȝ'), + ('Ȟ', 'Ȟ'), + ('Ƞ', 'Ƞ'), + ('Ȣ', 'Ȣ'), + ('Ȥ', 'Ȥ'), + ('Ȧ', 'Ȧ'), + ('Ȩ', 'Ȩ'), + ('Ȫ', 'Ȫ'), + ('Ȭ', 'Ȭ'), + ('Ȯ', 'Ȯ'), + ('Ȱ', 'Ȱ'), + ('Ȳ', 'Ȳ'), + ('Ⱥ', 'Ȼ'), + ('Ƚ', 'Ⱦ'), + ('Ɂ', 'Ɂ'), + ('Ƀ', 'Ɇ'), + ('Ɉ', 'Ɉ'), + ('Ɋ', 'Ɋ'), + ('Ɍ', 'Ɍ'), + ('Ɏ', 'Ɏ'), + ('\u{345}', '\u{345}'), + ('Ͱ', 'Ͱ'), + ('Ͳ', 'Ͳ'), + ('Ͷ', 'Ͷ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ώ'), + ('Α', 'Ρ'), + ('Σ', 'Ϋ'), + ('ς', 'ς'), + ('Ϗ', 'ϑ'), + ('ϕ', 'ϖ'), + ('Ϙ', 'Ϙ'), + ('Ϛ', 'Ϛ'), + ('Ϝ', 'Ϝ'), + ('Ϟ', 'Ϟ'), + ('Ϡ', 'Ϡ'), + ('Ϣ', 'Ϣ'), + ('Ϥ', 'Ϥ'), + ('Ϧ', 'Ϧ'), + ('Ϩ', 'Ϩ'), + ('Ϫ', 'Ϫ'), + ('Ϭ', 'Ϭ'), + ('Ϯ', 'Ϯ'), + ('ϰ', 'ϱ'), + ('ϴ', 'ϵ'), + ('Ϸ', 'Ϸ'), + ('Ϲ', 'Ϻ'), + ('Ͻ', 'Я'), + ('Ѡ', 'Ѡ'), + ('Ѣ', 'Ѣ'), + ('Ѥ', 'Ѥ'), + ('Ѧ', 'Ѧ'), + ('Ѩ', 'Ѩ'), + ('Ѫ', 'Ѫ'), + ('Ѭ', 'Ѭ'), + ('Ѯ', 'Ѯ'), + ('Ѱ', 'Ѱ'), + ('Ѳ', 'Ѳ'), + ('Ѵ', 'Ѵ'), + ('Ѷ', 'Ѷ'), + ('Ѹ', 'Ѹ'), + ('Ѻ', 'Ѻ'), + ('Ѽ', 'Ѽ'), + ('Ѿ', 'Ѿ'), + ('Ҁ', 'Ҁ'), + ('Ҋ', 'Ҋ'), + ('Ҍ', 'Ҍ'), + ('Ҏ', 'Ҏ'), + ('Ґ', 'Ґ'), + ('Ғ', 'Ғ'), + ('Ҕ', 'Ҕ'), + ('Җ', 'Җ'), + ('Ҙ', 'Ҙ'), + ('Қ', 'Қ'), + ('Ҝ', 'Ҝ'), + ('Ҟ', 'Ҟ'), + ('Ҡ', 'Ҡ'), + ('Ң', 'Ң'), + ('Ҥ', 'Ҥ'), + ('Ҧ', 'Ҧ'), + ('Ҩ', 'Ҩ'), + ('Ҫ', 'Ҫ'), + ('Ҭ', 'Ҭ'), + ('Ү', 'Ү'), + ('Ұ', 'Ұ'), + ('Ҳ', 'Ҳ'), + ('Ҵ', 'Ҵ'), + ('Ҷ', 'Ҷ'), + ('Ҹ', 'Ҹ'), + ('Һ', 'Һ'), + ('Ҽ', 'Ҽ'), + ('Ҿ', 'Ҿ'), + ('Ӏ', 'Ӂ'), + ('Ӄ', 'Ӄ'), + ('Ӆ', 'Ӆ'), + ('Ӈ', 'Ӈ'), + ('Ӊ', 'Ӊ'), + ('Ӌ', 'Ӌ'), + ('Ӎ', 'Ӎ'), + ('Ӑ', 'Ӑ'), + ('Ӓ', 'Ӓ'), + ('Ӕ', 'Ӕ'), + ('Ӗ', 'Ӗ'), + ('Ә', 'Ә'), + ('Ӛ', 'Ӛ'), + ('Ӝ', 'Ӝ'), + ('Ӟ', 'Ӟ'), + ('Ӡ', 'Ӡ'), + ('Ӣ', 'Ӣ'), + ('Ӥ', 'Ӥ'), + ('Ӧ', 'Ӧ'), + ('Ө', 'Ө'), + ('Ӫ', 'Ӫ'), + ('Ӭ', 'Ӭ'), + ('Ӯ', 'Ӯ'), + ('Ӱ', 'Ӱ'), + ('Ӳ', 'Ӳ'), + ('Ӵ', 'Ӵ'), + ('Ӷ', 'Ӷ'), + ('Ӹ', 'Ӹ'), + ('Ӻ', 'Ӻ'), + ('Ӽ', 'Ӽ'), + ('Ӿ', 'Ӿ'), + ('Ԁ', 'Ԁ'), + ('Ԃ', 'Ԃ'), + ('Ԅ', 'Ԅ'), + ('Ԇ', 'Ԇ'), + ('Ԉ', 'Ԉ'), + ('Ԋ', 'Ԋ'), + ('Ԍ', 'Ԍ'), + ('Ԏ', 'Ԏ'), + ('Ԑ', 'Ԑ'), + ('Ԓ', 'Ԓ'), + ('Ԕ', 'Ԕ'), + ('Ԗ', 'Ԗ'), + ('Ԙ', 'Ԙ'), + ('Ԛ', 'Ԛ'), + ('Ԝ', 'Ԝ'), + ('Ԟ', 'Ԟ'), + ('Ԡ', 'Ԡ'), + ('Ԣ', 'Ԣ'), + ('Ԥ', 'Ԥ'), + ('Ԧ', 'Ԧ'), + ('Ԩ', 'Ԩ'), + ('Ԫ', 'Ԫ'), + ('Ԭ', 'Ԭ'), + ('Ԯ', 'Ԯ'), + ('Ա', 'Ֆ'), + ('և', 'և'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ᏸ', 'ᏽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('Ḁ', 'Ḁ'), + ('Ḃ', 'Ḃ'), + ('Ḅ', 'Ḅ'), + ('Ḇ', 'Ḇ'), + ('Ḉ', 'Ḉ'), + ('Ḋ', 'Ḋ'), + ('Ḍ', 'Ḍ'), + ('Ḏ', 'Ḏ'), + ('Ḑ', 'Ḑ'), + ('Ḓ', 'Ḓ'), + ('Ḕ', 'Ḕ'), + ('Ḗ', 'Ḗ'), + ('Ḙ', 'Ḙ'), + ('Ḛ', 'Ḛ'), + ('Ḝ', 'Ḝ'), + ('Ḟ', 'Ḟ'), + ('Ḡ', 'Ḡ'), + ('Ḣ', 'Ḣ'), + ('Ḥ', 'Ḥ'), + ('Ḧ', 'Ḧ'), + ('Ḩ', 'Ḩ'), + ('Ḫ', 'Ḫ'), + ('Ḭ', 'Ḭ'), + ('Ḯ', 'Ḯ'), + ('Ḱ', 'Ḱ'), + ('Ḳ', 'Ḳ'), + ('Ḵ', 'Ḵ'), + ('Ḷ', 'Ḷ'), + ('Ḹ', 'Ḹ'), + ('Ḻ', 'Ḻ'), + ('Ḽ', 'Ḽ'), + ('Ḿ', 'Ḿ'), + ('Ṁ', 'Ṁ'), + ('Ṃ', 'Ṃ'), + ('Ṅ', 'Ṅ'), + ('Ṇ', 'Ṇ'), + ('Ṉ', 'Ṉ'), + ('Ṋ', 'Ṋ'), + ('Ṍ', 'Ṍ'), + ('Ṏ', 'Ṏ'), + ('Ṑ', 'Ṑ'), + ('Ṓ', 'Ṓ'), + ('Ṕ', 'Ṕ'), + ('Ṗ', 'Ṗ'), + ('Ṙ', 'Ṙ'), + ('Ṛ', 'Ṛ'), + ('Ṝ', 'Ṝ'), + ('Ṟ', 'Ṟ'), + ('Ṡ', 'Ṡ'), + ('Ṣ', 'Ṣ'), + ('Ṥ', 'Ṥ'), + ('Ṧ', 'Ṧ'), + ('Ṩ', 'Ṩ'), + ('Ṫ', 'Ṫ'), + ('Ṭ', 'Ṭ'), + ('Ṯ', 'Ṯ'), + ('Ṱ', 'Ṱ'), + ('Ṳ', 'Ṳ'), + ('Ṵ', 'Ṵ'), + ('Ṷ', 'Ṷ'), + ('Ṹ', 'Ṹ'), + ('Ṻ', 'Ṻ'), + ('Ṽ', 'Ṽ'), + ('Ṿ', 'Ṿ'), + ('Ẁ', 'Ẁ'), + ('Ẃ', 'Ẃ'), + ('Ẅ', 'Ẅ'), + ('Ẇ', 'Ẇ'), + ('Ẉ', 'Ẉ'), + ('Ẋ', 'Ẋ'), + ('Ẍ', 'Ẍ'), + ('Ẏ', 'Ẏ'), + ('Ẑ', 'Ẑ'), + ('Ẓ', 'Ẓ'), + ('Ẕ', 'Ẕ'), + ('ẚ', 'ẛ'), + ('ẞ', 'ẞ'), + ('Ạ', 'Ạ'), + ('Ả', 'Ả'), + ('Ấ', 'Ấ'), + ('Ầ', 'Ầ'), + ('Ẩ', 'Ẩ'), + ('Ẫ', 'Ẫ'), + ('Ậ', 'Ậ'), + ('Ắ', 'Ắ'), + ('Ằ', 'Ằ'), + ('Ẳ', 'Ẳ'), + ('Ẵ', 'Ẵ'), + ('Ặ', 'Ặ'), + ('Ẹ', 'Ẹ'), + ('Ẻ', 'Ẻ'), + ('Ẽ', 'Ẽ'), + ('Ế', 'Ế'), + ('Ề', 'Ề'), + ('Ể', 'Ể'), + ('Ễ', 'Ễ'), + ('Ệ', 'Ệ'), + ('Ỉ', 'Ỉ'), + ('Ị', 'Ị'), + ('Ọ', 'Ọ'), + ('Ỏ', 'Ỏ'), + ('Ố', 'Ố'), + ('Ồ', 'Ồ'), + ('Ổ', 'Ổ'), + ('Ỗ', 'Ỗ'), + ('Ộ', 'Ộ'), + ('Ớ', 'Ớ'), + ('Ờ', 'Ờ'), + ('Ở', 'Ở'), + ('Ỡ', 'Ỡ'), + ('Ợ', 'Ợ'), + ('Ụ', 'Ụ'), + ('Ủ', 'Ủ'), + ('Ứ', 'Ứ'), + ('Ừ', 'Ừ'), + ('Ử', 'Ử'), + ('Ữ', 'Ữ'), + ('Ự', 'Ự'), + ('Ỳ', 'Ỳ'), + ('Ỵ', 'Ỵ'), + ('Ỷ', 'Ỷ'), + ('Ỹ', 'Ỹ'), + ('Ỻ', 'Ỻ'), + ('Ỽ', 'Ỽ'), + ('Ỿ', 'Ỿ'), + ('Ἀ', 'Ἇ'), + ('Ἐ', 'Ἕ'), + ('Ἠ', 'Ἧ'), + ('Ἰ', 'Ἷ'), + ('Ὀ', 'Ὅ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'Ὗ'), + ('Ὠ', 'Ὧ'), + ('ᾀ', 'ᾯ'), + ('ᾲ', 'ᾴ'), + ('ᾷ', 'ᾼ'), + ('ῂ', 'ῄ'), + ('ῇ', 'ῌ'), + ('Ῐ', 'Ί'), + ('Ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῷ', 'ῼ'), + ('Ω', 'Ω'), + ('K', 'Å'), + ('Ⅎ', 'Ⅎ'), + ('Ⅰ', 'Ⅿ'), + ('Ↄ', 'Ↄ'), + ('Ⓐ', 'Ⓩ'), + ('Ⰰ', 'Ⱞ'), + ('Ⱡ', 'Ⱡ'), + ('Ɫ', 'Ɽ'), + ('Ⱨ', 'Ⱨ'), + ('Ⱪ', 'Ⱪ'), + ('Ⱬ', 'Ⱬ'), + ('Ɑ', 'Ɒ'), + ('Ⱳ', 'Ⱳ'), + ('Ⱶ', 'Ⱶ'), + ('Ȿ', 'Ⲁ'), + ('Ⲃ', 'Ⲃ'), + ('Ⲅ', 'Ⲅ'), + ('Ⲇ', 'Ⲇ'), + ('Ⲉ', 'Ⲉ'), + ('Ⲋ', 'Ⲋ'), + ('Ⲍ', 'Ⲍ'), + ('Ⲏ', 'Ⲏ'), + ('Ⲑ', 'Ⲑ'), + ('Ⲓ', 'Ⲓ'), + ('Ⲕ', 'Ⲕ'), + ('Ⲗ', 'Ⲗ'), + ('Ⲙ', 'Ⲙ'), + ('Ⲛ', 'Ⲛ'), + ('Ⲝ', 'Ⲝ'), + ('Ⲟ', 'Ⲟ'), + ('Ⲡ', 'Ⲡ'), + ('Ⲣ', 'Ⲣ'), + ('Ⲥ', 'Ⲥ'), + ('Ⲧ', 'Ⲧ'), + ('Ⲩ', 'Ⲩ'), + ('Ⲫ', 'Ⲫ'), + ('Ⲭ', 'Ⲭ'), + ('Ⲯ', 'Ⲯ'), + ('Ⲱ', 'Ⲱ'), + ('Ⲳ', 'Ⲳ'), + ('Ⲵ', 'Ⲵ'), + ('Ⲷ', 'Ⲷ'), + ('Ⲹ', 'Ⲹ'), + ('Ⲻ', 'Ⲻ'), + ('Ⲽ', 'Ⲽ'), + ('Ⲿ', 'Ⲿ'), + ('Ⳁ', 'Ⳁ'), + ('Ⳃ', 'Ⳃ'), + ('Ⳅ', 'Ⳅ'), + ('Ⳇ', 'Ⳇ'), + ('Ⳉ', 'Ⳉ'), + ('Ⳋ', 'Ⳋ'), + ('Ⳍ', 'Ⳍ'), + ('Ⳏ', 'Ⳏ'), + ('Ⳑ', 'Ⳑ'), + ('Ⳓ', 'Ⳓ'), + ('Ⳕ', 'Ⳕ'), + ('Ⳗ', 'Ⳗ'), + ('Ⳙ', 'Ⳙ'), + ('Ⳛ', 'Ⳛ'), + ('Ⳝ', 'Ⳝ'), + ('Ⳟ', 'Ⳟ'), + ('Ⳡ', 'Ⳡ'), + ('Ⳣ', 'Ⳣ'), + ('Ⳬ', 'Ⳬ'), + ('Ⳮ', 'Ⳮ'), + ('Ⳳ', 'Ⳳ'), + ('Ꙁ', 'Ꙁ'), + ('Ꙃ', 'Ꙃ'), + ('Ꙅ', 'Ꙅ'), + ('Ꙇ', 'Ꙇ'), + ('Ꙉ', 'Ꙉ'), + ('Ꙋ', 'Ꙋ'), + ('Ꙍ', 'Ꙍ'), + ('Ꙏ', 'Ꙏ'), + ('Ꙑ', 'Ꙑ'), + ('Ꙓ', 'Ꙓ'), + ('Ꙕ', 'Ꙕ'), + ('Ꙗ', 'Ꙗ'), + ('Ꙙ', 'Ꙙ'), + ('Ꙛ', 'Ꙛ'), + ('Ꙝ', 'Ꙝ'), + ('Ꙟ', 'Ꙟ'), + ('Ꙡ', 'Ꙡ'), + ('Ꙣ', 'Ꙣ'), + ('Ꙥ', 'Ꙥ'), + ('Ꙧ', 'Ꙧ'), + ('Ꙩ', 'Ꙩ'), + ('Ꙫ', 'Ꙫ'), + ('Ꙭ', 'Ꙭ'), + ('Ꚁ', 'Ꚁ'), + ('Ꚃ', 'Ꚃ'), + ('Ꚅ', 'Ꚅ'), + ('Ꚇ', 'Ꚇ'), + ('Ꚉ', 'Ꚉ'), + ('Ꚋ', 'Ꚋ'), + ('Ꚍ', 'Ꚍ'), + ('Ꚏ', 'Ꚏ'), + ('Ꚑ', 'Ꚑ'), + ('Ꚓ', 'Ꚓ'), + ('Ꚕ', 'Ꚕ'), + ('Ꚗ', 'Ꚗ'), + ('Ꚙ', 'Ꚙ'), + ('Ꚛ', 'Ꚛ'), + ('Ꜣ', 'Ꜣ'), + ('Ꜥ', 'Ꜥ'), + ('Ꜧ', 'Ꜧ'), + ('Ꜩ', 'Ꜩ'), + ('Ꜫ', 'Ꜫ'), + ('Ꜭ', 'Ꜭ'), + ('Ꜯ', 'Ꜯ'), + ('Ꜳ', 'Ꜳ'), + ('Ꜵ', 'Ꜵ'), + ('Ꜷ', 'Ꜷ'), + ('Ꜹ', 'Ꜹ'), + ('Ꜻ', 'Ꜻ'), + ('Ꜽ', 'Ꜽ'), + ('Ꜿ', 'Ꜿ'), + ('Ꝁ', 'Ꝁ'), + ('Ꝃ', 'Ꝃ'), + ('Ꝅ', 'Ꝅ'), + ('Ꝇ', 'Ꝇ'), + ('Ꝉ', 'Ꝉ'), + ('Ꝋ', 'Ꝋ'), + ('Ꝍ', 'Ꝍ'), + ('Ꝏ', 'Ꝏ'), + ('Ꝑ', 'Ꝑ'), + ('Ꝓ', 'Ꝓ'), + ('Ꝕ', 'Ꝕ'), + ('Ꝗ', 'Ꝗ'), + ('Ꝙ', 'Ꝙ'), + ('Ꝛ', 'Ꝛ'), + ('Ꝝ', 'Ꝝ'), + ('Ꝟ', 'Ꝟ'), + ('Ꝡ', 'Ꝡ'), + ('Ꝣ', 'Ꝣ'), + ('Ꝥ', 'Ꝥ'), + ('Ꝧ', 'Ꝧ'), + ('Ꝩ', 'Ꝩ'), + ('Ꝫ', 'Ꝫ'), + ('Ꝭ', 'Ꝭ'), + ('Ꝯ', 'Ꝯ'), + ('Ꝺ', 'Ꝺ'), + ('Ꝼ', 'Ꝼ'), + ('Ᵹ', 'Ꝿ'), + ('Ꞁ', 'Ꞁ'), + ('Ꞃ', 'Ꞃ'), + ('Ꞅ', 'Ꞅ'), + ('Ꞇ', 'Ꞇ'), + ('Ꞌ', 'Ꞌ'), + ('Ɥ', 'Ɥ'), + ('Ꞑ', 'Ꞑ'), + ('Ꞓ', 'Ꞓ'), + ('Ꞗ', 'Ꞗ'), + ('Ꞙ', 'Ꞙ'), + ('Ꞛ', 'Ꞛ'), + ('Ꞝ', 'Ꞝ'), + ('Ꞟ', 'Ꞟ'), + ('Ꞡ', 'Ꞡ'), + ('Ꞣ', 'Ꞣ'), + ('Ꞥ', 'Ꞥ'), + ('Ꞧ', 'Ꞧ'), + ('Ꞩ', 'Ꞩ'), + ('Ɦ', 'Ɪ'), + ('Ʞ', 'Ꞵ'), + ('Ꞷ', 'Ꞷ'), + ('Ꞹ', 'Ꞹ'), + ('\u{a7ba}', '\u{a7ba}'), + ('\u{a7bc}', '\u{a7bc}'), + ('\u{a7be}', '\u{a7be}'), + ('\u{a7c2}', '\u{a7c2}'), + ('\u{a7c4}', '\u{a7c6}'), + ('ꭰ', 'ꮿ'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('A', 'Z'), + ('𐐀', '𐐧'), + ('𐒰', '𐓓'), + ('𐲀', '𐲲'), + ('𑢠', '𑢿'), + ('𖹀', '𖹟'), + ('𞤀', '𞤡'), +]; + +pub const CHANGES_WHEN_CASEMAPPED: &'static [(char, char)] = &[ + ('A', 'Z'), + ('a', 'z'), + ('µ', 'µ'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ķ'), + ('Ĺ', 'ƌ'), + ('Ǝ', 'ƚ'), + ('Ɯ', 'Ʃ'), + ('Ƭ', 'ƹ'), + ('Ƽ', 'ƽ'), + ('ƿ', 'ƿ'), + ('DŽ', 'Ƞ'), + ('Ȣ', 'ȳ'), + ('Ⱥ', 'ɔ'), + ('ɖ', 'ɗ'), + ('ə', 'ə'), + ('ɛ', 'ɜ'), + ('ɠ', 'ɡ'), + ('ɣ', 'ɣ'), + ('ɥ', 'ɦ'), + ('ɨ', 'ɬ'), + ('ɯ', 'ɯ'), + ('ɱ', 'ɲ'), + ('ɵ', 'ɵ'), + ('ɽ', 'ɽ'), + ('ʀ', 'ʀ'), + ('ʂ', 'ʃ'), + ('ʇ', 'ʌ'), + ('ʒ', 'ʒ'), + ('ʝ', 'ʞ'), + ('\u{345}', '\u{345}'), + ('Ͱ', 'ͳ'), + ('Ͷ', 'ͷ'), + ('ͻ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϑ'), + ('ϕ', 'ϵ'), + ('Ϸ', 'ϻ'), + ('Ͻ', 'ҁ'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ա', 'և'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჽ', 'ჿ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ᵹ', 'ᵹ'), + ('ᵽ', 'ᵽ'), + ('ᶎ', 'ᶎ'), + ('Ḁ', 'ẛ'), + ('ẞ', 'ẞ'), + ('Ạ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('Ω', 'Ω'), + ('K', 'Å'), + ('Ⅎ', 'Ⅎ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ⅿ'), + ('Ↄ', 'ↄ'), + ('Ⓐ', 'ⓩ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'Ɒ'), + ('Ⱳ', 'ⱳ'), + ('Ⱶ', 'ⱶ'), + ('Ȿ', 'ⳣ'), + ('Ⳬ', 'ⳮ'), + ('Ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('Ꙁ', 'ꙭ'), + ('Ꚁ', 'ꚛ'), + ('Ꜣ', 'ꜯ'), + ('Ꜳ', 'ꝯ'), + ('Ꝺ', 'ꞇ'), + ('Ꞌ', 'Ɥ'), + ('Ꞑ', 'ꞔ'), + ('Ꞗ', 'Ɪ'), + ('Ʞ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꭓ', 'ꭓ'), + ('ꭰ', 'ꮿ'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('A', 'Z'), + ('a', 'z'), + ('𐐀', '𐑏'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𑢠', '𑣟'), + ('𖹀', '𖹿'), + ('𞤀', '𞥃'), +]; + +pub const CHANGES_WHEN_LOWERCASED: &'static [(char, char)] = &[ + ('A', 'Z'), + ('À', 'Ö'), + ('Ø', 'Þ'), + ('Ā', 'Ā'), + ('Ă', 'Ă'), + ('Ą', 'Ą'), + ('Ć', 'Ć'), + ('Ĉ', 'Ĉ'), + ('Ċ', 'Ċ'), + ('Č', 'Č'), + ('Ď', 'Ď'), + ('Đ', 'Đ'), + ('Ē', 'Ē'), + ('Ĕ', 'Ĕ'), + ('Ė', 'Ė'), + ('Ę', 'Ę'), + ('Ě', 'Ě'), + ('Ĝ', 'Ĝ'), + ('Ğ', 'Ğ'), + ('Ġ', 'Ġ'), + ('Ģ', 'Ģ'), + ('Ĥ', 'Ĥ'), + ('Ħ', 'Ħ'), + ('Ĩ', 'Ĩ'), + ('Ī', 'Ī'), + ('Ĭ', 'Ĭ'), + ('Į', 'Į'), + ('İ', 'İ'), + ('IJ', 'IJ'), + ('Ĵ', 'Ĵ'), + ('Ķ', 'Ķ'), + ('Ĺ', 'Ĺ'), + ('Ļ', 'Ļ'), + ('Ľ', 'Ľ'), + ('Ŀ', 'Ŀ'), + ('Ł', 'Ł'), + ('Ń', 'Ń'), + ('Ņ', 'Ņ'), + ('Ň', 'Ň'), + ('Ŋ', 'Ŋ'), + ('Ō', 'Ō'), + ('Ŏ', 'Ŏ'), + ('Ő', 'Ő'), + ('Œ', 'Œ'), + ('Ŕ', 'Ŕ'), + ('Ŗ', 'Ŗ'), + ('Ř', 'Ř'), + ('Ś', 'Ś'), + ('Ŝ', 'Ŝ'), + ('Ş', 'Ş'), + ('Š', 'Š'), + ('Ţ', 'Ţ'), + ('Ť', 'Ť'), + ('Ŧ', 'Ŧ'), + ('Ũ', 'Ũ'), + ('Ū', 'Ū'), + ('Ŭ', 'Ŭ'), + ('Ů', 'Ů'), + ('Ű', 'Ű'), + ('Ų', 'Ų'), + ('Ŵ', 'Ŵ'), + ('Ŷ', 'Ŷ'), + ('Ÿ', 'Ź'), + ('Ż', 'Ż'), + ('Ž', 'Ž'), + ('Ɓ', 'Ƃ'), + ('Ƅ', 'Ƅ'), + ('Ɔ', 'Ƈ'), + ('Ɖ', 'Ƌ'), + ('Ǝ', 'Ƒ'), + ('Ɠ', 'Ɣ'), + ('Ɩ', 'Ƙ'), + ('Ɯ', 'Ɲ'), + ('Ɵ', 'Ơ'), + ('Ƣ', 'Ƣ'), + ('Ƥ', 'Ƥ'), + ('Ʀ', 'Ƨ'), + ('Ʃ', 'Ʃ'), + ('Ƭ', 'Ƭ'), + ('Ʈ', 'Ư'), + ('Ʊ', 'Ƴ'), + ('Ƶ', 'Ƶ'), + ('Ʒ', 'Ƹ'), + ('Ƽ', 'Ƽ'), + ('DŽ', 'Dž'), + ('LJ', 'Lj'), + ('NJ', 'Nj'), + ('Ǎ', 'Ǎ'), + ('Ǐ', 'Ǐ'), + ('Ǒ', 'Ǒ'), + ('Ǔ', 'Ǔ'), + ('Ǖ', 'Ǖ'), + ('Ǘ', 'Ǘ'), + ('Ǚ', 'Ǚ'), + ('Ǜ', 'Ǜ'), + ('Ǟ', 'Ǟ'), + ('Ǡ', 'Ǡ'), + ('Ǣ', 'Ǣ'), + ('Ǥ', 'Ǥ'), + ('Ǧ', 'Ǧ'), + ('Ǩ', 'Ǩ'), + ('Ǫ', 'Ǫ'), + ('Ǭ', 'Ǭ'), + ('Ǯ', 'Ǯ'), + ('DZ', 'Dz'), + ('Ǵ', 'Ǵ'), + ('Ƕ', 'Ǹ'), + ('Ǻ', 'Ǻ'), + ('Ǽ', 'Ǽ'), + ('Ǿ', 'Ǿ'), + ('Ȁ', 'Ȁ'), + ('Ȃ', 'Ȃ'), + ('Ȅ', 'Ȅ'), + ('Ȇ', 'Ȇ'), + ('Ȉ', 'Ȉ'), + ('Ȋ', 'Ȋ'), + ('Ȍ', 'Ȍ'), + ('Ȏ', 'Ȏ'), + ('Ȑ', 'Ȑ'), + ('Ȓ', 'Ȓ'), + ('Ȕ', 'Ȕ'), + ('Ȗ', 'Ȗ'), + ('Ș', 'Ș'), + ('Ț', 'Ț'), + ('Ȝ', 'Ȝ'), + ('Ȟ', 'Ȟ'), + ('Ƞ', 'Ƞ'), + ('Ȣ', 'Ȣ'), + ('Ȥ', 'Ȥ'), + ('Ȧ', 'Ȧ'), + ('Ȩ', 'Ȩ'), + ('Ȫ', 'Ȫ'), + ('Ȭ', 'Ȭ'), + ('Ȯ', 'Ȯ'), + ('Ȱ', 'Ȱ'), + ('Ȳ', 'Ȳ'), + ('Ⱥ', 'Ȼ'), + ('Ƚ', 'Ⱦ'), + ('Ɂ', 'Ɂ'), + ('Ƀ', 'Ɇ'), + ('Ɉ', 'Ɉ'), + ('Ɋ', 'Ɋ'), + ('Ɍ', 'Ɍ'), + ('Ɏ', 'Ɏ'), + ('Ͱ', 'Ͱ'), + ('Ͳ', 'Ͳ'), + ('Ͷ', 'Ͷ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ώ'), + ('Α', 'Ρ'), + ('Σ', 'Ϋ'), + ('Ϗ', 'Ϗ'), + ('Ϙ', 'Ϙ'), + ('Ϛ', 'Ϛ'), + ('Ϝ', 'Ϝ'), + ('Ϟ', 'Ϟ'), + ('Ϡ', 'Ϡ'), + ('Ϣ', 'Ϣ'), + ('Ϥ', 'Ϥ'), + ('Ϧ', 'Ϧ'), + ('Ϩ', 'Ϩ'), + ('Ϫ', 'Ϫ'), + ('Ϭ', 'Ϭ'), + ('Ϯ', 'Ϯ'), + ('ϴ', 'ϴ'), + ('Ϸ', 'Ϸ'), + ('Ϲ', 'Ϻ'), + ('Ͻ', 'Я'), + ('Ѡ', 'Ѡ'), + ('Ѣ', 'Ѣ'), + ('Ѥ', 'Ѥ'), + ('Ѧ', 'Ѧ'), + ('Ѩ', 'Ѩ'), + ('Ѫ', 'Ѫ'), + ('Ѭ', 'Ѭ'), + ('Ѯ', 'Ѯ'), + ('Ѱ', 'Ѱ'), + ('Ѳ', 'Ѳ'), + ('Ѵ', 'Ѵ'), + ('Ѷ', 'Ѷ'), + ('Ѹ', 'Ѹ'), + ('Ѻ', 'Ѻ'), + ('Ѽ', 'Ѽ'), + ('Ѿ', 'Ѿ'), + ('Ҁ', 'Ҁ'), + ('Ҋ', 'Ҋ'), + ('Ҍ', 'Ҍ'), + ('Ҏ', 'Ҏ'), + ('Ґ', 'Ґ'), + ('Ғ', 'Ғ'), + ('Ҕ', 'Ҕ'), + ('Җ', 'Җ'), + ('Ҙ', 'Ҙ'), + ('Қ', 'Қ'), + ('Ҝ', 'Ҝ'), + ('Ҟ', 'Ҟ'), + ('Ҡ', 'Ҡ'), + ('Ң', 'Ң'), + ('Ҥ', 'Ҥ'), + ('Ҧ', 'Ҧ'), + ('Ҩ', 'Ҩ'), + ('Ҫ', 'Ҫ'), + ('Ҭ', 'Ҭ'), + ('Ү', 'Ү'), + ('Ұ', 'Ұ'), + ('Ҳ', 'Ҳ'), + ('Ҵ', 'Ҵ'), + ('Ҷ', 'Ҷ'), + ('Ҹ', 'Ҹ'), + ('Һ', 'Һ'), + ('Ҽ', 'Ҽ'), + ('Ҿ', 'Ҿ'), + ('Ӏ', 'Ӂ'), + ('Ӄ', 'Ӄ'), + ('Ӆ', 'Ӆ'), + ('Ӈ', 'Ӈ'), + ('Ӊ', 'Ӊ'), + ('Ӌ', 'Ӌ'), + ('Ӎ', 'Ӎ'), + ('Ӑ', 'Ӑ'), + ('Ӓ', 'Ӓ'), + ('Ӕ', 'Ӕ'), + ('Ӗ', 'Ӗ'), + ('Ә', 'Ә'), + ('Ӛ', 'Ӛ'), + ('Ӝ', 'Ӝ'), + ('Ӟ', 'Ӟ'), + ('Ӡ', 'Ӡ'), + ('Ӣ', 'Ӣ'), + ('Ӥ', 'Ӥ'), + ('Ӧ', 'Ӧ'), + ('Ө', 'Ө'), + ('Ӫ', 'Ӫ'), + ('Ӭ', 'Ӭ'), + ('Ӯ', 'Ӯ'), + ('Ӱ', 'Ӱ'), + ('Ӳ', 'Ӳ'), + ('Ӵ', 'Ӵ'), + ('Ӷ', 'Ӷ'), + ('Ӹ', 'Ӹ'), + ('Ӻ', 'Ӻ'), + ('Ӽ', 'Ӽ'), + ('Ӿ', 'Ӿ'), + ('Ԁ', 'Ԁ'), + ('Ԃ', 'Ԃ'), + ('Ԅ', 'Ԅ'), + ('Ԇ', 'Ԇ'), + ('Ԉ', 'Ԉ'), + ('Ԋ', 'Ԋ'), + ('Ԍ', 'Ԍ'), + ('Ԏ', 'Ԏ'), + ('Ԑ', 'Ԑ'), + ('Ԓ', 'Ԓ'), + ('Ԕ', 'Ԕ'), + ('Ԗ', 'Ԗ'), + ('Ԙ', 'Ԙ'), + ('Ԛ', 'Ԛ'), + ('Ԝ', 'Ԝ'), + ('Ԟ', 'Ԟ'), + ('Ԡ', 'Ԡ'), + ('Ԣ', 'Ԣ'), + ('Ԥ', 'Ԥ'), + ('Ԧ', 'Ԧ'), + ('Ԩ', 'Ԩ'), + ('Ԫ', 'Ԫ'), + ('Ԭ', 'Ԭ'), + ('Ԯ', 'Ԯ'), + ('Ա', 'Ֆ'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('Ꭰ', 'Ᏽ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('Ḁ', 'Ḁ'), + ('Ḃ', 'Ḃ'), + ('Ḅ', 'Ḅ'), + ('Ḇ', 'Ḇ'), + ('Ḉ', 'Ḉ'), + ('Ḋ', 'Ḋ'), + ('Ḍ', 'Ḍ'), + ('Ḏ', 'Ḏ'), + ('Ḑ', 'Ḑ'), + ('Ḓ', 'Ḓ'), + ('Ḕ', 'Ḕ'), + ('Ḗ', 'Ḗ'), + ('Ḙ', 'Ḙ'), + ('Ḛ', 'Ḛ'), + ('Ḝ', 'Ḝ'), + ('Ḟ', 'Ḟ'), + ('Ḡ', 'Ḡ'), + ('Ḣ', 'Ḣ'), + ('Ḥ', 'Ḥ'), + ('Ḧ', 'Ḧ'), + ('Ḩ', 'Ḩ'), + ('Ḫ', 'Ḫ'), + ('Ḭ', 'Ḭ'), + ('Ḯ', 'Ḯ'), + ('Ḱ', 'Ḱ'), + ('Ḳ', 'Ḳ'), + ('Ḵ', 'Ḵ'), + ('Ḷ', 'Ḷ'), + ('Ḹ', 'Ḹ'), + ('Ḻ', 'Ḻ'), + ('Ḽ', 'Ḽ'), + ('Ḿ', 'Ḿ'), + ('Ṁ', 'Ṁ'), + ('Ṃ', 'Ṃ'), + ('Ṅ', 'Ṅ'), + ('Ṇ', 'Ṇ'), + ('Ṉ', 'Ṉ'), + ('Ṋ', 'Ṋ'), + ('Ṍ', 'Ṍ'), + ('Ṏ', 'Ṏ'), + ('Ṑ', 'Ṑ'), + ('Ṓ', 'Ṓ'), + ('Ṕ', 'Ṕ'), + ('Ṗ', 'Ṗ'), + ('Ṙ', 'Ṙ'), + ('Ṛ', 'Ṛ'), + ('Ṝ', 'Ṝ'), + ('Ṟ', 'Ṟ'), + ('Ṡ', 'Ṡ'), + ('Ṣ', 'Ṣ'), + ('Ṥ', 'Ṥ'), + ('Ṧ', 'Ṧ'), + ('Ṩ', 'Ṩ'), + ('Ṫ', 'Ṫ'), + ('Ṭ', 'Ṭ'), + ('Ṯ', 'Ṯ'), + ('Ṱ', 'Ṱ'), + ('Ṳ', 'Ṳ'), + ('Ṵ', 'Ṵ'), + ('Ṷ', 'Ṷ'), + ('Ṹ', 'Ṹ'), + ('Ṻ', 'Ṻ'), + ('Ṽ', 'Ṽ'), + ('Ṿ', 'Ṿ'), + ('Ẁ', 'Ẁ'), + ('Ẃ', 'Ẃ'), + ('Ẅ', 'Ẅ'), + ('Ẇ', 'Ẇ'), + ('Ẉ', 'Ẉ'), + ('Ẋ', 'Ẋ'), + ('Ẍ', 'Ẍ'), + ('Ẏ', 'Ẏ'), + ('Ẑ', 'Ẑ'), + ('Ẓ', 'Ẓ'), + ('Ẕ', 'Ẕ'), + ('ẞ', 'ẞ'), + ('Ạ', 'Ạ'), + ('Ả', 'Ả'), + ('Ấ', 'Ấ'), + ('Ầ', 'Ầ'), + ('Ẩ', 'Ẩ'), + ('Ẫ', 'Ẫ'), + ('Ậ', 'Ậ'), + ('Ắ', 'Ắ'), + ('Ằ', 'Ằ'), + ('Ẳ', 'Ẳ'), + ('Ẵ', 'Ẵ'), + ('Ặ', 'Ặ'), + ('Ẹ', 'Ẹ'), + ('Ẻ', 'Ẻ'), + ('Ẽ', 'Ẽ'), + ('Ế', 'Ế'), + ('Ề', 'Ề'), + ('Ể', 'Ể'), + ('Ễ', 'Ễ'), + ('Ệ', 'Ệ'), + ('Ỉ', 'Ỉ'), + ('Ị', 'Ị'), + ('Ọ', 'Ọ'), + ('Ỏ', 'Ỏ'), + ('Ố', 'Ố'), + ('Ồ', 'Ồ'), + ('Ổ', 'Ổ'), + ('Ỗ', 'Ỗ'), + ('Ộ', 'Ộ'), + ('Ớ', 'Ớ'), + ('Ờ', 'Ờ'), + ('Ở', 'Ở'), + ('Ỡ', 'Ỡ'), + ('Ợ', 'Ợ'), + ('Ụ', 'Ụ'), + ('Ủ', 'Ủ'), + ('Ứ', 'Ứ'), + ('Ừ', 'Ừ'), + ('Ử', 'Ử'), + ('Ữ', 'Ữ'), + ('Ự', 'Ự'), + ('Ỳ', 'Ỳ'), + ('Ỵ', 'Ỵ'), + ('Ỷ', 'Ỷ'), + ('Ỹ', 'Ỹ'), + ('Ỻ', 'Ỻ'), + ('Ỽ', 'Ỽ'), + ('Ỿ', 'Ỿ'), + ('Ἀ', 'Ἇ'), + ('Ἐ', 'Ἕ'), + ('Ἠ', 'Ἧ'), + ('Ἰ', 'Ἷ'), + ('Ὀ', 'Ὅ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'Ὗ'), + ('Ὠ', 'Ὧ'), + ('ᾈ', 'ᾏ'), + ('ᾘ', 'ᾟ'), + ('ᾨ', 'ᾯ'), + ('Ᾰ', 'ᾼ'), + ('Ὲ', 'ῌ'), + ('Ῐ', 'Ί'), + ('Ῠ', 'Ῥ'), + ('Ὸ', 'ῼ'), + ('Ω', 'Ω'), + ('K', 'Å'), + ('Ⅎ', 'Ⅎ'), + ('Ⅰ', 'Ⅿ'), + ('Ↄ', 'Ↄ'), + ('Ⓐ', 'Ⓩ'), + ('Ⰰ', 'Ⱞ'), + ('Ⱡ', 'Ⱡ'), + ('Ɫ', 'Ɽ'), + ('Ⱨ', 'Ⱨ'), + ('Ⱪ', 'Ⱪ'), + ('Ⱬ', 'Ⱬ'), + ('Ɑ', 'Ɒ'), + ('Ⱳ', 'Ⱳ'), + ('Ⱶ', 'Ⱶ'), + ('Ȿ', 'Ⲁ'), + ('Ⲃ', 'Ⲃ'), + ('Ⲅ', 'Ⲅ'), + ('Ⲇ', 'Ⲇ'), + ('Ⲉ', 'Ⲉ'), + ('Ⲋ', 'Ⲋ'), + ('Ⲍ', 'Ⲍ'), + ('Ⲏ', 'Ⲏ'), + ('Ⲑ', 'Ⲑ'), + ('Ⲓ', 'Ⲓ'), + ('Ⲕ', 'Ⲕ'), + ('Ⲗ', 'Ⲗ'), + ('Ⲙ', 'Ⲙ'), + ('Ⲛ', 'Ⲛ'), + ('Ⲝ', 'Ⲝ'), + ('Ⲟ', 'Ⲟ'), + ('Ⲡ', 'Ⲡ'), + ('Ⲣ', 'Ⲣ'), + ('Ⲥ', 'Ⲥ'), + ('Ⲧ', 'Ⲧ'), + ('Ⲩ', 'Ⲩ'), + ('Ⲫ', 'Ⲫ'), + ('Ⲭ', 'Ⲭ'), + ('Ⲯ', 'Ⲯ'), + ('Ⲱ', 'Ⲱ'), + ('Ⲳ', 'Ⲳ'), + ('Ⲵ', 'Ⲵ'), + ('Ⲷ', 'Ⲷ'), + ('Ⲹ', 'Ⲹ'), + ('Ⲻ', 'Ⲻ'), + ('Ⲽ', 'Ⲽ'), + ('Ⲿ', 'Ⲿ'), + ('Ⳁ', 'Ⳁ'), + ('Ⳃ', 'Ⳃ'), + ('Ⳅ', 'Ⳅ'), + ('Ⳇ', 'Ⳇ'), + ('Ⳉ', 'Ⳉ'), + ('Ⳋ', 'Ⳋ'), + ('Ⳍ', 'Ⳍ'), + ('Ⳏ', 'Ⳏ'), + ('Ⳑ', 'Ⳑ'), + ('Ⳓ', 'Ⳓ'), + ('Ⳕ', 'Ⳕ'), + ('Ⳗ', 'Ⳗ'), + ('Ⳙ', 'Ⳙ'), + ('Ⳛ', 'Ⳛ'), + ('Ⳝ', 'Ⳝ'), + ('Ⳟ', 'Ⳟ'), + ('Ⳡ', 'Ⳡ'), + ('Ⳣ', 'Ⳣ'), + ('Ⳬ', 'Ⳬ'), + ('Ⳮ', 'Ⳮ'), + ('Ⳳ', 'Ⳳ'), + ('Ꙁ', 'Ꙁ'), + ('Ꙃ', 'Ꙃ'), + ('Ꙅ', 'Ꙅ'), + ('Ꙇ', 'Ꙇ'), + ('Ꙉ', 'Ꙉ'), + ('Ꙋ', 'Ꙋ'), + ('Ꙍ', 'Ꙍ'), + ('Ꙏ', 'Ꙏ'), + ('Ꙑ', 'Ꙑ'), + ('Ꙓ', 'Ꙓ'), + ('Ꙕ', 'Ꙕ'), + ('Ꙗ', 'Ꙗ'), + ('Ꙙ', 'Ꙙ'), + ('Ꙛ', 'Ꙛ'), + ('Ꙝ', 'Ꙝ'), + ('Ꙟ', 'Ꙟ'), + ('Ꙡ', 'Ꙡ'), + ('Ꙣ', 'Ꙣ'), + ('Ꙥ', 'Ꙥ'), + ('Ꙧ', 'Ꙧ'), + ('Ꙩ', 'Ꙩ'), + ('Ꙫ', 'Ꙫ'), + ('Ꙭ', 'Ꙭ'), + ('Ꚁ', 'Ꚁ'), + ('Ꚃ', 'Ꚃ'), + ('Ꚅ', 'Ꚅ'), + ('Ꚇ', 'Ꚇ'), + ('Ꚉ', 'Ꚉ'), + ('Ꚋ', 'Ꚋ'), + ('Ꚍ', 'Ꚍ'), + ('Ꚏ', 'Ꚏ'), + ('Ꚑ', 'Ꚑ'), + ('Ꚓ', 'Ꚓ'), + ('Ꚕ', 'Ꚕ'), + ('Ꚗ', 'Ꚗ'), + ('Ꚙ', 'Ꚙ'), + ('Ꚛ', 'Ꚛ'), + ('Ꜣ', 'Ꜣ'), + ('Ꜥ', 'Ꜥ'), + ('Ꜧ', 'Ꜧ'), + ('Ꜩ', 'Ꜩ'), + ('Ꜫ', 'Ꜫ'), + ('Ꜭ', 'Ꜭ'), + ('Ꜯ', 'Ꜯ'), + ('Ꜳ', 'Ꜳ'), + ('Ꜵ', 'Ꜵ'), + ('Ꜷ', 'Ꜷ'), + ('Ꜹ', 'Ꜹ'), + ('Ꜻ', 'Ꜻ'), + ('Ꜽ', 'Ꜽ'), + ('Ꜿ', 'Ꜿ'), + ('Ꝁ', 'Ꝁ'), + ('Ꝃ', 'Ꝃ'), + ('Ꝅ', 'Ꝅ'), + ('Ꝇ', 'Ꝇ'), + ('Ꝉ', 'Ꝉ'), + ('Ꝋ', 'Ꝋ'), + ('Ꝍ', 'Ꝍ'), + ('Ꝏ', 'Ꝏ'), + ('Ꝑ', 'Ꝑ'), + ('Ꝓ', 'Ꝓ'), + ('Ꝕ', 'Ꝕ'), + ('Ꝗ', 'Ꝗ'), + ('Ꝙ', 'Ꝙ'), + ('Ꝛ', 'Ꝛ'), + ('Ꝝ', 'Ꝝ'), + ('Ꝟ', 'Ꝟ'), + ('Ꝡ', 'Ꝡ'), + ('Ꝣ', 'Ꝣ'), + ('Ꝥ', 'Ꝥ'), + ('Ꝧ', 'Ꝧ'), + ('Ꝩ', 'Ꝩ'), + ('Ꝫ', 'Ꝫ'), + ('Ꝭ', 'Ꝭ'), + ('Ꝯ', 'Ꝯ'), + ('Ꝺ', 'Ꝺ'), + ('Ꝼ', 'Ꝼ'), + ('Ᵹ', 'Ꝿ'), + ('Ꞁ', 'Ꞁ'), + ('Ꞃ', 'Ꞃ'), + ('Ꞅ', 'Ꞅ'), + ('Ꞇ', 'Ꞇ'), + ('Ꞌ', 'Ꞌ'), + ('Ɥ', 'Ɥ'), + ('Ꞑ', 'Ꞑ'), + ('Ꞓ', 'Ꞓ'), + ('Ꞗ', 'Ꞗ'), + ('Ꞙ', 'Ꞙ'), + ('Ꞛ', 'Ꞛ'), + ('Ꞝ', 'Ꞝ'), + ('Ꞟ', 'Ꞟ'), + ('Ꞡ', 'Ꞡ'), + ('Ꞣ', 'Ꞣ'), + ('Ꞥ', 'Ꞥ'), + ('Ꞧ', 'Ꞧ'), + ('Ꞩ', 'Ꞩ'), + ('Ɦ', 'Ɪ'), + ('Ʞ', 'Ꞵ'), + ('Ꞷ', 'Ꞷ'), + ('Ꞹ', 'Ꞹ'), + ('\u{a7ba}', '\u{a7ba}'), + ('\u{a7bc}', '\u{a7bc}'), + ('\u{a7be}', '\u{a7be}'), + ('\u{a7c2}', '\u{a7c2}'), + ('\u{a7c4}', '\u{a7c6}'), + ('A', 'Z'), + ('𐐀', '𐐧'), + ('𐒰', '𐓓'), + ('𐲀', '𐲲'), + ('𑢠', '𑢿'), + ('𖹀', '𖹟'), + ('𞤀', '𞤡'), +]; + +pub const CHANGES_WHEN_TITLECASED: &'static [(char, char)] = &[ + ('a', 'z'), + ('µ', 'µ'), + ('ß', 'ö'), + ('ø', 'ÿ'), + ('ā', 'ā'), + ('ă', 'ă'), + ('ą', 'ą'), + ('ć', 'ć'), + ('ĉ', 'ĉ'), + ('ċ', 'ċ'), + ('č', 'č'), + ('ď', 'ď'), + ('đ', 'đ'), + ('ē', 'ē'), + ('ĕ', 'ĕ'), + ('ė', 'ė'), + ('ę', 'ę'), + ('ě', 'ě'), + ('ĝ', 'ĝ'), + ('ğ', 'ğ'), + ('ġ', 'ġ'), + ('ģ', 'ģ'), + ('ĥ', 'ĥ'), + ('ħ', 'ħ'), + ('ĩ', 'ĩ'), + ('ī', 'ī'), + ('ĭ', 'ĭ'), + ('į', 'į'), + ('ı', 'ı'), + ('ij', 'ij'), + ('ĵ', 'ĵ'), + ('ķ', 'ķ'), + ('ĺ', 'ĺ'), + ('ļ', 'ļ'), + ('ľ', 'ľ'), + ('ŀ', 'ŀ'), + ('ł', 'ł'), + ('ń', 'ń'), + ('ņ', 'ņ'), + ('ň', 'ʼn'), + ('ŋ', 'ŋ'), + ('ō', 'ō'), + ('ŏ', 'ŏ'), + ('ő', 'ő'), + ('œ', 'œ'), + ('ŕ', 'ŕ'), + ('ŗ', 'ŗ'), + ('ř', 'ř'), + ('ś', 'ś'), + ('ŝ', 'ŝ'), + ('ş', 'ş'), + ('š', 'š'), + ('ţ', 'ţ'), + ('ť', 'ť'), + ('ŧ', 'ŧ'), + ('ũ', 'ũ'), + ('ū', 'ū'), + ('ŭ', 'ŭ'), + ('ů', 'ů'), + ('ű', 'ű'), + ('ų', 'ų'), + ('ŵ', 'ŵ'), + ('ŷ', 'ŷ'), + ('ź', 'ź'), + ('ż', 'ż'), + ('ž', 'ƀ'), + ('ƃ', 'ƃ'), + ('ƅ', 'ƅ'), + ('ƈ', 'ƈ'), + ('ƌ', 'ƌ'), + ('ƒ', 'ƒ'), + ('ƕ', 'ƕ'), + ('ƙ', 'ƚ'), + ('ƞ', 'ƞ'), + ('ơ', 'ơ'), + ('ƣ', 'ƣ'), + ('ƥ', 'ƥ'), + ('ƨ', 'ƨ'), + ('ƭ', 'ƭ'), + ('ư', 'ư'), + ('ƴ', 'ƴ'), + ('ƶ', 'ƶ'), + ('ƹ', 'ƹ'), + ('ƽ', 'ƽ'), + ('ƿ', 'ƿ'), + ('DŽ', 'DŽ'), + ('dž', 'LJ'), + ('lj', 'NJ'), + ('nj', 'nj'), + ('ǎ', 'ǎ'), + ('ǐ', 'ǐ'), + ('ǒ', 'ǒ'), + ('ǔ', 'ǔ'), + ('ǖ', 'ǖ'), + ('ǘ', 'ǘ'), + ('ǚ', 'ǚ'), + ('ǜ', 'ǝ'), + ('ǟ', 'ǟ'), + ('ǡ', 'ǡ'), + ('ǣ', 'ǣ'), + ('ǥ', 'ǥ'), + ('ǧ', 'ǧ'), + ('ǩ', 'ǩ'), + ('ǫ', 'ǫ'), + ('ǭ', 'ǭ'), + ('ǯ', 'DZ'), + ('dz', 'dz'), + ('ǵ', 'ǵ'), + ('ǹ', 'ǹ'), + ('ǻ', 'ǻ'), + ('ǽ', 'ǽ'), + ('ǿ', 'ǿ'), + ('ȁ', 'ȁ'), + ('ȃ', 'ȃ'), + ('ȅ', 'ȅ'), + ('ȇ', 'ȇ'), + ('ȉ', 'ȉ'), + ('ȋ', 'ȋ'), + ('ȍ', 'ȍ'), + ('ȏ', 'ȏ'), + ('ȑ', 'ȑ'), + ('ȓ', 'ȓ'), + ('ȕ', 'ȕ'), + ('ȗ', 'ȗ'), + ('ș', 'ș'), + ('ț', 'ț'), + ('ȝ', 'ȝ'), + ('ȟ', 'ȟ'), + ('ȣ', 'ȣ'), + ('ȥ', 'ȥ'), + ('ȧ', 'ȧ'), + ('ȩ', 'ȩ'), + ('ȫ', 'ȫ'), + ('ȭ', 'ȭ'), + ('ȯ', 'ȯ'), + ('ȱ', 'ȱ'), + ('ȳ', 'ȳ'), + ('ȼ', 'ȼ'), + ('ȿ', 'ɀ'), + ('ɂ', 'ɂ'), + ('ɇ', 'ɇ'), + ('ɉ', 'ɉ'), + ('ɋ', 'ɋ'), + ('ɍ', 'ɍ'), + ('ɏ', 'ɔ'), + ('ɖ', 'ɗ'), + ('ə', 'ə'), + ('ɛ', 'ɜ'), + ('ɠ', 'ɡ'), + ('ɣ', 'ɣ'), + ('ɥ', 'ɦ'), + ('ɨ', 'ɬ'), + ('ɯ', 'ɯ'), + ('ɱ', 'ɲ'), + ('ɵ', 'ɵ'), + ('ɽ', 'ɽ'), + ('ʀ', 'ʀ'), + ('ʂ', 'ʃ'), + ('ʇ', 'ʌ'), + ('ʒ', 'ʒ'), + ('ʝ', 'ʞ'), + ('\u{345}', '\u{345}'), + ('ͱ', 'ͱ'), + ('ͳ', 'ͳ'), + ('ͷ', 'ͷ'), + ('ͻ', 'ͽ'), + ('ΐ', 'ΐ'), + ('ά', 'ώ'), + ('ϐ', 'ϑ'), + ('ϕ', 'ϗ'), + ('ϙ', 'ϙ'), + ('ϛ', 'ϛ'), + ('ϝ', 'ϝ'), + ('ϟ', 'ϟ'), + ('ϡ', 'ϡ'), + ('ϣ', 'ϣ'), + ('ϥ', 'ϥ'), + ('ϧ', 'ϧ'), + ('ϩ', 'ϩ'), + ('ϫ', 'ϫ'), + ('ϭ', 'ϭ'), + ('ϯ', 'ϳ'), + ('ϵ', 'ϵ'), + ('ϸ', 'ϸ'), + ('ϻ', 'ϻ'), + ('а', 'џ'), + ('ѡ', 'ѡ'), + ('ѣ', 'ѣ'), + ('ѥ', 'ѥ'), + ('ѧ', 'ѧ'), + ('ѩ', 'ѩ'), + ('ѫ', 'ѫ'), + ('ѭ', 'ѭ'), + ('ѯ', 'ѯ'), + ('ѱ', 'ѱ'), + ('ѳ', 'ѳ'), + ('ѵ', 'ѵ'), + ('ѷ', 'ѷ'), + ('ѹ', 'ѹ'), + ('ѻ', 'ѻ'), + ('ѽ', 'ѽ'), + ('ѿ', 'ѿ'), + ('ҁ', 'ҁ'), + ('ҋ', 'ҋ'), + ('ҍ', 'ҍ'), + ('ҏ', 'ҏ'), + ('ґ', 'ґ'), + ('ғ', 'ғ'), + ('ҕ', 'ҕ'), + ('җ', 'җ'), + ('ҙ', 'ҙ'), + ('қ', 'қ'), + ('ҝ', 'ҝ'), + ('ҟ', 'ҟ'), + ('ҡ', 'ҡ'), + ('ң', 'ң'), + ('ҥ', 'ҥ'), + ('ҧ', 'ҧ'), + ('ҩ', 'ҩ'), + ('ҫ', 'ҫ'), + ('ҭ', 'ҭ'), + ('ү', 'ү'), + ('ұ', 'ұ'), + ('ҳ', 'ҳ'), + ('ҵ', 'ҵ'), + ('ҷ', 'ҷ'), + ('ҹ', 'ҹ'), + ('һ', 'һ'), + ('ҽ', 'ҽ'), + ('ҿ', 'ҿ'), + ('ӂ', 'ӂ'), + ('ӄ', 'ӄ'), + ('ӆ', 'ӆ'), + ('ӈ', 'ӈ'), + ('ӊ', 'ӊ'), + ('ӌ', 'ӌ'), + ('ӎ', 'ӏ'), + ('ӑ', 'ӑ'), + ('ӓ', 'ӓ'), + ('ӕ', 'ӕ'), + ('ӗ', 'ӗ'), + ('ә', 'ә'), + ('ӛ', 'ӛ'), + ('ӝ', 'ӝ'), + ('ӟ', 'ӟ'), + ('ӡ', 'ӡ'), + ('ӣ', 'ӣ'), + ('ӥ', 'ӥ'), + ('ӧ', 'ӧ'), + ('ө', 'ө'), + ('ӫ', 'ӫ'), + ('ӭ', 'ӭ'), + ('ӯ', 'ӯ'), + ('ӱ', 'ӱ'), + ('ӳ', 'ӳ'), + ('ӵ', 'ӵ'), + ('ӷ', 'ӷ'), + ('ӹ', 'ӹ'), + ('ӻ', 'ӻ'), + ('ӽ', 'ӽ'), + ('ӿ', 'ӿ'), + ('ԁ', 'ԁ'), + ('ԃ', 'ԃ'), + ('ԅ', 'ԅ'), + ('ԇ', 'ԇ'), + ('ԉ', 'ԉ'), + ('ԋ', 'ԋ'), + ('ԍ', 'ԍ'), + ('ԏ', 'ԏ'), + ('ԑ', 'ԑ'), + ('ԓ', 'ԓ'), + ('ԕ', 'ԕ'), + ('ԗ', 'ԗ'), + ('ԙ', 'ԙ'), + ('ԛ', 'ԛ'), + ('ԝ', 'ԝ'), + ('ԟ', 'ԟ'), + ('ԡ', 'ԡ'), + ('ԣ', 'ԣ'), + ('ԥ', 'ԥ'), + ('ԧ', 'ԧ'), + ('ԩ', 'ԩ'), + ('ԫ', 'ԫ'), + ('ԭ', 'ԭ'), + ('ԯ', 'ԯ'), + ('ա', 'և'), + ('ᏸ', 'ᏽ'), + ('ᲀ', 'ᲈ'), + ('ᵹ', 'ᵹ'), + ('ᵽ', 'ᵽ'), + ('ᶎ', 'ᶎ'), + ('ḁ', 'ḁ'), + ('ḃ', 'ḃ'), + ('ḅ', 'ḅ'), + ('ḇ', 'ḇ'), + ('ḉ', 'ḉ'), + ('ḋ', 'ḋ'), + ('ḍ', 'ḍ'), + ('ḏ', 'ḏ'), + ('ḑ', 'ḑ'), + ('ḓ', 'ḓ'), + ('ḕ', 'ḕ'), + ('ḗ', 'ḗ'), + ('ḙ', 'ḙ'), + ('ḛ', 'ḛ'), + ('ḝ', 'ḝ'), + ('ḟ', 'ḟ'), + ('ḡ', 'ḡ'), + ('ḣ', 'ḣ'), + ('ḥ', 'ḥ'), + ('ḧ', 'ḧ'), + ('ḩ', 'ḩ'), + ('ḫ', 'ḫ'), + ('ḭ', 'ḭ'), + ('ḯ', 'ḯ'), + ('ḱ', 'ḱ'), + ('ḳ', 'ḳ'), + ('ḵ', 'ḵ'), + ('ḷ', 'ḷ'), + ('ḹ', 'ḹ'), + ('ḻ', 'ḻ'), + ('ḽ', 'ḽ'), + ('ḿ', 'ḿ'), + ('ṁ', 'ṁ'), + ('ṃ', 'ṃ'), + ('ṅ', 'ṅ'), + ('ṇ', 'ṇ'), + ('ṉ', 'ṉ'), + ('ṋ', 'ṋ'), + ('ṍ', 'ṍ'), + ('ṏ', 'ṏ'), + ('ṑ', 'ṑ'), + ('ṓ', 'ṓ'), + ('ṕ', 'ṕ'), + ('ṗ', 'ṗ'), + ('ṙ', 'ṙ'), + ('ṛ', 'ṛ'), + ('ṝ', 'ṝ'), + ('ṟ', 'ṟ'), + ('ṡ', 'ṡ'), + ('ṣ', 'ṣ'), + ('ṥ', 'ṥ'), + ('ṧ', 'ṧ'), + ('ṩ', 'ṩ'), + ('ṫ', 'ṫ'), + ('ṭ', 'ṭ'), + ('ṯ', 'ṯ'), + ('ṱ', 'ṱ'), + ('ṳ', 'ṳ'), + ('ṵ', 'ṵ'), + ('ṷ', 'ṷ'), + ('ṹ', 'ṹ'), + ('ṻ', 'ṻ'), + ('ṽ', 'ṽ'), + ('ṿ', 'ṿ'), + ('ẁ', 'ẁ'), + ('ẃ', 'ẃ'), + ('ẅ', 'ẅ'), + ('ẇ', 'ẇ'), + ('ẉ', 'ẉ'), + ('ẋ', 'ẋ'), + ('ẍ', 'ẍ'), + ('ẏ', 'ẏ'), + ('ẑ', 'ẑ'), + ('ẓ', 'ẓ'), + ('ẕ', 'ẛ'), + ('ạ', 'ạ'), + ('ả', 'ả'), + ('ấ', 'ấ'), + ('ầ', 'ầ'), + ('ẩ', 'ẩ'), + ('ẫ', 'ẫ'), + ('ậ', 'ậ'), + ('ắ', 'ắ'), + ('ằ', 'ằ'), + ('ẳ', 'ẳ'), + ('ẵ', 'ẵ'), + ('ặ', 'ặ'), + ('ẹ', 'ẹ'), + ('ẻ', 'ẻ'), + ('ẽ', 'ẽ'), + ('ế', 'ế'), + ('ề', 'ề'), + ('ể', 'ể'), + ('ễ', 'ễ'), + ('ệ', 'ệ'), + ('ỉ', 'ỉ'), + ('ị', 'ị'), + ('ọ', 'ọ'), + ('ỏ', 'ỏ'), + ('ố', 'ố'), + ('ồ', 'ồ'), + ('ổ', 'ổ'), + ('ỗ', 'ỗ'), + ('ộ', 'ộ'), + ('ớ', 'ớ'), + ('ờ', 'ờ'), + ('ở', 'ở'), + ('ỡ', 'ỡ'), + ('ợ', 'ợ'), + ('ụ', 'ụ'), + ('ủ', 'ủ'), + ('ứ', 'ứ'), + ('ừ', 'ừ'), + ('ử', 'ử'), + ('ữ', 'ữ'), + ('ự', 'ự'), + ('ỳ', 'ỳ'), + ('ỵ', 'ỵ'), + ('ỷ', 'ỷ'), + ('ỹ', 'ỹ'), + ('ỻ', 'ỻ'), + ('ỽ', 'ỽ'), + ('ỿ', 'ἇ'), + ('ἐ', 'ἕ'), + ('ἠ', 'ἧ'), + ('ἰ', 'ἷ'), + ('ὀ', 'ὅ'), + ('ὐ', 'ὗ'), + ('ὠ', 'ὧ'), + ('ὰ', 'ώ'), + ('ᾀ', 'ᾇ'), + ('ᾐ', 'ᾗ'), + ('ᾠ', 'ᾧ'), + ('ᾰ', 'ᾴ'), + ('ᾶ', 'ᾷ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῇ'), + ('ῐ', 'ΐ'), + ('ῖ', 'ῗ'), + ('ῠ', 'ῧ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῷ'), + ('ⅎ', 'ⅎ'), + ('ⅰ', 'ⅿ'), + ('ↄ', 'ↄ'), + ('ⓐ', 'ⓩ'), + ('ⰰ', 'ⱞ'), + ('ⱡ', 'ⱡ'), + ('ⱥ', 'ⱦ'), + ('ⱨ', 'ⱨ'), + ('ⱪ', 'ⱪ'), + ('ⱬ', 'ⱬ'), + ('ⱳ', 'ⱳ'), + ('ⱶ', 'ⱶ'), + ('ⲁ', 'ⲁ'), + ('ⲃ', 'ⲃ'), + ('ⲅ', 'ⲅ'), + ('ⲇ', 'ⲇ'), + ('ⲉ', 'ⲉ'), + ('ⲋ', 'ⲋ'), + ('ⲍ', 'ⲍ'), + ('ⲏ', 'ⲏ'), + ('ⲑ', 'ⲑ'), + ('ⲓ', 'ⲓ'), + ('ⲕ', 'ⲕ'), + ('ⲗ', 'ⲗ'), + ('ⲙ', 'ⲙ'), + ('ⲛ', 'ⲛ'), + ('ⲝ', 'ⲝ'), + ('ⲟ', 'ⲟ'), + ('ⲡ', 'ⲡ'), + ('ⲣ', 'ⲣ'), + ('ⲥ', 'ⲥ'), + ('ⲧ', 'ⲧ'), + ('ⲩ', 'ⲩ'), + ('ⲫ', 'ⲫ'), + ('ⲭ', 'ⲭ'), + ('ⲯ', 'ⲯ'), + ('ⲱ', 'ⲱ'), + ('ⲳ', 'ⲳ'), + ('ⲵ', 'ⲵ'), + ('ⲷ', 'ⲷ'), + ('ⲹ', 'ⲹ'), + ('ⲻ', 'ⲻ'), + ('ⲽ', 'ⲽ'), + ('ⲿ', 'ⲿ'), + ('ⳁ', 'ⳁ'), + ('ⳃ', 'ⳃ'), + ('ⳅ', 'ⳅ'), + ('ⳇ', 'ⳇ'), + ('ⳉ', 'ⳉ'), + ('ⳋ', 'ⳋ'), + ('ⳍ', 'ⳍ'), + ('ⳏ', 'ⳏ'), + ('ⳑ', 'ⳑ'), + ('ⳓ', 'ⳓ'), + ('ⳕ', 'ⳕ'), + ('ⳗ', 'ⳗ'), + ('ⳙ', 'ⳙ'), + ('ⳛ', 'ⳛ'), + ('ⳝ', 'ⳝ'), + ('ⳟ', 'ⳟ'), + ('ⳡ', 'ⳡ'), + ('ⳣ', 'ⳣ'), + ('ⳬ', 'ⳬ'), + ('ⳮ', 'ⳮ'), + ('ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ꙁ', 'ꙁ'), + ('ꙃ', 'ꙃ'), + ('ꙅ', 'ꙅ'), + ('ꙇ', 'ꙇ'), + ('ꙉ', 'ꙉ'), + ('ꙋ', 'ꙋ'), + ('ꙍ', 'ꙍ'), + ('ꙏ', 'ꙏ'), + ('ꙑ', 'ꙑ'), + ('ꙓ', 'ꙓ'), + ('ꙕ', 'ꙕ'), + ('ꙗ', 'ꙗ'), + ('ꙙ', 'ꙙ'), + ('ꙛ', 'ꙛ'), + ('ꙝ', 'ꙝ'), + ('ꙟ', 'ꙟ'), + ('ꙡ', 'ꙡ'), + ('ꙣ', 'ꙣ'), + ('ꙥ', 'ꙥ'), + ('ꙧ', 'ꙧ'), + ('ꙩ', 'ꙩ'), + ('ꙫ', 'ꙫ'), + ('ꙭ', 'ꙭ'), + ('ꚁ', 'ꚁ'), + ('ꚃ', 'ꚃ'), + ('ꚅ', 'ꚅ'), + ('ꚇ', 'ꚇ'), + ('ꚉ', 'ꚉ'), + ('ꚋ', 'ꚋ'), + ('ꚍ', 'ꚍ'), + ('ꚏ', 'ꚏ'), + ('ꚑ', 'ꚑ'), + ('ꚓ', 'ꚓ'), + ('ꚕ', 'ꚕ'), + ('ꚗ', 'ꚗ'), + ('ꚙ', 'ꚙ'), + ('ꚛ', 'ꚛ'), + ('ꜣ', 'ꜣ'), + ('ꜥ', 'ꜥ'), + ('ꜧ', 'ꜧ'), + ('ꜩ', 'ꜩ'), + ('ꜫ', 'ꜫ'), + ('ꜭ', 'ꜭ'), + ('ꜯ', 'ꜯ'), + ('ꜳ', 'ꜳ'), + ('ꜵ', 'ꜵ'), + ('ꜷ', 'ꜷ'), + ('ꜹ', 'ꜹ'), + ('ꜻ', 'ꜻ'), + ('ꜽ', 'ꜽ'), + ('ꜿ', 'ꜿ'), + ('ꝁ', 'ꝁ'), + ('ꝃ', 'ꝃ'), + ('ꝅ', 'ꝅ'), + ('ꝇ', 'ꝇ'), + ('ꝉ', 'ꝉ'), + ('ꝋ', 'ꝋ'), + ('ꝍ', 'ꝍ'), + ('ꝏ', 'ꝏ'), + ('ꝑ', 'ꝑ'), + ('ꝓ', 'ꝓ'), + ('ꝕ', 'ꝕ'), + ('ꝗ', 'ꝗ'), + ('ꝙ', 'ꝙ'), + ('ꝛ', 'ꝛ'), + ('ꝝ', 'ꝝ'), + ('ꝟ', 'ꝟ'), + ('ꝡ', 'ꝡ'), + ('ꝣ', 'ꝣ'), + ('ꝥ', 'ꝥ'), + ('ꝧ', 'ꝧ'), + ('ꝩ', 'ꝩ'), + ('ꝫ', 'ꝫ'), + ('ꝭ', 'ꝭ'), + ('ꝯ', 'ꝯ'), + ('ꝺ', 'ꝺ'), + ('ꝼ', 'ꝼ'), + ('ꝿ', 'ꝿ'), + ('ꞁ', 'ꞁ'), + ('ꞃ', 'ꞃ'), + ('ꞅ', 'ꞅ'), + ('ꞇ', 'ꞇ'), + ('ꞌ', 'ꞌ'), + ('ꞑ', 'ꞑ'), + ('ꞓ', 'ꞔ'), + ('ꞗ', 'ꞗ'), + ('ꞙ', 'ꞙ'), + ('ꞛ', 'ꞛ'), + ('ꞝ', 'ꞝ'), + ('ꞟ', 'ꞟ'), + ('ꞡ', 'ꞡ'), + ('ꞣ', 'ꞣ'), + ('ꞥ', 'ꞥ'), + ('ꞧ', 'ꞧ'), + ('ꞩ', 'ꞩ'), + ('ꞵ', 'ꞵ'), + ('ꞷ', 'ꞷ'), + ('ꞹ', 'ꞹ'), + ('\u{a7bb}', '\u{a7bb}'), + ('\u{a7bd}', '\u{a7bd}'), + ('\u{a7bf}', '\u{a7bf}'), + ('\u{a7c3}', '\u{a7c3}'), + ('ꭓ', 'ꭓ'), + ('ꭰ', 'ꮿ'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('a', 'z'), + ('𐐨', '𐑏'), + ('𐓘', '𐓻'), + ('𐳀', '𐳲'), + ('𑣀', '𑣟'), + ('𖹠', '𖹿'), + ('𞤢', '𞥃'), +]; + +pub const CHANGES_WHEN_UPPERCASED: &'static [(char, char)] = &[ + ('a', 'z'), + ('µ', 'µ'), + ('ß', 'ö'), + ('ø', 'ÿ'), + ('ā', 'ā'), + ('ă', 'ă'), + ('ą', 'ą'), + ('ć', 'ć'), + ('ĉ', 'ĉ'), + ('ċ', 'ċ'), + ('č', 'č'), + ('ď', 'ď'), + ('đ', 'đ'), + ('ē', 'ē'), + ('ĕ', 'ĕ'), + ('ė', 'ė'), + ('ę', 'ę'), + ('ě', 'ě'), + ('ĝ', 'ĝ'), + ('ğ', 'ğ'), + ('ġ', 'ġ'), + ('ģ', 'ģ'), + ('ĥ', 'ĥ'), + ('ħ', 'ħ'), + ('ĩ', 'ĩ'), + ('ī', 'ī'), + ('ĭ', 'ĭ'), + ('į', 'į'), + ('ı', 'ı'), + ('ij', 'ij'), + ('ĵ', 'ĵ'), + ('ķ', 'ķ'), + ('ĺ', 'ĺ'), + ('ļ', 'ļ'), + ('ľ', 'ľ'), + ('ŀ', 'ŀ'), + ('ł', 'ł'), + ('ń', 'ń'), + ('ņ', 'ņ'), + ('ň', 'ʼn'), + ('ŋ', 'ŋ'), + ('ō', 'ō'), + ('ŏ', 'ŏ'), + ('ő', 'ő'), + ('œ', 'œ'), + ('ŕ', 'ŕ'), + ('ŗ', 'ŗ'), + ('ř', 'ř'), + ('ś', 'ś'), + ('ŝ', 'ŝ'), + ('ş', 'ş'), + ('š', 'š'), + ('ţ', 'ţ'), + ('ť', 'ť'), + ('ŧ', 'ŧ'), + ('ũ', 'ũ'), + ('ū', 'ū'), + ('ŭ', 'ŭ'), + ('ů', 'ů'), + ('ű', 'ű'), + ('ų', 'ų'), + ('ŵ', 'ŵ'), + ('ŷ', 'ŷ'), + ('ź', 'ź'), + ('ż', 'ż'), + ('ž', 'ƀ'), + ('ƃ', 'ƃ'), + ('ƅ', 'ƅ'), + ('ƈ', 'ƈ'), + ('ƌ', 'ƌ'), + ('ƒ', 'ƒ'), + ('ƕ', 'ƕ'), + ('ƙ', 'ƚ'), + ('ƞ', 'ƞ'), + ('ơ', 'ơ'), + ('ƣ', 'ƣ'), + ('ƥ', 'ƥ'), + ('ƨ', 'ƨ'), + ('ƭ', 'ƭ'), + ('ư', 'ư'), + ('ƴ', 'ƴ'), + ('ƶ', 'ƶ'), + ('ƹ', 'ƹ'), + ('ƽ', 'ƽ'), + ('ƿ', 'ƿ'), + ('Dž', 'dž'), + ('Lj', 'lj'), + ('Nj', 'nj'), + ('ǎ', 'ǎ'), + ('ǐ', 'ǐ'), + ('ǒ', 'ǒ'), + ('ǔ', 'ǔ'), + ('ǖ', 'ǖ'), + ('ǘ', 'ǘ'), + ('ǚ', 'ǚ'), + ('ǜ', 'ǝ'), + ('ǟ', 'ǟ'), + ('ǡ', 'ǡ'), + ('ǣ', 'ǣ'), + ('ǥ', 'ǥ'), + ('ǧ', 'ǧ'), + ('ǩ', 'ǩ'), + ('ǫ', 'ǫ'), + ('ǭ', 'ǭ'), + ('ǯ', 'ǰ'), + ('Dz', 'dz'), + ('ǵ', 'ǵ'), + ('ǹ', 'ǹ'), + ('ǻ', 'ǻ'), + ('ǽ', 'ǽ'), + ('ǿ', 'ǿ'), + ('ȁ', 'ȁ'), + ('ȃ', 'ȃ'), + ('ȅ', 'ȅ'), + ('ȇ', 'ȇ'), + ('ȉ', 'ȉ'), + ('ȋ', 'ȋ'), + ('ȍ', 'ȍ'), + ('ȏ', 'ȏ'), + ('ȑ', 'ȑ'), + ('ȓ', 'ȓ'), + ('ȕ', 'ȕ'), + ('ȗ', 'ȗ'), + ('ș', 'ș'), + ('ț', 'ț'), + ('ȝ', 'ȝ'), + ('ȟ', 'ȟ'), + ('ȣ', 'ȣ'), + ('ȥ', 'ȥ'), + ('ȧ', 'ȧ'), + ('ȩ', 'ȩ'), + ('ȫ', 'ȫ'), + ('ȭ', 'ȭ'), + ('ȯ', 'ȯ'), + ('ȱ', 'ȱ'), + ('ȳ', 'ȳ'), + ('ȼ', 'ȼ'), + ('ȿ', 'ɀ'), + ('ɂ', 'ɂ'), + ('ɇ', 'ɇ'), + ('ɉ', 'ɉ'), + ('ɋ', 'ɋ'), + ('ɍ', 'ɍ'), + ('ɏ', 'ɔ'), + ('ɖ', 'ɗ'), + ('ə', 'ə'), + ('ɛ', 'ɜ'), + ('ɠ', 'ɡ'), + ('ɣ', 'ɣ'), + ('ɥ', 'ɦ'), + ('ɨ', 'ɬ'), + ('ɯ', 'ɯ'), + ('ɱ', 'ɲ'), + ('ɵ', 'ɵ'), + ('ɽ', 'ɽ'), + ('ʀ', 'ʀ'), + ('ʂ', 'ʃ'), + ('ʇ', 'ʌ'), + ('ʒ', 'ʒ'), + ('ʝ', 'ʞ'), + ('\u{345}', '\u{345}'), + ('ͱ', 'ͱ'), + ('ͳ', 'ͳ'), + ('ͷ', 'ͷ'), + ('ͻ', 'ͽ'), + ('ΐ', 'ΐ'), + ('ά', 'ώ'), + ('ϐ', 'ϑ'), + ('ϕ', 'ϗ'), + ('ϙ', 'ϙ'), + ('ϛ', 'ϛ'), + ('ϝ', 'ϝ'), + ('ϟ', 'ϟ'), + ('ϡ', 'ϡ'), + ('ϣ', 'ϣ'), + ('ϥ', 'ϥ'), + ('ϧ', 'ϧ'), + ('ϩ', 'ϩ'), + ('ϫ', 'ϫ'), + ('ϭ', 'ϭ'), + ('ϯ', 'ϳ'), + ('ϵ', 'ϵ'), + ('ϸ', 'ϸ'), + ('ϻ', 'ϻ'), + ('а', 'џ'), + ('ѡ', 'ѡ'), + ('ѣ', 'ѣ'), + ('ѥ', 'ѥ'), + ('ѧ', 'ѧ'), + ('ѩ', 'ѩ'), + ('ѫ', 'ѫ'), + ('ѭ', 'ѭ'), + ('ѯ', 'ѯ'), + ('ѱ', 'ѱ'), + ('ѳ', 'ѳ'), + ('ѵ', 'ѵ'), + ('ѷ', 'ѷ'), + ('ѹ', 'ѹ'), + ('ѻ', 'ѻ'), + ('ѽ', 'ѽ'), + ('ѿ', 'ѿ'), + ('ҁ', 'ҁ'), + ('ҋ', 'ҋ'), + ('ҍ', 'ҍ'), + ('ҏ', 'ҏ'), + ('ґ', 'ґ'), + ('ғ', 'ғ'), + ('ҕ', 'ҕ'), + ('җ', 'җ'), + ('ҙ', 'ҙ'), + ('қ', 'қ'), + ('ҝ', 'ҝ'), + ('ҟ', 'ҟ'), + ('ҡ', 'ҡ'), + ('ң', 'ң'), + ('ҥ', 'ҥ'), + ('ҧ', 'ҧ'), + ('ҩ', 'ҩ'), + ('ҫ', 'ҫ'), + ('ҭ', 'ҭ'), + ('ү', 'ү'), + ('ұ', 'ұ'), + ('ҳ', 'ҳ'), + ('ҵ', 'ҵ'), + ('ҷ', 'ҷ'), + ('ҹ', 'ҹ'), + ('һ', 'һ'), + ('ҽ', 'ҽ'), + ('ҿ', 'ҿ'), + ('ӂ', 'ӂ'), + ('ӄ', 'ӄ'), + ('ӆ', 'ӆ'), + ('ӈ', 'ӈ'), + ('ӊ', 'ӊ'), + ('ӌ', 'ӌ'), + ('ӎ', 'ӏ'), + ('ӑ', 'ӑ'), + ('ӓ', 'ӓ'), + ('ӕ', 'ӕ'), + ('ӗ', 'ӗ'), + ('ә', 'ә'), + ('ӛ', 'ӛ'), + ('ӝ', 'ӝ'), + ('ӟ', 'ӟ'), + ('ӡ', 'ӡ'), + ('ӣ', 'ӣ'), + ('ӥ', 'ӥ'), + ('ӧ', 'ӧ'), + ('ө', 'ө'), + ('ӫ', 'ӫ'), + ('ӭ', 'ӭ'), + ('ӯ', 'ӯ'), + ('ӱ', 'ӱ'), + ('ӳ', 'ӳ'), + ('ӵ', 'ӵ'), + ('ӷ', 'ӷ'), + ('ӹ', 'ӹ'), + ('ӻ', 'ӻ'), + ('ӽ', 'ӽ'), + ('ӿ', 'ӿ'), + ('ԁ', 'ԁ'), + ('ԃ', 'ԃ'), + ('ԅ', 'ԅ'), + ('ԇ', 'ԇ'), + ('ԉ', 'ԉ'), + ('ԋ', 'ԋ'), + ('ԍ', 'ԍ'), + ('ԏ', 'ԏ'), + ('ԑ', 'ԑ'), + ('ԓ', 'ԓ'), + ('ԕ', 'ԕ'), + ('ԗ', 'ԗ'), + ('ԙ', 'ԙ'), + ('ԛ', 'ԛ'), + ('ԝ', 'ԝ'), + ('ԟ', 'ԟ'), + ('ԡ', 'ԡ'), + ('ԣ', 'ԣ'), + ('ԥ', 'ԥ'), + ('ԧ', 'ԧ'), + ('ԩ', 'ԩ'), + ('ԫ', 'ԫ'), + ('ԭ', 'ԭ'), + ('ԯ', 'ԯ'), + ('ա', 'և'), + ('ა', 'ჺ'), + ('ჽ', 'ჿ'), + ('ᏸ', 'ᏽ'), + ('ᲀ', 'ᲈ'), + ('ᵹ', 'ᵹ'), + ('ᵽ', 'ᵽ'), + ('ᶎ', 'ᶎ'), + ('ḁ', 'ḁ'), + ('ḃ', 'ḃ'), + ('ḅ', 'ḅ'), + ('ḇ', 'ḇ'), + ('ḉ', 'ḉ'), + ('ḋ', 'ḋ'), + ('ḍ', 'ḍ'), + ('ḏ', 'ḏ'), + ('ḑ', 'ḑ'), + ('ḓ', 'ḓ'), + ('ḕ', 'ḕ'), + ('ḗ', 'ḗ'), + ('ḙ', 'ḙ'), + ('ḛ', 'ḛ'), + ('ḝ', 'ḝ'), + ('ḟ', 'ḟ'), + ('ḡ', 'ḡ'), + ('ḣ', 'ḣ'), + ('ḥ', 'ḥ'), + ('ḧ', 'ḧ'), + ('ḩ', 'ḩ'), + ('ḫ', 'ḫ'), + ('ḭ', 'ḭ'), + ('ḯ', 'ḯ'), + ('ḱ', 'ḱ'), + ('ḳ', 'ḳ'), + ('ḵ', 'ḵ'), + ('ḷ', 'ḷ'), + ('ḹ', 'ḹ'), + ('ḻ', 'ḻ'), + ('ḽ', 'ḽ'), + ('ḿ', 'ḿ'), + ('ṁ', 'ṁ'), + ('ṃ', 'ṃ'), + ('ṅ', 'ṅ'), + ('ṇ', 'ṇ'), + ('ṉ', 'ṉ'), + ('ṋ', 'ṋ'), + ('ṍ', 'ṍ'), + ('ṏ', 'ṏ'), + ('ṑ', 'ṑ'), + ('ṓ', 'ṓ'), + ('ṕ', 'ṕ'), + ('ṗ', 'ṗ'), + ('ṙ', 'ṙ'), + ('ṛ', 'ṛ'), + ('ṝ', 'ṝ'), + ('ṟ', 'ṟ'), + ('ṡ', 'ṡ'), + ('ṣ', 'ṣ'), + ('ṥ', 'ṥ'), + ('ṧ', 'ṧ'), + ('ṩ', 'ṩ'), + ('ṫ', 'ṫ'), + ('ṭ', 'ṭ'), + ('ṯ', 'ṯ'), + ('ṱ', 'ṱ'), + ('ṳ', 'ṳ'), + ('ṵ', 'ṵ'), + ('ṷ', 'ṷ'), + ('ṹ', 'ṹ'), + ('ṻ', 'ṻ'), + ('ṽ', 'ṽ'), + ('ṿ', 'ṿ'), + ('ẁ', 'ẁ'), + ('ẃ', 'ẃ'), + ('ẅ', 'ẅ'), + ('ẇ', 'ẇ'), + ('ẉ', 'ẉ'), + ('ẋ', 'ẋ'), + ('ẍ', 'ẍ'), + ('ẏ', 'ẏ'), + ('ẑ', 'ẑ'), + ('ẓ', 'ẓ'), + ('ẕ', 'ẛ'), + ('ạ', 'ạ'), + ('ả', 'ả'), + ('ấ', 'ấ'), + ('ầ', 'ầ'), + ('ẩ', 'ẩ'), + ('ẫ', 'ẫ'), + ('ậ', 'ậ'), + ('ắ', 'ắ'), + ('ằ', 'ằ'), + ('ẳ', 'ẳ'), + ('ẵ', 'ẵ'), + ('ặ', 'ặ'), + ('ẹ', 'ẹ'), + ('ẻ', 'ẻ'), + ('ẽ', 'ẽ'), + ('ế', 'ế'), + ('ề', 'ề'), + ('ể', 'ể'), + ('ễ', 'ễ'), + ('ệ', 'ệ'), + ('ỉ', 'ỉ'), + ('ị', 'ị'), + ('ọ', 'ọ'), + ('ỏ', 'ỏ'), + ('ố', 'ố'), + ('ồ', 'ồ'), + ('ổ', 'ổ'), + ('ỗ', 'ỗ'), + ('ộ', 'ộ'), + ('ớ', 'ớ'), + ('ờ', 'ờ'), + ('ở', 'ở'), + ('ỡ', 'ỡ'), + ('ợ', 'ợ'), + ('ụ', 'ụ'), + ('ủ', 'ủ'), + ('ứ', 'ứ'), + ('ừ', 'ừ'), + ('ử', 'ử'), + ('ữ', 'ữ'), + ('ự', 'ự'), + ('ỳ', 'ỳ'), + ('ỵ', 'ỵ'), + ('ỷ', 'ỷ'), + ('ỹ', 'ỹ'), + ('ỻ', 'ỻ'), + ('ỽ', 'ỽ'), + ('ỿ', 'ἇ'), + ('ἐ', 'ἕ'), + ('ἠ', 'ἧ'), + ('ἰ', 'ἷ'), + ('ὀ', 'ὅ'), + ('ὐ', 'ὗ'), + ('ὠ', 'ὧ'), + ('ὰ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾷ'), + ('ᾼ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῇ'), + ('ῌ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'ῗ'), + ('ῠ', 'ῧ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῷ'), + ('ῼ', 'ῼ'), + ('ⅎ', 'ⅎ'), + ('ⅰ', 'ⅿ'), + ('ↄ', 'ↄ'), + ('ⓐ', 'ⓩ'), + ('ⰰ', 'ⱞ'), + ('ⱡ', 'ⱡ'), + ('ⱥ', 'ⱦ'), + ('ⱨ', 'ⱨ'), + ('ⱪ', 'ⱪ'), + ('ⱬ', 'ⱬ'), + ('ⱳ', 'ⱳ'), + ('ⱶ', 'ⱶ'), + ('ⲁ', 'ⲁ'), + ('ⲃ', 'ⲃ'), + ('ⲅ', 'ⲅ'), + ('ⲇ', 'ⲇ'), + ('ⲉ', 'ⲉ'), + ('ⲋ', 'ⲋ'), + ('ⲍ', 'ⲍ'), + ('ⲏ', 'ⲏ'), + ('ⲑ', 'ⲑ'), + ('ⲓ', 'ⲓ'), + ('ⲕ', 'ⲕ'), + ('ⲗ', 'ⲗ'), + ('ⲙ', 'ⲙ'), + ('ⲛ', 'ⲛ'), + ('ⲝ', 'ⲝ'), + ('ⲟ', 'ⲟ'), + ('ⲡ', 'ⲡ'), + ('ⲣ', 'ⲣ'), + ('ⲥ', 'ⲥ'), + ('ⲧ', 'ⲧ'), + ('ⲩ', 'ⲩ'), + ('ⲫ', 'ⲫ'), + ('ⲭ', 'ⲭ'), + ('ⲯ', 'ⲯ'), + ('ⲱ', 'ⲱ'), + ('ⲳ', 'ⲳ'), + ('ⲵ', 'ⲵ'), + ('ⲷ', 'ⲷ'), + ('ⲹ', 'ⲹ'), + ('ⲻ', 'ⲻ'), + ('ⲽ', 'ⲽ'), + ('ⲿ', 'ⲿ'), + ('ⳁ', 'ⳁ'), + ('ⳃ', 'ⳃ'), + ('ⳅ', 'ⳅ'), + ('ⳇ', 'ⳇ'), + ('ⳉ', 'ⳉ'), + ('ⳋ', 'ⳋ'), + ('ⳍ', 'ⳍ'), + ('ⳏ', 'ⳏ'), + ('ⳑ', 'ⳑ'), + ('ⳓ', 'ⳓ'), + ('ⳕ', 'ⳕ'), + ('ⳗ', 'ⳗ'), + ('ⳙ', 'ⳙ'), + ('ⳛ', 'ⳛ'), + ('ⳝ', 'ⳝ'), + ('ⳟ', 'ⳟ'), + ('ⳡ', 'ⳡ'), + ('ⳣ', 'ⳣ'), + ('ⳬ', 'ⳬ'), + ('ⳮ', 'ⳮ'), + ('ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ꙁ', 'ꙁ'), + ('ꙃ', 'ꙃ'), + ('ꙅ', 'ꙅ'), + ('ꙇ', 'ꙇ'), + ('ꙉ', 'ꙉ'), + ('ꙋ', 'ꙋ'), + ('ꙍ', 'ꙍ'), + ('ꙏ', 'ꙏ'), + ('ꙑ', 'ꙑ'), + ('ꙓ', 'ꙓ'), + ('ꙕ', 'ꙕ'), + ('ꙗ', 'ꙗ'), + ('ꙙ', 'ꙙ'), + ('ꙛ', 'ꙛ'), + ('ꙝ', 'ꙝ'), + ('ꙟ', 'ꙟ'), + ('ꙡ', 'ꙡ'), + ('ꙣ', 'ꙣ'), + ('ꙥ', 'ꙥ'), + ('ꙧ', 'ꙧ'), + ('ꙩ', 'ꙩ'), + ('ꙫ', 'ꙫ'), + ('ꙭ', 'ꙭ'), + ('ꚁ', 'ꚁ'), + ('ꚃ', 'ꚃ'), + ('ꚅ', 'ꚅ'), + ('ꚇ', 'ꚇ'), + ('ꚉ', 'ꚉ'), + ('ꚋ', 'ꚋ'), + ('ꚍ', 'ꚍ'), + ('ꚏ', 'ꚏ'), + ('ꚑ', 'ꚑ'), + ('ꚓ', 'ꚓ'), + ('ꚕ', 'ꚕ'), + ('ꚗ', 'ꚗ'), + ('ꚙ', 'ꚙ'), + ('ꚛ', 'ꚛ'), + ('ꜣ', 'ꜣ'), + ('ꜥ', 'ꜥ'), + ('ꜧ', 'ꜧ'), + ('ꜩ', 'ꜩ'), + ('ꜫ', 'ꜫ'), + ('ꜭ', 'ꜭ'), + ('ꜯ', 'ꜯ'), + ('ꜳ', 'ꜳ'), + ('ꜵ', 'ꜵ'), + ('ꜷ', 'ꜷ'), + ('ꜹ', 'ꜹ'), + ('ꜻ', 'ꜻ'), + ('ꜽ', 'ꜽ'), + ('ꜿ', 'ꜿ'), + ('ꝁ', 'ꝁ'), + ('ꝃ', 'ꝃ'), + ('ꝅ', 'ꝅ'), + ('ꝇ', 'ꝇ'), + ('ꝉ', 'ꝉ'), + ('ꝋ', 'ꝋ'), + ('ꝍ', 'ꝍ'), + ('ꝏ', 'ꝏ'), + ('ꝑ', 'ꝑ'), + ('ꝓ', 'ꝓ'), + ('ꝕ', 'ꝕ'), + ('ꝗ', 'ꝗ'), + ('ꝙ', 'ꝙ'), + ('ꝛ', 'ꝛ'), + ('ꝝ', 'ꝝ'), + ('ꝟ', 'ꝟ'), + ('ꝡ', 'ꝡ'), + ('ꝣ', 'ꝣ'), + ('ꝥ', 'ꝥ'), + ('ꝧ', 'ꝧ'), + ('ꝩ', 'ꝩ'), + ('ꝫ', 'ꝫ'), + ('ꝭ', 'ꝭ'), + ('ꝯ', 'ꝯ'), + ('ꝺ', 'ꝺ'), + ('ꝼ', 'ꝼ'), + ('ꝿ', 'ꝿ'), + ('ꞁ', 'ꞁ'), + ('ꞃ', 'ꞃ'), + ('ꞅ', 'ꞅ'), + ('ꞇ', 'ꞇ'), + ('ꞌ', 'ꞌ'), + ('ꞑ', 'ꞑ'), + ('ꞓ', 'ꞔ'), + ('ꞗ', 'ꞗ'), + ('ꞙ', 'ꞙ'), + ('ꞛ', 'ꞛ'), + ('ꞝ', 'ꞝ'), + ('ꞟ', 'ꞟ'), + ('ꞡ', 'ꞡ'), + ('ꞣ', 'ꞣ'), + ('ꞥ', 'ꞥ'), + ('ꞧ', 'ꞧ'), + ('ꞩ', 'ꞩ'), + ('ꞵ', 'ꞵ'), + ('ꞷ', 'ꞷ'), + ('ꞹ', 'ꞹ'), + ('\u{a7bb}', '\u{a7bb}'), + ('\u{a7bd}', '\u{a7bd}'), + ('\u{a7bf}', '\u{a7bf}'), + ('\u{a7c3}', '\u{a7c3}'), + ('ꭓ', 'ꭓ'), + ('ꭰ', 'ꮿ'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('a', 'z'), + ('𐐨', '𐑏'), + ('𐓘', '𐓻'), + ('𐳀', '𐳲'), + ('𑣀', '𑣟'), + ('𖹠', '𖹿'), + ('𞤢', '𞥃'), +]; + +pub const DASH: &'static [(char, char)] = &[ + ('-', '-'), + ('֊', '֊'), + ('־', '־'), + ('᐀', '᐀'), + ('᠆', '᠆'), + ('‐', '―'), + ('⁓', '⁓'), + ('⁻', '⁻'), + ('₋', '₋'), + ('−', '−'), + ('⸗', '⸗'), + ('⸚', '⸚'), + ('⸺', '⸻'), + ('⹀', '⹀'), + ('〜', '〜'), + ('〰', '〰'), + ('゠', '゠'), + ('︱', '︲'), + ('﹘', '﹘'), + ('﹣', '﹣'), + ('-', '-'), +]; + +pub const DEFAULT_IGNORABLE_CODE_POINT: &'static [(char, char)] = &[ + ('\u{ad}', '\u{ad}'), + ('\u{34f}', '\u{34f}'), + ('\u{61c}', '\u{61c}'), + ('ᅟ', 'ᅠ'), + ('\u{17b4}', '\u{17b5}'), + ('\u{180b}', '\u{180e}'), + ('\u{200b}', '\u{200f}'), + ('\u{202a}', '\u{202e}'), + ('\u{2060}', '\u{206f}'), + ('ㅤ', 'ㅤ'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{feff}', '\u{feff}'), + ('ᅠ', 'ᅠ'), + ('\u{fff0}', '\u{fff8}'), + ('\u{1bca0}', '\u{1bca3}'), + ('\u{1d173}', '\u{1d17a}'), + ('\u{e0000}', '\u{e0fff}'), +]; + +pub const DEPRECATED: &'static [(char, char)] = &[ + ('ʼn', 'ʼn'), + ('ٳ', 'ٳ'), + ('\u{f77}', '\u{f77}'), + ('\u{f79}', '\u{f79}'), + ('ឣ', 'ឤ'), + ('\u{206a}', '\u{206f}'), + ('〈', '〉'), + ('\u{e0001}', '\u{e0001}'), +]; + +pub const DIACRITIC: &'static [(char, char)] = &[ + ('^', '^'), + ('`', '`'), + ('¨', '¨'), + ('¯', '¯'), + ('´', '´'), + ('·', '¸'), + ('ʰ', '\u{34e}'), + ('\u{350}', '\u{357}'), + ('\u{35d}', '\u{362}'), + ('ʹ', '͵'), + ('ͺ', 'ͺ'), + ('΄', '΅'), + ('\u{483}', '\u{487}'), + ('ՙ', 'ՙ'), + ('\u{591}', '\u{5a1}'), + ('\u{5a3}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c4}'), + ('\u{64b}', '\u{652}'), + ('\u{657}', '\u{658}'), + ('\u{6df}', '\u{6e0}'), + ('ۥ', 'ۦ'), + ('\u{6ea}', '\u{6ec}'), + ('\u{730}', '\u{74a}'), + ('\u{7a6}', '\u{7b0}'), + ('\u{7eb}', 'ߵ'), + ('\u{818}', '\u{819}'), + ('\u{8e3}', '\u{8fe}'), + ('\u{93c}', '\u{93c}'), + ('\u{94d}', '\u{94d}'), + ('\u{951}', '\u{954}'), + ('ॱ', 'ॱ'), + ('\u{9bc}', '\u{9bc}'), + ('\u{9cd}', '\u{9cd}'), + ('\u{a3c}', '\u{a3c}'), + ('\u{a4d}', '\u{a4d}'), + ('\u{abc}', '\u{abc}'), + ('\u{acd}', '\u{acd}'), + ('\u{afd}', '\u{aff}'), + ('\u{b3c}', '\u{b3c}'), + ('\u{b4d}', '\u{b4d}'), + ('\u{bcd}', '\u{bcd}'), + ('\u{c4d}', '\u{c4d}'), + ('\u{cbc}', '\u{cbc}'), + ('\u{ccd}', '\u{ccd}'), + ('\u{d3b}', '\u{d3c}'), + ('\u{d4d}', '\u{d4d}'), + ('\u{dca}', '\u{dca}'), + ('\u{e47}', '\u{e4c}'), + ('\u{e4e}', '\u{e4e}'), + ('\u{eba}', '\u{eba}'), + ('\u{ec8}', '\u{ecc}'), + ('\u{f18}', '\u{f19}'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('༾', '༿'), + ('\u{f82}', '\u{f84}'), + ('\u{f86}', '\u{f87}'), + ('\u{fc6}', '\u{fc6}'), + ('\u{1037}', '\u{1037}'), + ('\u{1039}', '\u{103a}'), + ('ၣ', 'ၤ'), + ('ၩ', 'ၭ'), + ('ႇ', '\u{108d}'), + ('ႏ', 'ႏ'), + ('ႚ', 'ႛ'), + ('\u{135d}', '\u{135f}'), + ('\u{17c9}', '\u{17d3}'), + ('\u{17dd}', '\u{17dd}'), + ('\u{1939}', '\u{193b}'), + ('\u{1a75}', '\u{1a7c}'), + ('\u{1a7f}', '\u{1a7f}'), + ('\u{1ab0}', '\u{1abd}'), + ('\u{1b34}', '\u{1b34}'), + ('᭄', '᭄'), + ('\u{1b6b}', '\u{1b73}'), + ('᮪', '\u{1bab}'), + ('\u{1c36}', '\u{1c37}'), + ('ᱸ', 'ᱽ'), + ('\u{1cd0}', '\u{1ce8}'), + ('\u{1ced}', '\u{1ced}'), + ('\u{1cf4}', '\u{1cf4}'), + ('᳷', '\u{1cf9}'), + ('ᴬ', 'ᵪ'), + ('\u{1dc4}', '\u{1dcf}'), + ('\u{1df5}', '\u{1df9}'), + ('\u{1dfd}', '\u{1dff}'), + ('᾽', '᾽'), + ('᾿', '῁'), + ('῍', '῏'), + ('῝', '῟'), + ('῭', '`'), + ('´', '῾'), + ('\u{2cef}', '\u{2cf1}'), + ('ⸯ', 'ⸯ'), + ('\u{302a}', '\u{302f}'), + ('\u{3099}', '゜'), + ('ー', 'ー'), + ('\u{a66f}', '\u{a66f}'), + ('\u{a67c}', '\u{a67d}'), + ('ꙿ', 'ꙿ'), + ('ꚜ', 'ꚝ'), + ('\u{a6f0}', '\u{a6f1}'), + ('꜀', '꜡'), + ('ꞈ', '꞊'), + ('ꟸ', 'ꟹ'), + ('\u{a8c4}', '\u{a8c4}'), + ('\u{a8e0}', '\u{a8f1}'), + ('\u{a92b}', '꤮'), + ('꥓', '꥓'), + ('\u{a9b3}', '\u{a9b3}'), + ('꧀', '꧀'), + ('\u{a9e5}', '\u{a9e5}'), + ('ꩻ', 'ꩽ'), + ('\u{aabf}', 'ꫂ'), + ('\u{aaf6}', '\u{aaf6}'), + ('꭛', 'ꭟ'), + ('꯬', '\u{abed}'), + ('\u{fb1e}', '\u{fb1e}'), + ('\u{fe20}', '\u{fe2f}'), + ('^', '^'), + ('`', '`'), + ('ー', 'ー'), + ('\u{ff9e}', '\u{ff9f}'), + (' ̄', ' ̄'), + ('\u{102e0}', '\u{102e0}'), + ('\u{10ae5}', '\u{10ae6}'), + ('𐴢', '\u{10d27}'), + ('\u{10f46}', '\u{10f50}'), + ('\u{110b9}', '\u{110ba}'), + ('\u{11133}', '\u{11134}'), + ('\u{11173}', '\u{11173}'), + ('𑇀', '𑇀'), + ('\u{111ca}', '\u{111cc}'), + ('𑈵', '\u{11236}'), + ('\u{112e9}', '\u{112ea}'), + ('\u{1133c}', '\u{1133c}'), + ('𑍍', '𑍍'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('\u{11442}', '\u{11442}'), + ('\u{11446}', '\u{11446}'), + ('\u{114c2}', '\u{114c3}'), + ('\u{115bf}', '\u{115c0}'), + ('\u{1163f}', '\u{1163f}'), + ('𑚶', '\u{116b7}'), + ('\u{1172b}', '\u{1172b}'), + ('\u{11839}', '\u{1183a}'), + ('\u{119e0}', '\u{119e0}'), + ('\u{11a34}', '\u{11a34}'), + ('\u{11a47}', '\u{11a47}'), + ('\u{11a99}', '\u{11a99}'), + ('\u{11c3f}', '\u{11c3f}'), + ('\u{11d42}', '\u{11d42}'), + ('\u{11d44}', '\u{11d45}'), + ('\u{11d97}', '\u{11d97}'), + ('\u{16af0}', '\u{16af4}'), + ('\u{16b30}', '\u{16b36}'), + ('\u{16f8f}', '𖾟'), + ('\u{1d167}', '\u{1d169}'), + ('𝅭', '\u{1d172}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1e130}', '\u{1e136}'), + ('\u{1e2ec}', '\u{1e2ef}'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('\u{1e944}', '\u{1e946}'), + ('\u{1e948}', '\u{1e94a}'), +]; + +pub const EMOJI: &'static [(char, char)] = &[ + ('#', '#'), + ('*', '*'), + ('0', '9'), + ('©', '©'), + ('®', '®'), + ('‼', '‼'), + ('⁉', '⁉'), + ('™', '™'), + ('ℹ', 'ℹ'), + ('↔', '↙'), + ('↩', '↪'), + ('⌚', '⌛'), + ('⌨', '⌨'), + ('⏏', '⏏'), + ('⏩', '⏳'), + ('⏸', '⏺'), + ('Ⓜ', 'Ⓜ'), + ('▪', '▫'), + ('▶', '▶'), + ('◀', '◀'), + ('◻', '◾'), + ('☀', '☄'), + ('☎', '☎'), + ('☑', '☑'), + ('☔', '☕'), + ('☘', '☘'), + ('☝', '☝'), + ('☠', '☠'), + ('☢', '☣'), + ('☦', '☦'), + ('☪', '☪'), + ('☮', '☯'), + ('☸', '☺'), + ('♀', '♀'), + ('♂', '♂'), + ('♈', '♓'), + ('♟', '♠'), + ('♣', '♣'), + ('♥', '♦'), + ('♨', '♨'), + ('♻', '♻'), + ('♾', '♿'), + ('⚒', '⚗'), + ('⚙', '⚙'), + ('⚛', '⚜'), + ('⚠', '⚡'), + ('⚪', '⚫'), + ('⚰', '⚱'), + ('⚽', '⚾'), + ('⛄', '⛅'), + ('⛈', '⛈'), + ('⛎', '⛏'), + ('⛑', '⛑'), + ('⛓', '⛔'), + ('⛩', '⛪'), + ('⛰', '⛵'), + ('⛷', '⛺'), + ('⛽', '⛽'), + ('✂', '✂'), + ('✅', '✅'), + ('✈', '✍'), + ('✏', '✏'), + ('✒', '✒'), + ('✔', '✔'), + ('✖', '✖'), + ('✝', '✝'), + ('✡', '✡'), + ('✨', '✨'), + ('✳', '✴'), + ('❄', '❄'), + ('❇', '❇'), + ('❌', '❌'), + ('❎', '❎'), + ('❓', '❕'), + ('❗', '❗'), + ('❣', '❤'), + ('➕', '➗'), + ('➡', '➡'), + ('➰', '➰'), + ('➿', '➿'), + ('⤴', '⤵'), + ('⬅', '⬇'), + ('⬛', '⬜'), + ('⭐', '⭐'), + ('⭕', '⭕'), + ('〰', '〰'), + ('〽', '〽'), + ('㊗', '㊗'), + ('㊙', '㊙'), + ('🀄', '🀄'), + ('🃏', '🃏'), + ('🅰', '🅱'), + ('🅾', '🅿'), + ('🆎', '🆎'), + ('🆑', '🆚'), + ('🇦', '🇿'), + ('🈁', '🈂'), + ('🈚', '🈚'), + ('🈯', '🈯'), + ('🈲', '🈺'), + ('🉐', '🉑'), + ('🌀', '🌡'), + ('🌤', '🎓'), + ('🎖', '🎗'), + ('🎙', '🎛'), + ('🎞', '🏰'), + ('🏳', '🏵'), + ('🏷', '📽'), + ('📿', '🔽'), + ('🕉', '🕎'), + ('🕐', '🕧'), + ('🕯', '🕰'), + ('🕳', '🕺'), + ('🖇', '🖇'), + ('🖊', '🖍'), + ('🖐', '🖐'), + ('🖕', '🖖'), + ('🖤', '🖥'), + ('🖨', '🖨'), + ('🖱', '🖲'), + ('🖼', '🖼'), + ('🗂', '🗄'), + ('🗑', '🗓'), + ('🗜', '🗞'), + ('🗡', '🗡'), + ('🗣', '🗣'), + ('🗨', '🗨'), + ('🗯', '🗯'), + ('🗳', '🗳'), + ('🗺', '🙏'), + ('🚀', '🛅'), + ('🛋', '🛒'), + ('\u{1f6d5}', '\u{1f6d5}'), + ('🛠', '🛥'), + ('🛩', '🛩'), + ('🛫', '🛬'), + ('🛰', '🛰'), + ('🛳', '\u{1f6fa}'), + ('\u{1f7e0}', '\u{1f7eb}'), + ('\u{1f90d}', '🤺'), + ('🤼', '🥅'), + ('🥇', '\u{1f971}'), + ('🥳', '🥶'), + ('🥺', '🦢'), + ('\u{1f9a5}', '\u{1f9aa}'), + ('\u{1f9ae}', '\u{1f9ca}'), + ('\u{1f9cd}', '🧿'), + ('\u{1fa70}', '\u{1fa73}'), + ('\u{1fa78}', '\u{1fa7a}'), + ('\u{1fa80}', '\u{1fa82}'), + ('\u{1fa90}', '\u{1fa95}'), +]; + +pub const EMOJI_COMPONENT: &'static [(char, char)] = &[ + ('#', '#'), + ('*', '*'), + ('0', '9'), + ('\u{200d}', '\u{200d}'), + ('\u{20e3}', '\u{20e3}'), + ('\u{fe0f}', '\u{fe0f}'), + ('🇦', '🇿'), + ('🏻', '🏿'), + ('🦰', '🦳'), + ('\u{e0020}', '\u{e007f}'), +]; + +pub const EMOJI_MODIFIER: &'static [(char, char)] = &[('🏻', '🏿')]; + +pub const EMOJI_MODIFIER_BASE: &'static [(char, char)] = &[ + ('☝', '☝'), + ('⛹', '⛹'), + ('✊', '✍'), + ('🎅', '🎅'), + ('🏂', '🏄'), + ('🏇', '🏇'), + ('🏊', '🏌'), + ('👂', '👃'), + ('👆', '👐'), + ('👦', '👸'), + ('👼', '👼'), + ('💁', '💃'), + ('💅', '💇'), + ('💏', '💏'), + ('💑', '💑'), + ('💪', '💪'), + ('🕴', '🕵'), + ('🕺', '🕺'), + ('🖐', '🖐'), + ('🖕', '🖖'), + ('🙅', '🙇'), + ('🙋', '🙏'), + ('🚣', '🚣'), + ('🚴', '🚶'), + ('🛀', '🛀'), + ('🛌', '🛌'), + ('\u{1f90f}', '\u{1f90f}'), + ('🤘', '🤟'), + ('🤦', '🤦'), + ('🤰', '🤹'), + ('🤼', '🤾'), + ('🦵', '🦶'), + ('🦸', '🦹'), + ('\u{1f9bb}', '\u{1f9bb}'), + ('\u{1f9cd}', '\u{1f9cf}'), + ('🧑', '🧝'), +]; + +pub const EMOJI_PRESENTATION: &'static [(char, char)] = &[ + ('⌚', '⌛'), + ('⏩', '⏬'), + ('⏰', '⏰'), + ('⏳', '⏳'), + ('◽', '◾'), + ('☔', '☕'), + ('♈', '♓'), + ('♿', '♿'), + ('⚓', '⚓'), + ('⚡', '⚡'), + ('⚪', '⚫'), + ('⚽', '⚾'), + ('⛄', '⛅'), + ('⛎', '⛎'), + ('⛔', '⛔'), + ('⛪', '⛪'), + ('⛲', '⛳'), + ('⛵', '⛵'), + ('⛺', '⛺'), + ('⛽', '⛽'), + ('✅', '✅'), + ('✊', '✋'), + ('✨', '✨'), + ('❌', '❌'), + ('❎', '❎'), + ('❓', '❕'), + ('❗', '❗'), + ('➕', '➗'), + ('➰', '➰'), + ('➿', '➿'), + ('⬛', '⬜'), + ('⭐', '⭐'), + ('⭕', '⭕'), + ('🀄', '🀄'), + ('🃏', '🃏'), + ('🆎', '🆎'), + ('🆑', '🆚'), + ('🇦', '🇿'), + ('🈁', '🈁'), + ('🈚', '🈚'), + ('🈯', '🈯'), + ('🈲', '🈶'), + ('🈸', '🈺'), + ('🉐', '🉑'), + ('🌀', '🌠'), + ('🌭', '🌵'), + ('🌷', '🍼'), + ('🍾', '🎓'), + ('🎠', '🏊'), + ('🏏', '🏓'), + ('🏠', '🏰'), + ('🏴', '🏴'), + ('🏸', '🐾'), + ('👀', '👀'), + ('👂', '📼'), + ('📿', '🔽'), + ('🕋', '🕎'), + ('🕐', '🕧'), + ('🕺', '🕺'), + ('🖕', '🖖'), + ('🖤', '🖤'), + ('🗻', '🙏'), + ('🚀', '🛅'), + ('🛌', '🛌'), + ('🛐', '🛒'), + ('\u{1f6d5}', '\u{1f6d5}'), + ('🛫', '🛬'), + ('🛴', '\u{1f6fa}'), + ('\u{1f7e0}', '\u{1f7eb}'), + ('\u{1f90d}', '🤺'), + ('🤼', '🥅'), + ('🥇', '\u{1f971}'), + ('🥳', '🥶'), + ('🥺', '🦢'), + ('\u{1f9a5}', '\u{1f9aa}'), + ('\u{1f9ae}', '\u{1f9ca}'), + ('\u{1f9cd}', '🧿'), + ('\u{1fa70}', '\u{1fa73}'), + ('\u{1fa78}', '\u{1fa7a}'), + ('\u{1fa80}', '\u{1fa82}'), + ('\u{1fa90}', '\u{1fa95}'), +]; + +pub const EXTENDED_PICTOGRAPHIC: &'static [(char, char)] = &[ + ('©', '©'), + ('®', '®'), + ('‼', '‼'), + ('⁉', '⁉'), + ('™', '™'), + ('ℹ', 'ℹ'), + ('↔', '↙'), + ('↩', '↪'), + ('⌚', '⌛'), + ('⌨', '⌨'), + ('⎈', '⎈'), + ('⏏', '⏏'), + ('⏩', '⏳'), + ('⏸', '⏺'), + ('Ⓜ', 'Ⓜ'), + ('▪', '▫'), + ('▶', '▶'), + ('◀', '◀'), + ('◻', '◾'), + ('☀', '★'), + ('☇', '☒'), + ('☔', '⚅'), + ('⚐', '✅'), + ('✈', '✒'), + ('✔', '✔'), + ('✖', '✖'), + ('✝', '✝'), + ('✡', '✡'), + ('✨', '✨'), + ('✳', '✴'), + ('❄', '❄'), + ('❇', '❇'), + ('❌', '❌'), + ('❎', '❎'), + ('❓', '❕'), + ('❗', '❗'), + ('❣', '❧'), + ('➕', '➗'), + ('➡', '➡'), + ('➰', '➰'), + ('➿', '➿'), + ('⤴', '⤵'), + ('⬅', '⬇'), + ('⬛', '⬜'), + ('⭐', '⭐'), + ('⭕', '⭕'), + ('〰', '〰'), + ('〽', '〽'), + ('㊗', '㊗'), + ('㊙', '㊙'), + ('🀀', '\u{1f0ff}'), + ('\u{1f10d}', '\u{1f10f}'), + ('🄯', '🄯'), + ('\u{1f16c}', '🅱'), + ('🅾', '🅿'), + ('🆎', '🆎'), + ('🆑', '🆚'), + ('\u{1f1ad}', '\u{1f1e5}'), + ('🈁', '\u{1f20f}'), + ('🈚', '🈚'), + ('🈯', '🈯'), + ('🈲', '🈺'), + ('\u{1f23c}', '\u{1f23f}'), + ('\u{1f249}', '🏺'), + ('🐀', '🔽'), + ('🕆', '🙏'), + ('🚀', '\u{1f6ff}'), + ('\u{1f774}', '\u{1f77f}'), + ('🟕', '\u{1f7ff}'), + ('\u{1f80c}', '\u{1f80f}'), + ('\u{1f848}', '\u{1f84f}'), + ('\u{1f85a}', '\u{1f85f}'), + ('\u{1f888}', '\u{1f88f}'), + ('\u{1f8ae}', '\u{1f8ff}'), + ('\u{1f90c}', '🤺'), + ('🤼', '🥅'), + ('🥇', '\u{1fffd}'), +]; + +pub const EXTENDER: &'static [(char, char)] = &[ + ('·', '·'), + ('ː', 'ˑ'), + ('ـ', 'ـ'), + ('ߺ', 'ߺ'), + ('ๆ', 'ๆ'), + ('ໆ', 'ໆ'), + ('᠊', '᠊'), + ('ᡃ', 'ᡃ'), + ('ᪧ', 'ᪧ'), + ('\u{1c36}', '\u{1c36}'), + ('ᱻ', 'ᱻ'), + ('々', '々'), + ('〱', '〵'), + ('ゝ', 'ゞ'), + ('ー', 'ヾ'), + ('ꀕ', 'ꀕ'), + ('ꘌ', 'ꘌ'), + ('ꧏ', 'ꧏ'), + ('ꧦ', 'ꧦ'), + ('ꩰ', 'ꩰ'), + ('ꫝ', 'ꫝ'), + ('ꫳ', 'ꫴ'), + ('ー', 'ー'), + ('𑍝', '𑍝'), + ('𑗆', '𑗈'), + ('\u{11a98}', '\u{11a98}'), + ('𖭂', '𖭃'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('\u{1e13c}', '\u{1e13d}'), + ('\u{1e944}', '\u{1e946}'), +]; + +pub const GRAPHEME_BASE: &'static [(char, char)] = &[ + (' ', '~'), + ('\u{a0}', '¬'), + ('®', '˿'), + ('Ͱ', 'ͷ'), + ('ͺ', 'Ϳ'), + ('΄', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', '҂'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՙ', '֊'), + ('֍', '֏'), + ('־', '־'), + ('׀', '׀'), + ('׃', '׃'), + ('׆', '׆'), + ('א', 'ת'), + ('ׯ', '״'), + ('؆', '؏'), + ('؛', '؛'), + ('؞', 'ي'), + ('٠', 'ٯ'), + ('ٱ', 'ە'), + ('۞', '۞'), + ('ۥ', 'ۦ'), + ('۩', '۩'), + ('ۮ', '܍'), + ('ܐ', 'ܐ'), + ('ܒ', 'ܯ'), + ('ݍ', 'ޥ'), + ('ޱ', 'ޱ'), + ('߀', 'ߪ'), + ('ߴ', 'ߺ'), + ('߾', 'ࠕ'), + ('ࠚ', 'ࠚ'), + ('ࠤ', 'ࠤ'), + ('ࠨ', 'ࠨ'), + ('࠰', '࠾'), + ('ࡀ', 'ࡘ'), + ('࡞', '࡞'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('ः', 'ह'), + ('ऻ', 'ऻ'), + ('ऽ', 'ी'), + ('ॉ', 'ौ'), + ('ॎ', 'ॐ'), + ('क़', 'ॡ'), + ('।', 'ঀ'), + ('ং', 'ঃ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('ঽ', 'ঽ'), + ('ি', 'ী'), + ('ে', 'ৈ'), + ('ো', 'ৌ'), + ('ৎ', 'ৎ'), + ('ড়', 'ঢ়'), + ('য়', 'ৡ'), + ('০', '৽'), + ('ਃ', 'ਃ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('ਾ', 'ੀ'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('੦', '੯'), + ('ੲ', 'ੴ'), + ('੶', '੶'), + ('ઃ', 'ઃ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('ઽ', 'ી'), + ('ૉ', 'ૉ'), + ('ો', 'ૌ'), + ('ૐ', 'ૐ'), + ('ૠ', 'ૡ'), + ('૦', '૱'), + ('ૹ', 'ૹ'), + ('ଂ', 'ଃ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('ଽ', 'ଽ'), + ('ୀ', 'ୀ'), + ('େ', 'ୈ'), + ('ୋ', 'ୌ'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', 'ୡ'), + ('୦', '୷'), + ('ஃ', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('ி', 'ி'), + ('ு', 'ூ'), + ('ெ', 'ை'), + ('ொ', 'ௌ'), + ('ௐ', 'ௐ'), + ('௦', '௺'), + ('ఁ', 'ః'), + ('అ', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ఽ'), + ('ు', 'ౄ'), + ('ౘ', 'ౚ'), + ('ౠ', 'ౡ'), + ('౦', '౯'), + ('\u{c77}', 'ಀ'), + ('ಂ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('ಽ', 'ಾ'), + ('ೀ', 'ು'), + ('ೃ', 'ೄ'), + ('ೇ', 'ೈ'), + ('ೊ', 'ೋ'), + ('ೞ', 'ೞ'), + ('ೠ', 'ೡ'), + ('೦', '೯'), + ('ೱ', 'ೲ'), + ('ം', 'ഃ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', 'ഺ'), + ('ഽ', 'ഽ'), + ('ി', 'ീ'), + ('െ', 'ൈ'), + ('ൊ', 'ൌ'), + ('ൎ', '൏'), + ('ൔ', 'ൖ'), + ('൘', 'ൡ'), + ('൦', 'ൿ'), + ('ං', 'ඃ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('ැ', 'ෑ'), + ('ෘ', 'ෞ'), + ('෦', '෯'), + ('ෲ', '෴'), + ('ก', 'ะ'), + ('า', 'ำ'), + ('฿', 'ๆ'), + ('๏', '๛'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ະ'), + ('າ', 'ຳ'), + ('ຽ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('໐', '໙'), + ('ໜ', 'ໟ'), + ('ༀ', '༗'), + ('༚', '༴'), + ('༶', '༶'), + ('༸', '༸'), + ('༺', 'ཇ'), + ('ཉ', 'ཬ'), + ('ཿ', 'ཿ'), + ('྅', '྅'), + ('ྈ', 'ྌ'), + ('྾', '࿅'), + ('࿇', '࿌'), + ('࿎', '࿚'), + ('က', 'ာ'), + ('ေ', 'ေ'), + ('း', 'း'), + ('ျ', 'ြ'), + ('ဿ', 'ၗ'), + ('ၚ', 'ၝ'), + ('ၡ', 'ၰ'), + ('ၵ', 'ႁ'), + ('ႃ', 'ႄ'), + ('ႇ', 'ႌ'), + ('ႎ', 'ႜ'), + ('႞', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('፠', '፼'), + ('ᎀ', '᎙'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('᐀', '᚜'), + ('ᚠ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', 'ᜑ'), + ('ᜠ', 'ᜱ'), + ('᜵', '᜶'), + ('ᝀ', 'ᝑ'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('ក', 'ឳ'), + ('ា', 'ា'), + ('ើ', 'ៅ'), + ('ះ', 'ៈ'), + ('។', 'ៜ'), + ('០', '៩'), + ('៰', '៹'), + ('᠀', '᠊'), + ('᠐', '᠙'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢄ'), + ('ᢇ', 'ᢨ'), + ('ᢪ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('ᤣ', 'ᤦ'), + ('ᤩ', 'ᤫ'), + ('ᤰ', 'ᤱ'), + ('ᤳ', 'ᤸ'), + ('᥀', '᥀'), + ('᥄', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('ᦀ', 'ᦫ'), + ('ᦰ', 'ᧉ'), + ('᧐', '᧚'), + ('᧞', 'ᨖ'), + ('ᨙ', 'ᨚ'), + ('᨞', 'ᩕ'), + ('ᩗ', 'ᩗ'), + ('ᩡ', 'ᩡ'), + ('ᩣ', 'ᩤ'), + ('ᩭ', 'ᩲ'), + ('᪀', '᪉'), + ('᪐', '᪙'), + ('᪠', '᪭'), + ('ᬄ', 'ᬳ'), + ('ᬻ', 'ᬻ'), + ('ᬽ', 'ᭁ'), + ('ᭃ', 'ᭋ'), + ('᭐', '᭪'), + ('᭴', '᭼'), + ('ᮂ', 'ᮡ'), + ('ᮦ', 'ᮧ'), + ('᮪', '᮪'), + ('ᮮ', 'ᯥ'), + ('ᯧ', 'ᯧ'), + ('ᯪ', 'ᯬ'), + ('ᯮ', 'ᯮ'), + ('᯲', '᯳'), + ('᯼', 'ᰫ'), + ('ᰴ', 'ᰵ'), + ('᰻', '᱉'), + ('ᱍ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', '᳇'), + ('᳓', '᳓'), + ('᳡', '᳡'), + ('ᳩ', 'ᳬ'), + ('ᳮ', 'ᳳ'), + ('ᳵ', '᳷'), + ('\u{1cfa}', '\u{1cfa}'), + ('ᴀ', 'ᶿ'), + ('Ḁ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ῄ'), + ('ῆ', 'ΐ'), + ('ῖ', 'Ί'), + ('῝', '`'), + ('ῲ', 'ῴ'), + ('ῶ', '῾'), + ('\u{2000}', '\u{200a}'), + ('‐', '‧'), + ('\u{202f}', '\u{205f}'), + ('⁰', 'ⁱ'), + ('⁴', '₎'), + ('ₐ', 'ₜ'), + ('₠', '₿'), + ('℀', '↋'), + ('←', '␦'), + ('⑀', '⑊'), + ('①', '⭳'), + ('⭶', '⮕'), + ('⮘', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⳮ'), + ('Ⳳ', 'ⳳ'), + ('⳹', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ⴰ', 'ⵧ'), + ('ⵯ', '⵰'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('⸀', '\u{2e4f}'), + ('⺀', '⺙'), + ('⺛', '⻳'), + ('⼀', '⿕'), + ('⿰', '⿻'), + ('\u{3000}', '〩'), + ('〰', '〿'), + ('ぁ', 'ゖ'), + ('゛', 'ヿ'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('㆐', 'ㆺ'), + ('㇀', '㇣'), + ('ㇰ', '㈞'), + ('㈠', '䶵'), + ('䷀', '鿯'), + ('ꀀ', 'ꒌ'), + ('꒐', '꓆'), + ('ꓐ', 'ꘫ'), + ('Ꙁ', 'ꙮ'), + ('꙳', '꙳'), + ('꙾', 'ꚝ'), + ('ꚠ', 'ꛯ'), + ('꛲', '꛷'), + ('꜀', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꠁ'), + ('ꠃ', 'ꠅ'), + ('ꠇ', 'ꠊ'), + ('ꠌ', 'ꠤ'), + ('ꠧ', '꠫'), + ('꠰', '꠹'), + ('ꡀ', '꡷'), + ('ꢀ', 'ꣃ'), + ('꣎', '꣙'), + ('ꣲ', 'ꣾ'), + ('꤀', 'ꤥ'), + ('꤮', 'ꥆ'), + ('ꥒ', '꥓'), + ('꥟', 'ꥼ'), + ('ꦃ', 'ꦲ'), + ('ꦴ', 'ꦵ'), + ('ꦺ', 'ꦻ'), + ('ꦾ', '꧍'), + ('ꧏ', '꧙'), + ('꧞', 'ꧤ'), + ('ꧦ', 'ꧾ'), + ('ꨀ', 'ꨨ'), + ('ꨯ', 'ꨰ'), + ('ꨳ', 'ꨴ'), + ('ꩀ', 'ꩂ'), + ('ꩄ', 'ꩋ'), + ('ꩍ', 'ꩍ'), + ('꩐', '꩙'), + ('꩜', 'ꩻ'), + ('ꩽ', 'ꪯ'), + ('ꪱ', 'ꪱ'), + ('ꪵ', 'ꪶ'), + ('ꪹ', 'ꪽ'), + ('ꫀ', 'ꫀ'), + ('ꫂ', 'ꫂ'), + ('ꫛ', 'ꫫ'), + ('ꫮ', 'ꫵ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꬰ', '\u{ab67}'), + ('ꭰ', 'ꯤ'), + ('ꯦ', 'ꯧ'), + ('ꯩ', '꯬'), + ('꯰', '꯹'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('豈', '舘'), + ('並', '龎'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('יִ', 'יִ'), + ('ײַ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', '﯁'), + ('ﯓ', '﴿'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', '﷽'), + ('︐', '︙'), + ('︰', '﹒'), + ('﹔', '﹦'), + ('﹨', '﹫'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('!', 'ン'), + ('ᅠ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('¢', '₩'), + ('│', '○'), + ('', '�'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐄀', '𐄂'), + ('𐄇', '𐄳'), + ('𐄷', '𐆎'), + ('𐆐', '𐆛'), + ('𐆠', '𐆠'), + ('𐇐', '𐇼'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('𐋡', '𐋻'), + ('𐌀', '𐌣'), + ('𐌭', '𐍊'), + ('𐍐', '𐍵'), + ('𐎀', '𐎝'), + ('𐎟', '𐏃'), + ('𐏈', '𐏕'), + ('𐐀', '𐒝'), + ('𐒠', '𐒩'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐕯', '𐕯'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡗', '𐢞'), + ('𐢧', '𐢯'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐣻', '𐤛'), + ('𐤟', '𐤹'), + ('𐤿', '𐤿'), + ('𐦀', '𐦷'), + ('𐦼', '𐧏'), + ('𐧒', '𐨀'), + ('𐨐', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('𐩀', '𐩈'), + ('𐩐', '𐩘'), + ('𐩠', '𐪟'), + ('𐫀', '𐫤'), + ('𐫫', '𐫶'), + ('𐬀', '𐬵'), + ('𐬹', '𐭕'), + ('𐭘', '𐭲'), + ('𐭸', '𐮑'), + ('𐮙', '𐮜'), + ('𐮩', '𐮯'), + ('𐰀', '𐱈'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𐳺', '𐴣'), + ('𐴰', '𐴹'), + ('𐹠', '𐹾'), + ('𐼀', '𐼧'), + ('𐼰', '𐽅'), + ('𐽑', '𐽙'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀀', '𑀀'), + ('𑀂', '𑀷'), + ('𑁇', '𑁍'), + ('𑁒', '𑁯'), + ('𑂂', '𑂲'), + ('𑂷', '𑂸'), + ('𑂻', '𑂼'), + ('𑂾', '𑃁'), + ('𑃐', '𑃨'), + ('𑃰', '𑃹'), + ('𑄃', '𑄦'), + ('𑄬', '𑄬'), + ('𑄶', '𑅆'), + ('𑅐', '𑅲'), + ('𑅴', '𑅶'), + ('𑆂', '𑆵'), + ('𑆿', '𑇈'), + ('𑇍', '𑇍'), + ('𑇐', '𑇟'), + ('𑇡', '𑇴'), + ('𑈀', '𑈑'), + ('𑈓', '𑈮'), + ('𑈲', '𑈳'), + ('𑈵', '𑈵'), + ('𑈸', '𑈽'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊩'), + ('𑊰', '𑋞'), + ('𑋠', '𑋢'), + ('𑋰', '𑋹'), + ('𑌂', '𑌃'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('𑌽', '𑌽'), + ('𑌿', '𑌿'), + ('𑍁', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('𑍐', '𑍐'), + ('𑍝', '𑍣'), + ('𑐀', '𑐷'), + ('𑑀', '𑑁'), + ('𑑅', '𑑅'), + ('𑑇', '𑑙'), + ('𑑛', '𑑛'), + ('𑑝', '𑑝'), + ('\u{1145f}', '\u{1145f}'), + ('𑒀', '𑒯'), + ('𑒱', '𑒲'), + ('𑒹', '𑒹'), + ('𑒻', '𑒼'), + ('𑒾', '𑒾'), + ('𑓁', '𑓁'), + ('𑓄', '𑓇'), + ('𑓐', '𑓙'), + ('𑖀', '𑖮'), + ('𑖰', '𑖱'), + ('𑖸', '𑖻'), + ('𑖾', '𑖾'), + ('𑗁', '𑗛'), + ('𑘀', '𑘲'), + ('𑘻', '𑘼'), + ('𑘾', '𑘾'), + ('𑙁', '𑙄'), + ('𑙐', '𑙙'), + ('𑙠', '𑙬'), + ('𑚀', '𑚪'), + ('𑚬', '𑚬'), + ('𑚮', '𑚯'), + ('𑚶', '𑚶'), + ('\u{116b8}', '\u{116b8}'), + ('𑛀', '𑛉'), + ('𑜀', '𑜚'), + ('𑜠', '𑜡'), + ('𑜦', '𑜦'), + ('𑜰', '𑜿'), + ('𑠀', '𑠮'), + ('𑠸', '𑠸'), + ('𑠻', '𑠻'), + ('𑢠', '𑣲'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d3}'), + ('\u{119dc}', '\u{119df}'), + ('\u{119e1}', '\u{119e4}'), + ('𑨀', '𑨀'), + ('𑨋', '𑨲'), + ('𑨹', '𑨺'), + ('𑨿', '𑩆'), + ('𑩐', '𑩐'), + ('𑩗', '𑩘'), + ('𑩜', '𑪉'), + ('𑪗', '𑪗'), + ('𑪚', '𑪢'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '𑰯'), + ('𑰾', '𑰾'), + ('𑱀', '𑱅'), + ('𑱐', '𑱬'), + ('𑱰', '𑲏'), + ('𑲩', '𑲩'), + ('𑲱', '𑲱'), + ('𑲴', '𑲴'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '𑴰'), + ('𑵆', '𑵆'), + ('𑵐', '𑵙'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶎'), + ('𑶓', '𑶔'), + ('𑶖', '𑶖'), + ('𑶘', '𑶘'), + ('𑶠', '𑶩'), + ('𑻠', '𑻲'), + ('𑻵', '𑻸'), + ('\u{11fc0}', '\u{11ff1}'), + ('\u{11fff}', '𒎙'), + ('𒐀', '𒑮'), + ('𒑰', '𒑴'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖩠', '𖩩'), + ('𖩮', '𖩯'), + ('𖫐', '𖫭'), + ('𖫵', '𖫵'), + ('𖬀', '𖬯'), + ('𖬷', '𖭅'), + ('𖭐', '𖭙'), + ('𖭛', '𖭡'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖹀', '𖺚'), + ('𖼀', '\u{16f4a}'), + ('𖽐', '\u{16f87}'), + ('𖾓', '𖾟'), + ('𖿠', '\u{16fe3}'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛀀', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('𛅰', '𛋻'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('𛲜', '𛲜'), + ('𛲟', '𛲟'), + ('𝀀', '𝃵'), + ('𝄀', '𝄦'), + ('𝄩', '𝅘𝅥𝅲'), + ('𝅦', '𝅦'), + ('𝅪', '𝅭'), + ('𝆃', '𝆄'), + ('𝆌', '𝆩'), + ('𝆮', '𝇨'), + ('𝈀', '𝉁'), + ('𝉅', '𝉅'), + ('𝋠', '𝋳'), + ('𝌀', '𝍖'), + ('𝍠', '𝍸'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝟋'), + ('𝟎', '𝧿'), + ('𝨷', '𝨺'), + ('𝩭', '𝩴'), + ('𝩶', '𝪃'), + ('𝪅', '𝪋'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e137}', '\u{1e13d}'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e14e}', '\u{1e14f}'), + ('\u{1e2c0}', '\u{1e2eb}'), + ('\u{1e2f0}', '\u{1e2f9}'), + ('\u{1e2ff}', '\u{1e2ff}'), + ('𞠀', '𞣄'), + ('𞣇', '𞣏'), + ('𞤀', '𞥃'), + ('\u{1e94b}', '\u{1e94b}'), + ('𞥐', '𞥙'), + ('𞥞', '𞥟'), + ('𞱱', '𞲴'), + ('\u{1ed01}', '\u{1ed3d}'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𞻰', '𞻱'), + ('🀀', '🀫'), + ('🀰', '🂓'), + ('🂠', '🂮'), + ('🂱', '🂿'), + ('🃁', '🃏'), + ('🃑', '🃵'), + ('🄀', '🄌'), + ('🄐', '\u{1f16c}'), + ('🅰', '🆬'), + ('🇦', '🈂'), + ('🈐', '🈻'), + ('🉀', '🉈'), + ('🉐', '🉑'), + ('🉠', '🉥'), + ('🌀', '\u{1f6d5}'), + ('🛠', '🛬'), + ('🛰', '\u{1f6fa}'), + ('🜀', '🝳'), + ('🞀', '🟘'), + ('\u{1f7e0}', '\u{1f7eb}'), + ('🠀', '🠋'), + ('🠐', '🡇'), + ('🡐', '🡙'), + ('🡠', '🢇'), + ('🢐', '🢭'), + ('🤀', '🤋'), + ('\u{1f90d}', '\u{1f971}'), + ('🥳', '🥶'), + ('🥺', '🦢'), + ('\u{1f9a5}', '\u{1f9aa}'), + ('\u{1f9ae}', '\u{1f9ca}'), + ('\u{1f9cd}', '\u{1fa53}'), + ('🩠', '🩭'), + ('\u{1fa70}', '\u{1fa73}'), + ('\u{1fa78}', '\u{1fa7a}'), + ('\u{1fa80}', '\u{1fa82}'), + ('\u{1fa90}', '\u{1fa95}'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), +]; + +pub const GRAPHEME_EXTEND: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), + ('\u{483}', '\u{489}'), + ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('\u{610}', '\u{61a}'), + ('\u{64b}', '\u{65f}'), + ('\u{670}', '\u{670}'), + ('\u{6d6}', '\u{6dc}'), + ('\u{6df}', '\u{6e4}'), + ('\u{6e7}', '\u{6e8}'), + ('\u{6ea}', '\u{6ed}'), + ('\u{711}', '\u{711}'), + ('\u{730}', '\u{74a}'), + ('\u{7a6}', '\u{7b0}'), + ('\u{7eb}', '\u{7f3}'), + ('\u{7fd}', '\u{7fd}'), + ('\u{816}', '\u{819}'), + ('\u{81b}', '\u{823}'), + ('\u{825}', '\u{827}'), + ('\u{829}', '\u{82d}'), + ('\u{859}', '\u{85b}'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', '\u{902}'), + ('\u{93a}', '\u{93a}'), + ('\u{93c}', '\u{93c}'), + ('\u{941}', '\u{948}'), + ('\u{94d}', '\u{94d}'), + ('\u{951}', '\u{957}'), + ('\u{962}', '\u{963}'), + ('\u{981}', '\u{981}'), + ('\u{9bc}', '\u{9bc}'), + ('\u{9be}', '\u{9be}'), + ('\u{9c1}', '\u{9c4}'), + ('\u{9cd}', '\u{9cd}'), + ('\u{9d7}', '\u{9d7}'), + ('\u{9e2}', '\u{9e3}'), + ('\u{9fe}', '\u{9fe}'), + ('\u{a01}', '\u{a02}'), + ('\u{a3c}', '\u{a3c}'), + ('\u{a41}', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('\u{a70}', '\u{a71}'), + ('\u{a75}', '\u{a75}'), + ('\u{a81}', '\u{a82}'), + ('\u{abc}', '\u{abc}'), + ('\u{ac1}', '\u{ac5}'), + ('\u{ac7}', '\u{ac8}'), + ('\u{acd}', '\u{acd}'), + ('\u{ae2}', '\u{ae3}'), + ('\u{afa}', '\u{aff}'), + ('\u{b01}', '\u{b01}'), + ('\u{b3c}', '\u{b3c}'), + ('\u{b3e}', '\u{b3f}'), + ('\u{b41}', '\u{b44}'), + ('\u{b4d}', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('\u{b62}', '\u{b63}'), + ('\u{b82}', '\u{b82}'), + ('\u{bbe}', '\u{bbe}'), + ('\u{bc0}', '\u{bc0}'), + ('\u{bcd}', '\u{bcd}'), + ('\u{bd7}', '\u{bd7}'), + ('\u{c00}', '\u{c00}'), + ('\u{c04}', '\u{c04}'), + ('\u{c3e}', '\u{c40}'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('\u{c62}', '\u{c63}'), + ('\u{c81}', '\u{c81}'), + ('\u{cbc}', '\u{cbc}'), + ('\u{cbf}', '\u{cbf}'), + ('\u{cc2}', '\u{cc2}'), + ('\u{cc6}', '\u{cc6}'), + ('\u{ccc}', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('\u{ce2}', '\u{ce3}'), + ('\u{d00}', '\u{d01}'), + ('\u{d3b}', '\u{d3c}'), + ('\u{d3e}', '\u{d3e}'), + ('\u{d41}', '\u{d44}'), + ('\u{d4d}', '\u{d4d}'), + ('\u{d57}', '\u{d57}'), + ('\u{d62}', '\u{d63}'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dcf}'), + ('\u{dd2}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('\u{ddf}', '\u{ddf}'), + ('\u{e31}', '\u{e31}'), + ('\u{e34}', '\u{e3a}'), + ('\u{e47}', '\u{e4e}'), + ('\u{eb1}', '\u{eb1}'), + ('\u{eb4}', '\u{ebc}'), + ('\u{ec8}', '\u{ecd}'), + ('\u{f18}', '\u{f19}'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('\u{f71}', '\u{f7e}'), + ('\u{f80}', '\u{f84}'), + ('\u{f86}', '\u{f87}'), + ('\u{f8d}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), + ('\u{102d}', '\u{1030}'), + ('\u{1032}', '\u{1037}'), + ('\u{1039}', '\u{103a}'), + ('\u{103d}', '\u{103e}'), + ('\u{1058}', '\u{1059}'), + ('\u{105e}', '\u{1060}'), + ('\u{1071}', '\u{1074}'), + ('\u{1082}', '\u{1082}'), + ('\u{1085}', '\u{1086}'), + ('\u{108d}', '\u{108d}'), + ('\u{109d}', '\u{109d}'), + ('\u{135d}', '\u{135f}'), + ('\u{1712}', '\u{1714}'), + ('\u{1732}', '\u{1734}'), + ('\u{1752}', '\u{1753}'), + ('\u{1772}', '\u{1773}'), + ('\u{17b4}', '\u{17b5}'), + ('\u{17b7}', '\u{17bd}'), + ('\u{17c6}', '\u{17c6}'), + ('\u{17c9}', '\u{17d3}'), + ('\u{17dd}', '\u{17dd}'), + ('\u{180b}', '\u{180d}'), + ('\u{1885}', '\u{1886}'), + ('\u{18a9}', '\u{18a9}'), + ('\u{1920}', '\u{1922}'), + ('\u{1927}', '\u{1928}'), + ('\u{1932}', '\u{1932}'), + ('\u{1939}', '\u{193b}'), + ('\u{1a17}', '\u{1a18}'), + ('\u{1a1b}', '\u{1a1b}'), + ('\u{1a56}', '\u{1a56}'), + ('\u{1a58}', '\u{1a5e}'), + ('\u{1a60}', '\u{1a60}'), + ('\u{1a62}', '\u{1a62}'), + ('\u{1a65}', '\u{1a6c}'), + ('\u{1a73}', '\u{1a7c}'), + ('\u{1a7f}', '\u{1a7f}'), + ('\u{1ab0}', '\u{1abe}'), + ('\u{1b00}', '\u{1b03}'), + ('\u{1b34}', '\u{1b3a}'), + ('\u{1b3c}', '\u{1b3c}'), + ('\u{1b42}', '\u{1b42}'), + ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', '\u{1b81}'), + ('\u{1ba2}', '\u{1ba5}'), + ('\u{1ba8}', '\u{1ba9}'), + ('\u{1bab}', '\u{1bad}'), + ('\u{1be6}', '\u{1be6}'), + ('\u{1be8}', '\u{1be9}'), + ('\u{1bed}', '\u{1bed}'), + ('\u{1bef}', '\u{1bf1}'), + ('\u{1c2c}', '\u{1c33}'), + ('\u{1c36}', '\u{1c37}'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1ce0}'), + ('\u{1ce2}', '\u{1ce8}'), + ('\u{1ced}', '\u{1ced}'), + ('\u{1cf4}', '\u{1cf4}'), + ('\u{1cf8}', '\u{1cf9}'), + ('\u{1dc0}', '\u{1df9}'), + ('\u{1dfb}', '\u{1dff}'), + ('\u{200c}', '\u{200c}'), + ('\u{20d0}', '\u{20f0}'), + ('\u{2cef}', '\u{2cf1}'), + ('\u{2d7f}', '\u{2d7f}'), + ('\u{2de0}', '\u{2dff}'), + ('\u{302a}', '\u{302f}'), + ('\u{3099}', '\u{309a}'), + ('\u{a66f}', '\u{a672}'), + ('\u{a674}', '\u{a67d}'), + ('\u{a69e}', '\u{a69f}'), + ('\u{a6f0}', '\u{a6f1}'), + ('\u{a802}', '\u{a802}'), + ('\u{a806}', '\u{a806}'), + ('\u{a80b}', '\u{a80b}'), + ('\u{a825}', '\u{a826}'), + ('\u{a8c4}', '\u{a8c5}'), + ('\u{a8e0}', '\u{a8f1}'), + ('\u{a8ff}', '\u{a8ff}'), + ('\u{a926}', '\u{a92d}'), + ('\u{a947}', '\u{a951}'), + ('\u{a980}', '\u{a982}'), + ('\u{a9b3}', '\u{a9b3}'), + ('\u{a9b6}', '\u{a9b9}'), + ('\u{a9bc}', 'ꦽ'), + ('\u{a9e5}', '\u{a9e5}'), + ('\u{aa29}', '\u{aa2e}'), + ('\u{aa31}', '\u{aa32}'), + ('\u{aa35}', '\u{aa36}'), + ('\u{aa43}', '\u{aa43}'), + ('\u{aa4c}', '\u{aa4c}'), + ('\u{aa7c}', '\u{aa7c}'), + ('\u{aab0}', '\u{aab0}'), + ('\u{aab2}', '\u{aab4}'), + ('\u{aab7}', '\u{aab8}'), + ('\u{aabe}', '\u{aabf}'), + ('\u{aac1}', '\u{aac1}'), + ('\u{aaec}', '\u{aaed}'), + ('\u{aaf6}', '\u{aaf6}'), + ('\u{abe5}', '\u{abe5}'), + ('\u{abe8}', '\u{abe8}'), + ('\u{abed}', '\u{abed}'), + ('\u{fb1e}', '\u{fb1e}'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2f}'), + ('\u{ff9e}', '\u{ff9f}'), + ('\u{101fd}', '\u{101fd}'), + ('\u{102e0}', '\u{102e0}'), + ('\u{10376}', '\u{1037a}'), + ('\u{10a01}', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a0f}'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), + ('\u{10ae5}', '\u{10ae6}'), + ('\u{10d24}', '\u{10d27}'), + ('\u{10f46}', '\u{10f50}'), + ('\u{11001}', '\u{11001}'), + ('\u{11038}', '\u{11046}'), + ('\u{1107f}', '\u{11081}'), + ('\u{110b3}', '\u{110b6}'), + ('\u{110b9}', '\u{110ba}'), + ('\u{11100}', '\u{11102}'), + ('\u{11127}', '\u{1112b}'), + ('\u{1112d}', '\u{11134}'), + ('\u{11173}', '\u{11173}'), + ('\u{11180}', '\u{11181}'), + ('\u{111b6}', '\u{111be}'), + ('\u{111c9}', '\u{111cc}'), + ('\u{1122f}', '\u{11231}'), + ('\u{11234}', '\u{11234}'), + ('\u{11236}', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('\u{112df}', '\u{112df}'), + ('\u{112e3}', '\u{112ea}'), + ('\u{11300}', '\u{11301}'), + ('\u{1133b}', '\u{1133c}'), + ('\u{1133e}', '\u{1133e}'), + ('\u{11340}', '\u{11340}'), + ('\u{11357}', '\u{11357}'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('\u{11438}', '\u{1143f}'), + ('\u{11442}', '\u{11444}'), + ('\u{11446}', '\u{11446}'), + ('\u{1145e}', '\u{1145e}'), + ('\u{114b0}', '\u{114b0}'), + ('\u{114b3}', '\u{114b8}'), + ('\u{114ba}', '\u{114ba}'), + ('\u{114bd}', '\u{114bd}'), + ('\u{114bf}', '\u{114c0}'), + ('\u{114c2}', '\u{114c3}'), + ('\u{115af}', '\u{115af}'), + ('\u{115b2}', '\u{115b5}'), + ('\u{115bc}', '\u{115bd}'), + ('\u{115bf}', '\u{115c0}'), + ('\u{115dc}', '\u{115dd}'), + ('\u{11633}', '\u{1163a}'), + ('\u{1163d}', '\u{1163d}'), + ('\u{1163f}', '\u{11640}'), + ('\u{116ab}', '\u{116ab}'), + ('\u{116ad}', '\u{116ad}'), + ('\u{116b0}', '\u{116b5}'), + ('\u{116b7}', '\u{116b7}'), + ('\u{1171d}', '\u{1171f}'), + ('\u{11722}', '\u{11725}'), + ('\u{11727}', '\u{1172b}'), + ('\u{1182f}', '\u{11837}'), + ('\u{11839}', '\u{1183a}'), + ('\u{119d4}', '\u{119d7}'), + ('\u{119da}', '\u{119db}'), + ('\u{119e0}', '\u{119e0}'), + ('\u{11a01}', '\u{11a0a}'), + ('\u{11a33}', '\u{11a38}'), + ('\u{11a3b}', '\u{11a3e}'), + ('\u{11a47}', '\u{11a47}'), + ('\u{11a51}', '\u{11a56}'), + ('\u{11a59}', '\u{11a5b}'), + ('\u{11a8a}', '\u{11a96}'), + ('\u{11a98}', '\u{11a99}'), + ('\u{11c30}', '\u{11c36}'), + ('\u{11c38}', '\u{11c3d}'), + ('\u{11c3f}', '\u{11c3f}'), + ('\u{11c92}', '\u{11ca7}'), + ('\u{11caa}', '\u{11cb0}'), + ('\u{11cb2}', '\u{11cb3}'), + ('\u{11cb5}', '\u{11cb6}'), + ('\u{11d31}', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d45}'), + ('\u{11d47}', '\u{11d47}'), + ('\u{11d90}', '\u{11d91}'), + ('\u{11d95}', '\u{11d95}'), + ('\u{11d97}', '\u{11d97}'), + ('\u{11ef3}', '\u{11ef4}'), + ('\u{16af0}', '\u{16af4}'), + ('\u{16b30}', '\u{16b36}'), + ('\u{16f4f}', '\u{16f4f}'), + ('\u{16f8f}', '\u{16f92}'), + ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d165}', '\u{1d165}'), + ('\u{1d167}', '\u{1d169}'), + ('\u{1d16e}', '\u{1d172}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1d242}', '\u{1d244}'), + ('\u{1da00}', '\u{1da36}'), + ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), + ('\u{1da84}', '\u{1da84}'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e130}', '\u{1e136}'), + ('\u{1e2ec}', '\u{1e2ef}'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('\u{1e944}', '\u{1e94a}'), + ('\u{e0020}', '\u{e007f}'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const GRAPHEME_LINK: &'static [(char, char)] = &[ + ('\u{94d}', '\u{94d}'), + ('\u{9cd}', '\u{9cd}'), + ('\u{a4d}', '\u{a4d}'), + ('\u{acd}', '\u{acd}'), + ('\u{b4d}', '\u{b4d}'), + ('\u{bcd}', '\u{bcd}'), + ('\u{c4d}', '\u{c4d}'), + ('\u{ccd}', '\u{ccd}'), + ('\u{d3b}', '\u{d3c}'), + ('\u{d4d}', '\u{d4d}'), + ('\u{dca}', '\u{dca}'), + ('\u{e3a}', '\u{e3a}'), + ('\u{eba}', '\u{eba}'), + ('\u{f84}', '\u{f84}'), + ('\u{1039}', '\u{103a}'), + ('\u{1714}', '\u{1714}'), + ('\u{1734}', '\u{1734}'), + ('\u{17d2}', '\u{17d2}'), + ('\u{1a60}', '\u{1a60}'), + ('᭄', '᭄'), + ('᮪', '\u{1bab}'), + ('᯲', '᯳'), + ('\u{2d7f}', '\u{2d7f}'), + ('\u{a806}', '\u{a806}'), + ('\u{a8c4}', '\u{a8c4}'), + ('꥓', '꥓'), + ('꧀', '꧀'), + ('\u{aaf6}', '\u{aaf6}'), + ('\u{abed}', '\u{abed}'), + ('\u{10a3f}', '\u{10a3f}'), + ('\u{11046}', '\u{11046}'), + ('\u{1107f}', '\u{1107f}'), + ('\u{110b9}', '\u{110b9}'), + ('\u{11133}', '\u{11134}'), + ('𑇀', '𑇀'), + ('𑈵', '𑈵'), + ('\u{112ea}', '\u{112ea}'), + ('𑍍', '𑍍'), + ('\u{11442}', '\u{11442}'), + ('\u{114c2}', '\u{114c2}'), + ('\u{115bf}', '\u{115bf}'), + ('\u{1163f}', '\u{1163f}'), + ('𑚶', '𑚶'), + ('\u{1172b}', '\u{1172b}'), + ('\u{11839}', '\u{11839}'), + ('\u{119e0}', '\u{119e0}'), + ('\u{11a34}', '\u{11a34}'), + ('\u{11a47}', '\u{11a47}'), + ('\u{11a99}', '\u{11a99}'), + ('\u{11c3f}', '\u{11c3f}'), + ('\u{11d44}', '\u{11d45}'), + ('\u{11d97}', '\u{11d97}'), +]; + +pub const HEX_DIGIT: &'static [(char, char)] = &[ + ('0', '9'), + ('A', 'F'), + ('a', 'f'), + ('0', '9'), + ('A', 'F'), + ('a', 'f'), +]; + +pub const HYPHEN: &'static [(char, char)] = &[ + ('-', '-'), + ('\u{ad}', '\u{ad}'), + ('֊', '֊'), + ('᠆', '᠆'), + ('‐', '‑'), + ('⸗', '⸗'), + ('・', '・'), + ('﹣', '﹣'), + ('-', '-'), + ('・', '・'), +]; + +pub const IDS_BINARY_OPERATOR: &'static [(char, char)] = + &[('⿰', '⿱'), ('⿴', '⿻')]; + +pub const IDS_TRINARY_OPERATOR: &'static [(char, char)] = &[('⿲', '⿳')]; + +pub const ID_CONTINUE: &'static [(char, char)] = &[ + ('0', '9'), + ('A', 'Z'), + ('_', '_'), + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('·', '·'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ˁ'), + ('ˆ', 'ˑ'), + ('ˠ', 'ˤ'), + ('ˬ', 'ˬ'), + ('ˮ', 'ˮ'), + ('\u{300}', 'ʹ'), + ('Ͷ', 'ͷ'), + ('ͺ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϵ'), + ('Ϸ', 'ҁ'), + ('\u{483}', '\u{487}'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՙ', 'ՙ'), + ('ՠ', 'ֈ'), + ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('א', 'ת'), + ('ׯ', 'ײ'), + ('\u{610}', '\u{61a}'), + ('ؠ', '٩'), + ('ٮ', 'ۓ'), + ('ە', '\u{6dc}'), + ('\u{6df}', '\u{6e8}'), + ('\u{6ea}', 'ۼ'), + ('ۿ', 'ۿ'), + ('ܐ', '\u{74a}'), + ('ݍ', 'ޱ'), + ('߀', 'ߵ'), + ('ߺ', 'ߺ'), + ('\u{7fd}', '\u{7fd}'), + ('ࠀ', '\u{82d}'), + ('ࡀ', '\u{85b}'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', '\u{963}'), + ('०', '९'), + ('ॱ', 'ঃ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('\u{9bc}', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', 'ৎ'), + ('\u{9d7}', '\u{9d7}'), + ('ড়', 'ঢ়'), + ('য়', '\u{9e3}'), + ('০', 'ৱ'), + ('ৼ', 'ৼ'), + ('\u{9fe}', '\u{9fe}'), + ('\u{a01}', 'ਃ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('\u{a3c}', '\u{a3c}'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('੦', '\u{a75}'), + ('\u{a81}', 'ઃ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('\u{abc}', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', '\u{acd}'), + ('ૐ', 'ૐ'), + ('ૠ', '\u{ae3}'), + ('૦', '૯'), + ('ૹ', '\u{aff}'), + ('\u{b01}', 'ଃ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('\u{b3c}', '\u{b44}'), + ('େ', 'ୈ'), + ('ୋ', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', '\u{b63}'), + ('୦', '୯'), + ('ୱ', 'ୱ'), + ('\u{b82}', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', '\u{bcd}'), + ('ௐ', 'ௐ'), + ('\u{bd7}', '\u{bd7}'), + ('௦', '௯'), + ('\u{c00}', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('ౘ', 'ౚ'), + ('ౠ', '\u{c63}'), + ('౦', '౯'), + ('ಀ', 'ಃ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('\u{cbc}', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('ೞ', 'ೞ'), + ('ೠ', '\u{ce3}'), + ('೦', '೯'), + ('ೱ', 'ೲ'), + ('\u{d00}', 'ഃ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', '\u{d44}'), + ('െ', 'ൈ'), + ('ൊ', 'ൎ'), + ('ൔ', '\u{d57}'), + ('ൟ', '\u{d63}'), + ('൦', '൯'), + ('ൺ', 'ൿ'), + ('ං', 'ඃ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('෦', '෯'), + ('ෲ', 'ෳ'), + ('ก', '\u{e3a}'), + ('เ', '\u{e4e}'), + ('๐', '๙'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('\u{ec8}', '\u{ecd}'), + ('໐', '໙'), + ('ໜ', 'ໟ'), + ('ༀ', 'ༀ'), + ('\u{f18}', '\u{f19}'), + ('༠', '༩'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('༾', 'ཇ'), + ('ཉ', 'ཬ'), + ('\u{f71}', '\u{f84}'), + ('\u{f86}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), + ('က', '၉'), + ('ၐ', '\u{109d}'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჼ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('\u{135d}', '\u{135f}'), + ('፩', '፱'), + ('ᎀ', 'ᎏ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᐁ', 'ᙬ'), + ('ᙯ', 'ᙿ'), + ('ᚁ', 'ᚚ'), + ('ᚠ', 'ᛪ'), + ('ᛮ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', '\u{1714}'), + ('ᜠ', '\u{1734}'), + ('ᝀ', '\u{1753}'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('\u{1772}', '\u{1773}'), + ('ក', '\u{17d3}'), + ('ៗ', 'ៗ'), + ('ៜ', '\u{17dd}'), + ('០', '៩'), + ('\u{180b}', '\u{180d}'), + ('᠐', '᠙'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', '\u{193b}'), + ('᥆', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('ᦀ', 'ᦫ'), + ('ᦰ', 'ᧉ'), + ('᧐', '᧚'), + ('ᨀ', '\u{1a1b}'), + ('ᨠ', '\u{1a5e}'), + ('\u{1a60}', '\u{1a7c}'), + ('\u{1a7f}', '᪉'), + ('᪐', '᪙'), + ('ᪧ', 'ᪧ'), + ('\u{1ab0}', '\u{1abd}'), + ('\u{1b00}', 'ᭋ'), + ('᭐', '᭙'), + ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', '᯳'), + ('ᰀ', '\u{1c37}'), + ('᱀', '᱉'), + ('ᱍ', 'ᱽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1cfa}'), + ('ᴀ', '\u{1df9}'), + ('\u{1dfb}', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('‿', '⁀'), + ('⁔', '⁔'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('\u{20d0}', '\u{20dc}'), + ('\u{20e1}', '\u{20e1}'), + ('\u{20e5}', '\u{20f0}'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('℘', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℹ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ↈ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⳤ'), + ('Ⳬ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ⴰ', 'ⵧ'), + ('ⵯ', 'ⵯ'), + ('\u{2d7f}', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('\u{2de0}', '\u{2dff}'), + ('々', '〇'), + ('〡', '\u{302f}'), + ('〱', '〵'), + ('〸', '〼'), + ('ぁ', 'ゖ'), + ('\u{3099}', 'ゟ'), + ('ァ', 'ヺ'), + ('ー', 'ヿ'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('ㆠ', 'ㆺ'), + ('ㇰ', 'ㇿ'), + ('㐀', '䶵'), + ('一', '鿯'), + ('ꀀ', 'ꒌ'), + ('ꓐ', 'ꓽ'), + ('ꔀ', 'ꘌ'), + ('ꘐ', 'ꘫ'), + ('Ꙁ', '\u{a66f}'), + ('\u{a674}', '\u{a67d}'), + ('ꙿ', '\u{a6f1}'), + ('ꜗ', 'ꜟ'), + ('Ꜣ', 'ꞈ'), + ('Ꞌ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꠧ'), + ('ꡀ', 'ꡳ'), + ('ꢀ', '\u{a8c5}'), + ('꣐', '꣙'), + ('\u{a8e0}', 'ꣷ'), + ('ꣻ', 'ꣻ'), + ('ꣽ', '\u{a92d}'), + ('ꤰ', '꥓'), + ('ꥠ', 'ꥼ'), + ('\u{a980}', '꧀'), + ('ꧏ', '꧙'), + ('ꧠ', 'ꧾ'), + ('ꨀ', '\u{aa36}'), + ('ꩀ', 'ꩍ'), + ('꩐', '꩙'), + ('ꩠ', 'ꩶ'), + ('ꩺ', 'ꫂ'), + ('ꫛ', 'ꫝ'), + ('ꫠ', 'ꫯ'), + ('ꫲ', '\u{aaf6}'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', '\u{ab67}'), + ('ꭰ', 'ꯪ'), + ('꯬', '\u{abed}'), + ('꯰', '꯹'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('豈', '舘'), + ('並', '龎'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('יִ', 'ﬨ'), + ('שׁ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﮱ'), + ('ﯓ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷻ'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2f}'), + ('︳', '︴'), + ('﹍', '﹏'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('0', '9'), + ('A', 'Z'), + ('_', '_'), + ('a', 'z'), + ('ヲ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐅀', '𐅴'), + ('\u{101fd}', '\u{101fd}'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('\u{102e0}', '\u{102e0}'), + ('𐌀', '𐌟'), + ('𐌭', '𐍊'), + ('𐍐', '\u{1037a}'), + ('𐎀', '𐎝'), + ('𐎠', '𐏃'), + ('𐏈', '𐏏'), + ('𐏑', '𐏕'), + ('𐐀', '𐒝'), + ('𐒠', '𐒩'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡠', '𐡶'), + ('𐢀', '𐢞'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐤀', '𐤕'), + ('𐤠', '𐤹'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𐨀', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), + ('𐩠', '𐩼'), + ('𐪀', '𐪜'), + ('𐫀', '𐫇'), + ('𐫉', '\u{10ae6}'), + ('𐬀', '𐬵'), + ('𐭀', '𐭕'), + ('𐭠', '𐭲'), + ('𐮀', '𐮑'), + ('𐰀', '𐱈'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𐴀', '\u{10d27}'), + ('𐴰', '𐴹'), + ('𐼀', '𐼜'), + ('𐼧', '𐼧'), + ('𐼰', '\u{10f50}'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀀', '\u{11046}'), + ('𑁦', '𑁯'), + ('\u{1107f}', '\u{110ba}'), + ('𑃐', '𑃨'), + ('𑃰', '𑃹'), + ('\u{11100}', '\u{11134}'), + ('𑄶', '𑄿'), + ('𑅄', '𑅆'), + ('𑅐', '\u{11173}'), + ('𑅶', '𑅶'), + ('\u{11180}', '𑇄'), + ('\u{111c9}', '\u{111cc}'), + ('𑇐', '𑇚'), + ('𑇜', '𑇜'), + ('𑈀', '𑈑'), + ('𑈓', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊨'), + ('𑊰', '\u{112ea}'), + ('𑋰', '𑋹'), + ('\u{11300}', '𑌃'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('\u{1133b}', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('𑍐', '𑍐'), + ('\u{11357}', '\u{11357}'), + ('𑍝', '𑍣'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('𑐀', '𑑊'), + ('𑑐', '𑑙'), + ('\u{1145e}', '\u{1145f}'), + ('𑒀', '𑓅'), + ('𑓇', '𑓇'), + ('𑓐', '𑓙'), + ('𑖀', '\u{115b5}'), + ('𑖸', '\u{115c0}'), + ('𑗘', '\u{115dd}'), + ('𑘀', '\u{11640}'), + ('𑙄', '𑙄'), + ('𑙐', '𑙙'), + ('𑚀', '\u{116b8}'), + ('𑛀', '𑛉'), + ('𑜀', '𑜚'), + ('\u{1171d}', '\u{1172b}'), + ('𑜰', '𑜹'), + ('𑠀', '\u{1183a}'), + ('𑢠', '𑣩'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d7}'), + ('\u{119da}', '\u{119e1}'), + ('\u{119e3}', '\u{119e4}'), + ('𑨀', '\u{11a3e}'), + ('\u{11a47}', '\u{11a47}'), + ('𑩐', '\u{11a99}'), + ('𑪝', '𑪝'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '\u{11c36}'), + ('\u{11c38}', '𑱀'), + ('𑱐', '𑱙'), + ('𑱲', '𑲏'), + ('\u{11c92}', '\u{11ca7}'), + ('𑲩', '\u{11cb6}'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d47}'), + ('𑵐', '𑵙'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '𑶘'), + ('𑶠', '𑶩'), + ('𑻠', '𑻶'), + ('𒀀', '𒎙'), + ('𒐀', '𒑮'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖩠', '𖩩'), + ('𖫐', '𖫭'), + ('\u{16af0}', '\u{16af4}'), + ('𖬀', '\u{16b36}'), + ('𖭀', '𖭃'), + ('𖭐', '𖭙'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖹀', '𖹿'), + ('𖼀', '\u{16f4a}'), + ('\u{16f4f}', '\u{16f87}'), + ('\u{16f8f}', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛀀', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('𛅰', '𛋻'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d165}', '\u{1d169}'), + ('𝅭', '\u{1d172}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1d242}', '\u{1d244}'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('𝟎', '𝟿'), + ('\u{1da00}', '\u{1da36}'), + ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), + ('\u{1da84}', '\u{1da84}'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e130}', '\u{1e13d}'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e14e}', '\u{1e14e}'), + ('\u{1e2c0}', '\u{1e2f9}'), + ('𞠀', '𞣄'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('𞤀', '\u{1e94b}'), + ('𞥐', '𞥙'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const ID_START: &'static [(char, char)] = &[ + ('A', 'Z'), + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ˁ'), + ('ˆ', 'ˑ'), + ('ˠ', 'ˤ'), + ('ˬ', 'ˬ'), + ('ˮ', 'ˮ'), + ('Ͱ', 'ʹ'), + ('Ͷ', 'ͷ'), + ('ͺ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϵ'), + ('Ϸ', 'ҁ'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՙ', 'ՙ'), + ('ՠ', 'ֈ'), + ('א', 'ת'), + ('ׯ', 'ײ'), + ('ؠ', 'ي'), + ('ٮ', 'ٯ'), + ('ٱ', 'ۓ'), + ('ە', 'ە'), + ('ۥ', 'ۦ'), + ('ۮ', 'ۯ'), + ('ۺ', 'ۼ'), + ('ۿ', 'ۿ'), + ('ܐ', 'ܐ'), + ('ܒ', 'ܯ'), + ('ݍ', 'ޥ'), + ('ޱ', 'ޱ'), + ('ߊ', 'ߪ'), + ('ߴ', 'ߵ'), + ('ߺ', 'ߺ'), + ('ࠀ', 'ࠕ'), + ('ࠚ', 'ࠚ'), + ('ࠤ', 'ࠤ'), + ('ࠨ', 'ࠨ'), + ('ࡀ', 'ࡘ'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('ऄ', 'ह'), + ('ऽ', 'ऽ'), + ('ॐ', 'ॐ'), + ('क़', 'ॡ'), + ('ॱ', 'ঀ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('ঽ', 'ঽ'), + ('ৎ', 'ৎ'), + ('ড়', 'ঢ়'), + ('য়', 'ৡ'), + ('ৰ', 'ৱ'), + ('ৼ', 'ৼ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('ੲ', 'ੴ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('ઽ', 'ઽ'), + ('ૐ', 'ૐ'), + ('ૠ', 'ૡ'), + ('ૹ', 'ૹ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('ଽ', 'ଽ'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', 'ୡ'), + ('ୱ', 'ୱ'), + ('ஃ', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('ௐ', 'ௐ'), + ('అ', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ఽ'), + ('ౘ', 'ౚ'), + ('ౠ', 'ౡ'), + ('ಀ', 'ಀ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('ಽ', 'ಽ'), + ('ೞ', 'ೞ'), + ('ೠ', 'ೡ'), + ('ೱ', 'ೲ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', 'ഺ'), + ('ഽ', 'ഽ'), + ('ൎ', 'ൎ'), + ('ൔ', 'ൖ'), + ('ൟ', 'ൡ'), + ('ൺ', 'ൿ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('ก', 'ะ'), + ('า', 'ำ'), + ('เ', 'ๆ'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ະ'), + ('າ', 'ຳ'), + ('ຽ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('ໜ', 'ໟ'), + ('ༀ', 'ༀ'), + ('ཀ', 'ཇ'), + ('ཉ', 'ཬ'), + ('ྈ', 'ྌ'), + ('က', 'ဪ'), + ('ဿ', 'ဿ'), + ('ၐ', 'ၕ'), + ('ၚ', 'ၝ'), + ('ၡ', 'ၡ'), + ('ၥ', 'ၦ'), + ('ၮ', 'ၰ'), + ('ၵ', 'ႁ'), + ('ႎ', 'ႎ'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჼ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('ᎀ', 'ᎏ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᐁ', 'ᙬ'), + ('ᙯ', 'ᙿ'), + ('ᚁ', 'ᚚ'), + ('ᚠ', 'ᛪ'), + ('ᛮ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', 'ᜑ'), + ('ᜠ', 'ᜱ'), + ('ᝀ', 'ᝑ'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('ក', 'ឳ'), + ('ៗ', 'ៗ'), + ('ៜ', 'ៜ'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢨ'), + ('ᢪ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('ᥐ', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('ᦀ', 'ᦫ'), + ('ᦰ', 'ᧉ'), + ('ᨀ', 'ᨖ'), + ('ᨠ', 'ᩔ'), + ('ᪧ', 'ᪧ'), + ('ᬅ', 'ᬳ'), + ('ᭅ', 'ᭋ'), + ('ᮃ', 'ᮠ'), + ('ᮮ', 'ᮯ'), + ('ᮺ', 'ᯥ'), + ('ᰀ', 'ᰣ'), + ('ᱍ', 'ᱏ'), + ('ᱚ', 'ᱽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ᳩ', 'ᳬ'), + ('ᳮ', 'ᳳ'), + ('ᳵ', 'ᳶ'), + ('\u{1cfa}', '\u{1cfa}'), + ('ᴀ', 'ᶿ'), + ('Ḁ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('℘', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℹ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ↈ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⳤ'), + ('Ⳬ', 'ⳮ'), + ('Ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ⴰ', 'ⵧ'), + ('ⵯ', 'ⵯ'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('々', '〇'), + ('〡', '〩'), + ('〱', '〵'), + ('〸', '〼'), + ('ぁ', 'ゖ'), + ('゛', 'ゟ'), + ('ァ', 'ヺ'), + ('ー', 'ヿ'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('ㆠ', 'ㆺ'), + ('ㇰ', 'ㇿ'), + ('㐀', '䶵'), + ('一', '鿯'), + ('ꀀ', 'ꒌ'), + ('ꓐ', 'ꓽ'), + ('ꔀ', 'ꘌ'), + ('ꘐ', 'ꘟ'), + ('ꘪ', 'ꘫ'), + ('Ꙁ', 'ꙮ'), + ('ꙿ', 'ꚝ'), + ('ꚠ', 'ꛯ'), + ('ꜗ', 'ꜟ'), + ('Ꜣ', 'ꞈ'), + ('Ꞌ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꠁ'), + ('ꠃ', 'ꠅ'), + ('ꠇ', 'ꠊ'), + ('ꠌ', 'ꠢ'), + ('ꡀ', 'ꡳ'), + ('ꢂ', 'ꢳ'), + ('ꣲ', 'ꣷ'), + ('ꣻ', 'ꣻ'), + ('ꣽ', 'ꣾ'), + ('ꤊ', 'ꤥ'), + ('ꤰ', 'ꥆ'), + ('ꥠ', 'ꥼ'), + ('ꦄ', 'ꦲ'), + ('ꧏ', 'ꧏ'), + ('ꧠ', 'ꧤ'), + ('ꧦ', 'ꧯ'), + ('ꧺ', 'ꧾ'), + ('ꨀ', 'ꨨ'), + ('ꩀ', 'ꩂ'), + ('ꩄ', 'ꩋ'), + ('ꩠ', 'ꩶ'), + ('ꩺ', 'ꩺ'), + ('ꩾ', 'ꪯ'), + ('ꪱ', 'ꪱ'), + ('ꪵ', 'ꪶ'), + ('ꪹ', 'ꪽ'), + ('ꫀ', 'ꫀ'), + ('ꫂ', 'ꫂ'), + ('ꫛ', 'ꫝ'), + ('ꫠ', 'ꫪ'), + ('ꫲ', 'ꫴ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', '\u{ab67}'), + ('ꭰ', 'ꯢ'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('豈', '舘'), + ('並', '龎'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('יִ', 'יִ'), + ('ײַ', 'ﬨ'), + ('שׁ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﮱ'), + ('ﯓ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷻ'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('A', 'Z'), + ('a', 'z'), + ('ヲ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐅀', '𐅴'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('𐌀', '𐌟'), + ('𐌭', '𐍊'), + ('𐍐', '𐍵'), + ('𐎀', '𐎝'), + ('𐎠', '𐏃'), + ('𐏈', '𐏏'), + ('𐏑', '𐏕'), + ('𐐀', '𐒝'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡠', '𐡶'), + ('𐢀', '𐢞'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐤀', '𐤕'), + ('𐤠', '𐤹'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𐨀', '𐨀'), + ('𐨐', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('𐩠', '𐩼'), + ('𐪀', '𐪜'), + ('𐫀', '𐫇'), + ('𐫉', '𐫤'), + ('𐬀', '𐬵'), + ('𐭀', '𐭕'), + ('𐭠', '𐭲'), + ('𐮀', '𐮑'), + ('𐰀', '𐱈'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𐴀', '𐴣'), + ('𐼀', '𐼜'), + ('𐼧', '𐼧'), + ('𐼰', '𐽅'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀃', '𑀷'), + ('𑂃', '𑂯'), + ('𑃐', '𑃨'), + ('𑄃', '𑄦'), + ('𑅄', '𑅄'), + ('𑅐', '𑅲'), + ('𑅶', '𑅶'), + ('𑆃', '𑆲'), + ('𑇁', '𑇄'), + ('𑇚', '𑇚'), + ('𑇜', '𑇜'), + ('𑈀', '𑈑'), + ('𑈓', '𑈫'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊨'), + ('𑊰', '𑋞'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('𑌽', '𑌽'), + ('𑍐', '𑍐'), + ('𑍝', '𑍡'), + ('𑐀', '𑐴'), + ('𑑇', '𑑊'), + ('\u{1145f}', '\u{1145f}'), + ('𑒀', '𑒯'), + ('𑓄', '𑓅'), + ('𑓇', '𑓇'), + ('𑖀', '𑖮'), + ('𑗘', '𑗛'), + ('𑘀', '𑘯'), + ('𑙄', '𑙄'), + ('𑚀', '𑚪'), + ('\u{116b8}', '\u{116b8}'), + ('𑜀', '𑜚'), + ('𑠀', '𑠫'), + ('𑢠', '𑣟'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d0}'), + ('\u{119e1}', '\u{119e1}'), + ('\u{119e3}', '\u{119e3}'), + ('𑨀', '𑨀'), + ('𑨋', '𑨲'), + ('𑨺', '𑨺'), + ('𑩐', '𑩐'), + ('𑩜', '𑪉'), + ('𑪝', '𑪝'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '𑰮'), + ('𑱀', '𑱀'), + ('𑱲', '𑲏'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '𑴰'), + ('𑵆', '𑵆'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶉'), + ('𑶘', '𑶘'), + ('𑻠', '𑻲'), + ('𒀀', '𒎙'), + ('𒐀', '𒑮'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖫐', '𖫭'), + ('𖬀', '𖬯'), + ('𖭀', '𖭃'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖹀', '𖹿'), + ('𖼀', '\u{16f4a}'), + ('𖽐', '𖽐'), + ('𖾓', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛀀', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('𛅰', '𛋻'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e137}', '\u{1e13d}'), + ('\u{1e14e}', '\u{1e14e}'), + ('\u{1e2c0}', '\u{1e2eb}'), + ('𞠀', '𞣄'), + ('𞤀', '𞥃'), + ('\u{1e94b}', '\u{1e94b}'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), +]; + +pub const IDEOGRAPHIC: &'static [(char, char)] = &[ + ('〆', '〇'), + ('〡', '〩'), + ('〸', '〺'), + ('㐀', '䶵'), + ('一', '鿯'), + ('豈', '舘'), + ('並', '龎'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛅰', '𛋻'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), +]; + +pub const JOIN_CONTROL: &'static [(char, char)] = &[('\u{200c}', '\u{200d}')]; + +pub const LOGICAL_ORDER_EXCEPTION: &'static [(char, char)] = &[ + ('เ', 'ไ'), + ('ເ', 'ໄ'), + ('ᦵ', 'ᦷ'), + ('ᦺ', 'ᦺ'), + ('ꪵ', 'ꪶ'), + ('ꪹ', 'ꪹ'), + ('ꪻ', 'ꪼ'), +]; + +pub const LOWERCASE: &'static [(char, char)] = &[ + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('º', 'º'), + ('ß', 'ö'), + ('ø', 'ÿ'), + ('ā', 'ā'), + ('ă', 'ă'), + ('ą', 'ą'), + ('ć', 'ć'), + ('ĉ', 'ĉ'), + ('ċ', 'ċ'), + ('č', 'č'), + ('ď', 'ď'), + ('đ', 'đ'), + ('ē', 'ē'), + ('ĕ', 'ĕ'), + ('ė', 'ė'), + ('ę', 'ę'), + ('ě', 'ě'), + ('ĝ', 'ĝ'), + ('ğ', 'ğ'), + ('ġ', 'ġ'), + ('ģ', 'ģ'), + ('ĥ', 'ĥ'), + ('ħ', 'ħ'), + ('ĩ', 'ĩ'), + ('ī', 'ī'), + ('ĭ', 'ĭ'), + ('į', 'į'), + ('ı', 'ı'), + ('ij', 'ij'), + ('ĵ', 'ĵ'), + ('ķ', 'ĸ'), + ('ĺ', 'ĺ'), + ('ļ', 'ļ'), + ('ľ', 'ľ'), + ('ŀ', 'ŀ'), + ('ł', 'ł'), + ('ń', 'ń'), + ('ņ', 'ņ'), + ('ň', 'ʼn'), + ('ŋ', 'ŋ'), + ('ō', 'ō'), + ('ŏ', 'ŏ'), + ('ő', 'ő'), + ('œ', 'œ'), + ('ŕ', 'ŕ'), + ('ŗ', 'ŗ'), + ('ř', 'ř'), + ('ś', 'ś'), + ('ŝ', 'ŝ'), + ('ş', 'ş'), + ('š', 'š'), + ('ţ', 'ţ'), + ('ť', 'ť'), + ('ŧ', 'ŧ'), + ('ũ', 'ũ'), + ('ū', 'ū'), + ('ŭ', 'ŭ'), + ('ů', 'ů'), + ('ű', 'ű'), + ('ų', 'ų'), + ('ŵ', 'ŵ'), + ('ŷ', 'ŷ'), + ('ź', 'ź'), + ('ż', 'ż'), + ('ž', 'ƀ'), + ('ƃ', 'ƃ'), + ('ƅ', 'ƅ'), + ('ƈ', 'ƈ'), + ('ƌ', 'ƍ'), + ('ƒ', 'ƒ'), + ('ƕ', 'ƕ'), + ('ƙ', 'ƛ'), + ('ƞ', 'ƞ'), + ('ơ', 'ơ'), + ('ƣ', 'ƣ'), + ('ƥ', 'ƥ'), + ('ƨ', 'ƨ'), + ('ƪ', 'ƫ'), + ('ƭ', 'ƭ'), + ('ư', 'ư'), + ('ƴ', 'ƴ'), + ('ƶ', 'ƶ'), + ('ƹ', 'ƺ'), + ('ƽ', 'ƿ'), + ('dž', 'dž'), + ('lj', 'lj'), + ('nj', 'nj'), + ('ǎ', 'ǎ'), + ('ǐ', 'ǐ'), + ('ǒ', 'ǒ'), + ('ǔ', 'ǔ'), + ('ǖ', 'ǖ'), + ('ǘ', 'ǘ'), + ('ǚ', 'ǚ'), + ('ǜ', 'ǝ'), + ('ǟ', 'ǟ'), + ('ǡ', 'ǡ'), + ('ǣ', 'ǣ'), + ('ǥ', 'ǥ'), + ('ǧ', 'ǧ'), + ('ǩ', 'ǩ'), + ('ǫ', 'ǫ'), + ('ǭ', 'ǭ'), + ('ǯ', 'ǰ'), + ('dz', 'dz'), + ('ǵ', 'ǵ'), + ('ǹ', 'ǹ'), + ('ǻ', 'ǻ'), + ('ǽ', 'ǽ'), + ('ǿ', 'ǿ'), + ('ȁ', 'ȁ'), + ('ȃ', 'ȃ'), + ('ȅ', 'ȅ'), + ('ȇ', 'ȇ'), + ('ȉ', 'ȉ'), + ('ȋ', 'ȋ'), + ('ȍ', 'ȍ'), + ('ȏ', 'ȏ'), + ('ȑ', 'ȑ'), + ('ȓ', 'ȓ'), + ('ȕ', 'ȕ'), + ('ȗ', 'ȗ'), + ('ș', 'ș'), + ('ț', 'ț'), + ('ȝ', 'ȝ'), + ('ȟ', 'ȟ'), + ('ȡ', 'ȡ'), + ('ȣ', 'ȣ'), + ('ȥ', 'ȥ'), + ('ȧ', 'ȧ'), + ('ȩ', 'ȩ'), + ('ȫ', 'ȫ'), + ('ȭ', 'ȭ'), + ('ȯ', 'ȯ'), + ('ȱ', 'ȱ'), + ('ȳ', 'ȹ'), + ('ȼ', 'ȼ'), + ('ȿ', 'ɀ'), + ('ɂ', 'ɂ'), + ('ɇ', 'ɇ'), + ('ɉ', 'ɉ'), + ('ɋ', 'ɋ'), + ('ɍ', 'ɍ'), + ('ɏ', 'ʓ'), + ('ʕ', 'ʸ'), + ('ˀ', 'ˁ'), + ('ˠ', 'ˤ'), + ('\u{345}', '\u{345}'), + ('ͱ', 'ͱ'), + ('ͳ', 'ͳ'), + ('ͷ', 'ͷ'), + ('ͺ', 'ͽ'), + ('ΐ', 'ΐ'), + ('ά', 'ώ'), + ('ϐ', 'ϑ'), + ('ϕ', 'ϗ'), + ('ϙ', 'ϙ'), + ('ϛ', 'ϛ'), + ('ϝ', 'ϝ'), + ('ϟ', 'ϟ'), + ('ϡ', 'ϡ'), + ('ϣ', 'ϣ'), + ('ϥ', 'ϥ'), + ('ϧ', 'ϧ'), + ('ϩ', 'ϩ'), + ('ϫ', 'ϫ'), + ('ϭ', 'ϭ'), + ('ϯ', 'ϳ'), + ('ϵ', 'ϵ'), + ('ϸ', 'ϸ'), + ('ϻ', 'ϼ'), + ('а', 'џ'), + ('ѡ', 'ѡ'), + ('ѣ', 'ѣ'), + ('ѥ', 'ѥ'), + ('ѧ', 'ѧ'), + ('ѩ', 'ѩ'), + ('ѫ', 'ѫ'), + ('ѭ', 'ѭ'), + ('ѯ', 'ѯ'), + ('ѱ', 'ѱ'), + ('ѳ', 'ѳ'), + ('ѵ', 'ѵ'), + ('ѷ', 'ѷ'), + ('ѹ', 'ѹ'), + ('ѻ', 'ѻ'), + ('ѽ', 'ѽ'), + ('ѿ', 'ѿ'), + ('ҁ', 'ҁ'), + ('ҋ', 'ҋ'), + ('ҍ', 'ҍ'), + ('ҏ', 'ҏ'), + ('ґ', 'ґ'), + ('ғ', 'ғ'), + ('ҕ', 'ҕ'), + ('җ', 'җ'), + ('ҙ', 'ҙ'), + ('қ', 'қ'), + ('ҝ', 'ҝ'), + ('ҟ', 'ҟ'), + ('ҡ', 'ҡ'), + ('ң', 'ң'), + ('ҥ', 'ҥ'), + ('ҧ', 'ҧ'), + ('ҩ', 'ҩ'), + ('ҫ', 'ҫ'), + ('ҭ', 'ҭ'), + ('ү', 'ү'), + ('ұ', 'ұ'), + ('ҳ', 'ҳ'), + ('ҵ', 'ҵ'), + ('ҷ', 'ҷ'), + ('ҹ', 'ҹ'), + ('һ', 'һ'), + ('ҽ', 'ҽ'), + ('ҿ', 'ҿ'), + ('ӂ', 'ӂ'), + ('ӄ', 'ӄ'), + ('ӆ', 'ӆ'), + ('ӈ', 'ӈ'), + ('ӊ', 'ӊ'), + ('ӌ', 'ӌ'), + ('ӎ', 'ӏ'), + ('ӑ', 'ӑ'), + ('ӓ', 'ӓ'), + ('ӕ', 'ӕ'), + ('ӗ', 'ӗ'), + ('ә', 'ә'), + ('ӛ', 'ӛ'), + ('ӝ', 'ӝ'), + ('ӟ', 'ӟ'), + ('ӡ', 'ӡ'), + ('ӣ', 'ӣ'), + ('ӥ', 'ӥ'), + ('ӧ', 'ӧ'), + ('ө', 'ө'), + ('ӫ', 'ӫ'), + ('ӭ', 'ӭ'), + ('ӯ', 'ӯ'), + ('ӱ', 'ӱ'), + ('ӳ', 'ӳ'), + ('ӵ', 'ӵ'), + ('ӷ', 'ӷ'), + ('ӹ', 'ӹ'), + ('ӻ', 'ӻ'), + ('ӽ', 'ӽ'), + ('ӿ', 'ӿ'), + ('ԁ', 'ԁ'), + ('ԃ', 'ԃ'), + ('ԅ', 'ԅ'), + ('ԇ', 'ԇ'), + ('ԉ', 'ԉ'), + ('ԋ', 'ԋ'), + ('ԍ', 'ԍ'), + ('ԏ', 'ԏ'), + ('ԑ', 'ԑ'), + ('ԓ', 'ԓ'), + ('ԕ', 'ԕ'), + ('ԗ', 'ԗ'), + ('ԙ', 'ԙ'), + ('ԛ', 'ԛ'), + ('ԝ', 'ԝ'), + ('ԟ', 'ԟ'), + ('ԡ', 'ԡ'), + ('ԣ', 'ԣ'), + ('ԥ', 'ԥ'), + ('ԧ', 'ԧ'), + ('ԩ', 'ԩ'), + ('ԫ', 'ԫ'), + ('ԭ', 'ԭ'), + ('ԯ', 'ԯ'), + ('ՠ', 'ֈ'), + ('ა', 'ჺ'), + ('ჽ', 'ჿ'), + ('ᏸ', 'ᏽ'), + ('ᲀ', 'ᲈ'), + ('ᴀ', 'ᶿ'), + ('ḁ', 'ḁ'), + ('ḃ', 'ḃ'), + ('ḅ', 'ḅ'), + ('ḇ', 'ḇ'), + ('ḉ', 'ḉ'), + ('ḋ', 'ḋ'), + ('ḍ', 'ḍ'), + ('ḏ', 'ḏ'), + ('ḑ', 'ḑ'), + ('ḓ', 'ḓ'), + ('ḕ', 'ḕ'), + ('ḗ', 'ḗ'), + ('ḙ', 'ḙ'), + ('ḛ', 'ḛ'), + ('ḝ', 'ḝ'), + ('ḟ', 'ḟ'), + ('ḡ', 'ḡ'), + ('ḣ', 'ḣ'), + ('ḥ', 'ḥ'), + ('ḧ', 'ḧ'), + ('ḩ', 'ḩ'), + ('ḫ', 'ḫ'), + ('ḭ', 'ḭ'), + ('ḯ', 'ḯ'), + ('ḱ', 'ḱ'), + ('ḳ', 'ḳ'), + ('ḵ', 'ḵ'), + ('ḷ', 'ḷ'), + ('ḹ', 'ḹ'), + ('ḻ', 'ḻ'), + ('ḽ', 'ḽ'), + ('ḿ', 'ḿ'), + ('ṁ', 'ṁ'), + ('ṃ', 'ṃ'), + ('ṅ', 'ṅ'), + ('ṇ', 'ṇ'), + ('ṉ', 'ṉ'), + ('ṋ', 'ṋ'), + ('ṍ', 'ṍ'), + ('ṏ', 'ṏ'), + ('ṑ', 'ṑ'), + ('ṓ', 'ṓ'), + ('ṕ', 'ṕ'), + ('ṗ', 'ṗ'), + ('ṙ', 'ṙ'), + ('ṛ', 'ṛ'), + ('ṝ', 'ṝ'), + ('ṟ', 'ṟ'), + ('ṡ', 'ṡ'), + ('ṣ', 'ṣ'), + ('ṥ', 'ṥ'), + ('ṧ', 'ṧ'), + ('ṩ', 'ṩ'), + ('ṫ', 'ṫ'), + ('ṭ', 'ṭ'), + ('ṯ', 'ṯ'), + ('ṱ', 'ṱ'), + ('ṳ', 'ṳ'), + ('ṵ', 'ṵ'), + ('ṷ', 'ṷ'), + ('ṹ', 'ṹ'), + ('ṻ', 'ṻ'), + ('ṽ', 'ṽ'), + ('ṿ', 'ṿ'), + ('ẁ', 'ẁ'), + ('ẃ', 'ẃ'), + ('ẅ', 'ẅ'), + ('ẇ', 'ẇ'), + ('ẉ', 'ẉ'), + ('ẋ', 'ẋ'), + ('ẍ', 'ẍ'), + ('ẏ', 'ẏ'), + ('ẑ', 'ẑ'), + ('ẓ', 'ẓ'), + ('ẕ', 'ẝ'), + ('ẟ', 'ẟ'), + ('ạ', 'ạ'), + ('ả', 'ả'), + ('ấ', 'ấ'), + ('ầ', 'ầ'), + ('ẩ', 'ẩ'), + ('ẫ', 'ẫ'), + ('ậ', 'ậ'), + ('ắ', 'ắ'), + ('ằ', 'ằ'), + ('ẳ', 'ẳ'), + ('ẵ', 'ẵ'), + ('ặ', 'ặ'), + ('ẹ', 'ẹ'), + ('ẻ', 'ẻ'), + ('ẽ', 'ẽ'), + ('ế', 'ế'), + ('ề', 'ề'), + ('ể', 'ể'), + ('ễ', 'ễ'), + ('ệ', 'ệ'), + ('ỉ', 'ỉ'), + ('ị', 'ị'), + ('ọ', 'ọ'), + ('ỏ', 'ỏ'), + ('ố', 'ố'), + ('ồ', 'ồ'), + ('ổ', 'ổ'), + ('ỗ', 'ỗ'), + ('ộ', 'ộ'), + ('ớ', 'ớ'), + ('ờ', 'ờ'), + ('ở', 'ở'), + ('ỡ', 'ỡ'), + ('ợ', 'ợ'), + ('ụ', 'ụ'), + ('ủ', 'ủ'), + ('ứ', 'ứ'), + ('ừ', 'ừ'), + ('ử', 'ử'), + ('ữ', 'ữ'), + ('ự', 'ự'), + ('ỳ', 'ỳ'), + ('ỵ', 'ỵ'), + ('ỷ', 'ỷ'), + ('ỹ', 'ỹ'), + ('ỻ', 'ỻ'), + ('ỽ', 'ỽ'), + ('ỿ', 'ἇ'), + ('ἐ', 'ἕ'), + ('ἠ', 'ἧ'), + ('ἰ', 'ἷ'), + ('ὀ', 'ὅ'), + ('ὐ', 'ὗ'), + ('ὠ', 'ὧ'), + ('ὰ', 'ώ'), + ('ᾀ', 'ᾇ'), + ('ᾐ', 'ᾗ'), + ('ᾠ', 'ᾧ'), + ('ᾰ', 'ᾴ'), + ('ᾶ', 'ᾷ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῇ'), + ('ῐ', 'ΐ'), + ('ῖ', 'ῗ'), + ('ῠ', 'ῧ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῷ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('ℊ', 'ℊ'), + ('ℎ', 'ℏ'), + ('ℓ', 'ℓ'), + ('ℯ', 'ℯ'), + ('ℴ', 'ℴ'), + ('ℹ', 'ℹ'), + ('ℼ', 'ℽ'), + ('ⅆ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('ⅰ', 'ⅿ'), + ('ↄ', 'ↄ'), + ('ⓐ', 'ⓩ'), + ('ⰰ', 'ⱞ'), + ('ⱡ', 'ⱡ'), + ('ⱥ', 'ⱦ'), + ('ⱨ', 'ⱨ'), + ('ⱪ', 'ⱪ'), + ('ⱬ', 'ⱬ'), + ('ⱱ', 'ⱱ'), + ('ⱳ', 'ⱴ'), + ('ⱶ', 'ⱽ'), + ('ⲁ', 'ⲁ'), + ('ⲃ', 'ⲃ'), + ('ⲅ', 'ⲅ'), + ('ⲇ', 'ⲇ'), + ('ⲉ', 'ⲉ'), + ('ⲋ', 'ⲋ'), + ('ⲍ', 'ⲍ'), + ('ⲏ', 'ⲏ'), + ('ⲑ', 'ⲑ'), + ('ⲓ', 'ⲓ'), + ('ⲕ', 'ⲕ'), + ('ⲗ', 'ⲗ'), + ('ⲙ', 'ⲙ'), + ('ⲛ', 'ⲛ'), + ('ⲝ', 'ⲝ'), + ('ⲟ', 'ⲟ'), + ('ⲡ', 'ⲡ'), + ('ⲣ', 'ⲣ'), + ('ⲥ', 'ⲥ'), + ('ⲧ', 'ⲧ'), + ('ⲩ', 'ⲩ'), + ('ⲫ', 'ⲫ'), + ('ⲭ', 'ⲭ'), + ('ⲯ', 'ⲯ'), + ('ⲱ', 'ⲱ'), + ('ⲳ', 'ⲳ'), + ('ⲵ', 'ⲵ'), + ('ⲷ', 'ⲷ'), + ('ⲹ', 'ⲹ'), + ('ⲻ', 'ⲻ'), + ('ⲽ', 'ⲽ'), + ('ⲿ', 'ⲿ'), + ('ⳁ', 'ⳁ'), + ('ⳃ', 'ⳃ'), + ('ⳅ', 'ⳅ'), + ('ⳇ', 'ⳇ'), + ('ⳉ', 'ⳉ'), + ('ⳋ', 'ⳋ'), + ('ⳍ', 'ⳍ'), + ('ⳏ', 'ⳏ'), + ('ⳑ', 'ⳑ'), + ('ⳓ', 'ⳓ'), + ('ⳕ', 'ⳕ'), + ('ⳗ', 'ⳗ'), + ('ⳙ', 'ⳙ'), + ('ⳛ', 'ⳛ'), + ('ⳝ', 'ⳝ'), + ('ⳟ', 'ⳟ'), + ('ⳡ', 'ⳡ'), + ('ⳣ', 'ⳤ'), + ('ⳬ', 'ⳬ'), + ('ⳮ', 'ⳮ'), + ('ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ꙁ', 'ꙁ'), + ('ꙃ', 'ꙃ'), + ('ꙅ', 'ꙅ'), + ('ꙇ', 'ꙇ'), + ('ꙉ', 'ꙉ'), + ('ꙋ', 'ꙋ'), + ('ꙍ', 'ꙍ'), + ('ꙏ', 'ꙏ'), + ('ꙑ', 'ꙑ'), + ('ꙓ', 'ꙓ'), + ('ꙕ', 'ꙕ'), + ('ꙗ', 'ꙗ'), + ('ꙙ', 'ꙙ'), + ('ꙛ', 'ꙛ'), + ('ꙝ', 'ꙝ'), + ('ꙟ', 'ꙟ'), + ('ꙡ', 'ꙡ'), + ('ꙣ', 'ꙣ'), + ('ꙥ', 'ꙥ'), + ('ꙧ', 'ꙧ'), + ('ꙩ', 'ꙩ'), + ('ꙫ', 'ꙫ'), + ('ꙭ', 'ꙭ'), + ('ꚁ', 'ꚁ'), + ('ꚃ', 'ꚃ'), + ('ꚅ', 'ꚅ'), + ('ꚇ', 'ꚇ'), + ('ꚉ', 'ꚉ'), + ('ꚋ', 'ꚋ'), + ('ꚍ', 'ꚍ'), + ('ꚏ', 'ꚏ'), + ('ꚑ', 'ꚑ'), + ('ꚓ', 'ꚓ'), + ('ꚕ', 'ꚕ'), + ('ꚗ', 'ꚗ'), + ('ꚙ', 'ꚙ'), + ('ꚛ', 'ꚝ'), + ('ꜣ', 'ꜣ'), + ('ꜥ', 'ꜥ'), + ('ꜧ', 'ꜧ'), + ('ꜩ', 'ꜩ'), + ('ꜫ', 'ꜫ'), + ('ꜭ', 'ꜭ'), + ('ꜯ', 'ꜱ'), + ('ꜳ', 'ꜳ'), + ('ꜵ', 'ꜵ'), + ('ꜷ', 'ꜷ'), + ('ꜹ', 'ꜹ'), + ('ꜻ', 'ꜻ'), + ('ꜽ', 'ꜽ'), + ('ꜿ', 'ꜿ'), + ('ꝁ', 'ꝁ'), + ('ꝃ', 'ꝃ'), + ('ꝅ', 'ꝅ'), + ('ꝇ', 'ꝇ'), + ('ꝉ', 'ꝉ'), + ('ꝋ', 'ꝋ'), + ('ꝍ', 'ꝍ'), + ('ꝏ', 'ꝏ'), + ('ꝑ', 'ꝑ'), + ('ꝓ', 'ꝓ'), + ('ꝕ', 'ꝕ'), + ('ꝗ', 'ꝗ'), + ('ꝙ', 'ꝙ'), + ('ꝛ', 'ꝛ'), + ('ꝝ', 'ꝝ'), + ('ꝟ', 'ꝟ'), + ('ꝡ', 'ꝡ'), + ('ꝣ', 'ꝣ'), + ('ꝥ', 'ꝥ'), + ('ꝧ', 'ꝧ'), + ('ꝩ', 'ꝩ'), + ('ꝫ', 'ꝫ'), + ('ꝭ', 'ꝭ'), + ('ꝯ', 'ꝸ'), + ('ꝺ', 'ꝺ'), + ('ꝼ', 'ꝼ'), + ('ꝿ', 'ꝿ'), + ('ꞁ', 'ꞁ'), + ('ꞃ', 'ꞃ'), + ('ꞅ', 'ꞅ'), + ('ꞇ', 'ꞇ'), + ('ꞌ', 'ꞌ'), + ('ꞎ', 'ꞎ'), + ('ꞑ', 'ꞑ'), + ('ꞓ', 'ꞕ'), + ('ꞗ', 'ꞗ'), + ('ꞙ', 'ꞙ'), + ('ꞛ', 'ꞛ'), + ('ꞝ', 'ꞝ'), + ('ꞟ', 'ꞟ'), + ('ꞡ', 'ꞡ'), + ('ꞣ', 'ꞣ'), + ('ꞥ', 'ꞥ'), + ('ꞧ', 'ꞧ'), + ('ꞩ', 'ꞩ'), + ('ꞯ', 'ꞯ'), + ('ꞵ', 'ꞵ'), + ('ꞷ', 'ꞷ'), + ('ꞹ', 'ꞹ'), + ('\u{a7bb}', '\u{a7bb}'), + ('\u{a7bd}', '\u{a7bd}'), + ('\u{a7bf}', '\u{a7bf}'), + ('\u{a7c3}', '\u{a7c3}'), + ('ꟸ', 'ꟺ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', '\u{ab67}'), + ('ꭰ', 'ꮿ'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('a', 'z'), + ('𐐨', '𐑏'), + ('𐓘', '𐓻'), + ('𐳀', '𐳲'), + ('𑣀', '𑣟'), + ('𖹠', '𖹿'), + ('𝐚', '𝐳'), + ('𝑎', '𝑔'), + ('𝑖', '𝑧'), + ('𝒂', '𝒛'), + ('𝒶', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝓏'), + ('𝓪', '𝔃'), + ('𝔞', '𝔷'), + ('𝕒', '𝕫'), + ('𝖆', '𝖟'), + ('𝖺', '𝗓'), + ('𝗮', '𝘇'), + ('𝘢', '𝘻'), + ('𝙖', '𝙯'), + ('𝚊', '𝚥'), + ('𝛂', '𝛚'), + ('𝛜', '𝛡'), + ('𝛼', '𝜔'), + ('𝜖', '𝜛'), + ('𝜶', '𝝎'), + ('𝝐', '𝝕'), + ('𝝰', '𝞈'), + ('𝞊', '𝞏'), + ('𝞪', '𝟂'), + ('𝟄', '𝟉'), + ('𝟋', '𝟋'), + ('𞤢', '𞥃'), +]; + +pub const MATH: &'static [(char, char)] = &[ + ('+', '+'), + ('<', '>'), + ('^', '^'), + ('|', '|'), + ('~', '~'), + ('¬', '¬'), + ('±', '±'), + ('×', '×'), + ('÷', '÷'), + ('ϐ', 'ϒ'), + ('ϕ', 'ϕ'), + ('ϰ', 'ϱ'), + ('ϴ', '϶'), + ('؆', '؈'), + ('‖', '‖'), + ('′', '‴'), + ('⁀', '⁀'), + ('⁄', '⁄'), + ('⁒', '⁒'), + ('\u{2061}', '\u{2064}'), + ('⁺', '⁾'), + ('₊', '₎'), + ('\u{20d0}', '\u{20dc}'), + ('\u{20e1}', '\u{20e1}'), + ('\u{20e5}', '\u{20e6}'), + ('\u{20eb}', '\u{20ef}'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('℘', 'ℝ'), + ('ℤ', 'ℤ'), + ('ℨ', '℩'), + ('ℬ', 'ℭ'), + ('ℯ', 'ℱ'), + ('ℳ', 'ℸ'), + ('ℼ', 'ⅉ'), + ('⅋', '⅋'), + ('←', '↧'), + ('↩', '↮'), + ('↰', '↱'), + ('↶', '↷'), + ('↼', '⇛'), + ('⇝', '⇝'), + ('⇤', '⇥'), + ('⇴', '⋿'), + ('⌈', '⌋'), + ('⌠', '⌡'), + ('⍼', '⍼'), + ('⎛', '⎵'), + ('⎷', '⎷'), + ('⏐', '⏐'), + ('⏜', '⏢'), + ('■', '□'), + ('▮', '▷'), + ('▼', '◁'), + ('◆', '◇'), + ('◊', '○'), + ('●', '◓'), + ('◢', '◢'), + ('◤', '◤'), + ('◧', '◬'), + ('◸', '◿'), + ('★', '☆'), + ('♀', '♀'), + ('♂', '♂'), + ('♠', '♣'), + ('♭', '♯'), + ('⟀', '⟿'), + ('⤀', '⫿'), + ('⬰', '⭄'), + ('⭇', '⭌'), + ('﬩', '﬩'), + ('﹡', '﹦'), + ('﹨', '﹨'), + ('+', '+'), + ('<', '>'), + ('\', '\'), + ('^', '^'), + ('|', '|'), + ('~', '~'), + ('¬', '¬'), + ('←', '↓'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝟋'), + ('𝟎', '𝟿'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𞻰', '𞻱'), +]; + +pub const NONCHARACTER_CODE_POINT: &'static [(char, char)] = &[ + ('\u{fdd0}', '\u{fdef}'), + ('\u{fffe}', '\u{ffff}'), + ('\u{1fffe}', '\u{1ffff}'), + ('\u{2fffe}', '\u{2ffff}'), + ('\u{3fffe}', '\u{3ffff}'), + ('\u{4fffe}', '\u{4ffff}'), + ('\u{5fffe}', '\u{5ffff}'), + ('\u{6fffe}', '\u{6ffff}'), + ('\u{7fffe}', '\u{7ffff}'), + ('\u{8fffe}', '\u{8ffff}'), + ('\u{9fffe}', '\u{9ffff}'), + ('\u{afffe}', '\u{affff}'), + ('\u{bfffe}', '\u{bffff}'), + ('\u{cfffe}', '\u{cffff}'), + ('\u{dfffe}', '\u{dffff}'), + ('\u{efffe}', '\u{effff}'), + ('\u{ffffe}', '\u{fffff}'), + ('\u{10fffe}', '\u{10ffff}'), +]; + +pub const OTHER_ALPHABETIC: &'static [(char, char)] = &[ + ('\u{345}', '\u{345}'), + ('\u{5b0}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('\u{610}', '\u{61a}'), + ('\u{64b}', '\u{657}'), + ('\u{659}', '\u{65f}'), + ('\u{670}', '\u{670}'), + ('\u{6d6}', '\u{6dc}'), + ('\u{6e1}', '\u{6e4}'), + ('\u{6e7}', '\u{6e8}'), + ('\u{6ed}', '\u{6ed}'), + ('\u{711}', '\u{711}'), + ('\u{730}', '\u{73f}'), + ('\u{7a6}', '\u{7b0}'), + ('\u{816}', '\u{817}'), + ('\u{81b}', '\u{823}'), + ('\u{825}', '\u{827}'), + ('\u{829}', '\u{82c}'), + ('\u{8d4}', '\u{8df}'), + ('\u{8e3}', '\u{8e9}'), + ('\u{8f0}', 'ः'), + ('\u{93a}', 'ऻ'), + ('ा', 'ौ'), + ('ॎ', 'ॏ'), + ('\u{955}', '\u{957}'), + ('\u{962}', '\u{963}'), + ('\u{981}', 'ঃ'), + ('\u{9be}', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', 'ৌ'), + ('\u{9d7}', '\u{9d7}'), + ('\u{9e2}', '\u{9e3}'), + ('\u{a01}', 'ਃ'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4c}'), + ('\u{a51}', '\u{a51}'), + ('\u{a70}', '\u{a71}'), + ('\u{a75}', '\u{a75}'), + ('\u{a81}', 'ઃ'), + ('ા', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', 'ૌ'), + ('\u{ae2}', '\u{ae3}'), + ('\u{afa}', '\u{afc}'), + ('\u{b01}', 'ଃ'), + ('\u{b3e}', '\u{b44}'), + ('େ', 'ୈ'), + ('ୋ', 'ୌ'), + ('\u{b56}', '\u{b57}'), + ('\u{b62}', '\u{b63}'), + ('\u{b82}', '\u{b82}'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', 'ௌ'), + ('\u{bd7}', '\u{bd7}'), + ('\u{c00}', 'ః'), + ('\u{c3e}', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4c}'), + ('\u{c55}', '\u{c56}'), + ('\u{c62}', '\u{c63}'), + ('\u{c81}', 'ಃ'), + ('ಾ', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccc}'), + ('\u{cd5}', '\u{cd6}'), + ('\u{ce2}', '\u{ce3}'), + ('\u{d00}', 'ഃ'), + ('\u{d3e}', '\u{d44}'), + ('െ', 'ൈ'), + ('ൊ', 'ൌ'), + ('\u{d57}', '\u{d57}'), + ('\u{d62}', '\u{d63}'), + ('ං', 'ඃ'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('ෲ', 'ෳ'), + ('\u{e31}', '\u{e31}'), + ('\u{e34}', '\u{e3a}'), + ('\u{e4d}', '\u{e4d}'), + ('\u{eb1}', '\u{eb1}'), + ('\u{eb4}', '\u{eb9}'), + ('\u{ebb}', '\u{ebc}'), + ('\u{ecd}', '\u{ecd}'), + ('\u{f71}', '\u{f81}'), + ('\u{f8d}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('ါ', '\u{1036}'), + ('း', 'း'), + ('ျ', '\u{103e}'), + ('ၖ', '\u{1059}'), + ('\u{105e}', '\u{1060}'), + ('ၢ', 'ၤ'), + ('ၧ', 'ၭ'), + ('\u{1071}', '\u{1074}'), + ('\u{1082}', '\u{108d}'), + ('ႏ', 'ႏ'), + ('ႚ', '\u{109d}'), + ('\u{1712}', '\u{1713}'), + ('\u{1732}', '\u{1733}'), + ('\u{1752}', '\u{1753}'), + ('\u{1772}', '\u{1773}'), + ('ា', 'ៈ'), + ('\u{1885}', '\u{1886}'), + ('\u{18a9}', '\u{18a9}'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', 'ᤸ'), + ('\u{1a17}', '\u{1a1b}'), + ('ᩕ', '\u{1a5e}'), + ('ᩡ', '\u{1a74}'), + ('\u{1b00}', 'ᬄ'), + ('ᬵ', 'ᭃ'), + ('\u{1b80}', 'ᮂ'), + ('ᮡ', '\u{1ba9}'), + ('\u{1bac}', '\u{1bad}'), + ('ᯧ', '\u{1bf1}'), + ('ᰤ', '\u{1c36}'), + ('\u{1de7}', '\u{1df4}'), + ('Ⓐ', 'ⓩ'), + ('\u{2de0}', '\u{2dff}'), + ('\u{a674}', '\u{a67b}'), + ('\u{a69e}', '\u{a69f}'), + ('\u{a802}', '\u{a802}'), + ('\u{a80b}', '\u{a80b}'), + ('ꠣ', 'ꠧ'), + ('ꢀ', 'ꢁ'), + ('ꢴ', 'ꣃ'), + ('\u{a8c5}', '\u{a8c5}'), + ('\u{a8ff}', '\u{a8ff}'), + ('\u{a926}', '\u{a92a}'), + ('\u{a947}', 'ꥒ'), + ('\u{a980}', 'ꦃ'), + ('ꦴ', 'ꦿ'), + ('\u{a9e5}', '\u{a9e5}'), + ('\u{aa29}', '\u{aa36}'), + ('\u{aa43}', '\u{aa43}'), + ('\u{aa4c}', 'ꩍ'), + ('ꩻ', 'ꩽ'), + ('\u{aab0}', '\u{aab0}'), + ('\u{aab2}', '\u{aab4}'), + ('\u{aab7}', '\u{aab8}'), + ('\u{aabe}', '\u{aabe}'), + ('ꫫ', 'ꫯ'), + ('ꫵ', 'ꫵ'), + ('ꯣ', 'ꯪ'), + ('\u{fb1e}', '\u{fb1e}'), + ('\u{10376}', '\u{1037a}'), + ('\u{10a01}', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a0f}'), + ('\u{10d24}', '\u{10d27}'), + ('𑀀', '𑀂'), + ('\u{11038}', '\u{11045}'), + ('𑂂', '𑂂'), + ('𑂰', '𑂸'), + ('\u{11100}', '\u{11102}'), + ('\u{11127}', '\u{11132}'), + ('𑅅', '𑅆'), + ('\u{11180}', '𑆂'), + ('𑆳', '𑆿'), + ('𑈬', '\u{11234}'), + ('\u{11237}', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('\u{112df}', '\u{112e8}'), + ('\u{11300}', '𑌃'), + ('\u{1133e}', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍌'), + ('\u{11357}', '\u{11357}'), + ('𑍢', '𑍣'), + ('𑐵', '𑑁'), + ('\u{11443}', '𑑅'), + ('\u{114b0}', '𑓁'), + ('\u{115af}', '\u{115b5}'), + ('𑖸', '𑖾'), + ('\u{115dc}', '\u{115dd}'), + ('𑘰', '𑘾'), + ('\u{11640}', '\u{11640}'), + ('\u{116ab}', '\u{116b5}'), + ('\u{1171d}', '\u{1172a}'), + ('𑠬', '𑠸'), + ('\u{119d1}', '\u{119d7}'), + ('\u{119da}', '\u{119df}'), + ('\u{119e4}', '\u{119e4}'), + ('\u{11a01}', '\u{11a0a}'), + ('\u{11a35}', '𑨹'), + ('\u{11a3b}', '\u{11a3e}'), + ('\u{11a51}', '\u{11a5b}'), + ('\u{11a8a}', '𑪗'), + ('𑰯', '\u{11c36}'), + ('\u{11c38}', '𑰾'), + ('\u{11c92}', '\u{11ca7}'), + ('𑲩', '\u{11cb6}'), + ('\u{11d31}', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d41}'), + ('\u{11d43}', '\u{11d43}'), + ('\u{11d47}', '\u{11d47}'), + ('𑶊', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '𑶖'), + ('\u{11ef3}', '𑻶'), + ('\u{16f4f}', '\u{16f4f}'), + ('𖽑', '\u{16f87}'), + ('\u{16f8f}', '\u{16f92}'), + ('\u{1bc9e}', '\u{1bc9e}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e947}', '\u{1e947}'), + ('🄰', '🅉'), + ('🅐', '🅩'), + ('🅰', '🆉'), +]; + +pub const OTHER_DEFAULT_IGNORABLE_CODE_POINT: &'static [(char, char)] = &[ + ('\u{34f}', '\u{34f}'), + ('ᅟ', 'ᅠ'), + ('\u{17b4}', '\u{17b5}'), + ('\u{2065}', '\u{2065}'), + ('ㅤ', 'ㅤ'), + ('ᅠ', 'ᅠ'), + ('\u{fff0}', '\u{fff8}'), + ('\u{e0000}', '\u{e0000}'), + ('\u{e0002}', '\u{e001f}'), + ('\u{e0080}', '\u{e00ff}'), + ('\u{e01f0}', '\u{e0fff}'), +]; + +pub const OTHER_GRAPHEME_EXTEND: &'static [(char, char)] = &[ + ('\u{9be}', '\u{9be}'), + ('\u{9d7}', '\u{9d7}'), + ('\u{b3e}', '\u{b3e}'), + ('\u{b57}', '\u{b57}'), + ('\u{bbe}', '\u{bbe}'), + ('\u{bd7}', '\u{bd7}'), + ('\u{cc2}', '\u{cc2}'), + ('\u{cd5}', '\u{cd6}'), + ('\u{d3e}', '\u{d3e}'), + ('\u{d57}', '\u{d57}'), + ('\u{dcf}', '\u{dcf}'), + ('\u{ddf}', '\u{ddf}'), + ('ᬵ', 'ᬵ'), + ('\u{200c}', '\u{200c}'), + ('\u{302e}', '\u{302f}'), + ('\u{ff9e}', '\u{ff9f}'), + ('\u{1133e}', '\u{1133e}'), + ('\u{11357}', '\u{11357}'), + ('\u{114b0}', '\u{114b0}'), + ('\u{114bd}', '\u{114bd}'), + ('\u{115af}', '\u{115af}'), + ('\u{1d165}', '\u{1d165}'), + ('\u{1d16e}', '\u{1d172}'), + ('\u{e0020}', '\u{e007f}'), +]; + +pub const OTHER_ID_CONTINUE: &'static [(char, char)] = + &[('·', '·'), ('·', '·'), ('፩', '፱'), ('᧚', '᧚')]; + +pub const OTHER_ID_START: &'static [(char, char)] = + &[('\u{1885}', '\u{1886}'), ('℘', '℘'), ('℮', '℮'), ('゛', '゜')]; + +pub const OTHER_LOWERCASE: &'static [(char, char)] = &[ + ('ª', 'ª'), + ('º', 'º'), + ('ʰ', 'ʸ'), + ('ˀ', 'ˁ'), + ('ˠ', 'ˤ'), + ('\u{345}', '\u{345}'), + ('ͺ', 'ͺ'), + ('ᴬ', 'ᵪ'), + ('ᵸ', 'ᵸ'), + ('ᶛ', 'ᶿ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('ⅰ', 'ⅿ'), + ('ⓐ', 'ⓩ'), + ('ⱼ', 'ⱽ'), + ('ꚜ', 'ꚝ'), + ('ꝰ', 'ꝰ'), + ('ꟸ', 'ꟹ'), + ('ꭜ', 'ꭟ'), +]; + +pub const OTHER_MATH: &'static [(char, char)] = &[ + ('^', '^'), + ('ϐ', 'ϒ'), + ('ϕ', 'ϕ'), + ('ϰ', 'ϱ'), + ('ϴ', 'ϵ'), + ('‖', '‖'), + ('′', '‴'), + ('⁀', '⁀'), + ('\u{2061}', '\u{2064}'), + ('⁽', '⁾'), + ('₍', '₎'), + ('\u{20d0}', '\u{20dc}'), + ('\u{20e1}', '\u{20e1}'), + ('\u{20e5}', '\u{20e6}'), + ('\u{20eb}', '\u{20ef}'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('ℙ', 'ℝ'), + ('ℤ', 'ℤ'), + ('ℨ', '℩'), + ('ℬ', 'ℭ'), + ('ℯ', 'ℱ'), + ('ℳ', 'ℸ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('↕', '↙'), + ('↜', '↟'), + ('↡', '↢'), + ('↤', '↥'), + ('↧', '↧'), + ('↩', '↭'), + ('↰', '↱'), + ('↶', '↷'), + ('↼', '⇍'), + ('⇐', '⇑'), + ('⇓', '⇓'), + ('⇕', '⇛'), + ('⇝', '⇝'), + ('⇤', '⇥'), + ('⌈', '⌋'), + ('⎴', '⎵'), + ('⎷', '⎷'), + ('⏐', '⏐'), + ('⏢', '⏢'), + ('■', '□'), + ('▮', '▶'), + ('▼', '◀'), + ('◆', '◇'), + ('◊', '○'), + ('●', '◓'), + ('◢', '◢'), + ('◤', '◤'), + ('◧', '◬'), + ('★', '☆'), + ('♀', '♀'), + ('♂', '♂'), + ('♠', '♣'), + ('♭', '♮'), + ('⟅', '⟆'), + ('⟦', '⟯'), + ('⦃', '⦘'), + ('⧘', '⧛'), + ('⧼', '⧽'), + ('﹡', '﹡'), + ('﹣', '﹣'), + ('﹨', '﹨'), + ('\', '\'), + ('^', '^'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('𝟎', '𝟿'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), +]; + +pub const OTHER_UPPERCASE: &'static [(char, char)] = + &[('Ⅰ', 'Ⅿ'), ('Ⓐ', 'Ⓩ'), ('🄰', '🅉'), ('🅐', '🅩'), ('🅰', '🆉')]; + +pub const PATTERN_SYNTAX: &'static [(char, char)] = &[ + ('!', '/'), + (':', '@'), + ('[', '^'), + ('`', '`'), + ('{', '~'), + ('¡', '§'), + ('©', '©'), + ('«', '¬'), + ('®', '®'), + ('°', '±'), + ('¶', '¶'), + ('»', '»'), + ('¿', '¿'), + ('×', '×'), + ('÷', '÷'), + ('‐', '‧'), + ('‰', '‾'), + ('⁁', '⁓'), + ('⁕', '⁞'), + ('←', '\u{245f}'), + ('─', '❵'), + ('➔', '\u{2bff}'), + ('⸀', '\u{2e7f}'), + ('、', '〃'), + ('〈', '〠'), + ('〰', '〰'), + ('﴾', '﴿'), + ('﹅', '﹆'), +]; + +pub const PATTERN_WHITE_SPACE: &'static [(char, char)] = &[ + ('\t', '\r'), + (' ', ' '), + ('\u{85}', '\u{85}'), + ('\u{200e}', '\u{200f}'), + ('\u{2028}', '\u{2029}'), +]; + +pub const PREPENDED_CONCATENATION_MARK: &'static [(char, char)] = &[ + ('\u{600}', '\u{605}'), + ('\u{6dd}', '\u{6dd}'), + ('\u{70f}', '\u{70f}'), + ('\u{8e2}', '\u{8e2}'), + ('\u{110bd}', '\u{110bd}'), + ('\u{110cd}', '\u{110cd}'), +]; + +pub const QUOTATION_MARK: &'static [(char, char)] = &[ + ('\"', '\"'), + ('\'', '\''), + ('«', '«'), + ('»', '»'), + ('‘', '‟'), + ('‹', '›'), + ('⹂', '⹂'), + ('「', '』'), + ('〝', '〟'), + ('﹁', '﹄'), + ('"', '"'), + (''', '''), + ('「', '」'), +]; + +pub const RADICAL: &'static [(char, char)] = + &[('⺀', '⺙'), ('⺛', '⻳'), ('⼀', '⿕')]; + +pub const REGIONAL_INDICATOR: &'static [(char, char)] = &[('🇦', '🇿')]; + +pub const SENTENCE_TERMINAL: &'static [(char, char)] = &[ + ('!', '!'), + ('.', '.'), + ('?', '?'), + ('։', '։'), + ('؞', '؟'), + ('۔', '۔'), + ('܀', '܂'), + ('߹', '߹'), + ('࠷', '࠷'), + ('࠹', '࠹'), + ('࠽', '࠾'), + ('।', '॥'), + ('၊', '။'), + ('።', '።'), + ('፧', '፨'), + ('᙮', '᙮'), + ('᜵', '᜶'), + ('᠃', '᠃'), + ('᠉', '᠉'), + ('᥄', '᥅'), + ('᪨', '᪫'), + ('᭚', '᭛'), + ('᭞', '᭟'), + ('᰻', '᰼'), + ('᱾', '᱿'), + ('‼', '‽'), + ('⁇', '⁉'), + ('⸮', '⸮'), + ('⸼', '⸼'), + ('。', '。'), + ('꓿', '꓿'), + ('꘎', '꘏'), + ('꛳', '꛳'), + ('꛷', '꛷'), + ('꡶', '꡷'), + ('꣎', '꣏'), + ('꤯', '꤯'), + ('꧈', '꧉'), + ('꩝', '꩟'), + ('꫰', '꫱'), + ('꯫', '꯫'), + ('﹒', '﹒'), + ('﹖', '﹗'), + ('!', '!'), + ('.', '.'), + ('?', '?'), + ('。', '。'), + ('𐩖', '𐩗'), + ('𐽕', '𐽙'), + ('𑁇', '𑁈'), + ('𑂾', '𑃁'), + ('𑅁', '𑅃'), + ('𑇅', '𑇆'), + ('𑇍', '𑇍'), + ('𑇞', '𑇟'), + ('𑈸', '𑈹'), + ('𑈻', '𑈼'), + ('𑊩', '𑊩'), + ('𑑋', '𑑌'), + ('𑗂', '𑗃'), + ('𑗉', '𑗗'), + ('𑙁', '𑙂'), + ('𑜼', '𑜾'), + ('𑩂', '𑩃'), + ('𑪛', '𑪜'), + ('𑱁', '𑱂'), + ('𑻷', '𑻸'), + ('𖩮', '𖩯'), + ('𖫵', '𖫵'), + ('𖬷', '𖬸'), + ('𖭄', '𖭄'), + ('𖺘', '𖺘'), + ('𛲟', '𛲟'), + ('𝪈', '𝪈'), +]; + +pub const SOFT_DOTTED: &'static [(char, char)] = &[ + ('i', 'j'), + ('į', 'į'), + ('ɉ', 'ɉ'), + ('ɨ', 'ɨ'), + ('ʝ', 'ʝ'), + ('ʲ', 'ʲ'), + ('ϳ', 'ϳ'), + ('і', 'і'), + ('ј', 'ј'), + ('ᵢ', 'ᵢ'), + ('ᶖ', 'ᶖ'), + ('ᶤ', 'ᶤ'), + ('ᶨ', 'ᶨ'), + ('ḭ', 'ḭ'), + ('ị', 'ị'), + ('ⁱ', 'ⁱ'), + ('ⅈ', 'ⅉ'), + ('ⱼ', 'ⱼ'), + ('𝐢', '𝐣'), + ('𝑖', '𝑗'), + ('𝒊', '𝒋'), + ('𝒾', '𝒿'), + ('𝓲', '𝓳'), + ('𝔦', '𝔧'), + ('𝕚', '𝕛'), + ('𝖎', '𝖏'), + ('𝗂', '𝗃'), + ('𝗶', '𝗷'), + ('𝘪', '𝘫'), + ('𝙞', '𝙟'), + ('𝚒', '𝚓'), +]; + +pub const TERMINAL_PUNCTUATION: &'static [(char, char)] = &[ + ('!', '!'), + (',', ','), + ('.', '.'), + (':', ';'), + ('?', '?'), + (';', ';'), + ('·', '·'), + ('։', '։'), + ('׃', '׃'), + ('،', '،'), + ('؛', '؛'), + ('؞', '؟'), + ('۔', '۔'), + ('܀', '܊'), + ('܌', '܌'), + ('߸', '߹'), + ('࠰', '࠾'), + ('࡞', '࡞'), + ('।', '॥'), + ('๚', '๛'), + ('༈', '༈'), + ('།', '༒'), + ('၊', '။'), + ('፡', '፨'), + ('᙮', '᙮'), + ('᛫', '᛭'), + ('᜵', '᜶'), + ('។', '៖'), + ('៚', '៚'), + ('᠂', '᠅'), + ('᠈', '᠉'), + ('᥄', '᥅'), + ('᪨', '᪫'), + ('᭚', '᭛'), + ('᭝', '᭟'), + ('᰻', '᰿'), + ('᱾', '᱿'), + ('‼', '‽'), + ('⁇', '⁉'), + ('⸮', '⸮'), + ('⸼', '⸼'), + ('⹁', '⹁'), + ('⹌', '⹌'), + ('⹎', '\u{2e4f}'), + ('、', '。'), + ('꓾', '꓿'), + ('꘍', '꘏'), + ('꛳', '꛷'), + ('꡶', '꡷'), + ('꣎', '꣏'), + ('꤯', '꤯'), + ('꧇', '꧉'), + ('꩝', '꩟'), + ('꫟', '꫟'), + ('꫰', '꫱'), + ('꯫', '꯫'), + ('﹐', '﹒'), + ('﹔', '﹗'), + ('!', '!'), + (',', ','), + ('.', '.'), + (':', ';'), + ('?', '?'), + ('。', '。'), + ('、', '、'), + ('𐎟', '𐎟'), + ('𐏐', '𐏐'), + ('𐡗', '𐡗'), + ('𐤟', '𐤟'), + ('𐩖', '𐩗'), + ('𐫰', '𐫵'), + ('𐬺', '𐬿'), + ('𐮙', '𐮜'), + ('𐽕', '𐽙'), + ('𑁇', '𑁍'), + ('𑂾', '𑃁'), + ('𑅁', '𑅃'), + ('𑇅', '𑇆'), + ('𑇍', '𑇍'), + ('𑇞', '𑇟'), + ('𑈸', '𑈼'), + ('𑊩', '𑊩'), + ('𑑋', '𑑍'), + ('𑑛', '𑑛'), + ('𑗂', '𑗅'), + ('𑗉', '𑗗'), + ('𑙁', '𑙂'), + ('𑜼', '𑜾'), + ('𑩂', '𑩃'), + ('𑪛', '𑪜'), + ('𑪡', '𑪢'), + ('𑱁', '𑱃'), + ('𑱱', '𑱱'), + ('𑻷', '𑻸'), + ('𒑰', '𒑴'), + ('𖩮', '𖩯'), + ('𖫵', '𖫵'), + ('𖬷', '𖬹'), + ('𖭄', '𖭄'), + ('𖺗', '𖺘'), + ('𛲟', '𛲟'), + ('𝪇', '𝪊'), +]; + +pub const UNIFIED_IDEOGRAPH: &'static [(char, char)] = &[ + ('㐀', '䶵'), + ('一', '鿯'), + ('﨎', '﨏'), + ('﨑', '﨑'), + ('﨓', '﨔'), + ('﨟', '﨟'), + ('﨡', '﨡'), + ('﨣', '﨤'), + ('﨧', '﨩'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), +]; + +pub const UPPERCASE: &'static [(char, char)] = &[ + ('A', 'Z'), + ('À', 'Ö'), + ('Ø', 'Þ'), + ('Ā', 'Ā'), + ('Ă', 'Ă'), + ('Ą', 'Ą'), + ('Ć', 'Ć'), + ('Ĉ', 'Ĉ'), + ('Ċ', 'Ċ'), + ('Č', 'Č'), + ('Ď', 'Ď'), + ('Đ', 'Đ'), + ('Ē', 'Ē'), + ('Ĕ', 'Ĕ'), + ('Ė', 'Ė'), + ('Ę', 'Ę'), + ('Ě', 'Ě'), + ('Ĝ', 'Ĝ'), + ('Ğ', 'Ğ'), + ('Ġ', 'Ġ'), + ('Ģ', 'Ģ'), + ('Ĥ', 'Ĥ'), + ('Ħ', 'Ħ'), + ('Ĩ', 'Ĩ'), + ('Ī', 'Ī'), + ('Ĭ', 'Ĭ'), + ('Į', 'Į'), + ('İ', 'İ'), + ('IJ', 'IJ'), + ('Ĵ', 'Ĵ'), + ('Ķ', 'Ķ'), + ('Ĺ', 'Ĺ'), + ('Ļ', 'Ļ'), + ('Ľ', 'Ľ'), + ('Ŀ', 'Ŀ'), + ('Ł', 'Ł'), + ('Ń', 'Ń'), + ('Ņ', 'Ņ'), + ('Ň', 'Ň'), + ('Ŋ', 'Ŋ'), + ('Ō', 'Ō'), + ('Ŏ', 'Ŏ'), + ('Ő', 'Ő'), + ('Œ', 'Œ'), + ('Ŕ', 'Ŕ'), + ('Ŗ', 'Ŗ'), + ('Ř', 'Ř'), + ('Ś', 'Ś'), + ('Ŝ', 'Ŝ'), + ('Ş', 'Ş'), + ('Š', 'Š'), + ('Ţ', 'Ţ'), + ('Ť', 'Ť'), + ('Ŧ', 'Ŧ'), + ('Ũ', 'Ũ'), + ('Ū', 'Ū'), + ('Ŭ', 'Ŭ'), + ('Ů', 'Ů'), + ('Ű', 'Ű'), + ('Ų', 'Ų'), + ('Ŵ', 'Ŵ'), + ('Ŷ', 'Ŷ'), + ('Ÿ', 'Ź'), + ('Ż', 'Ż'), + ('Ž', 'Ž'), + ('Ɓ', 'Ƃ'), + ('Ƅ', 'Ƅ'), + ('Ɔ', 'Ƈ'), + ('Ɖ', 'Ƌ'), + ('Ǝ', 'Ƒ'), + ('Ɠ', 'Ɣ'), + ('Ɩ', 'Ƙ'), + ('Ɯ', 'Ɲ'), + ('Ɵ', 'Ơ'), + ('Ƣ', 'Ƣ'), + ('Ƥ', 'Ƥ'), + ('Ʀ', 'Ƨ'), + ('Ʃ', 'Ʃ'), + ('Ƭ', 'Ƭ'), + ('Ʈ', 'Ư'), + ('Ʊ', 'Ƴ'), + ('Ƶ', 'Ƶ'), + ('Ʒ', 'Ƹ'), + ('Ƽ', 'Ƽ'), + ('DŽ', 'DŽ'), + ('LJ', 'LJ'), + ('NJ', 'NJ'), + ('Ǎ', 'Ǎ'), + ('Ǐ', 'Ǐ'), + ('Ǒ', 'Ǒ'), + ('Ǔ', 'Ǔ'), + ('Ǖ', 'Ǖ'), + ('Ǘ', 'Ǘ'), + ('Ǚ', 'Ǚ'), + ('Ǜ', 'Ǜ'), + ('Ǟ', 'Ǟ'), + ('Ǡ', 'Ǡ'), + ('Ǣ', 'Ǣ'), + ('Ǥ', 'Ǥ'), + ('Ǧ', 'Ǧ'), + ('Ǩ', 'Ǩ'), + ('Ǫ', 'Ǫ'), + ('Ǭ', 'Ǭ'), + ('Ǯ', 'Ǯ'), + ('DZ', 'DZ'), + ('Ǵ', 'Ǵ'), + ('Ƕ', 'Ǹ'), + ('Ǻ', 'Ǻ'), + ('Ǽ', 'Ǽ'), + ('Ǿ', 'Ǿ'), + ('Ȁ', 'Ȁ'), + ('Ȃ', 'Ȃ'), + ('Ȅ', 'Ȅ'), + ('Ȇ', 'Ȇ'), + ('Ȉ', 'Ȉ'), + ('Ȋ', 'Ȋ'), + ('Ȍ', 'Ȍ'), + ('Ȏ', 'Ȏ'), + ('Ȑ', 'Ȑ'), + ('Ȓ', 'Ȓ'), + ('Ȕ', 'Ȕ'), + ('Ȗ', 'Ȗ'), + ('Ș', 'Ș'), + ('Ț', 'Ț'), + ('Ȝ', 'Ȝ'), + ('Ȟ', 'Ȟ'), + ('Ƞ', 'Ƞ'), + ('Ȣ', 'Ȣ'), + ('Ȥ', 'Ȥ'), + ('Ȧ', 'Ȧ'), + ('Ȩ', 'Ȩ'), + ('Ȫ', 'Ȫ'), + ('Ȭ', 'Ȭ'), + ('Ȯ', 'Ȯ'), + ('Ȱ', 'Ȱ'), + ('Ȳ', 'Ȳ'), + ('Ⱥ', 'Ȼ'), + ('Ƚ', 'Ⱦ'), + ('Ɂ', 'Ɂ'), + ('Ƀ', 'Ɇ'), + ('Ɉ', 'Ɉ'), + ('Ɋ', 'Ɋ'), + ('Ɍ', 'Ɍ'), + ('Ɏ', 'Ɏ'), + ('Ͱ', 'Ͱ'), + ('Ͳ', 'Ͳ'), + ('Ͷ', 'Ͷ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ώ'), + ('Α', 'Ρ'), + ('Σ', 'Ϋ'), + ('Ϗ', 'Ϗ'), + ('ϒ', 'ϔ'), + ('Ϙ', 'Ϙ'), + ('Ϛ', 'Ϛ'), + ('Ϝ', 'Ϝ'), + ('Ϟ', 'Ϟ'), + ('Ϡ', 'Ϡ'), + ('Ϣ', 'Ϣ'), + ('Ϥ', 'Ϥ'), + ('Ϧ', 'Ϧ'), + ('Ϩ', 'Ϩ'), + ('Ϫ', 'Ϫ'), + ('Ϭ', 'Ϭ'), + ('Ϯ', 'Ϯ'), + ('ϴ', 'ϴ'), + ('Ϸ', 'Ϸ'), + ('Ϲ', 'Ϻ'), + ('Ͻ', 'Я'), + ('Ѡ', 'Ѡ'), + ('Ѣ', 'Ѣ'), + ('Ѥ', 'Ѥ'), + ('Ѧ', 'Ѧ'), + ('Ѩ', 'Ѩ'), + ('Ѫ', 'Ѫ'), + ('Ѭ', 'Ѭ'), + ('Ѯ', 'Ѯ'), + ('Ѱ', 'Ѱ'), + ('Ѳ', 'Ѳ'), + ('Ѵ', 'Ѵ'), + ('Ѷ', 'Ѷ'), + ('Ѹ', 'Ѹ'), + ('Ѻ', 'Ѻ'), + ('Ѽ', 'Ѽ'), + ('Ѿ', 'Ѿ'), + ('Ҁ', 'Ҁ'), + ('Ҋ', 'Ҋ'), + ('Ҍ', 'Ҍ'), + ('Ҏ', 'Ҏ'), + ('Ґ', 'Ґ'), + ('Ғ', 'Ғ'), + ('Ҕ', 'Ҕ'), + ('Җ', 'Җ'), + ('Ҙ', 'Ҙ'), + ('Қ', 'Қ'), + ('Ҝ', 'Ҝ'), + ('Ҟ', 'Ҟ'), + ('Ҡ', 'Ҡ'), + ('Ң', 'Ң'), + ('Ҥ', 'Ҥ'), + ('Ҧ', 'Ҧ'), + ('Ҩ', 'Ҩ'), + ('Ҫ', 'Ҫ'), + ('Ҭ', 'Ҭ'), + ('Ү', 'Ү'), + ('Ұ', 'Ұ'), + ('Ҳ', 'Ҳ'), + ('Ҵ', 'Ҵ'), + ('Ҷ', 'Ҷ'), + ('Ҹ', 'Ҹ'), + ('Һ', 'Һ'), + ('Ҽ', 'Ҽ'), + ('Ҿ', 'Ҿ'), + ('Ӏ', 'Ӂ'), + ('Ӄ', 'Ӄ'), + ('Ӆ', 'Ӆ'), + ('Ӈ', 'Ӈ'), + ('Ӊ', 'Ӊ'), + ('Ӌ', 'Ӌ'), + ('Ӎ', 'Ӎ'), + ('Ӑ', 'Ӑ'), + ('Ӓ', 'Ӓ'), + ('Ӕ', 'Ӕ'), + ('Ӗ', 'Ӗ'), + ('Ә', 'Ә'), + ('Ӛ', 'Ӛ'), + ('Ӝ', 'Ӝ'), + ('Ӟ', 'Ӟ'), + ('Ӡ', 'Ӡ'), + ('Ӣ', 'Ӣ'), + ('Ӥ', 'Ӥ'), + ('Ӧ', 'Ӧ'), + ('Ө', 'Ө'), + ('Ӫ', 'Ӫ'), + ('Ӭ', 'Ӭ'), + ('Ӯ', 'Ӯ'), + ('Ӱ', 'Ӱ'), + ('Ӳ', 'Ӳ'), + ('Ӵ', 'Ӵ'), + ('Ӷ', 'Ӷ'), + ('Ӹ', 'Ӹ'), + ('Ӻ', 'Ӻ'), + ('Ӽ', 'Ӽ'), + ('Ӿ', 'Ӿ'), + ('Ԁ', 'Ԁ'), + ('Ԃ', 'Ԃ'), + ('Ԅ', 'Ԅ'), + ('Ԇ', 'Ԇ'), + ('Ԉ', 'Ԉ'), + ('Ԋ', 'Ԋ'), + ('Ԍ', 'Ԍ'), + ('Ԏ', 'Ԏ'), + ('Ԑ', 'Ԑ'), + ('Ԓ', 'Ԓ'), + ('Ԕ', 'Ԕ'), + ('Ԗ', 'Ԗ'), + ('Ԙ', 'Ԙ'), + ('Ԛ', 'Ԛ'), + ('Ԝ', 'Ԝ'), + ('Ԟ', 'Ԟ'), + ('Ԡ', 'Ԡ'), + ('Ԣ', 'Ԣ'), + ('Ԥ', 'Ԥ'), + ('Ԧ', 'Ԧ'), + ('Ԩ', 'Ԩ'), + ('Ԫ', 'Ԫ'), + ('Ԭ', 'Ԭ'), + ('Ԯ', 'Ԯ'), + ('Ա', 'Ֆ'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('Ꭰ', 'Ᏽ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('Ḁ', 'Ḁ'), + ('Ḃ', 'Ḃ'), + ('Ḅ', 'Ḅ'), + ('Ḇ', 'Ḇ'), + ('Ḉ', 'Ḉ'), + ('Ḋ', 'Ḋ'), + ('Ḍ', 'Ḍ'), + ('Ḏ', 'Ḏ'), + ('Ḑ', 'Ḑ'), + ('Ḓ', 'Ḓ'), + ('Ḕ', 'Ḕ'), + ('Ḗ', 'Ḗ'), + ('Ḙ', 'Ḙ'), + ('Ḛ', 'Ḛ'), + ('Ḝ', 'Ḝ'), + ('Ḟ', 'Ḟ'), + ('Ḡ', 'Ḡ'), + ('Ḣ', 'Ḣ'), + ('Ḥ', 'Ḥ'), + ('Ḧ', 'Ḧ'), + ('Ḩ', 'Ḩ'), + ('Ḫ', 'Ḫ'), + ('Ḭ', 'Ḭ'), + ('Ḯ', 'Ḯ'), + ('Ḱ', 'Ḱ'), + ('Ḳ', 'Ḳ'), + ('Ḵ', 'Ḵ'), + ('Ḷ', 'Ḷ'), + ('Ḹ', 'Ḹ'), + ('Ḻ', 'Ḻ'), + ('Ḽ', 'Ḽ'), + ('Ḿ', 'Ḿ'), + ('Ṁ', 'Ṁ'), + ('Ṃ', 'Ṃ'), + ('Ṅ', 'Ṅ'), + ('Ṇ', 'Ṇ'), + ('Ṉ', 'Ṉ'), + ('Ṋ', 'Ṋ'), + ('Ṍ', 'Ṍ'), + ('Ṏ', 'Ṏ'), + ('Ṑ', 'Ṑ'), + ('Ṓ', 'Ṓ'), + ('Ṕ', 'Ṕ'), + ('Ṗ', 'Ṗ'), + ('Ṙ', 'Ṙ'), + ('Ṛ', 'Ṛ'), + ('Ṝ', 'Ṝ'), + ('Ṟ', 'Ṟ'), + ('Ṡ', 'Ṡ'), + ('Ṣ', 'Ṣ'), + ('Ṥ', 'Ṥ'), + ('Ṧ', 'Ṧ'), + ('Ṩ', 'Ṩ'), + ('Ṫ', 'Ṫ'), + ('Ṭ', 'Ṭ'), + ('Ṯ', 'Ṯ'), + ('Ṱ', 'Ṱ'), + ('Ṳ', 'Ṳ'), + ('Ṵ', 'Ṵ'), + ('Ṷ', 'Ṷ'), + ('Ṹ', 'Ṹ'), + ('Ṻ', 'Ṻ'), + ('Ṽ', 'Ṽ'), + ('Ṿ', 'Ṿ'), + ('Ẁ', 'Ẁ'), + ('Ẃ', 'Ẃ'), + ('Ẅ', 'Ẅ'), + ('Ẇ', 'Ẇ'), + ('Ẉ', 'Ẉ'), + ('Ẋ', 'Ẋ'), + ('Ẍ', 'Ẍ'), + ('Ẏ', 'Ẏ'), + ('Ẑ', 'Ẑ'), + ('Ẓ', 'Ẓ'), + ('Ẕ', 'Ẕ'), + ('ẞ', 'ẞ'), + ('Ạ', 'Ạ'), + ('Ả', 'Ả'), + ('Ấ', 'Ấ'), + ('Ầ', 'Ầ'), + ('Ẩ', 'Ẩ'), + ('Ẫ', 'Ẫ'), + ('Ậ', 'Ậ'), + ('Ắ', 'Ắ'), + ('Ằ', 'Ằ'), + ('Ẳ', 'Ẳ'), + ('Ẵ', 'Ẵ'), + ('Ặ', 'Ặ'), + ('Ẹ', 'Ẹ'), + ('Ẻ', 'Ẻ'), + ('Ẽ', 'Ẽ'), + ('Ế', 'Ế'), + ('Ề', 'Ề'), + ('Ể', 'Ể'), + ('Ễ', 'Ễ'), + ('Ệ', 'Ệ'), + ('Ỉ', 'Ỉ'), + ('Ị', 'Ị'), + ('Ọ', 'Ọ'), + ('Ỏ', 'Ỏ'), + ('Ố', 'Ố'), + ('Ồ', 'Ồ'), + ('Ổ', 'Ổ'), + ('Ỗ', 'Ỗ'), + ('Ộ', 'Ộ'), + ('Ớ', 'Ớ'), + ('Ờ', 'Ờ'), + ('Ở', 'Ở'), + ('Ỡ', 'Ỡ'), + ('Ợ', 'Ợ'), + ('Ụ', 'Ụ'), + ('Ủ', 'Ủ'), + ('Ứ', 'Ứ'), + ('Ừ', 'Ừ'), + ('Ử', 'Ử'), + ('Ữ', 'Ữ'), + ('Ự', 'Ự'), + ('Ỳ', 'Ỳ'), + ('Ỵ', 'Ỵ'), + ('Ỷ', 'Ỷ'), + ('Ỹ', 'Ỹ'), + ('Ỻ', 'Ỻ'), + ('Ỽ', 'Ỽ'), + ('Ỿ', 'Ỿ'), + ('Ἀ', 'Ἇ'), + ('Ἐ', 'Ἕ'), + ('Ἠ', 'Ἧ'), + ('Ἰ', 'Ἷ'), + ('Ὀ', 'Ὅ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'Ὗ'), + ('Ὠ', 'Ὧ'), + ('Ᾰ', 'Ά'), + ('Ὲ', 'Ή'), + ('Ῐ', 'Ί'), + ('Ῠ', 'Ῥ'), + ('Ὸ', 'Ώ'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℋ', 'ℍ'), + ('ℐ', 'ℒ'), + ('ℕ', 'ℕ'), + ('ℙ', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℭ'), + ('ℰ', 'ℳ'), + ('ℾ', 'ℿ'), + ('ⅅ', 'ⅅ'), + ('Ⅰ', 'Ⅿ'), + ('Ↄ', 'Ↄ'), + ('Ⓐ', 'Ⓩ'), + ('Ⰰ', 'Ⱞ'), + ('Ⱡ', 'Ⱡ'), + ('Ɫ', 'Ɽ'), + ('Ⱨ', 'Ⱨ'), + ('Ⱪ', 'Ⱪ'), + ('Ⱬ', 'Ⱬ'), + ('Ɑ', 'Ɒ'), + ('Ⱳ', 'Ⱳ'), + ('Ⱶ', 'Ⱶ'), + ('Ȿ', 'Ⲁ'), + ('Ⲃ', 'Ⲃ'), + ('Ⲅ', 'Ⲅ'), + ('Ⲇ', 'Ⲇ'), + ('Ⲉ', 'Ⲉ'), + ('Ⲋ', 'Ⲋ'), + ('Ⲍ', 'Ⲍ'), + ('Ⲏ', 'Ⲏ'), + ('Ⲑ', 'Ⲑ'), + ('Ⲓ', 'Ⲓ'), + ('Ⲕ', 'Ⲕ'), + ('Ⲗ', 'Ⲗ'), + ('Ⲙ', 'Ⲙ'), + ('Ⲛ', 'Ⲛ'), + ('Ⲝ', 'Ⲝ'), + ('Ⲟ', 'Ⲟ'), + ('Ⲡ', 'Ⲡ'), + ('Ⲣ', 'Ⲣ'), + ('Ⲥ', 'Ⲥ'), + ('Ⲧ', 'Ⲧ'), + ('Ⲩ', 'Ⲩ'), + ('Ⲫ', 'Ⲫ'), + ('Ⲭ', 'Ⲭ'), + ('Ⲯ', 'Ⲯ'), + ('Ⲱ', 'Ⲱ'), + ('Ⲳ', 'Ⲳ'), + ('Ⲵ', 'Ⲵ'), + ('Ⲷ', 'Ⲷ'), + ('Ⲹ', 'Ⲹ'), + ('Ⲻ', 'Ⲻ'), + ('Ⲽ', 'Ⲽ'), + ('Ⲿ', 'Ⲿ'), + ('Ⳁ', 'Ⳁ'), + ('Ⳃ', 'Ⳃ'), + ('Ⳅ', 'Ⳅ'), + ('Ⳇ', 'Ⳇ'), + ('Ⳉ', 'Ⳉ'), + ('Ⳋ', 'Ⳋ'), + ('Ⳍ', 'Ⳍ'), + ('Ⳏ', 'Ⳏ'), + ('Ⳑ', 'Ⳑ'), + ('Ⳓ', 'Ⳓ'), + ('Ⳕ', 'Ⳕ'), + ('Ⳗ', 'Ⳗ'), + ('Ⳙ', 'Ⳙ'), + ('Ⳛ', 'Ⳛ'), + ('Ⳝ', 'Ⳝ'), + ('Ⳟ', 'Ⳟ'), + ('Ⳡ', 'Ⳡ'), + ('Ⳣ', 'Ⳣ'), + ('Ⳬ', 'Ⳬ'), + ('Ⳮ', 'Ⳮ'), + ('Ⳳ', 'Ⳳ'), + ('Ꙁ', 'Ꙁ'), + ('Ꙃ', 'Ꙃ'), + ('Ꙅ', 'Ꙅ'), + ('Ꙇ', 'Ꙇ'), + ('Ꙉ', 'Ꙉ'), + ('Ꙋ', 'Ꙋ'), + ('Ꙍ', 'Ꙍ'), + ('Ꙏ', 'Ꙏ'), + ('Ꙑ', 'Ꙑ'), + ('Ꙓ', 'Ꙓ'), + ('Ꙕ', 'Ꙕ'), + ('Ꙗ', 'Ꙗ'), + ('Ꙙ', 'Ꙙ'), + ('Ꙛ', 'Ꙛ'), + ('Ꙝ', 'Ꙝ'), + ('Ꙟ', 'Ꙟ'), + ('Ꙡ', 'Ꙡ'), + ('Ꙣ', 'Ꙣ'), + ('Ꙥ', 'Ꙥ'), + ('Ꙧ', 'Ꙧ'), + ('Ꙩ', 'Ꙩ'), + ('Ꙫ', 'Ꙫ'), + ('Ꙭ', 'Ꙭ'), + ('Ꚁ', 'Ꚁ'), + ('Ꚃ', 'Ꚃ'), + ('Ꚅ', 'Ꚅ'), + ('Ꚇ', 'Ꚇ'), + ('Ꚉ', 'Ꚉ'), + ('Ꚋ', 'Ꚋ'), + ('Ꚍ', 'Ꚍ'), + ('Ꚏ', 'Ꚏ'), + ('Ꚑ', 'Ꚑ'), + ('Ꚓ', 'Ꚓ'), + ('Ꚕ', 'Ꚕ'), + ('Ꚗ', 'Ꚗ'), + ('Ꚙ', 'Ꚙ'), + ('Ꚛ', 'Ꚛ'), + ('Ꜣ', 'Ꜣ'), + ('Ꜥ', 'Ꜥ'), + ('Ꜧ', 'Ꜧ'), + ('Ꜩ', 'Ꜩ'), + ('Ꜫ', 'Ꜫ'), + ('Ꜭ', 'Ꜭ'), + ('Ꜯ', 'Ꜯ'), + ('Ꜳ', 'Ꜳ'), + ('Ꜵ', 'Ꜵ'), + ('Ꜷ', 'Ꜷ'), + ('Ꜹ', 'Ꜹ'), + ('Ꜻ', 'Ꜻ'), + ('Ꜽ', 'Ꜽ'), + ('Ꜿ', 'Ꜿ'), + ('Ꝁ', 'Ꝁ'), + ('Ꝃ', 'Ꝃ'), + ('Ꝅ', 'Ꝅ'), + ('Ꝇ', 'Ꝇ'), + ('Ꝉ', 'Ꝉ'), + ('Ꝋ', 'Ꝋ'), + ('Ꝍ', 'Ꝍ'), + ('Ꝏ', 'Ꝏ'), + ('Ꝑ', 'Ꝑ'), + ('Ꝓ', 'Ꝓ'), + ('Ꝕ', 'Ꝕ'), + ('Ꝗ', 'Ꝗ'), + ('Ꝙ', 'Ꝙ'), + ('Ꝛ', 'Ꝛ'), + ('Ꝝ', 'Ꝝ'), + ('Ꝟ', 'Ꝟ'), + ('Ꝡ', 'Ꝡ'), + ('Ꝣ', 'Ꝣ'), + ('Ꝥ', 'Ꝥ'), + ('Ꝧ', 'Ꝧ'), + ('Ꝩ', 'Ꝩ'), + ('Ꝫ', 'Ꝫ'), + ('Ꝭ', 'Ꝭ'), + ('Ꝯ', 'Ꝯ'), + ('Ꝺ', 'Ꝺ'), + ('Ꝼ', 'Ꝼ'), + ('Ᵹ', 'Ꝿ'), + ('Ꞁ', 'Ꞁ'), + ('Ꞃ', 'Ꞃ'), + ('Ꞅ', 'Ꞅ'), + ('Ꞇ', 'Ꞇ'), + ('Ꞌ', 'Ꞌ'), + ('Ɥ', 'Ɥ'), + ('Ꞑ', 'Ꞑ'), + ('Ꞓ', 'Ꞓ'), + ('Ꞗ', 'Ꞗ'), + ('Ꞙ', 'Ꞙ'), + ('Ꞛ', 'Ꞛ'), + ('Ꞝ', 'Ꞝ'), + ('Ꞟ', 'Ꞟ'), + ('Ꞡ', 'Ꞡ'), + ('Ꞣ', 'Ꞣ'), + ('Ꞥ', 'Ꞥ'), + ('Ꞧ', 'Ꞧ'), + ('Ꞩ', 'Ꞩ'), + ('Ɦ', 'Ɪ'), + ('Ʞ', 'Ꞵ'), + ('Ꞷ', 'Ꞷ'), + ('Ꞹ', 'Ꞹ'), + ('\u{a7ba}', '\u{a7ba}'), + ('\u{a7bc}', '\u{a7bc}'), + ('\u{a7be}', '\u{a7be}'), + ('\u{a7c2}', '\u{a7c2}'), + ('\u{a7c4}', '\u{a7c6}'), + ('A', 'Z'), + ('𐐀', '𐐧'), + ('𐒰', '𐓓'), + ('𐲀', '𐲲'), + ('𑢠', '𑢿'), + ('𖹀', '𖹟'), + ('𝐀', '𝐙'), + ('𝐴', '𝑍'), + ('𝑨', '𝒁'), + ('𝒜', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒵'), + ('𝓐', '𝓩'), + ('𝔄', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔸', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕬', '𝖅'), + ('𝖠', '𝖹'), + ('𝗔', '𝗭'), + ('𝘈', '𝘡'), + ('𝘼', '𝙕'), + ('𝙰', '𝚉'), + ('𝚨', '𝛀'), + ('𝛢', '𝛺'), + ('𝜜', '𝜴'), + ('𝝖', '𝝮'), + ('𝞐', '𝞨'), + ('𝟊', '𝟊'), + ('𞤀', '𞤡'), + ('🄰', '🅉'), + ('🅐', '🅩'), + ('🅰', '🆉'), +]; + +pub const VARIATION_SELECTOR: &'static [(char, char)] = &[ + ('\u{180b}', '\u{180d}'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const WHITE_SPACE: &'static [(char, char)] = &[ + ('\t', '\r'), + (' ', ' '), + ('\u{85}', '\u{85}'), + ('\u{a0}', '\u{a0}'), + ('\u{1680}', '\u{1680}'), + ('\u{2000}', '\u{200a}'), + ('\u{2028}', '\u{2029}'), + ('\u{202f}', '\u{202f}'), + ('\u{205f}', '\u{205f}'), + ('\u{3000}', '\u{3000}'), +]; + +pub const XID_CONTINUE: &'static [(char, char)] = &[ + ('0', '9'), + ('A', 'Z'), + ('_', '_'), + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('·', '·'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ˁ'), + ('ˆ', 'ˑ'), + ('ˠ', 'ˤ'), + ('ˬ', 'ˬ'), + ('ˮ', 'ˮ'), + ('\u{300}', 'ʹ'), + ('Ͷ', 'ͷ'), + ('ͻ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϵ'), + ('Ϸ', 'ҁ'), + ('\u{483}', '\u{487}'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՙ', 'ՙ'), + ('ՠ', 'ֈ'), + ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('א', 'ת'), + ('ׯ', 'ײ'), + ('\u{610}', '\u{61a}'), + ('ؠ', '٩'), + ('ٮ', 'ۓ'), + ('ە', '\u{6dc}'), + ('\u{6df}', '\u{6e8}'), + ('\u{6ea}', 'ۼ'), + ('ۿ', 'ۿ'), + ('ܐ', '\u{74a}'), + ('ݍ', 'ޱ'), + ('߀', 'ߵ'), + ('ߺ', 'ߺ'), + ('\u{7fd}', '\u{7fd}'), + ('ࠀ', '\u{82d}'), + ('ࡀ', '\u{85b}'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', '\u{963}'), + ('०', '९'), + ('ॱ', 'ঃ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('\u{9bc}', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', 'ৎ'), + ('\u{9d7}', '\u{9d7}'), + ('ড়', 'ঢ়'), + ('য়', '\u{9e3}'), + ('০', 'ৱ'), + ('ৼ', 'ৼ'), + ('\u{9fe}', '\u{9fe}'), + ('\u{a01}', 'ਃ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('\u{a3c}', '\u{a3c}'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('੦', '\u{a75}'), + ('\u{a81}', 'ઃ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('\u{abc}', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', '\u{acd}'), + ('ૐ', 'ૐ'), + ('ૠ', '\u{ae3}'), + ('૦', '૯'), + ('ૹ', '\u{aff}'), + ('\u{b01}', 'ଃ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('\u{b3c}', '\u{b44}'), + ('େ', 'ୈ'), + ('ୋ', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', '\u{b63}'), + ('୦', '୯'), + ('ୱ', 'ୱ'), + ('\u{b82}', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', '\u{bcd}'), + ('ௐ', 'ௐ'), + ('\u{bd7}', '\u{bd7}'), + ('௦', '௯'), + ('\u{c00}', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('ౘ', 'ౚ'), + ('ౠ', '\u{c63}'), + ('౦', '౯'), + ('ಀ', 'ಃ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('\u{cbc}', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('ೞ', 'ೞ'), + ('ೠ', '\u{ce3}'), + ('೦', '೯'), + ('ೱ', 'ೲ'), + ('\u{d00}', 'ഃ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', '\u{d44}'), + ('െ', 'ൈ'), + ('ൊ', 'ൎ'), + ('ൔ', '\u{d57}'), + ('ൟ', '\u{d63}'), + ('൦', '൯'), + ('ൺ', 'ൿ'), + ('ං', 'ඃ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('෦', '෯'), + ('ෲ', 'ෳ'), + ('ก', '\u{e3a}'), + ('เ', '\u{e4e}'), + ('๐', '๙'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('\u{ec8}', '\u{ecd}'), + ('໐', '໙'), + ('ໜ', 'ໟ'), + ('ༀ', 'ༀ'), + ('\u{f18}', '\u{f19}'), + ('༠', '༩'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('༾', 'ཇ'), + ('ཉ', 'ཬ'), + ('\u{f71}', '\u{f84}'), + ('\u{f86}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), + ('က', '၉'), + ('ၐ', '\u{109d}'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჼ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('\u{135d}', '\u{135f}'), + ('፩', '፱'), + ('ᎀ', 'ᎏ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᐁ', 'ᙬ'), + ('ᙯ', 'ᙿ'), + ('ᚁ', 'ᚚ'), + ('ᚠ', 'ᛪ'), + ('ᛮ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', '\u{1714}'), + ('ᜠ', '\u{1734}'), + ('ᝀ', '\u{1753}'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('\u{1772}', '\u{1773}'), + ('ក', '\u{17d3}'), + ('ៗ', 'ៗ'), + ('ៜ', '\u{17dd}'), + ('០', '៩'), + ('\u{180b}', '\u{180d}'), + ('᠐', '᠙'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', '\u{193b}'), + ('᥆', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('ᦀ', 'ᦫ'), + ('ᦰ', 'ᧉ'), + ('᧐', '᧚'), + ('ᨀ', '\u{1a1b}'), + ('ᨠ', '\u{1a5e}'), + ('\u{1a60}', '\u{1a7c}'), + ('\u{1a7f}', '᪉'), + ('᪐', '᪙'), + ('ᪧ', 'ᪧ'), + ('\u{1ab0}', '\u{1abd}'), + ('\u{1b00}', 'ᭋ'), + ('᭐', '᭙'), + ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', '᯳'), + ('ᰀ', '\u{1c37}'), + ('᱀', '᱉'), + ('ᱍ', 'ᱽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1cfa}'), + ('ᴀ', '\u{1df9}'), + ('\u{1dfb}', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('‿', '⁀'), + ('⁔', '⁔'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('\u{20d0}', '\u{20dc}'), + ('\u{20e1}', '\u{20e1}'), + ('\u{20e5}', '\u{20f0}'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('℘', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℹ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ↈ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⳤ'), + ('Ⳬ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ⴰ', 'ⵧ'), + ('ⵯ', 'ⵯ'), + ('\u{2d7f}', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('\u{2de0}', '\u{2dff}'), + ('々', '〇'), + ('〡', '\u{302f}'), + ('〱', '〵'), + ('〸', '〼'), + ('ぁ', 'ゖ'), + ('\u{3099}', '\u{309a}'), + ('ゝ', 'ゟ'), + ('ァ', 'ヺ'), + ('ー', 'ヿ'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('ㆠ', 'ㆺ'), + ('ㇰ', 'ㇿ'), + ('㐀', '䶵'), + ('一', '鿯'), + ('ꀀ', 'ꒌ'), + ('ꓐ', 'ꓽ'), + ('ꔀ', 'ꘌ'), + ('ꘐ', 'ꘫ'), + ('Ꙁ', '\u{a66f}'), + ('\u{a674}', '\u{a67d}'), + ('ꙿ', '\u{a6f1}'), + ('ꜗ', 'ꜟ'), + ('Ꜣ', 'ꞈ'), + ('Ꞌ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꠧ'), + ('ꡀ', 'ꡳ'), + ('ꢀ', '\u{a8c5}'), + ('꣐', '꣙'), + ('\u{a8e0}', 'ꣷ'), + ('ꣻ', 'ꣻ'), + ('ꣽ', '\u{a92d}'), + ('ꤰ', '꥓'), + ('ꥠ', 'ꥼ'), + ('\u{a980}', '꧀'), + ('ꧏ', '꧙'), + ('ꧠ', 'ꧾ'), + ('ꨀ', '\u{aa36}'), + ('ꩀ', 'ꩍ'), + ('꩐', '꩙'), + ('ꩠ', 'ꩶ'), + ('ꩺ', 'ꫂ'), + ('ꫛ', 'ꫝ'), + ('ꫠ', 'ꫯ'), + ('ꫲ', '\u{aaf6}'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', '\u{ab67}'), + ('ꭰ', 'ꯪ'), + ('꯬', '\u{abed}'), + ('꯰', '꯹'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('豈', '舘'), + ('並', '龎'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('יִ', 'ﬨ'), + ('שׁ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﮱ'), + ('ﯓ', 'ﱝ'), + ('ﱤ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷹ'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2f}'), + ('︳', '︴'), + ('﹍', '﹏'), + ('ﹱ', 'ﹱ'), + ('ﹳ', 'ﹳ'), + ('ﹷ', 'ﹷ'), + ('ﹹ', 'ﹹ'), + ('ﹻ', 'ﹻ'), + ('ﹽ', 'ﹽ'), + ('ﹿ', 'ﻼ'), + ('0', '9'), + ('A', 'Z'), + ('_', '_'), + ('a', 'z'), + ('ヲ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐅀', '𐅴'), + ('\u{101fd}', '\u{101fd}'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('\u{102e0}', '\u{102e0}'), + ('𐌀', '𐌟'), + ('𐌭', '𐍊'), + ('𐍐', '\u{1037a}'), + ('𐎀', '𐎝'), + ('𐎠', '𐏃'), + ('𐏈', '𐏏'), + ('𐏑', '𐏕'), + ('𐐀', '𐒝'), + ('𐒠', '𐒩'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡠', '𐡶'), + ('𐢀', '𐢞'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐤀', '𐤕'), + ('𐤠', '𐤹'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𐨀', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), + ('𐩠', '𐩼'), + ('𐪀', '𐪜'), + ('𐫀', '𐫇'), + ('𐫉', '\u{10ae6}'), + ('𐬀', '𐬵'), + ('𐭀', '𐭕'), + ('𐭠', '𐭲'), + ('𐮀', '𐮑'), + ('𐰀', '𐱈'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𐴀', '\u{10d27}'), + ('𐴰', '𐴹'), + ('𐼀', '𐼜'), + ('𐼧', '𐼧'), + ('𐼰', '\u{10f50}'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀀', '\u{11046}'), + ('𑁦', '𑁯'), + ('\u{1107f}', '\u{110ba}'), + ('𑃐', '𑃨'), + ('𑃰', '𑃹'), + ('\u{11100}', '\u{11134}'), + ('𑄶', '𑄿'), + ('𑅄', '𑅆'), + ('𑅐', '\u{11173}'), + ('𑅶', '𑅶'), + ('\u{11180}', '𑇄'), + ('\u{111c9}', '\u{111cc}'), + ('𑇐', '𑇚'), + ('𑇜', '𑇜'), + ('𑈀', '𑈑'), + ('𑈓', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊨'), + ('𑊰', '\u{112ea}'), + ('𑋰', '𑋹'), + ('\u{11300}', '𑌃'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('\u{1133b}', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('𑍐', '𑍐'), + ('\u{11357}', '\u{11357}'), + ('𑍝', '𑍣'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('𑐀', '𑑊'), + ('𑑐', '𑑙'), + ('\u{1145e}', '\u{1145f}'), + ('𑒀', '𑓅'), + ('𑓇', '𑓇'), + ('𑓐', '𑓙'), + ('𑖀', '\u{115b5}'), + ('𑖸', '\u{115c0}'), + ('𑗘', '\u{115dd}'), + ('𑘀', '\u{11640}'), + ('𑙄', '𑙄'), + ('𑙐', '𑙙'), + ('𑚀', '\u{116b8}'), + ('𑛀', '𑛉'), + ('𑜀', '𑜚'), + ('\u{1171d}', '\u{1172b}'), + ('𑜰', '𑜹'), + ('𑠀', '\u{1183a}'), + ('𑢠', '𑣩'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d7}'), + ('\u{119da}', '\u{119e1}'), + ('\u{119e3}', '\u{119e4}'), + ('𑨀', '\u{11a3e}'), + ('\u{11a47}', '\u{11a47}'), + ('𑩐', '\u{11a99}'), + ('𑪝', '𑪝'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '\u{11c36}'), + ('\u{11c38}', '𑱀'), + ('𑱐', '𑱙'), + ('𑱲', '𑲏'), + ('\u{11c92}', '\u{11ca7}'), + ('𑲩', '\u{11cb6}'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d47}'), + ('𑵐', '𑵙'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '𑶘'), + ('𑶠', '𑶩'), + ('𑻠', '𑻶'), + ('𒀀', '𒎙'), + ('𒐀', '𒑮'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖩠', '𖩩'), + ('𖫐', '𖫭'), + ('\u{16af0}', '\u{16af4}'), + ('𖬀', '\u{16b36}'), + ('𖭀', '𖭃'), + ('𖭐', '𖭙'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖹀', '𖹿'), + ('𖼀', '\u{16f4a}'), + ('\u{16f4f}', '\u{16f87}'), + ('\u{16f8f}', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛀀', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('𛅰', '𛋻'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d165}', '\u{1d169}'), + ('𝅭', '\u{1d172}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1d242}', '\u{1d244}'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('𝟎', '𝟿'), + ('\u{1da00}', '\u{1da36}'), + ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), + ('\u{1da84}', '\u{1da84}'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e130}', '\u{1e13d}'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e14e}', '\u{1e14e}'), + ('\u{1e2c0}', '\u{1e2f9}'), + ('𞠀', '𞣄'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('𞤀', '\u{1e94b}'), + ('𞥐', '𞥙'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const XID_START: &'static [(char, char)] = &[ + ('A', 'Z'), + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ˁ'), + ('ˆ', 'ˑ'), + ('ˠ', 'ˤ'), + ('ˬ', 'ˬ'), + ('ˮ', 'ˮ'), + ('Ͱ', 'ʹ'), + ('Ͷ', 'ͷ'), + ('ͻ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϵ'), + ('Ϸ', 'ҁ'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՙ', 'ՙ'), + ('ՠ', 'ֈ'), + ('א', 'ת'), + ('ׯ', 'ײ'), + ('ؠ', 'ي'), + ('ٮ', 'ٯ'), + ('ٱ', 'ۓ'), + ('ە', 'ە'), + ('ۥ', 'ۦ'), + ('ۮ', 'ۯ'), + ('ۺ', 'ۼ'), + ('ۿ', 'ۿ'), + ('ܐ', 'ܐ'), + ('ܒ', 'ܯ'), + ('ݍ', 'ޥ'), + ('ޱ', 'ޱ'), + ('ߊ', 'ߪ'), + ('ߴ', 'ߵ'), + ('ߺ', 'ߺ'), + ('ࠀ', 'ࠕ'), + ('ࠚ', 'ࠚ'), + ('ࠤ', 'ࠤ'), + ('ࠨ', 'ࠨ'), + ('ࡀ', 'ࡘ'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('ऄ', 'ह'), + ('ऽ', 'ऽ'), + ('ॐ', 'ॐ'), + ('क़', 'ॡ'), + ('ॱ', 'ঀ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('ঽ', 'ঽ'), + ('ৎ', 'ৎ'), + ('ড়', 'ঢ়'), + ('য়', 'ৡ'), + ('ৰ', 'ৱ'), + ('ৼ', 'ৼ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('ੲ', 'ੴ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('ઽ', 'ઽ'), + ('ૐ', 'ૐ'), + ('ૠ', 'ૡ'), + ('ૹ', 'ૹ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('ଽ', 'ଽ'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', 'ୡ'), + ('ୱ', 'ୱ'), + ('ஃ', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('ௐ', 'ௐ'), + ('అ', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ఽ'), + ('ౘ', 'ౚ'), + ('ౠ', 'ౡ'), + ('ಀ', 'ಀ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('ಽ', 'ಽ'), + ('ೞ', 'ೞ'), + ('ೠ', 'ೡ'), + ('ೱ', 'ೲ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', 'ഺ'), + ('ഽ', 'ഽ'), + ('ൎ', 'ൎ'), + ('ൔ', 'ൖ'), + ('ൟ', 'ൡ'), + ('ൺ', 'ൿ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('ก', 'ะ'), + ('า', 'า'), + ('เ', 'ๆ'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ະ'), + ('າ', 'າ'), + ('ຽ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('ໜ', 'ໟ'), + ('ༀ', 'ༀ'), + ('ཀ', 'ཇ'), + ('ཉ', 'ཬ'), + ('ྈ', 'ྌ'), + ('က', 'ဪ'), + ('ဿ', 'ဿ'), + ('ၐ', 'ၕ'), + ('ၚ', 'ၝ'), + ('ၡ', 'ၡ'), + ('ၥ', 'ၦ'), + ('ၮ', 'ၰ'), + ('ၵ', 'ႁ'), + ('ႎ', 'ႎ'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჼ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('ᎀ', 'ᎏ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᐁ', 'ᙬ'), + ('ᙯ', 'ᙿ'), + ('ᚁ', 'ᚚ'), + ('ᚠ', 'ᛪ'), + ('ᛮ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', 'ᜑ'), + ('ᜠ', 'ᜱ'), + ('ᝀ', 'ᝑ'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('ក', 'ឳ'), + ('ៗ', 'ៗ'), + ('ៜ', 'ៜ'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢨ'), + ('ᢪ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('ᥐ', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('ᦀ', 'ᦫ'), + ('ᦰ', 'ᧉ'), + ('ᨀ', 'ᨖ'), + ('ᨠ', 'ᩔ'), + ('ᪧ', 'ᪧ'), + ('ᬅ', 'ᬳ'), + ('ᭅ', 'ᭋ'), + ('ᮃ', 'ᮠ'), + ('ᮮ', 'ᮯ'), + ('ᮺ', 'ᯥ'), + ('ᰀ', 'ᰣ'), + ('ᱍ', 'ᱏ'), + ('ᱚ', 'ᱽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ᳩ', 'ᳬ'), + ('ᳮ', 'ᳳ'), + ('ᳵ', 'ᳶ'), + ('\u{1cfa}', '\u{1cfa}'), + ('ᴀ', 'ᶿ'), + ('Ḁ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('℘', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℹ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ↈ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⳤ'), + ('Ⳬ', 'ⳮ'), + ('Ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ⴰ', 'ⵧ'), + ('ⵯ', 'ⵯ'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('々', '〇'), + ('〡', '〩'), + ('〱', '〵'), + ('〸', '〼'), + ('ぁ', 'ゖ'), + ('ゝ', 'ゟ'), + ('ァ', 'ヺ'), + ('ー', 'ヿ'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('ㆠ', 'ㆺ'), + ('ㇰ', 'ㇿ'), + ('㐀', '䶵'), + ('一', '鿯'), + ('ꀀ', 'ꒌ'), + ('ꓐ', 'ꓽ'), + ('ꔀ', 'ꘌ'), + ('ꘐ', 'ꘟ'), + ('ꘪ', 'ꘫ'), + ('Ꙁ', 'ꙮ'), + ('ꙿ', 'ꚝ'), + ('ꚠ', 'ꛯ'), + ('ꜗ', 'ꜟ'), + ('Ꜣ', 'ꞈ'), + ('Ꞌ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꠁ'), + ('ꠃ', 'ꠅ'), + ('ꠇ', 'ꠊ'), + ('ꠌ', 'ꠢ'), + ('ꡀ', 'ꡳ'), + ('ꢂ', 'ꢳ'), + ('ꣲ', 'ꣷ'), + ('ꣻ', 'ꣻ'), + ('ꣽ', 'ꣾ'), + ('ꤊ', 'ꤥ'), + ('ꤰ', 'ꥆ'), + ('ꥠ', 'ꥼ'), + ('ꦄ', 'ꦲ'), + ('ꧏ', 'ꧏ'), + ('ꧠ', 'ꧤ'), + ('ꧦ', 'ꧯ'), + ('ꧺ', 'ꧾ'), + ('ꨀ', 'ꨨ'), + ('ꩀ', 'ꩂ'), + ('ꩄ', 'ꩋ'), + ('ꩠ', 'ꩶ'), + ('ꩺ', 'ꩺ'), + ('ꩾ', 'ꪯ'), + ('ꪱ', 'ꪱ'), + ('ꪵ', 'ꪶ'), + ('ꪹ', 'ꪽ'), + ('ꫀ', 'ꫀ'), + ('ꫂ', 'ꫂ'), + ('ꫛ', 'ꫝ'), + ('ꫠ', 'ꫪ'), + ('ꫲ', 'ꫴ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', '\u{ab67}'), + ('ꭰ', 'ꯢ'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('豈', '舘'), + ('並', '龎'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('יִ', 'יִ'), + ('ײַ', 'ﬨ'), + ('שׁ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﮱ'), + ('ﯓ', 'ﱝ'), + ('ﱤ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷹ'), + ('ﹱ', 'ﹱ'), + ('ﹳ', 'ﹳ'), + ('ﹷ', 'ﹷ'), + ('ﹹ', 'ﹹ'), + ('ﹻ', 'ﹻ'), + ('ﹽ', 'ﹽ'), + ('ﹿ', 'ﻼ'), + ('A', 'Z'), + ('a', 'z'), + ('ヲ', 'ン'), + ('ᅠ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐅀', '𐅴'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('𐌀', '𐌟'), + ('𐌭', '𐍊'), + ('𐍐', '𐍵'), + ('𐎀', '𐎝'), + ('𐎠', '𐏃'), + ('𐏈', '𐏏'), + ('𐏑', '𐏕'), + ('𐐀', '𐒝'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡠', '𐡶'), + ('𐢀', '𐢞'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐤀', '𐤕'), + ('𐤠', '𐤹'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𐨀', '𐨀'), + ('𐨐', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('𐩠', '𐩼'), + ('𐪀', '𐪜'), + ('𐫀', '𐫇'), + ('𐫉', '𐫤'), + ('𐬀', '𐬵'), + ('𐭀', '𐭕'), + ('𐭠', '𐭲'), + ('𐮀', '𐮑'), + ('𐰀', '𐱈'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𐴀', '𐴣'), + ('𐼀', '𐼜'), + ('𐼧', '𐼧'), + ('𐼰', '𐽅'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀃', '𑀷'), + ('𑂃', '𑂯'), + ('𑃐', '𑃨'), + ('𑄃', '𑄦'), + ('𑅄', '𑅄'), + ('𑅐', '𑅲'), + ('𑅶', '𑅶'), + ('𑆃', '𑆲'), + ('𑇁', '𑇄'), + ('𑇚', '𑇚'), + ('𑇜', '𑇜'), + ('𑈀', '𑈑'), + ('𑈓', '𑈫'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊨'), + ('𑊰', '𑋞'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('𑌽', '𑌽'), + ('𑍐', '𑍐'), + ('𑍝', '𑍡'), + ('𑐀', '𑐴'), + ('𑑇', '𑑊'), + ('\u{1145f}', '\u{1145f}'), + ('𑒀', '𑒯'), + ('𑓄', '𑓅'), + ('𑓇', '𑓇'), + ('𑖀', '𑖮'), + ('𑗘', '𑗛'), + ('𑘀', '𑘯'), + ('𑙄', '𑙄'), + ('𑚀', '𑚪'), + ('\u{116b8}', '\u{116b8}'), + ('𑜀', '𑜚'), + ('𑠀', '𑠫'), + ('𑢠', '𑣟'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d0}'), + ('\u{119e1}', '\u{119e1}'), + ('\u{119e3}', '\u{119e3}'), + ('𑨀', '𑨀'), + ('𑨋', '𑨲'), + ('𑨺', '𑨺'), + ('𑩐', '𑩐'), + ('𑩜', '𑪉'), + ('𑪝', '𑪝'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '𑰮'), + ('𑱀', '𑱀'), + ('𑱲', '𑲏'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '𑴰'), + ('𑵆', '𑵆'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶉'), + ('𑶘', '𑶘'), + ('𑻠', '𑻲'), + ('𒀀', '𒎙'), + ('𒐀', '𒑮'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖫐', '𖫭'), + ('𖬀', '𖬯'), + ('𖭀', '𖭃'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖹀', '𖹿'), + ('𖼀', '\u{16f4a}'), + ('𖽐', '𖽐'), + ('𖾓', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛀀', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('𛅰', '𛋻'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e137}', '\u{1e13d}'), + ('\u{1e14e}', '\u{1e14e}'), + ('\u{1e2c0}', '\u{1e2eb}'), + ('𞠀', '𞣄'), + ('𞤀', '𞥃'), + ('\u{1e94b}', '\u{1e94b}'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), +]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/property_names.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/property_names.rs new file mode 100644 index 0000000..1064b61 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/property_names.rs @@ -0,0 +1,253 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate property-names /tmp/ucd/12.1.0/ +// +// ucd-generate is available on crates.io. + +pub const PROPERTY_NAMES: &'static [(&'static str, &'static str)] = &[ + ("age", "Age"), + ("ahex", "ASCII_Hex_Digit"), + ("alpha", "Alphabetic"), + ("alphabetic", "Alphabetic"), + ("asciihexdigit", "ASCII_Hex_Digit"), + ("bc", "Bidi_Class"), + ("bidic", "Bidi_Control"), + ("bidiclass", "Bidi_Class"), + ("bidicontrol", "Bidi_Control"), + ("bidim", "Bidi_Mirrored"), + ("bidimirrored", "Bidi_Mirrored"), + ("bidimirroringglyph", "Bidi_Mirroring_Glyph"), + ("bidipairedbracket", "Bidi_Paired_Bracket"), + ("bidipairedbrackettype", "Bidi_Paired_Bracket_Type"), + ("blk", "Block"), + ("block", "Block"), + ("bmg", "Bidi_Mirroring_Glyph"), + ("bpb", "Bidi_Paired_Bracket"), + ("bpt", "Bidi_Paired_Bracket_Type"), + ("canonicalcombiningclass", "Canonical_Combining_Class"), + ("cased", "Cased"), + ("casefolding", "Case_Folding"), + ("caseignorable", "Case_Ignorable"), + ("ccc", "Canonical_Combining_Class"), + ("ce", "Composition_Exclusion"), + ("cf", "Case_Folding"), + ("changeswhencasefolded", "Changes_When_Casefolded"), + ("changeswhencasemapped", "Changes_When_Casemapped"), + ("changeswhenlowercased", "Changes_When_Lowercased"), + ("changeswhennfkccasefolded", "Changes_When_NFKC_Casefolded"), + ("changeswhentitlecased", "Changes_When_Titlecased"), + ("changeswhenuppercased", "Changes_When_Uppercased"), + ("ci", "Case_Ignorable"), + ("cjkaccountingnumeric", "kAccountingNumeric"), + ("cjkcompatibilityvariant", "kCompatibilityVariant"), + ("cjkiicore", "kIICore"), + ("cjkirggsource", "kIRG_GSource"), + ("cjkirghsource", "kIRG_HSource"), + ("cjkirgjsource", "kIRG_JSource"), + ("cjkirgkpsource", "kIRG_KPSource"), + ("cjkirgksource", "kIRG_KSource"), + ("cjkirgmsource", "kIRG_MSource"), + ("cjkirgtsource", "kIRG_TSource"), + ("cjkirgusource", "kIRG_USource"), + ("cjkirgvsource", "kIRG_VSource"), + ("cjkothernumeric", "kOtherNumeric"), + ("cjkprimarynumeric", "kPrimaryNumeric"), + ("cjkrsunicode", "kRSUnicode"), + ("compex", "Full_Composition_Exclusion"), + ("compositionexclusion", "Composition_Exclusion"), + ("cwcf", "Changes_When_Casefolded"), + ("cwcm", "Changes_When_Casemapped"), + ("cwkcf", "Changes_When_NFKC_Casefolded"), + ("cwl", "Changes_When_Lowercased"), + ("cwt", "Changes_When_Titlecased"), + ("cwu", "Changes_When_Uppercased"), + ("dash", "Dash"), + ("decompositionmapping", "Decomposition_Mapping"), + ("decompositiontype", "Decomposition_Type"), + ("defaultignorablecodepoint", "Default_Ignorable_Code_Point"), + ("dep", "Deprecated"), + ("deprecated", "Deprecated"), + ("di", "Default_Ignorable_Code_Point"), + ("dia", "Diacritic"), + ("diacritic", "Diacritic"), + ("dm", "Decomposition_Mapping"), + ("dt", "Decomposition_Type"), + ("ea", "East_Asian_Width"), + ("eastasianwidth", "East_Asian_Width"), + ("emoji", "Emoji"), + ("emojicomponent", "Emoji_Component"), + ("emojimodifier", "Emoji_Modifier"), + ("emojimodifierbase", "Emoji_Modifier_Base"), + ("emojipresentation", "Emoji_Presentation"), + ("equideo", "Equivalent_Unified_Ideograph"), + ("equivalentunifiedideograph", "Equivalent_Unified_Ideograph"), + ("expandsonnfc", "Expands_On_NFC"), + ("expandsonnfd", "Expands_On_NFD"), + ("expandsonnfkc", "Expands_On_NFKC"), + ("expandsonnfkd", "Expands_On_NFKD"), + ("ext", "Extender"), + ("extendedpictographic", "Extended_Pictographic"), + ("extender", "Extender"), + ("fcnfkc", "FC_NFKC_Closure"), + ("fcnfkcclosure", "FC_NFKC_Closure"), + ("fullcompositionexclusion", "Full_Composition_Exclusion"), + ("gc", "General_Category"), + ("gcb", "Grapheme_Cluster_Break"), + ("generalcategory", "General_Category"), + ("graphemebase", "Grapheme_Base"), + ("graphemeclusterbreak", "Grapheme_Cluster_Break"), + ("graphemeextend", "Grapheme_Extend"), + ("graphemelink", "Grapheme_Link"), + ("grbase", "Grapheme_Base"), + ("grext", "Grapheme_Extend"), + ("grlink", "Grapheme_Link"), + ("hangulsyllabletype", "Hangul_Syllable_Type"), + ("hex", "Hex_Digit"), + ("hexdigit", "Hex_Digit"), + ("hst", "Hangul_Syllable_Type"), + ("hyphen", "Hyphen"), + ("idc", "ID_Continue"), + ("idcontinue", "ID_Continue"), + ("ideo", "Ideographic"), + ("ideographic", "Ideographic"), + ("ids", "ID_Start"), + ("idsb", "IDS_Binary_Operator"), + ("idsbinaryoperator", "IDS_Binary_Operator"), + ("idst", "IDS_Trinary_Operator"), + ("idstart", "ID_Start"), + ("idstrinaryoperator", "IDS_Trinary_Operator"), + ("indicpositionalcategory", "Indic_Positional_Category"), + ("indicsyllabiccategory", "Indic_Syllabic_Category"), + ("inpc", "Indic_Positional_Category"), + ("insc", "Indic_Syllabic_Category"), + ("isc", "ISO_Comment"), + ("jamoshortname", "Jamo_Short_Name"), + ("jg", "Joining_Group"), + ("joinc", "Join_Control"), + ("joincontrol", "Join_Control"), + ("joininggroup", "Joining_Group"), + ("joiningtype", "Joining_Type"), + ("jsn", "Jamo_Short_Name"), + ("jt", "Joining_Type"), + ("kaccountingnumeric", "kAccountingNumeric"), + ("kcompatibilityvariant", "kCompatibilityVariant"), + ("kiicore", "kIICore"), + ("kirggsource", "kIRG_GSource"), + ("kirghsource", "kIRG_HSource"), + ("kirgjsource", "kIRG_JSource"), + ("kirgkpsource", "kIRG_KPSource"), + ("kirgksource", "kIRG_KSource"), + ("kirgmsource", "kIRG_MSource"), + ("kirgtsource", "kIRG_TSource"), + ("kirgusource", "kIRG_USource"), + ("kirgvsource", "kIRG_VSource"), + ("kothernumeric", "kOtherNumeric"), + ("kprimarynumeric", "kPrimaryNumeric"), + ("krsunicode", "kRSUnicode"), + ("lb", "Line_Break"), + ("lc", "Lowercase_Mapping"), + ("linebreak", "Line_Break"), + ("loe", "Logical_Order_Exception"), + ("logicalorderexception", "Logical_Order_Exception"), + ("lower", "Lowercase"), + ("lowercase", "Lowercase"), + ("lowercasemapping", "Lowercase_Mapping"), + ("math", "Math"), + ("na", "Name"), + ("na1", "Unicode_1_Name"), + ("name", "Name"), + ("namealias", "Name_Alias"), + ("nchar", "Noncharacter_Code_Point"), + ("nfcqc", "NFC_Quick_Check"), + ("nfcquickcheck", "NFC_Quick_Check"), + ("nfdqc", "NFD_Quick_Check"), + ("nfdquickcheck", "NFD_Quick_Check"), + ("nfkccasefold", "NFKC_Casefold"), + ("nfkccf", "NFKC_Casefold"), + ("nfkcqc", "NFKC_Quick_Check"), + ("nfkcquickcheck", "NFKC_Quick_Check"), + ("nfkdqc", "NFKD_Quick_Check"), + ("nfkdquickcheck", "NFKD_Quick_Check"), + ("noncharactercodepoint", "Noncharacter_Code_Point"), + ("nt", "Numeric_Type"), + ("numerictype", "Numeric_Type"), + ("numericvalue", "Numeric_Value"), + ("nv", "Numeric_Value"), + ("oalpha", "Other_Alphabetic"), + ("ocomment", "ISO_Comment"), + ("odi", "Other_Default_Ignorable_Code_Point"), + ("ogrext", "Other_Grapheme_Extend"), + ("oidc", "Other_ID_Continue"), + ("oids", "Other_ID_Start"), + ("olower", "Other_Lowercase"), + ("omath", "Other_Math"), + ("otheralphabetic", "Other_Alphabetic"), + ("otherdefaultignorablecodepoint", "Other_Default_Ignorable_Code_Point"), + ("othergraphemeextend", "Other_Grapheme_Extend"), + ("otheridcontinue", "Other_ID_Continue"), + ("otheridstart", "Other_ID_Start"), + ("otherlowercase", "Other_Lowercase"), + ("othermath", "Other_Math"), + ("otheruppercase", "Other_Uppercase"), + ("oupper", "Other_Uppercase"), + ("patsyn", "Pattern_Syntax"), + ("patternsyntax", "Pattern_Syntax"), + ("patternwhitespace", "Pattern_White_Space"), + ("patws", "Pattern_White_Space"), + ("pcm", "Prepended_Concatenation_Mark"), + ("prependedconcatenationmark", "Prepended_Concatenation_Mark"), + ("qmark", "Quotation_Mark"), + ("quotationmark", "Quotation_Mark"), + ("radical", "Radical"), + ("regionalindicator", "Regional_Indicator"), + ("ri", "Regional_Indicator"), + ("sb", "Sentence_Break"), + ("sc", "Script"), + ("scf", "Simple_Case_Folding"), + ("script", "Script"), + ("scriptextensions", "Script_Extensions"), + ("scx", "Script_Extensions"), + ("sd", "Soft_Dotted"), + ("sentencebreak", "Sentence_Break"), + ("sentenceterminal", "Sentence_Terminal"), + ("sfc", "Simple_Case_Folding"), + ("simplecasefolding", "Simple_Case_Folding"), + ("simplelowercasemapping", "Simple_Lowercase_Mapping"), + ("simpletitlecasemapping", "Simple_Titlecase_Mapping"), + ("simpleuppercasemapping", "Simple_Uppercase_Mapping"), + ("slc", "Simple_Lowercase_Mapping"), + ("softdotted", "Soft_Dotted"), + ("space", "White_Space"), + ("stc", "Simple_Titlecase_Mapping"), + ("sterm", "Sentence_Terminal"), + ("suc", "Simple_Uppercase_Mapping"), + ("tc", "Titlecase_Mapping"), + ("term", "Terminal_Punctuation"), + ("terminalpunctuation", "Terminal_Punctuation"), + ("titlecasemapping", "Titlecase_Mapping"), + ("uc", "Uppercase_Mapping"), + ("uideo", "Unified_Ideograph"), + ("unicode1name", "Unicode_1_Name"), + ("unicoderadicalstroke", "kRSUnicode"), + ("unifiedideograph", "Unified_Ideograph"), + ("upper", "Uppercase"), + ("uppercase", "Uppercase"), + ("uppercasemapping", "Uppercase_Mapping"), + ("urs", "kRSUnicode"), + ("variationselector", "Variation_Selector"), + ("verticalorientation", "Vertical_Orientation"), + ("vo", "Vertical_Orientation"), + ("vs", "Variation_Selector"), + ("wb", "Word_Break"), + ("whitespace", "White_Space"), + ("wordbreak", "Word_Break"), + ("wspace", "White_Space"), + ("xidc", "XID_Continue"), + ("xidcontinue", "XID_Continue"), + ("xids", "XID_Start"), + ("xidstart", "XID_Start"), + ("xonfc", "Expands_On_NFC"), + ("xonfd", "Expands_On_NFD"), + ("xonfkc", "Expands_On_NFKC"), + ("xonfkd", "Expands_On_NFKD"), +]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/property_values.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/property_values.rs new file mode 100644 index 0000000..0f960b0 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/property_values.rs @@ -0,0 +1,876 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate property-values /tmp/ucd/12.1.0/ --include gc,script,scx,age,gcb,wb,sb +// +// ucd-generate is available on crates.io. + +pub const PROPERTY_VALUES: &'static [( + &'static str, + &'static [(&'static str, &'static str)], +)] = &[ + ( + "Age", + &[ + ("1.1", "V1_1"), + ("10.0", "V10_0"), + ("11.0", "V11_0"), + ("12.0", "V12_0"), + ("12.1", "V12_1"), + ("2.0", "V2_0"), + ("2.1", "V2_1"), + ("3.0", "V3_0"), + ("3.1", "V3_1"), + ("3.2", "V3_2"), + ("4.0", "V4_0"), + ("4.1", "V4_1"), + ("5.0", "V5_0"), + ("5.1", "V5_1"), + ("5.2", "V5_2"), + ("6.0", "V6_0"), + ("6.1", "V6_1"), + ("6.2", "V6_2"), + ("6.3", "V6_3"), + ("7.0", "V7_0"), + ("8.0", "V8_0"), + ("9.0", "V9_0"), + ("na", "Unassigned"), + ("unassigned", "Unassigned"), + ("v100", "V10_0"), + ("v11", "V1_1"), + ("v110", "V11_0"), + ("v120", "V12_0"), + ("v121", "V12_1"), + ("v20", "V2_0"), + ("v21", "V2_1"), + ("v30", "V3_0"), + ("v31", "V3_1"), + ("v32", "V3_2"), + ("v40", "V4_0"), + ("v41", "V4_1"), + ("v50", "V5_0"), + ("v51", "V5_1"), + ("v52", "V5_2"), + ("v60", "V6_0"), + ("v61", "V6_1"), + ("v62", "V6_2"), + ("v63", "V6_3"), + ("v70", "V7_0"), + ("v80", "V8_0"), + ("v90", "V9_0"), + ], + ), + ( + "General_Category", + &[ + ("c", "Other"), + ("casedletter", "Cased_Letter"), + ("cc", "Control"), + ("cf", "Format"), + ("closepunctuation", "Close_Punctuation"), + ("cn", "Unassigned"), + ("cntrl", "Control"), + ("co", "Private_Use"), + ("combiningmark", "Mark"), + ("connectorpunctuation", "Connector_Punctuation"), + ("control", "Control"), + ("cs", "Surrogate"), + ("currencysymbol", "Currency_Symbol"), + ("dashpunctuation", "Dash_Punctuation"), + ("decimalnumber", "Decimal_Number"), + ("digit", "Decimal_Number"), + ("enclosingmark", "Enclosing_Mark"), + ("finalpunctuation", "Final_Punctuation"), + ("format", "Format"), + ("initialpunctuation", "Initial_Punctuation"), + ("l", "Letter"), + ("lc", "Cased_Letter"), + ("letter", "Letter"), + ("letternumber", "Letter_Number"), + ("lineseparator", "Line_Separator"), + ("ll", "Lowercase_Letter"), + ("lm", "Modifier_Letter"), + ("lo", "Other_Letter"), + ("lowercaseletter", "Lowercase_Letter"), + ("lt", "Titlecase_Letter"), + ("lu", "Uppercase_Letter"), + ("m", "Mark"), + ("mark", "Mark"), + ("mathsymbol", "Math_Symbol"), + ("mc", "Spacing_Mark"), + ("me", "Enclosing_Mark"), + ("mn", "Nonspacing_Mark"), + ("modifierletter", "Modifier_Letter"), + ("modifiersymbol", "Modifier_Symbol"), + ("n", "Number"), + ("nd", "Decimal_Number"), + ("nl", "Letter_Number"), + ("no", "Other_Number"), + ("nonspacingmark", "Nonspacing_Mark"), + ("number", "Number"), + ("openpunctuation", "Open_Punctuation"), + ("other", "Other"), + ("otherletter", "Other_Letter"), + ("othernumber", "Other_Number"), + ("otherpunctuation", "Other_Punctuation"), + ("othersymbol", "Other_Symbol"), + ("p", "Punctuation"), + ("paragraphseparator", "Paragraph_Separator"), + ("pc", "Connector_Punctuation"), + ("pd", "Dash_Punctuation"), + ("pe", "Close_Punctuation"), + ("pf", "Final_Punctuation"), + ("pi", "Initial_Punctuation"), + ("po", "Other_Punctuation"), + ("privateuse", "Private_Use"), + ("ps", "Open_Punctuation"), + ("punct", "Punctuation"), + ("punctuation", "Punctuation"), + ("s", "Symbol"), + ("sc", "Currency_Symbol"), + ("separator", "Separator"), + ("sk", "Modifier_Symbol"), + ("sm", "Math_Symbol"), + ("so", "Other_Symbol"), + ("spaceseparator", "Space_Separator"), + ("spacingmark", "Spacing_Mark"), + ("surrogate", "Surrogate"), + ("symbol", "Symbol"), + ("titlecaseletter", "Titlecase_Letter"), + ("unassigned", "Unassigned"), + ("uppercaseletter", "Uppercase_Letter"), + ("z", "Separator"), + ("zl", "Line_Separator"), + ("zp", "Paragraph_Separator"), + ("zs", "Space_Separator"), + ], + ), + ( + "Grapheme_Cluster_Break", + &[ + ("cn", "Control"), + ("control", "Control"), + ("cr", "CR"), + ("eb", "E_Base"), + ("ebase", "E_Base"), + ("ebasegaz", "E_Base_GAZ"), + ("ebg", "E_Base_GAZ"), + ("em", "E_Modifier"), + ("emodifier", "E_Modifier"), + ("ex", "Extend"), + ("extend", "Extend"), + ("gaz", "Glue_After_Zwj"), + ("glueafterzwj", "Glue_After_Zwj"), + ("l", "L"), + ("lf", "LF"), + ("lv", "LV"), + ("lvt", "LVT"), + ("other", "Other"), + ("pp", "Prepend"), + ("prepend", "Prepend"), + ("regionalindicator", "Regional_Indicator"), + ("ri", "Regional_Indicator"), + ("sm", "SpacingMark"), + ("spacingmark", "SpacingMark"), + ("t", "T"), + ("v", "V"), + ("xx", "Other"), + ("zwj", "ZWJ"), + ], + ), + ( + "Script", + &[ + ("adlam", "Adlam"), + ("adlm", "Adlam"), + ("aghb", "Caucasian_Albanian"), + ("ahom", "Ahom"), + ("anatolianhieroglyphs", "Anatolian_Hieroglyphs"), + ("arab", "Arabic"), + ("arabic", "Arabic"), + ("armenian", "Armenian"), + ("armi", "Imperial_Aramaic"), + ("armn", "Armenian"), + ("avestan", "Avestan"), + ("avst", "Avestan"), + ("bali", "Balinese"), + ("balinese", "Balinese"), + ("bamu", "Bamum"), + ("bamum", "Bamum"), + ("bass", "Bassa_Vah"), + ("bassavah", "Bassa_Vah"), + ("batak", "Batak"), + ("batk", "Batak"), + ("beng", "Bengali"), + ("bengali", "Bengali"), + ("bhaiksuki", "Bhaiksuki"), + ("bhks", "Bhaiksuki"), + ("bopo", "Bopomofo"), + ("bopomofo", "Bopomofo"), + ("brah", "Brahmi"), + ("brahmi", "Brahmi"), + ("brai", "Braille"), + ("braille", "Braille"), + ("bugi", "Buginese"), + ("buginese", "Buginese"), + ("buhd", "Buhid"), + ("buhid", "Buhid"), + ("cakm", "Chakma"), + ("canadianaboriginal", "Canadian_Aboriginal"), + ("cans", "Canadian_Aboriginal"), + ("cari", "Carian"), + ("carian", "Carian"), + ("caucasianalbanian", "Caucasian_Albanian"), + ("chakma", "Chakma"), + ("cham", "Cham"), + ("cher", "Cherokee"), + ("cherokee", "Cherokee"), + ("common", "Common"), + ("copt", "Coptic"), + ("coptic", "Coptic"), + ("cprt", "Cypriot"), + ("cuneiform", "Cuneiform"), + ("cypriot", "Cypriot"), + ("cyrillic", "Cyrillic"), + ("cyrl", "Cyrillic"), + ("deseret", "Deseret"), + ("deva", "Devanagari"), + ("devanagari", "Devanagari"), + ("dogr", "Dogra"), + ("dogra", "Dogra"), + ("dsrt", "Deseret"), + ("dupl", "Duployan"), + ("duployan", "Duployan"), + ("egyp", "Egyptian_Hieroglyphs"), + ("egyptianhieroglyphs", "Egyptian_Hieroglyphs"), + ("elba", "Elbasan"), + ("elbasan", "Elbasan"), + ("elym", "Elymaic"), + ("elymaic", "Elymaic"), + ("ethi", "Ethiopic"), + ("ethiopic", "Ethiopic"), + ("geor", "Georgian"), + ("georgian", "Georgian"), + ("glag", "Glagolitic"), + ("glagolitic", "Glagolitic"), + ("gong", "Gunjala_Gondi"), + ("gonm", "Masaram_Gondi"), + ("goth", "Gothic"), + ("gothic", "Gothic"), + ("gran", "Grantha"), + ("grantha", "Grantha"), + ("greek", "Greek"), + ("grek", "Greek"), + ("gujarati", "Gujarati"), + ("gujr", "Gujarati"), + ("gunjalagondi", "Gunjala_Gondi"), + ("gurmukhi", "Gurmukhi"), + ("guru", "Gurmukhi"), + ("han", "Han"), + ("hang", "Hangul"), + ("hangul", "Hangul"), + ("hani", "Han"), + ("hanifirohingya", "Hanifi_Rohingya"), + ("hano", "Hanunoo"), + ("hanunoo", "Hanunoo"), + ("hatr", "Hatran"), + ("hatran", "Hatran"), + ("hebr", "Hebrew"), + ("hebrew", "Hebrew"), + ("hira", "Hiragana"), + ("hiragana", "Hiragana"), + ("hluw", "Anatolian_Hieroglyphs"), + ("hmng", "Pahawh_Hmong"), + ("hmnp", "Nyiakeng_Puachue_Hmong"), + ("hrkt", "Katakana_Or_Hiragana"), + ("hung", "Old_Hungarian"), + ("imperialaramaic", "Imperial_Aramaic"), + ("inherited", "Inherited"), + ("inscriptionalpahlavi", "Inscriptional_Pahlavi"), + ("inscriptionalparthian", "Inscriptional_Parthian"), + ("ital", "Old_Italic"), + ("java", "Javanese"), + ("javanese", "Javanese"), + ("kaithi", "Kaithi"), + ("kali", "Kayah_Li"), + ("kana", "Katakana"), + ("kannada", "Kannada"), + ("katakana", "Katakana"), + ("katakanaorhiragana", "Katakana_Or_Hiragana"), + ("kayahli", "Kayah_Li"), + ("khar", "Kharoshthi"), + ("kharoshthi", "Kharoshthi"), + ("khmer", "Khmer"), + ("khmr", "Khmer"), + ("khoj", "Khojki"), + ("khojki", "Khojki"), + ("khudawadi", "Khudawadi"), + ("knda", "Kannada"), + ("kthi", "Kaithi"), + ("lana", "Tai_Tham"), + ("lao", "Lao"), + ("laoo", "Lao"), + ("latin", "Latin"), + ("latn", "Latin"), + ("lepc", "Lepcha"), + ("lepcha", "Lepcha"), + ("limb", "Limbu"), + ("limbu", "Limbu"), + ("lina", "Linear_A"), + ("linb", "Linear_B"), + ("lineara", "Linear_A"), + ("linearb", "Linear_B"), + ("lisu", "Lisu"), + ("lyci", "Lycian"), + ("lycian", "Lycian"), + ("lydi", "Lydian"), + ("lydian", "Lydian"), + ("mahajani", "Mahajani"), + ("mahj", "Mahajani"), + ("maka", "Makasar"), + ("makasar", "Makasar"), + ("malayalam", "Malayalam"), + ("mand", "Mandaic"), + ("mandaic", "Mandaic"), + ("mani", "Manichaean"), + ("manichaean", "Manichaean"), + ("marc", "Marchen"), + ("marchen", "Marchen"), + ("masaramgondi", "Masaram_Gondi"), + ("medefaidrin", "Medefaidrin"), + ("medf", "Medefaidrin"), + ("meeteimayek", "Meetei_Mayek"), + ("mend", "Mende_Kikakui"), + ("mendekikakui", "Mende_Kikakui"), + ("merc", "Meroitic_Cursive"), + ("mero", "Meroitic_Hieroglyphs"), + ("meroiticcursive", "Meroitic_Cursive"), + ("meroitichieroglyphs", "Meroitic_Hieroglyphs"), + ("miao", "Miao"), + ("mlym", "Malayalam"), + ("modi", "Modi"), + ("mong", "Mongolian"), + ("mongolian", "Mongolian"), + ("mro", "Mro"), + ("mroo", "Mro"), + ("mtei", "Meetei_Mayek"), + ("mult", "Multani"), + ("multani", "Multani"), + ("myanmar", "Myanmar"), + ("mymr", "Myanmar"), + ("nabataean", "Nabataean"), + ("nand", "Nandinagari"), + ("nandinagari", "Nandinagari"), + ("narb", "Old_North_Arabian"), + ("nbat", "Nabataean"), + ("newa", "Newa"), + ("newtailue", "New_Tai_Lue"), + ("nko", "Nko"), + ("nkoo", "Nko"), + ("nshu", "Nushu"), + ("nushu", "Nushu"), + ("nyiakengpuachuehmong", "Nyiakeng_Puachue_Hmong"), + ("ogam", "Ogham"), + ("ogham", "Ogham"), + ("olchiki", "Ol_Chiki"), + ("olck", "Ol_Chiki"), + ("oldhungarian", "Old_Hungarian"), + ("olditalic", "Old_Italic"), + ("oldnortharabian", "Old_North_Arabian"), + ("oldpermic", "Old_Permic"), + ("oldpersian", "Old_Persian"), + ("oldsogdian", "Old_Sogdian"), + ("oldsoutharabian", "Old_South_Arabian"), + ("oldturkic", "Old_Turkic"), + ("oriya", "Oriya"), + ("orkh", "Old_Turkic"), + ("orya", "Oriya"), + ("osage", "Osage"), + ("osge", "Osage"), + ("osma", "Osmanya"), + ("osmanya", "Osmanya"), + ("pahawhhmong", "Pahawh_Hmong"), + ("palm", "Palmyrene"), + ("palmyrene", "Palmyrene"), + ("pauc", "Pau_Cin_Hau"), + ("paucinhau", "Pau_Cin_Hau"), + ("perm", "Old_Permic"), + ("phag", "Phags_Pa"), + ("phagspa", "Phags_Pa"), + ("phli", "Inscriptional_Pahlavi"), + ("phlp", "Psalter_Pahlavi"), + ("phnx", "Phoenician"), + ("phoenician", "Phoenician"), + ("plrd", "Miao"), + ("prti", "Inscriptional_Parthian"), + ("psalterpahlavi", "Psalter_Pahlavi"), + ("qaac", "Coptic"), + ("qaai", "Inherited"), + ("rejang", "Rejang"), + ("rjng", "Rejang"), + ("rohg", "Hanifi_Rohingya"), + ("runic", "Runic"), + ("runr", "Runic"), + ("samaritan", "Samaritan"), + ("samr", "Samaritan"), + ("sarb", "Old_South_Arabian"), + ("saur", "Saurashtra"), + ("saurashtra", "Saurashtra"), + ("sgnw", "SignWriting"), + ("sharada", "Sharada"), + ("shavian", "Shavian"), + ("shaw", "Shavian"), + ("shrd", "Sharada"), + ("sidd", "Siddham"), + ("siddham", "Siddham"), + ("signwriting", "SignWriting"), + ("sind", "Khudawadi"), + ("sinh", "Sinhala"), + ("sinhala", "Sinhala"), + ("sogd", "Sogdian"), + ("sogdian", "Sogdian"), + ("sogo", "Old_Sogdian"), + ("sora", "Sora_Sompeng"), + ("sorasompeng", "Sora_Sompeng"), + ("soyo", "Soyombo"), + ("soyombo", "Soyombo"), + ("sund", "Sundanese"), + ("sundanese", "Sundanese"), + ("sylo", "Syloti_Nagri"), + ("sylotinagri", "Syloti_Nagri"), + ("syrc", "Syriac"), + ("syriac", "Syriac"), + ("tagalog", "Tagalog"), + ("tagb", "Tagbanwa"), + ("tagbanwa", "Tagbanwa"), + ("taile", "Tai_Le"), + ("taitham", "Tai_Tham"), + ("taiviet", "Tai_Viet"), + ("takr", "Takri"), + ("takri", "Takri"), + ("tale", "Tai_Le"), + ("talu", "New_Tai_Lue"), + ("tamil", "Tamil"), + ("taml", "Tamil"), + ("tang", "Tangut"), + ("tangut", "Tangut"), + ("tavt", "Tai_Viet"), + ("telu", "Telugu"), + ("telugu", "Telugu"), + ("tfng", "Tifinagh"), + ("tglg", "Tagalog"), + ("thaa", "Thaana"), + ("thaana", "Thaana"), + ("thai", "Thai"), + ("tibetan", "Tibetan"), + ("tibt", "Tibetan"), + ("tifinagh", "Tifinagh"), + ("tirh", "Tirhuta"), + ("tirhuta", "Tirhuta"), + ("ugar", "Ugaritic"), + ("ugaritic", "Ugaritic"), + ("unknown", "Unknown"), + ("vai", "Vai"), + ("vaii", "Vai"), + ("wancho", "Wancho"), + ("wara", "Warang_Citi"), + ("warangciti", "Warang_Citi"), + ("wcho", "Wancho"), + ("xpeo", "Old_Persian"), + ("xsux", "Cuneiform"), + ("yi", "Yi"), + ("yiii", "Yi"), + ("zanabazarsquare", "Zanabazar_Square"), + ("zanb", "Zanabazar_Square"), + ("zinh", "Inherited"), + ("zyyy", "Common"), + ("zzzz", "Unknown"), + ], + ), + ( + "Script_Extensions", + &[ + ("adlam", "Adlam"), + ("adlm", "Adlam"), + ("aghb", "Caucasian_Albanian"), + ("ahom", "Ahom"), + ("anatolianhieroglyphs", "Anatolian_Hieroglyphs"), + ("arab", "Arabic"), + ("arabic", "Arabic"), + ("armenian", "Armenian"), + ("armi", "Imperial_Aramaic"), + ("armn", "Armenian"), + ("avestan", "Avestan"), + ("avst", "Avestan"), + ("bali", "Balinese"), + ("balinese", "Balinese"), + ("bamu", "Bamum"), + ("bamum", "Bamum"), + ("bass", "Bassa_Vah"), + ("bassavah", "Bassa_Vah"), + ("batak", "Batak"), + ("batk", "Batak"), + ("beng", "Bengali"), + ("bengali", "Bengali"), + ("bhaiksuki", "Bhaiksuki"), + ("bhks", "Bhaiksuki"), + ("bopo", "Bopomofo"), + ("bopomofo", "Bopomofo"), + ("brah", "Brahmi"), + ("brahmi", "Brahmi"), + ("brai", "Braille"), + ("braille", "Braille"), + ("bugi", "Buginese"), + ("buginese", "Buginese"), + ("buhd", "Buhid"), + ("buhid", "Buhid"), + ("cakm", "Chakma"), + ("canadianaboriginal", "Canadian_Aboriginal"), + ("cans", "Canadian_Aboriginal"), + ("cari", "Carian"), + ("carian", "Carian"), + ("caucasianalbanian", "Caucasian_Albanian"), + ("chakma", "Chakma"), + ("cham", "Cham"), + ("cher", "Cherokee"), + ("cherokee", "Cherokee"), + ("common", "Common"), + ("copt", "Coptic"), + ("coptic", "Coptic"), + ("cprt", "Cypriot"), + ("cuneiform", "Cuneiform"), + ("cypriot", "Cypriot"), + ("cyrillic", "Cyrillic"), + ("cyrl", "Cyrillic"), + ("deseret", "Deseret"), + ("deva", "Devanagari"), + ("devanagari", "Devanagari"), + ("dogr", "Dogra"), + ("dogra", "Dogra"), + ("dsrt", "Deseret"), + ("dupl", "Duployan"), + ("duployan", "Duployan"), + ("egyp", "Egyptian_Hieroglyphs"), + ("egyptianhieroglyphs", "Egyptian_Hieroglyphs"), + ("elba", "Elbasan"), + ("elbasan", "Elbasan"), + ("elym", "Elymaic"), + ("elymaic", "Elymaic"), + ("ethi", "Ethiopic"), + ("ethiopic", "Ethiopic"), + ("geor", "Georgian"), + ("georgian", "Georgian"), + ("glag", "Glagolitic"), + ("glagolitic", "Glagolitic"), + ("gong", "Gunjala_Gondi"), + ("gonm", "Masaram_Gondi"), + ("goth", "Gothic"), + ("gothic", "Gothic"), + ("gran", "Grantha"), + ("grantha", "Grantha"), + ("greek", "Greek"), + ("grek", "Greek"), + ("gujarati", "Gujarati"), + ("gujr", "Gujarati"), + ("gunjalagondi", "Gunjala_Gondi"), + ("gurmukhi", "Gurmukhi"), + ("guru", "Gurmukhi"), + ("han", "Han"), + ("hang", "Hangul"), + ("hangul", "Hangul"), + ("hani", "Han"), + ("hanifirohingya", "Hanifi_Rohingya"), + ("hano", "Hanunoo"), + ("hanunoo", "Hanunoo"), + ("hatr", "Hatran"), + ("hatran", "Hatran"), + ("hebr", "Hebrew"), + ("hebrew", "Hebrew"), + ("hira", "Hiragana"), + ("hiragana", "Hiragana"), + ("hluw", "Anatolian_Hieroglyphs"), + ("hmng", "Pahawh_Hmong"), + ("hmnp", "Nyiakeng_Puachue_Hmong"), + ("hrkt", "Katakana_Or_Hiragana"), + ("hung", "Old_Hungarian"), + ("imperialaramaic", "Imperial_Aramaic"), + ("inherited", "Inherited"), + ("inscriptionalpahlavi", "Inscriptional_Pahlavi"), + ("inscriptionalparthian", "Inscriptional_Parthian"), + ("ital", "Old_Italic"), + ("java", "Javanese"), + ("javanese", "Javanese"), + ("kaithi", "Kaithi"), + ("kali", "Kayah_Li"), + ("kana", "Katakana"), + ("kannada", "Kannada"), + ("katakana", "Katakana"), + ("katakanaorhiragana", "Katakana_Or_Hiragana"), + ("kayahli", "Kayah_Li"), + ("khar", "Kharoshthi"), + ("kharoshthi", "Kharoshthi"), + ("khmer", "Khmer"), + ("khmr", "Khmer"), + ("khoj", "Khojki"), + ("khojki", "Khojki"), + ("khudawadi", "Khudawadi"), + ("knda", "Kannada"), + ("kthi", "Kaithi"), + ("lana", "Tai_Tham"), + ("lao", "Lao"), + ("laoo", "Lao"), + ("latin", "Latin"), + ("latn", "Latin"), + ("lepc", "Lepcha"), + ("lepcha", "Lepcha"), + ("limb", "Limbu"), + ("limbu", "Limbu"), + ("lina", "Linear_A"), + ("linb", "Linear_B"), + ("lineara", "Linear_A"), + ("linearb", "Linear_B"), + ("lisu", "Lisu"), + ("lyci", "Lycian"), + ("lycian", "Lycian"), + ("lydi", "Lydian"), + ("lydian", "Lydian"), + ("mahajani", "Mahajani"), + ("mahj", "Mahajani"), + ("maka", "Makasar"), + ("makasar", "Makasar"), + ("malayalam", "Malayalam"), + ("mand", "Mandaic"), + ("mandaic", "Mandaic"), + ("mani", "Manichaean"), + ("manichaean", "Manichaean"), + ("marc", "Marchen"), + ("marchen", "Marchen"), + ("masaramgondi", "Masaram_Gondi"), + ("medefaidrin", "Medefaidrin"), + ("medf", "Medefaidrin"), + ("meeteimayek", "Meetei_Mayek"), + ("mend", "Mende_Kikakui"), + ("mendekikakui", "Mende_Kikakui"), + ("merc", "Meroitic_Cursive"), + ("mero", "Meroitic_Hieroglyphs"), + ("meroiticcursive", "Meroitic_Cursive"), + ("meroitichieroglyphs", "Meroitic_Hieroglyphs"), + ("miao", "Miao"), + ("mlym", "Malayalam"), + ("modi", "Modi"), + ("mong", "Mongolian"), + ("mongolian", "Mongolian"), + ("mro", "Mro"), + ("mroo", "Mro"), + ("mtei", "Meetei_Mayek"), + ("mult", "Multani"), + ("multani", "Multani"), + ("myanmar", "Myanmar"), + ("mymr", "Myanmar"), + ("nabataean", "Nabataean"), + ("nand", "Nandinagari"), + ("nandinagari", "Nandinagari"), + ("narb", "Old_North_Arabian"), + ("nbat", "Nabataean"), + ("newa", "Newa"), + ("newtailue", "New_Tai_Lue"), + ("nko", "Nko"), + ("nkoo", "Nko"), + ("nshu", "Nushu"), + ("nushu", "Nushu"), + ("nyiakengpuachuehmong", "Nyiakeng_Puachue_Hmong"), + ("ogam", "Ogham"), + ("ogham", "Ogham"), + ("olchiki", "Ol_Chiki"), + ("olck", "Ol_Chiki"), + ("oldhungarian", "Old_Hungarian"), + ("olditalic", "Old_Italic"), + ("oldnortharabian", "Old_North_Arabian"), + ("oldpermic", "Old_Permic"), + ("oldpersian", "Old_Persian"), + ("oldsogdian", "Old_Sogdian"), + ("oldsoutharabian", "Old_South_Arabian"), + ("oldturkic", "Old_Turkic"), + ("oriya", "Oriya"), + ("orkh", "Old_Turkic"), + ("orya", "Oriya"), + ("osage", "Osage"), + ("osge", "Osage"), + ("osma", "Osmanya"), + ("osmanya", "Osmanya"), + ("pahawhhmong", "Pahawh_Hmong"), + ("palm", "Palmyrene"), + ("palmyrene", "Palmyrene"), + ("pauc", "Pau_Cin_Hau"), + ("paucinhau", "Pau_Cin_Hau"), + ("perm", "Old_Permic"), + ("phag", "Phags_Pa"), + ("phagspa", "Phags_Pa"), + ("phli", "Inscriptional_Pahlavi"), + ("phlp", "Psalter_Pahlavi"), + ("phnx", "Phoenician"), + ("phoenician", "Phoenician"), + ("plrd", "Miao"), + ("prti", "Inscriptional_Parthian"), + ("psalterpahlavi", "Psalter_Pahlavi"), + ("qaac", "Coptic"), + ("qaai", "Inherited"), + ("rejang", "Rejang"), + ("rjng", "Rejang"), + ("rohg", "Hanifi_Rohingya"), + ("runic", "Runic"), + ("runr", "Runic"), + ("samaritan", "Samaritan"), + ("samr", "Samaritan"), + ("sarb", "Old_South_Arabian"), + ("saur", "Saurashtra"), + ("saurashtra", "Saurashtra"), + ("sgnw", "SignWriting"), + ("sharada", "Sharada"), + ("shavian", "Shavian"), + ("shaw", "Shavian"), + ("shrd", "Sharada"), + ("sidd", "Siddham"), + ("siddham", "Siddham"), + ("signwriting", "SignWriting"), + ("sind", "Khudawadi"), + ("sinh", "Sinhala"), + ("sinhala", "Sinhala"), + ("sogd", "Sogdian"), + ("sogdian", "Sogdian"), + ("sogo", "Old_Sogdian"), + ("sora", "Sora_Sompeng"), + ("sorasompeng", "Sora_Sompeng"), + ("soyo", "Soyombo"), + ("soyombo", "Soyombo"), + ("sund", "Sundanese"), + ("sundanese", "Sundanese"), + ("sylo", "Syloti_Nagri"), + ("sylotinagri", "Syloti_Nagri"), + ("syrc", "Syriac"), + ("syriac", "Syriac"), + ("tagalog", "Tagalog"), + ("tagb", "Tagbanwa"), + ("tagbanwa", "Tagbanwa"), + ("taile", "Tai_Le"), + ("taitham", "Tai_Tham"), + ("taiviet", "Tai_Viet"), + ("takr", "Takri"), + ("takri", "Takri"), + ("tale", "Tai_Le"), + ("talu", "New_Tai_Lue"), + ("tamil", "Tamil"), + ("taml", "Tamil"), + ("tang", "Tangut"), + ("tangut", "Tangut"), + ("tavt", "Tai_Viet"), + ("telu", "Telugu"), + ("telugu", "Telugu"), + ("tfng", "Tifinagh"), + ("tglg", "Tagalog"), + ("thaa", "Thaana"), + ("thaana", "Thaana"), + ("thai", "Thai"), + ("tibetan", "Tibetan"), + ("tibt", "Tibetan"), + ("tifinagh", "Tifinagh"), + ("tirh", "Tirhuta"), + ("tirhuta", "Tirhuta"), + ("ugar", "Ugaritic"), + ("ugaritic", "Ugaritic"), + ("unknown", "Unknown"), + ("vai", "Vai"), + ("vaii", "Vai"), + ("wancho", "Wancho"), + ("wara", "Warang_Citi"), + ("warangciti", "Warang_Citi"), + ("wcho", "Wancho"), + ("xpeo", "Old_Persian"), + ("xsux", "Cuneiform"), + ("yi", "Yi"), + ("yiii", "Yi"), + ("zanabazarsquare", "Zanabazar_Square"), + ("zanb", "Zanabazar_Square"), + ("zinh", "Inherited"), + ("zyyy", "Common"), + ("zzzz", "Unknown"), + ], + ), + ( + "Sentence_Break", + &[ + ("at", "ATerm"), + ("aterm", "ATerm"), + ("cl", "Close"), + ("close", "Close"), + ("cr", "CR"), + ("ex", "Extend"), + ("extend", "Extend"), + ("fo", "Format"), + ("format", "Format"), + ("le", "OLetter"), + ("lf", "LF"), + ("lo", "Lower"), + ("lower", "Lower"), + ("nu", "Numeric"), + ("numeric", "Numeric"), + ("oletter", "OLetter"), + ("other", "Other"), + ("sc", "SContinue"), + ("scontinue", "SContinue"), + ("se", "Sep"), + ("sep", "Sep"), + ("sp", "Sp"), + ("st", "STerm"), + ("sterm", "STerm"), + ("up", "Upper"), + ("upper", "Upper"), + ("xx", "Other"), + ], + ), + ( + "Word_Break", + &[ + ("aletter", "ALetter"), + ("cr", "CR"), + ("doublequote", "Double_Quote"), + ("dq", "Double_Quote"), + ("eb", "E_Base"), + ("ebase", "E_Base"), + ("ebasegaz", "E_Base_GAZ"), + ("ebg", "E_Base_GAZ"), + ("em", "E_Modifier"), + ("emodifier", "E_Modifier"), + ("ex", "ExtendNumLet"), + ("extend", "Extend"), + ("extendnumlet", "ExtendNumLet"), + ("fo", "Format"), + ("format", "Format"), + ("gaz", "Glue_After_Zwj"), + ("glueafterzwj", "Glue_After_Zwj"), + ("hebrewletter", "Hebrew_Letter"), + ("hl", "Hebrew_Letter"), + ("ka", "Katakana"), + ("katakana", "Katakana"), + ("le", "ALetter"), + ("lf", "LF"), + ("mb", "MidNumLet"), + ("midletter", "MidLetter"), + ("midnum", "MidNum"), + ("midnumlet", "MidNumLet"), + ("ml", "MidLetter"), + ("mn", "MidNum"), + ("newline", "Newline"), + ("nl", "Newline"), + ("nu", "Numeric"), + ("numeric", "Numeric"), + ("other", "Other"), + ("regionalindicator", "Regional_Indicator"), + ("ri", "Regional_Indicator"), + ("singlequote", "Single_Quote"), + ("sq", "Single_Quote"), + ("wsegspace", "WSegSpace"), + ("xx", "Other"), + ("zwj", "ZWJ"), + ], + ), +]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/script.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/script.rs new file mode 100644 index 0000000..19dbc38 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/script.rs @@ -0,0 +1,1197 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate script /tmp/ucd/12.1.0/ --chars +// +// ucd-generate is available on crates.io. + +pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] = &[ + ("Adlam", ADLAM), + ("Ahom", AHOM), + ("Anatolian_Hieroglyphs", ANATOLIAN_HIEROGLYPHS), + ("Arabic", ARABIC), + ("Armenian", ARMENIAN), + ("Avestan", AVESTAN), + ("Balinese", BALINESE), + ("Bamum", BAMUM), + ("Bassa_Vah", BASSA_VAH), + ("Batak", BATAK), + ("Bengali", BENGALI), + ("Bhaiksuki", BHAIKSUKI), + ("Bopomofo", BOPOMOFO), + ("Brahmi", BRAHMI), + ("Braille", BRAILLE), + ("Buginese", BUGINESE), + ("Buhid", BUHID), + ("Canadian_Aboriginal", CANADIAN_ABORIGINAL), + ("Carian", CARIAN), + ("Caucasian_Albanian", CAUCASIAN_ALBANIAN), + ("Chakma", CHAKMA), + ("Cham", CHAM), + ("Cherokee", CHEROKEE), + ("Common", COMMON), + ("Coptic", COPTIC), + ("Cuneiform", CUNEIFORM), + ("Cypriot", CYPRIOT), + ("Cyrillic", CYRILLIC), + ("Deseret", DESERET), + ("Devanagari", DEVANAGARI), + ("Dogra", DOGRA), + ("Duployan", DUPLOYAN), + ("Egyptian_Hieroglyphs", EGYPTIAN_HIEROGLYPHS), + ("Elbasan", ELBASAN), + ("Elymaic", ELYMAIC), + ("Ethiopic", ETHIOPIC), + ("Georgian", GEORGIAN), + ("Glagolitic", GLAGOLITIC), + ("Gothic", GOTHIC), + ("Grantha", GRANTHA), + ("Greek", GREEK), + ("Gujarati", GUJARATI), + ("Gunjala_Gondi", GUNJALA_GONDI), + ("Gurmukhi", GURMUKHI), + ("Han", HAN), + ("Hangul", HANGUL), + ("Hanifi_Rohingya", HANIFI_ROHINGYA), + ("Hanunoo", HANUNOO), + ("Hatran", HATRAN), + ("Hebrew", HEBREW), + ("Hiragana", HIRAGANA), + ("Imperial_Aramaic", IMPERIAL_ARAMAIC), + ("Inherited", INHERITED), + ("Inscriptional_Pahlavi", INSCRIPTIONAL_PAHLAVI), + ("Inscriptional_Parthian", INSCRIPTIONAL_PARTHIAN), + ("Javanese", JAVANESE), + ("Kaithi", KAITHI), + ("Kannada", KANNADA), + ("Katakana", KATAKANA), + ("Kayah_Li", KAYAH_LI), + ("Kharoshthi", KHAROSHTHI), + ("Khmer", KHMER), + ("Khojki", KHOJKI), + ("Khudawadi", KHUDAWADI), + ("Lao", LAO), + ("Latin", LATIN), + ("Lepcha", LEPCHA), + ("Limbu", LIMBU), + ("Linear_A", LINEAR_A), + ("Linear_B", LINEAR_B), + ("Lisu", LISU), + ("Lycian", LYCIAN), + ("Lydian", LYDIAN), + ("Mahajani", MAHAJANI), + ("Makasar", MAKASAR), + ("Malayalam", MALAYALAM), + ("Mandaic", MANDAIC), + ("Manichaean", MANICHAEAN), + ("Marchen", MARCHEN), + ("Masaram_Gondi", MASARAM_GONDI), + ("Medefaidrin", MEDEFAIDRIN), + ("Meetei_Mayek", MEETEI_MAYEK), + ("Mende_Kikakui", MENDE_KIKAKUI), + ("Meroitic_Cursive", MEROITIC_CURSIVE), + ("Meroitic_Hieroglyphs", MEROITIC_HIEROGLYPHS), + ("Miao", MIAO), + ("Modi", MODI), + ("Mongolian", MONGOLIAN), + ("Mro", MRO), + ("Multani", MULTANI), + ("Myanmar", MYANMAR), + ("Nabataean", NABATAEAN), + ("Nandinagari", NANDINAGARI), + ("New_Tai_Lue", NEW_TAI_LUE), + ("Newa", NEWA), + ("Nko", NKO), + ("Nushu", NUSHU), + ("Nyiakeng_Puachue_Hmong", NYIAKENG_PUACHUE_HMONG), + ("Ogham", OGHAM), + ("Ol_Chiki", OL_CHIKI), + ("Old_Hungarian", OLD_HUNGARIAN), + ("Old_Italic", OLD_ITALIC), + ("Old_North_Arabian", OLD_NORTH_ARABIAN), + ("Old_Permic", OLD_PERMIC), + ("Old_Persian", OLD_PERSIAN), + ("Old_Sogdian", OLD_SOGDIAN), + ("Old_South_Arabian", OLD_SOUTH_ARABIAN), + ("Old_Turkic", OLD_TURKIC), + ("Oriya", ORIYA), + ("Osage", OSAGE), + ("Osmanya", OSMANYA), + ("Pahawh_Hmong", PAHAWH_HMONG), + ("Palmyrene", PALMYRENE), + ("Pau_Cin_Hau", PAU_CIN_HAU), + ("Phags_Pa", PHAGS_PA), + ("Phoenician", PHOENICIAN), + ("Psalter_Pahlavi", PSALTER_PAHLAVI), + ("Rejang", REJANG), + ("Runic", RUNIC), + ("Samaritan", SAMARITAN), + ("Saurashtra", SAURASHTRA), + ("Sharada", SHARADA), + ("Shavian", SHAVIAN), + ("Siddham", SIDDHAM), + ("SignWriting", SIGNWRITING), + ("Sinhala", SINHALA), + ("Sogdian", SOGDIAN), + ("Sora_Sompeng", SORA_SOMPENG), + ("Soyombo", SOYOMBO), + ("Sundanese", SUNDANESE), + ("Syloti_Nagri", SYLOTI_NAGRI), + ("Syriac", SYRIAC), + ("Tagalog", TAGALOG), + ("Tagbanwa", TAGBANWA), + ("Tai_Le", TAI_LE), + ("Tai_Tham", TAI_THAM), + ("Tai_Viet", TAI_VIET), + ("Takri", TAKRI), + ("Tamil", TAMIL), + ("Tangut", TANGUT), + ("Telugu", TELUGU), + ("Thaana", THAANA), + ("Thai", THAI), + ("Tibetan", TIBETAN), + ("Tifinagh", TIFINAGH), + ("Tirhuta", TIRHUTA), + ("Ugaritic", UGARITIC), + ("Vai", VAI), + ("Wancho", WANCHO), + ("Warang_Citi", WARANG_CITI), + ("Yi", YI), + ("Zanabazar_Square", ZANABAZAR_SQUARE), +]; + +pub const ADLAM: &'static [(char, char)] = + &[('𞤀', '\u{1e94b}'), ('𞥐', '𞥙'), ('𞥞', '𞥟')]; + +pub const AHOM: &'static [(char, char)] = + &[('𑜀', '𑜚'), ('\u{1171d}', '\u{1172b}'), ('𑜰', '𑜿')]; + +pub const ANATOLIAN_HIEROGLYPHS: &'static [(char, char)] = &[('𔐀', '𔙆')]; + +pub const ARABIC: &'static [(char, char)] = &[ + ('\u{600}', '\u{604}'), + ('؆', '؋'), + ('؍', '\u{61a}'), + ('\u{61c}', '\u{61c}'), + ('؞', '؞'), + ('ؠ', 'ؿ'), + ('ف', 'ي'), + ('\u{656}', 'ٯ'), + ('ٱ', '\u{6dc}'), + ('۞', 'ۿ'), + ('ݐ', 'ݿ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', '\u{8ff}'), + ('ﭐ', '﯁'), + ('ﯓ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', '﷽'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('𐹠', '𐹾'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𞻰', '𞻱'), +]; + +pub const ARMENIAN: &'static [(char, char)] = + &[('Ա', 'Ֆ'), ('ՙ', 'ֈ'), ('֊', '֊'), ('֍', '֏'), ('ﬓ', 'ﬗ')]; + +pub const AVESTAN: &'static [(char, char)] = &[('𐬀', '𐬵'), ('𐬹', '𐬿')]; + +pub const BALINESE: &'static [(char, char)] = &[('\u{1b00}', 'ᭋ'), ('᭐', '᭼')]; + +pub const BAMUM: &'static [(char, char)] = &[('ꚠ', '꛷'), ('𖠀', '𖨸')]; + +pub const BASSA_VAH: &'static [(char, char)] = + &[('𖫐', '𖫭'), ('\u{16af0}', '𖫵')]; + +pub const BATAK: &'static [(char, char)] = &[('ᯀ', '᯳'), ('᯼', '᯿')]; + +pub const BENGALI: &'static [(char, char)] = &[ + ('ঀ', 'ঃ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('\u{9bc}', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', 'ৎ'), + ('\u{9d7}', '\u{9d7}'), + ('ড়', 'ঢ়'), + ('য়', '\u{9e3}'), + ('০', '\u{9fe}'), +]; + +pub const BHAIKSUKI: &'static [(char, char)] = + &[('𑰀', '𑰈'), ('𑰊', '\u{11c36}'), ('\u{11c38}', '𑱅'), ('𑱐', '𑱬')]; + +pub const BOPOMOFO: &'static [(char, char)] = + &[('˪', '˫'), ('ㄅ', 'ㄯ'), ('ㆠ', 'ㆺ')]; + +pub const BRAHMI: &'static [(char, char)] = + &[('𑀀', '𑁍'), ('𑁒', '𑁯'), ('\u{1107f}', '\u{1107f}')]; + +pub const BRAILLE: &'static [(char, char)] = &[('⠀', '⣿')]; + +pub const BUGINESE: &'static [(char, char)] = &[('ᨀ', '\u{1a1b}'), ('᨞', '᨟')]; + +pub const BUHID: &'static [(char, char)] = &[('ᝀ', '\u{1753}')]; + +pub const CANADIAN_ABORIGINAL: &'static [(char, char)] = + &[('᐀', 'ᙿ'), ('ᢰ', 'ᣵ')]; + +pub const CARIAN: &'static [(char, char)] = &[('𐊠', '𐋐')]; + +pub const CAUCASIAN_ALBANIAN: &'static [(char, char)] = + &[('𐔰', '𐕣'), ('𐕯', '𐕯')]; + +pub const CHAKMA: &'static [(char, char)] = + &[('\u{11100}', '\u{11134}'), ('𑄶', '𑅆')]; + +pub const CHAM: &'static [(char, char)] = + &[('ꨀ', '\u{aa36}'), ('ꩀ', 'ꩍ'), ('꩐', '꩙'), ('꩜', '꩟')]; + +pub const CHEROKEE: &'static [(char, char)] = + &[('Ꭰ', 'Ᏽ'), ('ᏸ', 'ᏽ'), ('ꭰ', 'ꮿ')]; + +pub const COMMON: &'static [(char, char)] = &[ + ('\u{0}', '@'), + ('[', '`'), + ('{', '©'), + ('«', '¹'), + ('»', '¿'), + ('×', '×'), + ('÷', '÷'), + ('ʹ', '˟'), + ('˥', '˩'), + ('ˬ', '˿'), + ('ʹ', 'ʹ'), + (';', ';'), + ('΅', '΅'), + ('·', '·'), + ('։', '։'), + ('\u{605}', '\u{605}'), + ('،', '،'), + ('؛', '؛'), + ('؟', '؟'), + ('ـ', 'ـ'), + ('\u{6dd}', '\u{6dd}'), + ('\u{8e2}', '\u{8e2}'), + ('।', '॥'), + ('฿', '฿'), + ('࿕', '࿘'), + ('჻', '჻'), + ('᛫', '᛭'), + ('᜵', '᜶'), + ('᠂', '᠃'), + ('᠅', '᠅'), + ('᳓', '᳓'), + ('᳡', '᳡'), + ('ᳩ', 'ᳬ'), + ('ᳮ', 'ᳳ'), + ('ᳵ', '᳷'), + ('\u{1cfa}', '\u{1cfa}'), + ('\u{2000}', '\u{200b}'), + ('\u{200e}', '\u{2064}'), + ('\u{2066}', '⁰'), + ('⁴', '⁾'), + ('₀', '₎'), + ('₠', '₿'), + ('℀', '℥'), + ('℧', '℩'), + ('ℬ', 'ℱ'), + ('ℳ', '⅍'), + ('⅏', '⅟'), + ('↉', '↋'), + ('←', '␦'), + ('⑀', '⑊'), + ('①', '⟿'), + ('⤀', '⭳'), + ('⭶', '⮕'), + ('⮘', '\u{2bff}'), + ('⸀', '\u{2e4f}'), + ('⿰', '⿻'), + ('\u{3000}', '〄'), + ('〆', '〆'), + ('〈', '〠'), + ('〰', '〷'), + ('〼', '〿'), + ('゛', '゜'), + ('゠', '゠'), + ('・', 'ー'), + ('㆐', '㆟'), + ('㇀', '㇣'), + ('㈠', '㉟'), + ('㉿', '㋏'), + ('\u{32ff}', '\u{32ff}'), + ('㍘', '㏿'), + ('䷀', '䷿'), + ('꜀', '꜡'), + ('ꞈ', '꞊'), + ('꠰', '꠹'), + ('꤮', '꤮'), + ('ꧏ', 'ꧏ'), + ('꭛', '꭛'), + ('﴾', '﴿'), + ('︐', '︙'), + ('︰', '﹒'), + ('﹔', '﹦'), + ('﹨', '﹫'), + ('\u{feff}', '\u{feff}'), + ('!', '@'), + ('[', '`'), + ('{', '・'), + ('ー', 'ー'), + ('\u{ff9e}', '\u{ff9f}'), + ('¢', '₩'), + ('│', '○'), + ('\u{fff9}', '�'), + ('𐄀', '𐄂'), + ('𐄇', '𐄳'), + ('𐄷', '𐄿'), + ('𐆐', '𐆛'), + ('𐇐', '𐇼'), + ('𐋡', '𐋻'), + ('\u{16fe2}', '\u{16fe3}'), + ('\u{1bca0}', '\u{1bca3}'), + ('𝀀', '𝃵'), + ('𝄀', '𝄦'), + ('𝄩', '𝅦'), + ('𝅪', '\u{1d17a}'), + ('𝆃', '𝆄'), + ('𝆌', '𝆩'), + ('𝆮', '𝇨'), + ('𝋠', '𝋳'), + ('𝌀', '𝍖'), + ('𝍠', '𝍸'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝟋'), + ('𝟎', '𝟿'), + ('𞱱', '𞲴'), + ('\u{1ed01}', '\u{1ed3d}'), + ('🀀', '🀫'), + ('🀰', '🂓'), + ('🂠', '🂮'), + ('🂱', '🂿'), + ('🃁', '🃏'), + ('🃑', '🃵'), + ('🄀', '🄌'), + ('🄐', '\u{1f16c}'), + ('🅰', '🆬'), + ('🇦', '🇿'), + ('🈁', '🈂'), + ('🈐', '🈻'), + ('🉀', '🉈'), + ('🉐', '🉑'), + ('🉠', '🉥'), + ('🌀', '\u{1f6d5}'), + ('🛠', '🛬'), + ('🛰', '\u{1f6fa}'), + ('🜀', '🝳'), + ('🞀', '🟘'), + ('\u{1f7e0}', '\u{1f7eb}'), + ('🠀', '🠋'), + ('🠐', '🡇'), + ('🡐', '🡙'), + ('🡠', '🢇'), + ('🢐', '🢭'), + ('🤀', '🤋'), + ('\u{1f90d}', '\u{1f971}'), + ('🥳', '🥶'), + ('🥺', '🦢'), + ('\u{1f9a5}', '\u{1f9aa}'), + ('\u{1f9ae}', '\u{1f9ca}'), + ('\u{1f9cd}', '\u{1fa53}'), + ('🩠', '🩭'), + ('\u{1fa70}', '\u{1fa73}'), + ('\u{1fa78}', '\u{1fa7a}'), + ('\u{1fa80}', '\u{1fa82}'), + ('\u{1fa90}', '\u{1fa95}'), + ('\u{e0001}', '\u{e0001}'), + ('\u{e0020}', '\u{e007f}'), +]; + +pub const COPTIC: &'static [(char, char)] = + &[('Ϣ', 'ϯ'), ('Ⲁ', 'ⳳ'), ('⳹', '⳿')]; + +pub const CUNEIFORM: &'static [(char, char)] = + &[('𒀀', '𒎙'), ('𒐀', '𒑮'), ('𒑰', '𒑴'), ('𒒀', '𒕃')]; + +pub const CYPRIOT: &'static [(char, char)] = + &[('𐠀', '𐠅'), ('𐠈', '𐠈'), ('𐠊', '𐠵'), ('𐠷', '𐠸'), ('𐠼', '𐠼'), ('𐠿', '𐠿')]; + +pub const CYRILLIC: &'static [(char, char)] = &[ + ('Ѐ', '\u{484}'), + ('\u{487}', 'ԯ'), + ('ᲀ', 'ᲈ'), + ('ᴫ', 'ᴫ'), + ('ᵸ', 'ᵸ'), + ('\u{2de0}', '\u{2dff}'), + ('Ꙁ', '\u{a69f}'), + ('\u{fe2e}', '\u{fe2f}'), +]; + +pub const DESERET: &'static [(char, char)] = &[('𐐀', '𐑏')]; + +pub const DEVANAGARI: &'static [(char, char)] = &[ + ('\u{900}', 'ॐ'), + ('\u{955}', '\u{963}'), + ('०', 'ॿ'), + ('\u{a8e0}', '\u{a8ff}'), +]; + +pub const DOGRA: &'static [(char, char)] = &[('𑠀', '𑠻')]; + +pub const DUPLOYAN: &'static [(char, char)] = + &[('𛰀', '𛱪'), ('𛱰', '𛱼'), ('𛲀', '𛲈'), ('𛲐', '𛲙'), ('𛲜', '𛲟')]; + +pub const EGYPTIAN_HIEROGLYPHS: &'static [(char, char)] = + &[('𓀀', '𓐮'), ('\u{13430}', '\u{13438}')]; + +pub const ELBASAN: &'static [(char, char)] = &[('𐔀', '𐔧')]; + +pub const ELYMAIC: &'static [(char, char)] = &[('\u{10fe0}', '\u{10ff6}')]; + +pub const ETHIOPIC: &'static [(char, char)] = &[ + ('ሀ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('\u{135d}', '፼'), + ('ᎀ', '᎙'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), +]; + +pub const GEORGIAN: &'static [(char, char)] = &[ + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჼ', 'ჿ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), +]; + +pub const GLAGOLITIC: &'static [(char, char)] = &[ + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), +]; + +pub const GOTHIC: &'static [(char, char)] = &[('𐌰', '𐍊')]; + +pub const GRANTHA: &'static [(char, char)] = &[ + ('\u{11300}', '𑌃'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('\u{1133c}', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('𑍐', '𑍐'), + ('\u{11357}', '\u{11357}'), + ('𑍝', '𑍣'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), +]; + +pub const GREEK: &'static [(char, char)] = &[ + ('Ͱ', 'ͳ'), + ('͵', 'ͷ'), + ('ͺ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('΄', '΄'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϡ'), + ('ϰ', 'Ͽ'), + ('ᴦ', 'ᴪ'), + ('ᵝ', 'ᵡ'), + ('ᵦ', 'ᵪ'), + ('ᶿ', 'ᶿ'), + ('ἀ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ῄ'), + ('ῆ', 'ΐ'), + ('ῖ', 'Ί'), + ('῝', '`'), + ('ῲ', 'ῴ'), + ('ῶ', '῾'), + ('Ω', 'Ω'), + ('ꭥ', 'ꭥ'), + ('𐅀', '𐆎'), + ('𐆠', '𐆠'), + ('𝈀', '𝉅'), +]; + +pub const GUJARATI: &'static [(char, char)] = &[ + ('\u{a81}', 'ઃ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('\u{abc}', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', '\u{acd}'), + ('ૐ', 'ૐ'), + ('ૠ', '\u{ae3}'), + ('૦', '૱'), + ('ૹ', '\u{aff}'), +]; + +pub const GUNJALA_GONDI: &'static [(char, char)] = &[ + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '𑶘'), + ('𑶠', '𑶩'), +]; + +pub const GURMUKHI: &'static [(char, char)] = &[ + ('\u{a01}', 'ਃ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('\u{a3c}', '\u{a3c}'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('੦', '੶'), +]; + +pub const HAN: &'static [(char, char)] = &[ + ('⺀', '⺙'), + ('⺛', '⻳'), + ('⼀', '⿕'), + ('々', '々'), + ('〇', '〇'), + ('〡', '〩'), + ('〸', '〻'), + ('㐀', '䶵'), + ('一', '鿯'), + ('豈', '舘'), + ('並', '龎'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), +]; + +pub const HANGUL: &'static [(char, char)] = &[ + ('ᄀ', 'ᇿ'), + ('\u{302e}', '\u{302f}'), + ('ㄱ', 'ㆎ'), + ('㈀', '㈞'), + ('㉠', '㉾'), + ('ꥠ', 'ꥼ'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('ᅠ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), +]; + +pub const HANIFI_ROHINGYA: &'static [(char, char)] = + &[('𐴀', '\u{10d27}'), ('𐴰', '𐴹')]; + +pub const HANUNOO: &'static [(char, char)] = &[('ᜠ', '\u{1734}')]; + +pub const HATRAN: &'static [(char, char)] = + &[('𐣠', '𐣲'), ('𐣴', '𐣵'), ('𐣻', '𐣿')]; + +pub const HEBREW: &'static [(char, char)] = &[ + ('\u{591}', '\u{5c7}'), + ('א', 'ת'), + ('ׯ', '״'), + ('יִ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﭏ'), +]; + +pub const HIRAGANA: &'static [(char, char)] = &[ + ('ぁ', 'ゖ'), + ('ゝ', 'ゟ'), + ('𛀁', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('🈀', '🈀'), +]; + +pub const IMPERIAL_ARAMAIC: &'static [(char, char)] = + &[('𐡀', '𐡕'), ('𐡗', '𐡟')]; + +pub const INHERITED: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), + ('\u{485}', '\u{486}'), + ('\u{64b}', '\u{655}'), + ('\u{670}', '\u{670}'), + ('\u{951}', '\u{954}'), + ('\u{1ab0}', '\u{1abe}'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1ce0}'), + ('\u{1ce2}', '\u{1ce8}'), + ('\u{1ced}', '\u{1ced}'), + ('\u{1cf4}', '\u{1cf4}'), + ('\u{1cf8}', '\u{1cf9}'), + ('\u{1dc0}', '\u{1df9}'), + ('\u{1dfb}', '\u{1dff}'), + ('\u{200c}', '\u{200d}'), + ('\u{20d0}', '\u{20f0}'), + ('\u{302a}', '\u{302d}'), + ('\u{3099}', '\u{309a}'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2d}'), + ('\u{101fd}', '\u{101fd}'), + ('\u{102e0}', '\u{102e0}'), + ('\u{1133b}', '\u{1133b}'), + ('\u{1d167}', '\u{1d169}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const INSCRIPTIONAL_PAHLAVI: &'static [(char, char)] = + &[('𐭠', '𐭲'), ('𐭸', '𐭿')]; + +pub const INSCRIPTIONAL_PARTHIAN: &'static [(char, char)] = + &[('𐭀', '𐭕'), ('𐭘', '𐭟')]; + +pub const JAVANESE: &'static [(char, char)] = + &[('\u{a980}', '꧍'), ('꧐', '꧙'), ('꧞', '꧟')]; + +pub const KAITHI: &'static [(char, char)] = + &[('\u{11080}', '𑃁'), ('\u{110cd}', '\u{110cd}')]; + +pub const KANNADA: &'static [(char, char)] = &[ + ('ಀ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('\u{cbc}', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('ೞ', 'ೞ'), + ('ೠ', '\u{ce3}'), + ('೦', '೯'), + ('ೱ', 'ೲ'), +]; + +pub const KATAKANA: &'static [(char, char)] = &[ + ('ァ', 'ヺ'), + ('ヽ', 'ヿ'), + ('ㇰ', 'ㇿ'), + ('㋐', '㋾'), + ('㌀', '㍗'), + ('ヲ', 'ッ'), + ('ア', 'ン'), + ('𛀀', '𛀀'), + ('\u{1b164}', '\u{1b167}'), +]; + +pub const KAYAH_LI: &'static [(char, char)] = &[('꤀', '\u{a92d}'), ('꤯', '꤯')]; + +pub const KHAROSHTHI: &'static [(char, char)] = &[ + ('𐨀', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '𐩈'), + ('𐩐', '𐩘'), +]; + +pub const KHMER: &'static [(char, char)] = + &[('ក', '\u{17dd}'), ('០', '៩'), ('៰', '៹'), ('᧠', '᧿')]; + +pub const KHOJKI: &'static [(char, char)] = &[('𑈀', '𑈑'), ('𑈓', '\u{1123e}')]; + +pub const KHUDAWADI: &'static [(char, char)] = + &[('𑊰', '\u{112ea}'), ('𑋰', '𑋹')]; + +pub const LAO: &'static [(char, char)] = &[ + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('\u{ec8}', '\u{ecd}'), + ('໐', '໙'), + ('ໜ', 'ໟ'), +]; + +pub const LATIN: &'static [(char, char)] = &[ + ('A', 'Z'), + ('a', 'z'), + ('ª', 'ª'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ʸ'), + ('ˠ', 'ˤ'), + ('ᴀ', 'ᴥ'), + ('ᴬ', 'ᵜ'), + ('ᵢ', 'ᵥ'), + ('ᵫ', 'ᵷ'), + ('ᵹ', 'ᶾ'), + ('Ḁ', 'ỿ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('K', 'Å'), + ('Ⅎ', 'Ⅎ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ↈ'), + ('Ⱡ', 'Ɀ'), + ('Ꜣ', 'ꞇ'), + ('Ꞌ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꟿ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', 'ꭤ'), + ('\u{ab66}', '\u{ab67}'), + ('ff', 'st'), + ('A', 'Z'), + ('a', 'z'), +]; + +pub const LEPCHA: &'static [(char, char)] = + &[('ᰀ', '\u{1c37}'), ('᰻', '᱉'), ('ᱍ', 'ᱏ')]; + +pub const LIMBU: &'static [(char, char)] = &[ + ('ᤀ', 'ᤞ'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', '\u{193b}'), + ('᥀', '᥀'), + ('᥄', '᥏'), +]; + +pub const LINEAR_A: &'static [(char, char)] = + &[('𐘀', '𐜶'), ('𐝀', '𐝕'), ('𐝠', '𐝧')]; + +pub const LINEAR_B: &'static [(char, char)] = &[ + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), +]; + +pub const LISU: &'static [(char, char)] = &[('ꓐ', '꓿')]; + +pub const LYCIAN: &'static [(char, char)] = &[('𐊀', '𐊜')]; + +pub const LYDIAN: &'static [(char, char)] = &[('𐤠', '𐤹'), ('𐤿', '𐤿')]; + +pub const MAHAJANI: &'static [(char, char)] = &[('𑅐', '𑅶')]; + +pub const MAKASAR: &'static [(char, char)] = &[('𑻠', '𑻸')]; + +pub const MALAYALAM: &'static [(char, char)] = &[ + ('\u{d00}', 'ഃ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', '\u{d44}'), + ('െ', 'ൈ'), + ('ൊ', '൏'), + ('ൔ', '\u{d63}'), + ('൦', 'ൿ'), +]; + +pub const MANDAIC: &'static [(char, char)] = &[('ࡀ', '\u{85b}'), ('࡞', '࡞')]; + +pub const MANICHAEAN: &'static [(char, char)] = + &[('𐫀', '\u{10ae6}'), ('𐫫', '𐫶')]; + +pub const MARCHEN: &'static [(char, char)] = + &[('𑱰', '𑲏'), ('\u{11c92}', '\u{11ca7}'), ('𑲩', '\u{11cb6}')]; + +pub const MASARAM_GONDI: &'static [(char, char)] = &[ + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d47}'), + ('𑵐', '𑵙'), +]; + +pub const MEDEFAIDRIN: &'static [(char, char)] = &[('𖹀', '𖺚')]; + +pub const MEETEI_MAYEK: &'static [(char, char)] = + &[('ꫠ', '\u{aaf6}'), ('ꯀ', '\u{abed}'), ('꯰', '꯹')]; + +pub const MENDE_KIKAKUI: &'static [(char, char)] = + &[('𞠀', '𞣄'), ('𞣇', '\u{1e8d6}')]; + +pub const MEROITIC_CURSIVE: &'static [(char, char)] = + &[('𐦠', '𐦷'), ('𐦼', '𐧏'), ('𐧒', '𐧿')]; + +pub const MEROITIC_HIEROGLYPHS: &'static [(char, char)] = &[('𐦀', '𐦟')]; + +pub const MIAO: &'static [(char, char)] = + &[('𖼀', '\u{16f4a}'), ('\u{16f4f}', '\u{16f87}'), ('\u{16f8f}', '𖾟')]; + +pub const MODI: &'static [(char, char)] = &[('𑘀', '𑙄'), ('𑙐', '𑙙')]; + +pub const MONGOLIAN: &'static [(char, char)] = &[ + ('᠀', '᠁'), + ('᠄', '᠄'), + ('᠆', '\u{180e}'), + ('᠐', '᠙'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢪ'), + ('𑙠', '𑙬'), +]; + +pub const MRO: &'static [(char, char)] = &[('𖩀', '𖩞'), ('𖩠', '𖩩'), ('𖩮', '𖩯')]; + +pub const MULTANI: &'static [(char, char)] = + &[('𑊀', '𑊆'), ('𑊈', '𑊈'), ('𑊊', '𑊍'), ('𑊏', '𑊝'), ('𑊟', '𑊩')]; + +pub const MYANMAR: &'static [(char, char)] = + &[('က', '႟'), ('ꧠ', 'ꧾ'), ('ꩠ', 'ꩿ')]; + +pub const NABATAEAN: &'static [(char, char)] = &[('𐢀', '𐢞'), ('𐢧', '𐢯')]; + +pub const NANDINAGARI: &'static [(char, char)] = &[ + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d7}'), + ('\u{119da}', '\u{119e4}'), +]; + +pub const NEW_TAI_LUE: &'static [(char, char)] = + &[('ᦀ', 'ᦫ'), ('ᦰ', 'ᧉ'), ('᧐', '᧚'), ('᧞', '᧟')]; + +pub const NEWA: &'static [(char, char)] = + &[('𑐀', '𑑙'), ('𑑛', '𑑛'), ('𑑝', '\u{1145f}')]; + +pub const NKO: &'static [(char, char)] = &[('߀', 'ߺ'), ('\u{7fd}', '߿')]; + +pub const NUSHU: &'static [(char, char)] = &[('𖿡', '𖿡'), ('𛅰', '𛋻')]; + +pub const NYIAKENG_PUACHUE_HMONG: &'static [(char, char)] = &[ + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e130}', '\u{1e13d}'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e14e}', '\u{1e14f}'), +]; + +pub const OGHAM: &'static [(char, char)] = &[('\u{1680}', '᚜')]; + +pub const OL_CHIKI: &'static [(char, char)] = &[('᱐', '᱿')]; + +pub const OLD_HUNGARIAN: &'static [(char, char)] = + &[('𐲀', '𐲲'), ('𐳀', '𐳲'), ('𐳺', '𐳿')]; + +pub const OLD_ITALIC: &'static [(char, char)] = &[('𐌀', '𐌣'), ('𐌭', '𐌯')]; + +pub const OLD_NORTH_ARABIAN: &'static [(char, char)] = &[('𐪀', '𐪟')]; + +pub const OLD_PERMIC: &'static [(char, char)] = &[('𐍐', '\u{1037a}')]; + +pub const OLD_PERSIAN: &'static [(char, char)] = &[('𐎠', '𐏃'), ('𐏈', '𐏕')]; + +pub const OLD_SOGDIAN: &'static [(char, char)] = &[('𐼀', '𐼧')]; + +pub const OLD_SOUTH_ARABIAN: &'static [(char, char)] = &[('𐩠', '𐩿')]; + +pub const OLD_TURKIC: &'static [(char, char)] = &[('𐰀', '𐱈')]; + +pub const ORIYA: &'static [(char, char)] = &[ + ('\u{b01}', 'ଃ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('\u{b3c}', '\u{b44}'), + ('େ', 'ୈ'), + ('ୋ', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', '\u{b63}'), + ('୦', '୷'), +]; + +pub const OSAGE: &'static [(char, char)] = &[('𐒰', '𐓓'), ('𐓘', '𐓻')]; + +pub const OSMANYA: &'static [(char, char)] = &[('𐒀', '𐒝'), ('𐒠', '𐒩')]; + +pub const PAHAWH_HMONG: &'static [(char, char)] = + &[('𖬀', '𖭅'), ('𖭐', '𖭙'), ('𖭛', '𖭡'), ('𖭣', '𖭷'), ('𖭽', '𖮏')]; + +pub const PALMYRENE: &'static [(char, char)] = &[('𐡠', '𐡿')]; + +pub const PAU_CIN_HAU: &'static [(char, char)] = &[('𑫀', '𑫸')]; + +pub const PHAGS_PA: &'static [(char, char)] = &[('ꡀ', '꡷')]; + +pub const PHOENICIAN: &'static [(char, char)] = &[('𐤀', '𐤛'), ('𐤟', '𐤟')]; + +pub const PSALTER_PAHLAVI: &'static [(char, char)] = + &[('𐮀', '𐮑'), ('𐮙', '𐮜'), ('𐮩', '𐮯')]; + +pub const REJANG: &'static [(char, char)] = &[('ꤰ', '꥓'), ('꥟', '꥟')]; + +pub const RUNIC: &'static [(char, char)] = &[('ᚠ', 'ᛪ'), ('ᛮ', 'ᛸ')]; + +pub const SAMARITAN: &'static [(char, char)] = &[('ࠀ', '\u{82d}'), ('࠰', '࠾')]; + +pub const SAURASHTRA: &'static [(char, char)] = + &[('ꢀ', '\u{a8c5}'), ('꣎', '꣙')]; + +pub const SHARADA: &'static [(char, char)] = &[('\u{11180}', '𑇍'), ('𑇐', '𑇟')]; + +pub const SHAVIAN: &'static [(char, char)] = &[('𐑐', '𐑿')]; + +pub const SIDDHAM: &'static [(char, char)] = + &[('𑖀', '\u{115b5}'), ('𑖸', '\u{115dd}')]; + +pub const SIGNWRITING: &'static [(char, char)] = + &[('𝠀', '𝪋'), ('\u{1da9b}', '\u{1da9f}'), ('\u{1daa1}', '\u{1daaf}')]; + +pub const SINHALA: &'static [(char, char)] = &[ + ('ං', 'ඃ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('෦', '෯'), + ('ෲ', '෴'), + ('𑇡', '𑇴'), +]; + +pub const SOGDIAN: &'static [(char, char)] = &[('𐼰', '𐽙')]; + +pub const SORA_SOMPENG: &'static [(char, char)] = &[('𑃐', '𑃨'), ('𑃰', '𑃹')]; + +pub const SOYOMBO: &'static [(char, char)] = &[('𑩐', '𑪢')]; + +pub const SUNDANESE: &'static [(char, char)] = + &[('\u{1b80}', 'ᮿ'), ('᳀', '᳇')]; + +pub const SYLOTI_NAGRI: &'static [(char, char)] = &[('ꠀ', '꠫')]; + +pub const SYRIAC: &'static [(char, char)] = + &[('܀', '܍'), ('\u{70f}', '\u{74a}'), ('ݍ', 'ݏ'), ('ࡠ', 'ࡪ')]; + +pub const TAGALOG: &'static [(char, char)] = &[('ᜀ', 'ᜌ'), ('ᜎ', '\u{1714}')]; + +pub const TAGBANWA: &'static [(char, char)] = + &[('ᝠ', 'ᝬ'), ('ᝮ', 'ᝰ'), ('\u{1772}', '\u{1773}')]; + +pub const TAI_LE: &'static [(char, char)] = &[('ᥐ', 'ᥭ'), ('ᥰ', 'ᥴ')]; + +pub const TAI_THAM: &'static [(char, char)] = &[ + ('ᨠ', '\u{1a5e}'), + ('\u{1a60}', '\u{1a7c}'), + ('\u{1a7f}', '᪉'), + ('᪐', '᪙'), + ('᪠', '᪭'), +]; + +pub const TAI_VIET: &'static [(char, char)] = &[('ꪀ', 'ꫂ'), ('ꫛ', '꫟')]; + +pub const TAKRI: &'static [(char, char)] = &[('𑚀', '\u{116b8}'), ('𑛀', '𑛉')]; + +pub const TAMIL: &'static [(char, char)] = &[ + ('\u{b82}', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', '\u{bcd}'), + ('ௐ', 'ௐ'), + ('\u{bd7}', '\u{bd7}'), + ('௦', '௺'), + ('\u{11fc0}', '\u{11ff1}'), + ('\u{11fff}', '\u{11fff}'), +]; + +pub const TANGUT: &'static [(char, char)] = + &[('𖿠', '𖿠'), ('𗀀', '\u{187f7}'), ('𘠀', '𘫲')]; + +pub const TELUGU: &'static [(char, char)] = &[ + ('\u{c00}', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('ౘ', 'ౚ'), + ('ౠ', '\u{c63}'), + ('౦', '౯'), + ('\u{c77}', '౿'), +]; + +pub const THAANA: &'static [(char, char)] = &[('ހ', 'ޱ')]; + +pub const THAI: &'static [(char, char)] = &[('ก', '\u{e3a}'), ('เ', '๛')]; + +pub const TIBETAN: &'static [(char, char)] = &[ + ('ༀ', 'ཇ'), + ('ཉ', 'ཬ'), + ('\u{f71}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('྾', '࿌'), + ('࿎', '࿔'), + ('࿙', '࿚'), +]; + +pub const TIFINAGH: &'static [(char, char)] = + &[('ⴰ', 'ⵧ'), ('ⵯ', '⵰'), ('\u{2d7f}', '\u{2d7f}')]; + +pub const TIRHUTA: &'static [(char, char)] = &[('𑒀', '𑓇'), ('𑓐', '𑓙')]; + +pub const UGARITIC: &'static [(char, char)] = &[('𐎀', '𐎝'), ('𐎟', '𐎟')]; + +pub const VAI: &'static [(char, char)] = &[('ꔀ', 'ꘫ')]; + +pub const WANCHO: &'static [(char, char)] = + &[('\u{1e2c0}', '\u{1e2f9}'), ('\u{1e2ff}', '\u{1e2ff}')]; + +pub const WARANG_CITI: &'static [(char, char)] = &[('𑢠', '𑣲'), ('𑣿', '𑣿')]; + +pub const YI: &'static [(char, char)] = &[('ꀀ', 'ꒌ'), ('꒐', '꓆')]; + +pub const ZANABAZAR_SQUARE: &'static [(char, char)] = &[('𑨀', '\u{11a47}')]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/script_extension.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/script_extension.rs new file mode 100644 index 0000000..aa3894e --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/script_extension.rs @@ -0,0 +1,1359 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate script-extension /tmp/ucd/12.1.0/ --chars +// +// ucd-generate is available on crates.io. + +pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] = &[ + ("Adlam", ADLAM), + ("Ahom", AHOM), + ("Anatolian_Hieroglyphs", ANATOLIAN_HIEROGLYPHS), + ("Arabic", ARABIC), + ("Armenian", ARMENIAN), + ("Avestan", AVESTAN), + ("Balinese", BALINESE), + ("Bamum", BAMUM), + ("Bassa_Vah", BASSA_VAH), + ("Batak", BATAK), + ("Bengali", BENGALI), + ("Bhaiksuki", BHAIKSUKI), + ("Bopomofo", BOPOMOFO), + ("Brahmi", BRAHMI), + ("Braille", BRAILLE), + ("Buginese", BUGINESE), + ("Buhid", BUHID), + ("Canadian_Aboriginal", CANADIAN_ABORIGINAL), + ("Carian", CARIAN), + ("Caucasian_Albanian", CAUCASIAN_ALBANIAN), + ("Chakma", CHAKMA), + ("Cham", CHAM), + ("Cherokee", CHEROKEE), + ("Common", COMMON), + ("Coptic", COPTIC), + ("Cuneiform", CUNEIFORM), + ("Cypriot", CYPRIOT), + ("Cyrillic", CYRILLIC), + ("Deseret", DESERET), + ("Devanagari", DEVANAGARI), + ("Dogra", DOGRA), + ("Duployan", DUPLOYAN), + ("Egyptian_Hieroglyphs", EGYPTIAN_HIEROGLYPHS), + ("Elbasan", ELBASAN), + ("Elymaic", ELYMAIC), + ("Ethiopic", ETHIOPIC), + ("Georgian", GEORGIAN), + ("Glagolitic", GLAGOLITIC), + ("Gothic", GOTHIC), + ("Grantha", GRANTHA), + ("Greek", GREEK), + ("Gujarati", GUJARATI), + ("Gunjala_Gondi", GUNJALA_GONDI), + ("Gurmukhi", GURMUKHI), + ("Han", HAN), + ("Hangul", HANGUL), + ("Hanifi_Rohingya", HANIFI_ROHINGYA), + ("Hanunoo", HANUNOO), + ("Hatran", HATRAN), + ("Hebrew", HEBREW), + ("Hiragana", HIRAGANA), + ("Imperial_Aramaic", IMPERIAL_ARAMAIC), + ("Inherited", INHERITED), + ("Inscriptional_Pahlavi", INSCRIPTIONAL_PAHLAVI), + ("Inscriptional_Parthian", INSCRIPTIONAL_PARTHIAN), + ("Javanese", JAVANESE), + ("Kaithi", KAITHI), + ("Kannada", KANNADA), + ("Katakana", KATAKANA), + ("Kayah_Li", KAYAH_LI), + ("Kharoshthi", KHAROSHTHI), + ("Khmer", KHMER), + ("Khojki", KHOJKI), + ("Khudawadi", KHUDAWADI), + ("Lao", LAO), + ("Latin", LATIN), + ("Lepcha", LEPCHA), + ("Limbu", LIMBU), + ("Linear_A", LINEAR_A), + ("Linear_B", LINEAR_B), + ("Lisu", LISU), + ("Lycian", LYCIAN), + ("Lydian", LYDIAN), + ("Mahajani", MAHAJANI), + ("Makasar", MAKASAR), + ("Malayalam", MALAYALAM), + ("Mandaic", MANDAIC), + ("Manichaean", MANICHAEAN), + ("Marchen", MARCHEN), + ("Masaram_Gondi", MASARAM_GONDI), + ("Medefaidrin", MEDEFAIDRIN), + ("Meetei_Mayek", MEETEI_MAYEK), + ("Mende_Kikakui", MENDE_KIKAKUI), + ("Meroitic_Cursive", MEROITIC_CURSIVE), + ("Meroitic_Hieroglyphs", MEROITIC_HIEROGLYPHS), + ("Miao", MIAO), + ("Modi", MODI), + ("Mongolian", MONGOLIAN), + ("Mro", MRO), + ("Multani", MULTANI), + ("Myanmar", MYANMAR), + ("Nabataean", NABATAEAN), + ("Nandinagari", NANDINAGARI), + ("New_Tai_Lue", NEW_TAI_LUE), + ("Newa", NEWA), + ("Nko", NKO), + ("Nushu", NUSHU), + ("Nyiakeng_Puachue_Hmong", NYIAKENG_PUACHUE_HMONG), + ("Ogham", OGHAM), + ("Ol_Chiki", OL_CHIKI), + ("Old_Hungarian", OLD_HUNGARIAN), + ("Old_Italic", OLD_ITALIC), + ("Old_North_Arabian", OLD_NORTH_ARABIAN), + ("Old_Permic", OLD_PERMIC), + ("Old_Persian", OLD_PERSIAN), + ("Old_Sogdian", OLD_SOGDIAN), + ("Old_South_Arabian", OLD_SOUTH_ARABIAN), + ("Old_Turkic", OLD_TURKIC), + ("Oriya", ORIYA), + ("Osage", OSAGE), + ("Osmanya", OSMANYA), + ("Pahawh_Hmong", PAHAWH_HMONG), + ("Palmyrene", PALMYRENE), + ("Pau_Cin_Hau", PAU_CIN_HAU), + ("Phags_Pa", PHAGS_PA), + ("Phoenician", PHOENICIAN), + ("Psalter_Pahlavi", PSALTER_PAHLAVI), + ("Rejang", REJANG), + ("Runic", RUNIC), + ("Samaritan", SAMARITAN), + ("Saurashtra", SAURASHTRA), + ("Sharada", SHARADA), + ("Shavian", SHAVIAN), + ("Siddham", SIDDHAM), + ("SignWriting", SIGNWRITING), + ("Sinhala", SINHALA), + ("Sogdian", SOGDIAN), + ("Sora_Sompeng", SORA_SOMPENG), + ("Soyombo", SOYOMBO), + ("Sundanese", SUNDANESE), + ("Syloti_Nagri", SYLOTI_NAGRI), + ("Syriac", SYRIAC), + ("Tagalog", TAGALOG), + ("Tagbanwa", TAGBANWA), + ("Tai_Le", TAI_LE), + ("Tai_Tham", TAI_THAM), + ("Tai_Viet", TAI_VIET), + ("Takri", TAKRI), + ("Tamil", TAMIL), + ("Tangut", TANGUT), + ("Telugu", TELUGU), + ("Thaana", THAANA), + ("Thai", THAI), + ("Tibetan", TIBETAN), + ("Tifinagh", TIFINAGH), + ("Tirhuta", TIRHUTA), + ("Ugaritic", UGARITIC), + ("Vai", VAI), + ("Wancho", WANCHO), + ("Warang_Citi", WARANG_CITI), + ("Yi", YI), + ("Zanabazar_Square", ZANABAZAR_SQUARE), +]; + +pub const ADLAM: &'static [(char, char)] = + &[('ـ', 'ـ'), ('𞤀', '\u{1e94b}'), ('𞥐', '𞥙'), ('𞥞', '𞥟')]; + +pub const AHOM: &'static [(char, char)] = + &[('𑜀', '𑜚'), ('\u{1171d}', '\u{1172b}'), ('𑜰', '𑜿')]; + +pub const ANATOLIAN_HIEROGLYPHS: &'static [(char, char)] = &[('𔐀', '𔙆')]; + +pub const ARABIC: &'static [(char, char)] = &[ + ('\u{600}', '\u{604}'), + ('؆', '\u{61c}'), + ('؞', '\u{6dc}'), + ('۞', 'ۿ'), + ('ݐ', 'ݿ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', '\u{8ff}'), + ('ﭐ', '﯁'), + ('ﯓ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', '﷽'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('\u{102e0}', '𐋻'), + ('𐹠', '𐹾'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𞻰', '𞻱'), +]; + +pub const ARMENIAN: &'static [(char, char)] = + &[('Ա', 'Ֆ'), ('ՙ', '֊'), ('֍', '֏'), ('ﬓ', 'ﬗ')]; + +pub const AVESTAN: &'static [(char, char)] = &[('𐬀', '𐬵'), ('𐬹', '𐬿')]; + +pub const BALINESE: &'static [(char, char)] = &[('\u{1b00}', 'ᭋ'), ('᭐', '᭼')]; + +pub const BAMUM: &'static [(char, char)] = &[('ꚠ', '꛷'), ('𖠀', '𖨸')]; + +pub const BASSA_VAH: &'static [(char, char)] = + &[('𖫐', '𖫭'), ('\u{16af0}', '𖫵')]; + +pub const BATAK: &'static [(char, char)] = &[('ᯀ', '᯳'), ('᯼', '᯿')]; + +pub const BENGALI: &'static [(char, char)] = &[ + ('\u{951}', '\u{952}'), + ('।', '॥'), + ('ঀ', 'ঃ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('\u{9bc}', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', 'ৎ'), + ('\u{9d7}', '\u{9d7}'), + ('ড়', 'ঢ়'), + ('য়', '\u{9e3}'), + ('০', '\u{9fe}'), + ('\u{1cd0}', '\u{1cd0}'), + ('\u{1cd2}', '\u{1cd2}'), + ('\u{1cd5}', '\u{1cd6}'), + ('\u{1cd8}', '\u{1cd8}'), + ('᳡', '᳡'), + ('ᳪ', 'ᳪ'), + ('\u{1ced}', '\u{1ced}'), + ('ᳲ', 'ᳲ'), + ('ᳵ', '᳷'), + ('\u{a8f1}', '\u{a8f1}'), +]; + +pub const BHAIKSUKI: &'static [(char, char)] = + &[('𑰀', '𑰈'), ('𑰊', '\u{11c36}'), ('\u{11c38}', '𑱅'), ('𑱐', '𑱬')]; + +pub const BOPOMOFO: &'static [(char, char)] = &[ + ('˪', '˫'), + ('、', '〃'), + ('〈', '】'), + ('〓', '〟'), + ('\u{302a}', '\u{302d}'), + ('〰', '〰'), + ('〷', '〷'), + ('・', '・'), + ('ㄅ', 'ㄯ'), + ('ㆠ', 'ㆺ'), + ('﹅', '﹆'), + ('。', '・'), +]; + +pub const BRAHMI: &'static [(char, char)] = + &[('𑀀', '𑁍'), ('𑁒', '𑁯'), ('\u{1107f}', '\u{1107f}')]; + +pub const BRAILLE: &'static [(char, char)] = &[('⠀', '⣿')]; + +pub const BUGINESE: &'static [(char, char)] = + &[('ᨀ', '\u{1a1b}'), ('᨞', '᨟'), ('ꧏ', 'ꧏ')]; + +pub const BUHID: &'static [(char, char)] = &[('᜵', '᜶'), ('ᝀ', '\u{1753}')]; + +pub const CANADIAN_ABORIGINAL: &'static [(char, char)] = + &[('᐀', 'ᙿ'), ('ᢰ', 'ᣵ')]; + +pub const CARIAN: &'static [(char, char)] = &[('𐊠', '𐋐')]; + +pub const CAUCASIAN_ALBANIAN: &'static [(char, char)] = + &[('𐔰', '𐕣'), ('𐕯', '𐕯')]; + +pub const CHAKMA: &'static [(char, char)] = + &[('০', '৯'), ('၀', '၉'), ('\u{11100}', '\u{11134}'), ('𑄶', '𑅆')]; + +pub const CHAM: &'static [(char, char)] = + &[('ꨀ', '\u{aa36}'), ('ꩀ', 'ꩍ'), ('꩐', '꩙'), ('꩜', '꩟')]; + +pub const CHEROKEE: &'static [(char, char)] = + &[('Ꭰ', 'Ᏽ'), ('ᏸ', 'ᏽ'), ('ꭰ', 'ꮿ')]; + +pub const COMMON: &'static [(char, char)] = &[ + ('\u{0}', '@'), + ('[', '`'), + ('{', '©'), + ('«', '¹'), + ('»', '¿'), + ('×', '×'), + ('÷', '÷'), + ('ʹ', '˟'), + ('˥', '˩'), + ('ˬ', '˿'), + ('ʹ', 'ʹ'), + (';', ';'), + ('΅', '΅'), + ('·', '·'), + ('\u{605}', '\u{605}'), + ('\u{6dd}', '\u{6dd}'), + ('\u{8e2}', '\u{8e2}'), + ('฿', '฿'), + ('࿕', '࿘'), + ('᛫', '᛭'), + ('\u{2000}', '\u{200b}'), + ('\u{200e}', '\u{202e}'), + ('‰', '\u{2064}'), + ('\u{2066}', '⁰'), + ('⁴', '⁾'), + ('₀', '₎'), + ('₠', '₿'), + ('℀', '℥'), + ('℧', '℩'), + ('ℬ', 'ℱ'), + ('ℳ', '⅍'), + ('⅏', '⅟'), + ('↉', '↋'), + ('←', '␦'), + ('⑀', '⑊'), + ('①', '⟿'), + ('⤀', '⭳'), + ('⭶', '⮕'), + ('⮘', '\u{2bff}'), + ('⸀', '⹂'), + ('⹄', '\u{2e4f}'), + ('⿰', '⿻'), + ('\u{3000}', '\u{3000}'), + ('〄', '〄'), + ('〒', '〒'), + ('〠', '〠'), + ('〶', '〶'), + ('㉈', '㉟'), + ('㉿', '㉿'), + ('㊱', '㊿'), + ('㋌', '㋏'), + ('㍱', '㍺'), + ('㎀', '㏟'), + ('㏿', '㏿'), + ('䷀', '䷿'), + ('꜀', '꜡'), + ('ꞈ', '꞊'), + ('꭛', '꭛'), + ('﴾', '﴿'), + ('︐', '︙'), + ('︰', '﹄'), + ('﹇', '﹒'), + ('﹔', '﹦'), + ('﹨', '﹫'), + ('\u{feff}', '\u{feff}'), + ('!', '@'), + ('[', '`'), + ('{', '⦆'), + ('¢', '₩'), + ('│', '○'), + ('\u{fff9}', '�'), + ('𐆐', '𐆛'), + ('𐇐', '𐇼'), + ('\u{16fe2}', '\u{16fe3}'), + ('𝀀', '𝃵'), + ('𝄀', '𝄦'), + ('𝄩', '𝅦'), + ('𝅪', '\u{1d17a}'), + ('𝆃', '𝆄'), + ('𝆌', '𝆩'), + ('𝆮', '𝇨'), + ('𝋠', '𝋳'), + ('𝌀', '𝍖'), + ('𝍲', '𝍸'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝟋'), + ('𝟎', '𝟿'), + ('𞱱', '𞲴'), + ('\u{1ed01}', '\u{1ed3d}'), + ('🀀', '🀫'), + ('🀰', '🂓'), + ('🂠', '🂮'), + ('🂱', '🂿'), + ('🃁', '🃏'), + ('🃑', '🃵'), + ('🄀', '🄌'), + ('🄐', '\u{1f16c}'), + ('🅰', '🆬'), + ('🇦', '🇿'), + ('🈁', '🈂'), + ('🈐', '🈻'), + ('🉀', '🉈'), + ('🉠', '🉥'), + ('🌀', '\u{1f6d5}'), + ('🛠', '🛬'), + ('🛰', '\u{1f6fa}'), + ('🜀', '🝳'), + ('🞀', '🟘'), + ('\u{1f7e0}', '\u{1f7eb}'), + ('🠀', '🠋'), + ('🠐', '🡇'), + ('🡐', '🡙'), + ('🡠', '🢇'), + ('🢐', '🢭'), + ('🤀', '🤋'), + ('\u{1f90d}', '\u{1f971}'), + ('🥳', '🥶'), + ('🥺', '🦢'), + ('\u{1f9a5}', '\u{1f9aa}'), + ('\u{1f9ae}', '\u{1f9ca}'), + ('\u{1f9cd}', '\u{1fa53}'), + ('🩠', '🩭'), + ('\u{1fa70}', '\u{1fa73}'), + ('\u{1fa78}', '\u{1fa7a}'), + ('\u{1fa80}', '\u{1fa82}'), + ('\u{1fa90}', '\u{1fa95}'), + ('\u{e0001}', '\u{e0001}'), + ('\u{e0020}', '\u{e007f}'), +]; + +pub const COPTIC: &'static [(char, char)] = + &[('Ϣ', 'ϯ'), ('Ⲁ', 'ⳳ'), ('⳹', '⳿'), ('\u{102e0}', '𐋻')]; + +pub const CUNEIFORM: &'static [(char, char)] = + &[('𒀀', '𒎙'), ('𒐀', '𒑮'), ('𒑰', '𒑴'), ('𒒀', '𒕃')]; + +pub const CYPRIOT: &'static [(char, char)] = &[ + ('𐄀', '𐄂'), + ('𐄇', '𐄳'), + ('𐄷', '𐄿'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐠿'), +]; + +pub const CYRILLIC: &'static [(char, char)] = &[ + ('Ѐ', 'ԯ'), + ('ᲀ', 'ᲈ'), + ('ᴫ', 'ᴫ'), + ('ᵸ', 'ᵸ'), + ('\u{2de0}', '\u{2dff}'), + ('⹃', '⹃'), + ('Ꙁ', '\u{a69f}'), + ('\u{fe2e}', '\u{fe2f}'), +]; + +pub const DESERET: &'static [(char, char)] = &[('𐐀', '𐑏')]; + +pub const DEVANAGARI: &'static [(char, char)] = &[ + ('\u{900}', '\u{952}'), + ('\u{955}', 'ॿ'), + ('\u{1cd0}', 'ᳶ'), + ('\u{1cf8}', '\u{1cf9}'), + ('\u{20f0}', '\u{20f0}'), + ('꠰', '꠹'), + ('\u{a8e0}', '\u{a8ff}'), +]; + +pub const DOGRA: &'static [(char, char)] = + &[('।', '९'), ('꠰', '꠹'), ('𑠀', '𑠻')]; + +pub const DUPLOYAN: &'static [(char, char)] = + &[('𛰀', '𛱪'), ('𛱰', '𛱼'), ('𛲀', '𛲈'), ('𛲐', '𛲙'), ('𛲜', '\u{1bca3}')]; + +pub const EGYPTIAN_HIEROGLYPHS: &'static [(char, char)] = + &[('𓀀', '𓐮'), ('\u{13430}', '\u{13438}')]; + +pub const ELBASAN: &'static [(char, char)] = &[('𐔀', '𐔧')]; + +pub const ELYMAIC: &'static [(char, char)] = &[('\u{10fe0}', '\u{10ff6}')]; + +pub const ETHIOPIC: &'static [(char, char)] = &[ + ('ሀ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('\u{135d}', '፼'), + ('ᎀ', '᎙'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), +]; + +pub const GEORGIAN: &'static [(char, char)] = &[ + ('։', '։'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჿ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), +]; + +pub const GLAGOLITIC: &'static [(char, char)] = &[ + ('\u{484}', '\u{484}'), + ('\u{487}', '\u{487}'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('⹃', '⹃'), + ('\u{a66f}', '\u{a66f}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), +]; + +pub const GOTHIC: &'static [(char, char)] = &[('𐌰', '𐍊')]; + +pub const GRANTHA: &'static [(char, char)] = &[ + ('\u{951}', '\u{952}'), + ('।', '॥'), + ('௦', '௳'), + ('\u{1cd0}', '\u{1cd0}'), + ('\u{1cd2}', '᳓'), + ('ᳲ', '\u{1cf4}'), + ('\u{1cf8}', '\u{1cf9}'), + ('\u{20f0}', '\u{20f0}'), + ('\u{11300}', '𑌃'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('\u{1133b}', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('𑍐', '𑍐'), + ('\u{11357}', '\u{11357}'), + ('𑍝', '𑍣'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('\u{11fd0}', '\u{11fd1}'), + ('\u{11fd3}', '\u{11fd3}'), +]; + +pub const GREEK: &'static [(char, char)] = &[ + ('\u{342}', '\u{342}'), + ('\u{345}', '\u{345}'), + ('Ͱ', 'ͳ'), + ('͵', 'ͷ'), + ('ͺ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('΄', '΄'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϡ'), + ('ϰ', 'Ͽ'), + ('ᴦ', 'ᴪ'), + ('ᵝ', 'ᵡ'), + ('ᵦ', 'ᵪ'), + ('ᶿ', '\u{1dc1}'), + ('ἀ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ῄ'), + ('ῆ', 'ΐ'), + ('ῖ', 'Ί'), + ('῝', '`'), + ('ῲ', 'ῴ'), + ('ῶ', '῾'), + ('Ω', 'Ω'), + ('ꭥ', 'ꭥ'), + ('𐅀', '𐆎'), + ('𐆠', '𐆠'), + ('𝈀', '𝉅'), +]; + +pub const GUJARATI: &'static [(char, char)] = &[ + ('\u{951}', '\u{952}'), + ('।', '॥'), + ('\u{a81}', 'ઃ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('\u{abc}', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', '\u{acd}'), + ('ૐ', 'ૐ'), + ('ૠ', '\u{ae3}'), + ('૦', '૱'), + ('ૹ', '\u{aff}'), + ('꠰', '꠹'), +]; + +pub const GUNJALA_GONDI: &'static [(char, char)] = &[ + ('।', '॥'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '𑶘'), + ('𑶠', '𑶩'), +]; + +pub const GURMUKHI: &'static [(char, char)] = &[ + ('\u{951}', '\u{952}'), + ('।', '॥'), + ('\u{a01}', 'ਃ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('\u{a3c}', '\u{a3c}'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('੦', '੶'), + ('꠰', '꠹'), +]; + +pub const HAN: &'static [(char, char)] = &[ + ('⺀', '⺙'), + ('⺛', '⻳'), + ('⼀', '⿕'), + ('、', '〃'), + ('々', '】'), + ('〓', '〟'), + ('〡', '\u{302d}'), + ('〰', '〰'), + ('〷', '〿'), + ('・', '・'), + ('㆐', '㆟'), + ('㇀', '㇣'), + ('㈠', '㉇'), + ('㊀', '㊰'), + ('㋀', '㋋'), + ('\u{32ff}', '\u{32ff}'), + ('㍘', '㍰'), + ('㍻', '㍿'), + ('㏠', '㏾'), + ('㐀', '䶵'), + ('一', '鿯'), + ('豈', '舘'), + ('並', '龎'), + ('﹅', '﹆'), + ('。', '・'), + ('𝍠', '𝍱'), + ('🉐', '🉑'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), +]; + +pub const HANGUL: &'static [(char, char)] = &[ + ('ᄀ', 'ᇿ'), + ('、', '〃'), + ('〈', '】'), + ('〓', '〟'), + ('\u{302e}', '〰'), + ('〷', '〷'), + ('・', '・'), + ('ㄱ', 'ㆎ'), + ('㈀', '㈞'), + ('㉠', '㉾'), + ('ꥠ', 'ꥼ'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('﹅', '﹆'), + ('。', '・'), + ('ᅠ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), +]; + +pub const HANIFI_ROHINGYA: &'static [(char, char)] = &[ + ('،', '،'), + ('؛', '؛'), + ('؟', '؟'), + ('ـ', 'ـ'), + ('۔', '۔'), + ('𐴀', '\u{10d27}'), + ('𐴰', '𐴹'), +]; + +pub const HANUNOO: &'static [(char, char)] = &[('ᜠ', '᜶')]; + +pub const HATRAN: &'static [(char, char)] = + &[('𐣠', '𐣲'), ('𐣴', '𐣵'), ('𐣻', '𐣿')]; + +pub const HEBREW: &'static [(char, char)] = &[ + ('\u{591}', '\u{5c7}'), + ('א', 'ת'), + ('ׯ', '״'), + ('יִ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﭏ'), +]; + +pub const HIRAGANA: &'static [(char, char)] = &[ + ('、', '〃'), + ('〈', '】'), + ('〓', '〟'), + ('〰', '〵'), + ('〷', '〷'), + ('〼', '〽'), + ('ぁ', 'ゖ'), + ('\u{3099}', '゠'), + ('・', 'ー'), + ('﹅', '﹆'), + ('。', '・'), + ('ー', 'ー'), + ('\u{ff9e}', '\u{ff9f}'), + ('𛀁', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('🈀', '🈀'), +]; + +pub const IMPERIAL_ARAMAIC: &'static [(char, char)] = + &[('𐡀', '𐡕'), ('𐡗', '𐡟')]; + +pub const INHERITED: &'static [(char, char)] = &[ + ('\u{300}', '\u{341}'), + ('\u{343}', '\u{344}'), + ('\u{346}', '\u{362}'), + ('\u{953}', '\u{954}'), + ('\u{1ab0}', '\u{1abe}'), + ('\u{1dc2}', '\u{1df9}'), + ('\u{1dfb}', '\u{1dff}'), + ('\u{200c}', '\u{200d}'), + ('\u{20d0}', '\u{20ef}'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2d}'), + ('\u{101fd}', '\u{101fd}'), + ('\u{1d167}', '\u{1d169}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const INSCRIPTIONAL_PAHLAVI: &'static [(char, char)] = + &[('𐭠', '𐭲'), ('𐭸', '𐭿')]; + +pub const INSCRIPTIONAL_PARTHIAN: &'static [(char, char)] = + &[('𐭀', '𐭕'), ('𐭘', '𐭟')]; + +pub const JAVANESE: &'static [(char, char)] = + &[('\u{a980}', '꧍'), ('ꧏ', '꧙'), ('꧞', '꧟')]; + +pub const KAITHI: &'static [(char, char)] = + &[('०', '९'), ('꠰', '꠹'), ('\u{11080}', '𑃁'), ('\u{110cd}', '\u{110cd}')]; + +pub const KANNADA: &'static [(char, char)] = &[ + ('\u{951}', '\u{952}'), + ('।', '॥'), + ('ಀ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('\u{cbc}', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('ೞ', 'ೞ'), + ('ೠ', '\u{ce3}'), + ('೦', '೯'), + ('ೱ', 'ೲ'), + ('\u{1cd0}', '\u{1cd0}'), + ('\u{1cd2}', '\u{1cd2}'), + ('\u{1cda}', '\u{1cda}'), + ('ᳲ', 'ᳲ'), + ('\u{1cf4}', '\u{1cf4}'), + ('꠰', '꠵'), +]; + +pub const KATAKANA: &'static [(char, char)] = &[ + ('、', '〃'), + ('〈', '】'), + ('〓', '〟'), + ('〰', '〵'), + ('〷', '〷'), + ('〼', '〽'), + ('\u{3099}', '゜'), + ('゠', 'ヿ'), + ('ㇰ', 'ㇿ'), + ('㋐', '㋾'), + ('㌀', '㍗'), + ('﹅', '﹆'), + ('。', '\u{ff9f}'), + ('𛀀', '𛀀'), + ('\u{1b164}', '\u{1b167}'), +]; + +pub const KAYAH_LI: &'static [(char, char)] = &[('꤀', '꤯')]; + +pub const KHAROSHTHI: &'static [(char, char)] = &[ + ('𐨀', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '𐩈'), + ('𐩐', '𐩘'), +]; + +pub const KHMER: &'static [(char, char)] = + &[('ក', '\u{17dd}'), ('០', '៩'), ('៰', '៹'), ('᧠', '᧿')]; + +pub const KHOJKI: &'static [(char, char)] = + &[('૦', '૯'), ('꠰', '꠹'), ('𑈀', '𑈑'), ('𑈓', '\u{1123e}')]; + +pub const KHUDAWADI: &'static [(char, char)] = + &[('।', '॥'), ('꠰', '꠹'), ('𑊰', '\u{112ea}'), ('𑋰', '𑋹')]; + +pub const LAO: &'static [(char, char)] = &[ + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('\u{ec8}', '\u{ecd}'), + ('໐', '໙'), + ('ໜ', 'ໟ'), +]; + +pub const LATIN: &'static [(char, char)] = &[ + ('A', 'Z'), + ('a', 'z'), + ('ª', 'ª'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', 'ʸ'), + ('ˠ', 'ˤ'), + ('\u{363}', '\u{36f}'), + ('\u{485}', '\u{486}'), + ('\u{951}', '\u{952}'), + ('჻', '჻'), + ('ᴀ', 'ᴥ'), + ('ᴬ', 'ᵜ'), + ('ᵢ', 'ᵥ'), + ('ᵫ', 'ᵷ'), + ('ᵹ', 'ᶾ'), + ('Ḁ', 'ỿ'), + ('\u{202f}', '\u{202f}'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('\u{20f0}', '\u{20f0}'), + ('K', 'Å'), + ('Ⅎ', 'Ⅎ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ↈ'), + ('Ⱡ', 'Ɀ'), + ('Ꜣ', 'ꞇ'), + ('Ꞌ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꟿ'), + ('꤮', '꤮'), + ('ꬰ', 'ꭚ'), + ('ꭜ', 'ꭤ'), + ('\u{ab66}', '\u{ab67}'), + ('ff', 'st'), + ('A', 'Z'), + ('a', 'z'), +]; + +pub const LEPCHA: &'static [(char, char)] = + &[('ᰀ', '\u{1c37}'), ('᰻', '᱉'), ('ᱍ', 'ᱏ')]; + +pub const LIMBU: &'static [(char, char)] = &[ + ('॥', '॥'), + ('ᤀ', 'ᤞ'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', '\u{193b}'), + ('᥀', '᥀'), + ('᥄', '᥏'), +]; + +pub const LINEAR_A: &'static [(char, char)] = + &[('𐄇', '𐄳'), ('𐘀', '𐜶'), ('𐝀', '𐝕'), ('𐝠', '𐝧')]; + +pub const LINEAR_B: &'static [(char, char)] = &[ + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐄀', '𐄂'), + ('𐄇', '𐄳'), + ('𐄷', '𐄿'), +]; + +pub const LISU: &'static [(char, char)] = &[('ꓐ', '꓿')]; + +pub const LYCIAN: &'static [(char, char)] = &[('𐊀', '𐊜')]; + +pub const LYDIAN: &'static [(char, char)] = &[('𐤠', '𐤹'), ('𐤿', '𐤿')]; + +pub const MAHAJANI: &'static [(char, char)] = + &[('।', '९'), ('꠰', '꠹'), ('𑅐', '𑅶')]; + +pub const MAKASAR: &'static [(char, char)] = &[('𑻠', '𑻸')]; + +pub const MALAYALAM: &'static [(char, char)] = &[ + ('\u{951}', '\u{952}'), + ('।', '॥'), + ('\u{d00}', 'ഃ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', '\u{d44}'), + ('െ', 'ൈ'), + ('ൊ', '൏'), + ('ൔ', '\u{d63}'), + ('൦', 'ൿ'), + ('\u{1cda}', '\u{1cda}'), + ('꠰', '꠲'), +]; + +pub const MANDAIC: &'static [(char, char)] = + &[('ـ', 'ـ'), ('ࡀ', '\u{85b}'), ('࡞', '࡞')]; + +pub const MANICHAEAN: &'static [(char, char)] = + &[('ـ', 'ـ'), ('𐫀', '\u{10ae6}'), ('𐫫', '𐫶')]; + +pub const MARCHEN: &'static [(char, char)] = + &[('𑱰', '𑲏'), ('\u{11c92}', '\u{11ca7}'), ('𑲩', '\u{11cb6}')]; + +pub const MASARAM_GONDI: &'static [(char, char)] = &[ + ('।', '॥'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d47}'), + ('𑵐', '𑵙'), +]; + +pub const MEDEFAIDRIN: &'static [(char, char)] = &[('𖹀', '𖺚')]; + +pub const MEETEI_MAYEK: &'static [(char, char)] = + &[('ꫠ', '\u{aaf6}'), ('ꯀ', '\u{abed}'), ('꯰', '꯹')]; + +pub const MENDE_KIKAKUI: &'static [(char, char)] = + &[('𞠀', '𞣄'), ('𞣇', '\u{1e8d6}')]; + +pub const MEROITIC_CURSIVE: &'static [(char, char)] = + &[('𐦠', '𐦷'), ('𐦼', '𐧏'), ('𐧒', '𐧿')]; + +pub const MEROITIC_HIEROGLYPHS: &'static [(char, char)] = &[('𐦀', '𐦟')]; + +pub const MIAO: &'static [(char, char)] = + &[('𖼀', '\u{16f4a}'), ('\u{16f4f}', '\u{16f87}'), ('\u{16f8f}', '𖾟')]; + +pub const MODI: &'static [(char, char)] = + &[('꠰', '꠹'), ('𑘀', '𑙄'), ('𑙐', '𑙙')]; + +pub const MONGOLIAN: &'static [(char, char)] = &[ + ('᠀', '\u{180e}'), + ('᠐', '᠙'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢪ'), + ('\u{202f}', '\u{202f}'), + ('𑙠', '𑙬'), +]; + +pub const MRO: &'static [(char, char)] = &[('𖩀', '𖩞'), ('𖩠', '𖩩'), ('𖩮', '𖩯')]; + +pub const MULTANI: &'static [(char, char)] = + &[('੦', '੯'), ('𑊀', '𑊆'), ('𑊈', '𑊈'), ('𑊊', '𑊍'), ('𑊏', '𑊝'), ('𑊟', '𑊩')]; + +pub const MYANMAR: &'static [(char, char)] = + &[('က', '႟'), ('꤮', '꤮'), ('ꧠ', 'ꧾ'), ('ꩠ', 'ꩿ')]; + +pub const NABATAEAN: &'static [(char, char)] = &[('𐢀', '𐢞'), ('𐢧', '𐢯')]; + +pub const NANDINAGARI: &'static [(char, char)] = &[ + ('।', '॥'), + ('೦', '೯'), + ('ᳩ', 'ᳩ'), + ('ᳲ', 'ᳲ'), + ('\u{1cfa}', '\u{1cfa}'), + ('꠰', '꠵'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d7}'), + ('\u{119da}', '\u{119e4}'), +]; + +pub const NEW_TAI_LUE: &'static [(char, char)] = + &[('ᦀ', 'ᦫ'), ('ᦰ', 'ᧉ'), ('᧐', '᧚'), ('᧞', '᧟')]; + +pub const NEWA: &'static [(char, char)] = + &[('𑐀', '𑑙'), ('𑑛', '𑑛'), ('𑑝', '\u{1145f}')]; + +pub const NKO: &'static [(char, char)] = &[('߀', 'ߺ'), ('\u{7fd}', '߿')]; + +pub const NUSHU: &'static [(char, char)] = &[('𖿡', '𖿡'), ('𛅰', '𛋻')]; + +pub const NYIAKENG_PUACHUE_HMONG: &'static [(char, char)] = &[ + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e130}', '\u{1e13d}'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e14e}', '\u{1e14f}'), +]; + +pub const OGHAM: &'static [(char, char)] = &[('\u{1680}', '᚜')]; + +pub const OL_CHIKI: &'static [(char, char)] = &[('᱐', '᱿')]; + +pub const OLD_HUNGARIAN: &'static [(char, char)] = + &[('𐲀', '𐲲'), ('𐳀', '𐳲'), ('𐳺', '𐳿')]; + +pub const OLD_ITALIC: &'static [(char, char)] = &[('𐌀', '𐌣'), ('𐌭', '𐌯')]; + +pub const OLD_NORTH_ARABIAN: &'static [(char, char)] = &[('𐪀', '𐪟')]; + +pub const OLD_PERMIC: &'static [(char, char)] = + &[('\u{483}', '\u{483}'), ('𐍐', '\u{1037a}')]; + +pub const OLD_PERSIAN: &'static [(char, char)] = &[('𐎠', '𐏃'), ('𐏈', '𐏕')]; + +pub const OLD_SOGDIAN: &'static [(char, char)] = &[('𐼀', '𐼧')]; + +pub const OLD_SOUTH_ARABIAN: &'static [(char, char)] = &[('𐩠', '𐩿')]; + +pub const OLD_TURKIC: &'static [(char, char)] = &[('𐰀', '𐱈')]; + +pub const ORIYA: &'static [(char, char)] = &[ + ('\u{951}', '\u{952}'), + ('।', '॥'), + ('\u{b01}', 'ଃ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('\u{b3c}', '\u{b44}'), + ('େ', 'ୈ'), + ('ୋ', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', '\u{b63}'), + ('୦', '୷'), + ('\u{1cda}', '\u{1cda}'), + ('ᳲ', 'ᳲ'), +]; + +pub const OSAGE: &'static [(char, char)] = &[('𐒰', '𐓓'), ('𐓘', '𐓻')]; + +pub const OSMANYA: &'static [(char, char)] = &[('𐒀', '𐒝'), ('𐒠', '𐒩')]; + +pub const PAHAWH_HMONG: &'static [(char, char)] = + &[('𖬀', '𖭅'), ('𖭐', '𖭙'), ('𖭛', '𖭡'), ('𖭣', '𖭷'), ('𖭽', '𖮏')]; + +pub const PALMYRENE: &'static [(char, char)] = &[('𐡠', '𐡿')]; + +pub const PAU_CIN_HAU: &'static [(char, char)] = &[('𑫀', '𑫸')]; + +pub const PHAGS_PA: &'static [(char, char)] = + &[('᠂', '᠃'), ('᠅', '᠅'), ('ꡀ', '꡷')]; + +pub const PHOENICIAN: &'static [(char, char)] = &[('𐤀', '𐤛'), ('𐤟', '𐤟')]; + +pub const PSALTER_PAHLAVI: &'static [(char, char)] = + &[('ـ', 'ـ'), ('𐮀', '𐮑'), ('𐮙', '𐮜'), ('𐮩', '𐮯')]; + +pub const REJANG: &'static [(char, char)] = &[('ꤰ', '꥓'), ('꥟', '꥟')]; + +pub const RUNIC: &'static [(char, char)] = &[('ᚠ', 'ᛪ'), ('ᛮ', 'ᛸ')]; + +pub const SAMARITAN: &'static [(char, char)] = &[('ࠀ', '\u{82d}'), ('࠰', '࠾')]; + +pub const SAURASHTRA: &'static [(char, char)] = + &[('ꢀ', '\u{a8c5}'), ('꣎', '꣙')]; + +pub const SHARADA: &'static [(char, char)] = &[ + ('\u{951}', '\u{951}'), + ('\u{1cd7}', '\u{1cd7}'), + ('\u{1cd9}', '\u{1cd9}'), + ('\u{1cdc}', '\u{1cdd}'), + ('\u{1ce0}', '\u{1ce0}'), + ('\u{11180}', '𑇍'), + ('𑇐', '𑇟'), +]; + +pub const SHAVIAN: &'static [(char, char)] = &[('𐑐', '𐑿')]; + +pub const SIDDHAM: &'static [(char, char)] = + &[('𑖀', '\u{115b5}'), ('𑖸', '\u{115dd}')]; + +pub const SIGNWRITING: &'static [(char, char)] = + &[('𝠀', '𝪋'), ('\u{1da9b}', '\u{1da9f}'), ('\u{1daa1}', '\u{1daaf}')]; + +pub const SINHALA: &'static [(char, char)] = &[ + ('।', '॥'), + ('ං', 'ඃ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('෦', '෯'), + ('ෲ', '෴'), + ('𑇡', '𑇴'), +]; + +pub const SOGDIAN: &'static [(char, char)] = &[('ـ', 'ـ'), ('𐼰', '𐽙')]; + +pub const SORA_SOMPENG: &'static [(char, char)] = &[('𑃐', '𑃨'), ('𑃰', '𑃹')]; + +pub const SOYOMBO: &'static [(char, char)] = &[('𑩐', '𑪢')]; + +pub const SUNDANESE: &'static [(char, char)] = + &[('\u{1b80}', 'ᮿ'), ('᳀', '᳇')]; + +pub const SYLOTI_NAGRI: &'static [(char, char)] = + &[('।', '॥'), ('০', '৯'), ('ꠀ', '꠫')]; + +pub const SYRIAC: &'static [(char, char)] = &[ + ('،', '،'), + ('؛', '\u{61c}'), + ('؟', '؟'), + ('ـ', 'ـ'), + ('\u{64b}', '\u{655}'), + ('\u{670}', '\u{670}'), + ('܀', '܍'), + ('\u{70f}', '\u{74a}'), + ('ݍ', 'ݏ'), + ('ࡠ', 'ࡪ'), +]; + +pub const TAGALOG: &'static [(char, char)] = + &[('ᜀ', 'ᜌ'), ('ᜎ', '\u{1714}'), ('᜵', '᜶')]; + +pub const TAGBANWA: &'static [(char, char)] = + &[('᜵', '᜶'), ('ᝠ', 'ᝬ'), ('ᝮ', 'ᝰ'), ('\u{1772}', '\u{1773}')]; + +pub const TAI_LE: &'static [(char, char)] = + &[('၀', '၉'), ('ᥐ', 'ᥭ'), ('ᥰ', 'ᥴ')]; + +pub const TAI_THAM: &'static [(char, char)] = &[ + ('ᨠ', '\u{1a5e}'), + ('\u{1a60}', '\u{1a7c}'), + ('\u{1a7f}', '᪉'), + ('᪐', '᪙'), + ('᪠', '᪭'), +]; + +pub const TAI_VIET: &'static [(char, char)] = &[('ꪀ', 'ꫂ'), ('ꫛ', '꫟')]; + +pub const TAKRI: &'static [(char, char)] = + &[('।', '॥'), ('꠰', '꠹'), ('𑚀', '\u{116b8}'), ('𑛀', '𑛉')]; + +pub const TAMIL: &'static [(char, char)] = &[ + ('\u{951}', '\u{952}'), + ('।', '॥'), + ('\u{b82}', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', '\u{bcd}'), + ('ௐ', 'ௐ'), + ('\u{bd7}', '\u{bd7}'), + ('௦', '௺'), + ('\u{1cda}', '\u{1cda}'), + ('ꣳ', 'ꣳ'), + ('\u{11301}', '\u{11301}'), + ('𑌃', '𑌃'), + ('\u{1133b}', '\u{1133c}'), + ('\u{11fc0}', '\u{11ff1}'), + ('\u{11fff}', '\u{11fff}'), +]; + +pub const TANGUT: &'static [(char, char)] = + &[('𖿠', '𖿠'), ('𗀀', '\u{187f7}'), ('𘠀', '𘫲')]; + +pub const TELUGU: &'static [(char, char)] = &[ + ('\u{951}', '\u{952}'), + ('।', '॥'), + ('\u{c00}', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('ౘ', 'ౚ'), + ('ౠ', '\u{c63}'), + ('౦', '౯'), + ('\u{c77}', '౿'), + ('\u{1cda}', '\u{1cda}'), + ('ᳲ', 'ᳲ'), +]; + +pub const THAANA: &'static [(char, char)] = &[ + ('،', '،'), + ('؛', '\u{61c}'), + ('؟', '؟'), + ('٠', '٩'), + ('ހ', 'ޱ'), + ('ﷲ', 'ﷲ'), + ('﷽', '﷽'), +]; + +pub const THAI: &'static [(char, char)] = &[('ก', '\u{e3a}'), ('เ', '๛')]; + +pub const TIBETAN: &'static [(char, char)] = &[ + ('ༀ', 'ཇ'), + ('ཉ', 'ཬ'), + ('\u{f71}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('྾', '࿌'), + ('࿎', '࿔'), + ('࿙', '࿚'), +]; + +pub const TIFINAGH: &'static [(char, char)] = + &[('ⴰ', 'ⵧ'), ('ⵯ', '⵰'), ('\u{2d7f}', '\u{2d7f}')]; + +pub const TIRHUTA: &'static [(char, char)] = &[ + ('\u{951}', '\u{952}'), + ('।', '॥'), + ('ᳲ', 'ᳲ'), + ('꠰', '꠹'), + ('𑒀', '𑓇'), + ('𑓐', '𑓙'), +]; + +pub const UGARITIC: &'static [(char, char)] = &[('𐎀', '𐎝'), ('𐎟', '𐎟')]; + +pub const VAI: &'static [(char, char)] = &[('ꔀ', 'ꘫ')]; + +pub const WANCHO: &'static [(char, char)] = + &[('\u{1e2c0}', '\u{1e2f9}'), ('\u{1e2ff}', '\u{1e2ff}')]; + +pub const WARANG_CITI: &'static [(char, char)] = &[('𑢠', '𑣲'), ('𑣿', '𑣿')]; + +pub const YI: &'static [(char, char)] = &[ + ('、', '。'), + ('〈', '】'), + ('〔', '〛'), + ('・', '・'), + ('ꀀ', 'ꒌ'), + ('꒐', '꓆'), + ('。', '・'), +]; + +pub const ZANABAZAR_SQUARE: &'static [(char, char)] = &[('𑨀', '\u{11a47}')]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/sentence_break.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/sentence_break.rs new file mode 100644 index 0000000..2ee7ae5 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/sentence_break.rs @@ -0,0 +1,2361 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate sentence-break /tmp/ucd/12.1.0/ --chars +// +// ucd-generate is available on crates.io. + +pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] = &[ + ("ATerm", ATERM), + ("CR", CR), + ("Close", CLOSE), + ("Extend", EXTEND), + ("Format", FORMAT), + ("LF", LF), + ("Lower", LOWER), + ("Numeric", NUMERIC), + ("OLetter", OLETTER), + ("SContinue", SCONTINUE), + ("STerm", STERM), + ("Sep", SEP), + ("Sp", SP), + ("Upper", UPPER), +]; + +pub const ATERM: &'static [(char, char)] = + &[('.', '.'), ('․', '․'), ('﹒', '﹒'), ('.', '.')]; + +pub const CR: &'static [(char, char)] = &[('\r', '\r')]; + +pub const CLOSE: &'static [(char, char)] = &[ + ('\"', '\"'), + ('\'', ')'), + ('[', '['), + (']', ']'), + ('{', '{'), + ('}', '}'), + ('«', '«'), + ('»', '»'), + ('༺', '༽'), + ('᚛', '᚜'), + ('‘', '‟'), + ('‹', '›'), + ('⁅', '⁆'), + ('⁽', '⁾'), + ('₍', '₎'), + ('⌈', '⌋'), + ('〈', '〉'), + ('❛', '❠'), + ('❨', '❵'), + ('⟅', '⟆'), + ('⟦', '⟯'), + ('⦃', '⦘'), + ('⧘', '⧛'), + ('⧼', '⧽'), + ('⸀', '⸍'), + ('⸜', '⸝'), + ('⸠', '⸩'), + ('⹂', '⹂'), + ('〈', '】'), + ('〔', '〛'), + ('〝', '〟'), + ('﴾', '﴿'), + ('︗', '︘'), + ('︵', '﹄'), + ('﹇', '﹈'), + ('﹙', '﹞'), + ('(', ')'), + ('[', '['), + (']', ']'), + ('{', '{'), + ('}', '}'), + ('⦅', '⦆'), + ('「', '」'), + ('🙶', '🙸'), +]; + +pub const EXTEND: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), + ('\u{483}', '\u{489}'), + ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('\u{610}', '\u{61a}'), + ('\u{64b}', '\u{65f}'), + ('\u{670}', '\u{670}'), + ('\u{6d6}', '\u{6dc}'), + ('\u{6df}', '\u{6e4}'), + ('\u{6e7}', '\u{6e8}'), + ('\u{6ea}', '\u{6ed}'), + ('\u{711}', '\u{711}'), + ('\u{730}', '\u{74a}'), + ('\u{7a6}', '\u{7b0}'), + ('\u{7eb}', '\u{7f3}'), + ('\u{7fd}', '\u{7fd}'), + ('\u{816}', '\u{819}'), + ('\u{81b}', '\u{823}'), + ('\u{825}', '\u{827}'), + ('\u{829}', '\u{82d}'), + ('\u{859}', '\u{85b}'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', 'ः'), + ('\u{93a}', '\u{93c}'), + ('ा', 'ॏ'), + ('\u{951}', '\u{957}'), + ('\u{962}', '\u{963}'), + ('\u{981}', 'ঃ'), + ('\u{9bc}', '\u{9bc}'), + ('\u{9be}', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', '\u{9cd}'), + ('\u{9d7}', '\u{9d7}'), + ('\u{9e2}', '\u{9e3}'), + ('\u{9fe}', '\u{9fe}'), + ('\u{a01}', 'ਃ'), + ('\u{a3c}', '\u{a3c}'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('\u{a70}', '\u{a71}'), + ('\u{a75}', '\u{a75}'), + ('\u{a81}', 'ઃ'), + ('\u{abc}', '\u{abc}'), + ('ા', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', '\u{acd}'), + ('\u{ae2}', '\u{ae3}'), + ('\u{afa}', '\u{aff}'), + ('\u{b01}', 'ଃ'), + ('\u{b3c}', '\u{b3c}'), + ('\u{b3e}', '\u{b44}'), + ('େ', 'ୈ'), + ('ୋ', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('\u{b62}', '\u{b63}'), + ('\u{b82}', '\u{b82}'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', '\u{bcd}'), + ('\u{bd7}', '\u{bd7}'), + ('\u{c00}', '\u{c04}'), + ('\u{c3e}', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('\u{c62}', '\u{c63}'), + ('\u{c81}', 'ಃ'), + ('\u{cbc}', '\u{cbc}'), + ('ಾ', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('\u{ce2}', '\u{ce3}'), + ('\u{d00}', 'ഃ'), + ('\u{d3b}', '\u{d3c}'), + ('\u{d3e}', '\u{d44}'), + ('െ', 'ൈ'), + ('ൊ', '\u{d4d}'), + ('\u{d57}', '\u{d57}'), + ('\u{d62}', '\u{d63}'), + ('ං', 'ඃ'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('ෲ', 'ෳ'), + ('\u{e31}', '\u{e31}'), + ('\u{e34}', '\u{e3a}'), + ('\u{e47}', '\u{e4e}'), + ('\u{eb1}', '\u{eb1}'), + ('\u{eb4}', '\u{ebc}'), + ('\u{ec8}', '\u{ecd}'), + ('\u{f18}', '\u{f19}'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('༾', '༿'), + ('\u{f71}', '\u{f84}'), + ('\u{f86}', '\u{f87}'), + ('\u{f8d}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), + ('ါ', '\u{103e}'), + ('ၖ', '\u{1059}'), + ('\u{105e}', '\u{1060}'), + ('ၢ', 'ၤ'), + ('ၧ', 'ၭ'), + ('\u{1071}', '\u{1074}'), + ('\u{1082}', '\u{108d}'), + ('ႏ', 'ႏ'), + ('ႚ', '\u{109d}'), + ('\u{135d}', '\u{135f}'), + ('\u{1712}', '\u{1714}'), + ('\u{1732}', '\u{1734}'), + ('\u{1752}', '\u{1753}'), + ('\u{1772}', '\u{1773}'), + ('\u{17b4}', '\u{17d3}'), + ('\u{17dd}', '\u{17dd}'), + ('\u{180b}', '\u{180d}'), + ('\u{1885}', '\u{1886}'), + ('\u{18a9}', '\u{18a9}'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', '\u{193b}'), + ('\u{1a17}', '\u{1a1b}'), + ('ᩕ', '\u{1a5e}'), + ('\u{1a60}', '\u{1a7c}'), + ('\u{1a7f}', '\u{1a7f}'), + ('\u{1ab0}', '\u{1abe}'), + ('\u{1b00}', 'ᬄ'), + ('\u{1b34}', '᭄'), + ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', 'ᮂ'), + ('ᮡ', '\u{1bad}'), + ('\u{1be6}', '᯳'), + ('ᰤ', '\u{1c37}'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1ce8}'), + ('\u{1ced}', '\u{1ced}'), + ('\u{1cf4}', '\u{1cf4}'), + ('᳷', '\u{1cf9}'), + ('\u{1dc0}', '\u{1df9}'), + ('\u{1dfb}', '\u{1dff}'), + ('\u{200c}', '\u{200d}'), + ('\u{20d0}', '\u{20f0}'), + ('\u{2cef}', '\u{2cf1}'), + ('\u{2d7f}', '\u{2d7f}'), + ('\u{2de0}', '\u{2dff}'), + ('\u{302a}', '\u{302f}'), + ('\u{3099}', '\u{309a}'), + ('\u{a66f}', '\u{a672}'), + ('\u{a674}', '\u{a67d}'), + ('\u{a69e}', '\u{a69f}'), + ('\u{a6f0}', '\u{a6f1}'), + ('\u{a802}', '\u{a802}'), + ('\u{a806}', '\u{a806}'), + ('\u{a80b}', '\u{a80b}'), + ('ꠣ', 'ꠧ'), + ('ꢀ', 'ꢁ'), + ('ꢴ', '\u{a8c5}'), + ('\u{a8e0}', '\u{a8f1}'), + ('\u{a8ff}', '\u{a8ff}'), + ('\u{a926}', '\u{a92d}'), + ('\u{a947}', '꥓'), + ('\u{a980}', 'ꦃ'), + ('\u{a9b3}', '꧀'), + ('\u{a9e5}', '\u{a9e5}'), + ('\u{aa29}', '\u{aa36}'), + ('\u{aa43}', '\u{aa43}'), + ('\u{aa4c}', 'ꩍ'), + ('ꩻ', 'ꩽ'), + ('\u{aab0}', '\u{aab0}'), + ('\u{aab2}', '\u{aab4}'), + ('\u{aab7}', '\u{aab8}'), + ('\u{aabe}', '\u{aabf}'), + ('\u{aac1}', '\u{aac1}'), + ('ꫫ', 'ꫯ'), + ('ꫵ', '\u{aaf6}'), + ('ꯣ', 'ꯪ'), + ('꯬', '\u{abed}'), + ('\u{fb1e}', '\u{fb1e}'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2f}'), + ('\u{ff9e}', '\u{ff9f}'), + ('\u{101fd}', '\u{101fd}'), + ('\u{102e0}', '\u{102e0}'), + ('\u{10376}', '\u{1037a}'), + ('\u{10a01}', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a0f}'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), + ('\u{10ae5}', '\u{10ae6}'), + ('\u{10d24}', '\u{10d27}'), + ('\u{10f46}', '\u{10f50}'), + ('𑀀', '𑀂'), + ('\u{11038}', '\u{11046}'), + ('\u{1107f}', '𑂂'), + ('𑂰', '\u{110ba}'), + ('\u{11100}', '\u{11102}'), + ('\u{11127}', '\u{11134}'), + ('𑅅', '𑅆'), + ('\u{11173}', '\u{11173}'), + ('\u{11180}', '𑆂'), + ('𑆳', '𑇀'), + ('\u{111c9}', '\u{111cc}'), + ('𑈬', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('\u{112df}', '\u{112ea}'), + ('\u{11300}', '𑌃'), + ('\u{1133b}', '\u{1133c}'), + ('\u{1133e}', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('\u{11357}', '\u{11357}'), + ('𑍢', '𑍣'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('𑐵', '\u{11446}'), + ('\u{1145e}', '\u{1145e}'), + ('\u{114b0}', '\u{114c3}'), + ('\u{115af}', '\u{115b5}'), + ('𑖸', '\u{115c0}'), + ('\u{115dc}', '\u{115dd}'), + ('𑘰', '\u{11640}'), + ('\u{116ab}', '\u{116b7}'), + ('\u{1171d}', '\u{1172b}'), + ('𑠬', '\u{1183a}'), + ('\u{119d1}', '\u{119d7}'), + ('\u{119da}', '\u{119e0}'), + ('\u{119e4}', '\u{119e4}'), + ('\u{11a01}', '\u{11a0a}'), + ('\u{11a33}', '𑨹'), + ('\u{11a3b}', '\u{11a3e}'), + ('\u{11a47}', '\u{11a47}'), + ('\u{11a51}', '\u{11a5b}'), + ('\u{11a8a}', '\u{11a99}'), + ('𑰯', '\u{11c36}'), + ('\u{11c38}', '\u{11c3f}'), + ('\u{11c92}', '\u{11ca7}'), + ('𑲩', '\u{11cb6}'), + ('\u{11d31}', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d45}'), + ('\u{11d47}', '\u{11d47}'), + ('𑶊', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '\u{11d97}'), + ('\u{11ef3}', '𑻶'), + ('\u{16af0}', '\u{16af4}'), + ('\u{16b30}', '\u{16b36}'), + ('\u{16f4f}', '\u{16f4f}'), + ('𖽑', '\u{16f87}'), + ('\u{16f8f}', '\u{16f92}'), + ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d165}', '\u{1d169}'), + ('𝅭', '\u{1d172}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1d242}', '\u{1d244}'), + ('\u{1da00}', '\u{1da36}'), + ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), + ('\u{1da84}', '\u{1da84}'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e130}', '\u{1e136}'), + ('\u{1e2ec}', '\u{1e2ef}'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('\u{1e944}', '\u{1e94a}'), + ('\u{e0020}', '\u{e007f}'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const FORMAT: &'static [(char, char)] = &[ + ('\u{ad}', '\u{ad}'), + ('\u{600}', '\u{605}'), + ('\u{61c}', '\u{61c}'), + ('\u{6dd}', '\u{6dd}'), + ('\u{70f}', '\u{70f}'), + ('\u{8e2}', '\u{8e2}'), + ('\u{180e}', '\u{180e}'), + ('\u{200b}', '\u{200b}'), + ('\u{200e}', '\u{200f}'), + ('\u{202a}', '\u{202e}'), + ('\u{2060}', '\u{2064}'), + ('\u{2066}', '\u{206f}'), + ('\u{feff}', '\u{feff}'), + ('\u{fff9}', '\u{fffb}'), + ('\u{110bd}', '\u{110bd}'), + ('\u{110cd}', '\u{110cd}'), + ('\u{13430}', '\u{13438}'), + ('\u{1bca0}', '\u{1bca3}'), + ('\u{1d173}', '\u{1d17a}'), + ('\u{e0001}', '\u{e0001}'), +]; + +pub const LF: &'static [(char, char)] = &[('\n', '\n')]; + +pub const LOWER: &'static [(char, char)] = &[ + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('º', 'º'), + ('ß', 'ö'), + ('ø', 'ÿ'), + ('ā', 'ā'), + ('ă', 'ă'), + ('ą', 'ą'), + ('ć', 'ć'), + ('ĉ', 'ĉ'), + ('ċ', 'ċ'), + ('č', 'č'), + ('ď', 'ď'), + ('đ', 'đ'), + ('ē', 'ē'), + ('ĕ', 'ĕ'), + ('ė', 'ė'), + ('ę', 'ę'), + ('ě', 'ě'), + ('ĝ', 'ĝ'), + ('ğ', 'ğ'), + ('ġ', 'ġ'), + ('ģ', 'ģ'), + ('ĥ', 'ĥ'), + ('ħ', 'ħ'), + ('ĩ', 'ĩ'), + ('ī', 'ī'), + ('ĭ', 'ĭ'), + ('į', 'į'), + ('ı', 'ı'), + ('ij', 'ij'), + ('ĵ', 'ĵ'), + ('ķ', 'ĸ'), + ('ĺ', 'ĺ'), + ('ļ', 'ļ'), + ('ľ', 'ľ'), + ('ŀ', 'ŀ'), + ('ł', 'ł'), + ('ń', 'ń'), + ('ņ', 'ņ'), + ('ň', 'ʼn'), + ('ŋ', 'ŋ'), + ('ō', 'ō'), + ('ŏ', 'ŏ'), + ('ő', 'ő'), + ('œ', 'œ'), + ('ŕ', 'ŕ'), + ('ŗ', 'ŗ'), + ('ř', 'ř'), + ('ś', 'ś'), + ('ŝ', 'ŝ'), + ('ş', 'ş'), + ('š', 'š'), + ('ţ', 'ţ'), + ('ť', 'ť'), + ('ŧ', 'ŧ'), + ('ũ', 'ũ'), + ('ū', 'ū'), + ('ŭ', 'ŭ'), + ('ů', 'ů'), + ('ű', 'ű'), + ('ų', 'ų'), + ('ŵ', 'ŵ'), + ('ŷ', 'ŷ'), + ('ź', 'ź'), + ('ż', 'ż'), + ('ž', 'ƀ'), + ('ƃ', 'ƃ'), + ('ƅ', 'ƅ'), + ('ƈ', 'ƈ'), + ('ƌ', 'ƍ'), + ('ƒ', 'ƒ'), + ('ƕ', 'ƕ'), + ('ƙ', 'ƛ'), + ('ƞ', 'ƞ'), + ('ơ', 'ơ'), + ('ƣ', 'ƣ'), + ('ƥ', 'ƥ'), + ('ƨ', 'ƨ'), + ('ƪ', 'ƫ'), + ('ƭ', 'ƭ'), + ('ư', 'ư'), + ('ƴ', 'ƴ'), + ('ƶ', 'ƶ'), + ('ƹ', 'ƺ'), + ('ƽ', 'ƿ'), + ('dž', 'dž'), + ('lj', 'lj'), + ('nj', 'nj'), + ('ǎ', 'ǎ'), + ('ǐ', 'ǐ'), + ('ǒ', 'ǒ'), + ('ǔ', 'ǔ'), + ('ǖ', 'ǖ'), + ('ǘ', 'ǘ'), + ('ǚ', 'ǚ'), + ('ǜ', 'ǝ'), + ('ǟ', 'ǟ'), + ('ǡ', 'ǡ'), + ('ǣ', 'ǣ'), + ('ǥ', 'ǥ'), + ('ǧ', 'ǧ'), + ('ǩ', 'ǩ'), + ('ǫ', 'ǫ'), + ('ǭ', 'ǭ'), + ('ǯ', 'ǰ'), + ('dz', 'dz'), + ('ǵ', 'ǵ'), + ('ǹ', 'ǹ'), + ('ǻ', 'ǻ'), + ('ǽ', 'ǽ'), + ('ǿ', 'ǿ'), + ('ȁ', 'ȁ'), + ('ȃ', 'ȃ'), + ('ȅ', 'ȅ'), + ('ȇ', 'ȇ'), + ('ȉ', 'ȉ'), + ('ȋ', 'ȋ'), + ('ȍ', 'ȍ'), + ('ȏ', 'ȏ'), + ('ȑ', 'ȑ'), + ('ȓ', 'ȓ'), + ('ȕ', 'ȕ'), + ('ȗ', 'ȗ'), + ('ș', 'ș'), + ('ț', 'ț'), + ('ȝ', 'ȝ'), + ('ȟ', 'ȟ'), + ('ȡ', 'ȡ'), + ('ȣ', 'ȣ'), + ('ȥ', 'ȥ'), + ('ȧ', 'ȧ'), + ('ȩ', 'ȩ'), + ('ȫ', 'ȫ'), + ('ȭ', 'ȭ'), + ('ȯ', 'ȯ'), + ('ȱ', 'ȱ'), + ('ȳ', 'ȹ'), + ('ȼ', 'ȼ'), + ('ȿ', 'ɀ'), + ('ɂ', 'ɂ'), + ('ɇ', 'ɇ'), + ('ɉ', 'ɉ'), + ('ɋ', 'ɋ'), + ('ɍ', 'ɍ'), + ('ɏ', 'ʓ'), + ('ʕ', 'ʸ'), + ('ˀ', 'ˁ'), + ('ˠ', 'ˤ'), + ('ͱ', 'ͱ'), + ('ͳ', 'ͳ'), + ('ͷ', 'ͷ'), + ('ͺ', 'ͽ'), + ('ΐ', 'ΐ'), + ('ά', 'ώ'), + ('ϐ', 'ϑ'), + ('ϕ', 'ϗ'), + ('ϙ', 'ϙ'), + ('ϛ', 'ϛ'), + ('ϝ', 'ϝ'), + ('ϟ', 'ϟ'), + ('ϡ', 'ϡ'), + ('ϣ', 'ϣ'), + ('ϥ', 'ϥ'), + ('ϧ', 'ϧ'), + ('ϩ', 'ϩ'), + ('ϫ', 'ϫ'), + ('ϭ', 'ϭ'), + ('ϯ', 'ϳ'), + ('ϵ', 'ϵ'), + ('ϸ', 'ϸ'), + ('ϻ', 'ϼ'), + ('а', 'џ'), + ('ѡ', 'ѡ'), + ('ѣ', 'ѣ'), + ('ѥ', 'ѥ'), + ('ѧ', 'ѧ'), + ('ѩ', 'ѩ'), + ('ѫ', 'ѫ'), + ('ѭ', 'ѭ'), + ('ѯ', 'ѯ'), + ('ѱ', 'ѱ'), + ('ѳ', 'ѳ'), + ('ѵ', 'ѵ'), + ('ѷ', 'ѷ'), + ('ѹ', 'ѹ'), + ('ѻ', 'ѻ'), + ('ѽ', 'ѽ'), + ('ѿ', 'ѿ'), + ('ҁ', 'ҁ'), + ('ҋ', 'ҋ'), + ('ҍ', 'ҍ'), + ('ҏ', 'ҏ'), + ('ґ', 'ґ'), + ('ғ', 'ғ'), + ('ҕ', 'ҕ'), + ('җ', 'җ'), + ('ҙ', 'ҙ'), + ('қ', 'қ'), + ('ҝ', 'ҝ'), + ('ҟ', 'ҟ'), + ('ҡ', 'ҡ'), + ('ң', 'ң'), + ('ҥ', 'ҥ'), + ('ҧ', 'ҧ'), + ('ҩ', 'ҩ'), + ('ҫ', 'ҫ'), + ('ҭ', 'ҭ'), + ('ү', 'ү'), + ('ұ', 'ұ'), + ('ҳ', 'ҳ'), + ('ҵ', 'ҵ'), + ('ҷ', 'ҷ'), + ('ҹ', 'ҹ'), + ('һ', 'һ'), + ('ҽ', 'ҽ'), + ('ҿ', 'ҿ'), + ('ӂ', 'ӂ'), + ('ӄ', 'ӄ'), + ('ӆ', 'ӆ'), + ('ӈ', 'ӈ'), + ('ӊ', 'ӊ'), + ('ӌ', 'ӌ'), + ('ӎ', 'ӏ'), + ('ӑ', 'ӑ'), + ('ӓ', 'ӓ'), + ('ӕ', 'ӕ'), + ('ӗ', 'ӗ'), + ('ә', 'ә'), + ('ӛ', 'ӛ'), + ('ӝ', 'ӝ'), + ('ӟ', 'ӟ'), + ('ӡ', 'ӡ'), + ('ӣ', 'ӣ'), + ('ӥ', 'ӥ'), + ('ӧ', 'ӧ'), + ('ө', 'ө'), + ('ӫ', 'ӫ'), + ('ӭ', 'ӭ'), + ('ӯ', 'ӯ'), + ('ӱ', 'ӱ'), + ('ӳ', 'ӳ'), + ('ӵ', 'ӵ'), + ('ӷ', 'ӷ'), + ('ӹ', 'ӹ'), + ('ӻ', 'ӻ'), + ('ӽ', 'ӽ'), + ('ӿ', 'ӿ'), + ('ԁ', 'ԁ'), + ('ԃ', 'ԃ'), + ('ԅ', 'ԅ'), + ('ԇ', 'ԇ'), + ('ԉ', 'ԉ'), + ('ԋ', 'ԋ'), + ('ԍ', 'ԍ'), + ('ԏ', 'ԏ'), + ('ԑ', 'ԑ'), + ('ԓ', 'ԓ'), + ('ԕ', 'ԕ'), + ('ԗ', 'ԗ'), + ('ԙ', 'ԙ'), + ('ԛ', 'ԛ'), + ('ԝ', 'ԝ'), + ('ԟ', 'ԟ'), + ('ԡ', 'ԡ'), + ('ԣ', 'ԣ'), + ('ԥ', 'ԥ'), + ('ԧ', 'ԧ'), + ('ԩ', 'ԩ'), + ('ԫ', 'ԫ'), + ('ԭ', 'ԭ'), + ('ԯ', 'ԯ'), + ('ՠ', 'ֈ'), + ('ᏸ', 'ᏽ'), + ('ᲀ', 'ᲈ'), + ('ᴀ', 'ᶿ'), + ('ḁ', 'ḁ'), + ('ḃ', 'ḃ'), + ('ḅ', 'ḅ'), + ('ḇ', 'ḇ'), + ('ḉ', 'ḉ'), + ('ḋ', 'ḋ'), + ('ḍ', 'ḍ'), + ('ḏ', 'ḏ'), + ('ḑ', 'ḑ'), + ('ḓ', 'ḓ'), + ('ḕ', 'ḕ'), + ('ḗ', 'ḗ'), + ('ḙ', 'ḙ'), + ('ḛ', 'ḛ'), + ('ḝ', 'ḝ'), + ('ḟ', 'ḟ'), + ('ḡ', 'ḡ'), + ('ḣ', 'ḣ'), + ('ḥ', 'ḥ'), + ('ḧ', 'ḧ'), + ('ḩ', 'ḩ'), + ('ḫ', 'ḫ'), + ('ḭ', 'ḭ'), + ('ḯ', 'ḯ'), + ('ḱ', 'ḱ'), + ('ḳ', 'ḳ'), + ('ḵ', 'ḵ'), + ('ḷ', 'ḷ'), + ('ḹ', 'ḹ'), + ('ḻ', 'ḻ'), + ('ḽ', 'ḽ'), + ('ḿ', 'ḿ'), + ('ṁ', 'ṁ'), + ('ṃ', 'ṃ'), + ('ṅ', 'ṅ'), + ('ṇ', 'ṇ'), + ('ṉ', 'ṉ'), + ('ṋ', 'ṋ'), + ('ṍ', 'ṍ'), + ('ṏ', 'ṏ'), + ('ṑ', 'ṑ'), + ('ṓ', 'ṓ'), + ('ṕ', 'ṕ'), + ('ṗ', 'ṗ'), + ('ṙ', 'ṙ'), + ('ṛ', 'ṛ'), + ('ṝ', 'ṝ'), + ('ṟ', 'ṟ'), + ('ṡ', 'ṡ'), + ('ṣ', 'ṣ'), + ('ṥ', 'ṥ'), + ('ṧ', 'ṧ'), + ('ṩ', 'ṩ'), + ('ṫ', 'ṫ'), + ('ṭ', 'ṭ'), + ('ṯ', 'ṯ'), + ('ṱ', 'ṱ'), + ('ṳ', 'ṳ'), + ('ṵ', 'ṵ'), + ('ṷ', 'ṷ'), + ('ṹ', 'ṹ'), + ('ṻ', 'ṻ'), + ('ṽ', 'ṽ'), + ('ṿ', 'ṿ'), + ('ẁ', 'ẁ'), + ('ẃ', 'ẃ'), + ('ẅ', 'ẅ'), + ('ẇ', 'ẇ'), + ('ẉ', 'ẉ'), + ('ẋ', 'ẋ'), + ('ẍ', 'ẍ'), + ('ẏ', 'ẏ'), + ('ẑ', 'ẑ'), + ('ẓ', 'ẓ'), + ('ẕ', 'ẝ'), + ('ẟ', 'ẟ'), + ('ạ', 'ạ'), + ('ả', 'ả'), + ('ấ', 'ấ'), + ('ầ', 'ầ'), + ('ẩ', 'ẩ'), + ('ẫ', 'ẫ'), + ('ậ', 'ậ'), + ('ắ', 'ắ'), + ('ằ', 'ằ'), + ('ẳ', 'ẳ'), + ('ẵ', 'ẵ'), + ('ặ', 'ặ'), + ('ẹ', 'ẹ'), + ('ẻ', 'ẻ'), + ('ẽ', 'ẽ'), + ('ế', 'ế'), + ('ề', 'ề'), + ('ể', 'ể'), + ('ễ', 'ễ'), + ('ệ', 'ệ'), + ('ỉ', 'ỉ'), + ('ị', 'ị'), + ('ọ', 'ọ'), + ('ỏ', 'ỏ'), + ('ố', 'ố'), + ('ồ', 'ồ'), + ('ổ', 'ổ'), + ('ỗ', 'ỗ'), + ('ộ', 'ộ'), + ('ớ', 'ớ'), + ('ờ', 'ờ'), + ('ở', 'ở'), + ('ỡ', 'ỡ'), + ('ợ', 'ợ'), + ('ụ', 'ụ'), + ('ủ', 'ủ'), + ('ứ', 'ứ'), + ('ừ', 'ừ'), + ('ử', 'ử'), + ('ữ', 'ữ'), + ('ự', 'ự'), + ('ỳ', 'ỳ'), + ('ỵ', 'ỵ'), + ('ỷ', 'ỷ'), + ('ỹ', 'ỹ'), + ('ỻ', 'ỻ'), + ('ỽ', 'ỽ'), + ('ỿ', 'ἇ'), + ('ἐ', 'ἕ'), + ('ἠ', 'ἧ'), + ('ἰ', 'ἷ'), + ('ὀ', 'ὅ'), + ('ὐ', 'ὗ'), + ('ὠ', 'ὧ'), + ('ὰ', 'ώ'), + ('ᾀ', 'ᾇ'), + ('ᾐ', 'ᾗ'), + ('ᾠ', 'ᾧ'), + ('ᾰ', 'ᾴ'), + ('ᾶ', 'ᾷ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῇ'), + ('ῐ', 'ΐ'), + ('ῖ', 'ῗ'), + ('ῠ', 'ῧ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῷ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('ℊ', 'ℊ'), + ('ℎ', 'ℏ'), + ('ℓ', 'ℓ'), + ('ℯ', 'ℯ'), + ('ℴ', 'ℴ'), + ('ℹ', 'ℹ'), + ('ℼ', 'ℽ'), + ('ⅆ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('ⅰ', 'ⅿ'), + ('ↄ', 'ↄ'), + ('ⓐ', 'ⓩ'), + ('ⰰ', 'ⱞ'), + ('ⱡ', 'ⱡ'), + ('ⱥ', 'ⱦ'), + ('ⱨ', 'ⱨ'), + ('ⱪ', 'ⱪ'), + ('ⱬ', 'ⱬ'), + ('ⱱ', 'ⱱ'), + ('ⱳ', 'ⱴ'), + ('ⱶ', 'ⱽ'), + ('ⲁ', 'ⲁ'), + ('ⲃ', 'ⲃ'), + ('ⲅ', 'ⲅ'), + ('ⲇ', 'ⲇ'), + ('ⲉ', 'ⲉ'), + ('ⲋ', 'ⲋ'), + ('ⲍ', 'ⲍ'), + ('ⲏ', 'ⲏ'), + ('ⲑ', 'ⲑ'), + ('ⲓ', 'ⲓ'), + ('ⲕ', 'ⲕ'), + ('ⲗ', 'ⲗ'), + ('ⲙ', 'ⲙ'), + ('ⲛ', 'ⲛ'), + ('ⲝ', 'ⲝ'), + ('ⲟ', 'ⲟ'), + ('ⲡ', 'ⲡ'), + ('ⲣ', 'ⲣ'), + ('ⲥ', 'ⲥ'), + ('ⲧ', 'ⲧ'), + ('ⲩ', 'ⲩ'), + ('ⲫ', 'ⲫ'), + ('ⲭ', 'ⲭ'), + ('ⲯ', 'ⲯ'), + ('ⲱ', 'ⲱ'), + ('ⲳ', 'ⲳ'), + ('ⲵ', 'ⲵ'), + ('ⲷ', 'ⲷ'), + ('ⲹ', 'ⲹ'), + ('ⲻ', 'ⲻ'), + ('ⲽ', 'ⲽ'), + ('ⲿ', 'ⲿ'), + ('ⳁ', 'ⳁ'), + ('ⳃ', 'ⳃ'), + ('ⳅ', 'ⳅ'), + ('ⳇ', 'ⳇ'), + ('ⳉ', 'ⳉ'), + ('ⳋ', 'ⳋ'), + ('ⳍ', 'ⳍ'), + ('ⳏ', 'ⳏ'), + ('ⳑ', 'ⳑ'), + ('ⳓ', 'ⳓ'), + ('ⳕ', 'ⳕ'), + ('ⳗ', 'ⳗ'), + ('ⳙ', 'ⳙ'), + ('ⳛ', 'ⳛ'), + ('ⳝ', 'ⳝ'), + ('ⳟ', 'ⳟ'), + ('ⳡ', 'ⳡ'), + ('ⳣ', 'ⳤ'), + ('ⳬ', 'ⳬ'), + ('ⳮ', 'ⳮ'), + ('ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ꙁ', 'ꙁ'), + ('ꙃ', 'ꙃ'), + ('ꙅ', 'ꙅ'), + ('ꙇ', 'ꙇ'), + ('ꙉ', 'ꙉ'), + ('ꙋ', 'ꙋ'), + ('ꙍ', 'ꙍ'), + ('ꙏ', 'ꙏ'), + ('ꙑ', 'ꙑ'), + ('ꙓ', 'ꙓ'), + ('ꙕ', 'ꙕ'), + ('ꙗ', 'ꙗ'), + ('ꙙ', 'ꙙ'), + ('ꙛ', 'ꙛ'), + ('ꙝ', 'ꙝ'), + ('ꙟ', 'ꙟ'), + ('ꙡ', 'ꙡ'), + ('ꙣ', 'ꙣ'), + ('ꙥ', 'ꙥ'), + ('ꙧ', 'ꙧ'), + ('ꙩ', 'ꙩ'), + ('ꙫ', 'ꙫ'), + ('ꙭ', 'ꙭ'), + ('ꚁ', 'ꚁ'), + ('ꚃ', 'ꚃ'), + ('ꚅ', 'ꚅ'), + ('ꚇ', 'ꚇ'), + ('ꚉ', 'ꚉ'), + ('ꚋ', 'ꚋ'), + ('ꚍ', 'ꚍ'), + ('ꚏ', 'ꚏ'), + ('ꚑ', 'ꚑ'), + ('ꚓ', 'ꚓ'), + ('ꚕ', 'ꚕ'), + ('ꚗ', 'ꚗ'), + ('ꚙ', 'ꚙ'), + ('ꚛ', 'ꚝ'), + ('ꜣ', 'ꜣ'), + ('ꜥ', 'ꜥ'), + ('ꜧ', 'ꜧ'), + ('ꜩ', 'ꜩ'), + ('ꜫ', 'ꜫ'), + ('ꜭ', 'ꜭ'), + ('ꜯ', 'ꜱ'), + ('ꜳ', 'ꜳ'), + ('ꜵ', 'ꜵ'), + ('ꜷ', 'ꜷ'), + ('ꜹ', 'ꜹ'), + ('ꜻ', 'ꜻ'), + ('ꜽ', 'ꜽ'), + ('ꜿ', 'ꜿ'), + ('ꝁ', 'ꝁ'), + ('ꝃ', 'ꝃ'), + ('ꝅ', 'ꝅ'), + ('ꝇ', 'ꝇ'), + ('ꝉ', 'ꝉ'), + ('ꝋ', 'ꝋ'), + ('ꝍ', 'ꝍ'), + ('ꝏ', 'ꝏ'), + ('ꝑ', 'ꝑ'), + ('ꝓ', 'ꝓ'), + ('ꝕ', 'ꝕ'), + ('ꝗ', 'ꝗ'), + ('ꝙ', 'ꝙ'), + ('ꝛ', 'ꝛ'), + ('ꝝ', 'ꝝ'), + ('ꝟ', 'ꝟ'), + ('ꝡ', 'ꝡ'), + ('ꝣ', 'ꝣ'), + ('ꝥ', 'ꝥ'), + ('ꝧ', 'ꝧ'), + ('ꝩ', 'ꝩ'), + ('ꝫ', 'ꝫ'), + ('ꝭ', 'ꝭ'), + ('ꝯ', 'ꝸ'), + ('ꝺ', 'ꝺ'), + ('ꝼ', 'ꝼ'), + ('ꝿ', 'ꝿ'), + ('ꞁ', 'ꞁ'), + ('ꞃ', 'ꞃ'), + ('ꞅ', 'ꞅ'), + ('ꞇ', 'ꞇ'), + ('ꞌ', 'ꞌ'), + ('ꞎ', 'ꞎ'), + ('ꞑ', 'ꞑ'), + ('ꞓ', 'ꞕ'), + ('ꞗ', 'ꞗ'), + ('ꞙ', 'ꞙ'), + ('ꞛ', 'ꞛ'), + ('ꞝ', 'ꞝ'), + ('ꞟ', 'ꞟ'), + ('ꞡ', 'ꞡ'), + ('ꞣ', 'ꞣ'), + ('ꞥ', 'ꞥ'), + ('ꞧ', 'ꞧ'), + ('ꞩ', 'ꞩ'), + ('ꞯ', 'ꞯ'), + ('ꞵ', 'ꞵ'), + ('ꞷ', 'ꞷ'), + ('ꞹ', 'ꞹ'), + ('\u{a7bb}', '\u{a7bb}'), + ('\u{a7bd}', '\u{a7bd}'), + ('\u{a7bf}', '\u{a7bf}'), + ('\u{a7c3}', '\u{a7c3}'), + ('ꟸ', 'ꟺ'), + ('ꬰ', 'ꭚ'), + ('ꭜ', '\u{ab67}'), + ('ꭰ', 'ꮿ'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('a', 'z'), + ('𐐨', '𐑏'), + ('𐓘', '𐓻'), + ('𐳀', '𐳲'), + ('𑣀', '𑣟'), + ('𖹠', '𖹿'), + ('𝐚', '𝐳'), + ('𝑎', '𝑔'), + ('𝑖', '𝑧'), + ('𝒂', '𝒛'), + ('𝒶', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝓏'), + ('𝓪', '𝔃'), + ('𝔞', '𝔷'), + ('𝕒', '𝕫'), + ('𝖆', '𝖟'), + ('𝖺', '𝗓'), + ('𝗮', '𝘇'), + ('𝘢', '𝘻'), + ('𝙖', '𝙯'), + ('𝚊', '𝚥'), + ('𝛂', '𝛚'), + ('𝛜', '𝛡'), + ('𝛼', '𝜔'), + ('𝜖', '𝜛'), + ('𝜶', '𝝎'), + ('𝝐', '𝝕'), + ('𝝰', '𝞈'), + ('𝞊', '𝞏'), + ('𝞪', '𝟂'), + ('𝟄', '𝟉'), + ('𝟋', '𝟋'), + ('𞤢', '𞥃'), +]; + +pub const NUMERIC: &'static [(char, char)] = &[ + ('0', '9'), + ('٠', '٩'), + ('٫', '٬'), + ('۰', '۹'), + ('߀', '߉'), + ('०', '९'), + ('০', '৯'), + ('੦', '੯'), + ('૦', '૯'), + ('୦', '୯'), + ('௦', '௯'), + ('౦', '౯'), + ('೦', '೯'), + ('൦', '൯'), + ('෦', '෯'), + ('๐', '๙'), + ('໐', '໙'), + ('༠', '༩'), + ('၀', '၉'), + ('႐', '႙'), + ('០', '៩'), + ('᠐', '᠙'), + ('᥆', '᥏'), + ('᧐', '᧙'), + ('᪀', '᪉'), + ('᪐', '᪙'), + ('᭐', '᭙'), + ('᮰', '᮹'), + ('᱀', '᱉'), + ('᱐', '᱙'), + ('꘠', '꘩'), + ('꣐', '꣙'), + ('꤀', '꤉'), + ('꧐', '꧙'), + ('꧰', '꧹'), + ('꩐', '꩙'), + ('꯰', '꯹'), + ('0', '9'), + ('𐒠', '𐒩'), + ('𐴰', '𐴹'), + ('𑁦', '𑁯'), + ('𑃰', '𑃹'), + ('𑄶', '𑄿'), + ('𑇐', '𑇙'), + ('𑋰', '𑋹'), + ('𑑐', '𑑙'), + ('𑓐', '𑓙'), + ('𑙐', '𑙙'), + ('𑛀', '𑛉'), + ('𑜰', '𑜹'), + ('𑣠', '𑣩'), + ('𑱐', '𑱙'), + ('𑵐', '𑵙'), + ('𑶠', '𑶩'), + ('𖩠', '𖩩'), + ('𖭐', '𖭙'), + ('𝟎', '𝟿'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e2f0}', '\u{1e2f9}'), + ('𞥐', '𞥙'), +]; + +pub const OLETTER: &'static [(char, char)] = &[ + ('ƻ', 'ƻ'), + ('ǀ', 'ǃ'), + ('ʔ', 'ʔ'), + ('ʹ', 'ʿ'), + ('ˆ', 'ˑ'), + ('ˬ', 'ˬ'), + ('ˮ', 'ˮ'), + ('ʹ', 'ʹ'), + ('ՙ', 'ՙ'), + ('א', 'ת'), + ('ׯ', '׳'), + ('ؠ', 'ي'), + ('ٮ', 'ٯ'), + ('ٱ', 'ۓ'), + ('ە', 'ە'), + ('ۥ', 'ۦ'), + ('ۮ', 'ۯ'), + ('ۺ', 'ۼ'), + ('ۿ', 'ۿ'), + ('ܐ', 'ܐ'), + ('ܒ', 'ܯ'), + ('ݍ', 'ޥ'), + ('ޱ', 'ޱ'), + ('ߊ', 'ߪ'), + ('ߴ', 'ߵ'), + ('ߺ', 'ߺ'), + ('ࠀ', 'ࠕ'), + ('ࠚ', 'ࠚ'), + ('ࠤ', 'ࠤ'), + ('ࠨ', 'ࠨ'), + ('ࡀ', 'ࡘ'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('ऄ', 'ह'), + ('ऽ', 'ऽ'), + ('ॐ', 'ॐ'), + ('क़', 'ॡ'), + ('ॱ', 'ঀ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('ঽ', 'ঽ'), + ('ৎ', 'ৎ'), + ('ড়', 'ঢ়'), + ('য়', 'ৡ'), + ('ৰ', 'ৱ'), + ('ৼ', 'ৼ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('ੲ', 'ੴ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('ઽ', 'ઽ'), + ('ૐ', 'ૐ'), + ('ૠ', 'ૡ'), + ('ૹ', 'ૹ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('ଽ', 'ଽ'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', 'ୡ'), + ('ୱ', 'ୱ'), + ('ஃ', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('ௐ', 'ௐ'), + ('అ', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ఽ'), + ('ౘ', 'ౚ'), + ('ౠ', 'ౡ'), + ('ಀ', 'ಀ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('ಽ', 'ಽ'), + ('ೞ', 'ೞ'), + ('ೠ', 'ೡ'), + ('ೱ', 'ೲ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', 'ഺ'), + ('ഽ', 'ഽ'), + ('ൎ', 'ൎ'), + ('ൔ', 'ൖ'), + ('ൟ', 'ൡ'), + ('ൺ', 'ൿ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('ก', 'ะ'), + ('า', 'ำ'), + ('เ', 'ๆ'), + ('ກ', 'ຂ'), + ('ຄ', 'ຄ'), + ('\u{e86}', 'ຊ'), + ('\u{e8c}', 'ຣ'), + ('ລ', 'ລ'), + ('ວ', 'ະ'), + ('າ', 'ຳ'), + ('ຽ', 'ຽ'), + ('ເ', 'ໄ'), + ('ໆ', 'ໆ'), + ('ໜ', 'ໟ'), + ('ༀ', 'ༀ'), + ('ཀ', 'ཇ'), + ('ཉ', 'ཬ'), + ('ྈ', 'ྌ'), + ('က', 'ဪ'), + ('ဿ', 'ဿ'), + ('ၐ', 'ၕ'), + ('ၚ', 'ၝ'), + ('ၡ', 'ၡ'), + ('ၥ', 'ၦ'), + ('ၮ', 'ၰ'), + ('ၵ', 'ႁ'), + ('ႎ', 'ႎ'), + ('ა', 'ჺ'), + ('ჼ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('ᎀ', 'ᎏ'), + ('ᐁ', 'ᙬ'), + ('ᙯ', 'ᙿ'), + ('ᚁ', 'ᚚ'), + ('ᚠ', 'ᛪ'), + ('ᛮ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', 'ᜑ'), + ('ᜠ', 'ᜱ'), + ('ᝀ', 'ᝑ'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('ក', 'ឳ'), + ('ៗ', 'ៗ'), + ('ៜ', 'ៜ'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢄ'), + ('ᢇ', 'ᢨ'), + ('ᢪ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('ᥐ', 'ᥭ'), + ('ᥰ', 'ᥴ'), + ('ᦀ', 'ᦫ'), + ('ᦰ', 'ᧉ'), + ('ᨀ', 'ᨖ'), + ('ᨠ', 'ᩔ'), + ('ᪧ', 'ᪧ'), + ('ᬅ', 'ᬳ'), + ('ᭅ', 'ᭋ'), + ('ᮃ', 'ᮠ'), + ('ᮮ', 'ᮯ'), + ('ᮺ', 'ᯥ'), + ('ᰀ', 'ᰣ'), + ('ᱍ', 'ᱏ'), + ('ᱚ', 'ᱽ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ᳩ', 'ᳬ'), + ('ᳮ', 'ᳳ'), + ('ᳵ', 'ᳶ'), + ('\u{1cfa}', '\u{1cfa}'), + ('ℵ', 'ℸ'), + ('ↀ', 'ↂ'), + ('ↅ', 'ↈ'), + ('ⴰ', 'ⵧ'), + ('ⵯ', 'ⵯ'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('ⸯ', 'ⸯ'), + ('々', '〇'), + ('〡', '〩'), + ('〱', '〵'), + ('〸', '〼'), + ('ぁ', 'ゖ'), + ('ゝ', 'ゟ'), + ('ァ', 'ヺ'), + ('ー', 'ヿ'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('ㆠ', 'ㆺ'), + ('ㇰ', 'ㇿ'), + ('㐀', '䶵'), + ('一', '鿯'), + ('ꀀ', 'ꒌ'), + ('ꓐ', 'ꓽ'), + ('ꔀ', 'ꘌ'), + ('ꘐ', 'ꘟ'), + ('ꘪ', 'ꘫ'), + ('ꙮ', 'ꙮ'), + ('ꙿ', 'ꙿ'), + ('ꚠ', 'ꛯ'), + ('ꜗ', 'ꜟ'), + ('ꞈ', 'ꞈ'), + ('ꞏ', 'ꞏ'), + ('ꟷ', 'ꟷ'), + ('ꟻ', 'ꠁ'), + ('ꠃ', 'ꠅ'), + ('ꠇ', 'ꠊ'), + ('ꠌ', 'ꠢ'), + ('ꡀ', 'ꡳ'), + ('ꢂ', 'ꢳ'), + ('ꣲ', 'ꣷ'), + ('ꣻ', 'ꣻ'), + ('ꣽ', 'ꣾ'), + ('ꤊ', 'ꤥ'), + ('ꤰ', 'ꥆ'), + ('ꥠ', 'ꥼ'), + ('ꦄ', 'ꦲ'), + ('ꧏ', 'ꧏ'), + ('ꧠ', 'ꧤ'), + ('ꧦ', 'ꧯ'), + ('ꧺ', 'ꧾ'), + ('ꨀ', 'ꨨ'), + ('ꩀ', 'ꩂ'), + ('ꩄ', 'ꩋ'), + ('ꩠ', 'ꩶ'), + ('ꩺ', 'ꩺ'), + ('ꩾ', 'ꪯ'), + ('ꪱ', 'ꪱ'), + ('ꪵ', 'ꪶ'), + ('ꪹ', 'ꪽ'), + ('ꫀ', 'ꫀ'), + ('ꫂ', 'ꫂ'), + ('ꫛ', 'ꫝ'), + ('ꫠ', 'ꫪ'), + ('ꫲ', 'ꫴ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꯀ', 'ꯢ'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('豈', '舘'), + ('並', '龎'), + ('יִ', 'יִ'), + ('ײַ', 'ﬨ'), + ('שׁ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﮱ'), + ('ﯓ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷻ'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('ヲ', 'ン'), + ('ᅠ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐅀', '𐅴'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('𐌀', '𐌟'), + ('𐌭', '𐍊'), + ('𐍐', '𐍵'), + ('𐎀', '𐎝'), + ('𐎠', '𐏃'), + ('𐏈', '𐏏'), + ('𐏑', '𐏕'), + ('𐑐', '𐒝'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡠', '𐡶'), + ('𐢀', '𐢞'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐤀', '𐤕'), + ('𐤠', '𐤹'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𐨀', '𐨀'), + ('𐨐', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('𐩠', '𐩼'), + ('𐪀', '𐪜'), + ('𐫀', '𐫇'), + ('𐫉', '𐫤'), + ('𐬀', '𐬵'), + ('𐭀', '𐭕'), + ('𐭠', '𐭲'), + ('𐮀', '𐮑'), + ('𐰀', '𐱈'), + ('𐴀', '𐴣'), + ('𐼀', '𐼜'), + ('𐼧', '𐼧'), + ('𐼰', '𐽅'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀃', '𑀷'), + ('𑂃', '𑂯'), + ('𑃐', '𑃨'), + ('𑄃', '𑄦'), + ('𑅄', '𑅄'), + ('𑅐', '𑅲'), + ('𑅶', '𑅶'), + ('𑆃', '𑆲'), + ('𑇁', '𑇄'), + ('𑇚', '𑇚'), + ('𑇜', '𑇜'), + ('𑈀', '𑈑'), + ('𑈓', '𑈫'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊨'), + ('𑊰', '𑋞'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('𑌽', '𑌽'), + ('𑍐', '𑍐'), + ('𑍝', '𑍡'), + ('𑐀', '𑐴'), + ('𑑇', '𑑊'), + ('\u{1145f}', '\u{1145f}'), + ('𑒀', '𑒯'), + ('𑓄', '𑓅'), + ('𑓇', '𑓇'), + ('𑖀', '𑖮'), + ('𑗘', '𑗛'), + ('𑘀', '𑘯'), + ('𑙄', '𑙄'), + ('𑚀', '𑚪'), + ('\u{116b8}', '\u{116b8}'), + ('𑜀', '𑜚'), + ('𑠀', '𑠫'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d0}'), + ('\u{119e1}', '\u{119e1}'), + ('\u{119e3}', '\u{119e3}'), + ('𑨀', '𑨀'), + ('𑨋', '𑨲'), + ('𑨺', '𑨺'), + ('𑩐', '𑩐'), + ('𑩜', '𑪉'), + ('𑪝', '𑪝'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '𑰮'), + ('𑱀', '𑱀'), + ('𑱲', '𑲏'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '𑴰'), + ('𑵆', '𑵆'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶉'), + ('𑶘', '𑶘'), + ('𑻠', '𑻲'), + ('𒀀', '𒎙'), + ('𒐀', '𒑮'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖫐', '𖫭'), + ('𖬀', '𖬯'), + ('𖭀', '𖭃'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖼀', '\u{16f4a}'), + ('𖽐', '𖽐'), + ('𖾓', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('𗀀', '\u{187f7}'), + ('𘠀', '𘫲'), + ('𛀀', '𛄞'), + ('\u{1b150}', '\u{1b152}'), + ('\u{1b164}', '\u{1b167}'), + ('𛅰', '𛋻'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e137}', '\u{1e13d}'), + ('\u{1e14e}', '\u{1e14e}'), + ('\u{1e2c0}', '\u{1e2eb}'), + ('𞠀', '𞣄'), + ('\u{1e94b}', '\u{1e94b}'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('𠀀', '𪛖'), + ('𪜀', '𫜴'), + ('𫝀', '𫠝'), + ('𫠠', '𬺡'), + ('𬺰', '𮯠'), + ('丽', '𪘀'), +]; + +pub const SCONTINUE: &'static [(char, char)] = &[ + (',', '-'), + (':', ':'), + ('՝', '՝'), + ('،', '؍'), + ('߸', '߸'), + ('᠂', '᠂'), + ('᠈', '᠈'), + ('–', '—'), + ('、', '、'), + ('︐', '︑'), + ('︓', '︓'), + ('︱', '︲'), + ('﹐', '﹑'), + ('﹕', '﹕'), + ('﹘', '﹘'), + ('﹣', '﹣'), + (',', '-'), + (':', ':'), + ('、', '、'), +]; + +pub const STERM: &'static [(char, char)] = &[ + ('!', '!'), + ('?', '?'), + ('։', '։'), + ('؞', '؟'), + ('۔', '۔'), + ('܀', '܂'), + ('߹', '߹'), + ('࠷', '࠷'), + ('࠹', '࠹'), + ('࠽', '࠾'), + ('।', '॥'), + ('၊', '။'), + ('።', '።'), + ('፧', '፨'), + ('᙮', '᙮'), + ('᜵', '᜶'), + ('᠃', '᠃'), + ('᠉', '᠉'), + ('᥄', '᥅'), + ('᪨', '᪫'), + ('᭚', '᭛'), + ('᭞', '᭟'), + ('᰻', '᰼'), + ('᱾', '᱿'), + ('‼', '‽'), + ('⁇', '⁉'), + ('⸮', '⸮'), + ('⸼', '⸼'), + ('。', '。'), + ('꓿', '꓿'), + ('꘎', '꘏'), + ('꛳', '꛳'), + ('꛷', '꛷'), + ('꡶', '꡷'), + ('꣎', '꣏'), + ('꤯', '꤯'), + ('꧈', '꧉'), + ('꩝', '꩟'), + ('꫰', '꫱'), + ('꯫', '꯫'), + ('﹖', '﹗'), + ('!', '!'), + ('?', '?'), + ('。', '。'), + ('𐩖', '𐩗'), + ('𐽕', '𐽙'), + ('𑁇', '𑁈'), + ('𑂾', '𑃁'), + ('𑅁', '𑅃'), + ('𑇅', '𑇆'), + ('𑇍', '𑇍'), + ('𑇞', '𑇟'), + ('𑈸', '𑈹'), + ('𑈻', '𑈼'), + ('𑊩', '𑊩'), + ('𑑋', '𑑌'), + ('𑗂', '𑗃'), + ('𑗉', '𑗗'), + ('𑙁', '𑙂'), + ('𑜼', '𑜾'), + ('𑩂', '𑩃'), + ('𑪛', '𑪜'), + ('𑱁', '𑱂'), + ('𑻷', '𑻸'), + ('𖩮', '𖩯'), + ('𖫵', '𖫵'), + ('𖬷', '𖬸'), + ('𖭄', '𖭄'), + ('𖺘', '𖺘'), + ('𛲟', '𛲟'), + ('𝪈', '𝪈'), +]; + +pub const SEP: &'static [(char, char)] = + &[('\u{85}', '\u{85}'), ('\u{2028}', '\u{2029}')]; + +pub const SP: &'static [(char, char)] = &[ + ('\t', '\t'), + ('\u{b}', '\u{c}'), + (' ', ' '), + ('\u{a0}', '\u{a0}'), + ('\u{1680}', '\u{1680}'), + ('\u{2000}', '\u{200a}'), + ('\u{202f}', '\u{202f}'), + ('\u{205f}', '\u{205f}'), + ('\u{3000}', '\u{3000}'), +]; + +pub const UPPER: &'static [(char, char)] = &[ + ('A', 'Z'), + ('À', 'Ö'), + ('Ø', 'Þ'), + ('Ā', 'Ā'), + ('Ă', 'Ă'), + ('Ą', 'Ą'), + ('Ć', 'Ć'), + ('Ĉ', 'Ĉ'), + ('Ċ', 'Ċ'), + ('Č', 'Č'), + ('Ď', 'Ď'), + ('Đ', 'Đ'), + ('Ē', 'Ē'), + ('Ĕ', 'Ĕ'), + ('Ė', 'Ė'), + ('Ę', 'Ę'), + ('Ě', 'Ě'), + ('Ĝ', 'Ĝ'), + ('Ğ', 'Ğ'), + ('Ġ', 'Ġ'), + ('Ģ', 'Ģ'), + ('Ĥ', 'Ĥ'), + ('Ħ', 'Ħ'), + ('Ĩ', 'Ĩ'), + ('Ī', 'Ī'), + ('Ĭ', 'Ĭ'), + ('Į', 'Į'), + ('İ', 'İ'), + ('IJ', 'IJ'), + ('Ĵ', 'Ĵ'), + ('Ķ', 'Ķ'), + ('Ĺ', 'Ĺ'), + ('Ļ', 'Ļ'), + ('Ľ', 'Ľ'), + ('Ŀ', 'Ŀ'), + ('Ł', 'Ł'), + ('Ń', 'Ń'), + ('Ņ', 'Ņ'), + ('Ň', 'Ň'), + ('Ŋ', 'Ŋ'), + ('Ō', 'Ō'), + ('Ŏ', 'Ŏ'), + ('Ő', 'Ő'), + ('Œ', 'Œ'), + ('Ŕ', 'Ŕ'), + ('Ŗ', 'Ŗ'), + ('Ř', 'Ř'), + ('Ś', 'Ś'), + ('Ŝ', 'Ŝ'), + ('Ş', 'Ş'), + ('Š', 'Š'), + ('Ţ', 'Ţ'), + ('Ť', 'Ť'), + ('Ŧ', 'Ŧ'), + ('Ũ', 'Ũ'), + ('Ū', 'Ū'), + ('Ŭ', 'Ŭ'), + ('Ů', 'Ů'), + ('Ű', 'Ű'), + ('Ų', 'Ų'), + ('Ŵ', 'Ŵ'), + ('Ŷ', 'Ŷ'), + ('Ÿ', 'Ź'), + ('Ż', 'Ż'), + ('Ž', 'Ž'), + ('Ɓ', 'Ƃ'), + ('Ƅ', 'Ƅ'), + ('Ɔ', 'Ƈ'), + ('Ɖ', 'Ƌ'), + ('Ǝ', 'Ƒ'), + ('Ɠ', 'Ɣ'), + ('Ɩ', 'Ƙ'), + ('Ɯ', 'Ɲ'), + ('Ɵ', 'Ơ'), + ('Ƣ', 'Ƣ'), + ('Ƥ', 'Ƥ'), + ('Ʀ', 'Ƨ'), + ('Ʃ', 'Ʃ'), + ('Ƭ', 'Ƭ'), + ('Ʈ', 'Ư'), + ('Ʊ', 'Ƴ'), + ('Ƶ', 'Ƶ'), + ('Ʒ', 'Ƹ'), + ('Ƽ', 'Ƽ'), + ('DŽ', 'Dž'), + ('LJ', 'Lj'), + ('NJ', 'Nj'), + ('Ǎ', 'Ǎ'), + ('Ǐ', 'Ǐ'), + ('Ǒ', 'Ǒ'), + ('Ǔ', 'Ǔ'), + ('Ǖ', 'Ǖ'), + ('Ǘ', 'Ǘ'), + ('Ǚ', 'Ǚ'), + ('Ǜ', 'Ǜ'), + ('Ǟ', 'Ǟ'), + ('Ǡ', 'Ǡ'), + ('Ǣ', 'Ǣ'), + ('Ǥ', 'Ǥ'), + ('Ǧ', 'Ǧ'), + ('Ǩ', 'Ǩ'), + ('Ǫ', 'Ǫ'), + ('Ǭ', 'Ǭ'), + ('Ǯ', 'Ǯ'), + ('DZ', 'Dz'), + ('Ǵ', 'Ǵ'), + ('Ƕ', 'Ǹ'), + ('Ǻ', 'Ǻ'), + ('Ǽ', 'Ǽ'), + ('Ǿ', 'Ǿ'), + ('Ȁ', 'Ȁ'), + ('Ȃ', 'Ȃ'), + ('Ȅ', 'Ȅ'), + ('Ȇ', 'Ȇ'), + ('Ȉ', 'Ȉ'), + ('Ȋ', 'Ȋ'), + ('Ȍ', 'Ȍ'), + ('Ȏ', 'Ȏ'), + ('Ȑ', 'Ȑ'), + ('Ȓ', 'Ȓ'), + ('Ȕ', 'Ȕ'), + ('Ȗ', 'Ȗ'), + ('Ș', 'Ș'), + ('Ț', 'Ț'), + ('Ȝ', 'Ȝ'), + ('Ȟ', 'Ȟ'), + ('Ƞ', 'Ƞ'), + ('Ȣ', 'Ȣ'), + ('Ȥ', 'Ȥ'), + ('Ȧ', 'Ȧ'), + ('Ȩ', 'Ȩ'), + ('Ȫ', 'Ȫ'), + ('Ȭ', 'Ȭ'), + ('Ȯ', 'Ȯ'), + ('Ȱ', 'Ȱ'), + ('Ȳ', 'Ȳ'), + ('Ⱥ', 'Ȼ'), + ('Ƚ', 'Ⱦ'), + ('Ɂ', 'Ɂ'), + ('Ƀ', 'Ɇ'), + ('Ɉ', 'Ɉ'), + ('Ɋ', 'Ɋ'), + ('Ɍ', 'Ɍ'), + ('Ɏ', 'Ɏ'), + ('Ͱ', 'Ͱ'), + ('Ͳ', 'Ͳ'), + ('Ͷ', 'Ͷ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ώ'), + ('Α', 'Ρ'), + ('Σ', 'Ϋ'), + ('Ϗ', 'Ϗ'), + ('ϒ', 'ϔ'), + ('Ϙ', 'Ϙ'), + ('Ϛ', 'Ϛ'), + ('Ϝ', 'Ϝ'), + ('Ϟ', 'Ϟ'), + ('Ϡ', 'Ϡ'), + ('Ϣ', 'Ϣ'), + ('Ϥ', 'Ϥ'), + ('Ϧ', 'Ϧ'), + ('Ϩ', 'Ϩ'), + ('Ϫ', 'Ϫ'), + ('Ϭ', 'Ϭ'), + ('Ϯ', 'Ϯ'), + ('ϴ', 'ϴ'), + ('Ϸ', 'Ϸ'), + ('Ϲ', 'Ϻ'), + ('Ͻ', 'Я'), + ('Ѡ', 'Ѡ'), + ('Ѣ', 'Ѣ'), + ('Ѥ', 'Ѥ'), + ('Ѧ', 'Ѧ'), + ('Ѩ', 'Ѩ'), + ('Ѫ', 'Ѫ'), + ('Ѭ', 'Ѭ'), + ('Ѯ', 'Ѯ'), + ('Ѱ', 'Ѱ'), + ('Ѳ', 'Ѳ'), + ('Ѵ', 'Ѵ'), + ('Ѷ', 'Ѷ'), + ('Ѹ', 'Ѹ'), + ('Ѻ', 'Ѻ'), + ('Ѽ', 'Ѽ'), + ('Ѿ', 'Ѿ'), + ('Ҁ', 'Ҁ'), + ('Ҋ', 'Ҋ'), + ('Ҍ', 'Ҍ'), + ('Ҏ', 'Ҏ'), + ('Ґ', 'Ґ'), + ('Ғ', 'Ғ'), + ('Ҕ', 'Ҕ'), + ('Җ', 'Җ'), + ('Ҙ', 'Ҙ'), + ('Қ', 'Қ'), + ('Ҝ', 'Ҝ'), + ('Ҟ', 'Ҟ'), + ('Ҡ', 'Ҡ'), + ('Ң', 'Ң'), + ('Ҥ', 'Ҥ'), + ('Ҧ', 'Ҧ'), + ('Ҩ', 'Ҩ'), + ('Ҫ', 'Ҫ'), + ('Ҭ', 'Ҭ'), + ('Ү', 'Ү'), + ('Ұ', 'Ұ'), + ('Ҳ', 'Ҳ'), + ('Ҵ', 'Ҵ'), + ('Ҷ', 'Ҷ'), + ('Ҹ', 'Ҹ'), + ('Һ', 'Һ'), + ('Ҽ', 'Ҽ'), + ('Ҿ', 'Ҿ'), + ('Ӏ', 'Ӂ'), + ('Ӄ', 'Ӄ'), + ('Ӆ', 'Ӆ'), + ('Ӈ', 'Ӈ'), + ('Ӊ', 'Ӊ'), + ('Ӌ', 'Ӌ'), + ('Ӎ', 'Ӎ'), + ('Ӑ', 'Ӑ'), + ('Ӓ', 'Ӓ'), + ('Ӕ', 'Ӕ'), + ('Ӗ', 'Ӗ'), + ('Ә', 'Ә'), + ('Ӛ', 'Ӛ'), + ('Ӝ', 'Ӝ'), + ('Ӟ', 'Ӟ'), + ('Ӡ', 'Ӡ'), + ('Ӣ', 'Ӣ'), + ('Ӥ', 'Ӥ'), + ('Ӧ', 'Ӧ'), + ('Ө', 'Ө'), + ('Ӫ', 'Ӫ'), + ('Ӭ', 'Ӭ'), + ('Ӯ', 'Ӯ'), + ('Ӱ', 'Ӱ'), + ('Ӳ', 'Ӳ'), + ('Ӵ', 'Ӵ'), + ('Ӷ', 'Ӷ'), + ('Ӹ', 'Ӹ'), + ('Ӻ', 'Ӻ'), + ('Ӽ', 'Ӽ'), + ('Ӿ', 'Ӿ'), + ('Ԁ', 'Ԁ'), + ('Ԃ', 'Ԃ'), + ('Ԅ', 'Ԅ'), + ('Ԇ', 'Ԇ'), + ('Ԉ', 'Ԉ'), + ('Ԋ', 'Ԋ'), + ('Ԍ', 'Ԍ'), + ('Ԏ', 'Ԏ'), + ('Ԑ', 'Ԑ'), + ('Ԓ', 'Ԓ'), + ('Ԕ', 'Ԕ'), + ('Ԗ', 'Ԗ'), + ('Ԙ', 'Ԙ'), + ('Ԛ', 'Ԛ'), + ('Ԝ', 'Ԝ'), + ('Ԟ', 'Ԟ'), + ('Ԡ', 'Ԡ'), + ('Ԣ', 'Ԣ'), + ('Ԥ', 'Ԥ'), + ('Ԧ', 'Ԧ'), + ('Ԩ', 'Ԩ'), + ('Ԫ', 'Ԫ'), + ('Ԭ', 'Ԭ'), + ('Ԯ', 'Ԯ'), + ('Ա', 'Ֆ'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('Ꭰ', 'Ᏽ'), + ('Ḁ', 'Ḁ'), + ('Ḃ', 'Ḃ'), + ('Ḅ', 'Ḅ'), + ('Ḇ', 'Ḇ'), + ('Ḉ', 'Ḉ'), + ('Ḋ', 'Ḋ'), + ('Ḍ', 'Ḍ'), + ('Ḏ', 'Ḏ'), + ('Ḑ', 'Ḑ'), + ('Ḓ', 'Ḓ'), + ('Ḕ', 'Ḕ'), + ('Ḗ', 'Ḗ'), + ('Ḙ', 'Ḙ'), + ('Ḛ', 'Ḛ'), + ('Ḝ', 'Ḝ'), + ('Ḟ', 'Ḟ'), + ('Ḡ', 'Ḡ'), + ('Ḣ', 'Ḣ'), + ('Ḥ', 'Ḥ'), + ('Ḧ', 'Ḧ'), + ('Ḩ', 'Ḩ'), + ('Ḫ', 'Ḫ'), + ('Ḭ', 'Ḭ'), + ('Ḯ', 'Ḯ'), + ('Ḱ', 'Ḱ'), + ('Ḳ', 'Ḳ'), + ('Ḵ', 'Ḵ'), + ('Ḷ', 'Ḷ'), + ('Ḹ', 'Ḹ'), + ('Ḻ', 'Ḻ'), + ('Ḽ', 'Ḽ'), + ('Ḿ', 'Ḿ'), + ('Ṁ', 'Ṁ'), + ('Ṃ', 'Ṃ'), + ('Ṅ', 'Ṅ'), + ('Ṇ', 'Ṇ'), + ('Ṉ', 'Ṉ'), + ('Ṋ', 'Ṋ'), + ('Ṍ', 'Ṍ'), + ('Ṏ', 'Ṏ'), + ('Ṑ', 'Ṑ'), + ('Ṓ', 'Ṓ'), + ('Ṕ', 'Ṕ'), + ('Ṗ', 'Ṗ'), + ('Ṙ', 'Ṙ'), + ('Ṛ', 'Ṛ'), + ('Ṝ', 'Ṝ'), + ('Ṟ', 'Ṟ'), + ('Ṡ', 'Ṡ'), + ('Ṣ', 'Ṣ'), + ('Ṥ', 'Ṥ'), + ('Ṧ', 'Ṧ'), + ('Ṩ', 'Ṩ'), + ('Ṫ', 'Ṫ'), + ('Ṭ', 'Ṭ'), + ('Ṯ', 'Ṯ'), + ('Ṱ', 'Ṱ'), + ('Ṳ', 'Ṳ'), + ('Ṵ', 'Ṵ'), + ('Ṷ', 'Ṷ'), + ('Ṹ', 'Ṹ'), + ('Ṻ', 'Ṻ'), + ('Ṽ', 'Ṽ'), + ('Ṿ', 'Ṿ'), + ('Ẁ', 'Ẁ'), + ('Ẃ', 'Ẃ'), + ('Ẅ', 'Ẅ'), + ('Ẇ', 'Ẇ'), + ('Ẉ', 'Ẉ'), + ('Ẋ', 'Ẋ'), + ('Ẍ', 'Ẍ'), + ('Ẏ', 'Ẏ'), + ('Ẑ', 'Ẑ'), + ('Ẓ', 'Ẓ'), + ('Ẕ', 'Ẕ'), + ('ẞ', 'ẞ'), + ('Ạ', 'Ạ'), + ('Ả', 'Ả'), + ('Ấ', 'Ấ'), + ('Ầ', 'Ầ'), + ('Ẩ', 'Ẩ'), + ('Ẫ', 'Ẫ'), + ('Ậ', 'Ậ'), + ('Ắ', 'Ắ'), + ('Ằ', 'Ằ'), + ('Ẳ', 'Ẳ'), + ('Ẵ', 'Ẵ'), + ('Ặ', 'Ặ'), + ('Ẹ', 'Ẹ'), + ('Ẻ', 'Ẻ'), + ('Ẽ', 'Ẽ'), + ('Ế', 'Ế'), + ('Ề', 'Ề'), + ('Ể', 'Ể'), + ('Ễ', 'Ễ'), + ('Ệ', 'Ệ'), + ('Ỉ', 'Ỉ'), + ('Ị', 'Ị'), + ('Ọ', 'Ọ'), + ('Ỏ', 'Ỏ'), + ('Ố', 'Ố'), + ('Ồ', 'Ồ'), + ('Ổ', 'Ổ'), + ('Ỗ', 'Ỗ'), + ('Ộ', 'Ộ'), + ('Ớ', 'Ớ'), + ('Ờ', 'Ờ'), + ('Ở', 'Ở'), + ('Ỡ', 'Ỡ'), + ('Ợ', 'Ợ'), + ('Ụ', 'Ụ'), + ('Ủ', 'Ủ'), + ('Ứ', 'Ứ'), + ('Ừ', 'Ừ'), + ('Ử', 'Ử'), + ('Ữ', 'Ữ'), + ('Ự', 'Ự'), + ('Ỳ', 'Ỳ'), + ('Ỵ', 'Ỵ'), + ('Ỷ', 'Ỷ'), + ('Ỹ', 'Ỹ'), + ('Ỻ', 'Ỻ'), + ('Ỽ', 'Ỽ'), + ('Ỿ', 'Ỿ'), + ('Ἀ', 'Ἇ'), + ('Ἐ', 'Ἕ'), + ('Ἠ', 'Ἧ'), + ('Ἰ', 'Ἷ'), + ('Ὀ', 'Ὅ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'Ὗ'), + ('Ὠ', 'Ὧ'), + ('ᾈ', 'ᾏ'), + ('ᾘ', 'ᾟ'), + ('ᾨ', 'ᾯ'), + ('Ᾰ', 'ᾼ'), + ('Ὲ', 'ῌ'), + ('Ῐ', 'Ί'), + ('Ῠ', 'Ῥ'), + ('Ὸ', 'ῼ'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℋ', 'ℍ'), + ('ℐ', 'ℒ'), + ('ℕ', 'ℕ'), + ('ℙ', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℭ'), + ('ℰ', 'ℳ'), + ('ℾ', 'ℿ'), + ('ⅅ', 'ⅅ'), + ('Ⅰ', 'Ⅿ'), + ('Ↄ', 'Ↄ'), + ('Ⓐ', 'Ⓩ'), + ('Ⰰ', 'Ⱞ'), + ('Ⱡ', 'Ⱡ'), + ('Ɫ', 'Ɽ'), + ('Ⱨ', 'Ⱨ'), + ('Ⱪ', 'Ⱪ'), + ('Ⱬ', 'Ⱬ'), + ('Ɑ', 'Ɒ'), + ('Ⱳ', 'Ⱳ'), + ('Ⱶ', 'Ⱶ'), + ('Ȿ', 'Ⲁ'), + ('Ⲃ', 'Ⲃ'), + ('Ⲅ', 'Ⲅ'), + ('Ⲇ', 'Ⲇ'), + ('Ⲉ', 'Ⲉ'), + ('Ⲋ', 'Ⲋ'), + ('Ⲍ', 'Ⲍ'), + ('Ⲏ', 'Ⲏ'), + ('Ⲑ', 'Ⲑ'), + ('Ⲓ', 'Ⲓ'), + ('Ⲕ', 'Ⲕ'), + ('Ⲗ', 'Ⲗ'), + ('Ⲙ', 'Ⲙ'), + ('Ⲛ', 'Ⲛ'), + ('Ⲝ', 'Ⲝ'), + ('Ⲟ', 'Ⲟ'), + ('Ⲡ', 'Ⲡ'), + ('Ⲣ', 'Ⲣ'), + ('Ⲥ', 'Ⲥ'), + ('Ⲧ', 'Ⲧ'), + ('Ⲩ', 'Ⲩ'), + ('Ⲫ', 'Ⲫ'), + ('Ⲭ', 'Ⲭ'), + ('Ⲯ', 'Ⲯ'), + ('Ⲱ', 'Ⲱ'), + ('Ⲳ', 'Ⲳ'), + ('Ⲵ', 'Ⲵ'), + ('Ⲷ', 'Ⲷ'), + ('Ⲹ', 'Ⲹ'), + ('Ⲻ', 'Ⲻ'), + ('Ⲽ', 'Ⲽ'), + ('Ⲿ', 'Ⲿ'), + ('Ⳁ', 'Ⳁ'), + ('Ⳃ', 'Ⳃ'), + ('Ⳅ', 'Ⳅ'), + ('Ⳇ', 'Ⳇ'), + ('Ⳉ', 'Ⳉ'), + ('Ⳋ', 'Ⳋ'), + ('Ⳍ', 'Ⳍ'), + ('Ⳏ', 'Ⳏ'), + ('Ⳑ', 'Ⳑ'), + ('Ⳓ', 'Ⳓ'), + ('Ⳕ', 'Ⳕ'), + ('Ⳗ', 'Ⳗ'), + ('Ⳙ', 'Ⳙ'), + ('Ⳛ', 'Ⳛ'), + ('Ⳝ', 'Ⳝ'), + ('Ⳟ', 'Ⳟ'), + ('Ⳡ', 'Ⳡ'), + ('Ⳣ', 'Ⳣ'), + ('Ⳬ', 'Ⳬ'), + ('Ⳮ', 'Ⳮ'), + ('Ⳳ', 'Ⳳ'), + ('Ꙁ', 'Ꙁ'), + ('Ꙃ', 'Ꙃ'), + ('Ꙅ', 'Ꙅ'), + ('Ꙇ', 'Ꙇ'), + ('Ꙉ', 'Ꙉ'), + ('Ꙋ', 'Ꙋ'), + ('Ꙍ', 'Ꙍ'), + ('Ꙏ', 'Ꙏ'), + ('Ꙑ', 'Ꙑ'), + ('Ꙓ', 'Ꙓ'), + ('Ꙕ', 'Ꙕ'), + ('Ꙗ', 'Ꙗ'), + ('Ꙙ', 'Ꙙ'), + ('Ꙛ', 'Ꙛ'), + ('Ꙝ', 'Ꙝ'), + ('Ꙟ', 'Ꙟ'), + ('Ꙡ', 'Ꙡ'), + ('Ꙣ', 'Ꙣ'), + ('Ꙥ', 'Ꙥ'), + ('Ꙧ', 'Ꙧ'), + ('Ꙩ', 'Ꙩ'), + ('Ꙫ', 'Ꙫ'), + ('Ꙭ', 'Ꙭ'), + ('Ꚁ', 'Ꚁ'), + ('Ꚃ', 'Ꚃ'), + ('Ꚅ', 'Ꚅ'), + ('Ꚇ', 'Ꚇ'), + ('Ꚉ', 'Ꚉ'), + ('Ꚋ', 'Ꚋ'), + ('Ꚍ', 'Ꚍ'), + ('Ꚏ', 'Ꚏ'), + ('Ꚑ', 'Ꚑ'), + ('Ꚓ', 'Ꚓ'), + ('Ꚕ', 'Ꚕ'), + ('Ꚗ', 'Ꚗ'), + ('Ꚙ', 'Ꚙ'), + ('Ꚛ', 'Ꚛ'), + ('Ꜣ', 'Ꜣ'), + ('Ꜥ', 'Ꜥ'), + ('Ꜧ', 'Ꜧ'), + ('Ꜩ', 'Ꜩ'), + ('Ꜫ', 'Ꜫ'), + ('Ꜭ', 'Ꜭ'), + ('Ꜯ', 'Ꜯ'), + ('Ꜳ', 'Ꜳ'), + ('Ꜵ', 'Ꜵ'), + ('Ꜷ', 'Ꜷ'), + ('Ꜹ', 'Ꜹ'), + ('Ꜻ', 'Ꜻ'), + ('Ꜽ', 'Ꜽ'), + ('Ꜿ', 'Ꜿ'), + ('Ꝁ', 'Ꝁ'), + ('Ꝃ', 'Ꝃ'), + ('Ꝅ', 'Ꝅ'), + ('Ꝇ', 'Ꝇ'), + ('Ꝉ', 'Ꝉ'), + ('Ꝋ', 'Ꝋ'), + ('Ꝍ', 'Ꝍ'), + ('Ꝏ', 'Ꝏ'), + ('Ꝑ', 'Ꝑ'), + ('Ꝓ', 'Ꝓ'), + ('Ꝕ', 'Ꝕ'), + ('Ꝗ', 'Ꝗ'), + ('Ꝙ', 'Ꝙ'), + ('Ꝛ', 'Ꝛ'), + ('Ꝝ', 'Ꝝ'), + ('Ꝟ', 'Ꝟ'), + ('Ꝡ', 'Ꝡ'), + ('Ꝣ', 'Ꝣ'), + ('Ꝥ', 'Ꝥ'), + ('Ꝧ', 'Ꝧ'), + ('Ꝩ', 'Ꝩ'), + ('Ꝫ', 'Ꝫ'), + ('Ꝭ', 'Ꝭ'), + ('Ꝯ', 'Ꝯ'), + ('Ꝺ', 'Ꝺ'), + ('Ꝼ', 'Ꝼ'), + ('Ᵹ', 'Ꝿ'), + ('Ꞁ', 'Ꞁ'), + ('Ꞃ', 'Ꞃ'), + ('Ꞅ', 'Ꞅ'), + ('Ꞇ', 'Ꞇ'), + ('Ꞌ', 'Ꞌ'), + ('Ɥ', 'Ɥ'), + ('Ꞑ', 'Ꞑ'), + ('Ꞓ', 'Ꞓ'), + ('Ꞗ', 'Ꞗ'), + ('Ꞙ', 'Ꞙ'), + ('Ꞛ', 'Ꞛ'), + ('Ꞝ', 'Ꞝ'), + ('Ꞟ', 'Ꞟ'), + ('Ꞡ', 'Ꞡ'), + ('Ꞣ', 'Ꞣ'), + ('Ꞥ', 'Ꞥ'), + ('Ꞧ', 'Ꞧ'), + ('Ꞩ', 'Ꞩ'), + ('Ɦ', 'Ɪ'), + ('Ʞ', 'Ꞵ'), + ('Ꞷ', 'Ꞷ'), + ('Ꞹ', 'Ꞹ'), + ('\u{a7ba}', '\u{a7ba}'), + ('\u{a7bc}', '\u{a7bc}'), + ('\u{a7be}', '\u{a7be}'), + ('\u{a7c2}', '\u{a7c2}'), + ('\u{a7c4}', '\u{a7c6}'), + ('A', 'Z'), + ('𐐀', '𐐧'), + ('𐒰', '𐓓'), + ('𐲀', '𐲲'), + ('𑢠', '𑢿'), + ('𖹀', '𖹟'), + ('𝐀', '𝐙'), + ('𝐴', '𝑍'), + ('𝑨', '𝒁'), + ('𝒜', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒵'), + ('𝓐', '𝓩'), + ('𝔄', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔸', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕬', '𝖅'), + ('𝖠', '𝖹'), + ('𝗔', '𝗭'), + ('𝘈', '𝘡'), + ('𝘼', '𝙕'), + ('𝙰', '𝚉'), + ('𝚨', '𝛀'), + ('𝛢', '𝛺'), + ('𝜜', '𝜴'), + ('𝝖', '𝝮'), + ('𝞐', '𝞨'), + ('𝟊', '𝟊'), + ('𞤀', '𞤡'), + ('🄰', '🅉'), + ('🅐', '🅩'), + ('🅰', '🆉'), +]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/word_break.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/word_break.rs new file mode 100644 index 0000000..24f6fef --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/unicode_tables/word_break.rs @@ -0,0 +1,1035 @@ +// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY: +// +// ucd-generate word-break /tmp/ucd/12.1.0/ --chars +// +// ucd-generate is available on crates.io. + +pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] = &[ + ("ALetter", ALETTER), + ("CR", CR), + ("Double_Quote", DOUBLE_QUOTE), + ("Extend", EXTEND), + ("ExtendNumLet", EXTENDNUMLET), + ("Format", FORMAT), + ("Hebrew_Letter", HEBREW_LETTER), + ("Katakana", KATAKANA), + ("LF", LF), + ("MidLetter", MIDLETTER), + ("MidNum", MIDNUM), + ("MidNumLet", MIDNUMLET), + ("Newline", NEWLINE), + ("Numeric", NUMERIC), + ("Regional_Indicator", REGIONAL_INDICATOR), + ("Single_Quote", SINGLE_QUOTE), + ("WSegSpace", WSEGSPACE), + ("ZWJ", ZWJ), +]; + +pub const ALETTER: &'static [(char, char)] = &[ + ('A', 'Z'), + ('a', 'z'), + ('ª', 'ª'), + ('µ', 'µ'), + ('º', 'º'), + ('À', 'Ö'), + ('Ø', 'ö'), + ('ø', '˗'), + ('˞', 'ˤ'), + ('ˬ', '˿'), + ('Ͱ', 'ʹ'), + ('Ͷ', 'ͷ'), + ('ͺ', 'ͽ'), + ('Ϳ', 'Ϳ'), + ('Ά', 'Ά'), + ('Έ', 'Ί'), + ('Ό', 'Ό'), + ('Ύ', 'Ρ'), + ('Σ', 'ϵ'), + ('Ϸ', 'ҁ'), + ('Ҋ', 'ԯ'), + ('Ա', 'Ֆ'), + ('ՙ', 'ՙ'), + ('՛', '՜'), + ('՞', '՞'), + ('ՠ', 'ֈ'), + ('׳', '׳'), + ('ؠ', 'ي'), + ('ٮ', 'ٯ'), + ('ٱ', 'ۓ'), + ('ە', 'ە'), + ('ۥ', 'ۦ'), + ('ۮ', 'ۯ'), + ('ۺ', 'ۼ'), + ('ۿ', 'ۿ'), + ('ܐ', 'ܐ'), + ('ܒ', 'ܯ'), + ('ݍ', 'ޥ'), + ('ޱ', 'ޱ'), + ('ߊ', 'ߪ'), + ('ߴ', 'ߵ'), + ('ߺ', 'ߺ'), + ('ࠀ', 'ࠕ'), + ('ࠚ', 'ࠚ'), + ('ࠤ', 'ࠤ'), + ('ࠨ', 'ࠨ'), + ('ࡀ', 'ࡘ'), + ('ࡠ', 'ࡪ'), + ('ࢠ', 'ࢴ'), + ('ࢶ', 'ࢽ'), + ('ऄ', 'ह'), + ('ऽ', 'ऽ'), + ('ॐ', 'ॐ'), + ('क़', 'ॡ'), + ('ॱ', 'ঀ'), + ('অ', 'ঌ'), + ('এ', 'ঐ'), + ('ও', 'ন'), + ('প', 'র'), + ('ল', 'ল'), + ('শ', 'হ'), + ('ঽ', 'ঽ'), + ('ৎ', 'ৎ'), + ('ড়', 'ঢ়'), + ('য়', 'ৡ'), + ('ৰ', 'ৱ'), + ('ৼ', 'ৼ'), + ('ਅ', 'ਊ'), + ('ਏ', 'ਐ'), + ('ਓ', 'ਨ'), + ('ਪ', 'ਰ'), + ('ਲ', 'ਲ਼'), + ('ਵ', 'ਸ਼'), + ('ਸ', 'ਹ'), + ('ਖ਼', 'ੜ'), + ('ਫ਼', 'ਫ਼'), + ('ੲ', 'ੴ'), + ('અ', 'ઍ'), + ('એ', 'ઑ'), + ('ઓ', 'ન'), + ('પ', 'ર'), + ('લ', 'ળ'), + ('વ', 'હ'), + ('ઽ', 'ઽ'), + ('ૐ', 'ૐ'), + ('ૠ', 'ૡ'), + ('ૹ', 'ૹ'), + ('ଅ', 'ଌ'), + ('ଏ', 'ଐ'), + ('ଓ', 'ନ'), + ('ପ', 'ର'), + ('ଲ', 'ଳ'), + ('ଵ', 'ହ'), + ('ଽ', 'ଽ'), + ('ଡ଼', 'ଢ଼'), + ('ୟ', 'ୡ'), + ('ୱ', 'ୱ'), + ('ஃ', 'ஃ'), + ('அ', 'ஊ'), + ('எ', 'ஐ'), + ('ஒ', 'க'), + ('ங', 'ச'), + ('ஜ', 'ஜ'), + ('ஞ', 'ட'), + ('ண', 'த'), + ('ந', 'ப'), + ('ம', 'ஹ'), + ('ௐ', 'ௐ'), + ('అ', 'ఌ'), + ('ఎ', 'ఐ'), + ('ఒ', 'న'), + ('ప', 'హ'), + ('ఽ', 'ఽ'), + ('ౘ', 'ౚ'), + ('ౠ', 'ౡ'), + ('ಀ', 'ಀ'), + ('ಅ', 'ಌ'), + ('ಎ', 'ಐ'), + ('ಒ', 'ನ'), + ('ಪ', 'ಳ'), + ('ವ', 'ಹ'), + ('ಽ', 'ಽ'), + ('ೞ', 'ೞ'), + ('ೠ', 'ೡ'), + ('ೱ', 'ೲ'), + ('അ', 'ഌ'), + ('എ', 'ഐ'), + ('ഒ', 'ഺ'), + ('ഽ', 'ഽ'), + ('ൎ', 'ൎ'), + ('ൔ', 'ൖ'), + ('ൟ', 'ൡ'), + ('ൺ', 'ൿ'), + ('අ', 'ඖ'), + ('ක', 'න'), + ('ඳ', 'ර'), + ('ල', 'ල'), + ('ව', 'ෆ'), + ('ༀ', 'ༀ'), + ('ཀ', 'ཇ'), + ('ཉ', 'ཬ'), + ('ྈ', 'ྌ'), + ('Ⴀ', 'Ⴥ'), + ('Ⴧ', 'Ⴧ'), + ('Ⴭ', 'Ⴭ'), + ('ა', 'ჺ'), + ('ჼ', 'ቈ'), + ('ቊ', 'ቍ'), + ('ቐ', 'ቖ'), + ('ቘ', 'ቘ'), + ('ቚ', 'ቝ'), + ('በ', 'ኈ'), + ('ኊ', 'ኍ'), + ('ነ', 'ኰ'), + ('ኲ', 'ኵ'), + ('ኸ', 'ኾ'), + ('ዀ', 'ዀ'), + ('ዂ', 'ዅ'), + ('ወ', 'ዖ'), + ('ዘ', 'ጐ'), + ('ጒ', 'ጕ'), + ('ጘ', 'ፚ'), + ('ᎀ', 'ᎏ'), + ('Ꭰ', 'Ᏽ'), + ('ᏸ', 'ᏽ'), + ('ᐁ', 'ᙬ'), + ('ᙯ', 'ᙿ'), + ('ᚁ', 'ᚚ'), + ('ᚠ', 'ᛪ'), + ('ᛮ', 'ᛸ'), + ('ᜀ', 'ᜌ'), + ('ᜎ', 'ᜑ'), + ('ᜠ', 'ᜱ'), + ('ᝀ', 'ᝑ'), + ('ᝠ', 'ᝬ'), + ('ᝮ', 'ᝰ'), + ('ᠠ', 'ᡸ'), + ('ᢀ', 'ᢄ'), + ('ᢇ', 'ᢨ'), + ('ᢪ', 'ᢪ'), + ('ᢰ', 'ᣵ'), + ('ᤀ', 'ᤞ'), + ('ᨀ', 'ᨖ'), + ('ᬅ', 'ᬳ'), + ('ᭅ', 'ᭋ'), + ('ᮃ', 'ᮠ'), + ('ᮮ', 'ᮯ'), + ('ᮺ', 'ᯥ'), + ('ᰀ', 'ᰣ'), + ('ᱍ', 'ᱏ'), + ('ᱚ', 'ᱽ'), + ('ᲀ', 'ᲈ'), + ('Ა', 'Ჺ'), + ('Ჽ', 'Ჿ'), + ('ᳩ', 'ᳬ'), + ('ᳮ', 'ᳳ'), + ('ᳵ', 'ᳶ'), + ('\u{1cfa}', '\u{1cfa}'), + ('ᴀ', 'ᶿ'), + ('Ḁ', 'ἕ'), + ('Ἐ', 'Ἕ'), + ('ἠ', 'ὅ'), + ('Ὀ', 'Ὅ'), + ('ὐ', 'ὗ'), + ('Ὑ', 'Ὑ'), + ('Ὓ', 'Ὓ'), + ('Ὕ', 'Ὕ'), + ('Ὗ', 'ώ'), + ('ᾀ', 'ᾴ'), + ('ᾶ', 'ᾼ'), + ('ι', 'ι'), + ('ῂ', 'ῄ'), + ('ῆ', 'ῌ'), + ('ῐ', 'ΐ'), + ('ῖ', 'Ί'), + ('ῠ', 'Ῥ'), + ('ῲ', 'ῴ'), + ('ῶ', 'ῼ'), + ('ⁱ', 'ⁱ'), + ('ⁿ', 'ⁿ'), + ('ₐ', 'ₜ'), + ('ℂ', 'ℂ'), + ('ℇ', 'ℇ'), + ('ℊ', 'ℓ'), + ('ℕ', 'ℕ'), + ('ℙ', 'ℝ'), + ('ℤ', 'ℤ'), + ('Ω', 'Ω'), + ('ℨ', 'ℨ'), + ('K', 'ℭ'), + ('ℯ', 'ℹ'), + ('ℼ', 'ℿ'), + ('ⅅ', 'ⅉ'), + ('ⅎ', 'ⅎ'), + ('Ⅰ', 'ↈ'), + ('Ⓐ', 'ⓩ'), + ('Ⰰ', 'Ⱞ'), + ('ⰰ', 'ⱞ'), + ('Ⱡ', 'ⳤ'), + ('Ⳬ', 'ⳮ'), + ('Ⳳ', 'ⳳ'), + ('ⴀ', 'ⴥ'), + ('ⴧ', 'ⴧ'), + ('ⴭ', 'ⴭ'), + ('ⴰ', 'ⵧ'), + ('ⵯ', 'ⵯ'), + ('ⶀ', 'ⶖ'), + ('ⶠ', 'ⶦ'), + ('ⶨ', 'ⶮ'), + ('ⶰ', 'ⶶ'), + ('ⶸ', 'ⶾ'), + ('ⷀ', 'ⷆ'), + ('ⷈ', 'ⷎ'), + ('ⷐ', 'ⷖ'), + ('ⷘ', 'ⷞ'), + ('ⸯ', 'ⸯ'), + ('々', '々'), + ('〻', '〼'), + ('ㄅ', 'ㄯ'), + ('ㄱ', 'ㆎ'), + ('ㆠ', 'ㆺ'), + ('ꀀ', 'ꒌ'), + ('ꓐ', 'ꓽ'), + ('ꔀ', 'ꘌ'), + ('ꘐ', 'ꘟ'), + ('ꘪ', 'ꘫ'), + ('Ꙁ', 'ꙮ'), + ('ꙿ', 'ꚝ'), + ('ꚠ', 'ꛯ'), + ('ꜗ', '\u{a7bf}'), + ('\u{a7c2}', '\u{a7c6}'), + ('ꟷ', 'ꠁ'), + ('ꠃ', 'ꠅ'), + ('ꠇ', 'ꠊ'), + ('ꠌ', 'ꠢ'), + ('ꡀ', 'ꡳ'), + ('ꢂ', 'ꢳ'), + ('ꣲ', 'ꣷ'), + ('ꣻ', 'ꣻ'), + ('ꣽ', 'ꣾ'), + ('ꤊ', 'ꤥ'), + ('ꤰ', 'ꥆ'), + ('ꥠ', 'ꥼ'), + ('ꦄ', 'ꦲ'), + ('ꧏ', 'ꧏ'), + ('ꨀ', 'ꨨ'), + ('ꩀ', 'ꩂ'), + ('ꩄ', 'ꩋ'), + ('ꫠ', 'ꫪ'), + ('ꫲ', 'ꫴ'), + ('ꬁ', 'ꬆ'), + ('ꬉ', 'ꬎ'), + ('ꬑ', 'ꬖ'), + ('ꬠ', 'ꬦ'), + ('ꬨ', 'ꬮ'), + ('ꬰ', '\u{ab67}'), + ('ꭰ', 'ꯢ'), + ('가', '힣'), + ('ힰ', 'ퟆ'), + ('ퟋ', 'ퟻ'), + ('ff', 'st'), + ('ﬓ', 'ﬗ'), + ('ﭐ', 'ﮱ'), + ('ﯓ', 'ﴽ'), + ('ﵐ', 'ﶏ'), + ('ﶒ', 'ﷇ'), + ('ﷰ', 'ﷻ'), + ('ﹰ', 'ﹴ'), + ('ﹶ', 'ﻼ'), + ('A', 'Z'), + ('a', 'z'), + ('ᅠ', 'ᄒ'), + ('ᅡ', 'ᅦ'), + ('ᅧ', 'ᅬ'), + ('ᅭ', 'ᅲ'), + ('ᅳ', 'ᅵ'), + ('𐀀', '𐀋'), + ('𐀍', '𐀦'), + ('𐀨', '𐀺'), + ('𐀼', '𐀽'), + ('𐀿', '𐁍'), + ('𐁐', '𐁝'), + ('𐂀', '𐃺'), + ('𐅀', '𐅴'), + ('𐊀', '𐊜'), + ('𐊠', '𐋐'), + ('𐌀', '𐌟'), + ('𐌭', '𐍊'), + ('𐍐', '𐍵'), + ('𐎀', '𐎝'), + ('𐎠', '𐏃'), + ('𐏈', '𐏏'), + ('𐏑', '𐏕'), + ('𐐀', '𐒝'), + ('𐒰', '𐓓'), + ('𐓘', '𐓻'), + ('𐔀', '𐔧'), + ('𐔰', '𐕣'), + ('𐘀', '𐜶'), + ('𐝀', '𐝕'), + ('𐝠', '𐝧'), + ('𐠀', '𐠅'), + ('𐠈', '𐠈'), + ('𐠊', '𐠵'), + ('𐠷', '𐠸'), + ('𐠼', '𐠼'), + ('𐠿', '𐡕'), + ('𐡠', '𐡶'), + ('𐢀', '𐢞'), + ('𐣠', '𐣲'), + ('𐣴', '𐣵'), + ('𐤀', '𐤕'), + ('𐤠', '𐤹'), + ('𐦀', '𐦷'), + ('𐦾', '𐦿'), + ('𐨀', '𐨀'), + ('𐨐', '𐨓'), + ('𐨕', '𐨗'), + ('𐨙', '𐨵'), + ('𐩠', '𐩼'), + ('𐪀', '𐪜'), + ('𐫀', '𐫇'), + ('𐫉', '𐫤'), + ('𐬀', '𐬵'), + ('𐭀', '𐭕'), + ('𐭠', '𐭲'), + ('𐮀', '𐮑'), + ('𐰀', '𐱈'), + ('𐲀', '𐲲'), + ('𐳀', '𐳲'), + ('𐴀', '𐴣'), + ('𐼀', '𐼜'), + ('𐼧', '𐼧'), + ('𐼰', '𐽅'), + ('\u{10fe0}', '\u{10ff6}'), + ('𑀃', '𑀷'), + ('𑂃', '𑂯'), + ('𑃐', '𑃨'), + ('𑄃', '𑄦'), + ('𑅄', '𑅄'), + ('𑅐', '𑅲'), + ('𑅶', '𑅶'), + ('𑆃', '𑆲'), + ('𑇁', '𑇄'), + ('𑇚', '𑇚'), + ('𑇜', '𑇜'), + ('𑈀', '𑈑'), + ('𑈓', '𑈫'), + ('𑊀', '𑊆'), + ('𑊈', '𑊈'), + ('𑊊', '𑊍'), + ('𑊏', '𑊝'), + ('𑊟', '𑊨'), + ('𑊰', '𑋞'), + ('𑌅', '𑌌'), + ('𑌏', '𑌐'), + ('𑌓', '𑌨'), + ('𑌪', '𑌰'), + ('𑌲', '𑌳'), + ('𑌵', '𑌹'), + ('𑌽', '𑌽'), + ('𑍐', '𑍐'), + ('𑍝', '𑍡'), + ('𑐀', '𑐴'), + ('𑑇', '𑑊'), + ('\u{1145f}', '\u{1145f}'), + ('𑒀', '𑒯'), + ('𑓄', '𑓅'), + ('𑓇', '𑓇'), + ('𑖀', '𑖮'), + ('𑗘', '𑗛'), + ('𑘀', '𑘯'), + ('𑙄', '𑙄'), + ('𑚀', '𑚪'), + ('\u{116b8}', '\u{116b8}'), + ('𑠀', '𑠫'), + ('𑢠', '𑣟'), + ('𑣿', '𑣿'), + ('\u{119a0}', '\u{119a7}'), + ('\u{119aa}', '\u{119d0}'), + ('\u{119e1}', '\u{119e1}'), + ('\u{119e3}', '\u{119e3}'), + ('𑨀', '𑨀'), + ('𑨋', '𑨲'), + ('𑨺', '𑨺'), + ('𑩐', '𑩐'), + ('𑩜', '𑪉'), + ('𑪝', '𑪝'), + ('𑫀', '𑫸'), + ('𑰀', '𑰈'), + ('𑰊', '𑰮'), + ('𑱀', '𑱀'), + ('𑱲', '𑲏'), + ('𑴀', '𑴆'), + ('𑴈', '𑴉'), + ('𑴋', '𑴰'), + ('𑵆', '𑵆'), + ('𑵠', '𑵥'), + ('𑵧', '𑵨'), + ('𑵪', '𑶉'), + ('𑶘', '𑶘'), + ('𑻠', '𑻲'), + ('𒀀', '𒎙'), + ('𒐀', '𒑮'), + ('𒒀', '𒕃'), + ('𓀀', '𓐮'), + ('𔐀', '𔙆'), + ('𖠀', '𖨸'), + ('𖩀', '𖩞'), + ('𖫐', '𖫭'), + ('𖬀', '𖬯'), + ('𖭀', '𖭃'), + ('𖭣', '𖭷'), + ('𖭽', '𖮏'), + ('𖹀', '𖹿'), + ('𖼀', '\u{16f4a}'), + ('𖽐', '𖽐'), + ('𖾓', '𖾟'), + ('𖿠', '𖿡'), + ('\u{16fe3}', '\u{16fe3}'), + ('𛰀', '𛱪'), + ('𛱰', '𛱼'), + ('𛲀', '𛲈'), + ('𛲐', '𛲙'), + ('𝐀', '𝑔'), + ('𝑖', '𝒜'), + ('𝒞', '𝒟'), + ('𝒢', '𝒢'), + ('𝒥', '𝒦'), + ('𝒩', '𝒬'), + ('𝒮', '𝒹'), + ('𝒻', '𝒻'), + ('𝒽', '𝓃'), + ('𝓅', '𝔅'), + ('𝔇', '𝔊'), + ('𝔍', '𝔔'), + ('𝔖', '𝔜'), + ('𝔞', '𝔹'), + ('𝔻', '𝔾'), + ('𝕀', '𝕄'), + ('𝕆', '𝕆'), + ('𝕊', '𝕐'), + ('𝕒', '𝚥'), + ('𝚨', '𝛀'), + ('𝛂', '𝛚'), + ('𝛜', '𝛺'), + ('𝛼', '𝜔'), + ('𝜖', '𝜴'), + ('𝜶', '𝝎'), + ('𝝐', '𝝮'), + ('𝝰', '𝞈'), + ('𝞊', '𝞨'), + ('𝞪', '𝟂'), + ('𝟄', '𝟋'), + ('\u{1e100}', '\u{1e12c}'), + ('\u{1e137}', '\u{1e13d}'), + ('\u{1e14e}', '\u{1e14e}'), + ('\u{1e2c0}', '\u{1e2eb}'), + ('𞠀', '𞣄'), + ('𞤀', '𞥃'), + ('\u{1e94b}', '\u{1e94b}'), + ('𞸀', '𞸃'), + ('𞸅', '𞸟'), + ('𞸡', '𞸢'), + ('𞸤', '𞸤'), + ('𞸧', '𞸧'), + ('𞸩', '𞸲'), + ('𞸴', '𞸷'), + ('𞸹', '𞸹'), + ('𞸻', '𞸻'), + ('𞹂', '𞹂'), + ('𞹇', '𞹇'), + ('𞹉', '𞹉'), + ('𞹋', '𞹋'), + ('𞹍', '𞹏'), + ('𞹑', '𞹒'), + ('𞹔', '𞹔'), + ('𞹗', '𞹗'), + ('𞹙', '𞹙'), + ('𞹛', '𞹛'), + ('𞹝', '𞹝'), + ('𞹟', '𞹟'), + ('𞹡', '𞹢'), + ('𞹤', '𞹤'), + ('𞹧', '𞹪'), + ('𞹬', '𞹲'), + ('𞹴', '𞹷'), + ('𞹹', '𞹼'), + ('𞹾', '𞹾'), + ('𞺀', '𞺉'), + ('𞺋', '𞺛'), + ('𞺡', '𞺣'), + ('𞺥', '𞺩'), + ('𞺫', '𞺻'), + ('🄰', '🅉'), + ('🅐', '🅩'), + ('🅰', '🆉'), +]; + +pub const CR: &'static [(char, char)] = &[('\r', '\r')]; + +pub const DOUBLE_QUOTE: &'static [(char, char)] = &[('\"', '\"')]; + +pub const EXTEND: &'static [(char, char)] = &[ + ('\u{300}', '\u{36f}'), + ('\u{483}', '\u{489}'), + ('\u{591}', '\u{5bd}'), + ('\u{5bf}', '\u{5bf}'), + ('\u{5c1}', '\u{5c2}'), + ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), + ('\u{610}', '\u{61a}'), + ('\u{64b}', '\u{65f}'), + ('\u{670}', '\u{670}'), + ('\u{6d6}', '\u{6dc}'), + ('\u{6df}', '\u{6e4}'), + ('\u{6e7}', '\u{6e8}'), + ('\u{6ea}', '\u{6ed}'), + ('\u{711}', '\u{711}'), + ('\u{730}', '\u{74a}'), + ('\u{7a6}', '\u{7b0}'), + ('\u{7eb}', '\u{7f3}'), + ('\u{7fd}', '\u{7fd}'), + ('\u{816}', '\u{819}'), + ('\u{81b}', '\u{823}'), + ('\u{825}', '\u{827}'), + ('\u{829}', '\u{82d}'), + ('\u{859}', '\u{85b}'), + ('\u{8d3}', '\u{8e1}'), + ('\u{8e3}', 'ः'), + ('\u{93a}', '\u{93c}'), + ('ा', 'ॏ'), + ('\u{951}', '\u{957}'), + ('\u{962}', '\u{963}'), + ('\u{981}', 'ঃ'), + ('\u{9bc}', '\u{9bc}'), + ('\u{9be}', '\u{9c4}'), + ('ে', 'ৈ'), + ('ো', '\u{9cd}'), + ('\u{9d7}', '\u{9d7}'), + ('\u{9e2}', '\u{9e3}'), + ('\u{9fe}', '\u{9fe}'), + ('\u{a01}', 'ਃ'), + ('\u{a3c}', '\u{a3c}'), + ('ਾ', '\u{a42}'), + ('\u{a47}', '\u{a48}'), + ('\u{a4b}', '\u{a4d}'), + ('\u{a51}', '\u{a51}'), + ('\u{a70}', '\u{a71}'), + ('\u{a75}', '\u{a75}'), + ('\u{a81}', 'ઃ'), + ('\u{abc}', '\u{abc}'), + ('ા', '\u{ac5}'), + ('\u{ac7}', 'ૉ'), + ('ો', '\u{acd}'), + ('\u{ae2}', '\u{ae3}'), + ('\u{afa}', '\u{aff}'), + ('\u{b01}', 'ଃ'), + ('\u{b3c}', '\u{b3c}'), + ('\u{b3e}', '\u{b44}'), + ('େ', 'ୈ'), + ('ୋ', '\u{b4d}'), + ('\u{b56}', '\u{b57}'), + ('\u{b62}', '\u{b63}'), + ('\u{b82}', '\u{b82}'), + ('\u{bbe}', 'ூ'), + ('ெ', 'ை'), + ('ொ', '\u{bcd}'), + ('\u{bd7}', '\u{bd7}'), + ('\u{c00}', '\u{c04}'), + ('\u{c3e}', 'ౄ'), + ('\u{c46}', '\u{c48}'), + ('\u{c4a}', '\u{c4d}'), + ('\u{c55}', '\u{c56}'), + ('\u{c62}', '\u{c63}'), + ('\u{c81}', 'ಃ'), + ('\u{cbc}', '\u{cbc}'), + ('ಾ', 'ೄ'), + ('\u{cc6}', 'ೈ'), + ('ೊ', '\u{ccd}'), + ('\u{cd5}', '\u{cd6}'), + ('\u{ce2}', '\u{ce3}'), + ('\u{d00}', 'ഃ'), + ('\u{d3b}', '\u{d3c}'), + ('\u{d3e}', '\u{d44}'), + ('െ', 'ൈ'), + ('ൊ', '\u{d4d}'), + ('\u{d57}', '\u{d57}'), + ('\u{d62}', '\u{d63}'), + ('ං', 'ඃ'), + ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dd4}'), + ('\u{dd6}', '\u{dd6}'), + ('ෘ', '\u{ddf}'), + ('ෲ', 'ෳ'), + ('\u{e31}', '\u{e31}'), + ('\u{e34}', '\u{e3a}'), + ('\u{e47}', '\u{e4e}'), + ('\u{eb1}', '\u{eb1}'), + ('\u{eb4}', '\u{ebc}'), + ('\u{ec8}', '\u{ecd}'), + ('\u{f18}', '\u{f19}'), + ('\u{f35}', '\u{f35}'), + ('\u{f37}', '\u{f37}'), + ('\u{f39}', '\u{f39}'), + ('༾', '༿'), + ('\u{f71}', '\u{f84}'), + ('\u{f86}', '\u{f87}'), + ('\u{f8d}', '\u{f97}'), + ('\u{f99}', '\u{fbc}'), + ('\u{fc6}', '\u{fc6}'), + ('ါ', '\u{103e}'), + ('ၖ', '\u{1059}'), + ('\u{105e}', '\u{1060}'), + ('ၢ', 'ၤ'), + ('ၧ', 'ၭ'), + ('\u{1071}', '\u{1074}'), + ('\u{1082}', '\u{108d}'), + ('ႏ', 'ႏ'), + ('ႚ', '\u{109d}'), + ('\u{135d}', '\u{135f}'), + ('\u{1712}', '\u{1714}'), + ('\u{1732}', '\u{1734}'), + ('\u{1752}', '\u{1753}'), + ('\u{1772}', '\u{1773}'), + ('\u{17b4}', '\u{17d3}'), + ('\u{17dd}', '\u{17dd}'), + ('\u{180b}', '\u{180d}'), + ('\u{1885}', '\u{1886}'), + ('\u{18a9}', '\u{18a9}'), + ('\u{1920}', 'ᤫ'), + ('ᤰ', '\u{193b}'), + ('\u{1a17}', '\u{1a1b}'), + ('ᩕ', '\u{1a5e}'), + ('\u{1a60}', '\u{1a7c}'), + ('\u{1a7f}', '\u{1a7f}'), + ('\u{1ab0}', '\u{1abe}'), + ('\u{1b00}', 'ᬄ'), + ('\u{1b34}', '᭄'), + ('\u{1b6b}', '\u{1b73}'), + ('\u{1b80}', 'ᮂ'), + ('ᮡ', '\u{1bad}'), + ('\u{1be6}', '᯳'), + ('ᰤ', '\u{1c37}'), + ('\u{1cd0}', '\u{1cd2}'), + ('\u{1cd4}', '\u{1ce8}'), + ('\u{1ced}', '\u{1ced}'), + ('\u{1cf4}', '\u{1cf4}'), + ('᳷', '\u{1cf9}'), + ('\u{1dc0}', '\u{1df9}'), + ('\u{1dfb}', '\u{1dff}'), + ('\u{200c}', '\u{200c}'), + ('\u{20d0}', '\u{20f0}'), + ('\u{2cef}', '\u{2cf1}'), + ('\u{2d7f}', '\u{2d7f}'), + ('\u{2de0}', '\u{2dff}'), + ('\u{302a}', '\u{302f}'), + ('\u{3099}', '\u{309a}'), + ('\u{a66f}', '\u{a672}'), + ('\u{a674}', '\u{a67d}'), + ('\u{a69e}', '\u{a69f}'), + ('\u{a6f0}', '\u{a6f1}'), + ('\u{a802}', '\u{a802}'), + ('\u{a806}', '\u{a806}'), + ('\u{a80b}', '\u{a80b}'), + ('ꠣ', 'ꠧ'), + ('ꢀ', 'ꢁ'), + ('ꢴ', '\u{a8c5}'), + ('\u{a8e0}', '\u{a8f1}'), + ('\u{a8ff}', '\u{a8ff}'), + ('\u{a926}', '\u{a92d}'), + ('\u{a947}', '꥓'), + ('\u{a980}', 'ꦃ'), + ('\u{a9b3}', '꧀'), + ('\u{a9e5}', '\u{a9e5}'), + ('\u{aa29}', '\u{aa36}'), + ('\u{aa43}', '\u{aa43}'), + ('\u{aa4c}', 'ꩍ'), + ('ꩻ', 'ꩽ'), + ('\u{aab0}', '\u{aab0}'), + ('\u{aab2}', '\u{aab4}'), + ('\u{aab7}', '\u{aab8}'), + ('\u{aabe}', '\u{aabf}'), + ('\u{aac1}', '\u{aac1}'), + ('ꫫ', 'ꫯ'), + ('ꫵ', '\u{aaf6}'), + ('ꯣ', 'ꯪ'), + ('꯬', '\u{abed}'), + ('\u{fb1e}', '\u{fb1e}'), + ('\u{fe00}', '\u{fe0f}'), + ('\u{fe20}', '\u{fe2f}'), + ('\u{ff9e}', '\u{ff9f}'), + ('\u{101fd}', '\u{101fd}'), + ('\u{102e0}', '\u{102e0}'), + ('\u{10376}', '\u{1037a}'), + ('\u{10a01}', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), + ('\u{10a0c}', '\u{10a0f}'), + ('\u{10a38}', '\u{10a3a}'), + ('\u{10a3f}', '\u{10a3f}'), + ('\u{10ae5}', '\u{10ae6}'), + ('\u{10d24}', '\u{10d27}'), + ('\u{10f46}', '\u{10f50}'), + ('𑀀', '𑀂'), + ('\u{11038}', '\u{11046}'), + ('\u{1107f}', '𑂂'), + ('𑂰', '\u{110ba}'), + ('\u{11100}', '\u{11102}'), + ('\u{11127}', '\u{11134}'), + ('𑅅', '𑅆'), + ('\u{11173}', '\u{11173}'), + ('\u{11180}', '𑆂'), + ('𑆳', '𑇀'), + ('\u{111c9}', '\u{111cc}'), + ('𑈬', '\u{11237}'), + ('\u{1123e}', '\u{1123e}'), + ('\u{112df}', '\u{112ea}'), + ('\u{11300}', '𑌃'), + ('\u{1133b}', '\u{1133c}'), + ('\u{1133e}', '𑍄'), + ('𑍇', '𑍈'), + ('𑍋', '𑍍'), + ('\u{11357}', '\u{11357}'), + ('𑍢', '𑍣'), + ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), + ('𑐵', '\u{11446}'), + ('\u{1145e}', '\u{1145e}'), + ('\u{114b0}', '\u{114c3}'), + ('\u{115af}', '\u{115b5}'), + ('𑖸', '\u{115c0}'), + ('\u{115dc}', '\u{115dd}'), + ('𑘰', '\u{11640}'), + ('\u{116ab}', '\u{116b7}'), + ('\u{1171d}', '\u{1172b}'), + ('𑠬', '\u{1183a}'), + ('\u{119d1}', '\u{119d7}'), + ('\u{119da}', '\u{119e0}'), + ('\u{119e4}', '\u{119e4}'), + ('\u{11a01}', '\u{11a0a}'), + ('\u{11a33}', '𑨹'), + ('\u{11a3b}', '\u{11a3e}'), + ('\u{11a47}', '\u{11a47}'), + ('\u{11a51}', '\u{11a5b}'), + ('\u{11a8a}', '\u{11a99}'), + ('𑰯', '\u{11c36}'), + ('\u{11c38}', '\u{11c3f}'), + ('\u{11c92}', '\u{11ca7}'), + ('𑲩', '\u{11cb6}'), + ('\u{11d31}', '\u{11d36}'), + ('\u{11d3a}', '\u{11d3a}'), + ('\u{11d3c}', '\u{11d3d}'), + ('\u{11d3f}', '\u{11d45}'), + ('\u{11d47}', '\u{11d47}'), + ('𑶊', '𑶎'), + ('\u{11d90}', '\u{11d91}'), + ('𑶓', '\u{11d97}'), + ('\u{11ef3}', '𑻶'), + ('\u{16af0}', '\u{16af4}'), + ('\u{16b30}', '\u{16b36}'), + ('\u{16f4f}', '\u{16f4f}'), + ('𖽑', '\u{16f87}'), + ('\u{16f8f}', '\u{16f92}'), + ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d165}', '\u{1d169}'), + ('𝅭', '\u{1d172}'), + ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), + ('\u{1d1aa}', '\u{1d1ad}'), + ('\u{1d242}', '\u{1d244}'), + ('\u{1da00}', '\u{1da36}'), + ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), + ('\u{1da84}', '\u{1da84}'), + ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), + ('\u{1e000}', '\u{1e006}'), + ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), + ('\u{1e023}', '\u{1e024}'), + ('\u{1e026}', '\u{1e02a}'), + ('\u{1e130}', '\u{1e136}'), + ('\u{1e2ec}', '\u{1e2ef}'), + ('\u{1e8d0}', '\u{1e8d6}'), + ('\u{1e944}', '\u{1e94a}'), + ('🏻', '🏿'), + ('\u{e0020}', '\u{e007f}'), + ('\u{e0100}', '\u{e01ef}'), +]; + +pub const EXTENDNUMLET: &'static [(char, char)] = &[ + ('_', '_'), + ('\u{202f}', '\u{202f}'), + ('‿', '⁀'), + ('⁔', '⁔'), + ('︳', '︴'), + ('﹍', '﹏'), + ('_', '_'), +]; + +pub const FORMAT: &'static [(char, char)] = &[ + ('\u{ad}', '\u{ad}'), + ('\u{600}', '\u{605}'), + ('\u{61c}', '\u{61c}'), + ('\u{6dd}', '\u{6dd}'), + ('\u{70f}', '\u{70f}'), + ('\u{8e2}', '\u{8e2}'), + ('\u{180e}', '\u{180e}'), + ('\u{200e}', '\u{200f}'), + ('\u{202a}', '\u{202e}'), + ('\u{2060}', '\u{2064}'), + ('\u{2066}', '\u{206f}'), + ('\u{feff}', '\u{feff}'), + ('\u{fff9}', '\u{fffb}'), + ('\u{110bd}', '\u{110bd}'), + ('\u{110cd}', '\u{110cd}'), + ('\u{13430}', '\u{13438}'), + ('\u{1bca0}', '\u{1bca3}'), + ('\u{1d173}', '\u{1d17a}'), + ('\u{e0001}', '\u{e0001}'), +]; + +pub const HEBREW_LETTER: &'static [(char, char)] = &[ + ('א', 'ת'), + ('ׯ', 'ײ'), + ('יִ', 'יִ'), + ('ײַ', 'ﬨ'), + ('שׁ', 'זּ'), + ('טּ', 'לּ'), + ('מּ', 'מּ'), + ('נּ', 'סּ'), + ('ףּ', 'פּ'), + ('צּ', 'ﭏ'), +]; + +pub const KATAKANA: &'static [(char, char)] = &[ + ('〱', '〵'), + ('゛', '゜'), + ('゠', 'ヺ'), + ('ー', 'ヿ'), + ('ㇰ', 'ㇿ'), + ('㋐', '㋾'), + ('㌀', '㍗'), + ('ヲ', 'ン'), + ('𛀀', '𛀀'), + ('\u{1b164}', '\u{1b167}'), +]; + +pub const LF: &'static [(char, char)] = &[('\n', '\n')]; + +pub const MIDLETTER: &'static [(char, char)] = &[ + (':', ':'), + ('·', '·'), + ('·', '·'), + ('״', '״'), + ('‧', '‧'), + ('︓', '︓'), + ('﹕', '﹕'), + (':', ':'), +]; + +pub const MIDNUM: &'static [(char, char)] = &[ + (',', ','), + (';', ';'), + (';', ';'), + ('։', '։'), + ('،', '؍'), + ('٬', '٬'), + ('߸', '߸'), + ('⁄', '⁄'), + ('︐', '︐'), + ('︔', '︔'), + ('﹐', '﹐'), + ('﹔', '﹔'), + (',', ','), + (';', ';'), +]; + +pub const MIDNUMLET: &'static [(char, char)] = &[ + ('.', '.'), + ('‘', '’'), + ('․', '․'), + ('﹒', '﹒'), + (''', '''), + ('.', '.'), +]; + +pub const NEWLINE: &'static [(char, char)] = + &[('\u{b}', '\u{c}'), ('\u{85}', '\u{85}'), ('\u{2028}', '\u{2029}')]; + +pub const NUMERIC: &'static [(char, char)] = &[ + ('0', '9'), + ('٠', '٩'), + ('٫', '٫'), + ('۰', '۹'), + ('߀', '߉'), + ('०', '९'), + ('০', '৯'), + ('੦', '੯'), + ('૦', '૯'), + ('୦', '୯'), + ('௦', '௯'), + ('౦', '౯'), + ('೦', '೯'), + ('൦', '൯'), + ('෦', '෯'), + ('๐', '๙'), + ('໐', '໙'), + ('༠', '༩'), + ('၀', '၉'), + ('႐', '႙'), + ('០', '៩'), + ('᠐', '᠙'), + ('᥆', '᥏'), + ('᧐', '᧙'), + ('᪀', '᪉'), + ('᪐', '᪙'), + ('᭐', '᭙'), + ('᮰', '᮹'), + ('᱀', '᱉'), + ('᱐', '᱙'), + ('꘠', '꘩'), + ('꣐', '꣙'), + ('꤀', '꤉'), + ('꧐', '꧙'), + ('꧰', '꧹'), + ('꩐', '꩙'), + ('꯰', '꯹'), + ('0', '9'), + ('𐒠', '𐒩'), + ('𐴰', '𐴹'), + ('𑁦', '𑁯'), + ('𑃰', '𑃹'), + ('𑄶', '𑄿'), + ('𑇐', '𑇙'), + ('𑋰', '𑋹'), + ('𑑐', '𑑙'), + ('𑓐', '𑓙'), + ('𑙐', '𑙙'), + ('𑛀', '𑛉'), + ('𑜰', '𑜹'), + ('𑣠', '𑣩'), + ('𑱐', '𑱙'), + ('𑵐', '𑵙'), + ('𑶠', '𑶩'), + ('𖩠', '𖩩'), + ('𖭐', '𖭙'), + ('𝟎', '𝟿'), + ('\u{1e140}', '\u{1e149}'), + ('\u{1e2f0}', '\u{1e2f9}'), + ('𞥐', '𞥙'), +]; + +pub const REGIONAL_INDICATOR: &'static [(char, char)] = &[('🇦', '🇿')]; + +pub const SINGLE_QUOTE: &'static [(char, char)] = &[('\'', '\'')]; + +pub const WSEGSPACE: &'static [(char, char)] = &[ + (' ', ' '), + ('\u{1680}', '\u{1680}'), + ('\u{2000}', '\u{2006}'), + ('\u{2008}', '\u{200a}'), + ('\u{205f}', '\u{205f}'), + ('\u{3000}', '\u{3000}'), +]; + +pub const ZWJ: &'static [(char, char)] = &[('\u{200d}', '\u{200d}')]; diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/src/utf8.rs b/third_party/cargo/vendor/regex-syntax-0.6.13/src/utf8.rs new file mode 100644 index 0000000..de9c892 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/src/utf8.rs @@ -0,0 +1,521 @@ +/*! +Converts ranges of Unicode scalar values to equivalent ranges of UTF-8 bytes. + +This is sub-module is useful for constructing byte based automatons that need +to embed UTF-8 decoding. The most common use of this module is in conjunction +with the [`hir::ClassUnicodeRange`](../hir/struct.ClassUnicodeRange.html) type. + +See the documentation on the `Utf8Sequences` iterator for more details and +an example. + +# Wait, what is this? + +This is simplest to explain with an example. Let's say you wanted to test +whether a particular byte sequence was a Cyrillic character. One possible +scalar value range is `[0400-04FF]`. The set of allowed bytes for this +range can be expressed as a sequence of byte ranges: + +```ignore +[D0-D3][80-BF] +``` + +This is simple enough: simply encode the boundaries, `0400` encodes to +`D0 80` and `04FF` encodes to `D3 BF`, and create ranges from each +corresponding pair of bytes: `D0` to `D3` and `80` to `BF`. + +However, what if you wanted to add the Cyrillic Supplementary characters to +your range? Your range might then become `[0400-052F]`. The same procedure +as above doesn't quite work because `052F` encodes to `D4 AF`. The byte ranges +you'd get from the previous transformation would be `[D0-D4][80-AF]`. However, +this isn't quite correct because this range doesn't capture many characters, +for example, `04FF` (because its last byte, `BF` isn't in the range `80-AF`). + +Instead, you need multiple sequences of byte ranges: + +```ignore +[D0-D3][80-BF] # matches codepoints 0400-04FF +[D4][80-AF] # matches codepoints 0500-052F +``` + +This gets even more complicated if you want bigger ranges, particularly if +they naively contain surrogate codepoints. For example, the sequence of byte +ranges for the basic multilingual plane (`[0000-FFFF]`) look like this: + +```ignore +[0-7F] +[C2-DF][80-BF] +[E0][A0-BF][80-BF] +[E1-EC][80-BF][80-BF] +[ED][80-9F][80-BF] +[EE-EF][80-BF][80-BF] +``` + +Note that the byte ranges above will *not* match any erroneous encoding of +UTF-8, including encodings of surrogate codepoints. + +And, of course, for all of Unicode (`[000000-10FFFF]`): + +```ignore +[0-7F] +[C2-DF][80-BF] +[E0][A0-BF][80-BF] +[E1-EC][80-BF][80-BF] +[ED][80-9F][80-BF] +[EE-EF][80-BF][80-BF] +[F0][90-BF][80-BF][80-BF] +[F1-F3][80-BF][80-BF][80-BF] +[F4][80-8F][80-BF][80-BF] +``` + +This module automates the process of creating these byte ranges from ranges of +Unicode scalar values. + +# Lineage + +I got the idea and general implementation strategy from Russ Cox in his +[article on regexps](https://web.archive.org/web/20160404141123/https://swtch.com/~rsc/regexp/regexp3.html) and RE2. +Russ Cox got it from Ken Thompson's `grep` (no source, folk lore?). +I also got the idea from +[Lucene](https://github.com/apache/lucene-solr/blob/ae93f4e7ac6a3908046391de35d4f50a0d3c59ca/lucene/core/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java), +which uses it for executing automata on their term index. +*/ + +#![deny(missing_docs)] + +use std::char; +use std::fmt; +use std::slice; + +const MAX_UTF8_BYTES: usize = 4; + +/// Utf8Sequence represents a sequence of byte ranges. +/// +/// To match a Utf8Sequence, a candidate byte sequence must match each +/// successive range. +/// +/// For example, if there are two ranges, `[C2-DF][80-BF]`, then the byte +/// sequence `\xDD\x61` would not match because `0x61 < 0x80`. +#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord)] +pub enum Utf8Sequence { + /// One byte range. + One(Utf8Range), + /// Two successive byte ranges. + Two([Utf8Range; 2]), + /// Three successive byte ranges. + Three([Utf8Range; 3]), + /// Four successive byte ranges. + Four([Utf8Range; 4]), +} + +impl Utf8Sequence { + /// Creates a new UTF-8 sequence from the encoded bytes of a scalar value + /// range. + /// + /// This assumes that `start` and `end` have the same length. + fn from_encoded_range(start: &[u8], end: &[u8]) -> Self { + assert_eq!(start.len(), end.len()); + match start.len() { + 2 => Utf8Sequence::Two([ + Utf8Range::new(start[0], end[0]), + Utf8Range::new(start[1], end[1]), + ]), + 3 => Utf8Sequence::Three([ + Utf8Range::new(start[0], end[0]), + Utf8Range::new(start[1], end[1]), + Utf8Range::new(start[2], end[2]), + ]), + 4 => Utf8Sequence::Four([ + Utf8Range::new(start[0], end[0]), + Utf8Range::new(start[1], end[1]), + Utf8Range::new(start[2], end[2]), + Utf8Range::new(start[3], end[3]), + ]), + n => unreachable!("invalid encoded length: {}", n), + } + } + + /// Returns the underlying sequence of byte ranges as a slice. + pub fn as_slice(&self) -> &[Utf8Range] { + use self::Utf8Sequence::*; + match *self { + One(ref r) => slice::from_ref(r), + Two(ref r) => &r[..], + Three(ref r) => &r[..], + Four(ref r) => &r[..], + } + } + + /// Returns the number of byte ranges in this sequence. + /// + /// The length is guaranteed to be in the closed interval `[1, 4]`. + pub fn len(&self) -> usize { + self.as_slice().len() + } + + /// Returns true if and only if a prefix of `bytes` matches this sequence + /// of byte ranges. + pub fn matches(&self, bytes: &[u8]) -> bool { + if bytes.len() < self.len() { + return false; + } + for (&b, r) in bytes.iter().zip(self) { + if !r.matches(b) { + return false; + } + } + true + } +} + +impl<'a> IntoIterator for &'a Utf8Sequence { + type IntoIter = slice::Iter<'a, Utf8Range>; + type Item = &'a Utf8Range; + + fn into_iter(self) -> Self::IntoIter { + self.as_slice().into_iter() + } +} + +impl fmt::Debug for Utf8Sequence { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use self::Utf8Sequence::*; + match *self { + One(ref r) => write!(f, "{:?}", r), + Two(ref r) => write!(f, "{:?}{:?}", r[0], r[1]), + Three(ref r) => write!(f, "{:?}{:?}{:?}", r[0], r[1], r[2]), + Four(ref r) => { + write!(f, "{:?}{:?}{:?}{:?}", r[0], r[1], r[2], r[3]) + } + } + } +} + +/// A single inclusive range of UTF-8 bytes. +#[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Ord)] +pub struct Utf8Range { + /// Start of byte range (inclusive). + pub start: u8, + /// End of byte range (inclusive). + pub end: u8, +} + +impl Utf8Range { + fn new(start: u8, end: u8) -> Self { + Utf8Range { start: start, end: end } + } + + /// Returns true if and only if the given byte is in this range. + pub fn matches(&self, b: u8) -> bool { + self.start <= b && b <= self.end + } +} + +impl fmt::Debug for Utf8Range { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.start == self.end { + write!(f, "[{:X}]", self.start) + } else { + write!(f, "[{:X}-{:X}]", self.start, self.end) + } + } +} + +/// An iterator over ranges of matching UTF-8 byte sequences. +/// +/// The iteration represents an alternation of comprehensive byte sequences +/// that match precisely the set of UTF-8 encoded scalar values. +/// +/// A byte sequence corresponds to one of the scalar values in the range given +/// if and only if it completely matches exactly one of the sequences of byte +/// ranges produced by this iterator. +/// +/// Each sequence of byte ranges matches a unique set of bytes. That is, no two +/// sequences will match the same bytes. +/// +/// # Example +/// +/// This shows how to match an arbitrary byte sequence against a range of +/// scalar values. +/// +/// ```rust +/// use regex_syntax::utf8::{Utf8Sequences, Utf8Sequence}; +/// +/// fn matches(seqs: &[Utf8Sequence], bytes: &[u8]) -> bool { +/// for range in seqs { +/// if range.matches(bytes) { +/// return true; +/// } +/// } +/// false +/// } +/// +/// // Test the basic multilingual plane. +/// let seqs: Vec<_> = Utf8Sequences::new('\u{0}', '\u{FFFF}').collect(); +/// +/// // UTF-8 encoding of 'a'. +/// assert!(matches(&seqs, &[0x61])); +/// // UTF-8 encoding of '☃' (`\u{2603}`). +/// assert!(matches(&seqs, &[0xE2, 0x98, 0x83])); +/// // UTF-8 encoding of `\u{10348}` (outside the BMP). +/// assert!(!matches(&seqs, &[0xF0, 0x90, 0x8D, 0x88])); +/// // Tries to match against a UTF-8 encoding of a surrogate codepoint, +/// // which is invalid UTF-8, and therefore fails, despite the fact that +/// // the corresponding codepoint (0xD800) falls in the range given. +/// assert!(!matches(&seqs, &[0xED, 0xA0, 0x80])); +/// // And fails against plain old invalid UTF-8. +/// assert!(!matches(&seqs, &[0xFF, 0xFF])); +/// ``` +/// +/// If this example seems circuitous, that's because it is! It's meant to be +/// illustrative. In practice, you could just try to decode your byte sequence +/// and compare it with the scalar value range directly. However, this is not +/// always possible (for example, in a byte based automaton). +pub struct Utf8Sequences { + range_stack: Vec<ScalarRange>, +} + +impl Utf8Sequences { + /// Create a new iterator over UTF-8 byte ranges for the scalar value range + /// given. + pub fn new(start: char, end: char) -> Self { + let mut it = Utf8Sequences { range_stack: vec![] }; + it.push(start as u32, end as u32); + it + } + + /// reset resets the scalar value range. + /// Any existing state is cleared, but resources may be reused. + /// + /// N.B. Benchmarks say that this method is dubious. + #[doc(hidden)] + pub fn reset(&mut self, start: char, end: char) { + self.range_stack.clear(); + self.push(start as u32, end as u32); + } + + fn push(&mut self, start: u32, end: u32) { + self.range_stack.push(ScalarRange { start: start, end: end }); + } +} + +struct ScalarRange { + start: u32, + end: u32, +} + +impl fmt::Debug for ScalarRange { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ScalarRange({:X}, {:X})", self.start, self.end) + } +} + +impl Iterator for Utf8Sequences { + type Item = Utf8Sequence; + + fn next(&mut self) -> Option<Self::Item> { + 'TOP: while let Some(mut r) = self.range_stack.pop() { + 'INNER: loop { + if let Some((r1, r2)) = r.split() { + self.push(r2.start, r2.end); + r.start = r1.start; + r.end = r1.end; + continue 'INNER; + } + if !r.is_valid() { + continue 'TOP; + } + for i in 1..MAX_UTF8_BYTES { + let max = max_scalar_value(i); + if r.start <= max && max < r.end { + self.push(max + 1, r.end); + r.end = max; + continue 'INNER; + } + } + if let Some(ascii_range) = r.as_ascii() { + return Some(Utf8Sequence::One(ascii_range)); + } + for i in 1..MAX_UTF8_BYTES { + let m = (1 << (6 * i)) - 1; + if (r.start & !m) != (r.end & !m) { + if (r.start & m) != 0 { + self.push((r.start | m) + 1, r.end); + r.end = r.start | m; + continue 'INNER; + } + if (r.end & m) != m { + self.push(r.end & !m, r.end); + r.end = (r.end & !m) - 1; + continue 'INNER; + } + } + } + let mut start = [0; MAX_UTF8_BYTES]; + let mut end = [0; MAX_UTF8_BYTES]; + let n = r.encode(&mut start, &mut end); + return Some(Utf8Sequence::from_encoded_range( + &start[0..n], + &end[0..n], + )); + } + } + None + } +} + +impl ScalarRange { + /// split splits this range if it overlaps with a surrogate codepoint. + /// + /// Either or both ranges may be invalid. + fn split(&self) -> Option<(ScalarRange, ScalarRange)> { + if self.start < 0xE000 && self.end > 0xD7FF { + Some(( + ScalarRange { start: self.start, end: 0xD7FF }, + ScalarRange { start: 0xE000, end: self.end }, + )) + } else { + None + } + } + + /// is_valid returns true if and only if start <= end. + fn is_valid(&self) -> bool { + self.start <= self.end + } + + /// as_ascii returns this range as a Utf8Range if and only if all scalar + /// values in this range can be encoded as a single byte. + fn as_ascii(&self) -> Option<Utf8Range> { + if self.is_ascii() { + Some(Utf8Range::new(self.start as u8, self.end as u8)) + } else { + None + } + } + + /// is_ascii returns true if the range is ASCII only (i.e., takes a single + /// byte to encode any scalar value). + fn is_ascii(&self) -> bool { + self.is_valid() && self.end <= 0x7f + } + + /// encode writes the UTF-8 encoding of the start and end of this range + /// to the corresponding destination slices, and returns the number of + /// bytes written. + /// + /// The slices should have room for at least `MAX_UTF8_BYTES`. + fn encode(&self, start: &mut [u8], end: &mut [u8]) -> usize { + let cs = char::from_u32(self.start).unwrap(); + let ce = char::from_u32(self.end).unwrap(); + let ss = cs.encode_utf8(start); + let se = ce.encode_utf8(end); + assert_eq!(ss.len(), se.len()); + ss.len() + } +} + +fn max_scalar_value(nbytes: usize) -> u32 { + match nbytes { + 1 => 0x007F, + 2 => 0x07FF, + 3 => 0xFFFF, + 4 => 0x10FFFF, + _ => unreachable!("invalid UTF-8 byte sequence size"), + } +} + +#[cfg(test)] +mod tests { + use std::char; + + use utf8::{Utf8Range, Utf8Sequences}; + + fn rutf8(s: u8, e: u8) -> Utf8Range { + Utf8Range::new(s, e) + } + + fn never_accepts_surrogate_codepoints(start: char, end: char) { + for cp in 0xD800..0xE000 { + let buf = encode_surrogate(cp); + for r in Utf8Sequences::new(start, end) { + if r.matches(&buf) { + panic!( + "Sequence ({:X}, {:X}) contains range {:?}, \ + which matches surrogate code point {:X} \ + with encoded bytes {:?}", + start as u32, end as u32, r, cp, buf, + ); + } + } + } + } + + #[test] + fn codepoints_no_surrogates() { + never_accepts_surrogate_codepoints('\u{0}', '\u{FFFF}'); + never_accepts_surrogate_codepoints('\u{0}', '\u{10FFFF}'); + never_accepts_surrogate_codepoints('\u{0}', '\u{10FFFE}'); + never_accepts_surrogate_codepoints('\u{80}', '\u{10FFFF}'); + never_accepts_surrogate_codepoints('\u{D7FF}', '\u{E000}'); + } + + #[test] + fn single_codepoint_one_sequence() { + // Tests that every range of scalar values that contains a single + // scalar value is recognized by one sequence of byte ranges. + for i in 0x0..(0x10FFFF + 1) { + let c = match char::from_u32(i) { + None => continue, + Some(c) => c, + }; + let seqs: Vec<_> = Utf8Sequences::new(c, c).collect(); + assert_eq!(seqs.len(), 1); + } + } + + #[test] + fn bmp() { + use utf8::Utf8Sequence::*; + + let seqs = Utf8Sequences::new('\u{0}', '\u{FFFF}').collect::<Vec<_>>(); + assert_eq!( + seqs, + vec![ + One(rutf8(0x0, 0x7F)), + Two([rutf8(0xC2, 0xDF), rutf8(0x80, 0xBF)]), + Three([ + rutf8(0xE0, 0xE0), + rutf8(0xA0, 0xBF), + rutf8(0x80, 0xBF) + ]), + Three([ + rutf8(0xE1, 0xEC), + rutf8(0x80, 0xBF), + rutf8(0x80, 0xBF) + ]), + Three([ + rutf8(0xED, 0xED), + rutf8(0x80, 0x9F), + rutf8(0x80, 0xBF) + ]), + Three([ + rutf8(0xEE, 0xEF), + rutf8(0x80, 0xBF), + rutf8(0x80, 0xBF) + ]), + ] + ); + } + + fn encode_surrogate(cp: u32) -> [u8; 3] { + const TAG_CONT: u8 = 0b1000_0000; + const TAG_THREE_B: u8 = 0b1110_0000; + + assert!(0xD800 <= cp && cp < 0xE000); + let mut dst = [0; 3]; + dst[0] = (cp >> 12 & 0x0F) as u8 | TAG_THREE_B; + dst[1] = (cp >> 6 & 0x3F) as u8 | TAG_CONT; + dst[2] = (cp & 0x3F) as u8 | TAG_CONT; + dst + } +} diff --git a/third_party/cargo/vendor/regex-syntax-0.6.13/test b/third_party/cargo/vendor/regex-syntax-0.6.13/test new file mode 100755 index 0000000..9970a99 --- /dev/null +++ b/third_party/cargo/vendor/regex-syntax-0.6.13/test @@ -0,0 +1,20 @@ +#!/bin/bash + +# This is a convenience script for running a broad swath of the syntax tests. +echo "===== DEFAULT FEATURES ===" +cargo test + +features=( + unicode + unicode-age + unicode-bool + unicode-case + unicode-gencat + unicode-perl + unicode-script + unicode-segment +) +for f in "${features[@]}"; do + echo "===== FEATURE: $f ===" + cargo test --no-default-features --features "$f" +done diff --git a/third_party/cargo/vendor/rustc-demangle-0.1.16/.cargo-checksum.json b/third_party/cargo/vendor/rustc-demangle-0.1.16/.cargo-checksum.json new file mode 100644 index 0000000..f041b63 --- /dev/null +++ b/third_party/cargo/vendor/rustc-demangle-0.1.16/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"ead05c6446fe945323775a2805e07aae6784238364fa07a84a72d38f7363c5d1","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"7bb7dbc6378a31b5b925a0cff628a69006c77a4cdf3533f7507b7c8fbe3492b0","src/legacy.rs":"3d469f6ba81129500a23b5975c9f099020c734bd26bb039d1030bf359d3d53fc","src/lib.rs":"4069dce717cdc52933b39991b401834b5aa5cd02fa2cffb78691397a97a467be","src/v0.rs":"9c4df16df15277abe500a539876e77907cda248da4822a921b708d6d4468ff4a"},"package":"4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rustc-demangle-0.1.16/BUILD b/third_party/cargo/vendor/rustc-demangle-0.1.16/BUILD new file mode 100644 index 0000000..45ada52 --- /dev/null +++ b/third_party/cargo/vendor/rustc-demangle-0.1.16/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "rustc_demangle", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.16", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/rustc-demangle-0.1.16/Cargo.toml b/third_party/cargo/vendor/rustc-demangle-0.1.16/Cargo.toml new file mode 100644 index 0000000..9dac4e4 --- /dev/null +++ b/third_party/cargo/vendor/rustc-demangle-0.1.16/Cargo.toml @@ -0,0 +1,33 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rustc-demangle" +version = "0.1.16" +authors = ["Alex Crichton <alex@alexcrichton.com>"] +description = "Rust compiler symbol demangling.\n" +homepage = "https://github.com/alexcrichton/rustc-demangle" +documentation = "https://docs.rs/rustc-demangle" +readme = "README.md" +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/rustc-demangle" +[dependencies.compiler_builtins] +version = "0.1.2" +optional = true + +[dependencies.core] +version = "1.0.0" +optional = true +package = "rustc-std-workspace-core" + +[features] +rustc-dep-of-std = ["core", "compiler_builtins"] diff --git a/third_party/cargo/vendor/rustc-demangle-0.1.16/LICENSE-APACHE b/third_party/cargo/vendor/rustc-demangle-0.1.16/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/rustc-demangle-0.1.16/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rustc-demangle-0.1.16/LICENSE-MIT b/third_party/cargo/vendor/rustc-demangle-0.1.16/LICENSE-MIT new file mode 100644 index 0000000..39e0ed6 --- /dev/null +++ b/third_party/cargo/vendor/rustc-demangle-0.1.16/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rustc-demangle-0.1.16/README.md b/third_party/cargo/vendor/rustc-demangle-0.1.16/README.md new file mode 100644 index 0000000..4b480b8 --- /dev/null +++ b/third_party/cargo/vendor/rustc-demangle-0.1.16/README.md @@ -0,0 +1,24 @@ +# rustc-demangle + +Symbol demangling for Rust + +[![Build Status](https://travis-ci.org/alexcrichton/rustc-demangle.svg?branch=master)](https://travis-ci.org/alexcrichton/rustc-demangle) + +[Documentation](https://docs.rs/rustc-demangle) + +# License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in rustc-demangle you, as defined in the Apache-2.0 license, shall +be dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/rustc-demangle-0.1.16/src/legacy.rs b/third_party/cargo/vendor/rustc-demangle-0.1.16/src/legacy.rs new file mode 100644 index 0000000..5e30797 --- /dev/null +++ b/third_party/cargo/vendor/rustc-demangle-0.1.16/src/legacy.rs @@ -0,0 +1,379 @@ +use core::char; +use core::fmt; + +/// Representation of a demangled symbol name. +pub struct Demangle<'a> { + inner: &'a str, + /// The number of ::-separated elements in the original name. + elements: usize, +} + +/// De-mangles a Rust symbol into a more readable version +/// +/// All Rust symbols by default are mangled as they contain characters that +/// cannot be represented in all object files. The mangling mechanism is similar +/// to C++'s, but Rust has a few specifics to handle items like lifetimes in +/// symbols. +/// +/// This function will take a **mangled** symbol and return a value. When printed, +/// the de-mangled version will be written. If the symbol does not look like +/// a mangled symbol, the original value will be written instead. +/// +/// # Examples +/// +/// ``` +/// use rustc_demangle::demangle; +/// +/// assert_eq!(demangle("_ZN4testE").to_string(), "test"); +/// assert_eq!(demangle("_ZN3foo3barE").to_string(), "foo::bar"); +/// assert_eq!(demangle("foo").to_string(), "foo"); +/// ``` + +// All Rust symbols are in theory lists of "::"-separated identifiers. Some +// assemblers, however, can't handle these characters in symbol names. To get +// around this, we use C++-style mangling. The mangling method is: +// +// 1. Prefix the symbol with "_ZN" +// 2. For each element of the path, emit the length plus the element +// 3. End the path with "E" +// +// For example, "_ZN4testE" => "test" and "_ZN3foo3barE" => "foo::bar". +// +// We're the ones printing our backtraces, so we can't rely on anything else to +// demangle our symbols. It's *much* nicer to look at demangled symbols, so +// this function is implemented to give us nice pretty output. +// +// Note that this demangler isn't quite as fancy as it could be. We have lots +// of other information in our symbols like hashes, version, type information, +// etc. Additionally, this doesn't handle glue symbols at all. +pub fn demangle(s: &str) -> Result<(Demangle, &str), ()> { + // First validate the symbol. If it doesn't look like anything we're + // expecting, we just print it literally. Note that we must handle non-Rust + // symbols because we could have any function in the backtrace. + let inner = if s.starts_with("_ZN") { + &s[3..] + } else if s.starts_with("ZN") { + // On Windows, dbghelp strips leading underscores, so we accept "ZN...E" + // form too. + &s[2..] + } else if s.starts_with("__ZN") { + // On OSX, symbols are prefixed with an extra _ + &s[4..] + } else { + return Err(()); + }; + + // only work with ascii text + if inner.bytes().any(|c| c & 0x80 != 0) { + return Err(()); + } + + let mut elements = 0; + let mut chars = inner.chars(); + let mut c = try!(chars.next().ok_or(())); + while c != 'E' { + // Decode an identifier element's length. + if !c.is_digit(10) { + return Err(()); + } + let mut len = 0usize; + while let Some(d) = c.to_digit(10) { + len = try!(len.checked_mul(10) + .and_then(|len| len.checked_add(d as usize)) + .ok_or(())); + c = try!(chars.next().ok_or(())); + } + + // `c` already contains the first character of this identifier, skip it and + // all the other characters of this identifier, to reach the next element. + for _ in 0..len { + c = try!(chars.next().ok_or(())); + } + + elements += 1; + } + + Ok((Demangle { + inner: inner, + elements: elements, + }, chars.as_str())) +} + +// Rust hashes are hex digits with an `h` prepended. +fn is_rust_hash(s: &str) -> bool { + s.starts_with('h') && s[1..].chars().all(|c| c.is_digit(16)) +} + +impl<'a> fmt::Display for Demangle<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // Alright, let's do this. + let mut inner = self.inner; + for element in 0..self.elements { + let mut rest = inner; + while rest.chars().next().unwrap().is_digit(10) { + rest = &rest[1..]; + } + let i: usize = inner[..(inner.len() - rest.len())].parse().unwrap(); + inner = &rest[i..]; + rest = &rest[..i]; + // Skip printing the hash if alternate formatting + // was requested. + if f.alternate() && element+1 == self.elements && is_rust_hash(&rest) { + break; + } + if element != 0 { + try!(f.write_str("::")); + } + if rest.starts_with("_$") { + rest = &rest[1..]; + } + loop { + if rest.starts_with('.') { + if let Some('.') = rest[1..].chars().next() { + try!(f.write_str("::")); + rest = &rest[2..]; + } else { + try!(f.write_str(".")); + rest = &rest[1..]; + } + } else if rest.starts_with('$') { + let (escape, after_escape) = if let Some(end) = rest[1..].find('$') { + (&rest[1..end + 1], &rest[end + 2..]) + } else { + break; + }; + + // see src/librustc_codegen_utils/symbol_names/legacy.rs for these mappings + let unescaped = match escape { + "SP" => "@", + "BP" => "*", + "RF" => "&", + "LT" => "<", + "GT" => ">", + "LP" => "(", + "RP" => ")", + "C" => ",", + + _ => { + if escape.starts_with('u') { + let digits = &escape[1..]; + let all_lower_hex = digits.chars().all(|c| match c { + '0'...'9' | 'a'...'f' => true, + _ => false, + }); + let c = u32::from_str_radix(digits, 16).ok() + .and_then(char::from_u32); + if let (true, Some(c)) = (all_lower_hex, c) { + // FIXME(eddyb) do we need to filter out control codepoints? + if !c.is_control() { + try!(c.fmt(f)); + rest = after_escape; + continue; + } + } + } + break; + } + }; + try!(f.write_str(unescaped)); + rest = after_escape; + } else if let Some(i) = rest.find(|c| c == '$' || c == '.') { + try!(f.write_str(&rest[..i])); + rest = &rest[i..]; + } else { + break; + } + } + try!(f.write_str(rest)); + } + + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use std::prelude::v1::*; + + macro_rules! t { + ($a:expr, $b:expr) => (assert!(ok($a, $b))) + } + + macro_rules! t_err { + ($a:expr) => (assert!(ok_err($a))) + } + + macro_rules! t_nohash { + ($a:expr, $b:expr) => ({ + assert_eq!(format!("{:#}", ::demangle($a)), $b); + }) + } + + fn ok(sym: &str, expected: &str) -> bool { + match ::try_demangle(sym) { + Ok(s) => { + if s.to_string() == expected { + true + } else { + println!("\n{}\n!=\n{}\n", s, expected); + false + } + } + Err(_) => { + println!("error demangling"); + false + } + } + } + + fn ok_err(sym: &str) -> bool { + match ::try_demangle(sym) { + Ok(_) => { + println!("succeeded in demangling"); + false + } + Err(_) => ::demangle(sym).to_string() == sym, + } + } + + #[test] + fn demangle() { + t_err!("test"); + t!("_ZN4testE", "test"); + t_err!("_ZN4test"); + t!("_ZN4test1a2bcE", "test::a::bc"); + } + + #[test] + fn demangle_dollars() { + t!("_ZN4$RP$E", ")"); + t!("_ZN8$RF$testE", "&test"); + t!("_ZN8$BP$test4foobE", "*test::foob"); + t!("_ZN9$u20$test4foobE", " test::foob"); + t!("_ZN35Bar$LT$$u5b$u32$u3b$$u20$4$u5d$$GT$E", "Bar<[u32; 4]>"); + } + + #[test] + fn demangle_many_dollars() { + t!("_ZN13test$u20$test4foobE", "test test::foob"); + t!("_ZN12test$BP$test4foobE", "test*test::foob"); + } + + + #[test] + fn demangle_osx() { + t!("__ZN5alloc9allocator6Layout9for_value17h02a996811f781011E", "alloc::allocator::Layout::for_value::h02a996811f781011"); + t!("__ZN38_$LT$core..option..Option$LT$T$GT$$GT$6unwrap18_MSG_FILE_LINE_COL17haf7cb8d5824ee659E", "<core::option::Option<T>>::unwrap::_MSG_FILE_LINE_COL::haf7cb8d5824ee659"); + t!("__ZN4core5slice89_$LT$impl$u20$core..iter..traits..IntoIterator$u20$for$u20$$RF$$u27$a$u20$$u5b$T$u5d$$GT$9into_iter17h450e234d27262170E", "core::slice::<impl core::iter::traits::IntoIterator for &'a [T]>::into_iter::h450e234d27262170"); + } + + #[test] + fn demangle_windows() { + t!("ZN4testE", "test"); + t!("ZN13test$u20$test4foobE", "test test::foob"); + t!("ZN12test$RF$test4foobE", "test&test::foob"); + } + + #[test] + fn demangle_elements_beginning_with_underscore() { + t!("_ZN13_$LT$test$GT$E", "<test>"); + t!("_ZN28_$u7b$$u7b$closure$u7d$$u7d$E", "{{closure}}"); + t!("_ZN15__STATIC_FMTSTRE", "__STATIC_FMTSTR"); + } + + #[test] + fn demangle_trait_impls() { + t!("_ZN71_$LT$Test$u20$$u2b$$u20$$u27$static$u20$as$u20$foo..Bar$LT$Test$GT$$GT$3barE", + "<Test + 'static as foo::Bar<Test>>::bar"); + } + + #[test] + fn demangle_without_hash() { + let s = "_ZN3foo17h05af221e174051e9E"; + t!(s, "foo::h05af221e174051e9"); + t_nohash!(s, "foo"); + } + + #[test] + fn demangle_without_hash_edgecases() { + // One element, no hash. + t_nohash!("_ZN3fooE", "foo"); + // Two elements, no hash. + t_nohash!("_ZN3foo3barE", "foo::bar"); + // Longer-than-normal hash. + t_nohash!("_ZN3foo20h05af221e174051e9abcE", "foo"); + // Shorter-than-normal hash. + t_nohash!("_ZN3foo5h05afE", "foo"); + // Valid hash, but not at the end. + t_nohash!("_ZN17h05af221e174051e93fooE", "h05af221e174051e9::foo"); + // Not a valid hash, missing the 'h'. + t_nohash!("_ZN3foo16ffaf221e174051e9E", "foo::ffaf221e174051e9"); + // Not a valid hash, has a non-hex-digit. + t_nohash!("_ZN3foo17hg5af221e174051e9E", "foo::hg5af221e174051e9"); + } + + #[test] + fn demangle_thinlto() { + // One element, no hash. + t!("_ZN3fooE.llvm.9D1C9369", "foo"); + t!("_ZN3fooE.llvm.9D1C9369@@16", "foo"); + t_nohash!("_ZN9backtrace3foo17hbb467fcdaea5d79bE.llvm.A5310EB9", "backtrace::foo"); + } + + #[test] + fn demangle_llvm_ir_branch_labels() { + t!("_ZN4core5slice77_$LT$impl$u20$core..ops..index..IndexMut$LT$I$GT$$u20$for$u20$$u5b$T$u5d$$GT$9index_mut17haf9727c2edfbc47bE.exit.i.i", "core::slice::<impl core::ops::index::IndexMut<I> for [T]>::index_mut::haf9727c2edfbc47b.exit.i.i"); + t_nohash!("_ZN4core5slice77_$LT$impl$u20$core..ops..index..IndexMut$LT$I$GT$$u20$for$u20$$u5b$T$u5d$$GT$9index_mut17haf9727c2edfbc47bE.exit.i.i", "core::slice::<impl core::ops::index::IndexMut<I> for [T]>::index_mut.exit.i.i"); + } + + #[test] + fn demangle_ignores_suffix_that_doesnt_look_like_a_symbol() { + t_err!("_ZN3fooE.llvm moocow"); + } + + #[test] + fn dont_panic() { + ::demangle("_ZN2222222222222222222222EE").to_string(); + ::demangle("_ZN5*70527e27.ll34csaғE").to_string(); + ::demangle("_ZN5*70527a54.ll34_$b.1E").to_string(); + ::demangle("\ + _ZN5~saäb4e\n\ + 2734cOsbE\n\ + 5usage20h)3\0\0\0\0\0\0\07e2734cOsbE\ + ").to_string(); + } + + #[test] + fn invalid_no_chop() { + t_err!("_ZNfooE"); + } + + #[test] + fn handle_assoc_types() { + t!("_ZN151_$LT$alloc..boxed..Box$LT$alloc..boxed..FnBox$LT$A$C$$u20$Output$u3d$R$GT$$u20$$u2b$$u20$$u27$a$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$9call_once17h69e8f44b3723e1caE", "<alloc::boxed::Box<alloc::boxed::FnBox<A, Output=R> + 'a> as core::ops::function::FnOnce<A>>::call_once::h69e8f44b3723e1ca"); + } + + #[test] + fn handle_bang() { + t!( + "_ZN88_$LT$core..result..Result$LT$$u21$$C$$u20$E$GT$$u20$as$u20$std..process..Termination$GT$6report17hfc41d0da4a40b3e8E", + "<core::result::Result<!, E> as std::process::Termination>::report::hfc41d0da4a40b3e8" + ); + } + + #[test] + fn demangle_utf8_idents() { + t_nohash!( + "_ZN11utf8_idents157_$u10e1$$u10d0$$u10ed$$u10db$$u10d4$$u10da$$u10d0$$u10d3$_$u10d2$$u10d4$$u10db$$u10e0$$u10d8$$u10d4$$u10da$$u10d8$_$u10e1$$u10d0$$u10d3$$u10d8$$u10da$$u10d8$17h21634fd5714000aaE", + "utf8_idents::საჭმელად_გემრიელი_სადილი" + ); + } + + #[test] + fn demangle_issue_60925() { + t_nohash!( + "_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17h059a991a004536adE", + "issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo" + ); + } +} diff --git a/third_party/cargo/vendor/rustc-demangle-0.1.16/src/lib.rs b/third_party/cargo/vendor/rustc-demangle-0.1.16/src/lib.rs new file mode 100644 index 0000000..19778d8 --- /dev/null +++ b/third_party/cargo/vendor/rustc-demangle-0.1.16/src/lib.rs @@ -0,0 +1,373 @@ +//! Demangle Rust compiler symbol names. +//! +//! This crate provides a `demangle` function which will return a `Demangle` +//! sentinel value that can be used to learn about the demangled version of a +//! symbol name. The demangled representation will be the same as the original +//! if it doesn't look like a mangled symbol name. +//! +//! `Demangle` can be formatted with the `Display` trait. The alternate +//! modifier (`#`) can be used to format the symbol name without the +//! trailing hash value. +//! +//! # Examples +//! +//! ``` +//! use rustc_demangle::demangle; +//! +//! assert_eq!(demangle("_ZN4testE").to_string(), "test"); +//! assert_eq!(demangle("_ZN3foo3barE").to_string(), "foo::bar"); +//! assert_eq!(demangle("foo").to_string(), "foo"); +//! // With hash +//! assert_eq!(format!("{}", demangle("_ZN3foo17h05af221e174051e9E")), "foo::h05af221e174051e9"); +//! // Without hash +//! assert_eq!(format!("{:#}", demangle("_ZN3foo17h05af221e174051e9E")), "foo"); +//! ``` + +#![no_std] +#![deny(missing_docs)] + +#[cfg(test)] +#[macro_use] +extern crate std; + +mod legacy; +mod v0; + +use core::fmt; + +/// Representation of a demangled symbol name. +pub struct Demangle<'a> { + style: Option<DemangleStyle<'a>>, + original: &'a str, + suffix: &'a str, +} + +enum DemangleStyle<'a> { + Legacy(legacy::Demangle<'a>), + V0(v0::Demangle<'a>), +} + +/// De-mangles a Rust symbol into a more readable version +/// +/// This function will take a **mangled** symbol and return a value. When printed, +/// the de-mangled version will be written. If the symbol does not look like +/// a mangled symbol, the original value will be written instead. +/// +/// # Examples +/// +/// ``` +/// use rustc_demangle::demangle; +/// +/// assert_eq!(demangle("_ZN4testE").to_string(), "test"); +/// assert_eq!(demangle("_ZN3foo3barE").to_string(), "foo::bar"); +/// assert_eq!(demangle("foo").to_string(), "foo"); +/// ``` +pub fn demangle(mut s: &str) -> Demangle { + // During ThinLTO LLVM may import and rename internal symbols, so strip out + // those endings first as they're one of the last manglings applied to symbol + // names. + let llvm = ".llvm."; + if let Some(i) = s.find(llvm) { + let candidate = &s[i + llvm.len()..]; + let all_hex = candidate.chars().all(|c| { + match c { + 'A' ... 'F' | '0' ... '9' | '@' => true, + _ => false, + } + }); + + if all_hex { + s = &s[..i]; + } + } + + let mut suffix = ""; + let mut style = match legacy::demangle(s) { + Ok((d, s)) => { + suffix = s; + Some(DemangleStyle::Legacy(d)) + } + Err(()) => match v0::demangle(s) { + Ok((d, s)) => { + suffix = s; + Some(DemangleStyle::V0(d)) + } + Err(v0::Invalid) => None, + }, + }; + + // Output like LLVM IR adds extra period-delimited words. See if + // we are in that case and save the trailing words if so. + if !suffix.is_empty() { + if suffix.starts_with(".") && is_symbol_like(suffix) { + // Keep the suffix. + } else { + // Reset the suffix and invalidate the demangling. + suffix = ""; + style = None; + } + } + + Demangle { + style: style, + original: s, + suffix: suffix, + } +} + +/// Error returned from the `try_demangle` function below when demangling fails. +#[derive(Debug, Clone)] +pub struct TryDemangleError { + _priv: (), +} + +/// The same as `demangle`, except return an `Err` if the string does not appear +/// to be a Rust symbol, rather than "demangling" the given string as a no-op. +/// +/// ``` +/// extern crate rustc_demangle; +/// +/// let not_a_rust_symbol = "la la la"; +/// +/// // The `try_demangle` function will reject strings which are not Rust symbols. +/// assert!(rustc_demangle::try_demangle(not_a_rust_symbol).is_err()); +/// +/// // While `demangle` will just pass the non-symbol through as a no-op. +/// assert_eq!(rustc_demangle::demangle(not_a_rust_symbol).as_str(), not_a_rust_symbol); +/// ``` +pub fn try_demangle(s: &str) -> Result<Demangle, TryDemangleError> { + let sym = demangle(s); + if sym.style.is_some() { + Ok(sym) + } else { + Err(TryDemangleError { _priv: () }) + } +} + +impl<'a> Demangle<'a> { + /// Returns the underlying string that's being demangled. + pub fn as_str(&self) -> &'a str { + self.original + } +} + +fn is_symbol_like(s: &str) -> bool { + s.chars().all(|c| { + // Once `char::is_ascii_punctuation` and `char::is_ascii_alphanumeric` + // have been stable for long enough, use those instead for clarity + is_ascii_alphanumeric(c) || is_ascii_punctuation(c) + }) +} + +// Copied from the documentation of `char::is_ascii_alphanumeric` +fn is_ascii_alphanumeric(c: char) -> bool { + match c { + '\u{0041}' ... '\u{005A}' | + '\u{0061}' ... '\u{007A}' | + '\u{0030}' ... '\u{0039}' => true, + _ => false, + } +} + +// Copied from the documentation of `char::is_ascii_punctuation` +fn is_ascii_punctuation(c: char) -> bool { + match c { + '\u{0021}' ... '\u{002F}' | + '\u{003A}' ... '\u{0040}' | + '\u{005B}' ... '\u{0060}' | + '\u{007B}' ... '\u{007E}' => true, + _ => false, + } +} + +impl<'a> fmt::Display for Demangle<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.style { + None => try!(f.write_str(self.original)), + Some(DemangleStyle::Legacy(ref d)) => { + try!(fmt::Display::fmt(d, f)) + } + Some(DemangleStyle::V0(ref d)) => { + try!(fmt::Display::fmt(d, f)) + } + } + f.write_str(self.suffix) + } +} + +impl<'a> fmt::Debug for Demangle<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +#[cfg(test)] +mod tests { + use std::prelude::v1::*; + + macro_rules! t { + ($a:expr, $b:expr) => (assert!(ok($a, $b))) + } + + macro_rules! t_err { + ($a:expr) => (assert!(ok_err($a))) + } + + macro_rules! t_nohash { + ($a:expr, $b:expr) => ({ + assert_eq!(format!("{:#}", super::demangle($a)), $b); + }) + } + + fn ok(sym: &str, expected: &str) -> bool { + match super::try_demangle(sym) { + Ok(s) => { + if s.to_string() == expected { + true + } else { + println!("\n{}\n!=\n{}\n", s, expected); + false + } + } + Err(_) => { + println!("error demangling"); + false + } + } + } + + fn ok_err(sym: &str) -> bool { + match super::try_demangle(sym) { + Ok(_) => { + println!("succeeded in demangling"); + false + } + Err(_) => super::demangle(sym).to_string() == sym, + } + } + + #[test] + fn demangle() { + t_err!("test"); + t!("_ZN4testE", "test"); + t_err!("_ZN4test"); + t!("_ZN4test1a2bcE", "test::a::bc"); + } + + #[test] + fn demangle_dollars() { + t!("_ZN4$RP$E", ")"); + t!("_ZN8$RF$testE", "&test"); + t!("_ZN8$BP$test4foobE", "*test::foob"); + t!("_ZN9$u20$test4foobE", " test::foob"); + t!("_ZN35Bar$LT$$u5b$u32$u3b$$u20$4$u5d$$GT$E", "Bar<[u32; 4]>"); + } + + #[test] + fn demangle_many_dollars() { + t!("_ZN13test$u20$test4foobE", "test test::foob"); + t!("_ZN12test$BP$test4foobE", "test*test::foob"); + } + + + #[test] + fn demangle_osx() { + t!("__ZN5alloc9allocator6Layout9for_value17h02a996811f781011E", "alloc::allocator::Layout::for_value::h02a996811f781011"); + t!("__ZN38_$LT$core..option..Option$LT$T$GT$$GT$6unwrap18_MSG_FILE_LINE_COL17haf7cb8d5824ee659E", "<core::option::Option<T>>::unwrap::_MSG_FILE_LINE_COL::haf7cb8d5824ee659"); + t!("__ZN4core5slice89_$LT$impl$u20$core..iter..traits..IntoIterator$u20$for$u20$$RF$$u27$a$u20$$u5b$T$u5d$$GT$9into_iter17h450e234d27262170E", "core::slice::<impl core::iter::traits::IntoIterator for &'a [T]>::into_iter::h450e234d27262170"); + } + + #[test] + fn demangle_windows() { + t!("ZN4testE", "test"); + t!("ZN13test$u20$test4foobE", "test test::foob"); + t!("ZN12test$RF$test4foobE", "test&test::foob"); + } + + #[test] + fn demangle_elements_beginning_with_underscore() { + t!("_ZN13_$LT$test$GT$E", "<test>"); + t!("_ZN28_$u7b$$u7b$closure$u7d$$u7d$E", "{{closure}}"); + t!("_ZN15__STATIC_FMTSTRE", "__STATIC_FMTSTR"); + } + + #[test] + fn demangle_trait_impls() { + t!("_ZN71_$LT$Test$u20$$u2b$$u20$$u27$static$u20$as$u20$foo..Bar$LT$Test$GT$$GT$3barE", + "<Test + 'static as foo::Bar<Test>>::bar"); + } + + #[test] + fn demangle_without_hash() { + let s = "_ZN3foo17h05af221e174051e9E"; + t!(s, "foo::h05af221e174051e9"); + t_nohash!(s, "foo"); + } + + #[test] + fn demangle_without_hash_edgecases() { + // One element, no hash. + t_nohash!("_ZN3fooE", "foo"); + // Two elements, no hash. + t_nohash!("_ZN3foo3barE", "foo::bar"); + // Longer-than-normal hash. + t_nohash!("_ZN3foo20h05af221e174051e9abcE", "foo"); + // Shorter-than-normal hash. + t_nohash!("_ZN3foo5h05afE", "foo"); + // Valid hash, but not at the end. + t_nohash!("_ZN17h05af221e174051e93fooE", "h05af221e174051e9::foo"); + // Not a valid hash, missing the 'h'. + t_nohash!("_ZN3foo16ffaf221e174051e9E", "foo::ffaf221e174051e9"); + // Not a valid hash, has a non-hex-digit. + t_nohash!("_ZN3foo17hg5af221e174051e9E", "foo::hg5af221e174051e9"); + } + + #[test] + fn demangle_thinlto() { + // One element, no hash. + t!("_ZN3fooE.llvm.9D1C9369", "foo"); + t!("_ZN3fooE.llvm.9D1C9369@@16", "foo"); + t_nohash!("_ZN9backtrace3foo17hbb467fcdaea5d79bE.llvm.A5310EB9", "backtrace::foo"); + } + + #[test] + fn demangle_llvm_ir_branch_labels() { + t!("_ZN4core5slice77_$LT$impl$u20$core..ops..index..IndexMut$LT$I$GT$$u20$for$u20$$u5b$T$u5d$$GT$9index_mut17haf9727c2edfbc47bE.exit.i.i", "core::slice::<impl core::ops::index::IndexMut<I> for [T]>::index_mut::haf9727c2edfbc47b.exit.i.i"); + t_nohash!("_ZN4core5slice77_$LT$impl$u20$core..ops..index..IndexMut$LT$I$GT$$u20$for$u20$$u5b$T$u5d$$GT$9index_mut17haf9727c2edfbc47bE.exit.i.i", "core::slice::<impl core::ops::index::IndexMut<I> for [T]>::index_mut.exit.i.i"); + } + + #[test] + fn demangle_ignores_suffix_that_doesnt_look_like_a_symbol() { + t_err!("_ZN3fooE.llvm moocow"); + } + + #[test] + fn dont_panic() { + super::demangle("_ZN2222222222222222222222EE").to_string(); + super::demangle("_ZN5*70527e27.ll34csaғE").to_string(); + super::demangle("_ZN5*70527a54.ll34_$b.1E").to_string(); + super::demangle("\ + _ZN5~saäb4e\n\ + 2734cOsbE\n\ + 5usage20h)3\0\0\0\0\0\0\07e2734cOsbE\ + ").to_string(); + } + + #[test] + fn invalid_no_chop() { + t_err!("_ZNfooE"); + } + + #[test] + fn handle_assoc_types() { + t!("_ZN151_$LT$alloc..boxed..Box$LT$alloc..boxed..FnBox$LT$A$C$$u20$Output$u3d$R$GT$$u20$$u2b$$u20$$u27$a$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$9call_once17h69e8f44b3723e1caE", "<alloc::boxed::Box<alloc::boxed::FnBox<A, Output=R> + 'a> as core::ops::function::FnOnce<A>>::call_once::h69e8f44b3723e1ca"); + } + + #[test] + fn handle_bang() { + t!( + "_ZN88_$LT$core..result..Result$LT$$u21$$C$$u20$E$GT$$u20$as$u20$std..process..Termination$GT$6report17hfc41d0da4a40b3e8E", + "<core::result::Result<!, E> as std::process::Termination>::report::hfc41d0da4a40b3e8" + ); + } +} diff --git a/third_party/cargo/vendor/rustc-demangle-0.1.16/src/v0.rs b/third_party/cargo/vendor/rustc-demangle-0.1.16/src/v0.rs new file mode 100644 index 0000000..7a6c6a2 --- /dev/null +++ b/third_party/cargo/vendor/rustc-demangle-0.1.16/src/v0.rs @@ -0,0 +1,1084 @@ +use core::char; +use core::fmt; +use core::fmt::Display; + +/// Representation of a demangled symbol name. +pub struct Demangle<'a> { + inner: &'a str, +} + +/// De-mangles a Rust symbol into a more readable version +/// +/// This function will take a **mangled** symbol and return a value. When printed, +/// the de-mangled version will be written. If the symbol does not look like +/// a mangled symbol, the original value will be written instead. +pub fn demangle(s: &str) -> Result<(Demangle, &str), Invalid> { + // First validate the symbol. If it doesn't look like anything we're + // expecting, we just print it literally. Note that we must handle non-Rust + // symbols because we could have any function in the backtrace. + let inner; + if s.len() > 2 && s.starts_with("_R") { + inner = &s[2..]; + } else if s.len() > 1 && s.starts_with("R") { + // On Windows, dbghelp strips leading underscores, so we accept "R..." + // form too. + inner = &s[1..]; + } else if s.len() > 3 && s.starts_with("__R") { + // On OSX, symbols are prefixed with an extra _ + inner = &s[3..]; + } else { + return Err(Invalid); + } + + // Paths always start with uppercase characters. + match inner.as_bytes()[0] { + b'A'...b'Z' => {} + _ => return Err(Invalid), + } + + // only work with ascii text + if inner.bytes().any(|c| c & 0x80 != 0) { + return Err(Invalid); + } + + // Verify that the symbol is indeed a valid path. + let mut parser = Parser { + sym: inner, + next: 0, + }; + try!(parser.skip_path()); + + // Instantiating crate (paths always start with uppercase characters). + match parser.sym.as_bytes().get(parser.next) { + Some(&b'A'...b'Z') => { + try!(parser.skip_path()); + } + _ => {} + } + + Ok((Demangle { + inner: inner, + }, &parser.sym[parser.next..])) +} + +impl<'s> Display for Demangle<'s> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut printer = Printer { + parser: Ok(Parser { + sym: self.inner, + next: 0, + }), + out: f, + bound_lifetime_depth: 0, + }; + printer.print_path(true) + } +} + +#[derive(PartialEq, Eq)] +pub struct Invalid; + +struct Ident<'s> { + /// ASCII part of the identifier. + ascii: &'s str, + /// Punycode insertion codes for Unicode codepoints, if any. + punycode: &'s str, +} + +const SMALL_PUNYCODE_LEN: usize = 128; + +impl<'s> Ident<'s> { + /// Attempt to decode punycode on the stack (allocation-free), + /// and pass the char slice to the closure, if successful. + /// This supports up to `SMALL_PUNYCODE_LEN` characters. + fn try_small_punycode_decode<F: FnOnce(&[char]) -> R, R>( + &self, + f: F, + ) -> Option<R> { + let mut out = ['\0'; SMALL_PUNYCODE_LEN]; + let mut out_len = 0; + let r = self.punycode_decode(|i, c| { + // Check there's space left for another character. + try!(out.get(out_len).ok_or(())); + + // Move the characters after the insert position. + let mut j = out_len; + out_len += 1; + + while j > i { + out[j] = out[j - 1]; + j -= 1; + } + + // Insert the new character. + out[i] = c; + + Ok(()) + }); + if r.is_ok() { + Some(f(&out[..out_len])) + } else { + None + } + } + + /// Decode punycode as insertion positions and characters + /// and pass them to the closure, which can return `Err(())` + /// to stop the decoding process. + fn punycode_decode<F: FnMut(usize, char) -> Result<(), ()>>( + &self, + mut insert: F, + ) -> Result<(), ()> { + let mut punycode_bytes = self.punycode.bytes().peekable(); + if punycode_bytes.peek().is_none() { + return Err(()); + } + + let mut len = 0; + + // Populate initial output from ASCII fragment. + for c in self.ascii.chars() { + try!(insert(len, c)); + len += 1; + } + + // Punycode parameters and initial state. + let base = 36; + let t_min = 1; + let t_max = 26; + let skew = 38; + let mut damp = 700; + let mut bias = 72; + let mut i: usize = 0; + let mut n: usize = 0x80; + + loop { + // Read one delta value. + let mut delta: usize = 0; + let mut w = 1; + let mut k: usize = 0; + loop { + use core::cmp::{min, max}; + + k += base; + let t = min(max(k.saturating_sub(bias), t_min), t_max); + + let d = match punycode_bytes.next() { + Some(d @ b'a'...b'z') => d - b'a', + Some(d @ b'0'...b'9') => 26 + (d - b'0'), + _ => return Err(()), + }; + let d = d as usize; + delta = try!(delta.checked_add( + try!(d.checked_mul(w).ok_or(())) + ).ok_or(())); + if d < t { + break; + } + w = try!(w.checked_mul(base - t).ok_or(())); + } + + // Compute the new insert position and character. + len += 1; + i = try!(i.checked_add(delta).ok_or(())); + n = try!(n.checked_add(i / len).ok_or(())); + i %= len; + + let n_u32 = n as u32; + let c = if n_u32 as usize == n { + try!(char::from_u32(n_u32).ok_or(())) + } else { + return Err(()); + }; + + // Insert the new character and increment the insert position. + try!(insert(i, c)); + i += 1; + + // If there are no more deltas, decoding is complete. + if punycode_bytes.peek().is_none() { + return Ok(()); + } + + // Perform bias adaptation. + delta /= damp; + damp = 2; + + delta += delta / len; + let mut k = 0; + while delta > ((base - t_min) * t_max) / 2 { + delta /= base - t_min; + k += base; + } + bias = k + ((base - t_min + 1) * delta) / (delta + skew); + } + } +} + +impl<'s> Display for Ident<'s> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.try_small_punycode_decode(|chars| { + for &c in chars { + try!(c.fmt(f)); + } + Ok(()) + }).unwrap_or_else(|| { + if !self.punycode.is_empty() { + try!(f.write_str("punycode{")); + + // Reconstruct a standard Punycode encoding, + // by using `-` as the separator. + if !self.ascii.is_empty() { + try!(f.write_str(self.ascii)); + try!(f.write_str("-")); + } + try!(f.write_str(self.punycode)); + + f.write_str("}") + } else { + f.write_str(self.ascii) + } + }) + } +} + +fn basic_type(tag: u8) -> Option<&'static str> { + Some(match tag { + b'b' => "bool", + b'c' => "char", + b'e' => "str", + b'u' => "()", + b'a' => "i8", + b's' => "i16", + b'l' => "i32", + b'x' => "i64", + b'n' => "i128", + b'i' => "isize", + b'h' => "u8", + b't' => "u16", + b'm' => "u32", + b'y' => "u64", + b'o' => "u128", + b'j' => "usize", + b'f' => "f32", + b'd' => "f64", + b'z' => "!", + b'p' => "_", + b'v' => "...", + + _ => return None, + }) +} + +struct Parser<'s> { + sym: &'s str, + next: usize, +} + +impl<'s> Parser<'s> { + fn peek(&self) -> Option<u8> { + self.sym.as_bytes().get(self.next).cloned() + } + + fn eat(&mut self, b: u8) -> bool { + if self.peek() == Some(b) { + self.next += 1; + true + } else { + false + } + } + + fn next(&mut self) -> Result<u8, Invalid> { + let b = try!(self.peek().ok_or(Invalid)); + self.next += 1; + Ok(b) + } + + fn hex_nibbles(&mut self) -> Result<&'s str, Invalid> { + let start = self.next; + loop { + match try!(self.next()) { + b'0'...b'9' | b'a'...b'f' => {} + b'_' => break, + _ => return Err(Invalid), + } + } + Ok(&self.sym[start..self.next - 1]) + } + + fn digit_10(&mut self) -> Result<u8, Invalid> { + let d = match self.peek() { + Some(d @ b'0'...b'9') => d - b'0', + _ => return Err(Invalid), + }; + self.next += 1; + Ok(d) + } + + fn digit_62(&mut self) -> Result<u8, Invalid> { + let d = match self.peek() { + Some(d @ b'0'...b'9') => d - b'0', + Some(d @ b'a'...b'z') => 10 + (d - b'a'), + Some(d @ b'A'...b'Z') => 10 + 26 + (d - b'A'), + _ => return Err(Invalid), + }; + self.next += 1; + Ok(d) + } + + fn integer_62(&mut self) -> Result<u64, Invalid> { + if self.eat(b'_') { + return Ok(0); + } + + let mut x: u64 = 0; + while !self.eat(b'_') { + let d = try!(self.digit_62()) as u64; + x = try!(x.checked_mul(62).ok_or(Invalid)); + x = try!(x.checked_add(d).ok_or(Invalid)); + } + x.checked_add(1).ok_or(Invalid) + } + + fn opt_integer_62(&mut self, tag: u8) -> Result<u64, Invalid> { + if !self.eat(tag) { + return Ok(0); + } + try!(self.integer_62()).checked_add(1).ok_or(Invalid) + } + + fn disambiguator(&mut self) -> Result<u64, Invalid> { + self.opt_integer_62(b's') + } + + fn namespace(&mut self) -> Result<Option<char>, Invalid> { + match try!(self.next()) { + // Special namespaces, like closures and shims. + ns @ b'A'...b'Z' => Ok(Some(ns as char)), + + // Implementation-specific/unspecified namespaces. + b'a'...b'z' => Ok(None), + + _ => Err(Invalid), + } + } + + fn backref(&mut self) -> Result<Parser<'s>, Invalid> { + let s_start = self.next - 1; + let i = try!(self.integer_62()); + if i >= s_start as u64 { + return Err(Invalid); + } + Ok(Parser { + sym: self.sym, + next: i as usize, + }) + } + + fn ident(&mut self) -> Result<Ident<'s>, Invalid> { + let is_punycode = self.eat(b'u'); + let mut len = try!(self.digit_10()) as usize; + if len != 0 { + loop { + match self.digit_10() { + Ok(d) => { + len = try!(len.checked_mul(10).ok_or(Invalid)); + len = try!(len.checked_add(d as usize).ok_or(Invalid)); + } + Err(Invalid) => break, + } + } + } + + // Skip past the optional `_` separator. + self.eat(b'_'); + + let start = self.next; + self.next = try!(self.next.checked_add(len).ok_or(Invalid)); + if self.next > self.sym.len() { + return Err(Invalid); + } + + let ident = &self.sym[start..self.next]; + + if is_punycode { + let ident = match ident.bytes().rposition(|b| b == b'_') { + Some(i) => Ident { + ascii: &ident[..i], + punycode: &ident[i + 1..], + }, + None => Ident { + ascii: "", + punycode: ident, + }, + }; + if ident.punycode.is_empty() { + return Err(Invalid); + } + Ok(ident) + } else { + Ok(Ident { + ascii: ident, + punycode: "", + }) + } + } + + fn skip_path(&mut self) -> Result<(), Invalid> { + match try!(self.next()) { + b'C' => { + try!(self.disambiguator()); + try!(self.ident()); + } + b'N' => { + try!(self.namespace()); + try!(self.skip_path()); + try!(self.disambiguator()); + try!(self.ident()); + } + b'M' => { + try!(self.disambiguator()); + try!(self.skip_path()); + try!(self.skip_type()); + } + b'X' => { + try!(self.disambiguator()); + try!(self.skip_path()); + try!(self.skip_type()); + try!(self.skip_path()); + } + b'Y' => { + try!(self.skip_type()); + try!(self.skip_path()); + } + b'I' => { + try!(self.skip_path()); + while !self.eat(b'E') { + try!(self.skip_generic_arg()); + } + } + b'B' => { + try!(self.backref()); + } + _ => return Err(Invalid), + } + Ok(()) + } + + fn skip_generic_arg(&mut self) -> Result<(), Invalid> { + if self.eat(b'L') { + try!(self.integer_62()); + Ok(()) + } else if self.eat(b'K') { + self.skip_const() + } else { + self.skip_type() + } + } + + fn skip_type(&mut self) -> Result<(), Invalid> { + match try!(self.next()) { + tag if basic_type(tag).is_some() => {} + + b'R' | b'Q' => { + if self.eat(b'L') { + try!(self.integer_62()); + } + try!(self.skip_type()); + } + b'P' | b'O' | b'S' => try!(self.skip_type()), + b'A' => { + try!(self.skip_type()); + try!(self.skip_const()); + } + b'T' => while !self.eat(b'E') { + try!(self.skip_type()); + }, + b'F' => { + let _binder = try!(self.opt_integer_62(b'G')); + let _is_unsafe = self.eat(b'U'); + if self.eat(b'K') { + let c_abi = self.eat(b'C'); + if !c_abi { + let abi = try!(self.ident()); + if abi.ascii.is_empty() || !abi.punycode.is_empty() { + return Err(Invalid); + } + } + } + while !self.eat(b'E') { + try!(self.skip_type()); + } + try!(self.skip_type()); + } + b'D' => { + let _binder = try!(self.opt_integer_62(b'G')); + while !self.eat(b'E') { + try!(self.skip_path()); + while self.eat(b'p') { + try!(self.ident()); + try!(self.skip_type()); + } + } + if !self.eat(b'L') { + return Err(Invalid); + } + try!(self.integer_62()); + } + b'B' => { + try!(self.backref()); + } + _ => { + // Go back to the tag, so `skip_path` also sees it. + self.next -= 1; + try!(self.skip_path()); + } + } + Ok(()) + } + + fn skip_const(&mut self) -> Result<(), Invalid> { + if self.eat(b'B') { + try!(self.backref()); + return Ok(()); + } + + match try!(self.next()) { + // Unsigned integer types. + b'h' | b't' | b'm' | b'y' | b'o' | b'j' => {} + + _ => return Err(Invalid), + } + + if self.eat(b'p') { + return Ok(()); + } + try!(self.hex_nibbles()); + Ok(()) + } +} + +struct Printer<'a, 'b: 'a, 's> { + parser: Result<Parser<'s>, Invalid>, + out: &'a mut fmt::Formatter<'b>, + bound_lifetime_depth: u32, +} + +/// Mark the parser as errored, print `?` and return early. +/// This allows callers to keep printing the approximate +/// syntax of the path/type/const, despite having errors. +/// E.g. `Vec<[(A, ?); ?]>` instead of `Vec<[(A, ?`. +macro_rules! invalid { + ($printer:ident) => {{ + $printer.parser = Err(Invalid); + return $printer.out.write_str("?"); + }} +} + +/// Call a parser method (if the parser hasn't errored yet), +/// and mark the parser as errored if it returns `Err(Invalid)`. +/// +/// If the parser errored, before or now, prints `?`, and +/// returns early the current function (see `invalid!` above). +macro_rules! parse { + ($printer:ident, $method:ident $(($($arg:expr),*))*) => { + match $printer.parser_mut().and_then(|p| p.$method($($($arg),*)*)) { + Ok(x) => x, + Err(Invalid) => invalid!($printer), + } + }; +} + +impl<'a, 'b, 's> Printer<'a, 'b, 's> { + fn parser_mut<'c>(&'c mut self) -> Result<&'c mut Parser<'s>, Invalid> { + self.parser.as_mut().map_err(|_| Invalid) + } + + /// Eat the given character from the parser, + /// returning `false` if the parser errored. + fn eat(&mut self, b: u8) -> bool { + self.parser_mut().map(|p| p.eat(b)) == Ok(true) + } + + /// Return a nested parser for a backref. + fn backref_printer<'c>(&'c mut self) -> Printer<'c, 'b, 's> { + Printer { + parser: self.parser_mut().and_then(|p| p.backref()), + out: self.out, + bound_lifetime_depth: self.bound_lifetime_depth, + } + } + + /// Print the lifetime according to the previously decoded index. + /// An index of `0` always refers to `'_`, but starting with `1`, + /// indices refer to late-bound lifetimes introduced by a binder. + fn print_lifetime_from_index(&mut self, lt: u64) -> fmt::Result { + try!(self.out.write_str("'")); + if lt == 0 { + return self.out.write_str("_"); + } + match (self.bound_lifetime_depth as u64).checked_sub(lt) { + Some(depth) => { + // Try to print lifetimes alphabetically first. + if depth < 26 { + let c = (b'a' + depth as u8) as char; + c.fmt(self.out) + } else { + // Use `'_123` after running out of letters. + try!(self.out.write_str("_")); + depth.fmt(self.out) + } + } + None => invalid!(self), + } + } + + /// Optionally enter a binder ('G') for late-bound lifetimes, + /// printing e.g. `for<'a, 'b> ` before calling the closure, + /// and make those lifetimes visible to it (via depth level). + fn in_binder<F>(&mut self, f: F) -> fmt::Result + where F: FnOnce(&mut Self) -> fmt::Result, + { + let bound_lifetimes = parse!(self, opt_integer_62(b'G')); + + if bound_lifetimes > 0 { + try!(self.out.write_str("for<")); + for i in 0..bound_lifetimes { + if i > 0 { + try!(self.out.write_str(", ")); + } + self.bound_lifetime_depth += 1; + try!(self.print_lifetime_from_index(1)); + } + try!(self.out.write_str("> ")); + } + + let r = f(self); + + // Restore `bound_lifetime_depth` to the previous value. + self.bound_lifetime_depth -= bound_lifetimes as u32; + + r + } + + /// Print list elements using the given closure and separator, + /// until the end of the list ('E') is found, or the parser errors. + /// Returns the number of elements printed. + fn print_sep_list<F>(&mut self, f: F, sep: &str) -> Result<usize, fmt::Error> + where F: Fn(&mut Self) -> fmt::Result, + { + let mut i = 0; + while self.parser.is_ok() && !self.eat(b'E') { + if i > 0 { + try!(self.out.write_str(sep)); + } + try!(f(self)); + i += 1; + } + Ok(i) + } + + fn print_path(&mut self, in_value: bool) -> fmt::Result { + let tag = parse!(self, next); + match tag { + b'C' => { + let dis = parse!(self, disambiguator); + let name = parse!(self, ident); + + try!(name.fmt(self.out)); + if !self.out.alternate() { + try!(self.out.write_str("[")); + try!(fmt::LowerHex::fmt(&dis, self.out)); + try!(self.out.write_str("]")); + } + } + b'N' => { + let ns = parse!(self, namespace); + + try!(self.print_path(in_value)); + + let dis = parse!(self, disambiguator); + let name = parse!(self, ident); + + match ns { + // Special namespaces, like closures and shims. + Some(ns) => { + try!(self.out.write_str("::{")); + match ns { + 'C' => try!(self.out.write_str("closure")), + 'S' => try!(self.out.write_str("shim")), + _ => try!(ns.fmt(self.out)), + } + if !name.ascii.is_empty() || !name.punycode.is_empty() { + try!(self.out.write_str(":")); + try!(name.fmt(self.out)); + } + try!(self.out.write_str("#")); + try!(dis.fmt(self.out)); + try!(self.out.write_str("}")); + } + + // Implementation-specific/unspecified namespaces. + None => { + if !name.ascii.is_empty() || !name.punycode.is_empty() { + try!(self.out.write_str("::")); + try!(name.fmt(self.out)); + } + } + } + } + b'M' | b'X' | b'Y' => { + if tag != b'Y' { + // Ignore the `impl`'s own path. + parse!(self, disambiguator); + parse!(self, skip_path); + } + + try!(self.out.write_str("<")); + try!(self.print_type()); + if tag != b'M' { + try!(self.out.write_str(" as ")); + try!(self.print_path(false)); + } + try!(self.out.write_str(">")); + } + b'I' => { + try!(self.print_path(in_value)); + if in_value { + try!(self.out.write_str("::")); + } + try!(self.out.write_str("<")); + try!(self.print_sep_list(Self::print_generic_arg, ", ")); + try!(self.out.write_str(">")); + } + b'B' => { + try!(self.backref_printer().print_path(in_value)); + } + _ => invalid!(self), + } + Ok(()) + } + + fn print_generic_arg(&mut self) -> fmt::Result { + if self.eat(b'L') { + let lt = parse!(self, integer_62); + self.print_lifetime_from_index(lt) + } else if self.eat(b'K') { + self.print_const() + } else { + self.print_type() + } + } + + fn print_type(&mut self) -> fmt::Result { + let tag = parse!(self, next); + + match basic_type(tag) { + Some(ty) => return self.out.write_str(ty), + None => {} + } + + match tag { + b'R' | b'Q' => { + try!(self.out.write_str("&")); + if self.eat(b'L') { + let lt = parse!(self, integer_62); + if lt != 0 { + try!(self.print_lifetime_from_index(lt)); + try!(self.out.write_str(" ")); + } + } + if tag != b'R' { + try!(self.out.write_str("mut ")); + } + try!(self.print_type()); + } + + b'P' | b'O' => { + try!(self.out.write_str("*")); + if tag != b'P' { + try!(self.out.write_str("mut ")); + } else { + try!(self.out.write_str("const ")); + } + try!(self.print_type()); + } + + b'A' | b'S' => { + try!(self.out.write_str("[")); + try!(self.print_type()); + if tag == b'A' { + try!(self.out.write_str("; ")); + try!(self.print_const()); + } + try!(self.out.write_str("]")); + } + b'T' => { + try!(self.out.write_str("(")); + let count = try!(self.print_sep_list(Self::print_type, ", ")); + if count == 1 { + try!(self.out.write_str(",")); + } + try!(self.out.write_str(")")); + } + b'F' => try!(self.in_binder(|this| { + let is_unsafe = this.eat(b'U'); + let abi = if this.eat(b'K') { + if this.eat(b'C') { + Some("C") + } else { + let abi = parse!(this, ident); + if abi.ascii.is_empty() || !abi.punycode.is_empty() { + invalid!(this); + } + Some(abi.ascii) + } + } else { + None + }; + + if is_unsafe { + try!(this.out.write_str("unsafe ")); + } + + match abi { + Some(abi) => { + try!(this.out.write_str("extern \"")); + + // If the ABI had any `-`, they were replaced with `_`, + // so the parts between `_` have to be re-joined with `-`. + let mut parts = abi.split('_'); + try!(this.out.write_str(parts.next().unwrap())); + for part in parts { + try!(this.out.write_str("-")); + try!(this.out.write_str(part)); + } + + try!(this.out.write_str("\" ")); + } + None => {} + } + + try!(this.out.write_str("fn(")); + try!(this.print_sep_list(Self::print_type, ", ")); + try!(this.out.write_str(")")); + + if this.eat(b'u') { + // Skip printing the return type if it's 'u', i.e. `()`. + } else { + try!(this.out.write_str(" -> ")); + try!(this.print_type()); + } + + Ok(()) + })), + b'D' => { + try!(self.out.write_str("dyn ")); + try!(self.in_binder(|this| { + try!(this.print_sep_list(Self::print_dyn_trait, " + ")); + Ok(()) + })); + + if !self.eat(b'L') { + invalid!(self); + } + let lt = parse!(self, integer_62); + if lt != 0 { + try!(self.out.write_str(" + ")); + try!(self.print_lifetime_from_index(lt)); + } + } + b'B' => { + try!(self.backref_printer().print_type()); + } + _ => { + // Go back to the tag, so `print_path` also sees it. + let _ = self.parser_mut().map(|p| p.next -= 1); + try!(self.print_path(false)); + } + } + Ok(()) + } + + /// A trait in a trait object may have some "existential projections" + /// (i.e. associated type bindings) after it, which should be printed + /// in the `<...>` of the trait, e.g. `dyn Trait<T, U, Assoc=X>`. + /// To this end, this method will keep the `<...>` of an 'I' path + /// open, by omitting the `>`, and return `Ok(true)` in that case. + fn print_path_maybe_open_generics(&mut self) -> Result<bool, fmt::Error> { + if self.eat(b'B') { + self.backref_printer().print_path_maybe_open_generics() + } else if self.eat(b'I') { + try!(self.print_path(false)); + try!(self.out.write_str("<")); + try!(self.print_sep_list(Self::print_generic_arg, ", ")); + Ok(true) + } else { + try!(self.print_path(false)); + Ok(false) + } + } + + fn print_dyn_trait(&mut self) -> fmt::Result { + let mut open = try!(self.print_path_maybe_open_generics()); + + while self.eat(b'p') { + if !open { + try!(self.out.write_str("<")); + open = true; + } else { + try!(self.out.write_str(", ")); + } + + let name = parse!(self, ident); + try!(name.fmt(self.out)); + try!(self.out.write_str(" = ")); + try!(self.print_type()); + } + + if open { + try!(self.out.write_str(">")); + } + + Ok(()) + } + + fn print_const(&mut self) -> fmt::Result { + if self.eat(b'B') { + return self.backref_printer().print_const(); + } + + let ty_tag = parse!(self, next); + let ty = match ty_tag { + // Unsigned integer types. + b'h' | b't' | b'm' | b'y' | b'o' | b'j' => { + basic_type(ty_tag).unwrap() + } + + _ => invalid!(self), + }; + + + if self.eat(b'p') { + try!(self.out.write_str("_")); + } else { + try!(self.print_const_uint()); + } + + if !self.out.alternate() { + try!(self.out.write_str(": ")); + try!(self.out.write_str(ty)); + } + + Ok(()) + } + + fn print_const_uint(&mut self) -> fmt::Result { + let hex = parse!(self, hex_nibbles); + + // Print anything that doesn't fit in `u64` verbatim. + if hex.len() > 16 { + try!(self.out.write_str("0x")); + return self.out.write_str(hex); + } + + let mut v = 0; + for c in hex.chars() { + v = (v << 4) | (c.to_digit(16).unwrap() as u64); + } + v.fmt(self.out) + } +} + +#[cfg(test)] +mod tests { + macro_rules! t_nohash { + ($a:expr, $b:expr) => ({ + assert_eq!(format!("{:#}", ::demangle($a)), $b); + }) + } + macro_rules! t_nohash_type { + ($a:expr, $b:expr) => ( + t_nohash!(concat!("_RMC0", $a), concat!("<", $b, ">")) + ) + } + + #[test] + fn demangle_crate_with_leading_digit() { + t_nohash!( + "_RNvC6_123foo3bar", + "123foo::bar" + ); + } + + #[test] + fn demangle_utf8_idents() { + t_nohash!( + "_RNqCs4fqI2P2rA04_11utf8_identsu30____7hkackfecea1cbdathfdh9hlq6y", + "utf8_idents::საჭმელად_გემრიელი_სადილი" + ); + } + + #[test] + fn demangle_closure() { + t_nohash!( + "_RNCNCNgCs6DXkGYLi8lr_2cc5spawn00B5_", + "cc::spawn::{closure#0}::{closure#0}" + ); + t_nohash!( + "_RNCINkXs25_NgCsbmNqQUJIY6D_4core5sliceINyB9_4IterhENuNgNoBb_4iter8iterator8Iterator9rpositionNCNgNpB9_6memchr7memrchrs_0E0Bb_", + "<core::slice::Iter<u8> as core::iter::iterator::Iterator>::rposition::<core::slice::memchr::memrchr::{closure#1}>::{closure#0}" + ); + } + + #[test] + fn demangle_dyn_trait() { + t_nohash!( + "_RINbNbCskIICzLVDPPb_5alloc5alloc8box_freeDINbNiB4_5boxed5FnBoxuEp6OutputuEL_ECs1iopQbuBiw2_3std", + "alloc::alloc::box_free::<dyn alloc::boxed::FnBox<(), Output = ()>>" + ); + } + + #[test] + fn demangle_const_generics() { + // NOTE(eddyb) this was hand-written, before rustc had working + // const generics support (but the mangling format did include them). + t_nohash_type!( + "INtC8arrayvec8ArrayVechKj7b_E", + "arrayvec::ArrayVec<u8, 123>" + ); + } + + #[test] + fn demangle_exponential_explosion() { + // NOTE(eddyb) because of the prefix added by `t_nohash_type!` is + // 3 bytes long, `B2_` refers to the start of the type, not `B_`. + // 6 backrefs (`B8_E` through `B3_E`) result in 2^6 = 64 copies of `_`. + // Also, because the `p` (`_`) type is after all of the starts of the + // backrefs, it can be replaced with any other type, independently. + t_nohash_type!( + concat!("TTTTTT", "p", "B8_E", "B7_E", "B6_E", "B5_E", "B4_E", "B3_E"), + "((((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _)))), \ + ((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _))))), \ + (((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _)))), \ + ((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _))))))" + ); + } + + #[test] + fn demangle_thinlto() { + t_nohash!("_RC3foo.llvm.9D1C9369", "foo"); + t_nohash!("_RC3foo.llvm.9D1C9369@@16", "foo"); + t_nohash!("_RNvC9backtrace3foo.llvm.A5310EB9", "backtrace::foo"); + } + + #[test] + fn demangle_extra_suffix() { + // From alexcrichton/rustc-demangle#27: + t_nohash!( + "_RNvNtNtNtNtCs92dm3009vxr_4rand4rngs7adapter9reseeding4fork23FORK_HANDLER_REGISTERED.0.0", + "rand::rngs::adapter::reseeding::fork::FORK_HANDLER_REGISTERED.0.0" + ); + } +} diff --git a/third_party/cargo/vendor/rustc_version-0.2.3/.cargo-checksum.json b/third_party/cargo/vendor/rustc_version-0.2.3/.cargo-checksum.json new file mode 100644 index 0000000..f86fe1c --- /dev/null +++ b/third_party/cargo/vendor/rustc_version-0.2.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"80b9fb136c8c2945b4875b05b0f5a4b11e4722997e751f17d8d3f241d7c684db","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","README.md":"58bd14a1dfa1d828e6e99f35c3b7c2149d08e2d990d6ca93f92ab8ffb43275b7","src/errors.rs":"b28c2eeb1278fc3e8d68a64b177034faed67f6762335729d3a6d1e61be8fb034","src/lib.rs":"92a32673f77961724bc52b872781f06d22d166f06838c9582c5adae3c5214f51"},"package":"138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rustc_version-0.2.3/BUILD b/third_party/cargo/vendor/rustc_version-0.2.3/BUILD new file mode 100644 index 0000000..658bd75 --- /dev/null +++ b/third_party/cargo/vendor/rustc_version-0.2.3/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "rustc_version", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/semver-0.9.0:semver", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.2.3", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/rustc_version-0.2.3/Cargo.toml b/third_party/cargo/vendor/rustc_version-0.2.3/Cargo.toml new file mode 100644 index 0000000..3b252b8 --- /dev/null +++ b/third_party/cargo/vendor/rustc_version-0.2.3/Cargo.toml @@ -0,0 +1,26 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "rustc_version" +version = "0.2.3" +authors = ["Marvin Löbel <loebel.marvin@gmail.com>"] +description = "A library for querying the version of a installed rustc compiler" +documentation = "https://docs.rs/rustc_version/" +readme = "README.md" +keywords = ["version", "rustc"] +license = "MIT/Apache-2.0" +repository = "https://github.com/Kimundi/rustc-version-rs" +[dependencies.semver] +version = "0.9" +[badges.travis-ci] +repository = "Kimundi/rustc-version-rs" diff --git a/third_party/cargo/vendor/rustc_version-0.2.3/LICENSE-APACHE b/third_party/cargo/vendor/rustc_version-0.2.3/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/rustc_version-0.2.3/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/rustc_version-0.2.3/LICENSE-MIT b/third_party/cargo/vendor/rustc_version-0.2.3/LICENSE-MIT new file mode 100644 index 0000000..40b8817 --- /dev/null +++ b/third_party/cargo/vendor/rustc_version-0.2.3/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/rustc_version-0.2.3/README.md b/third_party/cargo/vendor/rustc_version-0.2.3/README.md new file mode 100644 index 0000000..f491ca9 --- /dev/null +++ b/third_party/cargo/vendor/rustc_version-0.2.3/README.md @@ -0,0 +1,75 @@ +rustc-version-rs +============== + +A library for querying the version of a `rustc` compiler. + +This can be used by build scripts or other tools dealing with Rust sources +to make decisions based on the version of the compiler. + +[![Travis-CI Status](https://travis-ci.org/Kimundi/rustc-version-rs.png?branch=master)](https://travis-ci.org/Kimundi/rustc-version-rs) + +# Getting Started + +[rustc-version-rs is available on crates.io](https://crates.io/crates/rustc_version). +It is recommended to look there for the newest released version, as well as links to the newest builds of the docs. + +At the point of the last update of this README, the latest published version could be used like this: + +Add the following dependency to your Cargo manifest... + +```toml +[build-dependencies] +rustc_version = "0.2" +``` + +...and see the [docs](http://kimundi.github.io/rustc-version-rs/rustc_version/index.html) for how to use it. + +# Example + +```rust +// This could be a cargo build script + +extern crate rustc_version; +use rustc_version::{version, version_meta, Channel, Version}; + +fn main() { + // Assert we haven't travelled back in time + assert!(version().unwrap().major >= 1); + + // Set cfg flags depending on release channel + match version_meta().unwrap().channel { + Channel::Stable => { + println!("cargo:rustc-cfg=RUSTC_IS_STABLE"); + } + Channel::Beta => { + println!("cargo:rustc-cfg=RUSTC_IS_BETA"); + } + Channel::Nightly => { + println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY"); + } + Channel::Dev => { + println!("cargo:rustc-cfg=RUSTC_IS_DEV"); + } + } + + // Check for a minimum version + if version().unwrap() >= Version::parse("1.4.0").unwrap() { + println!("cargo:rustc-cfg=compiler_has_important_bugfix"); + } +} +``` + +## License + +Licensed under either of + + * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any +additional terms or conditions. diff --git a/third_party/cargo/vendor/rustc_version-0.2.3/src/errors.rs b/third_party/cargo/vendor/rustc_version-0.2.3/src/errors.rs new file mode 100644 index 0000000..54557b6 --- /dev/null +++ b/third_party/cargo/vendor/rustc_version-0.2.3/src/errors.rs @@ -0,0 +1,79 @@ +use std::{self, error, fmt, io, str}; +use semver::{self, Identifier}; + +/// The error type for this crate. +#[derive(Debug)] +pub enum Error { + /// An error ocurrend when executing the `rustc` command. + CouldNotExecuteCommand(io::Error), + /// The output of `rustc -vV` was not valid utf-8. + Utf8Error(str::Utf8Error), + /// The output of `rustc -vV` was not in the expected format. + UnexpectedVersionFormat, + /// An error ocurred in parsing a `VersionReq`. + ReqParseError(semver::ReqParseError), + /// An error ocurred in parsing the semver. + SemVerError(semver::SemVerError), + /// The pre-release tag is unknown. + UnknownPreReleaseTag(Identifier), +} +use Error::*; + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use std::error::Error; + match *self { + CouldNotExecuteCommand(ref e) => write!(f, "{}: {}", self.description(), e), + Utf8Error(_) => write!(f, "{}", self.description()), + UnexpectedVersionFormat => write!(f, "{}", self.description()), + ReqParseError(ref e) => write!(f, "{}: {}", self.description(), e), + SemVerError(ref e) => write!(f, "{}: {}", self.description(), e), + UnknownPreReleaseTag(ref i) => write!(f, "{}: {}", self.description(), i), + } + } +} + +impl error::Error for Error { + fn cause(&self) -> Option<&error::Error> { + match *self { + CouldNotExecuteCommand(ref e) => Some(e), + Utf8Error(ref e) => Some(e), + UnexpectedVersionFormat => None, + ReqParseError(ref e) => Some(e), + SemVerError(ref e) => Some(e), + UnknownPreReleaseTag(_) => None, + } + } + + fn description(&self) -> &str { + match *self { + CouldNotExecuteCommand(_) => "could not execute command", + Utf8Error(_) => "invalid UTF-8 output from `rustc -vV`", + UnexpectedVersionFormat => "unexpected `rustc -vV` format", + ReqParseError(_) => "error parsing version requirement", + SemVerError(_) => "error parsing version", + UnknownPreReleaseTag(_) => "unknown pre-release tag", + } + } +} + +macro_rules! impl_from { + ($($err_ty:ty => $variant:ident),* $(,)*) => { + $( + impl From<$err_ty> for Error { + fn from(e: $err_ty) -> Error { + Error::$variant(e) + } + } + )* + } +} + +impl_from! { + str::Utf8Error => Utf8Error, + semver::SemVerError => SemVerError, + semver::ReqParseError => ReqParseError, +} + +/// The result type for this crate. +pub type Result<T> = std::result::Result<T, Error>; diff --git a/third_party/cargo/vendor/rustc_version-0.2.3/src/lib.rs b/third_party/cargo/vendor/rustc_version-0.2.3/src/lib.rs new file mode 100644 index 0000000..c038288 --- /dev/null +++ b/third_party/cargo/vendor/rustc_version-0.2.3/src/lib.rs @@ -0,0 +1,347 @@ +// Copyright 2016 rustc-version-rs developers +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![warn(missing_docs)] + +//! Simple library for getting the version information of a `rustc` +//! compiler. +//! +//! This can be used by build scripts or other tools dealing with Rust sources +//! to make decisions based on the version of the compiler. +//! +//! It calls `$RUSTC --version -v` and parses the output, falling +//! back to `rustc` if `$RUSTC` is not set. +//! +//! # Example +//! +//! ```rust +//! // This could be a cargo build script +//! +//! extern crate rustc_version; +//! use rustc_version::{version, version_meta, Channel, Version}; +//! +//! fn main() { +//! // Assert we haven't travelled back in time +//! assert!(version().unwrap().major >= 1); +//! +//! // Set cfg flags depending on release channel +//! match version_meta().unwrap().channel { +//! Channel::Stable => { +//! println!("cargo:rustc-cfg=RUSTC_IS_STABLE"); +//! } +//! Channel::Beta => { +//! println!("cargo:rustc-cfg=RUSTC_IS_BETA"); +//! } +//! Channel::Nightly => { +//! println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY"); +//! } +//! Channel::Dev => { +//! println!("cargo:rustc-cfg=RUSTC_IS_DEV"); +//! } +//! } +//! +//! // Check for a minimum version +//! if version().unwrap() >= Version::parse("1.4.0").unwrap() { +//! println!("cargo:rustc-cfg=compiler_has_important_bugfix"); +//! } +//! } +//! ``` + +extern crate semver; +use semver::Identifier; +use std::process::Command; +use std::{env, str}; +use std::ffi::OsString; + +// Convenience re-export to allow version comparison without needing to add +// semver crate. +pub use semver::Version; + +mod errors; +pub use errors::{Error, Result}; + +/// Release channel of the compiler. +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] +pub enum Channel { + /// Development release channel + Dev, + /// Nightly release channel + Nightly, + /// Beta release channel + Beta, + /// Stable release channel + Stable, +} + +/// Rustc version plus metada like git short hash and build date. +#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] +pub struct VersionMeta { + /// Version of the compiler + pub semver: Version, + + /// Git short hash of the build of the compiler + pub commit_hash: Option<String>, + + /// Commit date of the compiler + pub commit_date: Option<String>, + + /// Build date of the compiler; this was removed between Rust 1.0.0 and 1.1.0. + pub build_date: Option<String>, + + /// Release channel of the compiler + pub channel: Channel, + + /// Host target triple of the compiler + pub host: String, + + /// Short version string of the compiler + pub short_version_string: String, +} + +impl VersionMeta { + /// Returns the version metadata for `cmd`, which should be a `rustc` command. + pub fn for_command(cmd: Command) -> Result<VersionMeta> { + let mut cmd = cmd; + + let out = cmd.arg("-vV").output().map_err(Error::CouldNotExecuteCommand)?; + let out = str::from_utf8(&out.stdout)?; + + version_meta_for(out) + } +} + +/// Returns the `rustc` SemVer version. +pub fn version() -> Result<Version> { + Ok(version_meta()?.semver) +} + +/// Returns the `rustc` SemVer version and additional metadata +/// like the git short hash and build date. +pub fn version_meta() -> Result<VersionMeta> { + let cmd = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); + + VersionMeta::for_command(Command::new(cmd)) +} + +/// Parses a "rustc -vV" output string and returns +/// the SemVer version and additional metadata +/// like the git short hash and build date. +pub fn version_meta_for(verbose_version_string: &str) -> Result<VersionMeta> { + let out: Vec<_> = verbose_version_string.lines().collect(); + + if !(out.len() >= 6 && out.len() <= 8) { + return Err(Error::UnexpectedVersionFormat); + } + + let short_version_string = out[0]; + + fn expect_prefix<'a>(line: &'a str, prefix: &str) -> Result<&'a str> { + if line.starts_with(prefix) { + Ok(&line[prefix.len()..]) + } else { + Err(Error::UnexpectedVersionFormat) + } + } + + let commit_hash = match expect_prefix(out[2], "commit-hash: ")? { + "unknown" => None, + hash => Some(hash.to_owned()), + }; + + let commit_date = match expect_prefix(out[3], "commit-date: ")? { + "unknown" => None, + hash => Some(hash.to_owned()), + }; + + // Handle that the build date may or may not be present. + let mut idx = 4; + let mut build_date = None; + if out[idx].starts_with("build-date") { + build_date = match expect_prefix(out[idx], "build-date: ")? { + "unknown" => None, + s => Some(s.to_owned()), + }; + idx += 1; + } + + let host = expect_prefix(out[idx], "host: ")?; + idx += 1; + let release = expect_prefix(out[idx], "release: ")?; + + let semver: Version = release.parse()?; + + let channel = if semver.pre.is_empty() { + Channel::Stable + } else { + match semver.pre[0] { + Identifier::AlphaNumeric(ref s) if s == "dev" => Channel::Dev, + Identifier::AlphaNumeric(ref s) if s == "beta" => Channel::Beta, + Identifier::AlphaNumeric(ref s) if s == "nightly" => Channel::Nightly, + ref x => return Err(Error::UnknownPreReleaseTag(x.clone())), + } + }; + + Ok(VersionMeta { + semver: semver, + commit_hash: commit_hash, + commit_date: commit_date, + build_date: build_date, + channel: channel, + host: host.into(), + short_version_string: short_version_string.into(), + }) +} + +#[test] +fn smoketest() { + let v = version().unwrap(); + assert!(v.major >= 1); + + let v = version_meta().unwrap(); + assert!(v.semver.major >= 1); + + assert!(version().unwrap() >= Version::parse("1.0.0").unwrap()); +} + +#[test] +fn parse_unexpected() { + let res = version_meta_for( +"rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14) +binary: rustc +commit-hash: a59de37e99060162a2674e3ff45409ac73595c0e +commit-date: 2015-05-13 +rust-birthday: 2015-05-14 +host: x86_64-unknown-linux-gnu +release: 1.0.0"); + + assert!(match res { + Err(Error::UnexpectedVersionFormat) => true, + _ => false, + }); + +} + +#[test] +fn parse_1_0_0() { + let version = version_meta_for( +"rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14) +binary: rustc +commit-hash: a59de37e99060162a2674e3ff45409ac73595c0e +commit-date: 2015-05-13 +build-date: 2015-05-14 +host: x86_64-unknown-linux-gnu +release: 1.0.0").unwrap(); + + assert_eq!(version.semver, Version::parse("1.0.0").unwrap()); + assert_eq!(version.commit_hash, Some("a59de37e99060162a2674e3ff45409ac73595c0e".into())); + assert_eq!(version.commit_date, Some("2015-05-13".into())); + assert_eq!(version.build_date, Some("2015-05-14".into())); + assert_eq!(version.channel, Channel::Stable); + assert_eq!(version.host, "x86_64-unknown-linux-gnu"); + assert_eq!(version.short_version_string, "rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)"); +} + + +#[test] +fn parse_unknown() { + let version = version_meta_for( +"rustc 1.3.0 +binary: rustc +commit-hash: unknown +commit-date: unknown +host: x86_64-unknown-linux-gnu +release: 1.3.0").unwrap(); + + assert_eq!(version.semver, Version::parse("1.3.0").unwrap()); + assert_eq!(version.commit_hash, None); + assert_eq!(version.commit_date, None); + assert_eq!(version.channel, Channel::Stable); + assert_eq!(version.host, "x86_64-unknown-linux-gnu"); + assert_eq!(version.short_version_string, "rustc 1.3.0"); +} + +#[test] +fn parse_nightly() { + let version = version_meta_for( +"rustc 1.5.0-nightly (65d5c0833 2015-09-29) +binary: rustc +commit-hash: 65d5c083377645a115c4ac23a620d3581b9562b6 +commit-date: 2015-09-29 +host: x86_64-unknown-linux-gnu +release: 1.5.0-nightly").unwrap(); + + assert_eq!(version.semver, Version::parse("1.5.0-nightly").unwrap()); + assert_eq!(version.commit_hash, Some("65d5c083377645a115c4ac23a620d3581b9562b6".into())); + assert_eq!(version.commit_date, Some("2015-09-29".into())); + assert_eq!(version.channel, Channel::Nightly); + assert_eq!(version.host, "x86_64-unknown-linux-gnu"); + assert_eq!(version.short_version_string, "rustc 1.5.0-nightly (65d5c0833 2015-09-29)"); +} + +#[test] +fn parse_stable() { + let version = version_meta_for( +"rustc 1.3.0 (9a92aaf19 2015-09-15) +binary: rustc +commit-hash: 9a92aaf19a64603b02b4130fe52958cc12488900 +commit-date: 2015-09-15 +host: x86_64-unknown-linux-gnu +release: 1.3.0").unwrap(); + + assert_eq!(version.semver, Version::parse("1.3.0").unwrap()); + assert_eq!(version.commit_hash, Some("9a92aaf19a64603b02b4130fe52958cc12488900".into())); + assert_eq!(version.commit_date, Some("2015-09-15".into())); + assert_eq!(version.channel, Channel::Stable); + assert_eq!(version.host, "x86_64-unknown-linux-gnu"); + assert_eq!(version.short_version_string, "rustc 1.3.0 (9a92aaf19 2015-09-15)"); +} + +#[test] +fn parse_1_16_0_nightly() { + let version = version_meta_for( +"rustc 1.16.0-nightly (5d994d8b7 2017-01-05) +binary: rustc +commit-hash: 5d994d8b7e482e87467d4a521911477bd8284ce3 +commit-date: 2017-01-05 +host: x86_64-unknown-linux-gnu +release: 1.16.0-nightly +LLVM version: 3.9").unwrap(); + + assert_eq!(version.semver, Version::parse("1.16.0-nightly").unwrap()); + assert_eq!(version.commit_hash, Some("5d994d8b7e482e87467d4a521911477bd8284ce3".into())); + assert_eq!(version.commit_date, Some("2017-01-05".into())); + assert_eq!(version.channel, Channel::Nightly); + assert_eq!(version.host, "x86_64-unknown-linux-gnu"); + assert_eq!(version.short_version_string, "rustc 1.16.0-nightly (5d994d8b7 2017-01-05)"); +} + +/* +#[test] +fn version_matches_replacement() { + let f = |s1: &str, s2: &str| { + let a = Version::parse(s1).unwrap(); + let b = Version::parse(s2).unwrap(); + println!("{} <= {} : {}", s1, s2, a <= b); + }; + + println!(); + + f("1.5.0", "1.5.0"); + f("1.5.0-nightly", "1.5.0"); + f("1.5.0", "1.5.0-nightly"); + f("1.5.0-nightly", "1.5.0-nightly"); + + f("1.5.0", "1.6.0"); + f("1.5.0-nightly", "1.6.0"); + f("1.5.0", "1.6.0-nightly"); + f("1.5.0-nightly", "1.6.0-nightly"); + + panic!(); + +} +*/ diff --git a/third_party/cargo/vendor/rusttype-0.7.9/.cargo-checksum.json b/third_party/cargo/vendor/rusttype-0.7.9/.cargo-checksum.json new file mode 100644 index 0000000..bb77d68 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"516d3e945313c5631195a8fc1eb96d409cb6ae34ba214e199fd8f508b16646d0","Cargo.toml":"bd27bf65e40c2f25ca0eb39c07d860b010194f3981b64e79434dd24ee3425ccd","LICENSE-APACHE":"000b4962e6b27176a0ff89cce4be555b16472cafb5671eb2804a8fdac6854793","LICENSE-MIT":"fd198949ebcc78b2d12fc57ebfb2da4ae8f781b7c3b7047aaccc2f804b6f12ef","README.md":"fee072add28c557715864718d5dbb705f8bb71663873584bf8604228b4b56f22","benches/cache.rs":"5f4acfd3afdb6e9c795787f59369943c1839aba34975089fc959889371a4404c","benches/draw.rs":"7f22cac7f3b22cfbd5a8929cf53789c566c9d6c777ba7a2f6e221aa9f9e9fff7","examples/gpu_cache.rs":"a58809df1a589e6b64806e4a90ff771c116e6c4155a23325dcc1359ffe033a67","examples/image.rs":"95a5e14fa8936450fa3ca2c67e8e529680c10b6b877463dc64cb24c89e67135b","examples/simple.rs":"6edff01831cf9ce8fb8379309ae2882211ba160ea4e029a4ab806c22ed5db6b9","rustfmt.toml":"ed17bf27c3712b8f22ec7a2a9d8e5d9d2a5654299754fb93e9ac76ef6d153114","src/lib.rs":"b42b69f9579b5456236ca827f4c5051fb7e2c935a1ef84029db2cf97413eed78","tests/issues.rs":"5ec278cd8073c4095ad3757254d441f12a403ab745be8a446373209d0a6252a1","tests/lipsum.txt":"0e26c67bc34ba4c083a384468c0c3698800147f05afd13007cd44c5e4d799477","tests/reference_big_biohazard.png":"1f9a4fc9c6357d5462157c49f023d7be3805332be8b8dc85752b0ac0fa485e6a","tests/reference_iota.png":"83824e69dd00c9547a64a2f86a200fe58610bf02c2191044fa22942c56837d57","tests/reference_w.png":"6938997b5d4e798d90ea9ab7dc352c3807a17f974f6cf577963c827a5fc59a28","tests/render_reference.rs":"5ebe9c04e46a7b438d94446dae33e2e8abcac943a0018558d4f9c20b81436699"},"package":"310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rusttype-0.7.9/BUILD b/third_party/cargo/vendor/rusttype-0.7.9/BUILD new file mode 100644 index 0000000..4db5478 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/BUILD @@ -0,0 +1,50 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "cache" with type "bench" omitted +# Unsupported target "draw" with type "bench" omitted +# Unsupported target "gpu_cache" with type "example" omitted +# Unsupported target "image" with type "example" omitted +# Unsupported target "issues" with type "test" omitted +# Unsupported target "render_reference" with type "test" omitted + +rust_library( + name = "rusttype", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/rusttype-0.8.2:rusttype", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.7.9", + crate_features = [ + ], +) + +# Unsupported target "simple" with type "example" omitted diff --git a/third_party/cargo/vendor/rusttype-0.7.9/CHANGELOG.md b/third_party/cargo/vendor/rusttype-0.7.9/CHANGELOG.md new file mode 100644 index 0000000..49d857e --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/CHANGELOG.md @@ -0,0 +1,151 @@ +## 0.7.9 +* Use semver trick to re-expect rusttype `0.8` with default-features on. + +## 0.7.7 +* gpu_cache: Add `CacheBuilder::align_4x4` method which forces texture updates to align to 4x4 pixel boxes. +* gpu_cache: Disable multithread code and remove dependencies on wasm32. + +## 0.7.6 +* `GlyphIter` and `LayoutIter` provide the lifetime of the font data. + +## 0.7.5 +* gpu_cache: `Cache::cache_queued` now returns `CachedBy` for successes which can allow callers to tell that the texture cache has been re-ordered. + +## 0.7.4 +* Add fn `PositionedGlyph::set_position` +* gpu_cache: Update crossbeam-deque -> `0.7`, use `Injector` for minor rasterization performance boost. + +## 0.7.3 +* gpu_cache: Update crossbeam-utils -> `0.6` + +## 0.7.2 +* Update ordered-float -> `1` + +## 0.7.1 +* Fix `PositionedGlyph::pixel_bounding_box()` size inconsistencies at different positions with identical sub-pixel positions. + +## 0.7 + +* Rework `CacheBuilder` to use methods to allow non-breaking additions + in future. New style is `Cache::builder().dimensions(512, 512).build()`. +* Support multithreaded rasterization in the gpu_cache. This yields + significant improvements in worst case performance when more than 1 + CPU core is available. _Thrashing, resizing & population benchmarks + are ~3x faster on a 4-core Haswell._ + Multithreading is enabled by default in environments with more than + a single core, but can be explicitly disabled using + `Cache::builder().multithread(false)`. +* Remove all deprecated API. +* Add `Debug` implementations for `Font`, `Glyph`, `ScaledGlyph` & + `PositionedGlyph` +* Add and improve documentation + examples. + +## 0.6.5 + +* Re-export rusttype `0.7` non-breaking main API, while keeping the current + version of the gpu_cache module. + +## 0.6.4 + +* Add `CacheBuilder::rebuild` & `Cache::to_builder` methods. +* gpu_cache: Only rasterize & upload after queue has successfully fit in cache + producing a 1.16-1.29x speedup in resizing & thrashing benchmarks. + +## 0.6.3 + +* Documentation clarifications +* Avoid depending on unused dependency default-features + +## 0.6.2 + +* Add `From<&AsRef<[u8]>> for SharedBytes`. +* Optimise `gpu_cache` hashing to improve benchmark performance by ~30%. + +## 0.6.1 + +* Optimise rasterizer removing internal hashing. Improves draw benchmark + performance by 11-91%. + +## 0.6 + +* Rework gpu_cache data structures allowing constant time hash lookup + of matching cached glyph textures. Improve performance by ~60-200%. +* Deprecate `gpu_cache::Cache::new` in favour of `gpu_cache::CacheBuilder`. +* Deprecate `gpu_cache::Cache::set_scale_tolerance` & + `gpu_cache::Cache::set_position_tolerance`. These are now equivalent to + recreating the cache as they invalidate the cache keys. +* gpu_cache `scale_tolerance` & `position_tolerance` now have subtly different + meanings but guarantee their error in all cases, where previously the + worst case was double the set tolerance. + +## 0.5.2 + +* Add gpu cache glyph padding option to fix texture bleeding from other + glyphs when using interpolated texture coordinates near edges. Use + `CacheBuilder` to construct a `Cache` that makes use of padding. +* Inlining performance improvements. + +## 0.5.1 + +* Fix tree removal on row clear (gpu_cache). + +## 0.5 + +* Let functions like `Font::glyph` and `Font::pair_kerning` work with both + characters and glyph ids by having them accept any type that implements the + new `IntoGlyphId` trait. This replaces the `CodepointOrGlyph` enum, which + didn't seem widely used. +* Make `Font::glyph` always return a `Glyph`, not `Option<Glyph>`. Passing a + `char` the font doesn't cover returns a `.notdef` glyph (id 0), as it did + before. Passing an invalid glyph id now panics, like a bad array index: glyph + ids should only be used to index the font they were looked up for. +* Introduce `rusttype::Error`, which implements `std::error::Error`, `Debug` and + `Display`, and can be converted to `std::io::Error`. +* Use `Result<_, rusttype::Error>` to report failures in FontCollection, Font + and associated iterators. +* Add `Font::from_bytes` method similar to `FontCollection::from_bytes` for 1 + font collections. +* Improve gpu_cache performance ~2-6% + +## 0.4.3 + +* Improve gpu_cache performance ~6-17% + +## 0.4.2 + +* Allow users to get font names from `Font`. (#86) + +## 0.4 + +* Add more debugging features +* Add support for unscaled fonts +* Improve performance +* Make gpu_cache optional + +## 0.3 + +* Transfer to redox-os organization, merge a number of pull requests + +## 0.2.1 + +* Made the API more convenient (courtesy of @mitchmindtree, @I1048576). +* Fixes for the examples (@I1048576) +* Removed the dependency on ndarray (@I1048576) + +## 0.2 + +* Initial GPU caching implementation. +* Made font data management more flexible. +* Made the interface for font scales simpler. + +## 0.1.2 + +Fixed issue #8 + +## 0.1.1 + +Fixed issue #7 + +## 0.1 + +Initial release diff --git a/third_party/cargo/vendor/rusttype-0.7.9/Cargo.toml b/third_party/cargo/vendor/rusttype-0.7.9/Cargo.toml new file mode 100644 index 0000000..e4458dc --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/Cargo.toml @@ -0,0 +1,64 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "rusttype" +version = "0.7.9" +authors = ["Dylan Ede <dylanede@googlemail.com>", "Jeremy Soller <jackpot51@gmail.com>", "Alex Butler <alexheretic@gmail.com>"] +exclude = ["/fonts/**"] +description = "A pure Rust alternative to libraries like FreeType.\n\nRustType provides an API for loading, querying and rasterising TrueType fonts.\n\nIt also provides an implementation of a dynamic GPU glyph cache for hardware font rendering.\n" +homepage = "https://gitlab.redox-os.org/redox-os/rusttype" +documentation = "https://docs.rs/rusttype" +readme = "README.md" +keywords = ["font", "truetype", "opentype", "ttf", "otf"] +license = "MIT / Apache-2.0" +repository = "https://gitlab.redox-os.org/redox-os/rusttype" +[package.metadata.docs.rs] +features = ["gpu_cache"] + +[[example]] +name = "gpu_cache" +required-features = ["gpu_cache"] + +[[example]] +name = "image" + +[[example]] +name = "simple" +[dependencies.rusttype_next] +version = "0.8" +package = "rusttype" +[dev-dependencies.arrayvec] +version = "0.4" +default-features = false + +[dev-dependencies.blake2] +version = "0.8" + +[dev-dependencies.glium] +version = "0.25" + +[dev-dependencies.image] +version = "0.21" +features = ["png_codec"] +default-features = false + +[dev-dependencies.lazy_static] +version = "1" + +[dev-dependencies.unicode-normalization] +version = "0.1" + +[features] +bench = ["gpu_cache"] +gpu_cache = ["rusttype_next/gpu_cache"] diff --git a/third_party/cargo/vendor/rusttype-0.7.9/LICENSE-APACHE b/third_party/cargo/vendor/rusttype-0.7.9/LICENSE-APACHE new file mode 100644 index 0000000..6f75635 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/third_party/cargo/vendor/rusttype-0.7.9/LICENSE-MIT b/third_party/cargo/vendor/rusttype-0.7.9/LICENSE-MIT new file mode 100644 index 0000000..93cbd53 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Dylan Ede + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/rusttype-0.7.9/README.md b/third_party/cargo/vendor/rusttype-0.7.9/README.md new file mode 100644 index 0000000..291bd19 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/README.md @@ -0,0 +1,80 @@ +# RustType +[![crates.io](https://img.shields.io/crates/v/rusttype.svg)](https://crates.io/crates/rusttype) +[![docs.rs](https://docs.rs/rusttype/badge.svg)](https://docs.rs/rusttype) + +RustType is a pure Rust alternative to libraries like FreeType. + +The current capabilities of RustType: + +* Reading TrueType formatted fonts and font collections. This includes `*.ttf` + as well as a subset of `*.otf` font files. +* Retrieving glyph shapes and commonly used properties for a font and its glyphs. +* Laying out glyphs horizontally using horizontal and vertical metrics, and + glyph-pair-specific kerning. +* Rasterising glyphs with sub-pixel positioning using an accurate analytical + algorithm (not based on sampling). +* Managing a font cache on the GPU with the `gpu_cache` module. This keeps + recently used glyph renderings + in a dynamic cache in GPU memory to minimise texture uploads per-frame. It + also allows you keep the draw call count for text very low, as all glyphs are + kept in one GPU texture. + +Notable things that RustType does not support *yet*: + +* OpenType formatted fonts that are not just TrueType fonts (OpenType is a + superset of TrueType). Notably there is no support yet for cubic Bezier curves + used in glyphs. +* Font hinting. +* Ligatures of any kind +* Some less common TrueType sub-formats. +* Right-to-left and vertical text layout. + +## Getting Started + +To hit the ground running with RustType, look at the `simple.rs` example +supplied with the crate. It demonstrates loading a font file, rasterising an +arbitrary string, and displaying the result as ASCII art. If you prefer to just +look at the documentation, the entry point for loading fonts is +`FontCollection`, from which you can access individual fonts, then their glyphs. + +## Future Plans + +The initial motivation for the project was to provide easy-to-use font rendering for games. +There are numerous avenues for improving RustType. Ideas: + +* Some form of hinting for improved legibility at small font sizes. +* Replacing the dependency on + [stb_truetype-rs](https://gitlab.redox-os.org/redox-os/stb_truetype-rs) + (a translation of [stb_truetype.h](https://github.com/nothings/stb/blob/master/stb_truetype.h)), + with OpenType font loading written in idiomatic Rust. +* Add support for cubic curves in OpenType fonts. +* Extract the rasterisation code into a separate vector graphics rendering crate. +* Support for some common forms of ligatures. +* And, eventually, support for embedded right-to-left Unicode text. + +If you think you could help with achieving any of these goals, feel free to open +a tracking issue for discussing them. + +## Minimum supported rust compiler +This crate is maintained with [latest stable rust](https://gist.github.com/alexheretic/d1e98d8433b602e57f5d0a9637927e0c). + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. + +### See Also + +- [glyph_brush](https://github.com/alexheretic/glyph-brush) - can cache vertex generation & provides more complex layouts. diff --git a/third_party/cargo/vendor/rusttype-0.7.9/benches/cache.rs b/third_party/cargo/vendor/rusttype-0.7.9/benches/cache.rs new file mode 100644 index 0000000..ffc67f3 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/benches/cache.rs @@ -0,0 +1,410 @@ +#![feature(test)] +#![cfg(feature = "gpu_cache")] + +extern crate test; + +use rusttype::gpu_cache::*; +use rusttype::*; + +/// Busy wait 2us +fn mock_gpu_upload(_region: Rect<u32>, _bytes: &[u8]) { + use std::time::{Duration, Instant}; + + let now = Instant::now(); + while now.elapsed() < Duration::from_micros(2) {} +} + +fn test_glyphs<'a>(font: &Font<'a>, string: &str) -> Vec<PositionedGlyph<'a>> { + let mut glyphs = vec![]; + // Set of scales, found through brute force, to reproduce GlyphNotCached issue + // Cache settings also affect this, it occurs when position_tolerance is < 1.0 + for scale in &[25_f32, 24.5, 25.01, 24.7, 24.99] { + for glyph in layout_paragraph(font, Scale::uniform(*scale), 500, string) { + glyphs.push(glyph); + } + } + glyphs +} + +fn layout_paragraph<'a>( + font: &Font<'a>, + scale: Scale, + width: u32, + text: &str, +) -> Vec<PositionedGlyph<'a>> { + use unicode_normalization::UnicodeNormalization; + let mut result = Vec::new(); + let v_metrics = font.v_metrics(scale); + let advance_height = v_metrics.ascent - v_metrics.descent + v_metrics.line_gap; + let mut caret = point(0.0, v_metrics.ascent); + let mut last_glyph_id = None; + for c in text.nfc() { + if c.is_control() { + if c == '\n' { + caret = point(0.0, caret.y + advance_height) + } + continue; + } + let base_glyph = font.glyph(c); + if let Some(id) = last_glyph_id.take() { + caret.x += font.pair_kerning(scale, id, base_glyph.id()); + } + last_glyph_id = Some(base_glyph.id()); + let mut glyph = base_glyph.scaled(scale).positioned(caret); + if let Some(bb) = glyph.pixel_bounding_box() { + if bb.max.x > width as i32 { + caret = point(0.0, caret.y + advance_height); + glyph.set_position(caret); + last_glyph_id = None; + } + } + caret.x += glyph.unpositioned().h_metrics().advance_width; + result.push(glyph); + } + result +} + +lazy_static::lazy_static! { + static ref FONTS: Vec<Font<'static>> = vec![ + include_bytes!("../fonts/wqy-microhei/WenQuanYiMicroHei.ttf") as &[u8], + include_bytes!("../fonts/dejavu/DejaVuSansMono.ttf") as &[u8], + include_bytes!("../fonts/opensans/OpenSans-Italic.ttf") as &[u8], + ] + .into_iter() + .map(|bytes| Font::from_bytes(bytes).unwrap()) + .collect(); +} + +const TEST_STR: &str = include_str!("../tests/lipsum.txt"); + +/// General use benchmarks. +mod cache { + use super::*; + + /// Benchmark using a single font at "don't care" position tolerance + #[bench] + fn high_position_tolerance(b: &mut ::test::Bencher) { + let font_id = 0; + let glyphs = test_glyphs(&FONTS[font_id], TEST_STR); + let mut cache = Cache::builder() + .dimensions(1024, 1024) + .scale_tolerance(0.1) + .position_tolerance(1.0) + .build(); + + b.iter(|| { + for glyph in &glyphs { + cache.queue_glyph(font_id, glyph.clone()); + } + + cache.cache_queued(|_, _| {}).expect("cache_queued"); + + for (index, glyph) in glyphs.iter().enumerate() { + let rect = cache.rect_for(font_id, glyph); + assert!( + rect.is_ok(), + "Gpu cache rect lookup failed ({:?}) for glyph index {}, id {}", + rect, + index, + glyph.id().0 + ); + } + }); + } + + /// Benchmark using a single font with default tolerances + #[bench] + fn single_font(b: &mut ::test::Bencher) { + let font_id = 0; + let glyphs = test_glyphs(&FONTS[font_id], TEST_STR); + let mut cache = Cache::builder().dimensions(1024, 1024).build(); + + b.iter(|| { + for glyph in &glyphs { + cache.queue_glyph(font_id, glyph.clone()); + } + + cache.cache_queued(|_, _| {}).expect("cache_queued"); + + for (index, glyph) in glyphs.iter().enumerate() { + let rect = cache.rect_for(font_id, glyph); + assert!( + rect.is_ok(), + "Gpu cache rect lookup failed ({:?}) for glyph index {}, id {}", + rect, + index, + glyph.id().0 + ); + } + }); + } + + /// Benchmark using multiple fonts with default tolerances + #[bench] + fn multi_font(b: &mut ::test::Bencher) { + // Use a smaller amount of the test string, to offset the extra font-glyph + // bench load + let up_to_index = TEST_STR + .char_indices() + .nth(TEST_STR.chars().count() / FONTS.len()) + .unwrap() + .0; + let string = &TEST_STR[..up_to_index]; + + let font_glyphs: Vec<_> = FONTS + .iter() + .enumerate() + .map(|(id, font)| (id, test_glyphs(font, string))) + .collect(); + let mut cache = Cache::builder().dimensions(1024, 1024).build(); + + b.iter(|| { + for &(font_id, ref glyphs) in &font_glyphs { + for glyph in glyphs { + cache.queue_glyph(font_id, glyph.clone()); + } + } + + cache.cache_queued(|_, _| {}).expect("cache_queued"); + + for &(font_id, ref glyphs) in &font_glyphs { + for (index, glyph) in glyphs.iter().enumerate() { + let rect = cache.rect_for(font_id, glyph); + assert!( + rect.is_ok(), + "Gpu cache rect lookup failed ({:?}) for font {} glyph index {}, id {}", + rect, + font_id, + index, + glyph.id().0 + ); + } + } + }); + } + + /// Benchmark using multiple fonts with default tolerances, clears the + /// cache each run to test the population "first run" performance + #[bench] + fn multi_font_population(b: &mut ::test::Bencher) { + // Use a much smaller amount of the test string, to offset the extra font-glyph + // bench load & much slower performance of fresh population each run + let up_to_index = TEST_STR.char_indices().nth(70).unwrap().0; + let string = &TEST_STR[..up_to_index]; + + let font_glyphs: Vec<_> = FONTS + .iter() + .enumerate() + .map(|(id, font)| (id, test_glyphs(font, string))) + .collect(); + + b.iter(|| { + let mut cache = Cache::builder().dimensions(1024, 1024).build(); + + for &(font_id, ref glyphs) in &font_glyphs { + for glyph in glyphs { + cache.queue_glyph(font_id, glyph.clone()); + } + } + + cache.cache_queued(|_, _| {}).expect("cache_queued"); + + for &(font_id, ref glyphs) in &font_glyphs { + for (index, glyph) in glyphs.iter().enumerate() { + let rect = cache.rect_for(font_id, glyph); + assert!( + rect.is_ok(), + "Gpu cache rect lookup failed ({:?}) for font {} glyph index {}, id {}", + rect, + font_id, + index, + glyph.id().0 + ); + } + } + }); + } + + /// Benchmark using multiple fonts and a different text group of glyphs + /// each run + #[bench] + fn moving_text(b: &mut ::test::Bencher) { + let chars: Vec<_> = TEST_STR.chars().collect(); + let subsection_len = chars.len() / FONTS.len(); + let distinct_subsection: Vec<_> = chars.windows(subsection_len).collect(); + + let mut first_glyphs = vec![]; + let mut middle_glyphs = vec![]; + let mut last_glyphs = vec![]; + + for (id, font) in FONTS.iter().enumerate() { + let first_str: String = distinct_subsection[0].iter().collect(); + first_glyphs.push((id, test_glyphs(font, &first_str))); + + let middle_str: String = distinct_subsection[distinct_subsection.len() / 2] + .iter() + .collect(); + middle_glyphs.push((id, test_glyphs(font, &middle_str))); + + let last_str: String = distinct_subsection[distinct_subsection.len() - 1] + .iter() + .collect(); + last_glyphs.push((id, test_glyphs(font, &last_str))); + } + + let test_variants = [first_glyphs, middle_glyphs, last_glyphs]; + let mut test_variants = test_variants.iter().cycle(); + + let mut cache = Cache::builder() + .dimensions(1500, 1500) + .scale_tolerance(0.1) + .position_tolerance(0.1) + .build(); + + b.iter(|| { + // switch text variant each run to force cache to deal with moving text + // requirements + let glyphs = test_variants.next().unwrap(); + for &(font_id, ref glyphs) in glyphs { + for glyph in glyphs { + cache.queue_glyph(font_id, glyph.clone()); + } + } + + cache.cache_queued(|_, _| {}).expect("cache_queued"); + + for &(font_id, ref glyphs) in glyphs { + for (index, glyph) in glyphs.iter().enumerate() { + let rect = cache.rect_for(font_id, glyph); + assert!( + rect.is_ok(), + "Gpu cache rect lookup failed ({:?}) for font {} glyph index {}, id {}", + rect, + font_id, + index, + glyph.id().0 + ); + } + } + }); + } +} + +/// Benchmarks for cases that should generally be avoided by the cache user if +/// at all possible (ie by picking a better initial cache size). +mod cache_bad_cases { + use super::*; + + /// Cache isn't large enough for a queue so a new cache is created to hold + /// the queue. + #[bench] + fn resizing(b: &mut ::test::Bencher) { + let up_to_index = TEST_STR.char_indices().nth(120).unwrap().0; + let string = &TEST_STR[..up_to_index]; + + let font_glyphs: Vec<_> = FONTS + .iter() + .enumerate() + .map(|(id, font)| (id, test_glyphs(font, string))) + .collect(); + + b.iter(|| { + let mut cache = Cache::builder().dimensions(256, 256).build(); + + for &(font_id, ref glyphs) in &font_glyphs { + for glyph in glyphs { + cache.queue_glyph(font_id, glyph.clone()); + } + } + + cache + .cache_queued(mock_gpu_upload) + .expect_err("shouldn't fit"); + + cache.to_builder().dimensions(512, 512).rebuild(&mut cache); + + cache.cache_queued(mock_gpu_upload).expect("should fit now"); + + for &(font_id, ref glyphs) in &font_glyphs { + for (index, glyph) in glyphs.iter().enumerate() { + let rect = cache.rect_for(font_id, glyph); + assert!( + rect.is_ok(), + "Gpu cache rect lookup failed ({:?}) for font {} glyph index {}, id {}", + rect, + font_id, + index, + glyph.id().0 + ); + } + } + }); + } + + /// Benchmark using multiple fonts and a different text group of glyphs + /// each run. The cache is only large enough to fit each run if it is + /// cleared and re-built. + #[bench] + fn moving_text_thrashing(b: &mut ::test::Bencher) { + let chars: Vec<_> = TEST_STR.chars().collect(); + let subsection_len = 60; + let distinct_subsection: Vec<_> = chars.windows(subsection_len).collect(); + + let mut first_glyphs = vec![]; + let mut middle_glyphs = vec![]; + let mut last_glyphs = vec![]; + + for (id, font) in FONTS.iter().enumerate() { + let first_str: String = distinct_subsection[0].iter().collect(); + first_glyphs.push((id, test_glyphs(font, &first_str))); + + let middle_str: String = distinct_subsection[distinct_subsection.len() / 2] + .iter() + .collect(); + middle_glyphs.push((id, test_glyphs(font, &middle_str))); + + let last_str: String = distinct_subsection[distinct_subsection.len() - 1] + .iter() + .collect(); + last_glyphs.push((id, test_glyphs(font, &last_str))); + } + + let test_variants = [first_glyphs, middle_glyphs, last_glyphs]; + + // Cache is only a little larger than each variants size meaning a lot of + // re-ordering, re-rasterization & re-uploading has to occur. + let mut cache = Cache::builder() + .dimensions(450, 450) + .scale_tolerance(0.1) + .position_tolerance(0.1) + .build(); + + b.iter(|| { + // switch text variant each run to force cache to deal with moving text + // requirements + for glyphs in &test_variants { + for &(font_id, ref glyphs) in glyphs { + for glyph in glyphs { + cache.queue_glyph(font_id, glyph.clone()); + } + } + + cache.cache_queued(mock_gpu_upload).expect("cache_queued"); + + for &(font_id, ref glyphs) in glyphs { + for (index, glyph) in glyphs.iter().enumerate() { + let rect = cache.rect_for(font_id, glyph); + assert!( + rect.is_ok(), + "Gpu cache rect lookup failed ({:?}) for font {} glyph index {}, id {}", + rect, + font_id, + index, + glyph.id().0 + ); + } + } + } + }); + } +} diff --git a/third_party/cargo/vendor/rusttype-0.7.9/benches/draw.rs b/third_party/cargo/vendor/rusttype-0.7.9/benches/draw.rs new file mode 100644 index 0000000..5129358 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/benches/draw.rs @@ -0,0 +1,106 @@ +#![feature(test)] + +extern crate test; + +use blake2::{Blake2s, Digest}; +use rusttype::*; + +lazy_static::lazy_static! { + static ref DEJA_VU_MONO: Font<'static> = + Font::from_bytes(include_bytes!("../fonts/dejavu/DejaVuSansMono.ttf") as &[u8]).unwrap(); + static ref OPEN_SANS_ITALIC: Font<'static> = + Font::from_bytes(include_bytes!("../fonts/opensans/OpenSans-Italic.ttf") as &[u8]).unwrap(); +} + +#[bench] +fn draw_big_biohazard(b: &mut test::Bencher) { + let glyph = DEJA_VU_MONO + .glyph('☣') + .scaled(Scale::uniform(600.0)) + .positioned(point(0.0, 0.0)); + + const WIDTH: usize = 294; + const HEIGHT: usize = 269; + + let bounds = glyph.pixel_bounding_box().unwrap(); + assert_eq!( + (bounds.width() as usize, bounds.height() as usize), + (WIDTH, HEIGHT) + ); + + let mut target = [0u8; WIDTH * HEIGHT]; + b.iter(|| { + glyph.draw(|x, y, alpha| { + let (x, y) = (x as usize, y as usize); + target[WIDTH * y + x] = (alpha * 255.0) as u8; + }) + }); + + // verify the draw result against static reference hash + assert_eq!( + format!("{:x}", Blake2s::digest(&target)), + "8e3927a33c6d563d45f82fb9620dea8036274b403523a2e98cd5f93eafdb2125" + ); +} + +#[bench] +fn draw_w(b: &mut test::Bencher) { + let glyph = DEJA_VU_MONO + .glyph('w') + .scaled(Scale::uniform(16.0)) + .positioned(point(0.0, 0.0)); + + const WIDTH: usize = 9; + const HEIGHT: usize = 8; + + let bounds = glyph.pixel_bounding_box().unwrap(); + assert_eq!( + (bounds.width() as usize, bounds.height() as usize), + (WIDTH, HEIGHT) + ); + + let mut target = [0u8; WIDTH * HEIGHT]; + b.iter(|| { + glyph.draw(|x, y, alpha| { + let (x, y) = (x as usize, y as usize); + target[WIDTH * y + x] = (alpha * 255.0) as u8; + }) + }); + + // verify the draw result against static reference hash + assert_eq!( + format!("{:x}", Blake2s::digest(&target)), + "c0e795601e3412144d1bfdc0cd94d9507aa9775a0f0f4f9862fe7ec7e83d7684" + ); +} + +#[bench] +fn draw_iota(b: &mut test::Bencher) { + let glyph = OPEN_SANS_ITALIC + .glyph('ΐ') + .scaled(Scale::uniform(60.0)) + .positioned(point(0.0, 0.0)); + + const WIDTH: usize = 14; + const HEIGHT: usize = 38; + + let bounds = glyph.pixel_bounding_box().unwrap(); + assert_eq!( + (bounds.width() as usize, bounds.height() as usize), + (WIDTH, HEIGHT) + ); + + let mut target = [0u8; WIDTH * HEIGHT]; + b.iter(|| { + glyph.draw(|x, y, alpha| { + let (x, y) = (x as usize, y as usize); + target[WIDTH * y + x] = (alpha * 255.0) as u8; + }) + }); + + // verify the draw result against static reference hash + assert_eq!( + format!("{:x}", Blake2s::digest(&target)), + "cdad348e38263a13f68ae41a95ce3b900d2881375a745232309ebd568a27cd4c" + ); +} diff --git a/third_party/cargo/vendor/rusttype-0.7.9/examples/gpu_cache.rs b/third_party/cargo/vendor/rusttype-0.7.9/examples/gpu_cache.rs new file mode 100644 index 0000000..c7aa20e --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/examples/gpu_cache.rs @@ -0,0 +1,277 @@ +use glium::*; +use rusttype::gpu_cache::Cache; +use rusttype::{point, vector, Font, PositionedGlyph, Rect, Scale}; +use std::borrow::Cow; +use std::error::Error; + +fn layout_paragraph<'a>( + font: &'a Font, + scale: Scale, + width: u32, + text: &str, +) -> Vec<PositionedGlyph<'a>> { + use unicode_normalization::UnicodeNormalization; + let mut result = Vec::new(); + let v_metrics = font.v_metrics(scale); + let advance_height = v_metrics.ascent - v_metrics.descent + v_metrics.line_gap; + let mut caret = point(0.0, v_metrics.ascent); + let mut last_glyph_id = None; + for c in text.nfc() { + if c.is_control() { + match c { + '\r' => { + caret = point(0.0, caret.y + advance_height); + } + '\n' => {} + _ => {} + } + continue; + } + let base_glyph = font.glyph(c); + if let Some(id) = last_glyph_id.take() { + caret.x += font.pair_kerning(scale, id, base_glyph.id()); + } + last_glyph_id = Some(base_glyph.id()); + let mut glyph = base_glyph.scaled(scale).positioned(caret); + if let Some(bb) = glyph.pixel_bounding_box() { + if bb.max.x > width as i32 { + caret = point(0.0, caret.y + advance_height); + glyph.set_position(caret); + last_glyph_id = None; + } + } + caret.x += glyph.unpositioned().h_metrics().advance_width; + result.push(glyph); + } + result +} + +fn main() -> Result<(), Box<dyn Error>> { + let font_data = include_bytes!("../fonts/wqy-microhei/WenQuanYiMicroHei.ttf"); + let font = Font::from_bytes(font_data as &[u8])?; + + let window = glium::glutin::WindowBuilder::new() + .with_dimensions((512, 512).into()) + .with_title("RustType GPU cache example"); + let context = glium::glutin::ContextBuilder::new().with_vsync(true); + let mut events_loop = glium::glutin::EventsLoop::new(); + let display = glium::Display::new(window, context, &events_loop)?; + + let dpi_factor = display.gl_window().window().get_hidpi_factor(); + + let (cache_width, cache_height) = ((512.0 * dpi_factor) as u32, (512.0 * dpi_factor) as u32); + let mut cache = Cache::builder() + .dimensions(cache_width, cache_height) + .build(); + + let program = program!( + &display, + 140 => { + vertex: " + #version 140 + + in vec2 position; + in vec2 tex_coords; + in vec4 colour; + + out vec2 v_tex_coords; + out vec4 v_colour; + + void main() { + gl_Position = vec4(position, 0.0, 1.0); + v_tex_coords = tex_coords; + v_colour = colour; + } + ", + + fragment: " + #version 140 + uniform sampler2D tex; + in vec2 v_tex_coords; + in vec4 v_colour; + out vec4 f_colour; + + void main() { + f_colour = v_colour * vec4(1.0, 1.0, 1.0, texture(tex, v_tex_coords).r); + } + " + })?; + let cache_tex = glium::texture::Texture2d::with_format( + &display, + glium::texture::RawImage2d { + data: Cow::Owned(vec![128u8; cache_width as usize * cache_height as usize]), + width: cache_width, + height: cache_height, + format: glium::texture::ClientFormat::U8, + }, + glium::texture::UncompressedFloatFormat::U8, + glium::texture::MipmapsOption::NoMipmap, + )?; + let mut text: String = "A japanese poem:\r +\r +色は匂へど散りぬるを我が世誰ぞ常ならむ有為の奥山今日越えて浅き夢見じ酔ひもせず\r +\r +Feel free to type out some text, and delete it with Backspace. \ +You can also try resizing this window." + .into(); + loop { + let dpi_factor = display.gl_window().window().get_hidpi_factor(); + let (width, _): (u32, _) = display + .gl_window() + .window() + .get_inner_size() + .ok_or("get_inner_size")? + .to_physical(dpi_factor) + .into(); + let dpi_factor = dpi_factor as f32; + + let mut finished = false; + events_loop.poll_events(|event| { + use glium::glutin::*; + + if let Event::WindowEvent { event, .. } = event { + match event { + WindowEvent::CloseRequested => finished = true, + WindowEvent::KeyboardInput { + input: + KeyboardInput { + state: ElementState::Pressed, + virtual_keycode: Some(keypress), + .. + }, + .. + } => match keypress { + VirtualKeyCode::Escape => finished = true, + VirtualKeyCode::Back => { + text.pop(); + } + _ => (), + }, + WindowEvent::ReceivedCharacter(c) => { + if c != '\u{7f}' && c != '\u{8}' { + text.push(c); + } + } + _ => {} + } + } + }); + if finished { + break; + } + + let glyphs = layout_paragraph(&font, Scale::uniform(24.0 * dpi_factor), width, &text); + for glyph in &glyphs { + cache.queue_glyph(0, glyph.clone()); + } + cache.cache_queued(|rect, data| { + cache_tex.main_level().write( + glium::Rect { + left: rect.min.x, + bottom: rect.min.y, + width: rect.width(), + height: rect.height(), + }, + glium::texture::RawImage2d { + data: Cow::Borrowed(data), + width: rect.width(), + height: rect.height(), + format: glium::texture::ClientFormat::U8, + }, + ); + })?; + + let uniforms = uniform! { + tex: cache_tex.sampled().magnify_filter(glium::uniforms::MagnifySamplerFilter::Nearest) + }; + + let vertex_buffer = { + #[derive(Copy, Clone)] + struct Vertex { + position: [f32; 2], + tex_coords: [f32; 2], + colour: [f32; 4], + } + + implement_vertex!(Vertex, position, tex_coords, colour); + let colour = [0.0, 0.0, 0.0, 1.0]; + let (screen_width, screen_height) = { + let (w, h) = display.get_framebuffer_dimensions(); + (w as f32, h as f32) + }; + let origin = point(0.0, 0.0); + let vertices: Vec<Vertex> = glyphs + .iter() + .flat_map(|g| { + if let Ok(Some((uv_rect, screen_rect))) = cache.rect_for(0, g) { + let gl_rect = Rect { + min: origin + + (vector( + screen_rect.min.x as f32 / screen_width - 0.5, + 1.0 - screen_rect.min.y as f32 / screen_height - 0.5, + )) * 2.0, + max: origin + + (vector( + screen_rect.max.x as f32 / screen_width - 0.5, + 1.0 - screen_rect.max.y as f32 / screen_height - 0.5, + )) * 2.0, + }; + arrayvec::ArrayVec::<[Vertex; 6]>::from([ + Vertex { + position: [gl_rect.min.x, gl_rect.max.y], + tex_coords: [uv_rect.min.x, uv_rect.max.y], + colour, + }, + Vertex { + position: [gl_rect.min.x, gl_rect.min.y], + tex_coords: [uv_rect.min.x, uv_rect.min.y], + colour, + }, + Vertex { + position: [gl_rect.max.x, gl_rect.min.y], + tex_coords: [uv_rect.max.x, uv_rect.min.y], + colour, + }, + Vertex { + position: [gl_rect.max.x, gl_rect.min.y], + tex_coords: [uv_rect.max.x, uv_rect.min.y], + colour, + }, + Vertex { + position: [gl_rect.max.x, gl_rect.max.y], + tex_coords: [uv_rect.max.x, uv_rect.max.y], + colour, + }, + Vertex { + position: [gl_rect.min.x, gl_rect.max.y], + tex_coords: [uv_rect.min.x, uv_rect.max.y], + colour, + }, + ]) + } else { + arrayvec::ArrayVec::new() + } + }) + .collect(); + + glium::VertexBuffer::new(&display, &vertices)? + }; + + let mut target = display.draw(); + target.clear_color(1.0, 1.0, 1.0, 0.0); + target.draw( + &vertex_buffer, + glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList), + &program, + &uniforms, + &glium::DrawParameters { + blend: glium::Blend::alpha_blending(), + ..Default::default() + }, + )?; + + target.finish()?; + } + + Ok(()) +} diff --git a/third_party/cargo/vendor/rusttype-0.7.9/examples/image.rs b/third_party/cargo/vendor/rusttype-0.7.9/examples/image.rs new file mode 100644 index 0000000..66091bf --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/examples/image.rs @@ -0,0 +1,64 @@ +use image::{DynamicImage, Rgba}; +use rusttype::{point, Font, Scale}; + +fn main() { + // Load the font + let font_data = include_bytes!("../fonts/wqy-microhei/WenQuanYiMicroHei.ttf"); + // This only succeeds if collection consists of one font + let font = Font::from_bytes(font_data as &[u8]).expect("Error constructing Font"); + + // The font size to use + let scale = Scale::uniform(32.0); + + // The text to render + let text = "This is RustType rendered into a png!"; + + // Use a dark red colour + let colour = (150, 0, 0); + + let v_metrics = font.v_metrics(scale); + + // layout the glyphs in a line with 20 pixels padding + let glyphs: Vec<_> = font + .layout(text, scale, point(20.0, 20.0 + v_metrics.ascent)) + .collect(); + + // work out the layout size + let glyphs_height = (v_metrics.ascent - v_metrics.descent).ceil() as u32; + let glyphs_width = { + let min_x = glyphs + .first() + .map(|g| g.pixel_bounding_box().unwrap().min.x) + .unwrap(); + let max_x = glyphs + .last() + .map(|g| g.pixel_bounding_box().unwrap().max.x) + .unwrap(); + (max_x - min_x) as u32 + }; + + // Create a new rgba image with some padding + let mut image = DynamicImage::new_rgba8(glyphs_width + 40, glyphs_height + 40).to_rgba(); + + // Loop through the glyphs in the text, positing each one on a line + for glyph in glyphs { + if let Some(bounding_box) = glyph.pixel_bounding_box() { + // Draw the glyph into the image per-pixel by using the draw closure + glyph.draw(|x, y, v| { + image.put_pixel( + // Offset the position by the glyph bounding box + x + bounding_box.min.x as u32, + y + bounding_box.min.y as u32, + // Turn the coverage into an alpha value + Rgba { + data: [colour.0, colour.1, colour.2, (v * 255.0) as u8], + }, + ) + }); + } + } + + // Save the image to a png file + image.save("image_example.png").unwrap(); + println!("Generated: image_example.png"); +} diff --git a/third_party/cargo/vendor/rusttype-0.7.9/examples/simple.rs b/third_party/cargo/vendor/rusttype-0.7.9/examples/simple.rs new file mode 100644 index 0000000..4ddd29a --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/examples/simple.rs @@ -0,0 +1,79 @@ +use rusttype::{point, FontCollection, PositionedGlyph, Scale}; +use std::io::Write; + +fn main() { + let font_data = include_bytes!("../fonts/wqy-microhei/WenQuanYiMicroHei.ttf"); + let collection = FontCollection::from_bytes(font_data as &[u8]).unwrap_or_else(|e| { + panic!("error constructing a FontCollection from bytes: {}", e); + }); + let font = collection + .into_font() // only succeeds if collection consists of one font + .unwrap_or_else(|e| { + panic!("error turning FontCollection into a Font: {}", e); + }); + + // Desired font pixel height + let height: f32 = 12.4; // to get 80 chars across (fits most terminals); adjust as desired + let pixel_height = height.ceil() as usize; + + // 2x scale in x direction to counter the aspect ratio of monospace characters. + let scale = Scale { + x: height * 2.0, + y: height, + }; + + // The origin of a line of text is at the baseline (roughly where + // non-descending letters sit). We don't want to clip the text, so we shift + // it down with an offset when laying it out. v_metrics.ascent is the + // distance between the baseline and the highest edge of any glyph in + // the font. That's enough to guarantee that there's no clipping. + let v_metrics = font.v_metrics(scale); + let offset = point(0.0, v_metrics.ascent); + + // Glyphs to draw for "RustType". Feel free to try other strings. + let glyphs: Vec<PositionedGlyph<'_>> = font.layout("RustType", scale, offset).collect(); + + // Find the most visually pleasing width to display + let width = glyphs + .iter() + .rev() + .map(|g| g.position().x as f32 + g.unpositioned().h_metrics().advance_width) + .next() + .unwrap_or(0.0) + .ceil() as usize; + + println!("width: {}, height: {}", width, pixel_height); + + // Rasterise directly into ASCII art. + let mut pixel_data = vec![b'@'; width * pixel_height]; + let mapping = b"@%#x+=:-. "; // The approximation of greyscale + let mapping_scale = (mapping.len() - 1) as f32; + for g in glyphs { + if let Some(bb) = g.pixel_bounding_box() { + g.draw(|x, y, v| { + // v should be in the range 0.0 to 1.0 + let i = (v * mapping_scale + 0.5) as usize; + // so something's wrong if you get $ in the output. + let c = mapping.get(i).cloned().unwrap_or(b'$'); + let x = x as i32 + bb.min.x; + let y = y as i32 + bb.min.y; + // There's still a possibility that the glyph clips the boundaries of the bitmap + if x >= 0 && x < width as i32 && y >= 0 && y < pixel_height as i32 { + let x = x as usize; + let y = y as usize; + pixel_data[(x + y * width)] = c; + } + }) + } + } + + // Print it out + let stdout = ::std::io::stdout(); + let mut handle = stdout.lock(); + for j in 0..pixel_height { + handle + .write_all(&pixel_data[j * width..(j + 1) * width]) + .unwrap(); + handle.write_all(b"\n").unwrap(); + } +} diff --git a/third_party/cargo/vendor/rusttype-0.7.9/rustfmt.toml b/third_party/cargo/vendor/rusttype-0.7.9/rustfmt.toml new file mode 100644 index 0000000..e2447e3 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/rustfmt.toml @@ -0,0 +1,5 @@ +# rustfmt 0.3.x-nightly +wrap_comments = true +error_on_line_overflow = false +use_field_init_shorthand = true +condense_wildcard_suffixes = true diff --git a/third_party/cargo/vendor/rusttype-0.7.9/src/lib.rs b/third_party/cargo/vendor/rusttype-0.7.9/src/lib.rs new file mode 100644 index 0000000..8b99e62 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/src/lib.rs @@ -0,0 +1,91 @@ +//! RustType is a pure Rust alternative to libraries like FreeType. +//! +//! The current capabilities of RustType: +//! +//! * Reading TrueType formatted fonts and font collections. This includes +//! `*.ttf` as well as a subset of `*.otf` font files. +//! * Retrieving glyph shapes and commonly used properties for a font and its +//! glyphs. +//! * Laying out glyphs horizontally using horizontal and vertical metrics, and +//! glyph-pair-specific kerning. +//! * Rasterising glyphs with sub-pixel positioning using an accurate analytical +//! algorithm (not based on sampling). +//! * Managing a font cache on the GPU with the `gpu_cache` module. This keeps +//! recently used glyph renderings in a dynamic cache in GPU memory to +//! minimise texture uploads per-frame. It also allows you keep the draw call +//! count for text very low, as all glyphs are kept in one GPU texture. +//! +//! Notable things that RustType does not support *yet*: +//! +//! * OpenType formatted fonts that are not just TrueType fonts (OpenType is a +//! superset of TrueType). Notably there is no support yet for cubic Bezier +//! curves used in glyphs. +//! * Font hinting. +//! * Ligatures of any kind. +//! * Some less common TrueType sub-formats. +//! * Right-to-left and vertical text layout. +//! +//! # Getting Started +//! +//! To hit the ground running with RustType, look at the `simple.rs` example +//! supplied with the crate. It demonstrates loading a font file, rasterising an +//! arbitrary string, and displaying the result as ASCII art. If you prefer to +//! just look at the documentation, the entry point for loading fonts is +//! `FontCollection`, from which you can access individual fonts, then their +//! glyphs. +//! +//! # Glyphs +//! +//! The glyph API uses wrapper structs to augment a glyph with information such +//! as scaling and positioning, making relevant methods that make use of this +//! information available as appropriate. For example, given a `Glyph` `glyph` +//! obtained directly from a `Font`: +//! +//! ```no_run +//! # use rusttype::*; +//! # let glyph: Glyph<'static> = unimplemented!(); +//! // One of the few things you can do with an unsized, positionless glyph is get its id. +//! let id = glyph.id(); +//! let glyph = glyph.scaled(Scale::uniform(10.0)); +//! // Now glyph is a ScaledGlyph, you can do more with it, as well as what you can do with Glyph. +//! // For example, you can access the correctly scaled horizontal metrics for the glyph. +//! let h_metrics = glyph.h_metrics(); +//! let glyph = glyph.positioned(point(5.0, 3.0)); +//! // Now glyph is a PositionedGlyph, and you can do even more with it, e.g. drawing. +//! glyph.draw(|x, y, v| {}); // In this case the pixel values are not used. +//! ``` +//! +//! # Unicode terminology +//! +//! This crate uses terminology for computerised typography as specified by the +//! Unicode standard. If you are not sure of the differences between a code +//! point, a character, and a glyph, you may want to check the [official Unicode +//! glossary](http://unicode.org/glossary/), or alternatively, here's my take on +//! it from a practical perspective: +//! +//! * A character is what you would conventionally call a single symbol, +//! independent of its appearance or representation in a particular font. +//! Examples include `a`, `A`, `ä`, `å`, `1`, `*`, `Ω`, etc. +//! * A Unicode code point is the particular number that the Unicode standard +//! associates with a particular character. Note however that code points also +//! exist for things not conventionally thought of as characters by +//! themselves, but can be combined to form characters, such as diacritics +//! like accents. These "characters" are known in Unicode as "combining +//! characters". E.g., a diaeresis (`¨`) has the code point U+0308. If this +//! code point follows the code point U+0055 (the letter `u`), this sequence +//! represents the character `ü`. Note that there is also a single codepoint +//! for `ü`, U+00FC. This means that what visually looks like the same string +//! can have multiple different Unicode representations. Some fonts will have +//! glyphs (see below) for one sequence of codepoints, but not another that +//! has the same meaning. To deal with this problem it is recommended to use +//! Unicode normalisation, as provided by, for example, the +//! [unicode-normalization](http://crates.io/crates/unicode-normalization) +//! crate, to convert to code point sequences that work with the font in +//! question. Typically a font is more likely to support a single code point +//! vs. a sequence with the same meaning, so the best normalisation to use is +//! "canonical recomposition", known as NFC in the normalisation crate. +//! * A glyph is a particular font's shape to draw the character for a +//! particular Unicode code point. This will have its own identifying number +//! unique to the font, its ID. + +pub use rusttype_next::*; diff --git a/third_party/cargo/vendor/rusttype-0.7.9/tests/issues.rs b/third_party/cargo/vendor/rusttype-0.7.9/tests/issues.rs new file mode 100644 index 0000000..6a0c2c5 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/tests/issues.rs @@ -0,0 +1,32 @@ +use rusttype::*; + +static ROBOTO_REGULAR: &[u8] = include_bytes!("../fonts/Roboto-Regular.ttf"); + +#[test] +fn consistent_bounding_box_subpixel_size_proxy() { + let font = Font::from_bytes(ROBOTO_REGULAR).unwrap(); + let height_at_y = |y| { + font.glyph('s') + .scaled(rusttype::Scale::uniform(20.0)) + .positioned(rusttype::Point { x: 0.0, y }) + .pixel_bounding_box() + .unwrap() + .height() + }; + assert_eq!(height_at_y(50.833_336), height_at_y(110.833_336)); +} + +#[test] +fn consistent_bounding_box_subpixel_size_standalone() { + let font = Font::from_bytes(ROBOTO_REGULAR).unwrap(); + let height_at_y = |y| { + font.glyph('s') + .standalone() + .scaled(rusttype::Scale::uniform(20.0)) + .positioned(rusttype::Point { x: 0.0, y }) + .pixel_bounding_box() + .unwrap() + .height() + }; + assert_eq!(height_at_y(50.833_336), height_at_y(110.833_336)); +} diff --git a/third_party/cargo/vendor/rusttype-0.7.9/tests/lipsum.txt b/third_party/cargo/vendor/rusttype-0.7.9/tests/lipsum.txt new file mode 100644 index 0000000..1763c41 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/tests/lipsum.txt @@ -0,0 +1,9 @@ +Lorem ipsum dolor sit amet, ferri simul omittantur eam eu, no debet doming dolorem ius. Iriure vocibus est te, natum delicata dignissim pri ea. Purto docendi definitiones no qui. Vel ridens instructior ad, vidisse percipitur et eos. Alienum ocurreret laboramus mei cu, usu ne meliore nostrum, usu tritani luptatum electram ad. + +Vis oratio tantas prodesset et, id stet inermis mea, at his copiosae accusata. Mel diam accusata argumentum cu, ut agam consul invidunt est. Ocurreret appellantur deterruisset no vis, his alia postulant inciderint no. Has albucius offendit at. An has noluisse comprehensam, vel veri dicit blandit ea, per paulo noluisse reformidans no. Nec ad sale illum soleat, agam scriptorem ad per. + +An cum odio mucius apeirian, labores conceptam ex nec, eruditi habemus qualisque eam an. Eu facilisi maluisset eos, fabulas apeirian ut qui, no atqui blandit vix. Apeirian phaedrum pri ex, vel hinc omnes sapientem et, vim vocibus legendos disputando ne. Et vel semper nominati rationibus, eum lorem causae scripta no. + +Ut quo elitr viderer constituam, pro omnesque forensibus at. Timeam scaevola mediocrem ut pri, te pro congue delicatissimi. Mei wisi nostro imperdiet ea, ridens salutatus per no, ut viris partem disputationi sit. Exerci eripuit referrentur vix at, sale mediocrem repudiare per te, modus admodum an eam. No vocent indoctum vis, ne quodsi patrioque vix. Vocent labores omittam et usu. + +Democritum signiferumque id nam, enim idque facilis at his. Inermis percipitur scriptorem sea cu, est ne error ludus option. Graecis expetenda contentiones cum et, ius nullam impetus suscipit ex. Modus clita corrumpit mel te, qui at lorem harum, primis cetero habemus sea id. Ei mutat affert dolorum duo, eum dissentias voluptatibus te, libris theophrastus duo id. diff --git a/third_party/cargo/vendor/rusttype-0.7.9/tests/reference_big_biohazard.png b/third_party/cargo/vendor/rusttype-0.7.9/tests/reference_big_biohazard.png new file mode 100644 index 0000000..96ab2e8 Binary files /dev/null and b/third_party/cargo/vendor/rusttype-0.7.9/tests/reference_big_biohazard.png differ diff --git a/third_party/cargo/vendor/rusttype-0.7.9/tests/reference_iota.png b/third_party/cargo/vendor/rusttype-0.7.9/tests/reference_iota.png new file mode 100644 index 0000000..4488c68 Binary files /dev/null and b/third_party/cargo/vendor/rusttype-0.7.9/tests/reference_iota.png differ diff --git a/third_party/cargo/vendor/rusttype-0.7.9/tests/reference_w.png b/third_party/cargo/vendor/rusttype-0.7.9/tests/reference_w.png new file mode 100644 index 0000000..670740f Binary files /dev/null and b/third_party/cargo/vendor/rusttype-0.7.9/tests/reference_w.png differ diff --git a/third_party/cargo/vendor/rusttype-0.7.9/tests/render_reference.rs b/third_party/cargo/vendor/rusttype-0.7.9/tests/render_reference.rs new file mode 100644 index 0000000..d802e17 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.7.9/tests/render_reference.rs @@ -0,0 +1,122 @@ +use image::{DynamicImage, LumaA}; +use rusttype::{point, Font, Scale, ScaledGlyph}; +use std::io::Cursor; + +lazy_static::lazy_static! { + static ref DEJA_VU_MONO: Font<'static> = + Font::from_bytes(include_bytes!("../fonts/dejavu/DejaVuSansMono.ttf") as &[u8]).unwrap(); + static ref OPEN_SANS_ITALIC: Font<'static> = + Font::from_bytes(include_bytes!("../fonts/opensans/OpenSans-Italic.ttf") as &[u8]).unwrap(); +} + +fn draw_luma_alpha(glyph: ScaledGlyph<'_>) -> image::GrayAlphaImage { + let glyph = glyph.positioned(point(0.0, 0.0)); + let bounds = glyph.pixel_bounding_box().unwrap(); + let mut glyph_image = + DynamicImage::new_luma_a8(bounds.width() as _, bounds.height() as _).to_luma_alpha(); + + glyph.draw(|x, y, v| { + glyph_image.put_pixel( + x, + y, + LumaA { + data: [128, (v * 255.0) as u8], + }, + ) + }); + + glyph_image +} + +/// Render a 600px U+2623 character require it to match the reference with +/// 8-bit accuracy +#[test] +fn render_to_reference_big_biohazard() { + let new_image = draw_luma_alpha(DEJA_VU_MONO.glyph('☣').scaled(Scale::uniform(600.0))); + + // save the new render for manual inspection + new_image.save("target/big_biohazard.png").unwrap(); + + let reference = image::load( + Cursor::new(include_bytes!("reference_big_biohazard.png") as &[u8]), + image::PNG, + ) + .expect("!image::load") + .to_luma_alpha(); + + assert_eq!(reference.dimensions(), new_image.dimensions()); + + for y in 0..reference.height() { + for x in 0..reference.width() { + assert_eq!( + reference.get_pixel(x, y), + new_image.get_pixel(x, y), + "unexpected alpha difference at ({}, {})", + x, + y + ); + } + } +} + +/// Render a 16px 'w' character require it to match the reference with 8-bit +/// accuracy +#[test] +fn render_to_reference_w() { + let new_image = draw_luma_alpha(DEJA_VU_MONO.glyph('w').scaled(Scale::uniform(16.0))); + + // save the new render for manual inspection + new_image.save("target/w.png").unwrap(); + + let reference = image::load( + Cursor::new(include_bytes!("reference_w.png") as &[u8]), + image::PNG, + ) + .expect("!image::load") + .to_luma_alpha(); + + assert_eq!(reference.dimensions(), new_image.dimensions()); + + for y in 0..reference.height() { + for x in 0..reference.width() { + assert_eq!( + reference.get_pixel(x, y), + new_image.get_pixel(x, y), + "unexpected alpha difference at ({}, {})", + x, + y + ); + } + } +} + +/// Render a 60px 'ΐ' character require it to match the reference with 8-bit +/// accuracy +#[test] +fn render_to_reference_iota() { + let new_image = draw_luma_alpha(OPEN_SANS_ITALIC.glyph('ΐ').scaled(Scale::uniform(60.0))); + + // save the new render for manual inspection + new_image.save("target/iota.png").unwrap(); + + let reference = image::load( + Cursor::new(include_bytes!("reference_iota.png") as &[u8]), + image::PNG, + ) + .expect("!image::load") + .to_luma_alpha(); + + assert_eq!(reference.dimensions(), new_image.dimensions()); + + for y in 0..reference.height() { + for x in 0..reference.width() { + assert_eq!( + reference.get_pixel(x, y), + new_image.get_pixel(x, y), + "unexpected alpha difference at ({}, {})", + x, + y + ); + } + } +} diff --git a/third_party/cargo/vendor/rusttype-0.8.2/.cargo-checksum.json b/third_party/cargo/vendor/rusttype-0.8.2/.cargo-checksum.json new file mode 100644 index 0000000..992ae60 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"9010bf26df753d67a8a3dd8602f88b7bb8934defa46f634e925689280e0ca2f2","Cargo.toml":"bbbaea100e9ec78824b3bc13a4717718fb186830febeef2e0db842bad79b7e09","LICENSE-APACHE":"000b4962e6b27176a0ff89cce4be555b16472cafb5671eb2804a8fdac6854793","LICENSE-MIT":"fd198949ebcc78b2d12fc57ebfb2da4ae8f781b7c3b7047aaccc2f804b6f12ef","README.md":"57f3d1e10f26e69dce7120be911226246aead1d40db3bdd15b63b71d69f315b8","rustfmt.toml":"ed17bf27c3712b8f22ec7a2a9d8e5d9d2a5654299754fb93e9ac76ef6d153114","src/geometry.rs":"a817203d90212574233ea6af5cd02b629e9bb52f4b71073040cc1236810fb907","src/gpu_cache.rs":"e278a000fd01478cb92e696bf67a0a3ef0ec1a50b5a813717028cdc5676c6ef0","src/lib.rs":"89266e185088c7922b0d86399ad67ad53b89ad564ccc86db2395c338e074e9d0","src/nostd_float.rs":"11f38ff37d6f67369d2cfc3ce960476aad8c7904c47d430fbf4655482e6cde7d","src/rasterizer.rs":"f91b8ab4285da4b96ee8058181db36d0002da3cd58d946e954abd373024a84a3"},"package":"14a911032fb5791ccbeec9f28fdcb9bf0983b81f227bafdfd227c658d0731c8a"} \ No newline at end of file diff --git a/third_party/cargo/vendor/rusttype-0.8.2/BUILD b/third_party/cargo/vendor/rusttype-0.8.2/BUILD new file mode 100644 index 0000000..e010fb1 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/BUILD @@ -0,0 +1,50 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "rusttype", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/approx-0.3.2:approx", + "//third_party/cargo/vendor/arrayvec-0.5.1:arrayvec", + "//third_party/cargo/vendor/ordered-float-1.0.2:ordered_float", + "//third_party/cargo/vendor/stb_truetype-0.3.1:stb_truetype", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.8.2", + crate_features = [ + "default", + "has-atomics", + "stb_truetype", + "std", + ], +) + diff --git a/third_party/cargo/vendor/rusttype-0.8.2/CHANGELOG.md b/third_party/cargo/vendor/rusttype-0.8.2/CHANGELOG.md new file mode 100644 index 0000000..442c0ac --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/CHANGELOG.md @@ -0,0 +1,164 @@ +## 0.8.2 +* Update crossbeam-utils -> `0.7`. +* Update libm -> `0.2.1`. + +## 0.8.1 +* Update arrayvec -> `0.5`. + +## 0.8 +* Support no-std usage by disabling the new default feature `std` and using new features `libm-math` and `has-atomics`. The gpu_cache module/feature requires std. + +## 0.7.9 +* Use semver trick to re-expect rusttype `0.8` with default-features on. + +## 0.7.8 +_yanked_ + +## 0.7.7 +* gpu_cache: Add `CacheBuilder::align_4x4` method which forces texture updates to align to 4x4 pixel boxes. +* gpu_cache: Disable multithread code and remove dependencies on wasm32. + +## 0.7.6 +* `GlyphIter` and `LayoutIter` provide the lifetime of the font data. + +## 0.7.5 +* gpu_cache: `Cache::cache_queued` now returns `CachedBy` for successes which can allow callers to tell that the texture cache has been re-ordered. + +## 0.7.4 +* Add fn `PositionedGlyph::set_position` +* gpu_cache: Update crossbeam-deque -> `0.7`, use `Injector` for minor rasterization performance boost. + +## 0.7.3 +* gpu_cache: Update crossbeam-utils -> `0.6`. + +## 0.7.2 +* Update ordered-float -> `1`. + +## 0.7.1 +* Fix `PositionedGlyph::pixel_bounding_box()` size inconsistencies at different positions with identical sub-pixel positions. + +## 0.7 + +* Rework `CacheBuilder` to use methods to allow non-breaking additions + in future. New style is `Cache::builder().dimensions(512, 512).build()`. +* Support multithreaded rasterization in the gpu_cache. This yields + significant improvements in worst case performance when more than 1 + CPU core is available. _Thrashing, resizing & population benchmarks + are ~3x faster on a 4-core Haswell._ + Multithreading is enabled by default in environments with more than + a single core, but can be explicitly disabled using + `Cache::builder().multithread(false)`. +* Remove all deprecated API. +* Add `Debug` implementations for `Font`, `Glyph`, `ScaledGlyph` & + `PositionedGlyph` +* Add and improve documentation + examples. + +## 0.6.5 + +* Re-export rusttype `0.7` non-breaking main API, while keeping the current + version of the gpu_cache module. + +## 0.6.4 + +* Add `CacheBuilder::rebuild` & `Cache::to_builder` methods. +* gpu_cache: Only rasterize & upload after queue has successfully fit in cache + producing a 1.16-1.29x speedup in resizing & thrashing benchmarks. + +## 0.6.3 + +* Documentation clarifications +* Avoid depending on unused dependency default-features + +## 0.6.2 + +* Add `From<&AsRef<[u8]>> for SharedBytes`. +* Optimise `gpu_cache` hashing to improve benchmark performance by ~30%. + +## 0.6.1 + +* Optimise rasterizer removing internal hashing. Improves draw benchmark + performance by 11-91%. + +## 0.6 + +* Rework gpu_cache data structures allowing constant time hash lookup + of matching cached glyph textures. Improve performance by ~60-200%. +* Deprecate `gpu_cache::Cache::new` in favour of `gpu_cache::CacheBuilder`. +* Deprecate `gpu_cache::Cache::set_scale_tolerance` & + `gpu_cache::Cache::set_position_tolerance`. These are now equivalent to + recreating the cache as they invalidate the cache keys. +* gpu_cache `scale_tolerance` & `position_tolerance` now have subtly different + meanings but guarantee their error in all cases, where previously the + worst case was double the set tolerance. + +## 0.5.2 + +* Add gpu cache glyph padding option to fix texture bleeding from other + glyphs when using interpolated texture coordinates near edges. Use + `CacheBuilder` to construct a `Cache` that makes use of padding. +* Inlining performance improvements. + +## 0.5.1 + +* Fix tree removal on row clear (gpu_cache). + +## 0.5 + +* Let functions like `Font::glyph` and `Font::pair_kerning` work with both + characters and glyph ids by having them accept any type that implements the + new `IntoGlyphId` trait. This replaces the `CodepointOrGlyph` enum, which + didn't seem widely used. +* Make `Font::glyph` always return a `Glyph`, not `Option<Glyph>`. Passing a + `char` the font doesn't cover returns a `.notdef` glyph (id 0), as it did + before. Passing an invalid glyph id now panics, like a bad array index: glyph + ids should only be used to index the font they were looked up for. +* Introduce `rusttype::Error`, which implements `std::error::Error`, `Debug` and + `Display`, and can be converted to `std::io::Error`. +* Use `Result<_, rusttype::Error>` to report failures in FontCollection, Font + and associated iterators. +* Add `Font::from_bytes` method similar to `FontCollection::from_bytes` for 1 + font collections. +* Improve gpu_cache performance ~2-6% + +## 0.4.3 + +* Improve gpu_cache performance ~6-17% + +## 0.4.2 + +* Allow users to get font names from `Font`. (#86) + +## 0.4 + +* Add more debugging features +* Add support for unscaled fonts +* Improve performance +* Make gpu_cache optional + +## 0.3 + +* Transfer to redox-os organization, merge a number of pull requests + +## 0.2.1 + +* Made the API more convenient (courtesy of @mitchmindtree, @I1048576). +* Fixes for the examples (@I1048576) +* Removed the dependency on ndarray (@I1048576) + +## 0.2 + +* Initial GPU caching implementation. +* Made font data management more flexible. +* Made the interface for font scales simpler. + +## 0.1.2 + +Fixed issue #8 + +## 0.1.1 + +Fixed issue #7 + +## 0.1 + +Initial release diff --git a/third_party/cargo/vendor/rusttype-0.8.2/Cargo.toml b/third_party/cargo/vendor/rusttype-0.8.2/Cargo.toml new file mode 100644 index 0000000..7d51b86 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/Cargo.toml @@ -0,0 +1,75 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "rusttype" +version = "0.8.2" +authors = ["Dylan Ede <dylanede@googlemail.com>", "Jeremy Soller <jackpot51@gmail.com>", "Alex Butler <alexheretic@gmail.com>"] +exclude = ["/dev/**"] +description = "A pure Rust alternative to libraries like FreeType.\n\nRustType provides an API for loading, querying and rasterising TrueType fonts.\n\nIt also provides an implementation of a dynamic GPU glyph cache for hardware font rendering.\n" +homepage = "https://gitlab.redox-os.org/redox-os/rusttype" +documentation = "https://docs.rs/rusttype" +readme = "README.md" +keywords = ["font", "truetype", "opentype", "ttf", "otf"] +license = "MIT / Apache-2.0" +repository = "https://gitlab.redox-os.org/redox-os/rusttype" +[package.metadata.docs.rs] +features = ["gpu_cache"] +[dependencies.approx] +version = "0.3" +default-features = false + +[dependencies.arrayvec] +version = "0.5" +default-features = false + +[dependencies.libm] +version = "0.2.1" +optional = true +default-features = false + +[dependencies.linked-hash-map] +version = "0.5" +optional = true + +[dependencies.ordered-float] +version = "1" +default-features = false + +[dependencies.rustc-hash] +version = "1" +optional = true + +[dependencies.stb_truetype] +version = "0.3.1" +default-features = false + +[dev-dependencies] + +[features] +default = ["std", "has-atomics"] +gpu_cache = ["std", "linked-hash-map", "rustc-hash", "crossbeam-deque", "crossbeam-utils", "num_cpus"] +has-atomics = [] +libm-math = ["libm", "stb_truetype/libm"] +std = ["has-atomics", "stb_truetype/std"] +[target."cfg(not(target_arch = \"wasm32\"))".dependencies.crossbeam-deque] +version = "0.7" +optional = true + +[target."cfg(not(target_arch = \"wasm32\"))".dependencies.crossbeam-utils] +version = "0.7" +optional = true + +[target."cfg(not(target_arch = \"wasm32\"))".dependencies.num_cpus] +version = "1.0" +optional = true diff --git a/third_party/cargo/vendor/rusttype-0.8.2/LICENSE-APACHE b/third_party/cargo/vendor/rusttype-0.8.2/LICENSE-APACHE new file mode 100644 index 0000000..6f75635 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/third_party/cargo/vendor/rusttype-0.8.2/LICENSE-MIT b/third_party/cargo/vendor/rusttype-0.8.2/LICENSE-MIT new file mode 100644 index 0000000..93cbd53 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Dylan Ede + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/rusttype-0.8.2/README.md b/third_party/cargo/vendor/rusttype-0.8.2/README.md new file mode 100644 index 0000000..bef38a8 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/README.md @@ -0,0 +1,87 @@ +# RustType +[![crates.io](https://img.shields.io/crates/v/rusttype.svg)](https://crates.io/crates/rusttype) +[![docs.rs](https://docs.rs/rusttype/badge.svg)](https://docs.rs/rusttype) + +RustType is a pure Rust alternative to libraries like FreeType. + +The current capabilities of RustType: + +* Reading TrueType formatted fonts and font collections. This includes `*.ttf` + as well as a subset of `*.otf` font files. +* Retrieving glyph shapes and commonly used properties for a font and its glyphs. +* Laying out glyphs horizontally using horizontal and vertical metrics, and + glyph-pair-specific kerning. +* Rasterising glyphs with sub-pixel positioning using an accurate analytical + algorithm (not based on sampling). +* Managing a font cache on the GPU with the `gpu_cache` module. This keeps + recently used glyph renderings + in a dynamic cache in GPU memory to minimise texture uploads per-frame. It + also allows you keep the draw call count for text very low, as all glyphs are + kept in one GPU texture. + +Notable things that RustType does not support *yet*: + +* OpenType formatted fonts that are not just TrueType fonts (OpenType is a + superset of TrueType). Notably there is no support yet for cubic Bezier curves + used in glyphs. +* Font hinting. +* Ligatures of any kind +* Some less common TrueType sub-formats. +* Right-to-left and vertical text layout. + +## Testing & examples +Heavier examples, tests & benchmarks are in the `./dev` directory. This avoids dev-dependency feature bleed. + +Run all tests with `cargo test --all --all-features`. + +Run examples with `cargo run --example <NAME> -p rusttype-dev` + +## Getting Started + +To hit the ground running with RustType, look at `dev/examples/simple.rs` +supplied with the crate. It demonstrates loading a font file, rasterising an +arbitrary string, and displaying the result as ASCII art. If you prefer to just +look at the documentation, the entry point for loading fonts is +`FontCollection`, from which you can access individual fonts, then their glyphs. + +## Future Plans + +The initial motivation for the project was to provide easy-to-use font rendering for games. +There are numerous avenues for improving RustType. Ideas: + +* Some form of hinting for improved legibility at small font sizes. +* Replacing the dependency on + [stb_truetype-rs](https://gitlab.redox-os.org/redox-os/stb_truetype-rs) + (a translation of [stb_truetype.h](https://github.com/nothings/stb/blob/master/stb_truetype.h)), + with OpenType font loading written in idiomatic Rust. +* Add support for cubic curves in OpenType fonts. +* Extract the rasterisation code into a separate vector graphics rendering crate. +* Support for some common forms of ligatures. +* And, eventually, support for embedded right-to-left Unicode text. + +If you think you could help with achieving any of these goals, feel free to open +a tracking issue for discussing them. + +## Minimum supported rust compiler +This crate is maintained with [latest stable rust](https://gist.github.com/alexheretic/d1e98d8433b602e57f5d0a9637927e0c). + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. + +### See Also + +- [glyph_brush](https://github.com/alexheretic/glyph-brush) - can cache vertex generation & provides more complex layouts. diff --git a/third_party/cargo/vendor/rusttype-0.8.2/rustfmt.toml b/third_party/cargo/vendor/rusttype-0.8.2/rustfmt.toml new file mode 100644 index 0000000..e2447e3 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/rustfmt.toml @@ -0,0 +1,5 @@ +# rustfmt 0.3.x-nightly +wrap_comments = true +error_on_line_overflow = false +use_field_init_shorthand = true +condense_wildcard_suffixes = true diff --git a/third_party/cargo/vendor/rusttype-0.8.2/src/geometry.rs b/third_party/cargo/vendor/rusttype-0.8.2/src/geometry.rs new file mode 100644 index 0000000..422198a --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/src/geometry.rs @@ -0,0 +1,355 @@ +use core::ops; + +#[cfg(all(feature = "libm-math", not(feature = "std")))] +use crate::nostd_float::FloatExt; + +/// A point in 2-dimensional space, with each dimension of type `N`. +/// +/// Legal operations on points are addition and subtraction by vectors, and +/// subtraction between points, to give a vector representing the offset between +/// the two points. Combined with the legal operations on vectors, meaningful +/// manipulations of vectors and points can be performed. +/// +/// For example, to interpolate between two points by a factor `t`: +/// +/// ``` +/// # use rusttype::*; +/// # let t = 0.5; let p0 = point(0.0, 0.0); let p1 = point(0.0, 0.0); +/// let interpolated_point = p0 + (p1 - p0) * t; +/// ``` +#[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)] +pub struct Point<N> { + pub x: N, + pub y: N, +} + +/// A vector in 2-dimensional space, with each dimension of type `N`. +/// +/// Legal operations on vectors are addition and subtraction by vectors, +/// addition by points (to give points), and multiplication and division by +/// scalars. +#[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)] +pub struct Vector<N> { + pub x: N, + pub y: N, +} +/// A convenience function for generating `Point`s. +#[inline] +pub fn point<N>(x: N, y: N) -> Point<N> { + Point { x, y } +} +/// A convenience function for generating `Vector`s. +#[inline] +pub fn vector<N>(x: N, y: N) -> Vector<N> { + Vector { x, y } +} + +impl<N: ops::Sub<Output = N>> ops::Sub for Point<N> { + type Output = Vector<N>; + fn sub(self, rhs: Point<N>) -> Vector<N> { + vector(self.x - rhs.x, self.y - rhs.y) + } +} + +impl<N: ops::Add<Output = N>> ops::Add for Vector<N> { + type Output = Vector<N>; + fn add(self, rhs: Vector<N>) -> Vector<N> { + vector(self.x + rhs.x, self.y + rhs.y) + } +} + +impl<N: ops::Sub<Output = N>> ops::Sub for Vector<N> { + type Output = Vector<N>; + fn sub(self, rhs: Vector<N>) -> Vector<N> { + vector(self.x - rhs.x, self.y - rhs.y) + } +} + +impl ops::Mul<f32> for Vector<f32> { + type Output = Vector<f32>; + fn mul(self, rhs: f32) -> Vector<f32> { + vector(self.x * rhs, self.y * rhs) + } +} + +impl ops::Mul<Vector<f32>> for f32 { + type Output = Vector<f32>; + fn mul(self, rhs: Vector<f32>) -> Vector<f32> { + vector(self * rhs.x, self * rhs.y) + } +} + +impl ops::Mul<f64> for Vector<f64> { + type Output = Vector<f64>; + fn mul(self, rhs: f64) -> Vector<f64> { + vector(self.x * rhs, self.y * rhs) + } +} + +impl ops::Mul<Vector<f64>> for f64 { + type Output = Vector<f64>; + fn mul(self, rhs: Vector<f64>) -> Vector<f64> { + vector(self * rhs.x, self * rhs.y) + } +} + +impl ops::Div<f32> for Vector<f32> { + type Output = Vector<f32>; + fn div(self, rhs: f32) -> Vector<f32> { + vector(self.x / rhs, self.y / rhs) + } +} + +impl ops::Div<Vector<f32>> for f32 { + type Output = Vector<f32>; + fn div(self, rhs: Vector<f32>) -> Vector<f32> { + vector(self / rhs.x, self / rhs.y) + } +} + +impl ops::Div<f64> for Vector<f64> { + type Output = Vector<f64>; + fn div(self, rhs: f64) -> Vector<f64> { + vector(self.x / rhs, self.y / rhs) + } +} + +impl ops::Div<Vector<f64>> for f64 { + type Output = Vector<f64>; + fn div(self, rhs: Vector<f64>) -> Vector<f64> { + vector(self / rhs.x, self / rhs.y) + } +} + +impl<N: ops::Add<Output = N>> ops::Add<Vector<N>> for Point<N> { + type Output = Point<N>; + fn add(self, rhs: Vector<N>) -> Point<N> { + point(self.x + rhs.x, self.y + rhs.y) + } +} + +impl<N: ops::Sub<Output = N>> ops::Sub<Vector<N>> for Point<N> { + type Output = Point<N>; + fn sub(self, rhs: Vector<N>) -> Point<N> { + point(self.x - rhs.x, self.y - rhs.y) + } +} + +impl<N: ops::Add<Output = N>> ops::Add<Point<N>> for Vector<N> { + type Output = Point<N>; + fn add(self, rhs: Point<N>) -> Point<N> { + point(self.x + rhs.x, self.y + rhs.y) + } +} + +/// A straight line between two points, `p[0]` and `p[1]` +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] +pub struct Line { + pub p: [Point<f32>; 2], +} +/// A quadratic Bezier curve, starting at `p[0]`, ending at `p[2]`, with control +/// point `p[1]`. +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] +pub struct Curve { + pub p: [Point<f32>; 3], +} +/// A rectangle, with top-left corner at `min`, and bottom-right corner at +/// `max`. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub struct Rect<N> { + pub min: Point<N>, + pub max: Point<N>, +} +impl<N: ops::Sub<Output = N> + Copy> Rect<N> { + pub fn width(&self) -> N { + self.max.x - self.min.x + } + pub fn height(&self) -> N { + self.max.y - self.min.y + } +} + +pub trait BoundingBox<N> { + fn bounding_box(&self) -> Rect<N> { + let (min_x, max_x) = self.x_bounds(); + let (min_y, max_y) = self.y_bounds(); + Rect { + min: point(min_x, min_y), + max: point(max_x, max_y), + } + } + fn x_bounds(&self) -> (N, N); + fn y_bounds(&self) -> (N, N); +} + +impl BoundingBox<f32> for Line { + fn x_bounds(&self) -> (f32, f32) { + let p = &self.p; + if p[0].x < p[1].x { + (p[0].x, p[1].x) + } else { + (p[1].x, p[0].x) + } + } + fn y_bounds(&self) -> (f32, f32) { + let p = &self.p; + if p[0].y < p[1].y { + (p[0].y, p[1].y) + } else { + (p[1].y, p[0].y) + } + } +} + +impl BoundingBox<f32> for Curve { + fn x_bounds(&self) -> (f32, f32) { + let p = &self.p; + if p[0].x <= p[1].x && p[1].x <= p[2].x { + (p[0].x, p[2].x) + } else if p[0].x >= p[1].x && p[1].x >= p[2].x { + (p[2].x, p[0].x) + } else { + let t = (p[0].x - p[1].x) / (p[0].x - 2.0 * p[1].x + p[2].x); + let _1mt = 1.0 - t; + let inflection = _1mt * _1mt * p[0].x + 2.0 * _1mt * t * p[1].x + t * t * p[2].x; + if p[1].x < p[0].x { + (inflection, p[0].x.max(p[2].x)) + } else { + (p[0].x.min(p[2].x), inflection) + } + } + } + + fn y_bounds(&self) -> (f32, f32) { + let p = &self.p; + if p[0].y <= p[1].y && p[1].y <= p[2].y { + (p[0].y, p[2].y) + } else if p[0].y >= p[1].y && p[1].y >= p[2].y { + (p[2].y, p[0].y) + } else { + let t = (p[0].y - p[1].y) / (p[0].y - 2.0 * p[1].y + p[2].y); + let _1mt = 1.0 - t; + let inflection = _1mt * _1mt * p[0].y + 2.0 * _1mt * t * p[1].y + t * t * p[2].y; + if p[1].y < p[0].y { + (inflection, p[0].y.max(p[2].y)) + } else { + (p[0].y.min(p[2].y), inflection) + } + } + } +} + +pub trait Cut: Sized { + fn cut_to(self, t: f32) -> Self; + fn cut_from(self, t: f32) -> Self; + fn cut_from_to(self, t0: f32, t1: f32) -> Self { + self.cut_from(t0).cut_to((t1 - t0) / (1.0 - t0)) + } +} + +impl Cut for Curve { + fn cut_to(self, t: f32) -> Curve { + let p = self.p; + let a = p[0] + t * (p[1] - p[0]); + let b = p[1] + t * (p[2] - p[1]); + let c = a + t * (b - a); + Curve { p: [p[0], a, c] } + } + fn cut_from(self, t: f32) -> Curve { + let p = self.p; + let a = p[0] + t * (p[1] - p[0]); + let b = p[1] + t * (p[2] - p[1]); + let c = a + t * (b - a); + Curve { p: [c, b, p[2]] } + } +} + +impl Cut for Line { + fn cut_to(self, t: f32) -> Line { + let p = self.p; + Line { + p: [p[0], p[0] + t * (p[1] - p[0])], + } + } + fn cut_from(self, t: f32) -> Line { + let p = self.p; + Line { + p: [p[0] + t * (p[1] - p[0]), p[1]], + } + } + fn cut_from_to(self, t0: f32, t1: f32) -> Line { + let p = self.p; + let v = p[1] - p[0]; + Line { + p: [p[0] + t0 * v, p[0] + t1 * v], + } + } +} + +/// The real valued solutions to a real quadratic equation. +#[derive(Copy, Clone, Debug)] +pub enum RealQuadraticSolution { + /// Two zero-crossing solutions + Two(f32, f32), + /// One zero-crossing solution (equation is a straight line) + One(f32), + /// One zero-touching solution + Touch(f32), + /// No solutions + None, + /// All real numbers are solutions since a == b == c == 0.0 + All, +} + +impl RealQuadraticSolution { + /// If there are two solutions, this function ensures that they are in order + /// (first < second) + pub fn in_order(self) -> RealQuadraticSolution { + use self::RealQuadraticSolution::*; + match self { + Two(x, y) => { + if x < y { + Two(x, y) + } else { + Two(y, x) + } + } + other => other, + } + } +} + +/// Solve a real quadratic equation, giving all real solutions, if any. +pub fn solve_quadratic_real(a: f32, b: f32, c: f32) -> RealQuadraticSolution { + let discriminant = b * b - 4.0 * a * c; + if discriminant > 0.0 { + let sqrt_d = discriminant.sqrt(); + let common = -b + if b >= 0.0 { -sqrt_d } else { sqrt_d }; + let x1 = 2.0 * c / common; + if a == 0.0 { + RealQuadraticSolution::One(x1) + } else { + let x2 = common / (2.0 * a); + RealQuadraticSolution::Two(x1, x2) + } + } else if discriminant < 0.0 { + RealQuadraticSolution::None + } else if b == 0.0 { + if a == 0.0 { + if c == 0.0 { + RealQuadraticSolution::All + } else { + RealQuadraticSolution::None + } + } else { + RealQuadraticSolution::Touch(0.0) + } + } else { + RealQuadraticSolution::Touch(2.0 * c / -b) + } +} + +#[test] +fn quadratic_test() { + solve_quadratic_real(-0.000_000_1, -2.0, 10.0); +} diff --git a/third_party/cargo/vendor/rusttype-0.8.2/src/gpu_cache.rs b/third_party/cargo/vendor/rusttype-0.8.2/src/gpu_cache.rs new file mode 100644 index 0000000..45c0661 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/src/gpu_cache.rs @@ -0,0 +1,1238 @@ +//! This module provides capabilities for managing a cache of rendered glyphs in +//! GPU memory, with the goal of minimisng the size and frequency of glyph +//! uploads to GPU memory from the CPU. +//! +//! This module is optional, and not compiled by default. To use it enable the +//! `gpu_cache` feature in your Cargo.toml. +//! +//! Typical applications that render directly with hardware graphics APIs (e.g. +//! games) need text rendering. There is not yet a performant solution for high +//! quality text rendering directly on the GPU that isn't experimental research +//! work. Quality is often critical for legibility, so many applications use +//! text or individual characters that have been rendered on the CPU. This is +//! done either ahead-of-time, giving a fixed set of fonts, characters, and +//! sizes that can be used at runtime, or dynamically as text is required. This +//! latter scenario is more flexible and the focus of this module. +//! +//! To minimise the CPU load and texture upload bandwidth saturation, recently +//! used glyphs should be cached on the GPU for use by future frames. This +//! module provides a mechanism for maintaining such a cache in the form of a +//! single packed 2D GPU texture. When a rendered glyph is requested, it is +//! either retrieved from its location in the texture if it is present or room +//! is made in the cache (if necessary), the CPU renders the glyph then it is +//! uploaded into a gap in the texture to be available for GPU rendering. This +//! cache uses a Least Recently Used (LRU) cache eviction scheme - glyphs in the +//! cache that have not been used recently are as a rule of thumb not likely to +//! be used again soon, so they are the best candidates for eviction to make +//! room for required glyphs. +//! +//! The API for the cache does not assume a particular graphics API. The +//! intended usage is to queue up glyphs that need to be present for the current +//! frame using `Cache::queue_glyph`, update the cache to ensure that the queued +//! glyphs are present using `Cache::cache_queued` (providing a function for +//! uploading pixel data), then when it's time to render call `Cache::rect_for` +//! to get the UV coordinates in the cache texture for each glyph. For a +//! concrete use case see the `gpu_cache` example. +//! +//! Cache dimensions are immutable. If you need to change the dimensions of the +//! cache texture (e.g. due to high cache pressure), rebuild a new `Cache`. +//! Either from scratch or with `CacheBuilder::rebuild`. +//! +//! # Example +//! +//! ``` +//! # use rusttype::{Font, gpu_cache::Cache, point, Scale}; +//! # use std::error::Error; +//! # fn example() -> Result<(), Box<dyn Error>> { +//! # let font_data: &[u8] = include_bytes!("../dev/fonts/dejavu/DejaVuSansMono.ttf"); +//! # let font: Font<'static> = Font::from_bytes(font_data)?; +//! # let glyph = font.glyph('a').scaled(Scale::uniform(25.0)).positioned(point(0.0, 0.0)); +//! # let glyph2 = glyph.clone(); +//! # fn update_gpu_texture(_: rusttype::Rect<u32>, _: &[u8]) {}; +//! // Build a default Cache. +//! let mut cache = Cache::builder().build(); +//! +//! // Queue some positioned glyphs needed for the next frame. +//! cache.queue_glyph(0, glyph); +//! +//! // Cache all queued glyphs somewhere in the cache texture. +//! // If new glyph data has been drawn the closure is called to upload +//! // the pixel data to GPU memory. +//! cache.cache_queued(|region, data| update_gpu_texture(region, data))?; +//! +//! # let glyph = glyph2; +//! // Lookup a positioned glyph's texture location +//! if let Ok(Some((uv_rect, screen_rect))) = cache.rect_for(0, &glyph) { +//! // Generate vertex data, etc +//! } +//! # Ok(()) +//! # } +//! ``` +use crate::{point, vector, GlyphId, Point, PositionedGlyph, Rect, Vector}; +use linked_hash_map::LinkedHashMap; +use rustc_hash::{FxHashMap, FxHasher}; +use std::collections::{HashMap, HashSet}; +use std::error; +use std::fmt; +use std::hash::BuildHasherDefault; + +type FxBuildHasher = BuildHasherDefault<FxHasher>; + +/// Texture coordinates (floating point) of the quad for a glyph in the cache, +/// as well as the pixel-space (integer) coordinates that this region should be +/// drawn at. +pub type TextureCoords = (Rect<f32>, Rect<i32>); +type FontId = usize; + +/// Indicates where a glyph texture is stored in the cache +/// (row position, glyph index in row) +type TextureRowGlyphIndex = (u32, u32); + +/// Texture lookup key that uses scale & offset as integers attained +/// by dividing by the relevant tolerance. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +struct LossyGlyphInfo { + font_id: FontId, + glyph_id: GlyphId, + /// x & y scales divided by `scale_tolerance` & rounded + scale_over_tolerance: (u32, u32), + /// Normalised subpixel positions divided by `position_tolerance` & rounded + /// + /// `u16` is enough as subpixel position `[-0.5, 0.5]` converted to `[0, 1]` + /// divided by the min `position_tolerance` (`0.001`) is small. + offset_over_tolerance: (u16, u16), +} + +#[derive(Debug, Clone, PartialEq, Eq)] +struct ByteArray2d { + inner_array: Vec<u8>, + row: usize, + col: usize, +} + +impl ByteArray2d { + #[inline] + pub fn zeros(row: usize, col: usize) -> Self { + ByteArray2d { + inner_array: vec![0; row * col], + row, + col, + } + } + + #[inline] + fn as_slice(&self) -> &[u8] { + self.inner_array.as_slice() + } + + #[inline] + fn get_vec_index(&self, row: usize, col: usize) -> usize { + debug_assert!( + row < self.row, + "row out of range: row={}, given={}", + self.row, + row + ); + debug_assert!( + col < self.col, + "column out of range: col={}, given={}", + self.col, + col + ); + row * self.col + col + } +} + +impl std::ops::Index<(usize, usize)> for ByteArray2d { + type Output = u8; + + #[inline] + fn index(&self, (row, col): (usize, usize)) -> &u8 { + &self.inner_array[self.get_vec_index(row, col)] + } +} + +impl std::ops::IndexMut<(usize, usize)> for ByteArray2d { + #[inline] + fn index_mut(&mut self, (row, col): (usize, usize)) -> &mut u8 { + let vec_index = self.get_vec_index(row, col); + &mut self.inner_array[vec_index] + } +} + +/// Row of pixel data +struct Row { + /// Row pixel height + height: u32, + /// Pixel width current in use by glyphs + width: u32, + glyphs: Vec<GlyphTexInfo>, +} + +struct GlyphTexInfo { + glyph_info: LossyGlyphInfo, + /// Actual (lossless) normalised subpixel offset of rasterized glyph + offset: Vector<f32>, + tex_coords: Rect<u32>, +} + +trait PaddingAware { + fn unpadded(self) -> Self; +} + +impl PaddingAware for Rect<u32> { + /// A padded texture has 1 extra pixel on all sides + fn unpadded(mut self) -> Self { + self.min.x += 1; + self.min.y += 1; + self.max.x -= 1; + self.max.y -= 1; + self + } +} + +/// An implementation of a dynamic GPU glyph cache. See the module documentation +/// for more information. +pub struct Cache<'font> { + scale_tolerance: f32, + position_tolerance: f32, + width: u32, + height: u32, + rows: LinkedHashMap<u32, Row, FxBuildHasher>, + /// Mapping of row gaps bottom -> top + space_start_for_end: FxHashMap<u32, u32>, + /// Mapping of row gaps top -> bottom + space_end_for_start: FxHashMap<u32, u32>, + queue: Vec<(FontId, PositionedGlyph<'font>)>, + all_glyphs: FxHashMap<LossyGlyphInfo, TextureRowGlyphIndex>, + pad_glyphs: bool, + align_4x4: bool, + multithread: bool, +} + +/// Builder & rebuilder for `Cache`. +/// +/// # Example +/// +/// ``` +/// use rusttype::gpu_cache::Cache; +/// +/// // Create a cache with all default values set explicitly +/// // equivalent to `Cache::builder().build()` +/// let default_cache = Cache::builder() +/// .dimensions(256, 256) +/// .scale_tolerance(0.1) +/// .position_tolerance(0.1) +/// .pad_glyphs(true) +/// .align_4x4(false) +/// .multithread(true) +/// .build(); +/// +/// // Create a cache with all default values, except with a dimension of 1024x1024 +/// let bigger_cache = Cache::builder().dimensions(1024, 1024).build(); +/// ``` +#[derive(Debug, Clone)] +pub struct CacheBuilder { + dimensions: (u32, u32), + scale_tolerance: f32, + position_tolerance: f32, + pad_glyphs: bool, + align_4x4: bool, + multithread: bool, +} + +impl Default for CacheBuilder { + fn default() -> Self { + Self { + dimensions: (256, 256), + scale_tolerance: 0.1, + position_tolerance: 0.1, + pad_glyphs: true, + align_4x4: false, + multithread: true, + } + } +} + +impl CacheBuilder { + /// `width` & `height` dimensions of the 2D texture that will hold the + /// cache contents on the GPU. + /// + /// This must match the dimensions of the actual texture used, otherwise + /// `cache_queued` will try to cache into coordinates outside the bounds of + /// the texture. + /// + /// # Example (set to default value) + /// + /// ``` + /// # use rusttype::gpu_cache::Cache; + /// let cache = Cache::builder().dimensions(256, 256).build(); + /// ``` + pub fn dimensions(mut self, width: u32, height: u32) -> Self { + self.dimensions = (width, height); + self + } + + /// Specifies the tolerances (maximum allowed difference) for judging + /// whether an existing glyph in the cache is close enough to the + /// requested glyph in scale to be used in its place. Due to floating + /// point inaccuracies a min value of `0.001` is enforced. + /// + /// Both `scale_tolerance` and `position_tolerance` are measured in pixels. + /// + /// Tolerances produce even steps for scale and subpixel position. Only a + /// single glyph texture will be used within a single step. For example, + /// `scale_tolerance = 0.1` will have a step `9.95-10.05` so similar glyphs + /// with scale `9.98` & `10.04` will match. + /// + /// A typical application will produce results with no perceptible + /// inaccuracies with `scale_tolerance` and `position_tolerance` set to + /// 0.1. Depending on the target DPI higher tolerance may be acceptable. + /// + /// # Example (set to default value) + /// + /// ``` + /// # use rusttype::gpu_cache::Cache; + /// let cache = Cache::builder().scale_tolerance(0.1).build(); + /// ``` + pub fn scale_tolerance<V: Into<f32>>(mut self, scale_tolerance: V) -> Self { + self.scale_tolerance = scale_tolerance.into(); + self + } + /// Specifies the tolerances (maximum allowed difference) for judging + /// whether an existing glyph in the cache is close enough to the requested + /// glyph in subpixel offset to be used in its place. Due to floating + /// point inaccuracies a min value of `0.001` is enforced. + /// + /// Both `scale_tolerance` and `position_tolerance` are measured in pixels. + /// + /// Tolerances produce even steps for scale and subpixel position. Only a + /// single glyph texture will be used within a single step. For example, + /// `scale_tolerance = 0.1` will have a step `9.95-10.05` so similar glyphs + /// with scale `9.98` & `10.04` will match. + /// + /// Note that since `position_tolerance` is a tolerance of subpixel + /// offsets, setting it to 1.0 or higher is effectively a "don't care" + /// option. + /// + /// A typical application will produce results with no perceptible + /// inaccuracies with `scale_tolerance` and `position_tolerance` set to + /// 0.1. Depending on the target DPI higher tolerance may be acceptable. + /// + /// # Example (set to default value) + /// + /// ``` + /// # use rusttype::gpu_cache::Cache; + /// let cache = Cache::builder().position_tolerance(0.1).build(); + /// ``` + pub fn position_tolerance<V: Into<f32>>(mut self, position_tolerance: V) -> Self { + self.position_tolerance = position_tolerance.into(); + self + } + /// Pack glyphs in texture with a padding of a single zero alpha pixel to + /// avoid bleeding from interpolated shader texture lookups near edges. + /// + /// If glyphs are never transformed this may be set to `false` to slightly + /// improve the glyph packing. + /// + /// # Example (set to default value) + /// + /// ``` + /// # use rusttype::gpu_cache::Cache; + /// let cache = Cache::builder().pad_glyphs(true).build(); + /// ``` + pub fn pad_glyphs(mut self, pad_glyphs: bool) -> Self { + self.pad_glyphs = pad_glyphs; + self + } + /// Align glyphs in texture to 4x4 texel boundaries. + /// + /// If your backend requires texture updates to be aligned to 4x4 texel + /// boundaries (e.g. WebGL), this should be set to `true`. + /// + /// # Example (set to default value) + /// + /// ``` + /// # use rusttype::gpu_cache::Cache; + /// let cache = Cache::builder().align_4x4(false).build(); + /// ``` + pub fn align_4x4(mut self, align_4x4: bool) -> Self { + self.align_4x4 = align_4x4; + self + } + /// When multiple CPU cores are available spread rasterization work across + /// all cores. + /// + /// Significantly reduces worst case latency in multicore environments. + /// + /// # Platform-specific behaviour + /// + /// This option has no effect on wasm32. + /// + /// # Example (set to default value) + /// + /// ``` + /// # use rusttype::gpu_cache::Cache; + /// let cache = Cache::builder().multithread(true).build(); + /// ``` + pub fn multithread(mut self, multithread: bool) -> Self { + self.multithread = multithread; + self + } + + fn validated(self) -> Self { + assert!(self.scale_tolerance >= 0.0); + assert!(self.position_tolerance >= 0.0); + let scale_tolerance = self.scale_tolerance.max(0.001); + let position_tolerance = self.position_tolerance.max(0.001); + #[cfg(not(target_arch = "wasm32"))] + let multithread = self.multithread && num_cpus::get() > 1; + Self { + scale_tolerance, + position_tolerance, + #[cfg(not(target_arch = "wasm32"))] + multithread, + ..self + } + } + + /// Constructs a new cache. Note that this is just the CPU side of the + /// cache. The GPU texture is managed by the user. + /// + /// # Panics + /// + /// `scale_tolerance` or `position_tolerance` are less than or equal to + /// zero. + /// + /// # Example + /// + /// ``` + /// # use rusttype::gpu_cache::Cache; + /// let cache = Cache::builder().build(); + /// ``` + pub fn build<'a>(self) -> Cache<'a> { + let CacheBuilder { + dimensions: (width, height), + scale_tolerance, + position_tolerance, + pad_glyphs, + align_4x4, + multithread, + } = self.validated(); + + Cache { + scale_tolerance, + position_tolerance, + width, + height, + rows: LinkedHashMap::default(), + space_start_for_end: { + let mut m = HashMap::default(); + m.insert(height, 0); + m + }, + space_end_for_start: { + let mut m = HashMap::default(); + m.insert(0, height); + m + }, + queue: Vec::new(), + all_glyphs: HashMap::default(), + pad_glyphs, + align_4x4, + multithread, + } + } + + /// Rebuilds a `Cache` with new attributes. All cached glyphs are cleared, + /// however the glyph queue is retained unmodified. + /// + /// # Panics + /// + /// `scale_tolerance` or `position_tolerance` are less than or equal to + /// zero. + /// + /// # Example + /// + /// ``` + /// # use rusttype::gpu_cache::Cache; + /// # let mut cache = Cache::builder().build(); + /// // Rebuild the cache with different dimensions + /// cache.to_builder().dimensions(768, 768).rebuild(&mut cache); + /// ``` + pub fn rebuild(self, cache: &mut Cache) { + let CacheBuilder { + dimensions: (width, height), + scale_tolerance, + position_tolerance, + pad_glyphs, + align_4x4, + multithread, + } = self.validated(); + + cache.width = width; + cache.height = height; + cache.scale_tolerance = scale_tolerance; + cache.position_tolerance = position_tolerance; + cache.pad_glyphs = pad_glyphs; + cache.align_4x4 = align_4x4; + cache.multithread = multithread; + cache.clear(); + } +} + +/// Returned from `Cache::rect_for`. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub enum CacheReadErr { + /// Indicates that the requested glyph is not present in the cache + GlyphNotCached, +} +impl fmt::Display for CacheReadErr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", error::Error::description(self)) + } +} +impl error::Error for CacheReadErr { + fn description(&self) -> &str { + match *self { + CacheReadErr::GlyphNotCached => "Glyph not cached", + } + } +} + +/// Returned from `Cache::cache_queued`. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub enum CacheWriteErr { + /// At least one of the queued glyphs is too big to fit into the cache, even + /// if all other glyphs are removed. + GlyphTooLarge, + /// Not all of the requested glyphs can fit into the cache, even if the + /// cache is completely cleared before the attempt. + NoRoomForWholeQueue, +} +impl fmt::Display for CacheWriteErr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", error::Error::description(self)) + } +} +impl error::Error for CacheWriteErr { + fn description(&self) -> &str { + match *self { + CacheWriteErr::GlyphTooLarge => "Glyph too large", + CacheWriteErr::NoRoomForWholeQueue => "No room for whole queue", + } + } +} + +/// Successful method of caching of the queue. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub enum CachedBy { + /// Added any additional glyphs into the texture without affecting + /// the position of any already cached glyphs in the latest queue. + /// + /// Glyphs not in the latest queue may have been removed. + Adding, + /// Fit the glyph queue by re-ordering all glyph texture positions. + /// Previous texture positions are no longer valid. + Reordering, +} + +fn normalised_offset_from_position(position: Point<f32>) -> Vector<f32> { + let mut offset = vector(position.x.fract(), position.y.fract()); + if offset.x > 0.5 { + offset.x -= 1.0; + } else if offset.x < -0.5 { + offset.x += 1.0; + } + if offset.y > 0.5 { + offset.y -= 1.0; + } else if offset.y < -0.5 { + offset.y += 1.0; + } + offset +} + +impl<'font> Cache<'font> { + /// Returns a default `CacheBuilder`. + #[inline] + pub fn builder() -> CacheBuilder { + CacheBuilder::default() + } + + /// Returns the current scale tolerance for the cache. + pub fn scale_tolerance(&self) -> f32 { + self.scale_tolerance + } + + /// Returns the current subpixel position tolerance for the cache. + pub fn position_tolerance(&self) -> f32 { + self.position_tolerance + } + + /// Returns the cache texture dimensions assumed by the cache. For proper + /// operation this should match the dimensions of the used GPU texture. + pub fn dimensions(&self) -> (u32, u32) { + (self.width, self.height) + } + + /// Queue a glyph for caching by the next call to `cache_queued`. `font_id` + /// is used to disambiguate glyphs from different fonts. The user should + /// ensure that `font_id` is unique to the font the glyph is from. + pub fn queue_glyph(&mut self, font_id: usize, glyph: PositionedGlyph<'font>) { + if glyph.pixel_bounding_box().is_some() { + self.queue.push((font_id, glyph)); + } + } + + /// Clears the cache. Does not affect the glyph queue. + pub fn clear(&mut self) { + self.rows.clear(); + self.space_end_for_start.clear(); + self.space_end_for_start.insert(0, self.height); + self.space_start_for_end.clear(); + self.space_start_for_end.insert(self.height, 0); + self.all_glyphs.clear(); + } + + /// Clears the glyph queue. + pub fn clear_queue(&mut self) { + self.queue.clear(); + } + + /// Returns a `CacheBuilder` with this cache's attributes. + pub fn to_builder(&self) -> CacheBuilder { + CacheBuilder { + dimensions: (self.width, self.height), + position_tolerance: self.position_tolerance, + scale_tolerance: self.scale_tolerance, + pad_glyphs: self.pad_glyphs, + align_4x4: self.align_4x4, + multithread: self.multithread, + } + } + + /// Returns glyph info with accuracy according to the set tolerances. + fn lossy_info_for(&self, font_id: FontId, glyph: &PositionedGlyph<'font>) -> LossyGlyphInfo { + let scale = glyph.scale(); + let offset = normalised_offset_from_position(glyph.position()); + + LossyGlyphInfo { + font_id, + glyph_id: glyph.id(), + scale_over_tolerance: ( + (scale.x / self.scale_tolerance + 0.5) as u32, + (scale.y / self.scale_tolerance + 0.5) as u32, + ), + // convert [-0.5, 0.5] -> [0, 1] then divide + offset_over_tolerance: ( + ((offset.x + 0.5) / self.position_tolerance + 0.5) as u16, + ((offset.y + 0.5) / self.position_tolerance + 0.5) as u16, + ), + } + } + + /// Caches the queued glyphs. If this is unsuccessful, the queue is + /// untouched. Any glyphs cached by previous calls to this function may be + /// removed from the cache to make room for the newly queued glyphs. Thus if + /// you want to ensure that a glyph is in the cache, the most recently + /// cached queue must have contained that glyph. + /// + /// `uploader` is the user-provided function that should perform the texture + /// uploads to the GPU. The information provided is the rectangular region + /// to insert the pixel data into, and the pixel data itself. This data is + /// provided in horizontal scanline format (row major), with stride equal to + /// the rectangle width. + /// + /// If successful returns a `CachedBy` that can indicate the validity of + /// previously cached glyph textures. + pub fn cache_queued<F: FnMut(Rect<u32>, &[u8])>( + &mut self, + mut uploader: F, + ) -> Result<CachedBy, CacheWriteErr> { + let mut queue_success = true; + let from_empty = self.all_glyphs.is_empty(); + + { + let (mut in_use_rows, mut uncached_glyphs) = { + let mut in_use_rows = + HashSet::with_capacity_and_hasher(self.rows.len(), FxBuildHasher::default()); + let mut uncached_glyphs = Vec::with_capacity(self.queue.len()); + + // divide glyphs into texture rows where a matching glyph texture + // already exists & glyphs where new textures must be cached + for (font_id, ref glyph) in &self.queue { + let glyph_info = self.lossy_info_for(*font_id, glyph); + if let Some((row, ..)) = self.all_glyphs.get(&glyph_info) { + in_use_rows.insert(*row); + } else { + uncached_glyphs.push((glyph, glyph_info)); + } + } + + (in_use_rows, uncached_glyphs) + }; + + for row in &in_use_rows { + self.rows.get_refresh(row); + } + + // tallest first gives better packing + // can use 'sort_unstable' as order of equal elements is unimportant + uncached_glyphs + .sort_unstable_by_key(|(glyph, ..)| -glyph.pixel_bounding_box().unwrap().height()); + + self.all_glyphs.reserve(uncached_glyphs.len()); + let mut draw_and_upload = Vec::with_capacity(uncached_glyphs.len()); + + 'per_glyph: for (glyph, glyph_info) in uncached_glyphs { + // glyph may match a texture cached by a previous iteration + if self.all_glyphs.contains_key(&glyph_info) { + continue; + } + + // Not cached, so add it: + let (unaligned_width, unaligned_height) = { + let bb = glyph.pixel_bounding_box().unwrap(); + if self.pad_glyphs { + (bb.width() as u32 + 2, bb.height() as u32 + 2) + } else { + (bb.width() as u32, bb.height() as u32) + } + }; + let (aligned_width, aligned_height) = if self.align_4x4 { + // align to the next 4x4 texel boundary + ((unaligned_width + 3) & !3, (unaligned_height + 3) & !3) + } else { + (unaligned_width, unaligned_height) + }; + if aligned_width >= self.width || aligned_height >= self.height { + return Result::Err(CacheWriteErr::GlyphTooLarge); + } + // find row to put the glyph in, most used rows first + let mut row_top = None; + for (top, row) in self.rows.iter().rev() { + if row.height >= aligned_height && self.width - row.width >= aligned_width { + // found a spot on an existing row + row_top = Some(*top); + break; + } + } + + if row_top.is_none() { + let mut gap = None; + // See if there is space for a new row + for (start, end) in &self.space_end_for_start { + if end - start >= aligned_height { + gap = Some((*start, *end)); + break; + } + } + if gap.is_none() { + // Remove old rows until room is available + while !self.rows.is_empty() { + // check that the oldest row isn't also in use + if !in_use_rows.contains(self.rows.front().unwrap().0) { + // Remove row + let (top, row) = self.rows.pop_front().unwrap(); + + for g in row.glyphs { + self.all_glyphs.remove(&g.glyph_info); + } + + let (mut new_start, mut new_end) = (top, top + row.height); + // Update the free space maps + // Combine with neighbouring free space if possible + if let Some(end) = self.space_end_for_start.remove(&new_end) { + new_end = end; + } + if let Some(start) = self.space_start_for_end.remove(&new_start) { + new_start = start; + } + self.space_start_for_end.insert(new_end, new_start); + self.space_end_for_start.insert(new_start, new_end); + if new_end - new_start >= aligned_height { + // The newly formed gap is big enough + gap = Some((new_start, new_end)); + break; + } + } + // all rows left are in use + // try a clean insert of all needed glyphs + // if that doesn't work, fail + else if from_empty { + // already trying a clean insert, don't do it again + return Err(CacheWriteErr::NoRoomForWholeQueue); + } else { + // signal that a retry is needed + queue_success = false; + break 'per_glyph; + } + } + } + let (gap_start, gap_end) = gap.unwrap(); + // fill space for new row + let new_space_start = gap_start + aligned_height; + self.space_end_for_start.remove(&gap_start); + if new_space_start == gap_end { + self.space_start_for_end.remove(&gap_end); + } else { + self.space_end_for_start.insert(new_space_start, gap_end); + self.space_start_for_end.insert(gap_end, new_space_start); + } + // add the row + self.rows.insert( + gap_start, + Row { + width: 0, + height: aligned_height, + glyphs: Vec::new(), + }, + ); + row_top = Some(gap_start); + } + let row_top = row_top.unwrap(); + // calculate the target rect + let row = self.rows.get_refresh(&row_top).unwrap(); + let aligned_tex_coords = Rect { + min: point(row.width, row_top), + max: point(row.width + aligned_width, row_top + aligned_height), + }; + let unaligned_tex_coords = Rect { + min: point(row.width, row_top), + max: point(row.width + unaligned_width, row_top + unaligned_height), + }; + + draw_and_upload.push((aligned_tex_coords, glyph)); + + // add the glyph to the row + row.glyphs.push(GlyphTexInfo { + glyph_info, + offset: normalised_offset_from_position(glyph.position()), + tex_coords: unaligned_tex_coords, + }); + row.width += aligned_width; + in_use_rows.insert(row_top); + + self.all_glyphs + .insert(glyph_info, (row_top, row.glyphs.len() as u32 - 1)); + } + + if queue_success { + #[cfg(not(target_arch = "wasm32"))] { + let glyph_count = draw_and_upload.len(); + + if self.multithread && glyph_count > 1 { + // multithread rasterization + use crossbeam_deque::Steal; + use std::{ + mem, + sync::mpsc::{self, TryRecvError}, + }; + + let rasterize_queue = crossbeam_deque::Injector::new(); + let (to_main, from_stealers) = mpsc::channel(); + let pad_glyphs = self.pad_glyphs; + + for el in draw_and_upload { + rasterize_queue.push(el); + } + crossbeam_utils::thread::scope(|scope| { + for _ in 0..num_cpus::get().min(glyph_count).saturating_sub(1) { + let rasterize_queue = &rasterize_queue; + let to_main = to_main.clone(); + scope.spawn(move |_| loop { + match rasterize_queue.steal() { + Steal::Success((tex_coords, glyph)) => { + let pixels = draw_glyph(tex_coords, glyph, pad_glyphs); + to_main.send((tex_coords, pixels)).unwrap(); + } + Steal::Empty => break, + Steal::Retry => {} + } + }); + } + mem::drop(to_main); + + let mut workers_finished = false; + loop { + match rasterize_queue.steal() { + Steal::Success((tex_coords, glyph)) => { + let pixels = draw_glyph(tex_coords, glyph, pad_glyphs); + uploader(tex_coords, pixels.as_slice()); + } + Steal::Empty if workers_finished => break, + Steal::Empty | Steal::Retry => {} + } + + while !workers_finished { + match from_stealers.try_recv() { + Ok((tex_coords, pixels)) => { + uploader(tex_coords, pixels.as_slice()) + } + Err(TryRecvError::Disconnected) => workers_finished = true, + Err(TryRecvError::Empty) => break, + } + } + } + }) + .unwrap(); + } else { + // single thread rasterization + for (tex_coords, glyph) in draw_and_upload { + let pixels = draw_glyph(tex_coords, glyph, self.pad_glyphs); + uploader(tex_coords, pixels.as_slice()); + } + } + } + #[cfg(target_arch = "wasm32")] { + for (tex_coords, glyph) in draw_and_upload { + let pixels = draw_glyph(tex_coords, glyph, self.pad_glyphs); + uploader(tex_coords, pixels.as_slice()); + } + } + } + } + + if queue_success { + self.queue.clear(); + Ok(CachedBy::Adding) + } else { + // clear the cache then try again with optimal packing + self.clear(); + self.cache_queued(uploader).map(|_| CachedBy::Reordering) + } + } + + /// Retrieves the (floating point) texture coordinates of the quad for a + /// glyph in the cache, as well as the pixel-space (integer) coordinates + /// that this region should be drawn at. These pixel-space coordinates + /// assume an origin at the top left of the quad. In the majority of cases + /// these pixel-space coordinates should be identical to the bounding box of + /// the input glyph. They only differ if the cache has returned a substitute + /// glyph that is deemed close enough to the requested glyph as specified by + /// the cache tolerance parameters. + /// + /// A sucessful result is `Some` if the glyph is not an empty glyph (no + /// shape, and thus no rect to return). + /// + /// Ensure that `font_id` matches the `font_id` that was passed to + /// `queue_glyph` with this `glyph`. + pub fn rect_for( + &self, + font_id: usize, + glyph: &PositionedGlyph, + ) -> Result<Option<TextureCoords>, CacheReadErr> { + if glyph.pixel_bounding_box().is_none() { + return Ok(None); + } + + let (row, index) = self + .all_glyphs + .get(&self.lossy_info_for(font_id, glyph)) + .ok_or(CacheReadErr::GlyphNotCached)?; + + let (tex_width, tex_height) = (self.width as f32, self.height as f32); + + let GlyphTexInfo { + tex_coords: mut tex_rect, + offset: tex_offset, + .. + } = self.rows[&row].glyphs[*index as usize]; + if self.pad_glyphs { + tex_rect = tex_rect.unpadded(); + } + let uv_rect = Rect { + min: point( + tex_rect.min.x as f32 / tex_width, + tex_rect.min.y as f32 / tex_height, + ), + max: point( + tex_rect.max.x as f32 / tex_width, + tex_rect.max.y as f32 / tex_height, + ), + }; + + let local_bb = glyph + .unpositioned() + .clone() + .positioned(point(0.0, 0.0) + tex_offset) + .pixel_bounding_box() + .unwrap(); + let min_from_origin = + point(local_bb.min.x as f32, local_bb.min.y as f32) - (point(0.0, 0.0) + tex_offset); + let ideal_min = min_from_origin + glyph.position(); + let min = point(ideal_min.x.round() as i32, ideal_min.y.round() as i32); + let bb_offset = min - local_bb.min; + let bb = Rect { + min, + max: local_bb.max + bb_offset, + }; + Ok(Some((uv_rect, bb))) + } +} + +#[inline] +fn draw_glyph(tex_coords: Rect<u32>, glyph: &PositionedGlyph<'_>, pad_glyphs: bool) -> ByteArray2d { + let mut pixels = ByteArray2d::zeros(tex_coords.height() as usize, tex_coords.width() as usize); + if pad_glyphs { + glyph.draw(|x, y, v| { + let v = (v * 255.0).round().max(0.0).min(255.0) as u8; + // `+ 1` accounts for top/left glyph padding + pixels[(y as usize + 1, x as usize + 1)] = v; + }); + } else { + glyph.draw(|x, y, v| { + let v = (v * 255.0).round().max(0.0).min(255.0) as u8; + pixels[(y as usize, x as usize)] = v; + }); + } + pixels +} + +#[cfg(test)] +mod test { + use super::*; + use crate::{Font, FontCollection, Scale}; + use approx::*; + + #[test] + fn cache_test() { + let font_data = include_bytes!("../dev/fonts/wqy-microhei/WenQuanYiMicroHei.ttf"); + let font = FontCollection::from_bytes(font_data as &[u8]) + .unwrap() + .into_font() + .unwrap(); + + let mut cache = Cache::builder() + .dimensions(32, 32) + .scale_tolerance(0.1) + .position_tolerance(0.1) + .pad_glyphs(false) + .build(); + let strings = [ + ("Hello World!", 15.0), + ("Hello World!", 14.0), + ("Hello World!", 10.0), + ("Hello World!", 15.0), + ("Hello World!", 14.0), + ("Hello World!", 10.0), + ]; + for &(string, scale) in &strings { + println!("Caching {:?}", (string, scale)); + for glyph in font.layout(string, Scale::uniform(scale), point(0.0, 0.0)) { + cache.queue_glyph(0, glyph); + } + cache.cache_queued(|_, _| {}).unwrap(); + } + } + + #[test] + fn need_to_check_whole_cache() { + let font_data = include_bytes!("../dev/fonts/wqy-microhei/WenQuanYiMicroHei.ttf"); + let font = Font::from_bytes(font_data as &[u8]).unwrap(); + + let glyph = font.glyph('l'); + + let small = glyph.clone().scaled(Scale::uniform(10.0)); + let large = glyph.clone().scaled(Scale::uniform(10.05)); + + let small_left = small.clone().positioned(point(0.0, 0.0)); + let large_left = large.clone().positioned(point(0.0, 0.0)); + let large_right = large.clone().positioned(point(-0.2, 0.0)); + + let mut cache = Cache::builder() + .dimensions(32, 32) + .scale_tolerance(0.1) + .position_tolerance(0.1) + .pad_glyphs(false) + .build(); + + cache.queue_glyph(0, small_left.clone()); + // Next line is noop since it's within the scale tolerance of small_left: + cache.queue_glyph(0, large_left.clone()); + cache.queue_glyph(0, large_right.clone()); + + cache.cache_queued(|_, _| {}).unwrap(); + + cache.rect_for(0, &small_left).unwrap(); + cache.rect_for(0, &large_left).unwrap(); + cache.rect_for(0, &large_right).unwrap(); + } + + #[test] + fn lossy_info() { + let font_data = include_bytes!("../dev/fonts/wqy-microhei/WenQuanYiMicroHei.ttf"); + let font = Font::from_bytes(font_data as &[u8]).unwrap(); + let glyph = font.glyph('l'); + + let small = glyph.clone().scaled(Scale::uniform(9.91)); + let near = glyph.clone().scaled(Scale::uniform(10.09)); + let far = glyph.clone().scaled(Scale::uniform(10.11)); + let really_far = glyph.clone().scaled(Scale::uniform(12.0)); + + let small_pos = small.clone().positioned(point(0.0, 0.0)); + let match_1 = near.clone().positioned(point(-10.0, -0.1)); + let match_2 = near.clone().positioned(point(5.1, 0.24)); + let match_3 = small.clone().positioned(point(-100.2, 50.1)); + + let miss_1 = far.clone().positioned(point(0.0, 0.0)); + let miss_2 = really_far.clone().positioned(point(0.0, 0.0)); + let miss_3 = small.clone().positioned(point(0.3, 0.0)); + + let cache = Cache::builder() + .scale_tolerance(0.2) + .position_tolerance(0.5) + .build(); + + let small_info = cache.lossy_info_for(0, &small_pos); + + assert_eq!(small_info, cache.lossy_info_for(0, &match_1)); + assert_eq!(small_info, cache.lossy_info_for(0, &match_2)); + assert_eq!(small_info, cache.lossy_info_for(0, &match_3)); + + assert_ne!(small_info, cache.lossy_info_for(0, &miss_1)); + assert_ne!(small_info, cache.lossy_info_for(0, &miss_2)); + assert_ne!(small_info, cache.lossy_info_for(0, &miss_3)); + } + + #[test] + fn cache_to_builder() { + let cache = CacheBuilder { + dimensions: (32, 64), + scale_tolerance: 0.2, + position_tolerance: 0.3, + pad_glyphs: false, + align_4x4: false, + multithread: false, + } + .build(); + + let to_builder: CacheBuilder = cache.to_builder(); + + assert_eq!(to_builder.dimensions, (32, 64)); + assert_relative_eq!(to_builder.scale_tolerance, 0.2); + assert_relative_eq!(to_builder.position_tolerance, 0.3); + assert_eq!(to_builder.pad_glyphs, false); + assert_eq!(to_builder.align_4x4, false); + assert_eq!(to_builder.multithread, false); + } + + #[test] + fn builder_rebuild() { + let mut cache = Cache::builder() + .dimensions(32, 64) + .scale_tolerance(0.2) + .position_tolerance(0.3) + .pad_glyphs(false) + .align_4x4(true) + .multithread(true) + .build(); + + let font = Font::from_bytes( + include_bytes!("../dev/fonts/wqy-microhei/WenQuanYiMicroHei.ttf") as &[u8], + ) + .unwrap(); + cache.queue_glyph( + 0, + font.glyph('l') + .scaled(Scale::uniform(25.0)) + .positioned(point(0.0, 0.0)), + ); + cache.cache_queued(|_, _| {}).unwrap(); + + cache.queue_glyph( + 0, + font.glyph('a') + .scaled(Scale::uniform(25.0)) + .positioned(point(0.0, 0.0)), + ); + + Cache::builder() + .dimensions(64, 128) + .scale_tolerance(0.05) + .position_tolerance(0.15) + .pad_glyphs(true) + .align_4x4(false) + .multithread(false) + .rebuild(&mut cache); + + assert_eq!(cache.width, 64); + assert_eq!(cache.height, 128); + assert_relative_eq!(cache.scale_tolerance, 0.05); + assert_relative_eq!(cache.position_tolerance, 0.15); + assert_eq!(cache.pad_glyphs, true); + assert_eq!(cache.align_4x4, false); + assert_eq!(cache.multithread, false); + + assert!( + cache.all_glyphs.is_empty(), + "cache should have been cleared" + ); + + assert_eq!(cache.queue.len(), 1, "cache should have an unchanged queue"); + } + + /// Provide to caller that the cache was re-ordered to fit the latest queue + #[test] + fn return_cache_by_reordering() { + let font_data = include_bytes!("../dev/fonts/wqy-microhei/WenQuanYiMicroHei.ttf"); + let font = FontCollection::from_bytes(font_data as &[u8]) + .unwrap() + .into_font() + .unwrap(); + + let mut cache = Cache::builder() + .dimensions(36, 27) + .scale_tolerance(0.1) + .position_tolerance(0.1) + .build(); + + for glyph in font.layout("ABCDEFG", Scale::uniform(16.0), point(0.0, 0.0)) { + cache.queue_glyph(0, glyph); + } + assert_eq!(cache.cache_queued(|_, _| {}), Ok(CachedBy::Adding)); + + for glyph in font.layout("DEFGHIJK", Scale::uniform(16.0), point(0.0, 0.0)) { + cache.queue_glyph(0, glyph); + } + assert_eq!(cache.cache_queued(|_, _| {}), Ok(CachedBy::Reordering)); + } + + #[test] + fn align_4x4() { + // First, test align_4x4 disabled, to confirm non-4x4 alignment + align_4x4_helper(false, 5, 19); + // Now, test with align_4x4 enabled, to confirm 4x4 alignment + align_4x4_helper(true, 8, 20); + } + + fn align_4x4_helper(align_4x4: bool, expected_width: u32, expected_height: u32) { + let mut cache = Cache::builder() + .dimensions(64, 64) + .align_4x4(align_4x4) + .build(); + let font = Font::from_bytes( + include_bytes!("../dev/fonts/wqy-microhei/WenQuanYiMicroHei.ttf") as &[u8], + ) + .unwrap(); + let glyph = font + .glyph('l') + .scaled(Scale::uniform(25.0)) + .positioned(point(0.0, 0.0)); + cache.queue_glyph(0, glyph.clone()); + cache + .cache_queued(|rect, _| { + assert_eq!(rect.width(), expected_width); + assert_eq!(rect.height(), expected_height); + }) + .unwrap(); + let (uv_rect, _screen_rect) = cache.rect_for(0, &glyph).unwrap().unwrap(); + assert_eq!( + uv_rect, + crate::Rect { + min: crate::point(0.015_625, 0.015_625), + max: crate::point(0.0625, 0.28125), + } + ); + } +} diff --git a/third_party/cargo/vendor/rusttype-0.8.2/src/lib.rs b/third_party/cargo/vendor/rusttype-0.8.2/src/lib.rs new file mode 100644 index 0000000..186d243 --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/src/lib.rs @@ -0,0 +1,1112 @@ +//! RustType is a pure Rust alternative to libraries like FreeType. +//! +//! The current capabilities of RustType: +//! +//! * Reading TrueType formatted fonts and font collections. This includes +//! `*.ttf` as well as a subset of `*.otf` font files. +//! * Retrieving glyph shapes and commonly used properties for a font and its +//! glyphs. +//! * Laying out glyphs horizontally using horizontal and vertical metrics, and +//! glyph-pair-specific kerning. +//! * Rasterising glyphs with sub-pixel positioning using an accurate analytical +//! algorithm (not based on sampling). +//! * Managing a font cache on the GPU with the `gpu_cache` module. This keeps +//! recently used glyph renderings in a dynamic cache in GPU memory to +//! minimise texture uploads per-frame. It also allows you keep the draw call +//! count for text very low, as all glyphs are kept in one GPU texture. +//! +//! Notable things that RustType does not support *yet*: +//! +//! * OpenType formatted fonts that are not just TrueType fonts (OpenType is a +//! superset of TrueType). Notably there is no support yet for cubic Bezier +//! curves used in glyphs. +//! * Font hinting. +//! * Ligatures of any kind. +//! * Some less common TrueType sub-formats. +//! * Right-to-left and vertical text layout. +//! +//! # Getting Started +//! +//! To hit the ground running with RustType, look at the `simple.rs` example +//! supplied with the crate. It demonstrates loading a font file, rasterising an +//! arbitrary string, and displaying the result as ASCII art. If you prefer to +//! just look at the documentation, the entry point for loading fonts is +//! `FontCollection`, from which you can access individual fonts, then their +//! glyphs. +//! +//! # Glyphs +//! +//! The glyph API uses wrapper structs to augment a glyph with information such +//! as scaling and positioning, making relevant methods that make use of this +//! information available as appropriate. For example, given a `Glyph` `glyph` +//! obtained directly from a `Font`: +//! +//! ```no_run +//! # use rusttype::*; +//! # let glyph: Glyph<'static> = unimplemented!(); +//! // One of the few things you can do with an unsized, positionless glyph is get its id. +//! let id = glyph.id(); +//! let glyph = glyph.scaled(Scale::uniform(10.0)); +//! // Now glyph is a ScaledGlyph, you can do more with it, as well as what you can do with Glyph. +//! // For example, you can access the correctly scaled horizontal metrics for the glyph. +//! let h_metrics = glyph.h_metrics(); +//! let glyph = glyph.positioned(point(5.0, 3.0)); +//! // Now glyph is a PositionedGlyph, and you can do even more with it, e.g. drawing. +//! glyph.draw(|x, y, v| {}); // In this case the pixel values are not used. +//! ``` +//! +//! # Unicode terminology +//! +//! This crate uses terminology for computerised typography as specified by the +//! Unicode standard. If you are not sure of the differences between a code +//! point, a character, and a glyph, you may want to check the [official Unicode +//! glossary](http://unicode.org/glossary/), or alternatively, here's my take on +//! it from a practical perspective: +//! +//! * A character is what you would conventionally call a single symbol, +//! independent of its appearance or representation in a particular font. +//! Examples include `a`, `A`, `ä`, `å`, `1`, `*`, `Ω`, etc. +//! * A Unicode code point is the particular number that the Unicode standard +//! associates with a particular character. Note however that code points also +//! exist for things not conventionally thought of as characters by +//! themselves, but can be combined to form characters, such as diacritics +//! like accents. These "characters" are known in Unicode as "combining +//! characters". E.g., a diaeresis (`¨`) has the code point U+0308. If this +//! code point follows the code point U+0055 (the letter `u`), this sequence +//! represents the character `ü`. Note that there is also a single codepoint +//! for `ü`, U+00FC. This means that what visually looks like the same string +//! can have multiple different Unicode representations. Some fonts will have +//! glyphs (see below) for one sequence of codepoints, but not another that +//! has the same meaning. To deal with this problem it is recommended to use +//! Unicode normalisation, as provided by, for example, the +//! [unicode-normalization](http://crates.io/crates/unicode-normalization) +//! crate, to convert to code point sequences that work with the font in +//! question. Typically a font is more likely to support a single code point +//! vs. a sequence with the same meaning, so the best normalisation to use is +//! "canonical recomposition", known as NFC in the normalisation crate. +//! * A glyph is a particular font's shape to draw the character for a +//! particular Unicode code point. This will have its own identifying number +//! unique to the font, its ID. +#![allow( + clippy::cognitive_complexity, + clippy::doc_markdown, + clippy::cast_lossless, + clippy::many_single_char_names +)] +#![cfg_attr(not(feature = "std"), no_std)] + +extern crate alloc; + +mod geometry; +mod rasterizer; + +#[cfg(all(feature = "libm-math", not(feature = "std")))] +mod nostd_float; + +#[cfg(feature = "gpu_cache")] +pub mod gpu_cache; + +pub use crate::geometry::{point, vector, Curve, Line, Point, Rect, Vector}; +use approx::relative_eq; +use core::fmt; +use stb_truetype as tt; + +#[cfg(not(feature = "has-atomics"))] +use alloc::rc::Rc as Arc; +#[cfg(feature = "has-atomics")] +use alloc::sync::Arc; + +#[cfg(not(feature = "std"))] +use alloc::{boxed::Box, vec::Vec}; +#[cfg(all(feature = "libm-math", not(feature = "std")))] +use crate::nostd_float::FloatExt; + +/// A collection of fonts read straight from a font file's data. The data in the +/// collection is not validated. This structure may or may not own the font +/// data. +/// +/// # Lifetime +/// The lifetime reflects the font data lifetime. `FontCollection<'static>` +/// covers most cases ie both dynamically loaded owned data and for referenced +/// compile time font data. +#[derive(Clone, Debug)] +pub struct FontCollection<'a>(SharedBytes<'a>); +/// A single font. This may or may not own the font data. +/// +/// # Lifetime +/// The lifetime reflects the font data lifetime. `Font<'static>` covers most +/// cases ie both dynamically loaded owned data and for referenced compile time +/// font data. +/// +/// # Example +/// +/// ``` +/// # use rusttype::{Font, Error}; +/// # fn example() -> Result<(), Error> { +/// let font_data: &[u8] = include_bytes!("../dev/fonts/dejavu/DejaVuSansMono.ttf"); +/// let font: Font<'static> = Font::from_bytes(font_data)?; +/// +/// let owned_font_data: Vec<u8> = font_data.to_vec(); +/// let from_owned_font: Font<'static> = Font::from_bytes(owned_font_data)?; +/// # Ok(()) +/// # } +/// ``` +#[derive(Clone)] +pub struct Font<'a> { + info: tt::FontInfo<SharedBytes<'a>>, +} + +impl fmt::Debug for Font<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Font") + } +} + +/// `SharedBytes` handles the lifetime of font data used in RustType. The data +/// is either a shared reference to externally owned data, or managed by +/// reference counting. `SharedBytes` can be conveniently used with `From` and +/// `Into`, and dereferences to the contained bytes. +/// +/// # Lifetime +/// The lifetime reflects the font data lifetime. `SharedBytes<'static>` covers +/// most cases ie both dynamically loaded owned data and for referenced compile +/// time font data. +#[derive(Clone, Debug)] +pub enum SharedBytes<'a> { + ByRef(&'a [u8]), + ByArc(Arc<[u8]>), +} + +impl<'a> core::ops::Deref for SharedBytes<'a> { + type Target = [u8]; + fn deref(&self) -> &[u8] { + match *self { + SharedBytes::ByRef(bytes) => bytes, + SharedBytes::ByArc(ref bytes) => &**bytes, + } + } +} +/// ``` +/// # use rusttype::SharedBytes; +/// let bytes: &[u8] = &[0u8, 1, 2, 3]; +/// let shared: SharedBytes = bytes.into(); +/// assert_eq!(&*shared, bytes); +/// ``` +impl<'a> From<&'a [u8]> for SharedBytes<'a> { + fn from(bytes: &'a [u8]) -> SharedBytes<'a> { + SharedBytes::ByRef(bytes) + } +} +/// ``` +/// # use rusttype::SharedBytes; +/// # use std::sync::Arc; +/// let bytes: Arc<[u8]> = vec![0u8, 1, 2, 3].into(); +/// let shared: SharedBytes = Arc::clone(&bytes).into(); +/// assert_eq!(&*shared, &*bytes); +/// ``` +impl From<Arc<[u8]>> for SharedBytes<'static> { + fn from(bytes: Arc<[u8]>) -> SharedBytes<'static> { + SharedBytes::ByArc(bytes) + } +} +/// ``` +/// # use rusttype::SharedBytes; +/// let bytes: Box<[u8]> = vec![0u8, 1, 2, 3].into(); +/// let shared: SharedBytes = bytes.into(); +/// assert_eq!(&*shared, &[0u8, 1, 2, 3]); +/// ``` +impl From<Box<[u8]>> for SharedBytes<'static> { + fn from(bytes: Box<[u8]>) -> SharedBytes<'static> { + SharedBytes::ByArc(bytes.into()) + } +} +/// ``` +/// # use rusttype::SharedBytes; +/// let bytes = vec![0u8, 1, 2, 3]; +/// let shared: SharedBytes = bytes.into(); +/// assert_eq!(&*shared, &[0u8, 1, 2, 3]); +/// ``` +impl From<Vec<u8>> for SharedBytes<'static> { + fn from(bytes: Vec<u8>) -> SharedBytes<'static> { + SharedBytes::ByArc(bytes.into()) + } +} +/// ``` +/// # use rusttype::SharedBytes; +/// let bytes = vec![0u8, 1, 2, 3]; +/// let shared: SharedBytes = (&bytes).into(); +/// assert_eq!(&*shared, &bytes as &[u8]); +/// ``` +impl<'a, T: AsRef<[u8]>> From<&'a T> for SharedBytes<'a> { + fn from(bytes: &'a T) -> SharedBytes<'a> { + SharedBytes::ByRef(bytes.as_ref()) + } +} + +/// Represents a Unicode code point. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub struct Codepoint(pub u32); +/// Represents a glyph identifier for a particular font. This identifier will +/// not necessarily correspond to the correct glyph in a font other than the +/// one that it was obtained from. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub struct GlyphId(pub u32); +/// A single glyph of a font. this may either be a thin wrapper referring to the +/// font and the glyph id, or it may be a standalone glyph that owns the data +/// needed by it. +/// +/// A `Glyph` does not have an inherent scale or position associated with it. To +/// augment a glyph with a size, give it a scale using `scaled`. You can then +/// position it using `positioned`. +#[derive(Clone)] +pub struct Glyph<'a> { + inner: GlyphInner<'a>, +} + +impl fmt::Debug for Glyph<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Glyph").field("id", &self.id().0).finish() + } +} + +#[derive(Clone)] +enum GlyphInner<'a> { + Proxy(Font<'a>, u32), + Shared(Arc<SharedGlyphData>), +} + +#[derive(Debug)] +pub struct SharedGlyphData { + pub id: u32, + pub extents: Option<Rect<i32>>, + pub scale_for_1_pixel: f32, + pub unit_h_metrics: HMetrics, + pub shape: Option<Vec<tt::Vertex>>, +} +/// The "horizontal metrics" of a glyph. This is useful for calculating the +/// horizontal offset of a glyph from the previous one in a string when laying a +/// string out horizontally. +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] +pub struct HMetrics { + /// The horizontal offset that the origin of the next glyph should be from + /// the origin of this glyph. + pub advance_width: f32, + /// The horizontal offset between the origin of this glyph and the leftmost + /// edge/point of the glyph. + pub left_side_bearing: f32, +} +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] +/// The "vertical metrics" of a font at a particular scale. This is useful for +/// calculating the amount of vertical space to give a line of text, and for +/// computing the vertical offset between successive lines. +pub struct VMetrics { + /// The highest point that any glyph in the font extends to above the + /// baseline. Typically positive. + pub ascent: f32, + /// The lowest point that any glyph in the font extends to below the + /// baseline. Typically negative. + pub descent: f32, + /// The gap to leave between the descent of one line and the ascent of the + /// next. This is of course only a guideline given by the font's designers. + pub line_gap: f32, +} + +impl From<tt::VMetrics> for VMetrics { + fn from(vm: tt::VMetrics) -> Self { + Self { + ascent: vm.ascent as f32, + descent: vm.descent as f32, + line_gap: vm.line_gap as f32, + } + } +} + +impl core::ops::Mul<f32> for VMetrics { + type Output = VMetrics; + + fn mul(self, rhs: f32) -> Self { + Self { + ascent: self.ascent * rhs, + descent: self.descent * rhs, + line_gap: self.line_gap * rhs, + } + } +} + +/// A glyph augmented with scaling information. You can query such a glyph for +/// information that depends on the scale of the glyph. +#[derive(Clone)] +pub struct ScaledGlyph<'a> { + g: Glyph<'a>, + api_scale: Scale, + scale: Vector<f32>, +} + +impl fmt::Debug for ScaledGlyph<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ScaledGlyph") + .field("id", &self.id().0) + .field("scale", &self.api_scale) + .finish() + } +} + +/// A glyph augmented with positioning and scaling information. You can query +/// such a glyph for information that depends on the scale and position of the +/// glyph. +#[derive(Clone)] +pub struct PositionedGlyph<'a> { + sg: ScaledGlyph<'a>, + position: Point<f32>, + bb: Option<Rect<i32>>, +} + +impl fmt::Debug for PositionedGlyph<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("PositionedGlyph") + .field("id", &self.id().0) + .field("scale", &self.scale()) + .field("position", &self.position) + .finish() + } +} + +/// Defines the size of a rendered face of a font, in pixels, horizontally and +/// vertically. A vertical scale of `y` pixels means that the distance betwen +/// the ascent and descent lines (see `VMetrics`) of the face will be `y` +/// pixels. If `x` and `y` are equal the scaling is uniform. Non-uniform scaling +/// by a factor *f* in the horizontal direction is achieved by setting `x` equal +/// to *f* times `y`. +#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)] +pub struct Scale { + /// Horizontal scale, in pixels. + pub x: f32, + /// Vertical scale, in pixels. + pub y: f32, +} + +impl Scale { + /// Uniform scaling, equivalent to `Scale { x: s, y: s }`. + #[inline] + pub fn uniform(s: f32) -> Scale { + Scale { x: s, y: s } + } +} +/// A trait for types that can be converted into a `GlyphId`, in the context of +/// a specific font. +/// +/// Many `rusttype` functions that operate on characters accept values of any +/// type that implements `IntoGlyphId`. Such types include `char`, `Codepoint`, +/// and obviously `GlyphId` itself. +pub trait IntoGlyphId { + /// Convert `self` into a `GlyphId`, consulting the index map of `font` if + /// necessary. + fn into_glyph_id(self, _: &Font<'_>) -> GlyphId; +} +impl IntoGlyphId for char { + fn into_glyph_id(self, font: &Font<'_>) -> GlyphId { + GlyphId(font.info.find_glyph_index(self as u32)) + } +} +impl IntoGlyphId for Codepoint { + fn into_glyph_id(self, font: &Font<'_>) -> GlyphId { + GlyphId(font.info.find_glyph_index(self.0)) + } +} +impl IntoGlyphId for GlyphId { + #[inline] + fn into_glyph_id(self, _font: &Font<'_>) -> GlyphId { + self + } +} +impl<'a> FontCollection<'a> { + /// Constructs a font collection from an array of bytes, typically loaded + /// from a font file, which may be a single font or a TrueType Collection + /// holding a number of fonts. This array may be owned (e.g. `Vec<u8>`), or + /// borrowed (`&[u8]`). As long as `From<T>` is implemented for `Bytes` for + /// some type `T`, `T` can be used as input. + /// + /// This returns an error if `bytes` does not seem to be font data in a + /// format we recognize. + pub fn from_bytes<B: Into<SharedBytes<'a>>>(bytes: B) -> Result<FontCollection<'a>, Error> { + let bytes = bytes.into(); + // We should use tt::is_collection once it lands in stb_truetype-rs: + // https://github.com/redox-os/stb_truetype-rs/pull/15 + if !tt::is_font(&bytes) && &bytes[0..4] != b"ttcf" { + return Err(Error::UnrecognizedFormat); + } + + Ok(FontCollection(bytes)) + } + /// If this `FontCollection` holds a single font, or a TrueType Collection + /// containing only one font, return that as a `Font`. The `FontCollection` + /// is consumed. + /// + /// If this `FontCollection` holds multiple fonts, return a + /// `CollectionContainsMultipleFonts` error. + /// + /// If an error occurs, the `FontCollection` is lost, since this function + /// takes ownership of it, and the error values don't give it back. If that + /// is a problem, use the `font_at` or `into_fonts` methods instead, which + /// borrow the `FontCollection` rather than taking ownership of it. + pub fn into_font(self) -> Result<Font<'a>, Error> { + let offset = if tt::is_font(&self.0) { + 0 + } else if tt::get_font_offset_for_index(&self.0, 1).is_some() { + return Err(Error::CollectionContainsMultipleFonts); + } else { + // We now know that either a) `self.0` is a collection with only one + // font, or b) `get_font_offset_for_index` found data it couldn't + // recognize. Request the first font's offset, distinguishing + // those two cases. + match tt::get_font_offset_for_index(&self.0, 0) { + None => return Err(Error::IllFormed), + Some(offset) => offset, + } + }; + let info = tt::FontInfo::new(self.0, offset as usize).ok_or(Error::IllFormed)?; + Ok(Font { info }) + } + /// Gets the font at index `i` in the font collection, if it exists and is + /// valid. The produced font borrows the font data that is either borrowed + /// or owned by this font collection. + pub fn font_at(&self, i: usize) -> Result<Font<'a>, Error> { + let offset = tt::get_font_offset_for_index(&self.0, i as i32) + .ok_or(Error::CollectionIndexOutOfBounds)?; + let info = tt::FontInfo::new(self.0.clone(), offset as usize).ok_or(Error::IllFormed)?; + Ok(Font { info }) + } + /// Converts `self` into an `Iterator` yielding each `Font` that exists + /// within the collection. + pub fn into_fonts(self) -> IntoFontsIter<'a> { + IntoFontsIter { + collection: self, + next_index: 0, + } + } +} +pub struct IntoFontsIter<'a> { + next_index: usize, + collection: FontCollection<'a>, +} +impl<'a> Iterator for IntoFontsIter<'a> { + type Item = Result<Font<'a>, Error>; + fn next(&mut self) -> Option<Self::Item> { + let result = self.collection.font_at(self.next_index); + if let Err(Error::CollectionIndexOutOfBounds) = result { + return None; + } + self.next_index += 1; + Some(result) + } +} +impl<'a> Font<'a> { + /// Constructs a font from an array of bytes, this is a shortcut for + /// `FontCollection::from_bytes` for collections comprised of a single font. + pub fn from_bytes<B: Into<SharedBytes<'a>>>(bytes: B) -> Result<Font<'a>, Error> { + FontCollection::from_bytes(bytes).and_then(|c| c.into_font()) + } + + /// The "vertical metrics" for this font at a given scale. These metrics are + /// shared by all of the glyphs in the font. See `VMetrics` for more detail. + pub fn v_metrics(&self, scale: Scale) -> VMetrics { + let vm = self.info.get_v_metrics(); + let scale = self.info.scale_for_pixel_height(scale.y); + VMetrics::from(vm) * scale + } + + /// Get the unscaled VMetrics for this font, shared by all glyphs. + /// See `VMetrics` for more detail. + pub fn v_metrics_unscaled(&self) -> VMetrics { + VMetrics::from(self.info.get_v_metrics()) + } + + /// Returns the units per EM square of this font + pub fn units_per_em(&self) -> u16 { + self.info.units_per_em() + } + + /// The number of glyphs present in this font. Glyph identifiers for this + /// font will always be in the range `0..self.glyph_count()` + pub fn glyph_count(&self) -> usize { + self.info.get_num_glyphs() as usize + } + + /// Returns the corresponding glyph for a Unicode code point or a glyph id + /// for this font. + /// + /// If `id` is a `GlyphId`, it must be valid for this font; otherwise, this + /// function panics. `GlyphId`s should always be produced by looking up some + /// other sort of designator (like a Unicode code point) in a font, and + /// should only be used to index the font they were produced for. + /// + /// Note that code points without corresponding glyphs in this font map to + /// the ".notdef" glyph, glyph 0. + pub fn glyph<C: IntoGlyphId>(&self, id: C) -> Glyph<'a> { + let gid = id.into_glyph_id(self); + assert!((gid.0 as usize) < self.glyph_count()); + // font clone either a reference clone, or arc clone + Glyph::new(GlyphInner::Proxy(self.clone(), gid.0)) + } + /// A convenience function. + /// + /// Returns an iterator that produces the glyphs corresponding to the code + /// points or glyph ids produced by the given iterator `itr`. + /// + /// This is equivalent in behaviour to `itr.map(|c| font.glyph(c))`. + pub fn glyphs_for<I: Iterator>(&self, itr: I) -> GlyphIter<'a, '_, I> + where + I::Item: IntoGlyphId, + { + GlyphIter { font: self, itr } + } + /// Returns an iterator over the names for this font. + pub fn font_name_strings(&self) -> tt::FontNameIter<'_, SharedBytes<'a>> { + self.info.get_font_name_strings() + } + /// A convenience function for laying out glyphs for a string horizontally. + /// It does not take control characters like line breaks into account, as + /// treatment of these is likely to depend on the application. + /// + /// Note that this function does not perform Unicode normalisation. + /// Composite characters (such as ö constructed from two code points, ¨ and + /// o), will not be normalised to single code points. So if a font does not + /// contain a glyph for each separate code point, but does contain one for + /// the normalised single code point (which is common), the desired glyph + /// will not be produced, despite being present in the font. Deal with this + /// by performing Unicode normalisation on the input string before passing + /// it to `layout`. The crate + /// [unicode-normalization](http://crates.io/crates/unicode-normalization) + /// is perfect for this purpose. + /// + /// Calling this function is equivalent to a longer sequence of operations + /// involving `glyphs_for`, e.g. + /// + /// ```no_run + /// # use rusttype::*; + /// # let (scale, start) = (Scale::uniform(0.0), point(0.0, 0.0)); + /// # let font: Font = unimplemented!(); + /// font.layout("Hello World!", scale, start) + /// # ; + /// ``` + /// + /// produces an iterator with behaviour equivalent to the following: + /// + /// ```no_run + /// # use rusttype::*; + /// # let (scale, start) = (Scale::uniform(0.0), point(0.0, 0.0)); + /// # let font: Font = unimplemented!(); + /// font.glyphs_for("Hello World!".chars()) + /// .scan((None, 0.0), |&mut (mut last, mut x), g| { + /// let g = g.scaled(scale); + /// if let Some(last) = last { + /// x += font.pair_kerning(scale, last, g.id()); + /// } + /// let w = g.h_metrics().advance_width; + /// let next = g.positioned(start + vector(x, 0.0)); + /// last = Some(next.id()); + /// x += w; + /// Some(next) + /// }) + /// # ; + /// ``` + pub fn layout<'b>(&'b self, s: &'b str, scale: Scale, start: Point<f32>) -> LayoutIter<'a, 'b> { + LayoutIter { + font: self, + chars: s.chars(), + caret: 0.0, + scale, + start, + last_glyph: None, + } + } + /// Returns additional kerning to apply as well as that given by HMetrics + /// for a particular pair of glyphs. + pub fn pair_kerning<A, B>(&self, scale: Scale, first: A, second: B) -> f32 + where + A: IntoGlyphId, + B: IntoGlyphId, + { + let first_id = first.into_glyph_id(self); + let second_id = second.into_glyph_id(self); + let factor = self.info.scale_for_pixel_height(scale.y) * (scale.x / scale.y); + let kern = self.info.get_glyph_kern_advance(first_id.0, second_id.0); + factor * kern as f32 + } +} +#[derive(Clone)] +pub struct GlyphIter<'a, 'b, I: Iterator> +where + I::Item: IntoGlyphId, +{ + font: &'b Font<'a>, + itr: I, +} +impl<'a, 'b, I: Iterator> Iterator for GlyphIter<'a, 'b, I> +where + I::Item: IntoGlyphId, +{ + type Item = Glyph<'a>; + fn next(&mut self) -> Option<Glyph<'a>> { + self.itr.next().map(|c| self.font.glyph(c)) + } +} +#[derive(Clone)] +pub struct LayoutIter<'a, 'b> { + font: &'b Font<'a>, + chars: core::str::Chars<'b>, + caret: f32, + scale: Scale, + start: Point<f32>, + last_glyph: Option<GlyphId>, +} +impl<'a, 'b> Iterator for LayoutIter<'a, 'b> { + type Item = PositionedGlyph<'a>; + fn next(&mut self) -> Option<PositionedGlyph<'a>> { + self.chars.next().map(|c| { + let g = self.font.glyph(c).scaled(self.scale); + if let Some(last) = self.last_glyph { + self.caret += self.font.pair_kerning(self.scale, last, g.id()); + } + let g = g.positioned(point(self.start.x + self.caret, self.start.y)); + self.caret += g.sg.h_metrics().advance_width; + self.last_glyph = Some(g.id()); + g + }) + } +} +impl<'a> Glyph<'a> { + fn new(inner: GlyphInner<'a>) -> Glyph<'a> { + Glyph { inner } + } + /// The font to which this glyph belongs. If the glyph is a standalone glyph + /// that owns its resources, it no longer has a reference to the font which + /// it was created from (using `standalone()`). In which case, `None` is + /// returned. + pub fn font(&self) -> Option<&Font<'a>> { + match self.inner { + GlyphInner::Proxy(ref f, _) => Some(f), + GlyphInner::Shared(_) => None, + } + } + /// The glyph identifier for this glyph. + pub fn id(&self) -> GlyphId { + match self.inner { + GlyphInner::Proxy(_, id) => GlyphId(id), + GlyphInner::Shared(ref data) => GlyphId(data.id), + } + } + /// Augments this glyph with scaling information, making methods that depend + /// on the scale of the glyph available. + pub fn scaled(self, scale: Scale) -> ScaledGlyph<'a> { + let (scale_x, scale_y) = match self.inner { + GlyphInner::Proxy(ref font, _) => { + let scale_y = font.info.scale_for_pixel_height(scale.y); + let scale_x = scale_y * scale.x / scale.y; + (scale_x, scale_y) + } + GlyphInner::Shared(ref data) => { + let scale_y = data.scale_for_1_pixel * scale.y; + let scale_x = scale_y * scale.x / scale.y; + (scale_x, scale_y) + } + }; + ScaledGlyph { + g: self, + api_scale: scale, + scale: vector(scale_x, scale_y), + } + } + /// Turns a `Glyph<'a>` into a `Glyph<'static>`. This produces a glyph that + /// owns its resources, extracted from the font. This glyph can outlive the + /// font that it comes from. + /// + /// Calling `standalone()` on a standalone glyph shares the resources, and + /// is equivalent to `clone()`. + pub fn standalone(&self) -> Glyph<'static> { + match self.inner { + GlyphInner::Proxy(ref font, id) => { + Glyph::new(GlyphInner::Shared(Arc::new(SharedGlyphData { + id, + scale_for_1_pixel: font.info.scale_for_pixel_height(1.0), + unit_h_metrics: { + let hm = font.info.get_glyph_h_metrics(id); + HMetrics { + advance_width: hm.advance_width as f32, + left_side_bearing: hm.left_side_bearing as f32, + } + }, + extents: font.info.get_glyph_box(id).map(|bb| Rect { + min: point(bb.x0 as i32, -(bb.y1 as i32)), + max: point(bb.x1 as i32, -(bb.y0 as i32)), + }), + shape: font.info.get_glyph_shape(id), + }))) + } + GlyphInner::Shared(ref data) => Glyph::new(GlyphInner::Shared(data.clone())), + } + } + /// Get the data from this glyph (such as width, extents, vertices, etc.). + /// Only possible if the glyph is a shared glyph. + pub fn get_data(&self) -> Option<Arc<SharedGlyphData>> { + match self.inner { + GlyphInner::Proxy(..) => None, + GlyphInner::Shared(ref s) => Some(s.clone()), + } + } +} +/// Part of a `Contour`, either a `Line` or a `Curve`. +#[derive(Copy, Clone, Debug)] +pub enum Segment { + Line(Line), + Curve(Curve), +} +/// A closed loop consisting of a sequence of `Segment`s. +#[derive(Clone, Debug)] +pub struct Contour { + pub segments: Vec<Segment>, +} +impl<'a> ScaledGlyph<'a> { + /// The glyph identifier for this glyph. + pub fn id(&self) -> GlyphId { + self.g.id() + } + /// The font to which this glyph belongs. If the glyph is a standalone glyph + /// that owns its resources, it no longer has a reference to the font which + /// it was created from (using `standalone()`). In which case, `None` is + /// returned. + pub fn font(&self) -> Option<&Font<'a>> { + self.g.font() + } + /// A reference to this glyph without the scaling + pub fn into_unscaled(self) -> Glyph<'a> { + self.g + } + /// Removes the scaling from this glyph + pub fn unscaled(&self) -> &Glyph<'a> { + &self.g + } + /// Augments this glyph with positioning information, making methods that + /// depend on the position of the glyph available. + pub fn positioned(self, p: Point<f32>) -> PositionedGlyph<'a> { + let bb = self.pixel_bounds_at(p); + PositionedGlyph { + sg: self, + position: p, + bb, + } + } + pub fn scale(&self) -> Scale { + self.api_scale + } + /// Retrieves the "horizontal metrics" of this glyph. See `HMetrics` for + /// more detail. + pub fn h_metrics(&self) -> HMetrics { + match self.g.inner { + GlyphInner::Proxy(ref font, id) => { + let hm = font.info.get_glyph_h_metrics(id); + HMetrics { + advance_width: hm.advance_width as f32 * self.scale.x, + left_side_bearing: hm.left_side_bearing as f32 * self.scale.x, + } + } + GlyphInner::Shared(ref data) => HMetrics { + advance_width: data.unit_h_metrics.advance_width * self.scale.x, + left_side_bearing: data.unit_h_metrics.left_side_bearing * self.scale.y, + }, + } + } + fn shape_with_offset(&self, offset: Point<f32>) -> Option<Vec<Contour>> { + use core::mem::replace; + use stb_truetype::VertexType; + match self.g.inner { + GlyphInner::Proxy(ref font, id) => font.info.get_glyph_shape(id), + GlyphInner::Shared(ref data) => data.shape.clone(), + } + .map(|shape| { + let mut result = Vec::new(); + let mut current = Vec::new(); + let mut last = point(0.0, 0.0); + for v in shape { + let end = point( + v.x as f32 * self.scale.x + offset.x, + v.y as f32 * self.scale.y + offset.y, + ); + match v.vertex_type() { + VertexType::MoveTo if !current.is_empty() => result.push(Contour { + segments: replace(&mut current, Vec::new()), + }), + VertexType::LineTo => current.push(Segment::Line(Line { p: [last, end] })), + VertexType::CurveTo => { + let control = point( + v.cx as f32 * self.scale.x + offset.x, + v.cy as f32 * self.scale.y + offset.y, + ); + current.push(Segment::Curve(Curve { + p: [last, control, end], + })) + } + _ => (), + } + last = end; + } + if !current.is_empty() { + result.push(Contour { + segments: replace(&mut current, Vec::new()), + }); + } + result + }) + } + /// Produces a list of the contours that make up the shape of this glyph. + /// Each contour consists of a sequence of segments. Each segment is either + /// a straight `Line` or a `Curve`. + /// + /// The winding of the produced contours is clockwise for closed shapes, + /// anticlockwise for holes. + pub fn shape(&self) -> Option<Vec<Contour>> { + self.shape_with_offset(point(0.0, 0.0)) + } + /// The bounding box of the shape of this glyph, not to be confused with + /// `pixel_bounding_box`, the conservative pixel-boundary bounding box. The + /// coordinates are relative to the glyph's origin. + pub fn exact_bounding_box(&self) -> Option<Rect<f32>> { + match self.g.inner { + GlyphInner::Proxy(ref font, id) => font.info.get_glyph_box(id).map(|bb| Rect { + min: point(bb.x0 as f32 * self.scale.x, -bb.y1 as f32 * self.scale.y), + max: point(bb.x1 as f32 * self.scale.x, -bb.y0 as f32 * self.scale.y), + }), + GlyphInner::Shared(ref data) => data.extents.map(|bb| Rect { + min: point( + bb.min.x as f32 * self.scale.x, + bb.min.y as f32 * self.scale.y, + ), + max: point( + bb.max.x as f32 * self.scale.x, + bb.max.y as f32 * self.scale.y, + ), + }), + } + } + /// Constructs a glyph that owns its data from this glyph. This is similar + /// to `Glyph::standalone`. See that function for more details. + pub fn standalone(&self) -> ScaledGlyph<'static> { + ScaledGlyph { + g: self.g.standalone(), + api_scale: self.api_scale, + scale: self.scale, + } + } + + #[inline] + fn pixel_bounds_at(&self, p: Point<f32>) -> Option<Rect<i32>> { + // Use subpixel fraction in floor/ceil rounding to elimate rounding error + // from identical subpixel positions + let (x_trunc, x_fract) = (p.x.trunc() as i32, p.x.fract()); + let (y_trunc, y_fract) = (p.y.trunc() as i32, p.y.fract()); + + match self.g.inner { + GlyphInner::Proxy(ref font, id) => font + .info + .get_glyph_bitmap_box_subpixel(id, self.scale.x, self.scale.y, x_fract, y_fract) + .map(|bb| Rect { + min: point(x_trunc + bb.x0, y_trunc + bb.y0), + max: point(x_trunc + bb.x1, y_trunc + bb.y1), + }), + GlyphInner::Shared(ref data) => data.extents.map(|bb| Rect { + min: point( + (bb.min.x as f32 * self.scale.x + x_fract).floor() as i32 + x_trunc, + (bb.min.y as f32 * self.scale.y + y_fract).floor() as i32 + y_trunc, + ), + max: point( + (bb.max.x as f32 * self.scale.x + x_fract).ceil() as i32 + x_trunc, + (bb.max.y as f32 * self.scale.y + y_fract).ceil() as i32 + y_trunc, + ), + }), + } + } +} + +impl<'a> PositionedGlyph<'a> { + /// The glyph identifier for this glyph. + pub fn id(&self) -> GlyphId { + self.sg.id() + } + /// The font to which this glyph belongs. If the glyph is a standalone glyph + /// that owns its resources, it no longer has a reference to the font which + /// it was created from (using `standalone()`). In which case, `None` is + /// returned. + pub fn font(&self) -> Option<&Font<'a>> { + self.sg.font() + } + /// A reference to this glyph without positioning + pub fn unpositioned(&self) -> &ScaledGlyph<'a> { + &self.sg + } + /// Removes the positioning from this glyph + pub fn into_unpositioned(self) -> ScaledGlyph<'a> { + self.sg + } + /// The conservative pixel-boundary bounding box for this glyph. This is the + /// smallest rectangle aligned to pixel boundaries that encloses the shape + /// of this glyph at this position. Note that the origin of the glyph, at + /// pixel-space coordinates (0, 0), is at the top left of the bounding box. + pub fn pixel_bounding_box(&self) -> Option<Rect<i32>> { + self.bb + } + /// Similar to `ScaledGlyph::shape()`, but with the position of the glyph + /// taken into account. + pub fn shape(&self) -> Option<Vec<Contour>> { + self.sg.shape_with_offset(self.position) + } + pub fn scale(&self) -> Scale { + self.sg.api_scale + } + pub fn position(&self) -> Point<f32> { + self.position + } + /// Rasterises this glyph. For each pixel in the rect given by + /// `pixel_bounding_box()`, `o` is called: + /// + /// ```ignore + /// o(x, y, v) + /// ``` + /// + /// where `x` and `y` are the coordinates of the pixel relative to the `min` + /// coordinates of the bounding box, and `v` is the analytically calculated + /// coverage of the pixel by the shape of the glyph. Calls to `o` proceed in + /// horizontal scanline order, similar to this pseudo-code: + /// + /// ```ignore + /// let bb = glyph.pixel_bounding_box(); + /// for y in 0..bb.height() { + /// for x in 0..bb.width() { + /// o(x, y, calc_coverage(&glyph, x, y)); + /// } + /// } + /// ``` + pub fn draw<O: FnMut(u32, u32, f32)>(&self, o: O) { + use stb_truetype::VertexType; + let shape = match self.sg.g.inner { + GlyphInner::Proxy(ref font, id) => { + font.info.get_glyph_shape(id).unwrap_or_else(Vec::new) + } + GlyphInner::Shared(ref data) => data.shape.clone().unwrap_or_else(Vec::new), + }; + let bb = if let Some(bb) = self.bb.as_ref() { + bb + } else { + return; + }; + let offset = vector(bb.min.x as f32, bb.min.y as f32); + let mut lines = Vec::new(); + let mut curves = Vec::new(); + let mut last = point(0.0, 0.0); + for v in shape { + let end = point( + v.x as f32 * self.sg.scale.x + self.position.x, + -v.y as f32 * self.sg.scale.y + self.position.y, + ) - offset; + match v.vertex_type() { + VertexType::LineTo => lines.push(Line { p: [last, end] }), + VertexType::CurveTo => { + let control = point( + v.cx as f32 * self.sg.scale.x + self.position.x, + -v.cy as f32 * self.sg.scale.y + self.position.y, + ) - offset; + curves.push(Curve { + p: [last, control, end], + }) + } + VertexType::MoveTo => {} + } + last = end; + } + rasterizer::rasterize( + &lines, + &curves, + (bb.max.x - bb.min.x) as u32, + (bb.max.y - bb.min.y) as u32, + o, + ); + } + /// Constructs a glyph that owns its data from this glyph. This is similar + /// to `Glyph::standalone`. See that function for more details. + pub fn standalone(&self) -> PositionedGlyph<'static> { + PositionedGlyph { + sg: self.sg.standalone(), + bb: self.bb, + position: self.position, + } + } + + /// Resets positioning information and recalculates the pixel bounding box + pub fn set_position(&mut self, p: Point<f32>) { + let p_diff = p - self.position; + if relative_eq!(p_diff.x.fract(), 0.0) && relative_eq!(p_diff.y.fract(), 0.0) { + if let Some(bb) = self.bb.as_mut() { + let rounded_diff = vector(p_diff.x.round() as i32, p_diff.y.round() as i32); + bb.min = bb.min + rounded_diff; + bb.max = bb.max + rounded_diff; + } + } else { + self.bb = self.sg.pixel_bounds_at(p); + } + self.position = p; + } +} + +/// The type for errors returned by rusttype. +#[derive(Debug)] +pub enum Error { + /// Font data presented to rusttype is not in a format that the library + /// recognizes. + UnrecognizedFormat, + + /// Font data presented to rusttype was ill-formed (lacking necessary + /// tables, for example). + IllFormed, + + /// The caller tried to access the `i`'th font from a `FontCollection`, but + /// the collection doesn't contain that many fonts. + CollectionIndexOutOfBounds, + + /// The caller tried to convert a `FontCollection` into a font via + /// `into_font`, but the `FontCollection` contains more than one font. + CollectionContainsMultipleFonts, +} + +impl Error { + fn description(&self) -> &str { + use self::Error::*; + match *self { + UnrecognizedFormat => "Font data in unrecognized format", + IllFormed => "Font data is ill-formed", + CollectionIndexOutOfBounds => "Font collection has no font at the given index", + CollectionContainsMultipleFonts => { + "Attempted to convert collection into a font, \ + but collection contais more than one font" + } + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> core::result::Result<(), fmt::Error> { + f.write_str(self.description()) + } +} + +#[cfg(feature = "std")] +impl std::error::Error for Error { + fn description(&self) -> &str { + self.description() + } +} + +#[cfg(feature = "std")] +impl std::convert::From<Error> for std::io::Error { + fn from(error: Error) -> Self { + std::io::Error::new(std::io::ErrorKind::Other, error) + } +} diff --git a/third_party/cargo/vendor/rusttype-0.8.2/src/nostd_float.rs b/third_party/cargo/vendor/rusttype-0.8.2/src/nostd_float.rs new file mode 100644 index 0000000..04c7a1c --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/src/nostd_float.rs @@ -0,0 +1,40 @@ +pub(crate) trait FloatExt { + fn floor(self) -> Self; + fn ceil(self) -> Self; + fn sqrt(self) -> Self; + fn fract(self) -> Self; + fn trunc(self) -> Self; + fn round(self) -> Self; + fn abs(self) -> Self; +} + +impl FloatExt for f32 { + #[inline] + fn floor(self) -> Self { + libm::floorf(self) + } + #[inline] + fn ceil(self) -> Self { + libm::ceilf(self) + } + #[inline] + fn sqrt(self) -> Self { + libm::sqrtf(self) + } + #[inline] + fn fract(self) -> Self { + self - self.trunc() + } + #[inline] + fn trunc(self) -> Self { + libm::truncf(self) + } + #[inline] + fn round(self) -> Self { + libm::roundf(self) + } + #[inline] + fn abs(self) -> Self { + libm::fabsf(self) + } +} diff --git a/third_party/cargo/vendor/rusttype-0.8.2/src/rasterizer.rs b/third_party/cargo/vendor/rusttype-0.8.2/src/rasterizer.rs new file mode 100644 index 0000000..275709b --- /dev/null +++ b/third_party/cargo/vendor/rusttype-0.8.2/src/rasterizer.rs @@ -0,0 +1,396 @@ +use crate::geometry::*; +use approx::relative_eq; +use ordered_float::OrderedFloat; + +use alloc::vec::Vec; +#[cfg(all(feature = "libm-math", not(feature = "std")))] +use crate::nostd_float::FloatExt; + +trait SliceUp: Sized { + type PerSlice: Iterator<Item = Self>; + type Out: Iterator<Item = Self::PerSlice>; + fn slice_up_x(&self, planes: PlaneSet) -> Self::Out; + fn slice_up_y(&self, planes: PlaneSet) -> Self::Out; +} + +type LineIter = core::option::IntoIter<Line>; + +#[derive(Debug)] +struct LineSliceIter { + l: Line, + m: f32, + c: f32, + planes: PlaneSet, + i: usize, +} + +impl Iterator for LineSliceIter { + type Item = LineIter; + fn next(&mut self) -> Option<LineIter> { + if self.i >= self.planes.count { + return None; + } + if self.m == 0.0 { + self.i += 1; + return Some(Some(self.l).into_iter()); + } + let lower = self.i as f32; + let upper = lower + 1.0; + let lower_d = self.planes.start + self.planes.step * lower; + let upper_d = self.planes.start + self.planes.step * upper; + let mut lower_t = (lower_d - self.c) / self.m; + let mut upper_t = (upper_d - self.c) / self.m; + lower_t = lower_t.max(0.0).min(1.0); + upper_t = upper_t.max(0.0).min(1.0); + if self.m < 0.0 { + core::mem::swap(&mut lower_t, &mut upper_t); + } + self.i += 1; + if !relative_eq!(lower_t, upper_t) { + let p = &self.l.p; + let v = p[1] - p[0]; + Some( + Some(Line { + p: [p[0] + v * lower_t, p[0] + v * upper_t], + }) + .into_iter(), + ) + } else { + Some(None.into_iter()) + } + } +} + +impl SliceUp for Line { + type PerSlice = LineIter; + type Out = LineSliceIter; + fn slice_up_x(&self, planes: PlaneSet) -> LineSliceIter { + let p = &self.p; + LineSliceIter { + l: *self, + planes, + i: 0, + m: p[1].x - p[0].x, + c: p[0].x, + } + } + fn slice_up_y(&self, planes: PlaneSet) -> LineSliceIter { + let p = &self.p; + LineSliceIter { + l: *self, + planes, + i: 0, + m: p[1].y - p[0].y, + c: p[0].y, + } + } +} + +type CurveIter = arrayvec::IntoIter<[Curve; 2]>; + +struct CurveSliceIter { + curve: Curve, + planes: PlaneSet, + i: usize, + a: f32, + b: f32, + c_shift: f32, +} + +impl Iterator for CurveSliceIter { + type Item = CurveIter; + fn next(&mut self) -> Option<Self::Item> { + use crate::geometry::solve_quadratic_real as solve; + use crate::geometry::RealQuadraticSolution as RQS; + use arrayvec::ArrayVec; + if self.i >= self.planes.count { + return None; + } + let lower = self.i as f32; + self.i += 1; + let upper = lower + self.planes.step; + let lower_d = self.planes.start + self.planes.step * lower; + let upper_d = self.planes.start + self.planes.step * upper; + let l_sol = solve(self.a, self.b, self.c_shift - lower_d); + let u_sol = solve(self.a, self.b, self.c_shift - upper_d); + let mut result = ArrayVec::<[Curve; 2]>::new(); + match (l_sol.in_order(), u_sol.in_order()) { + (RQS::Two(a, b), RQS::Two(c, d)) => { + // Two pieces + let (a, b, c, d) = if self.a > 0.0 { + (c, a, b, d) + } else { + (a, c, d, b) + }; + let (a, b, c, d) = ( + a.min(1.0).max(0.0), + b.min(1.0).max(0.0), + c.min(1.0).max(0.0), + d.min(1.0).max(0.0), + ); + if !relative_eq!(a, b) { + result.push(self.curve.cut_from_to(a, b)); + } + if !relative_eq!(c, d) { + result.push(self.curve.cut_from_to(c, d)); + } + } + (RQS::Two(a, b), RQS::None) + | (RQS::Two(a, b), RQS::Touch(_)) + | (RQS::None, RQS::Two(a, b)) + | (RQS::Touch(_), RQS::Two(a, b)) + | (RQS::One(a), RQS::One(b)) => { + // One piece + let (a, b) = if a > b { (b, a) } else { (a, b) }; + let a = a.min(1.0).max(0.0); + let b = b.min(1.0).max(0.0); + if !relative_eq!(a, b) { + result.push(self.curve.cut_from_to(a, b)); + } + } + (RQS::All, RQS::None) | (RQS::None, RQS::All) => { + // coincident with one plane + result.push(self.curve); + } + (RQS::None, RQS::None) => { + if self.a == 0.0 + && self.b == 0.0 + && self.c_shift >= lower_d + && self.c_shift <= upper_d + { + // parallel to planes, inbetween + result.push(self.curve); + } + } + _ => unreachable!(), // impossible + } + Some(result.into_iter()) + } +} + +#[derive(Debug)] +struct PlaneSet { + start: f32, + step: f32, + count: usize, +} + +impl SliceUp for Curve { + type PerSlice = CurveIter; + type Out = CurveSliceIter; + fn slice_up_x(&self, planes: PlaneSet) -> CurveSliceIter { + let p = &self.p; + CurveSliceIter { + curve: *self, + planes, + i: 0, + a: p[0].x - 2.0 * p[1].x + p[2].x, + b: 2.0 * (p[1].x - p[0].x), + c_shift: p[0].x, + } + } + fn slice_up_y(&self, planes: PlaneSet) -> CurveSliceIter { + let p = &self.p; + CurveSliceIter { + curve: *self, + planes, + i: 0, + a: p[0].y - 2.0 * p[1].y + p[2].y, + b: 2.0 * (p[1].y - p[0].y), + c_shift: p[0].y, + } + } +} + +pub fn rasterize<O: FnMut(u32, u32, f32)>( + lines: &[Line], + curves: &[Curve], + width: u32, + height: u32, + mut output: O, +) { + let mut lines: Vec<_> = lines.iter().map(|&l| (l, l.bounding_box())).collect(); + lines.sort_by_key(|&(_, ref a)| OrderedFloat(a.min.y)); + let mut curves: Vec<_> = curves.iter().map(|&c| (c, c.bounding_box())).collect(); + curves.sort_by_key(|&(_, ref a)| OrderedFloat(a.min.y)); + let mut y = 0; + let mut next_line = 0; + let mut next_curve = 0; + let mut active_lines_y = Vec::new(); + let mut active_curves_y = Vec::new(); + let mut active_lines_x = Vec::new(); + let mut active_curves_x = Vec::new(); + let mut scanline_lines = Vec::new(); + let mut lines_to_remove = Vec::new(); + let mut scanline_curves = Vec::new(); + let mut curves_to_remove = Vec::new(); + while y < height + && (next_line != lines.len() + || next_curve != curves.len() + || !active_lines_y.is_empty() + || !active_curves_y.is_empty()) + { + let lower = y as f32; + let upper = (y + 1) as f32; + // Add newly active segments + for &(ref line, ref bb) in lines[next_line..].iter().take_while(|p| p.1.min.y < upper) { + let planes = PlaneSet { + start: lower, + step: 1.0, + count: (bb.max.y.ceil() - lower).max(1.0) as usize, + }; + active_lines_y.push(line.slice_up_y(planes)); + next_line += 1; + } + for &(ref curve, ref bb) in curves[next_curve..] + .iter() + .take_while(|p| p.1.min.y < upper) + { + let planes = PlaneSet { + start: lower, + step: 1.0, + count: (bb.max.y.ceil() - lower).max(1.0) as usize, + }; + active_curves_y.push(curve.slice_up_y(planes)); + next_curve += 1; + } + // get y sliced segments for this scanline + scanline_lines.clear(); + scanline_curves.clear(); + + for (k, itr) in active_lines_y.iter_mut().enumerate() { + if let Some(itr) = itr.next() { + for line in itr { + scanline_lines.push((line, line.x_bounds())) + } + } else { + lines_to_remove.push(k); + } + } + for (k, itr) in active_curves_y.iter_mut().enumerate() { + if let Some(itr) = itr.next() { + for curve in itr { + scanline_curves.push((curve, curve.x_bounds())) + } + } else { + curves_to_remove.push(k); + } + } + // remove deactivated segments + for k in lines_to_remove.drain(..).rev() { + active_lines_y.swap_remove(k); + } + for k in curves_to_remove.drain(..).rev() { + active_curves_y.swap_remove(k); + } + // sort scanline for traversal + scanline_lines.sort_by_key(|a| OrderedFloat((a.1).0)); + scanline_curves.sort_by_key(|a| OrderedFloat((a.1).0)); + // Iterate through x, slice scanline segments into each cell. + // Evaluate, accumulate and output. + { + let mut next_line = 0; + let mut next_curve = 0; + let mut x = 0; + let mut acc = 0.0; + active_lines_x.clear(); + active_curves_x.clear(); + while x < width + && (next_line != scanline_lines.len() + || next_curve != scanline_curves.len() + || !active_lines_x.is_empty() + || !active_curves_x.is_empty()) + { + let offset = vector(x as f32, y as f32); + let lower = x as f32; + let upper = (x + 1) as f32; + //add newly active segments + for &(ref line, (_, ref max)) in scanline_lines[next_line..] + .iter() + .take_while(|p| (p.1).0 < upper) + { + let planes = PlaneSet { + start: lower, + step: 1.0, + count: (max.ceil() - lower).max(1.0) as usize, + }; + active_lines_x.push(line.slice_up_x(planes)); + next_line += 1; + } + for &(ref curve, (_, ref max)) in scanline_curves[next_curve..] + .iter() + .take_while(|p| (p.1).0 < upper) + { + let planes = PlaneSet { + start: lower, + step: 1.0, + count: (max.ceil() - lower).max(1.0) as usize, + }; + active_curves_x.push(curve.slice_up_x(planes)); + next_curve += 1; + } + //process x sliced segments for this pixel + let mut pixel_value = acc; + let mut pixel_acc = 0.0; + for (k, itr) in active_lines_x.iter_mut().enumerate() { + if let Some(itr) = itr.next() { + for mut line in itr { + let p = &mut line.p; + p[0] = p[0] - offset; + p[1] = p[1] - offset; + + let a = p[0].y - p[1].y; + let v = (1.0 - (p[0].x + p[1].x) * 0.5) * a; + pixel_value += v; + pixel_acc += a; + } + } else { + lines_to_remove.push(k); + } + } + for (k, itr) in active_curves_x.iter_mut().enumerate() { + if let Some(itr) = itr.next() { + for mut curve in itr { + let p = &mut curve.p; + p[0] = p[0] - offset; + p[1] = p[1] - offset; + p[2] = p[2] - offset; + let a = p[0].y - p[2].y; + let b = p[0].y - p[1].y; + let c = p[1].y - p[2].y; + let v = (b * (6.0 - 3.0 * p[0].x - 2.0 * p[1].x - p[2].x) + + c * (6.0 - p[0].x - 2.0 * p[1].x - 3.0 * p[2].x)) + / 6.0; + pixel_value += v; + pixel_acc += a; + } + } else { + curves_to_remove.push(k); + } + } + //output + output(x, y, pixel_value.abs()); + acc += pixel_acc; + // remove deactivated segments + for k in lines_to_remove.drain(..).rev() { + active_lines_x.swap_remove(k); + } + for k in curves_to_remove.drain(..).rev() { + active_curves_x.swap_remove(k); + } + x += 1; + } + // fill remaining pixels + for x in x..width { + output(x, y, acc.abs()); + } + } + y += 1; + } + // fill remaining scanlines with 0.0 + for y in y..height { + for x in 0..width { + output(x, y, 0.0); + } + } +} diff --git a/third_party/cargo/vendor/same-file-1.0.6/.cargo-checksum.json b/third_party/cargo/vendor/same-file-1.0.6/.cargo-checksum.json new file mode 100644 index 0000000..0d13a57 --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"COPYING":"01c266bced4a434da0051174d6bee16a4c82cf634e2679b6155d40d75012390f","Cargo.toml":"991f8df8fa5a259801900a56908cf21a66c5cf7b238bc81ba9bdf348e233252e","LICENSE-MIT":"cb3c929a05e6cbc9de9ab06a4c57eeb60ca8c724bef6c138c87d3a577e27aa14","README.md":"70c109d9c89b4479016142f2a4ad6963b6fe5793bcdd997add3d3af3d2baf36b","UNLICENSE":"7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c","examples/is_same_file.rs":"7b3eeb27a15051667d97615fc7a2339cbff5630df3bca6ac19ab81d5be22f329","examples/is_stderr.rs":"e1c5d1a0f36d7aa0020bb5b87c2f45c7176033f03c52cf395be55dd8debfc413","rustfmt.toml":"1ca600239a27401c4a43f363cf3f38183a212affc1f31bff3ae93234bbaec228","src/lib.rs":"b22c2f0b5cad2248f16f4f42add52b2dc0c627631f71ee67a8c38fe305048f85","src/unix.rs":"69abed9fade151247696c6d4a442ef299554f3722e23a2d08053598a52a27d62","src/unknown.rs":"bfde4e9ac88f500c0ccb69165383682ddd24bf7d7ddaf5859426e1fd4b2f9359","src/win.rs":"94f912cc3734f60608d0ee2b0c664afb65fc96e5b0b223a53565fb8998c03fa3"},"package":"93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"} \ No newline at end of file diff --git a/third_party/cargo/vendor/same-file-1.0.6/BUILD b/third_party/cargo/vendor/same-file-1.0.6/BUILD new file mode 100644 index 0000000..56be299 --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/BUILD @@ -0,0 +1,45 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" + "unencumbered", # "Unlicense" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "is_same_file" with type "example" omitted +# Unsupported target "is_stderr" with type "example" omitted + +rust_library( + name = "same_file", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.0.6", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/same-file-1.0.6/COPYING b/third_party/cargo/vendor/same-file-1.0.6/COPYING new file mode 100644 index 0000000..bb9c20a --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/third_party/cargo/vendor/same-file-1.0.6/Cargo.toml b/third_party/cargo/vendor/same-file-1.0.6/Cargo.toml new file mode 100644 index 0000000..4f66820 --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/Cargo.toml @@ -0,0 +1,29 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "same-file" +version = "1.0.6" +authors = ["Andrew Gallant <jamslam@gmail.com>"] +exclude = ["/.github"] +description = "A simple crate for determining whether two file paths point to the same file.\n" +homepage = "https://github.com/BurntSushi/same-file" +documentation = "https://docs.rs/same-file" +readme = "README.md" +keywords = ["same", "file", "equal", "inode"] +license = "Unlicense/MIT" +repository = "https://github.com/BurntSushi/same-file" +[dev-dependencies.doc-comment] +version = "0.3" +[target."cfg(windows)".dependencies.winapi-util] +version = "0.1.1" diff --git a/third_party/cargo/vendor/same-file-1.0.6/LICENSE-MIT b/third_party/cargo/vendor/same-file-1.0.6/LICENSE-MIT new file mode 100644 index 0000000..3303149 --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/third_party/cargo/vendor/same-file-1.0.6/README.md b/third_party/cargo/vendor/same-file-1.0.6/README.md new file mode 100644 index 0000000..2c45fdf --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/README.md @@ -0,0 +1,49 @@ +same-file +========= +A safe and cross platform crate to determine whether two files or directories +are the same. + +[![Build status](https://github.com/BurntSushi/same-file/workflows/ci/badge.svg)](https://github.com/BurntSushi/same-file/actions) +[![](http://meritbadge.herokuapp.com/same-file)](https://crates.io/crates/same-file) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + +### Documentation + +https://docs.rs/same-file + +### Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +same-file = "1" +``` + +### Example + +The simplest use of this crate is to use the `is_same_file` function, which +takes two file paths and returns true if and only if they refer to the same +file: + +```rust,no_run +use same_file::is_same_file; + +fn main() { + assert!(is_same_file("/bin/sh", "/usr/bin/sh").unwrap()); +} +``` + +### Minimum Rust version policy + +This crate's minimum supported `rustc` version is `1.34.0`. + +The current policy is that the minimum Rust version required to use this crate +can be increased in minor version updates. For example, if `crate 1.0` requires +Rust 1.20.0, then `crate 1.0.z` for all values of `z` will also require Rust +1.20.0 or newer. However, `crate 1.y` for `y > 0` may require a newer minimum +version of Rust. + +In general, this crate will be conservative with respect to the minimum +supported version of Rust. diff --git a/third_party/cargo/vendor/same-file-1.0.6/UNLICENSE b/third_party/cargo/vendor/same-file-1.0.6/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <http://unlicense.org/> diff --git a/third_party/cargo/vendor/same-file-1.0.6/examples/is_same_file.rs b/third_party/cargo/vendor/same-file-1.0.6/examples/is_same_file.rs new file mode 100644 index 0000000..6ba948a --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/examples/is_same_file.rs @@ -0,0 +1,11 @@ +use same_file::is_same_file; +use std::io; + +fn try_main() -> Result<(), io::Error> { + assert!(is_same_file("/bin/sh", "/usr/bin/sh")?); + Ok(()) +} + +fn main() { + try_main().unwrap(); +} diff --git a/third_party/cargo/vendor/same-file-1.0.6/examples/is_stderr.rs b/third_party/cargo/vendor/same-file-1.0.6/examples/is_stderr.rs new file mode 100644 index 0000000..1078695 --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/examples/is_stderr.rs @@ -0,0 +1,31 @@ +use std::io; +use std::process; + +use same_file::Handle; + +fn main() { + if let Err(err) = run() { + println!("{}", err); + process::exit(1); + } +} + +fn run() -> io::Result<()> { + // Run with `cargo run --example is_stderr 2> examples/stderr` to see + // interesting output. + let candidates = &[ + "examples/is_same_file.rs", + "examples/is_stderr.rs", + "examples/stderr", + ]; + let stderr_handle = Handle::stderr()?; + for candidate in candidates { + let handle = Handle::from_path(candidate)?; + if stderr_handle == handle { + println!("{:?} is stderr!", candidate); + } else { + println!("{:?} is NOT stderr!", candidate); + } + } + Ok(()) +} diff --git a/third_party/cargo/vendor/same-file-1.0.6/rustfmt.toml b/third_party/cargo/vendor/same-file-1.0.6/rustfmt.toml new file mode 100644 index 0000000..aa37a21 --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/rustfmt.toml @@ -0,0 +1,2 @@ +max_width = 79 +use_small_heuristics = "max" diff --git a/third_party/cargo/vendor/same-file-1.0.6/src/lib.rs b/third_party/cargo/vendor/same-file-1.0.6/src/lib.rs new file mode 100644 index 0000000..ed7ccf5 --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/src/lib.rs @@ -0,0 +1,572 @@ +/*! +This crate provides a safe and simple **cross platform** way to determine +whether two file paths refer to the same file or directory. + +Most uses of this crate should be limited to the top-level [`is_same_file`] +function, which takes two file paths and returns true if they refer to the +same file or directory: + +```rust,no_run +# use std::error::Error; +use same_file::is_same_file; + +# fn try_main() -> Result<(), Box<Error>> { +assert!(is_same_file("/bin/sh", "/usr/bin/sh")?); +# Ok(()) +# } +# +# fn main() { +# try_main().unwrap(); +# } +``` + +Additionally, this crate provides a [`Handle`] type that permits a more efficient +equality check depending on your access pattern. For example, if one wanted to +check whether any path in a list of paths corresponded to the process' stdout +handle, then one could build a handle once for stdout. The equality check for +each file in the list then only requires one stat call instead of two. The code +might look like this: + +```rust,no_run +# use std::error::Error; +use same_file::Handle; + +# fn try_main() -> Result<(), Box<Error>> { +let candidates = &[ + "examples/is_same_file.rs", + "examples/is_stderr.rs", + "examples/stderr", +]; +let stdout_handle = Handle::stdout()?; +for candidate in candidates { + let handle = Handle::from_path(candidate)?; + if stdout_handle == handle { + println!("{:?} is stdout!", candidate); + } else { + println!("{:?} is NOT stdout!", candidate); + } +} +# Ok(()) +# } +# +# fn main() { +# try_main().unwrap(); +# } +``` + +See [`examples/is_stderr.rs`] for a runnable example and compare the output of: + +- `cargo run --example is_stderr 2> examples/stderr` and +- `cargo run --example is_stderr`. + +[`is_same_file`]: fn.is_same_file.html +[`Handle`]: struct.Handle.html +[`examples/is_stderr.rs`]: https://github.com/BurntSushi/same-file/blob/master/examples/is_same_file.rs + +*/ + +#![allow(bare_trait_objects, unknown_lints)] +#![deny(missing_docs)] + +#[cfg(test)] +doc_comment::doctest!("../README.md"); + +use std::fs::File; +use std::io; +use std::path::Path; + +#[cfg(any(target_os = "redox", unix))] +use crate::unix as imp; +#[cfg(not(any(target_os = "redox", unix, windows)))] +use unknown as imp; +#[cfg(windows)] +use win as imp; + +#[cfg(any(target_os = "redox", unix))] +mod unix; +#[cfg(not(any(target_os = "redox", unix, windows)))] +mod unknown; +#[cfg(windows)] +mod win; + +/// A handle to a file that can be tested for equality with other handles. +/// +/// If two files are the same, then any two handles of those files will compare +/// equal. If two files are not the same, then any two handles of those files +/// will compare not-equal. +/// +/// A handle consumes an open file resource as long as it exists. +/// +/// Equality is determined by comparing inode numbers on Unix and a combination +/// of identifier, volume serial, and file size on Windows. Note that it's +/// possible for comparing two handles to produce a false positive on some +/// platforms. Namely, two handles can compare equal even if the two handles +/// *don't* point to the same file. Check the [source] for specific +/// implementation details. +/// +/// [source]: https://github.com/BurntSushi/same-file/tree/master/src +#[derive(Debug, Eq, PartialEq, Hash)] +pub struct Handle(imp::Handle); + +impl Handle { + /// Construct a handle from a path. + /// + /// Note that the underlying [`File`] is opened in read-only mode on all + /// platforms. + /// + /// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html + /// + /// # Errors + /// This method will return an [`io::Error`] if the path cannot + /// be opened, or the file's metadata cannot be obtained. + /// The most common reasons for this are: the path does not + /// exist, or there were not enough permissions. + /// + /// [`io::Error`]: https://doc.rust-lang.org/std/io/struct.Error.html + /// + /// # Examples + /// Check that two paths are not the same file: + /// + /// ```rust,no_run + /// # use std::error::Error; + /// use same_file::Handle; + /// + /// # fn try_main() -> Result<(), Box<Error>> { + /// let source = Handle::from_path("./source")?; + /// let target = Handle::from_path("./target")?; + /// assert_ne!(source, target, "The files are the same."); + /// # Ok(()) + /// # } + /// # + /// # fn main() { + /// # try_main().unwrap(); + /// # } + /// ``` + pub fn from_path<P: AsRef<Path>>(p: P) -> io::Result<Handle> { + imp::Handle::from_path(p).map(Handle) + } + + /// Construct a handle from a file. + /// + /// # Errors + /// This method will return an [`io::Error`] if the metadata for + /// the given [`File`] cannot be obtained. + /// + /// [`io::Error`]: https://doc.rust-lang.org/std/io/struct.Error.html + /// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html + /// + /// # Examples + /// Check that two files are not in fact the same file: + /// + /// ```rust,no_run + /// # use std::error::Error; + /// # use std::fs::File; + /// use same_file::Handle; + /// + /// # fn try_main() -> Result<(), Box<Error>> { + /// let source = File::open("./source")?; + /// let target = File::open("./target")?; + /// + /// assert_ne!( + /// Handle::from_file(source)?, + /// Handle::from_file(target)?, + /// "The files are the same." + /// ); + /// # Ok(()) + /// # } + /// # + /// # fn main() { + /// # try_main().unwrap(); + /// # } + /// ``` + pub fn from_file(file: File) -> io::Result<Handle> { + imp::Handle::from_file(file).map(Handle) + } + + /// Construct a handle from stdin. + /// + /// # Errors + /// This method will return an [`io::Error`] if stdin cannot + /// be opened due to any I/O-related reason. + /// + /// [`io::Error`]: https://doc.rust-lang.org/std/io/struct.Error.html + /// + /// # Examples + /// + /// ```rust + /// # use std::error::Error; + /// use same_file::Handle; + /// + /// # fn try_main() -> Result<(), Box<Error>> { + /// let stdin = Handle::stdin()?; + /// let stdout = Handle::stdout()?; + /// let stderr = Handle::stderr()?; + /// + /// if stdin == stdout { + /// println!("stdin == stdout"); + /// } + /// if stdin == stderr { + /// println!("stdin == stderr"); + /// } + /// if stdout == stderr { + /// println!("stdout == stderr"); + /// } + /// # + /// # Ok(()) + /// # } + /// # + /// # fn main() { + /// # try_main().unwrap(); + /// # } + /// ``` + /// + /// The output differs depending on the platform. + /// + /// On Linux: + /// + /// ```text + /// $ ./example + /// stdin == stdout + /// stdin == stderr + /// stdout == stderr + /// $ ./example > result + /// $ cat result + /// stdin == stderr + /// $ ./example > result 2>&1 + /// $ cat result + /// stdout == stderr + /// ``` + /// + /// Windows: + /// + /// ```text + /// > example + /// > example > result 2>&1 + /// > type result + /// stdout == stderr + /// ``` + pub fn stdin() -> io::Result<Handle> { + imp::Handle::stdin().map(Handle) + } + + /// Construct a handle from stdout. + /// + /// # Errors + /// This method will return an [`io::Error`] if stdout cannot + /// be opened due to any I/O-related reason. + /// + /// [`io::Error`]: https://doc.rust-lang.org/std/io/struct.Error.html + /// + /// # Examples + /// See the example for [`stdin()`]. + /// + /// [`stdin()`]: #method.stdin + pub fn stdout() -> io::Result<Handle> { + imp::Handle::stdout().map(Handle) + } + + /// Construct a handle from stderr. + /// + /// # Errors + /// This method will return an [`io::Error`] if stderr cannot + /// be opened due to any I/O-related reason. + /// + /// [`io::Error`]: https://doc.rust-lang.org/std/io/struct.Error.html + /// + /// # Examples + /// See the example for [`stdin()`]. + /// + /// [`stdin()`]: #method.stdin + pub fn stderr() -> io::Result<Handle> { + imp::Handle::stderr().map(Handle) + } + + /// Return a reference to the underlying file. + /// + /// # Examples + /// Ensure that the target file is not the same as the source one, + /// and copy the data to it: + /// + /// ```rust,no_run + /// # use std::error::Error; + /// use std::io::prelude::*; + /// use std::io::Write; + /// use std::fs::File; + /// use same_file::Handle; + /// + /// # fn try_main() -> Result<(), Box<Error>> { + /// let source = File::open("source")?; + /// let target = File::create("target")?; + /// + /// let source_handle = Handle::from_file(source)?; + /// let mut target_handle = Handle::from_file(target)?; + /// assert_ne!(source_handle, target_handle, "The files are the same."); + /// + /// let mut source = source_handle.as_file(); + /// let target = target_handle.as_file_mut(); + /// + /// let mut buffer = Vec::new(); + /// // data copy is simplified for the purposes of the example + /// source.read_to_end(&mut buffer)?; + /// target.write_all(&buffer)?; + /// # + /// # Ok(()) + /// # } + /// # + /// # fn main() { + /// # try_main().unwrap(); + /// # } + /// ``` + pub fn as_file(&self) -> &File { + self.0.as_file() + } + + /// Return a mutable reference to the underlying file. + /// + /// # Examples + /// See the example for [`as_file()`]. + /// + /// [`as_file()`]: #method.as_file + pub fn as_file_mut(&mut self) -> &mut File { + self.0.as_file_mut() + } + + /// Return the underlying device number of this handle. + /// + /// Note that this only works on unix platforms. + #[cfg(any(target_os = "redox", unix))] + pub fn dev(&self) -> u64 { + self.0.dev() + } + + /// Return the underlying inode number of this handle. + /// + /// Note that this only works on unix platforms. + #[cfg(any(target_os = "redox", unix))] + pub fn ino(&self) -> u64 { + self.0.ino() + } +} + +/// Returns true if the two file paths may correspond to the same file. +/// +/// Note that it's possible for this to produce a false positive on some +/// platforms. Namely, this can return true even if the two file paths *don't* +/// resolve to the same file. +/// # Errors +/// This function will return an [`io::Error`] if any of the two paths cannot +/// be opened. The most common reasons for this are: the path does not exist, +/// or there were not enough permissions. +/// +/// [`io::Error`]: https://doc.rust-lang.org/std/io/struct.Error.html +/// +/// # Example +/// +/// ```rust,no_run +/// use same_file::is_same_file; +/// +/// assert!(is_same_file("./foo", "././foo").unwrap_or(false)); +/// ``` +pub fn is_same_file<P, Q>(path1: P, path2: Q) -> io::Result<bool> +where + P: AsRef<Path>, + Q: AsRef<Path>, +{ + Ok(Handle::from_path(path1)? == Handle::from_path(path2)?) +} + +#[cfg(test)] +mod tests { + use std::env; + use std::error; + use std::fs::{self, File}; + use std::io; + use std::path::{Path, PathBuf}; + use std::result; + + use super::is_same_file; + + type Result<T> = result::Result<T, Box<error::Error + Send + Sync>>; + + /// Create an error from a format!-like syntax. + macro_rules! err { + ($($tt:tt)*) => { + Box::<error::Error + Send + Sync>::from(format!($($tt)*)) + } + } + + /// A simple wrapper for creating a temporary directory that is + /// automatically deleted when it's dropped. + /// + /// We use this in lieu of tempfile because tempfile brings in too many + /// dependencies. + #[derive(Debug)] + struct TempDir(PathBuf); + + impl Drop for TempDir { + fn drop(&mut self) { + fs::remove_dir_all(&self.0).unwrap(); + } + } + + impl TempDir { + /// Create a new empty temporary directory under the system's + /// configured temporary directory. + fn new() -> Result<TempDir> { + #![allow(deprecated)] + + use std::sync::atomic::{ + AtomicUsize, Ordering, ATOMIC_USIZE_INIT, + }; + + static TRIES: usize = 100; + static COUNTER: AtomicUsize = ATOMIC_USIZE_INIT; + + let tmpdir = env::temp_dir(); + for _ in 0..TRIES { + let count = COUNTER.fetch_add(1, Ordering::SeqCst); + let path = tmpdir.join("rust-walkdir").join(count.to_string()); + if path.is_dir() { + continue; + } + fs::create_dir_all(&path).map_err(|e| { + err!("failed to create {}: {}", path.display(), e) + })?; + return Ok(TempDir(path)); + } + Err(err!("failed to create temp dir after {} tries", TRIES)) + } + + /// Return the underlying path to this temporary directory. + fn path(&self) -> &Path { + &self.0 + } + } + + fn tmpdir() -> TempDir { + TempDir::new().unwrap() + } + + #[cfg(unix)] + pub fn soft_link_dir<P: AsRef<Path>, Q: AsRef<Path>>( + src: P, + dst: Q, + ) -> io::Result<()> { + use std::os::unix::fs::symlink; + symlink(src, dst) + } + + #[cfg(unix)] + pub fn soft_link_file<P: AsRef<Path>, Q: AsRef<Path>>( + src: P, + dst: Q, + ) -> io::Result<()> { + soft_link_dir(src, dst) + } + + #[cfg(windows)] + pub fn soft_link_dir<P: AsRef<Path>, Q: AsRef<Path>>( + src: P, + dst: Q, + ) -> io::Result<()> { + use std::os::windows::fs::symlink_dir; + symlink_dir(src, dst) + } + + #[cfg(windows)] + pub fn soft_link_file<P: AsRef<Path>, Q: AsRef<Path>>( + src: P, + dst: Q, + ) -> io::Result<()> { + use std::os::windows::fs::symlink_file; + symlink_file(src, dst) + } + + // These tests are rather uninteresting. The really interesting tests + // would stress the edge cases. On Unix, this might be comparing two files + // on different mount points with the same inode number. On Windows, this + // might be comparing two files whose file indices are the same on file + // systems where such things aren't guaranteed to be unique. + // + // Alas, I don't know how to create those environmental conditions. ---AG + + #[test] + fn same_file_trivial() { + let tdir = tmpdir(); + let dir = tdir.path(); + + File::create(dir.join("a")).unwrap(); + assert!(is_same_file(dir.join("a"), dir.join("a")).unwrap()); + } + + #[test] + fn same_dir_trivial() { + let tdir = tmpdir(); + let dir = tdir.path(); + + fs::create_dir(dir.join("a")).unwrap(); + assert!(is_same_file(dir.join("a"), dir.join("a")).unwrap()); + } + + #[test] + fn not_same_file_trivial() { + let tdir = tmpdir(); + let dir = tdir.path(); + + File::create(dir.join("a")).unwrap(); + File::create(dir.join("b")).unwrap(); + assert!(!is_same_file(dir.join("a"), dir.join("b")).unwrap()); + } + + #[test] + fn not_same_dir_trivial() { + let tdir = tmpdir(); + let dir = tdir.path(); + + fs::create_dir(dir.join("a")).unwrap(); + fs::create_dir(dir.join("b")).unwrap(); + assert!(!is_same_file(dir.join("a"), dir.join("b")).unwrap()); + } + + #[test] + fn same_file_hard() { + let tdir = tmpdir(); + let dir = tdir.path(); + + File::create(dir.join("a")).unwrap(); + fs::hard_link(dir.join("a"), dir.join("alink")).unwrap(); + assert!(is_same_file(dir.join("a"), dir.join("alink")).unwrap()); + } + + #[test] + fn same_file_soft() { + let tdir = tmpdir(); + let dir = tdir.path(); + + File::create(dir.join("a")).unwrap(); + soft_link_file(dir.join("a"), dir.join("alink")).unwrap(); + assert!(is_same_file(dir.join("a"), dir.join("alink")).unwrap()); + } + + #[test] + fn same_dir_soft() { + let tdir = tmpdir(); + let dir = tdir.path(); + + fs::create_dir(dir.join("a")).unwrap(); + soft_link_dir(dir.join("a"), dir.join("alink")).unwrap(); + assert!(is_same_file(dir.join("a"), dir.join("alink")).unwrap()); + } + + #[test] + fn test_send() { + fn assert_send<T: Send>() {} + assert_send::<super::Handle>(); + } + + #[test] + fn test_sync() { + fn assert_sync<T: Sync>() {} + assert_sync::<super::Handle>(); + } +} diff --git a/third_party/cargo/vendor/same-file-1.0.6/src/unix.rs b/third_party/cargo/vendor/same-file-1.0.6/src/unix.rs new file mode 100644 index 0000000..fb3d19f --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/src/unix.rs @@ -0,0 +1,112 @@ +use std::fs::{File, OpenOptions}; +use std::hash::{Hash, Hasher}; +use std::io; +use std::os::unix::fs::MetadataExt; +use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; +use std::path::Path; + +#[derive(Debug)] +pub struct Handle { + file: Option<File>, + // If is_std is true, then we don't drop the corresponding File since it + // will close the handle. + is_std: bool, + dev: u64, + ino: u64, +} + +impl Drop for Handle { + fn drop(&mut self) { + if self.is_std { + // unwrap() will not panic. Since we were able to open an + // std stream successfully, then `file` is guaranteed to be Some() + self.file.take().unwrap().into_raw_fd(); + } + } +} + +impl Eq for Handle {} + +impl PartialEq for Handle { + fn eq(&self, other: &Handle) -> bool { + (self.dev, self.ino) == (other.dev, other.ino) + } +} + +impl AsRawFd for crate::Handle { + fn as_raw_fd(&self) -> RawFd { + // unwrap() will not panic. Since we were able to open the + // file successfully, then `file` is guaranteed to be Some() + self.0.file.as_ref().take().unwrap().as_raw_fd() + } +} + +impl IntoRawFd for crate::Handle { + fn into_raw_fd(mut self) -> RawFd { + // unwrap() will not panic. Since we were able to open the + // file successfully, then `file` is guaranteed to be Some() + self.0.file.take().unwrap().into_raw_fd() + } +} + +impl Hash for Handle { + fn hash<H: Hasher>(&self, state: &mut H) { + self.dev.hash(state); + self.ino.hash(state); + } +} + +impl Handle { + pub fn from_path<P: AsRef<Path>>(p: P) -> io::Result<Handle> { + Handle::from_file(OpenOptions::new().read(true).open(p)?) + } + + pub fn from_file(file: File) -> io::Result<Handle> { + let md = file.metadata()?; + Ok(Handle { + file: Some(file), + is_std: false, + dev: md.dev(), + ino: md.ino(), + }) + } + + pub fn from_std(file: File) -> io::Result<Handle> { + Handle::from_file(file).map(|mut h| { + h.is_std = true; + h + }) + } + + pub fn stdin() -> io::Result<Handle> { + Handle::from_std(unsafe { File::from_raw_fd(0) }) + } + + pub fn stdout() -> io::Result<Handle> { + Handle::from_std(unsafe { File::from_raw_fd(1) }) + } + + pub fn stderr() -> io::Result<Handle> { + Handle::from_std(unsafe { File::from_raw_fd(2) }) + } + + pub fn as_file(&self) -> &File { + // unwrap() will not panic. Since we were able to open the + // file successfully, then `file` is guaranteed to be Some() + self.file.as_ref().take().unwrap() + } + + pub fn as_file_mut(&mut self) -> &mut File { + // unwrap() will not panic. Since we were able to open the + // file successfully, then `file` is guaranteed to be Some() + self.file.as_mut().take().unwrap() + } + + pub fn dev(&self) -> u64 { + self.dev + } + + pub fn ino(&self) -> u64 { + self.ino + } +} diff --git a/third_party/cargo/vendor/same-file-1.0.6/src/unknown.rs b/third_party/cargo/vendor/same-file-1.0.6/src/unknown.rs new file mode 100644 index 0000000..6bfbdea --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/src/unknown.rs @@ -0,0 +1,52 @@ +use std::fs::File; +use std::io; +use std::path::Path; + +static ERROR_MESSAGE: &str = "same-file is not supported on this platform."; +// This implementation is to allow same-file to be compiled on +// unsupported platforms in case it was incidentally included +// as a transitive, unused dependency +#[derive(Debug, Hash)] +pub struct Handle; + +impl Eq for Handle {} + +impl PartialEq for Handle { + fn eq(&self, _other: &Handle) -> bool { + unreachable!(ERROR_MESSAGE); + } +} + +impl Handle { + pub fn from_path<P: AsRef<Path>>(_p: P) -> io::Result<Handle> { + error() + } + + pub fn from_file(_file: File) -> io::Result<Handle> { + error() + } + + pub fn stdin() -> io::Result<Handle> { + error() + } + + pub fn stdout() -> io::Result<Handle> { + error() + } + + pub fn stderr() -> io::Result<Handle> { + error() + } + + pub fn as_file(&self) -> &File { + unreachable!(ERROR_MESSAGE); + } + + pub fn as_file_mut(&self) -> &mut File { + unreachable!(ERROR_MESSAGE); + } +} + +fn error<T>() -> io::Result<T> { + Err(io::Error::new(io::ErrorKind::Other, ERROR_MESSAGE)) +} diff --git a/third_party/cargo/vendor/same-file-1.0.6/src/win.rs b/third_party/cargo/vendor/same-file-1.0.6/src/win.rs new file mode 100644 index 0000000..6924739 --- /dev/null +++ b/third_party/cargo/vendor/same-file-1.0.6/src/win.rs @@ -0,0 +1,172 @@ +use std::fs::File; +use std::hash::{Hash, Hasher}; +use std::io; +use std::os::windows::io::{AsRawHandle, IntoRawHandle, RawHandle}; +use std::path::Path; + +use winapi_util as winutil; + +// For correctness, it is critical that both file handles remain open while +// their attributes are checked for equality. In particular, the file index +// numbers on a Windows stat object are not guaranteed to remain stable over +// time. +// +// See the docs and remarks on MSDN: +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363788(v=vs.85).aspx +// +// It gets worse. It appears that the index numbers are not always +// guaranteed to be unique. Namely, ReFS uses 128 bit numbers for unique +// identifiers. This requires a distinct syscall to get `FILE_ID_INFO` +// documented here: +// https://msdn.microsoft.com/en-us/library/windows/desktop/hh802691(v=vs.85).aspx +// +// It seems straight-forward enough to modify this code to use +// `FILE_ID_INFO` when available (minimum Windows Server 2012), but I don't +// have access to such Windows machines. +// +// Two notes. +// +// 1. Java's NIO uses the approach implemented here and appears to ignore +// `FILE_ID_INFO` altogether. So Java's NIO and this code are +// susceptible to bugs when running on a file system where +// `nFileIndex{Low,High}` are not unique. +// +// 2. LLVM has a bug where they fetch the id of a file and continue to use +// it even after the handle has been closed, so that uniqueness is no +// longer guaranteed (when `nFileIndex{Low,High}` are unique). +// bug report: http://lists.llvm.org/pipermail/llvm-bugs/2014-December/037218.html +// +// All said and done, checking whether two files are the same on Windows +// seems quite tricky. Moreover, even if the code is technically incorrect, +// it seems like the chances of actually observing incorrect behavior are +// extremely small. Nevertheless, we mitigate this by checking size too. +// +// In the case where this code is erroneous, two files will be reported +// as equivalent when they are in fact distinct. This will cause the loop +// detection code to report a false positive, which will prevent descending +// into the offending directory. As far as failure modes goes, this isn't +// that bad. + +#[derive(Debug)] +pub struct Handle { + kind: HandleKind, + key: Option<Key>, +} + +#[derive(Debug)] +enum HandleKind { + /// Used when opening a file or acquiring ownership of a file. + Owned(winutil::Handle), + /// Used for stdio. + Borrowed(winutil::HandleRef), +} + +#[derive(Debug, Eq, PartialEq, Hash)] +struct Key { + volume: u64, + index: u64, +} + +impl Eq for Handle {} + +impl PartialEq for Handle { + fn eq(&self, other: &Handle) -> bool { + // Need this branch to satisfy `Eq` since `Handle`s with + // `key.is_none()` wouldn't otherwise. + if self as *const Handle == other as *const Handle { + return true; + } else if self.key.is_none() || other.key.is_none() { + return false; + } + self.key == other.key + } +} + +impl AsRawHandle for crate::Handle { + fn as_raw_handle(&self) -> RawHandle { + match self.0.kind { + HandleKind::Owned(ref h) => h.as_raw_handle(), + HandleKind::Borrowed(ref h) => h.as_raw_handle(), + } + } +} + +impl IntoRawHandle for crate::Handle { + fn into_raw_handle(self) -> RawHandle { + match self.0.kind { + HandleKind::Owned(h) => h.into_raw_handle(), + HandleKind::Borrowed(h) => h.as_raw_handle(), + } + } +} + +impl Hash for Handle { + fn hash<H: Hasher>(&self, state: &mut H) { + self.key.hash(state); + } +} + +impl Handle { + pub fn from_path<P: AsRef<Path>>(p: P) -> io::Result<Handle> { + let h = winutil::Handle::from_path_any(p)?; + let info = winutil::file::information(&h)?; + Ok(Handle::from_info(HandleKind::Owned(h), info)) + } + + pub fn from_file(file: File) -> io::Result<Handle> { + let h = winutil::Handle::from_file(file); + let info = winutil::file::information(&h)?; + Ok(Handle::from_info(HandleKind::Owned(h), info)) + } + + fn from_std_handle(h: winutil::HandleRef) -> io::Result<Handle> { + match winutil::file::information(&h) { + Ok(info) => Ok(Handle::from_info(HandleKind::Borrowed(h), info)), + // In a Windows console, if there is no pipe attached to a STD + // handle, then GetFileInformationByHandle will return an error. + // We don't really care. The only thing we care about is that + // this handle is never equivalent to any other handle, which is + // accomplished by setting key to None. + Err(_) => Ok(Handle { kind: HandleKind::Borrowed(h), key: None }), + } + } + + fn from_info( + kind: HandleKind, + info: winutil::file::Information, + ) -> Handle { + Handle { + kind: kind, + key: Some(Key { + volume: info.volume_serial_number(), + index: info.file_index(), + }), + } + } + + pub fn stdin() -> io::Result<Handle> { + Handle::from_std_handle(winutil::HandleRef::stdin()) + } + + pub fn stdout() -> io::Result<Handle> { + Handle::from_std_handle(winutil::HandleRef::stdout()) + } + + pub fn stderr() -> io::Result<Handle> { + Handle::from_std_handle(winutil::HandleRef::stderr()) + } + + pub fn as_file(&self) -> &File { + match self.kind { + HandleKind::Owned(ref h) => h.as_file(), + HandleKind::Borrowed(ref h) => h.as_file(), + } + } + + pub fn as_file_mut(&mut self) -> &mut File { + match self.kind { + HandleKind::Owned(ref mut h) => h.as_file_mut(), + HandleKind::Borrowed(ref mut h) => h.as_file_mut(), + } + } +} diff --git a/third_party/cargo/vendor/scopeguard-0.3.3/.cargo-checksum.json b/third_party/cargo/vendor/scopeguard-0.3.3/.cargo-checksum.json new file mode 100644 index 0000000..8657b29 --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-0.3.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"015263d52db02d239b69b9e3f090c2902056a80b8625e37a83bf4af79def93f7","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"7b63ecd5f1902af1b63729947373683c32745c16a10e8e6292e2e2dcd7e90ae0","README.rst":"e53c8b52d8c641b866ebc169fed1d2b154af70296ddf5e087e454de03a7e6040","examples/readme.rs":"5a01391acf2acc52a7a2e0ba58dc8ded3e8cc57d54b45778af5e8ba577158f86","src/lib.rs":"230fd73e62f7d43cd65931c16ed0083d2d4bfcd899abcf5215728732e0e601df"},"package":"94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"} \ No newline at end of file diff --git a/third_party/cargo/vendor/scopeguard-0.3.3/BUILD b/third_party/cargo/vendor/scopeguard-0.3.3/BUILD new file mode 100644 index 0000000..a22ad62 --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-0.3.3/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "readme" with type "example" omitted + +rust_library( + name = "scopeguard", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.3.3", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/scopeguard-0.3.3/Cargo.toml b/third_party/cargo/vendor/scopeguard-0.3.3/Cargo.toml new file mode 100644 index 0000000..4a0d52b --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-0.3.3/Cargo.toml @@ -0,0 +1,28 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "scopeguard" +version = "0.3.3" +authors = ["bluss"] +description = "A RAII scope guard that will run a given closure when it goes out of scope,\neven if the code between panics (assuming unwinding panic).\n\nDefines the macros `defer!` and `defer_on_unwind!`; the latter only runs\nif the scope is extited through unwinding on panic.\n" +documentation = "https://docs.rs/scopeguard/" +keywords = ["scope-guard", "defer", "panic"] +categories = ["rust-patterns"] +license = "MIT/Apache-2.0" +repository = "https://github.com/bluss/scopeguard" +[package.metadata.release] +no-dev-version = true + +[features] +default = ["use_std"] +use_std = [] diff --git a/third_party/cargo/vendor/scopeguard-0.3.3/LICENSE-APACHE b/third_party/cargo/vendor/scopeguard-0.3.3/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-0.3.3/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/scopeguard-0.3.3/LICENSE-MIT b/third_party/cargo/vendor/scopeguard-0.3.3/LICENSE-MIT new file mode 100644 index 0000000..e69282e --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-0.3.3/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2015 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/scopeguard-0.3.3/README.rst b/third_party/cargo/vendor/scopeguard-0.3.3/README.rst new file mode 100644 index 0000000..d4699ea --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-0.3.3/README.rst @@ -0,0 +1,81 @@ + +scopeguard +========== + +Rust crate for a convenient RAII scope guard that will run a given closure when +it goes out of scope, even if the code between panics (assuming unwinding panic). + +The `defer!` macro and `guard` are `no_std` compatible (require only core), +but the on unwinding strategy requires linking to `std`. + +Requires Rust 1.11. + + +Please read the `API documentation here`__ + +__ https://docs.rs/scopeguard/ + +|build_status|_ |crates|_ + +.. |build_status| image:: https://travis-ci.org/bluss/scopeguard.svg +.. _build_status: https://travis-ci.org/bluss/scopeguard + +.. |crates| image:: http://meritbadge.herokuapp.com/scopeguard +.. _crates: https://crates.io/crates/scopeguard + +How to use +---------- + +.. code:: rust + + #[macro_use(defer)] extern crate scopeguard; + + use scopeguard::guard; + + fn f() { + defer!(println!("Called at return or panic")); + panic!(); + } + + use std::fs::File; + use std::io::Write; + + fn g() { + let f = File::create("newfile.txt").unwrap(); + let mut file = guard(f, |f| { + // write file at return or panic + let _ = f.sync_all(); + }); + // Access the file through the scope guard itself + file.write(b"test me\n").unwrap(); + } + +Recent Changes +-------------- + +- 0.3.3 + + - Use ``#[inline]`` on a few more functions by @stjepang (#14) + - Add examples to crate documentation + +- 0.3.2 + + - Add crate categories + +- 0.3.1 + + - Add ``defer_on_unwind!``, ``Strategy`` trait + - Rename ``Guard`` → ``ScopeGuard`` + - Add ``ScopeGuard::with_strategy``. + - ``ScopeGuard`` now implements ``Debug``. + - Require Rust 1.11 + +- 0.2.0 + + - Require Rust 1.6 + - Use `no_std` unconditionally + - No other changes + +- 0.1.2 + + - Add macro ``defer!()`` diff --git a/third_party/cargo/vendor/scopeguard-0.3.3/examples/readme.rs b/third_party/cargo/vendor/scopeguard-0.3.3/examples/readme.rs new file mode 100644 index 0000000..904bc54 --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-0.3.3/examples/readme.rs @@ -0,0 +1,27 @@ + +#[macro_use(defer)] extern crate scopeguard; + +use scopeguard::guard; + +fn f() { + defer!(println!("Called at return or panic")); + panic!(); +} + +use std::fs::File; +use std::io::Write; + +fn g() { + let f = File::create("newfile.txt").unwrap(); + let mut file = guard(f, |f| { + // write file at return or panic + let _ = f.sync_all(); + }); + // Access the file through the scope guard itself + file.write(b"test me\n").unwrap(); +} + +fn main() { + f(); + g(); +} diff --git a/third_party/cargo/vendor/scopeguard-0.3.3/src/lib.rs b/third_party/cargo/vendor/scopeguard-0.3.3/src/lib.rs new file mode 100644 index 0000000..ff3929a --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-0.3.3/src/lib.rs @@ -0,0 +1,409 @@ +#![cfg_attr(not(any(test, feature = "use_std")), no_std)] + +//! A scope guard will run a given closure when it goes out of scope, +//! even if the code between panics. +//! (as long as panic doesn't abort) +//! +//! # Examples +//! +//! ## `defer!` +//! +//! Use the `defer` macro to run an operation at scope exit, +//! either regular scope exit or during unwinding from a panic. +//! +//! ``` +//! #[macro_use(defer)] extern crate scopeguard; +//! +//! use std::cell::Cell; +//! +//! fn main() { +//! // use a cell to observe drops during and after the scope guard is active +//! let drop_counter = Cell::new(0); +//! { +//! // Create a scope guard using `defer!` for the current scope +//! defer! {{ +//! drop_counter.set(1 + drop_counter.get()); +//! }}; +//! +//! // Do regular operations here in the meantime. +//! +//! // Just before scope exit: it hasn't run yet. +//! assert_eq!(drop_counter.get(), 0); +//! +//! // The following scope end is where the defer closure is called +//! } +//! assert_eq!(drop_counter.get(), 1); +//! } +//! ``` +//! +//! ## Scope Guard with Value +//! +//! If the scope guard closure needs to access an outer value that is also +//! mutated outside of the scope guard, then you may want to use the scope guard +//! with a value. The guard works like a smart pointer, so the inner value can +//! be accessed by reference or by mutable reference. +//! +//! ### 1. The guard owns a file +//! +//! In this example, the scope guard owns a file and ensures pending writes are +//! synced at scope exit. +//! +//! ``` +//! extern crate scopeguard; +//! +//! use std::fs::File; +//! use std::io::{self, Write}; +//! +//! fn try_main() -> io::Result<()> { +//! let f = File::create("newfile.txt")?; +//! let mut file = scopeguard::guard(f, |f| { +//! // ensure we flush file at return or panic +//! let _ = f.sync_all(); +//! }); +//! // Access the file through the scope guard itself +//! file.write(b"test me\n").map(|_| ()) +//! } +//! +//! fn main() { +//! try_main().unwrap(); +//! } +//! +//! ``` +//! +//! ### 2. The guard restores an invariant on scope exit +//! +//! ``` +//! extern crate scopeguard; +//! +//! use std::mem::ManuallyDrop; +//! use std::ptr; +//! +//! // This function, just for this example, takes the first element +//! // and inserts it into the assumed sorted tail of the vector. +//! // +//! // For optimization purposes we temporarily violate an invariant of the +//! // Vec, that it owns all of its elements. +//! // +//! // The safe approach is to use swap, which means two writes to memory, +//! // the optimization is to use a “hole” which uses only one write of memory +//! // for each position it moves. +//! // +//! // We *must* use a scope guard to run this code safely. We +//! // are running arbitrary user code (comparison operators) that may panic. +//! // The scope guard ensures we restore the invariant after successful +//! // exit or during unwinding from panic. +//! fn insertion_sort_first<T>(v: &mut Vec<T>) +//! where T: PartialOrd +//! { +//! struct Hole<'a, T: 'a> { +//! v: &'a mut Vec<T>, +//! index: usize, +//! value: ManuallyDrop<T>, +//! } +//! +//! unsafe { +//! // Create a moved-from location in the vector, a “hole”. +//! let value = ptr::read(&v[0]); +//! let mut hole = Hole { v: v, index: 0, value: ManuallyDrop::new(value) }; +//! +//! // Use a scope guard with a value. +//! // At scope exit, plug the hole so that the vector is fully +//! // initialized again. +//! // The scope guard owns the hole, but we can access it through the guard. +//! let mut hole_guard = scopeguard::guard(hole, |hole| { +//! // plug the hole in the vector with the value that was // taken out +//! let index = hole.index; +//! ptr::copy_nonoverlapping(&*hole.value, &mut hole.v[index], 1); +//! }); +//! +//! // run algorithm that moves the hole in the vector here +//! // move the hole until it's in a sorted position +//! for i in 1..hole_guard.v.len() { +//! if *hole_guard.value >= hole_guard.v[i] { +//! // move the element back and the hole forward +//! let index = hole_guard.index; +//! ptr::copy_nonoverlapping(&hole_guard.v[index + 1], &mut hole_guard.v[index], 1); +//! hole_guard.index += 1; +//! } else { +//! break; +//! } +//! } +//! +//! // When the scope exits here, the Vec becomes whole again! +//! } +//! } +//! +//! fn main() { +//! let string = String::from; +//! let mut data = vec![string("c"), string("a"), string("b"), string("d")]; +//! insertion_sort_first(&mut data); +//! assert_eq!(data, vec!["a", "b", "c", "d"]); +//! } +//! +//! ``` +//! +//! +//! # Crate features: +//! +//! - `use_std` +//! + Enabled by default. Enables the `OnUnwind` strategy. +//! + Disable to use `no_std`. + +#[cfg(not(any(test, feature = "use_std")))] +extern crate core as std; + +use std::fmt; +use std::marker::PhantomData; +use std::ops::{Deref, DerefMut}; + +pub trait Strategy { + /// Return `true` if the guard’s associated code should run + /// (in the context where this method is called). + fn should_run() -> bool; +} + +/// Always run on scope exit. +/// +/// “Always” run: on regular exit from a scope or on unwinding from a panic. +/// Can not run on abort, process exit, and other catastrophic events where +/// destructors don’t run. +#[derive(Debug)] +pub enum Always {} + +/// Run on scope exit through unwinding. +/// +/// Requires crate feature `use_std`. +#[cfg(feature = "use_std")] +#[derive(Debug)] +pub enum OnUnwind {} + +/// Run on regular scope exit, when not unwinding. +/// +/// Requires crate feature `use_std`. +#[cfg(feature = "use_std")] +#[derive(Debug)] +#[cfg(test)] +enum OnSuccess {} + +impl Strategy for Always { + #[inline(always)] + fn should_run() -> bool { true } +} + +#[cfg(feature = "use_std")] +impl Strategy for OnUnwind { + #[inline(always)] + fn should_run() -> bool { std::thread::panicking() } +} + +#[cfg(feature = "use_std")] +#[cfg(test)] +impl Strategy for OnSuccess { + #[inline(always)] + fn should_run() -> bool { !std::thread::panicking() } +} + +/// Macro to create a `ScopeGuard` (always run). +/// +/// The macro takes one expression `$e`, which is the body of a closure +/// that will run when the scope is exited. The expression can +/// be a whole block. +#[macro_export] +macro_rules! defer { + ($e:expr) => { + let _guard = $crate::guard((), |_| $e); + } +} + +/// Macro to create a `ScopeGuard` (run on successful scope exit). +/// +/// The macro takes one expression `$e`, which is the body of a closure +/// that will run when the scope is exited. The expression can +/// be a whole block. +/// +/// Requires crate feature `use_std`. +#[cfg(test)] +macro_rules! defer_on_success { + ($e:expr) => { + let _guard = $crate::guard_on_success((), |_| $e); + } +} + +/// Macro to create a `ScopeGuard` (run on unwinding from panic). +/// +/// The macro takes one expression `$e`, which is the body of a closure +/// that will run when the scope is exited. The expression can +/// be a whole block. +/// +/// Requires crate feature `use_std`. +#[macro_export] +macro_rules! defer_on_unwind { + ($e:expr) => { + let _guard = $crate::guard_on_unwind((), |_| $e); + } +} + +/// `ScopeGuard` is a scope guard that may own a protected value. +/// +/// If you place a guard in a local variable, the closure can +/// run regardless how you leave the scope — through regular return or panic +/// (except if panic or other code aborts; so as long as destructors run). +/// It is run only once. +/// +/// The `S` parameter for [`Strategy`](Strategy.t.html) determines if +/// the closure actually runs. +/// +/// The guard's closure will be called with a mut ref to the held value +/// in the destructor. It's called only once. +/// +/// The `ScopeGuard` implements `Deref` so that you can access the inner value. +pub struct ScopeGuard<T, F, S: Strategy = Always> + where F: FnMut(&mut T) +{ + __dropfn: F, + __value: T, + strategy: PhantomData<S>, +} +impl<T, F, S> ScopeGuard<T, F, S> + where F: FnMut(&mut T), + S: Strategy, +{ + /// Create a `ScopeGuard` that owns `v` (accessible through deref) and calls + /// `dropfn` when its destructor runs. + /// + /// The `Strategy` decides whether the scope guard's closure should run. + #[inline] + pub fn with_strategy(v: T, dropfn: F) -> ScopeGuard<T, F, S> { + ScopeGuard { + __value: v, + __dropfn: dropfn, + strategy: PhantomData, + } + } +} + + +/// Create a new `ScopeGuard` owning `v` and with deferred closure `dropfn`. +#[inline] +pub fn guard<T, F>(v: T, dropfn: F) -> ScopeGuard<T, F, Always> + where F: FnMut(&mut T) +{ + ScopeGuard::with_strategy(v, dropfn) +} + +/// Create a new `ScopeGuard` owning `v` and with deferred closure `dropfn`. +/// +/// Requires crate feature `use_std`. +#[cfg(feature = "use_std")] +#[cfg(test)] +#[inline] +fn guard_on_success<T, F>(v: T, dropfn: F) -> ScopeGuard<T, F, OnSuccess> + where F: FnMut(&mut T) +{ + ScopeGuard::with_strategy(v, dropfn) +} + +/// Create a new `ScopeGuard` owning `v` and with deferred closure `dropfn`. +/// +/// Requires crate feature `use_std`. +#[cfg(feature = "use_std")] +#[inline] +pub fn guard_on_unwind<T, F>(v: T, dropfn: F) -> ScopeGuard<T, F, OnUnwind> + where F: FnMut(&mut T) +{ + ScopeGuard::with_strategy(v, dropfn) +} + +impl<T, F, S: Strategy> Deref for ScopeGuard<T, F, S> + where F: FnMut(&mut T) +{ + type Target = T; + fn deref(&self) -> &T { + &self.__value + } + +} + +impl<T, F, S: Strategy> DerefMut for ScopeGuard<T, F, S> + where F: FnMut(&mut T) +{ + fn deref_mut(&mut self) -> &mut T { + &mut self.__value + } +} + +impl<T, F, S: Strategy> Drop for ScopeGuard<T, F, S> + where F: FnMut(&mut T) +{ + fn drop(&mut self) { + if S::should_run() { + (self.__dropfn)(&mut self.__value) + } + } +} + +impl<T, F, S> fmt::Debug for ScopeGuard<T, F, S> + where T: fmt::Debug, + F: FnMut(&mut T), + S: Strategy + fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("ScopeGuard") + .field("value", &self.__value) + .finish() + } +} + +#[cfg(test)] +mod tests { + use std::cell::Cell; + use std::panic::catch_unwind; + use std::panic::AssertUnwindSafe; + + #[test] + fn test_defer() { + let drops = Cell::new(0); + defer!(drops.set(1000)); + assert_eq!(drops.get(), 0); + } + + #[test] + fn test_defer_success_1() { + let drops = Cell::new(0); + { + defer_on_success!(drops.set(1)); + assert_eq!(drops.get(), 0); + } + assert_eq!(drops.get(), 1); + } + + #[test] + fn test_defer_success_2() { + let drops = Cell::new(0); + let _ = catch_unwind(AssertUnwindSafe(|| { + defer_on_success!(drops.set(1)); + panic!("failure") + })); + assert_eq!(drops.get(), 0); + } + + #[test] + fn test_defer_unwind_1() { + let drops = Cell::new(0); + let _ = catch_unwind(AssertUnwindSafe(|| { + defer_on_unwind!(drops.set(1)); + assert_eq!(drops.get(), 0); + panic!("failure") + })); + assert_eq!(drops.get(), 1); + } + + #[test] + fn test_defer_unwind_2() { + let drops = Cell::new(0); + { + defer_on_unwind!(drops.set(1)); + } + assert_eq!(drops.get(), 0); + } +} diff --git a/third_party/cargo/vendor/scopeguard-1.0.0/.cargo-checksum.json b/third_party/cargo/vendor/scopeguard-1.0.0/.cargo-checksum.json new file mode 100644 index 0000000..b80325b --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-1.0.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"3338b13bca1bd8bf830f563dd201bc5deed2a4848c7f6485c40ea2f3469c8279","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"7b63ecd5f1902af1b63729947373683c32745c16a10e8e6292e2e2dcd7e90ae0","README.rst":"dc20b385e388c7989454e3a6a96e8112e48680258895562097bf8c809b4d8106","examples/readme.rs":"d00fe19aecd7ca1632bcf176306f7a13ed8fdefa890761aa2c532f8c97532a33","src/lib.rs":"957f1f548d91129c6c9b248dd28c3857a1c988123a70da34dacef416d4204bec"},"package":"b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"} \ No newline at end of file diff --git a/third_party/cargo/vendor/scopeguard-1.0.0/BUILD b/third_party/cargo/vendor/scopeguard-1.0.0/BUILD new file mode 100644 index 0000000..142d8b6 --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-1.0.0/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "readme" with type "example" omitted + +rust_library( + name = "scopeguard", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.0.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/scopeguard-1.0.0/Cargo.toml b/third_party/cargo/vendor/scopeguard-1.0.0/Cargo.toml new file mode 100644 index 0000000..c8b6f85 --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-1.0.0/Cargo.toml @@ -0,0 +1,28 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "scopeguard" +version = "1.0.0" +authors = ["bluss"] +description = "A RAII scope guard that will run a given closure when it goes out of scope,\neven if the code between panics (assuming unwinding panic).\n\nDefines the macros `defer!`, `defer_on_unwind!`, `defer_on_success!` as\nshorthands for guards with one of the implemented strategies.\n" +documentation = "https://docs.rs/scopeguard/" +keywords = ["scope-guard", "defer", "panic", "unwind"] +categories = ["rust-patterns", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/bluss/scopeguard" +[package.metadata.release] +no-dev-version = true + +[features] +default = ["use_std"] +use_std = [] diff --git a/third_party/cargo/vendor/scopeguard-1.0.0/LICENSE-APACHE b/third_party/cargo/vendor/scopeguard-1.0.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-1.0.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/scopeguard-1.0.0/LICENSE-MIT b/third_party/cargo/vendor/scopeguard-1.0.0/LICENSE-MIT new file mode 100644 index 0000000..e69282e --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-1.0.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2015 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/scopeguard-1.0.0/README.rst b/third_party/cargo/vendor/scopeguard-1.0.0/README.rst new file mode 100644 index 0000000..016f175 --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-1.0.0/README.rst @@ -0,0 +1,98 @@ + +scopeguard +========== + +Rust crate for a convenient RAII scope guard that will run a given closure when +it goes out of scope, even if the code between panics (assuming unwinding panic). + +The `defer!` macro and `guard` are `no_std` compatible (require only core), +but the on unwinding / not on uwinding strategies requires linking to `std`. + +Requires Rust 1.20. + + +Please read the `API documentation here`__ + +__ https://docs.rs/scopeguard/ + +|build_status|_ |crates|_ + +.. |build_status| image:: https://travis-ci.org/bluss/scopeguard.svg +.. _build_status: https://travis-ci.org/bluss/scopeguard + +.. |crates| image:: http://meritbadge.herokuapp.com/scopeguard +.. _crates: https://crates.io/crates/scopeguard + +How to use +---------- + +.. code:: rust + + #[macro_use(defer)] extern crate scopeguard; + + use scopeguard::guard; + + fn f() { + defer!(println!("Called at return or panic")); + panic!(); + } + + use std::fs::File; + use std::io::Write; + + fn g() { + let f = File::create("newfile.txt").unwrap(); + let mut file = guard(f, |f| { + // write file at return or panic + let _ = f.sync_all(); + }); + // Access the file through the scope guard itself + file.write_all(b"test me\n").unwrap(); + } + +Recent Changes +-------------- + +- 1.0.0 + + - Change the closure type from ``FnMut(&mut T)`` to ``FnOnce(T)``: + Passing the inner value by value instead of a mutable reference is a + breaking change, but allows the guard closure to consume it. (by @tormol) + + - Add ``defer_on_success!{}``, ``guard_on_success()`` and ``OnSuccess`` + strategy, which triggers when scope is exited *without* panic. It's the + opposite to ``OnUnwind`` / ``guard_on_unwind()`` / ``defer_on_unwind!{}``. + + - Add ``ScopeGuard::into_inner()``, which "defuses" the guard and returns the + guarded value. (by @tormol) + + - Implement ``Sync`` for guards with non-``Sync`` closures. + + - Require Rust 1.20 + +- 0.3.3 + + - Use ``#[inline]`` on a few more functions by @stjepang (#14) + - Add examples to crate documentation + +- 0.3.2 + + - Add crate categories + +- 0.3.1 + + - Add ``defer_on_unwind!``, ``Strategy`` trait + - Rename ``Guard`` → ``ScopeGuard`` + - Add ``ScopeGuard::with_strategy``. + - ``ScopeGuard`` now implements ``Debug``. + - Require Rust 1.11 + +- 0.2.0 + + - Require Rust 1.6 + - Use `no_std` unconditionally + - No other changes + +- 0.1.2 + + - Add macro ``defer!()`` diff --git a/third_party/cargo/vendor/scopeguard-1.0.0/examples/readme.rs b/third_party/cargo/vendor/scopeguard-1.0.0/examples/readme.rs new file mode 100644 index 0000000..0710f9f --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-1.0.0/examples/readme.rs @@ -0,0 +1,27 @@ + +#[macro_use(defer)] extern crate scopeguard; + +use scopeguard::guard; + +fn f() { + defer!(println!("Called at return or panic")); + panic!(); +} + +use std::fs::File; +use std::io::Write; + +fn g() { + let f = File::create("newfile.txt").unwrap(); + let mut file = guard(f, |f| { + // write file at return or panic + let _ = f.sync_all(); + }); + // Access the file through the scope guard itself + file.write_all(b"test me\n").unwrap(); +} + +fn main() { + f(); + g(); +} diff --git a/third_party/cargo/vendor/scopeguard-1.0.0/src/lib.rs b/third_party/cargo/vendor/scopeguard-1.0.0/src/lib.rs new file mode 100644 index 0000000..553420e --- /dev/null +++ b/third_party/cargo/vendor/scopeguard-1.0.0/src/lib.rs @@ -0,0 +1,578 @@ +#![cfg_attr(not(any(test, feature = "use_std")), no_std)] +#![doc(html_root_url = "https://docs.rs/scopeguard/1/")] + +//! A scope guard will run a given closure when it goes out of scope, +//! even if the code between panics. +//! (as long as panic doesn't abort) +//! +//! # Examples +//! +//! ## Hello World +//! +//! This example creates a scope guard with an example function: +//! +//! ``` +//! extern crate scopeguard; +//! +//! fn f() { +//! let _guard = scopeguard::guard((), |_| { +//! println!("Hello Scope Exit!"); +//! }); +//! +//! // rest of the code here. +//! +//! // Here, at the end of `_guard`'s scope, the guard's closure is called. +//! // It is also called if we exit this scope through unwinding instead. +//! } +//! # fn main() { +//! # f(); +//! # } +//! ``` +//! +//! ## `defer!` +//! +//! Use the `defer` macro to run an operation at scope exit, +//! either regular scope exit or during unwinding from a panic. +//! +//! ``` +//! #[macro_use(defer)] extern crate scopeguard; +//! +//! use std::cell::Cell; +//! +//! fn main() { +//! // use a cell to observe drops during and after the scope guard is active +//! let drop_counter = Cell::new(0); +//! { +//! // Create a scope guard using `defer!` for the current scope +//! defer! {{ +//! drop_counter.set(1 + drop_counter.get()); +//! }}; +//! +//! // Do regular operations here in the meantime. +//! +//! // Just before scope exit: it hasn't run yet. +//! assert_eq!(drop_counter.get(), 0); +//! +//! // The following scope end is where the defer closure is called +//! } +//! assert_eq!(drop_counter.get(), 1); +//! } +//! ``` +//! +//! ## Scope Guard with Value +//! +//! If the scope guard closure needs to access an outer value that is also +//! mutated outside of the scope guard, then you may want to use the scope guard +//! with a value. The guard works like a smart pointer, so the inner value can +//! be accessed by reference or by mutable reference. +//! +//! ### 1. The guard owns a file +//! +//! In this example, the scope guard owns a file and ensures pending writes are +//! synced at scope exit. +//! +//! ``` +//! extern crate scopeguard; +//! +//! use std::fs::*; +//! use std::io::{self, Write}; +//! # // Mock file so that we don't actually write a file +//! # struct MockFile; +//! # impl MockFile { +//! # fn create(_s: &str) -> io::Result<Self> { Ok(MockFile) } +//! # fn write_all(&self, _b: &[u8]) -> io::Result<()> { Ok(()) } +//! # fn sync_all(&self) -> io::Result<()> { Ok(()) } +//! # } +//! # use self::MockFile as File; +//! +//! fn try_main() -> io::Result<()> { +//! let f = File::create("newfile.txt")?; +//! let mut file = scopeguard::guard(f, |f| { +//! // ensure we flush file at return or panic +//! let _ = f.sync_all(); +//! }); +//! // Access the file through the scope guard itself +//! file.write_all(b"test me\n").map(|_| ()) +//! } +//! +//! fn main() { +//! try_main().unwrap(); +//! } +//! +//! ``` +//! +//! ### 2. The guard restores an invariant on scope exit +//! +//! ``` +//! extern crate scopeguard; +//! +//! use std::mem::ManuallyDrop; +//! use std::ptr; +//! +//! // This function, just for this example, takes the first element +//! // and inserts it into the assumed sorted tail of the vector. +//! // +//! // For optimization purposes we temporarily violate an invariant of the +//! // Vec, that it owns all of its elements. +//! // +//! // The safe approach is to use swap, which means two writes to memory, +//! // the optimization is to use a “hole” which uses only one write of memory +//! // for each position it moves. +//! // +//! // We *must* use a scope guard to run this code safely. We +//! // are running arbitrary user code (comparison operators) that may panic. +//! // The scope guard ensures we restore the invariant after successful +//! // exit or during unwinding from panic. +//! fn insertion_sort_first<T>(v: &mut Vec<T>) +//! where T: PartialOrd +//! { +//! struct Hole<'a, T: 'a> { +//! v: &'a mut Vec<T>, +//! index: usize, +//! value: ManuallyDrop<T>, +//! } +//! +//! unsafe { +//! // Create a moved-from location in the vector, a “hole”. +//! let value = ptr::read(&v[0]); +//! let mut hole = Hole { v: v, index: 0, value: ManuallyDrop::new(value) }; +//! +//! // Use a scope guard with a value. +//! // At scope exit, plug the hole so that the vector is fully +//! // initialized again. +//! // The scope guard owns the hole, but we can access it through the guard. +//! let mut hole_guard = scopeguard::guard(hole, |hole| { +//! // plug the hole in the vector with the value that was // taken out +//! let index = hole.index; +//! ptr::copy_nonoverlapping(&*hole.value, &mut hole.v[index], 1); +//! }); +//! +//! // run algorithm that moves the hole in the vector here +//! // move the hole until it's in a sorted position +//! for i in 1..hole_guard.v.len() { +//! if *hole_guard.value >= hole_guard.v[i] { +//! // move the element back and the hole forward +//! let index = hole_guard.index; +//! ptr::copy_nonoverlapping(&hole_guard.v[index + 1], &mut hole_guard.v[index], 1); +//! hole_guard.index += 1; +//! } else { +//! break; +//! } +//! } +//! +//! // When the scope exits here, the Vec becomes whole again! +//! } +//! } +//! +//! fn main() { +//! let string = String::from; +//! let mut data = vec![string("c"), string("a"), string("b"), string("d")]; +//! insertion_sort_first(&mut data); +//! assert_eq!(data, vec!["a", "b", "c", "d"]); +//! } +//! +//! ``` +//! +//! +//! # Crate Features +//! +//! - `use_std` +//! + Enabled by default. Enables the `OnUnwind` and `OnSuccess` strategies. +//! + Disable to use `no_std`. +//! +//! # Rust Version +//! +//! This version of the crate requires Rust 1.20 or later. +//! +//! The scopeguard 1.x release series will use a carefully considered version +//! upgrade policy, where in a later 1.x version, we will raise the minimum +//! required Rust version. + +#[cfg(not(any(test, feature = "use_std")))] +extern crate core as std; + +use std::fmt; +use std::marker::PhantomData; +use std::mem::{self, ManuallyDrop}; +use std::ops::{Deref, DerefMut}; +use std::ptr; + +/// Controls in which cases the associated code should be run +pub trait Strategy { + /// Return `true` if the guard’s associated code should run + /// (in the context where this method is called). + fn should_run() -> bool; +} + +/// Always run on scope exit. +/// +/// “Always” run: on regular exit from a scope or on unwinding from a panic. +/// Can not run on abort, process exit, and other catastrophic events where +/// destructors don’t run. +#[derive(Debug)] +pub enum Always {} + +/// Run on scope exit through unwinding. +/// +/// Requires crate feature `use_std`. +#[cfg(feature = "use_std")] +#[derive(Debug)] +pub enum OnUnwind {} + +/// Run on regular scope exit, when not unwinding. +/// +/// Requires crate feature `use_std`. +#[cfg(feature = "use_std")] +#[derive(Debug)] +pub enum OnSuccess {} + +impl Strategy for Always { + #[inline(always)] + fn should_run() -> bool { true } +} + +#[cfg(feature = "use_std")] +impl Strategy for OnUnwind { + #[inline] + fn should_run() -> bool { std::thread::panicking() } +} + +#[cfg(feature = "use_std")] +impl Strategy for OnSuccess { + #[inline] + fn should_run() -> bool { !std::thread::panicking() } +} + +/// Macro to create a `ScopeGuard` (always run). +/// +/// The macro takes one expression `$e`, which is the body of a closure +/// that will run when the scope is exited. The expression can +/// be a whole block. +#[macro_export] +macro_rules! defer { + ($e:expr) => { + let _guard = $crate::guard((), |()| $e); + } +} + +/// Macro to create a `ScopeGuard` (run on successful scope exit). +/// +/// The macro takes one expression `$e`, which is the body of a closure +/// that will run when the scope is exited. The expression can +/// be a whole block. +/// +/// Requires crate feature `use_std`. +#[cfg(feature = "use_std")] +#[macro_export] +macro_rules! defer_on_success { + ($e:expr) => { + let _guard = $crate::guard_on_success((), |()| $e); + } +} + +/// Macro to create a `ScopeGuard` (run on unwinding from panic). +/// +/// The macro takes one expression `$e`, which is the body of a closure +/// that will run when the scope is exited. The expression can +/// be a whole block. +/// +/// Requires crate feature `use_std`. +#[cfg(feature = "use_std")] +#[macro_export] +macro_rules! defer_on_unwind { + ($e:expr) => { + let _guard = $crate::guard_on_unwind((), |()| $e); + } +} + +/// `ScopeGuard` is a scope guard that may own a protected value. +/// +/// If you place a guard in a local variable, the closure can +/// run regardless how you leave the scope — through regular return or panic +/// (except if panic or other code aborts; so as long as destructors run). +/// It is run only once. +/// +/// The `S` parameter for [`Strategy`](Strategy.t.html) determines if +/// the closure actually runs. +/// +/// The guard's closure will be called with the held value in the destructor. +/// +/// The `ScopeGuard` implements `Deref` so that you can access the inner value. +pub struct ScopeGuard<T, F, S = Always> + where F: FnOnce(T), + S: Strategy, +{ + value: ManuallyDrop<T>, + dropfn: ManuallyDrop<F>, + strategy: PhantomData<fn(S) -> S>, +} + +impl<T, F, S> ScopeGuard<T, F, S> + where F: FnOnce(T), + S: Strategy, +{ + /// Create a `ScopeGuard` that owns `v` (accessible through deref) and calls + /// `dropfn` when its destructor runs. + /// + /// The `Strategy` decides whether the scope guard's closure should run. + #[inline] + pub fn with_strategy(v: T, dropfn: F) -> ScopeGuard<T, F, S> { + ScopeGuard { + value: ManuallyDrop::new(v), + dropfn: ManuallyDrop::new(dropfn), + strategy: PhantomData, + } + } + + /// “Defuse” the guard and extract the value without calling the closure. + /// + /// ``` + /// extern crate scopeguard; + /// use scopeguard::{guard, ScopeGuard}; + /// + /// fn conditional() -> bool { true } + /// + /// fn main() { + /// let mut guard = guard(Vec::new(), |mut v| v.clear()); + /// guard.push(1); + /// + /// if conditional() { + /// // a condition maybe makes us decide to + /// // “defuse” the guard and get back its inner parts + /// let value = ScopeGuard::into_inner(guard); + /// } else { + /// // guard still exists in this branch + /// } + /// } + /// ``` + #[inline] + pub fn into_inner(guard: Self) -> T { + // Cannot pattern match out of Drop-implementing types, so + // ptr::read the value and forget the guard. + unsafe { + let value = ptr::read(&*guard.value); + // read the closure so that it is dropped, and assign it to a local + // variable to ensure that it is only dropped after the guard has + // been forgotten. (In case the Drop impl of the closure, or that + // of any consumed captured variable, panics). + let _dropfn = ptr::read(&*guard.dropfn); + mem::forget(guard); + value + } + } +} + + +/// Create a new `ScopeGuard` owning `v` and with deferred closure `dropfn`. +#[inline] +pub fn guard<T, F>(v: T, dropfn: F) -> ScopeGuard<T, F, Always> + where F: FnOnce(T) +{ + ScopeGuard::with_strategy(v, dropfn) +} + +/// Create a new `ScopeGuard` owning `v` and with deferred closure `dropfn`. +/// +/// Requires crate feature `use_std`. +#[cfg(feature = "use_std")] +#[inline] +pub fn guard_on_success<T, F>(v: T, dropfn: F) -> ScopeGuard<T, F, OnSuccess> + where F: FnOnce(T) +{ + ScopeGuard::with_strategy(v, dropfn) +} + +/// Create a new `ScopeGuard` owning `v` and with deferred closure `dropfn`. +/// +/// Requires crate feature `use_std`. +/// +/// ## Examples +/// +/// For performance reasons, or to emulate “only run guard on unwind” in +/// no-std environments, we can also use the default guard and simply manually +/// defuse it at the end of scope like the following example. (The performance +/// reason would be if the [`OnUnwind`]'s call to [std::thread::panicking()] is +/// an issue.) +/// +/// ``` +/// extern crate scopeguard; +/// +/// use scopeguard::ScopeGuard; +/// # fn main() { +/// { +/// let guard = scopeguard::guard((), |_| { }); +/// +/// // rest of the code here +/// +/// // we reached the end of scope without unwinding - defuse it +/// ScopeGuard::into_inner(guard); +/// } +/// # } +/// ``` +#[cfg(feature = "use_std")] +#[inline] +pub fn guard_on_unwind<T, F>(v: T, dropfn: F) -> ScopeGuard<T, F, OnUnwind> + where F: FnOnce(T) +{ + ScopeGuard::with_strategy(v, dropfn) +} + +// ScopeGuard can be Sync even if F isn't because the closure is +// not accessible from references. +// The guard does not store any instance of S, so it is also irellevant. +unsafe impl<T, F, S> Sync for ScopeGuard<T, F, S> + where T: Sync, + F: FnOnce(T), + S: Strategy +{ } + +impl<T, F, S> Deref for ScopeGuard<T, F, S> + where F: FnOnce(T), + S: Strategy +{ + type Target = T; + fn deref(&self) -> &T { + &*self.value + } +} + +impl<T, F, S> DerefMut for ScopeGuard<T, F, S> + where F: FnOnce(T), + S: Strategy +{ + fn deref_mut(&mut self) -> &mut T { + &mut*self.value + } +} + +impl<T, F, S> Drop for ScopeGuard<T, F, S> + where F: FnOnce(T), + S: Strategy +{ + fn drop(&mut self) { + // This is OK because the fields are `ManuallyDrop`s + // which will not be dropped by the compiler. + let (value, dropfn) = unsafe { + (ptr::read(&*self.value), ptr::read(&*self.dropfn)) + }; + if S::should_run() { + dropfn(value); + } + } +} + +impl<T, F, S> fmt::Debug for ScopeGuard<T, F, S> + where T: fmt::Debug, + F: FnOnce(T), + S: Strategy +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct(stringify!(ScopeGuard)) + .field("value", &*self.value) + .finish() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::cell::Cell; + use std::panic::catch_unwind; + use std::panic::AssertUnwindSafe; + + #[test] + fn test_defer() { + let drops = Cell::new(0); + defer!(drops.set(1000)); + assert_eq!(drops.get(), 0); + } + + #[cfg(feature = "use_std")] + #[test] + fn test_defer_success_1() { + let drops = Cell::new(0); + { + defer_on_success!(drops.set(1)); + assert_eq!(drops.get(), 0); + } + assert_eq!(drops.get(), 1); + } + + #[cfg(feature = "use_std")] + #[test] + fn test_defer_success_2() { + let drops = Cell::new(0); + let _ = catch_unwind(AssertUnwindSafe(|| { + defer_on_success!(drops.set(1)); + panic!("failure") + })); + assert_eq!(drops.get(), 0); + } + + #[cfg(feature = "use_std")] + #[test] + fn test_defer_unwind_1() { + let drops = Cell::new(0); + let _ = catch_unwind(AssertUnwindSafe(|| { + defer_on_unwind!(drops.set(1)); + assert_eq!(drops.get(), 0); + panic!("failure") + })); + assert_eq!(drops.get(), 1); + } + + #[cfg(feature = "use_std")] + #[test] + fn test_defer_unwind_2() { + let drops = Cell::new(0); + { + defer_on_unwind!(drops.set(1)); + } + assert_eq!(drops.get(), 0); + } + + #[test] + fn test_only_dropped_by_closure_when_run() { + let value_drops = Cell::new(0); + let value = guard((), |()| value_drops.set(1 + value_drops.get())); + let closure_drops = Cell::new(0); + let guard = guard(value, |_| closure_drops.set(1 + closure_drops.get())); + assert_eq!(value_drops.get(), 0); + assert_eq!(closure_drops.get(), 0); + drop(guard); + assert_eq!(value_drops.get(), 1); + assert_eq!(closure_drops.get(), 1); + } + + #[cfg(feature = "use_std")] + #[test] + fn test_dropped_once_when_not_run() { + let value_drops = Cell::new(0); + let value = guard((), |()| value_drops.set(1 + value_drops.get())); + let captured_drops = Cell::new(0); + let captured = guard((), |()| captured_drops.set(1 + captured_drops.get())); + let closure_drops = Cell::new(0); + let guard = guard_on_unwind(value, |value| { + drop(value); + drop(captured); + closure_drops.set(1 + closure_drops.get()) + }); + assert_eq!(value_drops.get(), 0); + assert_eq!(captured_drops.get(), 0); + assert_eq!(closure_drops.get(), 0); + drop(guard); + assert_eq!(value_drops.get(), 1); + assert_eq!(captured_drops.get(), 1); + assert_eq!(closure_drops.get(), 0); + } + + #[test] + fn test_into_inner() { + let dropped = Cell::new(false); + let value = guard(42, |_| dropped.set(true)); + let guard = guard(value, |_| dropped.set(true)); + let inner = ScopeGuard::into_inner(guard); + assert_eq!(dropped.get(), false); + assert_eq!(*inner, 42); + } +} diff --git a/third_party/cargo/vendor/semver-0.9.0/.cargo-checksum.json b/third_party/cargo/vendor/semver-0.9.0/.cargo-checksum.json new file mode 100644 index 0000000..2f9af6e --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"a5b995796b5559de8975a6fee7166c9fda6c21b449ec90bef5f9baaeddd479a5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"c780d8c3c802c5fe2c316127900385010c3e57f71c851eea9e8ed8495e2030dd","src/lib.rs":"cb1725a8bb90c1043f187c6ba504d0a9d07793e2f39f5205f926c58849311770","src/version.rs":"ffdf9c628597b889f149f3b2b1245b97c774eae1ce7030bd19235eabecaaede0","src/version_req.rs":"40d20720f5fdc0b3d9e398e64eb448a65987229bd322cab0fedf0cf1843f3bd8","tests/deprecation.rs":"b5ec79e19d61968d05b96b876c449e54d43cbd1762c6e63c23c3470f9db56292","tests/regression.rs":"180b699ad029b81e6135d42f0a8e6d782177bc29a41132f875ee6f8607a46b56","tests/serde.rs":"cdbbefc576ffcc814c30dad9598ab87a7fd9d14c5f42f1349e1db6afc72f8fed"},"package":"1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"} \ No newline at end of file diff --git a/third_party/cargo/vendor/semver-0.9.0/BUILD b/third_party/cargo/vendor/semver-0.9.0/BUILD new file mode 100644 index 0000000..1b98b77 --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "deprecation" with type "test" omitted +# Unsupported target "regression" with type "test" omitted + +rust_library( + name = "semver", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/semver-parser-0.7.0:semver_parser", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.9.0", + crate_features = [ + "default", + ], +) + +# Unsupported target "serde" with type "test" omitted diff --git a/third_party/cargo/vendor/semver-0.9.0/Cargo.toml b/third_party/cargo/vendor/semver-0.9.0/Cargo.toml new file mode 100644 index 0000000..7749f76 --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/Cargo.toml @@ -0,0 +1,45 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "semver" +version = "0.9.0" +authors = ["Steve Klabnik <steve@steveklabnik.com>", "The Rust Project Developers"] +description = "Semantic version parsing and comparison.\n" +homepage = "https://docs.rs/crate/semver/" +documentation = "https://docs.rs/crate/semver/" +readme = "README.md" +license = "MIT/Apache-2.0" +repository = "https://github.com/steveklabnik/semver" +[dependencies.semver-parser] +version = "0.7.0" + +[dependencies.serde] +version = "1.0" +optional = true +[dev-dependencies.crates-index] +version = "0.5.0" + +[dev-dependencies.serde_json] +version = "1.0" + +[dev-dependencies.serde_derive] +version = "1.0" + +[dev-dependencies.tempdir] +version = "0.3.4" + +[features] +default = [] +ci = ["serde"] +[badges.travis-ci] +repository = "steveklabnik/semver" diff --git a/third_party/cargo/vendor/semver-0.9.0/LICENSE-APACHE b/third_party/cargo/vendor/semver-0.9.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/semver-0.9.0/LICENSE-MIT b/third_party/cargo/vendor/semver-0.9.0/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/semver-0.9.0/README.md b/third_party/cargo/vendor/semver-0.9.0/README.md new file mode 100644 index 0000000..2a5306d --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/README.md @@ -0,0 +1,103 @@ +semver +====== + +Semantic version parsing and comparison. + +[![Build Status](https://api.travis-ci.org/steveklabnik/semver.svg?branch=master)](https://travis-ci.org/steveklabnik/semver) + +[Documentation](https://steveklabnik.github.io/semver) + +Semantic versioning (see http://semver.org/) is a set of rules for +assigning version numbers. + +## SemVer and the Rust ecosystem + +Rust itself follows the SemVer specification, as does its standard libraries. The two are +not tied together. + +[Cargo](https://crates.io), Rust's package manager, uses SemVer to determine which versions of +packages you need installed. + +## Installation + +To use `semver`, add this to your `[dependencies]` section: + +```toml +semver = "0.7.0" +``` + +And this to your crate root: + +```rust +extern crate semver; +``` + +## Versions + +At its simplest, the `semver` crate allows you to construct `Version` objects using the `parse` +method: + +```rust +use semver::Version; + +assert!(Version::parse("1.2.3") == Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec!(), + build: vec!(), +})); +``` + +If you have multiple `Version`s, you can use the usual comparison operators to compare them: + +```rust +use semver::Version; + +assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); +assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); +``` + +## Requirements + +The `semver` crate also provides the ability to compare requirements, which are more complex +comparisons. + +For example, creating a requirement that only matches versions greater than or +equal to 1.0.0: + +```rust +use semver::Version; +use semver::VersionReq; + +let r = VersionReq::parse(">= 1.0.0").unwrap(); +let v = Version::parse("1.0.0").unwrap(); + +assert!(r.to_string() == ">= 1.0.0".to_string()); +assert!(r.matches(&v)) +``` + +It also allows parsing of `~x.y.z` and `^x.y.z` requirements as defined at +https://www.npmjs.org/doc/misc/semver.html + +**Tilde requirements** specify a minimal version with some updates: + +```notrust +~1.2.3 := >=1.2.3 <1.3.0 +~1.2 := >=1.2.0 <1.3.0 +~1 := >=1.0.0 <2.0.0 +``` + +**Caret requirements** allow SemVer compatible updates to a specified version, +`0.x` and `0.x+1` are not considered compatible, but `1.x` and `1.x+1` are. + +`0.0.x` is not considered compatible with any other version. +Missing minor and patch versions are desugared to `0` but allow flexibility for that value. + +```notrust +^1.2.3 := >=1.2.3 <2.0.0 +^0.2.3 := >=0.2.3 <0.3.0 +^0.0.3 := >=0.0.3 <0.0.4 +^0.0 := >=0.0.0 <0.1.0 +^0 := >=0.0.0 <1.0.0 +``` diff --git a/third_party/cargo/vendor/semver-0.9.0/src/lib.rs b/third_party/cargo/vendor/semver-0.9.0/src/lib.rs new file mode 100644 index 0000000..a38aae0 --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/src/lib.rs @@ -0,0 +1,182 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Semantic version parsing and comparison. +//! +//! Semantic versioning (see http://semver.org/) is a set of rules for +//! assigning version numbers. +//! +//! ## SemVer overview +//! +//! Given a version number MAJOR.MINOR.PATCH, increment the: +//! +//! 1. MAJOR version when you make incompatible API changes, +//! 2. MINOR version when you add functionality in a backwards-compatible +//! manner, and +//! 3. PATCH version when you make backwards-compatible bug fixes. +//! +//! Additional labels for pre-release and build metadata are available as +//! extensions to the MAJOR.MINOR.PATCH format. +//! +//! Any references to 'the spec' in this documentation refer to [version 2.0 of +//! the SemVer spec](http://semver.org/spec/v2.0.0.html). +//! +//! ## SemVer and the Rust ecosystem +//! +//! Rust itself follows the SemVer specification, as does its standard +//! libraries. The two are not tied together. +//! +//! [Cargo](http://crates.io), Rust's package manager, uses SemVer to determine +//! which versions of packages you need installed. +//! +//! ## Versions +//! +//! At its simplest, the `semver` crate allows you to construct `Version` +//! objects using the `parse` method: +//! +//! ```{rust} +//! use semver::Version; +//! +//! assert!(Version::parse("1.2.3") == Ok(Version { +//! major: 1, +//! minor: 2, +//! patch: 3, +//! pre: vec!(), +//! build: vec!(), +//! })); +//! ``` +//! +//! If you have multiple `Version`s, you can use the usual comparison operators +//! to compare them: +//! +//! ```{rust} +//! use semver::Version; +//! +//! assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); +//! assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); +//! ``` +//! +//! If you explicitly need to modify a Version, SemVer also allows you to +//! increment the major, minor, and patch numbers in accordance with the spec. +//! +//! Please note that in order to do this, you must use a mutable Version: +//! +//! ```{rust} +//! use semver::Version; +//! +//! let mut bugfix_release = Version::parse("1.0.0").unwrap(); +//! bugfix_release.increment_patch(); +//! +//! assert_eq!(Ok(bugfix_release), Version::parse("1.0.1")); +//! ``` +//! +//! When incrementing the minor version number, the patch number resets to zero +//! (in accordance with section 7 of the spec) +//! +//! ```{rust} +//! use semver::Version; +//! +//! let mut feature_release = Version::parse("1.4.6").unwrap(); +//! feature_release.increment_minor(); +//! +//! assert_eq!(Ok(feature_release), Version::parse("1.5.0")); +//! ``` +//! +//! Similarly, when incrementing the major version number, the patch and minor +//! numbers reset to zero (in accordance with section 8 of the spec) +//! +//! ```{rust} +//! use semver::Version; +//! +//! let mut chrome_release = Version::parse("41.5.5377").unwrap(); +//! chrome_release.increment_major(); +//! +//! assert_eq!(Ok(chrome_release), Version::parse("42.0.0")); +//! ``` +//! +//! ## Requirements +//! +//! The `semver` crate also provides the ability to compare requirements, which +//! are more complex comparisons. +//! +//! For example, creating a requirement that only matches versions greater than +//! or equal to 1.0.0: +//! +//! ```{rust} +//! # #![allow(unstable)] +//! use semver::Version; +//! use semver::VersionReq; +//! +//! let r = VersionReq::parse(">= 1.0.0").unwrap(); +//! let v = Version::parse("1.0.0").unwrap(); +//! +//! assert!(r.to_string() == ">= 1.0.0".to_string()); +//! assert!(r.matches(&v)) +//! ``` +//! +//! It also allows parsing of `~x.y.z` and `^x.y.z` requirements as defined at +//! https://www.npmjs.org/doc/misc/semver.html +//! +//! **Tilde requirements** specify a minimal version with some updates: +//! +//! ```notrust +//! ~1.2.3 := >=1.2.3 <1.3.0 +//! ~1.2 := >=1.2.0 <1.3.0 +//! ~1 := >=1.0.0 <2.0.0 +//! ``` +//! +//! **Caret requirements** allow SemVer compatible updates to a specified +//! verion, `0.x` and `0.x+1` are not considered compatible, but `1.x` and +//! `1.x+1` are. +//! +//! `0.0.x` is not considered compatible with any other version. +//! Missing minor and patch versions are desugared to `0` but allow flexibility +//! for that value. +//! +//! ```notrust +//! ^1.2.3 := >=1.2.3 <2.0.0 +//! ^0.2.3 := >=0.2.3 <0.3.0 +//! ^0.0.3 := >=0.0.3 <0.0.4 +//! ^0.0 := >=0.0.0 <0.1.0 +//! ^0 := >=0.0.0 <1.0.0 +//! ``` +//! +//! **Wildcard requirements** allows parsing of version requirements of the +//! formats `*`, `x.*` and `x.y.*`. +//! +//! ```notrust +//! * := >=0.0.0 +//! 1.* := >=1.0.0 <2.0.0 +//! 1.2.* := >=1.2.0 <1.3.0 +//! ``` + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico")] +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] + +extern crate semver_parser; + +// Serialization and deserialization support for version numbers +#[cfg(feature = "serde")] +extern crate serde; + +// We take the common approach of keeping our own module system private, and +// just re-exporting the interface that we want. + +pub use version::{Version, Identifier, SemVerError}; +pub use version::Identifier::{Numeric, AlphaNumeric}; +pub use version_req::{VersionReq, ReqParseError}; + +// SemVer-compliant versions. +mod version; + +// advanced version comparisons +mod version_req; diff --git a/third_party/cargo/vendor/semver-0.9.0/src/version.rs b/third_party/cargo/vendor/semver-0.9.0/src/version.rs new file mode 100644 index 0000000..38de133 --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/src/version.rs @@ -0,0 +1,759 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `version` module gives you tools to create and compare SemVer-compliant +//! versions. + +use std::cmp::{self, Ordering}; +use std::fmt; +use std::hash; +use std::error::Error; + +use std::result; +use std::str; + +use semver_parser; + +#[cfg(feature = "serde")] +use serde::ser::{Serialize, Serializer}; +#[cfg(feature = "serde")] +use serde::de::{self, Deserialize, Deserializer, Visitor}; + +/// An identifier in the pre-release or build metadata. +/// +/// See sections 9 and 10 of the spec for more about pre-release identifers and +/// build metadata. +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +pub enum Identifier { + /// An identifier that's solely numbers. + Numeric(u64), + /// An identifier with letters and numbers. + AlphaNumeric(String), +} + +impl From<semver_parser::version::Identifier> for Identifier { + fn from(other: semver_parser::version::Identifier) -> Identifier { + match other { + semver_parser::version::Identifier::Numeric(n) => Identifier::Numeric(n), + semver_parser::version::Identifier::AlphaNumeric(s) => Identifier::AlphaNumeric(s), + } + } +} + +impl fmt::Display for Identifier { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Identifier::Numeric(ref n) => fmt::Display::fmt(n, f), + Identifier::AlphaNumeric(ref s) => fmt::Display::fmt(s, f), + } + } +} + +#[cfg(feature = "serde")] +impl Serialize for Identifier { + fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error> + where S: Serializer + { + // Serialize Identifier as a number or string. + match *self { + Identifier::Numeric(n) => serializer.serialize_u64(n), + Identifier::AlphaNumeric(ref s) => serializer.serialize_str(s), + } + } +} + +#[cfg(feature = "serde")] +impl<'de> Deserialize<'de> for Identifier { + fn deserialize<D>(deserializer: D) -> result::Result<Self, D::Error> + where D: Deserializer<'de> + { + struct IdentifierVisitor; + + // Deserialize Identifier from a number or string. + impl<'de> Visitor<'de> for IdentifierVisitor { + type Value = Identifier; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a SemVer pre-release or build identifier") + } + + fn visit_u64<E>(self, numeric: u64) -> result::Result<Self::Value, E> + where E: de::Error + { + Ok(Identifier::Numeric(numeric)) + } + + fn visit_str<E>(self, alphanumeric: &str) -> result::Result<Self::Value, E> + where E: de::Error + { + Ok(Identifier::AlphaNumeric(alphanumeric.to_owned())) + } + } + + deserializer.deserialize_any(IdentifierVisitor) + } +} + +/// Represents a version number conforming to the semantic versioning scheme. +#[derive(Clone, Eq, Debug)] +pub struct Version { + /// The major version, to be incremented on incompatible changes. + pub major: u64, + /// The minor version, to be incremented when functionality is added in a + /// backwards-compatible manner. + pub minor: u64, + /// The patch version, to be incremented when backwards-compatible bug + /// fixes are made. + pub patch: u64, + /// The pre-release version identifier, if one exists. + pub pre: Vec<Identifier>, + /// The build metadata, ignored when determining version precedence. + pub build: Vec<Identifier>, +} + +impl From<semver_parser::version::Version> for Version { + fn from(other: semver_parser::version::Version) -> Version { + Version { + major: other.major, + minor: other.minor, + patch: other.patch, + pre: other.pre.into_iter().map(From::from).collect(), + build: other.build.into_iter().map(From::from).collect(), + } + } +} + +#[cfg(feature = "serde")] +impl Serialize for Version { + fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error> + where S: Serializer + { + // Serialize Version as a string. + serializer.collect_str(self) + } +} + +#[cfg(feature = "serde")] +impl<'de> Deserialize<'de> for Version { + fn deserialize<D>(deserializer: D) -> result::Result<Self, D::Error> + where D: Deserializer<'de> + { + struct VersionVisitor; + + // Deserialize Version from a string. + impl<'de> Visitor<'de> for VersionVisitor { + type Value = Version; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a SemVer version as a string") + } + + fn visit_str<E>(self, v: &str) -> result::Result<Self::Value, E> + where E: de::Error + { + Version::parse(v).map_err(de::Error::custom) + } + } + + deserializer.deserialize_str(VersionVisitor) + } +} + +/// An error type for this crate +/// +/// Currently, just a generic error. Will make this nicer later. +#[derive(Clone,PartialEq,Debug,PartialOrd)] +pub enum SemVerError { + /// An error ocurred while parsing. + ParseError(String), +} + +impl fmt::Display for SemVerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + &SemVerError::ParseError(ref m) => write!(f, "{}", m), + } + } +} + +impl Error for SemVerError { + fn description(&self) -> &str { + match self { + &SemVerError::ParseError(ref m) => m, + } + } +} + +/// A Result type for errors +pub type Result<T> = result::Result<T, SemVerError>; + +impl Version { + + /// Contructs the simple case without pre or build. + pub fn new(major: u64, minor: u64, patch: u64) -> Version { + Version { + major: major, + minor: minor, + patch: patch, + pre: Vec::new(), + build: Vec::new() + } + } + + /// Parse a string into a semver object. + pub fn parse(version: &str) -> Result<Version> { + let res = semver_parser::version::parse(version); + + match res { + // Convert plain String error into proper ParseError + Err(e) => Err(SemVerError::ParseError(e)), + Ok(v) => Ok(From::from(v)), + } + } + + /// Clears the build metadata + fn clear_metadata(&mut self) { + self.build = Vec::new(); + self.pre = Vec::new(); + } + + /// Increments the patch number for this Version (Must be mutable) + pub fn increment_patch(&mut self) { + self.patch += 1; + self.clear_metadata(); + } + + /// Increments the minor version number for this Version (Must be mutable) + /// + /// As instructed by section 7 of the spec, the patch number is reset to 0. + pub fn increment_minor(&mut self) { + self.minor += 1; + self.patch = 0; + self.clear_metadata(); + } + + /// Increments the major version number for this Version (Must be mutable) + /// + /// As instructed by section 8 of the spec, the minor and patch numbers are + /// reset to 0 + pub fn increment_major(&mut self) { + self.major += 1; + self.minor = 0; + self.patch = 0; + self.clear_metadata(); + } + + /// Checks to see if the current Version is in pre-release status + pub fn is_prerelease(&self) -> bool { + !self.pre.is_empty() + } +} + +impl str::FromStr for Version { + type Err = SemVerError; + + fn from_str(s: &str) -> Result<Version> { + Version::parse(s) + } +} + +impl fmt::Display for Version { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "{}.{}.{}", self.major, self.minor, self.patch)); + if !self.pre.is_empty() { + try!(write!(f, "-")); + for (i, x) in self.pre.iter().enumerate() { + if i != 0 { + try!(write!(f, ".")) + } + try!(write!(f, "{}", x)); + } + } + if !self.build.is_empty() { + try!(write!(f, "+")); + for (i, x) in self.build.iter().enumerate() { + if i != 0 { + try!(write!(f, ".")) + } + try!(write!(f, "{}", x)); + } + } + Ok(()) + } +} + +impl cmp::PartialEq for Version { + #[inline] + fn eq(&self, other: &Version) -> bool { + // We should ignore build metadata here, otherwise versions v1 and v2 + // can exist such that !(v1 < v2) && !(v1 > v2) && v1 != v2, which + // violate strict total ordering rules. + self.major == other.major && self.minor == other.minor && self.patch == other.patch && + self.pre == other.pre + } +} + +impl cmp::PartialOrd for Version { + fn partial_cmp(&self, other: &Version) -> Option<Ordering> { + Some(self.cmp(other)) + } +} + +impl cmp::Ord for Version { + fn cmp(&self, other: &Version) -> Ordering { + match self.major.cmp(&other.major) { + Ordering::Equal => {} + r => return r, + } + + match self.minor.cmp(&other.minor) { + Ordering::Equal => {} + r => return r, + } + + match self.patch.cmp(&other.patch) { + Ordering::Equal => {} + r => return r, + } + + // NB: semver spec says 0.0.0-pre < 0.0.0 + // but the version of ord defined for vec + // says that [] < [pre] so we alter it here + match (self.pre.len(), other.pre.len()) { + (0, 0) => Ordering::Equal, + (0, _) => Ordering::Greater, + (_, 0) => Ordering::Less, + (_, _) => self.pre.cmp(&other.pre), + } + } +} + +impl hash::Hash for Version { + fn hash<H: hash::Hasher>(&self, into: &mut H) { + self.major.hash(into); + self.minor.hash(into); + self.patch.hash(into); + self.pre.hash(into); + } +} + +impl From<(u64,u64,u64)> for Version { + fn from(tuple: (u64,u64,u64)) -> Version { + let (major, minor, patch) = tuple; + Version::new(major, minor, patch) + } +} + +#[cfg(test)] +mod tests { + use std::result; + use super::Version; + use super::Identifier; + use super::SemVerError; + + #[test] + fn test_parse() { + fn parse_error(e: &str) -> result::Result<Version, SemVerError> { + return Err(SemVerError::ParseError(e.to_string())); + } + + assert_eq!(Version::parse(""), + parse_error("Error parsing major identifier")); + assert_eq!(Version::parse(" "), + parse_error("Error parsing major identifier")); + assert_eq!(Version::parse("1"), + parse_error("Expected dot")); + assert_eq!(Version::parse("1.2"), + parse_error("Expected dot")); + assert_eq!(Version::parse("1.2.3-"), + parse_error("Error parsing prerelease")); + assert_eq!(Version::parse("a.b.c"), + parse_error("Error parsing major identifier")); + assert_eq!(Version::parse("1.2.3 abc"), + parse_error("Extra junk after valid version: abc")); + + assert_eq!(Version::parse("1.2.3"), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: Vec::new(), + build: Vec::new(), + })); + + assert_eq!(Version::parse("1.2.3"), + Ok(Version::new(1,2,3))); + + assert_eq!(Version::parse(" 1.2.3 "), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: Vec::new(), + build: Vec::new(), + })); + assert_eq!(Version::parse("1.2.3-alpha1"), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], + build: Vec::new(), + })); + assert_eq!(Version::parse(" 1.2.3-alpha1 "), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], + build: Vec::new(), + })); + assert_eq!(Version::parse("1.2.3+build5"), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: Vec::new(), + build: vec![Identifier::AlphaNumeric(String::from("build5"))], + })); + assert_eq!(Version::parse(" 1.2.3+build5 "), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: Vec::new(), + build: vec![Identifier::AlphaNumeric(String::from("build5"))], + })); + assert_eq!(Version::parse("1.2.3-alpha1+build5"), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], + build: vec![Identifier::AlphaNumeric(String::from("build5"))], + })); + assert_eq!(Version::parse(" 1.2.3-alpha1+build5 "), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], + build: vec![Identifier::AlphaNumeric(String::from("build5"))], + })); + assert_eq!(Version::parse("1.2.3-1.alpha1.9+build5.7.3aedf "), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec![Identifier::Numeric(1), + Identifier::AlphaNumeric(String::from("alpha1")), + Identifier::Numeric(9), + ], + build: vec![Identifier::AlphaNumeric(String::from("build5")), + Identifier::Numeric(7), + Identifier::AlphaNumeric(String::from("3aedf")), + ], + })); + assert_eq!(Version::parse("0.4.0-beta.1+0851523"), + Ok(Version { + major: 0, + minor: 4, + patch: 0, + pre: vec![Identifier::AlphaNumeric(String::from("beta")), + Identifier::Numeric(1), + ], + build: vec![Identifier::AlphaNumeric(String::from("0851523"))], + })); + + } + + #[test] + fn test_increment_patch() { + let mut buggy_release = Version::parse("0.1.0").unwrap(); + buggy_release.increment_patch(); + assert_eq!(buggy_release, Version::parse("0.1.1").unwrap()); + } + + #[test] + fn test_increment_minor() { + let mut feature_release = Version::parse("1.4.6").unwrap(); + feature_release.increment_minor(); + assert_eq!(feature_release, Version::parse("1.5.0").unwrap()); + } + + #[test] + fn test_increment_major() { + let mut chrome_release = Version::parse("46.1.246773").unwrap(); + chrome_release.increment_major(); + assert_eq!(chrome_release, Version::parse("47.0.0").unwrap()); + } + + #[test] + fn test_increment_keep_prerelease() { + let mut release = Version::parse("1.0.0-alpha").unwrap(); + release.increment_patch(); + + assert_eq!(release, Version::parse("1.0.1").unwrap()); + + release.increment_minor(); + + assert_eq!(release, Version::parse("1.1.0").unwrap()); + + release.increment_major(); + + assert_eq!(release, Version::parse("2.0.0").unwrap()); + } + + + #[test] + fn test_increment_clear_metadata() { + let mut release = Version::parse("1.0.0+4442").unwrap(); + release.increment_patch(); + + assert_eq!(release, Version::parse("1.0.1").unwrap()); + release = Version::parse("1.0.1+hello").unwrap(); + + release.increment_minor(); + + assert_eq!(release, Version::parse("1.1.0").unwrap()); + release = Version::parse("1.1.3747+hello").unwrap(); + + release.increment_major(); + + assert_eq!(release, Version::parse("2.0.0").unwrap()); + } + + #[test] + fn test_eq() { + assert_eq!(Version::parse("1.2.3"), Version::parse("1.2.3")); + assert_eq!(Version::parse("1.2.3-alpha1"), + Version::parse("1.2.3-alpha1")); + assert_eq!(Version::parse("1.2.3+build.42"), + Version::parse("1.2.3+build.42")); + assert_eq!(Version::parse("1.2.3-alpha1+42"), + Version::parse("1.2.3-alpha1+42")); + assert_eq!(Version::parse("1.2.3+23"), Version::parse("1.2.3+42")); + } + + #[test] + fn test_ne() { + assert!(Version::parse("0.0.0") != Version::parse("0.0.1")); + assert!(Version::parse("0.0.0") != Version::parse("0.1.0")); + assert!(Version::parse("0.0.0") != Version::parse("1.0.0")); + assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); + } + + #[test] + fn test_show() { + assert_eq!(format!("{}", Version::parse("1.2.3").unwrap()), + "1.2.3".to_string()); + assert_eq!(format!("{}", Version::parse("1.2.3-alpha1").unwrap()), + "1.2.3-alpha1".to_string()); + assert_eq!(format!("{}", Version::parse("1.2.3+build.42").unwrap()), + "1.2.3+build.42".to_string()); + assert_eq!(format!("{}", Version::parse("1.2.3-alpha1+42").unwrap()), + "1.2.3-alpha1+42".to_string()); + } + + #[test] + fn test_to_string() { + assert_eq!(Version::parse("1.2.3").unwrap().to_string(), + "1.2.3".to_string()); + assert_eq!(Version::parse("1.2.3-alpha1").unwrap().to_string(), + "1.2.3-alpha1".to_string()); + assert_eq!(Version::parse("1.2.3+build.42").unwrap().to_string(), + "1.2.3+build.42".to_string()); + assert_eq!(Version::parse("1.2.3-alpha1+42").unwrap().to_string(), + "1.2.3-alpha1+42".to_string()); + } + + #[test] + fn test_lt() { + assert!(Version::parse("0.0.0") < Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.0.0") < Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.0") < Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.3-alpha1") < Version::parse("1.2.3")); + assert!(Version::parse("1.2.3-alpha1") < Version::parse("1.2.3-alpha2")); + assert!(!(Version::parse("1.2.3-alpha2") < Version::parse("1.2.3-alpha2"))); + assert!(!(Version::parse("1.2.3+23") < Version::parse("1.2.3+42"))); + } + + #[test] + fn test_le() { + assert!(Version::parse("0.0.0") <= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.0.0") <= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.0") <= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.3-alpha1") <= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.3-alpha2") <= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.3+23") <= Version::parse("1.2.3+42")); + } + + #[test] + fn test_gt() { + assert!(Version::parse("1.2.3-alpha2") > Version::parse("0.0.0")); + assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.0.0")); + assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); + assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.3-alpha1")); + assert!(Version::parse("1.2.3") > Version::parse("1.2.3-alpha2")); + assert!(!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.3-alpha2"))); + assert!(!(Version::parse("1.2.3+23") > Version::parse("1.2.3+42"))); + } + + #[test] + fn test_ge() { + assert!(Version::parse("1.2.3-alpha2") >= Version::parse("0.0.0")); + assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.0.0")); + assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.0")); + assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha1")); + assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha2")); + assert!(Version::parse("1.2.3+23") >= Version::parse("1.2.3+42")); + } + + #[test] + fn test_prerelease_check() { + assert!(Version::parse("1.0.0").unwrap().is_prerelease() == false); + assert!(Version::parse("0.0.1").unwrap().is_prerelease() == false); + assert!(Version::parse("4.1.4-alpha").unwrap().is_prerelease()); + assert!(Version::parse("1.0.0-beta294296").unwrap().is_prerelease()); + } + + #[test] + fn test_spec_order() { + let vs = ["1.0.0-alpha", + "1.0.0-alpha.1", + "1.0.0-alpha.beta", + "1.0.0-beta", + "1.0.0-beta.2", + "1.0.0-beta.11", + "1.0.0-rc.1", + "1.0.0"]; + let mut i = 1; + while i < vs.len() { + let a = Version::parse(vs[i - 1]); + let b = Version::parse(vs[i]); + assert!(a < b, "nope {:?} < {:?}", a, b); + i += 1; + } + } + + #[test] + fn test_from_str() { + assert_eq!("1.2.3".parse(), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: Vec::new(), + build: Vec::new(), + })); + assert_eq!(" 1.2.3 ".parse(), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: Vec::new(), + build: Vec::new(), + })); + assert_eq!("1.2.3-alpha1".parse(), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], + build: Vec::new(), + })); + assert_eq!(" 1.2.3-alpha1 ".parse(), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], + build: Vec::new(), + })); + assert_eq!("1.2.3+build5".parse(), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: Vec::new(), + build: vec![Identifier::AlphaNumeric(String::from("build5"))], + })); + assert_eq!(" 1.2.3+build5 ".parse(), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: Vec::new(), + build: vec![Identifier::AlphaNumeric(String::from("build5"))], + })); + assert_eq!("1.2.3-alpha1+build5".parse(), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], + build: vec![Identifier::AlphaNumeric(String::from("build5"))], + })); + assert_eq!(" 1.2.3-alpha1+build5 ".parse(), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], + build: vec![Identifier::AlphaNumeric(String::from("build5"))], + })); + assert_eq!("1.2.3-1.alpha1.9+build5.7.3aedf ".parse(), + Ok(Version { + major: 1, + minor: 2, + patch: 3, + pre: vec![Identifier::Numeric(1), + Identifier::AlphaNumeric(String::from("alpha1")), + Identifier::Numeric(9), + ], + build: vec![Identifier::AlphaNumeric(String::from("build5")), + Identifier::Numeric(7), + Identifier::AlphaNumeric(String::from("3aedf")), + ], + })); + assert_eq!("0.4.0-beta.1+0851523".parse(), + Ok(Version { + major: 0, + minor: 4, + patch: 0, + pre: vec![Identifier::AlphaNumeric(String::from("beta")), + Identifier::Numeric(1), + ], + build: vec![Identifier::AlphaNumeric(String::from("0851523"))], + })); + + } + + #[test] + fn test_from_str_errors() { + fn parse_error(e: &str) -> result::Result<Version, SemVerError> { + return Err(SemVerError::ParseError(e.to_string())); + } + + assert_eq!("".parse(), parse_error("Error parsing major identifier")); + assert_eq!(" ".parse(), parse_error("Error parsing major identifier")); + assert_eq!("1".parse(), parse_error("Expected dot")); + assert_eq!("1.2".parse(), + parse_error("Expected dot")); + assert_eq!("1.2.3-".parse(), + parse_error("Error parsing prerelease")); + assert_eq!("a.b.c".parse(), + parse_error("Error parsing major identifier")); + assert_eq!("1.2.3 abc".parse(), + parse_error("Extra junk after valid version: abc")); + } +} diff --git a/third_party/cargo/vendor/semver-0.9.0/src/version_req.rs b/third_party/cargo/vendor/semver-0.9.0/src/version_req.rs new file mode 100644 index 0000000..6e6a542 --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/src/version_req.rs @@ -0,0 +1,895 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::error::Error; +use std::fmt; +use std::result; +use std::str; + +use Version; +use version::Identifier; +use semver_parser; + +#[cfg(feature = "serde")] +use serde::ser::{Serialize, Serializer}; +#[cfg(feature = "serde")] +use serde::de::{self, Deserialize, Deserializer, Visitor}; + +use self::Op::{Ex, Gt, GtEq, Lt, LtEq, Tilde, Compatible, Wildcard}; +use self::WildcardVersion::{Major, Minor, Patch}; +use self::ReqParseError::*; + +/// A `VersionReq` is a struct containing a list of predicates that can apply to ranges of version +/// numbers. Matching operations can then be done with the `VersionReq` against a particular +/// version to see if it satisfies some or all of the constraints. +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +pub struct VersionReq { + predicates: Vec<Predicate>, +} + +impl From<semver_parser::range::VersionReq> for VersionReq { + fn from(other: semver_parser::range::VersionReq) -> VersionReq { + VersionReq { predicates: other.predicates.into_iter().map(From::from).collect() } + } +} + +#[cfg(feature = "serde")] +impl Serialize for VersionReq { + fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error> + where S: Serializer + { + // Serialize VersionReq as a string. + serializer.collect_str(self) + } +} + +#[cfg(feature = "serde")] +impl<'de> Deserialize<'de> for VersionReq { + fn deserialize<D>(deserializer: D) -> result::Result<Self, D::Error> + where D: Deserializer<'de> + { + struct VersionReqVisitor; + + /// Deserialize `VersionReq` from a string. + impl<'de> Visitor<'de> for VersionReqVisitor { + type Value = VersionReq; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a SemVer version requirement as a string") + } + + fn visit_str<E>(self, v: &str) -> result::Result<Self::Value, E> + where E: de::Error + { + VersionReq::parse(v).map_err(de::Error::custom) + } + } + + deserializer.deserialize_str(VersionReqVisitor) + } +} + +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +enum WildcardVersion { + Major, + Minor, + Patch, +} + +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +enum Op { + Ex, // Exact + Gt, // Greater than + GtEq, // Greater than or equal to + Lt, // Less than + LtEq, // Less than or equal to + Tilde, // e.g. ~1.0.0 + Compatible, // compatible by definition of semver, indicated by ^ + Wildcard(WildcardVersion), // x.y.*, x.*, * +} + +impl From<semver_parser::range::Op> for Op { + fn from(other: semver_parser::range::Op) -> Op { + use semver_parser::range; + match other { + range::Op::Ex => Op::Ex, + range::Op::Gt => Op::Gt, + range::Op::GtEq => Op::GtEq, + range::Op::Lt => Op::Lt, + range::Op::LtEq => Op::LtEq, + range::Op::Tilde => Op::Tilde, + range::Op::Compatible => Op::Compatible, + range::Op::Wildcard(version) => { + match version { + range::WildcardVersion::Major => Op::Wildcard(WildcardVersion::Major), + range::WildcardVersion::Minor => Op::Wildcard(WildcardVersion::Minor), + range::WildcardVersion::Patch => Op::Wildcard(WildcardVersion::Patch), + } + } + } + } +} + +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +struct Predicate { + op: Op, + major: u64, + minor: Option<u64>, + patch: Option<u64>, + pre: Vec<Identifier>, +} + +impl From<semver_parser::range::Predicate> for Predicate { + fn from(other: semver_parser::range::Predicate) -> Predicate { + Predicate { + op: From::from(other.op), + major: other.major, + minor: other.minor, + patch: other.patch, + pre: other.pre.into_iter().map(From::from).collect(), + } + } +} + +/// A `ReqParseError` is returned from methods which parse a string into a `VersionReq`. Each +/// enumeration is one of the possible errors that can occur. +#[derive(Clone, Debug, PartialEq)] +pub enum ReqParseError { + /// The given version requirement is invalid. + InvalidVersionRequirement, + /// You have already provided an operation, such as `=`, `~`, or `^`. Only use one. + OpAlreadySet, + /// The sigil you have written is not correct. + InvalidSigil, + /// All components of a version must be numeric. + VersionComponentsMustBeNumeric, + /// There was an error parsing an identifier. + InvalidIdentifier, + /// At least a major version is required. + MajorVersionRequired, + /// An unimplemented version requirement. + UnimplementedVersionRequirement, + /// This form of requirement is deprecated. + DeprecatedVersionRequirement(VersionReq), +} + +impl fmt::Display for ReqParseError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.description().fmt(f) + } +} + +impl Error for ReqParseError { + fn description(&self) -> &str { + match self { + &InvalidVersionRequirement => "the given version requirement is invalid", + &OpAlreadySet => { + "you have already provided an operation, such as =, ~, or ^; only use one" + }, + &InvalidSigil => "the sigil you have written is not correct", + &VersionComponentsMustBeNumeric => "version components must be numeric", + &InvalidIdentifier => "invalid identifier", + &MajorVersionRequired => "at least a major version number is required", + &UnimplementedVersionRequirement => { + "the given version requirement is not implemented, yet" + }, + &DeprecatedVersionRequirement(_) => "This requirement is deprecated", + } + } +} + +impl From<String> for ReqParseError { + fn from(other: String) -> ReqParseError { + match &*other { + "Null is not a valid VersionReq" => ReqParseError::InvalidVersionRequirement, + "VersionReq did not parse properly." => ReqParseError::OpAlreadySet, + _ => ReqParseError::InvalidVersionRequirement, + } + } +} + +impl VersionReq { + /// `any()` is a factory method which creates a `VersionReq` with no constraints. In other + /// words, any version will match against it. + /// + /// # Examples + /// + /// ``` + /// use semver::VersionReq; + /// + /// let anything = VersionReq::any(); + /// ``` + pub fn any() -> VersionReq { + VersionReq { predicates: vec![] } + } + + /// `parse()` is the main constructor of a `VersionReq`. It takes a string like `"^1.2.3"` + /// and turns it into a `VersionReq` that matches that particular constraint. + /// + /// A `Result` is returned which contains a `ReqParseError` if there was a problem parsing the + /// `VersionReq`. + /// + /// # Examples + /// + /// ``` + /// use semver::VersionReq; + /// + /// let version = VersionReq::parse("=1.2.3"); + /// let version = VersionReq::parse(">1.2.3"); + /// let version = VersionReq::parse("<1.2.3"); + /// let version = VersionReq::parse("~1.2.3"); + /// let version = VersionReq::parse("^1.2.3"); + /// let version = VersionReq::parse("1.2.3"); // synonym for ^1.2.3 + /// let version = VersionReq::parse("<=1.2.3"); + /// let version = VersionReq::parse(">=1.2.3"); + /// ``` + /// + /// This example demonstrates error handling, and will panic. + /// + /// ```should-panic + /// use semver::VersionReq; + /// + /// let version = match VersionReq::parse("not a version") { + /// Ok(version) => version, + /// Err(e) => panic!("There was a problem parsing: {}", e), + /// } + /// ``` + pub fn parse(input: &str) -> Result<VersionReq, ReqParseError> { + let res = semver_parser::range::parse(input); + + if let Ok(v) = res { + return Ok(From::from(v)); + } + + return match VersionReq::parse_deprecated(input) { + Some(v) => { + Err(ReqParseError::DeprecatedVersionRequirement(v)) + } + None => Err(From::from(res.err().unwrap())), + } + } + + fn parse_deprecated(version: &str) -> Option<VersionReq> { + return match version { + ".*" => Some(VersionReq::any()), + "0.1.0." => Some(VersionReq::parse("0.1.0").unwrap()), + "0.3.1.3" => Some(VersionReq::parse("0.3.13").unwrap()), + "0.2*" => Some(VersionReq::parse("0.2.*").unwrap()), + "*.0" => Some(VersionReq::any()), + _ => None, + } + } + + /// `exact()` is a factory method which creates a `VersionReq` with one exact constraint. + /// + /// # Examples + /// + /// ``` + /// use semver::VersionReq; + /// use semver::Version; + /// + /// let version = Version { major: 1, minor: 1, patch: 1, pre: vec![], build: vec![] }; + /// let exact = VersionReq::exact(&version); + /// ``` + pub fn exact(version: &Version) -> VersionReq { + VersionReq { predicates: vec![Predicate::exact(version)] } + } + + /// `matches()` matches a given `Version` against this `VersionReq`. + /// + /// # Examples + /// + /// ``` + /// use semver::VersionReq; + /// use semver::Version; + /// + /// let version = Version { major: 1, minor: 1, patch: 1, pre: vec![], build: vec![] }; + /// let exact = VersionReq::exact(&version); + /// + /// assert!(exact.matches(&version)); + /// ``` + pub fn matches(&self, version: &Version) -> bool { + // no predicates means anything matches + if self.predicates.is_empty() { + return true; + } + + self.predicates.iter().all(|p| p.matches(version)) && + self.predicates.iter().any(|p| p.pre_tag_is_compatible(version)) + } +} + +impl str::FromStr for VersionReq { + type Err = ReqParseError; + + fn from_str(s: &str) -> Result<VersionReq, ReqParseError> { + VersionReq::parse(s) + } +} + +impl Predicate { + fn exact(version: &Version) -> Predicate { + Predicate { + op: Ex, + major: version.major, + minor: Some(version.minor), + patch: Some(version.patch), + pre: version.pre.clone(), + } + } + + /// `matches()` takes a `Version` and determines if it matches this particular `Predicate`. + pub fn matches(&self, ver: &Version) -> bool { + match self.op { + Ex => self.is_exact(ver), + Gt => self.is_greater(ver), + GtEq => self.is_exact(ver) || self.is_greater(ver), + Lt => !self.is_exact(ver) && !self.is_greater(ver), + LtEq => !self.is_greater(ver), + Tilde => self.matches_tilde(ver), + Compatible => self.is_compatible(ver), + Wildcard(_) => self.matches_wildcard(ver), + } + } + + fn is_exact(&self, ver: &Version) -> bool { + if self.major != ver.major { + return false; + } + + match self.minor { + Some(minor) => { + if minor != ver.minor { + return false; + } + } + None => return true, + } + + match self.patch { + Some(patch) => { + if patch != ver.patch { + return false; + } + } + None => return true, + } + + if self.pre != ver.pre { + return false; + } + + true + } + + // https://docs.npmjs.com/misc/semver#prerelease-tags + fn pre_tag_is_compatible(&self, ver: &Version) -> bool { + // If a version has a prerelease tag (for example, 1.2.3-alpha.3) then it will + // only be + // allowed to satisfy comparator sets if at least one comparator with the same + // [major, + // minor, patch] tuple also has a prerelease tag. + !ver.is_prerelease() || + (self.major == ver.major && self.minor == Some(ver.minor) && + self.patch == Some(ver.patch) && !self.pre.is_empty()) + } + + fn is_greater(&self, ver: &Version) -> bool { + if self.major != ver.major { + return ver.major > self.major; + } + + match self.minor { + Some(minor) => { + if minor != ver.minor { + return ver.minor > minor; + } + } + None => return false, + } + + match self.patch { + Some(patch) => { + if patch != ver.patch { + return ver.patch > patch; + } + } + None => return false, + } + + if !self.pre.is_empty() { + return ver.pre.is_empty() || ver.pre > self.pre; + } + + false + } + + // see https://www.npmjs.org/doc/misc/semver.html for behavior + fn matches_tilde(&self, ver: &Version) -> bool { + let minor = match self.minor { + Some(n) => n, + None => return self.major == ver.major, + }; + + match self.patch { + Some(patch) => { + self.major == ver.major && minor == ver.minor && + (ver.patch > patch || (ver.patch == patch && self.pre_is_compatible(ver))) + } + None => self.major == ver.major && minor == ver.minor, + } + } + + // see https://www.npmjs.org/doc/misc/semver.html for behavior + fn is_compatible(&self, ver: &Version) -> bool { + if self.major != ver.major { + return false; + } + + let minor = match self.minor { + Some(n) => n, + None => return self.major == ver.major, + }; + + match self.patch { + Some(patch) => { + if self.major == 0 { + if minor == 0 { + ver.minor == minor && ver.patch == patch && self.pre_is_compatible(ver) + } else { + ver.minor == minor && + (ver.patch > patch || (ver.patch == patch && self.pre_is_compatible(ver))) + } + } else { + ver.minor > minor || + (ver.minor == minor && + (ver.patch > patch || (ver.patch == patch && self.pre_is_compatible(ver)))) + } + } + None => { + if self.major == 0 { + ver.minor == minor + } else { + ver.minor >= minor + } + } + } + } + + fn pre_is_compatible(&self, ver: &Version) -> bool { + ver.pre.is_empty() || ver.pre >= self.pre + } + + // see https://www.npmjs.org/doc/misc/semver.html for behavior + fn matches_wildcard(&self, ver: &Version) -> bool { + match self.op { + Wildcard(Major) => true, + Wildcard(Minor) => self.major == ver.major, + Wildcard(Patch) => { + match self.minor { + Some(minor) => self.major == ver.major && minor == ver.minor, + None => { + // minor and patch version astericks mean match on major + self.major == ver.major + } + } + } + _ => false, // unreachable + } + } +} + +impl fmt::Display for VersionReq { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + if self.predicates.is_empty() { + try!(write!(fmt, "*")); + } else { + for (i, ref pred) in self.predicates.iter().enumerate() { + if i == 0 { + try!(write!(fmt, "{}", pred)); + } else { + try!(write!(fmt, ", {}", pred)); + } + } + } + + Ok(()) + } +} + +impl fmt::Display for Predicate { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.op { + Wildcard(Major) => try!(write!(fmt, "*")), + Wildcard(Minor) => try!(write!(fmt, "{}.*", self.major)), + Wildcard(Patch) => { + if let Some(minor) = self.minor { + try!(write!(fmt, "{}.{}.*", self.major, minor)) + } else { + try!(write!(fmt, "{}.*.*", self.major)) + } + } + _ => { + try!(write!(fmt, "{}{}", self.op, self.major)); + + match self.minor { + Some(v) => try!(write!(fmt, ".{}", v)), + None => (), + } + + match self.patch { + Some(v) => try!(write!(fmt, ".{}", v)), + None => (), + } + + if !self.pre.is_empty() { + try!(write!(fmt, "-")); + for (i, x) in self.pre.iter().enumerate() { + if i != 0 { + try!(write!(fmt, ".")) + } + try!(write!(fmt, "{}", x)); + } + } + } + } + + Ok(()) + } +} + +impl fmt::Display for Op { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Ex => try!(write!(fmt, "= ")), + Gt => try!(write!(fmt, "> ")), + GtEq => try!(write!(fmt, ">= ")), + Lt => try!(write!(fmt, "< ")), + LtEq => try!(write!(fmt, "<= ")), + Tilde => try!(write!(fmt, "~")), + Compatible => try!(write!(fmt, "^")), + // gets handled specially in Predicate::fmt + Wildcard(_) => try!(write!(fmt, "")), + } + Ok(()) + } +} + +#[cfg(test)] +mod test { + use super::{VersionReq, Op}; + use super::super::version::Version; + use std::hash::{Hash, Hasher}; + + fn req(s: &str) -> VersionReq { + VersionReq::parse(s).unwrap() + } + + fn version(s: &str) -> Version { + match Version::parse(s) { + Ok(v) => v, + Err(e) => panic!("`{}` is not a valid version. Reason: {:?}", s, e), + } + } + + fn assert_match(req: &VersionReq, vers: &[&str]) { + for ver in vers.iter() { + assert!(req.matches(&version(*ver)), "did not match {}", ver); + } + } + + fn assert_not_match(req: &VersionReq, vers: &[&str]) { + for ver in vers.iter() { + assert!(!req.matches(&version(*ver)), "matched {}", ver); + } + } + + fn calculate_hash<T: Hash>(t: T) -> u64 { + use std::collections::hash_map::DefaultHasher; + + let mut s = DefaultHasher::new(); + t.hash(&mut s); + s.finish() + } + + #[test] + fn test_parsing_default() { + let r = req("1.0.0"); + + assert_eq!(r.to_string(), "^1.0.0".to_string()); + + assert_match(&r, &["1.0.0", "1.0.1"]); + assert_not_match(&r, &["0.9.9", "0.10.0", "0.1.0"]); + } + + #[test] + fn test_parsing_exact() { + let r = req("=1.0.0"); + + assert!(r.to_string() == "= 1.0.0".to_string()); + assert_eq!(r.to_string(), "= 1.0.0".to_string()); + + assert_match(&r, &["1.0.0"]); + assert_not_match(&r, &["1.0.1", "0.9.9", "0.10.0", "0.1.0", "1.0.0-pre"]); + + let r = req("=0.9.0"); + + assert_eq!(r.to_string(), "= 0.9.0".to_string()); + + assert_match(&r, &["0.9.0"]); + assert_not_match(&r, &["0.9.1", "1.9.0", "0.0.9"]); + + let r = req("=0.1.0-beta2.a"); + + assert_eq!(r.to_string(), "= 0.1.0-beta2.a".to_string()); + + assert_match(&r, &["0.1.0-beta2.a"]); + assert_not_match(&r, &["0.9.1", "0.1.0", "0.1.1-beta2.a", "0.1.0-beta2"]); + } + + #[test] + fn test_parse_metadata_see_issue_88_see_issue_88() { + for op in &[Op::Compatible, Op::Ex, Op::Gt, Op::GtEq, Op::Lt, Op::LtEq, Op::Tilde] { + req(&format!("{} 1.2.3+meta", op)); + } + } + + #[test] + pub fn test_parsing_greater_than() { + let r = req(">= 1.0.0"); + + assert_eq!(r.to_string(), ">= 1.0.0".to_string()); + + assert_match(&r, &["1.0.0", "2.0.0"]); + assert_not_match(&r, &["0.1.0", "0.0.1", "1.0.0-pre", "2.0.0-pre"]); + + let r = req(">= 2.1.0-alpha2"); + + assert_match(&r, &["2.1.0-alpha2", "2.1.0-alpha3", "2.1.0", "3.0.0"]); + assert_not_match(&r, + &["2.0.0", "2.1.0-alpha1", "2.0.0-alpha2", "3.0.0-alpha2"]); + } + + #[test] + pub fn test_parsing_less_than() { + let r = req("< 1.0.0"); + + assert_eq!(r.to_string(), "< 1.0.0".to_string()); + + assert_match(&r, &["0.1.0", "0.0.1"]); + assert_not_match(&r, &["1.0.0", "1.0.0-beta", "1.0.1", "0.9.9-alpha"]); + + let r = req("<= 2.1.0-alpha2"); + + assert_match(&r, &["2.1.0-alpha2", "2.1.0-alpha1", "2.0.0", "1.0.0"]); + assert_not_match(&r, + &["2.1.0", "2.2.0-alpha1", "2.0.0-alpha2", "1.0.0-alpha2"]); + } + + #[test] + pub fn test_multiple() { + let r = req("> 0.0.9, <= 2.5.3"); + assert_eq!(r.to_string(), "> 0.0.9, <= 2.5.3".to_string()); + assert_match(&r, &["0.0.10", "1.0.0", "2.5.3"]); + assert_not_match(&r, &["0.0.8", "2.5.4"]); + + let r = req("0.3.0, 0.4.0"); + assert_eq!(r.to_string(), "^0.3.0, ^0.4.0".to_string()); + assert_not_match(&r, &["0.0.8", "0.3.0", "0.4.0"]); + + let r = req("<= 0.2.0, >= 0.5.0"); + assert_eq!(r.to_string(), "<= 0.2.0, >= 0.5.0".to_string()); + assert_not_match(&r, &["0.0.8", "0.3.0", "0.5.1"]); + + let r = req("0.1.0, 0.1.4, 0.1.6"); + assert_eq!(r.to_string(), "^0.1.0, ^0.1.4, ^0.1.6".to_string()); + assert_match(&r, &["0.1.6", "0.1.9"]); + assert_not_match(&r, &["0.1.0", "0.1.4", "0.2.0"]); + + assert!(VersionReq::parse("> 0.1.0,").is_err()); + assert!(VersionReq::parse("> 0.3.0, ,").is_err()); + + let r = req(">=0.5.1-alpha3, <0.6"); + assert_eq!(r.to_string(), ">= 0.5.1-alpha3, < 0.6".to_string()); + assert_match(&r, + &["0.5.1-alpha3", "0.5.1-alpha4", "0.5.1-beta", "0.5.1", "0.5.5"]); + assert_not_match(&r, + &["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre"]); + assert_not_match(&r, &["0.6.0", "0.6.0-pre"]); + } + + #[test] + pub fn test_parsing_tilde() { + let r = req("~1"); + assert_match(&r, &["1.0.0", "1.0.1", "1.1.1"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "0.0.9"]); + + let r = req("~1.2"); + assert_match(&r, &["1.2.0", "1.2.1"]); + assert_not_match(&r, &["1.1.1", "1.3.0", "0.0.9"]); + + let r = req("~1.2.2"); + assert_match(&r, &["1.2.2", "1.2.4"]); + assert_not_match(&r, &["1.2.1", "1.9.0", "1.0.9", "2.0.1", "0.1.3"]); + + let r = req("~1.2.3-beta.2"); + assert_match(&r, &["1.2.3", "1.2.4", "1.2.3-beta.2", "1.2.3-beta.4"]); + assert_not_match(&r, &["1.3.3", "1.1.4", "1.2.3-beta.1", "1.2.4-beta.2"]); + } + + #[test] + pub fn test_parsing_compatible() { + let r = req("^1"); + assert_match(&r, &["1.1.2", "1.1.0", "1.2.1", "1.0.1"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "0.1.4"]); + assert_not_match(&r, &["1.0.0-beta1", "0.1.0-alpha", "1.0.1-pre"]); + + let r = req("^1.1"); + assert_match(&r, &["1.1.2", "1.1.0", "1.2.1"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "1.0.1", "0.1.4"]); + + let r = req("^1.1.2"); + assert_match(&r, &["1.1.2", "1.1.4", "1.2.1"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]); + assert_not_match(&r, &["1.1.2-alpha1", "1.1.3-alpha1", "2.9.0-alpha1"]); + + let r = req("^0.1.2"); + assert_match(&r, &["0.1.2", "0.1.4"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]); + assert_not_match(&r, &["0.1.2-beta", "0.1.3-alpha", "0.2.0-pre"]); + + let r = req("^0.5.1-alpha3"); + assert_match(&r, + &["0.5.1-alpha3", "0.5.1-alpha4", "0.5.1-beta", "0.5.1", "0.5.5"]); + assert_not_match(&r, + &["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre", "0.6.0"]); + + let r = req("^0.0.2"); + assert_match(&r, &["0.0.2"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.4"]); + + let r = req("^0.0"); + assert_match(&r, &["0.0.2", "0.0.0"]); + assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.1.4"]); + + let r = req("^0"); + assert_match(&r, &["0.9.1", "0.0.2", "0.0.0"]); + assert_not_match(&r, &["2.9.0", "1.1.1"]); + + let r = req("^1.4.2-beta.5"); + assert_match(&r, + &["1.4.2", "1.4.3", "1.4.2-beta.5", "1.4.2-beta.6", "1.4.2-c"]); + assert_not_match(&r, + &["0.9.9", "2.0.0", "1.4.2-alpha", "1.4.2-beta.4", "1.4.3-beta.5"]); + } + + #[test] + pub fn test_parsing_wildcard() { + let r = req(""); + assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]); + assert_not_match(&r, &[]); + let r = req("*"); + assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]); + assert_not_match(&r, &[]); + let r = req("x"); + assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]); + assert_not_match(&r, &[]); + let r = req("X"); + assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]); + assert_not_match(&r, &[]); + + let r = req("1.*"); + assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]); + assert_not_match(&r, &["0.0.9"]); + let r = req("1.x"); + assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]); + assert_not_match(&r, &["0.0.9"]); + let r = req("1.X"); + assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]); + assert_not_match(&r, &["0.0.9"]); + + let r = req("1.2.*"); + assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]); + assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]); + let r = req("1.2.x"); + assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]); + assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]); + let r = req("1.2.X"); + assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]); + assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]); + } + + #[test] + pub fn test_any() { + let r = VersionReq::any(); + assert_match(&r, &["0.0.1", "0.1.0", "1.0.0"]); + } + + #[test] + pub fn test_pre() { + let r = req("=2.1.1-really.0"); + assert_match(&r, &["2.1.1-really.0"]); + } + + // #[test] + // pub fn test_parse_errors() { + // assert_eq!(Err(InvalidVersionRequirement), VersionReq::parse("\0")); + // assert_eq!(Err(OpAlreadySet), VersionReq::parse(">= >= 0.0.2")); + // assert_eq!(Err(InvalidSigil), VersionReq::parse(">== 0.0.2")); + // assert_eq!(Err(VersionComponentsMustBeNumeric), + // VersionReq::parse("a.0.0")); + // assert_eq!(Err(InvalidIdentifier), VersionReq::parse("1.0.0-")); + // assert_eq!(Err(MajorVersionRequired), VersionReq::parse(">=")); + // } + + #[test] + pub fn test_from_str() { + assert_eq!("1.0.0".parse::<VersionReq>().unwrap().to_string(), + "^1.0.0".to_string()); + assert_eq!("=1.0.0".parse::<VersionReq>().unwrap().to_string(), + "= 1.0.0".to_string()); + assert_eq!("~1".parse::<VersionReq>().unwrap().to_string(), + "~1".to_string()); + assert_eq!("~1.2".parse::<VersionReq>().unwrap().to_string(), + "~1.2".to_string()); + assert_eq!("^1".parse::<VersionReq>().unwrap().to_string(), + "^1".to_string()); + assert_eq!("^1.1".parse::<VersionReq>().unwrap().to_string(), + "^1.1".to_string()); + assert_eq!("*".parse::<VersionReq>().unwrap().to_string(), + "*".to_string()); + assert_eq!("1.*".parse::<VersionReq>().unwrap().to_string(), + "1.*".to_string()); + assert_eq!("< 1.0.0".parse::<VersionReq>().unwrap().to_string(), + "< 1.0.0".to_string()); + } + + // #[test] + // pub fn test_from_str_errors() { + // assert_eq!(Err(InvalidVersionRequirement), "\0".parse::<VersionReq>()); + // assert_eq!(Err(OpAlreadySet), ">= >= 0.0.2".parse::<VersionReq>()); + // assert_eq!(Err(InvalidSigil), ">== 0.0.2".parse::<VersionReq>()); + // assert_eq!(Err(VersionComponentsMustBeNumeric), + // "a.0.0".parse::<VersionReq>()); + // assert_eq!(Err(InvalidIdentifier), "1.0.0-".parse::<VersionReq>()); + // assert_eq!(Err(MajorVersionRequired), ">=".parse::<VersionReq>()); + // } + + #[test] + fn test_cargo3202() { + let v = "0.*.*".parse::<VersionReq>().unwrap(); + assert_eq!("0.*.*", format!("{}", v.predicates[0])); + + let v = "0.0.*".parse::<VersionReq>().unwrap(); + assert_eq!("0.0.*", format!("{}", v.predicates[0])); + + let r = req("0.*.*"); + assert_match(&r, &["0.5.0"]); + } + + #[test] + fn test_eq_hash() { + assert!(req("^1") == req("^1")); + assert!(calculate_hash(req("^1")) == calculate_hash(req("^1"))); + assert!(req("^1") != req("^2")); + } + + #[test] + fn test_ordering() { + assert!(req("=1") < req("*")); + assert!(req(">1") < req("*")); + assert!(req(">=1") < req("*")); + assert!(req("<1") < req("*")); + assert!(req("<=1") < req("*")); + assert!(req("~1") < req("*")); + assert!(req("^1") < req("*")); + assert!(req("*") == req("*")); + } +} diff --git a/third_party/cargo/vendor/semver-0.9.0/tests/deprecation.rs b/third_party/cargo/vendor/semver-0.9.0/tests/deprecation.rs new file mode 100644 index 0000000..a5f533a --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/tests/deprecation.rs @@ -0,0 +1,22 @@ +extern crate semver; + +#[test] +fn test_regressions() { + use semver::VersionReq; + use semver::ReqParseError; + + let versions = vec![ + (".*", VersionReq::any()), + ("0.1.0.", VersionReq::parse("0.1.0").unwrap()), + ("0.3.1.3", VersionReq::parse("0.3.13").unwrap()), + ("0.2*", VersionReq::parse("0.2.*").unwrap()), + ("*.0", VersionReq::any()), + ]; + + for (version, requirement) in versions.into_iter() { + let parsed = VersionReq::parse(version); + let error = parsed.err().unwrap(); + + assert_eq!(ReqParseError::DeprecatedVersionRequirement(requirement), error); + } +} diff --git a/third_party/cargo/vendor/semver-0.9.0/tests/regression.rs b/third_party/cargo/vendor/semver-0.9.0/tests/regression.rs new file mode 100644 index 0000000..ef568a7 --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/tests/regression.rs @@ -0,0 +1,25 @@ +extern crate semver; +extern crate crates_index; +extern crate tempdir; + +// This test checks to see if every existing crate parses successfully. Important to not break the +// Rust universe! + +#[cfg(feature = "ci")] +#[test] +fn test_regressions() { + use tempdir::TempDir; + use crates_index::Index; + use semver::Version; + + let dir = TempDir::new("semver").unwrap(); + let index = Index::new(dir.into_path()); + index.clone().unwrap(); + + for krate in index.crates() { + for version in krate.versions() { + let v = version.version(); + assert!(Version::parse(v).is_ok(), "failed: {} ({})", version.name(), v); + } + } +} diff --git a/third_party/cargo/vendor/semver-0.9.0/tests/serde.rs b/third_party/cargo/vendor/semver-0.9.0/tests/serde.rs new file mode 100644 index 0000000..bcb9264 --- /dev/null +++ b/third_party/cargo/vendor/semver-0.9.0/tests/serde.rs @@ -0,0 +1,90 @@ +#![cfg(feature = "serde")] + +#[macro_use] +extern crate serde_derive; + +extern crate semver; +extern crate serde_json; + +use semver::{Identifier, Version, VersionReq}; + +#[derive(Serialize, Deserialize, PartialEq, Debug)] +struct Identified { + name: String, + identifier: Identifier, +} + +#[derive(Serialize, Deserialize, PartialEq, Debug)] +struct Versioned { + name: String, + vers: Version, +} + +#[test] +fn serialize_identifier() { + let id = Identified { + name: "serde".to_owned(), + identifier: Identifier::Numeric(100), + }; + let j = serde_json::to_string(&id).unwrap(); + assert_eq!(j, r#"{"name":"serde","identifier":100}"#); + + let id = Identified { + name: "serde".to_owned(), + identifier: Identifier::AlphaNumeric("b100".to_owned()), + }; + let j = serde_json::to_string(&id).unwrap(); + assert_eq!(j, r#"{"name":"serde","identifier":"b100"}"#); +} + +#[test] +fn deserialize_identifier() { + let j = r#"{"name":"serde","identifier":100}"#; + let id = serde_json::from_str::<Identified>(j).unwrap(); + let expected = Identified { + name: "serde".to_owned(), + identifier: Identifier::Numeric(100), + }; + assert_eq!(id, expected); + + let j = r#"{"name":"serde","identifier":"b100"}"#; + let id = serde_json::from_str::<Identified>(j).unwrap(); + let expected = Identified { + name: "serde".to_owned(), + identifier: Identifier::AlphaNumeric("b100".to_owned()), + }; + assert_eq!(id, expected); +} + +#[test] +fn serialize_version() { + let v = Versioned { + name: "serde".to_owned(), + vers: Version::parse("1.0.0").unwrap(), + }; + let j = serde_json::to_string(&v).unwrap(); + assert_eq!(j, r#"{"name":"serde","vers":"1.0.0"}"#); +} + +#[test] +fn deserialize_version() { + let j = r#"{"name":"serde","vers":"1.0.0"}"#; + let v = serde_json::from_str::<Versioned>(j).unwrap(); + let expected = Versioned { + name: "serde".to_owned(), + vers: Version::parse("1.0.0").unwrap(), + }; + assert_eq!(v, expected); +} + +#[test] +fn serialize_versionreq() { + let v = VersionReq::exact(&Version::parse("1.0.0").unwrap()); + + assert_eq!(serde_json::to_string(&v).unwrap(), r#""= 1.0.0""#); +} + +#[test] +fn deserialize_versionreq() { + assert_eq!("1.0.0".parse::<VersionReq>().unwrap(), serde_json::from_str(r#""1.0.0""#).unwrap()); +} diff --git a/third_party/cargo/vendor/semver-parser-0.7.0/.cargo-checksum.json b/third_party/cargo/vendor/semver-parser-0.7.0/.cargo-checksum.json new file mode 100644 index 0000000..73575fe --- /dev/null +++ b/third_party/cargo/vendor/semver-parser-0.7.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"67597114802114d2a7fdb457c1cf5f7e0c951b21e287c6a47b9a86b9028cf64d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"d38feaa4f9468cd1e0ece22e0ad2eadfe6195a9a0a3843b7c722d5c7d81804fb","src/common.rs":"dc42336abd34e19ca9f732f33657e106f98dcc8c10d4c2564bc4f160cb31926e","src/lib.rs":"3ac8ef5a280344a25cb18ac386034c0fee8d64060fa14af5e25ed49f0cb2fd9e","src/range.rs":"3596f048d466d43887aff1e8c8c834476672a4627631ed35379c35466b5f02ec","src/recognize.rs":"9f16eda9fcd7d8af7eee4c3b89c611bd648040273fde6b35778f8a50b004c8b1","src/version.rs":"dbd91a4e4fd92a0aa9eb4f858ecbc1ecd680aa60572cc2ad2085e5c5c30e5b77"},"package":"388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"} \ No newline at end of file diff --git a/third_party/cargo/vendor/semver-parser-0.7.0/BUILD b/third_party/cargo/vendor/semver-parser-0.7.0/BUILD new file mode 100644 index 0000000..8aaf66e --- /dev/null +++ b/third_party/cargo/vendor/semver-parser-0.7.0/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "semver_parser", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.7.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/semver-parser-0.7.0/Cargo.toml b/third_party/cargo/vendor/semver-parser-0.7.0/Cargo.toml new file mode 100644 index 0000000..c2be878 --- /dev/null +++ b/third_party/cargo/vendor/semver-parser-0.7.0/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "semver-parser" +version = "0.7.0" +authors = ["Steve Klabnik <steve@steveklabnik.com>"] +license = "MIT/Apache-2.0" +repository = "https://github.com/steveklabnik/semver-parser" +homepage = "https://github.com/steveklabnik/semver-parser" +documentation = "https://docs.rs/semver-parser" +description = """ +Parsing of the semver spec. +""" diff --git a/third_party/cargo/vendor/semver-parser-0.7.0/LICENSE-APACHE b/third_party/cargo/vendor/semver-parser-0.7.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/semver-parser-0.7.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/semver-parser-0.7.0/LICENSE-MIT b/third_party/cargo/vendor/semver-parser-0.7.0/LICENSE-MIT new file mode 100644 index 0000000..fb7494a --- /dev/null +++ b/third_party/cargo/vendor/semver-parser-0.7.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 Steve Klabnik + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/semver-parser-0.7.0/src/common.rs b/third_party/cargo/vendor/semver-parser-0.7.0/src/common.rs new file mode 100644 index 0000000..267b4d9 --- /dev/null +++ b/third_party/cargo/vendor/semver-parser-0.7.0/src/common.rs @@ -0,0 +1,66 @@ +use version::Identifier; +use recognize::{Recognize, Alt, OneOrMore, Inclusive, OneByte}; +use std::str::from_utf8; + +// by the time we get here, we know that it's all valid characters, so this doesn't need to return +// a result or anything +fn parse_meta(s: &str) -> Vec<Identifier> { + // Originally, I wanted to implement this method via calling parse, but parse is tolerant of + // leading zeroes, and we want anything with leading zeroes to be considered alphanumeric, not + // numeric. So the strategy is to check with a recognizer first, and then call parse once + // we've determined that it's a number without a leading zero. + s.split(".") + .map(|part| { + // another wrinkle: we made sure that any number starts with a + // non-zero. But there's a problem: an actual zero is a number, yet + // gets left out by this heuristic. So let's also check for the + // single, lone zero. + if is_alpha_numeric(part) { + Identifier::AlphaNumeric(part.to_string()) + } else { + // we can unwrap here because we know it is only digits due to the regex + Identifier::Numeric(part.parse().unwrap()) + } + }).collect() +} + +// parse optional metadata (preceded by the prefix character) +pub fn parse_optional_meta(s: &[u8], prefix_char: u8)-> Result<(Vec<Identifier>, usize), String> { + if let Some(len) = prefix_char.p(s) { + let start = len; + if let Some(len) = letters_numbers_dash_dot(&s[start..]) { + let end = start + len; + Ok((parse_meta(from_utf8(&s[start..end]).unwrap()), end)) + } else { + Err("Error parsing prerelease".to_string()) + } + } else { + Ok((Vec::new(), 0)) + } +} + +pub fn is_alpha_numeric(s: &str) -> bool { + if let Some((_val, len)) = numeric_identifier(s.as_bytes()) { + // Return true for number with leading zero + // Note: doing it this way also handily makes overflow fail over. + len != s.len() + } else { + true + } +} + +// Note: could plumb overflow error up to return value as Result +pub fn numeric_identifier(s: &[u8]) -> Option<(u64, usize)> { + if let Some(len) = Alt(b'0', OneOrMore(Inclusive(b'0'..b'9'))).p(s) { + from_utf8(&s[0..len]).unwrap().parse().ok().map(|val| (val, len)) + } else { + None + } +} + +pub fn letters_numbers_dash_dot(s: &[u8]) -> Option<usize> { + OneOrMore(OneByte(|c| c == b'-' || c == b'.' || + (b'0' <= c && c <= b'9') || + (b'a' <= c && c <= b'z') || + (b'A' <= c && c <= b'Z'))).p(s) +} diff --git a/third_party/cargo/vendor/semver-parser-0.7.0/src/lib.rs b/third_party/cargo/vendor/semver-parser-0.7.0/src/lib.rs new file mode 100644 index 0000000..3b0d8f0 --- /dev/null +++ b/third_party/cargo/vendor/semver-parser-0.7.0/src/lib.rs @@ -0,0 +1,8 @@ +pub mod version; +pub mod range; + +// for private stuff the two share +mod common; + +// for recognizer combinators +mod recognize; diff --git a/third_party/cargo/vendor/semver-parser-0.7.0/src/range.rs b/third_party/cargo/vendor/semver-parser-0.7.0/src/range.rs new file mode 100644 index 0000000..858be9f --- /dev/null +++ b/third_party/cargo/vendor/semver-parser-0.7.0/src/range.rs @@ -0,0 +1,696 @@ +use common::{self, numeric_identifier, letters_numbers_dash_dot}; +use version::Identifier; +use std::str::{FromStr, from_utf8}; +use recognize::*; + +#[derive(Debug)] +pub struct VersionReq { + pub predicates: Vec<Predicate>, +} + +#[derive(PartialEq,Debug)] +pub enum WildcardVersion { + Major, + Minor, + Patch, +} + +#[derive(PartialEq,Debug)] +pub enum Op { + Ex, // Exact + Gt, // Greater than + GtEq, // Greater than or equal to + Lt, // Less than + LtEq, // Less than or equal to + Tilde, // e.g. ~1.0.0 + Compatible, // compatible by definition of semver, indicated by ^ + Wildcard(WildcardVersion), // x.y.*, x.*, * +} + +impl FromStr for Op { + type Err = String; + + fn from_str(s: &str) -> Result<Op, String> { + match s { + "=" => Ok(Op::Ex), + ">" => Ok(Op::Gt), + ">=" => Ok(Op::GtEq), + "<" => Ok(Op::Lt), + "<=" => Ok(Op::LtEq), + "~" => Ok(Op::Tilde), + "^" => Ok(Op::Compatible), + _ => Err(String::from("Could not parse Op")), + } + } +} + +#[derive(PartialEq,Debug)] +pub struct Predicate { + pub op: Op, + pub major: u64, + pub minor: Option<u64>, + pub patch: Option<u64>, + pub pre: Vec<Identifier>, +} + +fn numeric_or_wild(s: &[u8]) -> Option<(Option<u64>, usize)> { + if let Some((val, len)) = numeric_identifier(s) { + Some((Some(val), len)) + } else if let Some(len) = OneOf(b"*xX").p(s) { + Some((None, len)) + } else { + None + } +} + +fn dot_numeric_or_wild(s: &[u8]) -> Option<(Option<u64>, usize)> { + b'.'.p(s).and_then(|len| + numeric_or_wild(&s[len..]).map(|(val, len2)| (val, len + len2)) + ) +} + +fn operation(s: &[u8]) -> Option<(Op, usize)> { + if let Some(len) = "=".p(s) { + Some((Op::Ex, len)) + } else if let Some(len) = ">=".p(s) { + Some((Op::GtEq, len)) + } else if let Some(len) = ">".p(s) { + Some((Op::Gt, len)) + } else if let Some(len) = "<=".p(s) { + Some((Op::LtEq, len)) + } else if let Some(len) = "<".p(s) { + Some((Op::Lt, len)) + } else if let Some(len) = "~".p(s) { + Some((Op::Tilde, len)) + } else if let Some(len) = "^".p(s) { + Some((Op::Compatible, len)) + } else { + None + } +} + +fn whitespace(s: &[u8]) -> Option<usize> { + ZeroOrMore(OneOf(b"\t\r\n ")).p(s) +} + +pub fn parse_predicate(range: &str) -> Result<Predicate, String> { + let s = range.trim().as_bytes(); + let mut i = 0; + let mut operation = if let Some((op, len)) = operation(&s[i..]) { + i += len; + op + } else { + // operations default to Compatible + Op::Compatible + }; + if let Some(len) = whitespace.p(&s[i..]) { + i += len; + } + let major = if let Some((major, len)) = numeric_identifier(&s[i..]) { + i += len; + major + } else { + return Err("Error parsing major version number: ".to_string()); + }; + let minor = if let Some((minor, len)) = dot_numeric_or_wild(&s[i..]) { + i += len; + if minor.is_none() { + operation = Op::Wildcard(WildcardVersion::Minor); + } + minor + } else { + None + }; + let patch = if let Some((patch, len)) = dot_numeric_or_wild(&s[i..]) { + i += len; + if patch.is_none() { + operation = Op::Wildcard(WildcardVersion::Patch); + } + patch + } else { + None + }; + let (pre, pre_len) = common::parse_optional_meta(&s[i..], b'-')?; + i += pre_len; + if let Some(len) = (b'+', letters_numbers_dash_dot).p(&s[i..]) { + i += len; + } + if i != s.len() { + return Err("Extra junk after valid predicate: ".to_string() + + from_utf8(&s[i..]).unwrap()); + } + Ok(Predicate { + op: operation, + major: major, + minor: minor, + patch: patch, + pre: pre, + }) +} + +pub fn parse(ranges: &str) -> Result<VersionReq, String> { + // null is an error + if ranges == "\0" { + return Err(String::from("Null is not a valid VersionReq")); + } + + // an empty range is a major version wildcard + // so is a lone * or x of either capitalization + if (ranges == "") + || (ranges == "*") + || (ranges == "x") + || (ranges == "X") { + return Ok(VersionReq { + predicates: vec![Predicate { + op: Op::Wildcard(WildcardVersion::Major), + major: 0, + minor: None, + patch: None, + pre: Vec::new(), + }], + }); + } + + + let ranges = ranges.trim(); + + let predicates: Result<Vec<_>, String> = ranges + .split(",") + .map(|range| { + parse_predicate(range) + }) + .collect(); + + let predicates = try!(predicates); + + if predicates.len() == 0 { + return Err(String::from("VersionReq did not parse properly")); + } + + Ok(VersionReq { + predicates: predicates, + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use range; + use version::Identifier; + + #[test] + fn test_parsing_default() { + let r = range::parse("1.0.0").unwrap(); + + assert_eq!(Predicate { + op: Op::Compatible, + major: 1, + minor: Some(0), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_exact_01() { + let r = range::parse("=1.0.0").unwrap(); + + assert_eq!(Predicate { + op: Op::Ex, + major: 1, + minor: Some(0), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_exact_02() { + let r = range::parse("=0.9.0").unwrap(); + + assert_eq!(Predicate { + op: Op::Ex, + major: 0, + minor: Some(9), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_exact_03() { + let r = range::parse("=0.1.0-beta2.a").unwrap(); + + assert_eq!(Predicate { + op: Op::Ex, + major: 0, + minor: Some(1), + patch: Some(0), + pre: vec![Identifier::AlphaNumeric(String::from("beta2")), + Identifier::AlphaNumeric(String::from("a"))], + }, + r.predicates[0] + ); + } + + #[test] + pub fn test_parsing_greater_than() { + let r = range::parse("> 1.0.0").unwrap(); + + assert_eq!(Predicate { + op: Op::Gt, + major: 1, + minor: Some(0), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + pub fn test_parsing_greater_than_01() { + let r = range::parse(">= 1.0.0").unwrap(); + + assert_eq!(Predicate { + op: Op::GtEq, + major: 1, + minor: Some(0), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + pub fn test_parsing_greater_than_02() { + let r = range::parse(">= 2.1.0-alpha2").unwrap(); + + assert_eq!(Predicate { + op: Op::GtEq, + major: 2, + minor: Some(1), + patch: Some(0), + pre: vec![Identifier::AlphaNumeric(String::from("alpha2"))], + }, + r.predicates[0] + ); + } + + #[test] + pub fn test_parsing_less_than() { + let r = range::parse("< 1.0.0").unwrap(); + + assert_eq!(Predicate { + op: Op::Lt, + major: 1, + minor: Some(0), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + pub fn test_parsing_less_than_eq() { + let r = range::parse("<= 2.1.0-alpha2").unwrap(); + + assert_eq!(Predicate { + op: Op::LtEq, + major: 2, + minor: Some(1), + patch: Some(0), + pre: vec![Identifier::AlphaNumeric(String::from("alpha2"))], + }, + r.predicates[0] + ); + } + + #[test] + pub fn test_parsing_tilde() { + let r = range::parse("~1").unwrap(); + + assert_eq!(Predicate { + op: Op::Tilde, + major: 1, + minor: None, + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + pub fn test_parsing_compatible() { + let r = range::parse("^0").unwrap(); + + assert_eq!(Predicate { + op: Op::Compatible, + major: 0, + minor: None, + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_blank() { + let r = range::parse("").unwrap(); + + assert_eq!(Predicate { + op: Op::Wildcard(WildcardVersion::Major), + major: 0, + minor: None, + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_wildcard() { + let r = range::parse("*").unwrap(); + + assert_eq!(Predicate { + op: Op::Wildcard(WildcardVersion::Major), + major: 0, + minor: None, + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_x() { + let r = range::parse("x").unwrap(); + + assert_eq!(Predicate { + op: Op::Wildcard(WildcardVersion::Major), + major: 0, + minor: None, + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_capital_x() { + let r = range::parse("X").unwrap(); + + assert_eq!(Predicate { + op: Op::Wildcard(WildcardVersion::Major), + major: 0, + minor: None, + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_minor_wildcard_star() { + let r = range::parse("1.*").unwrap(); + + assert_eq!(Predicate { + op: Op::Wildcard(WildcardVersion::Minor), + major: 1, + minor: None, + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_minor_wildcard_x() { + let r = range::parse("1.x").unwrap(); + + assert_eq!(Predicate { + op: Op::Wildcard(WildcardVersion::Minor), + major: 1, + minor: None, + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_minor_wildcard_capital_x() { + let r = range::parse("1.X").unwrap(); + + assert_eq!(Predicate { + op: Op::Wildcard(WildcardVersion::Minor), + major: 1, + minor: None, + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_patch_wildcard_star() { + let r = range::parse("1.2.*").unwrap(); + + assert_eq!(Predicate { + op: Op::Wildcard(WildcardVersion::Patch), + major: 1, + minor: Some(2), + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_patch_wildcard_x() { + let r = range::parse("1.2.x").unwrap(); + + assert_eq!(Predicate { + op: Op::Wildcard(WildcardVersion::Patch), + major: 1, + minor: Some(2), + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + fn test_parsing_patch_wildcard_capital_x() { + let r = range::parse("1.2.X").unwrap(); + + assert_eq!(Predicate { + op: Op::Wildcard(WildcardVersion::Patch), + major: 1, + minor: Some(2), + patch: None, + pre: Vec::new(), + }, + r.predicates[0] + ); + } + + #[test] + pub fn test_multiple_01() { + let r = range::parse("> 0.0.9, <= 2.5.3").unwrap(); + + assert_eq!(Predicate { + op: Op::Gt, + major: 0, + minor: Some(0), + patch: Some(9), + pre: Vec::new(), + }, + r.predicates[0] + ); + + assert_eq!(Predicate { + op: Op::LtEq, + major: 2, + minor: Some(5), + patch: Some(3), + pre: Vec::new(), + }, + r.predicates[1] + ); + } + + #[test] + pub fn test_multiple_02() { + let r = range::parse("0.3.0, 0.4.0").unwrap(); + + assert_eq!(Predicate { + op: Op::Compatible, + major: 0, + minor: Some(3), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[0] + ); + + assert_eq!(Predicate { + op: Op::Compatible, + major: 0, + minor: Some(4), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[1] + ); + } + + #[test] + pub fn test_multiple_03() { + let r = range::parse("<= 0.2.0, >= 0.5.0").unwrap(); + + assert_eq!(Predicate { + op: Op::LtEq, + major: 0, + minor: Some(2), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[0] + ); + + assert_eq!(Predicate { + op: Op::GtEq, + major: 0, + minor: Some(5), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[1] + ); + } + + #[test] + pub fn test_multiple_04() { + let r = range::parse("0.1.0, 0.1.4, 0.1.6").unwrap(); + + assert_eq!(Predicate { + op: Op::Compatible, + major: 0, + minor: Some(1), + patch: Some(0), + pre: Vec::new(), + }, + r.predicates[0] + ); + + assert_eq!(Predicate { + op: Op::Compatible, + major: 0, + minor: Some(1), + patch: Some(4), + pre: Vec::new(), + }, + r.predicates[1] + ); + + assert_eq!(Predicate { + op: Op::Compatible, + major: 0, + minor: Some(1), + patch: Some(6), + pre: Vec::new(), + }, + r.predicates[2] + ); + } + + #[test] + pub fn test_multiple_05() { + let r = range::parse(">=0.5.1-alpha3, <0.6").unwrap(); + + assert_eq!(Predicate { + op: Op::GtEq, + major: 0, + minor: Some(5), + patch: Some(1), + pre: vec![Identifier::AlphaNumeric(String::from("alpha3"))], + }, + r.predicates[0] + ); + + assert_eq!(Predicate { + op: Op::Lt, + major: 0, + minor: Some(6), + patch: None, + pre: Vec::new(), + }, + r.predicates[1] + ); + } + + #[test] + fn test_parse_build_metadata_with_predicate() { + assert_eq!(range::parse("^1.2.3+meta").unwrap().predicates[0].op, + Op::Compatible); + assert_eq!(range::parse("~1.2.3+meta").unwrap().predicates[0].op, + Op::Tilde); + assert_eq!(range::parse("=1.2.3+meta").unwrap().predicates[0].op, + Op::Ex); + assert_eq!(range::parse("<=1.2.3+meta").unwrap().predicates[0].op, + Op::LtEq); + assert_eq!(range::parse(">=1.2.3+meta").unwrap().predicates[0].op, + Op::GtEq); + assert_eq!(range::parse("<1.2.3+meta").unwrap().predicates[0].op, + Op::Lt); + assert_eq!(range::parse(">1.2.3+meta").unwrap().predicates[0].op, + Op::Gt); + } + + #[test] + pub fn test_parse_errors() { + assert!(range::parse("\0").is_err()); + assert!(range::parse(">= >= 0.0.2").is_err()); + assert!(range::parse(">== 0.0.2").is_err()); + assert!(range::parse("a.0.0").is_err()); + assert!(range::parse("1.0.0-").is_err()); + assert!(range::parse(">=").is_err()); + assert!(range::parse("> 0.1.0,").is_err()); + assert!(range::parse("> 0.3.0, ,").is_err()); + } + + #[test] + pub fn test_large_major_version() { + assert!(range::parse("18446744073709551617.0.0").is_err()); + } + + #[test] + pub fn test_large_minor_version() { + assert!(range::parse("0.18446744073709551617.0").is_err()); + } + + #[test] + pub fn test_large_patch_version() { + assert!(range::parse("0.0.18446744073709551617").is_err()); + } +} diff --git a/third_party/cargo/vendor/semver-parser-0.7.0/src/recognize.rs b/third_party/cargo/vendor/semver-parser-0.7.0/src/recognize.rs new file mode 100644 index 0000000..c0dd771 --- /dev/null +++ b/third_party/cargo/vendor/semver-parser-0.7.0/src/recognize.rs @@ -0,0 +1,154 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Licensed under either of MIT or Apache License, Version 2.0, +// at your option. +// +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Simple recognizer combinators. + +// This version is similar to a similar one in the "lang" module of +// xi-editor, but is stripped down to only the needed combinators. + +use std::ops; + +pub trait Recognize { + fn p(&self, s: &[u8]) -> Option<usize>; +} + +impl<F: Fn(&[u8]) -> Option<usize>> Recognize for F { + #[inline(always)] + fn p(&self, s: &[u8]) -> Option<usize> { + self(s) + } +} + +pub struct OneByte<F>(pub F); + +impl<F: Fn(u8) -> bool> Recognize for OneByte<F> { + #[inline(always)] + fn p(&self, s: &[u8]) -> Option<usize> { + if s.is_empty() || !self.0(s[0]) { + None + } else { + Some(1) + } + } +} + +impl Recognize for u8 { + #[inline(always)] + fn p(&self, s: &[u8]) -> Option<usize> { + OneByte(|b| b == *self).p(s) + } +} + +/// Use Inclusive(a..b) to indicate an inclusive range. When a...b syntax becomes +/// stable, we can get rid of this and switch to that. +pub struct Inclusive<T>(pub T); + +impl Recognize for Inclusive<ops::Range<u8>> { + #[inline(always)] + fn p(&self, s: &[u8]) -> Option<usize> { + OneByte(|x| x >= self.0.start && x <= self.0.end).p(s) + } +} + +impl<'a> Recognize for &'a [u8] { + #[inline(always)] + fn p(&self, s: &[u8]) -> Option<usize> { + let len = self.len(); + if s.len() >= len && &s[..len] == *self { + Some(len) + } else { + None + } + } +} + +impl<'a> Recognize for &'a str { + #[inline(always)] + fn p(&self, s: &[u8]) -> Option<usize> { + self.as_bytes().p(s) + } +} + +impl<P1: Recognize, P2: Recognize> Recognize for (P1, P2) { + #[inline(always)] + fn p(&self, s: &[u8]) -> Option<usize> { + self.0.p(s).and_then(|len1| + self.1.p(&s[len1..]).map(|len2| + len1 + len2)) + } +} + +/// Choice from two heterogeneous alternatives. +pub struct Alt<P1, P2>(pub P1, pub P2); + +impl<P1: Recognize, P2: Recognize> Recognize for Alt<P1, P2> { + #[inline(always)] + fn p(&self, s: &[u8]) -> Option<usize> { + self.0.p(s).or_else(|| self.1.p(s)) + } +} + +/// Choice from a homogenous slice of parsers. +pub struct OneOf<'a, P: 'a>(pub &'a [P]); + +impl<'a, P: Recognize> Recognize for OneOf<'a, P> { + #[inline] + fn p(&self, s: &[u8]) -> Option<usize> { + for ref p in self.0 { + if let Some(len) = p.p(s) { + return Some(len); + } + } + None + } +} + +pub struct OneOrMore<P>(pub P); + +impl<P: Recognize> Recognize for OneOrMore<P> { + #[inline] + fn p(&self, s: &[u8]) -> Option<usize> { + let mut i = 0; + let mut count = 0; + while let Some(len) = self.0.p(&s[i..]) { + i += len; + count += 1; + } + if count >= 1 { + Some(i) + } else { + None + } + } +} + +pub struct ZeroOrMore<P>(pub P); + +impl<P: Recognize> Recognize for ZeroOrMore<P> { + #[inline] + fn p(&self, s: &[u8]) -> Option<usize> { + let mut i = 0; + while let Some(len) = self.0.p(&s[i..]) { + i += len; + } + Some(i) + } +} diff --git a/third_party/cargo/vendor/semver-parser-0.7.0/src/version.rs b/third_party/cargo/vendor/semver-parser-0.7.0/src/version.rs new file mode 100644 index 0000000..570f947 --- /dev/null +++ b/third_party/cargo/vendor/semver-parser-0.7.0/src/version.rs @@ -0,0 +1,365 @@ +use std::fmt; +use std::str::from_utf8; + +use recognize::*; + +use common::{self, numeric_identifier}; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Version { + pub major: u64, + pub minor: u64, + pub patch: u64, + pub pre: Vec<Identifier>, + pub build: Vec<Identifier>, +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum Identifier { + /// An identifier that's solely numbers. + Numeric(u64), + /// An identifier with letters and numbers. + AlphaNumeric(String), +} + +pub fn parse(version: &str) -> Result<Version, String> { + let s = version.trim().as_bytes(); + let mut i = 0; + let major = if let Some((major, len)) = numeric_identifier(&s[i..]) { + i += len; + major + } else { + return Err("Error parsing major identifier".to_string()); + }; + if let Some(len) = b'.'.p(&s[i..]) { + i += len; + } else { + return Err("Expected dot".to_string()); + } + let minor = if let Some((minor, len)) = numeric_identifier(&s[i..]) { + i += len; + minor + } else { + return Err("Error parsing minor identifier".to_string()); + }; + if let Some(len) = b'.'.p(&s[i..]) { + i += len; + } else { + return Err("Expected dot".to_string()); + } + let patch = if let Some((patch, len)) = numeric_identifier(&s[i..]) { + i += len; + patch + } else { + return Err("Error parsing patch identifier".to_string()); + }; + let (pre, pre_len) = common::parse_optional_meta(&s[i..], b'-')?; + i += pre_len; + let (build, build_len) = common::parse_optional_meta(&s[i..], b'+')?; + i += build_len; + if i != s.len() { + return Err("Extra junk after valid version: ".to_string() + + from_utf8(&s[i..]).unwrap()); + } + Ok(Version { + major: major, + minor: minor, + patch: patch, + pre: pre, + build: build, + }) +} + +impl fmt::Display for Version { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "{}.{}.{}", self.major, self.minor, self.patch)); + if !self.pre.is_empty() { + let strs: Vec<_> = + self.pre.iter().map(ToString::to_string).collect(); + try!(write!(f, "-{}", strs.join("."))); + } + if !self.build.is_empty() { + let strs: Vec<_> = + self.build.iter().map(ToString::to_string).collect(); + try!(write!(f, "+{}", strs.join("."))); + } + Ok(()) + } +} + +impl fmt::Display for Identifier { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Identifier::Numeric(ref id) => id.fmt(f), + Identifier::AlphaNumeric(ref id) => id.fmt(f), + } + } +} + +#[cfg(test)] +mod tests { + use version; + use super::*; + + #[test] + fn parse_empty() { + let version = ""; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), "empty string incorrectly considered a valid parse"); + } + + #[test] + fn parse_blank() { + let version = " "; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), "blank string incorrectly considered a valid parse"); + } + + #[test] + fn parse_no_minor_patch() { + let version = "1"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), format!("'{}' incorrectly considered a valid parse", version)); + } + + #[test] + fn parse_no_patch() { + let version = "1.2"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), format!("'{}' incorrectly considered a valid parse", version)); + } + + #[test] + fn parse_empty_pre() { + let version = "1.2.3-"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), format!("'{}' incorrectly considered a valid parse", version)); + } + + #[test] + fn parse_letters() { + let version = "a.b.c"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), format!("'{}' incorrectly considered a valid parse", version)); + } + + #[test] + fn parse_with_letters() { + let version = "1.2.3 a.b.c"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), format!("'{}' incorrectly considered a valid parse", version)); + } + + #[test] + fn parse_basic_version() { + let version = "1.2.3"; + + let parsed = version::parse(version).unwrap(); + + assert_eq!(1, parsed.major); + assert_eq!(2, parsed.minor); + assert_eq!(3, parsed.patch); + } + + #[test] + fn parse_trims_input() { + let version = " 1.2.3 "; + + let parsed = version::parse(version).unwrap(); + + assert_eq!(1, parsed.major); + assert_eq!(2, parsed.minor); + assert_eq!(3, parsed.patch); + } + + #[test] + fn parse_no_major_leading_zeroes() { + let version = "01.0.0"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), "01 incorrectly considered a valid major version"); + } + + #[test] + fn parse_no_minor_leading_zeroes() { + let version = "0.01.0"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), "01 incorrectly considered a valid minor version"); + } + + #[test] + fn parse_no_patch_leading_zeroes() { + let version = "0.0.01"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), "01 incorrectly considered a valid patch version"); + } + + #[test] + fn parse_no_major_overflow() { + let version = "98765432109876543210.0.0"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), "98765432109876543210 incorrectly considered a valid major version"); + } + + #[test] + fn parse_no_minor_overflow() { + let version = "0.98765432109876543210.0"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), "98765432109876543210 incorrectly considered a valid minor version"); + } + + #[test] + fn parse_no_patch_overflow() { + let version = "0.0.98765432109876543210"; + + let parsed = version::parse(version); + + assert!(parsed.is_err(), "98765432109876543210 incorrectly considered a valid patch version"); + } + + #[test] + fn parse_basic_prerelease() { + let version = "1.2.3-pre"; + + let parsed = version::parse(version).unwrap(); + + let expected_pre = vec![Identifier::AlphaNumeric(String::from("pre"))]; + assert_eq!(expected_pre, parsed.pre); + } + + #[test] + fn parse_prerelease_alphanumeric() { + let version = "1.2.3-alpha1"; + + let parsed = version::parse(version).unwrap(); + + let expected_pre = vec![Identifier::AlphaNumeric(String::from("alpha1"))]; + assert_eq!(expected_pre, parsed.pre); + } + + #[test] + fn parse_prerelease_zero() { + let version = "1.2.3-pre.0"; + + let parsed = version::parse(version).unwrap(); + + let expected_pre = vec![Identifier::AlphaNumeric(String::from("pre")), + Identifier::Numeric(0)]; + assert_eq!(expected_pre, parsed.pre); + } + + #[test] + fn parse_basic_build() { + let version = "1.2.3+build"; + + let parsed = version::parse(version).unwrap(); + + let expected_build = vec![Identifier::AlphaNumeric(String::from("build"))]; + assert_eq!(expected_build, parsed.build); + } + + #[test] + fn parse_build_alphanumeric() { + let version = "1.2.3+build5"; + + let parsed = version::parse(version).unwrap(); + + let expected_build = vec![Identifier::AlphaNumeric(String::from("build5"))]; + assert_eq!(expected_build, parsed.build); + } + + #[test] + fn parse_pre_and_build() { + let version = "1.2.3-alpha1+build5"; + + let parsed = version::parse(version).unwrap(); + + let expected_pre = vec![Identifier::AlphaNumeric(String::from("alpha1"))]; + assert_eq!(expected_pre, parsed.pre); + + let expected_build = vec![Identifier::AlphaNumeric(String::from("build5"))]; + assert_eq!(expected_build, parsed.build); + } + + #[test] + fn parse_complex_metadata_01() { + let version = "1.2.3-1.alpha1.9+build5.7.3aedf "; + + let parsed = version::parse(version).unwrap(); + + let expected_pre = vec![Identifier::Numeric(1), + Identifier::AlphaNumeric(String::from("alpha1")), + Identifier::Numeric(9)]; + assert_eq!(expected_pre, parsed.pre); + + let expected_build = vec![Identifier::AlphaNumeric(String::from("build5")), + Identifier::Numeric(7), + Identifier::AlphaNumeric(String::from("3aedf"))]; + assert_eq!(expected_build, parsed.build); + } + + #[test] + fn parse_complex_metadata_02() { + let version = "0.4.0-beta.1+0851523"; + + let parsed = version::parse(version).unwrap(); + + let expected_pre = vec![Identifier::AlphaNumeric(String::from("beta")), + Identifier::Numeric(1)]; + assert_eq!(expected_pre, parsed.pre); + + let expected_build = vec![Identifier::AlphaNumeric(String::from("0851523"))]; + assert_eq!(expected_build, parsed.build); + } + + #[test] + fn parse_metadata_overflow() { + let version = "0.4.0-beta.1+98765432109876543210"; + + let parsed = version::parse(version).unwrap(); + + let expected_pre = vec![Identifier::AlphaNumeric(String::from("beta")), + Identifier::Numeric(1)]; + assert_eq!(expected_pre, parsed.pre); + + let expected_build = vec![Identifier::AlphaNumeric(String::from("98765432109876543210"))]; + assert_eq!(expected_build, parsed.build); + } + + #[test] + fn parse_regression_01() { + let version = "0.0.0-WIP"; + + let parsed = version::parse(version).unwrap(); + + assert_eq!(0, parsed.major); + assert_eq!(0, parsed.minor); + assert_eq!(0, parsed.patch); + + let expected_pre = vec![Identifier::AlphaNumeric(String::from("WIP"))]; + assert_eq!(expected_pre, parsed.pre); + } +} diff --git a/third_party/cargo/vendor/shared_library-0.1.9/.cargo-checksum.json b/third_party/cargo/vendor/shared_library-0.1.9/.cargo-checksum.json new file mode 100644 index 0000000..0b16e83 --- /dev/null +++ b/third_party/cargo/vendor/shared_library-0.1.9/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"f9ad715b6b6424f37f903a069039d3567d46e426d98d11d4e62a9a3933691e5b","LICENSE-APACHE":"c144680885b29e4719e2a51f0aab5439a1e02d980692b5aaf086cae12727f28b","LICENSE-MIT":"1c07d19ccbe2578665ab7d8c63f71559f890eb8d2a82fa39d0206b7a3414064f","src/dynamic_library.rs":"973df715d4ae2daae662392d73ca853b9bacdb4165bab3e4d8343427dca55c9c","src/lib.rs":"29f1aef9437d1ab891d17d6a6b86c6e1176813d372333cfdfc063b97586deb02"},"package":"5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"} \ No newline at end of file diff --git a/third_party/cargo/vendor/shared_library-0.1.9/BUILD b/third_party/cargo/vendor/shared_library-0.1.9/BUILD new file mode 100644 index 0000000..50dfc52 --- /dev/null +++ b/third_party/cargo/vendor/shared_library-0.1.9/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0,MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "shared_library", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + "//third_party/cargo/vendor/libc-0.2.66:libc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.9", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/shared_library-0.1.9/Cargo.toml b/third_party/cargo/vendor/shared_library-0.1.9/Cargo.toml new file mode 100644 index 0000000..1d7d58b --- /dev/null +++ b/third_party/cargo/vendor/shared_library-0.1.9/Cargo.toml @@ -0,0 +1,24 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "shared_library" +version = "0.1.9" +authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"] +description = "Easily bind to and load shared libraries" +license = "Apache-2.0/MIT" +repository = "https://github.com/tomaka/shared_library/" +[dependencies.lazy_static] +version = "1" + +[dependencies.libc] +version = "0.2" diff --git a/third_party/cargo/vendor/shared_library-0.1.9/LICENSE-APACHE b/third_party/cargo/vendor/shared_library-0.1.9/LICENSE-APACHE new file mode 100644 index 0000000..1b22bef --- /dev/null +++ b/third_party/cargo/vendor/shared_library-0.1.9/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/third_party/cargo/vendor/shared_library-0.1.9/LICENSE-MIT b/third_party/cargo/vendor/shared_library-0.1.9/LICENSE-MIT new file mode 100644 index 0000000..4f2b149 --- /dev/null +++ b/third_party/cargo/vendor/shared_library-0.1.9/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2017 Pierre Krieger + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/third_party/cargo/vendor/shared_library-0.1.9/src/dynamic_library.rs b/third_party/cargo/vendor/shared_library-0.1.9/src/dynamic_library.rs new file mode 100644 index 0000000..753b632 --- /dev/null +++ b/third_party/cargo/vendor/shared_library-0.1.9/src/dynamic_library.rs @@ -0,0 +1,410 @@ +// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Dynamic library facilities. +//! +//! A simple wrapper over the platform's dynamic library facilities + +#![allow(missing_docs)] + +use std::env; +use std::ffi::{CString, OsString}; +use std::mem; +use std::path::{Path, PathBuf}; +use libc; + +pub struct DynamicLibrary { + handle: *mut u8 +} + +unsafe impl Send for DynamicLibrary {} +unsafe impl Sync for DynamicLibrary {} + +impl Drop for DynamicLibrary { + fn drop(&mut self) { + if let Err(str) = dl::check_for_errors_in(|| unsafe { + dl::close(self.handle) + }) { + panic!("{}", str) + } + } +} + +/// Special handles to be used with the `symbol_special` function. These are +/// provided by a GNU only extension and are not included as part of the POSIX +/// standard. +/// +/// See https://linux.die.net/man/3/dlsym for their behaviour. +#[cfg(target_os = "linux")] +pub enum SpecialHandles { + Next, + Default, +} + +impl DynamicLibrary { + // FIXME (#12938): Until DST lands, we cannot decompose &str into + // & and str, so we cannot usefully take ToCStr arguments by + // reference (without forcing an additional & around &str). So we + // are instead temporarily adding an instance for &Path, so that + // we can take ToCStr as owned. When DST lands, the &Path instance + // should be removed, and arguments bound by ToCStr should be + // passed by reference. (Here: in the `open` method.) + + /// Lazily loads the dynamic library named `filename` into memory and + /// then returns an opaque "handle" for that dynamic library. + /// + /// Returns a handle to the calling process when passed `None`. + pub fn open(filename: Option<&Path>) -> Result<Self, String> { + // The dynamic library must not be constructed if there is + // an error opening the library so the destructor does not + // run. + dl::open(filename.map(|path| path.as_os_str())) + .map(|handle| DynamicLibrary { handle }) + } + + /// Prepends a path to this process's search path for dynamic libraries + pub fn prepend_search_path(path: &Path) { + let mut search_path = Self::search_path(); + search_path.insert(0, path.to_path_buf()); + env::set_var(Self::envvar(), &Self::create_path(&search_path)); + } + + /// From a slice of paths, create a new vector which is suitable to be an + /// environment variable for this platforms dylib search path. + pub fn create_path(path: &[PathBuf]) -> OsString { + let mut newvar = OsString::new(); + for (i, path) in path.iter().enumerate() { + if i > 0 { newvar.push(Self::separator()); } + newvar.push(path); + } + newvar + } + + /// Returns the environment variable for this process's dynamic library + /// search path + pub fn envvar() -> &'static str { + if cfg!(windows) { + "PATH" + } else if cfg!(target_os = "macos") { + "DYLD_LIBRARY_PATH" + } else { + "LD_LIBRARY_PATH" + } + } + + //TODO: turn this and `envvar` into associated constants + fn separator() -> &'static str { + if cfg!(windows) { ";" } else { ":" } + } + + /// Returns the current search path for dynamic libraries being used by this + /// process + pub fn search_path() -> Vec<PathBuf> { + match env::var_os(Self::envvar()) { + Some(var) => env::split_paths(&var).collect(), + None => Vec::new(), + } + } + + /// Returns the address of where symbol `symbol` was loaded into memory. + /// + /// In POSIX compliant systems, we return 'Err' if the symbol was not found, + /// in this library or any of the libraries that were automatically loaded + /// when this library was loaded. + pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*mut T, String> { + // This function should have a lifetime constraint of 'a on + // T but that feature is still unimplemented + + let raw_string = CString::new(symbol).unwrap(); + // The value must not be constructed if there is an error so + // the destructor does not run. + dl::check_for_errors_in(|| { + dl::symbol(self.handle as *mut libc::c_void, raw_string.as_ptr() as *const _) + }) + .map(|sym| mem::transmute(sym)) + } + + /// Returns the address of the first occurance of symbol `symbol` using the + /// default library search order if you use `SpecialHandles::Default`. + /// + /// Returns the address of the next occurance of symbol `symbol` after the + /// current library in the default library search order if you use + /// `SpecialHandles::Next`. + #[cfg(target_os = "linux")] + pub unsafe fn symbol_special<T>(handle: SpecialHandles, symbol: &str) -> Result<*mut T, String> { + // This function should have a lifetime constraint of 'a on + // T but that feature is still unimplemented + + let handle = match handle { + SpecialHandles::Next => mem::transmute::<libc::c_long, _>(-1), + SpecialHandles::Default => ::std::ptr::null_mut(), + }; + + let raw_string = CString::new(symbol).unwrap(); + // The value must not be constructed if there is an error so + // the destructor does not run. + dl::check_for_errors_in(|| { + dl::symbol(handle, raw_string.as_ptr() as *const _) + }) + .map(|sym| mem::transmute(sym)) + } +} + +#[cfg(all(test, not(target_os = "ios")))] +mod test { + use super::*; + use std::mem; + use std::path::Path; + + #[test] + #[cfg_attr(any(windows, target_os = "android"), ignore)] // FIXME #8818, #10379 + fn test_loading_cosine() { + // The math library does not need to be loaded since it is already + // statically linked in + let libm = match DynamicLibrary::open(None) { + Err(error) => panic!("Could not load self as module: {}", error), + Ok(libm) => libm + }; + + let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe { + match libm.symbol("cos") { + Err(error) => panic!("Could not load function cos: {}", error), + Ok(cosine) => mem::transmute::<*mut u8, _>(cosine) + } + }; + + let argument = 0.0; + let expected_result = 1.0; + let result = cosine(argument); + if result != expected_result { + panic!("cos({}) != {} but equaled {} instead", argument, + expected_result, result) + } + } + + #[test] + #[cfg(any(target_os = "linux", + target_os = "macos", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd", + target_os = "solaris"))] + fn test_errors_do_not_crash() { + // Open /dev/null as a library to get an error, and make sure + // that only causes an error, and not a crash. + let path = Path::new("/dev/null"); + match DynamicLibrary::open(Some(&path)) { + Err(_) => {} + Ok(_) => panic!("Successfully opened the empty library.") + } + } +} + +//TODO: use `unix` shortcut? +#[cfg(any(target_os = "linux", + target_os = "android", + target_os = "macos", + target_os = "ios", + target_os = "fuchsia", + target_os = "freebsd", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd", + target_os = "solaris", + target_os = "emscripten"))] +mod dl { + use std::ffi::{CString, CStr, OsStr}; + use std::os::unix::ffi::OsStrExt; + use std::str; + use libc; + use std::ptr; + use std::sync::Mutex; + + lazy_static! { + static ref LOCK: Mutex<()> = Mutex::new(()); + } + + pub fn open(filename: Option<&OsStr>) -> Result<*mut u8, String> { + check_for_errors_in(|| unsafe { + match filename { + Some(filename) => open_external(filename), + None => open_internal(), + } + }) + } + + const LAZY: libc::c_int = 1; + + unsafe fn open_external(filename: &OsStr) -> *mut u8 { + let s = CString::new(filename.as_bytes().to_vec()).unwrap(); + dlopen(s.as_ptr() as *const _, LAZY) as *mut u8 + } + + unsafe fn open_internal() -> *mut u8 { + dlopen(ptr::null(), LAZY) as *mut u8 + } + + pub fn check_for_errors_in<T, F>(f: F) -> Result<T, String> where + F: FnOnce() -> T, + { + unsafe { + // dlerror isn't thread safe, so we need to lock around this entire + // sequence + let _guard = LOCK.lock(); + let _old_error = dlerror(); + + let result = f(); + + let last_error = dlerror() as *const _; + let ret = if ptr::null() == last_error { + Ok(result) + } else { + let s = CStr::from_ptr(last_error).to_bytes(); + Err(str::from_utf8(s).unwrap().to_string()) + }; + + ret + } + } + + pub unsafe fn symbol( + handle: *mut libc::c_void, + symbol: *const libc::c_char, + ) -> *mut u8 { + dlsym(handle, symbol) as *mut u8 + } + + pub unsafe fn close(handle: *mut u8) { + dlclose(handle as *mut libc::c_void); () + } + + extern { + fn dlopen( + filename: *const libc::c_char, + flag: libc::c_int, + ) -> *mut libc::c_void; + fn dlerror() -> *mut libc::c_char; + fn dlsym( + handle: *mut libc::c_void, + symbol: *const libc::c_char, + ) -> *mut libc::c_void; + fn dlclose( + handle: *mut libc::c_void, + ) -> libc::c_int; + } +} + +#[cfg(target_os = "windows")] +mod dl { + use std::ffi::OsStr; + use std::iter::Iterator; + use libc; + use std::ops::FnOnce; + use std::io::Error as IoError; + use std::os::windows::prelude::*; + use std::option::Option::{self, Some, None}; + use std::ptr; + use std::result::Result; + use std::result::Result::{Ok, Err}; + use std::string::String; + use std::vec::Vec; + + pub fn open(filename: Option<&OsStr>) -> Result<*mut u8, String> { + // disable "dll load failed" error dialog. + let prev_error_mode = unsafe { + // SEM_FAILCRITICALERRORS 0x01 + let new_error_mode = 1; + SetErrorMode(new_error_mode) + }; + + unsafe { + SetLastError(0); + } + + let result = match filename { + Some(filename) => { + let filename_str: Vec<_> = + filename.encode_wide().chain(Some(0).into_iter()).collect(); + let result = unsafe { + LoadLibraryW(filename_str.as_ptr() as *const libc::c_void) + }; + // beware: Vec/String may change errno during drop! + // so we get error here. + if result == ptr::null_mut() { + Err(format!("{}", IoError::last_os_error())) + } else { + Ok(result as *mut u8) + } + } + None => { + let mut handle = ptr::null_mut(); + let succeeded = unsafe { + GetModuleHandleExW(0, ptr::null(), &mut handle) + }; + if succeeded == 0 { + Err(format!("{}", IoError::last_os_error())) + } else { + Ok(handle as *mut u8) + } + } + }; + + unsafe { + SetErrorMode(prev_error_mode); + } + + result + } + + pub fn check_for_errors_in<T, F>(f: F) -> Result<T, String> where + F: FnOnce() -> T, + { + unsafe { + SetLastError(0); + + let result = f(); + + let error = IoError::last_os_error(); + if 0 == error.raw_os_error().unwrap() { + Ok(result) + } else { + Err(format!("{}", error)) + } + } + } + + pub unsafe fn symbol(handle: *mut libc::c_void, symbol: *const libc::c_char) -> *mut u8 { + GetProcAddress(handle, symbol) as *mut u8 + } + pub unsafe fn close(handle: *mut u8) { + FreeLibrary(handle as *mut libc::c_void); () + } + + #[allow(non_snake_case)] + extern "system" { + fn SetLastError(error: libc::size_t); + fn LoadLibraryW(name: *const libc::c_void) -> *mut libc::c_void; + fn GetModuleHandleExW( + dwFlags: u32, + name: *const u16, + handle: *mut *mut libc::c_void, + ) -> i32; + fn GetProcAddress( + handle: *mut libc::c_void, + name: *const libc::c_char, + ) -> *mut libc::c_void; + fn FreeLibrary(handle: *mut libc::c_void); + fn SetErrorMode(uMode: libc::c_uint) -> libc::c_uint; + } +} diff --git a/third_party/cargo/vendor/shared_library-0.1.9/src/lib.rs b/third_party/cargo/vendor/shared_library-0.1.9/src/lib.rs new file mode 100644 index 0000000..e698a47 --- /dev/null +++ b/third_party/cargo/vendor/shared_library-0.1.9/src/lib.rs @@ -0,0 +1,175 @@ +extern crate libc; + +#[macro_use] +extern crate lazy_static; + +pub mod dynamic_library; + +/// Error that can happen while loading the shared library. +#[derive(Debug, Clone)] +pub enum LoadingError { + /// + LibraryNotFound { + descr: String, + }, + + /// One of the symbols could not be found in the library. + SymbolNotFound { + /// The symbol. + symbol: &'static str, + } +} + +#[macro_export] +macro_rules! shared_library { + ($struct_name:ident, pub $($rest:tt)+) => { + shared_library!(__impl $struct_name [] [] [] pub $($rest)+); + }; + + ($struct_name:ident, fn $($rest:tt)+) => { + shared_library!(__impl $struct_name [] [] [] fn $($rest)+); + }; + + ($struct_name:ident, static $($rest:tt)+) => { + shared_library!(__impl $struct_name [] [] [] static $($rest)+); + }; + + ($struct_name:ident, $def_path:expr, $($rest:tt)+) => { + shared_library!(__impl $struct_name [] [$def_path] [] $($rest)+); + }; + + (__impl $struct_name:ident + [$($p1:tt)*] [$($p2:tt)*] [$($p3:tt)*] + , $($rest:tt)* + ) => { + shared_library!(__impl $struct_name [$($p1)*] [$($p2)*] [$($p3)*] $($rest)*); + }; + + (__impl $struct_name:ident + [$($p1:tt)*] [$($p2:tt)*] [$($p3:tt)*] + pub $($rest:tt)* + ) => { + shared_library!(__impl $struct_name + [$($p1)*] [$($p2)*] [$($p3)* pub] $($rest)*); + }; + + (__impl $struct_name:ident + [$($p1:tt)*] [$($p2:tt)*] [$($p3:tt)*] + fn $name:ident($($p:ident:$ty:ty),*) -> $ret:ty, $($rest:tt)* + ) => { + shared_library!(__impl $struct_name + [$($p1)*, $name:unsafe extern fn($($p:$ty),*) -> $ret] + [$($p2)*] + [$($p3)* + unsafe fn $name($($p:$ty),*) -> $ret { + #![allow(dead_code)] + ($struct_name::get_static_ref().$name)($($p),*) + } + ] $($rest)*); + }; + + (__impl $struct_name:ident + [$($p1:tt)*] [$($p2:tt)*] [$($p3:tt)*] + static $name:ident:$ty:ty, $($rest:tt)* + ) => { + shared_library!(__impl $struct_name + [$($p1)*, $name: $ty] + [$($p2)*] + [$($p3)*] $($rest)*); + }; + + (__impl $struct_name:ident + [$($p1:tt)*] [$($p2:tt)*] [$($p3:tt)*] + fn $name:ident($($p:ident:$ty:ty),*), $($rest:tt)* + ) => { + shared_library!(__impl $struct_name + [$($p1)*] [$($p2)*] [$($p3)*] + fn $name($($p:$ty),*) -> (), $($rest)*); + }; + + (__impl $struct_name:ident [$(,$mem_n:ident:$mem_t:ty)+] [$($p2:tt)*] [$($p3:tt)*]) => { + /// Symbols loaded from a shared library. + #[allow(non_snake_case)] + pub struct $struct_name { + _library_guard: $crate::dynamic_library::DynamicLibrary, + $( + pub $mem_n: $mem_t, + )+ + } + + impl $struct_name { + /// Tries to open the dynamic library. + #[allow(non_snake_case)] + pub fn open(path: &::std::path::Path) -> Result<$struct_name, $crate::LoadingError> { + use std::mem; + + let dylib = match $crate::dynamic_library::DynamicLibrary::open(Some(path)) { + Ok(l) => l, + Err(reason) => return Err($crate::LoadingError::LibraryNotFound { descr: reason }) + }; + + $( + let $mem_n: *mut () = match unsafe { dylib.symbol(stringify!($mem_n)) } { + Ok(s) => s, + Err(_) => return Err($crate::LoadingError::SymbolNotFound { symbol: stringify!($mem_n) }), + }; + )+ + + Ok($struct_name { + _library_guard: dylib, + $( + $mem_n: unsafe { mem::transmute($mem_n) }, + )+ + }) + } + } + + shared_library!(__write_static_fns $struct_name [] [$($p2)*] [$($p3)*]); + }; + + (__write_static_fns $struct_name:ident [$($p1:tt)*] [] [$($p3:tt)*]) => { + }; + + (__write_static_fns $struct_name:ident [$($p1:tt)*] [$defpath:expr] [$($standalones:item)+]) => { + impl $struct_name { + /// This function is used by the regular functions. + fn get_static_ref() -> &'static $struct_name { + $struct_name::try_loading().ok() + .expect(concat!("Could not open dynamic \ + library `", stringify!($struct_name), + "`")) + } + + /// Try loading the static symbols linked to this library. + pub fn try_loading() -> Result<&'static $struct_name, $crate::LoadingError> { + use std::sync::{Mutex, Once, ONCE_INIT}; + use std::mem; + + unsafe { + static mut DATA: *const Mutex<Option<$struct_name>> = 0 as *const _; + + static mut INIT: Once = ONCE_INIT; + INIT.call_once(|| { + let data = Box::new(Mutex::new(None)); + DATA = &*data; + mem::forget(data); + }); + + let data: &Mutex<Option<$struct_name>> = &*DATA; + let mut data = data.lock().unwrap(); + + if let Some(ref data) = *data { + return Ok(mem::transmute(data)); + } + + let path = ::std::path::Path::new($defpath); + let result = try!($struct_name::open(path)); + *data = Some(result); + Ok(mem::transmute(data.as_ref().unwrap())) + } + } + } + + $($standalones)+ + }; +} diff --git a/third_party/cargo/vendor/smallvec-0.6.13/.cargo-checksum.json b/third_party/cargo/vendor/smallvec-0.6.13/.cargo-checksum.json new file mode 100644 index 0000000..5ef6f73 --- /dev/null +++ b/third_party/cargo/vendor/smallvec-0.6.13/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"9b9dd0b09c80450d9b16308948eef9675bec260a4cd738572ff67e8d7d271f9c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0b28172679e0009b655da42797c03fd163a3379d5cfa67ba1f1655e974a2a1a9","README.md":"38eef4ebde6fe6effa12a2dbca3bd69d6446b2935f19a329ac4926f1cb2e5013","benches/bench.rs":"9dca7122a3dcb2c099e49807e4d3b8f01d9220e2b3db0a54e9901ee74392866f","lib.rs":"f2f9c0f77e63672496591328cb90358d1a7d664aae8e7dee59cd0525010649cb","scripts/run_miri.sh":"cd645dfecf19cc77141ecaf698e58a3a743ad69aca5e5d25c8e5d3911e031322","specialization.rs":"b29ac094999b94cc193dde52432e8cd8d17a299192822b3485c27bf6a1bdc397"},"package":"f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"} \ No newline at end of file diff --git a/third_party/cargo/vendor/smallvec-0.6.13/BUILD b/third_party/cargo/vendor/smallvec-0.6.13/BUILD new file mode 100644 index 0000000..f8490e5 --- /dev/null +++ b/third_party/cargo/vendor/smallvec-0.6.13/BUILD @@ -0,0 +1,46 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "bench" with type "bench" omitted + +rust_library( + name = "smallvec", + crate_root = "lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/maybe-uninit-2.0.0:maybe_uninit", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.13", + crate_features = [ + "default", + "std", + ], +) + diff --git a/third_party/cargo/vendor/smallvec-0.6.13/Cargo.toml b/third_party/cargo/vendor/smallvec-0.6.13/Cargo.toml new file mode 100644 index 0000000..6d1679e --- /dev/null +++ b/third_party/cargo/vendor/smallvec-0.6.13/Cargo.toml @@ -0,0 +1,42 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "smallvec" +version = "0.6.13" +authors = ["Simon Sapin <simon.sapin@exyr.org>"] +description = "'Small vector' optimization: store up to a small number of items on the stack" +documentation = "https://doc.servo.org/smallvec/" +readme = "README.md" +keywords = ["small", "vec", "vector", "stack", "no_std"] +categories = ["data-structures"] +license = "MIT/Apache-2.0" +repository = "https://github.com/servo/rust-smallvec" + +[lib] +name = "smallvec" +path = "lib.rs" +[dependencies.maybe-uninit] +version = "2.0" + +[dependencies.serde] +version = "1" +optional = true +[dev-dependencies.bincode] +version = "1.0.1" + +[features] +default = ["std"] +may_dangle = [] +specialization = [] +std = [] +union = [] diff --git a/third_party/cargo/vendor/smallvec-0.6.13/LICENSE-APACHE b/third_party/cargo/vendor/smallvec-0.6.13/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/smallvec-0.6.13/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/smallvec-0.6.13/LICENSE-MIT b/third_party/cargo/vendor/smallvec-0.6.13/LICENSE-MIT new file mode 100644 index 0000000..9729c12 --- /dev/null +++ b/third_party/cargo/vendor/smallvec-0.6.13/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2018 The Servo Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/smallvec-0.6.13/README.md b/third_party/cargo/vendor/smallvec-0.6.13/README.md new file mode 100644 index 0000000..fda7fd4 --- /dev/null +++ b/third_party/cargo/vendor/smallvec-0.6.13/README.md @@ -0,0 +1,8 @@ +rust-smallvec +============= + +[Documentation](https://docs.rs/smallvec/) + +[Release notes](https://github.com/servo/rust-smallvec/releases) + +"Small vector" optimization for Rust: store up to a small number of items on the stack diff --git a/third_party/cargo/vendor/smallvec-0.6.13/benches/bench.rs b/third_party/cargo/vendor/smallvec-0.6.13/benches/bench.rs new file mode 100644 index 0000000..36cb133 --- /dev/null +++ b/third_party/cargo/vendor/smallvec-0.6.13/benches/bench.rs @@ -0,0 +1,295 @@ +#![feature(test)] + +#[macro_use] +extern crate smallvec; +extern crate test; + +use self::test::Bencher; +use smallvec::{ExtendFromSlice, SmallVec}; + +const VEC_SIZE: usize = 16; +const SPILLED_SIZE: usize = 100; + +trait Vector<T>: for<'a> From<&'a [T]> + Extend<T> + ExtendFromSlice<T> { + fn new() -> Self; + fn push(&mut self, val: T); + fn pop(&mut self) -> Option<T>; + fn remove(&mut self, p: usize) -> T; + fn insert(&mut self, n: usize, val: T); + fn from_elem(val: T, n: usize) -> Self; + fn from_elems(val: &[T]) -> Self; +} + +impl<T: Copy> Vector<T> for Vec<T> { + fn new() -> Self { + Self::with_capacity(VEC_SIZE) + } + + fn push(&mut self, val: T) { + self.push(val) + } + + fn pop(&mut self) -> Option<T> { + self.pop() + } + + fn remove(&mut self, p: usize) -> T { + self.remove(p) + } + + fn insert(&mut self, n: usize, val: T) { + self.insert(n, val) + } + + fn from_elem(val: T, n: usize) -> Self { + vec![val; n] + } + + fn from_elems(val: &[T]) -> Self { + val.to_owned() + } +} + +impl<T: Copy> Vector<T> for SmallVec<[T; VEC_SIZE]> { + fn new() -> Self { + Self::new() + } + + fn push(&mut self, val: T) { + self.push(val) + } + + fn pop(&mut self) -> Option<T> { + self.pop() + } + + fn remove(&mut self, p: usize) -> T { + self.remove(p) + } + + fn insert(&mut self, n: usize, val: T) { + self.insert(n, val) + } + + fn from_elem(val: T, n: usize) -> Self { + smallvec![val; n] + } + + fn from_elems(val: &[T]) -> Self { + SmallVec::from_slice(val) + } +} + +macro_rules! make_benches { + ($typ:ty { $($b_name:ident => $g_name:ident($($args:expr),*),)* }) => { + $( + #[bench] + fn $b_name(b: &mut Bencher) { + $g_name::<$typ>($($args,)* b) + } + )* + } +} + +make_benches! { + SmallVec<[u64; VEC_SIZE]> { + bench_push => gen_push(SPILLED_SIZE as _), + bench_push_small => gen_push(VEC_SIZE as _), + bench_insert => gen_insert(SPILLED_SIZE as _), + bench_insert_small => gen_insert(VEC_SIZE as _), + bench_remove => gen_remove(SPILLED_SIZE as _), + bench_remove_small => gen_remove(VEC_SIZE as _), + bench_extend => gen_extend(SPILLED_SIZE as _), + bench_extend_small => gen_extend(VEC_SIZE as _), + bench_from_iter => gen_from_iter(SPILLED_SIZE as _), + bench_from_iter_small => gen_from_iter(VEC_SIZE as _), + bench_from_slice => gen_from_slice(SPILLED_SIZE as _), + bench_from_slice_small => gen_from_slice(VEC_SIZE as _), + bench_extend_from_slice => gen_extend_from_slice(SPILLED_SIZE as _), + bench_extend_from_slice_small => gen_extend_from_slice(VEC_SIZE as _), + bench_macro_from_elem => gen_from_elem(SPILLED_SIZE as _), + bench_macro_from_elem_small => gen_from_elem(VEC_SIZE as _), + bench_pushpop => gen_pushpop(), + } +} + +make_benches! { + Vec<u64> { + bench_push_vec => gen_push(SPILLED_SIZE as _), + bench_push_vec_small => gen_push(VEC_SIZE as _), + bench_insert_vec => gen_insert(SPILLED_SIZE as _), + bench_insert_vec_small => gen_insert(VEC_SIZE as _), + bench_remove_vec => gen_remove(SPILLED_SIZE as _), + bench_remove_vec_small => gen_remove(VEC_SIZE as _), + bench_extend_vec => gen_extend(SPILLED_SIZE as _), + bench_extend_vec_small => gen_extend(VEC_SIZE as _), + bench_from_iter_vec => gen_from_iter(SPILLED_SIZE as _), + bench_from_iter_vec_small => gen_from_iter(VEC_SIZE as _), + bench_from_slice_vec => gen_from_slice(SPILLED_SIZE as _), + bench_from_slice_vec_small => gen_from_slice(VEC_SIZE as _), + bench_extend_from_slice_vec => gen_extend_from_slice(SPILLED_SIZE as _), + bench_extend_from_slice_vec_small => gen_extend_from_slice(VEC_SIZE as _), + bench_macro_from_elem_vec => gen_from_elem(SPILLED_SIZE as _), + bench_macro_from_elem_vec_small => gen_from_elem(VEC_SIZE as _), + bench_pushpop_vec => gen_pushpop(), + } +} + +fn gen_push<V: Vector<u64>>(n: u64, b: &mut Bencher) { + #[inline(never)] + fn push_noinline<V: Vector<u64>>(vec: &mut V, x: u64) { + vec.push(x); + } + + b.iter(|| { + let mut vec = V::new(); + for x in 0..n { + push_noinline(&mut vec, x); + } + vec + }); +} + +fn gen_insert<V: Vector<u64>>(n: u64, b: &mut Bencher) { + #[inline(never)] + fn insert_noinline<V: Vector<u64>>(vec: &mut V, p: usize, x: u64) { + vec.insert(p, x) + } + + b.iter(|| { + let mut vec = V::new(); + // Add one element, with each iteration we insert one before the end. + // This means that we benchmark the insertion operation and not the + // time it takes to `ptr::copy` the data. + vec.push(0); + for x in 0..n { + insert_noinline(&mut vec, x as _, x); + } + vec + }); +} + +fn gen_remove<V: Vector<u64>>(n: usize, b: &mut Bencher) { + #[inline(never)] + fn remove_noinline<V: Vector<u64>>(vec: &mut V, p: usize) -> u64 { + vec.remove(p) + } + + b.iter(|| { + let mut vec = V::from_elem(0, n as _); + + for x in (0..n - 1).rev() { + remove_noinline(&mut vec, x); + } + }); +} + +fn gen_extend<V: Vector<u64>>(n: u64, b: &mut Bencher) { + b.iter(|| { + let mut vec = V::new(); + vec.extend(0..n); + vec + }); +} + +fn gen_from_iter<V: Vector<u64>>(n: u64, b: &mut Bencher) { + let v: Vec<u64> = (0..n).collect(); + b.iter(|| { + let vec = V::from(&v); + vec + }); +} + +fn gen_from_slice<V: Vector<u64>>(n: u64, b: &mut Bencher) { + let v: Vec<u64> = (0..n).collect(); + b.iter(|| { + let vec = V::from_elems(&v); + vec + }); +} + +fn gen_extend_from_slice<V: Vector<u64>>(n: u64, b: &mut Bencher) { + let v: Vec<u64> = (0..n).collect(); + b.iter(|| { + let mut vec = V::new(); + vec.extend_from_slice(&v); + vec + }); +} + +fn gen_pushpop<V: Vector<u64>>(b: &mut Bencher) { + #[inline(never)] + fn pushpop_noinline<V: Vector<u64>>(vec: &mut V, x: u64) -> Option<u64> { + vec.push(x); + vec.pop() + } + + b.iter(|| { + let mut vec = V::new(); + for x in 0..SPILLED_SIZE as _ { + pushpop_noinline(&mut vec, x); + } + vec + }); +} + +fn gen_from_elem<V: Vector<u64>>(n: usize, b: &mut Bencher) { + b.iter(|| { + let vec = V::from_elem(42, n); + vec + }); +} + +#[bench] +fn bench_insert_many(b: &mut Bencher) { + #[inline(never)] + fn insert_many_noinline<I: IntoIterator<Item = u64>>( + vec: &mut SmallVec<[u64; VEC_SIZE]>, + index: usize, + iterable: I, + ) { + vec.insert_many(index, iterable) + } + + b.iter(|| { + let mut vec = SmallVec::<[u64; VEC_SIZE]>::new(); + insert_many_noinline(&mut vec, 0, 0..SPILLED_SIZE as _); + insert_many_noinline(&mut vec, 0, 0..SPILLED_SIZE as _); + vec + }); +} + +#[bench] +fn bench_insert_from_slice(b: &mut Bencher) { + let v: Vec<u64> = (0..SPILLED_SIZE as _).collect(); + b.iter(|| { + let mut vec = SmallVec::<[u64; VEC_SIZE]>::new(); + vec.insert_from_slice(0, &v); + vec.insert_from_slice(0, &v); + vec + }); +} + +#[bench] +fn bench_macro_from_list(b: &mut Bencher) { + b.iter(|| { + let vec: SmallVec<[u64; 16]> = smallvec![ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32, 36, 0x40, 0x80, + 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000, 0x40000, + 0x80000, 0x100000, + ]; + vec + }); +} + +#[bench] +fn bench_macro_from_list_vec(b: &mut Bencher) { + b.iter(|| { + let vec: Vec<u64> = vec![ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32, 36, 0x40, 0x80, + 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000, 0x40000, + 0x80000, 0x100000, + ]; + vec + }); +} diff --git a/third_party/cargo/vendor/smallvec-0.6.13/lib.rs b/third_party/cargo/vendor/smallvec-0.6.13/lib.rs new file mode 100644 index 0000000..55278ad --- /dev/null +++ b/third_party/cargo/vendor/smallvec-0.6.13/lib.rs @@ -0,0 +1,2374 @@ +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Small vectors in various sizes. These store a certain number of elements inline, and fall back +//! to the heap for larger allocations. This can be a useful optimization for improving cache +//! locality and reducing allocator traffic for workloads that fit within the inline buffer. +//! +//! ## no_std support +//! +//! By default, `smallvec` depends on `libstd`. However, it can be configured to use the unstable +//! `liballoc` API instead, for use on platforms that have `liballoc` but not `libstd`. This +//! configuration is currently unstable and is not guaranteed to work on all versions of Rust. +//! +//! To depend on `smallvec` without `libstd`, use `default-features = false` in the `smallvec` +//! section of Cargo.toml to disable its `"std"` feature. +//! +//! ## `union` feature +//! +//! When the `union` feature is enabled `smallvec` will track its state (inline or spilled) +//! without the use of an enum tag, reducing the size of the `smallvec` by one machine word. +//! This means that there is potentially no space overhead compared to `Vec`. +//! Note that `smallvec` can still be larger than `Vec` if the inline buffer is larger than two +//! machine words. +//! +//! To use this feature add `features = ["union"]` in the `smallvec` section of Cargo.toml. +//! Note that this feature requires a nightly compiler (for now). + +#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(feature = "union", feature(untagged_unions))] +#![cfg_attr(feature = "specialization", feature(specialization))] +#![cfg_attr(feature = "may_dangle", feature(dropck_eyepatch))] +#![deny(missing_docs)] + + +#[cfg(not(feature = "std"))] +#[macro_use] +extern crate alloc; + +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + +#[cfg(feature = "serde")] +extern crate serde; + +extern crate maybe_uninit; + +#[cfg(not(feature = "std"))] +mod std { + pub use core::*; +} + +use maybe_uninit::MaybeUninit; + +use std::borrow::{Borrow, BorrowMut}; +use std::cmp; +use std::fmt; +use std::hash::{Hash, Hasher}; +use std::iter::{IntoIterator, FromIterator, repeat}; +use std::mem; +use std::ops; +use std::ptr; +use std::slice; +#[cfg(feature = "std")] +use std::io; +#[cfg(feature = "serde")] +use serde::ser::{Serialize, Serializer, SerializeSeq}; +#[cfg(feature = "serde")] +use serde::de::{Deserialize, Deserializer, SeqAccess, Visitor}; +#[cfg(feature = "serde")] +use std::marker::PhantomData; + +/// Creates a [`SmallVec`] containing the arguments. +/// +/// `smallvec!` allows `SmallVec`s to be defined with the same syntax as array expressions. +/// There are two forms of this macro: +/// +/// - Create a [`SmallVec`] containing a given list of elements: +/// +/// ``` +/// # #[macro_use] extern crate smallvec; +/// # use smallvec::SmallVec; +/// # fn main() { +/// let v: SmallVec<[_; 128]> = smallvec![1, 2, 3]; +/// assert_eq!(v[0], 1); +/// assert_eq!(v[1], 2); +/// assert_eq!(v[2], 3); +/// # } +/// ``` +/// +/// - Create a [`SmallVec`] from a given element and size: +/// +/// ``` +/// # #[macro_use] extern crate smallvec; +/// # use smallvec::SmallVec; +/// # fn main() { +/// let v: SmallVec<[_; 0x8000]> = smallvec![1; 3]; +/// assert_eq!(v, SmallVec::from_buf([1, 1, 1])); +/// # } +/// ``` +/// +/// Note that unlike array expressions this syntax supports all elements +/// which implement [`Clone`] and the number of elements doesn't have to be +/// a constant. +/// +/// This will use `clone` to duplicate an expression, so one should be careful +/// using this with types having a nonstandard `Clone` implementation. For +/// example, `smallvec![Rc::new(1); 5]` will create a vector of five references +/// to the same boxed integer value, not five references pointing to independently +/// boxed integers. + +#[macro_export] +macro_rules! smallvec { + // count helper: transform any expression into 1 + (@one $x:expr) => (1usize); + ($elem:expr; $n:expr) => ({ + $crate::SmallVec::from_elem($elem, $n) + }); + ($($x:expr),*$(,)*) => ({ + let count = 0usize $(+ smallvec!(@one $x))*; + let mut vec = $crate::SmallVec::new(); + if count <= vec.inline_size() { + $(vec.push($x);)* + vec + } else { + $crate::SmallVec::from_vec(vec![$($x,)*]) + } + }); +} + +/// Hint to the optimizer that any code path which calls this function is +/// statically unreachable and can be removed. +/// +/// Equivalent to `std::hint::unreachable_unchecked` but works in older versions of Rust. +#[inline] +pub unsafe fn unreachable() -> ! { + enum Void {} + let x: &Void = mem::transmute(1usize); + match *x {} +} + +/// `panic!()` in debug builds, optimization hint in release. +#[cfg(not(feature = "union"))] +macro_rules! debug_unreachable { + () => { debug_unreachable!("entered unreachable code") }; + ($e:expr) => { + if cfg!(not(debug_assertions)) { + unreachable(); + } else { + panic!($e); + } + } +} + +/// Common operations implemented by both `Vec` and `SmallVec`. +/// +/// This can be used to write generic code that works with both `Vec` and `SmallVec`. +/// +/// ## Example +/// +/// ```rust +/// use smallvec::{VecLike, SmallVec}; +/// +/// fn initialize<V: VecLike<u8>>(v: &mut V) { +/// for i in 0..5 { +/// v.push(i); +/// } +/// } +/// +/// let mut vec = Vec::new(); +/// initialize(&mut vec); +/// +/// let mut small_vec = SmallVec::<[u8; 8]>::new(); +/// initialize(&mut small_vec); +/// ``` +#[deprecated(note = "Use `Extend` and `Deref<[T]>` instead")] +pub trait VecLike<T>: + ops::Index<usize, Output=T> + + ops::IndexMut<usize> + + ops::Index<ops::Range<usize>, Output=[T]> + + ops::IndexMut<ops::Range<usize>> + + ops::Index<ops::RangeFrom<usize>, Output=[T]> + + ops::IndexMut<ops::RangeFrom<usize>> + + ops::Index<ops::RangeTo<usize>, Output=[T]> + + ops::IndexMut<ops::RangeTo<usize>> + + ops::Index<ops::RangeFull, Output=[T]> + + ops::IndexMut<ops::RangeFull> + + ops::DerefMut<Target = [T]> + + Extend<T> { + + /// Append an element to the vector. + fn push(&mut self, value: T); +} + +#[allow(deprecated)] +impl<T> VecLike<T> for Vec<T> { + #[inline] + fn push(&mut self, value: T) { + Vec::push(self, value); + } +} + +/// Trait to be implemented by a collection that can be extended from a slice +/// +/// ## Example +/// +/// ```rust +/// use smallvec::{ExtendFromSlice, SmallVec}; +/// +/// fn initialize<V: ExtendFromSlice<u8>>(v: &mut V) { +/// v.extend_from_slice(b"Test!"); +/// } +/// +/// let mut vec = Vec::new(); +/// initialize(&mut vec); +/// assert_eq!(&vec, b"Test!"); +/// +/// let mut small_vec = SmallVec::<[u8; 8]>::new(); +/// initialize(&mut small_vec); +/// assert_eq!(&small_vec as &[_], b"Test!"); +/// ``` +pub trait ExtendFromSlice<T> { + /// Extends a collection from a slice of its element type + fn extend_from_slice(&mut self, other: &[T]); +} + +impl<T: Clone> ExtendFromSlice<T> for Vec<T> { + fn extend_from_slice(&mut self, other: &[T]) { + Vec::extend_from_slice(self, other) + } +} + +unsafe fn deallocate<T>(ptr: *mut T, capacity: usize) { + let _vec: Vec<T> = Vec::from_raw_parts(ptr, 0, capacity); + // Let it drop. +} + +/// An iterator that removes the items from a `SmallVec` and yields them by value. +/// +/// Returned from [`SmallVec::drain`][1]. +/// +/// [1]: struct.SmallVec.html#method.drain +pub struct Drain<'a, T: 'a> { + iter: slice::IterMut<'a,T>, +} + +impl<'a, T: 'a> Iterator for Drain<'a,T> { + type Item = T; + + #[inline] + fn next(&mut self) -> Option<T> { + self.iter.next().map(|reference| unsafe { ptr::read(reference) }) + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + self.iter.size_hint() + } +} + +impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> { + #[inline] + fn next_back(&mut self) -> Option<T> { + self.iter.next_back().map(|reference| unsafe { ptr::read(reference) }) + } +} + +impl<'a, T> ExactSizeIterator for Drain<'a, T> { } + +impl<'a, T: 'a> Drop for Drain<'a,T> { + fn drop(&mut self) { + // Destroy the remaining elements. + for _ in self.by_ref() {} + } +} + +#[cfg(feature = "union")] +union SmallVecData<A: Array> { + inline: MaybeUninit<A>, + heap: (*mut A::Item, usize), +} + +#[cfg(feature = "union")] +impl<A: Array> SmallVecData<A> { + #[inline] + unsafe fn inline(&self) -> *const A::Item { + self.inline.as_ptr() as *const A::Item + } + #[inline] + unsafe fn inline_mut(&mut self) -> *mut A::Item { + self.inline.as_mut_ptr() as *mut A::Item + } + #[inline] + fn from_inline(inline: MaybeUninit<A>) -> SmallVecData<A> { + SmallVecData { inline } + } + #[inline] + unsafe fn into_inline(self) -> MaybeUninit<A> { + self.inline + } + #[inline] + unsafe fn heap(&self) -> (*mut A::Item, usize) { + self.heap + } + #[inline] + unsafe fn heap_mut(&mut self) -> &mut (*mut A::Item, usize) { + &mut self.heap + } + #[inline] + fn from_heap(ptr: *mut A::Item, len: usize) -> SmallVecData<A> { + SmallVecData { heap: (ptr, len) } + } +} + +#[cfg(not(feature = "union"))] +enum SmallVecData<A: Array> { + Inline(MaybeUninit<A>), + Heap((*mut A::Item, usize)), +} + +#[cfg(not(feature = "union"))] +impl<A: Array> SmallVecData<A> { + #[inline] + unsafe fn inline(&self) -> *const A::Item { + match *self { + SmallVecData::Inline(ref a) => a.as_ptr() as *const A::Item, + _ => debug_unreachable!(), + } + } + #[inline] + unsafe fn inline_mut(&mut self) -> *mut A::Item { + match *self { + SmallVecData::Inline(ref mut a) => a.as_mut_ptr() as *mut A::Item, + _ => debug_unreachable!(), + } + } + #[inline] + fn from_inline(inline: MaybeUninit<A>) -> SmallVecData<A> { + SmallVecData::Inline(inline) + } + #[inline] + unsafe fn into_inline(self) -> MaybeUninit<A> { + match self { + SmallVecData::Inline(a) => a, + _ => debug_unreachable!(), + } + } + #[inline] + unsafe fn heap(&self) -> (*mut A::Item, usize) { + match *self { + SmallVecData::Heap(data) => data, + _ => debug_unreachable!(), + } + } + #[inline] + unsafe fn heap_mut(&mut self) -> &mut (*mut A::Item, usize) { + match *self { + SmallVecData::Heap(ref mut data) => data, + _ => debug_unreachable!(), + } + } + #[inline] + fn from_heap(ptr: *mut A::Item, len: usize) -> SmallVecData<A> { + SmallVecData::Heap((ptr, len)) + } +} + +unsafe impl<A: Array + Send> Send for SmallVecData<A> {} +unsafe impl<A: Array + Sync> Sync for SmallVecData<A> {} + +/// A `Vec`-like container that can store a small number of elements inline. +/// +/// `SmallVec` acts like a vector, but can store a limited amount of data inline within the +/// `SmallVec` struct rather than in a separate allocation. If the data exceeds this limit, the +/// `SmallVec` will "spill" its data onto the heap, allocating a new buffer to hold it. +/// +/// The amount of data that a `SmallVec` can store inline depends on its backing store. The backing +/// store can be any type that implements the `Array` trait; usually it is a small fixed-sized +/// array. For example a `SmallVec<[u64; 8]>` can hold up to eight 64-bit integers inline. +/// +/// ## Example +/// +/// ```rust +/// use smallvec::SmallVec; +/// let mut v = SmallVec::<[u8; 4]>::new(); // initialize an empty vector +/// +/// // The vector can hold up to 4 items without spilling onto the heap. +/// v.extend(0..4); +/// assert_eq!(v.len(), 4); +/// assert!(!v.spilled()); +/// +/// // Pushing another element will force the buffer to spill: +/// v.push(4); +/// assert_eq!(v.len(), 5); +/// assert!(v.spilled()); +/// ``` +pub struct SmallVec<A: Array> { + // The capacity field is used to determine which of the storage variants is active: + // If capacity <= A::size() then the inline variant is used and capacity holds the current length of the vector (number of elements actually in use). + // If capacity > A::size() then the heap variant is used and capacity holds the size of the memory allocation. + capacity: usize, + data: SmallVecData<A>, +} + +impl<A: Array> SmallVec<A> { + /// Construct an empty vector + #[inline] + pub fn new() -> SmallVec<A> { + // Try to detect invalid custom implementations of `Array`. Hopefuly, + // this check should be optimized away entirely for valid ones. + assert!( + mem::size_of::<A>() == A::size() * mem::size_of::<A::Item>() + && mem::align_of::<A>() >= mem::align_of::<A::Item>() + ); + SmallVec { + capacity: 0, + data: SmallVecData::from_inline(MaybeUninit::uninit()), + } + } + + /// Construct an empty vector with enough capacity pre-allocated to store at least `n` + /// elements. + /// + /// Will create a heap allocation only if `n` is larger than the inline capacity. + /// + /// ``` + /// # use smallvec::SmallVec; + /// + /// let v: SmallVec<[u8; 3]> = SmallVec::with_capacity(100); + /// + /// assert!(v.is_empty()); + /// assert!(v.capacity() >= 100); + /// ``` + #[inline] + pub fn with_capacity(n: usize) -> Self { + let mut v = SmallVec::new(); + v.reserve_exact(n); + v + } + + /// Construct a new `SmallVec` from a `Vec<A::Item>`. + /// + /// Elements will be copied to the inline buffer if vec.capacity() <= A::size(). + /// + /// ```rust + /// use smallvec::SmallVec; + /// + /// let vec = vec![1, 2, 3, 4, 5]; + /// let small_vec: SmallVec<[_; 3]> = SmallVec::from_vec(vec); + /// + /// assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]); + /// ``` + #[inline] + pub fn from_vec(mut vec: Vec<A::Item>) -> SmallVec<A> { + if vec.capacity() <= A::size() { + unsafe { + let mut data = SmallVecData::<A>::from_inline(MaybeUninit::uninit()); + let len = vec.len(); + vec.set_len(0); + ptr::copy_nonoverlapping(vec.as_ptr(), data.inline_mut(), len); + + SmallVec { + capacity: len, + data, + } + } + } else { + let (ptr, cap, len) = (vec.as_mut_ptr(), vec.capacity(), vec.len()); + mem::forget(vec); + + SmallVec { + capacity: cap, + data: SmallVecData::from_heap(ptr, len), + } + } + } + + /// Constructs a new `SmallVec` on the stack from an `A` without + /// copying elements. + /// + /// ```rust + /// use smallvec::SmallVec; + /// + /// let buf = [1, 2, 3, 4, 5]; + /// let small_vec: SmallVec<_> = SmallVec::from_buf(buf); + /// + /// assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]); + /// ``` + #[inline] + pub fn from_buf(buf: A) -> SmallVec<A> { + SmallVec { + capacity: A::size(), + data: SmallVecData::from_inline(MaybeUninit::new(buf)), + } + } + + /// Constructs a new `SmallVec` on the stack from an `A` without + /// copying elements. Also sets the length, which must be less or + /// equal to the size of `buf`. + /// + /// ```rust + /// use smallvec::SmallVec; + /// + /// let buf = [1, 2, 3, 4, 5, 0, 0, 0]; + /// let small_vec: SmallVec<_> = SmallVec::from_buf_and_len(buf, 5); + /// + /// assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]); + /// ``` + #[inline] + pub fn from_buf_and_len(buf: A, len: usize) -> SmallVec<A> { + assert!(len <= A::size()); + unsafe { SmallVec::from_buf_and_len_unchecked(buf, len) } + } + + /// Constructs a new `SmallVec` on the stack from an `A` without + /// copying elements. Also sets the length. The user is responsible + /// for ensuring that `len <= A::size()`. + /// + /// ```rust + /// use smallvec::SmallVec; + /// + /// let buf = [1, 2, 3, 4, 5, 0, 0, 0]; + /// let small_vec: SmallVec<_> = unsafe { + /// SmallVec::from_buf_and_len_unchecked(buf, 5) + /// }; + /// + /// assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]); + /// ``` + #[inline] + pub unsafe fn from_buf_and_len_unchecked(buf: A, len: usize) -> SmallVec<A> { + SmallVec { + capacity: len, + data: SmallVecData::from_inline(MaybeUninit::new(buf)), + } + } + + + /// Sets the length of a vector. + /// + /// This will explicitly set the size of the vector, without actually + /// modifying its buffers, so it is up to the caller to ensure that the + /// vector is actually the specified size. + pub unsafe fn set_len(&mut self, new_len: usize) { + let (_, len_ptr, _) = self.triple_mut(); + *len_ptr = new_len; + } + + /// The maximum number of elements this vector can hold inline + #[inline] + pub fn inline_size(&self) -> usize { + A::size() + } + + /// The number of elements stored in the vector + #[inline] + pub fn len(&self) -> usize { + self.triple().1 + } + + /// Returns `true` if the vector is empty + #[inline] + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// The number of items the vector can hold without reallocating + #[inline] + pub fn capacity(&self) -> usize { + self.triple().2 + } + + /// Returns a tuple with (data ptr, len, capacity) + /// Useful to get all SmallVec properties with a single check of the current storage variant. + #[inline] + fn triple(&self) -> (*const A::Item, usize, usize) { + unsafe { + if self.spilled() { + let (ptr, len) = self.data.heap(); + (ptr, len, self.capacity) + } else { + (self.data.inline(), self.capacity, A::size()) + } + } + } + + /// Returns a tuple with (data ptr, len ptr, capacity) + #[inline] + fn triple_mut(&mut self) -> (*mut A::Item, &mut usize, usize) { + unsafe { + if self.spilled() { + let &mut (ptr, ref mut len_ptr) = self.data.heap_mut(); + (ptr, len_ptr, self.capacity) + } else { + (self.data.inline_mut(), &mut self.capacity, A::size()) + } + } + } + + /// Returns `true` if the data has spilled into a separate heap-allocated buffer. + #[inline] + pub fn spilled(&self) -> bool { + self.capacity > A::size() + } + + /// Empty the vector and return an iterator over its former contents. + pub fn drain(&mut self) -> Drain<A::Item> { + unsafe { + let ptr = self.as_mut_ptr(); + + let current_len = self.len(); + self.set_len(0); + + let slice = slice::from_raw_parts_mut(ptr, current_len); + + Drain { + iter: slice.iter_mut(), + } + } + } + + /// Append an item to the vector. + #[inline] + pub fn push(&mut self, value: A::Item) { + unsafe { + let (_, &mut len, cap) = self.triple_mut(); + if len == cap { + self.reserve(1); + } + let (ptr, len_ptr, _) = self.triple_mut(); + *len_ptr = len + 1; + ptr::write(ptr.offset(len as isize), value); + } + } + + /// Remove an item from the end of the vector and return it, or None if empty. + #[inline] + pub fn pop(&mut self) -> Option<A::Item> { + unsafe { + let (ptr, len_ptr, _) = self.triple_mut(); + if *len_ptr == 0 { + return None; + } + let last_index = *len_ptr - 1; + *len_ptr = last_index; + Some(ptr::read(ptr.offset(last_index as isize))) + } + } + + /// Re-allocate to set the capacity to `max(new_cap, inline_size())`. + /// + /// Panics if `new_cap` is less than the vector's length. + pub fn grow(&mut self, new_cap: usize) { + unsafe { + let (ptr, &mut len, cap) = self.triple_mut(); + let unspilled = !self.spilled(); + assert!(new_cap >= len); + if new_cap <= self.inline_size() { + if unspilled { + return; + } + self.data = SmallVecData::from_inline(MaybeUninit::uninit()); + ptr::copy_nonoverlapping(ptr, self.data.inline_mut(), len); + self.capacity = len; + } else if new_cap != cap { + let mut vec = Vec::with_capacity(new_cap); + let new_alloc = vec.as_mut_ptr(); + mem::forget(vec); + ptr::copy_nonoverlapping(ptr, new_alloc, len); + self.data = SmallVecData::from_heap(new_alloc, len); + self.capacity = new_cap; + if unspilled { + return; + } + } else { + return; + } + deallocate(ptr, cap); + } + } + + /// Reserve capacity for `additional` more elements to be inserted. + /// + /// May reserve more space to avoid frequent reallocations. + /// + /// If the new capacity would overflow `usize` then it will be set to `usize::max_value()` + /// instead. (This means that inserting `additional` new elements is not guaranteed to be + /// possible after calling this function.) + #[inline] + pub fn reserve(&mut self, additional: usize) { + // prefer triple_mut() even if triple() would work + // so that the optimizer removes duplicated calls to it + // from callers like insert() + let (_, &mut len, cap) = self.triple_mut(); + if cap - len < additional { + let new_cap = len.checked_add(additional). + and_then(usize::checked_next_power_of_two). + unwrap_or(usize::max_value()); + self.grow(new_cap); + } + } + + /// Reserve the minimum capacity for `additional` more elements to be inserted. + /// + /// Panics if the new capacity overflows `usize`. + pub fn reserve_exact(&mut self, additional: usize) { + let (_, &mut len, cap) = self.triple_mut(); + if cap - len < additional { + match len.checked_add(additional) { + Some(cap) => self.grow(cap), + None => panic!("reserve_exact overflow"), + } + } + } + + /// Shrink the capacity of the vector as much as possible. + /// + /// When possible, this will move data from an external heap buffer to the vector's inline + /// storage. + pub fn shrink_to_fit(&mut self) { + if !self.spilled() { + return; + } + let len = self.len(); + if self.inline_size() >= len { + unsafe { + let (ptr, len) = self.data.heap(); + self.data = SmallVecData::from_inline(MaybeUninit::uninit()); + ptr::copy_nonoverlapping(ptr, self.data.inline_mut(), len); + deallocate(ptr, self.capacity); + self.capacity = len; + } + } else if self.capacity() > len { + self.grow(len); + } + } + + /// Shorten the vector, keeping the first `len` elements and dropping the rest. + /// + /// If `len` is greater than or equal to the vector's current length, this has no + /// effect. + /// + /// This does not re-allocate. If you want the vector's capacity to shrink, call + /// `shrink_to_fit` after truncating. + pub fn truncate(&mut self, len: usize) { + unsafe { + let (ptr, len_ptr, _) = self.triple_mut(); + while len < *len_ptr { + let last_index = *len_ptr - 1; + *len_ptr = last_index; + ptr::drop_in_place(ptr.offset(last_index as isize)); + } + } + } + + /// Extracts a slice containing the entire vector. + /// + /// Equivalent to `&s[..]`. + pub fn as_slice(&self) -> &[A::Item] { + self + } + + /// Extracts a mutable slice of the entire vector. + /// + /// Equivalent to `&mut s[..]`. + pub fn as_mut_slice(&mut self) -> &mut [A::Item] { + self + } + + /// Remove the element at position `index`, replacing it with the last element. + /// + /// This does not preserve ordering, but is O(1). + /// + /// Panics if `index` is out of bounds. + #[inline] + pub fn swap_remove(&mut self, index: usize) -> A::Item { + let len = self.len(); + self.swap(len - 1, index); + self.pop().unwrap_or_else(|| unsafe { unreachable() }) + } + + /// Remove all elements from the vector. + #[inline] + pub fn clear(&mut self) { + self.truncate(0); + } + + /// Remove and return the element at position `index`, shifting all elements after it to the + /// left. + /// + /// Panics if `index` is out of bounds. + pub fn remove(&mut self, index: usize) -> A::Item { + unsafe { + let (mut ptr, len_ptr, _) = self.triple_mut(); + let len = *len_ptr; + assert!(index < len); + *len_ptr = len - 1; + ptr = ptr.offset(index as isize); + let item = ptr::read(ptr); + ptr::copy(ptr.offset(1), ptr, len - index - 1); + item + } + } + + /// Insert an element at position `index`, shifting all elements after it to the right. + /// + /// Panics if `index` is out of bounds. + pub fn insert(&mut self, index: usize, element: A::Item) { + self.reserve(1); + + unsafe { + let (mut ptr, len_ptr, _) = self.triple_mut(); + let len = *len_ptr; + assert!(index <= len); + *len_ptr = len + 1; + ptr = ptr.offset(index as isize); + ptr::copy(ptr, ptr.offset(1), len - index); + ptr::write(ptr, element); + } + } + + /// Insert multiple elements at position `index`, shifting all following elements toward the + /// back. + pub fn insert_many<I: IntoIterator<Item=A::Item>>(&mut self, index: usize, iterable: I) { + let iter = iterable.into_iter(); + if index == self.len() { + return self.extend(iter); + } + + let (lower_size_bound, _) = iter.size_hint(); + assert!(lower_size_bound <= std::isize::MAX as usize); // Ensure offset is indexable + assert!(index + lower_size_bound >= index); // Protect against overflow + self.reserve(lower_size_bound); + + unsafe { + let old_len = self.len(); + assert!(index <= old_len); + let mut ptr = self.as_mut_ptr().offset(index as isize); + + // Move the trailing elements. + ptr::copy(ptr, ptr.offset(lower_size_bound as isize), old_len - index); + + // In case the iterator panics, don't double-drop the items we just copied above. + self.set_len(index); + + let mut num_added = 0; + for element in iter { + let mut cur = ptr.offset(num_added as isize); + if num_added >= lower_size_bound { + // Iterator provided more elements than the hint. Move trailing items again. + self.reserve(1); + ptr = self.as_mut_ptr().offset(index as isize); + cur = ptr.offset(num_added as isize); + ptr::copy(cur, cur.offset(1), old_len - index); + } + ptr::write(cur, element); + num_added += 1; + } + if num_added < lower_size_bound { + // Iterator provided fewer elements than the hint + ptr::copy(ptr.offset(lower_size_bound as isize), ptr.offset(num_added as isize), old_len - index); + } + + self.set_len(old_len + num_added); + } + } + + /// Convert a SmallVec to a Vec, without reallocating if the SmallVec has already spilled onto + /// the heap. + pub fn into_vec(self) -> Vec<A::Item> { + if self.spilled() { + unsafe { + let (ptr, len) = self.data.heap(); + let v = Vec::from_raw_parts(ptr, len, self.capacity); + mem::forget(self); + v + } + } else { + self.into_iter().collect() + } + } + + /// Convert the SmallVec into an `A` if possible. Otherwise return `Err(Self)`. + /// + /// This method returns `Err(Self)` if the SmallVec is too short (and the `A` contains uninitialized elements), + /// or if the SmallVec is too long (and all the elements were spilled to the heap). + pub fn into_inner(self) -> Result<A, Self> { + if self.spilled() || self.len() != A::size() { + Err(self) + } else { + unsafe { + let data = ptr::read(&self.data); + mem::forget(self); + Ok(data.into_inline().assume_init()) + } + } + } + + /// Retains only the elements specified by the predicate. + /// + /// In other words, remove all elements `e` such that `f(&e)` returns `false`. + /// This method operates in place and preserves the order of the retained + /// elements. + pub fn retain<F: FnMut(&mut A::Item) -> bool>(&mut self, mut f: F) { + let mut del = 0; + let len = self.len(); + for i in 0..len { + if !f(&mut self[i]) { + del += 1; + } else if del > 0 { + self.swap(i - del, i); + } + } + self.truncate(len - del); + } + + /// Removes consecutive duplicate elements. + pub fn dedup(&mut self) where A::Item: PartialEq<A::Item> { + self.dedup_by(|a, b| a == b); + } + + /// Removes consecutive duplicate elements using the given equality relation. + pub fn dedup_by<F>(&mut self, mut same_bucket: F) + where F: FnMut(&mut A::Item, &mut A::Item) -> bool + { + // See the implementation of Vec::dedup_by in the + // standard library for an explanation of this algorithm. + let len = self.len(); + if len <= 1 { + return; + } + + let ptr = self.as_mut_ptr(); + let mut w: usize = 1; + + unsafe { + for r in 1..len { + let p_r = ptr.offset(r as isize); + let p_wm1 = ptr.offset((w - 1) as isize); + if !same_bucket(&mut *p_r, &mut *p_wm1) { + if r != w { + let p_w = p_wm1.offset(1); + mem::swap(&mut *p_r, &mut *p_w); + } + w += 1; + } + } + } + + self.truncate(w); + } + + /// Removes consecutive elements that map to the same key. + pub fn dedup_by_key<F, K>(&mut self, mut key: F) + where F: FnMut(&mut A::Item) -> K, + K: PartialEq<K> + { + self.dedup_by(|a, b| key(a) == key(b)); + } + + /// Creates a `SmallVec` directly from the raw components of another + /// `SmallVec`. + /// + /// # Safety + /// + /// This is highly unsafe, due to the number of invariants that aren't + /// checked: + /// + /// * `ptr` needs to have been previously allocated via `SmallVec` for its + /// spilled storage (at least, it's highly likely to be incorrect if it + /// wasn't). + /// * `ptr`'s `A::Item` type needs to be the same size and alignment that + /// it was allocated with + /// * `length` needs to be less than or equal to `capacity`. + /// * `capacity` needs to be the capacity that the pointer was allocated + /// with. + /// + /// Violating these may cause problems like corrupting the allocator's + /// internal data structures. + /// + /// Additionally, `capacity` must be greater than the amount of inline + /// storage `A` has; that is, the new `SmallVec` must need to spill over + /// into heap allocated storage. This condition is asserted against. + /// + /// The ownership of `ptr` is effectively transferred to the + /// `SmallVec` which may then deallocate, reallocate or change the + /// contents of memory pointed to by the pointer at will. Ensure + /// that nothing else uses the pointer after calling this + /// function. + /// + /// # Examples + /// + /// ``` + /// # #[macro_use] extern crate smallvec; + /// # use smallvec::SmallVec; + /// use std::mem; + /// use std::ptr; + /// + /// fn main() { + /// let mut v: SmallVec<[_; 1]> = smallvec![1, 2, 3]; + /// + /// // Pull out the important parts of `v`. + /// let p = v.as_mut_ptr(); + /// let len = v.len(); + /// let cap = v.capacity(); + /// let spilled = v.spilled(); + /// + /// unsafe { + /// // Forget all about `v`. The heap allocation that stored the + /// // three values won't be deallocated. + /// mem::forget(v); + /// + /// // Overwrite memory with [4, 5, 6]. + /// // + /// // This is only safe if `spilled` is true! Otherwise, we are + /// // writing into the old `SmallVec`'s inline storage on the + /// // stack. + /// assert!(spilled); + /// for i in 0..len as isize { + /// ptr::write(p.offset(i), 4 + i); + /// } + /// + /// // Put everything back together into a SmallVec with a different + /// // amount of inline storage, but which is still less than `cap`. + /// let rebuilt = SmallVec::<[_; 2]>::from_raw_parts(p, len, cap); + /// assert_eq!(&*rebuilt, &[4, 5, 6]); + /// } + /// } + pub unsafe fn from_raw_parts( + ptr: *mut A::Item, + length: usize, + capacity: usize, + ) -> SmallVec<A> { + assert!(capacity > A::size()); + SmallVec { + capacity, + data: SmallVecData::from_heap(ptr, length), + } + } +} + +impl<A: Array> SmallVec<A> where A::Item: Copy { + /// Copy the elements from a slice into a new `SmallVec`. + /// + /// For slices of `Copy` types, this is more efficient than `SmallVec::from(slice)`. + pub fn from_slice(slice: &[A::Item]) -> Self { + let len = slice.len(); + if len <= A::size() { + SmallVec { + capacity: len, + data: SmallVecData::from_inline(unsafe { + let mut data: MaybeUninit<A> = MaybeUninit::uninit(); + ptr::copy_nonoverlapping( + slice.as_ptr(), + data.as_mut_ptr() as *mut A::Item, + len, + ); + data + }) + } + } else { + let mut b = slice.to_vec(); + let (ptr, cap) = (b.as_mut_ptr(), b.capacity()); + mem::forget(b); + SmallVec { + capacity: cap, + data: SmallVecData::from_heap(ptr, len), + } + } + } + + /// Copy elements from a slice into the vector at position `index`, shifting any following + /// elements toward the back. + /// + /// For slices of `Copy` types, this is more efficient than `insert`. + pub fn insert_from_slice(&mut self, index: usize, slice: &[A::Item]) { + self.reserve(slice.len()); + + let len = self.len(); + assert!(index <= len); + + unsafe { + let slice_ptr = slice.as_ptr(); + let ptr = self.as_mut_ptr().offset(index as isize); + ptr::copy(ptr, ptr.offset(slice.len() as isize), len - index); + ptr::copy_nonoverlapping(slice_ptr, ptr, slice.len()); + self.set_len(len + slice.len()); + } + } + + /// Copy elements from a slice and append them to the vector. + /// + /// For slices of `Copy` types, this is more efficient than `extend`. + #[inline] + pub fn extend_from_slice(&mut self, slice: &[A::Item]) { + let len = self.len(); + self.insert_from_slice(len, slice); + } +} + +impl<A: Array> SmallVec<A> where A::Item: Clone { + /// Resizes the vector so that its length is equal to `len`. + /// + /// If `len` is less than the current length, the vector simply truncated. + /// + /// If `len` is greater than the current length, `value` is appended to the + /// vector until its length equals `len`. + pub fn resize(&mut self, len: usize, value: A::Item) { + let old_len = self.len(); + + if len > old_len { + self.extend(repeat(value).take(len - old_len)); + } else { + self.truncate(len); + } + } + + /// Creates a `SmallVec` with `n` copies of `elem`. + /// ``` + /// use smallvec::SmallVec; + /// + /// let v = SmallVec::<[char; 128]>::from_elem('d', 2); + /// assert_eq!(v, SmallVec::from_buf(['d', 'd'])); + /// ``` + pub fn from_elem(elem: A::Item, n: usize) -> Self { + if n > A::size() { + vec![elem; n].into() + } else { + let mut v = SmallVec::<A>::new(); + unsafe { + let (ptr, len_ptr, _) = v.triple_mut(); + let mut local_len = SetLenOnDrop::new(len_ptr); + + for i in 0..n as isize { + ::std::ptr::write(ptr.offset(i), elem.clone()); + local_len.increment_len(1); + } + } + v + } + } +} + +impl<A: Array> ops::Deref for SmallVec<A> { + type Target = [A::Item]; + #[inline] + fn deref(&self) -> &[A::Item] { + unsafe { + let (ptr, len, _) = self.triple(); + slice::from_raw_parts(ptr, len) + } + } +} + +impl<A: Array> ops::DerefMut for SmallVec<A> { + #[inline] + fn deref_mut(&mut self) -> &mut [A::Item] { + unsafe { + let (ptr, &mut len, _) = self.triple_mut(); + slice::from_raw_parts_mut(ptr, len) + } + } +} + +impl<A: Array> AsRef<[A::Item]> for SmallVec<A> { + #[inline] + fn as_ref(&self) -> &[A::Item] { + self + } +} + +impl<A: Array> AsMut<[A::Item]> for SmallVec<A> { + #[inline] + fn as_mut(&mut self) -> &mut [A::Item] { + self + } +} + +impl<A: Array> Borrow<[A::Item]> for SmallVec<A> { + #[inline] + fn borrow(&self) -> &[A::Item] { + self + } +} + +impl<A: Array> BorrowMut<[A::Item]> for SmallVec<A> { + #[inline] + fn borrow_mut(&mut self) -> &mut [A::Item] { + self + } +} + +#[cfg(feature = "std")] +impl<A: Array<Item = u8>> io::Write for SmallVec<A> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + self.extend_from_slice(buf); + Ok(buf.len()) + } + + #[inline] + fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { + self.extend_from_slice(buf); + Ok(()) + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } +} + +#[cfg(feature = "serde")] +impl<A: Array> Serialize for SmallVec<A> where A::Item: Serialize { + fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { + let mut state = serializer.serialize_seq(Some(self.len()))?; + for item in self { + state.serialize_element(&item)?; + } + state.end() + } +} + +#[cfg(feature = "serde")] +impl<'de, A: Array> Deserialize<'de> for SmallVec<A> where A::Item: Deserialize<'de> { + fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { + deserializer.deserialize_seq(SmallVecVisitor{phantom: PhantomData}) + } +} + +#[cfg(feature = "serde")] +struct SmallVecVisitor<A> { + phantom: PhantomData<A> +} + +#[cfg(feature = "serde")] +impl<'de, A: Array> Visitor<'de> for SmallVecVisitor<A> +where A::Item: Deserialize<'de>, +{ + type Value = SmallVec<A>; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a sequence") + } + + fn visit_seq<B>(self, mut seq: B) -> Result<Self::Value, B::Error> + where + B: SeqAccess<'de>, + { + let len = seq.size_hint().unwrap_or(0); + let mut values = SmallVec::with_capacity(len); + + while let Some(value) = seq.next_element()? { + values.push(value); + } + + Ok(values) + } +} + + +#[cfg(feature = "specialization")] +trait SpecFrom<A: Array, S> { + fn spec_from(slice: S) -> SmallVec<A>; +} + +#[cfg(feature = "specialization")] +mod specialization; + +#[cfg(feature = "specialization")] +impl<'a, A: Array> SpecFrom<A, &'a [A::Item]> for SmallVec<A> where A::Item: Copy { + #[inline] + fn spec_from(slice: &'a [A::Item]) -> SmallVec<A> { + SmallVec::from_slice(slice) + } +} + +impl<'a, A: Array> From<&'a [A::Item]> for SmallVec<A> where A::Item: Clone { + #[cfg(not(feature = "specialization"))] + #[inline] + fn from(slice: &'a [A::Item]) -> SmallVec<A> { + slice.into_iter().cloned().collect() + } + + #[cfg(feature = "specialization")] + #[inline] + fn from(slice: &'a [A::Item]) -> SmallVec<A> { + SmallVec::spec_from(slice) + } +} + +impl<A: Array> From<Vec<A::Item>> for SmallVec<A> { + #[inline] + fn from(vec: Vec<A::Item>) -> SmallVec<A> { + SmallVec::from_vec(vec) + } +} + +impl<A: Array> From<A> for SmallVec<A> { + #[inline] + fn from(array: A) -> SmallVec<A> { + SmallVec::from_buf(array) + } +} + +macro_rules! impl_index { + ($index_type: ty, $output_type: ty) => { + impl<A: Array> ops::Index<$index_type> for SmallVec<A> { + type Output = $output_type; + #[inline] + fn index(&self, index: $index_type) -> &$output_type { + &(&**self)[index] + } + } + + impl<A: Array> ops::IndexMut<$index_type> for SmallVec<A> { + #[inline] + fn index_mut(&mut self, index: $index_type) -> &mut $output_type { + &mut (&mut **self)[index] + } + } + } +} + +impl_index!(usize, A::Item); +impl_index!(ops::Range<usize>, [A::Item]); +impl_index!(ops::RangeFrom<usize>, [A::Item]); +impl_index!(ops::RangeTo<usize>, [A::Item]); +impl_index!(ops::RangeFull, [A::Item]); + +impl<A: Array> ExtendFromSlice<A::Item> for SmallVec<A> where A::Item: Copy { + fn extend_from_slice(&mut self, other: &[A::Item]) { + SmallVec::extend_from_slice(self, other) + } +} + +#[allow(deprecated)] +impl<A: Array> VecLike<A::Item> for SmallVec<A> { + #[inline] + fn push(&mut self, value: A::Item) { + SmallVec::push(self, value); + } +} + +impl<A: Array> FromIterator<A::Item> for SmallVec<A> { + fn from_iter<I: IntoIterator<Item=A::Item>>(iterable: I) -> SmallVec<A> { + let mut v = SmallVec::new(); + v.extend(iterable); + v + } +} + +impl<A: Array> Extend<A::Item> for SmallVec<A> { + fn extend<I: IntoIterator<Item=A::Item>>(&mut self, iterable: I) { + let mut iter = iterable.into_iter(); + let (lower_size_bound, _) = iter.size_hint(); + self.reserve(lower_size_bound); + + unsafe { + let (ptr, len_ptr, cap) = self.triple_mut(); + let mut len = SetLenOnDrop::new(len_ptr); + while len.get() < cap { + if let Some(out) = iter.next() { + ptr::write(ptr.offset(len.get() as isize), out); + len.increment_len(1); + } else { + return; + } + } + } + + for elem in iter { + self.push(elem); + } + } +} + +impl<A: Array> fmt::Debug for SmallVec<A> where A::Item: fmt::Debug { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_list().entries(self.iter()).finish() + } +} + +impl<A: Array> Default for SmallVec<A> { + #[inline] + fn default() -> SmallVec<A> { + SmallVec::new() + } +} + +#[cfg(feature = "may_dangle")] +unsafe impl<#[may_dangle] A: Array> Drop for SmallVec<A> { + fn drop(&mut self) { + unsafe { + if self.spilled() { + let (ptr, len) = self.data.heap(); + Vec::from_raw_parts(ptr, len, self.capacity); + } else { + ptr::drop_in_place(&mut self[..]); + } + } + } +} + +#[cfg(not(feature = "may_dangle"))] +impl<A: Array> Drop for SmallVec<A> { + fn drop(&mut self) { + unsafe { + if self.spilled() { + let (ptr, len) = self.data.heap(); + Vec::from_raw_parts(ptr, len, self.capacity); + } else { + ptr::drop_in_place(&mut self[..]); + } + } + } +} + +impl<A: Array> Clone for SmallVec<A> where A::Item: Clone { + fn clone(&self) -> SmallVec<A> { + let mut new_vector = SmallVec::with_capacity(self.len()); + for element in self.iter() { + new_vector.push((*element).clone()) + } + new_vector + } +} + +impl<A: Array, B: Array> PartialEq<SmallVec<B>> for SmallVec<A> + where A::Item: PartialEq<B::Item> { + #[inline] + fn eq(&self, other: &SmallVec<B>) -> bool { self[..] == other[..] } + #[inline] + fn ne(&self, other: &SmallVec<B>) -> bool { self[..] != other[..] } +} + +impl<A: Array> Eq for SmallVec<A> where A::Item: Eq {} + +impl<A: Array> PartialOrd for SmallVec<A> where A::Item: PartialOrd { + #[inline] + fn partial_cmp(&self, other: &SmallVec<A>) -> Option<cmp::Ordering> { + PartialOrd::partial_cmp(&**self, &**other) + } +} + +impl<A: Array> Ord for SmallVec<A> where A::Item: Ord { + #[inline] + fn cmp(&self, other: &SmallVec<A>) -> cmp::Ordering { + Ord::cmp(&**self, &**other) + } +} + +impl<A: Array> Hash for SmallVec<A> where A::Item: Hash { + fn hash<H: Hasher>(&self, state: &mut H) { + (**self).hash(state) + } +} + +unsafe impl<A: Array> Send for SmallVec<A> where A::Item: Send {} + +/// An iterator that consumes a `SmallVec` and yields its items by value. +/// +/// Returned from [`SmallVec::into_iter`][1]. +/// +/// [1]: struct.SmallVec.html#method.into_iter +pub struct IntoIter<A: Array> { + data: SmallVec<A>, + current: usize, + end: usize, +} + +impl<A: Array> Drop for IntoIter<A> { + fn drop(&mut self) { + for _ in self { } + } +} + +impl<A: Array> Iterator for IntoIter<A> { + type Item = A::Item; + + #[inline] + fn next(&mut self) -> Option<A::Item> { + if self.current == self.end { + None + } + else { + unsafe { + let current = self.current as isize; + self.current += 1; + Some(ptr::read(self.data.as_ptr().offset(current))) + } + } + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + let size = self.end - self.current; + (size, Some(size)) + } +} + +impl<A: Array> DoubleEndedIterator for IntoIter<A> { + #[inline] + fn next_back(&mut self) -> Option<A::Item> { + if self.current == self.end { + None + } + else { + unsafe { + self.end -= 1; + Some(ptr::read(self.data.as_ptr().offset(self.end as isize))) + } + } + } +} + +impl<A: Array> ExactSizeIterator for IntoIter<A> { } + +impl<A: Array> IntoIterator for SmallVec<A> { + type IntoIter = IntoIter<A>; + type Item = A::Item; + fn into_iter(mut self) -> Self::IntoIter { + unsafe { + // Set SmallVec len to zero as `IntoIter` drop handles dropping of the elements + let len = self.len(); + self.set_len(0); + IntoIter { + data: self, + current: 0, + end: len, + } + } + } +} + +impl<'a, A: Array> IntoIterator for &'a SmallVec<A> { + type IntoIter = slice::Iter<'a, A::Item>; + type Item = &'a A::Item; + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + +impl<'a, A: Array> IntoIterator for &'a mut SmallVec<A> { + type IntoIter = slice::IterMut<'a, A::Item>; + type Item = &'a mut A::Item; + fn into_iter(self) -> Self::IntoIter { + self.iter_mut() + } +} + +/// Types that can be used as the backing store for a SmallVec +pub unsafe trait Array { + /// The type of the array's elements. + type Item; + /// Returns the number of items the array can hold. + fn size() -> usize; + /// Returns a pointer to the first element of the array. + fn ptr(&self) -> *const Self::Item; + /// Returns a mutable pointer to the first element of the array. + fn ptr_mut(&mut self) -> *mut Self::Item; +} + +/// Set the length of the vec when the `SetLenOnDrop` value goes out of scope. +/// +/// Copied from https://github.com/rust-lang/rust/pull/36355 +struct SetLenOnDrop<'a> { + len: &'a mut usize, + local_len: usize, +} + +impl<'a> SetLenOnDrop<'a> { + #[inline] + fn new(len: &'a mut usize) -> Self { + SetLenOnDrop { local_len: *len, len: len } + } + + #[inline] + fn get(&self) -> usize { + self.local_len + } + + #[inline] + fn increment_len(&mut self, increment: usize) { + self.local_len += increment; + } +} + +impl<'a> Drop for SetLenOnDrop<'a> { + #[inline] + fn drop(&mut self) { + *self.len = self.local_len; + } +} + +macro_rules! impl_array( + ($($size:expr),+) => { + $( + unsafe impl<T> Array for [T; $size] { + type Item = T; + fn size() -> usize { $size } + fn ptr(&self) -> *const T { unimplemented!() } + fn ptr_mut(&mut self) -> *mut T { unimplemented!() } + } + )+ + } +); + +impl_array!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32, 36, + 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, + 0x10000, 0x20000, 0x40000, 0x80000, 0x100000); + +#[cfg(test)] +mod tests { + use SmallVec; + + use std::iter::FromIterator; + + #[cfg(feature = "std")] + use std::borrow::ToOwned; + #[cfg(not(feature = "std"))] + use alloc::borrow::ToOwned; + #[cfg(feature = "std")] + use std::rc::Rc; + #[cfg(not(feature = "std"))] + use alloc::rc::Rc; + #[cfg(not(feature = "std"))] + use alloc::boxed::Box; + #[cfg(not(feature = "std"))] + use alloc::vec::Vec; + + #[test] + pub fn test_zero() { + let mut v = SmallVec::<[_; 0]>::new(); + assert!(!v.spilled()); + v.push(0usize); + assert!(v.spilled()); + assert_eq!(&*v, &[0]); + } + + // We heap allocate all these strings so that double frees will show up under valgrind. + + #[test] + pub fn test_inline() { + let mut v = SmallVec::<[_; 16]>::new(); + v.push("hello".to_owned()); + v.push("there".to_owned()); + assert_eq!(&*v, &[ + "hello".to_owned(), + "there".to_owned(), + ][..]); + } + + #[test] + pub fn test_spill() { + let mut v = SmallVec::<[_; 2]>::new(); + v.push("hello".to_owned()); + assert_eq!(v[0], "hello"); + v.push("there".to_owned()); + v.push("burma".to_owned()); + assert_eq!(v[0], "hello"); + v.push("shave".to_owned()); + assert_eq!(&*v, &[ + "hello".to_owned(), + "there".to_owned(), + "burma".to_owned(), + "shave".to_owned(), + ][..]); + } + + #[test] + pub fn test_double_spill() { + let mut v = SmallVec::<[_; 2]>::new(); + v.push("hello".to_owned()); + v.push("there".to_owned()); + v.push("burma".to_owned()); + v.push("shave".to_owned()); + v.push("hello".to_owned()); + v.push("there".to_owned()); + v.push("burma".to_owned()); + v.push("shave".to_owned()); + assert_eq!(&*v, &[ + "hello".to_owned(), + "there".to_owned(), + "burma".to_owned(), + "shave".to_owned(), + "hello".to_owned(), + "there".to_owned(), + "burma".to_owned(), + "shave".to_owned(), + ][..]); + } + + /// https://github.com/servo/rust-smallvec/issues/4 + #[test] + fn issue_4() { + SmallVec::<[Box<u32>; 2]>::new(); + } + + /// https://github.com/servo/rust-smallvec/issues/5 + #[test] + fn issue_5() { + assert!(Some(SmallVec::<[&u32; 2]>::new()).is_some()); + } + + #[test] + fn test_with_capacity() { + let v: SmallVec<[u8; 3]> = SmallVec::with_capacity(1); + assert!(v.is_empty()); + assert!(!v.spilled()); + assert_eq!(v.capacity(), 3); + + let v: SmallVec<[u8; 3]> = SmallVec::with_capacity(10); + assert!(v.is_empty()); + assert!(v.spilled()); + assert_eq!(v.capacity(), 10); + } + + #[test] + fn drain() { + let mut v: SmallVec<[u8; 2]> = SmallVec::new(); + v.push(3); + assert_eq!(v.drain().collect::<Vec<_>>(), &[3]); + + // spilling the vec + v.push(3); + v.push(4); + v.push(5); + assert_eq!(v.drain().collect::<Vec<_>>(), &[3, 4, 5]); + } + + #[test] + fn drain_rev() { + let mut v: SmallVec<[u8; 2]> = SmallVec::new(); + v.push(3); + assert_eq!(v.drain().rev().collect::<Vec<_>>(), &[3]); + + // spilling the vec + v.push(3); + v.push(4); + v.push(5); + assert_eq!(v.drain().rev().collect::<Vec<_>>(), &[5, 4, 3]); + } + + #[test] + fn into_iter() { + let mut v: SmallVec<[u8; 2]> = SmallVec::new(); + v.push(3); + assert_eq!(v.into_iter().collect::<Vec<_>>(), &[3]); + + // spilling the vec + let mut v: SmallVec<[u8; 2]> = SmallVec::new(); + v.push(3); + v.push(4); + v.push(5); + assert_eq!(v.into_iter().collect::<Vec<_>>(), &[3, 4, 5]); + } + + #[test] + fn into_iter_rev() { + let mut v: SmallVec<[u8; 2]> = SmallVec::new(); + v.push(3); + assert_eq!(v.into_iter().rev().collect::<Vec<_>>(), &[3]); + + // spilling the vec + let mut v: SmallVec<[u8; 2]> = SmallVec::new(); + v.push(3); + v.push(4); + v.push(5); + assert_eq!(v.into_iter().rev().collect::<Vec<_>>(), &[5, 4, 3]); + } + + #[test] + fn into_iter_drop() { + use std::cell::Cell; + + struct DropCounter<'a>(&'a Cell<i32>); + + impl<'a> Drop for DropCounter<'a> { + fn drop(&mut self) { + self.0.set(self.0.get() + 1); + } + } + + { + let cell = Cell::new(0); + let mut v: SmallVec<[DropCounter; 2]> = SmallVec::new(); + v.push(DropCounter(&cell)); + v.into_iter(); + assert_eq!(cell.get(), 1); + } + + { + let cell = Cell::new(0); + let mut v: SmallVec<[DropCounter; 2]> = SmallVec::new(); + v.push(DropCounter(&cell)); + v.push(DropCounter(&cell)); + assert!(v.into_iter().next().is_some()); + assert_eq!(cell.get(), 2); + } + + { + let cell = Cell::new(0); + let mut v: SmallVec<[DropCounter; 2]> = SmallVec::new(); + v.push(DropCounter(&cell)); + v.push(DropCounter(&cell)); + v.push(DropCounter(&cell)); + assert!(v.into_iter().next().is_some()); + assert_eq!(cell.get(), 3); + } + { + let cell = Cell::new(0); + let mut v: SmallVec<[DropCounter; 2]> = SmallVec::new(); + v.push(DropCounter(&cell)); + v.push(DropCounter(&cell)); + v.push(DropCounter(&cell)); + { + let mut it = v.into_iter(); + assert!(it.next().is_some()); + assert!(it.next_back().is_some()); + } + assert_eq!(cell.get(), 3); + } + } + + #[test] + fn test_capacity() { + let mut v: SmallVec<[u8; 2]> = SmallVec::new(); + v.reserve(1); + assert_eq!(v.capacity(), 2); + assert!(!v.spilled()); + + v.reserve_exact(0x100); + assert!(v.capacity() >= 0x100); + + v.push(0); + v.push(1); + v.push(2); + v.push(3); + + v.shrink_to_fit(); + assert!(v.capacity() < 0x100); + } + + #[test] + fn test_truncate() { + let mut v: SmallVec<[Box<u8>; 8]> = SmallVec::new(); + + for x in 0..8 { + v.push(Box::new(x)); + } + v.truncate(4); + + assert_eq!(v.len(), 4); + assert!(!v.spilled()); + + assert_eq!(*v.swap_remove(1), 1); + assert_eq!(*v.remove(1), 3); + v.insert(1, Box::new(3)); + + assert_eq!(&v.iter().map(|v| **v).collect::<Vec<_>>(), &[0, 3, 2]); + } + + #[test] + fn test_insert_many() { + let mut v: SmallVec<[u8; 8]> = SmallVec::new(); + for x in 0..4 { + v.push(x); + } + assert_eq!(v.len(), 4); + v.insert_many(1, [5, 6].iter().cloned()); + assert_eq!(&v.iter().map(|v| *v).collect::<Vec<_>>(), &[0, 5, 6, 1, 2, 3]); + } + + struct MockHintIter<T: Iterator>{x: T, hint: usize} + impl<T: Iterator> Iterator for MockHintIter<T> { + type Item = T::Item; + fn next(&mut self) -> Option<Self::Item> {self.x.next()} + fn size_hint(&self) -> (usize, Option<usize>) {(self.hint, None)} + } + + #[test] + fn test_insert_many_short_hint() { + let mut v: SmallVec<[u8; 8]> = SmallVec::new(); + for x in 0..4 { + v.push(x); + } + assert_eq!(v.len(), 4); + v.insert_many(1, MockHintIter{x: [5, 6].iter().cloned(), hint: 5}); + assert_eq!(&v.iter().map(|v| *v).collect::<Vec<_>>(), &[0, 5, 6, 1, 2, 3]); + } + + #[test] + fn test_insert_many_long_hint() { + let mut v: SmallVec<[u8; 8]> = SmallVec::new(); + for x in 0..4 { + v.push(x); + } + assert_eq!(v.len(), 4); + v.insert_many(1, MockHintIter{x: [5, 6].iter().cloned(), hint: 1}); + assert_eq!(&v.iter().map(|v| *v).collect::<Vec<_>>(), &[0, 5, 6, 1, 2, 3]); + } + + #[cfg(all(feature = "std", not(miri)))] // Miri currently does not support unwinding + #[test] + // https://github.com/servo/rust-smallvec/issues/96 + fn test_insert_many_panic() { + struct PanicOnDoubleDrop { + dropped: Box<bool> + } + + impl Drop for PanicOnDoubleDrop { + fn drop(&mut self) { + assert!(!*self.dropped, "already dropped"); + *self.dropped = true; + } + } + + struct BadIter; + impl Iterator for BadIter { + type Item = PanicOnDoubleDrop; + fn size_hint(&self) -> (usize, Option<usize>) { (1, None) } + fn next(&mut self) -> Option<Self::Item> { panic!() } + } + + let mut vec: SmallVec<[PanicOnDoubleDrop; 0]> = vec![ + PanicOnDoubleDrop { dropped: Box::new(false) }, + PanicOnDoubleDrop { dropped: Box::new(false) }, + ].into(); + let result = ::std::panic::catch_unwind(move || { + vec.insert_many(0, BadIter); + }); + assert!(result.is_err()); + } + + #[test] + #[should_panic] + fn test_invalid_grow() { + let mut v: SmallVec<[u8; 8]> = SmallVec::new(); + v.extend(0..8); + v.grow(5); + } + + #[test] + fn test_insert_from_slice() { + let mut v: SmallVec<[u8; 8]> = SmallVec::new(); + for x in 0..4 { + v.push(x); + } + assert_eq!(v.len(), 4); + v.insert_from_slice(1, &[5, 6]); + assert_eq!(&v.iter().map(|v| *v).collect::<Vec<_>>(), &[0, 5, 6, 1, 2, 3]); + } + + #[test] + fn test_extend_from_slice() { + let mut v: SmallVec<[u8; 8]> = SmallVec::new(); + for x in 0..4 { + v.push(x); + } + assert_eq!(v.len(), 4); + v.extend_from_slice(&[5, 6]); + assert_eq!(&v.iter().map(|v| *v).collect::<Vec<_>>(), &[0, 1, 2, 3, 5, 6]); + } + + #[test] + #[should_panic] + fn test_drop_panic_smallvec() { + // This test should only panic once, and not double panic, + // which would mean a double drop + struct DropPanic; + + impl Drop for DropPanic { + fn drop(&mut self) { + panic!("drop"); + } + } + + let mut v = SmallVec::<[_; 1]>::new(); + v.push(DropPanic); + } + + #[test] + fn test_eq() { + let mut a: SmallVec<[u32; 2]> = SmallVec::new(); + let mut b: SmallVec<[u32; 2]> = SmallVec::new(); + let mut c: SmallVec<[u32; 2]> = SmallVec::new(); + // a = [1, 2] + a.push(1); + a.push(2); + // b = [1, 2] + b.push(1); + b.push(2); + // c = [3, 4] + c.push(3); + c.push(4); + + assert!(a == b); + assert!(a != c); + } + + #[test] + fn test_ord() { + let mut a: SmallVec<[u32; 2]> = SmallVec::new(); + let mut b: SmallVec<[u32; 2]> = SmallVec::new(); + let mut c: SmallVec<[u32; 2]> = SmallVec::new(); + // a = [1] + a.push(1); + // b = [1, 1] + b.push(1); + b.push(1); + // c = [1, 2] + c.push(1); + c.push(2); + + assert!(a < b); + assert!(b > a); + assert!(b < c); + assert!(c > b); + } + + #[cfg(feature = "std")] + #[test] + fn test_hash() { + use std::hash::Hash; + use std::collections::hash_map::DefaultHasher; + + { + let mut a: SmallVec<[u32; 2]> = SmallVec::new(); + let b = [1, 2]; + a.extend(b.iter().cloned()); + let mut hasher = DefaultHasher::new(); + assert_eq!(a.hash(&mut hasher), b.hash(&mut hasher)); + } + { + let mut a: SmallVec<[u32; 2]> = SmallVec::new(); + let b = [1, 2, 11, 12]; + a.extend(b.iter().cloned()); + let mut hasher = DefaultHasher::new(); + assert_eq!(a.hash(&mut hasher), b.hash(&mut hasher)); + } + } + + #[test] + fn test_as_ref() { + let mut a: SmallVec<[u32; 2]> = SmallVec::new(); + a.push(1); + assert_eq!(a.as_ref(), [1]); + a.push(2); + assert_eq!(a.as_ref(), [1, 2]); + a.push(3); + assert_eq!(a.as_ref(), [1, 2, 3]); + } + + #[test] + fn test_as_mut() { + let mut a: SmallVec<[u32; 2]> = SmallVec::new(); + a.push(1); + assert_eq!(a.as_mut(), [1]); + a.push(2); + assert_eq!(a.as_mut(), [1, 2]); + a.push(3); + assert_eq!(a.as_mut(), [1, 2, 3]); + a.as_mut()[1] = 4; + assert_eq!(a.as_mut(), [1, 4, 3]); + } + + #[test] + fn test_borrow() { + use std::borrow::Borrow; + + let mut a: SmallVec<[u32; 2]> = SmallVec::new(); + a.push(1); + assert_eq!(a.borrow(), [1]); + a.push(2); + assert_eq!(a.borrow(), [1, 2]); + a.push(3); + assert_eq!(a.borrow(), [1, 2, 3]); + } + + #[test] + fn test_borrow_mut() { + use std::borrow::BorrowMut; + + let mut a: SmallVec<[u32; 2]> = SmallVec::new(); + a.push(1); + assert_eq!(a.borrow_mut(), [1]); + a.push(2); + assert_eq!(a.borrow_mut(), [1, 2]); + a.push(3); + assert_eq!(a.borrow_mut(), [1, 2, 3]); + BorrowMut::<[u32]>::borrow_mut(&mut a)[1] = 4; + assert_eq!(a.borrow_mut(), [1, 4, 3]); + } + + #[test] + fn test_from() { + assert_eq!(&SmallVec::<[u32; 2]>::from(&[1][..])[..], [1]); + assert_eq!(&SmallVec::<[u32; 2]>::from(&[1, 2, 3][..])[..], [1, 2, 3]); + + let vec = vec![]; + let small_vec: SmallVec<[u8; 3]> = SmallVec::from(vec); + assert_eq!(&*small_vec, &[]); + drop(small_vec); + + let vec = vec![1, 2, 3, 4, 5]; + let small_vec: SmallVec<[u8; 3]> = SmallVec::from(vec); + assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]); + drop(small_vec); + + let vec = vec![1, 2, 3, 4, 5]; + let small_vec: SmallVec<[u8; 1]> = SmallVec::from(vec); + assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]); + drop(small_vec); + + let array = [1]; + let small_vec: SmallVec<[u8; 1]> = SmallVec::from(array); + assert_eq!(&*small_vec, &[1]); + drop(small_vec); + + let array = [99; 128]; + let small_vec: SmallVec<[u8; 128]> = SmallVec::from(array); + assert_eq!(&*small_vec, vec![99u8; 128].as_slice()); + drop(small_vec); + } + + #[test] + fn test_from_slice() { + assert_eq!(&SmallVec::<[u32; 2]>::from_slice(&[1][..])[..], [1]); + assert_eq!(&SmallVec::<[u32; 2]>::from_slice(&[1, 2, 3][..])[..], [1, 2, 3]); + } + + #[test] + fn test_exact_size_iterator() { + let mut vec = SmallVec::<[u32; 2]>::from(&[1, 2, 3][..]); + assert_eq!(vec.clone().into_iter().len(), 3); + assert_eq!(vec.drain().len(), 3); + } + + #[test] + #[allow(deprecated)] + fn veclike_deref_slice() { + use super::VecLike; + + fn test<T: VecLike<i32>>(vec: &mut T) { + assert!(!vec.is_empty()); + assert_eq!(vec.len(), 3); + + vec.sort(); + assert_eq!(&vec[..], [1, 2, 3]); + } + + let mut vec = SmallVec::<[i32; 2]>::from(&[3, 1, 2][..]); + test(&mut vec); + } + + #[test] + fn shrink_to_fit_unspill() { + let mut vec = SmallVec::<[u8; 2]>::from_iter(0..3); + vec.pop(); + assert!(vec.spilled()); + vec.shrink_to_fit(); + assert!(!vec.spilled(), "shrink_to_fit will un-spill if possible"); + } + + #[test] + fn test_into_vec() { + let vec = SmallVec::<[u8; 2]>::from_iter(0..2); + assert_eq!(vec.into_vec(), vec![0, 1]); + + let vec = SmallVec::<[u8; 2]>::from_iter(0..3); + assert_eq!(vec.into_vec(), vec![0, 1, 2]); + } + + #[test] + fn test_into_inner() { + let vec = SmallVec::<[u8; 2]>::from_iter(0..2); + assert_eq!(vec.into_inner(), Ok([0, 1])); + + let vec = SmallVec::<[u8; 2]>::from_iter(0..1); + assert_eq!(vec.clone().into_inner(), Err(vec)); + + let vec = SmallVec::<[u8; 2]>::from_iter(0..3); + assert_eq!(vec.clone().into_inner(), Err(vec)); + } + + #[test] + fn test_from_vec() { + let vec = vec![]; + let small_vec: SmallVec<[u8; 3]> = SmallVec::from_vec(vec); + assert_eq!(&*small_vec, &[]); + drop(small_vec); + + let vec = vec![]; + let small_vec: SmallVec<[u8; 1]> = SmallVec::from_vec(vec); + assert_eq!(&*small_vec, &[]); + drop(small_vec); + + let vec = vec![1]; + let small_vec: SmallVec<[u8; 3]> = SmallVec::from_vec(vec); + assert_eq!(&*small_vec, &[1]); + drop(small_vec); + + let vec = vec![1, 2, 3]; + let small_vec: SmallVec<[u8; 3]> = SmallVec::from_vec(vec); + assert_eq!(&*small_vec, &[1, 2, 3]); + drop(small_vec); + + let vec = vec![1, 2, 3, 4, 5]; + let small_vec: SmallVec<[u8; 3]> = SmallVec::from_vec(vec); + assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]); + drop(small_vec); + + let vec = vec![1, 2, 3, 4, 5]; + let small_vec: SmallVec<[u8; 1]> = SmallVec::from_vec(vec); + assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]); + drop(small_vec); + } + + #[test] + fn test_retain() { + // Test inline data storate + let mut sv: SmallVec<[i32; 5]> = SmallVec::from_slice(&[1, 2, 3, 3, 4]); + sv.retain(|&mut i| i != 3); + assert_eq!(sv.pop(), Some(4)); + assert_eq!(sv.pop(), Some(2)); + assert_eq!(sv.pop(), Some(1)); + assert_eq!(sv.pop(), None); + + // Test spilled data storage + let mut sv: SmallVec<[i32; 3]> = SmallVec::from_slice(&[1, 2, 3, 3, 4]); + sv.retain(|&mut i| i != 3); + assert_eq!(sv.pop(), Some(4)); + assert_eq!(sv.pop(), Some(2)); + assert_eq!(sv.pop(), Some(1)); + assert_eq!(sv.pop(), None); + + // Test that drop implementations are called for inline. + let one = Rc::new(1); + let mut sv: SmallVec<[Rc<i32>; 3]> = SmallVec::new(); + sv.push(Rc::clone(&one)); + assert_eq!(Rc::strong_count(&one), 2); + sv.retain(|_| false); + assert_eq!(Rc::strong_count(&one), 1); + + // Test that drop implementations are called for spilled data. + let mut sv: SmallVec<[Rc<i32>; 1]> = SmallVec::new(); + sv.push(Rc::clone(&one)); + sv.push(Rc::new(2)); + assert_eq!(Rc::strong_count(&one), 2); + sv.retain(|_| false); + assert_eq!(Rc::strong_count(&one), 1); + } + + #[test] + fn test_dedup() { + let mut dupes: SmallVec<[i32; 5]> = SmallVec::from_slice(&[1, 1, 2, 3, 3]); + dupes.dedup(); + assert_eq!(&*dupes, &[1, 2, 3]); + + let mut empty: SmallVec<[i32; 5]> = SmallVec::new(); + empty.dedup(); + assert!(empty.is_empty()); + + let mut all_ones: SmallVec<[i32; 5]> = SmallVec::from_slice(&[1, 1, 1, 1, 1]); + all_ones.dedup(); + assert_eq!(all_ones.len(), 1); + + let mut no_dupes: SmallVec<[i32; 5]> = SmallVec::from_slice(&[1, 2, 3, 4, 5]); + no_dupes.dedup(); + assert_eq!(no_dupes.len(), 5); + } + + #[test] + fn test_resize() { + let mut v: SmallVec<[i32; 8]> = SmallVec::new(); + v.push(1); + v.resize(5, 0); + assert_eq!(v[..], [1, 0, 0, 0, 0][..]); + + v.resize(2, -1); + assert_eq!(v[..], [1, 0][..]); + } + + #[cfg(feature = "std")] + #[test] + fn test_write() { + use io::Write; + + let data = [1, 2, 3, 4, 5]; + + let mut small_vec: SmallVec<[u8; 2]> = SmallVec::new(); + let len = small_vec.write(&data[..]).unwrap(); + assert_eq!(len, 5); + assert_eq!(small_vec.as_ref(), data.as_ref()); + + let mut small_vec: SmallVec<[u8; 2]> = SmallVec::new(); + small_vec.write_all(&data[..]).unwrap(); + assert_eq!(small_vec.as_ref(), data.as_ref()); + } + + #[cfg(feature = "serde")] + extern crate bincode; + + #[cfg(feature = "serde")] + #[test] + fn test_serde() { + use self::bincode::{config, deserialize}; + let mut small_vec: SmallVec<[i32; 2]> = SmallVec::new(); + small_vec.push(1); + let encoded = config().limit(100).serialize(&small_vec).unwrap(); + let decoded: SmallVec<[i32; 2]> = deserialize(&encoded).unwrap(); + assert_eq!(small_vec, decoded); + small_vec.push(2); + // Spill the vec + small_vec.push(3); + small_vec.push(4); + // Check again after spilling. + let encoded = config().limit(100).serialize(&small_vec).unwrap(); + let decoded: SmallVec<[i32; 2]> = deserialize(&encoded).unwrap(); + assert_eq!(small_vec, decoded); + } + + #[test] + fn grow_to_shrink() { + let mut v: SmallVec<[u8; 2]> = SmallVec::new(); + v.push(1); + v.push(2); + v.push(3); + assert!(v.spilled()); + v.clear(); + // Shrink to inline. + v.grow(2); + assert!(!v.spilled()); + assert_eq!(v.capacity(), 2); + assert_eq!(v.len(), 0); + v.push(4); + assert_eq!(v[..], [4]); + } + + #[test] + fn resumable_extend() { + let s = "a b c"; + // This iterator yields: (Some('a'), None, Some('b'), None, Some('c')), None + let it = s + .chars() + .scan(0, |_, ch| if ch.is_whitespace() { None } else { Some(ch) }); + let mut v: SmallVec<[char; 4]> = SmallVec::new(); + v.extend(it); + assert_eq!(v[..], ['a']); + } + + // #139 + #[test] + fn uninhabited() { + enum Void {} + let _sv = SmallVec::<[Void; 8]>::new(); + } + + #[test] + fn grow_spilled_same_size() { + let mut v: SmallVec<[u8; 2]> = SmallVec::new(); + v.push(0); + v.push(1); + v.push(2); + assert!(v.spilled()); + assert_eq!(v.capacity(), 4); + // grow with the same capacity + v.grow(4); + assert_eq!(v.capacity(), 4); + assert_eq!(v[..], [0, 1, 2]); + } +} diff --git a/third_party/cargo/vendor/smallvec-0.6.13/scripts/run_miri.sh b/third_party/cargo/vendor/smallvec-0.6.13/scripts/run_miri.sh new file mode 100644 index 0000000..42f2884 --- /dev/null +++ b/third_party/cargo/vendor/smallvec-0.6.13/scripts/run_miri.sh @@ -0,0 +1,21 @@ +#!/usr/bin/bash + +set -ex + +# Clean out our target dir, which may have artifacts compiled by a version of +# rust different from the one we're about to download. +cargo clean + +# Install and run the latest version of nightly where miri built successfully. +# Taken from: https://github.com/rust-lang/miri#running-miri-on-ci + +MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri) +echo "Installing latest nightly with Miri: $MIRI_NIGHTLY" +rustup default "$MIRI_NIGHTLY" + +rustup component add miri +cargo miri setup + +cargo miri test --verbose -- -- -Zunstable-options --exclude-should-panic +cargo miri test --verbose --features union -- -- -Zunstable-options --exclude-should-panic +cargo miri test --verbose --all-features -- -- -Zunstable-options --exclude-should-panic diff --git a/third_party/cargo/vendor/smallvec-0.6.13/specialization.rs b/third_party/cargo/vendor/smallvec-0.6.13/specialization.rs new file mode 100644 index 0000000..2e7bb1e --- /dev/null +++ b/third_party/cargo/vendor/smallvec-0.6.13/specialization.rs @@ -0,0 +1,16 @@ +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Implementations that require `default fn`. + +use super::{SpecFrom, SmallVec, Array}; + +impl<'a, A: Array> SpecFrom<A, &'a [A::Item]> for SmallVec<A> where A::Item: Clone { + #[inline] + default fn spec_from(slice: &'a [A::Item]) -> SmallVec<A> { + slice.into_iter().cloned().collect() + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/.cargo-checksum.json b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/.cargo-checksum.json new file mode 100644 index 0000000..35cba36 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"2da4b714837a96ee9b51dd2dab5cef060ee2a66cca3c7dc752653beb85361520","CONTRIBUTING.md":"b3a310f25decb6d92da06a5db2df1a6d2e2a0843890e07c0bba0d517f83c60bf","Cargo.toml":"a8cdd44813422b28509a7f7675a709b3a27e7419ff94a4a837189eb06e3ec876","LICENSE.txt":"13c0147abe1c7607fde840e2dffcde75bf925aea504b2845b7be4869a5af2afc","README.md":"d9d772954f6bf2a0fbf963fabea93e2e9a5bae9a780ec14d44314842319d7fff","doc_index.html":"383be472c810a6ad7970779a37f2344735a6331ed21bd48de7a38a2772301621","examples/compositor_info.rs":"67611e783ca080082cdca05c72dcfc8c4bae5cebef107539b9b6e5438bb6a31e","examples/image_viewer.rs":"4a18e433296211e0022adbff1e966d19728e75a8faa4ae1fd431804629f03735","examples/kbd_input.rs":"a1656fef18fc07fbfd606fbf5dc4178e9da183789efae1bfd08f7cd9048f95db","examples/pointer_input.rs":"72c4d9c391b29bc94d29c8de2aa2cd76cd8db60ca13175d1f56f860c19113a09","examples/selection.rs":"e34fbdf99aed737fa071896b1671a5323d68b825ee8603a0e0b24325f4a60645","src/data_device/data_device.rs":"6951652791a8735e4feb314459030fae39e42635ac2f53bd08614db3f7382d6d","src/data_device/data_offer.rs":"9f8c84b06dd4c10d2412483e8efad9a6ac66e60e8a5bac3d07c0dd0af6cd3187","src/data_device/data_source.rs":"a00685604358808658143ef6c6b46cd9e4f64e3fc51fb3288809b5a80b7967c2","src/data_device/mod.rs":"6794d7443820d91144c957d9d09551f39624e33e337574a1c102b5aeea14c987","src/env.rs":"0cbd7b513387e18fe1a4d10a0cb64baf45cab92c401dbd0cdb2d8a3a5407be2d","src/keyboard/ffi.rs":"c35e40b4dab805dc3f6ae918497d04a2085958d41f27731f06b9dc4701e04fdb","src/keyboard/keysyms.rs":"c704c3b45ad18640ed906d0c14359aaea8afb49553e112cdef9f766de4f733f7","src/keyboard/mod.rs":"3494fedf5a49e830d9b622a825762f37dc50add68d980ef390814ecda37267ee","src/lib.rs":"cde040a0e905671c718db9f3390bb77dddf0c9db809c257a597442a7ba0152a4","src/output.rs":"b5268f6f3b7041b09844f900d8deedd2c2de51d9de3d17fcb7ecbf4faa9863e8","src/pointer/mod.rs":"95fc20099c165b401b7733a2ebbb9c33ca11a8aa0482d35e90bc745b14dacd28","src/pointer/theme.rs":"d13770347720e853f9ebe248aadca160ab77da0f14309941d440bbc18275504d","src/shell/mod.rs":"a2601abec2e14f12056ffba4e1d3c8474086e1652381f8a8948503599cdc8e90","src/shell/wl.rs":"ea83db9ccd9579ea423507e76ad9c656facb8e1bd172c6eafc99694245a57e6d","src/shell/xdg.rs":"fda40c7731dcafc481c237b3a2f5f83c62ce99bbea9be8efa53cfe7b17bee8bd","src/shell/zxdg.rs":"af3796a89dc4634e723da59d991162b0720527f55a7f45680e1ca80929106674","src/surface.rs":"c5d31a0ce6662758674e02756066e9939eecc98f20a26cbf7b1c0b49d13ca77c","src/utils/mempool.rs":"eb473a2d7dc6d41b88b53588afd31913e2ab1ad4a1b2679347bda1dd3eada9c7","src/utils/mod.rs":"0fd707ee8c6f7747910e7fa4c4e8b9eeb829eed250394175b814d6348bf131e9","src/window/basic_frame.rs":"7a051e1699847f0543e5283f3379e2b196a63e165c56ea4665983c19a7b96e23","src/window/concept_frame.rs":"96ec2f6959a00c5715d2ffb64242ddb265a7a9ebe89f7781283f266511fff316","src/window/mod.rs":"7c84ea00b415dd4f0b7a032bc1f8f10d5149323584dea8b8131522767ead1323","travis_install_wayland.sh":"02ba67cbc481d65b75440d04e059ab00fbd59bc1821d6206d28c6f4499e3368a","update_keysyms.sh":"6ef4695d6f0a083915e07bc92aae7757049ef507da140c5dc4b7a87d83090fa7"},"package":"2ccb8c57049b2a34d2cc2b203fa785020ba0129d31920ef0d317430adaf748fa"} \ No newline at end of file diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/BUILD b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/BUILD new file mode 100644 index 0000000..6dbdab4 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/BUILD @@ -0,0 +1,56 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "compositor_info" with type "example" omitted +# Unsupported target "image_viewer" with type "example" omitted +# Unsupported target "kbd_input" with type "example" omitted +# Unsupported target "pointer_input" with type "example" omitted +# Unsupported target "selection" with type "example" omitted + +rust_library( + name = "smithay_client_toolkit", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/andrew-0.2.1:andrew", + "//third_party/cargo/vendor/bitflags-1.2.1:bitflags", + "//third_party/cargo/vendor/dlib-0.4.1:dlib", + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + "//third_party/cargo/vendor/memmap-0.7.0:memmap", + "//third_party/cargo/vendor/nix-0.14.1:nix", + "//third_party/cargo/vendor/wayland-client-0.21.13:wayland_client", + "//third_party/cargo/vendor/wayland-commons-0.21.13:wayland_commons", + "//third_party/cargo/vendor/wayland-protocols-0.21.13:wayland_protocols", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.6", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/CHANGELOG.md b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/CHANGELOG.md new file mode 100644 index 0000000..1a7e20b --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/CHANGELOG.md @@ -0,0 +1,91 @@ +# Change Log + +## Unreleased + +- Keyboard: fix system repeat rate as repeats per second rather then millisecond delay between repeats +- Surface: fix panic in `compute_dpi_factor()` by only computing the dpi factor on surfaces known to the OutputMgr +- Window: `set_title()` now requires a manual `refresh()` for the change to take effect + +## 0.4.4 -- 2018-12-27 + +- Shell: expose shell interface and add `create_shell_surface` to `Environment`. +- Fix build failure on big endian targets + +## 0.4.3 -- 2018-12-03 + +- Update dependencies: rand, memmap, nix and image +- Surface: `create_surface` and `get_dpi_factor` utilities for creating dpi aware surfaces. + +## 0.4.2 -- 2018-11-14 + +- Fix compilation on BSD systems + +## 0.4.1 -- 2018-11-06 + +- Window: always request server-side decorations if available, otherwise ther compositor never configures us +- keyboard: only compute utf8 value on keypress, not key release. Otherwise it confuses `xkb_compose`. + +## 0.4.0 -- 2018-10-09 + +- BasicFrame: Display the title of the window in the window header +- Pass `set_selection()` `Option<DataSource>` and `AutoThemer::init()` `Proxy<WlShm>` by reference +- Window: add `set_theme()` function which takes an object implementing the trait `Theme` to adjust the look of window decorations +- Window: add new `ConceptFrame` which provides an alternative to the `BasicFrame` window decorations +- MemPool: add `mmap` method +- **[Breaking]** Keyboard: remove `modifiers` field from `keyboard::Event::Enter`, `keyboard::Event::Key` and `keyboard::KeyRepeatEvent` +- **[Breaking]** Keyboard: add `keyboard::Event::Modifiers` +- **[Breaking]** Upgrade to wayland-rs 0.21 +- Keyboard: end key repetition when the keyboard loses focus + +## 0.3.0 -- 2018-08-17 + +- Window: the minimum window width is set to 2 pixels to circumvent a bug in mutter - https://gitlab.gnome.org/GNOME/mutter/issues/259 +- **[Breaking]** MemPool: MemPool now requires an implementation to be called when the pool becomes free +- **[Breaking]** DoubleMemPool: DoubleMemPool now requires an implementation to be called when one of its pools becomes free +- **[Breaking]** DoubleMemPool: `swap()` is removed as `pool()` will now automatically track and return any free pools avaliable or return None +- Keyboard: add key repetition with 'map_keyboard_auto_with_repeat' and 'map_keyboard_rmlvo_with_repeat' +- Window: add `init_with_decorations` to allow the use of server-side decorations + +## 0.2.6 -- 2018-07-14 + +Big thanks to @trimental for improving the visual look of the window decorations: + +- BasicFrame: remove side and bottom border decorations +- BasicFrame: round window corners + +## 0.2.5 -- 2018-07-10 + +- Keyboard: try to load `libxkbcommon.so.0` as well to improve compatibility + +## 0.2.4 -- 2018-06-26 + +- Window: notify the compositor of our dimensions to avoid placement glitches + +## 0.2.3 -- 2018-06-08 + +- Update `nix` dependency to be fix build on FreeBSD (even if we can't run) + +## 0.2.2 -- 2018-06-08 + +- BasicFrame: don't desync the subsurface from the main one. This avoids + graphical glitches where the borders are not drawn exactly the same size + as the contents. +- Window: add `set_resizable`, (minor **breaking change** of the `Frame` trait by + adding a new method) + +## 0.2.1 -- 2018-05-03 + +- Add `DoubleMemPool` for double buffering, and use it to + improve the drawing performance of `BasicFrame`. + +## 0.2.0 -- 2018-04-29 + +- *Breaking* OutputMgr: expose wl_output global id + +## 0.1.0 -- 2018-04-26 + +Initial version, including: + +- basic environment manager +- keyboard keymap handling +- basic window decoration diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/CONTRIBUTING.md b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/CONTRIBUTING.md new file mode 100644 index 0000000..e1663d6 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/CONTRIBUTING.md @@ -0,0 +1,42 @@ +# Contributing + +Smithay's Client ToolKit (SCTK) is open to contributions from anyone. + +## Coordination + +Most discussion about features and their implementations takes place on github. +If you have questions, suggestions, ideas, you can open an issue to discuss it, or add your message +in an already existing issue if it fits its scope. + +If you want a more realtime discussion there is a a Matrix room dedicated to the Smithay project: +[#smithay:matrix.org](https://matrix.to/#/#smithay:matrix.org). If you don't want to use matrix, this room is +also bridged to gitter: https://gitter.im/smithay/Lobby. + +## Scope & Structure + +SCTK aims to provide generic building blocks to write wayland clients, abstracting away the boilerplate of the +wayland protocol while allowing direct control when wanted. As such, it is composed of several loosely-coupled +modules, which can be used independenly of each other. This given, if you want to contribute a new feature to +SCTK, please consider these design points: + +- The feature should be designed it is most general form, allowing it to be used by other projects, probaby + different from the exact use-case you have in mind. +- This new feature should not heavily depend on the other parts of SCTK if it can avoid it. As much as + possible, SCTK users should be able to use your feature alone. + +## Pull requests & commits organisation + +The development branch is the `master` branch, and it should be the target of your pull requests. + +In general, single-purpose pull requests are prefered. If you have two independent contributions to make, +please open two different pull requests. + +On the other hand, if you have changes that could technically be separated, but really belong together (for +example a new feature, that first require some refactoring before being introduced), it is okay to ship them +in the same pull request. However, to simplify the review work (and future reference to the commit history), +these changes should be separated in different commits. This will allow the reviewers to review each commit +independently, reducing the cognitive load. + +At merge time, pull requests consisting of a single commit or of a few well-scoped commits will be rebased on +master. Pull requests which have accumulated several review-addressing commits will be squashed. + diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/Cargo.toml b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/Cargo.toml new file mode 100644 index 0000000..2ffcf86 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/Cargo.toml @@ -0,0 +1,61 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "smithay-client-toolkit" +version = "0.4.6" +authors = ["Victor Berger <victor.berger@m4x.org>"] +description = "Toolkit for making client wayland applications." +documentation = "https://smithay.github.io/client-toolkit" +keywords = ["wayland", "client"] +categories = ["gui"] +license = "MIT" +repository = "https://github.com/smithay/client-toolkit" +[dependencies.andrew] +version = "0.2.0" + +[dependencies.bitflags] +version = "1.0" + +[dependencies.dlib] +version = "0.4" + +[dependencies.lazy_static] +version = "1" + +[dependencies.memmap] +version = "0.7" + +[dependencies.nix] +version = "0.14.1" + +[dependencies.wayland-client] +version = "0.21" +features = ["cursor"] + +[dependencies.wayland-commons] +version = "0.21" + +[dependencies.wayland-protocols] +version = "0.21" +features = ["native_client", "unstable_protocols"] +[dev-dependencies.byteorder] +version = "1.0" + +[dev-dependencies.image] +version = "0.20" + +[dev-dependencies.wayland-client] +version = "0.21" +features = ["dlopen"] +[badges.travis-ci] +repository = "smithay/client-toolkit" diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/LICENSE.txt b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/LICENSE.txt new file mode 100644 index 0000000..f916c14 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/LICENSE.txt @@ -0,0 +1,19 @@ +Copyright (c) 2018 Victor Berger + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/README.md b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/README.md new file mode 100644 index 0000000..11a5730 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/README.md @@ -0,0 +1,26 @@ +[![crates.io](http://meritbadge.herokuapp.com/smithay-client-toolkit)](https://crates.io/crates/smithay-client-toolkit) +[![Build Status](https://travis-ci.org/Smithay/client-toolkit.svg?branch=master)](https://travis-ci.org/Smithay/client-toolkit) + + +# Smithay's Client Toolkit + +This crate is a toolkit for writing wayland clients in rust, on top of [wayland-client](https://crates.io/crates/wayland-client). + +Currently a work in progress, it currently provides the following utilities: + +- Automatic binding of general wayland globals (`wl_compositor`, `wl_shm`, etc..) +- Abstraction to create windows (aka toplevel surfaces), abstracting the interaction + with the shell (`xdg_shell` or `wl_shell`) and the drawing of decorations +- Wrapper for `wl_keyboard` for automatic keymap interpretation using `libxkbcommon.so`. +- Utilites for creating dpi aware surfaces. + +## Documentation + +The documentation for the master branch is [available online](https://smithay.github.io/client-toolkit/). + +The documentation for the releases can be found on [docs.rs](https://docs.rs/smithay-client-toolkit). + +## Requirements + +Requires at least rust 1.22 to be used (using bitflags 1.0 for associated constants), and version 1.12 of the +wayland system libraries. diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/doc_index.html b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/doc_index.html new file mode 100644 index 0000000..b5837c2 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/doc_index.html @@ -0,0 +1,6 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv=refresh content=0;url=smithay_client_toolkit/index.html /> + </head> +</html> diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/compositor_info.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/compositor_info.rs new file mode 100644 index 0000000..3a672c6 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/compositor_info.rs @@ -0,0 +1,52 @@ +extern crate smithay_client_toolkit as sctk; + +use sctk::reexports::client::Display; +use sctk::{Environment, Shell}; + +// This is a small program that queries the compositor for +// various information and prints them on the console before exiting. + +fn main() { + let (display, mut event_queue) = Display::connect_to_env().unwrap(); + let env = Environment::from_display(&*display, &mut event_queue).unwrap(); + + println!("== Smithay's compositor info tool ==\n"); + + // print the best supported shell + println!( + "-> Most recent shell supported by the compositor is {}.\n", + match env.shell { + Shell::Wl(_) => "the legacy wl_shell", + Shell::Zxdg(_) => "the old unstable xdg_shell (zxdg_shell_v6)", + Shell::Xdg(_) => "the current xdg_shell", + } + ); + + env.outputs.with_all(|outputs| { + println!("-> Compositor advertised {} outputs:", outputs.len()); + for &(id, _, ref info) in outputs { + println!( + " -> #{}: {} ({}), with scale factor of {}", + id, info.model, info.make, info.scale_factor + ); + println!(" Possible modes are:"); + for mode in &info.modes { + println!( + " -> [{}{}] {} x {} @ {}.{} Hz", + if mode.is_preferred { "p" } else { " " }, + if mode.is_current { "c" } else { " " }, + mode.dimensions.0, + mode.dimensions.1, + mode.refresh_rate / 1000, + mode.refresh_rate % 1000 + ); + } + } + }); + + if env.decorations_mgr.is_some() { + println!("-> Compositor supports server-side decorations.") + } else { + println!("-> Compositor does not support server-side decorations.") + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/image_viewer.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/image_viewer.rs new file mode 100644 index 0000000..cd824b6 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/image_viewer.rs @@ -0,0 +1,369 @@ +extern crate byteorder; +extern crate image; +extern crate smithay_client_toolkit as sctk; + +use std::env; +use std::io::{BufWriter, Seek, SeekFrom, Write}; +use std::sync::{Arc, Mutex}; + +use byteorder::{NativeEndian, WriteBytesExt}; + +use sctk::reexports::client::protocol::wl_surface::RequestsTrait as SurfaceRequests; +use sctk::reexports::client::protocol::{wl_shm, wl_surface}; +use sctk::reexports::client::{Display, Proxy}; +use sctk::utils::{DoubleMemPool, MemPool}; +use sctk::window::{ConceptFrame, Event as WEvent, State, Window}; +use sctk::Environment; + +fn main() { + // First of all, retrieve the path from the program arguments: + let path = match env::args_os().skip(1).next() { + Some(p) => p, + None => { + println!("USAGE: ./image_wiewer <PATH>"); + return; + } + }; + // now, try to open the image + // the image crate will take care of auto-detecting the file format + let image = match image::open(&path) { + Ok(i) => i, + Err(e) => { + println!("Failed to open image {}.", path.to_string_lossy()); + println!("Error was: {:?}", e); + return; + } + }; + // We'll need the image in RGBA for drawing it + let image = image.to_rgba(); + + /* + * Initalize the wayland connection + */ + let (display, mut event_queue) = + Display::connect_to_env().expect("Failed to connect to the wayland server."); + + // All request methods of wayland objects return a result, as wayland-client + // returns an error if you try to send a message on an object that has already + // been destroyed by a previous message. + // + // The Environment takes a proxy to the display and a mutable borrow of the wayland event + // queue. It uses the event queue internally to exchange messages with the server + // to process the registry event. + // Like all manipulation of the event loop, it can fail (if the connection is + // unexpectedly lost), and thus returns a result. This failing would prevent + // us to continue though, so we unwrap(). + let env = Environment::from_display(&*display, &mut event_queue).unwrap(); + + // Use the compositor global to create a new surface + let surface = env.create_surface(|dpi, _surface| { + println!("dpi changed to {}", dpi); + }); + + /* + * Init the window + */ + + // First of all, this Arc<Mutex<Option<WEvent>>> will store + // any event from the window that we'll need to process. We + // store them and will process them later in the event loop + // rather that process them directly because in a batch of + // generated events, often only the last one needs to actually + // be processed, and some events may render other obsoletes. + // See the closure a few lines below for details + let next_action = Arc::new(Mutex::new(None::<WEvent>)); + + // We clone the arc to pass one end to the closure + let waction = next_action.clone(); + // Now we actually create the window. The type parameter `ConceptFrame` here + // specifies the type we want to use to draw the borders. To create your own + // decorations you just need an object to implement the `Frame` trait. + let mut window = Window::<ConceptFrame>::init_from_env( + &env, // the environment containing the wayland globals + surface, // the wl_surface that serves as the basis of this window + image.dimensions(), // the initial internal dimensions of the window + move |evt| { + // This is the closure that process the Window events. + // There are 3 possible events: + // - Close: the user requested the window to be closed, we'll then quit + // - Configure: the server suggested a new state for the window (possibly + // a new size if a resize is in progress). We'll likely need to redraw + // our contents + // - Refresh: the frame itself needs to be redrawn. SCTK does not do this + // automatically because it has a cost and should only be done in periods + // of the event loop where the client actually wants to draw + // Here we actually only keep the last event receive according to a priority + // order of Close > Configure > Refresh. + // Indeed, if we received a Close, there is not point drawing anything more as + // we will exit. A new Configure overrides a previous one, and if we received + // a Configure we will refresh the frame anyway. + let mut next_action = waction.lock().unwrap(); + // Check if we need to replace the old event by the new one + let replace = match (&evt, &*next_action) { + // replace if there is no old event + (_, &None) + // or the old event is refresh + | (_, &Some(WEvent::Refresh)) + // or we had a configure and received a new one + | (&WEvent::Configure { .. }, &Some(WEvent::Configure { .. })) + // or the new event is close + | (&WEvent::Close, _) => true, + // keep the old event otherwise + _ => false, + }; + if replace { + *next_action = Some(evt); + } + }, + // creating the window may fail if the code drawing the frame + // fails to initialize itself. For ConceptFrame this should not happen + // unless the system is utterly broken, though. + ) + .expect("Failed to create a window !"); + + // Setting the windows title allows the compositor to know what your + // window should be called and the title will be display on the header bar + // of the windows decorations + window.set_title("Image Viewer".to_string()); + + // The window needs access to pointer inputs to handle the user interaction + // with it: resizing/moving the window, or clicking its button. + // user interaction in wayland is done via the wl_seat object, which represent + // a set of pointer,keyboard,touchscreen (some may be absent) that logically + // represent a single user. Most systems have only one seat, multi-seat configurations + // are quite exotic. + // Thus, we just automatically bind the first seat we find. + let seat = env + .manager + .instantiate_auto(|seat| seat.implement(|_, _| {}, ())) + .unwrap(); + // And advertise it to the Window so it knows of it and can process the + // required pointer events. + window.new_seat(&seat); + + /* + * Initialization of the memory pool + */ + + // DoubleMemPool::new() requires access to the wl_shm global, which represents + // the capability of the server to use shared memory (SHM). All wayland servers + // are required to support it. + let mut pools = + DoubleMemPool::new(&env.shm, || {}).expect("Failed to create the memory pools."); + + /* + * Event Loop preparation and running + */ + + // First, we initialize a few boolean flags that we'll use to track our state: + // - the window needs to be redrawn + let mut need_redraw = false; + // - are we currently in the process of being resized? (to draw the image or + // black content) + let mut resizing = false; + // - the size of our contents + let mut dimensions = image.dimensions(); + + // if our shell does not need to wait for a configure event, we draw right away. + // + // Note that this is only the case for the old wl_shell protocol, which is now + // deprecated. This code is only for compatibility with old server that do not + // support the new standard xdg_shell protocol. + // + // But if we have fallbacked to wl_shell, we need to draw right away because we'll + // never receive a configure event if we don't draw something... + if !env.shell.needs_configure() { + // initial draw to bootstrap on wl_shell + if let Some(pool) = pools.pool() { + redraw( + pool, + window.surface(), + dimensions, + if resizing { None } else { Some(&image) }, + ) + .expect("Failed to draw") + } + window.refresh(); + } + + // We can now actually enter the event loop! + loop { + // First, check if any pending action was received by the + // Window implementation: + match next_action.lock().unwrap().take() { + // We received a Close event, just break from the loop + // and let the app quit + Some(WEvent::Close) => break, + // We receive a Refresh event, store that we need to refresh the + // frame + Some(WEvent::Refresh) => { + window.refresh(); + window.surface().commit(); + } + // We received a configure event, our action depends on its + // contents + Some(WEvent::Configure { new_size, states }) => { + // the configure event contains a suggested size, + // if it is different from our current size, we need to + // update it and redraw + if let Some((w, h)) = new_size { + if dimensions != (w, h) { + dimensions = (w, h); + } + } + window.resize(dimensions.0, dimensions.1); + window.refresh(); + // Are we currently resizing ? + // We check if a resizing just started or stopped, + // because in this case we'll swap between drawing black + // and drawing the window (or the reverse), and thus we need to + // redraw + let new_resizing = states.contains(&State::Resizing); + resizing = new_resizing; + + need_redraw = true; + } + // No event, nothing new to do. + None => {} + } + + if need_redraw { + // We need to redraw, but can only do it if at least one of the + // memory pools is not currently used by the server. If both are + // used, we'll keep the `need_redraw` flag to `true` and try again + // at next iteration of the loop. + // Draw the contents in the pool and retrieve the buffer + match pools.pool() { + Some(pool) => { + // We don't need to redraw or refresh anymore =) + need_redraw = false; + redraw( + pool, + window.surface(), + dimensions, + if resizing { None } else { Some(&image) }, + ) + .expect("Failed to draw") + } + None => {} + } + } + + // These last two calls are necessary for the processing of wayland messages: + // - first, flush all our requests to the server on the unix socket + display.flush().unwrap(); + // - then, retrieve all the incoming messages + // this method blocks until a message arrives from the server, and will process + // all events by calling the implementation of the target object or each, + // and only return once all pending messages have been processed. + event_queue.dispatch().unwrap(); + } +} + +// The draw function, which drawn `base_image` in the provided `MemPool`, +// at given dimensions, and returns a wl_buffer to it. +// +// It simply returns the `NewProxy`, as we'll take care of implementing the +// wl_buffer outside of this function. +// +// If `base_image` is `None`, it'll just draw black contents. This is to +// improve performance during resizing: we need to redraw the window frequently +// so that its dimensions follow the pointer during the resizing, but resizing the +// image is costly and long. So during an interactive resize of the window we'll +// just draw black contents to not feel laggy. +fn redraw( + pool: &mut MemPool, + surface: &Proxy<wl_surface::WlSurface>, + (buf_x, buf_y): (u32, u32), + base_image: Option<&image::ImageBuffer<image::Rgba<u8>, Vec<u8>>>, +) -> Result<(), ::std::io::Error> { + // First of all, we make sure the pool is big enough to hold our + // image. We'll write in ARGB8888 format, meaning 4 bytes per pixel. + // This resize method will only resize the pool if the requested size is bigger + // than the current size, as wayland SHM pools are not allowed to shrink. + // + // While writing on the file will automatically grow it, we need to advertise the + // server of its new size, so the call to this method is necessary. + pool.resize((4 * buf_x * buf_y) as usize) + .expect("Failed to resize the memory pool."); + + // Now, we can write the contents. MemPool implement the `Seek` and `Write` traits, + // so we use it directly as a file to write on. + + // First, seek to the beginning, to overwrite our previous content. + pool.seek(SeekFrom::Start(0))?; + { + // A sub-scope to limit our borrow of the pool by this BufWriter. + // This BufWrite will significantly improve our drawing performance, + // by reducing the number of syscalls we do. =) + let mut writer = BufWriter::new(&mut *pool); + if let Some(base_image) = base_image { + // We have an image to draw + + // first, resize it to the requested size. We just use the function provided + // by the image crate here. + let image = + image::imageops::resize(base_image, buf_x, buf_y, image::FilterType::Nearest); + + // Now, we'll write the pixels of the image to the MemPool. + // + // We do this in an horribly inefficient manner, for the sake of simplicity. + // We'll send pixels to the server in ARGB8888 format (this is one of the only + // formats that are guaranteed to be supported), but image provides it in + // RGBA8888, so we need to do the conversion. + // + // Additionally, if the image has some transparent parts, we'll blend them into + // a white background, otherwise the server will draw our window with a + // transparent background! + for pixel in image.pixels() { + // retrieve the pixel values + let r = pixel.data[0] as u32; + let g = pixel.data[1] as u32; + let b = pixel.data[2] as u32; + let a = pixel.data[3] as u32; + // blend them + let r = ::std::cmp::min(0xFF, (0xFF * (0xFF - a) + a * r) / 0xFF); + let g = ::std::cmp::min(0xFF, (0xFF * (0xFF - a) + a * g) / 0xFF); + let b = ::std::cmp::min(0xFF, (0xFF * (0xFF - a) + a * b) / 0xFF); + // write the pixel + // We use byteorder, as the wayland protocol explicitly specifies + // that the pixels must be written in native endianness + writer.write_u32::<NativeEndian>((0xFF << 24) + (r << 16) + (g << 8) + b)?; + } + } else { + // We do not have any image to draw, so we draw black contents + for _ in 0..(buf_x * buf_y) { + writer.write_u32::<NativeEndian>(0xFF000000)?; + } + } + // Don't forget to flush the writer, to make sure all the contents are + // indeed written to the file. + writer.flush()?; + } + // Now, we create a buffer to the memory pool pointing to the contents + // we just wrote + let new_buffer = pool.buffer( + 0, // initial offset of the buffer in the pool + buf_x as i32, // width of the buffer, in pixels + buf_y as i32, // height of the buffer, in pixels + 4 * buf_x as i32, // stride: number of bytes between the start of two + // consecutive rows of pixels + wl_shm::Format::Argb8888, // the pixel format we wrote in + ); + surface.attach(Some(&new_buffer), 0, 0); + // damage the surface so that the compositor knows it needs to redraw it + if surface.version() >= 4 { + // If our server is recent enough and supports at least version 4 of the + // wl_surface interface, we can specify the damage in buffer coordinates. + // This is obviously the best and do that if possible. + surface.damage_buffer(0, 0, buf_x as i32, buf_y as i32); + } else { + // Otherwise, we fallback to compatilibity mode. Here we specify damage + // in surface coordinates, which would have been different if we had drawn + // our buffer at HiDPI resolution. We didn't though, so it is ok. + // Using `damage_buffer` in general is better though. + surface.damage(0, 0, buf_x as i32, buf_y as i32); + } + surface.commit(); + Ok(()) +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/kbd_input.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/kbd_input.rs new file mode 100644 index 0000000..baa48cf --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/kbd_input.rs @@ -0,0 +1,181 @@ +extern crate byteorder; +extern crate smithay_client_toolkit as sctk; + +use std::cmp::min; +use std::io::{BufWriter, Seek, SeekFrom, Write}; +use std::sync::{Arc, Mutex}; + +use byteorder::{NativeEndian, WriteBytesExt}; + +use sctk::keyboard::{ + map_keyboard_auto_with_repeat, Event as KbEvent, KeyRepeatEvent, KeyRepeatKind, +}; +use sctk::reexports::client::protocol::wl_compositor::RequestsTrait as CompositorRequests; +use sctk::reexports::client::protocol::wl_surface::RequestsTrait as SurfaceRequests; +use sctk::reexports::client::protocol::{wl_shm, wl_surface}; +use sctk::reexports::client::{Display, Proxy}; +use sctk::utils::{DoubleMemPool, MemPool}; +use sctk::window::{ConceptFrame, Event as WEvent, Window}; +use sctk::Environment; + +fn main() { + let (display, mut event_queue) = Display::connect_to_env().unwrap(); + let env = Environment::from_display(&*display, &mut event_queue).unwrap(); + + /* + * Create a buffer with window contents + */ + + let mut dimensions = (320u32, 240u32); + + /* + * Init wayland objects + */ + + let surface = env + .compositor + .create_surface(|surface| surface.implement(|_, _| {}, ())) + .unwrap(); + + let next_action = Arc::new(Mutex::new(None::<WEvent>)); + + let waction = next_action.clone(); + let mut window = Window::<ConceptFrame>::init_from_env(&env, surface, dimensions, move |evt| { + let mut next_action = waction.lock().unwrap(); + // Keep last event in priority order : Close > Configure > Refresh + let replace = match (&evt, &*next_action) { + (_, &None) + | (_, &Some(WEvent::Refresh)) + | (&WEvent::Configure { .. }, &Some(WEvent::Configure { .. })) + | (&WEvent::Close, _) => true, + _ => false, + }; + if replace { + *next_action = Some(evt); + } + }) + .expect("Failed to create a window !"); + + window.set_title("Kbd Input".to_string()); + + let mut pools = DoubleMemPool::new(&env.shm, || {}).expect("Failed to create a memory pool !"); + + /* + * Keyboard initialization + */ + + // initialize a seat to retrieve keyboard events + let seat = env + .manager + .instantiate_auto(|seat| seat.implement(|_, _| {}, ())) + .unwrap(); + + window.new_seat(&seat); + + map_keyboard_auto_with_repeat( + &seat, + KeyRepeatKind::System, + move |event: KbEvent, _| match event { + KbEvent::Enter { keysyms, .. } => { + println!("Gained focus while {} keys pressed.", keysyms.len(),); + } + KbEvent::Leave { .. } => { + println!("Lost focus."); + } + KbEvent::Key { + keysym, + state, + utf8, + .. + } => { + println!("Key {:?}: {:x}.", state, keysym); + if let Some(txt) = utf8 { + println!(" -> Received text \"{}\".", txt); + } + } + KbEvent::RepeatInfo { rate, delay } => { + println!( + "Received repeat info: start repeating every {}ms after an initial delay of {}ms", + rate, delay + ); + } + KbEvent::Modifiers { modifiers } => { + println!("Modifiers changed {:?}", modifiers); + } + }, + move |repeat_event: KeyRepeatEvent, _| { + println!("Repeated key {:x}.", repeat_event.keysym); + if let Some(txt) = repeat_event.utf8 { + println!(" -> Received text \"{}\".", txt); + } + }, + ).expect("Failed to map keyboard"); + + if !env.shell.needs_configure() { + // initial draw to bootstrap on wl_shell + if let Some(pool) = pools.pool() { + redraw(pool, window.surface(), dimensions).expect("Failed to draw") + } + window.refresh(); + } + + loop { + match next_action.lock().unwrap().take() { + Some(WEvent::Close) => break, + Some(WEvent::Refresh) => { + window.refresh(); + window.surface().commit(); + } + Some(WEvent::Configure { new_size, states }) => { + if let Some((w, h)) = new_size { + window.resize(w, h); + dimensions = (w, h) + } + println!("Window states: {:?}", states); + window.refresh(); + if let Some(pool) = pools.pool() { + redraw(pool, window.surface(), dimensions).expect("Failed to draw") + } + } + None => {} + } + + display.flush().unwrap(); + event_queue.dispatch().unwrap(); + } +} + +fn redraw( + pool: &mut MemPool, + surface: &Proxy<wl_surface::WlSurface>, + (buf_x, buf_y): (u32, u32), +) -> Result<(), ::std::io::Error> { + // resize the pool if relevant + pool.resize((4 * buf_x * buf_y) as usize) + .expect("Failed to resize the memory pool."); + // write the contents, a nice color gradient =) + pool.seek(SeekFrom::Start(0))?; + { + let mut writer = BufWriter::new(&mut *pool); + for i in 0..(buf_x * buf_y) { + let x = (i % buf_x) as u32; + let y = (i / buf_x) as u32; + let r: u32 = min(((buf_x - x) * 0xFF) / buf_x, ((buf_y - y) * 0xFF) / buf_y); + let g: u32 = min((x * 0xFF) / buf_x, ((buf_y - y) * 0xFF) / buf_y); + let b: u32 = min(((buf_x - x) * 0xFF) / buf_x, (y * 0xFF) / buf_y); + writer.write_u32::<NativeEndian>((0xFF << 24) + (r << 16) + (g << 8) + b)?; + } + writer.flush()?; + } + // get a buffer and attach it + let new_buffer = pool.buffer( + 0, + buf_x as i32, + buf_y as i32, + 4 * buf_x as i32, + wl_shm::Format::Argb8888, + ); + surface.attach(Some(&new_buffer), 0, 0); + surface.commit(); + Ok(()) +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/pointer_input.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/pointer_input.rs new file mode 100644 index 0000000..8775a30 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/pointer_input.rs @@ -0,0 +1,218 @@ +extern crate byteorder; +extern crate smithay_client_toolkit as sctk; + +use std::cmp::min; +use std::io::{BufWriter, Seek, SeekFrom, Write}; +use std::sync::{Arc, Mutex}; + +use byteorder::{NativeEndian, WriteBytesExt}; + +use sctk::reexports::client::protocol::wl_seat::RequestsTrait as SeatRequests; +use sctk::reexports::client::protocol::wl_surface::RequestsTrait as SurfaceRequests; +use sctk::reexports::client::protocol::{wl_pointer, wl_shm, wl_surface}; +use sctk::reexports::client::{Display, Proxy}; +use sctk::utils::{DoubleMemPool, MemPool}; +use sctk::window::{ConceptFrame, Event as WEvent, Window}; +use sctk::Environment; + +#[derive(Debug)] +enum NextAction { + Refresh, + Redraw, + Exit, +} + +struct WindowConfig { + width: u32, + height: u32, + dpi_scale: i32, + next_action: Option<NextAction>, +} + +impl WindowConfig { + pub fn new() -> Self { + WindowConfig { + width: 320, + height: 240, + dpi_scale: 1, + next_action: None, + } + } + + pub fn dimensions(&self) -> (u32, u32) { + ( + self.width * self.dpi_scale as u32, + self.height * self.dpi_scale as u32, + ) + } + + pub fn handle_action(&mut self, new_action: NextAction) { + let replace = match (&self.next_action, &new_action) { + (&None, _) + | (&Some(NextAction::Refresh), _) + | (&Some(NextAction::Redraw), &NextAction::Exit) => true, + _ => false, + }; + if replace { + self.next_action = Some(new_action); + } + } +} + +fn main() { + let window_config = Arc::new(Mutex::new(WindowConfig::new())); + let (display, mut event_queue) = Display::connect_to_env().unwrap(); + let env = Environment::from_display(&*display, &mut event_queue).unwrap(); + + /* + * Init wayland objects + */ + + let surface = { + let window_config = window_config.clone(); + env.create_surface(move |dpi, surface| { + surface.set_buffer_scale(dpi); + let mut guard = window_config.lock().unwrap(); + guard.dpi_scale = dpi; + guard.handle_action(NextAction::Redraw); + }) + }; + + let mut window = { + let window_config = window_config.clone(); + let dimensions = window_config.lock().unwrap().dimensions(); + Window::<ConceptFrame>::init_from_env(&env, surface, dimensions, move |event| { + let mut guard = window_config.lock().unwrap(); + if let WEvent::Configure { new_size, .. } = event { + if let Some((width, height)) = new_size { + guard.width = width; + guard.height = height; + } + } + let next_action = match event { + WEvent::Refresh => NextAction::Refresh, + WEvent::Configure { .. } => NextAction::Redraw, + WEvent::Close => NextAction::Exit, + }; + guard.handle_action(next_action); + }) + .expect("Failed to create a window !") + }; + + let mut pools = DoubleMemPool::new(&env.shm, || {}).expect("Failed to create a memory pool !"); + + /* + * Pointer initialization + */ + + // initialize a seat to retrieve keyboard events + let seat = env + .manager + .instantiate_auto(|seat| seat.implement(|_, _| {}, ())) + .unwrap(); + + window.new_seat(&seat); + + let main_surface = window.surface().clone(); + seat.get_pointer(move |ptr| { + ptr.implement( + move |evt, _| match evt { + wl_pointer::Event::Enter { + surface, + surface_x, + surface_y, + .. + } => { + if main_surface == surface { + println!("Pointer entered at ({}, {})", surface_x, surface_y); + } + } + wl_pointer::Event::Leave { surface, .. } => { + if main_surface == surface { + println!("Pointer left"); + } + } + wl_pointer::Event::Button { button, state, .. } => { + println!("Button {:?} was {:?}", button, state); + } + wl_pointer::Event::Motion { + surface_x, + surface_y, + .. + } => println!("Pointer motion to ({}, {})", surface_x, surface_y), + _ => {} + }, + (), + ) + }) + .unwrap(); + + if !env.shell.needs_configure() { + window_config + .lock() + .unwrap() + .handle_action(NextAction::Redraw); + } + + loop { + let next_action = window_config.lock().unwrap().next_action.take(); + println!("{:?}", next_action); + match next_action { + Some(NextAction::Exit) => break, + Some(NextAction::Refresh) => { + window.refresh(); + window.surface().commit(); + } + Some(NextAction::Redraw) => { + window.refresh(); + if let Some(pool) = pools.pool() { + redraw( + pool, + window.surface(), + window_config.lock().unwrap().dimensions(), + ) + .expect("Failed to draw") + } + } + None => {} + } + + display.flush().unwrap(); + event_queue.dispatch().unwrap(); + } +} + +fn redraw( + pool: &mut MemPool, + surface: &Proxy<wl_surface::WlSurface>, + (buf_x, buf_y): (u32, u32), +) -> Result<(), ::std::io::Error> { + // resize the pool if relevant + pool.resize((4 * buf_x * buf_y) as usize) + .expect("Failed to resize the memory pool."); + // write the contents, a nice color gradient =) + pool.seek(SeekFrom::Start(0))?; + { + let mut writer = BufWriter::new(&mut *pool); + for i in 0..(buf_x * buf_y) { + let x = (i % buf_x) as u32; + let y = (i / buf_x) as u32; + let r: u32 = min(((buf_x - x) * 0xFF) / buf_x, ((buf_y - y) * 0xFF) / buf_y); + let g: u32 = min((x * 0xFF) / buf_x, ((buf_y - y) * 0xFF) / buf_y); + let b: u32 = min(((buf_x - x) * 0xFF) / buf_x, (y * 0xFF) / buf_y); + writer.write_u32::<NativeEndian>((0xFF << 24) + (r << 16) + (g << 8) + b)?; + } + writer.flush()?; + } + // get a buffer and attach it + let new_buffer = pool.buffer( + 0, + buf_x as i32, + buf_y as i32, + 4 * buf_x as i32, + wl_shm::Format::Argb8888, + ); + surface.attach(Some(&new_buffer), 0, 0); + surface.commit(); + Ok(()) +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/selection.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/selection.rs new file mode 100644 index 0000000..9d2daf2 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/examples/selection.rs @@ -0,0 +1,180 @@ +extern crate byteorder; +extern crate smithay_client_toolkit as sctk; + +use std::io::{BufWriter, Read, Seek, SeekFrom, Write}; +use std::sync::{Arc, Mutex}; + +use byteorder::{NativeEndian, WriteBytesExt}; + +use sctk::data_device::{DataDevice, DndEvent, ReadPipe}; +use sctk::keyboard::{map_keyboard_auto, Event as KbEvent, KeyState}; +use sctk::utils::{DoubleMemPool, MemPool}; +use sctk::window::{ConceptFrame, Event as WEvent, Window}; +use sctk::Environment; + +use sctk::reexports::client::protocol::wl_compositor::RequestsTrait as CompositorRequests; +use sctk::reexports::client::protocol::wl_surface::RequestsTrait as SurfaceRequests; +use sctk::reexports::client::protocol::{wl_shm, wl_surface}; +use sctk::reexports::client::{Display, Proxy}; + +fn main() { + let (display, mut event_queue) = + Display::connect_to_env().expect("Failed to connect to the wayland server."); + let env = Environment::from_display(&*display, &mut event_queue).unwrap(); + + let seat = env + .manager + .instantiate_auto(|seat| seat.implement(|_, _| {}, ())) + .unwrap(); + + let device = DataDevice::init_for_seat(&env.data_device_manager, &seat, |event| match event { + // we don't accept drag'n'drop + DndEvent::Enter { + offer: Some(offer), .. + } => offer.accept(None), + _ => (), + }); + + // we need a window to receive things actually + let mut dimensions = (320u32, 240u32); + let surface = env + .compositor + .create_surface(|surface| surface.implement(|_, _| {}, ())) + .unwrap(); + + let next_action = Arc::new(Mutex::new(None::<WEvent>)); + + let waction = next_action.clone(); + let mut window = Window::<ConceptFrame>::init_from_env(&env, surface, dimensions, move |evt| { + let mut next_action = waction.lock().unwrap(); + // Keep last event in priority order : Close > Configure > Refresh + let replace = match (&evt, &*next_action) { + (_, &None) + | (_, &Some(WEvent::Refresh)) + | (&WEvent::Configure { .. }, &Some(WEvent::Configure { .. })) + | (&WEvent::Close, _) => true, + _ => false, + }; + if replace { + *next_action = Some(evt); + } + }) + .expect("Failed to create a window !"); + + window.new_seat(&seat); + window.set_title("Selection".to_string()); + + let mut pools = DoubleMemPool::new(&env.shm, || {}).expect("Failed to create a memory pool !"); + + let reader = Arc::new(Mutex::new(None::<ReadPipe>)); + + let reader2 = reader.clone(); + map_keyboard_auto(&seat, move |event: KbEvent, _| { + match event { + KbEvent::Key { + state, + utf8: Some(text), + .. + } => { + if text == "p" && state == KeyState::Pressed { + // pressed the 'p' key, try to read contents ! + device.with_selection(|offer| { + if let Some(offer) = offer { + print!("Current selection buffer mime types: [ "); + let mut has_text = false; + offer.with_mime_types(|types| { + for t in types { + print!("\"{}\", ", t); + if t == "text/plain;charset=utf-8" { + has_text = true; + } + } + }); + println!("]"); + if has_text { + println!("Buffer contains text, going to read it..."); + let mut reader = reader2.lock().unwrap(); + *reader = + Some(offer.receive("text/plain;charset=utf-8".into()).unwrap()); + } + } else { + println!("No current selection buffer!"); + } + }); + } + } + _ => (), + } + }) + .unwrap(); + + if !env.shell.needs_configure() { + // initial draw to bootstrap on wl_shell + if let Some(pool) = pools.pool() { + redraw(pool, window.surface(), dimensions).expect("Failed to draw") + } + window.refresh(); + } + + loop { + match next_action.lock().unwrap().take() { + Some(WEvent::Close) => break, + Some(WEvent::Refresh) => { + window.refresh(); + window.surface().commit(); + } + Some(WEvent::Configure { new_size, .. }) => { + if let Some((w, h)) = new_size { + window.resize(w, h); + dimensions = (w, h) + } + window.refresh(); + if let Some(pool) = pools.pool() { + redraw(pool, window.surface(), dimensions).expect("Failed to draw") + } + } + None => {} + } + + display.flush().unwrap(); + + if let Some(mut reader) = reader.lock().unwrap().take() { + // we have something to read + let mut text = String::new(); + reader.read_to_string(&mut text).unwrap(); + println!("The selection buffer contained: \"{}\"", text); + } + + event_queue.dispatch().unwrap(); + } +} + +fn redraw( + pool: &mut MemPool, + surface: &Proxy<wl_surface::WlSurface>, + (buf_x, buf_y): (u32, u32), +) -> Result<(), ::std::io::Error> { + // resize the pool if relevant + pool.resize((4 * buf_x * buf_y) as usize) + .expect("Failed to resize the memory pool."); + // write the contents, a nice color gradient =) + pool.seek(SeekFrom::Start(0))?; + { + let mut writer = BufWriter::new(&mut *pool); + for _ in 0..(buf_x * buf_y) { + writer.write_u32::<NativeEndian>(0xFF000000)?; + } + writer.flush()?; + } + // get a buffer and attach it + let new_buffer = pool.buffer( + 0, + buf_x as i32, + buf_y as i32, + 4 * buf_x as i32, + wl_shm::Format::Argb8888, + ); + surface.attach(Some(&new_buffer), 0, 0); + surface.commit(); + Ok(()) +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/data_device.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/data_device.rs new file mode 100644 index 0000000..54b5c1a --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/data_device.rs @@ -0,0 +1,284 @@ +use wayland_client::protocol::{ + wl_data_device, wl_data_device_manager, wl_data_offer, wl_seat, wl_surface, +}; +use wayland_client::{NewProxy, Proxy, QueueToken}; + +use wayland_client::protocol::wl_data_device::RequestsTrait as DeviceRequests; +use wayland_client::protocol::wl_data_device_manager::RequestsTrait as MgrRequests; +use wayland_client::protocol::wl_data_source::RequestsTrait as SourceRequests; + +use std::sync::{Arc, Mutex}; + +use super::{DataOffer, DataSource, DndAction}; + +struct Inner { + selection: Option<DataOffer>, + current_dnd: Option<DataOffer>, + known_offers: Vec<DataOffer>, +} + +impl Inner { + fn new_offer(&mut self, offer: NewProxy<wl_data_offer::WlDataOffer>) { + self.known_offers.push(DataOffer::new(offer)); + } + + fn set_selection(&mut self, offer: Option<Proxy<wl_data_offer::WlDataOffer>>) { + if let Some(offer) = offer { + if let Some(id) = self + .known_offers + .iter() + .position(|o| o.offer.equals(&offer)) + { + self.selection = Some(self.known_offers.swap_remove(id)); + } else { + panic!("Compositor set an unknown data_offer for selection."); + } + } else { + // drop the current offer if any + self.selection = None; + } + } + + fn set_dnd(&mut self, offer: Option<Proxy<wl_data_offer::WlDataOffer>>) { + if let Some(offer) = offer { + if let Some(id) = self + .known_offers + .iter() + .position(|o| o.offer.equals(&offer)) + { + self.current_dnd = Some(self.known_offers.swap_remove(id)); + } else { + panic!("Compositor set an unknown data_offer for selection."); + } + } else { + // drop the current offer if any + self.current_dnd = None; + } + } +} + +/// Handle to support data exchange on a given seat +/// +/// This type provides you with functionality to send and receive +/// data through drag'n'drop or copy/paste actions. It is associated +/// with a seat upon creation. +pub struct DataDevice { + device: Proxy<wl_data_device::WlDataDevice>, + inner: Arc<Mutex<Inner>>, +} + +/// Possible events generated during a drag'n'drop session +pub enum DndEvent<'a> { + /// A new drag'n'drop entered your surfaces + Enter { + /// The associated data offer + /// + /// Is None if it is an internal drag'n'drop you started with + /// no source. See `DataDevice::start_drag` for details. + offer: Option<&'a DataOffer>, + /// A serial associated with the entry of this dnd + serial: u32, + /// The entered surface + surface: Proxy<wl_surface::WlSurface>, + /// horizontal location on the surface + x: f64, + /// vertical location on the surface + y: f64, + }, + /// The drag'n'drop offer moved on the surface + Motion { + /// The associated data offer + /// + /// Is None if it is an internal drag'n'drop you started with + /// no source. See `DataDevice::start_drag` for details. + offer: Option<&'a DataOffer>, + /// The time of this motion + time: u32, + /// new horizontal location + x: f64, + /// new vertical location + y: f64, + }, + /// The drag'n'drop offer left your surface + Leave, + /// The drag'n'drop was dropped on your surface + Drop { + /// The associated data offer + /// + /// Is None if it is an internal drag'n'drop you started with + /// no source. See `DataDevice::start_drag` for details. + offer: Option<&'a DataOffer>, + }, +} + +fn data_device_implem<Impl>(event: wl_data_device::Event, inner: &mut Inner, implem: &mut Impl) +where + for<'a> Impl: FnMut(DndEvent<'a>), +{ + use self::wl_data_device::Event; + + match event { + Event::DataOffer { id } => inner.new_offer(id), + Event::Enter { + serial, + surface, + x, + y, + id, + } => { + inner.set_dnd(id); + implem(DndEvent::Enter { + serial, + surface, + x, + y, + offer: inner.current_dnd.as_ref(), + }); + } + Event::Motion { time, x, y } => { + implem(DndEvent::Motion { + x, + y, + time, + offer: inner.current_dnd.as_ref(), + }); + } + Event::Leave => implem(DndEvent::Leave), + Event::Drop => { + implem(DndEvent::Drop { + offer: inner.current_dnd.as_ref(), + }); + } + Event::Selection { id } => inner.set_selection(id), + } +} + +impl DataDevice { + /// Create the DataDevice helper for this seat. + /// + /// You need to provide an implementation that will handle drag'n'drop + /// events. + pub fn init_for_seat<Impl>( + manager: &Proxy<wl_data_device_manager::WlDataDeviceManager>, + seat: &Proxy<wl_seat::WlSeat>, + mut implem: Impl, + ) -> DataDevice + where + for<'a> Impl: FnMut(DndEvent<'a>) + Send + 'static, + { + let inner = Arc::new(Mutex::new(Inner { + selection: None, + current_dnd: None, + known_offers: Vec::new(), + })); + + let inner2 = inner.clone(); + let device = manager + .get_data_device(seat, move |device| { + device.implement( + move |evt, _| { + let mut inner = inner2.lock().unwrap(); + data_device_implem(evt, &mut *inner, &mut implem); + }, + (), + ) + }) + .expect("Invalid data device or seat."); + + DataDevice { device, inner } + } + + /// Create the DataDevice helper for this seat. + /// + /// Same as `init_for_seat()`, but allows the implementation to + /// not be send. + /// + /// **unsafety**: unsafe for the same reasons as `NewProxy::implement_nonsend`. + pub unsafe fn init_for_seat_nonsend<Impl>( + manager: &Proxy<wl_data_device_manager::WlDataDeviceManager>, + seat: &Proxy<wl_seat::WlSeat>, + mut implem: Impl, + token: &QueueToken, + ) -> DataDevice + where + for<'a> Impl: FnMut(DndEvent<'a>) + Send + 'static, + { + let inner = Arc::new(Mutex::new(Inner { + selection: None, + current_dnd: None, + known_offers: Vec::new(), + })); + + let inner2 = inner.clone(); + let device = manager + .get_data_device(seat, move |device| { + device.implement_nonsend( + move |evt, _| { + let mut inner = inner2.lock().unwrap(); + data_device_implem(evt, &mut *inner, &mut implem); + }, + (), + token, + ) + }) + .expect("Invalid data device or seat."); + + DataDevice { device, inner } + } + + /// Start a drag'n'drop offer + /// + /// You need to specify the origin surface, as well a serial associated + /// to an implicit grab on this surface (for example received by a pointer click). + /// + /// An optional `DataSource` can be provided. If it is `None`, this drag'n'drop will + /// be considered as internal to your application, and other applications will not be + /// notified of it. You are then responsible for acting accordingly on drop. + /// + /// You also need to specify which possible drag'n'drop actions are associated to this + /// drag (copy, move, or ask), the final action will be chosen by the target and/or + /// compositor. + /// + /// You can finally provide a surface that will be used as an icon associated with + /// this drag'n'drop for user visibility. + pub fn start_drag( + &self, + origin: &Proxy<wl_surface::WlSurface>, + source: Option<DataSource>, + actions: DndAction, + icon: Option<&Proxy<wl_surface::WlSurface>>, + serial: u32, + ) { + if let Some(source) = source { + source.source.set_actions(actions.to_raw()); + self.device + .start_drag(Some(&source.source), origin, icon, serial); + } else { + self.device.start_drag(None, origin, icon, serial); + } + } + + /// Provide a data source as the new content for the selection + /// + /// Correspond to traditional copy/paste behavior. Setting the + /// source to `None` will clear the selection. + pub fn set_selection(&self, source: &Option<DataSource>, serial: u32) { + self.device + .set_selection(source.as_ref().map(|s| &s.source), serial); + } + + /// Access the `DataOffer` currently associated with the selection buffer + pub fn with_selection<F, T>(&self, f: F) -> T + where + F: FnOnce(Option<&DataOffer>) -> T, + { + let inner = self.inner.lock().unwrap(); + f(inner.selection.as_ref()) + } +} + +impl Drop for DataDevice { + fn drop(&mut self) { + self.device.release(); + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/data_offer.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/data_offer.rs new file mode 100644 index 0000000..3925fd2 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/data_offer.rs @@ -0,0 +1,164 @@ +use wayland_client::protocol::wl_data_device_manager::DndAction; +use wayland_client::protocol::wl_data_offer; +use wayland_client::{NewProxy, Proxy}; + +use wayland_client::protocol::wl_data_offer::RequestsTrait as OfferRequests; + +use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; +use std::sync::{Arc, Mutex}; +use std::{fs, io}; + +struct Inner { + mime_types: Vec<String>, + actions: DndAction, + current_action: DndAction, + serial: u32, +} + +/// A data offer for receiving data though copy/paste or +/// drag and drop +pub struct DataOffer { + pub(crate) offer: Proxy<wl_data_offer::WlDataOffer>, + inner: Arc<Mutex<Inner>>, +} + +impl DataOffer { + pub(crate) fn new(offer: NewProxy<wl_data_offer::WlDataOffer>) -> DataOffer { + let inner = Arc::new(Mutex::new(Inner { + mime_types: Vec::new(), + actions: DndAction::None, + current_action: DndAction::None, + serial: 0, + })); + let inner2 = inner.clone(); + let offer = offer.implement( + move |event, _| { + use self::wl_data_offer::Event; + let mut inner = inner2.lock().unwrap(); + match event { + Event::Offer { mime_type } => { + inner.mime_types.push(mime_type); + } + Event::SourceActions { source_actions } => { + inner.actions = DndAction::from_bits_truncate(source_actions); + } + Event::Action { dnd_action } => { + inner.current_action = DndAction::from_bits_truncate(dnd_action); + } + } + }, + (), + ); + + DataOffer { offer, inner } + } + + /// Access the list of mime types proposed by this offer + pub fn with_mime_types<F, T>(&self, f: F) -> T + where + F: FnOnce(&[String]) -> T, + { + let inner = self.inner.lock().unwrap(); + f(&inner.mime_types) + } + + /// Get the list of available actions for this offer + pub fn get_available_actions(&self) -> DndAction { + self.inner.lock().unwrap().actions + } + + /// Get the currently set final action for this offer + pub fn get_current_action(&self) -> DndAction { + self.inner.lock().unwrap().current_action + } + + /// Accept a mime type for receiving data through this offer + pub fn accept(&self, mime_type: Option<String>) { + let serial = self.inner.lock().unwrap().serial; + self.offer.accept(serial, mime_type); + } + + /// Request to receive the data of a given mime type + /// + /// You can do this several times, as a reaction to motion of + /// the dnd cursor, or to inspect the data in order to choose your + /// response. + /// + /// Note that you should *not* read the contents right way in a + /// blocking way, as you may deadlock your application doing so. + /// At least make sure you flush your events to the server before + /// doing so. + /// + /// Fails if too many file descriptors were already open and a pipe + /// could not be created. + pub fn receive(&self, mime_type: String) -> Result<ReadPipe, ()> { + use nix::fcntl::OFlag; + use nix::unistd::{close, pipe2}; + // create a pipe + let (readfd, writefd) = pipe2(OFlag::O_CLOEXEC).map_err(|_| ())?; + + self.offer.receive(mime_type, writefd); + + if let Err(err) = close(writefd) { + eprintln!("[SCTK] Data offer: failed to close write pipe: {}", err); + } + + Ok(unsafe { FromRawFd::from_raw_fd(readfd) }) + } + + /// Notify the send and compositor of the dnd actions you accept + /// + /// You need to provide the set of supported actions, as well as + /// a single preferred action. + pub fn set_actions(&self, supported: DndAction, preferred: DndAction) { + self.offer + .set_actions(supported.to_raw(), preferred.to_raw()); + } + + /// Notify that you are finished with this offer, and will no longer + /// be using it + /// + /// Note that it is a protocol error to finish if no action or mime + /// type was accepted. + pub fn finish(&self) { + self.offer.finish(); + self.offer.destroy(); + } +} + +impl Drop for DataOffer { + fn drop(&mut self) { + self.offer.destroy(); + } +} + +/// A file descriptor that can only be written to +pub struct ReadPipe { + file: fs::File, +} + +impl io::Read for ReadPipe { + fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { + self.file.read(buf) + } +} + +impl FromRawFd for ReadPipe { + unsafe fn from_raw_fd(fd: RawFd) -> ReadPipe { + ReadPipe { + file: FromRawFd::from_raw_fd(fd), + } + } +} + +impl AsRawFd for ReadPipe { + fn as_raw_fd(&self) -> RawFd { + self.file.as_raw_fd() + } +} + +impl IntoRawFd for ReadPipe { + fn into_raw_fd(self) -> RawFd { + self.file.into_raw_fd() + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/data_source.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/data_source.rs new file mode 100644 index 0000000..f6a1dbf --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/data_source.rs @@ -0,0 +1,205 @@ +use wayland_client::protocol::{wl_data_device_manager, wl_data_source}; +use wayland_client::{Proxy, QueueToken}; + +use wayland_client::protocol::wl_data_device_manager::RequestsTrait as MgrRequests; +use wayland_client::protocol::wl_data_source::RequestsTrait as SourceRequests; + +use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; +use std::{fs, io}; + +/// A data source for sending data though copy/paste or +/// drag and drop +pub struct DataSource { + pub(crate) source: Proxy<wl_data_source::WlDataSource>, +} + +/// Possible events a data source needs to react to +pub enum DataSourceEvent { + /// Write the offered data for selected mime type + /// + /// This can happen several times during a dnd setup, + /// and does not mean the action is finished. + Send { + /// Requested mime type + mime_type: String, + /// Pipe to write into + pipe: WritePipe, + }, + /// Target mime type + /// + /// Notifies that the target accepted a given mime type. + /// You can use it to provide feedback (changing the icon + /// of the drag'n'drop for example). + /// + /// Can be `None` if the current target does not accept any of the + /// proposed mime types. + /// + /// This event can be emitted several times during the process + Target { + /// The type accepted by the target + mime_type: Option<String>, + }, + /// Notifies of the current selected action for the drag'n'drop + /// + /// Can only happen for data sources used during a drag'n'drop. + /// + /// This can change several times, the last received defines which action + /// should actually be taken. + Action { + /// The action chosen by the target + action: wl_data_device_manager::DndAction, + }, + /// The action using this data source was cancelled. + /// + /// Once this event is received, the `DataSource` can not be used any more, + /// and you should drop it for cleanup. + /// + /// Happens if the user cancels the current drag'n'drop, or replaces the + /// selection buffer. + Cancelled, + /// The user performed the "drop" during a drag'n'drop + /// + /// This does not mean the operation is finished (the operation can still + /// be cancelled afterwards). + /// + /// You are not guaranteed to receive this event at some point, as the compositor + /// may cancel the action before the user drops. + /// + /// This event can only be generated on sources used for drag'n'drop, not + /// selection sources. + Dropped, + /// The action is finished, this data source will not be used any more + /// + /// If the selected drag'n'drop action was "move", you can now delete the + /// underlying resource. + /// + /// This event can only be generated on sources used for drag'n'drop, not + /// selection sources. + Finished, +} + +fn data_source_impl<Impl>( + evt: wl_data_source::Event, + source: &Proxy<wl_data_source::WlDataSource>, + implem: &mut Impl, +) where + Impl: FnMut(DataSourceEvent), +{ + use self::wl_data_source::Event; + let event = match evt { + Event::Target { mime_type } => DataSourceEvent::Target { mime_type }, + Event::Send { mime_type, fd } => DataSourceEvent::Send { + mime_type, + pipe: unsafe { FromRawFd::from_raw_fd(fd) }, + }, + Event::Action { dnd_action } => DataSourceEvent::Action { + action: wl_data_device_manager::DndAction::from_bits_truncate(dnd_action), + }, + Event::Cancelled => { + source.destroy(); + DataSourceEvent::Cancelled + } + Event::DndDropPerformed => DataSourceEvent::Dropped, + Event::DndFinished => { + source.destroy(); + DataSourceEvent::Finished + } + }; + implem(event); +} + +impl DataSource { + /// Create a new data source + /// + /// You'll then need to provide it to a data device to send it + /// either via selection (aka copy/paste) or via a drag and drop. + pub fn new<Impl>( + mgr: &Proxy<wl_data_device_manager::WlDataDeviceManager>, + mime_types: &[&str], + mut implem: Impl, + ) -> DataSource + where + Impl: FnMut(DataSourceEvent) + Send + 'static, + { + let source = mgr + .create_data_source(|source| { + source.implement( + move |evt, source: Proxy<_>| data_source_impl(evt, &source, &mut implem), + (), + ) + }) + .expect("Provided a dead data device manager to create a data source."); + + for &mime in mime_types { + source.offer(mime.into()); + } + + DataSource { source } + } + + /// Create a data source + /// + /// Like `new`, but the implementation does not require to + /// be `Send`. + /// + /// **unsafety**: for the same reasons as `NewProxy::implement_nonsend` + pub unsafe fn new_nonsend<Impl>( + mgr: &Proxy<wl_data_device_manager::WlDataDeviceManager>, + mime_types: &[&str], + mut implem: Impl, + token: &QueueToken, + ) -> DataSource + where + Impl: FnMut(DataSourceEvent) + 'static, + { + let source = mgr + .create_data_source(|source| { + source.implement_nonsend( + move |evt, source: Proxy<_>| data_source_impl(evt, &source, &mut implem), + (), + token, + ) + }) + .expect("Provided a dead data device manager to create a data source."); + + for &mime in mime_types { + source.offer(mime.into()); + } + + DataSource { source } + } +} + +/// A file descriptor that can only be written to +pub struct WritePipe { + file: fs::File, +} + +impl io::Write for WritePipe { + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + self.file.write(buf) + } + fn flush(&mut self) -> io::Result<()> { + self.file.flush() + } +} + +impl FromRawFd for WritePipe { + unsafe fn from_raw_fd(fd: RawFd) -> WritePipe { + WritePipe { + file: FromRawFd::from_raw_fd(fd), + } + } +} + +impl AsRawFd for WritePipe { + fn as_raw_fd(&self) -> RawFd { + self.file.as_raw_fd() + } +} + +impl IntoRawFd for WritePipe { + fn into_raw_fd(self) -> RawFd { + self.file.into_raw_fd() + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/mod.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/mod.rs new file mode 100644 index 0000000..3d26cdd --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/data_device/mod.rs @@ -0,0 +1,11 @@ +//! Helpers to handle data device related actions + +mod data_device; +mod data_offer; +mod data_source; + +pub use wayland_client::protocol::wl_data_device_manager::DndAction; + +pub use self::data_device::{DataDevice, DndEvent}; +pub use self::data_offer::{DataOffer, ReadPipe}; +pub use self::data_source::{DataSource, DataSourceEvent, WritePipe}; diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/env.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/env.rs new file mode 100644 index 0000000..1b46698 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/env.rs @@ -0,0 +1,258 @@ +use std::io; +use std::sync::{Arc, Mutex}; + +use shell::{create_shell_surface, Event, ShellSurface}; +use surface::{create_surface, SurfaceUserData}; + +use wayland_client::protocol::{ + wl_compositor, wl_data_device_manager, wl_display, wl_registry, wl_shell, wl_shm, + wl_subcompositor, wl_surface, +}; +use wayland_client::{EventQueue, GlobalEvent, GlobalManager, Proxy}; +use wayland_protocols::unstable::xdg_decoration::v1::client::zxdg_decoration_manager_v1; +use wayland_protocols::unstable::xdg_shell::v6::client::zxdg_shell_v6; +use wayland_protocols::xdg_shell::client::xdg_wm_base; + +/// Possible shell globals +pub enum Shell { + /// Using xdg_shell protocol, the standard + Xdg(Proxy<xdg_wm_base::XdgWmBase>), + /// Old version of xdg_shell, for compatibility + Zxdg(Proxy<zxdg_shell_v6::ZxdgShellV6>), + /// Using wl_shell, deprecated, compatibility mode + Wl(Proxy<wl_shell::WlShell>), +} + +impl Shell { + /// Check whether you need to wait for a configure before + /// drawing to your surfaces + /// + /// This depend on the underlying shell protocol + pub fn needs_configure(&self) -> bool { + match *self { + Shell::Xdg(_) => true, + Shell::Zxdg(_) => true, + Shell::Wl(_) => false, + } + } +} + +/// A convenience for global management +/// +/// This type provides convenience utilities for writing wayland +/// client apps, by auto-binding a large portion of the global +/// objects you'll likely need to write your app. This is mostly +/// provided as a mean to factor a consequent amount of dumb, +/// redundant code. +pub struct Environment { + /// The underlying GlobalManager wrapping your registry + pub manager: GlobalManager, + /// The compositor global, used to create surfaces + pub compositor: Proxy<wl_compositor::WlCompositor>, + /// The subcompositor global, used to create subsurfaces + pub subcompositor: Proxy<wl_subcompositor::WlSubcompositor>, + /// The shell global, used make your surfaces into windows + /// + /// This tries to bind using the xdg_shell protocol, and fallbacks + /// to wl_shell if it fails + pub shell: Shell, + /// The SHM global, to create shared memory buffers + pub shm: Proxy<wl_shm::WlShm>, + /// The data device manager, used to handle drag&drop and selection + /// copy/paste + pub data_device_manager: Proxy<wl_data_device_manager::WlDataDeviceManager>, + /// A manager for handling the advertised outputs + pub outputs: ::output::OutputMgr, + /// The decoration manager, if the server supports server-side decorations + pub decorations_mgr: Option<Proxy<zxdg_decoration_manager_v1::ZxdgDecorationManagerV1>>, + shm_formats: Arc<Mutex<Vec<wl_shm::Format>>>, + surfaces: Arc<Mutex<Vec<Proxy<wl_surface::WlSurface>>>>, +} + +impl Environment { + /// Create an environment wrapping a new registry + /// + /// It requires you to provide the `EventQueue` as well because + /// the initialization process does a few roundtrip to the server + /// to initialize all the globals. + pub fn from_display( + display: &Proxy<wl_display::WlDisplay>, + evq: &mut EventQueue, + ) -> io::Result<Environment> { + Environment::from_display_with_cb(display, evq, |_, _| {}) + } + + /// Create an environment wrapping a new registry + /// + /// Additionally to `from_display`, this allows you to provide + /// a callback to be notified of global events, just like + /// `GlobalManager::new_with_cb`. Note that you will still + /// receive events even if they are processed by this `Environment`. + pub fn from_display_with_cb<Impl>( + display: &Proxy<wl_display::WlDisplay>, + evq: &mut EventQueue, + mut cb: Impl, + ) -> io::Result<Environment> + where + Impl: FnMut(GlobalEvent, Proxy<wl_registry::WlRegistry>) + Send + 'static, + { + let outputs = ::output::OutputMgr::new(); + let outputs2 = outputs.clone(); + + let surfaces: Arc<Mutex<Vec<Proxy<wl_surface::WlSurface>>>> = + Arc::new(Mutex::new(Vec::new())); + let surfaces2 = surfaces.clone(); + + let display_wrapper = display.make_wrapper(&evq.get_token()).unwrap(); + let manager = GlobalManager::new_with_cb(&display_wrapper, move |event, registry| { + match event { + GlobalEvent::New { + id, + ref interface, + version, + } => { + if let "wl_output" = &interface[..] { + outputs2.new_output(id, version, ®istry) + } + } + GlobalEvent::Removed { id, ref interface } => { + if let "wl_output" = &interface[..] { + let output = outputs2 + .find_id(id, |output, _info| output.clone()) + .unwrap(); + for surface in &*surfaces2.lock().unwrap() { + surface + .user_data::<Mutex<SurfaceUserData>>() + .expect("Surface was not created with create_surface.") + .lock() + .unwrap() + .leave(&output, surface.clone()) + } + outputs2.output_removed(id) + } + } + } + cb(event, registry); + }); + + // double sync to retrieve the global list + // and the globals metadata + evq.sync_roundtrip()?; + evq.sync_roundtrip()?; + + // wl_compositor + let compositor = manager + .instantiate_auto(|compositor| compositor.implement(|_, _| {}, ())) + .expect("Server didn't advertise `wl_compositor`?!"); + + // wl_subcompositor + let subcompositor = manager + .instantiate_auto(|subcompositor| subcompositor.implement(|_, _| {}, ())) + .expect("Server didn't advertise `wl_subcompositor`?!"); + + // wl_shm + let shm_formats = Arc::new(Mutex::new(Vec::new())); + let shm_formats2 = shm_formats.clone(); + let shm = manager + .instantiate_auto(|shm| { + shm.implement( + move |wl_shm::Event::Format { format }, _| { + shm_formats2.lock().unwrap().push(format); + }, + (), + ) + }) + .expect("Server didn't advertise `wl_shm`?!"); + + let data_device_manager = manager + .instantiate_auto(|data_device_manager| data_device_manager.implement(|_, _| {}, ())) + .expect("Server didn't advertise `wl_data_device_manager`?!"); + + // shells + let shell = if let Ok(wm_base) = manager.instantiate_auto(|wm_base| { + wm_base.implement( + |xdg_wm_base::Event::Ping { serial }, proxy: Proxy<_>| { + use self::xdg_wm_base::RequestsTrait; + proxy.pong(serial) + }, + (), + ) + }) { + Shell::Xdg(wm_base) + } else if let Ok(xdg_shell) = manager.instantiate_auto(|xdg_shell| { + xdg_shell.implement( + |zxdg_shell_v6::Event::Ping { serial }, proxy: Proxy<_>| { + use self::zxdg_shell_v6::RequestsTrait; + proxy.pong(serial) + }, + (), + ) + }) { + Shell::Zxdg(xdg_shell) + } else if let Ok(wl_shell) = + manager.instantiate_auto(|wl_shell| wl_shell.implement(|_, _| {}, ())) + { + Shell::Wl(wl_shell) + } else { + panic!("Server didn't advertise neither `xdg_wm_base` nor `wl_shell`?!"); + }; + + // try to retrieve the decoration manager + let decorations_mgr = if let Shell::Xdg(_) = shell { + manager + .instantiate_auto(|mgr| mgr.implement(|_, _| {}, ())) + .ok() + } else { + None + }; + + // sync to retrieve the global events + evq.sync_roundtrip()?; + + Ok(Environment { + manager, + compositor, + subcompositor, + shell, + shm, + shm_formats, + data_device_manager, + decorations_mgr, + outputs, + surfaces, + }) + } + + /// Retrieve the accepted SHM formats of the server + pub fn shm_formats(&self) -> Vec<wl_shm::Format> { + self.shm_formats.lock().unwrap().clone() + } + + /// Create a new dpi aware surface + /// + /// The provided callback will be fired whenever the DPI factor associated to it + /// changes. + /// + /// The DPI factor associated to a surface is defined as the maximum of the DPI + /// factors of the outputs it is displayed on. + pub fn create_surface<F>(&self, dpi_change: F) -> Proxy<wl_surface::WlSurface> + where + F: FnMut(i32, Proxy<wl_surface::WlSurface>) + Send + 'static, + { + let surface = create_surface(&self, Box::new(dpi_change)); + self.surfaces.lock().unwrap().push(surface.clone()); + surface + } + + /// Create a new shell surface + pub fn create_shell_surface<Impl>( + &self, + surface: &Proxy<wl_surface::WlSurface>, + shell_impl: Impl, + ) -> Box<ShellSurface> + where + Impl: FnMut(Event) + Send + 'static, + { + create_shell_surface(&self.shell, surface, shell_impl) + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/keyboard/ffi.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/keyboard/ffi.rs new file mode 100644 index 0000000..68a8e8a --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/keyboard/ffi.rs @@ -0,0 +1,266 @@ +#![allow(dead_code, non_camel_case_types)] +#![cfg_attr(rustfmt, rustfmt_skip)] + +use std::os::raw::{c_char, c_int, c_void, c_uint}; + +pub const XKB_MOD_NAME_SHIFT : &[u8] = b"Shift\0"; +pub const XKB_MOD_NAME_CAPS : &[u8] = b"Lock\0"; +pub const XKB_MOD_NAME_CTRL : &[u8] = b"Control\0"; +pub const XKB_MOD_NAME_ALT : &[u8] = b"Mod1\0"; +pub const XKB_MOD_NAME_NUM : &[u8] = b"Mod2\0"; +pub const XKB_MOD_NAME_LOGO : &[u8] = b"Mod4\0"; + +pub const XKB_LED_NAME_CAPS : &[u8] = b"Caps Lock\0"; +pub const XKB_LED_NAME_NUM : &[u8] = b"Num Lock\0"; +pub const XKB_LED_NAME_SCROLL : &[u8] = b"Scroll Lock\0"; + +pub struct xkb_context; +pub struct xkb_keymap; +pub struct xkb_state; +pub struct xkb_compose_table; +pub struct xkb_compose_state; + +pub type xkb_keycode_t = u32; +pub type xkb_keysym_t = u32; +pub type xkb_layout_index_t = u32; +pub type xkb_layout_mask_t = u32; +pub type xkb_level_index_t = u32; +pub type xkb_mod_index_t = u32; +pub type xkb_mod_mask_t = u32; +pub type xkb_led_index_t = u32; +pub type xkb_led_mask_t = u32; + +pub const XKB_KEYCODE_INVALID :u32 = 0xffffffff; +pub const XKB_LAYOUT_INVALID :u32 = 0xffffffff; +pub const XKB_LEVEL_INVALID :u32 = 0xffffffff; +pub const XKB_MOD_INVALID :u32 = 0xffffffff; +pub const XKB_LED_INVALID :u32 = 0xffffffff; +pub const XKB_KEYCODE_MAX :u32 = 0xffffffff - 1; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct xkb_rule_names { + pub rules: *const c_char, + pub model: *const c_char , + pub layout: *const c_char, + pub variant: *const c_char, + pub options: *const c_char, +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_keysym_flags { + /** Do not apply any flags. */ + XKB_KEYSYM_NO_FLAGS = 0, + /** Find keysym by case-insensitive search. */ + XKB_KEYSYM_CASE_INSENSITIVE = (1 << 0) +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_context_flags { + /** Do not apply any context flags. */ + XKB_CONTEXT_NO_FLAGS = 0, + /** Create this context with an empty include path. */ + XKB_CONTEXT_NO_DEFAULT_INCLUDES = (1 << 0), + /** + * Don't take RMLVO names from the environment. + * @since 0.3.0 + */ + XKB_CONTEXT_NO_ENVIRONMENT_NAMES = (1 << 1) +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_log_level { + /** Log critical internal errors only. */ + XKB_LOG_LEVEL_CRITICAL = 10, + /** Log all errors. */ + XKB_LOG_LEVEL_ERROR = 20, + /** Log warnings and errors. */ + XKB_LOG_LEVEL_WARNING = 30, + /** Log information, warnings, and errors. */ + XKB_LOG_LEVEL_INFO = 40, + /** Log everything. */ + XKB_LOG_LEVEL_DEBUG = 50 +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_keymap_compile_flags { + /** Do not apply any flags. */ + XKB_KEYMAP_COMPILE_NO_FLAGS = 0, +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_keymap_format { + /** Cannot be used for creation */ + XKB_KEYMAP_USE_ORIGINAL_FORMAT = 0, + /** The current/classic XKB text format, as generated by xkbcomp -xkb. */ + XKB_KEYMAP_FORMAT_TEXT_V1 = 1, +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_key_direction { + /** The key was released. */ + XKB_KEY_UP, + /** The key was pressed. */ + XKB_KEY_DOWN +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_compose_compile_flags { + XKB_COMPOSE_COMPILE_NO_FLAGS = 0 +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_compose_format { + XKB_COMPOSE_FORMAT_TEXT_V1 = 1 +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_compose_state_flags { + XKB_COMPOSE_STATE_NO_FLAGS = 0 +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_compose_status { + XKB_COMPOSE_NOTHING, + XKB_COMPOSE_COMPOSING, + XKB_COMPOSE_COMPOSED, + XKB_COMPOSE_CANCELLED +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum xkb_compose_feed_result { + XKB_COMPOSE_FEED_IGNORED, + XKB_COMPOSE_FEED_ACCEPTED +} + +bitflags!( + pub struct xkb_state_component: u32 { + /** Depressed modifiers, i.e. a key is physically holding them. */ + const XKB_STATE_MODS_DEPRESSED = (1 << 0); + /** Latched modifiers, i.e. will be unset after the next non-modifier + * key press. */ + const XKB_STATE_MODS_LATCHED = (1 << 1); + /** Locked modifiers, i.e. will be unset after the key provoking the + * lock has been pressed again. */ + const XKB_STATE_MODS_LOCKED = (1 << 2); + /** Effective modifiers, i.e. currently active and affect key + * processing (derived from the other state components). + * Use this unless you explictly care how the state came about. */ + const XKB_STATE_MODS_EFFECTIVE = (1 << 3); + /** Depressed layout, i.e. a key is physically holding it. */ + const XKB_STATE_LAYOUT_DEPRESSED = (1 << 4); + /** Latched layout, i.e. will be unset after the next non-modifier + * key press. */ + const XKB_STATE_LAYOUT_LATCHED = (1 << 5); + /** Locked layout, i.e. will be unset after the key provoking the lock + * has been pressed again. */ + const XKB_STATE_LAYOUT_LOCKED = (1 << 6); + /** Effective layout, i.e. currently active and affects key processing + * (derived from the other state components). + * Use this unless you explictly care how the state came about. */ + const XKB_STATE_LAYOUT_EFFECTIVE = (1 << 7); + /** LEDs (derived from the other state components). */ + const XKB_STATE_LEDS = (1 << 8); + } +); + +dlopen_external_library!(XkbCommon, +functions: + fn xkb_keysym_get_name(xkb_keysym_t, *mut c_char, usize) -> c_int, + fn xkb_keysym_from_name(*const c_char, xkb_keysym_flags) -> xkb_keysym_t, + fn xkb_keysym_to_utf8(xkb_keysym_t, *mut c_char, usize) -> c_int, + fn xkb_keysym_to_utf32(xkb_keysym_t) -> u32, + fn xkb_context_new(xkb_context_flags) -> *mut xkb_context, + fn xkb_context_ref(*mut xkb_context) -> *mut xkb_context, + fn xkb_context_unref(*mut xkb_context) -> (), + fn xkb_context_set_user_data(*mut xkb_context, *mut c_void) -> (), + fn xkb_context_get_user_data(*mut xkb_context) -> *mut c_void, + fn xkb_context_include_path_append(*mut xkb_context, *const c_char) -> c_int, + fn xkb_context_include_path_append_default(*mut xkb_context) -> c_int, + fn xkb_context_include_path_reset_defaults(*mut xkb_context) -> c_int, + fn xkb_context_include_path_clear(*mut xkb_context) -> (), + fn xkb_context_num_include_paths(*mut xkb_context) -> c_uint, + fn xkb_context_include_path_get(*mut xkb_context, c_uint) -> *const c_char, + fn xkb_context_set_log_level(*mut xkb_context, xkb_log_level) -> (), + fn xkb_context_get_log_level(*mut xkb_context) -> xkb_log_level, + fn xkb_context_set_log_verbosity(*mut xkb_context, c_int) -> (), + fn xkb_context_get_log_verbosity(*mut xkb_context) -> c_int, + fn xkb_keymap_new_from_names(*mut xkb_context, + *const xkb_rule_names, + xkb_keymap_compile_flags + ) -> *mut xkb_keymap, + fn xkb_keymap_new_from_string(*mut xkb_context, + *const c_char, + xkb_keymap_format, + xkb_keymap_compile_flags + ) -> *mut xkb_keymap, + fn xkb_keymap_new_from_buffer(*mut xkb_context, + *const c_char, + usize, + xkb_keymap_format, + xkb_keymap_compile_flags + ) -> *mut xkb_keymap, + fn xkb_keymap_ref(*mut xkb_keymap) -> *mut xkb_keymap, + fn xkb_keymap_unref(*mut xkb_keymap) -> (), + fn xkb_keymap_get_as_string(*mut xkb_keymap, xkb_keymap_format) -> *const c_char, + fn xkb_keymap_key_repeats(*mut xkb_keymap, xkb_keycode_t) -> c_int, + + fn xkb_state_new(*mut xkb_keymap) -> *mut xkb_state, + fn xkb_state_ref(*mut xkb_state) -> *mut xkb_state, + fn xkb_state_unref(*mut xkb_state) -> (), + fn xkb_state_update_mask(*mut xkb_state, + xkb_mod_mask_t, + xkb_mod_mask_t, + xkb_mod_mask_t, + xkb_layout_index_t, + xkb_layout_index_t, + xkb_layout_index_t + ) -> xkb_state_component, + fn xkb_state_update_key(*mut xkb_state, + xkb_keycode_t, + xkb_key_direction + ) -> xkb_state_component, + fn xkb_state_key_get_syms(*mut xkb_state, + xkb_keycode_t, + *const *mut xkb_keysym_t + ) -> c_int, + fn xkb_state_key_get_utf8(*mut xkb_state, + xkb_keycode_t, + *mut c_char, + usize + ) -> c_int, + fn xkb_state_key_get_utf32(*mut xkb_state, xkb_keycode_t) -> u32, + fn xkb_state_key_get_one_sym(*mut xkb_state, xkb_keycode_t) -> xkb_keysym_t, + fn xkb_state_mod_name_is_active(*mut xkb_state, *const c_char, xkb_state_component) -> c_int, + fn xkb_compose_table_new_from_locale(*mut xkb_context, *const c_char, xkb_compose_compile_flags) -> *mut xkb_compose_table, + fn xkb_compose_table_unref(*mut xkb_compose_table) -> (), + fn xkb_compose_state_new(*mut xkb_compose_table, xkb_compose_state_flags) -> *mut xkb_compose_state, + fn xkb_compose_state_unref(*mut xkb_compose_state) -> (), + fn xkb_compose_state_feed(*mut xkb_compose_state, xkb_keysym_t) -> xkb_compose_feed_result, + fn xkb_compose_state_reset(*mut xkb_compose_state) -> (), + fn xkb_compose_state_get_status(*mut xkb_compose_state) -> xkb_compose_status, + fn xkb_compose_state_get_utf8(*mut xkb_compose_state, *mut c_char, usize) -> c_int, + fn xkb_compose_state_get_one_sym(*mut xkb_compose_state) -> xkb_keysym_t, +); + +lazy_static!( + pub static ref XKBCOMMON_OPTION: Option<XkbCommon> = { + XkbCommon::open("libxkbcommon.so.0") + .or_else(|_| XkbCommon::open("libxkbcommon.so")) + .ok() + }; + pub static ref XKBCOMMON_HANDLE: &'static XkbCommon = { + XKBCOMMON_OPTION.as_ref().expect("Library libxkbcommon.so could not be loaded.") + }; +); diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/keyboard/keysyms.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/keyboard/keysyms.rs new file mode 100644 index 0000000..8b42e91 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/keyboard/keysyms.rs @@ -0,0 +1,2995 @@ +// +// This file was auto-generated using the update-keysyms.sh script. +// + +#![allow(missing_docs)] +#![allow(non_upper_case_globals)] +#![cfg_attr(rustfmt, rustfmt_skip)] + +/*********************************************************** +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +/* + * The "X11 Window System Protocol" standard defines in Appendix A the + * keysym codes. These 29-bit integer values identify characters or + * functions associated with each key (e.g., via the visible + * engraving) of a keyboard layout. This file assigns mnemonic macro + * names for these keysyms. + * + * This file is also compiled (by src/util/makekeys.c in libX11) into + * hash tables that can be accessed with X11 library functions such as + * XStringToKeysym() and XKeysymToString(). + * + * Where a keysym corresponds one-to-one to an ISO 10646 / Unicode + * character, this is noted in a comment that provides both the U+xxxx + * Unicode position, as well as the official Unicode name of the + * character. + * + * Where the correspondence is either not one-to-one or semantically + * unclear, the Unicode position and name are enclosed in + * parentheses. Such legacy keysyms should be considered deprecated + * and are not recommended for use in future keyboard mappings. + * + * For any future extension of the keysyms with characters already + * found in ISO 10646 / Unicode, the following algorithm shall be + * used. The new keysym code position will simply be the character's + * Unicode number plus :u32 = 0x01000000;. The keysym values in the range + * :u32 = 0x01000100; to :u32 = 0x0110ffff; are reserved to represent Unicode + * characters in the range U+0100 to U+10FFFF. + * + * While most newer Unicode-based X11 clients do already accept + * Unicode-mapped keysyms in the range :u32 = 0x01000100; to :u32 = 0x0110ffff;, it + * will remain necessary for clients -- in the interest of + * compatibility with existing servers -- to also understand the + * existing legacy keysym values in the range :u32 = 0x0100; to :u32 = 0x20ff;. + * + * Where several mnemonic names are defined for the same keysym in this + * file, all but the first one listed should be considered deprecated. + * + * Mnemonic names for keysyms are defined in this file with lines + * that match one of these Perl regular expressions: + * + * /^\pub const XKB_KEY_([a-zA-Z_0-9]+)\s+:u32 = 0x;([0-9a-f]+)\s*\/\* U+([0-9A-F]{4,6}) (.*) \*\/\s*$/ + * /^\pub const XKB_KEY_([a-zA-Z_0-9]+)\s+:u32 = 0x;([0-9a-f]+)\s*\/\*\(U+([0-9A-F]{4,6}) (.*)\)\*\/\s*$/ + * /^\pub const XKB_KEY_([a-zA-Z_0-9]+)\s+:u32 = 0x;([0-9a-f]+)\s*(\/\*\s*(.*)\s*\*\/)?\s*$/ + * + * Before adding new keysyms, please do consider the following: In + * addition to the keysym names defined in this file, the + * XStringToKeysym() and XKeysymToString() functions will also handle + * any keysym string of the form "U0020" to "U007E" and "U00A0" to + * "U10FFFF" for all possible Unicode characters. In other words, + * every possible Unicode character has already a keysym string + * defined algorithmically, even if it is not listed here. Therefore, + * defining an additional keysym macro is only necessary where a + * non-hexadecimal mnemonic name is needed, or where the new keysym + * does not represent any existing Unicode character. + * + * When adding new keysyms to this file, do not forget to also update the + * following as needed: + * + * - the mappings in src/KeyBind.c in the repo + * git://anongit.freedesktop.org/xorg/lib/libX11.git + * + * - the protocol specification in specs/keysyms.xml + * in the repo git://anongit.freedesktop.org/xorg/proto/x11proto.git + * + */ + +pub const XKB_KEY_VoidSymbol :u32 = 0xffffff; /* Void symbol */ + +/* + * TTY function keys, cleverly chosen to map to ASCII, for convenience of + * programming, but could have been arbitrary (at the cost of lookup + * tables in client code). + */ + +pub const XKB_KEY_BackSpace :u32 = 0xff08; /* Back space, back char */ +pub const XKB_KEY_Tab :u32 = 0xff09; +pub const XKB_KEY_Linefeed :u32 = 0xff0a; /* Linefeed, LF */ +pub const XKB_KEY_Clear :u32 = 0xff0b; +pub const XKB_KEY_Return :u32 = 0xff0d; /* Return, enter */ +pub const XKB_KEY_Pause :u32 = 0xff13; /* Pause, hold */ +pub const XKB_KEY_Scroll_Lock :u32 = 0xff14; +pub const XKB_KEY_Sys_Req :u32 = 0xff15; +pub const XKB_KEY_Escape :u32 = 0xff1b; +pub const XKB_KEY_Delete :u32 = 0xffff; /* Delete, rubout */ + + + +/* International & multi-key character composition */ + +pub const XKB_KEY_Multi_key :u32 = 0xff20; /* Multi-key character compose */ +pub const XKB_KEY_Codeinput :u32 = 0xff37; +pub const XKB_KEY_SingleCandidate :u32 = 0xff3c; +pub const XKB_KEY_MultipleCandidate :u32 = 0xff3d; +pub const XKB_KEY_PreviousCandidate :u32 = 0xff3e; + +/* Japanese keyboard support */ + +pub const XKB_KEY_Kanji :u32 = 0xff21; /* Kanji, Kanji convert */ +pub const XKB_KEY_Muhenkan :u32 = 0xff22; /* Cancel Conversion */ +pub const XKB_KEY_Henkan_Mode :u32 = 0xff23; /* Start/Stop Conversion */ +pub const XKB_KEY_Henkan :u32 = 0xff23; /* Alias for Henkan_Mode */ +pub const XKB_KEY_Romaji :u32 = 0xff24; /* to Romaji */ +pub const XKB_KEY_Hiragana :u32 = 0xff25; /* to Hiragana */ +pub const XKB_KEY_Katakana :u32 = 0xff26; /* to Katakana */ +pub const XKB_KEY_Hiragana_Katakana :u32 = 0xff27; /* Hiragana/Katakana toggle */ +pub const XKB_KEY_Zenkaku :u32 = 0xff28; /* to Zenkaku */ +pub const XKB_KEY_Hankaku :u32 = 0xff29; /* to Hankaku */ +pub const XKB_KEY_Zenkaku_Hankaku :u32 = 0xff2a; /* Zenkaku/Hankaku toggle */ +pub const XKB_KEY_Touroku :u32 = 0xff2b; /* Add to Dictionary */ +pub const XKB_KEY_Massyo :u32 = 0xff2c; /* Delete from Dictionary */ +pub const XKB_KEY_Kana_Lock :u32 = 0xff2d; /* Kana Lock */ +pub const XKB_KEY_Kana_Shift :u32 = 0xff2e; /* Kana Shift */ +pub const XKB_KEY_Eisu_Shift :u32 = 0xff2f; /* Alphanumeric Shift */ +pub const XKB_KEY_Eisu_toggle :u32 = 0xff30; /* Alphanumeric toggle */ +pub const XKB_KEY_Kanji_Bangou :u32 = 0xff37; /* Codeinput */ +pub const XKB_KEY_Zen_Koho :u32 = 0xff3d; /* Multiple/All Candidate(s) */ +pub const XKB_KEY_Mae_Koho :u32 = 0xff3e; /* Previous Candidate */ + +/* :u32 = 0xff31; thru :u32 = 0xff3f; are under XK_KOREAN */ + +/* Cursor control & motion */ + +pub const XKB_KEY_Home :u32 = 0xff50; +pub const XKB_KEY_Left :u32 = 0xff51; /* Move left, left arrow */ +pub const XKB_KEY_Up :u32 = 0xff52; /* Move up, up arrow */ +pub const XKB_KEY_Right :u32 = 0xff53; /* Move right, right arrow */ +pub const XKB_KEY_Down :u32 = 0xff54; /* Move down, down arrow */ +pub const XKB_KEY_Prior :u32 = 0xff55; /* Prior, previous */ +pub const XKB_KEY_Page_Up :u32 = 0xff55; +pub const XKB_KEY_Next :u32 = 0xff56; /* Next */ +pub const XKB_KEY_Page_Down :u32 = 0xff56; +pub const XKB_KEY_End :u32 = 0xff57; /* EOL */ +pub const XKB_KEY_Begin :u32 = 0xff58; /* BOL */ + + +/* Misc functions */ + +pub const XKB_KEY_Select :u32 = 0xff60; /* Select, mark */ +pub const XKB_KEY_Print :u32 = 0xff61; +pub const XKB_KEY_Execute :u32 = 0xff62; /* Execute, run, do */ +pub const XKB_KEY_Insert :u32 = 0xff63; /* Insert, insert here */ +pub const XKB_KEY_Undo :u32 = 0xff65; +pub const XKB_KEY_Redo :u32 = 0xff66; /* Redo, again */ +pub const XKB_KEY_Menu :u32 = 0xff67; +pub const XKB_KEY_Find :u32 = 0xff68; /* Find, search */ +pub const XKB_KEY_Cancel :u32 = 0xff69; /* Cancel, stop, abort, exit */ +pub const XKB_KEY_Help :u32 = 0xff6a; /* Help */ +pub const XKB_KEY_Break :u32 = 0xff6b; +pub const XKB_KEY_Mode_switch :u32 = 0xff7e; /* Character set switch */ +pub const XKB_KEY_script_switch :u32 = 0xff7e; /* Alias for mode_switch */ +pub const XKB_KEY_Num_Lock :u32 = 0xff7f; + +/* Keypad functions, keypad numbers cleverly chosen to map to ASCII */ + +pub const XKB_KEY_KP_Space :u32 = 0xff80; /* Space */ +pub const XKB_KEY_KP_Tab :u32 = 0xff89; +pub const XKB_KEY_KP_Enter :u32 = 0xff8d; /* Enter */ +pub const XKB_KEY_KP_F1 :u32 = 0xff91; /* PF1, KP_A, ... */ +pub const XKB_KEY_KP_F2 :u32 = 0xff92; +pub const XKB_KEY_KP_F3 :u32 = 0xff93; +pub const XKB_KEY_KP_F4 :u32 = 0xff94; +pub const XKB_KEY_KP_Home :u32 = 0xff95; +pub const XKB_KEY_KP_Left :u32 = 0xff96; +pub const XKB_KEY_KP_Up :u32 = 0xff97; +pub const XKB_KEY_KP_Right :u32 = 0xff98; +pub const XKB_KEY_KP_Down :u32 = 0xff99; +pub const XKB_KEY_KP_Prior :u32 = 0xff9a; +pub const XKB_KEY_KP_Page_Up :u32 = 0xff9a; +pub const XKB_KEY_KP_Next :u32 = 0xff9b; +pub const XKB_KEY_KP_Page_Down :u32 = 0xff9b; +pub const XKB_KEY_KP_End :u32 = 0xff9c; +pub const XKB_KEY_KP_Begin :u32 = 0xff9d; +pub const XKB_KEY_KP_Insert :u32 = 0xff9e; +pub const XKB_KEY_KP_Delete :u32 = 0xff9f; +pub const XKB_KEY_KP_Equal :u32 = 0xffbd; /* Equals */ +pub const XKB_KEY_KP_Multiply :u32 = 0xffaa; +pub const XKB_KEY_KP_Add :u32 = 0xffab; +pub const XKB_KEY_KP_Separator :u32 = 0xffac; /* Separator, often comma */ +pub const XKB_KEY_KP_Subtract :u32 = 0xffad; +pub const XKB_KEY_KP_Decimal :u32 = 0xffae; +pub const XKB_KEY_KP_Divide :u32 = 0xffaf; + +pub const XKB_KEY_KP_0 :u32 = 0xffb0; +pub const XKB_KEY_KP_1 :u32 = 0xffb1; +pub const XKB_KEY_KP_2 :u32 = 0xffb2; +pub const XKB_KEY_KP_3 :u32 = 0xffb3; +pub const XKB_KEY_KP_4 :u32 = 0xffb4; +pub const XKB_KEY_KP_5 :u32 = 0xffb5; +pub const XKB_KEY_KP_6 :u32 = 0xffb6; +pub const XKB_KEY_KP_7 :u32 = 0xffb7; +pub const XKB_KEY_KP_8 :u32 = 0xffb8; +pub const XKB_KEY_KP_9 :u32 = 0xffb9; + + + +/* + * Auxiliary functions; note the duplicate definitions for left and right + * function keys; Sun keyboards and a few other manufacturers have such + * function key groups on the left and/or right sides of the keyboard. + * We've not found a keyboard with more than 35 function keys total. + */ + +pub const XKB_KEY_F1 :u32 = 0xffbe; +pub const XKB_KEY_F2 :u32 = 0xffbf; +pub const XKB_KEY_F3 :u32 = 0xffc0; +pub const XKB_KEY_F4 :u32 = 0xffc1; +pub const XKB_KEY_F5 :u32 = 0xffc2; +pub const XKB_KEY_F6 :u32 = 0xffc3; +pub const XKB_KEY_F7 :u32 = 0xffc4; +pub const XKB_KEY_F8 :u32 = 0xffc5; +pub const XKB_KEY_F9 :u32 = 0xffc6; +pub const XKB_KEY_F10 :u32 = 0xffc7; +pub const XKB_KEY_F11 :u32 = 0xffc8; +pub const XKB_KEY_L1 :u32 = 0xffc8; +pub const XKB_KEY_F12 :u32 = 0xffc9; +pub const XKB_KEY_L2 :u32 = 0xffc9; +pub const XKB_KEY_F13 :u32 = 0xffca; +pub const XKB_KEY_L3 :u32 = 0xffca; +pub const XKB_KEY_F14 :u32 = 0xffcb; +pub const XKB_KEY_L4 :u32 = 0xffcb; +pub const XKB_KEY_F15 :u32 = 0xffcc; +pub const XKB_KEY_L5 :u32 = 0xffcc; +pub const XKB_KEY_F16 :u32 = 0xffcd; +pub const XKB_KEY_L6 :u32 = 0xffcd; +pub const XKB_KEY_F17 :u32 = 0xffce; +pub const XKB_KEY_L7 :u32 = 0xffce; +pub const XKB_KEY_F18 :u32 = 0xffcf; +pub const XKB_KEY_L8 :u32 = 0xffcf; +pub const XKB_KEY_F19 :u32 = 0xffd0; +pub const XKB_KEY_L9 :u32 = 0xffd0; +pub const XKB_KEY_F20 :u32 = 0xffd1; +pub const XKB_KEY_L10 :u32 = 0xffd1; +pub const XKB_KEY_F21 :u32 = 0xffd2; +pub const XKB_KEY_R1 :u32 = 0xffd2; +pub const XKB_KEY_F22 :u32 = 0xffd3; +pub const XKB_KEY_R2 :u32 = 0xffd3; +pub const XKB_KEY_F23 :u32 = 0xffd4; +pub const XKB_KEY_R3 :u32 = 0xffd4; +pub const XKB_KEY_F24 :u32 = 0xffd5; +pub const XKB_KEY_R4 :u32 = 0xffd5; +pub const XKB_KEY_F25 :u32 = 0xffd6; +pub const XKB_KEY_R5 :u32 = 0xffd6; +pub const XKB_KEY_F26 :u32 = 0xffd7; +pub const XKB_KEY_R6 :u32 = 0xffd7; +pub const XKB_KEY_F27 :u32 = 0xffd8; +pub const XKB_KEY_R7 :u32 = 0xffd8; +pub const XKB_KEY_F28 :u32 = 0xffd9; +pub const XKB_KEY_R8 :u32 = 0xffd9; +pub const XKB_KEY_F29 :u32 = 0xffda; +pub const XKB_KEY_R9 :u32 = 0xffda; +pub const XKB_KEY_F30 :u32 = 0xffdb; +pub const XKB_KEY_R10 :u32 = 0xffdb; +pub const XKB_KEY_F31 :u32 = 0xffdc; +pub const XKB_KEY_R11 :u32 = 0xffdc; +pub const XKB_KEY_F32 :u32 = 0xffdd; +pub const XKB_KEY_R12 :u32 = 0xffdd; +pub const XKB_KEY_F33 :u32 = 0xffde; +pub const XKB_KEY_R13 :u32 = 0xffde; +pub const XKB_KEY_F34 :u32 = 0xffdf; +pub const XKB_KEY_R14 :u32 = 0xffdf; +pub const XKB_KEY_F35 :u32 = 0xffe0; +pub const XKB_KEY_R15 :u32 = 0xffe0; + +/* Modifiers */ + +pub const XKB_KEY_Shift_L :u32 = 0xffe1; /* Left shift */ +pub const XKB_KEY_Shift_R :u32 = 0xffe2; /* Right shift */ +pub const XKB_KEY_Control_L :u32 = 0xffe3; /* Left control */ +pub const XKB_KEY_Control_R :u32 = 0xffe4; /* Right control */ +pub const XKB_KEY_Caps_Lock :u32 = 0xffe5; /* Caps lock */ +pub const XKB_KEY_Shift_Lock :u32 = 0xffe6; /* Shift lock */ + +pub const XKB_KEY_Meta_L :u32 = 0xffe7; /* Left meta */ +pub const XKB_KEY_Meta_R :u32 = 0xffe8; /* Right meta */ +pub const XKB_KEY_Alt_L :u32 = 0xffe9; /* Left alt */ +pub const XKB_KEY_Alt_R :u32 = 0xffea; /* Right alt */ +pub const XKB_KEY_Super_L :u32 = 0xffeb; /* Left super */ +pub const XKB_KEY_Super_R :u32 = 0xffec; /* Right super */ +pub const XKB_KEY_Hyper_L :u32 = 0xffed; /* Left hyper */ +pub const XKB_KEY_Hyper_R :u32 = 0xffee; /* Right hyper */ + +/* + * Keyboard (XKB) Extension function and modifier keys + * (from Appendix C of "The X Keyboard Extension: Protocol Specification") + * Byte 3 = :u32 = 0xfe; + */ + +pub const XKB_KEY_ISO_Lock :u32 = 0xfe01; +pub const XKB_KEY_ISO_Level2_Latch :u32 = 0xfe02; +pub const XKB_KEY_ISO_Level3_Shift :u32 = 0xfe03; +pub const XKB_KEY_ISO_Level3_Latch :u32 = 0xfe04; +pub const XKB_KEY_ISO_Level3_Lock :u32 = 0xfe05; +pub const XKB_KEY_ISO_Level5_Shift :u32 = 0xfe11; +pub const XKB_KEY_ISO_Level5_Latch :u32 = 0xfe12; +pub const XKB_KEY_ISO_Level5_Lock :u32 = 0xfe13; +pub const XKB_KEY_ISO_Group_Shift :u32 = 0xff7e; /* Alias for mode_switch */ +pub const XKB_KEY_ISO_Group_Latch :u32 = 0xfe06; +pub const XKB_KEY_ISO_Group_Lock :u32 = 0xfe07; +pub const XKB_KEY_ISO_Next_Group :u32 = 0xfe08; +pub const XKB_KEY_ISO_Next_Group_Lock :u32 = 0xfe09; +pub const XKB_KEY_ISO_Prev_Group :u32 = 0xfe0a; +pub const XKB_KEY_ISO_Prev_Group_Lock :u32 = 0xfe0b; +pub const XKB_KEY_ISO_First_Group :u32 = 0xfe0c; +pub const XKB_KEY_ISO_First_Group_Lock :u32 = 0xfe0d; +pub const XKB_KEY_ISO_Last_Group :u32 = 0xfe0e; +pub const XKB_KEY_ISO_Last_Group_Lock :u32 = 0xfe0f; + +pub const XKB_KEY_ISO_Left_Tab :u32 = 0xfe20; +pub const XKB_KEY_ISO_Move_Line_Up :u32 = 0xfe21; +pub const XKB_KEY_ISO_Move_Line_Down :u32 = 0xfe22; +pub const XKB_KEY_ISO_Partial_Line_Up :u32 = 0xfe23; +pub const XKB_KEY_ISO_Partial_Line_Down :u32 = 0xfe24; +pub const XKB_KEY_ISO_Partial_Space_Left :u32 = 0xfe25; +pub const XKB_KEY_ISO_Partial_Space_Right :u32 = 0xfe26; +pub const XKB_KEY_ISO_Set_Margin_Left :u32 = 0xfe27; +pub const XKB_KEY_ISO_Set_Margin_Right :u32 = 0xfe28; +pub const XKB_KEY_ISO_Release_Margin_Left :u32 = 0xfe29; +pub const XKB_KEY_ISO_Release_Margin_Right :u32 = 0xfe2a; +pub const XKB_KEY_ISO_Release_Both_Margins :u32 = 0xfe2b; +pub const XKB_KEY_ISO_Fast_Cursor_Left :u32 = 0xfe2c; +pub const XKB_KEY_ISO_Fast_Cursor_Right :u32 = 0xfe2d; +pub const XKB_KEY_ISO_Fast_Cursor_Up :u32 = 0xfe2e; +pub const XKB_KEY_ISO_Fast_Cursor_Down :u32 = 0xfe2f; +pub const XKB_KEY_ISO_Continuous_Underline :u32 = 0xfe30; +pub const XKB_KEY_ISO_Discontinuous_Underline :u32 = 0xfe31; +pub const XKB_KEY_ISO_Emphasize :u32 = 0xfe32; +pub const XKB_KEY_ISO_Center_Object :u32 = 0xfe33; +pub const XKB_KEY_ISO_Enter :u32 = 0xfe34; + +pub const XKB_KEY_dead_grave :u32 = 0xfe50; +pub const XKB_KEY_dead_acute :u32 = 0xfe51; +pub const XKB_KEY_dead_circumflex :u32 = 0xfe52; +pub const XKB_KEY_dead_tilde :u32 = 0xfe53; +pub const XKB_KEY_dead_perispomeni :u32 = 0xfe53; /* alias for dead_tilde */ +pub const XKB_KEY_dead_macron :u32 = 0xfe54; +pub const XKB_KEY_dead_breve :u32 = 0xfe55; +pub const XKB_KEY_dead_abovedot :u32 = 0xfe56; +pub const XKB_KEY_dead_diaeresis :u32 = 0xfe57; +pub const XKB_KEY_dead_abovering :u32 = 0xfe58; +pub const XKB_KEY_dead_doubleacute :u32 = 0xfe59; +pub const XKB_KEY_dead_caron :u32 = 0xfe5a; +pub const XKB_KEY_dead_cedilla :u32 = 0xfe5b; +pub const XKB_KEY_dead_ogonek :u32 = 0xfe5c; +pub const XKB_KEY_dead_iota :u32 = 0xfe5d; +pub const XKB_KEY_dead_voiced_sound :u32 = 0xfe5e; +pub const XKB_KEY_dead_semivoiced_sound :u32 = 0xfe5f; +pub const XKB_KEY_dead_belowdot :u32 = 0xfe60; +pub const XKB_KEY_dead_hook :u32 = 0xfe61; +pub const XKB_KEY_dead_horn :u32 = 0xfe62; +pub const XKB_KEY_dead_stroke :u32 = 0xfe63; +pub const XKB_KEY_dead_abovecomma :u32 = 0xfe64; +pub const XKB_KEY_dead_psili :u32 = 0xfe64; /* alias for dead_abovecomma */ +pub const XKB_KEY_dead_abovereversedcomma :u32 = 0xfe65; +pub const XKB_KEY_dead_dasia :u32 = 0xfe65; /* alias for dead_abovereversedcomma */ +pub const XKB_KEY_dead_doublegrave :u32 = 0xfe66; +pub const XKB_KEY_dead_belowring :u32 = 0xfe67; +pub const XKB_KEY_dead_belowmacron :u32 = 0xfe68; +pub const XKB_KEY_dead_belowcircumflex :u32 = 0xfe69; +pub const XKB_KEY_dead_belowtilde :u32 = 0xfe6a; +pub const XKB_KEY_dead_belowbreve :u32 = 0xfe6b; +pub const XKB_KEY_dead_belowdiaeresis :u32 = 0xfe6c; +pub const XKB_KEY_dead_invertedbreve :u32 = 0xfe6d; +pub const XKB_KEY_dead_belowcomma :u32 = 0xfe6e; +pub const XKB_KEY_dead_currency :u32 = 0xfe6f; + +/* extra dead elements for German T3 layout */ +pub const XKB_KEY_dead_lowline :u32 = 0xfe90; +pub const XKB_KEY_dead_aboveverticalline :u32 = 0xfe91; +pub const XKB_KEY_dead_belowverticalline :u32 = 0xfe92; +pub const XKB_KEY_dead_longsolidusoverlay :u32 = 0xfe93; + +/* dead vowels for universal syllable entry */ +pub const XKB_KEY_dead_a :u32 = 0xfe80; +pub const XKB_KEY_dead_A :u32 = 0xfe81; +pub const XKB_KEY_dead_e :u32 = 0xfe82; +pub const XKB_KEY_dead_E :u32 = 0xfe83; +pub const XKB_KEY_dead_i :u32 = 0xfe84; +pub const XKB_KEY_dead_I :u32 = 0xfe85; +pub const XKB_KEY_dead_o :u32 = 0xfe86; +pub const XKB_KEY_dead_O :u32 = 0xfe87; +pub const XKB_KEY_dead_u :u32 = 0xfe88; +pub const XKB_KEY_dead_U :u32 = 0xfe89; +pub const XKB_KEY_dead_small_schwa :u32 = 0xfe8a; +pub const XKB_KEY_dead_capital_schwa :u32 = 0xfe8b; + +pub const XKB_KEY_dead_greek :u32 = 0xfe8c; + +pub const XKB_KEY_First_Virtual_Screen :u32 = 0xfed0; +pub const XKB_KEY_Prev_Virtual_Screen :u32 = 0xfed1; +pub const XKB_KEY_Next_Virtual_Screen :u32 = 0xfed2; +pub const XKB_KEY_Last_Virtual_Screen :u32 = 0xfed4; +pub const XKB_KEY_Terminate_Server :u32 = 0xfed5; + +pub const XKB_KEY_AccessX_Enable :u32 = 0xfe70; +pub const XKB_KEY_AccessX_Feedback_Enable :u32 = 0xfe71; +pub const XKB_KEY_RepeatKeys_Enable :u32 = 0xfe72; +pub const XKB_KEY_SlowKeys_Enable :u32 = 0xfe73; +pub const XKB_KEY_BounceKeys_Enable :u32 = 0xfe74; +pub const XKB_KEY_StickyKeys_Enable :u32 = 0xfe75; +pub const XKB_KEY_MouseKeys_Enable :u32 = 0xfe76; +pub const XKB_KEY_MouseKeys_Accel_Enable :u32 = 0xfe77; +pub const XKB_KEY_Overlay1_Enable :u32 = 0xfe78; +pub const XKB_KEY_Overlay2_Enable :u32 = 0xfe79; +pub const XKB_KEY_AudibleBell_Enable :u32 = 0xfe7a; + +pub const XKB_KEY_Pointer_Left :u32 = 0xfee0; +pub const XKB_KEY_Pointer_Right :u32 = 0xfee1; +pub const XKB_KEY_Pointer_Up :u32 = 0xfee2; +pub const XKB_KEY_Pointer_Down :u32 = 0xfee3; +pub const XKB_KEY_Pointer_UpLeft :u32 = 0xfee4; +pub const XKB_KEY_Pointer_UpRight :u32 = 0xfee5; +pub const XKB_KEY_Pointer_DownLeft :u32 = 0xfee6; +pub const XKB_KEY_Pointer_DownRight :u32 = 0xfee7; +pub const XKB_KEY_Pointer_Button_Dflt :u32 = 0xfee8; +pub const XKB_KEY_Pointer_Button1 :u32 = 0xfee9; +pub const XKB_KEY_Pointer_Button2 :u32 = 0xfeea; +pub const XKB_KEY_Pointer_Button3 :u32 = 0xfeeb; +pub const XKB_KEY_Pointer_Button4 :u32 = 0xfeec; +pub const XKB_KEY_Pointer_Button5 :u32 = 0xfeed; +pub const XKB_KEY_Pointer_DblClick_Dflt :u32 = 0xfeee; +pub const XKB_KEY_Pointer_DblClick1 :u32 = 0xfeef; +pub const XKB_KEY_Pointer_DblClick2 :u32 = 0xfef0; +pub const XKB_KEY_Pointer_DblClick3 :u32 = 0xfef1; +pub const XKB_KEY_Pointer_DblClick4 :u32 = 0xfef2; +pub const XKB_KEY_Pointer_DblClick5 :u32 = 0xfef3; +pub const XKB_KEY_Pointer_Drag_Dflt :u32 = 0xfef4; +pub const XKB_KEY_Pointer_Drag1 :u32 = 0xfef5; +pub const XKB_KEY_Pointer_Drag2 :u32 = 0xfef6; +pub const XKB_KEY_Pointer_Drag3 :u32 = 0xfef7; +pub const XKB_KEY_Pointer_Drag4 :u32 = 0xfef8; +pub const XKB_KEY_Pointer_Drag5 :u32 = 0xfefd; + +pub const XKB_KEY_Pointer_EnableKeys :u32 = 0xfef9; +pub const XKB_KEY_Pointer_Accelerate :u32 = 0xfefa; +pub const XKB_KEY_Pointer_DfltBtnNext :u32 = 0xfefb; +pub const XKB_KEY_Pointer_DfltBtnPrev :u32 = 0xfefc; + +/* Single-Stroke Multiple-Character N-Graph Keysyms For The X Input Method */ + +pub const XKB_KEY_ch :u32 = 0xfea0; +pub const XKB_KEY_Ch :u32 = 0xfea1; +pub const XKB_KEY_CH :u32 = 0xfea2; +pub const XKB_KEY_c_h :u32 = 0xfea3; +pub const XKB_KEY_C_h :u32 = 0xfea4; +pub const XKB_KEY_C_H :u32 = 0xfea5; + + +/* + * 3270 Terminal Keys + * Byte 3 = :u32 = 0xfd; + */ + +pub const XKB_KEY_3270_Duplicate :u32 = 0xfd01; +pub const XKB_KEY_3270_FieldMark :u32 = 0xfd02; +pub const XKB_KEY_3270_Right2 :u32 = 0xfd03; +pub const XKB_KEY_3270_Left2 :u32 = 0xfd04; +pub const XKB_KEY_3270_BackTab :u32 = 0xfd05; +pub const XKB_KEY_3270_EraseEOF :u32 = 0xfd06; +pub const XKB_KEY_3270_EraseInput :u32 = 0xfd07; +pub const XKB_KEY_3270_Reset :u32 = 0xfd08; +pub const XKB_KEY_3270_Quit :u32 = 0xfd09; +pub const XKB_KEY_3270_PA1 :u32 = 0xfd0a; +pub const XKB_KEY_3270_PA2 :u32 = 0xfd0b; +pub const XKB_KEY_3270_PA3 :u32 = 0xfd0c; +pub const XKB_KEY_3270_Test :u32 = 0xfd0d; +pub const XKB_KEY_3270_Attn :u32 = 0xfd0e; +pub const XKB_KEY_3270_CursorBlink :u32 = 0xfd0f; +pub const XKB_KEY_3270_AltCursor :u32 = 0xfd10; +pub const XKB_KEY_3270_KeyClick :u32 = 0xfd11; +pub const XKB_KEY_3270_Jump :u32 = 0xfd12; +pub const XKB_KEY_3270_Ident :u32 = 0xfd13; +pub const XKB_KEY_3270_Rule :u32 = 0xfd14; +pub const XKB_KEY_3270_Copy :u32 = 0xfd15; +pub const XKB_KEY_3270_Play :u32 = 0xfd16; +pub const XKB_KEY_3270_Setup :u32 = 0xfd17; +pub const XKB_KEY_3270_Record :u32 = 0xfd18; +pub const XKB_KEY_3270_ChangeScreen :u32 = 0xfd19; +pub const XKB_KEY_3270_DeleteWord :u32 = 0xfd1a; +pub const XKB_KEY_3270_ExSelect :u32 = 0xfd1b; +pub const XKB_KEY_3270_CursorSelect :u32 = 0xfd1c; +pub const XKB_KEY_3270_PrintScreen :u32 = 0xfd1d; +pub const XKB_KEY_3270_Enter :u32 = 0xfd1e; + +/* + * Latin 1 + * (ISO/IEC 8859-1 = Unicode U+0020..U+00FF) + * Byte 3 = 0 + */ +pub const XKB_KEY_space :u32 = 0x0020; /* U+0020 SPACE */ +pub const XKB_KEY_exclam :u32 = 0x0021; /* U+0021 EXCLAMATION MARK */ +pub const XKB_KEY_quotedbl :u32 = 0x0022; /* U+0022 QUOTATION MARK */ +pub const XKB_KEY_numbersign :u32 = 0x0023; /* U+0023 NUMBER SIGN */ +pub const XKB_KEY_dollar :u32 = 0x0024; /* U+0024 DOLLAR SIGN */ +pub const XKB_KEY_percent :u32 = 0x0025; /* U+0025 PERCENT SIGN */ +pub const XKB_KEY_ampersand :u32 = 0x0026; /* U+0026 AMPERSAND */ +pub const XKB_KEY_apostrophe :u32 = 0x0027; /* U+0027 APOSTROPHE */ +pub const XKB_KEY_quoteright :u32 = 0x0027; /* deprecated */ +pub const XKB_KEY_parenleft :u32 = 0x0028; /* U+0028 LEFT PARENTHESIS */ +pub const XKB_KEY_parenright :u32 = 0x0029; /* U+0029 RIGHT PARENTHESIS */ +pub const XKB_KEY_asterisk :u32 = 0x002a; /* U+002A ASTERISK */ +pub const XKB_KEY_plus :u32 = 0x002b; /* U+002B PLUS SIGN */ +pub const XKB_KEY_comma :u32 = 0x002c; /* U+002C COMMA */ +pub const XKB_KEY_minus :u32 = 0x002d; /* U+002D HYPHEN-MINUS */ +pub const XKB_KEY_period :u32 = 0x002e; /* U+002E FULL STOP */ +pub const XKB_KEY_slash :u32 = 0x002f; /* U+002F SOLIDUS */ +pub const XKB_KEY_0 :u32 = 0x0030; /* U+0030 DIGIT ZERO */ +pub const XKB_KEY_1 :u32 = 0x0031; /* U+0031 DIGIT ONE */ +pub const XKB_KEY_2 :u32 = 0x0032; /* U+0032 DIGIT TWO */ +pub const XKB_KEY_3 :u32 = 0x0033; /* U+0033 DIGIT THREE */ +pub const XKB_KEY_4 :u32 = 0x0034; /* U+0034 DIGIT FOUR */ +pub const XKB_KEY_5 :u32 = 0x0035; /* U+0035 DIGIT FIVE */ +pub const XKB_KEY_6 :u32 = 0x0036; /* U+0036 DIGIT SIX */ +pub const XKB_KEY_7 :u32 = 0x0037; /* U+0037 DIGIT SEVEN */ +pub const XKB_KEY_8 :u32 = 0x0038; /* U+0038 DIGIT EIGHT */ +pub const XKB_KEY_9 :u32 = 0x0039; /* U+0039 DIGIT NINE */ +pub const XKB_KEY_colon :u32 = 0x003a; /* U+003A COLON */ +pub const XKB_KEY_semicolon :u32 = 0x003b; /* U+003B SEMICOLON */ +pub const XKB_KEY_less :u32 = 0x003c; /* U+003C LESS-THAN SIGN */ +pub const XKB_KEY_equal :u32 = 0x003d; /* U+003D EQUALS SIGN */ +pub const XKB_KEY_greater :u32 = 0x003e; /* U+003E GREATER-THAN SIGN */ +pub const XKB_KEY_question :u32 = 0x003f; /* U+003F QUESTION MARK */ +pub const XKB_KEY_at :u32 = 0x0040; /* U+0040 COMMERCIAL AT */ +pub const XKB_KEY_A :u32 = 0x0041; /* U+0041 LATIN CAPITAL LETTER A */ +pub const XKB_KEY_B :u32 = 0x0042; /* U+0042 LATIN CAPITAL LETTER B */ +pub const XKB_KEY_C :u32 = 0x0043; /* U+0043 LATIN CAPITAL LETTER C */ +pub const XKB_KEY_D :u32 = 0x0044; /* U+0044 LATIN CAPITAL LETTER D */ +pub const XKB_KEY_E :u32 = 0x0045; /* U+0045 LATIN CAPITAL LETTER E */ +pub const XKB_KEY_F :u32 = 0x0046; /* U+0046 LATIN CAPITAL LETTER F */ +pub const XKB_KEY_G :u32 = 0x0047; /* U+0047 LATIN CAPITAL LETTER G */ +pub const XKB_KEY_H :u32 = 0x0048; /* U+0048 LATIN CAPITAL LETTER H */ +pub const XKB_KEY_I :u32 = 0x0049; /* U+0049 LATIN CAPITAL LETTER I */ +pub const XKB_KEY_J :u32 = 0x004a; /* U+004A LATIN CAPITAL LETTER J */ +pub const XKB_KEY_K :u32 = 0x004b; /* U+004B LATIN CAPITAL LETTER K */ +pub const XKB_KEY_L :u32 = 0x004c; /* U+004C LATIN CAPITAL LETTER L */ +pub const XKB_KEY_M :u32 = 0x004d; /* U+004D LATIN CAPITAL LETTER M */ +pub const XKB_KEY_N :u32 = 0x004e; /* U+004E LATIN CAPITAL LETTER N */ +pub const XKB_KEY_O :u32 = 0x004f; /* U+004F LATIN CAPITAL LETTER O */ +pub const XKB_KEY_P :u32 = 0x0050; /* U+0050 LATIN CAPITAL LETTER P */ +pub const XKB_KEY_Q :u32 = 0x0051; /* U+0051 LATIN CAPITAL LETTER Q */ +pub const XKB_KEY_R :u32 = 0x0052; /* U+0052 LATIN CAPITAL LETTER R */ +pub const XKB_KEY_S :u32 = 0x0053; /* U+0053 LATIN CAPITAL LETTER S */ +pub const XKB_KEY_T :u32 = 0x0054; /* U+0054 LATIN CAPITAL LETTER T */ +pub const XKB_KEY_U :u32 = 0x0055; /* U+0055 LATIN CAPITAL LETTER U */ +pub const XKB_KEY_V :u32 = 0x0056; /* U+0056 LATIN CAPITAL LETTER V */ +pub const XKB_KEY_W :u32 = 0x0057; /* U+0057 LATIN CAPITAL LETTER W */ +pub const XKB_KEY_X :u32 = 0x0058; /* U+0058 LATIN CAPITAL LETTER X */ +pub const XKB_KEY_Y :u32 = 0x0059; /* U+0059 LATIN CAPITAL LETTER Y */ +pub const XKB_KEY_Z :u32 = 0x005a; /* U+005A LATIN CAPITAL LETTER Z */ +pub const XKB_KEY_bracketleft :u32 = 0x005b; /* U+005B LEFT SQUARE BRACKET */ +pub const XKB_KEY_backslash :u32 = 0x005c; /* U+005C REVERSE SOLIDUS */ +pub const XKB_KEY_bracketright :u32 = 0x005d; /* U+005D RIGHT SQUARE BRACKET */ +pub const XKB_KEY_asciicircum :u32 = 0x005e; /* U+005E CIRCUMFLEX ACCENT */ +pub const XKB_KEY_underscore :u32 = 0x005f; /* U+005F LOW LINE */ +pub const XKB_KEY_grave :u32 = 0x0060; /* U+0060 GRAVE ACCENT */ +pub const XKB_KEY_quoteleft :u32 = 0x0060; /* deprecated */ +pub const XKB_KEY_a :u32 = 0x0061; /* U+0061 LATIN SMALL LETTER A */ +pub const XKB_KEY_b :u32 = 0x0062; /* U+0062 LATIN SMALL LETTER B */ +pub const XKB_KEY_c :u32 = 0x0063; /* U+0063 LATIN SMALL LETTER C */ +pub const XKB_KEY_d :u32 = 0x0064; /* U+0064 LATIN SMALL LETTER D */ +pub const XKB_KEY_e :u32 = 0x0065; /* U+0065 LATIN SMALL LETTER E */ +pub const XKB_KEY_f :u32 = 0x0066; /* U+0066 LATIN SMALL LETTER F */ +pub const XKB_KEY_g :u32 = 0x0067; /* U+0067 LATIN SMALL LETTER G */ +pub const XKB_KEY_h :u32 = 0x0068; /* U+0068 LATIN SMALL LETTER H */ +pub const XKB_KEY_i :u32 = 0x0069; /* U+0069 LATIN SMALL LETTER I */ +pub const XKB_KEY_j :u32 = 0x006a; /* U+006A LATIN SMALL LETTER J */ +pub const XKB_KEY_k :u32 = 0x006b; /* U+006B LATIN SMALL LETTER K */ +pub const XKB_KEY_l :u32 = 0x006c; /* U+006C LATIN SMALL LETTER L */ +pub const XKB_KEY_m :u32 = 0x006d; /* U+006D LATIN SMALL LETTER M */ +pub const XKB_KEY_n :u32 = 0x006e; /* U+006E LATIN SMALL LETTER N */ +pub const XKB_KEY_o :u32 = 0x006f; /* U+006F LATIN SMALL LETTER O */ +pub const XKB_KEY_p :u32 = 0x0070; /* U+0070 LATIN SMALL LETTER P */ +pub const XKB_KEY_q :u32 = 0x0071; /* U+0071 LATIN SMALL LETTER Q */ +pub const XKB_KEY_r :u32 = 0x0072; /* U+0072 LATIN SMALL LETTER R */ +pub const XKB_KEY_s :u32 = 0x0073; /* U+0073 LATIN SMALL LETTER S */ +pub const XKB_KEY_t :u32 = 0x0074; /* U+0074 LATIN SMALL LETTER T */ +pub const XKB_KEY_u :u32 = 0x0075; /* U+0075 LATIN SMALL LETTER U */ +pub const XKB_KEY_v :u32 = 0x0076; /* U+0076 LATIN SMALL LETTER V */ +pub const XKB_KEY_w :u32 = 0x0077; /* U+0077 LATIN SMALL LETTER W */ +pub const XKB_KEY_x :u32 = 0x0078; /* U+0078 LATIN SMALL LETTER X */ +pub const XKB_KEY_y :u32 = 0x0079; /* U+0079 LATIN SMALL LETTER Y */ +pub const XKB_KEY_z :u32 = 0x007a; /* U+007A LATIN SMALL LETTER Z */ +pub const XKB_KEY_braceleft :u32 = 0x007b; /* U+007B LEFT CURLY BRACKET */ +pub const XKB_KEY_bar :u32 = 0x007c; /* U+007C VERTICAL LINE */ +pub const XKB_KEY_braceright :u32 = 0x007d; /* U+007D RIGHT CURLY BRACKET */ +pub const XKB_KEY_asciitilde :u32 = 0x007e; /* U+007E TILDE */ + +pub const XKB_KEY_nobreakspace :u32 = 0x00a0; /* U+00A0 NO-BREAK SPACE */ +pub const XKB_KEY_exclamdown :u32 = 0x00a1; /* U+00A1 INVERTED EXCLAMATION MARK */ +pub const XKB_KEY_cent :u32 = 0x00a2; /* U+00A2 CENT SIGN */ +pub const XKB_KEY_sterling :u32 = 0x00a3; /* U+00A3 POUND SIGN */ +pub const XKB_KEY_currency :u32 = 0x00a4; /* U+00A4 CURRENCY SIGN */ +pub const XKB_KEY_yen :u32 = 0x00a5; /* U+00A5 YEN SIGN */ +pub const XKB_KEY_brokenbar :u32 = 0x00a6; /* U+00A6 BROKEN BAR */ +pub const XKB_KEY_section :u32 = 0x00a7; /* U+00A7 SECTION SIGN */ +pub const XKB_KEY_diaeresis :u32 = 0x00a8; /* U+00A8 DIAERESIS */ +pub const XKB_KEY_copyright :u32 = 0x00a9; /* U+00A9 COPYRIGHT SIGN */ +pub const XKB_KEY_ordfeminine :u32 = 0x00aa; /* U+00AA FEMININE ORDINAL INDICATOR */ +pub const XKB_KEY_guillemotleft :u32 = 0x00ab; /* U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */ +pub const XKB_KEY_notsign :u32 = 0x00ac; /* U+00AC NOT SIGN */ +pub const XKB_KEY_hyphen :u32 = 0x00ad; /* U+00AD SOFT HYPHEN */ +pub const XKB_KEY_registered :u32 = 0x00ae; /* U+00AE REGISTERED SIGN */ +pub const XKB_KEY_macron :u32 = 0x00af; /* U+00AF MACRON */ +pub const XKB_KEY_degree :u32 = 0x00b0; /* U+00B0 DEGREE SIGN */ +pub const XKB_KEY_plusminus :u32 = 0x00b1; /* U+00B1 PLUS-MINUS SIGN */ +pub const XKB_KEY_twosuperior :u32 = 0x00b2; /* U+00B2 SUPERSCRIPT TWO */ +pub const XKB_KEY_threesuperior :u32 = 0x00b3; /* U+00B3 SUPERSCRIPT THREE */ +pub const XKB_KEY_acute :u32 = 0x00b4; /* U+00B4 ACUTE ACCENT */ +pub const XKB_KEY_mu :u32 = 0x00b5; /* U+00B5 MICRO SIGN */ +pub const XKB_KEY_paragraph :u32 = 0x00b6; /* U+00B6 PILCROW SIGN */ +pub const XKB_KEY_periodcentered :u32 = 0x00b7; /* U+00B7 MIDDLE DOT */ +pub const XKB_KEY_cedilla :u32 = 0x00b8; /* U+00B8 CEDILLA */ +pub const XKB_KEY_onesuperior :u32 = 0x00b9; /* U+00B9 SUPERSCRIPT ONE */ +pub const XKB_KEY_masculine :u32 = 0x00ba; /* U+00BA MASCULINE ORDINAL INDICATOR */ +pub const XKB_KEY_guillemotright :u32 = 0x00bb; /* U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */ +pub const XKB_KEY_onequarter :u32 = 0x00bc; /* U+00BC VULGAR FRACTION ONE QUARTER */ +pub const XKB_KEY_onehalf :u32 = 0x00bd; /* U+00BD VULGAR FRACTION ONE HALF */ +pub const XKB_KEY_threequarters :u32 = 0x00be; /* U+00BE VULGAR FRACTION THREE QUARTERS */ +pub const XKB_KEY_questiondown :u32 = 0x00bf; /* U+00BF INVERTED QUESTION MARK */ +pub const XKB_KEY_Agrave :u32 = 0x00c0; /* U+00C0 LATIN CAPITAL LETTER A WITH GRAVE */ +pub const XKB_KEY_Aacute :u32 = 0x00c1; /* U+00C1 LATIN CAPITAL LETTER A WITH ACUTE */ +pub const XKB_KEY_Acircumflex :u32 = 0x00c2; /* U+00C2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX */ +pub const XKB_KEY_Atilde :u32 = 0x00c3; /* U+00C3 LATIN CAPITAL LETTER A WITH TILDE */ +pub const XKB_KEY_Adiaeresis :u32 = 0x00c4; /* U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS */ +pub const XKB_KEY_Aring :u32 = 0x00c5; /* U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE */ +pub const XKB_KEY_AE :u32 = 0x00c6; /* U+00C6 LATIN CAPITAL LETTER AE */ +pub const XKB_KEY_Ccedilla :u32 = 0x00c7; /* U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA */ +pub const XKB_KEY_Egrave :u32 = 0x00c8; /* U+00C8 LATIN CAPITAL LETTER E WITH GRAVE */ +pub const XKB_KEY_Eacute :u32 = 0x00c9; /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ +pub const XKB_KEY_Ecircumflex :u32 = 0x00ca; /* U+00CA LATIN CAPITAL LETTER E WITH CIRCUMFLEX */ +pub const XKB_KEY_Ediaeresis :u32 = 0x00cb; /* U+00CB LATIN CAPITAL LETTER E WITH DIAERESIS */ +pub const XKB_KEY_Igrave :u32 = 0x00cc; /* U+00CC LATIN CAPITAL LETTER I WITH GRAVE */ +pub const XKB_KEY_Iacute :u32 = 0x00cd; /* U+00CD LATIN CAPITAL LETTER I WITH ACUTE */ +pub const XKB_KEY_Icircumflex :u32 = 0x00ce; /* U+00CE LATIN CAPITAL LETTER I WITH CIRCUMFLEX */ +pub const XKB_KEY_Idiaeresis :u32 = 0x00cf; /* U+00CF LATIN CAPITAL LETTER I WITH DIAERESIS */ +pub const XKB_KEY_ETH :u32 = 0x00d0; /* U+00D0 LATIN CAPITAL LETTER ETH */ +pub const XKB_KEY_Eth :u32 = 0x00d0; /* deprecated */ +pub const XKB_KEY_Ntilde :u32 = 0x00d1; /* U+00D1 LATIN CAPITAL LETTER N WITH TILDE */ +pub const XKB_KEY_Ograve :u32 = 0x00d2; /* U+00D2 LATIN CAPITAL LETTER O WITH GRAVE */ +pub const XKB_KEY_Oacute :u32 = 0x00d3; /* U+00D3 LATIN CAPITAL LETTER O WITH ACUTE */ +pub const XKB_KEY_Ocircumflex :u32 = 0x00d4; /* U+00D4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX */ +pub const XKB_KEY_Otilde :u32 = 0x00d5; /* U+00D5 LATIN CAPITAL LETTER O WITH TILDE */ +pub const XKB_KEY_Odiaeresis :u32 = 0x00d6; /* U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS */ +pub const XKB_KEY_multiply :u32 = 0x00d7; /* U+00D7 MULTIPLICATION SIGN */ +pub const XKB_KEY_Oslash :u32 = 0x00d8; /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ +pub const XKB_KEY_Ooblique :u32 = 0x00d8; /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ +pub const XKB_KEY_Ugrave :u32 = 0x00d9; /* U+00D9 LATIN CAPITAL LETTER U WITH GRAVE */ +pub const XKB_KEY_Uacute :u32 = 0x00da; /* U+00DA LATIN CAPITAL LETTER U WITH ACUTE */ +pub const XKB_KEY_Ucircumflex :u32 = 0x00db; /* U+00DB LATIN CAPITAL LETTER U WITH CIRCUMFLEX */ +pub const XKB_KEY_Udiaeresis :u32 = 0x00dc; /* U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS */ +pub const XKB_KEY_Yacute :u32 = 0x00dd; /* U+00DD LATIN CAPITAL LETTER Y WITH ACUTE */ +pub const XKB_KEY_THORN :u32 = 0x00de; /* U+00DE LATIN CAPITAL LETTER THORN */ +pub const XKB_KEY_Thorn :u32 = 0x00de; /* deprecated */ +pub const XKB_KEY_ssharp :u32 = 0x00df; /* U+00DF LATIN SMALL LETTER SHARP S */ +pub const XKB_KEY_agrave :u32 = 0x00e0; /* U+00E0 LATIN SMALL LETTER A WITH GRAVE */ +pub const XKB_KEY_aacute :u32 = 0x00e1; /* U+00E1 LATIN SMALL LETTER A WITH ACUTE */ +pub const XKB_KEY_acircumflex :u32 = 0x00e2; /* U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX */ +pub const XKB_KEY_atilde :u32 = 0x00e3; /* U+00E3 LATIN SMALL LETTER A WITH TILDE */ +pub const XKB_KEY_adiaeresis :u32 = 0x00e4; /* U+00E4 LATIN SMALL LETTER A WITH DIAERESIS */ +pub const XKB_KEY_aring :u32 = 0x00e5; /* U+00E5 LATIN SMALL LETTER A WITH RING ABOVE */ +pub const XKB_KEY_ae :u32 = 0x00e6; /* U+00E6 LATIN SMALL LETTER AE */ +pub const XKB_KEY_ccedilla :u32 = 0x00e7; /* U+00E7 LATIN SMALL LETTER C WITH CEDILLA */ +pub const XKB_KEY_egrave :u32 = 0x00e8; /* U+00E8 LATIN SMALL LETTER E WITH GRAVE */ +pub const XKB_KEY_eacute :u32 = 0x00e9; /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ +pub const XKB_KEY_ecircumflex :u32 = 0x00ea; /* U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX */ +pub const XKB_KEY_ediaeresis :u32 = 0x00eb; /* U+00EB LATIN SMALL LETTER E WITH DIAERESIS */ +pub const XKB_KEY_igrave :u32 = 0x00ec; /* U+00EC LATIN SMALL LETTER I WITH GRAVE */ +pub const XKB_KEY_iacute :u32 = 0x00ed; /* U+00ED LATIN SMALL LETTER I WITH ACUTE */ +pub const XKB_KEY_icircumflex :u32 = 0x00ee; /* U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX */ +pub const XKB_KEY_idiaeresis :u32 = 0x00ef; /* U+00EF LATIN SMALL LETTER I WITH DIAERESIS */ +pub const XKB_KEY_eth :u32 = 0x00f0; /* U+00F0 LATIN SMALL LETTER ETH */ +pub const XKB_KEY_ntilde :u32 = 0x00f1; /* U+00F1 LATIN SMALL LETTER N WITH TILDE */ +pub const XKB_KEY_ograve :u32 = 0x00f2; /* U+00F2 LATIN SMALL LETTER O WITH GRAVE */ +pub const XKB_KEY_oacute :u32 = 0x00f3; /* U+00F3 LATIN SMALL LETTER O WITH ACUTE */ +pub const XKB_KEY_ocircumflex :u32 = 0x00f4; /* U+00F4 LATIN SMALL LETTER O WITH CIRCUMFLEX */ +pub const XKB_KEY_otilde :u32 = 0x00f5; /* U+00F5 LATIN SMALL LETTER O WITH TILDE */ +pub const XKB_KEY_odiaeresis :u32 = 0x00f6; /* U+00F6 LATIN SMALL LETTER O WITH DIAERESIS */ +pub const XKB_KEY_division :u32 = 0x00f7; /* U+00F7 DIVISION SIGN */ +pub const XKB_KEY_oslash :u32 = 0x00f8; /* U+00F8 LATIN SMALL LETTER O WITH STROKE */ +pub const XKB_KEY_ooblique :u32 = 0x00f8; /* U+00F8 LATIN SMALL LETTER O WITH STROKE */ +pub const XKB_KEY_ugrave :u32 = 0x00f9; /* U+00F9 LATIN SMALL LETTER U WITH GRAVE */ +pub const XKB_KEY_uacute :u32 = 0x00fa; /* U+00FA LATIN SMALL LETTER U WITH ACUTE */ +pub const XKB_KEY_ucircumflex :u32 = 0x00fb; /* U+00FB LATIN SMALL LETTER U WITH CIRCUMFLEX */ +pub const XKB_KEY_udiaeresis :u32 = 0x00fc; /* U+00FC LATIN SMALL LETTER U WITH DIAERESIS */ +pub const XKB_KEY_yacute :u32 = 0x00fd; /* U+00FD LATIN SMALL LETTER Y WITH ACUTE */ +pub const XKB_KEY_thorn :u32 = 0x00fe; /* U+00FE LATIN SMALL LETTER THORN */ +pub const XKB_KEY_ydiaeresis :u32 = 0x00ff; /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + +/* + * Latin 2 + * Byte 3 = 1 + */ + +pub const XKB_KEY_Aogonek :u32 = 0x01a1; /* U+0104 LATIN CAPITAL LETTER A WITH OGONEK */ +pub const XKB_KEY_breve :u32 = 0x01a2; /* U+02D8 BREVE */ +pub const XKB_KEY_Lstroke :u32 = 0x01a3; /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ +pub const XKB_KEY_Lcaron :u32 = 0x01a5; /* U+013D LATIN CAPITAL LETTER L WITH CARON */ +pub const XKB_KEY_Sacute :u32 = 0x01a6; /* U+015A LATIN CAPITAL LETTER S WITH ACUTE */ +pub const XKB_KEY_Scaron :u32 = 0x01a9; /* U+0160 LATIN CAPITAL LETTER S WITH CARON */ +pub const XKB_KEY_Scedilla :u32 = 0x01aa; /* U+015E LATIN CAPITAL LETTER S WITH CEDILLA */ +pub const XKB_KEY_Tcaron :u32 = 0x01ab; /* U+0164 LATIN CAPITAL LETTER T WITH CARON */ +pub const XKB_KEY_Zacute :u32 = 0x01ac; /* U+0179 LATIN CAPITAL LETTER Z WITH ACUTE */ +pub const XKB_KEY_Zcaron :u32 = 0x01ae; /* U+017D LATIN CAPITAL LETTER Z WITH CARON */ +pub const XKB_KEY_Zabovedot :u32 = 0x01af; /* U+017B LATIN CAPITAL LETTER Z WITH DOT ABOVE */ +pub const XKB_KEY_aogonek :u32 = 0x01b1; /* U+0105 LATIN SMALL LETTER A WITH OGONEK */ +pub const XKB_KEY_ogonek :u32 = 0x01b2; /* U+02DB OGONEK */ +pub const XKB_KEY_lstroke :u32 = 0x01b3; /* U+0142 LATIN SMALL LETTER L WITH STROKE */ +pub const XKB_KEY_lcaron :u32 = 0x01b5; /* U+013E LATIN SMALL LETTER L WITH CARON */ +pub const XKB_KEY_sacute :u32 = 0x01b6; /* U+015B LATIN SMALL LETTER S WITH ACUTE */ +pub const XKB_KEY_caron :u32 = 0x01b7; /* U+02C7 CARON */ +pub const XKB_KEY_scaron :u32 = 0x01b9; /* U+0161 LATIN SMALL LETTER S WITH CARON */ +pub const XKB_KEY_scedilla :u32 = 0x01ba; /* U+015F LATIN SMALL LETTER S WITH CEDILLA */ +pub const XKB_KEY_tcaron :u32 = 0x01bb; /* U+0165 LATIN SMALL LETTER T WITH CARON */ +pub const XKB_KEY_zacute :u32 = 0x01bc; /* U+017A LATIN SMALL LETTER Z WITH ACUTE */ +pub const XKB_KEY_doubleacute :u32 = 0x01bd; /* U+02DD DOUBLE ACUTE ACCENT */ +pub const XKB_KEY_zcaron :u32 = 0x01be; /* U+017E LATIN SMALL LETTER Z WITH CARON */ +pub const XKB_KEY_zabovedot :u32 = 0x01bf; /* U+017C LATIN SMALL LETTER Z WITH DOT ABOVE */ +pub const XKB_KEY_Racute :u32 = 0x01c0; /* U+0154 LATIN CAPITAL LETTER R WITH ACUTE */ +pub const XKB_KEY_Abreve :u32 = 0x01c3; /* U+0102 LATIN CAPITAL LETTER A WITH BREVE */ +pub const XKB_KEY_Lacute :u32 = 0x01c5; /* U+0139 LATIN CAPITAL LETTER L WITH ACUTE */ +pub const XKB_KEY_Cacute :u32 = 0x01c6; /* U+0106 LATIN CAPITAL LETTER C WITH ACUTE */ +pub const XKB_KEY_Ccaron :u32 = 0x01c8; /* U+010C LATIN CAPITAL LETTER C WITH CARON */ +pub const XKB_KEY_Eogonek :u32 = 0x01ca; /* U+0118 LATIN CAPITAL LETTER E WITH OGONEK */ +pub const XKB_KEY_Ecaron :u32 = 0x01cc; /* U+011A LATIN CAPITAL LETTER E WITH CARON */ +pub const XKB_KEY_Dcaron :u32 = 0x01cf; /* U+010E LATIN CAPITAL LETTER D WITH CARON */ +pub const XKB_KEY_Dstroke :u32 = 0x01d0; /* U+0110 LATIN CAPITAL LETTER D WITH STROKE */ +pub const XKB_KEY_Nacute :u32 = 0x01d1; /* U+0143 LATIN CAPITAL LETTER N WITH ACUTE */ +pub const XKB_KEY_Ncaron :u32 = 0x01d2; /* U+0147 LATIN CAPITAL LETTER N WITH CARON */ +pub const XKB_KEY_Odoubleacute :u32 = 0x01d5; /* U+0150 LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */ +pub const XKB_KEY_Rcaron :u32 = 0x01d8; /* U+0158 LATIN CAPITAL LETTER R WITH CARON */ +pub const XKB_KEY_Uring :u32 = 0x01d9; /* U+016E LATIN CAPITAL LETTER U WITH RING ABOVE */ +pub const XKB_KEY_Udoubleacute :u32 = 0x01db; /* U+0170 LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */ +pub const XKB_KEY_Tcedilla :u32 = 0x01de; /* U+0162 LATIN CAPITAL LETTER T WITH CEDILLA */ +pub const XKB_KEY_racute :u32 = 0x01e0; /* U+0155 LATIN SMALL LETTER R WITH ACUTE */ +pub const XKB_KEY_abreve :u32 = 0x01e3; /* U+0103 LATIN SMALL LETTER A WITH BREVE */ +pub const XKB_KEY_lacute :u32 = 0x01e5; /* U+013A LATIN SMALL LETTER L WITH ACUTE */ +pub const XKB_KEY_cacute :u32 = 0x01e6; /* U+0107 LATIN SMALL LETTER C WITH ACUTE */ +pub const XKB_KEY_ccaron :u32 = 0x01e8; /* U+010D LATIN SMALL LETTER C WITH CARON */ +pub const XKB_KEY_eogonek :u32 = 0x01ea; /* U+0119 LATIN SMALL LETTER E WITH OGONEK */ +pub const XKB_KEY_ecaron :u32 = 0x01ec; /* U+011B LATIN SMALL LETTER E WITH CARON */ +pub const XKB_KEY_dcaron :u32 = 0x01ef; /* U+010F LATIN SMALL LETTER D WITH CARON */ +pub const XKB_KEY_dstroke :u32 = 0x01f0; /* U+0111 LATIN SMALL LETTER D WITH STROKE */ +pub const XKB_KEY_nacute :u32 = 0x01f1; /* U+0144 LATIN SMALL LETTER N WITH ACUTE */ +pub const XKB_KEY_ncaron :u32 = 0x01f2; /* U+0148 LATIN SMALL LETTER N WITH CARON */ +pub const XKB_KEY_odoubleacute :u32 = 0x01f5; /* U+0151 LATIN SMALL LETTER O WITH DOUBLE ACUTE */ +pub const XKB_KEY_rcaron :u32 = 0x01f8; /* U+0159 LATIN SMALL LETTER R WITH CARON */ +pub const XKB_KEY_uring :u32 = 0x01f9; /* U+016F LATIN SMALL LETTER U WITH RING ABOVE */ +pub const XKB_KEY_udoubleacute :u32 = 0x01fb; /* U+0171 LATIN SMALL LETTER U WITH DOUBLE ACUTE */ +pub const XKB_KEY_tcedilla :u32 = 0x01fe; /* U+0163 LATIN SMALL LETTER T WITH CEDILLA */ +pub const XKB_KEY_abovedot :u32 = 0x01ff; /* U+02D9 DOT ABOVE */ + +/* + * Latin 3 + * Byte 3 = 2 + */ + +pub const XKB_KEY_Hstroke :u32 = 0x02a1; /* U+0126 LATIN CAPITAL LETTER H WITH STROKE */ +pub const XKB_KEY_Hcircumflex :u32 = 0x02a6; /* U+0124 LATIN CAPITAL LETTER H WITH CIRCUMFLEX */ +pub const XKB_KEY_Iabovedot :u32 = 0x02a9; /* U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE */ +pub const XKB_KEY_Gbreve :u32 = 0x02ab; /* U+011E LATIN CAPITAL LETTER G WITH BREVE */ +pub const XKB_KEY_Jcircumflex :u32 = 0x02ac; /* U+0134 LATIN CAPITAL LETTER J WITH CIRCUMFLEX */ +pub const XKB_KEY_hstroke :u32 = 0x02b1; /* U+0127 LATIN SMALL LETTER H WITH STROKE */ +pub const XKB_KEY_hcircumflex :u32 = 0x02b6; /* U+0125 LATIN SMALL LETTER H WITH CIRCUMFLEX */ +pub const XKB_KEY_idotless :u32 = 0x02b9; /* U+0131 LATIN SMALL LETTER DOTLESS I */ +pub const XKB_KEY_gbreve :u32 = 0x02bb; /* U+011F LATIN SMALL LETTER G WITH BREVE */ +pub const XKB_KEY_jcircumflex :u32 = 0x02bc; /* U+0135 LATIN SMALL LETTER J WITH CIRCUMFLEX */ +pub const XKB_KEY_Cabovedot :u32 = 0x02c5; /* U+010A LATIN CAPITAL LETTER C WITH DOT ABOVE */ +pub const XKB_KEY_Ccircumflex :u32 = 0x02c6; /* U+0108 LATIN CAPITAL LETTER C WITH CIRCUMFLEX */ +pub const XKB_KEY_Gabovedot :u32 = 0x02d5; /* U+0120 LATIN CAPITAL LETTER G WITH DOT ABOVE */ +pub const XKB_KEY_Gcircumflex :u32 = 0x02d8; /* U+011C LATIN CAPITAL LETTER G WITH CIRCUMFLEX */ +pub const XKB_KEY_Ubreve :u32 = 0x02dd; /* U+016C LATIN CAPITAL LETTER U WITH BREVE */ +pub const XKB_KEY_Scircumflex :u32 = 0x02de; /* U+015C LATIN CAPITAL LETTER S WITH CIRCUMFLEX */ +pub const XKB_KEY_cabovedot :u32 = 0x02e5; /* U+010B LATIN SMALL LETTER C WITH DOT ABOVE */ +pub const XKB_KEY_ccircumflex :u32 = 0x02e6; /* U+0109 LATIN SMALL LETTER C WITH CIRCUMFLEX */ +pub const XKB_KEY_gabovedot :u32 = 0x02f5; /* U+0121 LATIN SMALL LETTER G WITH DOT ABOVE */ +pub const XKB_KEY_gcircumflex :u32 = 0x02f8; /* U+011D LATIN SMALL LETTER G WITH CIRCUMFLEX */ +pub const XKB_KEY_ubreve :u32 = 0x02fd; /* U+016D LATIN SMALL LETTER U WITH BREVE */ +pub const XKB_KEY_scircumflex :u32 = 0x02fe; /* U+015D LATIN SMALL LETTER S WITH CIRCUMFLEX */ + + +/* + * Latin 4 + * Byte 3 = 3 + */ + +pub const XKB_KEY_kra :u32 = 0x03a2; /* U+0138 LATIN SMALL LETTER KRA */ +pub const XKB_KEY_kappa :u32 = 0x03a2; /* deprecated */ +pub const XKB_KEY_Rcedilla :u32 = 0x03a3; /* U+0156 LATIN CAPITAL LETTER R WITH CEDILLA */ +pub const XKB_KEY_Itilde :u32 = 0x03a5; /* U+0128 LATIN CAPITAL LETTER I WITH TILDE */ +pub const XKB_KEY_Lcedilla :u32 = 0x03a6; /* U+013B LATIN CAPITAL LETTER L WITH CEDILLA */ +pub const XKB_KEY_Emacron :u32 = 0x03aa; /* U+0112 LATIN CAPITAL LETTER E WITH MACRON */ +pub const XKB_KEY_Gcedilla :u32 = 0x03ab; /* U+0122 LATIN CAPITAL LETTER G WITH CEDILLA */ +pub const XKB_KEY_Tslash :u32 = 0x03ac; /* U+0166 LATIN CAPITAL LETTER T WITH STROKE */ +pub const XKB_KEY_rcedilla :u32 = 0x03b3; /* U+0157 LATIN SMALL LETTER R WITH CEDILLA */ +pub const XKB_KEY_itilde :u32 = 0x03b5; /* U+0129 LATIN SMALL LETTER I WITH TILDE */ +pub const XKB_KEY_lcedilla :u32 = 0x03b6; /* U+013C LATIN SMALL LETTER L WITH CEDILLA */ +pub const XKB_KEY_emacron :u32 = 0x03ba; /* U+0113 LATIN SMALL LETTER E WITH MACRON */ +pub const XKB_KEY_gcedilla :u32 = 0x03bb; /* U+0123 LATIN SMALL LETTER G WITH CEDILLA */ +pub const XKB_KEY_tslash :u32 = 0x03bc; /* U+0167 LATIN SMALL LETTER T WITH STROKE */ +pub const XKB_KEY_ENG :u32 = 0x03bd; /* U+014A LATIN CAPITAL LETTER ENG */ +pub const XKB_KEY_eng :u32 = 0x03bf; /* U+014B LATIN SMALL LETTER ENG */ +pub const XKB_KEY_Amacron :u32 = 0x03c0; /* U+0100 LATIN CAPITAL LETTER A WITH MACRON */ +pub const XKB_KEY_Iogonek :u32 = 0x03c7; /* U+012E LATIN CAPITAL LETTER I WITH OGONEK */ +pub const XKB_KEY_Eabovedot :u32 = 0x03cc; /* U+0116 LATIN CAPITAL LETTER E WITH DOT ABOVE */ +pub const XKB_KEY_Imacron :u32 = 0x03cf; /* U+012A LATIN CAPITAL LETTER I WITH MACRON */ +pub const XKB_KEY_Ncedilla :u32 = 0x03d1; /* U+0145 LATIN CAPITAL LETTER N WITH CEDILLA */ +pub const XKB_KEY_Omacron :u32 = 0x03d2; /* U+014C LATIN CAPITAL LETTER O WITH MACRON */ +pub const XKB_KEY_Kcedilla :u32 = 0x03d3; /* U+0136 LATIN CAPITAL LETTER K WITH CEDILLA */ +pub const XKB_KEY_Uogonek :u32 = 0x03d9; /* U+0172 LATIN CAPITAL LETTER U WITH OGONEK */ +pub const XKB_KEY_Utilde :u32 = 0x03dd; /* U+0168 LATIN CAPITAL LETTER U WITH TILDE */ +pub const XKB_KEY_Umacron :u32 = 0x03de; /* U+016A LATIN CAPITAL LETTER U WITH MACRON */ +pub const XKB_KEY_amacron :u32 = 0x03e0; /* U+0101 LATIN SMALL LETTER A WITH MACRON */ +pub const XKB_KEY_iogonek :u32 = 0x03e7; /* U+012F LATIN SMALL LETTER I WITH OGONEK */ +pub const XKB_KEY_eabovedot :u32 = 0x03ec; /* U+0117 LATIN SMALL LETTER E WITH DOT ABOVE */ +pub const XKB_KEY_imacron :u32 = 0x03ef; /* U+012B LATIN SMALL LETTER I WITH MACRON */ +pub const XKB_KEY_ncedilla :u32 = 0x03f1; /* U+0146 LATIN SMALL LETTER N WITH CEDILLA */ +pub const XKB_KEY_omacron :u32 = 0x03f2; /* U+014D LATIN SMALL LETTER O WITH MACRON */ +pub const XKB_KEY_kcedilla :u32 = 0x03f3; /* U+0137 LATIN SMALL LETTER K WITH CEDILLA */ +pub const XKB_KEY_uogonek :u32 = 0x03f9; /* U+0173 LATIN SMALL LETTER U WITH OGONEK */ +pub const XKB_KEY_utilde :u32 = 0x03fd; /* U+0169 LATIN SMALL LETTER U WITH TILDE */ +pub const XKB_KEY_umacron :u32 = 0x03fe; /* U+016B LATIN SMALL LETTER U WITH MACRON */ + +/* + * Latin 8 + */ +pub const XKB_KEY_Wcircumflex :u32 = 0x1000174; /* U+0174 LATIN CAPITAL LETTER W WITH CIRCUMFLEX */ +pub const XKB_KEY_wcircumflex :u32 = 0x1000175; /* U+0175 LATIN SMALL LETTER W WITH CIRCUMFLEX */ +pub const XKB_KEY_Ycircumflex :u32 = 0x1000176; /* U+0176 LATIN CAPITAL LETTER Y WITH CIRCUMFLEX */ +pub const XKB_KEY_ycircumflex :u32 = 0x1000177; /* U+0177 LATIN SMALL LETTER Y WITH CIRCUMFLEX */ +pub const XKB_KEY_Babovedot :u32 = 0x1001e02; /* U+1E02 LATIN CAPITAL LETTER B WITH DOT ABOVE */ +pub const XKB_KEY_babovedot :u32 = 0x1001e03; /* U+1E03 LATIN SMALL LETTER B WITH DOT ABOVE */ +pub const XKB_KEY_Dabovedot :u32 = 0x1001e0a; /* U+1E0A LATIN CAPITAL LETTER D WITH DOT ABOVE */ +pub const XKB_KEY_dabovedot :u32 = 0x1001e0b; /* U+1E0B LATIN SMALL LETTER D WITH DOT ABOVE */ +pub const XKB_KEY_Fabovedot :u32 = 0x1001e1e; /* U+1E1E LATIN CAPITAL LETTER F WITH DOT ABOVE */ +pub const XKB_KEY_fabovedot :u32 = 0x1001e1f; /* U+1E1F LATIN SMALL LETTER F WITH DOT ABOVE */ +pub const XKB_KEY_Mabovedot :u32 = 0x1001e40; /* U+1E40 LATIN CAPITAL LETTER M WITH DOT ABOVE */ +pub const XKB_KEY_mabovedot :u32 = 0x1001e41; /* U+1E41 LATIN SMALL LETTER M WITH DOT ABOVE */ +pub const XKB_KEY_Pabovedot :u32 = 0x1001e56; /* U+1E56 LATIN CAPITAL LETTER P WITH DOT ABOVE */ +pub const XKB_KEY_pabovedot :u32 = 0x1001e57; /* U+1E57 LATIN SMALL LETTER P WITH DOT ABOVE */ +pub const XKB_KEY_Sabovedot :u32 = 0x1001e60; /* U+1E60 LATIN CAPITAL LETTER S WITH DOT ABOVE */ +pub const XKB_KEY_sabovedot :u32 = 0x1001e61; /* U+1E61 LATIN SMALL LETTER S WITH DOT ABOVE */ +pub const XKB_KEY_Tabovedot :u32 = 0x1001e6a; /* U+1E6A LATIN CAPITAL LETTER T WITH DOT ABOVE */ +pub const XKB_KEY_tabovedot :u32 = 0x1001e6b; /* U+1E6B LATIN SMALL LETTER T WITH DOT ABOVE */ +pub const XKB_KEY_Wgrave :u32 = 0x1001e80; /* U+1E80 LATIN CAPITAL LETTER W WITH GRAVE */ +pub const XKB_KEY_wgrave :u32 = 0x1001e81; /* U+1E81 LATIN SMALL LETTER W WITH GRAVE */ +pub const XKB_KEY_Wacute :u32 = 0x1001e82; /* U+1E82 LATIN CAPITAL LETTER W WITH ACUTE */ +pub const XKB_KEY_wacute :u32 = 0x1001e83; /* U+1E83 LATIN SMALL LETTER W WITH ACUTE */ +pub const XKB_KEY_Wdiaeresis :u32 = 0x1001e84; /* U+1E84 LATIN CAPITAL LETTER W WITH DIAERESIS */ +pub const XKB_KEY_wdiaeresis :u32 = 0x1001e85; /* U+1E85 LATIN SMALL LETTER W WITH DIAERESIS */ +pub const XKB_KEY_Ygrave :u32 = 0x1001ef2; /* U+1EF2 LATIN CAPITAL LETTER Y WITH GRAVE */ +pub const XKB_KEY_ygrave :u32 = 0x1001ef3; /* U+1EF3 LATIN SMALL LETTER Y WITH GRAVE */ + +/* + * Latin 9 + * Byte 3 = :u32 = 0x13; + */ + +pub const XKB_KEY_OE :u32 = 0x13bc; /* U+0152 LATIN CAPITAL LIGATURE OE */ +pub const XKB_KEY_oe :u32 = 0x13bd; /* U+0153 LATIN SMALL LIGATURE OE */ +pub const XKB_KEY_Ydiaeresis :u32 = 0x13be; /* U+0178 LATIN CAPITAL LETTER Y WITH DIAERESIS */ + +/* + * Katakana + * Byte 3 = 4 + */ + +pub const XKB_KEY_overline :u32 = 0x047e; /* U+203E OVERLINE */ +pub const XKB_KEY_kana_fullstop :u32 = 0x04a1; /* U+3002 IDEOGRAPHIC FULL STOP */ +pub const XKB_KEY_kana_openingbracket :u32 = 0x04a2; /* U+300C LEFT CORNER BRACKET */ +pub const XKB_KEY_kana_closingbracket :u32 = 0x04a3; /* U+300D RIGHT CORNER BRACKET */ +pub const XKB_KEY_kana_comma :u32 = 0x04a4; /* U+3001 IDEOGRAPHIC COMMA */ +pub const XKB_KEY_kana_conjunctive :u32 = 0x04a5; /* U+30FB KATAKANA MIDDLE DOT */ +pub const XKB_KEY_kana_middledot :u32 = 0x04a5; /* deprecated */ +pub const XKB_KEY_kana_WO :u32 = 0x04a6; /* U+30F2 KATAKANA LETTER WO */ +pub const XKB_KEY_kana_a :u32 = 0x04a7; /* U+30A1 KATAKANA LETTER SMALL A */ +pub const XKB_KEY_kana_i :u32 = 0x04a8; /* U+30A3 KATAKANA LETTER SMALL I */ +pub const XKB_KEY_kana_u :u32 = 0x04a9; /* U+30A5 KATAKANA LETTER SMALL U */ +pub const XKB_KEY_kana_e :u32 = 0x04aa; /* U+30A7 KATAKANA LETTER SMALL E */ +pub const XKB_KEY_kana_o :u32 = 0x04ab; /* U+30A9 KATAKANA LETTER SMALL O */ +pub const XKB_KEY_kana_ya :u32 = 0x04ac; /* U+30E3 KATAKANA LETTER SMALL YA */ +pub const XKB_KEY_kana_yu :u32 = 0x04ad; /* U+30E5 KATAKANA LETTER SMALL YU */ +pub const XKB_KEY_kana_yo :u32 = 0x04ae; /* U+30E7 KATAKANA LETTER SMALL YO */ +pub const XKB_KEY_kana_tsu :u32 = 0x04af; /* U+30C3 KATAKANA LETTER SMALL TU */ +pub const XKB_KEY_kana_tu :u32 = 0x04af; /* deprecated */ +pub const XKB_KEY_prolongedsound :u32 = 0x04b0; /* U+30FC KATAKANA-HIRAGANA PROLONGED SOUND MARK */ +pub const XKB_KEY_kana_A :u32 = 0x04b1; /* U+30A2 KATAKANA LETTER A */ +pub const XKB_KEY_kana_I :u32 = 0x04b2; /* U+30A4 KATAKANA LETTER I */ +pub const XKB_KEY_kana_U :u32 = 0x04b3; /* U+30A6 KATAKANA LETTER U */ +pub const XKB_KEY_kana_E :u32 = 0x04b4; /* U+30A8 KATAKANA LETTER E */ +pub const XKB_KEY_kana_O :u32 = 0x04b5; /* U+30AA KATAKANA LETTER O */ +pub const XKB_KEY_kana_KA :u32 = 0x04b6; /* U+30AB KATAKANA LETTER KA */ +pub const XKB_KEY_kana_KI :u32 = 0x04b7; /* U+30AD KATAKANA LETTER KI */ +pub const XKB_KEY_kana_KU :u32 = 0x04b8; /* U+30AF KATAKANA LETTER KU */ +pub const XKB_KEY_kana_KE :u32 = 0x04b9; /* U+30B1 KATAKANA LETTER KE */ +pub const XKB_KEY_kana_KO :u32 = 0x04ba; /* U+30B3 KATAKANA LETTER KO */ +pub const XKB_KEY_kana_SA :u32 = 0x04bb; /* U+30B5 KATAKANA LETTER SA */ +pub const XKB_KEY_kana_SHI :u32 = 0x04bc; /* U+30B7 KATAKANA LETTER SI */ +pub const XKB_KEY_kana_SU :u32 = 0x04bd; /* U+30B9 KATAKANA LETTER SU */ +pub const XKB_KEY_kana_SE :u32 = 0x04be; /* U+30BB KATAKANA LETTER SE */ +pub const XKB_KEY_kana_SO :u32 = 0x04bf; /* U+30BD KATAKANA LETTER SO */ +pub const XKB_KEY_kana_TA :u32 = 0x04c0; /* U+30BF KATAKANA LETTER TA */ +pub const XKB_KEY_kana_CHI :u32 = 0x04c1; /* U+30C1 KATAKANA LETTER TI */ +pub const XKB_KEY_kana_TI :u32 = 0x04c1; /* deprecated */ +pub const XKB_KEY_kana_TSU :u32 = 0x04c2; /* U+30C4 KATAKANA LETTER TU */ +pub const XKB_KEY_kana_TU :u32 = 0x04c2; /* deprecated */ +pub const XKB_KEY_kana_TE :u32 = 0x04c3; /* U+30C6 KATAKANA LETTER TE */ +pub const XKB_KEY_kana_TO :u32 = 0x04c4; /* U+30C8 KATAKANA LETTER TO */ +pub const XKB_KEY_kana_NA :u32 = 0x04c5; /* U+30CA KATAKANA LETTER NA */ +pub const XKB_KEY_kana_NI :u32 = 0x04c6; /* U+30CB KATAKANA LETTER NI */ +pub const XKB_KEY_kana_NU :u32 = 0x04c7; /* U+30CC KATAKANA LETTER NU */ +pub const XKB_KEY_kana_NE :u32 = 0x04c8; /* U+30CD KATAKANA LETTER NE */ +pub const XKB_KEY_kana_NO :u32 = 0x04c9; /* U+30CE KATAKANA LETTER NO */ +pub const XKB_KEY_kana_HA :u32 = 0x04ca; /* U+30CF KATAKANA LETTER HA */ +pub const XKB_KEY_kana_HI :u32 = 0x04cb; /* U+30D2 KATAKANA LETTER HI */ +pub const XKB_KEY_kana_FU :u32 = 0x04cc; /* U+30D5 KATAKANA LETTER HU */ +pub const XKB_KEY_kana_HU :u32 = 0x04cc; /* deprecated */ +pub const XKB_KEY_kana_HE :u32 = 0x04cd; /* U+30D8 KATAKANA LETTER HE */ +pub const XKB_KEY_kana_HO :u32 = 0x04ce; /* U+30DB KATAKANA LETTER HO */ +pub const XKB_KEY_kana_MA :u32 = 0x04cf; /* U+30DE KATAKANA LETTER MA */ +pub const XKB_KEY_kana_MI :u32 = 0x04d0; /* U+30DF KATAKANA LETTER MI */ +pub const XKB_KEY_kana_MU :u32 = 0x04d1; /* U+30E0 KATAKANA LETTER MU */ +pub const XKB_KEY_kana_ME :u32 = 0x04d2; /* U+30E1 KATAKANA LETTER ME */ +pub const XKB_KEY_kana_MO :u32 = 0x04d3; /* U+30E2 KATAKANA LETTER MO */ +pub const XKB_KEY_kana_YA :u32 = 0x04d4; /* U+30E4 KATAKANA LETTER YA */ +pub const XKB_KEY_kana_YU :u32 = 0x04d5; /* U+30E6 KATAKANA LETTER YU */ +pub const XKB_KEY_kana_YO :u32 = 0x04d6; /* U+30E8 KATAKANA LETTER YO */ +pub const XKB_KEY_kana_RA :u32 = 0x04d7; /* U+30E9 KATAKANA LETTER RA */ +pub const XKB_KEY_kana_RI :u32 = 0x04d8; /* U+30EA KATAKANA LETTER RI */ +pub const XKB_KEY_kana_RU :u32 = 0x04d9; /* U+30EB KATAKANA LETTER RU */ +pub const XKB_KEY_kana_RE :u32 = 0x04da; /* U+30EC KATAKANA LETTER RE */ +pub const XKB_KEY_kana_RO :u32 = 0x04db; /* U+30ED KATAKANA LETTER RO */ +pub const XKB_KEY_kana_WA :u32 = 0x04dc; /* U+30EF KATAKANA LETTER WA */ +pub const XKB_KEY_kana_N :u32 = 0x04dd; /* U+30F3 KATAKANA LETTER N */ +pub const XKB_KEY_voicedsound :u32 = 0x04de; /* U+309B KATAKANA-HIRAGANA VOICED SOUND MARK */ +pub const XKB_KEY_semivoicedsound :u32 = 0x04df; /* U+309C KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK */ +pub const XKB_KEY_kana_switch :u32 = 0xff7e; /* Alias for mode_switch */ + +/* + * Arabic + * Byte 3 = 5 + */ + +pub const XKB_KEY_Farsi_0 :u32 = 0x10006f0; /* U+06F0 EXTENDED ARABIC-INDIC DIGIT ZERO */ +pub const XKB_KEY_Farsi_1 :u32 = 0x10006f1; /* U+06F1 EXTENDED ARABIC-INDIC DIGIT ONE */ +pub const XKB_KEY_Farsi_2 :u32 = 0x10006f2; /* U+06F2 EXTENDED ARABIC-INDIC DIGIT TWO */ +pub const XKB_KEY_Farsi_3 :u32 = 0x10006f3; /* U+06F3 EXTENDED ARABIC-INDIC DIGIT THREE */ +pub const XKB_KEY_Farsi_4 :u32 = 0x10006f4; /* U+06F4 EXTENDED ARABIC-INDIC DIGIT FOUR */ +pub const XKB_KEY_Farsi_5 :u32 = 0x10006f5; /* U+06F5 EXTENDED ARABIC-INDIC DIGIT FIVE */ +pub const XKB_KEY_Farsi_6 :u32 = 0x10006f6; /* U+06F6 EXTENDED ARABIC-INDIC DIGIT SIX */ +pub const XKB_KEY_Farsi_7 :u32 = 0x10006f7; /* U+06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN */ +pub const XKB_KEY_Farsi_8 :u32 = 0x10006f8; /* U+06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT */ +pub const XKB_KEY_Farsi_9 :u32 = 0x10006f9; /* U+06F9 EXTENDED ARABIC-INDIC DIGIT NINE */ +pub const XKB_KEY_Arabic_percent :u32 = 0x100066a; /* U+066A ARABIC PERCENT SIGN */ +pub const XKB_KEY_Arabic_superscript_alef :u32 = 0x1000670; /* U+0670 ARABIC LETTER SUPERSCRIPT ALEF */ +pub const XKB_KEY_Arabic_tteh :u32 = 0x1000679; /* U+0679 ARABIC LETTER TTEH */ +pub const XKB_KEY_Arabic_peh :u32 = 0x100067e; /* U+067E ARABIC LETTER PEH */ +pub const XKB_KEY_Arabic_tcheh :u32 = 0x1000686; /* U+0686 ARABIC LETTER TCHEH */ +pub const XKB_KEY_Arabic_ddal :u32 = 0x1000688; /* U+0688 ARABIC LETTER DDAL */ +pub const XKB_KEY_Arabic_rreh :u32 = 0x1000691; /* U+0691 ARABIC LETTER RREH */ +pub const XKB_KEY_Arabic_comma :u32 = 0x05ac; /* U+060C ARABIC COMMA */ +pub const XKB_KEY_Arabic_fullstop :u32 = 0x10006d4; /* U+06D4 ARABIC FULL STOP */ +pub const XKB_KEY_Arabic_0 :u32 = 0x1000660; /* U+0660 ARABIC-INDIC DIGIT ZERO */ +pub const XKB_KEY_Arabic_1 :u32 = 0x1000661; /* U+0661 ARABIC-INDIC DIGIT ONE */ +pub const XKB_KEY_Arabic_2 :u32 = 0x1000662; /* U+0662 ARABIC-INDIC DIGIT TWO */ +pub const XKB_KEY_Arabic_3 :u32 = 0x1000663; /* U+0663 ARABIC-INDIC DIGIT THREE */ +pub const XKB_KEY_Arabic_4 :u32 = 0x1000664; /* U+0664 ARABIC-INDIC DIGIT FOUR */ +pub const XKB_KEY_Arabic_5 :u32 = 0x1000665; /* U+0665 ARABIC-INDIC DIGIT FIVE */ +pub const XKB_KEY_Arabic_6 :u32 = 0x1000666; /* U+0666 ARABIC-INDIC DIGIT SIX */ +pub const XKB_KEY_Arabic_7 :u32 = 0x1000667; /* U+0667 ARABIC-INDIC DIGIT SEVEN */ +pub const XKB_KEY_Arabic_8 :u32 = 0x1000668; /* U+0668 ARABIC-INDIC DIGIT EIGHT */ +pub const XKB_KEY_Arabic_9 :u32 = 0x1000669; /* U+0669 ARABIC-INDIC DIGIT NINE */ +pub const XKB_KEY_Arabic_semicolon :u32 = 0x05bb; /* U+061B ARABIC SEMICOLON */ +pub const XKB_KEY_Arabic_question_mark :u32 = 0x05bf; /* U+061F ARABIC QUESTION MARK */ +pub const XKB_KEY_Arabic_hamza :u32 = 0x05c1; /* U+0621 ARABIC LETTER HAMZA */ +pub const XKB_KEY_Arabic_maddaonalef :u32 = 0x05c2; /* U+0622 ARABIC LETTER ALEF WITH MADDA ABOVE */ +pub const XKB_KEY_Arabic_hamzaonalef :u32 = 0x05c3; /* U+0623 ARABIC LETTER ALEF WITH HAMZA ABOVE */ +pub const XKB_KEY_Arabic_hamzaonwaw :u32 = 0x05c4; /* U+0624 ARABIC LETTER WAW WITH HAMZA ABOVE */ +pub const XKB_KEY_Arabic_hamzaunderalef :u32 = 0x05c5; /* U+0625 ARABIC LETTER ALEF WITH HAMZA BELOW */ +pub const XKB_KEY_Arabic_hamzaonyeh :u32 = 0x05c6; /* U+0626 ARABIC LETTER YEH WITH HAMZA ABOVE */ +pub const XKB_KEY_Arabic_alef :u32 = 0x05c7; /* U+0627 ARABIC LETTER ALEF */ +pub const XKB_KEY_Arabic_beh :u32 = 0x05c8; /* U+0628 ARABIC LETTER BEH */ +pub const XKB_KEY_Arabic_tehmarbuta :u32 = 0x05c9; /* U+0629 ARABIC LETTER TEH MARBUTA */ +pub const XKB_KEY_Arabic_teh :u32 = 0x05ca; /* U+062A ARABIC LETTER TEH */ +pub const XKB_KEY_Arabic_theh :u32 = 0x05cb; /* U+062B ARABIC LETTER THEH */ +pub const XKB_KEY_Arabic_jeem :u32 = 0x05cc; /* U+062C ARABIC LETTER JEEM */ +pub const XKB_KEY_Arabic_hah :u32 = 0x05cd; /* U+062D ARABIC LETTER HAH */ +pub const XKB_KEY_Arabic_khah :u32 = 0x05ce; /* U+062E ARABIC LETTER KHAH */ +pub const XKB_KEY_Arabic_dal :u32 = 0x05cf; /* U+062F ARABIC LETTER DAL */ +pub const XKB_KEY_Arabic_thal :u32 = 0x05d0; /* U+0630 ARABIC LETTER THAL */ +pub const XKB_KEY_Arabic_ra :u32 = 0x05d1; /* U+0631 ARABIC LETTER REH */ +pub const XKB_KEY_Arabic_zain :u32 = 0x05d2; /* U+0632 ARABIC LETTER ZAIN */ +pub const XKB_KEY_Arabic_seen :u32 = 0x05d3; /* U+0633 ARABIC LETTER SEEN */ +pub const XKB_KEY_Arabic_sheen :u32 = 0x05d4; /* U+0634 ARABIC LETTER SHEEN */ +pub const XKB_KEY_Arabic_sad :u32 = 0x05d5; /* U+0635 ARABIC LETTER SAD */ +pub const XKB_KEY_Arabic_dad :u32 = 0x05d6; /* U+0636 ARABIC LETTER DAD */ +pub const XKB_KEY_Arabic_tah :u32 = 0x05d7; /* U+0637 ARABIC LETTER TAH */ +pub const XKB_KEY_Arabic_zah :u32 = 0x05d8; /* U+0638 ARABIC LETTER ZAH */ +pub const XKB_KEY_Arabic_ain :u32 = 0x05d9; /* U+0639 ARABIC LETTER AIN */ +pub const XKB_KEY_Arabic_ghain :u32 = 0x05da; /* U+063A ARABIC LETTER GHAIN */ +pub const XKB_KEY_Arabic_tatweel :u32 = 0x05e0; /* U+0640 ARABIC TATWEEL */ +pub const XKB_KEY_Arabic_feh :u32 = 0x05e1; /* U+0641 ARABIC LETTER FEH */ +pub const XKB_KEY_Arabic_qaf :u32 = 0x05e2; /* U+0642 ARABIC LETTER QAF */ +pub const XKB_KEY_Arabic_kaf :u32 = 0x05e3; /* U+0643 ARABIC LETTER KAF */ +pub const XKB_KEY_Arabic_lam :u32 = 0x05e4; /* U+0644 ARABIC LETTER LAM */ +pub const XKB_KEY_Arabic_meem :u32 = 0x05e5; /* U+0645 ARABIC LETTER MEEM */ +pub const XKB_KEY_Arabic_noon :u32 = 0x05e6; /* U+0646 ARABIC LETTER NOON */ +pub const XKB_KEY_Arabic_ha :u32 = 0x05e7; /* U+0647 ARABIC LETTER HEH */ +pub const XKB_KEY_Arabic_heh :u32 = 0x05e7; /* deprecated */ +pub const XKB_KEY_Arabic_waw :u32 = 0x05e8; /* U+0648 ARABIC LETTER WAW */ +pub const XKB_KEY_Arabic_alefmaksura :u32 = 0x05e9; /* U+0649 ARABIC LETTER ALEF MAKSURA */ +pub const XKB_KEY_Arabic_yeh :u32 = 0x05ea; /* U+064A ARABIC LETTER YEH */ +pub const XKB_KEY_Arabic_fathatan :u32 = 0x05eb; /* U+064B ARABIC FATHATAN */ +pub const XKB_KEY_Arabic_dammatan :u32 = 0x05ec; /* U+064C ARABIC DAMMATAN */ +pub const XKB_KEY_Arabic_kasratan :u32 = 0x05ed; /* U+064D ARABIC KASRATAN */ +pub const XKB_KEY_Arabic_fatha :u32 = 0x05ee; /* U+064E ARABIC FATHA */ +pub const XKB_KEY_Arabic_damma :u32 = 0x05ef; /* U+064F ARABIC DAMMA */ +pub const XKB_KEY_Arabic_kasra :u32 = 0x05f0; /* U+0650 ARABIC KASRA */ +pub const XKB_KEY_Arabic_shadda :u32 = 0x05f1; /* U+0651 ARABIC SHADDA */ +pub const XKB_KEY_Arabic_sukun :u32 = 0x05f2; /* U+0652 ARABIC SUKUN */ +pub const XKB_KEY_Arabic_madda_above :u32 = 0x1000653; /* U+0653 ARABIC MADDAH ABOVE */ +pub const XKB_KEY_Arabic_hamza_above :u32 = 0x1000654; /* U+0654 ARABIC HAMZA ABOVE */ +pub const XKB_KEY_Arabic_hamza_below :u32 = 0x1000655; /* U+0655 ARABIC HAMZA BELOW */ +pub const XKB_KEY_Arabic_jeh :u32 = 0x1000698; /* U+0698 ARABIC LETTER JEH */ +pub const XKB_KEY_Arabic_veh :u32 = 0x10006a4; /* U+06A4 ARABIC LETTER VEH */ +pub const XKB_KEY_Arabic_keheh :u32 = 0x10006a9; /* U+06A9 ARABIC LETTER KEHEH */ +pub const XKB_KEY_Arabic_gaf :u32 = 0x10006af; /* U+06AF ARABIC LETTER GAF */ +pub const XKB_KEY_Arabic_noon_ghunna :u32 = 0x10006ba; /* U+06BA ARABIC LETTER NOON GHUNNA */ +pub const XKB_KEY_Arabic_heh_doachashmee :u32 = 0x10006be; /* U+06BE ARABIC LETTER HEH DOACHASHMEE */ +pub const XKB_KEY_Farsi_yeh :u32 = 0x10006cc; /* U+06CC ARABIC LETTER FARSI YEH */ +pub const XKB_KEY_Arabic_farsi_yeh :u32 = 0x10006cc; /* U+06CC ARABIC LETTER FARSI YEH */ +pub const XKB_KEY_Arabic_yeh_baree :u32 = 0x10006d2; /* U+06D2 ARABIC LETTER YEH BARREE */ +pub const XKB_KEY_Arabic_heh_goal :u32 = 0x10006c1; /* U+06C1 ARABIC LETTER HEH GOAL */ +pub const XKB_KEY_Arabic_switch :u32 = 0xff7e; /* Alias for mode_switch */ + +/* + * Cyrillic + * Byte 3 = 6 + */ +pub const XKB_KEY_Cyrillic_GHE_bar :u32 = 0x1000492; /* U+0492 CYRILLIC CAPITAL LETTER GHE WITH STROKE */ +pub const XKB_KEY_Cyrillic_ghe_bar :u32 = 0x1000493; /* U+0493 CYRILLIC SMALL LETTER GHE WITH STROKE */ +pub const XKB_KEY_Cyrillic_ZHE_descender :u32 = 0x1000496; /* U+0496 CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER */ +pub const XKB_KEY_Cyrillic_zhe_descender :u32 = 0x1000497; /* U+0497 CYRILLIC SMALL LETTER ZHE WITH DESCENDER */ +pub const XKB_KEY_Cyrillic_KA_descender :u32 = 0x100049a; /* U+049A CYRILLIC CAPITAL LETTER KA WITH DESCENDER */ +pub const XKB_KEY_Cyrillic_ka_descender :u32 = 0x100049b; /* U+049B CYRILLIC SMALL LETTER KA WITH DESCENDER */ +pub const XKB_KEY_Cyrillic_KA_vertstroke :u32 = 0x100049c; /* U+049C CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE */ +pub const XKB_KEY_Cyrillic_ka_vertstroke :u32 = 0x100049d; /* U+049D CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE */ +pub const XKB_KEY_Cyrillic_EN_descender :u32 = 0x10004a2; /* U+04A2 CYRILLIC CAPITAL LETTER EN WITH DESCENDER */ +pub const XKB_KEY_Cyrillic_en_descender :u32 = 0x10004a3; /* U+04A3 CYRILLIC SMALL LETTER EN WITH DESCENDER */ +pub const XKB_KEY_Cyrillic_U_straight :u32 = 0x10004ae; /* U+04AE CYRILLIC CAPITAL LETTER STRAIGHT U */ +pub const XKB_KEY_Cyrillic_u_straight :u32 = 0x10004af; /* U+04AF CYRILLIC SMALL LETTER STRAIGHT U */ +pub const XKB_KEY_Cyrillic_U_straight_bar :u32 = 0x10004b0; /* U+04B0 CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE */ +pub const XKB_KEY_Cyrillic_u_straight_bar :u32 = 0x10004b1; /* U+04B1 CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE */ +pub const XKB_KEY_Cyrillic_HA_descender :u32 = 0x10004b2; /* U+04B2 CYRILLIC CAPITAL LETTER HA WITH DESCENDER */ +pub const XKB_KEY_Cyrillic_ha_descender :u32 = 0x10004b3; /* U+04B3 CYRILLIC SMALL LETTER HA WITH DESCENDER */ +pub const XKB_KEY_Cyrillic_CHE_descender :u32 = 0x10004b6; /* U+04B6 CYRILLIC CAPITAL LETTER CHE WITH DESCENDER */ +pub const XKB_KEY_Cyrillic_che_descender :u32 = 0x10004b7; /* U+04B7 CYRILLIC SMALL LETTER CHE WITH DESCENDER */ +pub const XKB_KEY_Cyrillic_CHE_vertstroke :u32 = 0x10004b8; /* U+04B8 CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE */ +pub const XKB_KEY_Cyrillic_che_vertstroke :u32 = 0x10004b9; /* U+04B9 CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE */ +pub const XKB_KEY_Cyrillic_SHHA :u32 = 0x10004ba; /* U+04BA CYRILLIC CAPITAL LETTER SHHA */ +pub const XKB_KEY_Cyrillic_shha :u32 = 0x10004bb; /* U+04BB CYRILLIC SMALL LETTER SHHA */ + +pub const XKB_KEY_Cyrillic_SCHWA :u32 = 0x10004d8; /* U+04D8 CYRILLIC CAPITAL LETTER SCHWA */ +pub const XKB_KEY_Cyrillic_schwa :u32 = 0x10004d9; /* U+04D9 CYRILLIC SMALL LETTER SCHWA */ +pub const XKB_KEY_Cyrillic_I_macron :u32 = 0x10004e2; /* U+04E2 CYRILLIC CAPITAL LETTER I WITH MACRON */ +pub const XKB_KEY_Cyrillic_i_macron :u32 = 0x10004e3; /* U+04E3 CYRILLIC SMALL LETTER I WITH MACRON */ +pub const XKB_KEY_Cyrillic_O_bar :u32 = 0x10004e8; /* U+04E8 CYRILLIC CAPITAL LETTER BARRED O */ +pub const XKB_KEY_Cyrillic_o_bar :u32 = 0x10004e9; /* U+04E9 CYRILLIC SMALL LETTER BARRED O */ +pub const XKB_KEY_Cyrillic_U_macron :u32 = 0x10004ee; /* U+04EE CYRILLIC CAPITAL LETTER U WITH MACRON */ +pub const XKB_KEY_Cyrillic_u_macron :u32 = 0x10004ef; /* U+04EF CYRILLIC SMALL LETTER U WITH MACRON */ + +pub const XKB_KEY_Serbian_dje :u32 = 0x06a1; /* U+0452 CYRILLIC SMALL LETTER DJE */ +pub const XKB_KEY_Macedonia_gje :u32 = 0x06a2; /* U+0453 CYRILLIC SMALL LETTER GJE */ +pub const XKB_KEY_Cyrillic_io :u32 = 0x06a3; /* U+0451 CYRILLIC SMALL LETTER IO */ +pub const XKB_KEY_Ukrainian_ie :u32 = 0x06a4; /* U+0454 CYRILLIC SMALL LETTER UKRAINIAN IE */ +pub const XKB_KEY_Ukranian_je :u32 = 0x06a4; /* deprecated */ +pub const XKB_KEY_Macedonia_dse :u32 = 0x06a5; /* U+0455 CYRILLIC SMALL LETTER DZE */ +pub const XKB_KEY_Ukrainian_i :u32 = 0x06a6; /* U+0456 CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I */ +pub const XKB_KEY_Ukranian_i :u32 = 0x06a6; /* deprecated */ +pub const XKB_KEY_Ukrainian_yi :u32 = 0x06a7; /* U+0457 CYRILLIC SMALL LETTER YI */ +pub const XKB_KEY_Ukranian_yi :u32 = 0x06a7; /* deprecated */ +pub const XKB_KEY_Cyrillic_je :u32 = 0x06a8; /* U+0458 CYRILLIC SMALL LETTER JE */ +pub const XKB_KEY_Serbian_je :u32 = 0x06a8; /* deprecated */ +pub const XKB_KEY_Cyrillic_lje :u32 = 0x06a9; /* U+0459 CYRILLIC SMALL LETTER LJE */ +pub const XKB_KEY_Serbian_lje :u32 = 0x06a9; /* deprecated */ +pub const XKB_KEY_Cyrillic_nje :u32 = 0x06aa; /* U+045A CYRILLIC SMALL LETTER NJE */ +pub const XKB_KEY_Serbian_nje :u32 = 0x06aa; /* deprecated */ +pub const XKB_KEY_Serbian_tshe :u32 = 0x06ab; /* U+045B CYRILLIC SMALL LETTER TSHE */ +pub const XKB_KEY_Macedonia_kje :u32 = 0x06ac; /* U+045C CYRILLIC SMALL LETTER KJE */ +pub const XKB_KEY_Ukrainian_ghe_with_upturn :u32 = 0x06ad; /* U+0491 CYRILLIC SMALL LETTER GHE WITH UPTURN */ +pub const XKB_KEY_Byelorussian_shortu :u32 = 0x06ae; /* U+045E CYRILLIC SMALL LETTER SHORT U */ +pub const XKB_KEY_Cyrillic_dzhe :u32 = 0x06af; /* U+045F CYRILLIC SMALL LETTER DZHE */ +pub const XKB_KEY_Serbian_dze :u32 = 0x06af; /* deprecated */ +pub const XKB_KEY_numerosign :u32 = 0x06b0; /* U+2116 NUMERO SIGN */ +pub const XKB_KEY_Serbian_DJE :u32 = 0x06b1; /* U+0402 CYRILLIC CAPITAL LETTER DJE */ +pub const XKB_KEY_Macedonia_GJE :u32 = 0x06b2; /* U+0403 CYRILLIC CAPITAL LETTER GJE */ +pub const XKB_KEY_Cyrillic_IO :u32 = 0x06b3; /* U+0401 CYRILLIC CAPITAL LETTER IO */ +pub const XKB_KEY_Ukrainian_IE :u32 = 0x06b4; /* U+0404 CYRILLIC CAPITAL LETTER UKRAINIAN IE */ +pub const XKB_KEY_Ukranian_JE :u32 = 0x06b4; /* deprecated */ +pub const XKB_KEY_Macedonia_DSE :u32 = 0x06b5; /* U+0405 CYRILLIC CAPITAL LETTER DZE */ +pub const XKB_KEY_Ukrainian_I :u32 = 0x06b6; /* U+0406 CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */ +pub const XKB_KEY_Ukranian_I :u32 = 0x06b6; /* deprecated */ +pub const XKB_KEY_Ukrainian_YI :u32 = 0x06b7; /* U+0407 CYRILLIC CAPITAL LETTER YI */ +pub const XKB_KEY_Ukranian_YI :u32 = 0x06b7; /* deprecated */ +pub const XKB_KEY_Cyrillic_JE :u32 = 0x06b8; /* U+0408 CYRILLIC CAPITAL LETTER JE */ +pub const XKB_KEY_Serbian_JE :u32 = 0x06b8; /* deprecated */ +pub const XKB_KEY_Cyrillic_LJE :u32 = 0x06b9; /* U+0409 CYRILLIC CAPITAL LETTER LJE */ +pub const XKB_KEY_Serbian_LJE :u32 = 0x06b9; /* deprecated */ +pub const XKB_KEY_Cyrillic_NJE :u32 = 0x06ba; /* U+040A CYRILLIC CAPITAL LETTER NJE */ +pub const XKB_KEY_Serbian_NJE :u32 = 0x06ba; /* deprecated */ +pub const XKB_KEY_Serbian_TSHE :u32 = 0x06bb; /* U+040B CYRILLIC CAPITAL LETTER TSHE */ +pub const XKB_KEY_Macedonia_KJE :u32 = 0x06bc; /* U+040C CYRILLIC CAPITAL LETTER KJE */ +pub const XKB_KEY_Ukrainian_GHE_WITH_UPTURN :u32 = 0x06bd; /* U+0490 CYRILLIC CAPITAL LETTER GHE WITH UPTURN */ +pub const XKB_KEY_Byelorussian_SHORTU :u32 = 0x06be; /* U+040E CYRILLIC CAPITAL LETTER SHORT U */ +pub const XKB_KEY_Cyrillic_DZHE :u32 = 0x06bf; /* U+040F CYRILLIC CAPITAL LETTER DZHE */ +pub const XKB_KEY_Serbian_DZE :u32 = 0x06bf; /* deprecated */ +pub const XKB_KEY_Cyrillic_yu :u32 = 0x06c0; /* U+044E CYRILLIC SMALL LETTER YU */ +pub const XKB_KEY_Cyrillic_a :u32 = 0x06c1; /* U+0430 CYRILLIC SMALL LETTER A */ +pub const XKB_KEY_Cyrillic_be :u32 = 0x06c2; /* U+0431 CYRILLIC SMALL LETTER BE */ +pub const XKB_KEY_Cyrillic_tse :u32 = 0x06c3; /* U+0446 CYRILLIC SMALL LETTER TSE */ +pub const XKB_KEY_Cyrillic_de :u32 = 0x06c4; /* U+0434 CYRILLIC SMALL LETTER DE */ +pub const XKB_KEY_Cyrillic_ie :u32 = 0x06c5; /* U+0435 CYRILLIC SMALL LETTER IE */ +pub const XKB_KEY_Cyrillic_ef :u32 = 0x06c6; /* U+0444 CYRILLIC SMALL LETTER EF */ +pub const XKB_KEY_Cyrillic_ghe :u32 = 0x06c7; /* U+0433 CYRILLIC SMALL LETTER GHE */ +pub const XKB_KEY_Cyrillic_ha :u32 = 0x06c8; /* U+0445 CYRILLIC SMALL LETTER HA */ +pub const XKB_KEY_Cyrillic_i :u32 = 0x06c9; /* U+0438 CYRILLIC SMALL LETTER I */ +pub const XKB_KEY_Cyrillic_shorti :u32 = 0x06ca; /* U+0439 CYRILLIC SMALL LETTER SHORT I */ +pub const XKB_KEY_Cyrillic_ka :u32 = 0x06cb; /* U+043A CYRILLIC SMALL LETTER KA */ +pub const XKB_KEY_Cyrillic_el :u32 = 0x06cc; /* U+043B CYRILLIC SMALL LETTER EL */ +pub const XKB_KEY_Cyrillic_em :u32 = 0x06cd; /* U+043C CYRILLIC SMALL LETTER EM */ +pub const XKB_KEY_Cyrillic_en :u32 = 0x06ce; /* U+043D CYRILLIC SMALL LETTER EN */ +pub const XKB_KEY_Cyrillic_o :u32 = 0x06cf; /* U+043E CYRILLIC SMALL LETTER O */ +pub const XKB_KEY_Cyrillic_pe :u32 = 0x06d0; /* U+043F CYRILLIC SMALL LETTER PE */ +pub const XKB_KEY_Cyrillic_ya :u32 = 0x06d1; /* U+044F CYRILLIC SMALL LETTER YA */ +pub const XKB_KEY_Cyrillic_er :u32 = 0x06d2; /* U+0440 CYRILLIC SMALL LETTER ER */ +pub const XKB_KEY_Cyrillic_es :u32 = 0x06d3; /* U+0441 CYRILLIC SMALL LETTER ES */ +pub const XKB_KEY_Cyrillic_te :u32 = 0x06d4; /* U+0442 CYRILLIC SMALL LETTER TE */ +pub const XKB_KEY_Cyrillic_u :u32 = 0x06d5; /* U+0443 CYRILLIC SMALL LETTER U */ +pub const XKB_KEY_Cyrillic_zhe :u32 = 0x06d6; /* U+0436 CYRILLIC SMALL LETTER ZHE */ +pub const XKB_KEY_Cyrillic_ve :u32 = 0x06d7; /* U+0432 CYRILLIC SMALL LETTER VE */ +pub const XKB_KEY_Cyrillic_softsign :u32 = 0x06d8; /* U+044C CYRILLIC SMALL LETTER SOFT SIGN */ +pub const XKB_KEY_Cyrillic_yeru :u32 = 0x06d9; /* U+044B CYRILLIC SMALL LETTER YERU */ +pub const XKB_KEY_Cyrillic_ze :u32 = 0x06da; /* U+0437 CYRILLIC SMALL LETTER ZE */ +pub const XKB_KEY_Cyrillic_sha :u32 = 0x06db; /* U+0448 CYRILLIC SMALL LETTER SHA */ +pub const XKB_KEY_Cyrillic_e :u32 = 0x06dc; /* U+044D CYRILLIC SMALL LETTER E */ +pub const XKB_KEY_Cyrillic_shcha :u32 = 0x06dd; /* U+0449 CYRILLIC SMALL LETTER SHCHA */ +pub const XKB_KEY_Cyrillic_che :u32 = 0x06de; /* U+0447 CYRILLIC SMALL LETTER CHE */ +pub const XKB_KEY_Cyrillic_hardsign :u32 = 0x06df; /* U+044A CYRILLIC SMALL LETTER HARD SIGN */ +pub const XKB_KEY_Cyrillic_YU :u32 = 0x06e0; /* U+042E CYRILLIC CAPITAL LETTER YU */ +pub const XKB_KEY_Cyrillic_A :u32 = 0x06e1; /* U+0410 CYRILLIC CAPITAL LETTER A */ +pub const XKB_KEY_Cyrillic_BE :u32 = 0x06e2; /* U+0411 CYRILLIC CAPITAL LETTER BE */ +pub const XKB_KEY_Cyrillic_TSE :u32 = 0x06e3; /* U+0426 CYRILLIC CAPITAL LETTER TSE */ +pub const XKB_KEY_Cyrillic_DE :u32 = 0x06e4; /* U+0414 CYRILLIC CAPITAL LETTER DE */ +pub const XKB_KEY_Cyrillic_IE :u32 = 0x06e5; /* U+0415 CYRILLIC CAPITAL LETTER IE */ +pub const XKB_KEY_Cyrillic_EF :u32 = 0x06e6; /* U+0424 CYRILLIC CAPITAL LETTER EF */ +pub const XKB_KEY_Cyrillic_GHE :u32 = 0x06e7; /* U+0413 CYRILLIC CAPITAL LETTER GHE */ +pub const XKB_KEY_Cyrillic_HA :u32 = 0x06e8; /* U+0425 CYRILLIC CAPITAL LETTER HA */ +pub const XKB_KEY_Cyrillic_I :u32 = 0x06e9; /* U+0418 CYRILLIC CAPITAL LETTER I */ +pub const XKB_KEY_Cyrillic_SHORTI :u32 = 0x06ea; /* U+0419 CYRILLIC CAPITAL LETTER SHORT I */ +pub const XKB_KEY_Cyrillic_KA :u32 = 0x06eb; /* U+041A CYRILLIC CAPITAL LETTER KA */ +pub const XKB_KEY_Cyrillic_EL :u32 = 0x06ec; /* U+041B CYRILLIC CAPITAL LETTER EL */ +pub const XKB_KEY_Cyrillic_EM :u32 = 0x06ed; /* U+041C CYRILLIC CAPITAL LETTER EM */ +pub const XKB_KEY_Cyrillic_EN :u32 = 0x06ee; /* U+041D CYRILLIC CAPITAL LETTER EN */ +pub const XKB_KEY_Cyrillic_O :u32 = 0x06ef; /* U+041E CYRILLIC CAPITAL LETTER O */ +pub const XKB_KEY_Cyrillic_PE :u32 = 0x06f0; /* U+041F CYRILLIC CAPITAL LETTER PE */ +pub const XKB_KEY_Cyrillic_YA :u32 = 0x06f1; /* U+042F CYRILLIC CAPITAL LETTER YA */ +pub const XKB_KEY_Cyrillic_ER :u32 = 0x06f2; /* U+0420 CYRILLIC CAPITAL LETTER ER */ +pub const XKB_KEY_Cyrillic_ES :u32 = 0x06f3; /* U+0421 CYRILLIC CAPITAL LETTER ES */ +pub const XKB_KEY_Cyrillic_TE :u32 = 0x06f4; /* U+0422 CYRILLIC CAPITAL LETTER TE */ +pub const XKB_KEY_Cyrillic_U :u32 = 0x06f5; /* U+0423 CYRILLIC CAPITAL LETTER U */ +pub const XKB_KEY_Cyrillic_ZHE :u32 = 0x06f6; /* U+0416 CYRILLIC CAPITAL LETTER ZHE */ +pub const XKB_KEY_Cyrillic_VE :u32 = 0x06f7; /* U+0412 CYRILLIC CAPITAL LETTER VE */ +pub const XKB_KEY_Cyrillic_SOFTSIGN :u32 = 0x06f8; /* U+042C CYRILLIC CAPITAL LETTER SOFT SIGN */ +pub const XKB_KEY_Cyrillic_YERU :u32 = 0x06f9; /* U+042B CYRILLIC CAPITAL LETTER YERU */ +pub const XKB_KEY_Cyrillic_ZE :u32 = 0x06fa; /* U+0417 CYRILLIC CAPITAL LETTER ZE */ +pub const XKB_KEY_Cyrillic_SHA :u32 = 0x06fb; /* U+0428 CYRILLIC CAPITAL LETTER SHA */ +pub const XKB_KEY_Cyrillic_E :u32 = 0x06fc; /* U+042D CYRILLIC CAPITAL LETTER E */ +pub const XKB_KEY_Cyrillic_SHCHA :u32 = 0x06fd; /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ +pub const XKB_KEY_Cyrillic_CHE :u32 = 0x06fe; /* U+0427 CYRILLIC CAPITAL LETTER CHE */ +pub const XKB_KEY_Cyrillic_HARDSIGN :u32 = 0x06ff; /* U+042A CYRILLIC CAPITAL LETTER HARD SIGN */ + +/* + * Greek + * (based on an early draft of, and not quite identical to, ISO/IEC 8859-7) + * Byte 3 = 7 + */ + +pub const XKB_KEY_Greek_ALPHAaccent :u32 = 0x07a1; /* U+0386 GREEK CAPITAL LETTER ALPHA WITH TONOS */ +pub const XKB_KEY_Greek_EPSILONaccent :u32 = 0x07a2; /* U+0388 GREEK CAPITAL LETTER EPSILON WITH TONOS */ +pub const XKB_KEY_Greek_ETAaccent :u32 = 0x07a3; /* U+0389 GREEK CAPITAL LETTER ETA WITH TONOS */ +pub const XKB_KEY_Greek_IOTAaccent :u32 = 0x07a4; /* U+038A GREEK CAPITAL LETTER IOTA WITH TONOS */ +pub const XKB_KEY_Greek_IOTAdieresis :u32 = 0x07a5; /* U+03AA GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */ +pub const XKB_KEY_Greek_IOTAdiaeresis :u32 = 0x07a5; /* old typo */ +pub const XKB_KEY_Greek_OMICRONaccent :u32 = 0x07a7; /* U+038C GREEK CAPITAL LETTER OMICRON WITH TONOS */ +pub const XKB_KEY_Greek_UPSILONaccent :u32 = 0x07a8; /* U+038E GREEK CAPITAL LETTER UPSILON WITH TONOS */ +pub const XKB_KEY_Greek_UPSILONdieresis :u32 = 0x07a9; /* U+03AB GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */ +pub const XKB_KEY_Greek_OMEGAaccent :u32 = 0x07ab; /* U+038F GREEK CAPITAL LETTER OMEGA WITH TONOS */ +pub const XKB_KEY_Greek_accentdieresis :u32 = 0x07ae; /* U+0385 GREEK DIALYTIKA TONOS */ +pub const XKB_KEY_Greek_horizbar :u32 = 0x07af; /* U+2015 HORIZONTAL BAR */ +pub const XKB_KEY_Greek_alphaaccent :u32 = 0x07b1; /* U+03AC GREEK SMALL LETTER ALPHA WITH TONOS */ +pub const XKB_KEY_Greek_epsilonaccent :u32 = 0x07b2; /* U+03AD GREEK SMALL LETTER EPSILON WITH TONOS */ +pub const XKB_KEY_Greek_etaaccent :u32 = 0x07b3; /* U+03AE GREEK SMALL LETTER ETA WITH TONOS */ +pub const XKB_KEY_Greek_iotaaccent :u32 = 0x07b4; /* U+03AF GREEK SMALL LETTER IOTA WITH TONOS */ +pub const XKB_KEY_Greek_iotadieresis :u32 = 0x07b5; /* U+03CA GREEK SMALL LETTER IOTA WITH DIALYTIKA */ +pub const XKB_KEY_Greek_iotaaccentdieresis :u32 = 0x07b6; /* U+0390 GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */ +pub const XKB_KEY_Greek_omicronaccent :u32 = 0x07b7; /* U+03CC GREEK SMALL LETTER OMICRON WITH TONOS */ +pub const XKB_KEY_Greek_upsilonaccent :u32 = 0x07b8; /* U+03CD GREEK SMALL LETTER UPSILON WITH TONOS */ +pub const XKB_KEY_Greek_upsilondieresis :u32 = 0x07b9; /* U+03CB GREEK SMALL LETTER UPSILON WITH DIALYTIKA */ +pub const XKB_KEY_Greek_upsilonaccentdieresis :u32 = 0x07ba; /* U+03B0 GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS */ +pub const XKB_KEY_Greek_omegaaccent :u32 = 0x07bb; /* U+03CE GREEK SMALL LETTER OMEGA WITH TONOS */ +pub const XKB_KEY_Greek_ALPHA :u32 = 0x07c1; /* U+0391 GREEK CAPITAL LETTER ALPHA */ +pub const XKB_KEY_Greek_BETA :u32 = 0x07c2; /* U+0392 GREEK CAPITAL LETTER BETA */ +pub const XKB_KEY_Greek_GAMMA :u32 = 0x07c3; /* U+0393 GREEK CAPITAL LETTER GAMMA */ +pub const XKB_KEY_Greek_DELTA :u32 = 0x07c4; /* U+0394 GREEK CAPITAL LETTER DELTA */ +pub const XKB_KEY_Greek_EPSILON :u32 = 0x07c5; /* U+0395 GREEK CAPITAL LETTER EPSILON */ +pub const XKB_KEY_Greek_ZETA :u32 = 0x07c6; /* U+0396 GREEK CAPITAL LETTER ZETA */ +pub const XKB_KEY_Greek_ETA :u32 = 0x07c7; /* U+0397 GREEK CAPITAL LETTER ETA */ +pub const XKB_KEY_Greek_THETA :u32 = 0x07c8; /* U+0398 GREEK CAPITAL LETTER THETA */ +pub const XKB_KEY_Greek_IOTA :u32 = 0x07c9; /* U+0399 GREEK CAPITAL LETTER IOTA */ +pub const XKB_KEY_Greek_KAPPA :u32 = 0x07ca; /* U+039A GREEK CAPITAL LETTER KAPPA */ +pub const XKB_KEY_Greek_LAMDA :u32 = 0x07cb; /* U+039B GREEK CAPITAL LETTER LAMDA */ +pub const XKB_KEY_Greek_LAMBDA :u32 = 0x07cb; /* U+039B GREEK CAPITAL LETTER LAMDA */ +pub const XKB_KEY_Greek_MU :u32 = 0x07cc; /* U+039C GREEK CAPITAL LETTER MU */ +pub const XKB_KEY_Greek_NU :u32 = 0x07cd; /* U+039D GREEK CAPITAL LETTER NU */ +pub const XKB_KEY_Greek_XI :u32 = 0x07ce; /* U+039E GREEK CAPITAL LETTER XI */ +pub const XKB_KEY_Greek_OMICRON :u32 = 0x07cf; /* U+039F GREEK CAPITAL LETTER OMICRON */ +pub const XKB_KEY_Greek_PI :u32 = 0x07d0; /* U+03A0 GREEK CAPITAL LETTER PI */ +pub const XKB_KEY_Greek_RHO :u32 = 0x07d1; /* U+03A1 GREEK CAPITAL LETTER RHO */ +pub const XKB_KEY_Greek_SIGMA :u32 = 0x07d2; /* U+03A3 GREEK CAPITAL LETTER SIGMA */ +pub const XKB_KEY_Greek_TAU :u32 = 0x07d4; /* U+03A4 GREEK CAPITAL LETTER TAU */ +pub const XKB_KEY_Greek_UPSILON :u32 = 0x07d5; /* U+03A5 GREEK CAPITAL LETTER UPSILON */ +pub const XKB_KEY_Greek_PHI :u32 = 0x07d6; /* U+03A6 GREEK CAPITAL LETTER PHI */ +pub const XKB_KEY_Greek_CHI :u32 = 0x07d7; /* U+03A7 GREEK CAPITAL LETTER CHI */ +pub const XKB_KEY_Greek_PSI :u32 = 0x07d8; /* U+03A8 GREEK CAPITAL LETTER PSI */ +pub const XKB_KEY_Greek_OMEGA :u32 = 0x07d9; /* U+03A9 GREEK CAPITAL LETTER OMEGA */ +pub const XKB_KEY_Greek_alpha :u32 = 0x07e1; /* U+03B1 GREEK SMALL LETTER ALPHA */ +pub const XKB_KEY_Greek_beta :u32 = 0x07e2; /* U+03B2 GREEK SMALL LETTER BETA */ +pub const XKB_KEY_Greek_gamma :u32 = 0x07e3; /* U+03B3 GREEK SMALL LETTER GAMMA */ +pub const XKB_KEY_Greek_delta :u32 = 0x07e4; /* U+03B4 GREEK SMALL LETTER DELTA */ +pub const XKB_KEY_Greek_epsilon :u32 = 0x07e5; /* U+03B5 GREEK SMALL LETTER EPSILON */ +pub const XKB_KEY_Greek_zeta :u32 = 0x07e6; /* U+03B6 GREEK SMALL LETTER ZETA */ +pub const XKB_KEY_Greek_eta :u32 = 0x07e7; /* U+03B7 GREEK SMALL LETTER ETA */ +pub const XKB_KEY_Greek_theta :u32 = 0x07e8; /* U+03B8 GREEK SMALL LETTER THETA */ +pub const XKB_KEY_Greek_iota :u32 = 0x07e9; /* U+03B9 GREEK SMALL LETTER IOTA */ +pub const XKB_KEY_Greek_kappa :u32 = 0x07ea; /* U+03BA GREEK SMALL LETTER KAPPA */ +pub const XKB_KEY_Greek_lamda :u32 = 0x07eb; /* U+03BB GREEK SMALL LETTER LAMDA */ +pub const XKB_KEY_Greek_lambda :u32 = 0x07eb; /* U+03BB GREEK SMALL LETTER LAMDA */ +pub const XKB_KEY_Greek_mu :u32 = 0x07ec; /* U+03BC GREEK SMALL LETTER MU */ +pub const XKB_KEY_Greek_nu :u32 = 0x07ed; /* U+03BD GREEK SMALL LETTER NU */ +pub const XKB_KEY_Greek_xi :u32 = 0x07ee; /* U+03BE GREEK SMALL LETTER XI */ +pub const XKB_KEY_Greek_omicron :u32 = 0x07ef; /* U+03BF GREEK SMALL LETTER OMICRON */ +pub const XKB_KEY_Greek_pi :u32 = 0x07f0; /* U+03C0 GREEK SMALL LETTER PI */ +pub const XKB_KEY_Greek_rho :u32 = 0x07f1; /* U+03C1 GREEK SMALL LETTER RHO */ +pub const XKB_KEY_Greek_sigma :u32 = 0x07f2; /* U+03C3 GREEK SMALL LETTER SIGMA */ +pub const XKB_KEY_Greek_finalsmallsigma :u32 = 0x07f3; /* U+03C2 GREEK SMALL LETTER FINAL SIGMA */ +pub const XKB_KEY_Greek_tau :u32 = 0x07f4; /* U+03C4 GREEK SMALL LETTER TAU */ +pub const XKB_KEY_Greek_upsilon :u32 = 0x07f5; /* U+03C5 GREEK SMALL LETTER UPSILON */ +pub const XKB_KEY_Greek_phi :u32 = 0x07f6; /* U+03C6 GREEK SMALL LETTER PHI */ +pub const XKB_KEY_Greek_chi :u32 = 0x07f7; /* U+03C7 GREEK SMALL LETTER CHI */ +pub const XKB_KEY_Greek_psi :u32 = 0x07f8; /* U+03C8 GREEK SMALL LETTER PSI */ +pub const XKB_KEY_Greek_omega :u32 = 0x07f9; /* U+03C9 GREEK SMALL LETTER OMEGA */ +pub const XKB_KEY_Greek_switch :u32 = 0xff7e; /* Alias for mode_switch */ + +/* + * Technical + * (from the DEC VT330/VT420 Technical Character Set, http://vt100.net/charsets/technical.html) + * Byte 3 = 8 + */ + +pub const XKB_KEY_leftradical :u32 = 0x08a1; /* U+23B7 RADICAL SYMBOL BOTTOM */ +pub const XKB_KEY_topleftradical :u32 = 0x08a2; /*(U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT)*/ +pub const XKB_KEY_horizconnector :u32 = 0x08a3; /*(U+2500 BOX DRAWINGS LIGHT HORIZONTAL)*/ +pub const XKB_KEY_topintegral :u32 = 0x08a4; /* U+2320 TOP HALF INTEGRAL */ +pub const XKB_KEY_botintegral :u32 = 0x08a5; /* U+2321 BOTTOM HALF INTEGRAL */ +pub const XKB_KEY_vertconnector :u32 = 0x08a6; /*(U+2502 BOX DRAWINGS LIGHT VERTICAL)*/ +pub const XKB_KEY_topleftsqbracket :u32 = 0x08a7; /* U+23A1 LEFT SQUARE BRACKET UPPER CORNER */ +pub const XKB_KEY_botleftsqbracket :u32 = 0x08a8; /* U+23A3 LEFT SQUARE BRACKET LOWER CORNER */ +pub const XKB_KEY_toprightsqbracket :u32 = 0x08a9; /* U+23A4 RIGHT SQUARE BRACKET UPPER CORNER */ +pub const XKB_KEY_botrightsqbracket :u32 = 0x08aa; /* U+23A6 RIGHT SQUARE BRACKET LOWER CORNER */ +pub const XKB_KEY_topleftparens :u32 = 0x08ab; /* U+239B LEFT PARENTHESIS UPPER HOOK */ +pub const XKB_KEY_botleftparens :u32 = 0x08ac; /* U+239D LEFT PARENTHESIS LOWER HOOK */ +pub const XKB_KEY_toprightparens :u32 = 0x08ad; /* U+239E RIGHT PARENTHESIS UPPER HOOK */ +pub const XKB_KEY_botrightparens :u32 = 0x08ae; /* U+23A0 RIGHT PARENTHESIS LOWER HOOK */ +pub const XKB_KEY_leftmiddlecurlybrace :u32 = 0x08af; /* U+23A8 LEFT CURLY BRACKET MIDDLE PIECE */ +pub const XKB_KEY_rightmiddlecurlybrace :u32 = 0x08b0; /* U+23AC RIGHT CURLY BRACKET MIDDLE PIECE */ +pub const XKB_KEY_topleftsummation :u32 = 0x08b1; +pub const XKB_KEY_botleftsummation :u32 = 0x08b2; +pub const XKB_KEY_topvertsummationconnector :u32 = 0x08b3; +pub const XKB_KEY_botvertsummationconnector :u32 = 0x08b4; +pub const XKB_KEY_toprightsummation :u32 = 0x08b5; +pub const XKB_KEY_botrightsummation :u32 = 0x08b6; +pub const XKB_KEY_rightmiddlesummation :u32 = 0x08b7; +pub const XKB_KEY_lessthanequal :u32 = 0x08bc; /* U+2264 LESS-THAN OR EQUAL TO */ +pub const XKB_KEY_notequal :u32 = 0x08bd; /* U+2260 NOT EQUAL TO */ +pub const XKB_KEY_greaterthanequal :u32 = 0x08be; /* U+2265 GREATER-THAN OR EQUAL TO */ +pub const XKB_KEY_integral :u32 = 0x08bf; /* U+222B INTEGRAL */ +pub const XKB_KEY_therefore :u32 = 0x08c0; /* U+2234 THEREFORE */ +pub const XKB_KEY_variation :u32 = 0x08c1; /* U+221D PROPORTIONAL TO */ +pub const XKB_KEY_infinity :u32 = 0x08c2; /* U+221E INFINITY */ +pub const XKB_KEY_nabla :u32 = 0x08c5; /* U+2207 NABLA */ +pub const XKB_KEY_approximate :u32 = 0x08c8; /* U+223C TILDE OPERATOR */ +pub const XKB_KEY_similarequal :u32 = 0x08c9; /* U+2243 ASYMPTOTICALLY EQUAL TO */ +pub const XKB_KEY_ifonlyif :u32 = 0x08cd; /* U+21D4 LEFT RIGHT DOUBLE ARROW */ +pub const XKB_KEY_implies :u32 = 0x08ce; /* U+21D2 RIGHTWARDS DOUBLE ARROW */ +pub const XKB_KEY_identical :u32 = 0x08cf; /* U+2261 IDENTICAL TO */ +pub const XKB_KEY_radical :u32 = 0x08d6; /* U+221A SQUARE ROOT */ +pub const XKB_KEY_includedin :u32 = 0x08da; /* U+2282 SUBSET OF */ +pub const XKB_KEY_includes :u32 = 0x08db; /* U+2283 SUPERSET OF */ +pub const XKB_KEY_intersection :u32 = 0x08dc; /* U+2229 INTERSECTION */ +pub const XKB_KEY_union :u32 = 0x08dd; /* U+222A UNION */ +pub const XKB_KEY_logicaland :u32 = 0x08de; /* U+2227 LOGICAL AND */ +pub const XKB_KEY_logicalor :u32 = 0x08df; /* U+2228 LOGICAL OR */ +pub const XKB_KEY_partialderivative :u32 = 0x08ef; /* U+2202 PARTIAL DIFFERENTIAL */ +pub const XKB_KEY_function :u32 = 0x08f6; /* U+0192 LATIN SMALL LETTER F WITH HOOK */ +pub const XKB_KEY_leftarrow :u32 = 0x08fb; /* U+2190 LEFTWARDS ARROW */ +pub const XKB_KEY_uparrow :u32 = 0x08fc; /* U+2191 UPWARDS ARROW */ +pub const XKB_KEY_rightarrow :u32 = 0x08fd; /* U+2192 RIGHTWARDS ARROW */ +pub const XKB_KEY_downarrow :u32 = 0x08fe; /* U+2193 DOWNWARDS ARROW */ + +/* + * Special + * (from the DEC VT100 Special Graphics Character Set) + * Byte 3 = 9 + */ + +pub const XKB_KEY_blank :u32 = 0x09df; +pub const XKB_KEY_soliddiamond :u32 = 0x09e0; /* U+25C6 BLACK DIAMOND */ +pub const XKB_KEY_checkerboard :u32 = 0x09e1; /* U+2592 MEDIUM SHADE */ +pub const XKB_KEY_ht :u32 = 0x09e2; /* U+2409 SYMBOL FOR HORIZONTAL TABULATION */ +pub const XKB_KEY_ff :u32 = 0x09e3; /* U+240C SYMBOL FOR FORM FEED */ +pub const XKB_KEY_cr :u32 = 0x09e4; /* U+240D SYMBOL FOR CARRIAGE RETURN */ +pub const XKB_KEY_lf :u32 = 0x09e5; /* U+240A SYMBOL FOR LINE FEED */ +pub const XKB_KEY_nl :u32 = 0x09e8; /* U+2424 SYMBOL FOR NEWLINE */ +pub const XKB_KEY_vt :u32 = 0x09e9; /* U+240B SYMBOL FOR VERTICAL TABULATION */ +pub const XKB_KEY_lowrightcorner :u32 = 0x09ea; /* U+2518 BOX DRAWINGS LIGHT UP AND LEFT */ +pub const XKB_KEY_uprightcorner :u32 = 0x09eb; /* U+2510 BOX DRAWINGS LIGHT DOWN AND LEFT */ +pub const XKB_KEY_upleftcorner :u32 = 0x09ec; /* U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT */ +pub const XKB_KEY_lowleftcorner :u32 = 0x09ed; /* U+2514 BOX DRAWINGS LIGHT UP AND RIGHT */ +pub const XKB_KEY_crossinglines :u32 = 0x09ee; /* U+253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */ +pub const XKB_KEY_horizlinescan1 :u32 = 0x09ef; /* U+23BA HORIZONTAL SCAN LINE-1 */ +pub const XKB_KEY_horizlinescan3 :u32 = 0x09f0; /* U+23BB HORIZONTAL SCAN LINE-3 */ +pub const XKB_KEY_horizlinescan5 :u32 = 0x09f1; /* U+2500 BOX DRAWINGS LIGHT HORIZONTAL */ +pub const XKB_KEY_horizlinescan7 :u32 = 0x09f2; /* U+23BC HORIZONTAL SCAN LINE-7 */ +pub const XKB_KEY_horizlinescan9 :u32 = 0x09f3; /* U+23BD HORIZONTAL SCAN LINE-9 */ +pub const XKB_KEY_leftt :u32 = 0x09f4; /* U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT */ +pub const XKB_KEY_rightt :u32 = 0x09f5; /* U+2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT */ +pub const XKB_KEY_bott :u32 = 0x09f6; /* U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL */ +pub const XKB_KEY_topt :u32 = 0x09f7; /* U+252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */ +pub const XKB_KEY_vertbar :u32 = 0x09f8; /* U+2502 BOX DRAWINGS LIGHT VERTICAL */ + +/* + * Publishing + * (these are probably from a long forgotten DEC Publishing + * font that once shipped with DECwrite) + * Byte 3 = :u32 = 0x0a; + */ + +pub const XKB_KEY_emspace :u32 = 0x0aa1; /* U+2003 EM SPACE */ +pub const XKB_KEY_enspace :u32 = 0x0aa2; /* U+2002 EN SPACE */ +pub const XKB_KEY_em3space :u32 = 0x0aa3; /* U+2004 THREE-PER-EM SPACE */ +pub const XKB_KEY_em4space :u32 = 0x0aa4; /* U+2005 FOUR-PER-EM SPACE */ +pub const XKB_KEY_digitspace :u32 = 0x0aa5; /* U+2007 FIGURE SPACE */ +pub const XKB_KEY_punctspace :u32 = 0x0aa6; /* U+2008 PUNCTUATION SPACE */ +pub const XKB_KEY_thinspace :u32 = 0x0aa7; /* U+2009 THIN SPACE */ +pub const XKB_KEY_hairspace :u32 = 0x0aa8; /* U+200A HAIR SPACE */ +pub const XKB_KEY_emdash :u32 = 0x0aa9; /* U+2014 EM DASH */ +pub const XKB_KEY_endash :u32 = 0x0aaa; /* U+2013 EN DASH */ +pub const XKB_KEY_signifblank :u32 = 0x0aac; /*(U+2423 OPEN BOX)*/ +pub const XKB_KEY_ellipsis :u32 = 0x0aae; /* U+2026 HORIZONTAL ELLIPSIS */ +pub const XKB_KEY_doubbaselinedot :u32 = 0x0aaf; /* U+2025 TWO DOT LEADER */ +pub const XKB_KEY_onethird :u32 = 0x0ab0; /* U+2153 VULGAR FRACTION ONE THIRD */ +pub const XKB_KEY_twothirds :u32 = 0x0ab1; /* U+2154 VULGAR FRACTION TWO THIRDS */ +pub const XKB_KEY_onefifth :u32 = 0x0ab2; /* U+2155 VULGAR FRACTION ONE FIFTH */ +pub const XKB_KEY_twofifths :u32 = 0x0ab3; /* U+2156 VULGAR FRACTION TWO FIFTHS */ +pub const XKB_KEY_threefifths :u32 = 0x0ab4; /* U+2157 VULGAR FRACTION THREE FIFTHS */ +pub const XKB_KEY_fourfifths :u32 = 0x0ab5; /* U+2158 VULGAR FRACTION FOUR FIFTHS */ +pub const XKB_KEY_onesixth :u32 = 0x0ab6; /* U+2159 VULGAR FRACTION ONE SIXTH */ +pub const XKB_KEY_fivesixths :u32 = 0x0ab7; /* U+215A VULGAR FRACTION FIVE SIXTHS */ +pub const XKB_KEY_careof :u32 = 0x0ab8; /* U+2105 CARE OF */ +pub const XKB_KEY_figdash :u32 = 0x0abb; /* U+2012 FIGURE DASH */ +pub const XKB_KEY_leftanglebracket :u32 = 0x0abc; /*(U+27E8 MATHEMATICAL LEFT ANGLE BRACKET)*/ +pub const XKB_KEY_decimalpoint :u32 = 0x0abd; /*(U+002E FULL STOP)*/ +pub const XKB_KEY_rightanglebracket :u32 = 0x0abe; /*(U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET)*/ +pub const XKB_KEY_marker :u32 = 0x0abf; +pub const XKB_KEY_oneeighth :u32 = 0x0ac3; /* U+215B VULGAR FRACTION ONE EIGHTH */ +pub const XKB_KEY_threeeighths :u32 = 0x0ac4; /* U+215C VULGAR FRACTION THREE EIGHTHS */ +pub const XKB_KEY_fiveeighths :u32 = 0x0ac5; /* U+215D VULGAR FRACTION FIVE EIGHTHS */ +pub const XKB_KEY_seveneighths :u32 = 0x0ac6; /* U+215E VULGAR FRACTION SEVEN EIGHTHS */ +pub const XKB_KEY_trademark :u32 = 0x0ac9; /* U+2122 TRADE MARK SIGN */ +pub const XKB_KEY_signaturemark :u32 = 0x0aca; /*(U+2613 SALTIRE)*/ +pub const XKB_KEY_trademarkincircle :u32 = 0x0acb; +pub const XKB_KEY_leftopentriangle :u32 = 0x0acc; /*(U+25C1 WHITE LEFT-POINTING TRIANGLE)*/ +pub const XKB_KEY_rightopentriangle :u32 = 0x0acd; /*(U+25B7 WHITE RIGHT-POINTING TRIANGLE)*/ +pub const XKB_KEY_emopencircle :u32 = 0x0ace; /*(U+25CB WHITE CIRCLE)*/ +pub const XKB_KEY_emopenrectangle :u32 = 0x0acf; /*(U+25AF WHITE VERTICAL RECTANGLE)*/ +pub const XKB_KEY_leftsinglequotemark :u32 = 0x0ad0; /* U+2018 LEFT SINGLE QUOTATION MARK */ +pub const XKB_KEY_rightsinglequotemark :u32 = 0x0ad1; /* U+2019 RIGHT SINGLE QUOTATION MARK */ +pub const XKB_KEY_leftdoublequotemark :u32 = 0x0ad2; /* U+201C LEFT DOUBLE QUOTATION MARK */ +pub const XKB_KEY_rightdoublequotemark :u32 = 0x0ad3; /* U+201D RIGHT DOUBLE QUOTATION MARK */ +pub const XKB_KEY_prescription :u32 = 0x0ad4; /* U+211E PRESCRIPTION TAKE */ +pub const XKB_KEY_permille :u32 = 0x0ad5; /* U+2030 PER MILLE SIGN */ +pub const XKB_KEY_minutes :u32 = 0x0ad6; /* U+2032 PRIME */ +pub const XKB_KEY_seconds :u32 = 0x0ad7; /* U+2033 DOUBLE PRIME */ +pub const XKB_KEY_latincross :u32 = 0x0ad9; /* U+271D LATIN CROSS */ +pub const XKB_KEY_hexagram :u32 = 0x0ada; +pub const XKB_KEY_filledrectbullet :u32 = 0x0adb; /*(U+25AC BLACK RECTANGLE)*/ +pub const XKB_KEY_filledlefttribullet :u32 = 0x0adc; /*(U+25C0 BLACK LEFT-POINTING TRIANGLE)*/ +pub const XKB_KEY_filledrighttribullet :u32 = 0x0add; /*(U+25B6 BLACK RIGHT-POINTING TRIANGLE)*/ +pub const XKB_KEY_emfilledcircle :u32 = 0x0ade; /*(U+25CF BLACK CIRCLE)*/ +pub const XKB_KEY_emfilledrect :u32 = 0x0adf; /*(U+25AE BLACK VERTICAL RECTANGLE)*/ +pub const XKB_KEY_enopencircbullet :u32 = 0x0ae0; /*(U+25E6 WHITE BULLET)*/ +pub const XKB_KEY_enopensquarebullet :u32 = 0x0ae1; /*(U+25AB WHITE SMALL SQUARE)*/ +pub const XKB_KEY_openrectbullet :u32 = 0x0ae2; /*(U+25AD WHITE RECTANGLE)*/ +pub const XKB_KEY_opentribulletup :u32 = 0x0ae3; /*(U+25B3 WHITE UP-POINTING TRIANGLE)*/ +pub const XKB_KEY_opentribulletdown :u32 = 0x0ae4; /*(U+25BD WHITE DOWN-POINTING TRIANGLE)*/ +pub const XKB_KEY_openstar :u32 = 0x0ae5; /*(U+2606 WHITE STAR)*/ +pub const XKB_KEY_enfilledcircbullet :u32 = 0x0ae6; /*(U+2022 BULLET)*/ +pub const XKB_KEY_enfilledsqbullet :u32 = 0x0ae7; /*(U+25AA BLACK SMALL SQUARE)*/ +pub const XKB_KEY_filledtribulletup :u32 = 0x0ae8; /*(U+25B2 BLACK UP-POINTING TRIANGLE)*/ +pub const XKB_KEY_filledtribulletdown :u32 = 0x0ae9; /*(U+25BC BLACK DOWN-POINTING TRIANGLE)*/ +pub const XKB_KEY_leftpointer :u32 = 0x0aea; /*(U+261C WHITE LEFT POINTING INDEX)*/ +pub const XKB_KEY_rightpointer :u32 = 0x0aeb; /*(U+261E WHITE RIGHT POINTING INDEX)*/ +pub const XKB_KEY_club :u32 = 0x0aec; /* U+2663 BLACK CLUB SUIT */ +pub const XKB_KEY_diamond :u32 = 0x0aed; /* U+2666 BLACK DIAMOND SUIT */ +pub const XKB_KEY_heart :u32 = 0x0aee; /* U+2665 BLACK HEART SUIT */ +pub const XKB_KEY_maltesecross :u32 = 0x0af0; /* U+2720 MALTESE CROSS */ +pub const XKB_KEY_dagger :u32 = 0x0af1; /* U+2020 DAGGER */ +pub const XKB_KEY_doubledagger :u32 = 0x0af2; /* U+2021 DOUBLE DAGGER */ +pub const XKB_KEY_checkmark :u32 = 0x0af3; /* U+2713 CHECK MARK */ +pub const XKB_KEY_ballotcross :u32 = 0x0af4; /* U+2717 BALLOT X */ +pub const XKB_KEY_musicalsharp :u32 = 0x0af5; /* U+266F MUSIC SHARP SIGN */ +pub const XKB_KEY_musicalflat :u32 = 0x0af6; /* U+266D MUSIC FLAT SIGN */ +pub const XKB_KEY_malesymbol :u32 = 0x0af7; /* U+2642 MALE SIGN */ +pub const XKB_KEY_femalesymbol :u32 = 0x0af8; /* U+2640 FEMALE SIGN */ +pub const XKB_KEY_telephone :u32 = 0x0af9; /* U+260E BLACK TELEPHONE */ +pub const XKB_KEY_telephonerecorder :u32 = 0x0afa; /* U+2315 TELEPHONE RECORDER */ +pub const XKB_KEY_phonographcopyright :u32 = 0x0afb; /* U+2117 SOUND RECORDING COPYRIGHT */ +pub const XKB_KEY_caret :u32 = 0x0afc; /* U+2038 CARET */ +pub const XKB_KEY_singlelowquotemark :u32 = 0x0afd; /* U+201A SINGLE LOW-9 QUOTATION MARK */ +pub const XKB_KEY_doublelowquotemark :u32 = 0x0afe; /* U+201E DOUBLE LOW-9 QUOTATION MARK */ +pub const XKB_KEY_cursor :u32 = 0x0aff; + +/* + * APL + * Byte 3 = :u32 = 0x0b; + */ + +pub const XKB_KEY_leftcaret :u32 = 0x0ba3; /*(U+003C LESS-THAN SIGN)*/ +pub const XKB_KEY_rightcaret :u32 = 0x0ba6; /*(U+003E GREATER-THAN SIGN)*/ +pub const XKB_KEY_downcaret :u32 = 0x0ba8; /*(U+2228 LOGICAL OR)*/ +pub const XKB_KEY_upcaret :u32 = 0x0ba9; /*(U+2227 LOGICAL AND)*/ +pub const XKB_KEY_overbar :u32 = 0x0bc0; /*(U+00AF MACRON)*/ +pub const XKB_KEY_downtack :u32 = 0x0bc2; /* U+22A4 DOWN TACK */ +pub const XKB_KEY_upshoe :u32 = 0x0bc3; /*(U+2229 INTERSECTION)*/ +pub const XKB_KEY_downstile :u32 = 0x0bc4; /* U+230A LEFT FLOOR */ +pub const XKB_KEY_underbar :u32 = 0x0bc6; /*(U+005F LOW LINE)*/ +pub const XKB_KEY_jot :u32 = 0x0bca; /* U+2218 RING OPERATOR */ +pub const XKB_KEY_quad :u32 = 0x0bcc; /* U+2395 APL FUNCTIONAL SYMBOL QUAD */ +pub const XKB_KEY_uptack :u32 = 0x0bce; /* U+22A5 UP TACK */ +pub const XKB_KEY_circle :u32 = 0x0bcf; /* U+25CB WHITE CIRCLE */ +pub const XKB_KEY_upstile :u32 = 0x0bd3; /* U+2308 LEFT CEILING */ +pub const XKB_KEY_downshoe :u32 = 0x0bd6; /*(U+222A UNION)*/ +pub const XKB_KEY_rightshoe :u32 = 0x0bd8; /*(U+2283 SUPERSET OF)*/ +pub const XKB_KEY_leftshoe :u32 = 0x0bda; /*(U+2282 SUBSET OF)*/ +pub const XKB_KEY_lefttack :u32 = 0x0bdc; /* U+22A3 LEFT TACK */ +pub const XKB_KEY_righttack :u32 = 0x0bfc; /* U+22A2 RIGHT TACK */ + +/* + * Hebrew + * Byte 3 = :u32 = 0x0c; + */ + +pub const XKB_KEY_hebrew_doublelowline :u32 = 0x0cdf; /* U+2017 DOUBLE LOW LINE */ +pub const XKB_KEY_hebrew_aleph :u32 = 0x0ce0; /* U+05D0 HEBREW LETTER ALEF */ +pub const XKB_KEY_hebrew_bet :u32 = 0x0ce1; /* U+05D1 HEBREW LETTER BET */ +pub const XKB_KEY_hebrew_beth :u32 = 0x0ce1; /* deprecated */ +pub const XKB_KEY_hebrew_gimel :u32 = 0x0ce2; /* U+05D2 HEBREW LETTER GIMEL */ +pub const XKB_KEY_hebrew_gimmel :u32 = 0x0ce2; /* deprecated */ +pub const XKB_KEY_hebrew_dalet :u32 = 0x0ce3; /* U+05D3 HEBREW LETTER DALET */ +pub const XKB_KEY_hebrew_daleth :u32 = 0x0ce3; /* deprecated */ +pub const XKB_KEY_hebrew_he :u32 = 0x0ce4; /* U+05D4 HEBREW LETTER HE */ +pub const XKB_KEY_hebrew_waw :u32 = 0x0ce5; /* U+05D5 HEBREW LETTER VAV */ +pub const XKB_KEY_hebrew_zain :u32 = 0x0ce6; /* U+05D6 HEBREW LETTER ZAYIN */ +pub const XKB_KEY_hebrew_zayin :u32 = 0x0ce6; /* deprecated */ +pub const XKB_KEY_hebrew_chet :u32 = 0x0ce7; /* U+05D7 HEBREW LETTER HET */ +pub const XKB_KEY_hebrew_het :u32 = 0x0ce7; /* deprecated */ +pub const XKB_KEY_hebrew_tet :u32 = 0x0ce8; /* U+05D8 HEBREW LETTER TET */ +pub const XKB_KEY_hebrew_teth :u32 = 0x0ce8; /* deprecated */ +pub const XKB_KEY_hebrew_yod :u32 = 0x0ce9; /* U+05D9 HEBREW LETTER YOD */ +pub const XKB_KEY_hebrew_finalkaph :u32 = 0x0cea; /* U+05DA HEBREW LETTER FINAL KAF */ +pub const XKB_KEY_hebrew_kaph :u32 = 0x0ceb; /* U+05DB HEBREW LETTER KAF */ +pub const XKB_KEY_hebrew_lamed :u32 = 0x0cec; /* U+05DC HEBREW LETTER LAMED */ +pub const XKB_KEY_hebrew_finalmem :u32 = 0x0ced; /* U+05DD HEBREW LETTER FINAL MEM */ +pub const XKB_KEY_hebrew_mem :u32 = 0x0cee; /* U+05DE HEBREW LETTER MEM */ +pub const XKB_KEY_hebrew_finalnun :u32 = 0x0cef; /* U+05DF HEBREW LETTER FINAL NUN */ +pub const XKB_KEY_hebrew_nun :u32 = 0x0cf0; /* U+05E0 HEBREW LETTER NUN */ +pub const XKB_KEY_hebrew_samech :u32 = 0x0cf1; /* U+05E1 HEBREW LETTER SAMEKH */ +pub const XKB_KEY_hebrew_samekh :u32 = 0x0cf1; /* deprecated */ +pub const XKB_KEY_hebrew_ayin :u32 = 0x0cf2; /* U+05E2 HEBREW LETTER AYIN */ +pub const XKB_KEY_hebrew_finalpe :u32 = 0x0cf3; /* U+05E3 HEBREW LETTER FINAL PE */ +pub const XKB_KEY_hebrew_pe :u32 = 0x0cf4; /* U+05E4 HEBREW LETTER PE */ +pub const XKB_KEY_hebrew_finalzade :u32 = 0x0cf5; /* U+05E5 HEBREW LETTER FINAL TSADI */ +pub const XKB_KEY_hebrew_finalzadi :u32 = 0x0cf5; /* deprecated */ +pub const XKB_KEY_hebrew_zade :u32 = 0x0cf6; /* U+05E6 HEBREW LETTER TSADI */ +pub const XKB_KEY_hebrew_zadi :u32 = 0x0cf6; /* deprecated */ +pub const XKB_KEY_hebrew_qoph :u32 = 0x0cf7; /* U+05E7 HEBREW LETTER QOF */ +pub const XKB_KEY_hebrew_kuf :u32 = 0x0cf7; /* deprecated */ +pub const XKB_KEY_hebrew_resh :u32 = 0x0cf8; /* U+05E8 HEBREW LETTER RESH */ +pub const XKB_KEY_hebrew_shin :u32 = 0x0cf9; /* U+05E9 HEBREW LETTER SHIN */ +pub const XKB_KEY_hebrew_taw :u32 = 0x0cfa; /* U+05EA HEBREW LETTER TAV */ +pub const XKB_KEY_hebrew_taf :u32 = 0x0cfa; /* deprecated */ +pub const XKB_KEY_Hebrew_switch :u32 = 0xff7e; /* Alias for mode_switch */ + +/* + * Thai + * Byte 3 = :u32 = 0x0d; + */ + +pub const XKB_KEY_Thai_kokai :u32 = 0x0da1; /* U+0E01 THAI CHARACTER KO KAI */ +pub const XKB_KEY_Thai_khokhai :u32 = 0x0da2; /* U+0E02 THAI CHARACTER KHO KHAI */ +pub const XKB_KEY_Thai_khokhuat :u32 = 0x0da3; /* U+0E03 THAI CHARACTER KHO KHUAT */ +pub const XKB_KEY_Thai_khokhwai :u32 = 0x0da4; /* U+0E04 THAI CHARACTER KHO KHWAI */ +pub const XKB_KEY_Thai_khokhon :u32 = 0x0da5; /* U+0E05 THAI CHARACTER KHO KHON */ +pub const XKB_KEY_Thai_khorakhang :u32 = 0x0da6; /* U+0E06 THAI CHARACTER KHO RAKHANG */ +pub const XKB_KEY_Thai_ngongu :u32 = 0x0da7; /* U+0E07 THAI CHARACTER NGO NGU */ +pub const XKB_KEY_Thai_chochan :u32 = 0x0da8; /* U+0E08 THAI CHARACTER CHO CHAN */ +pub const XKB_KEY_Thai_choching :u32 = 0x0da9; /* U+0E09 THAI CHARACTER CHO CHING */ +pub const XKB_KEY_Thai_chochang :u32 = 0x0daa; /* U+0E0A THAI CHARACTER CHO CHANG */ +pub const XKB_KEY_Thai_soso :u32 = 0x0dab; /* U+0E0B THAI CHARACTER SO SO */ +pub const XKB_KEY_Thai_chochoe :u32 = 0x0dac; /* U+0E0C THAI CHARACTER CHO CHOE */ +pub const XKB_KEY_Thai_yoying :u32 = 0x0dad; /* U+0E0D THAI CHARACTER YO YING */ +pub const XKB_KEY_Thai_dochada :u32 = 0x0dae; /* U+0E0E THAI CHARACTER DO CHADA */ +pub const XKB_KEY_Thai_topatak :u32 = 0x0daf; /* U+0E0F THAI CHARACTER TO PATAK */ +pub const XKB_KEY_Thai_thothan :u32 = 0x0db0; /* U+0E10 THAI CHARACTER THO THAN */ +pub const XKB_KEY_Thai_thonangmontho :u32 = 0x0db1; /* U+0E11 THAI CHARACTER THO NANGMONTHO */ +pub const XKB_KEY_Thai_thophuthao :u32 = 0x0db2; /* U+0E12 THAI CHARACTER THO PHUTHAO */ +pub const XKB_KEY_Thai_nonen :u32 = 0x0db3; /* U+0E13 THAI CHARACTER NO NEN */ +pub const XKB_KEY_Thai_dodek :u32 = 0x0db4; /* U+0E14 THAI CHARACTER DO DEK */ +pub const XKB_KEY_Thai_totao :u32 = 0x0db5; /* U+0E15 THAI CHARACTER TO TAO */ +pub const XKB_KEY_Thai_thothung :u32 = 0x0db6; /* U+0E16 THAI CHARACTER THO THUNG */ +pub const XKB_KEY_Thai_thothahan :u32 = 0x0db7; /* U+0E17 THAI CHARACTER THO THAHAN */ +pub const XKB_KEY_Thai_thothong :u32 = 0x0db8; /* U+0E18 THAI CHARACTER THO THONG */ +pub const XKB_KEY_Thai_nonu :u32 = 0x0db9; /* U+0E19 THAI CHARACTER NO NU */ +pub const XKB_KEY_Thai_bobaimai :u32 = 0x0dba; /* U+0E1A THAI CHARACTER BO BAIMAI */ +pub const XKB_KEY_Thai_popla :u32 = 0x0dbb; /* U+0E1B THAI CHARACTER PO PLA */ +pub const XKB_KEY_Thai_phophung :u32 = 0x0dbc; /* U+0E1C THAI CHARACTER PHO PHUNG */ +pub const XKB_KEY_Thai_fofa :u32 = 0x0dbd; /* U+0E1D THAI CHARACTER FO FA */ +pub const XKB_KEY_Thai_phophan :u32 = 0x0dbe; /* U+0E1E THAI CHARACTER PHO PHAN */ +pub const XKB_KEY_Thai_fofan :u32 = 0x0dbf; /* U+0E1F THAI CHARACTER FO FAN */ +pub const XKB_KEY_Thai_phosamphao :u32 = 0x0dc0; /* U+0E20 THAI CHARACTER PHO SAMPHAO */ +pub const XKB_KEY_Thai_moma :u32 = 0x0dc1; /* U+0E21 THAI CHARACTER MO MA */ +pub const XKB_KEY_Thai_yoyak :u32 = 0x0dc2; /* U+0E22 THAI CHARACTER YO YAK */ +pub const XKB_KEY_Thai_rorua :u32 = 0x0dc3; /* U+0E23 THAI CHARACTER RO RUA */ +pub const XKB_KEY_Thai_ru :u32 = 0x0dc4; /* U+0E24 THAI CHARACTER RU */ +pub const XKB_KEY_Thai_loling :u32 = 0x0dc5; /* U+0E25 THAI CHARACTER LO LING */ +pub const XKB_KEY_Thai_lu :u32 = 0x0dc6; /* U+0E26 THAI CHARACTER LU */ +pub const XKB_KEY_Thai_wowaen :u32 = 0x0dc7; /* U+0E27 THAI CHARACTER WO WAEN */ +pub const XKB_KEY_Thai_sosala :u32 = 0x0dc8; /* U+0E28 THAI CHARACTER SO SALA */ +pub const XKB_KEY_Thai_sorusi :u32 = 0x0dc9; /* U+0E29 THAI CHARACTER SO RUSI */ +pub const XKB_KEY_Thai_sosua :u32 = 0x0dca; /* U+0E2A THAI CHARACTER SO SUA */ +pub const XKB_KEY_Thai_hohip :u32 = 0x0dcb; /* U+0E2B THAI CHARACTER HO HIP */ +pub const XKB_KEY_Thai_lochula :u32 = 0x0dcc; /* U+0E2C THAI CHARACTER LO CHULA */ +pub const XKB_KEY_Thai_oang :u32 = 0x0dcd; /* U+0E2D THAI CHARACTER O ANG */ +pub const XKB_KEY_Thai_honokhuk :u32 = 0x0dce; /* U+0E2E THAI CHARACTER HO NOKHUK */ +pub const XKB_KEY_Thai_paiyannoi :u32 = 0x0dcf; /* U+0E2F THAI CHARACTER PAIYANNOI */ +pub const XKB_KEY_Thai_saraa :u32 = 0x0dd0; /* U+0E30 THAI CHARACTER SARA A */ +pub const XKB_KEY_Thai_maihanakat :u32 = 0x0dd1; /* U+0E31 THAI CHARACTER MAI HAN-AKAT */ +pub const XKB_KEY_Thai_saraaa :u32 = 0x0dd2; /* U+0E32 THAI CHARACTER SARA AA */ +pub const XKB_KEY_Thai_saraam :u32 = 0x0dd3; /* U+0E33 THAI CHARACTER SARA AM */ +pub const XKB_KEY_Thai_sarai :u32 = 0x0dd4; /* U+0E34 THAI CHARACTER SARA I */ +pub const XKB_KEY_Thai_saraii :u32 = 0x0dd5; /* U+0E35 THAI CHARACTER SARA II */ +pub const XKB_KEY_Thai_saraue :u32 = 0x0dd6; /* U+0E36 THAI CHARACTER SARA UE */ +pub const XKB_KEY_Thai_sarauee :u32 = 0x0dd7; /* U+0E37 THAI CHARACTER SARA UEE */ +pub const XKB_KEY_Thai_sarau :u32 = 0x0dd8; /* U+0E38 THAI CHARACTER SARA U */ +pub const XKB_KEY_Thai_sarauu :u32 = 0x0dd9; /* U+0E39 THAI CHARACTER SARA UU */ +pub const XKB_KEY_Thai_phinthu :u32 = 0x0dda; /* U+0E3A THAI CHARACTER PHINTHU */ +pub const XKB_KEY_Thai_maihanakat_maitho :u32 = 0x0dde; +pub const XKB_KEY_Thai_baht :u32 = 0x0ddf; /* U+0E3F THAI CURRENCY SYMBOL BAHT */ +pub const XKB_KEY_Thai_sarae :u32 = 0x0de0; /* U+0E40 THAI CHARACTER SARA E */ +pub const XKB_KEY_Thai_saraae :u32 = 0x0de1; /* U+0E41 THAI CHARACTER SARA AE */ +pub const XKB_KEY_Thai_sarao :u32 = 0x0de2; /* U+0E42 THAI CHARACTER SARA O */ +pub const XKB_KEY_Thai_saraaimaimuan :u32 = 0x0de3; /* U+0E43 THAI CHARACTER SARA AI MAIMUAN */ +pub const XKB_KEY_Thai_saraaimaimalai :u32 = 0x0de4; /* U+0E44 THAI CHARACTER SARA AI MAIMALAI */ +pub const XKB_KEY_Thai_lakkhangyao :u32 = 0x0de5; /* U+0E45 THAI CHARACTER LAKKHANGYAO */ +pub const XKB_KEY_Thai_maiyamok :u32 = 0x0de6; /* U+0E46 THAI CHARACTER MAIYAMOK */ +pub const XKB_KEY_Thai_maitaikhu :u32 = 0x0de7; /* U+0E47 THAI CHARACTER MAITAIKHU */ +pub const XKB_KEY_Thai_maiek :u32 = 0x0de8; /* U+0E48 THAI CHARACTER MAI EK */ +pub const XKB_KEY_Thai_maitho :u32 = 0x0de9; /* U+0E49 THAI CHARACTER MAI THO */ +pub const XKB_KEY_Thai_maitri :u32 = 0x0dea; /* U+0E4A THAI CHARACTER MAI TRI */ +pub const XKB_KEY_Thai_maichattawa :u32 = 0x0deb; /* U+0E4B THAI CHARACTER MAI CHATTAWA */ +pub const XKB_KEY_Thai_thanthakhat :u32 = 0x0dec; /* U+0E4C THAI CHARACTER THANTHAKHAT */ +pub const XKB_KEY_Thai_nikhahit :u32 = 0x0ded; /* U+0E4D THAI CHARACTER NIKHAHIT */ +pub const XKB_KEY_Thai_leksun :u32 = 0x0df0; /* U+0E50 THAI DIGIT ZERO */ +pub const XKB_KEY_Thai_leknung :u32 = 0x0df1; /* U+0E51 THAI DIGIT ONE */ +pub const XKB_KEY_Thai_leksong :u32 = 0x0df2; /* U+0E52 THAI DIGIT TWO */ +pub const XKB_KEY_Thai_leksam :u32 = 0x0df3; /* U+0E53 THAI DIGIT THREE */ +pub const XKB_KEY_Thai_leksi :u32 = 0x0df4; /* U+0E54 THAI DIGIT FOUR */ +pub const XKB_KEY_Thai_lekha :u32 = 0x0df5; /* U+0E55 THAI DIGIT FIVE */ +pub const XKB_KEY_Thai_lekhok :u32 = 0x0df6; /* U+0E56 THAI DIGIT SIX */ +pub const XKB_KEY_Thai_lekchet :u32 = 0x0df7; /* U+0E57 THAI DIGIT SEVEN */ +pub const XKB_KEY_Thai_lekpaet :u32 = 0x0df8; /* U+0E58 THAI DIGIT EIGHT */ +pub const XKB_KEY_Thai_lekkao :u32 = 0x0df9; /* U+0E59 THAI DIGIT NINE */ + +/* + * Korean + * Byte 3 = :u32 = 0x0e; + */ + + +pub const XKB_KEY_Hangul :u32 = 0xff31; /* Hangul start/stop(toggle) */ +pub const XKB_KEY_Hangul_Start :u32 = 0xff32; /* Hangul start */ +pub const XKB_KEY_Hangul_End :u32 = 0xff33; /* Hangul end, English start */ +pub const XKB_KEY_Hangul_Hanja :u32 = 0xff34; /* Start Hangul->Hanja Conversion */ +pub const XKB_KEY_Hangul_Jamo :u32 = 0xff35; /* Hangul Jamo mode */ +pub const XKB_KEY_Hangul_Romaja :u32 = 0xff36; /* Hangul Romaja mode */ +pub const XKB_KEY_Hangul_Codeinput :u32 = 0xff37; /* Hangul code input mode */ +pub const XKB_KEY_Hangul_Jeonja :u32 = 0xff38; /* Jeonja mode */ +pub const XKB_KEY_Hangul_Banja :u32 = 0xff39; /* Banja mode */ +pub const XKB_KEY_Hangul_PreHanja :u32 = 0xff3a; /* Pre Hanja conversion */ +pub const XKB_KEY_Hangul_PostHanja :u32 = 0xff3b; /* Post Hanja conversion */ +pub const XKB_KEY_Hangul_SingleCandidate :u32 = 0xff3c; /* Single candidate */ +pub const XKB_KEY_Hangul_MultipleCandidate :u32 = 0xff3d; /* Multiple candidate */ +pub const XKB_KEY_Hangul_PreviousCandidate :u32 = 0xff3e; /* Previous candidate */ +pub const XKB_KEY_Hangul_Special :u32 = 0xff3f; /* Special symbols */ +pub const XKB_KEY_Hangul_switch :u32 = 0xff7e; /* Alias for mode_switch */ + +/* Hangul Consonant Characters */ +pub const XKB_KEY_Hangul_Kiyeog :u32 = 0x0ea1; +pub const XKB_KEY_Hangul_SsangKiyeog :u32 = 0x0ea2; +pub const XKB_KEY_Hangul_KiyeogSios :u32 = 0x0ea3; +pub const XKB_KEY_Hangul_Nieun :u32 = 0x0ea4; +pub const XKB_KEY_Hangul_NieunJieuj :u32 = 0x0ea5; +pub const XKB_KEY_Hangul_NieunHieuh :u32 = 0x0ea6; +pub const XKB_KEY_Hangul_Dikeud :u32 = 0x0ea7; +pub const XKB_KEY_Hangul_SsangDikeud :u32 = 0x0ea8; +pub const XKB_KEY_Hangul_Rieul :u32 = 0x0ea9; +pub const XKB_KEY_Hangul_RieulKiyeog :u32 = 0x0eaa; +pub const XKB_KEY_Hangul_RieulMieum :u32 = 0x0eab; +pub const XKB_KEY_Hangul_RieulPieub :u32 = 0x0eac; +pub const XKB_KEY_Hangul_RieulSios :u32 = 0x0ead; +pub const XKB_KEY_Hangul_RieulTieut :u32 = 0x0eae; +pub const XKB_KEY_Hangul_RieulPhieuf :u32 = 0x0eaf; +pub const XKB_KEY_Hangul_RieulHieuh :u32 = 0x0eb0; +pub const XKB_KEY_Hangul_Mieum :u32 = 0x0eb1; +pub const XKB_KEY_Hangul_Pieub :u32 = 0x0eb2; +pub const XKB_KEY_Hangul_SsangPieub :u32 = 0x0eb3; +pub const XKB_KEY_Hangul_PieubSios :u32 = 0x0eb4; +pub const XKB_KEY_Hangul_Sios :u32 = 0x0eb5; +pub const XKB_KEY_Hangul_SsangSios :u32 = 0x0eb6; +pub const XKB_KEY_Hangul_Ieung :u32 = 0x0eb7; +pub const XKB_KEY_Hangul_Jieuj :u32 = 0x0eb8; +pub const XKB_KEY_Hangul_SsangJieuj :u32 = 0x0eb9; +pub const XKB_KEY_Hangul_Cieuc :u32 = 0x0eba; +pub const XKB_KEY_Hangul_Khieuq :u32 = 0x0ebb; +pub const XKB_KEY_Hangul_Tieut :u32 = 0x0ebc; +pub const XKB_KEY_Hangul_Phieuf :u32 = 0x0ebd; +pub const XKB_KEY_Hangul_Hieuh :u32 = 0x0ebe; + +/* Hangul Vowel Characters */ +pub const XKB_KEY_Hangul_A :u32 = 0x0ebf; +pub const XKB_KEY_Hangul_AE :u32 = 0x0ec0; +pub const XKB_KEY_Hangul_YA :u32 = 0x0ec1; +pub const XKB_KEY_Hangul_YAE :u32 = 0x0ec2; +pub const XKB_KEY_Hangul_EO :u32 = 0x0ec3; +pub const XKB_KEY_Hangul_E :u32 = 0x0ec4; +pub const XKB_KEY_Hangul_YEO :u32 = 0x0ec5; +pub const XKB_KEY_Hangul_YE :u32 = 0x0ec6; +pub const XKB_KEY_Hangul_O :u32 = 0x0ec7; +pub const XKB_KEY_Hangul_WA :u32 = 0x0ec8; +pub const XKB_KEY_Hangul_WAE :u32 = 0x0ec9; +pub const XKB_KEY_Hangul_OE :u32 = 0x0eca; +pub const XKB_KEY_Hangul_YO :u32 = 0x0ecb; +pub const XKB_KEY_Hangul_U :u32 = 0x0ecc; +pub const XKB_KEY_Hangul_WEO :u32 = 0x0ecd; +pub const XKB_KEY_Hangul_WE :u32 = 0x0ece; +pub const XKB_KEY_Hangul_WI :u32 = 0x0ecf; +pub const XKB_KEY_Hangul_YU :u32 = 0x0ed0; +pub const XKB_KEY_Hangul_EU :u32 = 0x0ed1; +pub const XKB_KEY_Hangul_YI :u32 = 0x0ed2; +pub const XKB_KEY_Hangul_I :u32 = 0x0ed3; + +/* Hangul syllable-final (JongSeong) Characters */ +pub const XKB_KEY_Hangul_J_Kiyeog :u32 = 0x0ed4; +pub const XKB_KEY_Hangul_J_SsangKiyeog :u32 = 0x0ed5; +pub const XKB_KEY_Hangul_J_KiyeogSios :u32 = 0x0ed6; +pub const XKB_KEY_Hangul_J_Nieun :u32 = 0x0ed7; +pub const XKB_KEY_Hangul_J_NieunJieuj :u32 = 0x0ed8; +pub const XKB_KEY_Hangul_J_NieunHieuh :u32 = 0x0ed9; +pub const XKB_KEY_Hangul_J_Dikeud :u32 = 0x0eda; +pub const XKB_KEY_Hangul_J_Rieul :u32 = 0x0edb; +pub const XKB_KEY_Hangul_J_RieulKiyeog :u32 = 0x0edc; +pub const XKB_KEY_Hangul_J_RieulMieum :u32 = 0x0edd; +pub const XKB_KEY_Hangul_J_RieulPieub :u32 = 0x0ede; +pub const XKB_KEY_Hangul_J_RieulSios :u32 = 0x0edf; +pub const XKB_KEY_Hangul_J_RieulTieut :u32 = 0x0ee0; +pub const XKB_KEY_Hangul_J_RieulPhieuf :u32 = 0x0ee1; +pub const XKB_KEY_Hangul_J_RieulHieuh :u32 = 0x0ee2; +pub const XKB_KEY_Hangul_J_Mieum :u32 = 0x0ee3; +pub const XKB_KEY_Hangul_J_Pieub :u32 = 0x0ee4; +pub const XKB_KEY_Hangul_J_PieubSios :u32 = 0x0ee5; +pub const XKB_KEY_Hangul_J_Sios :u32 = 0x0ee6; +pub const XKB_KEY_Hangul_J_SsangSios :u32 = 0x0ee7; +pub const XKB_KEY_Hangul_J_Ieung :u32 = 0x0ee8; +pub const XKB_KEY_Hangul_J_Jieuj :u32 = 0x0ee9; +pub const XKB_KEY_Hangul_J_Cieuc :u32 = 0x0eea; +pub const XKB_KEY_Hangul_J_Khieuq :u32 = 0x0eeb; +pub const XKB_KEY_Hangul_J_Tieut :u32 = 0x0eec; +pub const XKB_KEY_Hangul_J_Phieuf :u32 = 0x0eed; +pub const XKB_KEY_Hangul_J_Hieuh :u32 = 0x0eee; + +/* Ancient Hangul Consonant Characters */ +pub const XKB_KEY_Hangul_RieulYeorinHieuh :u32 = 0x0eef; +pub const XKB_KEY_Hangul_SunkyeongeumMieum :u32 = 0x0ef0; +pub const XKB_KEY_Hangul_SunkyeongeumPieub :u32 = 0x0ef1; +pub const XKB_KEY_Hangul_PanSios :u32 = 0x0ef2; +pub const XKB_KEY_Hangul_KkogjiDalrinIeung :u32 = 0x0ef3; +pub const XKB_KEY_Hangul_SunkyeongeumPhieuf :u32 = 0x0ef4; +pub const XKB_KEY_Hangul_YeorinHieuh :u32 = 0x0ef5; + +/* Ancient Hangul Vowel Characters */ +pub const XKB_KEY_Hangul_AraeA :u32 = 0x0ef6; +pub const XKB_KEY_Hangul_AraeAE :u32 = 0x0ef7; + +/* Ancient Hangul syllable-final (JongSeong) Characters */ +pub const XKB_KEY_Hangul_J_PanSios :u32 = 0x0ef8; +pub const XKB_KEY_Hangul_J_KkogjiDalrinIeung :u32 = 0x0ef9; +pub const XKB_KEY_Hangul_J_YeorinHieuh :u32 = 0x0efa; + +/* Korean currency symbol */ +pub const XKB_KEY_Korean_Won :u32 = 0x0eff; /*(U+20A9 WON SIGN)*/ + + +/* + * Armenian + */ + +pub const XKB_KEY_Armenian_ligature_ew :u32 = 0x1000587; /* U+0587 ARMENIAN SMALL LIGATURE ECH YIWN */ +pub const XKB_KEY_Armenian_full_stop :u32 = 0x1000589; /* U+0589 ARMENIAN FULL STOP */ +pub const XKB_KEY_Armenian_verjaket :u32 = 0x1000589; /* U+0589 ARMENIAN FULL STOP */ +pub const XKB_KEY_Armenian_separation_mark :u32 = 0x100055d; /* U+055D ARMENIAN COMMA */ +pub const XKB_KEY_Armenian_but :u32 = 0x100055d; /* U+055D ARMENIAN COMMA */ +pub const XKB_KEY_Armenian_hyphen :u32 = 0x100058a; /* U+058A ARMENIAN HYPHEN */ +pub const XKB_KEY_Armenian_yentamna :u32 = 0x100058a; /* U+058A ARMENIAN HYPHEN */ +pub const XKB_KEY_Armenian_exclam :u32 = 0x100055c; /* U+055C ARMENIAN EXCLAMATION MARK */ +pub const XKB_KEY_Armenian_amanak :u32 = 0x100055c; /* U+055C ARMENIAN EXCLAMATION MARK */ +pub const XKB_KEY_Armenian_accent :u32 = 0x100055b; /* U+055B ARMENIAN EMPHASIS MARK */ +pub const XKB_KEY_Armenian_shesht :u32 = 0x100055b; /* U+055B ARMENIAN EMPHASIS MARK */ +pub const XKB_KEY_Armenian_question :u32 = 0x100055e; /* U+055E ARMENIAN QUESTION MARK */ +pub const XKB_KEY_Armenian_paruyk :u32 = 0x100055e; /* U+055E ARMENIAN QUESTION MARK */ +pub const XKB_KEY_Armenian_AYB :u32 = 0x1000531; /* U+0531 ARMENIAN CAPITAL LETTER AYB */ +pub const XKB_KEY_Armenian_ayb :u32 = 0x1000561; /* U+0561 ARMENIAN SMALL LETTER AYB */ +pub const XKB_KEY_Armenian_BEN :u32 = 0x1000532; /* U+0532 ARMENIAN CAPITAL LETTER BEN */ +pub const XKB_KEY_Armenian_ben :u32 = 0x1000562; /* U+0562 ARMENIAN SMALL LETTER BEN */ +pub const XKB_KEY_Armenian_GIM :u32 = 0x1000533; /* U+0533 ARMENIAN CAPITAL LETTER GIM */ +pub const XKB_KEY_Armenian_gim :u32 = 0x1000563; /* U+0563 ARMENIAN SMALL LETTER GIM */ +pub const XKB_KEY_Armenian_DA :u32 = 0x1000534; /* U+0534 ARMENIAN CAPITAL LETTER DA */ +pub const XKB_KEY_Armenian_da :u32 = 0x1000564; /* U+0564 ARMENIAN SMALL LETTER DA */ +pub const XKB_KEY_Armenian_YECH :u32 = 0x1000535; /* U+0535 ARMENIAN CAPITAL LETTER ECH */ +pub const XKB_KEY_Armenian_yech :u32 = 0x1000565; /* U+0565 ARMENIAN SMALL LETTER ECH */ +pub const XKB_KEY_Armenian_ZA :u32 = 0x1000536; /* U+0536 ARMENIAN CAPITAL LETTER ZA */ +pub const XKB_KEY_Armenian_za :u32 = 0x1000566; /* U+0566 ARMENIAN SMALL LETTER ZA */ +pub const XKB_KEY_Armenian_E :u32 = 0x1000537; /* U+0537 ARMENIAN CAPITAL LETTER EH */ +pub const XKB_KEY_Armenian_e :u32 = 0x1000567; /* U+0567 ARMENIAN SMALL LETTER EH */ +pub const XKB_KEY_Armenian_AT :u32 = 0x1000538; /* U+0538 ARMENIAN CAPITAL LETTER ET */ +pub const XKB_KEY_Armenian_at :u32 = 0x1000568; /* U+0568 ARMENIAN SMALL LETTER ET */ +pub const XKB_KEY_Armenian_TO :u32 = 0x1000539; /* U+0539 ARMENIAN CAPITAL LETTER TO */ +pub const XKB_KEY_Armenian_to :u32 = 0x1000569; /* U+0569 ARMENIAN SMALL LETTER TO */ +pub const XKB_KEY_Armenian_ZHE :u32 = 0x100053a; /* U+053A ARMENIAN CAPITAL LETTER ZHE */ +pub const XKB_KEY_Armenian_zhe :u32 = 0x100056a; /* U+056A ARMENIAN SMALL LETTER ZHE */ +pub const XKB_KEY_Armenian_INI :u32 = 0x100053b; /* U+053B ARMENIAN CAPITAL LETTER INI */ +pub const XKB_KEY_Armenian_ini :u32 = 0x100056b; /* U+056B ARMENIAN SMALL LETTER INI */ +pub const XKB_KEY_Armenian_LYUN :u32 = 0x100053c; /* U+053C ARMENIAN CAPITAL LETTER LIWN */ +pub const XKB_KEY_Armenian_lyun :u32 = 0x100056c; /* U+056C ARMENIAN SMALL LETTER LIWN */ +pub const XKB_KEY_Armenian_KHE :u32 = 0x100053d; /* U+053D ARMENIAN CAPITAL LETTER XEH */ +pub const XKB_KEY_Armenian_khe :u32 = 0x100056d; /* U+056D ARMENIAN SMALL LETTER XEH */ +pub const XKB_KEY_Armenian_TSA :u32 = 0x100053e; /* U+053E ARMENIAN CAPITAL LETTER CA */ +pub const XKB_KEY_Armenian_tsa :u32 = 0x100056e; /* U+056E ARMENIAN SMALL LETTER CA */ +pub const XKB_KEY_Armenian_KEN :u32 = 0x100053f; /* U+053F ARMENIAN CAPITAL LETTER KEN */ +pub const XKB_KEY_Armenian_ken :u32 = 0x100056f; /* U+056F ARMENIAN SMALL LETTER KEN */ +pub const XKB_KEY_Armenian_HO :u32 = 0x1000540; /* U+0540 ARMENIAN CAPITAL LETTER HO */ +pub const XKB_KEY_Armenian_ho :u32 = 0x1000570; /* U+0570 ARMENIAN SMALL LETTER HO */ +pub const XKB_KEY_Armenian_DZA :u32 = 0x1000541; /* U+0541 ARMENIAN CAPITAL LETTER JA */ +pub const XKB_KEY_Armenian_dza :u32 = 0x1000571; /* U+0571 ARMENIAN SMALL LETTER JA */ +pub const XKB_KEY_Armenian_GHAT :u32 = 0x1000542; /* U+0542 ARMENIAN CAPITAL LETTER GHAD */ +pub const XKB_KEY_Armenian_ghat :u32 = 0x1000572; /* U+0572 ARMENIAN SMALL LETTER GHAD */ +pub const XKB_KEY_Armenian_TCHE :u32 = 0x1000543; /* U+0543 ARMENIAN CAPITAL LETTER CHEH */ +pub const XKB_KEY_Armenian_tche :u32 = 0x1000573; /* U+0573 ARMENIAN SMALL LETTER CHEH */ +pub const XKB_KEY_Armenian_MEN :u32 = 0x1000544; /* U+0544 ARMENIAN CAPITAL LETTER MEN */ +pub const XKB_KEY_Armenian_men :u32 = 0x1000574; /* U+0574 ARMENIAN SMALL LETTER MEN */ +pub const XKB_KEY_Armenian_HI :u32 = 0x1000545; /* U+0545 ARMENIAN CAPITAL LETTER YI */ +pub const XKB_KEY_Armenian_hi :u32 = 0x1000575; /* U+0575 ARMENIAN SMALL LETTER YI */ +pub const XKB_KEY_Armenian_NU :u32 = 0x1000546; /* U+0546 ARMENIAN CAPITAL LETTER NOW */ +pub const XKB_KEY_Armenian_nu :u32 = 0x1000576; /* U+0576 ARMENIAN SMALL LETTER NOW */ +pub const XKB_KEY_Armenian_SHA :u32 = 0x1000547; /* U+0547 ARMENIAN CAPITAL LETTER SHA */ +pub const XKB_KEY_Armenian_sha :u32 = 0x1000577; /* U+0577 ARMENIAN SMALL LETTER SHA */ +pub const XKB_KEY_Armenian_VO :u32 = 0x1000548; /* U+0548 ARMENIAN CAPITAL LETTER VO */ +pub const XKB_KEY_Armenian_vo :u32 = 0x1000578; /* U+0578 ARMENIAN SMALL LETTER VO */ +pub const XKB_KEY_Armenian_CHA :u32 = 0x1000549; /* U+0549 ARMENIAN CAPITAL LETTER CHA */ +pub const XKB_KEY_Armenian_cha :u32 = 0x1000579; /* U+0579 ARMENIAN SMALL LETTER CHA */ +pub const XKB_KEY_Armenian_PE :u32 = 0x100054a; /* U+054A ARMENIAN CAPITAL LETTER PEH */ +pub const XKB_KEY_Armenian_pe :u32 = 0x100057a; /* U+057A ARMENIAN SMALL LETTER PEH */ +pub const XKB_KEY_Armenian_JE :u32 = 0x100054b; /* U+054B ARMENIAN CAPITAL LETTER JHEH */ +pub const XKB_KEY_Armenian_je :u32 = 0x100057b; /* U+057B ARMENIAN SMALL LETTER JHEH */ +pub const XKB_KEY_Armenian_RA :u32 = 0x100054c; /* U+054C ARMENIAN CAPITAL LETTER RA */ +pub const XKB_KEY_Armenian_ra :u32 = 0x100057c; /* U+057C ARMENIAN SMALL LETTER RA */ +pub const XKB_KEY_Armenian_SE :u32 = 0x100054d; /* U+054D ARMENIAN CAPITAL LETTER SEH */ +pub const XKB_KEY_Armenian_se :u32 = 0x100057d; /* U+057D ARMENIAN SMALL LETTER SEH */ +pub const XKB_KEY_Armenian_VEV :u32 = 0x100054e; /* U+054E ARMENIAN CAPITAL LETTER VEW */ +pub const XKB_KEY_Armenian_vev :u32 = 0x100057e; /* U+057E ARMENIAN SMALL LETTER VEW */ +pub const XKB_KEY_Armenian_TYUN :u32 = 0x100054f; /* U+054F ARMENIAN CAPITAL LETTER TIWN */ +pub const XKB_KEY_Armenian_tyun :u32 = 0x100057f; /* U+057F ARMENIAN SMALL LETTER TIWN */ +pub const XKB_KEY_Armenian_RE :u32 = 0x1000550; /* U+0550 ARMENIAN CAPITAL LETTER REH */ +pub const XKB_KEY_Armenian_re :u32 = 0x1000580; /* U+0580 ARMENIAN SMALL LETTER REH */ +pub const XKB_KEY_Armenian_TSO :u32 = 0x1000551; /* U+0551 ARMENIAN CAPITAL LETTER CO */ +pub const XKB_KEY_Armenian_tso :u32 = 0x1000581; /* U+0581 ARMENIAN SMALL LETTER CO */ +pub const XKB_KEY_Armenian_VYUN :u32 = 0x1000552; /* U+0552 ARMENIAN CAPITAL LETTER YIWN */ +pub const XKB_KEY_Armenian_vyun :u32 = 0x1000582; /* U+0582 ARMENIAN SMALL LETTER YIWN */ +pub const XKB_KEY_Armenian_PYUR :u32 = 0x1000553; /* U+0553 ARMENIAN CAPITAL LETTER PIWR */ +pub const XKB_KEY_Armenian_pyur :u32 = 0x1000583; /* U+0583 ARMENIAN SMALL LETTER PIWR */ +pub const XKB_KEY_Armenian_KE :u32 = 0x1000554; /* U+0554 ARMENIAN CAPITAL LETTER KEH */ +pub const XKB_KEY_Armenian_ke :u32 = 0x1000584; /* U+0584 ARMENIAN SMALL LETTER KEH */ +pub const XKB_KEY_Armenian_O :u32 = 0x1000555; /* U+0555 ARMENIAN CAPITAL LETTER OH */ +pub const XKB_KEY_Armenian_o :u32 = 0x1000585; /* U+0585 ARMENIAN SMALL LETTER OH */ +pub const XKB_KEY_Armenian_FE :u32 = 0x1000556; /* U+0556 ARMENIAN CAPITAL LETTER FEH */ +pub const XKB_KEY_Armenian_fe :u32 = 0x1000586; /* U+0586 ARMENIAN SMALL LETTER FEH */ +pub const XKB_KEY_Armenian_apostrophe :u32 = 0x100055a; /* U+055A ARMENIAN APOSTROPHE */ + +/* + * Georgian + */ + +pub const XKB_KEY_Georgian_an :u32 = 0x10010d0; /* U+10D0 GEORGIAN LETTER AN */ +pub const XKB_KEY_Georgian_ban :u32 = 0x10010d1; /* U+10D1 GEORGIAN LETTER BAN */ +pub const XKB_KEY_Georgian_gan :u32 = 0x10010d2; /* U+10D2 GEORGIAN LETTER GAN */ +pub const XKB_KEY_Georgian_don :u32 = 0x10010d3; /* U+10D3 GEORGIAN LETTER DON */ +pub const XKB_KEY_Georgian_en :u32 = 0x10010d4; /* U+10D4 GEORGIAN LETTER EN */ +pub const XKB_KEY_Georgian_vin :u32 = 0x10010d5; /* U+10D5 GEORGIAN LETTER VIN */ +pub const XKB_KEY_Georgian_zen :u32 = 0x10010d6; /* U+10D6 GEORGIAN LETTER ZEN */ +pub const XKB_KEY_Georgian_tan :u32 = 0x10010d7; /* U+10D7 GEORGIAN LETTER TAN */ +pub const XKB_KEY_Georgian_in :u32 = 0x10010d8; /* U+10D8 GEORGIAN LETTER IN */ +pub const XKB_KEY_Georgian_kan :u32 = 0x10010d9; /* U+10D9 GEORGIAN LETTER KAN */ +pub const XKB_KEY_Georgian_las :u32 = 0x10010da; /* U+10DA GEORGIAN LETTER LAS */ +pub const XKB_KEY_Georgian_man :u32 = 0x10010db; /* U+10DB GEORGIAN LETTER MAN */ +pub const XKB_KEY_Georgian_nar :u32 = 0x10010dc; /* U+10DC GEORGIAN LETTER NAR */ +pub const XKB_KEY_Georgian_on :u32 = 0x10010dd; /* U+10DD GEORGIAN LETTER ON */ +pub const XKB_KEY_Georgian_par :u32 = 0x10010de; /* U+10DE GEORGIAN LETTER PAR */ +pub const XKB_KEY_Georgian_zhar :u32 = 0x10010df; /* U+10DF GEORGIAN LETTER ZHAR */ +pub const XKB_KEY_Georgian_rae :u32 = 0x10010e0; /* U+10E0 GEORGIAN LETTER RAE */ +pub const XKB_KEY_Georgian_san :u32 = 0x10010e1; /* U+10E1 GEORGIAN LETTER SAN */ +pub const XKB_KEY_Georgian_tar :u32 = 0x10010e2; /* U+10E2 GEORGIAN LETTER TAR */ +pub const XKB_KEY_Georgian_un :u32 = 0x10010e3; /* U+10E3 GEORGIAN LETTER UN */ +pub const XKB_KEY_Georgian_phar :u32 = 0x10010e4; /* U+10E4 GEORGIAN LETTER PHAR */ +pub const XKB_KEY_Georgian_khar :u32 = 0x10010e5; /* U+10E5 GEORGIAN LETTER KHAR */ +pub const XKB_KEY_Georgian_ghan :u32 = 0x10010e6; /* U+10E6 GEORGIAN LETTER GHAN */ +pub const XKB_KEY_Georgian_qar :u32 = 0x10010e7; /* U+10E7 GEORGIAN LETTER QAR */ +pub const XKB_KEY_Georgian_shin :u32 = 0x10010e8; /* U+10E8 GEORGIAN LETTER SHIN */ +pub const XKB_KEY_Georgian_chin :u32 = 0x10010e9; /* U+10E9 GEORGIAN LETTER CHIN */ +pub const XKB_KEY_Georgian_can :u32 = 0x10010ea; /* U+10EA GEORGIAN LETTER CAN */ +pub const XKB_KEY_Georgian_jil :u32 = 0x10010eb; /* U+10EB GEORGIAN LETTER JIL */ +pub const XKB_KEY_Georgian_cil :u32 = 0x10010ec; /* U+10EC GEORGIAN LETTER CIL */ +pub const XKB_KEY_Georgian_char :u32 = 0x10010ed; /* U+10ED GEORGIAN LETTER CHAR */ +pub const XKB_KEY_Georgian_xan :u32 = 0x10010ee; /* U+10EE GEORGIAN LETTER XAN */ +pub const XKB_KEY_Georgian_jhan :u32 = 0x10010ef; /* U+10EF GEORGIAN LETTER JHAN */ +pub const XKB_KEY_Georgian_hae :u32 = 0x10010f0; /* U+10F0 GEORGIAN LETTER HAE */ +pub const XKB_KEY_Georgian_he :u32 = 0x10010f1; /* U+10F1 GEORGIAN LETTER HE */ +pub const XKB_KEY_Georgian_hie :u32 = 0x10010f2; /* U+10F2 GEORGIAN LETTER HIE */ +pub const XKB_KEY_Georgian_we :u32 = 0x10010f3; /* U+10F3 GEORGIAN LETTER WE */ +pub const XKB_KEY_Georgian_har :u32 = 0x10010f4; /* U+10F4 GEORGIAN LETTER HAR */ +pub const XKB_KEY_Georgian_hoe :u32 = 0x10010f5; /* U+10F5 GEORGIAN LETTER HOE */ +pub const XKB_KEY_Georgian_fi :u32 = 0x10010f6; /* U+10F6 GEORGIAN LETTER FI */ + +/* + * Azeri (and other Turkic or Caucasian languages) + */ + +/* latin */ +pub const XKB_KEY_Xabovedot :u32 = 0x1001e8a; /* U+1E8A LATIN CAPITAL LETTER X WITH DOT ABOVE */ +pub const XKB_KEY_Ibreve :u32 = 0x100012c; /* U+012C LATIN CAPITAL LETTER I WITH BREVE */ +pub const XKB_KEY_Zstroke :u32 = 0x10001b5; /* U+01B5 LATIN CAPITAL LETTER Z WITH STROKE */ +pub const XKB_KEY_Gcaron :u32 = 0x10001e6; /* U+01E6 LATIN CAPITAL LETTER G WITH CARON */ +pub const XKB_KEY_Ocaron :u32 = 0x10001d1; /* U+01D2 LATIN CAPITAL LETTER O WITH CARON */ +pub const XKB_KEY_Obarred :u32 = 0x100019f; /* U+019F LATIN CAPITAL LETTER O WITH MIDDLE TILDE */ +pub const XKB_KEY_xabovedot :u32 = 0x1001e8b; /* U+1E8B LATIN SMALL LETTER X WITH DOT ABOVE */ +pub const XKB_KEY_ibreve :u32 = 0x100012d; /* U+012D LATIN SMALL LETTER I WITH BREVE */ +pub const XKB_KEY_zstroke :u32 = 0x10001b6; /* U+01B6 LATIN SMALL LETTER Z WITH STROKE */ +pub const XKB_KEY_gcaron :u32 = 0x10001e7; /* U+01E7 LATIN SMALL LETTER G WITH CARON */ +pub const XKB_KEY_ocaron :u32 = 0x10001d2; /* U+01D2 LATIN SMALL LETTER O WITH CARON */ +pub const XKB_KEY_obarred :u32 = 0x1000275; /* U+0275 LATIN SMALL LETTER BARRED O */ +pub const XKB_KEY_SCHWA :u32 = 0x100018f; /* U+018F LATIN CAPITAL LETTER SCHWA */ +pub const XKB_KEY_schwa :u32 = 0x1000259; /* U+0259 LATIN SMALL LETTER SCHWA */ +pub const XKB_KEY_EZH :u32 = 0x10001b7; /* U+01B7 LATIN CAPITAL LETTER EZH */ +pub const XKB_KEY_ezh :u32 = 0x1000292; /* U+0292 LATIN SMALL LETTER EZH */ +/* those are not really Caucasus */ +/* For Inupiak */ +pub const XKB_KEY_Lbelowdot :u32 = 0x1001e36; /* U+1E36 LATIN CAPITAL LETTER L WITH DOT BELOW */ +pub const XKB_KEY_lbelowdot :u32 = 0x1001e37; /* U+1E37 LATIN SMALL LETTER L WITH DOT BELOW */ + +/* + * Vietnamese + */ + +pub const XKB_KEY_Abelowdot :u32 = 0x1001ea0; /* U+1EA0 LATIN CAPITAL LETTER A WITH DOT BELOW */ +pub const XKB_KEY_abelowdot :u32 = 0x1001ea1; /* U+1EA1 LATIN SMALL LETTER A WITH DOT BELOW */ +pub const XKB_KEY_Ahook :u32 = 0x1001ea2; /* U+1EA2 LATIN CAPITAL LETTER A WITH HOOK ABOVE */ +pub const XKB_KEY_ahook :u32 = 0x1001ea3; /* U+1EA3 LATIN SMALL LETTER A WITH HOOK ABOVE */ +pub const XKB_KEY_Acircumflexacute :u32 = 0x1001ea4; /* U+1EA4 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE */ +pub const XKB_KEY_acircumflexacute :u32 = 0x1001ea5; /* U+1EA5 LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE */ +pub const XKB_KEY_Acircumflexgrave :u32 = 0x1001ea6; /* U+1EA6 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE */ +pub const XKB_KEY_acircumflexgrave :u32 = 0x1001ea7; /* U+1EA7 LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE */ +pub const XKB_KEY_Acircumflexhook :u32 = 0x1001ea8; /* U+1EA8 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */ +pub const XKB_KEY_acircumflexhook :u32 = 0x1001ea9; /* U+1EA9 LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */ +pub const XKB_KEY_Acircumflextilde :u32 = 0x1001eaa; /* U+1EAA LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE */ +pub const XKB_KEY_acircumflextilde :u32 = 0x1001eab; /* U+1EAB LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE */ +pub const XKB_KEY_Acircumflexbelowdot :u32 = 0x1001eac; /* U+1EAC LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW */ +pub const XKB_KEY_acircumflexbelowdot :u32 = 0x1001ead; /* U+1EAD LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW */ +pub const XKB_KEY_Abreveacute :u32 = 0x1001eae; /* U+1EAE LATIN CAPITAL LETTER A WITH BREVE AND ACUTE */ +pub const XKB_KEY_abreveacute :u32 = 0x1001eaf; /* U+1EAF LATIN SMALL LETTER A WITH BREVE AND ACUTE */ +pub const XKB_KEY_Abrevegrave :u32 = 0x1001eb0; /* U+1EB0 LATIN CAPITAL LETTER A WITH BREVE AND GRAVE */ +pub const XKB_KEY_abrevegrave :u32 = 0x1001eb1; /* U+1EB1 LATIN SMALL LETTER A WITH BREVE AND GRAVE */ +pub const XKB_KEY_Abrevehook :u32 = 0x1001eb2; /* U+1EB2 LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE */ +pub const XKB_KEY_abrevehook :u32 = 0x1001eb3; /* U+1EB3 LATIN SMALL LETTER A WITH BREVE AND HOOK ABOVE */ +pub const XKB_KEY_Abrevetilde :u32 = 0x1001eb4; /* U+1EB4 LATIN CAPITAL LETTER A WITH BREVE AND TILDE */ +pub const XKB_KEY_abrevetilde :u32 = 0x1001eb5; /* U+1EB5 LATIN SMALL LETTER A WITH BREVE AND TILDE */ +pub const XKB_KEY_Abrevebelowdot :u32 = 0x1001eb6; /* U+1EB6 LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW */ +pub const XKB_KEY_abrevebelowdot :u32 = 0x1001eb7; /* U+1EB7 LATIN SMALL LETTER A WITH BREVE AND DOT BELOW */ +pub const XKB_KEY_Ebelowdot :u32 = 0x1001eb8; /* U+1EB8 LATIN CAPITAL LETTER E WITH DOT BELOW */ +pub const XKB_KEY_ebelowdot :u32 = 0x1001eb9; /* U+1EB9 LATIN SMALL LETTER E WITH DOT BELOW */ +pub const XKB_KEY_Ehook :u32 = 0x1001eba; /* U+1EBA LATIN CAPITAL LETTER E WITH HOOK ABOVE */ +pub const XKB_KEY_ehook :u32 = 0x1001ebb; /* U+1EBB LATIN SMALL LETTER E WITH HOOK ABOVE */ +pub const XKB_KEY_Etilde :u32 = 0x1001ebc; /* U+1EBC LATIN CAPITAL LETTER E WITH TILDE */ +pub const XKB_KEY_etilde :u32 = 0x1001ebd; /* U+1EBD LATIN SMALL LETTER E WITH TILDE */ +pub const XKB_KEY_Ecircumflexacute :u32 = 0x1001ebe; /* U+1EBE LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE */ +pub const XKB_KEY_ecircumflexacute :u32 = 0x1001ebf; /* U+1EBF LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE */ +pub const XKB_KEY_Ecircumflexgrave :u32 = 0x1001ec0; /* U+1EC0 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE */ +pub const XKB_KEY_ecircumflexgrave :u32 = 0x1001ec1; /* U+1EC1 LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE */ +pub const XKB_KEY_Ecircumflexhook :u32 = 0x1001ec2; /* U+1EC2 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */ +pub const XKB_KEY_ecircumflexhook :u32 = 0x1001ec3; /* U+1EC3 LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */ +pub const XKB_KEY_Ecircumflextilde :u32 = 0x1001ec4; /* U+1EC4 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE */ +pub const XKB_KEY_ecircumflextilde :u32 = 0x1001ec5; /* U+1EC5 LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE */ +pub const XKB_KEY_Ecircumflexbelowdot :u32 = 0x1001ec6; /* U+1EC6 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW */ +pub const XKB_KEY_ecircumflexbelowdot :u32 = 0x1001ec7; /* U+1EC7 LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW */ +pub const XKB_KEY_Ihook :u32 = 0x1001ec8; /* U+1EC8 LATIN CAPITAL LETTER I WITH HOOK ABOVE */ +pub const XKB_KEY_ihook :u32 = 0x1001ec9; /* U+1EC9 LATIN SMALL LETTER I WITH HOOK ABOVE */ +pub const XKB_KEY_Ibelowdot :u32 = 0x1001eca; /* U+1ECA LATIN CAPITAL LETTER I WITH DOT BELOW */ +pub const XKB_KEY_ibelowdot :u32 = 0x1001ecb; /* U+1ECB LATIN SMALL LETTER I WITH DOT BELOW */ +pub const XKB_KEY_Obelowdot :u32 = 0x1001ecc; /* U+1ECC LATIN CAPITAL LETTER O WITH DOT BELOW */ +pub const XKB_KEY_obelowdot :u32 = 0x1001ecd; /* U+1ECD LATIN SMALL LETTER O WITH DOT BELOW */ +pub const XKB_KEY_Ohook :u32 = 0x1001ece; /* U+1ECE LATIN CAPITAL LETTER O WITH HOOK ABOVE */ +pub const XKB_KEY_ohook :u32 = 0x1001ecf; /* U+1ECF LATIN SMALL LETTER O WITH HOOK ABOVE */ +pub const XKB_KEY_Ocircumflexacute :u32 = 0x1001ed0; /* U+1ED0 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE */ +pub const XKB_KEY_ocircumflexacute :u32 = 0x1001ed1; /* U+1ED1 LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE */ +pub const XKB_KEY_Ocircumflexgrave :u32 = 0x1001ed2; /* U+1ED2 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE */ +pub const XKB_KEY_ocircumflexgrave :u32 = 0x1001ed3; /* U+1ED3 LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE */ +pub const XKB_KEY_Ocircumflexhook :u32 = 0x1001ed4; /* U+1ED4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */ +pub const XKB_KEY_ocircumflexhook :u32 = 0x1001ed5; /* U+1ED5 LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */ +pub const XKB_KEY_Ocircumflextilde :u32 = 0x1001ed6; /* U+1ED6 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE */ +pub const XKB_KEY_ocircumflextilde :u32 = 0x1001ed7; /* U+1ED7 LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE */ +pub const XKB_KEY_Ocircumflexbelowdot :u32 = 0x1001ed8; /* U+1ED8 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW */ +pub const XKB_KEY_ocircumflexbelowdot :u32 = 0x1001ed9; /* U+1ED9 LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW */ +pub const XKB_KEY_Ohornacute :u32 = 0x1001eda; /* U+1EDA LATIN CAPITAL LETTER O WITH HORN AND ACUTE */ +pub const XKB_KEY_ohornacute :u32 = 0x1001edb; /* U+1EDB LATIN SMALL LETTER O WITH HORN AND ACUTE */ +pub const XKB_KEY_Ohorngrave :u32 = 0x1001edc; /* U+1EDC LATIN CAPITAL LETTER O WITH HORN AND GRAVE */ +pub const XKB_KEY_ohorngrave :u32 = 0x1001edd; /* U+1EDD LATIN SMALL LETTER O WITH HORN AND GRAVE */ +pub const XKB_KEY_Ohornhook :u32 = 0x1001ede; /* U+1EDE LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE */ +pub const XKB_KEY_ohornhook :u32 = 0x1001edf; /* U+1EDF LATIN SMALL LETTER O WITH HORN AND HOOK ABOVE */ +pub const XKB_KEY_Ohorntilde :u32 = 0x1001ee0; /* U+1EE0 LATIN CAPITAL LETTER O WITH HORN AND TILDE */ +pub const XKB_KEY_ohorntilde :u32 = 0x1001ee1; /* U+1EE1 LATIN SMALL LETTER O WITH HORN AND TILDE */ +pub const XKB_KEY_Ohornbelowdot :u32 = 0x1001ee2; /* U+1EE2 LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW */ +pub const XKB_KEY_ohornbelowdot :u32 = 0x1001ee3; /* U+1EE3 LATIN SMALL LETTER O WITH HORN AND DOT BELOW */ +pub const XKB_KEY_Ubelowdot :u32 = 0x1001ee4; /* U+1EE4 LATIN CAPITAL LETTER U WITH DOT BELOW */ +pub const XKB_KEY_ubelowdot :u32 = 0x1001ee5; /* U+1EE5 LATIN SMALL LETTER U WITH DOT BELOW */ +pub const XKB_KEY_Uhook :u32 = 0x1001ee6; /* U+1EE6 LATIN CAPITAL LETTER U WITH HOOK ABOVE */ +pub const XKB_KEY_uhook :u32 = 0x1001ee7; /* U+1EE7 LATIN SMALL LETTER U WITH HOOK ABOVE */ +pub const XKB_KEY_Uhornacute :u32 = 0x1001ee8; /* U+1EE8 LATIN CAPITAL LETTER U WITH HORN AND ACUTE */ +pub const XKB_KEY_uhornacute :u32 = 0x1001ee9; /* U+1EE9 LATIN SMALL LETTER U WITH HORN AND ACUTE */ +pub const XKB_KEY_Uhorngrave :u32 = 0x1001eea; /* U+1EEA LATIN CAPITAL LETTER U WITH HORN AND GRAVE */ +pub const XKB_KEY_uhorngrave :u32 = 0x1001eeb; /* U+1EEB LATIN SMALL LETTER U WITH HORN AND GRAVE */ +pub const XKB_KEY_Uhornhook :u32 = 0x1001eec; /* U+1EEC LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE */ +pub const XKB_KEY_uhornhook :u32 = 0x1001eed; /* U+1EED LATIN SMALL LETTER U WITH HORN AND HOOK ABOVE */ +pub const XKB_KEY_Uhorntilde :u32 = 0x1001eee; /* U+1EEE LATIN CAPITAL LETTER U WITH HORN AND TILDE */ +pub const XKB_KEY_uhorntilde :u32 = 0x1001eef; /* U+1EEF LATIN SMALL LETTER U WITH HORN AND TILDE */ +pub const XKB_KEY_Uhornbelowdot :u32 = 0x1001ef0; /* U+1EF0 LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW */ +pub const XKB_KEY_uhornbelowdot :u32 = 0x1001ef1; /* U+1EF1 LATIN SMALL LETTER U WITH HORN AND DOT BELOW */ +pub const XKB_KEY_Ybelowdot :u32 = 0x1001ef4; /* U+1EF4 LATIN CAPITAL LETTER Y WITH DOT BELOW */ +pub const XKB_KEY_ybelowdot :u32 = 0x1001ef5; /* U+1EF5 LATIN SMALL LETTER Y WITH DOT BELOW */ +pub const XKB_KEY_Yhook :u32 = 0x1001ef6; /* U+1EF6 LATIN CAPITAL LETTER Y WITH HOOK ABOVE */ +pub const XKB_KEY_yhook :u32 = 0x1001ef7; /* U+1EF7 LATIN SMALL LETTER Y WITH HOOK ABOVE */ +pub const XKB_KEY_Ytilde :u32 = 0x1001ef8; /* U+1EF8 LATIN CAPITAL LETTER Y WITH TILDE */ +pub const XKB_KEY_ytilde :u32 = 0x1001ef9; /* U+1EF9 LATIN SMALL LETTER Y WITH TILDE */ +pub const XKB_KEY_Ohorn :u32 = 0x10001a0; /* U+01A0 LATIN CAPITAL LETTER O WITH HORN */ +pub const XKB_KEY_ohorn :u32 = 0x10001a1; /* U+01A1 LATIN SMALL LETTER O WITH HORN */ +pub const XKB_KEY_Uhorn :u32 = 0x10001af; /* U+01AF LATIN CAPITAL LETTER U WITH HORN */ +pub const XKB_KEY_uhorn :u32 = 0x10001b0; /* U+01B0 LATIN SMALL LETTER U WITH HORN */ + + +pub const XKB_KEY_EcuSign :u32 = 0x10020a0; /* U+20A0 EURO-CURRENCY SIGN */ +pub const XKB_KEY_ColonSign :u32 = 0x10020a1; /* U+20A1 COLON SIGN */ +pub const XKB_KEY_CruzeiroSign :u32 = 0x10020a2; /* U+20A2 CRUZEIRO SIGN */ +pub const XKB_KEY_FFrancSign :u32 = 0x10020a3; /* U+20A3 FRENCH FRANC SIGN */ +pub const XKB_KEY_LiraSign :u32 = 0x10020a4; /* U+20A4 LIRA SIGN */ +pub const XKB_KEY_MillSign :u32 = 0x10020a5; /* U+20A5 MILL SIGN */ +pub const XKB_KEY_NairaSign :u32 = 0x10020a6; /* U+20A6 NAIRA SIGN */ +pub const XKB_KEY_PesetaSign :u32 = 0x10020a7; /* U+20A7 PESETA SIGN */ +pub const XKB_KEY_RupeeSign :u32 = 0x10020a8; /* U+20A8 RUPEE SIGN */ +pub const XKB_KEY_WonSign :u32 = 0x10020a9; /* U+20A9 WON SIGN */ +pub const XKB_KEY_NewSheqelSign :u32 = 0x10020aa; /* U+20AA NEW SHEQEL SIGN */ +pub const XKB_KEY_DongSign :u32 = 0x10020ab; /* U+20AB DONG SIGN */ +pub const XKB_KEY_EuroSign :u32 = 0x20ac; /* U+20AC EURO SIGN */ + +/* one, two and three are defined above. */ +pub const XKB_KEY_zerosuperior :u32 = 0x1002070; /* U+2070 SUPERSCRIPT ZERO */ +pub const XKB_KEY_foursuperior :u32 = 0x1002074; /* U+2074 SUPERSCRIPT FOUR */ +pub const XKB_KEY_fivesuperior :u32 = 0x1002075; /* U+2075 SUPERSCRIPT FIVE */ +pub const XKB_KEY_sixsuperior :u32 = 0x1002076; /* U+2076 SUPERSCRIPT SIX */ +pub const XKB_KEY_sevensuperior :u32 = 0x1002077; /* U+2077 SUPERSCRIPT SEVEN */ +pub const XKB_KEY_eightsuperior :u32 = 0x1002078; /* U+2078 SUPERSCRIPT EIGHT */ +pub const XKB_KEY_ninesuperior :u32 = 0x1002079; /* U+2079 SUPERSCRIPT NINE */ +pub const XKB_KEY_zerosubscript :u32 = 0x1002080; /* U+2080 SUBSCRIPT ZERO */ +pub const XKB_KEY_onesubscript :u32 = 0x1002081; /* U+2081 SUBSCRIPT ONE */ +pub const XKB_KEY_twosubscript :u32 = 0x1002082; /* U+2082 SUBSCRIPT TWO */ +pub const XKB_KEY_threesubscript :u32 = 0x1002083; /* U+2083 SUBSCRIPT THREE */ +pub const XKB_KEY_foursubscript :u32 = 0x1002084; /* U+2084 SUBSCRIPT FOUR */ +pub const XKB_KEY_fivesubscript :u32 = 0x1002085; /* U+2085 SUBSCRIPT FIVE */ +pub const XKB_KEY_sixsubscript :u32 = 0x1002086; /* U+2086 SUBSCRIPT SIX */ +pub const XKB_KEY_sevensubscript :u32 = 0x1002087; /* U+2087 SUBSCRIPT SEVEN */ +pub const XKB_KEY_eightsubscript :u32 = 0x1002088; /* U+2088 SUBSCRIPT EIGHT */ +pub const XKB_KEY_ninesubscript :u32 = 0x1002089; /* U+2089 SUBSCRIPT NINE */ +pub const XKB_KEY_partdifferential :u32 = 0x1002202; /* U+2202 PARTIAL DIFFERENTIAL */ +pub const XKB_KEY_emptyset :u32 = 0x1002205; /* U+2205 NULL SET */ +pub const XKB_KEY_elementof :u32 = 0x1002208; /* U+2208 ELEMENT OF */ +pub const XKB_KEY_notelementof :u32 = 0x1002209; /* U+2209 NOT AN ELEMENT OF */ +pub const XKB_KEY_containsas :u32 = 0x100220B; /* U+220B CONTAINS AS MEMBER */ +pub const XKB_KEY_squareroot :u32 = 0x100221A; /* U+221A SQUARE ROOT */ +pub const XKB_KEY_cuberoot :u32 = 0x100221B; /* U+221B CUBE ROOT */ +pub const XKB_KEY_fourthroot :u32 = 0x100221C; /* U+221C FOURTH ROOT */ +pub const XKB_KEY_dintegral :u32 = 0x100222C; /* U+222C DOUBLE INTEGRAL */ +pub const XKB_KEY_tintegral :u32 = 0x100222D; /* U+222D TRIPLE INTEGRAL */ +pub const XKB_KEY_because :u32 = 0x1002235; /* U+2235 BECAUSE */ +pub const XKB_KEY_approxeq :u32 = 0x1002248; /* U+2245 ALMOST EQUAL TO */ +pub const XKB_KEY_notapproxeq :u32 = 0x1002247; /* U+2247 NOT ALMOST EQUAL TO */ +pub const XKB_KEY_notidentical :u32 = 0x1002262; /* U+2262 NOT IDENTICAL TO */ +pub const XKB_KEY_stricteq :u32 = 0x1002263; /* U+2263 STRICTLY EQUIVALENT TO */ + +pub const XKB_KEY_braille_dot_1 :u32 = 0xfff1; +pub const XKB_KEY_braille_dot_2 :u32 = 0xfff2; +pub const XKB_KEY_braille_dot_3 :u32 = 0xfff3; +pub const XKB_KEY_braille_dot_4 :u32 = 0xfff4; +pub const XKB_KEY_braille_dot_5 :u32 = 0xfff5; +pub const XKB_KEY_braille_dot_6 :u32 = 0xfff6; +pub const XKB_KEY_braille_dot_7 :u32 = 0xfff7; +pub const XKB_KEY_braille_dot_8 :u32 = 0xfff8; +pub const XKB_KEY_braille_dot_9 :u32 = 0xfff9; +pub const XKB_KEY_braille_dot_10 :u32 = 0xfffa; +pub const XKB_KEY_braille_blank :u32 = 0x1002800; /* U+2800 BRAILLE PATTERN BLANK */ +pub const XKB_KEY_braille_dots_1 :u32 = 0x1002801; /* U+2801 BRAILLE PATTERN DOTS-1 */ +pub const XKB_KEY_braille_dots_2 :u32 = 0x1002802; /* U+2802 BRAILLE PATTERN DOTS-2 */ +pub const XKB_KEY_braille_dots_12 :u32 = 0x1002803; /* U+2803 BRAILLE PATTERN DOTS-12 */ +pub const XKB_KEY_braille_dots_3 :u32 = 0x1002804; /* U+2804 BRAILLE PATTERN DOTS-3 */ +pub const XKB_KEY_braille_dots_13 :u32 = 0x1002805; /* U+2805 BRAILLE PATTERN DOTS-13 */ +pub const XKB_KEY_braille_dots_23 :u32 = 0x1002806; /* U+2806 BRAILLE PATTERN DOTS-23 */ +pub const XKB_KEY_braille_dots_123 :u32 = 0x1002807; /* U+2807 BRAILLE PATTERN DOTS-123 */ +pub const XKB_KEY_braille_dots_4 :u32 = 0x1002808; /* U+2808 BRAILLE PATTERN DOTS-4 */ +pub const XKB_KEY_braille_dots_14 :u32 = 0x1002809; /* U+2809 BRAILLE PATTERN DOTS-14 */ +pub const XKB_KEY_braille_dots_24 :u32 = 0x100280a; /* U+280a BRAILLE PATTERN DOTS-24 */ +pub const XKB_KEY_braille_dots_124 :u32 = 0x100280b; /* U+280b BRAILLE PATTERN DOTS-124 */ +pub const XKB_KEY_braille_dots_34 :u32 = 0x100280c; /* U+280c BRAILLE PATTERN DOTS-34 */ +pub const XKB_KEY_braille_dots_134 :u32 = 0x100280d; /* U+280d BRAILLE PATTERN DOTS-134 */ +pub const XKB_KEY_braille_dots_234 :u32 = 0x100280e; /* U+280e BRAILLE PATTERN DOTS-234 */ +pub const XKB_KEY_braille_dots_1234 :u32 = 0x100280f; /* U+280f BRAILLE PATTERN DOTS-1234 */ +pub const XKB_KEY_braille_dots_5 :u32 = 0x1002810; /* U+2810 BRAILLE PATTERN DOTS-5 */ +pub const XKB_KEY_braille_dots_15 :u32 = 0x1002811; /* U+2811 BRAILLE PATTERN DOTS-15 */ +pub const XKB_KEY_braille_dots_25 :u32 = 0x1002812; /* U+2812 BRAILLE PATTERN DOTS-25 */ +pub const XKB_KEY_braille_dots_125 :u32 = 0x1002813; /* U+2813 BRAILLE PATTERN DOTS-125 */ +pub const XKB_KEY_braille_dots_35 :u32 = 0x1002814; /* U+2814 BRAILLE PATTERN DOTS-35 */ +pub const XKB_KEY_braille_dots_135 :u32 = 0x1002815; /* U+2815 BRAILLE PATTERN DOTS-135 */ +pub const XKB_KEY_braille_dots_235 :u32 = 0x1002816; /* U+2816 BRAILLE PATTERN DOTS-235 */ +pub const XKB_KEY_braille_dots_1235 :u32 = 0x1002817; /* U+2817 BRAILLE PATTERN DOTS-1235 */ +pub const XKB_KEY_braille_dots_45 :u32 = 0x1002818; /* U+2818 BRAILLE PATTERN DOTS-45 */ +pub const XKB_KEY_braille_dots_145 :u32 = 0x1002819; /* U+2819 BRAILLE PATTERN DOTS-145 */ +pub const XKB_KEY_braille_dots_245 :u32 = 0x100281a; /* U+281a BRAILLE PATTERN DOTS-245 */ +pub const XKB_KEY_braille_dots_1245 :u32 = 0x100281b; /* U+281b BRAILLE PATTERN DOTS-1245 */ +pub const XKB_KEY_braille_dots_345 :u32 = 0x100281c; /* U+281c BRAILLE PATTERN DOTS-345 */ +pub const XKB_KEY_braille_dots_1345 :u32 = 0x100281d; /* U+281d BRAILLE PATTERN DOTS-1345 */ +pub const XKB_KEY_braille_dots_2345 :u32 = 0x100281e; /* U+281e BRAILLE PATTERN DOTS-2345 */ +pub const XKB_KEY_braille_dots_12345 :u32 = 0x100281f; /* U+281f BRAILLE PATTERN DOTS-12345 */ +pub const XKB_KEY_braille_dots_6 :u32 = 0x1002820; /* U+2820 BRAILLE PATTERN DOTS-6 */ +pub const XKB_KEY_braille_dots_16 :u32 = 0x1002821; /* U+2821 BRAILLE PATTERN DOTS-16 */ +pub const XKB_KEY_braille_dots_26 :u32 = 0x1002822; /* U+2822 BRAILLE PATTERN DOTS-26 */ +pub const XKB_KEY_braille_dots_126 :u32 = 0x1002823; /* U+2823 BRAILLE PATTERN DOTS-126 */ +pub const XKB_KEY_braille_dots_36 :u32 = 0x1002824; /* U+2824 BRAILLE PATTERN DOTS-36 */ +pub const XKB_KEY_braille_dots_136 :u32 = 0x1002825; /* U+2825 BRAILLE PATTERN DOTS-136 */ +pub const XKB_KEY_braille_dots_236 :u32 = 0x1002826; /* U+2826 BRAILLE PATTERN DOTS-236 */ +pub const XKB_KEY_braille_dots_1236 :u32 = 0x1002827; /* U+2827 BRAILLE PATTERN DOTS-1236 */ +pub const XKB_KEY_braille_dots_46 :u32 = 0x1002828; /* U+2828 BRAILLE PATTERN DOTS-46 */ +pub const XKB_KEY_braille_dots_146 :u32 = 0x1002829; /* U+2829 BRAILLE PATTERN DOTS-146 */ +pub const XKB_KEY_braille_dots_246 :u32 = 0x100282a; /* U+282a BRAILLE PATTERN DOTS-246 */ +pub const XKB_KEY_braille_dots_1246 :u32 = 0x100282b; /* U+282b BRAILLE PATTERN DOTS-1246 */ +pub const XKB_KEY_braille_dots_346 :u32 = 0x100282c; /* U+282c BRAILLE PATTERN DOTS-346 */ +pub const XKB_KEY_braille_dots_1346 :u32 = 0x100282d; /* U+282d BRAILLE PATTERN DOTS-1346 */ +pub const XKB_KEY_braille_dots_2346 :u32 = 0x100282e; /* U+282e BRAILLE PATTERN DOTS-2346 */ +pub const XKB_KEY_braille_dots_12346 :u32 = 0x100282f; /* U+282f BRAILLE PATTERN DOTS-12346 */ +pub const XKB_KEY_braille_dots_56 :u32 = 0x1002830; /* U+2830 BRAILLE PATTERN DOTS-56 */ +pub const XKB_KEY_braille_dots_156 :u32 = 0x1002831; /* U+2831 BRAILLE PATTERN DOTS-156 */ +pub const XKB_KEY_braille_dots_256 :u32 = 0x1002832; /* U+2832 BRAILLE PATTERN DOTS-256 */ +pub const XKB_KEY_braille_dots_1256 :u32 = 0x1002833; /* U+2833 BRAILLE PATTERN DOTS-1256 */ +pub const XKB_KEY_braille_dots_356 :u32 = 0x1002834; /* U+2834 BRAILLE PATTERN DOTS-356 */ +pub const XKB_KEY_braille_dots_1356 :u32 = 0x1002835; /* U+2835 BRAILLE PATTERN DOTS-1356 */ +pub const XKB_KEY_braille_dots_2356 :u32 = 0x1002836; /* U+2836 BRAILLE PATTERN DOTS-2356 */ +pub const XKB_KEY_braille_dots_12356 :u32 = 0x1002837; /* U+2837 BRAILLE PATTERN DOTS-12356 */ +pub const XKB_KEY_braille_dots_456 :u32 = 0x1002838; /* U+2838 BRAILLE PATTERN DOTS-456 */ +pub const XKB_KEY_braille_dots_1456 :u32 = 0x1002839; /* U+2839 BRAILLE PATTERN DOTS-1456 */ +pub const XKB_KEY_braille_dots_2456 :u32 = 0x100283a; /* U+283a BRAILLE PATTERN DOTS-2456 */ +pub const XKB_KEY_braille_dots_12456 :u32 = 0x100283b; /* U+283b BRAILLE PATTERN DOTS-12456 */ +pub const XKB_KEY_braille_dots_3456 :u32 = 0x100283c; /* U+283c BRAILLE PATTERN DOTS-3456 */ +pub const XKB_KEY_braille_dots_13456 :u32 = 0x100283d; /* U+283d BRAILLE PATTERN DOTS-13456 */ +pub const XKB_KEY_braille_dots_23456 :u32 = 0x100283e; /* U+283e BRAILLE PATTERN DOTS-23456 */ +pub const XKB_KEY_braille_dots_123456 :u32 = 0x100283f; /* U+283f BRAILLE PATTERN DOTS-123456 */ +pub const XKB_KEY_braille_dots_7 :u32 = 0x1002840; /* U+2840 BRAILLE PATTERN DOTS-7 */ +pub const XKB_KEY_braille_dots_17 :u32 = 0x1002841; /* U+2841 BRAILLE PATTERN DOTS-17 */ +pub const XKB_KEY_braille_dots_27 :u32 = 0x1002842; /* U+2842 BRAILLE PATTERN DOTS-27 */ +pub const XKB_KEY_braille_dots_127 :u32 = 0x1002843; /* U+2843 BRAILLE PATTERN DOTS-127 */ +pub const XKB_KEY_braille_dots_37 :u32 = 0x1002844; /* U+2844 BRAILLE PATTERN DOTS-37 */ +pub const XKB_KEY_braille_dots_137 :u32 = 0x1002845; /* U+2845 BRAILLE PATTERN DOTS-137 */ +pub const XKB_KEY_braille_dots_237 :u32 = 0x1002846; /* U+2846 BRAILLE PATTERN DOTS-237 */ +pub const XKB_KEY_braille_dots_1237 :u32 = 0x1002847; /* U+2847 BRAILLE PATTERN DOTS-1237 */ +pub const XKB_KEY_braille_dots_47 :u32 = 0x1002848; /* U+2848 BRAILLE PATTERN DOTS-47 */ +pub const XKB_KEY_braille_dots_147 :u32 = 0x1002849; /* U+2849 BRAILLE PATTERN DOTS-147 */ +pub const XKB_KEY_braille_dots_247 :u32 = 0x100284a; /* U+284a BRAILLE PATTERN DOTS-247 */ +pub const XKB_KEY_braille_dots_1247 :u32 = 0x100284b; /* U+284b BRAILLE PATTERN DOTS-1247 */ +pub const XKB_KEY_braille_dots_347 :u32 = 0x100284c; /* U+284c BRAILLE PATTERN DOTS-347 */ +pub const XKB_KEY_braille_dots_1347 :u32 = 0x100284d; /* U+284d BRAILLE PATTERN DOTS-1347 */ +pub const XKB_KEY_braille_dots_2347 :u32 = 0x100284e; /* U+284e BRAILLE PATTERN DOTS-2347 */ +pub const XKB_KEY_braille_dots_12347 :u32 = 0x100284f; /* U+284f BRAILLE PATTERN DOTS-12347 */ +pub const XKB_KEY_braille_dots_57 :u32 = 0x1002850; /* U+2850 BRAILLE PATTERN DOTS-57 */ +pub const XKB_KEY_braille_dots_157 :u32 = 0x1002851; /* U+2851 BRAILLE PATTERN DOTS-157 */ +pub const XKB_KEY_braille_dots_257 :u32 = 0x1002852; /* U+2852 BRAILLE PATTERN DOTS-257 */ +pub const XKB_KEY_braille_dots_1257 :u32 = 0x1002853; /* U+2853 BRAILLE PATTERN DOTS-1257 */ +pub const XKB_KEY_braille_dots_357 :u32 = 0x1002854; /* U+2854 BRAILLE PATTERN DOTS-357 */ +pub const XKB_KEY_braille_dots_1357 :u32 = 0x1002855; /* U+2855 BRAILLE PATTERN DOTS-1357 */ +pub const XKB_KEY_braille_dots_2357 :u32 = 0x1002856; /* U+2856 BRAILLE PATTERN DOTS-2357 */ +pub const XKB_KEY_braille_dots_12357 :u32 = 0x1002857; /* U+2857 BRAILLE PATTERN DOTS-12357 */ +pub const XKB_KEY_braille_dots_457 :u32 = 0x1002858; /* U+2858 BRAILLE PATTERN DOTS-457 */ +pub const XKB_KEY_braille_dots_1457 :u32 = 0x1002859; /* U+2859 BRAILLE PATTERN DOTS-1457 */ +pub const XKB_KEY_braille_dots_2457 :u32 = 0x100285a; /* U+285a BRAILLE PATTERN DOTS-2457 */ +pub const XKB_KEY_braille_dots_12457 :u32 = 0x100285b; /* U+285b BRAILLE PATTERN DOTS-12457 */ +pub const XKB_KEY_braille_dots_3457 :u32 = 0x100285c; /* U+285c BRAILLE PATTERN DOTS-3457 */ +pub const XKB_KEY_braille_dots_13457 :u32 = 0x100285d; /* U+285d BRAILLE PATTERN DOTS-13457 */ +pub const XKB_KEY_braille_dots_23457 :u32 = 0x100285e; /* U+285e BRAILLE PATTERN DOTS-23457 */ +pub const XKB_KEY_braille_dots_123457 :u32 = 0x100285f; /* U+285f BRAILLE PATTERN DOTS-123457 */ +pub const XKB_KEY_braille_dots_67 :u32 = 0x1002860; /* U+2860 BRAILLE PATTERN DOTS-67 */ +pub const XKB_KEY_braille_dots_167 :u32 = 0x1002861; /* U+2861 BRAILLE PATTERN DOTS-167 */ +pub const XKB_KEY_braille_dots_267 :u32 = 0x1002862; /* U+2862 BRAILLE PATTERN DOTS-267 */ +pub const XKB_KEY_braille_dots_1267 :u32 = 0x1002863; /* U+2863 BRAILLE PATTERN DOTS-1267 */ +pub const XKB_KEY_braille_dots_367 :u32 = 0x1002864; /* U+2864 BRAILLE PATTERN DOTS-367 */ +pub const XKB_KEY_braille_dots_1367 :u32 = 0x1002865; /* U+2865 BRAILLE PATTERN DOTS-1367 */ +pub const XKB_KEY_braille_dots_2367 :u32 = 0x1002866; /* U+2866 BRAILLE PATTERN DOTS-2367 */ +pub const XKB_KEY_braille_dots_12367 :u32 = 0x1002867; /* U+2867 BRAILLE PATTERN DOTS-12367 */ +pub const XKB_KEY_braille_dots_467 :u32 = 0x1002868; /* U+2868 BRAILLE PATTERN DOTS-467 */ +pub const XKB_KEY_braille_dots_1467 :u32 = 0x1002869; /* U+2869 BRAILLE PATTERN DOTS-1467 */ +pub const XKB_KEY_braille_dots_2467 :u32 = 0x100286a; /* U+286a BRAILLE PATTERN DOTS-2467 */ +pub const XKB_KEY_braille_dots_12467 :u32 = 0x100286b; /* U+286b BRAILLE PATTERN DOTS-12467 */ +pub const XKB_KEY_braille_dots_3467 :u32 = 0x100286c; /* U+286c BRAILLE PATTERN DOTS-3467 */ +pub const XKB_KEY_braille_dots_13467 :u32 = 0x100286d; /* U+286d BRAILLE PATTERN DOTS-13467 */ +pub const XKB_KEY_braille_dots_23467 :u32 = 0x100286e; /* U+286e BRAILLE PATTERN DOTS-23467 */ +pub const XKB_KEY_braille_dots_123467 :u32 = 0x100286f; /* U+286f BRAILLE PATTERN DOTS-123467 */ +pub const XKB_KEY_braille_dots_567 :u32 = 0x1002870; /* U+2870 BRAILLE PATTERN DOTS-567 */ +pub const XKB_KEY_braille_dots_1567 :u32 = 0x1002871; /* U+2871 BRAILLE PATTERN DOTS-1567 */ +pub const XKB_KEY_braille_dots_2567 :u32 = 0x1002872; /* U+2872 BRAILLE PATTERN DOTS-2567 */ +pub const XKB_KEY_braille_dots_12567 :u32 = 0x1002873; /* U+2873 BRAILLE PATTERN DOTS-12567 */ +pub const XKB_KEY_braille_dots_3567 :u32 = 0x1002874; /* U+2874 BRAILLE PATTERN DOTS-3567 */ +pub const XKB_KEY_braille_dots_13567 :u32 = 0x1002875; /* U+2875 BRAILLE PATTERN DOTS-13567 */ +pub const XKB_KEY_braille_dots_23567 :u32 = 0x1002876; /* U+2876 BRAILLE PATTERN DOTS-23567 */ +pub const XKB_KEY_braille_dots_123567 :u32 = 0x1002877; /* U+2877 BRAILLE PATTERN DOTS-123567 */ +pub const XKB_KEY_braille_dots_4567 :u32 = 0x1002878; /* U+2878 BRAILLE PATTERN DOTS-4567 */ +pub const XKB_KEY_braille_dots_14567 :u32 = 0x1002879; /* U+2879 BRAILLE PATTERN DOTS-14567 */ +pub const XKB_KEY_braille_dots_24567 :u32 = 0x100287a; /* U+287a BRAILLE PATTERN DOTS-24567 */ +pub const XKB_KEY_braille_dots_124567 :u32 = 0x100287b; /* U+287b BRAILLE PATTERN DOTS-124567 */ +pub const XKB_KEY_braille_dots_34567 :u32 = 0x100287c; /* U+287c BRAILLE PATTERN DOTS-34567 */ +pub const XKB_KEY_braille_dots_134567 :u32 = 0x100287d; /* U+287d BRAILLE PATTERN DOTS-134567 */ +pub const XKB_KEY_braille_dots_234567 :u32 = 0x100287e; /* U+287e BRAILLE PATTERN DOTS-234567 */ +pub const XKB_KEY_braille_dots_1234567 :u32 = 0x100287f; /* U+287f BRAILLE PATTERN DOTS-1234567 */ +pub const XKB_KEY_braille_dots_8 :u32 = 0x1002880; /* U+2880 BRAILLE PATTERN DOTS-8 */ +pub const XKB_KEY_braille_dots_18 :u32 = 0x1002881; /* U+2881 BRAILLE PATTERN DOTS-18 */ +pub const XKB_KEY_braille_dots_28 :u32 = 0x1002882; /* U+2882 BRAILLE PATTERN DOTS-28 */ +pub const XKB_KEY_braille_dots_128 :u32 = 0x1002883; /* U+2883 BRAILLE PATTERN DOTS-128 */ +pub const XKB_KEY_braille_dots_38 :u32 = 0x1002884; /* U+2884 BRAILLE PATTERN DOTS-38 */ +pub const XKB_KEY_braille_dots_138 :u32 = 0x1002885; /* U+2885 BRAILLE PATTERN DOTS-138 */ +pub const XKB_KEY_braille_dots_238 :u32 = 0x1002886; /* U+2886 BRAILLE PATTERN DOTS-238 */ +pub const XKB_KEY_braille_dots_1238 :u32 = 0x1002887; /* U+2887 BRAILLE PATTERN DOTS-1238 */ +pub const XKB_KEY_braille_dots_48 :u32 = 0x1002888; /* U+2888 BRAILLE PATTERN DOTS-48 */ +pub const XKB_KEY_braille_dots_148 :u32 = 0x1002889; /* U+2889 BRAILLE PATTERN DOTS-148 */ +pub const XKB_KEY_braille_dots_248 :u32 = 0x100288a; /* U+288a BRAILLE PATTERN DOTS-248 */ +pub const XKB_KEY_braille_dots_1248 :u32 = 0x100288b; /* U+288b BRAILLE PATTERN DOTS-1248 */ +pub const XKB_KEY_braille_dots_348 :u32 = 0x100288c; /* U+288c BRAILLE PATTERN DOTS-348 */ +pub const XKB_KEY_braille_dots_1348 :u32 = 0x100288d; /* U+288d BRAILLE PATTERN DOTS-1348 */ +pub const XKB_KEY_braille_dots_2348 :u32 = 0x100288e; /* U+288e BRAILLE PATTERN DOTS-2348 */ +pub const XKB_KEY_braille_dots_12348 :u32 = 0x100288f; /* U+288f BRAILLE PATTERN DOTS-12348 */ +pub const XKB_KEY_braille_dots_58 :u32 = 0x1002890; /* U+2890 BRAILLE PATTERN DOTS-58 */ +pub const XKB_KEY_braille_dots_158 :u32 = 0x1002891; /* U+2891 BRAILLE PATTERN DOTS-158 */ +pub const XKB_KEY_braille_dots_258 :u32 = 0x1002892; /* U+2892 BRAILLE PATTERN DOTS-258 */ +pub const XKB_KEY_braille_dots_1258 :u32 = 0x1002893; /* U+2893 BRAILLE PATTERN DOTS-1258 */ +pub const XKB_KEY_braille_dots_358 :u32 = 0x1002894; /* U+2894 BRAILLE PATTERN DOTS-358 */ +pub const XKB_KEY_braille_dots_1358 :u32 = 0x1002895; /* U+2895 BRAILLE PATTERN DOTS-1358 */ +pub const XKB_KEY_braille_dots_2358 :u32 = 0x1002896; /* U+2896 BRAILLE PATTERN DOTS-2358 */ +pub const XKB_KEY_braille_dots_12358 :u32 = 0x1002897; /* U+2897 BRAILLE PATTERN DOTS-12358 */ +pub const XKB_KEY_braille_dots_458 :u32 = 0x1002898; /* U+2898 BRAILLE PATTERN DOTS-458 */ +pub const XKB_KEY_braille_dots_1458 :u32 = 0x1002899; /* U+2899 BRAILLE PATTERN DOTS-1458 */ +pub const XKB_KEY_braille_dots_2458 :u32 = 0x100289a; /* U+289a BRAILLE PATTERN DOTS-2458 */ +pub const XKB_KEY_braille_dots_12458 :u32 = 0x100289b; /* U+289b BRAILLE PATTERN DOTS-12458 */ +pub const XKB_KEY_braille_dots_3458 :u32 = 0x100289c; /* U+289c BRAILLE PATTERN DOTS-3458 */ +pub const XKB_KEY_braille_dots_13458 :u32 = 0x100289d; /* U+289d BRAILLE PATTERN DOTS-13458 */ +pub const XKB_KEY_braille_dots_23458 :u32 = 0x100289e; /* U+289e BRAILLE PATTERN DOTS-23458 */ +pub const XKB_KEY_braille_dots_123458 :u32 = 0x100289f; /* U+289f BRAILLE PATTERN DOTS-123458 */ +pub const XKB_KEY_braille_dots_68 :u32 = 0x10028a0; /* U+28a0 BRAILLE PATTERN DOTS-68 */ +pub const XKB_KEY_braille_dots_168 :u32 = 0x10028a1; /* U+28a1 BRAILLE PATTERN DOTS-168 */ +pub const XKB_KEY_braille_dots_268 :u32 = 0x10028a2; /* U+28a2 BRAILLE PATTERN DOTS-268 */ +pub const XKB_KEY_braille_dots_1268 :u32 = 0x10028a3; /* U+28a3 BRAILLE PATTERN DOTS-1268 */ +pub const XKB_KEY_braille_dots_368 :u32 = 0x10028a4; /* U+28a4 BRAILLE PATTERN DOTS-368 */ +pub const XKB_KEY_braille_dots_1368 :u32 = 0x10028a5; /* U+28a5 BRAILLE PATTERN DOTS-1368 */ +pub const XKB_KEY_braille_dots_2368 :u32 = 0x10028a6; /* U+28a6 BRAILLE PATTERN DOTS-2368 */ +pub const XKB_KEY_braille_dots_12368 :u32 = 0x10028a7; /* U+28a7 BRAILLE PATTERN DOTS-12368 */ +pub const XKB_KEY_braille_dots_468 :u32 = 0x10028a8; /* U+28a8 BRAILLE PATTERN DOTS-468 */ +pub const XKB_KEY_braille_dots_1468 :u32 = 0x10028a9; /* U+28a9 BRAILLE PATTERN DOTS-1468 */ +pub const XKB_KEY_braille_dots_2468 :u32 = 0x10028aa; /* U+28aa BRAILLE PATTERN DOTS-2468 */ +pub const XKB_KEY_braille_dots_12468 :u32 = 0x10028ab; /* U+28ab BRAILLE PATTERN DOTS-12468 */ +pub const XKB_KEY_braille_dots_3468 :u32 = 0x10028ac; /* U+28ac BRAILLE PATTERN DOTS-3468 */ +pub const XKB_KEY_braille_dots_13468 :u32 = 0x10028ad; /* U+28ad BRAILLE PATTERN DOTS-13468 */ +pub const XKB_KEY_braille_dots_23468 :u32 = 0x10028ae; /* U+28ae BRAILLE PATTERN DOTS-23468 */ +pub const XKB_KEY_braille_dots_123468 :u32 = 0x10028af; /* U+28af BRAILLE PATTERN DOTS-123468 */ +pub const XKB_KEY_braille_dots_568 :u32 = 0x10028b0; /* U+28b0 BRAILLE PATTERN DOTS-568 */ +pub const XKB_KEY_braille_dots_1568 :u32 = 0x10028b1; /* U+28b1 BRAILLE PATTERN DOTS-1568 */ +pub const XKB_KEY_braille_dots_2568 :u32 = 0x10028b2; /* U+28b2 BRAILLE PATTERN DOTS-2568 */ +pub const XKB_KEY_braille_dots_12568 :u32 = 0x10028b3; /* U+28b3 BRAILLE PATTERN DOTS-12568 */ +pub const XKB_KEY_braille_dots_3568 :u32 = 0x10028b4; /* U+28b4 BRAILLE PATTERN DOTS-3568 */ +pub const XKB_KEY_braille_dots_13568 :u32 = 0x10028b5; /* U+28b5 BRAILLE PATTERN DOTS-13568 */ +pub const XKB_KEY_braille_dots_23568 :u32 = 0x10028b6; /* U+28b6 BRAILLE PATTERN DOTS-23568 */ +pub const XKB_KEY_braille_dots_123568 :u32 = 0x10028b7; /* U+28b7 BRAILLE PATTERN DOTS-123568 */ +pub const XKB_KEY_braille_dots_4568 :u32 = 0x10028b8; /* U+28b8 BRAILLE PATTERN DOTS-4568 */ +pub const XKB_KEY_braille_dots_14568 :u32 = 0x10028b9; /* U+28b9 BRAILLE PATTERN DOTS-14568 */ +pub const XKB_KEY_braille_dots_24568 :u32 = 0x10028ba; /* U+28ba BRAILLE PATTERN DOTS-24568 */ +pub const XKB_KEY_braille_dots_124568 :u32 = 0x10028bb; /* U+28bb BRAILLE PATTERN DOTS-124568 */ +pub const XKB_KEY_braille_dots_34568 :u32 = 0x10028bc; /* U+28bc BRAILLE PATTERN DOTS-34568 */ +pub const XKB_KEY_braille_dots_134568 :u32 = 0x10028bd; /* U+28bd BRAILLE PATTERN DOTS-134568 */ +pub const XKB_KEY_braille_dots_234568 :u32 = 0x10028be; /* U+28be BRAILLE PATTERN DOTS-234568 */ +pub const XKB_KEY_braille_dots_1234568 :u32 = 0x10028bf; /* U+28bf BRAILLE PATTERN DOTS-1234568 */ +pub const XKB_KEY_braille_dots_78 :u32 = 0x10028c0; /* U+28c0 BRAILLE PATTERN DOTS-78 */ +pub const XKB_KEY_braille_dots_178 :u32 = 0x10028c1; /* U+28c1 BRAILLE PATTERN DOTS-178 */ +pub const XKB_KEY_braille_dots_278 :u32 = 0x10028c2; /* U+28c2 BRAILLE PATTERN DOTS-278 */ +pub const XKB_KEY_braille_dots_1278 :u32 = 0x10028c3; /* U+28c3 BRAILLE PATTERN DOTS-1278 */ +pub const XKB_KEY_braille_dots_378 :u32 = 0x10028c4; /* U+28c4 BRAILLE PATTERN DOTS-378 */ +pub const XKB_KEY_braille_dots_1378 :u32 = 0x10028c5; /* U+28c5 BRAILLE PATTERN DOTS-1378 */ +pub const XKB_KEY_braille_dots_2378 :u32 = 0x10028c6; /* U+28c6 BRAILLE PATTERN DOTS-2378 */ +pub const XKB_KEY_braille_dots_12378 :u32 = 0x10028c7; /* U+28c7 BRAILLE PATTERN DOTS-12378 */ +pub const XKB_KEY_braille_dots_478 :u32 = 0x10028c8; /* U+28c8 BRAILLE PATTERN DOTS-478 */ +pub const XKB_KEY_braille_dots_1478 :u32 = 0x10028c9; /* U+28c9 BRAILLE PATTERN DOTS-1478 */ +pub const XKB_KEY_braille_dots_2478 :u32 = 0x10028ca; /* U+28ca BRAILLE PATTERN DOTS-2478 */ +pub const XKB_KEY_braille_dots_12478 :u32 = 0x10028cb; /* U+28cb BRAILLE PATTERN DOTS-12478 */ +pub const XKB_KEY_braille_dots_3478 :u32 = 0x10028cc; /* U+28cc BRAILLE PATTERN DOTS-3478 */ +pub const XKB_KEY_braille_dots_13478 :u32 = 0x10028cd; /* U+28cd BRAILLE PATTERN DOTS-13478 */ +pub const XKB_KEY_braille_dots_23478 :u32 = 0x10028ce; /* U+28ce BRAILLE PATTERN DOTS-23478 */ +pub const XKB_KEY_braille_dots_123478 :u32 = 0x10028cf; /* U+28cf BRAILLE PATTERN DOTS-123478 */ +pub const XKB_KEY_braille_dots_578 :u32 = 0x10028d0; /* U+28d0 BRAILLE PATTERN DOTS-578 */ +pub const XKB_KEY_braille_dots_1578 :u32 = 0x10028d1; /* U+28d1 BRAILLE PATTERN DOTS-1578 */ +pub const XKB_KEY_braille_dots_2578 :u32 = 0x10028d2; /* U+28d2 BRAILLE PATTERN DOTS-2578 */ +pub const XKB_KEY_braille_dots_12578 :u32 = 0x10028d3; /* U+28d3 BRAILLE PATTERN DOTS-12578 */ +pub const XKB_KEY_braille_dots_3578 :u32 = 0x10028d4; /* U+28d4 BRAILLE PATTERN DOTS-3578 */ +pub const XKB_KEY_braille_dots_13578 :u32 = 0x10028d5; /* U+28d5 BRAILLE PATTERN DOTS-13578 */ +pub const XKB_KEY_braille_dots_23578 :u32 = 0x10028d6; /* U+28d6 BRAILLE PATTERN DOTS-23578 */ +pub const XKB_KEY_braille_dots_123578 :u32 = 0x10028d7; /* U+28d7 BRAILLE PATTERN DOTS-123578 */ +pub const XKB_KEY_braille_dots_4578 :u32 = 0x10028d8; /* U+28d8 BRAILLE PATTERN DOTS-4578 */ +pub const XKB_KEY_braille_dots_14578 :u32 = 0x10028d9; /* U+28d9 BRAILLE PATTERN DOTS-14578 */ +pub const XKB_KEY_braille_dots_24578 :u32 = 0x10028da; /* U+28da BRAILLE PATTERN DOTS-24578 */ +pub const XKB_KEY_braille_dots_124578 :u32 = 0x10028db; /* U+28db BRAILLE PATTERN DOTS-124578 */ +pub const XKB_KEY_braille_dots_34578 :u32 = 0x10028dc; /* U+28dc BRAILLE PATTERN DOTS-34578 */ +pub const XKB_KEY_braille_dots_134578 :u32 = 0x10028dd; /* U+28dd BRAILLE PATTERN DOTS-134578 */ +pub const XKB_KEY_braille_dots_234578 :u32 = 0x10028de; /* U+28de BRAILLE PATTERN DOTS-234578 */ +pub const XKB_KEY_braille_dots_1234578 :u32 = 0x10028df; /* U+28df BRAILLE PATTERN DOTS-1234578 */ +pub const XKB_KEY_braille_dots_678 :u32 = 0x10028e0; /* U+28e0 BRAILLE PATTERN DOTS-678 */ +pub const XKB_KEY_braille_dots_1678 :u32 = 0x10028e1; /* U+28e1 BRAILLE PATTERN DOTS-1678 */ +pub const XKB_KEY_braille_dots_2678 :u32 = 0x10028e2; /* U+28e2 BRAILLE PATTERN DOTS-2678 */ +pub const XKB_KEY_braille_dots_12678 :u32 = 0x10028e3; /* U+28e3 BRAILLE PATTERN DOTS-12678 */ +pub const XKB_KEY_braille_dots_3678 :u32 = 0x10028e4; /* U+28e4 BRAILLE PATTERN DOTS-3678 */ +pub const XKB_KEY_braille_dots_13678 :u32 = 0x10028e5; /* U+28e5 BRAILLE PATTERN DOTS-13678 */ +pub const XKB_KEY_braille_dots_23678 :u32 = 0x10028e6; /* U+28e6 BRAILLE PATTERN DOTS-23678 */ +pub const XKB_KEY_braille_dots_123678 :u32 = 0x10028e7; /* U+28e7 BRAILLE PATTERN DOTS-123678 */ +pub const XKB_KEY_braille_dots_4678 :u32 = 0x10028e8; /* U+28e8 BRAILLE PATTERN DOTS-4678 */ +pub const XKB_KEY_braille_dots_14678 :u32 = 0x10028e9; /* U+28e9 BRAILLE PATTERN DOTS-14678 */ +pub const XKB_KEY_braille_dots_24678 :u32 = 0x10028ea; /* U+28ea BRAILLE PATTERN DOTS-24678 */ +pub const XKB_KEY_braille_dots_124678 :u32 = 0x10028eb; /* U+28eb BRAILLE PATTERN DOTS-124678 */ +pub const XKB_KEY_braille_dots_34678 :u32 = 0x10028ec; /* U+28ec BRAILLE PATTERN DOTS-34678 */ +pub const XKB_KEY_braille_dots_134678 :u32 = 0x10028ed; /* U+28ed BRAILLE PATTERN DOTS-134678 */ +pub const XKB_KEY_braille_dots_234678 :u32 = 0x10028ee; /* U+28ee BRAILLE PATTERN DOTS-234678 */ +pub const XKB_KEY_braille_dots_1234678 :u32 = 0x10028ef; /* U+28ef BRAILLE PATTERN DOTS-1234678 */ +pub const XKB_KEY_braille_dots_5678 :u32 = 0x10028f0; /* U+28f0 BRAILLE PATTERN DOTS-5678 */ +pub const XKB_KEY_braille_dots_15678 :u32 = 0x10028f1; /* U+28f1 BRAILLE PATTERN DOTS-15678 */ +pub const XKB_KEY_braille_dots_25678 :u32 = 0x10028f2; /* U+28f2 BRAILLE PATTERN DOTS-25678 */ +pub const XKB_KEY_braille_dots_125678 :u32 = 0x10028f3; /* U+28f3 BRAILLE PATTERN DOTS-125678 */ +pub const XKB_KEY_braille_dots_35678 :u32 = 0x10028f4; /* U+28f4 BRAILLE PATTERN DOTS-35678 */ +pub const XKB_KEY_braille_dots_135678 :u32 = 0x10028f5; /* U+28f5 BRAILLE PATTERN DOTS-135678 */ +pub const XKB_KEY_braille_dots_235678 :u32 = 0x10028f6; /* U+28f6 BRAILLE PATTERN DOTS-235678 */ +pub const XKB_KEY_braille_dots_1235678 :u32 = 0x10028f7; /* U+28f7 BRAILLE PATTERN DOTS-1235678 */ +pub const XKB_KEY_braille_dots_45678 :u32 = 0x10028f8; /* U+28f8 BRAILLE PATTERN DOTS-45678 */ +pub const XKB_KEY_braille_dots_145678 :u32 = 0x10028f9; /* U+28f9 BRAILLE PATTERN DOTS-145678 */ +pub const XKB_KEY_braille_dots_245678 :u32 = 0x10028fa; /* U+28fa BRAILLE PATTERN DOTS-245678 */ +pub const XKB_KEY_braille_dots_1245678 :u32 = 0x10028fb; /* U+28fb BRAILLE PATTERN DOTS-1245678 */ +pub const XKB_KEY_braille_dots_345678 :u32 = 0x10028fc; /* U+28fc BRAILLE PATTERN DOTS-345678 */ +pub const XKB_KEY_braille_dots_1345678 :u32 = 0x10028fd; /* U+28fd BRAILLE PATTERN DOTS-1345678 */ +pub const XKB_KEY_braille_dots_2345678 :u32 = 0x10028fe; /* U+28fe BRAILLE PATTERN DOTS-2345678 */ +pub const XKB_KEY_braille_dots_12345678 :u32 = 0x10028ff; /* U+28ff BRAILLE PATTERN DOTS-12345678 */ + +/* + * Sinhala (http://unicode.org/charts/PDF/U0D80.pdf) + * http://www.nongnu.org/sinhala/doc/transliteration/sinhala-transliteration_6.html + */ + +pub const XKB_KEY_Sinh_ng :u32 = 0x1000d82; /* U+0D82 SINHALA ANUSVARAYA */ +pub const XKB_KEY_Sinh_h2 :u32 = 0x1000d83; /* U+0D83 SINHALA VISARGAYA */ +pub const XKB_KEY_Sinh_a :u32 = 0x1000d85; /* U+0D85 SINHALA AYANNA */ +pub const XKB_KEY_Sinh_aa :u32 = 0x1000d86; /* U+0D86 SINHALA AAYANNA */ +pub const XKB_KEY_Sinh_ae :u32 = 0x1000d87; /* U+0D87 SINHALA AEYANNA */ +pub const XKB_KEY_Sinh_aee :u32 = 0x1000d88; /* U+0D88 SINHALA AEEYANNA */ +pub const XKB_KEY_Sinh_i :u32 = 0x1000d89; /* U+0D89 SINHALA IYANNA */ +pub const XKB_KEY_Sinh_ii :u32 = 0x1000d8a; /* U+0D8A SINHALA IIYANNA */ +pub const XKB_KEY_Sinh_u :u32 = 0x1000d8b; /* U+0D8B SINHALA UYANNA */ +pub const XKB_KEY_Sinh_uu :u32 = 0x1000d8c; /* U+0D8C SINHALA UUYANNA */ +pub const XKB_KEY_Sinh_ri :u32 = 0x1000d8d; /* U+0D8D SINHALA IRUYANNA */ +pub const XKB_KEY_Sinh_rii :u32 = 0x1000d8e; /* U+0D8E SINHALA IRUUYANNA */ +pub const XKB_KEY_Sinh_lu :u32 = 0x1000d8f; /* U+0D8F SINHALA ILUYANNA */ +pub const XKB_KEY_Sinh_luu :u32 = 0x1000d90; /* U+0D90 SINHALA ILUUYANNA */ +pub const XKB_KEY_Sinh_e :u32 = 0x1000d91; /* U+0D91 SINHALA EYANNA */ +pub const XKB_KEY_Sinh_ee :u32 = 0x1000d92; /* U+0D92 SINHALA EEYANNA */ +pub const XKB_KEY_Sinh_ai :u32 = 0x1000d93; /* U+0D93 SINHALA AIYANNA */ +pub const XKB_KEY_Sinh_o :u32 = 0x1000d94; /* U+0D94 SINHALA OYANNA */ +pub const XKB_KEY_Sinh_oo :u32 = 0x1000d95; /* U+0D95 SINHALA OOYANNA */ +pub const XKB_KEY_Sinh_au :u32 = 0x1000d96; /* U+0D96 SINHALA AUYANNA */ +pub const XKB_KEY_Sinh_ka :u32 = 0x1000d9a; /* U+0D9A SINHALA KAYANNA */ +pub const XKB_KEY_Sinh_kha :u32 = 0x1000d9b; /* U+0D9B SINHALA MAHA. KAYANNA */ +pub const XKB_KEY_Sinh_ga :u32 = 0x1000d9c; /* U+0D9C SINHALA GAYANNA */ +pub const XKB_KEY_Sinh_gha :u32 = 0x1000d9d; /* U+0D9D SINHALA MAHA. GAYANNA */ +pub const XKB_KEY_Sinh_ng2 :u32 = 0x1000d9e; /* U+0D9E SINHALA KANTAJA NAASIKYAYA */ +pub const XKB_KEY_Sinh_nga :u32 = 0x1000d9f; /* U+0D9F SINHALA SANYAKA GAYANNA */ +pub const XKB_KEY_Sinh_ca :u32 = 0x1000da0; /* U+0DA0 SINHALA CAYANNA */ +pub const XKB_KEY_Sinh_cha :u32 = 0x1000da1; /* U+0DA1 SINHALA MAHA. CAYANNA */ +pub const XKB_KEY_Sinh_ja :u32 = 0x1000da2; /* U+0DA2 SINHALA JAYANNA */ +pub const XKB_KEY_Sinh_jha :u32 = 0x1000da3; /* U+0DA3 SINHALA MAHA. JAYANNA */ +pub const XKB_KEY_Sinh_nya :u32 = 0x1000da4; /* U+0DA4 SINHALA TAALUJA NAASIKYAYA */ +pub const XKB_KEY_Sinh_jnya :u32 = 0x1000da5; /* U+0DA5 SINHALA TAALUJA SANYOOGA NAASIKYAYA */ +pub const XKB_KEY_Sinh_nja :u32 = 0x1000da6; /* U+0DA6 SINHALA SANYAKA JAYANNA */ +pub const XKB_KEY_Sinh_tta :u32 = 0x1000da7; /* U+0DA7 SINHALA TTAYANNA */ +pub const XKB_KEY_Sinh_ttha :u32 = 0x1000da8; /* U+0DA8 SINHALA MAHA. TTAYANNA */ +pub const XKB_KEY_Sinh_dda :u32 = 0x1000da9; /* U+0DA9 SINHALA DDAYANNA */ +pub const XKB_KEY_Sinh_ddha :u32 = 0x1000daa; /* U+0DAA SINHALA MAHA. DDAYANNA */ +pub const XKB_KEY_Sinh_nna :u32 = 0x1000dab; /* U+0DAB SINHALA MUURDHAJA NAYANNA */ +pub const XKB_KEY_Sinh_ndda :u32 = 0x1000dac; /* U+0DAC SINHALA SANYAKA DDAYANNA */ +pub const XKB_KEY_Sinh_tha :u32 = 0x1000dad; /* U+0DAD SINHALA TAYANNA */ +pub const XKB_KEY_Sinh_thha :u32 = 0x1000dae; /* U+0DAE SINHALA MAHA. TAYANNA */ +pub const XKB_KEY_Sinh_dha :u32 = 0x1000daf; /* U+0DAF SINHALA DAYANNA */ +pub const XKB_KEY_Sinh_dhha :u32 = 0x1000db0; /* U+0DB0 SINHALA MAHA. DAYANNA */ +pub const XKB_KEY_Sinh_na :u32 = 0x1000db1; /* U+0DB1 SINHALA DANTAJA NAYANNA */ +pub const XKB_KEY_Sinh_ndha :u32 = 0x1000db3; /* U+0DB3 SINHALA SANYAKA DAYANNA */ +pub const XKB_KEY_Sinh_pa :u32 = 0x1000db4; /* U+0DB4 SINHALA PAYANNA */ +pub const XKB_KEY_Sinh_pha :u32 = 0x1000db5; /* U+0DB5 SINHALA MAHA. PAYANNA */ +pub const XKB_KEY_Sinh_ba :u32 = 0x1000db6; /* U+0DB6 SINHALA BAYANNA */ +pub const XKB_KEY_Sinh_bha :u32 = 0x1000db7; /* U+0DB7 SINHALA MAHA. BAYANNA */ +pub const XKB_KEY_Sinh_ma :u32 = 0x1000db8; /* U+0DB8 SINHALA MAYANNA */ +pub const XKB_KEY_Sinh_mba :u32 = 0x1000db9; /* U+0DB9 SINHALA AMBA BAYANNA */ +pub const XKB_KEY_Sinh_ya :u32 = 0x1000dba; /* U+0DBA SINHALA YAYANNA */ +pub const XKB_KEY_Sinh_ra :u32 = 0x1000dbb; /* U+0DBB SINHALA RAYANNA */ +pub const XKB_KEY_Sinh_la :u32 = 0x1000dbd; /* U+0DBD SINHALA DANTAJA LAYANNA */ +pub const XKB_KEY_Sinh_va :u32 = 0x1000dc0; /* U+0DC0 SINHALA VAYANNA */ +pub const XKB_KEY_Sinh_sha :u32 = 0x1000dc1; /* U+0DC1 SINHALA TAALUJA SAYANNA */ +pub const XKB_KEY_Sinh_ssha :u32 = 0x1000dc2; /* U+0DC2 SINHALA MUURDHAJA SAYANNA */ +pub const XKB_KEY_Sinh_sa :u32 = 0x1000dc3; /* U+0DC3 SINHALA DANTAJA SAYANNA */ +pub const XKB_KEY_Sinh_ha :u32 = 0x1000dc4; /* U+0DC4 SINHALA HAYANNA */ +pub const XKB_KEY_Sinh_lla :u32 = 0x1000dc5; /* U+0DC5 SINHALA MUURDHAJA LAYANNA */ +pub const XKB_KEY_Sinh_fa :u32 = 0x1000dc6; /* U+0DC6 SINHALA FAYANNA */ +pub const XKB_KEY_Sinh_al :u32 = 0x1000dca; /* U+0DCA SINHALA AL-LAKUNA */ +pub const XKB_KEY_Sinh_aa2 :u32 = 0x1000dcf; /* U+0DCF SINHALA AELA-PILLA */ +pub const XKB_KEY_Sinh_ae2 :u32 = 0x1000dd0; /* U+0DD0 SINHALA AEDA-PILLA */ +pub const XKB_KEY_Sinh_aee2 :u32 = 0x1000dd1; /* U+0DD1 SINHALA DIGA AEDA-PILLA */ +pub const XKB_KEY_Sinh_i2 :u32 = 0x1000dd2; /* U+0DD2 SINHALA IS-PILLA */ +pub const XKB_KEY_Sinh_ii2 :u32 = 0x1000dd3; /* U+0DD3 SINHALA DIGA IS-PILLA */ +pub const XKB_KEY_Sinh_u2 :u32 = 0x1000dd4; /* U+0DD4 SINHALA PAA-PILLA */ +pub const XKB_KEY_Sinh_uu2 :u32 = 0x1000dd6; /* U+0DD6 SINHALA DIGA PAA-PILLA */ +pub const XKB_KEY_Sinh_ru2 :u32 = 0x1000dd8; /* U+0DD8 SINHALA GAETTA-PILLA */ +pub const XKB_KEY_Sinh_e2 :u32 = 0x1000dd9; /* U+0DD9 SINHALA KOMBUVA */ +pub const XKB_KEY_Sinh_ee2 :u32 = 0x1000dda; /* U+0DDA SINHALA DIGA KOMBUVA */ +pub const XKB_KEY_Sinh_ai2 :u32 = 0x1000ddb; /* U+0DDB SINHALA KOMBU DEKA */ +pub const XKB_KEY_Sinh_o2 :u32 = 0x1000ddc; /* U+0DDC SINHALA KOMBUVA HAA AELA-PILLA*/ +pub const XKB_KEY_Sinh_oo2 :u32 = 0x1000ddd; /* U+0DDD SINHALA KOMBUVA HAA DIGA AELA-PILLA*/ +pub const XKB_KEY_Sinh_au2 :u32 = 0x1000dde; /* U+0DDE SINHALA KOMBUVA HAA GAYANUKITTA */ +pub const XKB_KEY_Sinh_lu2 :u32 = 0x1000ddf; /* U+0DDF SINHALA GAYANUKITTA */ +pub const XKB_KEY_Sinh_ruu2 :u32 = 0x1000df2; /* U+0DF2 SINHALA DIGA GAETTA-PILLA */ +pub const XKB_KEY_Sinh_luu2 :u32 = 0x1000df3; /* U+0DF3 SINHALA DIGA GAYANUKITTA */ +pub const XKB_KEY_Sinh_kunddaliya :u32 = 0x1000df4; /* U+0DF4 SINHALA KUNDDALIYA */ +/* + * XFree86 vendor specific keysyms. + * + * The XFree86 keysym range is :u32 = 0x10080001; - :u32 = 0x1008FFFF;. + * + * X.Org will not be adding to the XF86 set of keysyms, though they have + * been adopted and are considered a "standard" part of X keysym definitions. + * XFree86 never properly commented these keysyms, so we have done our + * best to explain the semantic meaning of these keys. + * + * XFree86 has removed their mail archives of the period, that might have + * shed more light on some of these definitions. Until/unless we resurrect + * these archives, these are from memory and usage. + */ + +/* + * ModeLock + * + * This one is old, and not really used any more since XKB offers this + * functionality. + */ + +pub const XKB_KEY_XF86ModeLock :u32 = 0x1008FF01; /* Mode Switch Lock */ + +/* Backlight controls. */ +pub const XKB_KEY_XF86MonBrightnessUp :u32 = 0x1008FF02; /* Monitor/panel brightness */ +pub const XKB_KEY_XF86MonBrightnessDown :u32 = 0x1008FF03; /* Monitor/panel brightness */ +pub const XKB_KEY_XF86KbdLightOnOff :u32 = 0x1008FF04; /* Keyboards may be lit */ +pub const XKB_KEY_XF86KbdBrightnessUp :u32 = 0x1008FF05; /* Keyboards may be lit */ +pub const XKB_KEY_XF86KbdBrightnessDown :u32 = 0x1008FF06; /* Keyboards may be lit */ + +/* + * Keys found on some "Internet" keyboards. + */ +pub const XKB_KEY_XF86Standby :u32 = 0x1008FF10; /* System into standby mode */ +pub const XKB_KEY_XF86AudioLowerVolume :u32 = 0x1008FF11; /* Volume control down */ +pub const XKB_KEY_XF86AudioMute :u32 = 0x1008FF12; /* Mute sound from the system */ +pub const XKB_KEY_XF86AudioRaiseVolume :u32 = 0x1008FF13; /* Volume control up */ +pub const XKB_KEY_XF86AudioPlay :u32 = 0x1008FF14; /* Start playing of audio > */ +pub const XKB_KEY_XF86AudioStop :u32 = 0x1008FF15; /* Stop playing audio */ +pub const XKB_KEY_XF86AudioPrev :u32 = 0x1008FF16; /* Previous track */ +pub const XKB_KEY_XF86AudioNext :u32 = 0x1008FF17; /* Next track */ +pub const XKB_KEY_XF86HomePage :u32 = 0x1008FF18; /* Display user's home page */ +pub const XKB_KEY_XF86Mail :u32 = 0x1008FF19; /* Invoke user's mail program */ +pub const XKB_KEY_XF86Start :u32 = 0x1008FF1A; /* Start application */ +pub const XKB_KEY_XF86Search :u32 = 0x1008FF1B; /* Search */ +pub const XKB_KEY_XF86AudioRecord :u32 = 0x1008FF1C; /* Record audio application */ + +/* These are sometimes found on PDA's (e.g. Palm, PocketPC or elsewhere) */ +pub const XKB_KEY_XF86Calculator :u32 = 0x1008FF1D; /* Invoke calculator program */ +pub const XKB_KEY_XF86Memo :u32 = 0x1008FF1E; /* Invoke Memo taking program */ +pub const XKB_KEY_XF86ToDoList :u32 = 0x1008FF1F; /* Invoke To Do List program */ +pub const XKB_KEY_XF86Calendar :u32 = 0x1008FF20; /* Invoke Calendar program */ +pub const XKB_KEY_XF86PowerDown :u32 = 0x1008FF21; /* Deep sleep the system */ +pub const XKB_KEY_XF86ContrastAdjust :u32 = 0x1008FF22; /* Adjust screen contrast */ +pub const XKB_KEY_XF86RockerUp :u32 = 0x1008FF23; /* Rocker switches exist up */ +pub const XKB_KEY_XF86RockerDown :u32 = 0x1008FF24; /* and down */ +pub const XKB_KEY_XF86RockerEnter :u32 = 0x1008FF25; /* and let you press them */ + +/* Some more "Internet" keyboard symbols */ +pub const XKB_KEY_XF86Back :u32 = 0x1008FF26; /* Like back on a browser */ +pub const XKB_KEY_XF86Forward :u32 = 0x1008FF27; /* Like forward on a browser */ +pub const XKB_KEY_XF86Stop :u32 = 0x1008FF28; /* Stop current operation */ +pub const XKB_KEY_XF86Refresh :u32 = 0x1008FF29; /* Refresh the page */ +pub const XKB_KEY_XF86PowerOff :u32 = 0x1008FF2A; /* Power off system entirely */ +pub const XKB_KEY_XF86WakeUp :u32 = 0x1008FF2B; /* Wake up system from sleep */ +pub const XKB_KEY_XF86Eject :u32 = 0x1008FF2C; /* Eject device (e.g. DVD) */ +pub const XKB_KEY_XF86ScreenSaver :u32 = 0x1008FF2D; /* Invoke screensaver */ +pub const XKB_KEY_XF86WWW :u32 = 0x1008FF2E; /* Invoke web browser */ +pub const XKB_KEY_XF86Sleep :u32 = 0x1008FF2F; /* Put system to sleep */ +pub const XKB_KEY_XF86Favorites :u32 = 0x1008FF30; /* Show favorite locations */ +pub const XKB_KEY_XF86AudioPause :u32 = 0x1008FF31; /* Pause audio playing */ +pub const XKB_KEY_XF86AudioMedia :u32 = 0x1008FF32; /* Launch media collection app */ +pub const XKB_KEY_XF86MyComputer :u32 = 0x1008FF33; /* Display "My Computer" window */ +pub const XKB_KEY_XF86VendorHome :u32 = 0x1008FF34; /* Display vendor home web site */ +pub const XKB_KEY_XF86LightBulb :u32 = 0x1008FF35; /* Light bulb keys exist */ +pub const XKB_KEY_XF86Shop :u32 = 0x1008FF36; /* Display shopping web site */ +pub const XKB_KEY_XF86History :u32 = 0x1008FF37; /* Show history of web surfing */ +pub const XKB_KEY_XF86OpenURL :u32 = 0x1008FF38; /* Open selected URL */ +pub const XKB_KEY_XF86AddFavorite :u32 = 0x1008FF39; /* Add URL to favorites list */ +pub const XKB_KEY_XF86HotLinks :u32 = 0x1008FF3A; /* Show "hot" links */ +pub const XKB_KEY_XF86BrightnessAdjust :u32 = 0x1008FF3B; /* Invoke brightness adj. UI */ +pub const XKB_KEY_XF86Finance :u32 = 0x1008FF3C; /* Display financial site */ +pub const XKB_KEY_XF86Community :u32 = 0x1008FF3D; /* Display user's community */ +pub const XKB_KEY_XF86AudioRewind :u32 = 0x1008FF3E; /* "rewind" audio track */ +pub const XKB_KEY_XF86BackForward :u32 = 0x1008FF3F; /* ??? */ +pub const XKB_KEY_XF86Launch0 :u32 = 0x1008FF40; /* Launch Application */ +pub const XKB_KEY_XF86Launch1 :u32 = 0x1008FF41; /* Launch Application */ +pub const XKB_KEY_XF86Launch2 :u32 = 0x1008FF42; /* Launch Application */ +pub const XKB_KEY_XF86Launch3 :u32 = 0x1008FF43; /* Launch Application */ +pub const XKB_KEY_XF86Launch4 :u32 = 0x1008FF44; /* Launch Application */ +pub const XKB_KEY_XF86Launch5 :u32 = 0x1008FF45; /* Launch Application */ +pub const XKB_KEY_XF86Launch6 :u32 = 0x1008FF46; /* Launch Application */ +pub const XKB_KEY_XF86Launch7 :u32 = 0x1008FF47; /* Launch Application */ +pub const XKB_KEY_XF86Launch8 :u32 = 0x1008FF48; /* Launch Application */ +pub const XKB_KEY_XF86Launch9 :u32 = 0x1008FF49; /* Launch Application */ +pub const XKB_KEY_XF86LaunchA :u32 = 0x1008FF4A; /* Launch Application */ +pub const XKB_KEY_XF86LaunchB :u32 = 0x1008FF4B; /* Launch Application */ +pub const XKB_KEY_XF86LaunchC :u32 = 0x1008FF4C; /* Launch Application */ +pub const XKB_KEY_XF86LaunchD :u32 = 0x1008FF4D; /* Launch Application */ +pub const XKB_KEY_XF86LaunchE :u32 = 0x1008FF4E; /* Launch Application */ +pub const XKB_KEY_XF86LaunchF :u32 = 0x1008FF4F; /* Launch Application */ + +pub const XKB_KEY_XF86ApplicationLeft :u32 = 0x1008FF50; /* switch to application, left */ +pub const XKB_KEY_XF86ApplicationRight :u32 = 0x1008FF51; /* switch to application, right*/ +pub const XKB_KEY_XF86Book :u32 = 0x1008FF52; /* Launch bookreader */ +pub const XKB_KEY_XF86CD :u32 = 0x1008FF53; /* Launch CD/DVD player */ +pub const XKB_KEY_XF86Calculater :u32 = 0x1008FF54; /* Launch Calculater */ +pub const XKB_KEY_XF86Clear :u32 = 0x1008FF55; /* Clear window, screen */ +pub const XKB_KEY_XF86Close :u32 = 0x1008FF56; /* Close window */ +pub const XKB_KEY_XF86Copy :u32 = 0x1008FF57; /* Copy selection */ +pub const XKB_KEY_XF86Cut :u32 = 0x1008FF58; /* Cut selection */ +pub const XKB_KEY_XF86Display :u32 = 0x1008FF59; /* Output switch key */ +pub const XKB_KEY_XF86DOS :u32 = 0x1008FF5A; /* Launch DOS (emulation) */ +pub const XKB_KEY_XF86Documents :u32 = 0x1008FF5B; /* Open documents window */ +pub const XKB_KEY_XF86Excel :u32 = 0x1008FF5C; /* Launch spread sheet */ +pub const XKB_KEY_XF86Explorer :u32 = 0x1008FF5D; /* Launch file explorer */ +pub const XKB_KEY_XF86Game :u32 = 0x1008FF5E; /* Launch game */ +pub const XKB_KEY_XF86Go :u32 = 0x1008FF5F; /* Go to URL */ +pub const XKB_KEY_XF86iTouch :u32 = 0x1008FF60; /* Logitch iTouch- don't use */ +pub const XKB_KEY_XF86LogOff :u32 = 0x1008FF61; /* Log off system */ +pub const XKB_KEY_XF86Market :u32 = 0x1008FF62; /* ?? */ +pub const XKB_KEY_XF86Meeting :u32 = 0x1008FF63; /* enter meeting in calendar */ +pub const XKB_KEY_XF86MenuKB :u32 = 0x1008FF65; /* distingush keyboard from PB */ +pub const XKB_KEY_XF86MenuPB :u32 = 0x1008FF66; /* distinuish PB from keyboard */ +pub const XKB_KEY_XF86MySites :u32 = 0x1008FF67; /* Favourites */ +pub const XKB_KEY_XF86New :u32 = 0x1008FF68; /* New (folder, document... */ +pub const XKB_KEY_XF86News :u32 = 0x1008FF69; /* News */ +pub const XKB_KEY_XF86OfficeHome :u32 = 0x1008FF6A; /* Office home (old Staroffice)*/ +pub const XKB_KEY_XF86Open :u32 = 0x1008FF6B; /* Open */ +pub const XKB_KEY_XF86Option :u32 = 0x1008FF6C; /* ?? */ +pub const XKB_KEY_XF86Paste :u32 = 0x1008FF6D; /* Paste */ +pub const XKB_KEY_XF86Phone :u32 = 0x1008FF6E; /* Launch phone; dial number */ +pub const XKB_KEY_XF86Q :u32 = 0x1008FF70; /* Compaq's Q - don't use */ +pub const XKB_KEY_XF86Reply :u32 = 0x1008FF72; /* Reply e.g., mail */ +pub const XKB_KEY_XF86Reload :u32 = 0x1008FF73; /* Reload web page, file, etc. */ +pub const XKB_KEY_XF86RotateWindows :u32 = 0x1008FF74; /* Rotate windows e.g. xrandr */ +pub const XKB_KEY_XF86RotationPB :u32 = 0x1008FF75; /* don't use */ +pub const XKB_KEY_XF86RotationKB :u32 = 0x1008FF76; /* don't use */ +pub const XKB_KEY_XF86Save :u32 = 0x1008FF77; /* Save (file, document, state */ +pub const XKB_KEY_XF86ScrollUp :u32 = 0x1008FF78; /* Scroll window/contents up */ +pub const XKB_KEY_XF86ScrollDown :u32 = 0x1008FF79; /* Scrool window/contentd down */ +pub const XKB_KEY_XF86ScrollClick :u32 = 0x1008FF7A; /* Use XKB mousekeys instead */ +pub const XKB_KEY_XF86Send :u32 = 0x1008FF7B; /* Send mail, file, object */ +pub const XKB_KEY_XF86Spell :u32 = 0x1008FF7C; /* Spell checker */ +pub const XKB_KEY_XF86SplitScreen :u32 = 0x1008FF7D; /* Split window or screen */ +pub const XKB_KEY_XF86Support :u32 = 0x1008FF7E; /* Get support (??) */ +pub const XKB_KEY_XF86TaskPane :u32 = 0x1008FF7F; /* Show tasks */ +pub const XKB_KEY_XF86Terminal :u32 = 0x1008FF80; /* Launch terminal emulator */ +pub const XKB_KEY_XF86Tools :u32 = 0x1008FF81; /* toolbox of desktop/app. */ +pub const XKB_KEY_XF86Travel :u32 = 0x1008FF82; /* ?? */ +pub const XKB_KEY_XF86UserPB :u32 = 0x1008FF84; /* ?? */ +pub const XKB_KEY_XF86User1KB :u32 = 0x1008FF85; /* ?? */ +pub const XKB_KEY_XF86User2KB :u32 = 0x1008FF86; /* ?? */ +pub const XKB_KEY_XF86Video :u32 = 0x1008FF87; /* Launch video player */ +pub const XKB_KEY_XF86WheelButton :u32 = 0x1008FF88; /* button from a mouse wheel */ +pub const XKB_KEY_XF86Word :u32 = 0x1008FF89; /* Launch word processor */ +pub const XKB_KEY_XF86Xfer :u32 = 0x1008FF8A; +pub const XKB_KEY_XF86ZoomIn :u32 = 0x1008FF8B; /* zoom in view, map, etc. */ +pub const XKB_KEY_XF86ZoomOut :u32 = 0x1008FF8C; /* zoom out view, map, etc. */ + +pub const XKB_KEY_XF86Away :u32 = 0x1008FF8D; /* mark yourself as away */ +pub const XKB_KEY_XF86Messenger :u32 = 0x1008FF8E; /* as in instant messaging */ +pub const XKB_KEY_XF86WebCam :u32 = 0x1008FF8F; /* Launch web camera app. */ +pub const XKB_KEY_XF86MailForward :u32 = 0x1008FF90; /* Forward in mail */ +pub const XKB_KEY_XF86Pictures :u32 = 0x1008FF91; /* Show pictures */ +pub const XKB_KEY_XF86Music :u32 = 0x1008FF92; /* Launch music application */ + +pub const XKB_KEY_XF86Battery :u32 = 0x1008FF93; /* Display battery information */ +pub const XKB_KEY_XF86Bluetooth :u32 = 0x1008FF94; /* Enable/disable Bluetooth */ +pub const XKB_KEY_XF86WLAN :u32 = 0x1008FF95; /* Enable/disable WLAN */ +pub const XKB_KEY_XF86UWB :u32 = 0x1008FF96; /* Enable/disable UWB */ + +pub const XKB_KEY_XF86AudioForward :u32 = 0x1008FF97; /* fast-forward audio track */ +pub const XKB_KEY_XF86AudioRepeat :u32 = 0x1008FF98; /* toggle repeat mode */ +pub const XKB_KEY_XF86AudioRandomPlay :u32 = 0x1008FF99; /* toggle shuffle mode */ +pub const XKB_KEY_XF86Subtitle :u32 = 0x1008FF9A; /* cycle through subtitle */ +pub const XKB_KEY_XF86AudioCycleTrack :u32 = 0x1008FF9B; /* cycle through audio tracks */ +pub const XKB_KEY_XF86CycleAngle :u32 = 0x1008FF9C; /* cycle through angles */ +pub const XKB_KEY_XF86FrameBack :u32 = 0x1008FF9D; /* video: go one frame back */ +pub const XKB_KEY_XF86FrameForward :u32 = 0x1008FF9E; /* video: go one frame forward */ +pub const XKB_KEY_XF86Time :u32 = 0x1008FF9F; /* display, or shows an entry for time seeking */ +pub const XKB_KEY_XF86Select :u32 = 0x1008FFA0; /* Select button on joypads and remotes */ +pub const XKB_KEY_XF86View :u32 = 0x1008FFA1; /* Show a view options/properties */ +pub const XKB_KEY_XF86TopMenu :u32 = 0x1008FFA2; /* Go to a top-level menu in a video */ + +pub const XKB_KEY_XF86Red :u32 = 0x1008FFA3; /* Red button */ +pub const XKB_KEY_XF86Green :u32 = 0x1008FFA4; /* Green button */ +pub const XKB_KEY_XF86Yellow :u32 = 0x1008FFA5; /* Yellow button */ +pub const XKB_KEY_XF86Blue :u32 = 0x1008FFA6; /* Blue button */ + +pub const XKB_KEY_XF86Suspend :u32 = 0x1008FFA7; /* Sleep to RAM */ +pub const XKB_KEY_XF86Hibernate :u32 = 0x1008FFA8; /* Sleep to disk */ +pub const XKB_KEY_XF86TouchpadToggle :u32 = 0x1008FFA9; /* Toggle between touchpad/trackstick */ +pub const XKB_KEY_XF86TouchpadOn :u32 = 0x1008FFB0; /* The touchpad got switched on */ +pub const XKB_KEY_XF86TouchpadOff :u32 = 0x1008FFB1; /* The touchpad got switched off */ + +pub const XKB_KEY_XF86AudioMicMute :u32 = 0x1008FFB2; /* Mute the Mic from the system */ + +/* Keys for special action keys (hot keys) */ +/* Virtual terminals on some operating systems */ +pub const XKB_KEY_XF86Switch_VT_1 :u32 = 0x1008FE01; +pub const XKB_KEY_XF86Switch_VT_2 :u32 = 0x1008FE02; +pub const XKB_KEY_XF86Switch_VT_3 :u32 = 0x1008FE03; +pub const XKB_KEY_XF86Switch_VT_4 :u32 = 0x1008FE04; +pub const XKB_KEY_XF86Switch_VT_5 :u32 = 0x1008FE05; +pub const XKB_KEY_XF86Switch_VT_6 :u32 = 0x1008FE06; +pub const XKB_KEY_XF86Switch_VT_7 :u32 = 0x1008FE07; +pub const XKB_KEY_XF86Switch_VT_8 :u32 = 0x1008FE08; +pub const XKB_KEY_XF86Switch_VT_9 :u32 = 0x1008FE09; +pub const XKB_KEY_XF86Switch_VT_10 :u32 = 0x1008FE0A; +pub const XKB_KEY_XF86Switch_VT_11 :u32 = 0x1008FE0B; +pub const XKB_KEY_XF86Switch_VT_12 :u32 = 0x1008FE0C; + +pub const XKB_KEY_XF86Ungrab :u32 = 0x1008FE20; /* force ungrab */ +pub const XKB_KEY_XF86ClearGrab :u32 = 0x1008FE21; /* kill application with grab */ +pub const XKB_KEY_XF86Next_VMode :u32 = 0x1008FE22; /* next video mode available */ +pub const XKB_KEY_XF86Prev_VMode :u32 = 0x1008FE23; /* prev. video mode available */ +pub const XKB_KEY_XF86LogWindowTree :u32 = 0x1008FE24; /* print window tree to log */ +pub const XKB_KEY_XF86LogGrabInfo :u32 = 0x1008FE25; /* print all active grabs to log */ +/* + * Copyright (c) 1991, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/************************************************************ + +Copyright 1991, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +***********************************************************/ + +/* + * Floating Accent + */ + +pub const XKB_KEY_SunFA_Grave :u32 = 0x1005FF00; +pub const XKB_KEY_SunFA_Circum :u32 = 0x1005FF01; +pub const XKB_KEY_SunFA_Tilde :u32 = 0x1005FF02; +pub const XKB_KEY_SunFA_Acute :u32 = 0x1005FF03; +pub const XKB_KEY_SunFA_Diaeresis :u32 = 0x1005FF04; +pub const XKB_KEY_SunFA_Cedilla :u32 = 0x1005FF05; + +/* + * Miscellaneous Functions + */ + +pub const XKB_KEY_SunF36 :u32 = 0x1005FF10; /* Labeled F11 */ +pub const XKB_KEY_SunF37 :u32 = 0x1005FF11; /* Labeled F12 */ + +pub const XKB_KEY_SunSys_Req :u32 = 0x1005FF60; +pub const XKB_KEY_SunPrint_Screen :u32 = 0x0000FF61; /* Same as XK_Print */ + +/* + * International & Multi-Key Character Composition + */ + +pub const XKB_KEY_SunCompose :u32 = 0x0000FF20; /* Same as XK_Multi_key */ +pub const XKB_KEY_SunAltGraph :u32 = 0x0000FF7E; /* Same as XK_Mode_switch */ + +/* + * Cursor Control + */ + +pub const XKB_KEY_SunPageUp :u32 = 0x0000FF55; /* Same as XK_Prior */ +pub const XKB_KEY_SunPageDown :u32 = 0x0000FF56; /* Same as XK_Next */ + +/* + * Open Look Functions + */ + +pub const XKB_KEY_SunUndo :u32 = 0x0000FF65; /* Same as XK_Undo */ +pub const XKB_KEY_SunAgain :u32 = 0x0000FF66; /* Same as XK_Redo */ +pub const XKB_KEY_SunFind :u32 = 0x0000FF68; /* Same as XK_Find */ +pub const XKB_KEY_SunStop :u32 = 0x0000FF69; /* Same as XK_Cancel */ +pub const XKB_KEY_SunProps :u32 = 0x1005FF70; +pub const XKB_KEY_SunFront :u32 = 0x1005FF71; +pub const XKB_KEY_SunCopy :u32 = 0x1005FF72; +pub const XKB_KEY_SunOpen :u32 = 0x1005FF73; +pub const XKB_KEY_SunPaste :u32 = 0x1005FF74; +pub const XKB_KEY_SunCut :u32 = 0x1005FF75; + +pub const XKB_KEY_SunPowerSwitch :u32 = 0x1005FF76; +pub const XKB_KEY_SunAudioLowerVolume :u32 = 0x1005FF77; +pub const XKB_KEY_SunAudioMute :u32 = 0x1005FF78; +pub const XKB_KEY_SunAudioRaiseVolume :u32 = 0x1005FF79; +pub const XKB_KEY_SunVideoDegauss :u32 = 0x1005FF7A; +pub const XKB_KEY_SunVideoLowerBrightness :u32 = 0x1005FF7B; +pub const XKB_KEY_SunVideoRaiseBrightness :u32 = 0x1005FF7C; +pub const XKB_KEY_SunPowerSwitchShift :u32 = 0x1005FF7D; +/*********************************************************** + +Copyright 1988, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1988 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +/* + * DEC private keysyms + * (29th bit set) + */ + +/* two-key compose sequence initiators, chosen to map to Latin1 characters */ + +pub const XKB_KEY_Dring_accent :u32 = 0x1000FEB0; +pub const XKB_KEY_Dcircumflex_accent :u32 = 0x1000FE5E; +pub const XKB_KEY_Dcedilla_accent :u32 = 0x1000FE2C; +pub const XKB_KEY_Dacute_accent :u32 = 0x1000FE27; +pub const XKB_KEY_Dgrave_accent :u32 = 0x1000FE60; +pub const XKB_KEY_Dtilde :u32 = 0x1000FE7E; +pub const XKB_KEY_Ddiaeresis :u32 = 0x1000FE22; + +/* special keysym for LK2** "Remove" key on editing keypad */ + +pub const XKB_KEY_DRemove :u32 = 0x1000FF00; /* Remove */ +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Hewlett Packard +or Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD +TO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. Hewlett-Packard shall not be liable for errors +contained herein or direct, indirect, special, incidental or +consequential damages in connection with the furnishing, +performance, or use of this material. + +*/ + + + +pub const XKB_KEY_hpClearLine :u32 = 0x1000FF6F; +pub const XKB_KEY_hpInsertLine :u32 = 0x1000FF70; +pub const XKB_KEY_hpDeleteLine :u32 = 0x1000FF71; +pub const XKB_KEY_hpInsertChar :u32 = 0x1000FF72; +pub const XKB_KEY_hpDeleteChar :u32 = 0x1000FF73; +pub const XKB_KEY_hpBackTab :u32 = 0x1000FF74; +pub const XKB_KEY_hpKP_BackTab :u32 = 0x1000FF75; +pub const XKB_KEY_hpModelock1 :u32 = 0x1000FF48; +pub const XKB_KEY_hpModelock2 :u32 = 0x1000FF49; +pub const XKB_KEY_hpReset :u32 = 0x1000FF6C; +pub const XKB_KEY_hpSystem :u32 = 0x1000FF6D; +pub const XKB_KEY_hpUser :u32 = 0x1000FF6E; +pub const XKB_KEY_hpmute_acute :u32 = 0x100000A8; +pub const XKB_KEY_hpmute_grave :u32 = 0x100000A9; +pub const XKB_KEY_hpmute_asciicircum :u32 = 0x100000AA; +pub const XKB_KEY_hpmute_diaeresis :u32 = 0x100000AB; +pub const XKB_KEY_hpmute_asciitilde :u32 = 0x100000AC; +pub const XKB_KEY_hplira :u32 = 0x100000AF; +pub const XKB_KEY_hpguilder :u32 = 0x100000BE; +pub const XKB_KEY_hpYdiaeresis :u32 = 0x100000EE; +pub const XKB_KEY_hpIO :u32 = 0x100000EE; +pub const XKB_KEY_hplongminus :u32 = 0x100000F6; +pub const XKB_KEY_hpblock :u32 = 0x100000FC; + + + +pub const XKB_KEY_osfCopy :u32 = 0x1004FF02; +pub const XKB_KEY_osfCut :u32 = 0x1004FF03; +pub const XKB_KEY_osfPaste :u32 = 0x1004FF04; +pub const XKB_KEY_osfBackTab :u32 = 0x1004FF07; +pub const XKB_KEY_osfBackSpace :u32 = 0x1004FF08; +pub const XKB_KEY_osfClear :u32 = 0x1004FF0B; +pub const XKB_KEY_osfEscape :u32 = 0x1004FF1B; +pub const XKB_KEY_osfAddMode :u32 = 0x1004FF31; +pub const XKB_KEY_osfPrimaryPaste :u32 = 0x1004FF32; +pub const XKB_KEY_osfQuickPaste :u32 = 0x1004FF33; +pub const XKB_KEY_osfPageLeft :u32 = 0x1004FF40; +pub const XKB_KEY_osfPageUp :u32 = 0x1004FF41; +pub const XKB_KEY_osfPageDown :u32 = 0x1004FF42; +pub const XKB_KEY_osfPageRight :u32 = 0x1004FF43; +pub const XKB_KEY_osfActivate :u32 = 0x1004FF44; +pub const XKB_KEY_osfMenuBar :u32 = 0x1004FF45; +pub const XKB_KEY_osfLeft :u32 = 0x1004FF51; +pub const XKB_KEY_osfUp :u32 = 0x1004FF52; +pub const XKB_KEY_osfRight :u32 = 0x1004FF53; +pub const XKB_KEY_osfDown :u32 = 0x1004FF54; +pub const XKB_KEY_osfEndLine :u32 = 0x1004FF57; +pub const XKB_KEY_osfBeginLine :u32 = 0x1004FF58; +pub const XKB_KEY_osfEndData :u32 = 0x1004FF59; +pub const XKB_KEY_osfBeginData :u32 = 0x1004FF5A; +pub const XKB_KEY_osfPrevMenu :u32 = 0x1004FF5B; +pub const XKB_KEY_osfNextMenu :u32 = 0x1004FF5C; +pub const XKB_KEY_osfPrevField :u32 = 0x1004FF5D; +pub const XKB_KEY_osfNextField :u32 = 0x1004FF5E; +pub const XKB_KEY_osfSelect :u32 = 0x1004FF60; +pub const XKB_KEY_osfInsert :u32 = 0x1004FF63; +pub const XKB_KEY_osfUndo :u32 = 0x1004FF65; +pub const XKB_KEY_osfMenu :u32 = 0x1004FF67; +pub const XKB_KEY_osfCancel :u32 = 0x1004FF69; +pub const XKB_KEY_osfHelp :u32 = 0x1004FF6A; +pub const XKB_KEY_osfSelectAll :u32 = 0x1004FF71; +pub const XKB_KEY_osfDeselectAll :u32 = 0x1004FF72; +pub const XKB_KEY_osfReselect :u32 = 0x1004FF73; +pub const XKB_KEY_osfExtend :u32 = 0x1004FF74; +pub const XKB_KEY_osfRestore :u32 = 0x1004FF78; +pub const XKB_KEY_osfDelete :u32 = 0x1004FFFF; + + + +/************************************************************** + * The use of the following macros is deprecated. + * They are listed below only for backwards compatibility. + */ +pub const XKB_KEY_Reset :u32 = 0x1000FF6C; +pub const XKB_KEY_System :u32 = 0x1000FF6D; +pub const XKB_KEY_User :u32 = 0x1000FF6E; +pub const XKB_KEY_ClearLine :u32 = 0x1000FF6F; +pub const XKB_KEY_InsertLine :u32 = 0x1000FF70; +pub const XKB_KEY_DeleteLine :u32 = 0x1000FF71; +pub const XKB_KEY_InsertChar :u32 = 0x1000FF72; +pub const XKB_KEY_DeleteChar :u32 = 0x1000FF73; +pub const XKB_KEY_BackTab :u32 = 0x1000FF74; +pub const XKB_KEY_KP_BackTab :u32 = 0x1000FF75; +pub const XKB_KEY_Ext16bit_L :u32 = 0x1000FF76; +pub const XKB_KEY_Ext16bit_R :u32 = 0x1000FF77; +pub const XKB_KEY_mute_acute :u32 = 0x100000a8; +pub const XKB_KEY_mute_grave :u32 = 0x100000a9; +pub const XKB_KEY_mute_asciicircum :u32 = 0x100000aa; +pub const XKB_KEY_mute_diaeresis :u32 = 0x100000ab; +pub const XKB_KEY_mute_asciitilde :u32 = 0x100000ac; +pub const XKB_KEY_lira :u32 = 0x100000af; +pub const XKB_KEY_guilder :u32 = 0x100000be; +pub const XKB_KEY_IO :u32 = 0x100000ee; +pub const XKB_KEY_longminus :u32 = 0x100000f6; +pub const XKB_KEY_block :u32 = 0x100000fc; + diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/keyboard/mod.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/keyboard/mod.rs new file mode 100644 index 0000000..359de1d --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/keyboard/mod.rs @@ -0,0 +1,893 @@ +//! Utilities for keymap interpretation of keyboard input +//! This module provides an implementation for `wl_keyboard` +//! objects using `libxkbcommon` to interpret the keyboard input +//! given the user keymap. +//! +//! You simply need to provide an implementation to receive the +//! intepreted events, as described by the `Event` enum of this modules. +//! +//! Implementation of you `NewProxy<WlKeyboard>` can be done with the +//! `map_keyboard_auto` or the `map_keyboard_rmlvo` functions depending +//! on whether you wish to use the keymap provided by the server or a +//! specific one. + +use std::env; +use std::ffi::CString; +use std::fs::File; +use std::os::raw::c_char; +use std::os::unix::ffi::OsStringExt; +use std::os::unix::io::{FromRawFd, RawFd}; +use std::ptr; +use std::sync::{mpsc, Arc, Mutex}; +use std::thread; +use std::time::{Duration, Instant}; + +use memmap::MmapOptions; + +pub use wayland_client::protocol::wl_keyboard::KeyState; +use wayland_client::protocol::{wl_keyboard, wl_seat, wl_surface}; +use wayland_client::Proxy; + +use wayland_client::protocol::wl_seat::RequestsTrait; + +use self::ffi::xkb_state_component; +use self::ffi::XKBCOMMON_HANDLE as XKBH; + +mod ffi; +pub mod keysyms; + +struct KbState { + xkb_context: *mut ffi::xkb_context, + xkb_keymap: *mut ffi::xkb_keymap, + xkb_state: *mut ffi::xkb_state, + xkb_compose_table: *mut ffi::xkb_compose_table, + xkb_compose_state: *mut ffi::xkb_compose_state, + mods_state: ModifiersState, + locked: bool, +} + +/// Represents the current state of the keyboard modifiers +/// +/// Each field of this struct represents a modifier and is `true` if this modifier is active. +/// +/// For some modifiers, this means that the key is currently pressed, others are toggled +/// (like caps lock). +#[derive(Copy, Clone, Debug, Default)] +pub struct ModifiersState { + /// The "control" key + pub ctrl: bool, + /// The "alt" key + pub alt: bool, + /// The "shift" key + pub shift: bool, + /// The "Caps lock" key + pub caps_lock: bool, + /// The "logo" key + /// + /// Also known as the "windows" key on most keyboards + pub logo: bool, + /// The "Num lock" key + pub num_lock: bool, +} + +impl ModifiersState { + fn new() -> ModifiersState { + ModifiersState::default() + } + + fn update_with(&mut self, state: *mut ffi::xkb_state) { + self.ctrl = unsafe { + (XKBH.xkb_state_mod_name_is_active)( + state, + ffi::XKB_MOD_NAME_CTRL.as_ptr() as *const c_char, + xkb_state_component::XKB_STATE_MODS_EFFECTIVE, + ) > 0 + }; + self.alt = unsafe { + (XKBH.xkb_state_mod_name_is_active)( + state, + ffi::XKB_MOD_NAME_ALT.as_ptr() as *const c_char, + xkb_state_component::XKB_STATE_MODS_EFFECTIVE, + ) > 0 + }; + self.shift = unsafe { + (XKBH.xkb_state_mod_name_is_active)( + state, + ffi::XKB_MOD_NAME_SHIFT.as_ptr() as *const c_char, + xkb_state_component::XKB_STATE_MODS_EFFECTIVE, + ) > 0 + }; + self.caps_lock = unsafe { + (XKBH.xkb_state_mod_name_is_active)( + state, + ffi::XKB_MOD_NAME_CAPS.as_ptr() as *const c_char, + xkb_state_component::XKB_STATE_MODS_EFFECTIVE, + ) > 0 + }; + self.logo = unsafe { + (XKBH.xkb_state_mod_name_is_active)( + state, + ffi::XKB_MOD_NAME_LOGO.as_ptr() as *const c_char, + xkb_state_component::XKB_STATE_MODS_EFFECTIVE, + ) > 0 + }; + self.num_lock = unsafe { + (XKBH.xkb_state_mod_name_is_active)( + state, + ffi::XKB_MOD_NAME_NUM.as_ptr() as *const c_char, + xkb_state_component::XKB_STATE_MODS_EFFECTIVE, + ) > 0 + }; + } +} + +unsafe impl Send for KbState {} + +impl KbState { + fn update_modifiers( + &mut self, + mods_depressed: u32, + mods_latched: u32, + mods_locked: u32, + group: u32, + ) { + if !self.ready() { + return; + } + let mask = unsafe { + (XKBH.xkb_state_update_mask)( + self.xkb_state, + mods_depressed, + mods_latched, + mods_locked, + 0, + 0, + group, + ) + }; + if mask.contains(xkb_state_component::XKB_STATE_MODS_EFFECTIVE) { + // effective value of mods have changed, we need to update our state + self.mods_state.update_with(self.xkb_state); + } + } + + fn get_one_sym_raw(&mut self, keycode: u32) -> u32 { + if !self.ready() { + return 0; + } + unsafe { (XKBH.xkb_state_key_get_one_sym)(self.xkb_state, keycode + 8) } + } + + fn get_utf8_raw(&mut self, keycode: u32) -> Option<String> { + if !self.ready() { + return None; + } + let size = unsafe { + (XKBH.xkb_state_key_get_utf8)(self.xkb_state, keycode + 8, ptr::null_mut(), 0) + } + 1; + if size <= 1 { + return None; + }; + let mut buffer = Vec::with_capacity(size as usize); + unsafe { + buffer.set_len(size as usize); + (XKBH.xkb_state_key_get_utf8)( + self.xkb_state, + keycode + 8, + buffer.as_mut_ptr() as *mut _, + size as usize, + ); + }; + // remove the final `\0` + buffer.pop(); + // libxkbcommon will always provide valid UTF8 + Some(unsafe { String::from_utf8_unchecked(buffer) }) + } + + fn compose_feed(&mut self, keysym: u32) -> Option<ffi::xkb_compose_feed_result> { + if !self.ready() || self.xkb_compose_state.is_null() { + return None; + } + Some(unsafe { (XKBH.xkb_compose_state_feed)(self.xkb_compose_state, keysym) }) + } + + fn compose_status(&mut self) -> Option<ffi::xkb_compose_status> { + if !self.ready() || self.xkb_compose_state.is_null() { + return None; + } + Some(unsafe { (XKBH.xkb_compose_state_get_status)(self.xkb_compose_state) }) + } + + fn compose_get_utf8(&mut self) -> Option<String> { + if !self.ready() || self.xkb_compose_state.is_null() { + return None; + } + let size = unsafe { + (XKBH.xkb_compose_state_get_utf8)(self.xkb_compose_state, ptr::null_mut(), 0) + } + 1; + if size <= 1 { + return None; + }; + let mut buffer = Vec::with_capacity(size as usize); + unsafe { + buffer.set_len(size as usize); + (XKBH.xkb_compose_state_get_utf8)( + self.xkb_compose_state, + buffer.as_mut_ptr() as *mut _, + size as usize, + ); + }; + // remove the final `\0` + buffer.pop(); + // libxkbcommon will always provide valid UTF8 + Some(unsafe { String::from_utf8_unchecked(buffer) }) + } + + fn new() -> Result<KbState, Error> { + let xkbh = match ffi::XKBCOMMON_OPTION.as_ref() { + Some(h) => h, + None => return Err(Error::XKBNotFound), + }; + let xkb_context = + unsafe { (xkbh.xkb_context_new)(ffi::xkb_context_flags::XKB_CONTEXT_NO_FLAGS) }; + if xkb_context.is_null() { + return Err(Error::XKBNotFound); + } + + let mut me = KbState { + xkb_context, + xkb_keymap: ptr::null_mut(), + xkb_state: ptr::null_mut(), + xkb_compose_table: ptr::null_mut(), + xkb_compose_state: ptr::null_mut(), + mods_state: ModifiersState::new(), + locked: false, + }; + + unsafe { + me.init_compose(); + } + + Ok(me) + } + + unsafe fn init_compose(&mut self) { + let locale = env::var_os("LC_ALL") + .or_else(|| env::var_os("LC_CTYPE")) + .or_else(|| env::var_os("LANG")) + .unwrap_or_else(|| "C".into()); + let locale = CString::new(locale.into_vec()).unwrap(); + + let compose_table = (XKBH.xkb_compose_table_new_from_locale)( + self.xkb_context, + locale.as_ptr(), + ffi::xkb_compose_compile_flags::XKB_COMPOSE_COMPILE_NO_FLAGS, + ); + + if compose_table.is_null() { + // init of compose table failed, continue without compose + return; + } + + let compose_state = (XKBH.xkb_compose_state_new)( + compose_table, + ffi::xkb_compose_state_flags::XKB_COMPOSE_STATE_NO_FLAGS, + ); + + if compose_state.is_null() { + // init of compose state failed, continue without compose + (XKBH.xkb_compose_table_unref)(compose_table); + return; + } + + self.xkb_compose_table = compose_table; + self.xkb_compose_state = compose_state; + } + + unsafe fn post_init(&mut self, xkb_keymap: *mut ffi::xkb_keymap) { + let xkb_state = (XKBH.xkb_state_new)(xkb_keymap); + self.xkb_keymap = xkb_keymap; + self.xkb_state = xkb_state; + self.mods_state.update_with(xkb_state); + } + + unsafe fn de_init(&mut self) { + (XKBH.xkb_state_unref)(self.xkb_state); + self.xkb_state = ptr::null_mut(); + (XKBH.xkb_keymap_unref)(self.xkb_keymap); + self.xkb_keymap = ptr::null_mut(); + } + + unsafe fn init_with_fd(&mut self, fd: RawFd, size: usize) { + let map = MmapOptions::new() + .len(size) + .map(&File::from_raw_fd(fd)) + .unwrap(); + + let xkb_keymap = (XKBH.xkb_keymap_new_from_string)( + self.xkb_context, + map.as_ptr() as *const _, + ffi::xkb_keymap_format::XKB_KEYMAP_FORMAT_TEXT_V1, + ffi::xkb_keymap_compile_flags::XKB_KEYMAP_COMPILE_NO_FLAGS, + ); + + if xkb_keymap.is_null() { + panic!("Received invalid keymap from compositor."); + } + + self.post_init(xkb_keymap); + } + + unsafe fn init_with_rmlvo(&mut self, names: ffi::xkb_rule_names) -> Result<(), Error> { + let xkb_keymap = (XKBH.xkb_keymap_new_from_names)( + self.xkb_context, + &names, + ffi::xkb_keymap_compile_flags::XKB_KEYMAP_COMPILE_NO_FLAGS, + ); + + if xkb_keymap.is_null() { + return Err(Error::BadNames); + } + + self.post_init(xkb_keymap); + + Ok(()) + } + + unsafe fn key_repeats(&mut self, xkb_keycode_t: ffi::xkb_keycode_t) -> bool { + (XKBH.xkb_keymap_key_repeats)(self.xkb_keymap, xkb_keycode_t) == 1 + } + + #[inline] + fn ready(&self) -> bool { + !self.xkb_state.is_null() + } +} + +impl Drop for KbState { + fn drop(&mut self) { + unsafe { + (XKBH.xkb_compose_state_unref)(self.xkb_compose_state); + (XKBH.xkb_compose_table_unref)(self.xkb_compose_table); + (XKBH.xkb_state_unref)(self.xkb_state); + (XKBH.xkb_keymap_unref)(self.xkb_keymap); + (XKBH.xkb_context_unref)(self.xkb_context); + } + } +} + +/// Determines the behavior of key repetition +#[derive(PartialEq)] +pub enum KeyRepeatKind { + /// keys will be repeated at a set rate and delay + Fixed { + /// the number of repetitions per second that should occur + rate: u64, + /// delay (in milliseconds) between a key press and the start of repetition + delay: u64, + }, + /// keys will be repeated at a rate and delay set by the wayland server + System, +} + +#[derive(Debug)] +/// An error that occurred while trying to initialize a mapped keyboard +pub enum Error { + /// libxkbcommon is not available + XKBNotFound, + /// Provided RMLVO specified a keymap that would not be loaded + BadNames, +} + +/// The RMLVO description of a keymap +/// +/// All fields are optional, and the system default +/// will be used if set to `None`. +pub struct RMLVO { + /// The rules file to use + pub rules: Option<String>, + /// The keyboard model by which to interpret keycodes and LEDs + pub model: Option<String>, + /// A comma separated list of layouts (languages) to include in the keymap + pub layout: Option<String>, + /// A comma separated list of variants, one per layout, which may modify or + /// augment the respective layout in various ways + pub variant: Option<String>, + /// A comma separated list of options, through which the user specifies + /// non-layout related preferences, like which key combinations are + /// used for switching layouts, or which key is the Compose key. + pub options: Option<String>, +} + +/// Events received from a mapped keyboard +pub enum Event<'a> { + /// The keyboard focus has entered a surface + Enter { + /// serial number of the event + serial: u32, + /// surface that was entered + surface: Proxy<wl_surface::WlSurface>, + /// raw values of the currently pressed keys + rawkeys: &'a [u32], + /// interpreted symbols of the currently pressed keys + keysyms: &'a [u32], + }, + /// The keyboard focus has left a surface + Leave { + /// serial number of the event + serial: u32, + /// surface that was left + surface: Proxy<wl_surface::WlSurface>, + }, + /// A key event occurred + Key { + /// serial number of the event + serial: u32, + /// time at which the keypress occurred + time: u32, + /// raw value of the key + rawkey: u32, + /// interpreted symbol of the key + keysym: u32, + /// new state of the key + state: KeyState, + /// utf8 interpretation of the entered text + /// + /// will always be `None` on key release events + utf8: Option<String>, + }, + /// Repetition information advertising + RepeatInfo { + /// rate (in millisecond) at which the repetition should occur + rate: i32, + /// delay (in millisecond) between a key press and the start of repetition + delay: i32, + }, + /// The key modifiers have changed state + Modifiers { + /// current state of the modifiers + modifiers: ModifiersState, + }, +} + +/// An event sent at repeated intervals for certain keys determined by xkb_keymap_key_repeats +pub struct KeyRepeatEvent { + /// time at which the keypress occurred + pub time: u32, + /// raw value of the key + pub rawkey: u32, + /// interpreted symbol of the key + pub keysym: u32, + /// utf8 interpretation of the entered text + pub utf8: Option<String>, +} + +/// Implement a keyboard to automatically detect the keymap +/// +/// This requires you to provide an implementation to receive the events after they +/// have been interpreted with the keymap. +/// +/// The keymap information will be loaded from the events sent by the compositor, +/// as such you need to call this method as soon as you have created the keyboard +/// to make sure this event does not get lost. +/// +/// Returns an error if xkbcommon could not be initialized. +pub fn map_keyboard_auto<Impl>( + seat: &Proxy<wl_seat::WlSeat>, + implementation: Impl, +) -> Result<Proxy<wl_keyboard::WlKeyboard>, Error> +where + for<'a> Impl: FnMut(Event<'a>, Proxy<wl_keyboard::WlKeyboard>) + Send + 'static, +{ + let state = match KbState::new() { + Ok(s) => s, + Err(e) => return Err(e), + }; + Ok(implement_kbd( + seat, + state, + implementation, + None::<(_, fn(_, _))>, + )) +} + +/// Implement a keyboard for a predefined keymap +/// +/// This requires you to provide an implementation to receive the events after they +/// have been interpreted with the keymap. +/// +/// The keymap will be loaded from the provided RMLVO rules. Any keymap provided +/// by the compositor will be ignored. +/// +/// Returns an error if xkbcommon could not be initialized or the RMLVO specification +/// contained invalid values. +pub fn map_keyboard_rmlvo<Impl>( + seat: &Proxy<wl_seat::WlSeat>, + rmlvo: RMLVO, + implementation: Impl, +) -> Result<Proxy<wl_keyboard::WlKeyboard>, Error> +where + for<'a> Impl: FnMut(Event<'a>, Proxy<wl_keyboard::WlKeyboard>) + Send + 'static, +{ + fn to_cstring(s: Option<String>) -> Result<Option<CString>, Error> { + s.map_or(Ok(None), |s| CString::new(s).map(Option::Some)) + .map_err(|_| Error::BadNames) + } + + fn init_state(rmlvo: RMLVO) -> Result<KbState, Error> { + let mut state = KbState::new()?; + + let rules = to_cstring(rmlvo.rules)?; + let model = to_cstring(rmlvo.model)?; + let layout = to_cstring(rmlvo.layout)?; + let variant = to_cstring(rmlvo.variant)?; + let options = to_cstring(rmlvo.options)?; + + let xkb_names = ffi::xkb_rule_names { + rules: rules.map_or(ptr::null(), |s| s.as_ptr()), + model: model.map_or(ptr::null(), |s| s.as_ptr()), + layout: layout.map_or(ptr::null(), |s| s.as_ptr()), + variant: variant.map_or(ptr::null(), |s| s.as_ptr()), + options: options.map_or(ptr::null(), |s| s.as_ptr()), + }; + + unsafe { + state.init_with_rmlvo(xkb_names)?; + } + + state.locked = true; + Ok(state) + } + + match init_state(rmlvo) { + Ok(state) => Ok(implement_kbd( + seat, + state, + implementation, + None::<(_, fn(_, _))>, + )), + Err(error) => Err(error), + } +} + +fn implement_kbd<Impl, RepeatImpl>( + seat: &Proxy<wl_seat::WlSeat>, + state: KbState, + mut event_impl: Impl, + repeat: Option<(KeyRepeatKind, RepeatImpl)>, +) -> Proxy<wl_keyboard::WlKeyboard> +where + for<'a> Impl: FnMut(Event<'a>, Proxy<wl_keyboard::WlKeyboard>) + Send + 'static, + RepeatImpl: FnMut(KeyRepeatEvent, Proxy<wl_keyboard::WlKeyboard>) + Send + 'static, +{ + let safe_state = Arc::new(Mutex::new(state)); + let (key_repeat_kind, repeat_impl) = { + if let Some(repeat) = repeat { + (Some(repeat.0), Some(Arc::new(Mutex::new(repeat.1)))) + } else { + (None, None) + } + }; + let kill_chan = Arc::new(Mutex::new(mpsc::channel::<()>())); + let state_chan = Arc::new(Mutex::new(mpsc::channel::<()>())); + let mut key_held: Option<u32> = None; + let system_repeat_timing: Arc<Mutex<(u64, u64)>> = Arc::new(Mutex::new((30, 500))); + + seat.get_keyboard(|kbd| { + kbd.implement( + move |event: wl_keyboard::Event, proxy: Proxy<wl_keyboard::WlKeyboard>| { + let mut state = safe_state.lock().unwrap(); + match event { + wl_keyboard::Event::Keymap { format, fd, size } => { + if state.locked { + // state is locked, ignore keymap updates + return; + } + if state.ready() { + // new keymap, we first deinit to free resources + unsafe { + state.de_init(); + } + } + match format { + wl_keyboard::KeymapFormat::XkbV1 => unsafe { + state.init_with_fd(fd, size as usize); + }, + wl_keyboard::KeymapFormat::NoKeymap => { + // TODO: how to handle this (hopefully never occuring) case? + } + } + } + wl_keyboard::Event::Enter { + serial, + surface, + keys, + } => { + let rawkeys: &[u32] = unsafe { + ::std::slice::from_raw_parts( + keys.as_ptr() as *const u32, + keys.len() / 4, + ) + }; + let keys: Vec<u32> = + rawkeys.iter().map(|k| state.get_one_sym_raw(*k)).collect(); + event_impl( + Event::Enter { + serial, + surface, + rawkeys, + keysyms: &keys, + }, + proxy, + ); + } + wl_keyboard::Event::Leave { serial, surface } => { + if key_held.is_some() { + kill_chan.lock().unwrap().0.send(()).unwrap(); + key_held = None; + } + event_impl(Event::Leave { serial, surface }, proxy); + } + wl_keyboard::Event::Key { + serial, + time, + key, + state: key_state, + } => { + // Get the values to generate a key event + let sym = state.get_one_sym_raw(key); + let utf8 = if key_state == wl_keyboard::KeyState::Pressed { + if state.compose_feed(sym) + != Some(ffi::xkb_compose_feed_result::XKB_COMPOSE_FEED_ACCEPTED) + { + None + } else if let Some(status) = state.compose_status() { + match status { + ffi::xkb_compose_status::XKB_COMPOSE_COMPOSED => { + state.compose_get_utf8() + } + ffi::xkb_compose_status::XKB_COMPOSE_NOTHING => { + state.get_utf8_raw(key) + } + _ => None, + } + } else { + state.get_utf8_raw(key) + } + } else { + None + }; + + if key_state == wl_keyboard::KeyState::Pressed { + event_impl( + Event::Key { + serial, + time, + rawkey: key, + keysym: sym, + state: key_state, + utf8: utf8.clone(), + }, + proxy.clone(), + ); + if let Some(repeat_impl) = repeat_impl.clone() { + // Check with xkb if key is repeatable + if unsafe { state.key_repeats(key + 8) } { + if key_held.is_some() { + // If a key is being held then kill its repeat thread + kill_chan.lock().unwrap().0.send(()).unwrap(); + } + key_held = Some(key); + // Clone variables for the thread + let thread_kill_chan = kill_chan.clone(); + let thread_state_chan = state_chan.clone(); + let thread_state = safe_state.clone(); + let thread_repeat_impl = repeat_impl.clone(); + let repeat_timing = match key_repeat_kind { + Some(KeyRepeatKind::Fixed { rate, delay, .. }) => { + (rate, delay) + } + Some(KeyRepeatKind::System { .. }) => { + *system_repeat_timing.lock().unwrap() + } + None => panic!(), + }; + // Start thread to send key events + thread::spawn(move || { + let time_tracker = Instant::now(); + // Delay + thread::sleep(Duration::from_millis(repeat_timing.1)); + match thread_kill_chan.lock().unwrap().1.try_recv() { + Ok(_) | Err(mpsc::TryRecvError::Disconnected) => return, + _ => {} + } + let mut thread_sym = sym; + let mut thread_utf8 = utf8; + + loop { + if thread_state_chan + .lock() + .unwrap() + .1 + .try_recv() + .is_ok() + { + let mut thread_state = thread_state.lock().unwrap(); + thread_sym = thread_state.get_one_sym_raw(key); + thread_utf8 = thread_state.get_utf8_raw(key); + } + let elapsed_time = time_tracker.elapsed(); + (&mut *thread_repeat_impl.lock().unwrap())( + KeyRepeatEvent { + time: time + + elapsed_time.as_secs() as u32 * 1000 + + elapsed_time.subsec_nanos() / 1_000_000, + rawkey: key, + keysym: thread_sym, + utf8: thread_utf8.clone(), + }, + proxy.clone(), + ); + // Rate + thread::sleep( + Duration::from_secs(1) / repeat_timing.0 as u32, + ); + match thread_kill_chan.lock().unwrap().1.try_recv() { + Ok(_) | Err(mpsc::TryRecvError::Disconnected) => { + break; + } + _ => {} + } + } + }); + } + } + } else { + if key_held == Some(key) { + kill_chan.lock().unwrap().0.send(()).unwrap(); + key_held = None; + } + event_impl( + Event::Key { + serial, + time, + rawkey: key, + keysym: sym, + state: key_state, + utf8: utf8.clone(), + }, + proxy.clone(), + ); + } + } + wl_keyboard::Event::Modifiers { + mods_depressed, + mods_latched, + mods_locked, + group, + .. + } => { + state.update_modifiers(mods_depressed, mods_latched, mods_locked, group); + event_impl( + Event::Modifiers { + modifiers: state.mods_state, + }, + proxy, + ); + if key_held.is_some() { + state_chan.lock().unwrap().0.send(()).unwrap(); + } + } + wl_keyboard::Event::RepeatInfo { rate, delay } => { + event_impl(Event::RepeatInfo { rate, delay }, proxy); + *system_repeat_timing.lock().unwrap() = (rate as u64, delay as u64); + } + } + }, + (), + ) + }) + .unwrap() +} + +/// Implement a keyboard to automatically detect the keymap and send KeyRepeatEvents +/// at set intervals +/// +/// This requires you to provide an implementation to receive the events after they +/// have been interpreted with the keymap. You must also provide an implementation to be called +/// when KeyRepeatEvents are sent at intervals set by the KeyRepeatKind argument, this +/// implementation can be called at anytime, independent of the dispatching of wayland events. +/// The dispatching of KeyRepeatEvents is handled with the spawning of threads. +/// +/// The keymap information will be loaded from the events sent by the compositor, +/// as such you need to call this method as soon as you have created the keyboard +/// to make sure this event does not get lost. +/// +/// Returns an error if xkbcommon could not be initialized. +pub fn map_keyboard_auto_with_repeat<Impl, RepeatImpl>( + seat: &Proxy<wl_seat::WlSeat>, + key_repeat_kind: KeyRepeatKind, + implementation: Impl, + repeat_implementation: RepeatImpl, +) -> Result<Proxy<wl_keyboard::WlKeyboard>, Error> +where + for<'a> Impl: FnMut(Event<'a>, Proxy<wl_keyboard::WlKeyboard>) + Send + 'static, + RepeatImpl: FnMut(KeyRepeatEvent, Proxy<wl_keyboard::WlKeyboard>) + Send + 'static, +{ + let state = match KbState::new() { + Ok(s) => s, + Err(e) => return Err(e), + }; + Ok(implement_kbd( + seat, + state, + implementation, + Some((key_repeat_kind, repeat_implementation)), + )) +} + +/// Implement a keyboard for a predefined keymap and send KeyRepeatEvents at set +/// intervals +/// +/// This requires you to provide an implementation to receive the events after they +/// have been interpreted with the keymap. You must also provide an implementation to be called +/// when KeyRepeatEvents are sent at intervals set by the KeyRepeatKind argument, this +/// implementation can be called at anytime, independent of the dispatching of wayland events. +/// The dispatching of KeyRepeatEvents is handled with the spawning of threads. +/// +/// The keymap will be loaded from the provided RMLVO rules. Any keymap provided +/// by the compositor will be ignored. +/// +/// Returns an error if xkbcommon could not be initialized or the RMLVO specification +/// contained invalid values. +pub fn map_keyboard_rmlvo_with_repeat<Impl, RepeatImpl>( + seat: &Proxy<wl_seat::WlSeat>, + rmlvo: RMLVO, + key_repeat_kind: KeyRepeatKind, + implementation: Impl, + repeat_implementation: RepeatImpl, +) -> Result<Proxy<wl_keyboard::WlKeyboard>, Error> +where + for<'a> Impl: FnMut(Event<'a>, Proxy<wl_keyboard::WlKeyboard>) + Send + 'static, + RepeatImpl: FnMut(KeyRepeatEvent, Proxy<wl_keyboard::WlKeyboard>) + Send + 'static, +{ + fn to_cstring(s: Option<String>) -> Result<Option<CString>, Error> { + s.map_or(Ok(None), |s| CString::new(s).map(Option::Some)) + .map_err(|_| Error::BadNames) + } + + fn init_state(rmlvo: RMLVO) -> Result<KbState, Error> { + let mut state = KbState::new()?; + + let rules = to_cstring(rmlvo.rules)?; + let model = to_cstring(rmlvo.model)?; + let layout = to_cstring(rmlvo.layout)?; + let variant = to_cstring(rmlvo.variant)?; + let options = to_cstring(rmlvo.options)?; + + let xkb_names = ffi::xkb_rule_names { + rules: rules.map_or(ptr::null(), |s| s.as_ptr()), + model: model.map_or(ptr::null(), |s| s.as_ptr()), + layout: layout.map_or(ptr::null(), |s| s.as_ptr()), + variant: variant.map_or(ptr::null(), |s| s.as_ptr()), + options: options.map_or(ptr::null(), |s| s.as_ptr()), + }; + + unsafe { + state.init_with_rmlvo(xkb_names)?; + } + + state.locked = true; + Ok(state) + } + + match init_state(rmlvo) { + Ok(state) => Ok(implement_kbd( + seat, + state, + implementation, + Some((key_repeat_kind, repeat_implementation)), + )), + Err(error) => Err(error), + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/lib.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/lib.rs new file mode 100644 index 0000000..c35557f --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/lib.rs @@ -0,0 +1,40 @@ +//! Smithay Client Toolkit +//! +//! Provides various utilities and abstractions for comunicating with various +//! Wayland compositors. +#![warn(missing_docs)] + +#[macro_use] +extern crate bitflags; +#[macro_use] +extern crate dlib; +#[macro_use] +extern crate lazy_static; +extern crate andrew; +extern crate memmap; +extern crate nix; +#[doc(hidden)] +pub extern crate wayland_client; +#[doc(hidden)] +pub extern crate wayland_commons; +#[doc(hidden)] +pub extern crate wayland_protocols; + +/// Re-exports of some crates, for convenience +pub mod reexports { + pub use wayland_client as client; + pub use wayland_protocols as protocols; +} + +pub mod data_device; +pub mod keyboard; +pub mod output; +pub mod pointer; +pub mod shell; +pub mod surface; +pub mod utils; +pub mod window; + +mod env; + +pub use env::{Environment, Shell}; diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/output.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/output.rs new file mode 100644 index 0000000..66f31ae --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/output.rs @@ -0,0 +1,267 @@ +//! Types related to `wl_output` handling + +use std::sync::{Arc, Mutex}; + +use wayland_client::protocol::wl_output::{self, Event, RequestsTrait, WlOutput}; +use wayland_client::protocol::wl_registry::{self, RequestsTrait as RegistryRequest}; +use wayland_client::Proxy; + +pub use wayland_client::protocol::wl_output::{Subpixel, Transform}; + +/// A possible mode for an output +#[derive(Copy, Clone, Debug)] +pub struct Mode { + /// Number of pixels of this mode in format `(width, height)` + /// + /// for example `(1920, 1080)` + pub dimensions: (i32, i32), + /// Refresh rate for this mode, in mHz + pub refresh_rate: i32, + /// Whether this is the current mode for this output + pub is_current: bool, + /// Whether this is the preferred mode for this output + pub is_preferred: bool, +} + +#[derive(Clone, Debug)] +/// Compiled information about an output +pub struct OutputInfo { + /// The model name of this output as advertised by the server + pub model: String, + /// The make name of this output as advertised by the server + pub make: String, + /// Location of the top-left corner of this output in compositor + /// space + /// + /// Note that the compositor may decide to always report (0,0) if + /// it decides clients are not allowed to know this information. + pub location: (i32, i32), + /// Physical dimensions of this output, in unspecified units + pub physical_size: (i32, i32), + /// The subpixel layout for this output + pub subpixel: Subpixel, + /// The current transformation applied to this output + /// + /// You can pre-render your buffers taking this information + /// into account and advertising it via `wl_buffer.set_tranform` + /// for better performances. + pub transform: Transform, + /// The scaling factor of this output + /// + /// Any buffer whose scaling factor does not match the one + /// of the output it is displayed on will be rescaled accordingly. + /// + /// For example, a buffer of scaling factor 1 will be doubled in + /// size if the output scaling factor is 2. + pub scale_factor: i32, + /// Possible modes for an output + pub modes: Vec<Mode>, +} + +impl OutputInfo { + fn new() -> OutputInfo { + OutputInfo { + model: String::new(), + make: String::new(), + location: (0, 0), + physical_size: (0, 0), + subpixel: Subpixel::Unknown, + transform: Transform::Normal, + scale_factor: 1, + modes: Vec::new(), + } + } +} + +struct Inner { + outputs: Vec<(u32, Proxy<WlOutput>, OutputInfo)>, + pending: Vec<(Proxy<WlOutput>, Event)>, +} + +impl Inner { + fn merge(&mut self, output: &Proxy<WlOutput>) { + let info = match self + .outputs + .iter_mut() + .find(|&&mut (_, ref o, _)| o.equals(output)) + { + Some(&mut (_, _, ref mut info)) => info, + // trying to merge a non-existing output ? + // well, might be some very bad luck of an + // output being concurrently destroyed at the bad time ? + None => { + // clean stale state + self.pending.retain(|&(ref o, _)| o.is_alive()); + return; + } + }; + // slow, but could be improved with Vec::drain_filter + // see https://github.com/rust-lang/rust/issues/43244 + // this vec should be pretty small at all times anyway + while let Some(idx) = self.pending.iter().position(|&(ref o, _)| o.equals(output)) { + let (_, event) = self.pending.swap_remove(idx); + match event { + Event::Geometry { + x, + y, + physical_width, + physical_height, + subpixel, + model, + make, + transform, + } => { + info.location = (x, y); + info.physical_size = (physical_width, physical_height); + info.subpixel = subpixel; + info.transform = transform; + info.model = model; + info.make = make; + } + Event::Scale { factor } => { + info.scale_factor = factor; + } + Event::Done => { + // should not happen + unreachable!(); + } + Event::Mode { + width, + height, + refresh, + flags, + } => { + let mut found = false; + if let Some(mode) = info + .modes + .iter_mut() + .find(|m| m.dimensions == (width, height) && m.refresh_rate == refresh) + { + // this mode already exists, update it + mode.is_preferred = flags.contains(wl_output::Mode::Preferred); + mode.is_current = flags.contains(wl_output::Mode::Current); + found = true; + } + if !found { + // otherwise, add it + info.modes.push(Mode { + dimensions: (width, height), + refresh_rate: refresh, + is_preferred: flags.contains(wl_output::Mode::Preferred), + is_current: flags.contains(wl_output::Mode::Current), + }) + } + } + } + } + } +} + +#[derive(Clone)] +/// An utility tracking the available outputs and their capabilities +pub struct OutputMgr { + inner: Arc<Mutex<Inner>>, +} + +impl OutputMgr { + pub(crate) fn new() -> OutputMgr { + OutputMgr { + inner: Arc::new(Mutex::new(Inner { + outputs: Vec::new(), + pending: Vec::new(), + })), + } + } + + pub(crate) fn new_output( + &self, + id: u32, + version: u32, + registry: &Proxy<wl_registry::WlRegistry>, + ) { + let inner = self.inner.clone(); + let output = registry + .bind(version, id, |output| { + output.implement( + move |event, output| { + let mut inner = inner.lock().unwrap(); + if let Event::Done = event { + inner.merge(&output); + } else { + inner.pending.push((output.clone(), event)); + if output.version() < 2 { + // in case of very old outputs, we can't treat the changes + // atomically as the Done event does not exist + inner.merge(&output); + } + } + }, + (), + ) + }) + .unwrap(); + + self.inner + .lock() + .unwrap() + .outputs + .push((id, output, OutputInfo::new())); + } + + pub(crate) fn output_removed(&self, id: u32) { + let mut inner = self.inner.lock().unwrap(); + if let Some(idx) = inner.outputs.iter().position(|&(i, _, _)| i == id) { + let (_, output, _) = inner.outputs.swap_remove(idx); + // cleanup all remaining pending if any + inner.pending.retain(|&(ref o, _)| !o.equals(&output)); + if output.version() >= 3 { + output.release(); + } + } + } + + /// Access the information of a specific output from its global id + /// + /// If the requested output is not found (likely because it has been destroyed) + /// the closure is not called and `None` is returned. + pub fn find_id<F, T>(&self, id: u32, f: F) -> Option<T> + where + F: FnOnce(&Proxy<wl_output::WlOutput>, &OutputInfo) -> T, + { + let inner = self.inner.lock().unwrap(); + if let Some(&(_, ref proxy, ref info)) = inner.outputs.iter().find(|&&(i, _, _)| i == id) { + Some(f(proxy, info)) + } else { + None + } + } + + /// Access the information of a specific output + /// + /// If the requested output is not found (likely because it has been destroyed) + /// the closure is not called and `None` is returned. + pub fn with_info<F, T>(&self, output: &Proxy<WlOutput>, f: F) -> Option<T> + where + F: FnOnce(u32, &OutputInfo) -> T, + { + let inner = self.inner.lock().unwrap(); + if let Some(&(id, _, ref info)) = inner + .outputs + .iter() + .find(|&&(_, ref o, _)| o.equals(output)) + { + Some(f(id, info)) + } else { + None + } + } + + /// Access all output information + pub fn with_all<F, T>(&self, f: F) -> T + where + F: FnOnce(&[(u32, Proxy<WlOutput>, OutputInfo)]) -> T, + { + let inner = self.inner.lock().unwrap(); + f(&inner.outputs) + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/pointer/mod.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/pointer/mod.rs new file mode 100644 index 0000000..6e75f47 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/pointer/mod.rs @@ -0,0 +1,177 @@ +//! Utilities to work with pointers and their icons + +use std::ops::Deref; + +use wayland_client::protocol::{wl_compositor, wl_pointer, wl_seat, wl_shm}; +use wayland_client::{NewProxy, Proxy, QueueToken}; + +use wayland_client::protocol::wl_seat::RequestsTrait as SeatRequests; + +mod theme; + +pub use self::theme::{ThemeManager, ThemedPointer}; + +/// Wrapper to gracefully handle a missing `libwayland-cursor` +/// +/// This wrapper has the same API as `ThemeManager`, but will +/// gracefully handle the case of a missing `libwayland-cursor` +/// by doing nothing. +/// +/// It is a convenience wrapper to handle systems where +/// `libwayland-client.so` is available but not `libwayland-cursor.so`. +pub enum AutoThemer { + /// The theme could be loaded + Themed(ThemeManager), + /// `libwayland-cursor.so` is not available + UnThemed, +} + +impl AutoThemer { + /// Load a system pointer theme + /// + /// Will use the default theme of the system if name is `None`. + /// + /// Falls back to `UnThemed` if `libwayland-cursor` is not available. + pub fn init( + name: Option<&str>, + compositor: Proxy<wl_compositor::WlCompositor>, + shm: &Proxy<wl_shm::WlShm>, + ) -> AutoThemer { + match ThemeManager::init(name, compositor, &shm) { + Ok(mgr) => AutoThemer::Themed(mgr), + Err(()) => AutoThemer::UnThemed, + } + } + + /// Wrap a pointer to theme it + pub fn theme_pointer(&self, pointer: Proxy<wl_pointer::WlPointer>) -> AutoPointer { + match *self { + AutoThemer::Themed(ref mgr) => AutoPointer::Themed(mgr.theme_pointer(pointer)), + AutoThemer::UnThemed => AutoPointer::UnThemed(pointer), + } + } + + /// Initialize a new pointer as a ThemedPointer with an adapter implementation + /// + /// You need to provide an implementation as if implementing a `wl_pointer`, but + /// it will receive as `meta` argument an `AutoPointer` wrapping your pointer, + /// rather than a `Proxy<WlPointer>`. + pub fn theme_pointer_with_impl<Impl, UD>( + &self, + seat: &Proxy<wl_seat::WlSeat>, + mut implementation: Impl, + user_data: UD, + ) -> AutoPointer + where + Impl: FnMut(wl_pointer::Event, AutoPointer) + Send + 'static, + UD: Send + Sync + 'static, + { + match *self { + AutoThemer::Themed(ref mgr) => { + let pointer = mgr.theme_pointer_with_impl( + seat, + move |event, seat| implementation(event, AutoPointer::Themed(seat)), + user_data, + ); + AutoPointer::Themed(pointer) + } + AutoThemer::UnThemed => { + let pointer = seat + .get_pointer(|pointer| { + pointer.implement( + move |event, seat| implementation(event, AutoPointer::UnThemed(seat)), + user_data, + ) + }) + .unwrap(); + AutoPointer::UnThemed(pointer) + } + } + } + + /// Initialize a new pointer as a ThemedPointer with an adapter implementation + /// + /// Like `theme_pointer_with_impl` but allows you to have a non-`Send` implementation. + /// + /// **Unsafe** for the same reasons as `NewProxy::implement_nonsend`. + pub unsafe fn theme_pointer_with_nonsend_impl<Impl, UD>( + &self, + pointer: NewProxy<wl_pointer::WlPointer>, + mut implementation: Impl, + user_data: UD, + token: &QueueToken, + ) -> AutoPointer + where + Impl: FnMut(wl_pointer::Event, AutoPointer) + Send + 'static, + UD: Send + Sync + 'static, + { + match *self { + AutoThemer::Themed(ref mgr) => { + let pointer = mgr.theme_pointer_with_nonsend_impl( + pointer, + move |event, pointer| implementation(event, AutoPointer::Themed(pointer)), + user_data, + token, + ); + AutoPointer::Themed(pointer) + } + AutoThemer::UnThemed => { + let pointer = pointer.implement_nonsend( + move |event, pointer| implementation(event, AutoPointer::UnThemed(pointer)), + user_data, + token, + ); + AutoPointer::UnThemed(pointer) + } + } + } +} + +/// A pointer wrapper to gracefully handle a missing `libwayland-cursor` +/// +/// It has the same API as `ThemedPointer`, but falls back to doing nothing +/// in its `Unthemed` variant. +pub enum AutoPointer { + /// The `ThemedPointer` + Themed(ThemedPointer), + /// The regular pointer if theme capability is not available + UnThemed(Proxy<wl_pointer::WlPointer>), +} + +impl AutoPointer { + /// Change the cursor to the given cursor name + /// + /// Possible names depend on the theme. Does nothing and returns + /// `Err(())` if given name is not available. + /// + /// Does nothing an returns `Ok(())` if no theme is loaded (if + /// `wayland-cursor` is not available). + /// + /// If this is done as an answer to an input event, you need to provide + /// the associated serial otherwise the server may ignore the request. + pub fn set_cursor(&self, name: &str, serial: Option<u32>) -> Result<(), ()> { + match *self { + AutoPointer::Themed(ref themed) => themed.set_cursor(name, serial), + AutoPointer::UnThemed(_) => Ok(()), + } + } +} + +impl Deref for AutoPointer { + type Target = Proxy<wl_pointer::WlPointer>; + fn deref(&self) -> &Proxy<wl_pointer::WlPointer> { + match *self { + AutoPointer::Themed(ref themed) => &**themed, + AutoPointer::UnThemed(ref ptr) => ptr, + } + } +} + +impl Clone for AutoPointer { + fn clone(&self) -> AutoPointer { + match *self { + AutoPointer::Themed(ref themed) => AutoPointer::Themed(themed.clone()), + AutoPointer::UnThemed(ref ptr) => AutoPointer::UnThemed(ptr.clone()), + } + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/pointer/theme.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/pointer/theme.rs new file mode 100644 index 0000000..bf5156c --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/pointer/theme.rs @@ -0,0 +1,243 @@ +use std::ops::Deref; +use std::sync::{Arc, Mutex}; +use wayland_client::cursor::{is_available, load_theme, CursorTheme}; +use wayland_client::protocol::{wl_compositor, wl_pointer, wl_seat, wl_shm, wl_surface}; +use wayland_client::{NewProxy, Proxy, QueueToken}; + +use wayland_client::protocol::wl_compositor::RequestsTrait as CompositorRequests; +use wayland_client::protocol::wl_pointer::RequestsTrait as PointerRequests; +use wayland_client::protocol::wl_seat::RequestsTrait as SeatRequests; +use wayland_client::protocol::wl_surface::RequestsTrait as SurfaceRequests; + +/// Wrapper managing a system theme for pointer images +/// +/// You can use it to initialize new pointers in order +/// to theme them. +/// +/// Is is also clone-able in case you need to handle several +/// pointer theming from different places. +/// +/// Note that it is however not `Send` nor `Sync` +pub struct ThemeManager { + theme: Arc<Mutex<CursorTheme>>, + compositor: Proxy<wl_compositor::WlCompositor>, +} + +impl ThemeManager { + /// Load a system pointer theme + /// + /// Will use the default theme of the system if name is `None`. + /// + /// Fails if `libwayland-cursor` is not available. + pub fn init( + name: Option<&str>, + compositor: Proxy<wl_compositor::WlCompositor>, + shm: &Proxy<wl_shm::WlShm>, + ) -> Result<ThemeManager, ()> { + if !is_available() { + return Err(()); + } + + Ok(ThemeManager { + compositor, + theme: Arc::new(Mutex::new(load_theme(name, 16, &shm))), + }) + } + + /// Wrap a pointer to theme it + pub fn theme_pointer(&self, pointer: Proxy<wl_pointer::WlPointer>) -> ThemedPointer { + let surface = self + .compositor + .create_surface(|surface| surface.implement(|_, _| {}, ())) + .unwrap(); + ThemedPointer { + pointer, + inner: Arc::new(Mutex::new(PointerInner { + surface, + theme: self.theme.clone(), + last_serial: 0, + })), + } + } + + /// Initialize a new pointer as a ThemedPointer with an adapter implementation + /// + /// You need to provide an implementation as if implementing a `wl_pointer`, but + /// it will receive as `meta` argument a `ThemedPointer` wrapping your pointer, + /// rather than a `Proxy<WlPointer>`. + pub fn theme_pointer_with_impl<Impl, UD>( + &self, + seat: &Proxy<wl_seat::WlSeat>, + mut implementation: Impl, + user_data: UD, + ) -> ThemedPointer + where + Impl: FnMut(wl_pointer::Event, ThemedPointer) + Send + 'static, + UD: Send + Sync + 'static, + { + let surface = self + .compositor + .create_surface(|surface| surface.implement(|_, _| {}, ())) + .unwrap(); + + let inner = Arc::new(Mutex::new(PointerInner { + surface, + theme: self.theme.clone(), + last_serial: 0, + })); + let inner2 = inner.clone(); + + let pointer = seat + .get_pointer(|pointer| { + pointer.implement( + move |event, ptr| { + implementation( + event, + ThemedPointer { + pointer: ptr, + inner: inner.clone(), + }, + ) + }, + user_data, + ) + }) + .unwrap(); + + ThemedPointer { + pointer, + inner: inner2, + } + } + + /// Initialize a new pointer as a ThemedPointer with an adapter implementation + /// + /// Like `theme_pointer_with_impl` but allows you to have a non-`Send` implementation. + /// + /// **Unsafe** for the same reasons as `NewProxy::implement_nonsend`. + pub unsafe fn theme_pointer_with_nonsend_impl<Impl, UD>( + &self, + pointer: NewProxy<wl_pointer::WlPointer>, + mut implementation: Impl, + user_data: UD, + token: &QueueToken, + ) -> ThemedPointer + where + Impl: FnMut(wl_pointer::Event, ThemedPointer) + 'static, + UD: Send + Sync + 'static, + { + let surface = self + .compositor + .create_surface(|surface| surface.implement(|_, _| {}, ())) + .unwrap(); + + let inner = Arc::new(Mutex::new(PointerInner { + surface, + theme: self.theme.clone(), + last_serial: 0, + })); + let inner2 = inner.clone(); + + let pointer = pointer.implement_nonsend( + move |event, ptr| { + implementation( + event, + ThemedPointer { + pointer: ptr, + inner: inner.clone(), + }, + ) + }, + user_data, + token, + ); + + ThemedPointer { + pointer, + inner: inner2, + } + } +} + +struct PointerInner { + surface: Proxy<wl_surface::WlSurface>, + theme: Arc<Mutex<CursorTheme>>, + last_serial: u32, +} + +/// Wrapper of a themed pointer +/// +/// You can access the underlying `Proxy<wl_pointer::WlPointer>` via +/// deref. It will *not* release the proxy when dropped. +/// +/// Just like `Proxy`, this is a `Rc`-like wrapper. You can clone it +/// to have several handles to the same theming machinery of a pointer. +pub struct ThemedPointer { + pointer: Proxy<wl_pointer::WlPointer>, + inner: Arc<Mutex<PointerInner>>, +} + +impl ThemedPointer { + /// Change the cursor to the given cursor name + /// + /// Possible names depend on the theme. Does nothing and returns + /// `Err(())` if given name is not available. + /// + /// If this is done as an answer to an input event, you need to provide + /// the associated serial otherwise the server may ignore the request. + pub fn set_cursor(&self, name: &str, serial: Option<u32>) -> Result<(), ()> { + let mut inner = self.inner.lock().unwrap(); + let PointerInner { + ref theme, + ref surface, + ref mut last_serial, + } = *inner; + + let theme = theme.lock().unwrap(); + let cursor = theme.get_cursor(name).ok_or(())?; + let buffer = cursor.frame_buffer(0).ok_or(())?; + let (w, h, hx, hy) = cursor + .frame_info(0) + .map(|(w, h, hx, hy, _)| (w as i32, h as i32, hx as i32, hy as i32)) + .unwrap_or((0, 0, 0, 0)); + + if let Some(s) = serial { + *last_serial = s; + } + + surface.attach(Some(&buffer), 0, 0); + if surface.version() >= 4 { + surface.damage_buffer(0, 0, w, h); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + surface.damage(0, 0, w, h); + } + surface.commit(); + self.pointer.set_cursor(*last_serial, Some(surface), hx, hy); + + Ok(()) + } +} + +impl Clone for ThemedPointer { + fn clone(&self) -> ThemedPointer { + ThemedPointer { + pointer: self.pointer.clone(), + inner: self.inner.clone(), + } + } +} + +impl Deref for ThemedPointer { + type Target = Proxy<wl_pointer::WlPointer>; + fn deref(&self) -> &Proxy<wl_pointer::WlPointer> { + &self.pointer + } +} + +impl Drop for PointerInner { + fn drop(&mut self) { + self.surface.destroy(); + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/mod.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/mod.rs new file mode 100644 index 0000000..ff9165d --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/mod.rs @@ -0,0 +1,102 @@ +//! Unified shell surface handling +//! +//! This module provides an abstraction unifying the various iterations of +//! the shell surface protocols (`wl_shell`, `zxdg_shell_v6` and `xdg_shell`, +//! the current standard). +//! +//! This abstraction only manages the protocol part of shell surfaces. If you're +//! looking for a more battery-included abstraction for creating windows, +//! consider the `Window` type. +use wayland_client::protocol::{wl_output, wl_seat, wl_surface}; +use wayland_client::Proxy; + +use wayland_protocols::xdg_shell::client::xdg_toplevel; +pub use wayland_protocols::xdg_shell::client::xdg_toplevel::State; + +use Shell; + +mod wl; +mod xdg; +mod zxdg; + +/// Possible events generated by a shell surface that you need to handle +#[derive(Clone, Debug)] +pub enum Event { + /// The state of your window has been changed + Configure { + /// Optional new size for your shell surface + /// + /// This is the new size of the contents of your shell surface + /// as suggested by the server. You can ignore it and choose + /// a new size if you want better control on the possible + /// sizes of your shell surface. + /// + /// In all cases, these events can be generated in large batches + /// during an interactive resize, and you should buffer them before + /// processing them. You only need to handle the last one of a batch. + new_size: Option<(u32, u32)>, + /// New combination of states of your window + /// + /// Typically tells you if your surface is active/inactive, maximized, + /// etc... + states: Vec<State>, + }, + /// A close request has been received + /// + /// Most likely the user has clicked on the close button of the decorations + /// or something equivalent + Close, +} + +pub(crate) fn create_shell_surface<Impl>( + shell: &Shell, + surface: &Proxy<wl_surface::WlSurface>, + implem: Impl, +) -> Box<ShellSurface> +where + Impl: FnMut(Event) + Send + 'static, +{ + match *shell { + Shell::Wl(ref shell) => Box::new(wl::Wl::create(surface, shell, implem)) as Box<_>, + Shell::Xdg(ref shell) => Box::new(xdg::Xdg::create(surface, shell, implem)) as Box<_>, + Shell::Zxdg(ref shell) => Box::new(zxdg::Zxdg::create(surface, shell, implem)) as Box<_>, + } +} + +/// Trait abstracting over shell surface protocols +/// +/// This trait's API is designed to reflect the behavior of the current standard +/// shell surface protocol: `xdg_shell`. Compatibility implementations are +/// provided for older protocols. +pub trait ShellSurface: Send + Sync { + /// Resizes the shell surface + fn resize(&self, seat: &Proxy<wl_seat::WlSeat>, serial: u32, edges: xdg_toplevel::ResizeEdge); + /// Moves the shell surface + fn move_(&self, seat: &Proxy<wl_seat::WlSeat>, serial: u32); + /// Set the title of the shell surface + fn set_title(&self, title: String); + /// Set the app id of the shell surface + fn set_app_id(&self, app_id: String); + /// Make fullscreen + fn set_fullscreen(&self, output: Option<&Proxy<wl_output::WlOutput>>); + /// Unset fullscreen + fn unset_fullscreen(&self); + /// Maximize surface + fn set_maximized(&self); + /// Unmaximize surface + fn unset_maximized(&self); + /// Minimize surface + fn set_minimized(&self); + /// Set geometry + fn set_geometry(&self, x: i32, y: i32, width: i32, height: i32); + /// Set minimum surface size + fn set_min_size(&self, size: Option<(i32, i32)>); + /// Set maximum surface size + fn set_max_size(&self, size: Option<(i32, i32)>); + /// Retrive the `XdgToplevel` proxy if the underlying shell surface + /// uses the `xdg_shell` protocol. + /// + /// This allows interactions with other protocol extensions, like + /// `xdg_decoratins` for example. + fn get_xdg(&self) -> Option<&Proxy<xdg_toplevel::XdgToplevel>>; +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/wl.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/wl.rs new file mode 100644 index 0000000..f3bfda6 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/wl.rs @@ -0,0 +1,114 @@ +use wayland_client::protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface}; +use wayland_client::Proxy; + +use wayland_client::protocol::wl_shell::RequestsTrait as ShellRequests; +use wayland_client::protocol::wl_shell_surface::RequestsTrait as ShellSurfaceRequests; + +use wayland_protocols::xdg_shell::client::xdg_toplevel; + +use super::{Event, ShellSurface}; + +pub(crate) struct Wl { + shell_surface: Proxy<wl_shell_surface::WlShellSurface>, +} + +impl Wl { + pub(crate) fn create<Impl>( + surface: &Proxy<wl_surface::WlSurface>, + shell: &Proxy<wl_shell::WlShell>, + mut implementation: Impl, + ) -> Wl + where + Impl: FnMut(Event) + Send + 'static, + { + let shell_surface = shell + .get_shell_surface(surface, |shell_surface| { + shell_surface.implement( + move |event, shell_surface: Proxy<_>| match event { + wl_shell_surface::Event::Ping { serial } => { + shell_surface.pong(serial); + } + wl_shell_surface::Event::Configure { width, height, .. } => { + use std::cmp::max; + implementation(Event::Configure { + new_size: Some((max(width, 1) as u32, max(height, 1) as u32)), + states: Vec::new(), + }); + } + wl_shell_surface::Event::PopupDone => { + unreachable!(); + } + }, + (), + ) + }) + .unwrap(); + shell_surface.set_toplevel(); + Wl { shell_surface } + } +} + +impl ShellSurface for Wl { + fn resize(&self, seat: &Proxy<wl_seat::WlSeat>, serial: u32, edges: xdg_toplevel::ResizeEdge) { + let edges = match edges { + xdg_toplevel::ResizeEdge::None => wl_shell_surface::Resize::None, + xdg_toplevel::ResizeEdge::Top => wl_shell_surface::Resize::Top, + xdg_toplevel::ResizeEdge::Left => wl_shell_surface::Resize::Left, + xdg_toplevel::ResizeEdge::Right => wl_shell_surface::Resize::Right, + xdg_toplevel::ResizeEdge::Bottom => wl_shell_surface::Resize::Bottom, + xdg_toplevel::ResizeEdge::TopLeft => wl_shell_surface::Resize::TopLeft, + xdg_toplevel::ResizeEdge::TopRight => wl_shell_surface::Resize::TopRight, + xdg_toplevel::ResizeEdge::BottomLeft => wl_shell_surface::Resize::BottomLeft, + xdg_toplevel::ResizeEdge::BottomRight => wl_shell_surface::Resize::BottomRight, + }; + self.shell_surface.resize(seat, serial, edges); + } + + fn move_(&self, seat: &Proxy<wl_seat::WlSeat>, serial: u32) { + self.shell_surface._move(seat, serial); + } + + fn set_title(&self, title: String) { + self.shell_surface.set_title(title); + } + + fn set_app_id(&self, app_id: String) { + self.shell_surface.set_class(app_id); + } + fn set_fullscreen(&self, output: Option<&Proxy<wl_output::WlOutput>>) { + self.shell_surface + .set_fullscreen(wl_shell_surface::FullscreenMethod::Default, 0, output) + } + + fn unset_fullscreen(&self) { + self.shell_surface.set_toplevel(); + } + + fn set_maximized(&self) { + self.shell_surface.set_maximized(None); + } + + fn unset_maximized(&self) { + self.shell_surface.set_toplevel(); + } + + fn set_minimized(&self) { + /* not available */ + } + + fn set_geometry(&self, _: i32, _: i32, _: i32, _: i32) { + /* not available */ + } + + fn set_min_size(&self, _: Option<(i32, i32)>) { + /* not available */ + } + + fn set_max_size(&self, _: Option<(i32, i32)>) { + /* not available */ + } + + fn get_xdg(&self) -> Option<&Proxy<xdg_toplevel::XdgToplevel>> { + None + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/xdg.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/xdg.rs new file mode 100644 index 0000000..71981fc --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/xdg.rs @@ -0,0 +1,151 @@ +use wayland_client::protocol::{wl_output, wl_seat, wl_surface}; +use wayland_client::Proxy; + +use wayland_protocols::xdg_shell::client::{xdg_surface, xdg_toplevel, xdg_wm_base}; + +use wayland_client::protocol::wl_surface::RequestsTrait as WlSurfaceRequests; +use wayland_protocols::xdg_shell::client::xdg_surface::RequestsTrait as SurfaceRequests; +use wayland_protocols::xdg_shell::client::xdg_toplevel::RequestsTrait as ToplevelRequests; +use wayland_protocols::xdg_shell::client::xdg_wm_base::RequestsTrait as ShellRequests; + +use super::{Event, ShellSurface}; + +pub(crate) struct Xdg { + surface: Proxy<xdg_surface::XdgSurface>, + toplevel: Proxy<xdg_toplevel::XdgToplevel>, +} + +impl Xdg { + pub(crate) fn create<Impl>( + surface: &Proxy<wl_surface::WlSurface>, + shell: &Proxy<xdg_wm_base::XdgWmBase>, + mut implementation: Impl, + ) -> Xdg + where + Impl: FnMut(Event) + Send + 'static, + { + let xdgs = shell + .get_xdg_surface(surface, |xdgs| { + xdgs.implement( + |evt, xdgs: Proxy<_>| match evt { + xdg_surface::Event::Configure { serial } => { + xdgs.ack_configure(serial); + } + }, + (), + ) + }) + .unwrap(); + let toplevel = xdgs + .get_toplevel(|toplevel| { + toplevel.implement( + move |evt, _| { + match evt { + xdg_toplevel::Event::Close => implementation(Event::Close), + xdg_toplevel::Event::Configure { + width, + height, + states, + } => { + use std::cmp::max; + let new_size = if width == 0 || height == 0 { + // if either w or h is zero, then we get to choose our size + None + } else { + Some((max(width, 1) as u32, max(height, 1) as u32)) + }; + let view: &[u32] = unsafe { + ::std::slice::from_raw_parts( + states.as_ptr() as *const _, + states.len() / 4, + ) + }; + let states = view + .iter() + .cloned() + .flat_map(xdg_toplevel::State::from_raw) + .collect::<Vec<_>>(); + implementation(Event::Configure { new_size, states }); + } + } + }, + (), + ) + }) + .unwrap(); + surface.commit(); + Xdg { + surface: xdgs, + toplevel, + } + } +} + +impl ShellSurface for Xdg { + fn resize(&self, seat: &Proxy<wl_seat::WlSeat>, serial: u32, edges: xdg_toplevel::ResizeEdge) { + self.toplevel.resize(seat, serial, edges as u32); + } + + fn move_(&self, seat: &Proxy<wl_seat::WlSeat>, serial: u32) { + self.toplevel._move(seat, serial); + } + + fn set_title(&self, title: String) { + self.toplevel.set_title(title); + } + + fn set_app_id(&self, app_id: String) { + self.toplevel.set_app_id(app_id); + } + + fn set_fullscreen(&self, output: Option<&Proxy<wl_output::WlOutput>>) { + self.toplevel.set_fullscreen(output) + } + + fn unset_fullscreen(&self) { + self.toplevel.unset_fullscreen(); + } + + fn set_maximized(&self) { + self.toplevel.set_maximized(); + } + + fn unset_maximized(&self) { + self.toplevel.unset_maximized(); + } + + fn set_minimized(&self) { + self.toplevel.set_minimized(); + } + + fn set_geometry(&self, x: i32, y: i32, width: i32, height: i32) { + self.surface.set_window_geometry(x, y, width, height); + } + + fn set_min_size(&self, size: Option<(i32, i32)>) { + if let Some((w, h)) = size { + self.toplevel.set_min_size(w, h); + } else { + self.toplevel.set_min_size(0, 0); + } + } + + fn set_max_size(&self, size: Option<(i32, i32)>) { + if let Some((w, h)) = size { + self.toplevel.set_max_size(w, h); + } else { + self.toplevel.set_max_size(0, 0); + } + } + + fn get_xdg(&self) -> Option<&Proxy<xdg_toplevel::XdgToplevel>> { + Some(&self.toplevel) + } +} + +impl Drop for Xdg { + fn drop(&mut self) { + self.toplevel.destroy(); + self.surface.destroy(); + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/zxdg.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/zxdg.rs new file mode 100644 index 0000000..8576e66 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/shell/zxdg.rs @@ -0,0 +1,156 @@ +use wayland_client::protocol::{wl_output, wl_seat, wl_surface}; +use wayland_client::Proxy; + +use wayland_protocols::unstable::xdg_shell::v6::client::{ + zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6, +}; +use wayland_protocols::xdg_shell::client::xdg_toplevel; + +use self::zxdg_shell_v6_proto::zxdg_shell_v6::RequestsTrait as ShellRequests; +use self::zxdg_shell_v6_proto::zxdg_surface_v6::RequestsTrait as SurfaceRequests; +use self::zxdg_shell_v6_proto::zxdg_toplevel_v6::RequestsTrait as ToplevelRequests; +use wayland_client::protocol::wl_surface::RequestsTrait as WlSurfaceRequests; +use wayland_protocols::unstable::xdg_shell::v6::client as zxdg_shell_v6_proto; + +use super::{Event, ShellSurface}; + +pub(crate) struct Zxdg { + surface: Proxy<zxdg_surface_v6::ZxdgSurfaceV6>, + toplevel: Proxy<zxdg_toplevel_v6::ZxdgToplevelV6>, +} + +impl Zxdg { + pub(crate) fn create<Impl>( + surface: &Proxy<wl_surface::WlSurface>, + shell: &Proxy<zxdg_shell_v6::ZxdgShellV6>, + mut implementation: Impl, + ) -> Zxdg + where + Impl: FnMut(Event) + Send + 'static, + { + let xdgs = shell + .get_xdg_surface(surface, |xdgs| { + xdgs.implement( + |evt, xdgs: Proxy<_>| match evt { + zxdg_surface_v6::Event::Configure { serial } => { + xdgs.ack_configure(serial); + } + }, + (), + ) + }) + .unwrap(); + let toplevel = xdgs + .get_toplevel(|toplevel| { + toplevel.implement( + move |evt, _| { + match evt { + zxdg_toplevel_v6::Event::Close => implementation(Event::Close), + zxdg_toplevel_v6::Event::Configure { + width, + height, + states, + } => { + use std::cmp::max; + let new_size = if width == 0 || height == 0 { + // if either w or h is zero, then we get to choose our size + None + } else { + Some((max(width, 1) as u32, max(height, 1) as u32)) + }; + let view: &[u32] = unsafe { + ::std::slice::from_raw_parts( + states.as_ptr() as *const _, + states.len() / 4, + ) + }; + let states = view + .iter() + .cloned() + // bit representation of xdg_toplevel_v6 and zxdg_toplevel_v6 matches + .flat_map(xdg_toplevel::State::from_raw) + .collect::<Vec<_>>(); + implementation(Event::Configure { new_size, states }); + } + } + }, + (), + ) + }) + .unwrap(); + surface.commit(); + Zxdg { + surface: xdgs, + toplevel, + } + } +} + +impl ShellSurface for Zxdg { + fn resize(&self, seat: &Proxy<wl_seat::WlSeat>, serial: u32, edges: xdg_toplevel::ResizeEdge) { + self.toplevel.resize(seat, serial, edges as u32); + } + + fn move_(&self, seat: &Proxy<wl_seat::WlSeat>, serial: u32) { + self.toplevel._move(seat, serial); + } + + fn set_title(&self, title: String) { + self.toplevel.set_title(title); + } + + fn set_app_id(&self, app_id: String) { + self.toplevel.set_app_id(app_id); + } + + fn set_fullscreen(&self, output: Option<&Proxy<wl_output::WlOutput>>) { + self.toplevel.set_fullscreen(output) + } + + fn unset_fullscreen(&self) { + self.toplevel.unset_fullscreen(); + } + + fn set_maximized(&self) { + self.toplevel.set_maximized(); + } + + fn unset_maximized(&self) { + self.toplevel.unset_maximized(); + } + + fn set_minimized(&self) { + self.toplevel.set_minimized(); + } + + fn set_geometry(&self, x: i32, y: i32, width: i32, height: i32) { + self.surface.set_window_geometry(x, y, width, height); + } + + fn set_min_size(&self, size: Option<(i32, i32)>) { + if let Some((w, h)) = size { + self.toplevel.set_min_size(w, h); + } else { + self.toplevel.set_min_size(0, 0); + } + } + + fn set_max_size(&self, size: Option<(i32, i32)>) { + if let Some((w, h)) = size { + self.toplevel.set_max_size(w, h); + } else { + self.toplevel.set_max_size(0, 0); + } + } + + fn get_xdg(&self) -> Option<&Proxy<xdg_toplevel::XdgToplevel>> { + None + } +} + +impl Drop for Zxdg { + fn drop(&mut self) { + self.toplevel.destroy(); + self.surface.destroy(); + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/surface.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/surface.rs new file mode 100644 index 0000000..efe9a8a --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/surface.rs @@ -0,0 +1,124 @@ +//! Utility functions for creating dpi aware wayland surfaces. +use env::Environment; +use output::OutputMgr; +use std::sync::Mutex; +use wayland_client::protocol::wl_compositor::RequestsTrait as CompositorRequest; +use wayland_client::protocol::{wl_output, wl_surface}; +use wayland_client::Proxy; + +pub(crate) struct SurfaceUserData { + dpi_factor: i32, + outputs: Vec<Proxy<wl_output::WlOutput>>, + output_manager: OutputMgr, + dpi_change_cb: Box<FnMut(i32, Proxy<wl_surface::WlSurface>) + Send + 'static>, +} + +impl SurfaceUserData { + fn new( + output_manager: OutputMgr, + dpi_change_cb: Box<FnMut(i32, Proxy<wl_surface::WlSurface>) + Send + 'static>, + ) -> Self { + SurfaceUserData { + dpi_factor: 1, + outputs: Vec::new(), + output_manager, + dpi_change_cb, + } + } + + pub(crate) fn enter( + &mut self, + output: Proxy<wl_output::WlOutput>, + surface: Proxy<wl_surface::WlSurface>, + ) { + self.outputs.push(output); + self.compute_dpi_factor(surface); + } + + pub(crate) fn leave( + &mut self, + output: &Proxy<wl_output::WlOutput>, + surface: Proxy<wl_surface::WlSurface>, + ) { + self.outputs.retain(|output2| !output.equals(output2)); + self.compute_dpi_factor(surface); + } + + fn compute_dpi_factor(&mut self, surface: Proxy<wl_surface::WlSurface>) { + let mut scale_factor = 1; + for output in &self.outputs { + if let Some(scale_factor2) = self + .output_manager + .with_info(&output, |_id, info| info.scale_factor) + { + scale_factor = ::std::cmp::max(scale_factor, scale_factor2); + } + } + if self.dpi_factor != scale_factor { + self.dpi_factor = scale_factor; + (self.dpi_change_cb)(scale_factor, surface.clone()); + } + } +} + +/// Creates a WlSurface from an Environment. +/// +/// Computes the dpi factor by taking the maximum dpi value of all the outputs +/// the surface is displayed on. The dpi factor is stored in the Proxy's user +/// data. When the dpi value is updated the caller is notified through the +/// dpi_change closure. +pub(crate) fn create_surface<F>( + environment: &Environment, + dpi_change: Box<F>, +) -> Proxy<wl_surface::WlSurface> +where + F: FnMut(i32, Proxy<wl_surface::WlSurface>) + Send + 'static, +{ + environment + .compositor + .create_surface(move |surface| { + surface.implement( + move |event, surface| { + let mut user_data = surface + .user_data::<Mutex<SurfaceUserData>>() + .unwrap() + .lock() + .unwrap(); + match event { + wl_surface::Event::Enter { output } => { + user_data.enter(output, surface.clone()); + } + wl_surface::Event::Leave { output } => { + user_data.leave(&output, surface.clone()); + } + }; + }, + Mutex::new(SurfaceUserData::new( + environment.outputs.clone(), + dpi_change, + )), + ) + }) + .unwrap() +} + +/// Returns the current dpi factor of a surface. +pub fn get_dpi_factor(surface: &Proxy<wl_surface::WlSurface>) -> i32 { + surface + .user_data::<Mutex<SurfaceUserData>>() + .expect("Surface was not created with create_surface.") + .lock() + .unwrap() + .dpi_factor +} + +/// Returns a list of outputs the surface is displayed on. +pub fn get_outputs(surface: &Proxy<wl_surface::WlSurface>) -> Vec<Proxy<wl_output::WlOutput>> { + surface + .user_data::<Mutex<SurfaceUserData>>() + .expect("Surface was not created with create_surface.") + .lock() + .unwrap() + .outputs + .clone() +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/utils/mempool.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/utils/mempool.rs new file mode 100644 index 0000000..6c4d53c --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/utils/mempool.rs @@ -0,0 +1,288 @@ +use nix; +use nix::errno::Errno; +use nix::fcntl; +#[cfg(target_os = "linux")] +use nix::sys::memfd; +use nix::sys::mman; +use nix::sys::stat; +use nix::unistd; +use std::ffi::CStr; +use std::fs::File; +use std::io; +use std::os::unix::io::FromRawFd; +use std::os::unix::io::RawFd; +use std::sync::{Arc, Mutex}; +use std::time::SystemTime; +use std::time::UNIX_EPOCH; + +use memmap::MmapMut; + +use wayland_client::protocol::{wl_buffer, wl_shm, wl_shm_pool}; +use wayland_client::Proxy; + +use wayland_client::protocol::wl_buffer::RequestsTrait; +use wayland_client::protocol::wl_shm::RequestsTrait as ShmRequests; +use wayland_client::protocol::wl_shm_pool::RequestsTrait as PoolRequests; + +/// A Double memory pool, for convenient double-buffering +/// +/// This type wraps two internal memory pool, and can be +/// use for conveniently implementing double-buffering in your +/// apps. +/// +/// DoubleMemPool requires a implementation that is called when +/// one of the two internal memory pools becomes free after None +/// was returned from the `pool()` method. +pub struct DoubleMemPool { + pool1: MemPool, + pool2: MemPool, + free: Arc<Mutex<bool>>, +} + +impl DoubleMemPool { + /// Create a double memory pool + pub fn new<Impl>(shm: &Proxy<wl_shm::WlShm>, implementation: Impl) -> io::Result<DoubleMemPool> + where + Impl: FnMut() + Send + 'static, + { + let free = Arc::new(Mutex::new(true)); + let implementation = Arc::new(Mutex::new(implementation)); + let my_free = free.clone(); + let my_implementation = implementation.clone(); + let pool1 = MemPool::new(shm, move || { + let mut my_free = my_free.lock().unwrap(); + if !*my_free { + (&mut *my_implementation.lock().unwrap())(); + *my_free = true + } + })?; + let my_free = free.clone(); + let my_implementation = implementation.clone(); + let pool2 = MemPool::new(shm, move || { + let mut my_free = my_free.lock().unwrap(); + if !*my_free { + (&mut *my_implementation.lock().unwrap())(); + *my_free = true + } + })?; + Ok(DoubleMemPool { pool1, pool2, free }) + } + + /// This method checks both its internal memory pools and returns + /// one if that pool does not contain any buffers that are still in use + /// by the server. If both the memory pools contain buffers that are currently + /// in use by the server None will be returned. + pub fn pool(&mut self) -> Option<&mut MemPool> { + if !self.pool1.is_used() { + Some(&mut self.pool1) + } else if !self.pool2.is_used() { + Some(&mut self.pool2) + } else { + *self.free.lock().unwrap() = false; + None + } + } +} + +/// A wrapper handling an SHM memory pool backed by a shared memory file +/// +/// This wrapper handles for you the creation of the shared memory file and its synchronization +/// with the protocol. +/// +/// Mempool internally tracks the lifetime of all buffers created from it and to ensure that +/// this buffer count is correct all buffers must be attached to a surface. Once a buffer is attached to +/// a surface it must be immediately committed to that surface before another buffer is attached. +/// +/// Mempool will also handle the destruction of buffers and as such the `destroy()` method should not +/// be used on buffers created from Mempool. +/// +/// Overwriting the contents of the memory pool before it is completely freed may cause graphical +/// glitches due to the possible corruption of data while the compositor is reading it. +/// +/// Mempool requires an implementation that will be called when the pool becomes free, this +/// happens when all the pools buffers are released by the server. +pub struct MemPool { + file: File, + len: usize, + pool: Proxy<wl_shm_pool::WlShmPool>, + buffer_count: Arc<Mutex<u32>>, + mmap: MmapMut, + implementation: Arc<Mutex<FnMut() + Send>>, +} + +impl MemPool { + /// Create a new memory pool associated with given shm + pub fn new<Impl>(shm: &Proxy<wl_shm::WlShm>, implementation: Impl) -> io::Result<MemPool> + where + Impl: FnMut() + Send + 'static, + { + let mem_fd = create_shm_fd()?; + let mem_file = unsafe { File::from_raw_fd(mem_fd) }; + mem_file.set_len(128)?; + + let pool = shm + .create_pool(mem_fd, 128, |pool| pool.implement(|e, _| match e {}, ())) + .unwrap(); + + let mmap = unsafe { MmapMut::map_mut(&mem_file).unwrap() }; + + Ok(MemPool { + file: mem_file, + len: 128, + pool, + buffer_count: Arc::new(Mutex::new(0)), + mmap, + implementation: Arc::new(Mutex::new(implementation)), + }) + } + + /// Resize the memory pool + /// + /// This affect the size as it is seen by the wayland server. Even + /// if you extend the temporary file size by writing to it, you need to + /// call this method otherwise the server won't see the new size. + /// + /// Memory pools can only be extented, as such this method will do nothing + /// if the requested new size is smaller than the current size. + /// + /// This method allows you to ensure the underlying pool is large enough to + /// hold what you want to write to it. + pub fn resize(&mut self, newsize: usize) -> io::Result<()> { + if newsize > self.len { + self.file.set_len(newsize as u64)?; + self.pool.resize(newsize as i32); + self.len = newsize; + self.mmap = unsafe { MmapMut::map_mut(&self.file).unwrap() }; + } + Ok(()) + } + + /// Create a new buffer to this pool + /// + /// The parameters are: + /// + /// - `offset`: the offset (in bytes) from the beginning of the pool at which this + /// buffer starts + /// - `width`: the width of this buffer (in pixels) + /// - `height`: the height of this buffer (in pixels) + /// - `stride`: distance (in bytes) between the beginning of a row and the next one + /// - `format`: the encoding format of the pixels. Using a format that was not + /// advertised to the `wl_shm` global by the server is a protocol error and will + /// terminate your connection + pub fn buffer( + &self, + offset: i32, + width: i32, + height: i32, + stride: i32, + format: wl_shm::Format, + ) -> Proxy<wl_buffer::WlBuffer> { + *self.buffer_count.lock().unwrap() += 1; + let my_buffer_count = self.buffer_count.clone(); + let my_implementation = self.implementation.clone(); + self.pool + .create_buffer(offset, width, height, stride, format, |buffer| { + buffer.implement( + move |event, buffer: Proxy<wl_buffer::WlBuffer>| match event { + wl_buffer::Event::Release => { + buffer.destroy(); + let mut my_buffer_count = my_buffer_count.lock().unwrap(); + *my_buffer_count -= 1; + if *my_buffer_count == 0 { + (&mut *my_implementation.lock().unwrap())(); + } + } + }, + (), + ) + }) + .unwrap() + } + + /// Uses the memmap crate to map the underlying shared memory file + pub fn mmap(&mut self) -> &mut MmapMut { + &mut self.mmap + } + + /// Returns true if the pool contains buffers that are currently in use by the server otherwise it returns + /// false + pub fn is_used(&self) -> bool { + *self.buffer_count.lock().unwrap() != 0 + } +} + +impl Drop for MemPool { + fn drop(&mut self) { + self.pool.destroy(); + } +} + +impl io::Write for MemPool { + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + io::Write::write(&mut self.file, buf) + } + fn flush(&mut self) -> io::Result<()> { + io::Write::flush(&mut self.file) + } +} + +impl io::Seek for MemPool { + fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> { + io::Seek::seek(&mut self.file, pos) + } +} + +fn create_shm_fd() -> io::Result<RawFd> { + // Only try memfd on linux + #[cfg(target_os = "linux")] + loop { + match memfd::memfd_create( + CStr::from_bytes_with_nul(b"smithay-client-toolkit\0").unwrap(), + memfd::MemFdCreateFlag::MFD_CLOEXEC, + ) { + Ok(fd) => return Ok(fd), + Err(nix::Error::Sys(Errno::EINTR)) => continue, + Err(nix::Error::Sys(Errno::ENOSYS)) => break, + Err(nix::Error::Sys(errno)) => return Err(io::Error::from(errno)), + Err(err) => unreachable!(err), + } + } + + // Fallback to using shm_open + let sys_time = SystemTime::now(); + let mut mem_file_handle = format!( + "/smithay-client-toolkit-{}", + sys_time.duration_since(UNIX_EPOCH).unwrap().subsec_nanos() + ); + loop { + match mman::shm_open( + mem_file_handle.as_str(), + fcntl::OFlag::O_CREAT + | fcntl::OFlag::O_EXCL + | fcntl::OFlag::O_RDWR + | fcntl::OFlag::O_CLOEXEC, + stat::Mode::S_IRUSR | stat::Mode::S_IWUSR, + ) { + Ok(fd) => match mman::shm_unlink(mem_file_handle.as_str()) { + Ok(_) => return Ok(fd), + Err(nix::Error::Sys(errno)) => match unistd::close(fd) { + Ok(_) => return Err(io::Error::from(errno)), + Err(nix::Error::Sys(errno)) => return Err(io::Error::from(errno)), + Err(err) => panic!(err), + }, + Err(err) => panic!(err), + }, + Err(nix::Error::Sys(Errno::EEXIST)) => { + // If a file with that handle exists then change the handle + mem_file_handle = format!( + "/smithay-client-toolkit-{}", + sys_time.duration_since(UNIX_EPOCH).unwrap().subsec_nanos() + ); + continue; + } + Err(nix::Error::Sys(Errno::EINTR)) => continue, + Err(nix::Error::Sys(errno)) => return Err(io::Error::from(errno)), + Err(err) => unreachable!(err), + } + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/utils/mod.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/utils/mod.rs new file mode 100644 index 0000000..3d314c2 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/utils/mod.rs @@ -0,0 +1,5 @@ +//! Various small utilities helping you to write clients + +mod mempool; + +pub use self::mempool::{DoubleMemPool, MemPool}; diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/window/basic_frame.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/window/basic_frame.rs new file mode 100644 index 0000000..bb3d2ca --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/window/basic_frame.rs @@ -0,0 +1,896 @@ +use std::cmp::max; +use std::io::Read; +use std::sync::{Arc, Mutex}; + +use andrew::shapes::rectangle; +use andrew::text; +use andrew::text::fontconfig; +use andrew::{Canvas, Endian}; + +use wayland_client::protocol::{ + wl_compositor, wl_pointer, wl_seat, wl_shm, wl_subcompositor, wl_subsurface, wl_surface, +}; +use wayland_client::Proxy; + +use wayland_client::protocol::wl_compositor::RequestsTrait as CompositorRequests; +use wayland_client::protocol::wl_pointer::RequestsTrait as PointerRequests; +use wayland_client::protocol::wl_subcompositor::RequestsTrait as SubcompRequests; +use wayland_client::protocol::wl_subsurface::RequestsTrait as SubsurfaceRequests; +use wayland_client::protocol::wl_surface::RequestsTrait as SurfaceRequests; + +use super::{ButtonState, Frame, FrameRequest, Theme}; +use pointer::{AutoPointer, AutoThemer}; +use utils::DoubleMemPool; + +/* + * Drawing theme definitions + */ + +const BORDER_SIZE: u32 = 12; +const HEADER_SIZE: u32 = 32; +const BUTTON_SPACE: u32 = 10; +const ROUNDING_SIZE: u32 = 5; + +// Defining the theme +struct DefaultTheme; + +impl Theme for DefaultTheme { + // Used for header color + fn get_primary_color(&self, active: bool) -> [u8; 4] { + if active { + [0xFF, 0x80, 0x80, 0x80] + } else { + [0xFF, 0x60, 0x60, 0x60] + } + } + + fn get_secondary_color(&self, _active: bool) -> [u8; 4] { + [0x00, 0x00, 0x00, 0x00] + } + + fn get_close_button_color(&self, state: ButtonState) -> [u8; 4] { + match state { + ButtonState::Hovered => [0xFF, 0xFF, 0x40, 0x40], + ButtonState::Idle => [0xFF, 0xB0, 0x40, 0x40], + _ => [0x00, 0x00, 0x00, 0x00], + } + } + + fn get_maximize_button_color(&self, state: ButtonState) -> [u8; 4] { + match state { + ButtonState::Hovered => [0xFF, 0xFF, 0xFF, 0x40], + ButtonState::Idle => [0xFF, 0xB0, 0xB0, 0x40], + ButtonState::Disabled => [0xFF, 0x80, 0x80, 0x20], + } + } + + fn get_minimize_button_color(&self, state: ButtonState) -> [u8; 4] { + match state { + ButtonState::Hovered => [0xFF, 0x40, 0xFF, 0x40], + ButtonState::Idle => [0xFF, 0x40, 0xB0, 0x40], + _ => [0x00, 0x00, 0x00, 0x00], + } + } +} + +/* + * Utilities + */ + +const HEAD: usize = 0; +const TOP: usize = 1; +const BOTTOM: usize = 2; +const LEFT: usize = 3; +const RIGHT: usize = 4; + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +enum Location { + None, + Head, + Top, + TopRight, + Right, + BottomRight, + Bottom, + BottomLeft, + Left, + TopLeft, + Button(UIButton), +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +enum UIButton { + Minimize, + Maximize, + Close, +} + +struct Part { + surface: Proxy<wl_surface::WlSurface>, + subsurface: Proxy<wl_subsurface::WlSubsurface>, +} + +impl Part { + fn new( + parent: &Proxy<wl_surface::WlSurface>, + compositor: &Proxy<wl_compositor::WlCompositor>, + subcompositor: &Proxy<wl_subcompositor::WlSubcompositor>, + ) -> Part { + let surface = compositor + .create_surface(|surface| surface.implement(|_, _| {}, ())) + .unwrap(); + let subsurface = subcompositor + .get_subsurface(&surface, parent, |subsurface| { + subsurface.implement(|_, _| {}, ()) + }) + .unwrap(); + Part { + surface, + subsurface, + } + } +} + +impl Drop for Part { + fn drop(&mut self) { + self.subsurface.destroy(); + self.surface.destroy(); + } +} + +struct PointerUserData { + location: Location, + position: (f64, f64), + seat: Proxy<wl_seat::WlSeat>, +} + +/* + * The core frame + */ + +struct Inner { + parts: [Part; 5], + size: Mutex<(u32, u32)>, + resizable: Arc<Mutex<bool>>, + implem: Mutex<Box<FnMut(FrameRequest, u32) + Send>>, + maximized: Arc<Mutex<bool>>, +} + +impl Inner { + fn find_surface(&self, surface: &Proxy<wl_surface::WlSurface>) -> Location { + if surface.equals(&self.parts[HEAD].surface) { + Location::Head + } else if surface.equals(&self.parts[TOP].surface) { + Location::Top + } else if surface.equals(&self.parts[BOTTOM].surface) { + Location::Bottom + } else if surface.equals(&self.parts[LEFT].surface) { + Location::Left + } else if surface.equals(&self.parts[RIGHT].surface) { + Location::Right + } else { + Location::None + } + } +} + +fn precise_location(old: Location, width: u32, x: f64, y: f64) -> Location { + match old { + Location::Head | Location::Button(_) => find_button(x, y, width), + + Location::Top | Location::TopLeft | Location::TopRight => { + if x <= f64::from(BORDER_SIZE) { + Location::TopLeft + } else if x >= f64::from(width + BORDER_SIZE) { + Location::TopRight + } else { + Location::Top + } + } + + Location::Bottom | Location::BottomLeft | Location::BottomRight => { + if x <= f64::from(BORDER_SIZE) { + Location::BottomLeft + } else if x >= f64::from(width + BORDER_SIZE) { + Location::BottomRight + } else { + Location::Bottom + } + } + + other => other, + } +} + +fn find_button(x: f64, y: f64, w: u32) -> Location { + if (w >= 24 + 2 * BUTTON_SPACE) + && (x >= f64::from(w - 24 - BUTTON_SPACE)) + && (x <= f64::from(w - BUTTON_SPACE)) + && (y <= f64::from(HEADER_SIZE) / 2.0 + 8.0) + && (y >= f64::from(HEADER_SIZE) / 2.0 - 8.0) + { + Location::Button(UIButton::Close) + } else if (w >= 56 + 2 * BUTTON_SPACE) + && (x >= f64::from(w - 56 - BUTTON_SPACE)) + && (x <= f64::from(w - 32 - BUTTON_SPACE)) + && (y <= f64::from(HEADER_SIZE) / 2.0 + 8.0) + && (y >= f64::from(HEADER_SIZE) / 2.0 - 8.0) + { + Location::Button(UIButton::Maximize) + } else if (w >= 88 + 2 * BUTTON_SPACE) + && (x >= f64::from(w - 88 - BUTTON_SPACE)) + && (x <= f64::from(w - 64 - BUTTON_SPACE)) + && (y <= f64::from(HEADER_SIZE) / 2.0 + 8.0) + && (y >= f64::from(HEADER_SIZE) / 2.0 - 8.0) + { + Location::Button(UIButton::Minimize) + } else { + Location::Head + } +} + +/// A minimalistic set of decorations +/// +/// This class draws minimalistic decorations, which are arguably not very +/// beautiful, but functional. +pub struct BasicFrame { + inner: Arc<Inner>, + pools: DoubleMemPool, + active: bool, + hidden: bool, + pointers: Vec<AutoPointer>, + themer: AutoThemer, + surface_version: u32, + theme: Box<Theme>, + title: Option<String>, + font_data: Option<Vec<u8>>, +} + +impl Frame for BasicFrame { + type Error = ::std::io::Error; + fn init( + base_surface: &Proxy<wl_surface::WlSurface>, + compositor: &Proxy<wl_compositor::WlCompositor>, + subcompositor: &Proxy<wl_subcompositor::WlSubcompositor>, + shm: &Proxy<wl_shm::WlShm>, + implementation: Box<FnMut(FrameRequest, u32) + Send>, + ) -> Result<BasicFrame, ::std::io::Error> { + let parts = [ + Part::new(base_surface, compositor, subcompositor), + Part::new(base_surface, compositor, subcompositor), + Part::new(base_surface, compositor, subcompositor), + Part::new(base_surface, compositor, subcompositor), + Part::new(base_surface, compositor, subcompositor), + ]; + let inner = Arc::new(Inner { + parts, + size: Mutex::new((1, 1)), + resizable: Arc::new(Mutex::new(true)), + implem: Mutex::new(implementation), + maximized: Arc::new(Mutex::new(false)), + }); + let my_inner = inner.clone(); + // Send a Refresh request on callback from DoubleMemPool as it will be fired when + // None was previously returned from `pool()` and the draw was postponed + let pools = DoubleMemPool::new(&shm, move || { + (&mut *my_inner.implem.lock().unwrap())(FrameRequest::Refresh, 0); + })?; + Ok(BasicFrame { + inner, + pools, + active: false, + hidden: false, + pointers: Vec::new(), + themer: AutoThemer::init(None, compositor.clone(), &shm), + surface_version: compositor.version(), + theme: Box::new(DefaultTheme), + title: None, + font_data: None, + }) + } + + fn new_seat(&mut self, seat: &Proxy<wl_seat::WlSeat>) { + use self::wl_pointer::Event; + let inner = self.inner.clone(); + let pointer = self.themer.theme_pointer_with_impl( + seat, + move |event, pointer: AutoPointer| { + let data: &Mutex<PointerUserData> = pointer.user_data().unwrap(); + let data = &mut *data.lock().unwrap(); + let (width, _) = *(inner.size.lock().unwrap()); + let resizable = *(inner.resizable.lock().unwrap()); + match event { + Event::Enter { + serial, + surface, + surface_x, + surface_y, + } => { + data.location = precise_location( + inner.find_surface(&surface), + width, + surface_x, + surface_y, + ); + data.position = (surface_x, surface_y); + if resizable { + change_pointer(&pointer, data.location, Some(serial)); + } + } + Event::Leave { serial, .. } => { + data.location = Location::None; + if resizable { + change_pointer(&pointer, data.location, Some(serial)); + } + } + Event::Motion { + surface_x, + surface_y, + .. + } => { + data.position = (surface_x, surface_y); + let newpos = precise_location(data.location, width, surface_x, surface_y); + if newpos != data.location { + match (newpos, data.location) { + (Location::Button(_), _) | (_, Location::Button(_)) => { + // pointer movement involves a button, request refresh + (&mut *inner.implem.lock().unwrap())(FrameRequest::Refresh, 0); + } + _ => (), + } + // we changed of part of the decoration, pointer image + // may need to be changed + data.location = newpos; + if resizable { + change_pointer(&pointer, data.location, None); + } + } + } + Event::Button { + serial, + button, + state, + .. + } => { + if state == wl_pointer::ButtonState::Pressed && button == 0x110 { + // left click + let req = request_for_location( + data.location, + &data.seat, + *(inner.maximized.lock().unwrap()), + resizable, + ); + if let Some(req) = req { + (&mut *inner.implem.lock().unwrap())(req, serial); + } + } + } + _ => {} + } + }, + Mutex::new(PointerUserData { + location: Location::None, + position: (0.0, 0.0), + seat: seat.clone(), + }), + ); + self.pointers.push(pointer); + } + + fn set_active(&mut self, active: bool) -> bool { + if self.active != active { + self.active = active; + true + } else { + false + } + } + + fn set_hidden(&mut self, hidden: bool) { + self.hidden = hidden; + } + + fn set_maximized(&mut self, maximized: bool) -> bool { + let mut my_maximized = self.inner.maximized.lock().unwrap(); + if *my_maximized != maximized { + *my_maximized = maximized; + true + } else { + false + } + } + + fn set_resizable(&mut self, resizable: bool) { + *(self.inner.resizable.lock().unwrap()) = resizable; + } + + fn resize(&mut self, newsize: (u32, u32)) { + *(self.inner.size.lock().unwrap()) = newsize; + } + + fn redraw(&mut self) { + if self.hidden { + // don't draw the borders + for p in &self.inner.parts { + p.surface.attach(None, 0, 0); + p.surface.commit(); + } + return; + } + let (width, height) = *(self.inner.size.lock().unwrap()); + + { + // grab the current pool + let pool = match self.pools.pool() { + Some(pool) => pool, + None => return, + }; + // resize the pool as appropriate + let pxcount = (HEADER_SIZE * width) + + max( + (width + 2 * BORDER_SIZE) * BORDER_SIZE, + (height + HEADER_SIZE) * BORDER_SIZE, + ); + + pool.resize(4 * pxcount as usize) + .expect("I/O Error while redrawing the borders"); + + // draw the grey header bar + { + let mmap = pool.mmap(); + { + let color = self.theme.get_primary_color(self.active); + + let mut header_canvas = Canvas::new( + &mut mmap[0..HEADER_SIZE as usize * width as usize * 4], + width as usize, + HEADER_SIZE as usize, + width as usize * 4, + Endian::native(), + ); + header_canvas.clear(); + + let header_bar = rectangle::Rectangle::new( + (0, 0), + (width as usize - 1, HEADER_SIZE as usize - 1), + Some(( + HEADER_SIZE as usize, + color, + rectangle::Sides::TOP, + Some(ROUNDING_SIZE as usize), + )), + None, + ); + header_canvas.draw(&header_bar); + + draw_buttons( + &mut header_canvas, + width, + true, + &self + .pointers + .iter() + .flat_map(|p| { + if p.is_alive() { + let data: &Mutex<PointerUserData> = p.user_data().unwrap(); + Some(data.lock().unwrap().location) + } else { + None + } + }) + .collect::<Vec<Location>>(), + &*self.theme, + ); + + if let Some(title) = self.title.clone() { + // If theres no stored font data, find the first ttf regular sans font and + // store it + if self.font_data.is_none() { + if let Some(font) = fontconfig::FontConfig::new() + .unwrap() + .get_regular_family_fonts("sans") + .unwrap() + .iter() + .filter_map(|p| { + if p.extension().unwrap() == "ttf" { + Some(p) + } else { + None + } + }) + .nth(0) + { + let mut font_data = Vec::new(); + if let Ok(mut file) = ::std::fs::File::open(font) { + match file.read_to_end(&mut font_data) { + Ok(_) => self.font_data = Some(font_data), + Err(err) => eprintln!("Could not read font file: {}", err), + } + } + } + } + + // Create text from stored title and font data + if let Some(ref font_data) = self.font_data { + let mut title_text = text::Text::new( + (0, HEADER_SIZE as usize / 2 - 8), + [0, 0, 0, 255], + font_data, + 17.0, + 1.0, + title, + ); + + // Check if text is bigger then the avaliable width + if (width as isize - 88 - 4 * BUTTON_SPACE as isize) + > (title_text.get_width() + BUTTON_SPACE as usize) as isize + { + title_text.pos.0 = + (width as usize) / 2 - (title_text.get_width() / 2); + // Adjust position for buttons if both compete for space + if (width as usize) / 2 + (title_text.get_width() / 2) + > (width - 88 - 2 * 2 * BUTTON_SPACE) as usize + { + title_text.pos.0 -= ((width as usize) / 2 + + (title_text.get_width() / 2)) + - (width - 88 - 2 * 2 * BUTTON_SPACE) as usize; + } + header_canvas.draw(&title_text); + } + } + } + } + + // For each pixel in borders + { + for b in &mut mmap[HEADER_SIZE as usize * width as usize * 4..] { + *b = 0x00; + } + } + if let Err(err) = mmap.flush() { + eprintln!( + "[SCTK] Basic frame: failed to flush frame memory map: {}", + err + ); + } + } + + // Create the buffers + // -> head-subsurface + let buffer = pool.buffer( + 0, + width as i32, + HEADER_SIZE as i32, + 4 * width as i32, + wl_shm::Format::Argb8888, + ); + self.inner.parts[HEAD] + .subsurface + .set_position(0, -(HEADER_SIZE as i32)); + self.inner.parts[HEAD].surface.attach(Some(&buffer), 0, 0); + if self.surface_version >= 4 { + self.inner.parts[HEAD].surface.damage_buffer( + 0, + 0, + width as i32, + HEADER_SIZE as i32, + ); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + self.inner.parts[HEAD] + .surface + .damage(0, 0, width as i32, HEADER_SIZE as i32); + } + self.inner.parts[HEAD].surface.commit(); + + // -> top-subsurface + let buffer = pool.buffer( + 4 * (width * HEADER_SIZE) as i32, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + 4 * (width + 2 * BORDER_SIZE) as i32, + wl_shm::Format::Argb8888, + ); + self.inner.parts[TOP].subsurface.set_position( + -(BORDER_SIZE as i32), + -(HEADER_SIZE as i32 + BORDER_SIZE as i32), + ); + self.inner.parts[TOP].surface.attach(Some(&buffer), 0, 0); + if self.surface_version >= 4 { + self.inner.parts[TOP].surface.damage_buffer( + 0, + 0, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + ); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + self.inner.parts[TOP].surface.damage( + 0, + 0, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + ); + } + self.inner.parts[TOP].surface.commit(); + + // -> bottom-subsurface + let buffer = pool.buffer( + 4 * (width * HEADER_SIZE) as i32, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + 4 * (width + 2 * BORDER_SIZE) as i32, + wl_shm::Format::Argb8888, + ); + self.inner.parts[BOTTOM] + .subsurface + .set_position(-(BORDER_SIZE as i32), height as i32); + self.inner.parts[BOTTOM].surface.attach(Some(&buffer), 0, 0); + if self.surface_version >= 4 { + self.inner.parts[BOTTOM].surface.damage_buffer( + 0, + 0, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + ); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + self.inner.parts[BOTTOM].surface.damage( + 0, + 0, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + ); + } + self.inner.parts[BOTTOM].surface.commit(); + + // -> left-subsurface + let buffer = pool.buffer( + 4 * (width * HEADER_SIZE) as i32, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + 4 * (BORDER_SIZE as i32), + wl_shm::Format::Argb8888, + ); + self.inner.parts[LEFT] + .subsurface + .set_position(-(BORDER_SIZE as i32), -(HEADER_SIZE as i32)); + self.inner.parts[LEFT].surface.attach(Some(&buffer), 0, 0); + if self.surface_version >= 4 { + self.inner.parts[LEFT].surface.damage_buffer( + 0, + 0, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + ); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + self.inner.parts[LEFT].surface.damage( + 0, + 0, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + ); + } + self.inner.parts[LEFT].surface.commit(); + + // -> right-subsurface + let buffer = pool.buffer( + 4 * (width * HEADER_SIZE) as i32, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + 4 * (BORDER_SIZE as i32), + wl_shm::Format::Argb8888, + ); + self.inner.parts[RIGHT] + .subsurface + .set_position(width as i32, -(HEADER_SIZE as i32)); + self.inner.parts[RIGHT].surface.attach(Some(&buffer), 0, 0); + if self.surface_version >= 4 { + self.inner.parts[RIGHT].surface.damage_buffer( + 0, + 0, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + ); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + self.inner.parts[RIGHT].surface.damage( + 0, + 0, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + ); + } + self.inner.parts[RIGHT].surface.commit(); + } + } + + fn subtract_borders(&self, width: i32, height: i32) -> (i32, i32) { + if self.hidden { + (width, height) + } else { + (width, height - HEADER_SIZE as i32) + } + } + + fn add_borders(&self, width: i32, height: i32) -> (i32, i32) { + if self.hidden { + (width, height) + } else { + (width, height + HEADER_SIZE as i32) + } + } + + fn location(&self) -> (i32, i32) { + if self.hidden { + (0, 0) + } else { + (0, -(HEADER_SIZE as i32)) + } + } + + fn set_theme<T: Theme>(&mut self, theme: T) { + self.theme = Box::new(theme) + } + + fn set_title(&mut self, title: String) { + self.title = Some(title); + } +} + +impl Drop for BasicFrame { + fn drop(&mut self) { + for ptr in self.pointers.drain(..) { + if ptr.version() >= 3 { + ptr.release(); + } + } + } +} + +fn change_pointer(pointer: &AutoPointer, location: Location, serial: Option<u32>) { + let name = match location { + Location::Top => "top_side", + Location::TopRight => "top_right_corner", + Location::Right => "right_side", + Location::BottomRight => "bottom_right_corner", + Location::Bottom => "bottom_side", + Location::BottomLeft => "bottom_left_corner", + Location::Left => "left_side", + Location::TopLeft => "top_left_corner", + _ => "left_ptr", + }; + if pointer.set_cursor(name, serial).is_err() { + eprintln!("[SCTK] Basic frame: failed to set cursor"); + } +} + +fn request_for_location( + location: Location, + seat: &Proxy<wl_seat::WlSeat>, + maximized: bool, + resizable: bool, +) -> Option<FrameRequest> { + use wayland_protocols::xdg_shell::client::xdg_toplevel::ResizeEdge; + match location { + Location::Top if resizable => Some(FrameRequest::Resize(seat.clone(), ResizeEdge::Top)), + Location::TopLeft if resizable => { + Some(FrameRequest::Resize(seat.clone(), ResizeEdge::TopLeft)) + } + Location::Left if resizable => Some(FrameRequest::Resize(seat.clone(), ResizeEdge::Left)), + Location::BottomLeft if resizable => { + Some(FrameRequest::Resize(seat.clone(), ResizeEdge::BottomLeft)) + } + Location::Bottom if resizable => { + Some(FrameRequest::Resize(seat.clone(), ResizeEdge::Bottom)) + } + Location::BottomRight if resizable => { + Some(FrameRequest::Resize(seat.clone(), ResizeEdge::BottomRight)) + } + Location::Right if resizable => Some(FrameRequest::Resize(seat.clone(), ResizeEdge::Right)), + Location::TopRight if resizable => { + Some(FrameRequest::Resize(seat.clone(), ResizeEdge::TopRight)) + } + Location::Head => Some(FrameRequest::Move(seat.clone())), + Location::Button(UIButton::Close) => Some(FrameRequest::Close), + Location::Button(UIButton::Maximize) => { + if maximized { + Some(FrameRequest::UnMaximize) + } else { + Some(FrameRequest::Maximize) + } + } + Location::Button(UIButton::Minimize) => Some(FrameRequest::Minimize), + _ => None, + } +} + +fn draw_buttons( + canvas: &mut Canvas, + width: u32, + maximizable: bool, + mouses: &[Location], + theme: &Theme, +) { + // draw up to 3 buttons, depending on the width of the window + // color of the button depends on whether a pointer is on it, and the maximizable + // button can be disabled + // buttons are 24x16 + if width >= 24 + 2 * BUTTON_SPACE { + // draw the red button + let button_state = if mouses + .iter() + .any(|&l| l == Location::Button(UIButton::Close)) + { + ButtonState::Hovered + } else { + ButtonState::Idle + }; + let color = theme.get_close_button_color(button_state); + let red_button = rectangle::Rectangle::new( + ( + (width - 24 - BUTTON_SPACE) as usize, + (HEADER_SIZE / 2 - 8) as usize, + ), + (24, 16), + None, + Some(color), + ); + canvas.draw(&red_button); + } + + if width >= 56 + 2 * BUTTON_SPACE { + // draw the yellow button + let button_state = if !maximizable { + ButtonState::Disabled + } else if mouses + .iter() + .any(|&l| l == Location::Button(UIButton::Maximize)) + { + ButtonState::Hovered + } else { + ButtonState::Idle + }; + let color = theme.get_maximize_button_color(button_state); + + let yellow_button = rectangle::Rectangle::new( + ( + (width - 56 - BUTTON_SPACE) as usize, + (HEADER_SIZE / 2 - 8) as usize, + ), + (24, 16), + None, + Some(color), + ); + canvas.draw(&yellow_button); + } + + if width >= 88 + 2 * BUTTON_SPACE { + // draw the green button + let button_state = if mouses + .iter() + .any(|&l| l == Location::Button(UIButton::Minimize)) + { + ButtonState::Hovered + } else { + ButtonState::Idle + }; + let color = theme.get_minimize_button_color(button_state); + let green_button = rectangle::Rectangle::new( + ( + (width - 88 - BUTTON_SPACE) as usize, + (HEADER_SIZE / 2 - 8) as usize, + ), + (24, 16), + None, + Some(color), + ); + canvas.draw(&green_button); + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/window/concept_frame.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/window/concept_frame.rs new file mode 100644 index 0000000..43857ba --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/window/concept_frame.rs @@ -0,0 +1,1040 @@ +use std::cmp::max; +use std::io::Read; +use std::sync::{Arc, Mutex}; + +use andrew::line; +use andrew::shapes::rectangle; +use andrew::text; +use andrew::text::fontconfig; +use andrew::{Canvas, Endian}; + +use wayland_client::protocol::{ + wl_compositor, wl_pointer, wl_seat, wl_shm, wl_subcompositor, wl_subsurface, wl_surface, +}; +use wayland_client::Proxy; + +use wayland_client::protocol::wl_compositor::RequestsTrait as CompositorRequests; +use wayland_client::protocol::wl_pointer::RequestsTrait as PointerRequests; +use wayland_client::protocol::wl_subcompositor::RequestsTrait as SubcompRequests; +use wayland_client::protocol::wl_subsurface::RequestsTrait as SubsurfaceRequests; +use wayland_client::protocol::wl_surface::RequestsTrait as SurfaceRequests; + +use super::{ButtonState, Frame, FrameRequest, Theme}; +use pointer::{AutoPointer, AutoThemer}; +use utils::DoubleMemPool; + +/* + * Drawing theme definitions + */ + +const BORDER_SIZE: u32 = 12; +const HEADER_SIZE: u32 = 30; +const BUTTON_SPACE: u32 = 10; + +// Defining the theme +struct DefaultTheme; + +impl Theme for DefaultTheme { + // Used for header color + fn get_primary_color(&self, active: bool) -> [u8; 4] { + if active { + [0xFF, 0xE6, 0xE6, 0xE6] + } else { + [0xFF, 0xDC, 0xDC, 0xDC] + } + } + + // Used for division line + fn get_secondary_color(&self, active: bool) -> [u8; 4] { + if active { + [0xFF, 0x1E, 0x1E, 0x1E] + } else { + [0xFF, 0x78, 0x78, 0x78] + } + } + + fn get_close_button_color(&self, state: ButtonState) -> [u8; 4] { + match state { + ButtonState::Hovered => [0xFF, 0xD9, 0x43, 0x52], + _ => [0x00, 0x00, 0x00, 0x00], + } + } + + fn get_maximize_button_color(&self, state: ButtonState) -> [u8; 4] { + match state { + ButtonState::Hovered => [0xFF, 0x2D, 0xCB, 0x70], + _ => [0x00, 0x00, 0x00, 0x00], + } + } + + fn get_minimize_button_color(&self, state: ButtonState) -> [u8; 4] { + match state { + ButtonState::Hovered => [0xFF, 0x3C, 0xAD, 0xE8], + _ => [0x00, 0x00, 0x00, 0x00], + } + } +} + +/* + * Utilities + */ + +const HEAD: usize = 0; +const TOP: usize = 1; +const BOTTOM: usize = 2; +const LEFT: usize = 3; +const RIGHT: usize = 4; + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +enum Location { + None, + Head, + Top, + TopRight, + Right, + BottomRight, + Bottom, + BottomLeft, + Left, + TopLeft, + Button(UIButton), +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +enum UIButton { + Minimize, + Maximize, + Close, +} + +struct Part { + surface: Proxy<wl_surface::WlSurface>, + subsurface: Proxy<wl_subsurface::WlSubsurface>, +} + +impl Part { + fn new( + parent: &Proxy<wl_surface::WlSurface>, + compositor: &Proxy<wl_compositor::WlCompositor>, + subcompositor: &Proxy<wl_subcompositor::WlSubcompositor>, + ) -> Part { + let surface = compositor + .create_surface(|surface| surface.implement(|_, _| {}, ())) + .unwrap(); + let subsurface = subcompositor + .get_subsurface(&surface, parent, |subsurface| { + subsurface.implement(|_, _| {}, ()) + }) + .unwrap(); + Part { + surface, + subsurface, + } + } +} + +impl Drop for Part { + fn drop(&mut self) { + self.subsurface.destroy(); + self.surface.destroy(); + } +} + +struct PointerUserData { + location: Location, + position: (f64, f64), + seat: Proxy<wl_seat::WlSeat>, +} + +/* + * The core frame + */ + +struct Inner { + parts: [Part; 5], + size: Mutex<(u32, u32)>, + resizable: Arc<Mutex<bool>>, + implem: Mutex<Box<FnMut(FrameRequest, u32) + Send>>, + maximized: Arc<Mutex<bool>>, +} + +impl Inner { + fn find_surface(&self, surface: &Proxy<wl_surface::WlSurface>) -> Location { + if surface.equals(&self.parts[HEAD].surface) { + Location::Head + } else if surface.equals(&self.parts[TOP].surface) { + Location::Top + } else if surface.equals(&self.parts[BOTTOM].surface) { + Location::Bottom + } else if surface.equals(&self.parts[LEFT].surface) { + Location::Left + } else if surface.equals(&self.parts[RIGHT].surface) { + Location::Right + } else { + Location::None + } + } +} + +fn precise_location(old: Location, width: u32, x: f64, y: f64) -> Location { + match old { + Location::Head | Location::Button(_) => find_button(x, y, width), + + Location::Top | Location::TopLeft | Location::TopRight => { + if x <= f64::from(BORDER_SIZE) { + Location::TopLeft + } else if x >= f64::from(width + BORDER_SIZE) { + Location::TopRight + } else { + Location::Top + } + } + + Location::Bottom | Location::BottomLeft | Location::BottomRight => { + if x <= f64::from(BORDER_SIZE) { + Location::BottomLeft + } else if x >= f64::from(width + BORDER_SIZE) { + Location::BottomRight + } else { + Location::Bottom + } + } + + other => other, + } +} + +fn find_button(x: f64, y: f64, w: u32) -> Location { + if (w >= 24 + 2 * BUTTON_SPACE) + && (x >= f64::from(w - HEADER_SIZE)) + && (x <= f64::from(w)) + && (y <= f64::from(HEADER_SIZE)) + && (y >= f64::from(0)) + { + Location::Button(UIButton::Close) + } else if (w >= 56 + 2 * BUTTON_SPACE) + && (x >= f64::from(w - 2 * HEADER_SIZE)) + && (x <= f64::from(w - HEADER_SIZE)) + && (y <= f64::from(HEADER_SIZE)) + && (y >= f64::from(0)) + { + Location::Button(UIButton::Maximize) + } else if (w >= 88 + 2 * BUTTON_SPACE) + && (x >= f64::from(w - 3 * HEADER_SIZE)) + && (x <= f64::from(w - 2 * HEADER_SIZE)) + && (y <= f64::from(HEADER_SIZE)) + && (y >= f64::from(0)) + { + Location::Button(UIButton::Minimize) + } else { + Location::Head + } +} + +/// A clean, modern and stylish set of decorations +/// +/// This class draws clean and modern decorations with +/// buttons inspired by breeze, material hover shade and +/// a white header background +pub struct ConceptFrame { + inner: Arc<Inner>, + pools: DoubleMemPool, + active: bool, + hidden: bool, + pointers: Vec<AutoPointer>, + themer: AutoThemer, + surface_version: u32, + theme: Box<Theme>, + title: Option<String>, + font_data: Option<Vec<u8>>, +} + +impl Frame for ConceptFrame { + type Error = ::std::io::Error; + fn init( + base_surface: &Proxy<wl_surface::WlSurface>, + compositor: &Proxy<wl_compositor::WlCompositor>, + subcompositor: &Proxy<wl_subcompositor::WlSubcompositor>, + shm: &Proxy<wl_shm::WlShm>, + implementation: Box<FnMut(FrameRequest, u32) + Send>, + ) -> Result<ConceptFrame, ::std::io::Error> { + let parts = [ + Part::new(base_surface, compositor, subcompositor), + Part::new(base_surface, compositor, subcompositor), + Part::new(base_surface, compositor, subcompositor), + Part::new(base_surface, compositor, subcompositor), + Part::new(base_surface, compositor, subcompositor), + ]; + let inner = Arc::new(Inner { + parts, + size: Mutex::new((1, 1)), + resizable: Arc::new(Mutex::new(true)), + implem: Mutex::new(implementation), + maximized: Arc::new(Mutex::new(false)), + }); + let my_inner = inner.clone(); + // Send a Refresh request on callback from DoubleMemPool as it will be fired when + // None was previously returned from `pool()` and the draw was postponed + let pools = DoubleMemPool::new(&shm, move || { + (&mut *my_inner.implem.lock().unwrap())(FrameRequest::Refresh, 0); + })?; + Ok(ConceptFrame { + inner, + pools, + active: false, + hidden: false, + pointers: Vec::new(), + themer: AutoThemer::init(None, compositor.clone(), &shm), + surface_version: compositor.version(), + theme: Box::new(DefaultTheme), + title: None, + font_data: None, + }) + } + + fn new_seat(&mut self, seat: &Proxy<wl_seat::WlSeat>) { + use self::wl_pointer::Event; + let inner = self.inner.clone(); + let pointer = self.themer.theme_pointer_with_impl( + seat, + move |event, pointer: AutoPointer| { + let data: &Mutex<PointerUserData> = pointer.user_data().unwrap(); + let data = &mut *data.lock().unwrap(); + let (width, _) = *(inner.size.lock().unwrap()); + let resizable = *(inner.resizable.lock().unwrap()); + match event { + Event::Enter { + serial, + surface, + surface_x, + surface_y, + } => { + data.location = precise_location( + inner.find_surface(&surface), + width, + surface_x, + surface_y, + ); + data.position = (surface_x, surface_y); + if resizable { + change_pointer(&pointer, data.location, Some(serial)) + } + } + Event::Leave { serial, .. } => { + data.location = Location::None; + change_pointer(&pointer, data.location, Some(serial)); + (&mut *inner.implem.lock().unwrap())(FrameRequest::Refresh, 0); + } + Event::Motion { + surface_x, + surface_y, + .. + } => { + data.position = (surface_x, surface_y); + let newpos = precise_location(data.location, width, surface_x, surface_y); + if newpos != data.location { + match (newpos, data.location) { + (Location::Button(_), _) | (_, Location::Button(_)) => { + // pointer movement involves a button, request refresh + (&mut *inner.implem.lock().unwrap())(FrameRequest::Refresh, 0); + } + _ => (), + } + // we changed of part of the decoration, pointer image + // may need to be changed + data.location = newpos; + if resizable { + change_pointer(&pointer, data.location, None) + } + } + } + Event::Button { + serial, + button, + state, + .. + } => { + if state == wl_pointer::ButtonState::Pressed && button == 0x110 { + // left click + let req = request_for_location( + data.location, + &data.seat, + *(inner.maximized.lock().unwrap()), + resizable, + ); + if let Some(req) = req { + (&mut *inner.implem.lock().unwrap())(req, serial); + } + } + } + _ => {} + } + }, + Mutex::new(PointerUserData { + location: Location::None, + position: (0.0, 0.0), + seat: seat.clone(), + }), + ); + self.pointers.push(pointer); + } + + fn set_active(&mut self, active: bool) -> bool { + if self.active != active { + self.active = active; + true + } else { + false + } + } + + fn set_hidden(&mut self, hidden: bool) { + self.hidden = hidden; + } + + fn set_maximized(&mut self, maximized: bool) -> bool { + let mut my_maximized = self.inner.maximized.lock().unwrap(); + if *my_maximized != maximized { + *my_maximized = maximized; + true + } else { + false + } + } + + fn set_resizable(&mut self, resizable: bool) { + *(self.inner.resizable.lock().unwrap()) = resizable; + } + + fn resize(&mut self, newsize: (u32, u32)) { + *(self.inner.size.lock().unwrap()) = newsize; + } + + fn redraw(&mut self) { + if self.hidden { + // don't draw the borders + for p in &self.inner.parts { + p.surface.attach(None, 0, 0); + p.surface.commit(); + } + return; + } + let (width, height) = *(self.inner.size.lock().unwrap()); + + { + // grab the current pool + let pool = match self.pools.pool() { + Some(pool) => pool, + None => return, + }; + // resize the pool as appropriate + let pxcount = (HEADER_SIZE * width) + + max( + (width + 2 * BORDER_SIZE) * BORDER_SIZE, + (height + HEADER_SIZE) * BORDER_SIZE, + ); + + pool.resize(4 * pxcount as usize) + .expect("I/O Error while redrawing the borders"); + + // draw the white header bar + { + let mmap = pool.mmap(); + { + let color = self.theme.get_primary_color(self.active); + + let mut header_canvas = Canvas::new( + &mut mmap[0..HEADER_SIZE as usize * width as usize * 4], + width as usize, + HEADER_SIZE as usize, + width as usize * 4, + Endian::native(), + ); + header_canvas.clear(); + + let header_bar = rectangle::Rectangle::new( + (0, 0), + (width as usize - 1, HEADER_SIZE as usize - 1), + None, + Some(color), + ); + header_canvas.draw(&header_bar); + + draw_buttons( + &mut header_canvas, + width, + true, + &self + .pointers + .iter() + .flat_map(|p| { + if p.is_alive() { + let data: &Mutex<PointerUserData> = p.user_data().unwrap(); + Some(data.lock().unwrap().location) + } else { + None + } + }) + .collect::<Vec<Location>>(), + &*self.theme, + ); + + if let Some(title) = self.title.clone() { + // If theres no stored font data, find the first ttf regular sans font and + // store it + if self.font_data.is_none() { + if let Some(font) = fontconfig::FontConfig::new() + .unwrap() + .get_regular_family_fonts("sans") + .unwrap() + .iter() + .filter_map(|p| { + if p.extension().unwrap() == "ttf" { + Some(p) + } else { + None + } + }) + .nth(0) + { + let mut font_data = Vec::new(); + if let Ok(mut file) = ::std::fs::File::open(font) { + match file.read_to_end(&mut font_data) { + Ok(_) => self.font_data = Some(font_data), + Err(err) => eprintln!("Could not read font file: {}", err), + } + } + } + } + + // Create text from stored title and font data + if let Some(ref font_data) = self.font_data { + let mut title_text = text::Text::new( + (0, HEADER_SIZE as usize / 2 - 8), + [0, 0, 0, 255], + font_data, + 17.0, + 1.0, + title, + ); + + // Check if text is bigger then the avaliable width + if (width as isize - 88 - 4 * BUTTON_SPACE as isize) + > (title_text.get_width() + BUTTON_SPACE as usize) as isize + { + title_text.pos.0 = + (width as usize) / 2 - (title_text.get_width() / 2); + // Adjust position for buttons if both compete for space + if (width as usize) / 2 + (title_text.get_width() / 2) + > (width - 88 - 2 * 2 * BUTTON_SPACE) as usize + { + title_text.pos.0 -= ((width as usize) / 2 + + (title_text.get_width() / 2)) + - (width - 88 - 2 * 2 * BUTTON_SPACE) as usize; + } + header_canvas.draw(&title_text); + } + } + } + } + + // For each pixel in borders + { + for b in &mut mmap[HEADER_SIZE as usize * width as usize * 4..] { + *b = 0x00; + } + } + if let Err(err) = mmap.flush() { + eprintln!( + "[SCTK] Basic frame: failed to flush frame memory map: {}", + err + ); + } + } + + // Create the buffers + // -> head-subsurface + let buffer = pool.buffer( + 0, + width as i32, + HEADER_SIZE as i32, + 4 * width as i32, + wl_shm::Format::Argb8888, + ); + self.inner.parts[HEAD] + .subsurface + .set_position(0, -(HEADER_SIZE as i32)); + self.inner.parts[HEAD].surface.attach(Some(&buffer), 0, 0); + if self.surface_version >= 4 { + self.inner.parts[HEAD].surface.damage_buffer( + 0, + 0, + width as i32, + HEADER_SIZE as i32, + ); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + self.inner.parts[HEAD] + .surface + .damage(0, 0, width as i32, HEADER_SIZE as i32); + } + self.inner.parts[HEAD].surface.commit(); + + // -> top-subsurface + let buffer = pool.buffer( + 4 * (width * HEADER_SIZE) as i32, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + 4 * (width + 2 * BORDER_SIZE) as i32, + wl_shm::Format::Argb8888, + ); + self.inner.parts[TOP].subsurface.set_position( + -(BORDER_SIZE as i32), + -(HEADER_SIZE as i32 + BORDER_SIZE as i32), + ); + self.inner.parts[TOP].surface.attach(Some(&buffer), 0, 0); + if self.surface_version >= 4 { + self.inner.parts[TOP].surface.damage_buffer( + 0, + 0, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + ); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + self.inner.parts[TOP].surface.damage( + 0, + 0, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + ); + } + self.inner.parts[TOP].surface.commit(); + + // -> bottom-subsurface + let buffer = pool.buffer( + 4 * (width * HEADER_SIZE) as i32, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + 4 * (width + 2 * BORDER_SIZE) as i32, + wl_shm::Format::Argb8888, + ); + self.inner.parts[BOTTOM] + .subsurface + .set_position(-(BORDER_SIZE as i32), height as i32); + self.inner.parts[BOTTOM].surface.attach(Some(&buffer), 0, 0); + if self.surface_version >= 4 { + self.inner.parts[BOTTOM].surface.damage_buffer( + 0, + 0, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + ); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + self.inner.parts[BOTTOM].surface.damage( + 0, + 0, + (width + 2 * BORDER_SIZE) as i32, + BORDER_SIZE as i32, + ); + } + self.inner.parts[BOTTOM].surface.commit(); + + // -> left-subsurface + let buffer = pool.buffer( + 4 * (width * HEADER_SIZE) as i32, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + 4 * (BORDER_SIZE as i32), + wl_shm::Format::Argb8888, + ); + self.inner.parts[LEFT] + .subsurface + .set_position(-(BORDER_SIZE as i32), -(HEADER_SIZE as i32)); + self.inner.parts[LEFT].surface.attach(Some(&buffer), 0, 0); + if self.surface_version >= 4 { + self.inner.parts[LEFT].surface.damage_buffer( + 0, + 0, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + ); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + self.inner.parts[LEFT].surface.damage( + 0, + 0, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + ); + } + self.inner.parts[LEFT].surface.commit(); + + // -> right-subsurface + let buffer = pool.buffer( + 4 * (width * HEADER_SIZE) as i32, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + 4 * (BORDER_SIZE as i32), + wl_shm::Format::Argb8888, + ); + self.inner.parts[RIGHT] + .subsurface + .set_position(width as i32, -(HEADER_SIZE as i32)); + self.inner.parts[RIGHT].surface.attach(Some(&buffer), 0, 0); + if self.surface_version >= 4 { + self.inner.parts[RIGHT].surface.damage_buffer( + 0, + 0, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + ); + } else { + // surface is old and does not support damage_buffer, so we damage + // in surface coordinates and hope it is not rescaled + self.inner.parts[RIGHT].surface.damage( + 0, + 0, + BORDER_SIZE as i32, + (height + HEADER_SIZE) as i32, + ); + } + self.inner.parts[RIGHT].surface.commit(); + } + } + + fn subtract_borders(&self, width: i32, height: i32) -> (i32, i32) { + if self.hidden { + (width, height) + } else { + (width, height - HEADER_SIZE as i32) + } + } + + fn add_borders(&self, width: i32, height: i32) -> (i32, i32) { + if self.hidden { + (width, height) + } else { + (width, height + HEADER_SIZE as i32) + } + } + + fn location(&self) -> (i32, i32) { + if self.hidden { + (0, 0) + } else { + (0, -(HEADER_SIZE as i32)) + } + } + + fn set_theme<T: Theme>(&mut self, theme: T) { + self.theme = Box::new(theme) + } + + fn set_title(&mut self, title: String) { + self.title = Some(title); + } +} + +impl Drop for ConceptFrame { + fn drop(&mut self) { + for ptr in self.pointers.drain(..) { + if ptr.version() >= 3 { + ptr.release(); + } + } + } +} + +fn change_pointer(pointer: &AutoPointer, location: Location, serial: Option<u32>) { + let name = match location { + Location::Top => "top_side", + Location::TopRight => "top_right_corner", + Location::Right => "right_side", + Location::BottomRight => "bottom_right_corner", + Location::Bottom => "bottom_side", + Location::BottomLeft => "bottom_left_corner", + Location::Left => "left_side", + Location::TopLeft => "top_left_corner", + _ => "left_ptr", + }; + if pointer.set_cursor(name, serial).is_err() { + eprintln!("[SCTK] Basic frame: failed to set cursor"); + } +} + +fn request_for_location( + location: Location, + seat: &Proxy<wl_seat::WlSeat>, + maximized: bool, + resizable: bool, +) -> Option<FrameRequest> { + use wayland_protocols::xdg_shell::client::xdg_toplevel::ResizeEdge; + match location { + Location::Top if resizable => Some(FrameRequest::Resize(seat.clone(), ResizeEdge::Top)), + Location::TopLeft if resizable => { + Some(FrameRequest::Resize(seat.clone(), ResizeEdge::TopLeft)) + } + Location::Left if resizable => Some(FrameRequest::Resize(seat.clone(), ResizeEdge::Left)), + Location::BottomLeft if resizable => { + Some(FrameRequest::Resize(seat.clone(), ResizeEdge::BottomLeft)) + } + Location::Bottom if resizable => { + Some(FrameRequest::Resize(seat.clone(), ResizeEdge::Bottom)) + } + Location::BottomRight if resizable => { + Some(FrameRequest::Resize(seat.clone(), ResizeEdge::BottomRight)) + } + Location::Right if resizable => Some(FrameRequest::Resize(seat.clone(), ResizeEdge::Right)), + Location::TopRight if resizable => { + Some(FrameRequest::Resize(seat.clone(), ResizeEdge::TopRight)) + } + Location::Head => Some(FrameRequest::Move(seat.clone())), + Location::Button(UIButton::Close) => Some(FrameRequest::Close), + Location::Button(UIButton::Maximize) => { + if maximized { + Some(FrameRequest::UnMaximize) + } else { + Some(FrameRequest::Maximize) + } + } + Location::Button(UIButton::Minimize) => Some(FrameRequest::Minimize), + _ => None, + } +} + +fn draw_buttons( + canvas: &mut Canvas, + width: u32, + maximizable: bool, + mouses: &[Location], + theme: &Theme, +) { + // Draw seperator between header and window contents + let division_line = line::Line::new( + (0, (HEADER_SIZE - 1) as usize), + ((width) as usize, (HEADER_SIZE - 1) as usize), + theme.get_secondary_color(false), + true, + ); + canvas.draw(&division_line); + + let button_color = theme.get_secondary_color(true); + + if width >= HEADER_SIZE { + // Draw the red button + if mouses + .iter() + .any(|&l| l == Location::Button(UIButton::Close)) + { + // Draw a red shading around close button if hovered over + let red_shade = theme.get_close_button_color(ButtonState::Hovered); + let red_hover = rectangle::Rectangle::new( + ((width - HEADER_SIZE) as usize, 0), + (HEADER_SIZE as usize, HEADER_SIZE as usize), + None, + Some(red_shade), + ); + canvas.draw(&red_hover); + let red_division_line = line::Line::new( + ((width - HEADER_SIZE) as usize, (HEADER_SIZE - 1) as usize), + ((width) as usize, (HEADER_SIZE - 1) as usize), + [ + red_shade[0].saturating_sub(50), + red_shade[1].saturating_sub(50), + red_shade[2].saturating_sub(50), + 255, + ], + true, + ); + canvas.draw(&red_division_line); + }; + + // Draw cross to represent the close button + for i in 0..2 { + let diagonal_line = line::Line::new( + ( + (width - HEADER_SIZE / 2 - 4 + i) as usize, + (HEADER_SIZE / 2 - 4) as usize, + ), + ( + (width - HEADER_SIZE / 2 + 4) as usize, + (HEADER_SIZE / 2 + 4 - i) as usize, + ), + button_color, + true, + ); + canvas.draw(&diagonal_line); + let diagonal_line = line::Line::new( + ( + (width - HEADER_SIZE / 2 - 4) as usize, + (HEADER_SIZE / 2 - 4 + i) as usize, + ), + ( + (width - HEADER_SIZE / 2 + 4 - i) as usize, + (HEADER_SIZE / 2 + 4) as usize, + ), + button_color, + true, + ); + canvas.draw(&diagonal_line); + let diagonal_line = line::Line::new( + ( + (width - HEADER_SIZE / 2 + 4 - i) as usize, + (HEADER_SIZE / 2 - 4) as usize, + ), + ( + (width - HEADER_SIZE / 2 - 4) as usize, + (HEADER_SIZE / 2 + 4 - i) as usize, + ), + button_color, + true, + ); + canvas.draw(&diagonal_line); + let diagonal_line = line::Line::new( + ( + (width - HEADER_SIZE / 2 + 4) as usize, + (HEADER_SIZE / 2 - 4 + i) as usize, + ), + ( + (width - HEADER_SIZE / 2 - 4 + i) as usize, + (HEADER_SIZE / 2 + 4) as usize, + ), + button_color, + true, + ); + canvas.draw(&diagonal_line); + } + } + + if width >= 2 * HEADER_SIZE { + // Draw the green button + if !maximizable { + } else if mouses + .iter() + .any(|&l| l == Location::Button(UIButton::Maximize)) + { + // Draw a green shading around maximize button if hovered over + let green_shade = theme.get_maximize_button_color(ButtonState::Hovered); + let green_hover = rectangle::Rectangle::new( + ((width - 2 * HEADER_SIZE) as usize, 0), + (HEADER_SIZE as usize, HEADER_SIZE as usize), + None, + Some(green_shade), + ); + canvas.draw(&green_hover); + let green_division_line = line::Line::new( + ( + (width - 2 * HEADER_SIZE) as usize, + (HEADER_SIZE - 1) as usize, + ), + ((width - HEADER_SIZE) as usize, (HEADER_SIZE - 1) as usize), + [ + green_shade[0].saturating_sub(50), + green_shade[1].saturating_sub(50), + green_shade[2].saturating_sub(50), + 255, + ], + true, + ); + canvas.draw(&green_division_line); + }; + for i in 0..3 { + let left_diagional = line::Line::new( + ( + (width - HEADER_SIZE - HEADER_SIZE / 2 - 4 - i) as usize, + (HEADER_SIZE / 2 + 2) as usize, + ), + ( + (width - HEADER_SIZE - HEADER_SIZE / 2) as usize, + (HEADER_SIZE / 2 - 2 - i) as usize, + ), + button_color, + true, + ); + canvas.draw(&left_diagional); + let right_diagional = line::Line::new( + ( + (width - HEADER_SIZE - HEADER_SIZE / 2 + 4 + i) as usize, + (HEADER_SIZE / 2 + 2) as usize, + ), + ( + (width - HEADER_SIZE - HEADER_SIZE / 2) as usize, + (HEADER_SIZE / 2 - 2 - i) as usize, + ), + button_color, + true, + ); + canvas.draw(&right_diagional); + } + } + + if width >= 3 * HEADER_SIZE { + // Draw the blue button + if mouses + .iter() + .any(|&l| l == Location::Button(UIButton::Minimize)) + { + // Draw a blue shading around minimize button if hovered over + let blue_shade = theme.get_minimize_button_color(ButtonState::Hovered); + let blue_hover = rectangle::Rectangle::new( + ((width - 3 * HEADER_SIZE) as usize, 0), + (HEADER_SIZE as usize, HEADER_SIZE as usize), + None, + Some(blue_shade), + ); + canvas.draw(&blue_hover); + let blue_division_line = line::Line::new( + ( + (width - 3 * HEADER_SIZE) as usize, + (HEADER_SIZE - 1) as usize, + ), + ( + (width - 2 * HEADER_SIZE) as usize, + (HEADER_SIZE - 1) as usize, + ), + [ + blue_shade[0].saturating_sub(50), + blue_shade[1].saturating_sub(50), + blue_shade[2].saturating_sub(50), + 255, + ], + true, + ); + canvas.draw(&blue_division_line); + } + for i in 0..3 { + let left_diagional = line::Line::new( + ( + (width - 2 * HEADER_SIZE - HEADER_SIZE / 2 - 4 - i) as usize, + (HEADER_SIZE / 2 - 3) as usize, + ), + ( + (width - 2 * HEADER_SIZE - HEADER_SIZE / 2) as usize, + (HEADER_SIZE / 2 + 1 + i) as usize, + ), + button_color, + true, + ); + canvas.draw(&left_diagional); + let right_diagional = line::Line::new( + ( + (width - 2 * HEADER_SIZE - HEADER_SIZE / 2 + 4 + i) as usize, + (HEADER_SIZE / 2 - 3) as usize, + ), + ( + (width - 2 * HEADER_SIZE - HEADER_SIZE / 2) as usize, + (HEADER_SIZE / 2 + 1 + i) as usize, + ), + button_color, + true, + ); + canvas.draw(&right_diagional); + } + } +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/window/mod.rs b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/window/mod.rs new file mode 100644 index 0000000..ece8d45 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/src/window/mod.rs @@ -0,0 +1,642 @@ +//! Window abstraction +use std::sync::{Arc, Mutex}; + +use wayland_client::protocol::{ + wl_compositor, wl_output, wl_seat, wl_shm, wl_subcompositor, wl_surface, +}; +use wayland_client::Proxy; + +use wayland_protocols::xdg_shell::client::xdg_toplevel::ResizeEdge; +pub use wayland_protocols::xdg_shell::client::xdg_toplevel::State; + +use self::zxdg_decoration_manager_v1::RequestsTrait as DecorationMgrRequests; +use self::zxdg_toplevel_decoration_v1::RequestsTrait as DecorationRequests; +use wayland_protocols::unstable::xdg_decoration::v1::client::{ + zxdg_decoration_manager_v1, zxdg_toplevel_decoration_v1, +}; + +use {Environment, Shell}; + +mod basic_frame; +mod concept_frame; +use shell; + +pub use self::basic_frame::BasicFrame; +pub use self::concept_frame::ConceptFrame; + +// Defines the minimum window size. Minimum width is set to 2 pixels to circumvent +// a bug in mutter - https://gitlab.gnome.org/GNOME/mutter/issues/259 +const MIN_WINDOW_SIZE: (u32, u32) = (2, 1); + +/// Represents the status of a button +pub enum ButtonState { + /// Button is being hovered over by pointer + Hovered, + /// Button is not being hovered over by pointer + Idle, + /// Button is disabled + Disabled, +} + +/// Interface for defining the theme of window decorations +/// +/// A type implementing this trait can be used to define custom +/// themes to adjust the decorations provided by a type implementing +/// the 'Frame' trait +pub trait Theme: Send + 'static { + /// Gets the primary color of the scheme, active when window is + fn get_primary_color(&self, active: bool) -> [u8; 4]; + /// Gets the secondary color of the scheme, active when window is + fn get_secondary_color(&self, active: bool) -> [u8; 4]; + /// Gets the color for the close button, active when button is hovered over + fn get_close_button_color(&self, status: ButtonState) -> [u8; 4]; + /// Gets the color for the maximize button, active when button is hovered over + fn get_maximize_button_color(&self, status: ButtonState) -> [u8; 4]; + /// Gets the color for the minimize button, active when button is hovered over + fn get_minimize_button_color(&self, status: ButtonState) -> [u8; 4]; +} + +/// Possible events generated by a window that you need to handle +#[derive(Clone, Debug)] +pub enum Event { + /// The state of your window has been changed + Configure { + /// Optional new size for your *inner* surface + /// + /// This is the new size of the contents of your window + /// as suggested by the server. You can ignore it and choose + /// a new size if you want better control on the possible + /// sizes of your window. + /// + /// In all cases, these events can be generated in large batches + /// during an interactive resize, and you should buffer them before + /// processing them. You only need to handle the last one of a batch. + new_size: Option<(u32, u32)>, + /// New combination of states of your window + /// + /// Typically tells you if your surface is active/inactive, maximized, + /// etc... + states: Vec<State>, + }, + /// A close request has been received + /// + /// Most likely the user has clicked on the close button of the decorations + /// or something equivalent + Close, + /// The decorations need to be refreshed + Refresh, +} + +struct WindowInner<F> { + frame: Arc<Mutex<F>>, + shell_surface: Arc<Box<shell::ShellSurface>>, + user_impl: Box<FnMut(Event) + Send>, + min_size: (u32, u32), + max_size: Option<(u32, u32)>, + current_size: (u32, u32), + old_size: Option<(u32, u32)>, + decorated: bool, +} + +/// A window +/// +/// This wrapper handles for you the decoration of your window +/// and the interaction with the server regarding the shell protocol. +/// +/// You are still entirely responsible for drawing the contents of your +/// window. +/// +/// Note also that as the dimensions of wayland surfaces is defined by +/// their attached buffer, you need to keep the decorations in sync with +/// your contents via the `resize(..)` method. +/// +/// Different kind of decorations can be used by customizing the type +/// parameter. A few are provided in this crate, but any type implementing +/// the `Frame` trait can do. +pub struct Window<F: Frame> { + frame: Arc<Mutex<F>>, + surface: Proxy<wl_surface::WlSurface>, + decoration: Mutex<Option<Proxy<zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1>>>, + decoration_mgr: Option<Proxy<zxdg_decoration_manager_v1::ZxdgDecorationManagerV1>>, + shell_surface: Arc<Box<shell::ShellSurface>>, + inner: Arc<Mutex<Option<WindowInner<F>>>>, +} + +impl<F: Frame + 'static> Window<F> { + /// Create a new window wrapping a given wayland surface as its main content and + /// following the compositor's preference regarding server-side decorations. + pub fn init_from_env<Impl>( + env: &Environment, + surface: Proxy<wl_surface::WlSurface>, + initial_dims: (u32, u32), + implementation: Impl, + ) -> Result<Window<F>, F::Error> + where + Impl: FnMut(Event) + Send + 'static, + { + Self::init_with_decorations( + surface, + initial_dims, + &env.compositor, + &env.subcompositor, + &env.shm, + &env.shell, + env.decorations_mgr.as_ref(), + implementation, + ) + } + + /// Create a new window wrapping a given wayland surface as its main content + /// + /// It can fail if the initialization of the frame fails (for example if the + /// frame class fails to initialize its SHM). + pub fn init<Impl>( + surface: Proxy<wl_surface::WlSurface>, + initial_dims: (u32, u32), + compositor: &Proxy<wl_compositor::WlCompositor>, + subcompositor: &Proxy<wl_subcompositor::WlSubcompositor>, + shm: &Proxy<wl_shm::WlShm>, + shell: &Shell, + implementation: Impl, + ) -> Result<Window<F>, F::Error> + where + Impl: FnMut(Event) + Send + 'static, + { + Self::init_with_decorations( + surface, + initial_dims, + compositor, + subcompositor, + shm, + shell, + None, + implementation, + ) + } + + /// Create a new window wrapping a given wayland surface as its main content and + /// following the compositor's preference regarding server-side decorations + /// + /// It can fail if the initialization of the frame fails (for example if the + /// frame class fails to initialize its SHM). + pub fn init_with_decorations<Impl>( + surface: Proxy<wl_surface::WlSurface>, + initial_dims: (u32, u32), + compositor: &Proxy<wl_compositor::WlCompositor>, + subcompositor: &Proxy<wl_subcompositor::WlSubcompositor>, + shm: &Proxy<wl_shm::WlShm>, + shell: &Shell, + decoration_mgr: Option<&Proxy<zxdg_decoration_manager_v1::ZxdgDecorationManagerV1>>, + implementation: Impl, + ) -> Result<Window<F>, F::Error> + where + Impl: FnMut(Event) + Send + 'static, + { + let inner = Arc::new(Mutex::new(None::<WindowInner<F>>)); + let frame_inner = inner.clone(); + let shell_inner = inner.clone(); + let mut frame = F::init( + &surface, + compositor, + subcompositor, + shm, + Box::new(move |req, serial| { + if let Some(ref mut inner) = *shell_inner.lock().unwrap() { + match req { + FrameRequest::Minimize => inner.shell_surface.set_minimized(), + FrameRequest::Maximize => inner.shell_surface.set_maximized(), + FrameRequest::UnMaximize => inner.shell_surface.unset_maximized(), + FrameRequest::Move(seat) => inner.shell_surface.move_(&seat, serial), + FrameRequest::Resize(seat, edges) => { + inner.shell_surface.resize(&seat, serial, edges) + } + FrameRequest::Close => (inner.user_impl)(Event::Close), + FrameRequest::Refresh => (inner.user_impl)(Event::Refresh), + } + } + }) as Box<_>, + )?; + frame.resize(initial_dims); + let frame = Arc::new(Mutex::new(frame)); + let shell_surface = Arc::new(shell::create_shell_surface(shell, &surface, move |event| { + if let Some(ref mut inner) = *frame_inner.lock().unwrap() { + match event { + shell::Event::Configure { + states, + mut new_size, + } => { + let mut frame = inner.frame.lock().unwrap(); + // clamp size + new_size = new_size.map(|(w, h)| { + use std::cmp::{max, min}; + let (mut w, mut h) = frame.subtract_borders(w as i32, h as i32); + let (minw, minh) = inner.min_size; + w = max(w, minw as i32); + h = max(h, minh as i32); + if let Some((maxw, maxh)) = inner.max_size { + w = min(w, maxw as i32); + h = min(h, maxh as i32); + } + (max(w, 1) as u32, max(h, 1) as u32) + }); + // compute frame changes + let mut need_refresh = false; + need_refresh |= frame.set_maximized(states.contains(&State::Maximized)); + if need_refresh { + // the maximization state changed + if states.contains(&State::Maximized) { + // we are getting maximized, store the size for restoration + inner.old_size = Some(inner.current_size); + } else if new_size.is_none() { + // we are getting de-maximized, restore the size + new_size = inner.old_size.take(); + } + } + need_refresh |= frame.set_active(states.contains(&State::Activated)); + if need_refresh { + (inner.user_impl)(Event::Refresh); + } + (inner.user_impl)(Event::Configure { states, new_size }); + } + shell::Event::Close => { + (inner.user_impl)(Event::Close); + } + } + } + })); + + // setup size and geometry + { + let frame = frame.lock().unwrap(); + let (minw, minh) = + frame.add_borders(MIN_WINDOW_SIZE.0 as i32, MIN_WINDOW_SIZE.1 as i32); + shell_surface.set_min_size(Some((minw, minh))); + let (w, h) = frame.add_borders(initial_dims.0 as i32, initial_dims.1 as i32); + let (x, y) = frame.location(); + shell_surface.set_geometry(x, y, w, h); + } + + *(inner.lock().unwrap()) = Some(WindowInner { + frame: frame.clone(), + shell_surface: shell_surface.clone(), + user_impl: Box::new(implementation) as Box<_>, + min_size: (MIN_WINDOW_SIZE.0, MIN_WINDOW_SIZE.1), + max_size: None, + current_size: initial_dims, + old_size: None, + decorated: true, + }); + + let window = Window { + frame, + shell_surface, + decoration: Mutex::new(None), + decoration_mgr: decoration_mgr.cloned(), + surface, + inner, + }; + + // init decoration if applicable + { + let mut decoration = window.decoration.lock().unwrap(); + window.ensure_decoration(&mut decoration); + } + + Ok(window) + } + + fn ensure_decoration( + &self, + decoration: &mut Option<Proxy<zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1>>, + ) { + if self.decoration_mgr.is_none() { + return; + } + + if let Some(ref decoration) = *decoration { + if decoration.is_alive() { + return; + } + } + + let decoration_frame = self.frame.clone(); + let decoration_inner = self.inner.clone(); + *decoration = match (self.shell_surface.get_xdg(), &self.decoration_mgr) { + (Some(toplevel), &Some(ref mgr)) => { + use self::zxdg_toplevel_decoration_v1::{Event, Mode}; + mgr.get_toplevel_decoration(toplevel, |newdec| { + newdec.implement( + move |event, _| { + let Event::Configure { mode } = event; + match mode { + Mode::ServerSide => { + decoration_frame.lock().unwrap().set_hidden(true); + } + Mode::ClientSide => { + let want_decorate = decoration_inner + .lock() + .unwrap() + .as_ref() + .map(|inner| inner.decorated) + .unwrap_or(false); + decoration_frame.lock().unwrap().set_hidden(!want_decorate); + } + } + }, + (), + ) + }) + .ok() + .map(|decoration| { + decoration.set_mode(Mode::ServerSide); + decoration + }) + } + _ => None, + }; + } + + /// Notify this window that a new seat is accessible + /// + /// This allows the decoration manager to get an handle to the pointer + /// to manage pointer events and change the pointer image appropriately. + pub fn new_seat(&mut self, seat: &Proxy<wl_seat::WlSeat>) { + self.frame.lock().unwrap().new_seat(seat); + } + + /// Access the surface wrapped in this Window + pub fn surface(&self) -> &Proxy<wl_surface::WlSurface> { + &self.surface + } + + /// Refreshes the frame + /// + /// Redraws the frame to match its requested state (dimensions, presence/ + /// absence of decorations, ...) + /// + /// You need to call this method after every change to the dimensions or state + /// of the decorations of your window, otherwise the drawn decorations may go + /// out of sync with the state of your content. + /// + /// Your implementation will also receive `Refresh` events when the frame requests + /// to be redrawn (to provide some frame animations for example). + pub fn refresh(&mut self) { + self.frame.lock().unwrap().redraw(); + } + + /// Set a short title for the window. + /// + /// This string may be used to identify the surface in a task bar, window list, or other + /// user interface elements provided by the compositor. + /// + /// You need to call `refresh()` afterwards for this to properly + /// take effect. + pub fn set_title(&self, title: String) { + self.frame.lock().unwrap().set_title(title.clone()); + self.shell_surface.set_title(title); + } + + /// Set an app id for the surface. + /// + /// The surface class identifies the general class of applications to which the surface + /// belongs. + /// + /// Several wayland compositors will try to find a `.desktop` file matching this name + /// to find metadata about your apps. + pub fn set_app_id(&self, app_id: String) { + self.shell_surface.set_app_id(app_id); + } + + /// Set whether the window should be decorated or not + /// + /// You need to call `refresh()` afterwards for this to properly + /// take effect. + pub fn set_decorate(&self, decorate: bool) { + self.frame.lock().unwrap().set_hidden(!decorate); + let mut decoration_guard = self.decoration.lock().unwrap(); + self.ensure_decoration(&mut decoration_guard); + if let Some(ref dec) = *decoration_guard { + if decorate { + // let the server decide decorations + dec.unset_mode(); + } else { + // destroy the decoration object, so that the server does not + // decorate us + dec.destroy(); + } + } + } + + /// Set whether the window should be resizeable by the user + /// + /// This is not an hard blocking, as the compositor can always + /// resize you forcibly if it wants. However it signals it that + /// you don't want this window to be resized. + /// + /// Additionally, the decorations will stop suggesting the user + /// to resize by dragging the borders if you set the window as + /// non-resizable. + /// + /// When re-activating resizability, any previously set min/max + /// sizes are restored. + pub fn set_resizable(&self, resizable: bool) { + let mut frame = self.frame.lock().unwrap(); + frame.set_resizable(resizable); + let mut inner = self.inner.lock().unwrap(); + if let Some(ref mut inner) = *inner { + if resizable { + // restore the min/max sizes + self.shell_surface.set_min_size( + Some(inner.min_size).map(|(w, h)| frame.add_borders(w as i32, h as i32)), + ); + self.shell_surface.set_max_size( + inner + .max_size + .map(|(w, h)| frame.add_borders(w as i32, h as i32)), + ); + } else { + // lock the min/max sizes to current size + let (w, h) = inner.current_size; + self.shell_surface + .set_min_size(Some(frame.add_borders(w as i32, h as i32))); + self.shell_surface + .set_max_size(Some(frame.add_borders(w as i32, h as i32))); + } + } + } + + /// Resize the decorations + /// + /// You should call this whenever you change the size of the contents + /// of your window, with the new _inner size_ of your window. + /// + /// You need to call `refresh()` afterwards for this to properly + /// take effect. + pub fn resize(&mut self, w: u32, h: u32) { + use std::cmp::max; + let w = max(w, 1); + let h = max(h, 1); + if let Some(ref mut inner) = *self.inner.lock().unwrap() { + inner.current_size = (w, h); + } + let mut frame = self.frame.lock().unwrap(); + frame.resize((w, h)); + let (w, h) = frame.add_borders(w as i32, h as i32); + let (x, y) = frame.location(); + self.shell_surface.set_geometry(x, y, w, h); + } + + /// Request the window to be maximized + pub fn set_maximized(&self) { + self.shell_surface.set_maximized(); + } + + /// Request the window to be un-maximized + pub fn unset_maximized(&self) { + self.shell_surface.unset_maximized(); + } + + /// Request the window to be minimized + pub fn set_minimized(&self) { + self.shell_surface.set_minimized(); + } + + /// Request the window to be set fullscreen + /// + /// Note: you need to manually disable the decorations if you + /// want to hide them! + pub fn set_fullscreen(&self, output: Option<&Proxy<wl_output::WlOutput>>) { + self.shell_surface.set_fullscreen(output); + } + + /// Request the window to quit fullscreen mode + pub fn unset_fullscreen(&self) { + self.shell_surface.unset_fullscreen(); + } + + /// Sets the minimum possible size for this window + /// + /// Provide either a tuple `Some((width, height))` or `None` to unset the + /// minimum size. + /// + /// The provided size is the interior size, not counting decorations + pub fn set_min_size(&mut self, size: Option<(u32, u32)>) { + let (w, h) = size.unwrap_or(MIN_WINDOW_SIZE); + let (w, h) = self.frame.lock().unwrap().add_borders(w as i32, h as i32); + self.shell_surface.set_min_size(Some((w, h))); + if let Some(ref mut inner) = *(self.inner.lock().unwrap()) { + inner.min_size = size.unwrap_or(MIN_WINDOW_SIZE) + } + } + + /// Sets the maximum possible size for this window + /// + /// Provide either a tuple `Some((width, height))` or `None` to unset the + /// maximum size. + /// + /// The provided size is the interior size, not counting decorations + pub fn set_max_size(&mut self, size: Option<(u32, u32)>) { + let max_size = + size.map(|(w, h)| self.frame.lock().unwrap().add_borders(w as i32, h as i32)); + self.shell_surface.set_max_size(max_size); + if let Some(ref mut inner) = *(self.inner.lock().unwrap()) { + inner.max_size = size.map(|(w, h)| (w as u32, h as u32)); + } + } + + /// Sets the theme for the window + /// + /// Provide a type that implements the 'Theme' trait to adjust + /// the look of the windows decorations + /// + /// The theme must return colors of the format of ARGB8888 + pub fn set_theme<T: Theme>(&mut self, theme: T) { + self.frame.lock().unwrap().set_theme(theme) + } +} + +impl<F: Frame> Drop for Window<F> { + fn drop(&mut self) { + self.inner.lock().unwrap().take(); + } +} + +/// Request generated by a Frame +/// +/// These requests are generated by a Frame and the Window will +/// forward them appropriately to the server. +pub enum FrameRequest { + /// The window should be minimized + Minimize, + /// The window should be maximized + Maximize, + /// The window should be unmaximized + UnMaximize, + /// The window should be closed + Close, + /// An interactive move should be started + Move(Proxy<wl_seat::WlSeat>), + /// An interactive resize should be started + Resize(Proxy<wl_seat::WlSeat>, ResizeEdge), + /// The frame requests to be refreshed + Refresh, +} + +/// Interface for defining the drawing of decorations +/// +/// A type implementing this trait can be used to define custom +/// decorations additionnaly to the ones provided by this crate +/// and be used with `Window`. +pub trait Frame: Sized + Send { + /// Type of errors that may occur when attempting to create a frame + type Error; + /// Initialize the Frame + fn init( + base_surface: &Proxy<wl_surface::WlSurface>, + compositor: &Proxy<wl_compositor::WlCompositor>, + subcompositor: &Proxy<wl_subcompositor::WlSubcompositor>, + shm: &Proxy<wl_shm::WlShm>, + implementation: Box<FnMut(FrameRequest, u32) + Send>, + ) -> Result<Self, Self::Error>; + /// Set whether the decorations should be drawn as active or not + /// + /// Calling this should *not* trigger a redraw, but return `true` if + /// a redraw is needed. + fn set_active(&mut self, active: bool) -> bool; + /// Set whether the decorations should be drawn as maximized or not + /// + /// Calling this should *not* trigger a redraw, but return `true` if + /// a redraw is needed. + fn set_maximized(&mut self, maximized: bool) -> bool; + /// Hide or show the decorations + /// + /// Calling this should *not* trigger a redraw + fn set_hidden(&mut self, hidden: bool); + /// Set whether interactive resize hints should be displayed + /// and reacted to + fn set_resizable(&mut self, resizable: bool); + /// Notify that a new wl_seat should be handled + fn new_seat(&mut self, seat: &Proxy<wl_seat::WlSeat>); + /// Change the size of the decorations + /// + /// Calling this should *not* trigger a redraw + fn resize(&mut self, newsize: (u32, u32)); + /// Redraw the decorations + fn redraw(&mut self); + /// Subtracts the border dimensions from the given dimensions. + fn subtract_borders(&self, width: i32, height: i32) -> (i32, i32); + /// Adds the border dimensions to the given dimensions. + fn add_borders(&self, width: i32, height: i32) -> (i32, i32); + /// Returns the coordinates of the top-left corner of the borders relative to the content + /// + /// Values should thus be negative + fn location(&self) -> (i32, i32) { + (0, 0) + } + + /// Sets the theme for the frame + fn set_theme<T: Theme>(&mut self, theme: T); + + /// Sets the frames title + fn set_title(&mut self, title: String); +} diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/travis_install_wayland.sh b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/travis_install_wayland.sh new file mode 100755 index 0000000..9667b94 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/travis_install_wayland.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# download and compile the wayland libs for given version, they will be installed in ~/install + +wayland_version=$1 + +mkdir ~/temp/ ~/install + +# download and extract +cd ~/temp/ +wget https://github.com/wayland-project/wayland/archive/${wayland_version}.tar.gz -O wayland.tar.gz +tar xf wayland.tar.gz +cd wayland-${wayland_version} + +# compile and install +./autogen.sh --prefix=$HOME/install --disable-documentation --disable-dtd-validation --disable-dependency-tracking +make +make install diff --git a/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/update_keysyms.sh b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/update_keysyms.sh new file mode 100755 index 0000000..cdefe49 --- /dev/null +++ b/third_party/cargo/vendor/smithay-client-toolkit-0.4.6/update_keysyms.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +X11_INCLUDEDIR="/usr/include/X11" +KEYSYMDEFS="${X11_INCLUDEDIR}/keysymdef.h + ${X11_INCLUDEDIR}/XF86keysym.h + ${X11_INCLUDEDIR}/Sunkeysym.h + ${X11_INCLUDEDIR}/DECkeysym.h + ${X11_INCLUDEDIR}/HPkeysym.h" +TARGET_FILE=src/keyboard/keysyms.rs + +echo "//" > $TARGET_FILE +echo "// This file was auto-generated using the update-keysyms.sh script." >> $TARGET_FILE +echo "//" >> $TARGET_FILE +echo "" >> $TARGET_FILE +echo "#![allow(non_upper_case_globals)]" >> $TARGET_FILE +echo "#![cfg_attr(rustfmt, rustfmt_skip)]" >> $TARGET_FILE +echo "" >> $TARGET_FILE + +cat $KEYSYMDEFS | sed -e '/XK_Ydiaeresis\s*0x100000ee/d' \ + -e '/#define _/d' \ + -e 's/#define\s*\(\w*\)XK_/#define XKB_KEY_\1/' \ + -e '/\(#ifdef\|#ifndef\|#endif\)/d' \ + -e 's/#define/pub const/g' \ + -e 's/0x\([0-9a-fA-F]*\)/:u32 = 0x\1;/g' >> $TARGET_FILE diff --git a/third_party/cargo/vendor/stable_deref_trait-1.1.1/.cargo-checksum.json b/third_party/cargo/vendor/stable_deref_trait-1.1.1/.cargo-checksum.json new file mode 100644 index 0000000..abdf0b4 --- /dev/null +++ b/third_party/cargo/vendor/stable_deref_trait-1.1.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"56ab4873c19b49e38e91820c4824f3ba208b58414c272d47cdbd34db1784eb69","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5e05b024f653a5ce199e77cbbbd42fb5553562ec714b819421ed0c3e552a75d7","README.md":"750fc2d57412de57566289e567b5674a666cc7a8a054f8c7129b8553f9003de7","src/lib.rs":"0223b3f374305b556cba65406d6c8bc5ff053e592c6c0c36e276b94f5e06d70d"},"package":"dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"} \ No newline at end of file diff --git a/third_party/cargo/vendor/stable_deref_trait-1.1.1/BUILD b/third_party/cargo/vendor/stable_deref_trait-1.1.1/BUILD new file mode 100644 index 0000000..b9598cc --- /dev/null +++ b/third_party/cargo/vendor/stable_deref_trait-1.1.1/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "stable_deref_trait", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.1.1", + crate_features = [ + "default", + "std", + ], +) + diff --git a/third_party/cargo/vendor/stable_deref_trait-1.1.1/Cargo.toml b/third_party/cargo/vendor/stable_deref_trait-1.1.1/Cargo.toml new file mode 100644 index 0000000..0bbe977 --- /dev/null +++ b/third_party/cargo/vendor/stable_deref_trait-1.1.1/Cargo.toml @@ -0,0 +1,27 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "stable_deref_trait" +version = "1.1.1" +authors = ["Robert Grosse <n210241048576@gmail.com>"] +description = "An unsafe marker trait for types like Box and Rc that dereference to a stable address even when moved, and hence can be used with libraries such as owning_ref and rental.\n" +documentation = "https://docs.rs/stable_deref_trait/1.1.1/stable_deref_trait" +readme = "README.md" +categories = ["memory-management", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/storyyeller/stable_deref_trait" + +[features] +alloc = [] +default = ["std"] +std = [] diff --git a/third_party/cargo/vendor/stable_deref_trait-1.1.1/LICENSE-APACHE b/third_party/cargo/vendor/stable_deref_trait-1.1.1/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/stable_deref_trait-1.1.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/stable_deref_trait-1.1.1/LICENSE-MIT b/third_party/cargo/vendor/stable_deref_trait-1.1.1/LICENSE-MIT new file mode 100644 index 0000000..3bf61a0 --- /dev/null +++ b/third_party/cargo/vendor/stable_deref_trait-1.1.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2017 Robert Grosse + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/third_party/cargo/vendor/stable_deref_trait-1.1.1/README.md b/third_party/cargo/vendor/stable_deref_trait-1.1.1/README.md new file mode 100644 index 0000000..24fd4b0 --- /dev/null +++ b/third_party/cargo/vendor/stable_deref_trait-1.1.1/README.md @@ -0,0 +1,23 @@ +This crate defines an unsafe marker trait, StableDeref, for container types which deref to a fixed address which is valid even when the containing type is moved. For example, Box, Vec, Rc, Arc and String implement this trait. Additionally, it defines CloneStableDeref for types like Rc where clones deref to the same address. + +It is intended to be used by crates such as [owning_ref](https://crates.io/crates/owning_ref) and [rental](https://crates.io/crates/rental), as well as library authors who wish to make their code interoperable with such crates. For example, if you write a custom Vec type, you can implement StableDeref, and then users will be able to use your custom Vec type together with owning_ref and rental. + +no_std support can be enabled by disabling default features (specifically "std"). In this case, the trait will not be implemented for the std types mentioned above, but you can still use it for your own types. + +Enable the "alloc" feature (with default-features disabled) to have this trait be implemented for the above types from the built-in `alloc` crate, specifically +* `alloc::boxed::Box` +* `alloc::vec::Vec` +* `alloc::rc::Rc` +* `alloc::arc::Arc` +* `alloc::string::String` + +For example, this crate can be built with alloc support via the following command: +`cargo build --no-default-features --features alloc` + +Or added as a `Cargo.toml` dependency as follows: +``` +[dependencies.stable_deref_trait] +version = "<version>" +default-features = false +features = [ "alloc" ] +``` diff --git a/third_party/cargo/vendor/stable_deref_trait-1.1.1/src/lib.rs b/third_party/cargo/vendor/stable_deref_trait-1.1.1/src/lib.rs new file mode 100644 index 0000000..c4272b8 --- /dev/null +++ b/third_party/cargo/vendor/stable_deref_trait-1.1.1/src/lib.rs @@ -0,0 +1,201 @@ +// Copyright 2017 Robert Grosse + +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/*! +This module defines an unsafe marker trait, StableDeref, for container types that deref to a fixed address which is valid even when the containing type is moved. For example, Box, Vec, Rc, Arc and String implement this trait. Additionally, it defines CloneStableDeref for types like Rc where clones deref to the same address. + +It is intended to be used by crates such as [owning_ref](https://crates.io/crates/owning_ref) and [rental](https://crates.io/crates/rental), as well as library authors who wish to make their code interoperable with such crates. For example, if you write a custom Vec type, you can implement StableDeref, and then users will be able to use your custom type together with owning_ref and rental. + +no_std support can be enabled by disabling default features (specifically "std"). In this case, the trait will not be implemented for the std types mentioned above, but you can still use it for your own types. +*/ + +#![cfg_attr(feature = "alloc", feature(alloc))] + +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(feature = "std")] +extern crate core; + +#[cfg(feature = "alloc")] +extern crate alloc; + +use core::ops::Deref; + + +/** +An unsafe marker trait for types that deref to a stable address, even when moved. For example, this is implemented by Box, Vec, Rc, Arc and String, among others. Even when a Box is moved, the underlying storage remains at a fixed location. + +More specifically, implementors must ensure that the result of calling deref() is valid for the lifetime of the object, not just the lifetime of the borrow, and that the deref is valid even if the object is moved. Also, it must be valid even after invoking arbitrary &self methods or doing anything transitively accessible from &Self. If Self also implements DerefMut, the same restrictions apply to deref_mut() and it must remain valid if anything transitively accessible from the result of deref_mut() is mutated/called. Additionally, multiple calls to deref, (and deref_mut if implemented) must return the same address. No requirements are placed on &mut self methods other than deref_mut() and drop(), if applicable. + +Basically, it must be valid to convert the result of deref() to a pointer, and later dereference that pointer, as long as the original object is still live, even if it has been moved or &self methods have been called on it. If DerefMut is also implemented, it must be valid to get pointers from deref() and deref_mut() and dereference them while the object is live, as long as you don't simultaneously dereference both of them. + +Additionally, Deref and DerefMut implementations must not panic, but users of the trait are not allowed to rely on this fact (so that this restriction can be removed later without breaking backwards compatibility, should the need arise). + +Here are some examples to help illustrate the requirements for implementing this trait: + +``` +# use std::ops::Deref; +struct Foo(u8); +impl Deref for Foo { + type Target = u8; + fn deref(&self) -> &Self::Target { &self.0 } +} +``` + +Foo cannot implement StableDeref because the int will move when Foo is moved, invalidating the result of deref(). + +``` +# use std::ops::Deref; +struct Foo(Box<u8>); +impl Deref for Foo { + type Target = u8; + fn deref(&self) -> &Self::Target { &*self.0 } +} +``` + +Foo can safely implement StableDeref, due to the use of Box. + + +``` +# use std::ops::Deref; +# use std::ops::DerefMut; +# use std::rc::Rc; +#[derive(Clone)] +struct Foo(Rc<u8>); +impl Deref for Foo { + type Target = u8; + fn deref(&self) -> &Self::Target { &*self.0 } +} +impl DerefMut for Foo { + fn deref_mut(&mut self) -> &mut Self::Target { Rc::make_mut(&mut self.0) } +} +``` + +This is a simple implementation of copy-on-write: Foo's deref_mut will copy the underlying int if it is not uniquely owned, ensuring unique access at the point where deref_mut() returns. However, Foo cannot implement StableDeref because calling deref_mut(), followed by clone().deref() will result in mutable and immutable references to the same location. Note that if the DerefMut implementation were removed, Foo could safely implement StableDeref. Likewise, if the Clone implementation were removed, it would be safe to implement StableDeref, although Foo would not be very useful in that case, (without clones, the rc will always be uniquely owned). + + +``` +# use std::ops::Deref; +struct Foo; +impl Deref for Foo { + type Target = str; + fn deref(&self) -> &Self::Target { &"Hello" } +} +``` +Foo can safely implement StableDeref. It doesn't own the data being derefed, but the data is gaurenteed to live long enough, due to it being 'static. + +``` +# use std::ops::Deref; +# use std::cell::Cell; +struct Foo(Cell<bool>); +impl Deref for Foo { + type Target = str; + fn deref(&self) -> &Self::Target { + let b = self.0.get(); + self.0.set(!b); + if b { &"Hello" } else { &"World" } + } +} +``` +Foo cannot safely implement StableDeref, even though every possible result of deref lives long enough. In order to safely implement StableAddress, multiple calls to deref must return the same result. + +``` +# use std::ops::Deref; +# use std::ops::DerefMut; +struct Foo(Box<(u8, u8)>); +impl Deref for Foo { + type Target = u8; + fn deref(&self) -> &Self::Target { &self.0.deref().0 } +} +impl DerefMut for Foo { + fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0.deref_mut().1 } +} +``` + +Foo cannot implement StableDeref because deref and deref_mut return different addresses. + + +*/ +pub unsafe trait StableDeref: Deref {} + +/** +An unsafe marker trait for types where clones deref to the same address. This has all the requirements of StableDeref, and additionally requires that after calling clone(), both the old and new value deref to the same address. For example, Rc and Arc implement CloneStableDeref, but Box and Vec do not. + +Note that a single type should never implement both DerefMut and CloneStableDeref. If it did, this would let you get two mutable references to the same location, by cloning and then calling deref_mut() on both values. +*/ +pub unsafe trait CloneStableDeref: StableDeref + Clone {} + +///////////////////////////////////////////////////////////////////////////// +// std types integration +///////////////////////////////////////////////////////////////////////////// + +#[cfg(all(feature = "std", not(feature = "alloc")))] +use std::boxed::Box; +#[cfg(all(not(feature = "std"), feature = "alloc"))] +use alloc::boxed::Box; + +#[cfg(all(feature = "std", not(feature = "alloc")))] +use std::rc::Rc; +#[cfg(all(not(feature = "std"), feature = "alloc"))] +use alloc::rc::Rc; + +#[cfg(all(feature = "std", not(feature = "alloc")))] +use std::sync::Arc; +#[cfg(all(not(feature = "std"), feature = "alloc"))] +use alloc::sync::Arc; + +#[cfg(all(feature = "std", not(feature = "alloc")))] +use std::vec::Vec; +#[cfg(all(not(feature = "std"), feature = "alloc"))] +use alloc::vec::Vec; + +#[cfg(all(feature = "std", not(feature = "alloc")))] +use std::string::String; +#[cfg(all(not(feature = "std"), feature = "alloc"))] +use alloc::string::String; + + +#[cfg(feature = "std")] +use std::sync::{MutexGuard, RwLockReadGuard, RwLockWriteGuard}; + +#[cfg(feature = "std")] +use std::cell::{Ref, RefMut}; +#[cfg(not(feature = "std"))] +use core::cell::{Ref, RefMut}; + + +#[cfg(any(feature = "std", feature = "alloc"))] +unsafe impl<T: ?Sized> StableDeref for Box<T> {} +#[cfg(any(feature = "std", feature = "alloc"))] +unsafe impl<T> StableDeref for Vec<T> {} +#[cfg(any(feature = "std", feature = "alloc"))] +unsafe impl StableDeref for String {} + +#[cfg(any(feature = "std", feature = "alloc"))] +unsafe impl<T: ?Sized> StableDeref for Rc<T> {} +#[cfg(any(feature = "std", feature = "alloc"))] +unsafe impl<T: ?Sized> CloneStableDeref for Rc<T> {} +#[cfg(any(feature = "std", feature = "alloc"))] +unsafe impl<T: ?Sized> StableDeref for Arc<T> {} +#[cfg(any(feature = "std", feature = "alloc"))] +unsafe impl<T: ?Sized> CloneStableDeref for Arc<T> {} + +// #[cfg(any(feature = "std", feature = "alloc"))] +unsafe impl<'a, T: ?Sized> StableDeref for Ref<'a, T> {} +// #[cfg(any(feature = "std", feature = "alloc"))] +unsafe impl<'a, T: ?Sized> StableDeref for RefMut<'a, T> {} +#[cfg(feature = "std")] +unsafe impl<'a, T: ?Sized> StableDeref for MutexGuard<'a, T> {} +#[cfg(feature = "std")] +unsafe impl<'a, T: ?Sized> StableDeref for RwLockReadGuard<'a, T> {} +#[cfg(feature = "std")] +unsafe impl<'a, T: ?Sized> StableDeref for RwLockWriteGuard<'a, T> {} + +unsafe impl<'a, T: ?Sized> StableDeref for &'a T {} +unsafe impl<'a, T: ?Sized> CloneStableDeref for &'a T {} +unsafe impl<'a, T: ?Sized> StableDeref for &'a mut T {} diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/.cargo-checksum.json b/third_party/cargo/vendor/stb_truetype-0.3.1/.cargo-checksum.json new file mode 100644 index 0000000..f78a770 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"ec2db7230716c5c111ad40ee7bf40ace7ccb3e3ba787b5bf0d0f79c1c5c06a4b","Cargo.toml":"3224d19a4ddd50259ff63526d043ffe0f0fe4879aeffd528591c9312ff1cd3c3","LICENSE-APACHE":"559a84a882160cd5ae5ad559efb15bc613adac9e5346fd047617f48e1bb9fcb4","LICENSE-MIT":"fd198949ebcc78b2d12fc57ebfb2da4ae8f781b7c3b7047aaccc2f804b6f12ef","README.md":"b048de643b604e9354c3f50b0ebb79356b3394e09bde19992cff704c0244f5b3","benches/api.rs":"b9884d6e0870a52de2ab7a86eab68b5ac73d0e1c7a35bf581b716c56f7217ef4","examples/fontnames.rs":"e8595f2f6c31ac543fccfe7ed1d208bf90cc622f66eec443170dd0a5515688d1","examples/simple.rs":"bfbc6dedbdacb90c341882bedaa613a2784e85e9a46346c226f6d657fdd28f9d","rustfmt.toml":"ed17bf27c3712b8f22ec7a2a9d8e5d9d2a5654299754fb93e9ac76ef6d153114","src/lib.rs":"dac930af78a95d6e05222438fd090231fd1f5c1f9f04efc1d9c121fa791132d3","tests/mod.rs":"e72f20ac7f3abf4afe29041f598c8dc3a6bcbdb78ab235775d80716ff0686b3a"},"package":"f77b6b07e862c66a9f3e62a07588fee67cd90a9135a2b942409f195507b4fb51"} \ No newline at end of file diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/BUILD b/third_party/cargo/vendor/stb_truetype-0.3.1/BUILD new file mode 100644 index 0000000..d142202 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/BUILD @@ -0,0 +1,48 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "api" with type "bench" omitted +# Unsupported target "fontnames" with type "example" omitted +# Unsupported target "mod" with type "test" omitted +# Unsupported target "simple" with type "example" omitted + +rust_library( + name = "stb_truetype", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/byteorder-1.3.2:byteorder", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.3.1", + crate_features = [ + "std", + ], +) + diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/CHANGELOG.md b/third_party/cargo/vendor/stb_truetype-0.3.1/CHANGELOG.md new file mode 100644 index 0000000..97f8056 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/CHANGELOG.md @@ -0,0 +1,62 @@ +## Unreleased +* Update libm -> `0.2.1`. + +## 0.3 +* Support no-std usage by disabling new default feature `std`. +```rust +stb_truetype = { version = "0.2", default-features = false, features = ["libm"] } +``` + +## 0.2.8 +* Use semver trick to re-expect stb_truetype `0.3` with default-features on. + +## 0.2.7 +_yanked_ + +## 0.2.6 +* Implement `Copy` for `FontInfo`. +* Implement `PartialEq`, `Eq`, `Hash` for `Vertex`, `VertexType`, `Rect`, `HMetrics`, `VMetrics`. +* Require byteorder `1.1` as a minimum to avoid compile errors with earlier versions. + +## 0.2.5 +* Fix `get_glyph_shape` panic with Consolas character `\u{feff}`. + +## 0.2.4 +* Remove all unsafe usage. +* Fix glyph positioning bug for compound glyphs (#18). +* Optimise compound glyph shape computation. + +## 0.2.3 +* Add `is_collection(&[u8]) -> bool`. +* Remove most unsafe usages. +* `VertexType` implements `Eq`. +* Optimise API performance using new benchmark/regression suite + +``` +name control ns/iter change ns/iter diff ns/iter diff % speedup +find_glyph_index_deja_vu_mono 1,189 856 -333 -28.01% x 1.39 +get_glyph_bitmap_box_subpixel_deja_vu_mono 859 696 -163 -18.98% x 1.23 +get_glyph_box_deja_vu_mono 617 276 -341 -55.27% x 2.24 +get_glyph_h_metrics_deja_vu_mono 204 184 -20 -9.80% x 1.11 +get_glyph_shape_deja_vu_mono 12,304 12,950 646 5.25% x 0.95 +get_v_metrics_deja_vu_mono 360 100 -260 -72.22% x 3.60 +scale_for_pixel_height_deja_vu_mono 145 118 -27 -18.62% x 1.23 +``` + +## 0.2.2 +* Merge a number of bugfixes, update documentation links, add new debugging features. + +## 0.2.1 +* Fix `attempt to subtract with overflow` error in get_glyph_kern_advance. + +## 0.2 +* `FontInfo` is now generic in the storage for the font data, allowing flexible management of font data lifetimes. This is a breaking change. + +## 0.1.2 +* Fix for edge case behaviour for `get_glyph_pair_kern_advance` by switching to `i32` instead of `u32` to match stb_truetype.h (see issue #3). + +## 0.1.1 +* Fix for glyf table format 12 and 13 handling to match implementation in stb_truetype.h (see issue #2). + +## 0.1 +* Initial release. diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/Cargo.toml b/third_party/cargo/vendor/stb_truetype-0.3.1/Cargo.toml new file mode 100644 index 0000000..f880a68 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/Cargo.toml @@ -0,0 +1,38 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "stb_truetype" +version = "0.3.1" +authors = ["Dylan Ede <dylanede@googlemail.com>", "Alex Butler <alexheretic@gmail.com>"] +exclude = ["/fonts/**"] +description = "A straight translation of the font loading code in stb_truetype.h from C to Rust." +documentation = "https://docs.rs/stb_truetype-rs" +readme = "README.md" +keywords = ["font", "truetype", "opentype", "ttf", "otf"] +license = "MIT / Apache-2.0" +repository = "https://gitlab.redox-os.org/redox-os/stb_truetype-rs" +[dependencies.byteorder] +version = "1.1" +default-features = false + +[dependencies.libm] +version = "0.2.1" +optional = true +[dev-dependencies.approx] +version = "0.3" +default-features = false + +[features] +default = ["std"] +std = [] diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/LICENSE-APACHE b/third_party/cargo/vendor/stb_truetype-0.3.1/LICENSE-APACHE new file mode 100644 index 0000000..23394dd --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2016 Dylan Ede + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/LICENSE-MIT b/third_party/cargo/vendor/stb_truetype-0.3.1/LICENSE-MIT new file mode 100644 index 0000000..93cbd53 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Dylan Ede + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/README.md b/third_party/cargo/vendor/stb_truetype-0.3.1/README.md new file mode 100644 index 0000000..0cf3af3 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/README.md @@ -0,0 +1,37 @@ +# stb_truetype-rs + +[![Crates.io](https://img.shields.io/crates/v/stb_truetype.svg)](https://crates.io/crates/stb_truetype) +[![docs.rs](https://docs.rs/stb_truetype/badge.svg)](https://docs.rs/stb_truetype/) + +This is a translation of the font loading code in +[stb_truetype.h](https://github.com/nothings/stb/blob/master/stb_truetype.h) +from C to Rust. It is intended as a stopgap dependency for libraries that deal +with fonts until something better, written in idiomatic Rust, is available. This +library is not an example of good Rust code, but it works. + +Please note that the documentation provided is also a straight copy from the +original code. + +Currently this port does not include the rasterisation or font querying API +provided by stb_truetype.h. If you are looking for font rasterisation, that is +provided by [RustType](https://gitlab.redox-os.org/redox-os/rusttype). + +## Minimum supported rust compiler +This crate is maintained with [latest stable rust](https://gist.github.com/alexheretic/d1e98d8433b602e57f5d0a9637927e0c). + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/benches/api.rs b/third_party/cargo/vendor/stb_truetype-0.3.1/benches/api.rs new file mode 100644 index 0000000..0af1dd7 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/benches/api.rs @@ -0,0 +1,505 @@ +#![feature(test)] +extern crate test; + +use approx::*; +use stb_truetype::*; + +/// index map format 12 +static DEJA_VU_MONO: &[u8] = include_bytes!("../fonts/DejaVuSansMono.ttf"); +static ROBOTO: &[u8] = include_bytes!("../fonts/Roboto-Regular.ttf"); +/// index map format 4 +static GUDEA: &[u8] = include_bytes!("../fonts/Gudea-Regular.ttf"); + +const ALPHABET_SIZE: usize = 62; +const ALPHABET: &[char; ALPHABET_SIZE] = &[ + 'A', 'a', 'B', 'b', 'C', 'c', 'D', 'd', 'E', 'e', 'F', 'f', 'G', 'g', 'H', 'h', 'I', 'i', 'J', + 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p', 'Q', 'q', 'R', 'r', 'S', 's', + 'T', 't', 'U', 'u', 'V', 'v', 'W', 'w', 'X', 'x', 'W', 'w', 'Z', 'z', '0', '1', '2', '3', '4', + '5', '6', '7', '8', '9', +]; + +#[bench] +fn find_glyph_index_deja_vu_mono(b: &mut test::Bencher) { + let font = FontInfo::new(&*DEJA_VU_MONO, 0).unwrap(); + + let mut indices = [0_u32; ALPHABET_SIZE]; + b.iter(|| { + for (i, c) in ALPHABET.iter().enumerate() { + indices[i] = font.find_glyph_index(*c as u32); + } + }); + + assert_eq!( + indices.to_vec(), + vec![ + 36, 68, 37, 69, 38, 70, 39, 71, 40, 72, 41, 73, 42, 74, 43, 75, 44, 76, 45, 77, 46, 78, + 47, 79, 48, 80, 49, 81, 50, 82, 51, 83, 52, 84, 53, 85, 54, 86, 55, 87, 56, 88, 57, 89, + 58, 90, 59, 91, 58, 90, 61, 93, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 + ] + ); +} + +#[bench] +fn find_glyph_index_gudea(b: &mut test::Bencher) { + let font = FontInfo::new(&*GUDEA, 0).unwrap(); + + let mut indices = [0_u32; ALPHABET_SIZE]; + b.iter(|| { + for (i, c) in ALPHABET.iter().enumerate() { + indices[i] = font.find_glyph_index(*c as u32); + } + }); + + assert_eq!( + indices.to_vec(), + vec![ + 37, 69, 38, 70, 39, 71, 40, 72, 41, 73, 42, 74, 43, 75, 44, 76, 45, 77, 46, 78, 47, 79, + 48, 80, 49, 81, 50, 82, 51, 83, 52, 84, 53, 85, 54, 86, 55, 87, 56, 88, 57, 89, 58, 90, + 59, 91, 60, 92, 59, 91, 62, 94, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 + ] + ); +} + +/// (x0, x1, y0, y1) +fn rect_to_tuple<T>(r: Rect<T>) -> (T, T, T, T) { + (r.x0, r.x1, r.y0, r.y1) +} + +#[bench] +fn get_glyph_box_deja_vu_mono(b: &mut test::Bencher) { + let font = FontInfo::new(&*DEJA_VU_MONO, 0).unwrap(); + + let indices: Vec<_> = ALPHABET + .iter() + .map(|c| font.find_glyph_index(*c as u32)) + .collect(); + + let mut boxes = [None; ALPHABET_SIZE]; + b.iter(|| { + for (i, glyph_index) in indices.iter().enumerate() { + boxes[i] = font.get_glyph_box(*glyph_index); + } + }); + + assert_eq!(rect_to_tuple(boxes[11].unwrap()), (195, 1063, 0, 1556)); + assert_eq!(rect_to_tuple(boxes[34].unwrap()), (143, 1233, 0, 1493)); + assert_eq!(rect_to_tuple(boxes[57].unwrap()), (143, 1069, -29, 1493)); +} + +#[bench] +fn get_glyph_box_gudea(b: &mut test::Bencher) { + let font = FontInfo::new(&*GUDEA, 0).unwrap(); + + let indices: Vec<_> = ALPHABET + .iter() + .map(|c| font.find_glyph_index(*c as u32)) + .collect(); + + let mut boxes = [None; ALPHABET_SIZE]; + b.iter(|| { + for (i, glyph_index) in indices.iter().enumerate() { + boxes[i] = font.get_glyph_box(*glyph_index); + } + }); + + assert_eq!(rect_to_tuple(boxes[11].unwrap()), (35, 316, 0, 710)); + assert_eq!(rect_to_tuple(boxes[34].unwrap()), (91, 571, 1, 701)); + assert_eq!(rect_to_tuple(boxes[57].unwrap()), (63, 504, -6, 700)); +} + +#[bench] +fn get_glyph_bitmap_box_subpixel_deja_vu_mono(b: &mut test::Bencher) { + let font = FontInfo::new(&*DEJA_VU_MONO, 0).unwrap(); + + let indices: Vec<_> = ALPHABET + .iter() + .map(|c| font.find_glyph_index(*c as u32)) + .collect(); + + let (s_x, s_y) = (12.0, 14.5); + let scale_y = font.scale_for_pixel_height(s_y); + let scale_x = scale_y * s_x / s_y; + + let mut boxes = [None; ALPHABET_SIZE]; + b.iter(|| { + for (i, glyph_index) in indices.iter().enumerate() { + boxes[i] = + font.get_glyph_bitmap_box_subpixel(*glyph_index, scale_x, scale_y, 656.0, 1034.0); + } + }); + + assert_eq!(rect_to_tuple(boxes[11].unwrap()), (656, 662, 1024, 1034)); + assert_eq!(rect_to_tuple(boxes[34].unwrap()), (656, 663, 1024, 1034)); + assert_eq!(rect_to_tuple(boxes[57].unwrap()), (656, 662, 1024, 1035)); +} + +#[bench] +fn get_glyph_bitmap_box_subpixel_gudea(b: &mut test::Bencher) { + let font = FontInfo::new(&*GUDEA, 0).unwrap(); + + let indices: Vec<_> = ALPHABET + .iter() + .map(|c| font.find_glyph_index(*c as u32)) + .collect(); + + let (s_x, s_y) = (12.0, 14.5); + let scale_y = font.scale_for_pixel_height(s_y); + let scale_x = scale_y * s_x / s_y; + + let mut boxes = [None; ALPHABET_SIZE]; + b.iter(|| { + for (i, glyph_index) in indices.iter().enumerate() { + boxes[i] = + font.get_glyph_bitmap_box_subpixel(*glyph_index, scale_x, scale_y, 656.0, 1034.0); + } + }); + + assert_eq!(rect_to_tuple(boxes[11].unwrap()), (656, 660, 1025, 1034)); + assert_eq!(rect_to_tuple(boxes[34].unwrap()), (656, 662, 1025, 1034)); + assert_eq!(rect_to_tuple(boxes[57].unwrap()), (656, 661, 1025, 1035)); +} + +/// (x, y, cx, cy, type) +fn vertex_to_tuple(vert: Vertex) -> (i16, i16, i16, i16, u8) { + (vert.x, vert.y, vert.cx, vert.cy, vert.vertex_type() as u8) +} + +#[bench] +fn get_glyph_shape_deja_vu_mono(b: &mut test::Bencher) { + let font = FontInfo::new(&*DEJA_VU_MONO, 0).unwrap(); + + let indices: Vec<_> = ALPHABET + .iter() + .map(|c| font.find_glyph_index(*c as u32)) + .collect(); + + let mut shapes = vec![None; ALPHABET_SIZE]; + b.iter(|| { + for (i, glyph_index) in indices.iter().enumerate() { + shapes[i] = font.get_glyph_shape(*glyph_index); + } + }); + + let shapes_11: Vec<_> = shapes[11] + .as_ref() + .unwrap() + .iter() + .map(|v| vertex_to_tuple(*v)) + .collect(); + assert_eq!( + shapes_11, + vec![ + (1063, 1556, 0, 0, 1), + (1063, 1403, 0, 0, 2), + (854, 1403, 0, 0, 2), + (716, 1362, 755, 1403, 3), + (678, 1219, 678, 1322, 3), + (678, 1120, 0, 0, 2), + (1063, 1120, 0, 0, 2), + (1063, 977, 0, 0, 2), + (678, 977, 0, 0, 2), + (678, 0, 0, 0, 2), + (494, 0, 0, 0, 2), + (494, 977, 0, 0, 2), + (195, 977, 0, 0, 2), + (195, 1120, 0, 0, 2), + (494, 1120, 0, 0, 2), + (494, 1198, 0, 0, 2), + (578, 1469, 494, 1382, 3), + (842, 1556, 663, 1556, 3), + (1063, 1556, 0, 0, 2) + ] + ); + + let shapes_47: Vec<_> = shapes[47] + .as_ref() + .unwrap() + .iter() + .map(|v| vertex_to_tuple(*v)) + .collect(); + assert_eq!( + shapes_47, + vec![ + (1118, 1120, 0, 0, 1), + (717, 584, 0, 0, 2), + (1157, 0, 0, 0, 2), + (944, 0, 0, 0, 2), + (616, 449, 0, 0, 2), + (289, 0, 0, 0, 2), + (76, 0, 0, 0, 2), + (516, 584, 0, 0, 2), + (115, 1120, 0, 0, 2), + (319, 1120, 0, 0, 2), + (616, 715, 0, 0, 2), + (911, 1120, 0, 0, 2), + (1118, 1120, 0, 0, 2) + ] + ); +} + +#[bench] +fn get_glyph_shape_gudea(b: &mut test::Bencher) { + let font = FontInfo::new(&*GUDEA, 0).unwrap(); + + let indices: Vec<_> = ALPHABET + .iter() + .map(|c| font.find_glyph_index(*c as u32)) + .collect(); + + let mut shapes = vec![None; ALPHABET_SIZE]; + b.iter(|| { + for (i, glyph_index) in indices.iter().enumerate() { + shapes[i] = font.get_glyph_shape(*glyph_index); + } + }); + + let shapes_11: Vec<_> = shapes[11] + .as_ref() + .unwrap() + .iter() + .map(|v| vertex_to_tuple(*v)) + .collect(); + assert_eq!( + shapes_11, + vec![ + (113, 500, 0, 0, 1), + (113, 596, 0, 0, 2), + (150, 683, 113, 657, 3), + (231, 710, 188, 710, 3), + (316, 697, 275, 710, 3), + (305, 643, 0, 0, 2), + (256, 649, 272, 649, 3), + (187, 582, 187, 649, 3), + (187, 500, 0, 0, 2), + (289, 500, 0, 0, 2), + (289, 440, 0, 0, 2), + (187, 440, 0, 0, 2), + (187, 0, 0, 0, 2), + (112, 0, 0, 0, 2), + (112, 440, 0, 0, 2), + (35, 440, 0, 0, 2), + (35, 500, 0, 0, 2), + (113, 500, 0, 0, 2) + ] + ); + + let shapes_47: Vec<_> = shapes[47] + .as_ref() + .unwrap() + .iter() + .map(|v| vertex_to_tuple(*v)) + .collect(); + assert_eq!( + shapes_47, + vec![ + (113, 501, 0, 0, 1), + (218, 324, 0, 0, 2), + (323, 501, 0, 0, 2), + (406, 501, 0, 0, 2), + (259, 255, 0, 0, 2), + (412, 0, 0, 0, 2), + (329, 0, 0, 0, 2), + (218, 198, 0, 0, 2), + (107, 0, 0, 0, 2), + (24, 0, 0, 0, 2), + (177, 255, 0, 0, 2), + (30, 501, 0, 0, 2), + (113, 501, 0, 0, 2) + ] + ); +} + +#[bench] +fn get_glyph_shape_compound_glyph_roboto_colon(b: &mut test::Bencher) { + let font = FontInfo::new(&*ROBOTO, 0).unwrap(); + + let colon_index = font.find_glyph_index(':' as u32); + + let mut shape = None; + b.iter(|| { + shape = font.get_glyph_shape(colon_index); + }); + + let shape: Vec<_> = shape.unwrap().iter().map(|v| vertex_to_tuple(*v)).collect(); + + assert_eq!( + shape, + vec![ + (134, 97, -10, 0, 1), + (162, 177, 134, 145, 3), + (248, 209, 191, 209, 3), + (334, 177, 305, 209, 3), + (364, 97, 364, 145, 3), + (334, 20, 364, 51, 3), + (248, -11, 305, -11, 3), + (162, 20, 191, -11, 3), + (134, 97, 134, 51, 3), + (135, 980, -9, 883, 1), + (163, 1060, 135, 1028, 3), + (249, 1092, 192, 1092, 3), + (335, 1060, 306, 1092, 3), + (365, 980, 365, 1028, 3), + (335, 903, 365, 934, 3), + (249, 872, 306, 872, 3), + (163, 903, 192, 872, 3), + (135, 980, 135, 934, 3) + ] + ); +} + +/// (advance_width, left_side_bearing) +fn h_metrics_to_tuple(h: HMetrics) -> (i32, i32) { + (h.advance_width, h.left_side_bearing) +} + +#[bench] +fn get_glyph_h_metrics_deja_vu_mono(b: &mut test::Bencher) { + let font = FontInfo::new(&*DEJA_VU_MONO, 0).unwrap(); + + let indices: Vec<_> = ALPHABET + .iter() + .map(|c| font.find_glyph_index(*c as u32)) + .collect(); + + let mut h_metrics = [HMetrics { + advance_width: 0, + left_side_bearing: 0, + }; ALPHABET_SIZE]; + b.iter(|| { + for (i, glyph_index) in indices.iter().enumerate() { + h_metrics[i] = font.get_glyph_h_metrics(*glyph_index); + } + }); + + assert_eq!(h_metrics_to_tuple(h_metrics[11]), (1233, 195)); + assert_eq!(h_metrics_to_tuple(h_metrics[25]), (1233, 109)); + assert_eq!(h_metrics_to_tuple(h_metrics[49]), (1233, 0)); +} + +#[bench] +fn get_glyph_h_metrics_gudea(b: &mut test::Bencher) { + let font = FontInfo::new(&*GUDEA, 0).unwrap(); + + let indices: Vec<_> = ALPHABET + .iter() + .map(|c| font.find_glyph_index(*c as u32)) + .collect(); + + let mut h_metrics = [HMetrics { + advance_width: 0, + left_side_bearing: 0, + }; ALPHABET_SIZE]; + b.iter(|| { + for (i, glyph_index) in indices.iter().enumerate() { + h_metrics[i] = font.get_glyph_h_metrics(*glyph_index); + } + }); + + assert_eq!(h_metrics_to_tuple(h_metrics[11]), (291, 35)); + assert_eq!(h_metrics_to_tuple(h_metrics[25]), (850, 91)); + assert_eq!(h_metrics_to_tuple(h_metrics[49]), (679, 11)); +} + +#[bench] +fn scale_for_pixel_height_deja_vu_mono(b: &mut test::Bencher) { + let font = FontInfo::new(&*DEJA_VU_MONO, 0).unwrap(); + + let pixel_heights: [f32; 8] = [1.0, 12.0, 14.5, 25.5, 50.0, 112.2, 500.5, 657.5]; + + let mut scales = [0.0; 8]; + b.iter(|| { + // repeat so its a similar number of calls to the other benchmarks + for _ in 0..test::black_box(8) { + for (i, pixel_height) in pixel_heights.iter().enumerate() { + scales[i] = font.scale_for_pixel_height(*pixel_height); + } + } + }); + + assert_relative_eq!(scales[0], 0.000_419_463_1); + assert_relative_eq!(scales[1], 0.005_033_557); + assert_relative_eq!(scales[2], 0.006_082_215); + assert_relative_eq!(scales[3], 0.010_696_309); + assert_relative_eq!(scales[4], 0.020_973_155); + assert_relative_eq!(scales[5], 0.047_063_757); + assert_relative_eq!(scales[6], 0.209_941_27); + assert_relative_eq!(scales[7], 0.275_796_98); +} + +#[bench] +fn scale_for_pixel_height_gudea(b: &mut test::Bencher) { + let font = FontInfo::new(&*GUDEA, 0).unwrap(); + + let pixel_heights: [f32; 8] = [1.0, 12.0, 14.5, 25.5, 50.0, 112.2, 500.5, 657.5]; + + let mut scales = [0.0; 8]; + b.iter(|| { + // repeat so its a similar number of calls to the other benchmarks + for _ in 0..test::black_box(8) { + for (i, pixel_height) in pixel_heights.iter().enumerate() { + scales[i] = font.scale_for_pixel_height(*pixel_height); + } + } + }); + + assert_relative_eq!(scales[0], 0.000_809_061_5); + assert_relative_eq!(scales[1], 0.009_708_738); + assert_relative_eq!(scales[2], 0.011_731_392); + assert_relative_eq!(scales[3], 0.020_631_067); + assert_relative_eq!(scales[4], 0.040_453_073); + assert_relative_eq!(scales[5], 0.090_776_7); + assert_relative_eq!(scales[6], 0.404_935_27); + assert_relative_eq!(scales[7], 0.531_957_9); +} + +#[bench] +fn get_v_metrics_deja_vu_mono(b: &mut test::Bencher) { + let font = FontInfo::new(&*DEJA_VU_MONO, 0).unwrap(); + + let mut v_metrics = VMetrics { + ascent: 1, + descent: 2, + line_gap: 3, + }; + b.iter(|| { + // repeat so its a similar number of calls to the other benchmarks + for _ in 0..test::black_box(ALPHABET_SIZE) { + v_metrics = font.get_v_metrics(); + } + }); + + let VMetrics { + ascent, + descent, + line_gap, + } = v_metrics; + assert_eq!(ascent, 1901); + assert_eq!(descent, -483); + assert_eq!(line_gap, 0); +} + +#[bench] +fn get_v_metrics_gudea(b: &mut test::Bencher) { + let font = FontInfo::new(&*GUDEA, 0).unwrap(); + + let mut v_metrics = VMetrics { + ascent: 1, + descent: 2, + line_gap: 3, + }; + b.iter(|| { + // repeat so its a similar number of calls to the other benchmarks + for _ in 0..test::black_box(ALPHABET_SIZE) { + v_metrics = font.get_v_metrics(); + } + }); + + let VMetrics { + ascent, + descent, + line_gap, + } = v_metrics; + assert_eq!(ascent, 972); + assert_eq!(descent, -264); + assert_eq!(line_gap, 0); +} diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/examples/fontnames.rs b/third_party/cargo/vendor/stb_truetype-0.3.1/examples/fontnames.rs new file mode 100644 index 0000000..89049f3 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/examples/fontnames.rs @@ -0,0 +1,50 @@ +#![allow(unknown_lints)] + +use stb_truetype::FontInfo; +use std::borrow::Cow; + +#[allow(clippy::cast_ptr_alignment)] // FIXME seems a bit dodgy +fn main() { + let file = &include_bytes!("../fonts/Gudea-Regular.ttf")[..]; + let font = FontInfo::new(Cow::Borrowed(file), 0).unwrap(); + + for info in font.get_font_name_strings() { + let (name, pl_en_la, na) = info; + let name = (match pl_en_la { + Some(stb_truetype::PlatformEncodingLanguageId::Mac( + Some(Ok(stb_truetype::MacEid::Roman)), + _, + )) => ::std::str::from_utf8(name).ok().map(Cow::Borrowed), + Some(stb_truetype::PlatformEncodingLanguageId::Microsoft( + Some(Ok(stb_truetype::MicrosoftEid::UnicodeBMP)), + _, + )) => { + let name16be = unsafe { + ::std::slice::from_raw_parts(name.as_ptr() as *const u16, name.len() / 2) + }; + let name16 = name16be + .iter() + .map(|&v| u16::from_be(v)) + .collect::<Vec<_>>(); + String::from_utf16(&name16).ok().map(Cow::Owned) + } + Some(stb_truetype::PlatformEncodingLanguageId::Microsoft( + Some(Ok(stb_truetype::MicrosoftEid::UnicodeFull)), + _, + )) => { + let name16be = unsafe { + ::std::slice::from_raw_parts(name.as_ptr() as *const u16, name.len() / 2) + }; + let name16 = name16be + .iter() + .map(|&v| u16::from_be(v)) + .collect::<Vec<_>>(); + String::from_utf16(&name16).ok().map(Cow::Owned) + } + Some(_) => Some(Cow::Borrowed("(Unknown encoding)")), + None => Some(Cow::Borrowed("(Unknown Platform ID)")), + }) + .unwrap_or(Cow::Borrowed("(Encoding error)")); + println!("{:?}, {:?}, {:?}", name, pl_en_la, na); + } +} diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/examples/simple.rs b/third_party/cargo/vendor/stb_truetype-0.3.1/examples/simple.rs new file mode 100644 index 0000000..b5059d2 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/examples/simple.rs @@ -0,0 +1,23 @@ +use stb_truetype::FontInfo; +use std::borrow::Cow; + +fn main() { + let file = include_bytes!("../fonts/Gudea-Regular.ttf") as &[u8]; + let font = FontInfo::new(Cow::Borrowed(file), 0).unwrap(); + let vmetrics = font.get_v_metrics(); + println!("{:?}", vmetrics); + let c = '\\'; + let cp = c as u32; + let g = font.find_glyph_index(cp); + println!("{:?} -> {:?}", cp, g); + let r = font.get_glyph_box(g); + println!("{:?}", r); + let shape = font.get_glyph_shape(g); + println!("{:#?}", shape); + let hmetrics = font.get_glyph_h_metrics(g); + println!("{:?}", hmetrics); + let advance = font.get_codepoint_kern_advance('f' as u32, 'f' as u32); + println!("{:?}", advance); + let scale = font.scale_for_pixel_height(20.0); + println!("{:?}", scale); +} diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/rustfmt.toml b/third_party/cargo/vendor/stb_truetype-0.3.1/rustfmt.toml new file mode 100644 index 0000000..e2447e3 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/rustfmt.toml @@ -0,0 +1,5 @@ +# rustfmt 0.3.x-nightly +wrap_comments = true +error_on_line_overflow = false +use_field_init_shorthand = true +condense_wildcard_suffixes = true diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/src/lib.rs b/third_party/cargo/vendor/stb_truetype-0.3.1/src/lib.rs new file mode 100644 index 0000000..58a529d --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/src/lib.rs @@ -0,0 +1,1313 @@ +#![warn(clippy::all)] +#![allow( + clippy::too_many_arguments, + clippy::cast_lossless, + clippy::many_single_char_names +)] +#![cfg_attr(not(feature = "std"), no_std)] + +extern crate alloc; + +use alloc::vec::Vec; +use byteorder::{BigEndian as BE, ByteOrder}; +use core::ops::Deref; + +#[cfg(not(any(feature = "libm", feature = "std")))] +compile_error!("You need to activate either the `std` or `libm` feature."); + +#[cfg(all(feature = "libm", not(feature = "std")))] +trait FloatExt { + fn floor(self) -> Self; + fn ceil(self) -> Self; + fn sqrt(self) -> Self; +} +#[cfg(all(feature = "libm", not(feature = "std")))] +impl FloatExt for f32 { + #[inline] + fn floor(self) -> Self { + libm::floorf(self) + } + #[inline] + fn ceil(self) -> Self { + libm::ceilf(self) + } + #[inline] + fn sqrt(self) -> Self { + libm::sqrtf(self) + } +} + +#[derive(Copy, Clone, Debug)] +pub struct FontInfo<Data: Deref<Target = [u8]>> { + data: Data, // pointer to .ttf file + // fontstart: usize, // offset of start of font + num_glyphs: u32, // number of glyphs, needed for range checking + loca: u32, + head: u32, + glyf: u32, + hhea: u32, + hmtx: u32, + name: u32, + kern: u32, // table locations as offset from start of .ttf + index_map: u32, // a cmap mapping for our chosen character encoding + index_to_loc_format: u32, // format needed to map from glyph index to glyph +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +#[repr(C)] +pub struct Vertex { + pub x: i16, + pub y: i16, + pub cx: i16, + pub cy: i16, + type_: u8, +} + +impl Vertex { + pub fn vertex_type(&self) -> VertexType { + match self.type_ { + 1 => VertexType::MoveTo, + 2 => VertexType::LineTo, + 3 => VertexType::CurveTo, + type_ => panic!("Invalid vertex type: {}", type_), + } + } +} + +#[test] +fn test_vertex_type() { + fn v(type_: VertexType) -> Vertex { + Vertex { + x: 0, + y: 0, + cx: 0, + cy: 0, + type_: type_ as u8, + } + } + assert_eq!(v(VertexType::MoveTo).vertex_type(), VertexType::MoveTo); + assert_eq!(v(VertexType::LineTo).vertex_type(), VertexType::LineTo); + assert_eq!(v(VertexType::CurveTo).vertex_type(), VertexType::CurveTo); +} + +#[test] +#[should_panic] +fn test_invalid_vertex_type() { + let v = Vertex { + x: 0, + y: 0, + cx: 0, + cy: 0, + type_: 255, + }; + let s = match v.vertex_type() { + VertexType::MoveTo => "move to", + VertexType::LineTo => "line to", + VertexType::CurveTo => "curve to", + }; + // With `Vertex::vertex_type` defined as `transmute` this would be undefined + // behavior: + println!("{}", s); +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +#[repr(u8)] +pub enum VertexType { + MoveTo = 1, + LineTo = 2, + CurveTo = 3, +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +pub struct Rect<T> { + pub x0: T, + pub y0: T, + pub x1: T, + pub y1: T, +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +pub struct HMetrics { + pub advance_width: i32, + pub left_side_bearing: i32, +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +pub struct VMetrics { + pub ascent: i32, + pub descent: i32, + pub line_gap: i32, +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[repr(C)] +pub enum PlatformId { + // platformID + Unicode = 0, + Mac = 1, + Iso = 2, + Microsoft = 3, +} +fn platform_id(v: u16) -> Option<PlatformId> { + use crate::PlatformId::*; + match v { + 0 => Some(Unicode), + 1 => Some(Mac), + 2 => Some(Iso), + 3 => Some(Microsoft), + _ => None, + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[repr(C)] +#[allow(non_camel_case_types)] +pub enum UnicodeEid { + // encodingID for PLATFORM_ID_UNICODE + Unicode_1_0 = 0, + Unicode_1_1 = 1, + Iso_10646 = 2, + Unicode_2_0_Bmp = 3, + Unicode_2_0_Full = 4, +} +fn unicode_eid(v: u16) -> Option<UnicodeEid> { + use crate::UnicodeEid::*; + match v { + 0 => Some(Unicode_1_0), + 1 => Some(Unicode_1_1), + 2 => Some(Iso_10646), + 3 => Some(Unicode_2_0_Bmp), + 4 => Some(Unicode_2_0_Full), + _ => None, + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[repr(C)] +pub enum MicrosoftEid { + // encodingID for PLATFORM_ID_MICROSOFT + Symbol = 0, + UnicodeBMP = 1, + Shiftjis = 2, + UnicodeFull = 10, +} +fn microsoft_eid(v: u16) -> Option<MicrosoftEid> { + use crate::MicrosoftEid::*; + match v { + 0 => Some(Symbol), + 1 => Some(UnicodeBMP), + 2 => Some(Shiftjis), + 10 => Some(UnicodeFull), + _ => None, + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[repr(C)] +pub enum MacEid { + // encodingID for PLATFORM_ID_MAC; same as Script Manager codes + Roman = 0, + Arabic = 4, + Japanese = 1, + Hebrew = 5, + ChineseTrad = 2, + Greek = 6, + Korean = 3, + Russian = 7, +} +fn mac_eid(v: u16) -> Option<MacEid> { + use crate::MacEid::*; + match v { + 0 => Some(Roman), + 1 => Some(Japanese), + 2 => Some(ChineseTrad), + 3 => Some(Korean), + 4 => Some(Arabic), + 5 => Some(Hebrew), + 6 => Some(Greek), + 7 => Some(Russian), + _ => None, + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[repr(C)] +pub enum MicrosoftLang { + // languageID for PLATFORM_ID_MICROSOFT; same as LCID... + // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs + English = 0x0409, + Italian = 0x0410, + Chinese = 0x0804, + Japanese = 0x0411, + Dutch = 0x0413, + Korean = 0x0412, + French = 0x040c, + Russian = 0x0419, + German = 0x0407, + // Spanish = 0x0409, + Hebrew = 0x040d, + Swedish = 0x041D, +} +fn microsoft_lang(v: u16) -> Option<MicrosoftLang> { + use crate::MicrosoftLang::*; + match v { + 0x0409 => Some(English), + 0x0804 => Some(Chinese), + 0x0413 => Some(Dutch), + 0x040c => Some(French), + 0x0407 => Some(German), + 0x040d => Some(Hebrew), + 0x0410 => Some(Italian), + 0x0411 => Some(Japanese), + 0x0412 => Some(Korean), + 0x0419 => Some(Russian), + 0x041D => Some(Swedish), + _ => None, + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[repr(C)] +pub enum MacLang { + // languageID for PLATFORM_ID_MAC + English = 0, + Japanese = 11, + Arabic = 12, + Korean = 23, + Dutch = 4, + Russian = 32, + French = 1, + Spanish = 6, + German = 2, + Swedish = 5, + Hebrew = 10, + ChineseSimplified = 33, + Italian = 3, + ChineseTrad = 19, +} +fn mac_lang(v: u16) -> Option<MacLang> { + use crate::MacLang::*; + match v { + 0 => Some(English), + 12 => Some(Arabic), + 4 => Some(Dutch), + 1 => Some(French), + 2 => Some(German), + 10 => Some(Hebrew), + 3 => Some(Italian), + 11 => Some(Japanese), + 23 => Some(Korean), + 32 => Some(Russian), + 6 => Some(Spanish), + 5 => Some(Swedish), + 33 => Some(ChineseSimplified), + 19 => Some(ChineseTrad), + _ => None, + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum PlatformEncodingLanguageId { + Unicode(Option<Result<UnicodeEid, u16>>, Option<u16>), + Mac(Option<Result<MacEid, u16>>, Option<Result<MacLang, u16>>), + Iso(Option<u16>, Option<u16>), + Microsoft( + Option<Result<MicrosoftEid, u16>>, + Option<Result<MicrosoftLang, u16>>, + ), +} +fn platform_encoding_id( + platform_id: PlatformId, + encoding_id: Option<u16>, + language_id: Option<u16>, +) -> PlatformEncodingLanguageId { + match platform_id { + PlatformId::Unicode => PlatformEncodingLanguageId::Unicode( + encoding_id.map(|id| unicode_eid(id).ok_or(id)), + language_id, + ), + PlatformId::Mac => PlatformEncodingLanguageId::Mac( + encoding_id.map(|id| mac_eid(id).ok_or(id)), + language_id.map(|id| mac_lang(id).ok_or(id)), + ), + PlatformId::Iso => PlatformEncodingLanguageId::Iso(encoding_id, language_id), + PlatformId::Microsoft => PlatformEncodingLanguageId::Microsoft( + encoding_id.map(|id| microsoft_eid(id).ok_or(id)), + language_id.map(|id| microsoft_lang(id).ok_or(id)), + ), + } +} + +// # accessors to parse data from file + +// on platforms that don't allow misaligned reads, if we want to allow +// truetype fonts that aren't padded to alignment, define +// ALLOW_UNALIGNED_TRUETYPE + +/// Return `true` if `data` holds a font stored in a format this crate +/// recognizes, according to its signature in the initial bytes. +pub fn is_font(data: &[u8]) -> bool { + if data.len() >= 4 { + let tag = &data[0..4]; + tag == [b'1', 0, 0, 0] || tag == b"typ1" || tag == b"OTTO" || tag == [0, 1, 0, 0] + } else { + false + } +} + +/// Return `true` if `data` holds a TrueType Collection, according to its +/// signature in the initial bytes. A TrueType Collection stores several fonts +/// in a single file, allowing them to share data for glyphs they have in +/// common. +pub fn is_collection(data: &[u8]) -> bool { + data.len() >= 4 && &data[0..4] == b"ttcf" +} + +fn find_table(data: &[u8], fontstart: usize, tag: &[u8]) -> u32 { + let num_tables = BE::read_u16(&data[fontstart + 4..]); + let tabledir = fontstart + 12; + for i in 0..num_tables { + let loc = tabledir + 16 * (i as usize); + if &data[loc..loc + 4] == tag { + return BE::read_u32(&data[loc + 8..]); + } + } + 0 +} + +/// Each .ttf/.ttc file may have more than one font. Each font has a sequential +/// index number starting from 0. Call this function to get the font offset for +/// a given index; it returns None if the index is out of range. A regular .ttf +/// file will only define one font and it always be at offset 0, so it will +/// return Some(0) for index 0, and None for all other indices. You can just +/// skip this step if you know it's that kind of font. +pub fn get_font_offset_for_index(font_collection: &[u8], index: i32) -> Option<u32> { + // if it's just a font, there's only one valid index + if is_font(font_collection) { + return if index == 0 { Some(0) } else { None }; + } + // check if it's a TTC + if is_collection(font_collection) + && (BE::read_u32(&font_collection[4..]) == 0x0001_0000 + || BE::read_u32(&font_collection[4..]) == 0x0002_0000) + { + let n = BE::read_i32(&font_collection[8..]); + if index >= n { + return None; + } + return Some(BE::read_u32(&font_collection[12 + (index as usize) * 4..])); + } + None +} + +macro_rules! read_ints { + ($n:expr, i16, $data:expr) => {{ + let mut nums = [0; $n]; + let data = $data; + BE::read_i16_into(&data[..$n * 2], &mut nums); + nums + }}; + ($n:expr, u16, $data:expr) => {{ + let mut nums = [0; $n]; + let data = $data; + BE::read_u16_into(&data[..$n * 2], &mut nums); + nums + }}; + ($n:expr, u32, $data:expr) => {{ + let mut nums = [0; $n]; + let data = $data; + BE::read_u32_into(&data[..$n * 4], &mut nums); + nums + }}; +} + +impl<Data: Deref<Target = [u8]>> FontInfo<Data> { + /// Given an offset into the file that defines a font, this function builds + /// the necessary cached info for the rest of the system. + pub fn new(data: Data, fontstart: usize) -> Option<FontInfo<Data>> { + let cmap = find_table(&data, fontstart, b"cmap"); // required + let loca = find_table(&data, fontstart, b"loca"); // required + let head = find_table(&data, fontstart, b"head"); // required + let glyf = find_table(&data, fontstart, b"glyf"); // required + let hhea = find_table(&data, fontstart, b"hhea"); // required + let hmtx = find_table(&data, fontstart, b"hmtx"); // required + let name = find_table(&data, fontstart, b"name"); // not required + let kern = find_table(&data, fontstart, b"kern"); // not required + if cmap == 0 || loca == 0 || head == 0 || glyf == 0 || hhea == 0 || hmtx == 0 { + return None; + } + let t = find_table(&data, fontstart, b"maxp"); + let num_glyphs = if t != 0 { + BE::read_u16(&data[t as usize + 4..]) + } else { + 0xffff + }; + + // find a cmap encoding table we understand *now* to avoid searching + // later. (todo: could make this installable) + // the same regardless of glyph. + let num_tables = BE::read_u16(&data[cmap as usize + 2..]); + let mut index_map = 0; + for i in 0..num_tables { + let encoding_record = (cmap + 4 + 8 * (i as u32)) as usize; + // find an encoding we understand: + match platform_id(BE::read_u16(&data[encoding_record..])) { + Some(PlatformId::Microsoft) => { + match microsoft_eid(BE::read_u16(&data[encoding_record + 2..])) { + Some(MicrosoftEid::UnicodeBMP) | Some(MicrosoftEid::UnicodeFull) => { + // MS/Unicode + index_map = cmap + BE::read_u32(&data[encoding_record + 4..]); + } + _ => (), + } + } + Some(PlatformId::Unicode) => { + // Mac/iOS has these + // all the encodingIDs are unicode, so we don't bother to check it + index_map = cmap + BE::read_u32(&data[encoding_record + 4..]); + } + _ => (), + } + } + if index_map == 0 { + return None; + } + let index_to_loc_format = BE::read_u16(&data[head as usize + 50..]) as u32; + Some(FontInfo { + // fontstart: fontstart, + data, + loca, + head, + glyf, + hhea, + hmtx, + name, + kern, + num_glyphs: num_glyphs as u32, + index_map, + index_to_loc_format, + }) + } + + pub fn get_num_glyphs(&self) -> u32 { + self.num_glyphs + } + + /// If you're going to perform multiple operations on the same character + /// and you want a speed-up, call this function with the character you're + /// going to process, then use glyph-based functions instead of the + /// codepoint-based functions. + pub fn find_glyph_index(&self, unicode_codepoint: u32) -> u32 { + let data = &self.data; + let index_map = &data[self.index_map as usize..]; //self.index_map as usize; + + let format = BE::read_u16(index_map); + match format { + 0 => { + // apple byte encoding + let bytes = BE::read_u16(&index_map[2..]); + if unicode_codepoint < bytes as u32 - 6 { + return index_map[6 + unicode_codepoint as usize] as u32; + } + 0 + } + 6 => { + let first = BE::read_u16(&index_map[6..]) as u32; + let count = BE::read_u16(&index_map[8..]) as u32; + if unicode_codepoint >= first && unicode_codepoint < first + count { + return BE::read_u16(&index_map[10 + (unicode_codepoint - first) as usize * 2..]) + as u32; + } + 0 + } + 2 => { + // @TODO: high-byte mapping for japanese/chinese/korean + panic!("Index map format unsupported: 2"); + } + 4 => { + // standard mapping for windows fonts: binary search collection of ranges + let segcount = BE::read_u16(&index_map[6..]) as usize >> 1; + let mut search_range = BE::read_u16(&index_map[8..]) as usize >> 1; + let mut entry_selector = BE::read_u16(&index_map[10..]); + let range_shift = BE::read_u16(&index_map[12..]) as usize >> 1; + + // do a binary search of the segments + let end_count = self.index_map as usize + 14; + let mut search = end_count; + + if unicode_codepoint > 0xffff { + return 0; + } + + // they lie from endCount .. endCount + segCount + // but searchRange is the nearest power of two, so... + if unicode_codepoint >= BE::read_u16(&data[search + range_shift * 2..]) as u32 { + search += range_shift * 2; + } + + // now decrement to bias correctly to find smallest + search -= 2; + while entry_selector != 0 { + search_range >>= 1; + let end = BE::read_u16(&data[search + search_range * 2..]) as u32; + if unicode_codepoint > end { + search += search_range * 2; + } + entry_selector -= 1; + } + search += 2; + + { + let item = (search - end_count) >> 1; + assert!( + unicode_codepoint <= BE::read_u16(&data[end_count + 2 * item..]) as u32 + ); + let start = BE::read_u16(&index_map[14 + segcount * 2 + 2 + 2 * item..]) as u32; + if unicode_codepoint < start { + return 0; + } + let offset = + BE::read_u16(&index_map[14 + segcount * 6 + 2 + 2 * item..]) as usize; + if offset == 0 { + return (unicode_codepoint as i32 + + BE::read_i16(&index_map[14 + segcount * 4 + 2 + 2 * item..]) as i32) + as u16 as u32; + } + BE::read_u16( + &index_map[offset + + (unicode_codepoint - start) as usize * 2 + + 14 + + segcount * 6 + + 2 + + 2 * item..], + ) as u32 + } + } + 12 | 13 => { + let mut low = 0u32; + let mut high = BE::read_u32(&index_map[12..]); + let groups = &index_map[16..]; + + // Binary search of the right group + while low < high { + let mid = (low + high) / 2; // rounds down, so low <= mid < high + let mid12 = (mid * 12) as usize; + let group = &groups[mid12..mid12 + 12]; + let start_char = BE::read_u32(group); + if unicode_codepoint < start_char { + high = mid; + } else if unicode_codepoint > BE::read_u32(&group[4..]) { + low = mid + 1; + } else { + let start_glyph = BE::read_u32(&group[8..]); + if format == 12 { + return start_glyph + unicode_codepoint - start_char; + } else { + return start_glyph; + } + } + } + + 0 + } + n => panic!("Index map format unsupported: {}", n), + } + } + + /// Returns the series of vertices encoding the shape of the glyph for this + /// codepoint. + /// + /// The shape is a series of countours. Each one starts with + /// a moveto, then consists of a series of mixed + /// lineto and curveto segments. A lineto + /// draws a line from previous endpoint to its x,y; a curveto + /// draws a quadratic bezier from previous endpoint to + /// its x,y, using cx,cy as the bezier control point. + pub fn get_codepoint_shape(&self, unicode_codepoint: u32) -> Option<Vec<Vertex>> { + self.get_glyph_shape(self.find_glyph_index(unicode_codepoint)) + } + + fn get_glyf_offset(&self, glyph_index: u32) -> Option<u32> { + if glyph_index >= self.num_glyphs || self.index_to_loc_format >= 2 { + // glyph index out of range or unknown index->glyph map format + return None; + } + + let [g1, g2] = if self.index_to_loc_format == 0 { + let d = &self.data[(self.loca + glyph_index * 2) as usize..]; + let [g1, g2] = read_ints!(2, u16, d); + [g1 as u32 * 2, g2 as u32 * 2] + } else { + read_ints!(2, u32, &self.data[(self.loca + glyph_index * 4) as usize..]) + }; + if g1 == g2 { + None + } else { + Some(self.glyf + g1) + } + } + + /// Like `get_codepoint_box`, but takes a glyph index. Use this if you have + /// cached the glyph index for a codepoint. + pub fn get_glyph_box(&self, glyph_index: u32) -> Option<Rect<i16>> { + let g = self.get_glyf_offset(glyph_index)? as usize; + let [x0, y0, x1, y1] = read_ints!(4, i16, &self.data[g + 2..]); + Some(Rect { x0, y0, x1, y1 }) + } + + /// Gets the bounding box of the visible part of the glyph, in unscaled + /// coordinates + pub fn get_codepoint_box(&self, codepoint: u32) -> Option<Rect<i16>> { + self.get_glyph_box(self.find_glyph_index(codepoint)) + } + + /// returns true if nothing is drawn for this glyph + pub fn is_glyph_empty(&self, glyph_index: u32) -> bool { + match self.get_glyf_offset(glyph_index) { + Some(g) => { + let number_of_contours = BE::read_i16(&self.data[g as usize..]); + number_of_contours == 0 + } + None => true, + } + } + + /// Like `get_codepoint_shape`, but takes a glyph index instead. Use this + /// if you have cached the glyph index for a codepoint. + pub fn get_glyph_shape(&self, glyph_index: u32) -> Option<Vec<Vertex>> { + let g = match self.get_glyf_offset(glyph_index) { + Some(g) => &self.data[g as usize..], + None => return None, + }; + + let number_of_contours = BE::read_i16(g); + let vertices: Vec<Vertex> = if number_of_contours > 0 { + self.glyph_shape_positive_contours(g, number_of_contours as usize) + } else if number_of_contours == -1 { + // Compound shapes + let mut more = true; + let mut comp = &g[10..]; + let mut vertices = Vec::new(); + while more { + let mut mtx = [1.0, 0.0, 0.0, 1.0, 0.0, 0.0]; + + let [flags, gidx] = read_ints!(2, i16, comp); + comp = &comp[4..]; + let gidx = gidx as u16; + + if flags & 2 != 0 { + // XY values + if flags & 1 != 0 { + // shorts + let [a, b] = read_ints!(2, i16, comp); + comp = &comp[4..]; + mtx[4] = a as f32; + mtx[5] = b as f32; + } else { + mtx[4] = (comp[0] as i8) as f32; + mtx[5] = (comp[1] as i8) as f32; + comp = &comp[2..]; + } + } else { + panic!("Matching points not supported."); + } + if flags & (1 << 3) != 0 { + // WE_HAVE_A_SCALE + mtx[0] = BE::read_i16(comp) as f32 / 16384.0; + comp = &comp[2..]; + mtx[1] = 0.0; + mtx[2] = 0.0; + mtx[3] = mtx[0]; + } else if flags & (1 << 6) != 0 { + // WE_HAVE_AN_X_AND_YSCALE + let [a, b] = read_ints!(2, i16, comp); + comp = &comp[4..]; + mtx[0] = a as f32 / 16384.0; + mtx[1] = 0.0; + mtx[2] = 0.0; + mtx[3] = b as f32 / 16384.0; + } else if flags & (1 << 7) != 0 { + // WE_HAVE_A_TWO_BY_TWO + let [a, b, c, d] = read_ints!(4, i16, comp); + comp = &comp[8..]; + mtx[0] = a as f32 / 16384.0; + mtx[1] = b as f32 / 16384.0; + mtx[2] = c as f32 / 16384.0; + mtx[3] = d as f32 / 16384.0; + } + + // Find transformation scales. + let m = (mtx[0] * mtx[0] + mtx[1] * mtx[1]).sqrt(); + let n = (mtx[2] * mtx[2] + mtx[3] * mtx[3]).sqrt(); + + // Get indexed glyph. + let mut comp_verts = self.get_glyph_shape(gidx as u32).unwrap_or_else(Vec::new); + if !comp_verts.is_empty() { + // Transform vertices + for v in &mut *comp_verts { + let (x, y, cx, cy) = (v.x as f32, v.y as f32, v.cx as f32, v.cy as f32); + *v = Vertex { + type_: v.type_, + x: (m * (mtx[0] * x + mtx[2] * y + mtx[4])) as i16, + y: (n * (mtx[1] * x + mtx[3] * y + mtx[5])) as i16, + cx: (m * (mtx[0] * cx + mtx[2] * cy + mtx[4])) as i16, + cy: (n * (mtx[1] * cx + mtx[3] * cy + mtx[5])) as i16, + }; + } + // Append vertices. + vertices.append(&mut comp_verts); + } + // More components ? + more = flags & (1 << 5) != 0; + } + vertices + } else if number_of_contours < 0 { + panic!("Contour format not supported.") + } else { + return None; + }; + Some(vertices) + } + + #[inline] + fn glyph_shape_positive_contours( + &self, + glyph_data: &[u8], + number_of_contours: usize, + ) -> Vec<Vertex> { + use crate::VertexType::*; + + struct FlagData { + flags: u8, + x: i16, + y: i16, + } + + #[inline] + fn close_shape( + vertices: &mut Vec<Vertex>, + was_off: bool, + start_off: bool, + sx: i16, + sy: i16, + scx: i16, + scy: i16, + cx: i16, + cy: i16, + ) { + if start_off { + if was_off { + vertices.push(Vertex { + type_: CurveTo as u8, + x: (cx + scx) >> 1, + y: (cy + scy) >> 1, + cx, + cy, + }); + } + vertices.push(Vertex { + type_: CurveTo as u8, + x: sx, + y: sy, + cx: scx, + cy: scy, + }); + } else { + vertices.push(if was_off { + Vertex { + type_: CurveTo as u8, + x: sx, + y: sy, + cx, + cy, + } + } else { + Vertex { + type_: LineTo as u8, + x: sx, + y: sy, + cx: 0, + cy: 0, + } + }); + } + } + + let number_of_contours = number_of_contours as usize; + let mut start_off = false; + let mut was_off = false; + let end_points_of_contours = &glyph_data[10..]; + let ins = BE::read_u16(&glyph_data[10 + number_of_contours * 2..]) as usize; + let mut points = &glyph_data[10 + number_of_contours * 2 + 2 + ins..]; + + let n = 1 + BE::read_u16(&end_points_of_contours[number_of_contours * 2 - 2..]) as usize; + + let m = n + 2 * number_of_contours; // a loose bound on how many vertices we might need + let mut vertices: Vec<Vertex> = Vec::with_capacity(m); + + let mut flag_data = Vec::with_capacity(n); + + let mut next_move = 0; + + // in first pass, we load uninterpreted data into the allocated array above + + // first load flags + { + let mut flagcount = 0; + let mut flags = 0; + for _ in 0..n { + if flagcount == 0 { + flags = points[0]; + if flags & 8 != 0 { + flagcount = points[1]; + points = &points[2..]; + } else { + points = &points[1..]; + } + } else { + flagcount -= 1; + } + flag_data.push(FlagData { flags, x: 0, y: 0 }); + } + } + + // now load x coordinates + let mut x_coord = 0_i16; + for flag_data in &mut flag_data { + let flags = flag_data.flags; + if flags & 2 != 0 { + let dx = i16::from(points[0]); + points = &points[1..]; + if flags & 16 != 0 { + // ??? + x_coord += dx; + } else { + x_coord -= dx; + } + } else if flags & 16 == 0 { + x_coord += BE::read_i16(points); + points = &points[2..]; + } + flag_data.x = x_coord; + } + + // now load y coordinates + let mut y_coord = 0_i16; + for flag_data in &mut flag_data { + let flags = flag_data.flags; + if flags & 4 != 0 { + let dy = i16::from(points[0]); + points = &points[1..]; + if flags & 32 != 0 { + y_coord += dy; + } else { + y_coord -= dy; + } + } else if flags & 32 == 0 { + y_coord += BE::read_i16(points); + points = &points[2..]; + } + flag_data.y = y_coord; + } + + // now convert them to our format + let mut sx = 0; + let mut sy = 0; + let mut cx = 0; + let mut cy = 0; + let mut scx = 0; + let mut scy = 0; + let mut j = 0; + + let mut iter = flag_data.into_iter().enumerate().peekable(); + + while let Some((index, FlagData { flags, x, y })) = iter.next() { + if next_move == index { + if index != 0 { + close_shape(&mut vertices, was_off, start_off, sx, sy, scx, scy, cx, cy); + } + + // now start the new one + start_off = flags & 1 == 0; + if start_off { + // if we start off with an off-curve point, then when we need to find a + // point on the curve where we can start, and we + // need to save some state for + // when we wraparound. + scx = x; + scy = y; + + let (next_flags, next_x, next_y) = match iter.peek() { + Some((_, fd)) => (fd.flags, fd.x, fd.y), + None => break, + }; + + if next_flags & 1 == 0 { + // next point is also a curve point, so interpolate an on-point curve + sx = (x + next_x) >> 1; + sy = (y + next_y) >> 1; + } else { + // otherwise just use the next point as our start point + sx = next_x; + sy = next_y; + + // we're using point i+1 as the starting point, so skip it + let _ = iter.next(); + } + } else { + sx = x; + sy = y; + } + vertices.push(Vertex { + type_: MoveTo as u8, + x: sx, + y: sy, + cx: 0, + cy: 0, + }); + was_off = false; + next_move = 1 + BE::read_u16(&end_points_of_contours[j * 2..]) as usize; + j += 1; + } else if flags & 1 == 0 { + // if it's a curve + if was_off { + // two off-curve control points in a row means interpolate an on-curve + // midpoint + vertices.push(Vertex { + type_: CurveTo as u8, + x: ((cx + x) >> 1), + y: ((cy + y) >> 1), + cx, + cy, + }); + } + cx = x; + cy = y; + was_off = true; + } else { + vertices.push(if was_off { + Vertex { + type_: CurveTo as u8, + x, + y, + cx, + cy, + } + } else { + Vertex { + type_: LineTo as u8, + x, + y, + cx: 0, + cy: 0, + } + }); + was_off = false; + } + } + close_shape( + &mut vertices, + // &mut num_vertices, + was_off, + start_off, + sx, + sy, + scx, + scy, + cx, + cy, + ); + + vertices + } + + /// like `get_codepoint_h_metrics`, but takes a glyph index instead. Use + /// this if you have cached the glyph index for a codepoint. + pub fn get_glyph_h_metrics(&self, glyph_index: u32) -> HMetrics { + let num_of_long_hor_metrics = BE::read_u16(&self.data[self.hhea as usize + 34..]) as usize; + let glyph_index = glyph_index as usize; + if glyph_index < num_of_long_hor_metrics { + let data = &self.data[self.hmtx as usize + 4 * glyph_index..]; + let [advance_width, left_side_bearing] = read_ints!(2, i16, data); + HMetrics { + advance_width: i32::from(advance_width), + left_side_bearing: i32::from(left_side_bearing), + } + } else { + HMetrics { + advance_width: BE::read_i16( + &self.data[self.hmtx as usize + 4 * (num_of_long_hor_metrics - 1)..], + ) as i32, + left_side_bearing: BE::read_i16( + &self.data[self.hmtx as usize + + 4 * num_of_long_hor_metrics + + 2 * (glyph_index as isize - num_of_long_hor_metrics as isize) as usize..], + ) as i32, + } + } + } + + /// like `get_codepoint_kern_advance`, but takes glyph indices instead. Use + /// this if you have cached the glyph indices for the codepoints. + pub fn get_glyph_kern_advance(&self, glyph_1: u32, glyph_2: u32) -> i32 { + let kern = &self.data[self.kern as usize..]; + // we only look at the first table. it must be 'horizontal' and format 0 + if self.kern == 0 || BE::read_u16(&kern[2..]) < 1 || BE::read_u16(&kern[8..]) != 1 { + // kern not present, OR + // no tables (need at least one), OR + // horizontal flag not set in format + return 0; + } + + let mut l: i32 = 0; + let mut r: i32 = BE::read_u16(&kern[10..]) as i32 - 1; + let needle = glyph_1 << 16 | glyph_2; + while l <= r { + let m = (l + r) >> 1; + let straw = BE::read_u32(&kern[18 + (m as usize) * 6..]); // note: unaligned read + if needle < straw { + r = m - 1; + } else if needle > straw { + l = m + 1; + } else { + return BE::read_i16(&kern[22 + (m as usize) * 6..]) as i32; + } + } + 0 + } + + /// an additional amount to add to the 'advance' value between cp1 and cp2 + pub fn get_codepoint_kern_advance(&self, cp1: u32, cp2: u32) -> i32 { + if self.kern == 0 { + // if no kerning table, don't waste time looking up both codepoint->glyphs + 0 + } else { + self.get_glyph_kern_advance(self.find_glyph_index(cp1), self.find_glyph_index(cp2)) + } + } + + /// `left_side_bearing` is the offset from the current horizontal position + /// to the left edge of the character `advance_width` is the offset + /// from the current horizontal position to the next horizontal + /// position these are + /// expressed in unscaled + /// coordinates + pub fn get_codepoint_h_metrics(&self, codepoint: u32) -> HMetrics { + self.get_glyph_h_metrics(self.find_glyph_index(codepoint)) + } + + /// `ascent` is the coordinate above the baseline the font extends; descent + /// is the coordinate below the baseline the font extends (i.e. it is + /// typically negative) `line_gap` is the spacing between one row's + /// descent and the next row's ascent... so you should advance the + /// vertical position by `ascent - + /// descent + line_gap` these are expressed in unscaled coordinates, so + /// you must multiply by the scale factor for a given size + pub fn get_v_metrics(&self) -> VMetrics { + let hhea = &self.data[self.hhea as usize..]; + let [ascent, descent, line_gap] = read_ints!(3, i16, &hhea[4..]); + VMetrics { + ascent: i32::from(ascent), + descent: i32::from(descent), + line_gap: i32::from(line_gap), + } + } + + /// the bounding box around all possible characters + pub fn get_bounding_box(&self) -> Rect<i16> { + let head = &self.data[self.head as usize..]; + Rect { + x0: BE::read_i16(&head[36..]), + y0: BE::read_i16(&head[38..]), + x1: BE::read_i16(&head[40..]), + y1: BE::read_i16(&head[42..]), + } + } + + /// computes a scale factor to produce a font whose "height" is 'pixels' + /// tall. Height is measured as the distance from the highest ascender + /// to the lowest descender; in other words, it's equivalent to calling + /// GetFontVMetrics and computing: + /// scale = pixels / (ascent - descent) + /// so if you prefer to measure height by the ascent only, use a similar + /// calculation. + pub fn scale_for_pixel_height(&self, height: f32) -> f32 { + let hhea = &self.data[self.hhea as usize..]; + let fheight = { + let [a, b] = read_ints!(2, i16, &hhea[4..]); + f32::from(a) - f32::from(b) + }; + height / fheight + } + + /// Returns the units per EM square of this font. + pub fn units_per_em(&self) -> u16 { + BE::read_u16(&self.data[self.head as usize + 18..]) + } + + /// computes a scale factor to produce a font whose EM size is mapped to + /// `pixels` tall. This is probably what traditional APIs compute, but + /// I'm not positive. + pub fn scale_for_mapping_em_to_pixels(&self, pixels: f32) -> f32 { + pixels / (self.units_per_em() as f32) + } + + /// like `get_codepoint_bitmap_box_subpixel`, but takes a glyph index + /// instead of a codepoint. + pub fn get_glyph_bitmap_box_subpixel( + &self, + glyph: u32, + scale_x: f32, + scale_y: f32, + shift_x: f32, + shift_y: f32, + ) -> Option<Rect<i32>> { + if let Some(glyph_box) = self.get_glyph_box(glyph) { + // move to integral bboxes (treating pixels as little squares, what pixels get + // touched?) + Some(Rect { + x0: (glyph_box.x0 as f32 * scale_x + shift_x).floor() as i32, + y0: (-glyph_box.y1 as f32 * scale_y + shift_y).floor() as i32, + x1: (glyph_box.x1 as f32 * scale_x + shift_x).ceil() as i32, + y1: (-glyph_box.y0 as f32 * scale_y + shift_y).ceil() as i32, + }) + } else { + // e.g. space character + None + } + } + + /// like `get_codepoint_bitmap_box`, but takes a glyph index instead of a + /// codepoint. + pub fn get_glyph_bitmap_box( + &self, + glyph: u32, + scale_x: f32, + scale_y: f32, + ) -> Option<Rect<i32>> { + self.get_glyph_bitmap_box_subpixel(glyph, scale_x, scale_y, 0.0, 0.0) + } + + /// same as get_codepoint_bitmap_box, but you can specify a subpixel + /// shift for the character + pub fn get_codepoint_bitmap_box_subpixel( + &self, + codepoint: u32, + scale_x: f32, + scale_y: f32, + shift_x: f32, + shift_y: f32, + ) -> Option<Rect<i32>> { + self.get_glyph_bitmap_box_subpixel( + self.find_glyph_index(codepoint), + scale_x, + scale_y, + shift_x, + shift_y, + ) + } + + /// get the bounding box of the bitmap centered around the glyph origin; so + /// the bitmap width is x1-x0, height is y1-y0, and location to place + /// the bitmap top left is (left_side_bearing*scale, y0). + /// (Note that the bitmap uses y-increases-down, but the shape uses + /// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) + pub fn get_codepoint_bitmap_box( + &self, + codepoint: u32, + scale_x: f32, + scale_y: f32, + ) -> Option<Rect<i32>> { + self.get_codepoint_bitmap_box_subpixel(codepoint, scale_x, scale_y, 0.0, 0.0) + } + + pub fn get_font_name_strings(&self) -> FontNameIter<'_, Data> { + let nm = self.name as usize; + if nm == 0 { + return FontNameIter { + font_info: &self, + string_offset: 0, + index: 0, + count: 0, + }; + } + let count = BE::read_u16(&self.data[nm + 2..]) as usize; + let string_offset = nm + BE::read_u16(&self.data[nm + 4..]) as usize; + + FontNameIter { + font_info: &self, + string_offset, + index: 0, + count, + } + } +} + +#[derive(Clone, Copy, Debug)] +pub struct FontNameIter<'a, Data: Deref<Target = [u8]>> { + /// Font info. + font_info: &'a FontInfo<Data>, + string_offset: usize, + /// Next index. + index: usize, + /// Number of name strings. + count: usize, +} + +impl<'a, Data: 'a + Deref<Target = [u8]>> Iterator for FontNameIter<'a, Data> { + type Item = (&'a [u8], Option<PlatformEncodingLanguageId>, u16); + + fn next(&mut self) -> Option<Self::Item> { + if self.index >= self.count { + return None; + } + + let loc = self.font_info.name as usize + 6 + 12 * self.index; + + let pl_id = platform_id(BE::read_u16(&self.font_info.data[loc..])); + let platform_encoding_language_id = pl_id.map(|pl_id| { + let encoding_id = BE::read_u16(&self.font_info.data[loc + 2..]); + let language_id = BE::read_u16(&self.font_info.data[loc + 4..]); + platform_encoding_id(pl_id, Some(encoding_id), Some(language_id)) + }); + // @TODO: Define an enum type for Name ID. + // See https://www.microsoft.com/typography/otspec/name.htm, "Name IDs" section. + let name_id = BE::read_u16(&self.font_info.data[loc + 6..]); + let length = BE::read_u16(&self.font_info.data[loc + 8..]) as usize; + let offset = self.string_offset + BE::read_u16(&self.font_info.data[loc + 10..]) as usize; + + self.index += 1; + + Some(( + &self.font_info.data[offset..offset + length], + platform_encoding_language_id, + name_id, + )) + } + + fn size_hint(&self) -> (usize, Option<usize>) { + let remaining = self.count - self.index; + (remaining, Some(remaining)) + } + + fn count(self) -> usize { + self.count - self.index + } + + fn last(mut self) -> Option<Self::Item> { + if self.index >= self.count || self.count == 0 { + return None; + } + self.index = self.count - 1; + self.next() + } + + fn nth(&mut self, n: usize) -> Option<Self::Item> { + if n > self.count - self.index { + self.index = self.count; + return None; + } + self.index += n; + self.next() + } +} diff --git a/third_party/cargo/vendor/stb_truetype-0.3.1/tests/mod.rs b/third_party/cargo/vendor/stb_truetype-0.3.1/tests/mod.rs new file mode 100644 index 0000000..db7d9e8 --- /dev/null +++ b/third_party/cargo/vendor/stb_truetype-0.3.1/tests/mod.rs @@ -0,0 +1,7 @@ +mod tests { + #[test] + fn is_font() { + assert!(stb_truetype::is_font(b"OTTO")); + assert!(!stb_truetype::is_font(b"")); + } +} diff --git a/third_party/cargo/vendor/termcolor-1.1.0/.cargo-checksum.json b/third_party/cargo/vendor/termcolor-1.1.0/.cargo-checksum.json new file mode 100644 index 0000000..665e531 --- /dev/null +++ b/third_party/cargo/vendor/termcolor-1.1.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"COPYING":"01c266bced4a434da0051174d6bee16a4c82cf634e2679b6155d40d75012390f","Cargo.toml":"45ba4a191f6371cd623421da1b73cb707b1a38a09a451ea1f7a0a84bd37cb592","LICENSE-MIT":"0f96a83840e146e43c0ec96a22ec1f392e0680e6c1226e6f3ba87e0740af850f","README.md":"5818a900b5f23ed13e824479c4739e3afe7929a5a08e0dcfdf2cc61ba019d986","UNLICENSE":"7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c","rustfmt.toml":"1ca600239a27401c4a43f363cf3f38183a212affc1f31bff3ae93234bbaec228","src/lib.rs":"f07f3a0e64d00d723f03fb377e4bc4d5323ade9b0f89dc9fe4bb22c5da71ed8e"},"package":"bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"} \ No newline at end of file diff --git a/third_party/cargo/vendor/termcolor-1.1.0/BUILD b/third_party/cargo/vendor/termcolor-1.1.0/BUILD new file mode 100644 index 0000000..bdc3650 --- /dev/null +++ b/third_party/cargo/vendor/termcolor-1.1.0/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "Unlicense OR MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "termcolor", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.1.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/termcolor-1.1.0/COPYING b/third_party/cargo/vendor/termcolor-1.1.0/COPYING new file mode 100644 index 0000000..bb9c20a --- /dev/null +++ b/third_party/cargo/vendor/termcolor-1.1.0/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/third_party/cargo/vendor/termcolor-1.1.0/Cargo.toml b/third_party/cargo/vendor/termcolor-1.1.0/Cargo.toml new file mode 100644 index 0000000..9d030e1 --- /dev/null +++ b/third_party/cargo/vendor/termcolor-1.1.0/Cargo.toml @@ -0,0 +1,33 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "termcolor" +version = "1.1.0" +authors = ["Andrew Gallant <jamslam@gmail.com>"] +exclude = ["/.travis.yml", "/appveyor.yml", "/ci/**"] +description = "A simple cross platform library for writing colored text to a terminal.\n" +homepage = "https://github.com/BurntSushi/termcolor" +documentation = "https://docs.rs/termcolor" +readme = "README.md" +keywords = ["windows", "win", "color", "ansi", "console"] +license = "Unlicense OR MIT" +repository = "https://github.com/BurntSushi/termcolor" + +[lib] +name = "termcolor" +bench = false +[dev-dependencies.doc-comment] +version = "0.3" +[target."cfg(windows)".dependencies.winapi-util] +version = "0.1.3" diff --git a/third_party/cargo/vendor/termcolor-1.1.0/LICENSE-MIT b/third_party/cargo/vendor/termcolor-1.1.0/LICENSE-MIT new file mode 100644 index 0000000..3b0a5dc --- /dev/null +++ b/third_party/cargo/vendor/termcolor-1.1.0/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/third_party/cargo/vendor/termcolor-1.1.0/README.md b/third_party/cargo/vendor/termcolor-1.1.0/README.md new file mode 100644 index 0000000..1c91d07 --- /dev/null +++ b/third_party/cargo/vendor/termcolor-1.1.0/README.md @@ -0,0 +1,115 @@ +termcolor +========= +A simple cross platform library for writing colored text to a terminal. This +library writes colored text either using standard ANSI escape sequences or +by interacting with the Windows console. Several convenient abstractions +are provided for use in single-threaded or multi-threaded command line +applications. + +[![Build status](https://github.com/BurntSushi/termcolor/workflows/ci/badge.svg)](https://github.com/BurntSushi/termcolor/actions) +[![](https://img.shields.io/crates/v/termcolor.svg)](https://crates.io/crates/termcolor) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + +### Documentation + +[https://docs.rs/termcolor](https://docs.rs/termcolor) + +### Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +termcolor = "1.1" +``` + +### Organization + +The `WriteColor` trait extends the `io::Write` trait with methods for setting +colors or resetting them. + +`StandardStream` and `StandardStreamLock` both satisfy `WriteColor` and are +analogous to `std::io::Stdout` and `std::io::StdoutLock`, or `std::io::Stderr` +and `std::io::StderrLock`. + +`Buffer` is an in memory buffer that supports colored text. In a parallel +program, each thread might write to its own buffer. A buffer can be printed to +stdout or stderr using a `BufferWriter`. The advantage of this design is that +each thread can work in parallel on a buffer without having to synchronize +access to global resources such as the Windows console. Moreover, this design +also prevents interleaving of buffer output. + +`Ansi` and `NoColor` both satisfy `WriteColor` for arbitrary implementors of +`io::Write`. These types are useful when you know exactly what you need. An +analogous type for the Windows console is not provided since it cannot exist. + +### Example: using `StandardStream` + +The `StandardStream` type in this crate works similarly to `std::io::Stdout`, +except it is augmented with methods for coloring by the `WriteColor` trait. +For example, to write some green text: + +```rust +use std::io::{self, Write}; +use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; + +fn write_green() -> io::Result<()> { + let mut stdout = StandardStream::stdout(ColorChoice::Always); + stdout.set_color(ColorSpec::new().set_fg(Some(Color::Green)))?; + writeln!(&mut stdout, "green text!") +} +``` + +### Example: using `BufferWriter` + +A `BufferWriter` can create buffers and write buffers to stdout or stderr. It +does *not* implement `io::Write` or `WriteColor` itself. Instead, `Buffer` +implements `io::Write` and `termcolor::WriteColor`. + +This example shows how to print some green text to stderr. + +```rust +use std::io::{self, Write}; +use termcolor::{BufferWriter, Color, ColorChoice, ColorSpec, WriteColor}; + +fn write_green() -> io::Result<()> { + let mut bufwtr = BufferWriter::stderr(ColorChoice::Always); + let mut buffer = bufwtr.buffer(); + buffer.set_color(ColorSpec::new().set_fg(Some(Color::Green)))?; + writeln!(&mut buffer, "green text!")?; + bufwtr.print(&buffer) +} +``` + +### Automatic color selection + +When building a writer with termcolor, the caller must provide a +[`ColorChoice`](https://docs.rs/termcolor/1.0.5/termcolor/enum.ColorChoice.html) +selection. When the color choice is `Auto`, termcolor will attempt to determine +whether colors should be enabled by inspecting the environment. Currently, +termcolor will inspect the `TERM` and `NO_COLOR` environment variables: + +* If `NO_COLOR` is set to any value, then colors will be suppressed. +* If `TERM` is set to `dumb`, then colors will be suppressed. +* In non-Windows environments, if `TERM` is not set, then colors will be + suppressed. + +This decision procedure may change over time. + +Currently, `termcolor` does not attempt to detect whether a tty is present or +not. To achieve that, please use the [`atty`](https://crates.io/crates/atty) +crate. + +### Minimum Rust version policy + +This crate's minimum supported `rustc` version is `1.34.0`. + +The current policy is that the minimum Rust version required to use this crate +can be increased in minor version updates. For example, if `crate 1.0` requires +Rust 1.20.0, then `crate 1.0.z` for all values of `z` will also require Rust +1.20.0 or newer. However, `crate 1.y` for `y > 0` may require a newer minimum +version of Rust. + +In general, this crate will be conservative with respect to the minimum +supported version of Rust. diff --git a/third_party/cargo/vendor/termcolor-1.1.0/UNLICENSE b/third_party/cargo/vendor/termcolor-1.1.0/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/third_party/cargo/vendor/termcolor-1.1.0/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <http://unlicense.org/> diff --git a/third_party/cargo/vendor/termcolor-1.1.0/rustfmt.toml b/third_party/cargo/vendor/termcolor-1.1.0/rustfmt.toml new file mode 100644 index 0000000..aa37a21 --- /dev/null +++ b/third_party/cargo/vendor/termcolor-1.1.0/rustfmt.toml @@ -0,0 +1,2 @@ +max_width = 79 +use_small_heuristics = "max" diff --git a/third_party/cargo/vendor/termcolor-1.1.0/src/lib.rs b/third_party/cargo/vendor/termcolor-1.1.0/src/lib.rs new file mode 100644 index 0000000..42eccda --- /dev/null +++ b/third_party/cargo/vendor/termcolor-1.1.0/src/lib.rs @@ -0,0 +1,2221 @@ +/*! +This crate provides a cross platform abstraction for writing colored text to +a terminal. Colors are written using either ANSI escape sequences or by +communicating with a Windows console. Much of this API was motivated by use +inside command line applications, where colors or styles can be configured +by the end user and/or the environment. + +This crate also provides platform independent support for writing colored text +to an in memory buffer. While this is easy to do with ANSI escape sequences +(because they are in the buffer themselves), it is trickier to do with the +Windows console API, which requires synchronous communication. + +# Organization + +The `WriteColor` trait extends the `io::Write` trait with methods for setting +colors or resetting them. + +`StandardStream` and `StandardStreamLock` both satisfy `WriteColor` and are +analogous to `std::io::Stdout` and `std::io::StdoutLock`, or `std::io::Stderr` +and `std::io::StderrLock`. + +`Buffer` is an in memory buffer that supports colored text. In a parallel +program, each thread might write to its own buffer. A buffer can be printed to +using a `BufferWriter`. The advantage of this design is that each thread can +work in parallel on a buffer without having to synchronize access to global +resources such as the Windows console. Moreover, this design also prevents +interleaving of buffer output. + +`Ansi` and `NoColor` both satisfy `WriteColor` for arbitrary implementors of +`io::Write`. These types are useful when you know exactly what you need. An +analogous type for the Windows console is not provided since it cannot exist. + +# Example: using `StandardStream` + +The `StandardStream` type in this crate works similarly to `std::io::Stdout`, +except it is augmented with methods for coloring by the `WriteColor` trait. +For example, to write some green text: + +```rust,no_run +# fn test() -> Result<(), Box<::std::error::Error>> { +use std::io::Write; +use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; + +let mut stdout = StandardStream::stdout(ColorChoice::Always); +stdout.set_color(ColorSpec::new().set_fg(Some(Color::Green)))?; +writeln!(&mut stdout, "green text!")?; +# Ok(()) } +``` + +Note that any text written to the terminal now will be colored +green when using ANSI escape sequences, even if it is written via +stderr, and even if stderr had previously been set to `Color::Red`. +Users will need to manage any color changes themselves by calling +[`WriteColor::set_color`](trait.WriteColor.html#tymethod.set_color), and this +may include calling [`WriteColor::reset`](trait.WriteColor.html#tymethod.reset) +before the program exits to a shell. + +# Example: using `BufferWriter` + +A `BufferWriter` can create buffers and write buffers to stdout or stderr. It +does *not* implement `io::Write` or `WriteColor` itself. Instead, `Buffer` +implements `io::Write` and `io::WriteColor`. + +This example shows how to print some green text to stderr. + +```rust,no_run +# fn test() -> Result<(), Box<::std::error::Error>> { +use std::io::Write; +use termcolor::{BufferWriter, Color, ColorChoice, ColorSpec, WriteColor}; + +let mut bufwtr = BufferWriter::stderr(ColorChoice::Always); +let mut buffer = bufwtr.buffer(); +buffer.set_color(ColorSpec::new().set_fg(Some(Color::Green)))?; +writeln!(&mut buffer, "green text!")?; +bufwtr.print(&buffer)?; +# Ok(()) } +``` + +# Detecting presence of a terminal + +In many scenarios when using color, one often wants to enable colors +automatically when writing to a terminal and disable colors automatically when +writing to anything else. The typical way to achieve this in Unix environments +is via libc's +[`isatty`](http://man7.org/linux/man-pages/man3/isatty.3.html) +function. +Unfortunately, this notoriously does not work well in Windows environments. To +work around that, the currently recommended solution is to use the +[`atty`](https://crates.io/crates/atty) +crate, which goes out of its way to get this as right as possible in Windows +environments. + +For example, in a command line application that exposes a `--color` flag, +your logic for how to enable colors might look like this: + +```rust,ignore +use atty; +use termcolor::{ColorChoice, StandardStream}; + +let preference = argv.get_flag("color").unwrap_or("auto"); +let choice = match preference { + "always" => ColorChoice::Always, + "ansi" => ColorChoice::AlwaysAnsi, + "auto" => { + if atty::is(atty::Stream::Stdout) { + ColorChoice::Auto + } else { + ColorChoice::Never + } + } + _ => ColorChoice::Never, +}; +let stdout = StandardStream::stdout(choice); +// ... write to stdout +``` + +Currently, `termcolor` does not provide anything to do this for you. +*/ + +#![deny(missing_docs)] + +#[cfg(test)] +use doc_comment::doctest; +#[cfg(test)] +doctest!("../README.md"); + +use std::env; +use std::error; +use std::fmt; +use std::io::{self, Write}; +use std::str::FromStr; +use std::sync::atomic::{AtomicBool, Ordering}; +#[cfg(windows)] +use std::sync::{Mutex, MutexGuard}; + +#[cfg(windows)] +use winapi_util::console as wincon; + +/// This trait describes the behavior of writers that support colored output. +pub trait WriteColor: io::Write { + /// Returns true if and only if the underlying writer supports colors. + fn supports_color(&self) -> bool; + + /// Set the color settings of the writer. + /// + /// Subsequent writes to this writer will use these settings until either + /// `reset` is called or new color settings are set. + /// + /// If there was a problem setting the color settings, then an error is + /// returned. + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()>; + + /// Reset the current color settings to their original settings. + /// + /// If there was a problem resetting the color settings, then an error is + /// returned. + fn reset(&mut self) -> io::Result<()>; + + /// Returns true if and only if the underlying writer must synchronously + /// interact with an end user's device in order to control colors. By + /// default, this always returns `false`. + /// + /// In practice, this should return `true` if the underlying writer is + /// manipulating colors using the Windows console APIs. + /// + /// This is useful for writing generic code (such as a buffered writer) + /// that can perform certain optimizations when the underlying writer + /// doesn't rely on synchronous APIs. For example, ANSI escape sequences + /// can be passed through to the end user's device as is. + fn is_synchronous(&self) -> bool { + false + } +} + +impl<'a, T: ?Sized + WriteColor> WriteColor for &'a mut T { + fn supports_color(&self) -> bool { + (&**self).supports_color() + } + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + (&mut **self).set_color(spec) + } + fn reset(&mut self) -> io::Result<()> { + (&mut **self).reset() + } + fn is_synchronous(&self) -> bool { + (&**self).is_synchronous() + } +} + +impl<T: ?Sized + WriteColor> WriteColor for Box<T> { + fn supports_color(&self) -> bool { + (&**self).supports_color() + } + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + (&mut **self).set_color(spec) + } + fn reset(&mut self) -> io::Result<()> { + (&mut **self).reset() + } + fn is_synchronous(&self) -> bool { + (&**self).is_synchronous() + } +} + +/// ColorChoice represents the color preferences of an end user. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum ColorChoice { + /// Try very hard to emit colors. This includes emitting ANSI colors + /// on Windows if the console API is unavailable. + Always, + /// AlwaysAnsi is like Always, except it never tries to use anything other + /// than emitting ANSI color codes. + AlwaysAnsi, + /// Try to use colors, but don't force the issue. If the console isn't + /// available on Windows, or if TERM=dumb, or if `NO_COLOR` is defined, for + /// example, then don't use colors. + Auto, + /// Never emit colors. + Never, +} + +impl ColorChoice { + /// Returns true if we should attempt to write colored output. + fn should_attempt_color(&self) -> bool { + match *self { + ColorChoice::Always => true, + ColorChoice::AlwaysAnsi => true, + ColorChoice::Never => false, + ColorChoice::Auto => self.env_allows_color(), + } + } + + #[cfg(not(windows))] + fn env_allows_color(&self) -> bool { + match env::var_os("TERM") { + // If TERM isn't set, then we are in a weird environment that + // probably doesn't support colors. + None => return false, + Some(k) => { + if k == "dumb" { + return false; + } + } + } + // If TERM != dumb, then the only way we don't allow colors at this + // point is if NO_COLOR is set. + if env::var_os("NO_COLOR").is_some() { + return false; + } + true + } + + #[cfg(windows)] + fn env_allows_color(&self) -> bool { + // On Windows, if TERM isn't set, then we shouldn't automatically + // assume that colors aren't allowed. This is unlike Unix environments + // where TERM is more rigorously set. + if let Some(k) = env::var_os("TERM") { + if k == "dumb" { + return false; + } + } + // If TERM != dumb, then the only way we don't allow colors at this + // point is if NO_COLOR is set. + if env::var_os("NO_COLOR").is_some() { + return false; + } + true + } + + /// Returns true if this choice should forcefully use ANSI color codes. + /// + /// It's possible that ANSI is still the correct choice even if this + /// returns false. + #[cfg(windows)] + fn should_ansi(&self) -> bool { + match *self { + ColorChoice::Always => false, + ColorChoice::AlwaysAnsi => true, + ColorChoice::Never => false, + ColorChoice::Auto => { + match env::var("TERM") { + Err(_) => false, + // cygwin doesn't seem to support ANSI escape sequences + // and instead has its own variety. However, the Windows + // console API may be available. + Ok(k) => k != "dumb" && k != "cygwin", + } + } + } + } +} + +/// `std::io` implements `Stdout` and `Stderr` (and their `Lock` variants) as +/// separate types, which makes it difficult to abstract over them. We use +/// some simple internal enum types to work around this. + +enum StandardStreamType { + Stdout, + Stderr, + StdoutBuffered, + StderrBuffered, +} + +enum IoStandardStream { + Stdout(io::Stdout), + Stderr(io::Stderr), + StdoutBuffered(io::BufWriter<io::Stdout>), + StderrBuffered(io::BufWriter<io::Stderr>), +} + +impl IoStandardStream { + fn new(sty: StandardStreamType) -> IoStandardStream { + match sty { + StandardStreamType::Stdout => { + IoStandardStream::Stdout(io::stdout()) + } + StandardStreamType::Stderr => { + IoStandardStream::Stderr(io::stderr()) + } + StandardStreamType::StdoutBuffered => { + let wtr = io::BufWriter::new(io::stdout()); + IoStandardStream::StdoutBuffered(wtr) + } + StandardStreamType::StderrBuffered => { + let wtr = io::BufWriter::new(io::stderr()); + IoStandardStream::StderrBuffered(wtr) + } + } + } + + fn lock(&self) -> IoStandardStreamLock<'_> { + match *self { + IoStandardStream::Stdout(ref s) => { + IoStandardStreamLock::StdoutLock(s.lock()) + } + IoStandardStream::Stderr(ref s) => { + IoStandardStreamLock::StderrLock(s.lock()) + } + IoStandardStream::StdoutBuffered(_) + | IoStandardStream::StderrBuffered(_) => { + // We don't permit this case to ever occur in the public API, + // so it's OK to panic. + panic!("cannot lock a buffered standard stream") + } + } + } +} + +impl io::Write for IoStandardStream { + #[inline(always)] + fn write(&mut self, b: &[u8]) -> io::Result<usize> { + match *self { + IoStandardStream::Stdout(ref mut s) => s.write(b), + IoStandardStream::Stderr(ref mut s) => s.write(b), + IoStandardStream::StdoutBuffered(ref mut s) => s.write(b), + IoStandardStream::StderrBuffered(ref mut s) => s.write(b), + } + } + + #[inline(always)] + fn flush(&mut self) -> io::Result<()> { + match *self { + IoStandardStream::Stdout(ref mut s) => s.flush(), + IoStandardStream::Stderr(ref mut s) => s.flush(), + IoStandardStream::StdoutBuffered(ref mut s) => s.flush(), + IoStandardStream::StderrBuffered(ref mut s) => s.flush(), + } + } +} + +// Same rigmarole for the locked variants of the standard streams. + +enum IoStandardStreamLock<'a> { + StdoutLock(io::StdoutLock<'a>), + StderrLock(io::StderrLock<'a>), +} + +impl<'a> io::Write for IoStandardStreamLock<'a> { + #[inline(always)] + fn write(&mut self, b: &[u8]) -> io::Result<usize> { + match *self { + IoStandardStreamLock::StdoutLock(ref mut s) => s.write(b), + IoStandardStreamLock::StderrLock(ref mut s) => s.write(b), + } + } + + #[inline(always)] + fn flush(&mut self) -> io::Result<()> { + match *self { + IoStandardStreamLock::StdoutLock(ref mut s) => s.flush(), + IoStandardStreamLock::StderrLock(ref mut s) => s.flush(), + } + } +} + +/// Satisfies `io::Write` and `WriteColor`, and supports optional coloring +/// to either of the standard output streams, stdout and stderr. +pub struct StandardStream { + wtr: LossyStandardStream<WriterInner<IoStandardStream>>, +} + +/// `StandardStreamLock` is a locked reference to a `StandardStream`. +/// +/// This implements the `io::Write` and `WriteColor` traits, and is constructed +/// via the `Write::lock` method. +/// +/// The lifetime `'a` refers to the lifetime of the corresponding +/// `StandardStream`. +pub struct StandardStreamLock<'a> { + wtr: LossyStandardStream<WriterInnerLock<'a, IoStandardStreamLock<'a>>>, +} + +/// Like `StandardStream`, but does buffered writing. +pub struct BufferedStandardStream { + wtr: LossyStandardStream<WriterInner<IoStandardStream>>, +} + +/// WriterInner is a (limited) generic representation of a writer. It is +/// limited because W should only ever be stdout/stderr on Windows. +enum WriterInner<W> { + NoColor(NoColor<W>), + Ansi(Ansi<W>), + #[cfg(windows)] + Windows { + wtr: W, + console: Mutex<wincon::Console>, + }, +} + +/// WriterInnerLock is a (limited) generic representation of a writer. It is +/// limited because W should only ever be stdout/stderr on Windows. +enum WriterInnerLock<'a, W> { + NoColor(NoColor<W>), + Ansi(Ansi<W>), + /// What a gross hack. On Windows, we need to specify a lifetime for the + /// console when in a locked state, but obviously don't need to do that + /// on Unix, which makes the `'a` unused. To satisfy the compiler, we need + /// a PhantomData. + #[allow(dead_code)] + Unreachable(::std::marker::PhantomData<&'a ()>), + #[cfg(windows)] + Windows { + wtr: W, + console: MutexGuard<'a, wincon::Console>, + }, +} + +impl StandardStream { + /// Create a new `StandardStream` with the given color preferences that + /// writes to standard output. + /// + /// On Windows, if coloring is desired and a Windows console could not be + /// found, then ANSI escape sequences are used instead. + /// + /// The specific color/style settings can be configured when writing via + /// the `WriteColor` trait. + pub fn stdout(choice: ColorChoice) -> StandardStream { + let wtr = WriterInner::create(StandardStreamType::Stdout, choice); + StandardStream { wtr: LossyStandardStream::new(wtr) } + } + + /// Create a new `StandardStream` with the given color preferences that + /// writes to standard error. + /// + /// On Windows, if coloring is desired and a Windows console could not be + /// found, then ANSI escape sequences are used instead. + /// + /// The specific color/style settings can be configured when writing via + /// the `WriteColor` trait. + pub fn stderr(choice: ColorChoice) -> StandardStream { + let wtr = WriterInner::create(StandardStreamType::Stderr, choice); + StandardStream { wtr: LossyStandardStream::new(wtr) } + } + + /// Lock the underlying writer. + /// + /// The lock guard returned also satisfies `io::Write` and + /// `WriteColor`. + /// + /// This method is **not reentrant**. It may panic if `lock` is called + /// while a `StandardStreamLock` is still alive. + pub fn lock(&self) -> StandardStreamLock<'_> { + StandardStreamLock::from_stream(self) + } +} + +impl<'a> StandardStreamLock<'a> { + #[cfg(not(windows))] + fn from_stream(stream: &StandardStream) -> StandardStreamLock<'_> { + let locked = match *stream.wtr.get_ref() { + WriterInner::NoColor(ref w) => { + WriterInnerLock::NoColor(NoColor(w.0.lock())) + } + WriterInner::Ansi(ref w) => { + WriterInnerLock::Ansi(Ansi(w.0.lock())) + } + }; + StandardStreamLock { wtr: stream.wtr.wrap(locked) } + } + + #[cfg(windows)] + fn from_stream(stream: &StandardStream) -> StandardStreamLock { + let locked = match *stream.wtr.get_ref() { + WriterInner::NoColor(ref w) => { + WriterInnerLock::NoColor(NoColor(w.0.lock())) + } + WriterInner::Ansi(ref w) => { + WriterInnerLock::Ansi(Ansi(w.0.lock())) + } + #[cfg(windows)] + WriterInner::Windows { ref wtr, ref console } => { + WriterInnerLock::Windows { + wtr: wtr.lock(), + console: console.lock().unwrap(), + } + } + }; + StandardStreamLock { wtr: stream.wtr.wrap(locked) } + } +} + +impl BufferedStandardStream { + /// Create a new `BufferedStandardStream` with the given color preferences + /// that writes to standard output via a buffered writer. + /// + /// On Windows, if coloring is desired and a Windows console could not be + /// found, then ANSI escape sequences are used instead. + /// + /// The specific color/style settings can be configured when writing via + /// the `WriteColor` trait. + pub fn stdout(choice: ColorChoice) -> BufferedStandardStream { + let wtr = + WriterInner::create(StandardStreamType::StdoutBuffered, choice); + BufferedStandardStream { wtr: LossyStandardStream::new(wtr) } + } + + /// Create a new `BufferedStandardStream` with the given color preferences + /// that writes to standard error via a buffered writer. + /// + /// On Windows, if coloring is desired and a Windows console could not be + /// found, then ANSI escape sequences are used instead. + /// + /// The specific color/style settings can be configured when writing via + /// the `WriteColor` trait. + pub fn stderr(choice: ColorChoice) -> BufferedStandardStream { + let wtr = + WriterInner::create(StandardStreamType::StderrBuffered, choice); + BufferedStandardStream { wtr: LossyStandardStream::new(wtr) } + } +} + +impl WriterInner<IoStandardStream> { + /// Create a new inner writer for a standard stream with the given color + /// preferences. + #[cfg(not(windows))] + fn create( + sty: StandardStreamType, + choice: ColorChoice, + ) -> WriterInner<IoStandardStream> { + if choice.should_attempt_color() { + WriterInner::Ansi(Ansi(IoStandardStream::new(sty))) + } else { + WriterInner::NoColor(NoColor(IoStandardStream::new(sty))) + } + } + + /// Create a new inner writer for a standard stream with the given color + /// preferences. + /// + /// If coloring is desired and a Windows console could not be found, then + /// ANSI escape sequences are used instead. + #[cfg(windows)] + fn create( + sty: StandardStreamType, + choice: ColorChoice, + ) -> WriterInner<IoStandardStream> { + let mut con = match sty { + StandardStreamType::Stdout => wincon::Console::stdout(), + StandardStreamType::Stderr => wincon::Console::stderr(), + StandardStreamType::StdoutBuffered => wincon::Console::stdout(), + StandardStreamType::StderrBuffered => wincon::Console::stderr(), + }; + let is_console_virtual = con + .as_mut() + .map(|con| con.set_virtual_terminal_processing(true).is_ok()) + .unwrap_or(false); + if choice.should_attempt_color() { + if choice.should_ansi() || is_console_virtual { + WriterInner::Ansi(Ansi(IoStandardStream::new(sty))) + } else if let Ok(console) = con { + WriterInner::Windows { + wtr: IoStandardStream::new(sty), + console: Mutex::new(console), + } + } else { + WriterInner::Ansi(Ansi(IoStandardStream::new(sty))) + } + } else { + WriterInner::NoColor(NoColor(IoStandardStream::new(sty))) + } + } +} + +impl io::Write for StandardStream { + #[inline] + fn write(&mut self, b: &[u8]) -> io::Result<usize> { + self.wtr.write(b) + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { + self.wtr.flush() + } +} + +impl WriteColor for StandardStream { + #[inline] + fn supports_color(&self) -> bool { + self.wtr.supports_color() + } + + #[inline] + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + self.wtr.set_color(spec) + } + + #[inline] + fn reset(&mut self) -> io::Result<()> { + self.wtr.reset() + } + + #[inline] + fn is_synchronous(&self) -> bool { + self.wtr.is_synchronous() + } +} + +impl<'a> io::Write for StandardStreamLock<'a> { + #[inline] + fn write(&mut self, b: &[u8]) -> io::Result<usize> { + self.wtr.write(b) + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { + self.wtr.flush() + } +} + +impl<'a> WriteColor for StandardStreamLock<'a> { + #[inline] + fn supports_color(&self) -> bool { + self.wtr.supports_color() + } + + #[inline] + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + self.wtr.set_color(spec) + } + + #[inline] + fn reset(&mut self) -> io::Result<()> { + self.wtr.reset() + } + + #[inline] + fn is_synchronous(&self) -> bool { + self.wtr.is_synchronous() + } +} + +impl io::Write for BufferedStandardStream { + #[inline] + fn write(&mut self, b: &[u8]) -> io::Result<usize> { + self.wtr.write(b) + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { + self.wtr.flush() + } +} + +impl WriteColor for BufferedStandardStream { + #[inline] + fn supports_color(&self) -> bool { + self.wtr.supports_color() + } + + #[inline] + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + if self.is_synchronous() { + self.wtr.flush()?; + } + self.wtr.set_color(spec) + } + + #[inline] + fn reset(&mut self) -> io::Result<()> { + self.wtr.reset() + } + + #[inline] + fn is_synchronous(&self) -> bool { + self.wtr.is_synchronous() + } +} + +impl<W: io::Write> io::Write for WriterInner<W> { + #[inline(always)] + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + match *self { + WriterInner::NoColor(ref mut wtr) => wtr.write(buf), + WriterInner::Ansi(ref mut wtr) => wtr.write(buf), + #[cfg(windows)] + WriterInner::Windows { ref mut wtr, .. } => wtr.write(buf), + } + } + + #[inline(always)] + fn flush(&mut self) -> io::Result<()> { + match *self { + WriterInner::NoColor(ref mut wtr) => wtr.flush(), + WriterInner::Ansi(ref mut wtr) => wtr.flush(), + #[cfg(windows)] + WriterInner::Windows { ref mut wtr, .. } => wtr.flush(), + } + } +} + +impl<W: io::Write> WriteColor for WriterInner<W> { + fn supports_color(&self) -> bool { + match *self { + WriterInner::NoColor(_) => false, + WriterInner::Ansi(_) => true, + #[cfg(windows)] + WriterInner::Windows { .. } => true, + } + } + + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + match *self { + WriterInner::NoColor(ref mut wtr) => wtr.set_color(spec), + WriterInner::Ansi(ref mut wtr) => wtr.set_color(spec), + #[cfg(windows)] + WriterInner::Windows { ref mut wtr, ref console } => { + wtr.flush()?; + let mut console = console.lock().unwrap(); + spec.write_console(&mut *console) + } + } + } + + fn reset(&mut self) -> io::Result<()> { + match *self { + WriterInner::NoColor(ref mut wtr) => wtr.reset(), + WriterInner::Ansi(ref mut wtr) => wtr.reset(), + #[cfg(windows)] + WriterInner::Windows { ref mut wtr, ref mut console } => { + wtr.flush()?; + console.lock().unwrap().reset()?; + Ok(()) + } + } + } + + fn is_synchronous(&self) -> bool { + match *self { + WriterInner::NoColor(_) => false, + WriterInner::Ansi(_) => false, + #[cfg(windows)] + WriterInner::Windows { .. } => true, + } + } +} + +impl<'a, W: io::Write> io::Write for WriterInnerLock<'a, W> { + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + match *self { + WriterInnerLock::Unreachable(_) => unreachable!(), + WriterInnerLock::NoColor(ref mut wtr) => wtr.write(buf), + WriterInnerLock::Ansi(ref mut wtr) => wtr.write(buf), + #[cfg(windows)] + WriterInnerLock::Windows { ref mut wtr, .. } => wtr.write(buf), + } + } + + fn flush(&mut self) -> io::Result<()> { + match *self { + WriterInnerLock::Unreachable(_) => unreachable!(), + WriterInnerLock::NoColor(ref mut wtr) => wtr.flush(), + WriterInnerLock::Ansi(ref mut wtr) => wtr.flush(), + #[cfg(windows)] + WriterInnerLock::Windows { ref mut wtr, .. } => wtr.flush(), + } + } +} + +impl<'a, W: io::Write> WriteColor for WriterInnerLock<'a, W> { + fn supports_color(&self) -> bool { + match *self { + WriterInnerLock::Unreachable(_) => unreachable!(), + WriterInnerLock::NoColor(_) => false, + WriterInnerLock::Ansi(_) => true, + #[cfg(windows)] + WriterInnerLock::Windows { .. } => true, + } + } + + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + match *self { + WriterInnerLock::Unreachable(_) => unreachable!(), + WriterInnerLock::NoColor(ref mut wtr) => wtr.set_color(spec), + WriterInnerLock::Ansi(ref mut wtr) => wtr.set_color(spec), + #[cfg(windows)] + WriterInnerLock::Windows { ref mut wtr, ref mut console } => { + wtr.flush()?; + spec.write_console(console) + } + } + } + + fn reset(&mut self) -> io::Result<()> { + match *self { + WriterInnerLock::Unreachable(_) => unreachable!(), + WriterInnerLock::NoColor(ref mut wtr) => wtr.reset(), + WriterInnerLock::Ansi(ref mut wtr) => wtr.reset(), + #[cfg(windows)] + WriterInnerLock::Windows { ref mut wtr, ref mut console } => { + wtr.flush()?; + console.reset()?; + Ok(()) + } + } + } + + fn is_synchronous(&self) -> bool { + match *self { + WriterInnerLock::Unreachable(_) => unreachable!(), + WriterInnerLock::NoColor(_) => false, + WriterInnerLock::Ansi(_) => false, + #[cfg(windows)] + WriterInnerLock::Windows { .. } => true, + } + } +} + +/// Writes colored buffers to stdout or stderr. +/// +/// Writable buffers can be obtained by calling `buffer` on a `BufferWriter`. +/// +/// This writer works with terminals that support ANSI escape sequences or +/// with a Windows console. +/// +/// It is intended for a `BufferWriter` to be put in an `Arc` and written to +/// from multiple threads simultaneously. +pub struct BufferWriter { + stream: LossyStandardStream<IoStandardStream>, + printed: AtomicBool, + separator: Option<Vec<u8>>, + color_choice: ColorChoice, + #[cfg(windows)] + console: Option<Mutex<wincon::Console>>, +} + +impl BufferWriter { + /// Create a new `BufferWriter` that writes to a standard stream with the + /// given color preferences. + /// + /// The specific color/style settings can be configured when writing to + /// the buffers themselves. + #[cfg(not(windows))] + fn create(sty: StandardStreamType, choice: ColorChoice) -> BufferWriter { + BufferWriter { + stream: LossyStandardStream::new(IoStandardStream::new(sty)), + printed: AtomicBool::new(false), + separator: None, + color_choice: choice, + } + } + + /// Create a new `BufferWriter` that writes to a standard stream with the + /// given color preferences. + /// + /// If coloring is desired and a Windows console could not be found, then + /// ANSI escape sequences are used instead. + /// + /// The specific color/style settings can be configured when writing to + /// the buffers themselves. + #[cfg(windows)] + fn create(sty: StandardStreamType, choice: ColorChoice) -> BufferWriter { + let mut con = match sty { + StandardStreamType::Stdout => wincon::Console::stdout(), + StandardStreamType::Stderr => wincon::Console::stderr(), + StandardStreamType::StdoutBuffered => wincon::Console::stdout(), + StandardStreamType::StderrBuffered => wincon::Console::stderr(), + } + .ok(); + let is_console_virtual = con + .as_mut() + .map(|con| con.set_virtual_terminal_processing(true).is_ok()) + .unwrap_or(false); + // If we can enable ANSI on Windows, then we don't need the console + // anymore. + if is_console_virtual { + con = None; + } + let stream = LossyStandardStream::new(IoStandardStream::new(sty)); + BufferWriter { + stream: stream, + printed: AtomicBool::new(false), + separator: None, + color_choice: choice, + console: con.map(Mutex::new), + } + } + + /// Create a new `BufferWriter` that writes to stdout with the given + /// color preferences. + /// + /// On Windows, if coloring is desired and a Windows console could not be + /// found, then ANSI escape sequences are used instead. + /// + /// The specific color/style settings can be configured when writing to + /// the buffers themselves. + pub fn stdout(choice: ColorChoice) -> BufferWriter { + BufferWriter::create(StandardStreamType::Stdout, choice) + } + + /// Create a new `BufferWriter` that writes to stderr with the given + /// color preferences. + /// + /// On Windows, if coloring is desired and a Windows console could not be + /// found, then ANSI escape sequences are used instead. + /// + /// The specific color/style settings can be configured when writing to + /// the buffers themselves. + pub fn stderr(choice: ColorChoice) -> BufferWriter { + BufferWriter::create(StandardStreamType::Stderr, choice) + } + + /// If set, the separator given is printed between buffers. By default, no + /// separator is printed. + /// + /// The default value is `None`. + pub fn separator(&mut self, sep: Option<Vec<u8>>) { + self.separator = sep; + } + + /// Creates a new `Buffer` with the current color preferences. + /// + /// A `Buffer` satisfies both `io::Write` and `WriteColor`. A `Buffer` can + /// be printed using the `print` method. + #[cfg(not(windows))] + pub fn buffer(&self) -> Buffer { + Buffer::new(self.color_choice) + } + + /// Creates a new `Buffer` with the current color preferences. + /// + /// A `Buffer` satisfies both `io::Write` and `WriteColor`. A `Buffer` can + /// be printed using the `print` method. + #[cfg(windows)] + pub fn buffer(&self) -> Buffer { + Buffer::new(self.color_choice, self.console.is_some()) + } + + /// Prints the contents of the given buffer. + /// + /// It is safe to call this from multiple threads simultaneously. In + /// particular, all buffers are written atomically. No interleaving will + /// occur. + pub fn print(&self, buf: &Buffer) -> io::Result<()> { + if buf.is_empty() { + return Ok(()); + } + let mut stream = self.stream.wrap(self.stream.get_ref().lock()); + if let Some(ref sep) = self.separator { + if self.printed.load(Ordering::SeqCst) { + stream.write_all(sep)?; + stream.write_all(b"\n")?; + } + } + match buf.0 { + BufferInner::NoColor(ref b) => stream.write_all(&b.0)?, + BufferInner::Ansi(ref b) => stream.write_all(&b.0)?, + #[cfg(windows)] + BufferInner::Windows(ref b) => { + // We guarantee by construction that we have a console here. + // Namely, a BufferWriter is the only way to produce a Buffer. + let console_mutex = self + .console + .as_ref() + .expect("got Windows buffer but have no Console"); + let mut console = console_mutex.lock().unwrap(); + b.print(&mut *console, &mut stream)?; + } + } + self.printed.store(true, Ordering::SeqCst); + Ok(()) + } +} + +/// Write colored text to memory. +/// +/// `Buffer` is a platform independent abstraction for printing colored text to +/// an in memory buffer. When the buffer is printed using a `BufferWriter`, the +/// color information will be applied to the output device (a tty on Unix and a +/// console on Windows). +/// +/// A `Buffer` is typically created by calling the `BufferWriter.buffer` +/// method, which will take color preferences and the environment into +/// account. However, buffers can also be manually created using `no_color`, +/// `ansi` or `console` (on Windows). +pub struct Buffer(BufferInner); + +/// BufferInner is an enumeration of different buffer types. +enum BufferInner { + /// No coloring information should be applied. This ignores all coloring + /// directives. + NoColor(NoColor<Vec<u8>>), + /// Apply coloring using ANSI escape sequences embedded into the buffer. + Ansi(Ansi<Vec<u8>>), + /// Apply coloring using the Windows console APIs. This buffer saves + /// color information in memory and only interacts with the console when + /// the buffer is printed. + #[cfg(windows)] + Windows(WindowsBuffer), +} + +impl Buffer { + /// Create a new buffer with the given color settings. + #[cfg(not(windows))] + fn new(choice: ColorChoice) -> Buffer { + if choice.should_attempt_color() { + Buffer::ansi() + } else { + Buffer::no_color() + } + } + + /// Create a new buffer with the given color settings. + /// + /// On Windows, one can elect to create a buffer capable of being written + /// to a console. Only enable it if a console is available. + /// + /// If coloring is desired and `console` is false, then ANSI escape + /// sequences are used instead. + #[cfg(windows)] + fn new(choice: ColorChoice, console: bool) -> Buffer { + if choice.should_attempt_color() { + if !console || choice.should_ansi() { + Buffer::ansi() + } else { + Buffer::console() + } + } else { + Buffer::no_color() + } + } + + /// Create a buffer that drops all color information. + pub fn no_color() -> Buffer { + Buffer(BufferInner::NoColor(NoColor(vec![]))) + } + + /// Create a buffer that uses ANSI escape sequences. + pub fn ansi() -> Buffer { + Buffer(BufferInner::Ansi(Ansi(vec![]))) + } + + /// Create a buffer that can be written to a Windows console. + #[cfg(windows)] + pub fn console() -> Buffer { + Buffer(BufferInner::Windows(WindowsBuffer::new())) + } + + /// Returns true if and only if this buffer is empty. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Returns the length of this buffer in bytes. + pub fn len(&self) -> usize { + match self.0 { + BufferInner::NoColor(ref b) => b.0.len(), + BufferInner::Ansi(ref b) => b.0.len(), + #[cfg(windows)] + BufferInner::Windows(ref b) => b.buf.len(), + } + } + + /// Clears this buffer. + pub fn clear(&mut self) { + match self.0 { + BufferInner::NoColor(ref mut b) => b.0.clear(), + BufferInner::Ansi(ref mut b) => b.0.clear(), + #[cfg(windows)] + BufferInner::Windows(ref mut b) => b.clear(), + } + } + + /// Consume this buffer and return the underlying raw data. + /// + /// On Windows, this unrecoverably drops all color information associated + /// with the buffer. + pub fn into_inner(self) -> Vec<u8> { + match self.0 { + BufferInner::NoColor(b) => b.0, + BufferInner::Ansi(b) => b.0, + #[cfg(windows)] + BufferInner::Windows(b) => b.buf, + } + } + + /// Return the underlying data of the buffer. + pub fn as_slice(&self) -> &[u8] { + match self.0 { + BufferInner::NoColor(ref b) => &b.0, + BufferInner::Ansi(ref b) => &b.0, + #[cfg(windows)] + BufferInner::Windows(ref b) => &b.buf, + } + } + + /// Return the underlying data of the buffer as a mutable slice. + pub fn as_mut_slice(&mut self) -> &mut [u8] { + match self.0 { + BufferInner::NoColor(ref mut b) => &mut b.0, + BufferInner::Ansi(ref mut b) => &mut b.0, + #[cfg(windows)] + BufferInner::Windows(ref mut b) => &mut b.buf, + } + } +} + +impl io::Write for Buffer { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + match self.0 { + BufferInner::NoColor(ref mut w) => w.write(buf), + BufferInner::Ansi(ref mut w) => w.write(buf), + #[cfg(windows)] + BufferInner::Windows(ref mut w) => w.write(buf), + } + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { + match self.0 { + BufferInner::NoColor(ref mut w) => w.flush(), + BufferInner::Ansi(ref mut w) => w.flush(), + #[cfg(windows)] + BufferInner::Windows(ref mut w) => w.flush(), + } + } +} + +impl WriteColor for Buffer { + #[inline] + fn supports_color(&self) -> bool { + match self.0 { + BufferInner::NoColor(_) => false, + BufferInner::Ansi(_) => true, + #[cfg(windows)] + BufferInner::Windows(_) => true, + } + } + + #[inline] + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + match self.0 { + BufferInner::NoColor(ref mut w) => w.set_color(spec), + BufferInner::Ansi(ref mut w) => w.set_color(spec), + #[cfg(windows)] + BufferInner::Windows(ref mut w) => w.set_color(spec), + } + } + + #[inline] + fn reset(&mut self) -> io::Result<()> { + match self.0 { + BufferInner::NoColor(ref mut w) => w.reset(), + BufferInner::Ansi(ref mut w) => w.reset(), + #[cfg(windows)] + BufferInner::Windows(ref mut w) => w.reset(), + } + } + + #[inline] + fn is_synchronous(&self) -> bool { + false + } +} + +/// Satisfies `WriteColor` but ignores all color options. +pub struct NoColor<W>(W); + +impl<W: Write> NoColor<W> { + /// Create a new writer that satisfies `WriteColor` but drops all color + /// information. + pub fn new(wtr: W) -> NoColor<W> { + NoColor(wtr) + } + + /// Consume this `NoColor` value and return the inner writer. + pub fn into_inner(self) -> W { + self.0 + } + + /// Return a reference to the inner writer. + pub fn get_ref(&self) -> &W { + &self.0 + } + + /// Return a mutable reference to the inner writer. + pub fn get_mut(&mut self) -> &mut W { + &mut self.0 + } +} + +impl<W: io::Write> io::Write for NoColor<W> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + self.0.write(buf) + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { + self.0.flush() + } +} + +impl<W: io::Write> WriteColor for NoColor<W> { + #[inline] + fn supports_color(&self) -> bool { + false + } + + #[inline] + fn set_color(&mut self, _: &ColorSpec) -> io::Result<()> { + Ok(()) + } + + #[inline] + fn reset(&mut self) -> io::Result<()> { + Ok(()) + } + + #[inline] + fn is_synchronous(&self) -> bool { + false + } +} + +/// Satisfies `WriteColor` using standard ANSI escape sequences. +pub struct Ansi<W>(W); + +impl<W: Write> Ansi<W> { + /// Create a new writer that satisfies `WriteColor` using standard ANSI + /// escape sequences. + pub fn new(wtr: W) -> Ansi<W> { + Ansi(wtr) + } + + /// Consume this `Ansi` value and return the inner writer. + pub fn into_inner(self) -> W { + self.0 + } + + /// Return a reference to the inner writer. + pub fn get_ref(&self) -> &W { + &self.0 + } + + /// Return a mutable reference to the inner writer. + pub fn get_mut(&mut self) -> &mut W { + &mut self.0 + } +} + +impl<W: io::Write> io::Write for Ansi<W> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + self.0.write(buf) + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { + self.0.flush() + } +} + +impl<W: io::Write> WriteColor for Ansi<W> { + #[inline] + fn supports_color(&self) -> bool { + true + } + + #[inline] + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + if spec.reset { + self.reset()?; + } + if spec.bold { + self.write_str("\x1B[1m")?; + } + if spec.italic { + self.write_str("\x1B[3m")?; + } + if spec.underline { + self.write_str("\x1B[4m")?; + } + if let Some(ref c) = spec.fg_color { + self.write_color(true, c, spec.intense)?; + } + if let Some(ref c) = spec.bg_color { + self.write_color(false, c, spec.intense)?; + } + Ok(()) + } + + #[inline] + fn reset(&mut self) -> io::Result<()> { + self.write_str("\x1B[0m") + } + + #[inline] + fn is_synchronous(&self) -> bool { + false + } +} + +impl<W: io::Write> Ansi<W> { + fn write_str(&mut self, s: &str) -> io::Result<()> { + self.write_all(s.as_bytes()) + } + + fn write_color( + &mut self, + fg: bool, + c: &Color, + intense: bool, + ) -> io::Result<()> { + macro_rules! write_intense { + ($clr:expr) => { + if fg { + self.write_str(concat!("\x1B[38;5;", $clr, "m")) + } else { + self.write_str(concat!("\x1B[48;5;", $clr, "m")) + } + }; + } + macro_rules! write_normal { + ($clr:expr) => { + if fg { + self.write_str(concat!("\x1B[3", $clr, "m")) + } else { + self.write_str(concat!("\x1B[4", $clr, "m")) + } + }; + } + macro_rules! write_var_ansi_code { + ($pre:expr, $($code:expr),+) => {{ + // The loop generates at worst a literal of the form + // '255,255,255m' which is 12-bytes. + // The largest `pre` expression we currently use is 7 bytes. + // This gives us the maximum of 19-bytes for our work buffer. + let pre_len = $pre.len(); + assert!(pre_len <= 7); + let mut fmt = [0u8; 19]; + fmt[..pre_len].copy_from_slice($pre); + let mut i = pre_len - 1; + $( + let c1: u8 = ($code / 100) % 10; + let c2: u8 = ($code / 10) % 10; + let c3: u8 = $code % 10; + let mut printed = false; + + if c1 != 0 { + printed = true; + i += 1; + fmt[i] = b'0' + c1; + } + if c2 != 0 || printed { + i += 1; + fmt[i] = b'0' + c2; + } + // If we received a zero value we must still print a value. + i += 1; + fmt[i] = b'0' + c3; + i += 1; + fmt[i] = b';'; + )+ + + fmt[i] = b'm'; + self.write_all(&fmt[0..i+1]) + }} + } + macro_rules! write_custom { + ($ansi256:expr) => { + if fg { + write_var_ansi_code!(b"\x1B[38;5;", $ansi256) + } else { + write_var_ansi_code!(b"\x1B[48;5;", $ansi256) + } + }; + + ($r:expr, $g:expr, $b:expr) => {{ + if fg { + write_var_ansi_code!(b"\x1B[38;2;", $r, $g, $b) + } else { + write_var_ansi_code!(b"\x1B[48;2;", $r, $g, $b) + } + }}; + } + if intense { + match *c { + Color::Black => write_intense!("8"), + Color::Blue => write_intense!("12"), + Color::Green => write_intense!("10"), + Color::Red => write_intense!("9"), + Color::Cyan => write_intense!("14"), + Color::Magenta => write_intense!("13"), + Color::Yellow => write_intense!("11"), + Color::White => write_intense!("15"), + Color::Ansi256(c) => write_custom!(c), + Color::Rgb(r, g, b) => write_custom!(r, g, b), + Color::__Nonexhaustive => unreachable!(), + } + } else { + match *c { + Color::Black => write_normal!("0"), + Color::Blue => write_normal!("4"), + Color::Green => write_normal!("2"), + Color::Red => write_normal!("1"), + Color::Cyan => write_normal!("6"), + Color::Magenta => write_normal!("5"), + Color::Yellow => write_normal!("3"), + Color::White => write_normal!("7"), + Color::Ansi256(c) => write_custom!(c), + Color::Rgb(r, g, b) => write_custom!(r, g, b), + Color::__Nonexhaustive => unreachable!(), + } + } + } +} + +/// An in-memory buffer that provides Windows console coloring. +/// +/// This doesn't actually communicate with the Windows console. Instead, it +/// acts like a normal buffer but also saves the color information associated +/// with positions in the buffer. It is only when the buffer is written to the +/// console that coloring is actually applied. +/// +/// This is roughly isomorphic to the ANSI based approach (i.e., +/// `Ansi<Vec<u8>>`), except with ANSI, the color information is embedded +/// directly into the buffer. +/// +/// Note that there is no way to write something generic like +/// `WindowsConsole<W: io::Write>` since coloring on Windows is tied +/// specifically to the console APIs, and therefore can't work on arbitrary +/// writers. +#[cfg(windows)] +#[derive(Clone, Debug)] +struct WindowsBuffer { + /// The actual content that should be printed. + buf: Vec<u8>, + /// A sequence of position oriented color specifications. Namely, each + /// element is a position and a color spec, where the color spec should + /// be applied at the position inside of `buf`. + /// + /// A missing color spec implies the underlying console should be reset. + colors: Vec<(usize, Option<ColorSpec>)>, +} + +#[cfg(windows)] +impl WindowsBuffer { + /// Create a new empty buffer for Windows console coloring. + fn new() -> WindowsBuffer { + WindowsBuffer { buf: vec![], colors: vec![] } + } + + /// Push the given color specification into this buffer. + /// + /// This has the effect of setting the given color information at the + /// current position in the buffer. + fn push(&mut self, spec: Option<ColorSpec>) { + let pos = self.buf.len(); + self.colors.push((pos, spec)); + } + + /// Print the contents to the given stream handle, and use the console + /// for coloring. + fn print( + &self, + console: &mut wincon::Console, + stream: &mut LossyStandardStream<IoStandardStreamLock>, + ) -> io::Result<()> { + let mut last = 0; + for &(pos, ref spec) in &self.colors { + stream.write_all(&self.buf[last..pos])?; + stream.flush()?; + last = pos; + match *spec { + None => console.reset()?, + Some(ref spec) => spec.write_console(console)?, + } + } + stream.write_all(&self.buf[last..])?; + stream.flush() + } + + /// Clear the buffer. + fn clear(&mut self) { + self.buf.clear(); + self.colors.clear(); + } +} + +#[cfg(windows)] +impl io::Write for WindowsBuffer { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + self.buf.extend_from_slice(buf); + Ok(buf.len()) + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } +} + +#[cfg(windows)] +impl WriteColor for WindowsBuffer { + #[inline] + fn supports_color(&self) -> bool { + true + } + + #[inline] + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + self.push(Some(spec.clone())); + Ok(()) + } + + #[inline] + fn reset(&mut self) -> io::Result<()> { + self.push(None); + Ok(()) + } + + #[inline] + fn is_synchronous(&self) -> bool { + false + } +} + +/// A color specification. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ColorSpec { + fg_color: Option<Color>, + bg_color: Option<Color>, + bold: bool, + intense: bool, + underline: bool, + italic: bool, + reset: bool, +} + +impl Default for ColorSpec { + fn default() -> ColorSpec { + ColorSpec { + fg_color: None, + bg_color: None, + bold: false, + intense: false, + underline: false, + italic: false, + reset: true, + } + } +} + +impl ColorSpec { + /// Create a new color specification that has no colors or styles. + pub fn new() -> ColorSpec { + ColorSpec::default() + } + + /// Get the foreground color. + pub fn fg(&self) -> Option<&Color> { + self.fg_color.as_ref() + } + + /// Set the foreground color. + pub fn set_fg(&mut self, color: Option<Color>) -> &mut ColorSpec { + self.fg_color = color; + self + } + + /// Get the background color. + pub fn bg(&self) -> Option<&Color> { + self.bg_color.as_ref() + } + + /// Set the background color. + pub fn set_bg(&mut self, color: Option<Color>) -> &mut ColorSpec { + self.bg_color = color; + self + } + + /// Get whether this is bold or not. + /// + /// Note that the bold setting has no effect in a Windows console. + pub fn bold(&self) -> bool { + self.bold + } + + /// Set whether the text is bolded or not. + /// + /// Note that the bold setting has no effect in a Windows console. + pub fn set_bold(&mut self, yes: bool) -> &mut ColorSpec { + self.bold = yes; + self + } + + /// Get whether this is italic or not. + /// + /// Note that the italic setting has no effect in a Windows console. + pub fn italic(&self) -> bool { + self.italic + } + + /// Set whether the text is italicized or not. + /// + /// Note that the italic setting has no effect in a Windows console. + pub fn set_italic(&mut self, yes: bool) -> &mut ColorSpec { + self.italic = yes; + self + } + + /// Get whether this is underline or not. + /// + /// Note that the underline setting has no effect in a Windows console. + pub fn underline(&self) -> bool { + self.underline + } + + /// Set whether the text is underlined or not. + /// + /// Note that the underline setting has no effect in a Windows console. + pub fn set_underline(&mut self, yes: bool) -> &mut ColorSpec { + self.underline = yes; + self + } + + /// Get whether reset is enabled or not. + /// + /// reset is enabled by default. When disabled and using ANSI escape + /// sequences, a "reset" code will be emitted every time a `ColorSpec`'s + /// settings are applied. + /// + /// Note that the reset setting has no effect in a Windows console. + pub fn reset(&self) -> bool { + self.reset + } + + /// Set whether to reset the terminal whenever color settings are applied. + /// + /// reset is enabled by default. When disabled and using ANSI escape + /// sequences, a "reset" code will be emitted every time a `ColorSpec`'s + /// settings are applied. + /// + /// Typically this is useful if callers have a requirement to more + /// scrupulously manage the exact sequence of escape codes that are emitted + /// when using ANSI for colors. + /// + /// Note that the reset setting has no effect in a Windows console. + pub fn set_reset(&mut self, yes: bool) -> &mut ColorSpec { + self.reset = yes; + self + } + + /// Get whether this is intense or not. + /// + /// On Unix-like systems, this will output the ANSI escape sequence + /// that will print a high-intensity version of the color + /// specified. + /// + /// On Windows systems, this will output the ANSI escape sequence + /// that will print a brighter version of the color specified. + pub fn intense(&self) -> bool { + self.intense + } + + /// Set whether the text is intense or not. + /// + /// On Unix-like systems, this will output the ANSI escape sequence + /// that will print a high-intensity version of the color + /// specified. + /// + /// On Windows systems, this will output the ANSI escape sequence + /// that will print a brighter version of the color specified. + pub fn set_intense(&mut self, yes: bool) -> &mut ColorSpec { + self.intense = yes; + self + } + + /// Returns true if this color specification has no colors or styles. + pub fn is_none(&self) -> bool { + self.fg_color.is_none() + && self.bg_color.is_none() + && !self.bold + && !self.underline + && !self.italic + && !self.intense + } + + /// Clears this color specification so that it has no color/style settings. + pub fn clear(&mut self) { + self.fg_color = None; + self.bg_color = None; + self.bold = false; + self.underline = false; + self.intense = false; + self.italic = false; + } + + /// Writes this color spec to the given Windows console. + #[cfg(windows)] + fn write_console(&self, console: &mut wincon::Console) -> io::Result<()> { + let fg_color = self.fg_color.and_then(|c| c.to_windows(self.intense)); + if let Some((intense, color)) = fg_color { + console.fg(intense, color)?; + } + let bg_color = self.bg_color.and_then(|c| c.to_windows(self.intense)); + if let Some((intense, color)) = bg_color { + console.bg(intense, color)?; + } + Ok(()) + } +} + +/// The set of available colors for the terminal foreground/background. +/// +/// The `Ansi256` and `Rgb` colors will only output the correct codes when +/// paired with the `Ansi` `WriteColor` implementation. +/// +/// The `Ansi256` and `Rgb` color types are not supported when writing colors +/// on Windows using the console. If they are used on Windows, then they are +/// silently ignored and no colors will be emitted. +/// +/// This set may expand over time. +/// +/// This type has a `FromStr` impl that can parse colors from their human +/// readable form. The format is as follows: +/// +/// 1. Any of the explicitly listed colors in English. They are matched +/// case insensitively. +/// 2. A single 8-bit integer, in either decimal or hexadecimal format. +/// 3. A triple of 8-bit integers separated by a comma, where each integer is +/// in decimal or hexadecimal format. +/// +/// Hexadecimal numbers are written with a `0x` prefix. +#[allow(missing_docs)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum Color { + Black, + Blue, + Green, + Red, + Cyan, + Magenta, + Yellow, + White, + Ansi256(u8), + Rgb(u8, u8, u8), + #[doc(hidden)] + __Nonexhaustive, +} + +impl Color { + /// Translate this color to a wincon::Color. + #[cfg(windows)] + fn to_windows( + self, + intense: bool, + ) -> Option<(wincon::Intense, wincon::Color)> { + use wincon::Intense::{No, Yes}; + + let color = match self { + Color::Black => wincon::Color::Black, + Color::Blue => wincon::Color::Blue, + Color::Green => wincon::Color::Green, + Color::Red => wincon::Color::Red, + Color::Cyan => wincon::Color::Cyan, + Color::Magenta => wincon::Color::Magenta, + Color::Yellow => wincon::Color::Yellow, + Color::White => wincon::Color::White, + Color::Ansi256(0) => return Some((No, wincon::Color::Black)), + Color::Ansi256(1) => return Some((No, wincon::Color::Red)), + Color::Ansi256(2) => return Some((No, wincon::Color::Green)), + Color::Ansi256(3) => return Some((No, wincon::Color::Yellow)), + Color::Ansi256(4) => return Some((No, wincon::Color::Blue)), + Color::Ansi256(5) => return Some((No, wincon::Color::Magenta)), + Color::Ansi256(6) => return Some((No, wincon::Color::Cyan)), + Color::Ansi256(7) => return Some((No, wincon::Color::White)), + Color::Ansi256(8) => return Some((Yes, wincon::Color::Black)), + Color::Ansi256(9) => return Some((Yes, wincon::Color::Red)), + Color::Ansi256(10) => return Some((Yes, wincon::Color::Green)), + Color::Ansi256(11) => return Some((Yes, wincon::Color::Yellow)), + Color::Ansi256(12) => return Some((Yes, wincon::Color::Blue)), + Color::Ansi256(13) => return Some((Yes, wincon::Color::Magenta)), + Color::Ansi256(14) => return Some((Yes, wincon::Color::Cyan)), + Color::Ansi256(15) => return Some((Yes, wincon::Color::White)), + Color::Ansi256(_) => return None, + Color::Rgb(_, _, _) => return None, + Color::__Nonexhaustive => unreachable!(), + }; + let intense = if intense { Yes } else { No }; + Some((intense, color)) + } + + /// Parses a numeric color string, either ANSI or RGB. + fn from_str_numeric(s: &str) -> Result<Color, ParseColorError> { + // The "ansi256" format is a single number (decimal or hex) + // corresponding to one of 256 colors. + // + // The "rgb" format is a triple of numbers (decimal or hex) delimited + // by a comma corresponding to one of 256^3 colors. + + fn parse_number(s: &str) -> Option<u8> { + use std::u8; + + if s.starts_with("0x") { + u8::from_str_radix(&s[2..], 16).ok() + } else { + u8::from_str_radix(s, 10).ok() + } + } + + let codes: Vec<&str> = s.split(',').collect(); + if codes.len() == 1 { + if let Some(n) = parse_number(&codes[0]) { + Ok(Color::Ansi256(n)) + } else { + if s.chars().all(|c| c.is_digit(16)) { + Err(ParseColorError { + kind: ParseColorErrorKind::InvalidAnsi256, + given: s.to_string(), + }) + } else { + Err(ParseColorError { + kind: ParseColorErrorKind::InvalidName, + given: s.to_string(), + }) + } + } + } else if codes.len() == 3 { + let mut v = vec![]; + for code in codes { + let n = parse_number(code).ok_or_else(|| ParseColorError { + kind: ParseColorErrorKind::InvalidRgb, + given: s.to_string(), + })?; + v.push(n); + } + Ok(Color::Rgb(v[0], v[1], v[2])) + } else { + Err(if s.contains(",") { + ParseColorError { + kind: ParseColorErrorKind::InvalidRgb, + given: s.to_string(), + } + } else { + ParseColorError { + kind: ParseColorErrorKind::InvalidName, + given: s.to_string(), + } + }) + } + } +} + +/// An error from parsing an invalid color specification. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ParseColorError { + kind: ParseColorErrorKind, + given: String, +} + +#[derive(Clone, Debug, Eq, PartialEq)] +enum ParseColorErrorKind { + InvalidName, + InvalidAnsi256, + InvalidRgb, +} + +impl ParseColorError { + /// Return the string that couldn't be parsed as a valid color. + pub fn invalid(&self) -> &str { + &self.given + } +} + +impl error::Error for ParseColorError { + fn description(&self) -> &str { + use self::ParseColorErrorKind::*; + match self.kind { + InvalidName => "unrecognized color name", + InvalidAnsi256 => "invalid ansi256 color number", + InvalidRgb => "invalid RGB color triple", + } + } +} + +impl fmt::Display for ParseColorError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use self::ParseColorErrorKind::*; + match self.kind { + InvalidName => write!( + f, + "unrecognized color name '{}'. Choose from: \ + black, blue, green, red, cyan, magenta, yellow, \ + white", + self.given + ), + InvalidAnsi256 => write!( + f, + "unrecognized ansi256 color number, \ + should be '[0-255]' (or a hex number), but is '{}'", + self.given + ), + InvalidRgb => write!( + f, + "unrecognized RGB color triple, \ + should be '[0-255],[0-255],[0-255]' (or a hex \ + triple), but is '{}'", + self.given + ), + } + } +} + +impl FromStr for Color { + type Err = ParseColorError; + + fn from_str(s: &str) -> Result<Color, ParseColorError> { + match &*s.to_lowercase() { + "black" => Ok(Color::Black), + "blue" => Ok(Color::Blue), + "green" => Ok(Color::Green), + "red" => Ok(Color::Red), + "cyan" => Ok(Color::Cyan), + "magenta" => Ok(Color::Magenta), + "yellow" => Ok(Color::Yellow), + "white" => Ok(Color::White), + _ => Color::from_str_numeric(s), + } + } +} + +struct LossyStandardStream<W> { + wtr: W, + #[cfg(windows)] + is_console: bool, +} + +impl<W: io::Write> LossyStandardStream<W> { + #[cfg(not(windows))] + fn new(wtr: W) -> LossyStandardStream<W> { + LossyStandardStream { wtr: wtr } + } + + #[cfg(windows)] + fn new(wtr: W) -> LossyStandardStream<W> { + let is_console = wincon::Console::stdout().is_ok() + || wincon::Console::stderr().is_ok(); + LossyStandardStream { wtr: wtr, is_console: is_console } + } + + #[cfg(not(windows))] + fn wrap<Q: io::Write>(&self, wtr: Q) -> LossyStandardStream<Q> { + LossyStandardStream::new(wtr) + } + + #[cfg(windows)] + fn wrap<Q: io::Write>(&self, wtr: Q) -> LossyStandardStream<Q> { + LossyStandardStream { wtr: wtr, is_console: self.is_console } + } + + fn get_ref(&self) -> &W { + &self.wtr + } +} + +impl<W: WriteColor> WriteColor for LossyStandardStream<W> { + fn supports_color(&self) -> bool { + self.wtr.supports_color() + } + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + self.wtr.set_color(spec) + } + fn reset(&mut self) -> io::Result<()> { + self.wtr.reset() + } + fn is_synchronous(&self) -> bool { + self.wtr.is_synchronous() + } +} + +impl<W: io::Write> io::Write for LossyStandardStream<W> { + #[cfg(not(windows))] + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + self.wtr.write(buf) + } + + #[cfg(windows)] + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + if self.is_console { + write_lossy_utf8(&mut self.wtr, buf) + } else { + self.wtr.write(buf) + } + } + + fn flush(&mut self) -> io::Result<()> { + self.wtr.flush() + } +} + +#[cfg(windows)] +fn write_lossy_utf8<W: io::Write>(mut w: W, buf: &[u8]) -> io::Result<usize> { + match ::std::str::from_utf8(buf) { + Ok(s) => w.write(s.as_bytes()), + Err(ref e) if e.valid_up_to() == 0 => { + w.write(b"\xEF\xBF\xBD")?; + Ok(1) + } + Err(e) => w.write(&buf[..e.valid_up_to()]), + } +} + +#[cfg(test)] +mod tests { + use super::{ + Ansi, Color, ColorSpec, ParseColorError, ParseColorErrorKind, + StandardStream, WriteColor, + }; + + fn assert_is_send<T: Send>() {} + + #[test] + fn standard_stream_is_send() { + assert_is_send::<StandardStream>(); + } + + #[test] + fn test_simple_parse_ok() { + let color = "green".parse::<Color>(); + assert_eq!(color, Ok(Color::Green)); + } + + #[test] + fn test_256_parse_ok() { + let color = "7".parse::<Color>(); + assert_eq!(color, Ok(Color::Ansi256(7))); + + let color = "32".parse::<Color>(); + assert_eq!(color, Ok(Color::Ansi256(32))); + + let color = "0xFF".parse::<Color>(); + assert_eq!(color, Ok(Color::Ansi256(0xFF))); + } + + #[test] + fn test_256_parse_err_out_of_range() { + let color = "256".parse::<Color>(); + assert_eq!( + color, + Err(ParseColorError { + kind: ParseColorErrorKind::InvalidAnsi256, + given: "256".to_string(), + }) + ); + } + + #[test] + fn test_rgb_parse_ok() { + let color = "0,0,0".parse::<Color>(); + assert_eq!(color, Ok(Color::Rgb(0, 0, 0))); + + let color = "0,128,255".parse::<Color>(); + assert_eq!(color, Ok(Color::Rgb(0, 128, 255))); + + let color = "0x0,0x0,0x0".parse::<Color>(); + assert_eq!(color, Ok(Color::Rgb(0, 0, 0))); + + let color = "0x33,0x66,0xFF".parse::<Color>(); + assert_eq!(color, Ok(Color::Rgb(0x33, 0x66, 0xFF))); + } + + #[test] + fn test_rgb_parse_err_out_of_range() { + let color = "0,0,256".parse::<Color>(); + assert_eq!( + color, + Err(ParseColorError { + kind: ParseColorErrorKind::InvalidRgb, + given: "0,0,256".to_string(), + }) + ); + } + + #[test] + fn test_rgb_parse_err_bad_format() { + let color = "0,0".parse::<Color>(); + assert_eq!( + color, + Err(ParseColorError { + kind: ParseColorErrorKind::InvalidRgb, + given: "0,0".to_string(), + }) + ); + + let color = "not_a_color".parse::<Color>(); + assert_eq!( + color, + Err(ParseColorError { + kind: ParseColorErrorKind::InvalidName, + given: "not_a_color".to_string(), + }) + ); + } + + #[test] + fn test_var_ansi_write_rgb() { + let mut buf = Ansi::new(vec![]); + let _ = buf.write_color(true, &Color::Rgb(254, 253, 255), false); + assert_eq!(buf.0, b"\x1B[38;2;254;253;255m"); + } + + #[test] + fn test_reset() { + let spec = ColorSpec::new(); + let mut buf = Ansi::new(vec![]); + buf.set_color(&spec).unwrap(); + assert_eq!(buf.0, b"\x1B[0m"); + } + + #[test] + fn test_no_reset() { + let mut spec = ColorSpec::new(); + spec.set_reset(false); + + let mut buf = Ansi::new(vec![]); + buf.set_color(&spec).unwrap(); + assert_eq!(buf.0, b""); + } + + #[test] + fn test_var_ansi_write_256() { + let mut buf = Ansi::new(vec![]); + let _ = buf.write_color(false, &Color::Ansi256(7), false); + assert_eq!(buf.0, b"\x1B[48;5;7m"); + + let mut buf = Ansi::new(vec![]); + let _ = buf.write_color(false, &Color::Ansi256(208), false); + assert_eq!(buf.0, b"\x1B[48;5;208m"); + } + + fn all_attributes() -> Vec<ColorSpec> { + let mut result = vec![]; + for fg in vec![None, Some(Color::Red)] { + for bg in vec![None, Some(Color::Red)] { + for bold in vec![false, true] { + for underline in vec![false, true] { + for intense in vec![false, true] { + for italic in vec![false, true] { + let mut color = ColorSpec::new(); + color.set_fg(fg); + color.set_bg(bg); + color.set_bold(bold); + color.set_underline(underline); + color.set_intense(intense); + color.set_italic(italic); + result.push(color); + } + } + } + } + } + } + result + } + + #[test] + fn test_is_none() { + for (i, color) in all_attributes().iter().enumerate() { + assert_eq!( + i == 0, + color.is_none(), + "{:?} => {}", + color, + color.is_none() + ) + } + } + + #[test] + fn test_clear() { + for color in all_attributes() { + let mut color1 = color.clone(); + color1.clear(); + assert!(color1.is_none(), "{:?} => {:?}", color, color1); + } + } +} diff --git a/third_party/cargo/vendor/thread_local-1.0.1/.cargo-checksum.json b/third_party/cargo/vendor/thread_local-1.0.1/.cargo-checksum.json new file mode 100644 index 0000000..b84db3e --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"a08d3007cec7ad1a83afad57980965ece5457089404f6f5d41eacc8143386d69","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","README.md":"ab6f09e96c06e37ee3df492562a07c1c3548dd5abf73301f8215a5dcedcccc84","benches/thread_local.rs":"cc8bde81ed6206525feff209598caf1e01e89a83bf21d8b7ccc0dadc8b89d815","src/cached.rs":"089286aa7bcde7c92b1ee7381b74f8c30049c0d80a85c1babdbac69b2e210396","src/lib.rs":"a67d7bf8c7c3bd869ea297cf1d158db8c9c4bbf7ae1e23d9028cfc3a7554e235","src/thread_id.rs":"0962c130061939557aa272115e4420fbbc63b6bd306783a456a8ffcbf304a447","src/unreachable.rs":"830d44988f86f4fc6c3c4dd7e9e4e7d0f2cb9c5b024c360b5f7ceae365983367"},"package":"d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"} \ No newline at end of file diff --git a/third_party/cargo/vendor/thread_local-1.0.1/BUILD b/third_party/cargo/vendor/thread_local-1.0.1/BUILD new file mode 100644 index 0000000..e9fd73c --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0,MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "thread_local" with type "bench" omitted + +rust_library( + name = "thread_local", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.0.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/thread_local-1.0.1/Cargo.toml b/third_party/cargo/vendor/thread_local-1.0.1/Cargo.toml new file mode 100644 index 0000000..0ce59da --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/Cargo.toml @@ -0,0 +1,26 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "thread_local" +version = "1.0.1" +authors = ["Amanieu d'Antras <amanieu@gmail.com>"] +description = "Per-object thread-local storage" +documentation = "https://amanieu.github.io/thread_local-rs/thread_local/index.html" +readme = "README.md" +keywords = ["thread_local", "concurrent", "thread"] +license = "Apache-2.0/MIT" +repository = "https://github.com/Amanieu/thread_local-rs" +[dependencies.lazy_static] +version = "1.0" +[badges.travis-ci] +repository = "Amanieu/thread_local-rs" diff --git a/third_party/cargo/vendor/thread_local-1.0.1/LICENSE-APACHE b/third_party/cargo/vendor/thread_local-1.0.1/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/thread_local-1.0.1/LICENSE-MIT b/third_party/cargo/vendor/thread_local-1.0.1/LICENSE-MIT new file mode 100644 index 0000000..40b8817 --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/thread_local-1.0.1/README.md b/third_party/cargo/vendor/thread_local-1.0.1/README.md new file mode 100644 index 0000000..d00355b --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/README.md @@ -0,0 +1,41 @@ +thread_local +============ + +[![Build Status](https://travis-ci.org/Amanieu/thread_local-rs.svg?branch=master)](https://travis-ci.org/Amanieu/thread_local-rs) [![Crates.io](https://img.shields.io/crates/v/thread_local.svg)](https://crates.io/crates/thread_local) + +This library provides the `ThreadLocal` and `CachedThreadLocal` types which +allow a separate copy of an object to be used for each thread. This allows for +per-object thread-local storage, unlike the standard library's `thread_local!` +macro which only allows static thread-local storage. + +[Documentation](https://amanieu.github.io/thread_local-rs/thread_local/index.html) + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +thread_local = "1.0" +``` + +and this to your crate root: + +```rust +extern crate thread_local; +``` + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any +additional terms or conditions. diff --git a/third_party/cargo/vendor/thread_local-1.0.1/benches/thread_local.rs b/third_party/cargo/vendor/thread_local-1.0.1/benches/thread_local.rs new file mode 100644 index 0000000..4cfaacd --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/benches/thread_local.rs @@ -0,0 +1,18 @@ +#![feature(test)] + +extern crate thread_local; +extern crate test; + +use thread_local::{ThreadLocal, CachedThreadLocal}; + +#[bench] +fn thread_local(b: &mut test::Bencher) { + let local = ThreadLocal::new(); + b.iter(|| { let _: &i32 = local.get_or(|| Box::new(0)); }); +} + +#[bench] +fn cached_thread_local(b: &mut test::Bencher) { + let local = CachedThreadLocal::new(); + b.iter(|| { let _: &i32 = local.get_or(|| Box::new(0)); }); +} diff --git a/third_party/cargo/vendor/thread_local-1.0.1/src/cached.rs b/third_party/cargo/vendor/thread_local-1.0.1/src/cached.rs new file mode 100644 index 0000000..ab43c86 --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/src/cached.rs @@ -0,0 +1,198 @@ +use super::{IntoIter, IterMut, ThreadLocal}; +use std::cell::UnsafeCell; +use std::fmt; +use std::panic::UnwindSafe; +use std::sync::atomic::{AtomicUsize, Ordering}; +use thread_id; +use unreachable::{UncheckedOptionExt, UncheckedResultExt}; + +/// Wrapper around `ThreadLocal` which adds a fast path for a single thread. +/// +/// This has the same API as `ThreadLocal`, but will register the first thread +/// that sets a value as its owner. All accesses by the owner will go through +/// a special fast path which is much faster than the normal `ThreadLocal` path. +pub struct CachedThreadLocal<T: Send> { + owner: AtomicUsize, + local: UnsafeCell<Option<Box<T>>>, + global: ThreadLocal<T>, +} + +// CachedThreadLocal is always Sync, even if T isn't +unsafe impl<T: Send> Sync for CachedThreadLocal<T> {} + +impl<T: Send> Default for CachedThreadLocal<T> { + fn default() -> CachedThreadLocal<T> { + CachedThreadLocal::new() + } +} + +impl<T: Send> CachedThreadLocal<T> { + /// Creates a new empty `CachedThreadLocal`. + pub fn new() -> CachedThreadLocal<T> { + CachedThreadLocal { + owner: AtomicUsize::new(0), + local: UnsafeCell::new(None), + global: ThreadLocal::new(), + } + } + + /// Returns the element for the current thread, if it exists. + pub fn get(&self) -> Option<&T> { + let id = thread_id::get(); + let owner = self.owner.load(Ordering::Relaxed); + if owner == id { + return unsafe { Some((*self.local.get()).as_ref().unchecked_unwrap()) }; + } + if owner == 0 { + return None; + } + self.global.get_fast(id) + } + + /// Returns the element for the current thread, or creates it if it doesn't + /// exist. + #[inline(always)] + pub fn get_or<F>(&self, create: F) -> &T + where + F: FnOnce() -> T, + { + unsafe { + self.get_or_try(|| Ok::<T, ()>(create())) + .unchecked_unwrap_ok() + } + } + + /// Returns the element for the current thread, or creates it if it doesn't + /// exist. If `create` fails, that error is returned and no element is + /// added. + pub fn get_or_try<F, E>(&self, create: F) -> Result<&T, E> + where + F: FnOnce() -> Result<T, E>, + { + let id = thread_id::get(); + let owner = self.owner.load(Ordering::Relaxed); + if owner == id { + return Ok(unsafe { (*self.local.get()).as_ref().unchecked_unwrap() }); + } + self.get_or_try_slow(id, owner, create) + } + + #[cold] + #[inline(never)] + fn get_or_try_slow<F, E>(&self, id: usize, owner: usize, create: F) -> Result<&T, E> + where + F: FnOnce() -> Result<T, E>, + { + if owner == 0 && self.owner.compare_and_swap(0, id, Ordering::Relaxed) == 0 { + unsafe { + (*self.local.get()) = Some(Box::new(create()?)); + return Ok((*self.local.get()).as_ref().unchecked_unwrap()); + } + } + match self.global.get_fast(id) { + Some(x) => Ok(x), + None => Ok(self.global.insert(id, Box::new(create()?), true)), + } + } + + /// Returns a mutable iterator over the local values of all threads. + /// + /// Since this call borrows the `ThreadLocal` mutably, this operation can + /// be done safely---the mutable borrow statically guarantees no other + /// threads are currently accessing their associated values. + pub fn iter_mut(&mut self) -> CachedIterMut<T> { + CachedIterMut { + local: unsafe { (*self.local.get()).as_mut().map(|x| &mut **x) }, + global: self.global.iter_mut(), + } + } + + /// Removes all thread-specific values from the `ThreadLocal`, effectively + /// reseting it to its original state. + /// + /// Since this call borrows the `ThreadLocal` mutably, this operation can + /// be done safely---the mutable borrow statically guarantees no other + /// threads are currently accessing their associated values. + pub fn clear(&mut self) { + *self = CachedThreadLocal::new(); + } +} + +impl<T: Send> IntoIterator for CachedThreadLocal<T> { + type Item = T; + type IntoIter = CachedIntoIter<T>; + + fn into_iter(self) -> CachedIntoIter<T> { + CachedIntoIter { + local: unsafe { (*self.local.get()).take().map(|x| *x) }, + global: self.global.into_iter(), + } + } +} + +impl<'a, T: Send + 'a> IntoIterator for &'a mut CachedThreadLocal<T> { + type Item = &'a mut T; + type IntoIter = CachedIterMut<'a, T>; + + fn into_iter(self) -> CachedIterMut<'a, T> { + self.iter_mut() + } +} + +impl<T: Send + Default> CachedThreadLocal<T> { + /// Returns the element for the current thread, or creates a default one if + /// it doesn't exist. + pub fn get_or_default(&self) -> &T { + self.get_or(T::default) + } +} + +impl<T: Send + fmt::Debug> fmt::Debug for CachedThreadLocal<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ThreadLocal {{ local_data: {:?} }}", self.get()) + } +} + +impl<T: Send + UnwindSafe> UnwindSafe for CachedThreadLocal<T> {} + +/// Mutable iterator over the contents of a `CachedThreadLocal`. +pub struct CachedIterMut<'a, T: Send + 'a> { + local: Option<&'a mut T>, + global: IterMut<'a, T>, +} + +impl<'a, T: Send + 'a> Iterator for CachedIterMut<'a, T> { + type Item = &'a mut T; + + fn next(&mut self) -> Option<&'a mut T> { + self.local.take().or_else(|| self.global.next()) + } + + fn size_hint(&self) -> (usize, Option<usize>) { + let len = self.global.size_hint().0 + self.local.is_some() as usize; + (len, Some(len)) + } +} + +impl<'a, T: Send + 'a> ExactSizeIterator for CachedIterMut<'a, T> {} + +/// An iterator that moves out of a `CachedThreadLocal`. +pub struct CachedIntoIter<T: Send> { + local: Option<T>, + global: IntoIter<T>, +} + +impl<T: Send> Iterator for CachedIntoIter<T> { + type Item = T; + + fn next(&mut self) -> Option<T> { + self.local.take().or_else(|| self.global.next()) + } + + fn size_hint(&self) -> (usize, Option<usize>) { + let len = self.global.size_hint().0 + self.local.is_some() as usize; + (len, Some(len)) + } +} + +impl<T: Send> ExactSizeIterator for CachedIntoIter<T> {} diff --git a/third_party/cargo/vendor/thread_local-1.0.1/src/lib.rs b/third_party/cargo/vendor/thread_local-1.0.1/src/lib.rs new file mode 100644 index 0000000..9fd6d19 --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/src/lib.rs @@ -0,0 +1,607 @@ +// Copyright 2017 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or +// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or +// http://opensource.org/licenses/MIT>, at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +//! Per-object thread-local storage +//! +//! This library provides the `ThreadLocal` type which allows a separate copy of +//! an object to be used for each thread. This allows for per-object +//! thread-local storage, unlike the standard library's `thread_local!` macro +//! which only allows static thread-local storage. +//! +//! Per-thread objects are not destroyed when a thread exits. Instead, objects +//! are only destroyed when the `ThreadLocal` containing them is destroyed. +//! +//! You can also iterate over the thread-local values of all thread in a +//! `ThreadLocal` object using the `iter_mut` and `into_iter` methods. This can +//! only be done if you have mutable access to the `ThreadLocal` object, which +//! guarantees that you are the only thread currently accessing it. +//! +//! A `CachedThreadLocal` type is also provided which wraps a `ThreadLocal` but +//! also uses a special fast path for the first thread that writes into it. The +//! fast path has very low overhead (<1ns per access) while keeping the same +//! performance as `ThreadLocal` for other threads. +//! +//! Note that since thread IDs are recycled when a thread exits, it is possible +//! for one thread to retrieve the object of another thread. Since this can only +//! occur after a thread has exited this does not lead to any race conditions. +//! +//! # Examples +//! +//! Basic usage of `ThreadLocal`: +//! +//! ```rust +//! use thread_local::ThreadLocal; +//! let tls: ThreadLocal<u32> = ThreadLocal::new(); +//! assert_eq!(tls.get(), None); +//! assert_eq!(tls.get_or(|| 5), &5); +//! assert_eq!(tls.get(), Some(&5)); +//! ``` +//! +//! Combining thread-local values into a single result: +//! +//! ```rust +//! use thread_local::ThreadLocal; +//! use std::sync::Arc; +//! use std::cell::Cell; +//! use std::thread; +//! +//! let tls = Arc::new(ThreadLocal::new()); +//! +//! // Create a bunch of threads to do stuff +//! for _ in 0..5 { +//! let tls2 = tls.clone(); +//! thread::spawn(move || { +//! // Increment a counter to count some event... +//! let cell = tls2.get_or(|| Cell::new(0)); +//! cell.set(cell.get() + 1); +//! }).join().unwrap(); +//! } +//! +//! // Once all threads are done, collect the counter values and return the +//! // sum of all thread-local counter values. +//! let tls = Arc::try_unwrap(tls).unwrap(); +//! let total = tls.into_iter().fold(0, |x, y| x + y.get()); +//! assert_eq!(total, 5); +//! ``` + +#![warn(missing_docs)] + +#[macro_use] +extern crate lazy_static; + +mod thread_id; +mod unreachable; +mod cached; + +pub use cached::{CachedIntoIter, CachedIterMut, CachedThreadLocal}; + +use std::cell::UnsafeCell; +use std::fmt; +use std::marker::PhantomData; +use std::panic::UnwindSafe; +use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; +use std::sync::Mutex; +use unreachable::{UncheckedOptionExt, UncheckedResultExt}; + +/// Thread-local variable wrapper +/// +/// See the [module-level documentation](index.html) for more. +pub struct ThreadLocal<T: Send> { + // Pointer to the current top-level hash table + table: AtomicPtr<Table<T>>, + + // Lock used to guard against concurrent modifications. This is only taken + // while writing to the table, not when reading from it. This also guards + // the counter for the total number of values in the hash table. + lock: Mutex<usize>, +} + +struct Table<T: Send> { + // Hash entries for the table + entries: Box<[TableEntry<T>]>, + + // Number of bits used for the hash function + hash_bits: usize, + + // Previous table, half the size of the current one + prev: Option<Box<Table<T>>>, +} + +struct TableEntry<T: Send> { + // Current owner of this entry, or 0 if this is an empty entry + owner: AtomicUsize, + + // The object associated with this entry. This is only ever accessed by the + // owner of the entry. + data: UnsafeCell<Option<Box<T>>>, +} + +// ThreadLocal is always Sync, even if T isn't +unsafe impl<T: Send> Sync for ThreadLocal<T> {} + +impl<T: Send> Default for ThreadLocal<T> { + fn default() -> ThreadLocal<T> { + ThreadLocal::new() + } +} + +impl<T: Send> Drop for ThreadLocal<T> { + fn drop(&mut self) { + unsafe { + Box::from_raw(self.table.load(Ordering::Relaxed)); + } + } +} + +// Implementation of Clone for TableEntry, needed to make vec![] work +impl<T: Send> Clone for TableEntry<T> { + fn clone(&self) -> TableEntry<T> { + TableEntry { + owner: AtomicUsize::new(0), + data: UnsafeCell::new(None), + } + } +} + +// Hash function for the thread id +#[cfg(target_pointer_width = "32")] +#[inline] +fn hash(id: usize, bits: usize) -> usize { + id.wrapping_mul(0x9E3779B9) >> (32 - bits) +} +#[cfg(target_pointer_width = "64")] +#[inline] +fn hash(id: usize, bits: usize) -> usize { + id.wrapping_mul(0x9E37_79B9_7F4A_7C15) >> (64 - bits) +} + +impl<T: Send> ThreadLocal<T> { + /// Creates a new empty `ThreadLocal`. + pub fn new() -> ThreadLocal<T> { + let entry = TableEntry { + owner: AtomicUsize::new(0), + data: UnsafeCell::new(None), + }; + let table = Table { + entries: vec![entry; 2].into_boxed_slice(), + hash_bits: 1, + prev: None, + }; + ThreadLocal { + table: AtomicPtr::new(Box::into_raw(Box::new(table))), + lock: Mutex::new(0), + } + } + + /// Returns the element for the current thread, if it exists. + pub fn get(&self) -> Option<&T> { + let id = thread_id::get(); + self.get_fast(id) + } + + /// Returns the element for the current thread, or creates it if it doesn't + /// exist. + pub fn get_or<F>(&self, create: F) -> &T + where + F: FnOnce() -> T, + { + unsafe { + self.get_or_try(|| Ok::<T, ()>(create())) + .unchecked_unwrap_ok() + } + } + + /// Returns the element for the current thread, or creates it if it doesn't + /// exist. If `create` fails, that error is returned and no element is + /// added. + pub fn get_or_try<F, E>(&self, create: F) -> Result<&T, E> + where + F: FnOnce() -> Result<T, E>, + { + let id = thread_id::get(); + match self.get_fast(id) { + Some(x) => Ok(x), + None => Ok(self.insert(id, Box::new(create()?), true)), + } + } + + // Simple hash table lookup function + fn lookup(id: usize, table: &Table<T>) -> Option<&UnsafeCell<Option<Box<T>>>> { + // Because we use a Mutex to prevent concurrent modifications (but not + // reads) of the hash table, we can avoid any memory barriers here. No + // elements between our hash bucket and our value can have been modified + // since we inserted our thread-local value into the table. + for entry in table.entries.iter().cycle().skip(hash(id, table.hash_bits)) { + let owner = entry.owner.load(Ordering::Relaxed); + if owner == id { + return Some(&entry.data); + } + if owner == 0 { + return None; + } + } + unreachable!(); + } + + // Fast path: try to find our thread in the top-level hash table + fn get_fast(&self, id: usize) -> Option<&T> { + let table = unsafe { &*self.table.load(Ordering::Acquire) }; + match Self::lookup(id, table) { + Some(x) => unsafe { Some((*x.get()).as_ref().unchecked_unwrap()) }, + None => self.get_slow(id, table), + } + } + + // Slow path: try to find our thread in the other hash tables, and then + // move it to the top-level hash table. + #[cold] + fn get_slow(&self, id: usize, table_top: &Table<T>) -> Option<&T> { + let mut current = &table_top.prev; + while let Some(ref table) = *current { + if let Some(x) = Self::lookup(id, table) { + let data = unsafe { (*x.get()).take().unchecked_unwrap() }; + return Some(self.insert(id, data, false)); + } + current = &table.prev; + } + None + } + + #[cold] + fn insert(&self, id: usize, data: Box<T>, new: bool) -> &T { + // Lock the Mutex to ensure only a single thread is modify the hash + // table at once. + let mut count = self.lock.lock().unwrap(); + if new { + *count += 1; + } + let table_raw = self.table.load(Ordering::Relaxed); + let table = unsafe { &*table_raw }; + + // If the current top-level hash table is more than 75% full, add a new + // level with 2x the capacity. Elements will be moved up to the new top + // level table as they are accessed. + let table = if *count > table.entries.len() * 3 / 4 { + let entry = TableEntry { + owner: AtomicUsize::new(0), + data: UnsafeCell::new(None), + }; + let new_table = Box::into_raw(Box::new(Table { + entries: vec![entry; table.entries.len() * 2].into_boxed_slice(), + hash_bits: table.hash_bits + 1, + prev: unsafe { Some(Box::from_raw(table_raw)) }, + })); + self.table.store(new_table, Ordering::Release); + unsafe { &*new_table } + } else { + table + }; + + // Insert the new element into the top-level hash table + for entry in table.entries.iter().cycle().skip(hash(id, table.hash_bits)) { + let owner = entry.owner.load(Ordering::Relaxed); + if owner == 0 { + unsafe { + entry.owner.store(id, Ordering::Relaxed); + *entry.data.get() = Some(data); + return (*entry.data.get()).as_ref().unchecked_unwrap(); + } + } + if owner == id { + // This can happen if create() inserted a value into this + // ThreadLocal between our calls to get_fast() and insert(). We + // just return the existing value and drop the newly-allocated + // Box. + unsafe { + return (*entry.data.get()).as_ref().unchecked_unwrap(); + } + } + } + unreachable!(); + } + + fn raw_iter(&mut self) -> RawIter<T> { + RawIter { + remaining: *self.lock.get_mut().unwrap(), + index: 0, + table: self.table.load(Ordering::Relaxed), + } + } + + /// Returns a mutable iterator over the local values of all threads. + /// + /// Since this call borrows the `ThreadLocal` mutably, this operation can + /// be done safely---the mutable borrow statically guarantees no other + /// threads are currently accessing their associated values. + pub fn iter_mut(&mut self) -> IterMut<T> { + IterMut { + raw: self.raw_iter(), + marker: PhantomData, + } + } + + /// Removes all thread-specific values from the `ThreadLocal`, effectively + /// reseting it to its original state. + /// + /// Since this call borrows the `ThreadLocal` mutably, this operation can + /// be done safely---the mutable borrow statically guarantees no other + /// threads are currently accessing their associated values. + pub fn clear(&mut self) { + *self = ThreadLocal::new(); + } +} + +impl<T: Send> IntoIterator for ThreadLocal<T> { + type Item = T; + type IntoIter = IntoIter<T>; + + fn into_iter(mut self) -> IntoIter<T> { + IntoIter { + raw: self.raw_iter(), + _thread_local: self, + } + } +} + +impl<'a, T: Send + 'a> IntoIterator for &'a mut ThreadLocal<T> { + type Item = &'a mut T; + type IntoIter = IterMut<'a, T>; + + fn into_iter(self) -> IterMut<'a, T> { + self.iter_mut() + } +} + +impl<T: Send + Default> ThreadLocal<T> { + /// Returns the element for the current thread, or creates a default one if + /// it doesn't exist. + pub fn get_or_default(&self) -> &T { + self.get_or(Default::default) + } +} + +impl<T: Send + fmt::Debug> fmt::Debug for ThreadLocal<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ThreadLocal {{ local_data: {:?} }}", self.get()) + } +} + +impl<T: Send + UnwindSafe> UnwindSafe for ThreadLocal<T> {} + +struct RawIter<T: Send> { + remaining: usize, + index: usize, + table: *const Table<T>, +} + +impl<T: Send> Iterator for RawIter<T> { + type Item = *mut Option<Box<T>>; + + fn next(&mut self) -> Option<*mut Option<Box<T>>> { + if self.remaining == 0 { + return None; + } + + loop { + let entries = unsafe { &(*self.table).entries[..] }; + while self.index < entries.len() { + let val = entries[self.index].data.get(); + self.index += 1; + if unsafe { (*val).is_some() } { + self.remaining -= 1; + return Some(val); + } + } + self.index = 0; + self.table = unsafe { &**(*self.table).prev.as_ref().unchecked_unwrap() }; + } + } + + fn size_hint(&self) -> (usize, Option<usize>) { + (self.remaining, Some(self.remaining)) + } +} + +/// Mutable iterator over the contents of a `ThreadLocal`. +pub struct IterMut<'a, T: Send + 'a> { + raw: RawIter<T>, + marker: PhantomData<&'a mut ThreadLocal<T>>, +} + +impl<'a, T: Send + 'a> Iterator for IterMut<'a, T> { + type Item = &'a mut T; + + fn next(&mut self) -> Option<&'a mut T> { + self.raw + .next() + .map(|x| unsafe { &mut **(*x).as_mut().unchecked_unwrap() }) + } + + fn size_hint(&self) -> (usize, Option<usize>) { + self.raw.size_hint() + } +} + +impl<'a, T: Send + 'a> ExactSizeIterator for IterMut<'a, T> {} + +/// An iterator that moves out of a `ThreadLocal`. +pub struct IntoIter<T: Send> { + raw: RawIter<T>, + _thread_local: ThreadLocal<T>, +} + +impl<T: Send> Iterator for IntoIter<T> { + type Item = T; + + fn next(&mut self) -> Option<T> { + self.raw + .next() + .map(|x| unsafe { *(*x).take().unchecked_unwrap() }) + } + + fn size_hint(&self) -> (usize, Option<usize>) { + self.raw.size_hint() + } +} + +impl<T: Send> ExactSizeIterator for IntoIter<T> {} + +#[cfg(test)] +mod tests { + use super::{CachedThreadLocal, ThreadLocal}; + use std::cell::RefCell; + use std::sync::atomic::AtomicUsize; + use std::sync::atomic::Ordering::Relaxed; + use std::sync::Arc; + use std::thread; + + fn make_create() -> Arc<dyn Fn() -> usize + Send + Sync> { + let count = AtomicUsize::new(0); + Arc::new(move || count.fetch_add(1, Relaxed)) + } + + #[test] + fn same_thread() { + let create = make_create(); + let mut tls = ThreadLocal::new(); + assert_eq!(None, tls.get()); + assert_eq!("ThreadLocal { local_data: None }", format!("{:?}", &tls)); + assert_eq!(0, *tls.get_or(|| create())); + assert_eq!(Some(&0), tls.get()); + assert_eq!(0, *tls.get_or(|| create())); + assert_eq!(Some(&0), tls.get()); + assert_eq!(0, *tls.get_or(|| create())); + assert_eq!(Some(&0), tls.get()); + assert_eq!("ThreadLocal { local_data: Some(0) }", format!("{:?}", &tls)); + tls.clear(); + assert_eq!(None, tls.get()); + } + + #[test] + fn same_thread_cached() { + let create = make_create(); + let mut tls = CachedThreadLocal::new(); + assert_eq!(None, tls.get()); + assert_eq!("ThreadLocal { local_data: None }", format!("{:?}", &tls)); + assert_eq!(0, *tls.get_or(|| create())); + assert_eq!(Some(&0), tls.get()); + assert_eq!(0, *tls.get_or(|| create())); + assert_eq!(Some(&0), tls.get()); + assert_eq!(0, *tls.get_or(|| create())); + assert_eq!(Some(&0), tls.get()); + assert_eq!("ThreadLocal { local_data: Some(0) }", format!("{:?}", &tls)); + tls.clear(); + assert_eq!(None, tls.get()); + } + + #[test] + fn different_thread() { + let create = make_create(); + let tls = Arc::new(ThreadLocal::new()); + assert_eq!(None, tls.get()); + assert_eq!(0, *tls.get_or(|| create())); + assert_eq!(Some(&0), tls.get()); + + let tls2 = tls.clone(); + let create2 = create.clone(); + thread::spawn(move || { + assert_eq!(None, tls2.get()); + assert_eq!(1, *tls2.get_or(|| create2())); + assert_eq!(Some(&1), tls2.get()); + }) + .join() + .unwrap(); + + assert_eq!(Some(&0), tls.get()); + assert_eq!(0, *tls.get_or(|| create())); + } + + #[test] + fn different_thread_cached() { + let create = make_create(); + let tls = Arc::new(CachedThreadLocal::new()); + assert_eq!(None, tls.get()); + assert_eq!(0, *tls.get_or(|| create())); + assert_eq!(Some(&0), tls.get()); + + let tls2 = tls.clone(); + let create2 = create.clone(); + thread::spawn(move || { + assert_eq!(None, tls2.get()); + assert_eq!(1, *tls2.get_or(|| create2())); + assert_eq!(Some(&1), tls2.get()); + }) + .join() + .unwrap(); + + assert_eq!(Some(&0), tls.get()); + assert_eq!(0, *tls.get_or(|| create())); + } + + #[test] + fn iter() { + let tls = Arc::new(ThreadLocal::new()); + tls.get_or(|| Box::new(1)); + + let tls2 = tls.clone(); + thread::spawn(move || { + tls2.get_or(|| Box::new(2)); + let tls3 = tls2.clone(); + thread::spawn(move || { + tls3.get_or(|| Box::new(3)); + }) + .join() + .unwrap(); + }) + .join() + .unwrap(); + + let mut tls = Arc::try_unwrap(tls).unwrap(); + let mut v = tls.iter_mut().map(|x| **x).collect::<Vec<i32>>(); + v.sort(); + assert_eq!(vec![1, 2, 3], v); + let mut v = tls.into_iter().map(|x| *x).collect::<Vec<i32>>(); + v.sort(); + assert_eq!(vec![1, 2, 3], v); + } + + #[test] + fn iter_cached() { + let tls = Arc::new(CachedThreadLocal::new()); + tls.get_or(|| Box::new(1)); + + let tls2 = tls.clone(); + thread::spawn(move || { + tls2.get_or(|| Box::new(2)); + let tls3 = tls2.clone(); + thread::spawn(move || { + tls3.get_or(|| Box::new(3)); + }) + .join() + .unwrap(); + }) + .join() + .unwrap(); + + let mut tls = Arc::try_unwrap(tls).unwrap(); + let mut v = tls.iter_mut().map(|x| **x).collect::<Vec<i32>>(); + v.sort(); + assert_eq!(vec![1, 2, 3], v); + let mut v = tls.into_iter().map(|x| *x).collect::<Vec<i32>>(); + v.sort(); + assert_eq!(vec![1, 2, 3], v); + } + + #[test] + fn is_sync() { + fn foo<T: Sync>() {} + foo::<ThreadLocal<String>>(); + foo::<ThreadLocal<RefCell<String>>>(); + foo::<CachedThreadLocal<String>>(); + foo::<CachedThreadLocal<RefCell<String>>>(); + } +} diff --git a/third_party/cargo/vendor/thread_local-1.0.1/src/thread_id.rs b/third_party/cargo/vendor/thread_local-1.0.1/src/thread_id.rs new file mode 100644 index 0000000..e757948 --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/src/thread_id.rs @@ -0,0 +1,61 @@ +// Copyright 2017 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or +// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or +// http://opensource.org/licenses/MIT>, at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +use std::collections::BinaryHeap; +use std::sync::Mutex; +use std::usize; + +// Thread ID manager which allocates thread IDs. It attempts to aggressively +// reuse thread IDs where possible to avoid cases where a ThreadLocal grows +// indefinitely when it is used by many short-lived threads. +struct ThreadIdManager { + limit: usize, + free_list: BinaryHeap<usize>, +} +impl ThreadIdManager { + fn new() -> ThreadIdManager { + ThreadIdManager { + limit: usize::MAX, + free_list: BinaryHeap::new(), + } + } + fn alloc(&mut self) -> usize { + if let Some(id) = self.free_list.pop() { + id + } else { + let id = self.limit; + self.limit = self.limit.checked_sub(1).expect("Ran out of thread IDs"); + id + } + } + fn free(&mut self, id: usize) { + self.free_list.push(id); + } +} +lazy_static! { + static ref THREAD_ID_MANAGER: Mutex<ThreadIdManager> = Mutex::new(ThreadIdManager::new()); +} + +// Non-zero integer which is unique to the current thread while it is running. +// A thread ID may be reused after a thread exits. +struct ThreadId(usize); +impl ThreadId { + fn new() -> ThreadId { + ThreadId(THREAD_ID_MANAGER.lock().unwrap().alloc()) + } +} +impl Drop for ThreadId { + fn drop(&mut self) { + THREAD_ID_MANAGER.lock().unwrap().free(self.0); + } +} +thread_local!(static THREAD_ID: ThreadId = ThreadId::new()); + +/// Returns a non-zero ID for the current thread +pub fn get() -> usize { + THREAD_ID.with(|x| x.0) +} diff --git a/third_party/cargo/vendor/thread_local-1.0.1/src/unreachable.rs b/third_party/cargo/vendor/thread_local-1.0.1/src/unreachable.rs new file mode 100644 index 0000000..baff766 --- /dev/null +++ b/third_party/cargo/vendor/thread_local-1.0.1/src/unreachable.rs @@ -0,0 +1,74 @@ +// Copyright 2017 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or +// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or +// http://opensource.org/licenses/MIT>, at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +//! # unreachable +//! inlined from https://github.com/reem/rust-unreachable/ +//! +//! An unreachable code optimization hint in stable rust, and some useful +//! extension traits for `Option` and `Result`. +//! + +/// Hint to the optimizer that any code path which calls this function is +/// statically unreachable and can be removed. +/// +/// Calling this function in reachable code invokes undefined behavior. Be +/// very, very sure this is what you want; often, a simple `panic!` is more +/// suitable. +#[inline] +pub unsafe fn unreachable() -> ! { + /// The empty type for cases which can't occur. + enum Void { } + let x: &Void = ::std::mem::transmute(1usize); + match *x {} +} + +/// An extension trait for `Option<T>` providing unchecked unwrapping methods. +pub trait UncheckedOptionExt<T> { + /// Get the value out of this Option without checking for None. + unsafe fn unchecked_unwrap(self) -> T; + + /// Assert that this Option is a None to the optimizer. + unsafe fn unchecked_unwrap_none(self); +} + +/// An extension trait for `Result<T, E>` providing unchecked unwrapping methods. +pub trait UncheckedResultExt<T, E> { + /// Get the value out of this Result without checking for Err. + unsafe fn unchecked_unwrap_ok(self) -> T; + + /// Get the error out of this Result without checking for Ok. + unsafe fn unchecked_unwrap_err(self) -> E; +} + +impl<T> UncheckedOptionExt<T> for Option<T> { + unsafe fn unchecked_unwrap(self) -> T { + match self { + Some(x) => x, + None => unreachable() + } + } + + unsafe fn unchecked_unwrap_none(self) { + if self.is_some() { unreachable() } + } +} + +impl<T, E> UncheckedResultExt<T, E> for Result<T, E> { + unsafe fn unchecked_unwrap_ok(self) -> T { + match self { + Ok(x) => x, + Err(_) => unreachable() + } + } + + unsafe fn unchecked_unwrap_err(self) -> E { + match self { + Ok(_) => unreachable(), + Err(e) => e + } + } +} \ No newline at end of file diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/.cargo-checksum.json b/third_party/cargo/vendor/unicode-xid-0.1.0/.cargo-checksum.json new file mode 100644 index 0000000..60faf25 --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"COPYRIGHT":"23860c2a7b5d96b21569afedf033469bab9fe14a1b24a35068b8641c578ce24d","Cargo.toml":"aafcae4002bee71546a6aa40a97b9124a69f169ee7e3a9e3262338e32b4c2b9b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"7b63ecd5f1902af1b63729947373683c32745c16a10e8e6292e2e2dcd7e90ae0","README.md":"67998486b32f4fe46abbbaa411b92528750e7f0e22452dc8a5b95d87d80fde75","scripts/unicode.py":"762eea92dd51238c6bf877570bde1149932ba15cf87be1618fc21cd53e941733","src/lib.rs":"4a89fadf452ae7c53536eaa4496f951a3153f8189dd1cbc532648731d30f0b11","src/tables.rs":"0643459b6ebeeed83aecd7604f0ea29c06bea7ce6c1cd9acd4988d27ace1ec53","src/tests.rs":"35a459382e190197e7b9a78832ae79f310b48a02a5b4227bf9bbc89d46c8deac"},"package":"fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"} \ No newline at end of file diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/BUILD b/third_party/cargo/vendor/unicode-xid-0.1.0/BUILD new file mode 100644 index 0000000..544be2c --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "unicode_xid", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.0", + crate_features = [ + "default", + ], +) + diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/COPYRIGHT b/third_party/cargo/vendor/unicode-xid-0.1.0/COPYRIGHT new file mode 100644 index 0000000..b286ec1 --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/COPYRIGHT @@ -0,0 +1,7 @@ +Licensed under the Apache License, Version 2.0 +<LICENSE-APACHE or +http://www.apache.org/licenses/LICENSE-2.0> or the MIT +license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +at your option. All files in the project carrying such +notice may not be copied, modified, or distributed except +according to those terms. diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/Cargo.toml b/third_party/cargo/vendor/unicode-xid-0.1.0/Cargo.toml new file mode 100644 index 0000000..b9b69b2 --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/Cargo.toml @@ -0,0 +1,26 @@ +[package] + +name = "unicode-xid" +version = "0.1.0" +authors = ["erick.tryzelaar <erick.tryzelaar@gmail.com>", + "kwantam <kwantam@gmail.com>", + ] + +homepage = "https://github.com/unicode-rs/unicode-xid" +repository = "https://github.com/unicode-rs/unicode-xid" +documentation = "https://unicode-rs.github.io/unicode-xid" +license = "MIT/Apache-2.0" +keywords = ["text", "unicode", "xid"] +readme = "README.md" +description = """ +Determine whether characters have the XID_Start +or XID_Continue properties according to +Unicode Standard Annex #31. +""" + +exclude = [ "target/*", "Cargo.lock" ] + +[features] +default = [] +no_std = [] +bench = [] diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/LICENSE-APACHE b/third_party/cargo/vendor/unicode-xid-0.1.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/LICENSE-MIT b/third_party/cargo/vendor/unicode-xid-0.1.0/LICENSE-MIT new file mode 100644 index 0000000..e69282e --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2015 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/README.md b/third_party/cargo/vendor/unicode-xid-0.1.0/README.md new file mode 100644 index 0000000..3a2be47 --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/README.md @@ -0,0 +1,34 @@ +# unicode-xid + +Determine if a `char` is a valid identifier for a parser and/or lexer according to +[Unicode Standard Annex #31](http://www.unicode.org/reports/tr31/) rules. + +[![Build Status](https://travis-ci.org/unicode-rs/unicode-xid.svg)](https://travis-ci.org/unicode-rs/unicode-xid) + +[Documentation](https://unicode-rs.github.io/unicode-xid/unicode_xid/index.html) + +```rust +extern crate unicode_xid; + +use unicode_xid::UnicodeXID; + +fn main() { + let ch = 'a'; + println!("Is {} a valid start of an identifier? {}", ch, UnicodeXID::is_xid_start(ch)); +} +``` + +# features + +unicode-xid supports a `no_std` feature. This eliminates dependence +on std, and instead uses equivalent functions from core. + +# crates.io + +You can use this package in your project by adding the following +to your `Cargo.toml`: + +```toml +[dependencies] +unicode-xid = "0.0.4" +``` diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/scripts/unicode.py b/third_party/cargo/vendor/unicode-xid-0.1.0/scripts/unicode.py new file mode 100755 index 0000000..a30d2f2 --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/scripts/unicode.py @@ -0,0 +1,187 @@ +#!/usr/bin/env python +# +# Copyright 2011-2015 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +# This script uses the following Unicode tables: +# - DerivedCoreProperties.txt +# - ReadMe.txt +# +# Since this should not require frequent updates, we just store this +# out-of-line and check the unicode.rs file into git. + +import fileinput, re, os, sys + +preamble = '''// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly + +#![allow(missing_docs, non_upper_case_globals, non_snake_case)] +''' + +def fetch(f): + if not os.path.exists(os.path.basename(f)): + os.system("curl -O http://www.unicode.org/Public/UNIDATA/%s" + % f) + + if not os.path.exists(os.path.basename(f)): + sys.stderr.write("cannot load %s" % f) + exit(1) + +def group_cat(cat): + cat_out = [] + letters = sorted(set(cat)) + cur_start = letters.pop(0) + cur_end = cur_start + for letter in letters: + assert letter > cur_end, \ + "cur_end: %s, letter: %s" % (hex(cur_end), hex(letter)) + if letter == cur_end + 1: + cur_end = letter + else: + cat_out.append((cur_start, cur_end)) + cur_start = cur_end = letter + cat_out.append((cur_start, cur_end)) + return cat_out + +def ungroup_cat(cat): + cat_out = [] + for (lo, hi) in cat: + while lo <= hi: + cat_out.append(lo) + lo += 1 + return cat_out + +def format_table_content(f, content, indent): + line = " "*indent + first = True + for chunk in content.split(","): + if len(line) + len(chunk) < 98: + if first: + line += chunk + else: + line += ", " + chunk + first = False + else: + f.write(line + ",\n") + line = " "*indent + chunk + f.write(line) + +def load_properties(f, interestingprops): + fetch(f) + props = {} + re1 = re.compile("^ *([0-9A-F]+) *; *(\w+)") + re2 = re.compile("^ *([0-9A-F]+)\.\.([0-9A-F]+) *; *(\w+)") + + for line in fileinput.input(os.path.basename(f)): + prop = None + d_lo = 0 + d_hi = 0 + m = re1.match(line) + if m: + d_lo = m.group(1) + d_hi = m.group(1) + prop = m.group(2) + else: + m = re2.match(line) + if m: + d_lo = m.group(1) + d_hi = m.group(2) + prop = m.group(3) + else: + continue + if interestingprops and prop not in interestingprops: + continue + d_lo = int(d_lo, 16) + d_hi = int(d_hi, 16) + if prop not in props: + props[prop] = [] + props[prop].append((d_lo, d_hi)) + + # optimize if possible + for prop in props: + props[prop] = group_cat(ungroup_cat(props[prop])) + + return props + +def escape_char(c): + return "'\\u{%x}'" % c + +def emit_bsearch_range_table(f): + f.write(""" +fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { + use core::cmp::Ordering::{Equal, Less, Greater}; + + r.binary_search_by(|&(lo,hi)| { + if lo <= c && c <= hi { Equal } + else if hi < c { Less } + else { Greater } + }).is_ok() +}\n +""") + +def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True, + pfun=lambda x: "(%s,%s)" % (escape_char(x[0]), escape_char(x[1])), is_const=True): + pub_string = "const" + if not is_const: + pub_string = "let" + if is_pub: + pub_string = "pub " + pub_string + f.write(" %s %s: %s = &[\n" % (pub_string, name, t_type)) + data = "" + first = True + for dat in t_data: + if not first: + data += "," + first = False + data += pfun(dat) + format_table_content(f, data, 8) + f.write("\n ];\n\n") + +def emit_property_module(f, mod, tbl, emit): + f.write("pub mod %s {\n" % mod) + for cat in sorted(emit): + emit_table(f, "%s_table" % cat, tbl[cat]) + f.write(" pub fn %s(c: char) -> bool {\n" % cat) + f.write(" super::bsearch_range_table(c, %s_table)\n" % cat) + f.write(" }\n\n") + f.write("}\n\n") + +if __name__ == "__main__": + r = "tables.rs" + if os.path.exists(r): + os.remove(r) + with open(r, "w") as rf: + # write the file's preamble + rf.write(preamble) + + # download and parse all the data + fetch("ReadMe.txt") + with open("ReadMe.txt") as readme: + pattern = "for Version (\d+)\.(\d+)\.(\d+) of the Unicode" + unicode_version = re.search(pattern, readme.read()).groups() + rf.write(""" +/// The version of [Unicode](http://www.unicode.org/) +/// that this version of unicode-xid is based on. +pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s); +""" % unicode_version) + emit_bsearch_range_table(rf) + + want_derived = ["XID_Start", "XID_Continue"] + derived = load_properties("DerivedCoreProperties.txt", want_derived) + emit_property_module(rf, "derived_property", derived, want_derived) diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/src/lib.rs b/third_party/cargo/vendor/unicode-xid-0.1.0/src/lib.rs new file mode 100644 index 0000000..09faf97 --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/src/lib.rs @@ -0,0 +1,87 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Determine if a `char` is a valid identifier for a parser and/or lexer according to +//! [Unicode Standard Annex #31](http://www.unicode.org/reports/tr31/) rules. +//! +//! ```rust +//! extern crate unicode_xid; +//! +//! use unicode_xid::UnicodeXID; +//! +//! fn main() { +//! let ch = 'a'; +//! println!("Is {} a valid start of an identifier? {}", ch, UnicodeXID::is_xid_start(ch)); +//! } +//! ``` +//! +//! # features +//! +//! unicode-xid supports a `no_std` feature. This eliminates dependence +//! on std, and instead uses equivalent functions from core. +//! +//! # crates.io +//! +//! You can use this package in your project by adding the following +//! to your `Cargo.toml`: +//! +//! ```toml +//! [dependencies] +//! unicode-xid = "0.0.4" +//! ``` + +#![deny(missing_docs, unsafe_code)] +#![doc(html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png", + html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png")] + +#![no_std] +#![cfg_attr(feature = "bench", feature(test, unicode))] + +#[cfg(test)] +#[macro_use] +extern crate std; + +#[cfg(feature = "bench")] +extern crate test; + +use tables::derived_property; +pub use tables::UNICODE_VERSION; + +mod tables; + +#[cfg(test)] +mod tests; + +/// Methods for determining if a character is a valid identifier character. +pub trait UnicodeXID { + /// Returns whether the specified character satisfies the 'XID_Start' + /// Unicode property. + /// + /// 'XID_Start' is a Unicode Derived Property specified in + /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications), + /// mostly similar to ID_Start but modified for closure under NFKx. + fn is_xid_start(self) -> bool; + + /// Returns whether the specified `char` satisfies the 'XID_Continue' + /// Unicode property. + /// + /// 'XID_Continue' is a Unicode Derived Property specified in + /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications), + /// mostly similar to 'ID_Continue' but modified for closure under NFKx. + fn is_xid_continue(self) -> bool; +} + +impl UnicodeXID for char { + #[inline] + fn is_xid_start(self) -> bool { derived_property::XID_Start(self) } + + #[inline] + fn is_xid_continue(self) -> bool { derived_property::XID_Continue(self) } +} diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/src/tables.rs b/third_party/cargo/vendor/unicode-xid-0.1.0/src/tables.rs new file mode 100644 index 0000000..3fe0d3d --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/src/tables.rs @@ -0,0 +1,426 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly + +#![allow(missing_docs, non_upper_case_globals, non_snake_case)] + +/// The version of [Unicode](http://www.unicode.org/) +/// that this version of unicode-xid is based on. +pub const UNICODE_VERSION: (u64, u64, u64) = (9, 0, 0); + +fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { + use core::cmp::Ordering::{Equal, Less, Greater}; + + r.binary_search_by(|&(lo,hi)| { + if lo <= c && c <= hi { Equal } + else if hi < c { Less } + else { Greater } + }).is_ok() +} + +pub mod derived_property { + pub const XID_Continue_table: &'static [(char, char)] = &[ + ('\u{30}', '\u{39}'), ('\u{41}', '\u{5a}'), ('\u{5f}', '\u{5f}'), ('\u{61}', '\u{7a}'), + ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), ('\u{b7}', '\u{b7}'), ('\u{ba}', '\u{ba}'), + ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), + ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), ('\u{300}', + '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37b}', '\u{37d}'), ('\u{37f}', '\u{37f}'), + ('\u{386}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', + '\u{3f5}'), ('\u{3f7}', '\u{481}'), ('\u{483}', '\u{487}'), ('\u{48a}', '\u{52f}'), + ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), ('\u{561}', '\u{587}'), ('\u{591}', + '\u{5bd}'), ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), + ('\u{5c7}', '\u{5c7}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f2}'), ('\u{610}', + '\u{61a}'), ('\u{620}', '\u{669}'), ('\u{66e}', '\u{6d3}'), ('\u{6d5}', '\u{6dc}'), + ('\u{6df}', '\u{6e8}'), ('\u{6ea}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), ('\u{710}', + '\u{74a}'), ('\u{74d}', '\u{7b1}'), ('\u{7c0}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), + ('\u{800}', '\u{82d}'), ('\u{840}', '\u{85b}'), ('\u{8a0}', '\u{8b4}'), ('\u{8b6}', + '\u{8bd}'), ('\u{8d4}', '\u{8e1}'), ('\u{8e3}', '\u{963}'), ('\u{966}', '\u{96f}'), + ('\u{971}', '\u{983}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', + '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), + ('\u{9bc}', '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9ce}'), ('\u{9d7}', + '\u{9d7}'), ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e3}'), ('\u{9e6}', '\u{9f1}'), + ('\u{a01}', '\u{a03}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', + '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), + ('\u{a38}', '\u{a39}'), ('\u{a3c}', '\u{a3c}'), ('\u{a3e}', '\u{a42}'), ('\u{a47}', + '\u{a48}'), ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), ('\u{a59}', '\u{a5c}'), + ('\u{a5e}', '\u{a5e}'), ('\u{a66}', '\u{a75}'), ('\u{a81}', '\u{a83}'), ('\u{a85}', + '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), + ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abc}', '\u{ac5}'), ('\u{ac7}', + '\u{ac9}'), ('\u{acb}', '\u{acd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae3}'), + ('\u{ae6}', '\u{aef}'), ('\u{af9}', '\u{af9}'), ('\u{b01}', '\u{b03}'), ('\u{b05}', + '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), + ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3c}', '\u{b44}'), ('\u{b47}', + '\u{b48}'), ('\u{b4b}', '\u{b4d}'), ('\u{b56}', '\u{b57}'), ('\u{b5c}', '\u{b5d}'), + ('\u{b5f}', '\u{b63}'), ('\u{b66}', '\u{b6f}'), ('\u{b71}', '\u{b71}'), ('\u{b82}', + '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), + ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', + '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bbe}', '\u{bc2}'), + ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcd}'), ('\u{bd0}', '\u{bd0}'), ('\u{bd7}', + '\u{bd7}'), ('\u{be6}', '\u{bef}'), ('\u{c00}', '\u{c03}'), ('\u{c05}', '\u{c0c}'), + ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', + '\u{c44}'), ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), + ('\u{c58}', '\u{c5a}'), ('\u{c60}', '\u{c63}'), ('\u{c66}', '\u{c6f}'), ('\u{c80}', + '\u{c83}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), + ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbc}', '\u{cc4}'), ('\u{cc6}', + '\u{cc8}'), ('\u{cca}', '\u{ccd}'), ('\u{cd5}', '\u{cd6}'), ('\u{cde}', '\u{cde}'), + ('\u{ce0}', '\u{ce3}'), ('\u{ce6}', '\u{cef}'), ('\u{cf1}', '\u{cf2}'), ('\u{d01}', + '\u{d03}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), + ('\u{d3d}', '\u{d44}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4e}'), ('\u{d54}', + '\u{d57}'), ('\u{d5f}', '\u{d63}'), ('\u{d66}', '\u{d6f}'), ('\u{d7a}', '\u{d7f}'), + ('\u{d82}', '\u{d83}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', + '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{dca}', '\u{dca}'), + ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), ('\u{dd8}', '\u{ddf}'), ('\u{de6}', + '\u{def}'), ('\u{df2}', '\u{df3}'), ('\u{e01}', '\u{e3a}'), ('\u{e40}', '\u{e4e}'), + ('\u{e50}', '\u{e59}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e87}', + '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), + ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', + '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb9}'), ('\u{ebb}', '\u{ebd}'), + ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), ('\u{ec8}', '\u{ecd}'), ('\u{ed0}', + '\u{ed9}'), ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f18}', '\u{f19}'), + ('\u{f20}', '\u{f29}'), ('\u{f35}', '\u{f35}'), ('\u{f37}', '\u{f37}'), ('\u{f39}', + '\u{f39}'), ('\u{f3e}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f71}', '\u{f84}'), + ('\u{f86}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), ('\u{fc6}', '\u{fc6}'), ('\u{1000}', + '\u{1049}'), ('\u{1050}', '\u{109d}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), + ('\u{10cd}', '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', + '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), + ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', + '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), + ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', + '\u{135a}'), ('\u{135d}', '\u{135f}'), ('\u{1369}', '\u{1371}'), ('\u{1380}', '\u{138f}'), + ('\u{13a0}', '\u{13f5}'), ('\u{13f8}', '\u{13fd}'), ('\u{1401}', '\u{166c}'), ('\u{166f}', + '\u{167f}'), ('\u{1681}', '\u{169a}'), ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), + ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1714}'), ('\u{1720}', '\u{1734}'), ('\u{1740}', + '\u{1753}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1772}', '\u{1773}'), + ('\u{1780}', '\u{17d3}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dd}'), ('\u{17e0}', + '\u{17e9}'), ('\u{180b}', '\u{180d}'), ('\u{1810}', '\u{1819}'), ('\u{1820}', '\u{1877}'), + ('\u{1880}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1920}', + '\u{192b}'), ('\u{1930}', '\u{193b}'), ('\u{1946}', '\u{196d}'), ('\u{1970}', '\u{1974}'), + ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{19d0}', '\u{19da}'), ('\u{1a00}', + '\u{1a1b}'), ('\u{1a20}', '\u{1a5e}'), ('\u{1a60}', '\u{1a7c}'), ('\u{1a7f}', '\u{1a89}'), + ('\u{1a90}', '\u{1a99}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1ab0}', '\u{1abd}'), ('\u{1b00}', + '\u{1b4b}'), ('\u{1b50}', '\u{1b59}'), ('\u{1b6b}', '\u{1b73}'), ('\u{1b80}', '\u{1bf3}'), + ('\u{1c00}', '\u{1c37}'), ('\u{1c40}', '\u{1c49}'), ('\u{1c4d}', '\u{1c7d}'), ('\u{1c80}', + '\u{1c88}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1cf6}'), ('\u{1cf8}', '\u{1cf9}'), + ('\u{1d00}', '\u{1df5}'), ('\u{1dfb}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', + '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), + ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', + '\u{1fb4}'), ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), + ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', + '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{203f}', '\u{2040}'), + ('\u{2054}', '\u{2054}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', + '\u{209c}'), ('\u{20d0}', '\u{20dc}'), ('\u{20e1}', '\u{20e1}'), ('\u{20e5}', '\u{20f0}'), + ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', + '\u{2115}'), ('\u{2118}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), + ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', + '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{2c00}', '\u{2c2e}'), + ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cf3}'), ('\u{2d00}', + '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), + ('\u{2d6f}', '\u{2d6f}'), ('\u{2d7f}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', + '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), + ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{2de0}', + '\u{2dff}'), ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{302f}'), ('\u{3031}', '\u{3035}'), + ('\u{3038}', '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{3099}', '\u{309a}'), ('\u{309d}', + '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', '\u{312d}'), + ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', + '\u{4db5}'), ('\u{4e00}', '\u{9fd5}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), + ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a62b}'), ('\u{a640}', '\u{a66f}'), ('\u{a674}', + '\u{a67d}'), ('\u{a67f}', '\u{a6f1}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'), + ('\u{a78b}', '\u{a7ae}'), ('\u{a7b0}', '\u{a7b7}'), ('\u{a7f7}', '\u{a827}'), ('\u{a840}', + '\u{a873}'), ('\u{a880}', '\u{a8c5}'), ('\u{a8d0}', '\u{a8d9}'), ('\u{a8e0}', '\u{a8f7}'), + ('\u{a8fb}', '\u{a8fb}'), ('\u{a8fd}', '\u{a8fd}'), ('\u{a900}', '\u{a92d}'), ('\u{a930}', + '\u{a953}'), ('\u{a960}', '\u{a97c}'), ('\u{a980}', '\u{a9c0}'), ('\u{a9cf}', '\u{a9d9}'), + ('\u{a9e0}', '\u{a9fe}'), ('\u{aa00}', '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), ('\u{aa50}', + '\u{aa59}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), + ('\u{aae0}', '\u{aaef}'), ('\u{aaf2}', '\u{aaf6}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', + '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), + ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab65}'), ('\u{ab70}', '\u{abea}'), ('\u{abec}', + '\u{abed}'), ('\u{abf0}', '\u{abf9}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), + ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', + '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), + ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', + '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fc5d}'), ('\u{fc64}', '\u{fd3d}'), + ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdf9}'), ('\u{fe00}', + '\u{fe0f}'), ('\u{fe20}', '\u{fe2f}'), ('\u{fe33}', '\u{fe34}'), ('\u{fe4d}', '\u{fe4f}'), + ('\u{fe71}', '\u{fe71}'), ('\u{fe73}', '\u{fe73}'), ('\u{fe77}', '\u{fe77}'), ('\u{fe79}', + '\u{fe79}'), ('\u{fe7b}', '\u{fe7b}'), ('\u{fe7d}', '\u{fe7d}'), ('\u{fe7f}', '\u{fefc}'), + ('\u{ff10}', '\u{ff19}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff3f}', '\u{ff3f}'), ('\u{ff41}', + '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), + ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), + ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), + ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'), + ('\u{10140}', '\u{10174}'), ('\u{101fd}', '\u{101fd}'), ('\u{10280}', '\u{1029c}'), + ('\u{102a0}', '\u{102d0}'), ('\u{102e0}', '\u{102e0}'), ('\u{10300}', '\u{1031f}'), + ('\u{10330}', '\u{1034a}'), ('\u{10350}', '\u{1037a}'), ('\u{10380}', '\u{1039d}'), + ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{103d1}', '\u{103d5}'), + ('\u{10400}', '\u{1049d}'), ('\u{104a0}', '\u{104a9}'), ('\u{104b0}', '\u{104d3}'), + ('\u{104d8}', '\u{104fb}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'), + ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'), + ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), + ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), + ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{108e0}', '\u{108f2}'), + ('\u{108f4}', '\u{108f5}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), + ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a03}'), + ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), + ('\u{10a19}', '\u{10a33}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', '\u{10a3f}'), + ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), + ('\u{10ac9}', '\u{10ae6}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), + ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), + ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{11000}', '\u{11046}'), + ('\u{11066}', '\u{1106f}'), ('\u{1107f}', '\u{110ba}'), ('\u{110d0}', '\u{110e8}'), + ('\u{110f0}', '\u{110f9}'), ('\u{11100}', '\u{11134}'), ('\u{11136}', '\u{1113f}'), + ('\u{11150}', '\u{11173}'), ('\u{11176}', '\u{11176}'), ('\u{11180}', '\u{111c4}'), + ('\u{111ca}', '\u{111cc}'), ('\u{111d0}', '\u{111da}'), ('\u{111dc}', '\u{111dc}'), + ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{11237}'), ('\u{1123e}', '\u{1123e}'), + ('\u{11280}', '\u{11286}'), ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), + ('\u{1128f}', '\u{1129d}'), ('\u{1129f}', '\u{112a8}'), ('\u{112b0}', '\u{112ea}'), + ('\u{112f0}', '\u{112f9}'), ('\u{11300}', '\u{11303}'), ('\u{11305}', '\u{1130c}'), + ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), + ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133c}', '\u{11344}'), + ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134d}'), ('\u{11350}', '\u{11350}'), + ('\u{11357}', '\u{11357}'), ('\u{1135d}', '\u{11363}'), ('\u{11366}', '\u{1136c}'), + ('\u{11370}', '\u{11374}'), ('\u{11400}', '\u{1144a}'), ('\u{11450}', '\u{11459}'), + ('\u{11480}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{114d0}', '\u{114d9}'), + ('\u{11580}', '\u{115b5}'), ('\u{115b8}', '\u{115c0}'), ('\u{115d8}', '\u{115dd}'), + ('\u{11600}', '\u{11640}'), ('\u{11644}', '\u{11644}'), ('\u{11650}', '\u{11659}'), + ('\u{11680}', '\u{116b7}'), ('\u{116c0}', '\u{116c9}'), ('\u{11700}', '\u{11719}'), + ('\u{1171d}', '\u{1172b}'), ('\u{11730}', '\u{11739}'), ('\u{118a0}', '\u{118e9}'), + ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{11c00}', '\u{11c08}'), + ('\u{11c0a}', '\u{11c36}'), ('\u{11c38}', '\u{11c40}'), ('\u{11c50}', '\u{11c59}'), + ('\u{11c72}', '\u{11c8f}'), ('\u{11c92}', '\u{11ca7}'), ('\u{11ca9}', '\u{11cb6}'), + ('\u{12000}', '\u{12399}'), ('\u{12400}', '\u{1246e}'), ('\u{12480}', '\u{12543}'), + ('\u{13000}', '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}', '\u{16a38}'), + ('\u{16a40}', '\u{16a5e}'), ('\u{16a60}', '\u{16a69}'), ('\u{16ad0}', '\u{16aed}'), + ('\u{16af0}', '\u{16af4}'), ('\u{16b00}', '\u{16b36}'), ('\u{16b40}', '\u{16b43}'), + ('\u{16b50}', '\u{16b59}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), + ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f7e}'), ('\u{16f8f}', '\u{16f9f}'), + ('\u{16fe0}', '\u{16fe0}'), ('\u{17000}', '\u{187ec}'), ('\u{18800}', '\u{18af2}'), + ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), + ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1bc9d}', '\u{1bc9e}'), + ('\u{1d165}', '\u{1d169}'), ('\u{1d16d}', '\u{1d172}'), ('\u{1d17b}', '\u{1d182}'), + ('\u{1d185}', '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), + ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), + ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), + ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), + ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), + ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), + ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), + ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), + ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), + ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), + ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), + ('\u{1d7ce}', '\u{1d7ff}'), ('\u{1da00}', '\u{1da36}'), ('\u{1da3b}', '\u{1da6c}'), + ('\u{1da75}', '\u{1da75}'), ('\u{1da84}', '\u{1da84}'), ('\u{1da9b}', '\u{1da9f}'), + ('\u{1daa1}', '\u{1daaf}'), ('\u{1e000}', '\u{1e006}'), ('\u{1e008}', '\u{1e018}'), + ('\u{1e01b}', '\u{1e021}'), ('\u{1e023}', '\u{1e024}'), ('\u{1e026}', '\u{1e02a}'), + ('\u{1e800}', '\u{1e8c4}'), ('\u{1e8d0}', '\u{1e8d6}'), ('\u{1e900}', '\u{1e94a}'), + ('\u{1e950}', '\u{1e959}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), + ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), + ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), + ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), + ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), + ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), + ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), + ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), + ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), + ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), + ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), + ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), + ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2f800}', '\u{2fa1d}'), + ('\u{e0100}', '\u{e01ef}') + ]; + + pub fn XID_Continue(c: char) -> bool { + super::bsearch_range_table(c, XID_Continue_table) + } + + pub const XID_Start_table: &'static [(char, char)] = &[ + ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), + ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), + ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', + '\u{2ee}'), ('\u{370}', '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37b}', '\u{37d}'), + ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}', + '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'), + ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), ('\u{561}', + '\u{587}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f2}'), ('\u{620}', '\u{64a}'), + ('\u{66e}', '\u{66f}'), ('\u{671}', '\u{6d3}'), ('\u{6d5}', '\u{6d5}'), ('\u{6e5}', + '\u{6e6}'), ('\u{6ee}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), + ('\u{710}', '\u{710}'), ('\u{712}', '\u{72f}'), ('\u{74d}', '\u{7a5}'), ('\u{7b1}', + '\u{7b1}'), ('\u{7ca}', '\u{7ea}'), ('\u{7f4}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), + ('\u{800}', '\u{815}'), ('\u{81a}', '\u{81a}'), ('\u{824}', '\u{824}'), ('\u{828}', + '\u{828}'), ('\u{840}', '\u{858}'), ('\u{8a0}', '\u{8b4}'), ('\u{8b6}', '\u{8bd}'), + ('\u{904}', '\u{939}'), ('\u{93d}', '\u{93d}'), ('\u{950}', '\u{950}'), ('\u{958}', + '\u{961}'), ('\u{971}', '\u{980}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), + ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', + '\u{9b9}'), ('\u{9bd}', '\u{9bd}'), ('\u{9ce}', '\u{9ce}'), ('\u{9dc}', '\u{9dd}'), + ('\u{9df}', '\u{9e1}'), ('\u{9f0}', '\u{9f1}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', + '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), + ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', + '\u{a5e}'), ('\u{a72}', '\u{a74}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), + ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', + '\u{ab9}'), ('\u{abd}', '\u{abd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae1}'), + ('\u{af9}', '\u{af9}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', + '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), + ('\u{b3d}', '\u{b3d}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b61}'), ('\u{b71}', + '\u{b71}'), ('\u{b83}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), + ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', + '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), + ('\u{bd0}', '\u{bd0}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', + '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c3d}'), ('\u{c58}', '\u{c5a}'), + ('\u{c60}', '\u{c61}'), ('\u{c80}', '\u{c80}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', + '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), + ('\u{cbd}', '\u{cbd}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce1}'), ('\u{cf1}', + '\u{cf2}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), + ('\u{d3d}', '\u{d3d}'), ('\u{d4e}', '\u{d4e}'), ('\u{d54}', '\u{d56}'), ('\u{d5f}', + '\u{d61}'), ('\u{d7a}', '\u{d7f}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), + ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{e01}', + '\u{e30}'), ('\u{e32}', '\u{e32}'), ('\u{e40}', '\u{e46}'), ('\u{e81}', '\u{e82}'), + ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', + '\u{e8d}'), ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), + ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', + '\u{eb0}'), ('\u{eb2}', '\u{eb2}'), ('\u{ebd}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), + ('\u{ec6}', '\u{ec6}'), ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f40}', + '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f88}', '\u{f8c}'), ('\u{1000}', '\u{102a}'), + ('\u{103f}', '\u{103f}'), ('\u{1050}', '\u{1055}'), ('\u{105a}', '\u{105d}'), ('\u{1061}', + '\u{1061}'), ('\u{1065}', '\u{1066}'), ('\u{106e}', '\u{1070}'), ('\u{1075}', '\u{1081}'), + ('\u{108e}', '\u{108e}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', + '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', '\u{124d}'), + ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', + '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), + ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', + '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), + ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f5}'), ('\u{13f8}', '\u{13fd}'), ('\u{1401}', + '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), ('\u{16a0}', '\u{16ea}'), + ('\u{16ee}', '\u{16f8}'), ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1711}'), ('\u{1720}', + '\u{1731}'), ('\u{1740}', '\u{1751}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), + ('\u{1780}', '\u{17b3}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dc}'), ('\u{1820}', + '\u{1877}'), ('\u{1880}', '\u{18a8}'), ('\u{18aa}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), + ('\u{1900}', '\u{191e}'), ('\u{1950}', '\u{196d}'), ('\u{1970}', '\u{1974}'), ('\u{1980}', + '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{1a00}', '\u{1a16}'), ('\u{1a20}', '\u{1a54}'), + ('\u{1aa7}', '\u{1aa7}'), ('\u{1b05}', '\u{1b33}'), ('\u{1b45}', '\u{1b4b}'), ('\u{1b83}', + '\u{1ba0}'), ('\u{1bae}', '\u{1baf}'), ('\u{1bba}', '\u{1be5}'), ('\u{1c00}', '\u{1c23}'), + ('\u{1c4d}', '\u{1c4f}'), ('\u{1c5a}', '\u{1c7d}'), ('\u{1c80}', '\u{1c88}'), ('\u{1ce9}', + '\u{1cec}'), ('\u{1cee}', '\u{1cf1}'), ('\u{1cf5}', '\u{1cf6}'), ('\u{1d00}', '\u{1dbf}'), + ('\u{1e00}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', + '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), + ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', + '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fcc}'), + ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', + '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), + ('\u{2090}', '\u{209c}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', + '\u{2113}'), ('\u{2115}', '\u{2115}'), ('\u{2118}', '\u{211d}'), ('\u{2124}', '\u{2124}'), + ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{2139}'), ('\u{213c}', + '\u{213f}'), ('\u{2145}', '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), + ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', + '\u{2cee}'), ('\u{2cf2}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), + ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2d80}', + '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), + ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', + '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{3029}'), + ('\u{3031}', '\u{3035}'), ('\u{3038}', '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{309d}', + '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', '\u{312d}'), + ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', + '\u{4db5}'), ('\u{4e00}', '\u{9fd5}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), + ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a640}', + '\u{a66e}'), ('\u{a67f}', '\u{a69d}'), ('\u{a6a0}', '\u{a6ef}'), ('\u{a717}', '\u{a71f}'), + ('\u{a722}', '\u{a788}'), ('\u{a78b}', '\u{a7ae}'), ('\u{a7b0}', '\u{a7b7}'), ('\u{a7f7}', + '\u{a801}'), ('\u{a803}', '\u{a805}'), ('\u{a807}', '\u{a80a}'), ('\u{a80c}', '\u{a822}'), + ('\u{a840}', '\u{a873}'), ('\u{a882}', '\u{a8b3}'), ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', + '\u{a8fb}'), ('\u{a8fd}', '\u{a8fd}'), ('\u{a90a}', '\u{a925}'), ('\u{a930}', '\u{a946}'), + ('\u{a960}', '\u{a97c}'), ('\u{a984}', '\u{a9b2}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e0}', + '\u{a9e4}'), ('\u{a9e6}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', '\u{aa28}'), + ('\u{aa40}', '\u{aa42}'), ('\u{aa44}', '\u{aa4b}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', + '\u{aa7a}'), ('\u{aa7e}', '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'), ('\u{aab5}', '\u{aab6}'), + ('\u{aab9}', '\u{aabd}'), ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', + '\u{aadd}'), ('\u{aae0}', '\u{aaea}'), ('\u{aaf2}', '\u{aaf4}'), ('\u{ab01}', '\u{ab06}'), + ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', + '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab65}'), ('\u{ab70}', '\u{abe2}'), + ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', + '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), + ('\u{fb1d}', '\u{fb1d}'), ('\u{fb1f}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', + '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), + ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fc5d}'), ('\u{fc64}', '\u{fd3d}'), ('\u{fd50}', + '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdf9}'), ('\u{fe71}', '\u{fe71}'), + ('\u{fe73}', '\u{fe73}'), ('\u{fe77}', '\u{fe77}'), ('\u{fe79}', '\u{fe79}'), ('\u{fe7b}', + '\u{fe7b}'), ('\u{fe7d}', '\u{fe7d}'), ('\u{fe7f}', '\u{fefc}'), ('\u{ff21}', '\u{ff3a}'), + ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ff9d}'), ('\u{ffa0}', '\u{ffbe}'), ('\u{ffc2}', + '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), + ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), + ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), + ('\u{10080}', '\u{100fa}'), ('\u{10140}', '\u{10174}'), ('\u{10280}', '\u{1029c}'), + ('\u{102a0}', '\u{102d0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{1034a}'), + ('\u{10350}', '\u{10375}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), + ('\u{103c8}', '\u{103cf}'), ('\u{103d1}', '\u{103d5}'), ('\u{10400}', '\u{1049d}'), + ('\u{104b0}', '\u{104d3}'), ('\u{104d8}', '\u{104fb}'), ('\u{10500}', '\u{10527}'), + ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), + ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), + ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), + ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), + ('\u{108e0}', '\u{108f2}'), ('\u{108f4}', '\u{108f5}'), ('\u{10900}', '\u{10915}'), + ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'), + ('\u{10a00}', '\u{10a00}'), ('\u{10a10}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), + ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), + ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), + ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), + ('\u{10c00}', '\u{10c48}'), ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), + ('\u{11003}', '\u{11037}'), ('\u{11083}', '\u{110af}'), ('\u{110d0}', '\u{110e8}'), + ('\u{11103}', '\u{11126}'), ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), + ('\u{11183}', '\u{111b2}'), ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), + ('\u{111dc}', '\u{111dc}'), ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{1122b}'), + ('\u{11280}', '\u{11286}'), ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), + ('\u{1128f}', '\u{1129d}'), ('\u{1129f}', '\u{112a8}'), ('\u{112b0}', '\u{112de}'), + ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), + ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), + ('\u{1133d}', '\u{1133d}'), ('\u{11350}', '\u{11350}'), ('\u{1135d}', '\u{11361}'), + ('\u{11400}', '\u{11434}'), ('\u{11447}', '\u{1144a}'), ('\u{11480}', '\u{114af}'), + ('\u{114c4}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115ae}'), + ('\u{115d8}', '\u{115db}'), ('\u{11600}', '\u{1162f}'), ('\u{11644}', '\u{11644}'), + ('\u{11680}', '\u{116aa}'), ('\u{11700}', '\u{11719}'), ('\u{118a0}', '\u{118df}'), + ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{11c00}', '\u{11c08}'), + ('\u{11c0a}', '\u{11c2e}'), ('\u{11c40}', '\u{11c40}'), ('\u{11c72}', '\u{11c8f}'), + ('\u{12000}', '\u{12399}'), ('\u{12400}', '\u{1246e}'), ('\u{12480}', '\u{12543}'), + ('\u{13000}', '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}', '\u{16a38}'), + ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16b00}', '\u{16b2f}'), + ('\u{16b40}', '\u{16b43}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), + ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f50}'), ('\u{16f93}', '\u{16f9f}'), + ('\u{16fe0}', '\u{16fe0}'), ('\u{17000}', '\u{187ec}'), ('\u{18800}', '\u{18af2}'), + ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), + ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1d400}', '\u{1d454}'), + ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), + ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), + ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), + ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), + ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), + ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), + ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), + ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), + ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), + ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1e800}', '\u{1e8c4}'), + ('\u{1e900}', '\u{1e943}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), + ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), + ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), + ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), + ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), + ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), + ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), + ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), + ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), + ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), + ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), + ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), + ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2f800}', '\u{2fa1d}') + ]; + + pub fn XID_Start(c: char) -> bool { + super::bsearch_range_table(c, XID_Start_table) + } + +} + diff --git a/third_party/cargo/vendor/unicode-xid-0.1.0/src/tests.rs b/third_party/cargo/vendor/unicode-xid-0.1.0/src/tests.rs new file mode 100644 index 0000000..f433396 --- /dev/null +++ b/third_party/cargo/vendor/unicode-xid-0.1.0/src/tests.rs @@ -0,0 +1,113 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(feature = "bench")] +use std::iter; +#[cfg(feature = "bench")] +use test::Bencher; +#[cfg(feature = "bench")] +use std::prelude::v1::*; + +use super::UnicodeXID; + +#[cfg(feature = "bench")] +#[bench] +fn cargo_is_xid_start(b: &mut Bencher) { + let string = iter::repeat('a').take(4096).collect::<String>(); + + b.bytes = string.len() as u64; + b.iter(|| { + string.chars().all(UnicodeXID::is_xid_start) + }); +} + +#[cfg(feature = "bench")] +#[bench] +fn stdlib_is_xid_start(b: &mut Bencher) { + let string = iter::repeat('a').take(4096).collect::<String>(); + + b.bytes = string.len() as u64; + b.iter(|| { + string.chars().all(char::is_xid_start) + }); +} + +#[cfg(feature = "bench")] +#[bench] +fn cargo_xid_continue(b: &mut Bencher) { + let string = iter::repeat('a').take(4096).collect::<String>(); + + b.bytes = string.len() as u64; + b.iter(|| { + string.chars().all(UnicodeXID::is_xid_continue) + }); +} + +#[cfg(feature = "bench")] +#[bench] +fn stdlib_xid_continue(b: &mut Bencher) { + let string = iter::repeat('a').take(4096).collect::<String>(); + + b.bytes = string.len() as u64; + b.iter(|| { + string.chars().all(char::is_xid_continue) + }); +} + +#[test] +fn test_is_xid_start() { + let chars = [ + 'A', 'Z', 'a', 'z', + '\u{1000d}', '\u{10026}', + ]; + + for ch in &chars { + assert!(UnicodeXID::is_xid_start(*ch), "{}", ch); + } +} + +#[test] +fn test_is_not_xid_start() { + let chars = [ + '\x00', '\x01', + '0', '9', + ' ', '[', '<', '{', '(', + '\u{02c2}', '\u{ffff}', + ]; + + for ch in &chars { + assert!(!UnicodeXID::is_xid_start(*ch), "{}", ch); + } +} + +#[test] +fn test_is_xid_continue() { + let chars = [ + '0', '9', 'A', 'Z', 'a', 'z', '_', + '\u{1000d}', '\u{10026}', + ]; + + for ch in &chars { + assert!(UnicodeXID::is_xid_continue(*ch), "{}", ch); + } +} + +#[test] +fn test_is_not_xid_continue() { + let chars = [ + '\x00', '\x01', + ' ', '[', '<', '{', '(', + '\u{02c2}', '\u{ffff}', + ]; + + for &ch in &chars { + assert!(!UnicodeXID::is_xid_continue(ch), "{}", ch); + } +} diff --git a/third_party/cargo/vendor/vk-sys-0.4.0/.cargo-checksum.json b/third_party/cargo/vendor/vk-sys-0.4.0/.cargo-checksum.json new file mode 100644 index 0000000..1f52e2b --- /dev/null +++ b/third_party/cargo/vendor/vk-sys-0.4.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"a9572757fb3826c2a084b93eb6db19299212d77843c1225310a838bdde4eb698","src/lib.rs":"f0ed92c5b1c96696077298b13ac7dea1a2e880d75636411a32de0bb1ccfbc4b7"},"package":"36f5fd4a7d6d5d19808610583131c0aed271556527cad4cb71c436831a28e059"} \ No newline at end of file diff --git a/third_party/cargo/vendor/vk-sys-0.4.0/BUILD b/third_party/cargo/vendor/vk-sys-0.4.0/BUILD new file mode 100644 index 0000000..df35203 --- /dev/null +++ b/third_party/cargo/vendor/vk-sys-0.4.0/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "vk_sys", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/vk-sys-0.4.0/Cargo.toml b/third_party/cargo/vendor/vk-sys-0.4.0/Cargo.toml new file mode 100644 index 0000000..7ea285b --- /dev/null +++ b/third_party/cargo/vendor/vk-sys-0.4.0/Cargo.toml @@ -0,0 +1,22 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "vk-sys" +version = "0.4.0" +authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>", "The vulkano contributors"] +description = "Bindings for the Vulkan graphics API" +documentation = "https://docs.rs/vk-sys" +keywords = ["vulkan", "bindings", "graphics", "gpu", "rendering"] +categories = ["rendering::graphics-api"] +license = "MIT/Apache-2.0" +repository = "https://github.com/vulkano-rs/vulkano" diff --git a/third_party/cargo/vendor/vk-sys-0.4.0/src/lib.rs b/third_party/cargo/vendor/vk-sys-0.4.0/src/lib.rs new file mode 100644 index 0000000..357aab5 --- /dev/null +++ b/third_party/cargo/vendor/vk-sys-0.4.0/src/lib.rs @@ -0,0 +1,2926 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +#![doc(html_logo_url = "https://raw.githubusercontent.com/vulkano-rs/vulkano/master/logo.png")] + +#![allow(non_upper_case_globals)] +#![allow(non_snake_case)] +#![allow(non_camel_case_types)] + +use std::mem; +use std::ffi::CStr; +use std::fmt; +use std::os::raw::c_char; +use std::os::raw::c_void; +use std::os::raw::c_ulong; +use std::os::raw::c_double; + +pub type Flags = u32; +pub type Bool32 = u32; +pub type DeviceSize = u64; +pub type SampleMask = u32; + +pub type Instance = usize; +pub type PhysicalDevice = usize; +pub type Device = usize; +pub type Queue = usize; +pub type CommandBuffer = usize; + +pub type Semaphore = u64; +pub type Fence = u64; +pub type DeviceMemory = u64; +pub type Buffer = u64; +pub type Image = u64; +pub type Event = u64; +pub type QueryPool = u64; +pub type BufferView = u64; +pub type ImageView = u64; +pub type ShaderModule = u64; +pub type PipelineCache = u64; +pub type PipelineLayout = u64; +pub type RenderPass = u64; +pub type Pipeline = u64; +pub type DescriptorSetLayout = u64; +pub type Sampler = u64; +pub type DescriptorPool = u64; +pub type DescriptorSet = u64; +pub type Framebuffer = u64; +pub type CommandPool = u64; +pub type SurfaceKHR = u64; +pub type SwapchainKHR = u64; +pub type DisplayKHR = u64; +pub type DisplayModeKHR = u64; +pub type DebugReportCallbackEXT = u64; +pub type DescriptorUpdateTemplateKHR = u64; + +pub const LOD_CLAMP_NONE: f32 = 1000.0; +pub const REMAINING_MIP_LEVELS: u32 = 0xffffffff; +pub const REMAINING_ARRAY_LAYERS: u32 = 0xffffffff; +pub const WHOLE_SIZE: u64 = 0xffffffffffffffff; +pub const ATTACHMENT_UNUSED: u32 = 0xffffffff; +pub const TRUE: u32 = 1; +pub const FALSE: u32 = 0; +pub const QUEUE_FAMILY_IGNORED: u32 = 0xffffffff; +pub const SUBPASS_EXTERNAL: u32 = 0xffffffff; +pub const MAX_PHYSICAL_DEVICE_NAME_SIZE: u32 = 256; +pub const UUID_SIZE: u32 = 16; +pub const MAX_MEMORY_TYPES: u32 = 32; +pub const MAX_MEMORY_HEAPS: u32 = 16; +pub const MAX_EXTENSION_NAME_SIZE: u32 = 256; +pub const MAX_DESCRIPTION_SIZE: u32 = 256; + +pub type PipelineCacheHeaderVersion = u32; +pub const PIPELINE_CACHE_HEADER_VERSION_ONE: u32 = 1; + +pub type Result = u32; +pub const SUCCESS: u32 = 0; +pub const NOT_READY: u32 = 1; +pub const TIMEOUT: u32 = 2; +pub const EVENT_SET: u32 = 3; +pub const EVENT_RESET: u32 = 4; +pub const INCOMPLETE: u32 = 5; +pub const ERROR_OUT_OF_HOST_MEMORY: u32 = -1i32 as u32; +pub const ERROR_OUT_OF_DEVICE_MEMORY: u32 = -2i32 as u32; +pub const ERROR_INITIALIZATION_FAILED: u32 = -3i32 as u32; +pub const ERROR_DEVICE_LOST: u32 = -4i32 as u32; +pub const ERROR_MEMORY_MAP_FAILED: u32 = -5i32 as u32; +pub const ERROR_LAYER_NOT_PRESENT: u32 = -6i32 as u32; +pub const ERROR_EXTENSION_NOT_PRESENT: u32 = -7i32 as u32; +pub const ERROR_FEATURE_NOT_PRESENT: u32 = -8i32 as u32; +pub const ERROR_INCOMPATIBLE_DRIVER: u32 = -9i32 as u32; +pub const ERROR_TOO_MANY_OBJECTS: u32 = -10i32 as u32; +pub const ERROR_FORMAT_NOT_SUPPORTED: u32 = -11i32 as u32; +pub const ERROR_SURFACE_LOST_KHR: u32 = -1000000000i32 as u32; +pub const ERROR_NATIVE_WINDOW_IN_USE_KHR: u32 = -1000000001i32 as u32; +pub const SUBOPTIMAL_KHR: u32 = 1000001003; +pub const ERROR_OUT_OF_DATE_KHR: u32 = -1000001004i32 as u32; +pub const ERROR_INCOMPATIBLE_DISPLAY_KHR: u32 = -1000003001i32 as u32; +pub const ERROR_VALIDATION_FAILED_EXT: u32 = -1000011001i32 as u32; +pub const ERROR_INVALID_SHADER_NV: u32 = -1000012000i32 as u32; +pub const ERROR_OUT_OF_POOL_MEMORY_KHR: u32 = -1000069000i32 as u32; + +pub type StructureType = u32; +pub const STRUCTURE_TYPE_APPLICATION_INFO: u32 = 0; +pub const STRUCTURE_TYPE_INSTANCE_CREATE_INFO: u32 = 1; +pub const STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO: u32 = 2; +pub const STRUCTURE_TYPE_DEVICE_CREATE_INFO: u32 = 3; +pub const STRUCTURE_TYPE_SUBMIT_INFO: u32 = 4; +pub const STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO: u32 = 5; +pub const STRUCTURE_TYPE_MAPPED_MEMORY_RANGE: u32 = 6; +pub const STRUCTURE_TYPE_BIND_SPARSE_INFO: u32 = 7; +pub const STRUCTURE_TYPE_FENCE_CREATE_INFO: u32 = 8; +pub const STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO: u32 = 9; +pub const STRUCTURE_TYPE_EVENT_CREATE_INFO: u32 = 10; +pub const STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO: u32 = 11; +pub const STRUCTURE_TYPE_BUFFER_CREATE_INFO: u32 = 12; +pub const STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO: u32 = 13; +pub const STRUCTURE_TYPE_IMAGE_CREATE_INFO: u32 = 14; +pub const STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO: u32 = 15; +pub const STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO: u32 = 16; +pub const STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO: u32 = 17; +pub const STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO: u32 = 18; +pub const STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO: u32 = 19; +pub const STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO: u32 = 20; +pub const STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO: u32 = 21; +pub const STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO: u32 = 22; +pub const STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO: u32 = 23; +pub const STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO: u32 = 24; +pub const STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO: u32 = 25; +pub const STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO: u32 = 26; +pub const STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO: u32 = 27; +pub const STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO: u32 = 28; +pub const STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO: u32 = 29; +pub const STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO: u32 = 30; +pub const STRUCTURE_TYPE_SAMPLER_CREATE_INFO: u32 = 31; +pub const STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO: u32 = 32; +pub const STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO: u32 = 33; +pub const STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO: u32 = 34; +pub const STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: u32 = 35; +pub const STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: u32 = 36; +pub const STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO: u32 = 37; +pub const STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO: u32 = 38; +pub const STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO: u32 = 39; +pub const STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO: u32 = 40; +pub const STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO: u32 = 41; +pub const STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO: u32 = 42; +pub const STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO: u32 = 43; +pub const STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER: u32 = 44; +pub const STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER: u32 = 45; +pub const STRUCTURE_TYPE_MEMORY_BARRIER: u32 = 46; +pub const STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO: u32 = 47; +pub const STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO: u32 = 48; +pub const STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR: u32 = 1000001000; +pub const STRUCTURE_TYPE_PRESENT_INFO_KHR: u32 = 1000001001; +pub const STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR: u32 = 1000002000; +pub const STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR: u32 = 1000002001; +pub const STRUCTURE_TYPE_DISPLAY_PRESENT_INFO_KHR: u32 = 1000003000; +pub const STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR: u32 = 1000004000; +pub const STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR: u32 = 1000005000; +pub const STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR: u32 = 1000006000; +pub const STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR: u32 = 1000008000; +pub const STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR: u32 = 1000009000; +#[deprecated(note = "Use STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT instead")] +pub const STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT: u32 = 1000011000; +pub const STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT: u32 = 1000011000; +pub const STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK: u32 = 1000122000 + (122 * 1000); +pub const STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK: u32 = 1000000000 + (123 * 1000); +pub const STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR: u32 = 1000059000; +pub const STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR: u32 = 1000059001; +pub const STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR: u32 = 1000059002; +pub const STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR: u32 = 1000059003; +pub const STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR: u32 = 1000059004; +pub const STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR: u32 = 1000059005; +pub const STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR: u32 = 1000059006; +pub const STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR: u32 = 1000059007; +pub const STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR: u32 = 1000059008; +pub const STRUCTURE_TYPE_VI_SURFACE_CREATE_INFO_NN: u32 = 1000062000; +pub const STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR: u32 = 1000080000; +pub const STRUCTURE_TYPE_PRESENT_REGIONS_KHR: u32 = 1000084000; +pub const STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR: u32 = 1000085000; +pub const STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR: u32 = 1000127000; +pub const STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR: u32 = 1000127001; +pub const STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR: u32 = 1000146000; +pub const STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR: u32 = 1000146001; +pub const STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2_KHR: u32 = 1000146002; +pub const STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR: u32 = 1000146003; +pub const STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2_KHR: u32 = 1000146004; +pub const STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT: u32 = 1000022000; +pub const STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT: u32 = 1000022001; +pub const STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT: u32 = 1000022002; + +pub type SystemAllocationScope = u32; +pub const SYSTEM_ALLOCATION_SCOPE_COMMAND: u32 = 0; +pub const SYSTEM_ALLOCATION_SCOPE_OBJECT: u32 = 1; +pub const SYSTEM_ALLOCATION_SCOPE_CACHE: u32 = 2; +pub const SYSTEM_ALLOCATION_SCOPE_DEVICE: u32 = 3; +pub const SYSTEM_ALLOCATION_SCOPE_INSTANCE: u32 = 4; + +pub type InternalAllocationType = u32; +pub const INTERNAL_ALLOCATION_TYPE_EXECUTABLE: u32 = 0; + +pub type Format = u32; +pub const FORMAT_UNDEFINED: u32 = 0; +pub const FORMAT_R4G4_UNORM_PACK8: u32 = 1; +pub const FORMAT_R4G4B4A4_UNORM_PACK16: u32 = 2; +pub const FORMAT_B4G4R4A4_UNORM_PACK16: u32 = 3; +pub const FORMAT_R5G6B5_UNORM_PACK16: u32 = 4; +pub const FORMAT_B5G6R5_UNORM_PACK16: u32 = 5; +pub const FORMAT_R5G5B5A1_UNORM_PACK16: u32 = 6; +pub const FORMAT_B5G5R5A1_UNORM_PACK16: u32 = 7; +pub const FORMAT_A1R5G5B5_UNORM_PACK16: u32 = 8; +pub const FORMAT_R8_UNORM: u32 = 9; +pub const FORMAT_R8_SNORM: u32 = 10; +pub const FORMAT_R8_USCALED: u32 = 11; +pub const FORMAT_R8_SSCALED: u32 = 12; +pub const FORMAT_R8_UINT: u32 = 13; +pub const FORMAT_R8_SINT: u32 = 14; +pub const FORMAT_R8_SRGB: u32 = 15; +pub const FORMAT_R8G8_UNORM: u32 = 16; +pub const FORMAT_R8G8_SNORM: u32 = 17; +pub const FORMAT_R8G8_USCALED: u32 = 18; +pub const FORMAT_R8G8_SSCALED: u32 = 19; +pub const FORMAT_R8G8_UINT: u32 = 20; +pub const FORMAT_R8G8_SINT: u32 = 21; +pub const FORMAT_R8G8_SRGB: u32 = 22; +pub const FORMAT_R8G8B8_UNORM: u32 = 23; +pub const FORMAT_R8G8B8_SNORM: u32 = 24; +pub const FORMAT_R8G8B8_USCALED: u32 = 25; +pub const FORMAT_R8G8B8_SSCALED: u32 = 26; +pub const FORMAT_R8G8B8_UINT: u32 = 27; +pub const FORMAT_R8G8B8_SINT: u32 = 28; +pub const FORMAT_R8G8B8_SRGB: u32 = 29; +pub const FORMAT_B8G8R8_UNORM: u32 = 30; +pub const FORMAT_B8G8R8_SNORM: u32 = 31; +pub const FORMAT_B8G8R8_USCALED: u32 = 32; +pub const FORMAT_B8G8R8_SSCALED: u32 = 33; +pub const FORMAT_B8G8R8_UINT: u32 = 34; +pub const FORMAT_B8G8R8_SINT: u32 = 35; +pub const FORMAT_B8G8R8_SRGB: u32 = 36; +pub const FORMAT_R8G8B8A8_UNORM: u32 = 37; +pub const FORMAT_R8G8B8A8_SNORM: u32 = 38; +pub const FORMAT_R8G8B8A8_USCALED: u32 = 39; +pub const FORMAT_R8G8B8A8_SSCALED: u32 = 40; +pub const FORMAT_R8G8B8A8_UINT: u32 = 41; +pub const FORMAT_R8G8B8A8_SINT: u32 = 42; +pub const FORMAT_R8G8B8A8_SRGB: u32 = 43; +pub const FORMAT_B8G8R8A8_UNORM: u32 = 44; +pub const FORMAT_B8G8R8A8_SNORM: u32 = 45; +pub const FORMAT_B8G8R8A8_USCALED: u32 = 46; +pub const FORMAT_B8G8R8A8_SSCALED: u32 = 47; +pub const FORMAT_B8G8R8A8_UINT: u32 = 48; +pub const FORMAT_B8G8R8A8_SINT: u32 = 49; +pub const FORMAT_B8G8R8A8_SRGB: u32 = 50; +pub const FORMAT_A8B8G8R8_UNORM_PACK32: u32 = 51; +pub const FORMAT_A8B8G8R8_SNORM_PACK32: u32 = 52; +pub const FORMAT_A8B8G8R8_USCALED_PACK32: u32 = 53; +pub const FORMAT_A8B8G8R8_SSCALED_PACK32: u32 = 54; +pub const FORMAT_A8B8G8R8_UINT_PACK32: u32 = 55; +pub const FORMAT_A8B8G8R8_SINT_PACK32: u32 = 56; +pub const FORMAT_A8B8G8R8_SRGB_PACK32: u32 = 57; +pub const FORMAT_A2R10G10B10_UNORM_PACK32: u32 = 58; +pub const FORMAT_A2R10G10B10_SNORM_PACK32: u32 = 59; +pub const FORMAT_A2R10G10B10_USCALED_PACK32: u32 = 60; +pub const FORMAT_A2R10G10B10_SSCALED_PACK32: u32 = 61; +pub const FORMAT_A2R10G10B10_UINT_PACK32: u32 = 62; +pub const FORMAT_A2R10G10B10_SINT_PACK32: u32 = 63; +pub const FORMAT_A2B10G10R10_UNORM_PACK32: u32 = 64; +pub const FORMAT_A2B10G10R10_SNORM_PACK32: u32 = 65; +pub const FORMAT_A2B10G10R10_USCALED_PACK32: u32 = 66; +pub const FORMAT_A2B10G10R10_SSCALED_PACK32: u32 = 67; +pub const FORMAT_A2B10G10R10_UINT_PACK32: u32 = 68; +pub const FORMAT_A2B10G10R10_SINT_PACK32: u32 = 69; +pub const FORMAT_R16_UNORM: u32 = 70; +pub const FORMAT_R16_SNORM: u32 = 71; +pub const FORMAT_R16_USCALED: u32 = 72; +pub const FORMAT_R16_SSCALED: u32 = 73; +pub const FORMAT_R16_UINT: u32 = 74; +pub const FORMAT_R16_SINT: u32 = 75; +pub const FORMAT_R16_SFLOAT: u32 = 76; +pub const FORMAT_R16G16_UNORM: u32 = 77; +pub const FORMAT_R16G16_SNORM: u32 = 78; +pub const FORMAT_R16G16_USCALED: u32 = 79; +pub const FORMAT_R16G16_SSCALED: u32 = 80; +pub const FORMAT_R16G16_UINT: u32 = 81; +pub const FORMAT_R16G16_SINT: u32 = 82; +pub const FORMAT_R16G16_SFLOAT: u32 = 83; +pub const FORMAT_R16G16B16_UNORM: u32 = 84; +pub const FORMAT_R16G16B16_SNORM: u32 = 85; +pub const FORMAT_R16G16B16_USCALED: u32 = 86; +pub const FORMAT_R16G16B16_SSCALED: u32 = 87; +pub const FORMAT_R16G16B16_UINT: u32 = 88; +pub const FORMAT_R16G16B16_SINT: u32 = 89; +pub const FORMAT_R16G16B16_SFLOAT: u32 = 90; +pub const FORMAT_R16G16B16A16_UNORM: u32 = 91; +pub const FORMAT_R16G16B16A16_SNORM: u32 = 92; +pub const FORMAT_R16G16B16A16_USCALED: u32 = 93; +pub const FORMAT_R16G16B16A16_SSCALED: u32 = 94; +pub const FORMAT_R16G16B16A16_UINT: u32 = 95; +pub const FORMAT_R16G16B16A16_SINT: u32 = 96; +pub const FORMAT_R16G16B16A16_SFLOAT: u32 = 97; +pub const FORMAT_R32_UINT: u32 = 98; +pub const FORMAT_R32_SINT: u32 = 99; +pub const FORMAT_R32_SFLOAT: u32 = 100; +pub const FORMAT_R32G32_UINT: u32 = 101; +pub const FORMAT_R32G32_SINT: u32 = 102; +pub const FORMAT_R32G32_SFLOAT: u32 = 103; +pub const FORMAT_R32G32B32_UINT: u32 = 104; +pub const FORMAT_R32G32B32_SINT: u32 = 105; +pub const FORMAT_R32G32B32_SFLOAT: u32 = 106; +pub const FORMAT_R32G32B32A32_UINT: u32 = 107; +pub const FORMAT_R32G32B32A32_SINT: u32 = 108; +pub const FORMAT_R32G32B32A32_SFLOAT: u32 = 109; +pub const FORMAT_R64_UINT: u32 = 110; +pub const FORMAT_R64_SINT: u32 = 111; +pub const FORMAT_R64_SFLOAT: u32 = 112; +pub const FORMAT_R64G64_UINT: u32 = 113; +pub const FORMAT_R64G64_SINT: u32 = 114; +pub const FORMAT_R64G64_SFLOAT: u32 = 115; +pub const FORMAT_R64G64B64_UINT: u32 = 116; +pub const FORMAT_R64G64B64_SINT: u32 = 117; +pub const FORMAT_R64G64B64_SFLOAT: u32 = 118; +pub const FORMAT_R64G64B64A64_UINT: u32 = 119; +pub const FORMAT_R64G64B64A64_SINT: u32 = 120; +pub const FORMAT_R64G64B64A64_SFLOAT: u32 = 121; +pub const FORMAT_B10G11R11_UFLOAT_PACK32: u32 = 122; +pub const FORMAT_E5B9G9R9_UFLOAT_PACK32: u32 = 123; +pub const FORMAT_D16_UNORM: u32 = 124; +pub const FORMAT_X8_D24_UNORM_PACK32: u32 = 125; +pub const FORMAT_D32_SFLOAT: u32 = 126; +pub const FORMAT_S8_UINT: u32 = 127; +pub const FORMAT_D16_UNORM_S8_UINT: u32 = 128; +pub const FORMAT_D24_UNORM_S8_UINT: u32 = 129; +pub const FORMAT_D32_SFLOAT_S8_UINT: u32 = 130; +pub const FORMAT_BC1_RGB_UNORM_BLOCK: u32 = 131; +pub const FORMAT_BC1_RGB_SRGB_BLOCK: u32 = 132; +pub const FORMAT_BC1_RGBA_UNORM_BLOCK: u32 = 133; +pub const FORMAT_BC1_RGBA_SRGB_BLOCK: u32 = 134; +pub const FORMAT_BC2_UNORM_BLOCK: u32 = 135; +pub const FORMAT_BC2_SRGB_BLOCK: u32 = 136; +pub const FORMAT_BC3_UNORM_BLOCK: u32 = 137; +pub const FORMAT_BC3_SRGB_BLOCK: u32 = 138; +pub const FORMAT_BC4_UNORM_BLOCK: u32 = 139; +pub const FORMAT_BC4_SNORM_BLOCK: u32 = 140; +pub const FORMAT_BC5_UNORM_BLOCK: u32 = 141; +pub const FORMAT_BC5_SNORM_BLOCK: u32 = 142; +pub const FORMAT_BC6H_UFLOAT_BLOCK: u32 = 143; +pub const FORMAT_BC6H_SFLOAT_BLOCK: u32 = 144; +pub const FORMAT_BC7_UNORM_BLOCK: u32 = 145; +pub const FORMAT_BC7_SRGB_BLOCK: u32 = 146; +pub const FORMAT_ETC2_R8G8B8_UNORM_BLOCK: u32 = 147; +pub const FORMAT_ETC2_R8G8B8_SRGB_BLOCK: u32 = 148; +pub const FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: u32 = 149; +pub const FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: u32 = 150; +pub const FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: u32 = 151; +pub const FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: u32 = 152; +pub const FORMAT_EAC_R11_UNORM_BLOCK: u32 = 153; +pub const FORMAT_EAC_R11_SNORM_BLOCK: u32 = 154; +pub const FORMAT_EAC_R11G11_UNORM_BLOCK: u32 = 155; +pub const FORMAT_EAC_R11G11_SNORM_BLOCK: u32 = 156; +pub const FORMAT_ASTC_4x4_UNORM_BLOCK: u32 = 157; +pub const FORMAT_ASTC_4x4_SRGB_BLOCK: u32 = 158; +pub const FORMAT_ASTC_5x4_UNORM_BLOCK: u32 = 159; +pub const FORMAT_ASTC_5x4_SRGB_BLOCK: u32 = 160; +pub const FORMAT_ASTC_5x5_UNORM_BLOCK: u32 = 161; +pub const FORMAT_ASTC_5x5_SRGB_BLOCK: u32 = 162; +pub const FORMAT_ASTC_6x5_UNORM_BLOCK: u32 = 163; +pub const FORMAT_ASTC_6x5_SRGB_BLOCK: u32 = 164; +pub const FORMAT_ASTC_6x6_UNORM_BLOCK: u32 = 165; +pub const FORMAT_ASTC_6x6_SRGB_BLOCK: u32 = 166; +pub const FORMAT_ASTC_8x5_UNORM_BLOCK: u32 = 167; +pub const FORMAT_ASTC_8x5_SRGB_BLOCK: u32 = 168; +pub const FORMAT_ASTC_8x6_UNORM_BLOCK: u32 = 169; +pub const FORMAT_ASTC_8x6_SRGB_BLOCK: u32 = 170; +pub const FORMAT_ASTC_8x8_UNORM_BLOCK: u32 = 171; +pub const FORMAT_ASTC_8x8_SRGB_BLOCK: u32 = 172; +pub const FORMAT_ASTC_10x5_UNORM_BLOCK: u32 = 173; +pub const FORMAT_ASTC_10x5_SRGB_BLOCK: u32 = 174; +pub const FORMAT_ASTC_10x6_UNORM_BLOCK: u32 = 175; +pub const FORMAT_ASTC_10x6_SRGB_BLOCK: u32 = 176; +pub const FORMAT_ASTC_10x8_UNORM_BLOCK: u32 = 177; +pub const FORMAT_ASTC_10x8_SRGB_BLOCK: u32 = 178; +pub const FORMAT_ASTC_10x10_UNORM_BLOCK: u32 = 179; +pub const FORMAT_ASTC_10x10_SRGB_BLOCK: u32 = 180; +pub const FORMAT_ASTC_12x10_UNORM_BLOCK: u32 = 181; +pub const FORMAT_ASTC_12x10_SRGB_BLOCK: u32 = 182; +pub const FORMAT_ASTC_12x12_UNORM_BLOCK: u32 = 183; +pub const FORMAT_ASTC_12x12_SRGB_BLOCK: u32 = 184; + +pub type ImageType = u32; +pub const IMAGE_TYPE_1D: u32 = 0; +pub const IMAGE_TYPE_2D: u32 = 1; +pub const IMAGE_TYPE_3D: u32 = 2; + +pub type ImageTiling = u32; +pub const IMAGE_TILING_OPTIMAL: u32 = 0; +pub const IMAGE_TILING_LINEAR: u32 = 1; + +pub type PhysicalDeviceType = u32; +pub const PHYSICAL_DEVICE_TYPE_OTHER: u32 = 0; +pub const PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: u32 = 1; +pub const PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: u32 = 2; +pub const PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: u32 = 3; +pub const PHYSICAL_DEVICE_TYPE_CPU: u32 = 4; + +pub type QueryType = u32; +pub const QUERY_TYPE_OCCLUSION: u32 = 0; +pub const QUERY_TYPE_PIPELINE_STATISTICS: u32 = 1; +pub const QUERY_TYPE_TIMESTAMP: u32 = 2; + +pub type SharingMode = u32; +pub const SHARING_MODE_EXCLUSIVE: u32 = 0; +pub const SHARING_MODE_CONCURRENT: u32 = 1; + +pub type ImageLayout = u32; +pub const IMAGE_LAYOUT_UNDEFINED: u32 = 0; +pub const IMAGE_LAYOUT_GENERAL: u32 = 1; +pub const IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: u32 = 2; +pub const IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: u32 = 3; +pub const IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: u32 = 4; +pub const IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: u32 = 5; +pub const IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: u32 = 6; +pub const IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: u32 = 7; +pub const IMAGE_LAYOUT_PREINITIALIZED: u32 = 8; +pub const IMAGE_LAYOUT_PRESENT_SRC_KHR: u32 = 1000001002; + +pub type ImageViewType = u32; +pub const IMAGE_VIEW_TYPE_1D: u32 = 0; +pub const IMAGE_VIEW_TYPE_2D: u32 = 1; +pub const IMAGE_VIEW_TYPE_3D: u32 = 2; +pub const IMAGE_VIEW_TYPE_CUBE: u32 = 3; +pub const IMAGE_VIEW_TYPE_1D_ARRAY: u32 = 4; +pub const IMAGE_VIEW_TYPE_2D_ARRAY: u32 = 5; +pub const IMAGE_VIEW_TYPE_CUBE_ARRAY: u32 = 6; + +pub type ComponentSwizzle = u32; +pub const COMPONENT_SWIZZLE_IDENTITY: u32 = 0; +pub const COMPONENT_SWIZZLE_ZERO: u32 = 1; +pub const COMPONENT_SWIZZLE_ONE: u32 = 2; +pub const COMPONENT_SWIZZLE_R: u32 = 3; +pub const COMPONENT_SWIZZLE_G: u32 = 4; +pub const COMPONENT_SWIZZLE_B: u32 = 5; +pub const COMPONENT_SWIZZLE_A: u32 = 6; + +pub type VertexInputRate = u32; +pub const VERTEX_INPUT_RATE_VERTEX: u32 = 0; +pub const VERTEX_INPUT_RATE_INSTANCE: u32 = 1; + +pub type PrimitiveTopology = u32; +pub const PRIMITIVE_TOPOLOGY_POINT_LIST: u32 = 0; +pub const PRIMITIVE_TOPOLOGY_LINE_LIST: u32 = 1; +pub const PRIMITIVE_TOPOLOGY_LINE_STRIP: u32 = 2; +pub const PRIMITIVE_TOPOLOGY_TRIANGLE_LIST: u32 = 3; +pub const PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP: u32 = 4; +pub const PRIMITIVE_TOPOLOGY_TRIANGLE_FAN: u32 = 5; +pub const PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY: u32 = 6; +pub const PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY: u32 = 7; +pub const PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY: u32 = 8; +pub const PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY: u32 = 9; +pub const PRIMITIVE_TOPOLOGY_PATCH_LIST: u32 = 10; + +pub type PolygonMode = u32; +pub const POLYGON_MODE_FILL: u32 = 0; +pub const POLYGON_MODE_LINE: u32 = 1; +pub const POLYGON_MODE_POINT: u32 = 2; + +pub type FrontFace = u32; +pub const FRONT_FACE_COUNTER_CLOCKWISE: u32 = 0; +pub const FRONT_FACE_CLOCKWISE: u32 = 1; + +pub type CompareOp = u32; +pub const COMPARE_OP_NEVER: u32 = 0; +pub const COMPARE_OP_LESS: u32 = 1; +pub const COMPARE_OP_EQUAL: u32 = 2; +pub const COMPARE_OP_LESS_OR_EQUAL: u32 = 3; +pub const COMPARE_OP_GREATER: u32 = 4; +pub const COMPARE_OP_NOT_EQUAL: u32 = 5; +pub const COMPARE_OP_GREATER_OR_EQUAL: u32 = 6; +pub const COMPARE_OP_ALWAYS: u32 = 7; + +pub type StencilOp = u32; +pub const STENCIL_OP_KEEP: u32 = 0; +pub const STENCIL_OP_ZERO: u32 = 1; +pub const STENCIL_OP_REPLACE: u32 = 2; +pub const STENCIL_OP_INCREMENT_AND_CLAMP: u32 = 3; +pub const STENCIL_OP_DECREMENT_AND_CLAMP: u32 = 4; +pub const STENCIL_OP_INVERT: u32 = 5; +pub const STENCIL_OP_INCREMENT_AND_WRAP: u32 = 6; +pub const STENCIL_OP_DECREMENT_AND_WRAP: u32 = 7; + +pub type LogicOp = u32; +pub const LOGIC_OP_CLEAR: u32 = 0; +pub const LOGIC_OP_AND: u32 = 1; +pub const LOGIC_OP_AND_REVERSE: u32 = 2; +pub const LOGIC_OP_COPY: u32 = 3; +pub const LOGIC_OP_AND_INVERTED: u32 = 4; +pub const LOGIC_OP_NO_OP: u32 = 5; +pub const LOGIC_OP_XOR: u32 = 6; +pub const LOGIC_OP_OR: u32 = 7; +pub const LOGIC_OP_NOR: u32 = 8; +pub const LOGIC_OP_EQUIVALENT: u32 = 9; +pub const LOGIC_OP_INVERT: u32 = 10; +pub const LOGIC_OP_OR_REVERSE: u32 = 11; +pub const LOGIC_OP_COPY_INVERTED: u32 = 12; +pub const LOGIC_OP_OR_INVERTED: u32 = 13; +pub const LOGIC_OP_NAND: u32 = 14; +pub const LOGIC_OP_SET: u32 = 15; + +pub type BlendFactor = u32; +pub const BLEND_FACTOR_ZERO: u32 = 0; +pub const BLEND_FACTOR_ONE: u32 = 1; +pub const BLEND_FACTOR_SRC_COLOR: u32 = 2; +pub const BLEND_FACTOR_ONE_MINUS_SRC_COLOR: u32 = 3; +pub const BLEND_FACTOR_DST_COLOR: u32 = 4; +pub const BLEND_FACTOR_ONE_MINUS_DST_COLOR: u32 = 5; +pub const BLEND_FACTOR_SRC_ALPHA: u32 = 6; +pub const BLEND_FACTOR_ONE_MINUS_SRC_ALPHA: u32 = 7; +pub const BLEND_FACTOR_DST_ALPHA: u32 = 8; +pub const BLEND_FACTOR_ONE_MINUS_DST_ALPHA: u32 = 9; +pub const BLEND_FACTOR_CONSTANT_COLOR: u32 = 10; +pub const BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR: u32 = 11; +pub const BLEND_FACTOR_CONSTANT_ALPHA: u32 = 12; +pub const BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA: u32 = 13; +pub const BLEND_FACTOR_SRC_ALPHA_SATURATE: u32 = 14; +pub const BLEND_FACTOR_SRC1_COLOR: u32 = 15; +pub const BLEND_FACTOR_ONE_MINUS_SRC1_COLOR: u32 = 16; +pub const BLEND_FACTOR_SRC1_ALPHA: u32 = 17; +pub const BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA: u32 = 18; + +pub type BlendOp = u32; +pub const BLEND_OP_ADD: u32 = 0; +pub const BLEND_OP_SUBTRACT: u32 = 1; +pub const BLEND_OP_REVERSE_SUBTRACT: u32 = 2; +pub const BLEND_OP_MIN: u32 = 3; +pub const BLEND_OP_MAX: u32 = 4; + +pub type DynamicState = u32; +pub const DYNAMIC_STATE_VIEWPORT: u32 = 0; +pub const DYNAMIC_STATE_SCISSOR: u32 = 1; +pub const DYNAMIC_STATE_LINE_WIDTH: u32 = 2; +pub const DYNAMIC_STATE_DEPTH_BIAS: u32 = 3; +pub const DYNAMIC_STATE_BLEND_CONSTANTS: u32 = 4; +pub const DYNAMIC_STATE_DEPTH_BOUNDS: u32 = 5; +pub const DYNAMIC_STATE_STENCIL_COMPARE_MASK: u32 = 6; +pub const DYNAMIC_STATE_STENCIL_WRITE_MASK: u32 = 7; +pub const DYNAMIC_STATE_STENCIL_REFERENCE: u32 = 8; + +pub type Filter = u32; +pub const FILTER_NEAREST: u32 = 0; +pub const FILTER_LINEAR: u32 = 1; + +pub type SamplerMipmapMode = u32; +pub const SAMPLER_MIPMAP_MODE_NEAREST: u32 = 0; +pub const SAMPLER_MIPMAP_MODE_LINEAR: u32 = 1; + +pub type SamplerAddressMode = u32; +pub const SAMPLER_ADDRESS_MODE_REPEAT: u32 = 0; +pub const SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT: u32 = 1; +pub const SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE: u32 = 2; +pub const SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER: u32 = 3; +pub const SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE: u32 = 4; + +pub type BorderColor = u32; +pub const BORDER_COLOR_FLOAT_TRANSPARENT_BLACK: u32 = 0; +pub const BORDER_COLOR_INT_TRANSPARENT_BLACK: u32 = 1; +pub const BORDER_COLOR_FLOAT_OPAQUE_BLACK: u32 = 2; +pub const BORDER_COLOR_INT_OPAQUE_BLACK: u32 = 3; +pub const BORDER_COLOR_FLOAT_OPAQUE_WHITE: u32 = 4; +pub const BORDER_COLOR_INT_OPAQUE_WHITE: u32 = 5; + +pub type DescriptorType = u32; +pub const DESCRIPTOR_TYPE_SAMPLER: u32 = 0; +pub const DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: u32 = 1; +pub const DESCRIPTOR_TYPE_SAMPLED_IMAGE: u32 = 2; +pub const DESCRIPTOR_TYPE_STORAGE_IMAGE: u32 = 3; +pub const DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: u32 = 4; +pub const DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: u32 = 5; +pub const DESCRIPTOR_TYPE_UNIFORM_BUFFER: u32 = 6; +pub const DESCRIPTOR_TYPE_STORAGE_BUFFER: u32 = 7; +pub const DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: u32 = 8; +pub const DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: u32 = 9; +pub const DESCRIPTOR_TYPE_INPUT_ATTACHMENT: u32 = 10; + +pub type AttachmentLoadOp = u32; +pub const ATTACHMENT_LOAD_OP_LOAD: u32 = 0; +pub const ATTACHMENT_LOAD_OP_CLEAR: u32 = 1; +pub const ATTACHMENT_LOAD_OP_DONT_CARE: u32 = 2; + +pub type AttachmentStoreOp = u32; +pub const ATTACHMENT_STORE_OP_STORE: u32 = 0; +pub const ATTACHMENT_STORE_OP_DONT_CARE: u32 = 1; + +pub type PipelineBindPoint = u32; +pub const PIPELINE_BIND_POINT_GRAPHICS: u32 = 0; +pub const PIPELINE_BIND_POINT_COMPUTE: u32 = 1; + +pub type CommandBufferLevel = u32; +pub const COMMAND_BUFFER_LEVEL_PRIMARY: u32 = 0; +pub const COMMAND_BUFFER_LEVEL_SECONDARY: u32 = 1; + +pub type IndexType = u32; +pub const INDEX_TYPE_UINT16: u32 = 0; +pub const INDEX_TYPE_UINT32: u32 = 1; + +pub type SubpassContents = u32; +pub const SUBPASS_CONTENTS_INLINE: u32 = 0; +pub const SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS: u32 = 1; + +pub type InstanceCreateFlags = Flags; + +pub type FormatFeatureFlagBits = u32; +pub const FORMAT_FEATURE_SAMPLED_IMAGE_BIT: u32 = 0x00000001; +pub const FORMAT_FEATURE_STORAGE_IMAGE_BIT: u32 = 0x00000002; +pub const FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT: u32 = 0x00000004; +pub const FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT: u32 = 0x00000008; +pub const FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT: u32 = 0x00000010; +pub const FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT: u32 = 0x00000020; +pub const FORMAT_FEATURE_VERTEX_BUFFER_BIT: u32 = 0x00000040; +pub const FORMAT_FEATURE_COLOR_ATTACHMENT_BIT: u32 = 0x00000080; +pub const FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT: u32 = 0x00000100; +pub const FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT: u32 = 0x00000200; +pub const FORMAT_FEATURE_BLIT_SRC_BIT: u32 = 0x00000400; +pub const FORMAT_FEATURE_BLIT_DST_BIT: u32 = 0x00000800; +pub const FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT: u32 = 0x00001000; +pub const FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR: u32 = 0x00004000; +pub const FORMAT_FEATURE_TRANSFER_DST_BIT_KHR: u32 = 0x00008000; +pub type FormatFeatureFlags = Flags; + + +pub type ImageUsageFlagBits = u32; +pub const IMAGE_USAGE_TRANSFER_SRC_BIT: u32 = 0x00000001; +pub const IMAGE_USAGE_TRANSFER_DST_BIT: u32 = 0x00000002; +pub const IMAGE_USAGE_SAMPLED_BIT: u32 = 0x00000004; +pub const IMAGE_USAGE_STORAGE_BIT: u32 = 0x00000008; +pub const IMAGE_USAGE_COLOR_ATTACHMENT_BIT: u32 = 0x00000010; +pub const IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT: u32 = 0x00000020; +pub const IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT: u32 = 0x00000040; +pub const IMAGE_USAGE_INPUT_ATTACHMENT_BIT: u32 = 0x00000080; +pub type ImageUsageFlags = Flags; + + +pub type ImageCreateFlagBits = u32; +pub const IMAGE_CREATE_SPARSE_BINDING_BIT: u32 = 0x00000001; +pub const IMAGE_CREATE_SPARSE_RESIDENCY_BIT: u32 = 0x00000002; +pub const IMAGE_CREATE_SPARSE_ALIASED_BIT: u32 = 0x00000004; +pub const IMAGE_CREATE_MUTABLE_FORMAT_BIT: u32 = 0x00000008; +pub const IMAGE_CREATE_CUBE_COMPATIBLE_BIT: u32 = 0x00000010; +pub const IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR: u32 = 0x00000020; +pub type ImageCreateFlags = Flags; + + +pub type SampleCountFlagBits = u32; +pub const SAMPLE_COUNT_1_BIT: u32 = 0x00000001; +pub const SAMPLE_COUNT_2_BIT: u32 = 0x00000002; +pub const SAMPLE_COUNT_4_BIT: u32 = 0x00000004; +pub const SAMPLE_COUNT_8_BIT: u32 = 0x00000008; +pub const SAMPLE_COUNT_16_BIT: u32 = 0x00000010; +pub const SAMPLE_COUNT_32_BIT: u32 = 0x00000020; +pub const SAMPLE_COUNT_64_BIT: u32 = 0x00000040; +pub type SampleCountFlags = Flags; + + +pub type QueueFlagBits = u32; +pub const QUEUE_GRAPHICS_BIT: u32 = 0x00000001; +pub const QUEUE_COMPUTE_BIT: u32 = 0x00000002; +pub const QUEUE_TRANSFER_BIT: u32 = 0x00000004; +pub const QUEUE_SPARSE_BINDING_BIT: u32 = 0x00000008; +pub type QueueFlags = Flags; + + +pub type MemoryPropertyFlagBits = u32; +pub const MEMORY_PROPERTY_DEVICE_LOCAL_BIT: u32 = 0x00000001; +pub const MEMORY_PROPERTY_HOST_VISIBLE_BIT: u32 = 0x00000002; +pub const MEMORY_PROPERTY_HOST_COHERENT_BIT: u32 = 0x00000004; +pub const MEMORY_PROPERTY_HOST_CACHED_BIT: u32 = 0x00000008; +pub const MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT: u32 = 0x00000010; +pub type MemoryPropertyFlags = Flags; + + +pub type MemoryHeapFlagBits = u32; +pub const MEMORY_HEAP_DEVICE_LOCAL_BIT: u32 = 0x00000001; +pub type MemoryHeapFlags = Flags; +pub type DeviceCreateFlags = Flags; +pub type DeviceQueueCreateFlags = Flags; + + +pub type PipelineStageFlagBits = u32; +pub const PIPELINE_STAGE_TOP_OF_PIPE_BIT: u32 = 0x00000001; +pub const PIPELINE_STAGE_DRAW_INDIRECT_BIT: u32 = 0x00000002; +pub const PIPELINE_STAGE_VERTEX_INPUT_BIT: u32 = 0x00000004; +pub const PIPELINE_STAGE_VERTEX_SHADER_BIT: u32 = 0x00000008; +pub const PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT: u32 = 0x00000010; +pub const PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT: u32 = 0x00000020; +pub const PIPELINE_STAGE_GEOMETRY_SHADER_BIT: u32 = 0x00000040; +pub const PIPELINE_STAGE_FRAGMENT_SHADER_BIT: u32 = 0x00000080; +pub const PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT: u32 = 0x00000100; +pub const PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT: u32 = 0x00000200; +pub const PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT: u32 = 0x00000400; +pub const PIPELINE_STAGE_COMPUTE_SHADER_BIT: u32 = 0x00000800; +pub const PIPELINE_STAGE_TRANSFER_BIT: u32 = 0x00001000; +pub const PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT: u32 = 0x00002000; +pub const PIPELINE_STAGE_HOST_BIT: u32 = 0x00004000; +pub const PIPELINE_STAGE_ALL_GRAPHICS_BIT: u32 = 0x00008000; +pub const PIPELINE_STAGE_ALL_COMMANDS_BIT: u32 = 0x00010000; +pub type PipelineStageFlags = Flags; +pub type MemoryMapFlags = Flags; + + +pub type ImageAspectFlagBits = u32; +pub const IMAGE_ASPECT_COLOR_BIT: u32 = 0x00000001; +pub const IMAGE_ASPECT_DEPTH_BIT: u32 = 0x00000002; +pub const IMAGE_ASPECT_STENCIL_BIT: u32 = 0x00000004; +pub const IMAGE_ASPECT_METADATA_BIT: u32 = 0x00000008; +pub type ImageAspectFlags = Flags; + + +pub type SparseImageFormatFlagBits = u32; +pub const SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT: u32 = 0x00000001; +pub const SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT: u32 = 0x00000002; +pub const SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT: u32 = 0x00000004; +pub type SparseImageFormatFlags = Flags; + + +pub type SparseMemoryBindFlagBits = u32; +pub const SPARSE_MEMORY_BIND_METADATA_BIT: u32 = 0x00000001; +pub type SparseMemoryBindFlags = Flags; + + +pub type FenceCreateFlagBits = u32; +pub const FENCE_CREATE_SIGNALED_BIT: u32 = 0x00000001; +pub type FenceCreateFlags = Flags; +pub type SemaphoreCreateFlags = Flags; +pub type EventCreateFlags = Flags; +pub type QueryPoolCreateFlags = Flags; + + +pub type QueryPipelineStatisticFlagBits = u32; +pub const QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT: u32 = 0x00000001; +pub const QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT: u32 = 0x00000002; +pub const QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT: u32 = 0x00000004; +pub const QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT: u32 = 0x00000008; +pub const QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT: u32 = 0x00000010; +pub const QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT: u32 = 0x00000020; +pub const QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT: u32 = 0x00000040; +pub const QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT: u32 = 0x00000080; +pub const QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT: u32 = 0x00000100; +pub const QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT: u32 = 0x00000200; +pub const QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT: u32 = 0x00000400; +pub type QueryPipelineStatisticFlags = Flags; + + +pub type QueryResultFlagBits = u32; +pub const QUERY_RESULT_64_BIT: u32 = 0x00000001; +pub const QUERY_RESULT_WAIT_BIT: u32 = 0x00000002; +pub const QUERY_RESULT_WITH_AVAILABILITY_BIT: u32 = 0x00000004; +pub const QUERY_RESULT_PARTIAL_BIT: u32 = 0x00000008; +pub type QueryResultFlags = Flags; + + +pub type BufferCreateFlagBits = u32; +pub const BUFFER_CREATE_SPARSE_BINDING_BIT: u32 = 0x00000001; +pub const BUFFER_CREATE_SPARSE_RESIDENCY_BIT: u32 = 0x00000002; +pub const BUFFER_CREATE_SPARSE_ALIASED_BIT: u32 = 0x00000004; +pub type BufferCreateFlags = Flags; + + +pub type BufferUsageFlagBits = u32; +pub const BUFFER_USAGE_TRANSFER_SRC_BIT: u32 = 0x00000001; +pub const BUFFER_USAGE_TRANSFER_DST_BIT: u32 = 0x00000002; +pub const BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT: u32 = 0x00000004; +pub const BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT: u32 = 0x00000008; +pub const BUFFER_USAGE_UNIFORM_BUFFER_BIT: u32 = 0x00000010; +pub const BUFFER_USAGE_STORAGE_BUFFER_BIT: u32 = 0x00000020; +pub const BUFFER_USAGE_INDEX_BUFFER_BIT: u32 = 0x00000040; +pub const BUFFER_USAGE_VERTEX_BUFFER_BIT: u32 = 0x00000080; +pub const BUFFER_USAGE_INDIRECT_BUFFER_BIT: u32 = 0x00000100; +pub type BufferUsageFlags = Flags; +pub type BufferViewCreateFlags = Flags; +pub type ImageViewCreateFlags = Flags; +pub type ShaderModuleCreateFlags = Flags; +pub type PipelineCacheCreateFlags = Flags; + + +pub type PipelineCreateFlagBits = u32; +pub const PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT: u32 = 0x00000001; +pub const PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT: u32 = 0x00000002; +pub const PIPELINE_CREATE_DERIVATIVE_BIT: u32 = 0x00000004; +pub type PipelineCreateFlags = Flags; +pub type PipelineShaderStageCreateFlags = Flags; + + +pub type ShaderStageFlagBits = u32; +pub const SHADER_STAGE_VERTEX_BIT: u32 = 0x00000001; +pub const SHADER_STAGE_TESSELLATION_CONTROL_BIT: u32 = 0x00000002; +pub const SHADER_STAGE_TESSELLATION_EVALUATION_BIT: u32 = 0x00000004; +pub const SHADER_STAGE_GEOMETRY_BIT: u32 = 0x00000008; +pub const SHADER_STAGE_FRAGMENT_BIT: u32 = 0x00000010; +pub const SHADER_STAGE_COMPUTE_BIT: u32 = 0x00000020; +pub const SHADER_STAGE_ALL_GRAPHICS: u32 = 0x1F; +pub const SHADER_STAGE_ALL: u32 = 0x7FFFFFFF; +pub type PipelineVertexInputStateCreateFlags = Flags; +pub type PipelineInputAssemblyStateCreateFlags = Flags; +pub type PipelineTessellationStateCreateFlags = Flags; +pub type PipelineViewportStateCreateFlags = Flags; +pub type PipelineRasterizationStateCreateFlags = Flags; + + +pub type CullModeFlagBits = u32; +pub const CULL_MODE_NONE: u32 = 0; +pub const CULL_MODE_FRONT_BIT: u32 = 0x00000001; +pub const CULL_MODE_BACK_BIT: u32 = 0x00000002; +pub const CULL_MODE_FRONT_AND_BACK: u32 = 0x3; +pub type CullModeFlags = Flags; +pub type PipelineMultisampleStateCreateFlags = Flags; +pub type PipelineDepthStencilStateCreateFlags = Flags; +pub type PipelineColorBlendStateCreateFlags = Flags; + + +pub type ColorComponentFlagBits = u32; +pub const COLOR_COMPONENT_R_BIT: u32 = 0x00000001; +pub const COLOR_COMPONENT_G_BIT: u32 = 0x00000002; +pub const COLOR_COMPONENT_B_BIT: u32 = 0x00000004; +pub const COLOR_COMPONENT_A_BIT: u32 = 0x00000008; +pub type ColorComponentFlags = Flags; +pub type PipelineDynamicStateCreateFlags = Flags; +pub type PipelineLayoutCreateFlags = Flags; +pub type ShaderStageFlags = Flags; +pub type SamplerCreateFlags = Flags; +pub type DescriptorSetLayoutCreateFlags = Flags; + + +pub type DescriptorPoolCreateFlagBits = u32; +pub const DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT: u32 = 0x00000001; +pub type DescriptorPoolCreateFlags = Flags; +pub type DescriptorPoolResetFlags = Flags; +pub type FramebufferCreateFlags = Flags; +pub type RenderPassCreateFlags = Flags; + + +pub type AttachmentDescriptionFlagBits = u32; +pub const ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT: u32 = 0x00000001; +pub type AttachmentDescriptionFlags = Flags; +pub type SubpassDescriptionFlags = Flags; + + +pub type AccessFlagBits = u32; +pub const ACCESS_INDIRECT_COMMAND_READ_BIT: u32 = 0x00000001; +pub const ACCESS_INDEX_READ_BIT: u32 = 0x00000002; +pub const ACCESS_VERTEX_ATTRIBUTE_READ_BIT: u32 = 0x00000004; +pub const ACCESS_UNIFORM_READ_BIT: u32 = 0x00000008; +pub const ACCESS_INPUT_ATTACHMENT_READ_BIT: u32 = 0x00000010; +pub const ACCESS_SHADER_READ_BIT: u32 = 0x00000020; +pub const ACCESS_SHADER_WRITE_BIT: u32 = 0x00000040; +pub const ACCESS_COLOR_ATTACHMENT_READ_BIT: u32 = 0x00000080; +pub const ACCESS_COLOR_ATTACHMENT_WRITE_BIT: u32 = 0x00000100; +pub const ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT: u32 = 0x00000200; +pub const ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT: u32 = 0x00000400; +pub const ACCESS_TRANSFER_READ_BIT: u32 = 0x00000800; +pub const ACCESS_TRANSFER_WRITE_BIT: u32 = 0x00001000; +pub const ACCESS_HOST_READ_BIT: u32 = 0x00002000; +pub const ACCESS_HOST_WRITE_BIT: u32 = 0x00004000; +pub const ACCESS_MEMORY_READ_BIT: u32 = 0x00008000; +pub const ACCESS_MEMORY_WRITE_BIT: u32 = 0x00010000; +pub type AccessFlags = Flags; + + +pub type DependencyFlagBits = u32; +pub const DEPENDENCY_BY_REGION_BIT: u32 = 0x00000001; +pub type DependencyFlags = Flags; + + +pub type CommandPoolCreateFlagBits = u32; +pub const COMMAND_POOL_CREATE_TRANSIENT_BIT: u32 = 0x00000001; +pub const COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT: u32 = 0x00000002; +pub type CommandPoolCreateFlags = Flags; + + +pub type CommandPoolResetFlagBits = u32; +pub const COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT: u32 = 0x00000001; +pub type CommandPoolResetFlags = Flags; + + +pub type CommandPoolTrimFlagsKHR = Flags; + + +pub type CommandBufferUsageFlagBits = u32; +pub const COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT: u32 = 0x00000001; +pub const COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT: u32 = 0x00000002; +pub const COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT: u32 = 0x00000004; +pub type CommandBufferUsageFlags = Flags; + + +pub type QueryControlFlagBits = u32; +pub const QUERY_CONTROL_PRECISE_BIT: u32 = 0x00000001; +pub type QueryControlFlags = Flags; + + +pub type CommandBufferResetFlagBits = u32; +pub const COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT: u32 = 0x00000001; +pub type CommandBufferResetFlags = Flags; + + +pub type StencilFaceFlagBits = u32; +pub const STENCIL_FACE_FRONT_BIT: u32 = 0x00000001; +pub const STENCIL_FACE_BACK_BIT: u32 = 0x00000002; +pub const STENCIL_FRONT_AND_BACK: u32 = 0x3; +pub type StencilFaceFlags = Flags; + + +pub type DisplayPlaneAlphaFlagBitsKHR = u32; +pub const DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR: u32 = 0x00000001; +pub const DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR: u32 = 0x00000002; +pub const DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR: u32 = 0x00000004; +pub const DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR: u32 = 0x00000008; +pub type DisplayModeCreateFlagsKHR = Flags; +pub type DisplayPlaneAlphaFlagsKHR = Flags; +pub type DisplaySurfaceCreateFlagsKHR = Flags; + +pub type ColorSpaceKHR = u32; +#[deprecated = "Renamed to COLOR_SPACE_SRGB_NONLINEAR_KHR"] +pub const COLORSPACE_SRGB_NONLINEAR_KHR: u32 = 0; +#[deprecated = "Magically disappeared from the Vulkan specs"] +pub const COLOR_SPACE_DISPLAY_P3_LINEAR_EXT: u32 = 1000104001; +#[deprecated = "Magically disappeared from the Vulkan specs"] +pub const COLOR_SPACE_SCRGB_LINEAR_EXT: u32 = 1000104003; +#[deprecated = "Magically disappeared from the Vulkan specs"] +pub const COLOR_SPACE_SCRGB_NONLINEAR_EXT: u32 = 1000104004; +#[deprecated = "Magically disappeared from the Vulkan specs"] +pub const COLOR_SPACE_BT2020_NONLINEAR_EXT: u32 = 1000104010; +pub const COLOR_SPACE_SRGB_NONLINEAR_KHR: u32 = 0; +pub const COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT: u32 = 1000104001; +pub const COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT: u32 = 1000104002; +pub const COLOR_SPACE_DCI_P3_LINEAR_EXT: u32 = 1000104003; +pub const COLOR_SPACE_DCI_P3_NONLINEAR_EXT: u32 = 1000104004; +pub const COLOR_SPACE_BT709_LINEAR_EXT: u32 = 1000104005; +pub const COLOR_SPACE_BT709_NONLINEAR_EXT: u32 = 1000104006; +pub const COLOR_SPACE_BT2020_LINEAR_EXT: u32 = 1000104007; +pub const COLOR_SPACE_HDR10_ST2084_EXT: u32 = 1000104008; +pub const COLOR_SPACE_DOLBYVISION_EXT: u32 = 1000104009; +pub const COLOR_SPACE_HDR10_HLG_EXT: u32 = 1000104010; +pub const COLOR_SPACE_ADOBERGB_LINEAR_EXT: u32 = 1000104011; +pub const COLOR_SPACE_ADOBERGB_NONLINEAR_EXT: u32 = 1000104012; +pub const COLOR_SPACE_PASS_THROUGH_EXT: u32 = 1000104013; + +pub type PresentModeKHR = u32; +pub const PRESENT_MODE_IMMEDIATE_KHR: u32 = 0; +pub const PRESENT_MODE_MAILBOX_KHR: u32 = 1; +pub const PRESENT_MODE_FIFO_KHR: u32 = 2; +pub const PRESENT_MODE_FIFO_RELAXED_KHR: u32 = 3; +pub const PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR: u32 = 1000111000; +pub const PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR: u32 = 1000111001; + +pub type SurfaceTransformFlagBitsKHR = u32; +pub const SURFACE_TRANSFORM_IDENTITY_BIT_KHR: u32 = 0x00000001; +pub const SURFACE_TRANSFORM_ROTATE_90_BIT_KHR: u32 = 0x00000002; +pub const SURFACE_TRANSFORM_ROTATE_180_BIT_KHR: u32 = 0x00000004; +pub const SURFACE_TRANSFORM_ROTATE_270_BIT_KHR: u32 = 0x00000008; +pub const SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR: u32 = 0x00000010; +pub const SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR: u32 = 0x00000020; +pub const SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR: u32 = 0x00000040; +pub const SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR: u32 = 0x00000080; +pub const SURFACE_TRANSFORM_INHERIT_BIT_KHR: u32 = 0x00000100; +pub type SurfaceTransformFlagsKHR = Flags; + +pub type CompositeAlphaFlagBitsKHR = u32; +pub const COMPOSITE_ALPHA_OPAQUE_BIT_KHR: u32 = 0x00000001; +pub const COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR: u32 = 0x00000002; +pub const COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR: u32 = 0x00000004; +pub const COMPOSITE_ALPHA_INHERIT_BIT_KHR: u32 = 0x00000008; +pub type CompositeAlphaFlagsKHR = Flags; + +pub type DebugReportObjectTypeEXT = u32; +pub const DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT: u32 = 0; +pub const DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT: u32 = 1; +pub const DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT: u32 = 2; +pub const DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT: u32 = 3; +pub const DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT: u32 = 4; +pub const DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT: u32 = 5; +pub const DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT: u32 = 6; +pub const DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT: u32 = 7; +pub const DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT: u32 = 8; +pub const DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: u32 = 9; +pub const DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: u32 = 10; +pub const DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT: u32 = 11; +pub const DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT: u32 = 12; +pub const DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT: u32 = 13; +pub const DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT: u32 = 14; +pub const DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT: u32 = 15; +pub const DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT: u32 = 16; +pub const DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT: u32 = 17; +pub const DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT: u32 = 18; +pub const DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT: u32 = 19; +pub const DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT: u32 = 20; +pub const DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT: u32 = 21; +pub const DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT: u32 = 22; +pub const DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT: u32 = 23; +pub const DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT: u32 = 24; +pub const DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT: u32 = 25; +pub const DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT: u32 = 26; +pub const DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT: u32 = 27; +#[deprecated = "Renamed to DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT"] +pub const DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT: u32 = DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT; +pub const DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT: u32 = 28; +pub const DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT: u32 = 29; +pub const DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT: u32 = 30; +pub const DEBUG_REPORT_OBJECT_TYPE_OBJECT_TABLE_NVX_EXT: u32 = 31; +pub const DEBUG_REPORT_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX_EXT: u32 = 32; +pub const DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT: u32 = 33; +pub const DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR_EXT: u32 = 1000085000; + +pub type DebugReportErrorEXT = u32; +pub const DEBUG_REPORT_ERROR_NONE_EXT: u32 = 0; +pub const DEBUG_REPORT_ERROR_CALLBACK_REF_EXT: u32 = 1; + +pub type DebugReportFlagBitsEXT = u32; +pub const DEBUG_REPORT_INFORMATION_BIT_EXT: u32 = 0x00000001; +pub const DEBUG_REPORT_WARNING_BIT_EXT: u32 = 0x00000002; +pub const DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT: u32 = 0x00000004; +pub const DEBUG_REPORT_ERROR_BIT_EXT: u32 = 0x00000008; +pub const DEBUG_REPORT_DEBUG_BIT_EXT: u32 = 0x00000010; +pub type DebugReportFlagsEXT = Flags; + +pub type MacOSSurfaceCreateFlagsMVK = u32; + +pub type IOSSurfaceCreateFlagsMVK = u32; + +pub type DescriptorSetLayoutCreateFlagBits = u32; +pub const DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR: u32 = 0x00000001; + +pub type DescriptorUpdateTemplateTypeKHR = u32; +pub const DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR: u32 = 0; +pub const DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR: u32 = 1; +pub const DESCRIPTOR_UPDATE_TEMPLATE_TYPE_BEGIN_RANGE_KHR: u32 = DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR; +pub const DESCRIPTOR_UPDATE_TEMPLATE_TYPE_END_RANGE_KHR: u32 = DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR; +pub const DESCRIPTOR_UPDATE_TEMPLATE_TYPE_RANGE_SIZE_KHR: u32 = (DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR - DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR + 1); +pub type DescriptorUpdateTemplateCreateFlagsKHR = Flags; + +pub type PFN_vkAllocationFunction = extern "system" fn(*mut c_void, usize, usize, SystemAllocationScope) -> *mut c_void; +pub type PFN_vkReallocationFunction = extern "system" fn(*mut c_void, *mut c_void, usize, usize, SystemAllocationScope) -> *mut c_void; +pub type PFN_vkFreeFunction = extern "system" fn(*mut c_void, *mut c_void); +pub type PFN_vkInternalAllocationNotification = extern "system" fn(*mut c_void, usize, InternalAllocationType, SystemAllocationScope) -> *mut c_void; +pub type PFN_vkInternalFreeNotification = extern "system" fn(*mut c_void, usize, InternalAllocationType, SystemAllocationScope) -> *mut c_void; +pub type PFN_vkDebugReportCallbackEXT = extern "system" fn(DebugReportFlagsEXT, DebugReportObjectTypeEXT, u64, usize, i32, *const c_char, *const c_char, *mut c_void) -> Bool32; + +pub type PFN_vkVoidFunction = extern "system" fn() -> (); + +#[repr(C)] +pub struct ApplicationInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub pApplicationName: *const c_char, + pub applicationVersion: u32, + pub pEngineName: *const c_char, + pub engineVersion: u32, + pub apiVersion: u32, +} + +#[repr(C)] +pub struct InstanceCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: InstanceCreateFlags, + pub pApplicationInfo: *const ApplicationInfo, + pub enabledLayerCount: u32, + pub ppEnabledLayerNames: *const *const c_char, + pub enabledExtensionCount: u32, + pub ppEnabledExtensionNames: *const *const c_char, +} + +#[repr(C)] +pub struct AllocationCallbacks { + pub pUserData: *mut c_void, + pub pfnAllocation: PFN_vkAllocationFunction, + pub pfnReallocation: PFN_vkReallocationFunction, + pub pfnFree: PFN_vkFreeFunction, + pub pfnInternalAllocation: PFN_vkInternalAllocationNotification, + pub pfnInternalFree: PFN_vkInternalFreeNotification, +} + +#[repr(C)] +pub struct PhysicalDeviceFeatures { + pub robustBufferAccess: Bool32, + pub fullDrawIndexUint32: Bool32, + pub imageCubeArray: Bool32, + pub independentBlend: Bool32, + pub geometryShader: Bool32, + pub tessellationShader: Bool32, + pub sampleRateShading: Bool32, + pub dualSrcBlend: Bool32, + pub logicOp: Bool32, + pub multiDrawIndirect: Bool32, + pub drawIndirectFirstInstance: Bool32, + pub depthClamp: Bool32, + pub depthBiasClamp: Bool32, + pub fillModeNonSolid: Bool32, + pub depthBounds: Bool32, + pub wideLines: Bool32, + pub largePoints: Bool32, + pub alphaToOne: Bool32, + pub multiViewport: Bool32, + pub samplerAnisotropy: Bool32, + pub textureCompressionETC2: Bool32, + pub textureCompressionASTC_LDR: Bool32, + pub textureCompressionBC: Bool32, + pub occlusionQueryPrecise: Bool32, + pub pipelineStatisticsQuery: Bool32, + pub vertexPipelineStoresAndAtomics: Bool32, + pub fragmentStoresAndAtomics: Bool32, + pub shaderTessellationAndGeometryPointSize: Bool32, + pub shaderImageGatherExtended: Bool32, + pub shaderStorageImageExtendedFormats: Bool32, + pub shaderStorageImageMultisample: Bool32, + pub shaderStorageImageReadWithoutFormat: Bool32, + pub shaderStorageImageWriteWithoutFormat: Bool32, + pub shaderUniformBufferArrayDynamicIndexing: Bool32, + pub shaderSampledImageArrayDynamicIndexing: Bool32, + pub shaderStorageBufferArrayDynamicIndexing: Bool32, + pub shaderStorageImageArrayDynamicIndexing: Bool32, + pub shaderClipDistance: Bool32, + pub shaderCullDistance: Bool32, + pub shaderf3264: Bool32, + pub shaderInt64: Bool32, + pub shaderInt16: Bool32, + pub shaderResourceResidency: Bool32, + pub shaderResourceMinLod: Bool32, + pub sparseBinding: Bool32, + pub sparseResidencyBuffer: Bool32, + pub sparseResidencyImage2D: Bool32, + pub sparseResidencyImage3D: Bool32, + pub sparseResidency2Samples: Bool32, + pub sparseResidency4Samples: Bool32, + pub sparseResidency8Samples: Bool32, + pub sparseResidency16Samples: Bool32, + pub sparseResidencyAliased: Bool32, + pub variableMultisampleRate: Bool32, + pub inheritedQueries: Bool32, +} + +#[repr(C)] +pub struct FormatProperties { + pub linearTilingFeatures: FormatFeatureFlags, + pub optimalTilingFeatures: FormatFeatureFlags, + pub bufferFeatures: FormatFeatureFlags, +} + +#[repr(C)] +pub struct Extent3D { + pub width: u32, + pub height: u32, + pub depth: u32, +} + +#[repr(C)] +pub struct ImageFormatProperties { + pub maxExtent: Extent3D, + pub maxMipLevels: u32, + pub maxArrayLayers: u32, + pub sampleCounts: SampleCountFlags, + pub maxResourceSize: DeviceSize, +} + +#[repr(C)] +pub struct PhysicalDeviceLimits { + pub maxImageDimension1D: u32, + pub maxImageDimension2D: u32, + pub maxImageDimension3D: u32, + pub maxImageDimensionCube: u32, + pub maxImageArrayLayers: u32, + pub maxTexelBufferElements: u32, + pub maxUniformBufferRange: u32, + pub maxStorageBufferRange: u32, + pub maxPushConstantsSize: u32, + pub maxMemoryAllocationCount: u32, + pub maxSamplerAllocationCount: u32, + pub bufferImageGranularity: DeviceSize, + pub sparseAddressSpaceSize: DeviceSize, + pub maxBoundDescriptorSets: u32, + pub maxPerStageDescriptorSamplers: u32, + pub maxPerStageDescriptorUniformBuffers: u32, + pub maxPerStageDescriptorStorageBuffers: u32, + pub maxPerStageDescriptorSampledImages: u32, + pub maxPerStageDescriptorStorageImages: u32, + pub maxPerStageDescriptorInputAttachments: u32, + pub maxPerStageResources: u32, + pub maxDescriptorSetSamplers: u32, + pub maxDescriptorSetUniformBuffers: u32, + pub maxDescriptorSetUniformBuffersDynamic: u32, + pub maxDescriptorSetStorageBuffers: u32, + pub maxDescriptorSetStorageBuffersDynamic: u32, + pub maxDescriptorSetSampledImages: u32, + pub maxDescriptorSetStorageImages: u32, + pub maxDescriptorSetInputAttachments: u32, + pub maxVertexInputAttributes: u32, + pub maxVertexInputBindings: u32, + pub maxVertexInputAttributeOffset: u32, + pub maxVertexInputBindingStride: u32, + pub maxVertexOutputComponents: u32, + pub maxTessellationGenerationLevel: u32, + pub maxTessellationPatchSize: u32, + pub maxTessellationControlPerVertexInputComponents: u32, + pub maxTessellationControlPerVertexOutputComponents: u32, + pub maxTessellationControlPerPatchOutputComponents: u32, + pub maxTessellationControlTotalOutputComponents: u32, + pub maxTessellationEvaluationInputComponents: u32, + pub maxTessellationEvaluationOutputComponents: u32, + pub maxGeometryShaderInvocations: u32, + pub maxGeometryInputComponents: u32, + pub maxGeometryOutputComponents: u32, + pub maxGeometryOutputVertices: u32, + pub maxGeometryTotalOutputComponents: u32, + pub maxFragmentInputComponents: u32, + pub maxFragmentOutputAttachments: u32, + pub maxFragmentDualSrcAttachments: u32, + pub maxFragmentCombinedOutputResources: u32, + pub maxComputeSharedMemorySize: u32, + pub maxComputeWorkGroupCount: [u32; 3], + pub maxComputeWorkGroupInvocations: u32, + pub maxComputeWorkGroupSize: [u32; 3], + pub subPixelPrecisionBits: u32, + pub subTexelPrecisionBits: u32, + pub mipmapPrecisionBits: u32, + pub maxDrawIndexedIndexValue: u32, + pub maxDrawIndirectCount: u32, + pub maxSamplerLodBias: f32, + pub maxSamplerAnisotropy: f32, + pub maxViewports: u32, + pub maxViewportDimensions: [u32; 2], + pub viewportBoundsRange: [f32; 2], + pub viewportSubPixelBits: u32, + pub minMemoryMapAlignment: usize, + pub minTexelBufferOffsetAlignment: DeviceSize, + pub minUniformBufferOffsetAlignment: DeviceSize, + pub minStorageBufferOffsetAlignment: DeviceSize, + pub minTexelOffset: i32, + pub maxTexelOffset: u32, + pub minTexelGatherOffset: i32, + pub maxTexelGatherOffset: u32, + pub minInterpolationOffset: f32, + pub maxInterpolationOffset: f32, + pub subPixelInterpolationOffsetBits: u32, + pub maxFramebufferWidth: u32, + pub maxFramebufferHeight: u32, + pub maxFramebufferLayers: u32, + pub framebufferColorSampleCounts: SampleCountFlags, + pub framebufferDepthSampleCounts: SampleCountFlags, + pub framebufferStencilSampleCounts: SampleCountFlags, + pub framebufferNoAttachmentsSampleCounts: SampleCountFlags, + pub maxColorAttachments: u32, + pub sampledImageColorSampleCounts: SampleCountFlags, + pub sampledImageIntegerSampleCounts: SampleCountFlags, + pub sampledImageDepthSampleCounts: SampleCountFlags, + pub sampledImageStencilSampleCounts: SampleCountFlags, + pub storageImageSampleCounts: SampleCountFlags, + pub maxSampleMaskWords: u32, + pub timestampComputeAndGraphics: Bool32, + pub timestampPeriod: f32, + pub maxClipDistances: u32, + pub maxCullDistances: u32, + pub maxCombinedClipAndCullDistances: u32, + pub discreteQueuePriorities: u32, + pub pointSizeRange: [f32; 2], + pub lineWidthRange: [f32; 2], + pub pointSizeGranularity: f32, + pub lineWidthGranularity: f32, + pub strictLines: Bool32, + pub standardSampleLocations: Bool32, + pub optimalBufferCopyOffsetAlignment: DeviceSize, + pub optimalBufferCopyRowPitchAlignment: DeviceSize, + pub nonCoherentAtomSize: DeviceSize, +} + +#[repr(C)] +pub struct PhysicalDeviceSparseProperties { + pub residencyStandard2DBlockShape: Bool32, + pub residencyStandard2DMultisampleBlockShape: Bool32, + pub residencyStandard3DBlockShape: Bool32, + pub residencyAlignedMipSize: Bool32, + pub residencyNonResidentStrict: Bool32, +} + +#[repr(C)] +pub struct PhysicalDeviceProperties { + pub apiVersion: u32, + pub driverVersion: u32, + pub vendorID: u32, + pub deviceID: u32, + pub deviceType: PhysicalDeviceType, + pub deviceName: [c_char; MAX_PHYSICAL_DEVICE_NAME_SIZE as usize], + pub pipelineCacheUUID: [u8; UUID_SIZE as usize], + pub limits: PhysicalDeviceLimits, + pub sparseProperties: PhysicalDeviceSparseProperties, +} + +#[repr(C)] +pub struct QueueFamilyProperties { + pub queueFlags: QueueFlags, + pub queueCount: u32, + pub timestampValidBits: u32, + pub minImageTransferGranularity: Extent3D, +} + +#[repr(C)] +pub struct MemoryType { + pub propertyFlags: MemoryPropertyFlags, + pub heapIndex: u32, +} + +#[repr(C)] +pub struct MemoryHeap { + pub size: DeviceSize, + pub flags: MemoryHeapFlags, +} + +#[repr(C)] +pub struct PhysicalDeviceMemoryProperties { + pub memoryTypeCount: u32, + pub memoryTypes: [MemoryType; MAX_MEMORY_TYPES as usize], + pub memoryHeapCount: u32, + pub memoryHeaps: [MemoryHeap; MAX_MEMORY_HEAPS as usize], +} + +#[repr(C)] +pub struct DeviceQueueCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: DeviceQueueCreateFlags, + pub queueFamilyIndex: u32, + pub queueCount: u32, + pub pQueuePriorities: *const f32, +} + +#[repr(C)] +pub struct DeviceCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: DeviceCreateFlags, + pub queueCreateInfoCount: u32, + pub pQueueCreateInfos: *const DeviceQueueCreateInfo, + pub enabledLayerCount: u32, + pub ppEnabledLayerNames: *const *const c_char, + pub enabledExtensionCount: u32, + pub ppEnabledExtensionNames: *const *const c_char, + pub pEnabledFeatures: *const PhysicalDeviceFeatures, +} + +#[repr(C)] +pub struct ExtensionProperties { + pub extensionName: [c_char; MAX_EXTENSION_NAME_SIZE as usize], + pub specVersion: u32, +} + +#[repr(C)] +pub struct LayerProperties { + pub layerName: [c_char; MAX_EXTENSION_NAME_SIZE as usize], + pub specVersion: u32, + pub implementationVersion: u32, + pub description: [c_char; MAX_DESCRIPTION_SIZE as usize], +} + +#[repr(C)] +pub struct SubmitInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub waitSemaphoreCount: u32, + pub pWaitSemaphores: *const Semaphore, + pub pWaitDstStageMask: *const PipelineStageFlags, + pub commandBufferCount: u32, + pub pCommandBuffers: *const CommandBuffer, + pub signalSemaphoreCount: u32, + pub pSignalSemaphores: *const Semaphore, +} + +#[repr(C)] +pub struct MemoryAllocateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub allocationSize: DeviceSize, + pub memoryTypeIndex: u32, +} + +#[repr(C)] +pub struct MappedMemoryRange { + pub sType: StructureType, + pub pNext: *const c_void, + pub memory: DeviceMemory, + pub offset: DeviceSize, + pub size: DeviceSize, +} + +#[repr(C)] +pub struct MemoryRequirements { + pub size: DeviceSize, + pub alignment: DeviceSize, + pub memoryTypeBits: u32, +} + +#[repr(C)] +pub struct SparseImageFormatProperties { + pub aspectMask: ImageAspectFlags, + pub imageGranularity: Extent3D, + pub flags: SparseImageFormatFlags, +} + +#[repr(C)] +pub struct SparseImageMemoryRequirements { + pub formatProperties: SparseImageFormatProperties, + pub imageMipTailFirstLod: u32, + pub imageMipTailSize: DeviceSize, + pub imageMipTailOffset: DeviceSize, + pub imageMipTailStride: DeviceSize, +} + +#[repr(C)] +pub struct SparseMemoryBind { + pub resourceOffset: DeviceSize, + pub size: DeviceSize, + pub memory: DeviceMemory, + pub memoryOffset: DeviceSize, + pub flags: SparseMemoryBindFlags, +} + +#[repr(C)] +pub struct SparseBufferMemoryBindInfo { + pub buffer: Buffer, + pub bindCount: u32, + pub pBinds: *const SparseMemoryBind, +} + +#[repr(C)] +pub struct SparseImageOpaqueMemoryBindInfo { + pub image: Image, + pub bindCount: u32, + pub pBinds: *const SparseMemoryBind, +} + +#[repr(C)] +pub struct ImageSubresource { + pub aspectMask: ImageAspectFlags, + pub mipLevel: u32, + pub arrayLayer: u32, +} + +#[repr(C)] +pub struct Offset3D { + pub x: i32, + pub y: i32, + pub z: i32, +} + +#[repr(C)] +pub struct SparseImageMemoryBind { + pub subresource: ImageSubresource, + pub offset: Offset3D, + pub extent: Extent3D, + pub memory: DeviceMemory, + pub memoryOffset: DeviceSize, + pub flags: SparseMemoryBindFlags, +} + +#[repr(C)] +pub struct SparseImageMemoryBindInfo { + pub image: Image, + pub bindCount: u32, + pub pBinds: *const SparseImageMemoryBind, +} + +#[repr(C)] +pub struct BindSparseInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub waitSemaphoreCount: u32, + pub pWaitSemaphores: *const Semaphore, + pub bufferBindCount: u32, + pub pBufferBinds: *const SparseBufferMemoryBindInfo, + pub imageOpaqueBindCount: u32, + pub pImageOpaqueBinds: *const SparseImageOpaqueMemoryBindInfo, + pub imageBindCount: u32, + pub pImageBinds: *const SparseImageMemoryBindInfo, + pub signalSemaphoreCount: u32, + pub pSignalSemaphores: *const Semaphore, +} + +#[repr(C)] +pub struct FenceCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: FenceCreateFlags, +} + +#[repr(C)] +pub struct SemaphoreCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: SemaphoreCreateFlags, +} + +#[repr(C)] +pub struct EventCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: EventCreateFlags, +} + +#[repr(C)] +pub struct QueryPoolCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: QueryPoolCreateFlags, + pub queryType: QueryType, + pub queryCount: u32, + pub pipelineStatistics: QueryPipelineStatisticFlags, +} + +#[repr(C)] +pub struct BufferCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: BufferCreateFlags, + pub size: DeviceSize, + pub usage: BufferUsageFlags, + pub sharingMode: SharingMode, + pub queueFamilyIndexCount: u32, + pub pQueueFamilyIndices: *const u32, +} + +#[repr(C)] +pub struct BufferViewCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: BufferViewCreateFlags, + pub buffer: Buffer, + pub format: Format, + pub offset: DeviceSize, + pub range: DeviceSize, +} + +#[repr(C)] +pub struct ImageCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: ImageCreateFlags, + pub imageType: ImageType, + pub format: Format, + pub extent: Extent3D, + pub mipLevels: u32, + pub arrayLayers: u32, + pub samples: SampleCountFlagBits, + pub tiling: ImageTiling, + pub usage: ImageUsageFlags, + pub sharingMode: SharingMode, + pub queueFamilyIndexCount: u32, + pub pQueueFamilyIndices: *const u32, + pub initialLayout: ImageLayout, +} + +#[repr(C)] +pub struct SubresourceLayout { + pub offset: DeviceSize, + pub size: DeviceSize, + pub rowPitch: DeviceSize, + pub arrayPitch: DeviceSize, + pub depthPitch: DeviceSize, +} + +#[repr(C)] +pub struct ComponentMapping { + pub r: ComponentSwizzle, + pub g: ComponentSwizzle, + pub b: ComponentSwizzle, + pub a: ComponentSwizzle, +} + +#[repr(C)] +pub struct ImageSubresourceRange { + pub aspectMask: ImageAspectFlags, + pub baseMipLevel: u32, + pub levelCount: u32, + pub baseArrayLayer: u32, + pub layerCount: u32, +} + +#[repr(C)] +pub struct ImageViewCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: ImageViewCreateFlags, + pub image: Image, + pub viewType: ImageViewType, + pub format: Format, + pub components: ComponentMapping, + pub subresourceRange: ImageSubresourceRange, +} + +#[repr(C)] +pub struct ShaderModuleCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: ShaderModuleCreateFlags, + pub codeSize: usize, + pub pCode: *const u32, +} + +#[repr(C)] +pub struct PipelineCacheCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineCacheCreateFlags, + pub initialDataSize: usize, + pub pInitialData: *const c_void, +} + +#[repr(C)] +pub struct SpecializationMapEntry { + pub constantID: u32, + pub offset: u32, + pub size: usize, +} + +#[repr(C)] +pub struct SpecializationInfo { + pub mapEntryCount: u32, + pub pMapEntries: *const SpecializationMapEntry, + pub dataSize: usize, + pub pData: *const c_void, +} + +#[repr(C)] +pub struct PipelineShaderStageCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineShaderStageCreateFlags, + pub stage: ShaderStageFlagBits, + pub module: ShaderModule, + pub pName: *const c_char, + pub pSpecializationInfo: *const SpecializationInfo, +} + +#[repr(C)] +pub struct VertexInputBindingDescription { + pub binding: u32, + pub stride: u32, + pub inputRate: VertexInputRate, +} + +#[repr(C)] +pub struct VertexInputAttributeDescription { + pub location: u32, + pub binding: u32, + pub format: Format, + pub offset: u32, +} + +#[repr(C)] +pub struct PipelineVertexInputStateCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineVertexInputStateCreateFlags, + pub vertexBindingDescriptionCount: u32, + pub pVertexBindingDescriptions: *const VertexInputBindingDescription, + pub vertexAttributeDescriptionCount: u32, + pub pVertexAttributeDescriptions: *const VertexInputAttributeDescription, +} + +#[repr(C)] +pub struct PipelineInputAssemblyStateCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineInputAssemblyStateCreateFlags, + pub topology: PrimitiveTopology, + pub primitiveRestartEnable: Bool32, +} + +#[repr(C)] +pub struct PipelineTessellationStateCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineTessellationStateCreateFlags, + pub patchControlPoints: u32, +} + +#[repr(C)] +pub struct Viewport { + pub x: f32, + pub y: f32, + pub width: f32, + pub height: f32, + pub minDepth: f32, + pub maxDepth: f32, +} + +#[repr(C)] +pub struct Offset2D { + pub x: i32, + pub y: i32, +} + +#[repr(C)] +pub struct Extent2D { + pub width: u32, + pub height: u32, +} + +#[repr(C)] +pub struct Rect2D { + pub offset: Offset2D, + pub extent: Extent2D, +} + +#[repr(C)] +pub struct PipelineViewportStateCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineViewportStateCreateFlags, + pub viewportCount: u32, + pub pViewports: *const Viewport, + pub scissorCount: u32, + pub pScissors: *const Rect2D, +} + +#[repr(C)] +pub struct PipelineRasterizationStateCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineRasterizationStateCreateFlags, + pub depthClampEnable: Bool32, + pub rasterizerDiscardEnable: Bool32, + pub polygonMode: PolygonMode, + pub cullMode: CullModeFlags, + pub frontFace: FrontFace, + pub depthBiasEnable: Bool32, + pub depthBiasConstantFactor: f32, + pub depthBiasClamp: f32, + pub depthBiasSlopeFactor: f32, + pub lineWidth: f32, +} + +#[repr(C)] +pub struct PipelineMultisampleStateCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineMultisampleStateCreateFlags, + pub rasterizationSamples: SampleCountFlagBits, + pub sampleShadingEnable: Bool32, + pub minSampleShading: f32, + pub pSampleMask: *const SampleMask, + pub alphaToCoverageEnable: Bool32, + pub alphaToOneEnable: Bool32, +} + +#[repr(C)] +pub struct StencilOpState { + pub failOp: StencilOp, + pub passOp: StencilOp, + pub depthFailOp: StencilOp, + pub compareOp: CompareOp, + pub compareMask: u32, + pub writeMask: u32, + pub reference: u32, +} + +#[repr(C)] +pub struct PipelineDepthStencilStateCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineDepthStencilStateCreateFlags, + pub depthTestEnable: Bool32, + pub depthWriteEnable: Bool32, + pub depthCompareOp: CompareOp, + pub depthBoundsTestEnable: Bool32, + pub stencilTestEnable: Bool32, + pub front: StencilOpState, + pub back: StencilOpState, + pub minDepthBounds: f32, + pub maxDepthBounds: f32, +} + +#[repr(C)] +pub struct PipelineColorBlendAttachmentState { + pub blendEnable: Bool32, + pub srcColorBlendFactor: BlendFactor, + pub dstColorBlendFactor: BlendFactor, + pub colorBlendOp: BlendOp, + pub srcAlphaBlendFactor: BlendFactor, + pub dstAlphaBlendFactor: BlendFactor, + pub alphaBlendOp: BlendOp, + pub colorWriteMask: ColorComponentFlags, +} + +#[repr(C)] +pub struct PipelineColorBlendStateCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineColorBlendStateCreateFlags, + pub logicOpEnable: Bool32, + pub logicOp: LogicOp, + pub attachmentCount: u32, + pub pAttachments: *const PipelineColorBlendAttachmentState, + pub blendConstants: [f32; 4], +} + +#[repr(C)] +pub struct PipelineDynamicStateCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineDynamicStateCreateFlags, + pub dynamicStateCount: u32, + pub pDynamicStates: *const DynamicState, +} + +#[repr(C)] +pub struct GraphicsPipelineCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineCreateFlags, + pub stageCount: u32, + pub pStages: *const PipelineShaderStageCreateInfo, + pub pVertexInputState: *const PipelineVertexInputStateCreateInfo, + pub pInputAssemblyState: *const PipelineInputAssemblyStateCreateInfo, + pub pTessellationState: *const PipelineTessellationStateCreateInfo, + pub pViewportState: *const PipelineViewportStateCreateInfo, + pub pRasterizationState: *const PipelineRasterizationStateCreateInfo, + pub pMultisampleState: *const PipelineMultisampleStateCreateInfo, + pub pDepthStencilState: *const PipelineDepthStencilStateCreateInfo, + pub pColorBlendState: *const PipelineColorBlendStateCreateInfo, + pub pDynamicState: *const PipelineDynamicStateCreateInfo, + pub layout: PipelineLayout, + pub renderPass: RenderPass, + pub subpass: u32, + pub basePipelineHandle: Pipeline, + pub basePipelineIndex: i32, +} + +#[repr(C)] +pub struct ComputePipelineCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineCreateFlags, + pub stage: PipelineShaderStageCreateInfo, + pub layout: PipelineLayout, + pub basePipelineHandle: Pipeline, + pub basePipelineIndex: i32, +} + +#[repr(C)] +pub struct PushConstantRange { + pub stageFlags: ShaderStageFlags, + pub offset: u32, + pub size: u32, +} + +#[repr(C)] +pub struct PipelineLayoutCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: PipelineLayoutCreateFlags, + pub setLayoutCount: u32, + pub pSetLayouts: *const DescriptorSetLayout, + pub pushConstantRangeCount: u32, + pub pPushConstantRanges: *const PushConstantRange, +} + +#[repr(C)] +pub struct SamplerCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: SamplerCreateFlags, + pub magFilter: Filter, + pub minFilter: Filter, + pub mipmapMode: SamplerMipmapMode, + pub addressModeU: SamplerAddressMode, + pub addressModeV: SamplerAddressMode, + pub addressModeW: SamplerAddressMode, + pub mipLodBias: f32, + pub anisotropyEnable: Bool32, + pub maxAnisotropy: f32, + pub compareEnable: Bool32, + pub compareOp: CompareOp, + pub minLod: f32, + pub maxLod: f32, + pub borderColor: BorderColor, + pub unnormalizedCoordinates: Bool32, +} + +#[repr(C)] +pub struct DescriptorSetLayoutBinding { + pub binding: u32, + pub descriptorType: DescriptorType, + pub descriptorCount: u32, + pub stageFlags: ShaderStageFlags, + pub pImmutableSamplers: *const Sampler, +} + +#[repr(C)] +pub struct DescriptorSetLayoutCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: DescriptorSetLayoutCreateFlags, + pub bindingCount: u32, + pub pBindings: *const DescriptorSetLayoutBinding, +} + +#[repr(C)] +pub struct DescriptorPoolSize { + pub ty: DescriptorType, + pub descriptorCount: u32, +} + +#[repr(C)] +pub struct DescriptorPoolCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: DescriptorPoolCreateFlags, + pub maxSets: u32, + pub poolSizeCount: u32, + pub pPoolSizes: *const DescriptorPoolSize, +} + +#[repr(C)] +pub struct DescriptorSetAllocateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub descriptorPool: DescriptorPool, + pub descriptorSetCount: u32, + pub pSetLayouts: *const DescriptorSetLayout, +} + +#[repr(C)] +pub struct DescriptorImageInfo { + pub sampler: Sampler, + pub imageView: ImageView, + pub imageLayout: ImageLayout, +} + +#[repr(C)] +pub struct DescriptorBufferInfo { + pub buffer: Buffer, + pub offset: DeviceSize, + pub range: DeviceSize, +} + +#[repr(C)] +pub struct WriteDescriptorSet { + pub sType: StructureType, + pub pNext: *const c_void, + pub dstSet: DescriptorSet, + pub dstBinding: u32, + pub dstArrayElement: u32, + pub descriptorCount: u32, + pub descriptorType: DescriptorType, + pub pImageInfo: *const DescriptorImageInfo, + pub pBufferInfo: *const DescriptorBufferInfo, + pub pTexelBufferView: *const BufferView, +} + +#[repr(C)] +pub struct CopyDescriptorSet { + pub sType: StructureType, + pub pNext: *const c_void, + pub srcSet: DescriptorSet, + pub srcBinding: u32, + pub srcArrayElement: u32, + pub dstSet: DescriptorSet, + pub dstBinding: u32, + pub dstArrayElement: u32, + pub descriptorCount: u32, +} + +#[repr(C)] +pub struct FramebufferCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: FramebufferCreateFlags, + pub renderPass: RenderPass, + pub attachmentCount: u32, + pub pAttachments: *const ImageView, + pub width: u32, + pub height: u32, + pub layers: u32, +} + +#[repr(C)] +pub struct AttachmentDescription { + pub flags: AttachmentDescriptionFlags, + pub format: Format, + pub samples: SampleCountFlagBits, + pub loadOp: AttachmentLoadOp, + pub storeOp: AttachmentStoreOp, + pub stencilLoadOp: AttachmentLoadOp, + pub stencilStoreOp: AttachmentStoreOp, + pub initialLayout: ImageLayout, + pub finalLayout: ImageLayout, +} + +#[repr(C)] +pub struct AttachmentReference { + pub attachment: u32, + pub layout: ImageLayout, +} + +#[repr(C)] +pub struct SubpassDescription { + pub flags: SubpassDescriptionFlags, + pub pipelineBindPoint: PipelineBindPoint, + pub inputAttachmentCount: u32, + pub pInputAttachments: *const AttachmentReference, + pub colorAttachmentCount: u32, + pub pColorAttachments: *const AttachmentReference, + pub pResolveAttachments: *const AttachmentReference, + pub pDepthStencilAttachment: *const AttachmentReference, + pub preserveAttachmentCount: u32, + pub pPreserveAttachments: *const u32, +} + +#[repr(C)] +pub struct SubpassDependency { + pub srcSubpass: u32, + pub dstSubpass: u32, + pub srcStageMask: PipelineStageFlags, + pub dstStageMask: PipelineStageFlags, + pub srcAccessMask: AccessFlags, + pub dstAccessMask: AccessFlags, + pub dependencyFlags: DependencyFlags, +} + +#[repr(C)] +pub struct RenderPassCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: RenderPassCreateFlags, + pub attachmentCount: u32, + pub pAttachments: *const AttachmentDescription, + pub subpassCount: u32, + pub pSubpasses: *const SubpassDescription, + pub dependencyCount: u32, + pub pDependencies: *const SubpassDependency, +} + +#[repr(C)] +pub struct CommandPoolCreateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: CommandPoolCreateFlags, + pub queueFamilyIndex: u32, +} + +#[repr(C)] +pub struct CommandBufferAllocateInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub commandPool: CommandPool, + pub level: CommandBufferLevel, + pub commandBufferCount: u32, +} + +#[repr(C)] +pub struct CommandBufferInheritanceInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub renderPass: RenderPass, + pub subpass: u32, + pub framebuffer: Framebuffer, + pub occlusionQueryEnable: Bool32, + pub queryFlags: QueryControlFlags, + pub pipelineStatistics: QueryPipelineStatisticFlags, +} + +#[repr(C)] +pub struct CommandBufferBeginInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: CommandBufferUsageFlags, + pub pInheritanceInfo: *const CommandBufferInheritanceInfo, +} + +#[repr(C)] +pub struct BufferCopy { + pub srcOffset: DeviceSize, + pub dstOffset: DeviceSize, + pub size: DeviceSize, +} + +#[repr(C)] +pub struct ImageSubresourceLayers { + pub aspectMask: ImageAspectFlags, + pub mipLevel: u32, + pub baseArrayLayer: u32, + pub layerCount: u32, +} + +#[repr(C)] +pub struct ImageCopy { + pub srcSubresource: ImageSubresourceLayers, + pub srcOffset: Offset3D, + pub dstSubresource: ImageSubresourceLayers, + pub dstOffset: Offset3D, + pub extent: Extent3D, +} + +#[repr(C)] +pub struct ImageBlit { + pub srcSubresource: ImageSubresourceLayers, + pub srcOffsets: [Offset3D; 2], + pub dstSubresource: ImageSubresourceLayers, + pub dstOffsets: [Offset3D; 2], +} + +#[repr(C)] +pub struct BufferImageCopy { + pub bufferOffset: DeviceSize, + pub bufferRowLength: u32, + pub bufferImageHeight: u32, + pub imageSubresource: ImageSubresourceLayers, + pub imageOffset: Offset3D, + pub imageExtent: Extent3D, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub union ClearColorValue { + pub float32: [f32; 4], + pub int32: [i32; 4], + pub uint32: [u32; 4] +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct ClearDepthStencilValue { + pub depth: f32, + pub stencil: u32, +} + +#[repr(C)] +pub union ClearValue { + pub color: ClearColorValue, + pub depthStencil: ClearDepthStencilValue +} + +#[repr(C)] +pub struct ClearAttachment { + pub aspectMask: ImageAspectFlags, + pub colorAttachment: u32, + pub clearValue: ClearValue, +} + +#[repr(C)] +pub struct ClearRect { + pub rect: Rect2D, + pub baseArrayLayer: u32, + pub layerCount: u32, +} + +#[repr(C)] +pub struct ImageResolve { + pub srcSubresource: ImageSubresourceLayers, + pub srcOffset: Offset3D, + pub dstSubresource: ImageSubresourceLayers, + pub dstOffset: Offset3D, + pub extent: Extent3D, +} + +#[repr(C)] +pub struct MemoryBarrier { + pub sType: StructureType, + pub pNext: *const c_void, + pub srcAccessMask: AccessFlags, + pub dstAccessMask: AccessFlags, +} + +#[repr(C)] +pub struct BufferMemoryBarrier { + pub sType: StructureType, + pub pNext: *const c_void, + pub srcAccessMask: AccessFlags, + pub dstAccessMask: AccessFlags, + pub srcQueueFamilyIndex: u32, + pub dstQueueFamilyIndex: u32, + pub buffer: Buffer, + pub offset: DeviceSize, + pub size: DeviceSize, +} + +#[repr(C)] +pub struct ImageMemoryBarrier { + pub sType: StructureType, + pub pNext: *const c_void, + pub srcAccessMask: AccessFlags, + pub dstAccessMask: AccessFlags, + pub oldLayout: ImageLayout, + pub newLayout: ImageLayout, + pub srcQueueFamilyIndex: u32, + pub dstQueueFamilyIndex: u32, + pub image: Image, + pub subresourceRange: ImageSubresourceRange, +} + +#[repr(C)] +pub struct RenderPassBeginInfo { + pub sType: StructureType, + pub pNext: *const c_void, + pub renderPass: RenderPass, + pub framebuffer: Framebuffer, + pub renderArea: Rect2D, + pub clearValueCount: u32, + pub pClearValues: *const ClearValue, +} + +#[repr(C)] +pub struct DispatchIndirectCommand { + pub x: u32, + pub y: u32, + pub z: u32, +} + +#[repr(C)] +pub struct DrawIndexedIndirectCommand { + pub indexCount: u32, + pub instanceCount: u32, + pub firstIndex: u32, + pub vertexOffset: i32, + pub firstInstance: u32, +} + +#[repr(C)] +pub struct DrawIndirectCommand { + pub vertexCount: u32, + pub instanceCount: u32, + pub firstVertex: u32, + pub firstInstance: u32, +} + +#[repr(C)] +pub struct SurfaceCapabilitiesKHR { + pub minImageCount: u32, + pub maxImageCount: u32, + pub currentExtent: Extent2D, + pub minImageExtent: Extent2D, + pub maxImageExtent: Extent2D, + pub maxImageArrayLayers: u32, + pub supportedTransforms: SurfaceTransformFlagsKHR, + pub currentTransform: SurfaceTransformFlagBitsKHR, + pub supportedCompositeAlpha: CompositeAlphaFlagsKHR, + pub supportedUsageFlags: ImageUsageFlags, +} + +#[repr(C)] +pub struct SurfaceFormatKHR { + pub format: Format, + pub colorSpace: ColorSpaceKHR, +} + +pub type SwapchainCreateFlagsKHR = Flags; + +#[repr(C)] +pub struct SwapchainCreateInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: SwapchainCreateFlagsKHR, + pub surface: SurfaceKHR, + pub minImageCount: u32, + pub imageFormat: Format, + pub imageColorSpace: ColorSpaceKHR, + pub imageExtent: Extent2D, + pub imageArrayLayers: u32, + pub imageUsage: ImageUsageFlags, + pub imageSharingMode: SharingMode, + pub queueFamilyIndexCount: u32, + pub pQueueFamilyIndices: *const u32, + pub preTransform: SurfaceTransformFlagBitsKHR, + pub compositeAlpha: CompositeAlphaFlagBitsKHR, + pub presentMode: PresentModeKHR, + pub clipped: Bool32, + pub oldSwapchain: SwapchainKHR, +} + +#[repr(C)] +pub struct PresentInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub waitSemaphoreCount: u32, + pub pWaitSemaphores: *const Semaphore, + pub swapchainCount: u32, + pub pSwapchains: *const SwapchainKHR, + pub pImageIndices: *const u32, + pub pResults: *mut Result, +} + + +#[repr(C)] +pub struct DisplayPropertiesKHR { + pub display: DisplayKHR, + pub displayName: *const c_char, + pub physicalDimensions: Extent2D, + pub physicalResolution: Extent2D, + pub supportedTransforms: SurfaceTransformFlagsKHR, + pub planeReorderPossible: Bool32, + pub persistentContent: Bool32, +} + +#[repr(C)] +pub struct DisplayModeParametersKHR { + pub visibleRegion: Extent2D, + pub refreshRate: u32, +} + +#[repr(C)] +pub struct DisplayModePropertiesKHR { + pub displayMode: DisplayModeKHR, + pub parameters: DisplayModeParametersKHR, +} + +#[repr(C)] +pub struct DisplayModeCreateInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: DisplayModeCreateFlagsKHR, + pub parameters: DisplayModeParametersKHR, +} + +#[repr(C)] +pub struct DisplayPlaneCapabilitiesKHR { + pub supportedAlpha: DisplayPlaneAlphaFlagsKHR, + pub minSrcPosition: Offset2D, + pub maxSrcPosition: Offset2D, + pub minSrcExtent: Extent2D, + pub maxSrcExtent: Extent2D, + pub minDstPosition: Offset2D, + pub maxDstPosition: Offset2D, + pub minDstExtent: Extent2D, + pub maxDstExtent: Extent2D, +} + +#[repr(C)] +pub struct DisplayPlanePropertiesKHR { + pub currentDisplay: DisplayKHR, + pub currentStackIndex: u32, +} + +#[repr(C)] +pub struct DisplaySurfaceCreateInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: DisplaySurfaceCreateFlagsKHR, + pub displayMode: DisplayModeKHR, + pub planeIndex: u32, + pub planeStackIndex: u32, + pub transform: SurfaceTransformFlagBitsKHR, + pub globalAlpha: f32, + pub alphaMode: DisplayPlaneAlphaFlagBitsKHR, + pub imageExtent: Extent2D, +} + +#[repr(C)] +pub struct DisplayPresentInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub srcRect: Rect2D, + pub dstRect: Rect2D, + pub persistent: Bool32, +} + + +pub type XlibSurfaceCreateFlagsKHR = Flags; + +#[repr(C)] +pub struct XlibSurfaceCreateInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: XlibSurfaceCreateFlagsKHR, + pub dpy: *mut c_void, + pub window: c_ulong, +} + +pub type XcbSurfaceCreateFlagsKHR = Flags; + +#[repr(C)] +pub struct XcbSurfaceCreateInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: XcbSurfaceCreateFlagsKHR, + pub connection: *const c_void, + pub window: u32, +} + + +pub type WaylandSurfaceCreateFlagsKHR = Flags; + +#[repr(C)] +pub struct WaylandSurfaceCreateInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: WaylandSurfaceCreateFlagsKHR, + pub display: *mut c_void, + pub surface: *mut c_void, +} + +pub type AndroidSurfaceCreateFlagsKHR = Flags; + +#[repr(C)] +pub struct AndroidSurfaceCreateInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: AndroidSurfaceCreateFlagsKHR, + pub window: *mut c_void, +} + + +pub type Win32SurfaceCreateFlagsKHR = Flags; + +#[repr(C)] +pub struct Win32SurfaceCreateInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: Win32SurfaceCreateFlagsKHR, + pub hinstance: *mut c_void, + pub hwnd: *mut c_void, +} + + +#[repr(C)] +pub struct DebugReportCallbackCreateInfoEXT { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: DebugReportFlagsEXT, + pub pfnCallback: PFN_vkDebugReportCallbackEXT, + pub pUserData: *mut c_void, +} + +#[repr(C)] +pub struct IOSSurfaceCreateInfoMVK { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: IOSSurfaceCreateFlagsMVK, + pub pView: *const c_void, +} + +#[repr(C)] +pub struct MacOSSurfaceCreateInfoMVK { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: MacOSSurfaceCreateFlagsMVK, + pub pView: *const c_void, +} + +#[repr(C)] +pub struct MVKDeviceConfiguration { + pub supportDisplayContentsScale: Bool32, + pub imageFlipY: Bool32, + pub shaderConversionFlipFragmentY: Bool32, + pub shaderConversionFlipVertexY: Bool32, + pub shaderConversionLogging: Bool32, + pub performanceTracking: Bool32, + pub performanceLoggingFrameCount: u32, +} + +#[repr(C)] +pub struct MVKPhysicalDeviceMetalFeatures { + pub depthClipMode: Bool32, + pub indirectDrawing: Bool32, + pub baseVertexInstanceDrawing: Bool32, + pub maxVertexBufferCount: u32, + pub maxFragmentBufferCount: u32, + pub bufferAlignment: DeviceSize, + pub pushConstantsAlignment: DeviceSize, +} + +#[repr(C)] +pub struct MVKSwapchainPerformance { + pub lastFrameInterval: c_double, + pub averageFrameInterval: c_double, + pub averageFramesPerSecond: c_double, +} + +#[repr(C)] +pub struct PhysicalDeviceFeatures2KHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub features: PhysicalDeviceFeatures, +} + +#[repr(C)] +pub struct PhysicalDeviceProperties2KHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub properties: PhysicalDeviceProperties, +} + +#[repr(C)] +pub struct FormatProperties2KHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub formatProperties: FormatProperties, +} + +#[repr(C)] +pub struct ImageFormatProperties2KHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub imageFormatProperties: ImageFormatProperties, +} + +#[repr(C)] +pub struct PhysicalDeviceImageFormatInfo2KHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub format: Format, + pub imageType: ImageType, + pub tiling: ImageTiling, + pub usage: ImageUsageFlags, + pub flags: ImageCreateFlags, +} + +#[repr(C)] +pub struct QueueFamilyProperties2KHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub queueFamilyProperties: QueueFamilyProperties, +} + +#[repr(C)] +pub struct PhysicalDeviceMemoryProperties2KHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub memoryProperties: PhysicalDeviceMemoryProperties, +} + +#[repr(C)] +pub struct SparseImageFormatProperties2KHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub properties: SparseImageFormatProperties, +} + +#[repr(C)] +pub struct PhysicalDeviceSparseImageFormatInfo2KHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub format: Format, + pub imageType: ImageType, + pub samples: SampleCountFlagBits, + pub usage: ImageUsageFlags, + pub tiling: ImageTiling, +} + +pub type ViSurfaceCreateFlagsNN = Flags; + +#[repr(C)] +pub struct ViSurfaceCreateInfoNN { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: ViSurfaceCreateFlagsNN, + pub window: *const c_void, +} + +#[repr(C)] +pub struct PhysicalDevicePushDescriptorPropertiesKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub maxPushDescriptors: u32, +} + +#[repr(C)] +pub struct DescriptorUpdateTemplateEntryKHR { + pub dstBinding: u32, + pub dstArrayElement: u32, + pub descriptorCount: u32, + pub descriptorType: DescriptorType, + pub offset: usize, + pub stride: usize, +} + +#[repr(C)] +pub struct DescriptorUpdateTemplateCreateInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub flags: DescriptorUpdateTemplateCreateFlagsKHR, + pub descriptorUpdateEntryCount: u32, + pub pDescriptorUpdateEntries: *const DescriptorUpdateTemplateEntryKHR, + pub templateType: DescriptorUpdateTemplateTypeKHR, + pub descriptorSetLayout: DescriptorSetLayout, + pub pipelineBindPoint: PipelineBindPoint, + pub pipelineLayout: PipelineLayout, + pub set: u32, +} + +#[repr(C)] +pub struct MemoryDedicatedRequirementsKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub prefersDedicatedAllocation: Bool32, + pub requiresDedicatedAllocation: Bool32, +} + +#[repr(C)] +pub struct MemoryDedicatedAllocateInfoKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub image: Image, + pub buffer: Buffer, +} + +#[repr(C)] +pub struct BufferMemoryRequirementsInfo2KHR { + pub sType: StructureType, + pub pNext: *mut c_void, + pub buffer: Buffer, +} + +#[repr(C)] +pub struct ImageMemoryRequirementsInfo2KHR { + pub sType: StructureType, + pub pNext: *mut c_void, + pub image: Image, +} + +#[repr(C)] +pub struct MemoryRequirements2KHR { + pub sType: StructureType, + pub pNext: *mut c_void, + pub memoryRequirements: MemoryRequirements, +} + +#[repr(C)] +pub struct RectLayerKHR { + pub offset: Offset2D, + pub extent: Extent2D, + pub layer: u32, +} + +#[repr(C)] +pub struct PresentRegionKHR { + pub rectangleCount: u32, + pub pRectangles: *const RectLayerKHR, +} + +#[repr(C)] +pub struct PresentRegionsKHR { + pub sType: StructureType, + pub pNext: *const c_void, + pub swapchainCount: u32, + pub pRegions: *const PresentRegionKHR, +} + +#[repr(C)] +pub struct DebugMarkerObjectNameInfoEXT { + pub sType: StructureType, + pub pNext: *const c_void, + pub objectType: DebugReportObjectTypeEXT, + pub object: u64, + pub name: *const c_char, +} + +#[repr(C)] +pub struct DebugMarkerObjectTagInfoEXT { + pub sType: StructureType, + pub pNext: *const c_void, + pub objectType: DebugReportObjectTypeEXT, + pub object: u64, + pub tagName: u64, + pub tagSize: usize, + pub tag: *const c_void, +} + +#[repr(C)] +pub struct DebugMarkerMarkerInfoEXT { + pub sType: StructureType, + pub pNext: *const c_void, + pub pMarkerName: *const c_char, + pub color: [f32; 4], +} + +macro_rules! ptrs { + ($struct_name:ident, { $($name:ident => ($($param_n:ident: $param_ty:ty),*) -> $ret:ty,)+ }) => ( + pub struct $struct_name { + $( + pub $name: extern "system" fn($($param_ty),*) -> $ret, + )+ + } + + impl fmt::Debug for $struct_name { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> { + write!(fmt, "<Vulkan functions>") // TODO: + } + } + + unsafe impl Send for $struct_name {} + unsafe impl Sync for $struct_name {} + + impl $struct_name { + pub fn load<F>(mut f: F) -> $struct_name + where F: FnMut(&CStr) -> *const c_void + { + $struct_name { + $( + $name: unsafe { + extern "system" fn $name($(_: $param_ty),*) { panic!("function pointer `{}` not loaded", stringify!($name)) } + let name = CStr::from_bytes_with_nul_unchecked(concat!("vk", stringify!($name), "\0").as_bytes()); + let val = f(name); + if val.is_null() { mem::transmute($name as *const ()) } else { mem::transmute(val) } + }, + )+ + } + } + + $( + #[inline] + pub unsafe fn $name(&self $(, $param_n: $param_ty)*) -> $ret { + let ptr = self.$name; + ptr($($param_n),*) + } + )+ + } + ) +} + +ptrs!(Static, { + GetInstanceProcAddr => (instance: Instance, pName: *const c_char) -> PFN_vkVoidFunction, +}); + +ptrs!(EntryPoints, { + CreateInstance => (pCreateInfo: *const InstanceCreateInfo, pAllocator: *const AllocationCallbacks, pInstance: *mut Instance) -> Result, + EnumerateInstanceExtensionProperties => (pLayerName: *const c_char, pPropertyCount: *mut u32, pProperties: *mut ExtensionProperties) -> Result, + EnumerateInstanceLayerProperties => (pPropertyCount: *mut u32, pProperties: *mut LayerProperties) -> Result, +}); + +ptrs!(InstancePointers, { + DestroyInstance => (instance: Instance, pAllocator: *const AllocationCallbacks) -> (), + GetDeviceProcAddr => (device: Device, pName: *const c_char) -> PFN_vkVoidFunction, + EnumeratePhysicalDevices => (instance: Instance, pPhysicalDeviceCount: *mut u32, pPhysicalDevices: *mut PhysicalDevice) -> Result, + EnumerateDeviceExtensionProperties => (physicalDevice: PhysicalDevice, pLayerName: *const c_char, pPropertyCount: *mut u32, pProperties: *mut ExtensionProperties) -> Result, + EnumerateDeviceLayerProperties => (physicalDevice: PhysicalDevice, pPropertyCount: *mut u32, pProperties: *mut LayerProperties) -> Result, + CreateDevice => (physicalDevice: PhysicalDevice, pCreateInfo: *const DeviceCreateInfo, pAllocator: *const AllocationCallbacks, pDevice: *mut Device) -> Result, + GetPhysicalDeviceFeatures => (physicalDevice: PhysicalDevice, pFeatures: *mut PhysicalDeviceFeatures) -> (), + GetPhysicalDeviceFormatProperties => (physicalDevice: PhysicalDevice, format: Format, pFormatProperties: *mut FormatProperties) -> (), + GetPhysicalDeviceImageFormatProperties => (physicalDevice: PhysicalDevice, format: Format, ty: ImageType, tiling: ImageTiling, usage: ImageUsageFlags, flags: ImageCreateFlags, pImageFormatProperties: *mut ImageFormatProperties) -> Result, + GetPhysicalDeviceProperties => (physicalDevice: PhysicalDevice, pProperties: *mut PhysicalDeviceProperties) -> (), + GetPhysicalDeviceQueueFamilyProperties => (physicalDevice: PhysicalDevice, pQueueFamilyPropertyCount: *mut u32, pQueueFamilyProperties: *mut QueueFamilyProperties) -> (), + GetPhysicalDeviceMemoryProperties => (physicalDevice: PhysicalDevice, pMemoryProperties: *mut PhysicalDeviceMemoryProperties) -> (), + GetPhysicalDeviceSparseImageFormatProperties => (physicalDevice: PhysicalDevice, format: Format, ty: ImageType, samples: SampleCountFlagBits, usage: ImageUsageFlags, tiling: ImageTiling, pPropertyCount: *mut u32, pProperties: *mut SparseImageFormatProperties) -> (), + DestroySurfaceKHR => (instance: Instance, surface: SurfaceKHR, pAllocator: *const AllocationCallbacks) -> (), + CreateXlibSurfaceKHR => (instance: Instance, pCreateInfo: *const XlibSurfaceCreateInfoKHR, pAllocator: *const AllocationCallbacks, pSurface: *mut SurfaceKHR) -> Result, + GetPhysicalDeviceXlibPresentationSupportKHR => (physicalDevice: PhysicalDevice, queueFamilyIndex: u32, dpy: *mut c_void, visualID: u32/* FIXME: VisualID */) -> Bool32, + CreateXcbSurfaceKHR => (instance: Instance, pCreateInfo: *const XcbSurfaceCreateInfoKHR, pAllocator: *const AllocationCallbacks, pSurface: *mut SurfaceKHR) -> Result, + GetPhysicalDeviceXcbPresentationSupportKHR => (physicalDevice: PhysicalDevice, queueFamilyIndex: u32, connection: *mut c_void, visual_id: u32 /* FIXME: xcb_visualid */) -> Bool32, + CreateWaylandSurfaceKHR => (instance: Instance, pCreateInfo: *const WaylandSurfaceCreateInfoKHR, pAllocator: *const AllocationCallbacks, pSurface: *mut SurfaceKHR) -> Result, + GetPhysicalDeviceWaylandPresentationSupportKHR => (physicalDevice: PhysicalDevice, queueFamilyIndex: u32, display: *mut c_void) -> Bool32, + CreateAndroidSurfaceKHR => (instance: Instance, pCreateInfo: *const AndroidSurfaceCreateInfoKHR, pAllocator: *const AllocationCallbacks, pSurface: *mut SurfaceKHR) -> Result, + CreateWin32SurfaceKHR => (instance: Instance, pCreateInfo: *const Win32SurfaceCreateInfoKHR, pAllocator: *const AllocationCallbacks, pSurface: *mut SurfaceKHR) -> Result, + GetPhysicalDeviceWin32PresentationSupportKHR => (physicalDevice: PhysicalDevice, queueFamilyIndex: u32) -> Bool32, + GetPhysicalDeviceDisplayPropertiesKHR => (physicalDevice: PhysicalDevice, pPropertyCount: *mut u32, pProperties: *mut DisplayPropertiesKHR) -> Result, + GetPhysicalDeviceDisplayPlanePropertiesKHR => (physicalDevice: PhysicalDevice, pPropertyCount: *mut u32, pProperties: *mut DisplayPlanePropertiesKHR) -> Result, + GetDisplayPlaneSupportedDisplaysKHR => (physicalDevice: PhysicalDevice, planeIndex: u32, pDisplayCount: *mut u32, pDisplays: *mut DisplayKHR) -> Result, + GetDisplayModePropertiesKHR => (physicalDevice: PhysicalDevice, display: DisplayKHR, pPropertyCount: *mut u32, pProperties: *mut DisplayModePropertiesKHR) -> Result, + CreateDisplayModeKHR => (physicalDevice: PhysicalDevice, display: DisplayKHR, pCreateInfo: *const DisplayModeCreateInfoKHR, pAllocator: *const AllocationCallbacks, pMode: *mut DisplayModeKHR) -> Result, + GetDisplayPlaneCapabilitiesKHR => (physicalDevice: PhysicalDevice, mode: DisplayModeKHR, planeIndex: u32, pCapabilities: *mut DisplayPlaneCapabilitiesKHR) -> Result, + CreateDisplayPlaneSurfaceKHR => (instance: Instance, pCreateInfo: *const DisplaySurfaceCreateInfoKHR, pAllocator: *const AllocationCallbacks, pSurface: *mut SurfaceKHR) -> Result, + GetPhysicalDeviceSurfaceSupportKHR => (physicalDevice: PhysicalDevice, queueFamilyIndex: u32, surface: SurfaceKHR, pSupported: *mut Bool32) -> Result, + GetPhysicalDeviceSurfaceCapabilitiesKHR => (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pSurfaceCapabilities: *mut SurfaceCapabilitiesKHR) -> Result, + GetPhysicalDeviceSurfaceFormatsKHR => (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pSurfaceFormatCount: *mut u32, pSurfaceFormats: *mut SurfaceFormatKHR) -> Result, + GetPhysicalDeviceSurfacePresentModesKHR => (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pPresentModeCount: *mut u32, pPresentModes: *mut PresentModeKHR) -> Result, + CreateDebugReportCallbackEXT => (instance: Instance, pCreateInfo: *const DebugReportCallbackCreateInfoEXT, pAllocator: *const AllocationCallbacks, pCallback: *mut DebugReportCallbackEXT) -> Result, + DestroyDebugReportCallbackEXT => (instance: Instance, callback: DebugReportCallbackEXT, pAllocator: *const AllocationCallbacks) -> (), + DebugReportMessageEXT => (instance: Instance, flags: DebugReportFlagsEXT, objectType: DebugReportObjectTypeEXT, object: u64, location: usize, messageCode: i32, pLayerPrefix: *const c_char, pMessage: *const c_char) -> (), + CreateIOSSurfaceMVK => (instance: Instance, pCreateInfo: *const IOSSurfaceCreateInfoMVK, pAllocator: *const AllocationCallbacks, pSurface: *mut SurfaceKHR) -> Result, + CreateMacOSSurfaceMVK => (instance: Instance, pCreateInfo: *const MacOSSurfaceCreateInfoMVK, pAllocator: *const AllocationCallbacks, pSurface: *mut SurfaceKHR) -> Result, + ActivateMoltenVKLicenseMVK => (licenseID: *const c_char, licenseKey: *const c_char, acceptLicenseTermsAndConditions: Bool32) -> Result, + ActivateMoltenVKLicensesMVK => () -> Result, + GetMoltenVKDeviceConfigurationMVK => (device: Device, pConfiguration: *mut MVKDeviceConfiguration) -> Result, + SetMoltenVKDeviceConfigurationMVK => (device: Device, pConfiguration: *mut MVKDeviceConfiguration) -> Result, + GetPhysicalDeviceMetalFeaturesMVK => (physicalDevice: PhysicalDevice, pMetalFeatures: *mut MVKPhysicalDeviceMetalFeatures) -> Result, + GetSwapchainPerformanceMVK => (device: Device, swapchain: SwapchainKHR, pSwapchainPerf: *mut MVKSwapchainPerformance) -> Result, + CreateViSurfaceNN => (instance: Instance, pCreateInfo: *const ViSurfaceCreateInfoNN, pAllocator: *const AllocationCallbacks, pSurface: *mut SurfaceKHR) -> Result, + GetPhysicalDeviceFeatures2KHR => (physicalDevice: PhysicalDevice, pFeatures: *mut PhysicalDeviceFeatures2KHR) -> (), + GetPhysicalDeviceProperties2KHR => (physicalDevice: PhysicalDevice, pProperties: *mut PhysicalDeviceProperties2KHR) -> (), + GetPhysicalDeviceFormatProperties2KHR => (physicalDevice: PhysicalDevice, pFormatProperties: *mut FormatProperties2KHR) -> (), + GetPhysicalDeviceImageFormatProperties2KHR => (physicalDevice: PhysicalDevice, pImageFormatInfo: *const PhysicalDeviceImageFormatInfo2KHR, pImageFormatProperties: *mut ImageFormatProperties2KHR) -> Result, + GetPhysicalDeviceQueueFamilyProperties2KHR => (physicalDevice: PhysicalDevice, pQueueFamilyPropertiesCount: *mut u32, pQueueFamilyProperties: *mut QueueFamilyProperties2KHR) -> (), + GetPhysicalDeviceMemoryProperties2KHR => (physicalDevice: PhysicalDevice, pMemoryProperties: *mut PhysicalDeviceMemoryProperties2KHR) -> (), + GetPhysicalDeviceSparseImageFormatProperties2KHR => (physicalDevice: PhysicalDevice, pFormatInfo: *const PhysicalDeviceSparseImageFormatInfo2KHR, pPropertyCount: *mut u32, pProperties: *mut SparseImageFormatProperties2KHR) -> (), +}); + +ptrs!(DevicePointers, { + DestroyDevice => (device: Device, pAllocator: *const AllocationCallbacks) -> (), + GetDeviceQueue => (device: Device, queueFamilyIndex: u32, queueIndex: u32, pQueue: *mut Queue) -> (), + QueueSubmit => (queue: Queue, submitCount: u32, pSubmits: *const SubmitInfo, fence: Fence) -> Result, + QueueWaitIdle => (queue: Queue) -> Result, + DeviceWaitIdle => (device: Device) -> Result, + AllocateMemory => (device: Device, pAllocateInfo: *const MemoryAllocateInfo, pAllocator: *const AllocationCallbacks, pMemory: *mut DeviceMemory) -> Result, + FreeMemory => (device: Device, memory: DeviceMemory, pAllocator: *const AllocationCallbacks) -> (), + MapMemory => (device: Device, memory: DeviceMemory, offset: DeviceSize, size: DeviceSize, flags: MemoryMapFlags, ppData: *mut *mut c_void) -> Result, + UnmapMemory => (device: Device, memory: DeviceMemory) -> (), + FlushMappedMemoryRanges => (device: Device, memoryRangeCount: u32, pMemoryRanges: *const MappedMemoryRange) -> Result, + InvalidateMappedMemoryRanges => (device: Device, memoryRangeCount: u32, pMemoryRanges: *const MappedMemoryRange) -> Result, + GetDeviceMemoryCommitment => (device: Device, memory: DeviceMemory, pCommittedMemoryInBytes: *mut DeviceSize) -> (), + BindBufferMemory => (device: Device, buffer: Buffer, memory: DeviceMemory, memoryOffset: DeviceSize) -> Result, + BindImageMemory => (device: Device, image: Image, memory: DeviceMemory, memoryOffset: DeviceSize) -> Result, + GetBufferMemoryRequirements => (device: Device, buffer: Buffer, pMemoryRequirements: *mut MemoryRequirements) -> (), + GetImageMemoryRequirements => (device: Device, image: Image, pMemoryRequirements: *mut MemoryRequirements) -> (), + GetImageSparseMemoryRequirements => (device: Device, image: Image, pSparseMemoryRequirementCount: *mut u32, pSparseMemoryRequirements: *mut SparseImageMemoryRequirements) -> (), + QueueBindSparse => (queue: Queue, bindInfoCount: u32, pBindInfo: *const BindSparseInfo, fence: Fence) -> Result, + CreateFence => (device: Device, pCreateInfo: *const FenceCreateInfo, pAllocator: *const AllocationCallbacks, pFence: *mut Fence) -> Result, + DestroyFence => (device: Device, fence: Fence, pAllocator: *const AllocationCallbacks) -> (), + ResetFences => (device: Device, fenceCount: u32, pFences: *const Fence) -> Result, + GetFenceStatus => (device: Device, fence: Fence) -> Result, + WaitForFences => (device: Device, fenceCount: u32, pFences: *const Fence, waitAll: Bool32, timeout: u64) -> Result, + CreateSemaphore => (device: Device, pCreateInfo: *const SemaphoreCreateInfo, pAllocator: *const AllocationCallbacks, pSemaphore: *mut Semaphore) -> Result, + DestroySemaphore => (device: Device, semaphore: Semaphore, pAllocator: *const AllocationCallbacks) -> (), + CreateEvent => (device: Device, pCreateInfo: *const EventCreateInfo, pAllocator: *const AllocationCallbacks, pEvent: *mut Event) -> Result, + DestroyEvent => (device: Device, event: Event, pAllocator: *const AllocationCallbacks) -> (), + GetEventStatus => (device: Device, event: Event) -> Result, + SetEvent => (device: Device, event: Event) -> Result, + ResetEvent => (device: Device, event: Event) -> Result, + CreateQueryPool => (device: Device, pCreateInfo: *const QueryPoolCreateInfo, pAllocator: *const AllocationCallbacks, pQueryPool: *mut QueryPool) -> Result, + DestroyQueryPool => (device: Device, queryPool: QueryPool, pAllocator: *const AllocationCallbacks) -> (), + GetQueryPoolResults => (device: Device, queryPool: QueryPool, firstQuery: u32, queryCount: u32, dataSize: usize, pData: *mut c_void, stride: DeviceSize, flags: QueryResultFlags) -> Result, + CreateBuffer => (device: Device, pCreateInfo: *const BufferCreateInfo, pAllocator: *const AllocationCallbacks, pBuffer: *mut Buffer) -> Result, + DestroyBuffer => (device: Device, buffer: Buffer, pAllocator: *const AllocationCallbacks) -> (), + CreateBufferView => (device: Device, pCreateInfo: *const BufferViewCreateInfo, pAllocator: *const AllocationCallbacks, pView: *mut BufferView) -> Result, + DestroyBufferView => (device: Device, bufferView: BufferView, pAllocator: *const AllocationCallbacks) -> (), + CreateImage => (device: Device, pCreateInfo: *const ImageCreateInfo, pAllocator: *const AllocationCallbacks, pImage: *mut Image) -> Result, + DestroyImage => (device: Device, image: Image, pAllocator: *const AllocationCallbacks) -> (), + GetImageSubresourceLayout => (device: Device, image: Image, pSubresource: *const ImageSubresource, pLayout: *mut SubresourceLayout) -> (), + CreateImageView => (device: Device, pCreateInfo: *const ImageViewCreateInfo, pAllocator: *const AllocationCallbacks, pView: *mut ImageView) -> Result, + DestroyImageView => (device: Device, imageView: ImageView, pAllocator: *const AllocationCallbacks) -> (), + CreateShaderModule => (device: Device, pCreateInfo: *const ShaderModuleCreateInfo, pAllocator: *const AllocationCallbacks, pShaderModule: *mut ShaderModule) -> Result, + DestroyShaderModule => (device: Device, shaderModule: ShaderModule, pAllocator: *const AllocationCallbacks) -> (), + CreatePipelineCache => (device: Device, pCreateInfo: *const PipelineCacheCreateInfo, pAllocator: *const AllocationCallbacks, pPipelineCache: *mut PipelineCache) -> Result, + DestroyPipelineCache => (device: Device, pipelineCache: PipelineCache, pAllocator: *const AllocationCallbacks) -> (), + GetPipelineCacheData => (device: Device, pipelineCache: PipelineCache, pDataSize: *mut usize, pData: *mut c_void) -> Result, + MergePipelineCaches => (device: Device, dstCache: PipelineCache, srcCacheCount: u32, pSrcCaches: *const PipelineCache) -> Result, + CreateGraphicsPipelines => (device: Device, pipelineCache: PipelineCache, createInfoCount: u32, pCreateInfos: *const GraphicsPipelineCreateInfo, pAllocator: *const AllocationCallbacks, pPipelines: *mut Pipeline) -> Result, + CreateComputePipelines => (device: Device, pipelineCache: PipelineCache, createInfoCount: u32, pCreateInfos: *const ComputePipelineCreateInfo, pAllocator: *const AllocationCallbacks, pPipelines: *mut Pipeline) -> Result, + DestroyPipeline => (device: Device, pipeline: Pipeline, pAllocator: *const AllocationCallbacks) -> (), + CreatePipelineLayout => (device: Device, pCreateInfo: *const PipelineLayoutCreateInfo, pAllocator: *const AllocationCallbacks, pPipelineLayout: *mut PipelineLayout) -> Result, + DestroyPipelineLayout => (device: Device, pipelineLayout: PipelineLayout, pAllocator: *const AllocationCallbacks) -> (), + CreateSampler => (device: Device, pCreateInfo: *const SamplerCreateInfo, pAllocator: *const AllocationCallbacks, pSampler: *mut Sampler) -> Result, + DestroySampler => (device: Device, sampler: Sampler, pAllocator: *const AllocationCallbacks) -> (), + CreateDescriptorSetLayout => (device: Device, pCreateInfo: *const DescriptorSetLayoutCreateInfo, pAllocator: *const AllocationCallbacks, pSetLayout: *mut DescriptorSetLayout) -> Result, + DestroyDescriptorSetLayout => (device: Device, descriptorSetLayout: DescriptorSetLayout, pAllocator: *const AllocationCallbacks) -> (), + CreateDescriptorPool => (device: Device, pCreateInfo: *const DescriptorPoolCreateInfo, pAllocator: *const AllocationCallbacks, pDescriptorPool: *mut DescriptorPool) -> Result, + DestroyDescriptorPool => (device: Device, descriptorPool: DescriptorPool, pAllocator: *const AllocationCallbacks) -> (), + ResetDescriptorPool => (device: Device, descriptorPool: DescriptorPool, flags: DescriptorPoolResetFlags) -> Result, + AllocateDescriptorSets => (device: Device, pAllocateInfo: *const DescriptorSetAllocateInfo, pDescriptorSets: *mut DescriptorSet) -> Result, + FreeDescriptorSets => (device: Device, descriptorPool: DescriptorPool, descriptorSetCount: u32, pDescriptorSets: *const DescriptorSet) -> Result, + UpdateDescriptorSets => (device: Device, descriptorWriteCount: u32, pDescriptorWrites: *const WriteDescriptorSet, descriptorCopyCount: u32, pDescriptorCopies: *const CopyDescriptorSet) -> (), + CreateFramebuffer => (device: Device, pCreateInfo: *const FramebufferCreateInfo, pAllocator: *const AllocationCallbacks, pFramebuffer: *mut Framebuffer) -> Result, + DestroyFramebuffer => (device: Device, framebuffer: Framebuffer, pAllocator: *const AllocationCallbacks) -> (), + CreateRenderPass => (device: Device, pCreateInfo: *const RenderPassCreateInfo, pAllocator: *const AllocationCallbacks, pRenderPass: *mut RenderPass) -> Result, + DestroyRenderPass => (device: Device, renderPass: RenderPass, pAllocator: *const AllocationCallbacks) -> (), + GetRenderAreaGranularity => (device: Device, renderPass: RenderPass, pGranularity: *mut Extent2D) -> (), + CreateCommandPool => (device: Device, pCreateInfo: *const CommandPoolCreateInfo, pAllocator: *const AllocationCallbacks, pCommandPool: *mut CommandPool) -> Result, + DestroyCommandPool => (device: Device, commandPool: CommandPool, pAllocator: *const AllocationCallbacks) -> (), + ResetCommandPool => (device: Device, commandPool: CommandPool, flags: CommandPoolResetFlags) -> Result, + TrimCommandPoolKHR => (device: Device, commandPool: CommandPool, flags: CommandPoolTrimFlagsKHR) -> (), + AllocateCommandBuffers => (device: Device, pAllocateInfo: *const CommandBufferAllocateInfo, pCommandBuffers: *mut CommandBuffer) -> Result, + FreeCommandBuffers => (device: Device, commandPool: CommandPool, commandBufferCount: u32, pCommandBuffers: *const CommandBuffer) -> (), + BeginCommandBuffer => (commandBuffer: CommandBuffer, pBeginInfo: *const CommandBufferBeginInfo) -> Result, + EndCommandBuffer => (commandBuffer: CommandBuffer) -> Result, + ResetCommandBuffer => (commandBuffer: CommandBuffer, flags: CommandBufferResetFlags) -> Result, + CmdBindPipeline => (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, pipeline: Pipeline) -> (), + CmdSetViewport => (commandBuffer: CommandBuffer, firstViewport: u32, viewportCount: u32, pViewports: *const Viewport) -> (), + CmdSetScissor => (commandBuffer: CommandBuffer, firstScissor: u32, scissorCount: u32, pScissors: *const Rect2D) -> (), + CmdSetLineWidth => (commandBuffer: CommandBuffer, lineWidth: f32) -> (), + CmdSetDepthBias => (commandBuffer: CommandBuffer, depthBiasConstantFactor: f32, depthBiasClamp: f32, depthBiasSlopeFactor: f32) -> (), + CmdSetBlendConstants => (commandBuffer: CommandBuffer, blendConstants: [f32; 4]) -> (), + CmdSetDepthBounds => (commandBuffer: CommandBuffer, minDepthBounds: f32, maxDepthBounds: f32) -> (), + CmdSetStencilCompareMask => (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, compareMask: u32) -> (), + CmdSetStencilWriteMask => (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, writeMask: u32) -> (), + CmdSetStencilReference => (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, reference: u32) -> (), + CmdBindDescriptorSets => (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, layout: PipelineLayout, firstSet: u32, descriptorSetCount: u32, pDescriptorSets: *const DescriptorSet, dynamicOffsetCount: u32, pDynamicOffsets: *const u32) -> (), + CmdBindIndexBuffer => (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, indexType: IndexType) -> (), + CmdBindVertexBuffers => (commandBuffer: CommandBuffer, firstBinding: u32, bindingCount: u32, pBuffers: *const Buffer, pOffsets: *const DeviceSize) -> (), + CmdDraw => (commandBuffer: CommandBuffer, vertexCount: u32, instanceCount: u32, firstVertex: u32, firstInstance: u32) -> (), + CmdDrawIndexed => (commandBuffer: CommandBuffer, indexCount: u32, instanceCount: u32, firstIndex: u32, vertexOffset: i32, firstInstance: u32) -> (), + CmdDrawIndirect => (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, drawCount: u32, stride: u32) -> (), + CmdDrawIndexedIndirect => (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, drawCount: u32, stride: u32) -> (), + CmdDispatch => (commandBuffer: CommandBuffer, x: u32, y: u32, z: u32) -> (), + CmdDispatchIndirect => (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize) -> (), + CmdCopyBuffer => (commandBuffer: CommandBuffer, srcBuffer: Buffer, dstBuffer: Buffer, regionCount: u32, pRegions: *const BufferCopy) -> (), + CmdCopyImage => (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: *const ImageCopy) -> (), + CmdBlitImage => (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: *const ImageBlit, filter: Filter) -> (), + CmdCopyBufferToImage => (commandBuffer: CommandBuffer, srcBuffer: Buffer, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: *const BufferImageCopy) -> (), + CmdCopyImageToBuffer => (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstBuffer: Buffer, regionCount: u32, pRegions: *const BufferImageCopy) -> (), + CmdUpdateBuffer => (commandBuffer: CommandBuffer, dstBuffer: Buffer, dstOffset: DeviceSize, dataSize: DeviceSize, pData: *const u32) -> (), + CmdFillBuffer => (commandBuffer: CommandBuffer, dstBuffer: Buffer, dstOffset: DeviceSize, size: DeviceSize, data: u32) -> (), + CmdClearColorImage => (commandBuffer: CommandBuffer, image: Image, imageLayout: ImageLayout, pColor: *const ClearColorValue, rangeCount: u32, pRanges: *const ImageSubresourceRange) -> (), + CmdClearDepthStencilImage => (commandBuffer: CommandBuffer, image: Image, imageLayout: ImageLayout, pDepthStencil: *const ClearDepthStencilValue, rangeCount: u32, pRanges: *const ImageSubresourceRange) -> (), + CmdClearAttachments => (commandBuffer: CommandBuffer, attachmentCount: u32, pAttachments: *const ClearAttachment, rectCount: u32, pRects: *const ClearRect) -> (), + CmdResolveImage => (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: *const ImageResolve) -> (), + CmdSetEvent => (commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags) -> (), + CmdResetEvent => (commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags) -> (), + CmdWaitEvents => (commandBuffer: CommandBuffer, eventCount: u32, pEvents: *const Event, srcStageMask: PipelineStageFlags, dstStageMask: PipelineStageFlags, memoryBarrierCount: u32, pMemoryBarriers: *const MemoryBarrier, bufferMemoryBarrierCount: u32, pBufferMemoryBarriers: *const BufferMemoryBarrier, imageMemoryBarrierCount: u32, pImageMemoryBarriers: *const ImageMemoryBarrier) -> (), + CmdPipelineBarrier => (commandBuffer: CommandBuffer, srcStageMask: PipelineStageFlags, dstStageMask: PipelineStageFlags, dependencyFlags: DependencyFlags, memoryBarrierCount: u32, pMemoryBarriers: *const MemoryBarrier, bufferMemoryBarrierCount: u32, pBufferMemoryBarriers: *const BufferMemoryBarrier, imageMemoryBarrierCount: u32, pImageMemoryBarriers: *const ImageMemoryBarrier) -> (), + CmdBeginQuery => (commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32, flags: QueryControlFlags) -> (), + CmdEndQuery => (commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32) -> (), + CmdResetQueryPool => (commandBuffer: CommandBuffer, queryPool: QueryPool, firstQuery: u32, queryCount: u32) -> (), + CmdWriteTimestamp => (commandBuffer: CommandBuffer, pipelineStage: PipelineStageFlagBits, queryPool: QueryPool, query: u32) -> (), + CmdCopyQueryPoolResults => (commandBuffer: CommandBuffer, queryPool: QueryPool, firstQuery: u32, queryCount: u32, dstBuffer: Buffer, dstOffset: DeviceSize, stride: DeviceSize, flags: QueryResultFlags) -> (), + CmdPushConstants => (commandBuffer: CommandBuffer, layout: PipelineLayout, stageFlags: ShaderStageFlags, offset: u32, size: u32, pValues: *const c_void) -> (), + CmdBeginRenderPass => (commandBuffer: CommandBuffer, pRenderPassBegin: *const RenderPassBeginInfo, contents: SubpassContents) -> (), + CmdNextSubpass => (commandBuffer: CommandBuffer, contents: SubpassContents) -> (), + CmdEndRenderPass => (commandBuffer: CommandBuffer) -> (), + CmdExecuteCommands => (commandBuffer: CommandBuffer, commandBufferCount: u32, pCommandBuffers: *const CommandBuffer) -> (), + CreateSwapchainKHR => (device: Device, pCreateInfo: *const SwapchainCreateInfoKHR, pAllocator: *const AllocationCallbacks, pSwapchain: *mut SwapchainKHR) -> Result, + DestroySwapchainKHR => (device: Device, swapchain: SwapchainKHR, pAllocator: *const AllocationCallbacks) -> (), + GetSwapchainImagesKHR => (device: Device, swapchain: SwapchainKHR, pSwapchainImageCount: *mut u32, pSwapchainImages: *mut Image) -> Result, + AcquireNextImageKHR => (device: Device, swapchain: SwapchainKHR, timeout: u64, semaphore: Semaphore, fence: Fence, pImageIndex: *mut u32) -> Result, + QueuePresentKHR => (queue: Queue, pPresentInfo: *const PresentInfoKHR) -> Result, + CreateSharedSwapchainsKHR => (device: Device, swapchainCount: u32, pCreateInfos: *const SwapchainCreateInfoKHR, pAllocator: *const AllocationCallbacks, pSwapchains: *mut SwapchainKHR) -> Result, + CmdPushDescriptorSetKHR => (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, layout: PipelineLayout, set: u32, descriptorWriteCount: u32, pDescriptorWrites: *const WriteDescriptorSet) -> (), + CreateDescriptorUpdateTemplateKHR => (device: Device, pCreateInfo: *const DescriptorUpdateTemplateCreateInfoKHR, pAllocator: *const AllocationCallbacks, pDescriptorUpdateTemplate: *mut DescriptorUpdateTemplateKHR) -> Result, + DestroyDescriptorUpdateTemplateKHR => (device: Device, descriptorUpdateTemplate: DescriptorUpdateTemplateKHR, pAllocator: *const AllocationCallbacks) -> (), + UpdateDescriptorSetWithTemplateKHR => (device: Device, descriptorSet: DescriptorSet, descriptorUpdateTemplate: DescriptorUpdateTemplateKHR, pData: *const c_void) -> (), + CmdPushDescriptorSetWithTemplateKHR => (commandBuffer: CommandBuffer, descriptorUpdateTemplate: DescriptorUpdateTemplateKHR, layout: PipelineLayout, set: u32, pData: *const c_void) -> (), + GetImageMemoryRequirements2KHR => (device: Device, pInfo: *const ImageMemoryRequirementsInfo2KHR, pMemoryRequirements: *mut MemoryRequirements2KHR) -> (), + GetBufferMemoryRequirements2KHR => (device: Device, pInfo: *const BufferMemoryRequirementsInfo2KHR, pMemoryRequirements: *mut MemoryRequirements2KHR) -> (), + DebugMarkerSetObjectNameEXT => (device: Device, pNameInfo: *const DebugMarkerObjectNameInfoEXT) -> Result, + DebugMarkerSetObjectTagEXT => (device: Device, pTagInfo: *const DebugMarkerObjectTagInfoEXT) -> Result, + CmdDebugMarkerBeginEXT => (commandBuffer: CommandBuffer, pMarkerInfo: *const DebugMarkerMarkerInfoEXT) -> (), + CmdDebugMarkerEndEXT => (commandBuffer: CommandBuffer) -> (), + CmdDebugMarkerInsertEXT => (commandBuffer: CommandBuffer, pMarkerInfo: *const DebugMarkerMarkerInfoEXT) -> (), +}); diff --git a/third_party/cargo/vendor/void-1.0.2/.cargo-checksum.json b/third_party/cargo/vendor/void-1.0.2/.cargo-checksum.json new file mode 100644 index 0000000..9554bcd --- /dev/null +++ b/third_party/cargo/vendor/void-1.0.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"ea686f87a150a8e43c4b7db57c56d3eda2a4963420d5570d91d99d7d610dd3fb","README.md":"f85783a6fcf9ecc19edabd710775a88430d9e886f46728bfd7d65cef55ff3e73","src/lib.rs":"7ab8269f30715c0729b0e04e5a09be4c413664dc4b530746ea3240ac80a64c66"},"package":"6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"} \ No newline at end of file diff --git a/third_party/cargo/vendor/void-1.0.2/BUILD b/third_party/cargo/vendor/void-1.0.2/BUILD new file mode 100644 index 0000000..73716eb --- /dev/null +++ b/third_party/cargo/vendor/void-1.0.2/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "void", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.0.2", + crate_features = [ + "default", + "std", + ], +) + diff --git a/third_party/cargo/vendor/void-1.0.2/Cargo.toml b/third_party/cargo/vendor/void-1.0.2/Cargo.toml new file mode 100644 index 0000000..1a03139 --- /dev/null +++ b/third_party/cargo/vendor/void-1.0.2/Cargo.toml @@ -0,0 +1,15 @@ +[package] + +name = "void" +version = "1.0.2" +authors = ["Jonathan Reem <jonathan.reem@gmail.com>"] +repository = "https://github.com/reem/rust-void.git" +description = "The uninhabited void type for use in statically impossible cases." +readme = "README.md" +license = "MIT" + +[features] + +default = ["std"] +std = [] + diff --git a/third_party/cargo/vendor/void-1.0.2/README.md b/third_party/cargo/vendor/void-1.0.2/README.md new file mode 100644 index 0000000..4f86c21 --- /dev/null +++ b/third_party/cargo/vendor/void-1.0.2/README.md @@ -0,0 +1,39 @@ +# Void + +> The uninhabited void type for use in statically impossible cases. + +## [Documentation](https://crates.fyi/crates/void/1.0.1) + +The uninhabited type, `enum Void { }` is useful in dealing with cases you +know to be impossible. For instance, if you are implementing a trait which +allows for error checking, but your case always succeeds, you can mark the +error case or type as `Void`, signaling to the compiler it can never happen. + +This crate also comes packed with a few traits offering extension methods to +`Result<T, Void>` and `Result<Void, T>`. + +## Usage + +Use the crates.io repository; add this to your `Cargo.toml` along +with the rest of your dependencies: + +```toml +[dependencies] +void = "1" +``` + +Then, use `Void` in your crate: + +```rust +extern crate void; +use void::Void; +``` + +## Author + +[Jonathan Reem](https://medium.com/@jreem) is the primary author and maintainer of void. + +## License + +MIT + diff --git a/third_party/cargo/vendor/void-1.0.2/src/lib.rs b/third_party/cargo/vendor/void-1.0.2/src/lib.rs new file mode 100644 index 0000000..3b6287c --- /dev/null +++ b/third_party/cargo/vendor/void-1.0.2/src/lib.rs @@ -0,0 +1,121 @@ +#![cfg_attr(test, deny(warnings))] +#![deny(missing_docs)] +#![cfg_attr(not(feature = "std"), no_std)] + +//! # Void +//! +//! The uninhabited void type for use in statically impossible cases. +//! +//! In its own crate so all the users in the ecosystem can share the same type. +//! This crate also comes ready with several extension traits for Result that add +//! extra functionality to `Result<T, Void>` and `Result<Void, E>`. +//! + +#[cfg(not(feature = "std"))] +mod coreprovider { + extern crate core; + pub use core::{fmt, cmp}; +} + +#[cfg(feature = "std")] +mod coreprovider { + pub use std::{fmt, cmp, error}; +} + +use coreprovider::*; + +/// The empty type for cases which can't occur. +#[derive(Copy)] +pub enum Void { } + +impl Clone for Void { + fn clone(&self) -> Void { + unreachable(*self) + } +} + +impl fmt::Debug for Void { + fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + unreachable(*self) + } +} + +impl fmt::Display for Void { + fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + unreachable(*self) + } +} + +impl<T> cmp::PartialEq<T> for Void { + fn eq(&self, _: &T) -> bool { + unreachable(*self) + } +} + +impl<T> cmp::PartialOrd<T> for Void { + fn partial_cmp(&self, _: &T) -> Option<cmp::Ordering> { + unreachable(*self) + } +} + +#[cfg(feature = "std")] +impl error::Error for Void { + fn description(&self) -> &str { + unreachable(*self) + } + + fn cause(&self) -> Option<&error::Error> { + unreachable(*self) + } +} + +/// A safe version of `intrinsincs::unreachable`. +/// +/// If this typechecks, anything that causes this to run is unreachable code. +/// +/// Calling this function in reachable code invokes undefined behavior, but +/// should not be possible unless `unsafe` was used elsewhere to construct +/// an instance of `Void` (which is already undefined behavior). +#[inline(always)] +pub fn unreachable(x: Void) -> ! { + match x {} +} + +/// Extensions to `Result<T, Void>` +pub trait ResultVoidExt<T>: Sized { + /// Get the value out of a wrapper. + fn void_unwrap(self) -> T; +} + +impl<T> ResultVoidExt<T> for Result<T, Void> { + /// Get the value out of an always-ok Result. + /// + /// Never panics, since it is statically known to be Ok. + #[inline] + fn void_unwrap(self) -> T { + match self { + Ok(val) => val, + Err(e) => unreachable(e) + } + } +} + +/// Extensions to `Result<Void, E>` +pub trait ResultVoidErrExt<E>: Sized { + /// Get the error out of a wrapper. + fn void_unwrap_err(self) -> E; +} + +impl<E> ResultVoidErrExt<E> for Result<Void, E> { + /// Get the error out of an always-err Result. + /// + /// Never panics, since it is statically known to be Err. + #[inline] + fn void_unwrap_err(self) -> E { + match self { + Ok(v) => unreachable(v), + Err(e) => e + } + } +} + diff --git a/third_party/cargo/vendor/vulkano-0.11.1/.cargo-checksum.json b/third_party/cargo/vendor/vulkano-0.11.1/.cargo-checksum.json new file mode 100644 index 0000000..d6f138a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"fc19cef33ec7d1d3c5fa2ec3a21d1aa17c36b13842cb7c8f29f52482ec8592db","build.rs":"5d41d549b78f0f85c4c4972eae3dd50398aafd5aa538f531b177381e6f439e21","src/alloc.rs":"92f53c94a7398dad0796e47afcf21f574e7571cd5415d7872874d3328341b042","src/buffer/cpu_access.rs":"8e19c2f080e4384eed2dfb1bc75858f30752e46141701f7274b99341b31b6073","src/buffer/cpu_pool.rs":"2f3f9c78baf1138e69425db623b17bb84dc097df98f0c6dcc0e506133aadde79","src/buffer/device_local.rs":"089dc2a675e87c78981d34b96380c7a1b4f7cbda6bfb5a3b775241aec103f41c","src/buffer/immutable.rs":"5f26e05713247c807e4d11ec3d7aed218f432a737234b50365dc21b2aeaaad0f","src/buffer/mod.rs":"91feaed262c84f37fc4ba6b5a9fe38d0b37c7b77764e8f6a2d34df59f7bcd5aa","src/buffer/slice.rs":"a99574585f4a8d32fc4789865576b083a7aba20eb17a76cc6d465043d92d9bf0","src/buffer/sys.rs":"fb4b31450c52c7476b938a843932c21c2ac27a60d4c30f094bb72031163e307b","src/buffer/traits.rs":"31d7936055c2ddccff856b1e80b49cc223bb91ced4b913bbf41479f71ff2a466","src/buffer/usage.rs":"048e41a7c433bb03d5a7c4627bf05ce7a397a1ce75ad53d416e07f19f9ee30ef","src/buffer/view.rs":"11186f30c71a278d58a8fc3b221db36b6b141ec9c969c60620962c559fd27ed0","src/command_buffer/auto.rs":"f951f0910bbf1d807aeb73f28268a531f8de3e726316f0f2f238f7fc523a97cb","src/command_buffer/mod.rs":"37e29521b32aec26d62ad5e1bc77b47b755ad471f78576b90fcea5c667480588","src/command_buffer/pool/mod.rs":"72ee8c6100691b27a7743449ed77046afa3ed31bdfb3479e959dcd376e77b4b7","src/command_buffer/pool/standard.rs":"0c6b9e87c55f31ba2ac8a9408d28e7913197d1fd29427cbec574fed0c172fdec","src/command_buffer/pool/sys.rs":"e70e2aeee58f8e5896de4d236014ca701dba2b78cf9b47db0604f5691e6debda","src/command_buffer/state_cacher.rs":"b1bd2a0ff7496f24d37edc8581213370263d5a35e551f8c3be575c415d04da8f","src/command_buffer/submit/bind_sparse.rs":"5e819d7c8ba1541e130ce3fc9eb970eef13e227bdd1bee7b570f83b8956b38dc","src/command_buffer/submit/mod.rs":"508027ed1e39b6f25ae9c3a5e4558647eec76b3751c9c35641791bd7dff33176","src/command_buffer/submit/queue_present.rs":"9af067341c6a04838eff898146669139660041a17c066b4914617476c9dbefd0","src/command_buffer/submit/queue_submit.rs":"6526c350220f3567edde8c8f53816d0c471709cb23223c0c51555ba9fe3911cf","src/command_buffer/submit/semaphores_wait.rs":"f8f3408a66d3ebca2b4cf4a53a54fda105c9c78b2278211263ef90b09333d1a8","src/command_buffer/synced/base.rs":"5320c7bddf7fbe7460e0626f4e6ea4bc64c7cd676951340c5edd702dd7ad6ffc","src/command_buffer/synced/commands.rs":"441abe24e14f19beae436d34285cdf25879260be484b8f2f552cde1ed831816a","src/command_buffer/synced/mod.rs":"73b2e30a22e124121362e435b91d0633f837c1506b4f2c62264f0370c0ef9e83","src/command_buffer/synced/tests.rs":"1ad3d125fc9018b5beca91b6e386b0ee80f6c594ae3b65e5a8fb88c718a773e1","src/command_buffer/sys.rs":"10571d81e535d944a5e9123652f26a06f6b4e4c289b54506e6315af767e84bfe","src/command_buffer/traits.rs":"6566967b92ac237e0422f730a73a49547ad6981532d5b9ce203e1df698ba368e","src/command_buffer/validity/blit_image.rs":"1667f130a29ff7ffd943c1f0773e446fa931d066ffd6e52f2fd6a697198ec2af","src/command_buffer/validity/clear_color_image.rs":"d4de33da67459ad650a75c6be3598d0650cb3b9d51d25e3a93d0654c69062103","src/command_buffer/validity/copy_buffer.rs":"471f2e1ed178f75f21897312e6385bd6c5d7742bcd9a3bec14b5c03a257ceb74","src/command_buffer/validity/copy_image.rs":"be27dc4e7052d4f986337c803ded9bf2206c8fc462d4d59b58ea7bf1de4e724d","src/command_buffer/validity/copy_image_buffer.rs":"f8bfb05756e2f1a0937bc5da44d35212612efff91fef8da538aaef3dae3ec390","src/command_buffer/validity/descriptor_sets.rs":"608ad2557f98126724b2ec074a7de2a3e176be3a1eacd31de340c4b64044cf00","src/command_buffer/validity/dispatch.rs":"e387feec3a0f7547ea3058fd8c0c45f0f094ff7ebba17cdda561858f90c9fa1e","src/command_buffer/validity/dynamic_state.rs":"0cbaece8b3921d92cc1403f88b6232f75c156760b78c1f98b4726a7983a06842","src/command_buffer/validity/fill_buffer.rs":"b64cd36974597694ec1c56247a154fc19524607b59faf3dbc9738fce29c5d068","src/command_buffer/validity/index_buffer.rs":"8a4d33cc6f98e255a6d29d7fdca988a898da7f2b1bb7b5bd77a587373088e8d2","src/command_buffer/validity/mod.rs":"9cc9153cc47c6a07f4119c51aca8fdab6851b2da8f5b14b04646ae88910c5e11","src/command_buffer/validity/push_constants.rs":"2229e83e1f31759fbdc5f32cdecf5f95ad790edf126693ea36845e438e6e2c54","src/command_buffer/validity/update_buffer.rs":"f7c8fecd162d28b423d975a1a2158efea0573af64d0434d30653e6d331d5260c","src/command_buffer/validity/vertex_buffers.rs":"3ea737b0953103724a1b3067952bff4c16b69e465cb0e17802094f68b9f00c86","src/descriptor/descriptor.rs":"50e41034e477de46079fb355d6cf890dd3b0550baa572a3cef4907d0b893bfa8","src/descriptor/descriptor_set/collection.rs":"ec0236d624fbeecf0db81a8c22194cfad5c3049e84691254f7fb53d6563d0284","src/descriptor/descriptor_set/fixed_size_pool.rs":"2e7ab32db3e278e75a93518362f212a63cc33fa9722576ca1f8ed4204875c54a","src/descriptor/descriptor_set/mod.rs":"ef128ee011618db22c005047511dd5de9a0084ae659ffd5079b11ab67dab3095","src/descriptor/descriptor_set/persistent.rs":"424ccbbed24e4720b61663236956f1ce911790c5489503ea471017c8541c78db","src/descriptor/descriptor_set/std_pool.rs":"3506791cf3d9c2d871293fe55986fbf53e276e14fdbdea186ee6a1035ed5f35b","src/descriptor/descriptor_set/sys.rs":"fddfa06000c2768050bc34919af06314431286c5afc05101fedb54d69955a656","src/descriptor/descriptor_set/unsafe_layout.rs":"6b89982776f750c278e77fbc735fb75cacce1a8a63b4e1d1b5d9342fb31ffc43","src/descriptor/mod.rs":"c3be3f1d7d7fa371f53fe79d58972220c590bdec7e3ac7356f8e7548c89b7bd2","src/descriptor/pipeline_layout/empty.rs":"abe6f50598a2325d9730a3b7005786476d636ff25f387ca78641153a3d005775","src/descriptor/pipeline_layout/limits_check.rs":"7f2c257e3b56eee03ce6a053b943085537eace8241bb5634484acd55508b7dcc","src/descriptor/pipeline_layout/mod.rs":"50d1ac01a6f3b69df48df6f8908c8cde63d292a23bfa3caa21cfa044ecda68ea","src/descriptor/pipeline_layout/runtime_desc.rs":"5d8019e16018d62fc00df13706340c0a8dcb2fb83db8ab14fdb2017ea5703aa4","src/descriptor/pipeline_layout/sys.rs":"cdebff27580c9807c8545a5a83297929456d37a59fa483e6ec78d97248d82631","src/descriptor/pipeline_layout/traits.rs":"1a38b276373a72d22fde25007be3cacdb12643643c8c661fc483370108efb82b","src/descriptor/pipeline_layout/tweaks.rs":"09da8effb0f18116971087d85deda987192599dd67507ea0918fea16f8c1d987","src/descriptor/pipeline_layout/union.rs":"1a97a91295a70882f69975dd64cbc5c5d8e9f20cd611dbb6fe958f1a3156aeae","src/device/extensions.rs":"0fac812987e10a0b1f19b3e5cfe6e73aa43825eb24a4d3fafa628ec4e5d64128","src/device/mod.rs":"614dd1d1243aca5ed253f18a18ff85a0a4a6b1bdf5985f096a02e90ad4e57078","src/extensions.rs":"0e7f2f208609f6b48202035b2a3e6a7fdcdc988e115b1752dda2ef173ff58d14","src/features.rs":"b820c519f8ca48b397088d2a75e976adf149ac227b58baa652bf51b5f11da890","src/format.rs":"b8afd7196a93f10391f2e377b622692e0d5d6979919c9fe018ea0ff5606a1360","src/framebuffer/attachments_list.rs":"c49ed2c54be0c8af9b37cba82b6abf6aeeb6e356acec4898dfc7edc563f0a09f","src/framebuffer/compat_atch.rs":"b6a4d127c3f8da4085e8d2507a4dab14f29c7655607349c169852651677f0091","src/framebuffer/desc.rs":"7273006b51d1aa65f30246bf8f3fc846489560640e6e714fa7e9add103622139","src/framebuffer/empty.rs":"dd910711113f0dbfbb3a396fe6bd8a22ba0ae287dd09280f0c6c16be76b66150","src/framebuffer/framebuffer.rs":"d56e8a1c1f5158af309c92148b94dda91e8fb679bf9a3fcde2d1746d02406639","src/framebuffer/macros.rs":"8e2ad980afeadc7759a12e900c0fadf3b85f185bd67d522177c715f1da942b96","src/framebuffer/mod.rs":"d71e2d1bc338d9f1b533ed3736c15d4f8ce5e7080ae142da9ce765ba8e38974e","src/framebuffer/sys.rs":"1e836b1dabbf5efaac7ec6fe9192a7522004d6f207a4656905ff4c0f10294351","src/framebuffer/traits.rs":"9a1a1c8bf35e77074af66fe2eb144e328e747ac32467823bfb0e6c2363328bee","src/image/attachment.rs":"76ac90bc3084a8976a09415634a27e9fae0e91006bb6ec586ff192b0bce0eeb3","src/image/immutable.rs":"dd92bfeceab97533745da9e67cfa1093030b53c6cf8dd4efadfeef06207226ff","src/image/layout.rs":"8b79a36208f2cd7790165c66b492d8d33979c4d5d108893821b9e920c0798c39","src/image/mod.rs":"aad7113f1a72855e1fcd74facaed88041f1fc3f43ac38889c4bfaf4dc27d1a1b","src/image/storage.rs":"b3de42691dcfc95d0eee6074412e167822b55cef0d7868ca1c1ee701b9d0e0d4","src/image/swapchain.rs":"63ca94aa140093359420e61cd272749e5272e299f714c3b71e8f96b2e148aa2f","src/image/sys.rs":"30a6aad07b95603669672781982c92f1d0d2b99b70703a93d7acf4887d95ae94","src/image/traits.rs":"a9043cbc7d9998e722b3b613e862465edc0b34ed2583ed847daaa32ad333c3bc","src/image/usage.rs":"c82d3be03f3159703ce2e2845d29401d21684af9221208bc17bee52e2bfefbc1","src/instance/debug.rs":"2065f08730532e5e84a019a36c1608c2bd2105c10421696595339b01538ef4dc","src/instance/extensions.rs":"6743b2b4133659e94099b76481b057e84b07ced506865e84e161a3d80d20ee33","src/instance/instance.rs":"3ac9c37c11b9c3261f78783833b9b358cb8576e8e842662c2f6de177998dc152","src/instance/layers.rs":"bc3620894ab6a6f11b6f17919f0a3c1722cd42828b0b63534d1c73c8299c719d","src/instance/limits.rs":"14bbf9208844b543ceb9b24bd4c17e14e427c9670c7ba2247e56cd956536ca81","src/instance/loader.rs":"95378a0f8db9e7148a0924548d056279dca4338a57a9feee3b00bcbb2ba36f1f","src/instance/mod.rs":"f4b4155bcb1e1e5c0edb7f3ad546baef79264db6b8d7c5c5062a5a8ec5f945f6","src/lib.rs":"76289ab5fd5fdc534e1a505421d6fd9bed6d85937c0006ee37d1d947a1fbe87b","src/memory/device_memory.rs":"9719cecfa31ab6f918735554509638426d51c6267ccb2957c75e9fa8ae1ff904","src/memory/mod.rs":"bbeda446fa69255d51a4ea99b07ac74e4b70af2d79628d84a27e8de821533075","src/memory/pool/host_visible.rs":"adafa215014a719eb5f7a9dbef911d7dda011d92fe77de0abe7b2aba8c879d63","src/memory/pool/mod.rs":"67070d3d7b5e619e82570c464d00f1aed70423931684d16b767b346986d71535","src/memory/pool/non_host_visible.rs":"4567828339cffacbb114d8764f8f15dfe8fd338edde94508d681f9aabfa5f8b8","src/memory/pool/pool.rs":"32f9f98b9f743ce5de85f80097b705f73802952e87272df8bd03af5fce7ce1ec","src/pipeline/blend.rs":"0e40f3aaa3f673e5a3fb56b5b67b98a977d589550cae8aff0fa4112bfd347e2f","src/pipeline/cache.rs":"b116f3e3d0aefddd2eb02ebaf032c5ba25cc80801b7ffbbc970044d1a1d777d3","src/pipeline/compute_pipeline.rs":"d58f1ed498a21cca5fac49edb73b1c01950c6a94c558e09cab02c95cec1670f4","src/pipeline/depth_stencil.rs":"9fa30b6cf5edc3a222c9211e302a12d796faf1d03abfe677fe2e9ead1a23e711","src/pipeline/graphics_pipeline/builder.rs":"bbd22ba9c38d89449bce7cf5c4323df5b3378bedc9a4fe22ac4a5c30db8fec3f","src/pipeline/graphics_pipeline/creation_error.rs":"51d152d0fa0bc08328af9e33afba4b4f830238576f3f26c613f62cf4ab134f58","src/pipeline/graphics_pipeline/mod.rs":"30484c9d70f554543eaca126c79485a76a9c868e29214434644a3fb745bf1ee3","src/pipeline/graphics_pipeline/tests.rs":"ebf6a7c77c82529091058d7d365f4b21a95ac44a82c98b4d00516080655f6d59","src/pipeline/input_assembly.rs":"9aceb3239264f7d7550034b3f0ac1339c8ccf5bfcd841421fd4a82245a119fca","src/pipeline/mod.rs":"b1b70cd6eb155cc7648f713a37016de9b233196d7d49eea25f79ce484f79fc1d","src/pipeline/multisample.rs":"d06bae13cad042a0827f3363d9f3828f1fcb13a788809288212c862ab698c1a7","src/pipeline/raster.rs":"4cf79b519cb26c77739d93e378e693f99da118dd6395fe9a5eeec30ad22a4239","src/pipeline/shader.rs":"d6afbfd045f6fcd6065024373af3e8c561211dee3001b6a91639ae9cc98daa7d","src/pipeline/vertex/bufferless.rs":"e3b9be77dd390a2a80b8d66eb91b18899132e5a92c75aded288f88b773bd6bd4","src/pipeline/vertex/definition.rs":"0ccc83d67985f9a1a488ab744105ffbbb3591758a441fa63a48f75d997eb86d9","src/pipeline/vertex/impl_vertex.rs":"5dbdb6e55825717f6a1b7d6c326cbec654814894fd19afb27911baab085c7fde","src/pipeline/vertex/instance_buffer.rs":"d96a84fa7528dd3c8f9b64ccd7e9c3527966d563c3d5537b3dd09ae3a2e08a27","src/pipeline/vertex/mod.rs":"afe3ac25e254a9794ffb7688bc7b669a2f7d9358324e5c2129b8e3034fe7b99f","src/pipeline/vertex/one_one.rs":"3e767879fd1dd3185d110d97d8c01ec76b9caa6dd6bebc3555a7d03f67f96ec8","src/pipeline/vertex/single.rs":"6ca26964f1a39310103e69e24700d68db677a6936db115730b002ee69e45eee3","src/pipeline/vertex/two.rs":"96e05f732e85b758b4dc1e15835d0c27bb3206942ef5601a6472934c4918ffeb","src/pipeline/vertex/vertex.rs":"8491bb8b29d80e82a80b518e083660ca38e92dbd4f8a96240da2772c3b92c383","src/pipeline/viewport.rs":"dce443ed415f4ec0fee05c870e9a5e2fbc9ff563ffba15b307db829fc627404f","src/query/mod.rs":"2b01a8c66f3c7fedf5062973c1586ea07b488d9a7d6a6bbf22264239f1752f20","src/sampler.rs":"f7aa27efeaeb90e5ad85da5a61c7e44c97598a34dec01df73e52011d726fa17b","src/swapchain/capabilities.rs":"490d4e9ee0272c4757e49231f39550cec81f1d4f9d46cdf51b39bb93221b874a","src/swapchain/display.rs":"f68d40ac409c0f4d76598a77c8cae26b8777005d040d8dd7c0e2718665546a39","src/swapchain/mod.rs":"3d22b36bdda23b4989ac4bdbde358a87ed5eb94a8054038a84488de8b75e9e82","src/swapchain/present_region.rs":"dfab165d09295fde86972a7173bf71e5b68f619c6511bc262c7faf8a691a17dd","src/swapchain/surface.rs":"006d6f01ef300ab0b46e2ee984bfe64b0be20f4a58e21ca85c44175604c4e9df","src/swapchain/swapchain.rs":"ce67f5e4d11edf1b97e138352465fd9b266d24c003c3d62a98365af3722c9880","src/sync/event.rs":"09d8d2090499e35d1929768724587da2bbf972d797633e18cdf3e31c6f3b8993","src/sync/fence.rs":"82721a1b91ed3af9bef6faa3e969c7d2d712c1810a124e2fbc2b35924ffb4aa0","src/sync/future/fence_signal.rs":"a93ad367afbeff07488d4f4091d2be4e789a3cc78d267d2381c5344103965c7b","src/sync/future/join.rs":"0047c8fbb2b886e1af1453ec96649a084775506742fcdea00b434cb0217e5d46","src/sync/future/mod.rs":"1d645727f4aa3672edf50607315a2a55eb6d53414ea73699ffd76415da8f9501","src/sync/future/now.rs":"30612cdd3784334f1d11e34bbb93aaa9eadebaa7c9391111080a8de1e62cf969","src/sync/future/semaphore_signal.rs":"632fcfddaca3add4091adc26db262e4c3aeb9c82a0795201b4f9f39bc7737320","src/sync/mod.rs":"5bc84e74386a70971b1dd90f472a03d17a9c8ac9e36a967675f0817f8ced4e07","src/sync/pipeline.rs":"b08df4301cb6ac4f3e4b6bd2b28bd9e525fbd8b0a3742927c881adb476c20bb5","src/sync/semaphore.rs":"780aae5374c0579688b483e76d4f964f34ce23b8971cb308096189622e72cbe6","src/tests.rs":"d9a0021fdb30f881026ca8acd7c98cf8333badcefc728fc063c7c43b064023f6","src/version.rs":"a69d8d926020f8428e3b5ddda09bda3fa8715aba1ebc5da775e71aa5ab14d1d6"},"package":"715b3528d50119f2b7088479a79ff9d95416a6613d18c853d87ad98185ca43d1"} \ No newline at end of file diff --git a/third_party/cargo/vendor/vulkano-0.11.1/BUILD b/third_party/cargo/vendor/vulkano-0.11.1/BUILD new file mode 100644 index 0000000..33710b2 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/BUILD @@ -0,0 +1,50 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "vulkano", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/crossbeam-0.5.0:crossbeam", + "//third_party/cargo/vendor/fnv-1.0.6:fnv", + "//third_party/cargo/vendor/half-1.4.0:half", + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + "//third_party/cargo/vendor/shared_library-0.1.9:shared_library", + "//third_party/cargo/vendor/smallvec-0.6.13:smallvec", + "//third_party/cargo/vendor/vk-sys-0.4.0:vk_sys", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.11.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/vulkano-0.11.1/Cargo.toml b/third_party/cargo/vendor/vulkano-0.11.1/Cargo.toml new file mode 100644 index 0000000..ffc7d15 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/Cargo.toml @@ -0,0 +1,45 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "vulkano" +version = "0.11.1" +authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>", "The vulkano contributors"] +build = "build.rs" +description = "Safe wrapper for the Vulkan graphics API" +homepage = "https://vulkano.rs" +documentation = "https://docs.rs/vulkano" +readme = "../README.md" +keywords = ["vulkan", "bindings", "graphics", "gpu", "rendering"] +categories = ["rendering::graphics-api"] +license = "MIT/Apache-2.0" +repository = "https://github.com/vulkano-rs/vulkano" +[dependencies.crossbeam] +version = "0.5" + +[dependencies.fnv] +version = "1.0.6" + +[dependencies.half] +version = "1" + +[dependencies.lazy_static] +version = "1" + +[dependencies.shared_library] +version = "0.1.7" + +[dependencies.smallvec] +version = "0.6.0" + +[dependencies.vk-sys] +version = "0.4.0" diff --git a/third_party/cargo/vendor/vulkano-0.11.1/build.rs b/third_party/cargo/vendor/vulkano-0.11.1/build.rs new file mode 100644 index 0000000..23a46a0 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/build.rs @@ -0,0 +1,24 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::env; + +fn main() { + let target = env::var("TARGET").unwrap(); + if target.contains("apple-ios") { + println!("cargo:rustc-link-search=framework=/Library/Frameworks/"); + println!("cargo:rustc-link-lib=c++"); + println!("cargo:rustc-link-lib=framework=MoltenVK"); + println!("cargo:rustc-link-lib=framework=Metal"); + println!("cargo:rustc-link-lib=framework=IOSurface"); + println!("cargo:rustc-link-lib=framework=QuartzCore"); + println!("cargo:rustc-link-lib=framework=UIKit"); + println!("cargo:rustc-link-lib=framework=Foundation"); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/alloc.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/alloc.rs new file mode 100644 index 0000000..f4c80a0 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/alloc.rs @@ -0,0 +1,23 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::mem; +use std::os::raw::c_void; + +pub unsafe trait Alloc { + fn alloc(&self, size: usize, alignment: usize) -> Result<*mut c_void, ()>; + + fn realloc(&self, original: *mut c_void, size: usize, alignment: usize) -> Result<*mut c_void, ()>; + + fn free(&self, *mut c_void); + + fn internal_free_notification(&self, size: usize); + + fn internal_allocation_notification(&self, size: usize); +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/cpu_access.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/cpu_access.rs new file mode 100644 index 0000000..62d8ba8 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/cpu_access.rs @@ -0,0 +1,584 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Buffer whose content is accessible to the CPU. +//! +//! The `CpuAccessibleBuffer` is a basic general-purpose buffer. It can be used in any situation +//! but may not perform as well as other buffer types. +//! +//! Each access from the CPU or from the GPU locks the whole buffer for either reading or writing. +//! You can read the buffer multiple times simultaneously. Trying to read and write simultaneously, +//! or write and write simultaneously will block. + +use smallvec::SmallVec; +use std::error; +use std::fmt; +use std::iter; +use std::marker::PhantomData; +use std::mem; +use std::ops::Deref; +use std::ops::DerefMut; +use std::ptr; +use std::sync::Arc; +use std::sync::RwLock; +use std::sync::RwLockReadGuard; +use std::sync::RwLockWriteGuard; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; + +use buffer::BufferUsage; +use buffer::sys::BufferCreationError; +use buffer::sys::SparseLevel; +use buffer::sys::UnsafeBuffer; +use buffer::traits::BufferAccess; +use buffer::traits::BufferInner; +use buffer::traits::TypedBufferAccess; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use instance::QueueFamily; +use memory::Content; +use memory::CpuAccess as MemCpuAccess; +use memory::DedicatedAlloc; +use memory::DeviceMemoryAllocError; +use memory::pool::AllocFromRequirementsFilter; +use memory::pool::AllocLayout; +use memory::pool::MappingRequirement; +use memory::pool::MemoryPool; +use memory::pool::MemoryPoolAlloc; +use memory::pool::PotentialDedicatedAllocation; +use memory::pool::StdMemoryPoolAlloc; +use sync::AccessError; +use sync::Sharing; + +/// Buffer whose content is accessible by the CPU. +#[derive(Debug)] +pub struct CpuAccessibleBuffer<T: ?Sized, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { + // Inner content. + inner: UnsafeBuffer, + + // The memory held by the buffer. + memory: A, + + // Access pattern of the buffer. + // Every time the user tries to read or write the buffer from the CPU, this `RwLock` is kept + // locked and its content is checked to verify that we are allowed access. Every time the user + // tries to submit this buffer for the GPU, this `RwLock` is briefly locked and modified. + access: RwLock<CurrentGpuAccess>, + + // Queue families allowed to access this buffer. + queue_families: SmallVec<[u32; 4]>, + + // Necessary to make it compile. + marker: PhantomData<Box<T>>, +} + +#[derive(Debug)] +enum CurrentGpuAccess { + NonExclusive { + // Number of non-exclusive GPU accesses. Can be 0. + num: AtomicUsize, + }, + Exclusive { + // Number of exclusive locks. Cannot be 0. If 0 is reached, we must jump to `NonExclusive`. + num: usize, + }, +} + +impl<T> CpuAccessibleBuffer<T> { + /// Builds a new buffer with some data in it. Only allowed for sized data. + pub fn from_data(device: Arc<Device>, usage: BufferUsage, data: T) + -> Result<Arc<CpuAccessibleBuffer<T>>, DeviceMemoryAllocError> + where T: Content + 'static + { + unsafe { + let uninitialized = + CpuAccessibleBuffer::raw(device, mem::size_of::<T>(), usage, iter::empty())?; + + // Note that we are in panic-unsafety land here. However a panic should never ever + // happen here, so in theory we are safe. + // TODO: check whether that's true ^ + + { + let mut mapping = uninitialized.write().unwrap(); + ptr::write::<T>(&mut *mapping, data) + } + + Ok(uninitialized) + } + } + + /// Builds a new uninitialized buffer. Only allowed for sized data. + #[inline] + pub unsafe fn uninitialized(device: Arc<Device>, usage: BufferUsage) + -> Result<Arc<CpuAccessibleBuffer<T>>, DeviceMemoryAllocError> { + CpuAccessibleBuffer::raw(device, mem::size_of::<T>(), usage, iter::empty()) + } +} + +impl<T> CpuAccessibleBuffer<[T]> { + /// Builds a new buffer that contains an array `T`. The initial data comes from an iterator + /// that produces that list of Ts. + pub fn from_iter<I>(device: Arc<Device>, usage: BufferUsage, data: I) + -> Result<Arc<CpuAccessibleBuffer<[T]>>, DeviceMemoryAllocError> + where I: ExactSizeIterator<Item = T>, + T: Content + 'static + { + unsafe { + let uninitialized = + CpuAccessibleBuffer::uninitialized_array(device, data.len(), usage)?; + + // Note that we are in panic-unsafety land here. However a panic should never ever + // happen here, so in theory we are safe. + // TODO: check whether that's true ^ + + { + let mut mapping = uninitialized.write().unwrap(); + + for (i, o) in data.zip(mapping.iter_mut()) { + ptr::write(o, i); + } + } + + Ok(uninitialized) + } + } + + /// Builds a new buffer. Can be used for arrays. + #[inline] + pub unsafe fn uninitialized_array( + device: Arc<Device>, len: usize, usage: BufferUsage) + -> Result<Arc<CpuAccessibleBuffer<[T]>>, DeviceMemoryAllocError> { + CpuAccessibleBuffer::raw(device, len * mem::size_of::<T>(), usage, iter::empty()) + } +} + +impl<T: ?Sized> CpuAccessibleBuffer<T> { + /// Builds a new buffer without checking the size. + /// + /// # Safety + /// + /// You must ensure that the size that you pass is correct for `T`. + /// + pub unsafe fn raw<'a, I>(device: Arc<Device>, size: usize, usage: BufferUsage, + queue_families: I) + -> Result<Arc<CpuAccessibleBuffer<T>>, DeviceMemoryAllocError> + where I: IntoIterator<Item = QueueFamily<'a>> + { + let queue_families = queue_families + .into_iter() + .map(|f| f.id()) + .collect::<SmallVec<[u32; 4]>>(); + + let (buffer, mem_reqs) = { + let sharing = if queue_families.len() >= 2 { + Sharing::Concurrent(queue_families.iter().cloned()) + } else { + Sharing::Exclusive + }; + + match UnsafeBuffer::new(device.clone(), size, usage, sharing, SparseLevel::none()) { + Ok(b) => b, + Err(BufferCreationError::AllocError(err)) => return Err(err), + Err(_) => unreachable!(), // We don't use sparse binding, therefore the other + // errors can't happen + } + }; + + let mem = MemoryPool::alloc_from_requirements(&Device::standard_pool(&device), + &mem_reqs, + AllocLayout::Linear, + MappingRequirement::Map, + DedicatedAlloc::Buffer(&buffer), + |_| AllocFromRequirementsFilter::Allowed)?; + debug_assert!((mem.offset() % mem_reqs.alignment) == 0); + debug_assert!(mem.mapped_memory().is_some()); + buffer.bind_memory(mem.memory(), mem.offset())?; + + Ok(Arc::new(CpuAccessibleBuffer { + inner: buffer, + memory: mem, + access: RwLock::new(CurrentGpuAccess::NonExclusive { + num: AtomicUsize::new(0), + }), + queue_families: queue_families, + marker: PhantomData, + })) + } +} + +impl<T: ?Sized, A> CpuAccessibleBuffer<T, A> { + /// Returns the queue families this buffer can be used on. + // TODO: use a custom iterator + #[inline] + pub fn queue_families(&self) -> Vec<QueueFamily> { + self.queue_families + .iter() + .map(|&num| { + self.device() + .physical_device() + .queue_family_by_id(num) + .unwrap() + }) + .collect() + } +} + +impl<T: ?Sized, A> CpuAccessibleBuffer<T, A> + where T: Content + 'static, + A: MemoryPoolAlloc +{ + /// Locks the buffer in order to read its content from the CPU. + /// + /// If the buffer is currently used in exclusive mode by the GPU, this function will return + /// an error. Similarly if you called `write()` on the buffer and haven't dropped the lock, + /// this function will return an error as well. + /// + /// After this function successfully locks the buffer, any attempt to submit a command buffer + /// that uses it in exclusive mode will fail. You can still submit this buffer for non-exclusive + /// accesses (ie. reads). + #[inline] + pub fn read(&self) -> Result<ReadLock<T>, ReadLockError> { + let lock = match self.access.try_read() { + Ok(l) => l, + // TODO: if a user simultaneously calls .write(), and write() is currently finding out + // that the buffer is in fact GPU locked, then we will return a CpuWriteLocked + // error instead of a GpuWriteLocked ; is this a problem? how do we fix this? + Err(_) => return Err(ReadLockError::CpuWriteLocked), + }; + + if let CurrentGpuAccess::Exclusive { .. } = *lock { + return Err(ReadLockError::GpuWriteLocked); + } + + let offset = self.memory.offset(); + let range = offset .. offset + self.inner.size(); + + Ok(ReadLock { + inner: unsafe { self.memory.mapped_memory().unwrap().read_write(range) }, + lock: lock, + }) + } + + /// Locks the buffer in order to write its content from the CPU. + /// + /// If the buffer is currently in use by the GPU, this function will return an error. Similarly + /// if you called `read()` on the buffer and haven't dropped the lock, this function will + /// return an error as well. + /// + /// After this function successfully locks the buffer, any attempt to submit a command buffer + /// that uses it and any attempt to call `read()` will return an error. + #[inline] + pub fn write(&self) -> Result<WriteLock<T>, WriteLockError> { + let lock = match self.access.try_write() { + Ok(l) => l, + // TODO: if a user simultaneously calls .read() or .write(), and the function is + // currently finding out that the buffer is in fact GPU locked, then we will + // return a CpuLocked error instead of a GpuLocked ; is this a problem? + // how do we fix this? + Err(_) => return Err(WriteLockError::CpuLocked), + }; + + match *lock { + CurrentGpuAccess::NonExclusive { ref num } if num.load(Ordering::SeqCst) == 0 => (), + _ => return Err(WriteLockError::GpuLocked), + } + + let offset = self.memory.offset(); + let range = offset .. offset + self.inner.size(); + + Ok(WriteLock { + inner: unsafe { self.memory.mapped_memory().unwrap().read_write(range) }, + lock: lock, + }) + } +} + +unsafe impl<T: ?Sized, A> BufferAccess for CpuAccessibleBuffer<T, A> + where T: 'static + Send + Sync +{ + #[inline] + fn inner(&self) -> BufferInner { + BufferInner { + buffer: &self.inner, + offset: 0, + } + } + + #[inline] + fn size(&self) -> usize { + self.inner.size() + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + self.conflict_key() == other.conflict_key() // TODO: + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + false + } + + #[inline] + fn conflict_key(&self) -> (u64, usize) { + (self.inner.key(), 0) + } + + #[inline] + fn try_gpu_lock(&self, exclusive_access: bool, _: &Queue) -> Result<(), AccessError> { + if exclusive_access { + let mut lock = match self.access.try_write() { + Ok(lock) => lock, + Err(_) => return Err(AccessError::AlreadyInUse), + }; + + match *lock { + CurrentGpuAccess::NonExclusive { ref num } if num.load(Ordering::SeqCst) == 0 => (), + _ => return Err(AccessError::AlreadyInUse), + }; + + *lock = CurrentGpuAccess::Exclusive { num: 1 }; + Ok(()) + + } else { + let lock = match self.access.try_read() { + Ok(lock) => lock, + Err(_) => return Err(AccessError::AlreadyInUse), + }; + + match *lock { + CurrentGpuAccess::Exclusive { .. } => return Err(AccessError::AlreadyInUse), + CurrentGpuAccess::NonExclusive { ref num } => { + num.fetch_add(1, Ordering::SeqCst) + }, + }; + + Ok(()) + } + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + // First, handle if we have a non-exclusive access. + { + // Since the buffer is in use by the GPU, it is invalid to hold a write-lock to + // the buffer. The buffer can still be briefly in a write-locked state for the duration + // of the check though. + let read_lock = self.access.read().unwrap(); + if let CurrentGpuAccess::NonExclusive { ref num } = *read_lock { + let prev = num.fetch_add(1, Ordering::SeqCst); + debug_assert!(prev >= 1); + return; + } + } + + // If we reach here, this means that `access` contains `CurrentGpuAccess::Exclusive`. + { + // Same remark as above, but for writing. + let mut write_lock = self.access.write().unwrap(); + if let CurrentGpuAccess::Exclusive { ref mut num } = *write_lock { + *num += 1; + } else { + unreachable!() + } + } + } + + #[inline] + unsafe fn unlock(&self) { + // First, handle if we had a non-exclusive access. + { + // Since the buffer is in use by the GPU, it is invalid to hold a write-lock to + // the buffer. The buffer can still be briefly in a write-locked state for the duration + // of the check though. + let read_lock = self.access.read().unwrap(); + if let CurrentGpuAccess::NonExclusive { ref num } = *read_lock { + let prev = num.fetch_sub(1, Ordering::SeqCst); + debug_assert!(prev >= 1); + return; + } + } + + // If we reach here, this means that `access` contains `CurrentGpuAccess::Exclusive`. + { + // Same remark as above, but for writing. + let mut write_lock = self.access.write().unwrap(); + if let CurrentGpuAccess::Exclusive { ref mut num } = *write_lock { + if *num != 1 { + *num -= 1; + return; + } + } else { + // Can happen if we lock in exclusive mode N times, and unlock N+1 times with the + // last two unlocks happen simultaneously. + panic!() + } + + *write_lock = CurrentGpuAccess::NonExclusive { num: AtomicUsize::new(0) }; + } + } +} + +unsafe impl<T: ?Sized, A> TypedBufferAccess for CpuAccessibleBuffer<T, A> + where T: 'static + Send + Sync +{ + type Content = T; +} + +unsafe impl<T: ?Sized, A> DeviceOwned for CpuAccessibleBuffer<T, A> { + #[inline] + fn device(&self) -> &Arc<Device> { + self.inner.device() + } +} + +/// Object that can be used to read or write the content of a `CpuAccessibleBuffer`. +/// +/// Note that this object holds a rwlock read guard on the chunk. If another thread tries to access +/// this buffer's content or tries to submit a GPU command that uses this buffer, it will block. +pub struct ReadLock<'a, T: ?Sized + 'a> { + inner: MemCpuAccess<'a, T>, + lock: RwLockReadGuard<'a, CurrentGpuAccess>, +} + +impl<'a, T: ?Sized + 'a> ReadLock<'a, T> { + /// Makes a new `ReadLock` to access a sub-part of the current `ReadLock`. + #[inline] + pub fn map<U: ?Sized + 'a, F>(self, f: F) -> ReadLock<'a, U> + where F: FnOnce(&mut T) -> &mut U + { + ReadLock { + inner: self.inner.map(|ptr| unsafe { f(&mut *ptr) as *mut _ }), + lock: self.lock, + } + } +} + +impl<'a, T: ?Sized + 'a> Deref for ReadLock<'a, T> { + type Target = T; + + #[inline] + fn deref(&self) -> &T { + self.inner.deref() + } +} + +/// Error when attempting to CPU-read a buffer. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ReadLockError { + /// The buffer is already locked for write mode by the CPU. + CpuWriteLocked, + /// The buffer is already locked for write mode by the GPU. + GpuWriteLocked, +} + +impl error::Error for ReadLockError { + #[inline] + fn description(&self) -> &str { + match *self { + ReadLockError::CpuWriteLocked => { + "the buffer is already locked for write mode by the CPU" + }, + ReadLockError::GpuWriteLocked => { + "the buffer is already locked for write mode by the GPU" + }, + } + } +} + +impl fmt::Display for ReadLockError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +/// Object that can be used to read or write the content of a `CpuAccessibleBuffer`. +/// +/// Note that this object holds a rwlock write guard on the chunk. If another thread tries to access +/// this buffer's content or tries to submit a GPU command that uses this buffer, it will block. +pub struct WriteLock<'a, T: ?Sized + 'a> { + inner: MemCpuAccess<'a, T>, + lock: RwLockWriteGuard<'a, CurrentGpuAccess>, +} + +impl<'a, T: ?Sized + 'a> WriteLock<'a, T> { + /// Makes a new `WriteLock` to access a sub-part of the current `WriteLock`. + #[inline] + pub fn map<U: ?Sized + 'a, F>(self, f: F) -> WriteLock<'a, U> + where F: FnOnce(&mut T) -> &mut U + { + WriteLock { + inner: self.inner.map(|ptr| unsafe { f(&mut *ptr) as *mut _ }), + lock: self.lock, + } + } +} + +impl<'a, T: ?Sized + 'a> Deref for WriteLock<'a, T> { + type Target = T; + + #[inline] + fn deref(&self) -> &T { + self.inner.deref() + } +} + +impl<'a, T: ?Sized + 'a> DerefMut for WriteLock<'a, T> { + #[inline] + fn deref_mut(&mut self) -> &mut T { + self.inner.deref_mut() + } +} + +/// Error when attempting to CPU-write a buffer. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum WriteLockError { + /// The buffer is already locked by the CPU. + CpuLocked, + /// The buffer is already locked by the GPU. + GpuLocked, +} + +impl error::Error for WriteLockError { + #[inline] + fn description(&self) -> &str { + match *self { + WriteLockError::CpuLocked => { + "the buffer is already locked by the CPU" + }, + WriteLockError::GpuLocked => { + "the buffer is already locked by the GPU" + }, + } + } +} + +impl fmt::Display for WriteLockError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +#[cfg(test)] +mod tests { + use buffer::{BufferUsage, CpuAccessibleBuffer}; + + #[test] + fn create_empty_buffer() { + let (device, queue) = gfx_dev_and_queue!(); + + const EMPTY: [i32; 0] = []; + + let _ = CpuAccessibleBuffer::from_data(device, BufferUsage::all(), EMPTY.iter()); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/cpu_pool.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/cpu_pool.rs new file mode 100644 index 0000000..7db45dc --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/cpu_pool.rs @@ -0,0 +1,878 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::cmp; +use std::iter; +use std::marker::PhantomData; +use std::mem; +use std::ptr; +use std::sync::Arc; +use std::sync::Mutex; +use std::sync::MutexGuard; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; + +use buffer::BufferUsage; +use buffer::sys::BufferCreationError; +use buffer::sys::SparseLevel; +use buffer::sys::UnsafeBuffer; +use buffer::traits::BufferAccess; +use buffer::traits::BufferInner; +use buffer::traits::TypedBufferAccess; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use memory::DedicatedAlloc; +use memory::DeviceMemoryAllocError; +use memory::pool::AllocFromRequirementsFilter; +use memory::pool::AllocLayout; +use memory::pool::MappingRequirement; +use memory::pool::MemoryPool; +use memory::pool::MemoryPoolAlloc; +use memory::pool::PotentialDedicatedAllocation; +use memory::pool::StdMemoryPool; +use sync::AccessError; +use sync::Sharing; + +use OomError; + +// TODO: Add `CpuBufferPoolSubbuffer::read` to read the content of a subbuffer. +// But that's hard to do because we must prevent `increase_gpu_lock` from working while a +// a buffer is locked. + +/// Ring buffer from which "sub-buffers" can be individually allocated. +/// +/// This buffer is especially suitable when you want to upload or download some data regularly +/// (for example, at each frame for a video game). +/// +/// # Usage +/// +/// A `CpuBufferPool` is similar to a ring buffer. You start by creating an empty pool, then you +/// grab elements from the pool and use them, and if the pool is full it will automatically grow +/// in size. +/// +/// Contrary to a `Vec`, elements automatically free themselves when they are dropped (ie. usually +/// when you call `cleanup_finished()` on a future, or when you drop that future). +/// +/// # Arc-like +/// +/// The `CpuBufferPool` struct internally contains an `Arc`. You can clone the `CpuBufferPool` for +/// a cheap cost, and all the clones will share the same underlying buffer. +/// +/// # Example +/// +/// ``` +/// use vulkano::buffer::CpuBufferPool; +/// use vulkano::command_buffer::AutoCommandBufferBuilder; +/// use vulkano::command_buffer::CommandBuffer; +/// use vulkano::sync::GpuFuture; +/// # let device: std::sync::Arc<vulkano::device::Device> = return; +/// # let queue: std::sync::Arc<vulkano::device::Queue> = return; +/// +/// // Create the ring buffer. +/// let buffer = CpuBufferPool::upload(device.clone()); +/// +/// for n in 0 .. 25u32 { +/// // Each loop grabs a new entry from that ring buffer and stores ` data` in it. +/// let data: [f32; 4] = [1.0, 0.5, n as f32 / 24.0, 0.0]; +/// let sub_buffer = buffer.next(data).unwrap(); +/// +/// // You can then use `sub_buffer` as if it was an entirely separate buffer. +/// AutoCommandBufferBuilder::primary_one_time_submit(device.clone(), queue.family()) +/// .unwrap() +/// // For the sake of the example we just call `update_buffer` on the buffer, even though +/// // it is pointless to do that. +/// .update_buffer(sub_buffer.clone(), [0.2, 0.3, 0.4, 0.5]) +/// .unwrap() +/// .build().unwrap() +/// .execute(queue.clone()) +/// .unwrap() +/// .then_signal_fence_and_flush() +/// .unwrap(); +/// } +/// ``` +/// +pub struct CpuBufferPool<T, A = Arc<StdMemoryPool>> + where A: MemoryPool +{ + // The device of the pool. + device: Arc<Device>, + + // The memory pool to use for allocations. + pool: A, + + // Current buffer from which elements are grabbed. + current_buffer: Mutex<Option<Arc<ActualBuffer<A>>>>, + + // Buffer usage. + usage: BufferUsage, + + // Necessary to make it compile. + marker: PhantomData<Box<T>>, +} + +// One buffer of the pool. +struct ActualBuffer<A> + where A: MemoryPool +{ + // Inner content. + inner: UnsafeBuffer, + + // The memory held by the buffer. + memory: PotentialDedicatedAllocation<A::Alloc>, + + // List of the chunks that are reserved. + chunks_in_use: Mutex<Vec<ActualBufferChunk>>, + + // The index of the chunk that should be available next for the ring buffer. + next_index: AtomicUsize, + + // Number of elements in the buffer. + capacity: usize, +} + +// Access pattern of one subbuffer. +#[derive(Debug)] +struct ActualBufferChunk { + // First element number within the actual buffer. + index: usize, + + // Number of occupied elements within the actual buffer. + len: usize, + + // Number of `CpuBufferPoolSubbuffer` objects that point to this subbuffer. + num_cpu_accesses: usize, + + // Number of `CpuBufferPoolSubbuffer` objects that point to this subbuffer and that have been + // GPU-locked. + num_gpu_accesses: usize, +} + +/// A subbuffer allocated from a `CpuBufferPool`. +/// +/// When this object is destroyed, the subbuffer is automatically reclaimed by the pool. +pub struct CpuBufferPoolChunk<T, A> + where A: MemoryPool +{ + buffer: Arc<ActualBuffer<A>>, + + // Index of the subbuffer within `buffer`. In number of elements. + index: usize, + + // Number of bytes to add to `index * mem::size_of::<T>()` to obtain the start of the data in + // the buffer. Necessary for alignment purposes. + align_offset: usize, + + // Size of the subbuffer in number of elements, as requested by the user. + // If this is 0, then no entry was added to `chunks_in_use`. + requested_len: usize, + + // Necessary to make it compile. + marker: PhantomData<Box<T>>, +} + +/// A subbuffer allocated from a `CpuBufferPool`. +/// +/// When this object is destroyed, the subbuffer is automatically reclaimed by the pool. +pub struct CpuBufferPoolSubbuffer<T, A> + where A: MemoryPool +{ + // This struct is just a wrapper around `CpuBufferPoolChunk`. + chunk: CpuBufferPoolChunk<T, A>, +} + +impl<T> CpuBufferPool<T> { + /// Builds a `CpuBufferPool`. + #[inline] + pub fn new(device: Arc<Device>, usage: BufferUsage) -> CpuBufferPool<T> { + let pool = Device::standard_pool(&device); + + CpuBufferPool { + device: device, + pool: pool, + current_buffer: Mutex::new(None), + usage: usage.clone(), + marker: PhantomData, + } + } + + /// Builds a `CpuBufferPool` meant for simple uploads. + /// + /// Shortcut for a pool that can only be used as transfer source and with exclusive queue + /// family accesses. + #[inline] + pub fn upload(device: Arc<Device>) -> CpuBufferPool<T> { + CpuBufferPool::new(device, BufferUsage::transfer_source()) + } + + /// Builds a `CpuBufferPool` meant for simple downloads. + /// + /// Shortcut for a pool that can only be used as transfer destination and with exclusive queue + /// family accesses. + #[inline] + pub fn download(device: Arc<Device>) -> CpuBufferPool<T> { + CpuBufferPool::new(device, BufferUsage::transfer_destination()) + } + + /// Builds a `CpuBufferPool` meant for usage as a uniform buffer. + /// + /// Shortcut for a pool that can only be used as uniform buffer and with exclusive queue + /// family accesses. + #[inline] + pub fn uniform_buffer(device: Arc<Device>) -> CpuBufferPool<T> { + CpuBufferPool::new(device, BufferUsage::uniform_buffer()) + } + + /// Builds a `CpuBufferPool` meant for usage as a vertex buffer. + /// + /// Shortcut for a pool that can only be used as vertex buffer and with exclusive queue + /// family accesses. + #[inline] + pub fn vertex_buffer(device: Arc<Device>) -> CpuBufferPool<T> { + CpuBufferPool::new(device, BufferUsage::vertex_buffer()) + } + + /// Builds a `CpuBufferPool` meant for usage as a indirect buffer. + /// + /// Shortcut for a pool that can only be used as indirect buffer and with exclusive queue + /// family accesses. + #[inline] + pub fn indirect_buffer(device: Arc<Device>) -> CpuBufferPool<T> { + CpuBufferPool::new(device, BufferUsage::indirect_buffer()) + } +} + +impl<T, A> CpuBufferPool<T, A> + where A: MemoryPool +{ + /// Returns the current capacity of the pool, in number of elements. + pub fn capacity(&self) -> usize { + match *self.current_buffer.lock().unwrap() { + None => 0, + Some(ref buf) => buf.capacity, + } + } + + /// Makes sure that the capacity is at least `capacity`. Allocates memory if it is not the + /// case. + /// + /// Since this can involve a memory allocation, an `OomError` can happen. + pub fn reserve(&self, capacity: usize) -> Result<(), DeviceMemoryAllocError> { + let mut cur_buf = self.current_buffer.lock().unwrap(); + + // Check current capacity. + match *cur_buf { + Some(ref buf) if buf.capacity >= capacity => { + return Ok(()); + }, + _ => (), + }; + + self.reset_buf(&mut cur_buf, capacity) + } + + /// Grants access to a new subbuffer and puts `data` in it. + /// + /// If no subbuffer is available (because they are still in use by the GPU), a new buffer will + /// automatically be allocated. + /// + /// > **Note**: You can think of it like a `Vec`. If you insert an element and the `Vec` is not + /// > large enough, a new chunk of memory is automatically allocated. + #[inline] + pub fn next(&self, data: T) -> Result<CpuBufferPoolSubbuffer<T, A>, DeviceMemoryAllocError> { + Ok(CpuBufferPoolSubbuffer { chunk: self.chunk(iter::once(data))? }) + } + + /// Grants access to a new subbuffer and puts `data` in it. + /// + /// If no subbuffer is available (because they are still in use by the GPU), a new buffer will + /// automatically be allocated. + /// + /// > **Note**: You can think of it like a `Vec`. If you insert elements and the `Vec` is not + /// > large enough, a new chunk of memory is automatically allocated. + /// + /// # Panic + /// + /// Panics if the length of the iterator didn't match the actual number of element. + /// + pub fn chunk<I>(&self, data: I) -> Result<CpuBufferPoolChunk<T, A>, DeviceMemoryAllocError> + where I: IntoIterator<Item = T>, + I::IntoIter: ExactSizeIterator + { + let data = data.into_iter(); + + let mut mutex = self.current_buffer.lock().unwrap(); + + let data = match self.try_next_impl(&mut mutex, data) { + Ok(n) => return Ok(n), + Err(d) => d, + }; + + let next_capacity = match *mutex { + Some(ref b) if data.len() < b.capacity => 2 * b.capacity, + _ => 2 * data.len(), + }; + + self.reset_buf(&mut mutex, next_capacity)?; + + match self.try_next_impl(&mut mutex, data) { + Ok(n) => Ok(n), + Err(_) => unreachable!(), + } + } + + /// Grants access to a new subbuffer and puts `data` in it. + /// + /// Returns `None` if no subbuffer is available. + /// + /// A `CpuBufferPool` is always empty the first time you use it, so you shouldn't use + /// `try_next` the first time you use it. + #[inline] + pub fn try_next(&self, data: T) -> Option<CpuBufferPoolSubbuffer<T, A>> { + let mut mutex = self.current_buffer.lock().unwrap(); + self.try_next_impl(&mut mutex, iter::once(data)) + .map(|c| CpuBufferPoolSubbuffer { chunk: c }) + .ok() + } + + // Creates a new buffer and sets it as current. The capacity is in number of elements. + // + // `cur_buf_mutex` must be an active lock of `self.current_buffer`. + fn reset_buf(&self, cur_buf_mutex: &mut MutexGuard<Option<Arc<ActualBuffer<A>>>>, + capacity: usize) + -> Result<(), DeviceMemoryAllocError> { + unsafe { + let (buffer, mem_reqs) = { + let size_bytes = match mem::size_of::<T>().checked_mul(capacity) { + Some(s) => s, + None => + return Err(DeviceMemoryAllocError::OomError(OomError::OutOfDeviceMemory)), + }; + + match UnsafeBuffer::new(self.device.clone(), + size_bytes, + self.usage, + Sharing::Exclusive::<iter::Empty<_>>, + SparseLevel::none()) { + Ok(b) => b, + Err(BufferCreationError::AllocError(err)) => return Err(err), + Err(_) => unreachable!(), // We don't use sparse binding, therefore the other + // errors can't happen + } + }; + + let mem = MemoryPool::alloc_from_requirements(&self.pool, + &mem_reqs, + AllocLayout::Linear, + MappingRequirement::Map, + DedicatedAlloc::Buffer(&buffer), + |_| AllocFromRequirementsFilter::Allowed)?; + debug_assert!((mem.offset() % mem_reqs.alignment) == 0); + debug_assert!(mem.mapped_memory().is_some()); + buffer.bind_memory(mem.memory(), mem.offset())?; + + **cur_buf_mutex = Some(Arc::new(ActualBuffer { + inner: buffer, + memory: mem, + chunks_in_use: Mutex::new(vec![]), + next_index: AtomicUsize::new(0), + capacity: capacity, + })); + + Ok(()) + } + } + + // Tries to lock a subbuffer from the current buffer. + // + // `cur_buf_mutex` must be an active lock of `self.current_buffer`. + // + // Returns `data` wrapped inside an `Err` if there is no slot available in the current buffer. + // + // # Panic + // + // Panics if the length of the iterator didn't match the actual number of element. + // + fn try_next_impl<I>(&self, cur_buf_mutex: &mut MutexGuard<Option<Arc<ActualBuffer<A>>>>, + mut data: I) + -> Result<CpuBufferPoolChunk<T, A>, I> + where I: ExactSizeIterator<Item = T> + { + // Grab the current buffer. Return `Err` if the pool wasn't "initialized" yet. + let current_buffer = match cur_buf_mutex.clone() { + Some(b) => b, + None => return Err(data), + }; + + let mut chunks_in_use = current_buffer.chunks_in_use.lock().unwrap(); + debug_assert!(!chunks_in_use.iter().any(|c| c.len == 0)); + + // Number of elements requested by the user. + let requested_len = data.len(); + + // We special case when 0 elements are requested. Polluting the list of allocated chunks + // with chunks of length 0 means that we will have troubles deallocating. + if requested_len == 0 { + assert!(data.next().is_none(), + "Expected iterator passed to CpuBufferPool::chunk to be empty"); + return Ok(CpuBufferPoolChunk { + // TODO: remove .clone() once non-lexical borrows land + buffer: current_buffer.clone(), + index: 0, + align_offset: 0, + requested_len: 0, + marker: PhantomData, + }); + } + + // Find a suitable offset and len, or returns if none available. + let (index, occupied_len, align_offset) = { + let (tentative_index, tentative_len, tentative_align_offset) = { + // Since the only place that touches `next_index` is this code, and since we + // own a mutex lock to the buffer, it means that `next_index` can't be accessed + // concurrently. + // TODO: ^ eventually should be put inside the mutex + let idx = current_buffer.next_index.load(Ordering::SeqCst); + + // Find the required alignment in bytes. + let align_bytes = cmp::max(if self.usage.uniform_buffer { + self.device() + .physical_device() + .limits() + .min_uniform_buffer_offset_alignment() as + usize + } else { + 1 + }, + if self.usage.storage_buffer { + self.device() + .physical_device() + .limits() + .min_storage_buffer_offset_alignment() as + usize + } else { + 1 + }); + + let tentative_align_offset = + (align_bytes - ((idx * mem::size_of::<T>()) % align_bytes)) % align_bytes; + let additional_len = if tentative_align_offset == 0 { + 0 + } else { + 1 + (tentative_align_offset - 1) / mem::size_of::<T>() + }; + + (idx, requested_len + additional_len, tentative_align_offset) + }; + + // Find out whether any chunk in use overlaps this range. + if tentative_index + tentative_len <= current_buffer.capacity && + !chunks_in_use.iter().any(|c| { + (c.index >= tentative_index && + c.index < tentative_index + tentative_len) || + (c.index <= tentative_index && + c.index + c.len > tentative_index) + }) + { + (tentative_index, tentative_len, tentative_align_offset) + } else { + // Impossible to allocate at `tentative_index`. Let's try 0 instead. + if requested_len <= current_buffer.capacity && + !chunks_in_use.iter().any(|c| c.index < requested_len) + { + (0, requested_len, 0) + } else { + // Buffer is full. Return. + return Err(data); + } + } + }; + + // Write `data` in the memory. + unsafe { + let mem_off = current_buffer.memory.offset(); + let range_start = index * mem::size_of::<T>() + align_offset + mem_off; + let range_end = (index + requested_len) * mem::size_of::<T>() + align_offset + mem_off; + let mut mapping = current_buffer + .memory + .mapped_memory() + .unwrap() + .read_write::<[T]>(range_start .. range_end); + + let mut written = 0; + for (o, i) in mapping.iter_mut().zip(data) { + ptr::write(o, i); + written += 1; + } + assert_eq!(written, + requested_len, + "Iterator passed to CpuBufferPool::chunk has a mismatch between reported \ + length and actual number of elements"); + } + + // Mark the chunk as in use. + current_buffer + .next_index + .store(index + occupied_len, Ordering::SeqCst); + chunks_in_use.push(ActualBufferChunk { + index, + len: occupied_len, + num_cpu_accesses: 1, + num_gpu_accesses: 0, + }); + + Ok(CpuBufferPoolChunk { + // TODO: remove .clone() once non-lexical borrows land + buffer: current_buffer.clone(), + index: index, + align_offset, + requested_len, + marker: PhantomData, + }) + } +} + +// Can't automatically derive `Clone`, otherwise the compiler adds a `T: Clone` requirement. +impl<T, A> Clone for CpuBufferPool<T, A> + where A: MemoryPool + Clone +{ + fn clone(&self) -> Self { + let buf = self.current_buffer.lock().unwrap(); + + CpuBufferPool { + device: self.device.clone(), + pool: self.pool.clone(), + current_buffer: Mutex::new(buf.clone()), + usage: self.usage.clone(), + marker: PhantomData, + } + } +} + +unsafe impl<T, A> DeviceOwned for CpuBufferPool<T, A> + where A: MemoryPool +{ + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl<T, A> Clone for CpuBufferPoolChunk<T, A> + where A: MemoryPool +{ + fn clone(&self) -> CpuBufferPoolChunk<T, A> { + let mut chunks_in_use_lock = self.buffer.chunks_in_use.lock().unwrap(); + let chunk = chunks_in_use_lock + .iter_mut() + .find(|c| c.index == self.index) + .unwrap(); + + debug_assert!(chunk.num_cpu_accesses >= 1); + chunk.num_cpu_accesses = chunk + .num_cpu_accesses + .checked_add(1) + .expect("Overflow in CPU accesses"); + + CpuBufferPoolChunk { + buffer: self.buffer.clone(), + index: self.index, + align_offset: self.align_offset, + requested_len: self.requested_len, + marker: PhantomData, + } + } +} + +unsafe impl<T, A> BufferAccess for CpuBufferPoolChunk<T, A> + where A: MemoryPool +{ + #[inline] + fn inner(&self) -> BufferInner { + BufferInner { + buffer: &self.buffer.inner, + offset: self.index * mem::size_of::<T>() + self.align_offset, + } + } + + #[inline] + fn size(&self) -> usize { + self.requested_len * mem::size_of::<T>() + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + self.conflict_key() == other.conflict_key() // TODO: + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + false + } + + #[inline] + fn conflict_key(&self) -> (u64, usize) { + ( + self.buffer.inner.key(), + // ensure the special cased empty buffers don't collide with a regular buffer starting at 0 + if self.requested_len == 0 { usize::max_value() } else { self.index } + ) + } + + #[inline] + fn try_gpu_lock(&self, _: bool, _: &Queue) -> Result<(), AccessError> { + if self.requested_len == 0 { + return Ok(()); + } + + let mut chunks_in_use_lock = self.buffer.chunks_in_use.lock().unwrap(); + let chunk = chunks_in_use_lock + .iter_mut() + .find(|c| c.index == self.index) + .unwrap(); + + if chunk.num_gpu_accesses != 0 { + return Err(AccessError::AlreadyInUse); + } + + chunk.num_gpu_accesses = 1; + Ok(()) + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + if self.requested_len == 0 { + return; + } + + let mut chunks_in_use_lock = self.buffer.chunks_in_use.lock().unwrap(); + let chunk = chunks_in_use_lock + .iter_mut() + .find(|c| c.index == self.index) + .unwrap(); + + debug_assert!(chunk.num_gpu_accesses >= 1); + chunk.num_gpu_accesses = chunk + .num_gpu_accesses + .checked_add(1) + .expect("Overflow in GPU usages"); + } + + #[inline] + unsafe fn unlock(&self) { + if self.requested_len == 0 { + return; + } + + let mut chunks_in_use_lock = self.buffer.chunks_in_use.lock().unwrap(); + let chunk = chunks_in_use_lock + .iter_mut() + .find(|c| c.index == self.index) + .unwrap(); + + debug_assert!(chunk.num_gpu_accesses >= 1); + chunk.num_gpu_accesses -= 1; + } +} + +impl<T, A> Drop for CpuBufferPoolChunk<T, A> + where A: MemoryPool +{ + fn drop(&mut self) { + // If `requested_len` is 0, then no entry was added in the chunks. + if self.requested_len == 0 { + return; + } + + let mut chunks_in_use_lock = self.buffer.chunks_in_use.lock().unwrap(); + let chunk_num = chunks_in_use_lock + .iter_mut() + .position(|c| c.index == self.index) + .unwrap(); + + if chunks_in_use_lock[chunk_num].num_cpu_accesses >= 2 { + chunks_in_use_lock[chunk_num].num_cpu_accesses -= 1; + } else { + debug_assert_eq!(chunks_in_use_lock[chunk_num].num_gpu_accesses, 0); + chunks_in_use_lock.remove(chunk_num); + } + } +} + +unsafe impl<T, A> TypedBufferAccess for CpuBufferPoolChunk<T, A> + where A: MemoryPool +{ + type Content = [T]; +} + +unsafe impl<T, A> DeviceOwned for CpuBufferPoolChunk<T, A> + where A: MemoryPool +{ + #[inline] + fn device(&self) -> &Arc<Device> { + self.buffer.inner.device() + } +} + +impl<T, A> Clone for CpuBufferPoolSubbuffer<T, A> + where A: MemoryPool +{ + fn clone(&self) -> CpuBufferPoolSubbuffer<T, A> { + CpuBufferPoolSubbuffer { chunk: self.chunk.clone() } + } +} + +unsafe impl<T, A> BufferAccess for CpuBufferPoolSubbuffer<T, A> + where A: MemoryPool +{ + #[inline] + fn inner(&self) -> BufferInner { + self.chunk.inner() + } + + #[inline] + fn size(&self) -> usize { + self.chunk.size() + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + self.conflict_key() == other.conflict_key() // TODO: + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + false + } + + #[inline] + fn conflict_key(&self) -> (u64, usize) { + self.chunk.conflict_key() + } + + #[inline] + fn try_gpu_lock(&self, e: bool, q: &Queue) -> Result<(), AccessError> { + self.chunk.try_gpu_lock(e, q) + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + self.chunk.increase_gpu_lock() + } + + #[inline] + unsafe fn unlock(&self) { + self.chunk.unlock() + } +} + +unsafe impl<T, A> TypedBufferAccess for CpuBufferPoolSubbuffer<T, A> + where A: MemoryPool +{ + type Content = T; +} + +unsafe impl<T, A> DeviceOwned for CpuBufferPoolSubbuffer<T, A> + where A: MemoryPool +{ + #[inline] + fn device(&self) -> &Arc<Device> { + self.chunk.buffer.inner.device() + } +} + +#[cfg(test)] +mod tests { + use buffer::CpuBufferPool; + use std::mem; + + #[test] + fn basic_create() { + let (device, _) = gfx_dev_and_queue!(); + let _ = CpuBufferPool::<u8>::upload(device); + } + + #[test] + fn reserve() { + let (device, _) = gfx_dev_and_queue!(); + + let pool = CpuBufferPool::<u8>::upload(device); + assert_eq!(pool.capacity(), 0); + + pool.reserve(83).unwrap(); + assert_eq!(pool.capacity(), 83); + } + + #[test] + fn capacity_increase() { + let (device, _) = gfx_dev_and_queue!(); + + let pool = CpuBufferPool::upload(device); + assert_eq!(pool.capacity(), 0); + + pool.next(12).unwrap(); + let first_cap = pool.capacity(); + assert!(first_cap >= 1); + + for _ in 0 .. first_cap + 5 { + mem::forget(pool.next(12).unwrap()); + } + + assert!(pool.capacity() > first_cap); + } + + #[test] + fn reuse_subbuffers() { + let (device, _) = gfx_dev_and_queue!(); + + let pool = CpuBufferPool::upload(device); + assert_eq!(pool.capacity(), 0); + + let mut capacity = None; + for _ in 0 .. 64 { + pool.next(12).unwrap(); + + let new_cap = pool.capacity(); + assert!(new_cap >= 1); + match capacity { + None => capacity = Some(new_cap), + Some(c) => assert_eq!(c, new_cap), + } + } + } + + #[test] + fn chunk_loopback() { + let (device, _) = gfx_dev_and_queue!(); + + let pool = CpuBufferPool::<u8>::upload(device); + pool.reserve(5).unwrap(); + + let a = pool.chunk(vec![0, 0]).unwrap(); + let b = pool.chunk(vec![0, 0]).unwrap(); + assert_eq!(b.index, 2); + drop(a); + + let c = pool.chunk(vec![0, 0]).unwrap(); + assert_eq!(c.index, 0); + + assert_eq!(pool.capacity(), 5); + } + + #[test] + fn chunk_0_elems_doesnt_pollute() { + let (device, _) = gfx_dev_and_queue!(); + + let pool = CpuBufferPool::<u8>::upload(device); + + let _ = pool.chunk(vec![]).unwrap(); + let _ = pool.chunk(vec![0, 0]).unwrap(); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/device_local.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/device_local.rs new file mode 100644 index 0000000..f1719a5 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/device_local.rs @@ -0,0 +1,286 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Buffer whose content is read-written by the GPU only. +//! +//! Each access from the CPU or from the GPU locks the whole buffer for either reading or writing. +//! You can read the buffer multiple times simultaneously from multiple queues. Trying to read and +//! write simultaneously, or write and write simultaneously will block with a semaphore. + +use smallvec::SmallVec; +use std::marker::PhantomData; +use std::mem; +use std::sync::Arc; +use std::sync::Mutex; + +use buffer::BufferUsage; +use buffer::sys::BufferCreationError; +use buffer::sys::SparseLevel; +use buffer::sys::UnsafeBuffer; +use buffer::traits::BufferAccess; +use buffer::traits::BufferInner; +use buffer::traits::TypedBufferAccess; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use instance::QueueFamily; +use memory::DedicatedAlloc; +use memory::DeviceMemoryAllocError; +use memory::pool::AllocFromRequirementsFilter; +use memory::pool::AllocLayout; +use memory::pool::MappingRequirement; +use memory::pool::MemoryPool; +use memory::pool::MemoryPoolAlloc; +use memory::pool::PotentialDedicatedAllocation; +use memory::pool::StdMemoryPoolAlloc; +use sync::AccessError; +use sync::Sharing; + +/// Buffer whose content is in device-local memory. +/// +/// This buffer type is useful in order to store intermediary data. For example you execute a +/// compute shader that writes to this buffer, then read the content of the buffer in a following +/// compute or graphics pipeline. +/// +/// The `DeviceLocalBuffer` will be in device-local memory, unless the device doesn't provide any +/// device-local memory. +#[derive(Debug)] +pub struct DeviceLocalBuffer<T: ?Sized, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { + // Inner content. + inner: UnsafeBuffer, + + // The memory held by the buffer. + memory: A, + + // Queue families allowed to access this buffer. + queue_families: SmallVec<[u32; 4]>, + + // Number of times this buffer is locked on the GPU side. + gpu_lock: Mutex<GpuAccess>, + + // Necessary to make it compile. + marker: PhantomData<Box<T>>, +} + +#[derive(Debug, Copy, Clone)] +enum GpuAccess { + None, + NonExclusive { num: u32 }, + Exclusive { num: u32 }, +} + +impl<T> DeviceLocalBuffer<T> { + /// Builds a new buffer. Only allowed for sized data. + // TODO: unsafe because uninitialized data + #[inline] + pub fn new<'a, I>(device: Arc<Device>, usage: BufferUsage, queue_families: I) + -> Result<Arc<DeviceLocalBuffer<T>>, DeviceMemoryAllocError> + where I: IntoIterator<Item = QueueFamily<'a>> + { + unsafe { DeviceLocalBuffer::raw(device, mem::size_of::<T>(), usage, queue_families) } + } +} + +impl<T> DeviceLocalBuffer<[T]> { + /// Builds a new buffer. Can be used for arrays. + // TODO: unsafe because uninitialized data + #[inline] + pub fn array<'a, I>(device: Arc<Device>, len: usize, usage: BufferUsage, queue_families: I) + -> Result<Arc<DeviceLocalBuffer<[T]>>, DeviceMemoryAllocError> + where I: IntoIterator<Item = QueueFamily<'a>> + { + unsafe { DeviceLocalBuffer::raw(device, len * mem::size_of::<T>(), usage, queue_families) } + } +} + +impl<T: ?Sized> DeviceLocalBuffer<T> { + /// Builds a new buffer without checking the size. + /// + /// # Safety + /// + /// You must ensure that the size that you pass is correct for `T`. + /// + pub unsafe fn raw<'a, I>(device: Arc<Device>, size: usize, usage: BufferUsage, + queue_families: I) + -> Result<Arc<DeviceLocalBuffer<T>>, DeviceMemoryAllocError> + where I: IntoIterator<Item = QueueFamily<'a>> + { + let queue_families = queue_families + .into_iter() + .map(|f| f.id()) + .collect::<SmallVec<[u32; 4]>>(); + + let (buffer, mem_reqs) = { + let sharing = if queue_families.len() >= 2 { + Sharing::Concurrent(queue_families.iter().cloned()) + } else { + Sharing::Exclusive + }; + + match UnsafeBuffer::new(device.clone(), size, usage, sharing, SparseLevel::none()) { + Ok(b) => b, + Err(BufferCreationError::AllocError(err)) => return Err(err), + Err(_) => unreachable!(), // We don't use sparse binding, therefore the other + // errors can't happen + } + }; + + let mem = MemoryPool::alloc_from_requirements(&Device::standard_pool(&device), + &mem_reqs, + AllocLayout::Linear, + MappingRequirement::DoNotMap, + DedicatedAlloc::Buffer(&buffer), + |t| if t.is_device_local() { + AllocFromRequirementsFilter::Preferred + } else { + AllocFromRequirementsFilter::Allowed + })?; + debug_assert!((mem.offset() % mem_reqs.alignment) == 0); + buffer.bind_memory(mem.memory(), mem.offset())?; + + Ok(Arc::new(DeviceLocalBuffer { + inner: buffer, + memory: mem, + queue_families: queue_families, + gpu_lock: Mutex::new(GpuAccess::None), + marker: PhantomData, + })) + } +} + +impl<T: ?Sized, A> DeviceLocalBuffer<T, A> { + /// Returns the queue families this buffer can be used on. + // TODO: use a custom iterator + #[inline] + pub fn queue_families(&self) -> Vec<QueueFamily> { + self.queue_families + .iter() + .map(|&num| { + self.device() + .physical_device() + .queue_family_by_id(num) + .unwrap() + }) + .collect() + } +} + +unsafe impl<T: ?Sized, A> DeviceOwned for DeviceLocalBuffer<T, A> { + #[inline] + fn device(&self) -> &Arc<Device> { + self.inner.device() + } +} + +unsafe impl<T: ?Sized, A> BufferAccess for DeviceLocalBuffer<T, A> + where T: 'static + Send + Sync +{ + #[inline] + fn inner(&self) -> BufferInner { + BufferInner { + buffer: &self.inner, + offset: 0, + } + } + + #[inline] + fn size(&self) -> usize { + self.inner.size() + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + self.conflict_key() == other.conflict_key() // TODO: + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + false + } + + #[inline] + fn conflict_key(&self) -> (u64, usize) { + (self.inner.key(), 0) + } + + #[inline] + fn try_gpu_lock(&self, exclusive: bool, _: &Queue) -> Result<(), AccessError> { + let mut lock = self.gpu_lock.lock().unwrap(); + match &mut *lock { + a @ &mut GpuAccess::None => { + if exclusive { + *a = GpuAccess::Exclusive { num: 1 }; + } else { + *a = GpuAccess::NonExclusive { num: 1 }; + } + + Ok(()) + }, + &mut GpuAccess::NonExclusive { ref mut num } => { + if exclusive { + Err(AccessError::AlreadyInUse) + } else { + *num += 1; + Ok(()) + } + }, + &mut GpuAccess::Exclusive { .. } => { + Err(AccessError::AlreadyInUse) + }, + } + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + let mut lock = self.gpu_lock.lock().unwrap(); + match *lock { + GpuAccess::None => panic!(), + GpuAccess::NonExclusive { ref mut num } => { + debug_assert!(*num >= 1); + *num += 1; + }, + GpuAccess::Exclusive { ref mut num } => { + debug_assert!(*num >= 1); + *num += 1; + }, + } + } + + #[inline] + unsafe fn unlock(&self) { + let mut lock = self.gpu_lock.lock().unwrap(); + + match *lock { + GpuAccess::None => panic!("Tried to unlock a buffer that isn't locked"), + GpuAccess::NonExclusive { ref mut num } => { + assert!(*num >= 1); + *num -= 1; + if *num >= 1 { + return; + } + }, + GpuAccess::Exclusive { ref mut num } => { + assert!(*num >= 1); + *num -= 1; + if *num >= 1 { + return; + } + }, + }; + + *lock = GpuAccess::None; + } +} + +unsafe impl<T: ?Sized, A> TypedBufferAccess for DeviceLocalBuffer<T, A> + where T: 'static + Send + Sync +{ + type Content = T; +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/immutable.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/immutable.rs new file mode 100644 index 0000000..2b5c4ac --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/immutable.rs @@ -0,0 +1,636 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Buffer that is written once then read for as long as it is alive. +//! +//! Use this buffer when you have data that you never modify. +//! +//! Only the first ever command buffer that uses this buffer can write to it (for example by +//! copying from another buffer). Any subsequent command buffer **must** only read from the buffer, +//! or a panic will happen. +//! +//! The buffer will be stored in device-local memory if possible +//! + +use smallvec::SmallVec; +use std::marker::PhantomData; +use std::mem; +use std::sync::Arc; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; + +use buffer::BufferUsage; +use buffer::CpuAccessibleBuffer; +use buffer::sys::BufferCreationError; +use buffer::sys::SparseLevel; +use buffer::sys::UnsafeBuffer; +use buffer::traits::BufferAccess; +use buffer::traits::BufferInner; +use buffer::traits::TypedBufferAccess; +use command_buffer::AutoCommandBuffer; +use command_buffer::AutoCommandBufferBuilder; +use command_buffer::CommandBuffer; +use command_buffer::CommandBufferExecFuture; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use instance::QueueFamily; +use memory::DedicatedAlloc; +use memory::DeviceMemoryAllocError; +use memory::pool::AllocFromRequirementsFilter; +use memory::pool::AllocLayout; +use memory::pool::MappingRequirement; +use memory::pool::MemoryPool; +use memory::pool::MemoryPoolAlloc; +use memory::pool::PotentialDedicatedAllocation; +use memory::pool::StdMemoryPoolAlloc; +use sync::AccessError; +use sync::NowFuture; +use sync::Sharing; + +/// Buffer that is written once then read for as long as it is alive. +// TODO: implement Debug +pub struct ImmutableBuffer<T: ?Sized, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { + // Inner content. + inner: UnsafeBuffer, + + // Memory allocated for the buffer. + memory: A, + + // True if the `ImmutableBufferInitialization` object was used by the GPU then dropped. + // This means that the `ImmutableBuffer` can be used as much as we want without any restriction. + initialized: AtomicBool, + + // Queue families allowed to access this buffer. + queue_families: SmallVec<[u32; 4]>, + + // Necessary to have the appropriate template parameter. + marker: PhantomData<Box<T>>, +} + +// TODO: make this prettier +type ImmutableBufferFromBufferFuture = CommandBufferExecFuture<NowFuture, AutoCommandBuffer>; + +impl<T: ?Sized> ImmutableBuffer<T> { + /// Builds an `ImmutableBuffer` from some data. + /// + /// This function builds a memory-mapped intermediate buffer, writes the data to it, builds a + /// command buffer that copies from this intermediate buffer to the final buffer, and finally + /// submits the command buffer as a future. + /// + /// This function returns two objects: the newly-created buffer, and a future representing + /// the initial upload operation. In order to be allowed to use the `ImmutableBuffer`, you must + /// either submit your operation after this future, or execute this future and wait for it to + /// be finished before submitting your own operation. + pub fn from_data( + data: T, usage: BufferUsage, queue: Arc<Queue>) + -> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferFromBufferFuture), + DeviceMemoryAllocError> + where T: 'static + Send + Sync + Sized + { + let source = CpuAccessibleBuffer::from_data(queue.device().clone(), + BufferUsage::transfer_source(), + data)?; + ImmutableBuffer::from_buffer(source, usage, queue) + } + + /// Builds an `ImmutableBuffer` that copies its data from another buffer. + /// + /// This function returns two objects: the newly-created buffer, and a future representing + /// the initial upload operation. In order to be allowed to use the `ImmutableBuffer`, you must + /// either submit your operation after this future, or execute this future and wait for it to + /// be finished before submitting your own operation. + pub fn from_buffer<B>( + source: B, usage: BufferUsage, queue: Arc<Queue>) + -> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferFromBufferFuture), + DeviceMemoryAllocError> + where B: BufferAccess + TypedBufferAccess<Content = T> + 'static + Clone + Send + Sync, + T: 'static + Send + Sync + { + unsafe { + // We automatically set `transfer_destination` to true in order to avoid annoying errors. + let actual_usage = BufferUsage { + transfer_destination: true, + ..usage + }; + + let (buffer, init) = ImmutableBuffer::raw(source.device().clone(), + source.size(), + actual_usage, + source.device().active_queue_families())?; + + let cb = AutoCommandBufferBuilder::new(source.device().clone(), + queue.family())? + .copy_buffer(source, init).unwrap() // TODO: return error? + .build().unwrap(); // TODO: return OomError + + let future = match cb.execute(queue) { + Ok(f) => f, + Err(_) => unreachable!(), + }; + + Ok((buffer, future)) + } + } +} + +impl<T> ImmutableBuffer<T> { + /// Builds a new buffer with uninitialized data. Only allowed for sized data. + /// + /// Returns two things: the buffer, and a special access that should be used for the initial + /// upload to the buffer. + /// + /// You will get an error if you try to use the buffer before using the initial upload access. + /// However this function doesn't check whether you actually used this initial upload to fill + /// the buffer like you're supposed to do. + /// + /// You will also get an error if you try to get exclusive access to the final buffer. + /// + /// # Safety + /// + /// - The `ImmutableBufferInitialization` should be used to fill the buffer with some initial + /// data, otherwise the content is undefined. + /// + #[inline] + pub unsafe fn uninitialized( + device: Arc<Device>, usage: BufferUsage) + -> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferInitialization<T>), + DeviceMemoryAllocError> { + ImmutableBuffer::raw(device.clone(), + mem::size_of::<T>(), + usage, + device.active_queue_families()) + } +} + +impl<T> ImmutableBuffer<[T]> { + pub fn from_iter<D>( + data: D, usage: BufferUsage, queue: Arc<Queue>) + -> Result<(Arc<ImmutableBuffer<[T]>>, ImmutableBufferFromBufferFuture), + DeviceMemoryAllocError> + where D: ExactSizeIterator<Item = T>, + T: 'static + Send + Sync + Sized + { + let source = CpuAccessibleBuffer::from_iter(queue.device().clone(), + BufferUsage::transfer_source(), + data)?; + ImmutableBuffer::from_buffer(source, usage, queue) + } + + /// Builds a new buffer with uninitialized data. Can be used for arrays. + /// + /// Returns two things: the buffer, and a special access that should be used for the initial + /// upload to the buffer. + /// + /// You will get an error if you try to use the buffer before using the initial upload access. + /// However this function doesn't check whether you actually used this initial upload to fill + /// the buffer like you're supposed to do. + /// + /// You will also get an error if you try to get exclusive access to the final buffer. + /// + /// # Safety + /// + /// - The `ImmutableBufferInitialization` should be used to fill the buffer with some initial + /// data, otherwise the content is undefined. + /// + #[inline] + pub unsafe fn uninitialized_array(device: Arc<Device>, len: usize, usage: BufferUsage) + -> Result<(Arc<ImmutableBuffer<[T]>>, + ImmutableBufferInitialization<[T]>), + DeviceMemoryAllocError> { + ImmutableBuffer::raw(device.clone(), + len * mem::size_of::<T>(), + usage, + device.active_queue_families()) + } +} + +impl<T: ?Sized> ImmutableBuffer<T> { + /// Builds a new buffer without checking the size and granting free access for the initial + /// upload. + /// + /// Returns two things: the buffer, and a special access that should be used for the initial + /// upload to the buffer. + /// You will get an error if you try to use the buffer before using the initial upload access. + /// However this function doesn't check whether you used this initial upload to fill the buffer. + /// You will also get an error if you try to get exclusive access to the final buffer. + /// + /// # Safety + /// + /// - You must ensure that the size that you pass is correct for `T`. + /// - The `ImmutableBufferInitialization` should be used to fill the buffer with some initial + /// data. + /// + #[inline] + pub unsafe fn raw<'a, I>( + device: Arc<Device>, size: usize, usage: BufferUsage, queue_families: I) + -> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferInitialization<T>), + DeviceMemoryAllocError> + where I: IntoIterator<Item = QueueFamily<'a>> + { + let queue_families = queue_families.into_iter().map(|f| f.id()).collect(); + ImmutableBuffer::raw_impl(device, size, usage, queue_families) + } + + // Internal implementation of `raw`. This is separated from `raw` so that it doesn't need to be + // inlined. + unsafe fn raw_impl( + device: Arc<Device>, size: usize, usage: BufferUsage, queue_families: SmallVec<[u32; 4]>) + -> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferInitialization<T>), + DeviceMemoryAllocError> { + let (buffer, mem_reqs) = { + let sharing = if queue_families.len() >= 2 { + Sharing::Concurrent(queue_families.iter().cloned()) + } else { + Sharing::Exclusive + }; + + match UnsafeBuffer::new(device.clone(), size, usage, sharing, SparseLevel::none()) { + Ok(b) => b, + Err(BufferCreationError::AllocError(err)) => return Err(err), + Err(_) => unreachable!(), // We don't use sparse binding, therefore the other + // errors can't happen + } + }; + + let mem = MemoryPool::alloc_from_requirements(&Device::standard_pool(&device), + &mem_reqs, + AllocLayout::Linear, + MappingRequirement::DoNotMap, + DedicatedAlloc::Buffer(&buffer), + |t| if t.is_device_local() { + AllocFromRequirementsFilter::Preferred + } else { + AllocFromRequirementsFilter::Allowed + })?; + debug_assert!((mem.offset() % mem_reqs.alignment) == 0); + buffer.bind_memory(mem.memory(), mem.offset())?; + + let final_buf = Arc::new(ImmutableBuffer { + inner: buffer, + memory: mem, + queue_families: queue_families, + initialized: AtomicBool::new(false), + marker: PhantomData, + }); + + let initialization = ImmutableBufferInitialization { + buffer: final_buf.clone(), + used: Arc::new(AtomicBool::new(false)), + }; + + Ok((final_buf, initialization)) + } +} + +impl<T: ?Sized, A> ImmutableBuffer<T, A> { + /// Returns the device used to create this buffer. + #[inline] + pub fn device(&self) -> &Arc<Device> { + self.inner.device() + } + + /// Returns the queue families this buffer can be used on. + // TODO: use a custom iterator + #[inline] + pub fn queue_families(&self) -> Vec<QueueFamily> { + self.queue_families + .iter() + .map(|&num| { + self.device() + .physical_device() + .queue_family_by_id(num) + .unwrap() + }) + .collect() + } +} + +unsafe impl<T: ?Sized, A> BufferAccess for ImmutableBuffer<T, A> { + #[inline] + fn inner(&self) -> BufferInner { + BufferInner { + buffer: &self.inner, + offset: 0, + } + } + + #[inline] + fn size(&self) -> usize { + self.inner.size() + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + self.conflict_key() == other.conflict_key() // TODO: + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + false + } + + #[inline] + fn conflict_key(&self) -> (u64, usize) { + (self.inner.key(), 0) + } + + #[inline] + fn try_gpu_lock(&self, exclusive_access: bool, _: &Queue) -> Result<(), AccessError> { + if exclusive_access { + return Err(AccessError::ExclusiveDenied); + } + + if !self.initialized.load(Ordering::Relaxed) { + return Err(AccessError::BufferNotInitialized); + } + + Ok(()) + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + } + + #[inline] + unsafe fn unlock(&self) { + } +} + +unsafe impl<T: ?Sized, A> TypedBufferAccess for ImmutableBuffer<T, A> { + type Content = T; +} + +unsafe impl<T: ?Sized, A> DeviceOwned for ImmutableBuffer<T, A> { + #[inline] + fn device(&self) -> &Arc<Device> { + self.inner.device() + } +} + +/// Access to the immutable buffer that can be used for the initial upload. +//#[derive(Debug)] // TODO: +pub struct ImmutableBufferInitialization<T: ?Sized, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { + buffer: Arc<ImmutableBuffer<T, A>>, + used: Arc<AtomicBool>, +} + +unsafe impl<T: ?Sized, A> BufferAccess for ImmutableBufferInitialization<T, A> { + #[inline] + fn inner(&self) -> BufferInner { + self.buffer.inner() + } + + #[inline] + fn size(&self) -> usize { + self.buffer.size() + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + self.conflict_key() == other.conflict_key() // TODO: + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + false + } + + #[inline] + fn conflict_key(&self) -> (u64, usize) { + (self.buffer.inner.key(), 0) + } + + #[inline] + fn try_gpu_lock(&self, _: bool, _: &Queue) -> Result<(), AccessError> { + if self.buffer.initialized.load(Ordering::Relaxed) { + return Err(AccessError::AlreadyInUse); + } + + if !self.used.compare_and_swap(false, true, Ordering::Relaxed) { + Ok(()) + } else { + Err(AccessError::AlreadyInUse) + } + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + debug_assert!(self.used.load(Ordering::Relaxed)); + } + + #[inline] + unsafe fn unlock(&self) { + self.buffer.initialized.store(true, Ordering::Relaxed); + } +} + +unsafe impl<T: ?Sized, A> TypedBufferAccess for ImmutableBufferInitialization<T, A> { + type Content = T; +} + +unsafe impl<T: ?Sized, A> DeviceOwned for ImmutableBufferInitialization<T, A> { + #[inline] + fn device(&self) -> &Arc<Device> { + self.buffer.inner.device() + } +} + +impl<T: ?Sized, A> Clone for ImmutableBufferInitialization<T, A> { + #[inline] + fn clone(&self) -> ImmutableBufferInitialization<T, A> { + ImmutableBufferInitialization { + buffer: self.buffer.clone(), + used: self.used.clone(), + } + } +} + +#[cfg(test)] +mod tests { + use buffer::BufferUsage; + use buffer::cpu_access::CpuAccessibleBuffer; + use buffer::immutable::ImmutableBuffer; + use command_buffer::AutoCommandBufferBuilder; + use command_buffer::CommandBuffer; + use sync::GpuFuture; + + #[test] + fn from_data_working() { + let (device, queue) = gfx_dev_and_queue!(); + + let (buffer, _) = ImmutableBuffer::from_data(12u32, BufferUsage::all(), queue.clone()) + .unwrap(); + + let destination = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), 0) + .unwrap(); + + let _ = AutoCommandBufferBuilder::new(device.clone(), queue.family()) + .unwrap() + .copy_buffer(buffer, destination.clone()) + .unwrap() + .build() + .unwrap() + .execute(queue.clone()) + .unwrap() + .then_signal_fence_and_flush() + .unwrap(); + + let destination_content = destination.read().unwrap(); + assert_eq!(*destination_content, 12); + } + + #[test] + fn from_iter_working() { + let (device, queue) = gfx_dev_and_queue!(); + + let (buffer, _) = ImmutableBuffer::from_iter((0 .. 512u32).map(|n| n * 2), + BufferUsage::all(), + queue.clone()) + .unwrap(); + + let destination = CpuAccessibleBuffer::from_iter(device.clone(), + BufferUsage::all(), + (0 .. 512).map(|_| 0u32)) + .unwrap(); + + let _ = AutoCommandBufferBuilder::new(device.clone(), queue.family()) + .unwrap() + .copy_buffer(buffer, destination.clone()) + .unwrap() + .build() + .unwrap() + .execute(queue.clone()) + .unwrap() + .then_signal_fence_and_flush() + .unwrap(); + + let destination_content = destination.read().unwrap(); + for (n, &v) in destination_content.iter().enumerate() { + assert_eq!(n * 2, v as usize); + } + } + + #[test] + fn writing_forbidden() { + let (device, queue) = gfx_dev_and_queue!(); + + let (buffer, _) = ImmutableBuffer::from_data(12u32, BufferUsage::all(), queue.clone()) + .unwrap(); + + assert_should_panic!({ + // TODO: check Result error instead of panicking + let _ = AutoCommandBufferBuilder::new(device.clone(), + queue.family()) + .unwrap() + .fill_buffer(buffer, 50) + .unwrap() + .build() + .unwrap() + .execute(queue.clone()) + .unwrap() + .then_signal_fence_and_flush() + .unwrap(); + }); + } + + #[test] + fn read_uninitialized_forbidden() { + let (device, queue) = gfx_dev_and_queue!(); + + let (buffer, _) = unsafe { + ImmutableBuffer::<u32>::uninitialized(device.clone(), BufferUsage::all()).unwrap() + }; + + let source = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), 0).unwrap(); + + assert_should_panic!({ + // TODO: check Result error instead of panicking + let _ = AutoCommandBufferBuilder::new(device.clone(), + queue.family()) + .unwrap() + .copy_buffer(source, buffer) + .unwrap() + .build() + .unwrap() + .execute(queue.clone()) + .unwrap() + .then_signal_fence_and_flush() + .unwrap(); + }); + } + + #[test] + fn init_then_read_same_cb() { + let (device, queue) = gfx_dev_and_queue!(); + + let (buffer, init) = unsafe { + ImmutableBuffer::<u32>::uninitialized(device.clone(), BufferUsage::all()).unwrap() + }; + + let source = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), 0).unwrap(); + + let _ = AutoCommandBufferBuilder::new(device.clone(), queue.family()) + .unwrap() + .copy_buffer(source.clone(), init) + .unwrap() + .copy_buffer(buffer, source.clone()) + .unwrap() + .build() + .unwrap() + .execute(queue.clone()) + .unwrap() + .then_signal_fence_and_flush() + .unwrap(); + } + + #[test] + #[ignore] // TODO: doesn't work because the submit sync layer isn't properly implemented + fn init_then_read_same_future() { + let (device, queue) = gfx_dev_and_queue!(); + + let (buffer, init) = unsafe { + ImmutableBuffer::<u32>::uninitialized(device.clone(), BufferUsage::all()).unwrap() + }; + + let source = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), 0).unwrap(); + + let cb1 = AutoCommandBufferBuilder::new(device.clone(), queue.family()) + .unwrap() + .copy_buffer(source.clone(), init) + .unwrap() + .build() + .unwrap(); + + let cb2 = AutoCommandBufferBuilder::new(device.clone(), queue.family()) + .unwrap() + .copy_buffer(buffer, source.clone()) + .unwrap() + .build() + .unwrap(); + + let _ = cb1.execute(queue.clone()) + .unwrap() + .then_execute(queue.clone(), cb2) + .unwrap() + .then_signal_fence_and_flush() + .unwrap(); + } + + #[test] + fn create_buffer_zero_size_data() { + let (device, queue) = gfx_dev_and_queue!(); + + let _ = ImmutableBuffer::from_data((), BufferUsage::all(), queue.clone()); + } + + // TODO: write tons of tests that try to exploit loopholes + // this isn't possible yet because checks aren't correctly implemented yet +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/mod.rs new file mode 100644 index 0000000..a336f15 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/mod.rs @@ -0,0 +1,102 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Location in memory that contains data. +//! +//! A Vulkan buffer is very similar to a buffer that you would use in programming languages in +//! general, in the sense that it is a location in memory that contains data. The difference +//! between a Vulkan buffer and a regular buffer is that the content of a Vulkan buffer is +//! accessible from the GPU. +//! +//! # Various kinds of buffers +//! +//! The low level implementation of a buffer is [`UnsafeBuffer`](sys/struct.UnsafeBuffer.html). +//! This type makes it possible to use all the features that Vulkan is capable of, but as its name +//! tells it is unsafe to use. +//! +//! Instead you are encouraged to use one of the high-level wrappers that vulkano provides. Which +//! wrapper to use depends on the way you are going to use the buffer: +//! +//! - A [`DeviceLocalBuffer`](device_local/struct.DeviceLocalBuffer.html) designates a buffer +//! usually located in video memory and whose content can't be directly accessed by your +//! application. Accessing this buffer from the GPU is generally faster compared to accessing a +//! CPU-accessible buffer. +//! - An [`ImmutableBuffer`](immutable/struct.ImmutableBuffer.html) designates a buffer in video +//! memory and whose content can only be written at creation. Compared to `DeviceLocalBuffer`, +//! this buffer requires less CPU processing because we don't need to keep track of the reads +//! and writes. +//! - A [`CpuBufferPool`](cpu_pool/struct.CpuBufferPool.html) is a ring buffer that can be used to +//! transfer data between the CPU and the GPU at a high rate. +//! - A [`CpuAccessibleBuffer`](cpu_access/struct.CpuAccessibleBuffer.html) is a simple buffer that +//! can be used to prototype. It may be removed from vulkano in the far future. +//! +//! Here is a quick way to choose which buffer to use. Do you often need to read or write +//! the content of the buffer? If so, use a `CpuBufferPool`. Otherwise, do you need to be able to +//! modify the content of the buffer after its initialization? If so, use a `DeviceLocalBuffer`. +//! If no to both questions, use an `ImmutableBuffer`. +//! +//! When deciding how your buffer is going to be used, don't forget that sometimes the best +//! solution is to manipulate multiple buffers instead. For example if you need to update a buffer's +//! content only from time to time, it may be a good idea to simply recreate a new `ImmutableBuffer` +//! every time. +//! Another example: if a buffer is under constant access by the GPU but you need to +//! read its content on the CPU from time to time, it may be a good idea to use a +//! `DeviceLocalBuffer` as the main buffer and a `CpuBufferPool` for when you need to read it. +//! Then whenever you need to read the main buffer, ask the GPU to copy from the device-local +//! buffer to the CPU buffer pool, and read the CPU buffer pool instead. +//! +//! # Buffers usage +//! +//! When you create a buffer object, you have to specify its *usage*. In other words, you have to +//! specify the way it is going to be used. Trying to use a buffer in a way that wasn't specified +//! when you created it will result in a runtime error. +//! +//! You can use buffers for the following purposes: +//! +//! - Can contain arbitrary data that can be transferred from/to other buffers and images. +//! - Can be read and modified from a shader. +//! - Can be used as a source of vertices and indices. +//! - Can be used as a source of list of models for draw indirect commands. +//! +//! Accessing a buffer from a shader can be done in the following ways: +//! +//! - As a uniform buffer. Uniform buffers are read-only. +//! - As a storage buffer. Storage buffers can be read and written. +//! - As a uniform texel buffer. Contrary to a uniform buffer, the data is interpreted by the +//! GPU and can be for example normalized. +//! - As a storage texel buffer. Additionally, some data formats can be modified with atomic +//! operations. +//! +//! Using uniform/storage texel buffers requires creating a *buffer view*. See the `view` module +//! for how to create a buffer view. +//! + +pub use self::cpu_access::CpuAccessibleBuffer; +pub use self::cpu_pool::CpuBufferPool; +pub use self::device_local::DeviceLocalBuffer; +pub use self::immutable::ImmutableBuffer; +pub use self::slice::BufferSlice; +pub use self::sys::BufferCreationError; +pub use self::traits::BufferAccess; +pub use self::traits::BufferInner; +pub use self::traits::TypedBufferAccess; +pub use self::usage::BufferUsage; +pub use self::view::BufferView; +pub use self::view::BufferViewRef; + +pub mod cpu_access; +pub mod cpu_pool; +pub mod device_local; +pub mod immutable; +pub mod sys; +pub mod view; + +mod slice; +mod traits; +mod usage; diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/slice.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/slice.rs new file mode 100644 index 0000000..4d8983a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/slice.rs @@ -0,0 +1,295 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::marker::PhantomData; +use std::mem; +use std::ops::Range; +use std::sync::Arc; + +use buffer::traits::BufferAccess; +use buffer::traits::BufferInner; +use buffer::traits::TypedBufferAccess; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use sync::AccessError; + +/// A subpart of a buffer. +/// +/// This object doesn't correspond to any Vulkan object. It exists for API convenience. +/// +/// # Example +/// +/// Creating a slice: +/// +/// ```ignore // FIXME: unignore +/// use vulkano::buffer::BufferSlice; +/// # let buffer: std::sync::Arc<vulkano::buffer::DeviceLocalBuffer<[u8]>> = return; +/// let _slice = BufferSlice::from(&buffer); +/// ``` +/// +/// Selecting a slice of a buffer that contains `[T]`: +/// +/// ```ignore // FIXME: unignore +/// use vulkano::buffer::BufferSlice; +/// # let buffer: std::sync::Arc<vulkano::buffer::DeviceLocalBuffer<[u8]>> = return; +/// let _slice = BufferSlice::from(&buffer).slice(12 .. 14).unwrap(); +/// ``` +/// +pub struct BufferSlice<T: ?Sized, B> { + marker: PhantomData<T>, + resource: B, + offset: usize, + size: usize, +} + +// We need to implement `Clone` manually, otherwise the derive adds a `T: Clone` requirement. +impl<T: ?Sized, B> Clone for BufferSlice<T, B> + where B: Clone +{ + #[inline] + fn clone(&self) -> Self { + BufferSlice { + marker: PhantomData, + resource: self.resource.clone(), + offset: self.offset, + size: self.size, + } + } +} + +impl<T: ?Sized, B> BufferSlice<T, B> { + #[inline] + pub fn from_typed_buffer_access(r: B) -> BufferSlice<T, B> + where B: TypedBufferAccess<Content = T> + { + let size = r.size(); + + BufferSlice { + marker: PhantomData, + resource: r, + offset: 0, + size: size, + } + } + + /// Returns the buffer that this slice belongs to. + pub fn buffer(&self) -> &B { + &self.resource + } + + /// Returns the offset of that slice within the buffer. + #[inline] + pub fn offset(&self) -> usize { + self.offset + } + + /// Returns the size of that slice in bytes. + #[inline] + pub fn size(&self) -> usize { + self.size + } + + /// Builds a slice that contains an element from inside the buffer. + /// + /// This method builds an object that represents a slice of the buffer. No actual operation + /// is performed. + /// + /// # Example + /// + /// TODO + /// + /// # Safety + /// + /// The object whose reference is passed to the closure is uninitialized. Therefore you + /// **must not** access the content of the object. + /// + /// You **must** return a reference to an element from the parameter. The closure **must not** + /// panic. + #[inline] + pub unsafe fn slice_custom<F, R: ?Sized>(self, f: F) -> BufferSlice<R, B> + where F: for<'r> FnOnce(&'r T) -> &'r R // TODO: bounds on R + { + let data: &T = mem::zeroed(); + let result = f(data); + let size = mem::size_of_val(result); + let result = result as *const R as *const () as usize; + + assert!(result <= self.size()); + assert!(result + size <= self.size()); + + BufferSlice { + marker: PhantomData, + resource: self.resource, + offset: self.offset + result, + size: size, + } + } + + /// Changes the `T` generic parameter of the `BufferSlice` to the desired type. This can be + /// useful when you have a buffer with various types of data and want to create a typed slice + /// of a region that contains a single type of data. + /// + /// # Example + /// + /// ``` + /// # use std::sync::Arc; + /// # use vulkano::buffer::BufferSlice; + /// # use vulkano::buffer::immutable::ImmutableBuffer; + /// # struct VertexImpl; + /// let blob_slice: BufferSlice<[u8], Arc<ImmutableBuffer<[u8]>>> = return; + /// let vertex_slice: BufferSlice<[VertexImpl], Arc<ImmutableBuffer<[u8]>>> = unsafe { + /// blob_slice.reinterpret::<[VertexImpl]>() + /// }; + /// ``` + /// + /// # Safety + /// + /// Correct `offset` and `size` must be ensured before using this `BufferSlice` on the device. + /// See `BufferSlice::slice` for adjusting these properties. + #[inline] + pub unsafe fn reinterpret<R: ?Sized>(self) -> BufferSlice<R, B> + { + BufferSlice { + marker: PhantomData, + resource: self.resource, + offset: self.offset, + size: self.size, + } + } +} + +impl<T, B> BufferSlice<[T], B> { + /// Returns the number of elements in this slice. + #[inline] + pub fn len(&self) -> usize { + debug_assert_eq!(self.size() % mem::size_of::<T>(), 0); + self.size() / mem::size_of::<T>() + } + + /// Reduces the slice to just one element of the array. + /// + /// Returns `None` if out of range. + #[inline] + pub fn index(self, index: usize) -> Option<BufferSlice<T, B>> { + if index >= self.len() { + return None; + } + + Some(BufferSlice { + marker: PhantomData, + resource: self.resource, + offset: self.offset + index * mem::size_of::<T>(), + size: mem::size_of::<T>(), + }) + } + + /// Reduces the slice to just a range of the array. + /// + /// Returns `None` if out of range. + #[inline] + pub fn slice(self, range: Range<usize>) -> Option<BufferSlice<[T], B>> { + if range.end > self.len() { + return None; + } + + Some(BufferSlice { + marker: PhantomData, + resource: self.resource, + offset: self.offset + range.start * mem::size_of::<T>(), + size: (range.end - range.start) * mem::size_of::<T>(), + }) + } +} + +unsafe impl<T: ?Sized, B> BufferAccess for BufferSlice<T, B> + where B: BufferAccess +{ + #[inline] + fn inner(&self) -> BufferInner { + let inner = self.resource.inner(); + BufferInner { + buffer: inner.buffer, + offset: inner.offset + self.offset, + } + } + + #[inline] + fn size(&self) -> usize { + self.size + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + self.resource.conflicts_buffer(other) + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + self.resource.conflicts_image(other) + } + + #[inline] + fn conflict_key(&self) -> (u64, usize) { + self.resource.conflict_key() + } + + #[inline] + fn try_gpu_lock(&self, exclusive_access: bool, queue: &Queue) -> Result<(), AccessError> { + self.resource.try_gpu_lock(exclusive_access, queue) + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + self.resource.increase_gpu_lock() + } + + #[inline] + unsafe fn unlock(&self) { + self.resource.unlock() + } +} + +unsafe impl<T: ?Sized, B> TypedBufferAccess for BufferSlice<T, B> + where B: BufferAccess +{ + type Content = T; +} + +unsafe impl<T: ?Sized, B> DeviceOwned for BufferSlice<T, B> + where B: DeviceOwned +{ + #[inline] + fn device(&self) -> &Arc<Device> { + self.resource.device() + } +} + +impl<T, B> From<BufferSlice<T, B>> for BufferSlice<[T], B> { + #[inline] + fn from(r: BufferSlice<T, B>) -> BufferSlice<[T], B> { + BufferSlice { + marker: PhantomData, + resource: r.resource, + offset: r.offset, + size: r.size, + } + } +} + +/// Takes a `BufferSlice` that points to a struct, and returns a `BufferSlice` that points to +/// a specific field of that struct. +#[macro_export] +macro_rules! buffer_slice_field { + ($slice:expr, $field:ident) => ( + // TODO: add #[allow(unsafe_code)] when that's allowed + unsafe { $slice.slice_custom(|s| &s.$field) } + ) +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/sys.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/sys.rs new file mode 100644 index 0000000..48a1e25 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/sys.rs @@ -0,0 +1,577 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Low level implementation of buffers. +//! +//! Wraps directly around Vulkan buffers, with the exceptions of a few safety checks. +//! +//! The `UnsafeBuffer` type is the lowest-level buffer object provided by this library. It is used +//! internally by the higher-level buffer types. You are strongly encouraged to have excellent +//! knowledge of the Vulkan specs if you want to use an `UnsafeBuffer`. +//! +//! Here is what you must take care of when you use an `UnsafeBuffer`: +//! +//! - Synchronization, ie. avoid reading and writing simultaneously to the same buffer. +//! - Memory aliasing considerations. If you use the same memory to back multiple resources, you +//! must ensure that they are not used together and must enable some additional flags. +//! - Binding memory correctly and only once. If you use sparse binding, respect the rules of +//! sparse binding. +//! - Type safety. + +use smallvec::SmallVec; +use std::error; +use std::fmt; +use std::mem; +use std::ptr; +use std::sync::Arc; + +use buffer::BufferUsage; +use device::Device; +use device::DeviceOwned; +use memory::DeviceMemory; +use memory::DeviceMemoryAllocError; +use memory::MemoryRequirements; +use sync::Sharing; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use vk; + +/// Data storage in a GPU-accessible location. +pub struct UnsafeBuffer { + buffer: vk::Buffer, + device: Arc<Device>, + size: usize, + usage: vk::BufferUsageFlags, +} + +impl UnsafeBuffer { + /// Creates a new buffer of the given size. + /// + /// See the module's documentation for information about safety. + /// + /// # Panic + /// + /// Panics if `sparse.sparse` is false and `sparse.sparse_residency` or + /// `sparse.sparse_aliased` is true. + /// + pub unsafe fn new<'a, I>(device: Arc<Device>, size: usize, usage: BufferUsage, + sharing: Sharing<I>, sparse: SparseLevel) + -> Result<(UnsafeBuffer, MemoryRequirements), BufferCreationError> + where I: Iterator<Item = u32> + { + let vk = device.pointers(); + + // Ensure we're not trying to create an empty buffer. + let size = if size == 0 { + // To avoid panicking when allocating 0 bytes, use a 1-byte buffer. + 1 + } else { + size + }; + + let usage_bits = usage.to_vulkan_bits(); + + // Checking sparse features. + assert!(sparse.sparse || !sparse.sparse_residency, + "Can't enable sparse residency without enabling sparse binding as well"); + assert!(sparse.sparse || !sparse.sparse_aliased, + "Can't enable sparse aliasing without enabling sparse binding as well"); + if sparse.sparse && !device.enabled_features().sparse_binding { + return Err(BufferCreationError::SparseBindingFeatureNotEnabled); + } + if sparse.sparse_residency && !device.enabled_features().sparse_residency_buffer { + return Err(BufferCreationError::SparseResidencyBufferFeatureNotEnabled); + } + if sparse.sparse_aliased && !device.enabled_features().sparse_residency_aliased { + return Err(BufferCreationError::SparseResidencyAliasedFeatureNotEnabled); + } + + let buffer = { + let (sh_mode, sh_indices) = match sharing { + Sharing::Exclusive => (vk::SHARING_MODE_EXCLUSIVE, SmallVec::<[u32; 8]>::new()), + Sharing::Concurrent(ids) => (vk::SHARING_MODE_CONCURRENT, ids.collect()), + }; + + let infos = vk::BufferCreateInfo { + sType: vk::STRUCTURE_TYPE_BUFFER_CREATE_INFO, + pNext: ptr::null(), + flags: sparse.to_flags(), + size: size as u64, + usage: usage_bits, + sharingMode: sh_mode, + queueFamilyIndexCount: sh_indices.len() as u32, + pQueueFamilyIndices: sh_indices.as_ptr(), + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateBuffer(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + let mem_reqs = { + #[inline] + fn align(val: usize, al: usize) -> usize { + al * (1 + (val - 1) / al) + } + + let mut output = if device.loaded_extensions().khr_get_memory_requirements2 { + let infos = vk::BufferMemoryRequirementsInfo2KHR { + sType: vk::STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR, + pNext: ptr::null_mut(), + buffer: buffer, + }; + + let mut output2 = if device.loaded_extensions().khr_dedicated_allocation { + Some(vk::MemoryDedicatedRequirementsKHR { + sType: vk::STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR, + pNext: ptr::null(), + prefersDedicatedAllocation: mem::uninitialized(), + requiresDedicatedAllocation: mem::uninitialized(), + }) + } else { + None + }; + + let mut output = vk::MemoryRequirements2KHR { + sType: vk::STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR, + pNext: output2 + .as_mut() + .map(|o| o as *mut vk::MemoryDedicatedRequirementsKHR) + .unwrap_or(ptr::null_mut()) as *mut _, + memoryRequirements: mem::uninitialized(), + }; + + vk.GetBufferMemoryRequirements2KHR(device.internal_object(), &infos, &mut output); + debug_assert!(output.memoryRequirements.size >= size as u64); + debug_assert!(output.memoryRequirements.memoryTypeBits != 0); + + let mut out = MemoryRequirements::from_vulkan_reqs(output.memoryRequirements); + if let Some(output2) = output2 { + debug_assert_eq!(output2.requiresDedicatedAllocation, 0); + out.prefer_dedicated = output2.prefersDedicatedAllocation != 0; + } + out + + } else { + let mut output: vk::MemoryRequirements = mem::uninitialized(); + vk.GetBufferMemoryRequirements(device.internal_object(), buffer, &mut output); + debug_assert!(output.size >= size as u64); + debug_assert!(output.memoryTypeBits != 0); + MemoryRequirements::from_vulkan_reqs(output) + }; + + // We have to manually enforce some additional requirements for some buffer types. + let limits = device.physical_device().limits(); + if usage.uniform_texel_buffer || usage.storage_texel_buffer { + output.alignment = align(output.alignment, + limits.min_texel_buffer_offset_alignment() as usize); + } + + if usage.storage_buffer { + output.alignment = align(output.alignment, + limits.min_storage_buffer_offset_alignment() as usize); + } + + if usage.uniform_buffer { + output.alignment = align(output.alignment, + limits.min_uniform_buffer_offset_alignment() as usize); + } + + output + }; + + let obj = UnsafeBuffer { + buffer: buffer, + device: device.clone(), + size: size as usize, + usage: usage_bits, + }; + + Ok((obj, mem_reqs)) + } + + pub unsafe fn bind_memory(&self, memory: &DeviceMemory, offset: usize) -> Result<(), OomError> { + let vk = self.device.pointers(); + + // We check for correctness in debug mode. + debug_assert!({ + let mut mem_reqs = mem::uninitialized(); + vk.GetBufferMemoryRequirements(self.device.internal_object(), + self.buffer, + &mut mem_reqs); + mem_reqs.size <= (memory.size() - offset) as u64 && + (offset as u64 % mem_reqs.alignment) == 0 && + mem_reqs.memoryTypeBits & (1 << memory.memory_type().id()) != 0 + }); + + // Check for alignment correctness. + { + let limits = self.device().physical_device().limits(); + if self.usage_uniform_texel_buffer() || self.usage_storage_texel_buffer() { + debug_assert!(offset % limits.min_texel_buffer_offset_alignment() as usize == 0); + } + if self.usage_storage_buffer() { + debug_assert!(offset % limits.min_storage_buffer_offset_alignment() as usize == 0); + } + if self.usage_uniform_buffer() { + debug_assert!(offset % limits.min_uniform_buffer_offset_alignment() as usize == 0); + } + } + + check_errors(vk.BindBufferMemory(self.device.internal_object(), + self.buffer, + memory.internal_object(), + offset as vk::DeviceSize))?; + Ok(()) + } + + /// Returns the size of the buffer in bytes. + #[inline] + pub fn size(&self) -> usize { + self.size + } + + #[inline] + pub fn usage_transfer_source(&self) -> bool { + (self.usage & vk::BUFFER_USAGE_TRANSFER_SRC_BIT) != 0 + } + + #[inline] + pub fn usage_transfer_destination(&self) -> bool { + (self.usage & vk::BUFFER_USAGE_TRANSFER_DST_BIT) != 0 + } + + #[inline] + pub fn usage_uniform_texel_buffer(&self) -> bool { + (self.usage & vk::BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) != 0 + } + + #[inline] + pub fn usage_storage_texel_buffer(&self) -> bool { + (self.usage & vk::BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT) != 0 + } + + #[inline] + pub fn usage_uniform_buffer(&self) -> bool { + (self.usage & vk::BUFFER_USAGE_UNIFORM_BUFFER_BIT) != 0 + } + + #[inline] + pub fn usage_storage_buffer(&self) -> bool { + (self.usage & vk::BUFFER_USAGE_STORAGE_BUFFER_BIT) != 0 + } + + #[inline] + pub fn usage_index_buffer(&self) -> bool { + (self.usage & vk::BUFFER_USAGE_INDEX_BUFFER_BIT) != 0 + } + + #[inline] + pub fn usage_vertex_buffer(&self) -> bool { + (self.usage & vk::BUFFER_USAGE_VERTEX_BUFFER_BIT) != 0 + } + + #[inline] + pub fn usage_indirect_buffer(&self) -> bool { + (self.usage & vk::BUFFER_USAGE_INDIRECT_BUFFER_BIT) != 0 + } + + /// Returns a key unique to each `UnsafeBuffer`. Can be used for the `conflicts_key` method. + #[inline] + pub fn key(&self) -> u64 { + self.buffer + } +} + +unsafe impl VulkanObject for UnsafeBuffer { + type Object = vk::Buffer; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT; + + #[inline] + fn internal_object(&self) -> vk::Buffer { + self.buffer + } +} + +unsafe impl DeviceOwned for UnsafeBuffer { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl fmt::Debug for UnsafeBuffer { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan buffer {:?}>", self.buffer) + } +} + +impl Drop for UnsafeBuffer { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyBuffer(self.device.internal_object(), self.buffer, ptr::null()); + } + } +} + +#[derive(Debug, Copy, Clone)] +pub struct SparseLevel { + pub sparse: bool, + pub sparse_residency: bool, + pub sparse_aliased: bool, +} + +impl SparseLevel { + #[inline] + pub fn none() -> SparseLevel { + SparseLevel { + sparse: false, + sparse_residency: false, + sparse_aliased: false, + } + } + + #[inline] + fn to_flags(&self) -> vk::BufferCreateFlagBits { + let mut result = 0; + if self.sparse { + result |= vk::BUFFER_CREATE_SPARSE_BINDING_BIT; + } + if self.sparse_residency { + result |= vk::BUFFER_CREATE_SPARSE_RESIDENCY_BIT; + } + if self.sparse_aliased { + result |= vk::BUFFER_CREATE_SPARSE_ALIASED_BIT; + } + result + } +} + +/// Error that can happen when creating a buffer. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum BufferCreationError { + /// Allocating memory failed. + AllocError(DeviceMemoryAllocError), + /// Sparse binding was requested but the corresponding feature wasn't enabled. + SparseBindingFeatureNotEnabled, + /// Sparse residency was requested but the corresponding feature wasn't enabled. + SparseResidencyBufferFeatureNotEnabled, + /// Sparse aliasing was requested but the corresponding feature wasn't enabled. + SparseResidencyAliasedFeatureNotEnabled, +} + +impl error::Error for BufferCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + BufferCreationError::AllocError(_) => "allocating memory failed", + BufferCreationError::SparseBindingFeatureNotEnabled => { + "sparse binding was requested but the corresponding feature wasn't enabled" + }, + BufferCreationError::SparseResidencyBufferFeatureNotEnabled => { + "sparse residency was requested but the corresponding feature wasn't enabled" + }, + BufferCreationError::SparseResidencyAliasedFeatureNotEnabled => { + "sparse aliasing was requested but the corresponding feature wasn't enabled" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + BufferCreationError::AllocError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for BufferCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for BufferCreationError { + #[inline] + fn from(err: OomError) -> BufferCreationError { + BufferCreationError::AllocError(err.into()) + } +} + +impl From<Error> for BufferCreationError { + #[inline] + fn from(err: Error) -> BufferCreationError { + match err { + err @ Error::OutOfHostMemory => + BufferCreationError::AllocError(DeviceMemoryAllocError::from(err)), + err @ Error::OutOfDeviceMemory => + BufferCreationError::AllocError(DeviceMemoryAllocError::from(err)), + _ => panic!("unexpected error: {:?}", err), + } + } +} + +#[cfg(test)] +mod tests { + use std::iter::Empty; + + use super::BufferCreationError; + use super::BufferUsage; + use super::SparseLevel; + use super::UnsafeBuffer; + + use device::Device; + use device::DeviceOwned; + use sync::Sharing; + + #[test] + fn create() { + let (device, _) = gfx_dev_and_queue!(); + let (buf, reqs) = unsafe { + UnsafeBuffer::new(device.clone(), + 128, + BufferUsage::all(), + Sharing::Exclusive::<Empty<_>>, + SparseLevel::none()) + }.unwrap(); + + assert!(reqs.size >= 128); + assert_eq!(buf.size(), 128); + assert_eq!(&**buf.device() as *const Device, &*device as *const Device); + } + + #[test] + fn panic_wrong_sparse_residency() { + let (device, _) = gfx_dev_and_queue!(); + let sparse = SparseLevel { + sparse: false, + sparse_residency: true, + sparse_aliased: false, + }; + + assert_should_panic!("Can't enable sparse residency without enabling sparse \ + binding as well", + { + let _ = unsafe { + UnsafeBuffer::new(device, + 128, + BufferUsage::all(), + Sharing::Exclusive::<Empty<_>>, + sparse) + }; + }); + } + + #[test] + fn panic_wrong_sparse_aliased() { + let (device, _) = gfx_dev_and_queue!(); + let sparse = SparseLevel { + sparse: false, + sparse_residency: false, + sparse_aliased: true, + }; + + assert_should_panic!("Can't enable sparse aliasing without enabling sparse \ + binding as well", + { + let _ = unsafe { + UnsafeBuffer::new(device, + 128, + BufferUsage::all(), + Sharing::Exclusive::<Empty<_>>, + sparse) + }; + }); + } + + #[test] + fn missing_feature_sparse_binding() { + let (device, _) = gfx_dev_and_queue!(); + let sparse = SparseLevel { + sparse: true, + sparse_residency: false, + sparse_aliased: false, + }; + unsafe { + match UnsafeBuffer::new(device, + 128, + BufferUsage::all(), + Sharing::Exclusive::<Empty<_>>, + sparse) { + Err(BufferCreationError::SparseBindingFeatureNotEnabled) => (), + _ => panic!(), + } + }; + } + + #[test] + fn missing_feature_sparse_residency() { + let (device, _) = gfx_dev_and_queue!(sparse_binding); + let sparse = SparseLevel { + sparse: true, + sparse_residency: true, + sparse_aliased: false, + }; + unsafe { + match UnsafeBuffer::new(device, + 128, + BufferUsage::all(), + Sharing::Exclusive::<Empty<_>>, + sparse) { + Err(BufferCreationError::SparseResidencyBufferFeatureNotEnabled) => (), + _ => panic!(), + } + }; + } + + #[test] + fn missing_feature_sparse_aliased() { + let (device, _) = gfx_dev_and_queue!(sparse_binding); + let sparse = SparseLevel { + sparse: true, + sparse_residency: false, + sparse_aliased: true, + }; + unsafe { + match UnsafeBuffer::new(device, + 128, + BufferUsage::all(), + Sharing::Exclusive::<Empty<_>>, + sparse) { + Err(BufferCreationError::SparseResidencyAliasedFeatureNotEnabled) => (), + _ => panic!(), + } + }; + } + + #[test] + fn create_empty_buffer() { + let (device, _) = gfx_dev_and_queue!(); + + unsafe { + let _ = UnsafeBuffer::new(device, + 0, + BufferUsage::all(), + Sharing::Exclusive::<Empty<_>>, + SparseLevel::none()); + }; + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/traits.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/traits.rs new file mode 100644 index 0000000..d037768 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/traits.rs @@ -0,0 +1,215 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::ops::Range; + +use buffer::BufferSlice; +use buffer::sys::UnsafeBuffer; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use memory::Content; +use sync::AccessError; + +use SafeDeref; + +/// Trait for objects that represent a way for the GPU to have access to a buffer or a slice of a +/// buffer. +/// +/// See also `TypedBufferAccess`. +pub unsafe trait BufferAccess: DeviceOwned { + /// Returns the inner information about this buffer. + fn inner(&self) -> BufferInner; + + /// Returns the size of the buffer in bytes. + fn size(&self) -> usize; + + /// Builds a `BufferSlice` object holding the buffer by reference. + #[inline] + fn as_buffer_slice(&self) -> BufferSlice<Self::Content, &Self> + where Self: Sized + TypedBufferAccess + { + BufferSlice::from_typed_buffer_access(self) + } + + /// Builds a `BufferSlice` object holding part of the buffer by reference. + /// + /// This method can only be called for buffers whose type is known to be an array. + /// + /// This method can be used when you want to perform an operation on some part of the buffer + /// and not on the whole buffer. + /// + /// Returns `None` if out of range. + #[inline] + fn slice<T>(&self, range: Range<usize>) -> Option<BufferSlice<[T], &Self>> + where Self: Sized + TypedBufferAccess<Content = [T]> + { + BufferSlice::slice(self.as_buffer_slice(), range) + } + + /// Builds a `BufferSlice` object holding the buffer by value. + #[inline] + fn into_buffer_slice(self) -> BufferSlice<Self::Content, Self> + where Self: Sized + TypedBufferAccess + { + BufferSlice::from_typed_buffer_access(self) + } + + /// Builds a `BufferSlice` object holding part of the buffer by reference. + /// + /// This method can only be called for buffers whose type is known to be an array. + /// + /// This method can be used when you want to perform an operation on a specific element of the + /// buffer and not on the whole buffer. + /// + /// Returns `None` if out of range. + #[inline] + fn index<T>(&self, index: usize) -> Option<BufferSlice<[T], &Self>> + where Self: Sized + TypedBufferAccess<Content = [T]> + { + self.slice(index .. (index + 1)) + } + + /// Returns true if an access to `self` potentially overlaps the same memory as an access to + /// `other`. + /// + /// If this function returns `false`, this means that we are allowed to mutably access the + /// content of `self` at the same time as the content of `other` without causing a data + /// race. + /// + /// Note that the function must be transitive. In other words if `conflicts(a, b)` is true and + /// `conflicts(b, c)` is true, then `conflicts(a, c)` must be true as well. + fn conflicts_buffer(&self, other: &BufferAccess) -> bool; + + /// Returns true if an access to `self` potentially overlaps the same memory as an access to + /// `other`. + /// + /// If this function returns `false`, this means that we are allowed to mutably access the + /// content of `self` at the same time as the content of `other` without causing a data + /// race. + /// + /// Note that the function must be transitive. In other words if `conflicts(a, b)` is true and + /// `conflicts(b, c)` is true, then `conflicts(a, c)` must be true as well. + fn conflicts_image(&self, other: &ImageAccess) -> bool; + + /// Returns a key that uniquely identifies the buffer. Two buffers or images that potentially + /// overlap in memory must return the same key. + /// + /// The key is shared amongst all buffers and images, which means that you can make several + /// different buffer objects share the same memory, or make some buffer objects share memory + /// with images, as long as they return the same key. + /// + /// Since it is possible to accidentally return the same key for memory ranges that don't + /// overlap, the `conflicts_buffer` or `conflicts_image` function should always be called to + /// verify whether they actually overlap. + fn conflict_key(&self) -> (u64, usize); + + /// Locks the resource for usage on the GPU. Returns an error if the lock can't be acquired. + /// + /// This function exists to prevent the user from causing a data race by reading and writing + /// to the same resource at the same time. + /// + /// If you call this function, you should call `unlock()` once the resource is no longer in use + /// by the GPU. The implementation is not expected to automatically perform any unlocking and + /// can rely on the fact that `unlock()` is going to be called. + fn try_gpu_lock(&self, exclusive_access: bool, queue: &Queue) -> Result<(), AccessError>; + + /// Locks the resource for usage on the GPU. Supposes that the resource is already locked, and + /// simply increases the lock by one. + /// + /// Must only be called after `try_gpu_lock()` succeeded. + /// + /// If you call this function, you should call `unlock()` once the resource is no longer in use + /// by the GPU. The implementation is not expected to automatically perform any unlocking and + /// can rely on the fact that `unlock()` is going to be called. + unsafe fn increase_gpu_lock(&self); + + /// Unlocks the resource previously acquired with `try_gpu_lock` or `increase_gpu_lock`. + /// + /// # Safety + /// + /// Must only be called once per previous lock. + unsafe fn unlock(&self); +} + +/// Inner information about a buffer. +#[derive(Copy, Clone, Debug)] +pub struct BufferInner<'a> { + /// The underlying buffer object. + pub buffer: &'a UnsafeBuffer, + /// The offset in bytes from the start of the underlying buffer object to the start of the + /// buffer we're describing. + pub offset: usize, +} + +unsafe impl<T> BufferAccess for T + where T: SafeDeref, + T::Target: BufferAccess +{ + #[inline] + fn inner(&self) -> BufferInner { + (**self).inner() + } + + #[inline] + fn size(&self) -> usize { + (**self).size() + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + (**self).conflicts_buffer(other) + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + (**self).conflicts_image(other) + } + + #[inline] + fn conflict_key(&self) -> (u64, usize) { + (**self).conflict_key() + } + + #[inline] + fn try_gpu_lock(&self, exclusive_access: bool, queue: &Queue) -> Result<(), AccessError> { + (**self).try_gpu_lock(exclusive_access, queue) + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + (**self).increase_gpu_lock() + } + + #[inline] + unsafe fn unlock(&self) { + (**self).unlock() + } +} + +/// Extension trait for `BufferAccess`. Indicates the type of the content of the buffer. +pub unsafe trait TypedBufferAccess: BufferAccess { + /// The type of the content. + type Content: ?Sized; + + /// Returns the length of the buffer in number of elements. + /// + /// This method can only be called for buffers whose type is known to be an array. + #[inline] + fn len(&self) -> usize where Self::Content: Content { + self.size() / <Self::Content as Content>::indiv_size() + } +} + +unsafe impl<T> TypedBufferAccess for T + where T: SafeDeref, + T::Target: TypedBufferAccess +{ + type Content = <T::Target as TypedBufferAccess>::Content; +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/usage.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/usage.rs new file mode 100644 index 0000000..1db4a80 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/usage.rs @@ -0,0 +1,213 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::ops::BitOr; +use vk; + +/// Describes how a buffer is going to be used. This is **not** just an optimization. +/// +/// If you try to use a buffer in a way that you didn't declare, a panic will happen. +/// +/// Some methods are provided to build `BufferUsage` structs for some common situations. However +/// there is no restriction in the combination of BufferUsages that can be enabled. +#[derive(Debug, Copy, Clone)] +pub struct BufferUsage { + pub transfer_source: bool, + pub transfer_destination: bool, + pub uniform_texel_buffer: bool, + pub storage_texel_buffer: bool, + pub uniform_buffer: bool, + pub storage_buffer: bool, + pub index_buffer: bool, + pub vertex_buffer: bool, + pub indirect_buffer: bool, +} + +impl BufferUsage { + /// Turns this `BufferUsage` into raw Vulkan bits. + pub(crate) fn to_vulkan_bits(&self) -> vk::BufferUsageFlagBits { + let mut result = 0; + if self.transfer_source { + result |= vk::BUFFER_USAGE_TRANSFER_SRC_BIT; + } + if self.transfer_destination { + result |= vk::BUFFER_USAGE_TRANSFER_DST_BIT; + } + if self.uniform_texel_buffer { + result |= vk::BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT; + } + if self.storage_texel_buffer { + result |= vk::BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; + } + if self.uniform_buffer { + result |= vk::BUFFER_USAGE_UNIFORM_BUFFER_BIT; + } + if self.storage_buffer { + result |= vk::BUFFER_USAGE_STORAGE_BUFFER_BIT; + } + if self.index_buffer { + result |= vk::BUFFER_USAGE_INDEX_BUFFER_BIT; + } + if self.vertex_buffer { + result |= vk::BUFFER_USAGE_VERTEX_BUFFER_BIT; + } + if self.indirect_buffer { + result |= vk::BUFFER_USAGE_INDIRECT_BUFFER_BIT; + } + result + } + + /// Builds a `BufferUsage` with all values set to false. + #[inline] + pub fn none() -> BufferUsage { + BufferUsage { + transfer_source: false, + transfer_destination: false, + uniform_texel_buffer: false, + storage_texel_buffer: false, + uniform_buffer: false, + storage_buffer: false, + index_buffer: false, + vertex_buffer: false, + indirect_buffer: false, + } + } + + /// Builds a `BufferUsage` with all values set to true. Can be used for quick prototyping. + #[inline] + pub fn all() -> BufferUsage { + BufferUsage { + transfer_source: true, + transfer_destination: true, + uniform_texel_buffer: true, + storage_texel_buffer: true, + uniform_buffer: true, + storage_buffer: true, + index_buffer: true, + vertex_buffer: true, + indirect_buffer: true, + } + } + + /// Builds a `BufferUsage` with `transfer_source` set to true and the rest to false. + #[inline] + pub fn transfer_source() -> BufferUsage { + BufferUsage { + transfer_source: true, + ..BufferUsage::none() + } + } + + /// Builds a `BufferUsage` with `transfer_destination` set to true and the rest to false. + #[inline] + pub fn transfer_destination() -> BufferUsage { + BufferUsage { + transfer_destination: true, + ..BufferUsage::none() + } + } + + /// Builds a `BufferUsage` with `vertex_buffer` set to true and the rest to false. + #[inline] + pub fn vertex_buffer() -> BufferUsage { + BufferUsage { + vertex_buffer: true, + ..BufferUsage::none() + } + } + + /// Builds a `BufferUsage` with `vertex_buffer` and `transfer_destination` set to true and the rest + /// to false. + #[inline] + pub fn vertex_buffer_transfer_destination() -> BufferUsage { + BufferUsage { + vertex_buffer: true, + transfer_destination: true, + ..BufferUsage::none() + } + } + + /// Builds a `BufferUsage` with `index_buffer` set to true and the rest to false. + #[inline] + pub fn index_buffer() -> BufferUsage { + BufferUsage { + index_buffer: true, + ..BufferUsage::none() + } + } + + /// Builds a `BufferUsage` with `index_buffer` and `transfer_destination` set to true and the rest to false. + #[inline] + pub fn index_buffer_transfer_destination() -> BufferUsage { + BufferUsage { + index_buffer: true, + transfer_destination: true, + ..BufferUsage::none() + } + } + + /// Builds a `BufferUsage` with `uniform_buffer` set to true and the rest to false. + #[inline] + pub fn uniform_buffer() -> BufferUsage { + BufferUsage { + uniform_buffer: true, + ..BufferUsage::none() + } + } + + /// Builds a `BufferUsage` with `uniform_buffer` and `transfer_destination` set to true and the rest + /// to false. + #[inline] + pub fn uniform_buffer_transfer_destination() -> BufferUsage { + BufferUsage { + uniform_buffer: true, + transfer_destination: true, + ..BufferUsage::none() + } + } + + /// Builds a `BufferUsage` with `indirect_buffer` set to true and the rest to false. + #[inline] + pub fn indirect_buffer() -> BufferUsage { + BufferUsage { + indirect_buffer: true, + ..BufferUsage::none() + } + } + + /// Builds a `BufferUsage` with `indirect_buffer` and `transfer_destination` set to true and the rest + /// to false. + #[inline] + pub fn indirect_buffer_transfer_destination() -> BufferUsage { + BufferUsage { + indirect_buffer: true, + transfer_destination: true, + ..BufferUsage::none() + } + } +} + +impl BitOr for BufferUsage { + type Output = Self; + + #[inline] + fn bitor(self, rhs: Self) -> Self { + BufferUsage { + transfer_source: self.transfer_source || rhs.transfer_source, + transfer_destination: self.transfer_destination || rhs.transfer_destination, + uniform_texel_buffer: self.uniform_texel_buffer || rhs.uniform_texel_buffer, + storage_texel_buffer: self.storage_texel_buffer || rhs.storage_texel_buffer, + uniform_buffer: self.uniform_buffer || rhs.uniform_buffer, + storage_buffer: self.storage_buffer || rhs.storage_buffer, + index_buffer: self.index_buffer || rhs.index_buffer, + vertex_buffer: self.vertex_buffer || rhs.vertex_buffer, + indirect_buffer: self.indirect_buffer || rhs.indirect_buffer, + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/view.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/view.rs new file mode 100644 index 0000000..ff7695a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/buffer/view.rs @@ -0,0 +1,450 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! View of a buffer, in order to use it as a uniform texel buffer or storage texel buffer. +//! +//! In order to use a buffer as a uniform texel buffer or a storage texel buffer, you have to +//! create a `BufferView`, which indicates which format the data is in. +//! +//! In order to create a view from a buffer, the buffer must have been created with either the +//! `uniform_texel_buffer` or the `storage_texel_buffer` usage. +//! +//! # Example +//! +//! ``` +//! # use std::sync::Arc; +//! use vulkano::buffer::immutable::ImmutableBuffer; +//! use vulkano::buffer::BufferUsage; +//! use vulkano::buffer::BufferView; +//! use vulkano::format; +//! +//! # let device: Arc<vulkano::device::Device> = return; +//! # let queue: Arc<vulkano::device::Queue> = return; +//! let usage = BufferUsage { +//! storage_texel_buffer: true, +//! .. BufferUsage::none() +//! }; +//! +//! let (buffer, _future) = ImmutableBuffer::<[u32]>::from_iter((0..128).map(|n| n), usage, +//! queue.clone()).unwrap(); +//! let _view = BufferView::new(buffer, format::R32Uint).unwrap(); +//! ``` + +use std::error; +use std::fmt; +use std::marker::PhantomData; +use std::mem; +use std::ptr; +use std::sync::Arc; + +use buffer::BufferAccess; +use buffer::BufferInner; +use buffer::TypedBufferAccess; +use device::Device; +use device::DeviceOwned; +use format::FormatDesc; +use format::StrongStorage; + +use Error; +use OomError; +use SafeDeref; +use VulkanObject; +use check_errors; +use vk; + +/// Represents a way for the GPU to interpret buffer data. See the documentation of the +/// `view` module. +pub struct BufferView<F, B> + where B: BufferAccess +{ + view: vk::BufferView, + buffer: B, + marker: PhantomData<F>, + atomic_accesses: bool, +} + +impl<F, B> BufferView<F, B> + where B: BufferAccess +{ + /// Builds a new buffer view. + #[inline] + pub fn new(buffer: B, format: F) -> Result<BufferView<F, B>, BufferViewCreationError> + where B: TypedBufferAccess<Content = [F::Pixel]>, + F: StrongStorage + 'static + { + unsafe { BufferView::unchecked(buffer, format) } + } + + /// Builds a new buffer view without checking that the format is correct. + pub unsafe fn unchecked(org_buffer: B, format: F) + -> Result<BufferView<F, B>, BufferViewCreationError> + where B: BufferAccess, + F: FormatDesc + 'static + { + let (view, format_props) = { + let size = org_buffer.size(); + let BufferInner { buffer, offset } = org_buffer.inner(); + + let device = buffer.device(); + let format = format.format(); + + if (offset % + device + .physical_device() + .limits() + .min_texel_buffer_offset_alignment() as usize) != 0 + { + return Err(BufferViewCreationError::WrongBufferAlignment); + } + + if !buffer.usage_uniform_texel_buffer() && !buffer.usage_storage_texel_buffer() { + return Err(BufferViewCreationError::WrongBufferUsage); + } + + { + let nb = size / + format + .size() + .expect("Can't use a compressed format for buffer views"); + let l = device + .physical_device() + .limits() + .max_texel_buffer_elements(); + if nb > l as usize { + return Err(BufferViewCreationError::MaxTexelBufferElementsExceeded); + } + } + + let format_props = { + let vk_i = device.instance().pointers(); + let mut output = mem::uninitialized(); + vk_i.GetPhysicalDeviceFormatProperties(device.physical_device().internal_object(), + format as u32, + &mut output); + output.bufferFeatures + }; + + if buffer.usage_uniform_texel_buffer() { + if (format_props & vk::FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT) == 0 { + return Err(BufferViewCreationError::UnsupportedFormat); + } + } + + if buffer.usage_storage_texel_buffer() { + if (format_props & vk::FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT) == 0 { + return Err(BufferViewCreationError::UnsupportedFormat); + } + } + + let infos = vk::BufferViewCreateInfo { + sType: vk::STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved, + buffer: buffer.internal_object(), + format: format as u32, + offset: offset as u64, + range: size as u64, + }; + + let vk = device.pointers(); + let mut output = mem::uninitialized(); + check_errors(vk.CreateBufferView(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + (output, format_props) + }; + + Ok(BufferView { + view: view, + buffer: org_buffer, + marker: PhantomData, + atomic_accesses: (format_props & + vk::FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT) != + 0, + }) + } + + /// Returns the buffer associated to this view. + #[inline] + pub fn buffer(&self) -> &B { + &self.buffer + } + + /// Returns true if the buffer view can be used as a uniform texel buffer. + #[inline] + pub fn uniform_texel_buffer(&self) -> bool { + self.buffer.inner().buffer.usage_uniform_texel_buffer() + } + + /// Returns true if the buffer view can be used as a storage texel buffer. + #[inline] + pub fn storage_texel_buffer(&self) -> bool { + self.buffer.inner().buffer.usage_storage_texel_buffer() + } + + /// Returns true if the buffer view can be used as a storage texel buffer with atomic accesses. + #[inline] + pub fn storage_texel_buffer_atomic(&self) -> bool { + self.atomic_accesses && self.storage_texel_buffer() + } +} + +unsafe impl<F, B> VulkanObject for BufferView<F, B> + where B: BufferAccess +{ + type Object = vk::BufferView; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT; + + #[inline] + fn internal_object(&self) -> vk::BufferView { + self.view + } +} + +unsafe impl<F, B> DeviceOwned for BufferView<F, B> + where B: BufferAccess +{ + #[inline] + fn device(&self) -> &Arc<Device> { + self.buffer.device() + } +} + +impl<F, B> fmt::Debug for BufferView<F, B> + where B: BufferAccess + fmt::Debug +{ + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fmt.debug_struct("BufferView") + .field("raw", &self.view) + .field("buffer", &self.buffer) + .finish() + } +} + +impl<F, B> Drop for BufferView<F, B> + where B: BufferAccess +{ + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.buffer.inner().buffer.device().pointers(); + vk.DestroyBufferView(self.buffer.inner().buffer.device().internal_object(), + self.view, + ptr::null()); + } + } +} + +pub unsafe trait BufferViewRef { + type BufferAccess: BufferAccess; + type Format; + + fn view(&self) -> &BufferView<Self::Format, Self::BufferAccess>; +} + +unsafe impl<F, B> BufferViewRef for BufferView<F, B> + where B: BufferAccess +{ + type BufferAccess = B; + type Format = F; + + #[inline] + fn view(&self) -> &BufferView<F, B> { + self + } +} + +unsafe impl<T, F, B> BufferViewRef for T + where T: SafeDeref<Target = BufferView<F, B>>, + B: BufferAccess +{ + type BufferAccess = B; + type Format = F; + + #[inline] + fn view(&self) -> &BufferView<F, B> { + &**self + } +} + +/// Error that can happen when creating a buffer view. +#[derive(Debug, Copy, Clone)] +pub enum BufferViewCreationError { + /// Out of memory. + OomError(OomError), + + /// The buffer was not creating with one of the `storage_texel_buffer` or + /// `uniform_texel_buffer` usages. + WrongBufferUsage, + + /// The offset within the buffer is not a multiple of the `min_texel_buffer_offset_alignment` + /// limit. + WrongBufferAlignment, + + /// The requested format is not supported for this usage. + UnsupportedFormat, + + /// The maximum number of elements in the buffer view has been exceeded. + MaxTexelBufferElementsExceeded, +} + +impl error::Error for BufferViewCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + BufferViewCreationError::OomError(_) => "out of memory when creating buffer view", + BufferViewCreationError::WrongBufferUsage => + "the buffer is missing correct usage flags", + BufferViewCreationError::WrongBufferAlignment => { + "the offset within the buffer is not a multiple of the + `min_texel_buffer_offset_alignment` limit" + }, + BufferViewCreationError::UnsupportedFormat => + "the requested format is not supported for this usage", + BufferViewCreationError::MaxTexelBufferElementsExceeded => { + "the maximum number of texel elements is exceeded" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + BufferViewCreationError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for BufferViewCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for BufferViewCreationError { + #[inline] + fn from(err: OomError) -> BufferViewCreationError { + BufferViewCreationError::OomError(err) + } +} + +impl From<Error> for BufferViewCreationError { + #[inline] + fn from(err: Error) -> BufferViewCreationError { + OomError::from(err).into() + } +} + +#[cfg(test)] +mod tests { + use buffer::BufferUsage; + use buffer::BufferView; + use buffer::immutable::ImmutableBuffer; + use buffer::view::BufferViewCreationError; + use format; + + #[test] + fn create_uniform() { + // `VK_FORMAT_R8G8B8A8_UNORM` guaranteed to be a supported format + let (device, queue) = gfx_dev_and_queue!(); + + let usage = BufferUsage { + uniform_texel_buffer: true, + ..BufferUsage::none() + }; + + let (buffer, _) = ImmutableBuffer::<[[u8; 4]]>::from_iter((0 .. 128).map(|_| [0; 4]), + usage, + queue.clone()) + .unwrap(); + let view = BufferView::new(buffer, format::R8G8B8A8Unorm).unwrap(); + + assert!(view.uniform_texel_buffer()); + } + + #[test] + fn create_storage() { + // `VK_FORMAT_R8G8B8A8_UNORM` guaranteed to be a supported format + let (device, queue) = gfx_dev_and_queue!(); + + let usage = BufferUsage { + storage_texel_buffer: true, + ..BufferUsage::none() + }; + + let (buffer, _) = ImmutableBuffer::<[[u8; 4]]>::from_iter((0 .. 128).map(|_| [0; 4]), + usage, + queue.clone()) + .unwrap(); + let view = BufferView::new(buffer, format::R8G8B8A8Unorm).unwrap(); + + assert!(view.storage_texel_buffer()); + } + + #[test] + fn create_storage_atomic() { + // `VK_FORMAT_R32_UINT` guaranteed to be a supported format for atomics + let (device, queue) = gfx_dev_and_queue!(); + + let usage = BufferUsage { + storage_texel_buffer: true, + ..BufferUsage::none() + }; + + let (buffer, _) = + ImmutableBuffer::<[u32]>::from_iter((0 .. 128).map(|_| 0), usage, queue.clone()) + .unwrap(); + let view = BufferView::new(buffer, format::R32Uint).unwrap(); + + assert!(view.storage_texel_buffer()); + assert!(view.storage_texel_buffer_atomic()); + } + + #[test] + fn wrong_usage() { + // `VK_FORMAT_R8G8B8A8_UNORM` guaranteed to be a supported format + let (device, queue) = gfx_dev_and_queue!(); + + let (buffer, _) = ImmutableBuffer::<[[u8; 4]]>::from_iter((0 .. 128).map(|_| [0; 4]), + BufferUsage::none(), + queue.clone()) + .unwrap(); + + match BufferView::new(buffer, format::R8G8B8A8Unorm) { + Err(BufferViewCreationError::WrongBufferUsage) => (), + _ => panic!(), + } + } + + #[test] + fn unsupported_format() { + let (device, queue) = gfx_dev_and_queue!(); + + let usage = BufferUsage { + uniform_texel_buffer: true, + storage_texel_buffer: true, + ..BufferUsage::none() + }; + + let (buffer, _) = ImmutableBuffer::<[[f64; 4]]>::from_iter((0 .. 128).map(|_| [0.0; 4]), + usage, + queue.clone()) + .unwrap(); + + // TODO: what if R64G64B64A64Sfloat is supported? + match BufferView::new(buffer, format::R64G64B64A64Sfloat) { + Err(BufferViewCreationError::UnsupportedFormat) => (), + _ => panic!(), + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/auto.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/auto.rs new file mode 100644 index 0000000..9b48f6e --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/auto.rs @@ -0,0 +1,1794 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::iter; +use std::mem; +use std::slice; +use std::sync::Arc; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; + +use OomError; +use buffer::BufferAccess; +use buffer::TypedBufferAccess; +use command_buffer::CommandBuffer; +use command_buffer::CommandBufferExecError; +use command_buffer::DrawIndirectCommand; +use command_buffer::DrawIndexedIndirectCommand; +use command_buffer::DynamicState; +use command_buffer::StateCacher; +use command_buffer::StateCacherOutcome; +use command_buffer::pool::CommandPoolBuilderAlloc; +use command_buffer::pool::standard::StandardCommandPoolAlloc; +use command_buffer::pool::standard::StandardCommandPoolBuilder; +use command_buffer::synced::SyncCommandBuffer; +use command_buffer::synced::SyncCommandBufferBuilder; +use command_buffer::synced::SyncCommandBufferBuilderError; +use command_buffer::sys::Flags; +use command_buffer::sys::Kind; +use command_buffer::sys::KindOcclusionQuery; +use command_buffer::sys::KindSecondaryRenderPass; +use command_buffer::sys::UnsafeCommandBuffer; +use command_buffer::sys::UnsafeCommandBufferBuilderBufferImageCopy; +use command_buffer::sys::UnsafeCommandBufferBuilderColorImageClear; +use command_buffer::sys::UnsafeCommandBufferBuilderImageAspect; +use command_buffer::sys::UnsafeCommandBufferBuilderImageBlit; +use command_buffer::sys::UnsafeCommandBufferBuilderImageCopy; +use command_buffer::validity::*; +use descriptor::descriptor_set::DescriptorSetsCollection; +use descriptor::pipeline_layout::PipelineLayoutAbstract; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use format::AcceptsPixels; +use format::ClearValue; +use format::Format; +use format::FormatTy; +use framebuffer::EmptySinglePassRenderPassDesc; +use framebuffer::Framebuffer; +use framebuffer::FramebufferAbstract; +use framebuffer::LoadOp; +use framebuffer::RenderPass; +use framebuffer::RenderPassAbstract; +use framebuffer::RenderPassCompatible; +use framebuffer::RenderPassDescClearValues; +use framebuffer::Subpass; +use framebuffer::SubpassContents; +use image::ImageAccess; +use image::ImageLayout; +use instance::QueueFamily; +use pipeline::ComputePipelineAbstract; +use pipeline::GraphicsPipelineAbstract; +use pipeline::input_assembly::Index; +use pipeline::vertex::VertexSource; +use query::QueryPipelineStatisticFlags; +use sampler::Filter; +use sync::AccessCheckError; +use sync::AccessFlagBits; +use sync::GpuFuture; +use sync::PipelineStages; + +/// Note that command buffers allocated from the default command pool (`Arc<StandardCommandPool>`) +/// don't implement the `Send` and `Sync` traits. If you use this pool, then the +/// `AutoCommandBufferBuilder` will not implement `Send` and `Sync` either. Once a command buffer +/// is built, however, it *does* implement `Send` and `Sync`. +pub struct AutoCommandBufferBuilder<P = StandardCommandPoolBuilder> { + inner: SyncCommandBufferBuilder<P>, + state_cacher: StateCacher, + + // True if the queue family supports graphics operations. + graphics_allowed: bool, + + // True if the queue family supports compute operations. + compute_allowed: bool, + + // If we're inside a render pass, contains the render pass and the subpass index. + render_pass: Option<(Box<RenderPassAbstract>, u32)>, + + // True if we are a secondary command buffer. + secondary_cb: bool, + + // True if we're in a subpass that only allows executing secondary command buffers. False if + // we're in a subpass that only allows inline commands. Irrelevant if not in a subpass. + subpass_secondary: bool, + + // Flags passed when creating the command buffer. + flags: Flags, +} + +impl AutoCommandBufferBuilder<StandardCommandPoolBuilder> { + #[inline] + pub fn new(device: Arc<Device>, queue_family: QueueFamily) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> { + AutoCommandBufferBuilder::with_flags(device, queue_family, Kind::primary(), Flags::None) + } + + /// Starts building a primary command buffer. + /// + /// The final command buffer can only be executed once at a time. In other words, it is as if + /// executing the command buffer modifies it. + #[inline] + pub fn primary(device: Arc<Device>, queue_family: QueueFamily) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> { + AutoCommandBufferBuilder::with_flags(device, queue_family, Kind::primary(), Flags::None) + } + + /// Starts building a primary command buffer. + /// + /// Contrary to `primary`, the final command buffer can only be submitted once before being + /// destroyed. This makes it possible for the implementation to perform additional + /// optimizations. + #[inline] + pub fn primary_one_time_submit( + device: Arc<Device>, queue_family: QueueFamily) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> { + AutoCommandBufferBuilder::with_flags(device, + queue_family, + Kind::primary(), + Flags::OneTimeSubmit) + } + + /// Starts building a primary command buffer. + /// + /// Contrary to `primary`, the final command buffer can be executed multiple times in parallel + /// in multiple different queues. + #[inline] + pub fn primary_simultaneous_use( + device: Arc<Device>, queue_family: QueueFamily) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> { + AutoCommandBufferBuilder::with_flags(device, + queue_family, + Kind::primary(), + Flags::SimultaneousUse) + } + + /// Starts building a secondary compute command buffer. + /// + /// The final command buffer can only be executed once at a time. In other words, it is as if + /// executing the command buffer modifies it. + #[inline] + pub fn secondary_compute( + device: Arc<Device>, queue_family: QueueFamily) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> { + let kind = Kind::secondary(KindOcclusionQuery::Forbidden, + QueryPipelineStatisticFlags::none()); + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::None) + } + + /// Starts building a secondary compute command buffer. + /// + /// Contrary to `secondary_compute`, the final command buffer can only be submitted once before + /// being destroyed. This makes it possible for the implementation to perform additional + /// optimizations. + #[inline] + pub fn secondary_compute_one_time_submit( + device: Arc<Device>, queue_family: QueueFamily) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> { + let kind = Kind::secondary(KindOcclusionQuery::Forbidden, + QueryPipelineStatisticFlags::none()); + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::OneTimeSubmit) + } + + /// Starts building a secondary compute command buffer. + /// + /// Contrary to `secondary_compute`, the final command buffer can be executed multiple times in + /// parallel in multiple different queues. + #[inline] + pub fn secondary_compute_simultaneous_use( + device: Arc<Device>, queue_family: QueueFamily) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> { + let kind = Kind::secondary(KindOcclusionQuery::Forbidden, + QueryPipelineStatisticFlags::none()); + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::SimultaneousUse) + } + + /// Same as `secondary_compute`, but allows specifying how queries are being inherited. + #[inline] + pub fn secondary_compute_inherit_queries( + device: Arc<Device>, queue_family: QueueFamily, occlusion_query: KindOcclusionQuery, + query_statistics_flags: QueryPipelineStatisticFlags) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> { + let kind = Kind::secondary(occlusion_query, query_statistics_flags); + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::None) + } + + /// Same as `secondary_compute_one_time_submit`, but allows specifying how queries are being inherited. + #[inline] + pub fn secondary_compute_one_time_submit_inherit_queries( + device: Arc<Device>, queue_family: QueueFamily, occlusion_query: KindOcclusionQuery, + query_statistics_flags: QueryPipelineStatisticFlags) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> { + let kind = Kind::secondary(occlusion_query, query_statistics_flags); + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::OneTimeSubmit) + } + + /// Same as `secondary_compute_simultaneous_use`, but allows specifying how queries are being inherited. + #[inline] + pub fn secondary_compute_simultaneous_use_inherit_queries( + device: Arc<Device>, queue_family: QueueFamily, occlusion_query: KindOcclusionQuery, + query_statistics_flags: QueryPipelineStatisticFlags) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> { + let kind = Kind::secondary(occlusion_query, query_statistics_flags); + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::SimultaneousUse) + } + + /// Starts building a secondary graphics command buffer. + /// + /// The final command buffer can only be executed once at a time. In other words, it is as if + /// executing the command buffer modifies it. + #[inline] + pub fn secondary_graphics<R>( + device: Arc<Device>, queue_family: QueueFamily, subpass: Subpass<R>) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> + where R: RenderPassAbstract + Clone + Send + Sync + 'static + { + let kind = Kind::Secondary { + render_pass: Some(KindSecondaryRenderPass { + subpass, + framebuffer: + None::<Framebuffer<RenderPass<EmptySinglePassRenderPassDesc>, + ()>>, + }), + occlusion_query: KindOcclusionQuery::Forbidden, + query_statistics_flags: QueryPipelineStatisticFlags::none(), + }; + + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::None) + } + + /// Starts building a secondary graphics command buffer. + /// + /// Contrary to `secondary_graphics`, the final command buffer can only be submitted once + /// before being destroyed. This makes it possible for the implementation to perform additional + /// optimizations. + #[inline] + pub fn secondary_graphics_one_time_submit<R>( + device: Arc<Device>, queue_family: QueueFamily, subpass: Subpass<R>) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> + where R: RenderPassAbstract + Clone + Send + Sync + 'static + { + let kind = Kind::Secondary { + render_pass: Some(KindSecondaryRenderPass { + subpass, + framebuffer: + None::<Framebuffer<RenderPass<EmptySinglePassRenderPassDesc>, + ()>>, + }), + occlusion_query: KindOcclusionQuery::Forbidden, + query_statistics_flags: QueryPipelineStatisticFlags::none(), + }; + + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::OneTimeSubmit) + } + + /// Starts building a secondary graphics command buffer. + /// + /// Contrary to `secondary_graphics`, the final command buffer can be executed multiple times + /// in parallel in multiple different queues. + #[inline] + pub fn secondary_graphics_simultaneous_use<R>( + device: Arc<Device>, queue_family: QueueFamily, subpass: Subpass<R>) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> + where R: RenderPassAbstract + Clone + Send + Sync + 'static + { + let kind = Kind::Secondary { + render_pass: Some(KindSecondaryRenderPass { + subpass, + framebuffer: + None::<Framebuffer<RenderPass<EmptySinglePassRenderPassDesc>, + ()>>, + }), + occlusion_query: KindOcclusionQuery::Forbidden, + query_statistics_flags: QueryPipelineStatisticFlags::none(), + }; + + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::SimultaneousUse) + } + + /// Same as `secondary_graphics`, but allows specifying how queries are being inherited. + #[inline] + pub fn secondary_graphics_inherit_queries<R>( + device: Arc<Device>, queue_family: QueueFamily, subpass: Subpass<R>, + occlusion_query: KindOcclusionQuery, query_statistics_flags: QueryPipelineStatisticFlags) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> + where R: RenderPassAbstract + Clone + Send + Sync + 'static + { + let kind = Kind::Secondary { + render_pass: Some(KindSecondaryRenderPass { + subpass, + framebuffer: + None::<Framebuffer<RenderPass<EmptySinglePassRenderPassDesc>, + ()>>, + }), + occlusion_query, + query_statistics_flags, + }; + + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::None) + } + + /// Same as `secondary_graphics_one_time_submit`, but allows specifying how queries are being inherited. + #[inline] + pub fn secondary_graphics_one_time_submit_inherit_queries<R>( + device: Arc<Device>, queue_family: QueueFamily, subpass: Subpass<R>, + occlusion_query: KindOcclusionQuery, query_statistics_flags: QueryPipelineStatisticFlags) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> + where R: RenderPassAbstract + Clone + Send + Sync + 'static + { + let kind = Kind::Secondary { + render_pass: Some(KindSecondaryRenderPass { + subpass, + framebuffer: + None::<Framebuffer<RenderPass<EmptySinglePassRenderPassDesc>, + ()>>, + }), + occlusion_query, + query_statistics_flags, + }; + + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::OneTimeSubmit) + } + + /// Same as `secondary_graphics_simultaneous_use`, but allows specifying how queries are being inherited. + #[inline] + pub fn secondary_graphics_simultaneous_use_inherit_queries<R>( + device: Arc<Device>, queue_family: QueueFamily, subpass: Subpass<R>, + occlusion_query: KindOcclusionQuery, query_statistics_flags: QueryPipelineStatisticFlags) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> + where R: RenderPassAbstract + Clone + Send + Sync + 'static + { + let kind = Kind::Secondary { + render_pass: Some(KindSecondaryRenderPass { + subpass, + framebuffer: + None::<Framebuffer<RenderPass<EmptySinglePassRenderPassDesc>, + ()>>, + }), + occlusion_query, + query_statistics_flags, + }; + + AutoCommandBufferBuilder::with_flags(device, queue_family, kind, Flags::SimultaneousUse) + } + + // Actual constructor. Private. + fn with_flags<R, F>(device: Arc<Device>, queue_family: QueueFamily, kind: Kind<R, F>, + flags: Flags) + -> Result<AutoCommandBufferBuilder<StandardCommandPoolBuilder>, OomError> + where R: RenderPassAbstract + Clone + Send + Sync + 'static, + F: FramebufferAbstract + { + unsafe { + let (secondary_cb, render_pass) = match kind { + Kind::Primary => (false, None), + Kind::Secondary { render_pass: Some(ref sec), .. } => { + let render_pass = sec.subpass.render_pass().clone(); + let index = sec.subpass.index(); + (true, Some((Box::new(render_pass) as Box<_>, index))) + }, + Kind::Secondary { render_pass: None, .. } => (true, None), + }; + + let pool = Device::standard_command_pool(&device, queue_family); + let inner = SyncCommandBufferBuilder::new(&pool, kind, flags); + let state_cacher = StateCacher::new(); + + let graphics_allowed = queue_family.supports_graphics(); + let compute_allowed = queue_family.supports_compute(); + + Ok(AutoCommandBufferBuilder { + inner: inner?, + state_cacher, + graphics_allowed, + compute_allowed, + render_pass, + secondary_cb, + subpass_secondary: false, + flags, + }) + } + } +} + +impl<P> AutoCommandBufferBuilder<P> { + #[inline] + fn ensure_outside_render_pass(&self) -> Result<(), AutoCommandBufferBuilderContextError> { + if self.render_pass.is_none() { + Ok(()) + } else { + Err(AutoCommandBufferBuilderContextError::ForbiddenInsideRenderPass) + } + } + + #[inline] + fn ensure_inside_render_pass_secondary(&self) + -> Result<(), AutoCommandBufferBuilderContextError> { + if self.render_pass.is_some() { + if self.subpass_secondary { + Ok(()) + } else { + Err(AutoCommandBufferBuilderContextError::WrongSubpassType) + } + } else { + Err(AutoCommandBufferBuilderContextError::ForbiddenOutsideRenderPass) + } + } + + #[inline] + fn ensure_inside_render_pass_inline<Gp>(&self, pipeline: &Gp) + -> Result<(), AutoCommandBufferBuilderContextError> + where Gp: ?Sized + GraphicsPipelineAbstract + { + if self.render_pass.is_none() { + return Err(AutoCommandBufferBuilderContextError::ForbiddenOutsideRenderPass); + } + + if self.subpass_secondary { + return Err(AutoCommandBufferBuilderContextError::WrongSubpassType); + } + + let local_render_pass = self.render_pass.as_ref().unwrap(); + + if pipeline.subpass_index() != local_render_pass.1 { + return Err(AutoCommandBufferBuilderContextError::WrongSubpassIndex); + } + + if !RenderPassCompatible::is_compatible_with(pipeline, &local_render_pass.0) { + return Err(AutoCommandBufferBuilderContextError::IncompatibleRenderPass); + } + + Ok(()) + } + + /// Builds the command buffer. + #[inline] + pub fn build(self) -> Result<AutoCommandBuffer<P::Alloc>, BuildError> + where P: CommandPoolBuilderAlloc + { + if !self.secondary_cb && self.render_pass.is_some() { + return Err(AutoCommandBufferBuilderContextError::ForbiddenInsideRenderPass.into()); + } + + let submit_state = match self.flags { + Flags::None => { + SubmitState::ExclusiveUse { in_use: AtomicBool::new(false) } + }, + Flags::SimultaneousUse => { + SubmitState::Concurrent + }, + Flags::OneTimeSubmit => { + SubmitState::OneTime { already_submitted: AtomicBool::new(false) } + }, + }; + + Ok(AutoCommandBuffer { + inner: self.inner.build()?, + submit_state, + }) + } + + /// Adds a command that enters a render pass. + /// + /// If `secondary` is true, then you will only be able to add secondary command buffers while + /// you're inside the first subpass of the render pass. If `secondary` is false, you will only + /// be able to add inline draw commands and not secondary command buffers. + /// + /// C must contain exactly one clear value for each attachment in the framebuffer. + /// + /// You must call this before you can add draw commands. + #[inline] + pub fn begin_render_pass<F, C>(mut self, framebuffer: F, secondary: bool, clear_values: C) + -> Result<Self, BeginRenderPassError> + where F: FramebufferAbstract + RenderPassDescClearValues<C> + Clone + Send + Sync + 'static + { + unsafe { + if self.secondary_cb { + return Err(AutoCommandBufferBuilderContextError::ForbiddenInSecondary.into()); + } + + if !self.graphics_allowed { + return Err(AutoCommandBufferBuilderContextError::NotSupportedByQueueFamily.into()); + } + + self.ensure_outside_render_pass()?; + + let clear_values = framebuffer.convert_clear_values(clear_values); + let clear_values = clear_values.collect::<Vec<_>>().into_iter(); // TODO: necessary for Send + Sync ; needs an API rework of convert_clear_values + let mut clear_values_copy = clear_values.clone().enumerate(); // TODO: Proper errors for clear value errors instead of panics + + for (atch_i, atch_desc) in framebuffer.attachment_descs().enumerate() { + match clear_values_copy.next() { + Some((clear_i, clear_value)) => { + if atch_desc.load == LoadOp::Clear { + match clear_value { + ClearValue::None => panic!("Bad ClearValue! index: {}, attachment index: {}, expected: {:?}, got: None", + clear_i, atch_i, atch_desc.format.ty()), + ClearValue::Float(_) => if atch_desc.format.ty() != FormatTy::Float { + panic!("Bad ClearValue! index: {}, attachment index: {}, expected: {:?}, got: Float", + clear_i, atch_i, atch_desc.format.ty()); + } + ClearValue::Int(_) => if atch_desc.format.ty() != FormatTy::Sint { + panic!("Bad ClearValue! index: {}, attachment index: {}, expected: {:?}, got: Int", + clear_i, atch_i, atch_desc.format.ty()); + } + ClearValue::Uint(_) => if atch_desc.format.ty() != FormatTy::Uint { + panic!("Bad ClearValue! index: {}, attachment index: {}, expected: {:?}, got: Uint", + clear_i, atch_i, atch_desc.format.ty()); + } + ClearValue::Depth(_) => if atch_desc.format.ty() != FormatTy::Depth { + panic!("Bad ClearValue! index: {}, attachment index: {}, expected: {:?}, got: Depth", + clear_i, atch_i, atch_desc.format.ty()); + } + ClearValue::Stencil(_) => if atch_desc.format.ty() != FormatTy::Stencil { + panic!("Bad ClearValue! index: {}, attachment index: {}, expected: {:?}, got: Stencil", + clear_i, atch_i, atch_desc.format.ty()); + } + ClearValue::DepthStencil(_) => if atch_desc.format.ty() != FormatTy::DepthStencil { + panic!("Bad ClearValue! index: {}, attachment index: {}, expected: {:?}, got: DepthStencil", + clear_i, atch_i, atch_desc.format.ty()); + } + } + } + else { + if clear_value != ClearValue::None { + panic!("Bad ClearValue! index: {}, attachment index: {}, expected: None, got: {:?}", + clear_i, atch_i, clear_value); + } + } + } + None => panic!("Not enough clear values") + } + } + + if clear_values_copy.count() != 0 { + panic!("Too many clear values") + } + + let contents = if secondary { + SubpassContents::SecondaryCommandBuffers + } else { + SubpassContents::Inline + }; + self.inner + .begin_render_pass(framebuffer.clone(), contents, clear_values)?; + self.render_pass = Some((Box::new(framebuffer) as Box<_>, 0)); + self.subpass_secondary = secondary; + Ok(self) + } + } + + /// Adds a command that copies an image to another. + /// + /// Copy operations have several restrictions: + /// + /// - Copy operations are only allowed on queue families that support transfer, graphics, or + /// compute operations. + /// - The number of samples in the source and destination images must be equal. + /// - The size of the uncompressed element format of the source image must be equal to the + /// compressed element format of the destination. + /// - If you copy between depth, stencil or depth-stencil images, the format of both images + /// must match exactly. + /// - For two-dimensional images, the Z coordinate must be 0 for the image offsets and 1 for + /// the extent. Same for the Y coordinate for one-dimensional images. + /// - For non-array images, the base array layer must be 0 and the number of layers must be 1. + /// + /// If `layer_count` is greater than 1, the copy will happen between each individual layer as + /// if they were separate images. + /// + /// # Panic + /// + /// - Panics if the source or the destination was not created with `device`. + /// + pub fn copy_image<S, D>(mut self, source: S, source_offset: [i32; 3], + source_base_array_layer: u32, source_mip_level: u32, + destination: D, destination_offset: [i32; 3], + destination_base_array_layer: u32, destination_mip_level: u32, + extent: [u32; 3], layer_count: u32) + -> Result<Self, CopyImageError> + where S: ImageAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static + { + unsafe { + self.ensure_outside_render_pass()?; + + check_copy_image(self.device(), + &source, + source_offset, + source_base_array_layer, + source_mip_level, + &destination, + destination_offset, + destination_base_array_layer, + destination_mip_level, + extent, + layer_count)?; + + let copy = UnsafeCommandBufferBuilderImageCopy { + // TODO: Allowing choosing a subset of the image aspects, but note that if color + // is included, neither depth nor stencil may. + aspect: UnsafeCommandBufferBuilderImageAspect { + color: source.has_color(), + depth: !source.has_color() && + source.has_depth() && destination.has_depth(), + stencil: !source.has_color() && + source.has_stencil() && destination.has_stencil(), + }, + source_mip_level, + destination_mip_level, + source_base_array_layer, + destination_base_array_layer, + layer_count, + source_offset, + destination_offset, + extent, + }; + + // TODO: Allow choosing layouts, but note that only Transfer*Optimal and General are + // valid. + self.inner + .copy_image(source, ImageLayout::TransferSrcOptimal, + destination, ImageLayout::TransferDstOptimal, + iter::once(copy))?; + Ok(self) + } + } + + /// Adds a command that blits an image to another. + /// + /// A *blit* is similar to an image copy operation, except that the portion of the image that + /// is transferred can be resized. You choose an area of the source and an area of the + /// destination, and the implementation will resize the area of the source so that it matches + /// the size of the area of the destination before writing it. + /// + /// Blit operations have several restrictions: + /// + /// - Blit operations are only allowed on queue families that support graphics operations. + /// - The format of the source and destination images must support blit operations, which + /// depends on the Vulkan implementation. Vulkan guarantees that some specific formats must + /// always be supported. See tables 52 to 61 of the specifications. + /// - Only single-sampled images are allowed. + /// - You can only blit between two images whose formats belong to the same type. The types + /// are: floating-point, signed integers, unsigned integers, depth-stencil. + /// - If you blit between depth, stencil or depth-stencil images, the format of both images + /// must match exactly. + /// - If you blit between depth, stencil or depth-stencil images, only the `Nearest` filter is + /// allowed. + /// - For two-dimensional images, the Z coordinate must be 0 for the top-left offset and 1 for + /// the bottom-right offset. Same for the Y coordinate for one-dimensional images. + /// - For non-array images, the base array layer must be 0 and the number of layers must be 1. + /// + /// If `layer_count` is greater than 1, the blit will happen between each individual layer as + /// if they were separate images. + /// + /// # Panic + /// + /// - Panics if the source or the destination was not created with `device`. + /// + pub fn blit_image<S, D>(mut self, source: S, source_top_left: [i32; 3], + source_bottom_right: [i32; 3], source_base_array_layer: u32, + source_mip_level: u32, destination: D, destination_top_left: [i32; 3], + destination_bottom_right: [i32; 3], destination_base_array_layer: u32, + destination_mip_level: u32, layer_count: u32, filter: Filter) + -> Result<Self, BlitImageError> + where S: ImageAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static + { + unsafe { + if !self.graphics_allowed { + return Err(AutoCommandBufferBuilderContextError::NotSupportedByQueueFamily.into()); + } + + self.ensure_outside_render_pass()?; + + check_blit_image(self.device(), + &source, + source_top_left, + source_bottom_right, + source_base_array_layer, + source_mip_level, + &destination, + destination_top_left, + destination_bottom_right, + destination_base_array_layer, + destination_mip_level, + layer_count, + filter)?; + + let blit = UnsafeCommandBufferBuilderImageBlit { + // TODO: + aspect: if source.has_color() { + UnsafeCommandBufferBuilderImageAspect { + color: true, + depth: false, + stencil: false, + } + } else { + unimplemented!() + }, + source_mip_level, + destination_mip_level, + source_base_array_layer, + destination_base_array_layer, + layer_count, + source_top_left, + source_bottom_right, + destination_top_left, + destination_bottom_right, + }; + + self.inner + .blit_image(source, + ImageLayout::TransferSrcOptimal, + destination, // TODO: let choose layout + ImageLayout::TransferDstOptimal, + iter::once(blit), + filter)?; + Ok(self) + } + } + + /// Adds a command that clears all the layers and mipmap levels of a color image with a + /// specific value. + /// + /// # Panic + /// + /// Panics if `color` is not a color value. + /// + pub fn clear_color_image<I>(self, image: I, color: ClearValue) + -> Result<Self, ClearColorImageError> + where I: ImageAccess + Send + Sync + 'static + { + let layers = image.dimensions().array_layers(); + let levels = image.mipmap_levels(); + + self.clear_color_image_dimensions(image, 0, layers, 0, levels, color) + } + + /// Adds a command that clears a color image with a specific value. + /// + /// # Panic + /// + /// - Panics if `color` is not a color value. + /// + pub fn clear_color_image_dimensions<I>(mut self, image: I, first_layer: u32, num_layers: u32, + first_mipmap: u32, num_mipmaps: u32, color: ClearValue) + -> Result<Self, ClearColorImageError> + where I: ImageAccess + Send + Sync + 'static + { + unsafe { + if !self.graphics_allowed && !self.compute_allowed { + return Err(AutoCommandBufferBuilderContextError::NotSupportedByQueueFamily.into()); + } + + self.ensure_outside_render_pass()?; + check_clear_color_image(self.device(), + &image, + first_layer, + num_layers, + first_mipmap, + num_mipmaps)?; + + match color { + ClearValue::Float(_) | + ClearValue::Int(_) | + ClearValue::Uint(_) => {}, + _ => panic!("The clear color is not a color value"), + }; + + let region = UnsafeCommandBufferBuilderColorImageClear { + base_mip_level: first_mipmap, + level_count: num_mipmaps, + base_array_layer: first_layer, + layer_count: num_layers, + }; + + // TODO: let choose layout + self.inner + .clear_color_image(image, + ImageLayout::TransferDstOptimal, + color, + iter::once(region))?; + Ok(self) + } + } + + /// Adds a command that copies from a buffer to another. + /// + /// This command will copy from the source to the destination. If their size is not equal, then + /// the amount of data copied is equal to the smallest of the two. + #[inline] + pub fn copy_buffer<S, D, T>(mut self, source: S, destination: D) + -> Result<Self, CopyBufferError> + where S: TypedBufferAccess<Content = T> + Send + Sync + 'static, + D: TypedBufferAccess<Content = T> + Send + Sync + 'static, + T: ?Sized + { + unsafe { + self.ensure_outside_render_pass()?; + let infos = check_copy_buffer(self.device(), &source, &destination)?; + self.inner + .copy_buffer(source, destination, iter::once((0, 0, infos.copy_size)))?; + Ok(self) + } + } + + /// Adds a command that copies from a buffer to an image. + pub fn copy_buffer_to_image<S, D, Px>(self, source: S, destination: D) + -> Result<Self, CopyBufferImageError> + where S: TypedBufferAccess<Content = [Px]> + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static, + Format: AcceptsPixels<Px> + { + self.ensure_outside_render_pass()?; + + let dims = destination.dimensions().width_height_depth(); + self.copy_buffer_to_image_dimensions(source, destination, [0, 0, 0], dims, 0, 1, 0) + } + + /// Adds a command that copies from a buffer to an image. + pub fn copy_buffer_to_image_dimensions<S, D, Px>(mut self, source: S, destination: D, + offset: [u32; 3], size: [u32; 3], + first_layer: u32, num_layers: u32, mipmap: u32) + -> Result<Self, CopyBufferImageError> + where S: TypedBufferAccess<Content = [Px]> + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static, + Format: AcceptsPixels<Px> + { + unsafe { + self.ensure_outside_render_pass()?; + + check_copy_buffer_image(self.device(), + &source, + &destination, + CheckCopyBufferImageTy::BufferToImage, + offset, + size, + first_layer, + num_layers, + mipmap)?; + + let copy = UnsafeCommandBufferBuilderBufferImageCopy { + buffer_offset: 0, + buffer_row_length: 0, + buffer_image_height: 0, + image_aspect: if destination.has_color() { + UnsafeCommandBufferBuilderImageAspect { + color: true, + depth: false, + stencil: false, + } + } else { + unimplemented!() + }, + image_mip_level: mipmap, + image_base_array_layer: first_layer, + image_layer_count: num_layers, + image_offset: [offset[0] as i32, offset[1] as i32, offset[2] as i32], + image_extent: size, + }; + + self.inner + .copy_buffer_to_image(source, + destination, + ImageLayout::TransferDstOptimal, // TODO: let choose layout + iter::once(copy))?; + Ok(self) + } + } + + /// Adds a command that copies from an image to a buffer. + pub fn copy_image_to_buffer<S, D, Px>(self, source: S, destination: D) + -> Result<Self, CopyBufferImageError> + where S: ImageAccess + Send + Sync + 'static, + D: TypedBufferAccess<Content = [Px]> + Send + Sync + 'static, + Format: AcceptsPixels<Px> + { + self.ensure_outside_render_pass()?; + + let dims = source.dimensions().width_height_depth(); + self.copy_image_to_buffer_dimensions(source, destination, [0, 0, 0], dims, 0, 1, 0) + } + + /// Adds a command that copies from an image to a buffer. + pub fn copy_image_to_buffer_dimensions<S, D, Px>(mut self, source: S, destination: D, + offset: [u32; 3], size: [u32; 3], + first_layer: u32, num_layers: u32, mipmap: u32) + -> Result<Self, CopyBufferImageError> + where S: ImageAccess + Send + Sync + 'static, + D: TypedBufferAccess<Content = [Px]> + Send + Sync + 'static, + Format: AcceptsPixels<Px> + { + unsafe { + self.ensure_outside_render_pass()?; + + check_copy_buffer_image(self.device(), + &destination, + &source, + CheckCopyBufferImageTy::ImageToBuffer, + offset, + size, + first_layer, + num_layers, + mipmap)?; + + let copy = UnsafeCommandBufferBuilderBufferImageCopy { + buffer_offset: 0, + buffer_row_length: 0, + buffer_image_height: 0, + image_aspect: UnsafeCommandBufferBuilderImageAspect { + color: source.has_color(), + depth: source.has_depth(), + stencil: source.has_stencil() + }, + image_mip_level: mipmap, + image_base_array_layer: first_layer, + image_layer_count: num_layers, + image_offset: [offset[0] as i32, offset[1] as i32, offset[2] as i32], + image_extent: size, + }; + + self.inner + .copy_image_to_buffer(source, + ImageLayout::TransferSrcOptimal, + destination, // TODO: let choose layout + iter::once(copy))?; + Ok(self) + } + } + + #[inline] + pub fn dispatch<Cp, S, Pc>(mut self, dimensions: [u32; 3], pipeline: Cp, sets: S, constants: Pc) + -> Result<Self, DispatchError> + where Cp: ComputePipelineAbstract + Send + Sync + 'static + Clone, // TODO: meh for Clone + S: DescriptorSetsCollection + { + unsafe { + if !self.compute_allowed { + return Err(AutoCommandBufferBuilderContextError::NotSupportedByQueueFamily.into()); + } + + self.ensure_outside_render_pass()?; + check_push_constants_validity(&pipeline, &constants)?; + check_descriptor_sets_validity(&pipeline, &sets)?; + check_dispatch(pipeline.device(), dimensions)?; + + if let StateCacherOutcome::NeedChange = + self.state_cacher.bind_compute_pipeline(&pipeline) + { + self.inner.bind_pipeline_compute(pipeline.clone()); + } + + push_constants(&mut self.inner, pipeline.clone(), constants); + descriptor_sets(&mut self.inner, + &mut self.state_cacher, + false, + pipeline.clone(), + sets)?; + + self.inner.dispatch(dimensions); + Ok(self) + } + } + + /// Draw once, using the `vertex_buffer`. + /// + /// To use only some data in the buffer, wrap it in a `vulkano::buffer::BufferSlice`. + #[inline] + pub fn draw<V, Gp, S, Pc>(mut self, pipeline: Gp, dynamic: &DynamicState, vertex_buffer: V, sets: S, + constants: Pc) + -> Result<Self, DrawError> + where Gp: GraphicsPipelineAbstract + VertexSource<V> + Send + Sync + 'static + Clone, // TODO: meh for Clone + S: DescriptorSetsCollection + { + unsafe { + // TODO: must check that pipeline is compatible with render pass + + self.ensure_inside_render_pass_inline(&pipeline)?; + check_dynamic_state_validity(&pipeline, dynamic)?; + check_push_constants_validity(&pipeline, &constants)?; + check_descriptor_sets_validity(&pipeline, &sets)?; + let vb_infos = check_vertex_buffers(&pipeline, vertex_buffer)?; + + if let StateCacherOutcome::NeedChange = + self.state_cacher.bind_graphics_pipeline(&pipeline) + { + self.inner.bind_pipeline_graphics(pipeline.clone()); + } + + let dynamic = self.state_cacher.dynamic_state(dynamic); + + push_constants(&mut self.inner, pipeline.clone(), constants); + set_state(&mut self.inner, &dynamic); + descriptor_sets(&mut self.inner, + &mut self.state_cacher, + true, + pipeline.clone(), + sets)?; + vertex_buffers(&mut self.inner, + &mut self.state_cacher, + vb_infos.vertex_buffers)?; + + debug_assert!(self.graphics_allowed); + + self.inner.draw(vb_infos.vertex_count as u32, + vb_infos.instance_count as u32, + 0, + 0); + Ok(self) + } + } + + /// Draw once, using the `vertex_buffer` and the `index_buffer`. + /// + /// To use only some data in a buffer, wrap it in a `vulkano::buffer::BufferSlice`. + #[inline] + pub fn draw_indexed<V, Gp, S, Pc, Ib, I>(mut self, pipeline: Gp, dynamic: &DynamicState, + vertex_buffer: V, index_buffer: Ib, sets: S, constants: Pc) + -> Result<Self, DrawIndexedError> + where Gp: GraphicsPipelineAbstract + VertexSource<V> + Send + Sync + 'static + Clone, // TODO: meh for Clone + S: DescriptorSetsCollection, + Ib: BufferAccess + TypedBufferAccess<Content = [I]> + Send + Sync + 'static, + I: Index + 'static + { + unsafe { + // TODO: must check that pipeline is compatible with render pass + + self.ensure_inside_render_pass_inline(&pipeline)?; + let ib_infos = check_index_buffer(self.device(), &index_buffer)?; + check_dynamic_state_validity(&pipeline, dynamic)?; + check_push_constants_validity(&pipeline, &constants)?; + check_descriptor_sets_validity(&pipeline, &sets)?; + let vb_infos = check_vertex_buffers(&pipeline, vertex_buffer)?; + + if let StateCacherOutcome::NeedChange = + self.state_cacher.bind_graphics_pipeline(&pipeline) + { + self.inner.bind_pipeline_graphics(pipeline.clone()); + } + + if let StateCacherOutcome::NeedChange = + self.state_cacher.bind_index_buffer(&index_buffer, I::ty()) + { + self.inner.bind_index_buffer(index_buffer, I::ty())?; + } + + let dynamic = self.state_cacher.dynamic_state(dynamic); + + push_constants(&mut self.inner, pipeline.clone(), constants); + set_state(&mut self.inner, &dynamic); + descriptor_sets(&mut self.inner, + &mut self.state_cacher, + true, + pipeline.clone(), + sets)?; + vertex_buffers(&mut self.inner, + &mut self.state_cacher, + vb_infos.vertex_buffers)?; + // TODO: how to handle an index out of range of the vertex buffers? + + debug_assert!(self.graphics_allowed); + + self.inner + .draw_indexed(ib_infos.num_indices as u32, + vb_infos.instance_count as u32, + 0, + 0, + 0); + Ok(self) + } + } + + /// Performs multiple draws, one draw for each `vulkano::command_buffer::DrawIndirectCommand` struct in `indirect_buffer`. + /// The `vertex_buffer` is used by all draws. + /// + /// To use only some data in a buffer, wrap it in a `vulkano::buffer::BufferSlice`. + #[inline] + pub fn draw_indirect<V, Gp, S, Pc, Ib>(mut self, pipeline: Gp, dynamic: &DynamicState, + vertex_buffer: V, indirect_buffer: Ib, sets: S, constants: Pc) + -> Result<Self, DrawIndirectError> + where Gp: GraphicsPipelineAbstract + VertexSource<V> + Send + Sync + 'static + Clone, // TODO: meh for Clone + S: DescriptorSetsCollection, + Ib: BufferAccess + + TypedBufferAccess<Content = [DrawIndirectCommand]> + + Send + + Sync + + 'static + { + unsafe { + // TODO: must check that pipeline is compatible with render pass + + self.ensure_inside_render_pass_inline(&pipeline)?; + check_dynamic_state_validity(&pipeline, dynamic)?; + check_push_constants_validity(&pipeline, &constants)?; + check_descriptor_sets_validity(&pipeline, &sets)?; + let vb_infos = check_vertex_buffers(&pipeline, vertex_buffer)?; + + let draw_count = indirect_buffer.len() as u32; + + if let StateCacherOutcome::NeedChange = + self.state_cacher.bind_graphics_pipeline(&pipeline) + { + self.inner.bind_pipeline_graphics(pipeline.clone()); + } + + let dynamic = self.state_cacher.dynamic_state(dynamic); + + push_constants(&mut self.inner, pipeline.clone(), constants); + set_state(&mut self.inner, &dynamic); + descriptor_sets(&mut self.inner, + &mut self.state_cacher, + true, + pipeline.clone(), + sets)?; + vertex_buffers(&mut self.inner, + &mut self.state_cacher, + vb_infos.vertex_buffers)?; + + debug_assert!(self.graphics_allowed); + + self.inner + .draw_indirect(indirect_buffer, + draw_count, + mem::size_of::<DrawIndirectCommand>() as u32)?; + Ok(self) + } + } + + /// Performs multiple draws, one draw for each `vulkano::command_buffer::DrawIndexedIndirectCommand` struct in `indirect_buffer`. + /// The `index_buffer` and `vertex_buffer` are used by all draws. + /// + /// To use only some data in a buffer, wrap it in a `vulkano::buffer::BufferSlice`. + #[inline] + pub fn draw_indexed_indirect<V, Gp, S, Pc, Ib, Inb, I>(mut self, pipeline: Gp, dynamic: &DynamicState, + vertex_buffer: V, index_buffer: Ib, indirect_buffer: Inb, sets: S, constants: Pc) + -> Result<Self, DrawIndexedIndirectError> + where Gp: GraphicsPipelineAbstract + VertexSource<V> + Send + Sync + 'static + Clone, // TODO: meh for Clone + S: DescriptorSetsCollection, + Ib: BufferAccess + TypedBufferAccess<Content = [I]> + Send + Sync + 'static, + Inb: BufferAccess + + TypedBufferAccess<Content = [DrawIndexedIndirectCommand]> + + Send + + Sync + + 'static, + I: Index + 'static + { + unsafe { + // TODO: must check that pipeline is compatible with render pass + + self.ensure_inside_render_pass_inline(&pipeline)?; + let ib_infos = check_index_buffer(self.device(), &index_buffer)?; + check_dynamic_state_validity(&pipeline, dynamic)?; + check_push_constants_validity(&pipeline, &constants)?; + check_descriptor_sets_validity(&pipeline, &sets)?; + let vb_infos = check_vertex_buffers(&pipeline, vertex_buffer)?; + + let draw_count = indirect_buffer.len() as u32; + + if let StateCacherOutcome::NeedChange = + self.state_cacher.bind_graphics_pipeline(&pipeline) + { + self.inner.bind_pipeline_graphics(pipeline.clone()); + } + + if let StateCacherOutcome::NeedChange = + self.state_cacher.bind_index_buffer(&index_buffer, I::ty()) + { + self.inner.bind_index_buffer(index_buffer, I::ty())?; + } + + let dynamic = self.state_cacher.dynamic_state(dynamic); + + push_constants(&mut self.inner, pipeline.clone(), constants); + set_state(&mut self.inner, &dynamic); + descriptor_sets(&mut self.inner, + &mut self.state_cacher, + true, + pipeline.clone(), + sets)?; + vertex_buffers(&mut self.inner, + &mut self.state_cacher, + vb_infos.vertex_buffers)?; + + debug_assert!(self.graphics_allowed); + + self.inner + .draw_indexed_indirect(indirect_buffer, + draw_count, + mem::size_of::<DrawIndexedIndirectCommand>() as u32)?; + Ok(self) + } + } + + /// Adds a command that ends the current render pass. + /// + /// This must be called after you went through all the subpasses and before you can build + /// the command buffer or add further commands. + #[inline] + pub fn end_render_pass(mut self) -> Result<Self, AutoCommandBufferBuilderContextError> { + unsafe { + if self.secondary_cb { + return Err(AutoCommandBufferBuilderContextError::ForbiddenInSecondary); + } + + match self.render_pass { + Some((ref rp, index)) if rp.num_subpasses() as u32 == index + 1 => (), + None => { + return Err(AutoCommandBufferBuilderContextError::ForbiddenOutsideRenderPass); + }, + Some((ref rp, index)) => { + return Err(AutoCommandBufferBuilderContextError::NumSubpassesMismatch { + actual: rp.num_subpasses() as u32, + current: index, + }); + }, + } + + debug_assert!(self.graphics_allowed); + + self.inner.end_render_pass(); + self.render_pass = None; + Ok(self) + } + } + + /// Adds a command that executes a secondary command buffer. + /// + /// **This function is unsafe for now because safety checks and synchronization are not + /// implemented.** + // TODO: implement correctly + pub unsafe fn execute_commands<C>(mut self, command_buffer: C) + -> Result<Self, ExecuteCommandsError> + where C: CommandBuffer + Send + Sync + 'static + { + { + let mut builder = self.inner.execute_commands(); + builder.add(command_buffer); + builder.submit()?; + } + + self.state_cacher.invalidate(); + + Ok(self) + } + + /// Adds a command that writes the content of a buffer. + /// + /// This function is similar to the `memset` function in C. The `data` parameter is a number + /// that will be repeatedly written through the entire buffer. + /// + /// > **Note**: This function is technically safe because buffers can only contain integers or + /// > floating point numbers, which are always valid whatever their memory representation is. + /// > But unless your buffer actually contains only 32-bits integers, you are encouraged to use + /// > this function only for zeroing the content of a buffer by passing `0` for the data. + // TODO: not safe because of signalling NaNs + #[inline] + pub fn fill_buffer<B>(mut self, buffer: B, data: u32) -> Result<Self, FillBufferError> + where B: BufferAccess + Send + Sync + 'static + { + unsafe { + self.ensure_outside_render_pass()?; + check_fill_buffer(self.device(), &buffer)?; + self.inner.fill_buffer(buffer, data); + Ok(self) + } + } + + /// Adds a command that jumps to the next subpass of the current render pass. + #[inline] + pub fn next_subpass(mut self, secondary: bool) + -> Result<Self, AutoCommandBufferBuilderContextError> { + unsafe { + if self.secondary_cb { + return Err(AutoCommandBufferBuilderContextError::ForbiddenInSecondary); + } + + match self.render_pass { + None => { + return Err(AutoCommandBufferBuilderContextError::ForbiddenOutsideRenderPass); + }, + Some((ref rp, ref mut index)) => { + if *index + 1 >= rp.num_subpasses() as u32 { + return Err(AutoCommandBufferBuilderContextError::NumSubpassesMismatch { + actual: rp.num_subpasses() as u32, + current: *index, + }); + } else { + *index += 1; + } + }, + }; + + self.subpass_secondary = secondary; + + debug_assert!(self.graphics_allowed); + + let contents = if secondary { + SubpassContents::SecondaryCommandBuffers + } else { + SubpassContents::Inline + }; + self.inner.next_subpass(contents); + Ok(self) + } + } + + /// Adds a command that writes data to a buffer. + /// + /// If `data` is larger than the buffer, only the part of `data` that fits is written. If the + /// buffer is larger than `data`, only the start of the buffer is written. + // TODO: allow unsized values + #[inline] + pub fn update_buffer<B, D>(mut self, buffer: B, data: D) -> Result<Self, UpdateBufferError> + where B: TypedBufferAccess<Content = D> + Send + Sync + 'static, + D: Send + Sync + 'static + { + unsafe { + self.ensure_outside_render_pass()?; + check_update_buffer(self.device(), &buffer, &data)?; + + let size_of_data = mem::size_of_val(&data); + if buffer.size() >= size_of_data { + self.inner.update_buffer(buffer, data); + } else { + unimplemented!() // TODO: + //self.inner.update_buffer(buffer.slice(0 .. size_of_data), data); + } + + Ok(self) + } + } +} + +unsafe impl<P> DeviceOwned for AutoCommandBufferBuilder<P> { + #[inline] + fn device(&self) -> &Arc<Device> { + self.inner.device() + } +} + +// Shortcut function to set the push constants. +unsafe fn push_constants<P, Pl, Pc>(destination: &mut SyncCommandBufferBuilder<P>, pipeline: Pl, + push_constants: Pc) + where Pl: PipelineLayoutAbstract + Send + Sync + Clone + 'static +{ + for num_range in 0 .. pipeline.num_push_constants_ranges() { + let range = match pipeline.push_constants_range(num_range) { + Some(r) => r, + None => continue, + }; + + debug_assert_eq!(range.offset % 4, 0); + debug_assert_eq!(range.size % 4, 0); + + let data = slice::from_raw_parts((&push_constants as *const Pc as *const u8) + .offset(range.offset as isize), + range.size as usize); + + destination.push_constants::<_, [u8]>(pipeline.clone(), + range.stages, + range.offset as u32, + range.size as u32, + data); + } +} + +// Shortcut function to change the state of the pipeline. +unsafe fn set_state<P>(destination: &mut SyncCommandBufferBuilder<P>, dynamic: &DynamicState) { + if let Some(line_width) = dynamic.line_width { + destination.set_line_width(line_width); + } + + if let Some(ref viewports) = dynamic.viewports { + destination.set_viewport(0, viewports.iter().cloned().collect::<Vec<_>>().into_iter()); // TODO: don't collect + } + + if let Some(ref scissors) = dynamic.scissors { + destination.set_scissor(0, scissors.iter().cloned().collect::<Vec<_>>().into_iter()); // TODO: don't collect + } +} + +// Shortcut function to bind vertex buffers. +unsafe fn vertex_buffers<P>(destination: &mut SyncCommandBufferBuilder<P>, + state_cacher: &mut StateCacher, + vertex_buffers: Vec<Box<BufferAccess + Send + Sync>>) + -> Result<(), SyncCommandBufferBuilderError> { + let binding_range = { + let mut compare = state_cacher.bind_vertex_buffers(); + for vb in vertex_buffers.iter() { + compare.add(vb); + } + match compare.compare() { + Some(r) => r, + None => return Ok(()), + } + }; + + let first_binding = binding_range.start; + let num_bindings = binding_range.end - binding_range.start; + + let mut binder = destination.bind_vertex_buffers(); + for vb in vertex_buffers + .into_iter() + .skip(first_binding as usize) + .take(num_bindings as usize) + { + binder.add(vb); + } + binder.submit(first_binding)?; + Ok(()) +} + +unsafe fn descriptor_sets<P, Pl, S>(destination: &mut SyncCommandBufferBuilder<P>, + state_cacher: &mut StateCacher, gfx: bool, pipeline: Pl, + sets: S) + -> Result<(), SyncCommandBufferBuilderError> + where Pl: PipelineLayoutAbstract + Send + Sync + Clone + 'static, + S: DescriptorSetsCollection +{ + let sets = sets.into_vec(); + + let first_binding = { + let mut compare = state_cacher.bind_descriptor_sets(gfx); + for set in sets.iter() { + compare.add(set); + } + compare.compare() + }; + + let first_binding = match first_binding { + None => return Ok(()), + Some(fb) => fb, + }; + + let mut sets_binder = destination.bind_descriptor_sets(); + for set in sets.into_iter().skip(first_binding as usize) { + sets_binder.add(set); + } + sets_binder + .submit(gfx, pipeline.clone(), first_binding, iter::empty())?; + Ok(()) +} + +pub struct AutoCommandBuffer<P = StandardCommandPoolAlloc> { + inner: SyncCommandBuffer<P>, + + // Tracks usage of the command buffer on the GPU. + submit_state: SubmitState, +} + +// Whether the command buffer can be submitted. +#[derive(Debug)] +enum SubmitState { + // The command buffer was created with the "SimultaneousUse" flag. Can always be submitted at + // any time. + Concurrent, + + // The command buffer can only be submitted once simultaneously. + ExclusiveUse { + // True if the command buffer is current in use by the GPU. + in_use: AtomicBool, + }, + + // The command buffer can only ever be submitted once. + OneTime { + // True if the command buffer has already been submitted once and can be no longer be + // submitted. + already_submitted: AtomicBool, + }, +} + +unsafe impl<P> CommandBuffer for AutoCommandBuffer<P> { + type PoolAlloc = P; + + #[inline] + fn inner(&self) -> &UnsafeCommandBuffer<P> { + self.inner.as_ref() + } + + #[inline] + fn lock_submit(&self, future: &GpuFuture, queue: &Queue) -> Result<(), CommandBufferExecError> { + match self.submit_state { + SubmitState::OneTime { ref already_submitted } => { + let was_already_submitted = already_submitted.swap(true, Ordering::SeqCst); + if was_already_submitted { + return Err(CommandBufferExecError::OneTimeSubmitAlreadySubmitted); + } + }, + SubmitState::ExclusiveUse { ref in_use } => { + let already_in_use = in_use.swap(true, Ordering::SeqCst); + if already_in_use { + return Err(CommandBufferExecError::ExclusiveAlreadyInUse); + } + }, + SubmitState::Concurrent => (), + }; + + let err = match self.inner.lock_submit(future, queue) { + Ok(()) => return Ok(()), + Err(err) => err, + }; + + // If `self.inner.lock_submit()` failed, we revert action. + match self.submit_state { + SubmitState::OneTime { ref already_submitted } => { + already_submitted.store(false, Ordering::SeqCst); + }, + SubmitState::ExclusiveUse { ref in_use } => { + in_use.store(false, Ordering::SeqCst); + }, + SubmitState::Concurrent => (), + }; + + Err(err) + } + + #[inline] + unsafe fn unlock(&self) { + // Because of panic safety, we unlock the inner command buffer first. + self.inner.unlock(); + + match self.submit_state { + SubmitState::OneTime { ref already_submitted } => { + debug_assert!(already_submitted.load(Ordering::SeqCst)); + }, + SubmitState::ExclusiveUse { ref in_use } => { + let old_val = in_use.swap(false, Ordering::SeqCst); + debug_assert!(old_val); + }, + SubmitState::Concurrent => (), + }; + } + + #[inline] + fn check_buffer_access( + &self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + self.inner.check_buffer_access(buffer, exclusive, queue) + } + + #[inline] + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + self.inner + .check_image_access(image, layout, exclusive, queue) + } +} + +unsafe impl<P> DeviceOwned for AutoCommandBuffer<P> { + #[inline] + fn device(&self) -> &Arc<Device> { + self.inner.device() + } +} + +macro_rules! err_gen { + ($name:ident { $($err:ident,)+ }) => ( + #[derive(Debug, Clone)] + pub enum $name { + $( + $err($err), + )+ + } + + impl error::Error for $name { + #[inline] + fn description(&self) -> &str { + match *self { + $( + $name::$err(_) => { + concat!("a ", stringify!($err)) + } + )+ + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + $( + $name::$err(ref err) => Some(err), + )+ + } + } + } + + impl fmt::Display for $name { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } + } + + $( + impl From<$err> for $name { + #[inline] + fn from(err: $err) -> $name { + $name::$err(err) + } + } + )+ + ); +} + +err_gen!(BuildError { + AutoCommandBufferBuilderContextError, + OomError, + }); + +err_gen!(BeginRenderPassError { + AutoCommandBufferBuilderContextError, + SyncCommandBufferBuilderError, + }); + +err_gen!(CopyImageError { + AutoCommandBufferBuilderContextError, + CheckCopyImageError, + SyncCommandBufferBuilderError, + }); + +err_gen!(BlitImageError { + AutoCommandBufferBuilderContextError, + CheckBlitImageError, + SyncCommandBufferBuilderError, + }); + +err_gen!(ClearColorImageError { + AutoCommandBufferBuilderContextError, + CheckClearColorImageError, + SyncCommandBufferBuilderError, + }); + +err_gen!(CopyBufferError { + AutoCommandBufferBuilderContextError, + CheckCopyBufferError, + SyncCommandBufferBuilderError, + }); + +err_gen!(CopyBufferImageError { + AutoCommandBufferBuilderContextError, + CheckCopyBufferImageError, + SyncCommandBufferBuilderError, + }); + +err_gen!(FillBufferError { + AutoCommandBufferBuilderContextError, + CheckFillBufferError, + }); + +err_gen!(DispatchError { + AutoCommandBufferBuilderContextError, + CheckPushConstantsValidityError, + CheckDescriptorSetsValidityError, + CheckDispatchError, + SyncCommandBufferBuilderError, + }); + +err_gen!(DrawError { + AutoCommandBufferBuilderContextError, + CheckDynamicStateValidityError, + CheckPushConstantsValidityError, + CheckDescriptorSetsValidityError, + CheckVertexBufferError, + SyncCommandBufferBuilderError, + }); + +err_gen!(DrawIndexedError { + AutoCommandBufferBuilderContextError, + CheckDynamicStateValidityError, + CheckPushConstantsValidityError, + CheckDescriptorSetsValidityError, + CheckVertexBufferError, + CheckIndexBufferError, + SyncCommandBufferBuilderError, + }); + +err_gen!(DrawIndirectError { + AutoCommandBufferBuilderContextError, + CheckDynamicStateValidityError, + CheckPushConstantsValidityError, + CheckDescriptorSetsValidityError, + CheckVertexBufferError, + SyncCommandBufferBuilderError, + }); + +err_gen!(DrawIndexedIndirectError { + AutoCommandBufferBuilderContextError, + CheckDynamicStateValidityError, + CheckPushConstantsValidityError, + CheckDescriptorSetsValidityError, + CheckVertexBufferError, + CheckIndexBufferError, + SyncCommandBufferBuilderError, + }); + +err_gen!(ExecuteCommandsError { + AutoCommandBufferBuilderContextError, + SyncCommandBufferBuilderError, + }); + +err_gen!(UpdateBufferError { + AutoCommandBufferBuilderContextError, + CheckUpdateBufferError, + }); + +#[derive(Debug, Copy, Clone)] +pub enum AutoCommandBufferBuilderContextError { + /// Operation forbidden in a secondary command buffer. + ForbiddenInSecondary, + /// Operation forbidden inside of a render pass. + ForbiddenInsideRenderPass, + /// Operation forbidden outside of a render pass. + ForbiddenOutsideRenderPass, + /// The queue family doesn't allow this operation. + NotSupportedByQueueFamily, + /// Tried to end a render pass with subpasses remaining, or tried to go to next subpass with no + /// subpass remaining. + NumSubpassesMismatch { + /// Actual number of subpasses in the current render pass. + actual: u32, + /// Current subpass index before the failing command. + current: u32, + }, + /// Tried to execute a secondary command buffer inside a subpass that only allows inline + /// commands, or a draw command in a subpass that only allows secondary command buffers. + WrongSubpassType, + /// Tried to use a graphics pipeline whose subpass index didn't match the current subpass + /// index. + WrongSubpassIndex, + /// Tried to use a graphics pipeline whose render pass is incompatible with the current render + /// pass. + IncompatibleRenderPass, +} + +impl error::Error for AutoCommandBufferBuilderContextError { + #[inline] + fn description(&self) -> &str { + match *self { + AutoCommandBufferBuilderContextError::ForbiddenInSecondary => { + "operation forbidden in a secondary command buffer" + }, + AutoCommandBufferBuilderContextError::ForbiddenInsideRenderPass => { + "operation forbidden inside of a render pass" + }, + AutoCommandBufferBuilderContextError::ForbiddenOutsideRenderPass => { + "operation forbidden outside of a render pass" + }, + AutoCommandBufferBuilderContextError::NotSupportedByQueueFamily => { + "the queue family doesn't allow this operation" + }, + AutoCommandBufferBuilderContextError::NumSubpassesMismatch { .. } => { + "tried to end a render pass with subpasses remaining, or tried to go to next \ + subpass with no subpass remaining" + }, + AutoCommandBufferBuilderContextError::WrongSubpassType => { + "tried to execute a secondary command buffer inside a subpass that only allows \ + inline commands, or a draw command in a subpass that only allows secondary \ + command buffers" + }, + AutoCommandBufferBuilderContextError::WrongSubpassIndex => { + "tried to use a graphics pipeline whose subpass index didn't match the current \ + subpass index" + }, + AutoCommandBufferBuilderContextError::IncompatibleRenderPass => { + "tried to use a graphics pipeline whose render pass is incompatible with the \ + current render pass" + }, + } + } +} + +impl fmt::Display for AutoCommandBufferBuilderContextError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/mod.rs new file mode 100644 index 0000000..358ea77 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/mod.rs @@ -0,0 +1,166 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Commands that the GPU will execute (includes draw commands). +//! +//! With Vulkan, before the GPU can do anything you must create a `CommandBuffer`. A command buffer +//! is a list of commands that will executed by the GPU. Once a command buffer is created, you can +//! execute it. A command buffer must always be created even for the most simple tasks. +//! +//! # Primary and secondary command buffers. +//! +//! There are three types of command buffers: +//! +//! - **Primary command buffers**. They can contain any command. They are the only type of command +//! buffer that can be submitted to a queue. +//! - **Secondary "graphics" command buffers**. They can only contain draw and clear commands. +//! They can only be called from a primary command buffer when inside a render pass. +//! - **Secondary "compute" command buffers**. They can only contain non-render-pass-related +//! commands (ie. everything but drawing, clearing, etc.) and cannot enter a render pass. They +//! can only be called from a primary command buffer outside of a render pass. +//! +//! Using secondary command buffers leads to slightly lower performance on the GPU, but they have +//! two advantages on the CPU side: +//! +//! - Building a command buffer is a single-threaded operation, but by using secondary command +//! buffers you can build multiple secondary command buffers in multiple threads simultaneously. +//! - Secondary command buffers can be kept alive between frames. When you always repeat the same +//! operations, it might be a good idea to build a secondary command buffer once at +//! initialization and then reuse it afterwards. +//! +//! # The `AutoCommandBufferBuilder` +//! +//! The most basic (and recommended) way to create a command buffer is to create a +//! [`AutoCommandBufferBuilder`](struct.AutoCommandBufferBuilder.html). Then use the +//! [`CommandBufferBuilder` trait](trait.CommandBufferBuilder.html) to add commands to it. +//! When you are done adding commands, use +//! [the `CommandBufferBuild` trait](trait.CommandBufferBuild.html) to obtain a +//! `AutoCommandBuffer`. +//! +//! Once built, use [the `CommandBuffer` trait](trait.CommandBuffer.html) to submit the command +//! buffer. Submitting a command buffer returns an object that implements the `GpuFuture` trait and +//! that represents the moment when the execution will end on the GPU. +//! +//! ``` +//! use vulkano::command_buffer::AutoCommandBufferBuilder; +//! use vulkano::command_buffer::CommandBuffer; +//! +//! # let device: std::sync::Arc<vulkano::device::Device> = return; +//! # let queue: std::sync::Arc<vulkano::device::Queue> = return; +//! let cb = AutoCommandBufferBuilder::new(device.clone(), queue.family()).unwrap() +//! // TODO: add an actual command to this example +//! .build().unwrap(); +//! +//! let _future = cb.execute(queue.clone()); +//! ``` +//! +//! # Internal architecture of vulkano +//! +//! The `commands_raw` and `commands_extra` modules contain structs that correspond to various +//! commands that can be added to command buffer builders. A command can be added to a command +//! buffer builder by using the `AddCommand<C>` trait, where `C` is the command struct. +//! +//! The `AutoCommandBufferBuilder` internally uses a `UnsafeCommandBufferBuilder` wrapped around +//! multiple layers. See the `cb` module for more information. +//! +//! Command pools are automatically handled by default, but vulkano also allows you to use +//! alternative command pool implementations and use them. See the `pool` module for more +//! information. + +pub use self::auto::AutoCommandBuffer; +pub use self::auto::AutoCommandBufferBuilder; +pub use self::auto::AutoCommandBufferBuilderContextError; +pub use self::auto::BeginRenderPassError; +pub use self::auto::BlitImageError; +pub use self::auto::BuildError; +pub use self::auto::ClearColorImageError; +pub use self::auto::CopyBufferError; +pub use self::auto::CopyBufferImageError; +pub use self::auto::CopyImageError; +pub use self::auto::DispatchError; +pub use self::auto::DrawError; +pub use self::auto::DrawIndexedError; +pub use self::auto::DrawIndexedIndirectError; +pub use self::auto::DrawIndirectError; +pub use self::auto::ExecuteCommandsError; +pub use self::auto::FillBufferError; +pub use self::auto::UpdateBufferError; +pub use self::state_cacher::StateCacher; +pub use self::state_cacher::StateCacherOutcome; +pub use self::traits::CommandBuffer; +pub use self::traits::CommandBufferExecError; +pub use self::traits::CommandBufferExecFuture; + +use pipeline::viewport::Scissor; +use pipeline::viewport::Viewport; + +pub mod pool; +pub mod submit; +pub mod synced; +pub mod sys; +pub mod validity; + +mod auto; +mod state_cacher; +mod traits; + +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct DrawIndirectCommand { + pub vertex_count: u32, + pub instance_count: u32, + pub first_vertex: u32, + pub first_instance: u32, +} + +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct DrawIndexedIndirectCommand { + pub index_count: u32, + pub instance_count: u32, + pub first_index: u32, + pub vertex_offset: u32, + pub first_instance: u32, +} + +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct DispatchIndirectCommand { + pub x: u32, + pub y: u32, + pub z: u32, +} + +/// The dynamic state to use for a draw command. +// TODO: probably not the right location +#[derive(Debug, Clone)] +pub struct DynamicState { + pub line_width: Option<f32>, + pub viewports: Option<Vec<Viewport>>, + pub scissors: Option<Vec<Scissor>>, + // TODO: missing fields +} + +impl DynamicState { + #[inline] + pub fn none() -> DynamicState { + DynamicState { + line_width: None, + viewports: None, + scissors: None, + } + } +} + +impl Default for DynamicState { + #[inline] + fn default() -> DynamicState { + DynamicState::none() + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/pool/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/pool/mod.rs new file mode 100644 index 0000000..988a8e3 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/pool/mod.rs @@ -0,0 +1,103 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! In the Vulkan API, command buffers must be allocated from *command pools*. +//! +//! A command pool holds and manages the memory of one or more command buffers. If you destroy a +//! command pool, all of its command buffers are automatically destroyed. +//! +//! In vulkano, creating a command buffer requires passing an implementation of the `CommandPool` +//! trait. By default vulkano will use the `StandardCommandPool` struct, but you can implement +//! this trait yourself by wrapping around the `UnsafeCommandPool` type. + +use instance::QueueFamily; + +use OomError; +use device::DeviceOwned; + +pub use self::standard::StandardCommandPool; +pub use self::sys::CommandPoolTrimError; +pub use self::sys::UnsafeCommandPool; +pub use self::sys::UnsafeCommandPoolAlloc; +pub use self::sys::UnsafeCommandPoolAllocIter; + +pub mod standard; +mod sys; + +/// Types that manage the memory of command buffers. +/// +/// # Safety +/// +/// A Vulkan command pool must be externally synchronized as if it owned the command buffers that +/// were allocated from it. This includes allocating from the pool, freeing from the pool, +/// resetting the pool or individual command buffers, and most importantly recording commands to +/// command buffers. +/// +/// The implementation of `CommandPool` is expected to manage this. For as long as a `Builder` +/// is alive, the trait implementation is expected to lock the pool that allocated the `Builder` +/// for the current thread. +/// +/// > **Note**: This may be modified in the future to allow different implementation strategies. +/// +/// The destructors of the `CommandPoolBuilderAlloc` and the `CommandPoolAlloc` are expected to +/// free the command buffer, reset the command buffer, or add it to a pool so that it gets reused. +/// If the implementation frees or resets the command buffer, it must not forget that this +/// operation must lock the pool. +/// +pub unsafe trait CommandPool: DeviceOwned { + /// See `alloc()`. + type Iter: Iterator<Item = Self::Builder>; + /// Represents a command buffer that has been allocated and that is currently being built. + type Builder: CommandPoolBuilderAlloc<Alloc = Self::Alloc>; + /// Represents a command buffer that has been allocated and that is pending execution or is + /// being executed. + type Alloc: CommandPoolAlloc; + + /// Allocates command buffers from this pool. + /// + /// Returns an iterator that contains an bunch of allocated command buffers. + fn alloc(&self, secondary: bool, count: u32) -> Result<Self::Iter, OomError>; + + /// Returns the queue family that this pool targets. + fn queue_family(&self) -> QueueFamily; +} + +/// A command buffer allocated from a pool and that can be recorded. +/// +/// # Safety +/// +/// See `CommandPool` for information about safety. +/// +pub unsafe trait CommandPoolBuilderAlloc: DeviceOwned { + /// Return type of `into_alloc`. + type Alloc: CommandPoolAlloc; + + /// Returns the internal object that contains the command buffer. + fn inner(&self) -> &UnsafeCommandPoolAlloc; + + /// Turns this builder into a command buffer that is pending execution. + fn into_alloc(self) -> Self::Alloc; + + /// Returns the queue family that the pool targets. + fn queue_family(&self) -> QueueFamily; +} + +/// A command buffer allocated from a pool that has finished being recorded. +/// +/// # Safety +/// +/// See `CommandPool` for information about safety. +/// +pub unsafe trait CommandPoolAlloc: DeviceOwned { + /// Returns the internal object that contains the command buffer. + fn inner(&self) -> &UnsafeCommandPoolAlloc; + + /// Returns the queue family that the pool targets. + fn queue_family(&self) -> QueueFamily; +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/pool/standard.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/pool/standard.rs new file mode 100644 index 0000000..a3a6a13 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/pool/standard.rs @@ -0,0 +1,316 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use crossbeam::queue::MsQueue; +use fnv::FnvHashMap; +use std::collections::hash_map::Entry; +use std::marker::PhantomData; +use std::mem::ManuallyDrop; +use std::ptr; +use std::sync::Arc; +use std::sync::Mutex; +use std::sync::Weak; +use std::thread; +use std::vec::IntoIter as VecIntoIter; + +use command_buffer::pool::CommandPool; +use command_buffer::pool::CommandPoolAlloc; +use command_buffer::pool::CommandPoolBuilderAlloc; +use command_buffer::pool::UnsafeCommandPool; +use command_buffer::pool::UnsafeCommandPoolAlloc; +use instance::QueueFamily; + +use OomError; +use VulkanObject; +use device::Device; +use device::DeviceOwned; + +/// Standard implementation of a command pool. +/// +/// It is guaranteed that the allocated command buffers keep the `Arc<StandardCommandPool>` alive. +/// This is desirable so that we can store a `Weak<StandardCommandPool>`. +/// +/// Will use one Vulkan pool per thread in order to avoid locking. Will try to reuse command +/// buffers. Command buffers can't be moved between threads during the building process, but +/// finished command buffers can. +pub struct StandardCommandPool { + // The device. + device: Arc<Device>, + + // Identifier of the queue family. + queue_family: u32, + + // For each thread, we store thread-specific info. + per_thread: Mutex<FnvHashMap<thread::ThreadId, Weak<StandardCommandPoolPerThread>>>, +} + +unsafe impl Send for StandardCommandPool { +} +unsafe impl Sync for StandardCommandPool { +} + +struct StandardCommandPoolPerThread { + // The Vulkan pool of this thread. + pool: Mutex<UnsafeCommandPool>, + // List of existing primary command buffers that are available for reuse. + available_primary_command_buffers: MsQueue<UnsafeCommandPoolAlloc>, + // List of existing secondary command buffers that are available for reuse. + available_secondary_command_buffers: MsQueue<UnsafeCommandPoolAlloc>, +} + +impl StandardCommandPool { + /// Builds a new pool. + /// + /// # Panic + /// + /// - Panics if the device and the queue family don't belong to the same physical device. + /// + pub fn new(device: Arc<Device>, queue_family: QueueFamily) -> StandardCommandPool { + assert_eq!(device.physical_device().internal_object(), + queue_family.physical_device().internal_object()); + + StandardCommandPool { + device: device, + queue_family: queue_family.id(), + per_thread: Mutex::new(Default::default()), + } + } +} + +unsafe impl CommandPool for Arc<StandardCommandPool> { + type Iter = VecIntoIter<StandardCommandPoolBuilder>; + type Builder = StandardCommandPoolBuilder; + type Alloc = StandardCommandPoolAlloc; + + fn alloc(&self, secondary: bool, count: u32) -> Result<Self::Iter, OomError> { + // Find the correct `StandardCommandPoolPerThread` structure. + let mut hashmap = self.per_thread.lock().unwrap(); + // TODO: meh for iterating everything every time + hashmap.retain(|_, w| w.upgrade().is_some()); + + // Get an appropriate `Arc<StandardCommandPoolPerThread>`. + let per_thread = match hashmap.entry(thread::current().id()) { + Entry::Occupied(entry) => { + // The `unwrap()` can't fail, since we retained only valid members earlier. + entry.get().upgrade().unwrap() + }, + Entry::Vacant(entry) => { + let new_pool = + UnsafeCommandPool::new(self.device.clone(), self.queue_family(), false, true)?; + let pt = Arc::new(StandardCommandPoolPerThread { + pool: Mutex::new(new_pool), + available_primary_command_buffers: MsQueue::new(), + available_secondary_command_buffers: MsQueue::new(), + }); + + entry.insert(Arc::downgrade(&pt)); + pt + }, + }; + + // The final output. + let mut output = Vec::with_capacity(count as usize); + + // First, pick from already-existing command buffers. + { + let existing = if secondary { + &per_thread.available_secondary_command_buffers + } else { + &per_thread.available_primary_command_buffers + }; + + for _ in 0 .. count as usize { + if let Some(cmd) = existing.try_pop() { + output.push(StandardCommandPoolBuilder { + inner: StandardCommandPoolAlloc { + cmd: ManuallyDrop::new(cmd), + pool: per_thread.clone(), + pool_parent: self.clone(), + secondary: secondary, + device: self.device.clone(), + }, + dummy_avoid_send_sync: PhantomData, + }); + } else { + break; + } + } + }; + + // Then allocate the rest. + if output.len() < count as usize { + let pool_lock = per_thread.pool.lock().unwrap(); + let num_new = count as usize - output.len(); + + for cmd in pool_lock.alloc_command_buffers(secondary, num_new)? { + output.push(StandardCommandPoolBuilder { + inner: StandardCommandPoolAlloc { + cmd: ManuallyDrop::new(cmd), + pool: per_thread.clone(), + pool_parent: self.clone(), + secondary: secondary, + device: self.device.clone(), + }, + dummy_avoid_send_sync: PhantomData, + }); + } + } + + // Final output. + Ok(output.into_iter()) + } + + #[inline] + fn queue_family(&self) -> QueueFamily { + self.device + .physical_device() + .queue_family_by_id(self.queue_family) + .unwrap() + } +} + +unsafe impl DeviceOwned for StandardCommandPool { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +/// Command buffer allocated from a `StandardCommandPool` and that is currently being built. +pub struct StandardCommandPoolBuilder { + // The only difference between a `StandardCommandPoolBuilder` and a `StandardCommandPoolAlloc` + // is that the former must not implement `Send` and `Sync`. Therefore we just share the structs. + inner: StandardCommandPoolAlloc, + // Unimplemented `Send` and `Sync` from the builder. + dummy_avoid_send_sync: PhantomData<*const u8>, +} + +unsafe impl CommandPoolBuilderAlloc for StandardCommandPoolBuilder { + type Alloc = StandardCommandPoolAlloc; + + #[inline] + fn inner(&self) -> &UnsafeCommandPoolAlloc { + self.inner.inner() + } + + #[inline] + fn into_alloc(self) -> Self::Alloc { + self.inner + } + + #[inline] + fn queue_family(&self) -> QueueFamily { + self.inner.queue_family() + } +} + +unsafe impl DeviceOwned for StandardCommandPoolBuilder { + #[inline] + fn device(&self) -> &Arc<Device> { + self.inner.device() + } +} + +/// Command buffer allocated from a `StandardCommandPool`. +pub struct StandardCommandPoolAlloc { + // The actual command buffer. Extracted in the `Drop` implementation. + cmd: ManuallyDrop<UnsafeCommandPoolAlloc>, + // We hold a reference to the command pool for our destructor. + pool: Arc<StandardCommandPoolPerThread>, + // Keep alive the `StandardCommandPool`, otherwise it would be destroyed. + pool_parent: Arc<StandardCommandPool>, + // True if secondary command buffer. + secondary: bool, + // The device we belong to. Necessary because of the `DeviceOwned` trait implementation. + device: Arc<Device>, +} + +unsafe impl Send for StandardCommandPoolAlloc { +} +unsafe impl Sync for StandardCommandPoolAlloc { +} + +unsafe impl CommandPoolAlloc for StandardCommandPoolAlloc { + #[inline] + fn inner(&self) -> &UnsafeCommandPoolAlloc { + &*self.cmd + } + + #[inline] + fn queue_family(&self) -> QueueFamily { + let queue_family_id = self.pool.pool.lock().unwrap().queue_family().id(); + + self.device + .physical_device() + .queue_family_by_id(queue_family_id) + .unwrap() + } +} + +unsafe impl DeviceOwned for StandardCommandPoolAlloc { + #[inline] + fn device(&self) -> &Arc<Device> { + // Note that we could grab the device from `self.pool`. Unfortunately this requires a mutex + // lock, so it isn't compatible with the API of `DeviceOwned`. + &self.device + } +} + +impl Drop for StandardCommandPoolAlloc { + fn drop(&mut self) { + // Safe because `self.cmd` is wrapped in a `ManuallyDrop`. + let cmd: UnsafeCommandPoolAlloc = unsafe { ptr::read(&*self.cmd) }; + + if self.secondary { + self.pool.available_secondary_command_buffers.push(cmd); + } else { + self.pool.available_primary_command_buffers.push(cmd); + } + } +} + +#[cfg(test)] +mod tests { + use VulkanObject; + use command_buffer::pool::CommandPool; + use command_buffer::pool::CommandPoolBuilderAlloc; + use command_buffer::pool::StandardCommandPool; + use device::Device; + use std::sync::Arc; + + #[test] + fn reuse_command_buffers() { + let (device, _) = gfx_dev_and_queue!(); + let queue_family = device.physical_device().queue_families().next().unwrap(); + + let pool = Device::standard_command_pool(&device, queue_family); + + let cb = pool.alloc(false, 1).unwrap().next().unwrap(); + let raw = cb.inner().internal_object(); + drop(cb); + + let cb2 = pool.alloc(false, 1).unwrap().next().unwrap(); + assert_eq!(raw, cb2.inner().internal_object()); + } + + #[test] + fn pool_kept_alive_by_allocs() { + let (device, queue) = gfx_dev_and_queue!(); + + let pool = Arc::new(StandardCommandPool::new(device, queue.family())); + let pool_weak = Arc::downgrade(&pool); + + let cb = pool.alloc(false, 1).unwrap().next().unwrap(); + drop(pool); + assert!(pool_weak.upgrade().is_some()); + + drop(cb); + assert!(pool_weak.upgrade().is_none()); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/pool/sys.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/pool/sys.rs new file mode 100644 index 0000000..01e18eb --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/pool/sys.rs @@ -0,0 +1,363 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::error; +use std::fmt; +use std::marker::PhantomData; +use std::mem; +use std::ptr; +use std::sync::Arc; +use std::vec::IntoIter as VecIntoIter; + +use instance::QueueFamily; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use device::Device; +use device::DeviceOwned; +use vk; + +/// Low-level implementation of a command pool. +/// +/// A command pool is always tied to a specific queue family. Command buffers allocated from a pool +/// can only be executed on the corresponding queue family. +/// +/// This struct doesn't implement the `Sync` trait because Vulkan command pools are not thread +/// safe. In other words, you can only use a pool from one thread at a time. +#[derive(Debug)] +pub struct UnsafeCommandPool { + pool: vk::CommandPool, + device: Arc<Device>, + + // Index of the associated queue family in the physical device. + queue_family_index: u32, + + // We don't want `UnsafeCommandPool` to implement Sync. + // This marker unimplements both Send and Sync, but we reimplement Send manually right under. + dummy_avoid_sync: PhantomData<*const u8>, +} + +unsafe impl Send for UnsafeCommandPool { +} + +impl UnsafeCommandPool { + /// Creates a new pool. + /// + /// The command buffers created with this pool can only be executed on queues of the given + /// family. + /// + /// Setting `transient` to true is a hint to the implementation that the command buffers will + /// be short-lived. + /// Setting `reset_cb` to true means that command buffers can be reset individually. + /// + /// # Panic + /// + /// - Panics if the queue family doesn't belong to the same physical device as `device`. + /// + pub fn new(device: Arc<Device>, queue_family: QueueFamily, transient: bool, reset_cb: bool) + -> Result<UnsafeCommandPool, OomError> { + assert_eq!(device.physical_device().internal_object(), + queue_family.physical_device().internal_object(), + "Device doesn't match physical device when creating a command pool"); + + let vk = device.pointers(); + + let flags = { + let flag1 = if transient { + vk::COMMAND_POOL_CREATE_TRANSIENT_BIT + } else { + 0 + }; + let flag2 = if reset_cb { + vk::COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT + } else { + 0 + }; + flag1 | flag2 + }; + + let pool = unsafe { + let infos = vk::CommandPoolCreateInfo { + sType: vk::STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, + pNext: ptr::null(), + flags: flags, + queueFamilyIndex: queue_family.id(), + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateCommandPool(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(UnsafeCommandPool { + pool: pool, + device: device.clone(), + queue_family_index: queue_family.id(), + dummy_avoid_sync: PhantomData, + }) + } + + /// Resets the pool, which resets all the command buffers that were allocated from it. + /// + /// If `release_resources` is true, it is a hint to the implementation that it should free all + /// the memory internally allocated for this pool. + /// + /// # Safety + /// + /// The command buffers allocated from this pool jump to the initial state. + /// + pub unsafe fn reset(&self, release_resources: bool) -> Result<(), OomError> { + let flags = if release_resources { + vk::COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT + } else { + 0 + }; + + let vk = self.device.pointers(); + check_errors(vk.ResetCommandPool(self.device.internal_object(), self.pool, flags))?; + Ok(()) + } + + /// Trims a command pool, which recycles unused internal memory from the command pool back to + /// the system. + /// + /// Command buffers allocated from the pool are not affected by trimming. + /// + /// This function is supported only if the `VK_KHR_maintenance1` extension was enabled at + /// device creation. Otherwise an error is returned. + /// Since this operation is purely an optimization it is legitimate to call this function and + /// simply ignore any possible error. + pub fn trim(&self) -> Result<(), CommandPoolTrimError> { + unsafe { + if !self.device.loaded_extensions().khr_maintenance1 { + return Err(CommandPoolTrimError::Maintenance1ExtensionNotEnabled); + } + + let vk = self.device.pointers(); + vk.TrimCommandPoolKHR(self.device.internal_object(), + self.pool, + 0 /* reserved */); + Ok(()) + } + } + + /// Allocates `count` command buffers. + /// + /// If `secondary` is true, allocates secondary command buffers. Otherwise, allocates primary + /// command buffers. + pub fn alloc_command_buffers(&self, secondary: bool, count: usize) + -> Result<UnsafeCommandPoolAllocIter, OomError> { + if count == 0 { + return Ok(UnsafeCommandPoolAllocIter { list: vec![].into_iter() }); + } + + let infos = vk::CommandBufferAllocateInfo { + sType: vk::STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, + pNext: ptr::null(), + commandPool: self.pool, + level: if secondary { + vk::COMMAND_BUFFER_LEVEL_SECONDARY + } else { + vk::COMMAND_BUFFER_LEVEL_PRIMARY + }, + commandBufferCount: count as u32, + }; + + unsafe { + let vk = self.device.pointers(); + let mut out = Vec::with_capacity(count); + check_errors(vk.AllocateCommandBuffers(self.device.internal_object(), + &infos, + out.as_mut_ptr()))?; + + out.set_len(count); + + Ok(UnsafeCommandPoolAllocIter { list: out.into_iter() }) + } + } + + /// Frees individual command buffers. + /// + /// # Safety + /// + /// The command buffers must have been allocated from this pool. They must not be in use. + /// + pub unsafe fn free_command_buffers<I>(&self, command_buffers: I) + where I: Iterator<Item = UnsafeCommandPoolAlloc> + { + let command_buffers: SmallVec<[_; 4]> = command_buffers.map(|cb| cb.0).collect(); + let vk = self.device.pointers(); + vk.FreeCommandBuffers(self.device.internal_object(), + self.pool, + command_buffers.len() as u32, + command_buffers.as_ptr()) + } + + /// Returns the queue family on which command buffers of this pool can be executed. + #[inline] + pub fn queue_family(&self) -> QueueFamily { + self.device + .physical_device() + .queue_family_by_id(self.queue_family_index) + .unwrap() + } +} + +unsafe impl DeviceOwned for UnsafeCommandPool { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +unsafe impl VulkanObject for UnsafeCommandPool { + type Object = vk::CommandPool; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT; + + #[inline] + fn internal_object(&self) -> vk::CommandPool { + self.pool + } +} + +impl Drop for UnsafeCommandPool { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyCommandPool(self.device.internal_object(), self.pool, ptr::null()); + } + } +} + +/// Opaque type that represents a command buffer allocated from a pool. +pub struct UnsafeCommandPoolAlloc(vk::CommandBuffer); + +unsafe impl VulkanObject for UnsafeCommandPoolAlloc { + type Object = vk::CommandBuffer; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT; + + #[inline] + fn internal_object(&self) -> vk::CommandBuffer { + self.0 + } +} + +/// Iterator for newly-allocated command buffers. +#[derive(Debug)] +pub struct UnsafeCommandPoolAllocIter { + list: VecIntoIter<vk::CommandBuffer>, +} + +impl Iterator for UnsafeCommandPoolAllocIter { + type Item = UnsafeCommandPoolAlloc; + + #[inline] + fn next(&mut self) -> Option<UnsafeCommandPoolAlloc> { + self.list.next().map(|cb| UnsafeCommandPoolAlloc(cb)) + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + self.list.size_hint() + } +} + +impl ExactSizeIterator for UnsafeCommandPoolAllocIter { +} + +/// Error that can happen when trimming command pools. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum CommandPoolTrimError { + /// The `KHR_maintenance1` extension was not enabled. + Maintenance1ExtensionNotEnabled, +} + +impl error::Error for CommandPoolTrimError { + #[inline] + fn description(&self) -> &str { + match *self { + CommandPoolTrimError::Maintenance1ExtensionNotEnabled => + "the `KHR_maintenance1` extension was not enabled", + } + } +} + +impl fmt::Display for CommandPoolTrimError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for CommandPoolTrimError { + #[inline] + fn from(err: Error) -> CommandPoolTrimError { + panic!("unexpected error: {:?}", err) + } +} + +#[cfg(test)] +mod tests { + use command_buffer::pool::CommandPoolTrimError; + use command_buffer::pool::UnsafeCommandPool; + + #[test] + fn basic_create() { + let (device, queue) = gfx_dev_and_queue!(); + let _ = UnsafeCommandPool::new(device, queue.family(), false, false).unwrap(); + } + + #[test] + fn queue_family_getter() { + let (device, queue) = gfx_dev_and_queue!(); + let pool = UnsafeCommandPool::new(device, queue.family(), false, false).unwrap(); + assert_eq!(pool.queue_family().id(), queue.family().id()); + } + + #[test] + fn panic_if_not_match_family() { + let (device, _) = gfx_dev_and_queue!(); + let (_, queue) = gfx_dev_and_queue!(); + + assert_should_panic!("Device doesn't match physical device when creating a command pool", { + let _ = UnsafeCommandPool::new(device, queue.family(), false, false); + }); + } + + #[test] + fn check_maintenance_when_trim() { + let (device, queue) = gfx_dev_and_queue!(); + let pool = UnsafeCommandPool::new(device, queue.family(), false, false).unwrap(); + + match pool.trim() { + Err(CommandPoolTrimError::Maintenance1ExtensionNotEnabled) => (), + _ => panic!(), + } + } + + // TODO: test that trim works if VK_KHR_maintenance1 if enabled ; the test macro doesn't + // support enabling extensions yet + + #[test] + fn basic_alloc() { + let (device, queue) = gfx_dev_and_queue!(); + let pool = UnsafeCommandPool::new(device, queue.family(), false, false).unwrap(); + let iter = pool.alloc_command_buffers(false, 12).unwrap(); + assert_eq!(iter.count(), 12); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/state_cacher.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/state_cacher.rs new file mode 100644 index 0000000..ce55c4a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/state_cacher.rs @@ -0,0 +1,470 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use VulkanObject; +use buffer::BufferAccess; +use command_buffer::DynamicState; +use descriptor::DescriptorSet; +use pipeline::ComputePipelineAbstract; +use pipeline::GraphicsPipelineAbstract; +use pipeline::input_assembly::IndexType; +use smallvec::SmallVec; +use std::ops::Range; +use vk; + +/// Keep track of the state of a command buffer builder, so that you don't need to bind objects +/// that were already bound. +/// +/// > **Important**: Executing a secondary command buffer invalidates the state of a command buffer +/// > builder. When you do so, you need to call `invalidate()`. +pub struct StateCacher { + // The dynamic state to synchronize with `CmdSetState`. + dynamic_state: DynamicState, + // The compute pipeline currently bound. 0 if nothing bound. + compute_pipeline: vk::Pipeline, + // The graphics pipeline currently bound. 0 if nothing bound. + graphics_pipeline: vk::Pipeline, + // The descriptor sets for the compute pipeline. + compute_descriptor_sets: SmallVec<[vk::DescriptorSet; 12]>, + // The descriptor sets for the graphics pipeline. + graphics_descriptor_sets: SmallVec<[vk::DescriptorSet; 12]>, + // If the user starts comparing descriptor sets, but drops the helper struct in the middle of + // the processing then we will end up in a weird state. This bool is true when we start + // comparing sets, and is set to false when we end up comparing. If it was true when we start + // comparing, we know that something bad happened and we flush the cache. + poisoned_descriptor_sets: bool, + // The vertex buffers currently bound. + vertex_buffers: SmallVec<[(vk::Buffer, vk::DeviceSize); 12]>, + // Same as `poisoned_descriptor_sets` but for vertex buffers. + poisoned_vertex_buffers: bool, + // The index buffer, offset, and index type currently bound. `None` if nothing bound. + index_buffer: Option<(vk::Buffer, usize, IndexType)>, +} + +/// Outcome of an operation. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum StateCacherOutcome { + /// The caller needs to perform the state change in the actual command buffer builder. + NeedChange, + /// The state change is not necessary. + AlreadyOk, +} + +impl StateCacher { + /// Builds a new `StateCacher`. + #[inline] + pub fn new() -> StateCacher { + StateCacher { + dynamic_state: DynamicState::none(), + compute_pipeline: 0, + graphics_pipeline: 0, + compute_descriptor_sets: SmallVec::new(), + graphics_descriptor_sets: SmallVec::new(), + poisoned_descriptor_sets: false, + vertex_buffers: SmallVec::new(), + poisoned_vertex_buffers: false, + index_buffer: None, + } + } + + /// Resets the cache to its default state. You **must** call this after executing a secondary + /// command buffer. + #[inline] + pub fn invalidate(&mut self) { + self.dynamic_state = DynamicState::none(); + self.compute_pipeline = 0; + self.graphics_pipeline = 0; + self.compute_descriptor_sets = SmallVec::new(); + self.graphics_descriptor_sets = SmallVec::new(); + self.vertex_buffers = SmallVec::new(); + self.index_buffer = None; + } + + /// Compares the current state with `incoming`, and returns a new state that contains the + /// states that differ and that need to be actually set in the command buffer builder. + /// + /// This function also updates the state cacher. The state cacher assumes that the state + /// changes are going to be performed after this function returns. + pub fn dynamic_state(&mut self, incoming: &DynamicState) -> DynamicState { + let mut changed = DynamicState::none(); + + macro_rules! cmp { + ($field:ident) => ( + if self.dynamic_state.$field != incoming.$field { + changed.$field = incoming.$field.clone(); + if incoming.$field.is_some() { + self.dynamic_state.$field = incoming.$field.clone(); + } + } + ); + } + + cmp!(line_width); + cmp!(viewports); + cmp!(scissors); + + changed + } + + /// Starts the process of comparing a list of descriptor sets to the descriptor sets currently + /// in cache. + /// + /// After calling this function, call `add` for each set one by one. Then call `compare` in + /// order to get the index of the first set to bind, or `None` if the sets were identical to + /// what is in cache. + /// + /// This process also updates the state cacher. The state cacher assumes that the state + /// changes are going to be performed after the `compare` function returns. + #[inline] + pub fn bind_descriptor_sets(&mut self, graphics: bool) -> StateCacherDescriptorSets { + if self.poisoned_descriptor_sets { + self.compute_descriptor_sets = SmallVec::new(); + self.graphics_descriptor_sets = SmallVec::new(); + } + + self.poisoned_descriptor_sets = true; + + StateCacherDescriptorSets { + poisoned: &mut self.poisoned_descriptor_sets, + state: if graphics { + &mut self.graphics_descriptor_sets + } else { + &mut self.compute_descriptor_sets + }, + offset: 0, + found_diff: None, + } + } + + /// Checks whether we need to bind a graphics pipeline. Returns `StateCacherOutcome::AlreadyOk` + /// if the pipeline was already bound earlier, and `StateCacherOutcome::NeedChange` if you need + /// to actually bind the pipeline. + /// + /// This function also updates the state cacher. The state cacher assumes that the state + /// changes are going to be performed after this function returns. + pub fn bind_graphics_pipeline<P>(&mut self, pipeline: &P) -> StateCacherOutcome + where P: GraphicsPipelineAbstract + { + let inner = GraphicsPipelineAbstract::inner(pipeline).internal_object(); + if inner == self.graphics_pipeline { + StateCacherOutcome::AlreadyOk + } else { + self.graphics_pipeline = inner; + StateCacherOutcome::NeedChange + } + } + + /// Checks whether we need to bind a compute pipeline. Returns `StateCacherOutcome::AlreadyOk` + /// if the pipeline was already bound earlier, and `StateCacherOutcome::NeedChange` if you need + /// to actually bind the pipeline. + /// + /// This function also updates the state cacher. The state cacher assumes that the state + /// changes are going to be performed after this function returns. + pub fn bind_compute_pipeline<P>(&mut self, pipeline: &P) -> StateCacherOutcome + where P: ComputePipelineAbstract + { + let inner = pipeline.inner().internal_object(); + if inner == self.compute_pipeline { + StateCacherOutcome::AlreadyOk + } else { + self.compute_pipeline = inner; + StateCacherOutcome::NeedChange + } + } + + /// Starts the process of comparing a list of vertex buffers to the vertex buffers currently + /// in cache. + /// + /// After calling this function, call `add` for each set one by one. Then call `compare` in + /// order to get the range of the vertex buffers to bind, or `None` if the sets were identical + /// to what is in cache. + /// + /// This process also updates the state cacher. The state cacher assumes that the state + /// changes are going to be performed after the `compare` function returns. + #[inline] + pub fn bind_vertex_buffers(&mut self) -> StateCacherVertexBuffers { + if self.poisoned_vertex_buffers { + self.vertex_buffers = SmallVec::new(); + } + + self.poisoned_vertex_buffers = true; + + StateCacherVertexBuffers { + poisoned: &mut self.poisoned_vertex_buffers, + state: &mut self.vertex_buffers, + offset: 0, + first_diff: None, + last_diff: 0, + } + } + + /// Checks whether we need to bind an index buffer. Returns `StateCacherOutcome::AlreadyOk` + /// if the index buffer was already bound earlier, and `StateCacherOutcome::NeedChange` if you + /// need to actually bind the buffer. + /// + /// This function also updates the state cacher. The state cacher assumes that the state + /// changes are going to be performed after this function returns. + pub fn bind_index_buffer<B>(&mut self, index_buffer: &B, ty: IndexType) -> StateCacherOutcome + where B: ?Sized + BufferAccess + { + let value = { + let inner = index_buffer.inner(); + (inner.buffer.internal_object(), inner.offset, ty) + }; + + if self.index_buffer == Some(value) { + StateCacherOutcome::AlreadyOk + } else { + self.index_buffer = Some(value); + StateCacherOutcome::NeedChange + } + } +} + +/// Helper struct for comparing descriptor sets. +/// +/// > **Note**: For reliability reasons, if you drop/leak this struct before calling `compare` then +/// > the cache of the currently bound descriptor sets will be reset. +pub struct StateCacherDescriptorSets<'s> { + // Reference to the parent's `poisoned_descriptor_sets`. + poisoned: &'s mut bool, + // Reference to the descriptor sets list to compare to. + state: &'s mut SmallVec<[vk::DescriptorSet; 12]>, + // Next offset within the list to compare to. + offset: usize, + // Contains the return value of `compare`. + found_diff: Option<u32>, +} + +impl<'s> StateCacherDescriptorSets<'s> { + /// Adds a descriptor set to the list to compare. + #[inline] + pub fn add<S>(&mut self, set: &S) + where S: ?Sized + DescriptorSet + { + let raw = set.inner().internal_object(); + + if self.offset < self.state.len() { + if self.state[self.offset] == raw { + self.offset += 1; + return; + } + + self.state[self.offset] = raw; + + } else { + self.state.push(raw); + } + + if self.found_diff.is_none() { + self.found_diff = Some(self.offset as u32); + } + self.offset += 1; + } + + /// Compares your list to the list in cache, and returns the offset of the first set to bind. + /// Returns `None` if the two lists were identical. + /// + /// After this function returns, the cache will be updated to match your list. + #[inline] + pub fn compare(self) -> Option<u32> { + *self.poisoned = false; + // Removing from the cache any set that wasn't added with `add`. + self.state.truncate(self.offset); + self.found_diff + } +} + +/// Helper struct for comparing vertex buffers. +/// +/// > **Note**: For reliability reasons, if you drop/leak this struct before calling `compare` then +/// > the cache of the currently bound vertex buffers will be reset. +pub struct StateCacherVertexBuffers<'s> { + // Reference to the parent's `poisoned_vertex_buffers`. + poisoned: &'s mut bool, + // Reference to the vertex buffers list to compare to. + state: &'s mut SmallVec<[(vk::Buffer, vk::DeviceSize); 12]>, + // Next offset within the list to compare to. + offset: usize, + // Contains the offset of the first vertex buffer that differs. + first_diff: Option<u32>, + // Offset of the last vertex buffer that differs. + last_diff: u32, +} + +impl<'s> StateCacherVertexBuffers<'s> { + /// Adds a vertex buffer to the list to compare. + #[inline] + pub fn add<B>(&mut self, buffer: &B) + where B: ?Sized + BufferAccess + { + let raw = { + let inner = buffer.inner(); + let raw = inner.buffer.internal_object(); + let offset = inner.offset as vk::DeviceSize; + (raw, offset) + }; + + if self.offset < self.state.len() { + if self.state[self.offset] == raw { + self.offset += 1; + return; + } + + self.state[self.offset] = raw; + + } else { + self.state.push(raw); + } + + self.last_diff = self.offset as u32; + if self.first_diff.is_none() { + self.first_diff = Some(self.offset as u32); + } + self.offset += 1; + } + + /// Compares your list to the list in cache, and returns the range of the vertex buffers to + /// bind. Returns `None` if the two lists were identical. + /// + /// After this function returns, the cache will be updated to match your list. + /// + /// > **Note**: Keep in mind that `range.end` is *after* the last element. For example the + /// > range `1 .. 2` only contains one element. + #[inline] + pub fn compare(self) -> Option<Range<u32>> { + *self.poisoned = false; + + // Removing from the cache any set that wasn't added with `add`. + self.state.truncate(self.offset); + + self.first_diff.map(|first| { + debug_assert!(first <= self.last_diff); + first .. (self.last_diff + 1) + }) + } +} + +#[cfg(test)] +mod tests { + use buffer::BufferUsage; + use buffer::CpuAccessibleBuffer; + use command_buffer::state_cacher::StateCacher; + + #[test] + fn vb_caching_single() { + let (device, queue) = gfx_dev_and_queue!(); + + const EMPTY: [i32; 0] = []; + let buf = + CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), EMPTY.iter()) + .unwrap(); + + let mut cacher = StateCacher::new(); + + { + let mut bind_vb = cacher.bind_vertex_buffers(); + bind_vb.add(&buf); + assert_eq!(bind_vb.compare(), Some(0 .. 1)); + } + + for _ in 0 .. 3 { + let mut bind_vb = cacher.bind_vertex_buffers(); + bind_vb.add(&buf); + assert_eq!(bind_vb.compare(), None); + } + } + + #[test] + fn vb_caching_invalidated() { + let (device, queue) = gfx_dev_and_queue!(); + + const EMPTY: [i32; 0] = []; + let buf = + CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), EMPTY.iter()) + .unwrap(); + + let mut cacher = StateCacher::new(); + + { + let mut bind_vb = cacher.bind_vertex_buffers(); + bind_vb.add(&buf); + assert_eq!(bind_vb.compare(), Some(0 .. 1)); + } + + { + let mut bind_vb = cacher.bind_vertex_buffers(); + bind_vb.add(&buf); + assert_eq!(bind_vb.compare(), None); + } + + cacher.invalidate(); + + { + let mut bind_vb = cacher.bind_vertex_buffers(); + bind_vb.add(&buf); + assert_eq!(bind_vb.compare(), Some(0 .. 1)); + } + } + + #[test] + fn vb_caching_multi() { + let (device, queue) = gfx_dev_and_queue!(); + + const EMPTY: [i32; 0] = []; + let buf1 = CpuAccessibleBuffer::from_data(device.clone(), + BufferUsage::vertex_buffer(), + EMPTY.iter()) + .unwrap(); + let buf2 = CpuAccessibleBuffer::from_data(device.clone(), + BufferUsage::vertex_buffer(), + EMPTY.iter()) + .unwrap(); + let buf3 = + CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), EMPTY.iter()) + .unwrap(); + + let mut cacher = StateCacher::new(); + + { + let mut bind_vb = cacher.bind_vertex_buffers(); + bind_vb.add(&buf1); + bind_vb.add(&buf2); + assert_eq!(bind_vb.compare(), Some(0 .. 2)); + } + + { + let mut bind_vb = cacher.bind_vertex_buffers(); + bind_vb.add(&buf1); + bind_vb.add(&buf2); + bind_vb.add(&buf3); + assert_eq!(bind_vb.compare(), Some(2 .. 3)); + } + + { + let mut bind_vb = cacher.bind_vertex_buffers(); + bind_vb.add(&buf1); + assert_eq!(bind_vb.compare(), None); + } + + { + let mut bind_vb = cacher.bind_vertex_buffers(); + bind_vb.add(&buf1); + bind_vb.add(&buf3); + assert_eq!(bind_vb.compare(), Some(1 .. 2)); + } + + { + let mut bind_vb = cacher.bind_vertex_buffers(); + bind_vb.add(&buf2); + bind_vb.add(&buf3); + assert_eq!(bind_vb.compare(), Some(0 .. 1)); + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/bind_sparse.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/bind_sparse.rs new file mode 100644 index 0000000..441fe1a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/bind_sparse.rs @@ -0,0 +1,501 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::error; +use std::fmt; +use std::marker::PhantomData; +use std::ptr; + +use buffer::sys::UnsafeBuffer; +use device::Queue; +use image::sys::UnsafeImage; +use memory::DeviceMemory; +use sync::Fence; +use sync::Semaphore; + +use Error; +use OomError; +use SynchronizedVulkanObject; +use VulkanObject; +use check_errors; +use vk; + +// TODO: correctly implement Debug on all the structs of this module + +/// Prototype for a submission that binds sparse memory. +// TODO: example here +pub struct SubmitBindSparseBuilder<'a> { + infos: SmallVec<[SubmitBindSparseBatchBuilder<'a>; 1]>, + fence: vk::Fence, +} + +impl<'a> SubmitBindSparseBuilder<'a> { + /// Builds a new empty `SubmitBindSparseBuilder`. + #[inline] + pub fn new() -> SubmitBindSparseBuilder<'a> { + SubmitBindSparseBuilder { + infos: SmallVec::new(), + fence: 0, + } + } + + /// Adds a batch to the command. + /// + /// Batches start execution in order, but can finish in a different order. In other words any + /// wait semaphore added to a batch will apply to further batches as well, but when a semaphore + /// is signalled, it does **not** mean that previous batches have been completed. + #[inline] + pub fn add(&mut self, builder: SubmitBindSparseBatchBuilder<'a>) { + self.infos.push(builder); + } + + /// Returns true if this builder will signal a fence when submitted. + /// + /// # Example + /// + /// ``` + /// use vulkano::command_buffer::submit::SubmitBindSparseBuilder; + /// use vulkano::sync::Fence; + /// # let device: std::sync::Arc<vulkano::device::Device> = return; + /// + /// unsafe { + /// let fence = Fence::from_pool(device.clone()).unwrap(); + /// + /// let mut builder = SubmitBindSparseBuilder::new(); + /// assert!(!builder.has_fence()); + /// builder.set_fence_signal(&fence); + /// assert!(builder.has_fence()); + /// } + /// ``` + #[inline] + pub fn has_fence(&self) -> bool { + self.fence != 0 + } + + /// Adds an operation that signals a fence after this submission ends. + /// + /// # Example + /// + /// ``` + /// use std::time::Duration; + /// use vulkano::command_buffer::submit::SubmitBindSparseBuilder; + /// use vulkano::sync::Fence; + /// # let device: std::sync::Arc<vulkano::device::Device> = return; + /// # let queue: std::sync::Arc<vulkano::device::Queue> = return; + /// + /// unsafe { + /// let fence = Fence::from_pool(device.clone()).unwrap(); + /// + /// let mut builder = SubmitBindSparseBuilder::new(); + /// builder.set_fence_signal(&fence); + /// + /// builder.submit(&queue).unwrap(); + /// + /// // We must not destroy the fence before it is signaled. + /// fence.wait(None).unwrap(); + /// } + /// ``` + /// + /// # Safety + /// + /// - The fence must not be signaled at the time when you call `submit()`. + /// + /// - If you use the fence for multiple submissions, only one at a time must be executed by the + /// GPU. In other words, you must submit one, wait for the fence to be signaled, then reset + /// the fence, and then only submit the second. + /// + /// - If you submit this builder, the fence must be kept alive until it is signaled by the GPU. + /// Destroying the fence earlier is an undefined behavior. + /// + /// - The fence, buffers, images, and semaphores must all belong to the same device. + /// + #[inline] + pub unsafe fn set_fence_signal(&mut self, fence: &'a Fence) { + self.fence = fence.internal_object(); + } + + /// Attempts to merge this builder with another one. + /// + /// If both builders have a fence already set, then this function will return `other` as an + /// error. + #[inline] + pub fn merge(&mut self, other: SubmitBindSparseBuilder<'a>) + -> Result<(), SubmitBindSparseBuilder<'a>> { + if self.fence != 0 && other.fence != 0 { + return Err(other); + } + + self.infos.extend(other.infos.into_iter()); + Ok(()) + } + + /// Submits the command. Calls `vkQueueBindSparse`. + pub fn submit(self, queue: &Queue) -> Result<(), SubmitBindSparseError> { + unsafe { + debug_assert!(queue.family().supports_sparse_binding()); + + let vk = queue.device().pointers(); + let queue = queue.internal_object_guard(); + + // We start by storing all the `VkSparseBufferMemoryBindInfo`s of the whole command + // in the same collection. + let buffer_binds_storage: SmallVec<[_; 4]> = self.infos + .iter() + .flat_map(|infos| infos.buffer_binds.iter()) + .map(|buf_bind| { + vk::SparseBufferMemoryBindInfo { + buffer: buf_bind.buffer, + bindCount: buf_bind.binds.len() as u32, + pBinds: buf_bind.binds.as_ptr(), + } + }) + .collect(); + + // Same for all the `VkSparseImageOpaqueMemoryBindInfo`s. + let image_opaque_binds_storage: SmallVec<[_; 4]> = self.infos + .iter() + .flat_map(|infos| infos.image_opaque_binds.iter()) + .map(|img_bind| { + vk::SparseImageOpaqueMemoryBindInfo { + image: img_bind.image, + bindCount: img_bind.binds.len() as u32, + pBinds: img_bind.binds.as_ptr(), + } + }) + .collect(); + + // And finally the `VkSparseImageMemoryBindInfo`s. + let image_binds_storage: SmallVec<[_; 4]> = self.infos + .iter() + .flat_map(|infos| infos.image_binds.iter()) + .map(|img_bind| { + vk::SparseImageMemoryBindInfo { + image: img_bind.image, + bindCount: img_bind.binds.len() as u32, + pBinds: img_bind.binds.as_ptr(), + } + }) + .collect(); + + // Now building the collection of `VkBindSparseInfo`s. + let bs_infos = { + let mut bs_infos: SmallVec<[_; 4]> = SmallVec::new(); + + // Since we stores all the bind infos contiguously, we keep track of the current + // offset within these containers. + let mut next_buffer_bind = 0; + let mut next_image_opaque_bind = 0; + let mut next_image_bind = 0; + + for builder in self.infos.iter() { + bs_infos.push(vk::BindSparseInfo { + sType: vk::STRUCTURE_TYPE_BIND_SPARSE_INFO, + pNext: ptr::null(), + waitSemaphoreCount: builder.wait_semaphores.len() as u32, + pWaitSemaphores: builder.wait_semaphores.as_ptr(), + bufferBindCount: builder.buffer_binds.len() as u32, + pBufferBinds: if next_buffer_bind != 0 { + // We need that `if` because `.as_ptr().offset(0)` is technically UB. + buffer_binds_storage.as_ptr().offset(next_buffer_bind) + } else { + buffer_binds_storage.as_ptr() + }, + imageOpaqueBindCount: builder.image_opaque_binds.len() as u32, + pImageOpaqueBinds: if next_image_opaque_bind != 0 { + // We need that `if` because `.as_ptr().offset(0)` is technically UB. + image_opaque_binds_storage.as_ptr().offset(next_image_opaque_bind) + } else { + image_opaque_binds_storage.as_ptr() + }, + imageBindCount: builder.image_binds.len() as u32, + pImageBinds: if next_image_bind != 0 { + // We need that `if` because `.as_ptr().offset(0)` is technically UB. + image_binds_storage.as_ptr().offset(next_image_bind) + } else { + image_binds_storage.as_ptr() + }, + signalSemaphoreCount: builder.signal_semaphores.len() as u32, + pSignalSemaphores: builder.signal_semaphores.as_ptr(), + + }); + + next_buffer_bind += builder.buffer_binds.len() as isize; + next_image_opaque_bind += builder.image_opaque_binds.len() as isize; + next_image_bind += builder.image_binds.len() as isize; + } + + // If these assertions fail, then there's something wrong in the code above. + debug_assert_eq!(next_buffer_bind as usize, buffer_binds_storage.len()); + debug_assert_eq!(next_image_opaque_bind as usize, + image_opaque_binds_storage.len()); + debug_assert_eq!(next_image_bind as usize, image_binds_storage.len()); + + bs_infos + }; + + // Finally executing the command. + check_errors(vk.QueueBindSparse(*queue, + bs_infos.len() as u32, + bs_infos.as_ptr(), + self.fence))?; + Ok(()) + } + } +} + +impl<'a> fmt::Debug for SubmitBindSparseBuilder<'a> { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Bind sparse operation>") + } +} + +/// A single batch of a sparse bind operation. +pub struct SubmitBindSparseBatchBuilder<'a> { + wait_semaphores: SmallVec<[vk::Semaphore; 8]>, + buffer_binds: SmallVec<[SubmitBindSparseBufferBindBuilder<'a>; 2]>, + image_opaque_binds: SmallVec<[SubmitBindSparseImageOpaqueBindBuilder<'a>; 2]>, + image_binds: SmallVec<[SubmitBindSparseImageBindBuilder<'a>; 2]>, + signal_semaphores: SmallVec<[vk::Semaphore; 8]>, + marker: PhantomData<&'a ()>, +} + +impl<'a> SubmitBindSparseBatchBuilder<'a> { + /// Builds a new empty `SubmitBindSparseBatchBuilder`. + #[inline] + pub fn new() -> SubmitBindSparseBatchBuilder<'a> { + SubmitBindSparseBatchBuilder { + wait_semaphores: SmallVec::new(), + buffer_binds: SmallVec::new(), + image_opaque_binds: SmallVec::new(), + image_binds: SmallVec::new(), + signal_semaphores: SmallVec::new(), + marker: PhantomData, + } + } + + /// Adds an operation that binds memory to a buffer. + pub fn add_buffer(&mut self, cmd: SubmitBindSparseBufferBindBuilder<'a>) { + self.buffer_binds.push(cmd); + } + + /// Adds an operation that binds memory to an opaque image. + pub fn add_image_opaque(&mut self, cmd: SubmitBindSparseImageOpaqueBindBuilder<'a>) { + self.image_opaque_binds.push(cmd); + } + + /// Adds an operation that binds memory to an image. + pub fn add_image(&mut self, cmd: SubmitBindSparseImageBindBuilder<'a>) { + self.image_binds.push(cmd); + } + + /// Adds a semaphore to be waited upon before the sparse binding is executed. + /// + /// # Safety + /// + /// - If you submit this builder, the semaphore must be kept alive until you are guaranteed + /// that the GPU has at least started executing the operation. + /// + /// - If you submit this builder, no other queue must be waiting on these semaphores. In other + /// words, each semaphore signal can only correspond to one semaphore wait. + /// + /// - If you submit this builder, the semaphores must be signaled when the queue execution + /// reaches this submission, or there must be one or more submissions in queues that are + /// going to signal these semaphores. In other words, you must not block the queue with + /// semaphores that can't get signaled. + /// + /// - The fence, buffers, images, and semaphores must all belong to the same device. + /// + #[inline] + pub unsafe fn add_wait_semaphore(&mut self, semaphore: &'a Semaphore) { + self.wait_semaphores.push(semaphore.internal_object()); + } + + /// Returns the number of semaphores to signal. + /// + /// In other words, this is the number of times `add_signal_semaphore` has been called. + #[inline] + pub fn num_signal_semaphores(&self) -> usize { + self.signal_semaphores.len() + } + + /// Adds a semaphore that is going to be signaled at the end of the submission. + /// + /// # Safety + /// + /// - If you submit this builder, the semaphore must be kept alive until you are guaranteed + /// that the GPU has finished executing this submission. + /// + /// - The semaphore must be in the unsignaled state when queue execution reaches this + /// submission. + /// + /// - The fence, buffers, images, and semaphores must all belong to the same device. + /// + #[inline] + pub unsafe fn add_signal_semaphore(&mut self, semaphore: &'a Semaphore) { + self.signal_semaphores.push(semaphore.internal_object()); + } +} + +pub struct SubmitBindSparseBufferBindBuilder<'a> { + buffer: vk::Buffer, + binds: SmallVec<[vk::SparseMemoryBind; 1]>, + marker: PhantomData<&'a ()>, +} + +impl<'a> SubmitBindSparseBufferBindBuilder<'a> { + /// + /// # Safety + /// + /// - `buffer` must be a buffer with sparse binding enabled. + pub unsafe fn new(buffer: &'a UnsafeBuffer) -> SubmitBindSparseBufferBindBuilder { + SubmitBindSparseBufferBindBuilder { + buffer: buffer.internal_object(), + binds: SmallVec::new(), + marker: PhantomData, + } + } + + pub unsafe fn add_bind(&mut self, offset: usize, size: usize, memory: &DeviceMemory, + memory_offset: usize) { + self.binds.push(vk::SparseMemoryBind { + resourceOffset: offset as vk::DeviceSize, + size: size as vk::DeviceSize, + memory: memory.internal_object(), + memoryOffset: memory_offset as vk::DeviceSize, + flags: 0, // Flags are only relevant for images. + }); + } + + pub unsafe fn add_unbind(&mut self, offset: usize, size: usize) { + self.binds.push(vk::SparseMemoryBind { + resourceOffset: offset as vk::DeviceSize, + size: size as vk::DeviceSize, + memory: 0, + memoryOffset: 0, + flags: 0, + }); + } +} + +pub struct SubmitBindSparseImageOpaqueBindBuilder<'a> { + image: vk::Image, + binds: SmallVec<[vk::SparseMemoryBind; 1]>, + marker: PhantomData<&'a ()>, +} + +impl<'a> SubmitBindSparseImageOpaqueBindBuilder<'a> { + /// + /// # Safety + /// + /// - `image` must be an image with sparse binding enabled. + pub unsafe fn new(image: &'a UnsafeImage) -> SubmitBindSparseImageOpaqueBindBuilder { + SubmitBindSparseImageOpaqueBindBuilder { + image: image.internal_object(), + binds: SmallVec::new(), + marker: PhantomData, + } + } + + pub unsafe fn add_bind(&mut self, offset: usize, size: usize, memory: &DeviceMemory, + memory_offset: usize, bind_metadata: bool) { + self.binds.push(vk::SparseMemoryBind { + resourceOffset: offset as vk::DeviceSize, + size: size as vk::DeviceSize, + memory: memory.internal_object(), + memoryOffset: memory_offset as vk::DeviceSize, + flags: if bind_metadata { + vk::SPARSE_MEMORY_BIND_METADATA_BIT + } else { + 0 + }, + }); + } + + pub unsafe fn add_unbind(&mut self, offset: usize, size: usize) { + self.binds.push(vk::SparseMemoryBind { + resourceOffset: offset as vk::DeviceSize, + size: size as vk::DeviceSize, + memory: 0, + memoryOffset: 0, + flags: 0, // TODO: is that relevant? + }); + } +} + +pub struct SubmitBindSparseImageBindBuilder<'a> { + image: vk::Image, + binds: SmallVec<[vk::SparseImageMemoryBind; 1]>, + marker: PhantomData<&'a ()>, +} + +impl<'a> SubmitBindSparseImageBindBuilder<'a> { + /// + /// # Safety + /// + /// - `image` must be an image with sparse binding enabled. + pub unsafe fn new(image: &'a UnsafeImage) -> SubmitBindSparseImageBindBuilder { + SubmitBindSparseImageBindBuilder { + image: image.internal_object(), + binds: SmallVec::new(), + marker: PhantomData, + } + } + + // TODO: finish +} + +/// Error that can happen when submitting the present prototype. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u32)] +pub enum SubmitBindSparseError { + /// Not enough memory. + OomError(OomError), + + /// The connection to the device has been lost. + DeviceLost, +} + +impl error::Error for SubmitBindSparseError { + #[inline] + fn description(&self) -> &str { + match *self { + SubmitBindSparseError::OomError(_) => "not enough memory", + SubmitBindSparseError::DeviceLost => "the connection to the device has been lost", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + SubmitBindSparseError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for SubmitBindSparseError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for SubmitBindSparseError { + #[inline] + fn from(err: Error) -> SubmitBindSparseError { + match err { + err @ Error::OutOfHostMemory => SubmitBindSparseError::OomError(OomError::from(err)), + err @ Error::OutOfDeviceMemory => SubmitBindSparseError::OomError(OomError::from(err)), + Error::DeviceLost => SubmitBindSparseError::DeviceLost, + _ => panic!("unexpected error: {:?}", err), + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/mod.rs new file mode 100644 index 0000000..7688f76 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/mod.rs @@ -0,0 +1,52 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Low-level builders that allow submitting an operation to a queue. +//! +//! In order to submit an operation to the GPU, you must use one of the builder structs of this +//! module. These structs are low-level and unsafe, and are mostly used to implement other parts +//! of vulkano, so you are encouraged to not use them directly. + +pub use self::bind_sparse::SubmitBindSparseBatchBuilder; +pub use self::bind_sparse::SubmitBindSparseBufferBindBuilder; +pub use self::bind_sparse::SubmitBindSparseBuilder; +pub use self::bind_sparse::SubmitBindSparseError; +pub use self::bind_sparse::SubmitBindSparseImageBindBuilder; +pub use self::bind_sparse::SubmitBindSparseImageOpaqueBindBuilder; +pub use self::queue_present::SubmitPresentBuilder; +pub use self::queue_present::SubmitPresentError; +pub use self::queue_submit::SubmitCommandBufferBuilder; +pub use self::queue_submit::SubmitCommandBufferError; +pub use self::semaphores_wait::SubmitSemaphoresWaitBuilder; + +mod bind_sparse; +mod queue_present; +mod queue_submit; +mod semaphores_wait; + +/// Contains all the possible submission builders. +#[derive(Debug)] +pub enum SubmitAnyBuilder<'a> { + Empty, + SemaphoresWait(SubmitSemaphoresWaitBuilder<'a>), + CommandBuffer(SubmitCommandBufferBuilder<'a>), + QueuePresent(SubmitPresentBuilder<'a>), + BindSparse(SubmitBindSparseBuilder<'a>), +} + +impl<'a> SubmitAnyBuilder<'a> { + /// Returns true if equal to `SubmitAnyBuilder::Empty`. + #[inline] + pub fn is_empty(&self) -> bool { + match self { + &SubmitAnyBuilder::Empty => true, + _ => false, + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/queue_present.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/queue_present.rs new file mode 100644 index 0000000..4a8b2d6 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/queue_present.rs @@ -0,0 +1,270 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::error; +use std::fmt; +use std::marker::PhantomData; +use std::ptr; + +use device::DeviceOwned; +use device::Queue; +use swapchain::PresentRegion; +use swapchain::Swapchain; +use sync::Semaphore; + +use Error; +use OomError; +use SynchronizedVulkanObject; +use VulkanObject; +use check_errors; +use vk; + +/// Prototype for a submission that presents a swapchain on the screen. +// TODO: example here +pub struct SubmitPresentBuilder<'a> { + wait_semaphores: SmallVec<[vk::Semaphore; 8]>, + swapchains: SmallVec<[vk::SwapchainKHR; 4]>, + image_indices: SmallVec<[u32; 4]>, + present_regions: SmallVec<[vk::PresentRegionKHR; 4]>, + rect_layers: SmallVec<[vk::RectLayerKHR; 4]>, + marker: PhantomData<&'a ()>, +} + +impl<'a> SubmitPresentBuilder<'a> { + /// Builds a new empty `SubmitPresentBuilder`. + #[inline] + pub fn new() -> SubmitPresentBuilder<'a> { + SubmitPresentBuilder { + wait_semaphores: SmallVec::new(), + swapchains: SmallVec::new(), + image_indices: SmallVec::new(), + present_regions: SmallVec::new(), + rect_layers: SmallVec::new(), + marker: PhantomData, + } + } + + /// Adds a semaphore to be waited upon before the presents are executed. + /// + /// # Safety + /// + /// - If you submit this builder, the semaphore must be kept alive until you are guaranteed + /// that the GPU has presented the swapchains. + /// + /// - If you submit this builder, no other queue must be waiting on these semaphores. In other + /// words, each semaphore signal can only correspond to one semaphore wait. + /// + /// - If you submit this builder, the semaphores must be signaled when the queue execution + /// reaches this submission, or there must be one or more submissions in queues that are + /// going to signal these semaphores. In other words, you must not block the queue with + /// semaphores that can't get signaled. + /// + /// - The swapchains and semaphores must all belong to the same device. + /// + #[inline] + pub unsafe fn add_wait_semaphore(&mut self, semaphore: &'a Semaphore) { + self.wait_semaphores.push(semaphore.internal_object()); + } + + /// Adds an image of a swapchain to be presented. + /// + /// Allows to specify a present region. + /// Areas outside the present region *can* be ignored by the Vulkan implementation for + /// optimizations purposes. + /// + /// If `VK_KHR_incremental_present` is not enabled, the `present_region` parameter is ignored. + /// + /// # Safety + /// + /// - If you submit this builder, the swapchain must be kept alive until you are + /// guaranteed that the GPU has finished presenting. + /// + /// - The swapchains and semaphores must all belong to the same device. + /// + #[inline] + pub unsafe fn add_swapchain<W>(&mut self, swapchain: &'a Swapchain<W>, image_num: u32, + present_region: Option<&'a PresentRegion>) { + debug_assert!(image_num < swapchain.num_images()); + + if swapchain + .device() + .loaded_extensions() + .khr_incremental_present + { + let vk_present_region = match present_region { + Some(present_region) => { + assert!(present_region.is_compatible_with(swapchain)); + for rectangle in &present_region.rectangles { + self.rect_layers.push(rectangle.to_vk()); + } + vk::PresentRegionKHR { + rectangleCount: present_region.rectangles.len() as u32, + // Set this to null for now; in submit fill it with self.rect_layers + pRectangles: ptr::null(), + } + }, + None => { + vk::PresentRegionKHR { + rectangleCount: 0, + pRectangles: ptr::null(), + } + }, + }; + self.present_regions.push(vk_present_region); + } + + self.swapchains.push(swapchain.internal_object()); + self.image_indices.push(image_num); + } + + + /// Submits the command. Calls `vkQueuePresentKHR`. + /// + /// # Panic + /// + /// Panics if no swapchain image has been added to the builder. + /// + pub fn submit(mut self, queue: &Queue) -> Result<(), SubmitPresentError> { + unsafe { + debug_assert_eq!(self.swapchains.len(), self.image_indices.len()); + assert!(!self.swapchains.is_empty(), + "Tried to submit a present command without any swapchain"); + + let present_regions = { + if !self.present_regions.is_empty() { + debug_assert!(queue.device().loaded_extensions().khr_incremental_present); + debug_assert_eq!(self.swapchains.len(), self.present_regions.len()); + let mut current_index = 0; + for present_region in &mut self.present_regions { + present_region.pRectangles = self.rect_layers[current_index ..].as_ptr(); + current_index += present_region.rectangleCount as usize; + } + Some(vk::PresentRegionsKHR { + sType: vk::STRUCTURE_TYPE_PRESENT_REGIONS_KHR, + pNext: ptr::null(), + swapchainCount: self.present_regions.len() as u32, + pRegions: self.present_regions.as_ptr(), + }) + } else { + None + } + }; + + let mut results = vec![vk::SUCCESS; self.swapchains.len()]; + + let vk = queue.device().pointers(); + let queue = queue.internal_object_guard(); + + let infos = vk::PresentInfoKHR { + sType: vk::STRUCTURE_TYPE_PRESENT_INFO_KHR, + pNext: present_regions + .as_ref() + .map(|pr| pr as *const vk::PresentRegionsKHR as *const _) + .unwrap_or(ptr::null()), + waitSemaphoreCount: self.wait_semaphores.len() as u32, + pWaitSemaphores: self.wait_semaphores.as_ptr(), + swapchainCount: self.swapchains.len() as u32, + pSwapchains: self.swapchains.as_ptr(), + pImageIndices: self.image_indices.as_ptr(), + pResults: results.as_mut_ptr(), + }; + + check_errors(vk.QueuePresentKHR(*queue, &infos))?; + + for result in results { + check_errors(result)?; + } + + Ok(()) + } + } +} + +impl<'a> fmt::Debug for SubmitPresentBuilder<'a> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fmt.debug_struct("SubmitPresentBuilder") + .field("wait_semaphores", &self.wait_semaphores) + .field("swapchains", &self.swapchains) + .field("image_indices", &self.image_indices) + .finish() + } +} + +/// Error that can happen when submitting the present prototype. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u32)] +pub enum SubmitPresentError { + /// Not enough memory. + OomError(OomError), + + /// The connection to the device has been lost. + DeviceLost, + + /// The surface is no longer accessible and must be recreated. + SurfaceLost, + + /// The surface has changed in a way that makes the swapchain unusable. You must query the + /// surface's new properties and recreate a new swapchain if you want to continue drawing. + OutOfDate, +} + +impl error::Error for SubmitPresentError { + #[inline] + fn description(&self) -> &str { + match *self { + SubmitPresentError::OomError(_) => "not enough memory", + SubmitPresentError::DeviceLost => "the connection to the device has been lost", + SubmitPresentError::SurfaceLost => "the surface of this swapchain is no longer valid", + SubmitPresentError::OutOfDate => "the swapchain needs to be recreated", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + SubmitPresentError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for SubmitPresentError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for SubmitPresentError { + #[inline] + fn from(err: Error) -> SubmitPresentError { + match err { + err @ Error::OutOfHostMemory => SubmitPresentError::OomError(OomError::from(err)), + err @ Error::OutOfDeviceMemory => SubmitPresentError::OomError(OomError::from(err)), + Error::DeviceLost => SubmitPresentError::DeviceLost, + Error::SurfaceLost => SubmitPresentError::SurfaceLost, + Error::OutOfDate => SubmitPresentError::OutOfDate, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn no_swapchain_added() { + let (_, queue) = gfx_dev_and_queue!(); + assert_should_panic!("Tried to submit a present command without any swapchain", { + let _ = SubmitPresentBuilder::new().submit(&queue); + }); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/queue_submit.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/queue_submit.rs new file mode 100644 index 0000000..db0bd9f --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/queue_submit.rs @@ -0,0 +1,361 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::error; +use std::fmt; +use std::marker::PhantomData; +use std::ptr; + +use command_buffer::sys::UnsafeCommandBuffer; +use device::Queue; +use sync::Fence; +use sync::PipelineStages; +use sync::Semaphore; + +use Error; +use OomError; +use SynchronizedVulkanObject; +use VulkanObject; +use check_errors; +use vk; + +/// Prototype for a submission that executes command buffers. +// TODO: example here +#[derive(Debug)] +pub struct SubmitCommandBufferBuilder<'a> { + wait_semaphores: SmallVec<[vk::Semaphore; 16]>, + destination_stages: SmallVec<[vk::PipelineStageFlags; 8]>, + signal_semaphores: SmallVec<[vk::Semaphore; 16]>, + command_buffers: SmallVec<[vk::CommandBuffer; 4]>, + fence: vk::Fence, + marker: PhantomData<&'a ()>, +} + +impl<'a> SubmitCommandBufferBuilder<'a> { + /// Builds a new empty `SubmitCommandBufferBuilder`. + #[inline] + pub fn new() -> SubmitCommandBufferBuilder<'a> { + SubmitCommandBufferBuilder { + wait_semaphores: SmallVec::new(), + destination_stages: SmallVec::new(), + signal_semaphores: SmallVec::new(), + command_buffers: SmallVec::new(), + fence: 0, + marker: PhantomData, + } + } + + /// Returns true if this builder will signal a fence when submitted. + /// + /// # Example + /// + /// ``` + /// use vulkano::command_buffer::submit::SubmitCommandBufferBuilder; + /// use vulkano::sync::Fence; + /// # let device: std::sync::Arc<vulkano::device::Device> = return; + /// + /// unsafe { + /// let fence = Fence::from_pool(device.clone()).unwrap(); + /// + /// let mut builder = SubmitCommandBufferBuilder::new(); + /// assert!(!builder.has_fence()); + /// builder.set_fence_signal(&fence); + /// assert!(builder.has_fence()); + /// } + /// ``` + #[inline] + pub fn has_fence(&self) -> bool { + self.fence != 0 + } + + /// Adds an operation that signals a fence after this submission ends. + /// + /// # Example + /// + /// ``` + /// use std::time::Duration; + /// use vulkano::command_buffer::submit::SubmitCommandBufferBuilder; + /// use vulkano::sync::Fence; + /// # let device: std::sync::Arc<vulkano::device::Device> = return; + /// # let queue: std::sync::Arc<vulkano::device::Queue> = return; + /// + /// unsafe { + /// let fence = Fence::from_pool(device.clone()).unwrap(); + /// + /// let mut builder = SubmitCommandBufferBuilder::new(); + /// builder.set_fence_signal(&fence); + /// + /// builder.submit(&queue).unwrap(); + /// + /// // We must not destroy the fence before it is signaled. + /// fence.wait(Some(Duration::from_secs(5))).unwrap(); + /// } + /// ``` + /// + /// # Safety + /// + /// - The fence must not be signaled at the time when you call `submit()`. + /// + /// - If you use the fence for multiple submissions, only one at a time must be executed by the + /// GPU. In other words, you must submit one, wait for the fence to be signaled, then reset + /// the fence, and then only submit the second. + /// + /// - If you submit this builder, the fence must be kept alive until it is signaled by the GPU. + /// Destroying the fence earlier is an undefined behavior. + /// + /// - The fence, command buffers, and semaphores must all belong to the same device. + /// + #[inline] + pub unsafe fn set_fence_signal(&mut self, fence: &'a Fence) { + self.fence = fence.internal_object(); + } + + /// Adds a semaphore to be waited upon before the command buffers are executed. + /// + /// Only the given `stages` of the command buffers added afterwards will wait upon + /// the semaphore. Other stages not included in `stages` can execute before waiting. + /// + /// # Safety + /// + /// - The stages must be supported by the device. + /// + /// - If you submit this builder, the semaphore must be kept alive until you are guaranteed + /// that the GPU has at least started executing the command buffers. + /// + /// - If you submit this builder, no other queue must be waiting on these semaphores. In other + /// words, each semaphore signal can only correspond to one semaphore wait. + /// + /// - If you submit this builder, the semaphores must be signaled when the queue execution + /// reaches this submission, or there must be one or more submissions in queues that are + /// going to signal these semaphores. In other words, you must not block the queue with + /// semaphores that can't get signaled. + /// + /// - The fence, command buffers, and semaphores must all belong to the same device. + /// + #[inline] + pub unsafe fn add_wait_semaphore(&mut self, semaphore: &'a Semaphore, stages: PipelineStages) { + debug_assert!(stages.into_vulkan_bits() != 0); + // TODO: debug assert that the device supports the stages + self.wait_semaphores.push(semaphore.internal_object()); + self.destination_stages.push(stages.into_vulkan_bits()); + } + + /// Adds a command buffer that is executed as part of this command. + /// + /// The command buffers are submitted in the order in which they are added. + /// + /// # Safety + /// + /// - If you submit this builder, the command buffer must be kept alive until you are + /// guaranteed that the GPU has finished executing it. + /// + /// - Any calls to vkCmdSetEvent, vkCmdResetEvent or vkCmdWaitEvents that have been recorded + /// into the command buffer must not reference any VkEvent that is referenced by any of + /// those commands that is pending execution on another queue. + /// TODO: rephrase ^ ? + /// + /// - The fence, command buffers, and semaphores must all belong to the same device. + /// + /// TODO: more here + /// + #[inline] + pub unsafe fn add_command_buffer<P>(&mut self, command_buffer: &'a UnsafeCommandBuffer<P>) { + self.command_buffers.push(command_buffer.internal_object()); + } + + /// Returns the number of semaphores to signal. + /// + /// In other words, this is the number of times `add_signal_semaphore` has been called. + #[inline] + pub fn num_signal_semaphores(&self) -> usize { + self.signal_semaphores.len() + } + + /// Adds a semaphore that is going to be signaled at the end of the submission. + /// + /// # Safety + /// + /// - If you submit this builder, the semaphore must be kept alive until you are guaranteed + /// that the GPU has finished executing this submission. + /// + /// - The semaphore must be in the unsignaled state when queue execution reaches this + /// submission. + /// + /// - The fence, command buffers, and semaphores must all belong to the same device. + /// + #[inline] + pub unsafe fn add_signal_semaphore(&mut self, semaphore: &'a Semaphore) { + self.signal_semaphores.push(semaphore.internal_object()); + } + + /// Submits the command buffer to the given queue. + /// + /// > **Note**: This is an expensive operation, so you may want to merge as many builders as + /// > possible together and avoid submitting them one by one. + /// + pub fn submit(self, queue: &Queue) -> Result<(), SubmitCommandBufferError> { + unsafe { + let vk = queue.device().pointers(); + let queue = queue.internal_object_guard(); + + debug_assert_eq!(self.wait_semaphores.len(), self.destination_stages.len()); + + let batch = vk::SubmitInfo { + sType: vk::STRUCTURE_TYPE_SUBMIT_INFO, + pNext: ptr::null(), + waitSemaphoreCount: self.wait_semaphores.len() as u32, + pWaitSemaphores: self.wait_semaphores.as_ptr(), + pWaitDstStageMask: self.destination_stages.as_ptr(), + commandBufferCount: self.command_buffers.len() as u32, + pCommandBuffers: self.command_buffers.as_ptr(), + signalSemaphoreCount: self.signal_semaphores.len() as u32, + pSignalSemaphores: self.signal_semaphores.as_ptr(), + }; + + check_errors(vk.QueueSubmit(*queue, 1, &batch, self.fence))?; + Ok(()) + } + } + + /// Merges this builder with another builder. + /// + /// # Panic + /// + /// Panics if both builders have a fence already set. + // TODO: create multiple batches instead + pub fn merge(mut self, other: Self) -> Self { + assert!(self.fence == 0 || other.fence == 0, + "Can't merge two queue submits that both have a fence"); + + self.wait_semaphores.extend(other.wait_semaphores); + self.destination_stages.extend(other.destination_stages); // TODO: meh? will be solved if we submit multiple batches + self.signal_semaphores.extend(other.signal_semaphores); + self.command_buffers.extend(other.command_buffers); + + if self.fence == 0 { + self.fence = other.fence; + } + + self + } +} + +/// Error that can happen when submitting the prototype. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u32)] +pub enum SubmitCommandBufferError { + /// Not enough memory. + OomError(OomError), + + /// The connection to the device has been lost. + DeviceLost, +} + +impl error::Error for SubmitCommandBufferError { + #[inline] + fn description(&self) -> &str { + match *self { + SubmitCommandBufferError::OomError(_) => "not enough memory", + SubmitCommandBufferError::DeviceLost => "the connection to the device has been lost", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + SubmitCommandBufferError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for SubmitCommandBufferError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for SubmitCommandBufferError { + #[inline] + fn from(err: Error) -> SubmitCommandBufferError { + match err { + err @ Error::OutOfHostMemory => SubmitCommandBufferError::OomError(OomError::from(err)), + err @ Error::OutOfDeviceMemory => + SubmitCommandBufferError::OomError(OomError::from(err)), + Error::DeviceLost => SubmitCommandBufferError::DeviceLost, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::time::Duration; + use sync::Fence; + + #[test] + fn empty_submit() { + let (device, queue) = gfx_dev_and_queue!(); + let builder = SubmitCommandBufferBuilder::new(); + builder.submit(&queue).unwrap(); + } + + #[test] + fn signal_fence() { + unsafe { + let (device, queue) = gfx_dev_and_queue!(); + + let fence = Fence::alloc(device.clone()).unwrap(); + assert!(!fence.ready().unwrap()); + + let mut builder = SubmitCommandBufferBuilder::new(); + builder.set_fence_signal(&fence); + + builder.submit(&queue).unwrap(); + fence.wait(Some(Duration::from_secs(5))).unwrap(); + assert!(fence.ready().unwrap()); + } + } + + #[test] + fn has_fence() { + unsafe { + let (device, queue) = gfx_dev_and_queue!(); + + let fence = Fence::alloc(device.clone()).unwrap(); + + let mut builder = SubmitCommandBufferBuilder::new(); + assert!(!builder.has_fence()); + builder.set_fence_signal(&fence); + assert!(builder.has_fence()); + } + } + + #[test] + fn merge_both_have_fences() { + unsafe { + let (device, _) = gfx_dev_and_queue!(); + + let fence1 = Fence::alloc(device.clone()).unwrap(); + let fence2 = Fence::alloc(device.clone()).unwrap(); + + let mut builder1 = SubmitCommandBufferBuilder::new(); + builder1.set_fence_signal(&fence1); + let mut builder2 = SubmitCommandBufferBuilder::new(); + builder2.set_fence_signal(&fence2); + + assert_should_panic!("Can't merge two queue submits that both have a fence", { + let _ = builder1.merge(builder2); + }); + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/semaphores_wait.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/semaphores_wait.rs new file mode 100644 index 0000000..8b1a02b --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/submit/semaphores_wait.rs @@ -0,0 +1,77 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; + +use command_buffer::submit::SubmitCommandBufferBuilder; +use command_buffer::submit::SubmitPresentBuilder; +use sync::PipelineStages; +use sync::Semaphore; + +/// Prototype for a submission that waits on semaphores. +/// +/// This prototype can't actually be submitted because it doesn't correspond to anything in Vulkan. +/// However you can convert it into another builder prototype through the `Into` trait. +#[derive(Debug)] +pub struct SubmitSemaphoresWaitBuilder<'a> { + semaphores: SmallVec<[&'a Semaphore; 8]>, +} + +impl<'a> SubmitSemaphoresWaitBuilder<'a> { + /// Builds a new empty `SubmitSemaphoresWaitBuilder`. + #[inline] + pub fn new() -> SubmitSemaphoresWaitBuilder<'a> { + SubmitSemaphoresWaitBuilder { semaphores: SmallVec::new() } + } + + /// Adds an operation that waits on a semaphore. + /// + /// The semaphore must be signaled by a previous submission. + #[inline] + pub unsafe fn add_wait_semaphore(&mut self, semaphore: &'a Semaphore) { + self.semaphores.push(semaphore); + } + + /// Merges this builder with another builder. + #[inline] + pub fn merge(&mut self, mut other: SubmitSemaphoresWaitBuilder<'a>) { + self.semaphores.extend(other.semaphores.drain()); + } +} + +impl<'a> Into<SubmitCommandBufferBuilder<'a>> for SubmitSemaphoresWaitBuilder<'a> { + #[inline] + fn into(mut self) -> SubmitCommandBufferBuilder<'a> { + unsafe { + let mut builder = SubmitCommandBufferBuilder::new(); + for sem in self.semaphores.drain() { + builder.add_wait_semaphore(sem, + PipelineStages { + // TODO: correct stages ; hard + all_commands: true, + ..PipelineStages::none() + }); + } + builder + } + } +} + +impl<'a> Into<SubmitPresentBuilder<'a>> for SubmitSemaphoresWaitBuilder<'a> { + #[inline] + fn into(mut self) -> SubmitPresentBuilder<'a> { + unsafe { + let mut builder = SubmitPresentBuilder::new(); + for sem in self.semaphores.drain() { + builder.add_wait_semaphore(sem); + } + builder + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/base.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/base.rs new file mode 100644 index 0000000..32f46b6 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/base.rs @@ -0,0 +1,1268 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use fnv::FnvHashMap; +use std::borrow::Cow; +use std::collections::hash_map::Entry; +use std::error; +use std::fmt; +use std::hash::{Hash, Hasher}; +use std::sync::Arc; +use std::sync::Mutex; + +use OomError; +use buffer::BufferAccess; +use command_buffer::CommandBufferExecError; +use command_buffer::pool::CommandPool; +use command_buffer::pool::CommandPoolAlloc; +use command_buffer::pool::CommandPoolBuilderAlloc; +use command_buffer::sys::Flags; +use command_buffer::sys::Kind; +use command_buffer::sys::UnsafeCommandBuffer; +use command_buffer::sys::UnsafeCommandBufferBuilder; +use command_buffer::sys::UnsafeCommandBufferBuilderPipelineBarrier; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use framebuffer::FramebufferAbstract; +use framebuffer::RenderPassAbstract; +use image::ImageAccess; +use image::ImageLayout; +use sync::AccessCheckError; +use sync::AccessError; +use sync::AccessFlagBits; +use sync::GpuFuture; +use sync::PipelineStages; + +/// Wrapper around `UnsafeCommandBufferBuilder` that handles synchronization for you. +/// +/// Each method of the `UnsafeCommandBufferBuilder` has an equivalent in this wrapper, except +/// for `pipeline_layout` which is automatically handled. This wrapper automatically builds +/// pipeline barriers, keeps used resources alive and implements the `CommandBuffer` trait. +/// +/// Since the implementation needs to cache commands in a `Vec`, most methods have additional +/// `Send + Sync + 'static` trait requirements on their generics. +/// +/// If this builder finds out that a command isn't valid because of synchronization reasons (eg. +/// trying to copy from a buffer to an image which share the same memory), then an error is +/// returned. +/// Note that all methods are still unsafe, because this builder doesn't check the validity of +/// the commands except for synchronization purposes. The builder may panic if you pass invalid +/// commands. +/// +/// The `P` generic is the same as `UnsafeCommandBufferBuilder`. +pub struct SyncCommandBufferBuilder<P> { + // The actual Vulkan command buffer builder. + inner: UnsafeCommandBufferBuilder<P>, + + // Stores the current state of all resources (buffers and images) that are in use by the + // command buffer. + resources: FnvHashMap<BuilderKey<P>, ResourceState>, + + // Prototype for the pipeline barrier that must be submitted before flushing the commands + // in `commands`. + pending_barrier: UnsafeCommandBufferBuilderPipelineBarrier, + + // Stores all the commands that were added to the sync builder. Some of them are maybe not + // submitted to the inner builder yet. A copy of this `Arc` is stored in each `BuilderKey`. + commands: Arc<Mutex<Commands<P>>>, + + // True if we're a secondary command buffer. + is_secondary: bool, +} + +// # How pipeline stages work in Vulkan +// +// Imagine you create a command buffer that contains 10 dispatch commands, and submit that command +// buffer. According to the Vulkan specs, the implementation is free to execute the 10 commands +// simultaneously. +// +// Now imagine that the command buffer contains 10 draw commands instead. Contrary to the dispatch +// commands, the draw pipeline contains multiple stages: draw indirect, vertex input, vertex shader, +// ..., fragment shader, late fragment test, color output. When there are multiple stages, the +// implementations must start and end the stages in order. In other words it can start the draw +// indirect stage of all 10 commands, then start the vertex input stage of all 10 commands, and so +// on. But it can't for example start the fragment shader stage of a command before starting the +// vertex shader stage of another command. Same thing for ending the stages in the right order. +// +// Depending on the type of the command, the pipeline stages are different. Compute shaders use the +// compute stage, while transfer commands use the transfer stage. The compute and transfer stages +// aren't ordered. +// +// When you submit multiple command buffers to a queue, the implementation doesn't do anything in +// particular and behaves as if the command buffers were appended to one another. Therefore if you +// submit a command buffer with 10 dispatch commands, followed with another command buffer with 5 +// dispatch commands, then the implementation can perform the 15 commands simultaneously. +// +// ## Introducing barriers +// +// In some situations this is not the desired behaviour. If you add a command that writes to a +// buffer followed with another command that reads that buffer, you don't want them to execute +// simultaneously. Instead you want the second one to wait until the first one is finished. This +// is done by adding a pipeline barrier between the two commands. +// +// A pipeline barriers has a source stage and a destination stage (plus various other things). +// A barrier represents a split in the list of commands. When you add it, the stages of the commands +// before the barrier corresponding to the source stage of the barrier, must finish before the +// stages of the commands after the barrier corresponding to the destination stage of the barrier +// can start. +// +// For example if you add a barrier that transitions from the compute stage to the compute stage, +// then the compute stage of all the commands before the barrier must end before the compute stage +// of all the commands after the barrier can start. This is appropriate for the example about +// writing then reading the same buffer. +// +// ## Batching barriers +// +// Since barriers are "expensive" (as the queue must block), vulkano attempts to group as many +// pipeline barriers as possible into one. +// +// Adding a command to a sync command buffer builder does not immediately add it to the underlying +// command buffer builder. Instead the command is added to a queue, and the builder keeps a +// prototype of a barrier that must be added before the commands in the queue are flushed. +// +// Whenever you add a command, the builder will find out whether a barrier is needed before the +// command. If so, it will try to merge this barrier with the prototype and add the command to the +// queue. If not possible, the queue will be entirely flushed and the command added to a fresh new +// queue with a fresh new barrier prototype. + +impl<P> fmt::Debug for SyncCommandBufferBuilder<P> { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.inner, f) + } +} + +/// Error returned if the builder detects that there's an unsolvable conflict. +#[derive(Debug, Clone)] +pub enum SyncCommandBufferBuilderError { + /// Unsolvable conflict. + Conflict { + command1_name: &'static str, + command1_param: Cow<'static, str>, + command1_offset: usize, + + command2_name: &'static str, + command2_param: Cow<'static, str>, + command2_offset: usize, + }, +} + +impl error::Error for SyncCommandBufferBuilderError { + #[inline] + fn description(&self) -> &str { + match *self { + SyncCommandBufferBuilderError::Conflict { .. } => { + "unsolvable conflict" + }, + } + } +} + +impl fmt::Display for SyncCommandBufferBuilderError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +// List of commands stored inside a `SyncCommandBufferBuilder`. +struct Commands<P> { + // Only the commands before `first_unflushed` have already been sent to the inner + // `UnsafeCommandBufferBuilder`. + first_unflushed: usize, + + // If we're currently inside a render pass, contains the index of the `CmdBeginRenderPass` + // command. + latest_render_pass_enter: Option<usize>, + + // The actual list. + commands: Vec<Box<Command<P> + Send + Sync>>, +} + +// Trait for single commands within the list of commands. +pub trait Command<P> { + // Returns a user-friendly name for the command, for error reporting purposes. + fn name(&self) -> &'static str; + + // Sends the command to the `UnsafeCommandBufferBuilder`. Calling this method twice on the same + // object will likely lead to a panic. + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>); + + // Turns this command into a `FinalCommand`. + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync>; + + // Gives access to the `num`th buffer used by the command. + fn buffer(&self, _num: usize) -> &BufferAccess { + panic!() + } + + // Gives access to the `num`th image used by the command. + fn image(&self, _num: usize) -> &ImageAccess { + panic!() + } + + // Returns a user-friendly name for the `num`th buffer used by the command, for error + // reporting purposes. + fn buffer_name(&self, _num: usize) -> Cow<'static, str> { + panic!() + } + + // Returns a user-friendly name for the `num`th image used by the command, for error + // reporting purposes. + fn image_name(&self, _num: usize) -> Cow<'static, str> { + panic!() + } +} + +/// Type of resource whose state is to be tracked. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum KeyTy { + Buffer, + Image, +} + +// Key that identifies a resource. Implements `PartialEq`, `Eq` and `Hash` so that two resources +// that conflict with each other compare equal. +// +// This works by holding an Arc to the list of commands and the index of the command that holds +// the resource. +struct BuilderKey<P> { + // Same `Arc` as in the `SyncCommandBufferBuilder`. + commands: Arc<Mutex<Commands<P>>>, + // Index of the command that holds the resource within `commands`. + command_id: usize, + // Type of the resource. + resource_ty: KeyTy, + // Index of the resource within the command. + resource_index: usize, +} + +impl<P> BuilderKey<P> { + // Turns this key used by the builder into a key used by the final command buffer. + // Called when the command buffer is being built. + fn into_cb_key(self, final_commands: Arc<Mutex<Vec<Box<FinalCommand + Send + Sync>>>>) + -> CbKey<'static> { + CbKey::Command { + commands: final_commands, + command_id: self.command_id, + resource_ty: self.resource_ty, + resource_index: self.resource_index, + } + } + + #[inline] + fn conflicts_buffer(&self, commands_lock: &Commands<P>, buf: &BufferAccess) -> bool { + // TODO: put the conflicts_* methods directly on the Command trait to avoid an indirect call? + match self.resource_ty { + KeyTy::Buffer => { + let c = &commands_lock.commands[self.command_id]; + c.buffer(self.resource_index).conflicts_buffer(buf) + }, + KeyTy::Image => { + let c = &commands_lock.commands[self.command_id]; + c.image(self.resource_index).conflicts_buffer(buf) + }, + } + } + + #[inline] + fn conflicts_image(&self, commands_lock: &Commands<P>, img: &ImageAccess) -> bool { + // TODO: put the conflicts_* methods directly on the Command trait to avoid an indirect call? + match self.resource_ty { + KeyTy::Buffer => { + let c = &commands_lock.commands[self.command_id]; + c.buffer(self.resource_index).conflicts_image(img) + }, + KeyTy::Image => { + let c = &commands_lock.commands[self.command_id]; + c.image(self.resource_index).conflicts_image(img) + }, + } + } +} + +impl<P> PartialEq for BuilderKey<P> { + #[inline] + fn eq(&self, other: &BuilderKey<P>) -> bool { + debug_assert!(Arc::ptr_eq(&self.commands, &other.commands)); + let commands_lock = self.commands.lock().unwrap(); + + match other.resource_ty { + KeyTy::Buffer => { + let c = &commands_lock.commands[other.command_id]; + self.conflicts_buffer(&commands_lock, c.buffer(other.resource_index)) + }, + KeyTy::Image => { + let c = &commands_lock.commands[other.command_id]; + self.conflicts_image(&commands_lock, c.image(other.resource_index)) + }, + } + } +} + +impl<P> Eq for BuilderKey<P> { +} + +impl<P> Hash for BuilderKey<P> { + #[inline] + fn hash<H: Hasher>(&self, state: &mut H) { + let commands_lock = self.commands.lock().unwrap(); + + match self.resource_ty { + KeyTy::Buffer => { + let c = &commands_lock.commands[self.command_id]; + c.buffer(self.resource_index).conflict_key().hash(state) + }, + KeyTy::Image => { + let c = &commands_lock.commands[self.command_id]; + c.image(self.resource_index).conflict_key().hash(state) + }, + } + } +} + +// State of a resource during the building of the command buffer. +#[derive(Debug, Clone)] +struct ResourceState { + // Stage of the command that last used this resource. + stages: PipelineStages, + // Access for the command that last used this resource. + access: AccessFlagBits, + + // True if the resource was used in exclusive mode at any point during the building of the + // command buffer. Also true if an image layout transition or queue transfer has been performed. + exclusive_any: bool, + + // True if the last command that used this resource used it in exclusive mode. + exclusive: bool, + + // Layout at the first use of the resource by the command buffer. Can be `Undefined` if we + // don't care. + initial_layout: ImageLayout, + + // Current layout at this stage of the building. + current_layout: ImageLayout, +} + +impl ResourceState { + // Turns this `ResourceState` into a `ResourceFinalState`. Called when the command buffer is + // being built. + #[inline] + fn finalize(self) -> ResourceFinalState { + ResourceFinalState { + final_stages: self.stages, + final_access: self.access, + exclusive: self.exclusive_any, + initial_layout: self.initial_layout, + final_layout: self.current_layout, + } + } +} + +impl<P> SyncCommandBufferBuilder<P> { + /// Builds a new `SyncCommandBufferBuilder`. The parameters are the same as the + /// `UnsafeCommandBufferBuilder::new` function. + /// + /// # Safety + /// + /// See `UnsafeCommandBufferBuilder::new()` and `SyncCommandBufferBuilder`. + pub unsafe fn new<Pool, R, F, A>(pool: &Pool, kind: Kind<R, F>, flags: Flags) + -> Result<SyncCommandBufferBuilder<P>, OomError> + where Pool: CommandPool<Builder = P, Alloc = A>, + P: CommandPoolBuilderAlloc<Alloc = A>, + A: CommandPoolAlloc, + R: RenderPassAbstract, + F: FramebufferAbstract + { + let (is_secondary, inside_render_pass) = match kind { + Kind::Primary => (false, false), + Kind::Secondary { ref render_pass, .. } => (true, render_pass.is_some()), + }; + + let cmd = UnsafeCommandBufferBuilder::new(pool, kind, flags)?; + Ok(SyncCommandBufferBuilder::from_unsafe_cmd(cmd, is_secondary, inside_render_pass)) + } + + /// Builds a `SyncCommandBufferBuilder` from an existing `UnsafeCommandBufferBuilder`. + /// + /// # Safety + /// + /// See `UnsafeCommandBufferBuilder::new()` and `SyncCommandBufferBuilder`. + /// + /// In addition to this, the `UnsafeCommandBufferBuilder` should be empty. If it isn't, then + /// you must take into account the fact that the `SyncCommandBufferBuilder` won't be aware of + /// any existing resource usage. + #[inline] + pub unsafe fn from_unsafe_cmd(cmd: UnsafeCommandBufferBuilder<P>, is_secondary: bool, + inside_render_pass: bool) + -> SyncCommandBufferBuilder<P> { + let latest_render_pass_enter = if inside_render_pass { Some(0) } else { None }; + + SyncCommandBufferBuilder { + inner: cmd, + resources: FnvHashMap::default(), + pending_barrier: UnsafeCommandBufferBuilderPipelineBarrier::new(), + commands: Arc::new(Mutex::new(Commands { + first_unflushed: 0, + latest_render_pass_enter, + commands: Vec::new(), + })), + is_secondary, + } + } + + // Adds a command to be processed by the builder. + // + // After this method has been called, call `prev_cmd_resource` for each buffer or image used + // by the command. + #[inline] + pub(super) fn append_command<C>(&mut self, command: C) + where C: Command<P> + Send + Sync + 'static + { + // Note that we don't submit the command to the inner command buffer yet. + self.commands + .lock() + .unwrap() + .commands + .push(Box::new(command)); + } + + // Call this when the previous command entered a render pass. + #[inline] + pub(super) fn prev_cmd_entered_render_pass(&mut self) { + let mut cmd_lock = self.commands.lock().unwrap(); + cmd_lock.latest_render_pass_enter = Some(cmd_lock.commands.len() - 1); + } + + // Call this when the previous command left a render pass. + #[inline] + pub(super) fn prev_cmd_left_render_pass(&mut self) { + let mut cmd_lock = self.commands.lock().unwrap(); + debug_assert!(cmd_lock.latest_render_pass_enter.is_some()); + cmd_lock.latest_render_pass_enter = None; + } + + // After a command is added to the list of pending commands, this function must be called for + // each resource used by the command that has just been added. + // The function will take care of handling the pipeline barrier or flushing. + // + // `resource_ty` and `resource_index` designate the resource in the previous command (accessed + // through `Command::buffer(..)` or `Command::image(..)`. + // + // `exclusive`, `stages` and `access` must match the way the resource has been used. + // + // `start_layout` and `end_layout` designate the image layout that the image is expected to be + // in when the command starts, and the image layout that the image will be transitioned to + // during the command. When it comes to buffers, you should pass `Undefined` for both. + pub(super) fn prev_cmd_resource(&mut self, resource_ty: KeyTy, resource_index: usize, + exclusive: bool, stages: PipelineStages, + access: AccessFlagBits, start_layout: ImageLayout, + end_layout: ImageLayout) + -> Result<(), SyncCommandBufferBuilderError> { + // Anti-dumbness checks. + debug_assert!(exclusive || start_layout == end_layout); + debug_assert!(access.is_compatible_with(&stages)); + debug_assert!(resource_ty != KeyTy::Image || end_layout != ImageLayout::Undefined); + debug_assert!(resource_ty != KeyTy::Buffer || start_layout == ImageLayout::Undefined); + debug_assert!(resource_ty != KeyTy::Buffer || end_layout == ImageLayout::Undefined); + debug_assert_ne!(end_layout, ImageLayout::Preinitialized); + + let (first_unflushed_cmd_id, latest_command_id) = { + let commands_lock = self.commands.lock().unwrap(); + debug_assert!(commands_lock.commands.len() >= 1); + (commands_lock.first_unflushed, commands_lock.commands.len() - 1) + }; + + let key = BuilderKey { + commands: self.commands.clone(), + command_id: latest_command_id, + resource_ty, + resource_index, + }; + + // Note that the call to `entry()` will lock the mutex, so we can't keep it locked + // throughout the function. + match self.resources.entry(key) { + + // Situation where this resource was used before in this command buffer. + Entry::Occupied(entry) => { + // `collision_cmd_id` contains the ID of the command that we are potentially + // colliding with. + let collision_cmd_id = entry.key().command_id; + debug_assert!(collision_cmd_id <= latest_command_id); + + let entry_key_resource_index = entry.key().resource_index; + let entry_key_resource_ty = entry.key().resource_ty; + let entry = entry.into_mut(); + + // Find out if we have a collision with the pending commands. + if exclusive || entry.exclusive || entry.current_layout != start_layout { + // Collision found between `latest_command_id` and `collision_cmd_id`. + + // We now want to modify the current pipeline barrier in order to handle the + // collision. But since the pipeline barrier is going to be submitted before + // the flushed commands, it would be a mistake if `collision_cmd_id` hasn't + // been flushed yet. + if collision_cmd_id >= first_unflushed_cmd_id { + unsafe { + // Flush the pending barrier. + self.inner.pipeline_barrier(&self.pending_barrier); + self.pending_barrier = UnsafeCommandBufferBuilderPipelineBarrier::new(); + + // Flush the commands if possible, or return an error if not possible. + { + let mut commands_lock = self.commands.lock().unwrap(); + let start = commands_lock.first_unflushed; + let end = if let Some(rp_enter) = commands_lock + .latest_render_pass_enter + { + rp_enter + } else { + latest_command_id + }; + if collision_cmd_id >= end { + let cmd1 = &commands_lock.commands[collision_cmd_id]; + let cmd2 = &commands_lock.commands[latest_command_id]; + return Err(SyncCommandBufferBuilderError::Conflict { + command1_name: cmd1.name(), + command1_param: match entry_key_resource_ty { + KeyTy::Buffer => cmd1.buffer_name(entry_key_resource_index), + KeyTy::Image => + cmd1.image_name(entry_key_resource_index), + }, + command1_offset: collision_cmd_id, + + command2_name: cmd2.name(), + command2_param: match resource_ty { + KeyTy::Buffer => + cmd2.buffer_name(resource_index), + KeyTy::Image => + cmd2.image_name(resource_index), + }, + command2_offset: latest_command_id, + }); + } + for command in &mut commands_lock.commands[start .. end] { + command.send(&mut self.inner); + } + commands_lock.first_unflushed = end; + } + } + } + + // Modify the pipeline barrier to handle the collision. + unsafe { + let commands_lock = self.commands.lock().unwrap(); + match resource_ty { + KeyTy::Buffer => { + let buf = commands_lock.commands[latest_command_id] + .buffer(resource_index); + + let b = &mut self.pending_barrier; + b.add_buffer_memory_barrier(buf, + entry.stages, + entry.access, + stages, + access, + true, + None, + 0, + buf.size()); + }, + + KeyTy::Image => { + let img = commands_lock.commands[latest_command_id] + .image(resource_index); + + let b = &mut self.pending_barrier; + b.add_image_memory_barrier(img, + 0 .. img.mipmap_levels(), + 0 .. img.dimensions().array_layers(), + entry.stages, + entry.access, + stages, + access, + true, + None, + entry.current_layout, + start_layout); + }, + }; + } + + // Update state. + entry.stages = stages; + entry.access = access; + entry.exclusive_any = true; + entry.exclusive = exclusive; + if exclusive || end_layout != ImageLayout::Undefined { + // Only modify the layout in case of a write, because buffer operations + // pass `Undefined` for the layout. While a buffer write *must* set the + // layout to `Undefined`, a buffer read must not touch it. + entry.current_layout = end_layout; + } + + } else { + // There is no collision. Simply merge the stages and accesses. + // TODO: what about simplifying the newly-constructed stages/accesses? + // this would simplify the job of the driver, but is it worth it? + entry.stages = entry.stages | stages; + entry.access = entry.access | access; + } + }, + + // Situation where this is the first time we use this resource in this command buffer. + Entry::Vacant(entry) => { + // We need to perform some tweaks if the initial layout requirement of the image + // is different from the first layout usage. + let mut actually_exclusive = exclusive; + let mut actual_start_layout = start_layout; + + if !self.is_secondary && resource_ty == KeyTy::Image && + start_layout != ImageLayout::Undefined && + start_layout != ImageLayout::Preinitialized + { + let commands_lock = self.commands.lock().unwrap(); + let img = commands_lock.commands[latest_command_id].image(resource_index); + let initial_layout_requirement = img.initial_layout_requirement(); + + if initial_layout_requirement != start_layout { + actually_exclusive = true; + actual_start_layout = initial_layout_requirement; + + // Note that we transition from `bottom_of_pipe`, which means that we + // wait for all the previous commands to be entirely finished. This is + // suboptimal, but: + // + // - If we're at the start of the command buffer we have no choice anyway, + // because we have no knowledge about what comes before. + // - If we're in the middle of the command buffer, this pipeline is going + // to be merged with an existing barrier. While it may still be + // suboptimal in some cases, in the general situation it will be ok. + // + unsafe { + let b = &mut self.pending_barrier; + b.add_image_memory_barrier(img, + 0 .. img.mipmap_levels(), + 0 .. img.dimensions().array_layers(), + PipelineStages { + bottom_of_pipe: true, + ..PipelineStages::none() + }, + AccessFlagBits::none(), + stages, + access, + true, + None, + initial_layout_requirement, + start_layout); + } + } + } + + entry.insert(ResourceState { + stages: stages, + access: access, + exclusive_any: actually_exclusive, + exclusive: actually_exclusive, + initial_layout: actual_start_layout, + current_layout: end_layout, // TODO: what if we reach the end with Undefined? that's not correct? + }); + }, + } + + + Ok(()) + } + + /// Builds the command buffer and turns it into a `SyncCommandBuffer`. + #[inline] + pub fn build(mut self) -> Result<SyncCommandBuffer<P::Alloc>, OomError> + where P: CommandPoolBuilderAlloc + { + let mut commands_lock = self.commands.lock().unwrap(); + debug_assert!(commands_lock.latest_render_pass_enter.is_none() || + self.pending_barrier.is_empty()); + + // The commands that haven't been sent to the inner command buffer yet need to be sent. + unsafe { + self.inner.pipeline_barrier(&self.pending_barrier); + let f = commands_lock.first_unflushed; + for command in &mut commands_lock.commands[f ..] { + command.send(&mut self.inner); + } + } + + // Transition images to their desired final layout. + if !self.is_secondary { + unsafe { + // TODO: this could be optimized by merging the barrier with the barrier above? + let mut barrier = UnsafeCommandBufferBuilderPipelineBarrier::new(); + + for (key, state) in &mut self.resources { + if key.resource_ty != KeyTy::Image { + continue; + } + + let img = commands_lock.commands[key.command_id].image(key.resource_index); + let requested_layout = img.final_layout_requirement(); + if requested_layout == state.current_layout { + continue; + } + + barrier.add_image_memory_barrier(img, + 0 .. img.mipmap_levels(), + 0 .. img.dimensions().array_layers(), + state.stages, + state.access, + PipelineStages { + top_of_pipe: true, + ..PipelineStages::none() + }, + AccessFlagBits::none(), + true, + None, // TODO: queue transfers? + state.current_layout, + requested_layout); + + state.exclusive_any = true; + state.current_layout = requested_layout; + } + + self.inner.pipeline_barrier(&barrier); + } + } + + // Turns the commands into a list of "final commands" that are slimmer. + let final_commands = { + let mut final_commands = Vec::with_capacity(commands_lock.commands.len()); + for command in commands_lock.commands.drain(..) { + final_commands.push(command.into_final_command()); + } + Arc::new(Mutex::new(final_commands)) + }; + + // Build the final resources states. + let final_resources_states: FnvHashMap<_, _> = { + self.resources + .into_iter() + .map(|(resource, state)| { + (resource.into_cb_key(final_commands.clone()), state.finalize()) + }) + .collect() + }; + + Ok(SyncCommandBuffer { + inner: self.inner.build()?, + resources: final_resources_states, + commands: final_commands, + }) + } +} + +unsafe impl<P> DeviceOwned for SyncCommandBufferBuilder<P> { + #[inline] + fn device(&self) -> &Arc<Device> { + self.inner.device() + } +} + +/// Command buffer built from a `SyncCommandBufferBuilder` that provides utilities to handle +/// synchronization. +pub struct SyncCommandBuffer<P> { + // The actual Vulkan command buffer. + inner: UnsafeCommandBuffer<P>, + + // State of all the resources used by this command buffer. + resources: FnvHashMap<CbKey<'static>, ResourceFinalState>, + + // List of commands used by the command buffer. Used to hold the various resources that are + // being used. Each element of `resources` has a copy of this `Arc`, but we need to keep one + // here in case `resources` is empty. + commands: Arc<Mutex<Vec<Box<FinalCommand + Send + Sync>>>>, +} + +// Usage of a resource in a finished command buffer. +#[derive(Debug, Clone)] +struct ResourceFinalState { + // Stages of the last command that uses the resource. + final_stages: PipelineStages, + // Access for the last command that uses the resource. + final_access: AccessFlagBits, + + // True if the resource is used in exclusive mode. + exclusive: bool, + + // Layout that an image must be in at the start of the command buffer. Can be `Undefined` if we + // don't care. + initial_layout: ImageLayout, + + // Layout the image will be in at the end of the command buffer. + final_layout: ImageLayout, // TODO: maybe wrap in an Option to mean that the layout doesn't change? because of buffers? +} + +/// Equivalent to `Command`, but with less methods. Typically contains less things than the +/// `Command` it comes from. +pub trait FinalCommand { + // Returns a user-friendly name for the command, for error reporting purposes. + fn name(&self) -> &'static str; + + // Gives access to the `num`th buffer used by the command. + fn buffer(&self, _num: usize) -> &BufferAccess { + panic!() + } + + // Gives access to the `num`th image used by the command. + fn image(&self, _num: usize) -> &ImageAccess { + panic!() + } + + // Returns a user-friendly name for the `num`th buffer used by the command, for error + // reporting purposes. + fn buffer_name(&self, _num: usize) -> Cow<'static, str> { + panic!() + } + + // Returns a user-friendly name for the `num`th image used by the command, for error + // reporting purposes. + fn image_name(&self, _num: usize) -> Cow<'static, str> { + panic!() + } +} + +impl FinalCommand for &'static str { + fn name(&self) -> &'static str { + *self + } +} + +// Equivalent of `BuilderKey` for a finished command buffer. +// +// In addition to this, it also add two other variants which are `BufferRef` and `ImageRef`. These +// variants are used in order to make it possible to compare a `CbKey` stored in the +// `SyncCommandBuffer` with a temporarily-created `CbKey`. The Rust HashMap doesn't allow us to do +// that otherwise. +// +// You should never store a `BufferRef` or a `ImageRef` inside the `SyncCommandBuffer`. +enum CbKey<'a> { + // The resource is held in the list of commands. + Command { + // Same `Arc` as in the `SyncCommandBufferBuilder`. + commands: Arc<Mutex<Vec<Box<FinalCommand + Send + Sync>>>>, + // Index of the command that holds the resource within `commands`. + command_id: usize, + // Type of the resource. + resource_ty: KeyTy, + // Index of the resource within the command. + resource_index: usize, + }, + + // Temporary key that holds a reference to a buffer. Should never be stored in the list of + // resources of `SyncCommandBuffer`. + BufferRef(&'a BufferAccess), + + // Temporary key that holds a reference to an image. Should never be stored in the list of + // resources of `SyncCommandBuffer`. + ImageRef(&'a ImageAccess), +} + +// The `CbKey::Command` variants implements `Send` and `Sync`, but the other two variants don't +// because it would be too constraining. +// +// Since only `CbKey::Command` must be stored in the resources hashmap, we force-implement `Send` +// and `Sync` so that the hashmap itself implements `Send` and `Sync`. +unsafe impl<'a> Send for CbKey<'a> { +} +unsafe impl<'a> Sync for CbKey<'a> { +} + +impl<'a> CbKey<'a> { + #[inline] + fn conflicts_buffer(&self, commands_lock: Option<&Vec<Box<FinalCommand + Send + Sync>>>, + buf: &BufferAccess) + -> bool { + match *self { + CbKey::Command { + ref commands, + command_id, + resource_ty, + resource_index, + } => { + let lock = if commands_lock.is_none() { + Some(commands.lock().unwrap()) + } else { + None + }; + let commands_lock = commands_lock.unwrap_or_else(|| lock.as_ref().unwrap()); + + // TODO: put the conflicts_* methods directly on the FinalCommand trait to avoid an indirect call? + match resource_ty { + KeyTy::Buffer => { + let c = &commands_lock[command_id]; + c.buffer(resource_index).conflicts_buffer(buf) + }, + KeyTy::Image => { + let c = &commands_lock[command_id]; + c.image(resource_index).conflicts_buffer(buf) + }, + } + }, + + CbKey::BufferRef(b) => b.conflicts_buffer(buf), + CbKey::ImageRef(i) => i.conflicts_buffer(buf), + } + } + + #[inline] + fn conflicts_image(&self, commands_lock: Option<&Vec<Box<FinalCommand + Send + Sync>>>, + img: &ImageAccess) + -> bool { + match *self { + CbKey::Command { + ref commands, + command_id, + resource_ty, + resource_index, + } => { + let lock = if commands_lock.is_none() { + Some(commands.lock().unwrap()) + } else { + None + }; + let commands_lock = commands_lock.unwrap_or_else(|| lock.as_ref().unwrap()); + + // TODO: put the conflicts_* methods directly on the Command trait to avoid an indirect call? + match resource_ty { + KeyTy::Buffer => { + let c = &commands_lock[command_id]; + c.buffer(resource_index).conflicts_image(img) + }, + KeyTy::Image => { + let c = &commands_lock[command_id]; + c.image(resource_index).conflicts_image(img) + }, + } + }, + + CbKey::BufferRef(b) => b.conflicts_image(img), + CbKey::ImageRef(i) => i.conflicts_image(img), + } + } +} + +impl<'a> PartialEq for CbKey<'a> { + #[inline] + fn eq(&self, other: &CbKey) -> bool { + match *self { + CbKey::BufferRef(a) => { + other.conflicts_buffer(None, a) + }, + CbKey::ImageRef(a) => { + other.conflicts_image(None, a) + }, + CbKey::Command { + ref commands, + command_id, + resource_ty, + resource_index, + } => { + let commands_lock = commands.lock().unwrap(); + + match resource_ty { + KeyTy::Buffer => { + let c = &commands_lock[command_id]; + other.conflicts_buffer(Some(&commands_lock), c.buffer(resource_index)) + }, + KeyTy::Image => { + let c = &commands_lock[command_id]; + other.conflicts_image(Some(&commands_lock), c.image(resource_index)) + }, + } + }, + } + } +} + +impl<'a> Eq for CbKey<'a> { +} + +impl<'a> Hash for CbKey<'a> { + #[inline] + fn hash<H: Hasher>(&self, state: &mut H) { + match *self { + CbKey::Command { + ref commands, + command_id, + resource_ty, + resource_index, + } => { + let commands_lock = commands.lock().unwrap(); + + match resource_ty { + KeyTy::Buffer => { + let c = &commands_lock[command_id]; + c.buffer(resource_index).conflict_key().hash(state) + }, + KeyTy::Image => { + let c = &commands_lock[command_id]; + c.image(resource_index).conflict_key().hash(state) + }, + } + }, + + CbKey::BufferRef(buf) => buf.conflict_key().hash(state), + CbKey::ImageRef(img) => img.conflict_key().hash(state), + } + } +} + +impl<P> AsRef<UnsafeCommandBuffer<P>> for SyncCommandBuffer<P> { + #[inline] + fn as_ref(&self) -> &UnsafeCommandBuffer<P> { + &self.inner + } +} + +impl<P> SyncCommandBuffer<P> { + /// Tries to lock the resources used by the command buffer. + /// + /// > **Note**: You should call this in the implementation of the `CommandBuffer` trait. + pub fn lock_submit(&self, future: &GpuFuture, queue: &Queue) + -> Result<(), CommandBufferExecError> { + + let commands_lock = self.commands.lock().unwrap(); + + // Number of resources in `self.resources` that have been successfully locked. + let mut locked_resources = 0; + // Final return value of this function. + let mut ret_value = Ok(()); + + // Try locking resources. Updates `locked_resources` and `ret_value`, and break if an error + // happens. + for (key, entry) in self.resources.iter() { + let (command_id, resource_ty, resource_index) = match *key { + CbKey::Command { + command_id, + resource_ty, + resource_index, + .. + } => { + (command_id, resource_ty, resource_index) + }, + _ => unreachable!(), + }; + + match resource_ty { + KeyTy::Buffer => { + let cmd = &commands_lock[command_id]; + let buf = cmd.buffer(resource_index); + + // Because try_gpu_lock needs to be called first, + // this should never return Ok without first returning Err + let prev_err = match future.check_buffer_access(&buf, entry.exclusive, queue) { + Ok(_) => { + unsafe { + buf.increase_gpu_lock(); + } + locked_resources += 1; + continue; + }, + Err(err) => err, + }; + + match (buf.try_gpu_lock(entry.exclusive, queue), prev_err) { + (Ok(_), _) => (), + (Err(err), AccessCheckError::Unknown) | + (_, AccessCheckError::Denied(err)) => { + ret_value = Err(CommandBufferExecError::AccessError { + error: err, + command_name: cmd.name().into(), + command_param: cmd.buffer_name(resource_index), + command_offset: command_id, + }); + break; + }, + }; + + locked_resources += 1; + }, + + KeyTy::Image => { + let cmd = &commands_lock[command_id]; + let img = cmd.image(resource_index); + + let prev_err = match future.check_image_access(img, entry.initial_layout, + entry.exclusive, queue) + { + Ok(_) => { + unsafe { img.increase_gpu_lock(); } + locked_resources += 1; + continue; + }, + Err(err) => err + }; + + match (img.try_gpu_lock(entry.exclusive, entry.initial_layout), prev_err) { + (Ok(_), _) => (), + (Err(err), AccessCheckError::Unknown) | + (_, AccessCheckError::Denied(err)) => { + ret_value = Err(CommandBufferExecError::AccessError { + error: err, + command_name: cmd.name().into(), + command_param: cmd.image_name(resource_index), + command_offset: command_id, + }); + break; + }, + }; + + locked_resources += 1; + }, + } + } + + // If we are going to return an error, we have to unlock all the resources we locked above. + if let Err(_) = ret_value { + for key in self.resources.keys().take(locked_resources) { + let (command_id, resource_ty, resource_index) = match *key { + CbKey::Command { + command_id, + resource_ty, + resource_index, + .. + } => { + (command_id, resource_ty, resource_index) + }, + _ => unreachable!(), + }; + + match resource_ty { + KeyTy::Buffer => { + let cmd = &commands_lock[command_id]; + let buf = cmd.buffer(resource_index); + unsafe { + buf.unlock(); + } + }, + + KeyTy::Image => { + let cmd = &commands_lock[command_id]; + let img = cmd.image(resource_index); + unsafe { + img.unlock(None); + } + }, + } + } + } + + // TODO: pipeline barriers if necessary? + + ret_value + } + + /// Unlocks the resources used by the command buffer. + /// + /// > **Note**: You should call this in the implementation of the `CommandBuffer` trait. + /// + /// # Safety + /// + /// The command buffer must have been successfully locked with `lock_submit()`. + /// + pub unsafe fn unlock(&self) { + let commands_lock = self.commands.lock().unwrap(); + + for (key, val) in self.resources.iter() { + let (command_id, resource_ty, resource_index) = match *key { + CbKey::Command { + command_id, + resource_ty, + resource_index, + .. + } => { + (command_id, resource_ty, resource_index) + }, + _ => unreachable!(), + }; + + match resource_ty { + KeyTy::Buffer => { + let cmd = &commands_lock[command_id]; + let buf = cmd.buffer(resource_index); + buf.unlock(); + }, + KeyTy::Image => { + let cmd = &commands_lock[command_id]; + let img = cmd.image(resource_index); + let trans = if val.final_layout != val.initial_layout { + Some(val.final_layout) + } else { + None + }; + img.unlock(trans); + }, + } + } + } + + /// Checks whether this command buffer has access to a buffer. + /// + /// > **Note**: Suitable when implementing the `CommandBuffer` trait. + #[inline] + pub fn check_buffer_access( + &self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + // TODO: check the queue family + + if let Some(value) = self.resources.get(&CbKey::BufferRef(buffer)) { + if !value.exclusive && exclusive { + return Err(AccessCheckError::Unknown); + } + + return Ok(Some((value.final_stages, value.final_access))); + } + + Err(AccessCheckError::Unknown) + } + + /// Checks whether this command buffer has access to an image. + /// + /// > **Note**: Suitable when implementing the `CommandBuffer` trait. + #[inline] + pub fn check_image_access( + &self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + // TODO: check the queue family + + if let Some(value) = self.resources.get(&CbKey::ImageRef(image)) { + if layout != ImageLayout::Undefined && value.final_layout != layout { + return Err(AccessCheckError::Denied(AccessError::UnexpectedImageLayout { + allowed: value.final_layout, + requested: layout, + })); + } + + if !value.exclusive && exclusive { + return Err(AccessCheckError::Unknown); + } + + return Ok(Some((value.final_stages, value.final_access))); + } + + Err(AccessCheckError::Unknown) + } +} + +unsafe impl<P> DeviceOwned for SyncCommandBuffer<P> { + #[inline] + fn device(&self) -> &Arc<Device> { + self.inner.device() + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/commands.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/commands.rs new file mode 100644 index 0000000..655d3fe --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/commands.rs @@ -0,0 +1,2193 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::any::Any; +use std::borrow::Cow; +use std::mem; +use std::ptr; +use std::sync::Arc; + +use buffer::BufferAccess; +use command_buffer::CommandBuffer; +use command_buffer::synced::base::Command; +use command_buffer::synced::base::FinalCommand; +use command_buffer::synced::base::KeyTy; +use command_buffer::synced::base::SyncCommandBufferBuilder; +use command_buffer::synced::base::SyncCommandBufferBuilderError; +use command_buffer::sys::UnsafeCommandBufferBuilder; +use command_buffer::sys::UnsafeCommandBufferBuilderBindVertexBuffer; +use command_buffer::sys::UnsafeCommandBufferBuilderBufferImageCopy; +use command_buffer::sys::UnsafeCommandBufferBuilderColorImageClear; +use command_buffer::sys::UnsafeCommandBufferBuilderExecuteCommands; +use command_buffer::sys::UnsafeCommandBufferBuilderImageCopy; +use command_buffer::sys::UnsafeCommandBufferBuilderImageBlit; +use descriptor::descriptor::DescriptorDescTy; +use descriptor::descriptor::ShaderStages; +use descriptor::descriptor_set::DescriptorSet; +use descriptor::pipeline_layout::PipelineLayoutAbstract; +use format::ClearValue; +use framebuffer::FramebufferAbstract; +use framebuffer::SubpassContents; +use image::ImageAccess; +use image::ImageLayout; +use pipeline::ComputePipelineAbstract; +use pipeline::GraphicsPipelineAbstract; +use pipeline::input_assembly::IndexType; +use pipeline::viewport::Scissor; +use pipeline::viewport::Viewport; +use sampler::Filter; +use sync::AccessFlagBits; +use sync::Event; +use sync::PipelineStages; + +impl<P> SyncCommandBufferBuilder<P> { + /// Calls `vkBeginRenderPass` on the builder. + // TODO: it shouldn't be possible to get an error if the framebuffer checked conflicts already + // TODO: after begin_render_pass has been called, flushing should be forbidden and an error + // returned if conflict + #[inline] + pub unsafe fn begin_render_pass<F, I>(&mut self, framebuffer: F, + subpass_contents: SubpassContents, clear_values: I) + -> Result<(), SyncCommandBufferBuilderError> + where F: FramebufferAbstract + Send + Sync + 'static, + I: Iterator<Item = ClearValue> + Send + Sync + 'static + { + struct Cmd<F, I> { + framebuffer: F, + subpass_contents: SubpassContents, + clear_values: Option<I>, + } + + impl<P, F, I> Command<P> for Cmd<F, I> + where F: FramebufferAbstract + Send + Sync + 'static, + I: Iterator<Item = ClearValue> + { + fn name(&self) -> &'static str { + "vkCmdBeginRenderPass" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.begin_render_pass(&self.framebuffer, + self.subpass_contents, + self.clear_values.take().unwrap()); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<F>(F); + impl<F> FinalCommand for Fin<F> + where F: FramebufferAbstract + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdBeginRenderPass" + } + fn image(&self, num: usize) -> &ImageAccess { + self.0.attached_image_view(num).unwrap().parent() + } + fn image_name(&self, num: usize) -> Cow<'static, str> { + format!("attachment {}", num).into() + } + } + Box::new(Fin(self.framebuffer)) + } + + fn image(&self, num: usize) -> &ImageAccess { + self.framebuffer.attached_image_view(num).unwrap().parent() + } + + fn image_name(&self, num: usize) -> Cow<'static, str> { + format!("attachment {}", num).into() + } + } + + let atch_desc = (0 .. framebuffer.num_attachments()) + .map(|atch| framebuffer.attachment_desc(atch).unwrap()) + .collect::<Vec<_>>(); + + self.append_command(Cmd { + framebuffer, + subpass_contents, + clear_values: Some(clear_values), + }); + + for (atch, desc) in atch_desc.into_iter().enumerate() { + self.prev_cmd_resource(KeyTy::Image, atch, true, // TODO: suboptimal ; note: remember to always pass true if desc.initial_layout != desc.final_layout + PipelineStages { + all_commands: true, + .. PipelineStages::none() + }, // TODO: wrong! + AccessFlagBits { + input_attachment_read: true, + color_attachment_read: true, + color_attachment_write: true, + depth_stencil_attachment_read: true, + depth_stencil_attachment_write: true, + .. AccessFlagBits::none() + }, // TODO: suboptimal + desc.initial_layout, desc.final_layout)?; + } + + self.prev_cmd_entered_render_pass(); + Ok(()) + } + + /// Calls `vkCmdBindIndexBuffer` on the builder. + #[inline] + pub unsafe fn bind_index_buffer<B>(&mut self, buffer: B, index_ty: IndexType) + -> Result<(), SyncCommandBufferBuilderError> + where B: BufferAccess + Send + Sync + 'static + { + struct Cmd<B> { + buffer: B, + index_ty: IndexType, + } + + impl<P, B> Command<P> for Cmd<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdBindIndexBuffer" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.bind_index_buffer(&self.buffer, self.index_ty); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<B>(B); + impl<B> FinalCommand for Fin<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdBindIndexBuffer" + } + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.0 + } + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "index buffer".into() + } + } + Box::new(Fin(self.buffer)) + } + + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.buffer + } + + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "index buffer".into() + } + } + + self.append_command(Cmd { buffer, index_ty }); + self.prev_cmd_resource(KeyTy::Buffer, + 0, + false, + PipelineStages { + vertex_input: true, + ..PipelineStages::none() + }, + AccessFlagBits { + index_read: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined)?; + Ok(()) + } + + /// Calls `vkCmdBindPipeline` on the builder with a graphics pipeline. + #[inline] + pub unsafe fn bind_pipeline_graphics<Gp>(&mut self, pipeline: Gp) + where Gp: GraphicsPipelineAbstract + Send + Sync + 'static + { + struct Cmd<Gp> { + pipeline: Gp, + } + + impl<P, Gp> Command<P> for Cmd<Gp> + where Gp: GraphicsPipelineAbstract + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdBindPipeline" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.bind_pipeline_graphics(&self.pipeline); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<Gp>(Gp); + impl<Gp> FinalCommand for Fin<Gp> + where Gp: Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdBindPipeline" + } + } + Box::new(Fin(self.pipeline)) + } + } + + self.append_command(Cmd { pipeline }); + } + + /// Calls `vkCmdBindPipeline` on the builder with a compute pipeline. + #[inline] + pub unsafe fn bind_pipeline_compute<Cp>(&mut self, pipeline: Cp) + where Cp: ComputePipelineAbstract + Send + Sync + 'static + { + struct Cmd<Gp> { + pipeline: Gp, + } + + impl<P, Gp> Command<P> for Cmd<Gp> + where Gp: ComputePipelineAbstract + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdBindPipeline" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.bind_pipeline_compute(&self.pipeline); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<Cp>(Cp); + impl<Cp> FinalCommand for Fin<Cp> + where Cp: Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdBindPipeline" + } + } + Box::new(Fin(self.pipeline)) + } + } + + self.append_command(Cmd { pipeline }); + } + + /// Starts the process of binding descriptor sets. Returns an intermediate struct which can be + /// used to add the sets. + #[inline] + pub fn bind_descriptor_sets(&mut self) -> SyncCommandBufferBuilderBindDescriptorSets<P> { + SyncCommandBufferBuilderBindDescriptorSets { + builder: self, + inner: SmallVec::new(), + } + } + + /// Starts the process of binding vertex buffers. Returns an intermediate struct which can be + /// used to add the buffers. + #[inline] + pub fn bind_vertex_buffers(&mut self) -> SyncCommandBufferBuilderBindVertexBuffer<P> { + SyncCommandBufferBuilderBindVertexBuffer { + builder: self, + inner: UnsafeCommandBufferBuilderBindVertexBuffer::new(), + buffers: Vec::new(), + } + } + + /// Calls `vkCmdCopyImage` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn copy_image<S, D, R>(&mut self, source: S, source_layout: ImageLayout, + destination: D, destination_layout: ImageLayout, regions: R) + -> Result<(), SyncCommandBufferBuilderError> + where S: ImageAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static, + R: Iterator<Item = UnsafeCommandBufferBuilderImageCopy> + Send + Sync + 'static + { + struct Cmd<S, D, R> { + source: Option<S>, + source_layout: ImageLayout, + destination: Option<D>, + destination_layout: ImageLayout, + regions: Option<R>, + } + + impl<P, S, D, R> Command<P> for Cmd<S, D, R> + where S: ImageAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static, + R: Iterator<Item = UnsafeCommandBufferBuilderImageCopy> + { + fn name(&self) -> &'static str { + "vkCmdCopyImage" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.copy_image(self.source.as_ref().unwrap(), + self.source_layout, + self.destination.as_ref().unwrap(), + self.destination_layout, + self.regions.take().unwrap()); + } + + fn into_final_command(mut self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<S, D>(S, D); + impl<S, D> FinalCommand for Fin<S, D> + where S: ImageAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdCopyImage" + } + fn image(&self, num: usize) -> &ImageAccess { + if num == 0 { + &self.0 + } else if num == 1 { + &self.1 + } else { + panic!() + } + } + fn image_name(&self, num: usize) -> Cow<'static, str> { + if num == 0 { + "source".into() + } else if num == 1 { + "destination".into() + } else { + panic!() + } + } + } + + // Note: borrow checker somehow doesn't accept `self.source` and `self.destination` + // without using an Option. + Box::new(Fin(self.source.take().unwrap(), + self.destination.take().unwrap())) + } + + fn image(&self, num: usize) -> &ImageAccess { + if num == 0 { + self.source.as_ref().unwrap() + } else if num == 1 { + self.destination.as_ref().unwrap() + } else { + panic!() + } + } + + fn image_name(&self, num: usize) -> Cow<'static, str> { + if num == 0 { + "source".into() + } else if num == 1 { + "destination".into() + } else { + panic!() + } + } + } + + self.append_command(Cmd { + source: Some(source), + source_layout, + destination: Some(destination), + destination_layout, + regions: Some(regions), + }); + self.prev_cmd_resource(KeyTy::Image, + 0, + false, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_read: true, + ..AccessFlagBits::none() + }, + source_layout, + source_layout)?; + self.prev_cmd_resource(KeyTy::Image, + 1, + true, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_write: true, + ..AccessFlagBits::none() + }, + destination_layout, + destination_layout)?; + Ok(()) + } + + /// Calls `vkCmdBlitImage` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn blit_image<S, D, R>(&mut self, source: S, source_layout: ImageLayout, + destination: D, destination_layout: ImageLayout, regions: R, + filter: Filter) + -> Result<(), SyncCommandBufferBuilderError> + where S: ImageAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static, + R: Iterator<Item = UnsafeCommandBufferBuilderImageBlit> + Send + Sync + 'static + { + struct Cmd<S, D, R> { + source: Option<S>, + source_layout: ImageLayout, + destination: Option<D>, + destination_layout: ImageLayout, + regions: Option<R>, + filter: Filter, + } + + impl<P, S, D, R> Command<P> for Cmd<S, D, R> + where S: ImageAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static, + R: Iterator<Item = UnsafeCommandBufferBuilderImageBlit> + { + fn name(&self) -> &'static str { + "vkCmdBlitImage" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.blit_image(self.source.as_ref().unwrap(), + self.source_layout, + self.destination.as_ref().unwrap(), + self.destination_layout, + self.regions.take().unwrap(), + self.filter); + } + + fn into_final_command(mut self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<S, D>(S, D); + impl<S, D> FinalCommand for Fin<S, D> + where S: ImageAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdBlitImage" + } + fn image(&self, num: usize) -> &ImageAccess { + if num == 0 { + &self.0 + } else if num == 1 { + &self.1 + } else { + panic!() + } + } + fn image_name(&self, num: usize) -> Cow<'static, str> { + if num == 0 { + "source".into() + } else if num == 1 { + "destination".into() + } else { + panic!() + } + } + } + + // Note: borrow checker somehow doesn't accept `self.source` and `self.destination` + // without using an Option. + Box::new(Fin(self.source.take().unwrap(), + self.destination.take().unwrap())) + } + + fn image(&self, num: usize) -> &ImageAccess { + if num == 0 { + self.source.as_ref().unwrap() + } else if num == 1 { + self.destination.as_ref().unwrap() + } else { + panic!() + } + } + + fn image_name(&self, num: usize) -> Cow<'static, str> { + if num == 0 { + "source".into() + } else if num == 1 { + "destination".into() + } else { + panic!() + } + } + } + + self.append_command(Cmd { + source: Some(source), + source_layout, + destination: Some(destination), + destination_layout, + regions: Some(regions), + filter, + }); + self.prev_cmd_resource(KeyTy::Image, + 0, + false, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_read: true, + ..AccessFlagBits::none() + }, + source_layout, + source_layout)?; + self.prev_cmd_resource(KeyTy::Image, + 1, + true, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_write: true, + ..AccessFlagBits::none() + }, + destination_layout, + destination_layout)?; + Ok(()) + } + + /// Calls `vkCmdClearColorImage` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + pub unsafe fn clear_color_image<I, R>(&mut self, image: I, layout: ImageLayout, + color: ClearValue, regions: R) + -> Result<(), SyncCommandBufferBuilderError> + where I: ImageAccess + Send + Sync + 'static, + R: Iterator<Item = UnsafeCommandBufferBuilderColorImageClear> + Send + Sync + 'static + { + struct Cmd<I, R> { + image: Option<I>, + layout: ImageLayout, + color: ClearValue, + regions: Option<R>, + } + + impl<P, I, R> Command<P> for Cmd<I, R> + where I: ImageAccess + Send + Sync + 'static, + R: Iterator<Item = UnsafeCommandBufferBuilderColorImageClear> + + Send + + Sync + + 'static + { + fn name(&self) -> &'static str { + "vkCmdClearColorImage" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.clear_color_image(self.image.as_ref().unwrap(), + self.layout, + self.color, + self.regions.take().unwrap()); + } + + fn into_final_command(mut self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<I>(I); + impl<I> FinalCommand for Fin<I> + where I: ImageAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdClearColorImage" + } + fn image(&self, num: usize) -> &ImageAccess { + assert_eq!(num, 0); + &self.0 + } + fn image_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "target".into() + } + } + + // Note: borrow checker somehow doesn't accept `self.image` without using an Option. + Box::new(Fin(self.image.take().unwrap())) + } + + fn image(&self, num: usize) -> &ImageAccess { + assert_eq!(num, 0); + self.image.as_ref().unwrap() + } + + fn image_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "target".into() + } + } + + self.append_command(Cmd { + image: Some(image), + layout, + color, + regions: Some(regions), + }); + self.prev_cmd_resource(KeyTy::Image, + 0, + true, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_write: true, + ..AccessFlagBits::none() + }, + layout, + layout)?; + Ok(()) + } + + /// Calls `vkCmdCopyBuffer` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn copy_buffer<S, D, R>(&mut self, source: S, destination: D, regions: R) + -> Result<(), SyncCommandBufferBuilderError> + where S: BufferAccess + Send + Sync + 'static, + D: BufferAccess + Send + Sync + 'static, + R: Iterator<Item = (usize, usize, usize)> + Send + Sync + 'static + { + struct Cmd<S, D, R> { + source: Option<S>, + destination: Option<D>, + regions: Option<R>, + } + + impl<P, S, D, R> Command<P> for Cmd<S, D, R> + where S: BufferAccess + Send + Sync + 'static, + D: BufferAccess + Send + Sync + 'static, + R: Iterator<Item = (usize, usize, usize)> + { + fn name(&self) -> &'static str { + "vkCmdCopyBuffer" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.copy_buffer(self.source.as_ref().unwrap(), + self.destination.as_ref().unwrap(), + self.regions.take().unwrap()); + } + + fn into_final_command(mut self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<S, D>(S, D); + impl<S, D> FinalCommand for Fin<S, D> + where S: BufferAccess + Send + Sync + 'static, + D: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdCopyBuffer" + } + fn buffer(&self, num: usize) -> &BufferAccess { + match num { + 0 => &self.0, + 1 => &self.1, + _ => panic!(), + } + } + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + match num { + 0 => "source".into(), + 1 => "destination".into(), + _ => panic!(), + } + } + } + // Note: borrow checker somehow doesn't accept `self.source` and `self.destination` + // without using an Option. + Box::new(Fin(self.source.take().unwrap(), + self.destination.take().unwrap())) + } + + fn buffer(&self, num: usize) -> &BufferAccess { + match num { + 0 => self.source.as_ref().unwrap(), + 1 => self.destination.as_ref().unwrap(), + _ => panic!(), + } + } + + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + match num { + 0 => "source".into(), + 1 => "destination".into(), + _ => panic!(), + } + } + } + + self.append_command(Cmd { + source: Some(source), + destination: Some(destination), + regions: Some(regions), + }); + self.prev_cmd_resource(KeyTy::Buffer, + 0, + false, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_read: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined)?; + self.prev_cmd_resource(KeyTy::Buffer, + 1, + true, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_write: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined)?; + Ok(()) + } + + /// Calls `vkCmdCopyBufferToImage` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn copy_buffer_to_image<S, D, R>(&mut self, source: S, destination: D, + destination_layout: ImageLayout, regions: R) + -> Result<(), SyncCommandBufferBuilderError> + where S: BufferAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static, + R: Iterator<Item = UnsafeCommandBufferBuilderBufferImageCopy> + Send + Sync + 'static + { + struct Cmd<S, D, R> { + source: Option<S>, + destination: Option<D>, + destination_layout: ImageLayout, + regions: Option<R>, + } + + impl<P, S, D, R> Command<P> for Cmd<S, D, R> + where S: BufferAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static, + R: Iterator<Item = UnsafeCommandBufferBuilderBufferImageCopy> + { + fn name(&self) -> &'static str { + "vkCmdCopyBufferToImage" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.copy_buffer_to_image(self.source.as_ref().unwrap(), + self.destination.as_ref().unwrap(), + self.destination_layout, + self.regions.take().unwrap()); + } + + fn into_final_command(mut self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<S, D>(S, D); + impl<S, D> FinalCommand for Fin<S, D> + where S: BufferAccess + Send + Sync + 'static, + D: ImageAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdCopyBufferToImage" + } + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.0 + } + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "source".into() + } + fn image(&self, num: usize) -> &ImageAccess { + assert_eq!(num, 0); + &self.1 + } + fn image_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "destination".into() + } + } + + // Note: borrow checker somehow doesn't accept `self.source` and `self.destination` + // without using an Option. + Box::new(Fin(self.source.take().unwrap(), + self.destination.take().unwrap())) + } + + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + self.source.as_ref().unwrap() + } + + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "source".into() + } + + fn image(&self, num: usize) -> &ImageAccess { + assert_eq!(num, 0); + self.destination.as_ref().unwrap() + } + + fn image_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "destination".into() + } + } + + self.append_command(Cmd { + source: Some(source), + destination: Some(destination), + destination_layout: destination_layout, + regions: Some(regions), + }); + self.prev_cmd_resource(KeyTy::Buffer, + 0, + false, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_read: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined)?; + self.prev_cmd_resource(KeyTy::Image, + 0, + true, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_write: true, + ..AccessFlagBits::none() + }, + destination_layout, + destination_layout)?; + Ok(()) + } + + /// Calls `vkCmdCopyImageToBuffer` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn copy_image_to_buffer<S, D, R>(&mut self, source: S, source_layout: ImageLayout, + destination: D, regions: R) + -> Result<(), SyncCommandBufferBuilderError> + where S: ImageAccess + Send + Sync + 'static, + D: BufferAccess + Send + Sync + 'static, + R: Iterator<Item = UnsafeCommandBufferBuilderBufferImageCopy> + Send + Sync + 'static + { + struct Cmd<S, D, R> { + source: Option<S>, + source_layout: ImageLayout, + destination: Option<D>, + regions: Option<R>, + } + + impl<P, S, D, R> Command<P> for Cmd<S, D, R> + where S: ImageAccess + Send + Sync + 'static, + D: BufferAccess + Send + Sync + 'static, + R: Iterator<Item = UnsafeCommandBufferBuilderBufferImageCopy> + { + fn name(&self) -> &'static str { + "vkCmdCopyImageToBuffer" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.copy_image_to_buffer(self.source.as_ref().unwrap(), + self.source_layout, + self.destination.as_ref().unwrap(), + self.regions.take().unwrap()); + } + + fn into_final_command(mut self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<S, D>(S, D); + impl<S, D> FinalCommand for Fin<S, D> + where S: ImageAccess + Send + Sync + 'static, + D: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdCopyImageToBuffer" + } + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.1 + } + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "destination".into() + } + fn image(&self, num: usize) -> &ImageAccess { + assert_eq!(num, 0); + &self.0 + } + fn image_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "source".into() + } + } + + // Note: borrow checker somehow doesn't accept `self.source` and `self.destination` + // without using an Option. + Box::new(Fin(self.source.take().unwrap(), + self.destination.take().unwrap())) + } + + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + self.destination.as_ref().unwrap() + } + + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "destination".into() + } + + fn image(&self, num: usize) -> &ImageAccess { + assert_eq!(num, 0); + self.source.as_ref().unwrap() + } + + fn image_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "source".into() + } + } + + self.append_command(Cmd { + source: Some(source), + destination: Some(destination), + source_layout: source_layout, + regions: Some(regions), + }); + self.prev_cmd_resource(KeyTy::Image, + 0, + false, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_read: true, + ..AccessFlagBits::none() + }, + source_layout, + source_layout)?; + self.prev_cmd_resource(KeyTy::Buffer, + 0, + true, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_write: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined)?; + Ok(()) + } + + /// Calls `vkCmdDispatch` on the builder. + #[inline] + pub unsafe fn dispatch(&mut self, dimensions: [u32; 3]) { + struct Cmd { + dimensions: [u32; 3], + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdDispatch" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.dispatch(self.dimensions); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdDispatch") + } + } + + self.append_command(Cmd { dimensions }); + } + + /// Calls `vkCmdDispatchIndirect` on the builder. + #[inline] + pub unsafe fn dispatch_indirect<B>(&mut self, buffer: B) + -> Result<(), SyncCommandBufferBuilderError> + where B: BufferAccess + Send + Sync + 'static + { + struct Cmd<B> { + buffer: B, + } + + impl<P, B> Command<P> for Cmd<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdDispatchIndirect" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.dispatch_indirect(&self.buffer); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<B>(B); + impl<B> FinalCommand for Fin<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdDispatchIndirect" + } + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.0 + } + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "indirect buffer".into() + } + } + Box::new(Fin(self.buffer)) + } + + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.buffer + } + + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "indirect buffer".into() + } + } + + self.append_command(Cmd { buffer }); + self.prev_cmd_resource(KeyTy::Buffer, + 0, + false, + PipelineStages { + draw_indirect: true, + ..PipelineStages::none() + }, // TODO: is draw_indirect correct? + AccessFlagBits { + indirect_command_read: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined)?; + Ok(()) + } + + /// Calls `vkCmdDraw` on the builder. + #[inline] + pub unsafe fn draw(&mut self, vertex_count: u32, instance_count: u32, first_vertex: u32, + first_instance: u32) { + struct Cmd { + vertex_count: u32, + instance_count: u32, + first_vertex: u32, + first_instance: u32, + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdDraw" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.draw(self.vertex_count, + self.instance_count, + self.first_vertex, + self.first_instance); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdDraw") + } + } + + self.append_command(Cmd { + vertex_count, + instance_count, + first_vertex, + first_instance, + }); + + } + + /// Calls `vkCmdDrawIndexed` on the builder. + #[inline] + pub unsafe fn draw_indexed(&mut self, index_count: u32, instance_count: u32, + first_index: u32, vertex_offset: i32, first_instance: u32) { + struct Cmd { + index_count: u32, + instance_count: u32, + first_index: u32, + vertex_offset: i32, + first_instance: u32, + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdDrawIndexed" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.draw_indexed(self.index_count, + self.instance_count, + self.first_index, + self.vertex_offset, + self.first_instance); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdDrawIndexed") + } + } + + self.append_command(Cmd { + index_count, + instance_count, + first_index, + vertex_offset, + first_instance, + }); + } + + /// Calls `vkCmdDrawIndirect` on the builder. + #[inline] + pub unsafe fn draw_indirect<B>(&mut self, buffer: B, draw_count: u32, stride: u32) + -> Result<(), SyncCommandBufferBuilderError> + where B: BufferAccess + Send + Sync + 'static + { + struct Cmd<B> { + buffer: B, + draw_count: u32, + stride: u32, + } + + impl<P, B> Command<P> for Cmd<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdDrawIndirect" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.draw_indirect(&self.buffer, self.draw_count, self.stride); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<B>(B); + impl<B> FinalCommand for Fin<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdDrawIndirect" + } + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.0 + } + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "indirect buffer".into() + } + } + Box::new(Fin(self.buffer)) + } + + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.buffer + } + + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "indirect buffer".into() + } + } + + self.append_command(Cmd { + buffer, + draw_count, + stride, + }); + self.prev_cmd_resource(KeyTy::Buffer, + 0, + false, + PipelineStages { + draw_indirect: true, + ..PipelineStages::none() + }, + AccessFlagBits { + indirect_command_read: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined)?; + Ok(()) + } + + /// Calls `vkCmdDrawIndexedIndirect` on the builder. + #[inline] + pub unsafe fn draw_indexed_indirect<B>(&mut self, buffer: B, draw_count: u32, stride: u32) + -> Result<(), SyncCommandBufferBuilderError> + where B: BufferAccess + Send + Sync + 'static + { + struct Cmd<B> { + buffer: B, + draw_count: u32, + stride: u32, + } + + impl<P, B> Command<P> for Cmd<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdDrawIndexedIndirect" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.draw_indexed_indirect(&self.buffer, self.draw_count, self.stride); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<B>(B); + impl<B> FinalCommand for Fin<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdDrawIndexedIndirect" + } + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.0 + } + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "indirect buffer".into() + } + } + Box::new(Fin(self.buffer)) + } + + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.buffer + } + + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + assert_eq!(num, 0); + "indirect buffer".into() + } + } + + self.append_command(Cmd { + buffer, + draw_count, + stride, + }); + self.prev_cmd_resource(KeyTy::Buffer, + 0, + false, + PipelineStages { + draw_indirect: true, + ..PipelineStages::none() + }, + AccessFlagBits { + indirect_command_read: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined)?; + Ok(()) + } + + /// Calls `vkCmdEndRenderPass` on the builder. + #[inline] + pub unsafe fn end_render_pass(&mut self) { + struct Cmd; + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdEndRenderPass" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.end_render_pass(); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdEndRenderPass") + } + } + + self.append_command(Cmd); + self.prev_cmd_left_render_pass(); + } + + /// Starts the process of executing secondary command buffers. Returns an intermediate struct + /// which can be used to add the command buffers. + #[inline] + pub unsafe fn execute_commands(&mut self) -> SyncCommandBufferBuilderExecuteCommands<P> { + SyncCommandBufferBuilderExecuteCommands { + builder: self, + inner: UnsafeCommandBufferBuilderExecuteCommands::new(), + command_buffers: Vec::new(), + } + } + + /// Calls `vkCmdFillBuffer` on the builder. + #[inline] + pub unsafe fn fill_buffer<B>(&mut self, buffer: B, data: u32) + where B: BufferAccess + Send + Sync + 'static + { + struct Cmd<B> { + buffer: B, + data: u32, + } + + impl<P, B> Command<P> for Cmd<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdFillBuffer" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.fill_buffer(&self.buffer, self.data); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<B>(B); + impl<B> FinalCommand for Fin<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdFillBuffer" + } + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.0 + } + fn buffer_name(&self, _: usize) -> Cow<'static, str> { + "destination".into() + } + } + Box::new(Fin(self.buffer)) + } + + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.buffer + } + + fn buffer_name(&self, _: usize) -> Cow<'static, str> { + "destination".into() + } + } + + self.append_command(Cmd { buffer, data }); + self.prev_cmd_resource(KeyTy::Buffer, + 0, + true, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_write: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined) + .unwrap(); + } + + /// Calls `vkCmdNextSubpass` on the builder. + #[inline] + pub unsafe fn next_subpass(&mut self, subpass_contents: SubpassContents) { + struct Cmd { + subpass_contents: SubpassContents, + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdNextSubpass" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.next_subpass(self.subpass_contents); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdNextSubpass") + } + } + + self.append_command(Cmd { subpass_contents }); + } + + /// Calls `vkCmdPushConstants` on the builder. + #[inline] + pub unsafe fn push_constants<Pl, D>(&mut self, pipeline_layout: Pl, stages: ShaderStages, + offset: u32, size: u32, data: &D) + where Pl: PipelineLayoutAbstract + Send + Sync + 'static, + D: ?Sized + Send + Sync + 'static + { + struct Cmd<Pl> { + pipeline_layout: Pl, + stages: ShaderStages, + offset: u32, + size: u32, + data: Box<[u8]>, + } + + impl<P, Pl> Command<P> for Cmd<Pl> + where Pl: PipelineLayoutAbstract + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdPushConstants" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.push_constants::<_, [u8]>(&self.pipeline_layout, + self.stages, + self.offset, + self.size, + &self.data); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<Pl>(Pl); + impl<Pl> FinalCommand for Fin<Pl> + where Pl: Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdPushConstants" + } + } + Box::new(Fin(self.pipeline_layout)) + } + } + + debug_assert!(mem::size_of_val(data) >= size as usize); + + let mut out = Vec::with_capacity(size as usize); + ptr::copy::<u8>(data as *const D as *const u8, + out.as_mut_ptr(), + size as usize); + out.set_len(size as usize); + + self.append_command(Cmd { + pipeline_layout, + stages, + offset, + size, + data: out.into(), + }); + } + + /// Calls `vkCmdResetEvent` on the builder. + #[inline] + pub unsafe fn reset_event(&mut self, event: Arc<Event>, stages: PipelineStages) { + struct Cmd { + event: Arc<Event>, + stages: PipelineStages, + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdResetEvent" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.reset_event(&self.event, self.stages); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin(Arc<Event>); + impl FinalCommand for Fin { + fn name(&self) -> &'static str { + "vkCmdResetEvent" + } + } + Box::new(Fin(self.event)) + } + } + + self.append_command(Cmd { event, stages }); + } + + /// Calls `vkCmdSetBlendConstants` on the builder. + #[inline] + pub unsafe fn set_blend_constants(&mut self, constants: [f32; 4]) { + struct Cmd { + constants: [f32; 4], + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdSetBlendConstants" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.set_blend_constants(self.constants); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdSetBlendConstants") + } + } + + self.append_command(Cmd { constants }); + } + + /// Calls `vkCmdSetDepthBias` on the builder. + #[inline] + pub unsafe fn set_depth_bias(&mut self, constant_factor: f32, clamp: f32, slope_factor: f32) { + struct Cmd { + constant_factor: f32, + clamp: f32, + slope_factor: f32, + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdSetDepthBias" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.set_depth_bias(self.constant_factor, self.clamp, self.slope_factor); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdSetDepthBias") + } + } + + self.append_command(Cmd { + constant_factor, + clamp, + slope_factor, + }); + } + + /// Calls `vkCmdSetDepthBounds` on the builder. + #[inline] + pub unsafe fn set_depth_bounds(&mut self, min: f32, max: f32) { + struct Cmd { + min: f32, + max: f32, + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdSetDepthBounds" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.set_depth_bounds(self.min, self.max); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdSetDepthBounds") + } + } + + self.append_command(Cmd { min, max }); + } + + /// Calls `vkCmdSetEvent` on the builder. + #[inline] + pub unsafe fn set_event(&mut self, event: Arc<Event>, stages: PipelineStages) { + struct Cmd { + event: Arc<Event>, + stages: PipelineStages, + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdSetEvent" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.set_event(&self.event, self.stages); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin(Arc<Event>); + impl FinalCommand for Fin { + fn name(&self) -> &'static str { + "vkCmdSetEvent" + } + } + Box::new(Fin(self.event)) + } + } + + self.append_command(Cmd { event, stages }); + } + + /// Calls `vkCmdSetLineWidth` on the builder. + #[inline] + pub unsafe fn set_line_width(&mut self, line_width: f32) { + struct Cmd { + line_width: f32, + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdSetLineWidth" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.set_line_width(self.line_width); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdSetLineWidth") + } + } + + self.append_command(Cmd { line_width }); + } + + // TODO: stencil states + + /// Calls `vkCmdSetScissor` on the builder. + /// + /// If the list is empty then the command is automatically ignored. + #[inline] + pub unsafe fn set_scissor<I>(&mut self, first_scissor: u32, scissors: I) + where I: Iterator<Item = Scissor> + Send + Sync + 'static + { + struct Cmd<I> { + first_scissor: u32, + scissors: Option<I>, + } + + impl<P, I> Command<P> for Cmd<I> + where I: Iterator<Item = Scissor> + { + fn name(&self) -> &'static str { + "vkCmdSetScissor" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.set_scissor(self.first_scissor, self.scissors.take().unwrap()); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdSetScissor") + } + } + + self.append_command(Cmd { + first_scissor, + scissors: Some(scissors), + }); + } + + /// Calls `vkCmdSetViewport` on the builder. + /// + /// If the list is empty then the command is automatically ignored. + #[inline] + pub unsafe fn set_viewport<I>(&mut self, first_viewport: u32, viewports: I) + where I: Iterator<Item = Viewport> + Send + Sync + 'static + { + struct Cmd<I> { + first_viewport: u32, + viewports: Option<I>, + } + + impl<P, I> Command<P> for Cmd<I> + where I: Iterator<Item = Viewport> + { + fn name(&self) -> &'static str { + "vkCmdSetViewport" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.set_viewport(self.first_viewport, self.viewports.take().unwrap()); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + Box::new("vkCmdSetViewport") + } + } + + self.append_command(Cmd { + first_viewport, + viewports: Some(viewports), + }); + } + + /// Calls `vkCmdUpdateBuffer` on the builder. + #[inline] + pub unsafe fn update_buffer<B, D>(&mut self, buffer: B, data: D) + where B: BufferAccess + Send + Sync + 'static, + D: Send + Sync + 'static + { + struct Cmd<B, D> { + buffer: B, + data: D, + } + + impl<P, B, D> Command<P> for Cmd<B, D> + where B: BufferAccess + Send + Sync + 'static, + D: Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdUpdateBuffer" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.update_buffer(&self.buffer, &self.data); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin<B>(B); + impl<B> FinalCommand for Fin<B> + where B: BufferAccess + Send + Sync + 'static + { + fn name(&self) -> &'static str { + "vkCmdUpdateBuffer" + } + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.0 + } + fn buffer_name(&self, _: usize) -> Cow<'static, str> { + "destination".into() + } + } + Box::new(Fin(self.buffer)) + } + + fn buffer(&self, num: usize) -> &BufferAccess { + assert_eq!(num, 0); + &self.buffer + } + + fn buffer_name(&self, _: usize) -> Cow<'static, str> { + "destination".into() + } + } + + self.append_command(Cmd { buffer, data }); + self.prev_cmd_resource(KeyTy::Buffer, + 0, + true, + PipelineStages { + transfer: true, + ..PipelineStages::none() + }, + AccessFlagBits { + transfer_write: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined) + .unwrap(); + } +} + +pub struct SyncCommandBufferBuilderBindDescriptorSets<'b, P: 'b> { + builder: &'b mut SyncCommandBufferBuilder<P>, + inner: SmallVec<[Box<DescriptorSet + Send + Sync>; 12]>, +} + +impl<'b, P> SyncCommandBufferBuilderBindDescriptorSets<'b, P> { + /// Adds a descriptor set to the list. + #[inline] + pub fn add<S>(&mut self, set: S) + where S: DescriptorSet + Send + Sync + 'static + { + self.inner.push(Box::new(set)); + } + + #[inline] + pub unsafe fn submit<Pl, I>(self, graphics: bool, pipeline_layout: Pl, first_binding: u32, + dynamic_offsets: I) + -> Result<(), SyncCommandBufferBuilderError> + where Pl: PipelineLayoutAbstract + Send + Sync + 'static, + I: Iterator<Item = u32> + Send + Sync + 'static + { + if self.inner.is_empty() { + return Ok(()); + } + + struct Cmd<Pl, I> { + inner: SmallVec<[Box<DescriptorSet + Send + Sync>; 12]>, + graphics: bool, + pipeline_layout: Pl, + first_binding: u32, + dynamic_offsets: Option<I>, + } + + impl<P, Pl, I> Command<P> for Cmd<Pl, I> + where Pl: PipelineLayoutAbstract, + I: Iterator<Item = u32> + { + fn name(&self) -> &'static str { + "vkCmdBindDescriptorSets" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.bind_descriptor_sets(self.graphics, + &self.pipeline_layout, + self.first_binding, + self.inner.iter().map(|s| s.inner()), + self.dynamic_offsets.take().unwrap()); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin(SmallVec<[Box<DescriptorSet + Send + Sync>; 12]>); + impl FinalCommand for Fin { + fn name(&self) -> &'static str { + "vkCmdBindDescriptorSets" + } + fn buffer(&self, mut num: usize) -> &BufferAccess { + for set in self.0.iter() { + if let Some(buf) = set.buffer(num) { + return buf.0; + } + num -= set.num_buffers(); + } + panic!() + } + fn buffer_name(&self, mut num: usize) -> Cow<'static, str> { + for (set_num, set) in self.0.iter().enumerate() { + if let Some(buf) = set.buffer(num) { + return format!("Buffer bound to descriptor {} of set {}", + buf.1, + set_num) + .into(); + } + num -= set.num_buffers(); + } + panic!() + } + fn image(&self, mut num: usize) -> &ImageAccess { + for set in self.0.iter() { + if let Some(img) = set.image(num) { + return img.0.parent(); + } + num -= set.num_images(); + } + panic!() + } + fn image_name(&self, mut num: usize) -> Cow<'static, str> { + for (set_num, set) in self.0.iter().enumerate() { + if let Some(img) = set.image(num) { + return format!("Image bound to descriptor {} of set {}", + img.1, + set_num) + .into(); + } + num -= set.num_images(); + } + panic!() + } + } + Box::new(Fin(self.inner)) + } + + fn buffer(&self, mut num: usize) -> &BufferAccess { + for set in self.inner.iter() { + if let Some(buf) = set.buffer(num) { + return buf.0; + } + num -= set.num_buffers(); + } + panic!() + } + + fn buffer_name(&self, mut num: usize) -> Cow<'static, str> { + for (set_num, set) in self.inner.iter().enumerate() { + if let Some(buf) = set.buffer(num) { + return format!("Buffer bound to descriptor {} of set {}", buf.1, set_num) + .into(); + } + num -= set.num_buffers(); + } + panic!() + } + + fn image(&self, mut num: usize) -> &ImageAccess { + for set in self.inner.iter() { + if let Some(img) = set.image(num) { + return img.0.parent(); + } + num -= set.num_images(); + } + panic!() + } + + fn image_name(&self, mut num: usize) -> Cow<'static, str> { + for (set_num, set) in self.inner.iter().enumerate() { + if let Some(img) = set.image(num) { + return format!("Image bound to descriptor {} of set {}", img.1, set_num) + .into(); + } + num -= set.num_images(); + } + panic!() + } + } + + let all_buffers = { + let mut all_buffers = Vec::new(); + for ds in self.inner.iter() { + for buf_num in 0 .. ds.num_buffers() { + let desc = ds.descriptor(ds.buffer(buf_num).unwrap().1 as usize) + .unwrap(); + let write = !desc.readonly; + let (stages, access) = desc.pipeline_stages_and_access(); + all_buffers.push((write, stages, access)); + } + } + all_buffers + }; + + let all_images = { + let mut all_images = Vec::new(); + for ds in self.inner.iter() { + for img_num in 0 .. ds.num_images() { + let (image_view, desc_num) = ds.image(img_num).unwrap(); + let desc = ds.descriptor(desc_num as usize).unwrap(); + let write = !desc.readonly; + let (stages, access) = desc.pipeline_stages_and_access(); + let mut ignore_me_hack = false; + let layout = match desc.ty { + DescriptorDescTy::CombinedImageSampler(_) => { + image_view.descriptor_set_combined_image_sampler_layout() + }, + DescriptorDescTy::Image(ref img) => { + if img.sampled { + image_view.descriptor_set_sampled_image_layout() + } else { + image_view.descriptor_set_storage_image_layout() + } + }, + DescriptorDescTy::InputAttachment { .. } => { + // FIXME: This is tricky. Since we read from the input attachment + // and this input attachment is being written in an earlier pass, + // vulkano will think that it needs to put a pipeline barrier and will + // return a `Conflict` error. For now as a work-around we simply ignore + // input attachments. + ignore_me_hack = true; + image_view.descriptor_set_input_attachment_layout() + }, + _ => panic!("Tried to bind an image to a non-image descriptor"), + }; + all_images.push((write, stages, access, layout, ignore_me_hack)); + } + } + all_images + }; + + self.builder.append_command(Cmd { + inner: self.inner, + graphics, + pipeline_layout, + first_binding, + dynamic_offsets: Some(dynamic_offsets), + }); + + for (n, (write, stages, access)) in all_buffers.into_iter().enumerate() { + self.builder + .prev_cmd_resource(KeyTy::Buffer, + n, + write, + stages, + access, + ImageLayout::Undefined, + ImageLayout::Undefined)?; + } + + for (n, (write, stages, access, layout, ignore_me_hack)) in + all_images.into_iter().enumerate() + { + if ignore_me_hack { + continue; + } + self.builder + .prev_cmd_resource(KeyTy::Image, n, write, stages, access, layout, layout)?; + } + + Ok(()) + } +} + +/// Prototype for a `vkCmdBindVertexBuffers`. +pub struct SyncCommandBufferBuilderBindVertexBuffer<'a, P: 'a> { + builder: &'a mut SyncCommandBufferBuilder<P>, + inner: UnsafeCommandBufferBuilderBindVertexBuffer, + buffers: Vec<Box<BufferAccess + Send + Sync>>, +} + +impl<'a, P> SyncCommandBufferBuilderBindVertexBuffer<'a, P> { + /// Adds a buffer to the list. + #[inline] + pub fn add<B>(&mut self, buffer: B) + where B: BufferAccess + Send + Sync + 'static + { + self.inner.add(&buffer); + self.buffers.push(Box::new(buffer)); + } + + #[inline] + pub unsafe fn submit(self, first_binding: u32) -> Result<(), SyncCommandBufferBuilderError> { + struct Cmd { + first_binding: u32, + inner: Option<UnsafeCommandBufferBuilderBindVertexBuffer>, + buffers: Vec<Box<BufferAccess + Send + Sync>>, + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdBindVertexBuffers" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.bind_vertex_buffers(self.first_binding, self.inner.take().unwrap()); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin(Vec<Box<BufferAccess + Send + Sync>>); + impl FinalCommand for Fin { + fn name(&self) -> &'static str { + "vkCmdBindVertexBuffers" + } + fn buffer(&self, num: usize) -> &BufferAccess { + &self.0[num] + } + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + format!("Buffer #{}", num).into() + } + } + Box::new(Fin(self.buffers)) + } + + fn buffer(&self, num: usize) -> &BufferAccess { + &self.buffers[num] + } + + fn buffer_name(&self, num: usize) -> Cow<'static, str> { + format!("Buffer #{}", num).into() + } + } + + let num_buffers = self.buffers.len(); + + self.builder.append_command(Cmd { + first_binding, + inner: Some(self.inner), + buffers: self.buffers, + }); + + for n in 0 .. num_buffers { + self.builder + .prev_cmd_resource(KeyTy::Buffer, + n, + false, + PipelineStages { + vertex_input: true, + ..PipelineStages::none() + }, + AccessFlagBits { + vertex_attribute_read: true, + ..AccessFlagBits::none() + }, + ImageLayout::Undefined, + ImageLayout::Undefined)?; + } + + Ok(()) + } +} + +/// Prototype for a `vkCmdExecuteCommands`. +// FIXME: synchronization not implemented yet +pub struct SyncCommandBufferBuilderExecuteCommands<'a, P: 'a> { + builder: &'a mut SyncCommandBufferBuilder<P>, + inner: UnsafeCommandBufferBuilderExecuteCommands, + command_buffers: Vec<Box<Any + Send + Sync>>, +} + +impl<'a, P> SyncCommandBufferBuilderExecuteCommands<'a, P> { + /// Adds a command buffer to the list. + #[inline] + pub fn add<C>(&mut self, command_buffer: C) + where C: CommandBuffer + Send + Sync + 'static + { + self.inner.add(&command_buffer); + self.command_buffers + .push(Box::new(command_buffer) as Box<_>); + } + + #[inline] + pub unsafe fn submit(self) -> Result<(), SyncCommandBufferBuilderError> { + struct Cmd { + inner: Option<UnsafeCommandBufferBuilderExecuteCommands>, + command_buffers: Vec<Box<Any + Send + Sync>>, + } + + impl<P> Command<P> for Cmd { + fn name(&self) -> &'static str { + "vkCmdExecuteCommands" + } + + unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) { + out.execute_commands(self.inner.take().unwrap()); + } + + fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> { + struct Fin(Vec<Box<Any + Send + Sync>>); + impl FinalCommand for Fin { + fn name(&self) -> &'static str { + "vkCmdExecuteCommands" + } + } + Box::new(Fin(self.command_buffers)) + } + } + + self.builder.append_command(Cmd { + inner: Some(self.inner), + command_buffers: self.command_buffers, + }); + Ok(()) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/mod.rs new file mode 100644 index 0000000..8c9a845 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/mod.rs @@ -0,0 +1,23 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Contains `SyncCommandBufferBuilder` and `SyncCommandBuffer`. + +pub use self::base::SyncCommandBuffer; +pub use self::base::SyncCommandBufferBuilder; +pub use self::base::SyncCommandBufferBuilderError; +pub use self::commands::SyncCommandBufferBuilderBindDescriptorSets; +pub use self::commands::SyncCommandBufferBuilderBindVertexBuffer; +pub use self::commands::SyncCommandBufferBuilderExecuteCommands; + +mod base; +mod commands; + +#[cfg(test)] +mod tests; diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/tests.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/tests.rs new file mode 100644 index 0000000..12a237c --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/synced/tests.rs @@ -0,0 +1,44 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::iter; + +use buffer::BufferUsage; +use buffer::CpuAccessibleBuffer; +use command_buffer::synced::base::SyncCommandBufferBuilder; +use command_buffer::synced::base::SyncCommandBufferBuilderError; +use command_buffer::sys::Flags; +use command_buffer::sys::Kind; +use device::Device; + +#[test] +fn basic_creation() { + unsafe { + let (device, queue) = gfx_dev_and_queue!(); + let pool = Device::standard_command_pool(&device, queue.family()); + SyncCommandBufferBuilder::new(&pool, Kind::primary(), Flags::None).unwrap(); + } +} + +#[test] +fn basic_conflict() { + unsafe { + let (device, queue) = gfx_dev_and_queue!(); + + let pool = Device::standard_command_pool(&device, queue.family()); + let mut sync = SyncCommandBufferBuilder::new(&pool, Kind::primary(), Flags::None).unwrap(); + + let buf = CpuAccessibleBuffer::from_data(device, BufferUsage::all(), 0u32).unwrap(); + + match sync.copy_buffer(buf.clone(), buf.clone(), iter::once((0, 0, 4))) { + Err(SyncCommandBufferBuilderError::Conflict { .. }) => (), + _ => panic!(), + }; + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/sys.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/sys.rs new file mode 100644 index 0000000..4d92afb --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/sys.rs @@ -0,0 +1,1961 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::fmt; +use std::mem; +use std::ops::Range; +use std::ptr; +use std::sync::Arc; +use std::ffi::CStr; + +use OomError; +use VulkanObject; +use buffer::BufferAccess; +use buffer::BufferInner; +use check_errors; +use command_buffer::CommandBuffer; +use command_buffer::pool::CommandPool; +use command_buffer::pool::CommandPoolAlloc; +use command_buffer::pool::CommandPoolBuilderAlloc; +use descriptor::descriptor::ShaderStages; +use descriptor::descriptor_set::UnsafeDescriptorSet; +use descriptor::pipeline_layout::PipelineLayoutAbstract; +use device::Device; +use device::DeviceOwned; +use format::ClearValue; +use format::FormatTy; +use format::PossibleCompressedFormatDesc; +use framebuffer::EmptySinglePassRenderPassDesc; +use framebuffer::Framebuffer; +use framebuffer::FramebufferAbstract; +use framebuffer::RenderPass; +use framebuffer::RenderPassAbstract; +use framebuffer::Subpass; +use framebuffer::SubpassContents; +use image::ImageAccess; +use image::ImageLayout; +use instance::QueueFamily; +use pipeline::ComputePipelineAbstract; +use pipeline::GraphicsPipelineAbstract; +use pipeline::input_assembly::IndexType; +use pipeline::viewport::Scissor; +use pipeline::viewport::Viewport; +use query::QueryPipelineStatisticFlags; +use query::UnsafeQueriesRange; +use query::UnsafeQuery; +use sampler::Filter; +use sync::AccessFlagBits; +use sync::Event; +use sync::PipelineStages; +use vk; + +/// Determines the kind of command buffer that we want to create. +#[derive(Debug, Clone)] +pub enum Kind<R, F> { + /// A primary command buffer can execute all commands and can call secondary command buffers. + Primary, + + /// A secondary command buffer. + Secondary { + /// If `Some`, can only call draw operations that can be executed from within a specific + /// subpass. Otherwise it can execute all dispatch and transfer operations, but not drawing + /// operations. + render_pass: Option<KindSecondaryRenderPass<R, F>>, + + /// Whether it is allowed to have an active occlusion query in the primary command buffer + /// when executing this secondary command buffer. + occlusion_query: KindOcclusionQuery, + + /// Which pipeline statistics queries are allowed to be active when this secondary command + /// buffer starts. + /// + /// Note that the `pipeline_statistics_query` feature must be enabled if any of the flags + /// of this value are set. + query_statistics_flags: QueryPipelineStatisticFlags, + }, +} + +/// Additional information for `Kind::Secondary`. +#[derive(Debug, Clone)] +pub struct KindSecondaryRenderPass<R, F> { + /// Which subpass this secondary command buffer can be called from. + pub subpass: Subpass<R>, + + /// The framebuffer object that will be used when calling the command buffer. + /// This parameter is optional and is an optimization hint for the implementation. + pub framebuffer: Option<F>, +} + +/// Additional information for `Kind::Secondary`. +#[derive(Debug, Copy, Clone)] +pub enum KindOcclusionQuery { + /// It is allowed to have an active occlusion query in the primary command buffer when + /// executing this secondary command buffer. + /// + /// The `inherited_queries` feature must be enabled on the device for this to be a valid option. + Allowed { + /// The occlusion query can have the `control_precise` flag. + control_precise_allowed: bool, + }, + + /// It is forbidden to have an active occlusion query. + Forbidden, +} + +impl + Kind<RenderPass<EmptySinglePassRenderPassDesc>, + Framebuffer<RenderPass<EmptySinglePassRenderPassDesc>, ()>> { + /// Equivalent to `Kind::Primary`. + /// + /// > **Note**: If you use `let kind = Kind::Primary;` in your code, you will probably get a + /// > compilation error because the Rust compiler couldn't determine the template parameters + /// > of `Kind`. To solve that problem in an easy way you can use this function instead. + #[inline] + pub fn primary() + -> Kind<Arc<RenderPass<EmptySinglePassRenderPassDesc>>, + Framebuffer<RenderPass<EmptySinglePassRenderPassDesc>, ()>> + { + Kind::Primary + } + + /// Equivalent to `Kind::Secondary`. + /// + /// > **Note**: If you use `let kind = Kind::Secondary;` in your code, you will probably get a + /// > compilation error because the Rust compiler couldn't determine the template parameters + /// > of `Kind`. To solve that problem in an easy way you can use this function instead. + #[inline] + pub fn secondary(occlusion_query: KindOcclusionQuery, + query_statistics_flags: QueryPipelineStatisticFlags) + -> Kind<Arc<RenderPass<EmptySinglePassRenderPassDesc>>, + Framebuffer<RenderPass<EmptySinglePassRenderPassDesc>, ()>> { + Kind::Secondary { + render_pass: None, + occlusion_query, + query_statistics_flags, + } + } +} + +/// Flags to pass when creating a command buffer. +/// +/// The safest option is `SimultaneousUse`, but it may be slower than the other two. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum Flags { + /// The command buffer can be used multiple times, but must not execute more than once + /// simultaneously. + None, + + /// The command buffer can be executed multiple times in parallel. + SimultaneousUse, + + /// The command buffer can only be submitted once. Any further submit is forbidden. + OneTimeSubmit, +} + +/// Command buffer being built. +/// +/// You can add commands to an `UnsafeCommandBufferBuilder` by using the `AddCommand` trait. +/// The `AddCommand<&Cmd>` trait is implemented on the `UnsafeCommandBufferBuilder` for any `Cmd` +/// that is a raw Vulkan command. +/// +/// When you are finished adding commands, you can use the `CommandBufferBuild` trait to turn this +/// builder into an `UnsafeCommandBuffer`. +pub struct UnsafeCommandBufferBuilder<P> { + // The command buffer obtained from the pool. Contains `None` if `build()` has been called. + cmd: Option<P>, + + // The raw `cmd`. Avoids having to specify a trait bound on `P`. + cmd_raw: vk::CommandBuffer, + + // Device that owns the command buffer. + // TODO: necessary? + device: Arc<Device>, +} + +impl<P> fmt::Debug for UnsafeCommandBufferBuilder<P> { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "<Vulkan command buffer builder #{}>", self.cmd_raw) + } +} + +impl<P> UnsafeCommandBufferBuilder<P> { + /// Creates a new builder. + /// + /// # Safety + /// + /// Creating and destroying an unsafe command buffer is not unsafe per se, but the commands + /// that you add to it are unchecked, do not have any synchronization, and are not kept alive. + /// + /// In other words, it is your job to make sure that the commands you add are valid, that they + /// don't use resources that have been destroyed, and that they do not introduce any race + /// condition. + /// + /// > **Note**: Some checks are still made with `debug_assert!`. Do not expect to be able to + /// > submit invalid commands. + pub unsafe fn new<Pool, R, F, A>(pool: &Pool, kind: Kind<R, F>, flags: Flags) + -> Result<UnsafeCommandBufferBuilder<P>, OomError> + where Pool: CommandPool<Builder = P, Alloc = A>, + P: CommandPoolBuilderAlloc<Alloc = A>, + A: CommandPoolAlloc, + R: RenderPassAbstract, + F: FramebufferAbstract + { + let secondary = match kind { + Kind::Primary => false, + Kind::Secondary { .. } => true, + }; + + let cmd = pool.alloc(secondary, 1)? + .next() + .expect("Requested one command buffer from the command pool, but got zero."); + UnsafeCommandBufferBuilder::already_allocated(cmd, kind, flags) + } + + /// Creates a new command buffer builder from an already-allocated command buffer. + /// + /// # Safety + /// + /// See the `new` method. + /// + /// The kind must match how the command buffer was allocated. + /// + pub unsafe fn already_allocated<R, F>(alloc: P, kind: Kind<R, F>, flags: Flags) + -> Result<UnsafeCommandBufferBuilder<P>, OomError> + where R: RenderPassAbstract, + F: FramebufferAbstract, + P: CommandPoolBuilderAlloc + { + let device = alloc.device().clone(); + let vk = device.pointers(); + let cmd = alloc.inner().internal_object(); + + let vk_flags = { + let a = match flags { + Flags::None => 0, + Flags::SimultaneousUse => vk::COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, + Flags::OneTimeSubmit => vk::COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, + }; + + let b = match kind { + Kind::Secondary { ref render_pass, .. } if render_pass.is_some() => { + vk::COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT + }, + _ => 0, + }; + + a | b + }; + + let (rp, sp, fb) = match kind { + Kind::Secondary { render_pass: Some(ref render_pass), .. } => { + let rp = render_pass.subpass.render_pass().inner().internal_object(); + let sp = render_pass.subpass.index(); + let fb = match render_pass.framebuffer { + Some(ref fb) => { + // TODO: debug assert that the framebuffer is compatible with + // the render pass? + FramebufferAbstract::inner(fb).internal_object() + }, + None => 0, + }; + (rp, sp, fb) + }, + _ => (0, 0, 0), + }; + + let (oqe, qf, ps) = match kind { + Kind::Secondary { + occlusion_query, + query_statistics_flags, + .. + } => { + let ps: vk::QueryPipelineStatisticFlagBits = query_statistics_flags.into(); + debug_assert!(ps == 0 || + alloc.device().enabled_features().pipeline_statistics_query); + + let (oqe, qf) = match occlusion_query { + KindOcclusionQuery::Allowed { control_precise_allowed } => { + debug_assert!(alloc.device().enabled_features().inherited_queries); + let qf = if control_precise_allowed { + vk::QUERY_CONTROL_PRECISE_BIT + } else { + 0 + }; + (vk::TRUE, qf) + }, + KindOcclusionQuery::Forbidden => (0, 0), + }; + + (oqe, qf, ps) + }, + _ => (0, 0, 0), + }; + + let inheritance = vk::CommandBufferInheritanceInfo { + sType: vk::STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, + pNext: ptr::null(), + renderPass: rp, + subpass: sp, + framebuffer: fb, + occlusionQueryEnable: oqe, + queryFlags: qf, + pipelineStatistics: ps, + }; + + let infos = vk::CommandBufferBeginInfo { + sType: vk::STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, + pNext: ptr::null(), + flags: vk_flags, + pInheritanceInfo: &inheritance, + }; + + check_errors(vk.BeginCommandBuffer(cmd, &infos))?; + + Ok(UnsafeCommandBufferBuilder { + cmd: Some(alloc), + cmd_raw: cmd, + device: device.clone(), + }) + } + + /// Returns the queue family of the builder. + #[inline] + pub fn queue_family(&self) -> QueueFamily + where P: CommandPoolBuilderAlloc + { + self.cmd.as_ref().unwrap().queue_family() + } + + /// Turns the builder into an actual command buffer. + #[inline] + pub fn build(mut self) -> Result<UnsafeCommandBuffer<P::Alloc>, OomError> + where P: CommandPoolBuilderAlloc + { + unsafe { + let cmd = self.cmd.take().unwrap(); + let vk = self.device.pointers(); + check_errors(vk.EndCommandBuffer(cmd.inner().internal_object()))?; + let cmd_raw = cmd.inner().internal_object(); + + Ok(UnsafeCommandBuffer { + cmd: cmd.into_alloc(), + cmd_raw: cmd_raw, + device: self.device.clone(), + }) + } + } + + /// Calls `vkCmdBeginQuery` on the builder. + #[inline] + pub unsafe fn begin_query(&mut self, query: UnsafeQuery, precise: bool) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + let flags = if precise { + vk::QUERY_CONTROL_PRECISE_BIT + } else { + 0 + }; + vk.CmdBeginQuery(cmd, query.pool().internal_object(), query.index(), flags); + } + + /// Calls `vkCmdBeginRenderPass` on the builder. + #[inline] + pub unsafe fn begin_render_pass<F, I>(&mut self, framebuffer: &F, + subpass_contents: SubpassContents, clear_values: I) + where F: ?Sized + FramebufferAbstract, + I: Iterator<Item = ClearValue> + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + // TODO: allow passing a different render pass + let raw_render_pass = RenderPassAbstract::inner(&framebuffer).internal_object(); + let raw_framebuffer = FramebufferAbstract::inner(&framebuffer).internal_object(); + + let raw_clear_values: SmallVec<[_; 12]> = clear_values + .map(|clear_value| match clear_value { + ClearValue::None => { + vk::ClearValue { color: vk::ClearColorValue { float32: [0.0; 4] } } + }, + ClearValue::Float(val) => { + vk::ClearValue { color: vk::ClearColorValue { float32: val } } + }, + ClearValue::Int(val) => { + vk::ClearValue { color: vk::ClearColorValue { int32: val } } + }, + ClearValue::Uint(val) => { + vk::ClearValue { color: vk::ClearColorValue { uint32: val } } + }, + ClearValue::Depth(val) => { + vk::ClearValue { + depthStencil: vk::ClearDepthStencilValue { + depth: val, + stencil: 0, + }, + } + }, + ClearValue::Stencil(val) => { + vk::ClearValue { + depthStencil: vk::ClearDepthStencilValue { + depth: 0.0, + stencil: val, + }, + } + }, + ClearValue::DepthStencil((depth, stencil)) => { + vk::ClearValue { + depthStencil: vk::ClearDepthStencilValue { + depth: depth, + stencil: stencil, + }, + } + }, + }) + .collect(); + + // TODO: allow customizing + let rect = [ + 0 .. framebuffer.dimensions()[0], + 0 .. framebuffer.dimensions()[1], + ]; + + let begin = vk::RenderPassBeginInfo { + sType: vk::STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, + pNext: ptr::null(), + renderPass: raw_render_pass, + framebuffer: raw_framebuffer, + renderArea: vk::Rect2D { + offset: vk::Offset2D { + x: rect[0].start as i32, + y: rect[1].start as i32, + }, + extent: vk::Extent2D { + width: rect[0].end - rect[0].start, + height: rect[1].end - rect[1].start, + }, + }, + clearValueCount: raw_clear_values.len() as u32, + pClearValues: raw_clear_values.as_ptr(), + }; + + vk.CmdBeginRenderPass(cmd, &begin, subpass_contents as u32); + } + + /// Calls `vkCmdBindDescriptorSets` on the builder. + /// + /// Does nothing if the list of descriptor sets is empty, as it would be a no-op and isn't a + /// valid usage of the command anyway. + #[inline] + pub unsafe fn bind_descriptor_sets<'s, Pl, S, I>(&mut self, graphics: bool, + pipeline_layout: &Pl, first_binding: u32, + sets: S, dynamic_offsets: I) + where Pl: ?Sized + PipelineLayoutAbstract, + S: Iterator<Item = &'s UnsafeDescriptorSet>, + I: Iterator<Item = u32> + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + let sets: SmallVec<[_; 12]> = sets.map(|s| s.internal_object()).collect(); + if sets.is_empty() { + return; + } + let dynamic_offsets: SmallVec<[u32; 32]> = dynamic_offsets.collect(); + + let num_bindings = sets.len() as u32; + debug_assert!(first_binding + num_bindings <= pipeline_layout.num_sets() as u32); + + let bind_point = if graphics { + vk::PIPELINE_BIND_POINT_GRAPHICS + } else { + vk::PIPELINE_BIND_POINT_COMPUTE + }; + + vk.CmdBindDescriptorSets(cmd, + bind_point, + pipeline_layout.sys().internal_object(), + first_binding, + num_bindings, + sets.as_ptr(), + dynamic_offsets.len() as u32, + dynamic_offsets.as_ptr()); + } + + /// Calls `vkCmdBindIndexBuffer` on the builder. + #[inline] + pub unsafe fn bind_index_buffer<B>(&mut self, buffer: &B, index_ty: IndexType) + where B: ?Sized + BufferAccess + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + let inner = buffer.inner(); + debug_assert!(inner.offset < inner.buffer.size()); + debug_assert!(inner.buffer.usage_index_buffer()); + + vk.CmdBindIndexBuffer(cmd, + inner.buffer.internal_object(), + inner.offset as vk::DeviceSize, + index_ty as vk::IndexType); + } + + /// Calls `vkCmdBindPipeline` on the builder with a compute pipeline. + #[inline] + pub unsafe fn bind_pipeline_compute<Cp>(&mut self, pipeline: &Cp) + where Cp: ?Sized + ComputePipelineAbstract + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdBindPipeline(cmd, + vk::PIPELINE_BIND_POINT_COMPUTE, + pipeline.inner().internal_object()); + } + + /// Calls `vkCmdBindPipeline` on the builder with a graphics pipeline. + #[inline] + pub unsafe fn bind_pipeline_graphics<Gp>(&mut self, pipeline: &Gp) + where Gp: ?Sized + GraphicsPipelineAbstract + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + let inner = GraphicsPipelineAbstract::inner(pipeline).internal_object(); + vk.CmdBindPipeline(cmd, vk::PIPELINE_BIND_POINT_GRAPHICS, inner); + } + + /// Calls `vkCmdBindVertexBuffers` on the builder. + /// + /// Does nothing if the list of buffers is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn bind_vertex_buffers(&mut self, first_binding: u32, + params: UnsafeCommandBufferBuilderBindVertexBuffer) { + debug_assert_eq!(params.raw_buffers.len(), params.offsets.len()); + + if params.raw_buffers.is_empty() { + return; + } + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + let num_bindings = params.raw_buffers.len() as u32; + + debug_assert!({ + let max_bindings = self.device() + .physical_device() + .limits() + .max_vertex_input_bindings(); + first_binding + num_bindings <= max_bindings + }); + + vk.CmdBindVertexBuffers(cmd, + first_binding, + num_bindings, + params.raw_buffers.as_ptr(), + params.offsets.as_ptr()); + } + + /// Calls `vkCmdCopyImage` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn copy_image<S, D, R>(&mut self, source: &S, source_layout: ImageLayout, + destination: &D, destination_layout: ImageLayout, regions: R) + where S: ?Sized + ImageAccess, + D: ?Sized + ImageAccess, + R: Iterator<Item = UnsafeCommandBufferBuilderImageCopy> + { + // TODO: The correct check here is that the uncompressed element size of the source is + // equal to the compressed element size of the destination. + debug_assert!(source.format().is_compressed() || + destination.format().is_compressed() || + source.format().size() == destination.format().size()); + + // Depth/Stencil formats are required to match exactly. + debug_assert!(!source.format().ty().is_depth_and_or_stencil() || + source.format() == destination.format()); + + debug_assert_eq!(source.samples(), destination.samples()); + let source = source.inner(); + debug_assert!(source.image.usage_transfer_source()); + debug_assert!(source_layout == ImageLayout::General || + source_layout == ImageLayout::TransferSrcOptimal); + + let destination = destination.inner(); + debug_assert!(destination.image.usage_transfer_destination()); + debug_assert!(destination_layout == ImageLayout::General || + destination_layout == ImageLayout::TransferDstOptimal); + + let regions: SmallVec<[_; 8]> = regions + .filter_map(|copy| { + // TODO: not everything is checked here + debug_assert!(copy.source_base_array_layer + copy.layer_count <= + source.num_layers as u32); + debug_assert!(copy.destination_base_array_layer + copy.layer_count <= + destination.num_layers as u32); + debug_assert!(copy.source_mip_level < destination.num_mipmap_levels as u32); + debug_assert!(copy.destination_mip_level < destination.num_mipmap_levels as u32); + + if copy.layer_count == 0 { + return None; + } + + Some(vk::ImageCopy { + srcSubresource: vk::ImageSubresourceLayers { + aspectMask: copy.aspect.to_vk_bits(), + mipLevel: copy.source_mip_level, + baseArrayLayer: copy.source_base_array_layer + source.first_layer as u32, + layerCount: copy.layer_count, + }, + srcOffset: vk::Offset3D { + x: copy.source_offset[0], + y: copy.source_offset[1], + z: copy.source_offset[2], + }, + dstSubresource: vk::ImageSubresourceLayers { + aspectMask: copy.aspect.to_vk_bits(), + mipLevel: copy.destination_mip_level, + baseArrayLayer: copy.destination_base_array_layer + + destination.first_layer as u32, + layerCount: copy.layer_count, + }, + dstOffset: vk::Offset3D { + x: copy.destination_offset[0], + y: copy.destination_offset[1], + z: copy.destination_offset[2], + }, + extent: vk::Extent3D { + width: copy.extent[0], + height: copy.extent[1], + depth: copy.extent[2], + } + }) + }) + .collect(); + + if regions.is_empty() { + return; + } + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdCopyImage(cmd, + source.image.internal_object(), + source_layout as u32, + destination.image.internal_object(), + destination_layout as u32, + regions.len() as u32, + regions.as_ptr()); + } + + /// Calls `vkCmdBlitImage` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn blit_image<S, D, R>(&mut self, source: &S, source_layout: ImageLayout, + destination: &D, destination_layout: ImageLayout, regions: R, + filter: Filter) + where S: ?Sized + ImageAccess, + D: ?Sized + ImageAccess, + R: Iterator<Item = UnsafeCommandBufferBuilderImageBlit> + { + debug_assert!(filter == Filter::Nearest || !source.format().ty().is_depth_and_or_stencil()); + debug_assert!((source.format().ty() == FormatTy::Uint) == + (destination.format().ty() == FormatTy::Uint)); + debug_assert!((source.format().ty() == FormatTy::Sint) == + (destination.format().ty() == FormatTy::Sint)); + debug_assert!(source.format() == destination.format() || + !source.format().ty().is_depth_and_or_stencil()); + + debug_assert_eq!(source.samples(), 1); + let source = source.inner(); + debug_assert!(source.image.supports_blit_source()); + debug_assert!(source.image.usage_transfer_source()); + debug_assert!(source_layout == ImageLayout::General || + source_layout == ImageLayout::TransferSrcOptimal); + + debug_assert_eq!(destination.samples(), 1); + let destination = destination.inner(); + debug_assert!(destination.image.supports_blit_destination()); + debug_assert!(destination.image.usage_transfer_destination()); + debug_assert!(destination_layout == ImageLayout::General || + destination_layout == ImageLayout::TransferDstOptimal); + + let regions: SmallVec<[_; 8]> = regions + .filter_map(|blit| { + // TODO: not everything is checked here + debug_assert!(blit.source_base_array_layer + blit.layer_count <= + source.num_layers as u32); + debug_assert!(blit.destination_base_array_layer + blit.layer_count <= + destination.num_layers as u32); + debug_assert!(blit.source_mip_level < destination.num_mipmap_levels as u32); + debug_assert!(blit.destination_mip_level < destination.num_mipmap_levels as u32); + + if blit.layer_count == 0 { + return None; + } + + Some(vk::ImageBlit { + srcSubresource: vk::ImageSubresourceLayers { + aspectMask: blit.aspect.to_vk_bits(), + mipLevel: blit.source_mip_level, + baseArrayLayer: blit.source_base_array_layer + source.first_layer as u32, + layerCount: blit.layer_count, + }, + srcOffsets: [ + vk::Offset3D { + x: blit.source_top_left[0], + y: blit.source_top_left[1], + z: blit.source_top_left[2], + }, + vk::Offset3D { + x: blit.source_bottom_right[0], + y: blit.source_bottom_right[1], + z: blit.source_bottom_right[2], + }, + ], + dstSubresource: vk::ImageSubresourceLayers { + aspectMask: blit.aspect.to_vk_bits(), + mipLevel: blit.destination_mip_level, + baseArrayLayer: blit.destination_base_array_layer + + destination.first_layer as u32, + layerCount: blit.layer_count, + }, + dstOffsets: [ + vk::Offset3D { + x: blit.destination_top_left[0], + y: blit.destination_top_left[1], + z: blit.destination_top_left[2], + }, + vk::Offset3D { + x: blit.destination_bottom_right[0], + y: blit.destination_bottom_right[1], + z: blit.destination_bottom_right[2], + }, + ], + }) + }) + .collect(); + + if regions.is_empty() { + return; + } + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdBlitImage(cmd, + source.image.internal_object(), + source_layout as u32, + destination.image.internal_object(), + destination_layout as u32, + regions.len() as u32, + regions.as_ptr(), + filter as u32); + } + + // TODO: missing structs + /*/// Calls `vkCmdClearAttachments` on the builder. + /// + /// Does nothing if the list of attachments or the list of rects is empty, as it would be a + /// no-op and isn't a valid usage of the command anyway. + #[inline] + pub unsafe fn clear_attachments<A, R>(&mut self, attachments: A, rects: R) + where A: Iterator<Item = >, + R: Iterator<Item = > + { + let attachments: SmallVec<[_; 16]> = attachments.map().collect(); + let rects: SmallVec<[_; 4]> = rects.map().collect(); + + if attachments.is_empty() || rects.is_empty() { + return; + } + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdClearAttachments(cmd, attachments.len() as u32, attachments.as_ptr(), + rects.len() as u32, rects.as_ptr()); + }*/ + + /// Calls `vkCmdClearColorImage` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + // TODO: ClearValue could be more precise + pub unsafe fn clear_color_image<I, R>(&mut self, image: &I, layout: ImageLayout, + color: ClearValue, regions: R) + where I: ?Sized + ImageAccess, + R: Iterator<Item = UnsafeCommandBufferBuilderColorImageClear> + { + debug_assert!(image.format().ty() == FormatTy::Float || + image.format().ty() == FormatTy::Uint || + image.format().ty() == FormatTy::Sint); + + let image = image.inner(); + debug_assert!(image.image.usage_transfer_destination()); + debug_assert!(layout == ImageLayout::General || layout == ImageLayout::TransferDstOptimal); + + let color = match color { + ClearValue::Float(val) => { + vk::ClearColorValue { float32: val } + }, + ClearValue::Int(val) => { + vk::ClearColorValue { int32: val } + }, + ClearValue::Uint(val) => { + vk::ClearColorValue { uint32: val } + }, + _ => { + vk::ClearColorValue { float32: [0.0; 4] } + }, + }; + + let regions: SmallVec<[_; 8]> = regions + .filter_map(|region| { + debug_assert!(region.layer_count + region.base_array_layer <= + image.num_layers as u32); + debug_assert!(region.level_count + region.base_mip_level <= + image.num_mipmap_levels as u32); + + if region.layer_count == 0 || region.level_count == 0 { + return None; + } + + Some(vk::ImageSubresourceRange { + aspectMask: vk::IMAGE_ASPECT_COLOR_BIT, + baseMipLevel: region.base_mip_level + image.first_mipmap_level as u32, + levelCount: region.level_count, + baseArrayLayer: region.base_array_layer + image.first_layer as u32, + layerCount: region.layer_count, + }) + }) + .collect(); + + if regions.is_empty() { + return; + } + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdClearColorImage(cmd, + image.image.internal_object(), + layout as u32, + &color, + regions.len() as u32, + regions.as_ptr()); + } + + /// Calls `vkCmdCopyBuffer` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn copy_buffer<S, D, R>(&mut self, source: &S, destination: &D, regions: R) + where S: ?Sized + BufferAccess, + D: ?Sized + BufferAccess, + R: Iterator<Item = (usize, usize, usize)> + { + // TODO: debug assert that there's no overlap in the destinations? + + let source = source.inner(); + debug_assert!(source.offset < source.buffer.size()); + debug_assert!(source.buffer.usage_transfer_source()); + + let destination = destination.inner(); + debug_assert!(destination.offset < destination.buffer.size()); + debug_assert!(destination.buffer.usage_transfer_destination()); + + let regions: SmallVec<[_; 8]> = regions + .map(|(sr, de, sz)| { + vk::BufferCopy { + srcOffset: (sr + source.offset) as vk::DeviceSize, + dstOffset: (de + destination.offset) as vk::DeviceSize, + size: sz as vk::DeviceSize, + } + }) + .collect(); + + if regions.is_empty() { + return; + } + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdCopyBuffer(cmd, + source.buffer.internal_object(), + destination.buffer.internal_object(), + regions.len() as u32, + regions.as_ptr()); + } + + /// Calls `vkCmdCopyBufferToImage` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn copy_buffer_to_image<S, D, R>(&mut self, source: &S, destination: &D, + destination_layout: ImageLayout, regions: R) + where S: ?Sized + BufferAccess, + D: ?Sized + ImageAccess, + R: Iterator<Item = UnsafeCommandBufferBuilderBufferImageCopy> + { + let source = source.inner(); + debug_assert!(source.offset < source.buffer.size()); + debug_assert!(source.buffer.usage_transfer_source()); + + debug_assert_eq!(destination.samples(), 1); + let destination = destination.inner(); + debug_assert!(destination.image.usage_transfer_destination()); + debug_assert!(destination_layout == ImageLayout::General || + destination_layout == ImageLayout::TransferDstOptimal); + + let regions: SmallVec<[_; 8]> = regions + .map(|copy| { + debug_assert!(copy.image_layer_count <= destination.num_layers as u32); + debug_assert!(copy.image_mip_level < destination.num_mipmap_levels as u32); + + vk::BufferImageCopy { + bufferOffset: (source.offset + copy.buffer_offset) as vk::DeviceSize, + bufferRowLength: copy.buffer_row_length, + bufferImageHeight: copy.buffer_image_height, + imageSubresource: vk::ImageSubresourceLayers { + aspectMask: copy.image_aspect.to_vk_bits(), + mipLevel: copy.image_mip_level + destination.first_mipmap_level as u32, + baseArrayLayer: copy.image_base_array_layer + + destination.first_layer as u32, + layerCount: copy.image_layer_count, + }, + imageOffset: vk::Offset3D { + x: copy.image_offset[0], + y: copy.image_offset[1], + z: copy.image_offset[2], + }, + imageExtent: vk::Extent3D { + width: copy.image_extent[0], + height: copy.image_extent[1], + depth: copy.image_extent[2], + }, + } + }) + .collect(); + + if regions.is_empty() { + return; + } + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdCopyBufferToImage(cmd, + source.buffer.internal_object(), + destination.image.internal_object(), + destination_layout as u32, + regions.len() as u32, + regions.as_ptr()); + } + + /// Calls `vkCmdCopyImageToBuffer` on the builder. + /// + /// Does nothing if the list of regions is empty, as it would be a no-op and isn't a valid + /// usage of the command anyway. + #[inline] + pub unsafe fn copy_image_to_buffer<S, D, R>(&mut self, source: &S, source_layout: ImageLayout, + destination: &D, regions: R) + where S: ?Sized + ImageAccess, + D: ?Sized + BufferAccess, + R: Iterator<Item = UnsafeCommandBufferBuilderBufferImageCopy> + { + debug_assert_eq!(source.samples(), 1); + let source = source.inner(); + debug_assert!(source.image.usage_transfer_source()); + debug_assert!(source_layout == ImageLayout::General || + source_layout == ImageLayout::TransferSrcOptimal); + + let destination = destination.inner(); + debug_assert!(destination.offset < destination.buffer.size()); + debug_assert!(destination.buffer.usage_transfer_destination()); + + let regions: SmallVec<[_; 8]> = regions + .map(|copy| { + debug_assert!(copy.image_layer_count <= source.num_layers as u32); + debug_assert!(copy.image_mip_level < source.num_mipmap_levels as u32); + + vk::BufferImageCopy { + bufferOffset: (destination.offset + copy.buffer_offset) as vk::DeviceSize, + bufferRowLength: copy.buffer_row_length, + bufferImageHeight: copy.buffer_image_height, + imageSubresource: vk::ImageSubresourceLayers { + aspectMask: copy.image_aspect.to_vk_bits(), + mipLevel: copy.image_mip_level + source.first_mipmap_level as u32, + baseArrayLayer: copy.image_base_array_layer + source.first_layer as u32, + layerCount: copy.image_layer_count, + }, + imageOffset: vk::Offset3D { + x: copy.image_offset[0], + y: copy.image_offset[1], + z: copy.image_offset[2], + }, + imageExtent: vk::Extent3D { + width: copy.image_extent[0], + height: copy.image_extent[1], + depth: copy.image_extent[2], + }, + } + }) + .collect(); + + if regions.is_empty() { + return; + } + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdCopyImageToBuffer(cmd, + source.image.internal_object(), + source_layout as u32, + destination.buffer.internal_object(), + regions.len() as u32, + regions.as_ptr()); + } + + /// Calls `vkCmdCopyQueryPoolResults` on the builder. + #[inline] + pub unsafe fn copy_query_pool_results(&mut self, queries: UnsafeQueriesRange, + destination: &BufferAccess, stride: usize) { + let destination = destination.inner(); + debug_assert!(destination.offset < destination.buffer.size()); + debug_assert!(destination.buffer.usage_transfer_destination()); + + let flags = 0; // FIXME: + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdCopyQueryPoolResults(cmd, + queries.pool().internal_object(), + queries.first_index(), + queries.count(), + destination.buffer.internal_object(), + destination.offset as vk::DeviceSize, + stride as vk::DeviceSize, + flags); + } + + /// Calls `vkCmdDispatch` on the builder. + #[inline] + pub unsafe fn dispatch(&mut self, dimensions: [u32; 3]) { + debug_assert!({ + let max_dims = self.device() + .physical_device() + .limits() + .max_compute_work_group_count(); + dimensions[0] <= max_dims[0] && dimensions[1] <= max_dims[1] && + dimensions[2] <= max_dims[2] + }); + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdDispatch(cmd, dimensions[0], dimensions[1], dimensions[2]); + } + + /// Calls `vkCmdDispatchIndirect` on the builder. + #[inline] + pub unsafe fn dispatch_indirect<B>(&mut self, buffer: &B) + where B: ?Sized + BufferAccess + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + let inner = buffer.inner(); + debug_assert!(inner.offset < buffer.size()); + debug_assert!(inner.buffer.usage_indirect_buffer()); + debug_assert_eq!(inner.offset % 4, 0); + + vk.CmdDispatchIndirect(cmd, + inner.buffer.internal_object(), + inner.offset as vk::DeviceSize); + } + + /// Calls `vkCmdDraw` on the builder. + #[inline] + pub unsafe fn draw(&mut self, vertex_count: u32, instance_count: u32, first_vertex: u32, + first_instance: u32) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdDraw(cmd, + vertex_count, + instance_count, + first_vertex, + first_instance); + } + + /// Calls `vkCmdDrawIndexed` on the builder. + #[inline] + pub unsafe fn draw_indexed(&mut self, index_count: u32, instance_count: u32, + first_index: u32, vertex_offset: i32, first_instance: u32) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdDrawIndexed(cmd, + index_count, + instance_count, + first_index, + vertex_offset, + first_instance); + } + + /// Calls `vkCmdDrawIndirect` on the builder. + #[inline] + pub unsafe fn draw_indirect<B>(&mut self, buffer: &B, draw_count: u32, stride: u32) + where B: ?Sized + BufferAccess + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + debug_assert!(draw_count == 0 || + ((stride % 4) == 0) && + stride as usize >= mem::size_of::<vk::DrawIndirectCommand>()); + + let inner = buffer.inner(); + debug_assert!(inner.offset < inner.buffer.size()); + debug_assert!(inner.buffer.usage_indirect_buffer()); + + vk.CmdDrawIndirect(cmd, + inner.buffer.internal_object(), + inner.offset as vk::DeviceSize, + draw_count, + stride); + } + + /// Calls `vkCmdDrawIndexedIndirect` on the builder. + #[inline] + pub unsafe fn draw_indexed_indirect<B>(&mut self, buffer: &B, draw_count: u32, stride: u32) + where B: ?Sized + BufferAccess + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + let inner = buffer.inner(); + debug_assert!(inner.offset < inner.buffer.size()); + debug_assert!(inner.buffer.usage_indirect_buffer()); + + vk.CmdDrawIndexedIndirect(cmd, + inner.buffer.internal_object(), + inner.offset as vk::DeviceSize, + draw_count, + stride); + } + + /// Calls `vkCmdEndQuery` on the builder. + #[inline] + pub unsafe fn end_query(&mut self, query: UnsafeQuery) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdEndQuery(cmd, query.pool().internal_object(), query.index()); + } + + /// Calls `vkCmdEndRenderPass` on the builder. + #[inline] + pub unsafe fn end_render_pass(&mut self) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdEndRenderPass(cmd); + } + + /// Calls `vkCmdExecuteCommands` on the builder. + /// + /// Does nothing if the list of command buffers is empty, as it would be a no-op and isn't a + /// valid usage of the command anyway. + #[inline] + pub unsafe fn execute_commands(&mut self, cbs: UnsafeCommandBufferBuilderExecuteCommands) { + if cbs.raw_cbs.is_empty() { + return; + } + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdExecuteCommands(cmd, cbs.raw_cbs.len() as u32, cbs.raw_cbs.as_ptr()); + } + + /// Calls `vkCmdFillBuffer` on the builder. + #[inline] + pub unsafe fn fill_buffer<B>(&mut self, buffer: &B, data: u32) + where B: ?Sized + BufferAccess + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + let size = buffer.size(); + + let (buffer_handle, offset) = { + let BufferInner { + buffer: buffer_inner, + offset, + } = buffer.inner(); + debug_assert!(buffer_inner.usage_transfer_destination()); + debug_assert_eq!(offset % 4, 0); + (buffer_inner.internal_object(), offset) + }; + + vk.CmdFillBuffer(cmd, + buffer_handle, + offset as vk::DeviceSize, + size as vk::DeviceSize, + data); + } + + /// Calls `vkCmdNextSubpass` on the builder. + #[inline] + pub unsafe fn next_subpass(&mut self, subpass_contents: SubpassContents) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdNextSubpass(cmd, subpass_contents as u32); + } + + #[inline] + pub unsafe fn pipeline_barrier(&mut self, command: &UnsafeCommandBufferBuilderPipelineBarrier) { + // If barrier is empty, don't do anything. + if command.src_stage_mask == 0 || command.dst_stage_mask == 0 { + debug_assert!(command.src_stage_mask == 0 && command.dst_stage_mask == 0); + debug_assert!(command.memory_barriers.is_empty()); + debug_assert!(command.buffer_barriers.is_empty()); + debug_assert!(command.image_barriers.is_empty()); + return; + } + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + debug_assert_ne!(command.src_stage_mask, 0); + debug_assert_ne!(command.dst_stage_mask, 0); + + vk.CmdPipelineBarrier(cmd, + command.src_stage_mask, + command.dst_stage_mask, + command.dependency_flags, + command.memory_barriers.len() as u32, + command.memory_barriers.as_ptr(), + command.buffer_barriers.len() as u32, + command.buffer_barriers.as_ptr(), + command.image_barriers.len() as u32, + command.image_barriers.as_ptr()); + } + + /// Calls `vkCmdPushConstants` on the builder. + #[inline] + pub unsafe fn push_constants<Pl, D>(&mut self, pipeline_layout: &Pl, stages: ShaderStages, + offset: u32, size: u32, data: &D) + where Pl: ?Sized + PipelineLayoutAbstract, + D: ?Sized + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + debug_assert!(stages != ShaderStages::none()); + debug_assert!(size > 0); + debug_assert_eq!(size % 4, 0); + debug_assert_eq!(offset % 4, 0); + debug_assert!(mem::size_of_val(data) >= size as usize); + + vk.CmdPushConstants(cmd, + pipeline_layout.sys().internal_object(), + stages.into_vulkan_bits(), + offset as u32, + size as u32, + data as *const D as *const _); + } + + /// Calls `vkCmdResetEvent` on the builder. + #[inline] + pub unsafe fn reset_event(&mut self, event: &Event, stages: PipelineStages) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + debug_assert!(!stages.host); + debug_assert_ne!(stages, PipelineStages::none()); + + vk.CmdResetEvent(cmd, event.internal_object(), stages.into_vulkan_bits()); + } + + /// Calls `vkCmdResetQueryPool` on the builder. + #[inline] + pub unsafe fn reset_query_pool(&mut self, queries: UnsafeQueriesRange) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdResetQueryPool(cmd, + queries.pool().internal_object(), + queries.first_index(), + queries.count()); + } + + /// Calls `vkCmdSetBlendConstants` on the builder. + #[inline] + pub unsafe fn set_blend_constants(&mut self, constants: [f32; 4]) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdSetBlendConstants(cmd, constants); // TODO: correct to pass array? + } + + /// Calls `vkCmdSetDepthBias` on the builder. + #[inline] + pub unsafe fn set_depth_bias(&mut self, constant_factor: f32, clamp: f32, slope_factor: f32) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + debug_assert!(clamp == 0.0 || self.device().enabled_features().depth_bias_clamp); + vk.CmdSetDepthBias(cmd, constant_factor, clamp, slope_factor); + } + + /// Calls `vkCmdSetDepthBounds` on the builder. + #[inline] + pub unsafe fn set_depth_bounds(&mut self, min: f32, max: f32) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + debug_assert!(min >= 0.0 && min <= 1.0); + debug_assert!(max >= 0.0 && max <= 1.0); + vk.CmdSetDepthBounds(cmd, min, max); + } + + /// Calls `vkCmdSetEvent` on the builder. + #[inline] + pub unsafe fn set_event(&mut self, event: &Event, stages: PipelineStages) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + debug_assert!(!stages.host); + debug_assert_ne!(stages, PipelineStages::none()); + + vk.CmdSetEvent(cmd, event.internal_object(), stages.into_vulkan_bits()); + } + + /// Calls `vkCmdSetLineWidth` on the builder. + #[inline] + pub unsafe fn set_line_width(&mut self, line_width: f32) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + debug_assert!(line_width == 1.0 || self.device().enabled_features().wide_lines); + vk.CmdSetLineWidth(cmd, line_width); + } + + // TODO: missing enum for face_mask + /*/// Calls `vkCmdSetStencilCompareMask` on the builder. + #[inline] + pub unsafe fn set_stencil_compare_mask(&mut self, face_mask: , compare_mask: u32) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdSetStencilCompareMask(cmd, face_mask, compare_mask); + }*/ + + // TODO: missing enum for face_mask + /*/// Calls `vkCmdSetStencilReference` on the builder. + #[inline] + pub unsafe fn set_stencil_reference(&mut self, face_mask: , reference: u32) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdSetStencilReference(cmd, face_mask, reference); + }*/ + + // TODO: missing enum for face_mask + /*/// Calls `vkCmdSetStencilWriteMask` on the builder. + #[inline] + pub unsafe fn set_stencil_write_mask(&mut self, face_mask: , write_mask: u32) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdSetStencilWriteMask(cmd, face_mask, write_mask); + }*/ + + /// Calls `vkCmdSetScissor` on the builder. + /// + /// If the list is empty then the command is automatically ignored. + #[inline] + pub unsafe fn set_scissor<I>(&mut self, first_scissor: u32, scissors: I) + where I: Iterator<Item = Scissor> + { + let scissors = scissors + .map(|v| v.clone().into_vulkan_rect()) + .collect::<SmallVec<[_; 16]>>(); + if scissors.is_empty() { + return; + } + + debug_assert!(scissors.iter().all(|s| s.offset.x >= 0 && s.offset.y >= 0)); + debug_assert!(scissors.iter().all(|s| { + s.extent.width < i32::max_value() as u32 && s.extent.height < i32::max_value() as u32 && + s.offset.x.checked_add(s.extent.width as i32).is_some() && + s.offset.y.checked_add(s.extent.height as i32).is_some() + })); + debug_assert!((first_scissor == 0 && scissors.len() == 1) || + self.device().enabled_features().multi_viewport); + debug_assert!({ + let max = self.device().physical_device().limits().max_viewports(); + first_scissor + scissors.len() as u32 <= max + }); + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdSetScissor(cmd, first_scissor, scissors.len() as u32, scissors.as_ptr()); + } + + /// Calls `vkCmdSetViewport` on the builder. + /// + /// If the list is empty then the command is automatically ignored. + #[inline] + pub unsafe fn set_viewport<I>(&mut self, first_viewport: u32, viewports: I) + where I: Iterator<Item = Viewport> + { + let viewports = viewports + .map(|v| v.clone().into_vulkan_viewport()) + .collect::<SmallVec<[_; 16]>>(); + if viewports.is_empty() { + return; + } + + debug_assert!((first_viewport == 0 && viewports.len() == 1) || + self.device().enabled_features().multi_viewport); + debug_assert!({ + let max = self.device().physical_device().limits().max_viewports(); + first_viewport + viewports.len() as u32 <= max + }); + + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdSetViewport(cmd, + first_viewport, + viewports.len() as u32, + viewports.as_ptr()); + } + + /// Calls `vkCmdUpdateBuffer` on the builder. + #[inline] + pub unsafe fn update_buffer<B, D>(&mut self, buffer: &B, data: &D) + where B: ?Sized + BufferAccess, + D: ?Sized + { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + + let size = buffer.size(); + debug_assert_eq!(size % 4, 0); + debug_assert!(size <= 65536); + debug_assert!(size <= mem::size_of_val(data)); + + let (buffer_handle, offset) = { + let BufferInner { + buffer: buffer_inner, + offset, + } = buffer.inner(); + debug_assert!(buffer_inner.usage_transfer_destination()); + debug_assert_eq!(offset % 4, 0); + (buffer_inner.internal_object(), offset) + }; + + vk.CmdUpdateBuffer(cmd, + buffer_handle, + offset as vk::DeviceSize, + size as vk::DeviceSize, + data as *const D as *const _); + } + + /// Calls `vkCmdWriteTimestamp` on the builder. + #[inline] + pub unsafe fn write_timestamp(&mut self, query: UnsafeQuery, stages: PipelineStages) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdWriteTimestamp(cmd, + stages.into_vulkan_bits(), + query.pool().internal_object(), + query.index()); + } + + /// Calls `vkCmdDebugMarkerBeginEXT` on the builder. + /// + /// # Panics + /// Requires the `VK_EXT_debug_marker` device extension to be loaded. + /// + /// # Safety + /// The command pool that this command buffer was allocated from must support graphics or + /// compute operations + #[inline] + pub unsafe fn debug_marker_begin(&mut self, name: &CStr, color: [f32; 4]) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + let info = vk::DebugMarkerMarkerInfoEXT { + sType: vk::STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT, + pNext: ptr::null(), + pMarkerName: name.as_ptr(), + color: color, + }; + vk.CmdDebugMarkerBeginEXT(cmd, &info); + } + + /// Calls `vkCmdDebugMarkerEndEXT` on the builder. + /// + /// # Panics + /// Requires the `VK_EXT_debug_marker` device extension to be loaded. + /// + /// # Safety + /// There must be an outstanding `vkCmdDebugMarkerBeginEXT` command prior to the + /// `vkCmdDebugMarkerEndEXT` on the queue that this command buffer is submitted to. If the + /// matching `vkCmdDebugMarkerBeginEXT` command was in a secondary command buffer, the + /// `vkCmdDebugMarkerEndEXT` must be in the same command buffer. + #[inline] + pub unsafe fn debug_marker_end(&mut self) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + vk.CmdDebugMarkerEndEXT(cmd); + } + + /// Calls `vkCmdDebugMarkerInsertEXT` on the builder. + /// + /// # Panics + /// Requires the `VK_EXT_debug_marker` device extension to be loaded. + /// + /// # Safety + /// The command pool that this command buffer was allocated from must support graphics or + /// compute operations + #[inline] + pub unsafe fn debug_marker_insert(&mut self, name: &CStr, color: [f32; 4]) { + let vk = self.device().pointers(); + let cmd = self.internal_object(); + let info = vk::DebugMarkerMarkerInfoEXT { + sType: vk::STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT, + pNext: ptr::null(), + pMarkerName: name.as_ptr(), + color: color, + }; + vk.CmdDebugMarkerInsertEXT(cmd, &info); + } +} + +unsafe impl<P> DeviceOwned for UnsafeCommandBufferBuilder<P> { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +unsafe impl<P> VulkanObject for UnsafeCommandBufferBuilder<P> { + type Object = vk::CommandBuffer; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT; + + #[inline] + fn internal_object(&self) -> vk::CommandBuffer { + debug_assert!(self.cmd.is_some()); + self.cmd_raw + } +} + +/// Prototype for a `vkCmdBindVertexBuffers`. +pub struct UnsafeCommandBufferBuilderBindVertexBuffer { + // Raw handles of the buffers to bind. + raw_buffers: SmallVec<[vk::Buffer; 4]>, + // Raw offsets of the buffers to bind. + offsets: SmallVec<[vk::DeviceSize; 4]>, +} + +impl UnsafeCommandBufferBuilderBindVertexBuffer { + /// Builds a new empty list. + #[inline] + pub fn new() -> UnsafeCommandBufferBuilderBindVertexBuffer { + UnsafeCommandBufferBuilderBindVertexBuffer { + raw_buffers: SmallVec::new(), + offsets: SmallVec::new(), + } + } + + /// Adds a buffer to the list. + #[inline] + pub fn add<B>(&mut self, buffer: &B) + where B: ?Sized + BufferAccess + { + let inner = buffer.inner(); + debug_assert!(inner.buffer.usage_vertex_buffer()); + self.raw_buffers.push(inner.buffer.internal_object()); + self.offsets.push(inner.offset as vk::DeviceSize); + } +} + +/// Prototype for a `vkCmdExecuteCommands`. +pub struct UnsafeCommandBufferBuilderExecuteCommands { + // Raw handles of the command buffers to execute. + raw_cbs: SmallVec<[vk::CommandBuffer; 4]>, +} + +impl UnsafeCommandBufferBuilderExecuteCommands { + /// Builds a new empty list. + #[inline] + pub fn new() -> UnsafeCommandBufferBuilderExecuteCommands { + UnsafeCommandBufferBuilderExecuteCommands { raw_cbs: SmallVec::new() } + } + + /// Adds a command buffer to the list. + #[inline] + pub fn add<C>(&mut self, cb: &C) + where C: ?Sized + CommandBuffer + { + // TODO: debug assert that it is a secondary command buffer? + self.raw_cbs.push(cb.inner().internal_object()); + } + + /// Adds a command buffer to the list. + #[inline] + pub unsafe fn add_raw(&mut self, cb: vk::CommandBuffer) { + self.raw_cbs.push(cb); + } +} + +// TODO: move somewhere else? +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct UnsafeCommandBufferBuilderImageAspect { + pub color: bool, + pub depth: bool, + pub stencil: bool, +} + +impl UnsafeCommandBufferBuilderImageAspect { + pub(crate) fn to_vk_bits(&self) -> vk::ImageAspectFlagBits { + let mut out = 0; + if self.color { + out |= vk::IMAGE_ASPECT_COLOR_BIT + }; + if self.depth { + out |= vk::IMAGE_ASPECT_DEPTH_BIT + }; + if self.stencil { + out |= vk::IMAGE_ASPECT_STENCIL_BIT + }; + out + } +} + +// TODO: move somewhere else? +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct UnsafeCommandBufferBuilderColorImageClear { + pub base_mip_level: u32, + pub level_count: u32, + pub base_array_layer: u32, + pub layer_count: u32, +} + +// TODO: move somewhere else? +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct UnsafeCommandBufferBuilderBufferImageCopy { + pub buffer_offset: usize, + pub buffer_row_length: u32, + pub buffer_image_height: u32, + pub image_aspect: UnsafeCommandBufferBuilderImageAspect, + pub image_mip_level: u32, + pub image_base_array_layer: u32, + pub image_layer_count: u32, + pub image_offset: [i32; 3], + pub image_extent: [u32; 3], +} + +// TODO: move somewhere else? +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct UnsafeCommandBufferBuilderImageCopy { + pub aspect: UnsafeCommandBufferBuilderImageAspect, + pub source_mip_level: u32, + pub destination_mip_level: u32, + pub source_base_array_layer: u32, + pub destination_base_array_layer: u32, + pub layer_count: u32, + pub source_offset: [i32; 3], + pub destination_offset: [i32; 3], + pub extent: [u32; 3], +} + +// TODO: move somewhere else? +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct UnsafeCommandBufferBuilderImageBlit { + pub aspect: UnsafeCommandBufferBuilderImageAspect, + pub source_mip_level: u32, + pub destination_mip_level: u32, + pub source_base_array_layer: u32, + pub destination_base_array_layer: u32, + pub layer_count: u32, + pub source_top_left: [i32; 3], + pub source_bottom_right: [i32; 3], + pub destination_top_left: [i32; 3], + pub destination_bottom_right: [i32; 3], +} + +/// Command that adds a pipeline barrier to a command buffer builder. +/// +/// A pipeline barrier is a low-level system-ish command that is often necessary for safety. By +/// default all commands that you add to a command buffer can potentially run simultaneously. +/// Adding a pipeline barrier separates commands before the barrier from commands after the barrier +/// and prevents them from running simultaneously. +/// +/// Please take a look at the Vulkan specifications for more information. Pipeline barriers are a +/// complex topic and explaining them in this documentation would be redundant. +/// +/// > **Note**: We use a builder-like API here so that users can pass multiple buffers or images of +/// > multiple different types. Doing so with a single function would be very tedious in terms of +/// > API. +pub struct UnsafeCommandBufferBuilderPipelineBarrier { + src_stage_mask: vk::PipelineStageFlags, + dst_stage_mask: vk::PipelineStageFlags, + dependency_flags: vk::DependencyFlags, + memory_barriers: SmallVec<[vk::MemoryBarrier; 2]>, + buffer_barriers: SmallVec<[vk::BufferMemoryBarrier; 8]>, + image_barriers: SmallVec<[vk::ImageMemoryBarrier; 8]>, +} + +impl UnsafeCommandBufferBuilderPipelineBarrier { + /// Creates a new empty pipeline barrier command. + #[inline] + pub fn new() -> UnsafeCommandBufferBuilderPipelineBarrier { + UnsafeCommandBufferBuilderPipelineBarrier { + src_stage_mask: 0, + dst_stage_mask: 0, + dependency_flags: vk::DEPENDENCY_BY_REGION_BIT, + memory_barriers: SmallVec::new(), + buffer_barriers: SmallVec::new(), + image_barriers: SmallVec::new(), + } + } + + /// Returns true if no barrier or execution dependency has been added yet. + #[inline] + pub fn is_empty(&self) -> bool { + self.src_stage_mask == 0 || self.dst_stage_mask == 0 + } + + /// Merges another pipeline builder into this one. + #[inline] + pub fn merge(&mut self, other: UnsafeCommandBufferBuilderPipelineBarrier) { + self.src_stage_mask |= other.src_stage_mask; + self.dst_stage_mask |= other.dst_stage_mask; + self.dependency_flags &= other.dependency_flags; + + self.memory_barriers + .extend(other.memory_barriers.into_iter()); + self.buffer_barriers + .extend(other.buffer_barriers.into_iter()); + self.image_barriers.extend(other.image_barriers.into_iter()); + } + + /// Adds an execution dependency. This means that all the stages in `source` of the previous + /// commands must finish before any of the stages in `destination` of the following commands can start. + /// + /// # Safety + /// + /// - If the pipeline stages include geometry or tessellation stages, then the corresponding + /// features must have been enabled in the device. + /// - There are certain rules regarding the pipeline barriers inside render passes. + /// + #[inline] + pub unsafe fn add_execution_dependency(&mut self, source: PipelineStages, + destination: PipelineStages, by_region: bool) { + if !by_region { + self.dependency_flags = 0; + } + + debug_assert_ne!(source, PipelineStages::none()); + debug_assert_ne!(destination, PipelineStages::none()); + + self.src_stage_mask |= source.into_vulkan_bits(); + self.dst_stage_mask |= destination.into_vulkan_bits(); + } + + /// Adds a memory barrier. This means that all the memory writes by the given source stages + /// for the given source accesses must be visible by the given destination stages for the given + /// destination accesses. + /// + /// Also adds an execution dependency similar to `add_execution_dependency`. + /// + /// # Safety + /// + /// - Same as `add_execution_dependency`. + /// + pub unsafe fn add_memory_barrier(&mut self, source_stage: PipelineStages, + source_access: AccessFlagBits, + destination_stage: PipelineStages, + destination_access: AccessFlagBits, by_region: bool) { + debug_assert!(source_access.is_compatible_with(&source_stage)); + debug_assert!(destination_access.is_compatible_with(&destination_stage)); + + self.add_execution_dependency(source_stage, destination_stage, by_region); + + self.memory_barriers.push(vk::MemoryBarrier { + sType: vk::STRUCTURE_TYPE_MEMORY_BARRIER, + pNext: ptr::null(), + srcAccessMask: source_access.into_vulkan_bits(), + dstAccessMask: destination_access.into_vulkan_bits(), + }); + } + + /// Adds a buffer memory barrier. This means that all the memory writes to the given buffer by + /// the given source stages for the given source accesses must be visible by the given dest + /// stages for the given destination accesses. + /// + /// Also adds an execution dependency similar to `add_execution_dependency`. + /// + /// Also allows transferring buffer ownership between queues. + /// + /// # Safety + /// + /// - Same as `add_execution_dependency`. + /// - The buffer must be alive for at least as long as the command buffer to which this barrier + /// is added. + /// - Queue ownership transfers must be correct. + /// + pub unsafe fn add_buffer_memory_barrier<B>(&mut self, buffer: &B, source_stage: PipelineStages, + source_access: AccessFlagBits, + destination_stage: PipelineStages, + destination_access: AccessFlagBits, by_region: bool, + queue_transfer: Option<(u32, u32)>, offset: usize, + size: usize) + where B: ?Sized + BufferAccess + { + debug_assert!(source_access.is_compatible_with(&source_stage)); + debug_assert!(destination_access.is_compatible_with(&destination_stage)); + + self.add_execution_dependency(source_stage, destination_stage, by_region); + + debug_assert!(size <= buffer.size()); + let BufferInner { + buffer, + offset: org_offset, + } = buffer.inner(); + let offset = offset + org_offset; + + let (src_queue, dest_queue) = if let Some((src_queue, dest_queue)) = queue_transfer { + (src_queue, dest_queue) + } else { + (vk::QUEUE_FAMILY_IGNORED, vk::QUEUE_FAMILY_IGNORED) + }; + + self.buffer_barriers.push(vk::BufferMemoryBarrier { + sType: vk::STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, + pNext: ptr::null(), + srcAccessMask: source_access.into_vulkan_bits(), + dstAccessMask: destination_access.into_vulkan_bits(), + srcQueueFamilyIndex: src_queue, + dstQueueFamilyIndex: dest_queue, + buffer: buffer.internal_object(), + offset: offset as vk::DeviceSize, + size: size as vk::DeviceSize, + }); + } + + /// Adds an image memory barrier. This is the equivalent of `add_buffer_memory_barrier` but + /// for images. + /// + /// In addition to transferring image ownership between queues, it also allows changing the + /// layout of images. + /// + /// Also adds an execution dependency similar to `add_execution_dependency`. + /// + /// # Safety + /// + /// - Same as `add_execution_dependency`. + /// - The buffer must be alive for at least as long as the command buffer to which this barrier + /// is added. + /// - Queue ownership transfers must be correct. + /// - Image layouts transfers must be correct. + /// - Access flags must be compatible with the image usage flags passed at image creation. + /// + pub unsafe fn add_image_memory_barrier<I>(&mut self, image: &I, mipmaps: Range<u32>, + layers: Range<u32>, source_stage: PipelineStages, + source_access: AccessFlagBits, + destination_stage: PipelineStages, + destination_access: AccessFlagBits, by_region: bool, + queue_transfer: Option<(u32, u32)>, + current_layout: ImageLayout, new_layout: ImageLayout) + where I: ?Sized + ImageAccess + { + debug_assert!(source_access.is_compatible_with(&source_stage)); + debug_assert!(destination_access.is_compatible_with(&destination_stage)); + + self.add_execution_dependency(source_stage, destination_stage, by_region); + + debug_assert_ne!(new_layout, ImageLayout::Undefined); + debug_assert_ne!(new_layout, ImageLayout::Preinitialized); + + debug_assert!(mipmaps.start < mipmaps.end); + debug_assert!(mipmaps.end <= image.mipmap_levels()); + debug_assert!(layers.start < layers.end); + debug_assert!(layers.end <= image.dimensions().array_layers()); + + let (src_queue, dest_queue) = if let Some((src_queue, dest_queue)) = queue_transfer { + (src_queue, dest_queue) + } else { + (vk::QUEUE_FAMILY_IGNORED, vk::QUEUE_FAMILY_IGNORED) + }; + + let aspect_mask = if image.has_color() { + vk::IMAGE_ASPECT_COLOR_BIT + } else if image.has_depth() && image.has_stencil() { + vk::IMAGE_ASPECT_DEPTH_BIT | vk::IMAGE_ASPECT_STENCIL_BIT + } else if image.has_depth() { + vk::IMAGE_ASPECT_DEPTH_BIT + } else if image.has_stencil() { + vk::IMAGE_ASPECT_STENCIL_BIT + } else { + unreachable!() + }; + + let image = image.inner(); + + self.image_barriers.push(vk::ImageMemoryBarrier { + sType: vk::STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + pNext: ptr::null(), + srcAccessMask: source_access.into_vulkan_bits(), + dstAccessMask: destination_access.into_vulkan_bits(), + oldLayout: current_layout as u32, + newLayout: new_layout as u32, + srcQueueFamilyIndex: src_queue, + dstQueueFamilyIndex: dest_queue, + image: image.image.internal_object(), + subresourceRange: vk::ImageSubresourceRange { + aspectMask: aspect_mask, + baseMipLevel: mipmaps.start + + image.first_mipmap_level as u32, + levelCount: mipmaps.end - mipmaps.start, + baseArrayLayer: layers.start + image.first_layer as u32, + layerCount: layers.end - layers.start, + }, + }); + } +} + +/// Command buffer that has been built. +/// +/// Doesn't perform any synchronization and doesn't keep the object it uses alive. +pub struct UnsafeCommandBuffer<P> { + // The Vulkan command buffer. + cmd: P, + + // The raw version of `cmd`. Avoids having to require a trait on `P`. + cmd_raw: vk::CommandBuffer, + + // Device that owns the command buffer. + // TODO: necessary? + device: Arc<Device>, +} + +unsafe impl<P> DeviceOwned for UnsafeCommandBuffer<P> { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +unsafe impl<P> VulkanObject for UnsafeCommandBuffer<P> { + type Object = vk::CommandBuffer; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT; + + #[inline] + fn internal_object(&self) -> vk::CommandBuffer { + self.cmd_raw + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/traits.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/traits.rs new file mode 100644 index 0000000..9c8f326 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/traits.rs @@ -0,0 +1,395 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::borrow::Cow; +use std::error; +use std::fmt; +use std::sync::Arc; +use std::sync::Mutex; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; + +use SafeDeref; +use VulkanObject; +use buffer::BufferAccess; +use command_buffer::submit::SubmitAnyBuilder; +use command_buffer::submit::SubmitCommandBufferBuilder; +use command_buffer::sys::UnsafeCommandBuffer; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use image::ImageLayout; +use sync::AccessCheckError; +use sync::AccessError; +use sync::AccessFlagBits; +use sync::FlushError; +use sync::GpuFuture; +use sync::NowFuture; +use sync::PipelineStages; +use sync::now; + +pub unsafe trait CommandBuffer: DeviceOwned { + /// The command pool of the command buffer. + type PoolAlloc; + + /// Returns the underlying `UnsafeCommandBuffer` of this command buffer. + fn inner(&self) -> &UnsafeCommandBuffer<Self::PoolAlloc>; + + /*/// Returns the queue family of the command buffer. + #[inline] + fn queue_family(&self) -> QueueFamily + where Self::PoolAlloc: CommandPoolAlloc + { + self.inner().queue_family() + }*/ + + /// Checks whether this command buffer is allowed to be submitted after the `future` and on + /// the given queue, and if so locks it. + /// + /// If you call this function, then you should call `unlock` afterwards. + fn lock_submit(&self, future: &GpuFuture, queue: &Queue) -> Result<(), CommandBufferExecError>; + + /// Unlocks the command buffer. Should be called once for each call to `lock_submit`. + /// + /// # Safety + /// + /// Must not be called if you haven't called `lock_submit` before. + unsafe fn unlock(&self); + + /// Executes this command buffer on a queue. + /// + /// This function returns an object that implements the `GpuFuture` trait. See the + /// documentation of the `sync` module for more information. + /// + /// The command buffer is not actually executed until you call `flush()` on the object. + /// You are encouraged to chain together as many futures as possible before calling `flush()`, + /// and call `.then_signal_future()` before doing so. Note however that once you called + /// `execute()` there is no way to cancel the execution, even if you didn't flush yet. + /// + /// > **Note**: In the future this function may return `-> impl GpuFuture` instead of a + /// > concrete type. + /// + /// > **Note**: This is just a shortcut for `execute_after(vulkano::sync::now(), queue)`. + /// + /// # Panic + /// + /// Panics if the device of the command buffer is not the same as the device of the future. + #[inline] + fn execute(self, queue: Arc<Queue>) + -> Result<CommandBufferExecFuture<NowFuture, Self>, CommandBufferExecError> + where Self: Sized + 'static + { + let device = queue.device().clone(); + self.execute_after(now(device), queue) + } + + /// Executes the command buffer after an existing future. + /// + /// This function returns an object that implements the `GpuFuture` trait. See the + /// documentation of the `sync` module for more information. + /// + /// The command buffer is not actually executed until you call `flush()` on the object. + /// You are encouraged to chain together as many futures as possible before calling `flush()`, + /// and call `.then_signal_future()` before doing so. Note however that once you called + /// `execute()` there is no way to cancel the execution, even if you didn't flush yet. + /// + /// > **Note**: In the future this function may return `-> impl GpuFuture` instead of a + /// > concrete type. + /// + /// This function requires the `'static` lifetime to be on the command buffer. This is because + /// this function returns a `CommandBufferExecFuture` whose job is to lock resources and keep + /// them alive while they are in use by the GPU. If `'static` wasn't required, you could call + /// `std::mem::forget` on that object and "unlock" these resources. For more information about + /// this problem, search the web for "rust thread scoped leakpocalypse". + /// + /// # Panic + /// + /// Panics if the device of the command buffer is not the same as the device of the future. + #[inline] + fn execute_after<F>(self, future: F, queue: Arc<Queue>) + -> Result<CommandBufferExecFuture<F, Self>, CommandBufferExecError> + where Self: Sized + 'static, + F: GpuFuture + { + assert_eq!(self.device().internal_object(), + future.device().internal_object()); + + if !future.queue_change_allowed() { + assert!(future.queue().unwrap().is_same(&queue)); + } + + self.lock_submit(&future, &queue)?; + + Ok(CommandBufferExecFuture { + previous: future, + command_buffer: self, + queue: queue, + submitted: Mutex::new(false), + finished: AtomicBool::new(false), + }) + } + + fn check_buffer_access(&self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>; + + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>; + + // FIXME: lots of other methods +} + +unsafe impl<T> CommandBuffer for T + where T: SafeDeref, + T::Target: CommandBuffer +{ + type PoolAlloc = <T::Target as CommandBuffer>::PoolAlloc; + + #[inline] + fn inner(&self) -> &UnsafeCommandBuffer<Self::PoolAlloc> { + (**self).inner() + } + + #[inline] + fn lock_submit(&self, future: &GpuFuture, queue: &Queue) -> Result<(), CommandBufferExecError> { + (**self).lock_submit(future, queue) + } + + #[inline] + unsafe fn unlock(&self) { + (**self).unlock(); + } + + #[inline] + fn check_buffer_access( + &self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + (**self).check_buffer_access(buffer, exclusive, queue) + } + + #[inline] + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + (**self).check_image_access(image, layout, exclusive, queue) + } +} + +/// Represents a command buffer being executed by the GPU and the moment when the execution +/// finishes. +#[must_use = "Dropping this object will immediately block the thread until the GPU has finished processing the submission"] +pub struct CommandBufferExecFuture<F, Cb> + where F: GpuFuture, + Cb: CommandBuffer +{ + previous: F, + command_buffer: Cb, + queue: Arc<Queue>, + // True if the command buffer has already been submitted. + // If flush is called multiple times, we want to block so that only one flushing is executed. + // Therefore we use a `Mutex<bool>` and not an `AtomicBool`. + submitted: Mutex<bool>, + finished: AtomicBool, +} + +unsafe impl<F, Cb> GpuFuture for CommandBufferExecFuture<F, Cb> + where F: GpuFuture, + Cb: CommandBuffer +{ + #[inline] + fn cleanup_finished(&mut self) { + self.previous.cleanup_finished(); + } + + unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError> { + Ok(match self.previous.build_submission()? { + SubmitAnyBuilder::Empty => { + let mut builder = SubmitCommandBufferBuilder::new(); + builder.add_command_buffer(self.command_buffer.inner()); + SubmitAnyBuilder::CommandBuffer(builder) + }, + SubmitAnyBuilder::SemaphoresWait(sem) => { + let mut builder: SubmitCommandBufferBuilder = sem.into(); + builder.add_command_buffer(self.command_buffer.inner()); + SubmitAnyBuilder::CommandBuffer(builder) + }, + SubmitAnyBuilder::CommandBuffer(mut builder) => { + // FIXME: add pipeline barrier + builder.add_command_buffer(self.command_buffer.inner()); + SubmitAnyBuilder::CommandBuffer(builder) + }, + SubmitAnyBuilder::QueuePresent(_) | + SubmitAnyBuilder::BindSparse(_) => { + unimplemented!() // TODO: + /*present.submit(); // TODO: wrong + let mut builder = SubmitCommandBufferBuilder::new(); + builder.add_command_buffer(self.command_buffer.inner()); + SubmitAnyBuilder::CommandBuffer(builder)*/ + }, + }) + } + + #[inline] + fn flush(&self) -> Result<(), FlushError> { + unsafe { + let mut submitted = self.submitted.lock().unwrap(); + if *submitted { + return Ok(()); + } + + let queue = self.queue.clone(); + + match self.build_submission()? { + SubmitAnyBuilder::Empty => {}, + SubmitAnyBuilder::CommandBuffer(builder) => { + builder.submit(&queue)?; + }, + _ => unreachable!(), + }; + + // Only write `true` here in order to try again next time if we failed to submit. + *submitted = true; + Ok(()) + } + } + + #[inline] + unsafe fn signal_finished(&self) { + if self.finished.swap(true, Ordering::SeqCst) == false { + self.command_buffer.unlock(); + } + + self.previous.signal_finished(); + } + + #[inline] + fn queue_change_allowed(&self) -> bool { + false + } + + #[inline] + fn queue(&self) -> Option<Arc<Queue>> { + Some(self.queue.clone()) + } + + #[inline] + fn check_buffer_access( + &self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + match self.command_buffer + .check_buffer_access(buffer, exclusive, queue) { + Ok(v) => Ok(v), + Err(AccessCheckError::Denied(err)) => Err(AccessCheckError::Denied(err)), + Err(AccessCheckError::Unknown) => { + self.previous.check_buffer_access(buffer, exclusive, queue) + }, + } + } + + #[inline] + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + match self.command_buffer + .check_image_access(image, layout, exclusive, queue) { + Ok(v) => Ok(v), + Err(AccessCheckError::Denied(err)) => Err(AccessCheckError::Denied(err)), + Err(AccessCheckError::Unknown) => { + self.previous + .check_image_access(image, layout, exclusive, queue) + }, + } + } +} + +unsafe impl<F, Cb> DeviceOwned for CommandBufferExecFuture<F, Cb> + where F: GpuFuture, + Cb: CommandBuffer +{ + #[inline] + fn device(&self) -> &Arc<Device> { + self.command_buffer.device() + } +} + +impl<F, Cb> Drop for CommandBufferExecFuture<F, Cb> + where F: GpuFuture, + Cb: CommandBuffer +{ + fn drop(&mut self) { + unsafe { + if !*self.finished.get_mut() { + // TODO: handle errors? + self.flush().unwrap(); + // Block until the queue finished. + self.queue.wait().unwrap(); + self.command_buffer.unlock(); + self.previous.signal_finished(); + } + } + } +} + +/// Error that can happen when attempting to execute a command buffer. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum CommandBufferExecError { + /// Access to a resource has been denied. + AccessError { + error: AccessError, + command_name: Cow<'static, str>, + command_param: Cow<'static, str>, + command_offset: usize, + }, + + /// The command buffer or one of the secondary command buffers it executes was created with the + /// "one time submit" flag, but has already been submitted it the past. + OneTimeSubmitAlreadySubmitted, + + /// The command buffer or one of the secondary command buffers it executes is already in use by + /// the GPU and was not created with the "concurrent" flag. + ExclusiveAlreadyInUse, + + // TODO: missing entries (eg. wrong queue family, secondary command buffer) +} + +impl error::Error for CommandBufferExecError { + #[inline] + fn description(&self) -> &str { + match *self { + CommandBufferExecError::AccessError { .. } => { + "access to a resource has been denied" + }, + CommandBufferExecError::OneTimeSubmitAlreadySubmitted => { + "the command buffer or one of the secondary command buffers it executes was \ + created with the \"one time submit\" flag, but has already been submitted it \ + the past" + }, + CommandBufferExecError::ExclusiveAlreadyInUse => { + "the command buffer or one of the secondary command buffers it executes is \ + already in use by the GPU and was not created with the \"concurrent\" flag" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + CommandBufferExecError::AccessError { ref error, .. } => Some(error), + _ => None, + } + } +} + +impl fmt::Display for CommandBufferExecError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/blit_image.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/blit_image.rs new file mode 100644 index 0000000..8d89f0b --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/blit_image.rs @@ -0,0 +1,285 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use VulkanObject; +use device::Device; +use format::FormatTy; +use image::ImageAccess; +use image::ImageDimensions; +use sampler::Filter; + +/// Checks whether a blit image command is valid. +/// +/// Note that this doesn't check whether `layer_count` is equal to 0. TODO: change that? +/// +/// # Panic +/// +/// - Panics if the source or the destination was not created with `device`. +/// +pub fn check_blit_image<S, D>(device: &Device, source: &S, source_top_left: [i32; 3], + source_bottom_right: [i32; 3], source_base_array_layer: u32, + source_mip_level: u32, destination: &D, + destination_top_left: [i32; 3], destination_bottom_right: [i32; 3], + destination_base_array_layer: u32, destination_mip_level: u32, + layer_count: u32, filter: Filter) + -> Result<(), CheckBlitImageError> + where S: ?Sized + ImageAccess, + D: ?Sized + ImageAccess +{ + let source_inner = source.inner(); + let destination_inner = destination.inner(); + + assert_eq!(source_inner.image.device().internal_object(), + device.internal_object()); + assert_eq!(destination_inner.image.device().internal_object(), + device.internal_object()); + + if !source_inner.image.usage_transfer_source() { + return Err(CheckBlitImageError::MissingTransferSourceUsage); + } + + if !destination_inner.image.usage_transfer_destination() { + return Err(CheckBlitImageError::MissingTransferDestinationUsage); + } + + if !source_inner.image.supports_blit_source() { + return Err(CheckBlitImageError::SourceFormatNotSupported); + } + + if !destination_inner.image.supports_blit_destination() { + return Err(CheckBlitImageError::DestinationFormatNotSupported); + } + + if source.samples() != 1 || destination.samples() != 1 { + return Err(CheckBlitImageError::UnexpectedMultisampled); + } + + let source_format_ty = source.format().ty(); + let destination_format_ty = destination.format().ty(); + + if source_format_ty.is_depth_and_or_stencil() { + if source.format() != destination.format() { + return Err(CheckBlitImageError::DepthStencilFormatMismatch); + } + + if filter != Filter::Nearest { + return Err(CheckBlitImageError::DepthStencilNearestMandatory); + } + } + + let types_should_be_same = + source_format_ty == FormatTy::Uint || destination_format_ty == FormatTy::Uint || + source_format_ty == FormatTy::Sint || destination_format_ty == FormatTy::Sint; + if types_should_be_same && (source_format_ty != destination_format_ty) { + return Err(CheckBlitImageError::IncompatibleFormatsTypes { + source_format_ty: source.format().ty(), + destination_format_ty: destination.format().ty(), + }); + } + + let source_dimensions = match source.dimensions().mipmap_dimensions(source_mip_level) { + Some(d) => d, + None => return Err(CheckBlitImageError::SourceCoordinatesOutOfRange), + }; + + let destination_dimensions = match destination + .dimensions() + .mipmap_dimensions(destination_mip_level) { + Some(d) => d, + None => return Err(CheckBlitImageError::DestinationCoordinatesOutOfRange), + }; + + if source_base_array_layer + layer_count > source_dimensions.array_layers() { + return Err(CheckBlitImageError::SourceCoordinatesOutOfRange); + } + + if destination_base_array_layer + layer_count > destination_dimensions.array_layers() { + return Err(CheckBlitImageError::DestinationCoordinatesOutOfRange); + } + + if source_top_left[0] < 0 || source_top_left[0] > source_dimensions.width() as i32 { + return Err(CheckBlitImageError::SourceCoordinatesOutOfRange); + } + + if source_top_left[1] < 0 || source_top_left[1] > source_dimensions.height() as i32 { + return Err(CheckBlitImageError::SourceCoordinatesOutOfRange); + } + + if source_top_left[2] < 0 || source_top_left[2] > source_dimensions.depth() as i32 { + return Err(CheckBlitImageError::SourceCoordinatesOutOfRange); + } + + if source_bottom_right[0] < 0 || source_bottom_right[0] > source_dimensions.width() as i32 { + return Err(CheckBlitImageError::SourceCoordinatesOutOfRange); + } + + if source_bottom_right[1] < 0 || source_bottom_right[1] > source_dimensions.height() as i32 { + return Err(CheckBlitImageError::SourceCoordinatesOutOfRange); + } + + if source_bottom_right[2] < 0 || source_bottom_right[2] > source_dimensions.depth() as i32 { + return Err(CheckBlitImageError::SourceCoordinatesOutOfRange); + } + + if destination_top_left[0] < 0 || + destination_top_left[0] > destination_dimensions.width() as i32 + { + return Err(CheckBlitImageError::DestinationCoordinatesOutOfRange); + } + + if destination_top_left[1] < 0 || + destination_top_left[1] > destination_dimensions.height() as i32 + { + return Err(CheckBlitImageError::DestinationCoordinatesOutOfRange); + } + + if destination_top_left[2] < 0 || + destination_top_left[2] > destination_dimensions.depth() as i32 + { + return Err(CheckBlitImageError::DestinationCoordinatesOutOfRange); + } + + if destination_bottom_right[0] < 0 || + destination_bottom_right[0] > destination_dimensions.width() as i32 + { + return Err(CheckBlitImageError::DestinationCoordinatesOutOfRange); + } + + if destination_bottom_right[1] < 0 || + destination_bottom_right[1] > destination_dimensions.height() as i32 + { + return Err(CheckBlitImageError::DestinationCoordinatesOutOfRange); + } + + if destination_bottom_right[2] < 0 || + destination_bottom_right[2] > destination_dimensions.depth() as i32 + { + return Err(CheckBlitImageError::DestinationCoordinatesOutOfRange); + } + + match source_dimensions { + ImageDimensions::Dim1d { .. } => { + if source_top_left[1] != 0 || source_bottom_right[1] != 1 { + return Err(CheckBlitImageError::IncompatibleRangeForImageType); + } + if source_top_left[2] != 0 || source_bottom_right[2] != 1 { + return Err(CheckBlitImageError::IncompatibleRangeForImageType); + } + }, + ImageDimensions::Dim2d { .. } => { + if source_top_left[2] != 0 || source_bottom_right[2] != 1 { + return Err(CheckBlitImageError::IncompatibleRangeForImageType); + } + }, + ImageDimensions::Dim3d { .. } => {}, + } + + match destination_dimensions { + ImageDimensions::Dim1d { .. } => { + if destination_top_left[1] != 0 || destination_bottom_right[1] != 1 { + return Err(CheckBlitImageError::IncompatibleRangeForImageType); + } + if destination_top_left[2] != 0 || destination_bottom_right[2] != 1 { + return Err(CheckBlitImageError::IncompatibleRangeForImageType); + } + }, + ImageDimensions::Dim2d { .. } => { + if destination_top_left[2] != 0 || destination_bottom_right[2] != 1 { + return Err(CheckBlitImageError::IncompatibleRangeForImageType); + } + }, + ImageDimensions::Dim3d { .. } => {}, + } + + Ok(()) +} + +/// Error that can happen from `check_clear_color_image`. +#[derive(Debug, Copy, Clone)] +pub enum CheckBlitImageError { + /// The source is missing the transfer source usage. + MissingTransferSourceUsage, + /// The destination is missing the transfer destination usage. + MissingTransferDestinationUsage, + /// The format of the source image doesn't support blit operations. + SourceFormatNotSupported, + /// The format of the destination image doesn't support blit operations. + DestinationFormatNotSupported, + /// You must use the nearest filter when blitting depth/stencil images. + DepthStencilNearestMandatory, + /// The format of the source and destination must be equal when blitting depth/stencil images. + DepthStencilFormatMismatch, + /// The types of the source format and the destination format aren't compatible. + IncompatibleFormatsTypes { + source_format_ty: FormatTy, + destination_format_ty: FormatTy, + }, + /// Blitting between multisampled images is forbidden. + UnexpectedMultisampled, + /// The offsets, array layers and/or mipmap levels are out of range in the source image. + SourceCoordinatesOutOfRange, + /// The offsets, array layers and/or mipmap levels are out of range in the destination image. + DestinationCoordinatesOutOfRange, + /// The top-left and/or bottom-right coordinates are incompatible with the image type. + IncompatibleRangeForImageType, +} + +impl error::Error for CheckBlitImageError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckBlitImageError::MissingTransferSourceUsage => { + "the source is missing the transfer source usage" + }, + CheckBlitImageError::MissingTransferDestinationUsage => { + "the destination is missing the transfer destination usage" + }, + CheckBlitImageError::SourceFormatNotSupported => { + "the format of the source image doesn't support blit operations" + }, + CheckBlitImageError::DestinationFormatNotSupported => { + "the format of the destination image doesn't support blit operations" + }, + CheckBlitImageError::DepthStencilNearestMandatory => { + "you must use the nearest filter when blitting depth/stencil images" + }, + CheckBlitImageError::DepthStencilFormatMismatch => { + "the format of the source and destination must be equal when blitting \ + depth/stencil images" + }, + CheckBlitImageError::IncompatibleFormatsTypes { .. } => { + "the types of the source format and the destination format aren't compatible" + }, + CheckBlitImageError::UnexpectedMultisampled => { + "blitting between multisampled images is forbidden" + }, + CheckBlitImageError::SourceCoordinatesOutOfRange => { + "the offsets, array layers and/or mipmap levels are out of range in the source \ + image" + }, + CheckBlitImageError::DestinationCoordinatesOutOfRange => { + "the offsets, array layers and/or mipmap levels are out of range in the \ + destination image" + }, + CheckBlitImageError::IncompatibleRangeForImageType => { + "the top-left and/or bottom-right coordinates are incompatible with the image type" + }, + } + } +} + +impl fmt::Display for CheckBlitImageError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/clear_color_image.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/clear_color_image.rs new file mode 100644 index 0000000..27267cd --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/clear_color_image.rs @@ -0,0 +1,74 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use VulkanObject; +use device::Device; +use image::ImageAccess; + +/// Checks whether a clear color image command is valid. +/// +/// # Panic +/// +/// - Panics if the destination was not created with `device`. +/// +pub fn check_clear_color_image<I>(device: &Device, image: &I, first_layer: u32, num_layers: u32, + first_mipmap: u32, num_mipmaps: u32) + -> Result<(), CheckClearColorImageError> + where I: ?Sized + ImageAccess +{ + assert_eq!(image.inner().image.device().internal_object(), + device.internal_object()); + + if !image.inner().image.usage_transfer_destination() { + return Err(CheckClearColorImageError::MissingTransferUsage); + } + + if first_layer + num_layers > image.dimensions().array_layers() { + return Err(CheckClearColorImageError::OutOfRange); + } + + if first_mipmap + num_mipmaps > image.mipmap_levels() { + return Err(CheckClearColorImageError::OutOfRange); + } + + Ok(()) +} + +/// Error that can happen from `check_clear_color_image`. +#[derive(Debug, Copy, Clone)] +pub enum CheckClearColorImageError { + /// The image is missing the transfer destination usage. + MissingTransferUsage, + /// The array layers and mipmap levels are out of range. + OutOfRange, +} + +impl error::Error for CheckClearColorImageError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckClearColorImageError::MissingTransferUsage => { + "the image is missing the transfer destination usage" + }, + CheckClearColorImageError::OutOfRange => { + "the array layers and mipmap levels are out of range" + }, + } + } +} + +impl fmt::Display for CheckClearColorImageError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/copy_buffer.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/copy_buffer.rs new file mode 100644 index 0000000..7fc1ac2 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/copy_buffer.rs @@ -0,0 +1,97 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::cmp; +use std::error; +use std::fmt; + +use VulkanObject; +use buffer::TypedBufferAccess; +use device::Device; +use device::DeviceOwned; + +/// Checks whether a copy buffer command is valid. +/// +/// # Panic +/// +/// - Panics if the source and destination were not created with `device`. +/// +pub fn check_copy_buffer<S, D, T>(device: &Device, source: &S, destination: &D) + -> Result<CheckCopyBuffer, CheckCopyBufferError> + where S: ?Sized + TypedBufferAccess<Content = T>, + D: ?Sized + TypedBufferAccess<Content = T>, + T: ?Sized +{ + assert_eq!(source.inner().buffer.device().internal_object(), + device.internal_object()); + assert_eq!(destination.inner().buffer.device().internal_object(), + device.internal_object()); + + if !source.inner().buffer.usage_transfer_source() { + return Err(CheckCopyBufferError::SourceMissingTransferUsage); + } + + if !destination.inner().buffer.usage_transfer_destination() { + return Err(CheckCopyBufferError::DestinationMissingTransferUsage); + } + + let copy_size = cmp::min(source.size(), destination.size()); + + if source.conflicts_buffer(&destination) { + return Err(CheckCopyBufferError::OverlappingRanges); + } else { + debug_assert!(!destination.conflicts_buffer(&source)); + } + + Ok(CheckCopyBuffer { copy_size }) +} + +/// Information returned if `check_copy_buffer` succeeds. +pub struct CheckCopyBuffer { + /// Size of the transfer in bytes. + /// + /// If the size of the source and destination are not equal, then the value is equal to the + /// smallest of the two. + pub copy_size: usize, +} + +/// Error that can happen from `check_copy_buffer`. +#[derive(Debug, Copy, Clone)] +pub enum CheckCopyBufferError { + /// The source buffer is missing the transfer source usage. + SourceMissingTransferUsage, + /// The destination buffer is missing the transfer destination usage. + DestinationMissingTransferUsage, + /// The source and destination are overlapping. + OverlappingRanges, +} + +impl error::Error for CheckCopyBufferError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckCopyBufferError::SourceMissingTransferUsage => { + "the source buffer is missing the transfer source usage" + }, + CheckCopyBufferError::DestinationMissingTransferUsage => { + "the destination buffer is missing the transfer destination usage" + }, + CheckCopyBufferError::OverlappingRanges => { + "the source and destination are overlapping" + }, + } + } +} + +impl fmt::Display for CheckCopyBufferError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/copy_image.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/copy_image.rs new file mode 100644 index 0000000..ce597f9 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/copy_image.rs @@ -0,0 +1,230 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use VulkanObject; +use device::Device; +use format::FormatTy; +use format::PossibleCompressedFormatDesc; +use image::ImageAccess; +use image::ImageDimensions; + +/// Checks whether a copy image command is valid. +/// +/// Note that this doesn't check whether `layer_count` is equal to 0. TODO: change that? +/// +/// # Panic +/// +/// - Panics if the source or the destination was not created with `device`. +/// +pub fn check_copy_image<S, D>(device: &Device, source: &S, source_offset: [i32; 3], + source_base_array_layer: u32, source_mip_level: u32, + destination: &D, destination_offset: [i32; 3], + destination_base_array_layer: u32, destination_mip_level: u32, + extent: [u32; 3], layer_count: u32) + -> Result<(), CheckCopyImageError> + where S: ?Sized + ImageAccess, + D: ?Sized + ImageAccess +{ + let source_inner = source.inner(); + let destination_inner = destination.inner(); + + assert_eq!(source_inner.image.device().internal_object(), + device.internal_object()); + assert_eq!(destination_inner.image.device().internal_object(), + device.internal_object()); + + if !source_inner.image.usage_transfer_source() { + return Err(CheckCopyImageError::MissingTransferSourceUsage); + } + + if !destination_inner.image.usage_transfer_destination() { + return Err(CheckCopyImageError::MissingTransferDestinationUsage); + } + + if source.samples() != destination.samples() { + return Err(CheckCopyImageError::SampleCountMismatch); + } + + let source_format_ty = source.format().ty(); + let destination_format_ty = destination.format().ty(); + + if source_format_ty.is_depth_and_or_stencil() { + if source.format() != destination.format() { + return Err(CheckCopyImageError::DepthStencilFormatMismatch); + } + } + + // TODO: The correct check here is that the uncompressed element size of the source is + // equal to the compressed element size of the destination. However, format doesn't + // currently expose this information, so to be safe, we simply disallow compressed formats. + if source.format().is_compressed() || destination.format().is_compressed() || + (source.format().size() != destination.format().size()) { + return Err(CheckCopyImageError::SizeIncompatibleFormatsTypes { + source_format_ty: source.format().ty(), + destination_format_ty: destination.format().ty(), + }); + } + + let source_dimensions = match source + .dimensions() + .mipmap_dimensions(source_mip_level) { + Some(d) => d, + None => return Err(CheckCopyImageError::SourceCoordinatesOutOfRange), + }; + + let destination_dimensions = match destination + .dimensions() + .mipmap_dimensions(destination_mip_level) { + Some(d) => d, + None => return Err(CheckCopyImageError::DestinationCoordinatesOutOfRange), + }; + + if source_base_array_layer + layer_count > source_dimensions.array_layers() { + return Err(CheckCopyImageError::SourceCoordinatesOutOfRange); + } + + if destination_base_array_layer + layer_count > destination_dimensions.array_layers() { + return Err(CheckCopyImageError::DestinationCoordinatesOutOfRange); + } + + if source_offset[0] < 0 || + source_offset[0] as u32 + extent[0] > source_dimensions.width() { + return Err(CheckCopyImageError::SourceCoordinatesOutOfRange); + } + + if source_offset[1] < 0 || + source_offset[1] as u32 + extent[1] > source_dimensions.height() { + return Err(CheckCopyImageError::SourceCoordinatesOutOfRange); + } + + if source_offset[2] < 0 || + source_offset[2] as u32 + extent[2] > source_dimensions.depth() { + return Err(CheckCopyImageError::SourceCoordinatesOutOfRange); + } + + if destination_offset[0] < 0 || + destination_offset[0] as u32 + extent[0] > destination_dimensions.width() { + return Err(CheckCopyImageError::DestinationCoordinatesOutOfRange); + } + + if destination_offset[1] < 0 || + destination_offset[1] as u32 + extent[1] > destination_dimensions.height() { + return Err(CheckCopyImageError::DestinationCoordinatesOutOfRange); + } + + if destination_offset[2] < 0 || + destination_offset[2] as u32 + extent[2] > destination_dimensions.depth() { + return Err(CheckCopyImageError::DestinationCoordinatesOutOfRange); + } + + match source_dimensions { + ImageDimensions::Dim1d { .. } => { + if source_offset[1] != 0 || extent[1] != 1 { + return Err(CheckCopyImageError::IncompatibleRangeForImageType); + } + if source_offset[2] != 0 || extent[2] != 1 { + return Err(CheckCopyImageError::IncompatibleRangeForImageType); + } + }, + ImageDimensions::Dim2d { .. } => { + if source_offset[2] != 0 || extent[2] != 1 { + return Err(CheckCopyImageError::IncompatibleRangeForImageType); + } + }, + ImageDimensions::Dim3d { .. } => {}, + } + + match destination_dimensions { + ImageDimensions::Dim1d { .. } => { + if destination_offset[1] != 0 || extent[1] != 1 { + return Err(CheckCopyImageError::IncompatibleRangeForImageType); + } + if destination_offset[2] != 0 || extent[2] != 1 { + return Err(CheckCopyImageError::IncompatibleRangeForImageType); + } + }, + ImageDimensions::Dim2d { .. } => { + if destination_offset[2] != 0 || extent[2] != 1 { + return Err(CheckCopyImageError::IncompatibleRangeForImageType); + } + }, + ImageDimensions::Dim3d { .. } => {}, + } + + Ok(()) +} + +/// Error that can happen from `check_copy_image`. +#[derive(Debug, Copy, Clone)] +pub enum CheckCopyImageError { + /// The source is missing the transfer source usage. + MissingTransferSourceUsage, + /// The destination is missing the transfer destination usage. + MissingTransferDestinationUsage, + /// The number of samples in the source and destination do not match. + SampleCountMismatch, + /// The format of the source and destination must be equal when copying depth/stencil images. + DepthStencilFormatMismatch, + /// The types of the source format and the destination format aren't size-compatible. + SizeIncompatibleFormatsTypes { + source_format_ty: FormatTy, + destination_format_ty: FormatTy, + }, + /// The offsets, array layers and/or mipmap levels are out of range in the source image. + SourceCoordinatesOutOfRange, + /// The offsets, array layers and/or mipmap levels are out of range in the destination image. + DestinationCoordinatesOutOfRange, + /// The offsets or extent are incompatible with the image type. + IncompatibleRangeForImageType, +} + +impl error::Error for CheckCopyImageError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckCopyImageError::MissingTransferSourceUsage => { + "the source is missing the transfer source usage" + }, + CheckCopyImageError::MissingTransferDestinationUsage => { + "the destination is missing the transfer destination usage" + }, + CheckCopyImageError::SampleCountMismatch => { + "the number of samples in the source and destination do not match" + } + CheckCopyImageError::DepthStencilFormatMismatch => { + "the format of the source and destination must be equal when copying \ + depth/stencil images" + }, + CheckCopyImageError::SizeIncompatibleFormatsTypes { .. } => { + "the types of the source format and the destination format aren't size-compatible" + }, + CheckCopyImageError::SourceCoordinatesOutOfRange => { + "the offsets, array layers and/or mipmap levels are out of range in the source \ + image" + }, + CheckCopyImageError::DestinationCoordinatesOutOfRange => { + "the offsets, array layers and/or mipmap levels are out of range in the \ + destination image" + }, + CheckCopyImageError::IncompatibleRangeForImageType => { + "the offsets or extent are incompatible with the image type" + }, + } + } +} + +impl fmt::Display for CheckCopyImageError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/copy_image_buffer.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/copy_image_buffer.rs new file mode 100644 index 0000000..d1f2e57 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/copy_image_buffer.rs @@ -0,0 +1,190 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use VulkanObject; +use buffer::TypedBufferAccess; +use device::Device; +use device::DeviceOwned; +use format::AcceptsPixels; +use format::Format; +use format::IncompatiblePixelsType; +use image::ImageAccess; + +/// Type of operation to check. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum CheckCopyBufferImageTy { + BufferToImage, + ImageToBuffer, +} + +/// Checks whether a copy buffer-image command is valid. Can check both buffer-to-image copies and +/// image-to-buffer copies. +/// +/// # Panic +/// +/// - Panics if the buffer and image were not created with `device`. +/// +// TODO: handle compressed image formats +pub fn check_copy_buffer_image<B, I, P>(device: &Device, buffer: &B, image: &I, + ty: CheckCopyBufferImageTy, image_offset: [u32; 3], + image_size: [u32; 3], image_first_layer: u32, + image_num_layers: u32, image_mipmap: u32) + -> Result<(), CheckCopyBufferImageError> + where I: ?Sized + ImageAccess, + B: ?Sized + TypedBufferAccess<Content = [P]>, + Format: AcceptsPixels<P> // TODO: use a trait on the image itself instead +{ + let buffer_inner = buffer.inner(); + let image_inner = image.inner(); + + assert_eq!(buffer_inner.buffer.device().internal_object(), + device.internal_object()); + assert_eq!(image_inner.image.device().internal_object(), + device.internal_object()); + + match ty { + CheckCopyBufferImageTy::BufferToImage => { + if !buffer_inner.buffer.usage_transfer_source() { + return Err(CheckCopyBufferImageError::SourceMissingTransferUsage); + } + if !image_inner.image.usage_transfer_destination() { + return Err(CheckCopyBufferImageError::DestinationMissingTransferUsage); + } + }, + CheckCopyBufferImageTy::ImageToBuffer => { + if !image_inner.image.usage_transfer_source() { + return Err(CheckCopyBufferImageError::SourceMissingTransferUsage); + } + if !buffer_inner.buffer.usage_transfer_destination() { + return Err(CheckCopyBufferImageError::DestinationMissingTransferUsage); + } + }, + } + + if image.samples() != 1 { + return Err(CheckCopyBufferImageError::UnexpectedMultisampled); + } + + let image_dimensions = match image.dimensions().mipmap_dimensions(image_mipmap) { + Some(d) => d, + None => return Err(CheckCopyBufferImageError::ImageCoordinatesOutOfRange), + }; + + if image_first_layer + image_num_layers > image_dimensions.array_layers() { + return Err(CheckCopyBufferImageError::ImageCoordinatesOutOfRange); + } + + if image_offset[0] + image_size[0] > image_dimensions.width() { + return Err(CheckCopyBufferImageError::ImageCoordinatesOutOfRange); + } + + if image_offset[1] + image_size[1] > image_dimensions.height() { + return Err(CheckCopyBufferImageError::ImageCoordinatesOutOfRange); + } + + if image_offset[2] + image_size[2] > image_dimensions.depth() { + return Err(CheckCopyBufferImageError::ImageCoordinatesOutOfRange); + } + + image.format().ensure_accepts()?; + + { + let num_texels = image_size[0] * image_size[1] * image_size[2] * image_num_layers; + let required_len = num_texels as usize * image.format().rate() as usize; + if required_len > buffer.len() { + return Err(CheckCopyBufferImageError::BufferTooSmall { + required_len: required_len, + actual_len: buffer.len(), + }); + } + } + + // TODO: check memory overlap? + + Ok(()) +} + +/// Error that can happen from `check_copy_buffer_image`. +#[derive(Debug, Copy, Clone)] +pub enum CheckCopyBufferImageError { + /// The source buffer or image is missing the transfer source usage. + SourceMissingTransferUsage, + /// The destination buffer or image is missing the transfer destination usage. + DestinationMissingTransferUsage, + /// The source and destination are overlapping. + OverlappingRanges, + /// The image must not be multisampled. + UnexpectedMultisampled, + /// The image coordinates are out of range. + ImageCoordinatesOutOfRange, + /// The type of pixels in the buffer isn't compatible with the image format. + WrongPixelType(IncompatiblePixelsType), + /// The buffer is too small for the copy operation. + BufferTooSmall { + /// Required number of elements in the buffer. + required_len: usize, + /// Actual number of elements in the buffer. + actual_len: usize, + }, +} + +impl error::Error for CheckCopyBufferImageError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckCopyBufferImageError::SourceMissingTransferUsage => { + "the source buffer is missing the transfer source usage" + }, + CheckCopyBufferImageError::DestinationMissingTransferUsage => { + "the destination buffer is missing the transfer destination usage" + }, + CheckCopyBufferImageError::OverlappingRanges => { + "the source and destination are overlapping" + }, + CheckCopyBufferImageError::UnexpectedMultisampled => { + "the image must not be multisampled" + }, + CheckCopyBufferImageError::ImageCoordinatesOutOfRange => { + "the image coordinates are out of range" + }, + CheckCopyBufferImageError::WrongPixelType(_) => { + "the type of pixels in the buffer isn't compatible with the image format" + }, + CheckCopyBufferImageError::BufferTooSmall { .. } => { + "the buffer is too small for the copy operation" + }, + } + } + + fn cause(&self) -> Option<&error::Error> { + match *self { + CheckCopyBufferImageError::WrongPixelType(ref err) => { + Some(err) + }, + _ => None, + } + } +} + +impl fmt::Display for CheckCopyBufferImageError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<IncompatiblePixelsType> for CheckCopyBufferImageError { + #[inline] + fn from(err: IncompatiblePixelsType) -> CheckCopyBufferImageError { + CheckCopyBufferImageError::WrongPixelType(err) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/descriptor_sets.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/descriptor_sets.rs new file mode 100644 index 0000000..4b5eed6 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/descriptor_sets.rs @@ -0,0 +1,109 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use descriptor::descriptor::DescriptorDescSupersetError; +use descriptor::descriptor_set::DescriptorSetsCollection; +use descriptor::pipeline_layout::PipelineLayoutDesc; + +/// Checks whether descriptor sets are compatible with the pipeline. +pub fn check_descriptor_sets_validity<Pl, D>(pipeline: &Pl, descriptor_sets: &D) + -> Result<(), CheckDescriptorSetsValidityError> + where Pl: ?Sized + PipelineLayoutDesc, + D: ?Sized + DescriptorSetsCollection +{ + // What's important is not that the pipeline layout and the descriptor sets *match*. Instead + // what's important is that the descriptor sets are a superset of the pipeline layout. It's not + // a problem if the descriptor sets provide more elements than expected. + + for set_num in 0 .. pipeline.num_sets() { + for binding_num in 0 .. pipeline.num_bindings_in_set(set_num).unwrap_or(0) { + let set_desc = descriptor_sets.descriptor(set_num, binding_num); + let pipeline_desc = pipeline.descriptor(set_num, binding_num); + + let (set_desc, pipeline_desc) = match (set_desc, pipeline_desc) { + (Some(s), Some(p)) => (s, p), + (None, Some(_)) => + return Err(CheckDescriptorSetsValidityError::MissingDescriptor { + set_num: set_num, + binding_num: binding_num, + }), + (Some(_), None) => continue, + (None, None) => continue, + }; + + if let Err(err) = set_desc.is_superset_of(&pipeline_desc) { + return Err(CheckDescriptorSetsValidityError::IncompatibleDescriptor { + error: err, + set_num: set_num, + binding_num: binding_num, + }); + } + } + } + + Ok(()) +} + +/// Error that can happen when checking descriptor sets validity. +#[derive(Debug, Clone)] +pub enum CheckDescriptorSetsValidityError { + /// A descriptor is missing in the descriptor sets that were provided. + MissingDescriptor { + /// The index of the set of the descriptor. + set_num: usize, + /// The binding number of the descriptor. + binding_num: usize, + }, + + /// A descriptor in the provided sets is not compatible with what is expected. + IncompatibleDescriptor { + /// The reason why the two descriptors aren't compatible. + error: DescriptorDescSupersetError, + /// The index of the set of the descriptor. + set_num: usize, + /// The binding number of the descriptor. + binding_num: usize, + }, +} + +impl error::Error for CheckDescriptorSetsValidityError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckDescriptorSetsValidityError::MissingDescriptor { .. } => { + "a descriptor is missing in the descriptor sets that were provided" + }, + CheckDescriptorSetsValidityError::IncompatibleDescriptor { .. } => { + "a descriptor in the provided sets is not compatible with what is expected" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + CheckDescriptorSetsValidityError::IncompatibleDescriptor { ref error, .. } => { + Some(error) + }, + _ => None, + } + } +} + +impl fmt::Display for CheckDescriptorSetsValidityError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +// TODO: tests diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/dispatch.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/dispatch.rs new file mode 100644 index 0000000..b827d96 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/dispatch.rs @@ -0,0 +1,88 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use device::Device; + +/// Checks whether the dispatch dimensions are supported by the device. +pub fn check_dispatch(device: &Device, dimensions: [u32; 3]) -> Result<(), CheckDispatchError> { + let max = device + .physical_device() + .limits() + .max_compute_work_group_count(); + + if dimensions[0] > max[0] || dimensions[1] > max[1] || dimensions[2] > max[2] { + return Err(CheckDispatchError::UnsupportedDimensions { + requested: dimensions, + max_supported: max, + }); + } + + Ok(()) +} + +/// Error that can happen when checking dispatch command validity. +#[derive(Debug, Copy, Clone)] +pub enum CheckDispatchError { + /// The dimensions are too large for the device's limits. + UnsupportedDimensions { + /// The requested dimensions. + requested: [u32; 3], + /// The actual supported dimensions. + max_supported: [u32; 3], + }, +} + +impl error::Error for CheckDispatchError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckDispatchError::UnsupportedDimensions { .. } => { + "the dimensions are too large for the device's limits" + }, + } + } +} + +impl fmt::Display for CheckDispatchError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +#[cfg(test)] +mod tests { + use command_buffer::validity; + + #[test] + fn max_checked() { + let (device, _) = gfx_dev_and_queue!(); + + let attempted = [u32::max_value(), u32::max_value(), u32::max_value()]; + + // Just in case the device is some kind of software implementation. + if device + .physical_device() + .limits() + .max_compute_work_group_count() == attempted + { + return; + } + + match validity::check_dispatch(&device, attempted) { + Err(validity::CheckDispatchError::UnsupportedDimensions { requested, .. }) => { + assert_eq!(requested, attempted); + }, + _ => panic!(), + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/dynamic_state.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/dynamic_state.rs new file mode 100644 index 0000000..843f88a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/dynamic_state.rs @@ -0,0 +1,158 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use command_buffer::DynamicState; +use pipeline::GraphicsPipelineAbstract; + +/// Checks whether states that are about to be set are correct. +pub fn check_dynamic_state_validity<Pl>(pipeline: &Pl, state: &DynamicState) + -> Result<(), CheckDynamicStateValidityError> + where Pl: GraphicsPipelineAbstract +{ + let device = pipeline.device(); + + if pipeline.has_dynamic_line_width() { + if let Some(value) = state.line_width { + if value != 1.0 && !pipeline.device().enabled_features().wide_lines { + return Err(CheckDynamicStateValidityError::LineWidthMissingExtension); + } + } else { + return Err(CheckDynamicStateValidityError::LineWidthMissing); + } + + } else { + if state.line_width.is_some() { + return Err(CheckDynamicStateValidityError::LineWidthNotDynamic); + } + } + + if pipeline.has_dynamic_viewports() { + if let Some(ref viewports) = state.viewports { + if viewports.len() != pipeline.num_viewports() as usize { + return Err(CheckDynamicStateValidityError::ViewportsCountMismatch { + expected: pipeline.num_viewports() as usize, + obtained: viewports.len(), + }); + } + } else { + return Err(CheckDynamicStateValidityError::ViewportsMissing); + } + + } else { + if state.viewports.is_some() { + return Err(CheckDynamicStateValidityError::ViewportsNotDynamic); + } + } + + if pipeline.has_dynamic_scissors() { + if let Some(ref scissors) = state.scissors { + if scissors.len() != pipeline.num_viewports() as usize { + return Err(CheckDynamicStateValidityError::ScissorsCountMismatch { + expected: pipeline.num_viewports() as usize, + obtained: scissors.len(), + }); + } + } else { + return Err(CheckDynamicStateValidityError::ScissorsMissing); + } + + } else { + if state.scissors.is_some() { + return Err(CheckDynamicStateValidityError::ScissorsNotDynamic); + } + } + + // TODO: don't forget to implement the rest + + Ok(()) +} + +/// Error that can happen when validating dynamic states. +#[derive(Debug, Copy, Clone)] +pub enum CheckDynamicStateValidityError { + /// Passed a dynamic line width, while the pipeline doesn't have line width set as dynamic. + LineWidthNotDynamic, + /// The pipeline has a dynamic line width, but no line width value was passed. + LineWidthMissing, + /// The `wide_lines` extension must be enabled in order to use line width values different + /// from 1.0. + LineWidthMissingExtension, + /// Passed dynamic viewports, while the pipeline doesn't have viewports set as dynamic. + ViewportsNotDynamic, + /// The pipeline has dynamic viewports, but no viewports were passed. + ViewportsMissing, + /// The number of dynamic viewports doesn't match the expected number of viewports. + ViewportsCountMismatch { + /// Expected number of viewports. + expected: usize, + /// Number of viewports that were passed. + obtained: usize, + }, + /// Passed dynamic scissors, while the pipeline doesn't have scissors set as dynamic. + ScissorsNotDynamic, + /// The pipeline has dynamic scissors, but no scissors were passed. + ScissorsMissing, + /// The number of dynamic scissors doesn't match the expected number of scissors. + ScissorsCountMismatch { + /// Expected number of scissors. + expected: usize, + /// Number of scissors that were passed. + obtained: usize, + }, +} + +impl error::Error for CheckDynamicStateValidityError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckDynamicStateValidityError::LineWidthNotDynamic => { + "passed a dynamic line width, while the pipeline doesn't have line width set as \ + dynamic" + }, + CheckDynamicStateValidityError::LineWidthMissing => { + "the pipeline has a dynamic line width, but no line width value was passed" + }, + CheckDynamicStateValidityError::LineWidthMissingExtension => { + "the `wide_lines` extension must be enabled in order to use line width values \ + different from 1.0" + }, + CheckDynamicStateValidityError::ViewportsNotDynamic => { + "passed dynamic viewports, while the pipeline doesn't have viewports set as \ + dynamic" + }, + CheckDynamicStateValidityError::ViewportsMissing => { + "the pipeline has dynamic viewports, but no viewports were passed" + }, + CheckDynamicStateValidityError::ViewportsCountMismatch { .. } => { + "the number of dynamic viewports doesn't match the expected number of viewports" + }, + CheckDynamicStateValidityError::ScissorsNotDynamic => { + "passed dynamic scissors, while the pipeline doesn't have scissors set as dynamic" + }, + CheckDynamicStateValidityError::ScissorsMissing => { + "the pipeline has dynamic scissors, but no scissors were passed" + }, + CheckDynamicStateValidityError::ScissorsCountMismatch { .. } => { + "the number of dynamic scissors doesn't match the expected number of scissors" + }, + } + } +} + +impl fmt::Display for CheckDynamicStateValidityError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +// TODO: tests diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/fill_buffer.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/fill_buffer.rs new file mode 100644 index 0000000..2648849 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/fill_buffer.rs @@ -0,0 +1,100 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use VulkanObject; +use buffer::BufferAccess; +use device::Device; +use device::DeviceOwned; + +/// Checks whether a fill buffer command is valid. +/// +/// # Panic +/// +/// - Panics if the buffer not created with `device`. +/// +pub fn check_fill_buffer<B>(device: &Device, buffer: &B) -> Result<(), CheckFillBufferError> + where B: ?Sized + BufferAccess +{ + assert_eq!(buffer.inner().buffer.device().internal_object(), + device.internal_object()); + + if !buffer.inner().buffer.usage_transfer_destination() { + return Err(CheckFillBufferError::BufferMissingUsage); + } + + if buffer.inner().offset % 4 != 0 { + return Err(CheckFillBufferError::WrongAlignment); + } + + Ok(()) +} + +/// Error that can happen when attempting to add a `fill_buffer` command. +#[derive(Debug, Copy, Clone)] +pub enum CheckFillBufferError { + /// The "transfer destination" usage must be enabled on the buffer. + BufferMissingUsage, + /// The data or size must be 4-bytes aligned. + WrongAlignment, +} + +impl error::Error for CheckFillBufferError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckFillBufferError::BufferMissingUsage => { + "the transfer destination usage must be enabled on the buffer" + }, + CheckFillBufferError::WrongAlignment => { + "the offset or size are not aligned to 4 bytes" + }, + } + } +} + +impl fmt::Display for CheckFillBufferError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use buffer::BufferUsage; + use buffer::CpuAccessibleBuffer; + + #[test] + fn missing_usage() { + let (device, queue) = gfx_dev_and_queue!(); + let buffer = + CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::vertex_buffer(), 0u32) + .unwrap(); + + match check_fill_buffer(&device, &buffer) { + Err(CheckFillBufferError::BufferMissingUsage) => (), + _ => panic!(), + } + } + + #[test] + fn wrong_device() { + let (dev1, queue) = gfx_dev_and_queue!(); + let (dev2, _) = gfx_dev_and_queue!(); + let buffer = CpuAccessibleBuffer::from_data(dev1, BufferUsage::all(), 0u32).unwrap(); + + assert_should_panic!({ + let _ = check_fill_buffer(&dev2, &buffer); + }); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/index_buffer.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/index_buffer.rs new file mode 100644 index 0000000..1978741 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/index_buffer.rs @@ -0,0 +1,135 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use VulkanObject; +use buffer::BufferAccess; +use buffer::TypedBufferAccess; +use device::Device; +use device::DeviceOwned; +use pipeline::input_assembly::Index; + +/// Checks whether an index buffer can be bound. +/// +/// # Panic +/// +/// - Panics if the buffer was not created with `device`. +/// +pub fn check_index_buffer<B, I>(device: &Device, buffer: &B) + -> Result<CheckIndexBuffer, CheckIndexBufferError> + where B: ?Sized + BufferAccess + TypedBufferAccess<Content = [I]>, + I: Index +{ + assert_eq!(buffer.inner().buffer.device().internal_object(), + device.internal_object()); + + if !buffer.inner().buffer.usage_index_buffer() { + return Err(CheckIndexBufferError::BufferMissingUsage); + } + + // TODO: The sum of offset and the address of the range of VkDeviceMemory object that is + // backing buffer, must be a multiple of the type indicated by indexType + + // TODO: fullDrawIndexUint32 feature + + Ok(CheckIndexBuffer { num_indices: buffer.len() }) +} + +/// Information returned if `check_index_buffer` succeeds. +pub struct CheckIndexBuffer { + /// Number of indices in the index buffer. + pub num_indices: usize, +} + +/// Error that can happen when checking whether binding an index buffer is valid. +#[derive(Debug, Copy, Clone)] +pub enum CheckIndexBufferError { + /// The "index buffer" usage must be enabled on the index buffer. + BufferMissingUsage, + /// The data or size must be 4-bytes aligned. + WrongAlignment, + /// The type of the indices is not supported by the device. + UnsupportIndexType, +} + +impl error::Error for CheckIndexBufferError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckIndexBufferError::BufferMissingUsage => { + "the index buffer usage must be enabled on the index buffer" + }, + CheckIndexBufferError::WrongAlignment => { + "the sum of offset and the address of the range of VkDeviceMemory object that is \ + backing buffer, must be a multiple of the type indicated by indexType" + }, + CheckIndexBufferError::UnsupportIndexType => { + "the type of the indices is not supported by the device" + }, + } + } +} + +impl fmt::Display for CheckIndexBufferError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use buffer::BufferUsage; + use buffer::CpuAccessibleBuffer; + + #[test] + fn num_indices() { + let (device, queue) = gfx_dev_and_queue!(); + let buffer = CpuAccessibleBuffer::from_iter(device.clone(), + BufferUsage::index_buffer(), + 0 .. 500u32) + .unwrap(); + + match check_index_buffer(&device, &buffer) { + Ok(CheckIndexBuffer { num_indices }) => { + assert_eq!(num_indices, 500); + }, + _ => panic!(), + } + } + + #[test] + fn missing_usage() { + let (device, queue) = gfx_dev_and_queue!(); + let buffer = CpuAccessibleBuffer::from_iter(device.clone(), + BufferUsage::vertex_buffer(), + 0 .. 500u32) + .unwrap(); + + match check_index_buffer(&device, &buffer) { + Err(CheckIndexBufferError::BufferMissingUsage) => (), + _ => panic!(), + } + } + + #[test] + fn wrong_device() { + let (dev1, queue) = gfx_dev_and_queue!(); + let (dev2, _) = gfx_dev_and_queue!(); + + let buffer = CpuAccessibleBuffer::from_iter(dev1, BufferUsage::all(), 0 .. 500u32).unwrap(); + + assert_should_panic!({ + let _ = check_index_buffer(&dev2, &buffer); + }); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/mod.rs new file mode 100644 index 0000000..a5b1b14 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/mod.rs @@ -0,0 +1,39 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Functions that check the validity of commands. + +pub use self::blit_image::{CheckBlitImageError, check_blit_image}; +pub use self::clear_color_image::{CheckClearColorImageError, check_clear_color_image}; +pub use self::copy_buffer::{CheckCopyBuffer, CheckCopyBufferError, check_copy_buffer}; +pub use self::copy_image::{CheckCopyImageError, check_copy_image}; +pub use self::copy_image_buffer::{CheckCopyBufferImageError, CheckCopyBufferImageTy, + check_copy_buffer_image}; +pub use self::descriptor_sets::{CheckDescriptorSetsValidityError, check_descriptor_sets_validity}; +pub use self::dispatch::{CheckDispatchError, check_dispatch}; +pub use self::dynamic_state::{CheckDynamicStateValidityError, check_dynamic_state_validity}; +pub use self::fill_buffer::{CheckFillBufferError, check_fill_buffer}; +pub use self::index_buffer::{CheckIndexBuffer, CheckIndexBufferError, check_index_buffer}; +pub use self::push_constants::{CheckPushConstantsValidityError, check_push_constants_validity}; +pub use self::update_buffer::{CheckUpdateBufferError, check_update_buffer}; +pub use self::vertex_buffers::{CheckVertexBuffer, CheckVertexBufferError, check_vertex_buffers}; + +mod blit_image; +mod clear_color_image; +mod copy_buffer; +mod copy_image; +mod copy_image_buffer; +mod descriptor_sets; +mod dispatch; +mod dynamic_state; +mod fill_buffer; +mod index_buffer; +mod push_constants; +mod update_buffer; +mod vertex_buffers; diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/push_constants.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/push_constants.rs new file mode 100644 index 0000000..e5c3fb6 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/push_constants.rs @@ -0,0 +1,52 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use descriptor::pipeline_layout::PipelineLayoutAbstract; +use descriptor::pipeline_layout::PipelineLayoutPushConstantsCompatible; + +/// Checks whether push constants are compatible with the pipeline. +pub fn check_push_constants_validity<Pl, Pc>(pipeline: &Pl, push_constants: &Pc) + -> Result<(), CheckPushConstantsValidityError> + where Pl: ?Sized + PipelineLayoutAbstract + PipelineLayoutPushConstantsCompatible<Pc>, + Pc: ?Sized +{ + if !pipeline.is_compatible(push_constants) { + return Err(CheckPushConstantsValidityError::IncompatiblePushConstants); + } + + Ok(()) +} + +/// Error that can happen when checking push constants validity. +#[derive(Debug, Copy, Clone)] +pub enum CheckPushConstantsValidityError { + /// The push constants are incompatible with the pipeline layout. + IncompatiblePushConstants, +} + +impl error::Error for CheckPushConstantsValidityError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckPushConstantsValidityError::IncompatiblePushConstants => { + "the push constants are incompatible with the pipeline layout" + }, + } + } +} + +impl fmt::Display for CheckPushConstantsValidityError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/update_buffer.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/update_buffer.rs new file mode 100644 index 0000000..6384643 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/update_buffer.rs @@ -0,0 +1,163 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::cmp; +use std::error; +use std::fmt; +use std::mem; + +use VulkanObject; +use buffer::TypedBufferAccess; +use device::Device; +use device::DeviceOwned; + +/// Checks whether an update buffer command is valid. +/// +/// # Panic +/// +/// - Panics if the buffer not created with `device`. +/// +pub fn check_update_buffer<B, D>(device: &Device, buffer: &B, data: &D) + -> Result<(), CheckUpdateBufferError> + where B: ?Sized + TypedBufferAccess<Content = D>, + D: ?Sized +{ + assert_eq!(buffer.inner().buffer.device().internal_object(), + device.internal_object()); + + if !buffer.inner().buffer.usage_transfer_destination() { + return Err(CheckUpdateBufferError::BufferMissingUsage); + } + + if buffer.inner().offset % 4 != 0 { + return Err(CheckUpdateBufferError::WrongAlignment); + } + + let size = cmp::min(buffer.size(), mem::size_of_val(data)); + + if size % 4 != 0 { + return Err(CheckUpdateBufferError::WrongAlignment); + } + + if size > 65536 { + return Err(CheckUpdateBufferError::DataTooLarge); + } + + Ok(()) +} + +/// Error that can happen when attempting to add an `update_buffer` command. +#[derive(Debug, Copy, Clone)] +pub enum CheckUpdateBufferError { + /// The "transfer destination" usage must be enabled on the buffer. + BufferMissingUsage, + /// The data or size must be 4-bytes aligned. + WrongAlignment, + /// The data must not be larger than 64k bytes. + DataTooLarge, +} + +impl error::Error for CheckUpdateBufferError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckUpdateBufferError::BufferMissingUsage => { + "the transfer destination usage must be enabled on the buffer" + }, + CheckUpdateBufferError::WrongAlignment => { + "the offset or size are not aligned to 4 bytes" + }, + CheckUpdateBufferError::DataTooLarge => "data is too large", + } + } +} + +impl fmt::Display for CheckUpdateBufferError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use buffer::BufferAccess; + use buffer::BufferUsage; + use buffer::CpuAccessibleBuffer; + + #[test] + fn missing_usage() { + let (device, queue) = gfx_dev_and_queue!(); + let buffer = + CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::vertex_buffer(), 0u32) + .unwrap(); + + match check_update_buffer(&device, &buffer, &0) { + Err(CheckUpdateBufferError::BufferMissingUsage) => (), + _ => panic!(), + } + } + + #[test] + fn data_too_large() { + let (device, queue) = gfx_dev_and_queue!(); + let buffer = CpuAccessibleBuffer::from_iter(device.clone(), + BufferUsage::transfer_destination(), + 0 .. 65536) + .unwrap(); + let data = (0 .. 65536).collect::<Vec<u32>>(); + + match check_update_buffer(&device, &buffer, &data[..]) { + Err(CheckUpdateBufferError::DataTooLarge) => (), + _ => panic!(), + } + } + + #[test] + fn data_just_large_enough() { + let (device, queue) = gfx_dev_and_queue!(); + let buffer = CpuAccessibleBuffer::from_iter(device.clone(), + BufferUsage::transfer_destination(), + (0 .. 100000).map(|_| 0)) + .unwrap(); + let data = (0 .. 65536).map(|_| 0).collect::<Vec<u8>>(); + + match check_update_buffer(&device, &buffer, &data[..]) { + Ok(_) => (), + _ => panic!(), + } + } + + #[test] + fn wrong_alignment() { + let (device, queue) = gfx_dev_and_queue!(); + let buffer = CpuAccessibleBuffer::from_iter(device.clone(), + BufferUsage::transfer_destination(), + 0 .. 100) + .unwrap(); + let data = (0 .. 30).collect::<Vec<u8>>(); + + match check_update_buffer(&device, &buffer.slice(1 .. 50).unwrap(), &data[..]) { + Err(CheckUpdateBufferError::WrongAlignment) => (), + _ => panic!(), + } + } + + #[test] + fn wrong_device() { + let (dev1, queue) = gfx_dev_and_queue!(); + let (dev2, _) = gfx_dev_and_queue!(); + let buffer = CpuAccessibleBuffer::from_data(dev1, BufferUsage::all(), 0u32).unwrap(); + + assert_should_panic!({ + let _ = check_update_buffer(&dev2, &buffer, &0); + }); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/vertex_buffers.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/vertex_buffers.rs new file mode 100644 index 0000000..62980d0 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/command_buffer/validity/vertex_buffers.rs @@ -0,0 +1,82 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use VulkanObject; +use buffer::BufferAccess; +use device::DeviceOwned; +use pipeline::vertex::VertexSource; + +/// Checks whether vertex buffers can be bound. +/// +/// # Panic +/// +/// - Panics if one of the vertex buffers was not created with the same device as `pipeline`. +/// +pub fn check_vertex_buffers<P, V>(pipeline: &P, vertex_buffers: V) + -> Result<CheckVertexBuffer, CheckVertexBufferError> + where P: DeviceOwned + VertexSource<V> +{ + let (vertex_buffers, vertex_count, instance_count) = pipeline.decode(vertex_buffers); + + for (num, buf) in vertex_buffers.iter().enumerate() { + assert_eq!(buf.inner().buffer.device().internal_object(), + pipeline.device().internal_object()); + + if !buf.inner().buffer.usage_vertex_buffer() { + return Err(CheckVertexBufferError::BufferMissingUsage { num_buffer: num }); + } + } + + Ok(CheckVertexBuffer { + vertex_buffers, + vertex_count: vertex_count as u32, + instance_count: instance_count as u32, + }) +} + +/// Information returned if `check_vertex_buffer` succeeds. +pub struct CheckVertexBuffer { + /// The list of vertex buffers. + pub vertex_buffers: Vec<Box<BufferAccess + Send + Sync>>, + /// Number of vertices available in the intersection of the buffers. + pub vertex_count: u32, + /// Number of instances available in the intersection of the buffers. + pub instance_count: u32, +} + +/// Error that can happen when checking whether the vertex buffers are valid. +#[derive(Debug, Copy, Clone)] +pub enum CheckVertexBufferError { + /// The "vertex buffer" usage must be enabled on the buffer. + BufferMissingUsage { + /// Index of the buffer that is missing usage. + num_buffer: usize, + }, +} + +impl error::Error for CheckVertexBufferError { + #[inline] + fn description(&self) -> &str { + match *self { + CheckVertexBufferError::BufferMissingUsage { .. } => { + "the vertex buffer usage is missing on a vertex buffer" + }, + } + } +} + +impl fmt::Display for CheckVertexBufferError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor.rs new file mode 100644 index 0000000..adaae6e --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor.rs @@ -0,0 +1,742 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Description of a single descriptor. +//! +//! This module contains traits and structs related to describing a single descriptor. A descriptor +//! is a slot where you can bind a buffer or an image so that it can be accessed from your shaders. +//! In order to specify which buffer or image to bind to a descriptor, see the `descriptor_set` +//! module. +//! +//! There are four different kinds of descriptors that give access to buffers: +//! +//! - Uniform texel buffers. Gives read-only access to the content of a buffer. Only supports +//! certain buffer formats. +//! - Storage texel buffers. Gives read and/or write access to the content of a buffer. Only +//! supports certain buffer formats. Less restrictive but sometimes slower than uniform texel +//! buffers. +//! - Uniform buffers. Gives read-only access to the content of a buffer. Less restrictive but +//! sometimes slower than uniform texel buffers. +//! - Storage buffers. Gives read and/or write access to the content of a buffer. Less restrictive +//! but sometimes slower than uniform buffers and storage texel buffers. +//! +//! There are five different kinds of descriptors related to images: +//! +//! - Storage images. Gives read and/or write access to individual pixels in an image. The image +//! cannot be sampled. In other words, you have exactly specify which pixel to read or write. +//! - Sampled images. Gives read-only access to an image. Before you can use a sampled image in a +//! a shader, you have to combine it with a sampler (see below). The sampler describes how +//! reading the image will behave. +//! - Samplers. Doesn't contain an image but a sampler object that describes how an image will be +//! accessed. This is meant to be combined with a sampled image (see above). +//! - Combined image and sampler. Similar to a sampled image, but also directly includes the +//! sampler which indicates how the sampling is done. +//! - Input attachments. The fastest but also most restrictive access to images. Must be integrated +//! in a render pass. Can only give access to the same pixel as the one you're processing. +//! + +use format::Format; +use image::Dimensions; +use std::cmp; +use std::error; +use std::fmt; +use std::ops::BitOr; +use sync::AccessFlagBits; +use sync::PipelineStages; +use vk; + +/// Contains the exact description of a single descriptor. +/// +/// > **Note**: You are free to fill a `DescriptorDesc` struct the way you want, but its validity +/// > will be checked when you create a pipeline layout, a descriptor set, or when you try to bind +/// > a descriptor set. +// TODO: add example +#[derive(Debug, Clone)] +pub struct DescriptorDesc { + /// Describes the content and layout of each array element of a descriptor. + pub ty: DescriptorDescTy, + + /// How many array elements this descriptor is made of. The value 0 is invalid and may trigger + /// a panic depending on the situation. + pub array_count: u32, + + /// Which shader stages are going to access this descriptor. + pub stages: ShaderStages, + + /// True if the attachment is only ever read by the shader. False if it is also written. + pub readonly: bool, +} + +impl DescriptorDesc { + /// Checks whether we are a superset of another descriptor. + /// + /// Returns true if `self` is the same descriptor as `other`, or if `self` is the same as + /// `other` but with a larger array elements count and/or more shader stages. + // TODO: add example + #[inline] + pub fn is_superset_of(&self, other: &DescriptorDesc) + -> Result<(), DescriptorDescSupersetError> { + self.ty.is_superset_of(&other.ty)?; + self.stages.is_superset_of(&other.stages)?; + + if self.array_count < other.array_count { + return Err(DescriptorDescSupersetError::ArrayTooSmall { + len: self.array_count, + required: other.array_count, + }); + } + + if self.readonly && !other.readonly { + return Err(DescriptorDescSupersetError::MutabilityRequired); + } + + Ok(()) + } + + /// Builds a `DescriptorDesc` that is the union of `self` and `other`, if possible. + /// + /// The returned value will be a superset of both `self` and `other`. + // TODO: Result instead of Option + // TODO: add example + #[inline] + pub fn union(&self, other: &DescriptorDesc) -> Option<DescriptorDesc> { + if self.ty != other.ty { + return None; + } + + Some(DescriptorDesc { + ty: self.ty.clone(), + array_count: cmp::max(self.array_count, other.array_count), + stages: self.stages | other.stages, + readonly: self.readonly && other.readonly, + }) + } + + /// Returns the pipeline stages and access flags corresponding to the usage of this descriptor. + /// + /// # Panic + /// + /// Panics if the type is `Sampler`. + /// + pub fn pipeline_stages_and_access(&self) -> (PipelineStages, AccessFlagBits) { + let stages: PipelineStages = self.stages.into(); + + let access = match self.ty { + DescriptorDescTy::Sampler => panic!(), + DescriptorDescTy::CombinedImageSampler(_) | + DescriptorDescTy::Image(_) => { + AccessFlagBits { + shader_read: true, + shader_write: !self.readonly, + ..AccessFlagBits::none() + } + }, + DescriptorDescTy::TexelBuffer { .. } => { + AccessFlagBits { + shader_read: true, + shader_write: !self.readonly, + ..AccessFlagBits::none() + } + }, + DescriptorDescTy::InputAttachment { .. } => { + AccessFlagBits { + input_attachment_read: true, + ..AccessFlagBits::none() + } + }, + DescriptorDescTy::Buffer(ref buf) => { + if buf.storage { + AccessFlagBits { + shader_read: true, + shader_write: !self.readonly, + ..AccessFlagBits::none() + } + } else { + AccessFlagBits { + uniform_read: true, + ..AccessFlagBits::none() + } + } + }, + }; + + (stages, access) + } +} + +/// Describes the content and layout of each array element of a descriptor. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum DescriptorDescTy { + Sampler, // TODO: the sampler has some restrictions as well + CombinedImageSampler(DescriptorImageDesc), // TODO: the sampler has some restrictions as well + Image(DescriptorImageDesc), + TexelBuffer { + /// If `true`, this describes a storage texel buffer. + storage: bool, + + /// The format of the content, or `None` if the format is unknown. Depending on the + /// context, it may be invalid to have a `None` value here. If the format is `Some`, only + /// buffer views that have this exact format can be attached to this descriptor. + format: Option<Format>, + }, + InputAttachment { + /// If `true`, the input attachment is multisampled. Only multisampled images can be + /// attached to this descriptor. If `false`, only single-sampled images can be attached. + multisampled: bool, + array_layers: DescriptorImageDescArray, + }, + Buffer(DescriptorBufferDesc), +} + +impl DescriptorDescTy { + /// Returns the type of descriptor. + /// + /// Returns `None` if there's not enough info to determine the type. + // TODO: add example + pub fn ty(&self) -> Option<DescriptorType> { + Some(match *self { + DescriptorDescTy::Sampler => DescriptorType::Sampler, + DescriptorDescTy::CombinedImageSampler(_) => DescriptorType::CombinedImageSampler, + DescriptorDescTy::Image(ref desc) => { + if desc.sampled { + DescriptorType::SampledImage + } else { + DescriptorType::StorageImage + } + }, + DescriptorDescTy::InputAttachment { .. } => DescriptorType::InputAttachment, + DescriptorDescTy::Buffer(ref desc) => { + let dynamic = match desc.dynamic { + Some(d) => d, + None => return None, + }; + match (desc.storage, dynamic) { + (false, false) => DescriptorType::UniformBuffer, + (true, false) => DescriptorType::StorageBuffer, + (false, true) => DescriptorType::UniformBufferDynamic, + (true, true) => DescriptorType::StorageBufferDynamic, + } + }, + DescriptorDescTy::TexelBuffer { storage, .. } => { + if storage { + DescriptorType::StorageTexelBuffer + } else { + DescriptorType::UniformTexelBuffer + } + }, + }) + } + + /// Checks whether we are a superset of another descriptor type. + // TODO: add example + #[inline] + pub fn is_superset_of(&self, other: &DescriptorDescTy) + -> Result<(), DescriptorDescSupersetError> { + match (self, other) { + (&DescriptorDescTy::Sampler, &DescriptorDescTy::Sampler) => Ok(()), + + (&DescriptorDescTy::CombinedImageSampler(ref me), + &DescriptorDescTy::CombinedImageSampler(ref other)) => me.is_superset_of(other), + + (&DescriptorDescTy::Image(ref me), &DescriptorDescTy::Image(ref other)) => + me.is_superset_of(other), + + (&DescriptorDescTy::InputAttachment { + multisampled: me_multisampled, + array_layers: me_array_layers, + }, + &DescriptorDescTy::InputAttachment { + multisampled: other_multisampled, + array_layers: other_array_layers, + }) => { + if me_multisampled != other_multisampled { + return Err(DescriptorDescSupersetError::MultisampledMismatch { + provided: me_multisampled, + expected: other_multisampled, + }); + } + + if me_array_layers != other_array_layers { + return Err(DescriptorDescSupersetError::IncompatibleArrayLayers { + provided: me_array_layers, + required: other_array_layers, + }); + } + + Ok(()) + }, + + (&DescriptorDescTy::Buffer(ref me), &DescriptorDescTy::Buffer(ref other)) => { + if me.storage != other.storage { + return Err(DescriptorDescSupersetError::TypeMismatch); + } + + match (me.dynamic, other.dynamic) { + (Some(_), None) => Ok(()), + (Some(m), Some(o)) => if m == o { + Ok(()) + } else { + Err(DescriptorDescSupersetError::TypeMismatch) + }, + (None, None) => Ok(()), + (None, Some(_)) => Err(DescriptorDescSupersetError::TypeMismatch), + } + }, + + (&DescriptorDescTy::TexelBuffer { + storage: me_storage, + format: me_format, + }, + &DescriptorDescTy::TexelBuffer { + storage: other_storage, + format: other_format, + }) => { + if me_storage != other_storage { + return Err(DescriptorDescSupersetError::TypeMismatch); + } + + match (me_format, other_format) { + (Some(_), None) => Ok(()), + (Some(m), Some(o)) => if m == o { + Ok(()) + } else { + Err(DescriptorDescSupersetError::FormatMismatch { + provided: Some(m), + expected: o, + }) + }, + (None, None) => Ok(()), + (None, Some(a)) => Err(DescriptorDescSupersetError::FormatMismatch { + provided: Some(a), + expected: a, + }), + } + }, + + // Any other combination is invalid. + _ => Err(DescriptorDescSupersetError::TypeMismatch), + } + } +} + +/// Additional description for descriptors that contain images. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct DescriptorImageDesc { + /// If `true`, the image can be sampled by the shader. Only images that were created with the + /// `sampled` usage can be attached to the descriptor. + pub sampled: bool, + /// The kind of image: one-dimensional, two-dimensional, three-dimensional, or cube. + pub dimensions: DescriptorImageDescDimensions, + /// The format of the image, or `None` if the format is unknown. If `Some`, only images with + /// exactly that format can be attached. + pub format: Option<Format>, + /// True if the image is multisampled. + pub multisampled: bool, + /// Whether the descriptor contains one or more array layers of an image. + pub array_layers: DescriptorImageDescArray, +} + +impl DescriptorImageDesc { + /// Checks whether we are a superset of another image. + // TODO: add example + #[inline] + pub fn is_superset_of(&self, other: &DescriptorImageDesc) + -> Result<(), DescriptorDescSupersetError> { + if self.dimensions != other.dimensions { + return Err(DescriptorDescSupersetError::DimensionsMismatch { + provided: self.dimensions, + expected: other.dimensions, + }); + } + + if self.multisampled != other.multisampled { + return Err(DescriptorDescSupersetError::MultisampledMismatch { + provided: self.multisampled, + expected: other.multisampled, + }); + } + + match (self.format, other.format) { + (Some(a), Some(b)) => if a != b { + return Err(DescriptorDescSupersetError::FormatMismatch { + provided: Some(a), + expected: b, + }); + }, + (Some(_), None) => (), + (None, None) => (), + (None, Some(a)) => { + return Err(DescriptorDescSupersetError::FormatMismatch { + provided: None, + expected: a, + }); + }, + }; + + match (self.array_layers, other.array_layers) { + (DescriptorImageDescArray::NonArrayed, DescriptorImageDescArray::NonArrayed) => (), + (DescriptorImageDescArray::Arrayed { max_layers: my_max }, + DescriptorImageDescArray::Arrayed { max_layers: other_max }) => { + match (my_max, other_max) { + (Some(m), Some(o)) => if m < o { + return Err(DescriptorDescSupersetError::IncompatibleArrayLayers { + provided: DescriptorImageDescArray::Arrayed { + max_layers: my_max, + }, + required: DescriptorImageDescArray::Arrayed { + max_layers: other_max, + }, + }); + }, + (Some(_), None) => (), + (None, Some(m)) => { + return Err(DescriptorDescSupersetError::IncompatibleArrayLayers { + provided: DescriptorImageDescArray::Arrayed { + max_layers: my_max, + }, + required: DescriptorImageDescArray::Arrayed { + max_layers: other_max, + }, + }); + }, + (None, None) => (), // TODO: is this correct? + }; + }, + (a, b) => return Err(DescriptorDescSupersetError::IncompatibleArrayLayers { + provided: a, + required: b, + }), + }; + + Ok(()) + } +} + +// TODO: documentation +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum DescriptorImageDescArray { + NonArrayed, + Arrayed { max_layers: Option<u32> }, +} + +// TODO: documentation +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum DescriptorImageDescDimensions { + OneDimensional, + TwoDimensional, + ThreeDimensional, + Cube, +} + +impl DescriptorImageDescDimensions { + /// Builds the `DescriptorImageDescDimensions` that corresponds to actual dimensions. + #[inline] + pub fn from_dimensions(dims: Dimensions) -> DescriptorImageDescDimensions { + match dims { + Dimensions::Dim1d { .. } => DescriptorImageDescDimensions::OneDimensional, + Dimensions::Dim1dArray { .. } => DescriptorImageDescDimensions::OneDimensional, + Dimensions::Dim2d { .. } => DescriptorImageDescDimensions::TwoDimensional, + Dimensions::Dim2dArray { .. } => DescriptorImageDescDimensions::TwoDimensional, + Dimensions::Dim3d { .. } => DescriptorImageDescDimensions::ThreeDimensional, + Dimensions::Cubemap { .. } => DescriptorImageDescDimensions::Cube, + Dimensions::CubemapArray { .. } => DescriptorImageDescDimensions::Cube, + } + } +} + +// TODO: documentation +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct DescriptorBufferDesc { + pub dynamic: Option<bool>, + pub storage: bool, +} + +/// Describes what kind of resource may later be bound to a descriptor. +/// +/// This is mostly the same as a `DescriptorDescTy` but with less precise information. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[repr(u32)] +pub enum DescriptorType { + Sampler = vk::DESCRIPTOR_TYPE_SAMPLER, + CombinedImageSampler = vk::DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + SampledImage = vk::DESCRIPTOR_TYPE_SAMPLED_IMAGE, + StorageImage = vk::DESCRIPTOR_TYPE_STORAGE_IMAGE, + UniformTexelBuffer = vk::DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, + StorageTexelBuffer = vk::DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, + UniformBuffer = vk::DESCRIPTOR_TYPE_UNIFORM_BUFFER, + StorageBuffer = vk::DESCRIPTOR_TYPE_STORAGE_BUFFER, + UniformBufferDynamic = vk::DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, + StorageBufferDynamic = vk::DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, + InputAttachment = vk::DESCRIPTOR_TYPE_INPUT_ATTACHMENT, +} + +/// Error when checking whether a descriptor is a superset of another one. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum DescriptorDescSupersetError { + /// The number of array elements of the descriptor is smaller than expected. + ArrayTooSmall { len: u32, required: u32 }, + + /// The descriptor type doesn't match the type of the other descriptor. + TypeMismatch, + + /// The descriptor is marked as read-only, but the other is not. + MutabilityRequired, + + /// The shader stages are not a superset of one another. + ShaderStagesNotSuperset, + + DimensionsMismatch { + provided: DescriptorImageDescDimensions, + expected: DescriptorImageDescDimensions, + }, + + FormatMismatch { + provided: Option<Format>, + expected: Format, + }, + + MultisampledMismatch { provided: bool, expected: bool }, + + IncompatibleArrayLayers { + provided: DescriptorImageDescArray, + required: DescriptorImageDescArray, + }, +} + +impl error::Error for DescriptorDescSupersetError { + #[inline] + fn description(&self) -> &str { + match *self { + DescriptorDescSupersetError::ArrayTooSmall { .. } => { + "the number of array elements of the descriptor is smaller than expected" + }, + DescriptorDescSupersetError::TypeMismatch => { + "the descriptor type doesn't match the type of the other descriptor" + }, + DescriptorDescSupersetError::MutabilityRequired => { + "the descriptor is marked as read-only, but the other is not" + }, + DescriptorDescSupersetError::ShaderStagesNotSuperset => { + "the shader stages are not a superset of one another" + }, + DescriptorDescSupersetError::DimensionsMismatch { .. } => { + "mismatch between the dimensions of the two descriptors" + }, + DescriptorDescSupersetError::FormatMismatch { .. } => { + "mismatch between the format of the two descriptors" + }, + DescriptorDescSupersetError::MultisampledMismatch { .. } => { + "mismatch between whether the descriptors are multisampled" + }, + DescriptorDescSupersetError::IncompatibleArrayLayers { .. } => { + "the array layers of the descriptors aren't compatible" + }, + } + } +} + +impl fmt::Display for DescriptorDescSupersetError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<ShaderStagesSupersetError> for DescriptorDescSupersetError { + #[inline] + fn from(err: ShaderStagesSupersetError) -> DescriptorDescSupersetError { + match err { + ShaderStagesSupersetError::NotSuperset => { + DescriptorDescSupersetError::ShaderStagesNotSuperset + }, + } + } +} + +/// Describes which shader stages have access to a descriptor. +// TODO: add example with BitOr +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct ShaderStages { + /// `True` means that the descriptor will be used by the vertex shader. + pub vertex: bool, + /// `True` means that the descriptor will be used by the tessellation control shader. + pub tessellation_control: bool, + /// `True` means that the descriptor will be used by the tessellation evaluation shader. + pub tessellation_evaluation: bool, + /// `True` means that the descriptor will be used by the geometry shader. + pub geometry: bool, + /// `True` means that the descriptor will be used by the fragment shader. + pub fragment: bool, + /// `True` means that the descriptor will be used by the compute shader. + pub compute: bool, +} + +impl ShaderStages { + /// Creates a `ShaderStages` struct will all stages set to `true`. + // TODO: add example + #[inline] + pub fn all() -> ShaderStages { + ShaderStages { + vertex: true, + tessellation_control: true, + tessellation_evaluation: true, + geometry: true, + fragment: true, + compute: true, + } + } + + /// Creates a `ShaderStages` struct will all stages set to `false`. + // TODO: add example + #[inline] + pub fn none() -> ShaderStages { + ShaderStages { + vertex: false, + tessellation_control: false, + tessellation_evaluation: false, + geometry: false, + fragment: false, + compute: false, + } + } + + /// Creates a `ShaderStages` struct with all graphics stages set to `true`. + // TODO: add example + #[inline] + pub fn all_graphics() -> ShaderStages { + ShaderStages { + vertex: true, + tessellation_control: true, + tessellation_evaluation: true, + geometry: true, + fragment: true, + compute: false, + } + } + + /// Creates a `ShaderStages` struct with the compute stage set to `true`. + // TODO: add example + #[inline] + pub fn compute() -> ShaderStages { + ShaderStages { + vertex: false, + tessellation_control: false, + tessellation_evaluation: false, + geometry: false, + fragment: false, + compute: true, + } + } + + /// Checks whether we have more stages enabled than `other`. + // TODO: add example + #[inline] + pub fn is_superset_of(&self, other: &ShaderStages) -> Result<(), ShaderStagesSupersetError> { + if (self.vertex || !other.vertex) && + (self.tessellation_control || !other.tessellation_control) && + (self.tessellation_evaluation || !other.tessellation_evaluation) && + (self.geometry || !other.geometry) && + (self.fragment || !other.fragment) && (self.compute || !other.compute) + { + Ok(()) + } else { + Err(ShaderStagesSupersetError::NotSuperset) + } + } + + /// Checks whether any of the stages in `self` are also present in `other`. + // TODO: add example + #[inline] + pub fn intersects(&self, other: &ShaderStages) -> bool { + (self.vertex && other.vertex) || + (self.tessellation_control && other.tessellation_control) || + (self.tessellation_evaluation && other.tessellation_evaluation) || + (self.geometry && other.geometry) || (self.fragment && other.fragment) || + (self.compute && other.compute) + } + + #[inline] + pub(crate) fn into_vulkan_bits(self) -> vk::ShaderStageFlags { + let mut result = 0; + if self.vertex { + result |= vk::SHADER_STAGE_VERTEX_BIT; + } + if self.tessellation_control { + result |= vk::SHADER_STAGE_TESSELLATION_CONTROL_BIT; + } + if self.tessellation_evaluation { + result |= vk::SHADER_STAGE_TESSELLATION_EVALUATION_BIT; + } + if self.geometry { + result |= vk::SHADER_STAGE_GEOMETRY_BIT; + } + if self.fragment { + result |= vk::SHADER_STAGE_FRAGMENT_BIT; + } + if self.compute { + result |= vk::SHADER_STAGE_COMPUTE_BIT; + } + result + } +} + +impl BitOr for ShaderStages { + type Output = ShaderStages; + + #[inline] + fn bitor(self, other: ShaderStages) -> ShaderStages { + ShaderStages { + vertex: self.vertex || other.vertex, + tessellation_control: self.tessellation_control || other.tessellation_control, + tessellation_evaluation: self.tessellation_evaluation || other.tessellation_evaluation, + geometry: self.geometry || other.geometry, + fragment: self.fragment || other.fragment, + compute: self.compute || other.compute, + } + } +} + +impl From<ShaderStages> for PipelineStages { + #[inline] + fn from(stages: ShaderStages) -> PipelineStages { + PipelineStages { + vertex_shader: stages.vertex, + tessellation_control_shader: stages.tessellation_control, + tessellation_evaluation_shader: stages.tessellation_evaluation, + geometry_shader: stages.geometry, + fragment_shader: stages.fragment, + compute_shader: stages.compute, + ..PipelineStages::none() + } + } +} + +/// Error when checking whether some shader stages are superset of others. +#[derive(Debug, Clone)] +pub enum ShaderStagesSupersetError { + NotSuperset, +} + +impl error::Error for ShaderStagesSupersetError { + #[inline] + fn description(&self) -> &str { + match *self { + ShaderStagesSupersetError::NotSuperset => { + "shader stages not a superset" + }, + } + } +} + +impl fmt::Display for ShaderStagesSupersetError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/collection.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/collection.rs new file mode 100644 index 0000000..3d23a57 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/collection.rs @@ -0,0 +1,189 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use descriptor::descriptor::DescriptorDesc; +use descriptor::descriptor_set::DescriptorSet; +use descriptor::descriptor_set::DescriptorSetDesc; + +/// A collection of descriptor set objects. +pub unsafe trait DescriptorSetsCollection { + fn into_vec(self) -> Vec<Box<DescriptorSet + Send + Sync>>; + + /// Returns the number of descriptors in the set. Includes possibly empty descriptors. + /// + /// Returns `None` if the set is out of range. + // TODO: remove ; user should just use `into_vec` instead + fn num_bindings_in_set(&self, set: usize) -> Option<usize>; + + /// Returns the descriptor for the given binding of the given set. + /// + /// Returns `None` if out of range. + // TODO: remove ; user should just use `into_vec` instead + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc>; +} + +unsafe impl DescriptorSetsCollection for () { + #[inline] + fn into_vec(self) -> Vec<Box<DescriptorSet + Send + Sync>> { + vec![] + } + + #[inline] + fn num_bindings_in_set(&self, _: usize) -> Option<usize> { + None + } + + #[inline] + fn descriptor(&self, _: usize, _: usize) -> Option<DescriptorDesc> { + None + } +} + +unsafe impl<T> DescriptorSetsCollection for T + where T: DescriptorSet + Send + Sync + 'static +{ + #[inline] + fn into_vec(self) -> Vec<Box<DescriptorSet + Send + Sync>> { + vec![Box::new(self) as Box<_>] + } + + #[inline] + fn num_bindings_in_set(&self, set: usize) -> Option<usize> { + match set { + 0 => Some(self.num_bindings()), + _ => None, + } + } + + #[inline] + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> { + match set { + 0 => self.descriptor(binding), + _ => None, + } + } +} + +unsafe impl<T> DescriptorSetsCollection for Vec<T> + where T: DescriptorSet + Send + Sync + 'static +{ + #[inline] + fn into_vec(self) -> Vec<Box<DescriptorSet + Send + Sync>> { + let mut v = Vec::new(); + for o in self { + v.push(Box::new(o) as Box<_>); + } + return v; + } + + #[inline] + fn num_bindings_in_set(&self, set: usize) -> Option<usize> { + self.get(set).map(|x| x.num_bindings()) + } + #[inline] + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> { + self.get(set).and_then(|x| x.descriptor(binding)) + } +} + +macro_rules! impl_collection { + ($first:ident $(, $others:ident)+) => ( + unsafe impl<$first$(, $others)+> DescriptorSetsCollection for ($first, $($others),+) + where $first: DescriptorSet + DescriptorSetDesc + Send + Sync + 'static + $(, $others: DescriptorSet + DescriptorSetDesc + Send + Sync + 'static)* + { + #[inline] + fn into_vec(self) -> Vec<Box<DescriptorSet + Send + Sync>> { + #![allow(non_snake_case)] + + let ($first, $($others,)*) = self; + + let mut list = Vec::new(); + list.push(Box::new($first) as Box<_>); + $( + list.push(Box::new($others) as Box<_>); + )+ + list + } + + #[inline] + fn num_bindings_in_set(&self, mut set: usize) -> Option<usize> { + #![allow(non_snake_case)] + #![allow(unused_mut)] // For the `set` parameter. + + if set == 0 { + return Some(self.0.num_bindings()); + } + + let &(_, $(ref $others,)*) = self; + + $( + set -= 1; + if set == 0 { + return Some($others.num_bindings()); + } + )* + + None + } + + #[inline] + fn descriptor(&self, mut set: usize, binding: usize) -> Option<DescriptorDesc> { + #![allow(non_snake_case)] + #![allow(unused_mut)] // For the `set` parameter. + + if set == 0 { + return self.0.descriptor(binding); + } + + let &(_, $(ref $others,)*) = self; + + $( + set -= 1; + if set == 0 { + return $others.descriptor(binding); + } + )* + + None + } + } + + impl_collection!($($others),+); + ); + + ($i:ident) => (); +} + +impl_collection!(Z, + Y, + X, + W, + V, + U, + T, + S, + R, + Q, + P, + O, + N, + M, + L, + K, + J, + I, + H, + G, + F, + E, + D, + C, + B, + A); diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/fixed_size_pool.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/fixed_size_pool.rs new file mode 100644 index 0000000..656a38a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/fixed_size_pool.rs @@ -0,0 +1,560 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use crossbeam::queue::SegQueue; +use std::sync::Arc; + +use OomError; +use buffer::BufferAccess; +use buffer::BufferViewRef; +use descriptor::descriptor::DescriptorDesc; +use descriptor::descriptor_set::DescriptorPool; +use descriptor::descriptor_set::DescriptorPoolAlloc; +use descriptor::descriptor_set::DescriptorPoolAllocError; +use descriptor::descriptor_set::DescriptorSet; +use descriptor::descriptor_set::DescriptorSetDesc; +use descriptor::descriptor_set::UnsafeDescriptorPool; +use descriptor::descriptor_set::UnsafeDescriptorSet; +use descriptor::descriptor_set::UnsafeDescriptorSetLayout; +use descriptor::descriptor_set::persistent::*; +use descriptor::pipeline_layout::PipelineLayoutAbstract; +use device::Device; +use device::DeviceOwned; +use image::ImageViewAccess; +use sampler::Sampler; + +/// Pool of descriptor sets of a specific capacity and that are automatically reclaimed. +/// +/// You are encouraged to use this type when you need a different descriptor set at each frame, or +/// regularly during the execution. +/// +/// # Example +/// +/// At initialization, create a `FixedSizeDescriptorSetsPool`. The first parameter of the `new` +/// function can be a graphics pipeline, a compute pipeline, or anything that represents a pipeline +/// layout. +/// +/// ```rust +/// use vulkano::descriptor::descriptor_set::FixedSizeDescriptorSetsPool; +/// # use vulkano::pipeline::GraphicsPipelineAbstract; +/// # use std::sync::Arc; +/// # let graphics_pipeline: Arc<GraphicsPipelineAbstract> = return; +/// // use vulkano::pipeline::GraphicsPipelineAbstract; +/// // let graphics_pipeline: Arc<GraphicsPipelineAbstract> = ...; +/// +/// let pool = FixedSizeDescriptorSetsPool::new(graphics_pipeline.clone(), 0); +/// ``` +/// +/// You would then typically store the pool in a struct for later. Its type is +/// `FixedSizeDescriptorSetsPool<T>` where `T` is the type of what was passed to `new()`. In the +/// example above, it would be `FixedSizeDescriptorSetsPool<Arc<GraphicsPipelineAbstract>>`. +/// +/// Then whenever you need a descriptor set, call `pool.next()` to start the process of building +/// it. +/// +/// ```rust +/// # use std::sync::Arc; +/// # use vulkano::descriptor::descriptor_set::FixedSizeDescriptorSetsPool; +/// # use vulkano::pipeline::GraphicsPipelineAbstract; +/// # let mut pool: FixedSizeDescriptorSetsPool<Arc<GraphicsPipelineAbstract>> = return; +/// let descriptor_set = pool.next() +/// //.add_buffer(...) +/// //.add_sampled_image(...) +/// .build().unwrap(); +/// ``` +/// +/// Note that `next()` requires exclusive (`mut`) access to the pool. You can use a `Mutex` around +/// the pool if you can't provide this. +/// +#[derive(Clone)] +pub struct FixedSizeDescriptorSetsPool<L> { + pipeline_layout: L, + set_id: usize, + set_layout: Arc<UnsafeDescriptorSetLayout>, + // We hold a local implementation of the `DescriptorPool` trait for our own purpose. Since we + // don't want to expose this trait impl in our API, we use a separate struct. + pool: LocalPool, +} + +impl<L> FixedSizeDescriptorSetsPool<L> { + /// Initializes a new pool. The pool is configured to allocate sets that corresponds to the + /// parameters passed to this function. + pub fn new(layout: L, set_id: usize) -> FixedSizeDescriptorSetsPool<L> + where L: PipelineLayoutAbstract + { + assert!(layout.num_sets() > set_id); + + let device = layout.device().clone(); + + let set_layout = layout + .descriptor_set_layout(set_id) + .expect("Unable to get the descriptor set layout") + .clone(); + + FixedSizeDescriptorSetsPool { + pipeline_layout: layout, + set_id, + set_layout, + pool: LocalPool { + device: device, + next_capacity: 3, + current_pool: None, + }, + } + } + + /// Starts the process of building a new descriptor set. + /// + /// The set will corresponds to the set layout that was passed to `new`. + #[inline] + pub fn next(&mut self) -> FixedSizeDescriptorSetBuilder<L, ()> + where L: PipelineLayoutAbstract + Clone + { + let inner = PersistentDescriptorSet::start(self.pipeline_layout.clone(), self.set_id); + + FixedSizeDescriptorSetBuilder { + pool: self, + inner: inner, + } + } +} + +/// A descriptor set created from a `FixedSizeDescriptorSetsPool`. +pub struct FixedSizeDescriptorSet<L, R> { + inner: PersistentDescriptorSet<L, R, LocalPoolAlloc>, +} + +unsafe impl<L, R> DescriptorSet for FixedSizeDescriptorSet<L, R> + where L: PipelineLayoutAbstract, + R: PersistentDescriptorSetResources +{ + #[inline] + fn inner(&self) -> &UnsafeDescriptorSet { + self.inner.inner() + } + + #[inline] + fn num_buffers(&self) -> usize { + self.inner.num_buffers() + } + + #[inline] + fn buffer(&self, index: usize) -> Option<(&BufferAccess, u32)> { + self.inner.buffer(index) + } + + #[inline] + fn num_images(&self) -> usize { + self.inner.num_images() + } + + #[inline] + fn image(&self, index: usize) -> Option<(&ImageViewAccess, u32)> { + self.inner.image(index) + } +} + +unsafe impl<L, R> DescriptorSetDesc for FixedSizeDescriptorSet<L, R> + where L: PipelineLayoutAbstract +{ + #[inline] + fn num_bindings(&self) -> usize { + self.inner.num_bindings() + } + + #[inline] + fn descriptor(&self, binding: usize) -> Option<DescriptorDesc> { + self.inner.descriptor(binding) + } +} + +unsafe impl<L, R> DeviceOwned for FixedSizeDescriptorSet<L, R> + where L: DeviceOwned +{ + #[inline] + fn device(&self) -> &Arc<Device> { + self.inner.device() + } +} + +// The fields of this struct can be considered as fields of the `FixedSizeDescriptorSet`. They are +// in a separate struct because we don't want to expose the fact that we implement the +// `DescriptorPool` trait. +#[derive(Clone)] +struct LocalPool { + // The `LocalPoolInner` struct contains an actual Vulkan pool. Every time it is full, we create + // a new pool and replace the current one with the new one. + current_pool: Option<Arc<LocalPoolInner>>, + // Capacity to use when we create a new Vulkan pool. + next_capacity: u32, + // The Vulkan device. + device: Arc<Device>, +} + +struct LocalPoolInner { + // The actual Vulkan descriptor pool. This field isn't actually used anywhere, but we need to + // keep the pool alive in order to keep the descriptor sets valid. + actual_pool: UnsafeDescriptorPool, + + // List of descriptor sets. When `alloc` is called, a descriptor will be extracted from this + // list. When a `LocalPoolAlloc` is dropped, its descriptor set is put back in this list. + reserve: SegQueue<UnsafeDescriptorSet>, +} + +struct LocalPoolAlloc { + // The `LocalPoolInner` we were allocated from. We need to keep a copy of it in each allocation + // so that we can put back the allocation in the list in our `Drop` impl. + pool: Arc<LocalPoolInner>, + + // The actual descriptor set, wrapped inside an `Option` so that we can extract it in our + // `Drop` impl. + actual_alloc: Option<UnsafeDescriptorSet>, +} + +unsafe impl DescriptorPool for LocalPool { + type Alloc = LocalPoolAlloc; + + fn alloc(&mut self, layout: &UnsafeDescriptorSetLayout) -> Result<Self::Alloc, OomError> { + loop { + // Try to extract a descriptor from the current pool if any exist. + // This is the most common case. + if let Some(ref mut current_pool) = self.current_pool { + if let Some(already_existing_set) = current_pool.reserve.try_pop() { + return Ok(LocalPoolAlloc { + actual_alloc: Some(already_existing_set), + pool: current_pool.clone(), + }); + } + } + + // If we failed to grab an existing set, that means the current pool is full. Create a + // new one of larger capacity. + let count = *layout.descriptors_count() * self.next_capacity; + let mut new_pool = + UnsafeDescriptorPool::new(self.device.clone(), &count, self.next_capacity, false)?; + let alloc = unsafe { + match new_pool.alloc((0 .. self.next_capacity).map(|_| layout)) { + Ok(iter) => { + let stack = SegQueue::new(); + for elem in iter { + stack.push(elem); + } + stack + }, + Err(DescriptorPoolAllocError::OutOfHostMemory) => { + return Err(OomError::OutOfHostMemory); + }, + Err(DescriptorPoolAllocError::OutOfDeviceMemory) => { + return Err(OomError::OutOfDeviceMemory); + }, + Err(DescriptorPoolAllocError::FragmentedPool) => { + // This can't happen as we don't free individual sets. + unreachable!() + }, + Err(DescriptorPoolAllocError::OutOfPoolMemory) => { + unreachable!() + }, + } + }; + + self.next_capacity = self.next_capacity.saturating_mul(2); + self.current_pool = Some(Arc::new(LocalPoolInner { + actual_pool: new_pool, + reserve: alloc, + })); + } + } +} + +unsafe impl DeviceOwned for LocalPool { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl DescriptorPoolAlloc for LocalPoolAlloc { + #[inline] + fn inner(&self) -> &UnsafeDescriptorSet { + self.actual_alloc.as_ref().unwrap() + } + + #[inline] + fn inner_mut(&mut self) -> &mut UnsafeDescriptorSet { + self.actual_alloc.as_mut().unwrap() + } +} + +impl Drop for LocalPoolAlloc { + fn drop(&mut self) { + let inner = self.actual_alloc.take().unwrap(); + self.pool.reserve.push(inner); + } +} + +/// Prototype of a `FixedSizeDescriptorSet`. +/// +/// The template parameter `L` is the pipeline layout to use, and the template parameter `R` is +/// an unspecified type that represents the list of resources. +/// +/// See the docs of `FixedSizeDescriptorSetsPool` for an example. +pub struct FixedSizeDescriptorSetBuilder<'a, L: 'a, R> { + pool: &'a mut FixedSizeDescriptorSetsPool<L>, + inner: PersistentDescriptorSetBuilder<L, R>, +} + +impl<'a, L, R> FixedSizeDescriptorSetBuilder<'a, L, R> + where L: PipelineLayoutAbstract +{ + /// Builds a `FixedSizeDescriptorSet` from the builder. + #[inline] + pub fn build(self) -> Result<FixedSizeDescriptorSet<L, R>, PersistentDescriptorSetBuildError> { + let inner = self.inner.build_with_pool(&mut self.pool.pool)?; + Ok(FixedSizeDescriptorSet { inner: inner }) + } + + /// Call this function if the next element of the set is an array in order to set the value of + /// each element. + /// + /// Returns an error if the descriptor is empty. + /// + /// This function can be called even if the descriptor isn't an array, and it is valid to enter + /// the "array", add one element, then leave. + #[inline] + pub fn enter_array( + self) + -> Result<FixedSizeDescriptorSetBuilderArray<'a, L, R>, PersistentDescriptorSetError> { + Ok(FixedSizeDescriptorSetBuilderArray { + pool: self.pool, + inner: self.inner.enter_array()?, + }) + } + + /// Skips the current descriptor if it is empty. + #[inline] + pub fn add_empty( + self) + -> Result<FixedSizeDescriptorSetBuilder<'a, L, R>, PersistentDescriptorSetError> { + Ok(FixedSizeDescriptorSetBuilder { + pool: self.pool, + inner: self.inner.add_empty()?, + }) + } + + /// Binds a buffer as the next descriptor. + /// + /// An error is returned if the buffer isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the buffer doesn't have the same device as the pipeline layout. + /// + #[inline] + pub fn add_buffer<T>(self, buffer: T) + -> Result<FixedSizeDescriptorSetBuilder<'a, + L, + (R, + PersistentDescriptorSetBuf<T>)>, + PersistentDescriptorSetError> + where T: BufferAccess + { + Ok(FixedSizeDescriptorSetBuilder { + pool: self.pool, + inner: self.inner.add_buffer(buffer)?, + }) + } + + /// Binds a buffer view as the next descriptor. + /// + /// An error is returned if the buffer isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the buffer view doesn't have the same device as the pipeline layout. + /// + pub fn add_buffer_view<T>(self, view: T) + -> Result<FixedSizeDescriptorSetBuilder<'a, L, (R, PersistentDescriptorSetBufView<T>)>, PersistentDescriptorSetError> + where T: BufferViewRef + { + Ok(FixedSizeDescriptorSetBuilder { + pool: self.pool, + inner: self.inner.add_buffer_view(view)?, + }) + } + + /// Binds an image view as the next descriptor. + /// + /// An error is returned if the image view isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the image view doesn't have the same device as the pipeline layout. + /// + #[inline] + pub fn add_image<T>(self, image_view: T) + -> Result<FixedSizeDescriptorSetBuilder<'a, + L, + (R, PersistentDescriptorSetImg<T>)>, + PersistentDescriptorSetError> + where T: ImageViewAccess + { + Ok(FixedSizeDescriptorSetBuilder { + pool: self.pool, + inner: self.inner.add_image(image_view)?, + }) + } + + /// Binds an image view with a sampler as the next descriptor. + /// + /// An error is returned if the image view isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the image view or the sampler doesn't have the same device as the pipeline layout. + /// + #[inline] + pub fn add_sampled_image<T>(self, image_view: T, sampler: Arc<Sampler>) + -> Result<FixedSizeDescriptorSetBuilder<'a, L, ((R, PersistentDescriptorSetImg<T>), PersistentDescriptorSetSampler)>, PersistentDescriptorSetError> + where T: ImageViewAccess + { + Ok(FixedSizeDescriptorSetBuilder { + pool: self.pool, + inner: self.inner.add_sampled_image(image_view, sampler)?, + }) + } + + /// Binds a sampler as the next descriptor. + /// + /// An error is returned if the sampler isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the sampler doesn't have the same device as the pipeline layout. + /// + #[inline] + pub fn add_sampler(self, sampler: Arc<Sampler>) + -> Result<FixedSizeDescriptorSetBuilder<'a, + L, + (R, PersistentDescriptorSetSampler)>, + PersistentDescriptorSetError> { + Ok(FixedSizeDescriptorSetBuilder { + pool: self.pool, + inner: self.inner.add_sampler(sampler)?, + }) + } +} + +/// Same as `FixedSizeDescriptorSetBuilder`, but we're in an array. +pub struct FixedSizeDescriptorSetBuilderArray<'a, L: 'a, R> { + pool: &'a mut FixedSizeDescriptorSetsPool<L>, + inner: PersistentDescriptorSetBuilderArray<L, R>, +} + +impl<'a, L, R> FixedSizeDescriptorSetBuilderArray<'a, L, R> + where L: PipelineLayoutAbstract +{ + /// Leaves the array. Call this once you added all the elements of the array. + pub fn leave_array( + self) + -> Result<FixedSizeDescriptorSetBuilder<'a, L, R>, PersistentDescriptorSetError> { + Ok(FixedSizeDescriptorSetBuilder { + pool: self.pool, + inner: self.inner.leave_array()?, + }) + } + + /// Binds a buffer as the next element in the array. + /// + /// An error is returned if the buffer isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the buffer doesn't have the same device as the pipeline layout. + /// + pub fn add_buffer<T>(self, buffer: T) + -> Result<FixedSizeDescriptorSetBuilderArray<'a, L, (R, PersistentDescriptorSetBuf<T>)>, PersistentDescriptorSetError> + where T: BufferAccess + { + Ok(FixedSizeDescriptorSetBuilderArray { + pool: self.pool, + inner: self.inner.add_buffer(buffer)?, + }) + } + + /// Binds a buffer view as the next element in the array. + /// + /// An error is returned if the buffer isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the buffer view doesn't have the same device as the pipeline layout. + /// + pub fn add_buffer_view<T>(self, view: T) + -> Result<FixedSizeDescriptorSetBuilderArray<'a, L, (R, PersistentDescriptorSetBufView<T>)>, PersistentDescriptorSetError> + where T: BufferViewRef + { + Ok(FixedSizeDescriptorSetBuilderArray { + pool: self.pool, + inner: self.inner.add_buffer_view(view)?, + }) + } + + /// Binds an image view as the next element in the array. + /// + /// An error is returned if the image view isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the image view doesn't have the same device as the pipeline layout. + /// + pub fn add_image<T>(self, image_view: T) + -> Result<FixedSizeDescriptorSetBuilderArray<'a, L, (R, PersistentDescriptorSetImg<T>)>, PersistentDescriptorSetError> + where T: ImageViewAccess + { + Ok(FixedSizeDescriptorSetBuilderArray { + pool: self.pool, + inner: self.inner.add_image(image_view)?, + }) + } + + /// Binds an image view with a sampler as the next element in the array. + /// + /// An error is returned if the image view isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the image or the sampler doesn't have the same device as the pipeline layout. + /// + pub fn add_sampled_image<T>(self, image_view: T, sampler: Arc<Sampler>) + -> Result<FixedSizeDescriptorSetBuilderArray<'a, L, ((R, PersistentDescriptorSetImg<T>), PersistentDescriptorSetSampler)>, PersistentDescriptorSetError> + where T: ImageViewAccess + { + Ok(FixedSizeDescriptorSetBuilderArray { + pool: self.pool, + inner: self.inner.add_sampled_image(image_view, sampler)?, + }) + } + + /// Binds a sampler as the next element in the array. + /// + /// An error is returned if the sampler isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the sampler doesn't have the same device as the pipeline layout. + /// + pub fn add_sampler(self, sampler: Arc<Sampler>) + -> Result<FixedSizeDescriptorSetBuilderArray<'a, L, (R, PersistentDescriptorSetSampler)>, PersistentDescriptorSetError> + { + Ok(FixedSizeDescriptorSetBuilderArray { + pool: self.pool, + inner: self.inner.add_sampler(sampler)?, + }) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/mod.rs new file mode 100644 index 0000000..95ac51d --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/mod.rs @@ -0,0 +1,155 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Descriptor sets creation and management +//! +//! This module is dedicated to managing descriptor sets. There are three concepts in Vulkan +//! related to descriptor sets: +//! +//! - A `DescriptorSetLayout` is a Vulkan object that describes to the Vulkan implementation the +//! layout of a future descriptor set. When you allocate a descriptor set, you have to pass an +//! instance of this object. This is represented with the `UnsafeDescriptorSetLayout` type in +//! vulkano. +//! - A `DescriptorPool` is a Vulkan object that holds the memory of descriptor sets and that can +//! be used to allocate and free individual descriptor sets. This is represented with the +//! `UnsafeDescriptorPool` type in vulkano. +//! - A `DescriptorSet` contains the bindings to resources and is allocated from a pool. This is +//! represented with the `UnsafeDescriptorSet` type in vulkano. +//! +//! In addition to this, vulkano defines the following: +//! +//! - The `DescriptorPool` trait can be implemented on types from which you can allocate and free +//! descriptor sets. However it is different from Vulkan descriptor pools in the sense that an +//! implementation of the `DescriptorPool` trait can manage multiple Vulkan descriptor pools. +//! - The `StdDescriptorPool` type is a default implementation of the `DescriptorPool` trait. +//! - The `DescriptorSet` trait is implemented on types that wrap around Vulkan descriptor sets in +//! a safe way. A Vulkan descriptor set is inherently unsafe, so we need safe wrappers around +//! them. +//! - The `SimpleDescriptorSet` type is a default implementation of the `DescriptorSet` trait. +//! - The `DescriptorSetsCollection` trait is implemented on collections of types that implement +//! `DescriptorSet`. It is what you pass to the draw functions. + +use SafeDeref; +use buffer::BufferAccess; +use descriptor::descriptor::DescriptorDesc; +use image::ImageViewAccess; + +pub use self::collection::DescriptorSetsCollection; +pub use self::fixed_size_pool::FixedSizeDescriptorSet; +pub use self::fixed_size_pool::FixedSizeDescriptorSetBuilder; +pub use self::fixed_size_pool::FixedSizeDescriptorSetBuilderArray; +pub use self::fixed_size_pool::FixedSizeDescriptorSetsPool; +pub use self::persistent::PersistentDescriptorSet; +pub use self::persistent::PersistentDescriptorSetBuf; +pub use self::persistent::PersistentDescriptorSetBufView; +pub use self::persistent::PersistentDescriptorSetBuildError; +pub use self::persistent::PersistentDescriptorSetBuilder; +pub use self::persistent::PersistentDescriptorSetBuilderArray; +pub use self::persistent::PersistentDescriptorSetError; +pub use self::persistent::PersistentDescriptorSetImg; +pub use self::persistent::PersistentDescriptorSetSampler; +pub use self::std_pool::StdDescriptorPool; +pub use self::std_pool::StdDescriptorPoolAlloc; +pub use self::sys::DescriptorPool; +pub use self::sys::DescriptorPoolAlloc; +pub use self::sys::DescriptorPoolAllocError; +pub use self::sys::DescriptorWrite; +pub use self::sys::DescriptorsCount; +pub use self::sys::UnsafeDescriptorPool; +pub use self::sys::UnsafeDescriptorPoolAllocIter; +pub use self::sys::UnsafeDescriptorSet; +pub use self::unsafe_layout::UnsafeDescriptorSetLayout; + +pub mod collection; + +mod fixed_size_pool; +mod persistent; +mod std_pool; +mod sys; +mod unsafe_layout; + +/// Trait for objects that contain a collection of resources that will be accessible by shaders. +/// +/// Objects of this type can be passed when submitting a draw command. +pub unsafe trait DescriptorSet: DescriptorSetDesc { + /// Returns the inner `UnsafeDescriptorSet`. + fn inner(&self) -> &UnsafeDescriptorSet; + + /// Returns the number of buffers within this descriptor set. + fn num_buffers(&self) -> usize; + + /// Returns the `index`th buffer of this descriptor set, or `None` if out of range. Also + /// returns the index of the descriptor that uses this buffer. + /// + /// The valid range is between 0 and `num_buffers()`. + fn buffer(&self, index: usize) -> Option<(&BufferAccess, u32)>; + + /// Returns the number of images within this descriptor set. + fn num_images(&self) -> usize; + + /// Returns the `index`th image of this descriptor set, or `None` if out of range. Also returns + /// the index of the descriptor that uses this image. + /// + /// The valid range is between 0 and `num_images()`. + fn image(&self, index: usize) -> Option<(&ImageViewAccess, u32)>; +} + +unsafe impl<T> DescriptorSet for T + where T: SafeDeref, + T::Target: DescriptorSet +{ + #[inline] + fn inner(&self) -> &UnsafeDescriptorSet { + (**self).inner() + } + + #[inline] + fn num_buffers(&self) -> usize { + (**self).num_buffers() + } + + #[inline] + fn buffer(&self, index: usize) -> Option<(&BufferAccess, u32)> { + (**self).buffer(index) + } + + #[inline] + fn num_images(&self) -> usize { + (**self).num_images() + } + + #[inline] + fn image(&self, index: usize) -> Option<(&ImageViewAccess, u32)> { + (**self).image(index) + } +} + +/// Trait for objects that describe the layout of the descriptors of a set. +pub unsafe trait DescriptorSetDesc { + /// Returns the number of binding slots in the set. + fn num_bindings(&self) -> usize; + + /// Returns a description of a descriptor, or `None` if out of range. + fn descriptor(&self, binding: usize) -> Option<DescriptorDesc>; +} + +unsafe impl<T> DescriptorSetDesc for T + where T: SafeDeref, + T::Target: DescriptorSetDesc +{ + #[inline] + fn num_bindings(&self) -> usize { + (**self).num_bindings() + } + + #[inline] + fn descriptor(&self, binding: usize) -> Option<DescriptorDesc> { + (**self).descriptor(binding) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/persistent.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/persistent.rs new file mode 100644 index 0000000..b60d580 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/persistent.rs @@ -0,0 +1,1162 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::sync::Arc; + +use OomError; +use VulkanObject; +use buffer::BufferAccess; +use buffer::BufferViewRef; +use descriptor::descriptor::DescriptorDesc; +use descriptor::descriptor::DescriptorDescTy; +use descriptor::descriptor::DescriptorImageDesc; +use descriptor::descriptor::DescriptorImageDescArray; +use descriptor::descriptor::DescriptorImageDescDimensions; +use descriptor::descriptor::DescriptorType; +use descriptor::descriptor_set::DescriptorPool; +use descriptor::descriptor_set::DescriptorPoolAlloc; +use descriptor::descriptor_set::DescriptorSet; +use descriptor::descriptor_set::DescriptorSetDesc; +use descriptor::descriptor_set::DescriptorWrite; +use descriptor::descriptor_set::StdDescriptorPoolAlloc; +use descriptor::descriptor_set::UnsafeDescriptorSet; +use descriptor::descriptor_set::UnsafeDescriptorSetLayout; +use descriptor::pipeline_layout::PipelineLayoutAbstract; +use device::Device; +use device::DeviceOwned; +use format::Format; +use image::ImageViewAccess; +use sampler::Sampler; + +/// An immutable descriptor set that is expected to be long-lived. +/// +/// Creating a persistent descriptor set allocates from a pool, and can't be modified once created. +/// You are therefore encouraged to create them at initialization and not the during +/// performance-critical paths. +/// +/// > **Note**: You can control of the pool that is used to create the descriptor set, if you wish +/// > so. By creating a implementation of the `DescriptorPool` trait that doesn't perform any +/// > actual allocation, you can skip this allocation and make it acceptable to use a persistent +/// > descriptor set in performance-critical paths.. +/// +/// The template parameter of the `PersistentDescriptorSet` is complex, and you shouldn't try to +/// express it explicitly. If you want to store your descriptor set in a struct or in a `Vec` for +/// example, you are encouraged to turn the `PersistentDescriptorSet` into a `Box<DescriptorSet>` +/// or a `Arc<DescriptorSet>`. +/// +/// # Example +// TODO: +pub struct PersistentDescriptorSet<L, R, P = StdDescriptorPoolAlloc> { + inner: P, + resources: R, + pipeline_layout: L, + set_id: usize, + layout: Arc<UnsafeDescriptorSetLayout>, +} + +impl<L> PersistentDescriptorSet<L, ()> { + /// Starts the process of building a `PersistentDescriptorSet`. Returns a builder. + /// + /// # Panic + /// + /// - Panics if the set id is out of range. + /// + pub fn start(layout: L, set_id: usize) -> PersistentDescriptorSetBuilder<L, ()> + where L: PipelineLayoutAbstract + { + assert!(layout.num_sets() > set_id); + + let cap = layout.num_bindings_in_set(set_id).unwrap_or(0); + + PersistentDescriptorSetBuilder { + layout: layout, + set_id: set_id, + binding_id: 0, + writes: Vec::with_capacity(cap), + resources: (), + } + } +} + +unsafe impl<L, R, P> DescriptorSet for PersistentDescriptorSet<L, R, P> + where L: PipelineLayoutAbstract, + P: DescriptorPoolAlloc, + R: PersistentDescriptorSetResources +{ + #[inline] + fn inner(&self) -> &UnsafeDescriptorSet { + self.inner.inner() + } + + #[inline] + fn num_buffers(&self) -> usize { + self.resources.num_buffers() + } + + #[inline] + fn buffer(&self, index: usize) -> Option<(&BufferAccess, u32)> { + self.resources.buffer(index) + } + + #[inline] + fn num_images(&self) -> usize { + self.resources.num_images() + } + + #[inline] + fn image(&self, index: usize) -> Option<(&ImageViewAccess, u32)> { + self.resources.image(index) + } +} + +unsafe impl<L, R, P> DescriptorSetDesc for PersistentDescriptorSet<L, R, P> + where L: PipelineLayoutAbstract +{ + #[inline] + fn num_bindings(&self) -> usize { + self.pipeline_layout + .num_bindings_in_set(self.set_id) + .unwrap() + } + + #[inline] + fn descriptor(&self, binding: usize) -> Option<DescriptorDesc> { + self.pipeline_layout.descriptor(self.set_id, binding) + } +} + +unsafe impl<L, R, P> DeviceOwned for PersistentDescriptorSet<L, R, P> + where L: DeviceOwned +{ + #[inline] + fn device(&self) -> &Arc<Device> { + self.layout.device() + } +} + +/// Prototype of a `PersistentDescriptorSet`. +/// +/// The template parameter `L` is the pipeline layout to use, and the template parameter `R` is +/// an unspecified type that represents the list of resources. +/// +/// See the docs of `PersistentDescriptorSet` for an example. +pub struct PersistentDescriptorSetBuilder<L, R> { + // The pipeline layout. + layout: L, + // Id of the set within the pipeline layout. + set_id: usize, + // Binding currently being filled. + binding_id: usize, + // The writes to perform on a descriptor set in order to put the resources in it. + writes: Vec<DescriptorWrite>, + // Holds the resources alive. + resources: R, +} + +// TODO: lots of checks are still missing, see the docs of +// VkDescriptorImageInfo and VkWriteDescriptorSet + +impl<L, R> PersistentDescriptorSetBuilder<L, R> + where L: PipelineLayoutAbstract +{ + /// Builds a `PersistentDescriptorSet` from the builder. + #[inline] + pub fn build(self) + -> Result<PersistentDescriptorSet<L, R, StdDescriptorPoolAlloc>, + PersistentDescriptorSetBuildError> { + let mut pool = Device::standard_descriptor_pool(self.layout.device()); + self.build_with_pool(&mut pool) + } + + /// Builds a `PersistentDescriptorSet` from the builder. + /// + /// # Panic + /// + /// Panics if the pool doesn't have the same device as the pipeline layout. + /// + pub fn build_with_pool<P>( + self, pool: &mut P) + -> Result<PersistentDescriptorSet<L, R, P::Alloc>, PersistentDescriptorSetBuildError> + where P: ?Sized + DescriptorPool + { + assert_eq!(self.layout.device().internal_object(), + pool.device().internal_object()); + + let expected_desc = self.layout.num_bindings_in_set(self.set_id).unwrap(); + + if expected_desc > self.binding_id { + return Err(PersistentDescriptorSetBuildError::MissingDescriptors { + expected: expected_desc as u32, + obtained: self.binding_id as u32, + }); + } + + debug_assert_eq!(expected_desc, self.binding_id); + + let set_layout = self.layout + .descriptor_set_layout(self.set_id) + .expect("Unable to get the descriptor set layout") + .clone(); + + let set = unsafe { + let mut set = pool.alloc(&set_layout)?; + set.inner_mut() + .write(pool.device(), self.writes.into_iter()); + set + }; + + Ok(PersistentDescriptorSet { + inner: set, + resources: self.resources, + pipeline_layout: self.layout, + set_id: self.set_id, + layout: set_layout, + }) + } + + /// Call this function if the next element of the set is an array in order to set the value of + /// each element. + /// + /// Returns an error if the descriptor is empty. + /// + /// This function can be called even if the descriptor isn't an array, and it is valid to enter + /// the "array", add one element, then leave. + #[inline] + pub fn enter_array( + self) + -> Result<PersistentDescriptorSetBuilderArray<L, R>, PersistentDescriptorSetError> { + let desc = match self.layout.descriptor(self.set_id, self.binding_id) { + Some(d) => d, + None => return Err(PersistentDescriptorSetError::EmptyExpected), + }; + + Ok(PersistentDescriptorSetBuilderArray { + builder: self, + desc, + array_element: 0, + }) + } + + /// Skips the current descriptor if it is empty. + #[inline] + pub fn add_empty( + mut self) + -> Result<PersistentDescriptorSetBuilder<L, R>, PersistentDescriptorSetError> { + match self.layout.descriptor(self.set_id, self.binding_id) { + None => (), + Some(desc) => return Err(PersistentDescriptorSetError::WrongDescriptorTy { + expected: desc.ty.ty().unwrap(), + }), + } + + self.binding_id += 1; + Ok(self) + } + + /// Binds a buffer as the next descriptor. + /// + /// An error is returned if the buffer isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the buffer doesn't have the same device as the pipeline layout. + /// + #[inline] + pub fn add_buffer<T>(self, buffer: T) + -> Result<PersistentDescriptorSetBuilder<L, + (R, + PersistentDescriptorSetBuf<T>)>, + PersistentDescriptorSetError> + where T: BufferAccess + { + self.enter_array()?.add_buffer(buffer)?.leave_array() + } + + /// Binds a buffer view as the next descriptor. + /// + /// An error is returned if the buffer isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the buffer view doesn't have the same device as the pipeline layout. + /// + pub fn add_buffer_view<T>(self, view: T) + -> Result<PersistentDescriptorSetBuilder<L, (R, PersistentDescriptorSetBufView<T>)>, PersistentDescriptorSetError> + where T: BufferViewRef + { + self.enter_array()?.add_buffer_view(view)?.leave_array() + } + + /// Binds an image view as the next descriptor. + /// + /// An error is returned if the image view isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the image view doesn't have the same device as the pipeline layout. + /// + #[inline] + pub fn add_image<T>(self, image_view: T) + -> Result<PersistentDescriptorSetBuilder<L, + (R, + PersistentDescriptorSetImg<T>)>, + PersistentDescriptorSetError> + where T: ImageViewAccess + { + self.enter_array()?.add_image(image_view)?.leave_array() + } + + /// Binds an image view with a sampler as the next descriptor. + /// + /// An error is returned if the image view isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the image view or the sampler doesn't have the same device as the pipeline layout. + /// + #[inline] + pub fn add_sampled_image<T>(self, image_view: T, sampler: Arc<Sampler>) + -> Result<PersistentDescriptorSetBuilder<L, ((R, PersistentDescriptorSetImg<T>), PersistentDescriptorSetSampler)>, PersistentDescriptorSetError> + where T: ImageViewAccess + { + self.enter_array()? + .add_sampled_image(image_view, sampler)? + .leave_array() + } + + /// Binds a sampler as the next descriptor. + /// + /// An error is returned if the sampler isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the sampler doesn't have the same device as the pipeline layout. + /// + #[inline] + pub fn add_sampler(self, sampler: Arc<Sampler>) + -> Result<PersistentDescriptorSetBuilder<L, + (R, + PersistentDescriptorSetSampler)>, + PersistentDescriptorSetError> { + self.enter_array()?.add_sampler(sampler)?.leave_array() + } +} + +/// Same as `PersistentDescriptorSetBuilder`, but we're in an array. +pub struct PersistentDescriptorSetBuilderArray<L, R> { + // The original builder. + builder: PersistentDescriptorSetBuilder<L, R>, + // Current array elements. + array_element: usize, + // Description of the descriptor. + desc: DescriptorDesc, +} + +impl<L, R> PersistentDescriptorSetBuilderArray<L, R> + where L: PipelineLayoutAbstract +{ + /// Leaves the array. Call this once you added all the elements of the array. + pub fn leave_array( + mut self) + -> Result<PersistentDescriptorSetBuilder<L, R>, PersistentDescriptorSetError> { + if self.desc.array_count > self.array_element as u32 { + return Err(PersistentDescriptorSetError::MissingArrayElements { + expected: self.desc.array_count, + obtained: self.array_element as u32, + }); + } + + debug_assert_eq!(self.desc.array_count, self.array_element as u32); + + self.builder.binding_id += 1; + Ok(self.builder) + } + + /// Binds a buffer as the next element in the array. + /// + /// An error is returned if the buffer isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the buffer doesn't have the same device as the pipeline layout. + /// + pub fn add_buffer<T>(mut self, buffer: T) + -> Result<PersistentDescriptorSetBuilderArray<L, (R, PersistentDescriptorSetBuf<T>)>, PersistentDescriptorSetError> + where T: BufferAccess + { + assert_eq!(self.builder.layout.device().internal_object(), + buffer.inner().buffer.device().internal_object()); + + if self.array_element as u32 >= self.desc.array_count { + return Err(PersistentDescriptorSetError::ArrayOutOfBounds); + } + + self.builder.writes.push(match self.desc.ty { + DescriptorDescTy::Buffer(ref buffer_desc) => { + // Note that the buffer content is not checked. This is technically not unsafe as + // long as the data in the buffer has no invalid memory representation (ie. no + // bool, no enum, no pointer, no str) and as long as the robust buffer access + // feature is enabled. + // TODO: this is not checked ^ + + // TODO: eventually shouldn't be an assert ; for now robust_buffer_access is always + // enabled so this assert should never fail in practice, but we put it anyway + // in case we forget to adjust this code + assert!(self.builder + .layout + .device() + .enabled_features() + .robust_buffer_access); + + if buffer_desc.storage { + if !buffer.inner().buffer.usage_storage_buffer() { + return Err(PersistentDescriptorSetError::MissingBufferUsage( + MissingBufferUsage::StorageBuffer)); + } + + unsafe { + DescriptorWrite::storage_buffer(self.builder.binding_id as u32, + self.array_element as u32, + &buffer) + } + } else { + if !buffer.inner().buffer.usage_uniform_buffer() { + return Err(PersistentDescriptorSetError::MissingBufferUsage( + MissingBufferUsage::UniformBuffer)); + } + + unsafe { + DescriptorWrite::uniform_buffer(self.builder.binding_id as u32, + self.array_element as u32, + &buffer) + } + } + }, + ref d => { + return Err(PersistentDescriptorSetError::WrongDescriptorTy { + expected: d.ty().unwrap(), + }); + }, + }); + + Ok(PersistentDescriptorSetBuilderArray { + builder: PersistentDescriptorSetBuilder { + layout: self.builder.layout, + set_id: self.builder.set_id, + binding_id: self.builder.binding_id, + writes: self.builder.writes, + resources: (self.builder.resources, + PersistentDescriptorSetBuf { + buffer: buffer, + descriptor_num: self.builder.binding_id as u32, + }), + }, + desc: self.desc, + array_element: self.array_element + 1, + }) + } + + /// Binds a buffer view as the next element in the array. + /// + /// An error is returned if the buffer isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the buffer view doesn't have the same device as the pipeline layout. + /// + pub fn add_buffer_view<T>(mut self, view: T) + -> Result<PersistentDescriptorSetBuilderArray<L, (R, PersistentDescriptorSetBufView<T>)>, PersistentDescriptorSetError> + where T: BufferViewRef + { + assert_eq!(self.builder.layout.device().internal_object(), + view.view().device().internal_object()); + + if self.array_element as u32 >= self.desc.array_count { + return Err(PersistentDescriptorSetError::ArrayOutOfBounds); + } + + self.builder.writes.push(match self.desc.ty { + DescriptorDescTy::TexelBuffer { storage, .. } => { + if storage { + // TODO: storage_texel_buffer_atomic + + if !view.view().storage_texel_buffer() { + return Err(PersistentDescriptorSetError::MissingBufferUsage( + MissingBufferUsage::StorageTexelBuffer)); + } + + DescriptorWrite::storage_texel_buffer(self.builder.binding_id as u32, + self.array_element as u32, + view.view()) + } else { + if !view.view().uniform_texel_buffer() { + return Err(PersistentDescriptorSetError::MissingBufferUsage( + MissingBufferUsage::UniformTexelBuffer)); + } + + DescriptorWrite::uniform_texel_buffer(self.builder.binding_id as u32, + self.array_element as u32, + view.view()) + } + }, + ref d => { + return Err(PersistentDescriptorSetError::WrongDescriptorTy { + expected: d.ty().unwrap(), + }); + }, + }); + + Ok(PersistentDescriptorSetBuilderArray { + builder: PersistentDescriptorSetBuilder { + layout: self.builder.layout, + set_id: self.builder.set_id, + binding_id: self.builder.binding_id, + writes: self.builder.writes, + resources: (self.builder.resources, + PersistentDescriptorSetBufView { + view: view, + descriptor_num: self.builder.binding_id as u32, + }), + }, + desc: self.desc, + array_element: self.array_element + 1, + }) + } + + /// Binds an image view as the next element in the array. + /// + /// An error is returned if the image view isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the image view doesn't have the same device as the pipeline layout. + /// + pub fn add_image<T>(mut self, image_view: T) + -> Result<PersistentDescriptorSetBuilderArray<L, (R, PersistentDescriptorSetImg<T>)>, PersistentDescriptorSetError> + where T: ImageViewAccess + { + assert_eq!(self.builder.layout.device().internal_object(), + image_view.parent().inner().image.device().internal_object()); + + if self.array_element as u32 >= self.desc.array_count { + return Err(PersistentDescriptorSetError::ArrayOutOfBounds); + } + + let desc = match self.builder + .layout + .descriptor(self.builder.set_id, self.builder.binding_id) { + Some(d) => d, + None => return Err(PersistentDescriptorSetError::EmptyExpected), + }; + + self.builder.writes.push(match desc.ty { + DescriptorDescTy::Image(ref desc) => { + image_match_desc(&image_view, &desc)?; + + if desc.sampled { + DescriptorWrite::sampled_image(self.builder.binding_id as u32, + self.array_element as u32, + &image_view) + } else { + DescriptorWrite::storage_image(self.builder.binding_id as u32, + self.array_element as u32, + &image_view) + } + }, + DescriptorDescTy::InputAttachment { + multisampled, + array_layers, + } => { + if !image_view.parent().inner().image.usage_input_attachment() { + return Err(PersistentDescriptorSetError::MissingImageUsage( + MissingImageUsage::InputAttachment)); + } + + if multisampled && image_view.samples() == 1 { + return Err(PersistentDescriptorSetError::ExpectedMultisampled); + } else if !multisampled && image_view.samples() != 1 { + return Err(PersistentDescriptorSetError::UnexpectedMultisampled); + } + + let image_layers = image_view.dimensions().array_layers(); + + match array_layers { + DescriptorImageDescArray::NonArrayed => { + if image_layers != 1 { + return Err(PersistentDescriptorSetError::ArrayLayersMismatch { + expected: 1, + obtained: image_layers, + }); + } + }, + DescriptorImageDescArray::Arrayed { max_layers: Some(max_layers) } => { + if image_layers > max_layers { + // TODO: is this correct? "max" layers? or is it in fact min layers? + return Err(PersistentDescriptorSetError::ArrayLayersMismatch { + expected: max_layers, + obtained: image_layers, + }); + } + }, + DescriptorImageDescArray::Arrayed { max_layers: None } => {}, + }; + + DescriptorWrite::input_attachment(self.builder.binding_id as u32, + self.array_element as u32, + &image_view) + }, + ty => { + return Err(PersistentDescriptorSetError::WrongDescriptorTy { + expected: ty.ty().unwrap(), + }); + }, + }); + + Ok(PersistentDescriptorSetBuilderArray { + builder: PersistentDescriptorSetBuilder { + layout: self.builder.layout, + set_id: self.builder.set_id, + binding_id: self.builder.binding_id, + writes: self.builder.writes, + resources: (self.builder.resources, + PersistentDescriptorSetImg { + image: image_view, + descriptor_num: self.builder.binding_id as u32, + }), + }, + desc: self.desc, + array_element: self.array_element + 1, + }) + } + + /// Binds an image view with a sampler as the next element in the array. + /// + /// An error is returned if the image view isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the image or the sampler doesn't have the same device as the pipeline layout. + /// + pub fn add_sampled_image<T>(mut self, image_view: T, sampler: Arc<Sampler>) + -> Result<PersistentDescriptorSetBuilderArray<L, ((R, PersistentDescriptorSetImg<T>), PersistentDescriptorSetSampler)>, PersistentDescriptorSetError> + where T: ImageViewAccess + { + assert_eq!(self.builder.layout.device().internal_object(), + image_view.parent().inner().image.device().internal_object()); + assert_eq!(self.builder.layout.device().internal_object(), + sampler.device().internal_object()); + + if self.array_element as u32 >= self.desc.array_count { + return Err(PersistentDescriptorSetError::ArrayOutOfBounds); + } + + let desc = match self.builder + .layout + .descriptor(self.builder.set_id, self.builder.binding_id) { + Some(d) => d, + None => return Err(PersistentDescriptorSetError::EmptyExpected), + }; + + if !image_view.can_be_sampled(&sampler) { + return Err(PersistentDescriptorSetError::IncompatibleImageViewSampler); + } + + self.builder.writes.push(match desc.ty { + DescriptorDescTy::CombinedImageSampler(ref desc) => { + image_match_desc(&image_view, &desc)?; + DescriptorWrite::combined_image_sampler(self.builder.binding_id as u32, + self.array_element as u32, + &sampler, + &image_view) + }, + ty => { + return Err(PersistentDescriptorSetError::WrongDescriptorTy { + expected: ty.ty().unwrap(), + }); + }, + }); + + Ok(PersistentDescriptorSetBuilderArray { + builder: PersistentDescriptorSetBuilder { + layout: self.builder.layout, + set_id: self.builder.set_id, + binding_id: self.builder.binding_id, + writes: self.builder.writes, + resources: ((self.builder.resources, + PersistentDescriptorSetImg { + image: image_view, + descriptor_num: self.builder.binding_id as u32, + }), + PersistentDescriptorSetSampler { sampler: sampler }), + }, + desc: self.desc, + array_element: self.array_element + 1, + }) + } + + /// Binds a sampler as the next element in the array. + /// + /// An error is returned if the sampler isn't compatible with the descriptor. + /// + /// # Panic + /// + /// Panics if the sampler doesn't have the same device as the pipeline layout. + /// + pub fn add_sampler(mut self, sampler: Arc<Sampler>) + -> Result<PersistentDescriptorSetBuilderArray<L, (R, PersistentDescriptorSetSampler)>, PersistentDescriptorSetError> + { + assert_eq!(self.builder.layout.device().internal_object(), + sampler.device().internal_object()); + + if self.array_element as u32 >= self.desc.array_count { + return Err(PersistentDescriptorSetError::ArrayOutOfBounds); + } + + let desc = match self.builder + .layout + .descriptor(self.builder.set_id, self.builder.binding_id) { + Some(d) => d, + None => return Err(PersistentDescriptorSetError::EmptyExpected), + }; + + self.builder.writes.push(match desc.ty { + DescriptorDescTy::Sampler => { + DescriptorWrite::sampler(self.builder.binding_id as u32, + self.array_element as u32, + &sampler) + }, + ty => { + return Err(PersistentDescriptorSetError::WrongDescriptorTy { + expected: ty.ty().unwrap(), + }); + }, + }); + + Ok(PersistentDescriptorSetBuilderArray { + builder: PersistentDescriptorSetBuilder { + layout: self.builder.layout, + set_id: self.builder.set_id, + binding_id: self.builder.binding_id, + writes: self.builder.writes, + resources: (self.builder.resources, + PersistentDescriptorSetSampler { sampler: sampler }), + }, + desc: self.desc, + array_element: self.array_element + 1, + }) + } +} + +// Checks whether an image view matches the descriptor. +fn image_match_desc<I>(image_view: &I, desc: &DescriptorImageDesc) + -> Result<(), PersistentDescriptorSetError> + where I: ?Sized + ImageViewAccess +{ + if desc.sampled && !image_view.parent().inner().image.usage_sampled() { + return Err(PersistentDescriptorSetError::MissingImageUsage( + MissingImageUsage::Sampled)); + } else if !desc.sampled && !image_view.parent().inner().image.usage_storage() { + return Err(PersistentDescriptorSetError::MissingImageUsage( + MissingImageUsage::Storage)); + } + + let image_view_ty = DescriptorImageDescDimensions::from_dimensions(image_view.dimensions()); + if image_view_ty != desc.dimensions { + return Err(PersistentDescriptorSetError::ImageViewTypeMismatch { + expected: desc.dimensions, + obtained: image_view_ty, + }); + } + + if let Some(format) = desc.format { + if image_view.format() != format { + return Err(PersistentDescriptorSetError::ImageViewFormatMismatch { + expected: format, + obtained: image_view.format(), + }); + } + } + + if desc.multisampled && image_view.samples() == 1 { + return Err(PersistentDescriptorSetError::ExpectedMultisampled); + } else if !desc.multisampled && image_view.samples() != 1 { + return Err(PersistentDescriptorSetError::UnexpectedMultisampled); + } + + let image_layers = image_view.dimensions().array_layers(); + + match desc.array_layers { + DescriptorImageDescArray::NonArrayed => { + // TODO: when a non-array is expected, can we pass an image view that is in fact an + // array with one layer? need to check + if image_layers != 1 { + return Err(PersistentDescriptorSetError::ArrayLayersMismatch { + expected: 1, + obtained: image_layers, + }); + } + }, + DescriptorImageDescArray::Arrayed { max_layers: Some(max_layers) } => { + if image_layers > max_layers { + // TODO: is this correct? "max" layers? or is it in fact min layers? + return Err(PersistentDescriptorSetError::ArrayLayersMismatch { + expected: max_layers, + obtained: image_layers, + }); + } + }, + DescriptorImageDescArray::Arrayed { max_layers: None } => {}, + }; + + Ok(()) +} + +pub unsafe trait PersistentDescriptorSetResources { + fn num_buffers(&self) -> usize; + fn buffer(&self, index: usize) -> Option<(&BufferAccess, u32)>; + fn num_images(&self) -> usize; + fn image(&self, index: usize) -> Option<(&ImageViewAccess, u32)>; +} + +unsafe impl PersistentDescriptorSetResources for () { + #[inline] + fn num_buffers(&self) -> usize { + 0 + } + + #[inline] + fn buffer(&self, _: usize) -> Option<(&BufferAccess, u32)> { + None + } + + #[inline] + fn num_images(&self) -> usize { + 0 + } + + #[inline] + fn image(&self, _: usize) -> Option<(&ImageViewAccess, u32)> { + None + } +} + +/// Internal object related to the `PersistentDescriptorSet` system. +pub struct PersistentDescriptorSetBuf<B> { + buffer: B, + descriptor_num: u32, +} + +unsafe impl<R, B> PersistentDescriptorSetResources for (R, PersistentDescriptorSetBuf<B>) + where R: PersistentDescriptorSetResources, + B: BufferAccess +{ + #[inline] + fn num_buffers(&self) -> usize { + self.0.num_buffers() + 1 + } + + #[inline] + fn buffer(&self, index: usize) -> Option<(&BufferAccess, u32)> { + if let Some(buf) = self.0.buffer(index) { + Some(buf) + } else if index == self.0.num_buffers() { + Some((&self.1.buffer, self.1.descriptor_num)) + } else { + None + } + } + + #[inline] + fn num_images(&self) -> usize { + self.0.num_images() + } + + #[inline] + fn image(&self, index: usize) -> Option<(&ImageViewAccess, u32)> { + self.0.image(index) + } +} + +/// Internal object related to the `PersistentDescriptorSet` system. +pub struct PersistentDescriptorSetBufView<V> + where V: BufferViewRef +{ + view: V, + descriptor_num: u32, +} + +unsafe impl<R, V> PersistentDescriptorSetResources for (R, PersistentDescriptorSetBufView<V>) + where R: PersistentDescriptorSetResources, + V: BufferViewRef +{ + #[inline] + fn num_buffers(&self) -> usize { + self.0.num_buffers() + 1 + } + + #[inline] + fn buffer(&self, index: usize) -> Option<(&BufferAccess, u32)> { + if let Some(buf) = self.0.buffer(index) { + Some(buf) + } else if index == self.0.num_buffers() { + Some((self.1.view.view().buffer(), self.1.descriptor_num)) + } else { + None + } + } + + #[inline] + fn num_images(&self) -> usize { + self.0.num_images() + } + + #[inline] + fn image(&self, index: usize) -> Option<(&ImageViewAccess, u32)> { + self.0.image(index) + } +} + +/// Internal object related to the `PersistentDescriptorSet` system. +pub struct PersistentDescriptorSetImg<I> { + image: I, + descriptor_num: u32, +} + +unsafe impl<R, I> PersistentDescriptorSetResources for (R, PersistentDescriptorSetImg<I>) + where R: PersistentDescriptorSetResources, + I: ImageViewAccess +{ + #[inline] + fn num_buffers(&self) -> usize { + self.0.num_buffers() + } + + #[inline] + fn buffer(&self, index: usize) -> Option<(&BufferAccess, u32)> { + self.0.buffer(index) + } + + #[inline] + fn num_images(&self) -> usize { + self.0.num_images() + 1 + } + + #[inline] + fn image(&self, index: usize) -> Option<(&ImageViewAccess, u32)> { + if let Some(img) = self.0.image(index) { + Some(img) + } else if index == self.0.num_images() { + Some((&self.1.image, self.1.descriptor_num)) + } else { + None + } + } +} + +/// Internal object related to the `PersistentDescriptorSet` system. +pub struct PersistentDescriptorSetSampler { + sampler: Arc<Sampler>, +} + +unsafe impl<R> PersistentDescriptorSetResources for (R, PersistentDescriptorSetSampler) + where R: PersistentDescriptorSetResources +{ + #[inline] + fn num_buffers(&self) -> usize { + self.0.num_buffers() + } + + #[inline] + fn buffer(&self, index: usize) -> Option<(&BufferAccess, u32)> { + self.0.buffer(index) + } + + #[inline] + fn num_images(&self) -> usize { + self.0.num_images() + } + + #[inline] + fn image(&self, index: usize) -> Option<(&ImageViewAccess, u32)> { + self.0.image(index) + } +} + +// Part of the PersistentDescriptorSetError for the case +// of missing usage on a buffer. +#[derive(Debug, Clone)] +pub enum MissingBufferUsage { + StorageBuffer, UniformBuffer, StorageTexelBuffer, UniformTexelBuffer +} + +// Part of the PersistentDescriptorSetError for the case +// of missing usage on an image. +#[derive(Debug, Clone)] +pub enum MissingImageUsage { + InputAttachment, Sampled, Storage +} + +/// Error related to the persistent descriptor set. +#[derive(Debug, Clone)] +pub enum PersistentDescriptorSetError { + /// Expected one type of resource but got another. + WrongDescriptorTy { + /// The expected descriptor type. + expected: DescriptorType, + }, + + /// Expected nothing. + EmptyExpected, + + /// Tried to add too many elements to an array. + ArrayOutOfBounds, + + /// Didn't fill all the elements of an array before leaving. + MissingArrayElements { + /// Number of expected elements. + expected: u32, + /// Number of elements that were added. + obtained: u32, + }, + + /// The image view isn't compatible with the sampler. + IncompatibleImageViewSampler, + + /// The buffer is missing the correct usage. + MissingBufferUsage(MissingBufferUsage), + + /// The image is missing the correct usage. + MissingImageUsage(MissingImageUsage), + + /// Expected a multisampled image, but got a single-sampled image. + ExpectedMultisampled, + + /// Expected a single-sampled image, but got a multisampled image. + UnexpectedMultisampled, + + /// The number of array layers of an image doesn't match what was expected. + ArrayLayersMismatch { + /// Number of expected array layers for the image. + expected: u32, + /// Number of array layers of the image that was added. + obtained: u32, + }, + + /// The format of an image view doesn't match what was expected. + ImageViewFormatMismatch { + /// Expected format. + expected: Format, + /// Format of the image view that was passed. + obtained: Format, + }, + + /// The type of an image view doesn't match what was expected. + ImageViewTypeMismatch { + /// Expected type. + expected: DescriptorImageDescDimensions, + /// Type of the image view that was passed. + obtained: DescriptorImageDescDimensions, + }, +} + +impl error::Error for PersistentDescriptorSetError { + #[inline] + fn description(&self) -> &str { + match *self { + PersistentDescriptorSetError::WrongDescriptorTy { .. } => { + "expected one type of resource but got another" + }, + PersistentDescriptorSetError::EmptyExpected => { + "expected an empty descriptor but got something" + }, + PersistentDescriptorSetError::ArrayOutOfBounds => { + "tried to add too many elements to an array" + }, + PersistentDescriptorSetError::MissingArrayElements { .. } => { + "didn't fill all the elements of an array before leaving" + }, + PersistentDescriptorSetError::IncompatibleImageViewSampler => { + "the image view isn't compatible with the sampler" + }, + PersistentDescriptorSetError::MissingBufferUsage { .. } => { + "the buffer is missing the correct usage" + }, + PersistentDescriptorSetError::MissingImageUsage { .. } => { + "the image is missing the correct usage" + }, + PersistentDescriptorSetError::ExpectedMultisampled => { + "expected a multisampled image, but got a single-sampled image" + }, + PersistentDescriptorSetError::UnexpectedMultisampled => { + "expected a single-sampled image, but got a multisampled image" + }, + PersistentDescriptorSetError::ArrayLayersMismatch { .. } => { + "the number of array layers of an image doesn't match what was expected" + }, + PersistentDescriptorSetError::ImageViewFormatMismatch { .. } => { + "the format of an image view doesn't match what was expected" + }, + PersistentDescriptorSetError::ImageViewTypeMismatch { .. } => { + "the type of an image view doesn't match what was expected" + }, + } + } +} + +impl fmt::Display for PersistentDescriptorSetError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +/// Error when building a persistent descriptor set. +#[derive(Debug, Clone)] +pub enum PersistentDescriptorSetBuildError { + /// Out of memory. + OomError(OomError), + + /// Didn't fill all the descriptors before building. + MissingDescriptors { + /// Number of expected descriptors. + expected: u32, + /// Number of descriptors that were added. + obtained: u32, + }, +} + +impl error::Error for PersistentDescriptorSetBuildError { + #[inline] + fn description(&self) -> &str { + match *self { + PersistentDescriptorSetBuildError::MissingDescriptors { .. } => { + "didn't fill all the descriptors before building" + }, + PersistentDescriptorSetBuildError::OomError(_) => { + "not enough memory available" + }, + } + } +} + +impl From<OomError> for PersistentDescriptorSetBuildError { + #[inline] + fn from(err: OomError) -> PersistentDescriptorSetBuildError { + PersistentDescriptorSetBuildError::OomError(err) + } +} + +impl fmt::Display for PersistentDescriptorSetBuildError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/std_pool.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/std_pool.rs new file mode 100644 index 0000000..d803102 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/std_pool.rs @@ -0,0 +1,212 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::sync::Arc; +use std::sync::Mutex; + +use OomError; +use descriptor::descriptor_set::DescriptorPool; +use descriptor::descriptor_set::DescriptorPoolAlloc; +use descriptor::descriptor_set::DescriptorPoolAllocError; +use descriptor::descriptor_set::DescriptorsCount; +use descriptor::descriptor_set::UnsafeDescriptorPool; +use descriptor::descriptor_set::UnsafeDescriptorSet; +use descriptor::descriptor_set::UnsafeDescriptorSetLayout; +use device::Device; +use device::DeviceOwned; + +/// Standard implementation of a descriptor pool. +/// +/// It is guaranteed that the `Arc<StdDescriptorPool>` is kept alive by its allocations. This is +/// desirable so that we can store a `Weak<StdDescriptorPool>`. +/// +/// Whenever a set is allocated, this implementation will try to find a pool that has some space +/// for it. If there is one, allocate from it. If there is none, create a new pool whose capacity +/// is 40 sets and 40 times the requested descriptors. This number is arbitrary. +pub struct StdDescriptorPool { + device: Arc<Device>, + pools: Mutex<Vec<Arc<Mutex<Pool>>>>, +} + +struct Pool { + pool: UnsafeDescriptorPool, + remaining_capacity: DescriptorsCount, + remaining_sets_count: u32, +} + +impl StdDescriptorPool { + /// Builds a new `StdDescriptorPool`. + pub fn new(device: Arc<Device>) -> StdDescriptorPool { + StdDescriptorPool { + device: device, + pools: Mutex::new(Vec::new()), + } + } +} + +/// A descriptor set allocated from a `StdDescriptorPool`. +pub struct StdDescriptorPoolAlloc { + pool: Arc<Mutex<Pool>>, + // The set. Inside an option so that we can extract it in the destructor. + set: Option<UnsafeDescriptorSet>, + // We need to keep track of this count in order to add it back to the capacity when freeing. + descriptors: DescriptorsCount, + // We keep the parent of the pool alive, otherwise it would be destroyed. + pool_parent: Arc<StdDescriptorPool>, +} + +unsafe impl DescriptorPool for Arc<StdDescriptorPool> { + type Alloc = StdDescriptorPoolAlloc; + + // TODO: eventually use a lock-free algorithm? + fn alloc(&mut self, layout: &UnsafeDescriptorSetLayout) + -> Result<StdDescriptorPoolAlloc, OomError> { + let mut pools = self.pools.lock().unwrap(); + + // Try find an existing pool with some free space. + for pool_arc in pools.iter_mut() { + let mut pool = pool_arc.lock().unwrap(); + + if pool.remaining_sets_count == 0 { + continue; + } + + if !(pool.remaining_capacity >= *layout.descriptors_count()) { + continue; + } + + // Note that we decrease these values *before* trying to allocate from the pool. + // If allocating from the pool results in an error, we just ignore it. In order to + // avoid trying the same failing pool every time, we "pollute" it by reducing the + // available space. + pool.remaining_sets_count -= 1; + pool.remaining_capacity -= *layout.descriptors_count(); + + let alloc = unsafe { + match pool.pool.alloc(Some(layout)) { + Ok(mut sets) => sets.next().unwrap(), + // An error can happen if we're out of memory, or if the pool is fragmented. + // We handle these errors by just ignoring this pool and trying the next ones. + Err(_) => continue, + } + }; + + return Ok(StdDescriptorPoolAlloc { + pool: pool_arc.clone(), + set: Some(alloc), + descriptors: *layout.descriptors_count(), + pool_parent: self.clone(), + }); + } + + // No existing pool can be used. Create a new one. + // We use an arbitrary number of 40 sets and 40 times the requested descriptors. + let count = layout.descriptors_count().clone() * 40; + // Failure to allocate a new pool results in an error for the whole function because + // there's no way we can recover from that. + let mut new_pool = UnsafeDescriptorPool::new(self.device.clone(), &count, 40, true)?; + + let alloc = unsafe { + match new_pool.alloc(Some(layout)) { + Ok(mut sets) => sets.next().unwrap(), + Err(DescriptorPoolAllocError::OutOfHostMemory) => { + return Err(OomError::OutOfHostMemory); + }, + Err(DescriptorPoolAllocError::OutOfDeviceMemory) => { + return Err(OomError::OutOfDeviceMemory); + }, + // A fragmented pool error can't happen at the first ever allocation. + Err(DescriptorPoolAllocError::FragmentedPool) => unreachable!(), + // Out of pool memory cannot happen at the first ever allocation. + Err(DescriptorPoolAllocError::OutOfPoolMemory) => unreachable!(), + } + }; + + let pool_obj = Arc::new(Mutex::new(Pool { + pool: new_pool, + remaining_capacity: count - + *layout.descriptors_count(), + remaining_sets_count: 40 - 1, + })); + + pools.push(pool_obj.clone()); + + Ok(StdDescriptorPoolAlloc { + pool: pool_obj, + set: Some(alloc), + descriptors: *layout.descriptors_count(), + pool_parent: self.clone(), + }) + } +} + +unsafe impl DeviceOwned for StdDescriptorPool { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl DescriptorPoolAlloc for StdDescriptorPoolAlloc { + #[inline] + fn inner(&self) -> &UnsafeDescriptorSet { + self.set.as_ref().unwrap() + } + + #[inline] + fn inner_mut(&mut self) -> &mut UnsafeDescriptorSet { + self.set.as_mut().unwrap() + } +} + +impl Drop for StdDescriptorPoolAlloc { + // This is the destructor of a single allocation (not of the whole pool). + fn drop(&mut self) { + unsafe { + let mut pool = self.pool.lock().unwrap(); + pool.pool.free(self.set.take()).unwrap(); + // Add back the capacity only after freeing, in case of a panic during the free. + pool.remaining_sets_count += 1; + pool.remaining_capacity += self.descriptors; + } + } +} + +#[cfg(test)] +mod tests { + use descriptor::descriptor::DescriptorDesc; + use descriptor::descriptor::DescriptorDescTy; + use descriptor::descriptor::ShaderStages; + use descriptor::descriptor_set::DescriptorPool; + use descriptor::descriptor_set::StdDescriptorPool; + use descriptor::descriptor_set::UnsafeDescriptorSetLayout; + use std::iter; + use std::sync::Arc; + + #[test] + fn desc_pool_kept_alive() { + // Test that the `StdDescriptorPool` is kept alive by its allocations. + let (device, _) = gfx_dev_and_queue!(); + + let desc = DescriptorDesc { + ty: DescriptorDescTy::Sampler, + array_count: 1, + stages: ShaderStages::all(), + readonly: false, + }; + let layout = UnsafeDescriptorSetLayout::new(device.clone(), iter::once(Some(desc))) + .unwrap(); + + let mut pool = Arc::new(StdDescriptorPool::new(device)); + let pool_weak = Arc::downgrade(&pool); + let alloc = pool.alloc(&layout); + drop(pool); + assert!(pool_weak.upgrade().is_some()); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/sys.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/sys.rs new file mode 100644 index 0000000..d81a863 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/sys.rs @@ -0,0 +1,1160 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::cmp; +use std::error; +use std::fmt; +use std::mem; +use std::ops; +use std::ptr; +use std::sync::Arc; +use std::vec::IntoIter as VecIntoIter; + +use buffer::BufferAccess; +use buffer::BufferInner; +use buffer::BufferView; +use descriptor::descriptor::DescriptorType; +use descriptor::descriptor_set::UnsafeDescriptorSetLayout; +use device::Device; +use device::DeviceOwned; +use image::ImageViewAccess; +use sampler::Sampler; + +use OomError; +use VulkanObject; +use check_errors; +use vk; + +/// A pool from which descriptor sets can be allocated. +/// +/// Since the destructor of `Alloc` must free the descriptor set, this trait is usually implemented +/// on `Arc<T>` or `&'a T` and not `T` directly, so that the `Alloc` object can hold the pool. +pub unsafe trait DescriptorPool: DeviceOwned { + /// Object that represented an allocated descriptor set. + /// + /// The destructor of this object should free the descriptor set. + type Alloc: DescriptorPoolAlloc; + + /// Allocates a descriptor set. + fn alloc(&mut self, layout: &UnsafeDescriptorSetLayout) -> Result<Self::Alloc, OomError>; +} + +/// An allocated descriptor set. +pub trait DescriptorPoolAlloc { + /// Returns the inner unsafe descriptor set object. + fn inner(&self) -> &UnsafeDescriptorSet; + + /// Returns the inner unsafe descriptor set object. + fn inner_mut(&mut self) -> &mut UnsafeDescriptorSet; +} + +macro_rules! descriptors_count { + ($($name:ident,)+) => ( + /// Number of available descriptors slots in a pool. + /// + /// # Example + /// + /// ``` + /// use vulkano::descriptor::descriptor_set::DescriptorsCount; + /// + /// let _descriptors = DescriptorsCount { + /// uniform_buffer: 10, + /// input_attachment: 5, + /// .. DescriptorsCount::zero() + /// }; + /// ``` + /// + #[derive(Debug, Copy, Clone)] + pub struct DescriptorsCount { + $( + pub $name: u32, + )+ + } + + impl DescriptorsCount { + /// Returns a `DescriptorsCount` object with all fields set to 0. + #[inline] + pub fn zero() -> DescriptorsCount { + DescriptorsCount { + $( + $name: 0, + )+ + } + } + + /// Adds one descriptor of the given type to the count. + #[inline] + pub fn add_one(&mut self, ty: DescriptorType) { + match ty { + DescriptorType::Sampler => self.sampler += 1, + DescriptorType::CombinedImageSampler => self.combined_image_sampler += 1, + DescriptorType::SampledImage => self.sampled_image += 1, + DescriptorType::StorageImage => self.storage_image += 1, + DescriptorType::UniformTexelBuffer => self.uniform_texel_buffer += 1, + DescriptorType::StorageTexelBuffer => self.storage_texel_buffer += 1, + DescriptorType::UniformBuffer => self.uniform_buffer += 1, + DescriptorType::StorageBuffer => self.storage_buffer += 1, + DescriptorType::UniformBufferDynamic => self.uniform_buffer_dynamic += 1, + DescriptorType::StorageBufferDynamic => self.storage_buffer_dynamic += 1, + DescriptorType::InputAttachment => self.input_attachment += 1, + }; + } + } + + impl cmp::PartialEq for DescriptorsCount { + #[inline] + fn eq(&self, other: &DescriptorsCount) -> bool { + self.partial_cmp(other) == Some(cmp::Ordering::Equal) + } + } + + impl cmp::Eq for DescriptorsCount { + } + + impl cmp::PartialOrd for DescriptorsCount { + fn partial_cmp(&self, other: &DescriptorsCount) -> Option<cmp::Ordering> { + if $(self.$name > other.$name)&&+ { + Some(cmp::Ordering::Greater) + } else if $(self.$name < other.$name)&&+ { + Some(cmp::Ordering::Less) + } else if $(self.$name == other.$name)&&+ { + Some(cmp::Ordering::Equal) + } else { + None + } + } + + fn le(&self, other: &DescriptorsCount) -> bool { + $(self.$name <= other.$name)&&+ + } + + fn ge(&self, other: &DescriptorsCount) -> bool { + $(self.$name >= other.$name)&&+ + } + } + + impl ops::Sub for DescriptorsCount { + type Output = DescriptorsCount; + + #[inline] + fn sub(self, rhs: DescriptorsCount) -> DescriptorsCount { + DescriptorsCount { + $( + $name: self.$name - rhs.$name, + )+ + } + } + } + + impl ops::SubAssign for DescriptorsCount { + #[inline] + fn sub_assign(&mut self, rhs: DescriptorsCount) { + $( + self.$name -= rhs.$name; + )+ + } + } + + impl ops::Add for DescriptorsCount { + type Output = DescriptorsCount; + + #[inline] + fn add(self, rhs: DescriptorsCount) -> DescriptorsCount { + DescriptorsCount { + $( + $name: self.$name + rhs.$name, + )+ + } + } + } + + impl ops::AddAssign for DescriptorsCount { + #[inline] + fn add_assign(&mut self, rhs: DescriptorsCount) { + $( + self.$name += rhs.$name; + )+ + } + } + + impl ops::Mul<u32> for DescriptorsCount { + type Output = DescriptorsCount; + + #[inline] + fn mul(self, rhs: u32) -> DescriptorsCount { + DescriptorsCount { + $( + $name: self.$name * rhs, + )+ + } + } + } + + impl ops::MulAssign<u32> for DescriptorsCount { + #[inline] + fn mul_assign(&mut self, rhs: u32) { + $( + self.$name *= rhs; + )+ + } + } + ); +} + +descriptors_count! { + uniform_buffer, + storage_buffer, + uniform_buffer_dynamic, + storage_buffer_dynamic, + uniform_texel_buffer, + storage_texel_buffer, + sampled_image, + storage_image, + sampler, + combined_image_sampler, + input_attachment, +} + +/// Pool from which descriptor sets are allocated from. +/// +/// A pool has a maximum number of descriptor sets and a maximum number of descriptors (one value +/// per descriptor type) it can allocate. +pub struct UnsafeDescriptorPool { + pool: vk::DescriptorPool, + device: Arc<Device>, +} + +impl UnsafeDescriptorPool { + /// Initializes a new pool. + /// + /// Initializes a pool whose capacity is given by `count` and `max_sets`. At most `count` + /// descriptors or `max_sets` descriptor sets can be allocated at once with this pool. + /// + /// If `free_descriptor_set_bit` is `true`, then individual descriptor sets can be free'd from + /// the pool. Otherwise you must reset or destroy the whole pool at once. + /// + /// # Panic + /// + /// - Panics if all the descriptors count are 0. + /// - Panics if `max_sets` is 0. + /// + pub fn new(device: Arc<Device>, count: &DescriptorsCount, max_sets: u32, + free_descriptor_set_bit: bool) + -> Result<UnsafeDescriptorPool, OomError> { + let vk = device.pointers(); + + assert_ne!(max_sets, 0, "The maximum number of sets can't be 0"); + + let mut pool_sizes: SmallVec<[_; 10]> = SmallVec::new(); + + macro_rules! elem { + ($field:ident, $ty:expr) => ( + if count.$field >= 1 { + pool_sizes.push(vk::DescriptorPoolSize { + ty: $ty, + descriptorCount: count.$field, + }); + } + ); + } + + elem!(uniform_buffer, vk::DESCRIPTOR_TYPE_UNIFORM_BUFFER); + elem!(storage_buffer, vk::DESCRIPTOR_TYPE_STORAGE_BUFFER); + elem!(uniform_buffer_dynamic, + vk::DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC); + elem!(storage_buffer_dynamic, + vk::DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC); + elem!(uniform_texel_buffer, + vk::DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER); + elem!(storage_texel_buffer, + vk::DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER); + elem!(sampled_image, vk::DESCRIPTOR_TYPE_SAMPLED_IMAGE); + elem!(storage_image, vk::DESCRIPTOR_TYPE_STORAGE_IMAGE); + elem!(sampler, vk::DESCRIPTOR_TYPE_SAMPLER); + elem!(combined_image_sampler, + vk::DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER); + elem!(input_attachment, vk::DESCRIPTOR_TYPE_INPUT_ATTACHMENT); + + assert!(!pool_sizes.is_empty(), + "All the descriptors count of a pool are 0"); + + let pool = unsafe { + let infos = vk::DescriptorPoolCreateInfo { + sType: vk::STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, + pNext: ptr::null(), + flags: if free_descriptor_set_bit { + vk::DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT + } else { + 0 + }, + maxSets: max_sets, + poolSizeCount: pool_sizes.len() as u32, + pPoolSizes: pool_sizes.as_ptr(), + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateDescriptorPool(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(UnsafeDescriptorPool { + pool: pool, + device: device.clone(), + }) + } + + /// Allocates descriptor sets from the pool, one for each layout. + /// Returns an iterator to the allocated sets, or an error. + /// + /// The `FragmentedPool` errors often can't be prevented. If the function returns this error, + /// you should just create a new pool. + /// + /// # Panic + /// + /// - Panics if one of the layouts wasn't created with the same device as the pool. + /// + /// # Safety + /// + /// See also the `new` function. + /// + /// - The total descriptors of the layouts must fit in the pool. + /// - The total number of descriptor sets allocated from the pool must not overflow the pool. + /// - You must ensure that the allocated descriptor sets are no longer in use when the pool + /// is destroyed, as destroying the pool is equivalent to freeing all the sets. + /// + #[inline] + pub unsafe fn alloc<'l, I>(&mut self, layouts: I) + -> Result<UnsafeDescriptorPoolAllocIter, DescriptorPoolAllocError> + where I: IntoIterator<Item = &'l UnsafeDescriptorSetLayout> + { + let layouts: SmallVec<[_; 8]> = layouts + .into_iter() + .map(|l| { + assert_eq!(self.device.internal_object(), + l.device().internal_object(), + "Tried to allocate from a pool with a set layout of a different \ + device"); + l.internal_object() + }) + .collect(); + + self.alloc_impl(&layouts) + } + + // Actual implementation of `alloc`. Separated so that it is not inlined. + unsafe fn alloc_impl(&mut self, layouts: &SmallVec<[vk::DescriptorSetLayout; 8]>) + -> Result<UnsafeDescriptorPoolAllocIter, DescriptorPoolAllocError> { + let num = layouts.len(); + + if num == 0 { + return Ok(UnsafeDescriptorPoolAllocIter { sets: vec![].into_iter() }); + } + + let infos = vk::DescriptorSetAllocateInfo { + sType: vk::STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, + pNext: ptr::null(), + descriptorPool: self.pool, + descriptorSetCount: layouts.len() as u32, + pSetLayouts: layouts.as_ptr(), + }; + + let mut output = Vec::with_capacity(num); + + let vk = self.device.pointers(); + let ret = + vk.AllocateDescriptorSets(self.device.internal_object(), &infos, output.as_mut_ptr()); + + // According to the specs, because `VK_ERROR_FRAGMENTED_POOL` was added after version + // 1.0 of Vulkan, any negative return value except out-of-memory errors must be + // considered as a fragmented pool error. + match ret { + vk::ERROR_OUT_OF_HOST_MEMORY => { + return Err(DescriptorPoolAllocError::OutOfHostMemory); + }, + vk::ERROR_OUT_OF_DEVICE_MEMORY => { + return Err(DescriptorPoolAllocError::OutOfDeviceMemory); + }, + vk::ERROR_OUT_OF_POOL_MEMORY_KHR => { + return Err(DescriptorPoolAllocError::OutOfPoolMemory); + }, + c if (c as i32) < 0 => { + return Err(DescriptorPoolAllocError::FragmentedPool); + }, + _ => (), + }; + + output.set_len(num); + + Ok(UnsafeDescriptorPoolAllocIter { sets: output.into_iter() }) + } + + /// Frees some descriptor sets. + /// + /// Note that it is not mandatory to free sets. Destroying or resetting the pool destroys all + /// the descriptor sets. + /// + /// # Safety + /// + /// - The pool must have been created with `free_descriptor_set_bit` set to `true`. + /// - The descriptor sets must have been allocated from the pool. + /// - The descriptor sets must not be free'd twice. + /// - The descriptor sets must not be in use by the GPU. + /// + #[inline] + pub unsafe fn free<I>(&mut self, descriptor_sets: I) -> Result<(), OomError> + where I: IntoIterator<Item = UnsafeDescriptorSet> + { + let sets: SmallVec<[_; 8]> = descriptor_sets.into_iter().map(|s| s.set).collect(); + if !sets.is_empty() { + self.free_impl(&sets) + } else { + Ok(()) + } + } + + // Actual implementation of `free`. Separated so that it is not inlined. + unsafe fn free_impl(&mut self, sets: &SmallVec<[vk::DescriptorSet; 8]>) + -> Result<(), OomError> { + let vk = self.device.pointers(); + check_errors(vk.FreeDescriptorSets(self.device.internal_object(), + self.pool, + sets.len() as u32, + sets.as_ptr()))?; + Ok(()) + } + + /// Resets the pool. + /// + /// This destroys all descriptor sets and empties the pool. + pub unsafe fn reset(&mut self) -> Result<(), OomError> { + let vk = self.device.pointers(); + check_errors(vk.ResetDescriptorPool(self.device.internal_object(), + self.pool, + 0 /* reserved flags */))?; + Ok(()) + } +} + +unsafe impl DeviceOwned for UnsafeDescriptorPool { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl fmt::Debug for UnsafeDescriptorPool { + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fmt.debug_struct("UnsafeDescriptorPool") + .field("raw", &self.pool) + .field("device", &self.device) + .finish() + } +} + +impl Drop for UnsafeDescriptorPool { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyDescriptorPool(self.device.internal_object(), self.pool, ptr::null()); + } + } +} + +/// Error that can be returned when creating a device. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum DescriptorPoolAllocError { + /// There is no memory available on the host (ie. the CPU, RAM, etc.). + OutOfHostMemory, + /// There is no memory available on the device (ie. video memory). + OutOfDeviceMemory, + /// Allocation has failed because the pool is too fragmented. + FragmentedPool, + /// There is no more space available in the descriptor pool. + OutOfPoolMemory, +} + +impl error::Error for DescriptorPoolAllocError { + #[inline] + fn description(&self) -> &str { + match *self { + DescriptorPoolAllocError::OutOfHostMemory => { + "no memory available on the host" + }, + DescriptorPoolAllocError::OutOfDeviceMemory => { + "no memory available on the graphical device" + }, + DescriptorPoolAllocError::FragmentedPool => { + "allocation has failed because the pool is too fragmented" + }, + DescriptorPoolAllocError::OutOfPoolMemory => { + "there is no more space available in the descriptor pool" + }, + } + } +} + +impl fmt::Display for DescriptorPoolAllocError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +/// Iterator to the descriptor sets allocated from an unsafe descriptor pool. +#[derive(Debug)] +pub struct UnsafeDescriptorPoolAllocIter { + sets: VecIntoIter<vk::DescriptorSet>, +} + +impl Iterator for UnsafeDescriptorPoolAllocIter { + type Item = UnsafeDescriptorSet; + + #[inline] + fn next(&mut self) -> Option<UnsafeDescriptorSet> { + self.sets.next().map(|s| UnsafeDescriptorSet { set: s }) + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + self.sets.size_hint() + } +} + +impl ExactSizeIterator for UnsafeDescriptorPoolAllocIter { +} + +/// Low-level descriptor set. +/// +/// Contrary to most other objects in this library, this one doesn't free itself automatically and +/// doesn't hold the pool or the device it is associated to. +/// Instead it is an object meant to be used with the `UnsafeDescriptorPool`. +pub struct UnsafeDescriptorSet { + set: vk::DescriptorSet, +} + +impl UnsafeDescriptorSet { + // TODO: add copying from other descriptor sets + // add a `copy` method that just takes a copy, and an `update` method that takes both + // writes and copies and that actually performs the operation + + /// Modifies a descriptor set. Doesn't check that the writes or copies are correct, and + /// doesn't check whether the descriptor set is in use. + /// + /// **Important**: You must ensure that the `UnsafeDescriptorSetLayout` object is alive before + /// updating a descriptor set. + /// + /// # Safety + /// + /// - The `Device` must be the device the pool of this set was created with. + /// - The `UnsafeDescriptorSetLayout` object this set was created with must be alive. + /// - Doesn't verify that the things you write in the descriptor set match its layout. + /// - Doesn't keep the resources alive. You have to do that yourself. + /// - Updating a descriptor set obeys synchronization rules that aren't checked here. Once a + /// command buffer contains a pointer/reference to a descriptor set, it is illegal to write + /// to it. + /// + pub unsafe fn write<I>(&mut self, device: &Device, writes: I) + where I: Iterator<Item = DescriptorWrite> + { + let vk = device.pointers(); + + // In this function, we build 4 arrays: one array of image descriptors (image_descriptors), + // one for buffer descriptors (buffer_descriptors), one for buffer view descriptors + // (buffer_views_descriptors), and one for the final list of writes (raw_writes). + // Only the final list is passed to Vulkan, but it will contain pointers to the first three + // lists in `pImageInfo`, `pBufferInfo` and `pTexelBufferView`. + // + // In order to handle that, we start by writing null pointers as placeholders in the final + // writes, and we store in `raw_writes_img_infos`, `raw_writes_buf_infos` and + // `raw_writes_buf_view_infos` the offsets of the pointers compared to the start of the + // list. + // Once we have finished iterating all the writes requested by the user, we modify + // `raw_writes` to point to the correct locations. + + let mut buffer_descriptors: SmallVec<[_; 64]> = SmallVec::new(); + let mut image_descriptors: SmallVec<[_; 64]> = SmallVec::new(); + let mut buffer_views_descriptors: SmallVec<[_; 64]> = SmallVec::new(); + + let mut raw_writes: SmallVec<[_; 64]> = SmallVec::new(); + let mut raw_writes_img_infos: SmallVec<[_; 64]> = SmallVec::new(); + let mut raw_writes_buf_infos: SmallVec<[_; 64]> = SmallVec::new(); + let mut raw_writes_buf_view_infos: SmallVec<[_; 64]> = SmallVec::new(); + + for indiv_write in writes { + // Since the `DescriptorWrite` objects are built only through functions, we know for + // sure that it's impossible to have an empty descriptor write. + debug_assert!(!indiv_write.inner.is_empty()); + + // The whole struct thats written here is valid, except for pImageInfo, pBufferInfo + // and pTexelBufferView which are placeholder values. + raw_writes.push(vk::WriteDescriptorSet { + sType: vk::STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, + pNext: ptr::null(), + dstSet: self.set, + dstBinding: indiv_write.binding, + dstArrayElement: indiv_write.first_array_element, + descriptorCount: indiv_write.inner.len() as u32, + descriptorType: indiv_write.ty() as u32, + pImageInfo: ptr::null(), + pBufferInfo: ptr::null(), + pTexelBufferView: ptr::null(), + }); + + match indiv_write.inner[0] { + DescriptorWriteInner::Sampler(_) | + DescriptorWriteInner::CombinedImageSampler(_, _, _) | + DescriptorWriteInner::SampledImage(_, _) | + DescriptorWriteInner::StorageImage(_, _) | + DescriptorWriteInner::InputAttachment(_, _) => { + raw_writes_img_infos.push(Some(image_descriptors.len())); + raw_writes_buf_infos.push(None); + raw_writes_buf_view_infos.push(None); + }, + DescriptorWriteInner::UniformBuffer(_, _, _) | + DescriptorWriteInner::StorageBuffer(_, _, _) | + DescriptorWriteInner::DynamicUniformBuffer(_, _, _) | + DescriptorWriteInner::DynamicStorageBuffer(_, _, _) => { + raw_writes_img_infos.push(None); + raw_writes_buf_infos.push(Some(buffer_descriptors.len())); + raw_writes_buf_view_infos.push(None); + }, + DescriptorWriteInner::UniformTexelBuffer(_) | + DescriptorWriteInner::StorageTexelBuffer(_) => { + raw_writes_img_infos.push(None); + raw_writes_buf_infos.push(None); + raw_writes_buf_view_infos.push(Some(buffer_views_descriptors.len())); + }, + } + + for elem in indiv_write.inner.iter() { + match *elem { + DescriptorWriteInner::UniformBuffer(buffer, offset, size) | + DescriptorWriteInner::DynamicUniformBuffer(buffer, offset, size) => { + buffer_descriptors.push(vk::DescriptorBufferInfo { + buffer: buffer, + offset: offset as u64, + range: size as u64, + }); + }, + DescriptorWriteInner::StorageBuffer(buffer, offset, size) | + DescriptorWriteInner::DynamicStorageBuffer(buffer, offset, size) => { + buffer_descriptors.push(vk::DescriptorBufferInfo { + buffer: buffer, + offset: offset as u64, + range: size as u64, + }); + }, + DescriptorWriteInner::Sampler(sampler) => { + image_descriptors.push(vk::DescriptorImageInfo { + sampler: sampler, + imageView: 0, + imageLayout: 0, + }); + }, + DescriptorWriteInner::CombinedImageSampler(sampler, view, layout) => { + image_descriptors.push(vk::DescriptorImageInfo { + sampler: sampler, + imageView: view, + imageLayout: layout, + }); + }, + DescriptorWriteInner::StorageImage(view, layout) => { + image_descriptors.push(vk::DescriptorImageInfo { + sampler: 0, + imageView: view, + imageLayout: layout, + }); + }, + DescriptorWriteInner::SampledImage(view, layout) => { + image_descriptors.push(vk::DescriptorImageInfo { + sampler: 0, + imageView: view, + imageLayout: layout, + }); + }, + DescriptorWriteInner::InputAttachment(view, layout) => { + image_descriptors.push(vk::DescriptorImageInfo { + sampler: 0, + imageView: view, + imageLayout: layout, + }); + }, + DescriptorWriteInner::UniformTexelBuffer(view) | + DescriptorWriteInner::StorageTexelBuffer(view) => { + buffer_views_descriptors.push(view); + }, + } + } + } + + // Now that `image_descriptors`, `buffer_descriptors` and `buffer_views_descriptors` are + // entirely filled and will never move again, we can fill the pointers in `raw_writes`. + for (i, write) in raw_writes.iter_mut().enumerate() { + write.pImageInfo = match raw_writes_img_infos[i] { + Some(off) => image_descriptors.as_ptr().offset(off as isize), + None => ptr::null(), + }; + + write.pBufferInfo = match raw_writes_buf_infos[i] { + Some(off) => buffer_descriptors.as_ptr().offset(off as isize), + None => ptr::null(), + }; + + write.pTexelBufferView = match raw_writes_buf_view_infos[i] { + Some(off) => buffer_views_descriptors.as_ptr().offset(off as isize), + None => ptr::null(), + }; + } + + // It is forbidden to call `vkUpdateDescriptorSets` with 0 writes, so we need to perform + // this emptiness check. + if !raw_writes.is_empty() { + vk.UpdateDescriptorSets(device.internal_object(), + raw_writes.len() as u32, + raw_writes.as_ptr(), + 0, + ptr::null()); + } + } +} + +unsafe impl VulkanObject for UnsafeDescriptorSet { + type Object = vk::DescriptorSet; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT; + + #[inline] + fn internal_object(&self) -> vk::DescriptorSet { + self.set + } +} + +impl fmt::Debug for UnsafeDescriptorSet { + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan descriptor set {:?}>", self.set) + } +} + +/// Represents a single write entry to a descriptor set. +/// +/// Use the various constructors to build a `DescriptorWrite`. While it is safe to build a +/// `DescriptorWrite`, it is unsafe to actually use it to write to a descriptor set. +// TODO: allow binding whole arrays at once +pub struct DescriptorWrite { + binding: u32, + first_array_element: u32, + inner: SmallVec<[DescriptorWriteInner; 1]>, +} + +#[derive(Debug, Clone)] +enum DescriptorWriteInner { + Sampler(vk::Sampler), + StorageImage(vk::ImageView, vk::ImageLayout), + SampledImage(vk::ImageView, vk::ImageLayout), + CombinedImageSampler(vk::Sampler, vk::ImageView, vk::ImageLayout), + UniformTexelBuffer(vk::BufferView), + StorageTexelBuffer(vk::BufferView), + UniformBuffer(vk::Buffer, usize, usize), + StorageBuffer(vk::Buffer, usize, usize), + DynamicUniformBuffer(vk::Buffer, usize, usize), + DynamicStorageBuffer(vk::Buffer, usize, usize), + InputAttachment(vk::ImageView, vk::ImageLayout), +} + +macro_rules! smallvec { + ($elem:expr) => ({ let mut s = SmallVec::new(); s.push($elem); s }); +} + +impl DescriptorWrite { + #[inline] + pub fn storage_image<I>(binding: u32, array_element: u32, image: &I) -> DescriptorWrite + where I: ImageViewAccess + { + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!({ + let layout = image.descriptor_set_storage_image_layout() as u32; + DescriptorWriteInner::StorageImage(image.inner().internal_object(), + layout) + }), + } + } + + #[inline] + pub fn sampler(binding: u32, array_element: u32, sampler: &Arc<Sampler>) -> DescriptorWrite { + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!(DescriptorWriteInner::Sampler(sampler.internal_object())), + } + } + + #[inline] + pub fn sampled_image<I>(binding: u32, array_element: u32, image: &I) -> DescriptorWrite + where I: ImageViewAccess + { + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!({ + let layout = image.descriptor_set_sampled_image_layout() as u32; + DescriptorWriteInner::SampledImage(image.inner().internal_object(), + layout) + }), + } + } + + #[inline] + pub fn combined_image_sampler<I>(binding: u32, array_element: u32, sampler: &Arc<Sampler>, + image: &I) + -> DescriptorWrite + where I: ImageViewAccess + { + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!({ + let layout = + image.descriptor_set_combined_image_sampler_layout() as u32; + DescriptorWriteInner::CombinedImageSampler(sampler + .internal_object(), + image + .inner() + .internal_object(), + layout) + }), + } + } + + #[inline] + pub fn uniform_texel_buffer<'a, F, B>(binding: u32, array_element: u32, view: &BufferView<F, B>) + -> DescriptorWrite + where B: BufferAccess + { + assert!(view.uniform_texel_buffer()); + + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!(DescriptorWriteInner::UniformTexelBuffer(view.internal_object())), + } + } + + #[inline] + pub fn storage_texel_buffer<'a, F, B>(binding: u32, array_element: u32, view: &BufferView<F, B>) + -> DescriptorWrite + where B: BufferAccess + { + assert!(view.storage_texel_buffer()); + + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!(DescriptorWriteInner::StorageTexelBuffer(view.internal_object())), + } + } + + #[inline] + pub unsafe fn uniform_buffer<B>(binding: u32, array_element: u32, buffer: &B) -> DescriptorWrite + where B: BufferAccess + { + let size = buffer.size(); + let BufferInner { buffer, offset } = buffer.inner(); + + debug_assert_eq!(offset % + buffer + .device() + .physical_device() + .limits() + .min_uniform_buffer_offset_alignment() as + usize, + 0); + debug_assert!(size <= + buffer + .device() + .physical_device() + .limits() + .max_uniform_buffer_range() as usize); + + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!({ + DescriptorWriteInner::UniformBuffer(buffer.internal_object(), + offset, + size) + }), + } + } + + #[inline] + pub unsafe fn storage_buffer<B>(binding: u32, array_element: u32, buffer: &B) -> DescriptorWrite + where B: BufferAccess + { + let size = buffer.size(); + let BufferInner { buffer, offset } = buffer.inner(); + + debug_assert_eq!(offset % + buffer + .device() + .physical_device() + .limits() + .min_storage_buffer_offset_alignment() as + usize, + 0); + debug_assert!(size <= + buffer + .device() + .physical_device() + .limits() + .max_storage_buffer_range() as usize); + + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!({ + DescriptorWriteInner::StorageBuffer(buffer.internal_object(), + offset, + size) + }), + } + } + + #[inline] + pub unsafe fn dynamic_uniform_buffer<B>(binding: u32, array_element: u32, buffer: &B) + -> DescriptorWrite + where B: BufferAccess + { + let size = buffer.size(); + let BufferInner { buffer, offset } = buffer.inner(); + + debug_assert_eq!(offset % + buffer + .device() + .physical_device() + .limits() + .min_uniform_buffer_offset_alignment() as + usize, + 0); + debug_assert!(size <= + buffer + .device() + .physical_device() + .limits() + .max_uniform_buffer_range() as usize); + + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!(DescriptorWriteInner::DynamicUniformBuffer(buffer.internal_object(), + offset, + size)), + } + } + + #[inline] + pub unsafe fn dynamic_storage_buffer<B>(binding: u32, array_element: u32, buffer: &B) + -> DescriptorWrite + where B: BufferAccess + { + let size = buffer.size(); + let BufferInner { buffer, offset } = buffer.inner(); + + debug_assert_eq!(offset % + buffer + .device() + .physical_device() + .limits() + .min_storage_buffer_offset_alignment() as + usize, + 0); + debug_assert!(size <= + buffer + .device() + .physical_device() + .limits() + .max_storage_buffer_range() as usize); + + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!(DescriptorWriteInner::DynamicStorageBuffer(buffer.internal_object(), + offset, + size)), + } + } + + #[inline] + pub fn input_attachment<I>(binding: u32, array_element: u32, image: &I) -> DescriptorWrite + where I: ImageViewAccess + { + DescriptorWrite { + binding: binding, + first_array_element: array_element, + inner: smallvec!({ + let layout = image.descriptor_set_input_attachment_layout() as u32; + DescriptorWriteInner::InputAttachment(image + .inner() + .internal_object(), + layout) + }), + } + } + + /// Returns the type corresponding to this write. + #[inline] + pub fn ty(&self) -> DescriptorType { + match self.inner[0] { + DescriptorWriteInner::Sampler(_) => DescriptorType::Sampler, + DescriptorWriteInner::CombinedImageSampler(_, _, _) => + DescriptorType::CombinedImageSampler, + DescriptorWriteInner::SampledImage(_, _) => DescriptorType::SampledImage, + DescriptorWriteInner::StorageImage(_, _) => DescriptorType::StorageImage, + DescriptorWriteInner::UniformTexelBuffer(_) => DescriptorType::UniformTexelBuffer, + DescriptorWriteInner::StorageTexelBuffer(_) => DescriptorType::StorageTexelBuffer, + DescriptorWriteInner::UniformBuffer(_, _, _) => DescriptorType::UniformBuffer, + DescriptorWriteInner::StorageBuffer(_, _, _) => DescriptorType::StorageBuffer, + DescriptorWriteInner::DynamicUniformBuffer(_, _, _) => + DescriptorType::UniformBufferDynamic, + DescriptorWriteInner::DynamicStorageBuffer(_, _, _) => + DescriptorType::StorageBufferDynamic, + DescriptorWriteInner::InputAttachment(_, _) => DescriptorType::InputAttachment, + } + } +} + +#[cfg(test)] +mod tests { + use descriptor::descriptor::DescriptorBufferDesc; + use descriptor::descriptor::DescriptorDesc; + use descriptor::descriptor::DescriptorDescTy; + use descriptor::descriptor::ShaderStages; + use descriptor::descriptor_set::DescriptorsCount; + use descriptor::descriptor_set::UnsafeDescriptorPool; + use descriptor::descriptor_set::UnsafeDescriptorSetLayout; + use std::iter; + + #[test] + fn pool_create() { + let (device, _) = gfx_dev_and_queue!(); + let desc = DescriptorsCount { + uniform_buffer: 1, + ..DescriptorsCount::zero() + }; + + let _ = UnsafeDescriptorPool::new(device, &desc, 10, false).unwrap(); + } + + #[test] + fn zero_max_set() { + let (device, _) = gfx_dev_and_queue!(); + let desc = DescriptorsCount { + uniform_buffer: 1, + ..DescriptorsCount::zero() + }; + + assert_should_panic!("The maximum number of sets can't be 0", { + let _ = UnsafeDescriptorPool::new(device, &desc, 0, false); + }); + } + + #[test] + fn zero_descriptors() { + let (device, _) = gfx_dev_and_queue!(); + + assert_should_panic!("All the descriptors count of a pool are 0", { + let _ = UnsafeDescriptorPool::new(device, &DescriptorsCount::zero(), 10, false); + }); + } + + #[test] + fn basic_alloc() { + let (device, _) = gfx_dev_and_queue!(); + + let layout = DescriptorDesc { + ty: DescriptorDescTy::Buffer(DescriptorBufferDesc { + dynamic: Some(false), + storage: false, + }), + array_count: 1, + stages: ShaderStages::all_graphics(), + readonly: true, + }; + + let set_layout = UnsafeDescriptorSetLayout::new(device.clone(), iter::once(Some(layout))) + .unwrap(); + + let desc = DescriptorsCount { + uniform_buffer: 10, + ..DescriptorsCount::zero() + }; + + let mut pool = UnsafeDescriptorPool::new(device, &desc, 10, false).unwrap(); + unsafe { + let sets = pool.alloc(iter::once(&set_layout)).unwrap(); + assert_eq!(sets.count(), 1); + } + } + + #[test] + fn alloc_diff_device() { + let (device1, _) = gfx_dev_and_queue!(); + let (device2, _) = gfx_dev_and_queue!(); + + let layout = DescriptorDesc { + ty: DescriptorDescTy::Buffer(DescriptorBufferDesc { + dynamic: Some(false), + storage: false, + }), + array_count: 1, + stages: ShaderStages::all_graphics(), + readonly: true, + }; + + let set_layout = UnsafeDescriptorSetLayout::new(device1, iter::once(Some(layout))).unwrap(); + + let desc = DescriptorsCount { + uniform_buffer: 10, + ..DescriptorsCount::zero() + }; + + assert_should_panic!("Tried to allocate from a pool with a set layout \ + of a different device", + { + let mut pool = + UnsafeDescriptorPool::new(device2, &desc, 10, false).unwrap(); + + unsafe { + let _ = pool.alloc(iter::once(&set_layout)); + } + }); + } + + #[test] + fn alloc_zero() { + let (device, _) = gfx_dev_and_queue!(); + + let desc = DescriptorsCount { + uniform_buffer: 1, + ..DescriptorsCount::zero() + }; + + let mut pool = UnsafeDescriptorPool::new(device, &desc, 1, false).unwrap(); + unsafe { + let sets = pool.alloc(iter::empty()).unwrap(); + assert_eq!(sets.count(), 0); + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/unsafe_layout.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/unsafe_layout.rs new file mode 100644 index 0000000..dc23bc5 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/descriptor_set/unsafe_layout.rs @@ -0,0 +1,186 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::fmt; +use std::mem; +use std::ptr; +use std::sync::Arc; + +use OomError; +use VulkanObject; +use check_errors; +use vk; + +use descriptor::descriptor::DescriptorDesc; +use descriptor::descriptor_set::DescriptorsCount; +use device::Device; +use device::DeviceOwned; + +/// Describes to the Vulkan implementation the layout of all descriptors within a descriptor set. +/// +/// Despite its name, this type is technically not unsafe. However it serves the same purpose +/// in the API as other types whose names start with `Unsafe`. Using the same naming scheme avoids +/// confusions. +pub struct UnsafeDescriptorSetLayout { + // The layout. + layout: vk::DescriptorSetLayout, + // The device this layout belongs to. + device: Arc<Device>, + // Number of descriptors. + descriptors_count: DescriptorsCount, +} + +impl UnsafeDescriptorSetLayout { + /// Builds a new `UnsafeDescriptorSetLayout` with the given descriptors. + /// + /// The descriptors must be passed in the order of the bindings. In order words, descriptor + /// at bind point 0 first, then descriptor at bind point 1, and so on. If a binding must remain + /// empty, you can make the iterator yield `None` for an element. + pub fn new<I>(device: Arc<Device>, descriptors: I) + -> Result<UnsafeDescriptorSetLayout, OomError> + where I: IntoIterator<Item = Option<DescriptorDesc>> + { + let mut descriptors_count = DescriptorsCount::zero(); + + let bindings = descriptors + .into_iter() + .enumerate() + .filter_map(|(binding, desc)| { + let desc = match desc { + Some(d) => d, + None => return None, + }; + + // FIXME: it is not legal to pass eg. the TESSELLATION_SHADER bit when the device + // doesn't have tess shaders enabled + + let ty = desc.ty.ty().unwrap(); // TODO: shouldn't panic + descriptors_count.add_one(ty); + + Some(vk::DescriptorSetLayoutBinding { + binding: binding as u32, + descriptorType: ty as u32, + descriptorCount: desc.array_count, + stageFlags: desc.stages.into_vulkan_bits(), + pImmutableSamplers: ptr::null(), // FIXME: not yet implemented + }) + }) + .collect::<SmallVec<[_; 32]>>(); + + // Note that it seems legal to have no descriptor at all in the set. + + let layout = unsafe { + let infos = vk::DescriptorSetLayoutCreateInfo { + sType: vk::STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + bindingCount: bindings.len() as u32, + pBindings: bindings.as_ptr(), + }; + + let mut output = mem::uninitialized(); + let vk = device.pointers(); + check_errors(vk.CreateDescriptorSetLayout(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(UnsafeDescriptorSetLayout { + layout: layout, + device: device, + descriptors_count: descriptors_count, + }) + } + + /// Returns the number of descriptors of each type. + #[inline] + pub fn descriptors_count(&self) -> &DescriptorsCount { + &self.descriptors_count + } +} + +unsafe impl DeviceOwned for UnsafeDescriptorSetLayout { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl fmt::Debug for UnsafeDescriptorSetLayout { + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fmt.debug_struct("UnsafeDescriptorSetLayout") + .field("raw", &self.layout) + .field("device", &self.device) + .finish() + } +} + +unsafe impl VulkanObject for UnsafeDescriptorSetLayout { + type Object = vk::DescriptorSetLayout; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT; + + #[inline] + fn internal_object(&self) -> vk::DescriptorSetLayout { + self.layout + } +} + +impl Drop for UnsafeDescriptorSetLayout { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyDescriptorSetLayout(self.device.internal_object(), self.layout, ptr::null()); + } + } +} + +#[cfg(test)] +mod tests { + use descriptor::descriptor::DescriptorBufferDesc; + use descriptor::descriptor::DescriptorDesc; + use descriptor::descriptor::DescriptorDescTy; + use descriptor::descriptor::ShaderStages; + use descriptor::descriptor_set::DescriptorsCount; + use descriptor::descriptor_set::UnsafeDescriptorSetLayout; + use std::iter; + + #[test] + fn empty() { + let (device, _) = gfx_dev_and_queue!(); + let _layout = UnsafeDescriptorSetLayout::new(device, iter::empty()); + } + + #[test] + fn basic_create() { + let (device, _) = gfx_dev_and_queue!(); + + let layout = DescriptorDesc { + ty: DescriptorDescTy::Buffer(DescriptorBufferDesc { + dynamic: Some(false), + storage: false, + }), + array_count: 1, + stages: ShaderStages::all_graphics(), + readonly: true, + }; + + let sl = UnsafeDescriptorSetLayout::new(device.clone(), iter::once(Some(layout))).unwrap(); + + assert_eq!(sl.descriptors_count(), + &DescriptorsCount { + uniform_buffer: 1, + ..DescriptorsCount::zero() + }); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/mod.rs new file mode 100644 index 0000000..10322b4 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/mod.rs @@ -0,0 +1,91 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Provides a way for shaders to access the content of buffers and images, or read arbitrary data. +//! +//! If you except vertex attributes, there are two ways in Vulkan to pass data to a shader: +//! +//! - You can pass a very small amount of data (only a guaranteed 128 bytes) through the *push +//! constants* mechanism. Push constants are the fastest and easiest way to pass data. +//! - You can make your shader read from a buffer or an image by binding it to a *descriptor*. +//! +//! Here is an example fragment shader in GLSL that uses both: +//! +//! ```ignore +//! #version 450 +//! +//! // This is a descriptor that contains a texture. +//! layout(set = 0, binding = 0) uniform sampler2D u_texture; +//! +//! // This is a descriptor that contains a buffer. +//! layout(set = 0, binding = 1) uniform struct { +//! int data[128]; +//! } u_buffer; +//! +//! layout(push_constant) uniform PushConstants { +//! // This is a push constant. +//! float opacity; +//! } push_constants; +//! +//! layout(location = 0) in vec2 v_tex_coords; +//! layout(location = 0) out vec4 f_output; +//! +//! void main() { +//! f_output.rgb = texture(u_texture, v_tex_coords).rgb; +//! if (u_buffer.data[12] == 5) { f_output.rgb *= 2.0; } +//! f_output.a = push_constants.opacity; +//! } +//! ``` +//! +//! # Descriptors +//! +//! In order to read the content of a buffer or an image from a shader, that buffer or image +//! must be put in a *descriptor*. Each descriptor contains one buffer or one image alongside with +//! the way that it can be accessed. A descriptor can also be an array, in which case it contains +//! multiple buffers or images that all have the same layout. +//! +//! Descriptors are grouped in what is called *descriptor sets*. In Vulkan you don't bind +//! individual descriptors one by one, but you create then bind descriptor sets one by one. As +//! binding a descriptor set has (small but non-null) a cost, you are encouraged to put descriptors +//! that are often used together in the same set so that you can keep the same set binding through +//! multiple draws. +//! +//! # Example +//! +//! > **Note**: This section describes the simple way to bind resources. There are more optimized +//! > ways. +//! +//! There are two steps to give access to a resource in a shader: creating the descriptor set, and +//! passing the descriptor sets when drawing. +//! +//! ## Creating a descriptor set +//! +//! ```ignore +//! // TODO: write example for: PersistentDescriptorSet::start(pipeline.clone(), 0).add_buffer(data_buffer.clone()) +//! ``` +//! +//! ## Passing the descriptor set when drawing +//! +//! TODO: write +//! +//! # When drawing +//! +//! When you call a function that adds a draw command to a command buffer, one of the parameters +//! corresponds to the list of descriptor sets to use, and another parameter contains the push +//! constants. Vulkano will check that what you passed is compatible with the layout of the +//! compute or graphics pipeline. +//! +//! TODO: talk about perfs of changing sets + +pub use self::descriptor_set::DescriptorSet; +pub use self::pipeline_layout::PipelineLayoutAbstract; + +pub mod descriptor; +pub mod descriptor_set; +pub mod pipeline_layout; diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/empty.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/empty.rs new file mode 100644 index 0000000..9e7b53b --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/empty.rs @@ -0,0 +1,55 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use descriptor::descriptor::DescriptorDesc; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use descriptor::pipeline_layout::PipelineLayoutDescPcRange; + +/// Description of an empty pipeline layout. +/// +/// # Example +/// +/// ``` +/// # use std::sync::Arc; +/// # use vulkano::device::Device; +/// use vulkano::descriptor::pipeline_layout::EmptyPipelineDesc; +/// use vulkano::descriptor::pipeline_layout::PipelineLayoutDesc; +/// +/// # let device: Arc<Device> = return; +/// let pipeline_layout = EmptyPipelineDesc.build(device.clone()).unwrap(); +/// ``` +#[derive(Debug, Copy, Clone)] +pub struct EmptyPipelineDesc; + +unsafe impl PipelineLayoutDesc for EmptyPipelineDesc { + #[inline] + fn num_sets(&self) -> usize { + 0 + } + + #[inline] + fn num_bindings_in_set(&self, _: usize) -> Option<usize> { + None + } + + #[inline] + fn descriptor(&self, _: usize, _: usize) -> Option<DescriptorDesc> { + None + } + + #[inline] + fn num_push_constants_ranges(&self) -> usize { + 0 + } + + #[inline] + fn push_constants_range(&self, _: usize) -> Option<PipelineLayoutDescPcRange> { + None + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/limits_check.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/limits_check.rs new file mode 100644 index 0000000..1fcb297 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/limits_check.rs @@ -0,0 +1,483 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Contains the `check_desc_against_limits` function and the `PipelineLayoutLimitsError` error. + +use std::error; +use std::fmt; + +use descriptor::descriptor::DescriptorType; +use descriptor::descriptor::ShaderStages; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use descriptor::pipeline_layout::PipelineLayoutDescPcRange; +use instance::Limits; + +/// Checks whether the pipeline layout description fulfills the device limits requirements. +pub fn check_desc_against_limits<D>(desc: &D, limits: Limits) + -> Result<(), PipelineLayoutLimitsError> + where D: ?Sized + PipelineLayoutDesc +{ + let mut num_resources = Counter::default(); + let mut num_samplers = Counter::default(); + let mut num_uniform_buffers = Counter::default(); + let mut num_uniform_buffers_dynamic = 0; + let mut num_storage_buffers = Counter::default(); + let mut num_storage_buffers_dynamic = 0; + let mut num_sampled_images = Counter::default(); + let mut num_storage_images = Counter::default(); + let mut num_input_attachments = Counter::default(); + + for set in 0 .. desc.num_sets() { + let num_bindings_in_set = match desc.num_bindings_in_set(set) { + None => continue, + Some(n) => n, + }; + + for binding in 0 .. num_bindings_in_set { + let descriptor = match desc.descriptor(set, binding) { + None => continue, + Some(n) => n, + }; + + num_resources.increment(descriptor.array_count, &descriptor.stages); + + match descriptor.ty.ty().expect("Not implemented yet") { // TODO: + DescriptorType::Sampler => { + num_samplers.increment(descriptor.array_count, &descriptor.stages); + }, + DescriptorType::CombinedImageSampler => { + num_samplers.increment(descriptor.array_count, &descriptor.stages); + num_sampled_images.increment(descriptor.array_count, &descriptor.stages); + }, + DescriptorType::SampledImage | + DescriptorType::UniformTexelBuffer => { + num_sampled_images.increment(descriptor.array_count, &descriptor.stages); + }, + DescriptorType::StorageImage | + DescriptorType::StorageTexelBuffer => { + num_storage_images.increment(descriptor.array_count, &descriptor.stages); + }, + DescriptorType::UniformBuffer => { + num_uniform_buffers.increment(descriptor.array_count, &descriptor.stages); + }, + DescriptorType::UniformBufferDynamic => { + num_uniform_buffers.increment(descriptor.array_count, &descriptor.stages); + num_uniform_buffers_dynamic += 1; + }, + DescriptorType::StorageBuffer => { + num_storage_buffers.increment(descriptor.array_count, &descriptor.stages); + }, + DescriptorType::StorageBufferDynamic => { + num_storage_buffers.increment(descriptor.array_count, &descriptor.stages); + num_storage_buffers_dynamic += 1; + }, + DescriptorType::InputAttachment => { + num_input_attachments.increment(descriptor.array_count, &descriptor.stages); + }, + } + } + } + + if desc.num_sets() > limits.max_bound_descriptor_sets() as usize { + return Err(PipelineLayoutLimitsError::MaxDescriptorSetsLimitExceeded { + limit: limits.max_bound_descriptor_sets() as usize, + requested: desc.num_sets(), + }); + } + + if num_resources.max_per_stage() > limits.max_per_stage_resources() { + return Err(PipelineLayoutLimitsError::MaxPerStageResourcesLimitExceeded { + limit: limits.max_per_stage_resources(), + requested: num_resources.max_per_stage(), + }); + } + + if num_samplers.max_per_stage() > limits.max_per_stage_descriptor_samplers() { + return Err(PipelineLayoutLimitsError::MaxPerStageDescriptorSamplersLimitExceeded { + limit: limits.max_per_stage_descriptor_samplers(), + requested: num_samplers.max_per_stage(), + }); + } + if num_uniform_buffers.max_per_stage() > limits.max_per_stage_descriptor_uniform_buffers() { + return Err(PipelineLayoutLimitsError::MaxPerStageDescriptorUniformBuffersLimitExceeded { + limit: limits.max_per_stage_descriptor_uniform_buffers(), + requested: num_uniform_buffers.max_per_stage(), + }); + } + if num_storage_buffers.max_per_stage() > limits.max_per_stage_descriptor_storage_buffers() { + return Err(PipelineLayoutLimitsError::MaxPerStageDescriptorStorageBuffersLimitExceeded { + limit: limits.max_per_stage_descriptor_storage_buffers(), + requested: num_storage_buffers.max_per_stage(), + }); + } + if num_sampled_images.max_per_stage() > limits.max_per_stage_descriptor_sampled_images() { + return Err(PipelineLayoutLimitsError::MaxPerStageDescriptorSampledImagesLimitExceeded { + limit: limits.max_per_stage_descriptor_sampled_images(), + requested: num_sampled_images.max_per_stage(), + }); + } + if num_storage_images.max_per_stage() > limits.max_per_stage_descriptor_storage_images() { + return Err(PipelineLayoutLimitsError::MaxPerStageDescriptorStorageImagesLimitExceeded { + limit: limits.max_per_stage_descriptor_storage_images(), + requested: num_storage_images.max_per_stage(), + }); + } + if num_input_attachments.max_per_stage() > limits.max_per_stage_descriptor_input_attachments() { + return Err(PipelineLayoutLimitsError::MaxPerStageDescriptorInputAttachmentsLimitExceeded { + limit: limits.max_per_stage_descriptor_input_attachments(), + requested: num_input_attachments.max_per_stage(), + }); + } + + if num_samplers.total > limits.max_descriptor_set_samplers() { + return Err(PipelineLayoutLimitsError::MaxDescriptorSetSamplersLimitExceeded { + limit: limits.max_descriptor_set_samplers(), + requested: num_samplers.total, + }); + } + if num_uniform_buffers.total > limits.max_descriptor_set_uniform_buffers() { + return Err(PipelineLayoutLimitsError::MaxDescriptorSetUniformBuffersLimitExceeded { + limit: limits.max_descriptor_set_uniform_buffers(), + requested: num_uniform_buffers.total, + }); + } + if num_uniform_buffers_dynamic > limits.max_descriptor_set_uniform_buffers_dynamic() { + return Err(PipelineLayoutLimitsError::MaxDescriptorSetUniformBuffersDynamicLimitExceeded { + limit: limits.max_descriptor_set_uniform_buffers_dynamic(), + requested: num_uniform_buffers_dynamic, + }); + } + if num_storage_buffers.total > limits.max_descriptor_set_storage_buffers() { + return Err(PipelineLayoutLimitsError::MaxDescriptorSetStorageBuffersLimitExceeded { + limit: limits.max_descriptor_set_storage_buffers(), + requested: num_storage_buffers.total, + }); + } + if num_storage_buffers_dynamic > limits.max_descriptor_set_storage_buffers_dynamic() { + return Err(PipelineLayoutLimitsError::MaxDescriptorSetStorageBuffersDynamicLimitExceeded { + limit: limits.max_descriptor_set_storage_buffers_dynamic(), + requested: num_storage_buffers_dynamic, + }); + } + if num_sampled_images.total > limits.max_descriptor_set_sampled_images() { + return Err(PipelineLayoutLimitsError::MaxDescriptorSetSampledImagesLimitExceeded { + limit: limits.max_descriptor_set_sampled_images(), + requested: num_sampled_images.total, + }); + } + if num_storage_images.total > limits.max_descriptor_set_storage_images() { + return Err(PipelineLayoutLimitsError::MaxDescriptorSetStorageImagesLimitExceeded { + limit: limits.max_descriptor_set_storage_images(), + requested: num_storage_images.total, + }); + } + if num_input_attachments.total > limits.max_descriptor_set_input_attachments() { + return Err(PipelineLayoutLimitsError::MaxDescriptorSetInputAttachmentsLimitExceeded { + limit: limits.max_descriptor_set_input_attachments(), + requested: num_input_attachments.total, + }); + } + + for pc_id in 0 .. desc.num_push_constants_ranges() { + let PipelineLayoutDescPcRange { offset, size, .. } = { + match desc.push_constants_range(pc_id) { + Some(o) => o, + None => continue, + } + }; + + if offset + size > limits.max_push_constants_size() as usize { + return Err(PipelineLayoutLimitsError::MaxPushConstantsSizeExceeded { + limit: limits.max_push_constants_size() as usize, + requested: offset + size, + }); + } + } + + Ok(()) +} + +/// The pipeline layout description isn't compatible with the hardware limits. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum PipelineLayoutLimitsError { + /// The maximum number of descriptor sets has been exceeded. + MaxDescriptorSetsLimitExceeded { + /// The limit that must be fulfilled. + limit: usize, + /// What was requested. + requested: usize, + }, + + /// The maximum size of push constants has been exceeded. + MaxPushConstantsSizeExceeded { + /// The limit that must be fulfilled. + limit: usize, + /// What was requested. + requested: usize, + }, + + /// The `max_per_stage_resources()` limit has been exceeded. + MaxPerStageResourcesLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_per_stage_descriptor_samplers()` limit has been exceeded. + MaxPerStageDescriptorSamplersLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_per_stage_descriptor_uniform_buffers()` limit has been exceeded. + MaxPerStageDescriptorUniformBuffersLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_per_stage_descriptor_storage_buffers()` limit has been exceeded. + MaxPerStageDescriptorStorageBuffersLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_per_stage_descriptor_sampled_images()` limit has been exceeded. + MaxPerStageDescriptorSampledImagesLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_per_stage_descriptor_storage_images()` limit has been exceeded. + MaxPerStageDescriptorStorageImagesLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_per_stage_descriptor_input_attachments()` limit has been exceeded. + MaxPerStageDescriptorInputAttachmentsLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_descriptor_set_samplers()` limit has been exceeded. + MaxDescriptorSetSamplersLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_descriptor_set_uniform_buffers()` limit has been exceeded. + MaxDescriptorSetUniformBuffersLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_descriptor_set_uniform_buffers_dynamic()` limit has been exceeded. + MaxDescriptorSetUniformBuffersDynamicLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_descriptor_set_storage_buffers()` limit has been exceeded. + MaxDescriptorSetStorageBuffersLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_descriptor_set_storage_buffers_dynamic()` limit has been exceeded. + MaxDescriptorSetStorageBuffersDynamicLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_descriptor_set_sampled_images()` limit has been exceeded. + MaxDescriptorSetSampledImagesLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_descriptor_set_storage_images()` limit has been exceeded. + MaxDescriptorSetStorageImagesLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, + + /// The `max_descriptor_set_input_attachments()` limit has been exceeded. + MaxDescriptorSetInputAttachmentsLimitExceeded { + /// The limit that must be fulfilled. + limit: u32, + /// What was requested. + requested: u32, + }, +} + +impl error::Error for PipelineLayoutLimitsError { + #[inline] + fn description(&self) -> &str { + match *self { + PipelineLayoutLimitsError::MaxDescriptorSetsLimitExceeded { .. } => { + "the maximum number of descriptor sets has been exceeded" + }, + PipelineLayoutLimitsError::MaxPushConstantsSizeExceeded { .. } => { + "the maximum size of push constants has been exceeded" + }, + PipelineLayoutLimitsError::MaxPerStageResourcesLimitExceeded { .. } => { + "the `max_per_stage_resources()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxPerStageDescriptorSamplersLimitExceeded { .. } => { + "the `max_per_stage_descriptor_samplers()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxPerStageDescriptorUniformBuffersLimitExceeded { + .. + } => { + "the `max_per_stage_descriptor_uniform_buffers()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxPerStageDescriptorStorageBuffersLimitExceeded { + .. + } => { + "the `max_per_stage_descriptor_storage_buffers()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxPerStageDescriptorSampledImagesLimitExceeded { + .. + } => { + "the `max_per_stage_descriptor_sampled_images()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxPerStageDescriptorStorageImagesLimitExceeded { + .. + } => { + "the `max_per_stage_descriptor_storage_images()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxPerStageDescriptorInputAttachmentsLimitExceeded { + .. + } => { + "the `max_per_stage_descriptor_input_attachments()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxDescriptorSetSamplersLimitExceeded { .. } => { + "the `max_descriptor_set_samplers()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxDescriptorSetUniformBuffersLimitExceeded { .. } => { + "the `max_descriptor_set_uniform_buffers()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxDescriptorSetUniformBuffersDynamicLimitExceeded { + .. + } => { + "the `max_descriptor_set_uniform_buffers_dynamic()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxDescriptorSetStorageBuffersLimitExceeded { .. } => { + "the `max_descriptor_set_storage_buffers()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxDescriptorSetStorageBuffersDynamicLimitExceeded { + .. + } => { + "the `max_descriptor_set_storage_buffers_dynamic()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxDescriptorSetSampledImagesLimitExceeded { .. } => { + "the `max_descriptor_set_sampled_images()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxDescriptorSetStorageImagesLimitExceeded { .. } => { + "the `max_descriptor_set_storage_images()` limit has been exceeded" + }, + PipelineLayoutLimitsError::MaxDescriptorSetInputAttachmentsLimitExceeded { .. } => { + "the `max_descriptor_set_input_attachments()` limit has been exceeded" + }, + } + } +} + +impl fmt::Display for PipelineLayoutLimitsError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +// Helper struct for the main function. +#[derive(Default)] +struct Counter { + total: u32, + compute: u32, + vertex: u32, + geometry: u32, + tess_ctl: u32, + tess_eval: u32, + frag: u32, +} + +impl Counter { + fn increment(&mut self, num: u32, stages: &ShaderStages) { + self.total += num; + if stages.compute { + self.compute += num; + } + if stages.vertex { + self.vertex += num; + } + if stages.tessellation_control { + self.tess_ctl += num; + } + if stages.tessellation_evaluation { + self.tess_eval += num; + } + if stages.geometry { + self.geometry += num; + } + if stages.fragment { + self.frag += num; + } + } + + fn max_per_stage(&self) -> u32 { + let mut max = 0; + if self.compute > max { + max = self.compute; + } + if self.vertex > max { + max = self.vertex; + } + if self.geometry > max { + max = self.geometry; + } + if self.tess_ctl > max { + max = self.tess_ctl; + } + if self.tess_eval > max { + max = self.tess_eval; + } + if self.frag > max { + max = self.frag; + } + max + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/mod.rs new file mode 100644 index 0000000..2e59005 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/mod.rs @@ -0,0 +1,76 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! A pipeline layout describes the layout of descriptors and push constants used by a graphics +//! pipeline or a compute pipeline. +//! +//! The layout itself only *describes* the descriptors and push constants, and does not contain +//! the content of the push constants or the actual list of resources that are going to be +//! available through the descriptors. Push constants are set when you submit a draw command, and +//! the list of resources is set by creating *descriptor set* objects and passing these sets when +//! you submit a draw command. +//! +//! # Pipeline layout objects +//! +//! A pipeline layout is something that you must describe to the Vulkan implementation by creating +//! a **pipeline layout object**, represented by the `PipelineLayout` struct in vulkano. +//! +//! Each graphics pipeline or compute pipeline that you create therefore holds a +//! **pipeline layout object** By default, creating a pipeline automatically builds a new pipeline +//! layout object describing the union of all the descriptors and push constants of all the shaders +//! used by the pipeline. +//! +//! The `PipelineLayout` struct describes the pipeline layout to both the Vulkan implementation and +//! to vulkano. It holds a template parameter whose type must implement the `PipelineLayoutDesc` +//! trait. +//! +//! # The PipelineLayoutAbstract trait +//! +//! All the functions in vulkano that operate on pipeline layout objects (for example, creating a +//! descriptor set) do not take directly a `PipelineLayout` struct as parameter. Instead they can +//! take any object that implements the `PipelineLayoutAbstract` trait. +//! +//! This trait represents any object that holds a `PipelineLayout`. It is implemented on the +//! `PipelineLayout` struct itself (obviously), but also notably on `GraphicsPipeline` and +//! `ComputePipeline`. In other words, you can for example create a descriptor set by passing a +//! graphics pipeline as parameter. +//! +//! # Custom pipeline layouts +//! +//! In some situations, it is better (as in, faster) to share the same descriptor set or sets +//! between multiple pipelines that each use different descriptors. To do so, you have to create a +//! pipeline layout object in advance and pass it when you create the pipelines. +//! +//! TODO: write this section + +pub use self::empty::EmptyPipelineDesc; +pub use self::limits_check::PipelineLayoutLimitsError; +pub use self::runtime_desc::RuntimePipelineDesc; +pub use self::runtime_desc::RuntimePipelineDescError; +pub use self::sys::PipelineLayout; +pub use self::sys::PipelineLayoutCreationError; +pub use self::sys::PipelineLayoutSys; +pub use self::traits::PipelineLayoutAbstract; +pub use self::traits::PipelineLayoutDesc; +pub use self::traits::PipelineLayoutDescPcRange; +pub use self::traits::PipelineLayoutNotSupersetError; +pub use self::traits::PipelineLayoutPushConstantsCompatible; +pub use self::traits::PipelineLayoutSetsCompatible; +pub use self::traits::PipelineLayoutSuperset; +pub use self::union::PipelineLayoutDescUnion; + +pub(crate) use self::tweaks::PipelineLayoutDescTweaks; + +mod empty; +mod limits_check; +mod runtime_desc; +mod sys; +mod traits; +mod union; +mod tweaks; diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/runtime_desc.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/runtime_desc.rs new file mode 100644 index 0000000..41d3c88 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/runtime_desc.rs @@ -0,0 +1,159 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; + +use smallvec::SmallVec; + +use descriptor::descriptor::DescriptorDesc; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use descriptor::pipeline_layout::PipelineLayoutDescPcRange; + +/// Runtime description of a pipeline layout. +#[derive(Debug, Clone)] +pub struct RuntimePipelineDesc { + descriptors: SmallVec<[SmallVec<[Option<DescriptorDesc>; 5]>; 3]>, + push_constants: SmallVec<[PipelineLayoutDescPcRange; 6]>, +} + +impl RuntimePipelineDesc { + /// Builds a new `RuntimePipelineDesc` from the descriptors and push constants descriptions. + pub fn new<TSetsIter, TPushConstsIter, TDescriptorsIter>( + desc: TSetsIter, push_constants: TPushConstsIter) + -> Result<RuntimePipelineDesc, RuntimePipelineDescError> + where TSetsIter: IntoIterator<Item = TDescriptorsIter>, + TDescriptorsIter: IntoIterator<Item = Option<DescriptorDesc>>, + TPushConstsIter: IntoIterator<Item = PipelineLayoutDescPcRange> + { + let descriptors = desc.into_iter().map(|s| s.into_iter().collect()).collect(); + let push_constants: SmallVec<[PipelineLayoutDescPcRange; 6]> = + push_constants.into_iter().collect(); + + for (a_id, a) in push_constants.iter().enumerate() { + for b in push_constants.iter().skip(a_id + 1) { + if a.offset <= b.offset && a.offset + a.size > b.offset { + return Err(RuntimePipelineDescError::PushConstantsConflict { + first_offset: a.offset, + first_size: a.size, + second_offset: b.offset, + }); + } + + if b.offset <= a.offset && b.offset + b.size > a.offset { + return Err(RuntimePipelineDescError::PushConstantsConflict { + first_offset: b.offset, + first_size: b.size, + second_offset: a.offset, + }); + } + } + } + + Ok(RuntimePipelineDesc { + descriptors, + push_constants, + }) + } +} + +unsafe impl PipelineLayoutDesc for RuntimePipelineDesc { + #[inline] + fn num_sets(&self) -> usize { + self.descriptors.len() + } + + #[inline] + fn num_bindings_in_set(&self, set: usize) -> Option<usize> { + self.descriptors.get(set).map(|s| s.len()) + } + + #[inline] + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> { + self.descriptors + .get(set) + .and_then(|s| s.get(binding).cloned().unwrap_or(None)) + } + + #[inline] + fn num_push_constants_ranges(&self) -> usize { + self.push_constants.len() + } + + #[inline] + fn push_constants_range(&self, num: usize) -> Option<PipelineLayoutDescPcRange> { + self.push_constants.get(num).cloned() + } +} + +/// Error when building a persistent descriptor set. +#[derive(Debug, Clone)] +pub enum RuntimePipelineDescError { + /// Conflict between different push constants ranges. + PushConstantsConflict { + first_offset: usize, + first_size: usize, + second_offset: usize, + }, +} + +impl error::Error for RuntimePipelineDescError { + #[inline] + fn description(&self) -> &str { + match *self { + RuntimePipelineDescError::PushConstantsConflict { .. } => { + "conflict between different push constants ranges" + }, + } + } +} + +impl fmt::Display for RuntimePipelineDescError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +#[cfg(test)] +mod tests { + use descriptor::descriptor::DescriptorDesc; + use descriptor::descriptor::ShaderStages; + use descriptor::pipeline_layout::PipelineLayoutDescPcRange; + use descriptor::pipeline_layout::RuntimePipelineDesc; + use descriptor::pipeline_layout::RuntimePipelineDescError; + use std::iter; + + #[test] + fn pc_conflict() { + let range1 = PipelineLayoutDescPcRange { + offset: 0, + size: 8, + stages: ShaderStages::all(), + }; + + let range2 = PipelineLayoutDescPcRange { + offset: 4, + size: 8, + stages: ShaderStages::all(), + }; + + let r = RuntimePipelineDesc::new::<_, _, iter::Empty<Option<DescriptorDesc>>> + (iter::empty(), iter::once(range1).chain(iter::once(range2))); + + match r { + Err(RuntimePipelineDescError::PushConstantsConflict { + first_offset: 0, + first_size: 8, + second_offset: 4, + }) => (), + _ => panic!(), // test failed + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/sys.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/sys.rs new file mode 100644 index 0000000..4da6e79 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/sys.rs @@ -0,0 +1,404 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::error; +use std::fmt; +use std::mem; +use std::ptr; +use std::sync::Arc; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use vk; + +use descriptor::descriptor::DescriptorDesc; +use descriptor::descriptor::ShaderStages; +use descriptor::descriptor_set::UnsafeDescriptorSetLayout; +use descriptor::pipeline_layout::PipelineLayoutAbstract; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use descriptor::pipeline_layout::PipelineLayoutDescPcRange; +use descriptor::pipeline_layout::PipelineLayoutLimitsError; +use device::Device; +use device::DeviceOwned; + +/// Wrapper around the `PipelineLayout` Vulkan object. Describes to the Vulkan implementation the +/// descriptor sets and push constants available to your shaders +pub struct PipelineLayout<L> { + device: Arc<Device>, + layout: vk::PipelineLayout, + layouts: SmallVec<[Arc<UnsafeDescriptorSetLayout>; 16]>, + desc: L, +} + +impl<L> PipelineLayout<L> + where L: PipelineLayoutDesc +{ + /// Creates a new `PipelineLayout`. + /// + /// # Panic + /// + /// - Panics if one of the layout returned by `provided_set_layout()` belongs to a different + /// device than the one passed as parameter. + #[inline] + pub fn new(device: Arc<Device>, desc: L) + -> Result<PipelineLayout<L>, PipelineLayoutCreationError> { + let vk = device.pointers(); + + desc.check_against_limits(&device)?; + + // Building the list of `UnsafeDescriptorSetLayout` objects. + let layouts = { + let mut layouts: SmallVec<[_; 16]> = SmallVec::new(); + for num in 0 .. desc.num_sets() { + layouts.push(match desc.provided_set_layout(num) { + Some(l) => { + assert_eq!(l.device().internal_object(), + device.internal_object()); + l + }, + None => { + let sets_iter = 0 .. + desc.num_bindings_in_set(num).unwrap_or(0); + let desc_iter = sets_iter.map(|d| desc.descriptor(num, d)); + Arc::new(UnsafeDescriptorSetLayout::new(device.clone(), + desc_iter)?) + }, + }); + } + layouts + }; + + // Grab the list of `vkDescriptorSetLayout` objects from `layouts`. + let layouts_ids = layouts + .iter() + .map(|l| l.internal_object()) + .collect::<SmallVec<[_; 16]>>(); + + // Builds a list of `vkPushConstantRange` that describe the push constants. + let push_constants = { + let mut out: SmallVec<[_; 8]> = SmallVec::new(); + + for pc_id in 0 .. desc.num_push_constants_ranges() { + let PipelineLayoutDescPcRange { + offset, + size, + stages, + } = { + match desc.push_constants_range(pc_id) { + Some(o) => o, + None => continue, + } + }; + + if stages == ShaderStages::none() || size == 0 || (size % 4) != 0 { + return Err(PipelineLayoutCreationError::InvalidPushConstant); + } + + out.push(vk::PushConstantRange { + stageFlags: stages.into_vulkan_bits(), + offset: offset as u32, + size: size as u32, + }); + } + + out + }; + + // Each bit of `stageFlags` must only be present in a single push constants range. + // We check that with a debug_assert because it's supposed to be enforced by the + // `PipelineLayoutDesc`. + debug_assert!({ + let mut stages = 0; + let mut outcome = true; + for pc in push_constants.iter() { + if (stages & pc.stageFlags) != 0 { + outcome = false; + break; + } + stages &= pc.stageFlags; + } + outcome + }); + + // FIXME: it is not legal to pass eg. the TESSELLATION_SHADER bit when the device doesn't + // have tess shaders enabled + + // Build the final object. + let layout = unsafe { + let infos = vk::PipelineLayoutCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + setLayoutCount: layouts_ids.len() as u32, + pSetLayouts: layouts_ids.as_ptr(), + pushConstantRangeCount: push_constants.len() as u32, + pPushConstantRanges: push_constants.as_ptr(), + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreatePipelineLayout(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(PipelineLayout { + device: device.clone(), + layout: layout, + layouts: layouts, + desc: desc, + }) + } +} + +impl<L> PipelineLayout<L> + where L: PipelineLayoutDesc +{ + /// Returns the description of the pipeline layout. + #[inline] + pub fn desc(&self) -> &L { + &self.desc + } +} + +unsafe impl<D> PipelineLayoutAbstract for PipelineLayout<D> + where D: PipelineLayoutDesc +{ + #[inline] + fn sys(&self) -> PipelineLayoutSys { + PipelineLayoutSys(&self.layout) + } + + #[inline] + fn descriptor_set_layout(&self, index: usize) -> Option<&Arc<UnsafeDescriptorSetLayout>> { + self.layouts.get(index) + } +} + +unsafe impl<D> PipelineLayoutDesc for PipelineLayout<D> + where D: PipelineLayoutDesc +{ + #[inline] + fn num_sets(&self) -> usize { + self.desc.num_sets() + } + + #[inline] + fn num_bindings_in_set(&self, set: usize) -> Option<usize> { + self.desc.num_bindings_in_set(set) + } + + #[inline] + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> { + self.desc.descriptor(set, binding) + } + + #[inline] + fn num_push_constants_ranges(&self) -> usize { + self.desc.num_push_constants_ranges() + } + + #[inline] + fn push_constants_range(&self, num: usize) -> Option<PipelineLayoutDescPcRange> { + self.desc.push_constants_range(num) + } +} + +unsafe impl<D> DeviceOwned for PipelineLayout<D> { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl<D> fmt::Debug for PipelineLayout<D> + where D: fmt::Debug +{ + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fmt.debug_struct("PipelineLayout") + .field("raw", &self.layout) + .field("device", &self.device) + .field("desc", &self.desc) + .finish() + } +} + +impl<L> Drop for PipelineLayout<L> { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyPipelineLayout(self.device.internal_object(), self.layout, ptr::null()); + } + } +} + +/// Opaque object that is borrowed from a `PipelineLayout`. +/// +/// This object exists so that we can pass it around without having to be generic over the template +/// parameter of the `PipelineLayout`. +#[derive(Copy, Clone)] +pub struct PipelineLayoutSys<'a>(&'a vk::PipelineLayout); + +unsafe impl<'a> VulkanObject for PipelineLayoutSys<'a> { + type Object = vk::PipelineLayout; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT; + + #[inline] + fn internal_object(&self) -> vk::PipelineLayout { + *self.0 + } +} + +/// Error that can happen when creating a pipeline layout. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum PipelineLayoutCreationError { + /// Not enough memory. + OomError(OomError), + /// The pipeline layout description doesn't fulfill the limit requirements. + LimitsError(PipelineLayoutLimitsError), + /// One of the push constants range didn't obey the rules. The list of stages must not be + /// empty, the size must not be 0, and the size must be a multiple or 4. + InvalidPushConstant, +} + +impl error::Error for PipelineLayoutCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + PipelineLayoutCreationError::OomError(_) => { + "not enough memory available" + }, + PipelineLayoutCreationError::LimitsError(_) => { + "the pipeline layout description doesn't fulfill the limit requirements" + }, + PipelineLayoutCreationError::InvalidPushConstant => { + "one of the push constants range didn't obey the rules" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + PipelineLayoutCreationError::OomError(ref err) => Some(err), + PipelineLayoutCreationError::LimitsError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for PipelineLayoutCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for PipelineLayoutCreationError { + #[inline] + fn from(err: OomError) -> PipelineLayoutCreationError { + PipelineLayoutCreationError::OomError(err) + } +} + +impl From<PipelineLayoutLimitsError> for PipelineLayoutCreationError { + #[inline] + fn from(err: PipelineLayoutLimitsError) -> PipelineLayoutCreationError { + PipelineLayoutCreationError::LimitsError(err) + } +} + +impl From<Error> for PipelineLayoutCreationError { + #[inline] + fn from(err: Error) -> PipelineLayoutCreationError { + match err { + err @ Error::OutOfHostMemory => { + PipelineLayoutCreationError::OomError(OomError::from(err)) + }, + err @ Error::OutOfDeviceMemory => { + PipelineLayoutCreationError::OomError(OomError::from(err)) + }, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +/* TODO: restore +#[cfg(test)] +mod tests { + use std::iter; + use std::sync::Arc; + use descriptor::descriptor::ShaderStages; + use descriptor::descriptor_set::UnsafeDescriptorSetLayout; + use descriptor::pipeline_layout::sys::PipelineLayout; + use descriptor::pipeline_layout::sys::PipelineLayoutCreationError; + + #[test] + fn empty() { + let (device, _) = gfx_dev_and_queue!(); + let _layout = PipelineLayout::new(&device, iter::empty(), iter::empty()).unwrap(); + } + + #[test] + fn wrong_device_panic() { + let (device1, _) = gfx_dev_and_queue!(); + let (device2, _) = gfx_dev_and_queue!(); + + let set = match UnsafeDescriptorSetLayout::raw(device1, iter::empty()) { + Ok(s) => Arc::new(s), + Err(_) => return + }; + + assert_should_panic!({ + let _ = PipelineLayout::new(&device2, Some(&set), iter::empty()); + }); + } + + #[test] + fn invalid_push_constant_stages() { + let (device, _) = gfx_dev_and_queue!(); + + let push_constant = (0, 8, ShaderStages::none()); + + match PipelineLayout::new(&device, iter::empty(), Some(push_constant)) { + Err(PipelineLayoutCreationError::InvalidPushConstant) => (), + _ => panic!() + } + } + + #[test] + fn invalid_push_constant_size1() { + let (device, _) = gfx_dev_and_queue!(); + + let push_constant = (0, 0, ShaderStages::all_graphics()); + + match PipelineLayout::new(&device, iter::empty(), Some(push_constant)) { + Err(PipelineLayoutCreationError::InvalidPushConstant) => (), + _ => panic!() + } + } + + #[test] + fn invalid_push_constant_size2() { + let (device, _) = gfx_dev_and_queue!(); + + let push_constant = (0, 11, ShaderStages::all_graphics()); + + match PipelineLayout::new(&device, iter::empty(), Some(push_constant)) { + Err(PipelineLayoutCreationError::InvalidPushConstant) => (), + _ => panic!() + } + } +}*/ diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/traits.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/traits.rs new file mode 100644 index 0000000..d1cdc7a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/traits.rs @@ -0,0 +1,328 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::cmp; +use std::error; +use std::fmt; +use std::sync::Arc; + +use SafeDeref; +use descriptor::descriptor::DescriptorDesc; +use descriptor::descriptor::DescriptorDescSupersetError; +use descriptor::descriptor::ShaderStages; +use descriptor::descriptor_set::DescriptorSetsCollection; +use descriptor::descriptor_set::UnsafeDescriptorSetLayout; +use descriptor::pipeline_layout::PipelineLayout; +use descriptor::pipeline_layout::PipelineLayoutCreationError; +use descriptor::pipeline_layout::PipelineLayoutDescUnion; +use descriptor::pipeline_layout::PipelineLayoutSys; +use descriptor::pipeline_layout::limits_check; +use device::Device; +use device::DeviceOwned; + +/// Trait for objects that describe the layout of the descriptors and push constants of a pipeline. +pub unsafe trait PipelineLayoutAbstract: PipelineLayoutDesc + DeviceOwned { + /// Returns an opaque object that allows internal access to the pipeline layout. + /// + /// Can be obtained by calling `PipelineLayoutAbstract::sys()` on the pipeline layout. + /// + /// > **Note**: This is an internal function that you normally don't need to call. + fn sys(&self) -> PipelineLayoutSys; + + /// Returns the `UnsafeDescriptorSetLayout` object of the specified set index. + /// + /// Returns `None` if out of range or if the set is empty for this index. + fn descriptor_set_layout(&self, index: usize) -> Option<&Arc<UnsafeDescriptorSetLayout>>; +} + +unsafe impl<T> PipelineLayoutAbstract for T + where T: SafeDeref, + T::Target: PipelineLayoutAbstract +{ + #[inline] + fn sys(&self) -> PipelineLayoutSys { + (**self).sys() + } + + #[inline] + fn descriptor_set_layout(&self, index: usize) -> Option<&Arc<UnsafeDescriptorSetLayout>> { + (**self).descriptor_set_layout(index) + } +} + +/// Trait for objects that describe the layout of the descriptors and push constants of a pipeline. +pub unsafe trait PipelineLayoutDesc { + /// Returns the number of sets in the layout. Includes possibly empty sets. + /// + /// In other words, this should be equal to the highest set number plus one. + fn num_sets(&self) -> usize; + + /// Returns the number of descriptors in the set. Includes possibly empty descriptors. + /// + /// Returns `None` if the set is out of range. + fn num_bindings_in_set(&self, set: usize) -> Option<usize>; + + /// Returns the descriptor for the given binding of the given set. + /// + /// Returns `None` if out of range or if the descriptor is empty. + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc>; + + /// If the `PipelineLayoutDesc` implementation is able to provide an existing + /// `UnsafeDescriptorSetLayout` for a given set, it can do so by returning it here. + #[inline] + fn provided_set_layout(&self, _set: usize) -> Option<Arc<UnsafeDescriptorSetLayout>> { + None + } + + /// Returns the number of push constant ranges of the layout. + fn num_push_constants_ranges(&self) -> usize; + + /// Returns a description of the given push constants range. + /// + /// Contrary to the descriptors, a push constants range can't be empty. + /// + /// Returns `None` if out of range. + /// + /// Each bit of `stages` must only be present in a single push constants range of the + /// description. + fn push_constants_range(&self, num: usize) -> Option<PipelineLayoutDescPcRange>; + + /// Builds the union of this layout and another. + #[inline] + fn union<T>(self, other: T) -> PipelineLayoutDescUnion<Self, T> + where Self: Sized + { + PipelineLayoutDescUnion::new(self, other) + } + + /// Checks whether this description fulfills the device limits requirements. + #[inline] + fn check_against_limits(&self, device: &Device) + -> Result<(), limits_check::PipelineLayoutLimitsError> { + limits_check::check_desc_against_limits(self, device.physical_device().limits()) + } + + /// Turns the layout description into a `PipelineLayout` object that can be used by Vulkan. + /// + /// > **Note**: This is just a shortcut for `PipelineLayout::new`. + #[inline] + fn build(self, device: Arc<Device>) -> Result<PipelineLayout<Self>, PipelineLayoutCreationError> + where Self: Sized + { + PipelineLayout::new(device, self) + } +} + +/// Description of a range of the push constants of a pipeline layout. +// TODO: should contain the layout as well +#[derive(Debug, Copy, Clone)] +pub struct PipelineLayoutDescPcRange { + /// Offset in bytes from the start of the push constants to this range. + pub offset: usize, + /// Size in bytes of the range. + pub size: usize, + /// The stages which can access this range. Note that the same shader stage can't access two + /// different ranges. + pub stages: ShaderStages, +} + +unsafe impl<T> PipelineLayoutDesc for T + where T: SafeDeref, + T::Target: PipelineLayoutDesc +{ + #[inline] + fn num_sets(&self) -> usize { + (**self).num_sets() + } + + #[inline] + fn num_bindings_in_set(&self, set: usize) -> Option<usize> { + (**self).num_bindings_in_set(set) + } + + #[inline] + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> { + (**self).descriptor(set, binding) + } + + #[inline] + fn num_push_constants_ranges(&self) -> usize { + (**self).num_push_constants_ranges() + } + + #[inline] + fn push_constants_range(&self, num: usize) -> Option<PipelineLayoutDescPcRange> { + (**self).push_constants_range(num) + } +} + +/// Traits that allow determining whether a pipeline layout is a superset of another one. +/// +/// This trait is automatically implemented on all types that implement `PipelineLayoutAbstract`. +/// TODO: once specialization lands, we can add implementations that don't perform deep comparisons +pub unsafe trait PipelineLayoutSuperset<Other: ?Sized>: PipelineLayoutDesc + where Other: PipelineLayoutDesc +{ + /// Makes sure that `self` is a superset of `Other`. Returns an `Err` if this is not the case. + fn ensure_superset_of(&self, &Other) -> Result<(), PipelineLayoutNotSupersetError>; +} + +unsafe impl<T: ?Sized, U: ?Sized> PipelineLayoutSuperset<U> for T + where T: PipelineLayoutDesc, + U: PipelineLayoutDesc +{ + fn ensure_superset_of(&self, other: &U) -> Result<(), PipelineLayoutNotSupersetError> { + for set_num in 0 .. cmp::max(self.num_sets(), other.num_sets()) { + let other_num_bindings = other.num_bindings_in_set(set_num).unwrap_or(0); + let self_num_bindings = self.num_bindings_in_set(set_num).unwrap_or(0); + + if self_num_bindings < other_num_bindings { + return Err(PipelineLayoutNotSupersetError::DescriptorsCountMismatch { + set_num: set_num as u32, + self_num_descriptors: self_num_bindings as u32, + other_num_descriptors: other_num_bindings as u32, + }); + } + + for desc_num in 0 .. other_num_bindings { + match (self.descriptor(set_num, desc_num), other.descriptor(set_num, desc_num)) { + (Some(mine), Some(other)) => { + if let Err(err) = mine.is_superset_of(&other) { + return Err(PipelineLayoutNotSupersetError::IncompatibleDescriptors { + error: err, + set_num: set_num as u32, + descriptor: desc_num as u32, + }); + } + }, + (None, Some(_)) => + return Err(PipelineLayoutNotSupersetError::ExpectedEmptyDescriptor { + set_num: set_num as u32, + descriptor: desc_num as u32, + }), + _ => (), + } + } + } + + // FIXME: check push constants + + Ok(()) + } +} + +/// Error that can happen when creating a graphics pipeline. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum PipelineLayoutNotSupersetError { + /// There are more descriptors in the child than in the parent layout. + DescriptorsCountMismatch { + set_num: u32, + self_num_descriptors: u32, + other_num_descriptors: u32, + }, + + /// Expected an empty descriptor, but got something instead. + ExpectedEmptyDescriptor { set_num: u32, descriptor: u32 }, + + /// Two descriptors are incompatible. + IncompatibleDescriptors { + error: DescriptorDescSupersetError, + set_num: u32, + descriptor: u32, + }, +} + +impl error::Error for PipelineLayoutNotSupersetError { + #[inline] + fn description(&self) -> &str { + match *self { + PipelineLayoutNotSupersetError::DescriptorsCountMismatch { .. } => { + "there are more descriptors in the child than in the parent layout" + }, + PipelineLayoutNotSupersetError::ExpectedEmptyDescriptor { .. } => { + "expected an empty descriptor, but got something instead" + }, + PipelineLayoutNotSupersetError::IncompatibleDescriptors { .. } => { + "two descriptors are incompatible" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + PipelineLayoutNotSupersetError::IncompatibleDescriptors { ref error, .. } => { + Some(error) + }, + _ => None, + } + } +} + +impl fmt::Display for PipelineLayoutNotSupersetError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +/// Traits that allow determining whether +pub unsafe trait PipelineLayoutSetsCompatible<Other: ?Sized>: PipelineLayoutDesc + where Other: DescriptorSetsCollection +{ + /// Returns true if `Other` can be used with a pipeline that uses `self` as layout. + fn is_compatible(&self, &Other) -> bool; +} + +unsafe impl<T: ?Sized, U: ?Sized> PipelineLayoutSetsCompatible<U> for T + where T: PipelineLayoutDesc, + U: DescriptorSetsCollection +{ + fn is_compatible(&self, sets: &U) -> bool { + /*let mut other_descriptor_sets = DescriptorSetsCollection::description(sets); + + for my_set in self.descriptors_desc() { + let mut other_set = match other_descriptor_sets.next() { + None => return false, + Some(s) => s, + }; + + for my_desc in my_set { + let other_desc = match other_set.next() { + None => return false, + Some(d) => d, + }; + + if !my_desc.is_superset_of(&other_desc) { + return false; + } + } + }*/ + + // FIXME: + true + } +} + +/// Traits that allow determining whether +// TODO: require a trait on Pc +pub unsafe trait PipelineLayoutPushConstantsCompatible<Pc: ?Sized> + : PipelineLayoutDesc { + /// Returns true if `Pc` can be used with a pipeline that uses `self` as layout. + fn is_compatible(&self, &Pc) -> bool; +} + +unsafe impl<T: ?Sized, U: ?Sized> PipelineLayoutPushConstantsCompatible<U> for T + where T: PipelineLayoutDesc +{ + fn is_compatible(&self, _: &U) -> bool { + // FIXME: + true + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/tweaks.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/tweaks.rs new file mode 100644 index 0000000..1ba05bf --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/tweaks.rs @@ -0,0 +1,78 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use descriptor::descriptor::DescriptorDesc; +use descriptor::descriptor::DescriptorDescTy; +use descriptor::descriptor::DescriptorBufferDesc; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use descriptor::pipeline_layout::PipelineLayoutDescPcRange; +use fnv::FnvHashSet; + +/// Transforms a `PipelineLayoutDesc`. +/// +/// Used to adjust automatically inferred `PipelineLayoutDesc`s with information that cannot be inferred. +pub struct PipelineLayoutDescTweaks<T> { + inner: T, + dynamic_buffers: FnvHashSet<(usize, usize)>, +} + +impl<T> PipelineLayoutDescTweaks<T> + where T: PipelineLayoutDesc +{ + /// Describe a layout, ensuring that each `(set, binding)` in `dynamic_buffers` is a dynamic buffers. + pub fn new<I>(inner: T, dynamic_buffers: I) -> Self + where I: IntoIterator<Item=(usize, usize)> + { + let dynamic_buffers = dynamic_buffers.into_iter().collect(); + for &(set, binding) in &dynamic_buffers { + debug_assert!(inner.descriptor(set, binding) + .map_or(false, |desc| match desc.ty { + DescriptorDescTy::Buffer(_) => true, + _ => false, + }), + "tried to make the non-buffer descriptor at set {} binding {} a dynamic buffer", set, binding); + } + Self { inner, dynamic_buffers } + } +} + +unsafe impl<T> PipelineLayoutDesc for PipelineLayoutDescTweaks<T> + where T: PipelineLayoutDesc +{ + #[inline] + fn num_sets(&self) -> usize { self.inner.num_sets() } + + #[inline] + fn num_bindings_in_set(&self, set: usize) -> Option<usize> { self.inner.num_bindings_in_set(set) } + + #[inline] + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> { + self.inner.descriptor(set, binding).map(|desc| { + match desc.ty { + DescriptorDescTy::Buffer(ref buffer_desc) if self.dynamic_buffers.contains(&(set, binding)) => { + DescriptorDesc { + ty: DescriptorDescTy::Buffer(DescriptorBufferDesc { + dynamic: Some(true), + ..*buffer_desc + }), + ..desc + } + } + _ => desc, + } + }) + } + + #[inline] + fn num_push_constants_ranges(&self) -> usize { self.inner.num_push_constants_ranges() } + + // TODO: needs tests + #[inline] + fn push_constants_range(&self, num: usize) -> Option<PipelineLayoutDescPcRange> { self.inner.push_constants_range(num) } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/union.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/union.rs new file mode 100644 index 0000000..658a5b8 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/descriptor/pipeline_layout/union.rs @@ -0,0 +1,135 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use descriptor::descriptor::DescriptorDesc; +use descriptor::descriptor_set::UnsafeDescriptorSetLayout; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use descriptor::pipeline_layout::PipelineLayoutDescPcRange; +use std::cmp; +use std::sync::Arc; + +/// Contains the union of two pipeline layout description. +/// +/// If `A` and `B` both implement `PipelineLayoutDesc`, then this struct also implements +/// `PipelineLayoutDesc` and will correspond to the union of the `A` object and the `B` object. +pub struct PipelineLayoutDescUnion<A, B> { + a: A, + b: B, +} + +impl<A, B> PipelineLayoutDescUnion<A, B> { + // FIXME: check collisions + pub fn new(a: A, b: B) -> PipelineLayoutDescUnion<A, B> { + PipelineLayoutDescUnion { a: a, b: b } + } +} + +unsafe impl<A, B> PipelineLayoutDesc for PipelineLayoutDescUnion<A, B> + where A: PipelineLayoutDesc, + B: PipelineLayoutDesc +{ + #[inline] + fn num_sets(&self) -> usize { + cmp::max(self.a.num_sets(), self.b.num_sets()) + } + + #[inline] + fn num_bindings_in_set(&self, set: usize) -> Option<usize> { + let a = self.a.num_bindings_in_set(set); + let b = self.b.num_bindings_in_set(set); + + match (a, b) { + (Some(a), Some(b)) => Some(cmp::max(a, b)), + (Some(a), None) => Some(a), + (None, Some(b)) => Some(b), + (None, None) => None, + } + } + + #[inline] + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> { + let a = self.a.descriptor(set, binding); + let b = self.b.descriptor(set, binding); + + match (a, b) { + (Some(a), Some(b)) => Some(a.union(&b).expect("Can't be union-ed")), + (Some(a), None) => Some(a), + (None, Some(b)) => Some(b), + (None, None) => None, + } + } + + #[inline] + fn provided_set_layout(&self, set: usize) -> Option<Arc<UnsafeDescriptorSetLayout>> { + self.a + .provided_set_layout(set) + .or(self.b.provided_set_layout(set)) + } + + #[inline] + fn num_push_constants_ranges(&self) -> usize { + // We simply call `push_constants_range` repeatedly to determine when it is over. + // TODO: consider caching this + (self.a.num_push_constants_ranges() ..) + .filter(|&n| self.push_constants_range(n).is_none()) + .next() + .unwrap() + } + + // TODO: needs tests + #[inline] + fn push_constants_range(&self, num: usize) -> Option<PipelineLayoutDescPcRange> { + // The strategy here is that we return the same ranges as `self.a`, except that if there + // happens to be a range with a similar stage in `self.b` then we adjust the offset and + // size of the range coming from `self.a` to include the range of `self.b`. + // + // After all the ranges of `self.a` have been returned, we return the ones from `self.b` + // that don't intersect with any range of `self.a`. + + if let Some(mut pc) = self.a.push_constants_range(num) { + // We try to find the ranges in `self.b` that share the same stages as us. + for n in 0 .. self.b.num_push_constants_ranges() { + let other_pc = self.b.push_constants_range(n).unwrap(); + + if other_pc.stages.intersects(&pc.stages) { + if other_pc.offset < pc.offset { + pc.size += pc.offset - other_pc.offset; + pc.size = cmp::max(pc.size, other_pc.size); + pc.offset = other_pc.offset; + + } else if other_pc.offset > pc.offset { + pc.size = cmp::max(pc.size, other_pc.size + (other_pc.offset - pc.offset)); + } + } + } + + return Some(pc); + } + + let mut num = num - self.a.num_push_constants_ranges(); + 'outer_loop: for b_r in 0 .. self.b.num_push_constants_ranges() { + let pc = self.b.push_constants_range(b_r).unwrap(); + + for n in 0 .. self.a.num_push_constants_ranges() { + let other_pc = self.a.push_constants_range(n).unwrap(); + if other_pc.stages.intersects(&pc.stages) { + continue 'outer_loop; + } + } + + if num == 0 { + return Some(pc); + } else { + num -= 1; + } + } + + None + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/device/extensions.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/device/extensions.rs new file mode 100644 index 0000000..c05909e --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/device/extensions.rs @@ -0,0 +1,130 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::collections::HashSet; +use std::ffi::{CStr, CString}; +use std::fmt; +use std::iter::FromIterator; +use std::ptr; +use std::str; + +use VulkanObject; +use check_errors; +use instance::PhysicalDevice; +use extensions::SupportedExtensionsError; +use vk; + +macro_rules! device_extensions { + ($sname:ident, $rawname:ident, $($ext:ident => $s:expr,)*) => ( + extensions! { + $sname, $rawname, + $( $ext => $s,)* + } + + impl $rawname { + /// See the docs of supported_by_device(). + pub fn supported_by_device_raw(physical_device: PhysicalDevice) -> Result<Self, SupportedExtensionsError> { + let vk = physical_device.instance().pointers(); + + let properties: Vec<vk::ExtensionProperties> = unsafe { + let mut num = 0; + try!(check_errors(vk.EnumerateDeviceExtensionProperties( + physical_device.internal_object(), ptr::null(), &mut num, ptr::null_mut()))); + + let mut properties = Vec::with_capacity(num as usize); + try!(check_errors(vk.EnumerateDeviceExtensionProperties( + physical_device.internal_object(), ptr::null(), &mut num, properties.as_mut_ptr()))); + properties.set_len(num as usize); + properties + }; + Ok($rawname(properties.iter().map(|x| unsafe { CStr::from_ptr(x.extensionName.as_ptr()) }.to_owned()).collect())) + } + + /// Returns an `Extensions` object with extensions supported by the `PhysicalDevice`. + pub fn supported_by_device(physical_device: PhysicalDevice) -> Self { + match $rawname::supported_by_device_raw(physical_device) { + Ok(l) => l, + Err(SupportedExtensionsError::LoadingError(_)) => unreachable!(), + Err(SupportedExtensionsError::OomError(e)) => panic!("{:?}", e), + } + } + } + + impl $sname { + /// See the docs of supported_by_device(). + pub fn supported_by_device_raw(physical_device: PhysicalDevice) -> Result<Self, SupportedExtensionsError> { + let vk = physical_device.instance().pointers(); + + let properties: Vec<vk::ExtensionProperties> = unsafe { + let mut num = 0; + try!(check_errors(vk.EnumerateDeviceExtensionProperties( + physical_device.internal_object(), ptr::null(), &mut num, ptr::null_mut()))); + + let mut properties = Vec::with_capacity(num as usize); + try!(check_errors(vk.EnumerateDeviceExtensionProperties( + physical_device.internal_object(), ptr::null(), &mut num, properties.as_mut_ptr()))); + properties.set_len(num as usize); + properties + }; + + let mut extensions = $sname::none(); + for property in properties { + let name = unsafe { CStr::from_ptr(property.extensionName.as_ptr()) }; + $( + // TODO: Check specVersion? + if name.to_bytes() == &$s[..] { + extensions.$ext = true; + } + )* + } + + Ok(extensions) + } + + /// Returns an `Extensions` object with extensions supported by the `PhysicalDevice`. + pub fn supported_by_device(physical_device: PhysicalDevice) -> Self { + match $sname::supported_by_device_raw(physical_device) { + Ok(l) => l, + Err(SupportedExtensionsError::LoadingError(_)) => unreachable!(), + Err(SupportedExtensionsError::OomError(e)) => panic!("{:?}", e), + } + } + } + ); +} + +device_extensions! { + DeviceExtensions, + RawDeviceExtensions, + khr_swapchain => b"VK_KHR_swapchain", + khr_display_swapchain => b"VK_KHR_display_swapchain", + khr_sampler_mirror_clamp_to_edge => b"VK_KHR_sampler_mirror_clamp_to_edge", + khr_maintenance1 => b"VK_KHR_maintenance1", + khr_get_memory_requirements2 => b"VK_KHR_get_memory_requirements2", + khr_dedicated_allocation => b"VK_KHR_dedicated_allocation", + khr_incremental_present => b"VK_KHR_incremental_present", + ext_debug_marker => b"VK_EXT_debug_marker", +} + +/// This helper type can only be instantiated inside this module. +/// See `*Extensions::_unbuildable`. +#[doc(hidden)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct Unbuildable(()); + +#[cfg(test)] +mod tests { + use device::{DeviceExtensions, RawDeviceExtensions}; + + #[test] + fn empty_extensions() { + let d: RawDeviceExtensions = (&DeviceExtensions::none()).into(); + assert!(d.iter().next().is_none()); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/device/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/device/mod.rs new file mode 100644 index 0000000..876bda2 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/device/mod.rs @@ -0,0 +1,845 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Communication channel with a physical device. +//! +//! The `Device` is one of the most important objects of Vulkan. Creating a `Device` is required +//! before you can create buffers, textures, shaders, etc. +//! +//! Basic example: +//! +//! ```no_run +//! use vulkano::device::Device; +//! use vulkano::device::DeviceExtensions; +//! use vulkano::device::Features; +//! use vulkano::instance::Instance; +//! use vulkano::instance::InstanceExtensions; +//! use vulkano::instance::PhysicalDevice; +//! +//! // Creating the instance. See the documentation of the `instance` module. +//! let instance = match Instance::new(None, &InstanceExtensions::none(), None) { +//! Ok(i) => i, +//! Err(err) => panic!("Couldn't build instance: {:?}", err) +//! }; +//! +//! // We just choose the first physical device. In a real application you would choose depending +//! // on the capabilities of the physical device and the user's preferences. +//! let physical_device = PhysicalDevice::enumerate(&instance).next().expect("No physical device"); +//! +//! // Here is the device-creating code. +//! let device = { +//! let queue_family = physical_device.queue_families().next().unwrap(); +//! let features = Features::none(); +//! let ext = DeviceExtensions::none(); +//! +//! match Device::new(physical_device, &features, &ext, Some((queue_family, 1.0))) { +//! Ok(d) => d, +//! Err(err) => panic!("Couldn't build device: {:?}", err) +//! } +//! }; +//! ``` +//! +//! # Features and extensions +//! +//! Two of the parameters that you pass to `Device::new` are the list of the features and the list +//! of extensions to enable on the newly-created device. +//! +//! > **Note**: Device extensions are the same as instance extensions, except for the device. +//! > Features are similar to extensions, except that they are part of the core Vulkan +//! > specifications instead of being separate documents. +//! +//! Some Vulkan capabilities, such as swapchains (that allow you to render on the screen) or +//! geometry shaders for example, require that you enable a certain feature or extension when you +//! create the device. Contrary to OpenGL, you can't use the functions provided by a feature or an +//! extension if you didn't explicitly enable it when creating the device. +//! +//! Not all physical devices support all possible features and extensions. For example mobile +//! devices tend to not support geometry shaders, because their hardware is not capable of it. You +//! can query what is supported with respectively `PhysicalDevice::supported_features` and +//! `DeviceExtensions::supported_by_device`. +//! +//! > **Note**: The fact that you need to manually enable features at initialization also means +//! > that you don't need to worry about a capability not being supported later on in your code. +//! +//! # Queues +//! +//! Each physical device proposes one or more *queues* that are divided in *queue families*. A +//! queue is a thread of execution to which you can submit commands that the GPU will execute. +//! +//! > **Note**: You can think of a queue like a CPU thread. Each queue executes its commands one +//! > after the other, and queues run concurrently. A GPU behaves similarly to the hyper-threading +//! > technology, in the sense that queues will only run partially in parallel. +//! +//! The Vulkan API requires that you specify the list of queues that you are going to use at the +//! same time as when you create the device. This is done in vulkano by passing an iterator where +//! each element is a tuple containing a queue family and a number between 0.0 and 1.0 indicating +//! the priority of execution of the queue relative to the others. +//! +//! TODO: write better doc here +//! +//! The `Device::new` function returns the newly-created device, but also the list of queues. +//! +//! # Extended example +//! +//! TODO: write + +use fnv::FnvHasher; +use smallvec::SmallVec; +use std::collections::HashMap; +use std::collections::hash_map::Entry; +use std::error; +use std::fmt; +use std::hash::BuildHasherDefault; +use std::mem; +use std::ops::Deref; +use std::ptr; +use std::sync::Arc; +use std::sync::Mutex; +use std::sync::MutexGuard; +use std::sync::Weak; +use std::ffi::CStr; + +use command_buffer::pool::StandardCommandPool; +use descriptor::descriptor_set::StdDescriptorPool; +use instance::Instance; +use instance::PhysicalDevice; +use instance::QueueFamily; +use memory::pool::StdMemoryPool; + +use Error; +use OomError; +use SynchronizedVulkanObject; +use VulkanObject; +use VulkanHandle; +use check_errors; +use vk; + +pub use self::extensions::DeviceExtensions; +pub use self::extensions::RawDeviceExtensions; +pub use ::features::Features; +mod extensions; + +/// Represents a Vulkan context. +pub struct Device { + instance: Arc<Instance>, + physical_device: usize, + device: vk::Device, + vk: vk::DevicePointers, + standard_pool: Mutex<Weak<StdMemoryPool>>, + standard_descriptor_pool: Mutex<Weak<StdDescriptorPool>>, + standard_command_pools: + Mutex<HashMap<u32, Weak<StandardCommandPool>, BuildHasherDefault<FnvHasher>>>, + features: Features, + extensions: DeviceExtensions, + active_queue_families: SmallVec<[u32; 8]>, + allocation_count: Mutex<u32>, + fence_pool: Mutex<Vec<vk::Fence>>, + semaphore_pool: Mutex<Vec<vk::Semaphore>>, + event_pool: Mutex<Vec<vk::Event>>, +} + +// The `StandardCommandPool` type doesn't implement Send/Sync, so we have to manually reimplement +// them for the device itself. +unsafe impl Send for Device { +} +unsafe impl Sync for Device { +} + +impl Device { + /// Builds a new Vulkan device for the given physical device. + /// + /// You must pass two things when creating a logical device: + /// + /// - A list of optional Vulkan features that must be enabled on the device. Note that if a + /// feature is not enabled at device creation, you can't use it later even it it's supported + /// by the physical device. + /// + /// - An iterator to a list of queues to create. Each element of the iterator must indicate + /// the family whose queue belongs to and a priority between 0.0 and 1.0 to assign to it. + /// A queue with a higher value indicates that the commands will execute faster than on a + /// queue with a lower value. Note however that no guarantee can be made on the way the + /// priority value is handled by the implementation. + /// + /// # Panic + /// + /// - Panics if one of the queue families doesn't belong to the given device. + /// + // TODO: return Arc<Queue> and handle synchronization in the Queue + // TODO: should take the PhysicalDevice by value + pub fn new<'a, I, Ext>(phys: PhysicalDevice, requested_features: &Features, extensions: Ext, + queue_families: I) + -> Result<(Arc<Device>, QueuesIter), DeviceCreationError> + where I: IntoIterator<Item = (QueueFamily<'a>, f32)>, + Ext: Into<RawDeviceExtensions> + { + let queue_families = queue_families.into_iter(); + + if !phys.supported_features().superset_of(&requested_features) { + return Err(DeviceCreationError::FeatureNotPresent); + } + + let vk_i = phys.instance().pointers(); + + // this variable will contain the queue family ID and queue ID of each requested queue + let mut output_queues: SmallVec<[(u32, u32); 8]> = SmallVec::new(); + + // Device layers were deprecated in Vulkan 1.0.13, and device layer requests should be + // ignored by the driver. For backwards compatibility, the spec recommends passing the + // exact instance layers to the device as well. There's no need to support separate + // requests at device creation time for legacy drivers: the spec claims that "[at] the + // time of deprecation there were no known device-only layers." + // + // Because there's no way to query the list of layers enabled for an instance, we need + // to save it alongside the instance. (`vkEnumerateDeviceLayerProperties` should get + // the right list post-1.0.13, but not pre-1.0.13, so we can't use it here.) + let layers_ptr = phys.instance() + .loaded_layers() + .map(|layer| layer.as_ptr()) + .collect::<SmallVec<[_; 16]>>(); + + let extensions = extensions.into(); + let extensions_list = extensions + .iter() + .map(|extension| extension.as_ptr()) + .collect::<SmallVec<[_; 16]>>(); + + // device creation + let device = unsafe { + // each element of `queues` is a `(queue_family, priorities)` + // each queue family must only have one entry in `queues` + let mut queues: Vec<(u32, Vec<f32>)> = Vec::with_capacity(phys.queue_families().len()); + + for (queue_family, priority) in queue_families { + // checking the parameters + assert_eq!(queue_family.physical_device().internal_object(), + phys.internal_object()); + if priority < 0.0 || priority > 1.0 { + return Err(DeviceCreationError::PriorityOutOfRange); + } + + // adding to `queues` and `output_queues` + if let Some(q) = queues.iter_mut().find(|q| q.0 == queue_family.id()) { + output_queues.push((queue_family.id(), q.1.len() as u32)); + q.1.push(priority); + if q.1.len() > queue_family.queues_count() { + return Err(DeviceCreationError::TooManyQueuesForFamily); + } + continue; + } + queues.push((queue_family.id(), vec![priority])); + output_queues.push((queue_family.id(), 0)); + } + + // turning `queues` into an array of `vkDeviceQueueCreateInfo` suitable for Vulkan + let queues = queues + .iter() + .map(|&(queue_id, ref priorities)| { + vk::DeviceQueueCreateInfo { + sType: vk::STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + queueFamilyIndex: queue_id, + queueCount: priorities.len() as u32, + pQueuePriorities: priorities.as_ptr(), + } + }) + .collect::<SmallVec<[_; 16]>>(); + + // TODO: The plan regarding `robustBufferAccess` is to check the shaders' code to see + // if they can possibly perform out-of-bounds reads and writes. If the user tries + // to use a shader that can perform out-of-bounds operations without having + // `robustBufferAccess` enabled, an error is returned. + // + // However for the moment this verification isn't performed. In order to be safe, + // we always enable the `robustBufferAccess` feature as it is guaranteed to be + // supported everywhere. + // + // The only alternative (while waiting for shaders introspection to work) is to + // make all shaders depend on `robustBufferAccess`. But since usually the + // majority of shaders don't need this feature, it would be very annoying to have + // to enable it manually when you don't need it. + // + // Note that if we ever remove this, don't forget to adjust the change in + // `Device`'s construction below. + let features = { + let mut features = requested_features.clone().into_vulkan_features(); + features.robustBufferAccess = vk::TRUE; + features + }; + + let infos = vk::DeviceCreateInfo { + sType: vk::STRUCTURE_TYPE_DEVICE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + queueCreateInfoCount: queues.len() as u32, + pQueueCreateInfos: queues.as_ptr(), + enabledLayerCount: layers_ptr.len() as u32, + ppEnabledLayerNames: layers_ptr.as_ptr(), + enabledExtensionCount: extensions_list.len() as u32, + ppEnabledExtensionNames: extensions_list.as_ptr(), + pEnabledFeatures: &features, + }; + + let mut output = mem::uninitialized(); + check_errors(vk_i.CreateDevice(phys.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + // loading the function pointers of the newly-created device + let vk = vk::DevicePointers::load(|name| unsafe { + vk_i.GetDeviceProcAddr(device, name.as_ptr()) as + *const _ + }); + + let device = + Arc::new(Device { + instance: phys.instance().clone(), + physical_device: phys.index(), + device: device, + vk: vk, + standard_pool: Mutex::new(Weak::new()), + standard_descriptor_pool: Mutex::new(Weak::new()), + standard_command_pools: Mutex::new(Default::default()), + features: Features { + // Always enabled ; see above + robust_buffer_access: true, + ..requested_features.clone() + }, + extensions: (&extensions).into(), + active_queue_families: output_queues.iter().map(|&(q, _)| q).collect(), + allocation_count: Mutex::new(0), + fence_pool: Mutex::new(Vec::new()), + semaphore_pool: Mutex::new(Vec::new()), + event_pool: Mutex::new(Vec::new()), + }); + + // Iterator for the produced queues. + let output_queues = QueuesIter { + next_queue: 0, + device: device.clone(), + families_and_ids: output_queues, + }; + + Ok((device, output_queues)) + } + + /// Grants access to the pointers to the Vulkan functions of the device. + #[inline] + pub(crate) fn pointers(&self) -> &vk::DevicePointers { + &self.vk + } + + /// Waits until all work on this device has finished. You should never need to call + /// this function, but it can be useful for debugging or benchmarking purposes. + /// + /// > **Note**: This is the Vulkan equivalent of OpenGL's `glFinish`. + /// + /// # Safety + /// + /// This function is not thread-safe. You must not submit anything to any of the queue + /// of the device (either explicitly or implicitly, for example with a future's destructor) + /// while this function is waiting. + /// + pub unsafe fn wait(&self) -> Result<(), OomError> { + check_errors(self.vk.DeviceWaitIdle(self.device))?; + Ok(()) + } + + /// Returns the instance used to create this device. + #[inline] + pub fn instance(&self) -> &Arc<Instance> { + &self.instance + } + + /// Returns the physical device that was used to create this device. + #[inline] + pub fn physical_device(&self) -> PhysicalDevice { + PhysicalDevice::from_index(&self.instance, self.physical_device).unwrap() + } + + /// Returns an iterator to the list of queues families that this device uses. + /// + /// > **Note**: Will return `-> impl ExactSizeIterator<Item = QueueFamily>` in the future. + // TODO: ^ + #[inline] + pub fn active_queue_families<'a>(&'a self) + -> Box<ExactSizeIterator<Item = QueueFamily<'a>> + 'a> { + let physical_device = self.physical_device(); + Box::new(self.active_queue_families + .iter() + .map(move |&id| physical_device.queue_family_by_id(id).unwrap())) + } + + /// Returns the features that are enabled in the device. + #[inline] + pub fn enabled_features(&self) -> &Features { + &self.features + } + + /// Returns the list of extensions that have been loaded. + #[inline] + pub fn loaded_extensions(&self) -> &DeviceExtensions { + &self.extensions + } + + /// Returns the standard memory pool used by default if you don't provide any other pool. + pub fn standard_pool(me: &Arc<Self>) -> Arc<StdMemoryPool> { + let mut pool = me.standard_pool.lock().unwrap(); + + if let Some(p) = pool.upgrade() { + return p; + } + + // The weak pointer is empty, so we create the pool. + let new_pool = StdMemoryPool::new(me.clone()); + *pool = Arc::downgrade(&new_pool); + new_pool + } + + /// Returns the standard descriptor pool used by default if you don't provide any other pool. + pub fn standard_descriptor_pool(me: &Arc<Self>) -> Arc<StdDescriptorPool> { + let mut pool = me.standard_descriptor_pool.lock().unwrap(); + + if let Some(p) = pool.upgrade() { + return p; + } + + // The weak pointer is empty, so we create the pool. + let new_pool = Arc::new(StdDescriptorPool::new(me.clone())); + *pool = Arc::downgrade(&new_pool); + new_pool + } + + /// Returns the standard command buffer pool used by default if you don't provide any other + /// pool. + /// + /// # Panic + /// + /// - Panics if the device and the queue family don't belong to the same physical device. + /// + pub fn standard_command_pool(me: &Arc<Self>, queue: QueueFamily) -> Arc<StandardCommandPool> { + let mut standard_command_pools = me.standard_command_pools.lock().unwrap(); + + match standard_command_pools.entry(queue.id()) { + Entry::Occupied(mut entry) => { + if let Some(pool) = entry.get().upgrade() { + return pool; + } + + let new_pool = Arc::new(StandardCommandPool::new(me.clone(), queue)); + *entry.get_mut() = Arc::downgrade(&new_pool); + new_pool + }, + Entry::Vacant(entry) => { + let new_pool = Arc::new(StandardCommandPool::new(me.clone(), queue)); + entry.insert(Arc::downgrade(&new_pool)); + new_pool + }, + } + } + + /// Used to track the number of allocations on this device. + /// + /// To ensure valid usage of the Vulkan API, we cannot call `vkAllocateMemory` when + /// `maxMemoryAllocationCount` has been exceeded. See the Vulkan specs: + /// https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#vkAllocateMemory + /// + /// Warning: You should never modify this value, except in `device_memory` module + pub(crate) fn allocation_count(&self) -> &Mutex<u32> { + &self.allocation_count + } + + pub(crate) fn fence_pool(&self) -> &Mutex<Vec<vk::Fence>> { + &self.fence_pool + } + + pub(crate) fn semaphore_pool(&self) -> &Mutex<Vec<vk::Semaphore>> { + &self.semaphore_pool + } + + pub(crate) fn event_pool(&self) -> &Mutex<Vec<vk::Event>> { + &self.event_pool + } + + /// Assigns a human-readable name to `object` for debugging purposes. + /// + /// # Panics + /// * If the `VK_EXT_debug_marker` device extension is not loaded. + /// * If `object` is not owned by this device. + pub fn set_object_name<T: VulkanObject + DeviceOwned>(&self, object: &T, name: &CStr) -> Result<(), OomError> { + assert!(object.device().internal_object() == self.internal_object()); + unsafe { self.set_object_name_raw(T::TYPE, object.internal_object().value(), name) } + } + + /// Assigns a human-readable name to `object` for debugging purposes. + /// + /// # Panics + /// * If the `VK_EXT_debug_marker` device extension is not loaded. + /// + /// # Safety + /// `object` must be a Vulkan handle owned by this device, and its type must be accurately described by `ty`. + pub unsafe fn set_object_name_raw(&self, ty: vk::DebugReportObjectTypeEXT, object: u64, name: &CStr) -> Result<(), OomError> { + let info = vk::DebugMarkerObjectNameInfoEXT { + sType: vk::STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT, + pNext: ptr::null(), + objectType: ty, + object: object, + name: name.as_ptr(), + }; + check_errors(self.vk.DebugMarkerSetObjectNameEXT(self.device, &info))?; + Ok(()) + } +} + +impl fmt::Debug for Device { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan device {:?}>", self.device) + } +} + +unsafe impl VulkanObject for Device { + type Object = vk::Device; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT; + + #[inline] + fn internal_object(&self) -> vk::Device { + self.device + } +} + +impl Drop for Device { + #[inline] + fn drop(&mut self) { + unsafe { + for &raw_fence in self.fence_pool.lock().unwrap().iter() { + self.vk.DestroyFence(self.device, raw_fence, ptr::null()); + } + for &raw_sem in self.semaphore_pool.lock().unwrap().iter() { + self.vk.DestroySemaphore(self.device, raw_sem, ptr::null()); + } + for &raw_event in self.event_pool.lock().unwrap().iter() { + self.vk.DestroyEvent(self.device, raw_event, ptr::null()); + } + self.vk.DestroyDevice(self.device, ptr::null()); + } + } +} + +/// Implemented on objects that belong to a Vulkan device. +/// +/// # Safety +/// +/// - `device()` must return the correct device. +/// +pub unsafe trait DeviceOwned { + /// Returns the device that owns `Self`. + fn device(&self) -> &Arc<Device>; +} + +unsafe impl<T> DeviceOwned for T + where T: Deref, + T::Target: DeviceOwned +{ + #[inline] + fn device(&self) -> &Arc<Device> { + (**self).device() + } +} + +/// Iterator that returns the queues produced when creating a device. +pub struct QueuesIter { + next_queue: usize, + device: Arc<Device>, + families_and_ids: SmallVec<[(u32, u32); 8]>, +} + +unsafe impl DeviceOwned for QueuesIter { + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl Iterator for QueuesIter { + type Item = Arc<Queue>; + + fn next(&mut self) -> Option<Arc<Queue>> { + unsafe { + let &(family, id) = match self.families_and_ids.get(self.next_queue) { + Some(a) => a, + None => return None, + }; + + self.next_queue += 1; + + let mut output = mem::uninitialized(); + self.device + .vk + .GetDeviceQueue(self.device.device, family, id, &mut output); + + Some(Arc::new(Queue { + queue: Mutex::new(output), + device: self.device.clone(), + family: family, + id: id, + })) + } + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + let len = self.families_and_ids.len().saturating_sub(self.next_queue); + (len, Some(len)) + } +} + +impl ExactSizeIterator for QueuesIter { +} + +/// Error that can be returned when creating a device. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum DeviceCreationError { + /// Failed to create the device for an implementation-specific reason. + InitializationFailed, + /// You have reached the limit to the number of devices that can be created from the same + /// physical device. + TooManyObjects, + /// Failed to connect to the device. + DeviceLost, + /// Some of the requested features are unsupported by the physical device. + FeatureNotPresent, + /// Some of the requested device extensions are not supported by the physical device. + ExtensionNotPresent, + /// Tried to create too many queues for a given family. + TooManyQueuesForFamily, + /// The priority of one of the queues is out of the [0.0; 1.0] range. + PriorityOutOfRange, + /// There is no memory available on the host (ie. the CPU, RAM, etc.). + OutOfHostMemory, + /// There is no memory available on the device (ie. video memory). + OutOfDeviceMemory, +} + +impl error::Error for DeviceCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + DeviceCreationError::InitializationFailed => { + "failed to create the device for an implementation-specific reason" + }, + DeviceCreationError::OutOfHostMemory => "no memory available on the host", + DeviceCreationError::OutOfDeviceMemory => { + "no memory available on the graphical device" + }, + DeviceCreationError::DeviceLost => { + "failed to connect to the device" + }, + DeviceCreationError::TooManyQueuesForFamily => { + "tried to create too many queues for a given family" + }, + DeviceCreationError::FeatureNotPresent => { + "some of the requested features are unsupported by the physical device" + }, + DeviceCreationError::PriorityOutOfRange => { + "the priority of one of the queues is out of the [0.0; 1.0] range" + }, + DeviceCreationError::ExtensionNotPresent => { + "some of the requested device extensions are not supported by the physical device" + }, + DeviceCreationError::TooManyObjects => { + "you have reached the limit to the number of devices that can be created from the + same physical device" + }, + } + } +} + +impl fmt::Display for DeviceCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for DeviceCreationError { + #[inline] + fn from(err: Error) -> DeviceCreationError { + match err { + Error::InitializationFailed => DeviceCreationError::InitializationFailed, + Error::OutOfHostMemory => DeviceCreationError::OutOfHostMemory, + Error::OutOfDeviceMemory => DeviceCreationError::OutOfDeviceMemory, + Error::DeviceLost => DeviceCreationError::DeviceLost, + Error::ExtensionNotPresent => DeviceCreationError::ExtensionNotPresent, + Error::FeatureNotPresent => DeviceCreationError::FeatureNotPresent, + Error::TooManyObjects => DeviceCreationError::TooManyObjects, + _ => panic!("Unexpected error value: {}", err as i32), + } + } +} + +/// Represents a queue where commands can be submitted. +// TODO: should use internal synchronization? +#[derive(Debug)] +pub struct Queue { + queue: Mutex<vk::Queue>, + device: Arc<Device>, + family: u32, + id: u32, // id within family +} + +impl Queue { + /// Returns the device this queue belongs to. + #[inline] + pub fn device(&self) -> &Arc<Device> { + &self.device + } + + /// Returns true if this is the same queue as another one. + #[inline] + pub fn is_same(&self, other: &Queue) -> bool { + self.id == other.id && self.family == other.family && + self.device.internal_object() == other.device.internal_object() + } + + /// Returns the family this queue belongs to. + #[inline] + pub fn family(&self) -> QueueFamily { + self.device + .physical_device() + .queue_family_by_id(self.family) + .unwrap() + } + + /// Returns the index of this queue within its family. + #[inline] + pub fn id_within_family(&self) -> u32 { + self.id + } + + /// Waits until all work on this queue has finished. + /// + /// Just like `Device::wait()`, you shouldn't have to call this function in a typical program. + #[inline] + pub fn wait(&self) -> Result<(), OomError> { + unsafe { + let vk = self.device.pointers(); + let queue = self.queue.lock().unwrap(); + check_errors(vk.QueueWaitIdle(*queue))?; + Ok(()) + } + } +} + + +unsafe impl DeviceOwned for Queue { + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +unsafe impl SynchronizedVulkanObject for Queue { + type Object = vk::Queue; + + #[inline] + fn internal_object_guard(&self) -> MutexGuard<vk::Queue> { + self.queue.lock().unwrap() + } +} + +#[cfg(test)] +mod tests { + use device::Device; + use device::DeviceCreationError; + use device::DeviceExtensions; + use features::Features; + use instance; + use std::sync::Arc; + + #[test] + fn one_ref() { + let (mut device, _) = gfx_dev_and_queue!(); + assert!(Arc::get_mut(&mut device).is_some()); + } + + #[test] + fn too_many_queues() { + let instance = instance!(); + let physical = match instance::PhysicalDevice::enumerate(&instance).next() { + Some(p) => p, + None => return, + }; + + let family = physical.queue_families().next().unwrap(); + let queues = (0 .. family.queues_count() + 1).map(|_| (family, 1.0)); + + match Device::new(physical, + &Features::none(), + &DeviceExtensions::none(), + queues) { + Err(DeviceCreationError::TooManyQueuesForFamily) => return, // Success + _ => panic!(), + }; + } + + #[test] + fn unsupposed_features() { + let instance = instance!(); + let physical = match instance::PhysicalDevice::enumerate(&instance).next() { + Some(p) => p, + None => return, + }; + + let family = physical.queue_families().next().unwrap(); + + let features = Features::all(); + // In the unlikely situation where the device supports everything, we ignore the test. + if physical.supported_features().superset_of(&features) { + return; + } + + match Device::new(physical, + &features, + &DeviceExtensions::none(), + Some((family, 1.0))) { + Err(DeviceCreationError::FeatureNotPresent) => return, // Success + _ => panic!(), + }; + } + + #[test] + fn priority_out_of_range() { + let instance = instance!(); + let physical = match instance::PhysicalDevice::enumerate(&instance).next() { + Some(p) => p, + None => return, + }; + + let family = physical.queue_families().next().unwrap(); + + match Device::new(physical, + &Features::none(), + &DeviceExtensions::none(), + Some((family, 1.4))) { + Err(DeviceCreationError::PriorityOutOfRange) => (), // Success + _ => panic!(), + }; + + match Device::new(physical, + &Features::none(), + &DeviceExtensions::none(), + Some((family, -0.2))) { + Err(DeviceCreationError::PriorityOutOfRange) => (), // Success + _ => panic!(), + }; + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/extensions.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/extensions.rs new file mode 100644 index 0000000..5b40e15 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/extensions.rs @@ -0,0 +1,227 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::str; + +use Error; +use OomError; +use instance::loader::LoadingError; + +macro_rules! extensions { + ($sname:ident, $rawname:ident, $($ext:ident => $s:expr,)*) => ( + /// List of extensions that are enabled or available. + #[derive(Copy, Clone, PartialEq, Eq)] + #[allow(missing_docs)] + pub struct $sname { + $( + pub $ext: bool, + )* + + /// This field ensures that an instance of this `Extensions` struct + /// can only be created through Vulkano functions and the update + /// syntax. This way, extensions can be added to Vulkano without + /// breaking existing code. + pub _unbuildable: Unbuildable, + } + + impl $sname { + /// Returns an `Extensions` object with all members set to `false`. + #[inline] + pub fn none() -> $sname { + $sname { + $($ext: false,)* + _unbuildable: Unbuildable(()) + } + } + + /// Returns the intersection of this list and another list. + #[inline] + pub fn intersection(&self, other: &$sname) -> $sname { + $sname { + $( + $ext: self.$ext && other.$ext, + )* + _unbuildable: Unbuildable(()) + } + } + + /// Returns the difference of another list from this list. + #[inline] + pub fn difference(&self, other: &$sname) -> $sname { + $sname { + $( + $ext: self.$ext && !other.$ext, + )* + _unbuildable: Unbuildable(()) + } + } + } + + impl fmt::Debug for $sname { + #[allow(unused_assignments)] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "[")); + + let mut first = true; + + $( + if self.$ext { + if !first { try!(write!(f, ", ")); } + else { first = false; } + try!(f.write_str(str::from_utf8($s).unwrap())); + } + )* + + write!(f, "]") + } + } + + /// Set of extensions, not restricted to those vulkano knows about. + /// + /// This is useful when interacting with external code that has statically-unknown extension + /// requirements. + #[derive(Clone, Eq, PartialEq)] + pub struct $rawname(HashSet<CString>); + + impl $rawname { + /// Constructs an extension set containing the supplied extensions. + pub fn new<I>(extensions: I) -> Self + where I: IntoIterator<Item=CString> + { + $rawname(extensions.into_iter().collect()) + } + + /// Constructs an empty extension set. + pub fn none() -> Self { $rawname(HashSet::new()) } + + /// Adds an extension to the set if it is not already present. + pub fn insert(&mut self, extension: CString) { + self.0.insert(extension); + } + + /// Returns the intersection of this set and another. + pub fn intersection(&self, other: &Self) -> Self { + $rawname(self.0.intersection(&other.0).cloned().collect()) + } + + /// Returns the difference of another set from this one. + pub fn difference(&self, other: &Self) -> Self { + $rawname(self.0.difference(&other.0).cloned().collect()) + } + + /// Returns the union of both extension sets + pub fn union(&self, other: &Self) -> Self { + $rawname(self.0.union(&other.0).cloned().collect()) + } + + // TODO: impl Iterator + pub fn iter(&self) -> ::std::collections::hash_set::Iter<CString> { self.0.iter() } + } + + impl fmt::Debug for $rawname { + #[allow(unused_assignments)] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } + } + + impl FromIterator<CString> for $rawname { + fn from_iter<T>(iter: T) -> Self + where T: IntoIterator<Item = CString> + { + $rawname(iter.into_iter().collect()) + } + } + + impl<'a> From<&'a $sname> for $rawname { + fn from(x: &'a $sname) -> Self { + let mut data = HashSet::new(); + $(if x.$ext { data.insert(CString::new(&$s[..]).unwrap()); })* + $rawname(data) + } + } + + impl<'a> From<&'a $rawname> for $sname { + fn from(x: &'a $rawname) -> Self { + let mut extensions = $sname::none(); + $( + if x.0.iter().any(|x| x.as_bytes() == &$s[..]) { + extensions.$ext = true; + } + )* + extensions + } + } + ); +} + +/// Error that can happen when loading the list of layers. +#[derive(Clone, Debug)] +pub enum SupportedExtensionsError { + /// Failed to load the Vulkan shared library. + LoadingError(LoadingError), + /// Not enough memory. + OomError(OomError), +} + +impl error::Error for SupportedExtensionsError { + #[inline] + fn description(&self) -> &str { + match *self { + SupportedExtensionsError::LoadingError(_) => "failed to load the Vulkan shared library", + SupportedExtensionsError::OomError(_) => "not enough memory available", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + SupportedExtensionsError::LoadingError(ref err) => Some(err), + SupportedExtensionsError::OomError(ref err) => Some(err), + } + } +} + +impl fmt::Display for SupportedExtensionsError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for SupportedExtensionsError { + #[inline] + fn from(err: OomError) -> SupportedExtensionsError { + SupportedExtensionsError::OomError(err) + } +} + +impl From<LoadingError> for SupportedExtensionsError { + #[inline] + fn from(err: LoadingError) -> SupportedExtensionsError { + SupportedExtensionsError::LoadingError(err) + } +} + +impl From<Error> for SupportedExtensionsError { + #[inline] + fn from(err: Error) -> SupportedExtensionsError { + match err { + err @ Error::OutOfHostMemory => { + SupportedExtensionsError::OomError(OomError::from(err)) + }, + err @ Error::OutOfDeviceMemory => { + SupportedExtensionsError::OomError(OomError::from(err)) + }, + _ => panic!("unexpected error: {:?}", err), + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/features.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/features.rs new file mode 100644 index 0000000..3ee803a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/features.rs @@ -0,0 +1,180 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use vk; + +macro_rules! features { + ($($name:ident => $vk:ident,)+) => ( + /// Represents all the features that are available on a physical device or enabled on + /// a logical device. + /// + /// Note that the `robust_buffer_access` is guaranteed to be supported by all Vulkan + /// implementations. + /// + /// # Example + /// + /// ``` + /// use vulkano::device::Features; + /// # let physical_device: vulkano::instance::PhysicalDevice = return; + /// let minimal_features = Features { + /// geometry_shader: true, + /// .. Features::none() + /// }; + /// + /// let optimal_features = vulkano::device::Features { + /// geometry_shader: true, + /// tessellation_shader: true, + /// .. Features::none() + /// }; + /// + /// if !physical_device.supported_features().superset_of(&minimal_features) { + /// panic!("The physical device is not good enough for this application."); + /// } + /// + /// assert!(optimal_features.superset_of(&minimal_features)); + /// let features_to_request = optimal_features.intersection(physical_device.supported_features()); + /// ``` + /// + #[derive(Debug, Clone, PartialEq, Eq, Hash)] + #[allow(missing_docs)] + pub struct Features { + $( + pub $name: bool, + )+ + } + + impl Features { + /// Builds a `Features` object with all values to false. + pub fn none() -> Features { + Features { + $( + $name: false, + )+ + } + } + + /// Builds a `Features` object with all values to true. + /// + /// > **Note**: This function is used for testing purposes, and is probably useless in + /// > a real code. + pub fn all() -> Features { + Features { + $( + $name: true, + )+ + } + } + + /// Returns true if `self` is a superset of the parameter. + /// + /// That is, for each feature of the parameter that is true, the corresponding value + /// in self is true as well. + pub fn superset_of(&self, other: &Features) -> bool { + $((self.$name == true || other.$name == false))&&+ + } + + /// Builds a `Features` that is the intersection of `self` and another `Features` + /// object. + /// + /// The result's field will be true if it is also true in both `self` and `other`. + pub fn intersection(&self, other: &Features) -> Features { + Features { + $( + $name: self.$name && other.$name, + )+ + } + } + + /// Builds a `Features` that is the difference of another `Features` object from `self`. + /// + /// The result's field will be true if it is true in `self` but not `other`. + pub fn difference(&self, other: &Features) -> Features { + Features { + $( + $name: self.$name && !other.$name, + )+ + } + } + + pub(crate) fn from_vulkan_features(features: vk::PhysicalDeviceFeatures) -> Features { + Features { + $( + $name: features.$vk != 0, + )+ + } + } + + pub(crate) fn into_vulkan_features(self) -> vk::PhysicalDeviceFeatures { + vk::PhysicalDeviceFeatures { + $( + $vk: if self.$name { vk::TRUE } else { vk::FALSE }, + )+ + } + } + } + ) +} + +features!{ + robust_buffer_access => robustBufferAccess, + full_draw_index_uint32 => fullDrawIndexUint32, + image_cube_array => imageCubeArray, + independent_blend => independentBlend, + geometry_shader => geometryShader, + tessellation_shader => tessellationShader, + sample_rate_shading => sampleRateShading, + dual_src_blend => dualSrcBlend, + logic_op => logicOp, + multi_draw_indirect => multiDrawIndirect, + draw_indirect_first_instance => drawIndirectFirstInstance, + depth_clamp => depthClamp, + depth_bias_clamp => depthBiasClamp, + fill_mode_non_solid => fillModeNonSolid, + depth_bounds => depthBounds, + wide_lines => wideLines, + large_points => largePoints, + alpha_to_one => alphaToOne, + multi_viewport => multiViewport, + sampler_anisotropy => samplerAnisotropy, + texture_compression_etc2 => textureCompressionETC2, + texture_compression_astc_ldr => textureCompressionASTC_LDR, + texture_compression_bc => textureCompressionBC, + occlusion_query_precise => occlusionQueryPrecise, + pipeline_statistics_query => pipelineStatisticsQuery, + vertex_pipeline_stores_and_atomics => vertexPipelineStoresAndAtomics, + fragment_stores_and_atomics => fragmentStoresAndAtomics, + shader_tessellation_and_geometry_point_size => shaderTessellationAndGeometryPointSize, + shader_image_gather_extended => shaderImageGatherExtended, + shader_storage_image_extended_formats => shaderStorageImageExtendedFormats, + shader_storage_image_multisample => shaderStorageImageMultisample, + shader_storage_image_read_without_format => shaderStorageImageReadWithoutFormat, + shader_storage_image_write_without_format => shaderStorageImageWriteWithoutFormat, + shader_uniform_buffer_array_dynamic_indexing => shaderUniformBufferArrayDynamicIndexing, + shader_sampled_image_array_dynamic_indexing => shaderSampledImageArrayDynamicIndexing, + shader_storage_buffer_array_dynamic_indexing => shaderStorageBufferArrayDynamicIndexing, + shader_storage_image_array_dynamic_indexing => shaderStorageImageArrayDynamicIndexing, + shader_clip_distance => shaderClipDistance, + shader_cull_distance => shaderCullDistance, + shader_f3264 => shaderf3264, + shader_int64 => shaderInt64, + shader_int16 => shaderInt16, + shader_resource_residency => shaderResourceResidency, + shader_resource_min_lod => shaderResourceMinLod, + sparse_binding => sparseBinding, + sparse_residency_buffer => sparseResidencyBuffer, + sparse_residency_image2d => sparseResidencyImage2D, + sparse_residency_image3d => sparseResidencyImage3D, + sparse_residency2_samples => sparseResidency2Samples, + sparse_residency4_samples => sparseResidency4Samples, + sparse_residency8_samples => sparseResidency8Samples, + sparse_residency16_samples => sparseResidency16Samples, + sparse_residency_aliased => sparseResidencyAliased, + variable_multisample_rate => variableMultisampleRate, + inherited_queries => inheritedQueries, +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/format.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/format.rs new file mode 100644 index 0000000..5026015 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/format.rs @@ -0,0 +1,958 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Declares all the formats of data and images supported by Vulkan. +//! +//! # Content of this module +//! +//! This module contains three things: +//! +//! - The `Format` enumeration, which contains all the available formats. +//! - The `FormatDesc` trait. +//! - One struct for each format. +//! +//! # Formats +//! +//! List of suffixes: +//! +//! - `Unorm` means that the values are unsigned integers that are converted into floating points. +//! The maximum possible representable value becomes `1.0`, and the minimum representable value +//! becomes `0.0`. For example the value `255` in a `R8Unorm` will be interpreted as `1.0`. +//! +//! - `Snorm` is the same as `Unorm`, but the integers are signed and the range is from `-1.0` to +//! `1.0` instead. +//! +//! - `Uscaled` means that the values are unsigned integers that are converted into floating points. +//! No change in the value is done. For example the value `255` in a `R8Uscaled` will be +//! interpreted as `255.0`. +//! +//! - `Sscaled` is the same as `Uscaled` expect that the integers are signed. +//! +//! - `Uint` means that the values are unsigned integers. No conversion is performed. +//! +//! - `Sint` means that the values are signed integers. No conversion is performed. +//! +//! - `Ufloat` means that the values are unsigned floating points. No conversion is performed. This +//! format is very unusual. +//! +//! - `Sfloat` means that the values are regular floating points. No conversion is performed. +//! +//! - `Srgb` is the same as `Unorm`, except that the value is interpreted as being in the sRGB +//! color space. This means that its value will be converted to fit in the RGB color space when +//! it is read. The fourth channel (usually used for alpha), if present, is not concerned by the +//! conversion. +//! +//! # Choosing a format +//! +//! The following formats are guaranteed to be supported for everything that is related to +//! texturing (ie. blitting source and sampling them linearly). You should choose one of these +//! formats if you have an image that you are going to sample from: +//! +//! // TODO: use vulkano enums +//! - B4G4R4A4_UNORM_PACK16 +//! - R5G6B5_UNORM_PACK16 +//! - A1R5G5B5_UNORM_PACK16 +//! - R8_UNORM +//! - R8_SNORM +//! - R8G8_UNORM +//! - R8G8_SNORM +//! - R8G8B8A8_UNORM +//! - R8G8B8A8_SNORM +//! - R8G8B8A8_SRGB +//! - B8G8R8A8_UNORM +//! - B8G8R8A8_SRGB +//! - A8B8G8R8_UNORM_PACK32 +//! - A8B8G8R8_SNORM_PACK32 +//! - A8B8G8R8_SRGB_PACK32 +//! - A2B10G10R10_UNORM_PACK32 +//! - R16_SFLOAT +//! - R16G16_SFLOAT +//! - R16G16B16A16_SFLOAT +//! - B10G11R11_UFLOAT_PACK32 +//! - E5B9G9R9_UFLOAT_PACK32 +//! +//! The following formats are guaranteed to be supported for everything that is related to +//! intermediate render targets (ie. blitting destination, color attachment and sampling linearly): +//! +//! // TODO: use vulkano enums +//! - R5G6B5_UNORM_PACK16 +//! - A1R5G5B5_UNORM_PACK16 +//! - R8_UNORM +//! - R8G8_UNORM +//! - R8G8B8A8_UNORM +//! - R8G8B8A8_SRGB +//! - B8G8R8A8_UNORM +//! - B8G8R8A8_SRGB +//! - A8B8G8R8_UNORM_PACK32 +//! - A8B8G8R8_SRGB_PACK32 +//! - A2B10G10R10_UNORM_PACK32 +//! - R16_SFLOAT +//! - R16G16_SFLOAT +//! - R16G16B16A16_SFLOAT +//! +//! For depth images, only `D16Unorm` is guaranteed to be supported. For depth-stencil images, +//! it is guaranteed that either `D24Unorm_S8Uint` or `D32Sfloat_S8Uint` are supported. +//! +//! // TODO: storage formats +//! + +use std::{error, fmt, mem}; +use std::vec::IntoIter as VecIntoIter; + +use half::f16; + +use vk; + +// TODO: add enumerations for color, depth, stencil and depthstencil formats + +/// Some data whose type must be known by the library. +/// +/// This trait is unsafe to implement because bad things will happen if `ty()` returns a wrong +/// value. +pub unsafe trait Data { + /// Returns the type of the data from an enum. + fn ty() -> Format; + + // TODO "is_supported" functions that redirect to `Self::ty().is_supported()` +} + +// TODO: that's just an example ; implement for all common data types +unsafe impl Data for i8 { + #[inline] + fn ty() -> Format { + Format::R8Sint + } +} +unsafe impl Data for u8 { + #[inline] + fn ty() -> Format { + Format::R8Uint + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct IncompatiblePixelsType; + +impl error::Error for IncompatiblePixelsType { + #[inline] + fn description(&self) -> &str { + "supplied pixels' type is incompatible with this format" + } +} + +impl fmt::Display for IncompatiblePixelsType { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +pub unsafe trait AcceptsPixels<T> { + /// Returns an error if `T` cannot be used as a source of pixels for `Self`. + fn ensure_accepts(&self) -> Result<(), IncompatiblePixelsType>; + + /// The number of `T`s which make up a single pixel. + /// + /// ``` + /// use vulkano::format::{AcceptsPixels, R8G8B8A8Srgb}; + /// assert_eq!(<R8G8B8A8Srgb as AcceptsPixels<[u8; 4]>>::rate(&R8G8B8A8Srgb), 1); + /// assert_eq!(<R8G8B8A8Srgb as AcceptsPixels<u8>>::rate(&R8G8B8A8Srgb), 4); + /// ``` + /// + /// # Panics + /// + /// May panic if `ensure_accepts` would not return `Ok(())`. + fn rate(&self) -> u32 { + 1 + } +} + +macro_rules! formats { + ($($name:ident => $vk:ident [$sz:expr] [$($f_ty:tt)*] {$($d_ty:tt)*},)+) => ( + /// An enumeration of all the possible formats. + #[derive(Copy, Clone, Debug, PartialEq, Eq)] + #[repr(u32)] + #[allow(missing_docs)] + #[allow(non_camel_case_types)] + pub enum Format { + $($name = vk::$vk,)+ + } + + impl Format { + /*pub fn is_supported_for_vertex_attributes(&self) -> bool { + + } + + .. other functions .. + */ + + /// Returns the size in bytes of an element of this format. Returns `None` if the + /// size is irrelevant (for example for compressed formats). + #[inline] + pub fn size(&self) -> Option<usize> { + match *self { + $( + Format::$name => $sz, + )+ + } + } + + /// Returns the `Format` corresponding to a Vulkan constant. + pub(crate) fn from_vulkan_num(val: u32) -> Option<Format> { + match val { + $( + vk::$vk => Some(Format::$name), + )+ + _ => None, + } + } + + #[inline] + pub fn ty(&self) -> FormatTy { + match *self { + $( + Format::$name => formats!(__inner_ty__ $name $($f_ty)*), + )+ + } + } + } + + $( + #[derive(Debug, Copy, Clone, Default)] + #[allow(missing_docs)] + #[allow(non_camel_case_types)] + pub struct $name; + + formats!(__inner_impl__ $name $($f_ty)*); + formats!(__inner_strongstorage__ $name $($d_ty)*); + )+ + ); + + (__inner_impl__ $name:ident float=$num:expr) => { + unsafe impl FormatDesc for $name { + type ClearValue = [f32; $num]; + + #[inline] + fn format(&self) -> Format { + Format::$name + } + + #[inline] + fn decode_clear_value(&self, val: Self::ClearValue) -> ClearValue { + val.into() + } + } + unsafe impl PossibleFloatFormatDesc for $name { + #[inline(always)] + fn is_float(&self) -> bool { true } + } + unsafe impl PossibleFloatOrCompressedFormatDesc for $name { + #[inline(always)] + fn is_float_or_compressed(&self) -> bool { true } + } + }; + + (__inner_impl__ $name:ident uint=$num:expr) => { + unsafe impl FormatDesc for $name { + type ClearValue = [u32; $num]; + + #[inline] + fn format(&self) -> Format { + Format::$name + } + + #[inline] + fn decode_clear_value(&self, val: Self::ClearValue) -> ClearValue { + val.into() + } + } + + unsafe impl PossibleUintFormatDesc for $name { + #[inline(always)] + fn is_uint(&self) -> bool { true } + } + }; + + (__inner_impl__ $name:ident sint=$num:expr) => { + unsafe impl FormatDesc for $name { + type ClearValue = [i32; $num]; + + #[inline] + fn format(&self) -> Format { + Format::$name + } + + #[inline] + fn decode_clear_value(&self, val: Self::ClearValue) -> ClearValue { + val.into() + } + } + + unsafe impl PossibleSintFormatDesc for $name { + #[inline(always)] + fn is_sint(&self) -> bool { true } + } + }; + + (__inner_impl__ $name:ident depth) => { + unsafe impl FormatDesc for $name { + type ClearValue = f32; + + #[inline] + fn format(&self) -> Format { + Format::$name + } + + #[inline] + fn decode_clear_value(&self, val: Self::ClearValue) -> ClearValue { + val.into() + } + } + + unsafe impl PossibleDepthFormatDesc for $name { + #[inline(always)] + fn is_depth(&self) -> bool { true } + } + }; + + (__inner_impl__ $name:ident stencil) => { + unsafe impl FormatDesc for $name { + type ClearValue = u32; // FIXME: shouldn't stencil be i32? + + #[inline] + fn format(&self) -> Format { + Format::$name + } + + #[inline] + fn decode_clear_value(&self, val: Self::ClearValue) -> ClearValue { + val.into() + } + } + + unsafe impl PossibleStencilFormatDesc for $name { + #[inline(always)] + fn is_stencil(&self) -> bool { true } + } + }; + + (__inner_impl__ $name:ident depthstencil) => { + unsafe impl FormatDesc for $name { + type ClearValue = (f32, u32); // FIXME: shouldn't stencil be i32? + + #[inline] + fn format(&self) -> Format { + Format::$name + } + + #[inline] + fn decode_clear_value(&self, val: Self::ClearValue) -> ClearValue { + val.into() + } + } + + unsafe impl PossibleDepthStencilFormatDesc for $name { + #[inline(always)] + fn is_depth_stencil(&self) -> bool { true } + } + }; + + (__inner_impl__ $name:ident compressed = $feature:ident) => { + unsafe impl FormatDesc for $name { + type ClearValue = [f32; 4]; + + #[inline] + fn format(&self) -> Format { + Format::$name + } + + #[inline] + fn decode_clear_value(&self, val: Self::ClearValue) -> ClearValue { + val.into() + } + } + + unsafe impl PossibleCompressedFormatDesc for $name { + #[inline(always)] + fn is_compressed(&self) -> bool { true } + } + unsafe impl PossibleFloatOrCompressedFormatDesc for $name { + #[inline(always)] + fn is_float_or_compressed(&self) -> bool { true } + } + }; + + (__inner_ty__ $name:ident float=$num:tt) => { FormatTy::Float }; + (__inner_ty__ $name:ident uint=$num:tt) => { FormatTy::Uint }; + (__inner_ty__ $name:ident sint=$num:tt) => { FormatTy::Sint }; + (__inner_ty__ $name:ident depth) => { FormatTy::Depth }; + (__inner_ty__ $name:ident stencil) => { FormatTy::Stencil }; + (__inner_ty__ $name:ident depthstencil) => { FormatTy::DepthStencil }; + (__inner_ty__ $name:ident compressed=$f:tt) => { FormatTy::Compressed }; + + + (__inner_strongstorage__ $name:ident [$ty:ty; $dim:expr]) => { + formats!(__inner_strongstorage_common__ $name [$ty; $dim]); + unsafe impl AcceptsPixels<$ty> for $name { + fn ensure_accepts(&self) -> Result<(), IncompatiblePixelsType> { Ok(()) } + fn rate(&self) -> u32 { $dim } + } + }; + (__inner_strongstorage__ $name:ident $ty:ty) => { + formats!(__inner_strongstorage_common__ $name $ty); + }; + (__inner_strongstorage__ $name:ident ) => {}; + + (__inner_strongstorage_common__ $name:ident $ty:ty) => { + unsafe impl StrongStorage for $name { + type Pixel = $ty; + } + unsafe impl AcceptsPixels<$ty> for $name { + fn ensure_accepts(&self) -> Result<(), IncompatiblePixelsType> { Ok(()) } + } + }; +} + +formats! { + R4G4UnormPack8 => FORMAT_R4G4_UNORM_PACK8 [Some(1)] [float=2] {u8}, + R4G4B4A4UnormPack16 => FORMAT_R4G4B4A4_UNORM_PACK16 [Some(2)] [float=4] {u16}, + B4G4R4A4UnormPack16 => FORMAT_B4G4R4A4_UNORM_PACK16 [Some(2)] [float=4] {u16}, + R5G6B5UnormPack16 => FORMAT_R5G6B5_UNORM_PACK16 [Some(2)] [float=3] {u16}, + B5G6R5UnormPack16 => FORMAT_B5G6R5_UNORM_PACK16 [Some(2)] [float=3] {u16}, + R5G5B5A1UnormPack16 => FORMAT_R5G5B5A1_UNORM_PACK16 [Some(2)] [float=4] {u16}, + B5G5R5A1UnormPack16 => FORMAT_B5G5R5A1_UNORM_PACK16 [Some(2)] [float=4] {u16}, + A1R5G5B5UnormPack16 => FORMAT_A1R5G5B5_UNORM_PACK16 [Some(2)] [float=4] {u16}, + R8Unorm => FORMAT_R8_UNORM [Some(1)] [float=1] {u8}, + R8Snorm => FORMAT_R8_SNORM [Some(1)] [float=1] {i8}, + R8Uscaled => FORMAT_R8_USCALED [Some(1)] [float=1] {u8}, + R8Sscaled => FORMAT_R8_SSCALED [Some(1)] [float=1] {i8}, + R8Uint => FORMAT_R8_UINT [Some(1)] [uint=1] {u8}, + R8Sint => FORMAT_R8_SINT [Some(1)] [sint=1] {i8}, + R8Srgb => FORMAT_R8_SRGB [Some(1)] [float=1] {u8}, + R8G8Unorm => FORMAT_R8G8_UNORM [Some(2)] [float=2] {[u8; 2]}, + R8G8Snorm => FORMAT_R8G8_SNORM [Some(2)] [float=2] {[i8; 2]}, + R8G8Uscaled => FORMAT_R8G8_USCALED [Some(2)] [float=2] {[u8; 2]}, + R8G8Sscaled => FORMAT_R8G8_SSCALED [Some(2)] [float=2] {[i8; 2]}, + R8G8Uint => FORMAT_R8G8_UINT [Some(2)] [uint=2] {[u8; 2]}, + R8G8Sint => FORMAT_R8G8_SINT [Some(2)] [sint=2] {[i8; 2]}, + R8G8Srgb => FORMAT_R8G8_SRGB [Some(2)] [float=2] {[u8; 2]}, + R8G8B8Unorm => FORMAT_R8G8B8_UNORM [Some(3)] [float=3] {[u8; 3]}, + R8G8B8Snorm => FORMAT_R8G8B8_SNORM [Some(3)] [float=3] {[i8; 3]}, + R8G8B8Uscaled => FORMAT_R8G8B8_USCALED [Some(3)] [float=3] {[u8; 3]}, + R8G8B8Sscaled => FORMAT_R8G8B8_SSCALED [Some(3)] [float=3] {[i8; 3]}, + R8G8B8Uint => FORMAT_R8G8B8_UINT [Some(3)] [uint=3] {[u8; 3]}, + R8G8B8Sint => FORMAT_R8G8B8_SINT [Some(3)] [sint=3] {[i8; 3]}, + R8G8B8Srgb => FORMAT_R8G8B8_SRGB [Some(3)] [float=3] {[u8; 3]}, + B8G8R8Unorm => FORMAT_B8G8R8_UNORM [Some(3)] [float=3] {[u8; 3]}, + B8G8R8Snorm => FORMAT_B8G8R8_SNORM [Some(3)] [float=3] {[i8; 3]}, + B8G8R8Uscaled => FORMAT_B8G8R8_USCALED [Some(3)] [float=3] {[u8; 3]}, + B8G8R8Sscaled => FORMAT_B8G8R8_SSCALED [Some(3)] [float=3] {[i8; 3]}, + B8G8R8Uint => FORMAT_B8G8R8_UINT [Some(3)] [uint=3] {[u8; 3]}, + B8G8R8Sint => FORMAT_B8G8R8_SINT [Some(3)] [sint=3] {[i8; 3]}, + B8G8R8Srgb => FORMAT_B8G8R8_SRGB [Some(3)] [float=3] {[u8; 3]}, + R8G8B8A8Unorm => FORMAT_R8G8B8A8_UNORM [Some(4)] [float=4] {[u8; 4]}, + R8G8B8A8Snorm => FORMAT_R8G8B8A8_SNORM [Some(4)] [float=4] {[i8; 4]}, + R8G8B8A8Uscaled => FORMAT_R8G8B8A8_USCALED [Some(4)] [float=4] {[u8; 4]}, + R8G8B8A8Sscaled => FORMAT_R8G8B8A8_SSCALED [Some(4)] [float=4] {[i8; 4]}, + R8G8B8A8Uint => FORMAT_R8G8B8A8_UINT [Some(4)] [uint=4] {[u8; 4]}, + R8G8B8A8Sint => FORMAT_R8G8B8A8_SINT [Some(4)] [sint=4] {[i8; 4]}, + R8G8B8A8Srgb => FORMAT_R8G8B8A8_SRGB [Some(4)] [float=4] {[u8; 4]}, + B8G8R8A8Unorm => FORMAT_B8G8R8A8_UNORM [Some(4)] [float=4] {[u8; 4]}, + B8G8R8A8Snorm => FORMAT_B8G8R8A8_SNORM [Some(4)] [float=4] {[i8; 4]}, + B8G8R8A8Uscaled => FORMAT_B8G8R8A8_USCALED [Some(4)] [float=4] {[u8; 4]}, + B8G8R8A8Sscaled => FORMAT_B8G8R8A8_SSCALED [Some(4)] [float=4] {[i8; 4]}, + B8G8R8A8Uint => FORMAT_B8G8R8A8_UINT [Some(4)] [uint=4] {[u8; 4]}, + B8G8R8A8Sint => FORMAT_B8G8R8A8_SINT [Some(4)] [sint=4] {[i8; 4]}, + B8G8R8A8Srgb => FORMAT_B8G8R8A8_SRGB [Some(4)] [float=4] {[u8; 4]}, + A8B8G8R8UnormPack32 => FORMAT_A8B8G8R8_UNORM_PACK32 [Some(4)] [float=4] {[u8; 4]}, + A8B8G8R8SnormPack32 => FORMAT_A8B8G8R8_SNORM_PACK32 [Some(4)] [float=4] {[i8; 4]}, + A8B8G8R8UscaledPack32 => FORMAT_A8B8G8R8_USCALED_PACK32 [Some(4)] [float=4] {[u8; 4]}, + A8B8G8R8SscaledPack32 => FORMAT_A8B8G8R8_SSCALED_PACK32 [Some(4)] [float=4] {[i8; 4]}, + A8B8G8R8UintPack32 => FORMAT_A8B8G8R8_UINT_PACK32 [Some(4)] [uint=4] {[u8; 4]}, + A8B8G8R8SintPack32 => FORMAT_A8B8G8R8_SINT_PACK32 [Some(4)] [sint=4] {[i8; 4]}, + A8B8G8R8SrgbPack32 => FORMAT_A8B8G8R8_SRGB_PACK32 [Some(4)] [float=4] {[u8; 4]}, + A2R10G10B10UnormPack32 => FORMAT_A2R10G10B10_UNORM_PACK32 [Some(4)] [float=4] {u32}, + A2R10G10B10SnormPack32 => FORMAT_A2R10G10B10_SNORM_PACK32 [Some(4)] [float=4] {u32}, + A2R10G10B10UscaledPack32 => FORMAT_A2R10G10B10_USCALED_PACK32 [Some(4)] [float=4] {u32}, + A2R10G10B10SscaledPack32 => FORMAT_A2R10G10B10_SSCALED_PACK32 [Some(4)] [float=4] {u32}, + A2R10G10B10UintPack32 => FORMAT_A2R10G10B10_UINT_PACK32 [Some(4)] [uint=4] {u32}, + A2R10G10B10SintPack32 => FORMAT_A2R10G10B10_SINT_PACK32 [Some(4)] [sint=4] {u32}, + A2B10G10R10UnormPack32 => FORMAT_A2B10G10R10_UNORM_PACK32 [Some(4)] [float=4] {u32}, + A2B10G10R10SnormPack32 => FORMAT_A2B10G10R10_SNORM_PACK32 [Some(4)] [float=4] {u32}, + A2B10G10R10UscaledPack32 => FORMAT_A2B10G10R10_USCALED_PACK32 [Some(4)] [float=4] {u32}, + A2B10G10R10SscaledPack32 => FORMAT_A2B10G10R10_SSCALED_PACK32 [Some(4)] [float=4] {u32}, + A2B10G10R10UintPack32 => FORMAT_A2B10G10R10_UINT_PACK32 [Some(4)] [uint=4] {u32}, + A2B10G10R10SintPack32 => FORMAT_A2B10G10R10_SINT_PACK32 [Some(4)] [sint=4] {u32}, + R16Unorm => FORMAT_R16_UNORM [Some(2)] [float=1] {u16}, + R16Snorm => FORMAT_R16_SNORM [Some(2)] [float=1] {i16}, + R16Uscaled => FORMAT_R16_USCALED [Some(2)] [float=1] {u16}, + R16Sscaled => FORMAT_R16_SSCALED [Some(2)] [float=1] {i16}, + R16Uint => FORMAT_R16_UINT [Some(2)] [uint=1] {u16}, + R16Sint => FORMAT_R16_SINT [Some(2)] [sint=1] {i16}, + R16Sfloat => FORMAT_R16_SFLOAT [Some(2)] [float=1] {f16}, + R16G16Unorm => FORMAT_R16G16_UNORM [Some(4)] [float=2] {[u16; 2]}, + R16G16Snorm => FORMAT_R16G16_SNORM [Some(4)] [float=2] {[i16; 2]}, + R16G16Uscaled => FORMAT_R16G16_USCALED [Some(4)] [float=2] {[u16; 2]}, + R16G16Sscaled => FORMAT_R16G16_SSCALED [Some(4)] [float=2] {[i16; 2]}, + R16G16Uint => FORMAT_R16G16_UINT [Some(4)] [uint=2] {[u16; 2]}, + R16G16Sint => FORMAT_R16G16_SINT [Some(4)] [sint=2] {[i16; 2]}, + R16G16Sfloat => FORMAT_R16G16_SFLOAT [Some(4)] [float=2] {[f16; 2]}, + R16G16B16Unorm => FORMAT_R16G16B16_UNORM [Some(6)] [float=3] {[u16; 3]}, + R16G16B16Snorm => FORMAT_R16G16B16_SNORM [Some(6)] [float=3] {[i16; 3]}, + R16G16B16Uscaled => FORMAT_R16G16B16_USCALED [Some(6)] [float=3] {[u16; 3]}, + R16G16B16Sscaled => FORMAT_R16G16B16_SSCALED [Some(6)] [float=3] {[i16; 3]}, + R16G16B16Uint => FORMAT_R16G16B16_UINT [Some(6)] [uint=3] {[u16; 3]}, + R16G16B16Sint => FORMAT_R16G16B16_SINT [Some(6)] [sint=3] {[i16; 3]}, + R16G16B16Sfloat => FORMAT_R16G16B16_SFLOAT [Some(6)] [float=3] {[f16; 3]}, + R16G16B16A16Unorm => FORMAT_R16G16B16A16_UNORM [Some(8)] [float=4] {[u16; 4]}, + R16G16B16A16Snorm => FORMAT_R16G16B16A16_SNORM [Some(8)] [float=4] {[i16; 4]}, + R16G16B16A16Uscaled => FORMAT_R16G16B16A16_USCALED [Some(8)] [float=4] {[u16; 4]}, + R16G16B16A16Sscaled => FORMAT_R16G16B16A16_SSCALED [Some(8)] [float=4] {[i16; 4]}, + R16G16B16A16Uint => FORMAT_R16G16B16A16_UINT [Some(8)] [uint=4] {[u16; 4]}, + R16G16B16A16Sint => FORMAT_R16G16B16A16_SINT [Some(8)] [sint=4] {[i16; 4]}, + R16G16B16A16Sfloat => FORMAT_R16G16B16A16_SFLOAT [Some(8)] [float=4] {[f16; 4]}, + R32Uint => FORMAT_R32_UINT [Some(4)] [uint=1] {u32}, + R32Sint => FORMAT_R32_SINT [Some(4)] [sint=1] {i32}, + R32Sfloat => FORMAT_R32_SFLOAT [Some(4)] [float=1] {f32}, + R32G32Uint => FORMAT_R32G32_UINT [Some(8)] [uint=2] {[u32; 2]}, + R32G32Sint => FORMAT_R32G32_SINT [Some(8)] [sint=2] {[i32; 2]}, + R32G32Sfloat => FORMAT_R32G32_SFLOAT [Some(8)] [float=2] {[f32; 2]}, + R32G32B32Uint => FORMAT_R32G32B32_UINT [Some(12)] [uint=3] {[u32; 3]}, + R32G32B32Sint => FORMAT_R32G32B32_SINT [Some(12)] [sint=3] {[i32; 3]}, + R32G32B32Sfloat => FORMAT_R32G32B32_SFLOAT [Some(12)] [float=3] {[f32; 3]}, + R32G32B32A32Uint => FORMAT_R32G32B32A32_UINT [Some(16)] [uint=4] {[u32; 4]}, + R32G32B32A32Sint => FORMAT_R32G32B32A32_SINT [Some(16)] [sint=4] {[i32; 4]}, + R32G32B32A32Sfloat => FORMAT_R32G32B32A32_SFLOAT [Some(16)] [float=4] {[f32; 4]}, + R64Uint => FORMAT_R64_UINT [Some(8)] [uint=1] {u64}, + R64Sint => FORMAT_R64_SINT [Some(8)] [sint=1] {i64}, + R64Sfloat => FORMAT_R64_SFLOAT [Some(8)] [float=1] {f64}, + R64G64Uint => FORMAT_R64G64_UINT [Some(16)] [uint=2] {[u64; 2]}, + R64G64Sint => FORMAT_R64G64_SINT [Some(16)] [sint=2] {[i64; 2]}, + R64G64Sfloat => FORMAT_R64G64_SFLOAT [Some(16)] [float=2] {[f64; 2]}, + R64G64B64Uint => FORMAT_R64G64B64_UINT [Some(24)] [uint=3] {[u64; 3]}, + R64G64B64Sint => FORMAT_R64G64B64_SINT [Some(24)] [sint=3] {[i64; 3]}, + R64G64B64Sfloat => FORMAT_R64G64B64_SFLOAT [Some(24)] [float=3] {[f64; 3]}, + R64G64B64A64Uint => FORMAT_R64G64B64A64_UINT [Some(32)] [uint=4] {[u64; 4]}, + R64G64B64A64Sint => FORMAT_R64G64B64A64_SINT [Some(32)] [sint=4] {[i64; 4]}, + R64G64B64A64Sfloat => FORMAT_R64G64B64A64_SFLOAT [Some(32)] [float=4] {[f64; 4]}, + B10G11R11UfloatPack32 => FORMAT_B10G11R11_UFLOAT_PACK32 [Some(4)] [float=3] {u32}, + E5B9G9R9UfloatPack32 => FORMAT_E5B9G9R9_UFLOAT_PACK32 [Some(4)] [float=3] {u32}, + D16Unorm => FORMAT_D16_UNORM [Some(2)] [depth] {}, + X8_D24UnormPack32 => FORMAT_X8_D24_UNORM_PACK32 [Some(4)] [depth] {}, + D32Sfloat => FORMAT_D32_SFLOAT [Some(4)] [depth] {}, + S8Uint => FORMAT_S8_UINT [Some(1)] [stencil] {}, + D16Unorm_S8Uint => FORMAT_D16_UNORM_S8_UINT [None] [depthstencil] {}, + D24Unorm_S8Uint => FORMAT_D24_UNORM_S8_UINT [None] [depthstencil] {}, + D32Sfloat_S8Uint => FORMAT_D32_SFLOAT_S8_UINT [None] [depthstencil] {}, + BC1_RGBUnormBlock => FORMAT_BC1_RGB_UNORM_BLOCK [None] [compressed=texture_compression_bc] {}, + BC1_RGBSrgbBlock => FORMAT_BC1_RGB_SRGB_BLOCK [None] [compressed=texture_compression_bc] {}, + BC1_RGBAUnormBlock => FORMAT_BC1_RGBA_UNORM_BLOCK [None] [compressed=texture_compression_bc] {}, + BC1_RGBASrgbBlock => FORMAT_BC1_RGBA_SRGB_BLOCK [None] [compressed=texture_compression_bc] {}, + BC2UnormBlock => FORMAT_BC2_UNORM_BLOCK [None] [compressed=texture_compression_bc] {}, + BC2SrgbBlock => FORMAT_BC2_SRGB_BLOCK [None] [compressed=texture_compression_bc] {}, + BC3UnormBlock => FORMAT_BC3_UNORM_BLOCK [None] [compressed=texture_compression_bc] {}, + BC3SrgbBlock => FORMAT_BC3_SRGB_BLOCK [None] [compressed=texture_compression_bc] {}, + BC4UnormBlock => FORMAT_BC4_UNORM_BLOCK [None] [compressed=texture_compression_bc] {}, + BC4SnormBlock => FORMAT_BC4_SNORM_BLOCK [None] [compressed=texture_compression_bc] {}, + BC5UnormBlock => FORMAT_BC5_UNORM_BLOCK [None] [compressed=texture_compression_bc] {}, + BC5SnormBlock => FORMAT_BC5_SNORM_BLOCK [None] [compressed=texture_compression_bc] {}, + BC6HUfloatBlock => FORMAT_BC6H_UFLOAT_BLOCK [None] [compressed=texture_compression_bc] {}, + BC6HSfloatBlock => FORMAT_BC6H_SFLOAT_BLOCK [None] [compressed=texture_compression_bc] {}, + BC7UnormBlock => FORMAT_BC7_UNORM_BLOCK [None] [compressed=texture_compression_bc] {}, + BC7SrgbBlock => FORMAT_BC7_SRGB_BLOCK [None] [compressed=texture_compression_bc] {}, + ETC2_R8G8B8UnormBlock => FORMAT_ETC2_R8G8B8_UNORM_BLOCK [None] [compressed=texture_compression_etc2] {}, + ETC2_R8G8B8SrgbBlock => FORMAT_ETC2_R8G8B8_SRGB_BLOCK [None] [compressed=texture_compression_etc2] {}, + ETC2_R8G8B8A1UnormBlock => FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK [None] [compressed=texture_compression_etc2] {}, + ETC2_R8G8B8A1SrgbBlock => FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK [None] [compressed=texture_compression_etc2] {}, + ETC2_R8G8B8A8UnormBlock => FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK [None] [compressed=texture_compression_etc2] {}, + ETC2_R8G8B8A8SrgbBlock => FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK [None] [compressed=texture_compression_etc2] {}, + EAC_R11UnormBlock => FORMAT_EAC_R11_UNORM_BLOCK [None] [compressed=texture_compression_etc2] {}, + EAC_R11SnormBlock => FORMAT_EAC_R11_SNORM_BLOCK [None] [compressed=texture_compression_etc2] {}, + EAC_R11G11UnormBlock => FORMAT_EAC_R11G11_UNORM_BLOCK [None] [compressed=texture_compression_etc2] {}, + EAC_R11G11SnormBlock => FORMAT_EAC_R11G11_SNORM_BLOCK [None] [compressed=texture_compression_etc2] {}, + ASTC_4x4UnormBlock => FORMAT_ASTC_4x4_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_4x4SrgbBlock => FORMAT_ASTC_4x4_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_5x4UnormBlock => FORMAT_ASTC_5x4_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_5x4SrgbBlock => FORMAT_ASTC_5x4_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_5x5UnormBlock => FORMAT_ASTC_5x5_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_5x5SrgbBlock => FORMAT_ASTC_5x5_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_6x5UnormBlock => FORMAT_ASTC_6x5_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_6x5SrgbBlock => FORMAT_ASTC_6x5_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_6x6UnormBlock => FORMAT_ASTC_6x6_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_6x6SrgbBlock => FORMAT_ASTC_6x6_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_8x5UnormBlock => FORMAT_ASTC_8x5_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_8x5SrgbBlock => FORMAT_ASTC_8x5_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_8x6UnormBlock => FORMAT_ASTC_8x6_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_8x6SrgbBlock => FORMAT_ASTC_8x6_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_8x8UnormBlock => FORMAT_ASTC_8x8_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_8x8SrgbBlock => FORMAT_ASTC_8x8_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_10x5UnormBlock => FORMAT_ASTC_10x5_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_10x5SrgbBlock => FORMAT_ASTC_10x5_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_10x6UnormBlock => FORMAT_ASTC_10x6_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_10x6SrgbBlock => FORMAT_ASTC_10x6_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_10x8UnormBlock => FORMAT_ASTC_10x8_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_10x8SrgbBlock => FORMAT_ASTC_10x8_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_10x10UnormBlock => FORMAT_ASTC_10x10_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_10x10SrgbBlock => FORMAT_ASTC_10x10_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_12x10UnormBlock => FORMAT_ASTC_12x10_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_12x10SrgbBlock => FORMAT_ASTC_12x10_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_12x12UnormBlock => FORMAT_ASTC_12x12_UNORM_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, + ASTC_12x12SrgbBlock => FORMAT_ASTC_12x12_SRGB_BLOCK [None] [compressed=texture_compression_astc_ldr] {}, +} + +pub unsafe trait FormatDesc { + type ClearValue; + + fn format(&self) -> Format; + + fn decode_clear_value(&self, Self::ClearValue) -> ClearValue; +} + +unsafe impl FormatDesc for Format { + type ClearValue = ClearValue; + + #[inline] + fn format(&self) -> Format { + *self + } + + fn decode_clear_value(&self, value: Self::ClearValue) -> ClearValue { + match (self.ty(), value) { + (FormatTy::Float, f @ ClearValue::Float(_)) => f, + (FormatTy::Compressed, f @ ClearValue::Float(_)) => f, + (FormatTy::Sint, f @ ClearValue::Int(_)) => f, + (FormatTy::Uint, f @ ClearValue::Uint(_)) => f, + (FormatTy::Depth, f @ ClearValue::Depth(_)) => f, + (FormatTy::Stencil, f @ ClearValue::Stencil(_)) => f, + (FormatTy::DepthStencil, f @ ClearValue::DepthStencil(_)) => f, + _ => panic!("Wrong clear value"), + } + } +} + +/// Trait for types that can possibly describe a float attachment. +pub unsafe trait PossibleFloatFormatDesc: FormatDesc { + /// Returns true if the format is a float format. + fn is_float(&self) -> bool; +} + +unsafe impl PossibleFloatFormatDesc for Format { + #[inline] + fn is_float(&self) -> bool { + self.ty() == FormatTy::Float + } +} + +pub unsafe trait PossibleUintFormatDesc: FormatDesc { + fn is_uint(&self) -> bool; +} + +unsafe impl PossibleUintFormatDesc for Format { + #[inline] + fn is_uint(&self) -> bool { + self.ty() == FormatTy::Uint + } +} + +pub unsafe trait PossibleSintFormatDesc: FormatDesc { + fn is_sint(&self) -> bool; +} + +unsafe impl PossibleSintFormatDesc for Format { + #[inline] + fn is_sint(&self) -> bool { + self.ty() == FormatTy::Sint + } +} + +pub unsafe trait PossibleDepthFormatDesc: FormatDesc { + fn is_depth(&self) -> bool; +} + +unsafe impl PossibleDepthFormatDesc for Format { + #[inline] + fn is_depth(&self) -> bool { + self.ty() == FormatTy::Depth + } +} + +pub unsafe trait PossibleStencilFormatDesc: FormatDesc { + fn is_stencil(&self) -> bool; +} + +unsafe impl PossibleStencilFormatDesc for Format { + #[inline] + fn is_stencil(&self) -> bool { + self.ty() == FormatTy::Stencil + } +} + +pub unsafe trait PossibleDepthStencilFormatDesc: FormatDesc { + fn is_depth_stencil(&self) -> bool; +} + +unsafe impl PossibleDepthStencilFormatDesc for Format { + #[inline] + fn is_depth_stencil(&self) -> bool { + self.ty() == FormatTy::DepthStencil + } +} + +pub unsafe trait PossibleCompressedFormatDesc: FormatDesc { + fn is_compressed(&self) -> bool; +} + +unsafe impl PossibleCompressedFormatDesc for Format { + #[inline] + fn is_compressed(&self) -> bool { + self.ty() == FormatTy::Compressed + } +} + +/// Trait for types that can possibly describe a float or compressed attachment. +pub unsafe trait PossibleFloatOrCompressedFormatDesc: FormatDesc { + /// Returns true if the format is a float or compressed format. + fn is_float_or_compressed(&self) -> bool; +} + +unsafe impl PossibleFloatOrCompressedFormatDesc for Format { + #[inline] + fn is_float_or_compressed(&self) -> bool { + self.ty() == FormatTy::Float || self.ty() == FormatTy::Compressed + } +} + +macro_rules! impl_pixel { + {$($ty:ty;)+} => { + $(impl_pixel!(inner $ty);)* + $(impl_pixel!(inner [$ty; 1]);)* + $(impl_pixel!(inner [$ty; 2]);)* + $(impl_pixel!(inner [$ty; 3]);)* + $(impl_pixel!(inner [$ty; 4]);)* + $(impl_pixel!(inner ($ty,));)* + $(impl_pixel!(inner ($ty, $ty));)* + $(impl_pixel!(inner ($ty, $ty, $ty));)* + $(impl_pixel!(inner ($ty, $ty, $ty, $ty));)* + }; + (inner $ty:ty) => { + unsafe impl AcceptsPixels<$ty> for Format { + fn ensure_accepts(&self) -> Result<(), IncompatiblePixelsType> { + // TODO: Be more strict: accept only if the format has a matching AcceptsPixels impl. + if self.size().map_or(false, |x| x % mem::size_of::<$ty>() == 0) { + Ok(()) + } else { + Err(IncompatiblePixelsType) + } + } + fn rate(&self) -> u32 { + (self.size().expect("this format cannot accept pixels") / mem::size_of::<$ty>()) as u32 + } + } + } +} + +impl_pixel! { + u8; i8; u16; i16; u32; i32; u64; i64; f16; f32; f64; +} + +pub unsafe trait StrongStorage: FormatDesc { + type Pixel: Copy; +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum FormatTy { + Float, + Uint, + Sint, + Depth, + Stencil, + DepthStencil, + Compressed, +} + +impl FormatTy { + /// Returns true if `Depth`, `Stencil`, `DepthStencil`. False otherwise. + #[inline] + pub fn is_depth_and_or_stencil(&self) -> bool { + match *self { + FormatTy::Depth => true, + FormatTy::Stencil => true, + FormatTy::DepthStencil => true, + _ => false, + } + } +} + +/// Describes a uniform value that will be used to fill an image. +// TODO: should have the same layout as `vk::ClearValue` for performance +#[derive(Debug, Copy, Clone, PartialEq)] +pub enum ClearValue { + /// Entry for attachments that aren't cleared. + None, + /// Value for floating-point attachments, including `Unorm`, `Snorm`, `Sfloat`. + Float([f32; 4]), + /// Value for integer attachments, including `Int`. + Int([i32; 4]), + /// Value for unsigned integer attachments, including `Uint`. + Uint([u32; 4]), + /// Value for depth attachments. + Depth(f32), + /// Value for stencil attachments. + Stencil(u32), + /// Value for depth and stencil attachments. + DepthStencil((f32, u32)), +} + +// TODO: remove all these From implementations once they are no longer needed + +impl From<[f32; 1]> for ClearValue { + #[inline] + fn from(val: [f32; 1]) -> ClearValue { + ClearValue::Float([val[0], 0.0, 0.0, 1.0]) + } +} + +impl From<[f32; 2]> for ClearValue { + #[inline] + fn from(val: [f32; 2]) -> ClearValue { + ClearValue::Float([val[0], val[1], 0.0, 1.0]) + } +} + +impl From<[f32; 3]> for ClearValue { + #[inline] + fn from(val: [f32; 3]) -> ClearValue { + ClearValue::Float([val[0], val[1], val[2], 1.0]) + } +} + +impl From<[f32; 4]> for ClearValue { + #[inline] + fn from(val: [f32; 4]) -> ClearValue { + ClearValue::Float(val) + } +} + +impl From<[u32; 1]> for ClearValue { + #[inline] + fn from(val: [u32; 1]) -> ClearValue { + ClearValue::Uint([val[0], 0, 0, 0]) // TODO: is alpha value 0 correct? + } +} + +impl From<[u32; 2]> for ClearValue { + #[inline] + fn from(val: [u32; 2]) -> ClearValue { + ClearValue::Uint([val[0], val[1], 0, 0]) // TODO: is alpha value 0 correct? + } +} + +impl From<[u32; 3]> for ClearValue { + #[inline] + fn from(val: [u32; 3]) -> ClearValue { + ClearValue::Uint([val[0], val[1], val[2], 0]) // TODO: is alpha value 0 correct? + } +} + +impl From<[u32; 4]> for ClearValue { + #[inline] + fn from(val: [u32; 4]) -> ClearValue { + ClearValue::Uint(val) + } +} + +impl From<[i32; 1]> for ClearValue { + #[inline] + fn from(val: [i32; 1]) -> ClearValue { + ClearValue::Int([val[0], 0, 0, 0]) // TODO: is alpha value 0 correct? + } +} + +impl From<[i32; 2]> for ClearValue { + #[inline] + fn from(val: [i32; 2]) -> ClearValue { + ClearValue::Int([val[0], val[1], 0, 0]) // TODO: is alpha value 0 correct? + } +} + +impl From<[i32; 3]> for ClearValue { + #[inline] + fn from(val: [i32; 3]) -> ClearValue { + ClearValue::Int([val[0], val[1], val[2], 0]) // TODO: is alpha value 0 correct? + } +} + +impl From<[i32; 4]> for ClearValue { + #[inline] + fn from(val: [i32; 4]) -> ClearValue { + ClearValue::Int(val) + } +} + +impl From<f32> for ClearValue { + #[inline] + fn from(val: f32) -> ClearValue { + ClearValue::Depth(val) + } +} + +impl From<u32> for ClearValue { + #[inline] + fn from(val: u32) -> ClearValue { + ClearValue::Stencil(val) + } +} + +impl From<(f32, u32)> for ClearValue { + #[inline] + fn from(val: (f32, u32)) -> ClearValue { + ClearValue::DepthStencil(val) + } +} + + +// TODO: remove once no longer needed +pub unsafe trait ClearValuesTuple { + type Iter: Iterator<Item = ClearValue>; + fn iter(self) -> Self::Iter; +} + +macro_rules! impl_clear_values_tuple { + ($first:ident $($others:ident)+) => ( + #[allow(non_snake_case)] + unsafe impl<$first $(, $others)*> ClearValuesTuple for ($first, $($others,)+) + where $first: Into<ClearValue> $(, $others: Into<ClearValue>)* + { + type Iter = VecIntoIter<ClearValue>; + #[inline] + fn iter(self) -> VecIntoIter<ClearValue> { + let ($first, $($others,)+) = self; + vec![ + $first.into() $(, $others.into())+ + ].into_iter() + } + } + + impl_clear_values_tuple!($($others)*); + ); + + ($first:ident) => ( + unsafe impl<$first> ClearValuesTuple for ($first,) + where $first: Into<ClearValue> + { + type Iter = VecIntoIter<ClearValue>; + #[inline] + fn iter(self) -> VecIntoIter<ClearValue> { + vec![self.0.into()].into_iter() + } + } + ); +} + +impl_clear_values_tuple!(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z); diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/attachments_list.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/attachments_list.rs new file mode 100644 index 0000000..e0694fc --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/attachments_list.rs @@ -0,0 +1,80 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use SafeDeref; +use image::ImageViewAccess; +use std::sync::Arc; +//use sync::AccessFlagBits; +//use sync::PipelineStages; + +/// A list of attachments. +// TODO: rework this trait +pub unsafe trait AttachmentsList { + fn num_attachments(&self) -> usize; + + fn as_image_view_access(&self, index: usize) -> Option<&ImageViewAccess>; +} + +unsafe impl<T> AttachmentsList for T + where T: SafeDeref, + T::Target: AttachmentsList +{ + #[inline] + fn num_attachments(&self) -> usize { + (**self).num_attachments() + } + + #[inline] + fn as_image_view_access(&self, index: usize) -> Option<&ImageViewAccess> { + (**self).as_image_view_access(index) + } +} + +unsafe impl AttachmentsList for () { + #[inline] + fn num_attachments(&self) -> usize { + 0 + } + + #[inline] + fn as_image_view_access(&self, _: usize) -> Option<&ImageViewAccess> { + None + } +} + +unsafe impl AttachmentsList for Vec<Arc<ImageViewAccess + Send + Sync>> { + #[inline] + fn num_attachments(&self) -> usize { + self.len() + } + + #[inline] + fn as_image_view_access(&self, index: usize) -> Option<&ImageViewAccess> { + self.get(index).map(|v| &**v as &_) + } +} + +unsafe impl<A, B> AttachmentsList for (A, B) + where A: AttachmentsList, + B: ImageViewAccess +{ + #[inline] + fn num_attachments(&self) -> usize { + self.0.num_attachments() + 1 + } + + #[inline] + fn as_image_view_access(&self, index: usize) -> Option<&ImageViewAccess> { + if index == self.0.num_attachments() { + Some(&self.1) + } else { + self.0.as_image_view_access(index) + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/compat_atch.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/compat_atch.rs new file mode 100644 index 0000000..53912e8 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/compat_atch.rs @@ -0,0 +1,249 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! This module contains the `ensure_image_view_compatible` function, which verifies whether +//! an image view can be used as a render pass attachment. + +use format::Format; +use framebuffer::RenderPassDesc; +use image::ImageViewAccess; +use std::error; +use std::fmt; + +/// Checks whether the given image view is allowed to be the nth attachment of the given render +/// pass. +/// +/// # Panic +/// +/// Panics if the attachment number is out of range. +// TODO: add a specializable trait instead, that uses this function +// TODO: ImageView instead of ImageViewAccess? +pub fn ensure_image_view_compatible<Rp, I>(render_pass: &Rp, attachment_num: usize, image: &I) + -> Result<(), IncompatibleRenderPassAttachmentError> + where Rp: ?Sized + RenderPassDesc, + I: ?Sized + ImageViewAccess +{ + let attachment_desc = render_pass + .attachment_desc(attachment_num) + .expect("Attachment num out of range"); + + if image.format() != attachment_desc.format { + return Err(IncompatibleRenderPassAttachmentError::FormatMismatch { + expected: attachment_desc.format, + obtained: image.format(), + }); + } + + if image.samples() != attachment_desc.samples { + return Err(IncompatibleRenderPassAttachmentError::SamplesMismatch { + expected: attachment_desc.samples, + obtained: image.samples(), + }); + } + + if !image.identity_swizzle() { + return Err(IncompatibleRenderPassAttachmentError::NotIdentitySwizzled); + } + + for subpass_num in 0 .. render_pass.num_subpasses() { + let subpass = render_pass + .subpass_desc(subpass_num) + .expect("Subpass num out of range ; wrong RenderPassDesc trait impl"); + + if subpass + .color_attachments + .iter() + .any(|&(n, _)| n == attachment_num) + { + debug_assert!(image.parent().has_color()); // Was normally checked by the render pass. + if !image.parent().inner().image.usage_color_attachment() { + return Err(IncompatibleRenderPassAttachmentError::MissingColorAttachmentUsage); + } + } + + if let Some((ds, _)) = subpass.depth_stencil { + if ds == attachment_num { + // Was normally checked by the render pass. + debug_assert!(image.parent().has_depth() || image.parent().has_stencil()); + if !image + .parent() + .inner() + .image + .usage_depth_stencil_attachment() + { + return Err(IncompatibleRenderPassAttachmentError::MissingDepthStencilAttachmentUsage); + } + } + } + + if subpass + .input_attachments + .iter() + .any(|&(n, _)| n == attachment_num) + { + if !image.parent().inner().image.usage_input_attachment() { + return Err(IncompatibleRenderPassAttachmentError::MissingInputAttachmentUsage); + } + } + } + + // TODO: consider forbidding LoadOp::Load if image is transient + + // TODO: are all image layouts allowed? check this + + Ok(()) +} + +/// Error that can happen when an image is not compatible with a render pass attachment slot. +#[derive(Copy, Clone, Debug)] +pub enum IncompatibleRenderPassAttachmentError { + /// The image format expected by the render pass doesn't match the actual format of + /// the image. + FormatMismatch { + /// Format expected by the render pass. + expected: Format, + /// Format of the image. + obtained: Format, + }, + + /// The number of samples expected by the render pass doesn't match the number of samples of + /// the image. + SamplesMismatch { + /// Number of samples expected by the render pass. + expected: u32, + /// Number of samples of the image. + obtained: u32, + }, + + /// The image view has a component swizzle that is different from identity. + NotIdentitySwizzled, + + /// The image is used as a color attachment but is missing the color attachment usage. + MissingColorAttachmentUsage, + + /// The image is used as a depth/stencil attachment but is missing the depth-stencil attachment + /// usage. + MissingDepthStencilAttachmentUsage, + + /// The image is used as an input attachment but is missing the input attachment usage. + MissingInputAttachmentUsage, +} + +impl error::Error for IncompatibleRenderPassAttachmentError { + #[inline] + fn description(&self) -> &str { + match *self { + IncompatibleRenderPassAttachmentError::FormatMismatch { .. } => { + "mismatch between the format expected by the render pass and the actual format" + }, + IncompatibleRenderPassAttachmentError::SamplesMismatch { .. } => { + "mismatch between the number of samples expected by the render pass and the actual \ + number of samples" + }, + IncompatibleRenderPassAttachmentError::NotIdentitySwizzled => { + "the image view does not use identity swizzling" + }, + IncompatibleRenderPassAttachmentError::MissingColorAttachmentUsage => { + "the image is used as a color attachment but is missing the color attachment usage" + }, + IncompatibleRenderPassAttachmentError::MissingDepthStencilAttachmentUsage => { + "the image is used as a depth/stencil attachment but is missing the depth-stencil \ + attachment usage" + }, + IncompatibleRenderPassAttachmentError::MissingInputAttachmentUsage => { + "the image is used as an input attachment but is missing the input \ + attachment usage" + }, + } + } +} + +impl fmt::Display for IncompatibleRenderPassAttachmentError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +#[cfg(test)] +mod tests { + use super::IncompatibleRenderPassAttachmentError; + use super::ensure_image_view_compatible; + use format::Format; + use framebuffer::EmptySinglePassRenderPassDesc; + use image::AttachmentImage; + + #[test] + fn basic_ok() { + let (device, _) = gfx_dev_and_queue!(); + + let rp = single_pass_renderpass!(device.clone(), + attachments: { + color: { + load: Clear, + store: Store, + format: Format::R8G8B8A8Unorm, + samples: 1, + } + }, + pass: { + color: [color], + depth_stencil: {} + } + ).unwrap(); + + let img = AttachmentImage::new(device, [128, 128], Format::R8G8B8A8Unorm).unwrap(); + + ensure_image_view_compatible(&rp, 0, &img).unwrap(); + } + + #[test] + fn format_mismatch() { + let (device, _) = gfx_dev_and_queue!(); + + let rp = single_pass_renderpass!(device.clone(), + attachments: { + color: { + load: Clear, + store: Store, + format: Format::R16G16Sfloat, + samples: 1, + } + }, + pass: { + color: [color], + depth_stencil: {} + } + ).unwrap(); + + let img = AttachmentImage::new(device, [128, 128], Format::R8G8B8A8Unorm).unwrap(); + + match ensure_image_view_compatible(&rp, 0, &img) { + Err(IncompatibleRenderPassAttachmentError::FormatMismatch { + expected: Format::R16G16Sfloat, + obtained: Format::R8G8B8A8Unorm, + }) => (), + e => panic!("{:?}", e), + } + } + + #[test] + fn attachment_out_of_range() { + let (device, _) = gfx_dev_and_queue!(); + + let rp = EmptySinglePassRenderPassDesc; + let img = AttachmentImage::new(device, [128, 128], Format::R8G8B8A8Unorm).unwrap(); + + assert_should_panic!("Attachment num out of range", { + let _ = ensure_image_view_compatible(&rp, 0, &img); + }); + } + + // TODO: more tests +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/desc.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/desc.rs new file mode 100644 index 0000000..5e4ba90 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/desc.rs @@ -0,0 +1,595 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::sync::Arc; + +use device::Device; +use format::ClearValue; +use format::Format; +use format::FormatTy; +use framebuffer::RenderPass; +use framebuffer::RenderPassCompatible; +use framebuffer::RenderPassCreationError; +use framebuffer::RenderPassDescClearValues; +use image::ImageLayout; +use sync::AccessFlagBits; +use sync::PipelineStages; + +use SafeDeref; +use vk; + +/// Trait for objects that contain the description of a render pass. +/// +/// See also all the traits whose name start with `RenderPassDesc` (eg. `RenderPassDescAttachments` +/// or TODO: rename existing traits to match this). They are extensions to this trait. +/// +/// # Safety +/// +/// TODO: finish this section +/// - All color and depth/stencil attachments used by any given subpass must have the same number +/// of samples. +/// - The trait methods should always return the same values, unless you modify the description +/// through a mutable borrow. Once you pass the `RenderPassDesc` object to vulkano, you can still +/// access it through the `RenderPass::desc()` method that returns a shared borrow to the +/// description. It must not be possible for a shared borrow to modify the description in such a +/// way that the description changes. +/// - The provided methods shouldn't be overridden with fancy implementations. For example +/// `build_render_pass` must build a render pass from the description and not a different one. +/// +pub unsafe trait RenderPassDesc: RenderPassDescClearValues<Vec<ClearValue>> { + /// Returns the number of attachments of the render pass. + fn num_attachments(&self) -> usize; + + /// Returns the description of an attachment. + /// + /// Returns `None` if `num` is greater than or equal to `num_attachments()`. + fn attachment_desc(&self, num: usize) -> Option<AttachmentDescription>; + + /// Returns an iterator to the list of attachments. + #[inline] + fn attachment_descs(&self) -> RenderPassDescAttachments<Self> + where Self: Sized + { + RenderPassDescAttachments { + render_pass: self, + num: 0, + } + } + + /// Returns the number of subpasses of the render pass. + fn num_subpasses(&self) -> usize; + + /// Returns the description of a subpass. + /// + /// Returns `None` if `num` is greater than or equal to `num_subpasses()`. + fn subpass_desc(&self, num: usize) -> Option<PassDescription>; + + /// Returns an iterator to the list of subpasses. + #[inline] + fn subpass_descs(&self) -> RenderPassDescSubpasses<Self> + where Self: Sized + { + RenderPassDescSubpasses { + render_pass: self, + num: 0, + } + } + + /// Returns the number of dependencies of the render pass. + fn num_dependencies(&self) -> usize; + + /// Returns the description of a dependency. + /// + /// Returns `None` if `num` is greater than or equal to `num_dependencies()`. + fn dependency_desc(&self, num: usize) -> Option<PassDependencyDescription>; + + /// Returns an iterator to the list of dependencies. + #[inline] + fn dependency_descs(&self) -> RenderPassDescDependencies<Self> + where Self: Sized + { + RenderPassDescDependencies { + render_pass: self, + num: 0, + } + } + + /// Returns true if this render pass is compatible with another render pass. + /// + /// Two render passes that contain one subpass are compatible if they are identical. Two render + /// passes that contain more than one subpass are compatible if they are identical except for + /// the load/store operations and the image layouts. + /// + /// This function is just a shortcut for the `RenderPassCompatible` trait. + #[inline] + fn is_compatible_with<T>(&self, other: &T) -> bool + where Self: Sized, + T: ?Sized + RenderPassDesc + { + RenderPassCompatible::is_compatible_with(self, other) + } + + /// Builds a render pass from this description. + /// + /// > **Note**: This function is just a shortcut for `RenderPass::new`. + #[inline] + fn build_render_pass(self, device: Arc<Device>) + -> Result<RenderPass<Self>, RenderPassCreationError> + where Self: Sized + { + RenderPass::new(device, self) + } + + /// Returns the number of color attachments of a subpass. Returns `None` if out of range. + #[inline] + fn num_color_attachments(&self, subpass: u32) -> Option<u32> { + (&self) + .subpass_descs() + .skip(subpass as usize) + .next() + .map(|p| p.color_attachments.len() as u32) + } + + /// Returns the number of samples of the attachments of a subpass. Returns `None` if out of + /// range or if the subpass has no attachment. TODO: return an enum instead? + #[inline] + fn num_samples(&self, subpass: u32) -> Option<u32> { + (&self) + .subpass_descs() + .skip(subpass as usize) + .next() + .and_then(|p| { + // TODO: chain input attachments as well? + p.color_attachments + .iter() + .cloned() + .chain(p.depth_stencil.clone().into_iter()) + .filter_map(|a| (&self).attachment_descs().skip(a.0).next()) + .next() + .map(|a| a.samples) + }) + } + + /// Returns a tuple whose first element is `true` if there's a depth attachment, and whose + /// second element is `true` if there's a stencil attachment. Returns `None` if out of range. + #[inline] + fn has_depth_stencil_attachment(&self, subpass: u32) -> Option<(bool, bool)> { + (&self) + .subpass_descs() + .skip(subpass as usize) + .next() + .map(|p| { + let atch_num = match p.depth_stencil { + Some((d, _)) => d, + None => return (false, false), + }; + + match (&self) + .attachment_descs() + .skip(atch_num) + .next() + .unwrap() + .format + .ty() { + FormatTy::Depth => (true, false), + FormatTy::Stencil => (false, true), + FormatTy::DepthStencil => (true, true), + _ => unreachable!(), + } + }) + } + + /// Returns true if a subpass has a depth attachment or a depth-stencil attachment. + #[inline] + fn has_depth(&self, subpass: u32) -> Option<bool> { + (&self) + .subpass_descs() + .skip(subpass as usize) + .next() + .map(|p| { + let atch_num = match p.depth_stencil { + Some((d, _)) => d, + None => return false, + }; + + match (&self) + .attachment_descs() + .skip(atch_num) + .next() + .unwrap() + .format + .ty() { + FormatTy::Depth => true, + FormatTy::Stencil => false, + FormatTy::DepthStencil => true, + _ => unreachable!(), + } + }) + } + + /// Returns true if a subpass has a depth attachment or a depth-stencil attachment whose + /// layout is not `DepthStencilReadOnlyOptimal`. + #[inline] + fn has_writable_depth(&self, subpass: u32) -> Option<bool> { + (&self) + .subpass_descs() + .skip(subpass as usize) + .next() + .map(|p| { + let atch_num = match p.depth_stencil { + Some((d, l)) => { + if l == ImageLayout::DepthStencilReadOnlyOptimal { + return false; + } + d + }, + None => return false, + }; + + match (&self) + .attachment_descs() + .skip(atch_num) + .next() + .unwrap() + .format + .ty() { + FormatTy::Depth => true, + FormatTy::Stencil => false, + FormatTy::DepthStencil => true, + _ => unreachable!(), + } + }) + } + + /// Returns true if a subpass has a stencil attachment or a depth-stencil attachment. + #[inline] + fn has_stencil(&self, subpass: u32) -> Option<bool> { + (&self) + .subpass_descs() + .skip(subpass as usize) + .next() + .map(|p| { + let atch_num = match p.depth_stencil { + Some((d, _)) => d, + None => return false, + }; + + match (&self) + .attachment_descs() + .skip(atch_num) + .next() + .unwrap() + .format + .ty() { + FormatTy::Depth => false, + FormatTy::Stencil => true, + FormatTy::DepthStencil => true, + _ => unreachable!(), + } + }) + } + + /// Returns true if a subpass has a stencil attachment or a depth-stencil attachment whose + /// layout is not `DepthStencilReadOnlyOptimal`. + #[inline] + fn has_writable_stencil(&self, subpass: u32) -> Option<bool> { + (&self) + .subpass_descs() + .skip(subpass as usize) + .next() + .map(|p| { + let atch_num = match p.depth_stencil { + Some((d, l)) => { + if l == ImageLayout::DepthStencilReadOnlyOptimal { + return false; + } + d + }, + None => return false, + }; + + match (&self) + .attachment_descs() + .skip(atch_num) + .next() + .unwrap() + .format + .ty() { + FormatTy::Depth => false, + FormatTy::Stencil => true, + FormatTy::DepthStencil => true, + _ => unreachable!(), + } + }) + } +} + +unsafe impl<T> RenderPassDesc for T + where T: SafeDeref, + T::Target: RenderPassDesc +{ + #[inline] + fn num_attachments(&self) -> usize { + (**self).num_attachments() + } + + #[inline] + fn attachment_desc(&self, num: usize) -> Option<AttachmentDescription> { + (**self).attachment_desc(num) + } + + #[inline] + fn num_subpasses(&self) -> usize { + (**self).num_subpasses() + } + + #[inline] + fn subpass_desc(&self, num: usize) -> Option<PassDescription> { + (**self).subpass_desc(num) + } + + #[inline] + fn num_dependencies(&self) -> usize { + (**self).num_dependencies() + } + + #[inline] + fn dependency_desc(&self, num: usize) -> Option<PassDependencyDescription> { + (**self).dependency_desc(num) + } +} + +/// Iterator to the attachments of a `RenderPassDesc`. +#[derive(Debug, Copy, Clone)] +pub struct RenderPassDescAttachments<'a, R: ?Sized + 'a> { + render_pass: &'a R, + num: usize, +} + +impl<'a, R: ?Sized + 'a> Iterator for RenderPassDescAttachments<'a, R> + where R: RenderPassDesc +{ + type Item = AttachmentDescription; + + fn next(&mut self) -> Option<AttachmentDescription> { + if self.num < self.render_pass.num_attachments() { + let n = self.num; + self.num += 1; + Some(self.render_pass + .attachment_desc(n) + .expect("Wrong RenderPassDesc implementation")) + } else { + None + } + } +} + +/// Iterator to the subpasses of a `RenderPassDesc`. +#[derive(Debug, Copy, Clone)] +pub struct RenderPassDescSubpasses<'a, R: ?Sized + 'a> { + render_pass: &'a R, + num: usize, +} + +impl<'a, R: ?Sized + 'a> Iterator for RenderPassDescSubpasses<'a, R> + where R: RenderPassDesc +{ + type Item = PassDescription; + + fn next(&mut self) -> Option<PassDescription> { + if self.num < self.render_pass.num_subpasses() { + let n = self.num; + self.num += 1; + Some(self.render_pass + .subpass_desc(n) + .expect("Wrong RenderPassDesc implementation")) + } else { + None + } + } +} + +/// Iterator to the subpass dependencies of a `RenderPassDesc`. +#[derive(Debug, Copy, Clone)] +pub struct RenderPassDescDependencies<'a, R: ?Sized + 'a> { + render_pass: &'a R, + num: usize, +} + +impl<'a, R: ?Sized + 'a> Iterator for RenderPassDescDependencies<'a, R> + where R: RenderPassDesc +{ + type Item = PassDependencyDescription; + + fn next(&mut self) -> Option<PassDependencyDescription> { + if self.num < self.render_pass.num_dependencies() { + let n = self.num; + self.num += 1; + Some(self.render_pass + .dependency_desc(n) + .expect("Wrong RenderPassDesc implementation")) + } else { + None + } + } +} + +/// Describes an attachment that will be used in a render pass. +#[derive(Debug, Clone)] +pub struct AttachmentDescription { + /// Format of the image that is going to be bound. + pub format: Format, + /// Number of samples of the image that is going to be bound. + pub samples: u32, + + /// What the implementation should do with that attachment at the start of the render pass. + pub load: LoadOp, + /// What the implementation should do with that attachment at the end of the render pass. + pub store: StoreOp, + + /// Equivalent of `load` for the stencil component of the attachment, if any. Irrelevant if + /// there is no stencil component. + pub stencil_load: LoadOp, + /// Equivalent of `store` for the stencil component of the attachment, if any. Irrelevant if + /// there is no stencil component. + pub stencil_store: StoreOp, + + /// Layout that the image is going to be in at the start of the renderpass. + /// + /// The vulkano library will automatically switch to the correct layout if necessary, but it + /// is more efficient to set this to the correct value. + pub initial_layout: ImageLayout, + + /// Layout that the image will be transitioned to at the end of the renderpass. + pub final_layout: ImageLayout, +} + +impl AttachmentDescription { + /// Returns true if this attachment is compatible with another attachment, as defined in the + /// `Render Pass Compatibility` section of the Vulkan specs. + #[inline] + pub fn is_compatible_with(&self, other: &AttachmentDescription) -> bool { + self.format == other.format && self.samples == other.samples + } +} + +/// Describes one of the passes of a render pass. +/// +/// # Restrictions +/// +/// All these restrictions are checked when the `RenderPass` object is created. +/// TODO: that's not the case ^ +/// +/// - The number of color attachments must be less than the limit of the physical device. +/// - All the attachments in `color_attachments` and `depth_stencil` must have the same +/// samples count. +/// - If any attachment is used as both an input attachment and a color or +/// depth/stencil attachment, then each use must use the same layout. +/// - Elements of `preserve_attachments` must not be used in any of the other members. +/// - If `resolve_attachments` is not empty, then all the resolve attachments must be attachments +/// with 1 sample and all the color attachments must have more than 1 sample. +/// - If `resolve_attachments` is not empty, all the resolve attachments must have the same format +/// as the color attachments. +/// - If the first use of an attachment in this renderpass is as an input attachment and the +/// attachment is not also used as a color or depth/stencil attachment in the same subpass, +/// then the loading operation must not be `Clear`. +/// +// TODO: add tests for all these restrictions +// TODO: allow unused attachments (for example attachment 0 and 2 are used, 1 is unused) +#[derive(Debug, Clone)] +pub struct PassDescription { + /// Indices and layouts of attachments to use as color attachments. + pub color_attachments: Vec<(usize, ImageLayout)>, // TODO: Vec is slow + + /// Index and layout of the attachment to use as depth-stencil attachment. + pub depth_stencil: Option<(usize, ImageLayout)>, + + /// Indices and layouts of attachments to use as input attachments. + pub input_attachments: Vec<(usize, ImageLayout)>, // TODO: Vec is slow + + /// If not empty, each color attachment will be resolved into each corresponding entry of + /// this list. + /// + /// If this value is not empty, it **must** be the same length as `color_attachments`. + pub resolve_attachments: Vec<(usize, ImageLayout)>, // TODO: Vec is slow + + /// Indices of attachments that will be preserved during this pass. + pub preserve_attachments: Vec<usize>, // TODO: Vec is slow +} + +/// Describes a dependency between two passes of a render pass. +/// +/// The implementation is allowed to change the order of the passes within a render pass, unless +/// you specify that there exists a dependency between two passes (ie. the result of one will be +/// used as the input of another one). +#[derive(Debug, Clone)] +pub struct PassDependencyDescription { + /// Index of the subpass that writes the data that `destination_subpass` is going to use. + pub source_subpass: usize, + + /// Index of the subpass that reads the data that `source_subpass` wrote. + pub destination_subpass: usize, + + /// The pipeline stages that must be finished on the previous subpass before the destination + /// subpass can start. + pub source_stages: PipelineStages, + + /// The pipeline stages of the destination subpass that must wait for the source to be finished. + /// Stages that are earlier of the stages specified here can start before the source is + /// finished. + pub destination_stages: PipelineStages, + + /// The way the source subpass accesses the attachments on which we depend. + pub source_access: AccessFlagBits, + + /// The way the destination subpass accesses the attachments on which we depend. + pub destination_access: AccessFlagBits, + + /// If false, then the whole subpass must be finished for the next one to start. If true, then + /// the implementation can start the new subpass for some given pixels as long as the previous + /// subpass is finished for these given pixels. + /// + /// In other words, if the previous subpass has some side effects on other parts of an + /// attachment, then you should set it to false. + /// + /// Passing `false` is always safer than passing `true`, but in practice you rarely need to + /// pass `false`. + pub by_region: bool, +} + +/// Describes what the implementation should do with an attachment after all the subpasses have +/// completed. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[repr(u32)] +pub enum StoreOp { + /// The attachment will be stored. This is what you usually want. + /// + /// While this is the most intuitive option, it is also slower than `DontCare` because it can + /// take time to write the data back to memory. + Store = vk::ATTACHMENT_STORE_OP_STORE, + + /// What happens is implementation-specific. + /// + /// This is purely an optimization compared to `Store`. The implementation doesn't need to copy + /// from the internal cache to the memory, which saves memory bandwidth. + /// + /// This doesn't mean that the data won't be copied, as an implementation is also free to not + /// use a cache and write the output directly in memory. In other words, the content of the + /// image will be undefined. + DontCare = vk::ATTACHMENT_STORE_OP_DONT_CARE, +} + +/// Describes what the implementation should do with an attachment at the start of the subpass. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[repr(u32)] +pub enum LoadOp { + /// The content of the attachment will be loaded from memory. This is what you want if you want + /// to draw over something existing. + /// + /// While this is the most intuitive option, it is also the slowest because it uses a lot of + /// memory bandwidth. + Load = vk::ATTACHMENT_LOAD_OP_LOAD, + + /// The content of the attachment will be filled by the implementation with a uniform value + /// that you must provide when you start drawing. + /// + /// This is what you usually use at the start of a frame, in order to reset the content of + /// the color, depth and/or stencil buffers. + /// + /// See the `draw_inline` and `draw_secondary` methods of `PrimaryComputeBufferBuilder`. + Clear = vk::ATTACHMENT_LOAD_OP_CLEAR, + + /// The attachment will have undefined content. + /// + /// This is what you should use for attachments that you intend to entirely cover with draw + /// commands. + /// If you are going to fill the attachment with a uniform value, it is better to use `Clear` + /// instead. + DontCare = vk::ATTACHMENT_LOAD_OP_DONT_CARE, +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/empty.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/empty.rs new file mode 100644 index 0000000..d985610 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/empty.rs @@ -0,0 +1,129 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use format::ClearValue; +use framebuffer::AttachmentDescription; +use framebuffer::PassDependencyDescription; +use framebuffer::PassDescription; +use framebuffer::RenderPassDesc; +use framebuffer::RenderPassDescClearValues; +use std::iter; + +/// Description of an empty render pass. +/// +/// Can be used to create a render pass with one subpass and no attachment. +/// +/// # Example +/// +/// ``` +/// use vulkano::framebuffer::EmptySinglePassRenderPassDesc; +/// use vulkano::framebuffer::RenderPassDesc; +/// +/// # let device: std::sync::Arc<vulkano::device::Device> = return; +/// let rp = EmptySinglePassRenderPassDesc.build_render_pass(device.clone()); +/// ``` +/// +#[derive(Debug, Copy, Clone)] +pub struct EmptySinglePassRenderPassDesc; + +unsafe impl RenderPassDesc for EmptySinglePassRenderPassDesc { + #[inline] + fn num_attachments(&self) -> usize { + 0 + } + + #[inline] + fn attachment_desc(&self, _: usize) -> Option<AttachmentDescription> { + None + } + + #[inline] + fn num_subpasses(&self) -> usize { + 1 + } + + #[inline] + fn subpass_desc(&self, num: usize) -> Option<PassDescription> { + if num == 0 { + Some(PassDescription { + color_attachments: vec![], + depth_stencil: None, + input_attachments: vec![], + resolve_attachments: vec![], + preserve_attachments: vec![], + }) + } else { + None + } + } + + #[inline] + fn num_dependencies(&self) -> usize { + 0 + } + + #[inline] + fn dependency_desc(&self, _: usize) -> Option<PassDependencyDescription> { + None + } + + #[inline] + fn num_color_attachments(&self, subpass: u32) -> Option<u32> { + if subpass == 0 { Some(0) } else { None } + } + + #[inline] + fn num_samples(&self, _: u32) -> Option<u32> { + None + } + + #[inline] + fn has_depth_stencil_attachment(&self, subpass: u32) -> Option<(bool, bool)> { + if subpass == 0 { + Some((false, false)) + } else { + None + } + } + + #[inline] + fn has_depth(&self, subpass: u32) -> Option<bool> { + if subpass == 0 { Some(false) } else { None } + } + + #[inline] + fn has_writable_depth(&self, subpass: u32) -> Option<bool> { + if subpass == 0 { Some(false) } else { None } + } + + #[inline] + fn has_stencil(&self, subpass: u32) -> Option<bool> { + if subpass == 0 { Some(false) } else { None } + } + + #[inline] + fn has_writable_stencil(&self, subpass: u32) -> Option<bool> { + if subpass == 0 { Some(false) } else { None } + } +} + +unsafe impl RenderPassDescClearValues<Vec<ClearValue>> for EmptySinglePassRenderPassDesc { + #[inline] + fn convert_clear_values(&self, values: Vec<ClearValue>) -> Box<Iterator<Item = ClearValue>> { + assert!(values.is_empty()); // TODO: error instead + Box::new(iter::empty()) + } +} + +unsafe impl RenderPassDescClearValues<()> for EmptySinglePassRenderPassDesc { + #[inline] + fn convert_clear_values(&self, _: ()) -> Box<Iterator<Item = ClearValue>> { + Box::new(iter::empty()) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/framebuffer.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/framebuffer.rs new file mode 100644 index 0000000..c734406 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/framebuffer.rs @@ -0,0 +1,904 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::cmp; +use std::error; +use std::fmt; +use std::marker::PhantomData; +use std::mem; +use std::ptr; +use std::sync::Arc; + +use device::Device; +use device::DeviceOwned; +use format::ClearValue; +use framebuffer::AttachmentsList; +use framebuffer::FramebufferAbstract; +use framebuffer::IncompatibleRenderPassAttachmentError; +use framebuffer::AttachmentDescription; +use framebuffer::PassDependencyDescription; +use framebuffer::PassDescription; +use framebuffer::RenderPassAbstract; +use framebuffer::RenderPassDesc; +use framebuffer::RenderPassDescClearValues; +use framebuffer::RenderPassSys; +use framebuffer::ensure_image_view_compatible; +use image::ImageViewAccess; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use vk; + +/// Contains a render pass and the image views that are attached to it. +/// +/// Creating a framebuffer is done by calling `Framebuffer::start`, which returns a +/// `FramebufferBuilder` object. You can then add the framebuffer attachments one by one by +/// calling `add(image)`. When you are done, call `build()`. +/// +/// Both the `add` and the `build` functions perform various checks to make sure that the number +/// of images is correct and that each image is compatible with the attachment definition in the +/// render pass. +/// +/// ``` +/// # use std::sync::Arc; +/// # use vulkano::framebuffer::RenderPassAbstract; +/// use vulkano::framebuffer::Framebuffer; +/// +/// # let render_pass: Arc<RenderPassAbstract + Send + Sync> = return; +/// # let my_image: Arc<vulkano::image::AttachmentImage<vulkano::format::Format>> = return; +/// // let render_pass: Arc<_> = ...; +/// let framebuffer = Framebuffer::start(render_pass.clone()) +/// .add(my_image).unwrap() +/// .build().unwrap(); +/// ``` +/// +/// Just like render pass objects implement the `RenderPassAbstract` trait, all framebuffer +/// objects implement the `FramebufferAbstract` trait. This means that you can cast any +/// `Arc<Framebuffer<..>>` into an `Arc<FramebufferAbstract + Send + Sync>` for easier storage. +/// +/// ## Framebuffer dimensions +/// +/// If you use `Framebuffer::start()` to create a framebuffer then vulkano will automatically +/// make sure that all the attachments have the same dimensions, as this is the most common +/// situation. +/// +/// Alternatively you can also use `with_intersecting_dimensions`, in which case the dimensions of +/// the framebuffer will be the intersection of the dimensions of all attachments, or +/// `with_dimensions` if you want to specify exact dimensions. If you use `with_dimensions`, you +/// are allowed to attach images that are larger than these dimensions. +/// +/// If the dimensions of the framebuffer don't match the dimensions of one of its attachment, then +/// only the top-left hand corner of the image will be drawn to. +/// +#[derive(Debug)] +pub struct Framebuffer<Rp, A> { + device: Arc<Device>, + render_pass: Rp, + framebuffer: vk::Framebuffer, + dimensions: [u32; 3], + resources: A, +} + +impl<Rp> Framebuffer<Rp, ()> { + /// Starts building a framebuffer. + pub fn start(render_pass: Rp) -> FramebufferBuilder<Rp, ()> { + FramebufferBuilder { + render_pass: render_pass, + raw_ids: SmallVec::new(), + dimensions: FramebufferBuilderDimensions::AutoIdentical(None), + attachments: (), + } + } + + /// Starts building a framebuffer. The dimensions of the framebuffer will automatically be + /// the intersection of the dimensions of all the attachments. + pub fn with_intersecting_dimensions(render_pass: Rp) -> FramebufferBuilder<Rp, ()> { + FramebufferBuilder { + render_pass: render_pass, + raw_ids: SmallVec::new(), + dimensions: FramebufferBuilderDimensions::AutoSmaller(None), + attachments: (), + } + } + + /// Starts building a framebuffer. + pub fn with_dimensions(render_pass: Rp, dimensions: [u32; 3]) -> FramebufferBuilder<Rp, ()> { + FramebufferBuilder { + render_pass: render_pass, + raw_ids: SmallVec::new(), + dimensions: FramebufferBuilderDimensions::Specific(dimensions), + attachments: (), + } + } +} + +/// Prototype of a framebuffer. +pub struct FramebufferBuilder<Rp, A> { + render_pass: Rp, + raw_ids: SmallVec<[vk::ImageView; 8]>, + dimensions: FramebufferBuilderDimensions, + attachments: A, +} + +impl<Rp, A> fmt::Debug for FramebufferBuilder<Rp, A> + where Rp: fmt::Debug, + A: fmt::Debug +{ + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fmt.debug_struct("FramebufferBuilder") + .field("render_pass", &self.render_pass) + .field("dimensions", &self.dimensions) + .field("attachments", &self.attachments) + .finish() + } +} + +#[derive(Debug)] +enum FramebufferBuilderDimensions { + AutoIdentical(Option<[u32; 3]>), + AutoSmaller(Option<[u32; 3]>), + Specific([u32; 3]), +} + +impl<Rp, A> FramebufferBuilder<Rp, A> + where Rp: RenderPassAbstract, + A: AttachmentsList +{ + /// Appends an attachment to the prototype of the framebuffer. + /// + /// Attachments must be added in the same order as the one defined in the render pass. + pub fn add<T>(self, attachment: T) + -> Result<FramebufferBuilder<Rp, (A, T)>, FramebufferCreationError> + where T: ImageViewAccess + { + if self.raw_ids.len() >= self.render_pass.num_attachments() { + return Err(FramebufferCreationError::AttachmentsCountMismatch { + expected: self.render_pass.num_attachments(), + obtained: self.raw_ids.len() + 1, + }); + } + + match ensure_image_view_compatible(&self.render_pass, self.raw_ids.len(), &attachment) { + Ok(()) => (), + Err(err) => return Err(FramebufferCreationError::IncompatibleAttachment(err)), + }; + + let img_dims = attachment.dimensions(); + debug_assert_eq!(img_dims.depth(), 1); + + let dimensions = match self.dimensions { + FramebufferBuilderDimensions::AutoIdentical(None) => { + let dims = [img_dims.width(), img_dims.height(), img_dims.array_layers()]; + FramebufferBuilderDimensions::AutoIdentical(Some(dims)) + }, + FramebufferBuilderDimensions::AutoIdentical(Some(current)) => { + if img_dims.width() != current[0] || img_dims.height() != current[1] || + img_dims.array_layers() != current[2] + { + return Err(FramebufferCreationError::AttachmentDimensionsIncompatible { + expected: current, + obtained: [img_dims.width(), img_dims.height(), img_dims.array_layers()], + }); + } + + FramebufferBuilderDimensions::AutoIdentical(Some(current)) + }, + FramebufferBuilderDimensions::AutoSmaller(None) => { + let dims = [img_dims.width(), img_dims.height(), img_dims.array_layers()]; + FramebufferBuilderDimensions::AutoSmaller(Some(dims)) + }, + FramebufferBuilderDimensions::AutoSmaller(Some(current)) => { + let new_dims = [ + cmp::min(current[0], img_dims.width()), + cmp::min(current[1], img_dims.height()), + cmp::min(current[2], img_dims.array_layers()), + ]; + + FramebufferBuilderDimensions::AutoSmaller(Some(new_dims)) + }, + FramebufferBuilderDimensions::Specific(current) => { + if img_dims.width() < current[0] || img_dims.height() < current[1] || + img_dims.array_layers() < current[2] + { + return Err(FramebufferCreationError::AttachmentDimensionsIncompatible { + expected: current, + obtained: [img_dims.width(), img_dims.height(), img_dims.array_layers()], + }); + } + + FramebufferBuilderDimensions::Specific( + [img_dims.width(), img_dims.height(), img_dims.array_layers()], + ) + }, + }; + + let mut raw_ids = self.raw_ids; + raw_ids.push(attachment.inner().internal_object()); + + Ok(FramebufferBuilder { + render_pass: self.render_pass, + raw_ids: raw_ids, + dimensions: dimensions, + attachments: (self.attachments, attachment), + }) + } + + /// Turns this builder into a `FramebufferBuilder<Rp, Box<AttachmentsList>>`. + /// + /// This allows you to store the builder in situations where you don't know in advance the + /// number of attachments. + /// + /// > **Note**: This is a very rare corner case and you shouldn't have to use this function + /// > in most situations. + #[inline] + pub fn boxed(self) -> FramebufferBuilder<Rp, Box<AttachmentsList>> + where A: 'static + { + FramebufferBuilder { + render_pass: self.render_pass, + raw_ids: self.raw_ids, + dimensions: self.dimensions, + attachments: Box::new(self.attachments) as Box<_>, + } + } + + /// Builds the framebuffer. + pub fn build(self) -> Result<Framebuffer<Rp, A>, FramebufferCreationError> { + let device = self.render_pass.device().clone(); + + // Check the number of attachments. + if self.raw_ids.len() != self.render_pass.num_attachments() { + return Err(FramebufferCreationError::AttachmentsCountMismatch { + expected: self.render_pass.num_attachments(), + obtained: self.raw_ids.len(), + }); + } + + // Compute the dimensions. + let dimensions = match self.dimensions { + FramebufferBuilderDimensions::Specific(dims) | + FramebufferBuilderDimensions::AutoIdentical(Some(dims)) | + FramebufferBuilderDimensions::AutoSmaller(Some(dims)) => { + dims + }, + FramebufferBuilderDimensions::AutoIdentical(None) | + FramebufferBuilderDimensions::AutoSmaller(None) => { + return Err(FramebufferCreationError::CantDetermineDimensions); + }, + }; + + // Checking the dimensions against the limits. + { + let limits = device.physical_device().limits(); + let limits = [ + limits.max_framebuffer_width(), + limits.max_framebuffer_height(), + limits.max_framebuffer_layers(), + ]; + if dimensions[0] > limits[0] || dimensions[1] > limits[1] || dimensions[2] > limits[2] { + return Err(FramebufferCreationError::DimensionsTooLarge); + } + } + + let framebuffer = unsafe { + let vk = device.pointers(); + + let infos = vk::FramebufferCreateInfo { + sType: vk::STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + renderPass: self.render_pass.inner().internal_object(), + attachmentCount: self.raw_ids.len() as u32, + pAttachments: self.raw_ids.as_ptr(), + width: dimensions[0], + height: dimensions[1], + layers: dimensions[2], + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateFramebuffer(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Framebuffer { + device: device, + render_pass: self.render_pass, + framebuffer: framebuffer, + dimensions: dimensions, + resources: self.attachments, + }) + } +} + +impl<Rp, A> Framebuffer<Rp, A> { + /// Returns the width, height and layers of this framebuffer. + #[inline] + pub fn dimensions(&self) -> [u32; 3] { + self.dimensions + } + + /// Returns the width of the framebuffer in pixels. + #[inline] + pub fn width(&self) -> u32 { + self.dimensions[0] + } + + /// Returns the height of the framebuffer in pixels. + #[inline] + pub fn height(&self) -> u32 { + self.dimensions[1] + } + + /// Returns the number of layers (or depth) of the framebuffer. + #[inline] + pub fn layers(&self) -> u32 { + self.dimensions[2] + } + + /// Returns the device that was used to create this framebuffer. + #[inline] + pub fn device(&self) -> &Arc<Device> { + &self.device + } + + /// Returns the renderpass that was used to create this framebuffer. + #[inline] + pub fn render_pass(&self) -> &Rp { + &self.render_pass + } +} + +unsafe impl<Rp, A> FramebufferAbstract for Framebuffer<Rp, A> + where Rp: RenderPassAbstract, + A: AttachmentsList +{ + #[inline] + fn inner(&self) -> FramebufferSys { + FramebufferSys(self.framebuffer, PhantomData) + } + + #[inline] + fn dimensions(&self) -> [u32; 3] { + self.dimensions + } + + #[inline] + fn attached_image_view(&self, index: usize) -> Option<&ImageViewAccess> { + self.resources.as_image_view_access(index) + } +} + +unsafe impl<Rp, A> RenderPassDesc for Framebuffer<Rp, A> + where Rp: RenderPassDesc +{ + #[inline] + fn num_attachments(&self) -> usize { + self.render_pass.num_attachments() + } + + #[inline] + fn attachment_desc(&self, num: usize) -> Option<AttachmentDescription> { + self.render_pass.attachment_desc(num) + } + + #[inline] + fn num_subpasses(&self) -> usize { + self.render_pass.num_subpasses() + } + + #[inline] + fn subpass_desc(&self, num: usize) -> Option<PassDescription> { + self.render_pass.subpass_desc(num) + } + + #[inline] + fn num_dependencies(&self) -> usize { + self.render_pass.num_dependencies() + } + + #[inline] + fn dependency_desc(&self, num: usize) -> Option<PassDependencyDescription> { + self.render_pass.dependency_desc(num) + } +} + +unsafe impl<C, Rp, A> RenderPassDescClearValues<C> for Framebuffer<Rp, A> + where Rp: RenderPassDescClearValues<C> +{ + #[inline] + fn convert_clear_values(&self, vals: C) -> Box<Iterator<Item = ClearValue>> { + self.render_pass.convert_clear_values(vals) + } +} + +unsafe impl<Rp, A> RenderPassAbstract for Framebuffer<Rp, A> + where Rp: RenderPassAbstract +{ + #[inline] + fn inner(&self) -> RenderPassSys { + self.render_pass.inner() + } +} + +unsafe impl<Rp, A> DeviceOwned for Framebuffer<Rp, A> { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl<Rp, A> Drop for Framebuffer<Rp, A> { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyFramebuffer(self.device.internal_object(), self.framebuffer, ptr::null()); + } + } +} + +/// Opaque object that represents the internals of a framebuffer. +#[derive(Debug, Copy, Clone)] +pub struct FramebufferSys<'a>(vk::Framebuffer, PhantomData<&'a ()>); + +unsafe impl<'a> VulkanObject for FramebufferSys<'a> { + type Object = vk::Framebuffer; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT; + + #[inline] + fn internal_object(&self) -> vk::Framebuffer { + self.0 + } +} + +/// Error that can happen when creating a framebuffer object. +#[derive(Copy, Clone, Debug)] +pub enum FramebufferCreationError { + /// Out of memory. + OomError(OomError), + /// The requested dimensions exceed the device's limits. + DimensionsTooLarge, + /// The attachment has a size that isn't compatible with the requested framebuffer dimensions. + AttachmentDimensionsIncompatible { + /// Expected dimensions. + expected: [u32; 3], + /// Attachment dimensions. + obtained: [u32; 3], + }, + /// The number of attachments doesn't match the number expected by the render pass. + AttachmentsCountMismatch { + /// Expected number of attachments. + expected: usize, + /// Number of attachments that were given. + obtained: usize, + }, + /// One of the images cannot be used as the requested attachment. + IncompatibleAttachment(IncompatibleRenderPassAttachmentError), + /// The framebuffer has no attachment and no dimension was specified. + CantDetermineDimensions, +} + +impl From<OomError> for FramebufferCreationError { + #[inline] + fn from(err: OomError) -> FramebufferCreationError { + FramebufferCreationError::OomError(err) + } +} + +impl error::Error for FramebufferCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + FramebufferCreationError::OomError(_) => "no memory available", + FramebufferCreationError::DimensionsTooLarge => + "the dimensions of the framebuffer are too large", + FramebufferCreationError::AttachmentDimensionsIncompatible { .. } => { + "the attachment has a size that isn't compatible with the framebuffer dimensions" + }, + FramebufferCreationError::AttachmentsCountMismatch { .. } => { + "the number of attachments doesn't match the number expected by the render pass" + }, + FramebufferCreationError::IncompatibleAttachment(_) => { + "one of the images cannot be used as the requested attachment" + }, + FramebufferCreationError::CantDetermineDimensions => { + "the framebuffer has no attachment and no dimension was specified" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + FramebufferCreationError::OomError(ref err) => Some(err), + FramebufferCreationError::IncompatibleAttachment(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for FramebufferCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for FramebufferCreationError { + #[inline] + fn from(err: Error) -> FramebufferCreationError { + FramebufferCreationError::from(OomError::from(err)) + } +} + +#[cfg(test)] +mod tests { + use format::Format; + use framebuffer::EmptySinglePassRenderPassDesc; + use framebuffer::Framebuffer; + use framebuffer::FramebufferCreationError; + use framebuffer::RenderPassDesc; + use image::attachment::AttachmentImage; + use std::sync::Arc; + + #[test] + fn simple_create() { + let (device, _) = gfx_dev_and_queue!(); + + let render_pass = Arc::new( + single_pass_renderpass!(device.clone(), + attachments: { + color: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + } + }, + pass: { + color: [color], + depth_stencil: {} + } + ).unwrap(), + ); + + let image = AttachmentImage::new(device.clone(), [1024, 768], Format::R8G8B8A8Unorm) + .unwrap(); + let _ = Framebuffer::start(render_pass) + .add(image.clone()) + .unwrap() + .build() + .unwrap(); + } + + #[test] + fn check_device_limits() { + let (device, _) = gfx_dev_and_queue!(); + + let rp = EmptySinglePassRenderPassDesc + .build_render_pass(device) + .unwrap(); + let res = Framebuffer::with_dimensions(rp, [0xffffffff, 0xffffffff, 0xffffffff]).build(); + match res { + Err(FramebufferCreationError::DimensionsTooLarge) => (), + _ => panic!(), + } + } + + #[test] + fn attachment_format_mismatch() { + let (device, _) = gfx_dev_and_queue!(); + + let render_pass = Arc::new( + single_pass_renderpass!(device.clone(), + attachments: { + color: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + } + }, + pass: { + color: [color], + depth_stencil: {} + } + ).unwrap(), + ); + + let image = AttachmentImage::new(device.clone(), [1024, 768], Format::R8Unorm).unwrap(); + + match Framebuffer::start(render_pass).add(image.clone()) { + Err(FramebufferCreationError::IncompatibleAttachment(_)) => (), + _ => panic!(), + } + } + + // TODO: check samples mismatch + + #[test] + fn attachment_dims_larger_than_specified_valid() { + let (device, _) = gfx_dev_and_queue!(); + + let render_pass = Arc::new( + single_pass_renderpass!(device.clone(), + attachments: { + color: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + } + }, + pass: { + color: [color], + depth_stencil: {} + } + ).unwrap(), + ); + + let img = AttachmentImage::new(device.clone(), [600, 600], Format::R8G8B8A8Unorm).unwrap(); + + let _ = Framebuffer::with_dimensions(render_pass, [512, 512, 1]) + .add(img) + .unwrap() + .build() + .unwrap(); + } + + #[test] + fn attachment_dims_smaller_than_specified() { + let (device, _) = gfx_dev_and_queue!(); + + let render_pass = Arc::new( + single_pass_renderpass!(device.clone(), + attachments: { + color: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + } + }, + pass: { + color: [color], + depth_stencil: {} + } + ).unwrap(), + ); + + let img = AttachmentImage::new(device.clone(), [512, 700], Format::R8G8B8A8Unorm).unwrap(); + + match Framebuffer::with_dimensions(render_pass, [600, 600, 1]).add(img) { + Err(FramebufferCreationError::AttachmentDimensionsIncompatible { + expected, + obtained, + }) => { + assert_eq!(expected, [600, 600, 1]); + assert_eq!(obtained, [512, 700, 1]); + }, + _ => panic!(), + } + } + + #[test] + fn multi_attachments_dims_not_identical() { + let (device, _) = gfx_dev_and_queue!(); + + let render_pass = Arc::new( + single_pass_renderpass!(device.clone(), + attachments: { + a: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + }, + b: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + } + }, + pass: { + color: [a, b], + depth_stencil: {} + } + ).unwrap(), + ); + + let a = AttachmentImage::new(device.clone(), [512, 512], Format::R8G8B8A8Unorm).unwrap(); + let b = AttachmentImage::new(device.clone(), [512, 513], Format::R8G8B8A8Unorm).unwrap(); + + match Framebuffer::start(render_pass).add(a).unwrap().add(b) { + Err(FramebufferCreationError::AttachmentDimensionsIncompatible { + expected, + obtained, + }) => { + assert_eq!(expected, [512, 512, 1]); + assert_eq!(obtained, [512, 513, 1]); + }, + _ => panic!(), + } + } + + #[test] + fn multi_attachments_auto_smaller() { + let (device, _) = gfx_dev_and_queue!(); + + let render_pass = Arc::new( + single_pass_renderpass!(device.clone(), + attachments: { + a: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + }, + b: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + } + }, + pass: { + color: [a, b], + depth_stencil: {} + } + ).unwrap(), + ); + + let a = AttachmentImage::new(device.clone(), [256, 512], Format::R8G8B8A8Unorm).unwrap(); + let b = AttachmentImage::new(device.clone(), [512, 128], Format::R8G8B8A8Unorm).unwrap(); + + let fb = Framebuffer::with_intersecting_dimensions(render_pass) + .add(a) + .unwrap() + .add(b) + .unwrap() + .build() + .unwrap(); + + match (fb.width(), fb.height(), fb.layers()) { + (256, 128, 1) => (), + _ => panic!(), + } + } + + #[test] + fn not_enough_attachments() { + let (device, _) = gfx_dev_and_queue!(); + + let render_pass = Arc::new( + single_pass_renderpass!(device.clone(), + attachments: { + a: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + }, + b: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + } + }, + pass: { + color: [a, b], + depth_stencil: {} + } + ).unwrap(), + ); + + let img = AttachmentImage::new(device.clone(), [256, 512], Format::R8G8B8A8Unorm).unwrap(); + + let res = Framebuffer::with_intersecting_dimensions(render_pass) + .add(img) + .unwrap() + .build(); + + match res { + Err(FramebufferCreationError::AttachmentsCountMismatch { + expected: 2, + obtained: 1, + }) => (), + _ => panic!(), + } + } + + #[test] + fn too_many_attachments() { + let (device, _) = gfx_dev_and_queue!(); + + let render_pass = Arc::new( + single_pass_renderpass!(device.clone(), + attachments: { + a: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 1, + } + }, + pass: { + color: [a], + depth_stencil: {} + } + ).unwrap(), + ); + + let a = AttachmentImage::new(device.clone(), [256, 512], Format::R8G8B8A8Unorm).unwrap(); + let b = AttachmentImage::new(device.clone(), [256, 512], Format::R8G8B8A8Unorm).unwrap(); + + let res = Framebuffer::with_intersecting_dimensions(render_pass) + .add(a) + .unwrap() + .add(b); + + match res { + Err(FramebufferCreationError::AttachmentsCountMismatch { + expected: 1, + obtained: 2, + }) => (), + _ => panic!(), + } + } + + #[test] + fn empty_working() { + let (device, _) = gfx_dev_and_queue!(); + + let rp = EmptySinglePassRenderPassDesc + .build_render_pass(device) + .unwrap(); + let _ = Framebuffer::with_dimensions(rp, [512, 512, 1]) + .build() + .unwrap(); + } + + #[test] + fn cant_determine_dimensions_auto() { + let (device, _) = gfx_dev_and_queue!(); + + let rp = EmptySinglePassRenderPassDesc + .build_render_pass(device) + .unwrap(); + let res = Framebuffer::start(rp).build(); + match res { + Err(FramebufferCreationError::CantDetermineDimensions) => (), + _ => panic!(), + } + } + + #[test] + fn cant_determine_dimensions_intersect() { + let (device, _) = gfx_dev_and_queue!(); + + let rp = EmptySinglePassRenderPassDesc + .build_render_pass(device) + .unwrap(); + let res = Framebuffer::with_intersecting_dimensions(rp).build(); + match res { + Err(FramebufferCreationError::CantDetermineDimensions) => (), + _ => panic!(), + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/macros.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/macros.rs new file mode 100644 index 0000000..68cb34b --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/macros.rs @@ -0,0 +1,378 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +/// Builds a `RenderPass` object whose template parameter is of indeterminate type. +#[macro_export] +macro_rules! single_pass_renderpass { + ( + $device:expr, + attachments: { $($a:tt)* }, + pass: { + color: [$($color_atch:ident),*], + depth_stencil: {$($depth_atch:ident)*}$(,)* + $(resolve: [$($resolve_atch:ident),*])*$(,)* + } + ) => ( + $crate::ordered_passes_renderpass!( + $device, + attachments: { $($a)* }, + passes: [ + { + color: [$($color_atch),*], + depth_stencil: {$($depth_atch)*}, + input: [], + resolve: [$($($resolve_atch),*)*] + } + ] + ) + ) +} + +/// Builds a `RenderPass` object whose template parameter is of indeterminate type. +#[macro_export] +macro_rules! ordered_passes_renderpass { + ( + $device:expr, + attachments: { + $( + $atch_name:ident: { + load: $load:ident, + store: $store:ident, + format: $format:expr, + samples: $samples:expr, + $(initial_layout: $init_layout:expr,)* + $(final_layout: $final_layout:expr,)* + } + ),* + }, + passes: [ + $( + { + color: [$($color_atch:ident),*], + depth_stencil: {$($depth_atch:ident)*}, + input: [$($input_atch:ident),*]$(,)* + $(resolve: [$($resolve_atch:ident),*])*$(,)* + } + ),* + ] + ) => ({ + use $crate::framebuffer::RenderPassDesc; + + mod scope { + #![allow(non_camel_case_types)] + #![allow(non_snake_case)] + + use $crate::format::ClearValue; + use $crate::format::Format; + use $crate::framebuffer::RenderPassDesc; + use $crate::framebuffer::RenderPassDescClearValues; + use $crate::framebuffer::AttachmentDescription; + use $crate::framebuffer::PassDescription; + use $crate::framebuffer::PassDependencyDescription; + use $crate::image::ImageLayout; + use $crate::sync::AccessFlagBits; + use $crate::sync::PipelineStages; + + pub struct CustomRenderPassDesc { + $( + pub $atch_name: (Format, u32), + )* + } + + #[allow(unsafe_code)] + unsafe impl RenderPassDesc for CustomRenderPassDesc { + #[inline] + fn num_attachments(&self) -> usize { + num_attachments() + } + + #[inline] + fn attachment_desc(&self, id: usize) -> Option<AttachmentDescription> { + attachment(self, id) + } + + #[inline] + fn num_subpasses(&self) -> usize { + num_subpasses() + } + + #[inline] + fn subpass_desc(&self, id: usize) -> Option<PassDescription> { + subpass(id) + } + + #[inline] + fn num_dependencies(&self) -> usize { + num_dependencies() + } + + #[inline] + fn dependency_desc(&self, id: usize) -> Option<PassDependencyDescription> { + dependency(id) + } + } + + unsafe impl RenderPassDescClearValues<Vec<ClearValue>> for CustomRenderPassDesc { + fn convert_clear_values(&self, values: Vec<ClearValue>) -> Box<Iterator<Item = ClearValue>> { + // FIXME: safety checks + Box::new(values.into_iter()) + } + } + + #[inline] + fn num_attachments() -> usize { + #![allow(unused_assignments)] + #![allow(unused_mut)] + #![allow(unused_variables)] + let mut num = 0; + $(let $atch_name = num; num += 1;)* + num + } + + #[inline] + fn attachment(desc: &CustomRenderPassDesc, id: usize) -> Option<AttachmentDescription> { + #![allow(unused_assignments)] + #![allow(unused_mut)] + + let mut num = 0; + + $({ + if id == num { + let (initial_layout, final_layout) = attachment_layouts(num); + + return Some($crate::framebuffer::AttachmentDescription { + format: desc.$atch_name.0, + samples: desc.$atch_name.1, + load: $crate::framebuffer::LoadOp::$load, + store: $crate::framebuffer::StoreOp::$store, + stencil_load: $crate::framebuffer::LoadOp::$load, + stencil_store: $crate::framebuffer::StoreOp::$store, + initial_layout: initial_layout, + final_layout: final_layout, + }); + } + + num += 1; + })* + + None + } + + #[inline] + fn num_subpasses() -> usize { + #![allow(unused_assignments)] + #![allow(unused_mut)] + #![allow(unused_variables)] + let mut num = 0; + $($(let $color_atch = num;)* num += 1;)* + num + } + + #[inline] + fn subpass(id: usize) -> Option<PassDescription> { + #![allow(unused_assignments)] + #![allow(unused_mut)] + #![allow(unused_variables)] + + let mut attachment_num = 0; + $( + let $atch_name = attachment_num; + attachment_num += 1; + )* + + let mut cur_pass_num = 0; + + $({ + if id == cur_pass_num { + let mut depth = None; + $( + depth = Some(($depth_atch, ImageLayout::DepthStencilAttachmentOptimal)); + )* + + let mut desc = PassDescription { + color_attachments: vec![ + $( + ($color_atch, ImageLayout::ColorAttachmentOptimal) + ),* + ], + depth_stencil: depth, + input_attachments: vec![ + $( + ($input_atch, ImageLayout::ShaderReadOnlyOptimal) + ),* + ], + resolve_attachments: vec![ + $($( + ($resolve_atch, ImageLayout::TransferDstOptimal) + ),*)* + ], + preserve_attachments: (0 .. attachment_num).filter(|&a| { + $(if a == $color_atch { return false; })* + $(if a == $depth_atch { return false; })* + $(if a == $input_atch { return false; })* + $($(if a == $resolve_atch { return false; })*)* + true + }).collect() + }; + + assert!(desc.resolve_attachments.is_empty() || + desc.resolve_attachments.len() == desc.color_attachments.len()); + return Some(desc); + } + + cur_pass_num += 1; + })* + + None + } + + #[inline] + fn num_dependencies() -> usize { + num_subpasses().saturating_sub(1) + } + + #[inline] + fn dependency(id: usize) -> Option<PassDependencyDescription> { + let num_passes = num_subpasses(); + + if id + 1 >= num_passes { + return None; + } + + Some(PassDependencyDescription { + source_subpass: id, + destination_subpass: id + 1, + source_stages: PipelineStages { all_graphics: true, .. PipelineStages::none() }, // TODO: correct values + destination_stages: PipelineStages { all_graphics: true, .. PipelineStages::none() }, // TODO: correct values + source_access: AccessFlagBits::all(), // TODO: correct values + destination_access: AccessFlagBits::all(), // TODO: correct values + by_region: true, // TODO: correct values + }) + } + + /// Returns the initial and final layout of an attachment, given its num. + /// + /// The value always correspond to the first and last usages of an attachment. + fn attachment_layouts(num: usize) -> (ImageLayout, ImageLayout) { + #![allow(unused_assignments)] + #![allow(unused_mut)] + #![allow(unused_variables)] + + let mut attachment_num = 0; + $( + let $atch_name = attachment_num; + attachment_num += 1; + )* + + let mut initial_layout = None; + let mut final_layout = None; + + $({ + $( + if $depth_atch == num { + if initial_layout.is_none() { + initial_layout = Some(ImageLayout::DepthStencilAttachmentOptimal); + } + final_layout = Some(ImageLayout::DepthStencilAttachmentOptimal); + } + )* + + $( + if $color_atch == num { + if initial_layout.is_none() { + initial_layout = Some(ImageLayout::ColorAttachmentOptimal); + } + final_layout = Some(ImageLayout::ColorAttachmentOptimal); + } + )* + + $($( + if $resolve_atch == num { + if initial_layout.is_none() { + initial_layout = Some(ImageLayout::TransferDstOptimal); + } + final_layout = Some(ImageLayout::TransferDstOptimal); + } + )*)* + + $( + if $input_atch == num { + if initial_layout.is_none() { + initial_layout = Some(ImageLayout::ShaderReadOnlyOptimal); + } + final_layout = Some(ImageLayout::ShaderReadOnlyOptimal); + } + )* + })* + + $(if $atch_name == num { + // If the clear OP is Clear or DontCare, default to the Undefined layout. + if initial_layout == Some(ImageLayout::DepthStencilAttachmentOptimal) || + initial_layout == Some(ImageLayout::ColorAttachmentOptimal) || + initial_layout == Some(ImageLayout::TransferDstOptimal) + { + if $crate::framebuffer::LoadOp::$load == $crate::framebuffer::LoadOp::Clear || + $crate::framebuffer::LoadOp::$load == $crate::framebuffer::LoadOp::DontCare + { + initial_layout = Some(ImageLayout::Undefined); + } + } + + $(initial_layout = Some($init_layout);)* + $(final_layout = Some($final_layout);)* + })* + ( + initial_layout.expect(format!("Attachment {} is missing initial_layout, this is normally \ + automatically determined but you can manually specify it for an individual \ + attachment in the single_pass_renderpass! macro", attachment_num).as_ref()), + final_layout.expect(format!("Attachment {} is missing final_layout, this is normally \ + automatically determined but you can manually specify it for an individual \ + attachment in the single_pass_renderpass! macro", attachment_num).as_ref()) + ) + } + } + + scope::CustomRenderPassDesc { + $( + $atch_name: ($format, $samples), + )* + }.build_render_pass($device) + }); +} + +#[cfg(test)] +mod tests { + use format::Format; + + #[test] + fn single_pass_resolve() { + let (device, _) = gfx_dev_and_queue!(); + let _ = single_pass_renderpass!(device.clone(), + attachments: { + a: { + load: Clear, + store: DontCare, + format: Format::R8G8B8A8Unorm, + samples: 4, + }, + b: { + load: DontCare, + store: Store, + format: Format::R8G8B8A8Unorm, + samples: 1, + } + }, + pass: { + color: [a], + depth_stencil: {}, + resolve: [b], + } + ).unwrap(); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/mod.rs new file mode 100644 index 0000000..89b91cb --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/mod.rs @@ -0,0 +1,140 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Targets on which your draw commands are executed. +//! +//! # Render passes and framebuffers +//! +//! There are two concepts in Vulkan: +//! +//! - A *render pass* describes the target which you are going to render to. It is a collection +//! of descriptions of one or more attachments (ie. image that are rendered to), and of one or +//! multiples subpasses. The render pass contains the format and number of samples of each +//! attachment, and the attachments that are attached to each subpass. They are represented +//! in vulkano with the `RenderPass` object. +//! - A *framebuffer* contains the list of actual images that are attached. It is created from a +//! render pass and has to match its characteristics. They are represented in vulkano with the +//! `Framebuffer` object. +//! +//! Render passes are typically created at initialization only (for example during a loading +//! screen) because they can be costly, while framebuffers can be created and destroyed either at +//! initialization or during the frame. +//! +//! Consequently you can create graphics pipelines from a render pass object alone. +//! A `Framebuffer` object is only needed when you actually add draw commands to a command buffer. +//! +//! # Render passes +//! +//! In vulkano a render pass is represented by the `RenderPass` struct. This struct has a template +//! parameter that contains the description of the render pass. The `RenderPassAbstract` trait is +//! implemented on all instances of `RenderPass<_>` and makes it easier to store render passes +//! without having to explicitly write its type. +//! +//! The template parameter of the `RenderPass` struct must implement the `RenderPassDesc` trait. +//! In order to create a render pass, you can create an object that implements this trait, then +//! call the `build_render_pass` method on it. +//! +//! ``` +//! use vulkano::framebuffer::EmptySinglePassRenderPassDesc; +//! use vulkano::framebuffer::RenderPassDesc; +//! +//! # let device: std::sync::Arc<vulkano::device::Device> = return; +//! let desc = EmptySinglePassRenderPassDesc; +//! let render_pass = desc.build_render_pass(device.clone()).unwrap(); +//! // The type of `render_pass` is `RenderPass<EmptySinglePassRenderPassDesc>`. +//! ``` +//! +//! This example creates a render pass with no attachment and one single subpass that doesn't draw +//! on anything. While it's sometimes useful, most of the time it's not what you want. +//! +//! The easiest way to create a "real" render pass is to use the `single_pass_renderpass!` macro. +//! +//! ``` +//! # #[macro_use] extern crate vulkano; +//! # fn main() { +//! # let device: std::sync::Arc<vulkano::device::Device> = return; +//! use vulkano::format::Format; +//! +//! let render_pass = single_pass_renderpass!(device.clone(), +//! attachments: { +//! // `foo` is a custom name we give to the first and only attachment. +//! foo: { +//! load: Clear, +//! store: Store, +//! format: Format::R8G8B8A8Unorm, +//! samples: 1, +//! } +//! }, +//! pass: { +//! color: [foo], // Repeat the attachment name here. +//! depth_stencil: {} +//! } +//! ).unwrap(); +//! # } +//! ``` +//! +//! See the documentation of the macro for more details. TODO: put link here +//! +//! Once a `RenderPass<_>` struct is created, it implements the same render-pass-related traits as +//! its template parameter. +//! +//! # Framebuffers +//! +//! See [the documentation of the `Framebuffer` struct](struct.Framebuffer.html) for information +//! about how to create a framebuffer. +//! + +pub use self::attachments_list::AttachmentsList; +pub use self::compat_atch::IncompatibleRenderPassAttachmentError; +pub use self::compat_atch::ensure_image_view_compatible; +pub use self::desc::AttachmentDescription; +pub use self::desc::PassDependencyDescription; +pub use self::desc::PassDescription; +pub use self::desc::LoadOp; +pub use self::desc::RenderPassDesc; +pub use self::desc::RenderPassDescAttachments; +pub use self::desc::RenderPassDescDependencies; +pub use self::desc::RenderPassDescSubpasses; +pub use self::desc::StoreOp; +pub use self::empty::EmptySinglePassRenderPassDesc; +pub use self::framebuffer::Framebuffer; +pub use self::framebuffer::FramebufferBuilder; +pub use self::framebuffer::FramebufferCreationError; +pub use self::framebuffer::FramebufferSys; +pub use self::sys::RenderPass; +pub use self::sys::RenderPassCreationError; +pub use self::sys::RenderPassSys; +pub use self::traits::FramebufferAbstract; +pub use self::traits::RenderPassAbstract; +pub use self::traits::RenderPassCompatible; +pub use self::traits::RenderPassDescClearValues; +pub use self::traits::RenderPassSubpassInterface; +pub use self::traits::Subpass; + +use vk; + +#[macro_use] +mod macros; +mod attachments_list; +mod compat_atch; +mod desc; +mod empty; +mod framebuffer; +mod sys; +mod traits; + +/// Describes what a subpass in a command buffer will contain. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[repr(u32)] +pub enum SubpassContents { + /// The subpass will only directly contain commands. + Inline = vk::SUBPASS_CONTENTS_INLINE, + /// The subpass will only contain secondary command buffers invocations. + SecondaryCommandBuffers = vk::SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS, +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/sys.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/sys.rs new file mode 100644 index 0000000..d7d09c7 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/sys.rs @@ -0,0 +1,631 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::error; +use std::fmt; +use std::marker::PhantomData; +use std::mem; +use std::ptr; +use std::sync::Arc; +use std::sync::Mutex; + +use device::Device; +use device::DeviceOwned; +use format::ClearValue; +use framebuffer::EmptySinglePassRenderPassDesc; +use framebuffer::AttachmentDescription; +use framebuffer::PassDependencyDescription; +use framebuffer::PassDescription; +use framebuffer::LoadOp; +use framebuffer::RenderPassAbstract; +use framebuffer::RenderPassDesc; +use framebuffer::RenderPassDescClearValues; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use vk; + +/// Defines the layout of multiple subpasses. +/// +/// The `RenderPass` struct should always implement the `RenderPassAbstract` trait. Therefore +/// you can turn any `Arc<RenderPass<D>>` into a `Arc<RenderPassAbstract + Send + Sync>` if you need to. +pub struct RenderPass<D> { + // The internal Vulkan object. + render_pass: vk::RenderPass, + + // Device this render pass was created from. + device: Arc<Device>, + + // Description of the render pass. + desc: D, + + // Cache of the granularity of the render pass. + granularity: Mutex<Option<[u32; 2]>>, +} + +impl<D> RenderPass<D> + where D: RenderPassDesc +{ + /// Builds a new render pass. + /// + /// # Panic + /// + /// - Can panic if it detects some violations in the restrictions. Only inexpensive checks are + /// performed. `debug_assert!` is used, so some restrictions are only checked in debug + /// mode. + /// + pub fn new(device: Arc<Device>, description: D) + -> Result<RenderPass<D>, RenderPassCreationError> { + let vk = device.pointers(); + + // If the first use of an attachment in this render pass is as an input attachment, and + // the attachment is not also used as a color or depth/stencil attachment in the same + // subpass, then loadOp must not be VK_ATTACHMENT_LOAD_OP_CLEAR + debug_assert!(description.attachment_descs().enumerate().all(|(atch_num, + attachment)| { + if attachment.load != LoadOp::Clear { + return true; + } + + for p in description.subpass_descs() { + if p.color_attachments + .iter() + .find(|&&(a, _)| a == atch_num) + .is_some() + { + return true; + } + if let Some((a, _)) = p.depth_stencil { + if a == atch_num { + return true; + } + } + if p.input_attachments + .iter() + .find(|&&(a, _)| a == atch_num) + .is_some() + { + return false; + } + } + + true + })); + + let attachments = description + .attachment_descs() + .map(|attachment| { + debug_assert!(attachment.samples.is_power_of_two()); + + vk::AttachmentDescription { + flags: 0, // FIXME: may alias flag + format: attachment.format as u32, + samples: attachment.samples, + loadOp: attachment.load as u32, + storeOp: attachment.store as u32, + stencilLoadOp: attachment.stencil_load as u32, + stencilStoreOp: attachment.stencil_store as u32, + initialLayout: attachment.initial_layout as u32, + finalLayout: attachment.final_layout as u32, + } + }) + .collect::<SmallVec<[_; 16]>>(); + + // We need to pass pointers to vkAttachmentReference structs when creating the render pass. + // Therefore we need to allocate them in advance. + // + // This block allocates, for each pass, in order, all color attachment references, then all + // input attachment references, then all resolve attachment references, then the depth + // stencil attachment reference. + let attachment_references = description + .subpass_descs() + .flat_map(|pass| { + // Performing some validation with debug asserts. + debug_assert!(pass.resolve_attachments.is_empty() || + pass.resolve_attachments.len() == pass.color_attachments.len()); + debug_assert!(pass.resolve_attachments + .iter() + .all(|a| attachments[a.0].samples == 1)); + debug_assert!(pass.resolve_attachments.is_empty() || + pass.color_attachments + .iter() + .all(|a| attachments[a.0].samples > 1)); + debug_assert!(pass.resolve_attachments.is_empty() || + pass.resolve_attachments + .iter() + .zip(pass.color_attachments.iter()) + .all(|(r, c)| { + attachments[r.0].format == attachments[c.0].format + })); + debug_assert!(pass.color_attachments + .iter() + .cloned() + .chain(pass.depth_stencil.clone().into_iter()) + .chain(pass.input_attachments.iter().cloned()) + .chain(pass.resolve_attachments.iter().cloned()) + .all(|(a, _)| { + pass.preserve_attachments + .iter() + .find(|&&b| a == b) + .is_none() + })); + debug_assert!( + pass.color_attachments + .iter() + .cloned() + .chain(pass.depth_stencil.clone().into_iter()) + .all(|(atch, layout)| if let Some(r) = + pass.input_attachments.iter().find(|r| r.0 == atch) + { + r.1 == layout + } else { + true + }) + ); + + let resolve = pass.resolve_attachments + .into_iter() + .map(|(offset, img_la)| { + debug_assert!(offset < attachments.len()); + vk::AttachmentReference { + attachment: offset as u32, + layout: img_la as u32, + } + }); + + let color = pass.color_attachments.into_iter().map(|(offset, img_la)| { + debug_assert!(offset < attachments.len()); + vk::AttachmentReference { + attachment: offset as u32, + layout: img_la as u32, + } + }); + + let input = pass.input_attachments.into_iter().map(|(offset, img_la)| { + debug_assert!(offset < attachments.len()); + vk::AttachmentReference { + attachment: offset as u32, + layout: img_la as u32, + } + }); + + let depthstencil = if let Some((offset, img_la)) = pass.depth_stencil { + Some(vk::AttachmentReference { + attachment: offset as u32, + layout: img_la as u32, + }) + } else { + None + }.into_iter(); + + color.chain(input).chain(resolve).chain(depthstencil) + }) + .collect::<SmallVec<[_; 16]>>(); + + // Same as `attachment_references` but only for the preserve attachments. + // This is separate because attachment references are u32s and not `vkAttachmentReference` + // structs. + let preserve_attachments_references = description + .subpass_descs() + .flat_map(|pass| { + pass.preserve_attachments + .into_iter() + .map(|offset| offset as u32) + }) + .collect::<SmallVec<[_; 16]>>(); + + // Now iterating over passes. + let passes = unsafe { + // `ref_index` and `preserve_ref_index` are increased during the loop and point to the + // next element to use in respectively `attachment_references` and + // `preserve_attachments_references`. + let mut ref_index = 0usize; + let mut preserve_ref_index = 0usize; + let mut out: SmallVec<[_; 16]> = SmallVec::new(); + + for pass in description.subpass_descs() { + if pass.color_attachments.len() as u32 > + device.physical_device().limits().max_color_attachments() + { + return Err(RenderPassCreationError::ColorAttachmentsLimitExceeded); + } + + let color_attachments = attachment_references.as_ptr().offset(ref_index as isize); + ref_index += pass.color_attachments.len(); + let input_attachments = attachment_references.as_ptr().offset(ref_index as isize); + ref_index += pass.input_attachments.len(); + let resolve_attachments = attachment_references.as_ptr().offset(ref_index as isize); + ref_index += pass.resolve_attachments.len(); + let depth_stencil = if pass.depth_stencil.is_some() { + let a = attachment_references.as_ptr().offset(ref_index as isize); + ref_index += 1; + a + } else { + ptr::null() + }; + + let preserve_attachments = preserve_attachments_references + .as_ptr() + .offset(preserve_ref_index as isize); + preserve_ref_index += pass.preserve_attachments.len(); + + out.push(vk::SubpassDescription { + flags: 0, // reserved + pipelineBindPoint: vk::PIPELINE_BIND_POINT_GRAPHICS, + inputAttachmentCount: pass.input_attachments.len() as u32, + pInputAttachments: if pass.input_attachments.is_empty() { + ptr::null() + } else { + input_attachments + }, + colorAttachmentCount: pass.color_attachments.len() as u32, + pColorAttachments: if pass.color_attachments.is_empty() { + ptr::null() + } else { + color_attachments + }, + pResolveAttachments: if pass.resolve_attachments.is_empty() { + ptr::null() + } else { + resolve_attachments + }, + pDepthStencilAttachment: depth_stencil, + preserveAttachmentCount: pass.preserve_attachments.len() as u32, + pPreserveAttachments: if pass.preserve_attachments.is_empty() { + ptr::null() + } else { + preserve_attachments + }, + }); + } + + assert!(!out.is_empty()); + // If these assertions fails, there's a serious bug in the code above ^. + debug_assert!(ref_index == attachment_references.len()); + debug_assert!(preserve_ref_index == preserve_attachments_references.len()); + + out + }; + + let dependencies = description + .dependency_descs() + .map(|dependency| { + debug_assert!(dependency.source_subpass as u32 == vk::SUBPASS_EXTERNAL || dependency.source_subpass < passes.len()); + debug_assert!(dependency.destination_subpass as u32 == vk::SUBPASS_EXTERNAL || dependency.destination_subpass < passes.len()); + + vk::SubpassDependency { + srcSubpass: dependency.source_subpass as u32, + dstSubpass: dependency.destination_subpass as u32, + srcStageMask: dependency.source_stages.into_vulkan_bits(), + dstStageMask: dependency.destination_stages.into_vulkan_bits(), + srcAccessMask: dependency.source_access.into_vulkan_bits(), + dstAccessMask: dependency.destination_access.into_vulkan_bits(), + dependencyFlags: if dependency.by_region { + vk::DEPENDENCY_BY_REGION_BIT + } else { + 0 + }, + } + }) + .collect::<SmallVec<[_; 16]>>(); + + let render_pass = unsafe { + let infos = vk::RenderPassCreateInfo { + sType: vk::STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + attachmentCount: attachments.len() as u32, + pAttachments: if attachments.is_empty() { + ptr::null() + } else { + attachments.as_ptr() + }, + subpassCount: passes.len() as u32, + pSubpasses: if passes.is_empty() { + ptr::null() + } else { + passes.as_ptr() + }, + dependencyCount: dependencies.len() as u32, + pDependencies: if dependencies.is_empty() { + ptr::null() + } else { + dependencies.as_ptr() + }, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateRenderPass(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(RenderPass { + device: device.clone(), + render_pass: render_pass, + desc: description, + granularity: Mutex::new(None), + }) + } +} + +impl RenderPass<EmptySinglePassRenderPassDesc> { + /// Builds a render pass with one subpass and no attachment. + /// + /// This method is useful for quick tests. + #[inline] + pub fn empty_single_pass( + device: Arc<Device>) + -> Result<RenderPass<EmptySinglePassRenderPassDesc>, RenderPassCreationError> { + RenderPass::new(device, EmptySinglePassRenderPassDesc) + } +} + +impl<D> RenderPass<D> { + /// Returns the granularity of this render pass. + /// + /// If the render area of a render pass in a command buffer is a multiple of this granularity, + /// then the performance will be optimal. Performances are always optimal for render areas + /// that cover the whole framebuffer. + pub fn granularity(&self) -> [u32; 2] { + let mut granularity = self.granularity.lock().unwrap(); + + if let Some(&granularity) = granularity.as_ref() { + return granularity; + } + + unsafe { + let vk = self.device.pointers(); + let mut out = mem::uninitialized(); + vk.GetRenderAreaGranularity(self.device.internal_object(), self.render_pass, &mut out); + + debug_assert_ne!(out.width, 0); + debug_assert_ne!(out.height, 0); + let gran = [out.width, out.height]; + *granularity = Some(gran); + gran + } + } + + /// Returns the description of the render pass. + /// + /// > **Note**: You must not somehow modify the description. This shouldn't be possible anyway + /// > if `RenderPassDesc` was implemented correctly. + #[inline] + pub fn desc(&self) -> &D { + &self.desc + } +} + +unsafe impl<D> RenderPassDesc for RenderPass<D> + where D: RenderPassDesc +{ + #[inline] + fn num_attachments(&self) -> usize { + self.desc.num_attachments() + } + + #[inline] + fn attachment_desc(&self, num: usize) -> Option<AttachmentDescription> { + self.desc.attachment_desc(num) + } + + #[inline] + fn num_subpasses(&self) -> usize { + self.desc.num_subpasses() + } + + #[inline] + fn subpass_desc(&self, num: usize) -> Option<PassDescription> { + self.desc.subpass_desc(num) + } + + #[inline] + fn num_dependencies(&self) -> usize { + self.desc.num_dependencies() + } + + #[inline] + fn dependency_desc(&self, num: usize) -> Option<PassDependencyDescription> { + self.desc.dependency_desc(num) + } +} + +unsafe impl<C, D> RenderPassDescClearValues<C> for RenderPass<D> + where D: RenderPassDescClearValues<C> +{ + #[inline] + fn convert_clear_values(&self, vals: C) -> Box<Iterator<Item = ClearValue>> { + self.desc.convert_clear_values(vals) + } +} + +unsafe impl<D> RenderPassAbstract for RenderPass<D> + where D: RenderPassDesc +{ + #[inline] + fn inner(&self) -> RenderPassSys { + RenderPassSys(self.render_pass, PhantomData) + } +} + +unsafe impl<D> DeviceOwned for RenderPass<D> { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl<D> fmt::Debug for RenderPass<D> + where D: fmt::Debug +{ + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fmt.debug_struct("RenderPass") + .field("raw", &self.render_pass) + .field("device", &self.device) + .field("desc", &self.desc) + .finish() + } +} + +impl<D> Drop for RenderPass<D> { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyRenderPass(self.device.internal_object(), self.render_pass, ptr::null()); + } + } +} + +/// Opaque object that represents the render pass' internals. +#[derive(Debug, Copy, Clone)] +pub struct RenderPassSys<'a>(vk::RenderPass, PhantomData<&'a ()>); + +unsafe impl<'a> VulkanObject for RenderPassSys<'a> { + type Object = vk::RenderPass; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT; + + #[inline] + fn internal_object(&self) -> vk::RenderPass { + self.0 + } +} + +/// Error that can happen when creating a compute pipeline. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum RenderPassCreationError { + /// Not enough memory. + OomError(OomError), + /// The maximum number of color attachments has been exceeded. + ColorAttachmentsLimitExceeded, +} + +impl error::Error for RenderPassCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + RenderPassCreationError::OomError(_) => "not enough memory available", + RenderPassCreationError::ColorAttachmentsLimitExceeded => { + "the maximum number of color attachments has been exceeded" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + RenderPassCreationError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for RenderPassCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for RenderPassCreationError { + #[inline] + fn from(err: OomError) -> RenderPassCreationError { + RenderPassCreationError::OomError(err) + } +} + +impl From<Error> for RenderPassCreationError { + #[inline] + fn from(err: Error) -> RenderPassCreationError { + match err { + err @ Error::OutOfHostMemory => { + RenderPassCreationError::OomError(OomError::from(err)) + }, + err @ Error::OutOfDeviceMemory => { + RenderPassCreationError::OomError(OomError::from(err)) + }, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +#[cfg(test)] +mod tests { + use format::Format; + use framebuffer::RenderPass; + use framebuffer::RenderPassCreationError; + + #[test] + fn empty() { + let (device, _) = gfx_dev_and_queue!(); + let _ = RenderPass::empty_single_pass(device).unwrap(); + } + + #[test] + fn too_many_color_atch() { + let (device, _) = gfx_dev_and_queue!(); + + if device.physical_device().limits().max_color_attachments() >= 10 { + return; // test ignored + } + + let rp = + single_pass_renderpass! { + device.clone(), + attachments: { + a1: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, }, + a2: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, }, + a3: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, }, + a4: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, }, + a5: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, }, + a6: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, }, + a7: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, }, + a8: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, }, + a9: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, }, + a10: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, } + }, + pass: { + color: [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10], + depth_stencil: {} + } + }; + + match rp { + Err(RenderPassCreationError::ColorAttachmentsLimitExceeded) => (), + _ => panic!(), + } + } + + #[test] + fn non_zero_granularity() { + let (device, _) = gfx_dev_and_queue!(); + + let rp = single_pass_renderpass! { + device.clone(), + attachments: { + a: { load: Clear, store: DontCare, format: Format::R8G8B8A8Unorm, samples: 1, } + }, + pass: { + color: [a], + depth_stencil: {} + } + }.unwrap(); + + let granularity = rp.granularity(); + assert_ne!(granularity[0], 0); + assert_ne!(granularity[1], 0); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/traits.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/traits.rs new file mode 100644 index 0000000..deb4ed0 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/framebuffer/traits.rs @@ -0,0 +1,349 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use device::DeviceOwned; +use format::ClearValue; +use framebuffer::FramebufferSys; +use framebuffer::RenderPassDesc; +use framebuffer::RenderPassSys; +use image::ImageViewAccess; +use pipeline::shader::ShaderInterfaceDef; + +use SafeDeref; + +/// Trait for objects that contain a Vulkan framebuffer object. +/// +/// Any `Framebuffer` object implements this trait. You can therefore turn a `Arc<Framebuffer<_>>` +/// into a `Arc<FramebufferAbstract + Send + Sync>` for easier storage. +pub unsafe trait FramebufferAbstract: RenderPassAbstract { + /// Returns an opaque struct that represents the framebuffer's internals. + fn inner(&self) -> FramebufferSys; + + /// Returns the width, height and array layers of the framebuffer. + fn dimensions(&self) -> [u32; 3]; + + /// Returns the attachment of the framebuffer with the given index. + /// + /// If the `index` is not between `0` and `num_attachments`, then `None` should be returned. + fn attached_image_view(&self, index: usize) -> Option<&ImageViewAccess>; + + /// Returns the width of the framebuffer in pixels. + #[inline] + fn width(&self) -> u32 { + self.dimensions()[0] + } + + /// Returns the height of the framebuffer in pixels. + #[inline] + fn height(&self) -> u32 { + self.dimensions()[1] + } + + /// Returns the number of layers (or depth) of the framebuffer. + #[inline] + fn layers(&self) -> u32 { + self.dimensions()[2] + } +} + +unsafe impl<T> FramebufferAbstract for T + where T: SafeDeref, + T::Target: FramebufferAbstract +{ + #[inline] + fn inner(&self) -> FramebufferSys { + FramebufferAbstract::inner(&**self) + } + + #[inline] + fn dimensions(&self) -> [u32; 3] { + (**self).dimensions() + } + + #[inline] + fn attached_image_view(&self, index: usize) -> Option<&ImageViewAccess> { + (**self).attached_image_view(index) + } +} + +/// Trait for objects that contain a Vulkan render pass object. +/// +/// Any `RenderPass` object implements this trait. You can therefore turn a `Arc<RenderPass<_>>` +/// into a `Arc<RenderPassAbstract + Send + Sync>` for easier storage. +/// +/// The `Arc<RenderPassAbstract + Send + Sync>` accepts a `Vec<ClearValue>` for clear values and a +/// `Vec<Arc<ImageView + Send + Sync>>` for the list of attachments. +/// +/// # Example +/// +/// ``` +/// use std::sync::Arc; +/// use vulkano::framebuffer::EmptySinglePassRenderPassDesc; +/// use vulkano::framebuffer::RenderPass; +/// use vulkano::framebuffer::RenderPassAbstract; +/// +/// # let device: Arc<vulkano::device::Device> = return; +/// let render_pass = RenderPass::new(device.clone(), EmptySinglePassRenderPassDesc).unwrap(); +/// +/// // For easier storage, turn this render pass into a `Arc<RenderPassAbstract + Send + Sync>`. +/// let stored_rp = Arc::new(render_pass) as Arc<RenderPassAbstract + Send + Sync>; +/// ``` +pub unsafe trait RenderPassAbstract: DeviceOwned + RenderPassDesc { + /// Returns an opaque object representing the render pass' internals. + /// + /// # Safety + /// + /// The trait implementation must return the same value every time. + fn inner(&self) -> RenderPassSys; +} + +unsafe impl<T> RenderPassAbstract for T + where T: SafeDeref, + T::Target: RenderPassAbstract +{ + #[inline] + fn inner(&self) -> RenderPassSys { + (**self).inner() + } +} + +/// Extension trait for `RenderPassDesc`. Defines which types are allowed as a list of clear values. +/// +/// When the user enters a render pass, they need to pass a list of clear values to apply to +/// the attachments of the framebuffer. To do so, the render pass object or the framebuffer +/// (depending on the function you use) must implement `RenderPassDescClearValues<C>` where `C` is +/// the parameter that the user passed. The trait method is then responsible for checking the +/// correctness of these values and turning them into a list that can be processed by vulkano. +pub unsafe trait RenderPassDescClearValues<C> { + /// Decodes a `C` into a list of clear values where each element corresponds + /// to an attachment. The size of the returned iterator must be the same as the number of + /// attachments. + /// + /// The format of the clear value **must** match the format of the attachment. Attachments + /// that are not loaded with `LoadOp::Clear` must have an entry equal to `ClearValue::None`. + /// + /// # Safety + /// + /// This trait is unsafe because vulkano doesn't check whether the clear value is in a format + /// that matches the attachment. + /// + // TODO: meh for boxing + fn convert_clear_values(&self, C) -> Box<Iterator<Item = ClearValue>>; +} + +unsafe impl<T, C> RenderPassDescClearValues<C> for T + where T: SafeDeref, + T::Target: RenderPassDescClearValues<C> +{ + #[inline] + fn convert_clear_values(&self, vals: C) -> Box<Iterator<Item = ClearValue>> { + (**self).convert_clear_values(vals) + } +} + +/// Extension trait for `RenderPassDesc` that checks whether a subpass of this render pass accepts +/// the output of a fragment shader. +/// +/// The trait is automatically implemented for all type that implement `RenderPassDesc` and +/// `RenderPassDesc`. +/// +/// > **Note**: This trait exists so that you can specialize it once specialization lands in Rust. +// TODO: once specialization lands, this trait can be specialized for pairs that are known to +// always be compatible +pub unsafe trait RenderPassSubpassInterface<Other: ?Sized>: RenderPassDesc + where Other: ShaderInterfaceDef +{ + /// Returns `true` if this subpass is compatible with the fragment output definition. + /// Also returns `false` if the subpass is out of range. + // TODO: return proper error + fn is_compatible_with(&self, subpass: u32, other: &Other) -> bool; +} + +unsafe impl<A, B: ?Sized> RenderPassSubpassInterface<B> for A + where A: RenderPassDesc, + B: ShaderInterfaceDef +{ + fn is_compatible_with(&self, subpass: u32, other: &B) -> bool { + let pass_descr = match RenderPassDesc::subpass_descs(self) + .skip(subpass as usize) + .next() { + Some(s) => s, + None => return false, + }; + + for element in other.elements() { + for location in element.location.clone() { + let attachment_id = match pass_descr.color_attachments.get(location as usize) { + Some(a) => a.0, + None => return false, + }; + + let attachment_desc = (&self) + .attachment_descs() + .skip(attachment_id) + .next() + .unwrap(); + + // FIXME: compare formats depending on the number of components and data type + /*if attachment_desc.format != element.format { + return false; + }*/ + } + } + + true + } +} + +/// Trait implemented on render pass objects to check whether they are compatible +/// with another render pass. +/// +/// The trait is automatically implemented for all type that implement `RenderPassDesc`. +/// +/// > **Note**: This trait exists so that you can specialize it once specialization lands in Rust. +// TODO: once specialization lands, this trait can be specialized for pairs that are known to +// always be compatible +// TODO: maybe this can be unimplemented on some pairs, to provide compile-time checks? +pub unsafe trait RenderPassCompatible<Other: ?Sized>: RenderPassDesc + where Other: RenderPassDesc +{ + /// Returns `true` if this layout is compatible with the other layout, as defined in the + /// `Render Pass Compatibility` section of the Vulkan specs. + // TODO: return proper error + fn is_compatible_with(&self, other: &Other) -> bool; +} + +unsafe impl<A: ?Sized, B: ?Sized> RenderPassCompatible<B> for A + where A: RenderPassDesc, + B: RenderPassDesc +{ + fn is_compatible_with(&self, other: &B) -> bool { + if self.num_attachments() != other.num_attachments() { + return false; + } + + for atch_num in 0 .. self.num_attachments() { + let my_atch = self.attachment_desc(atch_num).unwrap(); + let other_atch = other.attachment_desc(atch_num).unwrap(); + + if !my_atch.is_compatible_with(&other_atch) { + return false; + } + } + + return true; + + // FIXME: finish + } +} + +/// Represents a subpass within a `RenderPassAbstract` object. +/// +/// This struct doesn't correspond to anything in Vulkan. It is simply an equivalent to a +/// tuple of a render pass and subpass index. Contrary to a tuple, however, the existence of the +/// subpass is checked when the object is created. When you have a `Subpass` you are guaranteed +/// that the given subpass does exist. +#[derive(Debug, Copy, Clone)] +pub struct Subpass<L> { + render_pass: L, + subpass_id: u32, +} + +impl<L> Subpass<L> + where L: RenderPassDesc +{ + /// Returns a handle that represents a subpass of a render pass. + #[inline] + pub fn from(render_pass: L, id: u32) -> Option<Subpass<L>> { + if (id as usize) < render_pass.num_subpasses() { + Some(Subpass { + render_pass: render_pass, + subpass_id: id, + }) + + } else { + None + } + } + + /// Returns the number of color attachments in this subpass. + #[inline] + pub fn num_color_attachments(&self) -> u32 { + self.render_pass + .num_color_attachments(self.subpass_id) + .unwrap() + } + + /// Returns true if the subpass has a depth attachment or a depth-stencil attachment. + #[inline] + pub fn has_depth(&self) -> bool { + self.render_pass.has_depth(self.subpass_id).unwrap() + } + + /// Returns true if the subpass has a depth attachment or a depth-stencil attachment whose + /// layout is not `DepthStencilReadOnlyOptimal`. + #[inline] + pub fn has_writable_depth(&self) -> bool { + self.render_pass + .has_writable_depth(self.subpass_id) + .unwrap() + } + + /// Returns true if the subpass has a stencil attachment or a depth-stencil attachment. + #[inline] + pub fn has_stencil(&self) -> bool { + self.render_pass.has_stencil(self.subpass_id).unwrap() + } + + /// Returns true if the subpass has a stencil attachment or a depth-stencil attachment whose + /// layout is not `DepthStencilReadOnlyOptimal`. + #[inline] + pub fn has_writable_stencil(&self) -> bool { + self.render_pass + .has_writable_stencil(self.subpass_id) + .unwrap() + } + + /// Returns true if the subpass has any color or depth/stencil attachment. + #[inline] + pub fn has_color_or_depth_stencil_attachment(&self) -> bool { + self.num_color_attachments() >= 1 || + self.render_pass + .has_depth_stencil_attachment(self.subpass_id) + .unwrap() != (false, false) + } + + /// Returns the number of samples in the color and/or depth/stencil attachments. Returns `None` + /// if there is no such attachment in this subpass. + #[inline] + pub fn num_samples(&self) -> Option<u32> { + self.render_pass.num_samples(self.subpass_id) + } +} + +impl<L> Subpass<L> { + /// Returns the render pass of this subpass. + #[inline] + pub fn render_pass(&self) -> &L { + &self.render_pass + } + + /// Returns the index of this subpass within the renderpass. + #[inline] + pub fn index(&self) -> u32 { + self.subpass_id + } +} + +impl<L> Into<(L, u32)> for Subpass<L> { + #[inline] + fn into(self) -> (L, u32) { + (self.render_pass, self.subpass_id) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/image/attachment.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/image/attachment.rs new file mode 100644 index 0000000..7ee458f --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/image/attachment.rs @@ -0,0 +1,590 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::iter::Empty; +use std::sync::Arc; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; + +use buffer::BufferAccess; +use device::Device; +use format::ClearValue; +use format::Format; +use format::FormatDesc; +use format::FormatTy; +use image::Dimensions; +use image::ImageDimensions; +use image::ImageInner; +use image::ImageLayout; +use image::ImageUsage; +use image::ViewType; +use image::sys::ImageCreationError; +use image::sys::UnsafeImage; +use image::sys::UnsafeImageView; +use image::traits::ImageAccess; +use image::traits::ImageClearValue; +use image::traits::ImageContent; +use image::traits::ImageViewAccess; +use memory::DedicatedAlloc; +use memory::pool::AllocFromRequirementsFilter; +use memory::pool::AllocLayout; +use memory::pool::MappingRequirement; +use memory::pool::MemoryPool; +use memory::pool::MemoryPoolAlloc; +use memory::pool::PotentialDedicatedAllocation; +use memory::pool::StdMemoryPoolAlloc; +use sync::AccessError; +use sync::Sharing; + +/// ImageAccess whose purpose is to be used as a framebuffer attachment. +/// +/// The image is always two-dimensional and has only one mipmap, but it can have any kind of +/// format. Trying to use a format that the backend doesn't support for rendering will result in +/// an error being returned when creating the image. Once you have an `AttachmentImage`, you are +/// guaranteed that you will be able to draw on it. +/// +/// The template parameter of `AttachmentImage` is a type that describes the format of the image. +/// +/// # Regular vs transient +/// +/// Calling `AttachmentImage::new` will create a regular image, while calling +/// `AttachmentImage::transient` will create a *transient* image. Transient image are only +/// relevant for images that serve as attachments, so `AttachmentImage` is the only type of +/// image in vulkano that provides a shortcut for this. +/// +/// A transient image is a special kind of image whose content is undefined outside of render +/// passes. Once you finish drawing, reading from it will returned undefined data (which can be +/// either valid or garbage, depending on the implementation). +/// +/// This gives a hint to the Vulkan implementation that it is possible for the image's content to +/// live exclusively in some cache memory, and that no real memory has to be allocated for it. +/// +/// In other words, if you are going to read from the image after drawing to it, use a regular +/// image. If you don't need to read from it (for example if it's some kind of intermediary color, +/// or a depth buffer that is only used once) then use a transient image as it may improve +/// performance. +/// +// TODO: forbid reading transient images outside render passes? +#[derive(Debug)] +pub struct AttachmentImage<F = Format, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { + // Inner implementation. + image: UnsafeImage, + + // We maintain a view of the whole image since we will need it when rendering. + view: UnsafeImageView, + + // Memory used to back the image. + memory: A, + + // Format. + format: F, + + // Layout to use when the image is used as a framebuffer attachment. + // Must be either "depth-stencil optimal" or "color optimal". + attachment_layout: ImageLayout, + + // If true, then the image is in the layout of `attachment_layout` (above). If false, then it + // is still `Undefined`. + initialized: AtomicBool, + + // Number of times this image is locked on the GPU side. + gpu_lock: AtomicUsize, +} + +impl<F> AttachmentImage<F> { + /// Creates a new image with the given dimensions and format. + /// + /// Returns an error if the dimensions are too large or if the backend doesn't support this + /// format as a framebuffer attachment. + #[inline] + pub fn new(device: Arc<Device>, dimensions: [u32; 2], format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + AttachmentImage::new_impl(device, dimensions, format, ImageUsage::none(), 1) + } + + /// Same as `new`, but creates an image that can be used as an input attachment. + /// + /// > **Note**: This function is just a convenient shortcut for `with_usage`. + #[inline] + pub fn input_attachment(device: Arc<Device>, dimensions: [u32; 2], format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + let base_usage = ImageUsage { + input_attachment: true, + ..ImageUsage::none() + }; + + AttachmentImage::new_impl(device, dimensions, format, base_usage, 1) + } + + /// Same as `new`, but creates a multisampled image. + /// + /// > **Note**: You can also use this function and pass `1` for the number of samples if you + /// > want a regular image. + #[inline] + pub fn multisampled(device: Arc<Device>, dimensions: [u32; 2], samples: u32, format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + AttachmentImage::new_impl(device, dimensions, format, ImageUsage::none(), samples) + } + + /// Same as `multisampled`, but creates an image that can be used as an input attachment. + /// + /// > **Note**: This function is just a convenient shortcut for `multisampled_with_usage`. + #[inline] + pub fn multisampled_input_attachment(device: Arc<Device>, dimensions: [u32; 2], samples: u32, + format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + let base_usage = ImageUsage { + input_attachment: true, + ..ImageUsage::none() + }; + + AttachmentImage::new_impl(device, dimensions, format, base_usage, samples) + } + + /// Same as `new`, but lets you specify additional usages. + /// + /// The `color_attachment` or `depth_stencil_attachment` usages are automatically added based + /// on the format of the usage. Therefore the `usage` parameter allows you specify usages in + /// addition to these two. + #[inline] + pub fn with_usage(device: Arc<Device>, dimensions: [u32; 2], format: F, usage: ImageUsage) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + AttachmentImage::new_impl(device, dimensions, format, usage, 1) + } + + /// Same as `with_usage`, but creates a multisampled image. + /// + /// > **Note**: You can also use this function and pass `1` for the number of samples if you + /// > want a regular image. + /// + /// > **Note**: This function is just a convenient shortcut for `multisampled_with_usage`. + #[inline] + pub fn multisampled_with_usage(device: Arc<Device>, dimensions: [u32; 2], samples: u32, + format: F, usage: ImageUsage) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + AttachmentImage::new_impl(device, dimensions, format, usage, samples) + } + + /// Same as `new`, except that the image can later be sampled. + /// + /// > **Note**: This function is just a convenient shortcut for `with_usage`. + #[inline] + pub fn sampled(device: Arc<Device>, dimensions: [u32; 2], format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + let base_usage = ImageUsage { + sampled: true, + ..ImageUsage::none() + }; + + AttachmentImage::new_impl(device, dimensions, format, base_usage, 1) + } + + /// Same as `sampled`, except that the image can be used as an input attachment. + /// + /// > **Note**: This function is just a convenient shortcut for `with_usage`. + #[inline] + pub fn sampled_input_attachment(device: Arc<Device>, dimensions: [u32; 2], format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + let base_usage = ImageUsage { + sampled: true, + input_attachment: true, + ..ImageUsage::none() + }; + + AttachmentImage::new_impl(device, dimensions, format, base_usage, 1) + } + + /// Same as `sampled`, but creates a multisampled image. + /// + /// > **Note**: You can also use this function and pass `1` for the number of samples if you + /// > want a regular image. + /// + /// > **Note**: This function is just a convenient shortcut for `multisampled_with_usage`. + #[inline] + pub fn sampled_multisampled(device: Arc<Device>, dimensions: [u32; 2], samples: u32, format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + let base_usage = ImageUsage { + sampled: true, + ..ImageUsage::none() + }; + + AttachmentImage::new_impl(device, dimensions, format, base_usage, samples) + } + + /// Same as `sampled_multisampled`, but creates an image that can be used as an input + /// attachment. + /// + /// > **Note**: This function is just a convenient shortcut for `multisampled_with_usage`. + #[inline] + pub fn sampled_multisampled_input_attachment( + device: Arc<Device>, dimensions: [u32; 2], samples: u32, format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + let base_usage = ImageUsage { + sampled: true, + input_attachment: true, + ..ImageUsage::none() + }; + + AttachmentImage::new_impl(device, dimensions, format, base_usage, samples) + } + + /// Same as `new`, except that the image will be transient. + /// + /// A transient image is special because its content is undefined outside of a render pass. + /// This means that the implementation has the possibility to not allocate any memory for it. + /// + /// > **Note**: This function is just a convenient shortcut for `with_usage`. + #[inline] + pub fn transient(device: Arc<Device>, dimensions: [u32; 2], format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + let base_usage = ImageUsage { + transient_attachment: true, + ..ImageUsage::none() + }; + + AttachmentImage::new_impl(device, dimensions, format, base_usage, 1) + } + + /// Same as `transient`, except that the image can be used as an input attachment. + /// + /// > **Note**: This function is just a convenient shortcut for `with_usage`. + #[inline] + pub fn transient_input_attachment(device: Arc<Device>, dimensions: [u32; 2], format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + let base_usage = ImageUsage { + transient_attachment: true, + input_attachment: true, + ..ImageUsage::none() + }; + + AttachmentImage::new_impl(device, dimensions, format, base_usage, 1) + } + + /// Same as `transient`, but creates a multisampled image. + /// + /// > **Note**: You can also use this function and pass `1` for the number of samples if you + /// > want a regular image. + /// + /// > **Note**: This function is just a convenient shortcut for `multisampled_with_usage`. + #[inline] + pub fn transient_multisampled(device: Arc<Device>, dimensions: [u32; 2], samples: u32, + format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + let base_usage = ImageUsage { + transient_attachment: true, + ..ImageUsage::none() + }; + + AttachmentImage::new_impl(device, dimensions, format, base_usage, samples) + } + + /// Same as `transient_multisampled`, but creates an image that can be used as an input + /// attachment. + /// + /// > **Note**: This function is just a convenient shortcut for `multisampled_with_usage`. + #[inline] + pub fn transient_multisampled_input_attachment( + device: Arc<Device>, dimensions: [u32; 2], samples: u32, format: F) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + let base_usage = ImageUsage { + transient_attachment: true, + input_attachment: true, + ..ImageUsage::none() + }; + + AttachmentImage::new_impl(device, dimensions, format, base_usage, samples) + } + + // All constructors dispatch to this one. + fn new_impl(device: Arc<Device>, dimensions: [u32; 2], format: F, base_usage: ImageUsage, + samples: u32) + -> Result<Arc<AttachmentImage<F>>, ImageCreationError> + where F: FormatDesc + { + // TODO: check dimensions against the max_framebuffer_width/height/layers limits + + let is_depth = match format.format().ty() { + FormatTy::Depth => true, + FormatTy::DepthStencil => true, + FormatTy::Stencil => true, + FormatTy::Compressed => panic!(), + _ => false, + }; + + let usage = ImageUsage { + color_attachment: !is_depth, + depth_stencil_attachment: is_depth, + ..base_usage + }; + + let (image, mem_reqs) = unsafe { + let dims = ImageDimensions::Dim2d { + width: dimensions[0], + height: dimensions[1], + array_layers: 1, + cubemap_compatible: false, + }; + + UnsafeImage::new(device.clone(), + usage, + format.format(), + dims, + samples, + 1, + Sharing::Exclusive::<Empty<u32>>, + false, + false)? + }; + + let mem = MemoryPool::alloc_from_requirements(&Device::standard_pool(&device), + &mem_reqs, + AllocLayout::Optimal, + MappingRequirement::DoNotMap, + DedicatedAlloc::Image(&image), + |t| if t.is_device_local() { + AllocFromRequirementsFilter::Preferred + } else { + AllocFromRequirementsFilter::Allowed + })?; + debug_assert!((mem.offset() % mem_reqs.alignment) == 0); + unsafe { + image.bind_memory(mem.memory(), mem.offset())?; + } + + let view = unsafe { UnsafeImageView::raw(&image, ViewType::Dim2d, 0 .. 1, 0 .. 1)? }; + + Ok(Arc::new(AttachmentImage { + image: image, + view: view, + memory: mem, + format: format, + attachment_layout: if is_depth { + ImageLayout::DepthStencilAttachmentOptimal + } else { + ImageLayout::ColorAttachmentOptimal + }, + initialized: AtomicBool::new(false), + gpu_lock: AtomicUsize::new(0), + })) + } +} + +impl<F, A> AttachmentImage<F, A> { + /// Returns the dimensions of the image. + #[inline] + pub fn dimensions(&self) -> [u32; 2] { + let dims = self.image.dimensions(); + [dims.width(), dims.height()] + } +} + +unsafe impl<F, A> ImageAccess for AttachmentImage<F, A> + where F: 'static + Send + Sync +{ + #[inline] + fn inner(&self) -> ImageInner { + ImageInner { + image: &self.image, + first_layer: 0, + num_layers: self.image.dimensions().array_layers() as usize, + first_mipmap_level: 0, + num_mipmap_levels: 1, + } + } + + #[inline] + fn initial_layout_requirement(&self) -> ImageLayout { + self.attachment_layout + } + + #[inline] + fn final_layout_requirement(&self) -> ImageLayout { + self.attachment_layout + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + false + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + self.conflict_key() == other.conflict_key() + } + + #[inline] + fn conflict_key(&self) -> u64 { + self.image.key() + } + + #[inline] + fn try_gpu_lock(&self, _: bool, expected_layout: ImageLayout) -> Result<(), AccessError> { + if expected_layout != self.attachment_layout && expected_layout != ImageLayout::Undefined { + if self.initialized.load(Ordering::SeqCst) { + return Err(AccessError::UnexpectedImageLayout { + requested: expected_layout, + allowed: self.attachment_layout, + }); + } else { + return Err(AccessError::UnexpectedImageLayout { + requested: expected_layout, + allowed: ImageLayout::Undefined, + }); + } + } + + if expected_layout != ImageLayout::Undefined { + if !self.initialized.load(Ordering::SeqCst) { + return Err(AccessError::ImageNotInitialized { requested: expected_layout }); + } + } + + if self.gpu_lock.compare_and_swap(0, 1, Ordering::SeqCst) == 0 { + Ok(()) + } else { + Err(AccessError::AlreadyInUse) + } + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + let val = self.gpu_lock.fetch_add(1, Ordering::SeqCst); + debug_assert!(val >= 1); + } + + #[inline] + unsafe fn unlock(&self, new_layout: Option<ImageLayout>) { + if let Some(new_layout) = new_layout { + debug_assert_eq!(new_layout, self.attachment_layout); + self.initialized.store(true, Ordering::SeqCst); + } + + let prev_val = self.gpu_lock.fetch_sub(1, Ordering::SeqCst); + debug_assert!(prev_val >= 1); + } +} + +unsafe impl<F, A> ImageClearValue<F::ClearValue> for Arc<AttachmentImage<F, A>> + where F: FormatDesc + 'static + Send + Sync +{ + #[inline] + fn decode(&self, value: F::ClearValue) -> Option<ClearValue> { + Some(self.format.decode_clear_value(value)) + } +} + +unsafe impl<P, F, A> ImageContent<P> for Arc<AttachmentImage<F, A>> + where F: 'static + Send + Sync +{ + #[inline] + fn matches_format(&self) -> bool { + true // FIXME: + } +} + +unsafe impl<F, A> ImageViewAccess for AttachmentImage<F, A> + where F: 'static + Send + Sync +{ + #[inline] + fn parent(&self) -> &ImageAccess { + self + } + + #[inline] + fn dimensions(&self) -> Dimensions { + let dims = self.image.dimensions(); + Dimensions::Dim2d { + width: dims.width(), + height: dims.height(), + } + } + + #[inline] + fn inner(&self) -> &UnsafeImageView { + &self.view + } + + #[inline] + fn descriptor_set_storage_image_layout(&self) -> ImageLayout { + ImageLayout::ShaderReadOnlyOptimal + } + + #[inline] + fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout { + ImageLayout::ShaderReadOnlyOptimal + } + + #[inline] + fn descriptor_set_sampled_image_layout(&self) -> ImageLayout { + ImageLayout::ShaderReadOnlyOptimal + } + + #[inline] + fn descriptor_set_input_attachment_layout(&self) -> ImageLayout { + ImageLayout::ShaderReadOnlyOptimal + } + + #[inline] + fn identity_swizzle(&self) -> bool { + true + } +} + +#[cfg(test)] +mod tests { + use super::AttachmentImage; + use format::Format; + + #[test] + fn create_regular() { + let (device, _) = gfx_dev_and_queue!(); + let _img = AttachmentImage::new(device, [32, 32], Format::R8G8B8A8Unorm).unwrap(); + } + + #[test] + fn create_transient() { + let (device, _) = gfx_dev_and_queue!(); + let _img = AttachmentImage::transient(device, [32, 32], Format::R8G8B8A8Unorm).unwrap(); + } + + #[test] + fn d16_unorm_always_supported() { + let (device, _) = gfx_dev_and_queue!(); + let _img = AttachmentImage::new(device, [32, 32], Format::D16Unorm).unwrap(); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/image/immutable.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/image/immutable.rs new file mode 100644 index 0000000..90e2ece --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/image/immutable.rs @@ -0,0 +1,458 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::sync::Arc; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; + +use buffer::BufferAccess; +use buffer::BufferUsage; +use buffer::CpuAccessibleBuffer; +use buffer::TypedBufferAccess; +use command_buffer::AutoCommandBuffer; +use command_buffer::AutoCommandBufferBuilder; +use command_buffer::CommandBuffer; +use command_buffer::CommandBufferExecFuture; +use device::Device; +use device::Queue; +use format::AcceptsPixels; +use format::Format; +use format::FormatDesc; +use image::Dimensions; +use image::ImageInner; +use image::ImageLayout; +use image::ImageUsage; +use image::MipmapsCount; +use image::sys::ImageCreationError; +use image::sys::UnsafeImage; +use image::sys::UnsafeImageView; +use image::traits::ImageAccess; +use image::traits::ImageContent; +use image::traits::ImageViewAccess; +use instance::QueueFamily; +use memory::DedicatedAlloc; +use memory::pool::AllocFromRequirementsFilter; +use memory::pool::AllocLayout; +use memory::pool::MappingRequirement; +use memory::pool::MemoryPool; +use memory::pool::MemoryPoolAlloc; +use memory::pool::PotentialDedicatedAllocation; +use memory::pool::StdMemoryPoolAlloc; +use sync::AccessError; +use sync::NowFuture; +use sync::Sharing; + +/// Image whose purpose is to be used for read-only purposes. You can write to the image once, +/// but then you must only ever read from it. +// TODO: type (2D, 3D, array, etc.) as template parameter +#[derive(Debug)] +pub struct ImmutableImage<F, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { + image: UnsafeImage, + view: UnsafeImageView, + dimensions: Dimensions, + memory: A, + format: F, + initialized: AtomicBool, + layout: ImageLayout, +} + +// Must not implement Clone, as that would lead to multiple `used` values. +pub struct ImmutableImageInitialization<F, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { + image: Arc<ImmutableImage<F, A>>, + used: AtomicBool, +} + +impl<F> ImmutableImage<F> { + #[deprecated(note = "use ImmutableImage::uninitialized instead")] + #[inline] + pub fn new<'a, I>(device: Arc<Device>, dimensions: Dimensions, format: F, queue_families: I) + -> Result<Arc<ImmutableImage<F>>, ImageCreationError> + where F: FormatDesc, + I: IntoIterator<Item = QueueFamily<'a>> + { + #[allow(deprecated)] + ImmutableImage::with_mipmaps(device, + dimensions, + format, + MipmapsCount::One, + queue_families) + } + + #[deprecated(note = "use ImmutableImage::uninitialized instead")] + #[inline] + pub fn with_mipmaps<'a, I, M>(device: Arc<Device>, dimensions: Dimensions, format: F, + mipmaps: M, queue_families: I) + -> Result<Arc<ImmutableImage<F>>, ImageCreationError> + where F: FormatDesc, + I: IntoIterator<Item = QueueFamily<'a>>, + M: Into<MipmapsCount> + { + let usage = ImageUsage { + transfer_source: true, // for blits + transfer_destination: true, + sampled: true, + ..ImageUsage::none() + }; + + let (image, _) = ImmutableImage::uninitialized(device, + dimensions, + format, + mipmaps, + usage, + ImageLayout::ShaderReadOnlyOptimal, + queue_families)?; + image.initialized.store(true, Ordering::Relaxed); // Allow uninitialized access for backwards compatibility + Ok(image) + } + + /// Builds an uninitialized immutable image. + /// + /// Returns two things: the image, and a special access that should be used for the initial upload to the image. + pub fn uninitialized<'a, I, M>( + device: Arc<Device>, dimensions: Dimensions, format: F, mipmaps: M, usage: ImageUsage, + layout: ImageLayout, queue_families: I) + -> Result<(Arc<ImmutableImage<F>>, ImmutableImageInitialization<F>), ImageCreationError> + where F: FormatDesc, + I: IntoIterator<Item = QueueFamily<'a>>, + M: Into<MipmapsCount> + { + let queue_families = queue_families + .into_iter() + .map(|f| f.id()) + .collect::<SmallVec<[u32; 4]>>(); + + let (image, mem_reqs) = unsafe { + let sharing = if queue_families.len() >= 2 { + Sharing::Concurrent(queue_families.iter().cloned()) + } else { + Sharing::Exclusive + }; + + UnsafeImage::new(device.clone(), + usage, + format.format(), + dimensions.to_image_dimensions(), + 1, + mipmaps, + sharing, + false, + false)? + }; + + let mem = MemoryPool::alloc_from_requirements(&Device::standard_pool(&device), + &mem_reqs, + AllocLayout::Optimal, + MappingRequirement::DoNotMap, + DedicatedAlloc::Image(&image), + |t| if t.is_device_local() { + AllocFromRequirementsFilter::Preferred + } else { + AllocFromRequirementsFilter::Allowed + })?; + debug_assert!((mem.offset() % mem_reqs.alignment) == 0); + unsafe { + image.bind_memory(mem.memory(), mem.offset())?; + } + + let view = unsafe { + UnsafeImageView::raw(&image, + dimensions.to_view_type(), + 0 .. image.mipmap_levels(), + 0 .. image.dimensions().array_layers())? + }; + + let image = Arc::new(ImmutableImage { + image: image, + view: view, + memory: mem, + dimensions: dimensions, + format: format, + initialized: AtomicBool::new(false), + layout: layout, + }); + + let init = ImmutableImageInitialization { + image: image.clone(), + used: AtomicBool::new(false), + }; + + Ok((image, init)) + } + + /// Construct an ImmutableImage from the contents of `iter`. + /// + /// TODO: Support mipmaps + #[inline] + pub fn from_iter<P, I>(iter: I, dimensions: Dimensions, format: F, queue: Arc<Queue>) + -> Result<(Arc<Self>, + CommandBufferExecFuture<NowFuture, AutoCommandBuffer>), + ImageCreationError> + where P: Send + Sync + Clone + 'static, + F: FormatDesc + AcceptsPixels<P> + 'static + Send + Sync, + I: ExactSizeIterator<Item = P>, + Format: AcceptsPixels<P> + { + let source = CpuAccessibleBuffer::from_iter(queue.device().clone(), + BufferUsage::transfer_source(), + iter)?; + ImmutableImage::from_buffer(source, dimensions, format, queue) + } + + /// Construct an ImmutableImage containing a copy of the data in `source`. + /// + /// TODO: Support mipmaps + pub fn from_buffer<B, P>(source: B, dimensions: Dimensions, format: F, queue: Arc<Queue>) + -> Result<(Arc<Self>, + CommandBufferExecFuture<NowFuture, AutoCommandBuffer>), + ImageCreationError> + where B: BufferAccess + TypedBufferAccess<Content = [P]> + 'static + Clone + Send + Sync, + P: Send + Sync + Clone + 'static, + F: FormatDesc + AcceptsPixels<P> + 'static + Send + Sync, + Format: AcceptsPixels<P> + { + let usage = ImageUsage { + transfer_destination: true, + sampled: true, + ..ImageUsage::none() + }; + let layout = ImageLayout::ShaderReadOnlyOptimal; + + let (buffer, init) = + ImmutableImage::uninitialized(source.device().clone(), + dimensions, + format, + MipmapsCount::One, + usage, + layout, + source.device().active_queue_families())?; + + let cb = AutoCommandBufferBuilder::new(source.device().clone(), queue.family())? + .copy_buffer_to_image_dimensions(source, + init, + [0, 0, 0], + dimensions.width_height_depth(), + 0, + dimensions.array_layers_with_cube(), + 0) + .unwrap() + .build() + .unwrap(); + + let future = match cb.execute(queue) { + Ok(f) => f, + Err(_) => unreachable!(), + }; + + Ok((buffer, future)) + } +} + +impl<F, A> ImmutableImage<F, A> { + /// Returns the dimensions of the image. + #[inline] + pub fn dimensions(&self) -> Dimensions { + self.dimensions + } + + /// Returns the number of mipmap levels of the image. + #[inline] + pub fn mipmap_levels(&self) -> u32 { + self.image.mipmap_levels() + } +} + +unsafe impl<F, A> ImageAccess for ImmutableImage<F, A> + where F: 'static + Send + Sync +{ + #[inline] + fn inner(&self) -> ImageInner { + ImageInner { + image: &self.image, + first_layer: 0, + num_layers: self.image.dimensions().array_layers() as usize, + first_mipmap_level: 0, + num_mipmap_levels: self.image.mipmap_levels() as usize, + } + } + + #[inline] + fn initial_layout_requirement(&self) -> ImageLayout { + self.layout + } + + #[inline] + fn final_layout_requirement(&self) -> ImageLayout { + self.layout + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + false + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + self.conflict_key() == other.conflict_key() // TODO: + } + + #[inline] + fn conflict_key(&self) -> u64 { + self.image.key() + } + + #[inline] + fn try_gpu_lock(&self, exclusive_access: bool, expected_layout: ImageLayout) + -> Result<(), AccessError> { + if expected_layout != self.layout && expected_layout != ImageLayout::Undefined { + return Err(AccessError::UnexpectedImageLayout { + requested: expected_layout, + allowed: self.layout, + }); + } + + if exclusive_access { + return Err(AccessError::ExclusiveDenied); + } + + if !self.initialized.load(Ordering::Relaxed) { + return Err(AccessError::BufferNotInitialized); + } + + Ok(()) + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + } + + #[inline] + unsafe fn unlock(&self, new_layout: Option<ImageLayout>) { + debug_assert!(new_layout.is_none()); + } +} + +unsafe impl<P, F, A> ImageContent<P> for ImmutableImage<F, A> + where F: 'static + Send + Sync +{ + #[inline] + fn matches_format(&self) -> bool { + true // FIXME: + } +} + +unsafe impl<F: 'static, A> ImageViewAccess for ImmutableImage<F, A> + where F: 'static + Send + Sync +{ + #[inline] + fn parent(&self) -> &ImageAccess { + self + } + + #[inline] + fn dimensions(&self) -> Dimensions { + self.dimensions + } + + #[inline] + fn inner(&self) -> &UnsafeImageView { + &self.view + } + + #[inline] + fn descriptor_set_storage_image_layout(&self) -> ImageLayout { + self.layout + } + + #[inline] + fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout { + self.layout + } + + #[inline] + fn descriptor_set_sampled_image_layout(&self) -> ImageLayout { + self.layout + } + + #[inline] + fn descriptor_set_input_attachment_layout(&self) -> ImageLayout { + self.layout + } + + #[inline] + fn identity_swizzle(&self) -> bool { + true + } +} + +unsafe impl<F, A> ImageAccess for ImmutableImageInitialization<F, A> + where F: 'static + Send + Sync +{ + #[inline] + fn inner(&self) -> ImageInner { + ImageAccess::inner(&self.image) + } + + #[inline] + fn initial_layout_requirement(&self) -> ImageLayout { + ImageLayout::Undefined + } + + #[inline] + fn final_layout_requirement(&self) -> ImageLayout { + self.image.layout + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + false + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + self.conflict_key() == other.conflict_key() // TODO: + } + + #[inline] + fn conflict_key(&self) -> u64 { + self.image.image.key() + } + + #[inline] + fn try_gpu_lock(&self, _: bool, expected_layout: ImageLayout) -> Result<(), AccessError> { + if expected_layout != ImageLayout::Undefined { + return Err(AccessError::UnexpectedImageLayout { + requested: expected_layout, + allowed: ImageLayout::Undefined, + }); + } + + if self.image.initialized.load(Ordering::Relaxed) { + return Err(AccessError::AlreadyInUse); + } + + // FIXME: Mipmapped textures require multiple writes to initialize + if !self.used.compare_and_swap(false, true, Ordering::Relaxed) { + Ok(()) + } else { + Err(AccessError::AlreadyInUse) + } + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + debug_assert!(self.used.load(Ordering::Relaxed)); + } + + #[inline] + unsafe fn unlock(&self, new_layout: Option<ImageLayout>) { + assert_eq!(new_layout, Some(self.image.layout)); + self.image.initialized.store(true, Ordering::Relaxed); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/image/layout.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/image/layout.rs new file mode 100644 index 0000000..4502f00 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/image/layout.rs @@ -0,0 +1,42 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use vk; + +/// Layout of an image. +/// +/// > **Note**: In vulkano, image layouts are mostly a low-level detail. You can ignore them, +/// > unless you use an unsafe function that states in its documentation that you must take care of +/// > an image's layout. +/// +/// In the Vulkan API, each mipmap level of each array layer is in one of the layouts of this enum. +/// +/// Unless you use some sort of high-level shortcut function, an image always starts in either +/// the `Undefined` or the `Preinitialized` layout. +/// Before you can use an image for a given purpose, you must ensure that the image in question is +/// in the layout required for that purpose. For example if you want to write data to an image, you +/// must first transition the image to the `TransferDstOptimal` layout. The `General` layout can +/// also be used as a general-purpose fit-all layout, but using it will result in slower operations. +/// +/// Transitioning between layouts can only be done through a GPU-side operation that is part of +/// a command buffer. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[repr(u32)] +pub enum ImageLayout { + Undefined = vk::IMAGE_LAYOUT_UNDEFINED, + General = vk::IMAGE_LAYOUT_GENERAL, + ColorAttachmentOptimal = vk::IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, + DepthStencilAttachmentOptimal = vk::IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, + DepthStencilReadOnlyOptimal = vk::IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL, + ShaderReadOnlyOptimal = vk::IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + TransferSrcOptimal = vk::IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + TransferDstOptimal = vk::IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + Preinitialized = vk::IMAGE_LAYOUT_PREINITIALIZED, + PresentSrc = vk::IMAGE_LAYOUT_PRESENT_SRC_KHR, +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/image/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/image/mod.rs new file mode 100644 index 0000000..c14f056 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/image/mod.rs @@ -0,0 +1,634 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Image storage (1D, 2D, 3D, arrays, etc.). +//! +//! An *image* is a region of memory whose purpose is to store multi-dimensional data. Its +//! most common use is to store a 2D array of color pixels (in other words an *image* in +//! everyday language), but it can also be used to store arbitrary data. +//! +//! The advantage of using an image compared to a buffer is that the memory layout is optimized +//! for locality. When reading a specific pixel of an image, reading the nearby pixels is really +//! fast. Most implementations have hardware dedicated to reading from images if you access them +//! through a sampler. +//! +//! # Properties of an image +//! +//! # Images and image views +//! +//! There is a distinction between *images* and *image views*. As its name suggests, an image +//! view describes how the GPU must interpret the image. +//! +//! Transfer and memory operations operate on images themselves, while reading/writing an image +//! operates on image views. You can create multiple image views from the same image. +//! +//! # High-level wrappers +//! +//! In the vulkano library, an image is any object that implements the `Image` trait and an image +//! view is any object that implements the `ImageView` trait. +//! +//! Since these traits are low-level, you are encouraged to not implement them yourself but instead +//! use one of the provided implementations that are specialized depending on the way you are going +//! to use the image: +//! +//! - An `AttachmentImage` can be used when you want to draw to an image. +//! - An `ImmutableImage` stores data which never need be changed after the initial upload, +//! like a texture. +//! +//! # Low-level information +//! +//! To be written. +//! + +use std::cmp; + +pub use self::attachment::AttachmentImage; +pub use self::immutable::ImmutableImage; +pub use self::layout::ImageLayout; +pub use self::storage::StorageImage; +pub use self::swapchain::SwapchainImage; +pub use self::sys::ImageCreationError; +pub use self::traits::ImageAccess; +pub use self::traits::ImageInner; +pub use self::traits::ImageViewAccess; +pub use self::usage::ImageUsage; + +pub mod attachment; // TODO: make private +pub mod immutable; // TODO: make private +mod layout; +mod storage; +pub mod swapchain; // TODO: make private +pub mod sys; +pub mod traits; +mod usage; + +/// Specifies how many mipmaps must be allocated. +/// +/// Note that at least one mipmap must be allocated, to store the main level of the image. +#[derive(Debug, Copy, Clone)] +pub enum MipmapsCount { + /// Allocates the number of mipmaps required to store all the mipmaps of the image where each + /// mipmap is half the dimensions of the previous level. Guaranteed to be always supported. + /// + /// Note that this is not necessarily the maximum number of mipmaps, as the Vulkan + /// implementation may report that it supports a greater value. + Log2, + + /// Allocate one mipmap (ie. just the main level). Always supported. + One, + + /// Allocate the given number of mipmaps. May result in an error if the value is out of range + /// of what the implementation supports. + Specific(u32), +} + +impl From<u32> for MipmapsCount { + #[inline] + fn from(num: u32) -> MipmapsCount { + MipmapsCount::Specific(num) + } +} + +/// Specifies how the components of an image must be swizzled. +/// +/// When creating an image view, it is possible to ask the implementation to modify the value +/// returned when accessing a given component from within a shader. +/// +/// If all the members are `Identity`, then the view is said to have identity swizzling. This is +/// what the `Default` trait implementation of this struct returns. +/// Views that don't have identity swizzling may not be supported for some operations. For example +/// attaching a view to a framebuffer is only possible if the view is identity-swizzled. +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] +pub struct Swizzle { + /// First component. + pub r: ComponentSwizzle, + /// Second component. + pub g: ComponentSwizzle, + /// Third component. + pub b: ComponentSwizzle, + /// Fourth component. + pub a: ComponentSwizzle, +} + +/// Describes the value that an individual component must return when being accessed. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum ComponentSwizzle { + /// Returns the value that this component should normally have. + Identity, + /// Always return zero. + Zero, + /// Always return one. + One, + /// Returns the value of the first component. + Red, + /// Returns the value of the second component. + Green, + /// Returns the value of the third component. + Blue, + /// Returns the value of the fourth component. + Alpha, +} + +impl Default for ComponentSwizzle { + #[inline] + fn default() -> ComponentSwizzle { + ComponentSwizzle::Identity + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum Dimensions { + Dim1d { width: u32 }, + Dim1dArray { width: u32, array_layers: u32 }, + Dim2d { width: u32, height: u32 }, + Dim2dArray { + width: u32, + height: u32, + array_layers: u32, + }, + Dim3d { width: u32, height: u32, depth: u32 }, + Cubemap { size: u32 }, + CubemapArray { size: u32, array_layers: u32 }, +} + +impl Dimensions { + #[inline] + pub fn width(&self) -> u32 { + match *self { + Dimensions::Dim1d { width } => width, + Dimensions::Dim1dArray { width, .. } => width, + Dimensions::Dim2d { width, .. } => width, + Dimensions::Dim2dArray { width, .. } => width, + Dimensions::Dim3d { width, .. } => width, + Dimensions::Cubemap { size } => size, + Dimensions::CubemapArray { size, .. } => size, + } + } + + #[inline] + pub fn height(&self) -> u32 { + match *self { + Dimensions::Dim1d { .. } => 1, + Dimensions::Dim1dArray { .. } => 1, + Dimensions::Dim2d { height, .. } => height, + Dimensions::Dim2dArray { height, .. } => height, + Dimensions::Dim3d { height, .. } => height, + Dimensions::Cubemap { size } => size, + Dimensions::CubemapArray { size, .. } => size, + } + } + + #[inline] + pub fn width_height(&self) -> [u32; 2] { + [self.width(), self.height()] + } + + #[inline] + pub fn depth(&self) -> u32 { + match *self { + Dimensions::Dim1d { .. } => 1, + Dimensions::Dim1dArray { .. } => 1, + Dimensions::Dim2d { .. } => 1, + Dimensions::Dim2dArray { .. } => 1, + Dimensions::Dim3d { depth, .. } => depth, + Dimensions::Cubemap { .. } => 1, + Dimensions::CubemapArray { .. } => 1, + } + } + + #[inline] + pub fn width_height_depth(&self) -> [u32; 3] { + [self.width(), self.height(), self.depth()] + } + + #[inline] + pub fn array_layers(&self) -> u32 { + match *self { + Dimensions::Dim1d { .. } => 1, + Dimensions::Dim1dArray { array_layers, .. } => array_layers, + Dimensions::Dim2d { .. } => 1, + Dimensions::Dim2dArray { array_layers, .. } => array_layers, + Dimensions::Dim3d { .. } => 1, + Dimensions::Cubemap { .. } => 1, + Dimensions::CubemapArray { array_layers, .. } => array_layers, + } + } + + #[inline] + pub fn array_layers_with_cube(&self) -> u32 { + match *self { + Dimensions::Dim1d { .. } => 1, + Dimensions::Dim1dArray { array_layers, .. } => array_layers, + Dimensions::Dim2d { .. } => 1, + Dimensions::Dim2dArray { array_layers, .. } => array_layers, + Dimensions::Dim3d { .. } => 1, + Dimensions::Cubemap { .. } => 6, + Dimensions::CubemapArray { array_layers, .. } => array_layers * 6, + } + } + + /// Builds the corresponding `ImageDimensions`. + #[inline] + pub fn to_image_dimensions(&self) -> ImageDimensions { + match *self { + Dimensions::Dim1d { width } => { + ImageDimensions::Dim1d { + width: width, + array_layers: 1, + } + }, + Dimensions::Dim1dArray { + width, + array_layers, + } => { + ImageDimensions::Dim1d { + width: width, + array_layers: array_layers, + } + }, + Dimensions::Dim2d { width, height } => { + ImageDimensions::Dim2d { + width: width, + height: height, + array_layers: 1, + cubemap_compatible: false, + } + }, + Dimensions::Dim2dArray { + width, + height, + array_layers, + } => { + ImageDimensions::Dim2d { + width: width, + height: height, + array_layers: array_layers, + cubemap_compatible: false, + } + }, + Dimensions::Dim3d { + width, + height, + depth, + } => { + ImageDimensions::Dim3d { + width: width, + height: height, + depth: depth, + } + }, + Dimensions::Cubemap { size } => { + ImageDimensions::Dim2d { + width: size, + height: size, + array_layers: 6, + cubemap_compatible: true, + } + }, + Dimensions::CubemapArray { size, array_layers } => { + ImageDimensions::Dim2d { + width: size, + height: size, + array_layers: array_layers * 6, + cubemap_compatible: true, + } + }, + } + } + + /// Builds the corresponding `ViewType`. + #[inline] + pub fn to_view_type(&self) -> ViewType { + match *self { + Dimensions::Dim1d { .. } => ViewType::Dim1d, + Dimensions::Dim1dArray { .. } => ViewType::Dim1dArray, + Dimensions::Dim2d { .. } => ViewType::Dim2d, + Dimensions::Dim2dArray { .. } => ViewType::Dim2dArray, + Dimensions::Dim3d { .. } => ViewType::Dim3d, + Dimensions::Cubemap { .. } => ViewType::Cubemap, + Dimensions::CubemapArray { .. } => ViewType::CubemapArray, + } + } + + /// Returns the total number of texels for an image of these dimensions. + #[inline] + pub fn num_texels(&self) -> u32 { + self.width() * self.height() * self.depth() * self.array_layers_with_cube() + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum ViewType { + Dim1d, + Dim1dArray, + Dim2d, + Dim2dArray, + Dim3d, + Cubemap, + CubemapArray, +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum ImageDimensions { + Dim1d { width: u32, array_layers: u32 }, + Dim2d { + width: u32, + height: u32, + array_layers: u32, + cubemap_compatible: bool, + }, + Dim3d { width: u32, height: u32, depth: u32 }, +} + +impl ImageDimensions { + #[inline] + pub fn width(&self) -> u32 { + match *self { + ImageDimensions::Dim1d { width, .. } => width, + ImageDimensions::Dim2d { width, .. } => width, + ImageDimensions::Dim3d { width, .. } => width, + } + } + + #[inline] + pub fn height(&self) -> u32 { + match *self { + ImageDimensions::Dim1d { .. } => 1, + ImageDimensions::Dim2d { height, .. } => height, + ImageDimensions::Dim3d { height, .. } => height, + } + } + + #[inline] + pub fn width_height(&self) -> [u32; 2] { + [self.width(), self.height()] + } + + #[inline] + pub fn depth(&self) -> u32 { + match *self { + ImageDimensions::Dim1d { .. } => 1, + ImageDimensions::Dim2d { .. } => 1, + ImageDimensions::Dim3d { depth, .. } => depth, + } + } + + #[inline] + pub fn width_height_depth(&self) -> [u32; 3] { + [self.width(), self.height(), self.depth()] + } + + #[inline] + pub fn array_layers(&self) -> u32 { + match *self { + ImageDimensions::Dim1d { array_layers, .. } => array_layers, + ImageDimensions::Dim2d { array_layers, .. } => array_layers, + ImageDimensions::Dim3d { .. } => 1, + } + } + + /// Returns the total number of texels for an image of these dimensions. + #[inline] + pub fn num_texels(&self) -> u32 { + self.width() * self.height() * self.depth() * self.array_layers() + } + + /// Returns the maximum number of mipmaps for these image dimensions. + /// + /// The returned value is always at least superior or equal to 1. + /// + /// # Example + /// + /// ``` + /// use vulkano::image::ImageDimensions; + /// + /// let dims = ImageDimensions::Dim2d { + /// width: 32, + /// height: 50, + /// cubemap_compatible: false, + /// array_layers: 1, + /// }; + /// + /// assert_eq!(dims.max_mipmaps(), 7); + /// ``` + /// + /// # Panic + /// + /// May panic if the dimensions are 0. + /// + pub fn max_mipmaps(&self) -> u32 { + let max_dim = cmp::max(cmp::max(self.width(), self.height()), self.depth()); + let num_zeroes = 32 - (max_dim - 1).leading_zeros(); + num_zeroes + 1 + } + + /// Returns the dimensions of the `level`th mipmap level. If `level` is 0, then the dimensions + /// are left unchanged. + /// + /// Returns `None` if `level` is superior or equal to `max_mipmaps()`. + /// + /// # Example + /// + /// ``` + /// use vulkano::image::ImageDimensions; + /// + /// let dims = ImageDimensions::Dim2d { + /// width: 963, + /// height: 256, + /// cubemap_compatible: false, + /// array_layers: 1, + /// }; + /// + /// assert_eq!(dims.mipmap_dimensions(0), Some(dims)); + /// assert_eq!(dims.mipmap_dimensions(1), Some(ImageDimensions::Dim2d { + /// width: 512, + /// height: 128, + /// cubemap_compatible: false, + /// array_layers: 1, + /// })); + /// assert_eq!(dims.mipmap_dimensions(6), Some(ImageDimensions::Dim2d { + /// width: 16, + /// height: 4, + /// cubemap_compatible: false, + /// array_layers: 1, + /// })); + /// assert_eq!(dims.mipmap_dimensions(9), Some(ImageDimensions::Dim2d { + /// width: 2, + /// height: 1, + /// cubemap_compatible: false, + /// array_layers: 1, + /// })); + /// assert_eq!(dims.mipmap_dimensions(11), None); + /// ``` + /// + /// # Panic + /// + /// In debug mode, Panics if `width`, `height` or `depth` is equal to 0. In release, returns + /// an unspecified value. + /// + pub fn mipmap_dimensions(&self, level: u32) -> Option<ImageDimensions> { + if level == 0 { + return Some(*self); + } + + if level >= self.max_mipmaps() { + return None; + } + + Some(match *self { + ImageDimensions::Dim1d { + width, + array_layers, + } => { + debug_assert_ne!(width, 0); + ImageDimensions::Dim1d { + array_layers: array_layers, + width: (((width - 1) >> level) + 1).next_power_of_two(), + } + }, + + ImageDimensions::Dim2d { + width, + height, + array_layers, + cubemap_compatible, + } => { + debug_assert_ne!(width, 0); + debug_assert_ne!(height, 0); + ImageDimensions::Dim2d { + width: (((width - 1) >> level) + 1).next_power_of_two(), + height: (((height - 1) >> level) + 1).next_power_of_two(), + array_layers: array_layers, + cubemap_compatible: cubemap_compatible, + } + }, + + ImageDimensions::Dim3d { + width, + height, + depth, + } => { + debug_assert_ne!(width, 0); + debug_assert_ne!(height, 0); + ImageDimensions::Dim3d { + width: (((width - 1) >> level) + 1).next_power_of_two(), + height: (((height - 1) >> level) + 1).next_power_of_two(), + depth: (((depth - 1) >> level) + 1).next_power_of_two(), + } + }, + }) + } +} + +#[cfg(test)] +mod tests { + use image::ImageDimensions; + + #[test] + fn max_mipmaps() { + let dims = ImageDimensions::Dim2d { + width: 2, + height: 1, + cubemap_compatible: false, + array_layers: 1, + }; + assert_eq!(dims.max_mipmaps(), 2); + + let dims = ImageDimensions::Dim2d { + width: 2, + height: 3, + cubemap_compatible: false, + array_layers: 1, + }; + assert_eq!(dims.max_mipmaps(), 3); + + let dims = ImageDimensions::Dim2d { + width: 512, + height: 512, + cubemap_compatible: false, + array_layers: 1, + }; + assert_eq!(dims.max_mipmaps(), 10); + } + + #[test] + fn mipmap_dimensions() { + let dims = ImageDimensions::Dim2d { + width: 283, + height: 175, + cubemap_compatible: false, + array_layers: 1, + }; + assert_eq!(dims.mipmap_dimensions(0), Some(dims)); + assert_eq!(dims.mipmap_dimensions(1), + Some(ImageDimensions::Dim2d { + width: 256, + height: 128, + cubemap_compatible: false, + array_layers: 1, + })); + assert_eq!(dims.mipmap_dimensions(2), + Some(ImageDimensions::Dim2d { + width: 128, + height: 64, + cubemap_compatible: false, + array_layers: 1, + })); + assert_eq!(dims.mipmap_dimensions(3), + Some(ImageDimensions::Dim2d { + width: 64, + height: 32, + cubemap_compatible: false, + array_layers: 1, + })); + assert_eq!(dims.mipmap_dimensions(4), + Some(ImageDimensions::Dim2d { + width: 32, + height: 16, + cubemap_compatible: false, + array_layers: 1, + })); + assert_eq!(dims.mipmap_dimensions(5), + Some(ImageDimensions::Dim2d { + width: 16, + height: 8, + cubemap_compatible: false, + array_layers: 1, + })); + assert_eq!(dims.mipmap_dimensions(6), + Some(ImageDimensions::Dim2d { + width: 8, + height: 4, + cubemap_compatible: false, + array_layers: 1, + })); + assert_eq!(dims.mipmap_dimensions(7), + Some(ImageDimensions::Dim2d { + width: 4, + height: 2, + cubemap_compatible: false, + array_layers: 1, + })); + assert_eq!(dims.mipmap_dimensions(8), + Some(ImageDimensions::Dim2d { + width: 2, + height: 1, + cubemap_compatible: false, + array_layers: 1, + })); + assert_eq!(dims.mipmap_dimensions(9), + Some(ImageDimensions::Dim2d { + width: 1, + height: 1, + cubemap_compatible: false, + array_layers: 1, + })); + assert_eq!(dims.mipmap_dimensions(10), None); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/image/storage.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/image/storage.rs new file mode 100644 index 0000000..ef7aef3 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/image/storage.rs @@ -0,0 +1,329 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::sync::Arc; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; + +use buffer::BufferAccess; +use device::Device; +use format::ClearValue; +use format::FormatDesc; +use format::FormatTy; +use image::Dimensions; +use image::ImageInner; +use image::ImageLayout; +use image::ImageUsage; +use image::sys::ImageCreationError; +use image::sys::UnsafeImage; +use image::sys::UnsafeImageView; +use image::traits::ImageAccess; +use image::traits::ImageClearValue; +use image::traits::ImageContent; +use image::traits::ImageViewAccess; +use instance::QueueFamily; +use memory::DedicatedAlloc; +use memory::pool::AllocFromRequirementsFilter; +use memory::pool::AllocLayout; +use memory::pool::MappingRequirement; +use memory::pool::MemoryPool; +use memory::pool::MemoryPoolAlloc; +use memory::pool::PotentialDedicatedAllocation; +use memory::pool::StdMemoryPool; +use sync::AccessError; +use sync::Sharing; + +/// General-purpose image in device memory. Can be used for any usage, but will be slower than a +/// specialized image. +#[derive(Debug)] +pub struct StorageImage<F, A = Arc<StdMemoryPool>> + where A: MemoryPool +{ + // Inner implementation. + image: UnsafeImage, + + // We maintain a view of the whole image. + view: UnsafeImageView, + + // Memory used to back the image. + memory: PotentialDedicatedAllocation<A::Alloc>, + + // Dimensions of the image view. + dimensions: Dimensions, + + // Format. + format: F, + + // Queue families allowed to access this image. + queue_families: SmallVec<[u32; 4]>, + + // Number of times this image is locked on the GPU side. + gpu_lock: AtomicUsize, +} + +impl<F> StorageImage<F> { + /// Creates a new image with the given dimensions and format. + #[inline] + pub fn new<'a, I>(device: Arc<Device>, dimensions: Dimensions, format: F, queue_families: I) + -> Result<Arc<StorageImage<F>>, ImageCreationError> + where F: FormatDesc, + I: IntoIterator<Item = QueueFamily<'a>> + { + let is_depth = match format.format().ty() { + FormatTy::Depth => true, + FormatTy::DepthStencil => true, + FormatTy::Stencil => true, + FormatTy::Compressed => panic!(), + _ => false, + }; + + let usage = ImageUsage { + transfer_source: true, + transfer_destination: true, + sampled: true, + storage: true, + color_attachment: !is_depth, + depth_stencil_attachment: is_depth, + input_attachment: true, + transient_attachment: false, + }; + + StorageImage::with_usage(device, dimensions, format, usage, queue_families) + } + + /// Same as `new`, but allows specifying the usage. + pub fn with_usage<'a, I>(device: Arc<Device>, dimensions: Dimensions, format: F, + usage: ImageUsage, queue_families: I) + -> Result<Arc<StorageImage<F>>, ImageCreationError> + where F: FormatDesc, + I: IntoIterator<Item = QueueFamily<'a>> + { + let queue_families = queue_families + .into_iter() + .map(|f| f.id()) + .collect::<SmallVec<[u32; 4]>>(); + + let (image, mem_reqs) = unsafe { + let sharing = if queue_families.len() >= 2 { + Sharing::Concurrent(queue_families.iter().cloned()) + } else { + Sharing::Exclusive + }; + + UnsafeImage::new(device.clone(), + usage, + format.format(), + dimensions.to_image_dimensions(), + 1, + 1, + sharing, + false, + false)? + }; + + let mem = MemoryPool::alloc_from_requirements(&Device::standard_pool(&device), + &mem_reqs, + AllocLayout::Optimal, + MappingRequirement::DoNotMap, + DedicatedAlloc::Image(&image), + |t| if t.is_device_local() { + AllocFromRequirementsFilter::Preferred + } else { + AllocFromRequirementsFilter::Allowed + })?; + debug_assert!((mem.offset() % mem_reqs.alignment) == 0); + unsafe { + image.bind_memory(mem.memory(), mem.offset())?; + } + + let view = unsafe { + UnsafeImageView::raw(&image, + dimensions.to_view_type(), + 0 .. image.mipmap_levels(), + 0 .. image.dimensions().array_layers())? + }; + + Ok(Arc::new(StorageImage { + image: image, + view: view, + memory: mem, + dimensions: dimensions, + format: format, + queue_families: queue_families, + gpu_lock: AtomicUsize::new(0), + })) + } +} + +impl<F, A> StorageImage<F, A> + where A: MemoryPool +{ + /// Returns the dimensions of the image. + #[inline] + pub fn dimensions(&self) -> Dimensions { + self.dimensions + } +} + +unsafe impl<F, A> ImageAccess for StorageImage<F, A> + where F: 'static + Send + Sync, + A: MemoryPool +{ + #[inline] + fn inner(&self) -> ImageInner { + ImageInner { + image: &self.image, + first_layer: 0, + num_layers: self.dimensions.array_layers() as usize, + first_mipmap_level: 0, + num_mipmap_levels: 1, + } + } + + #[inline] + fn initial_layout_requirement(&self) -> ImageLayout { + ImageLayout::General + } + + #[inline] + fn final_layout_requirement(&self) -> ImageLayout { + ImageLayout::General + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + false + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + self.conflict_key() == other.conflict_key() // TODO: + } + + #[inline] + fn conflict_key(&self) -> u64 { + self.image.key() + } + + #[inline] + fn try_gpu_lock(&self, _: bool, expected_layout: ImageLayout) -> Result<(), AccessError> { + // TODO: handle initial layout transition + if expected_layout != ImageLayout::General && expected_layout != ImageLayout::Undefined { + return Err(AccessError::UnexpectedImageLayout { + requested: expected_layout, + allowed: ImageLayout::General, + }); + } + + let val = self.gpu_lock.compare_and_swap(0, 1, Ordering::SeqCst); + if val == 0 { + Ok(()) + } else { + Err(AccessError::AlreadyInUse) + } + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + let val = self.gpu_lock.fetch_add(1, Ordering::SeqCst); + debug_assert!(val >= 1); + } + + #[inline] + unsafe fn unlock(&self, new_layout: Option<ImageLayout>) { + assert!(new_layout.is_none() || new_layout == Some(ImageLayout::General)); + self.gpu_lock.fetch_sub(1, Ordering::SeqCst); + } +} + +unsafe impl<F, A> ImageClearValue<F::ClearValue> for StorageImage<F, A> + where F: FormatDesc + 'static + Send + Sync, + A: MemoryPool +{ + #[inline] + fn decode(&self, value: F::ClearValue) -> Option<ClearValue> { + Some(self.format.decode_clear_value(value)) + } +} + +unsafe impl<P, F, A> ImageContent<P> for StorageImage<F, A> + where F: 'static + Send + Sync, + A: MemoryPool +{ + #[inline] + fn matches_format(&self) -> bool { + true // FIXME: + } +} + +unsafe impl<F, A> ImageViewAccess for StorageImage<F, A> + where F: 'static + Send + Sync, + A: MemoryPool +{ + #[inline] + fn parent(&self) -> &ImageAccess { + self + } + + #[inline] + fn dimensions(&self) -> Dimensions { + self.dimensions + } + + #[inline] + fn inner(&self) -> &UnsafeImageView { + &self.view + } + + #[inline] + fn descriptor_set_storage_image_layout(&self) -> ImageLayout { + ImageLayout::General + } + + #[inline] + fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout { + ImageLayout::General + } + + #[inline] + fn descriptor_set_sampled_image_layout(&self) -> ImageLayout { + ImageLayout::General + } + + #[inline] + fn descriptor_set_input_attachment_layout(&self) -> ImageLayout { + ImageLayout::General + } + + #[inline] + fn identity_swizzle(&self) -> bool { + true + } +} + +#[cfg(test)] +mod tests { + use super::StorageImage; + use format::Format; + use image::Dimensions; + + #[test] + fn create() { + let (device, queue) = gfx_dev_and_queue!(); + let _img = StorageImage::new(device, + Dimensions::Dim2d { + width: 32, + height: 32, + }, + Format::R8G8B8A8Unorm, + Some(queue.family())) + .unwrap(); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/image/swapchain.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/image/swapchain.rs new file mode 100644 index 0000000..f3c6169 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/image/swapchain.rs @@ -0,0 +1,192 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::sync::Arc; + +use buffer::BufferAccess; +use format::ClearValue; +use format::Format; +use format::FormatDesc; +use image::Dimensions; +use image::ImageInner; +use image::ImageLayout; +use image::ViewType; +use image::sys::UnsafeImageView; +use image::traits::ImageAccess; +use image::traits::ImageClearValue; +use image::traits::ImageContent; +use image::traits::ImageViewAccess; +use swapchain::Swapchain; +use sync::AccessError; + +use OomError; + +/// An image that is part of a swapchain. +/// +/// Creating a `SwapchainImage` is automatically done when creating a swapchain. +/// +/// A swapchain image is special in the sense that it can only be used after being acquired by +/// calling the `acquire` method on the swapchain. You have no way to know in advance which +/// swapchain image is going to be acquired, so you should keep all of them alive. +/// +/// After a swapchain image has been acquired, you are free to perform all the usual operations +/// on it. When you are done you can then *present* the image (by calling the corresponding +/// method on the swapchain), which will have the effect of showing the content of the image to +/// the screen. Once an image has been presented, it can no longer be used unless it is acquired +/// again. +// TODO: #[derive(Debug)] +pub struct SwapchainImage<W> { + swapchain: Arc<Swapchain<W>>, + image_offset: usize, + view: UnsafeImageView, +} + +impl<W> SwapchainImage<W> { + /// Builds a `SwapchainImage` from raw components. + /// + /// This is an internal method that you shouldn't call. + pub unsafe fn from_raw(swapchain: Arc<Swapchain<W>>, id: usize) + -> Result<Arc<SwapchainImage<W>>, OomError> { + let image = swapchain.raw_image(id).unwrap(); + let view = UnsafeImageView::raw(&image.image, ViewType::Dim2d, 0 .. 1, 0 .. 1)?; + + Ok(Arc::new(SwapchainImage { + swapchain: swapchain.clone(), + image_offset: id, + view: view, + })) + } + + /// Returns the dimensions of the image. + /// + /// A `SwapchainImage` is always two-dimensional. + #[inline] + pub fn dimensions(&self) -> [u32; 2] { + let dims = self.my_image().image.dimensions(); + [dims.width(), dims.height()] + } + + /// Returns the swapchain this image belongs to. + #[inline] + pub fn swapchain(&self) -> &Arc<Swapchain<W>> { + &self.swapchain + } + + #[inline] + fn my_image(&self) -> ImageInner { + self.swapchain.raw_image(self.image_offset).unwrap() + } +} + +unsafe impl<W> ImageAccess for SwapchainImage<W> { + #[inline] + fn inner(&self) -> ImageInner { + self.my_image() + } + + #[inline] + fn initial_layout_requirement(&self) -> ImageLayout { + ImageLayout::PresentSrc + } + + #[inline] + fn final_layout_requirement(&self) -> ImageLayout { + ImageLayout::PresentSrc + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + false + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + self.my_image().image.key() == other.conflict_key() // TODO: + } + + #[inline] + fn conflict_key(&self) -> u64 { + self.my_image().image.key() + } + + #[inline] + fn try_gpu_lock(&self, _: bool, _: ImageLayout) -> Result<(), AccessError> { + // Swapchain image are only accessible after being acquired. + Err(AccessError::SwapchainImageAcquireOnly) + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + } + + #[inline] + unsafe fn unlock(&self, _: Option<ImageLayout>) { + // TODO: store that the image was initialized + } +} + +unsafe impl<W> ImageClearValue<<Format as FormatDesc>::ClearValue> for SwapchainImage<W> { + #[inline] + fn decode(&self, value: <Format as FormatDesc>::ClearValue) -> Option<ClearValue> { + Some(self.swapchain.format().decode_clear_value(value)) + } +} + +unsafe impl<P,W> ImageContent<P> for SwapchainImage<W> { + #[inline] + fn matches_format(&self) -> bool { + true // FIXME: + } +} + +unsafe impl<W> ImageViewAccess for SwapchainImage<W> { + #[inline] + fn parent(&self) -> &ImageAccess { + self + } + + #[inline] + fn dimensions(&self) -> Dimensions { + let dims = self.swapchain.dimensions(); + Dimensions::Dim2d { + width: dims[0], + height: dims[1], + } + } + + #[inline] + fn inner(&self) -> &UnsafeImageView { + &self.view + } + + #[inline] + fn descriptor_set_storage_image_layout(&self) -> ImageLayout { + ImageLayout::ShaderReadOnlyOptimal + } + + #[inline] + fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout { + ImageLayout::ShaderReadOnlyOptimal + } + + #[inline] + fn descriptor_set_sampled_image_layout(&self) -> ImageLayout { + ImageLayout::ShaderReadOnlyOptimal + } + + #[inline] + fn descriptor_set_input_attachment_layout(&self) -> ImageLayout { + ImageLayout::ShaderReadOnlyOptimal + } + + #[inline] + fn identity_swizzle(&self) -> bool { + true + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/image/sys.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/image/sys.rs new file mode 100644 index 0000000..b675c34 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/image/sys.rs @@ -0,0 +1,1444 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Low-level implementation of images and images views. +//! +//! This module contains low-level wrappers around the Vulkan image and image view types. All +//! other image or image view types of this library, and all custom image or image view types +//! that you create must wrap around the types in this module. + +use smallvec::SmallVec; +use std::error; +use std::fmt; +use std::mem; +use std::ops::Range; +use std::ptr; +use std::sync::Arc; + +use device::Device; +use format::Format; +use format::FormatTy; +use image::ImageDimensions; +use image::ImageUsage; +use image::MipmapsCount; +use image::ViewType; +use memory::DeviceMemory; +use memory::DeviceMemoryAllocError; +use memory::MemoryRequirements; +use sync::Sharing; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use vk; + +/// A storage for pixels or arbitrary data. +/// +/// # Safety +/// +/// This type is not just unsafe but very unsafe. Don't use it directly. +/// +/// - You must manually bind memory to the image with `bind_memory`. The memory must respect the +/// requirements returned by `new`. +/// - The memory that you bind to the image must be manually kept alive. +/// - The queue family ownership must be manually enforced. +/// - The usage must be manually enforced. +/// - The image layout must be manually enforced and transitioned. +/// +pub struct UnsafeImage { + image: vk::Image, + device: Arc<Device>, + usage: vk::ImageUsageFlagBits, + format: Format, + + dimensions: ImageDimensions, + samples: u32, + mipmaps: u32, + + // Features that are supported for this particular format. + format_features: vk::FormatFeatureFlagBits, + + // `vkDestroyImage` is called only if `needs_destruction` is true. + needs_destruction: bool, +} + +impl UnsafeImage { + /// Creates a new image and allocates memory for it. + /// + /// # Panic + /// + /// - Panics if one of the dimensions is 0. + /// - Panics if the number of mipmaps is 0. + /// - Panics if the number of samples is 0. + /// + #[inline] + pub unsafe fn new<'a, Mi, I>(device: Arc<Device>, usage: ImageUsage, format: Format, + dimensions: ImageDimensions, num_samples: u32, mipmaps: Mi, + sharing: Sharing<I>, linear_tiling: bool, + preinitialized_layout: bool) + -> Result<(UnsafeImage, MemoryRequirements), ImageCreationError> + where Mi: Into<MipmapsCount>, + I: Iterator<Item = u32> + { + let sharing = match sharing { + Sharing::Exclusive => (vk::SHARING_MODE_EXCLUSIVE, SmallVec::<[u32; 8]>::new()), + Sharing::Concurrent(ids) => (vk::SHARING_MODE_CONCURRENT, ids.collect()), + }; + + UnsafeImage::new_impl(device, + usage, + format, + dimensions, + num_samples, + mipmaps.into(), + sharing, + linear_tiling, + preinitialized_layout) + } + + // Non-templated version to avoid inlining and improve compile times. + unsafe fn new_impl(device: Arc<Device>, usage: ImageUsage, format: Format, + dimensions: ImageDimensions, num_samples: u32, mipmaps: MipmapsCount, + (sh_mode, sh_indices): (vk::SharingMode, SmallVec<[u32; 8]>), + linear_tiling: bool, preinitialized_layout: bool) + -> Result<(UnsafeImage, MemoryRequirements), ImageCreationError> { + // TODO: doesn't check that the proper features are enabled + + let vk = device.pointers(); + let vk_i = device.instance().pointers(); + + // Checking if image usage conforms to what is supported. + let format_features = { + let physical_device = device.physical_device().internal_object(); + + let mut output = mem::uninitialized(); + vk_i.GetPhysicalDeviceFormatProperties(physical_device, format as u32, &mut output); + + let features = if linear_tiling { + output.linearTilingFeatures + } else { + output.optimalTilingFeatures + }; + + if features == 0 { + return Err(ImageCreationError::FormatNotSupported); + } + + if usage.sampled && (features & vk::FORMAT_FEATURE_SAMPLED_IMAGE_BIT == 0) { + return Err(ImageCreationError::UnsupportedUsage); + } + if usage.storage && (features & vk::FORMAT_FEATURE_STORAGE_IMAGE_BIT == 0) { + return Err(ImageCreationError::UnsupportedUsage); + } + if usage.color_attachment && (features & vk::FORMAT_FEATURE_COLOR_ATTACHMENT_BIT == 0) { + return Err(ImageCreationError::UnsupportedUsage); + } + if usage.depth_stencil_attachment && + (features & vk::FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT == 0) + { + return Err(ImageCreationError::UnsupportedUsage); + } + if usage.input_attachment && + (features & + (vk::FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | + vk::FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) + { + return Err(ImageCreationError::UnsupportedUsage); + } + if device.loaded_extensions().khr_maintenance1 { + if usage.transfer_source && + (features & vk::FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR == 0) + { + return Err(ImageCreationError::UnsupportedUsage); + } + if usage.transfer_destination && + (features & vk::FORMAT_FEATURE_TRANSFER_DST_BIT_KHR == 0) + { + return Err(ImageCreationError::UnsupportedUsage); + } + } + + features + }; + + // If `transient_attachment` is true, then only `color_attachment`, + // `depth_stencil_attachment` and `input_attachment` can be true as well. + if usage.transient_attachment { + let u = ImageUsage { + transient_attachment: false, + color_attachment: false, + depth_stencil_attachment: false, + input_attachment: false, + ..usage.clone() + }; + + if u != ImageUsage::none() { + return Err(ImageCreationError::UnsupportedUsage); + } + } + + // This function is going to perform various checks and write to `capabilities_error` in + // case of error. + // + // If `capabilities_error` is not `None` after the checks are finished, the function will + // check for additional image capabilities (section 31.4 of the specs). + let mut capabilities_error = None; + + // Compute the number of mipmaps. + let mipmaps = match mipmaps.into() { + MipmapsCount::Specific(num) => { + let max_mipmaps = dimensions.max_mipmaps(); + debug_assert!(max_mipmaps >= 1); + if num < 1 { + return Err(ImageCreationError::InvalidMipmapsCount { + obtained: num, + valid_range: 1 .. max_mipmaps + 1, + }); + } else if num > max_mipmaps { + capabilities_error = Some(ImageCreationError::InvalidMipmapsCount { + obtained: num, + valid_range: 1 .. max_mipmaps + 1, + }); + } + + num + }, + MipmapsCount::Log2 => dimensions.max_mipmaps(), + MipmapsCount::One => 1, + }; + + // Checking whether the number of samples is supported. + if num_samples == 0 { + return Err(ImageCreationError::UnsupportedSamplesCount { obtained: num_samples }); + + } else if !num_samples.is_power_of_two() { + return Err(ImageCreationError::UnsupportedSamplesCount { obtained: num_samples }); + + } else { + let mut supported_samples = 0x7f; // all bits up to VK_SAMPLE_COUNT_64_BIT + + if usage.sampled { + match format.ty() { + FormatTy::Float | FormatTy::Compressed => { + supported_samples &= device + .physical_device() + .limits() + .sampled_image_color_sample_counts(); + }, + FormatTy::Uint | FormatTy::Sint => { + supported_samples &= device + .physical_device() + .limits() + .sampled_image_integer_sample_counts(); + }, + FormatTy::Depth => { + supported_samples &= device + .physical_device() + .limits() + .sampled_image_depth_sample_counts(); + }, + FormatTy::Stencil => { + supported_samples &= device + .physical_device() + .limits() + .sampled_image_stencil_sample_counts(); + }, + FormatTy::DepthStencil => { + supported_samples &= device + .physical_device() + .limits() + .sampled_image_depth_sample_counts(); + supported_samples &= device + .physical_device() + .limits() + .sampled_image_stencil_sample_counts(); + }, + } + } + + if usage.storage { + supported_samples &= device + .physical_device() + .limits() + .storage_image_sample_counts(); + } + + if usage.color_attachment || usage.depth_stencil_attachment || + usage.input_attachment || usage.transient_attachment + { + match format.ty() { + FormatTy::Float | FormatTy::Compressed | FormatTy::Uint | FormatTy::Sint => { + supported_samples &= device + .physical_device() + .limits() + .framebuffer_color_sample_counts(); + }, + FormatTy::Depth => { + supported_samples &= device + .physical_device() + .limits() + .framebuffer_depth_sample_counts(); + }, + FormatTy::Stencil => { + supported_samples &= device + .physical_device() + .limits() + .framebuffer_stencil_sample_counts(); + }, + FormatTy::DepthStencil => { + supported_samples &= device + .physical_device() + .limits() + .framebuffer_depth_sample_counts(); + supported_samples &= device + .physical_device() + .limits() + .framebuffer_stencil_sample_counts(); + }, + } + } + + if (num_samples & supported_samples) == 0 { + let err = ImageCreationError::UnsupportedSamplesCount { obtained: num_samples }; + capabilities_error = Some(err); + } + } + + // If the `shaderStorageImageMultisample` feature is not enabled and we have + // `usage_storage` set to true, then the number of samples must be 1. + if usage.storage && num_samples > 1 { + if !device.enabled_features().shader_storage_image_multisample { + return Err(ImageCreationError::ShaderStorageImageMultisampleFeatureNotEnabled); + } + } + + // Decoding the dimensions. + let (ty, extent, array_layers, flags) = match dimensions { + ImageDimensions::Dim1d { + width, + array_layers, + } => { + if width == 0 || array_layers == 0 { + return Err(ImageCreationError::UnsupportedDimensions { + dimensions: dimensions, + }); + } + let extent = vk::Extent3D { + width: width, + height: 1, + depth: 1, + }; + (vk::IMAGE_TYPE_1D, extent, array_layers, 0) + }, + ImageDimensions::Dim2d { + width, + height, + array_layers, + cubemap_compatible, + } => { + if width == 0 || height == 0 || array_layers == 0 { + return Err(ImageCreationError::UnsupportedDimensions { + dimensions: dimensions, + }); + } + if cubemap_compatible && width != height { + return Err(ImageCreationError::UnsupportedDimensions { + dimensions: dimensions, + }); + } + let extent = vk::Extent3D { + width: width, + height: height, + depth: 1, + }; + let flags = if cubemap_compatible { + vk::IMAGE_CREATE_CUBE_COMPATIBLE_BIT + } else { + 0 + }; + (vk::IMAGE_TYPE_2D, extent, array_layers, flags) + }, + ImageDimensions::Dim3d { + width, + height, + depth, + } => { + if width == 0 || height == 0 || depth == 0 { + return Err(ImageCreationError::UnsupportedDimensions { + dimensions: dimensions, + }); + } + let extent = vk::Extent3D { + width: width, + height: height, + depth: depth, + }; + (vk::IMAGE_TYPE_3D, extent, 1, 0) + }, + }; + + // Checking the dimensions against the limits. + if array_layers > device.physical_device().limits().max_image_array_layers() { + let err = ImageCreationError::UnsupportedDimensions { dimensions: dimensions }; + capabilities_error = Some(err); + } + match ty { + vk::IMAGE_TYPE_1D => { + if extent.width > device.physical_device().limits().max_image_dimension_1d() { + let err = ImageCreationError::UnsupportedDimensions { dimensions: dimensions }; + capabilities_error = Some(err); + } + }, + vk::IMAGE_TYPE_2D => { + let limit = device.physical_device().limits().max_image_dimension_2d(); + if extent.width > limit || extent.height > limit { + let err = ImageCreationError::UnsupportedDimensions { dimensions: dimensions }; + capabilities_error = Some(err); + } + + if (flags & vk::IMAGE_CREATE_CUBE_COMPATIBLE_BIT) != 0 { + let limit = device.physical_device().limits().max_image_dimension_cube(); + debug_assert_eq!(extent.width, extent.height); // checked above + if extent.width > limit { + let err = + ImageCreationError::UnsupportedDimensions { dimensions: dimensions }; + capabilities_error = Some(err); + } + } + }, + vk::IMAGE_TYPE_3D => { + let limit = device.physical_device().limits().max_image_dimension_3d(); + if extent.width > limit || extent.height > limit || extent.depth > limit { + let err = ImageCreationError::UnsupportedDimensions { dimensions: dimensions }; + capabilities_error = Some(err); + } + }, + _ => unreachable!(), + }; + + let usage = usage.to_usage_bits(); + + // Now that all checks have been performed, if any of the check failed we query the Vulkan + // implementation for additional image capabilities. + if let Some(capabilities_error) = capabilities_error { + let tiling = if linear_tiling { + vk::IMAGE_TILING_LINEAR + } else { + vk::IMAGE_TILING_OPTIMAL + }; + + let mut output = mem::uninitialized(); + let physical_device = device.physical_device().internal_object(); + let r = vk_i.GetPhysicalDeviceImageFormatProperties(physical_device, + format as u32, + ty, + tiling, + usage, + 0, /* TODO */ + &mut output); + + match check_errors(r) { + Ok(_) => (), + Err(Error::FormatNotSupported) => + return Err(ImageCreationError::FormatNotSupported), + Err(err) => return Err(err.into()), + } + + if extent.width > output.maxExtent.width || extent.height > output.maxExtent.height || + extent.depth > output.maxExtent.depth || + mipmaps > output.maxMipLevels || + array_layers > output.maxArrayLayers || + (num_samples & output.sampleCounts) == 0 + { + return Err(capabilities_error); + } + } + + // Everything now ok. Creating the image. + let image = { + let infos = vk::ImageCreateInfo { + sType: vk::STRUCTURE_TYPE_IMAGE_CREATE_INFO, + pNext: ptr::null(), + flags: flags, + imageType: ty, + format: format as u32, + extent: extent, + mipLevels: mipmaps, + arrayLayers: array_layers, + samples: num_samples, + tiling: if linear_tiling { + vk::IMAGE_TILING_LINEAR + } else { + vk::IMAGE_TILING_OPTIMAL + }, + usage: usage, + sharingMode: sh_mode, + queueFamilyIndexCount: sh_indices.len() as u32, + pQueueFamilyIndices: sh_indices.as_ptr(), + initialLayout: if preinitialized_layout { + vk::IMAGE_LAYOUT_PREINITIALIZED + } else { + vk::IMAGE_LAYOUT_UNDEFINED + }, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateImage(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + let mem_reqs = if device.loaded_extensions().khr_get_memory_requirements2 { + let infos = vk::ImageMemoryRequirementsInfo2KHR { + sType: vk::STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR, + pNext: ptr::null_mut(), + image: image, + }; + + let mut output2 = if device.loaded_extensions().khr_dedicated_allocation { + Some(vk::MemoryDedicatedRequirementsKHR { + sType: vk::STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR, + pNext: ptr::null(), + prefersDedicatedAllocation: mem::uninitialized(), + requiresDedicatedAllocation: mem::uninitialized(), + }) + } else { + None + }; + + let mut output = vk::MemoryRequirements2KHR { + sType: vk::STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR, + pNext: output2 + .as_mut() + .map(|o| o as *mut vk::MemoryDedicatedRequirementsKHR) + .unwrap_or(ptr::null_mut()) as *mut _, + memoryRequirements: mem::uninitialized(), + }; + + vk.GetImageMemoryRequirements2KHR(device.internal_object(), &infos, &mut output); + debug_assert!(output.memoryRequirements.memoryTypeBits != 0); + + let mut out = MemoryRequirements::from_vulkan_reqs(output.memoryRequirements); + if let Some(output2) = output2 { + debug_assert_eq!(output2.requiresDedicatedAllocation, 0); + out.prefer_dedicated = output2.prefersDedicatedAllocation != 0; + } + out + + } else { + let mut output: vk::MemoryRequirements = mem::uninitialized(); + vk.GetImageMemoryRequirements(device.internal_object(), image, &mut output); + debug_assert!(output.memoryTypeBits != 0); + MemoryRequirements::from_vulkan_reqs(output) + }; + + let image = UnsafeImage { + device: device.clone(), + image: image, + usage: usage, + format: format, + dimensions: dimensions, + samples: num_samples, + mipmaps: mipmaps, + format_features: format_features, + needs_destruction: true, + }; + + Ok((image, mem_reqs)) + } + + /// Creates an image from a raw handle. The image won't be destroyed. + /// + /// This function is for example used at the swapchain's initialization. + pub unsafe fn from_raw(device: Arc<Device>, handle: u64, usage: u32, format: Format, + dimensions: ImageDimensions, samples: u32, mipmaps: u32) + -> UnsafeImage { + let vk_i = device.instance().pointers(); + let physical_device = device.physical_device().internal_object(); + + let mut output = mem::uninitialized(); + vk_i.GetPhysicalDeviceFormatProperties(physical_device, format as u32, &mut output); + + // TODO: check that usage is correct in regard to `output`? + + UnsafeImage { + device: device.clone(), + image: handle, + usage: usage, + format: format, + dimensions: dimensions, + samples: samples, + mipmaps: mipmaps, + format_features: output.optimalTilingFeatures, + needs_destruction: false, // TODO: pass as parameter + } + } + + pub unsafe fn bind_memory(&self, memory: &DeviceMemory, offset: usize) -> Result<(), OomError> { + let vk = self.device.pointers(); + + // We check for correctness in debug mode. + debug_assert!({ + let mut mem_reqs = mem::uninitialized(); + vk.GetImageMemoryRequirements(self.device.internal_object(), + self.image, + &mut mem_reqs); + mem_reqs.size <= (memory.size() - offset) as u64 && + (offset as u64 % mem_reqs.alignment) == 0 && + mem_reqs.memoryTypeBits & (1 << memory.memory_type().id()) != 0 + }); + + check_errors(vk.BindImageMemory(self.device.internal_object(), + self.image, + memory.internal_object(), + offset as vk::DeviceSize))?; + Ok(()) + } + + #[inline] + pub fn device(&self) -> &Arc<Device> { + &self.device + } + + #[inline] + pub fn format(&self) -> Format { + self.format + } + + #[inline] + pub fn mipmap_levels(&self) -> u32 { + self.mipmaps + } + + #[inline] + pub fn dimensions(&self) -> ImageDimensions { + self.dimensions + } + + #[inline] + pub fn samples(&self) -> u32 { + self.samples + } + + /// Returns a key unique to each `UnsafeImage`. Can be used for the `conflicts_key` method. + #[inline] + pub fn key(&self) -> u64 { + self.image + } + + /// Queries the layout of an image in memory. Only valid for images with linear tiling. + /// + /// This function is only valid for images with a color format. See the other similar functions + /// for the other aspects. + /// + /// The layout is invariant for each image. However it is not cached, as this would waste + /// memory in the case of non-linear-tiling images. You are encouraged to store the layout + /// somewhere in order to avoid calling this semi-expensive function at every single memory + /// access. + /// + /// Note that while Vulkan allows querying the array layers other than 0, it is redundant as + /// you can easily calculate the position of any layer. + /// + /// # Panic + /// + /// - Panics if the mipmap level is out of range. + /// + /// # Safety + /// + /// - The image must *not* have a depth, stencil or depth-stencil format. + /// - The image must have been created with linear tiling. + /// + #[inline] + pub unsafe fn color_linear_layout(&self, mip_level: u32) -> LinearLayout { + self.linear_layout_impl(mip_level, vk::IMAGE_ASPECT_COLOR_BIT) + } + + /// Same as `color_linear_layout`, except that it retrieves the depth component of the image. + /// + /// # Panic + /// + /// - Panics if the mipmap level is out of range. + /// + /// # Safety + /// + /// - The image must have a depth or depth-stencil format. + /// - The image must have been created with linear tiling. + /// + #[inline] + pub unsafe fn depth_linear_layout(&self, mip_level: u32) -> LinearLayout { + self.linear_layout_impl(mip_level, vk::IMAGE_ASPECT_DEPTH_BIT) + } + + /// Same as `color_linear_layout`, except that it retrieves the stencil component of the image. + /// + /// # Panic + /// + /// - Panics if the mipmap level is out of range. + /// + /// # Safety + /// + /// - The image must have a stencil or depth-stencil format. + /// - The image must have been created with linear tiling. + /// + #[inline] + pub unsafe fn stencil_linear_layout(&self, mip_level: u32) -> LinearLayout { + self.linear_layout_impl(mip_level, vk::IMAGE_ASPECT_STENCIL_BIT) + } + + // Implementation of the `*_layout` functions. + unsafe fn linear_layout_impl(&self, mip_level: u32, aspect: u32) -> LinearLayout { + let vk = self.device.pointers(); + + assert!(mip_level < self.mipmaps); + + let subresource = vk::ImageSubresource { + aspectMask: aspect, + mipLevel: mip_level, + arrayLayer: 0, + }; + + let mut out = mem::uninitialized(); + vk.GetImageSubresourceLayout(self.device.internal_object(), + self.image, + &subresource, + &mut out); + + LinearLayout { + offset: out.offset as usize, + size: out.size as usize, + row_pitch: out.rowPitch as usize, + array_pitch: out.arrayPitch as usize, + depth_pitch: out.depthPitch as usize, + } + } + + /// Returns true if the image can be used as a source for blits. + #[inline] + pub fn supports_blit_source(&self) -> bool { + (self.format_features & vk::FORMAT_FEATURE_BLIT_SRC_BIT) != 0 + } + + /// Returns true if the image can be used as a destination for blits. + #[inline] + pub fn supports_blit_destination(&self) -> bool { + (self.format_features & vk::FORMAT_FEATURE_BLIT_DST_BIT) != 0 + } + + /// Returns true if the image can be sampled with a linear filtering. + #[inline] + pub fn supports_linear_filtering(&self) -> bool { + (self.format_features & vk::FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT) != 0 + } + + #[inline] + pub fn usage_transfer_source(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_TRANSFER_SRC_BIT) != 0 + } + + #[inline] + pub fn usage_transfer_destination(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_TRANSFER_DST_BIT) != 0 + } + + #[inline] + pub fn usage_sampled(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_SAMPLED_BIT) != 0 + } + + #[inline] + pub fn usage_storage(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_STORAGE_BIT) != 0 + } + + #[inline] + pub fn usage_color_attachment(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0 + } + + #[inline] + pub fn usage_depth_stencil_attachment(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0 + } + + #[inline] + pub fn usage_transient_attachment(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0 + } + + #[inline] + pub fn usage_input_attachment(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0 + } +} + +unsafe impl VulkanObject for UnsafeImage { + type Object = vk::Image; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT; + + #[inline] + fn internal_object(&self) -> vk::Image { + self.image + } +} + +impl fmt::Debug for UnsafeImage { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan image {:?}>", self.image) + } +} + +impl Drop for UnsafeImage { + #[inline] + fn drop(&mut self) { + if !self.needs_destruction { + return; + } + + unsafe { + let vk = self.device.pointers(); + vk.DestroyImage(self.device.internal_object(), self.image, ptr::null()); + } + } +} + +/// Error that can happen when creating an instance. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ImageCreationError { + /// Allocating memory failed. + AllocError(DeviceMemoryAllocError), + /// A wrong number of mipmaps was provided. + InvalidMipmapsCount { + obtained: u32, + valid_range: Range<u32>, + }, + /// The requested number of samples is not supported, or is 0. + UnsupportedSamplesCount { obtained: u32 }, + /// The dimensions are too large, or one of the dimensions is 0. + UnsupportedDimensions { dimensions: ImageDimensions }, + /// The requested format is not supported by the Vulkan implementation. + FormatNotSupported, + /// The format is supported, but at least one of the requested usages is not supported. + UnsupportedUsage, + /// The `shader_storage_image_multisample` feature must be enabled to create such an image. + ShaderStorageImageMultisampleFeatureNotEnabled, +} + +impl error::Error for ImageCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + ImageCreationError::AllocError(_) => "allocating memory failed", + ImageCreationError::InvalidMipmapsCount { .. } => + "a wrong number of mipmaps was provided", + ImageCreationError::UnsupportedSamplesCount { .. } => + "the requested number of samples is not supported, or is 0", + ImageCreationError::UnsupportedDimensions { .. } => + "the dimensions are too large, or one of the dimensions is 0", + ImageCreationError::FormatNotSupported => + "the requested format is not supported by the Vulkan implementation", + ImageCreationError::UnsupportedUsage => + "the format is supported, but at least one of the requested usages is not \ + supported", + ImageCreationError::ShaderStorageImageMultisampleFeatureNotEnabled => { + "the `shader_storage_image_multisample` feature must be enabled to create such \ + an image" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + ImageCreationError::AllocError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for ImageCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for ImageCreationError { + #[inline] + fn from(err: OomError) -> ImageCreationError { + ImageCreationError::AllocError(DeviceMemoryAllocError::OomError(err)) + } +} + +impl From<DeviceMemoryAllocError> for ImageCreationError { + #[inline] + fn from(err: DeviceMemoryAllocError) -> ImageCreationError { + ImageCreationError::AllocError(err) + } +} + +impl From<Error> for ImageCreationError { + #[inline] + fn from(err: Error) -> ImageCreationError { + match err { + err @ Error::OutOfHostMemory => ImageCreationError::AllocError(err.into()), + err @ Error::OutOfDeviceMemory => ImageCreationError::AllocError(err.into()), + _ => panic!("unexpected error: {:?}", err), + } + } +} + +/// Describes the memory layout of an image with linear tiling. +/// +/// Obtained by calling `*_linear_layout` on the image. +/// +/// The address of a texel at `(x, y, z, layer)` is `layer * array_pitch + z * depth_pitch + +/// y * row_pitch + x * size_of_each_texel + offset`. `size_of_each_texel` must be determined +/// depending on the format. The same formula applies for compressed formats, except that the +/// coordinates must be in number of blocks. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct LinearLayout { + /// Number of bytes from the start of the memory and the start of the queried subresource. + pub offset: usize, + /// Total number of bytes for the queried subresource. Can be used for a safety check. + pub size: usize, + /// Number of bytes between two texels or two blocks in adjacent rows. + pub row_pitch: usize, + /// Number of bytes between two texels or two blocks in adjacent array layers. This value is + /// undefined for images with only one array layer. + pub array_pitch: usize, + /// Number of bytes between two texels or two blocks in adjacent depth layers. This value is + /// undefined for images that are not three-dimensional. + pub depth_pitch: usize, +} + +pub struct UnsafeImageView { + view: vk::ImageView, + device: Arc<Device>, + usage: vk::ImageUsageFlagBits, + identity_swizzle: bool, + format: Format, +} + +impl UnsafeImageView { + /// See the docs of new(). + pub unsafe fn raw(image: &UnsafeImage, ty: ViewType, mipmap_levels: Range<u32>, + array_layers: Range<u32>) + -> Result<UnsafeImageView, OomError> { + let vk = image.device.pointers(); + + assert!(mipmap_levels.end > mipmap_levels.start); + assert!(mipmap_levels.end <= image.mipmaps); + assert!(array_layers.end > array_layers.start); + assert!(array_layers.end <= image.dimensions.array_layers()); + + let aspect_mask = match image.format.ty() { + FormatTy::Float | FormatTy::Uint | FormatTy::Sint | FormatTy::Compressed => { + vk::IMAGE_ASPECT_COLOR_BIT + }, + FormatTy::Depth => vk::IMAGE_ASPECT_DEPTH_BIT, + FormatTy::Stencil => vk::IMAGE_ASPECT_STENCIL_BIT, + FormatTy::DepthStencil => vk::IMAGE_ASPECT_DEPTH_BIT | vk::IMAGE_ASPECT_STENCIL_BIT, + }; + + let view_type = match (image.dimensions(), ty, array_layers.end - array_layers.start) { + (ImageDimensions::Dim1d { .. }, ViewType::Dim1d, 1) => vk::IMAGE_VIEW_TYPE_1D, + (ImageDimensions::Dim1d { .. }, ViewType::Dim1dArray, _) => + vk::IMAGE_VIEW_TYPE_1D_ARRAY, + (ImageDimensions::Dim2d { .. }, ViewType::Dim2d, 1) => vk::IMAGE_VIEW_TYPE_2D, + (ImageDimensions::Dim2d { .. }, ViewType::Dim2dArray, _) => + vk::IMAGE_VIEW_TYPE_2D_ARRAY, + (ImageDimensions::Dim2d { cubemap_compatible, .. }, ViewType::Cubemap, n) + if cubemap_compatible => { + assert_eq!(n, 6); + vk::IMAGE_VIEW_TYPE_CUBE + }, + (ImageDimensions::Dim2d { cubemap_compatible, .. }, ViewType::CubemapArray, n) + if cubemap_compatible => { + assert_eq!(n % 6, 0); + vk::IMAGE_VIEW_TYPE_CUBE_ARRAY + }, + (ImageDimensions::Dim3d { .. }, ViewType::Dim3d, _) => vk::IMAGE_VIEW_TYPE_3D, + _ => panic!(), + }; + + let view = { + let infos = vk::ImageViewCreateInfo { + sType: vk::STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + image: image.internal_object(), + viewType: view_type, + format: image.format as u32, + components: vk::ComponentMapping { + r: 0, + g: 0, + b: 0, + a: 0, + }, // FIXME: + subresourceRange: vk::ImageSubresourceRange { + aspectMask: aspect_mask, + baseMipLevel: mipmap_levels.start, + levelCount: mipmap_levels.end - mipmap_levels.start, + baseArrayLayer: array_layers.start, + layerCount: array_layers.end - array_layers.start, + }, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateImageView(image.device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(UnsafeImageView { + view: view, + device: image.device.clone(), + usage: image.usage, + identity_swizzle: true, // FIXME: + format: image.format, + }) + } + + /// Creates a new view from an image. + /// + /// Note that you must create the view with identity swizzling if you want to use this view + /// as a framebuffer attachment. + /// + /// # Panic + /// + /// - Panics if `mipmap_levels` or `array_layers` is out of range of the image. + /// - Panics if the view types doesn't match the dimensions of the image (for example a 2D + /// view from a 3D image). + /// - Panics if trying to create a cubemap with a number of array layers different from 6. + /// - Panics if trying to create a cubemap array with a number of array layers not a multiple + /// of 6. + /// - Panics if the device or host ran out of memory. + /// + #[inline] + pub unsafe fn new(image: &UnsafeImage, ty: ViewType, mipmap_levels: Range<u32>, + array_layers: Range<u32>) + -> UnsafeImageView { + UnsafeImageView::raw(image, ty, mipmap_levels, array_layers).unwrap() + } + + #[inline] + pub fn format(&self) -> Format { + self.format + } + + #[inline] + pub fn usage_transfer_source(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_TRANSFER_SRC_BIT) != 0 + } + + #[inline] + pub fn usage_transfer_destination(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_TRANSFER_DST_BIT) != 0 + } + + #[inline] + pub fn usage_sampled(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_SAMPLED_BIT) != 0 + } + + #[inline] + pub fn usage_storage(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_STORAGE_BIT) != 0 + } + + #[inline] + pub fn usage_color_attachment(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0 + } + + #[inline] + pub fn usage_depth_stencil_attachment(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0 + } + + #[inline] + pub fn usage_transient_attachment(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0 + } + + #[inline] + pub fn usage_input_attachment(&self) -> bool { + (self.usage & vk::IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0 + } +} + +unsafe impl VulkanObject for UnsafeImageView { + type Object = vk::ImageView; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT; + + #[inline] + fn internal_object(&self) -> vk::ImageView { + self.view + } +} + +impl fmt::Debug for UnsafeImageView { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan image view {:?}>", self.view) + } +} + +impl Drop for UnsafeImageView { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyImageView(self.device.internal_object(), self.view, ptr::null()); + } + } +} + +#[cfg(test)] +mod tests { + use std::iter::Empty; + use std::u32; + + use super::ImageCreationError; + use super::ImageUsage; + use super::UnsafeImage; + + use format::Format; + use image::ImageDimensions; + use sync::Sharing; + + #[test] + fn create_sampled() { + let (device, _) = gfx_dev_and_queue!(); + + let usage = ImageUsage { + sampled: true, + ..ImageUsage::none() + }; + + let (_img, _) = unsafe { + UnsafeImage::new(device, + usage, + Format::R8G8B8A8Unorm, + ImageDimensions::Dim2d { + width: 32, + height: 32, + array_layers: 1, + cubemap_compatible: false, + }, + 1, + 1, + Sharing::Exclusive::<Empty<_>>, + false, + false) + }.unwrap(); + } + + #[test] + fn create_transient() { + let (device, _) = gfx_dev_and_queue!(); + + let usage = ImageUsage { + transient_attachment: true, + color_attachment: true, + ..ImageUsage::none() + }; + + let (_img, _) = unsafe { + UnsafeImage::new(device, + usage, + Format::R8G8B8A8Unorm, + ImageDimensions::Dim2d { + width: 32, + height: 32, + array_layers: 1, + cubemap_compatible: false, + }, + 1, + 1, + Sharing::Exclusive::<Empty<_>>, + false, + false) + }.unwrap(); + } + + #[test] + fn zero_sample() { + let (device, _) = gfx_dev_and_queue!(); + + let usage = ImageUsage { + sampled: true, + ..ImageUsage::none() + }; + + let res = unsafe { + UnsafeImage::new(device, + usage, + Format::R8G8B8A8Unorm, + ImageDimensions::Dim2d { + width: 32, + height: 32, + array_layers: 1, + cubemap_compatible: false, + }, + 0, + 1, + Sharing::Exclusive::<Empty<_>>, + false, + false) + }; + + match res { + Err(ImageCreationError::UnsupportedSamplesCount { .. }) => (), + _ => panic!(), + }; + } + + #[test] + fn non_po2_sample() { + let (device, _) = gfx_dev_and_queue!(); + + let usage = ImageUsage { + sampled: true, + ..ImageUsage::none() + }; + + let res = unsafe { + UnsafeImage::new(device, + usage, + Format::R8G8B8A8Unorm, + ImageDimensions::Dim2d { + width: 32, + height: 32, + array_layers: 1, + cubemap_compatible: false, + }, + 5, + 1, + Sharing::Exclusive::<Empty<_>>, + false, + false) + }; + + match res { + Err(ImageCreationError::UnsupportedSamplesCount { .. }) => (), + _ => panic!(), + }; + } + + #[test] + fn zero_mipmap() { + let (device, _) = gfx_dev_and_queue!(); + + let usage = ImageUsage { + sampled: true, + ..ImageUsage::none() + }; + + let res = unsafe { + UnsafeImage::new(device, + usage, + Format::R8G8B8A8Unorm, + ImageDimensions::Dim2d { + width: 32, + height: 32, + array_layers: 1, + cubemap_compatible: false, + }, + 1, + 0, + Sharing::Exclusive::<Empty<_>>, + false, + false) + }; + + match res { + Err(ImageCreationError::InvalidMipmapsCount { .. }) => (), + _ => panic!(), + }; + } + + #[test] + #[ignore] // TODO: AMD card seems to support a u32::MAX number of mipmaps + fn mipmaps_too_high() { + let (device, _) = gfx_dev_and_queue!(); + + let usage = ImageUsage { + sampled: true, + ..ImageUsage::none() + }; + + let res = unsafe { + UnsafeImage::new(device, + usage, + Format::R8G8B8A8Unorm, + ImageDimensions::Dim2d { + width: 32, + height: 32, + array_layers: 1, + cubemap_compatible: false, + }, + 1, + u32::MAX, + Sharing::Exclusive::<Empty<_>>, + false, + false) + }; + + match res { + Err(ImageCreationError::InvalidMipmapsCount { + obtained, + valid_range, + }) => { + assert_eq!(obtained, u32::MAX); + assert_eq!(valid_range.start, 1); + }, + _ => panic!(), + }; + } + + #[test] + fn shader_storage_image_multisample() { + let (device, _) = gfx_dev_and_queue!(); + + let usage = ImageUsage { + storage: true, + ..ImageUsage::none() + }; + + let res = unsafe { + UnsafeImage::new(device, + usage, + Format::R8G8B8A8Unorm, + ImageDimensions::Dim2d { + width: 32, + height: 32, + array_layers: 1, + cubemap_compatible: false, + }, + 2, + 1, + Sharing::Exclusive::<Empty<_>>, + false, + false) + }; + + match res { + Err(ImageCreationError::ShaderStorageImageMultisampleFeatureNotEnabled) => (), + Err(ImageCreationError::UnsupportedSamplesCount { .. }) => (), // unlikely but possible + _ => panic!(), + }; + } + + #[test] + fn compressed_not_color_attachment() { + let (device, _) = gfx_dev_and_queue!(); + + let usage = ImageUsage { + color_attachment: true, + ..ImageUsage::none() + }; + + let res = unsafe { + UnsafeImage::new(device, + usage, + Format::ASTC_5x4UnormBlock, + ImageDimensions::Dim2d { + width: 32, + height: 32, + array_layers: 1, + cubemap_compatible: false, + }, + 1, + u32::MAX, + Sharing::Exclusive::<Empty<_>>, + false, + false) + }; + + match res { + Err(ImageCreationError::FormatNotSupported) => (), + Err(ImageCreationError::UnsupportedUsage) => (), + _ => panic!(), + }; + } + + #[test] + fn transient_forbidden_with_some_usages() { + let (device, _) = gfx_dev_and_queue!(); + + let usage = ImageUsage { + transient_attachment: true, + sampled: true, + ..ImageUsage::none() + }; + + let res = unsafe { + UnsafeImage::new(device, + usage, + Format::R8G8B8A8Unorm, + ImageDimensions::Dim2d { + width: 32, + height: 32, + array_layers: 1, + cubemap_compatible: false, + }, + 1, + 1, + Sharing::Exclusive::<Empty<_>>, + false, + false) + }; + + match res { + Err(ImageCreationError::UnsupportedUsage) => (), + _ => panic!(), + }; + } + + #[test] + fn cubecompatible_dims_mismatch() { + let (device, _) = gfx_dev_and_queue!(); + + let usage = ImageUsage { + sampled: true, + ..ImageUsage::none() + }; + + let res = unsafe { + UnsafeImage::new(device, + usage, + Format::R8G8B8A8Unorm, + ImageDimensions::Dim2d { + width: 32, + height: 64, + array_layers: 1, + cubemap_compatible: true, + }, + 1, + 1, + Sharing::Exclusive::<Empty<_>>, + false, + false) + }; + + match res { + Err(ImageCreationError::UnsupportedDimensions { .. }) => (), + _ => panic!(), + }; + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/image/traits.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/image/traits.rs new file mode 100644 index 0000000..224aa5f --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/image/traits.rs @@ -0,0 +1,454 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use buffer::BufferAccess; +use format::ClearValue; +use format::Format; +use format::PossibleDepthFormatDesc; +use format::PossibleDepthStencilFormatDesc; +use format::PossibleFloatFormatDesc; +use format::PossibleSintFormatDesc; +use format::PossibleStencilFormatDesc; +use format::PossibleUintFormatDesc; +use image::Dimensions; +use image::ImageDimensions; +use image::ImageLayout; +use image::sys::UnsafeImage; +use image::sys::UnsafeImageView; +use sampler::Sampler; +use sync::AccessError; + +use SafeDeref; + +/// Trait for types that represent the way a GPU can access an image. +pub unsafe trait ImageAccess { + /// Returns the inner unsafe image object used by this image. + fn inner(&self) -> ImageInner; + + /// Returns the format of this image. + #[inline] + fn format(&self) -> Format { + self.inner().image.format() + } + + /// Returns true if the image is a color image. + #[inline] + fn has_color(&self) -> bool { + let format = self.format(); + format.is_float() || format.is_uint() || format.is_sint() + } + + /// Returns true if the image has a depth component. In other words, if it is a depth or a + /// depth-stencil format. + #[inline] + fn has_depth(&self) -> bool { + let format = self.format(); + format.is_depth() || format.is_depth_stencil() + } + + /// Returns true if the image has a stencil component. In other words, if it is a stencil or a + /// depth-stencil format. + #[inline] + fn has_stencil(&self) -> bool { + let format = self.format(); + format.is_stencil() || format.is_depth_stencil() + } + + /// Returns the number of mipmap levels of this image. + #[inline] + fn mipmap_levels(&self) -> u32 { + // TODO: not necessarily correct because of the new inner() design? + self.inner().image.mipmap_levels() + } + + /// Returns the number of samples of this image. + #[inline] + fn samples(&self) -> u32 { + self.inner().image.samples() + } + + /// Returns the dimensions of the image. + #[inline] + fn dimensions(&self) -> ImageDimensions { + // TODO: not necessarily correct because of the new inner() design? + self.inner().image.dimensions() + } + + /// Returns true if the image can be used as a source for blits. + #[inline] + fn supports_blit_source(&self) -> bool { + self.inner().image.supports_blit_source() + } + + /// Returns true if the image can be used as a destination for blits. + #[inline] + fn supports_blit_destination(&self) -> bool { + self.inner().image.supports_blit_destination() + } + + /// Returns the layout that the image has when it is first used in a primary command buffer. + /// + /// The first time you use an image in an `AutoCommandBufferBuilder`, vulkano will suppose that + /// the image is in the layout returned by this function. Later when the command buffer is + /// submitted vulkano will check whether the image is actually in this layout, and if it is not + /// the case then an error will be returned. + /// TODO: ^ that check is not yet implemented + fn initial_layout_requirement(&self) -> ImageLayout; + + /// Returns the layout that the image must be returned to before the end of the command buffer. + /// + /// When an image is used in an `AutoCommandBufferBuilder` vulkano will automatically + /// transition this image to the layout returned by this function at the end of the command + /// buffer, if necessary. + /// + /// Except for special cases, this value should likely be the same as the one returned by + /// `initial_layout_requirement` so that the user can submit multiple command buffers that use + /// this image one after the other. + fn final_layout_requirement(&self) -> ImageLayout; + + /// Wraps around this `ImageAccess` and returns an identical `ImageAccess` but whose initial + /// layout requirement is either `Undefined` or `Preinitialized`. + #[inline] + unsafe fn forced_undefined_initial_layout(self, preinitialized: bool) + -> ImageAccessFromUndefinedLayout<Self> + where Self: Sized + { + ImageAccessFromUndefinedLayout { + image: self, + preinitialized: preinitialized, + } + } + + /// Returns true if an access to `self` potentially overlaps the same memory as an + /// access to `other`. + /// + /// If this function returns `false`, this means that we are allowed to access the content + /// of `self` at the same time as the content of `other` without causing a data race. + /// + /// Note that the function must be transitive. In other words if `conflicts(a, b)` is true and + /// `conflicts(b, c)` is true, then `conflicts(a, c)` must be true as well. + fn conflicts_buffer(&self, other: &BufferAccess) -> bool; + + /// Returns true if an access to `self` potentially overlaps the same memory as an + /// access to `other`. + /// + /// If this function returns `false`, this means that we are allowed to access the content + /// of `self` at the same time as the content of `other` without causing a data race. + /// + /// Note that the function must be transitive. In other words if `conflicts(a, b)` is true and + /// `conflicts(b, c)` is true, then `conflicts(a, c)` must be true as well. + fn conflicts_image(&self, other: &ImageAccess) -> bool; + + /// Returns a key that uniquely identifies the memory content of the image. + /// Two ranges that potentially overlap in memory must return the same key. + /// + /// The key is shared amongst all buffers and images, which means that you can make several + /// different image objects share the same memory, or make some image objects share memory + /// with buffers, as long as they return the same key. + /// + /// Since it is possible to accidentally return the same key for memory ranges that don't + /// overlap, the `conflicts_image` or `conflicts_buffer` function should always be called to + /// verify whether they actually overlap. + fn conflict_key(&self) -> u64; + + /// Locks the resource for usage on the GPU. Returns an error if the lock can't be acquired. + /// + /// After this function returns `Ok`, you are authorized to use the image on the GPU. If the + /// GPU operation requires an exclusive access to the image (which includes image layout + /// transitions) then `exclusive_access` should be true. + /// + /// The `expected_layout` is the layout we expect the image to be in when we lock it. If the + /// actual layout doesn't match this expected layout, then an error should be returned. If + /// `Undefined` is passed, that means that the caller doesn't care about the actual layout, + /// and that a layout mismatch shouldn't return an error. + /// + /// This function exists to prevent the user from causing a data race by reading and writing + /// to the same resource at the same time. + /// + /// If you call this function, you should call `unlock()` once the resource is no longer in use + /// by the GPU. The implementation is not expected to automatically perform any unlocking and + /// can rely on the fact that `unlock()` is going to be called. + fn try_gpu_lock(&self, exclusive_access: bool, expected_layout: ImageLayout) + -> Result<(), AccessError>; + + /// Locks the resource for usage on the GPU. Supposes that the resource is already locked, and + /// simply increases the lock by one. + /// + /// Must only be called after `try_gpu_lock()` succeeded. + /// + /// If you call this function, you should call `unlock()` once the resource is no longer in use + /// by the GPU. The implementation is not expected to automatically perform any unlocking and + /// can rely on the fact that `unlock()` is going to be called. + unsafe fn increase_gpu_lock(&self); + + /// Unlocks the resource previously acquired with `try_gpu_lock` or `increase_gpu_lock`. + /// + /// If the GPU operation that we unlock from transitioned the image to another layout, then + /// it should be passed as parameter. + /// + /// A layout transition requires exclusive access to the image, which means two things: + /// + /// - The implementation can panic if it finds out that the layout is not the same as it + /// currently is and that it is not locked in exclusive mode. + /// - There shouldn't be any possible race between `unlock` and `try_gpu_lock`, since + /// `try_gpu_lock` should fail if the image is already locked in exclusive mode. + /// + /// # Safety + /// + /// - Must only be called once per previous lock. + /// - The transitioned layout must be supported by the image (eg. the layout shouldn't be + /// `ColorAttachmentOptimal` if the image wasn't created with the `color_attachment` usage). + /// - The transitioned layout must not be `Undefined`. + /// + unsafe fn unlock(&self, transitioned_layout: Option<ImageLayout>); +} + +/// Inner information about an image. +#[derive(Copy, Clone, Debug)] +pub struct ImageInner<'a> { + /// The underlying image object. + pub image: &'a UnsafeImage, + + /// The first layer of `image` to consider. + pub first_layer: usize, + + /// The number of layers of `image` to consider. + pub num_layers: usize, + + /// The first mipmap level of `image` to consider. + pub first_mipmap_level: usize, + + /// The number of mipmap levels of `image` to consider. + pub num_mipmap_levels: usize, +} + +unsafe impl<T> ImageAccess for T + where T: SafeDeref, + T::Target: ImageAccess +{ + #[inline] + fn inner(&self) -> ImageInner { + (**self).inner() + } + + #[inline] + fn initial_layout_requirement(&self) -> ImageLayout { + (**self).initial_layout_requirement() + } + + #[inline] + fn final_layout_requirement(&self) -> ImageLayout { + (**self).final_layout_requirement() + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + (**self).conflicts_buffer(other) + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + (**self).conflicts_image(other) + } + + #[inline] + fn conflict_key(&self) -> u64 { + (**self).conflict_key() + } + + #[inline] + fn try_gpu_lock(&self, exclusive_access: bool, expected_layout: ImageLayout) + -> Result<(), AccessError> { + (**self).try_gpu_lock(exclusive_access, expected_layout) + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + (**self).increase_gpu_lock() + } + + #[inline] + unsafe fn unlock(&self, transitioned_layout: Option<ImageLayout>) { + (**self).unlock(transitioned_layout) + } +} + +/// Wraps around an object that implements `ImageAccess` and modifies the initial layout +/// requirement to be either `Undefined` or `Preinitialized`. +#[derive(Debug, Copy, Clone)] +pub struct ImageAccessFromUndefinedLayout<I> { + image: I, + preinitialized: bool, +} + +unsafe impl<I> ImageAccess for ImageAccessFromUndefinedLayout<I> + where I: ImageAccess +{ + #[inline] + fn inner(&self) -> ImageInner { + self.image.inner() + } + + #[inline] + fn initial_layout_requirement(&self) -> ImageLayout { + if self.preinitialized { + ImageLayout::Preinitialized + } else { + ImageLayout::Undefined + } + } + + #[inline] + fn final_layout_requirement(&self) -> ImageLayout { + self.image.final_layout_requirement() + } + + #[inline] + fn conflicts_buffer(&self, other: &BufferAccess) -> bool { + self.image.conflicts_buffer(other) + } + + #[inline] + fn conflicts_image(&self, other: &ImageAccess) -> bool { + self.image.conflicts_image(other) + } + + #[inline] + fn conflict_key(&self) -> u64 { + self.image.conflict_key() + } + + #[inline] + fn try_gpu_lock(&self, exclusive_access: bool, expected_layout: ImageLayout) + -> Result<(), AccessError> { + self.image.try_gpu_lock(exclusive_access, expected_layout) + } + + #[inline] + unsafe fn increase_gpu_lock(&self) { + self.image.increase_gpu_lock() + } + + #[inline] + unsafe fn unlock(&self, new_layout: Option<ImageLayout>) { + self.image.unlock(new_layout) + } +} + +/// Extension trait for images. Checks whether the value `T` can be used as a clear value for the +/// given image. +// TODO: isn't that for image views instead? +pub unsafe trait ImageClearValue<T>: ImageAccess { + fn decode(&self, T) -> Option<ClearValue>; +} + +pub unsafe trait ImageContent<P>: ImageAccess { + /// Checks whether pixels of type `P` match the format of the image. + fn matches_format(&self) -> bool; +} + +/// Trait for types that represent the GPU can access an image view. +pub unsafe trait ImageViewAccess { + fn parent(&self) -> &ImageAccess; + + /// Returns the dimensions of the image view. + fn dimensions(&self) -> Dimensions; + + /// Returns the inner unsafe image view object used by this image view. + fn inner(&self) -> &UnsafeImageView; + + /// Returns the format of this view. This can be different from the parent's format. + #[inline] + fn format(&self) -> Format { + // TODO: remove this default impl + self.inner().format() + } + + #[inline] + fn samples(&self) -> u32 { + self.parent().samples() + } + + /// Returns the image layout to use in a descriptor with the given subresource. + fn descriptor_set_storage_image_layout(&self) -> ImageLayout; + /// Returns the image layout to use in a descriptor with the given subresource. + fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout; + /// Returns the image layout to use in a descriptor with the given subresource. + fn descriptor_set_sampled_image_layout(&self) -> ImageLayout; + /// Returns the image layout to use in a descriptor with the given subresource. + fn descriptor_set_input_attachment_layout(&self) -> ImageLayout; + + /// Returns true if the view doesn't use components swizzling. + /// + /// Must be true when the view is used as a framebuffer attachment or TODO: I don't remember + /// the other thing. + fn identity_swizzle(&self) -> bool; + + /// Returns true if the given sampler can be used with this image view. + /// + /// This method should check whether the sampler's configuration can be used with the format + /// of the view. + // TODO: return a Result and propagate it when binding to a descriptor set + fn can_be_sampled(&self, _sampler: &Sampler) -> bool { + true /* FIXME */ + } + + //fn usable_as_render_pass_attachment(&self, ???) -> Result<(), ???>; +} + +unsafe impl<T> ImageViewAccess for T + where T: SafeDeref, + T::Target: ImageViewAccess +{ + #[inline] + fn parent(&self) -> &ImageAccess { + (**self).parent() + } + + #[inline] + fn inner(&self) -> &UnsafeImageView { + (**self).inner() + } + + #[inline] + fn dimensions(&self) -> Dimensions { + (**self).dimensions() + } + + #[inline] + fn descriptor_set_storage_image_layout(&self) -> ImageLayout { + (**self).descriptor_set_storage_image_layout() + } + #[inline] + fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout { + (**self).descriptor_set_combined_image_sampler_layout() + } + #[inline] + fn descriptor_set_sampled_image_layout(&self) -> ImageLayout { + (**self).descriptor_set_sampled_image_layout() + } + #[inline] + fn descriptor_set_input_attachment_layout(&self) -> ImageLayout { + (**self).descriptor_set_input_attachment_layout() + } + + #[inline] + fn identity_swizzle(&self) -> bool { + (**self).identity_swizzle() + } + + #[inline] + fn can_be_sampled(&self, sampler: &Sampler) -> bool { + (**self).can_be_sampled(sampler) + } +} + +pub unsafe trait AttachmentImageView: ImageViewAccess { + fn accept(&self, initial_layout: ImageLayout, final_layout: ImageLayout) -> bool; +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/image/usage.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/image/usage.rs new file mode 100644 index 0000000..ca47185 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/image/usage.rs @@ -0,0 +1,157 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::ops::BitOr; +use vk; + +/// Describes how an image is going to be used. This is **not** just an optimization. +/// +/// If you try to use an image in a way that you didn't declare, a panic will happen. +/// +/// If `transient_attachment` is true, then only `color_attachment`, `depth_stencil_attachment` +/// and `input_attachment` can be true as well. The rest must be false or an error will be returned +/// when creating the image. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct ImageUsage { + /// Can be used as a source for transfers. Includes blits. + pub transfer_source: bool, + + /// Can be used as a destination for transfers. Includes blits. + pub transfer_destination: bool, + + /// Can be sampled from a shader. + pub sampled: bool, + + /// Can be used as an image storage in a shader. + pub storage: bool, + + /// Can be attached as a color attachment to a framebuffer. + pub color_attachment: bool, + + /// Can be attached as a depth, stencil or depth-stencil attachment to a framebuffer. + pub depth_stencil_attachment: bool, + + /// Indicates that this image will only ever be used as a temporary framebuffer attachment. + /// As soon as you leave a render pass, the content of transient images becomes undefined. + /// + /// This is a hint to the Vulkan implementation that it may not need allocate any memory for + /// this image if the image can live entirely in some cache. + pub transient_attachment: bool, + + /// Can be used as an input attachment. In other words, you can draw to it in a subpass then + /// read from it in a following pass. + pub input_attachment: bool, +} + +impl ImageUsage { + /// Builds a `ImageUsage` with all values set to true. Note that using the returned value will + /// produce an error because of `transient_attachment` being true. + #[inline] + pub fn all() -> ImageUsage { + ImageUsage { + transfer_source: true, + transfer_destination: true, + sampled: true, + storage: true, + color_attachment: true, + depth_stencil_attachment: true, + transient_attachment: true, + input_attachment: true, + } + } + + /// Builds a `ImageUsage` with all values set to false. Useful as a default value. + /// + /// # Example + /// + /// ```rust + /// use vulkano::image::ImageUsage as ImageUsage; + /// + /// let _usage = ImageUsage { + /// transfer_destination: true, + /// sampled: true, + /// .. ImageUsage::none() + /// }; + /// ``` + #[inline] + pub fn none() -> ImageUsage { + ImageUsage { + transfer_source: false, + transfer_destination: false, + sampled: false, + storage: false, + color_attachment: false, + depth_stencil_attachment: false, + transient_attachment: false, + input_attachment: false, + } + } + + #[inline] + pub(crate) fn to_usage_bits(&self) -> vk::ImageUsageFlagBits { + let mut result = 0; + if self.transfer_source { + result |= vk::IMAGE_USAGE_TRANSFER_SRC_BIT; + } + if self.transfer_destination { + result |= vk::IMAGE_USAGE_TRANSFER_DST_BIT; + } + if self.sampled { + result |= vk::IMAGE_USAGE_SAMPLED_BIT; + } + if self.storage { + result |= vk::IMAGE_USAGE_STORAGE_BIT; + } + if self.color_attachment { + result |= vk::IMAGE_USAGE_COLOR_ATTACHMENT_BIT; + } + if self.depth_stencil_attachment { + result |= vk::IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; + } + if self.transient_attachment { + result |= vk::IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; + } + if self.input_attachment { + result |= vk::IMAGE_USAGE_INPUT_ATTACHMENT_BIT; + } + result + } + + #[inline] + pub(crate) fn from_bits(val: u32) -> ImageUsage { + ImageUsage { + transfer_source: (val & vk::IMAGE_USAGE_TRANSFER_SRC_BIT) != 0, + transfer_destination: (val & vk::IMAGE_USAGE_TRANSFER_DST_BIT) != 0, + sampled: (val & vk::IMAGE_USAGE_SAMPLED_BIT) != 0, + storage: (val & vk::IMAGE_USAGE_STORAGE_BIT) != 0, + color_attachment: (val & vk::IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0, + depth_stencil_attachment: (val & vk::IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0, + transient_attachment: (val & vk::IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0, + input_attachment: (val & vk::IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0, + } + } +} + +impl BitOr for ImageUsage { + type Output = Self; + + #[inline] + fn bitor(self, rhs: Self) -> Self { + ImageUsage { + transfer_source: self.transfer_source || rhs.transfer_source, + transfer_destination: self.transfer_destination || rhs.transfer_destination, + sampled: self.sampled || rhs.sampled, + storage: self.storage || rhs.storage, + color_attachment: self.color_attachment || rhs.color_attachment, + depth_stencil_attachment: self.depth_stencil_attachment || rhs.depth_stencil_attachment, + transient_attachment: self.transient_attachment || rhs.transient_attachment, + input_attachment: self.input_attachment || rhs.input_attachment, + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/instance/debug.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/debug.rs new file mode 100644 index 0000000..8c41343 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/debug.rs @@ -0,0 +1,280 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Debug callback called by intermediate layers or by the driver. +//! +//! When working on an application, it is recommended to register a debug callback. For example if +//! you enable the validation layers provided by the official Vulkan SDK, they will warn you about +//! invalid API usages or performance problems by calling this callback. The callback can also +//! be called by the driver or by whatever intermediate layer is activated. +//! +//! Note that the vulkano library can also emit messages to warn you about performance issues. +//! TODO: ^ that's not the case yet, need to choose whether we keep this idea +//! +//! # Example +//! +//! ``` +//! # use vulkano::instance::Instance; +//! # use std::sync::Arc; +//! # let instance: Arc<Instance> = return; +//! use vulkano::instance::debug::DebugCallback; +//! +//! let _callback = DebugCallback::errors_and_warnings(&instance, |msg| { +//! println!("Debug callback: {:?}", msg.description); +//! }).ok(); +//! ``` +//! +//! The type of `msg` in the callback is [`Message`](struct.Message.html). +//! +//! Note that you must keep the `_callback` object alive for as long as you want your callback to +//! be callable. If you don't store the return value of `DebugCallback`'s constructor in a +//! variable, it will be immediately destroyed and your callback will not work. +//! + +use std::error; +use std::ffi::CStr; +use std::fmt; +use std::mem; +use std::os::raw::{c_char, c_void}; +use std::panic; +use std::ptr; +use std::sync::Arc; + +use instance::Instance; + +use Error; +use VulkanObject; +use check_errors; +use vk; + +/// Registration of a callback called by validation layers. +/// +/// The callback can be called as long as this object is alive. +#[must_use = "The DebugCallback object must be kept alive for as long as you want your callback \ + to be called"] +pub struct DebugCallback { + instance: Arc<Instance>, + debug_report_callback: vk::DebugReportCallbackEXT, + user_callback: Box<Box<Fn(&Message)>>, +} + +impl DebugCallback { + /// Initializes a debug callback. + /// + /// Panics generated by calling `user_callback` are ignored. + pub fn new<F>(instance: &Arc<Instance>, messages: MessageTypes, user_callback: F) + -> Result<DebugCallback, DebugCallbackCreationError> + where F: Fn(&Message) + 'static + Send + panic::RefUnwindSafe + { + if !instance.loaded_extensions().ext_debug_report { + return Err(DebugCallbackCreationError::MissingExtension); + } + + // Note that we need to double-box the callback, because a `*const Fn()` is a fat pointer + // that can't be cast to a `*const c_void`. + let user_callback = Box::new(Box::new(user_callback) as Box<_>); + + extern "system" fn callback(ty: vk::DebugReportFlagsEXT, _: vk::DebugReportObjectTypeEXT, + _: u64, _: usize, _: i32, layer_prefix: *const c_char, + description: *const c_char, user_data: *mut c_void) + -> u32 { + unsafe { + let user_callback = user_data as *mut Box<Fn()> as *const _; + let user_callback: &Box<Fn(&Message)> = &*user_callback; + + let layer_prefix = CStr::from_ptr(layer_prefix) + .to_str() + .expect("debug callback message not utf-8"); + let description = CStr::from_ptr(description) + .to_str() + .expect("debug callback message not utf-8"); + + let message = Message { + ty: MessageTypes { + information: (ty & vk::DEBUG_REPORT_INFORMATION_BIT_EXT) != 0, + warning: (ty & vk::DEBUG_REPORT_WARNING_BIT_EXT) != 0, + performance_warning: (ty & vk::DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) != + 0, + error: (ty & vk::DEBUG_REPORT_ERROR_BIT_EXT) != 0, + debug: (ty & vk::DEBUG_REPORT_DEBUG_BIT_EXT) != 0, + }, + layer_prefix: layer_prefix, + description: description, + }; + + // Since we box the closure, the type system doesn't detect that the `UnwindSafe` + // bound is enforced. Therefore we enforce it manually. + let _ = panic::catch_unwind(panic::AssertUnwindSafe(move || { + user_callback(&message); + })); + + vk::FALSE + } + } + + let flags = { + let mut flags = 0; + if messages.information { + flags |= vk::DEBUG_REPORT_INFORMATION_BIT_EXT; + } + if messages.warning { + flags |= vk::DEBUG_REPORT_WARNING_BIT_EXT; + } + if messages.performance_warning { + flags |= vk::DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; + } + if messages.error { + flags |= vk::DEBUG_REPORT_ERROR_BIT_EXT; + } + if messages.debug { + flags |= vk::DEBUG_REPORT_DEBUG_BIT_EXT; + } + flags + }; + + let infos = vk::DebugReportCallbackCreateInfoEXT { + sType: vk::STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT, + pNext: ptr::null(), + flags: flags, + pfnCallback: callback, + pUserData: &*user_callback as &Box<_> as *const Box<_> as *const c_void as *mut _, + }; + + let vk = instance.pointers(); + + let debug_report_callback = unsafe { + let mut output = mem::uninitialized(); + check_errors(vk.CreateDebugReportCallbackEXT(instance.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(DebugCallback { + instance: instance.clone(), + debug_report_callback: debug_report_callback, + user_callback: user_callback, + }) + } + + /// Initializes a debug callback with errors and warnings. + /// + /// Shortcut for `new(instance, MessageTypes::errors_and_warnings(), user_callback)`. + #[inline] + pub fn errors_and_warnings<F>(instance: &Arc<Instance>, user_callback: F) + -> Result<DebugCallback, DebugCallbackCreationError> + where F: Fn(&Message) + Send + 'static + panic::RefUnwindSafe + { + DebugCallback::new(instance, MessageTypes::errors_and_warnings(), user_callback) + } +} + +impl Drop for DebugCallback { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.instance.pointers(); + vk.DestroyDebugReportCallbackEXT(self.instance.internal_object(), + self.debug_report_callback, + ptr::null()); + } + } +} + +/// A message received by the callback. +pub struct Message<'a> { + /// Type of message. + pub ty: MessageTypes, + /// Prefix of the layer that reported this message. + pub layer_prefix: &'a str, + /// Description of the message. + pub description: &'a str, +} + +/// Type of message. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct MessageTypes { + /// An error that may cause undefined results, including an application crash. + pub error: bool, + /// An unexpected use. + pub warning: bool, + /// A potential non-optimal use. + pub performance_warning: bool, + /// An informational message that may be handy when debugging an application. + pub information: bool, + /// Diagnostic information from the loader and layers. + pub debug: bool, +} + +impl MessageTypes { + /// Builds a `MessageTypes` with all fields set to `false` expect `error`. + #[inline] + pub fn errors() -> MessageTypes { + MessageTypes { + error: true, + ..MessageTypes::none() + } + } + + /// Builds a `MessageTypes` with all fields set to `false` expect `error`, `warning` + /// and `performance_warning`. + #[inline] + pub fn errors_and_warnings() -> MessageTypes { + MessageTypes { + error: true, + warning: true, + performance_warning: true, + ..MessageTypes::none() + } + } + + /// Builds a `MessageTypes` with all fields set to `false`. + #[inline] + pub fn none() -> MessageTypes { + MessageTypes { + error: false, + warning: false, + performance_warning: false, + information: false, + debug: false, + } + } +} + +/// Error that can happen when creating a debug callback. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum DebugCallbackCreationError { + /// The `EXT_debug_report` extension was not enabled. + MissingExtension, +} + +impl error::Error for DebugCallbackCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + DebugCallbackCreationError::MissingExtension => + "the `EXT_debug_report` extension was not enabled", + } + } +} + +impl fmt::Display for DebugCallbackCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for DebugCallbackCreationError { + #[inline] + fn from(err: Error) -> DebugCallbackCreationError { + panic!("unexpected error: {:?}", err) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/instance/extensions.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/extensions.rs new file mode 100644 index 0000000..06c89e3 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/extensions.rs @@ -0,0 +1,175 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::collections::HashSet; +use std::ffi::{CStr, CString}; +use std::fmt; +use std::iter::FromIterator; +use std::ptr; +use std::str; + +use check_errors; +use instance::loader; +use instance::loader::LoadingError; +use extensions::SupportedExtensionsError; +use vk; + +macro_rules! instance_extensions { + ($sname:ident, $rawname:ident, $($ext:ident => $s:expr,)*) => ( + extensions! { + $sname, $rawname, + $( $ext => $s,)* + } + + impl $rawname { + /// See the docs of supported_by_core(). + pub fn supported_by_core_raw() -> Result<Self, SupportedExtensionsError> { + $rawname::supported_by_core_raw_with_loader(loader::auto_loader()?) + } + + /// Same as `supported_by_core_raw()`, but allows specifying a loader. + pub fn supported_by_core_raw_with_loader<L>(ptrs: &loader::FunctionPointers<L>) + -> Result<Self, SupportedExtensionsError> + where L: loader::Loader + { + let entry_points = ptrs.entry_points(); + + let properties: Vec<vk::ExtensionProperties> = unsafe { + let mut num = 0; + try!(check_errors(entry_points.EnumerateInstanceExtensionProperties( + ptr::null(), &mut num, ptr::null_mut()))); + + let mut properties = Vec::with_capacity(num as usize); + try!(check_errors(entry_points.EnumerateInstanceExtensionProperties( + ptr::null(), &mut num, properties.as_mut_ptr()))); + properties.set_len(num as usize); + properties + }; + Ok($rawname(properties.iter().map(|x| unsafe { CStr::from_ptr(x.extensionName.as_ptr()) }.to_owned()).collect())) + } + + /// Returns a `RawExtensions` object with extensions supported by the core driver. + pub fn supported_by_core() -> Result<Self, LoadingError> { + match $rawname::supported_by_core_raw() { + Ok(l) => Ok(l), + Err(SupportedExtensionsError::LoadingError(e)) => Err(e), + Err(SupportedExtensionsError::OomError(e)) => panic!("{:?}", e), + } + } + + /// Same as `supported_by_core`, but allows specifying a loader. + pub fn supported_by_core_with_loader<L>(ptrs: &loader::FunctionPointers<L>) + -> Result<Self, LoadingError> + where L: loader::Loader + { + match $rawname::supported_by_core_raw_with_loader(ptrs) { + Ok(l) => Ok(l), + Err(SupportedExtensionsError::LoadingError(e)) => Err(e), + Err(SupportedExtensionsError::OomError(e)) => panic!("{:?}", e), + } + } + } + + impl $sname { + /// See the docs of supported_by_core(). + pub fn supported_by_core_raw() -> Result<Self, SupportedExtensionsError> { + $sname::supported_by_core_raw_with_loader(loader::auto_loader()?) + } + + /// See the docs of supported_by_core(). + pub fn supported_by_core_raw_with_loader<L>(ptrs: &loader::FunctionPointers<L>) + -> Result<Self, SupportedExtensionsError> + where L: loader::Loader + { + let entry_points = ptrs.entry_points(); + + let properties: Vec<vk::ExtensionProperties> = unsafe { + let mut num = 0; + try!(check_errors(entry_points.EnumerateInstanceExtensionProperties( + ptr::null(), &mut num, ptr::null_mut()))); + + let mut properties = Vec::with_capacity(num as usize); + try!(check_errors(entry_points.EnumerateInstanceExtensionProperties( + ptr::null(), &mut num, properties.as_mut_ptr()))); + properties.set_len(num as usize); + properties + }; + + let mut extensions = $sname::none(); + for property in properties { + let name = unsafe { CStr::from_ptr(property.extensionName.as_ptr()) }; + $( + // TODO: Check specVersion? + if name.to_bytes() == &$s[..] { + extensions.$ext = true; + } + )* + } + Ok(extensions) + } + + /// Returns a `RawExtensions` object with extensions supported by the core driver. + pub fn supported_by_core() -> Result<Self, LoadingError> { + match $sname::supported_by_core_raw() { + Ok(l) => Ok(l), + Err(SupportedExtensionsError::LoadingError(e)) => Err(e), + Err(SupportedExtensionsError::OomError(e)) => panic!("{:?}", e), + } + } + + /// Same as `supported_by_core`, but allows specifying a loader. + pub fn supported_by_core_with_loader<L>(ptrs: &loader::FunctionPointers<L>) + -> Result<Self, LoadingError> + where L: loader::Loader + { + match $sname::supported_by_core_raw_with_loader(ptrs) { + Ok(l) => Ok(l), + Err(SupportedExtensionsError::LoadingError(e)) => Err(e), + Err(SupportedExtensionsError::OomError(e)) => panic!("{:?}", e), + } + } + } + ); +} + +instance_extensions! { + InstanceExtensions, + RawInstanceExtensions, + khr_surface => b"VK_KHR_surface", + khr_display => b"VK_KHR_display", + khr_xlib_surface => b"VK_KHR_xlib_surface", + khr_xcb_surface => b"VK_KHR_xcb_surface", + khr_wayland_surface => b"VK_KHR_wayland_surface", + khr_android_surface => b"VK_KHR_android_surface", + khr_win32_surface => b"VK_KHR_win32_surface", + ext_debug_report => b"VK_EXT_debug_report", + mvk_ios_surface => b"VK_MVK_ios_surface", + mvk_macos_surface => b"VK_MVK_macos_surface", + mvk_moltenvk => b"VK_MVK_moltenvk", // TODO: confirm that it's an instance extension + nn_vi_surface => b"VK_NN_vi_surface", + ext_swapchain_colorspace => b"VK_EXT_swapchain_colorspace", + khr_get_physical_device_properties2 => b"VK_KHR_get_physical_device_properties2", +} + +/// This helper type can only be instantiated inside this module. +/// See `*Extensions::_unbuildable`. +#[doc(hidden)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct Unbuildable(()); + +#[cfg(test)] +mod tests { + use instance::{InstanceExtensions, RawInstanceExtensions}; + + #[test] + fn empty_extensions() { + let i: RawInstanceExtensions = (&InstanceExtensions::none()).into(); + assert!(i.iter().next().is_none()); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/instance/instance.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/instance.rs new file mode 100644 index 0000000..0e93eff --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/instance.rs @@ -0,0 +1,1347 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::borrow::Cow; +use std::error; +use std::ffi::CStr; +use std::ffi::CString; +use std::fmt; +use std::mem; +use std::ops::Deref; +use std::ptr; +use std::slice; +use std::sync::Arc; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use instance::limits::Limits; +use instance::loader; +use instance::loader::FunctionPointers; +use instance::loader::Loader; +use instance::loader::LoadingError; +use vk; + +use instance::{InstanceExtensions, RawInstanceExtensions}; +use version::Version; +use features::Features; + +/// An instance of a Vulkan context. This is the main object that should be created by an +/// application before everything else. +/// +/// See the documentation of [the `instance` module](index.html) for an introduction about +/// Vulkan instances. +/// +/// # Extensions and application infos +/// +/// Please check the documentation of [the `instance` module](index.html). +/// +/// # Layers +/// +/// When creating an `Instance`, you have the possibility to pass a list of **layers** that will +/// be activated on the newly-created instance. The list of available layers can be retrieved by +/// calling [the `layers_list` function](fn.layers_list.html). +/// +/// A layer is a component that will hook and potentially modify the Vulkan function calls. +/// For example, activating a layer could add a frames-per-second counter on the screen, or it +/// could send information to a debugger that will debug your application. +/// +/// > **Note**: From an application's point of view, layers "just exist". In practice, on Windows +/// > and Linux layers can be installed by third party installers or by package managers and can +/// > also be activated by setting the value of the `VK_INSTANCE_LAYERS` environment variable +/// > before starting the program. See the documentation of the official Vulkan loader for these +/// > platforms. +/// +/// > **Note**: In practice, the most common use of layers right now is for debugging purposes. +/// > To do so, you are encouraged to set the `VK_INSTANCE_LAYERS` environment variable on Windows +/// > or Linux instead of modifying the source code of your program. For example: +/// > `export VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_api_dump` on Linux if you installed the Vulkan SDK +/// > will print the list of raw Vulkan function calls. +/// +/// ## Example +/// +/// ``` +/// # use vulkano::instance; +/// # use vulkano::instance::Instance; +/// # use vulkano::instance::InstanceExtensions; +/// # use std::sync::Arc; +/// # use std::error::Error; +/// # fn test() -> Result<Arc<Instance>, Box<Error>> { +/// // For the sake of the example, we activate all the layers that +/// // contain the word "foo" in their description. +/// let layers: Vec<_> = instance::layers_list()? +/// .filter(|l| l.description().contains("foo")) +/// .collect(); +/// +/// let layer_names = layers.iter() +/// .map(|l| l.name()); +/// +/// let instance = Instance::new(None, &InstanceExtensions::none(), layer_names)?; +/// # Ok(instance) +/// # } +/// ``` +// TODO: mention that extensions must be supported by layers as well +pub struct Instance { + instance: vk::Instance, + //alloc: Option<Box<Alloc + Send + Sync>>, + physical_devices: Vec<PhysicalDeviceInfos>, + vk: vk::InstancePointers, + extensions: InstanceExtensions, + layers: SmallVec<[CString; 16]>, + function_pointers: OwnedOrRef<FunctionPointers<Box<Loader + Send + Sync>>>, +} + +// TODO: fix the underlying cause instead +impl ::std::panic::UnwindSafe for Instance { +} +impl ::std::panic::RefUnwindSafe for Instance { +} + +impl Instance { + /// Initializes a new instance of Vulkan. + /// + /// See the documentation of `Instance` or of [the `instance` module](index.html) for more + /// details. + /// + /// # Example + /// + /// ```no_run + /// use vulkano::instance::Instance; + /// use vulkano::instance::InstanceExtensions; + /// + /// let instance = match Instance::new(None, &InstanceExtensions::none(), None) { + /// Ok(i) => i, + /// Err(err) => panic!("Couldn't build instance: {:?}", err) + /// }; + /// ``` + /// + /// # Panic + /// + /// - Panics if the version numbers passed in `ApplicationInfo` are too large can't be + /// converted into a Vulkan version number. + /// - Panics if the application name or engine name contain a null character. + // TODO: add a test for these ^ + // TODO: if no allocator is specified by the user, use Rust's allocator instead of leaving + // the choice to Vulkan + pub fn new<'a, L, Ext>(app_infos: Option<&ApplicationInfo>, extensions: Ext, layers: L) + -> Result<Arc<Instance>, InstanceCreationError> + where L: IntoIterator<Item = &'a str>, + Ext: Into<RawInstanceExtensions> + { + let layers = layers + .into_iter() + .map(|layer| CString::new(layer).unwrap()) + .collect::<SmallVec<[_; 16]>>(); + + Instance::new_inner(app_infos, + extensions.into(), + layers, + OwnedOrRef::Ref(loader::auto_loader()?)) + } + + /// Same as `new`, but allows specifying a loader where to load Vulkan from. + pub fn with_loader<'a, L, Ext>(loader: FunctionPointers<Box<Loader + Send + Sync>>, + app_infos: Option<&ApplicationInfo>, extensions: Ext, layers: L) + -> Result<Arc<Instance>, InstanceCreationError> + where L: IntoIterator<Item = &'a str>, + Ext: Into<RawInstanceExtensions> + { + let layers = layers + .into_iter() + .map(|layer| CString::new(layer).unwrap()) + .collect::<SmallVec<[_; 16]>>(); + + Instance::new_inner(app_infos, + extensions.into(), + layers, + OwnedOrRef::Owned(loader)) + } + + fn new_inner(app_infos: Option<&ApplicationInfo>, extensions: RawInstanceExtensions, + layers: SmallVec<[CString; 16]>, + function_pointers: OwnedOrRef<FunctionPointers<Box<Loader + Send + Sync>>>) + -> Result<Arc<Instance>, InstanceCreationError> { + // TODO: For now there are still buggy drivers that will segfault if you don't pass any + // appinfos. Therefore for now we ensure that it can't be `None`. + let def = Default::default(); + let app_infos = match app_infos { + Some(a) => Some(a), + None => Some(&def), + }; + + // Building the CStrings from the `str`s within `app_infos`. + // They need to be created ahead of time, since we pass pointers to them. + let app_infos_strings = if let Some(app_infos) = app_infos { + Some((app_infos + .application_name + .clone() + .map(|n| CString::new(n.as_bytes().to_owned()).unwrap()), + app_infos + .engine_name + .clone() + .map(|n| CString::new(n.as_bytes().to_owned()).unwrap()))) + } else { + None + }; + + // Building the `vk::ApplicationInfo` if required. + let app_infos = if let Some(app_infos) = app_infos { + Some(vk::ApplicationInfo { + sType: vk::STRUCTURE_TYPE_APPLICATION_INFO, + pNext: ptr::null(), + pApplicationName: app_infos_strings + .as_ref() + .unwrap() + .0 + .as_ref() + .map(|s| s.as_ptr()) + .unwrap_or(ptr::null()), + applicationVersion: app_infos + .application_version + .map(|v| v.into_vulkan_version()) + .unwrap_or(0), + pEngineName: app_infos_strings + .as_ref() + .unwrap() + .1 + .as_ref() + .map(|s| s.as_ptr()) + .unwrap_or(ptr::null()), + engineVersion: app_infos + .engine_version + .map(|v| v.into_vulkan_version()) + .unwrap_or(0), + apiVersion: Version { + major: 1, + minor: 0, + patch: 0, + }.into_vulkan_version(), // TODO: + }) + + } else { + None + }; + + // FIXME: check whether each layer is supported + let layers_ptr = layers + .iter() + .map(|layer| layer.as_ptr()) + .collect::<SmallVec<[_; 16]>>(); + + let extensions_list = extensions + .iter() + .map(|extension| extension.as_ptr()) + .collect::<SmallVec<[_; 32]>>(); + + // Creating the Vulkan instance. + let instance = unsafe { + let mut output = mem::uninitialized(); + let infos = vk::InstanceCreateInfo { + sType: vk::STRUCTURE_TYPE_INSTANCE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, + pApplicationInfo: if let Some(app) = app_infos.as_ref() { + app as *const _ + } else { + ptr::null() + }, + enabledLayerCount: layers_ptr.len() as u32, + ppEnabledLayerNames: layers_ptr.as_ptr(), + enabledExtensionCount: extensions_list.len() as u32, + ppEnabledExtensionNames: extensions_list.as_ptr(), + }; + + let entry_points = function_pointers.entry_points(); + check_errors(entry_points.CreateInstance(&infos, ptr::null(), &mut output))?; + output + }; + + // Loading the function pointers of the newly-created instance. + let vk = { + vk::InstancePointers::load(|name| unsafe { + mem::transmute(function_pointers.get_instance_proc_addr(instance, name.as_ptr())) + }) + }; + + // Enumerating all physical devices. + let physical_devices: Vec<vk::PhysicalDevice> = unsafe { + let mut num = 0; + check_errors(vk.EnumeratePhysicalDevices(instance, &mut num, ptr::null_mut()))?; + + let mut devices = Vec::with_capacity(num as usize); + check_errors(vk.EnumeratePhysicalDevices(instance, &mut num, devices.as_mut_ptr()))?; + devices.set_len(num as usize); + devices + }; + + // TODO: should be Into + let extensions: InstanceExtensions = (&extensions).into(); + + // Getting the properties of all physical devices. + // If possible, we use VK_KHR_get_physical_device_properties2. + let physical_devices = if extensions.khr_get_physical_device_properties2 { + Instance::init_physical_devices2(&vk, physical_devices, &extensions) + } else { + Instance::init_physical_devices(&vk, physical_devices) + }; + + Ok(Arc::new(Instance { + instance: instance, + //alloc: None, + physical_devices: physical_devices, + vk: vk, + extensions: extensions, + layers: layers, + function_pointers: function_pointers, + })) + } + + /// Initialize all physical devices + fn init_physical_devices(vk: &vk::InstancePointers, physical_devices: Vec<vk::PhysicalDevice>) + -> Vec<PhysicalDeviceInfos> { + let mut output = Vec::with_capacity(physical_devices.len()); + + for device in physical_devices.into_iter() { + let properties: vk::PhysicalDeviceProperties = unsafe { + let mut output = mem::uninitialized(); + vk.GetPhysicalDeviceProperties(device, &mut output); + output + }; + + let queue_families = unsafe { + let mut num = 0; + vk.GetPhysicalDeviceQueueFamilyProperties(device, &mut num, ptr::null_mut()); + + let mut families = Vec::with_capacity(num as usize); + vk.GetPhysicalDeviceQueueFamilyProperties(device, &mut num, families.as_mut_ptr()); + families.set_len(num as usize); + families + }; + + let memory: vk::PhysicalDeviceMemoryProperties = unsafe { + let mut output = mem::uninitialized(); + vk.GetPhysicalDeviceMemoryProperties(device, &mut output); + output + }; + + let available_features: vk::PhysicalDeviceFeatures = unsafe { + let mut output = mem::uninitialized(); + vk.GetPhysicalDeviceFeatures(device, &mut output); + output + }; + + output.push(PhysicalDeviceInfos { + device: device, + properties: properties, + memory: memory, + queue_families: queue_families, + available_features: Features::from_vulkan_features(available_features), + }); + } + output + } + + /// Initialize all physical devices, but use VK_KHR_get_physical_device_properties2 + /// TODO: Query extension-specific physical device properties, once a new instance extension is supported. + fn init_physical_devices2(vk: &vk::InstancePointers, + physical_devices: Vec<vk::PhysicalDevice>, + extensions: &InstanceExtensions) + -> Vec<PhysicalDeviceInfos> { + let mut output = Vec::with_capacity(physical_devices.len()); + + for device in physical_devices.into_iter() { + let properties: vk::PhysicalDeviceProperties = unsafe { + let mut output = vk::PhysicalDeviceProperties2KHR { + sType: vk::STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR, + pNext: ptr::null_mut(), + properties: mem::uninitialized(), + }; + + vk.GetPhysicalDeviceProperties2KHR(device, &mut output); + output.properties + }; + + let queue_families = unsafe { + let mut num = 0; + vk.GetPhysicalDeviceQueueFamilyProperties2KHR(device, &mut num, ptr::null_mut()); + + let mut families = (0 .. num) + .map(|_| { + vk::QueueFamilyProperties2KHR { + sType: vk::STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR, + pNext: ptr::null_mut(), + queueFamilyProperties: mem::uninitialized(), + } + }) + .collect::<Vec<_>>(); + + vk.GetPhysicalDeviceQueueFamilyProperties2KHR(device, + &mut num, + families.as_mut_ptr()); + families + .into_iter() + .map(|family| family.queueFamilyProperties) + .collect() + }; + + let memory: vk::PhysicalDeviceMemoryProperties = unsafe { + let mut output = vk::PhysicalDeviceMemoryProperties2KHR { + sType: vk::STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR, + pNext: ptr::null_mut(), + memoryProperties: mem::uninitialized(), + }; + vk.GetPhysicalDeviceMemoryProperties2KHR(device, &mut output); + output.memoryProperties + }; + + let available_features: vk::PhysicalDeviceFeatures = unsafe { + let mut output = vk::PhysicalDeviceFeatures2KHR { + sType: vk::STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR, + pNext: ptr::null_mut(), + features: mem::uninitialized(), + }; + vk.GetPhysicalDeviceFeatures2KHR(device, &mut output); + output.features + }; + + output.push(PhysicalDeviceInfos { + device: device, + properties: properties, + memory: memory, + queue_families: queue_families, + available_features: Features::from_vulkan_features(available_features), + }); + } + output + } + + /*/// Same as `new`, but provides an allocator that will be used by the Vulkan library whenever + /// it needs to allocate memory on the host. + /// + /// Note that this allocator can be overridden when you create a `Device`, a `MemoryPool`, etc. + pub fn with_alloc(app_infos: Option<&ApplicationInfo>, alloc: Box<Alloc + Send + Sync>) -> Arc<Instance> { + unimplemented!() + }*/ + + /// Grants access to the Vulkan functions of the instance. + #[inline] + pub(crate) fn pointers(&self) -> &vk::InstancePointers { + &self.vk + } + + /// Returns the list of extensions that have been loaded. + /// + /// This list is equal to what was passed to `Instance::new()`. + /// + /// # Example + /// + /// ```no_run + /// use vulkano::instance::Instance; + /// use vulkano::instance::InstanceExtensions; + /// + /// let extensions = InstanceExtensions::supported_by_core().unwrap(); + /// let instance = Instance::new(None, &extensions, None).unwrap(); + /// assert_eq!(instance.loaded_extensions(), &extensions); + /// ``` + #[inline] + pub fn loaded_extensions(&self) -> &InstanceExtensions { + &self.extensions + } + + /// Returns the list of layers requested when creating this instance. + #[doc(hidden)] + #[inline] + pub fn loaded_layers(&self) -> slice::Iter<CString> { + self.layers.iter() + } +} + +impl fmt::Debug for Instance { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan instance {:?}>", self.instance) + } +} + +unsafe impl VulkanObject for Instance { + type Object = vk::Instance; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT; + + #[inline] + fn internal_object(&self) -> vk::Instance { + self.instance + } +} + +impl Drop for Instance { + #[inline] + fn drop(&mut self) { + unsafe { + self.vk.DestroyInstance(self.instance, ptr::null()); + } + } +} + +// Same as Cow but less annoying. +enum OwnedOrRef<T: 'static> { + Owned(T), + Ref(&'static T), +} + +impl<T> Deref for OwnedOrRef<T> { + type Target = T; + #[inline] + fn deref(&self) -> &T { + match *self { + OwnedOrRef::Owned(ref v) => v, + OwnedOrRef::Ref(v) => v, + } + } +} + +/// Information that can be given to the Vulkan driver so that it can identify your application. +// TODO: better documentation for struct and methods +#[derive(Debug, Clone)] +pub struct ApplicationInfo<'a> { + /// Name of the application. + pub application_name: Option<Cow<'a, str>>, + /// An opaque number that contains the version number of the application. + pub application_version: Option<Version>, + /// Name of the engine used to power the application. + pub engine_name: Option<Cow<'a, str>>, + /// An opaque number that contains the version number of the engine. + pub engine_version: Option<Version>, +} + +impl<'a> ApplicationInfo<'a> { + /// Builds an `ApplicationInfo` from the information gathered by Cargo. + /// + /// # Panic + /// + /// - Panics if the required environment variables are missing, which happens if the project + /// wasn't built by Cargo. + /// + #[deprecated(note = "Please use the `app_info_from_cargo_toml!` macro instead")] + pub fn from_cargo_toml() -> ApplicationInfo<'a> { + let version = Version { + major: env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap(), + minor: env!("CARGO_PKG_VERSION_MINOR").parse().unwrap(), + patch: env!("CARGO_PKG_VERSION_PATCH").parse().unwrap(), + }; + + let name = env!("CARGO_PKG_NAME"); + + ApplicationInfo { + application_name: Some(name.into()), + application_version: Some(version), + engine_name: None, + engine_version: None, + } + } +} + +/// Builds an `ApplicationInfo` from the information gathered by Cargo. +/// +/// # Panic +/// +/// - Panics if the required environment variables are missing, which happens if the project +/// wasn't built by Cargo. +/// +#[macro_export] +macro_rules! app_info_from_cargo_toml { + () => {{ + let version = $crate::instance::Version { + major: env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap(), + minor: env!("CARGO_PKG_VERSION_MINOR").parse().unwrap(), + patch: env!("CARGO_PKG_VERSION_PATCH").parse().unwrap(), + }; + + let name = env!("CARGO_PKG_NAME"); + + $crate::instance::ApplicationInfo { + application_name: Some(name.into()), + application_version: Some(version), + engine_name: None, + engine_version: None, + } + }} +} + +impl<'a> Default for ApplicationInfo<'a> { + fn default() -> ApplicationInfo<'a> { + ApplicationInfo { + application_name: None, + application_version: None, + engine_name: None, + engine_version: None, + } + } +} + +/// Error that can happen when creating an instance. +#[derive(Clone, Debug)] +pub enum InstanceCreationError { + /// Failed to load the Vulkan shared library. + LoadingError(LoadingError), + /// Not enough memory. + OomError(OomError), + /// Failed to initialize for an implementation-specific reason. + InitializationFailed, + /// One of the requested layers is missing. + LayerNotPresent, + /// One of the requested extensions is missing. + ExtensionNotPresent, + /// The version requested is not supported by the implementation. + // TODO: more info about this once the question of the version has been resolved + IncompatibleDriver, +} + +impl error::Error for InstanceCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + InstanceCreationError::LoadingError(_) => "failed to load the Vulkan shared library", + InstanceCreationError::OomError(_) => "not enough memory available", + InstanceCreationError::InitializationFailed => "initialization failed", + InstanceCreationError::LayerNotPresent => "layer not present", + InstanceCreationError::ExtensionNotPresent => "extension not present", + InstanceCreationError::IncompatibleDriver => "incompatible driver", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + InstanceCreationError::LoadingError(ref err) => Some(err), + InstanceCreationError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for InstanceCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for InstanceCreationError { + #[inline] + fn from(err: OomError) -> InstanceCreationError { + InstanceCreationError::OomError(err) + } +} + +impl From<LoadingError> for InstanceCreationError { + #[inline] + fn from(err: LoadingError) -> InstanceCreationError { + InstanceCreationError::LoadingError(err) + } +} + +impl From<Error> for InstanceCreationError { + #[inline] + fn from(err: Error) -> InstanceCreationError { + match err { + err @ Error::OutOfHostMemory => InstanceCreationError::OomError(OomError::from(err)), + err @ Error::OutOfDeviceMemory => InstanceCreationError::OomError(OomError::from(err)), + Error::InitializationFailed => InstanceCreationError::InitializationFailed, + Error::LayerNotPresent => InstanceCreationError::LayerNotPresent, + Error::ExtensionNotPresent => InstanceCreationError::ExtensionNotPresent, + Error::IncompatibleDriver => InstanceCreationError::IncompatibleDriver, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +struct PhysicalDeviceInfos { + device: vk::PhysicalDevice, + properties: vk::PhysicalDeviceProperties, + queue_families: Vec<vk::QueueFamilyProperties>, + memory: vk::PhysicalDeviceMemoryProperties, + available_features: Features, +} + +/// Represents one of the available devices on this machine. +/// +/// This struct simply contains a pointer to an instance and a number representing the physical +/// device. You are therefore encouraged to pass this around by value instead of by reference. +/// +/// # Example +/// +/// ```no_run +/// # use vulkano::instance::Instance; +/// # use vulkano::instance::InstanceExtensions; +/// use vulkano::instance::PhysicalDevice; +/// +/// # let instance = Instance::new(None, &InstanceExtensions::none(), None).unwrap(); +/// for physical_device in PhysicalDevice::enumerate(&instance) { +/// print_infos(physical_device); +/// } +/// +/// fn print_infos(dev: PhysicalDevice) { +/// println!("Name: {}", dev.name()); +/// } +/// ``` +#[derive(Debug, Copy, Clone)] +pub struct PhysicalDevice<'a> { + instance: &'a Arc<Instance>, + device: usize, +} + +impl<'a> PhysicalDevice<'a> { + /// Returns an iterator that enumerates the physical devices available. + /// + /// # Example + /// + /// ```no_run + /// # use vulkano::instance::Instance; + /// # use vulkano::instance::InstanceExtensions; + /// use vulkano::instance::PhysicalDevice; + /// + /// # let instance = Instance::new(None, &InstanceExtensions::none(), None).unwrap(); + /// for physical_device in PhysicalDevice::enumerate(&instance) { + /// println!("Available device: {}", physical_device.name()); + /// } + /// ``` + #[inline] + pub fn enumerate(instance: &'a Arc<Instance>) -> PhysicalDevicesIter<'a> { + PhysicalDevicesIter { + instance: instance, + current_id: 0, + } + } + + /// Returns a physical device from its index. Returns `None` if out of range. + /// + /// Indices range from 0 to the number of devices. + /// + /// # Example + /// + /// ```no_run + /// use vulkano::instance::Instance; + /// use vulkano::instance::InstanceExtensions; + /// use vulkano::instance::PhysicalDevice; + /// + /// let instance = Instance::new(None, &InstanceExtensions::none(), None).unwrap(); + /// let first_physical_device = PhysicalDevice::from_index(&instance, 0).unwrap(); + /// ``` + #[inline] + pub fn from_index(instance: &'a Arc<Instance>, index: usize) -> Option<PhysicalDevice<'a>> { + if instance.physical_devices.len() > index { + Some(PhysicalDevice { + instance: instance, + device: index, + }) + } else { + None + } + } + + /// Returns the instance corresponding to this physical device. + /// + /// # Example + /// + /// ```no_run + /// use vulkano::instance::PhysicalDevice; + /// + /// fn do_something(physical_device: PhysicalDevice) { + /// let _loaded_extensions = physical_device.instance().loaded_extensions(); + /// // ... + /// } + /// ``` + #[inline] + pub fn instance(&self) -> &'a Arc<Instance> { + &self.instance + } + + /// Returns the index of the physical device in the physical devices list. + /// + /// This index never changes and can be used later to retrieve a `PhysicalDevice` from an + /// instance and an index. + #[inline] + pub fn index(&self) -> usize { + self.device + } + + /// Returns the human-readable name of the device. + #[inline] + pub fn name(&self) -> String { + // FIXME: for some reason this panics if you use a `&str` + unsafe { + let val = self.infos().properties.deviceName; + let val = CStr::from_ptr(val.as_ptr()); + val.to_str() + .expect("physical device name contained non-UTF8 characters") + .to_owned() + } + } + + /// Returns the type of the device. + /// + /// # Example + /// + /// ```no_run + /// # use vulkano::instance::Instance; + /// # use vulkano::instance::InstanceExtensions; + /// use vulkano::instance::PhysicalDevice; + /// + /// # let instance = Instance::new(None, &InstanceExtensions::none(), None).unwrap(); + /// for physical_device in PhysicalDevice::enumerate(&instance) { + /// println!("Available device: {} (type: {:?})", + /// physical_device.name(), physical_device.ty()); + /// } + /// ``` + #[inline] + pub fn ty(&self) -> PhysicalDeviceType { + match self.instance.physical_devices[self.device] + .properties + .deviceType { + vk::PHYSICAL_DEVICE_TYPE_OTHER => PhysicalDeviceType::Other, + vk::PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU => PhysicalDeviceType::IntegratedGpu, + vk::PHYSICAL_DEVICE_TYPE_DISCRETE_GPU => PhysicalDeviceType::DiscreteGpu, + vk::PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU => PhysicalDeviceType::VirtualGpu, + vk::PHYSICAL_DEVICE_TYPE_CPU => PhysicalDeviceType::Cpu, + _ => panic!("Unrecognized Vulkan device type"), + } + } + + /// Returns the version of Vulkan supported by this device. + #[inline] + pub fn api_version(&self) -> Version { + let val = self.infos().properties.apiVersion; + Version::from_vulkan_version(val) + } + + /// Returns the Vulkan features that are supported by this physical device. + #[inline] + pub fn supported_features(&self) -> &'a Features { + &self.infos().available_features + } + + /// Builds an iterator that enumerates all the queue families on this physical device. + #[inline] + pub fn queue_families(&self) -> QueueFamiliesIter<'a> { + QueueFamiliesIter { + physical_device: *self, + current_id: 0, + } + } + + /// Returns the queue family with the given index, or `None` if out of range. + #[inline] + pub fn queue_family_by_id(&self, id: u32) -> Option<QueueFamily<'a>> { + if (id as usize) < self.infos().queue_families.len() { + Some(QueueFamily { + physical_device: *self, + id: id, + }) + + } else { + None + } + } + + /// Builds an iterator that enumerates all the memory types on this physical device. + #[inline] + pub fn memory_types(&self) -> MemoryTypesIter<'a> { + MemoryTypesIter { + physical_device: *self, + current_id: 0, + } + } + + /// Returns the memory type with the given index, or `None` if out of range. + #[inline] + pub fn memory_type_by_id(&self, id: u32) -> Option<MemoryType<'a>> { + if id < self.infos().memory.memoryTypeCount { + Some(MemoryType { + physical_device: *self, + id: id, + }) + + } else { + None + } + } + + /// Builds an iterator that enumerates all the memory heaps on this physical device. + #[inline] + pub fn memory_heaps(&self) -> MemoryHeapsIter<'a> { + MemoryHeapsIter { + physical_device: *self, + current_id: 0, + } + } + + /// Returns the memory heap with the given index, or `None` if out of range. + #[inline] + pub fn memory_heap_by_id(&self, id: u32) -> Option<MemoryHeap<'a>> { + if id < self.infos().memory.memoryHeapCount { + Some(MemoryHeap { + physical_device: *self, + id: id, + }) + + } else { + None + } + } + + /// Gives access to the limits of the physical device. + /// + /// This function should be zero-cost in release mode. It only exists to not pollute the + /// namespace of `PhysicalDevice` with all the limits-related getters. + #[inline] + pub fn limits(&self) -> Limits<'a> { + Limits::from_vk_limits(&self.infos().properties.limits) + } + + /// Returns an opaque number representing the version of the driver of this device. + /// + /// The meaning of this number is implementation-specific. It can be used in bug reports, for + /// example. + #[inline] + pub fn driver_version(&self) -> u32 { + self.infos().properties.driverVersion + } + + /// Returns the PCI ID of the device. + #[inline] + pub fn pci_device_id(&self) -> u32 { + self.infos().properties.deviceID + } + + /// Returns the PCI ID of the vendor. + #[inline] + pub fn pci_vendor_id(&self) -> u32 { + self.infos().properties.vendorID + } + + /// Returns a unique identifier for the device. + /// + /// Can be stored in a configuration file, so that you can retrieve the device again the next + /// time the program is run. + #[inline] + pub fn uuid(&self) -> &[u8; 16] { + // must be equal to vk::UUID_SIZE + &self.infos().properties.pipelineCacheUUID + } + + // Internal function to make it easier to get the infos of this device. + #[inline] + fn infos(&self) -> &'a PhysicalDeviceInfos { + &self.instance.physical_devices[self.device] + } +} + +unsafe impl<'a> VulkanObject for PhysicalDevice<'a> { + type Object = vk::PhysicalDevice; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT; + + #[inline] + fn internal_object(&self) -> vk::PhysicalDevice { + self.infos().device + } +} + +/// Iterator for all the physical devices available on hardware. +#[derive(Debug, Clone)] +pub struct PhysicalDevicesIter<'a> { + instance: &'a Arc<Instance>, + current_id: usize, +} + +impl<'a> Iterator for PhysicalDevicesIter<'a> { + type Item = PhysicalDevice<'a>; + + #[inline] + fn next(&mut self) -> Option<PhysicalDevice<'a>> { + if self.current_id >= self.instance.physical_devices.len() { + return None; + } + + let dev = PhysicalDevice { + instance: self.instance, + device: self.current_id, + }; + + self.current_id += 1; + Some(dev) + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + let len = self.instance.physical_devices.len() - self.current_id; + (len, Some(len)) + } +} + +impl<'a> ExactSizeIterator for PhysicalDevicesIter<'a> { +} + +/// Type of a physical device. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[repr(u32)] +pub enum PhysicalDeviceType { + /// The device is an integrated GPU. + IntegratedGpu = 1, + /// The device is a discrete GPU. + DiscreteGpu = 2, + /// The device is a virtual GPU. + VirtualGpu = 3, + /// The device is a CPU. + Cpu = 4, + /// The device is something else. + Other = 0, +} + +/// Represents a queue family in a physical device. +/// +/// A queue family is group of one or multiple queues. All queues of one family have the same +/// characteristics. +#[derive(Debug, Copy, Clone)] +pub struct QueueFamily<'a> { + physical_device: PhysicalDevice<'a>, + id: u32, +} + +impl<'a> QueueFamily<'a> { + /// Returns the physical device associated to this queue family. + #[inline] + pub fn physical_device(&self) -> PhysicalDevice<'a> { + self.physical_device + } + + /// Returns the identifier of this queue family within the physical device. + #[inline] + pub fn id(&self) -> u32 { + self.id + } + + /// Returns the number of queues that belong to this family. + /// + /// Guaranteed to be at least 1 (or else that family wouldn't exist). + #[inline] + pub fn queues_count(&self) -> usize { + self.physical_device.infos().queue_families[self.id as usize].queueCount as usize + } + + /// If timestamps are supported, returns the number of bits supported by timestamp operations. + /// The returned value will be in the range 36..64. + /// If timestamps are not supported, returns None. + #[inline] + pub fn timestamp_valid_bits(&self) -> Option<u32> { + let value = self.physical_device.infos().queue_families[self.id as usize].timestampValidBits; + if value == 0 { + None + } else { + Some(value) + } + } + + /// Returns the minimum granularity supported for image transfers in terms + /// of `[width, height, depth]` + #[inline] + pub fn min_image_transfer_granularity(&self) -> [u32; 3] { + let ref granularity = self.physical_device.infos().queue_families[self.id as usize] + .minImageTransferGranularity; + [granularity.width, granularity.height, granularity.depth] + } + + /// Returns true if queues of this family can execute graphics operations. + #[inline] + pub fn supports_graphics(&self) -> bool { + (self.flags() & vk::QUEUE_GRAPHICS_BIT) != 0 + } + + /// Returns true if queues of this family can execute compute operations. + #[inline] + pub fn supports_compute(&self) -> bool { + (self.flags() & vk::QUEUE_COMPUTE_BIT) != 0 + } + + /// Returns true if queues of this family can execute transfer operations. + /// + /// > **Note**: Queues that support graphics or compute operations also always support transfer + /// > operations. As of writing this, this function will always return true. The purpose of + /// > this function is to be future-proofed in case queues that don't support transfer + /// > operations are ever added to Vulkan. + #[inline] + pub fn supports_transfers(&self) -> bool { + (self.flags() & vk::QUEUE_TRANSFER_BIT) != 0 || self.supports_graphics() || + self.supports_compute() + } + + /// Returns true if queues of this family can execute sparse resources binding operations. + #[inline] + pub fn supports_sparse_binding(&self) -> bool { + (self.flags() & vk::QUEUE_SPARSE_BINDING_BIT) != 0 + } + + /// Internal utility function that returns the flags of this queue family. + #[inline] + fn flags(&self) -> u32 { + self.physical_device.infos().queue_families[self.id as usize].queueFlags + } +} + +/// Iterator for all the queue families available on a physical device. +#[derive(Debug, Clone)] +pub struct QueueFamiliesIter<'a> { + physical_device: PhysicalDevice<'a>, + current_id: u32, +} + +impl<'a> Iterator for QueueFamiliesIter<'a> { + type Item = QueueFamily<'a>; + + #[inline] + fn next(&mut self) -> Option<QueueFamily<'a>> { + if self.current_id as usize >= self.physical_device.infos().queue_families.len() { + return None; + } + + let dev = QueueFamily { + physical_device: self.physical_device, + id: self.current_id, + }; + + self.current_id += 1; + Some(dev) + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + let len = self.physical_device.infos().queue_families.len(); + let remain = len - self.current_id as usize; + (remain, Some(remain)) + } +} + +impl<'a> ExactSizeIterator for QueueFamiliesIter<'a> { +} + +/// Represents a memory type in a physical device. +#[derive(Debug, Copy, Clone)] +pub struct MemoryType<'a> { + physical_device: PhysicalDevice<'a>, + id: u32, +} + +impl<'a> MemoryType<'a> { + /// Returns the physical device associated to this memory type. + #[inline] + pub fn physical_device(&self) -> PhysicalDevice<'a> { + self.physical_device + } + + /// Returns the identifier of this memory type within the physical device. + #[inline] + pub fn id(&self) -> u32 { + self.id + } + + /// Returns the heap that corresponds to this memory type. + #[inline] + pub fn heap(&self) -> MemoryHeap<'a> { + let heap_id = self.physical_device.infos().memory.memoryTypes[self.id as usize].heapIndex; + MemoryHeap { + physical_device: self.physical_device, + id: heap_id, + } + } + + /// Returns true if the memory type is located on the device, which means that it's the most + /// efficient for GPU accesses. + #[inline] + pub fn is_device_local(&self) -> bool { + (self.flags() & vk::MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0 + } + + /// Returns true if the memory type can be accessed by the host. + #[inline] + pub fn is_host_visible(&self) -> bool { + (self.flags() & vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0 + } + + /// Returns true if modifications made by the host or the GPU on this memory type are + /// instantaneously visible to the other party. False means that changes have to be flushed. + /// + /// You don't need to worry about this, as this library handles that for you. + #[inline] + pub fn is_host_coherent(&self) -> bool { + (self.flags() & vk::MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0 + } + + /// Returns true if memory of this memory type is cached by the host. Host memory accesses to + /// cached memory is faster than for uncached memory. However you are not guaranteed that it + /// is coherent. + #[inline] + pub fn is_host_cached(&self) -> bool { + (self.flags() & vk::MEMORY_PROPERTY_HOST_CACHED_BIT) != 0 + } + + /// Returns true if allocations made to this memory type is lazy. + /// + /// This means that no actual allocation is performed. Instead memory is automatically + /// allocated by the Vulkan implementation. + /// + /// Memory of this type can only be used on images created with a certain flag. Memory of this + /// type is never host-visible. + #[inline] + pub fn is_lazily_allocated(&self) -> bool { + (self.flags() & vk::MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) != 0 + } + + /// Internal utility function that returns the flags of this queue family. + #[inline] + fn flags(&self) -> u32 { + self.physical_device.infos().memory.memoryTypes[self.id as usize].propertyFlags + } +} + +/// Iterator for all the memory types available on a physical device. +#[derive(Debug, Clone)] +pub struct MemoryTypesIter<'a> { + physical_device: PhysicalDevice<'a>, + current_id: u32, +} + +impl<'a> Iterator for MemoryTypesIter<'a> { + type Item = MemoryType<'a>; + + #[inline] + fn next(&mut self) -> Option<MemoryType<'a>> { + if self.current_id >= self.physical_device.infos().memory.memoryTypeCount { + return None; + } + + let dev = MemoryType { + physical_device: self.physical_device, + id: self.current_id, + }; + + self.current_id += 1; + Some(dev) + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + let len = self.physical_device.infos().memory.memoryTypeCount; + let remain = (len - self.current_id) as usize; + (remain, Some(remain)) + } +} + +impl<'a> ExactSizeIterator for MemoryTypesIter<'a> { +} + +/// Represents a memory heap in a physical device. +#[derive(Debug, Copy, Clone)] +pub struct MemoryHeap<'a> { + physical_device: PhysicalDevice<'a>, + id: u32, +} + +impl<'a> MemoryHeap<'a> { + /// Returns the physical device associated to this memory heap. + #[inline] + pub fn physical_device(&self) -> PhysicalDevice<'a> { + self.physical_device + } + + /// Returns the identifier of this memory heap within the physical device. + #[inline] + pub fn id(&self) -> u32 { + self.id + } + + /// Returns the size in bytes on this heap. + #[inline] + pub fn size(&self) -> usize { + self.physical_device.infos().memory.memoryHeaps[self.id as usize].size as usize + } + + /// Returns true if the heap is local to the GPU. + #[inline] + pub fn is_device_local(&self) -> bool { + let flags = self.physical_device.infos().memory.memoryHeaps[self.id as usize].flags; + (flags & vk::MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0 + } +} + +/// Iterator for all the memory heaps available on a physical device. +#[derive(Debug, Clone)] +pub struct MemoryHeapsIter<'a> { + physical_device: PhysicalDevice<'a>, + current_id: u32, +} + +impl<'a> Iterator for MemoryHeapsIter<'a> { + type Item = MemoryHeap<'a>; + + #[inline] + fn next(&mut self) -> Option<MemoryHeap<'a>> { + if self.current_id >= self.physical_device.infos().memory.memoryHeapCount { + return None; + } + + let dev = MemoryHeap { + physical_device: self.physical_device, + id: self.current_id, + }; + + self.current_id += 1; + Some(dev) + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + let len = self.physical_device.infos().memory.memoryHeapCount; + let remain = (len - self.current_id) as usize; + (remain, Some(remain)) + } +} + +impl<'a> ExactSizeIterator for MemoryHeapsIter<'a> { +} + +#[cfg(test)] +mod tests { + use instance; + + #[test] + fn create_instance() { + let _ = instance!(); + } + + #[test] + fn queue_family_by_id() { + let instance = instance!(); + + let phys = match instance::PhysicalDevice::enumerate(&instance).next() { + Some(p) => p, + None => return, + }; + + let queue_family = match phys.queue_families().next() { + Some(q) => q, + None => return, + }; + + let by_id = phys.queue_family_by_id(queue_family.id()).unwrap(); + assert_eq!(by_id.id(), queue_family.id()); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/instance/layers.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/layers.rs new file mode 100644 index 0000000..f6e8e7a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/layers.rs @@ -0,0 +1,259 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::ffi::CStr; +use std::fmt; +use std::ptr; +use std::vec::IntoIter; + +use Error; +use OomError; +use check_errors; +use instance::loader; +use instance::loader::LoadingError; +use version::Version; +use vk; + +/// Queries the list of layers that are available when creating an instance. +/// +/// On success, this function returns an iterator that produces +/// [`LayerProperties`](struct.LayerProperties.html) objects. In order to enable a layer, you need +/// to pass its name (returned by `LayerProperties::name()`) when creating the +/// [`Instance`](struct.Instance.html). +/// +/// This function returns an error if it failed to load the Vulkan library. +/// +/// > **Note**: It is possible that one of the layers enumerated here is no longer available when +/// > you create the `Instance`. This will lead to an error when calling `Instance::new`. The +/// > author isn't aware of any situation where this would happen, but it is theoretically possible +/// > according to the specifications. +/// +/// # Example +/// +/// ```no_run +/// use vulkano::instance; +/// +/// for layer in instance::layers_list().unwrap() { +/// println!("Available layer: {}", layer.name()); +/// } +/// ``` +pub fn layers_list() -> Result<LayersIterator, LayersListError> { + layers_list_from_loader(loader::auto_loader()?) +} + +/// Same as `layers_list()`, but allows specifying a loader. +pub fn layers_list_from_loader<L>(ptrs: &loader::FunctionPointers<L>) + -> Result<LayersIterator, LayersListError> + where L: loader::Loader +{ + unsafe { + let entry_points = ptrs.entry_points(); + + let mut num = 0; + check_errors({ + entry_points.EnumerateInstanceLayerProperties(&mut num, ptr::null_mut()) + })?; + + let mut layers: Vec<vk::LayerProperties> = Vec::with_capacity(num as usize); + check_errors({ + entry_points + .EnumerateInstanceLayerProperties(&mut num, layers.as_mut_ptr()) + })?; + layers.set_len(num as usize); + + Ok(LayersIterator { iter: layers.into_iter() }) + } +} + +/// Properties of a layer. +pub struct LayerProperties { + props: vk::LayerProperties, +} + +impl LayerProperties { + /// Returns the name of the layer. + /// + /// If you want to enable this layer on an instance, you need to pass this value to + /// `Instance::new`. + /// + /// # Example + /// + /// ```no_run + /// use vulkano::instance; + /// + /// for layer in instance::layers_list().unwrap() { + /// println!("Layer name: {}", layer.name()); + /// } + /// ``` + #[inline] + pub fn name(&self) -> &str { + unsafe { + CStr::from_ptr(self.props.layerName.as_ptr()) + .to_str() + .unwrap() + } + } + + /// Returns a description of the layer. + /// + /// This description is chosen by the layer itself. + /// + /// # Example + /// + /// ```no_run + /// use vulkano::instance; + /// + /// for layer in instance::layers_list().unwrap() { + /// println!("Layer description: {}", layer.description()); + /// } + /// ``` + #[inline] + pub fn description(&self) -> &str { + unsafe { + CStr::from_ptr(self.props.description.as_ptr()) + .to_str() + .unwrap() + } + } + + /// Returns the version of Vulkan supported by this layer. + /// + /// # Example + /// + /// ```no_run + /// use vulkano::instance; + /// use vulkano::instance::Version; + /// + /// for layer in instance::layers_list().unwrap() { + /// if layer.vulkan_version() >= (Version { major: 2, minor: 0, patch: 0 }) { + /// println!("Layer {} requires Vulkan 2.0", layer.name()); + /// } + /// } + /// ``` + #[inline] + pub fn vulkan_version(&self) -> Version { + Version::from_vulkan_version(self.props.specVersion) + } + + /// Returns an implementation-specific version number for this layer. + /// + /// The number is chosen by the layer itself. It can be used for bug reports for example. + /// + /// # Example + /// + /// ```no_run + /// use vulkano::instance; + /// + /// for layer in instance::layers_list().unwrap() { + /// println!("Layer {} - Version: {}", layer.name(), layer.implementation_version()); + /// } + /// ``` + #[inline] + pub fn implementation_version(&self) -> u32 { + self.props.implementationVersion + } +} + +/// Error that can happen when loading the list of layers. +#[derive(Clone, Debug)] +pub enum LayersListError { + /// Failed to load the Vulkan shared library. + LoadingError(LoadingError), + /// Not enough memory. + OomError(OomError), +} + +impl error::Error for LayersListError { + #[inline] + fn description(&self) -> &str { + match *self { + LayersListError::LoadingError(_) => "failed to load the Vulkan shared library", + LayersListError::OomError(_) => "not enough memory available", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + LayersListError::LoadingError(ref err) => Some(err), + LayersListError::OomError(ref err) => Some(err), + } + } +} + +impl fmt::Display for LayersListError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for LayersListError { + #[inline] + fn from(err: OomError) -> LayersListError { + LayersListError::OomError(err) + } +} + +impl From<LoadingError> for LayersListError { + #[inline] + fn from(err: LoadingError) -> LayersListError { + LayersListError::LoadingError(err) + } +} + +impl From<Error> for LayersListError { + #[inline] + fn from(err: Error) -> LayersListError { + match err { + err @ Error::OutOfHostMemory => LayersListError::OomError(OomError::from(err)), + err @ Error::OutOfDeviceMemory => LayersListError::OomError(OomError::from(err)), + _ => panic!("unexpected error: {:?}", err), + } + } +} + +/// Iterator that produces the list of layers that are available. +// TODO: #[derive(Debug, Clone)] +pub struct LayersIterator { + iter: IntoIter<vk::LayerProperties>, +} + +impl Iterator for LayersIterator { + type Item = LayerProperties; + + #[inline] + fn next(&mut self) -> Option<LayerProperties> { + self.iter.next().map(|p| LayerProperties { props: p }) + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + self.iter.size_hint() + } +} + +impl ExactSizeIterator for LayersIterator { +} + +#[cfg(test)] +mod tests { + use instance; + + #[test] + fn layers_list() { + let mut list = match instance::layers_list() { + Ok(l) => l, + Err(_) => return, + }; + + while let Some(_) = list.next() {} + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/instance/limits.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/limits.rs new file mode 100644 index 0000000..5031a69 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/limits.rs @@ -0,0 +1,147 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! The `Limits` struct provides a nicer API around `vkPhysicalDeviceLimits`. + +use vk; + +/// Limits of a physical device. +pub struct Limits<'a> { + limits: &'a vk::PhysicalDeviceLimits, +} + +macro_rules! limits_impl { + ($($name:ident: $t:ty => $target:ident,)*) => ( + impl<'a> Limits<'a> { + /// Builds the `Limits` object. + #[inline] + pub(crate) fn from_vk_limits(limits: &'a vk::PhysicalDeviceLimits) -> Limits<'a> { + Limits { + limits + } + } + + $( + #[inline] + pub fn $name(&self) -> $t { + self.limits.$target + } + )* + } + ) +} + +limits_impl!{ + max_image_dimension_1d: u32 => maxImageDimension1D, + max_image_dimension_2d: u32 => maxImageDimension2D, + max_image_dimension_3d: u32 => maxImageDimension3D, + max_image_dimension_cube: u32 => maxImageDimensionCube, + max_image_array_layers: u32 => maxImageArrayLayers, + max_texel_buffer_elements: u32 => maxTexelBufferElements, + max_uniform_buffer_range: u32 => maxUniformBufferRange, + max_storage_buffer_range: u32 => maxStorageBufferRange, + max_push_constants_size: u32 => maxPushConstantsSize, + max_memory_allocation_count: u32 => maxMemoryAllocationCount, + max_sampler_allocation_count: u32 => maxSamplerAllocationCount, + buffer_image_granularity: u64 => bufferImageGranularity, + sparse_address_space_size: u64 => sparseAddressSpaceSize, + max_bound_descriptor_sets: u32 => maxBoundDescriptorSets, + max_per_stage_descriptor_samplers: u32 => maxPerStageDescriptorSamplers, + max_per_stage_descriptor_uniform_buffers: u32 => maxPerStageDescriptorUniformBuffers, + max_per_stage_descriptor_storage_buffers: u32 => maxPerStageDescriptorStorageBuffers, + max_per_stage_descriptor_sampled_images: u32 => maxPerStageDescriptorSampledImages, + max_per_stage_descriptor_storage_images: u32 => maxPerStageDescriptorStorageImages, + max_per_stage_descriptor_input_attachments: u32 => maxPerStageDescriptorInputAttachments, + max_per_stage_resources: u32 => maxPerStageResources, + max_descriptor_set_samplers: u32 => maxDescriptorSetSamplers, + max_descriptor_set_uniform_buffers: u32 => maxDescriptorSetUniformBuffers, + max_descriptor_set_uniform_buffers_dynamic: u32 => maxDescriptorSetUniformBuffersDynamic, + max_descriptor_set_storage_buffers: u32 => maxDescriptorSetStorageBuffers, + max_descriptor_set_storage_buffers_dynamic: u32 => maxDescriptorSetStorageBuffersDynamic, + max_descriptor_set_sampled_images: u32 => maxDescriptorSetSampledImages, + max_descriptor_set_storage_images: u32 => maxDescriptorSetStorageImages, + max_descriptor_set_input_attachments: u32 => maxDescriptorSetInputAttachments, + max_vertex_input_attributes: u32 => maxVertexInputAttributes, + max_vertex_input_bindings: u32 => maxVertexInputBindings, + max_vertex_input_attribute_offset: u32 => maxVertexInputAttributeOffset, + max_vertex_input_binding_stride: u32 => maxVertexInputBindingStride, + max_vertex_output_components: u32 => maxVertexOutputComponents, + max_tessellation_generation_level: u32 => maxTessellationGenerationLevel, + max_tessellation_patch_size: u32 => maxTessellationPatchSize, + max_tessellation_control_per_vertex_input_components: u32 => maxTessellationControlPerVertexInputComponents, + max_tessellation_control_per_vertex_output_components: u32 => maxTessellationControlPerVertexOutputComponents, + max_tessellation_control_per_patch_output_components: u32 => maxTessellationControlPerPatchOutputComponents, + max_tessellation_control_total_output_components: u32 => maxTessellationControlTotalOutputComponents, + max_tessellation_evaluation_input_components: u32 => maxTessellationEvaluationInputComponents, + max_tessellation_evaluation_output_components: u32 => maxTessellationEvaluationOutputComponents, + max_geometry_shader_invocations: u32 => maxGeometryShaderInvocations, + max_geometry_input_components: u32 => maxGeometryInputComponents, + max_geometry_output_components: u32 => maxGeometryOutputComponents, + max_geometry_output_vertices: u32 => maxGeometryOutputVertices, + max_geometry_total_output_components: u32 => maxGeometryTotalOutputComponents, + max_fragment_input_components: u32 => maxFragmentInputComponents, + max_fragment_output_attachments: u32 => maxFragmentOutputAttachments, + max_fragment_dual_src_attachments: u32 => maxFragmentDualSrcAttachments, + max_fragment_combined_output_resources: u32 => maxFragmentCombinedOutputResources, + max_compute_shared_memory_size: u32 => maxComputeSharedMemorySize, + max_compute_work_group_count: [u32; 3] => maxComputeWorkGroupCount, + max_compute_work_group_invocations: u32 => maxComputeWorkGroupInvocations, + max_compute_work_group_size: [u32; 3] => maxComputeWorkGroupSize, + sub_pixel_precision_bits: u32 => subPixelPrecisionBits, + sub_texel_precision_bits: u32 => subTexelPrecisionBits, + mipmap_precision_bits: u32 => mipmapPrecisionBits, + max_draw_indexed_index_value: u32 => maxDrawIndexedIndexValue, + max_draw_indirect_count: u32 => maxDrawIndirectCount, + max_sampler_lod_bias: f32 => maxSamplerLodBias, + max_sampler_anisotropy: f32 => maxSamplerAnisotropy, + max_viewports: u32 => maxViewports, + max_viewport_dimensions: [u32; 2] => maxViewportDimensions, + viewport_bounds_range: [f32; 2] => viewportBoundsRange, + viewport_sub_pixel_bits: u32 => viewportSubPixelBits, + min_memory_map_alignment: usize => minMemoryMapAlignment, + min_texel_buffer_offset_alignment: u64 => minTexelBufferOffsetAlignment, + min_uniform_buffer_offset_alignment: u64 => minUniformBufferOffsetAlignment, + min_storage_buffer_offset_alignment: u64 => minStorageBufferOffsetAlignment, + min_texel_offset: i32 => minTexelOffset, + max_texel_offset: u32 => maxTexelOffset, + min_texel_gather_offset: i32 => minTexelGatherOffset, + max_texel_gather_offset: u32 => maxTexelGatherOffset, + min_interpolation_offset: f32 => minInterpolationOffset, + max_interpolation_offset: f32 => maxInterpolationOffset, + sub_pixel_interpolation_offset_bits: u32 => subPixelInterpolationOffsetBits, + max_framebuffer_width: u32 => maxFramebufferWidth, + max_framebuffer_height: u32 => maxFramebufferHeight, + max_framebuffer_layers: u32 => maxFramebufferLayers, + framebuffer_color_sample_counts: u32 => framebufferColorSampleCounts, // FIXME: SampleCountFlag + framebuffer_depth_sample_counts: u32 => framebufferDepthSampleCounts, // FIXME: SampleCountFlag + framebuffer_stencil_sample_counts: u32 => framebufferStencilSampleCounts, // FIXME: SampleCountFlag + framebuffer_no_attachments_sample_counts: u32 => framebufferNoAttachmentsSampleCounts, // FIXME: SampleCountFlag + max_color_attachments: u32 => maxColorAttachments, + sampled_image_color_sample_counts: u32 => sampledImageColorSampleCounts, // FIXME: SampleCountFlag + sampled_image_integer_sample_counts: u32 => sampledImageIntegerSampleCounts, // FIXME: SampleCountFlag + sampled_image_depth_sample_counts: u32 => sampledImageDepthSampleCounts, // FIXME: SampleCountFlag + sampled_image_stencil_sample_counts: u32 => sampledImageStencilSampleCounts, // FIXME: SampleCountFlag + storage_image_sample_counts: u32 => storageImageSampleCounts, // FIXME: SampleCountFlag + max_sample_mask_words: u32 => maxSampleMaskWords, + timestamp_compute_and_graphics: u32 => timestampComputeAndGraphics, // TODO: these are booleans + timestamp_period: f32 => timestampPeriod, + max_clip_distances: u32 => maxClipDistances, + max_cull_distances: u32 => maxCullDistances, + max_combined_clip_and_cull_distances: u32 => maxCombinedClipAndCullDistances, + discrete_queue_priorities: u32 => discreteQueuePriorities, + point_size_range: [f32; 2] => pointSizeRange, + line_width_range: [f32; 2] => lineWidthRange, + point_size_granularity: f32 => pointSizeGranularity, + line_width_granularity: f32 => lineWidthGranularity, + strict_lines: u32 => strictLines, // TODO: these are booleans + standard_sample_locations: u32 => standardSampleLocations, // TODO: these are booleans + optimal_buffer_copy_offset_alignment: u64 => optimalBufferCopyOffsetAlignment, + optimal_buffer_copy_row_pitch_alignment: u64 => optimalBufferCopyRowPitchAlignment, + non_coherent_atom_size: u64 => nonCoherentAtomSize, +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/instance/loader.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/loader.rs new file mode 100644 index 0000000..80d7218 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/loader.rs @@ -0,0 +1,271 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Vulkan implementation loading system. +//! +//! Before vulkano can do anything, it first needs to find an implementation of Vulkan. A Vulkan +//! implementation is defined as a single `vkGetInstanceProcAddr` function, which can be accessed +//! through the `Loader` trait. +//! +//! This module provides various implementations of the `Loader` trait. +//! +//! Once you have a struct that implements `Loader`, you can create a `FunctionPointers` struct +//! from it and use this `FunctionPointers` struct to build an `Instance`. +//! +//! By default vulkano will use the `auto_loader()` function, which tries to automatically load +//! a Vulkan implementation from the system. + +use shared_library; +use std::error; +use std::fmt; +use std::mem; +use std::ops::Deref; +use std::os::raw::c_char; +use std::os::raw::c_void; +use std::path::Path; + +use SafeDeref; +use vk; + +/// Implemented on objects that grant access to a Vulkan implementation. +pub unsafe trait Loader { + /// Calls the `vkGetInstanceProcAddr` function. The parameters are the same. + /// + /// The returned function must stay valid for as long as `self` is alive. + fn get_instance_proc_addr(&self, instance: vk::Instance, name: *const c_char) + -> extern "system" fn() -> (); +} + +unsafe impl<T> Loader for T + where T: SafeDeref, + T::Target: Loader +{ + #[inline] + fn get_instance_proc_addr(&self, instance: vk::Instance, name: *const c_char) + -> extern "system" fn() -> () { + (**self).get_instance_proc_addr(instance, name) + } +} + +/// Implementation of `Loader` that loads Vulkan from a dynamic library. +pub struct DynamicLibraryLoader { + vk_lib: shared_library::dynamic_library::DynamicLibrary, + get_proc_addr: extern "system" fn(instance: vk::Instance, pName: *const c_char) + -> extern "system" fn() -> (), +} + +impl DynamicLibraryLoader { + /// Tries to load the dynamic library at the given path, and tries to + /// load `vkGetInstanceProcAddr` in it. + /// + /// # Safety + /// + /// - The dynamic library must be a valid Vulkan implementation. + /// + pub unsafe fn new<P>(path: P) -> Result<DynamicLibraryLoader, LoadingError> + where P: AsRef<Path> + { + let vk_lib = shared_library::dynamic_library::DynamicLibrary::open(Some(path.as_ref())) + .map_err(LoadingError::LibraryLoadFailure)?; + + let get_proc_addr = { + let ptr: *mut c_void = + vk_lib + .symbol("vkGetInstanceProcAddr") + .map_err(|_| { + LoadingError::MissingEntryPoint("vkGetInstanceProcAddr".to_owned()) + })?; + mem::transmute(ptr) + }; + + Ok(DynamicLibraryLoader { + vk_lib, + get_proc_addr, + }) + } +} + +unsafe impl Loader for DynamicLibraryLoader { + #[inline] + fn get_instance_proc_addr(&self, instance: vk::Instance, name: *const c_char) + -> extern "system" fn() -> () { + (self.get_proc_addr)(instance, name) + } +} + +/// Wraps around a loader and contains function pointers. +pub struct FunctionPointers<L> { + loader: L, + entry_points: vk::EntryPoints, +} + +impl<L> FunctionPointers<L> { + /// Loads some global function pointer from the loader. + pub fn new(loader: L) -> FunctionPointers<L> + where L: Loader + { + let entry_points = vk::EntryPoints::load(|name| unsafe { mem::transmute(loader.get_instance_proc_addr(0, name.as_ptr())) }); + + FunctionPointers { + loader, + entry_points, + } + } + + /// Returns the collection of Vulkan entry points from the Vulkan loader. + #[inline] + pub(crate) fn entry_points(&self) -> &vk::EntryPoints { + &self.entry_points + } + + /// Calls `get_instance_proc_addr` on the underlying loader. + #[inline] + pub fn get_instance_proc_addr(&self, instance: vk::Instance, name: *const c_char) + -> extern "system" fn() -> () + where L: Loader + { + self.loader.get_instance_proc_addr(instance, name) + } +} + +/// Expression that returns a loader that assumes that Vulkan is linked to the executable you're +/// compiling. +/// +/// If you use this macro, you must linked to a library that provides the `vkGetInstanceProcAddr` +/// symbol. +/// +/// This is provided as a macro and not as a regular function, because the macro contains an +/// `extern {}` block. +// TODO: should this be unsafe? +#[macro_export] +macro_rules! statically_linked_vulkan_loader { + () => ({ + extern "C" { + fn vkGetInstanceProcAddr(instance: vk::Instance, pName: *const c_char) + -> vk::PFN_vkVoidFunction; + } + + struct StaticallyLinkedVulkanLoader; + unsafe impl Loader for StaticallyLinkedVulkanLoader { + fn get_instance_proc_addr(&self, instance: vk::Instance, name: *const c_char) + -> extern "system" fn() -> () { + unsafe { vkGetInstanceProcAddr(instance, name) } + } + } + + StaticallyLinkedVulkanLoader + }) +} + +/// Returns the default `FunctionPointers` for this system. +/// +/// This function tries to auto-guess where to find the Vulkan implementation, and loads it in a +/// `lazy_static!`. The content of the lazy_static is then returned, or an error if we failed to +/// load Vulkan. +pub fn auto_loader() + -> Result<&'static FunctionPointers<Box<Loader + Send + Sync>>, LoadingError> +{ + #[cfg(target_os = "ios")] + #[allow(non_snake_case)] + fn def_loader_impl() -> Result<Box<Loader + Send + Sync>, LoadingError> { + let loader = statically_linked_vulkan_loader!(); + Ok(Box::new(loader)) + } + + #[cfg(not(target_os = "ios"))] + fn def_loader_impl() -> Result<Box<Loader + Send + Sync>, LoadingError> { + #[cfg(windows)] + fn get_path() -> &'static Path { + Path::new("vulkan-1.dll") + } + #[cfg(all(unix, not(target_os = "android"), not(target_os = "macos")))] + fn get_path() -> &'static Path { + Path::new("libvulkan.so.1") + } + #[cfg(target_os = "macos")] + fn get_path() -> &'static Path { + Path::new("libvulkan.1.dylib") + } + #[cfg(target_os = "android")] + fn get_path() -> &'static Path { + Path::new("libvulkan.so") + } + + let loader = unsafe { DynamicLibraryLoader::new(get_path())? }; + + Ok(Box::new(loader)) + } + + lazy_static! { + static ref DEFAULT_LOADER: Result<FunctionPointers<Box<Loader + Send + Sync>>, LoadingError> = { + def_loader_impl().map(FunctionPointers::new) + }; + } + + match DEFAULT_LOADER.deref() { + &Ok(ref ptr) => Ok(ptr), + &Err(ref err) => Err(err.clone()), + } +} + +/// Error that can happen when loading the Vulkan loader. +#[derive(Debug, Clone)] +pub enum LoadingError { + /// Failed to load the Vulkan shared library. + LibraryLoadFailure(String), // TODO: meh for error type, but this needs changes in shared_library + + /// One of the entry points required to be supported by the Vulkan implementation is missing. + MissingEntryPoint(String), +} + +impl error::Error for LoadingError { + #[inline] + fn description(&self) -> &str { + match *self { + LoadingError::LibraryLoadFailure(_) => { + "failed to load the Vulkan shared library" + }, + LoadingError::MissingEntryPoint(_) => { + "one of the entry points required to be supported by the Vulkan implementation \ + is missing" + }, + } + } + + /*#[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + LoadingError::LibraryLoadFailure(ref err) => Some(err), + _ => None + } + }*/ +} + +impl fmt::Display for LoadingError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +#[cfg(test)] +mod tests { + use instance::loader::DynamicLibraryLoader; + use instance::loader::LoadingError; + + #[test] + fn dl_open_error() { + unsafe { + match DynamicLibraryLoader::new("_non_existing_library.void") { + Err(LoadingError::LibraryLoadFailure(_)) => (), + _ => panic!(), + } + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/instance/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/mod.rs new file mode 100644 index 0000000..e8afa39 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/instance/mod.rs @@ -0,0 +1,137 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! API entry point. +//! +//! The first thing to do before you start using Vulkan is to create an `Instance` object. +//! +//! For example: +//! +//! ```no_run +//! use vulkano::instance::Instance; +//! use vulkano::instance::InstanceExtensions; +//! +//! let instance = match Instance::new(None, &InstanceExtensions::none(), None) { +//! Ok(i) => i, +//! Err(err) => panic!("Couldn't build instance: {:?}", err) +//! }; +//! ``` +//! +//! Creating an instance initializes everything and allows you to enumerate physical devices, +//! ie. all the Vulkan implementations that are available on the system. +//! +//! ```no_run +//! # use vulkano::instance::Instance; +//! # use vulkano::instance::InstanceExtensions; +//! use vulkano::instance::PhysicalDevice; +//! +//! # let instance = Instance::new(None, &InstanceExtensions::none(), None).unwrap(); +//! for physical_device in PhysicalDevice::enumerate(&instance) { +//! println!("Available device: {}", physical_device.name()); +//! } +//! ``` +//! +//! # Extensions +//! +//! Notice the second parameter of `Instance::new()`. It is an `InstanceExtensions` struct that +//! contains a list of extensions that must be enabled on the newly-created instance. Trying to +//! enable an extension that is not supported by the system will result in an error. +//! +//! Contrary to OpenGL, it is not possible to use the features of an extension if it was not +//! explicitly enabled. +//! +//! Extensions are especially important to take into account if you want to render images on the +//! screen, as the only way to do so is to use the `VK_KHR_surface` extension. More information +//! about this in the `swapchain` module. +//! +//! For example, here is how we create an instance with the `VK_KHR_surface` and +//! `VK_KHR_android_surface` extensions enabled, which will allow us to render images to an +//! Android screen. You can compile and run this code on any system, but it is highly unlikely to +//! succeed on anything else than an Android-running device. +//! +//! ```no_run +//! use vulkano::instance::Instance; +//! use vulkano::instance::InstanceExtensions; +//! +//! let extensions = InstanceExtensions { +//! khr_surface: true, +//! khr_android_surface: true, +//! .. InstanceExtensions::none() +//! }; +//! +//! let instance = match Instance::new(None, &extensions, None) { +//! Ok(i) => i, +//! Err(err) => panic!("Couldn't build instance: {:?}", err) +//! }; +//! ``` +//! +//! # Application info +//! +//! When you create an instance, you have the possibility to pass an `ApplicationInfo` struct as +//! the first parameter. This struct contains various information about your application, most +//! notably its name and engine. +//! +//! Passing such a structure allows for example the driver to let the user configure the driver's +//! behavior for your application alone through a control panel. +//! +//! ```no_run +//! # #[macro_use] extern crate vulkano; +//! # fn main() { +//! use vulkano::instance::{Instance, InstanceExtensions}; +//! +//! // Builds an `ApplicationInfo` by looking at the content of the `Cargo.toml` file at +//! // compile-time. +//! let app_infos = app_info_from_cargo_toml!(); +//! +//! let _instance = Instance::new(Some(&app_infos), &InstanceExtensions::none(), None).unwrap(); +//! # } +//! ``` +//! +//! # Enumerating physical devices and creating a device +//! +//! After you have created an instance, the next step is usually to enumerate the physical devices +//! that are available on the system with `PhysicalDevice::enumerate()` (see above). +//! +//! When choosing which physical device to use, keep in mind that physical devices may or may not +//! be able to draw to a certain surface (ie. to a window or a monitor), or may even not be able +//! to draw at all. See the `swapchain` module for more information about surfaces. +//! +//! Once you have chosen a physical device, you can create a `Device` object from it. See the +//! `device` module for more info. +//! + +pub use self::extensions::InstanceExtensions; +pub use self::extensions::RawInstanceExtensions; +pub use self::instance::ApplicationInfo; +pub use self::instance::Instance; +pub use self::instance::InstanceCreationError; +pub use self::instance::MemoryHeap; +pub use self::instance::MemoryHeapsIter; +pub use self::instance::MemoryType; +pub use self::instance::MemoryTypesIter; +pub use self::instance::PhysicalDevice; +pub use self::instance::PhysicalDeviceType; +pub use self::instance::PhysicalDevicesIter; +pub use self::instance::QueueFamiliesIter; +pub use self::instance::QueueFamily; +pub use self::layers::LayerProperties; +pub use self::layers::LayersIterator; +pub use self::layers::LayersListError; +pub use self::layers::layers_list; +pub use self::limits::Limits; +pub use self::loader::LoadingError; +pub use version::Version; + +pub mod debug; +pub mod loader; + +mod extensions; +mod instance; +mod layers; +mod limits; diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/lib.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/lib.rs new file mode 100644 index 0000000..120e705 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/lib.rs @@ -0,0 +1,256 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +#![doc(html_logo_url = "https://raw.githubusercontent.com/vulkano-rs/vulkano/master/logo.png")] +//! Safe and rich Rust wrapper around the Vulkan API. +//! +//! # Brief summary of Vulkan +//! +//! - The [`Instance`](instance/struct.Instance.html) object is the API entry point. It is the +//! first object you must create before starting to use Vulkan. +//! +//! - The [`PhysicalDevice`](instance/struct.PhysicalDevice.html) object represents an +//! implementation of Vulkan available on the system (eg. a graphics card, a software +//! implementation, etc.). Physical devices can be enumerated from an instance with +//! [`PhysicalDevice::enumerate()`](instance/struct.PhysicalDevice.html#method.enumerate). +//! +//! - Once you have chosen a physical device to use, you can create a +//! [`Device`](device/index.html) object from it. The `Device` is the most important +//! object of Vulkan, as it represents an open channel of communication with a physical device. +//! You always need to have one before you can do interesting things with Vulkan. +//! +//! - [*Buffers*](buffer/index.html) and [*images*](image/index.html) can be used to store data on +//! memory accessible by the GPU (or more generally by the Vulkan implementation). Buffers are +//! usually used to store information about vertices, lights, etc. or arbitrary data, while +//! images are used to store textures or multi-dimensional data. +//! +//! - In order to show something on the screen, you need a [`Swapchain`](swapchain/index.html). +//! A `Swapchain` contains special `Image`s that correspond to the content of the window or the +//! monitor. When you *present* a swapchain, the content of one of these special images is shown +//! on the screen. +//! +//! - In order to ask the GPU to do something, you must create a +//! [*command buffer*](command_buffer/index.html). A command buffer contains a list of commands +//! that the GPU must perform. This can include copies between buffers and images, compute +//! operations, or graphics operations. For the work to start, the command buffer must then be +//! submitted to a [`Queue`](device/struct.Queue.html), which is obtained when you create the +//! `Device`. +//! +//! - In order to be able to add a compute operation or a graphics operation to a command buffer, +//! you need to have created a [`ComputePipeline` or a `GraphicsPipeline` +//! object](pipeline/index.html) that describes the operation you want. These objects are usually +//! created during your program's initialization. `Shader`s are programs that the GPU will +//! execute as part of a pipeline. [*Descriptors*](descriptor/index.html) can be used to access +//! the content of buffers or images from within shaders. +//! +//! - For graphical operations, [`RenderPass`es and `Framebuffer`s](framebuffer/index.html) +//! describe on which images the implementation must draw upon. +//! +//! - Once you have built a *command buffer* that contains a list of commands, submitting it to the +//! GPU will return an object that implements [the `GpuFuture` trait](sync/index.html). +//! `GpuFuture`s allow you to chain multiple submissions together and are essential to performing +//! multiple operations on multiple different GPU queues. +//! + +//#![warn(missing_docs)] // TODO: activate +#![allow(dead_code)] // TODO: remove +#![allow(unused_variables)] // TODO: remove + +extern crate crossbeam; +extern crate fnv; +#[macro_use] +extern crate lazy_static; +extern crate shared_library; +extern crate smallvec; +extern crate vk_sys as vk; +pub extern crate half; + +#[macro_use] +mod tests; + +#[macro_use] +mod extensions; +mod features; +mod version; + +pub mod buffer; +pub mod command_buffer; +pub mod descriptor; +pub mod device; +pub mod format; +#[macro_use] +pub mod framebuffer; +pub mod image; +pub mod instance; +pub mod memory; +pub mod pipeline; +pub mod query; +pub mod sampler; +pub mod swapchain; +pub mod sync; + +use std::error; +use std::fmt; +use std::ops::Deref; +use std::sync::Arc; +use std::sync::MutexGuard; + +/// Alternative to the `Deref` trait. Contrary to `Deref`, must always return the same object. +pub unsafe trait SafeDeref: Deref {} +unsafe impl<'a, T: ?Sized> SafeDeref for &'a T { +} +unsafe impl<T: ?Sized> SafeDeref for Arc<T> { +} +unsafe impl<T: ?Sized> SafeDeref for Box<T> { +} + +pub trait VulkanHandle { + fn value(&self) -> u64; +} + +impl VulkanHandle for usize { + #[inline] + fn value(&self) -> u64 { *self as u64 } +} +impl VulkanHandle for u64 { + #[inline] + fn value(&self) -> u64 { *self } +} + +/// Gives access to the internal identifier of an object. +pub unsafe trait VulkanObject { + /// The type of the object. + type Object: VulkanHandle; + + /// The `DebugReportObjectTypeEXT` of the internal Vulkan handle. + const TYPE: vk::DebugReportObjectTypeEXT; + + /// Returns a reference to the object. + fn internal_object(&self) -> Self::Object; +} + +/// Gives access to the internal identifier of an object. +// TODO: remove ; crappy design +pub unsafe trait SynchronizedVulkanObject { + /// The type of the object. + type Object: VulkanHandle; + + /// Returns a reference to the object. + fn internal_object_guard(&self) -> MutexGuard<Self::Object>; +} + +/// Error type returned by most Vulkan functions. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum OomError { + /// There is no memory available on the host (ie. the CPU, RAM, etc.). + OutOfHostMemory, + /// There is no memory available on the device (ie. video memory). + OutOfDeviceMemory, +} + +impl error::Error for OomError { + #[inline] + fn description(&self) -> &str { + match *self { + OomError::OutOfHostMemory => "no memory available on the host", + OomError::OutOfDeviceMemory => "no memory available on the graphical device", + } + } +} + +impl fmt::Display for OomError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for OomError { + #[inline] + fn from(err: Error) -> OomError { + match err { + Error::OutOfHostMemory => OomError::OutOfHostMemory, + Error::OutOfDeviceMemory => OomError::OutOfDeviceMemory, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +/// All possible success codes returned by any Vulkan function. +#[derive(Debug, Copy, Clone)] +#[repr(u32)] +enum Success { + Success = vk::SUCCESS, + NotReady = vk::NOT_READY, + Timeout = vk::TIMEOUT, + EventSet = vk::EVENT_SET, + EventReset = vk::EVENT_RESET, + Incomplete = vk::INCOMPLETE, + Suboptimal = vk::SUBOPTIMAL_KHR, +} + +/// All possible errors returned by any Vulkan function. +/// +/// This type is not public. Instead all public error types should implement `From<Error>` and +/// panic for error code that aren't supposed to happen. +#[derive(Debug, Copy, Clone)] +#[repr(u32)] +// TODO: being pub is necessary because of the weird visibility rules in rustc +pub(crate) enum Error { + OutOfHostMemory = vk::ERROR_OUT_OF_HOST_MEMORY, + OutOfDeviceMemory = vk::ERROR_OUT_OF_DEVICE_MEMORY, + InitializationFailed = vk::ERROR_INITIALIZATION_FAILED, + DeviceLost = vk::ERROR_DEVICE_LOST, + MemoryMapFailed = vk::ERROR_MEMORY_MAP_FAILED, + LayerNotPresent = vk::ERROR_LAYER_NOT_PRESENT, + ExtensionNotPresent = vk::ERROR_EXTENSION_NOT_PRESENT, + FeatureNotPresent = vk::ERROR_FEATURE_NOT_PRESENT, + IncompatibleDriver = vk::ERROR_INCOMPATIBLE_DRIVER, + TooManyObjects = vk::ERROR_TOO_MANY_OBJECTS, + FormatNotSupported = vk::ERROR_FORMAT_NOT_SUPPORTED, + SurfaceLost = vk::ERROR_SURFACE_LOST_KHR, + NativeWindowInUse = vk::ERROR_NATIVE_WINDOW_IN_USE_KHR, + OutOfDate = vk::ERROR_OUT_OF_DATE_KHR, + IncompatibleDisplay = vk::ERROR_INCOMPATIBLE_DISPLAY_KHR, + ValidationFailed = vk::ERROR_VALIDATION_FAILED_EXT, + OutOfPoolMemory = vk::ERROR_OUT_OF_POOL_MEMORY_KHR, +} + +/// Checks whether the result returned correctly. +fn check_errors(result: vk::Result) -> Result<Success, Error> { + match result { + vk::SUCCESS => Ok(Success::Success), + vk::NOT_READY => Ok(Success::NotReady), + vk::TIMEOUT => Ok(Success::Timeout), + vk::EVENT_SET => Ok(Success::EventSet), + vk::EVENT_RESET => Ok(Success::EventReset), + vk::INCOMPLETE => Ok(Success::Incomplete), + vk::ERROR_OUT_OF_HOST_MEMORY => Err(Error::OutOfHostMemory), + vk::ERROR_OUT_OF_DEVICE_MEMORY => Err(Error::OutOfDeviceMemory), + vk::ERROR_INITIALIZATION_FAILED => Err(Error::InitializationFailed), + vk::ERROR_DEVICE_LOST => Err(Error::DeviceLost), + vk::ERROR_MEMORY_MAP_FAILED => Err(Error::MemoryMapFailed), + vk::ERROR_LAYER_NOT_PRESENT => Err(Error::LayerNotPresent), + vk::ERROR_EXTENSION_NOT_PRESENT => Err(Error::ExtensionNotPresent), + vk::ERROR_FEATURE_NOT_PRESENT => Err(Error::FeatureNotPresent), + vk::ERROR_INCOMPATIBLE_DRIVER => Err(Error::IncompatibleDriver), + vk::ERROR_TOO_MANY_OBJECTS => Err(Error::TooManyObjects), + vk::ERROR_FORMAT_NOT_SUPPORTED => Err(Error::FormatNotSupported), + vk::ERROR_SURFACE_LOST_KHR => Err(Error::SurfaceLost), + vk::ERROR_NATIVE_WINDOW_IN_USE_KHR => Err(Error::NativeWindowInUse), + vk::SUBOPTIMAL_KHR => Ok(Success::Suboptimal), + vk::ERROR_OUT_OF_DATE_KHR => Err(Error::OutOfDate), + vk::ERROR_INCOMPATIBLE_DISPLAY_KHR => Err(Error::IncompatibleDisplay), + vk::ERROR_VALIDATION_FAILED_EXT => Err(Error::ValidationFailed), + vk::ERROR_OUT_OF_POOL_MEMORY_KHR => Err(Error::OutOfPoolMemory), + vk::ERROR_INVALID_SHADER_NV => panic!("Vulkan function returned \ + VK_ERROR_INVALID_SHADER_NV"), + c => unreachable!("Unexpected error code returned by Vulkan: {}", c), + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/memory/device_memory.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/device_memory.rs new file mode 100644 index 0000000..ab9958a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/device_memory.rs @@ -0,0 +1,597 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::mem; +use std::ops::Deref; +use std::ops::DerefMut; +use std::ops::Range; +use std::os::raw::c_void; +use std::ptr; +use std::sync::Arc; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use device::Device; +use device::DeviceOwned; +use instance::MemoryType; +use memory::Content; +use memory::DedicatedAlloc; +use vk; + +/// Represents memory that has been allocated. +/// +/// The destructor of `DeviceMemory` automatically frees the memory. +/// +/// # Example +/// +/// ``` +/// use vulkano::memory::DeviceMemory; +/// +/// # let device: std::sync::Arc<vulkano::device::Device> = return; +/// let mem_ty = device.physical_device().memory_types().next().unwrap(); +/// +/// // Allocates 1KB of memory. +/// let memory = DeviceMemory::alloc(device.clone(), mem_ty, 1024).unwrap(); +/// ``` +pub struct DeviceMemory { + memory: vk::DeviceMemory, + device: Arc<Device>, + size: usize, + memory_type_index: u32, +} + +impl DeviceMemory { + /// Allocates a chunk of memory from the device. + /// + /// Some platforms may have a limit on the maximum size of a single allocation. For example, + /// certain systems may fail to create allocations with a size greater than or equal to 4GB. + /// + /// # Panic + /// + /// - Panics if `size` is 0. + /// - Panics if `memory_type` doesn't belong to the same physical device as `device`. + /// + #[inline] + pub fn alloc(device: Arc<Device>, memory_type: MemoryType, size: usize) + -> Result<DeviceMemory, DeviceMemoryAllocError> { + DeviceMemory::dedicated_alloc(device, memory_type, size, DedicatedAlloc::None) + } + + /// Same as `alloc`, but allows specifying a resource that will be bound to the memory. + /// + /// If a buffer or an image is specified in `resource`, then the returned memory must not be + /// bound to a different buffer or image. + /// + /// If the `VK_KHR_dedicated_allocation` extension is enabled on the device, then it will be + /// used by this method. Otherwise the `resource` parameter will be ignored. + #[inline] + pub fn dedicated_alloc(device: Arc<Device>, memory_type: MemoryType, size: usize, + resource: DedicatedAlloc) + -> Result<DeviceMemory, DeviceMemoryAllocError> { + assert!(size >= 1); + assert_eq!(device.physical_device().internal_object(), + memory_type.physical_device().internal_object()); + + // Note: This check is disabled because MoltenVK doesn't report correct heap sizes yet. + // More generally, whether or not this check is useful is questionable. + // TODO: ^ + /*if size > memory_type.heap().size() { + return Err(OomError::OutOfDeviceMemory); + }*/ + + let memory = unsafe { + let physical_device = device.physical_device(); + let mut allocation_count = device.allocation_count().lock().expect("Poisoned mutex"); + if *allocation_count >= physical_device.limits().max_memory_allocation_count() { + return Err(DeviceMemoryAllocError::TooManyObjects); + } + let vk = device.pointers(); + + // Decide whether we are going to pass a `vkMemoryDedicatedAllocateInfoKHR`. + let dedicated_alloc_info = if device.loaded_extensions().khr_dedicated_allocation { + match resource { + DedicatedAlloc::Buffer(buffer) => { + Some(vk::MemoryDedicatedAllocateInfoKHR { + sType: vk::STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR, + pNext: ptr::null(), + image: 0, + buffer: buffer.internal_object(), + }) + }, + DedicatedAlloc::Image(image) => { + Some(vk::MemoryDedicatedAllocateInfoKHR { + sType: vk::STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR, + pNext: ptr::null(), + image: image.internal_object(), + buffer: 0, + }) + }, + DedicatedAlloc::None => { + None + }, + } + } else { + None + }; + + let infos = vk::MemoryAllocateInfo { + sType: vk::STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, + pNext: dedicated_alloc_info + .as_ref() + .map(|i| i as *const vk::MemoryDedicatedAllocateInfoKHR) + .unwrap_or(ptr::null()) as *const _, + allocationSize: size as u64, + memoryTypeIndex: memory_type.id(), + }; + + let mut output = mem::uninitialized(); + check_errors(vk.AllocateMemory(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + *allocation_count += 1; + output + }; + + Ok(DeviceMemory { + memory: memory, + device: device, + size: size, + memory_type_index: memory_type.id(), + }) + } + + /// Allocates a chunk of memory and maps it. + /// + /// # Panic + /// + /// - Panics if `memory_type` doesn't belong to the same physical device as `device`. + /// - Panics if the memory type is not host-visible. + /// + #[inline] + pub fn alloc_and_map(device: Arc<Device>, memory_type: MemoryType, size: usize) + -> Result<MappedDeviceMemory, DeviceMemoryAllocError> { + DeviceMemory::dedicated_alloc_and_map(device, memory_type, size, DedicatedAlloc::None) + } + + /// Equivalent of `dedicated_alloc` for `alloc_and_map`. + pub fn dedicated_alloc_and_map(device: Arc<Device>, memory_type: MemoryType, size: usize, + resource: DedicatedAlloc) + -> Result<MappedDeviceMemory, DeviceMemoryAllocError> { + let vk = device.pointers(); + + assert!(memory_type.is_host_visible()); + let mem = DeviceMemory::dedicated_alloc(device.clone(), memory_type, size, resource)?; + + let coherent = memory_type.is_host_coherent(); + + let ptr = unsafe { + let mut output = mem::uninitialized(); + check_errors(vk.MapMemory(device.internal_object(), + mem.memory, + 0, + mem.size as vk::DeviceSize, + 0, /* reserved flags */ + &mut output))?; + output + }; + + Ok(MappedDeviceMemory { + memory: mem, + pointer: ptr, + coherent: coherent, + }) + } + + /// Returns the memory type this chunk was allocated on. + #[inline] + pub fn memory_type(&self) -> MemoryType { + self.device + .physical_device() + .memory_type_by_id(self.memory_type_index) + .unwrap() + } + + /// Returns the size in bytes of that memory chunk. + #[inline] + pub fn size(&self) -> usize { + self.size + } +} + +unsafe impl DeviceOwned for DeviceMemory { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl fmt::Debug for DeviceMemory { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("DeviceMemory") + .field("device", &*self.device) + .field("memory_type", &self.memory_type()) + .field("size", &self.size) + .finish() + } +} + +unsafe impl VulkanObject for DeviceMemory { + type Object = vk::DeviceMemory; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT; + + #[inline] + fn internal_object(&self) -> vk::DeviceMemory { + self.memory + } +} + +impl Drop for DeviceMemory { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.FreeMemory(self.device.internal_object(), self.memory, ptr::null()); + let mut allocation_count = self.device + .allocation_count() + .lock() + .expect("Poisoned mutex"); + *allocation_count -= 1; + } + } +} + +/// Represents memory that has been allocated and mapped in CPU accessible space. +/// +/// Can be obtained with `DeviceMemory::alloc_and_map`. The function will panic if the memory type +/// is not host-accessible. +/// +/// In order to access the content of the allocated memory, you can use the `read_write` method. +/// This method returns a guard object that derefs to the content. +/// +/// # Example +/// +/// ``` +/// use vulkano::memory::DeviceMemory; +/// +/// # let device: std::sync::Arc<vulkano::device::Device> = return; +/// // The memory type must be mappable. +/// let mem_ty = device.physical_device().memory_types() +/// .filter(|t| t.is_host_visible()) +/// .next().unwrap(); // Vk specs guarantee that this can't fail +/// +/// // Allocates 1KB of memory. +/// let memory = DeviceMemory::alloc_and_map(device.clone(), mem_ty, 1024).unwrap(); +/// +/// // Get access to the content. Note that this is very unsafe for two reasons: 1) the content is +/// // uninitialized, and 2) the access is unsynchronized. +/// unsafe { +/// let mut content = memory.read_write::<[u8]>(0 .. 1024); +/// content[12] = 54; // `content` derefs to a `&[u8]` or a `&mut [u8]` +/// } +/// ``` +pub struct MappedDeviceMemory { + memory: DeviceMemory, + pointer: *mut c_void, + coherent: bool, +} + +// Note that `MappedDeviceMemory` doesn't implement `Drop`, as we don't need to unmap memory before +// freeing it. +// +// Vulkan specs, documentation of `vkFreeMemory`: +// > If a memory object is mapped at the time it is freed, it is implicitly unmapped. +// + +impl MappedDeviceMemory { + /// Unmaps the memory. It will no longer be accessible from the CPU. + pub fn unmap(self) -> DeviceMemory { + unsafe { + let device = self.memory.device(); + let vk = device.pointers(); + vk.UnmapMemory(device.internal_object(), self.memory.memory); + } + + self.memory + } + + /// Gives access to the content of the memory. + /// + /// This function takes care of calling `vkInvalidateMappedMemoryRanges` and + /// `vkFlushMappedMemoryRanges` on the given range. You are therefore encouraged to use the + /// smallest range as possible, and to not call this function multiple times in a row for + /// several small changes. + /// + /// # Safety + /// + /// - Type safety is not checked. You must ensure that `T` corresponds to the content of the + /// buffer. + /// - Accesses are not synchronized. Synchronization must be handled outside of + /// the `MappedDeviceMemory`. + /// + #[inline] + pub unsafe fn read_write<T: ?Sized>(&self, range: Range<usize>) -> CpuAccess<T> + where T: Content + { + let vk = self.memory.device().pointers(); + let pointer = T::ref_from_ptr((self.pointer as usize + range.start) as *mut _, + range.end - range.start) + .unwrap(); // TODO: error + + if !self.coherent { + let range = vk::MappedMemoryRange { + sType: vk::STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, + pNext: ptr::null(), + memory: self.memory.internal_object(), + offset: range.start as u64, + size: (range.end - range.start) as u64, + }; + + // TODO: check result? + vk.InvalidateMappedMemoryRanges(self.memory.device().internal_object(), 1, &range); + } + + CpuAccess { + pointer: pointer, + mem: self, + coherent: self.coherent, + range: range, + } + } +} + +impl AsRef<DeviceMemory> for MappedDeviceMemory { + #[inline] + fn as_ref(&self) -> &DeviceMemory { + &self.memory + } +} + +impl AsMut<DeviceMemory> for MappedDeviceMemory { + #[inline] + fn as_mut(&mut self) -> &mut DeviceMemory { + &mut self.memory + } +} + +unsafe impl DeviceOwned for MappedDeviceMemory { + #[inline] + fn device(&self) -> &Arc<Device> { + self.memory.device() + } +} + +unsafe impl Send for MappedDeviceMemory { +} +unsafe impl Sync for MappedDeviceMemory { +} + +impl fmt::Debug for MappedDeviceMemory { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_tuple("MappedDeviceMemory") + .field(&self.memory) + .finish() + } +} + +/// Object that can be used to read or write the content of a `MappedDeviceMemory`. +/// +/// This object derefs to the content, just like a `MutexGuard` for example. +pub struct CpuAccess<'a, T: ?Sized + 'a> { + pointer: *mut T, + mem: &'a MappedDeviceMemory, + coherent: bool, + range: Range<usize>, +} + +impl<'a, T: ?Sized + 'a> CpuAccess<'a, T> { + /// Builds a new `CpuAccess` to access a sub-part of the current `CpuAccess`. + /// + /// This function is unstable. Don't use it directly. + // TODO: unsafe? + // TODO: decide what to do with this + #[doc(hidden)] + #[inline] + pub fn map<U: ?Sized + 'a, F>(self, f: F) -> CpuAccess<'a, U> + where F: FnOnce(*mut T) -> *mut U + { + CpuAccess { + pointer: f(self.pointer), + mem: self.mem, + coherent: self.coherent, + range: self.range.clone(), // TODO: ? + } + } +} + +unsafe impl<'a, T: ?Sized + 'a> Send for CpuAccess<'a, T> { +} +unsafe impl<'a, T: ?Sized + 'a> Sync for CpuAccess<'a, T> { +} + +impl<'a, T: ?Sized + 'a> Deref for CpuAccess<'a, T> { + type Target = T; + + #[inline] + fn deref(&self) -> &T { + unsafe { &*self.pointer } + } +} + +impl<'a, T: ?Sized + 'a> DerefMut for CpuAccess<'a, T> { + #[inline] + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *self.pointer } + } +} + +impl<'a, T: ?Sized + 'a> Drop for CpuAccess<'a, T> { + #[inline] + fn drop(&mut self) { + // If the memory doesn't have the `coherent` flag, we need to flush the data. + if !self.coherent { + let vk = self.mem.as_ref().device().pointers(); + + let range = vk::MappedMemoryRange { + sType: vk::STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, + pNext: ptr::null(), + memory: self.mem.as_ref().internal_object(), + offset: self.range.start as u64, + size: (self.range.end - self.range.start) as u64, + }; + + // TODO: check result? + unsafe { + vk.FlushMappedMemoryRanges(self.mem.as_ref().device().internal_object(), 1, &range); + } + } + } +} + +/// Error type returned by functions related to `DeviceMemory`. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum DeviceMemoryAllocError { + /// Not enough memory available. + OomError(OomError), + /// The maximum number of allocations has been exceeded. + TooManyObjects, + /// Memory map failed. + MemoryMapFailed, +} + +impl error::Error for DeviceMemoryAllocError { + #[inline] + fn description(&self) -> &str { + match *self { + DeviceMemoryAllocError::OomError(_) => "not enough memory available", + DeviceMemoryAllocError::TooManyObjects => + "the maximum number of allocations has been exceeded", + DeviceMemoryAllocError::MemoryMapFailed => "memory map failed", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + DeviceMemoryAllocError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for DeviceMemoryAllocError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for DeviceMemoryAllocError { + #[inline] + fn from(err: Error) -> DeviceMemoryAllocError { + match err { + e @ Error::OutOfHostMemory | + e @ Error::OutOfDeviceMemory => DeviceMemoryAllocError::OomError(e.into()), + Error::TooManyObjects => DeviceMemoryAllocError::TooManyObjects, + Error::MemoryMapFailed => DeviceMemoryAllocError::MemoryMapFailed, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +impl From<OomError> for DeviceMemoryAllocError { + #[inline] + fn from(err: OomError) -> DeviceMemoryAllocError { + DeviceMemoryAllocError::OomError(err) + } +} + +#[cfg(test)] +mod tests { + use OomError; + use memory::DeviceMemory; + use memory::DeviceMemoryAllocError; + + #[test] + fn create() { + let (device, _) = gfx_dev_and_queue!(); + let mem_ty = device.physical_device().memory_types().next().unwrap(); + let _ = DeviceMemory::alloc(device.clone(), mem_ty, 256).unwrap(); + } + + #[test] + fn zero_size() { + let (device, _) = gfx_dev_and_queue!(); + let mem_ty = device.physical_device().memory_types().next().unwrap(); + assert_should_panic!({ + let _ = DeviceMemory::alloc(device.clone(), mem_ty, 0); + }); + } + + #[test] + #[cfg(target_pointer_width = "64")] + fn oom_single() { + let (device, _) = gfx_dev_and_queue!(); + let mem_ty = device + .physical_device() + .memory_types() + .filter(|m| !m.is_lazily_allocated()) + .next() + .unwrap(); + + match DeviceMemory::alloc(device.clone(), mem_ty, 0xffffffffffffffff) { + Err(DeviceMemoryAllocError::OomError(OomError::OutOfDeviceMemory)) => (), + _ => panic!(), + } + } + + #[test] + #[ignore] // TODO: test fails for now on Mesa+Intel + fn oom_multi() { + let (device, _) = gfx_dev_and_queue!(); + let mem_ty = device + .physical_device() + .memory_types() + .filter(|m| !m.is_lazily_allocated()) + .next() + .unwrap(); + let heap_size = mem_ty.heap().size(); + + let mut allocs = Vec::new(); + + for _ in 0 .. 4 { + match DeviceMemory::alloc(device.clone(), mem_ty, heap_size / 3) { + Err(DeviceMemoryAllocError::OomError(OomError::OutOfDeviceMemory)) => return, // test succeeded + Ok(a) => allocs.push(a), + _ => (), + } + } + + panic!() + } + + #[test] + fn allocation_count() { + let (device, _) = gfx_dev_and_queue!(); + let mem_ty = device.physical_device().memory_types().next().unwrap(); + assert_eq!(*device.allocation_count().lock().unwrap(), 0); + let mem1 = DeviceMemory::alloc(device.clone(), mem_ty, 256).unwrap(); + assert_eq!(*device.allocation_count().lock().unwrap(), 1); + { + let mem2 = DeviceMemory::alloc(device.clone(), mem_ty, 256).unwrap(); + assert_eq!(*device.allocation_count().lock().unwrap(), 2); + } + assert_eq!(*device.allocation_count().lock().unwrap(), 1); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/memory/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/mod.rs new file mode 100644 index 0000000..77c184b --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/mod.rs @@ -0,0 +1,221 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Device memory allocation and memory pools. +//! +//! By default, memory allocation is automatically handled by the vulkano library when you create +//! a buffer or an image. But if you want more control, you have the possibility to customise the +//! memory allocation strategy. +//! +//! # Memory types and heaps +//! +//! A physical device is composed of one or more **memory heaps**. A memory heap is a pool of +//! memory that can be allocated. +//! +//! ``` +//! // Enumerating memory heaps. +//! # let physical_device: vulkano::instance::PhysicalDevice = return; +//! for heap in physical_device.memory_heaps() { +//! println!("Heap #{:?} has a capacity of {:?} bytes", heap.id(), heap.size()); +//! } +//! ``` +//! +//! However you can't allocate directly from a memory heap. A memory heap is shared amongst one or +//! multiple **memory types**, which you can allocate memory from. Each memory type has different +//! characteristics. +//! +//! A memory type may or may not be visible to the host. In other words, it may or may not be +//! directly writable by the CPU. A memory type may or may not be device-local. A device-local +//! memory type has a much quicker access time from the GPU than a non-device-local type. Note +//! that non-device-local memory types are still accessible by the device, they are just slower. +//! +//! ``` +//! // Enumerating memory types. +//! # let physical_device: vulkano::instance::PhysicalDevice = return; +//! for ty in physical_device.memory_types() { +//! println!("Memory type belongs to heap #{:?}", ty.heap().id()); +//! println!("Host-accessible: {:?}", ty.is_host_visible()); +//! println!("Device-local: {:?}", ty.is_device_local()); +//! } +//! ``` +//! +//! Memory types are order from "best" to "worse". In other words, the implementation prefers that +//! you use the memory types that are earlier in the list. This means that selecting a memory type +//! should always be done by enumerating them and taking the first one that matches our criteria. +//! +//! ## In practice +//! +//! In practice, desktop machines usually have two memory heaps: one that represents the RAM of +//! the CPU, and one that represents the RAM of the GPU. The CPU's RAM is host-accessible but not +//! device-local, while the GPU's RAM is not host-accessible but is device-local. +//! +//! Mobile machines usually have a single memory heap that is "equally local" to both the CPU and +//! the GPU. It is both host-accessible and device-local. +//! +//! # Allocating memory and memory pools +//! +//! Allocating memory can be done by calling `DeviceMemory::alloc()`. +//! +//! Here is an example: +//! +//! ``` +//! use vulkano::memory::DeviceMemory; +//! +//! # let device: std::sync::Arc<vulkano::device::Device> = return; +//! // Taking the first memory type for the sake of this example. +//! let ty = device.physical_device().memory_types().next().unwrap(); +//! +//! let alloc = DeviceMemory::alloc(device.clone(), ty, 1024).expect("Failed to allocate memory"); +//! +//! // The memory is automatically free'd when `alloc` is destroyed. +//! ``` +//! +//! However allocating and freeing memory is very slow (up to several hundred milliseconds +//! sometimes). Instead you are strongly encouraged to use a memory pool. A memory pool is not +//! a Vulkan concept but a vulkano concept. +//! +//! A memory pool is any object that implements the `MemoryPool` trait. You can implement that +//! trait on your own structure and then use it when you create buffers and images so that they +//! get memory from that pool. By default if you don't specify any pool when creating a buffer or +//! an image, an instance of `StdMemoryPool` that is shared by the `Device` object is used. + +use std::mem; +use std::os::raw::c_void; +use std::slice; + +use buffer::sys::UnsafeBuffer; +use image::sys::UnsafeImage; +use vk; + +pub use self::device_memory::CpuAccess; +pub use self::device_memory::DeviceMemory; +pub use self::device_memory::DeviceMemoryAllocError; +pub use self::device_memory::MappedDeviceMemory; +pub use self::pool::MemoryPool; + +mod device_memory; +pub mod pool; + +/// Represents requirements expressed by the Vulkan implementation when it comes to binding memory +/// to a resource. +#[derive(Debug, Copy, Clone)] +pub struct MemoryRequirements { + /// Number of bytes of memory required. + pub size: usize, + + /// Alignment of the requirement buffer. The base memory address must be a multiple + /// of this value. + pub alignment: usize, + + /// Indicates which memory types can be used. Each bit that is set to 1 means that the memory + /// type whose index is the same as the position of the bit can be used. + pub memory_type_bits: u32, + + /// True if the implementation prefers to use dedicated allocations (in other words, allocate + /// a whole block of memory dedicated to this resource alone). If the + /// `khr_get_memory_requirements2` extension isn't enabled, then this will be false. + /// + /// > **Note**: As its name says, using a dedicated allocation is an optimization and not a + /// > requirement. + pub prefer_dedicated: bool, +} + +impl MemoryRequirements { + #[inline] + pub(crate) fn from_vulkan_reqs(reqs: vk::MemoryRequirements) -> MemoryRequirements { + MemoryRequirements { + size: reqs.size as usize, + alignment: reqs.alignment as usize, + memory_type_bits: reqs.memoryTypeBits, + prefer_dedicated: false, + } + } +} + +/// Indicates whether we want to allocate memory for a specific resource, or in a generic way. +/// +/// Using dedicated allocations can yield better performance, but requires the +/// `VK_KHR_dedicated_allocation` extension to be enabled on the device. +/// +/// If a dedicated allocation is performed, it must only be bound to any resource other than the +/// one that was passed with the enumeration. +#[derive(Debug, Copy, Clone)] +pub enum DedicatedAlloc<'a> { + /// Generic allocation. + None, + /// Allocation dedicated to a buffer. + Buffer(&'a UnsafeBuffer), + /// Allocation dedicated to an image. + Image(&'a UnsafeImage), +} + +/// Trait for types of data that can be mapped. +// TODO: move to `buffer` module +pub unsafe trait Content { + /// Builds a pointer to this type from a raw pointer. + fn ref_from_ptr<'a>(ptr: *mut c_void, size: usize) -> Option<*mut Self>; + + /// Returns true if the size is suitable to store a type like this. + fn is_size_suitable(usize) -> bool; + + /// Returns the size of an individual element. + fn indiv_size() -> usize; +} + +unsafe impl<T> Content for T { + #[inline] + fn ref_from_ptr<'a>(ptr: *mut c_void, size: usize) -> Option<*mut T> { + if size < mem::size_of::<T>() { + return None; + } + + Some(ptr as *mut T) + } + + #[inline] + fn is_size_suitable(size: usize) -> bool { + size == mem::size_of::<T>() + } + + #[inline] + fn indiv_size() -> usize { + mem::size_of::<T>() + } +} + +unsafe impl<T> Content for [T] { + #[inline] + fn ref_from_ptr<'a>(ptr: *mut c_void, size: usize) -> Option<*mut [T]> { + let ptr = ptr as *mut T; + let size = size / mem::size_of::<T>(); + Some(unsafe { slice::from_raw_parts_mut(&mut *ptr, size) as *mut [T] }) + } + + #[inline] + fn is_size_suitable(size: usize) -> bool { + size % mem::size_of::<T>() == 0 + } + + #[inline] + fn indiv_size() -> usize { + mem::size_of::<T>() + } +} + +/* +TODO: do this when it's possible +unsafe impl Content for .. {} +impl<'a, T> !Content for &'a T {} +impl<'a, T> !Content for &'a mut T {} +impl<T> !Content for *const T {} +impl<T> !Content for *mut T {} +impl<T> !Content for Box<T> {} +impl<T> !Content for UnsafeCell<T> {} + +*/ diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/host_visible.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/host_visible.rs new file mode 100644 index 0000000..bafa169 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/host_visible.rs @@ -0,0 +1,175 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::cmp; +use std::ops::Range; +use std::sync::Arc; +use std::sync::Mutex; + +use device::Device; +use instance::Instance; +use instance::MemoryType; +use memory::DeviceMemory; +use memory::DeviceMemoryAllocError; +use memory::MappedDeviceMemory; + +/// Memory pool that operates on a given memory type. +#[derive(Debug)] +pub struct StdHostVisibleMemoryTypePool { + device: Arc<Device>, + memory_type: u32, + // TODO: obviously very inefficient + occupied: Mutex<Vec<(Arc<MappedDeviceMemory>, Vec<Range<usize>>)>>, +} + +impl StdHostVisibleMemoryTypePool { + /// Creates a new pool that will operate on the given memory type. + /// + /// # Panic + /// + /// - Panics if the `device` and `memory_type` don't belong to the same physical device. + /// - Panics if the memory type is not host-visible. + /// + #[inline] + pub fn new(device: Arc<Device>, memory_type: MemoryType) -> Arc<StdHostVisibleMemoryTypePool> { + assert_eq!(&**device.physical_device().instance() as *const Instance, + &**memory_type.physical_device().instance() as *const Instance); + assert_eq!(device.physical_device().index(), + memory_type.physical_device().index()); + assert!(memory_type.is_host_visible()); + + Arc::new(StdHostVisibleMemoryTypePool { + device: device.clone(), + memory_type: memory_type.id(), + occupied: Mutex::new(Vec::new()), + }) + } + + /// Allocates memory from the pool. + /// + /// # Panic + /// + /// - Panics if `size` is 0. + /// - Panics if `alignment` is 0. + /// + pub fn alloc(me: &Arc<Self>, size: usize, alignment: usize) + -> Result<StdHostVisibleMemoryTypePoolAlloc, DeviceMemoryAllocError> { + assert!(size != 0); + assert!(alignment != 0); + + #[inline] + fn align(val: usize, al: usize) -> usize { + al * (1 + (val - 1) / al) + } + + // Find a location. + let mut occupied = me.occupied.lock().unwrap(); + + // Try finding an entry in already-allocated chunks. + for &mut (ref dev_mem, ref mut entries) in occupied.iter_mut() { + // Try find some free space in-between two entries. + for i in 0 .. entries.len().saturating_sub(1) { + let entry1 = entries[i].clone(); + let entry1_end = align(entry1.end, alignment); + let entry2 = entries[i + 1].clone(); + if entry1_end + size <= entry2.start { + entries.insert(i + 1, entry1_end .. entry1_end + size); + return Ok(StdHostVisibleMemoryTypePoolAlloc { + pool: me.clone(), + memory: dev_mem.clone(), + offset: entry1_end, + size: size, + }); + } + } + + // Try append at the end. + let last_end = entries.last().map(|e| align(e.end, alignment)).unwrap_or(0); + if last_end + size <= (**dev_mem).as_ref().size() { + entries.push(last_end .. last_end + size); + return Ok(StdHostVisibleMemoryTypePoolAlloc { + pool: me.clone(), + memory: dev_mem.clone(), + offset: last_end, + size: size, + }); + } + } + + // We need to allocate a new block. + let new_block = { + const MIN_BLOCK_SIZE: usize = 8 * 1024 * 1024; // 8 MB + let to_alloc = cmp::max(MIN_BLOCK_SIZE, size.next_power_of_two()); + let new_block = + DeviceMemory::alloc_and_map(me.device.clone(), me.memory_type(), to_alloc)?; + Arc::new(new_block) + }; + + occupied.push((new_block.clone(), vec![0 .. size])); + Ok(StdHostVisibleMemoryTypePoolAlloc { + pool: me.clone(), + memory: new_block, + offset: 0, + size: size, + }) + } + + /// Returns the device this pool operates on. + #[inline] + pub fn device(&self) -> &Arc<Device> { + &self.device + } + + /// Returns the memory type this pool operates on. + #[inline] + pub fn memory_type(&self) -> MemoryType { + self.device + .physical_device() + .memory_type_by_id(self.memory_type) + .unwrap() + } +} + +#[derive(Debug)] +pub struct StdHostVisibleMemoryTypePoolAlloc { + pool: Arc<StdHostVisibleMemoryTypePool>, + memory: Arc<MappedDeviceMemory>, + offset: usize, + size: usize, +} + +impl StdHostVisibleMemoryTypePoolAlloc { + #[inline] + pub fn memory(&self) -> &MappedDeviceMemory { + &self.memory + } + + #[inline] + pub fn offset(&self) -> usize { + self.offset + } + + #[inline] + pub fn size(&self) -> usize { + self.size + } +} + +impl Drop for StdHostVisibleMemoryTypePoolAlloc { + fn drop(&mut self) { + let mut occupied = self.pool.occupied.lock().unwrap(); + + let entries = occupied + .iter_mut() + .find(|e| &*e.0 as *const MappedDeviceMemory == &*self.memory) + .unwrap(); + + entries.1.retain(|e| e.start != self.offset); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/mod.rs new file mode 100644 index 0000000..39ced77 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/mod.rs @@ -0,0 +1,243 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use device::DeviceOwned; +use instance::MemoryType; +use memory::DedicatedAlloc; +use memory::DeviceMemory; +use memory::DeviceMemoryAllocError; +use memory::MappedDeviceMemory; +use memory::MemoryRequirements; + +pub use self::host_visible::StdHostVisibleMemoryTypePool; +pub use self::host_visible::StdHostVisibleMemoryTypePoolAlloc; +pub use self::non_host_visible::StdNonHostVisibleMemoryTypePool; +pub use self::non_host_visible::StdNonHostVisibleMemoryTypePoolAlloc; +pub use self::pool::StdMemoryPool; +pub use self::pool::StdMemoryPoolAlloc; + +mod host_visible; +mod non_host_visible; +mod pool; + +/// Pool of GPU-visible memory that can be allocated from. +pub unsafe trait MemoryPool: DeviceOwned { + /// Object that represents a single allocation. Its destructor should free the chunk. + type Alloc: MemoryPoolAlloc; + + /// Allocates memory from the pool. + /// + /// # Safety + /// + /// Implementation safety: + /// + /// - The returned object must match the requirements. + /// - When a linear object is allocated next to an optimal object, it is mandatory that + /// the boundary is aligned to the value of the `buffer_image_granularity` limit. + /// + /// Note that it is not unsafe to *call* this function, but it is unsafe to bind the memory + /// returned by this function to a resource. + /// + /// # Panic + /// + /// - Panics if `memory_type` doesn't belong to the same physical device as the device which + /// was used to create this pool. + /// - Panics if the memory type is not host-visible and `map` is `MappingRequirement::Map`. + /// - Panics if `size` is 0. + /// - Panics if `alignment` is 0. + /// + fn alloc_generic(&self, ty: MemoryType, size: usize, alignment: usize, layout: AllocLayout, + map: MappingRequirement) + -> Result<Self::Alloc, DeviceMemoryAllocError>; + + /// Chooses a memory type and allocates memory from it. + /// + /// Contrary to `alloc_generic`, this function may allocate a whole new block of memory + /// dedicated to a resource based on `requirements.prefer_dedicated`. + /// + /// `filter` can be used to restrict the memory types and to indicate which are preferred. + /// If `map` is `MappingRequirement::Map`, then non-host-visible memory types will + /// automatically be filtered out. + /// + /// # Safety + /// + /// Implementation safety: + /// + /// - The returned object must match the requirements. + /// - When a linear object is allocated next to an optimal object, it is mandatory that + /// the boundary is aligned to the value of the `buffer_image_granularity` limit. + /// - If `dedicated` is not `None`, the returned memory must either not be dedicated or be + /// dedicated to the resource that was passed. + /// + /// Note that it is not unsafe to *call* this function, but it is unsafe to bind the memory + /// returned by this function to a resource. + /// + /// # Panic + /// + /// - Panics if no memory type could be found, which can happen if `filter` is too restrictive. + // TODO: ^ is this a good idea? + /// - Panics if `size` is 0. + /// - Panics if `alignment` is 0. + /// + fn alloc_from_requirements<F>( + &self, requirements: &MemoryRequirements, layout: AllocLayout, map: MappingRequirement, + dedicated: DedicatedAlloc, mut filter: F) + -> Result<PotentialDedicatedAllocation<Self::Alloc>, DeviceMemoryAllocError> + where F: FnMut(MemoryType) -> AllocFromRequirementsFilter + { + // Choose a suitable memory type. + let mem_ty = { + let mut filter = |ty: MemoryType| { + if map == MappingRequirement::Map && !ty.is_host_visible() { + return AllocFromRequirementsFilter::Forbidden; + } + filter(ty) + }; + let first_loop = self.device() + .physical_device() + .memory_types() + .map(|t| (t, AllocFromRequirementsFilter::Preferred)); + let second_loop = self.device() + .physical_device() + .memory_types() + .map(|t| (t, AllocFromRequirementsFilter::Allowed)); + first_loop + .chain(second_loop) + .filter(|&(t, _)| (requirements.memory_type_bits & (1 << t.id())) != 0) + .filter(|&(t, rq)| filter(t) == rq) + .next() + .expect("Couldn't find a memory type to allocate from") + .0 + }; + + // Redirect to `self.alloc_generic` if we don't perform a dedicated allocation. + if !requirements.prefer_dedicated || + !self.device().loaded_extensions().khr_dedicated_allocation + { + let alloc = self.alloc_generic(mem_ty, + requirements.size, + requirements.alignment, + layout, + map)?; + return Ok(alloc.into()); + } + if let DedicatedAlloc::None = dedicated { + let alloc = self.alloc_generic(mem_ty, + requirements.size, + requirements.alignment, + layout, + map)?; + return Ok(alloc.into()); + } + + // If we reach here, then we perform a dedicated alloc. + match map { + MappingRequirement::Map => { + let mem = DeviceMemory::dedicated_alloc_and_map(self.device().clone(), + mem_ty, + requirements.size, + dedicated)?; + Ok(PotentialDedicatedAllocation::DedicatedMapped(mem)) + }, + MappingRequirement::DoNotMap => { + let mem = DeviceMemory::dedicated_alloc(self.device().clone(), + mem_ty, + requirements.size, + dedicated)?; + Ok(PotentialDedicatedAllocation::Dedicated(mem)) + }, + } + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum AllocFromRequirementsFilter { + Preferred, + Allowed, + Forbidden, +} + +/// Object that represents a single allocation. Its destructor should free the chunk. +pub unsafe trait MemoryPoolAlloc { + /// Returns the memory object from which this is allocated. Returns `None` if the memory is + /// not mapped. + fn mapped_memory(&self) -> Option<&MappedDeviceMemory>; + + /// Returns the memory object from which this is allocated. + fn memory(&self) -> &DeviceMemory; + + /// Returns the offset at the start of the memory where the first byte of this allocation + /// resides. + fn offset(&self) -> usize; +} + +/// Whether an allocation should map the memory or not. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum MappingRequirement { + /// Should map. + Map, + /// Shouldn't map. + DoNotMap, +} + +/// Layout of the object being allocated. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum AllocLayout { + /// The object has a linear layout. + Linear, + /// The object has an optimal layout. + Optimal, +} + +/// Enumeration that can contain either a generic allocation coming from a pool, or a dedicated +/// allocation for one specific resource. +#[derive(Debug)] +pub enum PotentialDedicatedAllocation<A> { + Generic(A), + Dedicated(DeviceMemory), + DedicatedMapped(MappedDeviceMemory), +} + +unsafe impl<A> MemoryPoolAlloc for PotentialDedicatedAllocation<A> + where A: MemoryPoolAlloc +{ + #[inline] + fn mapped_memory(&self) -> Option<&MappedDeviceMemory> { + match *self { + PotentialDedicatedAllocation::Generic(ref alloc) => alloc.mapped_memory(), + PotentialDedicatedAllocation::Dedicated(_) => None, + PotentialDedicatedAllocation::DedicatedMapped(ref mem) => Some(mem), + } + } + + #[inline] + fn memory(&self) -> &DeviceMemory { + match *self { + PotentialDedicatedAllocation::Generic(ref alloc) => alloc.memory(), + PotentialDedicatedAllocation::Dedicated(ref mem) => mem, + PotentialDedicatedAllocation::DedicatedMapped(ref mem) => mem.as_ref(), + } + } + + #[inline] + fn offset(&self) -> usize { + match *self { + PotentialDedicatedAllocation::Generic(ref alloc) => alloc.offset(), + PotentialDedicatedAllocation::Dedicated(_) => 0, + PotentialDedicatedAllocation::DedicatedMapped(_) => 0, + } + } +} + +impl<A> From<A> for PotentialDedicatedAllocation<A> { + #[inline] + fn from(alloc: A) -> PotentialDedicatedAllocation<A> { + PotentialDedicatedAllocation::Generic(alloc) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/non_host_visible.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/non_host_visible.rs new file mode 100644 index 0000000..7388c7a --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/non_host_visible.rs @@ -0,0 +1,172 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::cmp; +use std::ops::Range; +use std::sync::Arc; +use std::sync::Mutex; + +use device::Device; +use instance::Instance; +use instance::MemoryType; +use memory::DeviceMemory; +use memory::DeviceMemoryAllocError; + +/// Memory pool that operates on a given memory type. +#[derive(Debug)] +pub struct StdNonHostVisibleMemoryTypePool { + device: Arc<Device>, + memory_type: u32, + // TODO: obviously very inefficient + occupied: Mutex<Vec<(Arc<DeviceMemory>, Vec<Range<usize>>)>>, +} + +impl StdNonHostVisibleMemoryTypePool { + /// Creates a new pool that will operate on the given memory type. + /// + /// # Panic + /// + /// - Panics if the `device` and `memory_type` don't belong to the same physical device. + /// + #[inline] + pub fn new(device: Arc<Device>, memory_type: MemoryType) + -> Arc<StdNonHostVisibleMemoryTypePool> { + assert_eq!(&**device.physical_device().instance() as *const Instance, + &**memory_type.physical_device().instance() as *const Instance); + assert_eq!(device.physical_device().index(), + memory_type.physical_device().index()); + + Arc::new(StdNonHostVisibleMemoryTypePool { + device: device.clone(), + memory_type: memory_type.id(), + occupied: Mutex::new(Vec::new()), + }) + } + + /// Allocates memory from the pool. + /// + /// # Panic + /// + /// - Panics if `size` is 0. + /// - Panics if `alignment` is 0. + /// + pub fn alloc(me: &Arc<Self>, size: usize, alignment: usize) + -> Result<StdNonHostVisibleMemoryTypePoolAlloc, DeviceMemoryAllocError> { + assert!(size != 0); + assert!(alignment != 0); + + #[inline] + fn align(val: usize, al: usize) -> usize { + al * (1 + (val - 1) / al) + } + + // Find a location. + let mut occupied = me.occupied.lock().unwrap(); + + // Try finding an entry in already-allocated chunks. + for &mut (ref dev_mem, ref mut entries) in occupied.iter_mut() { + // Try find some free space in-between two entries. + for i in 0 .. entries.len().saturating_sub(1) { + let entry1 = entries[i].clone(); + let entry1_end = align(entry1.end, alignment); + let entry2 = entries[i + 1].clone(); + if entry1_end + size <= entry2.start { + entries.insert(i + 1, entry1_end .. entry1_end + size); + return Ok(StdNonHostVisibleMemoryTypePoolAlloc { + pool: me.clone(), + memory: dev_mem.clone(), + offset: entry1_end, + size: size, + }); + } + } + + // Try append at the end. + let last_end = entries.last().map(|e| align(e.end, alignment)).unwrap_or(0); + if last_end + size <= dev_mem.size() { + entries.push(last_end .. last_end + size); + return Ok(StdNonHostVisibleMemoryTypePoolAlloc { + pool: me.clone(), + memory: dev_mem.clone(), + offset: last_end, + size: size, + }); + } + } + + // We need to allocate a new block. + let new_block = { + const MIN_BLOCK_SIZE: usize = 8 * 1024 * 1024; // 8 MB + let to_alloc = cmp::max(MIN_BLOCK_SIZE, size.next_power_of_two()); + let new_block = DeviceMemory::alloc(me.device.clone(), me.memory_type(), to_alloc)?; + Arc::new(new_block) + }; + + occupied.push((new_block.clone(), vec![0 .. size])); + Ok(StdNonHostVisibleMemoryTypePoolAlloc { + pool: me.clone(), + memory: new_block, + offset: 0, + size: size, + }) + } + + /// Returns the device this pool operates on. + #[inline] + pub fn device(&self) -> &Arc<Device> { + &self.device + } + + /// Returns the memory type this pool operates on. + #[inline] + pub fn memory_type(&self) -> MemoryType { + self.device + .physical_device() + .memory_type_by_id(self.memory_type) + .unwrap() + } +} + +#[derive(Debug)] +pub struct StdNonHostVisibleMemoryTypePoolAlloc { + pool: Arc<StdNonHostVisibleMemoryTypePool>, + memory: Arc<DeviceMemory>, + offset: usize, + size: usize, +} + +impl StdNonHostVisibleMemoryTypePoolAlloc { + #[inline] + pub fn memory(&self) -> &DeviceMemory { + &self.memory + } + + #[inline] + pub fn offset(&self) -> usize { + self.offset + } + + #[inline] + pub fn size(&self) -> usize { + self.size + } +} + +impl Drop for StdNonHostVisibleMemoryTypePoolAlloc { + fn drop(&mut self) { + let mut occupied = self.pool.occupied.lock().unwrap(); + + let entries = occupied + .iter_mut() + .find(|e| &*e.0 as *const DeviceMemory == &*self.memory) + .unwrap(); + + entries.1.retain(|e| e.start != self.offset); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/pool.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/pool.rs new file mode 100644 index 0000000..fc02368 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/memory/pool/pool.rs @@ -0,0 +1,173 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use fnv::FnvHasher; +use std::collections::HashMap; +use std::collections::hash_map::Entry; +use std::hash::BuildHasherDefault; +use std::sync::Arc; +use std::sync::Mutex; + +use device::Device; +use device::DeviceOwned; +use instance::MemoryType; +use memory::DeviceMemory; +use memory::DeviceMemoryAllocError; +use memory::MappedDeviceMemory; +use memory::pool::AllocLayout; +use memory::pool::MappingRequirement; +use memory::pool::MemoryPool; +use memory::pool::MemoryPoolAlloc; +use memory::pool::StdHostVisibleMemoryTypePool; +use memory::pool::StdHostVisibleMemoryTypePoolAlloc; +use memory::pool::StdNonHostVisibleMemoryTypePool; +use memory::pool::StdNonHostVisibleMemoryTypePoolAlloc; + +#[derive(Debug)] +pub struct StdMemoryPool { + device: Arc<Device>, + + // For each memory type index, stores the associated pool. + pools: + Mutex<HashMap<(u32, AllocLayout, MappingRequirement), Pool, BuildHasherDefault<FnvHasher>>>, +} + +impl StdMemoryPool { + /// Creates a new pool. + #[inline] + pub fn new(device: Arc<Device>) -> Arc<StdMemoryPool> { + let cap = device.physical_device().memory_types().len(); + let hasher = BuildHasherDefault::<FnvHasher>::default(); + + Arc::new(StdMemoryPool { + device: device.clone(), + pools: Mutex::new(HashMap::with_capacity_and_hasher(cap, hasher)), + }) + } +} + +unsafe impl MemoryPool for Arc<StdMemoryPool> { + type Alloc = StdMemoryPoolAlloc; + + fn alloc_generic(&self, memory_type: MemoryType, size: usize, alignment: usize, + layout: AllocLayout, map: MappingRequirement) + -> Result<StdMemoryPoolAlloc, DeviceMemoryAllocError> { + let mut pools = self.pools.lock().unwrap(); + + let memory_type_host_visible = memory_type.is_host_visible(); + assert!(memory_type_host_visible || map == MappingRequirement::DoNotMap); + + match pools.entry((memory_type.id(), layout, map)) { + Entry::Occupied(entry) => { + match entry.get() { + &Pool::HostVisible(ref pool) => { + let alloc = StdHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?; + let inner = StdMemoryPoolAllocInner::HostVisible(alloc); + Ok(StdMemoryPoolAlloc { + inner: inner, + pool: self.clone(), + }) + }, + &Pool::NonHostVisible(ref pool) => { + let alloc = StdNonHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?; + let inner = StdMemoryPoolAllocInner::NonHostVisible(alloc); + Ok(StdMemoryPoolAlloc { + inner: inner, + pool: self.clone(), + }) + }, + } + }, + + Entry::Vacant(entry) => { + if memory_type_host_visible { + let pool = StdHostVisibleMemoryTypePool::new(self.device.clone(), memory_type); + entry.insert(Pool::HostVisible(pool.clone())); + let alloc = StdHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?; + let inner = StdMemoryPoolAllocInner::HostVisible(alloc); + Ok(StdMemoryPoolAlloc { + inner: inner, + pool: self.clone(), + }) + } else { + let pool = StdNonHostVisibleMemoryTypePool::new(self.device.clone(), + memory_type); + entry.insert(Pool::NonHostVisible(pool.clone())); + let alloc = StdNonHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?; + let inner = StdMemoryPoolAllocInner::NonHostVisible(alloc); + Ok(StdMemoryPoolAlloc { + inner: inner, + pool: self.clone(), + }) + } + }, + } + } +} + +unsafe impl DeviceOwned for StdMemoryPool { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +#[derive(Debug)] +enum Pool { + HostVisible(Arc<StdHostVisibleMemoryTypePool>), + NonHostVisible(Arc<StdNonHostVisibleMemoryTypePool>), +} + +#[derive(Debug)] +pub struct StdMemoryPoolAlloc { + inner: StdMemoryPoolAllocInner, + pool: Arc<StdMemoryPool>, +} + +impl StdMemoryPoolAlloc { + #[inline] + pub fn size(&self) -> usize { + match self.inner { + StdMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.size(), + StdMemoryPoolAllocInner::HostVisible(ref mem) => mem.size(), + } + } +} + +unsafe impl MemoryPoolAlloc for StdMemoryPoolAlloc { + #[inline] + fn memory(&self) -> &DeviceMemory { + match self.inner { + StdMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.memory(), + StdMemoryPoolAllocInner::HostVisible(ref mem) => mem.memory().as_ref(), + } + } + + #[inline] + fn mapped_memory(&self) -> Option<&MappedDeviceMemory> { + match self.inner { + StdMemoryPoolAllocInner::NonHostVisible(_) => None, + StdMemoryPoolAllocInner::HostVisible(ref mem) => Some(mem.memory()), + } + } + + #[inline] + fn offset(&self) -> usize { + match self.inner { + StdMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.offset(), + StdMemoryPoolAllocInner::HostVisible(ref mem) => mem.offset(), + } + } +} + +#[derive(Debug)] +enum StdMemoryPoolAllocInner { + NonHostVisible(StdNonHostVisibleMemoryTypePoolAlloc), + HostVisible(StdHostVisibleMemoryTypePoolAlloc), +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/blend.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/blend.rs new file mode 100644 index 0000000..57435fc --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/blend.rs @@ -0,0 +1,266 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Defines how the color output of the fragment shader is written to the attachment. +//! +//! # Blending in details +//! +//! There are three kinds of color attachments for the purpose of blending: +//! +//! - Attachments with a floating-point, fixed point format. +//! - Attachments with a (non-normalized) integer format. +//! - Attachments with a normalized integer format. +//! +//! For floating-point and fixed-point formats, the blending operation is applied. For integer +//! formats, the logic operation is applied. For normalized integer formats, the logic operation +//! will take precedence if it is activated, otherwise the blending operation is applied. +//! + +use vk; + +/// Describes how the color output of the fragment shader is written to the attachment. See the +/// documentation of the `blend` module for more info. +#[derive(Debug, Clone, PartialEq)] +pub struct Blend { + pub logic_op: Option<LogicOp>, + + pub attachments: AttachmentsBlend, + + /// The constant color to use for the `Constant*` blending operation. + /// + /// If you pass `None`, then this state will be considered as dynamic and the blend constants + /// will need to be set when you build the command buffer. + pub blend_constants: Option<[f32; 4]>, +} + +impl Blend { + /// Returns a `Blend` object that directly writes colors and alpha on the surface. + #[inline] + pub fn pass_through() -> Blend { + Blend { + logic_op: None, + attachments: AttachmentsBlend::Collective(AttachmentBlend::pass_through()), + blend_constants: Some([0.0, 0.0, 0.0, 0.0]), + } + } + + /// Returns a `Blend` object that adds transparent objects over others. + #[inline] + pub fn alpha_blending() -> Blend { + Blend { + logic_op: None, + attachments: AttachmentsBlend::Collective(AttachmentBlend::alpha_blending()), + blend_constants: Some([0.0, 0.0, 0.0, 0.0]), + } + } +} + +/// Describes how the blending system should behave. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum AttachmentsBlend { + /// All the framebuffer attachments will use the same blending. + Collective(AttachmentBlend), + + /// Each attachment will behave differently. Note that this requires enabling the + /// `independent_blend` feature. + Individual(Vec<AttachmentBlend>), +} + +/// Describes how the blending system should behave for an individual attachment. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct AttachmentBlend { + // TODO: could be automatically determined from the other params + /// If false, blending is ignored and the output is directly written to the attachment. + pub enabled: bool, + + pub color_op: BlendOp, + pub color_source: BlendFactor, + pub color_destination: BlendFactor, + + pub alpha_op: BlendOp, + pub alpha_source: BlendFactor, + pub alpha_destination: BlendFactor, + + pub mask_red: bool, + pub mask_green: bool, + pub mask_blue: bool, + pub mask_alpha: bool, +} + +impl AttachmentBlend { + /// Builds an `AttachmentBlend` where blending is disabled. + #[inline] + pub fn pass_through() -> AttachmentBlend { + AttachmentBlend { + enabled: false, + color_op: BlendOp::Add, + color_source: BlendFactor::Zero, + color_destination: BlendFactor::One, + alpha_op: BlendOp::Add, + alpha_source: BlendFactor::Zero, + alpha_destination: BlendFactor::One, + mask_red: true, + mask_green: true, + mask_blue: true, + mask_alpha: true, + } + } + + /// Builds an `AttachmentBlend` where the output of the fragment shader is ignored and the + /// destination is untouched. + #[inline] + pub fn ignore_source() -> AttachmentBlend { + AttachmentBlend { + enabled: true, + color_op: BlendOp::Add, + color_source: BlendFactor::Zero, + color_destination: BlendFactor::DstColor, + alpha_op: BlendOp::Add, + alpha_source: BlendFactor::Zero, + alpha_destination: BlendFactor::DstColor, + mask_red: true, + mask_green: true, + mask_blue: true, + mask_alpha: true, + } + } + + /// Builds an `AttachmentBlend` where the output will be merged with the existing value + /// based on the alpha of the source. + #[inline] + pub fn alpha_blending() -> AttachmentBlend { + AttachmentBlend { + enabled: true, + color_op: BlendOp::Add, + color_source: BlendFactor::SrcAlpha, + color_destination: BlendFactor::OneMinusSrcAlpha, + alpha_op: BlendOp::Add, + alpha_source: BlendFactor::SrcAlpha, + alpha_destination: BlendFactor::OneMinusSrcAlpha, + mask_red: true, + mask_green: true, + mask_blue: true, + mask_alpha: true, + } + } + + #[inline] + pub(crate) fn into_vulkan_state(self) -> vk::PipelineColorBlendAttachmentState { + vk::PipelineColorBlendAttachmentState { + blendEnable: if self.enabled { vk::TRUE } else { vk::FALSE }, + srcColorBlendFactor: self.color_source as u32, + dstColorBlendFactor: self.color_destination as u32, + colorBlendOp: self.color_op as u32, + srcAlphaBlendFactor: self.alpha_source as u32, + dstAlphaBlendFactor: self.alpha_destination as u32, + alphaBlendOp: self.alpha_op as u32, + colorWriteMask: { + let mut mask = 0; + if self.mask_red { + mask |= vk::COLOR_COMPONENT_R_BIT; + } + if self.mask_green { + mask |= vk::COLOR_COMPONENT_G_BIT; + } + if self.mask_blue { + mask |= vk::COLOR_COMPONENT_B_BIT; + } + if self.mask_alpha { + mask |= vk::COLOR_COMPONENT_A_BIT; + } + mask + }, + } + } +} + +/// Which logical operation to apply to the output values. +/// +/// The operation is applied individually for each channel (red, green, blue and alpha). +/// +/// Only relevant for integer or unsigned attachments. +/// +/// Also note that some implementations don't support logic operations. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[repr(u32)] +pub enum LogicOp { + /// Returns `0`. + Clear = vk::LOGIC_OP_CLEAR, + /// Returns `source & destination`. + And = vk::LOGIC_OP_AND, + /// Returns `source & !destination`. + AndReverse = vk::LOGIC_OP_AND_REVERSE, + /// Returns `source`. + Copy = vk::LOGIC_OP_COPY, + /// Returns `!source & destination`. + AndInverted = vk::LOGIC_OP_AND_INVERTED, + /// Returns `destination`. + Noop = vk::LOGIC_OP_NO_OP, + /// Returns `source ^ destination`. + Xor = vk::LOGIC_OP_XOR, + /// Returns `source | destination`. + Or = vk::LOGIC_OP_OR, + /// Returns `!(source | destination)`. + Nor = vk::LOGIC_OP_NOR, + /// Returns `!(source ^ destination)`. + Equivalent = vk::LOGIC_OP_EQUIVALENT, + /// Returns `!destination`. + Invert = vk::LOGIC_OP_INVERT, + /// Returns `source | !destination. + OrReverse = vk::LOGIC_OP_OR_REVERSE, + /// Returns `!source`. + CopyInverted = vk::LOGIC_OP_COPY_INVERTED, + /// Returns `!source | destination`. + OrInverted = vk::LOGIC_OP_OR_INVERTED, + /// Returns `!(source & destination)`. + Nand = vk::LOGIC_OP_NAND, + /// Returns `!0` (all bits set to 1). + Set = vk::LOGIC_OP_SET, +} + +impl Default for LogicOp { + #[inline] + fn default() -> LogicOp { + LogicOp::Noop + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[repr(u32)] +pub enum BlendOp { + Add = vk::BLEND_OP_ADD, + Subtract = vk::BLEND_OP_SUBTRACT, + ReverseSubtract = vk::BLEND_OP_REVERSE_SUBTRACT, + Min = vk::BLEND_OP_MIN, + Max = vk::BLEND_OP_MAX, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[repr(u32)] +pub enum BlendFactor { + Zero = vk::BLEND_FACTOR_ZERO, + One = vk::BLEND_FACTOR_ONE, + SrcColor = vk::BLEND_FACTOR_SRC_COLOR, + OneMinusSrcColor = vk::BLEND_FACTOR_ONE_MINUS_SRC_COLOR, + DstColor = vk::BLEND_FACTOR_DST_COLOR, + OneMinusDstColor = vk::BLEND_FACTOR_ONE_MINUS_DST_COLOR, + SrcAlpha = vk::BLEND_FACTOR_SRC_ALPHA, + OneMinusSrcAlpha = vk::BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, + DstAlpha = vk::BLEND_FACTOR_DST_ALPHA, + OneMinusDstAlpha = vk::BLEND_FACTOR_ONE_MINUS_DST_ALPHA, + ConstantColor = vk::BLEND_FACTOR_CONSTANT_COLOR, + OneMinusConstantColor = vk::BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR, + ConstantAlpha = vk::BLEND_FACTOR_CONSTANT_ALPHA, + OneMinusConstantAlpha = vk::BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA, + SrcAlphaSaturate = vk::BLEND_FACTOR_SRC_ALPHA_SATURATE, + Src1Color = vk::BLEND_FACTOR_SRC1_COLOR, + OneMinusSrc1Color = vk::BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, + Src1Alpha = vk::BLEND_FACTOR_SRC1_ALPHA, + OneMinusSrc1Alpha = vk::BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/cache.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/cache.rs new file mode 100644 index 0000000..8ef7fa2 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/cache.rs @@ -0,0 +1,252 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Cache the pipeline objects to disk for faster reloads. +//! +//! A pipeline cache is an opaque type that allow you to cache your graphics and compute +//! pipelines on the disk. +//! +//! You can create either an empty cache or a cache from some initial data. Whenever you create a +//! graphics or compute pipeline, you have the possibility to pass a reference to that cache. +//! TODO: ^ that's not the case yet +//! The Vulkan implementation will then look in the cache for an existing entry, or add one if it +//! doesn't exist. +//! +//! Once that is done, you can extract the data from the cache and store it. See the documentation +//! of [`get_data`](struct.PipelineCache.html#method.get_data) for example of how to store the data +//! on the disk, and [`with_data`](struct.PipelineCache.html#method.with_data) for how to reload it. +//! + +use std::mem; +use std::ptr; +use std::sync::Arc; + +use device::Device; + +use OomError; +use VulkanObject; +use check_errors; +use vk; + +/// Opaque cache that contains pipeline objects. +/// +/// See [the documentation of the module](index.html) for more info. +pub struct PipelineCache { + device: Arc<Device>, + cache: vk::PipelineCache, +} + +impl PipelineCache { + /// Builds a new pipeline cache from existing data. The data must have been previously obtained + /// with [`get_data`](#method.get_data). + /// + /// The data passed to this function will most likely be blindly trusted by the Vulkan + /// implementation. Therefore you can easily crash your application or the system by passing + /// wrong data. Hence why this function is unsafe. + /// + /// # Example + /// + /// This example loads a cache from a file, if it exists. + /// See [`get_data`](#method.get_data) for how to store the data in a file. + /// TODO: there's a header in the cached data that must be checked ; talk about this + /// + /// ``` + /// # use std::sync::Arc; + /// # use vulkano::device::Device; + /// use std::fs::File; + /// use std::io::Read; + /// use vulkano::pipeline::cache::PipelineCache; + /// # let device: Arc<Device> = return; + /// + /// let data = { + /// let file = File::open("pipeline_cache.bin"); + /// if let Ok(mut file) = file { + /// let mut data = Vec::new(); + /// if let Ok(_) = file.read_to_end(&mut data) { + /// Some(data) + /// } else { None } + /// } else { None } + /// }; + /// + /// let cache = if let Some(data) = data { + /// // This is unsafe because there is no way to be sure that the file contains valid data. + /// unsafe { PipelineCache::with_data(device.clone(), &data).unwrap() } + /// } else { + /// PipelineCache::empty(device.clone()).unwrap() + /// }; + /// ``` + #[inline] + pub unsafe fn with_data(device: Arc<Device>, initial_data: &[u8]) + -> Result<Arc<PipelineCache>, OomError> { + PipelineCache::new_impl(device, Some(initial_data)) + } + + /// Builds a new empty pipeline cache. + /// + /// # Example + /// + /// ``` + /// # use std::sync::Arc; + /// # use vulkano::device::Device; + /// use vulkano::pipeline::cache::PipelineCache; + /// # let device: Arc<Device> = return; + /// let cache = PipelineCache::empty(device.clone()).unwrap(); + /// ``` + #[inline] + pub fn empty(device: Arc<Device>) -> Result<Arc<PipelineCache>, OomError> { + unsafe { PipelineCache::new_impl(device, None) } + } + + // Actual implementation of the constructor. + unsafe fn new_impl(device: Arc<Device>, initial_data: Option<&[u8]>) + -> Result<Arc<PipelineCache>, OomError> { + let vk = device.pointers(); + + let cache = { + let infos = vk::PipelineCacheCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + initialDataSize: initial_data.map(|d| d.len()).unwrap_or(0), + pInitialData: initial_data + .map(|d| d.as_ptr() as *const _) + .unwrap_or(ptr::null()), + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreatePipelineCache(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(PipelineCache { + device: device.clone(), + cache: cache, + })) + } + + /// Merges other pipeline caches into this one. + /// + /// It is `self` that is modified here. The pipeline caches passed as parameter are untouched. + /// + /// # Panic + /// + /// - Panics if `self` is included in the list of other pipelines. + /// + // FIXME: vkMergePipelineCaches is not thread safe for the destination cache + // TODO: write example + pub fn merge<'a, I>(&self, pipelines: I) -> Result<(), OomError> + where I: IntoIterator<Item = &'a &'a Arc<PipelineCache>> + { + unsafe { + let vk = self.device.pointers(); + + let pipelines = pipelines + .into_iter() + .map(|pipeline| { + assert!(&***pipeline as *const _ != &*self as *const _); + pipeline.cache + }) + .collect::<Vec<_>>(); + + check_errors(vk.MergePipelineCaches(self.device.internal_object(), + self.cache, + pipelines.len() as u32, + pipelines.as_ptr()))?; + + Ok(()) + } + } + + /// Obtains the data from the cache. + /// + /// This data can be stored and then reloaded and passed to `PipelineCache::with_data`. + /// + /// # Example + /// + /// This example stores the data of a pipeline cache on the disk. + /// See [`with_data`](#method.with_data) for how to reload it. + /// + /// ``` + /// use std::fs; + /// use std::fs::File; + /// use std::io::Write; + /// # use std::sync::Arc; + /// # use vulkano::pipeline::cache::PipelineCache; + /// + /// # let cache: Arc<PipelineCache> = return; + /// // If an error happens (eg. no permission for the file) we simply skip storing the cache. + /// if let Ok(data) = cache.get_data() { + /// if let Ok(mut file) = File::create("pipeline_cache.bin.tmp") { + /// if let Ok(_) = file.write_all(&data) { + /// let _ = fs::rename("pipeline_cache.bin.tmp", "pipeline_cache.bin"); + /// } else { + /// let _ = fs::remove_file("pipeline_cache.bin.tmp"); + /// } + /// } + /// } + /// ``` + pub fn get_data(&self) -> Result<Vec<u8>, OomError> { + unsafe { + let vk = self.device.pointers(); + + let mut num = 0; + check_errors(vk.GetPipelineCacheData(self.device.internal_object(), + self.cache, + &mut num, + ptr::null_mut()))?; + + let mut data: Vec<u8> = Vec::with_capacity(num as usize); + check_errors(vk.GetPipelineCacheData(self.device.internal_object(), + self.cache, + &mut num, + data.as_mut_ptr() as *mut _))?; + data.set_len(num as usize); + + Ok(data) + } + } +} + +unsafe impl VulkanObject for PipelineCache { + type Object = vk::PipelineCache; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT; + + #[inline] + fn internal_object(&self) -> vk::PipelineCache { + self.cache + } +} + +impl Drop for PipelineCache { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyPipelineCache(self.device.internal_object(), self.cache, ptr::null()); + } + } +} + +#[cfg(test)] +mod tests { + use pipeline::cache::PipelineCache; + + #[test] + fn merge_self_forbidden() { + let (device, queue) = gfx_dev_and_queue!(); + let pipeline = PipelineCache::empty(device).unwrap(); + assert_should_panic!({ + pipeline.merge(&[&pipeline]).unwrap(); + }); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/compute_pipeline.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/compute_pipeline.rs new file mode 100644 index 0000000..2db5164 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/compute_pipeline.rs @@ -0,0 +1,996 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::marker::PhantomData; +use std::mem; +use std::ptr; +use std::sync::Arc; + +use descriptor::descriptor::DescriptorDesc; +use descriptor::descriptor_set::UnsafeDescriptorSetLayout; +use descriptor::pipeline_layout::PipelineLayout; +use descriptor::pipeline_layout::PipelineLayoutAbstract; +use descriptor::pipeline_layout::PipelineLayoutCreationError; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use descriptor::pipeline_layout::PipelineLayoutDescPcRange; +use descriptor::pipeline_layout::PipelineLayoutNotSupersetError; +use descriptor::pipeline_layout::PipelineLayoutSuperset; +use descriptor::pipeline_layout::PipelineLayoutSys; +use pipeline::shader::EntryPointAbstract; +use pipeline::shader::SpecializationConstants; + +use Error; +use OomError; +use SafeDeref; +use VulkanObject; +use check_errors; +use device::Device; +use device::DeviceOwned; +use vk; + +/// A pipeline object that describes to the Vulkan implementation how it should perform compute +/// operations. +/// +/// The template parameter contains the descriptor set to use with this pipeline. +/// +/// All compute pipeline objects implement the `ComputePipelineAbstract` trait. You can turn any +/// `Arc<ComputePipeline<Pl>>` into an `Arc<ComputePipelineAbstract>` if necessary. +pub struct ComputePipeline<Pl> { + inner: Inner, + pipeline_layout: Pl, +} + +struct Inner { + pipeline: vk::Pipeline, + device: Arc<Device>, +} + +impl ComputePipeline<()> { + /// Builds a new `ComputePipeline`. + pub fn new<Cs>( + device: Arc<Device>, shader: &Cs, specialization: &Cs::SpecializationConstants) + -> Result<ComputePipeline<PipelineLayout<Cs::PipelineLayout>>, ComputePipelineCreationError> + where Cs::PipelineLayout: Clone, + Cs: EntryPointAbstract + { + unsafe { + let pipeline_layout = shader.layout().clone().build(device.clone())?; + ComputePipeline::with_unchecked_pipeline_layout(device, + shader, + specialization, + pipeline_layout) + } + } +} + +impl<Pl> ComputePipeline<Pl> { + /// Builds a new `ComputePipeline` with a specific pipeline layout. + /// + /// An error will be returned if the pipeline layout isn't a superset of what the shader + /// uses. + pub fn with_pipeline_layout<Cs>(device: Arc<Device>, shader: &Cs, + specialization: &Cs::SpecializationConstants, + pipeline_layout: Pl) + -> Result<ComputePipeline<Pl>, ComputePipelineCreationError> + where Cs::PipelineLayout: Clone, + Cs: EntryPointAbstract, + Pl: PipelineLayoutAbstract + { + unsafe { + PipelineLayoutSuperset::ensure_superset_of(&pipeline_layout, shader.layout())?; + ComputePipeline::with_unchecked_pipeline_layout(device, + shader, + specialization, + pipeline_layout) + } + } + + /// Same as `with_pipeline_layout`, but doesn't check whether the pipeline layout is a + /// superset of what the shader expects. + pub unsafe fn with_unchecked_pipeline_layout<Cs>( + device: Arc<Device>, shader: &Cs, specialization: &Cs::SpecializationConstants, + pipeline_layout: Pl) + -> Result<ComputePipeline<Pl>, ComputePipelineCreationError> + where Cs::PipelineLayout: Clone, + Cs: EntryPointAbstract, + Pl: PipelineLayoutAbstract + { + let vk = device.pointers(); + + let pipeline = { + let spec_descriptors = Cs::SpecializationConstants::descriptors(); + let specialization = vk::SpecializationInfo { + mapEntryCount: spec_descriptors.len() as u32, + pMapEntries: spec_descriptors.as_ptr() as *const _, + dataSize: mem::size_of_val(specialization), + pData: specialization as *const Cs::SpecializationConstants as *const _, + }; + + let stage = vk::PipelineShaderStageCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, + stage: vk::SHADER_STAGE_COMPUTE_BIT, + module: shader.module().internal_object(), + pName: shader.name().as_ptr(), + pSpecializationInfo: if specialization.dataSize == 0 { + ptr::null() + } else { + &specialization + }, + }; + + let infos = vk::ComputePipelineCreateInfo { + sType: vk::STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, + stage: stage, + layout: PipelineLayoutAbstract::sys(&pipeline_layout).internal_object(), + basePipelineHandle: 0, + basePipelineIndex: 0, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateComputePipelines(device.internal_object(), + 0, + 1, + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(ComputePipeline { + inner: Inner { + device: device.clone(), + pipeline: pipeline, + }, + pipeline_layout: pipeline_layout, + }) + } +} + +impl<Pl> fmt::Debug for ComputePipeline<Pl> { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan compute pipeline {:?}>", self.inner.pipeline) + } +} + +impl<Pl> ComputePipeline<Pl> { + /// Returns the `Device` this compute pipeline was created with. + #[inline] + pub fn device(&self) -> &Arc<Device> { + &self.inner.device + } + + /// Returns the pipeline layout used in this compute pipeline. + #[inline] + pub fn layout(&self) -> &Pl { + &self.pipeline_layout + } +} + +/// Trait implemented on all compute pipelines. +pub unsafe trait ComputePipelineAbstract: PipelineLayoutAbstract { + /// Returns an opaque object that represents the inside of the compute pipeline. + fn inner(&self) -> ComputePipelineSys; +} + +unsafe impl<Pl> ComputePipelineAbstract for ComputePipeline<Pl> + where Pl: PipelineLayoutAbstract +{ + #[inline] + fn inner(&self) -> ComputePipelineSys { + ComputePipelineSys(self.inner.pipeline, PhantomData) + } +} + +unsafe impl<T> ComputePipelineAbstract for T + where T: SafeDeref, + T::Target: ComputePipelineAbstract +{ + #[inline] + fn inner(&self) -> ComputePipelineSys { + (**self).inner() + } +} + +/// Opaque object that represents the inside of the compute pipeline. Can be made into a trait +/// object. +#[derive(Debug, Copy, Clone)] +pub struct ComputePipelineSys<'a>(vk::Pipeline, PhantomData<&'a ()>); + +unsafe impl<'a> VulkanObject for ComputePipelineSys<'a> { + type Object = vk::Pipeline; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT; + + #[inline] + fn internal_object(&self) -> vk::Pipeline { + self.0 + } +} + +unsafe impl<Pl> PipelineLayoutAbstract for ComputePipeline<Pl> + where Pl: PipelineLayoutAbstract +{ + #[inline] + fn sys(&self) -> PipelineLayoutSys { + self.layout().sys() + } + + #[inline] + fn descriptor_set_layout(&self, index: usize) -> Option<&Arc<UnsafeDescriptorSetLayout>> { + self.layout().descriptor_set_layout(index) + } +} + +unsafe impl<Pl> PipelineLayoutDesc for ComputePipeline<Pl> + where Pl: PipelineLayoutDesc +{ + #[inline] + fn num_sets(&self) -> usize { + self.pipeline_layout.num_sets() + } + + #[inline] + fn num_bindings_in_set(&self, set: usize) -> Option<usize> { + self.pipeline_layout.num_bindings_in_set(set) + } + + #[inline] + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> { + self.pipeline_layout.descriptor(set, binding) + } + + #[inline] + fn num_push_constants_ranges(&self) -> usize { + self.pipeline_layout.num_push_constants_ranges() + } + + #[inline] + fn push_constants_range(&self, num: usize) -> Option<PipelineLayoutDescPcRange> { + self.pipeline_layout.push_constants_range(num) + } +} + +unsafe impl<Pl> DeviceOwned for ComputePipeline<Pl> { + #[inline] + fn device(&self) -> &Arc<Device> { + self.device() + } +} + +// TODO: remove in favor of ComputePipelineAbstract? +unsafe impl<Pl> VulkanObject for ComputePipeline<Pl> { + type Object = vk::Pipeline; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT; + + #[inline] + fn internal_object(&self) -> vk::Pipeline { + self.inner.pipeline + } +} + +impl Drop for Inner { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyPipeline(self.device.internal_object(), self.pipeline, ptr::null()); + } + } +} + +/// Error that can happen when creating a compute pipeline. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ComputePipelineCreationError { + /// Not enough memory. + OomError(OomError), + /// Error while creating the pipeline layout object. + PipelineLayoutCreationError(PipelineLayoutCreationError), + /// The pipeline layout is not compatible with what the shader expects. + IncompatiblePipelineLayout(PipelineLayoutNotSupersetError), +} + +impl error::Error for ComputePipelineCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + ComputePipelineCreationError::OomError(_) => "not enough memory available", + ComputePipelineCreationError::PipelineLayoutCreationError(_) => + "error while creating the pipeline layout object", + ComputePipelineCreationError::IncompatiblePipelineLayout(_) => + "the pipeline layout is not compatible with what the shader expects", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + ComputePipelineCreationError::OomError(ref err) => Some(err), + ComputePipelineCreationError::PipelineLayoutCreationError(ref err) => Some(err), + ComputePipelineCreationError::IncompatiblePipelineLayout(ref err) => Some(err), + } + } +} + +impl fmt::Display for ComputePipelineCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for ComputePipelineCreationError { + #[inline] + fn from(err: OomError) -> ComputePipelineCreationError { + ComputePipelineCreationError::OomError(err) + } +} + +impl From<PipelineLayoutCreationError> for ComputePipelineCreationError { + #[inline] + fn from(err: PipelineLayoutCreationError) -> ComputePipelineCreationError { + ComputePipelineCreationError::PipelineLayoutCreationError(err) + } +} + +impl From<PipelineLayoutNotSupersetError> for ComputePipelineCreationError { + #[inline] + fn from(err: PipelineLayoutNotSupersetError) -> ComputePipelineCreationError { + ComputePipelineCreationError::IncompatiblePipelineLayout(err) + } +} + +impl From<Error> for ComputePipelineCreationError { + #[inline] + fn from(err: Error) -> ComputePipelineCreationError { + match err { + err @ Error::OutOfHostMemory => { + ComputePipelineCreationError::OomError(OomError::from(err)) + }, + err @ Error::OutOfDeviceMemory => { + ComputePipelineCreationError::OomError(OomError::from(err)) + }, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +#[cfg(test)] +mod tests { + use buffer::BufferUsage; + use buffer::CpuAccessibleBuffer; + use command_buffer::AutoCommandBufferBuilder; + use descriptor::descriptor::DescriptorBufferDesc; + use descriptor::descriptor::DescriptorDesc; + use descriptor::descriptor::DescriptorDescTy; + use descriptor::descriptor::ShaderStages; + use descriptor::descriptor_set::PersistentDescriptorSet; + use descriptor::pipeline_layout::PipelineLayoutDesc; + use descriptor::pipeline_layout::PipelineLayoutDescPcRange; + use pipeline::ComputePipeline; + use pipeline::shader::ShaderModule; + use pipeline::shader::SpecializationConstants; + use pipeline::shader::SpecializationMapEntry; + use std::ffi::CStr; + use std::sync::Arc; + use sync::GpuFuture; + use sync::now; + + // TODO: test for basic creation + // TODO: test for pipeline layout error + + #[test] + fn spec_constants() { + // This test checks whether specialization constants work. + // It executes a single compute shader (one invocation) that writes the value of a spec. + // constant to a buffer. The buffer content is then checked for the right value. + + let (device, queue) = gfx_dev_and_queue!(); + + let module = unsafe { + /* + #version 450 + + layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + + layout(constant_id = 83) const int VALUE = 0xdeadbeef; + + layout(set = 0, binding = 0) buffer Output { + int write; + } write; + + void main() { + write.write = VALUE; + } + */ + const MODULE: [u8; 480] = [ + 3, + 2, + 35, + 7, + 0, + 0, + 1, + 0, + 1, + 0, + 8, + 0, + 14, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 17, + 0, + 2, + 0, + 1, + 0, + 0, + 0, + 11, + 0, + 6, + 0, + 1, + 0, + 0, + 0, + 71, + 76, + 83, + 76, + 46, + 115, + 116, + 100, + 46, + 52, + 53, + 48, + 0, + 0, + 0, + 0, + 14, + 0, + 3, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 15, + 0, + 5, + 0, + 5, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 109, + 97, + 105, + 110, + 0, + 0, + 0, + 0, + 16, + 0, + 6, + 0, + 4, + 0, + 0, + 0, + 17, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 3, + 0, + 3, + 0, + 2, + 0, + 0, + 0, + 194, + 1, + 0, + 0, + 5, + 0, + 4, + 0, + 4, + 0, + 0, + 0, + 109, + 97, + 105, + 110, + 0, + 0, + 0, + 0, + 5, + 0, + 4, + 0, + 7, + 0, + 0, + 0, + 79, + 117, + 116, + 112, + 117, + 116, + 0, + 0, + 6, + 0, + 5, + 0, + 7, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 119, + 114, + 105, + 116, + 101, + 0, + 0, + 0, + 5, + 0, + 4, + 0, + 9, + 0, + 0, + 0, + 119, + 114, + 105, + 116, + 101, + 0, + 0, + 0, + 5, + 0, + 4, + 0, + 11, + 0, + 0, + 0, + 86, + 65, + 76, + 85, + 69, + 0, + 0, + 0, + 72, + 0, + 5, + 0, + 7, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 35, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 71, + 0, + 3, + 0, + 7, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 71, + 0, + 4, + 0, + 9, + 0, + 0, + 0, + 34, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 71, + 0, + 4, + 0, + 9, + 0, + 0, + 0, + 33, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 71, + 0, + 4, + 0, + 11, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 83, + 0, + 0, + 0, + 19, + 0, + 2, + 0, + 2, + 0, + 0, + 0, + 33, + 0, + 3, + 0, + 3, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 21, + 0, + 4, + 0, + 6, + 0, + 0, + 0, + 32, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 30, + 0, + 3, + 0, + 7, + 0, + 0, + 0, + 6, + 0, + 0, + 0, + 32, + 0, + 4, + 0, + 8, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 7, + 0, + 0, + 0, + 59, + 0, + 4, + 0, + 8, + 0, + 0, + 0, + 9, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 43, + 0, + 4, + 0, + 6, + 0, + 0, + 0, + 10, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 50, + 0, + 4, + 0, + 6, + 0, + 0, + 0, + 11, + 0, + 0, + 0, + 239, + 190, + 173, + 222, + 32, + 0, + 4, + 0, + 12, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 6, + 0, + 0, + 0, + 54, + 0, + 5, + 0, + 2, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 248, + 0, + 2, + 0, + 5, + 0, + 0, + 0, + 65, + 0, + 5, + 0, + 12, + 0, + 0, + 0, + 13, + 0, + 0, + 0, + 9, + 0, + 0, + 0, + 10, + 0, + 0, + 0, + 62, + 0, + 3, + 0, + 13, + 0, + 0, + 0, + 11, + 0, + 0, + 0, + 253, + 0, + 1, + 0, + 56, + 0, + 1, + 0, + ]; + ShaderModule::new(device.clone(), &MODULE).unwrap() + }; + + let shader = unsafe { + #[derive(Debug, Copy, Clone)] + struct Layout; + unsafe impl PipelineLayoutDesc for Layout { + fn num_sets(&self) -> usize { + 1 + } + fn num_bindings_in_set(&self, set: usize) -> Option<usize> { + match set { + 0 => Some(1), + _ => None, + } + } + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> { + match (set, binding) { + (0, 0) => Some(DescriptorDesc { + ty: DescriptorDescTy::Buffer(DescriptorBufferDesc { + dynamic: Some(false), + storage: true, + }), + array_count: 1, + stages: ShaderStages { + compute: true, + ..ShaderStages::none() + }, + readonly: true, + }), + _ => None, + } + } + fn num_push_constants_ranges(&self) -> usize { + 0 + } + fn push_constants_range(&self, num: usize) -> Option<PipelineLayoutDescPcRange> { + None + } + } + + static NAME: [u8; 5] = [109, 97, 105, 110, 0]; // "main" + module.compute_entry_point(CStr::from_ptr(NAME.as_ptr() as *const _), Layout) + }; + + #[derive(Debug, Copy, Clone)] + #[allow(non_snake_case)] + #[repr(C)] + struct SpecConsts { + VALUE: i32, + } + unsafe impl SpecializationConstants for SpecConsts { + fn descriptors() -> &'static [SpecializationMapEntry] { + static DESCRIPTORS: [SpecializationMapEntry; 1] = [ + SpecializationMapEntry { + constant_id: 83, + offset: 0, + size: 4, + }, + ]; + &DESCRIPTORS + } + } + + let pipeline = Arc::new(ComputePipeline::new(device.clone(), + &shader, + &SpecConsts { VALUE: 0x12345678 }) + .unwrap()); + + let data_buffer = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), 0) + .unwrap(); + let set = PersistentDescriptorSet::start(pipeline.clone(), 0) + .add_buffer(data_buffer.clone()) + .unwrap() + .build() + .unwrap(); + + let command_buffer = AutoCommandBufferBuilder::primary_one_time_submit(device.clone(), + queue.family()) + .unwrap() + .dispatch([1, 1, 1], pipeline, set, ()) + .unwrap() + .build() + .unwrap(); + + let future = now(device.clone()) + .then_execute(queue.clone(), command_buffer) + .unwrap() + .then_signal_fence_and_flush() + .unwrap(); + future.wait(None).unwrap(); + + let data_buffer_content = data_buffer.read().unwrap(); + assert_eq!(*data_buffer_content, 0x12345678); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/depth_stencil.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/depth_stencil.rs new file mode 100644 index 0000000..e871100 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/depth_stencil.rs @@ -0,0 +1,223 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Depth and stencil operations description. +//! +//! After the fragment shader has finished running, each fragment goes through the depth +//! and stencil tests. +//! +//! The depth test passes of fails depending on how the depth value of each fragment compares +//! to the existing depth value in the depth buffer at that fragment's location. Depth values +//! are always between 0.0 and 1.0. +//! +//! The stencil test passes or fails depending on how a reference value compares to the existing +//! value in the stencil buffer at each fragment's location. Depending on the outcome of the +//! depth and stencil tests, the value of the stencil buffer at that location can be updated. + +use std::ops::Range; +use std::u32; +use vk; + +/// Configuration of the depth and stencil tests. +#[derive(Debug, Clone)] +pub struct DepthStencil { + /// Comparison to use between the depth value of each fragment and the depth value currently + /// in the depth buffer. + pub depth_compare: Compare, + + /// If `true`, then the value in the depth buffer will be updated when the depth test succeeds. + pub depth_write: bool, + + /// Allows you to ask the GPU to exclude fragments that are outside of a certain range. This is + /// done in addition to the regular depth test. + pub depth_bounds_test: DepthBounds, + + /// Stencil operations to use for points, lines and triangles whose front is facing the user. + pub stencil_front: Stencil, + + /// Stencil operations to use for triangles whose back is facing the user. + pub stencil_back: Stencil, +} + +impl DepthStencil { + /// Creates a `DepthStencil` where both the depth and stencil tests are disabled and have + /// no effect. + #[inline] + pub fn disabled() -> DepthStencil { + DepthStencil { + depth_write: false, + depth_compare: Compare::Always, + depth_bounds_test: DepthBounds::Disabled, + stencil_front: Default::default(), + stencil_back: Default::default(), + } + } + + /// Creates a `DepthStencil` with a `Less` depth test, `depth_write` set to true, and stencil + /// testing disabled. + #[inline] + pub fn simple_depth_test() -> DepthStencil { + DepthStencil { + depth_write: true, + depth_compare: Compare::Less, + depth_bounds_test: DepthBounds::Disabled, + stencil_front: Default::default(), + stencil_back: Default::default(), + } + } +} + +impl Default for DepthStencil { + #[inline] + fn default() -> DepthStencil { + DepthStencil::disabled() + } +} + +/// Configuration of a stencil test. +#[derive(Debug, Copy, Clone)] +pub struct Stencil { + /// The comparison to perform between the existing stencil value in the stencil buffer, and + /// the reference value (given by `reference`). + pub compare: Compare, + + /// The operation to perform when both the depth test and the stencil test passed. + pub pass_op: StencilOp, + + /// The operation to perform when the stencil test failed. + pub fail_op: StencilOp, + + /// The operation to perform when the stencil test passed but the depth test failed. + pub depth_fail_op: StencilOp, + + /// Selects the bits of the unsigned integer stencil values participating in the stencil test. + /// + /// Ignored if `compare` is `Never` or `Always`. + /// + /// If `None`, then this value is dynamic and will need to be set when drawing. Doesn't apply + /// if `compare` is `Never` or `Always`. + /// + /// Note that if this value is `Some` in `stencil_front`, it must also be `Some` in + /// `stencil_back` (but the content can be different). If this value is `None` in + /// `stencil_front`, then it must also be `None` in `stencil_back`. This rule doesn't apply + /// if `compare` is `Never` or `Always`. + pub compare_mask: Option<u32>, + + /// Selects the bits of the unsigned integer stencil values updated by the stencil test in the + /// stencil framebuffer attachment. + /// + /// If `None`, then this value is dynamic and will need to be set when drawing. + /// + /// Note that if this value is `Some` in `stencil_front`, it must also be `Some` in + /// `stencil_back` (but the content can be different). If this value is `None` in + /// `stencil_front`, then it must also be `None` in `stencil_back`. + pub write_mask: Option<u32>, + + /// Reference value that is used in the unsigned stencil comparison. + /// + /// If `None`, then this value is dynamic and will need to be set when drawing. + /// + /// Note that if this value is `Some` in `stencil_front`, it must also be `Some` in + /// `stencil_back` (but the content can be different). If this value is `None` in + /// `stencil_front`, then it must also be `None` in `stencil_back`. + pub reference: Option<u32>, +} + +impl Stencil { + /// Returns true if the stencil operation will always result in `Keep`. + #[inline] + pub fn always_keep(&self) -> bool { + match self.compare { + Compare::Always => self.pass_op == StencilOp::Keep && + self.depth_fail_op == StencilOp::Keep, + Compare::Never => self.fail_op == StencilOp::Keep, + _ => self.pass_op == StencilOp::Keep && self.fail_op == StencilOp::Keep && + self.depth_fail_op == StencilOp::Keep, + } + } +} + +impl Default for Stencil { + #[inline] + fn default() -> Stencil { + Stencil { + compare: Compare::Never, + pass_op: StencilOp::Keep, + fail_op: StencilOp::Keep, + depth_fail_op: StencilOp::Keep, + compare_mask: Some(u32::MAX), + write_mask: Some(u32::MAX), + reference: Some(u32::MAX), + } + } +} + +/// Operation to perform after the depth and stencil tests. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[repr(u32)] +pub enum StencilOp { + Keep = vk::STENCIL_OP_KEEP, + Zero = vk::STENCIL_OP_ZERO, + Replace = vk::STENCIL_OP_REPLACE, + IncrementAndClamp = vk::STENCIL_OP_INCREMENT_AND_CLAMP, + DecrementAndClamp = vk::STENCIL_OP_DECREMENT_AND_CLAMP, + Invert = vk::STENCIL_OP_INVERT, + IncrementAndWrap = vk::STENCIL_OP_INCREMENT_AND_WRAP, + DecrementAndWrap = vk::STENCIL_OP_DECREMENT_AND_WRAP, +} + +/// Allows you to ask the GPU to exclude fragments that are outside of a certain range. +#[derive(Debug, Clone, PartialEq)] +pub enum DepthBounds { + /// The test is disabled. All fragments pass the depth bounds test. + Disabled, + + /// Fragments that are within the given range do pass the test. Values are depth values + /// between 0.0 and 1.0. + Fixed(Range<f32>), + + /// The depth bounds test is enabled, but the range will need to specified when you submit + /// a draw command. + Dynamic, +} + +impl DepthBounds { + /// Returns true if equal to `DepthBounds::Dynamic`. + #[inline] + pub fn is_dynamic(&self) -> bool { + match self { + &DepthBounds::Dynamic => true, + _ => false, + } + } +} + +/// Specifies how two values should be compared to decide whether a test passes or fails. +/// +/// Used for both depth testing and stencil testing. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[repr(u32)] +pub enum Compare { + /// The test never passes. + Never = vk::COMPARE_OP_NEVER, + /// The test passes if `value < reference_value`. + Less = vk::COMPARE_OP_LESS, + /// The test passes if `value == reference_value`. + Equal = vk::COMPARE_OP_EQUAL, + /// The test passes if `value <= reference_value`. + LessOrEqual = vk::COMPARE_OP_LESS_OR_EQUAL, + /// The test passes if `value > reference_value`. + Greater = vk::COMPARE_OP_GREATER, + /// The test passes if `value != reference_value`. + NotEqual = vk::COMPARE_OP_NOT_EQUAL, + /// The test passes if `value >= reference_value`. + GreaterOrEqual = vk::COMPARE_OP_GREATER_OR_EQUAL, + /// The test always passes. + Always = vk::COMPARE_OP_ALWAYS, +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/builder.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/builder.rs new file mode 100644 index 0000000..970a52c --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/builder.rs @@ -0,0 +1,1809 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +// TODO: graphics pipeline params are deprecated, but are still the primary implementation in order +// to avoid duplicating code, so we hide the warnings for now +#![allow(deprecated)] + +use smallvec::SmallVec; +use std::mem; +use std::ptr; +use std::sync::Arc; +use std::u32; + +use descriptor::pipeline_layout::PipelineLayoutAbstract; +use device::Device; +use framebuffer::RenderPassAbstract; +use framebuffer::Subpass; +use pipeline::blend::AttachmentBlend; +use pipeline::blend::AttachmentsBlend; +use pipeline::blend::Blend; +use pipeline::blend::LogicOp; +use pipeline::depth_stencil::Compare; +use pipeline::depth_stencil::DepthBounds; +use pipeline::depth_stencil::DepthStencil; +use pipeline::graphics_pipeline::GraphicsPipeline; +use pipeline::graphics_pipeline::GraphicsPipelineCreationError; +use pipeline::graphics_pipeline::Inner as GraphicsPipelineInner; +use pipeline::input_assembly::PrimitiveTopology; +use pipeline::raster::CullMode; +use pipeline::raster::DepthBiasControl; +use pipeline::raster::FrontFace; +use pipeline::raster::PolygonMode; +use pipeline::raster::Rasterization; +use pipeline::shader::EmptyEntryPointDummy; +use pipeline::shader::GraphicsEntryPointAbstract; +use pipeline::shader::GraphicsShaderType; +use pipeline::shader::ShaderInterfaceDefMatch; +use pipeline::shader::SpecializationConstants; +use pipeline::vertex::BufferlessDefinition; +use pipeline::vertex::SingleBufferDefinition; +use pipeline::vertex::VertexDefinition; +use pipeline::viewport::Scissor; +use pipeline::viewport::Viewport; +use pipeline::viewport::ViewportsState; + +use VulkanObject; +use check_errors; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use descriptor::pipeline_layout::PipelineLayoutDescTweaks; +use descriptor::pipeline_layout::PipelineLayoutSuperset; +use framebuffer::RenderPassSubpassInterface; +use vk; + +/// Prototype for a `GraphicsPipeline`. +// TODO: we can optimize this by filling directly the raw vk structs +pub struct GraphicsPipelineBuilder<Vdef, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs, Fss, Rp> { + vertex_input: Vdef, + vertex_shader: Option<(Vs, Vss)>, + input_assembly: vk::PipelineInputAssemblyStateCreateInfo, + // Note: the `input_assembly_topology` member is temporary in order to not lose information + // about the number of patches per primitive. + input_assembly_topology: PrimitiveTopology, + tessellation: Option<TessInfo<Tcs, Tcss, Tes, Tess>>, + geometry_shader: Option<(Gs, Gss)>, + viewport: Option<ViewportsState>, + raster: Rasterization, + multisample: vk::PipelineMultisampleStateCreateInfo, + fragment_shader: Option<(Fs, Fss)>, + depth_stencil: DepthStencil, + blend: Blend, + render_pass: Option<Subpass<Rp>>, +} + +// Additional parameters if tessellation is used. +#[derive(Copy, Clone)] +struct TessInfo<Tcs, Tcss, Tes, Tess> { + tessellation_control_shader: (Tcs, Tcss), + tessellation_evaluation_shader: (Tes, Tess), +} + +impl + GraphicsPipelineBuilder<BufferlessDefinition, + EmptyEntryPointDummy, + (), + EmptyEntryPointDummy, + (), + EmptyEntryPointDummy, + (), + EmptyEntryPointDummy, + (), + EmptyEntryPointDummy, + (), + ()> { + /// Builds a new empty builder. + pub(super) fn new() -> Self { + unsafe { + GraphicsPipelineBuilder { + vertex_input: BufferlessDefinition, + vertex_shader: None, + input_assembly: vk::PipelineInputAssemblyStateCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, + topology: PrimitiveTopology::TriangleList.into(), + ..mem::zeroed() + }, + input_assembly_topology: PrimitiveTopology::TriangleList, + tessellation: None, + geometry_shader: None, + viewport: None, + raster: Default::default(), + multisample: vk::PipelineMultisampleStateCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, + ..mem::zeroed() + }, + fragment_shader: None, + depth_stencil: DepthStencil::disabled(), + blend: Blend::pass_through(), + render_pass: None, + } + } + } +} + +impl<Vdef, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs, Fss, Rp> + GraphicsPipelineBuilder<Vdef, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs, Fss, Rp> + where Vdef: VertexDefinition<Vs::InputDefinition>, + Vs: GraphicsEntryPointAbstract, + Fs: GraphicsEntryPointAbstract, + Gs: GraphicsEntryPointAbstract, + Tcs: GraphicsEntryPointAbstract, + Tes: GraphicsEntryPointAbstract, + Vss: SpecializationConstants, + Tcss: SpecializationConstants, + Tess: SpecializationConstants, + Gss: SpecializationConstants, + Fss: SpecializationConstants, + Vs::PipelineLayout: Clone + 'static + Send + Sync, // TODO: shouldn't be required + Fs::PipelineLayout: Clone + 'static + Send + Sync, // TODO: shouldn't be required + Tcs::PipelineLayout: Clone + 'static + Send + Sync, // TODO: shouldn't be required + Tes::PipelineLayout: Clone + 'static + Send + Sync, // TODO: shouldn't be required + Gs::PipelineLayout: Clone + 'static + Send + Sync, // TODO: shouldn't be required + Tcs::InputDefinition: ShaderInterfaceDefMatch<Vs::OutputDefinition>, + Tes::InputDefinition: ShaderInterfaceDefMatch<Tcs::OutputDefinition>, + Gs::InputDefinition: ShaderInterfaceDefMatch<Tes::OutputDefinition> + + ShaderInterfaceDefMatch<Vs::OutputDefinition>, + Fs::InputDefinition: ShaderInterfaceDefMatch<Gs::OutputDefinition> + + ShaderInterfaceDefMatch<Tes::OutputDefinition> + + ShaderInterfaceDefMatch<Vs::OutputDefinition>, + Rp: RenderPassAbstract + RenderPassSubpassInterface<Fs::OutputDefinition> +{ + /// Builds the graphics pipeline, using an inferred a pipeline layout. + // TODO: replace Box<PipelineLayoutAbstract> with a PipelineUnion struct without template params + pub fn build(self, device: Arc<Device>) + -> Result<GraphicsPipeline<Vdef, Box<PipelineLayoutAbstract + Send + Sync>, Rp>, + GraphicsPipelineCreationError> { + self.with_auto_layout(device, &[]) + } + + /// Builds the graphics pipeline, using an inferred pipeline layout with some dynamic buffers. + /// + /// Configures the inferred layout for each descriptor `(set, binding)` in `dynamic_buffers` to accept dynamic + /// buffers. + pub fn with_auto_layout(self, device: Arc<Device>, dynamic_buffers: &[(usize, usize)]) + -> Result<GraphicsPipeline<Vdef, Box<PipelineLayoutAbstract + Send + Sync>, Rp>, + GraphicsPipelineCreationError> + { + let pipeline_layout; + + if let Some(ref tess) = self.tessellation { + if let Some(ref gs) = self.geometry_shader { + if let Err(err) = tess.tessellation_control_shader + .0 + .input() + .matches(self.vertex_shader.as_ref().unwrap().0.output()) + { + return Err(GraphicsPipelineCreationError::VertexTessControlStagesMismatch(err)); + } + if let Err(err) = tess.tessellation_evaluation_shader + .0 + .input() + .matches(tess.tessellation_control_shader.0.output()) + { + return Err(GraphicsPipelineCreationError::TessControlTessEvalStagesMismatch(err)); + } + if let Err(err) = gs.0 + .input() + .matches(tess.tessellation_evaluation_shader.0.output()) + { + return Err(GraphicsPipelineCreationError::TessEvalGeometryStagesMismatch(err)); + } + if let Err(err) = self.fragment_shader + .as_ref() + .unwrap() + .0 + .input() + .matches(gs.0.output()) + { + return Err(GraphicsPipelineCreationError::GeometryFragmentStagesMismatch(err)); + } + + pipeline_layout = Box::new( + PipelineLayoutDescTweaks::new(self.vertex_shader.as_ref().unwrap().0.layout().clone() + .union(self.fragment_shader.as_ref().unwrap().0.layout().clone()) + .union(self.tessellation.as_ref().unwrap().tessellation_control_shader.0.layout().clone()) // FIXME: unwrap() + .union(self.tessellation.as_ref().unwrap().tessellation_evaluation_shader.0.layout().clone()) // FIXME: unwrap() + .union(self.geometry_shader.as_ref().unwrap().0.layout().clone()), // FIXME: unwrap() + dynamic_buffers.into_iter().cloned() + ).build(device.clone()).unwrap()) as Box<_>; // TODO: error + + } else { + if let Err(err) = tess.tessellation_control_shader + .0 + .input() + .matches(self.vertex_shader.as_ref().unwrap().0.output()) + { + return Err(GraphicsPipelineCreationError::VertexTessControlStagesMismatch(err)); + } + if let Err(err) = tess.tessellation_evaluation_shader + .0 + .input() + .matches(tess.tessellation_control_shader.0.output()) + { + return Err(GraphicsPipelineCreationError::TessControlTessEvalStagesMismatch(err)); + } + if let Err(err) = self.fragment_shader + .as_ref() + .unwrap() + .0 + .input() + .matches(tess.tessellation_evaluation_shader.0.output()) + { + return Err(GraphicsPipelineCreationError::TessEvalFragmentStagesMismatch(err)); + } + + pipeline_layout = Box::new( + PipelineLayoutDescTweaks::new(self.vertex_shader.as_ref().unwrap().0.layout().clone() + .union(self.fragment_shader.as_ref().unwrap().0.layout().clone()) + .union(self.tessellation.as_ref().unwrap().tessellation_control_shader.0.layout().clone()) // FIXME: unwrap() + .union(self.tessellation.as_ref().unwrap().tessellation_evaluation_shader.0.layout().clone()), // FIXME: unwrap() + dynamic_buffers.into_iter().cloned() + ).build(device.clone()).unwrap()) as Box<_>; // TODO: error + } + + } else { + if let Some(ref geometry_shader) = self.geometry_shader { + if let Err(err) = geometry_shader + .0 + .input() + .matches(self.vertex_shader.as_ref().unwrap().0.output()) + { + return Err(GraphicsPipelineCreationError::VertexGeometryStagesMismatch(err)); + } + if let Err(err) = self.fragment_shader + .as_ref() + .unwrap() + .0 + .input() + .matches(geometry_shader.0.output()) + { + return Err(GraphicsPipelineCreationError::GeometryFragmentStagesMismatch(err)); + } + + pipeline_layout = Box::new( + PipelineLayoutDescTweaks::new(self.vertex_shader.as_ref().unwrap().0.layout().clone() + .union(self.fragment_shader.as_ref().unwrap().0.layout().clone()) + .union(self.geometry_shader.as_ref().unwrap().0.layout().clone()), // FIXME: unwrap() + dynamic_buffers.into_iter().cloned() + ).build(device.clone()).unwrap()) as Box<_>; // TODO: error + + } else { + if let Err(err) = self.fragment_shader + .as_ref() + .unwrap() + .0 + .input() + .matches(self.vertex_shader.as_ref().unwrap().0.output()) + { + return Err(GraphicsPipelineCreationError::VertexFragmentStagesMismatch(err)); + } + + pipeline_layout = + Box::new( + PipelineLayoutDescTweaks::new(self.vertex_shader + .as_ref() + .unwrap() + .0 + .layout() + .clone() + .union(self.fragment_shader.as_ref().unwrap().0.layout().clone()), + dynamic_buffers.into_iter().cloned() + ).build(device.clone()).unwrap()) as Box<_>; // TODO: error + } + } + + self.with_pipeline_layout(device, pipeline_layout) + } + + /// Builds the graphics pipeline. + /// + /// Does the same as `build`, except that `build` automatically builds the pipeline layout + /// object corresponding to the union of your shaders while this function allows you to specify + /// the pipeline layout. + pub fn with_pipeline_layout<Pl>(mut self, device: Arc<Device>, pipeline_layout: Pl) + -> Result<GraphicsPipeline<Vdef, Pl, Rp>, + GraphicsPipelineCreationError> + where Pl: PipelineLayoutAbstract + { + // TODO: return errors instead of panicking if missing param + + let vk = device.pointers(); + + // Checking that the pipeline layout matches the shader stages. + // TODO: more details in the errors + PipelineLayoutSuperset::ensure_superset_of(&pipeline_layout, + self.vertex_shader + .as_ref() + .unwrap() + .0 + .layout())?; + PipelineLayoutSuperset::ensure_superset_of(&pipeline_layout, + self.fragment_shader + .as_ref() + .unwrap() + .0 + .layout())?; + if let Some(ref geometry_shader) = self.geometry_shader { + PipelineLayoutSuperset::ensure_superset_of(&pipeline_layout, + geometry_shader.0.layout())?; + } + if let Some(ref tess) = self.tessellation { + PipelineLayoutSuperset::ensure_superset_of(&pipeline_layout, + tess.tessellation_control_shader + .0 + .layout())?; + PipelineLayoutSuperset::ensure_superset_of(&pipeline_layout, + tess.tessellation_evaluation_shader + .0 + .layout())?; + } + + // Check that the subpass can accept the output of the fragment shader. + if !RenderPassSubpassInterface::is_compatible_with(&self.render_pass + .as_ref() + .unwrap() + .render_pass(), + self.render_pass + .as_ref() + .unwrap() + .index(), + self.fragment_shader + .as_ref() + .unwrap() + .0 + .output()) + { + return Err(GraphicsPipelineCreationError::FragmentShaderRenderPassIncompatible); + } + + // Will contain the list of dynamic states. Filled throughout this function. + let mut dynamic_states: SmallVec<[vk::DynamicState; 8]> = SmallVec::new(); + + // Creating the specialization constants of the various stages. + let vertex_shader_specialization = { + let spec_descriptors = Vss::descriptors(); + let constants = &self.vertex_shader.as_ref().unwrap().1; + vk::SpecializationInfo { + mapEntryCount: spec_descriptors.len() as u32, + pMapEntries: spec_descriptors.as_ptr() as *const _, + dataSize: mem::size_of_val(constants), + pData: constants as *const Vss as *const _, + } + }; + let tess_shader_specialization = if let Some(ref tess) = self.tessellation { + let tcs_spec = { + let spec_descriptors = Tcss::descriptors(); + let constants = &tess.tessellation_control_shader.1; + vk::SpecializationInfo { + mapEntryCount: spec_descriptors.len() as u32, + pMapEntries: spec_descriptors.as_ptr() as *const _, + dataSize: mem::size_of_val(constants), + pData: constants as *const Tcss as *const _, + } + }; + let tes_spec = { + let spec_descriptors = Tess::descriptors(); + let constants = &tess.tessellation_evaluation_shader.1; + vk::SpecializationInfo { + mapEntryCount: spec_descriptors.len() as u32, + pMapEntries: spec_descriptors.as_ptr() as *const _, + dataSize: mem::size_of_val(constants), + pData: constants as *const Tess as *const _, + } + }; + Some((tcs_spec, tes_spec)) + } else { + None + }; + let geometry_shader_specialization = if let Some(ref gs) = self.geometry_shader { + let spec_descriptors = Gss::descriptors(); + let constants = &gs.1; + Some(vk::SpecializationInfo { + mapEntryCount: spec_descriptors.len() as u32, + pMapEntries: spec_descriptors.as_ptr() as *const _, + dataSize: mem::size_of_val(constants), + pData: constants as *const Gss as *const _, + }) + } else { + None + }; + let fragment_shader_specialization = { + let spec_descriptors = Fss::descriptors(); + let constants = &self.fragment_shader.as_ref().unwrap().1; + vk::SpecializationInfo { + mapEntryCount: spec_descriptors.len() as u32, + pMapEntries: spec_descriptors.as_ptr() as *const _, + dataSize: mem::size_of_val(constants), + pData: constants as *const Fss as *const _, + } + }; + + // List of shader stages. + let stages = { + let mut stages = SmallVec::<[_; 5]>::new(); + + match self.vertex_shader.as_ref().unwrap().0.ty() { + GraphicsShaderType::Vertex => {}, + _ => return Err(GraphicsPipelineCreationError::WrongShaderType), + }; + + stages.push(vk::PipelineShaderStageCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + stage: vk::SHADER_STAGE_VERTEX_BIT, + module: self.vertex_shader + .as_ref() + .unwrap() + .0 + .module() + .internal_object(), + pName: self.vertex_shader.as_ref().unwrap().0.name().as_ptr(), + pSpecializationInfo: &vertex_shader_specialization as *const _, + }); + + match self.fragment_shader.as_ref().unwrap().0.ty() { + GraphicsShaderType::Fragment => {}, + _ => return Err(GraphicsPipelineCreationError::WrongShaderType), + }; + + stages.push(vk::PipelineShaderStageCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + stage: vk::SHADER_STAGE_FRAGMENT_BIT, + module: self.fragment_shader + .as_ref() + .unwrap() + .0 + .module() + .internal_object(), + pName: self.fragment_shader.as_ref().unwrap().0.name().as_ptr(), + pSpecializationInfo: &fragment_shader_specialization as *const _, + }); + + if let Some(ref gs) = self.geometry_shader { + if !device.enabled_features().geometry_shader { + return Err(GraphicsPipelineCreationError::GeometryShaderFeatureNotEnabled); + } + + stages.push(vk::PipelineShaderStageCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + stage: vk::SHADER_STAGE_GEOMETRY_BIT, + module: gs.0.module().internal_object(), + pName: gs.0.name().as_ptr(), + pSpecializationInfo: geometry_shader_specialization + .as_ref() + .unwrap() as + *const _, + }); + } + + if let Some(ref tess) = self.tessellation { + // FIXME: must check that the control shader and evaluation shader are compatible + + if !device.enabled_features().tessellation_shader { + return Err(GraphicsPipelineCreationError::TessellationShaderFeatureNotEnabled); + } + + match tess.tessellation_control_shader.0.ty() { + GraphicsShaderType::TessellationControl => {}, + _ => return Err(GraphicsPipelineCreationError::WrongShaderType), + }; + + match tess.tessellation_evaluation_shader.0.ty() { + GraphicsShaderType::TessellationEvaluation => {}, + _ => return Err(GraphicsPipelineCreationError::WrongShaderType), + }; + + stages.push(vk::PipelineShaderStageCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + stage: vk::SHADER_STAGE_TESSELLATION_CONTROL_BIT, + module: tess.tessellation_control_shader + .0 + .module() + .internal_object(), + pName: tess.tessellation_control_shader.0.name().as_ptr(), + pSpecializationInfo: &tess_shader_specialization + .as_ref() + .unwrap() + .0 as + *const _, + }); + + stages.push(vk::PipelineShaderStageCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + stage: vk::SHADER_STAGE_TESSELLATION_EVALUATION_BIT, + module: tess.tessellation_evaluation_shader + .0 + .module() + .internal_object(), + pName: tess.tessellation_evaluation_shader.0.name().as_ptr(), + pSpecializationInfo: &tess_shader_specialization + .as_ref() + .unwrap() + .1 as + *const _, + }); + } + + stages + }; + + // Vertex bindings. + let (binding_descriptions, attribute_descriptions) = { + let (buffers_iter, attribs_iter) = + self.vertex_input + .definition(self.vertex_shader.as_ref().unwrap().0.input())?; + + let mut binding_descriptions = SmallVec::<[_; 8]>::new(); + for (num, stride, rate) in buffers_iter { + if stride > + device + .physical_device() + .limits() + .max_vertex_input_binding_stride() as usize + { + return Err(GraphicsPipelineCreationError::MaxVertexInputBindingStrideExceeded { + binding: num as usize, + max: device.physical_device().limits().max_vertex_input_binding_stride() as usize, + obtained: stride, + }); + } + + binding_descriptions.push(vk::VertexInputBindingDescription { + binding: num as u32, + stride: stride as u32, + inputRate: rate as u32, + }); + } + + let mut attribute_descriptions = SmallVec::<[_; 8]>::new(); + for (loc, binding, info) in attribs_iter { + // TODO: check attribute format support + + if info.offset > + device + .physical_device() + .limits() + .max_vertex_input_attribute_offset() as usize + { + return Err(GraphicsPipelineCreationError::MaxVertexInputAttributeOffsetExceeded { + max: device.physical_device().limits().max_vertex_input_attribute_offset() as usize, + obtained: info.offset, + }); + } + + debug_assert!(binding_descriptions + .iter() + .find(|b| b.binding == binding) + .is_some()); + + attribute_descriptions.push(vk::VertexInputAttributeDescription { + location: loc as u32, + binding: binding as u32, + format: info.format as u32, + offset: info.offset as u32, + }); + } + + (binding_descriptions, attribute_descriptions) + }; + + if binding_descriptions.len() > + device + .physical_device() + .limits() + .max_vertex_input_bindings() as usize + { + return Err(GraphicsPipelineCreationError::MaxVertexInputBindingsExceeded { + max: device + .physical_device() + .limits() + .max_vertex_input_bindings() as + usize, + obtained: binding_descriptions.len(), + }); + } + + if attribute_descriptions.len() > + device + .physical_device() + .limits() + .max_vertex_input_attributes() as usize + { + return Err(GraphicsPipelineCreationError::MaxVertexInputAttributesExceeded { + max: device + .physical_device() + .limits() + .max_vertex_input_attributes() as + usize, + obtained: attribute_descriptions.len(), + }); + } + + let vertex_input_state = vk::PipelineVertexInputStateCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + vertexBindingDescriptionCount: binding_descriptions.len() as u32, + pVertexBindingDescriptions: binding_descriptions.as_ptr(), + vertexAttributeDescriptionCount: attribute_descriptions.len() as u32, + pVertexAttributeDescriptions: attribute_descriptions.as_ptr(), + }; + + if self.input_assembly.primitiveRestartEnable != vk::FALSE && + !self.input_assembly_topology.supports_primitive_restart() + { + return Err(GraphicsPipelineCreationError::PrimitiveDoesntSupportPrimitiveRestart { + primitive: self.input_assembly_topology, + }); + } + + // TODO: should check from the tess eval shader instead of the input assembly + if let Some(ref gs) = self.geometry_shader { + match gs.0.ty() { + GraphicsShaderType::Geometry(primitives) => { + if !primitives.matches(self.input_assembly_topology) { + return Err(GraphicsPipelineCreationError::TopologyNotMatchingGeometryShader); + } + }, + _ => return Err(GraphicsPipelineCreationError::WrongShaderType), + } + } + + let tessellation = match self.input_assembly_topology { + PrimitiveTopology::PatchList { vertices_per_patch } => { + if self.tessellation.is_none() { + return Err(GraphicsPipelineCreationError::InvalidPrimitiveTopology); + } + if vertices_per_patch > + device + .physical_device() + .limits() + .max_tessellation_patch_size() + { + return Err(GraphicsPipelineCreationError::MaxTessellationPatchSizeExceeded); + } + + Some(vk::PipelineTessellationStateCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved, + patchControlPoints: vertices_per_patch, + }) + }, + _ => { + if self.tessellation.is_some() { + return Err(GraphicsPipelineCreationError::InvalidPrimitiveTopology); + } + + None + }, + }; + + let (vp_vp, vp_sc, vp_num) = match *self.viewport.as_ref().unwrap() { + ViewportsState::Fixed { ref data } => (data.iter() + .map(|e| e.0.clone().into_vulkan_viewport()) + .collect::<SmallVec<[vk::Viewport; 4]>>(), + data.iter() + .map(|e| e.1.clone().into_vulkan_rect()) + .collect::<SmallVec<[vk::Rect2D; 4]>>(), + data.len() as u32), + ViewportsState::DynamicViewports { ref scissors } => { + let num = scissors.len() as u32; + let scissors = scissors + .iter() + .map(|e| e.clone().into_vulkan_rect()) + .collect::<SmallVec<[vk::Rect2D; 4]>>(); + dynamic_states.push(vk::DYNAMIC_STATE_VIEWPORT); + (SmallVec::new(), scissors, num) + }, + ViewportsState::DynamicScissors { ref viewports } => { + let num = viewports.len() as u32; + let viewports = viewports + .iter() + .map(|e| e.clone().into_vulkan_viewport()) + .collect::<SmallVec<[vk::Viewport; 4]>>(); + dynamic_states.push(vk::DYNAMIC_STATE_SCISSOR); + (viewports, SmallVec::new(), num) + }, + ViewportsState::Dynamic { num } => { + dynamic_states.push(vk::DYNAMIC_STATE_VIEWPORT); + dynamic_states.push(vk::DYNAMIC_STATE_SCISSOR); + (SmallVec::new(), SmallVec::new(), num) + }, + }; + + if vp_num > 1 && !device.enabled_features().multi_viewport { + return Err(GraphicsPipelineCreationError::MultiViewportFeatureNotEnabled); + } + + if vp_num > device.physical_device().limits().max_viewports() { + return Err(GraphicsPipelineCreationError::MaxViewportsExceeded { + obtained: vp_num, + max: device.physical_device().limits().max_viewports(), + }); + } + + for vp in vp_vp.iter() { + if vp.width > device.physical_device().limits().max_viewport_dimensions()[0] as f32 || + vp.height > device.physical_device().limits().max_viewport_dimensions()[1] as f32 + { + return Err(GraphicsPipelineCreationError::MaxViewportDimensionsExceeded); + } + + if vp.x < device.physical_device().limits().viewport_bounds_range()[0] || + vp.x + vp.width > device.physical_device().limits().viewport_bounds_range()[1] || + vp.y < device.physical_device().limits().viewport_bounds_range()[0] || + vp.y + vp.height > device.physical_device().limits().viewport_bounds_range()[1] + { + return Err(GraphicsPipelineCreationError::ViewportBoundsExceeded); + } + } + + let viewport_info = vk::PipelineViewportStateCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + viewportCount: vp_num, + pViewports: if vp_vp.is_empty() { + ptr::null() + } else { + vp_vp.as_ptr() + }, // validation layer crashes if you just pass the pointer + scissorCount: vp_num, + pScissors: if vp_sc.is_empty() { + ptr::null() + } else { + vp_sc.as_ptr() + }, // validation layer crashes if you just pass the pointer + }; + + if let Some(line_width) = self.raster.line_width { + if line_width != 1.0 && !device.enabled_features().wide_lines { + return Err(GraphicsPipelineCreationError::WideLinesFeatureNotEnabled); + } + } else { + dynamic_states.push(vk::DYNAMIC_STATE_LINE_WIDTH); + } + + let (db_enable, db_const, db_clamp, db_slope) = match self.raster.depth_bias { + DepthBiasControl::Dynamic => { + dynamic_states.push(vk::DYNAMIC_STATE_DEPTH_BIAS); + (vk::TRUE, 0.0, 0.0, 0.0) + }, + DepthBiasControl::Disabled => { + (vk::FALSE, 0.0, 0.0, 0.0) + }, + DepthBiasControl::Static(bias) => { + if bias.clamp != 0.0 && !device.enabled_features().depth_bias_clamp { + return Err(GraphicsPipelineCreationError::DepthBiasClampFeatureNotEnabled); + } + + (vk::TRUE, bias.constant_factor, bias.clamp, bias.slope_factor) + }, + }; + + if self.raster.depth_clamp && !device.enabled_features().depth_clamp { + return Err(GraphicsPipelineCreationError::DepthClampFeatureNotEnabled); + } + + if self.raster.polygon_mode != PolygonMode::Fill && + !device.enabled_features().fill_mode_non_solid + { + return Err(GraphicsPipelineCreationError::FillModeNonSolidFeatureNotEnabled); + } + + let rasterization = vk::PipelineRasterizationStateCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + depthClampEnable: if self.raster.depth_clamp { + vk::TRUE + } else { + vk::FALSE + }, + rasterizerDiscardEnable: if self.raster.rasterizer_discard { + vk::TRUE + } else { + vk::FALSE + }, + polygonMode: self.raster.polygon_mode as u32, + cullMode: self.raster.cull_mode as u32, + frontFace: self.raster.front_face as u32, + depthBiasEnable: db_enable, + depthBiasConstantFactor: db_const, + depthBiasClamp: db_clamp, + depthBiasSlopeFactor: db_slope, + lineWidth: self.raster.line_width.unwrap_or(1.0), + }; + + self.multisample.rasterizationSamples = self.render_pass + .as_ref() + .unwrap() + .num_samples() + .unwrap_or(1); + if self.multisample.sampleShadingEnable != vk::FALSE { + debug_assert!(self.multisample.minSampleShading >= 0.0 && + self.multisample.minSampleShading <= 1.0); + if !device.enabled_features().sample_rate_shading { + return Err(GraphicsPipelineCreationError::SampleRateShadingFeatureNotEnabled); + } + } + if self.multisample.alphaToOneEnable != vk::FALSE { + if !device.enabled_features().alpha_to_one { + return Err(GraphicsPipelineCreationError::AlphaToOneFeatureNotEnabled); + } + } + + let depth_stencil = { + let db = match self.depth_stencil.depth_bounds_test { + DepthBounds::Disabled => (vk::FALSE, 0.0, 0.0), + DepthBounds::Fixed(ref range) => { + if !device.enabled_features().depth_bounds { + return Err(GraphicsPipelineCreationError::DepthBoundsFeatureNotEnabled); + } + + (vk::TRUE, range.start, range.end) + }, + DepthBounds::Dynamic => { + if !device.enabled_features().depth_bounds { + return Err(GraphicsPipelineCreationError::DepthBoundsFeatureNotEnabled); + } + + dynamic_states.push(vk::DYNAMIC_STATE_DEPTH_BOUNDS); + + (vk::TRUE, 0.0, 1.0) + }, + }; + + match (self.depth_stencil.stencil_front.compare_mask, + self.depth_stencil.stencil_back.compare_mask) { + (Some(_), Some(_)) => (), + (None, None) => { + dynamic_states.push(vk::DYNAMIC_STATE_STENCIL_COMPARE_MASK); + }, + _ => return Err(GraphicsPipelineCreationError::WrongStencilState), + }; + + match (self.depth_stencil.stencil_front.write_mask, + self.depth_stencil.stencil_back.write_mask) { + (Some(_), Some(_)) => (), + (None, None) => { + dynamic_states.push(vk::DYNAMIC_STATE_STENCIL_WRITE_MASK); + }, + _ => return Err(GraphicsPipelineCreationError::WrongStencilState), + }; + + match (self.depth_stencil.stencil_front.reference, + self.depth_stencil.stencil_back.reference) { + (Some(_), Some(_)) => (), + (None, None) => { + dynamic_states.push(vk::DYNAMIC_STATE_STENCIL_REFERENCE); + }, + _ => return Err(GraphicsPipelineCreationError::WrongStencilState), + }; + + if self.depth_stencil.depth_write && + !self.render_pass.as_ref().unwrap().has_writable_depth() + { + return Err(GraphicsPipelineCreationError::NoDepthAttachment); + } + + if self.depth_stencil.depth_compare != Compare::Always && + !self.render_pass.as_ref().unwrap().has_depth() + { + return Err(GraphicsPipelineCreationError::NoDepthAttachment); + } + + if (!self.depth_stencil.stencil_front.always_keep() || + !self.depth_stencil.stencil_back.always_keep()) && + !self.render_pass.as_ref().unwrap().has_stencil() + { + return Err(GraphicsPipelineCreationError::NoStencilAttachment); + } + + // FIXME: stencil writability + + vk::PipelineDepthStencilStateCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + depthTestEnable: if !self.depth_stencil.depth_write && + self.depth_stencil.depth_compare == Compare::Always + { + vk::FALSE + } else { + vk::TRUE + }, + depthWriteEnable: if self.depth_stencil.depth_write { + vk::TRUE + } else { + vk::FALSE + }, + depthCompareOp: self.depth_stencil.depth_compare as u32, + depthBoundsTestEnable: db.0, + stencilTestEnable: if self.depth_stencil.stencil_front.always_keep() && + self.depth_stencil.stencil_back.always_keep() + { + vk::FALSE + } else { + vk::TRUE + }, + front: vk::StencilOpState { + failOp: self.depth_stencil.stencil_front.fail_op as u32, + passOp: self.depth_stencil.stencil_front.pass_op as u32, + depthFailOp: self.depth_stencil.stencil_front.depth_fail_op as u32, + compareOp: self.depth_stencil.stencil_front.compare as u32, + compareMask: self.depth_stencil + .stencil_front + .compare_mask + .unwrap_or(u32::MAX), + writeMask: self.depth_stencil + .stencil_front + .write_mask + .unwrap_or(u32::MAX), + reference: self.depth_stencil.stencil_front.reference.unwrap_or(0), + }, + back: vk::StencilOpState { + failOp: self.depth_stencil.stencil_back.fail_op as u32, + passOp: self.depth_stencil.stencil_back.pass_op as u32, + depthFailOp: self.depth_stencil.stencil_back.depth_fail_op as u32, + compareOp: self.depth_stencil.stencil_back.compare as u32, + compareMask: self.depth_stencil + .stencil_back + .compare_mask + .unwrap_or(u32::MAX), + writeMask: self.depth_stencil + .stencil_back + .write_mask + .unwrap_or(u32::MAX), + reference: self.depth_stencil.stencil_back.reference.unwrap_or(0), + }, + minDepthBounds: db.1, + maxDepthBounds: db.2, + } + }; + + let blend_atch: SmallVec<[vk::PipelineColorBlendAttachmentState; 8]> = { + let num_atch = self.render_pass.as_ref().unwrap().num_color_attachments(); + + match self.blend.attachments { + AttachmentsBlend::Collective(blend) => { + (0 .. num_atch) + .map(|_| blend.clone().into_vulkan_state()) + .collect() + }, + AttachmentsBlend::Individual(blend) => { + if blend.len() != num_atch as usize { + return Err(GraphicsPipelineCreationError::MismatchBlendingAttachmentsCount); + } + + if !device.enabled_features().independent_blend { + return Err(GraphicsPipelineCreationError::IndependentBlendFeatureNotEnabled); + } + + blend + .iter() + .map(|b| b.clone().into_vulkan_state()) + .collect() + }, + } + }; + + let blend = vk::PipelineColorBlendStateCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + logicOpEnable: if self.blend.logic_op.is_some() { + if !device.enabled_features().logic_op { + return Err(GraphicsPipelineCreationError::LogicOpFeatureNotEnabled); + } + vk::TRUE + } else { + vk::FALSE + }, + logicOp: self.blend.logic_op.unwrap_or(Default::default()) as u32, + attachmentCount: blend_atch.len() as u32, + pAttachments: blend_atch.as_ptr(), + blendConstants: if let Some(c) = self.blend.blend_constants { + c + } else { + dynamic_states.push(vk::DYNAMIC_STATE_BLEND_CONSTANTS); + [0.0, 0.0, 0.0, 0.0] + }, + }; + + let dynamic_states = if !dynamic_states.is_empty() { + Some(vk::PipelineDynamicStateCreateInfo { + sType: vk::STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + dynamicStateCount: dynamic_states.len() as u32, + pDynamicStates: dynamic_states.as_ptr(), + }) + } else { + None + }; + + let pipeline = unsafe { + let infos = vk::GraphicsPipelineCreateInfo { + sType: vk::STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // TODO: some flags are available but none are critical + stageCount: stages.len() as u32, + pStages: stages.as_ptr(), + pVertexInputState: &vertex_input_state, + pInputAssemblyState: &self.input_assembly, + pTessellationState: tessellation + .as_ref() + .map(|t| t as *const _) + .unwrap_or(ptr::null()), + pViewportState: &viewport_info, + pRasterizationState: &rasterization, + pMultisampleState: &self.multisample, + pDepthStencilState: &depth_stencil, + pColorBlendState: &blend, + pDynamicState: dynamic_states + .as_ref() + .map(|s| s as *const _) + .unwrap_or(ptr::null()), + layout: PipelineLayoutAbstract::sys(&pipeline_layout).internal_object(), + renderPass: self.render_pass + .as_ref() + .unwrap() + .render_pass() + .inner() + .internal_object(), + subpass: self.render_pass.as_ref().unwrap().index(), + basePipelineHandle: 0, // TODO: + basePipelineIndex: -1, // TODO: + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateGraphicsPipelines(device.internal_object(), + 0, + 1, + &infos, + ptr::null(), + &mut output))?; + output + }; + + let (render_pass, render_pass_subpass) = self.render_pass.take().unwrap().into(); + + Ok(GraphicsPipeline { + inner: GraphicsPipelineInner { + device: device.clone(), + pipeline: pipeline, + }, + layout: pipeline_layout, + + vertex_definition: self.vertex_input, + + render_pass: render_pass, + render_pass_subpass: render_pass_subpass, + + dynamic_line_width: self.raster.line_width.is_none(), + dynamic_viewport: self.viewport.as_ref().unwrap().dynamic_viewports(), + dynamic_scissor: self.viewport.as_ref().unwrap().dynamic_scissors(), + dynamic_depth_bias: self.raster.depth_bias.is_dynamic(), + dynamic_depth_bounds: self.depth_stencil.depth_bounds_test.is_dynamic(), + dynamic_stencil_compare_mask: self.depth_stencil.stencil_back.compare_mask.is_none(), + dynamic_stencil_write_mask: self.depth_stencil.stencil_back.write_mask.is_none(), + dynamic_stencil_reference: self.depth_stencil.stencil_back.reference.is_none(), + dynamic_blend_constants: self.blend.blend_constants.is_none(), + + num_viewports: self.viewport.as_ref().unwrap().num_viewports(), + }) + } + + // TODO: add build_with_cache method +} + +impl<Vdef, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs, Fss, Rp> + GraphicsPipelineBuilder<Vdef, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs, Fss, Rp> { + // TODO: add pipeline derivate system + + /// Sets the vertex input. + #[inline] + pub fn vertex_input<T>( + self, vertex_input: T) + -> GraphicsPipelineBuilder<T, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs, Fss, Rp> { + GraphicsPipelineBuilder { + vertex_input: vertex_input, + vertex_shader: self.vertex_shader, + input_assembly: self.input_assembly, + input_assembly_topology: self.input_assembly_topology, + tessellation: self.tessellation, + geometry_shader: self.geometry_shader, + viewport: self.viewport, + raster: self.raster, + multisample: self.multisample, + fragment_shader: self.fragment_shader, + depth_stencil: self.depth_stencil, + blend: self.blend, + render_pass: self.render_pass, + } + } + + /// Sets the vertex input to a single vertex buffer. + /// + /// You will most likely need to explicitly specify the template parameter to the type of a + /// vertex. + #[inline] + pub fn vertex_input_single_buffer<V>(self) + -> GraphicsPipelineBuilder<SingleBufferDefinition<V>, + Vs, + Vss, + Tcs, + Tcss, + Tes, + Tess, + Gs, + Gss, + Fs, + Fss, + Rp> { + self.vertex_input(SingleBufferDefinition::<V>::new()) + } + + /// Sets the vertex shader to use. + // TODO: correct specialization constants + #[inline] + pub fn vertex_shader<Vs2, Vss2>( + self, shader: Vs2, specialization_constants: Vss2) + -> GraphicsPipelineBuilder<Vdef, Vs2, Vss2, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs, Fss, Rp> + where Vs2: GraphicsEntryPointAbstract<SpecializationConstants = Vss2>, + Vss2: SpecializationConstants + { + GraphicsPipelineBuilder { + vertex_input: self.vertex_input, + vertex_shader: Some((shader, specialization_constants)), + input_assembly: self.input_assembly, + input_assembly_topology: self.input_assembly_topology, + tessellation: self.tessellation, + geometry_shader: self.geometry_shader, + viewport: self.viewport, + raster: self.raster, + multisample: self.multisample, + fragment_shader: self.fragment_shader, + depth_stencil: self.depth_stencil, + blend: self.blend, + render_pass: self.render_pass, + } + } + + /// Sets whether primitive restart if enabled. + #[inline] + pub fn primitive_restart(mut self, enabled: bool) -> Self { + self.input_assembly.primitiveRestartEnable = if enabled { + vk::TRUE + } else { + vk::FALSE + }; + + self + } + + /// Sets the topology of the primitives that are expected by the pipeline. + #[inline] + pub fn primitive_topology(mut self, topology: PrimitiveTopology) -> Self { + self.input_assembly_topology = topology; + self.input_assembly.topology = topology.into(); + self + } + + /// Sets the topology of the primitives to a list of points. + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::PointList)`. + #[inline] + pub fn point_list(self) -> Self { + self.primitive_topology(PrimitiveTopology::PointList) + } + + /// Sets the topology of the primitives to a list of lines. + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::LineList)`. + #[inline] + pub fn line_list(self) -> Self { + self.primitive_topology(PrimitiveTopology::LineList) + } + + /// Sets the topology of the primitives to a line strip. + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::LineStrip)`. + #[inline] + pub fn line_strip(self) -> Self { + self.primitive_topology(PrimitiveTopology::LineStrip) + } + + /// Sets the topology of the primitives to a list of triangles. Note that this is the default. + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::TriangleList)`. + #[inline] + pub fn triangle_list(self) -> Self { + self.primitive_topology(PrimitiveTopology::TriangleList) + } + + /// Sets the topology of the primitives to a triangle strip. + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::TriangleStrip)`. + #[inline] + pub fn triangle_strip(self) -> Self { + self.primitive_topology(PrimitiveTopology::TriangleStrip) + } + + /// Sets the topology of the primitives to a fan of triangles. + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::TriangleFan)`. + #[inline] + pub fn triangle_fan(self) -> Self { + self.primitive_topology(PrimitiveTopology::TriangleFan) + } + + /// Sets the topology of the primitives to a list of lines with adjacency information. + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::LineListWithAdjacency)`. + #[inline] + pub fn line_list_with_adjacency(self) -> Self { + self.primitive_topology(PrimitiveTopology::LineListWithAdjacency) + } + + /// Sets the topology of the primitives to a line strip with adjacency information. + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::LineStripWithAdjacency)`. + #[inline] + pub fn line_strip_with_adjacency(self) -> Self { + self.primitive_topology(PrimitiveTopology::LineStripWithAdjacency) + } + + /// Sets the topology of the primitives to a list of triangles with adjacency information. + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::TriangleListWithAdjacency)`. + #[inline] + pub fn triangle_list_with_adjacency(self) -> Self { + self.primitive_topology(PrimitiveTopology::TriangleListWithAdjacency) + } + + /// Sets the topology of the primitives to a triangle strip with adjacency information` + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::TriangleStripWithAdjacency)`. + #[inline] + pub fn triangle_strip_with_adjacency(self) -> Self { + self.primitive_topology(PrimitiveTopology::TriangleStripWithAdjacency) + } + + /// Sets the topology of the primitives to a list of patches. Can only be used and must be used + /// with a tessellation shader. + /// + /// > **Note**: This is equivalent to + /// > `self.primitive_topology(PrimitiveTopology::PatchList { vertices_per_patch })`. + #[inline] + pub fn patch_list(self, vertices_per_patch: u32) -> Self { + self.primitive_topology(PrimitiveTopology::PatchList { vertices_per_patch }) + } + + /// Sets the tessellation shaders to use. + // TODO: correct specialization constants + #[inline] + pub fn tessellation_shaders<Tcs2, Tcss2, Tes2, Tess2>( + self, tessellation_control_shader: Tcs2, + tessellation_control_shader_spec_constants: Tcss2, tessellation_evaluation_shader: Tes2, + tessellation_evaluation_shader_spec_constants: Tess2) + -> GraphicsPipelineBuilder<Vdef, Vs, Vss, Tcs2, Tcss2, Tes2, Tess2, Gs, Gss, Fs, Fss, Rp> + where Tcs2: GraphicsEntryPointAbstract<SpecializationConstants = Tcss2>, + Tes2: GraphicsEntryPointAbstract<SpecializationConstants = Tess2>, + Tcss2: SpecializationConstants, + Tess2: SpecializationConstants + { + GraphicsPipelineBuilder { + vertex_input: self.vertex_input, + vertex_shader: self.vertex_shader, + input_assembly: self.input_assembly, + input_assembly_topology: self.input_assembly_topology, + tessellation: Some(TessInfo { + tessellation_control_shader: + (tessellation_control_shader, + tessellation_control_shader_spec_constants), + tessellation_evaluation_shader: + (tessellation_evaluation_shader, + tessellation_evaluation_shader_spec_constants), + }), + geometry_shader: self.geometry_shader, + viewport: self.viewport, + raster: self.raster, + multisample: self.multisample, + fragment_shader: self.fragment_shader, + depth_stencil: self.depth_stencil, + blend: self.blend, + render_pass: self.render_pass, + } + } + + /// Sets the tessellation shaders stage as disabled. This is the default. + #[inline] + pub fn tessellation_shaders_disabled(mut self) -> Self { + self.tessellation = None; + self + } + + /// Sets the geometry shader to use. + // TODO: correct specialization constants + #[inline] + pub fn geometry_shader<Gs2, Gss2>( + self, shader: Gs2, specialization_constants: Gss2) + -> GraphicsPipelineBuilder<Vdef, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs2, Gss2, Fs, Fss, Rp> + where Gs2: GraphicsEntryPointAbstract<SpecializationConstants = Gss2>, + Gss2: SpecializationConstants + { + GraphicsPipelineBuilder { + vertex_input: self.vertex_input, + vertex_shader: self.vertex_shader, + input_assembly: self.input_assembly, + input_assembly_topology: self.input_assembly_topology, + tessellation: self.tessellation, + geometry_shader: Some((shader, specialization_constants)), + viewport: self.viewport, + raster: self.raster, + multisample: self.multisample, + fragment_shader: self.fragment_shader, + depth_stencil: self.depth_stencil, + blend: self.blend, + render_pass: self.render_pass, + } + } + + /// Sets the geometry shader stage as disabled. This is the default. + #[inline] + pub fn geometry_shader_disabled(mut self) -> Self { + self.geometry_shader = None; + self + } + + /// Sets the viewports to some value, and the scissor boxes to boxes that always cover the + /// whole viewport. + #[inline] + pub fn viewports<I>(self, viewports: I) -> Self + where I: IntoIterator<Item = Viewport> + { + self.viewports_scissors(viewports.into_iter().map(|v| (v, Scissor::irrelevant()))) + } + + /// Sets the characteristics of viewports and scissor boxes in advance. + #[inline] + pub fn viewports_scissors<I>(mut self, viewports: I) -> Self + where I: IntoIterator<Item = (Viewport, Scissor)> + { + self.viewport = Some(ViewportsState::Fixed { data: viewports.into_iter().collect() }); + self + } + + /// Sets the scissor boxes to some values, and viewports to dynamic. The viewports will + /// need to be set before drawing. + #[inline] + pub fn viewports_dynamic_scissors_fixed<I>(mut self, scissors: I) -> Self + where I: IntoIterator<Item = Scissor> + { + self.viewport = + Some(ViewportsState::DynamicViewports { scissors: scissors.into_iter().collect() }); + self + } + + /// Sets the viewports to dynamic, and the scissor boxes to boxes that always cover the whole + /// viewport. The viewports will need to be set before drawing. + #[inline] + pub fn viewports_dynamic_scissors_irrelevant(mut self, num: u32) -> Self { + self.viewport = Some(ViewportsState::DynamicViewports { + scissors: (0 .. num).map(|_| Scissor::irrelevant()).collect(), + }); + self + } + + /// Sets the viewports to some values, and scissor boxes to dynamic. The scissor boxes will + /// need to be set before drawing. + #[inline] + pub fn viewports_fixed_scissors_dynamic<I>(mut self, viewports: I) -> Self + where I: IntoIterator<Item = Viewport> + { + self.viewport = + Some(ViewportsState::DynamicScissors { viewports: viewports.into_iter().collect() }); + self + } + + /// Sets the viewports and scissor boxes to dynamic. They will both need to be set before + /// drawing. + #[inline] + pub fn viewports_scissors_dynamic(mut self, num: u32) -> Self { + self.viewport = Some(ViewportsState::Dynamic { num: num }); + self + } + + /// If true, then the depth value of the vertices will be clamped to the range `[0.0 ; 1.0]`. + /// If false, fragments whose depth is outside of this range will be discarded before the + /// fragment shader even runs. + #[inline] + pub fn depth_clamp(mut self, clamp: bool) -> Self { + self.raster.depth_clamp = clamp; + self + } + + // TODO: this won't work correctly + /*/// Disables the fragment shader stage. + #[inline] + pub fn rasterizer_discard(mut self) -> Self { + self.rasterization.rasterizer_discard. = true; + self + }*/ + + /// Sets the front-facing faces to counter-clockwise faces. This is the default. + /// + /// Triangles whose vertices are oriented counter-clockwise on the screen will be considered + /// as facing their front. Otherwise they will be considered as facing their back. + #[inline] + pub fn front_face_counter_clockwise(mut self) -> Self { + self.raster.front_face = FrontFace::CounterClockwise; + self + } + + /// Sets the front-facing faces to clockwise faces. + /// + /// Triangles whose vertices are oriented clockwise on the screen will be considered + /// as facing their front. Otherwise they will be considered as facing their back. + #[inline] + pub fn front_face_clockwise(mut self) -> Self { + self.raster.front_face = FrontFace::Clockwise; + self + } + + /// Sets backface culling as disabled. This is the default. + #[inline] + pub fn cull_mode_disabled(mut self) -> Self { + self.raster.cull_mode = CullMode::None; + self + } + + /// Sets backface culling to front faces. The front faces (as chosen with the `front_face_*` + /// methods) will be discarded by the GPU when drawing. + #[inline] + pub fn cull_mode_front(mut self) -> Self { + self.raster.cull_mode = CullMode::Front; + self + } + + /// Sets backface culling to back faces. Faces that are not facing the front (as chosen with + /// the `front_face_*` methods) will be discarded by the GPU when drawing. + #[inline] + pub fn cull_mode_back(mut self) -> Self { + self.raster.cull_mode = CullMode::Back; + self + } + + /// Sets backface culling to both front and back faces. All the faces will be discarded. + /// + /// > **Note**: This option exists for the sake of completeness. It has no known practical + /// > usage. + #[inline] + pub fn cull_mode_front_and_back(mut self) -> Self { + self.raster.cull_mode = CullMode::FrontAndBack; + self + } + + /// Sets the polygon mode to "fill". This is the default. + #[inline] + pub fn polygon_mode_fill(mut self) -> Self { + self.raster.polygon_mode = PolygonMode::Fill; + self + } + + /// Sets the polygon mode to "line". Triangles will each be turned into three lines. + #[inline] + pub fn polygon_mode_line(mut self) -> Self { + self.raster.polygon_mode = PolygonMode::Line; + self + } + + /// Sets the polygon mode to "point". Triangles and lines will each be turned into three points. + #[inline] + pub fn polygon_mode_point(mut self) -> Self { + self.raster.polygon_mode = PolygonMode::Point; + self + } + + /// Sets the width of the lines, if the GPU needs to draw lines. The default is `1.0`. + #[inline] + pub fn line_width(mut self, value: f32) -> Self { + self.raster.line_width = Some(value); + self + } + + /// Sets the width of the lines as dynamic, which means that you will need to set this value + /// when drawing. + #[inline] + pub fn line_width_dynamic(mut self) -> Self { + self.raster.line_width = None; + self + } + + // TODO: missing DepthBiasControl + + /// Disables sample shading. The fragment shader will only be run once per fragment (ie. per + /// pixel) and not once by sample. The output will then be copied in all of the covered + /// samples. + /// + /// Sample shading is disabled by default. + #[inline] + pub fn sample_shading_disabled(mut self) -> Self { + self.multisample.sampleShadingEnable = vk::FALSE; + self + } + + /// Enables sample shading. The fragment shader will be run once per sample at the borders of + /// the object you're drawing. + /// + /// Enabling sampling shading requires the `sample_rate_shading` feature to be enabled on the + /// device. + /// + /// The `min_fract` parameter is the minimum fraction of samples shading. For example if its + /// value is 0.5, then the fragment shader will run for at least half of the samples. The other + /// half of the samples will get their values determined automatically. + /// + /// Sample shading is disabled by default. + /// + /// # Panic + /// + /// - Panics if `min_fract` is not between 0.0 and 1.0. + /// + #[inline] + pub fn sample_shading_enabled(mut self, min_fract: f32) -> Self { + assert!(min_fract >= 0.0 && min_fract <= 1.0); + self.multisample.sampleShadingEnable = vk::TRUE; + self.multisample.minSampleShading = min_fract; + self + } + + // TODO: doc + pub fn alpha_to_coverage_disabled(mut self) -> Self { + self.multisample.alphaToCoverageEnable = vk::FALSE; + self + } + + // TODO: doc + pub fn alpha_to_coverage_enabled(mut self) -> Self { + self.multisample.alphaToCoverageEnable = vk::TRUE; + self + } + + /// Disables alpha-to-one. + /// + /// Alpha-to-one is disabled by default. + #[inline] + pub fn alpha_to_one_disabled(mut self) -> Self { + self.multisample.alphaToOneEnable = vk::FALSE; + self + } + + /// Enables alpha-to-one. The alpha component of the first color output of the fragment shader + /// will be replaced by the value `1.0`. + /// + /// Enabling alpha-to-one requires the `alpha_to_one` feature to be enabled on the device. + /// + /// Alpha-to-one is disabled by default. + #[inline] + pub fn alpha_to_one_enabled(mut self) -> Self { + self.multisample.alphaToOneEnable = vk::TRUE; + self + } + + // TODO: rasterizationSamples and pSampleMask + + /// Sets the fragment shader to use. + /// + /// The fragment shader is run once for each pixel that is covered by each primitive. + // TODO: correct specialization constants + #[inline] + pub fn fragment_shader<Fs2, Fss2>( + self, shader: Fs2, specialization_constants: Fss2) + -> GraphicsPipelineBuilder<Vdef, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs2, Fss2, Rp> + where Fs2: GraphicsEntryPointAbstract<SpecializationConstants = Fss2>, + Fss2: SpecializationConstants + { + GraphicsPipelineBuilder { + vertex_input: self.vertex_input, + vertex_shader: self.vertex_shader, + input_assembly: self.input_assembly, + input_assembly_topology: self.input_assembly_topology, + tessellation: self.tessellation, + geometry_shader: self.geometry_shader, + viewport: self.viewport, + raster: self.raster, + multisample: self.multisample, + fragment_shader: Some((shader, specialization_constants)), + depth_stencil: self.depth_stencil, + blend: self.blend, + render_pass: self.render_pass, + } + } + + /// Sets the depth/stencil configuration. This function may be removed in the future. + #[inline] + pub fn depth_stencil(mut self, depth_stencil: DepthStencil) -> Self { + self.depth_stencil = depth_stencil; + self + } + + /// Sets the depth/stencil tests as disabled. + /// + /// > **Note**: This is a shortcut for all the other `depth_*` and `depth_stencil_*` methods + /// > of the builder. + #[inline] + pub fn depth_stencil_disabled(mut self) -> Self { + self.depth_stencil = DepthStencil::disabled(); + self + } + + /// Sets the depth/stencil tests as a simple depth test and no stencil test. + /// + /// > **Note**: This is a shortcut for setting the depth test to `Less`, the depth write Into + /// > ` true` and disable the stencil test. + #[inline] + pub fn depth_stencil_simple_depth(mut self) -> Self { + self.depth_stencil = DepthStencil::simple_depth_test(); + self + } + + /// Sets whether the depth buffer will be written. + #[inline] + pub fn depth_write(mut self, write: bool) -> Self { + self.depth_stencil.depth_write = write; + self + } + + // TODO: missing tons of depth-stencil stuff + + + #[inline] + pub fn blend_collective(mut self, blend: AttachmentBlend) -> Self { + self.blend.attachments = AttachmentsBlend::Collective(blend); + self + } + + #[inline] + pub fn blend_individual<I>(mut self, blend: I) -> Self + where I: IntoIterator<Item = AttachmentBlend> + { + self.blend.attachments = AttachmentsBlend::Individual(blend.into_iter().collect()); + self + } + + /// Each fragment shader output will have its value directly written to the framebuffer + /// attachment. This is the default. + #[inline] + pub fn blend_pass_through(self) -> Self { + self.blend_collective(AttachmentBlend::pass_through()) + } + + #[inline] + pub fn blend_alpha_blending(self) -> Self { + self.blend_collective(AttachmentBlend::alpha_blending()) + } + + #[inline] + pub fn blend_logic_op(mut self, logic_op: LogicOp) -> Self { + self.blend.logic_op = Some(logic_op); + self + } + + /// Sets the logic operation as disabled. This is the default. + #[inline] + pub fn blend_logic_op_disabled(mut self) -> Self { + self.blend.logic_op = None; + self + } + + /// Sets the blend constant. The default is `[0.0, 0.0, 0.0, 0.0]`. + /// + /// The blend constant is used for some blending calculations. It is irrelevant otherwise. + #[inline] + pub fn blend_constants(mut self, constants: [f32; 4]) -> Self { + self.blend.blend_constants = Some(constants); + self + } + + /// Sets the blend constant value as dynamic. Its value will need to be set before drawing. + /// + /// The blend constant is used for some blending calculations. It is irrelevant otherwise. + #[inline] + pub fn blend_constants_dynamic(mut self) -> Self { + self.blend.blend_constants = None; + self + } + + /// Sets the render pass subpass to use. + #[inline] + pub fn render_pass<Rp2>( + self, subpass: Subpass<Rp2>) + -> GraphicsPipelineBuilder<Vdef, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs, Fss, Rp2> { + GraphicsPipelineBuilder { + vertex_input: self.vertex_input, + vertex_shader: self.vertex_shader, + input_assembly: self.input_assembly, + input_assembly_topology: self.input_assembly_topology, + tessellation: self.tessellation, + geometry_shader: self.geometry_shader, + viewport: self.viewport, + raster: self.raster, + multisample: self.multisample, + fragment_shader: self.fragment_shader, + depth_stencil: self.depth_stencil, + blend: self.blend, + render_pass: Some(subpass), + } + } +} + +impl<Vdef, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs, Fss, Rp> Clone + for GraphicsPipelineBuilder<Vdef, Vs, Vss, Tcs, Tcss, Tes, Tess, Gs, Gss, Fs, Fss, Rp> + where Vdef: Clone, + Vs: Clone, + Vss: Clone, + Tcs: Clone, + Tcss: Clone, + Tes: Clone, + Tess: Clone, + Gs: Clone, + Gss: Clone, + Fs: Clone, + Fss: Clone, + Rp: Clone +{ + fn clone(&self) -> Self { + GraphicsPipelineBuilder { + vertex_input: self.vertex_input.clone(), + vertex_shader: self.vertex_shader.clone(), + input_assembly: unsafe { ptr::read(&self.input_assembly) }, + input_assembly_topology: self.input_assembly_topology, + tessellation: self.tessellation.clone(), + geometry_shader: self.geometry_shader.clone(), + viewport: self.viewport.clone(), + raster: self.raster.clone(), + multisample: vk::PipelineMultisampleStateCreateInfo { + sType: self.multisample.sType, + pNext: self.multisample.pNext, + flags: self.multisample.flags, + rasterizationSamples: self.multisample.rasterizationSamples, + sampleShadingEnable: self.multisample.sampleShadingEnable, + minSampleShading: self.multisample.minSampleShading, + pSampleMask: self.multisample.pSampleMask, + alphaToCoverageEnable: self.multisample.alphaToCoverageEnable, + alphaToOneEnable: self.multisample.alphaToOneEnable, + }, + fragment_shader: self.fragment_shader.clone(), + depth_stencil: self.depth_stencil.clone(), + blend: self.blend.clone(), + render_pass: self.render_pass.clone(), + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/creation_error.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/creation_error.rs new file mode 100644 index 0000000..d6a1742 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/creation_error.rs @@ -0,0 +1,384 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::u32; + +use Error; +use OomError; +use descriptor::pipeline_layout::PipelineLayoutNotSupersetError; +use pipeline::input_assembly::PrimitiveTopology; +use pipeline::shader::ShaderInterfaceMismatchError; +use pipeline::vertex::IncompatibleVertexDefinitionError; + +/// Error that can happen when creating a graphics pipeline. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum GraphicsPipelineCreationError { + /// Not enough memory. + OomError(OomError), + + /// The pipeline layout is not compatible with what the shaders expect. + IncompatiblePipelineLayout(PipelineLayoutNotSupersetError), + + /// The interface between the vertex shader and the geometry shader mismatches. + VertexGeometryStagesMismatch(ShaderInterfaceMismatchError), + + /// The interface between the vertex shader and the tessellation control shader mismatches. + VertexTessControlStagesMismatch(ShaderInterfaceMismatchError), + + /// The interface between the vertex shader and the fragment shader mismatches. + VertexFragmentStagesMismatch(ShaderInterfaceMismatchError), + + /// The interface between the tessellation control shader and the tessellation evaluation + /// shader mismatches. + TessControlTessEvalStagesMismatch(ShaderInterfaceMismatchError), + + /// The interface between the tessellation evaluation shader and the geometry shader + /// mismatches. + TessEvalGeometryStagesMismatch(ShaderInterfaceMismatchError), + + /// The interface between the tessellation evaluation shader and the fragment shader + /// mismatches. + TessEvalFragmentStagesMismatch(ShaderInterfaceMismatchError), + + /// The interface between the geometry shader and the fragment shader mismatches. + GeometryFragmentStagesMismatch(ShaderInterfaceMismatchError), + + /// The output of the fragment shader is not compatible with what the render pass subpass + /// expects. + FragmentShaderRenderPassIncompatible, + + /// The vertex definition is not compatible with the input of the vertex shader. + IncompatibleVertexDefinition(IncompatibleVertexDefinitionError), + + /// The maximum stride value for vertex input (ie. the distance between two vertex elements) + /// has been exceeded. + MaxVertexInputBindingStrideExceeded { + /// Index of the faulty binding. + binding: usize, + /// Maximum allowed value. + max: usize, + /// Value that was passed. + obtained: usize, + }, + + /// The maximum number of vertex sources has been exceeded. + MaxVertexInputBindingsExceeded { + /// Maximum allowed value. + max: usize, + /// Value that was passed. + obtained: usize, + }, + + /// The maximum offset for a vertex attribute has been exceeded. This means that your vertex + /// struct is too large. + MaxVertexInputAttributeOffsetExceeded { + /// Maximum allowed value. + max: usize, + /// Value that was passed. + obtained: usize, + }, + + /// The maximum number of vertex attributes has been exceeded. + MaxVertexInputAttributesExceeded { + /// Maximum allowed value. + max: usize, + /// Value that was passed. + obtained: usize, + }, + + /// The user requested to use primitive restart, but the primitive topology doesn't support it. + PrimitiveDoesntSupportPrimitiveRestart { + /// The topology that doesn't support primitive restart. + primitive: PrimitiveTopology, + }, + + /// The `multi_viewport` feature must be enabled in order to use multiple viewports at once. + MultiViewportFeatureNotEnabled, + + /// The maximum number of viewports has been exceeded. + MaxViewportsExceeded { + /// Maximum allowed value. + max: u32, + /// Value that was passed. + obtained: u32, + }, + + /// The maximum dimensions of viewports has been exceeded. + MaxViewportDimensionsExceeded, + + /// The minimum or maximum bounds of viewports have been exceeded. + ViewportBoundsExceeded, + + /// The `wide_lines` feature must be enabled in order to use a line width greater than 1.0. + WideLinesFeatureNotEnabled, + + /// The `depth_clamp` feature must be enabled in order to use depth clamping. + DepthClampFeatureNotEnabled, + + /// The `depth_bias_clamp` feature must be enabled in order to use a depth bias clamp different + /// from 0.0. + DepthBiasClampFeatureNotEnabled, + + /// The `fill_mode_non_solid` feature must be enabled in order to use a polygon mode different + /// from `Fill`. + FillModeNonSolidFeatureNotEnabled, + + /// The `depth_bounds` feature must be enabled in order to use depth bounds testing. + DepthBoundsFeatureNotEnabled, + + /// The requested stencil test is invalid. + WrongStencilState, + + /// The primitives topology does not match what the geometry shader expects. + TopologyNotMatchingGeometryShader, + + /// The `geometry_shader` feature must be enabled in order to use geometry shaders. + GeometryShaderFeatureNotEnabled, + + /// The `tessellation_shader` feature must be enabled in order to use tessellation shaders. + TessellationShaderFeatureNotEnabled, + + /// The number of attachments specified in the blending does not match the number of + /// attachments in the subpass. + MismatchBlendingAttachmentsCount, + + /// The `independent_blend` feature must be enabled in order to use different blending + /// operations per attachment. + IndependentBlendFeatureNotEnabled, + + /// The `logic_op` feature must be enabled in order to use logic operations. + LogicOpFeatureNotEnabled, + + /// The depth test requires a depth attachment but render pass has no depth attachment, or + /// depth writing is enabled and the depth attachment is read-only. + NoDepthAttachment, + + /// The stencil test requires a stencil attachment but render pass has no stencil attachment, or + /// stencil writing is enabled and the stencil attachment is read-only. + NoStencilAttachment, + + /// Tried to use a patch list without a tessellation shader, or a non-patch-list with a + /// tessellation shader. + InvalidPrimitiveTopology, + + /// The `maxTessellationPatchSize` limit was exceeded. + MaxTessellationPatchSizeExceeded, + + /// The wrong type of shader has been passed. + /// + /// For example you passed a vertex shader as the fragment shader. + WrongShaderType, + + /// The `sample_rate_shading` feature must be enabled in order to use sample shading. + SampleRateShadingFeatureNotEnabled, + + /// The `alpha_to_one` feature must be enabled in order to use alpha-to-one. + AlphaToOneFeatureNotEnabled, +} + +impl error::Error for GraphicsPipelineCreationError { + #[inline] + // TODO: finish + fn description(&self) -> &str { + match *self { + GraphicsPipelineCreationError::OomError(_) => "not enough memory available", + GraphicsPipelineCreationError::VertexGeometryStagesMismatch(_) => { + "the interface between the vertex shader and the geometry shader mismatches" + }, + GraphicsPipelineCreationError::VertexTessControlStagesMismatch(_) => { + "the interface between the vertex shader and the tessellation control shader \ + mismatches" + }, + GraphicsPipelineCreationError::VertexFragmentStagesMismatch(_) => { + "the interface between the vertex shader and the fragment shader mismatches" + }, + GraphicsPipelineCreationError::TessControlTessEvalStagesMismatch(_) => { + "the interface between the tessellation control shader and the tessellation \ + evaluation shader mismatches" + }, + GraphicsPipelineCreationError::TessEvalGeometryStagesMismatch(_) => { + "the interface between the tessellation evaluation shader and the geometry \ + shader mismatches" + }, + GraphicsPipelineCreationError::TessEvalFragmentStagesMismatch(_) => { + "the interface between the tessellation evaluation shader and the fragment \ + shader mismatches" + }, + GraphicsPipelineCreationError::GeometryFragmentStagesMismatch(_) => { + "the interface between the geometry shader and the fragment shader mismatches" + }, + GraphicsPipelineCreationError::IncompatiblePipelineLayout(_) => { + "the pipeline layout is not compatible with what the shaders expect" + }, + GraphicsPipelineCreationError::FragmentShaderRenderPassIncompatible => { + "the output of the fragment shader is not compatible with what the render pass \ + subpass expects" + }, + GraphicsPipelineCreationError::IncompatibleVertexDefinition(_) => { + "the vertex definition is not compatible with the input of the vertex shader" + }, + GraphicsPipelineCreationError::MaxVertexInputBindingStrideExceeded { .. } => { + "the maximum stride value for vertex input (ie. the distance between two vertex \ + elements) has been exceeded" + }, + GraphicsPipelineCreationError::MaxVertexInputBindingsExceeded { .. } => { + "the maximum number of vertex sources has been exceeded" + }, + GraphicsPipelineCreationError::MaxVertexInputAttributeOffsetExceeded { .. } => { + "the maximum offset for a vertex attribute has been exceeded" + }, + GraphicsPipelineCreationError::MaxVertexInputAttributesExceeded { .. } => { + "the maximum number of vertex attributes has been exceeded" + }, + GraphicsPipelineCreationError::PrimitiveDoesntSupportPrimitiveRestart { .. } => { + "the user requested to use primitive restart, but the primitive topology \ + doesn't support it" + }, + GraphicsPipelineCreationError::MultiViewportFeatureNotEnabled => { + "the `multi_viewport` feature must be enabled in order to use multiple viewports \ + at once" + }, + GraphicsPipelineCreationError::MaxViewportsExceeded { .. } => { + "the maximum number of viewports has been exceeded" + }, + GraphicsPipelineCreationError::MaxViewportDimensionsExceeded => { + "the maximum dimensions of viewports has been exceeded" + }, + GraphicsPipelineCreationError::ViewportBoundsExceeded => { + "the minimum or maximum bounds of viewports have been exceeded" + }, + GraphicsPipelineCreationError::WideLinesFeatureNotEnabled => { + "the `wide_lines` feature must be enabled in order to use a line width \ + greater than 1.0" + }, + GraphicsPipelineCreationError::DepthClampFeatureNotEnabled => { + "the `depth_clamp` feature must be enabled in order to use depth clamping" + }, + GraphicsPipelineCreationError::DepthBiasClampFeatureNotEnabled => { + "the `depth_bias_clamp` feature must be enabled in order to use a depth bias \ + clamp different from 0.0." + }, + GraphicsPipelineCreationError::FillModeNonSolidFeatureNotEnabled => { + "the `fill_mode_non_solid` feature must be enabled in order to use a polygon mode \ + different from `Fill`" + }, + GraphicsPipelineCreationError::DepthBoundsFeatureNotEnabled => { + "the `depth_bounds` feature must be enabled in order to use depth bounds testing" + }, + GraphicsPipelineCreationError::WrongStencilState => { + "the requested stencil test is invalid" + }, + GraphicsPipelineCreationError::TopologyNotMatchingGeometryShader => { + "the primitives topology does not match what the geometry shader expects" + }, + GraphicsPipelineCreationError::GeometryShaderFeatureNotEnabled => { + "the `geometry_shader` feature must be enabled in order to use geometry shaders" + }, + GraphicsPipelineCreationError::TessellationShaderFeatureNotEnabled => { + "the `tessellation_shader` feature must be enabled in order to use tessellation \ + shaders" + }, + GraphicsPipelineCreationError::MismatchBlendingAttachmentsCount => { + "the number of attachments specified in the blending does not match the number of \ + attachments in the subpass" + }, + GraphicsPipelineCreationError::IndependentBlendFeatureNotEnabled => { + "the `independent_blend` feature must be enabled in order to use different \ + blending operations per attachment" + }, + GraphicsPipelineCreationError::LogicOpFeatureNotEnabled => { + "the `logic_op` feature must be enabled in order to use logic operations" + }, + GraphicsPipelineCreationError::NoDepthAttachment => { + "the depth attachment of the render pass does not match the depth test" + }, + GraphicsPipelineCreationError::NoStencilAttachment => { + "the stencil attachment of the render pass does not match the stencil test" + }, + GraphicsPipelineCreationError::InvalidPrimitiveTopology => { + "trying to use a patch list without a tessellation shader, or a non-patch-list \ + with a tessellation shader" + }, + GraphicsPipelineCreationError::MaxTessellationPatchSizeExceeded => { + "the maximum tessellation patch size was exceeded" + }, + GraphicsPipelineCreationError::WrongShaderType => { + "the wrong type of shader has been passed" + }, + GraphicsPipelineCreationError::SampleRateShadingFeatureNotEnabled => { + "the `sample_rate_shading` feature must be enabled in order to use sample shading" + }, + GraphicsPipelineCreationError::AlphaToOneFeatureNotEnabled => { + "the `alpha_to_one` feature must be enabled in order to use alpha-to-one" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + GraphicsPipelineCreationError::OomError(ref err) => Some(err), + GraphicsPipelineCreationError::IncompatiblePipelineLayout(ref err) => Some(err), + GraphicsPipelineCreationError::VertexGeometryStagesMismatch(ref err) => Some(err), + GraphicsPipelineCreationError::VertexTessControlStagesMismatch(ref err) => Some(err), + GraphicsPipelineCreationError::VertexFragmentStagesMismatch(ref err) => Some(err), + GraphicsPipelineCreationError::TessControlTessEvalStagesMismatch(ref err) => Some(err), + GraphicsPipelineCreationError::TessEvalGeometryStagesMismatch(ref err) => Some(err), + GraphicsPipelineCreationError::TessEvalFragmentStagesMismatch(ref err) => Some(err), + GraphicsPipelineCreationError::GeometryFragmentStagesMismatch(ref err) => Some(err), + GraphicsPipelineCreationError::IncompatibleVertexDefinition(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for GraphicsPipelineCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for GraphicsPipelineCreationError { + #[inline] + fn from(err: OomError) -> GraphicsPipelineCreationError { + GraphicsPipelineCreationError::OomError(err) + } +} + +impl From<PipelineLayoutNotSupersetError> for GraphicsPipelineCreationError { + #[inline] + fn from(err: PipelineLayoutNotSupersetError) -> GraphicsPipelineCreationError { + GraphicsPipelineCreationError::IncompatiblePipelineLayout(err) + } +} + +impl From<IncompatibleVertexDefinitionError> for GraphicsPipelineCreationError { + #[inline] + fn from(err: IncompatibleVertexDefinitionError) -> GraphicsPipelineCreationError { + GraphicsPipelineCreationError::IncompatibleVertexDefinition(err) + } +} + +impl From<Error> for GraphicsPipelineCreationError { + #[inline] + fn from(err: Error) -> GraphicsPipelineCreationError { + match err { + err @ Error::OutOfHostMemory => { + GraphicsPipelineCreationError::OomError(OomError::from(err)) + }, + err @ Error::OutOfDeviceMemory => { + GraphicsPipelineCreationError::OomError(OomError::from(err)) + }, + _ => panic!("unexpected error: {:?}", err), + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/mod.rs new file mode 100644 index 0000000..ff28620 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/mod.rs @@ -0,0 +1,513 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::fmt; +use std::marker::PhantomData; +use std::ptr; +use std::sync::Arc; +use std::u32; + +use SafeDeref; +use VulkanObject; +use buffer::BufferAccess; +use descriptor::PipelineLayoutAbstract; +use descriptor::descriptor::DescriptorDesc; +use descriptor::descriptor_set::UnsafeDescriptorSetLayout; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use descriptor::pipeline_layout::PipelineLayoutDescPcRange; +use descriptor::pipeline_layout::PipelineLayoutSys; +use device::Device; +use device::DeviceOwned; +use format::ClearValue; +use framebuffer::AttachmentDescription; +use framebuffer::PassDependencyDescription; +use framebuffer::PassDescription; +use framebuffer::RenderPassAbstract; +use framebuffer::RenderPassDesc; +use framebuffer::RenderPassDescClearValues; +use framebuffer::RenderPassSys; +use framebuffer::Subpass; +use pipeline::shader::EmptyEntryPointDummy; +use pipeline::vertex::BufferlessDefinition; +use pipeline::vertex::IncompatibleVertexDefinitionError; +use pipeline::vertex::VertexDefinition; +use pipeline::vertex::VertexSource; +use vk; + +pub use self::builder::GraphicsPipelineBuilder; +pub use self::creation_error::GraphicsPipelineCreationError; + +mod builder; +mod creation_error; +// FIXME: restore +//mod tests; + +/// Defines how the implementation should perform a draw operation. +/// +/// This object contains the shaders and the various fixed states that describe how the +/// implementation should perform the various operations needed by a draw command. +pub struct GraphicsPipeline<VertexDefinition, Layout, RenderP> { + inner: Inner, + layout: Layout, + + render_pass: RenderP, + render_pass_subpass: u32, + + vertex_definition: VertexDefinition, + + dynamic_line_width: bool, + dynamic_viewport: bool, + dynamic_scissor: bool, + dynamic_depth_bias: bool, + dynamic_depth_bounds: bool, + dynamic_stencil_compare_mask: bool, + dynamic_stencil_write_mask: bool, + dynamic_stencil_reference: bool, + dynamic_blend_constants: bool, + + num_viewports: u32, +} + +struct Inner { + pipeline: vk::Pipeline, + device: Arc<Device>, +} + +impl GraphicsPipeline<(), (), ()> { + /// Starts the building process of a graphics pipeline. Returns a builder object that you can + /// fill with the various parameters. + pub fn start<'a>() + -> GraphicsPipelineBuilder<BufferlessDefinition, + EmptyEntryPointDummy, + (), + EmptyEntryPointDummy, + (), + EmptyEntryPointDummy, + (), + EmptyEntryPointDummy, + (), + EmptyEntryPointDummy, + (), + ()> + { + GraphicsPipelineBuilder::new() + } +} + +impl<Mv, L, Rp> GraphicsPipeline<Mv, L, Rp> { + /// Returns the vertex definition used in the constructor. + #[inline] + pub fn vertex_definition(&self) -> &Mv { + &self.vertex_definition + } + + /// Returns the device used to create this pipeline. + #[inline] + pub fn device(&self) -> &Arc<Device> { + &self.inner.device + } +} + +impl<Mv, L, Rp> GraphicsPipeline<Mv, L, Rp> + where L: PipelineLayoutAbstract +{ + /// Returns the pipeline layout used in the constructor. + #[inline] + pub fn layout(&self) -> &L { + &self.layout + } +} + +impl<Mv, L, Rp> GraphicsPipeline<Mv, L, Rp> + where Rp: RenderPassDesc +{ + /// Returns the pass used in the constructor. + #[inline] + pub fn subpass(&self) -> Subpass<&Rp> { + Subpass::from(&self.render_pass, self.render_pass_subpass).unwrap() + } +} + +impl<Mv, L, Rp> GraphicsPipeline<Mv, L, Rp> { + /// Returns the render pass used in the constructor. + #[inline] + pub fn render_pass(&self) -> &Rp { + &self.render_pass + } + + /// Returns true if the line width used by this pipeline is dynamic. + #[inline] + pub fn has_dynamic_line_width(&self) -> bool { + self.dynamic_line_width + } + + /// Returns the number of viewports and scissors of this pipeline. + #[inline] + pub fn num_viewports(&self) -> u32 { + self.num_viewports + } + + /// Returns true if the viewports used by this pipeline are dynamic. + #[inline] + pub fn has_dynamic_viewports(&self) -> bool { + self.dynamic_viewport + } + + /// Returns true if the scissors used by this pipeline are dynamic. + #[inline] + pub fn has_dynamic_scissors(&self) -> bool { + self.dynamic_scissor + } + + /// Returns true if the depth bounds used by this pipeline are dynamic. + #[inline] + pub fn has_dynamic_depth_bounds(&self) -> bool { + self.dynamic_depth_bounds + } + + /// Returns true if the stencil compare masks used by this pipeline are dynamic. + #[inline] + pub fn has_dynamic_stencil_compare_mask(&self) -> bool { + self.dynamic_stencil_compare_mask + } + + /// Returns true if the stencil write masks used by this pipeline are dynamic. + #[inline] + pub fn has_dynamic_stencil_write_mask(&self) -> bool { + self.dynamic_stencil_write_mask + } + + /// Returns true if the stencil references used by this pipeline are dynamic. + #[inline] + pub fn has_dynamic_stencil_reference(&self) -> bool { + self.dynamic_stencil_reference + } +} + +unsafe impl<Mv, L, Rp> PipelineLayoutAbstract for GraphicsPipeline<Mv, L, Rp> + where L: PipelineLayoutAbstract +{ + #[inline] + fn sys(&self) -> PipelineLayoutSys { + self.layout.sys() + } + + #[inline] + fn descriptor_set_layout(&self, index: usize) -> Option<&Arc<UnsafeDescriptorSetLayout>> { + self.layout.descriptor_set_layout(index) + } +} + +unsafe impl<Mv, L, Rp> PipelineLayoutDesc for GraphicsPipeline<Mv, L, Rp> + where L: PipelineLayoutDesc +{ + #[inline] + fn num_sets(&self) -> usize { + self.layout.num_sets() + } + + #[inline] + fn num_bindings_in_set(&self, set: usize) -> Option<usize> { + self.layout.num_bindings_in_set(set) + } + + #[inline] + fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> { + self.layout.descriptor(set, binding) + } + + #[inline] + fn num_push_constants_ranges(&self) -> usize { + self.layout.num_push_constants_ranges() + } + + #[inline] + fn push_constants_range(&self, num: usize) -> Option<PipelineLayoutDescPcRange> { + self.layout.push_constants_range(num) + } +} + +unsafe impl<Mv, L, Rp> DeviceOwned for GraphicsPipeline<Mv, L, Rp> { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.inner.device + } +} + +impl<Mv, L, Rp> fmt::Debug for GraphicsPipeline<Mv, L, Rp> { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan graphics pipeline {:?}>", self.inner.pipeline) + } +} + +unsafe impl<Mv, L, Rp> RenderPassAbstract for GraphicsPipeline<Mv, L, Rp> + where Rp: RenderPassAbstract +{ + #[inline] + fn inner(&self) -> RenderPassSys { + self.render_pass.inner() + } +} + +unsafe impl<Mv, L, Rp> RenderPassDesc for GraphicsPipeline<Mv, L, Rp> + where Rp: RenderPassDesc +{ + #[inline] + fn num_attachments(&self) -> usize { + self.render_pass.num_attachments() + } + + #[inline] + fn attachment_desc(&self, num: usize) -> Option<AttachmentDescription> { + self.render_pass.attachment_desc(num) + } + + #[inline] + fn num_subpasses(&self) -> usize { + self.render_pass.num_subpasses() + } + + #[inline] + fn subpass_desc(&self, num: usize) -> Option<PassDescription> { + self.render_pass.subpass_desc(num) + } + + #[inline] + fn num_dependencies(&self) -> usize { + self.render_pass.num_dependencies() + } + + #[inline] + fn dependency_desc(&self, num: usize) -> Option<PassDependencyDescription> { + self.render_pass.dependency_desc(num) + } +} + +unsafe impl<C, Mv, L, Rp> RenderPassDescClearValues<C> for GraphicsPipeline<Mv, L, Rp> + where Rp: RenderPassDescClearValues<C> +{ + #[inline] + fn convert_clear_values(&self, vals: C) -> Box<Iterator<Item = ClearValue>> { + self.render_pass.convert_clear_values(vals) + } +} + +unsafe impl<Mv, L, Rp> VulkanObject for GraphicsPipeline<Mv, L, Rp> { + type Object = vk::Pipeline; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT; + + #[inline] + fn internal_object(&self) -> vk::Pipeline { + self.inner.pipeline + } +} + +impl Drop for Inner { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyPipeline(self.device.internal_object(), self.pipeline, ptr::null()); + } + } +} + +/// Trait implemented on objects that reference a graphics pipeline. Can be made into a trait +/// object. +/// When using this trait `AutoCommandBufferBuilder::draw*` calls will need the buffers to be +/// wrapped in a `vec!()`. +pub unsafe trait GraphicsPipelineAbstract: PipelineLayoutAbstract + RenderPassAbstract + VertexSource<Vec<Arc<BufferAccess + Send + Sync>>> { + /// Returns an opaque object that represents the inside of the graphics pipeline. + fn inner(&self) -> GraphicsPipelineSys; + + /// Returns the index of the subpass this graphics pipeline is rendering to. + fn subpass_index(&self) -> u32; + + /// Returns the subpass this graphics pipeline is rendering to. + #[inline] + fn subpass(self) -> Subpass<Self> where Self: Sized { + let index = self.subpass_index(); + Subpass::from(self, index).expect("Wrong subpass index in GraphicsPipelineAbstract::subpass") + } + + /// Returns true if the line width used by this pipeline is dynamic. + fn has_dynamic_line_width(&self) -> bool; + + /// Returns the number of viewports and scissors of this pipeline. + fn num_viewports(&self) -> u32; + + /// Returns true if the viewports used by this pipeline are dynamic. + fn has_dynamic_viewports(&self) -> bool; + + /// Returns true if the scissors used by this pipeline are dynamic. + fn has_dynamic_scissors(&self) -> bool; + + /// Returns true if the depth bounds used by this pipeline are dynamic. + fn has_dynamic_depth_bounds(&self) -> bool; + + /// Returns true if the stencil compare masks used by this pipeline are dynamic. + fn has_dynamic_stencil_compare_mask(&self) -> bool; + + /// Returns true if the stencil write masks used by this pipeline are dynamic. + fn has_dynamic_stencil_write_mask(&self) -> bool; + + /// Returns true if the stencil references used by this pipeline are dynamic. + fn has_dynamic_stencil_reference(&self) -> bool; +} + +unsafe impl<Mv, L, Rp> GraphicsPipelineAbstract for GraphicsPipeline<Mv, L, Rp> + where L: PipelineLayoutAbstract, + Rp: RenderPassAbstract, + Mv: VertexSource<Vec<Arc<BufferAccess + Send + Sync>>> +{ + #[inline] + fn inner(&self) -> GraphicsPipelineSys { + GraphicsPipelineSys(self.inner.pipeline, PhantomData) + } + + #[inline] + fn subpass_index(&self) -> u32 { + self.render_pass_subpass + } + + #[inline] + fn has_dynamic_line_width(&self) -> bool { + self.dynamic_line_width + } + + #[inline] + fn num_viewports(&self) -> u32 { + self.num_viewports + } + + #[inline] + fn has_dynamic_viewports(&self) -> bool { + self.dynamic_viewport + } + + #[inline] + fn has_dynamic_scissors(&self) -> bool { + self.dynamic_scissor + } + + #[inline] + fn has_dynamic_depth_bounds(&self) -> bool { + self.dynamic_depth_bounds + } + + #[inline] + fn has_dynamic_stencil_compare_mask(&self) -> bool { + self.dynamic_stencil_compare_mask + } + + #[inline] + fn has_dynamic_stencil_write_mask(&self) -> bool { + self.dynamic_stencil_write_mask + } + + #[inline] + fn has_dynamic_stencil_reference(&self) -> bool { + self.dynamic_stencil_reference + } +} + +unsafe impl<T> GraphicsPipelineAbstract for T + where T: SafeDeref, + T::Target: GraphicsPipelineAbstract +{ + #[inline] + fn inner(&self) -> GraphicsPipelineSys { + GraphicsPipelineAbstract::inner(&**self) + } + + #[inline] + fn subpass_index(&self) -> u32 { + (**self).subpass_index() + } + + #[inline] + fn has_dynamic_line_width(&self) -> bool { + (**self).has_dynamic_line_width() + } + + #[inline] + fn num_viewports(&self) -> u32 { + (**self).num_viewports() + } + + #[inline] + fn has_dynamic_viewports(&self) -> bool { + (**self).has_dynamic_viewports() + } + + #[inline] + fn has_dynamic_scissors(&self) -> bool { + (**self).has_dynamic_scissors() + } + + #[inline] + fn has_dynamic_depth_bounds(&self) -> bool { + (**self).has_dynamic_depth_bounds() + } + + #[inline] + fn has_dynamic_stencil_compare_mask(&self) -> bool { + (**self).has_dynamic_stencil_compare_mask() + } + + #[inline] + fn has_dynamic_stencil_write_mask(&self) -> bool { + (**self).has_dynamic_stencil_write_mask() + } + + #[inline] + fn has_dynamic_stencil_reference(&self) -> bool { + (**self).has_dynamic_stencil_reference() + } +} + +/// Opaque object that represents the inside of the graphics pipeline. +#[derive(Debug, Copy, Clone)] +pub struct GraphicsPipelineSys<'a>(vk::Pipeline, PhantomData<&'a ()>); + +unsafe impl<'a> VulkanObject for GraphicsPipelineSys<'a> { + type Object = vk::Pipeline; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT; + + #[inline] + fn internal_object(&self) -> vk::Pipeline { + self.0 + } +} + +unsafe impl<Mv, L, Rp, I> VertexDefinition<I> for GraphicsPipeline<Mv, L, Rp> + where Mv: VertexDefinition<I> +{ + type BuffersIter = <Mv as VertexDefinition<I>>::BuffersIter; + type AttribsIter = <Mv as VertexDefinition<I>>::AttribsIter; + + #[inline] + fn definition( + &self, interface: &I) + -> Result<(Self::BuffersIter, Self::AttribsIter), IncompatibleVertexDefinitionError> { + self.vertex_definition.definition(interface) + } +} + +unsafe impl<Mv, L, Rp, S> VertexSource<S> for GraphicsPipeline<Mv, L, Rp> + where Mv: VertexSource<S> +{ + #[inline] + fn decode(&self, s: S) -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) { + self.vertex_definition.decode(s) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/tests.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/tests.rs new file mode 100644 index 0000000..dac8959 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/graphics_pipeline/tests.rs @@ -0,0 +1,344 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! This module contains the unit tests of `GraphicsPipeline`. + +#![cfg(test)] + +use std::ffi::CString; +use format::Format; +use framebuffer::Subpass; +use descriptor::pipeline_layout::EmptyPipelineDesc; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use pipeline::GraphicsPipeline; +use pipeline::GraphicsPipelineParams; +use pipeline::GraphicsPipelineCreationError; +use pipeline::blend::Blend; +use pipeline::depth_stencil::DepthStencil; +use pipeline::input_assembly::InputAssembly; +use pipeline::input_assembly::PrimitiveTopology; +use pipeline::multisample::Multisample; +use pipeline::shader::ShaderModule; +use pipeline::shader::EmptyShaderInterfaceDef; +use pipeline::vertex::SingleBufferDefinition; +use pipeline::viewport::ViewportsState; + +#[test] +fn create() { + let (device, _) = gfx_dev_and_queue!(); + + let vs = unsafe { ShaderModule::new(device.clone(), &BASIC_VS).unwrap() }; + let fs = unsafe { ShaderModule::new(device.clone(), &BASIC_FS).unwrap() }; + + let _ = GraphicsPipeline::new(&device, GraphicsPipelineParams { + vertex_input: SingleBufferDefinition::<()>::new(), + vertex_shader: unsafe { + vs.vertex_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(), + EmptyShaderInterfaceDef, + EmptyShaderInterfaceDef, + EmptyPipelineDesc) + }, + input_assembly: InputAssembly::triangle_list(), + tessellation: None, + geometry_shader: None, + viewport: ViewportsState::Dynamic { num: 1 }, + raster: Default::default(), + multisample: Multisample::disabled(), + fragment_shader: unsafe { + fs.fragment_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(), + EmptyShaderInterfaceDef, + EmptyShaderInterfaceDef, + EmptyPipelineDesc) + }, + depth_stencil: DepthStencil::disabled(), + blend: Blend::pass_through(), + render_pass: Subpass::from(simple_rp::CustomRenderPass::new(&device, &{ + simple_rp::Formats { color: (Format::R8G8B8A8Unorm, 1) } + }).unwrap(), 0).unwrap(), + }).unwrap(); +} + +#[test] +fn bad_primitive_restart() { + let (device, _) = gfx_dev_and_queue!(); + + let vs = unsafe { ShaderModule::new(device.clone(), &BASIC_VS).unwrap() }; + let fs = unsafe { ShaderModule::new(device.clone(), &BASIC_FS).unwrap() }; + + let result = GraphicsPipeline::new(&device, GraphicsPipelineParams { + vertex_input: SingleBufferDefinition::<()>::new(), + vertex_shader: unsafe { + vs.vertex_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(), + EmptyShaderInterfaceDef, + EmptyShaderInterfaceDef, + EmptyPipelineDesc) + }, + input_assembly: InputAssembly { + topology: PrimitiveTopology::TriangleList, + primitive_restart_enable: true, + }, + tessellation: None, + geometry_shader: None, + viewport: ViewportsState::Dynamic { num: 1 }, + raster: Default::default(), + multisample: Multisample::disabled(), + fragment_shader: unsafe { + fs.fragment_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(), + EmptyShaderInterfaceDef, + EmptyShaderInterfaceDef, + EmptyPipelineDesc) + }, + depth_stencil: DepthStencil::disabled(), + blend: Blend::pass_through(), + render_pass: Subpass::from(simple_rp::CustomRenderPass::new(&device, &{ + simple_rp::Formats { color: (Format::R8G8B8A8Unorm, 1) } + }).unwrap(), 0).unwrap(), + }); + + match result { + Err(GraphicsPipelineCreationError::PrimitiveDoesntSupportPrimitiveRestart { .. }) => (), + _ => panic!() + } +} + +#[test] +fn multi_viewport_feature() { + let (device, _) = gfx_dev_and_queue!(); + + let vs = unsafe { ShaderModule::new(device.clone(), &BASIC_VS).unwrap() }; + let fs = unsafe { ShaderModule::new(device.clone(), &BASIC_FS).unwrap() }; + + let result = GraphicsPipeline::new(&device, GraphicsPipelineParams { + vertex_input: SingleBufferDefinition::<()>::new(), + vertex_shader: unsafe { + vs.vertex_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(), + EmptyShaderInterfaceDef, + EmptyShaderInterfaceDef, + EmptyPipelineDesc) + }, + input_assembly: InputAssembly::triangle_list(), + tessellation: None, + geometry_shader: None, + viewport: ViewportsState::Dynamic { num: 2 }, + raster: Default::default(), + multisample: Multisample::disabled(), + fragment_shader: unsafe { + fs.fragment_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(), + EmptyShaderInterfaceDef, + EmptyShaderInterfaceDef, + EmptyPipelineDesc) + }, + depth_stencil: DepthStencil::disabled(), + blend: Blend::pass_through(), + render_pass: Subpass::from(simple_rp::CustomRenderPass::new(&device, &{ + simple_rp::Formats { color: (Format::R8G8B8A8Unorm, 1) } + }).unwrap(), 0).unwrap(), + }); + + match result { + Err(GraphicsPipelineCreationError::MultiViewportFeatureNotEnabled) => (), + _ => panic!() + } +} + +#[test] +fn max_viewports() { + let (device, _) = gfx_dev_and_queue!(multi_viewport); + + let vs = unsafe { ShaderModule::new(device.clone(), &BASIC_VS).unwrap() }; + let fs = unsafe { ShaderModule::new(device.clone(), &BASIC_FS).unwrap() }; + + let result = GraphicsPipeline::new(&device, GraphicsPipelineParams { + vertex_input: SingleBufferDefinition::<()>::new(), + vertex_shader: unsafe { + vs.vertex_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(), + EmptyShaderInterfaceDef, + EmptyShaderInterfaceDef, + EmptyPipelineDesc) + }, + input_assembly: InputAssembly::triangle_list(), + tessellation: None, + geometry_shader: None, + viewport: ViewportsState::Dynamic { num: !0 }, + raster: Default::default(), + multisample: Multisample::disabled(), + fragment_shader: unsafe { + fs.fragment_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(), + EmptyShaderInterfaceDef, + EmptyShaderInterfaceDef, + EmptyPipelineDesc) + }, + depth_stencil: DepthStencil::disabled(), + blend: Blend::pass_through(), + render_pass: Subpass::from(simple_rp::CustomRenderPass::new(&device, &{ + simple_rp::Formats { color: (Format::R8G8B8A8Unorm, 1) } + }).unwrap(), 0).unwrap(), + }); + + match result { + Err(GraphicsPipelineCreationError::MaxViewportsExceeded { .. }) => (), + _ => panic!() + } +} + +#[test] +fn no_depth_attachment() { + let (device, _) = gfx_dev_and_queue!(); + + let vs = unsafe { ShaderModule::new(device.clone(), &BASIC_VS).unwrap() }; + let fs = unsafe { ShaderModule::new(device.clone(), &BASIC_FS).unwrap() }; + + let result = GraphicsPipeline::new(&device, GraphicsPipelineParams { + vertex_input: SingleBufferDefinition::<()>::new(), + vertex_shader: unsafe { + vs.vertex_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(), + EmptyShaderInterfaceDef, + EmptyShaderInterfaceDef, + EmptyPipelineDesc) + }, + input_assembly: InputAssembly::triangle_list(), + tessellation: None, + geometry_shader: None, + viewport: ViewportsState::Dynamic { num: 1 }, + raster: Default::default(), + multisample: Multisample::disabled(), + fragment_shader: unsafe { + fs.fragment_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(), + EmptyShaderInterfaceDef, + EmptyShaderInterfaceDef, + EmptyPipelineDesc) + }, + depth_stencil: DepthStencil::simple_depth_test(), + blend: Blend::pass_through(), + render_pass: Subpass::from(simple_rp::CustomRenderPass::new(&device, &{ + simple_rp::Formats { color: (Format::R8G8B8A8Unorm, 1) } + }).unwrap(), 0).unwrap(), + }); + + match result { + Err(GraphicsPipelineCreationError::NoDepthAttachment) => (), + _ => panic!() + } +} + + +mod simple_rp { + use format::Format; + + single_pass_renderpass!{ + attachments: { + color: { + load: Clear, + store: Store, + format: Format, + } + }, + pass: { + color: [color], + depth_stencil: {} + } + } +} + +/* + #version 450 + + #extension GL_ARB_separate_shader_objects : enable + #extension GL_ARB_shading_language_420pack : enable + + layout(location = 0) in vec2 position; + + void main() { + gl_Position = vec4(position, 0.0, 1.0); + } +*/ +const BASIC_VS: [u8; 912] = [3, 2, 35, 7, 0, 0, 1, 0, 1, 0, 8, 0, 27, 0, 0, 0, 0, 0, 0, 0, 17, + 0, 2, 0, 1, 0, 0, 0, 17, 0, 2, 0, 32, 0, 0, 0, 17, 0, 2, 0, 33, 0, + 0, 0, 11, 0, 6, 0, 1, 0, 0, 0, 71, 76, 83, 76, 46, 115, 116, 100, + 46, 52, 53, 48, 0, 0, 0, 0, 14, 0, 3, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 15, 0, 7, 0, 0, 0, 0, 0, 4, 0, 0, 0, 109, 97, 105, 110, 0, 0, 0, + 0, 13, 0, 0, 0, 18, 0, 0, 0, 3, 0, 3, 0, 2, 0, 0, 0, 194, 1, 0, + 0, 4, 0, 9, 0, 71, 76, 95, 65, 82, 66, 95, 115, 101, 112, 97, + 114, 97, 116, 101, 95, 115, 104, 97, 100, 101, 114, 95, 111, 98, + 106, 101, 99, 116, 115, 0, 0, 4, 0, 9, 0, 71, 76, 95, 65, 82, 66, + 95, 115, 104, 97, 100, 105, 110, 103, 95, 108, 97, 110, 103, 117, + 97, 103, 101, 95, 52, 50, 48, 112, 97, 99, 107, 0, 5, 0, 4, 0, 4, + 0, 0, 0, 109, 97, 105, 110, 0, 0, 0, 0, 5, 0, 6, 0, 11, 0, 0, 0, + 103, 108, 95, 80, 101, 114, 86, 101, 114, 116, 101, 120, 0, 0, 0, + 0, 6, 0, 6, 0, 11, 0, 0, 0, 0, 0, 0, 0, 103, 108, 95, 80, 111, + 115, 105, 116, 105, 111, 110, 0, 6, 0, 7, 0, 11, 0, 0, 0, 1, 0, + 0, 0, 103, 108, 95, 80, 111, 105, 110, 116, 83, 105, 122, 101, 0, + 0, 0, 0, 6, 0, 7, 0, 11, 0, 0, 0, 2, 0, 0, 0, 103, 108, 95, 67, + 108, 105, 112, 68, 105, 115, 116, 97, 110, 99, 101, 0, 6, 0, 7, + 0, 11, 0, 0, 0, 3, 0, 0, 0, 103, 108, 95, 67, 117, 108, 108, 68, + 105, 115, 116, 97, 110, 99, 101, 0, 5, 0, 3, 0, 13, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 5, 0, 18, 0, 0, 0, 112, 111, 115, 105, 116, 105, 111, + 110, 0, 0, 0, 0, 72, 0, 5, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, + 0, 0, 0, 0, 0, 72, 0, 5, 0, 11, 0, 0, 0, 1, 0, 0, 0, 11, 0, 0, 0, + 1, 0, 0, 0, 72, 0, 5, 0, 11, 0, 0, 0, 2, 0, 0, 0, 11, 0, 0, 0, 3, + 0, 0, 0, 72, 0, 5, 0, 11, 0, 0, 0, 3, 0, 0, 0, 11, 0, 0, 0, 4, 0, + 0, 0, 71, 0, 3, 0, 11, 0, 0, 0, 2, 0, 0, 0, 71, 0, 4, 0, 18, 0, 0, + 0, 30, 0, 0, 0, 0, 0, 0, 0, 19, 0, 2, 0, 2, 0, 0, 0, 33, 0, 3, 0, + 3, 0, 0, 0, 2, 0, 0, 0, 22, 0, 3, 0, 6, 0, 0, 0, 32, 0, 0, 0, 23, + 0, 4, 0, 7, 0, 0, 0, 6, 0, 0, 0, 4, 0, 0, 0, 21, 0, 4, 0, 8, 0, 0, + 0, 32, 0, 0, 0, 0, 0, 0, 0, 43, 0, 4, 0, 8, 0, 0, 0, 9, 0, 0, 0, + 1, 0, 0, 0, 28, 0, 4, 0, 10, 0, 0, 0, 6, 0, 0, 0, 9, 0, 0, 0, 30, + 0, 6, 0, 11, 0, 0, 0, 7, 0, 0, 0, 6, 0, 0, 0, 10, 0, 0, 0, 10, 0, + 0, 0, 32, 0, 4, 0, 12, 0, 0, 0, 3, 0, 0, 0, 11, 0, 0, 0, 59, 0, + 4, 0, 12, 0, 0, 0, 13, 0, 0, 0, 3, 0, 0, 0, 21, 0, 4, 0, 14, 0, + 0, 0, 32, 0, 0, 0, 1, 0, 0, 0, 43, 0, 4, 0, 14, 0, 0, 0, 15, 0, + 0, 0, 0, 0, 0, 0, 23, 0, 4, 0, 16, 0, 0, 0, 6, 0, 0, 0, 2, 0, 0, + 0, 32, 0, 4, 0, 17, 0, 0, 0, 1, 0, 0, 0, 16, 0, 0, 0, 59, 0, 4, + 0, 17, 0, 0, 0, 18, 0, 0, 0, 1, 0, 0, 0, 43, 0, 4, 0, 6, 0, 0, + 0, 20, 0, 0, 0, 0, 0, 0, 0, 43, 0, 4, 0, 6, 0, 0, 0, 21, 0, 0, + 0, 0, 0, 128, 63, 32, 0, 4, 0, 25, 0, 0, 0, 3, 0, 0, 0, 7, 0, 0, + 0, 54, 0, 5, 0, 2, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, + 248, 0, 2, 0, 5, 0, 0, 0, 61, 0, 4, 0, 16, 0, 0, 0, 19, 0, 0, 0, + 18, 0, 0, 0, 81, 0, 5, 0, 6, 0, 0, 0, 22, 0, 0, 0, 19, 0, 0, 0, + 0, 0, 0, 0, 81, 0, 5, 0, 6, 0, 0, 0, 23, 0, 0, 0, 19, 0, 0, 0, 1, + 0, 0, 0, 80, 0, 7, 0, 7, 0, 0, 0, 24, 0, 0, 0, 22, 0, 0, 0, 23, + 0, 0, 0, 20, 0, 0, 0, 21, 0, 0, 0, 65, 0, 5, 0, 25, 0, 0, 0, 26, + 0, 0, 0, 13, 0, 0, 0, 15, 0, 0, 0, 62, 0, 3, 0, 26, 0, 0, 0, 24, + 0, 0, 0, 253, 0, 1, 0, 56, 0, 1, 0]; + +/* + #version 450 + + #extension GL_ARB_separate_shader_objects : enable + #extension GL_ARB_shading_language_420pack : enable + + layout(location = 0) out vec4 f_color; + + void main() { + f_color = vec4(1.0, 0.0, 0.0, 1.0); + } +*/ +const BASIC_FS: [u8; 420] = [3, 2, 35, 7, 0, 0, 1, 0, 1, 0, 8, 0, 13, 0, 0, 0, 0, 0, 0, 0, 17, + 0, 2, 0, 1, 0, 0, 0, 11, 0, 6, 0, 1, 0, 0, 0, 71, 76, 83, 76, 46, + 115, 116, 100, 46, 52, 53,48, 0, 0, 0, 0, 14, 0, 3, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 15, 0, 6, 0, 4, 0, 0, 0, 4, 0, 0, 0, 109, 97, + 105, 110, 0, 0, 0, 0, 9, 0, 0, 0, 16, 0, 3, 0, 4, 0, 0, 0, 7, 0, + 0, 0, 3, 0, 3, 0, 2, 0, 0, 0, 194, 1, 0, 0, 4, 0, 9, 0, 71, 76, + 95, 65, 82, 66, 95, 115, 101, 112, 97, 114, 97, 116, 101, 95, + 115, 104, 97, 100, 101, 114, 95, 111, 98, 106, 101, 99, 116, 115, + 0, 0, 4, 0, 9, 0, 71, 76, 95, 65, 82, 66, 95, 115, 104, 97, 100, + 105, 110, 103, 95, 108, 97, 110, 103, 117, 97, 103, 101, 95, 52, + 50, 48, 112, 97, 99, 107, 0, 5, 0, 4, 0, 4, 0, 0, 0, 109, 97, + 105, 110, 0, 0, 0, 0, 5, 0, 4, 0, 9, 0, 0, 0, 102, 95, 99, 111, + 108, 111, 114, 0, 71, 0, 4, 0, 9, 0, 0, 0, 30, 0, 0, 0, 0, 0, + 0, 0, 19, 0, 2, 0, 2, 0, 0, 0, 33, 0, 3, 0, 3, 0, 0, 0, 2, 0, 0, + 0, 22, 0, 3, 0, 6, 0, 0, 0, 32, 0, 0, 0, 23, 0, 4, 0, 7, 0, 0, + 0, 6, 0, 0, 0, 4, 0, 0, 0, 32, 0, 4, 0, 8, 0, 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 59, 0, 4, 0, 8, 0, 0, 0, 9, 0, 0, 0, 3, 0, 0, 0, 43, + 0, 4, 0, 6, 0, 0, 0, 10, 0, 0, 0, 0, 0, 128, 63, 43, 0, 4, 0, 6, + 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 44, 0, 7, 0, 7, 0, 0, 0, 12, 0, + 0, 0, 10, 0, 0, 0, 11, 0, 0, 0, 11, 0, 0, 0, 10, 0, 0, 0, 54, 0, + 5, 0, 2, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 248, 0, 2, + 0, 5, 0, 0, 0, 62, 0, 3, 0, 9, 0, 0, 0, 12, 0, 0, 0, 253, 0, 1, + 0, 56, 0, 1, 0]; diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/input_assembly.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/input_assembly.rs new file mode 100644 index 0000000..6b732c1 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/input_assembly.rs @@ -0,0 +1,127 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Assembling vertices into primitives. +//! +//! The input assembly is the stage where lists of vertices are turned into primitives. +//! + +use vk; + +/// How the input assembly stage should behave. +#[derive(Copy, Clone, Debug)] +#[deprecated] +pub struct InputAssembly { + /// The type of primitives. + /// + /// Note that some topologies don't support primitive restart. + pub topology: PrimitiveTopology, + + /// If true, then the special index value `0xffff` or `0xffffffff` will tell the GPU that it is + /// the end of the current primitive. A new primitive will restart at the next index. + /// + /// Note that some topologies don't support primitive restart. + pub primitive_restart_enable: bool, +} + +impl InputAssembly { + /// Builds an `InputAssembly` struct with the `TriangleList` topology. + #[inline] + pub fn triangle_list() -> InputAssembly { + InputAssembly { + topology: PrimitiveTopology::TriangleList, + primitive_restart_enable: false, + } + } +} + +/// Describes how vertices must be grouped together to form primitives. +/// +/// Note that some topologies don't support primitive restart. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum PrimitiveTopology { + PointList, + LineList, + LineStrip, + TriangleList, + TriangleStrip, + TriangleFan, + LineListWithAdjacency, + LineStripWithAdjacency, + TriangleListWithAdjacency, + TriangleStripWithAdjacency, + PatchList { vertices_per_patch: u32 }, +} + +impl Into<vk::PrimitiveTopology> for PrimitiveTopology { + #[inline] + fn into(self) -> vk::PrimitiveTopology { + match self { + PrimitiveTopology::PointList => vk::PRIMITIVE_TOPOLOGY_POINT_LIST, + PrimitiveTopology::LineList => vk::PRIMITIVE_TOPOLOGY_LINE_LIST, + PrimitiveTopology::LineStrip => vk::PRIMITIVE_TOPOLOGY_LINE_STRIP, + PrimitiveTopology::TriangleList => vk::PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, + PrimitiveTopology::TriangleStrip => vk::PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, + PrimitiveTopology::TriangleFan => vk::PRIMITIVE_TOPOLOGY_TRIANGLE_FAN, + PrimitiveTopology::LineListWithAdjacency => + vk::PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, + PrimitiveTopology::LineStripWithAdjacency => + vk::PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY, + PrimitiveTopology::TriangleListWithAdjacency => + vk::PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, + PrimitiveTopology::TriangleStripWithAdjacency => + vk::PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY, + PrimitiveTopology::PatchList { .. } => vk::PRIMITIVE_TOPOLOGY_PATCH_LIST, + } + } +} + +impl PrimitiveTopology { + /// Returns true if this primitive topology supports using primitives restart. + #[inline] + pub fn supports_primitive_restart(&self) -> bool { + match *self { + PrimitiveTopology::LineStrip => true, + PrimitiveTopology::TriangleStrip => true, + PrimitiveTopology::TriangleFan => true, + PrimitiveTopology::LineStripWithAdjacency => true, + PrimitiveTopology::TriangleStripWithAdjacency => true, + _ => false, + } + } +} + +/// Trait for types that can be used as indices by the GPU. +pub unsafe trait Index { + /// Returns the type of data. + fn ty() -> IndexType; +} + +unsafe impl Index for u16 { + #[inline(always)] + fn ty() -> IndexType { + IndexType::U16 + } +} + +unsafe impl Index for u32 { + #[inline(always)] + fn ty() -> IndexType { + IndexType::U32 + } +} + +/// An enumeration of all valid index types. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +#[allow(missing_docs)] +#[repr(u32)] +pub enum IndexType { + U16 = vk::INDEX_TYPE_UINT16, + U32 = vk::INDEX_TYPE_UINT32, +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/mod.rs new file mode 100644 index 0000000..5235199 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/mod.rs @@ -0,0 +1,99 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Describes a graphical or compute operation. +//! +//! In Vulkan, before you can add a draw or a compute command to a command buffer you have to +//! create a *pipeline object* that describes this command. +//! +//! When you create a pipeline object, the implementation will usually generate some GPU machine +//! code that will execute the operation (similar to a compiler that generates an executable for +//! the CPU). Consequently it is a CPU-intensive operation that should be performed at +//! initialization or during a loading screen. +//! +//! There are two kinds of pipelines: +//! +//! - `ComputePipeline`s, for compute operations (general-purpose operations that read/write data +//! in buffers or raw pixels in images). +//! - `GraphicsPipeline`s, for graphical operations (operations that take vertices as input and +//! write pixels to a framebuffer). +//! +//! # Creating a compute pipeline. +//! +//! In order to create a compute pipeline, you first need a *shader entry point*. +//! +//! TODO: write the rest +//! For now vulkano has no "clean" way to create shaders ; everything's a bit hacky +//! +//! # Creating a graphics pipeline +//! +//! A graphics operation takes vertices or vertices and indices as input, and writes pixels to a +//! framebuffer. It consists of multiple steps: +//! +//! - A *shader* named the *vertex shader* is run once for each vertex of the input. +//! - Vertices are assembled into primitives. +//! - Optionally, a shader named the *tessellation control shader* is run once for each primitive +//! and indicates the tessellation level to apply for this primitive. +//! - Optionally, a shader named the *tessellation evaluation shader* is run once for each vertex, +//! including the ones newly created by the tessellation. +//! - Optionally, a shader named the *geometry shader* is run once for each line or triangle. +//! - The vertex coordinates (as outputted by the geometry shader, or by the tessellation +//! evaluation shader if there's no geometry shader, or by the vertex shader if there's no +//! geometry shader nor tessellation evaluation shader) are turned into screen-space coordinates. +//! - The list of pixels that cover each triangle are determined. +//! - A shader named the fragment shader is run once for each pixel that covers one of the +//! triangles. +//! - The depth test and/or the stencil test are performed. +//! - The output of the fragment shader is written to the framebuffer attachments, possibly by +//! mixing it with the existing values. +//! +//! All the sub-modules of this module (with the exception of `cache`) correspond to the various +//! stages of graphical pipelines. +//! +//! > **Note**: With the exception of the addition of the tessellation shaders and the geometry +//! > shader, these steps haven't changed in the past decade. If you are familiar with shaders in +//! > OpenGL 2 for example, don't worry as it works in the same in Vulkan. +//! +//! > **Note**: All the stages that consist in executing a shader are performed by a microprocessor +//! > (unless you happen to use a software implementation of Vulkan). As for the other stages, +//! > some hardware (usually desktop graphics cards) have dedicated chips that will execute them +//! > while some other hardware (usually mobile) perform them with the microprocessor as well. In +//! > the latter situation, the implementation will usually glue these steps to your shaders. +//! +//! Creating a graphics pipeline follows the same principle as a compute pipeline, except that +//! you must pass multiple shaders alongside with configuration for the other steps. +//! +//! TODO: add an example + +// TODO: graphics pipeline params are deprecated, but are still the primary implementation in order +// to avoid duplicating code, so we hide the warnings for now +#![allow(deprecated)] + +pub use self::compute_pipeline::ComputePipeline; +pub use self::compute_pipeline::ComputePipelineAbstract; +pub use self::compute_pipeline::ComputePipelineCreationError; +pub use self::compute_pipeline::ComputePipelineSys; +pub use self::graphics_pipeline::GraphicsPipeline; +pub use self::graphics_pipeline::GraphicsPipelineAbstract; +pub use self::graphics_pipeline::GraphicsPipelineBuilder; +pub use self::graphics_pipeline::GraphicsPipelineCreationError; +pub use self::graphics_pipeline::GraphicsPipelineSys; + +mod compute_pipeline; +mod graphics_pipeline; + +pub mod blend; +pub mod cache; +pub mod depth_stencil; +pub mod input_assembly; +pub mod multisample; +pub mod raster; +pub mod shader; +pub mod vertex; +pub mod viewport; diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/multisample.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/multisample.rs new file mode 100644 index 0000000..4466f9f --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/multisample.rs @@ -0,0 +1,61 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! State of multisampling. +//! +//! Multisampling allows you to ask the GPU to run the rasterizer to generate more than one +//! sample per pixel. +//! +//! For example, if `rasterization_samples` is 1 then the fragment shader, depth test and stencil +//! test will be run once for each pixel. However if `rasterization_samples` is `n`, then the +//! GPU will pick `n` different locations within each pixel and assign to each of these locations +//! a different depth value. Depth and stencil test will then be run `n` times. +//! +//! In addition to this, the `sample_shading` parameter is the proportion (between 0.0 and 1.0) or +//! the samples that will be run through the fragment shader. For example if you set this to 1.0, +//! then all the sub-pixel samples will run through the shader and get a different value. If you +//! set this to 0.5, about half of the samples will run through the shader and the other half will +//! get their values from the ones which went through the shader. +//! +//! If `alpha_to_coverage` is true, then the alpha value of the fragment will be used in +//! an implementation-defined way to determine which samples get disabled or not. For example if +//! the alpha value is 0.5, then about half of the samples will be discarded. If you render to a +//! multisample image, this means that the color will end up being mixed with whatever color was +//! underneath, which gives the same effect as alpha blending. +//! +//! If `alpha_to_one` is true, the alpha value of all the samples will be forced to 1.0 (or the +//! maximum possible value) after the effects of `alpha_to_coverage` have been applied. + +// TODO: handle some weird behaviors with non-floating-point targets + +/// State of the multisampling. +/// +/// See the documentation in this module. +#[deprecated(note = "No longer needed")] +#[derive(Debug, Copy, Clone)] +pub struct Multisample { + pub rasterization_samples: u32, + pub sample_mask: [u32; 4], + pub sample_shading: Option<f32>, + pub alpha_to_coverage: bool, + pub alpha_to_one: bool, +} + +impl Multisample { + #[inline] + pub fn disabled() -> Multisample { + Multisample { + rasterization_samples: 1, + sample_mask: [0xffffffff; 4], + sample_shading: None, + alpha_to_coverage: false, + alpha_to_one: false, + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/raster.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/raster.rs new file mode 100644 index 0000000..db61eb0 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/raster.rs @@ -0,0 +1,147 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Stage when triangles are turned into pixels. +//! +//! The rasterization is the stage when collections of triangles are turned into collections +//! of pixels or samples. +//! + +use vk; + +/// State of the rasterizer. +#[derive(Clone, Debug)] +pub struct Rasterization { + /// If true, then the depth value of the vertices will be clamped to [0.0 ; 1.0]. If false, + /// fragments whose depth is outside of this range will be discarded. + pub depth_clamp: bool, + + /// If true, all the fragments will be discarded. This is usually used when your vertex shader + /// has some side effects and you don't need to run the fragment shader. + pub rasterizer_discard: bool, + + /// This setting can ask the rasterizer to downgrade triangles into lines or points, or lines + /// into points. + pub polygon_mode: PolygonMode, + + /// Specifies whether front faces or back faces should be discarded, or none, or both. + pub cull_mode: CullMode, + + /// Specifies which triangle orientation corresponds to the front or the triangle. + pub front_face: FrontFace, + + /// Width, in pixels, of lines when drawing lines. + /// + /// If you pass `None`, then this state will be considered as dynamic and the line width will + /// need to be set when you build the command buffer. + pub line_width: Option<f32>, + + pub depth_bias: DepthBiasControl, +} + +impl Default for Rasterization { + #[inline] + fn default() -> Rasterization { + Rasterization { + depth_clamp: false, + rasterizer_discard: false, + polygon_mode: Default::default(), + cull_mode: Default::default(), + front_face: Default::default(), + line_width: Some(1.0), + depth_bias: DepthBiasControl::Disabled, + } + } +} + +#[derive(Copy, Clone, Debug)] +pub enum DepthBiasControl { + Disabled, + Dynamic, + Static(DepthBias), +} + +impl DepthBiasControl { + #[inline] + pub fn is_dynamic(&self) -> bool { + match *self { + DepthBiasControl::Dynamic => true, + _ => false, + } + } +} + +#[derive(Copy, Clone, Debug)] +pub struct DepthBias { + pub constant_factor: f32, + /// Requires the `depth_bias_clamp` feature to be enabled. + pub clamp: f32, + pub slope_factor: f32, +} + +/// Specifies the culling mode. +/// +/// This setting works in pair with `front_face`. The `front_face` setting tells the GPU whether +/// clockwise or counter-clockwise correspond to the front and the back of each triangle. Then +/// `cull_mode` lets you specify whether front faces should be discarded, back faces should be +/// discarded, or none, or both. +#[derive(Copy, Clone, Debug)] +#[repr(u32)] +pub enum CullMode { + /// No culling. + None = vk::CULL_MODE_NONE, + /// The faces facing the front of the screen (ie. facing the user) will be removed. + Front = vk::CULL_MODE_FRONT_BIT, + /// The faces facing the back of the screen will be removed. + Back = vk::CULL_MODE_BACK_BIT, + /// All faces will be removed. + FrontAndBack = vk::CULL_MODE_FRONT_AND_BACK, +} + +impl Default for CullMode { + #[inline] + fn default() -> CullMode { + CullMode::None + } +} + +/// Specifies which triangle orientation corresponds to the front or the triangle. +#[derive(Copy, Clone, Debug)] +#[repr(u32)] +pub enum FrontFace { + /// Triangles whose vertices are oriented counter-clockwise on the screen will be considered + /// as facing their front. Otherwise they will be considered as facing their back. + CounterClockwise = vk::FRONT_FACE_COUNTER_CLOCKWISE, + + /// Triangles whose vertices are oriented clockwise on the screen will be considered + /// as facing their front. Otherwise they will be considered as facing their back. + Clockwise = vk::FRONT_FACE_CLOCKWISE, +} + +impl Default for FrontFace { + #[inline] + fn default() -> FrontFace { + FrontFace::CounterClockwise + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u32)] +pub enum PolygonMode { + Fill = vk::POLYGON_MODE_FILL, + Line = vk::POLYGON_MODE_LINE, + Point = vk::POLYGON_MODE_POINT, +} + +impl Default for PolygonMode { + #[inline] + fn default() -> PolygonMode { + PolygonMode::Fill + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/shader.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/shader.rs new file mode 100644 index 0000000..ec652db --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/shader.rs @@ -0,0 +1,648 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Stage of a graphics pipeline. +//! +//! In Vulkan, shaders are grouped in *shader modules*. Each shader module is built from SPIR-V +//! code and can contain one or more entry points. Note that for the moment the official +//! GLSL-to-SPIR-V compiler does not support multiple entry points. +//! +//! The vulkano library does not provide any functionality that checks and introspects the SPIR-V +//! code, therefore the whole shader-related API is unsafe. You are encouraged to use the +//! `vulkano-shaders` crate that will generate Rust code that wraps around vulkano's shaders API. + +use std::borrow::Cow; +use std::error; +use std::ffi::CStr; +use std::fmt; +use std::iter; +use std::iter::Empty as EmptyIter; +use std::marker::PhantomData; +use std::mem; +use std::ops::Range; +use std::ptr; +use std::sync::Arc; + +use descriptor::pipeline_layout::EmptyPipelineDesc; +use descriptor::pipeline_layout::PipelineLayoutDesc; +use format::Format; +use pipeline::input_assembly::PrimitiveTopology; + +use OomError; +use VulkanObject; +use check_errors; +use device::Device; +use vk; + +/// Contains SPIR-V code with one or more entry points. +/// +/// Note that it is advised to wrap around a `ShaderModule` with a struct that is different for +/// each shader. +#[derive(Debug)] +pub struct ShaderModule { + // The module. + module: vk::ShaderModule, + // Pointer to the device. + device: Arc<Device>, +} + +impl ShaderModule { + /// Builds a new shader module from SPIR-V bytes. + /// + /// # Safety + /// + /// - The SPIR-V code is not validated. + /// - The SPIR-V code may require some features that are not enabled. This isn't checked by + /// this function either. + /// + pub unsafe fn new(device: Arc<Device>, spirv: &[u8]) -> Result<Arc<ShaderModule>, OomError> { + debug_assert!((spirv.len() % 4) == 0); + Self::from_ptr(device, spirv.as_ptr() as *const _, spirv.len()) + } + + /// Builds a new shader module from SPIR-V 32-bit words. + /// + /// # Safety + /// + /// - The SPIR-V code is not validated. + /// - The SPIR-V code may require some features that are not enabled. This isn't checked by + /// this function either. + /// + pub unsafe fn from_words(device: Arc<Device>, spirv: &[u32]) + -> Result<Arc<ShaderModule>, OomError> { + Self::from_ptr(device, spirv.as_ptr(), spirv.len() * mem::size_of::<u32>()) + } + + /// Builds a new shader module from SPIR-V. + /// + /// # Safety + /// + /// - The SPIR-V code is not validated. + /// - The SPIR-V code may require some features that are not enabled. This isn't checked by + /// this function either. + /// + unsafe fn from_ptr(device: Arc<Device>, spirv: *const u32, spirv_len: usize) + -> Result<Arc<ShaderModule>, OomError> { + let module = { + let infos = vk::ShaderModuleCreateInfo { + sType: vk::STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + codeSize: spirv_len, + pCode: spirv, + }; + + let vk = device.pointers(); + let mut output = mem::uninitialized(); + check_errors(vk.CreateShaderModule(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(ShaderModule { + module: module, + device: device, + })) + } + + /// Gets access to an entry point contained in this module. + /// + /// This is purely a *logical* operation. It returns a struct that *represents* the entry + /// point but doesn't actually do anything. + /// + /// # Safety + /// + /// - The user must check that the entry point exists in the module, as this is not checked + /// by Vulkan. + /// - The input, output and layout must correctly describe the input, output and layout used + /// by this stage. + /// + pub unsafe fn graphics_entry_point<'a, S, I, O, L>(&'a self, name: &'a CStr, input: I, + output: O, layout: L, + ty: GraphicsShaderType) + -> GraphicsEntryPoint<'a, S, I, O, L> { + GraphicsEntryPoint { + module: self, + name: name, + input: input, + output: output, + layout: layout, + ty: ty, + marker: PhantomData, + } + } + + /// Gets access to an entry point contained in this module. + /// + /// This is purely a *logical* operation. It returns a struct that *represents* the entry + /// point but doesn't actually do anything. + /// + /// # Safety + /// + /// - The user must check that the entry point exists in the module, as this is not checked + /// by Vulkan. + /// - The layout must correctly describe the layout used by this stage. + /// + #[inline] + pub unsafe fn compute_entry_point<'a, S, L>(&'a self, name: &'a CStr, layout: L) + -> ComputeEntryPoint<'a, S, L> { + ComputeEntryPoint { + module: self, + name: name, + layout: layout, + marker: PhantomData, + } + } +} + +unsafe impl VulkanObject for ShaderModule { + type Object = vk::ShaderModule; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT; + + #[inline] + fn internal_object(&self) -> vk::ShaderModule { + self.module + } +} + +impl Drop for ShaderModule { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyShaderModule(self.device.internal_object(), self.module, ptr::null()); + } + } +} + +pub unsafe trait GraphicsEntryPointAbstract: EntryPointAbstract { + type InputDefinition: ShaderInterfaceDef; + type OutputDefinition: ShaderInterfaceDef; + + /// Returns the input attributes used by the shader stage. + fn input(&self) -> &Self::InputDefinition; + + /// Returns the output attributes used by the shader stage. + fn output(&self) -> &Self::OutputDefinition; + + /// Returns the type of shader. + fn ty(&self) -> GraphicsShaderType; +} + +/// Represents a shader entry point in a shader module. +/// +/// Can be obtained by calling `entry_point()` on the shader module. +#[derive(Debug, Copy, Clone)] +pub struct GraphicsEntryPoint<'a, S, I, O, L> { + module: &'a ShaderModule, + name: &'a CStr, + input: I, + layout: L, + output: O, + ty: GraphicsShaderType, + marker: PhantomData<S>, +} + +unsafe impl<'a, S, I, O, L> EntryPointAbstract for GraphicsEntryPoint<'a, S, I, O, L> + where L: PipelineLayoutDesc, + I: ShaderInterfaceDef, + O: ShaderInterfaceDef, + S: SpecializationConstants +{ + type PipelineLayout = L; + type SpecializationConstants = S; + + #[inline] + fn module(&self) -> &ShaderModule { + self.module + } + + #[inline] + fn name(&self) -> &CStr { + self.name + } + + #[inline] + fn layout(&self) -> &L { + &self.layout + } +} + +unsafe impl<'a, S, I, O, L> GraphicsEntryPointAbstract for GraphicsEntryPoint<'a, S, I, O, L> + where L: PipelineLayoutDesc, + I: ShaderInterfaceDef, + O: ShaderInterfaceDef, + S: SpecializationConstants +{ + type InputDefinition = I; + type OutputDefinition = O; + + #[inline] + fn input(&self) -> &I { + &self.input + } + + #[inline] + fn output(&self) -> &O { + &self.output + } + + #[inline] + fn ty(&self) -> GraphicsShaderType { + self.ty + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum GraphicsShaderType { + Vertex, + TessellationControl, + TessellationEvaluation, + Geometry(GeometryShaderExecutionMode), + Fragment, +} + +/// Declares which type of primitives are expected by the geometry shader. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum GeometryShaderExecutionMode { + Points, + Lines, + LinesWithAdjacency, + Triangles, + TrianglesWithAdjacency, +} + +impl GeometryShaderExecutionMode { + /// Returns true if the given primitive topology can be used with this execution mode. + #[inline] + pub fn matches(&self, input: PrimitiveTopology) -> bool { + match (*self, input) { + (GeometryShaderExecutionMode::Points, PrimitiveTopology::PointList) => true, + (GeometryShaderExecutionMode::Lines, PrimitiveTopology::LineList) => true, + (GeometryShaderExecutionMode::Lines, PrimitiveTopology::LineStrip) => true, + (GeometryShaderExecutionMode::LinesWithAdjacency, + PrimitiveTopology::LineListWithAdjacency) => true, + (GeometryShaderExecutionMode::LinesWithAdjacency, + PrimitiveTopology::LineStripWithAdjacency) => true, + (GeometryShaderExecutionMode::Triangles, PrimitiveTopology::TriangleList) => true, + (GeometryShaderExecutionMode::Triangles, PrimitiveTopology::TriangleStrip) => true, + (GeometryShaderExecutionMode::Triangles, PrimitiveTopology::TriangleFan) => true, + (GeometryShaderExecutionMode::TrianglesWithAdjacency, + PrimitiveTopology::TriangleListWithAdjacency) => true, + (GeometryShaderExecutionMode::TrianglesWithAdjacency, + PrimitiveTopology::TriangleStripWithAdjacency) => true, + _ => false, + } + } +} + +pub unsafe trait EntryPointAbstract { + type PipelineLayout: PipelineLayoutDesc; + type SpecializationConstants: SpecializationConstants; + + /// Returns the module this entry point comes from. + fn module(&self) -> &ShaderModule; + + /// Returns the name of the entry point. + fn name(&self) -> &CStr; + + /// Returns the pipeline layout used by the shader stage. + fn layout(&self) -> &Self::PipelineLayout; +} + +/// Represents the entry point of a compute shader in a shader module. +/// +/// Can be obtained by calling `compute_shader_entry_point()` on the shader module. +#[derive(Debug, Copy, Clone)] +pub struct ComputeEntryPoint<'a, S, L> { + module: &'a ShaderModule, + name: &'a CStr, + layout: L, + marker: PhantomData<S>, +} + +unsafe impl<'a, S, L> EntryPointAbstract for ComputeEntryPoint<'a, S, L> + where L: PipelineLayoutDesc, + S: SpecializationConstants +{ + type PipelineLayout = L; + type SpecializationConstants = S; + + #[inline] + fn module(&self) -> &ShaderModule { + self.module + } + + #[inline] + fn name(&self) -> &CStr { + self.name + } + + #[inline] + fn layout(&self) -> &L { + &self.layout + } +} + +/// A dummy that implements `GraphicsEntryPointAbstract` and `EntryPointAbstract`. +/// +/// When a function has a signature like: `fn foo<S: EntryPointAbstract>(shader: Option<S>)`, you +/// can pass `None::<EmptyEntryPointDummy>`. +/// +/// This object is meant to be a replacement to `!` before it is stabilized. +// TODO: ^ +#[derive(Debug, Copy, Clone)] +pub enum EmptyEntryPointDummy { +} + +unsafe impl EntryPointAbstract for EmptyEntryPointDummy { + type PipelineLayout = EmptyPipelineDesc; + type SpecializationConstants = (); + + #[inline] + fn module(&self) -> &ShaderModule { + unreachable!() + } + + #[inline] + fn name(&self) -> &CStr { + unreachable!() + } + + #[inline] + fn layout(&self) -> &EmptyPipelineDesc { + unreachable!() + } +} + +unsafe impl GraphicsEntryPointAbstract for EmptyEntryPointDummy { + type InputDefinition = EmptyShaderInterfaceDef; + type OutputDefinition = EmptyShaderInterfaceDef; + + #[inline] + fn input(&self) -> &EmptyShaderInterfaceDef { + unreachable!() + } + + #[inline] + fn output(&self) -> &EmptyShaderInterfaceDef { + unreachable!() + } + + #[inline] + fn ty(&self) -> GraphicsShaderType { + unreachable!() + } +} + +/// Types that contain the definition of an interface between two shader stages, or between +/// the outside and a shader stage. +/// +/// # Safety +/// +/// - Must only provide one entry per location. +/// - The format of each element must not be larger than 128 bits. +/// +pub unsafe trait ShaderInterfaceDef { + /// Iterator returned by `elements`. + type Iter: ExactSizeIterator<Item = ShaderInterfaceDefEntry>; + + /// Iterates over the elements of the interface. + fn elements(&self) -> Self::Iter; +} + +/// Entry of a shader interface definition. +#[derive(Debug, Clone)] +pub struct ShaderInterfaceDefEntry { + /// Range of locations covered by the element. + pub location: Range<u32>, + /// Format of a each location of the element. + pub format: Format, + /// Name of the element, or `None` if the name is unknown. + pub name: Option<Cow<'static, str>>, +} + +/// Description of an empty shader interface. +#[derive(Debug, Copy, Clone)] +pub struct EmptyShaderInterfaceDef; + +unsafe impl ShaderInterfaceDef for EmptyShaderInterfaceDef { + type Iter = EmptyIter<ShaderInterfaceDefEntry>; + + #[inline] + fn elements(&self) -> Self::Iter { + iter::empty() + } +} + +/// Extension trait for `ShaderInterfaceDef` that specifies that the interface is potentially +/// compatible with another one. +pub unsafe trait ShaderInterfaceDefMatch<I>: ShaderInterfaceDef + where I: ShaderInterfaceDef +{ + /// Returns `Ok` if the two definitions match. + fn matches(&self, other: &I) -> Result<(), ShaderInterfaceMismatchError>; +} + +// TODO: turn this into a default impl that can be specialized +unsafe impl<T, I> ShaderInterfaceDefMatch<I> for T + where T: ShaderInterfaceDef, + I: ShaderInterfaceDef +{ + fn matches(&self, other: &I) -> Result<(), ShaderInterfaceMismatchError> { + if self.elements().len() != other.elements().len() { + return Err(ShaderInterfaceMismatchError::ElementsCountMismatch { + self_elements: self.elements().len() as u32, + other_elements: other.elements().len() as u32, + }); + } + + for a in self.elements() { + for loc in a.location.clone() { + let b = match other + .elements() + .find(|e| loc >= e.location.start && loc < e.location.end) { + None => return Err(ShaderInterfaceMismatchError::MissingElement { + location: loc, + }), + Some(b) => b, + }; + + if a.format != b.format { + return Err(ShaderInterfaceMismatchError::FormatMismatch { + location: loc, + self_format: a.format, + other_format: b.format, + }); + } + + // TODO: enforce this? + /*match (a.name, b.name) { + (Some(ref an), Some(ref bn)) => if an != bn { return false }, + _ => () + };*/ + } + } + + // Note: since we check that the number of elements is the same, we don't need to iterate + // over b's elements. + + Ok(()) + } +} + +/// Error that can happen when the interface mismatches between two shader stages. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ShaderInterfaceMismatchError { + /// The number of elements is not the same between the two shader interfaces. + ElementsCountMismatch { + /// Number of elements in the first interface. + self_elements: u32, + /// Number of elements in the second interface. + other_elements: u32, + }, + + /// An element is missing from one of the interfaces. + MissingElement { + /// Location of the missing element. + location: u32, + }, + + /// The format of an element does not match. + FormatMismatch { + /// Location of the element that mismatches. + location: u32, + /// Format in the first interface. + self_format: Format, + /// Format in the second interface. + other_format: Format + }, +} + +impl error::Error for ShaderInterfaceMismatchError { + #[inline] + fn description(&self) -> &str { + match *self { + ShaderInterfaceMismatchError::ElementsCountMismatch { .. } => { + "the number of elements mismatches" + }, + ShaderInterfaceMismatchError::MissingElement { .. } => { + "an element is missing" + }, + ShaderInterfaceMismatchError::FormatMismatch { .. } => { + "the format of an element does not match" + }, + } + } +} + +impl fmt::Display for ShaderInterfaceMismatchError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +/// Trait for types that contain specialization data for shaders. +/// +/// Shader modules can contain what is called *specialization constants*. They are the same as +/// constants except that their values can be defined when you create a compute pipeline or a +/// graphics pipeline. Doing so is done by passing a type that implements the +/// `SpecializationConstants` trait and that stores the values in question. The `descriptors()` +/// method of this trait indicates how to grab them. +/// +/// Boolean specialization constants must be stored as 32bits integers, where `0` means `false` and +/// any non-zero value means `true`. Integer and floating-point specialization constants are +/// stored as their Rust equivalent. +/// +/// This trait is implemented on `()` for shaders that don't have any specialization constant. +/// +/// Note that it is the shader module that chooses which type that implements +/// `SpecializationConstants` it is possible to pass when creating the pipeline, through [the +/// `EntryPointAbstract` trait](trait.EntryPointAbstract.html). Therefore there is generally no +/// point to implement this trait yourself, unless you are also writing your own implementation of +/// `EntryPointAbstract`. +/// +/// # Example +/// +/// ```rust +/// use vulkano::pipeline::shader::SpecializationConstants; +/// use vulkano::pipeline::shader::SpecializationMapEntry; +/// +/// #[repr(C)] // `#[repr(C)]` guarantees that the struct has a specific layout +/// struct MySpecConstants { +/// my_integer_constant: i32, +/// a_boolean: u32, +/// floating_point: f32, +/// } +/// +/// unsafe impl SpecializationConstants for MySpecConstants { +/// fn descriptors() -> &'static [SpecializationMapEntry] { +/// static DESCRIPTORS: [SpecializationMapEntry; 3] = [ +/// SpecializationMapEntry { +/// constant_id: 0, +/// offset: 0, +/// size: 4, +/// }, +/// SpecializationMapEntry { +/// constant_id: 1, +/// offset: 4, +/// size: 4, +/// }, +/// SpecializationMapEntry { +/// constant_id: 2, +/// offset: 8, +/// size: 4, +/// }, +/// ]; +/// +/// &DESCRIPTORS +/// } +/// } +/// ``` +/// +/// # Safety +/// +/// - The `SpecializationMapEntry` returned must contain valid offsets and sizes. +/// - The size of each `SpecializationMapEntry` must match the size of the corresponding constant +/// (`4` for booleans). +/// +pub unsafe trait SpecializationConstants { + /// Returns descriptors of the struct's layout. + fn descriptors() -> &'static [SpecializationMapEntry]; +} + +unsafe impl SpecializationConstants for () { + #[inline] + fn descriptors() -> &'static [SpecializationMapEntry] { + &[] + } +} + +/// Describes an individual constant to set in the shader. Also a field in the struct. +// Implementation note: has the same memory representation as a `VkSpecializationMapEntry`. +#[repr(C)] +pub struct SpecializationMapEntry { + /// Identifier of the constant in the shader that corresponds to this field. + /// + /// For SPIR-V, this must be the value of the `SpecId` decoration applied to the specialization + /// constant. + /// For GLSL, this must be the value of `N` in the `layout(constant_id = N)` attribute applied + /// to a constant. + pub constant_id: u32, + + /// Offset within the struct where the data can be found. + pub offset: u32, + + /// Size of the data in bytes. Must match the size of the constant (`4` for booleans). + pub size: usize, +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/bufferless.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/bufferless.rs new file mode 100644 index 0000000..4d718c7 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/bufferless.rs @@ -0,0 +1,56 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::iter; + +use buffer::BufferAccess; +use pipeline::vertex::AttributeInfo; +use pipeline::vertex::IncompatibleVertexDefinitionError; +use pipeline::vertex::InputRate; +use pipeline::vertex::VertexDefinition; +use pipeline::vertex::VertexSource; + +/// Implementation of `VertexDefinition` for drawing with no buffers at all. +/// +/// This is only useful if your shaders come up with vertex data on their own, e.g. by inspecting +/// `gl_VertexIndex` +pub struct BufferlessDefinition; + +/// Value to be passed as the vertex source for bufferless draw commands. +/// +/// Note that the concrete type of the graphics pipeline using `BufferlessDefinition` must be +/// visible to the command buffer builder for this to be usable. +pub struct BufferlessVertices { + pub vertices: usize, + pub instances: usize, +} + +unsafe impl VertexSource<BufferlessVertices> for BufferlessDefinition { + fn decode(&self, n: BufferlessVertices) + -> (Vec<Box<BufferAccess + Sync + Send + 'static>>, usize, usize) { + (Vec::new(), n.vertices, n.instances) + } +} + +unsafe impl<T> VertexSource<Vec<T>> for BufferlessDefinition { + fn decode<'l>(&self, _: Vec<T>) + -> (Vec<Box<BufferAccess + Sync + Send + 'static>>, usize, usize) { + panic!("bufferless drawing should not be supplied with buffers") + } +} + +unsafe impl<I> VertexDefinition<I> for BufferlessDefinition { + type BuffersIter = iter::Empty<(u32, usize, InputRate)>; + type AttribsIter = iter::Empty<(u32, u32, AttributeInfo)>; + fn definition( + &self, _: &I) + -> Result<(Self::BuffersIter, Self::AttribsIter), IncompatibleVertexDefinitionError> { + Ok((iter::empty(), iter::empty())) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/definition.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/definition.rs new file mode 100644 index 0000000..12fe672 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/definition.rs @@ -0,0 +1,128 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::sync::Arc; + +use SafeDeref; +use buffer::BufferAccess; +use format::Format; +use pipeline::vertex::VertexMemberTy; +use vk; + +/// Trait for types that describe the definition of the vertex input used by a graphics pipeline. +pub unsafe trait VertexDefinition<I> + : VertexSource<Vec<Arc<BufferAccess + Send + Sync>>> { + /// Iterator that returns the offset, the stride (in bytes) and input rate of each buffer. + type BuffersIter: ExactSizeIterator<Item = (u32, usize, InputRate)>; + /// Iterator that returns the attribute location, buffer id, and infos. + type AttribsIter: ExactSizeIterator<Item = (u32, u32, AttributeInfo)>; + + /// Builds the vertex definition to use to link this definition to a vertex shader's input + /// interface. + fn definition( + &self, interface: &I) + -> Result<(Self::BuffersIter, Self::AttribsIter), IncompatibleVertexDefinitionError>; +} + +unsafe impl<I, T> VertexDefinition<I> for T + where T: SafeDeref, + T::Target: VertexDefinition<I> +{ + type BuffersIter = <T::Target as VertexDefinition<I>>::BuffersIter; + type AttribsIter = <T::Target as VertexDefinition<I>>::AttribsIter; + + #[inline] + fn definition( + &self, interface: &I) + -> Result<(Self::BuffersIter, Self::AttribsIter), IncompatibleVertexDefinitionError> { + (**self).definition(interface) + } +} + +/// How the vertex source should be unrolled. +#[derive(Copy, Clone, Debug)] +#[repr(u32)] +pub enum InputRate { + /// Each element of the source corresponds to a vertex. + Vertex = vk::VERTEX_INPUT_RATE_VERTEX, + /// Each element of the source corresponds to an instance. + Instance = vk::VERTEX_INPUT_RATE_INSTANCE, +} + +/// Information about a single attribute within a vertex. +/// TODO: change that API +#[derive(Copy, Clone, Debug)] +pub struct AttributeInfo { + /// Number of bytes between the start of a vertex and the location of attribute. + pub offset: usize, + /// VertexMember type of the attribute. + pub format: Format, +} + +/// Error that can happen when the vertex definition doesn't match the input of the vertex shader. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum IncompatibleVertexDefinitionError { + /// An attribute of the vertex shader is missing in the vertex source. + MissingAttribute { + /// Name of the missing attribute. + attribute: String, + }, + + /// The format of an attribute does not match. + FormatMismatch { + /// Name of the attribute. + attribute: String, + /// The format in the vertex shader. + shader: (Format, usize), + /// The format in the vertex definition. + definition: (VertexMemberTy, usize), + }, +} + +impl error::Error for IncompatibleVertexDefinitionError { + #[inline] + fn description(&self) -> &str { + match *self { + IncompatibleVertexDefinitionError::MissingAttribute { .. } => "an attribute is missing", + IncompatibleVertexDefinitionError::FormatMismatch { .. } => { + "the format of an attribute does not match" + }, + } + } +} + +impl fmt::Display for IncompatibleVertexDefinitionError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + + +/// Extension trait of `VertexDefinition`. The `L` parameter is an acceptable vertex source for this +/// vertex definition. +pub unsafe trait VertexSource<L> { + /// Checks and returns the list of buffers with offsets, number of vertices and number of instances. + // TODO: return error if problem + // TODO: better than a Vec + // TODO: return a struct instead + fn decode(&self, L) -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize); +} + +unsafe impl<L, T> VertexSource<L> for T + where T: SafeDeref, + T::Target: VertexSource<L> +{ + #[inline] + fn decode(&self, list: L) -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) { + (**self).decode(list) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/impl_vertex.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/impl_vertex.rs new file mode 100644 index 0000000..0077a92 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/impl_vertex.rs @@ -0,0 +1,188 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use pipeline::vertex::VertexMemberTy; + +/// Implements the `Vertex` trait on a struct. +// TODO: add example +#[macro_export] +macro_rules! impl_vertex { + ($out:ty $(, $member:ident)*) => ( + #[allow(unsafe_code)] + unsafe impl $crate::pipeline::vertex::Vertex for $out { + #[inline(always)] + fn member(name: &str) -> Option<$crate::pipeline::vertex::VertexMemberInfo> { + use std::ptr; + #[allow(unused_imports)] + use $crate::format::Format; + use $crate::pipeline::vertex::VertexMemberInfo; + use $crate::pipeline::vertex::VertexMemberTy; + use $crate::pipeline::vertex::VertexMember; + + $( + if name == stringify!($member) { + let (ty, array_size) = unsafe { + #[inline] fn f<T: VertexMember>(_: &T) -> (VertexMemberTy, usize) + { T::format() } + let dummy: *const $out = ptr::null(); + f(&(&*dummy).$member) + }; + + return Some(VertexMemberInfo { + offset: unsafe { + let dummy: *const $out = ptr::null(); + let member = (&(&*dummy).$member) as *const _; + member as usize + }, + + ty: ty, + array_size: array_size, + }); + } + )* + + None + } + } + ) +} + +/// Trait for data types that can be used as vertex members. Used by the `impl_vertex!` macro. +pub unsafe trait VertexMember { + /// Returns the format and array size of the member. + fn format() -> (VertexMemberTy, usize); +} + +unsafe impl VertexMember for i8 { + #[inline] + fn format() -> (VertexMemberTy, usize) { + (VertexMemberTy::I8, 1) + } +} + +unsafe impl VertexMember for u8 { + #[inline] + fn format() -> (VertexMemberTy, usize) { + (VertexMemberTy::U8, 1) + } +} + +unsafe impl VertexMember for i16 { + #[inline] + fn format() -> (VertexMemberTy, usize) { + (VertexMemberTy::I16, 1) + } +} + +unsafe impl VertexMember for u16 { + #[inline] + fn format() -> (VertexMemberTy, usize) { + (VertexMemberTy::U16, 1) + } +} + +unsafe impl VertexMember for i32 { + #[inline] + fn format() -> (VertexMemberTy, usize) { + (VertexMemberTy::I32, 1) + } +} + +unsafe impl VertexMember for u32 { + #[inline] + fn format() -> (VertexMemberTy, usize) { + (VertexMemberTy::U32, 1) + } +} + +unsafe impl VertexMember for f32 { + #[inline] + fn format() -> (VertexMemberTy, usize) { + (VertexMemberTy::F32, 1) + } +} + +unsafe impl VertexMember for f64 { + #[inline] + fn format() -> (VertexMemberTy, usize) { + (VertexMemberTy::F64, 1) + } +} + +unsafe impl<T> VertexMember for (T,) + where T: VertexMember +{ + #[inline] + fn format() -> (VertexMemberTy, usize) { + <T as VertexMember>::format() + } +} + +unsafe impl<T> VertexMember for (T, T) + where T: VertexMember +{ + #[inline] + fn format() -> (VertexMemberTy, usize) { + let (ty, sz) = <T as VertexMember>::format(); + (ty, sz * 2) + } +} + +unsafe impl<T> VertexMember for (T, T, T) + where T: VertexMember +{ + #[inline] + fn format() -> (VertexMemberTy, usize) { + let (ty, sz) = <T as VertexMember>::format(); + (ty, sz * 3) + } +} + +unsafe impl<T> VertexMember for (T, T, T, T) + where T: VertexMember +{ + #[inline] + fn format() -> (VertexMemberTy, usize) { + let (ty, sz) = <T as VertexMember>::format(); + (ty, sz * 4) + } +} + +macro_rules! impl_vm_array { + ($sz:expr) => ( + unsafe impl<T> VertexMember for [T; $sz] + where T: VertexMember + { + #[inline] + fn format() -> (VertexMemberTy, usize) { + let (ty, sz) = <T as VertexMember>::format(); + (ty, sz * $sz) + } + } + ); +} + +impl_vm_array!(1); +impl_vm_array!(2); +impl_vm_array!(3); +impl_vm_array!(4); +impl_vm_array!(5); +impl_vm_array!(6); +impl_vm_array!(7); +impl_vm_array!(8); +impl_vm_array!(9); +impl_vm_array!(10); +impl_vm_array!(11); +impl_vm_array!(12); +impl_vm_array!(13); +impl_vm_array!(14); +impl_vm_array!(15); +impl_vm_array!(16); +impl_vm_array!(32); +impl_vm_array!(64); diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/instance_buffer.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/instance_buffer.rs new file mode 100644 index 0000000..70b4947 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/instance_buffer.rs @@ -0,0 +1,122 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::marker::PhantomData; +use std::mem; +use std::option::IntoIter as OptionIntoIter; +use std::sync::Arc; +use std::vec::IntoIter as VecIntoIter; + +use buffer::BufferAccess; +use buffer::TypedBufferAccess; +use pipeline::shader::ShaderInterfaceDef; +use pipeline::vertex::AttributeInfo; +use pipeline::vertex::IncompatibleVertexDefinitionError; +use pipeline::vertex::InputRate; +use pipeline::vertex::Vertex; +use pipeline::vertex::VertexDefinition; +use pipeline::vertex::VertexSource; + +/// Same as `SingleBufferDefinition` but advances by instance. +pub struct SingleInstanceBufferDefinition<T>(pub PhantomData<T>); + +impl<T> SingleInstanceBufferDefinition<T> { + #[inline] + pub fn new() -> SingleInstanceBufferDefinition<T> { + SingleInstanceBufferDefinition(PhantomData) + } +} + +unsafe impl<T, I> VertexDefinition<I> for SingleInstanceBufferDefinition<T> +where + T: Vertex, + I: ShaderInterfaceDef, +{ + type BuffersIter = OptionIntoIter<(u32, usize, InputRate)>; + type AttribsIter = VecIntoIter<(u32, u32, AttributeInfo)>; + + fn definition( + &self, + interface: &I, + ) -> Result<(Self::BuffersIter, Self::AttribsIter), IncompatibleVertexDefinitionError> { + let attrib = { + let mut attribs = Vec::with_capacity(interface.elements().len()); + for e in interface.elements() { + let name = e.name.as_ref().unwrap(); + + let infos = match <T as Vertex>::member(name) { + Some(m) => m, + None => { + return Err(IncompatibleVertexDefinitionError::MissingAttribute { + attribute: name.clone().into_owned(), + }) + } + }; + + if !infos.ty.matches( + infos.array_size, + e.format, + e.location.end - e.location.start, + ) { + return Err(IncompatibleVertexDefinitionError::FormatMismatch { + attribute: name.clone().into_owned(), + shader: (e.format, (e.location.end - e.location.start) as usize), + definition: (infos.ty, infos.array_size), + }); + } + + let mut offset = infos.offset; + for loc in e.location.clone() { + attribs.push(( + loc, + 0, + AttributeInfo { + offset: offset, + format: e.format, + }, + )); + offset += e.format.size().unwrap(); + } + } + attribs + }.into_iter(); // TODO: meh + + let buffers = Some((0, mem::size_of::<T>(), InputRate::Instance)).into_iter(); + Ok((buffers, attrib)) + } +} + +unsafe impl<V> VertexSource<Vec<Arc<BufferAccess + Send + Sync>>> + for SingleInstanceBufferDefinition<V> +where + V: Vertex, +{ + #[inline] + fn decode( + &self, + mut source: Vec<Arc<BufferAccess + Send + Sync>>, + ) -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) { + // FIXME: safety + assert_eq!(source.len(), 1); + let len = source[0].size() / mem::size_of::<V>(); + (vec![Box::new(source.remove(0))], 1, len) + } +} + +unsafe impl<'a, B, V> VertexSource<B> for SingleInstanceBufferDefinition<V> +where + B: TypedBufferAccess<Content = [V]> + Send + Sync + 'static, + V: Vertex, +{ + #[inline] + fn decode(&self, source: B) -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) { + let len = source.len(); + (vec![Box::new(source) as Box<_>], 1, len) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/mod.rs new file mode 100644 index 0000000..36c11c1 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/mod.rs @@ -0,0 +1,89 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! # Vertex sources definition +//! +//! When you create a graphics pipeline object, you need to pass an object which indicates the +//! layout of the vertex buffer(s) that will serve as input for the vertex shader. This is done +//! by passing an implementation of the `VertexDefinition` trait. +//! +//! In addition to this, the object that you pass when you create the graphics pipeline must also +//! implement the `VertexSource` trait. This trait has a template parameter which corresponds to the +//! list of vertex buffers. +//! +//! The vulkano library provides some structs that already implement these traits. +//! The most common situation is a single vertex buffer and no instancing, in which case you can +//! pass a `SingleBufferDefinition` when you create the pipeline. +//! +//! # Implementing `Vertex` +//! +//! The implementations of the `VertexDefinition` trait that are provided by vulkano (like +//! `SingleBufferDefinition`) require you to use a buffer whose content is `[V]` where `V` +//! implements the `Vertex` trait. +//! +//! The `Vertex` trait is unsafe, but can be implemented on a struct with the `impl_vertex!` +//! macro. +//! +//! # Example +//! +//! ```ignore // TODO: +//! # #[macro_use] extern crate vulkano +//! # fn main() { +//! # use std::sync::Arc; +//! # use vulkano::device::Device; +//! # use vulkano::device::Queue; +//! use vulkano::buffer::BufferAccess; +//! use vulkano::buffer::BufferUsage; +//! use vulkano::memory::HostVisible; +//! use vulkano::pipeline::vertex::; +//! # let device: Arc<Device> = return; +//! # let queue: Arc<Queue> = return; +//! +//! struct Vertex { +//! position: [f32; 2] +//! } +//! +//! impl_vertex!(Vertex, position); +//! +//! let usage = BufferUsage { +//! vertex_buffer: true, +//! .. BufferUsage::none() +//! }; +//! +//! let vertex_buffer = BufferAccess::<[Vertex], _>::array(&device, 128, &usage, HostVisible, &queue) +//! .expect("failed to create buffer"); +//! +//! // TODO: finish example +//! # } +//! ``` + +pub use self::bufferless::BufferlessDefinition; +pub use self::bufferless::BufferlessVertices; +pub use self::definition::AttributeInfo; +pub use self::definition::IncompatibleVertexDefinitionError; +pub use self::definition::InputRate; +pub use self::definition::VertexDefinition; +pub use self::definition::VertexSource; +pub use self::impl_vertex::VertexMember; +pub use self::instance_buffer::SingleInstanceBufferDefinition; +pub use self::one_one::OneVertexOneInstanceDefinition; +pub use self::single::SingleBufferDefinition; +pub use self::two::TwoBuffersDefinition; +pub use self::vertex::Vertex; +pub use self::vertex::VertexMemberInfo; +pub use self::vertex::VertexMemberTy; + +mod bufferless; +mod definition; +mod impl_vertex; +mod instance_buffer; +mod one_one; +mod single; +mod two; +mod vertex; diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/one_one.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/one_one.rs new file mode 100644 index 0000000..ce00a44 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/one_one.rs @@ -0,0 +1,126 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::marker::PhantomData; +use std::mem; +use std::sync::Arc; +use std::vec::IntoIter as VecIntoIter; + +use buffer::BufferAccess; +use buffer::TypedBufferAccess; +use pipeline::shader::ShaderInterfaceDef; +use pipeline::vertex::AttributeInfo; +use pipeline::vertex::IncompatibleVertexDefinitionError; +use pipeline::vertex::InputRate; +use pipeline::vertex::Vertex; +use pipeline::vertex::VertexDefinition; +use pipeline::vertex::VertexSource; + +/// Unstable. +// TODO: bad way to do things +pub struct OneVertexOneInstanceDefinition<T, U>(pub PhantomData<(T, U)>); + +impl<T, U> OneVertexOneInstanceDefinition<T, U> { + #[inline] + pub fn new() -> OneVertexOneInstanceDefinition<T, U> { + OneVertexOneInstanceDefinition(PhantomData) + } +} + +unsafe impl<T, U, I> VertexDefinition<I> for OneVertexOneInstanceDefinition<T, U> + where T: Vertex, + U: Vertex, + I: ShaderInterfaceDef +{ + type BuffersIter = VecIntoIter<(u32, usize, InputRate)>; + type AttribsIter = VecIntoIter<(u32, u32, AttributeInfo)>; + + fn definition( + &self, interface: &I) + -> Result<(Self::BuffersIter, Self::AttribsIter), IncompatibleVertexDefinitionError> { + let attrib = { + let mut attribs = Vec::with_capacity(interface.elements().len()); + for e in interface.elements() { + let name = e.name.as_ref().unwrap(); + + let (infos, buf_offset) = if let Some(infos) = <T as Vertex>::member(name) { + (infos, 0) + } else if let Some(infos) = <U as Vertex>::member(name) { + (infos, 1) + } else { + return Err(IncompatibleVertexDefinitionError::MissingAttribute { + attribute: name.clone().into_owned(), + }); + }; + + if !infos.ty.matches(infos.array_size, + e.format, + e.location.end - e.location.start) + { + return Err(IncompatibleVertexDefinitionError::FormatMismatch { + attribute: name.clone().into_owned(), + shader: (e.format, (e.location.end - e.location.start) as usize), + definition: (infos.ty, infos.array_size), + }); + } + + let mut offset = infos.offset; + for loc in e.location.clone() { + attribs.push((loc, + buf_offset, + AttributeInfo { + offset: offset, + format: e.format, + })); + offset += e.format.size().unwrap(); + } + } + attribs + }.into_iter(); // TODO: meh + + let buffers = vec![ + (0, mem::size_of::<T>(), InputRate::Vertex), + (1, mem::size_of::<U>(), InputRate::Instance), + ].into_iter(); + + Ok((buffers, attrib)) + } +} + +unsafe impl<T, U> VertexSource<Vec<Arc<BufferAccess + Send + Sync>>> + for OneVertexOneInstanceDefinition<T, U> + where T: Vertex, + U: Vertex +{ + #[inline] + fn decode(&self, mut source: Vec<Arc<BufferAccess + Send + Sync>>) + -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) { + // FIXME: safety + assert_eq!(source.len(), 2); + let len = source[0].size() / mem::size_of::<T>(); + let inst = source[1].size() / mem::size_of::<U>(); + let s0 = source.remove(0); + let s1 = source.remove(0); + (vec![Box::new(s0) as Box<_>, Box::new(s1) as Box<_>], len, inst) + } +} + +unsafe impl<'a, T, U, Bt, Bu> VertexSource<(Bt, Bu)> for OneVertexOneInstanceDefinition<T, U> + where T: Vertex, + Bt: TypedBufferAccess<Content = [T]> + Send + Sync + 'static, + U: Vertex, + Bu: TypedBufferAccess<Content = [U]> + Send + Sync + 'static +{ + #[inline] + fn decode(&self, source: (Bt, Bu)) -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) { + let s1l = source.0.len(); + let s2l = source.1.len(); + (vec![Box::new(source.0) as Box<_>, Box::new(source.1) as Box<_>], s1l, s2l) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/single.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/single.rs new file mode 100644 index 0000000..e56ab26 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/single.rs @@ -0,0 +1,110 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::marker::PhantomData; +use std::mem; +use std::option::IntoIter as OptionIntoIter; +use std::sync::Arc; +use std::vec::IntoIter as VecIntoIter; + +use buffer::BufferAccess; +use buffer::TypedBufferAccess; +use pipeline::shader::ShaderInterfaceDef; +use pipeline::vertex::AttributeInfo; +use pipeline::vertex::IncompatibleVertexDefinitionError; +use pipeline::vertex::InputRate; +use pipeline::vertex::Vertex; +use pipeline::vertex::VertexDefinition; +use pipeline::vertex::VertexSource; + +/// Implementation of `VertexDefinition` for a single vertex buffer. +pub struct SingleBufferDefinition<T>(pub PhantomData<T>); + +impl<T> SingleBufferDefinition<T> { + #[inline] + pub fn new() -> SingleBufferDefinition<T> { + SingleBufferDefinition(PhantomData) + } +} + +unsafe impl<T, I> VertexDefinition<I> for SingleBufferDefinition<T> + where T: Vertex, + I: ShaderInterfaceDef +{ + type BuffersIter = OptionIntoIter<(u32, usize, InputRate)>; + type AttribsIter = VecIntoIter<(u32, u32, AttributeInfo)>; + + fn definition( + &self, interface: &I) + -> Result<(Self::BuffersIter, Self::AttribsIter), IncompatibleVertexDefinitionError> { + let attrib = { + let mut attribs = Vec::with_capacity(interface.elements().len()); + for e in interface.elements() { + let name = e.name.as_ref().unwrap(); + + let infos = match <T as Vertex>::member(name) { + Some(m) => m, + None => return Err(IncompatibleVertexDefinitionError::MissingAttribute { + attribute: name.clone().into_owned(), + }), + }; + + if !infos.ty.matches(infos.array_size, + e.format, + e.location.end - e.location.start) + { + return Err(IncompatibleVertexDefinitionError::FormatMismatch { + attribute: name.clone().into_owned(), + shader: (e.format, (e.location.end - e.location.start) as usize), + definition: (infos.ty, infos.array_size), + }); + } + + let mut offset = infos.offset; + for loc in e.location.clone() { + attribs.push((loc, + 0, + AttributeInfo { + offset: offset, + format: e.format, + })); + offset += e.format.size().unwrap(); + } + } + attribs + }.into_iter(); // TODO: meh + + let buffers = Some((0, mem::size_of::<T>(), InputRate::Vertex)).into_iter(); + Ok((buffers, attrib)) + } +} + +unsafe impl<V> VertexSource<Vec<Arc<BufferAccess + Send + Sync>>> for SingleBufferDefinition<V> + where V: Vertex +{ + #[inline] + fn decode(&self, mut source: Vec<Arc<BufferAccess + Send + Sync>>) + -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) { + // FIXME: safety + assert_eq!(source.len(), 1); + let len = source[0].size() / mem::size_of::<V>(); + (vec![Box::new(source.remove(0))], len, 1) + } +} + +unsafe impl<'a, B, V> VertexSource<B> for SingleBufferDefinition<V> + where B: TypedBufferAccess<Content = [V]> + Send + Sync + 'static, + V: Vertex +{ + #[inline] + fn decode(&self, source: B) -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) { + let len = source.len(); + (vec![Box::new(source) as Box<_>], len, 1) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/two.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/two.rs new file mode 100644 index 0000000..3c48eff --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/two.rs @@ -0,0 +1,131 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::marker::PhantomData; +use std::mem; +use std::sync::Arc; +use std::vec::IntoIter as VecIntoIter; + +use buffer::BufferAccess; +use buffer::TypedBufferAccess; +use pipeline::shader::ShaderInterfaceDef; +use pipeline::vertex::AttributeInfo; +use pipeline::vertex::IncompatibleVertexDefinitionError; +use pipeline::vertex::InputRate; +use pipeline::vertex::Vertex; +use pipeline::vertex::VertexDefinition; +use pipeline::vertex::VertexSource; + +/// Unstable. +// TODO: shouldn't be just `Two` but `Multi` +pub struct TwoBuffersDefinition<T, U>(pub PhantomData<(T, U)>); + +impl<T, U> TwoBuffersDefinition<T, U> { + #[inline] + pub fn new() -> TwoBuffersDefinition<T, U> { + TwoBuffersDefinition(PhantomData) + } +} + +unsafe impl<T, U, I> VertexDefinition<I> for TwoBuffersDefinition<T, U> + where T: Vertex, + U: Vertex, + I: ShaderInterfaceDef +{ + type BuffersIter = VecIntoIter<(u32, usize, InputRate)>; + type AttribsIter = VecIntoIter<(u32, u32, AttributeInfo)>; + + fn definition( + &self, interface: &I) + -> Result<(Self::BuffersIter, Self::AttribsIter), IncompatibleVertexDefinitionError> { + let attrib = { + let mut attribs = Vec::with_capacity(interface.elements().len()); + for e in interface.elements() { + let name = e.name.as_ref().unwrap(); + + let (infos, buf_offset) = if let Some(infos) = <T as Vertex>::member(name) { + (infos, 0) + } else if let Some(infos) = <U as Vertex>::member(name) { + (infos, 1) + } else { + return Err(IncompatibleVertexDefinitionError::MissingAttribute { + attribute: name.clone().into_owned(), + }); + }; + + if !infos.ty.matches(infos.array_size, + e.format, + e.location.end - e.location.start) + { + return Err(IncompatibleVertexDefinitionError::FormatMismatch { + attribute: name.clone().into_owned(), + shader: (e.format, (e.location.end - e.location.start) as usize), + definition: (infos.ty, infos.array_size), + }); + } + + let mut offset = infos.offset; + for loc in e.location.clone() { + attribs.push((loc, + buf_offset, + AttributeInfo { + offset: offset, + format: e.format, + })); + offset += e.format.size().unwrap(); + } + } + attribs + }.into_iter(); // TODO: meh + + let buffers = vec![ + (0, mem::size_of::<T>(), InputRate::Vertex), + (1, mem::size_of::<U>(), InputRate::Vertex), + ].into_iter(); + + Ok((buffers, attrib)) + } +} + +unsafe impl<T, U> VertexSource<Vec<Arc<BufferAccess + Send + Sync>>> for TwoBuffersDefinition<T, U> + where T: Vertex, + U: Vertex +{ + #[inline] + fn decode(&self, source: Vec<Arc<BufferAccess + Send + Sync>>) + -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) { + // FIXME: safety + assert_eq!(source.len(), 2); + let vertices = [ + source[0].size() / mem::size_of::<T>(), + source[1].size() / mem::size_of::<U>(), + ].iter() + .cloned() + .min() + .unwrap(); + (vec![Box::new(source[0].clone()), Box::new(source[1].clone())], vertices, 1) + } +} + +unsafe impl<'a, T, U, Bt, Bu> VertexSource<(Bt, Bu)> for TwoBuffersDefinition<T, U> + where T: Vertex, + Bt: TypedBufferAccess<Content = [T]> + Send + Sync + 'static, + U: Vertex, + Bu: TypedBufferAccess<Content = [U]> + Send + Sync + 'static +{ + #[inline] + fn decode(&self, source: (Bt, Bu)) -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) { + let vertices = [source.0.len(), source.1.len()] + .iter() + .cloned() + .min() + .unwrap(); + (vec![Box::new(source.0) as Box<_>, Box::new(source.1) as Box<_>], vertices, 1) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/vertex.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/vertex.rs new file mode 100644 index 0000000..8ac4a10 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/vertex/vertex.rs @@ -0,0 +1,76 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use format::Format; + +/// Describes an individual `Vertex`. In other words a collection of attributes that can be read +/// from a vertex shader. +/// +/// At this stage, the vertex is in a "raw" format. For example a `[f32; 4]` can match both a +/// `vec4` or a `float[4]`. The way the things are bound depends on the shader. +pub unsafe trait Vertex: 'static + Send + Sync { + /// Returns the characteristics of a vertex member by its name. + fn member(name: &str) -> Option<VertexMemberInfo>; +} + +unsafe impl Vertex for () { + #[inline] + fn member(_: &str) -> Option<VertexMemberInfo> { + None + } +} + +/// Information about a member of a vertex struct. +pub struct VertexMemberInfo { + /// Offset of the member in bytes from the start of the struct. + pub offset: usize, + /// Type of data. This is used to check that the interface is matching. + pub ty: VertexMemberTy, + /// Number of consecutive elements of that type. + pub array_size: usize, +} + +/// Type of a member of a vertex struct. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[allow(missing_docs)] +pub enum VertexMemberTy { + I8, + U8, + I16, + U16, + I32, + U32, + F32, + F64, +} + +impl VertexMemberTy { + /// Returns true if a combination of `(type, array_size)` matches a format. + #[inline] + pub fn matches(&self, array_size: usize, format: Format, num_locs: u32) -> bool { + // TODO: implement correctly + let my_size = match *self { + VertexMemberTy::I8 => 1, + VertexMemberTy::U8 => 1, + VertexMemberTy::I16 => 2, + VertexMemberTy::U16 => 2, + VertexMemberTy::I32 => 4, + VertexMemberTy::U32 => 4, + VertexMemberTy::F32 => 4, + VertexMemberTy::F64 => 8, + }; + + let format_size = match format.size() { + None => return false, + Some(s) => s, + }; + + array_size * my_size == format_size * num_locs as usize + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/viewport.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/viewport.rs new file mode 100644 index 0000000..a9189ba --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/pipeline/viewport.rs @@ -0,0 +1,201 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Viewports and scissor boxes. +//! +//! There are two different concepts to determine where things will be drawn: +//! +//! - The viewport is the region of the image which corresponds to the +//! vertex coordinates `-1.0` to `1.0`. +//! - Any pixel outside of the scissor box will be discarded. +//! +//! In other words modifying the viewport will stretch the image, while modifying the scissor +//! box acts like a filter. +//! +//! It is legal and sensible to use a viewport that is larger than the target image or that +//! only partially overlaps the target image. +//! +//! # Multiple viewports +//! +//! In most situations, you only need a single viewport and a single scissor box. +//! +//! If, however, you use a geometry shader, you can specify multiple viewports and scissor boxes. +//! Then in your geometry shader you can specify in which viewport and scissor box the primitive +//! should be written to. In GLSL this is done by writing to the special variable +//! `gl_ViewportIndex`. +//! +//! If you don't use a geometry shader or use a geometry shader where don't set which viewport to +//! use, then the first viewport and scissor box will be used. +//! +//! # Dynamic and fixed +//! +//! Vulkan allows four different setups: +//! +//! - The state of both the viewports and scissor boxes is known at pipeline creation. +//! - The state of viewports is known at pipeline creation, but the state of scissor boxes is +//! only known when submitting the draw command. +//! - The state of scissor boxes is known at pipeline creation, but the state of viewports is +//! only known when submitting the draw command. +//! - The state of both the viewports and scissor boxes is only known when submitting the +//! draw command. +//! +//! In all cases the number of viewports and scissor boxes must be the same. +//! + +use std::ops::Range; +use vk; + +/// List of viewports and scissors that are used when creating a graphics pipeline object. +/// +/// Note that the number of viewports and scissors must be the same. +#[derive(Debug, Clone)] +pub enum ViewportsState { + /// The state is known in advance. + Fixed { + /// State of the viewports and scissors. + data: Vec<(Viewport, Scissor)>, + }, + + /// The state of scissors is known in advance, but the state of viewports is dynamic and will + /// bet set when drawing. + /// + /// Note that the number of viewports and scissors must be the same. + DynamicViewports { + /// State of the scissors. + scissors: Vec<Scissor>, + }, + + /// The state of viewports is known in advance, but the state of scissors is dynamic and will + /// bet set when drawing. + /// + /// Note that the number of viewports and scissors must be the same. + DynamicScissors { + /// State of the viewports + viewports: Vec<Viewport>, + }, + + /// The state of both the viewports and scissors is dynamic and will be set when drawing. + Dynamic { + /// Number of viewports and scissors. + num: u32, + }, +} + +impl ViewportsState { + /// Returns true if the state of the viewports is dynamic. + pub fn dynamic_viewports(&self) -> bool { + match *self { + ViewportsState::Fixed { .. } => false, + ViewportsState::DynamicViewports { .. } => true, + ViewportsState::DynamicScissors { .. } => false, + ViewportsState::Dynamic { .. } => true, + } + } + + /// Returns true if the state of the scissors is dynamic. + pub fn dynamic_scissors(&self) -> bool { + match *self { + ViewportsState::Fixed { .. } => false, + ViewportsState::DynamicViewports { .. } => false, + ViewportsState::DynamicScissors { .. } => true, + ViewportsState::Dynamic { .. } => true, + } + } + + /// Returns the number of viewports and scissors. + pub fn num_viewports(&self) -> u32 { + match *self { + ViewportsState::Fixed { ref data } => data.len() as u32, + ViewportsState::DynamicViewports { ref scissors } => scissors.len() as u32, + ViewportsState::DynamicScissors { ref viewports } => viewports.len() as u32, + ViewportsState::Dynamic { num } => num, + } + } +} + +/// State of a single viewport. +// FIXME: check that: +// x + width must be less than or equal to viewportBoundsRange[0] +// y + height must be less than or equal to viewportBoundsRange[1] +#[derive(Debug, Clone, PartialEq)] +pub struct Viewport { + /// Coordinates in pixels of the top-left hand corner of the viewport. + pub origin: [f32; 2], + + /// Dimensions in pixels of the viewport. + pub dimensions: [f32; 2], + + /// Minimum and maximum values of the depth. + /// + /// The values `0.0` to `1.0` of each vertex's Z coordinate will be mapped to this + /// `depth_range` before being compared to the existing depth value. + /// + /// This is equivalents to `glDepthRange` in OpenGL, except that OpenGL uses the Z coordinate + /// range from `-1.0` to `1.0` instead. + pub depth_range: Range<f32>, +} + +impl Viewport { + #[inline] + pub(crate) fn into_vulkan_viewport(self) -> vk::Viewport { + vk::Viewport { + x: self.origin[0], + y: self.origin[1], + width: self.dimensions[0], + height: self.dimensions[1], + minDepth: self.depth_range.start, + maxDepth: self.depth_range.end, + } + } +} + +/// State of a single scissor box. +// FIXME: add a check: +// Evaluation of (offset.x + extent.width) must not cause a signed integer addition overflow +// Evaluation of (offset.y + extent.height) must not cause a signed integer addition overflow +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct Scissor { + /// Coordinates in pixels of the top-left hand corner of the box. + pub origin: [i32; 2], + + /// Dimensions in pixels of the box. + pub dimensions: [u32; 2], +} + +impl Scissor { + /// Defines a scissor box that it outside of the image. + #[inline] + pub fn irrelevant() -> Scissor { + Scissor { + origin: [0, 0], + dimensions: [0x7fffffff, 0x7fffffff], + } + } + + #[inline] + pub(crate) fn into_vulkan_rect(self) -> vk::Rect2D { + vk::Rect2D { + offset: vk::Offset2D { + x: self.origin[0], + y: self.origin[1], + }, + extent: vk::Extent2D { + width: self.dimensions[0], + height: self.dimensions[1], + }, + } + } +} + +impl Default for Scissor { + #[inline] + fn default() -> Scissor { + Scissor::irrelevant() + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/query/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/query/mod.rs new file mode 100644 index 0000000..8268356 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/query/mod.rs @@ -0,0 +1,385 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! This module provides support for query pools. +//! +//! In Vulkan, queries are not created individually. Instead you manipulate **query pools**, which +//! represent a collection of queries. Whenever you use a query, you have to specify both the query +//! pool and the slot id within that query pool. + +use std::error; +use std::fmt; +use std::mem; +use std::ptr; +use std::sync::Arc; + +use device::Device; +use device::DeviceOwned; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use vk; + +pub struct UnsafeQueryPool { + pool: vk::QueryPool, + device: Arc<Device>, + num_slots: u32, +} + +impl UnsafeQueryPool { + /// Builds a new query pool. + pub fn new(device: Arc<Device>, ty: QueryType, num_slots: u32) + -> Result<UnsafeQueryPool, QueryPoolCreationError> { + let (vk_ty, statistics) = match ty { + QueryType::Occlusion => (vk::QUERY_TYPE_OCCLUSION, 0), + QueryType::Timestamp => (vk::QUERY_TYPE_TIMESTAMP, 0), + QueryType::PipelineStatistics(flags) => { + if !device.enabled_features().pipeline_statistics_query { + return Err(QueryPoolCreationError::PipelineStatisticsQueryFeatureNotEnabled); + } + + (vk::QUERY_TYPE_PIPELINE_STATISTICS, flags.into()) + }, + }; + + let pool = unsafe { + let infos = vk::QueryPoolCreateInfo { + sType: vk::STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + queryType: vk_ty, + queryCount: num_slots, + pipelineStatistics: statistics, + }; + + let mut output = mem::uninitialized(); + let vk = device.pointers(); + check_errors(vk.CreateQueryPool(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(UnsafeQueryPool { + pool: pool, + device: device, + num_slots: num_slots, + }) + } + + /// Returns the number of slots of that query pool. + #[inline] + pub fn num_slots(&self) -> u32 { + self.num_slots + } + + #[inline] + pub fn query(&self, index: u32) -> Option<UnsafeQuery> { + if index < self.num_slots() { + Some(UnsafeQuery { pool: self, index }) + } else { + None + } + } + + /// + /// # Panic + /// + /// Panics if `count` is 0. + #[inline] + pub fn queries_range(&self, first_index: u32, count: u32) -> Option<UnsafeQueriesRange> { + assert!(count >= 1); + + if first_index + count < self.num_slots() { + Some(UnsafeQueriesRange { + pool: self, + first: first_index, + count, + }) + } else { + None + } + } +} + +unsafe impl VulkanObject for UnsafeQueryPool { + type Object = vk::QueryPool; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT; + + #[inline] + fn internal_object(&self) -> vk::QueryPool { + self.pool + } +} + +unsafe impl DeviceOwned for UnsafeQueryPool { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +pub struct UnsafeQuery<'a> { + pool: &'a UnsafeQueryPool, + index: u32, +} + +impl<'a> UnsafeQuery<'a> { + #[inline] + pub fn pool(&self) -> &'a UnsafeQueryPool { + &self.pool + } + + #[inline] + pub fn index(&self) -> u32 { + self.index + } +} + +pub struct UnsafeQueriesRange<'a> { + pool: &'a UnsafeQueryPool, + first: u32, + count: u32, +} + +impl<'a> UnsafeQueriesRange<'a> { + #[inline] + pub fn pool(&self) -> &'a UnsafeQueryPool { + &self.pool + } + + #[inline] + pub fn first_index(&self) -> u32 { + self.first + } + + #[inline] + pub fn count(&self) -> u32 { + self.count + } +} + +#[derive(Debug, Copy, Clone)] +pub enum QueryType { + Occlusion, + PipelineStatistics(QueryPipelineStatisticFlags), + Timestamp, +} + +#[derive(Debug, Copy, Clone)] +pub struct QueryPipelineStatisticFlags { + pub input_assembly_vertices: bool, + pub input_assembly_primitives: bool, + pub vertex_shader_invocations: bool, + pub geometry_shader_invocations: bool, + pub geometry_shader_primitives: bool, + pub clipping_invocations: bool, + pub clipping_primitives: bool, + pub fragment_shader_invocations: bool, + pub tessellation_control_shader_patches: bool, + pub tessellation_evaluation_shader_invocations: bool, + pub compute_shader_invocations: bool, +} + +impl QueryPipelineStatisticFlags { + #[inline] + pub fn none() -> QueryPipelineStatisticFlags { + QueryPipelineStatisticFlags { + input_assembly_vertices: false, + input_assembly_primitives: false, + vertex_shader_invocations: false, + geometry_shader_invocations: false, + geometry_shader_primitives: false, + clipping_invocations: false, + clipping_primitives: false, + fragment_shader_invocations: false, + tessellation_control_shader_patches: false, + tessellation_evaluation_shader_invocations: false, + compute_shader_invocations: false, + } + } +} + +impl Into<vk::QueryPipelineStatisticFlags> for QueryPipelineStatisticFlags { + fn into(self) -> vk::QueryPipelineStatisticFlags { + let mut result = 0; + if self.input_assembly_vertices { + result |= vk::QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT; + } + if self.input_assembly_primitives { + result |= vk::QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT; + } + if self.vertex_shader_invocations { + result |= vk::QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT; + } + if self.geometry_shader_invocations { + result |= vk::QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT; + } + if self.geometry_shader_primitives { + result |= vk::QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT; + } + if self.clipping_invocations { + result |= vk::QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT; + } + if self.clipping_primitives { + result |= vk::QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT; + } + if self.fragment_shader_invocations { + result |= vk::QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT; + } + if self.tessellation_control_shader_patches { + result |= vk::QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT; + } + if self.tessellation_evaluation_shader_invocations { + result |= vk::QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT; + } + if self.compute_shader_invocations { + result |= vk::QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT; + } + result + } +} + +impl Drop for UnsafeQueryPool { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroyQueryPool(self.device.internal_object(), self.pool, ptr::null()); + } + } +} + +/// Error that can happen when creating a buffer. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum QueryPoolCreationError { + /// Not enough memory. + OomError(OomError), + /// A pipeline statistics pool was requested but the corresponding feature wasn't enabled. + PipelineStatisticsQueryFeatureNotEnabled, +} + +impl error::Error for QueryPoolCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + QueryPoolCreationError::OomError(_) => "not enough memory available", + QueryPoolCreationError::PipelineStatisticsQueryFeatureNotEnabled => { + "a pipeline statistics pool was requested but the corresponding feature \ + wasn't enabled" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + QueryPoolCreationError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for QueryPoolCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for QueryPoolCreationError { + #[inline] + fn from(err: OomError) -> QueryPoolCreationError { + QueryPoolCreationError::OomError(err) + } +} + +impl From<Error> for QueryPoolCreationError { + #[inline] + fn from(err: Error) -> QueryPoolCreationError { + match err { + err @ Error::OutOfHostMemory => QueryPoolCreationError::OomError(OomError::from(err)), + err @ Error::OutOfDeviceMemory => QueryPoolCreationError::OomError(OomError::from(err)), + _ => panic!("unexpected error: {:?}", err), + } + } +} + +pub struct OcclusionQueriesPool { + inner: UnsafeQueryPool, +} + +impl OcclusionQueriesPool { + /// See the docs of new(). + pub fn raw(device: Arc<Device>, num_slots: u32) -> Result<OcclusionQueriesPool, OomError> { + Ok(OcclusionQueriesPool { + inner: match UnsafeQueryPool::new(device, QueryType::Occlusion, num_slots) { + Ok(q) => q, + Err(QueryPoolCreationError::OomError(err)) => return Err(err), + Err(QueryPoolCreationError::PipelineStatisticsQueryFeatureNotEnabled) => { + unreachable!() + }, + }, + }) + } + + /// Builds a new query pool. + /// + /// # Panic + /// + /// - Panics if the device or host ran out of memory. + /// + #[inline] + pub fn new(device: Arc<Device>, num_slots: u32) -> Arc<OcclusionQueriesPool> { + Arc::new(OcclusionQueriesPool::raw(device, num_slots).unwrap()) + } + + /// Returns the number of slots of that query pool. + #[inline] + pub fn num_slots(&self) -> u32 { + self.inner.num_slots() + } +} + +unsafe impl DeviceOwned for OcclusionQueriesPool { + #[inline] + fn device(&self) -> &Arc<Device> { + self.inner.device() + } +} + +#[cfg(test)] +mod tests { + use query::OcclusionQueriesPool; + use query::QueryPipelineStatisticFlags; + use query::QueryPoolCreationError; + use query::QueryType; + use query::UnsafeQueryPool; + + #[test] + fn occlusion_create() { + let (device, _) = gfx_dev_and_queue!(); + let _ = OcclusionQueriesPool::new(device, 256); + } + + #[test] + fn pipeline_statistics_feature() { + let (device, _) = gfx_dev_and_queue!(); + + let ty = QueryType::PipelineStatistics(QueryPipelineStatisticFlags::none()); + match UnsafeQueryPool::new(device, ty, 256) { + Err(QueryPoolCreationError::PipelineStatisticsQueryFeatureNotEnabled) => (), + _ => panic!(), + }; + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sampler.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sampler.rs new file mode 100644 index 0000000..06c8ccb --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sampler.rs @@ -0,0 +1,956 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! How to retrieve data from an image within a shader. +//! +//! When you retrieve data from an image, you have to pass the coordinates of the pixel you want +//! to retrieve. The implementation then performs various calculations, and these operations are +//! what the `Sampler` struct describes. +//! +//! Sampling is a very complex topic but that hasn't changed much since the beginnings of 3D +//! rendering. Documentation here is missing, but any tutorial about OpenGL or DirectX can teach +//! you how it works. +//! +//! # Examples +//! +//! A simple sampler for most usages: +//! +//! ``` +//! use vulkano::sampler::Sampler; +//! +//! # let device: std::sync::Arc<vulkano::device::Device> = return; +//! let _sampler = Sampler::simple_repeat_linear_no_mipmap(device.clone()); +//! ``` +//! +//! More detailed sampler creation: +//! +//! ``` +//! use vulkano::sampler; +//! +//! # let device: std::sync::Arc<vulkano::device::Device> = return; +//! let _sampler = sampler::Sampler::new(device.clone(), sampler::Filter::Linear, +//! sampler::Filter::Linear, +//! sampler::MipmapMode::Nearest, +//! sampler::SamplerAddressMode::Repeat, +//! sampler::SamplerAddressMode::Repeat, +//! sampler::SamplerAddressMode::Repeat, 1.0, 1.0, +//! 0.0, 100.0).unwrap();; +//! ``` +//! +//! # About border colors +//! +//! One of the possible values of `SamplerAddressMode` and `UnnormalizedSamplerAddressMode` is +//! `ClampToBorder`. This value indicates that accessing an image outside of its range must return +//! the specified color. +//! +//! However this comes with restrictions. When using a floating-point border color, the sampler can +//! only be used with floating-point or depth image views. When using an integer border color, the +//! sampler can only be used with integer or stencil image views. In addition to this, you can't +//! use an opaque black border color with an image view that uses components swizzling. +//! +//! > **Note**: The reason for this restriction about opaque black borders is that the value of the +//! > alpha is 1.0 while the value of the color components is 0.0. In the other border colors, the +//! > value of all the components is the same. +//! +//! Samplers that don't use `ClampToBorder` are not concerned by these restrictions. +//! +// FIXME: restrictions aren't checked yet + +use std::error; +use std::fmt; +use std::mem; +use std::ptr; +use std::sync::Arc; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use device::Device; +use device::DeviceOwned; +use vk; + +pub use pipeline::depth_stencil::Compare; + +/// Describes how to retrieve data from an image within a shader. +pub struct Sampler { + sampler: vk::Sampler, + device: Arc<Device>, + compare_mode: bool, + unnormalized: bool, + usable_with_float_formats: bool, + usable_with_int_formats: bool, + usable_with_swizzling: bool, +} + +impl Sampler { + /// Shortcut for creating a sampler with linear sampling, linear mipmaps, and with the repeat + /// mode for borders. + /// + /// Useful for prototyping, but can also be used in real projects. + /// + /// # Panic + /// + /// - Panics if out of memory or the maximum number of samplers has exceeded. + /// + #[inline] + pub fn simple_repeat_linear(device: Arc<Device>) -> Arc<Sampler> { + Sampler::new(device, + Filter::Linear, + Filter::Linear, + MipmapMode::Linear, + SamplerAddressMode::Repeat, + SamplerAddressMode::Repeat, + SamplerAddressMode::Repeat, + 0.0, + 1.0, + 0.0, + 1_000.0) + .unwrap() + } + + /// Shortcut for creating a sampler with linear sampling, that only uses the main level of + /// images, and with the repeat mode for borders. + /// + /// Useful for prototyping, but can also be used in real projects. + /// + /// # Panic + /// + /// - Panics if out of memory or the maximum number of samplers has exceeded. + /// + #[inline] + pub fn simple_repeat_linear_no_mipmap(device: Arc<Device>) -> Arc<Sampler> { + Sampler::new(device, + Filter::Linear, + Filter::Linear, + MipmapMode::Nearest, + SamplerAddressMode::Repeat, + SamplerAddressMode::Repeat, + SamplerAddressMode::Repeat, + 0.0, + 1.0, + 0.0, + 1.0) + .unwrap() + } + + /// Creates a new `Sampler` with the given behavior. + /// + /// `mag_filter` and `min_filter` define how the implementation should sample from the image + /// when it is respectively larger and smaller than the original. + /// + /// `mipmap_mode` defines how the implementation should choose which mipmap to use. + /// + /// `address_u`, `address_v` and `address_w` define how the implementation should behave when + /// sampling outside of the texture coordinates range `[0.0, 1.0]`. + /// + /// `mip_lod_bias` is a value to add to . + /// + /// `max_anisotropy` must be greater than or equal to 1.0. If greater than 1.0, the + /// implementation will use anisotropic filtering. Using a value greater than 1.0 requires + /// the `sampler_anisotropy` feature to be enabled when creating the device. + /// + /// `min_lod` and `max_lod` are respectively the minimum and maximum mipmap level to use. + /// `max_lod` must always be greater than or equal to `min_lod`. + /// + /// # Panic + /// + /// - Panics if multiple `ClampToBorder` values are passed and the border color is different. + /// - Panics if `max_anisotropy < 1.0`. + /// - Panics if `min_lod > max_lod`. + /// + #[inline(always)] + pub fn new(device: Arc<Device>, mag_filter: Filter, min_filter: Filter, + mipmap_mode: MipmapMode, address_u: SamplerAddressMode, + address_v: SamplerAddressMode, address_w: SamplerAddressMode, mip_lod_bias: f32, + max_anisotropy: f32, min_lod: f32, max_lod: f32) + -> Result<Arc<Sampler>, SamplerCreationError> { + Sampler::new_impl(device, + mag_filter, + min_filter, + mipmap_mode, + address_u, + address_v, + address_w, + mip_lod_bias, + max_anisotropy, + min_lod, + max_lod, + None) + } + + /// Creates a new `Sampler` with the given behavior. + /// + /// Contrary to `new`, this creates a sampler that is used to compare depth values. + /// + /// A sampler like this can only operate on depth or depth-stencil textures. Instead of + /// returning the value of the texture, this sampler will return a value between 0.0 and 1.0 + /// indicating how much the reference value (passed by the shader) compares to the value in the + /// texture. + /// + /// Note that it doesn't make sense to create a compare-mode sampler with an integer border + /// color, as such a sampler would be unusable. + /// + /// # Panic + /// + /// Same panic reasons as `new`. + /// + #[inline(always)] + pub fn compare(device: Arc<Device>, mag_filter: Filter, min_filter: Filter, + mipmap_mode: MipmapMode, address_u: SamplerAddressMode, + address_v: SamplerAddressMode, address_w: SamplerAddressMode, + mip_lod_bias: f32, max_anisotropy: f32, min_lod: f32, max_lod: f32, + compare: Compare) + -> Result<Arc<Sampler>, SamplerCreationError> { + Sampler::new_impl(device, + mag_filter, + min_filter, + mipmap_mode, + address_u, + address_v, + address_w, + mip_lod_bias, + max_anisotropy, + min_lod, + max_lod, + Some(compare)) + } + + fn new_impl(device: Arc<Device>, mag_filter: Filter, min_filter: Filter, + mipmap_mode: MipmapMode, address_u: SamplerAddressMode, + address_v: SamplerAddressMode, address_w: SamplerAddressMode, mip_lod_bias: f32, + max_anisotropy: f32, min_lod: f32, max_lod: f32, compare: Option<Compare>) + -> Result<Arc<Sampler>, SamplerCreationError> { + assert!(max_anisotropy >= 1.0); + assert!(min_lod <= max_lod); + + // Check max anisotropy. + if max_anisotropy > 1.0 { + if !device.enabled_features().sampler_anisotropy { + return Err(SamplerCreationError::SamplerAnisotropyFeatureNotEnabled); + } + + let limit = device.physical_device().limits().max_sampler_anisotropy(); + if max_anisotropy > limit { + return Err(SamplerCreationError::AnisotropyLimitExceeded { + requested: max_anisotropy, + maximum: limit, + }); + } + } + + // Check mip_lod_bias value. + { + let limit = device.physical_device().limits().max_sampler_lod_bias(); + if mip_lod_bias > limit { + return Err(SamplerCreationError::MipLodBiasLimitExceeded { + requested: mip_lod_bias, + maximum: limit, + }); + } + } + + // Check MirrorClampToEdge extension support + if [address_u, address_v, address_w] + .iter() + .any(|&mode| mode == SamplerAddressMode::MirrorClampToEdge) + { + if !device.loaded_extensions().khr_sampler_mirror_clamp_to_edge { + return Err(SamplerCreationError::SamplerMirrorClampToEdgeExtensionNotEnabled); + } + } + + // Handling border color. + let border_color = address_u.border_color(); + let border_color = match (border_color, address_v.border_color()) { + (Some(b1), Some(b2)) => { + assert_eq!(b1, b2); + Some(b1) + }, + (None, b) => b, + (b, None) => b, + }; + let border_color = match (border_color, address_w.border_color()) { + (Some(b1), Some(b2)) => { + assert_eq!(b1, b2); + Some(b1) + }, + (None, b) => b, + (b, None) => b, + }; + + let vk = device.pointers(); + let sampler = unsafe { + let infos = vk::SamplerCreateInfo { + sType: vk::STRUCTURE_TYPE_SAMPLER_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + magFilter: mag_filter as u32, + minFilter: min_filter as u32, + mipmapMode: mipmap_mode as u32, + addressModeU: address_u.to_vk(), + addressModeV: address_v.to_vk(), + addressModeW: address_w.to_vk(), + mipLodBias: mip_lod_bias, + anisotropyEnable: if max_anisotropy > 1.0 { + vk::TRUE + } else { + vk::FALSE + }, + maxAnisotropy: max_anisotropy, + compareEnable: if compare.is_some() { + vk::TRUE + } else { + vk::FALSE + }, + compareOp: compare.map(|c| c as u32).unwrap_or(0), + minLod: min_lod, + maxLod: max_lod, + borderColor: border_color.map(|b| b as u32).unwrap_or(0), + unnormalizedCoordinates: vk::FALSE, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateSampler(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Sampler { + sampler: sampler, + device: device.clone(), + compare_mode: compare.is_some(), + unnormalized: false, + usable_with_float_formats: match border_color { + Some(BorderColor::FloatTransparentBlack) => true, + Some(BorderColor::FloatOpaqueBlack) => true, + Some(BorderColor::FloatOpaqueWhite) => true, + Some(_) => false, + None => true, + }, + usable_with_int_formats: compare.is_none() && + match border_color { + Some(BorderColor::IntTransparentBlack) => true, + Some(BorderColor::IntOpaqueBlack) => true, + Some(BorderColor::IntOpaqueWhite) => true, + Some(_) => false, + None => true, + }, + usable_with_swizzling: match border_color { + Some(BorderColor::FloatOpaqueBlack) => false, + Some(BorderColor::IntOpaqueBlack) => false, + _ => true, + }, + })) + } + + /// Creates a sampler with unnormalized coordinates. This means that texture coordinates won't + /// range between `0.0` and `1.0` but use plain pixel offsets. + /// + /// Using an unnormalized sampler adds a few restrictions: + /// + /// - It can only be used with non-array 1D or 2D images. + /// - It can only be used with images with a single mipmap. + /// - Projection and offsets can't be used by shaders. Only the first mipmap can be accessed. + /// + /// # Panic + /// + /// - Panics if multiple `ClampToBorder` values are passed and the border color is different. + /// + pub fn unnormalized(device: Arc<Device>, filter: Filter, + address_u: UnnormalizedSamplerAddressMode, + address_v: UnnormalizedSamplerAddressMode) + -> Result<Arc<Sampler>, SamplerCreationError> { + let vk = device.pointers(); + + let border_color = address_u.border_color(); + let border_color = match (border_color, address_v.border_color()) { + (Some(b1), Some(b2)) => { + assert_eq!(b1, b2); + Some(b1) + }, + (None, b) => b, + (b, None) => b, + }; + + let sampler = unsafe { + let infos = vk::SamplerCreateInfo { + sType: vk::STRUCTURE_TYPE_SAMPLER_CREATE_INFO, + pNext: ptr::null(), + flags: 0, // reserved + magFilter: filter as u32, + minFilter: filter as u32, + mipmapMode: vk::SAMPLER_MIPMAP_MODE_NEAREST, + addressModeU: address_u.to_vk(), + addressModeV: address_v.to_vk(), + addressModeW: vk::SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // unused by the impl + mipLodBias: 0.0, + anisotropyEnable: vk::FALSE, + maxAnisotropy: 1.0, + compareEnable: vk::FALSE, + compareOp: vk::COMPARE_OP_NEVER, + minLod: 0.0, + maxLod: 0.0, + borderColor: border_color.map(|b| b as u32).unwrap_or(0), + unnormalizedCoordinates: vk::TRUE, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateSampler(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Sampler { + sampler: sampler, + device: device.clone(), + compare_mode: false, + unnormalized: true, + usable_with_float_formats: match border_color { + Some(BorderColor::FloatTransparentBlack) => true, + Some(BorderColor::FloatOpaqueBlack) => true, + Some(BorderColor::FloatOpaqueWhite) => true, + Some(_) => false, + None => true, + }, + usable_with_int_formats: match border_color { + Some(BorderColor::IntTransparentBlack) => true, + Some(BorderColor::IntOpaqueBlack) => true, + Some(BorderColor::IntOpaqueWhite) => true, + Some(_) => false, + None => true, + }, + usable_with_swizzling: match border_color { + Some(BorderColor::FloatOpaqueBlack) => false, + Some(BorderColor::IntOpaqueBlack) => false, + _ => true, + }, + })) + } + + /// Returns true if the sampler is a compare-mode sampler. + #[inline] + pub fn compare_mode(&self) -> bool { + self.compare_mode + } + + /// Returns true if the sampler is unnormalized. + #[inline] + pub fn is_unnormalized(&self) -> bool { + self.unnormalized + } + + /// Returns true if the sampler can be used with floating-point image views. See the + /// documentation of the `sampler` module for more info. + #[inline] + pub fn usable_with_float_formats(&self) -> bool { + self.usable_with_float_formats + } + + /// Returns true if the sampler can be used with integer image views. See the documentation of + /// the `sampler` module for more info. + #[inline] + pub fn usable_with_int_formats(&self) -> bool { + self.usable_with_int_formats + } + + /// Returns true if the sampler can be used with image views that have non-identity swizzling. + /// See the documentation of the `sampler` module for more info. + #[inline] + pub fn usable_with_swizzling(&self) -> bool { + self.usable_with_swizzling + } +} + +unsafe impl DeviceOwned for Sampler { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +unsafe impl VulkanObject for Sampler { + type Object = vk::Sampler; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT; + + #[inline] + fn internal_object(&self) -> vk::Sampler { + self.sampler + } +} + +impl fmt::Debug for Sampler { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan sampler {:?}>", self.sampler) + } +} + +impl Drop for Sampler { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroySampler(self.device.internal_object(), self.sampler, ptr::null()); + } + } +} + +/// Describes how the color of each pixel should be determined. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[repr(u32)] +pub enum Filter { + /// The four pixels whose center surround the requested coordinates are taken, then their + /// values are interpolated. + Linear = vk::FILTER_LINEAR, + + /// The pixel whose center is nearest to the requested coordinates is taken from the source + /// and its value is returned as-is. + Nearest = vk::FILTER_NEAREST, +} + +/// Describes which mipmap from the source to use. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[repr(u32)] +pub enum MipmapMode { + /// Use the mipmap whose dimensions are the nearest to the dimensions of the destination. + Nearest = vk::SAMPLER_MIPMAP_MODE_NEAREST, + + /// Take the mipmap whose dimensions are no greater than that of the destination together + /// with the next higher level mipmap, calculate the value for both, and interpolate them. + Linear = vk::SAMPLER_MIPMAP_MODE_LINEAR, +} + +/// How the sampler should behave when it needs to access a pixel that is out of range of the +/// texture. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum SamplerAddressMode { + /// Repeat the texture. In other words, the pixel at coordinate `x + 1.0` is the same as the + /// one at coordinate `x`. + Repeat, + + /// Repeat the texture but mirror it at every repetition. In other words, the pixel at + /// coordinate `x + 1.0` is the same as the one at coordinate `1.0 - x`. + MirroredRepeat, + + /// The coordinates are clamped to the valid range. Coordinates below 0.0 have the same value + /// as coordinate 0.0. Coordinates over 1.0 have the same value as coordinate 1.0. + ClampToEdge, + + /// Any pixel out of range is considered to be part of the "border" of the image, which has a + /// specific color of your choice. + /// + /// Note that if you use `ClampToBorder` multiple times, they must all have the same border + /// color. + ClampToBorder(BorderColor), + + /// Similar to `MirroredRepeat`, except that coordinates are clamped to the range + /// `[-1.0, 1.0]`. + MirrorClampToEdge, +} + +impl SamplerAddressMode { + #[inline] + fn to_vk(self) -> vk::SamplerAddressMode { + match self { + SamplerAddressMode::Repeat => vk::SAMPLER_ADDRESS_MODE_REPEAT, + SamplerAddressMode::MirroredRepeat => vk::SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT, + SamplerAddressMode::ClampToEdge => vk::SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, + SamplerAddressMode::ClampToBorder(_) => vk::SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, + SamplerAddressMode::MirrorClampToEdge => vk::SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, + } + } + + #[inline] + fn border_color(self) -> Option<BorderColor> { + match self { + SamplerAddressMode::ClampToBorder(c) => Some(c), + _ => None, + } + } +} + +/// How the sampler should behave when it needs to access a pixel that is out of range of the +/// texture. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[repr(u32)] +pub enum UnnormalizedSamplerAddressMode { + /// The coordinates are clamped to the valid range. Coordinates below 0 have the same value + /// as coordinate 0. Coordinates over *size of texture* have the same value as coordinate + /// *size of texture*. + ClampToEdge, + + /// Any pixel out of range is considered to be part of the "border" of the image, which has a + /// specific color of your choice. + /// + /// Note that if you use `ClampToBorder` multiple times, they must all have the same border + /// color. + ClampToBorder(BorderColor), +} + +impl UnnormalizedSamplerAddressMode { + #[inline] + fn to_vk(self) -> vk::SamplerAddressMode { + match self { + UnnormalizedSamplerAddressMode::ClampToEdge => vk::SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, + UnnormalizedSamplerAddressMode::ClampToBorder(_) => { + vk::SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER + }, + } + } + + #[inline] + fn border_color(self) -> Option<BorderColor> { + match self { + UnnormalizedSamplerAddressMode::ClampToEdge => None, + UnnormalizedSamplerAddressMode::ClampToBorder(c) => Some(c), + } + } +} + +/// The color to use for the border of an image. +/// +/// Only relevant if you use `ClampToBorder`. +/// +/// Using a border color restricts the sampler to either floating-point images or integer images. +/// See the documentation of the `sampler` module for more info. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[repr(u32)] +pub enum BorderColor { + /// The value `(0.0, 0.0, 0.0, 0.0)`. Can only be used with floating-point images. + FloatTransparentBlack = vk::BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, + + /// The value `(0, 0, 0, 0)`. Can only be used with integer images. + IntTransparentBlack = vk::BORDER_COLOR_INT_TRANSPARENT_BLACK, + + /// The value `(0.0, 0.0, 0.0, 1.0)`. Can only be used with floating-point identity-swizzled + /// images. + FloatOpaqueBlack = vk::BORDER_COLOR_FLOAT_OPAQUE_BLACK, + + /// The value `(0, 0, 0, 1)`. Can only be used with integer identity-swizzled images. + IntOpaqueBlack = vk::BORDER_COLOR_INT_OPAQUE_BLACK, + + /// The value `(1.0, 1.0, 1.0, 1.0)`. Can only be used with floating-point images. + FloatOpaqueWhite = vk::BORDER_COLOR_FLOAT_OPAQUE_WHITE, + + /// The value `(1, 1, 1, 1)`. Can only be used with integer images. + IntOpaqueWhite = vk::BORDER_COLOR_INT_OPAQUE_WHITE, +} + +/// Error that can happen when creating an instance. +#[derive(Clone, Debug, PartialEq)] +pub enum SamplerCreationError { + /// Not enough memory. + OomError(OomError), + + /// Too many sampler objects have been created. You must destroy some before creating new ones. + /// Note the specs guarantee that at least 4000 samplers can exist simultaneously. + TooManyObjects, + + /// Using an anisotropy greater than 1.0 requires enabling the `sampler_anisotropy` feature + /// when creating the device. + SamplerAnisotropyFeatureNotEnabled, + + /// The requested anisotropy level exceeds the device's limits. + AnisotropyLimitExceeded { + /// The value that was requested. + requested: f32, + /// The maximum supported value. + maximum: f32, + }, + + /// The requested mip lod bias exceeds the device's limits. + MipLodBiasLimitExceeded { + /// The value that was requested. + requested: f32, + /// The maximum supported value. + maximum: f32, + }, + + /// Using `MirrorClampToEdge` requires enabling the `VK_KHR_sampler_mirror_clamp_to_edge` + /// extension when creating the device. + SamplerMirrorClampToEdgeExtensionNotEnabled, +} + +impl error::Error for SamplerCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + SamplerCreationError::OomError(_) => "not enough memory available", + SamplerCreationError::TooManyObjects => "too many simultaneous sampler objects", + SamplerCreationError::SamplerAnisotropyFeatureNotEnabled => + "the `sampler_anisotropy` feature is not enabled", + SamplerCreationError::AnisotropyLimitExceeded { .. } => "anisotropy limit exceeded", + SamplerCreationError::MipLodBiasLimitExceeded { .. } => "mip lod bias limit exceeded", + SamplerCreationError::SamplerMirrorClampToEdgeExtensionNotEnabled => + "the device extension `VK_KHR_sampler_mirror_clamp_to_edge` is not enabled", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + SamplerCreationError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for SamplerCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for SamplerCreationError { + #[inline] + fn from(err: OomError) -> SamplerCreationError { + SamplerCreationError::OomError(err) + } +} + +impl From<Error> for SamplerCreationError { + #[inline] + fn from(err: Error) -> SamplerCreationError { + match err { + err @ Error::OutOfHostMemory => SamplerCreationError::OomError(OomError::from(err)), + err @ Error::OutOfDeviceMemory => SamplerCreationError::OomError(OomError::from(err)), + Error::TooManyObjects => SamplerCreationError::TooManyObjects, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +#[cfg(test)] +mod tests { + use sampler; + + #[test] + fn create_regular() { + let (device, queue) = gfx_dev_and_queue!(); + + let s = sampler::Sampler::new(device, + sampler::Filter::Linear, + sampler::Filter::Linear, + sampler::MipmapMode::Nearest, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + 1.0, + 1.0, + 0.0, + 2.0) + .unwrap(); + assert!(!s.compare_mode()); + assert!(!s.is_unnormalized()); + } + + #[test] + fn create_compare() { + let (device, queue) = gfx_dev_and_queue!(); + + let s = sampler::Sampler::compare(device, + sampler::Filter::Linear, + sampler::Filter::Linear, + sampler::MipmapMode::Nearest, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + 1.0, + 1.0, + 0.0, + 2.0, + sampler::Compare::Less) + .unwrap(); + + assert!(s.compare_mode()); + assert!(!s.is_unnormalized()); + } + + #[test] + fn create_unnormalized() { + let (device, queue) = gfx_dev_and_queue!(); + + let s = + sampler::Sampler::unnormalized(device, + sampler::Filter::Linear, + sampler::UnnormalizedSamplerAddressMode::ClampToEdge, + sampler::UnnormalizedSamplerAddressMode::ClampToEdge) + .unwrap(); + + assert!(!s.compare_mode()); + assert!(s.is_unnormalized()); + } + + #[test] + fn simple_repeat_linear() { + let (device, queue) = gfx_dev_and_queue!(); + let _ = sampler::Sampler::simple_repeat_linear(device); + } + + #[test] + fn simple_repeat_linear_no_mipmap() { + let (device, queue) = gfx_dev_and_queue!(); + let _ = sampler::Sampler::simple_repeat_linear_no_mipmap(device); + } + + #[test] + fn min_lod_inferior() { + let (device, queue) = gfx_dev_and_queue!(); + + assert_should_panic!({ + let _ = sampler::Sampler::new(device, + sampler::Filter::Linear, + sampler::Filter::Linear, + sampler::MipmapMode::Nearest, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + 1.0, + 1.0, + 5.0, + 2.0); + }); + } + + #[test] + fn max_anisotropy() { + let (device, queue) = gfx_dev_and_queue!(); + + assert_should_panic!({ + let _ = sampler::Sampler::new(device, + sampler::Filter::Linear, + sampler::Filter::Linear, + sampler::MipmapMode::Nearest, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + 1.0, + 0.5, + 0.0, + 2.0); + }); + } + + #[test] + fn different_borders() { + let (device, queue) = gfx_dev_and_queue!(); + + let b1 = sampler::BorderColor::IntTransparentBlack; + let b2 = sampler::BorderColor::FloatOpaqueWhite; + + assert_should_panic!({ + let _ = sampler::Sampler::new(device, + sampler::Filter::Linear, + sampler::Filter::Linear, + sampler::MipmapMode::Nearest, + sampler::SamplerAddressMode::ClampToBorder(b1), + sampler::SamplerAddressMode::ClampToBorder(b2), + sampler::SamplerAddressMode::Repeat, + 1.0, + 1.0, + 5.0, + 2.0); + }); + } + + #[test] + fn anisotropy_feature() { + let (device, queue) = gfx_dev_and_queue!(); + + let r = sampler::Sampler::new(device, + sampler::Filter::Linear, + sampler::Filter::Linear, + sampler::MipmapMode::Nearest, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + 1.0, + 2.0, + 0.0, + 2.0); + + match r { + Err(sampler::SamplerCreationError::SamplerAnisotropyFeatureNotEnabled) => (), + _ => panic!(), + } + } + + #[test] + fn anisotropy_limit() { + let (device, queue) = gfx_dev_and_queue!(sampler_anisotropy); + + let r = sampler::Sampler::new(device, + sampler::Filter::Linear, + sampler::Filter::Linear, + sampler::MipmapMode::Nearest, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + 1.0, + 100000000.0, + 0.0, + 2.0); + + match r { + Err(sampler::SamplerCreationError::AnisotropyLimitExceeded { .. }) => (), + _ => panic!(), + } + } + + #[test] + fn mip_lod_bias_limit() { + let (device, queue) = gfx_dev_and_queue!(); + + let r = sampler::Sampler::new(device, + sampler::Filter::Linear, + sampler::Filter::Linear, + sampler::MipmapMode::Nearest, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + sampler::SamplerAddressMode::Repeat, + 100000000.0, + 1.0, + 0.0, + 2.0); + + match r { + Err(sampler::SamplerCreationError::MipLodBiasLimitExceeded { .. }) => (), + _ => panic!(), + } + } + + #[test] + fn sampler_mirror_clamp_to_edge_extension() { + let (device, queue) = gfx_dev_and_queue!(); + + let r = sampler::Sampler::new(device, + sampler::Filter::Linear, + sampler::Filter::Linear, + sampler::MipmapMode::Nearest, + sampler::SamplerAddressMode::MirrorClampToEdge, + sampler::SamplerAddressMode::MirrorClampToEdge, + sampler::SamplerAddressMode::MirrorClampToEdge, + 1.0, + 1.0, + 0.0, + 2.0); + + match r { + Err(sampler::SamplerCreationError::SamplerMirrorClampToEdgeExtensionNotEnabled) => (), + _ => panic!(), + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/capabilities.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/capabilities.rs new file mode 100644 index 0000000..6483c88 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/capabilities.rs @@ -0,0 +1,594 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use format::Format; +use image::ImageUsage; +use vk; + +/// The capabilities of a surface when used by a physical device. +/// +/// You have to match these capabilities when you create a swapchain. +#[derive(Clone, Debug)] +pub struct Capabilities { + /// Minimum number of images that must be present in the swapchain. + pub min_image_count: u32, + + /// Maximum number of images that must be present in the swapchain, or `None` if there is no + /// maximum value. Note that "no maximum" doesn't mean that you can set a very high value, as + /// you may still get out of memory errors. + pub max_image_count: Option<u32>, + + /// The current dimensions of the surface. `None` means that the surface's dimensions will + /// depend on the dimensions of the swapchain that you are going to create. + pub current_extent: Option<[u32; 2]>, + + /// Minimum width and height of a swapchain that uses this surface. + pub min_image_extent: [u32; 2], + + /// Maximum width and height of a swapchain that uses this surface. + pub max_image_extent: [u32; 2], + + /// Maximum number of image layers if you create an image array. The minimum is 1. + pub max_image_array_layers: u32, + + /// List of transforms supported for the swapchain. + pub supported_transforms: SupportedSurfaceTransforms, + + /// Current transform used by the surface. + pub current_transform: SurfaceTransform, + + /// List of composite alpha modes supports for the swapchain. + pub supported_composite_alpha: SupportedCompositeAlpha, + + /// List of image usages that are supported for images of the swapchain. Only + /// the `color_attachment` usage is guaranteed to be supported. + pub supported_usage_flags: ImageUsage, + + /// List of formats supported for the swapchain. + pub supported_formats: Vec<(Format, ColorSpace)>, // TODO: https://github.com/KhronosGroup/Vulkan-Docs/issues/207 + + /// List of present modes that are supported. `Fifo` is always guaranteed to be supported. + pub present_modes: SupportedPresentModes, +} + +/// The way presenting a swapchain is accomplished. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u32)] +pub enum PresentMode { + /// Immediately shows the image to the user. May result in visible tearing. + Immediate = vk::PRESENT_MODE_IMMEDIATE_KHR, + + /// The action of presenting an image puts it in wait. When the next vertical blanking period + /// happens, the waiting image is effectively shown to the user. If an image is presented while + /// another one is waiting, it is replaced. + Mailbox = vk::PRESENT_MODE_MAILBOX_KHR, + + /// The action of presenting an image adds it to a queue of images. At each vertical blanking + /// period, the queue is popped and an image is presented. + /// + /// Guaranteed to be always supported. + /// + /// This is the equivalent of OpenGL's `SwapInterval` with a value of 1. + Fifo = vk::PRESENT_MODE_FIFO_KHR, + + /// Same as `Fifo`, except that if the queue was empty during the previous vertical blanking + /// period then it is equivalent to `Immediate`. + /// + /// This is the equivalent of OpenGL's `SwapInterval` with a value of -1. + Relaxed = vk::PRESENT_MODE_FIFO_RELAXED_KHR, + + // TODO: These can't be enabled yet because they have to be used with shared present surfaces + // which vulkano doesnt support yet. + //SharedDemand = vk::PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR, + //SharedContinuous = vk::PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR, +} + +/// List of `PresentMode`s that are supported. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct SupportedPresentModes { + pub immediate: bool, + pub mailbox: bool, + pub fifo: bool, + pub relaxed: bool, + pub shared_demand: bool, + pub shared_continuous: bool, +} + +pub fn supported_present_modes_from_list<I>(elem: I) -> SupportedPresentModes + where I: Iterator<Item = vk::PresentModeKHR> +{ + let mut result = SupportedPresentModes::none(); + for e in elem { + match e { + vk::PRESENT_MODE_IMMEDIATE_KHR => result.immediate = true, + vk::PRESENT_MODE_MAILBOX_KHR => result.mailbox = true, + vk::PRESENT_MODE_FIFO_KHR => result.fifo = true, + vk::PRESENT_MODE_FIFO_RELAXED_KHR => result.relaxed = true, + vk::PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR => result.shared_demand = true, + vk::PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR => result.shared_continuous = true, + _ => { } + } + } + result +} + +impl SupportedPresentModes { + /// Builds a `SupportedPresentModes` with all fields set to false. + #[inline] + pub fn none() -> SupportedPresentModes { + SupportedPresentModes { + immediate: false, + mailbox: false, + fifo: false, + relaxed: false, + shared_demand: false, + shared_continuous: false, + } + } + + /// Returns true if the given present mode is in this list of supported modes. + #[inline] + pub fn supports(&self, mode: PresentMode) -> bool { + match mode { + PresentMode::Immediate => self.immediate, + PresentMode::Mailbox => self.mailbox, + PresentMode::Fifo => self.fifo, + PresentMode::Relaxed => self.relaxed, + } + } + + /// Returns an iterator to the list of supported present modes. + #[inline] + pub fn iter(&self) -> SupportedPresentModesIter { + SupportedPresentModesIter(self.clone()) + } +} + +/// Enumeration of the `PresentMode`s that are supported. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct SupportedPresentModesIter(SupportedPresentModes); + +impl Iterator for SupportedPresentModesIter { + type Item = PresentMode; + + #[inline] + fn next(&mut self) -> Option<PresentMode> { + if self.0.immediate { + self.0.immediate = false; + return Some(PresentMode::Immediate); + } + if self.0.mailbox { + self.0.mailbox = false; + return Some(PresentMode::Mailbox); + } + if self.0.fifo { + self.0.fifo = false; + return Some(PresentMode::Fifo); + } + if self.0.relaxed { + self.0.relaxed = false; + return Some(PresentMode::Relaxed); + } + None + } +} + +/// A transformation to apply to the image before showing it on the screen. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u32)] +pub enum SurfaceTransform { + /// Don't transform the image. + Identity = vk::SURFACE_TRANSFORM_IDENTITY_BIT_KHR, + /// Rotate 90 degrees. + Rotate90 = vk::SURFACE_TRANSFORM_ROTATE_90_BIT_KHR, + /// Rotate 180 degrees. + Rotate180 = vk::SURFACE_TRANSFORM_ROTATE_180_BIT_KHR, + /// Rotate 270 degrees. + Rotate270 = vk::SURFACE_TRANSFORM_ROTATE_270_BIT_KHR, + /// Mirror the image horizontally. + HorizontalMirror = vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR, + /// Mirror the image horizontally and rotate 90 degrees. + HorizontalMirrorRotate90 = vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR, + /// Mirror the image horizontally and rotate 180 degrees. + HorizontalMirrorRotate180 = vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR, + /// Mirror the image horizontally and rotate 270 degrees. + HorizontalMirrorRotate270 = vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR, + /// Let the operating system or driver implementation choose. + Inherit = vk::SURFACE_TRANSFORM_INHERIT_BIT_KHR, +} + +/// How the alpha values of the pixels of the window are treated. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u32)] +pub enum CompositeAlpha { + /// The alpha channel of the image is ignored. All the pixels are considered as if they have a + /// value of 1.0. + Opaque = vk::COMPOSITE_ALPHA_OPAQUE_BIT_KHR, + + /// The alpha channel of the image is respected. The color channels are expected to have + /// already been multiplied by the alpha value. + PreMultiplied = vk::COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR, + + /// The alpha channel of the image is respected. The color channels will be multiplied by the + /// alpha value by the compositor before being added to what is behind. + PostMultiplied = vk::COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR, + + /// Let the operating system or driver implementation choose. + Inherit = vk::COMPOSITE_ALPHA_INHERIT_BIT_KHR, +} + +/// List of supported composite alpha modes. +/// +/// See the docs of `CompositeAlpha`. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[allow(missing_docs)] +pub struct SupportedCompositeAlpha { + pub opaque: bool, + pub pre_multiplied: bool, + pub post_multiplied: bool, + pub inherit: bool, +} + +pub fn supported_composite_alpha_from_bits(val: u32) -> SupportedCompositeAlpha { + let mut result = SupportedCompositeAlpha::none(); + if (val & vk::COMPOSITE_ALPHA_OPAQUE_BIT_KHR) != 0 { + result.opaque = true; + } + if (val & vk::COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR) != 0 { + result.pre_multiplied = true; + } + if (val & vk::COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR) != 0 { + result.post_multiplied = true; + } + if (val & vk::COMPOSITE_ALPHA_INHERIT_BIT_KHR) != 0 { + result.inherit = true; + } + result +} + +impl SupportedCompositeAlpha { + /// Builds a `SupportedCompositeAlpha` with all fields set to false. + #[inline] + pub fn none() -> SupportedCompositeAlpha { + SupportedCompositeAlpha { + opaque: false, + pre_multiplied: false, + post_multiplied: false, + inherit: false, + } + } + + /// Returns true if the given `CompositeAlpha` is in this list. + #[inline] + pub fn supports(&self, value: CompositeAlpha) -> bool { + match value { + CompositeAlpha::Opaque => self.opaque, + CompositeAlpha::PreMultiplied => self.pre_multiplied, + CompositeAlpha::PostMultiplied => self.post_multiplied, + CompositeAlpha::Inherit => self.inherit, + } + } + + /// Returns an iterator to the list of supported composite alpha. + #[inline] + pub fn iter(&self) -> SupportedCompositeAlphaIter { + SupportedCompositeAlphaIter(self.clone()) + } +} + +/// Enumeration of the `CompositeAlpha` that are supported. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct SupportedCompositeAlphaIter(SupportedCompositeAlpha); + +impl Iterator for SupportedCompositeAlphaIter { + type Item = CompositeAlpha; + + #[inline] + fn next(&mut self) -> Option<CompositeAlpha> { + if self.0.opaque { + self.0.opaque = false; + return Some(CompositeAlpha::Opaque); + } + if self.0.pre_multiplied { + self.0.pre_multiplied = false; + return Some(CompositeAlpha::PreMultiplied); + } + if self.0.post_multiplied { + self.0.post_multiplied = false; + return Some(CompositeAlpha::PostMultiplied); + } + if self.0.inherit { + self.0.inherit = false; + return Some(CompositeAlpha::Inherit); + } + None + } +} + +/// List of supported composite alpha modes. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct SupportedSurfaceTransforms { + pub identity: bool, + pub rotate90: bool, + pub rotate180: bool, + pub rotate270: bool, + pub horizontal_mirror: bool, + pub horizontal_mirror_rotate90: bool, + pub horizontal_mirror_rotate180: bool, + pub horizontal_mirror_rotate270: bool, + pub inherit: bool, +} + +pub fn surface_transforms_from_bits(val: vk::SurfaceTransformFlagsKHR) + -> SupportedSurfaceTransforms { + macro_rules! v { + ($val:expr, $out:ident, $e:expr, $f:ident) => ( + if ($val & $e) != 0 { $out.$f = true; } + ); + } + + let mut result = SupportedSurfaceTransforms::none(); + v!(val, + result, + vk::SURFACE_TRANSFORM_IDENTITY_BIT_KHR, + identity); + v!(val, + result, + vk::SURFACE_TRANSFORM_ROTATE_90_BIT_KHR, + rotate90); + v!(val, + result, + vk::SURFACE_TRANSFORM_ROTATE_180_BIT_KHR, + rotate180); + v!(val, + result, + vk::SURFACE_TRANSFORM_ROTATE_270_BIT_KHR, + rotate270); + v!(val, + result, + vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR, + horizontal_mirror); + v!(val, + result, + vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR, + horizontal_mirror_rotate90); + v!(val, + result, + vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR, + horizontal_mirror_rotate180); + v!(val, + result, + vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR, + horizontal_mirror_rotate270); + v!(val, result, vk::SURFACE_TRANSFORM_INHERIT_BIT_KHR, inherit); + result +} + +impl SupportedSurfaceTransforms { + /// Builds a `SupportedSurfaceTransforms` with all fields set to false. + #[inline] + pub fn none() -> SupportedSurfaceTransforms { + SupportedSurfaceTransforms { + identity: false, + rotate90: false, + rotate180: false, + rotate270: false, + horizontal_mirror: false, + horizontal_mirror_rotate90: false, + horizontal_mirror_rotate180: false, + horizontal_mirror_rotate270: false, + inherit: false, + } + } + + /// Returns true if the given `SurfaceTransform` is in this list. + #[inline] + pub fn supports(&self, value: SurfaceTransform) -> bool { + match value { + SurfaceTransform::Identity => self.identity, + SurfaceTransform::Rotate90 => self.rotate90, + SurfaceTransform::Rotate180 => self.rotate180, + SurfaceTransform::Rotate270 => self.rotate270, + SurfaceTransform::HorizontalMirror => self.horizontal_mirror, + SurfaceTransform::HorizontalMirrorRotate90 => self.horizontal_mirror_rotate90, + SurfaceTransform::HorizontalMirrorRotate180 => self.horizontal_mirror_rotate180, + SurfaceTransform::HorizontalMirrorRotate270 => self.horizontal_mirror_rotate270, + SurfaceTransform::Inherit => self.inherit, + } + } + + /// Returns an iterator to the list of supported composite alpha. + #[inline] + pub fn iter(&self) -> SupportedSurfaceTransformsIter { + SupportedSurfaceTransformsIter(self.clone()) + } +} + +/// Enumeration of the `SurfaceTransform` that are supported. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct SupportedSurfaceTransformsIter(SupportedSurfaceTransforms); + +impl Iterator for SupportedSurfaceTransformsIter { + type Item = SurfaceTransform; + + #[inline] + fn next(&mut self) -> Option<SurfaceTransform> { + if self.0.identity { + self.0.identity = false; + return Some(SurfaceTransform::Identity); + } + if self.0.rotate90 { + self.0.rotate90 = false; + return Some(SurfaceTransform::Rotate90); + } + if self.0.rotate180 { + self.0.rotate180 = false; + return Some(SurfaceTransform::Rotate180); + } + if self.0.rotate270 { + self.0.rotate270 = false; + return Some(SurfaceTransform::Rotate270); + } + if self.0.horizontal_mirror { + self.0.horizontal_mirror = false; + return Some(SurfaceTransform::HorizontalMirror); + } + if self.0.horizontal_mirror_rotate90 { + self.0.horizontal_mirror_rotate90 = false; + return Some(SurfaceTransform::HorizontalMirrorRotate90); + } + if self.0.horizontal_mirror_rotate180 { + self.0.horizontal_mirror_rotate180 = false; + return Some(SurfaceTransform::HorizontalMirrorRotate180); + } + if self.0.horizontal_mirror_rotate270 { + self.0.horizontal_mirror_rotate270 = false; + return Some(SurfaceTransform::HorizontalMirrorRotate270); + } + if self.0.inherit { + self.0.inherit = false; + return Some(SurfaceTransform::Inherit); + } + None + } +} + +impl Default for SurfaceTransform { + #[inline] + fn default() -> SurfaceTransform { + SurfaceTransform::Identity + } +} + +/// How the presentation engine should interpret the data. +/// +/// # A quick lesson about color spaces +/// +/// ## What is a color space? +/// +/// Each pixel of a monitor is made of three components: one red, one green, and one blue. In the +/// past, computers would simply send to the monitor the intensity of each of the three components. +/// +/// This proved to be problematic, because depending on the brand of the monitor the colors would +/// not exactly be the same. For example on some monitors, a value of `[1.0, 0.0, 0.0]` would be a +/// bit more orange than on others. +/// +/// In order to standardize this, there exist what are called *color spaces*: sRGB, AdobeRGB, +/// DCI-P3, scRGB, etc. When you manipulate RGB values in a specific color space, these values have +/// a precise absolute meaning in terms of color, that is the same across all systems and monitors. +/// +/// > **Note**: Color spaces are orthogonal to concept of RGB. *RGB* only indicates what is the +/// > representation of the data, but not how it is interpreted. You can think of this a bit like +/// > text encoding. An *RGB* value is a like a byte, in other words it is the medium by which +/// > values are communicated, and a *color space* is like a text encoding (eg. UTF-8), in other +/// > words it is the way the value should be interpreted. +/// +/// The most commonly used color space today is sRGB. Most monitors today use this color space, +/// and most images files are encoded in this color space. +/// +/// ## Pixel formats and linear vs non-linear +/// +/// In Vulkan all images have a specific format in which the data is stored. The data of an image +/// consists of pixels in RGB but contains no information about the color space (or lack thereof) +/// of these pixels. You are free to store them in whatever color space you want. +/// +/// But one big practical problem with color spaces is that they are sometimes not linear, and in +/// particular the popular sRGB color space is not linear. In a non-linear color space, a value of +/// `[0.6, 0.6, 0.6]` for example is **not** twice as bright as a value of `[0.3, 0.3, 0.3]`. This +/// is problematic, because operations such as taking the average of two colors or calculating the +/// lighting of a texture with a dot product are mathematically incorrect and will produce +/// incorrect colors. +/// +/// > **Note**: If the texture format has an alpha component, it is not affected by the color space +/// > and always behaves linearly. +/// +/// In order to solve this Vulkan also provides image formats with the `Srgb` suffix, which are +/// expected to contain RGB data in the sRGB color space. When you sample an image with such a +/// format from a shader, the implementation will automatically turn the pixel values into a linear +/// color space that is suitable for linear operations (such as additions or multiplications). +/// When you write to a framebuffer attachment with such a format, the implementation will +/// automatically perform the opposite conversion. These conversions are most of the time performed +/// by the hardware and incur no additional cost. +/// +/// ## Color space of the swapchain +/// +/// The color space that you specify when you create a swapchain is how the implementation will +/// interpret the raw data inside of the image. +/// +/// > **Note**: The implementation can choose to send the data in the swapchain image directly to +/// > the monitor, but it can also choose to write it in an intermediary buffer that is then read +/// > by the operating system or windowing system. Therefore the color space that the +/// > implementation supports is not necessarily the same as the one supported by the monitor. +/// +/// It is *your* job to ensure that the data in the swapchain image is in the color space +/// that is specified here, otherwise colors will be incorrect. +/// The implementation will never perform any additional automatic conversion after the colors have +/// been written to the swapchain image. +/// +/// # How do I handle this correctly? +/// +/// The easiest way to handle color spaces in a cross-platform program is: +/// +/// - Always request the `SrgbNonLinear` color space when creating the swapchain. +/// - Make sure that all your image files use the sRGB color space, and load them in images whose +/// format has the `Srgb` suffix. Only use non-sRGB image formats for intermediary computations +/// or to store non-color data. +/// - Swapchain images should have a format with the `Srgb` suffix. +/// +/// > **Note**: It is unclear whether the `SrgbNonLinear` color space is always supported by the +/// > the implementation or not. See https://github.com/KhronosGroup/Vulkan-Docs/issues/442. +/// +/// > **Note**: Lots of developers are confused by color spaces. You can sometimes find articles +/// > talking about gamma correction and suggestion to put your colors to the power 2.2 for +/// > example. These are all hacks and you should use the sRGB pixel formats instead. +/// +/// If you follow these three rules, then everything should render the same way on all platforms. +/// +/// Additionally you can try detect whether the implementation supports any additional color space +/// and perform a manual conversion to that color space from inside your shader. +/// +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u32)] +pub enum ColorSpace { + SrgbNonLinear = vk::COLOR_SPACE_SRGB_NONLINEAR_KHR, + DisplayP3NonLinear = vk::COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT, + ExtendedSrgbLinear = vk::COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT, + DciP3Linear = vk::COLOR_SPACE_DCI_P3_LINEAR_EXT, + DciP3NonLinear = vk::COLOR_SPACE_DCI_P3_NONLINEAR_EXT, + Bt709Linear = vk::COLOR_SPACE_BT709_LINEAR_EXT, + Bt709NonLinear = vk::COLOR_SPACE_BT709_NONLINEAR_EXT, + Bt2020Linear = vk::COLOR_SPACE_BT2020_LINEAR_EXT, + Hdr10St2084 = vk::COLOR_SPACE_HDR10_ST2084_EXT, + DolbyVision = vk::COLOR_SPACE_DOLBYVISION_EXT, + Hdr10Hlg = vk::COLOR_SPACE_HDR10_HLG_EXT, + AdobeRgbLinear = vk::COLOR_SPACE_ADOBERGB_LINEAR_EXT, + AdobeRgbNonLinear = vk::COLOR_SPACE_ADOBERGB_NONLINEAR_EXT, + PassThrough = vk::COLOR_SPACE_PASS_THROUGH_EXT, +} + +#[inline] +pub fn color_space_from_num(val: u32) -> ColorSpace { + match val { + vk::COLOR_SPACE_SRGB_NONLINEAR_KHR => ColorSpace::SrgbNonLinear, + vk::COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT => ColorSpace::DisplayP3NonLinear, + vk::COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT => ColorSpace::ExtendedSrgbLinear, + vk::COLOR_SPACE_DCI_P3_LINEAR_EXT => ColorSpace::DciP3Linear, + vk::COLOR_SPACE_DCI_P3_NONLINEAR_EXT => ColorSpace::DciP3NonLinear, + vk::COLOR_SPACE_BT709_LINEAR_EXT => ColorSpace::Bt709Linear, + vk::COLOR_SPACE_BT709_NONLINEAR_EXT => ColorSpace::Bt709NonLinear, + vk::COLOR_SPACE_BT2020_LINEAR_EXT => ColorSpace::Bt2020Linear, + vk::COLOR_SPACE_HDR10_ST2084_EXT => ColorSpace::Hdr10St2084, + vk::COLOR_SPACE_DOLBYVISION_EXT => ColorSpace::DolbyVision, + vk::COLOR_SPACE_HDR10_HLG_EXT => ColorSpace::Hdr10Hlg, + vk::COLOR_SPACE_ADOBERGB_LINEAR_EXT => ColorSpace::AdobeRgbLinear, + vk::COLOR_SPACE_ADOBERGB_NONLINEAR_EXT => ColorSpace::AdobeRgbNonLinear, + vk::COLOR_SPACE_PASS_THROUGH_EXT => ColorSpace::PassThrough, + _ => panic!("Wrong value for color space enum"), + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/display.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/display.rs new file mode 100644 index 0000000..46a62d3 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/display.rs @@ -0,0 +1,389 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Allows you to create surfaces that fill a whole display, outside of the windowing system. +//! +//! **As far as the author knows, no existing device supports these features. Therefore the code +//! here is mostly a draft and needs rework in both the API and the implementation.** +//! +//! The purpose of the objects in this module is to let you create a `Surface` object that +//! represents a location on the screen. This is done in four steps: +//! +//! - Choose a `Display` where the surface will be located. A `Display` represents a display +//! display, usually a monitor. The available displays can be enumerated with +//! `Display::enumerate`. +//! - Choose a `DisplayMode`, which is the combination of a display, a resolution and a refresh +//! rate. You can enumerate the modes available on a display with `Display::display_modes`, or +//! attempt to create your own mode with `TODO`. +//! - Choose a `DisplayPlane`. A display can show multiple planes in a stacking fashion. +//! - Create a `Surface` object with `Surface::from_display_mode` and pass the chosen `DisplayMode` +//! and `DisplayPlane`. + +#![allow(dead_code)] // TODO: this module isn't finished +#![allow(unused_variables)] // TODO: this module isn't finished + +use std::ffi::CStr; +use std::ptr; +use std::sync::Arc; +use std::vec::IntoIter; + +use instance::Instance; +use instance::PhysicalDevice; +use swapchain::SupportedSurfaceTransforms; +use swapchain::capabilities; + +use OomError; +use VulkanObject; +use check_errors; +use vk; + +// TODO: extract this to a `display` module and solve the visibility problems + +/// ? +// TODO: plane capabilities +// TODO: store properties in the instance? +pub struct DisplayPlane { + instance: Arc<Instance>, + physical_device: usize, + index: u32, + properties: vk::DisplayPlanePropertiesKHR, + supported_displays: Vec<vk::DisplayKHR>, +} + +impl DisplayPlane { + /// See the docs of enumerate(). + pub fn enumerate_raw(device: PhysicalDevice) -> Result<IntoIter<DisplayPlane>, OomError> { + let vk = device.instance().pointers(); + + assert!(device.instance().loaded_extensions().khr_display); // TODO: return error instead + + let num = unsafe { + let mut num: u32 = 0; + check_errors(vk.GetPhysicalDeviceDisplayPlanePropertiesKHR(device.internal_object(), + &mut num, + ptr::null_mut()))?; + num + }; + + let planes: Vec<vk::DisplayPlanePropertiesKHR> = unsafe { + let mut planes = Vec::with_capacity(num as usize); + let mut num = num; + check_errors(vk.GetPhysicalDeviceDisplayPlanePropertiesKHR(device.internal_object(), + &mut num, + planes.as_mut_ptr()))?; + planes.set_len(num as usize); + planes + }; + + Ok(planes.into_iter().enumerate().map(|(index, prop)| { + let num = unsafe { + let mut num: u32 = 0; + check_errors(vk.GetDisplayPlaneSupportedDisplaysKHR(device.internal_object(), index as u32, + &mut num, ptr::null_mut())).unwrap(); // TODO: shouldn't unwrap + num + }; + + let supported_displays: Vec<vk::DisplayKHR> = unsafe { + let mut displays = Vec::with_capacity(num as usize); + let mut num = num; + check_errors(vk.GetDisplayPlaneSupportedDisplaysKHR(device.internal_object(), + index as u32, &mut num, + displays.as_mut_ptr())).unwrap(); // TODO: shouldn't unwrap + displays.set_len(num as usize); + displays + }; + + DisplayPlane { + instance: device.instance().clone(), + physical_device: device.index(), + index: index as u32, + properties: prop, + supported_displays: supported_displays, + } + }).collect::<Vec<_>>().into_iter()) + } + + /// Enumerates all the display planes that are available on a given physical device. + /// + /// # Panic + /// + /// - Panics if the device or host ran out of memory. + /// + // TODO: move iterator creation here from raw constructor? + #[inline] + pub fn enumerate(device: PhysicalDevice) -> IntoIter<DisplayPlane> { + DisplayPlane::enumerate_raw(device).unwrap() + } + + /// Returns the physical device that was used to create this display. + #[inline] + pub fn physical_device(&self) -> PhysicalDevice { + PhysicalDevice::from_index(&self.instance, self.physical_device).unwrap() + } + + /// Returns the index of the plane. + #[inline] + pub fn index(&self) -> u32 { + self.index + } + + /// Returns true if this plane supports the given display. + #[inline] + pub fn supports(&self, display: &Display) -> bool { + // making sure that the physical device is the same + if self.physical_device().internal_object() != display.physical_device().internal_object() { + return false; + } + + self.supported_displays + .iter() + .find(|&&d| d == display.internal_object()) + .is_some() + } +} + +/// Represents a monitor connected to a physical device. +// TODO: store properties in the instance? +#[derive(Clone)] +pub struct Display { + instance: Arc<Instance>, + physical_device: usize, + properties: Arc<vk::DisplayPropertiesKHR>, // TODO: Arc because struct isn't clone +} + +impl Display { + /// See the docs of enumerate(). + pub fn enumerate_raw(device: PhysicalDevice) -> Result<IntoIter<Display>, OomError> { + let vk = device.instance().pointers(); + assert!(device.instance().loaded_extensions().khr_display); // TODO: return error instead + + let num = unsafe { + let mut num = 0; + check_errors(vk.GetPhysicalDeviceDisplayPropertiesKHR(device.internal_object(), + &mut num, + ptr::null_mut()))?; + num + }; + + let displays: Vec<vk::DisplayPropertiesKHR> = unsafe { + let mut displays = Vec::with_capacity(num as usize); + let mut num = num; + check_errors(vk.GetPhysicalDeviceDisplayPropertiesKHR(device.internal_object(), + &mut num, + displays.as_mut_ptr()))?; + displays.set_len(num as usize); + displays + }; + + Ok(displays + .into_iter() + .map(|prop| { + Display { + instance: device.instance().clone(), + physical_device: device.index(), + properties: Arc::new(prop), + } + }) + .collect::<Vec<_>>() + .into_iter()) + } + + /// Enumerates all the displays that are available on a given physical device. + /// + /// # Panic + /// + /// - Panics if the device or host ran out of memory. + /// + // TODO: move iterator creation here from raw constructor? + #[inline] + pub fn enumerate(device: PhysicalDevice) -> IntoIter<Display> { + Display::enumerate_raw(device).unwrap() + } + + /// Returns the name of the display. + #[inline] + pub fn name(&self) -> &str { + unsafe { + CStr::from_ptr(self.properties.displayName) + .to_str() + .expect("non UTF-8 characters in display name") + } + } + + /// Returns the physical device that was used to create this display. + #[inline] + pub fn physical_device(&self) -> PhysicalDevice { + PhysicalDevice::from_index(&self.instance, self.physical_device).unwrap() + } + + /// Returns the physical dimensions of the display in millimeters. + #[inline] + pub fn physical_dimensions(&self) -> [u32; 2] { + let ref r = self.properties.physicalDimensions; + [r.width, r.height] + } + + /// Returns the physical, native, or preferred resolution of the display. + /// + /// > **Note**: The display is usually still capable of displaying other resolutions. This is + /// > only the "best" resolution. + #[inline] + pub fn physical_resolution(&self) -> [u32; 2] { + let ref r = self.properties.physicalResolution; + [r.width, r.height] + } + + /// Returns the transforms supported by this display. + #[inline] + pub fn supported_transforms(&self) -> SupportedSurfaceTransforms { + capabilities::surface_transforms_from_bits(self.properties.supportedTransforms) + } + + /// Returns true if TODO. + #[inline] + pub fn plane_reorder_possible(&self) -> bool { + self.properties.planeReorderPossible != 0 + } + + /// Returns true if TODO. + #[inline] + pub fn persistent_content(&self) -> bool { + self.properties.persistentContent != 0 + } + + /// See the docs of display_modes(). + pub fn display_modes_raw(&self) -> Result<IntoIter<DisplayMode>, OomError> { + let vk = self.instance.pointers(); + + let num = unsafe { + let mut num = 0; + check_errors(vk.GetDisplayModePropertiesKHR(self.physical_device().internal_object(), + self.properties.display, + &mut num, + ptr::null_mut()))?; + num + }; + + let modes: Vec<vk::DisplayModePropertiesKHR> = unsafe { + let mut modes = Vec::with_capacity(num as usize); + let mut num = num; + check_errors(vk.GetDisplayModePropertiesKHR(self.physical_device().internal_object(), + self.properties.display, + &mut num, + modes.as_mut_ptr()))?; + modes.set_len(num as usize); + modes + }; + + Ok(modes + .into_iter() + .map(|mode| { + DisplayMode { + display: self.clone(), + display_mode: mode.displayMode, + parameters: mode.parameters, + } + }) + .collect::<Vec<_>>() + .into_iter()) + } + + /// Returns a list of all modes available on this display. + /// + /// # Panic + /// + /// - Panics if the device or host ran out of memory. + /// + // TODO: move iterator creation here from display_modes_raw? + #[inline] + pub fn display_modes(&self) -> IntoIter<DisplayMode> { + self.display_modes_raw().unwrap() + } +} + +unsafe impl VulkanObject for Display { + type Object = vk::DisplayKHR; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT; + + #[inline] + fn internal_object(&self) -> vk::DisplayKHR { + self.properties.display + } +} + +/// Represents a mode on a specific display. +pub struct DisplayMode { + display: Display, + display_mode: vk::DisplayModeKHR, + parameters: vk::DisplayModeParametersKHR, +} + +impl DisplayMode { + /*pub fn new(display: &Display) -> Result<Arc<DisplayMode>, OomError> { + let vk = instance.pointers(); + assert!(device.instance().loaded_extensions().khr_display); // TODO: return error instead + + let parameters = vk::DisplayModeParametersKHR { + visibleRegion: vk::Extent2D { width: , height: }, + refreshRate: , + }; + + let display_mode = { + let infos = vk::DisplayModeCreateInfoKHR { + sType: vk::STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR, + pNext: ptr::null(), + flags: 0, // reserved + parameters: parameters, + }; + + let mut output = mem::uninitialized(); + try!(check_errors(vk.CreateDisplayModeKHR(display.device.internal_object(), + display.display, &infos, ptr::null(), + &mut output))); + output + }; + + Ok(Arc::new(DisplayMode { + instance: display.device.instance().clone(), + display_mode: display_mode, + parameters: , + })) + }*/ + + /// Returns the display corresponding to this mode. + #[inline] + pub fn display(&self) -> &Display { + &self.display + } + + /// Returns the dimensions of the region that is visible on the monitor. + #[inline] + pub fn visible_region(&self) -> [u32; 2] { + let ref d = self.parameters.visibleRegion; + [d.width, d.height] + } + + /// Returns the refresh rate of this mode. + #[inline] + pub fn refresh_rate(&self) -> u32 { + self.parameters.refreshRate + } +} + +unsafe impl VulkanObject for DisplayMode { + type Object = vk::DisplayModeKHR; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT; + + #[inline] + fn internal_object(&self) -> vk::DisplayModeKHR { + self.display_mode + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/mod.rs new file mode 100644 index 0000000..baa38f9 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/mod.rs @@ -0,0 +1,341 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Link between Vulkan and a window and/or the screen. +//! +//! Before you can draw on the screen or a window, you have to create two objects: +//! +//! - Create a `Surface` object that represents the location where the image will show up (either +//! a window or a monitor). +//! - Create a `Swapchain` that uses that `Surface`. +//! +//! Creating a surface can be done with only an `Instance` object. However creating a swapchain +//! requires a `Device` object. +//! +//! Once you have a swapchain, you can retrieve `Image` objects from it and draw to them just like +//! you would draw on any other image. +//! +//! # Surfaces +//! +//! A surface is an object that represents a location where to render. It can be created from an +//! instance and either a window handle (in a platform-specific way) or a monitor. +//! +//! In order to use surfaces, you will have to enable the `VK_KHR_surface` extension on the +//! instance. See the `instance` module for more information about how to enable extensions. +//! +//! ## Creating a surface from a window +//! +//! There are 5 extensions that each allow you to create a surface from a type of window: +//! +//! - `VK_KHR_xlib_surface` +//! - `VK_KHR_xcb_surface` +//! - `VK_KHR_wayland_surface` +//! - `VK_KHR_android_surface` +//! - `VK_KHR_win32_surface` +//! +//! For example if you want to create a surface from an Android surface, you will have to enable +//! the `VK_KHR_android_surface` extension and use `Surface::from_anativewindow`. +//! See the documentation of `Surface` for all the possible constructors. +//! +//! Trying to use one of these functions without enabling the proper extension will result in an +//! error. +//! +//! **Note that the `Surface` object is potentially unsafe**. It is your responsibility to +//! keep the window alive for at least as long as the surface exists. In many cases Surface +//! may be able to do this for you, if you pass it ownership of your Window (or a +//! reference-counting container for it). +//! +//! ### Example +//! +//! ```no_run +//! use std::ptr; +//! use vulkano::instance::Instance; +//! use vulkano::instance::InstanceExtensions; +//! use vulkano::swapchain::Surface; +//! +//! let instance = { +//! let extensions = InstanceExtensions { +//! khr_surface: true, +//! khr_win32_surface: true, // If you don't enable this, `from_hwnd` will fail. +//! .. InstanceExtensions::none() +//! }; +//! +//! match Instance::new(None, &extensions, None) { +//! Ok(i) => i, +//! Err(err) => panic!("Couldn't build instance: {:?}", err) +//! } +//! }; +//! +//! # use std::sync::Arc; +//! # struct Window(*const u32); +//! # impl Window { +//! # fn hwnd(&self) -> *const u32 { self.0 } +//! # } +//! # +//! # fn build_window() -> Arc<Window> { Arc::new(Window(ptr::null())) } +//! let window = build_window(); // Third-party function, not provided by vulkano +//! let _surface = unsafe { +//! let hinstance: *const () = ptr::null(); // Windows-specific object +//! Surface::from_hwnd(instance.clone(), hinstance, window.hwnd(), Arc::clone(&window)).unwrap() +//! }; +//! ``` +//! +//! ## Creating a surface from a monitor +//! +//! Currently no system provides the `VK_KHR_display` extension that contains this feature. +//! This feature is still a work-in-progress in vulkano and will reside in the `display` module. +//! +//! # Swapchains +//! +//! A surface represents a location on the screen and can be created from an instance. Once you +//! have a surface, the next step is to create a swapchain. Creating a swapchain requires a device, +//! and allocates the resources that will be used to display images on the screen. +//! +//! A swapchain is composed of one or multiple images. Each image of the swapchain is presented in +//! turn on the screen, one after another. More information below. +//! +//! Swapchains have several properties: +//! +//! - The number of images that will cycle on the screen. +//! - The format of the images. +//! - The 2D dimensions of the images, plus a number of layers, for a total of three dimensions. +//! - The usage of the images, similar to creating other images. +//! - The queue families that are going to use the images, similar to creating other images. +//! - An additional transformation (rotation or mirroring) to perform on the final output. +//! - How the alpha of the final output will be interpreted. +//! - How to perform the cycling between images in regard to vsync. +//! +//! You can query the supported values of all these properties with +//! [`Surface::capabilities()]`](struct.Surface.html#method.capabilities). +//! +//! ## Creating a swapchain +//! +//! In order to create a swapchain, you will first have to enable the `VK_KHR_swapchain` extension +//! on the device (and not on the instance like `VK_KHR_surface`): +//! +//! ```no_run +//! # use vulkano::device::DeviceExtensions; +//! let ext = DeviceExtensions { +//! khr_swapchain: true, +//! .. DeviceExtensions::none() +//! }; +//! ``` +//! +//! Then, query the capabilities of the surface with +//! [`Surface::capabilities()`](struct.Surface.html#method.capabilities) +//! and choose which values you are going to use. +//! +//! ```no_run +//! # use std::sync::Arc; +//! # use vulkano::device::Device; +//! # use vulkano::swapchain::Surface; +//! # use std::cmp::{max, min}; +//! # fn choose_caps(device: Arc<Device>, surface: Arc<Surface<()>>) -> Result<(), Box<std::error::Error>> { +//! let caps = surface.capabilities(device.physical_device())?; +//! +//! // Use the current window size or some fixed resolution. +//! let dimensions = caps.current_extent.unwrap_or([640, 480]); +//! +//! // Try to use double-buffering. +//! let buffers_count = match caps.max_image_count { +//! None => max(2, caps.min_image_count), +//! Some(limit) => min(max(2, caps.min_image_count), limit) +//! }; +//! +//! // Preserve the current surface transform. +//! let transform = caps.current_transform; +//! +//! // Use the first available format. +//! let (format, color_space) = caps.supported_formats[0]; +//! # Ok(()) +//! # } +//! ``` +//! +//! Then, call [`Swapchain::new()`](struct.Swapchain.html#method.new). +//! +//! ```no_run +//! # use std::sync::Arc; +//! # use vulkano::device::{Device, Queue}; +//! # use vulkano::image::ImageUsage; +//! # use vulkano::sync::SharingMode; +//! # use vulkano::format::Format; +//! # use vulkano::swapchain::{Surface, Swapchain, SurfaceTransform, PresentMode, CompositeAlpha}; +//! # fn create_swapchain( +//! # device: Arc<Device>, surface: Arc<Surface<()>>, present_queue: Arc<Queue>, +//! # buffers_count: u32, format: Format, dimensions: [u32; 2], +//! # surface_transform: SurfaceTransform, composite_alpha: CompositeAlpha, present_mode: PresentMode +//! # ) -> Result<(), Box<std::error::Error>> { +//! // The created swapchain will be used as a color attachment for rendering. +//! let usage = ImageUsage { +//! color_attachment: true, +//! .. ImageUsage::none() +//! }; +//! +//! let sharing_mode = SharingMode::Exclusive(present_queue.family().id()); +//! +//! // Create the swapchain and its buffers. +//! let (swapchain, buffers) = Swapchain::new( +//! // Create the swapchain in this `device`'s memory. +//! device, +//! // The surface where the images will be presented. +//! surface, +//! // How many buffers to use in the swapchain. +//! buffers_count, +//! // The format of the images. +//! format, +//! // The size of each image. +//! dimensions, +//! // How many layers each image has. +//! 1, +//! // What the images are going to be used for. +//! usage, +//! // Describes which queues will interact with the swapchain. +//! sharing_mode, +//! // What transformation to use with the surface. +//! surface_transform, +//! // How to handle the alpha channel. +//! composite_alpha, +//! // How to present images. +//! present_mode, +//! // Clip the parts of the buffer which aren't visible. +//! true, +//! // No previous swapchain. +//! None +//! )?; +//! +//! # Ok(()) +//! # } +//! ``` +//! +//! Creating a swapchain not only returns the swapchain object, but also all the images that belong +//! to it. +//! +//! ## Acquiring and presenting images +//! +//! Once you created a swapchain and retrieved all the images that belong to it (see previous +//! section), you can draw on it. This is done in three steps: +//! +//! - Call `swapchain::acquire_next_image`. This function will return the index of the image +//! (within the list returned by `Swapchain::new`) that is available to draw, plus a future +//! representing the moment when the GPU will gain access to that image. +//! - Draw on that image just like you would draw to any other image (see the documentation of +//! the `pipeline` module). You need to chain the draw after the future that was returned by +//! `acquire_next_image`. +//! - Call `Swapchain::present` with the same index and by chaining the futures, in order to tell +//! the implementation that you are finished drawing to the image and that it can queue a +//! command to present the image on the screen after the draw operations are finished. +//! +//! ``` +//! use vulkano::swapchain; +//! use vulkano::sync::GpuFuture; +//! # let queue: ::std::sync::Arc<::vulkano::device::Queue> = return; +//! # let mut swapchain: ::std::sync::Arc<swapchain::Swapchain<()>> = return; +//! // let mut (swapchain, images) = Swapchain::new(...); +//! loop { +//! # let mut command_buffer: ::vulkano::command_buffer::AutoCommandBuffer<()> = return; +//! let (image_num, acquire_future) +//! = swapchain::acquire_next_image(swapchain.clone(), None).unwrap(); +//! +//! // The command_buffer contains the draw commands that modify the framebuffer +//! // constructed from images[image_num] +//! acquire_future +//! .then_execute(queue.clone(), command_buffer).unwrap() +//! .then_swapchain_present(queue.clone(), swapchain.clone(), image_num) +//! .then_signal_fence_and_flush().unwrap(); +//! } +//! ``` +//! +//! ## Recreating a swapchain +//! +//! In some situations, the swapchain will become invalid by itself. This includes for example when +//! the window is resized (as the images of the swapchain will no longer match the window's) or, +//! on Android, when the application went to the background and goes back to the foreground. +//! +//! In this situation, acquiring a swapchain image or presenting it will return an error. Rendering +//! to an image of that swapchain will not produce any error, but may or may not work. To continue +//! rendering, you will need to *recreate* the swapchain by creating a new swapchain and passing +//! as last parameter the old swapchain. +//! +//! TODO: suboptimal stuff +//! +//! ``` +//! use vulkano::swapchain; +//! use vulkano::swapchain::AcquireError; +//! use vulkano::sync::GpuFuture; +//! +//! // let mut swapchain = Swapchain::new(...); +//! # let mut swapchain: (::std::sync::Arc<::vulkano::swapchain::Swapchain<()>>, _) = return; +//! # let queue: ::std::sync::Arc<::vulkano::device::Queue> = return; +//! let mut recreate_swapchain = false; +//! +//! loop { +//! if recreate_swapchain { +//! swapchain = swapchain.0.recreate_with_dimension([1024, 768]).unwrap(); +//! recreate_swapchain = false; +//! } +//! +//! let (ref swapchain, ref _images) = swapchain; +//! +//! let (index, acq_future) = match swapchain::acquire_next_image(swapchain.clone(), None) { +//! Ok(r) => r, +//! Err(AcquireError::OutOfDate) => { recreate_swapchain = true; continue; }, +//! Err(err) => panic!("{:?}", err) +//! }; +//! +//! // ... +//! +//! let final_future = acq_future +//! // .then_execute(...) +//! .then_swapchain_present(queue.clone(), swapchain.clone(), index) +//! .then_signal_fence_and_flush().unwrap(); // TODO: PresentError? +//! } +//! ``` +//! + +use std::sync::atomic::AtomicBool; + +pub use self::capabilities::Capabilities; +pub use self::capabilities::ColorSpace; +pub use self::capabilities::CompositeAlpha; +pub use self::capabilities::PresentMode; +pub use self::capabilities::SupportedCompositeAlpha; +pub use self::capabilities::SupportedCompositeAlphaIter; +pub use self::capabilities::SupportedPresentModes; +pub use self::capabilities::SupportedPresentModesIter; +pub use self::capabilities::SupportedSurfaceTransforms; +pub use self::capabilities::SupportedSurfaceTransformsIter; +pub use self::capabilities::SurfaceTransform; +pub use self::present_region::PresentRegion; +pub use self::present_region::RectangleLayer; +pub use self::surface::CapabilitiesError; +pub use self::surface::Surface; +pub use self::surface::SurfaceCreationError; +pub use self::swapchain::AcquireError; +pub use self::swapchain::AcquiredImage; +pub use self::swapchain::PresentFuture; +pub use self::swapchain::Swapchain; +pub use self::swapchain::SwapchainAcquireFuture; +pub use self::swapchain::SwapchainCreationError; +pub use self::swapchain::acquire_next_image; +pub use self::swapchain::acquire_next_image_raw; +pub use self::swapchain::present; +pub use self::swapchain::present_incremental; + +mod capabilities; +pub mod display; +mod present_region; +mod surface; +mod swapchain; + +/// Internal trait so that creating/destroying a swapchain can access the surface's "has_swapchain" +/// flag. +// TODO: use pub(crate) maybe? +unsafe trait SurfaceSwapchainLock { + fn flag(&self) -> &AtomicBool; +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/present_region.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/present_region.rs new file mode 100644 index 0000000..baa6a47 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/present_region.rs @@ -0,0 +1,67 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use swapchain::Swapchain; +use vk; + +/// Represents a region on an image. +/// +/// A region consists of an arbitrary amount of rectangles. +#[derive(Debug, Clone)] +pub struct PresentRegion { + pub rectangles: Vec<RectangleLayer>, +} + +impl PresentRegion { + /// Returns true if this present region is compatible with swapchain. + pub fn is_compatible_with<W>(&self, swapchain: &Swapchain<W>) -> bool { + self.rectangles + .iter() + .all(|rect| rect.is_compatible_with(swapchain)) + } +} + +/// Represents a rectangular region on an image layer. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct RectangleLayer { + /// Coordinates in pixels of the top-left hand corner of the rectangle. + pub offset: [i32; 2], + + /// Dimensions in pixels of the rectangle. + pub extent: [u32; 2], + + /// The layer of the image. For images with only one layer, the value of layer must be 0. + pub layer: u32, +} + +impl RectangleLayer { + /// Returns true if this rectangle layer is compatible with swapchain. + pub fn is_compatible_with<W>(&self, swapchain: &Swapchain<W>) -> bool { + // FIXME negative offset is not disallowed by spec, but semantically should not be possible + debug_assert!(self.offset[0] >= 0); + debug_assert!(self.offset[1] >= 0); + self.offset[0] as u32 + self.extent[0] <= swapchain.dimensions()[0] && + self.offset[1] as u32 + self.extent[1] <= swapchain.dimensions()[1] && + self.layer < swapchain.layers() + } + + pub(crate) fn to_vk(&self) -> vk::RectLayerKHR { + vk::RectLayerKHR { + offset: vk::Offset2D { + x: self.offset[0], + y: self.offset[1], + }, + extent: vk::Extent2D { + width: self.extent[0], + height: self.extent[1], + }, + layer: self.layer, + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/surface.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/surface.rs new file mode 100644 index 0000000..bfb676c --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/surface.rs @@ -0,0 +1,770 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::mem; +use std::os::raw::c_ulong; +use std::ptr; +use std::sync::Arc; +use std::sync::atomic::AtomicBool; + +use format::Format; +use image::ImageUsage; +use instance::Instance; +use instance::PhysicalDevice; +use instance::QueueFamily; +use swapchain::Capabilities; +use swapchain::SurfaceSwapchainLock; +use swapchain::capabilities; +use swapchain::display::DisplayMode; +use swapchain::display::DisplayPlane; + +use Error; +use OomError; +use VulkanObject; +use check_errors; +use vk; + +/// Represents a surface on the screen. +/// +/// Creating a `Surface` is platform-specific. +pub struct Surface<W> { + window: W, + instance: Arc<Instance>, + surface: vk::SurfaceKHR, + + // If true, a swapchain has been associated to this surface, and that any new swapchain + // creation should be forbidden. + has_swapchain: AtomicBool, +} + +impl<W> Surface<W> { + /// Creates a `Surface` given the raw handler. + /// + /// Be careful when using it + /// + pub unsafe fn from_raw_surface(instance: Arc<Instance>, surface: vk::SurfaceKHR, + win: W) + -> Surface<W> { + Surface { + window: win, + instance: instance, + surface: surface, + has_swapchain: AtomicBool::new(false), + } + } + + /// Creates a `Surface` that covers a display mode. + /// + /// # Panic + /// + /// - Panics if `display_mode` and `plane` don't belong to the same physical device. + /// - Panics if `plane` doesn't support the display of `display_mode`. + /// + pub fn from_display_mode(display_mode: &DisplayMode, plane: &DisplayPlane) + -> Result<Arc<Surface<()>>, SurfaceCreationError> { + if !display_mode + .display() + .physical_device() + .instance() + .loaded_extensions() + .khr_display + { + return Err(SurfaceCreationError::MissingExtension { name: "VK_KHR_display" }); + } + + assert_eq!(display_mode.display().physical_device().internal_object(), + plane.physical_device().internal_object()); + assert!(plane.supports(display_mode.display())); + + let instance = display_mode.display().physical_device().instance(); + let vk = instance.pointers(); + + let surface = unsafe { + let infos = vk::DisplaySurfaceCreateInfoKHR { + sType: vk::STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR, + pNext: ptr::null(), + flags: 0, // reserved + displayMode: display_mode.internal_object(), + planeIndex: plane.index(), + planeStackIndex: 0, // FIXME: plane.properties.currentStackIndex, + transform: vk::SURFACE_TRANSFORM_IDENTITY_BIT_KHR, // TODO: let user choose + globalAlpha: 0.0, // TODO: let user choose + alphaMode: vk::DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR, // TODO: let user choose + imageExtent: vk::Extent2D { + // TODO: let user choose + width: display_mode.visible_region()[0], + height: display_mode.visible_region()[1], + }, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateDisplayPlaneSurfaceKHR(instance.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Surface { + window: (), + instance: instance.clone(), + surface: surface, + has_swapchain: AtomicBool::new(false), + })) + } + + /// Creates a `Surface` from a Win32 window. + /// + /// The surface's min, max and current extent will always match the window's dimensions. + /// + /// # Safety + /// + /// The caller must ensure that the `hinstance` and the `hwnd` are both correct and stay + /// alive for the entire lifetime of the surface. The `win` parameter can be used to ensure this. + + pub unsafe fn from_hwnd<T, U>(instance: Arc<Instance>, hinstance: *const T, hwnd: *const U, + win: W) + -> Result<Arc<Surface<W>>, SurfaceCreationError> { + let vk = instance.pointers(); + + if !instance.loaded_extensions().khr_win32_surface { + return Err(SurfaceCreationError::MissingExtension { name: "VK_KHR_win32_surface" }); + } + + let surface = { + let infos = vk::Win32SurfaceCreateInfoKHR { + sType: vk::STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, + pNext: ptr::null(), + flags: 0, // reserved + hinstance: hinstance as *mut _, + hwnd: hwnd as *mut _, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateWin32SurfaceKHR(instance.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Surface { + window: win, + instance: instance.clone(), + surface: surface, + has_swapchain: AtomicBool::new(false), + })) + } + + /// Creates a `Surface` from an XCB window. + /// + /// The surface's min, max and current extent will always match the window's dimensions. + /// + /// # Safety + /// + /// The caller must ensure that the `connection` and the `window` are both correct and stay + /// alive for the entire lifetime of the surface. The `win` parameter can be used to ensure this. + pub unsafe fn from_xcb<C>(instance: Arc<Instance>, connection: *const C, window: u32, + win: W) + -> Result<Arc<Surface<W>>, SurfaceCreationError> { + let vk = instance.pointers(); + + if !instance.loaded_extensions().khr_xcb_surface { + return Err(SurfaceCreationError::MissingExtension { name: "VK_KHR_xcb_surface" }); + } + + let surface = { + let infos = vk::XcbSurfaceCreateInfoKHR { + sType: vk::STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR, + pNext: ptr::null(), + flags: 0, // reserved + connection: connection as *mut _, + window: window, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateXcbSurfaceKHR(instance.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Surface { + window: win, + instance: instance.clone(), + surface: surface, + has_swapchain: AtomicBool::new(false), + })) + } + + /// Creates a `Surface` from an Xlib window. + /// + /// The surface's min, max and current extent will always match the window's dimensions. + /// + /// # Safety + /// + /// The caller must ensure that the `display` and the `window` are both correct and stay + /// alive for the entire lifetime of the surface. The `win` parameter can be used to ensure this. + pub unsafe fn from_xlib<D>(instance: Arc<Instance>, display: *const D, window: c_ulong, + win: W) + -> Result<Arc<Surface<W>>, SurfaceCreationError> { + let vk = instance.pointers(); + + if !instance.loaded_extensions().khr_xlib_surface { + return Err(SurfaceCreationError::MissingExtension { name: "VK_KHR_xlib_surface" }); + } + + let surface = { + let infos = vk::XlibSurfaceCreateInfoKHR { + sType: vk::STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, + pNext: ptr::null(), + flags: 0, // reserved + dpy: display as *mut _, + window: window, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateXlibSurfaceKHR(instance.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Surface { + window: win, + instance: instance.clone(), + surface: surface, + has_swapchain: AtomicBool::new(false), + })) + } + + /// Creates a `Surface` from a Wayland window. + /// + /// The window's dimensions will be set to the size of the swapchain. + /// + /// # Safety + /// + /// The caller must ensure that the `display` and the `surface` are both correct and stay + /// alive for the entire lifetime of the surface. The `win` parameter can be used to ensure this. + pub unsafe fn from_wayland<D, S>(instance: Arc<Instance>, display: *const D, + surface: *const S, + win: W) + -> Result<Arc<Surface<W>>, SurfaceCreationError> { + let vk = instance.pointers(); + + if !instance.loaded_extensions().khr_wayland_surface { + return Err(SurfaceCreationError::MissingExtension { name: "VK_KHR_wayland_surface" }); + } + + let surface = { + let infos = vk::WaylandSurfaceCreateInfoKHR { + sType: vk::STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR, + pNext: ptr::null(), + flags: 0, // reserved + display: display as *mut _, + surface: surface as *mut _, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateWaylandSurfaceKHR(instance.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Surface { + window: win, + instance: instance.clone(), + surface: surface, + has_swapchain: AtomicBool::new(false), + })) + } + + /// Creates a `Surface` from an Android window. + /// + /// # Safety + /// + /// The caller must ensure that the `window` is correct and stays alive for the entire + /// lifetime of the surface. The `win` parameter can be used to ensure this. + pub unsafe fn from_anativewindow<T>(instance: Arc<Instance>, window: *const T, + win: W) + -> Result<Arc<Surface<W>>, SurfaceCreationError> { + let vk = instance.pointers(); + + if !instance.loaded_extensions().khr_android_surface { + return Err(SurfaceCreationError::MissingExtension { name: "VK_KHR_android_surface" }); + } + + let surface = { + let infos = vk::AndroidSurfaceCreateInfoKHR { + sType: vk::STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR, + pNext: ptr::null(), + flags: 0, // reserved + window: window as *mut _, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateAndroidSurfaceKHR(instance.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Surface { + window: win, + instance: instance.clone(), + surface: surface, + has_swapchain: AtomicBool::new(false), + })) + } + + /// Creates a `Surface` from an iOS `UIView`. + /// + /// # Safety + /// + /// - The caller must ensure that the `view` is correct and stays alive for the entire + /// lifetime of the surface. The win parameter can be used to ensure this. + /// - The `UIView` must be backed by a `CALayer` instance of type `CAMetalLayer`. + pub unsafe fn from_ios_moltenvk<T>(instance: Arc<Instance>, view: *const T, + win: W) + -> Result<Arc<Surface<W>>, SurfaceCreationError> { + let vk = instance.pointers(); + + if !instance.loaded_extensions().mvk_ios_surface { + return Err(SurfaceCreationError::MissingExtension { name: "VK_MVK_ios_surface" }); + } + + let surface = { + let infos = vk::IOSSurfaceCreateInfoMVK { + sType: vk::STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK, + pNext: ptr::null(), + flags: 0, // reserved + pView: view as *const _, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateIOSSurfaceMVK(instance.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Surface { + window: win, + instance: instance.clone(), + surface: surface, + has_swapchain: AtomicBool::new(false), + })) + } + + /// Creates a `Surface` from a MacOS `NSView`. + /// + /// # Safety + /// + /// - The caller must ensure that the `view` is correct and stays alive for the entire + /// lifetime of the surface. The `win` parameter can be used to ensure this. + /// - The `NSView` must be backed by a `CALayer` instance of type `CAMetalLayer`. + pub unsafe fn from_macos_moltenvk<T>(instance: Arc<Instance>, view: *const T, + win: W) + -> Result<Arc<Surface<W>>, SurfaceCreationError> { + let vk = instance.pointers(); + + if !instance.loaded_extensions().mvk_macos_surface { + return Err(SurfaceCreationError::MissingExtension { name: "VK_MVK_macos_surface" }); + } + + let surface = { + let infos = vk::MacOSSurfaceCreateInfoMVK { + sType: vk::STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK, + pNext: ptr::null(), + flags: 0, // reserved + pView: view as *const _, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateMacOSSurfaceMVK(instance.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Surface { + window: win, + instance: instance.clone(), + surface: surface, + has_swapchain: AtomicBool::new(false), + })) + } + + /// Creates a `Surface` from a `code:nn::code:vi::code:Layer`. + /// + /// # Safety + /// + /// The caller must ensure that the `window` is correct and stays alive for the entire + /// lifetime of the surface. The `win` parameter can be used to ensure this. + pub unsafe fn from_vi_surface<T>(instance: Arc<Instance>, window: *const T, + win: W) + -> Result<Arc<Surface<W>>, SurfaceCreationError> { + let vk = instance.pointers(); + + if !instance.loaded_extensions().nn_vi_surface { + return Err(SurfaceCreationError::MissingExtension { name: "VK_NN_vi_surface" }); + } + + let surface = { + let infos = vk::ViSurfaceCreateInfoNN { + sType: vk::STRUCTURE_TYPE_VI_SURFACE_CREATE_INFO_NN, + pNext: ptr::null(), + flags: 0, // reserved + window: window as *mut _, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateViSurfaceNN(instance.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Arc::new(Surface { + window: win, + instance: instance.clone(), + surface: surface, + has_swapchain: AtomicBool::new(false), + })) + } + + /// Returns true if the given queue family can draw on this surface. + // FIXME: vulkano doesn't check this for the moment! + pub fn is_supported(&self, queue: QueueFamily) -> Result<bool, CapabilitiesError> { + unsafe { + let vk = self.instance.pointers(); + + let mut output = mem::uninitialized(); + check_errors(vk.GetPhysicalDeviceSurfaceSupportKHR(queue + .physical_device() + .internal_object(), + queue.id(), + self.surface, + &mut output))?; + Ok(output != 0) + } + } + + /// Retrieves the capabilities of a surface when used by a certain device. + /// + /// # Panic + /// + /// - Panics if the device and the surface don't belong to the same instance. + /// + pub fn capabilities(&self, device: PhysicalDevice) -> Result<Capabilities, CapabilitiesError> { + unsafe { + assert_eq!(&*self.instance as *const _, + &**device.instance() as *const _, + "Instance mismatch in Surface::capabilities"); + + let vk = self.instance.pointers(); + + let caps = { + let mut out: vk::SurfaceCapabilitiesKHR = mem::uninitialized(); + check_errors(vk.GetPhysicalDeviceSurfaceCapabilitiesKHR(device.internal_object(), + self.surface, + &mut out))?; + out + }; + + let formats = { + let mut num = 0; + check_errors(vk.GetPhysicalDeviceSurfaceFormatsKHR(device.internal_object(), + self.surface, + &mut num, + ptr::null_mut()))?; + + let mut formats = Vec::with_capacity(num as usize); + check_errors(vk.GetPhysicalDeviceSurfaceFormatsKHR(device.internal_object(), + self.surface, + &mut num, + formats.as_mut_ptr()))?; + formats.set_len(num as usize); + formats + }; + + let modes = { + let mut num = 0; + check_errors(vk.GetPhysicalDeviceSurfacePresentModesKHR(device.internal_object(), + self.surface, + &mut num, + ptr::null_mut()))?; + + let mut modes = Vec::with_capacity(num as usize); + check_errors(vk.GetPhysicalDeviceSurfacePresentModesKHR(device.internal_object(), + self.surface, + &mut num, + modes.as_mut_ptr()))?; + modes.set_len(num as usize); + debug_assert!(modes + .iter() + .find(|&&m| m == vk::PRESENT_MODE_FIFO_KHR) + .is_some()); + debug_assert!(modes.iter().count() > 0); + capabilities::supported_present_modes_from_list(modes.into_iter()) + }; + + Ok(Capabilities { + min_image_count: caps.minImageCount, + max_image_count: if caps.maxImageCount == 0 { None } + else { Some(caps.maxImageCount) }, + current_extent: if caps.currentExtent.width == 0xffffffff && + caps.currentExtent.height == 0xffffffff + { + None + } else { + Some([caps.currentExtent.width, caps.currentExtent.height]) + }, + min_image_extent: [caps.minImageExtent.width, caps.minImageExtent.height], + max_image_extent: [caps.maxImageExtent.width, caps.maxImageExtent.height], + max_image_array_layers: caps.maxImageArrayLayers, + supported_transforms: capabilities::surface_transforms_from_bits(caps.supportedTransforms), + current_transform: capabilities::surface_transforms_from_bits(caps.currentTransform).iter().next().unwrap(), // TODO: + supported_composite_alpha: capabilities::supported_composite_alpha_from_bits(caps.supportedCompositeAlpha), + supported_usage_flags: { + let usage = ImageUsage::from_bits(caps.supportedUsageFlags); + debug_assert!(usage.color_attachment); // specs say that this must be true + usage + }, + supported_formats: formats.into_iter().map(|f| { + (Format::from_vulkan_num(f.format).unwrap(), capabilities::color_space_from_num(f.colorSpace)) + }).collect(), + present_modes: modes, + }) + } + } + + #[inline] + pub fn window(&self) -> &W { + &self.window + } + + + /// Returns the instance this surface was created with. + #[inline] + pub fn instance(&self) -> &Arc<Instance> { + &self.instance + } +} + +unsafe impl <W> SurfaceSwapchainLock for Surface<W> { + #[inline] + fn flag(&self) -> &AtomicBool { + &self.has_swapchain + } +} + +unsafe impl <W> VulkanObject for Surface<W> { + type Object = vk::SurfaceKHR; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT; + + #[inline] + fn internal_object(&self) -> vk::SurfaceKHR { + self.surface + } +} + +impl <W> fmt::Debug for Surface<W> { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan surface {:?}>", self.surface) + } +} + +impl <W> Drop for Surface<W> { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.instance.pointers(); + vk.DestroySurfaceKHR(self.instance.internal_object(), self.surface, ptr::null()); + } + } +} + +/// Error that can happen when creating a debug callback. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum SurfaceCreationError { + /// Not enough memory. + OomError(OomError), + + /// The extension required for this function was not enabled. + MissingExtension { + /// Name of the missing extension. + name: &'static str, + }, +} + +impl error::Error for SurfaceCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + SurfaceCreationError::OomError(_) => "not enough memory available", + SurfaceCreationError::MissingExtension { .. } => + "the extension required for this function was not enabled", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + SurfaceCreationError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for SurfaceCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for SurfaceCreationError { + #[inline] + fn from(err: OomError) -> SurfaceCreationError { + SurfaceCreationError::OomError(err) + } +} + +impl From<Error> for SurfaceCreationError { + #[inline] + fn from(err: Error) -> SurfaceCreationError { + match err { + err @ Error::OutOfHostMemory => SurfaceCreationError::OomError(OomError::from(err)), + err @ Error::OutOfDeviceMemory => SurfaceCreationError::OomError(OomError::from(err)), + _ => panic!("unexpected error: {:?}", err), + } + } +} + +/// Error that can happen when retrieving a surface's capabilities. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u32)] +pub enum CapabilitiesError { + /// Not enough memory. + OomError(OomError), + + /// The surface is no longer accessible and must be recreated. + SurfaceLost, +} + +impl error::Error for CapabilitiesError { + #[inline] + fn description(&self) -> &str { + match *self { + CapabilitiesError::OomError(_) => "not enough memory", + CapabilitiesError::SurfaceLost => "the surface is no longer valid", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + CapabilitiesError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for CapabilitiesError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for CapabilitiesError { + #[inline] + fn from(err: OomError) -> CapabilitiesError { + CapabilitiesError::OomError(err) + } +} + +impl From<Error> for CapabilitiesError { + #[inline] + fn from(err: Error) -> CapabilitiesError { + match err { + err @ Error::OutOfHostMemory => CapabilitiesError::OomError(OomError::from(err)), + err @ Error::OutOfDeviceMemory => CapabilitiesError::OomError(OomError::from(err)), + Error::SurfaceLost => CapabilitiesError::SurfaceLost, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +#[cfg(test)] +mod tests { + use std::ptr; + use swapchain::Surface; + use swapchain::SurfaceCreationError; + + #[test] + fn khr_win32_surface_ext_missing() { + let instance = instance!(); + match unsafe { Surface::from_hwnd(instance, ptr::null::<u8>(), ptr::null::<u8>(), ()) } { + Err(SurfaceCreationError::MissingExtension { .. }) => (), + _ => panic!(), + } + } + + #[test] + fn khr_xcb_surface_ext_missing() { + let instance = instance!(); + match unsafe { Surface::from_xcb(instance, ptr::null::<u8>(), 0, ()) } { + Err(SurfaceCreationError::MissingExtension { .. }) => (), + _ => panic!(), + } + } + + #[test] + fn khr_xlib_surface_ext_missing() { + let instance = instance!(); + match unsafe { Surface::from_xlib(instance, ptr::null::<u8>(), 0, ()) } { + Err(SurfaceCreationError::MissingExtension { .. }) => (), + _ => panic!(), + } + } + + #[test] + fn khr_wayland_surface_ext_missing() { + let instance = instance!(); + match unsafe { + Surface::from_wayland(instance, ptr::null::<u8>(), ptr::null::<u8>(), ()) + } { + Err(SurfaceCreationError::MissingExtension { .. }) => (), + _ => panic!(), + } + } + + #[test] + fn khr_android_surface_ext_missing() { + let instance = instance!(); + match unsafe { Surface::from_anativewindow(instance, ptr::null::<u8>(), ()) } { + Err(SurfaceCreationError::MissingExtension { .. }) => (), + _ => panic!(), + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/swapchain.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/swapchain.rs new file mode 100644 index 0000000..b6b6a73 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/swapchain/swapchain.rs @@ -0,0 +1,1191 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::mem; +use std::ptr; +use std::sync::Arc; +use std::sync::Mutex; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; +use std::time::Duration; + +use buffer::BufferAccess; +use command_buffer::submit::SubmitAnyBuilder; +use command_buffer::submit::SubmitPresentBuilder; +use command_buffer::submit::SubmitSemaphoresWaitBuilder; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use format::Format; +use format::FormatDesc; +use image::ImageAccess; +use image::ImageDimensions; +use image::ImageInner; +use image::ImageLayout; +use image::ImageUsage; +use image::swapchain::SwapchainImage; +use image::sys::UnsafeImage; +use swapchain::CapabilitiesError; +use swapchain::ColorSpace; +use swapchain::CompositeAlpha; +use swapchain::PresentMode; +use swapchain::PresentRegion; +use swapchain::Surface; +use swapchain::SurfaceSwapchainLock; +use swapchain::SurfaceTransform; +use sync::AccessCheckError; +use sync::AccessError; +use sync::AccessFlagBits; +use sync::Fence; +use sync::FlushError; +use sync::GpuFuture; +use sync::PipelineStages; +use sync::Semaphore; +use sync::SharingMode; + +use Error; +use OomError; +use Success; +use VulkanObject; +use check_errors; +use vk; + +/// Tries to take ownership of an image in order to draw on it. +/// +/// The function returns the index of the image in the array of images that was returned +/// when creating the swapchain, plus a future that represents the moment when the image will +/// become available from the GPU (which may not be *immediately*). +/// +/// If you try to draw on an image without acquiring it first, the execution will block. (TODO +/// behavior may change). +pub fn acquire_next_image<W>(swapchain: Arc<Swapchain<W>>, timeout: Option<Duration>) + -> Result<(usize, SwapchainAcquireFuture<W>), AcquireError> { + let semaphore = Semaphore::from_pool(swapchain.device.clone())?; + let fence = Fence::from_pool(swapchain.device.clone())?; + + // TODO: propagate `suboptimal` to the user + let AcquiredImage { id, suboptimal } = { + // Check that this is not an old swapchain. From specs: + // > swapchain must not have been replaced by being passed as the + // > VkSwapchainCreateInfoKHR::oldSwapchain value to vkCreateSwapchainKHR + let stale = swapchain.stale.lock().unwrap(); + if *stale { + return Err(AcquireError::OutOfDate); + } + + unsafe { acquire_next_image_raw(&swapchain, timeout, Some(&semaphore), Some(&fence)) }? + }; + + Ok((id, + SwapchainAcquireFuture { + swapchain: swapchain, + semaphore: Some(semaphore), + fence: Some(fence), + image_id: id, + finished: AtomicBool::new(false), + })) +} + +/// Presents an image on the screen. +/// +/// The parameter is the same index as what `acquire_next_image` returned. The image must +/// have been acquired first. +/// +/// The actual behavior depends on the present mode that you passed when creating the +/// swapchain. +pub fn present<F, W>(swapchain: Arc<Swapchain<W>>, before: F, queue: Arc<Queue>, index: usize) + -> PresentFuture<F,W> + where F: GpuFuture +{ + assert!(index < swapchain.images.len()); + + // TODO: restore this check with a dummy ImageAccess implementation + /*let swapchain_image = me.images.lock().unwrap().get(index).unwrap().0.upgrade().unwrap(); // TODO: return error instead + // Normally if `check_image_access` returns false we're supposed to call the `gpu_access` + // function on the image instead. But since we know that this method on `SwapchainImage` + // always returns false anyway (by design), we don't need to do it. + assert!(before.check_image_access(&swapchain_image, ImageLayout::PresentSrc, true, &queue).is_ok()); // TODO: return error instead*/ + + PresentFuture { + previous: before, + queue: queue, + swapchain: swapchain, + image_id: index, + present_region: None, + flushed: AtomicBool::new(false), + finished: AtomicBool::new(false), + } +} + +/// Same as `swapchain::present`, except it allows specifying a present region. +/// Areas outside the present region may be ignored by Vulkan in order to optimize presentation. +/// +/// This is just an optimization hint, as the Vulkan driver is free to ignore the given present region. +/// +/// If `VK_KHR_incremental_present` is not enabled on the device, the parameter will be ignored. +pub fn present_incremental<F, W>(swapchain: Arc<Swapchain<W>>, before: F, queue: Arc<Queue>, + index: usize, present_region: PresentRegion) + -> PresentFuture<F, W> + where F: GpuFuture +{ + assert!(index < swapchain.images.len()); + + // TODO: restore this check with a dummy ImageAccess implementation + /*let swapchain_image = me.images.lock().unwrap().get(index).unwrap().0.upgrade().unwrap(); // TODO: return error instead + // Normally if `check_image_access` returns false we're supposed to call the `gpu_access` + // function on the image instead. But since we know that this method on `SwapchainImage` + // always returns false anyway (by design), we don't need to do it. + assert!(before.check_image_access(&swapchain_image, ImageLayout::PresentSrc, true, &queue).is_ok()); // TODO: return error instead*/ + + PresentFuture { + previous: before, + queue: queue, + swapchain: swapchain, + image_id: index, + present_region: Some(present_region), + flushed: AtomicBool::new(false), + finished: AtomicBool::new(false), + } +} + +/// Contains the swapping system and the images that can be shown on a surface. +pub struct Swapchain<W> { + // The Vulkan device this swapchain was created with. + device: Arc<Device>, + // The surface, which we need to keep alive. + surface: Arc<Surface<W>>, + // The swapchain object. + swapchain: vk::SwapchainKHR, + + // The images of this swapchain. + images: Vec<ImageEntry>, + + // If true, that means we have tried to use this swapchain to recreate a new swapchain. The current + // swapchain can no longer be used for anything except presenting already-acquired images. + // + // We use a `Mutex` instead of an `AtomicBool` because we want to keep that locked while + // we acquire the image. + stale: Mutex<bool>, + + // Parameters passed to the constructor. + num_images: u32, + format: Format, + color_space: ColorSpace, + dimensions: [u32; 2], + layers: u32, + usage: ImageUsage, + sharing: SharingMode, + transform: SurfaceTransform, + alpha: CompositeAlpha, + mode: PresentMode, + clipped: bool, +} + +struct ImageEntry { + // The actual image. + image: UnsafeImage, + // If true, then the image is still in the undefined layout and must be transitioned. + undefined_layout: AtomicBool, +} + +impl <W> Swapchain<W> { + /// Builds a new swapchain. Allocates images who content can be made visible on a surface. + /// + /// See also the `Surface::get_capabilities` function which returns the values that are + /// supported by the implementation. All the parameters that you pass to `Swapchain::new` + /// must be supported. + /// + /// The `clipped` parameter indicates whether the implementation is allowed to discard + /// rendering operations that affect regions of the surface which aren't visible. This is + /// important to take into account if your fragment shader has side-effects or if you want to + /// read back the content of the image afterwards. + /// + /// This function returns the swapchain plus a list of the images that belong to the + /// swapchain. The order in which the images are returned is important for the + /// `acquire_next_image` and `present` functions. + /// + /// # Panic + /// + /// - Panics if the device and the surface don't belong to the same instance. + /// - Panics if `usage` is empty. + /// + // TODO: remove `old_swapchain` parameter and add another function `with_old_swapchain`. + // TODO: add `ColorSpace` parameter + // TODO: isn't it unsafe to take the surface through an Arc when it comes to vulkano-win? + #[inline] + pub fn new<F, S>( + device: Arc<Device>, surface: Arc<Surface<W>>, num_images: u32, format: F, + dimensions: [u32; 2], layers: u32, usage: ImageUsage, sharing: S, + transform: SurfaceTransform, alpha: CompositeAlpha, mode: PresentMode, clipped: bool, + old_swapchain: Option<&Arc<Swapchain<W>>>) + -> Result<(Arc<Swapchain<W>>, Vec<Arc<SwapchainImage<W>>>), SwapchainCreationError> + where F: FormatDesc, + S: Into<SharingMode> + { + Swapchain::new_inner(device, + surface, + num_images, + format.format(), + ColorSpace::SrgbNonLinear, + dimensions, + layers, + usage, + sharing.into(), + transform, + alpha, + mode, + clipped, + old_swapchain.map(|s| &**s)) + } + + /// Recreates the swapchain with new dimensions. + pub fn recreate_with_dimension( + &self, dimensions: [u32; 2]) + -> Result<(Arc<Swapchain<W>>, Vec<Arc<SwapchainImage<W>>>), SwapchainCreationError> { + Swapchain::new_inner(self.device.clone(), + self.surface.clone(), + self.num_images, + self.format, + self.color_space, + dimensions, + self.layers, + self.usage, + self.sharing.clone(), + self.transform, + self.alpha, + self.mode, + self.clipped, + Some(self)) + } + + fn new_inner(device: Arc<Device>, surface: Arc<Surface<W>>, num_images: u32, format: Format, + color_space: ColorSpace, dimensions: [u32; 2], layers: u32, usage: ImageUsage, + sharing: SharingMode, transform: SurfaceTransform, alpha: CompositeAlpha, + mode: PresentMode, clipped: bool, old_swapchain: Option<&Swapchain<W>>) + -> Result<(Arc<Swapchain<W>>, Vec<Arc<SwapchainImage<W>>>), SwapchainCreationError> { + assert_eq!(device.instance().internal_object(), + surface.instance().internal_object()); + + // Checking that the requested parameters match the capabilities. + let capabilities = surface.capabilities(device.physical_device())?; + if num_images < capabilities.min_image_count { + return Err(SwapchainCreationError::UnsupportedMinImagesCount); + } + if let Some(c) = capabilities.max_image_count { + if num_images > c { + return Err(SwapchainCreationError::UnsupportedMaxImagesCount); + } + } + if !capabilities + .supported_formats + .iter() + .any(|&(f, c)| f == format && c == color_space) + { + return Err(SwapchainCreationError::UnsupportedFormat); + } + if dimensions[0] < capabilities.min_image_extent[0] { + return Err(SwapchainCreationError::UnsupportedDimensions); + } + if dimensions[1] < capabilities.min_image_extent[1] { + return Err(SwapchainCreationError::UnsupportedDimensions); + } + if dimensions[0] > capabilities.max_image_extent[0] { + return Err(SwapchainCreationError::UnsupportedDimensions); + } + if dimensions[1] > capabilities.max_image_extent[1] { + return Err(SwapchainCreationError::UnsupportedDimensions); + } + if layers < 1 || layers > capabilities.max_image_array_layers { + return Err(SwapchainCreationError::UnsupportedArrayLayers); + } + if (usage.to_usage_bits() & capabilities.supported_usage_flags.to_usage_bits()) != + usage.to_usage_bits() + { + return Err(SwapchainCreationError::UnsupportedUsageFlags); + } + if !capabilities.supported_transforms.supports(transform) { + return Err(SwapchainCreationError::UnsupportedSurfaceTransform); + } + if !capabilities.supported_composite_alpha.supports(alpha) { + return Err(SwapchainCreationError::UnsupportedCompositeAlpha); + } + if !capabilities.present_modes.supports(mode) { + return Err(SwapchainCreationError::UnsupportedPresentMode); + } + + // If we recreate a swapchain, make sure that the surface is the same. + if let Some(sc) = old_swapchain { + if surface.internal_object() != sc.surface.internal_object() { + return Err(SwapchainCreationError::OldSwapchainSurfaceMismatch); + } + } + + // Checking that the surface doesn't already have a swapchain. + if old_swapchain.is_none() { + let has_already = surface.flag().swap(true, Ordering::AcqRel); + if has_already { + return Err(SwapchainCreationError::SurfaceInUse); + } + } + + if !device.loaded_extensions().khr_swapchain { + return Err(SwapchainCreationError::MissingExtension); + } + + // Required by the specs. + assert_ne!(usage, ImageUsage::none()); + + if let Some(ref old_swapchain) = old_swapchain { + let mut stale = old_swapchain.stale.lock().unwrap(); + + // The swapchain has already been used to create a new one. + if *stale { + return Err(SwapchainCreationError::OldSwapchainAlreadyUsed); + } else { + // According to the documentation of VkSwapchainCreateInfoKHR: + // + // > Upon calling vkCreateSwapchainKHR with a oldSwapchain that is not VK_NULL_HANDLE, + // > any images not acquired by the application may be freed by the implementation, + // > which may occur even if creation of the new swapchain fails. + // + // Therefore, we set stale to true and keep it to true even if the call to `vkCreateSwapchainKHR` below fails. + *stale = true; + } + } + + let vk = device.pointers(); + + let swapchain = unsafe { + let (sh_mode, sh_count, sh_indices) = match sharing { + SharingMode::Exclusive(_) => (vk::SHARING_MODE_EXCLUSIVE, 0, ptr::null()), + SharingMode::Concurrent(ref ids) => (vk::SHARING_MODE_CONCURRENT, + ids.len() as u32, + ids.as_ptr()), + }; + + let infos = vk::SwapchainCreateInfoKHR { + sType: vk::STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, + pNext: ptr::null(), + flags: 0, // reserved + surface: surface.internal_object(), + minImageCount: num_images, + imageFormat: format as u32, + imageColorSpace: color_space as u32, + imageExtent: vk::Extent2D { + width: dimensions[0], + height: dimensions[1], + }, + imageArrayLayers: layers, + imageUsage: usage.to_usage_bits(), + imageSharingMode: sh_mode, + queueFamilyIndexCount: sh_count, + pQueueFamilyIndices: sh_indices, + preTransform: transform as u32, + compositeAlpha: alpha as u32, + presentMode: mode as u32, + clipped: if clipped { vk::TRUE } else { vk::FALSE }, + oldSwapchain: if let Some(ref old_swapchain) = old_swapchain { + old_swapchain.swapchain + } else { + 0 + }, + }; + + let mut output = mem::uninitialized(); + check_errors(vk.CreateSwapchainKHR(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + let image_handles = unsafe { + let mut num = 0; + check_errors(vk.GetSwapchainImagesKHR(device.internal_object(), + swapchain, + &mut num, + ptr::null_mut()))?; + + let mut images = Vec::with_capacity(num as usize); + check_errors(vk.GetSwapchainImagesKHR(device.internal_object(), + swapchain, + &mut num, + images.as_mut_ptr()))?; + images.set_len(num as usize); + images + }; + + let images = image_handles + .into_iter() + .map(|image| unsafe { + let dims = ImageDimensions::Dim2d { + width: dimensions[0], + height: dimensions[1], + array_layers: layers, + cubemap_compatible: false, + }; + + let img = UnsafeImage::from_raw(device.clone(), + image, + usage.to_usage_bits(), + format, + dims, + 1, + 1); + + ImageEntry { + image: img, + undefined_layout: AtomicBool::new(true), + } + }) + .collect::<Vec<_>>(); + + let swapchain = Arc::new(Swapchain { + device: device.clone(), + surface: surface.clone(), + swapchain: swapchain, + images: images, + stale: Mutex::new(false), + num_images: num_images, + format: format, + color_space: color_space, + dimensions: dimensions, + layers: layers, + usage: usage.clone(), + sharing: sharing, + transform: transform, + alpha: alpha, + mode: mode, + clipped: clipped, + }); + + let swapchain_images = unsafe { + let mut swapchain_images = Vec::with_capacity(swapchain.images.len()); + for n in 0 .. swapchain.images.len() { + swapchain_images.push(SwapchainImage::from_raw(swapchain.clone(), n)?); + } + swapchain_images + }; + + Ok((swapchain, swapchain_images)) + } + + /// Returns of the images that belong to this swapchain. + #[inline] + pub fn raw_image(&self, offset: usize) -> Option<ImageInner> { + self.images.get(offset).map(|i| { + ImageInner { + image: &i.image, + first_layer: 0, + num_layers: self.layers as usize, + first_mipmap_level: 0, + num_mipmap_levels: 1, + } + }) + } + + /// Returns the number of images of the swapchain. + /// + /// See the documentation of `Swapchain::new`. + #[inline] + pub fn num_images(&self) -> u32 { + self.images.len() as u32 + } + + /// Returns the format of the images of the swapchain. + /// + /// See the documentation of `Swapchain::new`. + #[inline] + pub fn format(&self) -> Format { + self.format + } + + /// Returns the dimensions of the images of the swapchain. + /// + /// See the documentation of `Swapchain::new`. + #[inline] + pub fn dimensions(&self) -> [u32; 2] { + self.dimensions + } + + /// Returns the number of layers of the images of the swapchain. + /// + /// See the documentation of `Swapchain::new`. + #[inline] + pub fn layers(&self) -> u32 { + self.layers + } + + /// Returns the transform that was passed when creating the swapchain. + /// + /// See the documentation of `Swapchain::new`. + #[inline] + pub fn transform(&self) -> SurfaceTransform { + self.transform + } + + /// Returns the alpha mode that was passed when creating the swapchain. + /// + /// See the documentation of `Swapchain::new`. + #[inline] + pub fn composite_alpha(&self) -> CompositeAlpha { + self.alpha + } + + /// Returns the present mode that was passed when creating the swapchain. + /// + /// See the documentation of `Swapchain::new`. + #[inline] + pub fn present_mode(&self) -> PresentMode { + self.mode + } + + /// Returns the value of `clipped` that was passed when creating the swapchain. + /// + /// See the documentation of `Swapchain::new`. + #[inline] + pub fn clipped(&self) -> bool { + self.clipped + } +} + +unsafe impl<W> VulkanObject for Swapchain<W> { + type Object = vk::SwapchainKHR; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT; + + #[inline] + fn internal_object(&self) -> vk::SwapchainKHR { + self.swapchain + } +} + +unsafe impl<W> DeviceOwned for Swapchain<W> { + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl<W> fmt::Debug for Swapchain<W> { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "<Vulkan swapchain {:?}>", self.swapchain) + } +} + +impl<W> Drop for Swapchain<W> { + #[inline] + fn drop(&mut self) { + unsafe { + let vk = self.device.pointers(); + vk.DestroySwapchainKHR(self.device.internal_object(), self.swapchain, ptr::null()); + self.surface.flag().store(false, Ordering::Release); + } + } +} + +/// Error that can happen when creation a swapchain. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum SwapchainCreationError { + /// Not enough memory. + OomError(OomError), + /// The device was lost. + DeviceLost, + /// The surface was lost. + SurfaceLost, + /// The surface is already used by another swapchain. + SurfaceInUse, + /// The window is already in use by another API. + NativeWindowInUse, + /// The `VK_KHR_swapchain` extension was not enabled. + MissingExtension, + /// Surface mismatch between old and new swapchain. + OldSwapchainSurfaceMismatch, + /// The old swapchain has already been used to recreate another one. + OldSwapchainAlreadyUsed, + /// The requested number of swapchain images is not supported by the surface. + UnsupportedMinImagesCount, + /// The requested number of swapchain images is not supported by the surface. + UnsupportedMaxImagesCount, + /// The requested image format is not supported by the surface. + UnsupportedFormat, + /// The requested dimensions are not supported by the surface. + UnsupportedDimensions, + /// The requested array layers count is not supported by the surface. + UnsupportedArrayLayers, + /// The requested image usage is not supported by the surface. + UnsupportedUsageFlags, + /// The requested surface transform is not supported by the surface. + UnsupportedSurfaceTransform, + /// The requested composite alpha is not supported by the surface. + UnsupportedCompositeAlpha, + /// The requested present mode is not supported by the surface. + UnsupportedPresentMode, +} + +impl error::Error for SwapchainCreationError { + #[inline] + fn description(&self) -> &str { + match *self { + SwapchainCreationError::OomError(_) => { + "not enough memory available" + }, + SwapchainCreationError::DeviceLost => { + "the device was lost" + }, + SwapchainCreationError::SurfaceLost => { + "the surface was lost" + }, + SwapchainCreationError::SurfaceInUse => { + "the surface is already used by another swapchain" + }, + SwapchainCreationError::NativeWindowInUse => { + "the window is already in use by another API" + }, + SwapchainCreationError::MissingExtension => { + "the `VK_KHR_swapchain` extension was not enabled" + }, + SwapchainCreationError::OldSwapchainSurfaceMismatch => { + "surface mismatch between old and new swapchain" + }, + SwapchainCreationError::OldSwapchainAlreadyUsed => { + "old swapchain has already been used to recreate a new one" + }, + SwapchainCreationError::UnsupportedMinImagesCount => { + "the requested number of swapchain images is not supported by the surface" + }, + SwapchainCreationError::UnsupportedMaxImagesCount => { + "the requested number of swapchain images is not supported by the surface" + }, + SwapchainCreationError::UnsupportedFormat => { + "the requested image format is not supported by the surface" + }, + SwapchainCreationError::UnsupportedDimensions => { + "the requested dimensions are not supported by the surface" + }, + SwapchainCreationError::UnsupportedArrayLayers => { + "the requested array layers count is not supported by the surface" + }, + SwapchainCreationError::UnsupportedUsageFlags => { + "the requested image usage is not supported by the surface" + }, + SwapchainCreationError::UnsupportedSurfaceTransform => { + "the requested surface transform is not supported by the surface" + }, + SwapchainCreationError::UnsupportedCompositeAlpha => { + "the requested composite alpha is not supported by the surface" + }, + SwapchainCreationError::UnsupportedPresentMode => { + "the requested present mode is not supported by the surface" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + SwapchainCreationError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for SwapchainCreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for SwapchainCreationError { + #[inline] + fn from(err: Error) -> SwapchainCreationError { + match err { + err @ Error::OutOfHostMemory => { + SwapchainCreationError::OomError(OomError::from(err)) + }, + err @ Error::OutOfDeviceMemory => { + SwapchainCreationError::OomError(OomError::from(err)) + }, + Error::DeviceLost => { + SwapchainCreationError::DeviceLost + }, + Error::SurfaceLost => { + SwapchainCreationError::SurfaceLost + }, + Error::NativeWindowInUse => { + SwapchainCreationError::NativeWindowInUse + }, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +impl From<OomError> for SwapchainCreationError { + #[inline] + fn from(err: OomError) -> SwapchainCreationError { + SwapchainCreationError::OomError(err) + } +} + +impl From<CapabilitiesError> for SwapchainCreationError { + #[inline] + fn from(err: CapabilitiesError) -> SwapchainCreationError { + match err { + CapabilitiesError::OomError(err) => SwapchainCreationError::OomError(err), + CapabilitiesError::SurfaceLost => SwapchainCreationError::SurfaceLost, + } + } +} + +/// Represents the moment when the GPU will have access to a swapchain image. +#[must_use] +pub struct SwapchainAcquireFuture<W> { + swapchain: Arc<Swapchain<W>>, + image_id: usize, + // Semaphore that is signalled when the acquire is complete. Empty if the acquire has already + // happened. + semaphore: Option<Semaphore>, + // Fence that is signalled when the acquire is complete. Empty if the acquire has already + // happened. + fence: Option<Fence>, + finished: AtomicBool, +} + +impl<W> SwapchainAcquireFuture<W> { + /// Returns the index of the image in the list of images returned when creating the swapchain. + #[inline] + pub fn image_id(&self) -> usize { + self.image_id + } + + /// Returns the corresponding swapchain. + #[inline] + pub fn swapchain(&self) -> &Arc<Swapchain<W>> { + &self.swapchain + } +} + +unsafe impl<W> GpuFuture for SwapchainAcquireFuture<W> { + #[inline] + fn cleanup_finished(&mut self) { + } + + #[inline] + unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError> { + if let Some(ref semaphore) = self.semaphore { + let mut sem = SubmitSemaphoresWaitBuilder::new(); + sem.add_wait_semaphore(&semaphore); + Ok(SubmitAnyBuilder::SemaphoresWait(sem)) + } else { + Ok(SubmitAnyBuilder::Empty) + } + } + + #[inline] + fn flush(&self) -> Result<(), FlushError> { + Ok(()) + } + + #[inline] + unsafe fn signal_finished(&self) { + self.finished.store(true, Ordering::SeqCst); + } + + #[inline] + fn queue_change_allowed(&self) -> bool { + true + } + + #[inline] + fn queue(&self) -> Option<Arc<Queue>> { + None + } + + #[inline] + fn check_buffer_access( + &self, _: &BufferAccess, _: bool, _: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + Err(AccessCheckError::Unknown) + } + + #[inline] + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, _: bool, _: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + let swapchain_image = self.swapchain.raw_image(self.image_id).unwrap(); + if swapchain_image.image.internal_object() != image.inner().image.internal_object() { + return Err(AccessCheckError::Unknown); + } + + if self.swapchain.images[self.image_id] + .undefined_layout + .load(Ordering::Relaxed) && layout != ImageLayout::Undefined + { + return Err(AccessCheckError::Denied(AccessError::ImageNotInitialized { + requested: layout, + })); + } + + if layout != ImageLayout::Undefined && layout != ImageLayout::PresentSrc { + return Err(AccessCheckError::Denied(AccessError::UnexpectedImageLayout { + allowed: ImageLayout::PresentSrc, + requested: layout, + })); + } + + Ok(None) + } +} + +unsafe impl<W> DeviceOwned for SwapchainAcquireFuture<W> { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.swapchain.device + } +} + +impl<W> Drop for SwapchainAcquireFuture<W> { + fn drop(&mut self) { + if !*self.finished.get_mut() { + if let Some(ref fence) = self.fence { + fence.wait(None).unwrap(); // TODO: handle error? + self.semaphore = None; + } + + } else { + // We make sure that the fence is signalled. This also silences an error from the + // validation layers about using a fence whose state hasn't been checked (even though + // we know for sure that it must've been signalled). + debug_assert!({ + let dur = Some(Duration::new(0, 0)); + self.fence + .as_ref() + .map(|f| f.wait(dur).is_ok()) + .unwrap_or(true) + }); + } + + // TODO: if this future is destroyed without being presented, then eventually acquiring + // a new image will block forever ; difficulty: hard + } +} + +/// Error that can happen when calling `acquire_next_image`. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(u32)] +pub enum AcquireError { + /// Not enough memory. + OomError(OomError), + + /// The connection to the device has been lost. + DeviceLost, + + /// The timeout of the function has been reached before an image was available. + Timeout, + + /// The surface is no longer accessible and must be recreated. + SurfaceLost, + + /// The surface has changed in a way that makes the swapchain unusable. You must query the + /// surface's new properties and recreate a new swapchain if you want to continue drawing. + OutOfDate, +} + +impl error::Error for AcquireError { + #[inline] + fn description(&self) -> &str { + match *self { + AcquireError::OomError(_) => "not enough memory", + AcquireError::DeviceLost => "the connection to the device has been lost", + AcquireError::Timeout => "no image is available for acquiring yet", + AcquireError::SurfaceLost => "the surface of this swapchain is no longer valid", + AcquireError::OutOfDate => "the swapchain needs to be recreated", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + AcquireError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for AcquireError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<OomError> for AcquireError { + #[inline] + fn from(err: OomError) -> AcquireError { + AcquireError::OomError(err) + } +} + +impl From<Error> for AcquireError { + #[inline] + fn from(err: Error) -> AcquireError { + match err { + err @ Error::OutOfHostMemory => AcquireError::OomError(OomError::from(err)), + err @ Error::OutOfDeviceMemory => AcquireError::OomError(OomError::from(err)), + Error::DeviceLost => AcquireError::DeviceLost, + Error::SurfaceLost => AcquireError::SurfaceLost, + Error::OutOfDate => AcquireError::OutOfDate, + _ => panic!("unexpected error: {:?}", err), + } + } +} + +/// Represents a swapchain image being presented on the screen. +#[must_use = "Dropping this object will immediately block the thread until the GPU has finished processing the submission"] +pub struct PresentFuture<P, W> + where P: GpuFuture +{ + previous: P, + queue: Arc<Queue>, + swapchain: Arc<Swapchain<W>>, + image_id: usize, + present_region: Option<PresentRegion>, + // True if `flush()` has been called on the future, which means that the present command has + // been submitted. + flushed: AtomicBool, + // True if `signal_finished()` has been called on the future, which means that the future has + // been submitted and has already been processed by the GPU. + finished: AtomicBool, +} + +impl<P, W> PresentFuture<P, W> + where P: GpuFuture +{ + /// Returns the index of the image in the list of images returned when creating the swapchain. + #[inline] + pub fn image_id(&self) -> usize { + self.image_id + } + + /// Returns the corresponding swapchain. + #[inline] + pub fn swapchain(&self) -> &Arc<Swapchain<W>> { + &self.swapchain + } +} + +unsafe impl<P, W> GpuFuture for PresentFuture<P, W> + where P: GpuFuture +{ + #[inline] + fn cleanup_finished(&mut self) { + self.previous.cleanup_finished(); + } + + #[inline] + unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError> { + if self.flushed.load(Ordering::SeqCst) { + return Ok(SubmitAnyBuilder::Empty); + } + + let queue = self.previous.queue().map(|q| q.clone()); + + // TODO: if the swapchain image layout is not PRESENT, should add a transition command + // buffer + + Ok(match self.previous.build_submission()? { + SubmitAnyBuilder::Empty => { + let mut builder = SubmitPresentBuilder::new(); + builder.add_swapchain(&self.swapchain, + self.image_id as u32, + self.present_region.as_ref()); + SubmitAnyBuilder::QueuePresent(builder) + }, + SubmitAnyBuilder::SemaphoresWait(sem) => { + let mut builder: SubmitPresentBuilder = sem.into(); + builder.add_swapchain(&self.swapchain, + self.image_id as u32, + self.present_region.as_ref()); + SubmitAnyBuilder::QueuePresent(builder) + }, + SubmitAnyBuilder::CommandBuffer(cb) => { + // submit the command buffer by flushing previous. + // Since the implementation should remember being flushed it's safe to call build_submission multiple times + self.previous.flush()?; + + let mut builder = SubmitPresentBuilder::new(); + builder.add_swapchain(&self.swapchain, + self.image_id as u32, + self.present_region.as_ref()); + SubmitAnyBuilder::QueuePresent(builder) + }, + SubmitAnyBuilder::BindSparse(cb) => { + // submit the command buffer by flushing previous. + // Since the implementation should remember being flushed it's safe to call build_submission multiple times + self.previous.flush()?; + + let mut builder = SubmitPresentBuilder::new(); + builder.add_swapchain(&self.swapchain, + self.image_id as u32, + self.present_region.as_ref()); + SubmitAnyBuilder::QueuePresent(builder) + }, + SubmitAnyBuilder::QueuePresent(present) => { + unimplemented!() // TODO: + /*present.submit(); + let mut builder = SubmitPresentBuilder::new(); + builder.add_swapchain(self.command_buffer.inner(), self.image_id); + SubmitAnyBuilder::CommandBuffer(builder)*/ + }, + }) + } + + #[inline] + fn flush(&self) -> Result<(), FlushError> { + unsafe { + // If `flushed` already contains `true`, then `build_submission` will return `Empty`. + + match self.build_submission()? { + SubmitAnyBuilder::Empty => {}, + SubmitAnyBuilder::QueuePresent(present) => { + present.submit(&self.queue)?; + }, + _ => unreachable!(), + } + + self.flushed.store(true, Ordering::SeqCst); + Ok(()) + } + } + + #[inline] + unsafe fn signal_finished(&self) { + self.flushed.store(true, Ordering::SeqCst); + self.finished.store(true, Ordering::SeqCst); + self.previous.signal_finished(); + } + + #[inline] + fn queue_change_allowed(&self) -> bool { + false + } + + #[inline] + fn queue(&self) -> Option<Arc<Queue>> { + debug_assert!(match self.previous.queue() { + None => true, + Some(q) => q.is_same(&self.queue), + }); + + Some(self.queue.clone()) + } + + #[inline] + fn check_buffer_access( + &self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + self.previous.check_buffer_access(buffer, exclusive, queue) + } + + #[inline] + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + let swapchain_image = self.swapchain.raw_image(self.image_id).unwrap(); + if swapchain_image.image.internal_object() == image.inner().image.internal_object() { + // This future presents the swapchain image, which "unlocks" it. Therefore any attempt + // to use this swapchain image afterwards shouldn't get granted automatic access. + // Instead any attempt to access the image afterwards should get an authorization from + // a later swapchain acquire future. Hence why we return `Unknown` here. + Err(AccessCheckError::Unknown) + } else { + self.previous + .check_image_access(image, layout, exclusive, queue) + } + } +} + +unsafe impl<P, W> DeviceOwned for PresentFuture<P, W> + where P: GpuFuture +{ + #[inline] + fn device(&self) -> &Arc<Device> { + self.queue.device() + } +} + +impl<P, W> Drop for PresentFuture<P, W> + where P: GpuFuture +{ + fn drop(&mut self) { + unsafe { + if !*self.finished.get_mut() { + match self.flush() { + Ok(()) => { + // Block until the queue finished. + self.queue().unwrap().wait().unwrap(); + self.previous.signal_finished(); + }, + Err(_) => { + // In case of error we simply do nothing, as there's nothing to do + // anyway. + }, + } + } + } + } +} + +pub struct AcquiredImage { + pub id: usize, + pub suboptimal: bool, +} + +/// Unsafe variant of `acquire_next_image`. +/// +/// # Safety +/// +/// - The semaphore and/or the fence must be kept alive until it is signaled. +/// - The swapchain must not have been replaced by being passed as the old swapchain when creating +/// a new one. +pub unsafe fn acquire_next_image_raw<W>(swapchain: &Swapchain<W>, timeout: Option<Duration>, + semaphore: Option<&Semaphore>, fence: Option<&Fence>) + -> Result<AcquiredImage, AcquireError> { + let vk = swapchain.device.pointers(); + + let timeout_ns = if let Some(timeout) = timeout { + timeout + .as_secs() + .saturating_mul(1_000_000_000) + .saturating_add(timeout.subsec_nanos() as u64) + } else { + u64::max_value() + }; + + let mut out = mem::uninitialized(); + let r = + check_errors(vk.AcquireNextImageKHR(swapchain.device.internal_object(), + swapchain.swapchain, + timeout_ns, + semaphore.map(|s| s.internal_object()).unwrap_or(0), + fence.map(|f| f.internal_object()).unwrap_or(0), + &mut out))?; + + let (id, suboptimal) = match r { + Success::Success => (out as usize, false), + Success::Suboptimal => (out as usize, true), + Success::NotReady => return Err(AcquireError::Timeout), + Success::Timeout => return Err(AcquireError::Timeout), + s => panic!("unexpected success value: {:?}", s), + }; + + Ok(AcquiredImage { id, suboptimal }) +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sync/event.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/event.rs new file mode 100644 index 0000000..4158aca --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/event.rs @@ -0,0 +1,240 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::mem; +use std::ptr; +use std::sync::Arc; + +use OomError; +use Success; +use VulkanObject; +use check_errors; +use device::Device; +use device::DeviceOwned; +use vk; + +/// Used to block the GPU execution until an event on the CPU occurs. +/// +/// Note that Vulkan implementations may have limits on how long a command buffer will wait for an +/// event to be signaled, in order to avoid interfering with progress of other clients of the GPU. +/// If the event isn't signaled within these limits, results are undefined and may include +/// device loss. +#[derive(Debug)] +pub struct Event { + // The event. + event: vk::Event, + // The device. + device: Arc<Device>, + must_put_in_pool: bool, +} + +impl Event { + /// Takes an event from the vulkano-provided event pool. + /// If the pool is empty, a new event will be allocated. + /// Upon `drop`, the event is put back into the pool. + /// + /// For most applications, using the event pool should be preferred, + /// in order to avoid creating new events every frame. + pub fn from_pool(device: Arc<Device>) -> Result<Event, OomError> { + let maybe_raw_event = device.event_pool().lock().unwrap().pop(); + match maybe_raw_event { + Some(raw_event) => { + unsafe { + // Make sure the event isn't signaled + let vk = device.pointers(); + check_errors(vk.ResetEvent(device.internal_object(), raw_event))?; + } + Ok(Event { + event: raw_event, + device: device, + must_put_in_pool: true, + }) + }, + None => { + // Pool is empty, alloc new event + Event::alloc_impl(device, true) + }, + } + } + + /// Builds a new event. + #[inline] + pub fn alloc(device: Arc<Device>) -> Result<Event, OomError> { + Event::alloc_impl(device, false) + } + + fn alloc_impl(device: Arc<Device>, must_put_in_pool: bool) -> Result<Event, OomError> { + let event = unsafe { + // since the creation is constant, we use a `static` instead of a struct on the stack + static mut INFOS: vk::EventCreateInfo = vk::EventCreateInfo { + sType: vk::STRUCTURE_TYPE_EVENT_CREATE_INFO, + pNext: 0 as *const _, //ptr::null(), + flags: 0, // reserved + }; + + let mut output = mem::uninitialized(); + let vk = device.pointers(); + check_errors(vk.CreateEvent(device.internal_object(), + &INFOS, + ptr::null(), + &mut output))?; + output + }; + + Ok(Event { + device: device, + event: event, + must_put_in_pool: must_put_in_pool, + }) + } + + /// Returns true if the event is signaled. + #[inline] + pub fn signaled(&self) -> Result<bool, OomError> { + unsafe { + let vk = self.device.pointers(); + let result = check_errors(vk.GetEventStatus(self.device.internal_object(), + self.event))?; + match result { + Success::EventSet => Ok(true), + Success::EventReset => Ok(false), + _ => unreachable!(), + } + } + } + + /// See the docs of set(). + #[inline] + pub fn set_raw(&mut self) -> Result<(), OomError> { + unsafe { + let vk = self.device.pointers(); + check_errors(vk.SetEvent(self.device.internal_object(), self.event))?; + Ok(()) + } + } + + /// Changes the `Event` to the signaled state. + /// + /// If a command buffer is waiting on this event, it is then unblocked. + /// + /// # Panic + /// + /// - Panics if the device or host ran out of memory. + /// + #[inline] + pub fn set(&mut self) { + self.set_raw().unwrap(); + } + + /// See the docs of reset(). + #[inline] + pub fn reset_raw(&mut self) -> Result<(), OomError> { + unsafe { + let vk = self.device.pointers(); + check_errors(vk.ResetEvent(self.device.internal_object(), self.event))?; + Ok(()) + } + } + + /// Changes the `Event` to the unsignaled state. + /// + /// # Panic + /// + /// - Panics if the device or host ran out of memory. + /// + #[inline] + pub fn reset(&mut self) { + self.reset_raw().unwrap(); + } +} + +unsafe impl DeviceOwned for Event { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +unsafe impl VulkanObject for Event { + type Object = vk::Event; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT; + + #[inline] + fn internal_object(&self) -> vk::Event { + self.event + } +} + +impl Drop for Event { + #[inline] + fn drop(&mut self) { + unsafe { + if self.must_put_in_pool { + let raw_event = self.event; + self.device.event_pool().lock().unwrap().push(raw_event); + } else { + let vk = self.device.pointers(); + vk.DestroyEvent(self.device.internal_object(), self.event, ptr::null()); + } + } + } +} + +#[cfg(test)] +mod tests { + use VulkanObject; + use sync::Event; + + #[test] + fn event_create() { + let (device, _) = gfx_dev_and_queue!(); + let event = Event::alloc(device).unwrap(); + assert!(!event.signaled().unwrap()); + } + + #[test] + fn event_set() { + let (device, _) = gfx_dev_and_queue!(); + let mut event = Event::alloc(device).unwrap(); + assert!(!event.signaled().unwrap()); + + event.set(); + assert!(event.signaled().unwrap()); + } + + #[test] + fn event_reset() { + let (device, _) = gfx_dev_and_queue!(); + + let mut event = Event::alloc(device).unwrap(); + event.set(); + assert!(event.signaled().unwrap()); + + event.reset(); + assert!(!event.signaled().unwrap()); + } + + #[test] + fn event_pool() { + let (device, _) = gfx_dev_and_queue!(); + + assert_eq!(device.event_pool().lock().unwrap().len(), 0); + let event1_internal_obj = { + let event = Event::from_pool(device.clone()).unwrap(); + assert_eq!(device.event_pool().lock().unwrap().len(), 0); + event.internal_object() + }; + + assert_eq!(device.event_pool().lock().unwrap().len(), 1); + let event2 = Event::from_pool(device.clone()).unwrap(); + assert_eq!(device.event_pool().lock().unwrap().len(), 0); + assert_eq!(event2.internal_object(), event1_internal_obj); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sync/fence.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/fence.rs new file mode 100644 index 0000000..7b5a88c --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/fence.rs @@ -0,0 +1,475 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use smallvec::SmallVec; +use std::error; +use std::fmt; +use std::mem; +use std::ptr; +use std::sync::Arc; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; +use std::time::Duration; + +use Error; +use OomError; +use SafeDeref; +use Success; +use VulkanObject; +use check_errors; +use device::Device; +use device::DeviceOwned; +use vk; + +/// A fence is used to know when a command buffer submission has finished its execution. +/// +/// When a command buffer accesses a resource, you have to ensure that the CPU doesn't access +/// the same resource simultaneously (except for concurrent reads). Therefore in order to know +/// when the CPU can access a resource again, a fence has to be used. +#[derive(Debug)] +pub struct Fence<D = Arc<Device>> + where D: SafeDeref<Target = Device> +{ + fence: vk::Fence, + + device: D, + + // If true, we know that the `Fence` is signaled. If false, we don't know. + // This variable exists so that we don't need to call `vkGetFenceStatus` or `vkWaitForFences` + // multiple times. + signaled: AtomicBool, + + // Indicates whether this fence was taken from the fence pool. + // If true, will be put back into fence pool on drop. + must_put_in_pool: bool, +} + +impl<D> Fence<D> + where D: SafeDeref<Target = Device> +{ + /// Takes a fence from the vulkano-provided fence pool. + /// If the pool is empty, a new fence will be allocated. + /// Upon `drop`, the fence is put back into the pool. + /// + /// For most applications, using the fence pool should be preferred, + /// in order to avoid creating new fences every frame. + pub fn from_pool(device: D) -> Result<Fence<D>, OomError> { + let maybe_raw_fence = device.fence_pool().lock().unwrap().pop(); + match maybe_raw_fence { + Some(raw_fence) => { + unsafe { + // Make sure the fence isn't signaled + let vk = device.pointers(); + check_errors(vk.ResetFences(device.internal_object(), 1, &raw_fence))?; + } + Ok(Fence { + fence: raw_fence, + device: device, + signaled: AtomicBool::new(false), + must_put_in_pool: true, + }) + }, + None => { + // Pool is empty, alloc new fence + Fence::alloc_impl(device, false, true) + }, + } + } + + /// Builds a new fence. + #[inline] + pub fn alloc(device: D) -> Result<Fence<D>, OomError> { + Fence::alloc_impl(device, false, false) + } + + /// Builds a new fence in signaled state. + #[inline] + pub fn alloc_signaled(device: D) -> Result<Fence<D>, OomError> { + Fence::alloc_impl(device, true, false) + } + + fn alloc_impl(device: D, signaled: bool, must_put_in_pool: bool) -> Result<Fence<D>, OomError> { + let fence = unsafe { + let infos = vk::FenceCreateInfo { + sType: vk::STRUCTURE_TYPE_FENCE_CREATE_INFO, + pNext: ptr::null(), + flags: if signaled { + vk::FENCE_CREATE_SIGNALED_BIT + } else { + 0 + }, + }; + + let vk = device.pointers(); + let mut output = mem::uninitialized(); + check_errors(vk.CreateFence(device.internal_object(), + &infos, + ptr::null(), + &mut output))?; + output + }; + + Ok(Fence { + fence: fence, + device: device, + signaled: AtomicBool::new(signaled), + must_put_in_pool: must_put_in_pool, + }) + } + + /// Returns true if the fence is signaled. + #[inline] + pub fn ready(&self) -> Result<bool, OomError> { + unsafe { + if self.signaled.load(Ordering::Relaxed) { + return Ok(true); + } + + let vk = self.device.pointers(); + let result = check_errors(vk.GetFenceStatus(self.device.internal_object(), + self.fence))?; + match result { + Success::Success => { + self.signaled.store(true, Ordering::Relaxed); + Ok(true) + }, + Success::NotReady => Ok(false), + _ => unreachable!(), + } + } + } + + /// Waits until the fence is signaled, or at least until the timeout duration has elapsed. + /// + /// Returns `Ok` if the fence is now signaled. Returns `Err` if the timeout was reached instead. + /// + /// If you pass a duration of 0, then the function will return without blocking. + pub fn wait(&self, timeout: Option<Duration>) -> Result<(), FenceWaitError> { + unsafe { + if self.signaled.load(Ordering::Relaxed) { + return Ok(()); + } + + let timeout_ns = if let Some(timeout) = timeout { + timeout + .as_secs() + .saturating_mul(1_000_000_000) + .saturating_add(timeout.subsec_nanos() as u64) + } else { + u64::max_value() + }; + + let vk = self.device.pointers(); + let r = check_errors(vk.WaitForFences(self.device.internal_object(), + 1, + &self.fence, + vk::TRUE, + timeout_ns))?; + + match r { + Success::Success => { + self.signaled.store(true, Ordering::Relaxed); + Ok(()) + }, + Success::Timeout => { + Err(FenceWaitError::Timeout) + }, + _ => unreachable!(), + } + } + } + + /// Waits for multiple fences at once. + /// + /// # Panic + /// + /// Panics if not all fences belong to the same device. + pub fn multi_wait<'a, I>(iter: I, timeout: Option<Duration>) -> Result<(), FenceWaitError> + where I: IntoIterator<Item = &'a Fence<D>>, + D: 'a + { + let mut device: Option<&Device> = None; + + let fences: SmallVec<[vk::Fence; 8]> = iter.into_iter() + .filter_map(|fence| { + match &mut device { + dev @ &mut None => *dev = Some(&*fence.device), + &mut Some(ref dev) + if &**dev as *const Device == &*fence.device as *const Device => {}, + _ => panic!("Tried to wait for multiple fences that didn't belong to the \ + same device"), + }; + + if fence.signaled.load(Ordering::Relaxed) { + None + } else { + Some(fence.fence) + } + }) + .collect(); + + let timeout_ns = if let Some(timeout) = timeout { + timeout + .as_secs() + .saturating_mul(1_000_000_000) + .saturating_add(timeout.subsec_nanos() as u64) + } else { + u64::max_value() + }; + + let r = if let Some(device) = device { + unsafe { + let vk = device.pointers(); + check_errors(vk.WaitForFences(device.internal_object(), + fences.len() as u32, + fences.as_ptr(), + vk::TRUE, + timeout_ns))? + } + } else { + return Ok(()); + }; + + match r { + Success::Success => Ok(()), + Success::Timeout => Err(FenceWaitError::Timeout), + _ => unreachable!(), + } + } + + /// Resets the fence. + // This function takes a `&mut self` because the Vulkan API requires that the fence be + // externally synchronized. + #[inline] + pub fn reset(&mut self) -> Result<(), OomError> { + unsafe { + let vk = self.device.pointers(); + check_errors(vk.ResetFences(self.device.internal_object(), 1, &self.fence))?; + self.signaled.store(false, Ordering::Relaxed); + Ok(()) + } + } + + /// Resets multiple fences at once. + /// + /// # Panic + /// + /// - Panics if not all fences belong to the same device. + /// + pub fn multi_reset<'a, I>(iter: I) -> Result<(), OomError> + where I: IntoIterator<Item = &'a mut Fence<D>>, + D: 'a + { + let mut device: Option<&Device> = None; + + let fences: SmallVec<[vk::Fence; 8]> = iter.into_iter() + .map(|fence| { + match &mut device { + dev @ &mut None => *dev = Some(&*fence.device), + &mut Some(ref dev) + if &**dev as *const Device == &*fence.device as *const Device => {}, + _ => panic!("Tried to reset multiple fences that didn't belong to the same \ + device"), + }; + + fence.signaled.store(false, Ordering::Relaxed); + fence.fence + }) + .collect(); + + if let Some(device) = device { + unsafe { + let vk = device.pointers(); + check_errors(vk.ResetFences(device.internal_object(), + fences.len() as u32, + fences.as_ptr()))?; + } + } + Ok(()) + } +} + +unsafe impl DeviceOwned for Fence { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +unsafe impl<D> VulkanObject for Fence<D> + where D: SafeDeref<Target = Device> +{ + type Object = vk::Fence; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT; + + #[inline] + fn internal_object(&self) -> vk::Fence { + self.fence + } +} + +impl<D> Drop for Fence<D> + where D: SafeDeref<Target = Device> +{ + #[inline] + fn drop(&mut self) { + unsafe { + if self.must_put_in_pool { + let raw_fence = self.fence; + self.device.fence_pool().lock().unwrap().push(raw_fence); + } else { + let vk = self.device.pointers(); + vk.DestroyFence(self.device.internal_object(), self.fence, ptr::null()); + } + } + } +} + +/// Error that can be returned when waiting on a fence. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum FenceWaitError { + /// Not enough memory to complete the wait. + OomError(OomError), + + /// The specified timeout wasn't long enough. + Timeout, + + /// The device has been lost. + DeviceLostError, +} + +impl error::Error for FenceWaitError { + #[inline] + fn description(&self) -> &str { + match *self { + FenceWaitError::OomError(_) => "no memory available", + FenceWaitError::Timeout => "the timeout has been reached", + FenceWaitError::DeviceLostError => "the device was lost", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + FenceWaitError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for FenceWaitError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<Error> for FenceWaitError { + #[inline] + fn from(err: Error) -> FenceWaitError { + match err { + Error::OutOfHostMemory => FenceWaitError::OomError(From::from(err)), + Error::OutOfDeviceMemory => FenceWaitError::OomError(From::from(err)), + Error::DeviceLost => FenceWaitError::DeviceLostError, + _ => panic!("Unexpected error value: {}", err as i32), + } + } +} + +#[cfg(test)] +mod tests { + use VulkanObject; + use std::time::Duration; + use sync::Fence; + + #[test] + fn fence_create() { + let (device, _) = gfx_dev_and_queue!(); + + let fence = Fence::alloc(device.clone()).unwrap(); + assert!(!fence.ready().unwrap()); + } + + #[test] + fn fence_create_signaled() { + let (device, _) = gfx_dev_and_queue!(); + + let fence = Fence::alloc_signaled(device.clone()).unwrap(); + assert!(fence.ready().unwrap()); + } + + #[test] + fn fence_signaled_wait() { + let (device, _) = gfx_dev_and_queue!(); + + let fence = Fence::alloc_signaled(device.clone()).unwrap(); + fence.wait(Some(Duration::new(0, 10))).unwrap(); + } + + #[test] + fn fence_reset() { + let (device, _) = gfx_dev_and_queue!(); + + let mut fence = Fence::alloc_signaled(device.clone()).unwrap(); + fence.reset().unwrap(); + assert!(!fence.ready().unwrap()); + } + + #[test] + fn multiwait_different_devices() { + let (device1, _) = gfx_dev_and_queue!(); + let (device2, _) = gfx_dev_and_queue!(); + + assert_should_panic!("Tried to wait for multiple fences that didn't belong \ + to the same device", + { + let fence1 = Fence::alloc_signaled(device1.clone()).unwrap(); + let fence2 = Fence::alloc_signaled(device2.clone()).unwrap(); + + let _ = Fence::multi_wait([&fence1, &fence2].iter().cloned(), + Some(Duration::new(0, 10))); + }); + } + + #[test] + fn multireset_different_devices() { + use std::iter::once; + + let (device1, _) = gfx_dev_and_queue!(); + let (device2, _) = gfx_dev_and_queue!(); + + assert_should_panic!("Tried to reset multiple fences that didn't belong \ + to the same device", + { + let mut fence1 = Fence::alloc_signaled(device1.clone()).unwrap(); + let mut fence2 = Fence::alloc_signaled(device2.clone()).unwrap(); + + let _ = Fence::multi_reset(once(&mut fence1) + .chain(once(&mut fence2))); + }); + } + + #[test] + fn fence_pool() { + let (device, _) = gfx_dev_and_queue!(); + + assert_eq!(device.fence_pool().lock().unwrap().len(), 0); + let fence1_internal_obj = { + let fence = Fence::from_pool(device.clone()).unwrap(); + assert_eq!(device.fence_pool().lock().unwrap().len(), 0); + fence.internal_object() + }; + + assert_eq!(device.fence_pool().lock().unwrap().len(), 1); + let fence2 = Fence::from_pool(device.clone()).unwrap(); + assert_eq!(device.fence_pool().lock().unwrap().len(), 0); + assert_eq!(fence2.internal_object(), fence1_internal_obj); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/fence_signal.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/fence_signal.rs new file mode 100644 index 0000000..b6cd3d9 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/fence_signal.rs @@ -0,0 +1,505 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::mem; +use std::sync::Arc; +use std::sync::Mutex; +use std::sync::MutexGuard; +use std::time::Duration; + +use buffer::BufferAccess; +use command_buffer::submit::SubmitAnyBuilder; +use command_buffer::submit::SubmitCommandBufferBuilder; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use image::ImageLayout; +use sync::AccessCheckError; +use sync::AccessFlagBits; +use sync::Fence; +use sync::FlushError; +use sync::GpuFuture; +use sync::PipelineStages; + +/// Builds a new fence signal future. +#[inline] +pub fn then_signal_fence<F>(future: F, behavior: FenceSignalFutureBehavior) -> FenceSignalFuture<F> + where F: GpuFuture +{ + let device = future.device().clone(); + + assert!(future.queue().is_some()); // TODO: document + + let fence = Fence::from_pool(device.clone()).unwrap(); + FenceSignalFuture { + device: device, + state: Mutex::new(FenceSignalFutureState::Pending(future, fence)), + behavior: behavior, + } +} + +/// Describes the behavior of the future if you submit something after it. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum FenceSignalFutureBehavior { + /// Continue execution on the same queue. + Continue, + /// Wait for the fence to be signalled before submitting any further operation. + Block { + /// How long to block the current thread. + timeout: Option<Duration>, + }, +} + +/// Represents a fence being signaled after a previous event. +/// +/// Contrary to most other future types, it is possible to block the current thread until the event +/// happens. This is done by calling the `wait()` function. +/// +/// Also note that the `GpuFuture` trait is implemented on `Arc<FenceSignalFuture<_>>`. +/// This means that you can put this future in an `Arc` and keep a copy of it somewhere in order +/// to know when the execution reached that point. +/// +/// ``` +/// use std::sync::Arc; +/// use vulkano::sync::GpuFuture; +/// +/// # let future: Box<GpuFuture> = return; +/// // Assuming you have a chain of operations, like this: +/// // let future = ... +/// // .then_execute(foo) +/// // .then_execute(bar) +/// +/// // You can signal a fence at this point of the chain, and put the future in an `Arc`. +/// let fence_signal = Arc::new(future.then_signal_fence()); +/// +/// // And then continue the chain: +/// // fence_signal.clone() +/// // .then_execute(baz) +/// // .then_execute(qux) +/// +/// // Later you can wait until you reach the point of `fence_signal`: +/// fence_signal.wait(None).unwrap(); +/// ``` +#[must_use = "Dropping this object will immediately block the thread until the GPU has finished \ + processing the submission"] +pub struct FenceSignalFuture<F> + where F: GpuFuture +{ + // Current state. See the docs of `FenceSignalFutureState`. + state: Mutex<FenceSignalFutureState<F>>, + // The device of the future. + device: Arc<Device>, + behavior: FenceSignalFutureBehavior, +} + +// This future can be in three different states: pending (ie. newly-created), submitted (ie. the +// command that submits the fence has been submitted), or cleaned (ie. the previous future has +// been dropped). +enum FenceSignalFutureState<F> { + // Newly-created. Not submitted yet. + Pending(F, Fence), + + // Partially submitted to the queue. Only happens in situations where submitting requires two + // steps, and when the first step succeeded while the second step failed. + // + // Note that if there's ever a submit operation that needs three steps we will need to rework + // this code, as it was designed for two-step operations only. + PartiallyFlushed(F, Fence), + + // Submitted to the queue. + Flushed(F, Fence), + + // The submission is finished. The previous future and the fence have been cleaned. + Cleaned, + + // A function panicked while the state was being modified. Should never happen. + Poisoned, +} + +impl<F> FenceSignalFuture<F> + where F: GpuFuture +{ + /// Blocks the current thread until the fence is signaled by the GPU. Performs a flush if + /// necessary. + /// + /// If `timeout` is `None`, then the wait is infinite. Otherwise the thread will unblock after + /// the specified timeout has elapsed and an error will be returned. + /// + /// If the wait is successful, this function also cleans any resource locked by previous + /// submissions. + pub fn wait(&self, timeout: Option<Duration>) -> Result<(), FlushError> { + let mut state = self.state.lock().unwrap(); + + self.flush_impl(&mut state)?; + + match mem::replace(&mut *state, FenceSignalFutureState::Cleaned) { + FenceSignalFutureState::Flushed(previous, fence) => { + fence.wait(timeout)?; + unsafe { + previous.signal_finished(); + } + Ok(()) + }, + FenceSignalFutureState::Cleaned => Ok(()), + _ => unreachable!(), + } + } +} + +impl<F> FenceSignalFuture<F> + where F: GpuFuture +{ + // Implementation of `cleanup_finished`, but takes a `&self` instead of a `&mut self`. + // This is an external function so that we can also call it from an `Arc<FenceSignalFuture>`. + #[inline] + fn cleanup_finished_impl(&self) { + let mut state = self.state.lock().unwrap(); + + match *state { + FenceSignalFutureState::Flushed(ref mut prev, ref fence) => { + match fence.wait(Some(Duration::from_secs(0))) { + Ok(()) => unsafe { + prev.signal_finished() + }, + Err(_) => { + prev.cleanup_finished(); + return; + }, + } + }, + FenceSignalFutureState::Pending(ref mut prev, _) => { + prev.cleanup_finished(); + return; + }, + FenceSignalFutureState::PartiallyFlushed(ref mut prev, _) => { + prev.cleanup_finished(); + return; + }, + _ => return, + }; + + // This code can only be reached if we're already flushed and waiting on the fence + // succeeded. + *state = FenceSignalFutureState::Cleaned; + } + + // Implementation of `flush`. You must lock the state and pass the mutex guard here. + fn flush_impl(&self, state: &mut MutexGuard<FenceSignalFutureState<F>>) + -> Result<(), FlushError> { + unsafe { + // In this function we temporarily replace the current state with `Poisoned` at the + // beginning, and we take care to always put back a value into `state` before + // returning (even in case of error). + let old_state = mem::replace(&mut **state, FenceSignalFutureState::Poisoned); + + let (previous, fence, partially_flushed) = match old_state { + FenceSignalFutureState::Pending(prev, fence) => { + (prev, fence, false) + }, + FenceSignalFutureState::PartiallyFlushed(prev, fence) => { + (prev, fence, true) + }, + other => { + // We were already flushed in the past, or we're already poisoned. Don't do + // anything. + **state = other; + return Ok(()); + }, + }; + + // TODO: meh for unwrap + let queue = previous.queue().unwrap().clone(); + + // There are three possible outcomes for the flush operation: success, partial success + // in which case `result` will contain `Err(OutcomeErr::Partial)`, or total failure + // in which case `result` will contain `Err(OutcomeErr::Full)`. + enum OutcomeErr<E> { + Partial(E), + Full(E), + } + let result = match previous.build_submission()? { + SubmitAnyBuilder::Empty => { + debug_assert!(!partially_flushed); + let mut b = SubmitCommandBufferBuilder::new(); + b.set_fence_signal(&fence); + b.submit(&queue).map_err(|err| OutcomeErr::Full(err.into())) + }, + SubmitAnyBuilder::SemaphoresWait(sem) => { + debug_assert!(!partially_flushed); + let b: SubmitCommandBufferBuilder = sem.into(); + debug_assert!(!b.has_fence()); + b.submit(&queue).map_err(|err| OutcomeErr::Full(err.into())) + }, + SubmitAnyBuilder::CommandBuffer(mut cb_builder) => { + debug_assert!(!partially_flushed); + // The assert below could technically be a debug assertion as it is part of the + // safety contract of the trait. However it is easy to get this wrong if you + // write a custom implementation, and if so the consequences would be + // disastrous and hard to debug. Therefore we prefer to just use a regular + // assertion. + assert!(!cb_builder.has_fence()); + cb_builder.set_fence_signal(&fence); + cb_builder + .submit(&queue) + .map_err(|err| OutcomeErr::Full(err.into())) + }, + SubmitAnyBuilder::BindSparse(mut sparse) => { + debug_assert!(!partially_flushed); + // Same remark as `CommandBuffer`. + assert!(!sparse.has_fence()); + sparse.set_fence_signal(&fence); + sparse + .submit(&queue) + .map_err(|err| OutcomeErr::Full(err.into())) + }, + SubmitAnyBuilder::QueuePresent(present) => { + let intermediary_result = if partially_flushed { + Ok(()) + } else { + present.submit(&queue) + }; + match intermediary_result { + Ok(()) => { + let mut b = SubmitCommandBufferBuilder::new(); + b.set_fence_signal(&fence); + b.submit(&queue).map_err(|err| OutcomeErr::Partial(err.into())) + }, + Err(err) => { + Err(OutcomeErr::Full(err.into())) + }, + } + }, + }; + + // Restore the state before returning. + match result { + Ok(()) => { + **state = FenceSignalFutureState::Flushed(previous, fence); + Ok(()) + }, + Err(OutcomeErr::Partial(err)) => { + **state = FenceSignalFutureState::PartiallyFlushed(previous, fence); + Err(err) + }, + Err(OutcomeErr::Full(err)) => { + **state = FenceSignalFutureState::Pending(previous, fence); + Err(err) + }, + } + } + } +} + +impl<F> FenceSignalFutureState<F> { + #[inline] + fn get_prev(&self) -> Option<&F> { + match *self { + FenceSignalFutureState::Pending(ref prev, _) => Some(prev), + FenceSignalFutureState::PartiallyFlushed(ref prev, _) => Some(prev), + FenceSignalFutureState::Flushed(ref prev, _) => Some(prev), + FenceSignalFutureState::Cleaned => None, + FenceSignalFutureState::Poisoned => None, + } + } +} + +unsafe impl<F> GpuFuture for FenceSignalFuture<F> + where F: GpuFuture +{ + #[inline] + fn cleanup_finished(&mut self) { + self.cleanup_finished_impl() + } + + #[inline] + unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError> { + let mut state = self.state.lock().unwrap(); + self.flush_impl(&mut state)?; + + match *state { + FenceSignalFutureState::Flushed(_, ref fence) => { + match self.behavior { + FenceSignalFutureBehavior::Block { timeout } => { + fence.wait(timeout)?; + }, + FenceSignalFutureBehavior::Continue => (), + } + }, + FenceSignalFutureState::Cleaned | + FenceSignalFutureState::Poisoned => (), + FenceSignalFutureState::Pending(_, _) => unreachable!(), + FenceSignalFutureState::PartiallyFlushed(_, _) => unreachable!(), + } + + Ok(SubmitAnyBuilder::Empty) + } + + #[inline] + fn flush(&self) -> Result<(), FlushError> { + let mut state = self.state.lock().unwrap(); + self.flush_impl(&mut state) + } + + #[inline] + unsafe fn signal_finished(&self) { + let state = self.state.lock().unwrap(); + match *state { + FenceSignalFutureState::Flushed(ref prev, _) => { + prev.signal_finished(); + }, + FenceSignalFutureState::Cleaned | + FenceSignalFutureState::Poisoned => (), + _ => unreachable!(), + } + } + + #[inline] + fn queue_change_allowed(&self) -> bool { + match self.behavior { + FenceSignalFutureBehavior::Continue => { + let state = self.state.lock().unwrap(); + if state.get_prev().is_some() { + false + } else { + true + } + }, + FenceSignalFutureBehavior::Block { .. } => { + true + }, + } + } + + #[inline] + fn queue(&self) -> Option<Arc<Queue>> { + let state = self.state.lock().unwrap(); + if let Some(prev) = state.get_prev() { + prev.queue() + } else { + None + } + } + + #[inline] + fn check_buffer_access( + &self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + let state = self.state.lock().unwrap(); + if let Some(previous) = state.get_prev() { + previous.check_buffer_access(buffer, exclusive, queue) + } else { + Err(AccessCheckError::Unknown) + } + } + + #[inline] + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + let state = self.state.lock().unwrap(); + if let Some(previous) = state.get_prev() { + previous.check_image_access(image, layout, exclusive, queue) + } else { + Err(AccessCheckError::Unknown) + } + } +} + +unsafe impl<F> DeviceOwned for FenceSignalFuture<F> + where F: GpuFuture +{ + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +impl<F> Drop for FenceSignalFuture<F> + where F: GpuFuture +{ + fn drop(&mut self) { + let mut state = self.state.lock().unwrap(); + + // We ignore any possible error while submitting for now. Problems are handled below. + let _ = self.flush_impl(&mut state); + + match mem::replace(&mut *state, FenceSignalFutureState::Cleaned) { + FenceSignalFutureState::Flushed(previous, fence) => { + // This is a normal situation. Submitting worked. + // TODO: handle errors? + fence.wait(None).unwrap(); + unsafe { + previous.signal_finished(); + } + }, + FenceSignalFutureState::Cleaned => { + // Also a normal situation. The user called `cleanup_finished()` before dropping. + }, + FenceSignalFutureState::Poisoned => { + // The previous future was already dropped and blocked the current queue. + }, + FenceSignalFutureState::Pending(_, _) | + FenceSignalFutureState::PartiallyFlushed(_, _) => { + // Flushing produced an error. There's nothing more we can do except drop the + // previous future and let it block the current queue. + }, + } + } +} + +unsafe impl<F> GpuFuture for Arc<FenceSignalFuture<F>> + where F: GpuFuture +{ + #[inline] + fn cleanup_finished(&mut self) { + self.cleanup_finished_impl() + } + + #[inline] + unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError> { + // Note that this is sound because we always return `SubmitAnyBuilder::Empty`. See the + // documentation of `build_submission`. + (**self).build_submission() + } + + #[inline] + fn flush(&self) -> Result<(), FlushError> { + (**self).flush() + } + + #[inline] + unsafe fn signal_finished(&self) { + (**self).signal_finished() + } + + #[inline] + fn queue_change_allowed(&self) -> bool { + (**self).queue_change_allowed() + } + + #[inline] + fn queue(&self) -> Option<Arc<Queue>> { + (**self).queue() + } + + #[inline] + fn check_buffer_access( + &self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + (**self).check_buffer_access(buffer, exclusive, queue) + } + + #[inline] + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + (**self).check_image_access(image, layout, exclusive, queue) + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/join.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/join.rs new file mode 100644 index 0000000..3c19d80 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/join.rs @@ -0,0 +1,245 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::sync::Arc; + +use buffer::BufferAccess; +use command_buffer::submit::SubmitAnyBuilder; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use image::ImageLayout; +use sync::AccessCheckError; +use sync::AccessFlagBits; +use sync::FlushError; +use sync::GpuFuture; +use sync::PipelineStages; + +use VulkanObject; + +/// Joins two futures together. +// TODO: handle errors +#[inline] +pub fn join<F, S>(first: F, second: S) -> JoinFuture<F, S> + where F: GpuFuture, + S: GpuFuture +{ + assert_eq!(first.device().internal_object(), + second.device().internal_object()); + + if !first.queue_change_allowed() && !second.queue_change_allowed() { + assert!(first.queue().unwrap().is_same(&second.queue().unwrap())); + } + + JoinFuture { + first: first, + second: second, + } +} + +/// Two futures joined into one. +#[must_use] +pub struct JoinFuture<A, B> { + first: A, + second: B, +} + +unsafe impl<A, B> DeviceOwned for JoinFuture<A, B> + where A: DeviceOwned, + B: DeviceOwned +{ + #[inline] + fn device(&self) -> &Arc<Device> { + let device = self.first.device(); + debug_assert_eq!(self.second.device().internal_object(), + device.internal_object()); + device + } +} + +unsafe impl<A, B> GpuFuture for JoinFuture<A, B> + where A: GpuFuture, + B: GpuFuture +{ + #[inline] + fn cleanup_finished(&mut self) { + self.first.cleanup_finished(); + self.second.cleanup_finished(); + } + + #[inline] + fn flush(&self) -> Result<(), FlushError> { + // Since each future remembers whether it has been flushed, there's no safety issue here + // if we call this function multiple times. + self.first.flush()?; + self.second.flush()?; + Ok(()) + } + + #[inline] + unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError> { + // TODO: review this function + + let first = self.first.build_submission()?; + let second = self.second.build_submission()?; + + Ok(match (first, second) { + (SubmitAnyBuilder::Empty, b) => b, + (a, SubmitAnyBuilder::Empty) => a, + (SubmitAnyBuilder::SemaphoresWait(mut a), SubmitAnyBuilder::SemaphoresWait(b)) => { + a.merge(b); + SubmitAnyBuilder::SemaphoresWait(a) + }, + (SubmitAnyBuilder::SemaphoresWait(a), SubmitAnyBuilder::CommandBuffer(b)) => { + b.submit(&self.second.queue().clone().unwrap())?; + SubmitAnyBuilder::SemaphoresWait(a) + }, + (SubmitAnyBuilder::CommandBuffer(a), SubmitAnyBuilder::SemaphoresWait(b)) => { + a.submit(&self.first.queue().clone().unwrap())?; + SubmitAnyBuilder::SemaphoresWait(b) + }, + (SubmitAnyBuilder::SemaphoresWait(a), SubmitAnyBuilder::QueuePresent(b)) => { + b.submit(&self.second.queue().clone().unwrap())?; + SubmitAnyBuilder::SemaphoresWait(a) + }, + (SubmitAnyBuilder::QueuePresent(a), SubmitAnyBuilder::SemaphoresWait(b)) => { + a.submit(&self.first.queue().clone().unwrap())?; + SubmitAnyBuilder::SemaphoresWait(b) + }, + (SubmitAnyBuilder::SemaphoresWait(a), SubmitAnyBuilder::BindSparse(b)) => { + b.submit(&self.second.queue().clone().unwrap())?; + SubmitAnyBuilder::SemaphoresWait(a) + }, + (SubmitAnyBuilder::BindSparse(a), SubmitAnyBuilder::SemaphoresWait(b)) => { + a.submit(&self.first.queue().clone().unwrap())?; + SubmitAnyBuilder::SemaphoresWait(b) + }, + (SubmitAnyBuilder::CommandBuffer(a), SubmitAnyBuilder::CommandBuffer(b)) => { + // TODO: we may want to add debug asserts here + let new = a.merge(b); + SubmitAnyBuilder::CommandBuffer(new) + }, + (SubmitAnyBuilder::QueuePresent(a), SubmitAnyBuilder::QueuePresent(b)) => { + a.submit(&self.first.queue().clone().unwrap())?; + b.submit(&self.second.queue().clone().unwrap())?; + SubmitAnyBuilder::Empty + }, + (SubmitAnyBuilder::CommandBuffer(a), SubmitAnyBuilder::QueuePresent(b)) => { + unimplemented!() + }, + (SubmitAnyBuilder::QueuePresent(a), SubmitAnyBuilder::CommandBuffer(b)) => { + unimplemented!() + }, + (SubmitAnyBuilder::BindSparse(a), SubmitAnyBuilder::QueuePresent(b)) => { + unimplemented!() + }, + (SubmitAnyBuilder::QueuePresent(a), SubmitAnyBuilder::BindSparse(b)) => { + unimplemented!() + }, + (SubmitAnyBuilder::BindSparse(a), SubmitAnyBuilder::CommandBuffer(b)) => { + unimplemented!() + }, + (SubmitAnyBuilder::CommandBuffer(a), SubmitAnyBuilder::BindSparse(b)) => { + unimplemented!() + }, + (SubmitAnyBuilder::BindSparse(mut a), SubmitAnyBuilder::BindSparse(b)) => { + match a.merge(b) { + Ok(()) => SubmitAnyBuilder::BindSparse(a), + Err(_) => { + // TODO: this happens if both bind sparse have been given a fence already + // annoying, but not impossible, to handle + unimplemented!() + }, + } + }, + }) + } + + #[inline] + unsafe fn signal_finished(&self) { + self.first.signal_finished(); + self.second.signal_finished(); + } + + #[inline] + fn queue_change_allowed(&self) -> bool { + self.first.queue_change_allowed() && self.second.queue_change_allowed() + } + + #[inline] + fn queue(&self) -> Option<Arc<Queue>> { + match (self.first.queue(), self.second.queue()) { + (Some(q1), Some(q2)) => if q1.is_same(&q2) { + Some(q1) + } else if self.first.queue_change_allowed() { + Some(q2) + } else if self.second.queue_change_allowed() { + Some(q1) + } else { + None + }, + (Some(q), None) => Some(q), + (None, Some(q)) => Some(q), + (None, None) => None, + } + } + + #[inline] + fn check_buffer_access( + &self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + let first = self.first.check_buffer_access(buffer, exclusive, queue); + let second = self.second.check_buffer_access(buffer, exclusive, queue); + debug_assert!(!exclusive || !(first.is_ok() && second.is_ok()), + "Two futures gave exclusive access to the same resource"); + match (first, second) { + (v, Err(AccessCheckError::Unknown)) => v, + (Err(AccessCheckError::Unknown), v) => v, + (Err(AccessCheckError::Denied(e1)), Err(AccessCheckError::Denied(e2))) => + Err(AccessCheckError::Denied(e1)), // TODO: which one? + (Ok(_), Err(AccessCheckError::Denied(_))) | + (Err(AccessCheckError::Denied(_)), Ok(_)) => panic!("Contradictory information \ + between two futures"), + (Ok(None), Ok(None)) => Ok(None), + (Ok(Some(a)), Ok(None)) | + (Ok(None), Ok(Some(a))) => Ok(Some(a)), + (Ok(Some((a1, a2))), Ok(Some((b1, b2)))) => { + Ok(Some((a1 | b1, a2 | b2))) + }, + } + } + + #[inline] + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + let first = self.first + .check_image_access(image, layout, exclusive, queue); + let second = self.second + .check_image_access(image, layout, exclusive, queue); + debug_assert!(!exclusive || !(first.is_ok() && second.is_ok()), + "Two futures gave exclusive access to the same resource"); + match (first, second) { + (v, Err(AccessCheckError::Unknown)) => v, + (Err(AccessCheckError::Unknown), v) => v, + (Err(AccessCheckError::Denied(e1)), Err(AccessCheckError::Denied(e2))) => + Err(AccessCheckError::Denied(e1)), // TODO: which one? + (Ok(_), Err(AccessCheckError::Denied(_))) | + (Err(AccessCheckError::Denied(_)), Ok(_)) => panic!("Contradictory information \ + between two futures"), + (Ok(None), Ok(None)) => Ok(None), + (Ok(Some(a)), Ok(None)) | + (Ok(None), Ok(Some(a))) => Ok(Some(a)), + (Ok(Some((a1, a2))), Ok(Some((b1, b2)))) => { + Ok(Some((a1 | b1, a2 | b2))) + }, + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/mod.rs new file mode 100644 index 0000000..e4e9692 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/mod.rs @@ -0,0 +1,510 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::sync::Arc; + +use OomError; +use buffer::BufferAccess; +use command_buffer::CommandBuffer; +use command_buffer::CommandBufferExecError; +use command_buffer::CommandBufferExecFuture; +use command_buffer::submit::SubmitAnyBuilder; +use command_buffer::submit::SubmitBindSparseError; +use command_buffer::submit::SubmitCommandBufferError; +use command_buffer::submit::SubmitPresentError; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use image::ImageLayout; +use swapchain; +use swapchain::PresentFuture; +use swapchain::PresentRegion; +use swapchain::Swapchain; +use sync::AccessFlagBits; +use sync::FenceWaitError; +use sync::PipelineStages; + +pub use self::fence_signal::{FenceSignalFuture, FenceSignalFutureBehavior}; +pub use self::join::JoinFuture; +pub use self::now::{NowFuture, now}; +pub use self::semaphore_signal::SemaphoreSignalFuture; + +mod now; +mod fence_signal; +mod join; +mod semaphore_signal; + +/// Represents an event that will happen on the GPU in the future. +/// +/// See the documentation of the `sync` module for explanations about futures. +// TODO: consider switching all methods to take `&mut self` for optimization purposes +pub unsafe trait GpuFuture: DeviceOwned { + /// If possible, checks whether the submission has finished. If so, gives up ownership of the + /// resources used by these submissions. + /// + /// It is highly recommended to call `cleanup_finished` from time to time. Doing so will + /// prevent memory usage from increasing over time, and will also destroy the locks on + /// resources used by the GPU. + fn cleanup_finished(&mut self); + + /// Builds a submission that, if submitted, makes sure that the event represented by this + /// `GpuFuture` will happen, and possibly contains extra elements (eg. a semaphore wait or an + /// event wait) that makes the dependency with subsequent operations work. + /// + /// It is the responsibility of the caller to ensure that the submission is going to be + /// submitted only once. However keep in mind that this function can perfectly be called + /// multiple times (as long as the returned object is only submitted once). + /// Also note that calling `flush()` on the future may change the value returned by + /// `build_submission()`. + /// + /// It is however the responsibility of the implementation to not return the same submission + /// from multiple different future objects. For example if you implement `GpuFuture` on + /// `Arc<Foo>` then `build_submission()` must always return `SubmitAnyBuilder::Empty`, + /// otherwise it would be possible for the user to clone the `Arc` and make the same + /// submission be submitted multiple times. + /// + /// It is also the responsibility of the implementation to ensure that it works if you call + /// `build_submission()` and submits the returned value without calling `flush()` first. In + /// other words, `build_submission()` should perform an implicit flush if necessary. + /// + /// Once the caller has submitted the submission and has determined that the GPU has finished + /// executing it, it should call `signal_finished`. Failure to do so will incur a large runtime + /// overhead, as the future will have to block to make sure that it is finished. + unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError>; + + /// Flushes the future and submits to the GPU the actions that will permit this future to + /// occur. + /// + /// The implementation must remember that it was flushed. If the function is called multiple + /// times, only the first time must result in a flush. + fn flush(&self) -> Result<(), FlushError>; + + /// Sets the future to its "complete" state, meaning that it can safely be destroyed. + /// + /// This must only be done if you called `build_submission()`, submitted the returned + /// submission, and determined that it was finished. + /// + /// The implementation must be aware that this function can be called multiple times on the + /// same future. + unsafe fn signal_finished(&self); + + /// Returns the queue that triggers the event. Returns `None` if unknown or irrelevant. + /// + /// If this function returns `None` and `queue_change_allowed` returns `false`, then a panic + /// is likely to occur if you use this future. This is only a problem if you implement + /// the `GpuFuture` trait yourself for a type outside of vulkano. + fn queue(&self) -> Option<Arc<Queue>>; + + /// Returns `true` if elements submitted after this future can be submitted to a different + /// queue than the other returned by `queue()`. + fn queue_change_allowed(&self) -> bool; + + /// Checks whether submitting something after this future grants access (exclusive or shared, + /// depending on the parameter) to the given buffer on the given queue. + /// + /// If the access is granted, returns the pipeline stage and access flags of the latest usage + /// of this resource, or `None` if irrelevant. + /// + /// > **Note**: Returning `Ok` means "access granted", while returning `Err` means + /// > "don't know". Therefore returning `Err` is never unsafe. + fn check_buffer_access(&self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>; + + /// Checks whether submitting something after this future grants access (exclusive or shared, + /// depending on the parameter) to the given image on the given queue. + /// + /// If the access is granted, returns the pipeline stage and access flags of the latest usage + /// of this resource, or `None` if irrelevant. + /// + /// Implementations must ensure that the image is in the given layout. However if the `layout` + /// is `Undefined` then the implementation should accept any actual layout. + /// + /// > **Note**: Returning `Ok` means "access granted", while returning `Err` means + /// > "don't know". Therefore returning `Err` is never unsafe. + /// + /// > **Note**: Keep in mind that changing the layout of an image also requires exclusive + /// > access. + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>; + + /// Joins this future with another one, representing the moment when both events have happened. + // TODO: handle errors + fn join<F>(self, other: F) -> JoinFuture<Self, F> + where Self: Sized, + F: GpuFuture + { + join::join(self, other) + } + + /// Executes a command buffer after this future. + /// + /// > **Note**: This is just a shortcut function. The actual implementation is in the + /// > `CommandBuffer` trait. + #[inline] + fn then_execute<Cb>(self, queue: Arc<Queue>, command_buffer: Cb) + -> Result<CommandBufferExecFuture<Self, Cb>, CommandBufferExecError> + where Self: Sized, + Cb: CommandBuffer + 'static + { + command_buffer.execute_after(self, queue) + } + + /// Executes a command buffer after this future, on the same queue as the future. + /// + /// > **Note**: This is just a shortcut function. The actual implementation is in the + /// > `CommandBuffer` trait. + #[inline] + fn then_execute_same_queue<Cb>( + self, command_buffer: Cb) + -> Result<CommandBufferExecFuture<Self, Cb>, CommandBufferExecError> + where Self: Sized, + Cb: CommandBuffer + 'static + { + let queue = self.queue().unwrap().clone(); + command_buffer.execute_after(self, queue) + } + + /// Signals a semaphore after this future. Returns another future that represents the signal. + /// + /// Call this function when you want to execute some operations on a queue and want to see the + /// result on another queue. + #[inline] + fn then_signal_semaphore(self) -> SemaphoreSignalFuture<Self> + where Self: Sized + { + semaphore_signal::then_signal_semaphore(self) + } + + /// Signals a semaphore after this future and flushes it. Returns another future that + /// represents the moment when the semaphore is signalled. + /// + /// This is a just a shortcut for `then_signal_semaphore()` followed with `flush()`. + /// + /// When you want to execute some operations A on a queue and some operations B on another + /// queue that need to see the results of A, it can be a good idea to submit A as soon as + /// possible while you're preparing B. + /// + /// If you ran A and B on the same queue, you would have to decide between submitting A then + /// B, or A and B simultaneously. Both approaches have their trade-offs. But if A and B are + /// on two different queues, then you would need two submits anyway and it is always + /// advantageous to submit A as soon as possible. + #[inline] + fn then_signal_semaphore_and_flush(self) -> Result<SemaphoreSignalFuture<Self>, FlushError> + where Self: Sized + { + let f = self.then_signal_semaphore(); + f.flush()?; + Ok(f) + } + + /// Signals a fence after this future. Returns another future that represents the signal. + /// + /// > **Note**: More often than not you want to immediately flush the future after calling this + /// > function. If so, consider using `then_signal_fence_and_flush`. + #[inline] + fn then_signal_fence(self) -> FenceSignalFuture<Self> + where Self: Sized + { + fence_signal::then_signal_fence(self, FenceSignalFutureBehavior::Continue) + } + + /// Signals a fence after this future. Returns another future that represents the signal. + /// + /// This is a just a shortcut for `then_signal_fence()` followed with `flush()`. + #[inline] + fn then_signal_fence_and_flush(self) -> Result<FenceSignalFuture<Self>, FlushError> + where Self: Sized + { + let f = self.then_signal_fence(); + f.flush()?; + Ok(f) + } + + /// Presents a swapchain image after this future. + /// + /// You should only ever do this indirectly after a `SwapchainAcquireFuture` of the same image, + /// otherwise an error will occur when flushing. + /// + /// > **Note**: This is just a shortcut for the `Swapchain::present()` function. + #[inline] + fn then_swapchain_present<W>(self, queue: Arc<Queue>, swapchain: Arc<Swapchain<W>>, + image_index: usize) + -> PresentFuture<Self,W> + where Self: Sized + { + swapchain::present(swapchain, self, queue, image_index) + } + + /// Same as `then_swapchain_present`, except it allows specifying a present region. + /// + /// > **Note**: This is just a shortcut for the `Swapchain::present_incremental()` function. + #[inline] + fn then_swapchain_present_incremental<W>(self, queue: Arc<Queue>, swapchain: Arc<Swapchain<W>>, + image_index: usize, present_region: PresentRegion) + -> PresentFuture<Self,W> + where Self: Sized + { + swapchain::present_incremental(swapchain, self, queue, image_index, present_region) + } +} + +unsafe impl<F: ?Sized> GpuFuture for Box<F> + where F: GpuFuture +{ + #[inline] + fn cleanup_finished(&mut self) { + (**self).cleanup_finished() + } + + #[inline] + unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError> { + (**self).build_submission() + } + + #[inline] + fn flush(&self) -> Result<(), FlushError> { + (**self).flush() + } + + #[inline] + unsafe fn signal_finished(&self) { + (**self).signal_finished() + } + + #[inline] + fn queue_change_allowed(&self) -> bool { + (**self).queue_change_allowed() + } + + #[inline] + fn queue(&self) -> Option<Arc<Queue>> { + (**self).queue() + } + + #[inline] + fn check_buffer_access( + &self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + (**self).check_buffer_access(buffer, exclusive, queue) + } + + #[inline] + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + (**self).check_image_access(image, layout, exclusive, queue) + } +} + +/// Access to a resource was denied. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum AccessError { + /// Exclusive access is denied. + ExclusiveDenied, + + /// The resource is already in use, and there is no tracking of concurrent usages. + AlreadyInUse, + + UnexpectedImageLayout { + allowed: ImageLayout, + requested: ImageLayout, + }, + + /// Trying to use an image without transitioning it from the "undefined" or "preinitialized" + /// layouts first. + ImageNotInitialized { + /// The layout that was requested for the image. + requested: ImageLayout, + }, + + /// Trying to use a buffer that still contains garbage data. + BufferNotInitialized, + + /// Trying to use a swapchain image without depending on a corresponding acquire image future. + SwapchainImageAcquireOnly, +} + +impl error::Error for AccessError { + #[inline] + fn description(&self) -> &str { + match *self { + AccessError::ExclusiveDenied => { + "only shared access is allowed for this resource" + }, + AccessError::AlreadyInUse => { + "the resource is already in use, and there is no tracking of concurrent usages" + }, + AccessError::UnexpectedImageLayout { .. } => { + unimplemented!() // TODO: find a description + }, + AccessError::ImageNotInitialized { .. } => { + "trying to use an image without transitioning it from the undefined or \ + preinitialized layouts first" + }, + AccessError::BufferNotInitialized => { + "trying to use a buffer that still contains garbage data" + }, + AccessError::SwapchainImageAcquireOnly => { + "trying to use a swapchain image without depending on a corresponding acquire \ + image future" + }, + } + } +} + +impl fmt::Display for AccessError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +/// Error that can happen when checking whether we have access to a resource. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum AccessCheckError { + /// Access to the resource has been denied. + Denied(AccessError), + /// The resource is unknown, therefore we cannot possibly answer whether we have access or not. + Unknown, +} + +impl error::Error for AccessCheckError { + #[inline] + fn description(&self) -> &str { + match *self { + AccessCheckError::Denied(_) => { + "access to the resource has been denied" + }, + AccessCheckError::Unknown => { + "the resource is unknown" + }, + } + } +} + +impl fmt::Display for AccessCheckError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<AccessError> for AccessCheckError { + #[inline] + fn from(err: AccessError) -> AccessCheckError { + AccessCheckError::Denied(err) + } +} + +/// Error that can happen when creating a graphics pipeline. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum FlushError { + /// Access to a resource has been denied. + AccessError(AccessError), + + /// Not enough memory. + OomError(OomError), + + /// The connection to the device has been lost. + DeviceLost, + + /// The surface is no longer accessible and must be recreated. + SurfaceLost, + + /// The surface has changed in a way that makes the swapchain unusable. You must query the + /// surface's new properties and recreate a new swapchain if you want to continue drawing. + OutOfDate, + + /// The flush operation needed to block, but the timeout has elapsed. + Timeout, +} + +impl error::Error for FlushError { + #[inline] + fn description(&self) -> &str { + match *self { + FlushError::AccessError(_) => "access to a resource has been denied", + FlushError::OomError(_) => "not enough memory", + FlushError::DeviceLost => "the connection to the device has been lost", + FlushError::SurfaceLost => "the surface of this swapchain is no longer valid", + FlushError::OutOfDate => "the swapchain needs to be recreated", + FlushError::Timeout => "the flush operation needed to block, but the timeout has \ + elapsed", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + FlushError::AccessError(ref err) => Some(err), + FlushError::OomError(ref err) => Some(err), + _ => None, + } + } +} + +impl fmt::Display for FlushError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<AccessError> for FlushError { + #[inline] + fn from(err: AccessError) -> FlushError { + FlushError::AccessError(err) + } +} + +impl From<SubmitPresentError> for FlushError { + #[inline] + fn from(err: SubmitPresentError) -> FlushError { + match err { + SubmitPresentError::OomError(err) => FlushError::OomError(err), + SubmitPresentError::DeviceLost => FlushError::DeviceLost, + SubmitPresentError::SurfaceLost => FlushError::SurfaceLost, + SubmitPresentError::OutOfDate => FlushError::OutOfDate, + } + } +} + +impl From<SubmitCommandBufferError> for FlushError { + #[inline] + fn from(err: SubmitCommandBufferError) -> FlushError { + match err { + SubmitCommandBufferError::OomError(err) => FlushError::OomError(err), + SubmitCommandBufferError::DeviceLost => FlushError::DeviceLost, + } + } +} + +impl From<SubmitBindSparseError> for FlushError { + #[inline] + fn from(err: SubmitBindSparseError) -> FlushError { + match err { + SubmitBindSparseError::OomError(err) => FlushError::OomError(err), + SubmitBindSparseError::DeviceLost => FlushError::DeviceLost, + } + } +} + +impl From<FenceWaitError> for FlushError { + #[inline] + fn from(err: FenceWaitError) -> FlushError { + match err { + FenceWaitError::OomError(err) => FlushError::OomError(err), + FenceWaitError::Timeout => FlushError::Timeout, + FenceWaitError::DeviceLostError => FlushError::DeviceLost, + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/now.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/now.rs new file mode 100644 index 0000000..aa8bbb7 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/now.rs @@ -0,0 +1,84 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::sync::Arc; + +use buffer::BufferAccess; +use command_buffer::submit::SubmitAnyBuilder; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use image::ImageLayout; +use sync::AccessCheckError; +use sync::AccessFlagBits; +use sync::FlushError; +use sync::GpuFuture; +use sync::PipelineStages; + +/// Builds a future that represents "now". +#[inline] +pub fn now(device: Arc<Device>) -> NowFuture { + NowFuture { device: device } +} + +/// A dummy future that represents "now". +pub struct NowFuture { + device: Arc<Device>, +} + +unsafe impl GpuFuture for NowFuture { + #[inline] + fn cleanup_finished(&mut self) { + } + + #[inline] + unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError> { + Ok(SubmitAnyBuilder::Empty) + } + + #[inline] + fn flush(&self) -> Result<(), FlushError> { + Ok(()) + } + + #[inline] + unsafe fn signal_finished(&self) { + } + + #[inline] + fn queue_change_allowed(&self) -> bool { + true + } + + #[inline] + fn queue(&self) -> Option<Arc<Queue>> { + None + } + + #[inline] + fn check_buffer_access( + &self, buffer: &BufferAccess, _: bool, _: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + Err(AccessCheckError::Unknown) + } + + #[inline] + fn check_image_access(&self, _: &ImageAccess, _: ImageLayout, _: bool, _: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + Err(AccessCheckError::Unknown) + } +} + +unsafe impl DeviceOwned for NowFuture { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/semaphore_signal.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/semaphore_signal.rs new file mode 100644 index 0000000..bda4927 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/future/semaphore_signal.rs @@ -0,0 +1,186 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::sync::Arc; +use std::sync::Mutex; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; + +use buffer::BufferAccess; +use command_buffer::submit::SubmitAnyBuilder; +use command_buffer::submit::SubmitCommandBufferBuilder; +use command_buffer::submit::SubmitSemaphoresWaitBuilder; +use device::Device; +use device::DeviceOwned; +use device::Queue; +use image::ImageAccess; +use image::ImageLayout; +use sync::AccessCheckError; +use sync::AccessFlagBits; +use sync::FlushError; +use sync::GpuFuture; +use sync::PipelineStages; +use sync::Semaphore; + +/// Builds a new semaphore signal future. +#[inline] +pub fn then_signal_semaphore<F>(future: F) -> SemaphoreSignalFuture<F> + where F: GpuFuture +{ + let device = future.device().clone(); + + assert!(future.queue().is_some()); // TODO: document + + SemaphoreSignalFuture { + previous: future, + semaphore: Semaphore::from_pool(device).unwrap(), + wait_submitted: Mutex::new(false), + finished: AtomicBool::new(false), + } +} + +/// Represents a semaphore being signaled after a previous event. +#[must_use = "Dropping this object will immediately block the thread until the GPU has finished \ + processing the submission"] +pub struct SemaphoreSignalFuture<F> + where F: GpuFuture +{ + previous: F, + semaphore: Semaphore, + // True if the signaling command has already been submitted. + // If flush is called multiple times, we want to block so that only one flushing is executed. + // Therefore we use a `Mutex<bool>` and not an `AtomicBool`. + wait_submitted: Mutex<bool>, + finished: AtomicBool, +} + +unsafe impl<F> GpuFuture for SemaphoreSignalFuture<F> + where F: GpuFuture +{ + #[inline] + fn cleanup_finished(&mut self) { + self.previous.cleanup_finished(); + } + + #[inline] + unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError> { + // Flushing the signaling part, since it must always be submitted before the waiting part. + self.flush()?; + + let mut sem = SubmitSemaphoresWaitBuilder::new(); + sem.add_wait_semaphore(&self.semaphore); + Ok(SubmitAnyBuilder::SemaphoresWait(sem)) + } + + fn flush(&self) -> Result<(), FlushError> { + unsafe { + let mut wait_submitted = self.wait_submitted.lock().unwrap(); + + if *wait_submitted { + return Ok(()); + } + + let queue = self.previous.queue().unwrap().clone(); + + match self.previous.build_submission()? { + SubmitAnyBuilder::Empty => { + let mut builder = SubmitCommandBufferBuilder::new(); + builder.add_signal_semaphore(&self.semaphore); + builder.submit(&queue)?; + }, + SubmitAnyBuilder::SemaphoresWait(sem) => { + let mut builder: SubmitCommandBufferBuilder = sem.into(); + builder.add_signal_semaphore(&self.semaphore); + builder.submit(&queue)?; + }, + SubmitAnyBuilder::CommandBuffer(mut builder) => { + debug_assert_eq!(builder.num_signal_semaphores(), 0); + builder.add_signal_semaphore(&self.semaphore); + builder.submit(&queue)?; + }, + SubmitAnyBuilder::BindSparse(_) => { + unimplemented!() // TODO: how to do that? + /*debug_assert_eq!(builder.num_signal_semaphores(), 0); + builder.add_signal_semaphore(&self.semaphore); + try!(builder.submit(&queue));*/ + }, + SubmitAnyBuilder::QueuePresent(present) => { + present.submit(&queue)?; + let mut builder = SubmitCommandBufferBuilder::new(); + builder.add_signal_semaphore(&self.semaphore); + builder.submit(&queue)?; // FIXME: problematic because if we return an error and flush() is called again, then we'll submit the present twice + }, + }; + + // Only write `true` here in order to try again next time if an error occurs. + *wait_submitted = true; + Ok(()) + } + } + + #[inline] + unsafe fn signal_finished(&self) { + debug_assert!(*self.wait_submitted.lock().unwrap()); + self.finished.store(true, Ordering::SeqCst); + self.previous.signal_finished(); + } + + #[inline] + fn queue_change_allowed(&self) -> bool { + true + } + + #[inline] + fn queue(&self) -> Option<Arc<Queue>> { + self.previous.queue() + } + + #[inline] + fn check_buffer_access( + &self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + self.previous + .check_buffer_access(buffer, exclusive, queue) + .map(|_| None) + } + + #[inline] + fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, + queue: &Queue) + -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> { + self.previous + .check_image_access(image, layout, exclusive, queue) + .map(|_| None) + } +} + +unsafe impl<F> DeviceOwned for SemaphoreSignalFuture<F> + where F: GpuFuture +{ + #[inline] + fn device(&self) -> &Arc<Device> { + self.semaphore.device() + } +} + +impl<F> Drop for SemaphoreSignalFuture<F> + where F: GpuFuture +{ + fn drop(&mut self) { + unsafe { + if !*self.finished.get_mut() { + // TODO: handle errors? + self.flush().unwrap(); + // Block until the queue finished. + self.queue().unwrap().wait().unwrap(); + self.previous.signal_finished(); + } + } + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sync/mod.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/mod.rs new file mode 100644 index 0000000..f231a98 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/mod.rs @@ -0,0 +1,168 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +//! Synchronization on the GPU. +//! +//! Just like for CPU code, you have to ensure that buffers and images are not accessed mutably by +//! multiple GPU queues simultaneously and that they are not accessed mutably by the CPU and by the +//! GPU simultaneously. +//! +//! This safety is enforced at runtime by vulkano but it is not magic and you will require some +//! knowledge if you want to avoid errors. +//! +//! # Futures +//! +//! Whenever you ask the GPU to start an operation by using a function of the vulkano library (for +//! example executing a command buffer), this function will return a *future*. A future is an +//! object that implements [the `GpuFuture` trait](trait.GpuFuture.html) and that represents the +//! point in time when this operation is over. +//! +//! No function in vulkano immediately sends an operation to the GPU (with the exception of some +//! unsafe low-level functions). Instead they return a future that is in the pending state. Before +//! the GPU actually starts doing anything, you have to *flush* the future by calling the `flush()` +//! method or one of its derivatives. +//! +//! Futures serve several roles: +//! +//! - Futures can be used to build dependencies between operations and makes it possible to ask +//! that an operation starts only after a previous operation is finished. +//! - Submitting an operation to the GPU is a costly operation. By chaining multiple operations +//! with futures you will submit them all at once instead of one by one, thereby reducing this +//! cost. +//! - Futures keep alive the resources and objects used by the GPU so that they don't get destroyed +//! while they are still in use. +//! +//! The last point means that you should keep futures alive in your program for as long as their +//! corresponding operation is potentially still being executed by the GPU. Dropping a future +//! earlier will block the current thread (after flushing, if necessary) until the GPU has finished +//! the operation, which is usually not what you want. +//! +//! If you write a function that submits an operation to the GPU in your program, you are +//! encouraged to let this function return the corresponding future and let the caller handle it. +//! This way the caller will be able to chain multiple futures together and decide when it wants to +//! keep the future alive or drop it. +//! +//! # Executing an operation after a future +//! +//! Respecting the order of operations on the GPU is important, as it is what *proves* vulkano that +//! what you are doing is indeed safe. For example if you submit two operations that modify the +//! same buffer, then you need to execute one after the other instead of submitting them +//! independently. Failing to do so would mean that these two operations could potentially execute +//! simultaneously on the GPU, which would be unsafe. +//! +//! This is done by calling one of the methods of the `GpuFuture` trait. For example calling +//! `prev_future.then_execute(command_buffer)` takes ownership of `prev_future` and will make sure +//! to only start executing `command_buffer` after the moment corresponding to `prev_future` +//! happens. The object returned by the `then_execute` function is itself a future that corresponds +//! to the moment when the execution of `command_buffer` ends. +//! +//! ## Between two different GPU queues +//! +//! When you want to perform an operation after another operation on two different queues, you +//! **must** put a *semaphore* between them. Failure to do so would result in a runtime error. +//! Adding a semaphore is a simple as replacing `prev_future.then_execute(...)` with +//! `prev_future.then_signal_semaphore().then_execute(...)`. +//! +//! > **Note**: A common use-case is using a transfer queue (ie. a queue that is only capable of +//! > performing transfer operations) to write data to a buffer, then read that data from the +//! > rendering queue. +//! +//! What happens when you do so is that the first queue will execute the first set of operations +//! (represented by `prev_future` in the example), then put a semaphore in the signalled state. +//! Meanwhile the second queue blocks (if necessary) until that same semaphore gets signalled, and +//! then only will execute the second set of operations. +//! +//! Since you want to avoid blocking the second queue as much as possible, you probably want to +//! flush the operation to the first queue as soon as possible. This can easily be done by calling +//! `then_signal_semaphore_and_flush()` instead of `then_signal_semaphore()`. +//! +//! ## Between several different GPU queues +//! +//! The `then_signal_semaphore()` method is appropriate when you perform an operation in one queue, +//! and want to see the result in another queue. However in some situations you want to start +//! multiple operations on several different queues. +//! +//! TODO: this is not yet implemented +//! +//! # Fences +//! +//! A `Fence` is an object that is used to signal the CPU when an operation on the GPU is finished. +//! +//! Signalling a fence is done by calling `then_signal_fence()` on a future. Just like semaphores, +//! you are encouraged to use `then_signal_fence_and_flush()` instead. +//! +//! Signalling a fence is kind of a "terminator" to a chain of futures. +//! +//! TODO: lots of problems with how to use fences +//! TODO: talk about fence + semaphore simultaneously +//! TODO: talk about using fences to clean up + +use device::Queue; +use std::sync::Arc; + +pub use self::event::Event; +pub use self::fence::Fence; +pub use self::fence::FenceWaitError; +pub use self::future::AccessCheckError; +pub use self::future::AccessError; +pub use self::future::FenceSignalFuture; +pub use self::future::FlushError; +pub use self::future::GpuFuture; +pub use self::future::JoinFuture; +pub use self::future::NowFuture; +pub use self::future::SemaphoreSignalFuture; +pub use self::future::now; +pub use self::pipeline::AccessFlagBits; +pub use self::pipeline::PipelineStages; +pub use self::semaphore::Semaphore; + +mod event; +mod fence; +mod future; +mod pipeline; +mod semaphore; + +/// Declares in which queue(s) a resource can be used. +/// +/// When you create a buffer or an image, you have to tell the Vulkan library in which queue +/// families it will be used. The vulkano library requires you to tell in which queue family +/// the resource will be used, even for exclusive mode. +#[derive(Debug, Clone, PartialEq, Eq)] +// TODO: remove +pub enum SharingMode { + /// The resource is used is only one queue family. + Exclusive(u32), + /// The resource is used in multiple queue families. Can be slower than `Exclusive`. + Concurrent(Vec<u32>), // TODO: Vec is too expensive here +} + +impl<'a> From<&'a Arc<Queue>> for SharingMode { + #[inline] + fn from(queue: &'a Arc<Queue>) -> SharingMode { + SharingMode::Exclusive(queue.family().id()) + } +} + +impl<'a> From<&'a [&'a Arc<Queue>]> for SharingMode { + #[inline] + fn from(queues: &'a [&'a Arc<Queue>]) -> SharingMode { + SharingMode::Concurrent(queues.iter().map(|queue| queue.family().id()).collect()) + } +} + +/// Declares in which queue(s) a resource can be used. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Sharing<I> + where I: Iterator<Item = u32> +{ + /// The resource is used is only one queue family. + Exclusive, + /// The resource is used in multiple queue families. Can be slower than `Exclusive`. + Concurrent(I), +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sync/pipeline.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/pipeline.rs new file mode 100644 index 0000000..3a201f9 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/pipeline.rs @@ -0,0 +1,226 @@ +// Copyright (c) 2017 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::ops; +use vk; + +macro_rules! pipeline_stages { + ($($elem:ident => $val:expr,)+) => ( + #[derive(Debug, Copy, Clone, PartialEq, Eq)] + #[allow(missing_docs)] + pub struct PipelineStages { + $( + pub $elem: bool, + )+ + } + + impl PipelineStages { + /// Builds an `PipelineStages` struct with none of the stages set. + pub fn none() -> PipelineStages { + PipelineStages { + $( + $elem: false, + )+ + } + } + + #[inline] + pub(crate) fn into_vulkan_bits(self) -> vk::PipelineStageFlagBits { + let mut result = 0; + $( + if self.$elem { result |= $val } + )+ + result + } + } + + impl ops::BitOr for PipelineStages { + type Output = PipelineStages; + + #[inline] + fn bitor(self, rhs: PipelineStages) -> PipelineStages { + PipelineStages { + $( + $elem: self.$elem || rhs.$elem, + )+ + } + } + } + + impl ops::BitOrAssign for PipelineStages { + #[inline] + fn bitor_assign(&mut self, rhs: PipelineStages) { + $( + self.$elem = self.$elem || rhs.$elem; + )+ + } + } + ); +} + +pipeline_stages!{ + top_of_pipe => vk::PIPELINE_STAGE_TOP_OF_PIPE_BIT, + draw_indirect => vk::PIPELINE_STAGE_DRAW_INDIRECT_BIT, + vertex_input => vk::PIPELINE_STAGE_VERTEX_INPUT_BIT, + vertex_shader => vk::PIPELINE_STAGE_VERTEX_SHADER_BIT, + tessellation_control_shader => vk::PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT, + tessellation_evaluation_shader => vk::PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT, + geometry_shader => vk::PIPELINE_STAGE_GEOMETRY_SHADER_BIT, + fragment_shader => vk::PIPELINE_STAGE_FRAGMENT_SHADER_BIT, + early_fragment_tests => vk::PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT, + late_fragment_tests => vk::PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, + color_attachment_output => vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, + compute_shader => vk::PIPELINE_STAGE_COMPUTE_SHADER_BIT, + transfer => vk::PIPELINE_STAGE_TRANSFER_BIT, + bottom_of_pipe => vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, + host => vk::PIPELINE_STAGE_HOST_BIT, + all_graphics => vk::PIPELINE_STAGE_ALL_GRAPHICS_BIT, + all_commands => vk::PIPELINE_STAGE_ALL_COMMANDS_BIT, +} + +macro_rules! access_flags { + ($($elem:ident => $val:expr,)+) => ( + #[derive(Debug, Copy, Clone)] + #[allow(missing_docs)] + pub struct AccessFlagBits { + $( + pub $elem: bool, + )+ + } + + impl AccessFlagBits { + /// Builds an `AccessFlagBits` struct with all bits set. + pub fn all() -> AccessFlagBits { + AccessFlagBits { + $( + $elem: true, + )+ + } + } + + /// Builds an `AccessFlagBits` struct with none of the bits set. + pub fn none() -> AccessFlagBits { + AccessFlagBits { + $( + $elem: false, + )+ + } + } + + #[inline] + pub(crate) fn into_vulkan_bits(self) -> vk::AccessFlagBits { + let mut result = 0; + $( + if self.$elem { result |= $val } + )+ + result + } + } + + impl ops::BitOr for AccessFlagBits { + type Output = AccessFlagBits; + + #[inline] + fn bitor(self, rhs: AccessFlagBits) -> AccessFlagBits { + AccessFlagBits { + $( + $elem: self.$elem || rhs.$elem, + )+ + } + } + } + + impl ops::BitOrAssign for AccessFlagBits { + #[inline] + fn bitor_assign(&mut self, rhs: AccessFlagBits) { + $( + self.$elem = self.$elem || rhs.$elem; + )+ + } + } + ); +} + +access_flags!{ + indirect_command_read => vk::ACCESS_INDIRECT_COMMAND_READ_BIT, + index_read => vk::ACCESS_INDEX_READ_BIT, + vertex_attribute_read => vk::ACCESS_VERTEX_ATTRIBUTE_READ_BIT, + uniform_read => vk::ACCESS_UNIFORM_READ_BIT, + input_attachment_read => vk::ACCESS_INPUT_ATTACHMENT_READ_BIT, + shader_read => vk::ACCESS_SHADER_READ_BIT, + shader_write => vk::ACCESS_SHADER_WRITE_BIT, + color_attachment_read => vk::ACCESS_COLOR_ATTACHMENT_READ_BIT, + color_attachment_write => vk::ACCESS_COLOR_ATTACHMENT_WRITE_BIT, + depth_stencil_attachment_read => vk::ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT, + depth_stencil_attachment_write => vk::ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, + transfer_read => vk::ACCESS_TRANSFER_READ_BIT, + transfer_write => vk::ACCESS_TRANSFER_WRITE_BIT, + host_read => vk::ACCESS_HOST_READ_BIT, + host_write => vk::ACCESS_HOST_WRITE_BIT, + memory_read => vk::ACCESS_MEMORY_READ_BIT, + memory_write => vk::ACCESS_MEMORY_WRITE_BIT, +} + +impl AccessFlagBits { + /// Returns true if the access flags can be used with the given pipeline stages. + /// + /// Corresponds to `Table 4. Supported access types` in section `6.1.3. Access Types` of the + /// Vulkan specs. + pub fn is_compatible_with(&self, stages: &PipelineStages) -> bool { + if stages.all_commands { + return true; + } + + if self.indirect_command_read && !stages.draw_indirect && !stages.all_graphics { + return false; + } + + if (self.index_read || self.vertex_attribute_read) && !stages.vertex_input && + !stages.all_graphics + { + return false; + } + + if (self.uniform_read || self.shader_read || self.shader_write) && + !stages.vertex_shader && !stages.tessellation_control_shader && + !stages.tessellation_evaluation_shader && !stages.geometry_shader && + !stages.fragment_shader && + !stages.compute_shader && !stages.all_graphics + { + return false; + } + + if self.input_attachment_read && !stages.fragment_shader && !stages.all_graphics { + return false; + } + + if (self.color_attachment_read || self.color_attachment_write) && + !stages.color_attachment_output && !stages.all_graphics + { + return false; + } + + if (self.depth_stencil_attachment_read || self.depth_stencil_attachment_write) && + !stages.early_fragment_tests && !stages.late_fragment_tests && + !stages.all_graphics + { + return false; + } + + if (self.transfer_read || self.transfer_write) && !stages.transfer { + return false; + } + + if (self.host_read || self.host_write) && !stages.host { + return false; + } + + true + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/sync/semaphore.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/semaphore.rs new file mode 100644 index 0000000..b159531 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/sync/semaphore.rs @@ -0,0 +1,157 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::mem; +use std::ptr; +use std::sync::Arc; + +use OomError; +use SafeDeref; +use VulkanObject; +use check_errors; +use device::Device; +use device::DeviceOwned; +use vk; + +/// Used to provide synchronization between command buffers during their execution. +/// +/// It is similar to a fence, except that it is purely on the GPU side. The CPU can't query a +/// semaphore's status or wait for it to be signaled. +#[derive(Debug)] +pub struct Semaphore<D = Arc<Device>> + where D: SafeDeref<Target = Device> +{ + semaphore: vk::Semaphore, + device: D, + must_put_in_pool: bool, +} + +impl<D> Semaphore<D> + where D: SafeDeref<Target = Device> +{ + /// Takes a semaphore from the vulkano-provided semaphore pool. + /// If the pool is empty, a new semaphore will be allocated. + /// Upon `drop`, the semaphore is put back into the pool. + /// + /// For most applications, using the pool should be preferred, + /// in order to avoid creating new semaphores every frame. + pub fn from_pool(device: D) -> Result<Semaphore<D>, OomError> { + let maybe_raw_sem = device.semaphore_pool().lock().unwrap().pop(); + match maybe_raw_sem { + Some(raw_sem) => { + Ok(Semaphore { + device: device, + semaphore: raw_sem, + must_put_in_pool: true, + }) + }, + None => { + // Pool is empty, alloc new semaphore + Semaphore::alloc_impl(device, true) + }, + } + } + + /// Builds a new semaphore. + #[inline] + pub fn alloc(device: D) -> Result<Semaphore<D>, OomError> { + Semaphore::alloc_impl(device, false) + } + + fn alloc_impl(device: D, must_put_in_pool: bool) -> Result<Semaphore<D>, OomError> { + let semaphore = unsafe { + // since the creation is constant, we use a `static` instead of a struct on the stack + static mut INFOS: vk::SemaphoreCreateInfo = vk::SemaphoreCreateInfo { + sType: vk::STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, + pNext: 0 as *const _, // ptr::null() + flags: 0, // reserved + }; + + let vk = device.pointers(); + let mut output = mem::uninitialized(); + check_errors(vk.CreateSemaphore(device.internal_object(), + &INFOS, + ptr::null(), + &mut output))?; + output + }; + + Ok(Semaphore { + device: device, + semaphore: semaphore, + must_put_in_pool: must_put_in_pool, + }) + } +} + +unsafe impl DeviceOwned for Semaphore { + #[inline] + fn device(&self) -> &Arc<Device> { + &self.device + } +} + +unsafe impl<D> VulkanObject for Semaphore<D> + where D: SafeDeref<Target = Device> +{ + type Object = vk::Semaphore; + + const TYPE: vk::DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT; + + #[inline] + fn internal_object(&self) -> vk::Semaphore { + self.semaphore + } +} + +impl<D> Drop for Semaphore<D> + where D: SafeDeref<Target = Device> +{ + #[inline] + fn drop(&mut self) { + unsafe { + if self.must_put_in_pool { + let raw_sem = self.semaphore; + self.device.semaphore_pool().lock().unwrap().push(raw_sem); + } else { + let vk = self.device.pointers(); + vk.DestroySemaphore(self.device.internal_object(), self.semaphore, ptr::null()); + } + } + } +} + +#[cfg(test)] +mod tests { + use VulkanObject; + use sync::Semaphore; + + #[test] + fn semaphore_create() { + let (device, _) = gfx_dev_and_queue!(); + let _ = Semaphore::alloc(device.clone()); + } + + #[test] + fn semaphore_pool() { + let (device, _) = gfx_dev_and_queue!(); + + assert_eq!(device.semaphore_pool().lock().unwrap().len(), 0); + let sem1_internal_obj = { + let sem = Semaphore::from_pool(device.clone()).unwrap(); + assert_eq!(device.semaphore_pool().lock().unwrap().len(), 0); + sem.internal_object() + }; + + assert_eq!(device.semaphore_pool().lock().unwrap().len(), 1); + let sem2 = Semaphore::from_pool(device.clone()).unwrap(); + assert_eq!(device.semaphore_pool().lock().unwrap().len(), 0); + assert_eq!(sem2.internal_object(), sem1_internal_obj); + } +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/tests.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/tests.rs new file mode 100644 index 0000000..5245d77 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/tests.rs @@ -0,0 +1,99 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +#![cfg(test)] + +/// Creates an instance or returns if initialization fails. +macro_rules! instance { + () => ({ + use instance; + + match instance::Instance::new(None, &instance::InstanceExtensions::none(), None) { + Ok(i) => i, + Err(_) => return + } + }) +} + +/// Creates a device and a queue for graphics operations. +macro_rules! gfx_dev_and_queue { + ($($feature:ident),*) => ({ + use instance; + use device::Device; + use device::DeviceExtensions; + use features::Features; + + let instance = instance!(); + + let physical = match instance::PhysicalDevice::enumerate(&instance).next() { + Some(p) => p, + None => return + }; + + let queue = match physical.queue_families().find(|q| q.supports_graphics()) { + Some(q) => q, + None => return + }; + + let extensions = DeviceExtensions::none(); + + let features = Features { + $( + $feature: true, + )* + .. Features::none() + }; + + // If the physical device doesn't support the requested features, just return. + if !physical.supported_features().superset_of(&features) { + return; + } + + let (device, mut queues) = match Device::new(physical, &features, + &extensions, [(queue, 0.5)].iter().cloned()) + { + Ok(r) => r, + Err(_) => return + }; + + (device, queues.next().unwrap()) + }); +} + +macro_rules! assert_should_panic { + ($msg:expr, $code:block) => ({ + let res = ::std::panic::catch_unwind(|| { + $code + }); + + match res { + Ok(_) => panic!("Test expected to panic but didn't"), + Err(err) => { + if let Some(msg) = err.downcast_ref::<String>() { + assert!(msg.contains($msg)); + } else if let Some(&msg) = err.downcast_ref::<&str>() { + assert!(msg.contains($msg)); + } else { + panic!("Couldn't decipher the panic message of the test") + } + } + } + }); + + ($code:block) => ({ + let res = ::std::panic::catch_unwind(|| { + $code + }); + + match res { + Ok(_) => panic!("Test expected to panic but didn't"), + Err(_) => {} + } + }); +} diff --git a/third_party/cargo/vendor/vulkano-0.11.1/src/version.rs b/third_party/cargo/vendor/vulkano-0.11.1/src/version.rs new file mode 100644 index 0000000..01be60d --- /dev/null +++ b/third_party/cargo/vendor/vulkano-0.11.1/src/version.rs @@ -0,0 +1,145 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT +// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +// The `Version` object is reexported from the `instance` module. + +use std::cmp::Ordering; +use std::fmt; + +/// Represents an API version of Vulkan. +#[derive(Copy, Clone, PartialEq, Eq)] +pub struct Version { + /// Major version number. + pub major: u16, + /// Minor version number. + pub minor: u16, + /// Patch version number. + pub patch: u16, +} + +impl fmt::Debug for Version { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch) + } +} + +impl fmt::Display for Version { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(self, formatter) + } +} + +impl PartialOrd for Version { + #[inline] + fn partial_cmp(&self, other: &Version) -> Option<Ordering> { + Some(self.cmp(other)) + } +} + +impl Ord for Version { + fn cmp(&self, other: &Version) -> Ordering { + match self.major.cmp(&other.major) { + Ordering::Equal => (), + o => return o, + }; + + match self.minor.cmp(&other.minor) { + Ordering::Equal => (), + o => return o, + }; + + self.patch.cmp(&other.patch) + } +} + +impl Version { + /// Turns a version number given by Vulkan into a `Version` struct. + #[inline] + pub fn from_vulkan_version(value: u32) -> Version { + Version { + major: ((value & 0xffc00000) >> 22) as u16, + minor: ((value & 0x003ff000) >> 12) as u16, + patch: (value & 0x00000fff) as u16, + } + } + + /// Turns a `Version` into a version number accepted by Vulkan. + /// + /// # Panic + /// + /// Panics if the values in the `Version` are out of acceptable range. + #[inline] + pub fn into_vulkan_version(&self) -> u32 { + assert!(self.major <= 0x3ff); + assert!(self.minor <= 0x3ff); + assert!(self.patch <= 0xfff); + + (self.major as u32) << 22 | (self.minor as u32) << 12 | (self.patch as u32) + } +} + +#[cfg(test)] +mod tests { + use super::Version; + + #[test] + fn into_vk_version() { + let version = Version { + major: 1, + minor: 0, + patch: 0, + }; + assert_eq!(version.into_vulkan_version(), 0x400000); + } + + #[test] + fn greater_major() { + let v1 = Version { + major: 1, + minor: 0, + patch: 0, + }; + let v2 = Version { + major: 2, + minor: 0, + patch: 0, + }; + assert!(v2 > v1); + } + + #[test] + fn greater_minor() { + let v1 = Version { + major: 1, + minor: 1, + patch: 0, + }; + let v2 = Version { + major: 1, + minor: 3, + patch: 0, + }; + assert!(v2 > v1); + } + + #[test] + fn greater_patch() { + let v1 = Version { + major: 1, + minor: 0, + patch: 4, + }; + let v2 = Version { + major: 1, + minor: 0, + patch: 5, + }; + assert!(v2 > v1); + } +} diff --git a/third_party/cargo/vendor/vulkano-win-0.11.1/.cargo-checksum.json b/third_party/cargo/vendor/vulkano-win-0.11.1/.cargo-checksum.json new file mode 100644 index 0000000..66f8745 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-win-0.11.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"165c8ee51ce7d4cc325b5c5bf43950419c58ce61fddff281f98f85ccd318aa79","src/lib.rs":"0768763d3cee8d98049a603efe7bdca49ca1442633979100a283b95ece6784c2"},"package":"07fffe247f37c8b051e8210ecfb6fe9a13bbb69e05ea61aceb1def5f709320ae"} \ No newline at end of file diff --git a/third_party/cargo/vendor/vulkano-win-0.11.1/BUILD b/third_party/cargo/vendor/vulkano-win-0.11.1/BUILD new file mode 100644 index 0000000..7d36c45 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-win-0.11.1/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "vulkano_win", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/vulkano-0.11.1:vulkano", + "//third_party/cargo/vendor/winit-0.18.1:winit", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.11.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/vulkano-win-0.11.1/Cargo.toml b/third_party/cargo/vendor/vulkano-win-0.11.1/Cargo.toml new file mode 100644 index 0000000..024b2b9 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-win-0.11.1/Cargo.toml @@ -0,0 +1,36 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "vulkano-win" +version = "0.11.1" +authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>", "The vulkano contributors"] +description = "Link between vulkano and winit" +homepage = "https://vulkano.rs" +documentation = "https://docs.rs/vulkano" +keywords = ["vulkan", "bindings", "graphics", "gpu", "rendering"] +categories = ["rendering::graphics-api"] +license = "MIT/Apache-2.0" +repository = "https://github.com/vulkano-rs/vulkano" +[dependencies.vulkano] +version = "0.11.0" + +[dependencies.winit] +version = "0.18" +[target."cfg(target_os = \"macos\")".dependencies.cocoa] +version = "0.18" + +[target."cfg(target_os = \"macos\")".dependencies.metal] +version = "0.13" + +[target."cfg(target_os = \"macos\")".dependencies.objc] +version = "0.2.2" diff --git a/third_party/cargo/vendor/vulkano-win-0.11.1/src/lib.rs b/third_party/cargo/vendor/vulkano-win-0.11.1/src/lib.rs new file mode 100644 index 0000000..fa209e6 --- /dev/null +++ b/third_party/cargo/vendor/vulkano-win-0.11.1/src/lib.rs @@ -0,0 +1,218 @@ +#![doc(html_logo_url = "https://raw.githubusercontent.com/vulkano-rs/vulkano/master/logo.png")] + +extern crate vulkano; +extern crate winit; + +#[cfg(target_os = "macos")] +extern crate objc; +#[cfg(target_os = "macos")] +extern crate cocoa; +#[cfg(target_os = "macos")] +extern crate metal; + +use std::borrow::Borrow; +use std::error; +use std::fmt; +#[cfg(target_os = "windows")] +use std::ptr; +use std::rc::Rc; +use std::sync::Arc; + +use vulkano::instance::Instance; +use vulkano::instance::InstanceExtensions; +use vulkano::swapchain::Surface; +use vulkano::swapchain::SurfaceCreationError; +use winit::{EventsLoop, WindowBuilder}; +use winit::CreationError as WindowCreationError; + +#[cfg(target_os = "macos")] +use cocoa::appkit::{NSView, NSWindow}; +#[cfg(target_os = "macos")] +use cocoa::base::id as cocoa_id; +#[cfg(target_os = "macos")] +use metal::CoreAnimationLayer; +#[cfg(target_os = "macos")] +use objc::runtime::YES; + +#[cfg(target_os = "macos")] +use std::mem; + +pub fn required_extensions() -> InstanceExtensions { + let ideal = InstanceExtensions { + khr_surface: true, + khr_xlib_surface: true, + khr_xcb_surface: true, + khr_wayland_surface: true, + khr_android_surface: true, + khr_win32_surface: true, + mvk_ios_surface: true, + mvk_macos_surface: true, + ..InstanceExtensions::none() + }; + + match InstanceExtensions::supported_by_core() { + Ok(supported) => supported.intersection(&ideal), + Err(_) => InstanceExtensions::none(), + } +} + +/// Create a surface from the window type `W`. The surface borrows the window +/// to prevent it from being dropped before the surface. +pub fn create_vk_surface<W>( + window: W, instance: Arc<Instance> +) -> Result<Arc<Surface<W>>, SurfaceCreationError> +where + W: SafeBorrow<winit::Window>, +{ + unsafe { winit_to_surface(instance, window) } +} + +pub trait VkSurfaceBuild { + fn build_vk_surface( + self, events_loop: &EventsLoop, instance: Arc<Instance>, + ) -> Result<Arc<Surface<winit::Window>>, CreationError>; +} + +impl VkSurfaceBuild for WindowBuilder { + fn build_vk_surface( + self, events_loop: &EventsLoop, instance: Arc<Instance>, + ) -> Result<Arc<Surface<winit::Window>>, CreationError> { + let window = self.build(events_loop)?; + Ok(create_vk_surface(window, instance)?) + } +} + +/// Error that can happen when creating a window. +#[derive(Debug)] +pub enum CreationError { + /// Error when creating the surface. + SurfaceCreationError(SurfaceCreationError), + /// Error when creating the window. + WindowCreationError(WindowCreationError), +} + +impl error::Error for CreationError { + #[inline] + fn description(&self) -> &str { + match *self { + CreationError::SurfaceCreationError(_) => "error while creating the surface", + CreationError::WindowCreationError(_) => "error while creating the window", + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + CreationError::SurfaceCreationError(ref err) => Some(err), + CreationError::WindowCreationError(ref err) => Some(err), + } + } +} + +impl fmt::Display for CreationError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +impl From<SurfaceCreationError> for CreationError { + #[inline] + fn from(err: SurfaceCreationError) -> CreationError { + CreationError::SurfaceCreationError(err) + } +} + +impl From<WindowCreationError> for CreationError { + #[inline] + fn from(err: WindowCreationError) -> CreationError { + CreationError::WindowCreationError(err) + } +} + +#[cfg(target_os = "android")] +unsafe fn winit_to_surface<W: SafeBorrow<winit::Window>>( + instance: Arc<Instance>, win: W, +) -> Result<Arc<Surface<W>>, SurfaceCreationError> { + use winit::os::android::WindowExt; + Surface::from_anativewindow(instance, win.borrow().get_native_window(), win) +} + +#[cfg(all(unix, not(target_os = "android"), not(target_os = "macos")))] +unsafe fn winit_to_surface<W: SafeBorrow<winit::Window>>( + instance: Arc<Instance>, win: W, +) -> Result<Arc<Surface<W>>, SurfaceCreationError> { + use winit::os::unix::WindowExt; + match ( + win.borrow().get_wayland_display(), + win.borrow().get_wayland_surface(), + ) { + (Some(display), Some(surface)) => Surface::from_wayland(instance, display, surface, win), + _ => { + // No wayland display found, check if we can use xlib. + // If not, we use xcb. + if instance.loaded_extensions().khr_xlib_surface { + Surface::from_xlib( + instance, + win.borrow().get_xlib_display().unwrap(), + win.borrow().get_xlib_window().unwrap() as _, + win, + ) + } else { + Surface::from_xcb( + instance, + win.borrow().get_xcb_connection().unwrap(), + win.borrow().get_xlib_window().unwrap() as _, + win, + ) + } + }, + } +} + +#[cfg(target_os = "windows")] +unsafe fn winit_to_surface<W: SafeBorrow<winit::Window>>( + instance: Arc<Instance>, win: W, +) -> Result<Arc<Surface<W>>, SurfaceCreationError> { + use winit::os::windows::WindowExt; + Surface::from_hwnd( + instance, + ptr::null() as *const (), // FIXME + win.borrow().get_hwnd(), + win, + ) +} + +#[cfg(target_os = "macos")] +unsafe fn winit_to_surface<W: SafeBorrow<winit::Window>>( + instance: Arc<Instance>, win: W, +) -> Result<Arc<Surface<W>>, SurfaceCreationError> { + use winit::os::macos::WindowExt; + + let wnd: cocoa_id = mem::transmute(win.borrow().get_nswindow()); + + let layer = CoreAnimationLayer::new(); + + layer.set_edge_antialiasing_mask(0); + layer.set_presents_with_transaction(false); + layer.remove_all_animations(); + + let view = wnd.contentView(); + + layer.set_contents_scale(view.backingScaleFactor()); + view.setLayer(mem::transmute(layer.as_ref())); // Bombs here with out of memory + view.setWantsLayer(YES); + + Surface::from_macos_moltenvk(instance, win.borrow().get_nsview() as *const (), win) +} + +/// An alternative to `Borrow<T>` with the requirement that all calls to +/// `borrow` return the same object. +pub unsafe trait SafeBorrow<T>: Borrow<T> {} + +unsafe impl<T> SafeBorrow<T> for T {} +unsafe impl<'a, T> SafeBorrow<T> for &'a T {} +unsafe impl<'a, T> SafeBorrow<T> for &'a mut T {} +unsafe impl<T> SafeBorrow<T> for Rc<T> {} +unsafe impl<T> SafeBorrow<T> for Arc<T> {} +unsafe impl<T> SafeBorrow<T> for Box<T> {} diff --git a/third_party/cargo/vendor/walkdir-2.3.1/.cargo-checksum.json b/third_party/cargo/vendor/walkdir-2.3.1/.cargo-checksum.json new file mode 100644 index 0000000..aadb1e9 --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"COPYING":"01c266bced4a434da0051174d6bee16a4c82cf634e2679b6155d40d75012390f","Cargo.toml":"82f8a860714a7952156e2ec02f06745707fe43b36e193c4afe91ca30b0b926db","LICENSE-MIT":"0f96a83840e146e43c0ec96a22ec1f392e0680e6c1226e6f3ba87e0740af850f","README.md":"dd77cc3c4d98dc80ef9ad75a7779bf8ae85423c3463a64297fa54d14b715d967","UNLICENSE":"7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c","compare/nftw.c":"6b900b0ac78ce8ece1995f834b194fa14d87d744cabba8f475f0e10b21722c56","compare/walk.py":"d49e26d0b8b2b201d00f2f46bf1f9db46f873c27332da679c9a7adbbf54462d2","rustfmt.toml":"1ca600239a27401c4a43f363cf3f38183a212affc1f31bff3ae93234bbaec228","src/dent.rs":"99226b37127b0a18cf8541b0262fb43b1be52e61b5ae5c574499d316185c5f0d","src/error.rs":"55e9688cc5483eb04b7c765dc8414f51b6342c25264fc3ec248bd7023fa1d93e","src/lib.rs":"9ec13ad047071406c877c03563e621942021725c5d60f50910ce41d6482527e3","src/tests/mod.rs":"bbce9174bfdbb4a81a9000f702be056b63b439cb8f1bcac64b8569368627d56d","src/tests/recursive.rs":"6737833a87e426b4f0b348c176e29af03aa7ade430e6401f14ef010c78e18461","src/tests/util.rs":"ca72ef96f82bb87d8c93d13d581ebb65efcd53fffa87097a84437acecbc30faa","src/util.rs":"14e0da711cad4825ead21446cd61a1444fd49bab853a8a239d8cb74b2caab351"},"package":"777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"} \ No newline at end of file diff --git a/third_party/cargo/vendor/walkdir-2.3.1/BUILD b/third_party/cargo/vendor/walkdir-2.3.1/BUILD new file mode 100644 index 0000000..945a675 --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" + "unencumbered", # "Unlicense" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "walkdir", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/same-file-1.0.6:same_file", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "2.3.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/walkdir-2.3.1/COPYING b/third_party/cargo/vendor/walkdir-2.3.1/COPYING new file mode 100644 index 0000000..bb9c20a --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/third_party/cargo/vendor/walkdir-2.3.1/Cargo.toml b/third_party/cargo/vendor/walkdir-2.3.1/Cargo.toml new file mode 100644 index 0000000..313d6f4 --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/Cargo.toml @@ -0,0 +1,41 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "walkdir" +version = "2.3.1" +authors = ["Andrew Gallant <jamslam@gmail.com>"] +exclude = ["/ci/*", "/.travis.yml", "/appveyor.yml"] +description = "Recursively walk a directory." +homepage = "https://github.com/BurntSushi/walkdir" +documentation = "https://docs.rs/walkdir/" +readme = "README.md" +keywords = ["directory", "recursive", "walk", "iterator"] +categories = ["filesystem"] +license = "Unlicense/MIT" +repository = "https://github.com/BurntSushi/walkdir" +[dependencies.same-file] +version = "1.0.1" +[dev-dependencies.doc-comment] +version = "0.3" +[target."cfg(windows)".dependencies.winapi] +version = "0.3" +features = ["std", "winnt"] + +[target."cfg(windows)".dependencies.winapi-util] +version = "0.1.1" +[badges.appveyor] +repository = "BurntSushi/walkdir" + +[badges.travis-ci] +repository = "BurntSushi/walkdir" diff --git a/third_party/cargo/vendor/walkdir-2.3.1/LICENSE-MIT b/third_party/cargo/vendor/walkdir-2.3.1/LICENSE-MIT new file mode 100644 index 0000000..3b0a5dc --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/third_party/cargo/vendor/walkdir-2.3.1/README.md b/third_party/cargo/vendor/walkdir-2.3.1/README.md new file mode 100644 index 0000000..2b49506 --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/README.md @@ -0,0 +1,139 @@ +walkdir +======= +A cross platform Rust library for efficiently walking a directory recursively. +Comes with support for following symbolic links, controlling the number of +open file descriptors and efficient mechanisms for pruning the entries in the +directory tree. + +[![Build status](https://github.com/BurntSushi/walkdir/workflows/ci/badge.svg)](https://github.com/BurntSushi/walkdir/actions) +[![](http://meritbadge.herokuapp.com/walkdir)](https://crates.io/crates/walkdir) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + +### Documentation + +[docs.rs/walkdir](https://docs.rs/walkdir/) + +### Usage + +To use this crate, add `walkdir` as a dependency to your project's +`Cargo.toml`: + +```toml +[dependencies] +walkdir = "2" +``` + +### Example + +The following code recursively iterates over the directory given and prints +the path for each entry: + +```rust,no_run +use walkdir::WalkDir; + +for entry in WalkDir::new("foo") { + let entry = entry.unwrap(); + println!("{}", entry.path().display()); +} +``` + +Or, if you'd like to iterate over all entries and ignore any errors that may +arise, use `filter_map`. (e.g., This code below will silently skip directories +that the owner of the running process does not have permission to access.) + +```rust,no_run +use walkdir::WalkDir; + +for entry in WalkDir::new("foo").into_iter().filter_map(|e| e.ok()) { + println!("{}", entry.path().display()); +} +``` + +### Example: follow symbolic links + +The same code as above, except `follow_links` is enabled: + +```rust,no_run +use walkdir::WalkDir; + +for entry in WalkDir::new("foo").follow_links(true) { + let entry = entry.unwrap(); + println!("{}", entry.path().display()); +} +``` + +### Example: skip hidden files and directories efficiently on unix + +This uses the `filter_entry` iterator adapter to avoid yielding hidden files +and directories efficiently: + +```rust,no_run +use walkdir::{DirEntry, WalkDir}; + +fn is_hidden(entry: &DirEntry) -> bool { + entry.file_name() + .to_str() + .map(|s| s.starts_with(".")) + .unwrap_or(false) +} + +let walker = WalkDir::new("foo").into_iter(); +for entry in walker.filter_entry(|e| !is_hidden(e)) { + let entry = entry.unwrap(); + println!("{}", entry.path().display()); +} +``` + +### Minimum Rust version policy + +This crate's minimum supported `rustc` version is `1.34.0`. + +The current policy is that the minimum Rust version required to use this crate +can be increased in minor version updates. For example, if `crate 1.0` requires +Rust 1.20.0, then `crate 1.0.z` for all values of `z` will also require Rust +1.20.0 or newer. However, `crate 1.y` for `y > 0` may require a newer minimum +version of Rust. + +In general, this crate will be conservative with respect to the minimum +supported version of Rust. + +### Performance + +The short story is that performance is comparable with `find` and glibc's +`nftw` on both a warm and cold file cache. In fact, I cannot observe any +performance difference after running `find /`, `walkdir /` and `nftw /` on my +local file system (SSD, ~3 million entries). More precisely, I am reasonably +confident that this crate makes as few system calls and close to as few +allocations as possible. + +I haven't recorded any benchmarks, but here are some things you can try with a +local checkout of `walkdir`: + +```sh +# The directory you want to recursively walk: +DIR=$HOME + +# If you want to observe perf on a cold file cache, run this before *each* +# command: +sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches' + +# To warm the caches +find $DIR + +# Test speed of `find` on warm cache: +time find $DIR + +# Compile and test speed of `walkdir` crate: +cargo build --release --example walkdir +time ./target/release/examples/walkdir $DIR + +# Compile and test speed of glibc's `nftw`: +gcc -O3 -o nftw ./compare/nftw.c +time ./nftw $DIR + +# For shits and giggles, test speed of Python's (2 or 3) os.walk: +time python ./compare/walk.py $DIR +``` + +On my system, the performance of `walkdir`, `find` and `nftw` is comparable. diff --git a/third_party/cargo/vendor/walkdir-2.3.1/UNLICENSE b/third_party/cargo/vendor/walkdir-2.3.1/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <http://unlicense.org/> diff --git a/third_party/cargo/vendor/walkdir-2.3.1/compare/nftw.c b/third_party/cargo/vendor/walkdir-2.3.1/compare/nftw.c new file mode 100644 index 0000000..7d36e2f --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/compare/nftw.c @@ -0,0 +1,25 @@ +#define _XOPEN_SOURCE 500 +#include <ftw.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +static int +display_info(const char *fpath, const struct stat *sb, + int tflag, struct FTW *ftwbuf) +{ + printf("%s\n", fpath); + return 0; +} + +int +main(int argc, char *argv[]) +{ + int flags = FTW_PHYS; + if (nftw((argc < 2) ? "." : argv[1], display_info, 20, flags) == -1) { + perror("nftw"); + exit(EXIT_FAILURE); + } + exit(EXIT_SUCCESS); +} diff --git a/third_party/cargo/vendor/walkdir-2.3.1/compare/walk.py b/third_party/cargo/vendor/walkdir-2.3.1/compare/walk.py new file mode 100644 index 0000000..303d323 --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/compare/walk.py @@ -0,0 +1,10 @@ +from __future__ import absolute_import, division, print_function + +import os +import sys + +for dirpath, dirnames, filenames in os.walk(sys.argv[1]): + for n in dirnames: + print(os.path.join(dirpath, n)) + for n in filenames: + print(os.path.join(dirpath, n)) diff --git a/third_party/cargo/vendor/walkdir-2.3.1/rustfmt.toml b/third_party/cargo/vendor/walkdir-2.3.1/rustfmt.toml new file mode 100644 index 0000000..aa37a21 --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/rustfmt.toml @@ -0,0 +1,2 @@ +max_width = 79 +use_small_heuristics = "max" diff --git a/third_party/cargo/vendor/walkdir-2.3.1/src/dent.rs b/third_party/cargo/vendor/walkdir-2.3.1/src/dent.rs new file mode 100644 index 0000000..a28ed3d --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/src/dent.rs @@ -0,0 +1,375 @@ +use std::ffi::OsStr; +use std::fmt; +use std::fs::{self, FileType}; +use std::path::{Path, PathBuf}; + +use crate::error::Error; +use crate::Result; + +/// A directory entry. +/// +/// This is the type of value that is yielded from the iterators defined in +/// this crate. +/// +/// On Unix systems, this type implements the [`DirEntryExt`] trait, which +/// provides efficient access to the inode number of the directory entry. +/// +/// # Differences with `std::fs::DirEntry` +/// +/// This type mostly mirrors the type by the same name in [`std::fs`]. There +/// are some differences however: +/// +/// * All recursive directory iterators must inspect the entry's type. +/// Therefore, the value is stored and its access is guaranteed to be cheap and +/// successful. +/// * [`path`] and [`file_name`] return borrowed variants. +/// * If [`follow_links`] was enabled on the originating iterator, then all +/// operations except for [`path`] operate on the link target. Otherwise, all +/// operations operate on the symbolic link. +/// +/// [`std::fs`]: https://doc.rust-lang.org/stable/std/fs/index.html +/// [`path`]: #method.path +/// [`file_name`]: #method.file_name +/// [`follow_links`]: struct.WalkDir.html#method.follow_links +/// [`DirEntryExt`]: trait.DirEntryExt.html +pub struct DirEntry { + /// The path as reported by the [`fs::ReadDir`] iterator (even if it's a + /// symbolic link). + /// + /// [`fs::ReadDir`]: https://doc.rust-lang.org/stable/std/fs/struct.ReadDir.html + path: PathBuf, + /// The file type. Necessary for recursive iteration, so store it. + ty: FileType, + /// Is set when this entry was created from a symbolic link and the user + /// expects the iterator to follow symbolic links. + follow_link: bool, + /// The depth at which this entry was generated relative to the root. + depth: usize, + /// The underlying inode number (Unix only). + #[cfg(unix)] + ino: u64, + /// The underlying metadata (Windows only). We store this on Windows + /// because this comes for free while reading a directory. + /// + /// We use this to determine whether an entry is a directory or not, which + /// works around a bug in Rust's standard library: + /// https://github.com/rust-lang/rust/issues/46484 + #[cfg(windows)] + metadata: fs::Metadata, +} + +impl DirEntry { + /// The full path that this entry represents. + /// + /// The full path is created by joining the parents of this entry up to the + /// root initially given to [`WalkDir::new`] with the file name of this + /// entry. + /// + /// Note that this *always* returns the path reported by the underlying + /// directory entry, even when symbolic links are followed. To get the + /// target path, use [`path_is_symlink`] to (cheaply) check if this entry + /// corresponds to a symbolic link, and [`std::fs::read_link`] to resolve + /// the target. + /// + /// [`WalkDir::new`]: struct.WalkDir.html#method.new + /// [`path_is_symlink`]: struct.DirEntry.html#method.path_is_symlink + /// [`std::fs::read_link`]: https://doc.rust-lang.org/stable/std/fs/fn.read_link.html + pub fn path(&self) -> &Path { + &self.path + } + + /// The full path that this entry represents. + /// + /// Analogous to [`path`], but moves ownership of the path. + /// + /// [`path`]: struct.DirEntry.html#method.path + pub fn into_path(self) -> PathBuf { + self.path + } + + /// Returns `true` if and only if this entry was created from a symbolic + /// link. This is unaffected by the [`follow_links`] setting. + /// + /// When `true`, the value returned by the [`path`] method is a + /// symbolic link name. To get the full target path, you must call + /// [`std::fs::read_link(entry.path())`]. + /// + /// [`path`]: struct.DirEntry.html#method.path + /// [`follow_links`]: struct.WalkDir.html#method.follow_links + /// [`std::fs::read_link(entry.path())`]: https://doc.rust-lang.org/stable/std/fs/fn.read_link.html + pub fn path_is_symlink(&self) -> bool { + self.ty.is_symlink() || self.follow_link + } + + /// Return the metadata for the file that this entry points to. + /// + /// This will follow symbolic links if and only if the [`WalkDir`] value + /// has [`follow_links`] enabled. + /// + /// # Platform behavior + /// + /// This always calls [`std::fs::symlink_metadata`]. + /// + /// If this entry is a symbolic link and [`follow_links`] is enabled, then + /// [`std::fs::metadata`] is called instead. + /// + /// # Errors + /// + /// Similar to [`std::fs::metadata`], returns errors for path values that + /// the program does not have permissions to access or if the path does not + /// exist. + /// + /// [`WalkDir`]: struct.WalkDir.html + /// [`follow_links`]: struct.WalkDir.html#method.follow_links + /// [`std::fs::metadata`]: https://doc.rust-lang.org/std/fs/fn.metadata.html + /// [`std::fs::symlink_metadata`]: https://doc.rust-lang.org/stable/std/fs/fn.symlink_metadata.html + pub fn metadata(&self) -> Result<fs::Metadata> { + self.metadata_internal() + } + + #[cfg(windows)] + fn metadata_internal(&self) -> Result<fs::Metadata> { + if self.follow_link { + fs::metadata(&self.path) + } else { + Ok(self.metadata.clone()) + } + .map_err(|err| Error::from_entry(self, err)) + } + + #[cfg(not(windows))] + fn metadata_internal(&self) -> Result<fs::Metadata> { + if self.follow_link { + fs::metadata(&self.path) + } else { + fs::symlink_metadata(&self.path) + } + .map_err(|err| Error::from_entry(self, err)) + } + + /// Return the file type for the file that this entry points to. + /// + /// If this is a symbolic link and [`follow_links`] is `true`, then this + /// returns the type of the target. + /// + /// This never makes any system calls. + /// + /// [`follow_links`]: struct.WalkDir.html#method.follow_links + pub fn file_type(&self) -> fs::FileType { + self.ty + } + + /// Return the file name of this entry. + /// + /// If this entry has no file name (e.g., `/`), then the full path is + /// returned. + pub fn file_name(&self) -> &OsStr { + self.path.file_name().unwrap_or_else(|| self.path.as_os_str()) + } + + /// Returns the depth at which this entry was created relative to the root. + /// + /// The smallest depth is `0` and always corresponds to the path given + /// to the `new` function on `WalkDir`. Its direct descendents have depth + /// `1`, and their descendents have depth `2`, and so on. + pub fn depth(&self) -> usize { + self.depth + } + + /// Returns true if and only if this entry points to a directory. + /// + /// This works around a bug in Rust's standard library: + /// https://github.com/rust-lang/rust/issues/46484 + #[cfg(windows)] + pub(crate) fn is_dir(&self) -> bool { + use std::os::windows::fs::MetadataExt; + use winapi::um::winnt::FILE_ATTRIBUTE_DIRECTORY; + self.metadata.file_attributes() & FILE_ATTRIBUTE_DIRECTORY != 0 + } + + /// Returns true if and only if this entry points to a directory. + #[cfg(not(windows))] + pub(crate) fn is_dir(&self) -> bool { + self.ty.is_dir() + } + + #[cfg(windows)] + pub(crate) fn from_entry( + depth: usize, + ent: &fs::DirEntry, + ) -> Result<DirEntry> { + let path = ent.path(); + let ty = ent + .file_type() + .map_err(|err| Error::from_path(depth, path.clone(), err))?; + let md = ent + .metadata() + .map_err(|err| Error::from_path(depth, path.clone(), err))?; + Ok(DirEntry { + path: path, + ty: ty, + follow_link: false, + depth: depth, + metadata: md, + }) + } + + #[cfg(unix)] + pub(crate) fn from_entry( + depth: usize, + ent: &fs::DirEntry, + ) -> Result<DirEntry> { + use std::os::unix::fs::DirEntryExt; + + let ty = ent + .file_type() + .map_err(|err| Error::from_path(depth, ent.path(), err))?; + Ok(DirEntry { + path: ent.path(), + ty: ty, + follow_link: false, + depth: depth, + ino: ent.ino(), + }) + } + + #[cfg(not(any(unix, windows)))] + pub(crate) fn from_entry( + depth: usize, + ent: &fs::DirEntry, + ) -> Result<DirEntry> { + let ty = ent + .file_type() + .map_err(|err| Error::from_path(depth, ent.path(), err))?; + Ok(DirEntry { + path: ent.path(), + ty: ty, + follow_link: false, + depth: depth, + }) + } + + #[cfg(windows)] + pub(crate) fn from_path( + depth: usize, + pb: PathBuf, + follow: bool, + ) -> Result<DirEntry> { + let md = if follow { + fs::metadata(&pb) + .map_err(|err| Error::from_path(depth, pb.clone(), err))? + } else { + fs::symlink_metadata(&pb) + .map_err(|err| Error::from_path(depth, pb.clone(), err))? + }; + Ok(DirEntry { + path: pb, + ty: md.file_type(), + follow_link: follow, + depth: depth, + metadata: md, + }) + } + + #[cfg(unix)] + pub(crate) fn from_path( + depth: usize, + pb: PathBuf, + follow: bool, + ) -> Result<DirEntry> { + use std::os::unix::fs::MetadataExt; + + let md = if follow { + fs::metadata(&pb) + .map_err(|err| Error::from_path(depth, pb.clone(), err))? + } else { + fs::symlink_metadata(&pb) + .map_err(|err| Error::from_path(depth, pb.clone(), err))? + }; + Ok(DirEntry { + path: pb, + ty: md.file_type(), + follow_link: follow, + depth: depth, + ino: md.ino(), + }) + } + + #[cfg(not(any(unix, windows)))] + pub(crate) fn from_path( + depth: usize, + pb: PathBuf, + follow: bool, + ) -> Result<DirEntry> { + let md = if follow { + fs::metadata(&pb) + .map_err(|err| Error::from_path(depth, pb.clone(), err))? + } else { + fs::symlink_metadata(&pb) + .map_err(|err| Error::from_path(depth, pb.clone(), err))? + }; + Ok(DirEntry { + path: pb, + ty: md.file_type(), + follow_link: follow, + depth: depth, + }) + } +} + +impl Clone for DirEntry { + #[cfg(windows)] + fn clone(&self) -> DirEntry { + DirEntry { + path: self.path.clone(), + ty: self.ty, + follow_link: self.follow_link, + depth: self.depth, + metadata: self.metadata.clone(), + } + } + + #[cfg(unix)] + fn clone(&self) -> DirEntry { + DirEntry { + path: self.path.clone(), + ty: self.ty, + follow_link: self.follow_link, + depth: self.depth, + ino: self.ino, + } + } + + #[cfg(not(any(unix, windows)))] + fn clone(&self) -> DirEntry { + DirEntry { + path: self.path.clone(), + ty: self.ty, + follow_link: self.follow_link, + depth: self.depth, + } + } +} + +impl fmt::Debug for DirEntry { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "DirEntry({:?})", self.path) + } +} + +/// Unix-specific extension methods for `walkdir::DirEntry` +#[cfg(unix)] +pub trait DirEntryExt { + /// Returns the underlying `d_ino` field in the contained `dirent` + /// structure. + fn ino(&self) -> u64; +} + +#[cfg(unix)] +impl DirEntryExt for DirEntry { + /// Returns the underlying `d_ino` field in the contained `dirent` + /// structure. + fn ino(&self) -> u64 { + self.ino + } +} diff --git a/third_party/cargo/vendor/walkdir-2.3.1/src/error.rs b/third_party/cargo/vendor/walkdir-2.3.1/src/error.rs new file mode 100644 index 0000000..3fb619c --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/src/error.rs @@ -0,0 +1,265 @@ +use std::error; +use std::fmt; +use std::io; +use std::path::{Path, PathBuf}; + +use crate::DirEntry; + +/// An error produced by recursively walking a directory. +/// +/// This error type is a light wrapper around [`std::io::Error`]. In +/// particular, it adds the following information: +/// +/// * The depth at which the error occurred in the file tree, relative to the +/// root. +/// * The path, if any, associated with the IO error. +/// * An indication that a loop occurred when following symbolic links. In this +/// case, there is no underlying IO error. +/// +/// To maintain good ergonomics, this type has a +/// [`impl From<Error> for std::io::Error`][impl] defined which preserves the original context. +/// This allows you to use an [`io::Result`] with methods in this crate if you don't care about +/// accessing the underlying error data in a structured form. +/// +/// [`std::io::Error`]: https://doc.rust-lang.org/stable/std/io/struct.Error.html +/// [`io::Result`]: https://doc.rust-lang.org/stable/std/io/type.Result.html +/// [impl]: struct.Error.html#impl-From%3CError%3E +#[derive(Debug)] +pub struct Error { + depth: usize, + inner: ErrorInner, +} + +#[derive(Debug)] +enum ErrorInner { + Io { path: Option<PathBuf>, err: io::Error }, + Loop { ancestor: PathBuf, child: PathBuf }, +} + +impl Error { + /// Returns the path associated with this error if one exists. + /// + /// For example, if an error occurred while opening a directory handle, + /// the error will include the path passed to [`std::fs::read_dir`]. + /// + /// [`std::fs::read_dir`]: https://doc.rust-lang.org/stable/std/fs/fn.read_dir.html + pub fn path(&self) -> Option<&Path> { + match self.inner { + ErrorInner::Io { path: None, .. } => None, + ErrorInner::Io { path: Some(ref path), .. } => Some(path), + ErrorInner::Loop { ref child, .. } => Some(child), + } + } + + /// Returns the path at which a cycle was detected. + /// + /// If no cycle was detected, [`None`] is returned. + /// + /// A cycle is detected when a directory entry is equivalent to one of + /// its ancestors. + /// + /// To get the path to the child directory entry in the cycle, use the + /// [`path`] method. + /// + /// [`None`]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#variant.None + /// [`path`]: struct.Error.html#path + pub fn loop_ancestor(&self) -> Option<&Path> { + match self.inner { + ErrorInner::Loop { ref ancestor, .. } => Some(ancestor), + _ => None, + } + } + + /// Returns the depth at which this error occurred relative to the root. + /// + /// The smallest depth is `0` and always corresponds to the path given to + /// the [`new`] function on [`WalkDir`]. Its direct descendents have depth + /// `1`, and their descendents have depth `2`, and so on. + /// + /// [`new`]: struct.WalkDir.html#method.new + /// [`WalkDir`]: struct.WalkDir.html + pub fn depth(&self) -> usize { + self.depth + } + + /// Inspect the original [`io::Error`] if there is one. + /// + /// [`None`] is returned if the [`Error`] doesn't correspond to an + /// [`io::Error`]. This might happen, for example, when the error was + /// produced because a cycle was found in the directory tree while + /// following symbolic links. + /// + /// This method returns a borrowed value that is bound to the lifetime of the [`Error`]. To + /// obtain an owned value, the [`into_io_error`] can be used instead. + /// + /// > This is the original [`io::Error`] and is _not_ the same as + /// > [`impl From<Error> for std::io::Error`][impl] which contains additional context about the + /// error. + /// + /// # Example + /// + /// ```rust,no-run + /// use std::io; + /// use std::path::Path; + /// + /// use walkdir::WalkDir; + /// + /// for entry in WalkDir::new("foo") { + /// match entry { + /// Ok(entry) => println!("{}", entry.path().display()), + /// Err(err) => { + /// let path = err.path().unwrap_or(Path::new("")).display(); + /// println!("failed to access entry {}", path); + /// if let Some(inner) = err.io_error() { + /// match inner.kind() { + /// io::ErrorKind::InvalidData => { + /// println!( + /// "entry contains invalid data: {}", + /// inner) + /// } + /// io::ErrorKind::PermissionDenied => { + /// println!( + /// "Missing permission to read entry: {}", + /// inner) + /// } + /// _ => { + /// println!( + /// "Unexpected error occurred: {}", + /// inner) + /// } + /// } + /// } + /// } + /// } + /// } + /// ``` + /// + /// [`None`]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#variant.None + /// [`io::Error`]: https://doc.rust-lang.org/stable/std/io/struct.Error.html + /// [`From`]: https://doc.rust-lang.org/stable/std/convert/trait.From.html + /// [`Error`]: struct.Error.html + /// [`into_io_error`]: struct.Error.html#method.into_io_error + /// [impl]: struct.Error.html#impl-From%3CError%3E + pub fn io_error(&self) -> Option<&io::Error> { + match self.inner { + ErrorInner::Io { ref err, .. } => Some(err), + ErrorInner::Loop { .. } => None, + } + } + + /// Similar to [`io_error`] except consumes self to convert to the original + /// [`io::Error`] if one exists. + /// + /// [`io_error`]: struct.Error.html#method.io_error + /// [`io::Error`]: https://doc.rust-lang.org/stable/std/io/struct.Error.html + pub fn into_io_error(self) -> Option<io::Error> { + match self.inner { + ErrorInner::Io { err, .. } => Some(err), + ErrorInner::Loop { .. } => None, + } + } + + pub(crate) fn from_path( + depth: usize, + pb: PathBuf, + err: io::Error, + ) -> Self { + Error { + depth: depth, + inner: ErrorInner::Io { path: Some(pb), err: err }, + } + } + + pub(crate) fn from_entry(dent: &DirEntry, err: io::Error) -> Self { + Error { + depth: dent.depth(), + inner: ErrorInner::Io { + path: Some(dent.path().to_path_buf()), + err: err, + }, + } + } + + pub(crate) fn from_io(depth: usize, err: io::Error) -> Self { + Error { depth: depth, inner: ErrorInner::Io { path: None, err: err } } + } + + pub(crate) fn from_loop( + depth: usize, + ancestor: &Path, + child: &Path, + ) -> Self { + Error { + depth: depth, + inner: ErrorInner::Loop { + ancestor: ancestor.to_path_buf(), + child: child.to_path_buf(), + }, + } + } +} + +impl error::Error for Error { + #[allow(deprecated)] + fn description(&self) -> &str { + match self.inner { + ErrorInner::Io { ref err, .. } => err.description(), + ErrorInner::Loop { .. } => "file system loop found", + } + } + + fn cause(&self) -> Option<&dyn error::Error> { + self.source() + } + + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + match self.inner { + ErrorInner::Io { ref err, .. } => Some(err), + ErrorInner::Loop { .. } => None, + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self.inner { + ErrorInner::Io { path: None, ref err } => err.fmt(f), + ErrorInner::Io { path: Some(ref path), ref err } => write!( + f, + "IO error for operation on {}: {}", + path.display(), + err + ), + ErrorInner::Loop { ref ancestor, ref child } => write!( + f, + "File system loop found: \ + {} points to an ancestor {}", + child.display(), + ancestor.display() + ), + } + } +} + +impl From<Error> for io::Error { + /// Convert the [`Error`] to an [`io::Error`], preserving the original + /// [`Error`] as the ["inner error"]. Note that this also makes the display + /// of the error include the context. + /// + /// This is different from [`into_io_error`] which returns the original + /// [`io::Error`]. + /// + /// [`Error`]: struct.Error.html + /// [`io::Error`]: https://doc.rust-lang.org/stable/std/io/struct.Error.html + /// ["inner error"]: https://doc.rust-lang.org/std/io/struct.Error.html#method.into_inner + /// [`into_io_error`]: struct.WalkDir.html#method.into_io_error + fn from(walk_err: Error) -> io::Error { + let kind = match walk_err { + Error { inner: ErrorInner::Io { ref err, .. }, .. } => err.kind(), + Error { inner: ErrorInner::Loop { .. }, .. } => { + io::ErrorKind::Other + } + }; + io::Error::new(kind, walk_err) + } +} diff --git a/third_party/cargo/vendor/walkdir-2.3.1/src/lib.rs b/third_party/cargo/vendor/walkdir-2.3.1/src/lib.rs new file mode 100644 index 0000000..5132dd5 --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/src/lib.rs @@ -0,0 +1,1125 @@ +/*! +Crate `walkdir` provides an efficient and cross platform implementation +of recursive directory traversal. Several options are exposed to control +iteration, such as whether to follow symbolic links (default off), limit the +maximum number of simultaneous open file descriptors and the ability to +efficiently skip descending into directories. + +To use this crate, add `walkdir` as a dependency to your project's +`Cargo.toml`: + +```toml +[dependencies] +walkdir = "2" +``` + +# From the top + +The [`WalkDir`] type builds iterators. The [`DirEntry`] type describes values +yielded by the iterator. Finally, the [`Error`] type is a small wrapper around +[`std::io::Error`] with additional information, such as if a loop was detected +while following symbolic links (not enabled by default). + +[`WalkDir`]: struct.WalkDir.html +[`DirEntry`]: struct.DirEntry.html +[`Error`]: struct.Error.html +[`std::io::Error`]: https://doc.rust-lang.org/stable/std/io/struct.Error.html + +# Example + +The following code recursively iterates over the directory given and prints +the path for each entry: + +```no_run +use walkdir::WalkDir; +# use walkdir::Error; + +# fn try_main() -> Result<(), Error> { +for entry in WalkDir::new("foo") { + println!("{}", entry?.path().display()); +} +# Ok(()) +# } +``` + +Or, if you'd like to iterate over all entries and ignore any errors that +may arise, use [`filter_map`]. (e.g., This code below will silently skip +directories that the owner of the running process does not have permission to +access.) + +```no_run +use walkdir::WalkDir; + +for entry in WalkDir::new("foo").into_iter().filter_map(|e| e.ok()) { + println!("{}", entry.path().display()); +} +``` + +[`filter_map`]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html#method.filter_map + +# Example: follow symbolic links + +The same code as above, except [`follow_links`] is enabled: + +```no_run +use walkdir::WalkDir; +# use walkdir::Error; + +# fn try_main() -> Result<(), Error> { +for entry in WalkDir::new("foo").follow_links(true) { + println!("{}", entry?.path().display()); +} +# Ok(()) +# } +``` + +[`follow_links`]: struct.WalkDir.html#method.follow_links + +# Example: skip hidden files and directories on unix + +This uses the [`filter_entry`] iterator adapter to avoid yielding hidden files +and directories efficiently (i.e. without recursing into hidden directories): + +```no_run +use walkdir::{DirEntry, WalkDir}; +# use walkdir::Error; + +fn is_hidden(entry: &DirEntry) -> bool { + entry.file_name() + .to_str() + .map(|s| s.starts_with(".")) + .unwrap_or(false) +} + +# fn try_main() -> Result<(), Error> { +let walker = WalkDir::new("foo").into_iter(); +for entry in walker.filter_entry(|e| !is_hidden(e)) { + println!("{}", entry?.path().display()); +} +# Ok(()) +# } +``` + +[`filter_entry`]: struct.IntoIter.html#method.filter_entry +*/ + +#![deny(missing_docs)] +#![allow(unknown_lints)] + +#[cfg(test)] +doc_comment::doctest!("../README.md"); + +use std::cmp::{min, Ordering}; +use std::fmt; +use std::fs::{self, ReadDir}; +use std::io; +use std::path::{Path, PathBuf}; +use std::result; +use std::vec; + +use same_file::Handle; + +pub use crate::dent::DirEntry; +#[cfg(unix)] +pub use crate::dent::DirEntryExt; +pub use crate::error::Error; + +mod dent; +mod error; +#[cfg(test)] +mod tests; +mod util; + +/// Like try, but for iterators that return [`Option<Result<_, _>>`]. +/// +/// [`Option<Result<_, _>>`]: https://doc.rust-lang.org/stable/std/option/enum.Option.html +macro_rules! itry { + ($e:expr) => { + match $e { + Ok(v) => v, + Err(err) => return Some(Err(From::from(err))), + } + }; +} + +/// A result type for walkdir operations. +/// +/// Note that this result type embeds the error type in this crate. This +/// is only useful if you care about the additional information provided by +/// the error (such as the path associated with the error or whether a loop +/// was dectected). If you want things to Just Work, then you can use +/// [`io::Result`] instead since the error type in this package will +/// automatically convert to an [`io::Result`] when using the [`try!`] macro. +/// +/// [`io::Result`]: https://doc.rust-lang.org/stable/std/io/type.Result.html +/// [`try!`]: https://doc.rust-lang.org/stable/std/macro.try.html +pub type Result<T> = ::std::result::Result<T, Error>; + +/// A builder to create an iterator for recursively walking a directory. +/// +/// Results are returned in depth first fashion, with directories yielded +/// before their contents. If [`contents_first`] is true, contents are yielded +/// before their directories. The order is unspecified but if [`sort_by`] is +/// given, directory entries are sorted according to this function. Directory +/// entries `.` and `..` are always omitted. +/// +/// If an error occurs at any point during iteration, then it is returned in +/// place of its corresponding directory entry and iteration continues as +/// normal. If an error occurs while opening a directory for reading, then it +/// is not descended into (but the error is still yielded by the iterator). +/// Iteration may be stopped at any time. When the iterator is destroyed, all +/// resources associated with it are freed. +/// +/// [`contents_first`]: struct.WalkDir.html#method.contents_first +/// [`sort_by`]: struct.WalkDir.html#method.sort_by +/// +/// # Usage +/// +/// This type implements [`IntoIterator`] so that it may be used as the subject +/// of a `for` loop. You may need to call [`into_iter`] explicitly if you want +/// to use iterator adapters such as [`filter_entry`]. +/// +/// Idiomatic use of this type should use method chaining to set desired +/// options. For example, this only shows entries with a depth of `1`, `2` or +/// `3` (relative to `foo`): +/// +/// ```no_run +/// use walkdir::WalkDir; +/// # use walkdir::Error; +/// +/// # fn try_main() -> Result<(), Error> { +/// for entry in WalkDir::new("foo").min_depth(1).max_depth(3) { +/// println!("{}", entry?.path().display()); +/// } +/// # Ok(()) +/// # } +/// ``` +/// +/// [`IntoIterator`]: https://doc.rust-lang.org/stable/std/iter/trait.IntoIterator.html +/// [`into_iter`]: https://doc.rust-lang.org/nightly/core/iter/trait.IntoIterator.html#tymethod.into_iter +/// [`filter_entry`]: struct.IntoIter.html#method.filter_entry +/// +/// Note that the iterator by default includes the top-most directory. Since +/// this is the only directory yielded with depth `0`, it is easy to ignore it +/// with the [`min_depth`] setting: +/// +/// ```no_run +/// use walkdir::WalkDir; +/// # use walkdir::Error; +/// +/// # fn try_main() -> Result<(), Error> { +/// for entry in WalkDir::new("foo").min_depth(1) { +/// println!("{}", entry?.path().display()); +/// } +/// # Ok(()) +/// # } +/// ``` +/// +/// [`min_depth`]: struct.WalkDir.html#method.min_depth +/// +/// This will only return descendents of the `foo` directory and not `foo` +/// itself. +/// +/// # Loops +/// +/// This iterator (like most/all recursive directory iterators) assumes that +/// no loops can be made with *hard* links on your file system. In particular, +/// this would require creating a hard link to a directory such that it creates +/// a loop. On most platforms, this operation is illegal. +/// +/// Note that when following symbolic/soft links, loops are detected and an +/// error is reported. +#[derive(Debug)] +pub struct WalkDir { + opts: WalkDirOptions, + root: PathBuf, +} + +struct WalkDirOptions { + follow_links: bool, + max_open: usize, + min_depth: usize, + max_depth: usize, + sorter: Option< + Box< + dyn FnMut(&DirEntry, &DirEntry) -> Ordering + + Send + + Sync + + 'static, + >, + >, + contents_first: bool, + same_file_system: bool, +} + +impl fmt::Debug for WalkDirOptions { + fn fmt( + &self, + f: &mut fmt::Formatter<'_>, + ) -> result::Result<(), fmt::Error> { + let sorter_str = if self.sorter.is_some() { + // FnMut isn't `Debug` + "Some(...)" + } else { + "None" + }; + f.debug_struct("WalkDirOptions") + .field("follow_links", &self.follow_links) + .field("max_open", &self.max_open) + .field("min_depth", &self.min_depth) + .field("max_depth", &self.max_depth) + .field("sorter", &sorter_str) + .field("contents_first", &self.contents_first) + .field("same_file_system", &self.same_file_system) + .finish() + } +} + +impl WalkDir { + /// Create a builder for a recursive directory iterator starting at the + /// file path `root`. If `root` is a directory, then it is the first item + /// yielded by the iterator. If `root` is a file, then it is the first + /// and only item yielded by the iterator. If `root` is a symlink, then it + /// is always followed for the purposes of directory traversal. (A root + /// `DirEntry` still obeys its documentation with respect to symlinks and + /// the `follow_links` setting.) + pub fn new<P: AsRef<Path>>(root: P) -> Self { + WalkDir { + opts: WalkDirOptions { + follow_links: false, + max_open: 10, + min_depth: 0, + max_depth: ::std::usize::MAX, + sorter: None, + contents_first: false, + same_file_system: false, + }, + root: root.as_ref().to_path_buf(), + } + } + + /// Set the minimum depth of entries yielded by the iterator. + /// + /// The smallest depth is `0` and always corresponds to the path given + /// to the `new` function on this type. Its direct descendents have depth + /// `1`, and their descendents have depth `2`, and so on. + pub fn min_depth(mut self, depth: usize) -> Self { + self.opts.min_depth = depth; + if self.opts.min_depth > self.opts.max_depth { + self.opts.min_depth = self.opts.max_depth; + } + self + } + + /// Set the maximum depth of entries yield by the iterator. + /// + /// The smallest depth is `0` and always corresponds to the path given + /// to the `new` function on this type. Its direct descendents have depth + /// `1`, and their descendents have depth `2`, and so on. + /// + /// Note that this will not simply filter the entries of the iterator, but + /// it will actually avoid descending into directories when the depth is + /// exceeded. + pub fn max_depth(mut self, depth: usize) -> Self { + self.opts.max_depth = depth; + if self.opts.max_depth < self.opts.min_depth { + self.opts.max_depth = self.opts.min_depth; + } + self + } + + /// Follow symbolic links. By default, this is disabled. + /// + /// When `yes` is `true`, symbolic links are followed as if they were + /// normal directories and files. If a symbolic link is broken or is + /// involved in a loop, an error is yielded. + /// + /// When enabled, the yielded [`DirEntry`] values represent the target of + /// the link while the path corresponds to the link. See the [`DirEntry`] + /// type for more details. + /// + /// [`DirEntry`]: struct.DirEntry.html + pub fn follow_links(mut self, yes: bool) -> Self { + self.opts.follow_links = yes; + self + } + + /// Set the maximum number of simultaneously open file descriptors used + /// by the iterator. + /// + /// `n` must be greater than or equal to `1`. If `n` is `0`, then it is set + /// to `1` automatically. If this is not set, then it defaults to some + /// reasonably low number. + /// + /// This setting has no impact on the results yielded by the iterator + /// (even when `n` is `1`). Instead, this setting represents a trade off + /// between scarce resources (file descriptors) and memory. Namely, when + /// the maximum number of file descriptors is reached and a new directory + /// needs to be opened to continue iteration, then a previous directory + /// handle is closed and has its unyielded entries stored in memory. In + /// practice, this is a satisfying trade off because it scales with respect + /// to the *depth* of your file tree. Therefore, low values (even `1`) are + /// acceptable. + /// + /// Note that this value does not impact the number of system calls made by + /// an exhausted iterator. + /// + /// # Platform behavior + /// + /// On Windows, if `follow_links` is enabled, then this limit is not + /// respected. In particular, the maximum number of file descriptors opened + /// is proportional to the depth of the directory tree traversed. + pub fn max_open(mut self, mut n: usize) -> Self { + if n == 0 { + n = 1; + } + self.opts.max_open = n; + self + } + + /// Set a function for sorting directory entries. + /// + /// If a compare function is set, the resulting iterator will return all + /// paths in sorted order. The compare function will be called to compare + /// entries from the same directory. + /// + /// ```rust,no-run + /// use std::cmp; + /// use std::ffi::OsString; + /// use walkdir::WalkDir; + /// + /// WalkDir::new("foo").sort_by(|a,b| a.file_name().cmp(b.file_name())); + /// ``` + pub fn sort_by<F>(mut self, cmp: F) -> Self + where + F: FnMut(&DirEntry, &DirEntry) -> Ordering + Send + Sync + 'static, + { + self.opts.sorter = Some(Box::new(cmp)); + self + } + + /// Yield a directory's contents before the directory itself. By default, + /// this is disabled. + /// + /// When `yes` is `false` (as is the default), the directory is yielded + /// before its contents are read. This is useful when, e.g. you want to + /// skip processing of some directories. + /// + /// When `yes` is `true`, the iterator yields the contents of a directory + /// before yielding the directory itself. This is useful when, e.g. you + /// want to recursively delete a directory. + /// + /// # Example + /// + /// Assume the following directory tree: + /// + /// ```text + /// foo/ + /// abc/ + /// qrs + /// tuv + /// def/ + /// ``` + /// + /// With contents_first disabled (the default), the following code visits + /// the directory tree in depth-first order: + /// + /// ```no_run + /// use walkdir::WalkDir; + /// + /// for entry in WalkDir::new("foo") { + /// let entry = entry.unwrap(); + /// println!("{}", entry.path().display()); + /// } + /// + /// // foo + /// // foo/abc + /// // foo/abc/qrs + /// // foo/abc/tuv + /// // foo/def + /// ``` + /// + /// With contents_first enabled: + /// + /// ```no_run + /// use walkdir::WalkDir; + /// + /// for entry in WalkDir::new("foo").contents_first(true) { + /// let entry = entry.unwrap(); + /// println!("{}", entry.path().display()); + /// } + /// + /// // foo/abc/qrs + /// // foo/abc/tuv + /// // foo/abc + /// // foo/def + /// // foo + /// ``` + pub fn contents_first(mut self, yes: bool) -> Self { + self.opts.contents_first = yes; + self + } + + /// Do not cross file system boundaries. + /// + /// When this option is enabled, directory traversal will not descend into + /// directories that are on a different file system from the root path. + /// + /// Currently, this option is only supported on Unix and Windows. If this + /// option is used on an unsupported platform, then directory traversal + /// will immediately return an error and will not yield any entries. + pub fn same_file_system(mut self, yes: bool) -> Self { + self.opts.same_file_system = yes; + self + } +} + +impl IntoIterator for WalkDir { + type Item = Result<DirEntry>; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + IntoIter { + opts: self.opts, + start: Some(self.root), + stack_list: vec![], + stack_path: vec![], + oldest_opened: 0, + depth: 0, + deferred_dirs: vec![], + root_device: None, + } + } +} + +/// An iterator for recursively descending into a directory. +/// +/// A value with this type must be constructed with the [`WalkDir`] type, which +/// uses a builder pattern to set options such as min/max depth, max open file +/// descriptors and whether the iterator should follow symbolic links. After +/// constructing a `WalkDir`, call [`.into_iter()`] at the end of the chain. +/// +/// The order of elements yielded by this iterator is unspecified. +/// +/// [`WalkDir`]: struct.WalkDir.html +/// [`.into_iter()`]: struct.WalkDir.html#into_iter.v +#[derive(Debug)] +pub struct IntoIter { + /// Options specified in the builder. Depths, max fds, etc. + opts: WalkDirOptions, + /// The start path. + /// + /// This is only `Some(...)` at the beginning. After the first iteration, + /// this is always `None`. + start: Option<PathBuf>, + /// A stack of open (up to max fd) or closed handles to directories. + /// An open handle is a plain [`fs::ReadDir`] while a closed handle is + /// a `Vec<fs::DirEntry>` corresponding to the as-of-yet consumed entries. + /// + /// [`fs::ReadDir`]: https://doc.rust-lang.org/stable/std/fs/struct.ReadDir.html + stack_list: Vec<DirList>, + /// A stack of file paths. + /// + /// This is *only* used when [`follow_links`] is enabled. In all other + /// cases this stack is empty. + /// + /// [`follow_links`]: struct.WalkDir.html#method.follow_links + stack_path: Vec<Ancestor>, + /// An index into `stack_list` that points to the oldest open directory + /// handle. If the maximum fd limit is reached and a new directory needs to + /// be read, the handle at this index is closed before the new directory is + /// opened. + oldest_opened: usize, + /// The current depth of iteration (the length of the stack at the + /// beginning of each iteration). + depth: usize, + /// A list of DirEntries corresponding to directories, that are + /// yielded after their contents has been fully yielded. This is only + /// used when `contents_first` is enabled. + deferred_dirs: Vec<DirEntry>, + /// The device of the root file path when the first call to `next` was + /// made. + /// + /// If the `same_file_system` option isn't enabled, then this is always + /// `None`. Conversely, if it is enabled, this is always `Some(...)` after + /// handling the root path. + root_device: Option<u64>, +} + +/// An ancestor is an item in the directory tree traversed by walkdir, and is +/// used to check for loops in the tree when traversing symlinks. +#[derive(Debug)] +struct Ancestor { + /// The path of this ancestor. + path: PathBuf, + /// An open file to this ancesor. This is only used on Windows where + /// opening a file handle appears to be quite expensive, so we choose to + /// cache it. This comes at the cost of not respecting the file descriptor + /// limit set by the user. + #[cfg(windows)] + handle: Handle, +} + +impl Ancestor { + /// Create a new ancestor from the given directory path. + #[cfg(windows)] + fn new(dent: &DirEntry) -> io::Result<Ancestor> { + let handle = Handle::from_path(dent.path())?; + Ok(Ancestor { path: dent.path().to_path_buf(), handle: handle }) + } + + /// Create a new ancestor from the given directory path. + #[cfg(not(windows))] + fn new(dent: &DirEntry) -> io::Result<Ancestor> { + Ok(Ancestor { path: dent.path().to_path_buf() }) + } + + /// Returns true if and only if the given open file handle corresponds to + /// the same directory as this ancestor. + #[cfg(windows)] + fn is_same(&self, child: &Handle) -> io::Result<bool> { + Ok(child == &self.handle) + } + + /// Returns true if and only if the given open file handle corresponds to + /// the same directory as this ancestor. + #[cfg(not(windows))] + fn is_same(&self, child: &Handle) -> io::Result<bool> { + Ok(child == &Handle::from_path(&self.path)?) + } +} + +/// A sequence of unconsumed directory entries. +/// +/// This represents the opened or closed state of a directory handle. When +/// open, future entries are read by iterating over the raw `fs::ReadDir`. +/// When closed, all future entries are read into memory. Iteration then +/// proceeds over a [`Vec<fs::DirEntry>`]. +/// +/// [`fs::ReadDir`]: https://doc.rust-lang.org/stable/std/fs/struct.ReadDir.html +/// [`Vec<fs::DirEntry>`]: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html +#[derive(Debug)] +enum DirList { + /// An opened handle. + /// + /// This includes the depth of the handle itself. + /// + /// If there was an error with the initial [`fs::read_dir`] call, then it + /// is stored here. (We use an [`Option<...>`] to make yielding the error + /// exactly once simpler.) + /// + /// [`fs::read_dir`]: https://doc.rust-lang.org/stable/std/fs/fn.read_dir.html + /// [`Option<...>`]: https://doc.rust-lang.org/stable/std/option/enum.Option.html + Opened { depth: usize, it: result::Result<ReadDir, Option<Error>> }, + /// A closed handle. + /// + /// All remaining directory entries are read into memory. + Closed(vec::IntoIter<Result<DirEntry>>), +} + +impl Iterator for IntoIter { + type Item = Result<DirEntry>; + /// Advances the iterator and returns the next value. + /// + /// # Errors + /// + /// If the iterator fails to retrieve the next value, this method returns + /// an error value. The error will be wrapped in an Option::Some. + fn next(&mut self) -> Option<Result<DirEntry>> { + if let Some(start) = self.start.take() { + if self.opts.same_file_system { + let result = util::device_num(&start) + .map_err(|e| Error::from_path(0, start.clone(), e)); + self.root_device = Some(itry!(result)); + } + let dent = itry!(DirEntry::from_path(0, start, false)); + if let Some(result) = self.handle_entry(dent) { + return Some(result); + } + } + while !self.stack_list.is_empty() { + self.depth = self.stack_list.len(); + if let Some(dentry) = self.get_deferred_dir() { + return Some(Ok(dentry)); + } + if self.depth > self.opts.max_depth { + // If we've exceeded the max depth, pop the current dir + // so that we don't descend. + self.pop(); + continue; + } + // Unwrap is safe here because we've verified above that + // `self.stack_list` is not empty + let next = self + .stack_list + .last_mut() + .expect("BUG: stack should be non-empty") + .next(); + match next { + None => self.pop(), + Some(Err(err)) => return Some(Err(err)), + Some(Ok(dent)) => { + if let Some(result) = self.handle_entry(dent) { + return Some(result); + } + } + } + } + if self.opts.contents_first { + self.depth = self.stack_list.len(); + if let Some(dentry) = self.get_deferred_dir() { + return Some(Ok(dentry)); + } + } + None + } +} + +impl IntoIter { + /// Skips the current directory. + /// + /// This causes the iterator to stop traversing the contents of the least + /// recently yielded directory. This means any remaining entries in that + /// directory will be skipped (including sub-directories). + /// + /// Note that the ergonomics of this method are questionable since it + /// borrows the iterator mutably. Namely, you must write out the looping + /// condition manually. For example, to skip hidden entries efficiently on + /// unix systems: + /// + /// ```no_run + /// use walkdir::{DirEntry, WalkDir}; + /// + /// fn is_hidden(entry: &DirEntry) -> bool { + /// entry.file_name() + /// .to_str() + /// .map(|s| s.starts_with(".")) + /// .unwrap_or(false) + /// } + /// + /// let mut it = WalkDir::new("foo").into_iter(); + /// loop { + /// let entry = match it.next() { + /// None => break, + /// Some(Err(err)) => panic!("ERROR: {}", err), + /// Some(Ok(entry)) => entry, + /// }; + /// if is_hidden(&entry) { + /// if entry.file_type().is_dir() { + /// it.skip_current_dir(); + /// } + /// continue; + /// } + /// println!("{}", entry.path().display()); + /// } + /// ``` + /// + /// You may find it more convenient to use the [`filter_entry`] iterator + /// adapter. (See its documentation for the same example functionality as + /// above.) + /// + /// [`filter_entry`]: #method.filter_entry + pub fn skip_current_dir(&mut self) { + if !self.stack_list.is_empty() { + self.pop(); + } + } + + /// Yields only entries which satisfy the given predicate and skips + /// descending into directories that do not satisfy the given predicate. + /// + /// The predicate is applied to all entries. If the predicate is + /// true, iteration carries on as normal. If the predicate is false, the + /// entry is ignored and if it is a directory, it is not descended into. + /// + /// This is often more convenient to use than [`skip_current_dir`]. For + /// example, to skip hidden files and directories efficiently on unix + /// systems: + /// + /// ```no_run + /// use walkdir::{DirEntry, WalkDir}; + /// # use walkdir::Error; + /// + /// fn is_hidden(entry: &DirEntry) -> bool { + /// entry.file_name() + /// .to_str() + /// .map(|s| s.starts_with(".")) + /// .unwrap_or(false) + /// } + /// + /// # fn try_main() -> Result<(), Error> { + /// for entry in WalkDir::new("foo") + /// .into_iter() + /// .filter_entry(|e| !is_hidden(e)) { + /// println!("{}", entry?.path().display()); + /// } + /// # Ok(()) + /// # } + /// ``` + /// + /// Note that the iterator will still yield errors for reading entries that + /// may not satisfy the predicate. + /// + /// Note that entries skipped with [`min_depth`] and [`max_depth`] are not + /// passed to this predicate. + /// + /// Note that if the iterator has `contents_first` enabled, then this + /// method is no different than calling the standard `Iterator::filter` + /// method (because directory entries are yielded after they've been + /// descended into). + /// + /// [`skip_current_dir`]: #method.skip_current_dir + /// [`min_depth`]: struct.WalkDir.html#method.min_depth + /// [`max_depth`]: struct.WalkDir.html#method.max_depth + pub fn filter_entry<P>(self, predicate: P) -> FilterEntry<Self, P> + where + P: FnMut(&DirEntry) -> bool, + { + FilterEntry { it: self, predicate: predicate } + } + + fn handle_entry( + &mut self, + mut dent: DirEntry, + ) -> Option<Result<DirEntry>> { + if self.opts.follow_links && dent.file_type().is_symlink() { + dent = itry!(self.follow(dent)); + } + let is_normal_dir = !dent.file_type().is_symlink() && dent.is_dir(); + if is_normal_dir { + if self.opts.same_file_system && dent.depth() > 0 { + if itry!(self.is_same_file_system(&dent)) { + itry!(self.push(&dent)); + } + } else { + itry!(self.push(&dent)); + } + } else if dent.depth() == 0 && dent.file_type().is_symlink() { + // As a special case, if we are processing a root entry, then we + // always follow it even if it's a symlink and follow_links is + // false. We are careful to not let this change the semantics of + // the DirEntry however. Namely, the DirEntry should still respect + // the follow_links setting. When it's disabled, it should report + // itself as a symlink. When it's enabled, it should always report + // itself as the target. + let md = itry!(fs::metadata(dent.path()).map_err(|err| { + Error::from_path(dent.depth(), dent.path().to_path_buf(), err) + })); + if md.file_type().is_dir() { + itry!(self.push(&dent)); + } + } + if is_normal_dir && self.opts.contents_first { + self.deferred_dirs.push(dent); + None + } else if self.skippable() { + None + } else { + Some(Ok(dent)) + } + } + + fn get_deferred_dir(&mut self) -> Option<DirEntry> { + if self.opts.contents_first { + if self.depth < self.deferred_dirs.len() { + // Unwrap is safe here because we've guaranteed that + // `self.deferred_dirs.len()` can never be less than 1 + let deferred: DirEntry = self + .deferred_dirs + .pop() + .expect("BUG: deferred_dirs should be non-empty"); + if !self.skippable() { + return Some(deferred); + } + } + } + None + } + + fn push(&mut self, dent: &DirEntry) -> Result<()> { + // Make room for another open file descriptor if we've hit the max. + let free = + self.stack_list.len().checked_sub(self.oldest_opened).unwrap(); + if free == self.opts.max_open { + self.stack_list[self.oldest_opened].close(); + } + // Open a handle to reading the directory's entries. + let rd = fs::read_dir(dent.path()).map_err(|err| { + Some(Error::from_path(self.depth, dent.path().to_path_buf(), err)) + }); + let mut list = DirList::Opened { depth: self.depth, it: rd }; + if let Some(ref mut cmp) = self.opts.sorter { + let mut entries: Vec<_> = list.collect(); + entries.sort_by(|a, b| match (a, b) { + (&Ok(ref a), &Ok(ref b)) => cmp(a, b), + (&Err(_), &Err(_)) => Ordering::Equal, + (&Ok(_), &Err(_)) => Ordering::Greater, + (&Err(_), &Ok(_)) => Ordering::Less, + }); + list = DirList::Closed(entries.into_iter()); + } + if self.opts.follow_links { + let ancestor = Ancestor::new(&dent) + .map_err(|err| Error::from_io(self.depth, err))?; + self.stack_path.push(ancestor); + } + // We push this after stack_path since creating the Ancestor can fail. + // If it fails, then we return the error and won't descend. + self.stack_list.push(list); + // If we had to close out a previous directory stream, then we need to + // increment our index the oldest still-open stream. We do this only + // after adding to our stack, in order to ensure that the oldest_opened + // index remains valid. The worst that can happen is that an already + // closed stream will be closed again, which is a no-op. + // + // We could move the close of the stream above into this if-body, but + // then we would have more than the maximum number of file descriptors + // open at a particular point in time. + if free == self.opts.max_open { + // Unwrap is safe here because self.oldest_opened is guaranteed to + // never be greater than `self.stack_list.len()`, which implies + // that the subtraction won't underflow and that adding 1 will + // never overflow. + self.oldest_opened = self.oldest_opened.checked_add(1).unwrap(); + } + Ok(()) + } + + fn pop(&mut self) { + self.stack_list.pop().expect("BUG: cannot pop from empty stack"); + if self.opts.follow_links { + self.stack_path.pop().expect("BUG: list/path stacks out of sync"); + } + // If everything in the stack is already closed, then there is + // room for at least one more open descriptor and it will + // always be at the top of the stack. + self.oldest_opened = min(self.oldest_opened, self.stack_list.len()); + } + + fn follow(&self, mut dent: DirEntry) -> Result<DirEntry> { + dent = + DirEntry::from_path(self.depth, dent.path().to_path_buf(), true)?; + // The only way a symlink can cause a loop is if it points + // to a directory. Otherwise, it always points to a leaf + // and we can omit any loop checks. + if dent.is_dir() { + self.check_loop(dent.path())?; + } + Ok(dent) + } + + fn check_loop<P: AsRef<Path>>(&self, child: P) -> Result<()> { + let hchild = Handle::from_path(&child) + .map_err(|err| Error::from_io(self.depth, err))?; + for ancestor in self.stack_path.iter().rev() { + let is_same = ancestor + .is_same(&hchild) + .map_err(|err| Error::from_io(self.depth, err))?; + if is_same { + return Err(Error::from_loop( + self.depth, + &ancestor.path, + child.as_ref(), + )); + } + } + Ok(()) + } + + fn is_same_file_system(&mut self, dent: &DirEntry) -> Result<bool> { + let dent_device = util::device_num(dent.path()) + .map_err(|err| Error::from_entry(dent, err))?; + Ok(self + .root_device + .map(|d| d == dent_device) + .expect("BUG: called is_same_file_system without root device")) + } + + fn skippable(&self) -> bool { + self.depth < self.opts.min_depth || self.depth > self.opts.max_depth + } +} + +impl DirList { + fn close(&mut self) { + if let DirList::Opened { .. } = *self { + *self = DirList::Closed(self.collect::<Vec<_>>().into_iter()); + } + } +} + +impl Iterator for DirList { + type Item = Result<DirEntry>; + + #[inline(always)] + fn next(&mut self) -> Option<Result<DirEntry>> { + match *self { + DirList::Closed(ref mut it) => it.next(), + DirList::Opened { depth, ref mut it } => match *it { + Err(ref mut err) => err.take().map(Err), + Ok(ref mut rd) => rd.next().map(|r| match r { + Ok(r) => DirEntry::from_entry(depth + 1, &r), + Err(err) => Err(Error::from_io(depth + 1, err)), + }), + }, + } + } +} + +/// A recursive directory iterator that skips entries. +/// +/// Values of this type are created by calling [`.filter_entry()`] on an +/// `IntoIter`, which is formed by calling [`.into_iter()`] on a `WalkDir`. +/// +/// Directories that fail the predicate `P` are skipped. Namely, they are +/// never yielded and never descended into. +/// +/// Entries that are skipped with the [`min_depth`] and [`max_depth`] options +/// are not passed through this filter. +/// +/// If opening a handle to a directory resulted in an error, then it is yielded +/// and no corresponding call to the predicate is made. +/// +/// Type parameter `I` refers to the underlying iterator and `P` refers to the +/// predicate, which is usually `FnMut(&DirEntry) -> bool`. +/// +/// [`.filter_entry()`]: struct.IntoIter.html#method.filter_entry +/// [`.into_iter()`]: struct.WalkDir.html#into_iter.v +/// [`min_depth`]: struct.WalkDir.html#method.min_depth +/// [`max_depth`]: struct.WalkDir.html#method.max_depth +#[derive(Debug)] +pub struct FilterEntry<I, P> { + it: I, + predicate: P, +} + +impl<P> Iterator for FilterEntry<IntoIter, P> +where + P: FnMut(&DirEntry) -> bool, +{ + type Item = Result<DirEntry>; + + /// Advances the iterator and returns the next value. + /// + /// # Errors + /// + /// If the iterator fails to retrieve the next value, this method returns + /// an error value. The error will be wrapped in an `Option::Some`. + fn next(&mut self) -> Option<Result<DirEntry>> { + loop { + let dent = match self.it.next() { + None => return None, + Some(result) => itry!(result), + }; + if !(self.predicate)(&dent) { + if dent.is_dir() { + self.it.skip_current_dir(); + } + continue; + } + return Some(Ok(dent)); + } + } +} + +impl<P> FilterEntry<IntoIter, P> +where + P: FnMut(&DirEntry) -> bool, +{ + /// Yields only entries which satisfy the given predicate and skips + /// descending into directories that do not satisfy the given predicate. + /// + /// The predicate is applied to all entries. If the predicate is + /// true, iteration carries on as normal. If the predicate is false, the + /// entry is ignored and if it is a directory, it is not descended into. + /// + /// This is often more convenient to use than [`skip_current_dir`]. For + /// example, to skip hidden files and directories efficiently on unix + /// systems: + /// + /// ```no_run + /// use walkdir::{DirEntry, WalkDir}; + /// # use walkdir::Error; + /// + /// fn is_hidden(entry: &DirEntry) -> bool { + /// entry.file_name() + /// .to_str() + /// .map(|s| s.starts_with(".")) + /// .unwrap_or(false) + /// } + /// + /// # fn try_main() -> Result<(), Error> { + /// for entry in WalkDir::new("foo") + /// .into_iter() + /// .filter_entry(|e| !is_hidden(e)) { + /// println!("{}", entry?.path().display()); + /// } + /// # Ok(()) + /// # } + /// ``` + /// + /// Note that the iterator will still yield errors for reading entries that + /// may not satisfy the predicate. + /// + /// Note that entries skipped with [`min_depth`] and [`max_depth`] are not + /// passed to this predicate. + /// + /// Note that if the iterator has `contents_first` enabled, then this + /// method is no different than calling the standard `Iterator::filter` + /// method (because directory entries are yielded after they've been + /// descended into). + /// + /// [`skip_current_dir`]: #method.skip_current_dir + /// [`min_depth`]: struct.WalkDir.html#method.min_depth + /// [`max_depth`]: struct.WalkDir.html#method.max_depth + pub fn filter_entry(self, predicate: P) -> FilterEntry<Self, P> { + FilterEntry { it: self, predicate: predicate } + } + + /// Skips the current directory. + /// + /// This causes the iterator to stop traversing the contents of the least + /// recently yielded directory. This means any remaining entries in that + /// directory will be skipped (including sub-directories). + /// + /// Note that the ergonomics of this method are questionable since it + /// borrows the iterator mutably. Namely, you must write out the looping + /// condition manually. For example, to skip hidden entries efficiently on + /// unix systems: + /// + /// ```no_run + /// use walkdir::{DirEntry, WalkDir}; + /// + /// fn is_hidden(entry: &DirEntry) -> bool { + /// entry.file_name() + /// .to_str() + /// .map(|s| s.starts_with(".")) + /// .unwrap_or(false) + /// } + /// + /// let mut it = WalkDir::new("foo").into_iter(); + /// loop { + /// let entry = match it.next() { + /// None => break, + /// Some(Err(err)) => panic!("ERROR: {}", err), + /// Some(Ok(entry)) => entry, + /// }; + /// if is_hidden(&entry) { + /// if entry.file_type().is_dir() { + /// it.skip_current_dir(); + /// } + /// continue; + /// } + /// println!("{}", entry.path().display()); + /// } + /// ``` + /// + /// You may find it more convenient to use the [`filter_entry`] iterator + /// adapter. (See its documentation for the same example functionality as + /// above.) + /// + /// [`filter_entry`]: #method.filter_entry + pub fn skip_current_dir(&mut self) { + self.it.skip_current_dir(); + } +} diff --git a/third_party/cargo/vendor/walkdir-2.3.1/src/tests/mod.rs b/third_party/cargo/vendor/walkdir-2.3.1/src/tests/mod.rs new file mode 100644 index 0000000..ebf952d --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/src/tests/mod.rs @@ -0,0 +1,4 @@ +#[macro_use] +mod util; + +mod recursive; diff --git a/third_party/cargo/vendor/walkdir-2.3.1/src/tests/recursive.rs b/third_party/cargo/vendor/walkdir-2.3.1/src/tests/recursive.rs new file mode 100644 index 0000000..bbb1ce1 --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/src/tests/recursive.rs @@ -0,0 +1,980 @@ +use std::fs; +use std::path::PathBuf; + +use crate::tests::util::Dir; +use crate::WalkDir; + +#[test] +fn send_sync_traits() { + use crate::{FilterEntry, IntoIter}; + + fn assert_send<T: Send>() {} + fn assert_sync<T: Sync>() {} + + assert_send::<WalkDir>(); + assert_sync::<WalkDir>(); + assert_send::<IntoIter>(); + assert_sync::<IntoIter>(); + assert_send::<FilterEntry<IntoIter, u8>>(); + assert_sync::<FilterEntry<IntoIter, u8>>(); +} + +#[test] +fn empty() { + let dir = Dir::tmp(); + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + assert_eq!(1, r.ents().len()); + let ent = &r.ents()[0]; + assert!(ent.file_type().is_dir()); + assert!(!ent.path_is_symlink()); + assert_eq!(0, ent.depth()); + assert_eq!(dir.path(), ent.path()); + assert_eq!(dir.path().file_name().unwrap(), ent.file_name()); +} + +#[test] +fn empty_follow() { + let dir = Dir::tmp(); + let wd = WalkDir::new(dir.path()).follow_links(true); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + assert_eq!(1, r.ents().len()); + let ent = &r.ents()[0]; + assert!(ent.file_type().is_dir()); + assert!(!ent.path_is_symlink()); + assert_eq!(0, ent.depth()); + assert_eq!(dir.path(), ent.path()); + assert_eq!(dir.path().file_name().unwrap(), ent.file_name()); +} + +#[test] +fn empty_file() { + let dir = Dir::tmp(); + dir.touch("a"); + + let wd = WalkDir::new(dir.path().join("a")); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + assert_eq!(1, r.ents().len()); + let ent = &r.ents()[0]; + assert!(ent.file_type().is_file()); + assert!(!ent.path_is_symlink()); + assert_eq!(0, ent.depth()); + assert_eq!(dir.join("a"), ent.path()); + assert_eq!("a", ent.file_name()); +} + +#[test] +fn empty_file_follow() { + let dir = Dir::tmp(); + dir.touch("a"); + + let wd = WalkDir::new(dir.path().join("a")).follow_links(true); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + assert_eq!(1, r.ents().len()); + let ent = &r.ents()[0]; + assert!(ent.file_type().is_file()); + assert!(!ent.path_is_symlink()); + assert_eq!(0, ent.depth()); + assert_eq!(dir.join("a"), ent.path()); + assert_eq!("a", ent.file_name()); +} + +#[test] +fn one_dir() { + let dir = Dir::tmp(); + dir.mkdirp("a"); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let ents = r.ents(); + assert_eq!(2, ents.len()); + let ent = &ents[1]; + assert_eq!(dir.join("a"), ent.path()); + assert_eq!(1, ent.depth()); + assert_eq!("a", ent.file_name()); + assert!(ent.file_type().is_dir()); +} + +#[test] +fn one_file() { + let dir = Dir::tmp(); + dir.touch("a"); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let ents = r.ents(); + assert_eq!(2, ents.len()); + let ent = &ents[1]; + assert_eq!(dir.join("a"), ent.path()); + assert_eq!(1, ent.depth()); + assert_eq!("a", ent.file_name()); + assert!(ent.file_type().is_file()); +} + +#[test] +fn one_dir_one_file() { + let dir = Dir::tmp(); + dir.mkdirp("foo"); + dir.touch("foo/a"); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("foo"), + dir.join("foo").join("a"), + ]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn many_files() { + let dir = Dir::tmp(); + dir.mkdirp("foo"); + dir.touch_all(&["foo/a", "foo/b", "foo/c"]); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("foo"), + dir.join("foo").join("a"), + dir.join("foo").join("b"), + dir.join("foo").join("c"), + ]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn many_dirs() { + let dir = Dir::tmp(); + dir.mkdirp("foo/a"); + dir.mkdirp("foo/b"); + dir.mkdirp("foo/c"); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("foo"), + dir.join("foo").join("a"), + dir.join("foo").join("b"), + dir.join("foo").join("c"), + ]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn many_mixed() { + let dir = Dir::tmp(); + dir.mkdirp("foo/a"); + dir.mkdirp("foo/c"); + dir.mkdirp("foo/e"); + dir.touch_all(&["foo/b", "foo/d", "foo/f"]); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("foo"), + dir.join("foo").join("a"), + dir.join("foo").join("b"), + dir.join("foo").join("c"), + dir.join("foo").join("d"), + dir.join("foo").join("e"), + dir.join("foo").join("f"), + ]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn nested() { + let nested = + PathBuf::from("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z"); + let dir = Dir::tmp(); + dir.mkdirp(&nested); + dir.touch(nested.join("A")); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("a"), + dir.join("a/b"), + dir.join("a/b/c"), + dir.join("a/b/c/d"), + dir.join("a/b/c/d/e"), + dir.join("a/b/c/d/e/f"), + dir.join("a/b/c/d/e/f/g"), + dir.join("a/b/c/d/e/f/g/h"), + dir.join("a/b/c/d/e/f/g/h/i"), + dir.join("a/b/c/d/e/f/g/h/i/j"), + dir.join("a/b/c/d/e/f/g/h/i/j/k"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z"), + dir.join(&nested).join("A"), + ]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn nested_small_max_open() { + let nested = + PathBuf::from("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z"); + let dir = Dir::tmp(); + dir.mkdirp(&nested); + dir.touch(nested.join("A")); + + let wd = WalkDir::new(dir.path()).max_open(1); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("a"), + dir.join("a/b"), + dir.join("a/b/c"), + dir.join("a/b/c/d"), + dir.join("a/b/c/d/e"), + dir.join("a/b/c/d/e/f"), + dir.join("a/b/c/d/e/f/g"), + dir.join("a/b/c/d/e/f/g/h"), + dir.join("a/b/c/d/e/f/g/h/i"), + dir.join("a/b/c/d/e/f/g/h/i/j"), + dir.join("a/b/c/d/e/f/g/h/i/j/k"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y"), + dir.join("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z"), + dir.join(&nested).join("A"), + ]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn siblings() { + let dir = Dir::tmp(); + dir.mkdirp("foo"); + dir.mkdirp("bar"); + dir.touch_all(&["foo/a", "foo/b"]); + dir.touch_all(&["bar/a", "bar/b"]); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("bar"), + dir.join("bar").join("a"), + dir.join("bar").join("b"), + dir.join("foo"), + dir.join("foo").join("a"), + dir.join("foo").join("b"), + ]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn sym_root_file_nofollow() { + let dir = Dir::tmp(); + dir.touch("a"); + dir.symlink_file("a", "a-link"); + + let wd = WalkDir::new(dir.join("a-link")); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let ents = r.sorted_ents(); + assert_eq!(1, ents.len()); + let link = &ents[0]; + + assert_eq!(dir.join("a-link"), link.path()); + + assert!(link.path_is_symlink()); + + assert_eq!(dir.join("a"), fs::read_link(link.path()).unwrap()); + + assert_eq!(0, link.depth()); + + assert!(link.file_type().is_symlink()); + assert!(!link.file_type().is_file()); + assert!(!link.file_type().is_dir()); + + assert!(link.metadata().unwrap().file_type().is_symlink()); + assert!(!link.metadata().unwrap().is_file()); + assert!(!link.metadata().unwrap().is_dir()); +} + +#[test] +fn sym_root_file_follow() { + let dir = Dir::tmp(); + dir.touch("a"); + dir.symlink_file("a", "a-link"); + + let wd = WalkDir::new(dir.join("a-link")).follow_links(true); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let ents = r.sorted_ents(); + let link = &ents[0]; + + assert_eq!(dir.join("a-link"), link.path()); + + assert!(link.path_is_symlink()); + + assert_eq!(dir.join("a"), fs::read_link(link.path()).unwrap()); + + assert_eq!(0, link.depth()); + + assert!(!link.file_type().is_symlink()); + assert!(link.file_type().is_file()); + assert!(!link.file_type().is_dir()); + + assert!(!link.metadata().unwrap().file_type().is_symlink()); + assert!(link.metadata().unwrap().is_file()); + assert!(!link.metadata().unwrap().is_dir()); +} + +#[test] +fn sym_root_dir_nofollow() { + let dir = Dir::tmp(); + dir.mkdirp("a"); + dir.symlink_dir("a", "a-link"); + dir.touch("a/zzz"); + + let wd = WalkDir::new(dir.join("a-link")); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let ents = r.sorted_ents(); + assert_eq!(2, ents.len()); + let link = &ents[0]; + + assert_eq!(dir.join("a-link"), link.path()); + + assert!(link.path_is_symlink()); + + assert_eq!(dir.join("a"), fs::read_link(link.path()).unwrap()); + + assert_eq!(0, link.depth()); + + assert!(link.file_type().is_symlink()); + assert!(!link.file_type().is_file()); + assert!(!link.file_type().is_dir()); + + assert!(link.metadata().unwrap().file_type().is_symlink()); + assert!(!link.metadata().unwrap().is_file()); + assert!(!link.metadata().unwrap().is_dir()); + + let link_zzz = &ents[1]; + assert_eq!(dir.join("a-link").join("zzz"), link_zzz.path()); + assert!(!link_zzz.path_is_symlink()); +} + +#[test] +fn sym_root_dir_follow() { + let dir = Dir::tmp(); + dir.mkdirp("a"); + dir.symlink_dir("a", "a-link"); + dir.touch("a/zzz"); + + let wd = WalkDir::new(dir.join("a-link")).follow_links(true); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let ents = r.sorted_ents(); + assert_eq!(2, ents.len()); + let link = &ents[0]; + + assert_eq!(dir.join("a-link"), link.path()); + + assert!(link.path_is_symlink()); + + assert_eq!(dir.join("a"), fs::read_link(link.path()).unwrap()); + + assert_eq!(0, link.depth()); + + assert!(!link.file_type().is_symlink()); + assert!(!link.file_type().is_file()); + assert!(link.file_type().is_dir()); + + assert!(!link.metadata().unwrap().file_type().is_symlink()); + assert!(!link.metadata().unwrap().is_file()); + assert!(link.metadata().unwrap().is_dir()); + + let link_zzz = &ents[1]; + assert_eq!(dir.join("a-link").join("zzz"), link_zzz.path()); + assert!(!link_zzz.path_is_symlink()); +} + +#[test] +fn sym_file_nofollow() { + let dir = Dir::tmp(); + dir.touch("a"); + dir.symlink_file("a", "a-link"); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let ents = r.sorted_ents(); + assert_eq!(3, ents.len()); + let (src, link) = (&ents[1], &ents[2]); + + assert_eq!(dir.join("a"), src.path()); + assert_eq!(dir.join("a-link"), link.path()); + + assert!(!src.path_is_symlink()); + assert!(link.path_is_symlink()); + + assert_eq!(dir.join("a"), fs::read_link(link.path()).unwrap()); + + assert_eq!(1, src.depth()); + assert_eq!(1, link.depth()); + + assert!(src.file_type().is_file()); + assert!(link.file_type().is_symlink()); + assert!(!link.file_type().is_file()); + assert!(!link.file_type().is_dir()); + + assert!(src.metadata().unwrap().is_file()); + assert!(link.metadata().unwrap().file_type().is_symlink()); + assert!(!link.metadata().unwrap().is_file()); + assert!(!link.metadata().unwrap().is_dir()); +} + +#[test] +fn sym_file_follow() { + let dir = Dir::tmp(); + dir.touch("a"); + dir.symlink_file("a", "a-link"); + + let wd = WalkDir::new(dir.path()).follow_links(true); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let ents = r.sorted_ents(); + assert_eq!(3, ents.len()); + let (src, link) = (&ents[1], &ents[2]); + + assert_eq!(dir.join("a"), src.path()); + assert_eq!(dir.join("a-link"), link.path()); + + assert!(!src.path_is_symlink()); + assert!(link.path_is_symlink()); + + assert_eq!(dir.join("a"), fs::read_link(link.path()).unwrap()); + + assert_eq!(1, src.depth()); + assert_eq!(1, link.depth()); + + assert!(src.file_type().is_file()); + assert!(!link.file_type().is_symlink()); + assert!(link.file_type().is_file()); + assert!(!link.file_type().is_dir()); + + assert!(src.metadata().unwrap().is_file()); + assert!(!link.metadata().unwrap().file_type().is_symlink()); + assert!(link.metadata().unwrap().is_file()); + assert!(!link.metadata().unwrap().is_dir()); +} + +#[test] +fn sym_dir_nofollow() { + let dir = Dir::tmp(); + dir.mkdirp("a"); + dir.symlink_dir("a", "a-link"); + dir.touch("a/zzz"); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let ents = r.sorted_ents(); + assert_eq!(4, ents.len()); + let (src, link) = (&ents[1], &ents[3]); + + assert_eq!(dir.join("a"), src.path()); + assert_eq!(dir.join("a-link"), link.path()); + + assert!(!src.path_is_symlink()); + assert!(link.path_is_symlink()); + + assert_eq!(dir.join("a"), fs::read_link(link.path()).unwrap()); + + assert_eq!(1, src.depth()); + assert_eq!(1, link.depth()); + + assert!(src.file_type().is_dir()); + assert!(link.file_type().is_symlink()); + assert!(!link.file_type().is_file()); + assert!(!link.file_type().is_dir()); + + assert!(src.metadata().unwrap().is_dir()); + assert!(link.metadata().unwrap().file_type().is_symlink()); + assert!(!link.metadata().unwrap().is_file()); + assert!(!link.metadata().unwrap().is_dir()); +} + +#[test] +fn sym_dir_follow() { + let dir = Dir::tmp(); + dir.mkdirp("a"); + dir.symlink_dir("a", "a-link"); + dir.touch("a/zzz"); + + let wd = WalkDir::new(dir.path()).follow_links(true); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let ents = r.sorted_ents(); + assert_eq!(5, ents.len()); + let (src, link) = (&ents[1], &ents[3]); + + assert_eq!(dir.join("a"), src.path()); + assert_eq!(dir.join("a-link"), link.path()); + + assert!(!src.path_is_symlink()); + assert!(link.path_is_symlink()); + + assert_eq!(dir.join("a"), fs::read_link(link.path()).unwrap()); + + assert_eq!(1, src.depth()); + assert_eq!(1, link.depth()); + + assert!(src.file_type().is_dir()); + assert!(!link.file_type().is_symlink()); + assert!(!link.file_type().is_file()); + assert!(link.file_type().is_dir()); + + assert!(src.metadata().unwrap().is_dir()); + assert!(!link.metadata().unwrap().file_type().is_symlink()); + assert!(!link.metadata().unwrap().is_file()); + assert!(link.metadata().unwrap().is_dir()); + + let (src_zzz, link_zzz) = (&ents[2], &ents[4]); + assert_eq!(dir.join("a").join("zzz"), src_zzz.path()); + assert_eq!(dir.join("a-link").join("zzz"), link_zzz.path()); + assert!(!src_zzz.path_is_symlink()); + assert!(!link_zzz.path_is_symlink()); +} + +#[test] +fn sym_noloop() { + let dir = Dir::tmp(); + dir.mkdirp("a/b/c"); + dir.symlink_dir("a", "a/b/c/a-link"); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + // There's no loop if we aren't following symlinks. + r.assert_no_errors(); + + assert_eq!(5, r.ents().len()); +} + +#[test] +fn sym_loop_detect() { + let dir = Dir::tmp(); + dir.mkdirp("a/b/c"); + dir.symlink_dir("a", "a/b/c/a-link"); + + let wd = WalkDir::new(dir.path()).follow_links(true); + let r = dir.run_recursive(wd); + + let (ents, errs) = (r.sorted_ents(), r.errs()); + assert_eq!(4, ents.len()); + assert_eq!(1, errs.len()); + + let err = &errs[0]; + + let expected = dir.join("a/b/c/a-link"); + assert_eq!(Some(&*expected), err.path()); + + let expected = dir.join("a"); + assert_eq!(Some(&*expected), err.loop_ancestor()); + + assert_eq!(4, err.depth()); + assert!(err.io_error().is_none()); +} + +#[test] +fn sym_self_loop_no_error() { + let dir = Dir::tmp(); + dir.symlink_file("a", "a"); + + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + // No errors occur because even though the symlink points to nowhere, it + // is never followed, and thus no error occurs. + r.assert_no_errors(); + assert_eq!(2, r.ents().len()); + + let ent = &r.ents()[1]; + assert_eq!(dir.join("a"), ent.path()); + assert!(ent.path_is_symlink()); + + assert!(ent.file_type().is_symlink()); + assert!(!ent.file_type().is_file()); + assert!(!ent.file_type().is_dir()); + + assert!(ent.metadata().unwrap().file_type().is_symlink()); + assert!(!ent.metadata().unwrap().file_type().is_file()); + assert!(!ent.metadata().unwrap().file_type().is_dir()); +} + +#[test] +fn sym_file_self_loop_io_error() { + let dir = Dir::tmp(); + dir.symlink_file("a", "a"); + + let wd = WalkDir::new(dir.path()).follow_links(true); + let r = dir.run_recursive(wd); + + let (ents, errs) = (r.sorted_ents(), r.errs()); + assert_eq!(1, ents.len()); + assert_eq!(1, errs.len()); + + let err = &errs[0]; + + let expected = dir.join("a"); + assert_eq!(Some(&*expected), err.path()); + assert_eq!(1, err.depth()); + assert!(err.loop_ancestor().is_none()); + assert!(err.io_error().is_some()); +} + +#[test] +fn sym_dir_self_loop_io_error() { + let dir = Dir::tmp(); + dir.symlink_dir("a", "a"); + + let wd = WalkDir::new(dir.path()).follow_links(true); + let r = dir.run_recursive(wd); + + let (ents, errs) = (r.sorted_ents(), r.errs()); + assert_eq!(1, ents.len()); + assert_eq!(1, errs.len()); + + let err = &errs[0]; + + let expected = dir.join("a"); + assert_eq!(Some(&*expected), err.path()); + assert_eq!(1, err.depth()); + assert!(err.loop_ancestor().is_none()); + assert!(err.io_error().is_some()); +} + +#[test] +fn min_depth_1() { + let dir = Dir::tmp(); + dir.mkdirp("a/b"); + + let wd = WalkDir::new(dir.path()).min_depth(1); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![dir.join("a"), dir.join("a").join("b")]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn min_depth_2() { + let dir = Dir::tmp(); + dir.mkdirp("a/b"); + + let wd = WalkDir::new(dir.path()).min_depth(2); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![dir.join("a").join("b")]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn max_depth_0() { + let dir = Dir::tmp(); + dir.mkdirp("a/b"); + + let wd = WalkDir::new(dir.path()).max_depth(0); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![dir.path().to_path_buf()]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn max_depth_1() { + let dir = Dir::tmp(); + dir.mkdirp("a/b"); + + let wd = WalkDir::new(dir.path()).max_depth(1); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![dir.path().to_path_buf(), dir.join("a")]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn max_depth_2() { + let dir = Dir::tmp(); + dir.mkdirp("a/b"); + + let wd = WalkDir::new(dir.path()).max_depth(2); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = + vec![dir.path().to_path_buf(), dir.join("a"), dir.join("a").join("b")]; + assert_eq!(expected, r.sorted_paths()); +} + +// FIXME: This test seems wrong. It should return nothing! +#[test] +fn min_max_depth_diff_nada() { + let dir = Dir::tmp(); + dir.mkdirp("a/b/c"); + + let wd = WalkDir::new(dir.path()).min_depth(3).max_depth(2); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![dir.join("a").join("b").join("c")]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn min_max_depth_diff_0() { + let dir = Dir::tmp(); + dir.mkdirp("a/b/c"); + + let wd = WalkDir::new(dir.path()).min_depth(2).max_depth(2); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![dir.join("a").join("b")]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn min_max_depth_diff_1() { + let dir = Dir::tmp(); + dir.mkdirp("a/b/c"); + + let wd = WalkDir::new(dir.path()).min_depth(1).max_depth(2); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![dir.join("a"), dir.join("a").join("b")]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn contents_first() { + let dir = Dir::tmp(); + dir.touch("a"); + + let wd = WalkDir::new(dir.path()).contents_first(true); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![dir.join("a"), dir.path().to_path_buf()]; + assert_eq!(expected, r.paths()); +} + +#[test] +fn skip_current_dir() { + let dir = Dir::tmp(); + dir.mkdirp("foo/bar/baz"); + dir.mkdirp("quux"); + + let mut paths = vec![]; + let mut it = WalkDir::new(dir.path()).into_iter(); + while let Some(result) = it.next() { + let ent = result.unwrap(); + paths.push(ent.path().to_path_buf()); + if ent.file_name() == "bar" { + it.skip_current_dir(); + } + } + paths.sort(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("foo"), + dir.join("foo").join("bar"), + dir.join("quux"), + ]; + assert_eq!(expected, paths); +} + +#[test] +fn filter_entry() { + let dir = Dir::tmp(); + dir.mkdirp("foo/bar/baz/abc"); + dir.mkdirp("quux"); + + let wd = WalkDir::new(dir.path()) + .into_iter() + .filter_entry(|ent| ent.file_name() != "baz"); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("foo"), + dir.join("foo").join("bar"), + dir.join("quux"), + ]; + assert_eq!(expected, r.sorted_paths()); +} + +#[test] +fn sort() { + let dir = Dir::tmp(); + dir.mkdirp("foo/bar/baz/abc"); + dir.mkdirp("quux"); + + let wd = WalkDir::new(dir.path()) + .sort_by(|a, b| a.file_name().cmp(b.file_name()).reverse()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("quux"), + dir.join("foo"), + dir.join("foo").join("bar"), + dir.join("foo").join("bar").join("baz"), + dir.join("foo").join("bar").join("baz").join("abc"), + ]; + assert_eq!(expected, r.paths()); +} + +#[test] +fn sort_max_open() { + let dir = Dir::tmp(); + dir.mkdirp("foo/bar/baz/abc"); + dir.mkdirp("quux"); + + let wd = WalkDir::new(dir.path()) + .max_open(1) + .sort_by(|a, b| a.file_name().cmp(b.file_name()).reverse()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = vec![ + dir.path().to_path_buf(), + dir.join("quux"), + dir.join("foo"), + dir.join("foo").join("bar"), + dir.join("foo").join("bar").join("baz"), + dir.join("foo").join("bar").join("baz").join("abc"), + ]; + assert_eq!(expected, r.paths()); +} + +#[cfg(target_os = "linux")] +#[test] +fn same_file_system() { + use std::path::Path; + + // This test is a little weird since it's not clear whether it's a good + // idea to setup a distinct mounted volume in these tests. Instead, we + // probe for an existing one. + if !Path::new("/sys").is_dir() { + return; + } + + let dir = Dir::tmp(); + dir.touch("a"); + dir.symlink_dir("/sys", "sys-link"); + + // First, do a sanity check that things work without following symlinks. + let wd = WalkDir::new(dir.path()); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = + vec![dir.path().to_path_buf(), dir.join("a"), dir.join("sys-link")]; + assert_eq!(expected, r.sorted_paths()); + + // ... now follow symlinks and ensure we don't descend into /sys. + let wd = + WalkDir::new(dir.path()).same_file_system(true).follow_links(true); + let r = dir.run_recursive(wd); + r.assert_no_errors(); + + let expected = + vec![dir.path().to_path_buf(), dir.join("a"), dir.join("sys-link")]; + assert_eq!(expected, r.sorted_paths()); +} + +// Tests that skip_current_dir doesn't destroy internal invariants. +// +// See: https://github.com/BurntSushi/walkdir/issues/118 +#[test] +fn regression_skip_current_dir() { + let dir = Dir::tmp(); + dir.mkdirp("foo/a/b"); + dir.mkdirp("foo/1/2"); + + let mut wd = WalkDir::new(dir.path()).max_open(1).into_iter(); + wd.next(); + wd.next(); + wd.next(); + wd.next(); + + wd.skip_current_dir(); + wd.skip_current_dir(); + wd.next(); +} diff --git a/third_party/cargo/vendor/walkdir-2.3.1/src/tests/util.rs b/third_party/cargo/vendor/walkdir-2.3.1/src/tests/util.rs new file mode 100644 index 0000000..fdf06f5 --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/src/tests/util.rs @@ -0,0 +1,252 @@ +use std::env; +use std::error; +use std::fs::{self, File}; +use std::io; +use std::path::{Path, PathBuf}; +use std::result; + +use crate::{DirEntry, Error}; + +/// Create an error from a format!-like syntax. +#[macro_export] +macro_rules! err { + ($($tt:tt)*) => { + Box::<dyn error::Error + Send + Sync>::from(format!($($tt)*)) + } +} + +/// A convenient result type alias. +pub type Result<T> = result::Result<T, Box<dyn error::Error + Send + Sync>>; + +/// The result of running a recursive directory iterator on a single directory. +#[derive(Debug)] +pub struct RecursiveResults { + ents: Vec<DirEntry>, + errs: Vec<Error>, +} + +impl RecursiveResults { + /// Return all of the errors encountered during traversal. + pub fn errs(&self) -> &[Error] { + &self.errs + } + + /// Assert that no errors have occurred. + pub fn assert_no_errors(&self) { + assert!( + self.errs.is_empty(), + "expected to find no errors, but found: {:?}", + self.errs + ); + } + + /// Return all the successfully retrieved directory entries in the order + /// in which they were retrieved. + pub fn ents(&self) -> &[DirEntry] { + &self.ents + } + + /// Return all paths from all successfully retrieved directory entries. + /// + /// This does not include paths that correspond to an error. + pub fn paths(&self) -> Vec<PathBuf> { + self.ents.iter().map(|d| d.path().to_path_buf()).collect() + } + + /// Return all the successfully retrieved directory entries, sorted + /// lexicographically by their full file path. + pub fn sorted_ents(&self) -> Vec<DirEntry> { + let mut ents = self.ents.clone(); + ents.sort_by(|e1, e2| e1.path().cmp(e2.path())); + ents + } + + /// Return all paths from all successfully retrieved directory entries, + /// sorted lexicographically. + /// + /// This does not include paths that correspond to an error. + pub fn sorted_paths(&self) -> Vec<PathBuf> { + self.sorted_ents().into_iter().map(|d| d.into_path()).collect() + } +} + +/// A helper for managing a directory in which to run tests. +/// +/// When manipulating paths within this directory, paths are interpreted +/// relative to this directory. +#[derive(Debug)] +pub struct Dir { + dir: TempDir, +} + +impl Dir { + /// Create a new empty temporary directory. + pub fn tmp() -> Dir { + let dir = TempDir::new().unwrap(); + Dir { dir } + } + + /// Return the path to this directory. + pub fn path(&self) -> &Path { + self.dir.path() + } + + /// Return a path joined to the path to this directory. + pub fn join<P: AsRef<Path>>(&self, path: P) -> PathBuf { + self.path().join(path) + } + + /// Run the given iterator and return the result as a distinct collection + /// of directory entries and errors. + pub fn run_recursive<I>(&self, it: I) -> RecursiveResults + where + I: IntoIterator<Item = result::Result<DirEntry, Error>>, + { + let mut results = RecursiveResults { ents: vec![], errs: vec![] }; + for result in it { + match result { + Ok(ent) => results.ents.push(ent), + Err(err) => results.errs.push(err), + } + } + results + } + + /// Create a directory at the given path, while creating all intermediate + /// directories as needed. + pub fn mkdirp<P: AsRef<Path>>(&self, path: P) { + let full = self.join(path); + fs::create_dir_all(&full) + .map_err(|e| { + err!("failed to create directory {}: {}", full.display(), e) + }) + .unwrap(); + } + + /// Create an empty file at the given path. All ancestor directories must + /// already exists. + pub fn touch<P: AsRef<Path>>(&self, path: P) { + let full = self.join(path); + File::create(&full) + .map_err(|e| { + err!("failed to create file {}: {}", full.display(), e) + }) + .unwrap(); + } + + /// Create empty files at the given paths. All ancestor directories must + /// already exists. + pub fn touch_all<P: AsRef<Path>>(&self, paths: &[P]) { + for p in paths { + self.touch(p); + } + } + + /// Create a file symlink to the given src with the given link name. + pub fn symlink_file<P1: AsRef<Path>, P2: AsRef<Path>>( + &self, + src: P1, + link_name: P2, + ) { + #[cfg(windows)] + fn imp(src: &Path, link_name: &Path) -> io::Result<()> { + use std::os::windows::fs::symlink_file; + symlink_file(src, link_name) + } + + #[cfg(unix)] + fn imp(src: &Path, link_name: &Path) -> io::Result<()> { + use std::os::unix::fs::symlink; + symlink(src, link_name) + } + + let (src, link_name) = (self.join(src), self.join(link_name)); + imp(&src, &link_name) + .map_err(|e| { + err!( + "failed to symlink file {} with target {}: {}", + src.display(), + link_name.display(), + e + ) + }) + .unwrap() + } + + /// Create a directory symlink to the given src with the given link name. + pub fn symlink_dir<P1: AsRef<Path>, P2: AsRef<Path>>( + &self, + src: P1, + link_name: P2, + ) { + #[cfg(windows)] + fn imp(src: &Path, link_name: &Path) -> io::Result<()> { + use std::os::windows::fs::symlink_dir; + symlink_dir(src, link_name) + } + + #[cfg(unix)] + fn imp(src: &Path, link_name: &Path) -> io::Result<()> { + use std::os::unix::fs::symlink; + symlink(src, link_name) + } + + let (src, link_name) = (self.join(src), self.join(link_name)); + imp(&src, &link_name) + .map_err(|e| { + err!( + "failed to symlink directory {} with target {}: {}", + src.display(), + link_name.display(), + e + ) + }) + .unwrap() + } +} + +/// A simple wrapper for creating a temporary directory that is automatically +/// deleted when it's dropped. +/// +/// We use this in lieu of tempfile because tempfile brings in too many +/// dependencies. +#[derive(Debug)] +pub struct TempDir(PathBuf); + +impl Drop for TempDir { + fn drop(&mut self) { + fs::remove_dir_all(&self.0).unwrap(); + } +} + +impl TempDir { + /// Create a new empty temporary directory under the system's configured + /// temporary directory. + pub fn new() -> Result<TempDir> { + #[allow(deprecated)] + use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; + + static TRIES: usize = 100; + #[allow(deprecated)] + static COUNTER: AtomicUsize = ATOMIC_USIZE_INIT; + + let tmpdir = env::temp_dir(); + for _ in 0..TRIES { + let count = COUNTER.fetch_add(1, Ordering::SeqCst); + let path = tmpdir.join("rust-walkdir").join(count.to_string()); + if path.is_dir() { + continue; + } + fs::create_dir_all(&path).map_err(|e| { + err!("failed to create {}: {}", path.display(), e) + })?; + return Ok(TempDir(path)); + } + Err(err!("failed to create temp dir after {} tries", TRIES)) + } + + /// Return the underlying path to this temporary directory. + pub fn path(&self) -> &Path { + &self.0 + } +} diff --git a/third_party/cargo/vendor/walkdir-2.3.1/src/util.rs b/third_party/cargo/vendor/walkdir-2.3.1/src/util.rs new file mode 100644 index 0000000..b9fcad8 --- /dev/null +++ b/third_party/cargo/vendor/walkdir-2.3.1/src/util.rs @@ -0,0 +1,25 @@ +use std::io; +use std::path::Path; + +#[cfg(unix)] +pub fn device_num<P: AsRef<Path>>(path: P) -> io::Result<u64> { + use std::os::unix::fs::MetadataExt; + + path.as_ref().metadata().map(|md| md.dev()) +} + +#[cfg(windows)] +pub fn device_num<P: AsRef<Path>>(path: P) -> io::Result<u64> { + use winapi_util::{file, Handle}; + + let h = Handle::from_path_any(path)?; + file::information(h).map(|info| info.volume_serial_number()) +} + +#[cfg(not(any(unix, windows)))] +pub fn device_num<P: AsRef<Path>>(_: P) -> io::Result<u64> { + Err(io::Error::new( + io::ErrorKind::Other, + "walkdir: same_file_system option not supported on this platform", + )) +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/.cargo-checksum.json b/third_party/cargo/vendor/wayland-client-0.21.13/.cargo-checksum.json new file mode 100644 index 0000000..8b89c51 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"64fb60b860735f77016f3930484e3c50d831f4feea1d7936076cca19905ba7d5","build.rs":"9da6649c903a99185c755b9c501a1ebfcb147c0f89a9c0d20d2619bcb4b788ef","examples/dynamic_globals.rs":"7ec24e7fdee780915d15f2236cd6804fadf7b16b46d94d62b6a960a6a99c6a19","examples/list_globals.rs":"b05d691efa2b9a69680abba94601fc4063fb7c465228e098024336dfc652b194","examples/simple_window.rs":"7b50e4a6e535fb49698bfc142f0ff5ac090aabf97b542d19f9037f7ffc4e0629","src/cursor.rs":"0a19c067f19eb7d3472263482c5c14bd24c6690d1fa859b479678cfc53f76abc","src/display.rs":"d0ed902fa37c2938e7047176cb81f85b05d282a48aada8ac228323320e753d35","src/egl.rs":"a1ff24cbf247a1679dc716a617232565f5d83fa39c7854d690ab4aac9d8ac949","src/event_queue.rs":"44a78c83c30e1eefcb039610835d1f9d2e7e5d54d82cef81a1b1031a86b73dec","src/globals.rs":"2f724371a3d8d8dc2039111b817340f9bed5b89a913bfe3bacf67281d6401a47","src/lib.rs":"6f3340ab9808cea3bcde9c2c9a90c5dbe0424e6875c628ee97bf2fab208a4587","src/native_lib/display.rs":"9b4eddaa3c2f71b60b1f5f3e543ded75d2a8a7051d2de6694cec21beaa03691f","src/native_lib/event_queue.rs":"eef45cea3256ae186103ffdd51ef38c7fb2f07f016eea2f6584344a0b096770c","src/native_lib/mod.rs":"4c8412191bb696642f4dbb1df93eb74319188cb68ae514d8d3fc747f23db8d17","src/native_lib/proxy.rs":"1e35534c6fe34c5f720d8de33a88e226c5f273e6bdc524b7eab46a177c67b30c","src/proxy.rs":"60ee4344cc2a913a332bbd2433359d2aec024aa52ae1e3df47e2300f1ddd814f","src/rust_imp/connection.rs":"72fe83594cbb98356ccba77f091e50a6c039c9ca44538a5e11a7364a7668b8ee","src/rust_imp/display.rs":"0125c0463fe27d91b3d0f05f0d490087d1cac41c1682d410bcf45829787f00b3","src/rust_imp/mod.rs":"2d514130df7d76a39ce80483d05e411483fb0e81734db4f94eb56b9ca11f648b","src/rust_imp/proxy.rs":"2eab2f11ebaeba6d694dbaadaf850a099ec4f68205f1de627db0a60988918363","src/rust_imp/queues.rs":"514431bdbe0675e240eaacaf9654cf6aacc94f86f0847aea65b0bb334e8aa543","wayland.xml":"356cc470810e14fd4d209b0979b2260d83f3db5e6975dbcddd174193c9d84ec7"},"package":"49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713"} \ No newline at end of file diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/BUILD b/third_party/cargo/vendor/wayland-client-0.21.13/BUILD new file mode 100644 index 0000000..9ca00db --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/BUILD @@ -0,0 +1,107 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + +rust_binary( + name = "wayland_client_build_script", + srcs = glob(["**/*.rs"]), + crate_root = "build.rs", + edition = "2015", + deps = [ + "//third_party/cargo/vendor/wayland-scanner-0.21.13:wayland_scanner", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + crate_features = [ + "cursor", + "dlopen", + "egl", + "native_lib", + "wayland-commons", + "wayland-sys", + ], + data = glob(["*"]), + version = "0.21.13", + visibility = ["//visibility:private"], +) + +genrule( + name = "wayland_client_build_script_executor", + srcs = glob(["*", "**/*.rs"]), + outs = ["wayland_client_out_dir_outputs.tar.gz"], + tools = [ + ":wayland_client_build_script", + ], + tags = ["no-sandbox"], + cmd = "mkdir -p $$(dirname $@)/wayland_client_out_dir_outputs/;" + + " (export CARGO_MANIFEST_DIR=\"$$PWD/$$(dirname $(location :Cargo.toml))\";" + # TODO(acmcarther): This needs to be revisited as part of the cross compilation story. + # See also: https://github.com/google/cargo-raze/pull/54 + + " export TARGET='x86_64-unknown-linux-gnu';" + + " export RUST_BACKTRACE=1;" + + " export CARGO_FEATURE_CURSOR=1;" + + " export CARGO_FEATURE_DLOPEN=1;" + + " export CARGO_FEATURE_EGL=1;" + + " export CARGO_FEATURE_NATIVE_LIB=1;" + + " export CARGO_FEATURE_WAYLAND_COMMONS=1;" + + " export CARGO_FEATURE_WAYLAND_SYS=1;" + + " export OUT_DIR=$$PWD/$$(dirname $@)/wayland_client_out_dir_outputs;" + + " export BINARY_PATH=\"$$PWD/$(location :wayland_client_build_script)\";" + + " export OUT_TAR=$$PWD/$@;" + + " cd $$(dirname $(location :Cargo.toml)) && $$BINARY_PATH && tar -czf $$OUT_TAR -C $$OUT_DIR .)" +) + +# Unsupported target "dynamic_globals" with type "example" omitted +# Unsupported target "list_globals" with type "example" omitted +# Unsupported target "simple_window" with type "example" omitted + +rust_library( + name = "wayland_client", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/bitflags-1.2.1:bitflags", + "//third_party/cargo/vendor/downcast-rs-1.1.1:downcast_rs", + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/nix-0.14.1:nix", + "//third_party/cargo/vendor/wayland-commons-0.21.13:wayland_commons", + "//third_party/cargo/vendor/wayland-sys-0.21.13:wayland_sys", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + out_dir_tar = ":wayland_client_build_script_executor", + version = "0.21.13", + crate_features = [ + "cursor", + "dlopen", + "egl", + "native_lib", + "wayland-commons", + "wayland-sys", + ], +) + diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/Cargo.toml b/third_party/cargo/vendor/wayland-client-0.21.13/Cargo.toml new file mode 100644 index 0000000..c43ee4e --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/Cargo.toml @@ -0,0 +1,66 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "wayland-client" +version = "0.21.13" +authors = ["Victor Berger <victor.berger@m4x.org>"] +build = "build.rs" +description = "Bindings to the standard C implementation of the wayland protocol, client side." +documentation = "https://smithay.github.io/wayland-rs/wayland_client/" +keywords = ["wayland", "client"] +categories = ["gui", "api-bindings"] +license = "MIT" +repository = "https://github.com/smithay/wayland-rs" +[dependencies.bitflags] +version = "1.0" + +[dependencies.calloop] +version = ">=0.3.1, <0.5" +optional = true + +[dependencies.downcast-rs] +version = "1.0" + +[dependencies.libc] +version = "0.2" + +[dependencies.mio] +version = "0.6.0" +optional = true + +[dependencies.nix] +version = "0.14.1" + +[dependencies.wayland-commons] +version = "0.21.13" + +[dependencies.wayland-sys] +version = "0.21.13" +features = ["client"] +optional = true +[dev-dependencies.byteorder] +version = "1.0" + +[dev-dependencies.tempfile] +version = ">=2.0, <4.0" +[build-dependencies.wayland-scanner] +version = "0.21.13" + +[features] +cursor = ["wayland-sys/cursor", "native_lib"] +dlopen = ["wayland-sys/dlopen", "native_lib"] +egl = ["wayland-sys/egl", "native_lib"] +eventloop = ["calloop", "mio"] +native_lib = ["wayland-sys", "wayland-commons/native_lib"] +[badges.travis-ci] +repository = "Smithay/wayland-rs" diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/build.rs b/third_party/cargo/vendor/wayland-client-0.21.13/build.rs new file mode 100644 index 0000000..8c7bff5 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/build.rs @@ -0,0 +1,20 @@ +extern crate wayland_scanner; + +use std::env::var; +use std::path::Path; +use wayland_scanner::*; + +fn main() { + let protocol_file = "./wayland.xml"; + + let out_dir_str = var("OUT_DIR").unwrap(); + let out_dir = Path::new(&out_dir_str); + + if var("CARGO_FEATURE_NATIVE_LIB").ok().is_some() { + // generate the C code + generate_c_code(protocol_file, out_dir.join("wayland_c_api.rs"), Side::Client); + generate_c_interfaces(protocol_file, out_dir.join("wayland_c_interfaces.rs")); + } else { + generate_rust_code(protocol_file, out_dir.join("wayland_rust_api.rs"), Side::Client); + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/examples/dynamic_globals.rs b/third_party/cargo/vendor/wayland-client-0.21.13/examples/dynamic_globals.rs new file mode 100644 index 0000000..9921838 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/examples/dynamic_globals.rs @@ -0,0 +1,109 @@ +#[macro_use] +extern crate wayland_client; + +use wayland_client::{Display, GlobalManager}; + +use wayland_client::protocol::{wl_output, wl_seat}; + +// An example showcasing the capability of GlobalManager to handle +// dynamically created globals like wl_seat or wl_output, which can +// exist with multiplicity and created at any time + +fn main() { + let (display, mut event_queue) = Display::connect_to_env().unwrap(); + + // We create a GlobalManager with a callback, that will be + // advertised of any global creation or deletion + let _globals = GlobalManager::new_with_cb( + &display, + // This macro generates a callback for auto-creating the globals + // that interest us and calling our provided callbacks + global_filter!( + // Here we ask that all seats be automatically instantiated + // with version 1 when advertised, and provide a callback that + // will handle the created wl_seat to implement them + // + // NOTE: the type annotations are necessary because rustc's + // inference is apparently not smart enough + [wl_seat::WlSeat, 1, |seat: NewProxy<_>| { + let mut seat_name = None; + let mut caps = None; + seat.implement( + move |event, _| { + use wayland_client::protocol::wl_seat::Event; + match event { + Event::Name { name } => { + seat_name = Some(name); + } + Event::Capabilities { capabilities } => { + // We *should* have received the "name" event first + caps = Some(capabilities); + } + } + }, + (), + ) + }], + // Same thing with wl_output, but we require version 2 + [wl_output::WlOutput, 2, |output: NewProxy<_>| { + let mut name = "<unknown>".to_owned(); + let mut modes = Vec::new(); + let mut scale = 1; + output.implement( + move |event, _| { + use wayland_client::protocol::wl_output::Event; + match event { + Event::Geometry { + x, + y, + physical_width, + physical_height, + subpixel, + make, + model, + transform, + } => { + println!("New output: \"{} ({})\"", make, model); + println!(" -> physical dimensions {}x{}", physical_width, physical_height); + println!(" -> location in the compositor space: ({}, {})", x, y); + println!(" -> transform: {:?}", transform); + println!(" -> subpixel orientation: {:?}", subpixel); + name = format!("{} ({})", make, model); + } + Event::Mode { + flags, + width, + height, + refresh, + } => { + modes.push((flags, width, height, refresh)); + } + Event::Scale { factor } => { + scale = factor; + } + Event::Done => { + println!("Modesetting information for output \"{}\"", name); + println!(" -> scaling factor: {}", scale); + println!(" -> mode list:"); + for &(f, w, h, r) in &modes { + println!( + " -> {}x{} @{}Hz (flags: [ {:?} ])", + w, + h, + (r as f32) / 1000.0, + f + ); + } + } + } + }, + (), + ) + }] + ), + ); + + event_queue.sync_roundtrip().unwrap(); + event_queue.sync_roundtrip().unwrap(); + event_queue.sync_roundtrip().unwrap(); +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/examples/list_globals.rs b/third_party/cargo/vendor/wayland-client-0.21.13/examples/list_globals.rs new file mode 100644 index 0000000..7993c7a --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/examples/list_globals.rs @@ -0,0 +1,25 @@ +extern crate wayland_client; + +use wayland_client::{Display, GlobalManager}; + +// A minimal example printing the list of globals advertised by the server and +// then exiting + +fn main() { + // Connect to the server + let (display, mut event_queue) = Display::connect_to_env().unwrap(); + + // We use the GlobalManager convenience provided by the crate, it covers + // most classic use cases and avoids us the trouble to manually implement + // the registry + let globals = GlobalManager::new(&display); + + // A roundtrip synchronization to make sure the server received our registry + // creation and sent us the global list + event_queue.sync_roundtrip().unwrap(); + + // Print the list + for (id, interface, version) in globals.list() { + println!("{}: {} (version {})", id, interface, version); + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/examples/simple_window.rs b/third_party/cargo/vendor/wayland-client-0.21.13/examples/simple_window.rs new file mode 100644 index 0000000..2464c4c --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/examples/simple_window.rs @@ -0,0 +1,168 @@ +extern crate byteorder; +extern crate tempfile; +extern crate wayland_client; + +use std::cmp::min; +use std::io::Write; +use std::os::unix::io::AsRawFd; + +use byteorder::{NativeEndian, WriteBytesExt}; + +use wayland_client::protocol::wl_compositor::RequestsTrait as CompositorRequests; +use wayland_client::protocol::wl_shell::RequestsTrait as ShellRequests; +use wayland_client::protocol::wl_shell_surface::RequestsTrait as ShellSurfaceRequests; +use wayland_client::protocol::wl_shm::RequestsTrait as ShmRequests; +use wayland_client::protocol::wl_shm_pool::RequestsTrait as PoolRequests; +use wayland_client::protocol::wl_surface::RequestsTrait as SurfaceRequests; +use wayland_client::protocol::{wl_compositor, wl_seat, wl_shell, wl_shell_surface, wl_shm}; +use wayland_client::{Display, GlobalManager, Proxy}; + +fn main() { + let (display, mut event_queue) = Display::connect_to_env().unwrap(); + let globals = GlobalManager::new(&display); + + // roundtrip to retrieve the globals list + event_queue.sync_roundtrip().unwrap(); + + /* + * Create a buffer with window contents + */ + + // buffer (and window) width and height + let buf_x: u32 = 320; + let buf_y: u32 = 240; + + // create a tempfile to write the contents of the window on + let mut tmp = tempfile::tempfile().ok().expect("Unable to create a tempfile."); + // write the contents to it, lets put a nice color gradient + for i in 0..(buf_x * buf_y) { + let x = (i % buf_x) as u32; + let y = (i / buf_x) as u32; + let r: u32 = min(((buf_x - x) * 0xFF) / buf_x, ((buf_y - y) * 0xFF) / buf_y); + let g: u32 = min((x * 0xFF) / buf_x, ((buf_y - y) * 0xFF) / buf_y); + let b: u32 = min(((buf_x - x) * 0xFF) / buf_x, (y * 0xFF) / buf_y); + let _ = tmp.write_u32::<NativeEndian>((0xFF << 24) + (r << 16) + (g << 8) + b); + } + let _ = tmp.flush(); + + /* + * Init wayland objects + */ + + // The compositor allows us to creates surfaces + let compositor = globals + .instantiate_auto::<wl_compositor::WlCompositor, _>(|comp| comp.implement(|_, _| {}, ())) + .unwrap(); + let surface = compositor + .create_surface(|surface| surface.implement(|_, _| {}, ())) + .unwrap(); + + // The SHM allows us to share memory with the server, and create buffers + // on this shared memory to paint our surfaces + let shm = globals + .instantiate_auto::<wl_shm::WlShm, _>(|shm| shm.implement(|_, _| {}, ())) + .unwrap(); + let pool = shm + .create_pool( + tmp.as_raw_fd(), // RawFd to the tempfile serving as shared memory + (buf_x * buf_y * 4) as i32, // size in bytes of the shared memory (4 bytes per pixel) + |pool| pool.implement(|_, _| {}, ()), + ) + .unwrap(); + let buffer = pool + .create_buffer( + 0, // Start of the buffer in the pool + buf_x as i32, // width of the buffer in pixels + buf_y as i32, // height of the buffer in pixels + (buf_x * 4) as i32, // number of bytes between the beginning of two consecutive lines + wl_shm::Format::Argb8888, // chosen encoding for the data + |buffer| buffer.implement(|_, _| {}, ()), + ) + .unwrap(); + + // The shell allows us to define our surface as a "toplevel", meaning the + // server will treat it as a window + // + // NOTE: the wl_shell interface is actually deprecated in favour of the xdg_shell + // protocol, available in wayland-protocols. But this will do for this example. + let shell = globals + .instantiate_auto::<wl_shell::WlShell, _>(|shell| shell.implement(|_, _| {}, ())) + .unwrap(); + let shell_surface = shell + .get_shell_surface(&surface, |shellsurface| { + shellsurface.implement( + |event, shell_surface: Proxy<wl_shell_surface::WlShellSurface>| { + use wayland_client::protocol::wl_shell_surface::{Event, RequestsTrait}; + // This ping/pong mechanism is used by the wayland server to detect + // unresponsive applications + if let Event::Ping { serial } = event { + shell_surface.pong(serial); + } + }, + (), + ) + }) + .unwrap(); + + // Set our surface as toplevel and define its contents + shell_surface.set_toplevel(); + surface.attach(Some(&buffer), 0, 0); + surface.commit(); + + // initialize a seat to retrieve pointer events + // to be handled properly this should be more dynamic, as more + // than one seat can exist (and they can be created and destroyed + // dynamically), however most "traditional" setups have a single + // seat, so we'll keep it simple here + let mut pointer_created = false; + globals.instantiate_auto::<wl_seat::WlSeat, _>(|seat| { + seat.implement( + move |event, seat: Proxy<wl_seat::WlSeat>| { + // The capabilities of a seat are known at runtime and we retrieve + // them via an events. 3 capabilities exists: pointer, keyboard, and touch + // we are only interested in pointer here + use wayland_client::protocol::wl_pointer::Event as PointerEvent; + use wayland_client::protocol::wl_seat::{ + Capability, Event as SeatEvent, RequestsTrait as SeatRequests, + }; + + if let SeatEvent::Capabilities { capabilities } = event { + if !pointer_created && capabilities.contains(Capability::Pointer) { + // create the pointer only once + pointer_created = true; + seat.get_pointer(|pointer| { + pointer.implement( + |event, _| match event { + PointerEvent::Enter { + surface_x, surface_y, .. + } => { + println!("Pointer entered at ({}, {}).", surface_x, surface_y); + } + PointerEvent::Leave { .. } => { + println!("Pointer left."); + } + PointerEvent::Motion { + surface_x, surface_y, .. + } => { + println!("Pointer moved to ({}, {}).", surface_x, surface_y); + } + PointerEvent::Button { button, state, .. } => { + println!("Button {} was {:?}.", button, state); + } + _ => {} + }, + (), + ) + }); + } + } + }, + (), + ) + }); + + loop { + display.flush().unwrap(); + event_queue.dispatch().unwrap(); + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/cursor.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/cursor.rs new file mode 100644 index 0000000..3205eb7 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/cursor.rs @@ -0,0 +1,234 @@ +//! Cursor utilities +//! +//! This module contains bindings to the `libwayland-cursor.so` library. +//! +//! These utilities allows you to load cursor images in order to match +//! your cursors to the ones of the system. +//! +//! First of all, the function `load_theme` will allow you to load a +//! `CursorTheme`, which represents the full cursor theme. +//! +//! From this theme, you can load a specific `Cursor`, which can each +//! contain several images if the cursor is animated. It provides you +//! with the means of knowing which frame of the animation should be +//! displayed at which time, as well as handles to the buffers containing +//! these frames, to attach them to a wayland surface. + +use protocol::wl_buffer::WlBuffer; +use protocol::wl_shm::WlShm; +use std::ffi::{CStr, CString}; +use std::marker::PhantomData; +use std::ops::Deref; +use std::os::raw::c_int; +use std::ptr; +use wayland_sys::cursor::*; +use Proxy; + +/// Checks if the wayland-cursor lib is available and can be used +/// +/// Trying to call any function of this module if the lib cannot +/// be used will result in a panic. +pub fn is_available() -> bool { + is_lib_available() +} + +/// Represents a cursor theme loaded from the system. +pub struct CursorTheme { + theme: *mut wl_cursor_theme, +} + +unsafe impl Send for CursorTheme {} + +/// Attempts to load a cursor theme from given name. +/// +/// If no name is given or the requested theme is not found, will +/// load the default theme. +/// +/// Other arguments are the requested size for the cursor images (ex: 16) +/// and a handle to the global `WlShm` object. +/// +/// Panics: +/// +/// - If the `wayland-cursor` lib is not available (see `is_available()` function) +/// in this module. +/// - In case of memory allocation failure. +/// - If the theme name provided as argument contains an interior null +pub fn load_theme(name: Option<&str>, size: u32, shm: &Proxy<WlShm>) -> CursorTheme { + let ptr = if let Some(theme) = name { + let cstr = CString::new(theme).expect("Theme name contained an interior null."); + unsafe { + ffi_dispatch!( + WAYLAND_CURSOR_HANDLE, + wl_cursor_theme_load, + cstr.as_ptr(), + size as c_int, + shm.c_ptr() + ) + } + } else { + unsafe { + ffi_dispatch!( + WAYLAND_CURSOR_HANDLE, + wl_cursor_theme_load, + ptr::null(), + size as c_int, + shm.c_ptr() + ) + } + }; + + assert!(!ptr.is_null(), "Memory allocation failure while loading a theme."); + + CursorTheme { theme: ptr } +} + +impl CursorTheme { + /// Retrieve a cursor from the theme. + /// + /// Returns `None` if this cursor is not provided by the theme. + /// + /// Panics if the name contains an interior null. + pub fn get_cursor(&self, name: &str) -> Option<Cursor> { + let cstr = CString::new(name).expect("Cursor name contained an interior null."); + let ptr = unsafe { + ffi_dispatch!( + WAYLAND_CURSOR_HANDLE, + wl_cursor_theme_get_cursor, + self.theme, + cstr.as_ptr() + ) + }; + if ptr.is_null() { + None + } else { + Some(Cursor { + _theme: PhantomData, + cursor: ptr, + }) + } + } +} + +impl Drop for CursorTheme { + fn drop(&mut self) { + unsafe { + ffi_dispatch!(WAYLAND_CURSOR_HANDLE, wl_cursor_theme_destroy, self.theme); + } + } +} + +/// A cursor from a theme. Can contain several images if animated. +pub struct Cursor<'a> { + _theme: PhantomData<&'a CursorTheme>, + cursor: *mut wl_cursor, +} + +unsafe impl<'a> Send for Cursor<'a> {} + +impl<'a> Cursor<'a> { + /// Retrieve the name of this cursor. + pub fn name(&self) -> String { + let name = unsafe { CStr::from_ptr((*self.cursor).name) }; + name.to_string_lossy().into_owned() + } + + /// Retrieve the number of images contained in this + /// animated cursor + pub fn image_count(&self) -> usize { + let count = unsafe { (*self.cursor).image_count }; + count as usize + } + + /// Retrieve the image number of cursor animation. + /// + /// Returns the image number of the animation that should be displayed + /// after a given amount of time since the beginning of the animation, + /// in milliseconds. + pub fn frame(&self, duration: u32) -> usize { + let frame = unsafe { ffi_dispatch!(WAYLAND_CURSOR_HANDLE, wl_cursor_frame, self.cursor, duration) }; + frame as usize + } + + /// Retrieve the image number and its duration. + /// + /// Same as `frame()`, but also returns the number of milliseconds this + /// frame should still be displayed. + pub fn frame_and_duration(&self, duration: u32) -> (usize, u32) { + let mut out_duration = 0u32; + let frame = unsafe { + ffi_dispatch!( + WAYLAND_CURSOR_HANDLE, + wl_cursor_frame_and_duration, + self.cursor, + duration, + &mut out_duration as *mut u32 + ) + } as usize; + (frame, out_duration) + } + + /// Retrieve a `CursorImageBuffer` containing the given image of an animation. + /// + /// It can be used to be attached to a surface as a classic `WlBuffer`. + /// + /// Returns `None` if the frame is out of bounds. + /// + /// Note: destroying this buffer (using the `destroy` method) will corrupt + /// your theme data, so you might not want to do it. + pub fn frame_buffer(&self, frame: usize) -> Option<CursorImageBuffer> { + if frame >= self.image_count() { + None + } else { + unsafe { + let image = *(*self.cursor).images.offset(frame as isize); + let ptr = ffi_dispatch!(WAYLAND_CURSOR_HANDLE, wl_cursor_image_get_buffer, image); + let buffer = Proxy::from_c_ptr(ptr); + + Some(CursorImageBuffer { + _cursor: PhantomData, + buffer: buffer, + }) + } + } + } + + /// Retrieve the metadata associated with given frame of the animation. + /// + /// The tuple contains: `(width, height, hotspot_x, hotspot_y, delay)` + /// + /// Returns `None` if the frame is out of bounds. + pub fn frame_info(&self, frame: usize) -> Option<(u32, u32, u32, u32, u32)> { + if frame >= self.image_count() { + None + } else { + let image = unsafe { &**(*self.cursor).images.offset(frame as isize) }; + Some(( + image.width, + image.height, + image.hotspot_x, + image.hotspot_y, + image.delay, + )) + } + } +} + +/// A buffer containing a cursor image. +/// +/// You can access the `Proxy<WlBuffer>` via `Deref`. +/// +/// Note that this proxy will be considered as "unmanaged" by the crate, as such you should +/// not try to act on it beyond assigning it to `wl_surface`s. +pub struct CursorImageBuffer<'a> { + _cursor: PhantomData<&'a Cursor<'a>>, + buffer: Proxy<WlBuffer>, +} + +unsafe impl<'a> Send for CursorImageBuffer<'a> {} + +impl<'a> Deref for CursorImageBuffer<'a> { + type Target = Proxy<WlBuffer>; + fn deref(&self) -> &Proxy<WlBuffer> { + &self.buffer + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/display.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/display.rs new file mode 100644 index 0000000..8ce88c7 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/display.rs @@ -0,0 +1,193 @@ +use std::env; +use std::ffi::OsString; +use std::io; +use std::ops::Deref; +use std::os::unix::io::{IntoRawFd, RawFd}; +use std::os::unix::net::UnixStream; +use std::path::PathBuf; +use std::sync::Arc; + +use nix::fcntl; + +use {EventQueue, Proxy}; + +use imp::DisplayInner; + +#[cfg(feature = "native_lib")] +use wayland_sys::client::wl_display; + +/// Enum representing the possible reasons why connecting to the wayland server failed +#[derive(Debug)] +pub enum ConnectError { + /// The library was compiled with the `dlopen` feature, and the `libwayland-client.so` + /// library could not be found at runtime + NoWaylandLib, + /// The `XDG_RUNTIME_DIR` variable is not set while it should be + XdgRuntimeDirNotSet, + /// Any needed library was found, but the listening socket of the server could not be + /// found. + /// + /// Most of the time, this means that the program was not started from a wayland session. + NoCompositorListening, + /// The provided socket name is invalid + InvalidName, + /// The FD provided in `WAYLAND_SOCKET` was invalid + InvalidFd, +} + +impl ::std::error::Error for ConnectError { + fn description(&self) -> &str { + match *self { + ConnectError::NoWaylandLib => "Could not find libwayland-client.so.", + ConnectError::XdgRuntimeDirNotSet => "XDG_RUNTIME_DIR is not set.", + ConnectError::NoCompositorListening => "Could not find a listening wayland compositor.", + ConnectError::InvalidName => "The wayland socket name is invalid.", + ConnectError::InvalidFd => "The FD provided in WAYLAND_SOCKET is invalid.", + } + } +} + +impl ::std::fmt::Display for ConnectError { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { + f.write_str(::std::error::Error::description(self)) + } +} + +/// A connection to a wayland server +/// +/// This object both represent the connection to the server, and as such +/// must be kept alive as long as you are connected, and contains the +/// primary `WlDisplay` wayland object, from which you can create all +/// your need objects. The inner `Proxy<WlDisplay>` can be accessed via +/// `Deref`. +pub struct Display { + pub(crate) inner: Arc<DisplayInner>, +} + +impl Display { + /// Attempt to connect to a wayland server using the contents of the environment variables + /// + /// First of all, if the `WAYLAND_SOCKET` environment variable is set, it'll try to interpret + /// it as a FD number to use + /// + /// If the `WAYLAND_DISPLAY` variable is set, it will try to connect to the socket it points + /// to. Otherwise, it will default to `wayland-0`. + /// + /// On success, you are given the `Display` object as well as the main `EventQueue` hosting + /// the `WlDisplay` wayland object. + /// + /// This requires the `XDG_RUNTIME_DIR` variable to be properly set. + pub fn connect_to_env() -> Result<(Display, EventQueue), ConnectError> { + if let Ok(txt) = env::var("WAYLAND_SOCKET") { + // We should connect to the provided WAYLAND_SOCKET + let fd = txt.parse::<i32>().map_err(|_| ConnectError::InvalidFd)?; + // set the CLOEXEC flag on this FD + let flags = fcntl::fcntl(fd, fcntl::FcntlArg::F_GETFD); + let result = flags + .map(|f| fcntl::FdFlag::from_bits(f).unwrap() | fcntl::FdFlag::FD_CLOEXEC) + .and_then(|f| fcntl::fcntl(fd, fcntl::FcntlArg::F_SETFD(f))); + match result { + Ok(_) => { + // setting the O_CLOEXEC worked + unsafe { Display::from_fd(fd) } + } + Err(_) => { + // something went wrong in F_GETFD or F_SETFD + let _ = ::nix::unistd::close(fd); + return Err(ConnectError::InvalidFd); + } + } + } else { + let mut socket_path = env::var_os("XDG_RUNTIME_DIR") + .map(Into::<PathBuf>::into) + .ok_or(ConnectError::XdgRuntimeDirNotSet)?; + socket_path.push(env::var_os("WAYLAND_DISPLAY").unwrap_or_else(|| "wayland-0".into())); + + let socket = UnixStream::connect(socket_path).map_err(|_| ConnectError::NoCompositorListening)?; + unsafe { Display::from_fd(socket.into_raw_fd()) } + } + } + + /// Attempt to connect to a wayland server socket with given name + /// + /// On success, you are given the `Display` object as well as the main `EventQueue` hosting + /// the `WlDisplay` wayland object. + /// + /// This requires the `XDG_RUNTIME_DIR` variable to be properly set. + pub fn connect_to_name<S: Into<OsString>>(name: S) -> Result<(Display, EventQueue), ConnectError> { + let mut socket_path = env::var_os("XDG_RUNTIME_DIR") + .map(Into::<PathBuf>::into) + .ok_or(ConnectError::XdgRuntimeDirNotSet)?; + socket_path.push(name.into()); + + let socket = UnixStream::connect(socket_path).map_err(|_| ConnectError::NoCompositorListening)?; + unsafe { Display::from_fd(socket.into_raw_fd()) } + } + + /// Attempt to use an already connected unix socket on given FD to start a wayland connection + /// + /// On success, you are given the `Display` object as well as the main `EventQueue` hosting + /// the `WlDisplay` wayland object. + /// + /// Will take ownership of the FD. + pub unsafe fn from_fd(fd: RawFd) -> Result<(Display, EventQueue), ConnectError> { + let (d_inner, evq_inner) = DisplayInner::from_fd(fd)?; + Ok((Display { inner: d_inner }, EventQueue::new(evq_inner))) + } + + /// Non-blocking write to the server + /// + /// Outgoing messages to the server are buffered by the library for efficiency. This method + /// flushes the internal buffer to the server socket. + /// + /// Will write as many pending requests as possible to the server socket. Never blocks: if not all + /// requests could be written, will return an io error `WouldBlock`. + /// + /// On success returns the number of written requests. + pub fn flush(&self) -> io::Result<()> { + self.inner.flush() + } + + /// Create a new event queue associated with this wayland connection + pub fn create_event_queue(&self) -> EventQueue { + let evq_inner = DisplayInner::create_event_queue(&self.inner); + EventQueue::new(evq_inner) + } + + #[cfg(feature = "native_lib")] + /// Create a Display and Event Queue from an external display + /// + /// This allows you to interface with an already-existing wayland connection, + /// for example provided by a GUI toolkit. + /// + /// To avoid interferences with the owner of the connection, wayland-client will + /// create a new event queue and register a wrapper of the `wl_display` to this queue, + /// then provide them to you. You can then use them as if they came from a direct + /// wayland connection. + /// + /// Note that if you need to retrieve the actual `wl_display` pointer back (rather than + /// its wrapper), you must use the `get_display_ptr()` method. + pub unsafe fn from_external_display(display_ptr: *mut wl_display) -> (Display, EventQueue) { + let (d_inner, evq_inner) = DisplayInner::from_external(display_ptr); + (Display { inner: d_inner }, EventQueue::new(evq_inner)) + } + + #[cfg(feature = "native_lib")] + /// Retrieve the `wl_display` pointer + /// + /// If this `Display` was created from an external `wl_display`, its `c_ptr()` method will + /// return a wrapper to the actual display. While this is perfectly good as a `wl_proxy` + /// pointer, to send requests, this is not the actual `wl_display` and cannot be used as such. + /// + /// This method will give you the `wl_display`. + pub fn get_display_ptr(&self) -> *mut wl_display { + self.inner.ptr() + } +} + +impl Deref for Display { + type Target = Proxy<::protocol::wl_display::WlDisplay>; + fn deref(&self) -> &Proxy<::protocol::wl_display::WlDisplay> { + self.inner.get_proxy() + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/egl.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/egl.rs new file mode 100644 index 0000000..23aaab2 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/egl.rs @@ -0,0 +1,103 @@ +//! EGL utilities +//! +//! This module contains bindings to the `libwayland-egl.so` library. +//! +//! This library is used to interface with the OpenGL stack, and creating +//! EGL surfaces from a wayland surface. +//! +//! See WlEglSurface documentation for details. + +use protocol::wl_surface::WlSurface; +use std::os::raw::c_void; +use wayland_sys::client::wl_proxy; +use wayland_sys::egl::*; +use Proxy; + +/// Checks if the wayland-egl lib is available and can be used +/// +/// Trying to create an `WlEglSurface` while this function returns +/// `false` will result in a panic. +pub fn is_available() -> bool { + is_lib_available() +} + +unsafe impl Send for WlEglSurface {} +unsafe impl Sync for WlEglSurface {} + +/// EGL surface +/// +/// This object is a simple wrapper around a `WlSurface` to add the EGL +/// capabilities. Just use the `ptr` method once this object is created +/// to get the window pointer your OpenGL library is needing to initialize the +/// EGL context (you'll most likely need the display ptr as well, that you can +/// get via the `ptr` method of the `Proxy` trait on the `WlDisplay` object). +pub struct WlEglSurface { + ptr: *mut wl_egl_window, +} + +impl WlEglSurface { + /// Create an EGL surface from a wayland surface + pub fn new(surface: &Proxy<WlSurface>, width: i32, height: i32) -> WlEglSurface { + unsafe { WlEglSurface::new_from_raw(surface.c_ptr(), width, height) } + } + + /// Create an EGL surface from a raw pointer to a wayland surface + /// + /// This function is unsafe because `surface` must be a valid wl_surface pointer + pub unsafe fn new_from_raw(surface: *mut wl_proxy, width: i32, height: i32) -> WlEglSurface { + let ptr = ffi_dispatch!(WAYLAND_EGL_HANDLE, wl_egl_window_create, surface, width, height); + WlEglSurface { ptr: ptr } + } + + /// Fetch current size of the EGL surface + pub fn get_size(&self) -> (i32, i32) { + let mut w = 0i32; + let mut h = 0i32; + unsafe { + ffi_dispatch!( + WAYLAND_EGL_HANDLE, + wl_egl_window_get_attached_size, + self.ptr, + &mut w as *mut i32, + &mut h as *mut i32 + ); + } + (w, h) + } + + /// Resize the EGL surface + /// + /// The two first arguments `(width, height)` are the new size of + /// the surface, the two others `(dx, dy)` represent the displacement + /// of the top-left corner of the surface. It allows you to control the + /// direction of the resizing if necessary. + pub fn resize(&self, width: i32, height: i32, dx: i32, dy: i32) { + unsafe { + ffi_dispatch!( + WAYLAND_EGL_HANDLE, + wl_egl_window_resize, + self.ptr, + width, + height, + dx, + dy + ) + } + } + + /// Raw pointer to the EGL surface + /// + /// You'll need this pointer to initialize the EGL context in your + /// favourite OpenGL lib. + pub fn ptr(&self) -> *const c_void { + self.ptr as *const c_void + } +} + +impl Drop for WlEglSurface { + fn drop(&mut self) { + unsafe { + ffi_dispatch!(WAYLAND_EGL_HANDLE, wl_egl_window_destroy, self.ptr); + } + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/event_queue.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/event_queue.rs new file mode 100644 index 0000000..2228a7d --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/event_queue.rs @@ -0,0 +1,172 @@ +use std::io; +use std::rc::Rc; + +use imp::EventQueueInner; + +/// An event queue for protocol messages +/// +/// Event dispatching in wayland is made on a queue basis, allowing you +/// to organize your objects into different queues that can be dispatched +/// independently, for example from different threads. +/// +/// And `EventQueue` is not `Send`, and thus must stay on the thread on which +/// they were created. However the `Display` object is `Send + Sync`, allowing +/// you to create the queues directly in the threads that host them. +/// +/// When a queue is dispatched (via the `dispatch()` or `dispatch_pending()` methods) +/// all the incoming messages from the server designated to objects associated with +/// the queue are processed sequentially, and the appropriate implementation for each +/// is invoked. When all messages have been processed these methods return. +/// +/// Thus, a typical single-queue event loop for a simple wayland app can be: +/// +/// ```no_run +/// # extern crate wayland_client; +/// # use wayland_client::{Display}; +/// # fn main() { +/// # let (display, mut event_queue) = Display::connect_to_env().unwrap(); +/// loop { +/// display.flush().unwrap(); +/// event_queue.dispatch().expect("An error occurred during event dispatching!"); +/// } +/// # } +/// ``` +/// +/// See `EventQueue::prepare_read()` if you need more control about when the connection +/// socket is read. This will typically the case if you need to integrate other sources +/// of event into the event loop of your application. +pub struct EventQueue { + // EventQueue is *not* Send + pub(crate) inner: Rc<EventQueueInner>, +} + +/// A token representing this event queue +/// +/// This token can be cloned and is meant to allow easier +/// interaction with other functions in the library that +/// require the specification of an event queue, like +/// `Proxy::make_wrapper` and `NewProxy::implement_nonsend`. +pub struct QueueToken { + pub(crate) inner: Rc<EventQueueInner>, +} + +impl EventQueue { + pub(crate) fn new(inner: EventQueueInner) -> EventQueue { + EventQueue { + inner: Rc::new(inner), + } + } + /// Dispatches events from the internal buffer. + /// + /// Dispatches all events to their appropriators. + /// If no events were in the internal buffer, will block until + /// some events are read and dispatch them. + /// This process can insert events in the internal buffers of + /// other event queues. + /// + /// If an error is returned, your connection with the wayland + /// compositor is probably lost. + pub fn dispatch(&mut self) -> io::Result<u32> { + self.inner.dispatch() + } + + /// Dispatches pending events from the internal buffer. + /// + /// Dispatches all events to their appropriators. + /// Never blocks, if no events were pending, simply returns + /// `Ok(0)`. + /// + /// If an error is returned, your connection with the wayland + /// compositor is probably lost. + pub fn dispatch_pending(&mut self) -> io::Result<u32> { + self.inner.dispatch_pending() + } + + /// Synchronous roundtrip + /// + /// This call will cause a synchronous roundtrip with the wayland server. It will block until all + /// pending requests of this queue are sent to the server and it has processed all of them and + /// send the appropriate events. + /// + /// Handlers are called as a consequence. + /// + /// On success returns the number of dispatched events. + pub fn sync_roundtrip(&mut self) -> io::Result<u32> { + self.inner.sync_roundtrip() + } + + /// Create a new token associated with this event queue + /// + /// See `QueueToken` documentation for its use. + pub fn get_token(&self) -> QueueToken { + QueueToken { + inner: self.inner.clone(), + } + } + + /// Prepare an concurrent read + /// + /// Will declare your intention to read events from the server socket. + /// + /// Will return `None` if there are still some events awaiting dispatch on this EventIterator. + /// In this case, you need to call `dispatch_pending()` before calling this method again. + /// + /// As long as the returned guard is in scope, no events can be dispatched to any event iterator. + /// + /// The guard can then be destroyed by two means: + /// + /// - Calling its `cancel()` method (or letting it go out of scope): the read intention will + /// be cancelled + /// - Calling its `read_events()` method: will block until all existing guards are destroyed + /// by one of these methods, then events will be read and all blocked `read_events()` calls + /// will return. + /// + /// This call will otherwise not block on the server socket if it is empty, and return + /// an io error `WouldBlock` in such cases. + pub fn prepare_read(&self) -> Option<ReadEventsGuard> { + match self.inner.prepare_read() { + Ok(()) => Some(ReadEventsGuard { + inner: self.inner.clone(), + done: false, + }), + Err(()) => None, + } + } +} + +/// A guard over a read intention. +/// +/// See `EventQueue::prepare_read()` for details about its use. +pub struct ReadEventsGuard { + inner: Rc<EventQueueInner>, + done: bool, +} + +impl ReadEventsGuard { + /// Read events + /// + /// Reads events from the server socket. If other `ReadEventsGuard` exists, will block + /// until they are all consumed or destroyed. + pub fn read_events(mut self) -> io::Result<i32> { + self.done = true; + self.inner.read_events() + } + + /// Cancel the read + /// + /// Will cancel the read intention associated with this guard. Never blocks. + /// + /// Has the same effect as letting the guard go out of scope. + pub fn cancel(mut self) { + // just run the destructor + self.done = true; + } +} + +impl Drop for ReadEventsGuard { + fn drop(&mut self) { + if !self.done { + self.inner.cancel_read(); + } + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/globals.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/globals.rs new file mode 100644 index 0000000..ed07efd --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/globals.rs @@ -0,0 +1,346 @@ +use std::sync::{Arc, Mutex}; + +use protocol::wl_display::{self, RequestsTrait as DisplayRequests}; +use protocol::wl_registry::{self, RequestsTrait as RegistryRequests}; +use {Interface, NewProxy, Proxy}; + +struct Inner { + list: Vec<(u32, String, u32)>, + callback: Box<FnMut(GlobalEvent, Proxy<wl_registry::WlRegistry>) + Send>, +} + +/// An utility to manage global objects +/// +/// This utility provides an implemenation for the registry +/// that track the list of globals for you, as well as utilities +/// to bind them. +#[derive(Clone)] +pub struct GlobalManager { + inner: Arc<Mutex<Inner>>, + registry: Proxy<wl_registry::WlRegistry>, +} + +/// An error that occurred trying to bind a global +#[derive(Debug, PartialEq)] +pub enum GlobalError { + /// The requested global was missing + Missing, + /// The global advertised by the server has a lower version number + /// than the one requested + VersionTooLow(u32), +} + +impl ::std::error::Error for GlobalError { + fn description(&self) -> &str { + match *self { + GlobalError::Missing => "The requested global was missing.", + GlobalError::VersionTooLow(_) => "The requested global's version is too low.", + } + } +} + +impl ::std::fmt::Display for GlobalError { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { + f.write_str(::std::error::Error::description(self)) + } +} + +/// Event provided to the user callback of GlobalManager +pub enum GlobalEvent { + /// A new global was created + New { + /// Id of the new global + id: u32, + /// Interface of the new global + interface: String, + /// Maximum supported version of the new global + version: u32, + }, + /// A global was removed + Removed { + /// Id of the removed global + id: u32, + /// Interface of the removed global + interface: String, + }, +} + +impl GlobalManager { + /// Create a global manager handling a registry + pub fn new(display: &Proxy<wl_display::WlDisplay>) -> GlobalManager { + let inner = Arc::new(Mutex::new(Inner { + list: Vec::new(), + callback: Box::new(|_, _| {}), + })); + let inner_clone = inner.clone(); + + let registry = display + .get_registry(|registry| { + registry.implement( + move |msg, _proxy| { + let mut inner = inner.lock().unwrap(); + match msg { + wl_registry::Event::Global { + name, + interface, + version, + } => { + inner.list.push((name, interface, version)); + } + wl_registry::Event::GlobalRemove { name } => { + inner.list.retain(|&(n, _, _)| n != name); + } + } + }, + (), + ) + }) + .expect("Attempted to create a GlobalManager from a dead display."); + + GlobalManager { + inner: inner_clone, + registry: registry, + } + } + + /// Create a global manager handling a registry with a callback + /// + /// This global manager will track globals as a simple one, but will + /// also forward the registry events to your callback. + /// + /// This can be used if you want to handle specially certain globals, but want + /// to use the default mechanism for the rest. + pub fn new_with_cb<F>(display: &Proxy<wl_display::WlDisplay>, callback: F) -> GlobalManager + where + F: FnMut(GlobalEvent, Proxy<wl_registry::WlRegistry>) + Send + 'static, + { + let inner = Arc::new(Mutex::new(Inner { + list: Vec::new(), + callback: Box::new(callback), + })); + let inner_clone = inner.clone(); + + let registry = display + .get_registry(|registry| { + registry.implement( + move |msg, proxy| { + let mut inner = inner.lock().unwrap(); + let inner = &mut *inner; + match msg { + wl_registry::Event::Global { + name, + interface, + version, + } => { + inner.list.push((name, interface.clone(), version)); + (inner.callback)( + GlobalEvent::New { + id: name, + interface: interface, + version: version, + }, + proxy, + ); + } + wl_registry::Event::GlobalRemove { name } => { + if let Some((i, _)) = + inner.list.iter().enumerate().find(|&(_, &(n, _, _))| n == name) + { + let (id, interface, _) = inner.list.swap_remove(i); + (inner.callback)( + GlobalEvent::Removed { + id: id, + interface: interface, + }, + proxy, + ); + } else { + panic!( + "Wayland protocol error: the server removed non-existing global \"{}\".", + name + ); + } + } + } + }, + (), + ) + }) + .expect("Attempted to create a GlobalManager from a dead display."); + + GlobalManager { + inner: inner_clone, + registry: registry, + } + } + + /// Instantiate a global with highest available version + /// + /// This method is only appropriate for globals that are expected to + /// not exist with multiplicity (such as `wl_compositor` or `wl_shm`), + /// as it will only bind a single one. + pub fn instantiate_auto<I: Interface, F>(&self, implementor: F) -> Result<Proxy<I>, GlobalError> + where + F: FnOnce(NewProxy<I>) -> Proxy<I>, + { + let inner = self.inner.lock().unwrap(); + for &(id, ref interface, version) in &inner.list { + if interface == I::NAME { + return Ok(self.registry.bind(version, id, implementor).unwrap()); + } + } + Err(GlobalError::Missing) + } + + /// Instantiate a global with a specific version + /// + /// Like `instantiate_auto`, but will bind a specific version of + /// this global an not the highest available. + pub fn instantiate_exact<I: Interface, F>( + &self, + version: u32, + implementor: F, + ) -> Result<Proxy<I>, GlobalError> + where + F: FnOnce(NewProxy<I>) -> Proxy<I>, + { + let inner = self.inner.lock().unwrap(); + for &(id, ref interface, server_version) in &inner.list { + if interface == I::NAME { + if version > server_version { + return Err(GlobalError::VersionTooLow(server_version)); + } else { + return Ok(self.registry.bind(version, id, implementor).unwrap()); + } + } + } + Err(GlobalError::Missing) + } + + /// Retrieve the list of currently known globals + pub fn list(&self) -> Vec<(u32, String, u32)> { + self.inner.lock().unwrap().list.clone() + } +} + +/// A trait for implementation of the global advertisement +/// +/// It is automatically implemented for `FnMut(NewProxy<I>) -> Proxy<I>` +/// closures, in which case the `error` messages are ignored. +pub trait GlobalImplementor<I: Interface> { + /// A new global of given interface has been instantiated and you are + /// supposed to provide an implementation for it. + fn new_global(&mut self, global: NewProxy<I>) -> Proxy<I>; + /// A global was advertised but its version was lower than the minimal version + /// you requested. + /// + /// The advertised version is provided as argument. + fn error(&mut self, _version: u32) {} +} + +impl<F, I: Interface> GlobalImplementor<I> for F +where + F: FnMut(NewProxy<I>) -> Proxy<I>, +{ + fn new_global(&mut self, global: NewProxy<I>) -> Proxy<I> { + (*self)(global) + } +} + +/// Convenience macro to create a `GlobalManager` callback +/// +/// This macro aims to simplify the specific but common case of +/// providing a callback to the `GlobalManager` that needs to +/// auto-bind all advertised instances of some specific globals +/// whenever they happen. Typically, your application will likely +/// want to keep track of all `wl_seat` and `wl_output` globals +/// to be able to correctly react to user input and their different +/// monitors. +/// +/// The output of this macro is a closure, that can be given to +/// `GlobalManager::new_with_cb` as the callback argument. +/// +/// Example use is typically: +/// +/// ```no_run +/// # #[macro_use] extern crate wayland_client; +/// use wayland_client::GlobalManager; +/// # use wayland_client::{Display, NewProxy, Proxy}; +/// use wayland_client::protocol::{wl_output, wl_seat}; +/// +/// # fn main() { +/// # let (display, mut event_queue) = Display::connect_to_env().unwrap(); +/// # let seat_implementor: fn(NewProxy<_>) -> Proxy<_> = unimplemented!(); +/// # let output_implementor: fn(NewProxy<_>) -> Proxy<_> = unimplemented!(); +/// let globals = GlobalManager::new_with_cb( +/// &display, +/// global_filter!( +/// // Bind all wl_seat with version 4 +/// [wl_seat::WlSeat, 4, seat_implementor], +/// // Bind all wl_output with version 1 +/// [wl_output::WlOutput, 1, output_implementor] +/// ) +/// ); +/// # } +/// ``` +/// +/// The supplied callbacks for each global kind must be an instance of a type +/// implementing the `GlobalImplementor<I>` trait. The argument provided to your +/// callback is a `NewProxy` of the newly instantiated global, and you should implement +/// it and return the implemented proxy. The error case happens if the server advertised +/// a lower version of the global than the one you requested, in which case you are given +/// the version it advertised in the error method, if you want to handle it graciously. +/// +/// As with all implementations, you can also provide closures for the various +/// callbacks, in this case the errors will be ignored. However, due to a lack of +/// capability of rustc's inference, you'll likely need to add some type annotation +/// to your closure, typically something like +/// +/// ```ignore +/// global_filter!( +/// [Interface, version, |new_proxy: NewProxy<_>| { +/// ... +/// }] +/// ); +/// ``` +#[macro_export] +macro_rules! global_filter { + ($([$interface:ty, $version:expr, $callback:expr]),*) => { + { + use $crate::protocol::wl_registry::{self, RequestsTrait}; + use $crate::{Proxy, GlobalEvent, NewProxy, Interface, GlobalImplementor}; + type Callback = Box<FnMut(u32, u32, Proxy<wl_registry::WlRegistry>) + Send>; + let mut callbacks: Vec<(&'static str, Callback)> = Vec::new(); + // Create the callback list + $({ + let mut cb = { $callback }; + callbacks.push(( + <$interface as Interface>::NAME, + Box::new(move |id, version, registry: Proxy<wl_registry::WlRegistry>| { + if version < $version { + GlobalImplementor::<$interface>::error(&mut cb, version); + } else { + registry.bind::<$interface, _>( + version, + id, + |newp| GlobalImplementor::<$interface>::new_global(&mut cb, newp) + ); + } + }) as Box<_> + )); + })* + + // return the global closure + move |event: GlobalEvent, registry: Proxy<wl_registry::WlRegistry>| { + if let GlobalEvent::New { id, interface, version } = event { + for &mut (iface, ref mut cb) in &mut callbacks { + if iface == interface { + cb(id, version, registry); + break; + } + } + } + } + } + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/lib.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/lib.rs new file mode 100644 index 0000000..ce6eca0 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/lib.rs @@ -0,0 +1,282 @@ +//! Client-side Wayland connector +//! +//! ## Overview +//! +//! This crate provides the interfaces and machinery to safely create +//! client applications for the wayland protocol. It is a rust wrapper +//! around the `libwayland-client.so` C library. +//! +//! The wayland protocol revolves around the creation of various objects +//! and the exchange of messages associated to these objects. The initial +//! object is always the `Display`, that you get at initialization of the +//! connection, exposed by this crate as `Display::connect_to_env()`. +//! +//! ## Protocol and messages handling model +//! +//! The protocol being bi-directional, you can send and receive messages. +//! Sending messages is done via methods of `Proxy<_>` objects, receiving +//! and handling them is done by providing implementations. +//! +//! ### Proxies +//! +//! Wayland protocol objects are represented in this crate by `Proxy<I>` +//! objects, where `I` is a type representing the interface of the considered +//! object. And object's interface (think "class" in an object-oriented context) +//! defines which messages it can send and receive. +//! +//! These proxies are used to send messages to the server (in the wayland context, +//! these are called "requests"). To do so, you need to import the appropriate +//! extension trait adding these methods. For example, to use a `Proxy<WlSurface>`, +//! you need to import `protocol::wl_surface::RequestsTrait` from this crate. +//! It is also possible to directly use the `Proxy::<I>::send(..)` method, but +//! this should only be done carefully: using it improperly can mess the protocol +//! state and cause protocol errors, which are fatal to the connection (the server +//! will kill you). +//! +//! There is not a 1 to 1 mapping between `Proxy<I>` instances and protocol +//! objects. Rather, you can think of `Proxy<I>` as an `Rc`-like handle to a +//! wayland object. Multiple instances of it can exist referring to the same +//! protocol object. +//! +//! Similarly, the lifetimes of the protocol objects and the `Proxy<I>` are +//! not tightly tied. As protocol objects are created and destroyed by protocol +//! messages, it can happen that an object gets destroyed while one or more +//! `Proxy<I>` still refers to it. In such case, these proxies will be disabled +//! and their `alive()` method will start to return `false`. Trying to send messages +//! with them will also fail. +//! +//! ### Implementations +//! +//! To receive and process messages from the server to you (in wayland context they are +//! called "events"), you need to provide an `Implementation` for each wayland object +//! created in the protocol session. Whenever a new protocol object is created, you will +//! receive a `NewProxy<I>` object. Providing an implementation via its `implement()` method +//! will turn it into a regular `Proxy<I>` object. +//! +//! **All objects must be implemented**, even if it is an implementation doing nothing. +//! Failure to do so (by dropping the `NewProxy<I>` for example) can cause future fatal +//! errors if the server tries to send an event to this object. +//! +//! An implementation is just an `FnMut(I::Event, Proxy<I>), where `I` is the interface of +//! the considered object. +//! +//! ## Event Queues +//! +//! The wayland client machinery provides the possibility to have one or more event queues +//! handling the processing of received messages. All wayland objects are associated to an +//! event queue, which controls when its events are dispatched. +//! +//! Events received from the server are stored in an internal buffer, and processed (by calling +//! the appropriate implementations) when the associated event queue is dispatched. +//! +//! A default event queue is created at the same time as the initial `Display`, and by default +//! whenever a wayland object is created, it inherits the queue of its parent (the object that sent +//! or receive the message that created the new object). It means that if you only plan to use the +//! default event queue, you don't need to worry about assigning objects to their queues. +//! +//! See the documentation of `EventQueue` for details about dispatching and integrating the event +//! queue into the event loop of your application. See the `Proxy::make_wrapper()` method for +//! details about assigning objects to event queues. +//! +//! ## Dynamic linking with `libwayland-client.so` +//! +//! If you need to gracefully handle the case of a system on which wayland is not installed (by +//! fallbacking to X11 for example), you can do so by activating the `dlopen` cargo feature. +//! +//! When this is done, the library will be loaded a runtime rather than directly linked. And trying +//! to create a `Display` on a system that does not have this library will return a `NoWaylandLib` +//! error. +//! +//! ## Auxiliary libraries +//! +//! Two auxiliary libraries are also available behind cargo features: +//! +//! - the `cursor` feature will try to load `libwayland-cursor.so`, a library helping with loading +//! system themed cursor textures, to integrate your app in the system theme. +//! - the `egl` feature will try to load `libwayland-egl.so`, a library allowing the creation of +//! OpenGL surface from wayland surfaces. +//! +//! Both of them will also be loaded at runtime if the `dlopen` feature was provided. See their +//! respective submodules for details about their use. +//! +//! ### Event Loop integration +//! +//! The `eventloop` cargo feature adds the necessary implementations to use an `EventQueue` +//! as a `calloop` event source. If you want to use it, here are a few points to take into +//! account: +//! +//! - The `EventQueue` will not call its associated callback, but rather manage all the +//! event dispatching internally. As a result, there is no point registering it to +//! `calloop` with anything other than a dummy callback. +//! - You still need to call `Display::flush()` yourself between `calloop`s dispatches, +//! or in the `EventLoop::run()` callback of `calloop`. + +#![warn(missing_docs)] + +#[macro_use] +extern crate bitflags; +#[cfg(not(feature = "native_lib"))] +#[macro_use] +extern crate downcast_rs as downcast; +extern crate libc; +extern crate nix; + +#[cfg(feature = "eventloop")] +extern crate calloop; +#[cfg(feature = "eventloop")] +extern crate mio; + +extern crate wayland_commons; +#[cfg(feature = "native_lib")] +#[macro_use] +extern crate wayland_sys; + +mod display; +mod event_queue; +mod globals; +mod proxy; + +pub use display::{ConnectError, Display}; +pub use event_queue::{EventQueue, QueueToken, ReadEventsGuard}; +pub use globals::{GlobalError, GlobalEvent, GlobalImplementor, GlobalManager}; +pub use imp::ProxyMap; +pub use proxy::{NewProxy, Proxy}; + +#[cfg(feature = "cursor")] +pub mod cursor; + +#[cfg(feature = "egl")] +pub mod egl; + +pub use wayland_commons::{AnonymousObject, Interface, MessageGroup, NoMessage}; + +// rust implementation +#[cfg(not(feature = "native_lib"))] +#[path = "rust_imp/mod.rs"] +mod imp; +// C-lib based implementation +#[cfg(feature = "native_lib")] +#[path = "native_lib/mod.rs"] +mod imp; + +#[cfg(feature = "native_lib")] +/// C-associated types +/// +/// Required for plugging wayland-scanner generated protocols +/// or interfacing with C code using wayland objects. +pub mod sys { + pub use super::generated::c_interfaces as protocol_interfaces; + pub use wayland_sys::{client, common}; +} + +/// Generated interfaces for the core wayland protocol +pub mod protocol { + #[cfg(feature = "native_lib")] + pub use generated::c_api::*; + #[cfg(not(feature = "native_lib"))] + pub use generated::rust_api::*; +} + +mod generated { + #![allow(dead_code, non_camel_case_types, unused_unsafe, unused_variables)] + #![allow(non_upper_case_globals, non_snake_case, unused_imports)] + #![allow(missing_docs)] + + #[cfg(feature = "native_lib")] + pub mod c_interfaces { + include!(concat!(env!("OUT_DIR"), "/wayland_c_interfaces.rs")); + } + #[cfg(feature = "native_lib")] + pub mod c_api { + pub(crate) use wayland_commons::map::{Object, ObjectMetadata}; + pub(crate) use wayland_commons::wire::{Argument, ArgumentType, Message, MessageDesc}; + pub(crate) use wayland_commons::{AnonymousObject, Interface, MessageGroup}; + pub(crate) use wayland_sys as sys; + pub(crate) use {NewProxy, Proxy, ProxyMap}; + include!(concat!(env!("OUT_DIR"), "/wayland_c_api.rs")); + } + #[cfg(not(feature = "native_lib"))] + pub mod rust_api { + pub(crate) use wayland_commons::map::{Object, ObjectMetadata}; + pub(crate) use wayland_commons::wire::{Argument, ArgumentType, Message, MessageDesc}; + pub(crate) use wayland_commons::{AnonymousObject, Interface, MessageGroup}; + pub(crate) use {NewProxy, Proxy, ProxyMap}; + include!(concat!(env!("OUT_DIR"), "/wayland_rust_api.rs")); + } +} + +#[cfg(feature = "eventloop")] +impl ::mio::event::Evented for EventQueue { + fn register( + &self, + poll: &::mio::Poll, + token: ::mio::Token, + interest: ::mio::Ready, + opts: ::mio::PollOpt, + ) -> ::std::io::Result<()> { + let fd = self.inner.get_connection_fd(); + ::mio::unix::EventedFd(&fd).register(poll, token, interest, opts) + } + + fn reregister( + &self, + poll: &::mio::Poll, + token: ::mio::Token, + interest: ::mio::Ready, + opts: ::mio::PollOpt, + ) -> ::std::io::Result<()> { + let fd = self.inner.get_connection_fd(); + ::mio::unix::EventedFd(&fd).reregister(poll, token, interest, opts) + } + + fn deregister(&self, poll: &::mio::Poll) -> ::std::io::Result<()> { + let fd = self.inner.get_connection_fd(); + ::mio::unix::EventedFd(&fd).deregister(poll) + } +} + +#[cfg(feature = "eventloop")] +impl ::calloop::EventSource for EventQueue { + type Event = (); + + fn interest(&self) -> ::mio::Ready { + ::mio::Ready::readable() + } + + fn pollopts(&self) -> ::mio::PollOpt { + ::mio::PollOpt::edge() + } + + fn make_dispatcher<Data: 'static, F: FnMut((), &mut Data) + 'static>( + &self, + _callback: F, + ) -> ::std::rc::Rc<::std::cell::RefCell<::calloop::EventDispatcher<Data>>> { + struct Dispatcher { + inner: ::std::rc::Rc<::imp::EventQueueInner>, + } + + impl<Data> ::calloop::EventDispatcher<Data> for Dispatcher { + fn ready(&mut self, _ready: ::mio::Ready, _data: &mut Data) { + if let Err(()) = self.inner.prepare_read() { + self.inner.dispatch_pending().unwrap(); + } else { + match self.inner.read_events() { + Ok(_) => { + self.inner.dispatch_pending().unwrap(); + } + Err(e) => match e.kind() { + ::std::io::ErrorKind::WouldBlock => {} + _ => { + panic!("Failed to read from wayland socket: {}", e); + } + }, + } + } + } + } + + ::std::rc::Rc::new(::std::cell::RefCell::new(Dispatcher { + inner: self.inner.clone(), + })) + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/display.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/display.rs new file mode 100644 index 0000000..e64ec0f --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/display.rs @@ -0,0 +1,103 @@ +use std::io; +use std::os::unix::io::RawFd; +use std::sync::Arc; + +use protocol::wl_display::WlDisplay; +use wayland_sys::client::*; + +use {ConnectError, Proxy}; + +use super::EventQueueInner; + +pub(crate) struct DisplayInner { + proxy: Proxy<WlDisplay>, + display: *mut wl_display, +} + +unsafe impl Send for DisplayInner {} +unsafe impl Sync for DisplayInner {} + +unsafe fn make_display(ptr: *mut wl_display) -> Result<(Arc<DisplayInner>, EventQueueInner), ConnectError> { + if ptr.is_null() { + return Err(ConnectError::NoCompositorListening); + } + + let display = Arc::new(DisplayInner { + proxy: Proxy::from_c_ptr(ptr as *mut _), + display: ptr, + }); + + let evq = EventQueueInner::new(display.clone(), None); + + Ok((display, evq)) +} + +impl DisplayInner { + pub unsafe fn from_fd(fd: RawFd) -> Result<(Arc<DisplayInner>, EventQueueInner), ConnectError> { + if !::wayland_sys::client::is_lib_available() { + return Err(ConnectError::NoWaylandLib); + } + + let display_ptr = ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_connect_to_fd, fd); + + make_display(display_ptr) + } + + pub(crate) fn ptr(&self) -> *mut wl_display { + self.display + } + + pub(crate) fn flush(&self) -> io::Result<()> { + let ret = unsafe { ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_flush, self.ptr()) }; + if ret >= 0 { + Ok(()) + } else { + Err(io::Error::last_os_error()) + } + } + + pub(crate) fn create_event_queue(me: &Arc<DisplayInner>) -> EventQueueInner { + unsafe { + let ptr = ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_create_queue, me.ptr()); + EventQueueInner::new(me.clone(), Some(ptr)) + } + } + + pub(crate) fn get_proxy(&self) -> &Proxy<WlDisplay> { + &self.proxy + } + + pub(crate) unsafe fn from_external(display_ptr: *mut wl_display) -> (Arc<DisplayInner>, EventQueueInner) { + let evq_ptr = ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_create_queue, display_ptr); + + let wrapper_ptr = ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_proxy_create_wrapper, + display_ptr as *mut _ + ); + ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_set_queue, wrapper_ptr, evq_ptr); + + let display = Arc::new(DisplayInner { + proxy: Proxy::from_c_display_wrapper(wrapper_ptr), + display: display_ptr, + }); + + let evq = EventQueueInner::new(display.clone(), Some(evq_ptr)); + (display, evq) + } +} + +impl Drop for DisplayInner { + fn drop(&mut self) { + if self.proxy.c_ptr() == (self.display as *mut _) { + // disconnect only if we are owning this display + unsafe { + ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_display_disconnect, + self.proxy.c_ptr() as *mut wl_display + ); + } + } + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/event_queue.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/event_queue.rs new file mode 100644 index 0000000..b36a4cd --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/event_queue.rs @@ -0,0 +1,137 @@ +use std::io; +use std::ptr; +use std::sync::Arc; + +use wayland_sys::client::*; + +use super::DisplayInner; + +pub(crate) struct EventQueueInner { + wlevq: Option<*mut wl_event_queue>, + inner: Arc<super::DisplayInner>, +} + +impl EventQueueInner { + pub(crate) fn new(inner: Arc<DisplayInner>, wlevq: Option<*mut wl_event_queue>) -> EventQueueInner { + EventQueueInner { inner, wlevq } + } + + #[cfg(feature = "eventloop")] + pub(crate) fn get_connection_fd(&self) -> ::std::os::unix::io::RawFd { + unsafe { ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_get_fd, self.inner.ptr()) } + } + + pub fn dispatch(&self) -> io::Result<u32> { + let ret = match self.wlevq { + Some(evq) => unsafe { + ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_display_dispatch_queue, + self.inner.ptr(), + evq + ) + }, + None => unsafe { ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_dispatch, self.inner.ptr()) }, + }; + if ret >= 0 { + Ok(ret as u32) + } else { + Err(io::Error::last_os_error()) + } + } + + pub fn dispatch_pending(&self) -> io::Result<u32> { + let ret = match self.wlevq { + Some(evq) => unsafe { + ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_display_dispatch_queue_pending, + self.inner.ptr(), + evq + ) + }, + None => unsafe { + ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_display_dispatch_pending, + self.inner.ptr() + ) + }, + }; + if ret >= 0 { + Ok(ret as u32) + } else { + Err(io::Error::last_os_error()) + } + } + + pub fn sync_roundtrip(&self) -> io::Result<u32> { + let ret = unsafe { + match self.wlevq { + Some(evtq) => ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_display_roundtrip_queue, + self.inner.ptr(), + evtq + ), + None => ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_roundtrip, self.inner.ptr()), + } + }; + if ret >= 0 { + Ok(ret as u32) + } else { + Err(io::Error::last_os_error()) + } + } + + pub(crate) fn prepare_read(&self) -> Result<(), ()> { + let ret = unsafe { + match self.wlevq { + Some(evtq) => ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_display_prepare_read_queue, + self.inner.ptr(), + evtq + ), + None => ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_prepare_read, self.inner.ptr()), + } + }; + if ret >= 0 { + Ok(()) + } else { + Err(()) + } + } + + pub(crate) fn read_events(&self) -> io::Result<i32> { + let ret = unsafe { ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_read_events, self.inner.ptr()) }; + if ret >= 0 { + Ok(ret) + } else { + Err(io::Error::last_os_error()) + } + } + + pub(crate) fn cancel_read(&self) { + unsafe { ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_cancel_read, self.inner.ptr()) } + } + + pub(crate) unsafe fn assign_proxy(&self, proxy: *mut wl_proxy) { + ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_proxy_set_queue, + proxy, + self.wlevq.unwrap_or(ptr::null_mut()) + ) + } +} + +impl Drop for EventQueueInner { + fn drop(&mut self) { + if let Some(evq) = self.wlevq { + unsafe { + ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_event_queue_destroy, evq); + } + } + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/mod.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/mod.rs new file mode 100644 index 0000000..77e6172 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/mod.rs @@ -0,0 +1,27 @@ +mod display; +mod event_queue; +mod proxy; + +pub(crate) use self::display::DisplayInner; +pub(crate) use self::event_queue::EventQueueInner; +pub(crate) use self::proxy::{NewProxyInner, ProxyInner}; + +use {Interface, NewProxy, Proxy}; + +/// This type only exists for type-level compatibility +/// with the rust implementation. +/// +/// It is an empty enum that cannot be instantiated +pub enum ProxyMap {} + +impl ProxyMap { + /// Unusable method only existing for type-level compatibility + pub fn get<I: Interface>(&mut self, _: u32) -> Option<Proxy<I>> { + match *self {} + } + + /// Unusable method only existing for type-level compatibility + pub fn get_new<I: Interface>(&mut self, _: u32) -> Option<NewProxy<I>> { + match *self {} + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/proxy.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/proxy.rs new file mode 100644 index 0000000..fdf5e12 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/native_lib/proxy.rs @@ -0,0 +1,372 @@ +use std::os::raw::{c_int, c_void}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; + +use wayland_commons::utils::UserData; +use wayland_commons::wire::ArgumentType; +use wayland_commons::MessageGroup; +use {Interface, Proxy}; + +use super::EventQueueInner; + +use wayland_sys::client::*; +use wayland_sys::common::*; + +pub struct ProxyInternal { + alive: AtomicBool, + user_data: UserData, +} + +impl ProxyInternal { + pub fn new(user_data: UserData) -> ProxyInternal { + ProxyInternal { + alive: AtomicBool::new(true), + user_data, + } + } +} + +#[derive(Clone)] +pub(crate) struct ProxyInner { + internal: Option<Arc<ProxyInternal>>, + ptr: *mut wl_proxy, + is_wrapper: bool, +} + +unsafe impl Send for ProxyInner {} +unsafe impl Sync for ProxyInner {} + +impl ProxyInner { + pub(crate) fn is_alive(&self) -> bool { + self.internal + .as_ref() + .map(|i| i.alive.load(Ordering::Acquire)) + .unwrap_or(true) + } + + pub(crate) fn is_external(&self) -> bool { + self.internal.is_none() + } + + pub(crate) fn version(&self) -> u32 { + if !self.is_alive() { + return 0; + } + unsafe { ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_get_version, self.ptr) as u32 } + } + + pub(crate) fn id(&self) -> u32 { + if !self.is_alive() { + return 0; + } + unsafe { ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_get_id, self.ptr) } + } + + pub(crate) fn get_user_data<UD: 'static>(&self) -> Option<&UD> { + if let Some(ref inner) = self.internal { + inner.user_data.get::<UD>() + } else { + None + } + } + + pub(crate) fn send<I: Interface>(&self, msg: I::Request) { + if let Some(ref internal) = self.internal { + // object is managed + if !internal.alive.load(Ordering::Acquire) { + // don't send message to dead objects ! + return; + } + } + let destructor = msg.is_destructor(); + msg.as_raw_c_in(|opcode, args| unsafe { + ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_proxy_marshal_array, + self.ptr, + opcode, + args.as_ptr() as *mut _ + ); + }); + + if destructor { + // we need to destroy the proxy now + if let Some(ref internal) = self.internal { + internal.alive.store(false, Ordering::Release); + } + unsafe { + ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_destroy, self.ptr); + } + } + } + + pub(crate) fn send_constructor<I, J>( + &self, + msg: I::Request, + version: Option<u32>, + ) -> Result<NewProxyInner, ()> + where + I: Interface, + J: Interface, + { + if let Some(ref internal) = self.internal { + // object is managed + if !internal.alive.load(Ordering::Acquire) { + // don't send message to dead objects ! + return Err(()); + } + } + let destructor = msg.is_destructor(); + + let opcode = msg.opcode(); + + // sanity check + let mut nid_idx = I::Request::MESSAGES[opcode as usize] + .signature + .iter() + .position(|&t| t == ArgumentType::NewId) + .expect("Trying to use 'send_constructor' with a message not creating any object."); + + if let Some(o) = I::Request::child(opcode, 1, &()) { + if !o.is_interface::<J>() { + panic!("Trying to use 'send_constructor' with the wrong return type. Required interface {} but the message creates interface {}") + } + } else { + // there is no target interface in the protocol, this is a generic object-creating + // function (likely wl_registry.bind), the newid arg will thus expand to (str, u32, obj) + nid_idx += 2; + } + + let version = version.unwrap_or_else(|| self.version()); + + let ptr = msg.as_raw_c_in(|opcode, args| unsafe { + assert!( + args[nid_idx].o.is_null(), + "Trying to use 'send_constructor' with a non-placeholder object." + ); + ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_proxy_marshal_array_constructor_versioned, + self.ptr, + opcode, + args.as_mut_ptr(), + J::c_interface(), + version + ) + }); + + if destructor { + // we need to destroy the proxy now + if let Some(ref internal) = self.internal { + internal.alive.store(false, Ordering::Release); + } + unsafe { + ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_destroy, self.ptr); + } + } + + Ok(unsafe { NewProxyInner::from_c_ptr(ptr) }) + } + + pub(crate) fn equals(&self, other: &ProxyInner) -> bool { + if !self.is_alive() { + return false; + } + match (&self.internal, &other.internal) { + (&Some(ref my_inner), &Some(ref other_inner)) => Arc::ptr_eq(my_inner, other_inner), + (&None, &None) => self.ptr == other.ptr, + _ => false, + } + } + + pub(crate) fn make_wrapper(&self, queue: &EventQueueInner) -> Result<ProxyInner, ()> { + if !self.is_external() && !self.is_alive() { + return Err(()); + } + + let wrapper_ptr; + unsafe { + wrapper_ptr = ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_create_wrapper, self.ptr); + queue.assign_proxy(wrapper_ptr); + } + + Ok(ProxyInner { + internal: self.internal.clone(), + ptr: wrapper_ptr, + is_wrapper: true, + }) + } + + pub(crate) fn child<I: Interface>(&self) -> NewProxyInner { + let ptr = + unsafe { ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_create, self.ptr, I::c_interface()) }; + NewProxyInner { ptr: ptr } + } + + pub(crate) fn c_ptr(&self) -> *mut wl_proxy { + self.ptr + } + + pub(crate) unsafe fn from_c_ptr<I: Interface>(ptr: *mut wl_proxy) -> Self { + if ptr.is_null() { + return ProxyInner { + internal: Some(Arc::new(ProxyInternal { + alive: AtomicBool::new(false), + user_data: UserData::empty(), + })), + ptr: ptr, + is_wrapper: false, + }; + } + + let is_managed = { + ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_get_listener, ptr) + == &::wayland_sys::RUST_MANAGED as *const u8 as *const _ + }; + let internal = if is_managed { + let user_data = + ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_get_user_data, ptr) as *mut ProxyUserData<I>; + Some((*user_data).internal.clone()) + } else { + None + }; + ProxyInner { + internal: internal, + ptr: ptr, + is_wrapper: false, + } + } + + pub(crate) unsafe fn from_c_display_wrapper(d: *mut wl_proxy) -> ProxyInner { + ProxyInner { + internal: None, + ptr: d, + is_wrapper: true, + } + } + + pub(crate) fn child_placeholder(&self) -> ProxyInner { + ProxyInner { + internal: Some(Arc::new(ProxyInternal { + alive: AtomicBool::new(false), + user_data: UserData::empty(), + })), + ptr: ::std::ptr::null_mut(), + is_wrapper: false, + } + } +} + +pub(crate) struct NewProxyInner { + ptr: *mut wl_proxy, +} + +impl NewProxyInner { + pub(crate) unsafe fn implement<I: Interface, F>( + self, + implementation: F, + user_data: UserData, + ) -> ProxyInner + where + F: FnMut(I::Event, Proxy<I>) + 'static, + { + let new_user_data = Box::new(ProxyUserData::new(implementation, user_data)); + let internal = new_user_data.internal.clone(); + + ffi_dispatch!( + WAYLAND_CLIENT_HANDLE, + wl_proxy_add_dispatcher, + self.ptr, + proxy_dispatcher::<I>, + &::wayland_sys::RUST_MANAGED as *const _ as *const _, + Box::into_raw(new_user_data) as *mut _ + ); + + ProxyInner { + internal: Some(internal), + ptr: self.ptr, + is_wrapper: false, + } + } + + pub(crate) fn c_ptr(&self) -> *mut wl_proxy { + self.ptr + } + + pub(crate) unsafe fn from_c_ptr(ptr: *mut wl_proxy) -> NewProxyInner { + NewProxyInner { ptr: ptr } + } +} + +struct ProxyUserData<I: Interface> { + internal: Arc<ProxyInternal>, + implem: Option<Box<FnMut(I::Event, Proxy<I>)>>, +} + +impl<I: Interface> ProxyUserData<I> { + fn new<F>(implem: F, user_data: UserData) -> ProxyUserData<I> + where + F: FnMut(I::Event, Proxy<I>) + 'static, + { + ProxyUserData { + internal: Arc::new(ProxyInternal::new(user_data)), + implem: Some(Box::new(implem)), + } + } +} + +unsafe extern "C" fn proxy_dispatcher<I: Interface>( + _implem: *const c_void, + proxy: *mut c_void, + opcode: u32, + _msg: *const wl_message, + args: *const wl_argument, +) -> c_int +where + I: Interface, +{ + let proxy = proxy as *mut wl_proxy; + + // We don't need to worry about panic-safeness, because if there is a panic, + // we'll abort the process, so no access to corrupted data is possible. + let ret = ::std::panic::catch_unwind(move || { + // parse the message: + let msg = I::Event::from_raw_c(proxy as *mut _, opcode, args)?; + let must_destroy = msg.is_destructor(); + // create the proxy object + let proxy_obj = ::Proxy::<I>::from_c_ptr(proxy); + // retrieve the impl + let user_data = ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_get_user_data, proxy); + { + let user_data = &mut *(user_data as *mut ProxyUserData<I>); + let implem = user_data.implem.as_mut().unwrap(); + if must_destroy { + user_data.internal.alive.store(false, Ordering::Release); + ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_destroy, proxy); + } + // call the impl + implem(msg, proxy_obj); + } + if must_destroy { + // final cleanup + let _ = Box::from_raw(user_data as *mut ProxyUserData<I>); + } + Ok(()) + }); + // check the return status + match ret { + Ok(Ok(())) => return 0, + Ok(Err(())) => { + eprintln!( + "[wayland-client error] Attempted to dispatch unknown opcode {} for {}, aborting.", + opcode, + I::NAME + ); + ::libc::abort(); + } + Err(_) => { + eprintln!("[wayland-client error] A handler for {} panicked.", I::NAME); + ::libc::abort() + } + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/proxy.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/proxy.rs new file mode 100644 index 0000000..1534d47 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/proxy.rs @@ -0,0 +1,361 @@ +use wayland_commons::utils::UserData; +use wayland_commons::{AnonymousObject, Interface}; + +#[cfg(feature = "native_lib")] +use wayland_sys::client::*; + +use event_queue::QueueToken; + +use imp::{NewProxyInner, ProxyInner}; + +use wayland_commons::MessageGroup; +use ProxyMap; + +/// An handle to a wayland proxy +/// +/// This represents a wayland object instantiated in your client +/// session. Several handles to the same object can exist at a given +/// time, and cloning them won't create a new protocol object, only +/// clone the handle. The lifetime of the protocol object is **not** +/// tied to the lifetime of these handles, but rather to sending or +/// receiving destroying messages. +/// +/// These handles are notably used to send requests to the server. To do +/// you need to import the associated `RequestsTrait` trait from the module +/// of this interface. +pub struct Proxy<I: Interface> { + _i: ::std::marker::PhantomData<&'static I>, + pub(crate) inner: ProxyInner, +} + +impl<I: Interface> Clone for Proxy<I> { + fn clone(&self) -> Proxy<I> { + Proxy { + _i: ::std::marker::PhantomData, + inner: self.inner.clone(), + } + } +} + +impl<I: Interface> PartialEq for Proxy<I> { + fn eq(&self, other: &Proxy<I>) -> bool { + self.equals(other) + } +} + +impl<I: Interface> Eq for Proxy<I> {} + +impl<I: Interface> Proxy<I> { + pub(crate) fn wrap(inner: ProxyInner) -> Proxy<I> { + Proxy { + _i: ::std::marker::PhantomData, + inner, + } + } + + /// Send a request through this object + /// + /// **Warning:** This method is mostly intended to be used by code generated + /// by `wayland-scanner`, and you should probably never need to use it directly, + /// but rather use the appropriate `RequestsTrait` for your proxy. + /// + /// This is the generic method to send requests. + /// + /// If your request needs to create an object, use `send_constructor`. + pub fn send(&self, msg: I::Request) { + self.inner.send::<I>(msg) + } + + /// Send a request creating an object through this object + /// + /// **Warning:** This method is mostly intended to be used by code generated + /// by `wayland-scanner`, and you should probably never need to use it directly, + /// but rather use the appropriate `RequestsTrait` for your proxy. + /// + /// This is the generic method to send requests that create objects + /// + /// The slot in the message corresponding with the newly created object must have + /// been filled by a placeholder object (see `child_placeholder`). + pub fn send_constructor<J, F>( + &self, + msg: I::Request, + implementor: F, + version: Option<u32>, + ) -> Result<Proxy<J>, ()> + where + J: Interface, + F: FnOnce(NewProxy<J>) -> Proxy<J>, + { + self.inner + .send_constructor::<I, J>(msg, version) + .map(NewProxy::wrap) + .map(implementor) + } + + /// Check if the object associated with this proxy is still alive + /// + /// Will return `false` if the object has been destroyed. + /// + /// If the object is not managed by this library, this will always + /// returns `true`. + pub fn is_alive(&self) -> bool { + self.inner.is_alive() + } + + /// Retrieve the interface version of this wayland object instance + /// + /// Returns 0 on dead objects + pub fn version(&self) -> u32 { + self.inner.version() + } + + /// Retrieve the object id of this wayland object + pub fn id(&self) -> u32 { + self.inner.id() + } + + /// Access the arbitrary payload associated to this object + /// + /// You need to specify the expected type of this payload, and this + /// function will return `None` if either the types don't match or + /// you are attempting to access a non `Send + Sync` user data from the + /// wrong thread. + /// + /// This value is associated to the Proxy when you implement it, and you + /// cannot access it mutably afterwards. If you need interior mutability, + /// you are responsible for using a `Mutex` or similar type to achieve it. + pub fn user_data<UD: 'static>(&self) -> Option<&UD> { + self.inner.get_user_data() + } + + /// Check if the other proxy refers to the same underlying wayland object + pub fn equals(&self, other: &Proxy<I>) -> bool { + self.inner.equals(&other.inner) + } + + /// Create a new child object + /// + /// **Warning:** This method is mostly intended to be used by code generated + /// by `wayland-scanner`, and you should probably never need to use it directly, + /// but rather use the appropriate `RequestsTrait` for your proxy. + /// + /// This creates a new wayland object, considered as a + /// child of this object. It will notably inherit its interface + /// version. + /// + /// The created object should immediately be implemented and sent + /// in a request to the server, to keep the object list properly + /// synchronized. Failure to do so will likely cause a protocol + /// error. + pub fn child<C: Interface>(&self) -> NewProxy<C> { + NewProxy { + _i: ::std::marker::PhantomData, + inner: self.inner.child::<C>(), + } + } + + /// Creates a handle of this proxy with its actual type erased + pub fn anonymize(&self) -> Proxy<AnonymousObject> { + Proxy { + _i: ::std::marker::PhantomData, + inner: self.inner.clone(), + } + } + + /// Create a wrapper for this object for queue management + /// + /// As assigning a proxy to an event queue can be a racy operation + /// in contexts involving multiple thread, this provides a facility + /// to do this safely. + /// + /// The wrapper object created behaves like a regular `Proxy`, except that + /// all objects created as the result of its requests will be assigned to + /// the queue associated to the provided token, rather than the queue of + /// their parent. This does not change the queue of the proxy itself. + pub fn make_wrapper(&self, queue: &QueueToken) -> Result<Proxy<I>, ()> { + let inner = self.inner.make_wrapper(&queue.inner)?; + + Ok(Proxy { + _i: ::std::marker::PhantomData, + inner, + }) + } + + /// Create a placeholder object, to be used with `send_constructor` + /// + /// **Warning:** This method is mostly intended to be used by code generated + /// by `wayland-scanner`, and you should probably never need to use it directly, + /// but rather use the appropriate `RequestsTrait` for your proxy. + pub fn child_placeholder<J: Interface>(&self) -> Proxy<J> { + Proxy::wrap(self.inner.child_placeholder()) + } +} + +#[cfg(feature = "native_lib")] +impl<I: Interface> Proxy<I> { + /// Check whether this proxy is managed by the library or not + /// + /// See `from_c_ptr` for details. + pub fn is_external(&self) -> bool { + self.inner.is_external() + } + + /// Get a raw pointer to the underlying wayland object + /// + /// Retrieve a pointer to the object from the `libwayland-client.so` library. + /// You will mostly need it to interface with C libraries needing access + /// to wayland objects (to initialize an opengl context for example). + pub fn c_ptr(&self) -> *mut wl_proxy { + self.inner.c_ptr() + } + + /// Create a `Proxy` instance from a C pointer + /// + /// Create a `Proxy` from a raw pointer to a wayland object from the + /// C library. + /// + /// If the pointer was previously obtained by the `c_ptr()` method, this + /// constructs a new proxy for the same object just like the `clone()` + /// method would have. + /// + /// If the object was created by some other C library you are interfacing + /// with, it will be created in an "unmanaged" state: wayland-client will + /// treat it as foreign, and as such most of the safeties will be absent. + /// Notably the lifetime of the object can't be tracked, so the `alive()` + /// method will always return `false` and you are responsible of not using + /// an object past its destruction (as this would cause a protocol error). + /// You will also be unable to associate any user data pointer to this object. + /// + /// In order to handle protocol races, invoking it with a NULL pointer will + /// create an already-dead object. + pub unsafe fn from_c_ptr(ptr: *mut wl_proxy) -> Proxy<I> { + Proxy { + _i: ::std::marker::PhantomData, + inner: ProxyInner::from_c_ptr::<I>(ptr), + } + } +} + +#[cfg(feature = "native_lib")] +impl Proxy<::protocol::wl_display::WlDisplay> { + pub(crate) unsafe fn from_c_display_wrapper( + ptr: *mut wl_proxy, + ) -> Proxy<::protocol::wl_display::WlDisplay> { + Proxy { + _i: ::std::marker::PhantomData, + inner: ProxyInner::from_c_display_wrapper(ptr), + } + } +} + +/// A newly-created proxy that needs implementation +/// +/// Whenever a new wayland object is created, you will +/// receive it as a `NewProxy`. You then have to provide an +/// implementation for it, in order to process the incoming +/// events it may receive. Once this done you will be able +/// to use it as a regular `Proxy`. +/// +/// Implementations are structs implementing the appropriate +/// variant of the `Implementation` trait. They can also be +/// closures. +pub struct NewProxy<I: Interface> { + _i: ::std::marker::PhantomData<*const I>, + pub(crate) inner: NewProxyInner, +} + +impl<I: Interface + 'static> NewProxy<I> { + #[allow(dead_code)] + pub(crate) fn wrap(inner: NewProxyInner) -> NewProxy<I> { + NewProxy { + _i: ::std::marker::PhantomData, + inner, + } + } + + /// Implement this proxy using given function and implementation data. + pub fn implement<F, UD>(self, implementation: F, user_data: UD) -> Proxy<I> + where + F: FnMut(I::Event, Proxy<I>) + Send + 'static, + UD: Send + Sync + 'static, + I::Event: MessageGroup<Map = ProxyMap>, + { + let inner = unsafe { + self.inner + .implement::<I, _>(implementation, UserData::new_threadsafe(user_data)) + }; + Proxy { + _i: ::std::marker::PhantomData, + inner: inner, + } + } + + /// Implement this proxy using given function and implementation data. + /// + /// This method allows the implementation to not be `Send`, but requires for + /// safety that you provide a token to the event queue this proxy will be implemented + /// on. This method will then ensure that this proxy is registered on this event queue, + /// so that it cannot be dispatched from an other thread. + /// + /// **Unsafety:** + /// + /// This call can be racy if the proxy is not already registered on this event queue and its + /// old queue is being dispatched from an other thread. + /// + /// To ensure safety, see `Proxy::make_wrapper`. + pub unsafe fn implement_nonsend<Impl, UD>( + self, + implementation: Impl, + user_data: UD, + queue: &QueueToken, + ) -> Proxy<I> + where + Impl: FnMut(I::Event, Proxy<I>) + 'static, + UD: 'static, + I::Event: MessageGroup<Map = ProxyMap>, + { + #[cfg(feature = "native_lib")] + { + queue.inner.assign_proxy(self.inner.c_ptr()); + } + #[cfg(not(feature = "native_lib"))] + { + self.inner.assign_queue(&queue.inner); + } + let inner = self + .inner + .implement::<I, _>(implementation, UserData::new(user_data)); + Proxy { + _i: ::std::marker::PhantomData, + inner: inner, + } + } +} + +#[cfg(feature = "native_lib")] +impl<I: Interface + 'static> NewProxy<I> { + /// Get a raw pointer to the underlying wayland object + /// + /// Retrieve a pointer to the object from the `libwayland-client.so` library. + /// You will mostly need it to interface with C libraries needing access + /// to wayland objects (to initialize an opengl context for example). + /// + /// Use this if you need to pass an unimplemented object to the C library + /// you are interfacing with. + pub fn c_ptr(&self) -> *mut wl_proxy { + self.inner.c_ptr() + } + + /// Create a `NewProxy` instance from a C pointer. + /// + /// By doing so, you assert that this wayland object was newly created and + /// can be safely implemented. As implementing it will overwrite any previously + /// associated data or implementation, this can cause weird errors akin to + /// memory corruption if it was not the case. + pub unsafe fn from_c_ptr(ptr: *mut wl_proxy) -> Self { + NewProxy { + _i: ::std::marker::PhantomData, + inner: NewProxyInner::from_c_ptr(ptr), + } + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/connection.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/connection.rs new file mode 100644 index 0000000..049fc29 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/connection.rs @@ -0,0 +1,147 @@ +use std::cell::RefCell; +use std::os::unix::io::{FromRawFd, RawFd}; +use std::sync::{Arc, Mutex}; + +use nix::Result as NixResult; + +use wayland_commons::map::{Object, ObjectMap}; +use wayland_commons::socket::{BufferedSocket, Socket}; +use wayland_commons::wire::{Argument, ArgumentType, Message, MessageParseError}; + +use super::proxy::ObjectMeta; +use super::queues::QueueBuffer; + +#[derive(Clone, Debug)] +pub(crate) enum Error { + Protocol, + Parse(MessageParseError), + Nix(::nix::Error), +} + +pub(crate) struct Connection { + pub(crate) socket: BufferedSocket, + pub(crate) map: Arc<Mutex<ObjectMap<ObjectMeta>>>, + pub(crate) last_error: Arc<Mutex<Option<Error>>>, + pub(crate) display_buffer: QueueBuffer, +} + +impl Connection { + pub(crate) unsafe fn new(fd: RawFd, display_object: Object<ObjectMeta>) -> Connection { + let socket = BufferedSocket::new(Socket::from_raw_fd(fd)); + + let mut map = ObjectMap::new(); + // Insert first pre-existing object + let display_buffer = display_object.meta.buffer.clone(); + map.insert_at(1, display_object).unwrap(); + + Connection { + socket, + map: Arc::new(Mutex::new(map)), + last_error: Arc::new(Mutex::new(None)), + display_buffer, + } + } + + pub(crate) fn write_message(&mut self, msg: &Message) -> NixResult<()> { + self.socket.write_message(msg) + } + + pub(crate) fn flush(&mut self) -> NixResult<()> { + self.socket.flush() + } + + pub(crate) fn read_events(&mut self) -> Result<usize, Error> { + if let Some(ref err) = *self.last_error.lock().unwrap() { + return Err(err.clone()); + } + // acquire the map lock, this means no objects can be created nor destroyed while we + // are reading events + let mut map = self.map.lock().unwrap(); + // wrap it in a RefCell for cheap sharing in the two closures below + let map = RefCell::new(&mut *map); + let mut last_error = self.last_error.lock().unwrap(); + // read messages + let ret = self.socket.read_messages( + |id, opcode| { + map.borrow() + .find(id) + .and_then(|o| o.events.get(opcode as usize)) + .map(|desc| desc.signature) + }, + |msg| { + let mut map = map.borrow_mut(); + let object = match map.find(msg.sender_id) { + Some(obj) => obj, + None => { + // this is a message sent to a destroyed object + // to avoid dying because of races, we just consume it into void + // closing any associated FDs + for a in msg.args { + if let Argument::Fd(fd) = a { + let _ = ::nix::unistd::close(fd); + } + } + // continue parsing to the next message + return true; + } + }; + + // create a new object if applicable + if let Some(child) = object.event_child(msg.opcode) { + let new_id = msg + .args + .iter() + .flat_map(|a| { + if let &Argument::NewId(nid) = a { + Some(nid) + } else { + None + } + }) + .next() + .unwrap(); + let child_interface = child.interface; + if let Err(()) = map.insert_at(new_id, child) { + eprintln!( + "[wayland-client] Protocol error: server tried to create an object \"{}\" with invalid id \"{}\".", + child_interface, + new_id + ); + // abort parsing, this is an unrecoverable error + *last_error = Some(Error::Protocol); + return false; + } + } else { + // debug assert: if this opcode does not define a child, then there should be no + // NewId argument + debug_assert!(msg.args.iter().any(|a| a.get_type() == ArgumentType::NewId) == false); + } + + // send the message to the appropriate pending queue + object.meta.buffer.lock().unwrap().push_back(msg); + // continue parsing + true + }, + ); + match ret { + Ok(Ok(n)) => { + if let Some(ref e) = *last_error { + Err(e.clone()) + } else { + Ok(n) + } + } + Ok(Err(e)) => { + *last_error = Some(Error::Parse(e.clone())); + Err(Error::Parse(e)) + } + // non-fatal error + Err(e @ ::nix::Error::Sys(::nix::errno::Errno::EAGAIN)) => Err(Error::Nix(e)), + // fatal errors + Err(e) => { + *last_error = Some(Error::Nix(e)); + Err(Error::Nix(e)) + } + } + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/display.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/display.rs new file mode 100644 index 0000000..744a8e0 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/display.rs @@ -0,0 +1,96 @@ +use std::io; +use std::os::unix::io::RawFd; +use std::sync::{Arc, Mutex}; + +use wayland_commons::map::Object; +use wayland_commons::utils::UserData; + +use protocol::wl_display::{self, WlDisplay}; + +use {ConnectError, Proxy}; + +use super::connection::Connection; +use super::proxy::{NewProxyInner, ObjectMeta}; +use super::EventQueueInner; + +pub(crate) struct DisplayInner { + connection: Arc<Mutex<Connection>>, + proxy: Proxy<WlDisplay>, +} + +impl DisplayInner { + pub unsafe fn from_fd(fd: RawFd) -> Result<(Arc<DisplayInner>, EventQueueInner), ConnectError> { + // The special buffer for display events + let buffer = super::queues::create_queue_buffer(); + let display_object = Object::from_interface::<WlDisplay>(1, ObjectMeta::new(buffer.clone())); + let (connection, map) = { + let c = Connection::new(fd, display_object); + let m = c.map.clone(); + (Arc::new(Mutex::new(c)), m) + }; + + let display_newproxy = NewProxyInner::from_id(1, map.clone(), connection.clone()).unwrap(); + + // give access to the map to the display impl + let impl_map = map; + let impl_last_error = connection.lock().unwrap().last_error.clone(); + // our implementation is Send, we are safe + let display_proxy = display_newproxy.implement::<WlDisplay, _>( + move |event, _| match event { + wl_display::Event::Error { + object_id, + code, + message, + } => { + eprintln!( + "[wayland-client] Protocol error {} on object {}@{}: {}", + code, + object_id.inner.object.interface, + object_id.id(), + message + ); + *impl_last_error.lock().unwrap() = Some(super::connection::Error::Protocol); + } + wl_display::Event::DeleteId { id } => { + // cleanup the map as appropriate + let mut map = impl_map.lock().unwrap(); + let client_destroyed = map + .with(id, |obj| { + obj.meta.server_destroyed = true; + obj.meta.client_destroyed + }) + .unwrap_or(false); + if client_destroyed { + map.remove(id); + } + } + }, + UserData::empty(), + ); + + let default_event_queue = EventQueueInner::new(connection.clone(), None); + + let display = DisplayInner { + proxy: Proxy::wrap(display_proxy.make_wrapper(&default_event_queue).unwrap()), + connection, + }; + + Ok((Arc::new(display), default_event_queue)) + } + + pub(crate) fn flush(&self) -> io::Result<()> { + match self.connection.lock().unwrap().flush() { + Ok(()) => Ok(()), + Err(::nix::Error::Sys(errno)) => Err(errno.into()), + Err(_) => unreachable!(), + } + } + + pub(crate) fn create_event_queue(me: &Arc<DisplayInner>) -> EventQueueInner { + EventQueueInner::new(me.connection.clone(), None) + } + + pub(crate) fn get_proxy(&self) -> &Proxy<WlDisplay> { + &self.proxy + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/mod.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/mod.rs new file mode 100644 index 0000000..6fec292 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/mod.rs @@ -0,0 +1,150 @@ +use std::sync::atomic::Ordering; +use std::sync::{Arc, Mutex}; + +use downcast::Downcast; + +use wayland_commons::map::ObjectMap; +use wayland_commons::wire::Message; +use wayland_commons::MessageGroup; + +use {Interface, NewProxy, Proxy}; + +mod connection; +mod display; +mod proxy; +mod queues; + +pub(crate) use self::display::DisplayInner; +pub(crate) use self::proxy::{NewProxyInner, ProxyInner}; +pub(crate) use self::queues::EventQueueInner; + +/// A handle to the object map internal to the lib state +/// +/// This type is only usable by code generated by `wayland-scanner`, and is +/// not instantiable directly. +pub struct ProxyMap { + map: Arc<Mutex<ObjectMap<self::proxy::ObjectMeta>>>, + connection: Arc<Mutex<self::connection::Connection>>, +} + +impl ProxyMap { + pub(crate) fn make( + map: Arc<Mutex<ObjectMap<self::proxy::ObjectMeta>>>, + connection: Arc<Mutex<self::connection::Connection>>, + ) -> ProxyMap { + ProxyMap { map, connection } + } + + /// Retrieve the Proxy corresponding to a given id + pub fn get<I: Interface>(&mut self, id: u32) -> Option<Proxy<I>> { + ProxyInner::from_id(id, self.map.clone(), self.connection.clone()).map(|object| { + debug_assert!(I::NAME == "<anonymous>" || object.is_interface::<I>()); + Proxy::wrap(object) + }) + } + + /// Create a new proxy for given id + pub fn get_new<I: Interface>(&mut self, id: u32) -> Option<NewProxy<I>> { + debug_assert!(self + .map + .lock() + .unwrap() + .find(id) + .map(|obj| obj.is_interface::<I>()) + .unwrap_or(true)); + NewProxyInner::from_id(id, self.map.clone(), self.connection.clone()) + .map(|object| NewProxy::wrap(object)) + } +} + +pub(crate) trait Dispatcher: Downcast + Send { + fn dispatch(&mut self, msg: Message, proxy: ProxyInner, map: &mut ProxyMap) -> Result<(), ()>; +} + +mod dispatcher_impl { + // this mod has for sole purpose to allow to silence these `dead_code` warnings... + #![allow(dead_code)] + use super::Dispatcher; + impl_downcast!(Dispatcher); +} + +pub(crate) struct ImplDispatcher<I: Interface, F: FnMut(I::Event, Proxy<I>) + 'static> { + _i: ::std::marker::PhantomData<&'static I>, + implementation: F, +} + +// This unsafe impl is "technically wrong", but enforced by the fact that +// the Impl will only ever be called from the EventQueue, which is stuck +// on a single thread. The NewProxy::implement/implement_nonsend methods +// take care of ensuring that any non-Send impl is on the correct thread. +unsafe impl<I, F> Send for ImplDispatcher<I, F> +where + I: Interface, + F: FnMut(I::Event, Proxy<I>) + 'static, + I::Event: MessageGroup<Map = ProxyMap>, +{ +} + +impl<I, F> Dispatcher for ImplDispatcher<I, F> +where + I: Interface, + F: FnMut(I::Event, Proxy<I>) + 'static, + I::Event: MessageGroup<Map = ProxyMap>, +{ + fn dispatch(&mut self, msg: Message, proxy: ProxyInner, map: &mut ProxyMap) -> Result<(), ()> { + if ::std::env::var_os("WAYLAND_DEBUG").is_some() { + println!( + " <- {}@{}: {} {:?}", + proxy.object.interface, proxy.id, proxy.object.events[msg.opcode as usize].name, msg.args + ); + } + let message = I::Event::from_raw(msg, map)?; + if message.is_destructor() { + proxy.object.meta.alive.store(false, Ordering::Release); + { + // cleanup the map as appropriate + let mut map = proxy.map.lock().unwrap(); + let server_destroyed = map + .with(proxy.id, |obj| { + obj.meta.client_destroyed = true; + obj.meta.server_destroyed + }) + .unwrap_or(false); + if server_destroyed { + map.remove(proxy.id); + } + } + (self.implementation)(message, Proxy::<I>::wrap(proxy.clone())); + } else { + (self.implementation)(message, Proxy::<I>::wrap(proxy)); + } + Ok(()) + } +} + +pub(crate) unsafe fn make_dispatcher<I, F>(implementation: F) -> Arc<Mutex<Dispatcher + Send>> +where + I: Interface, + F: FnMut(I::Event, Proxy<I>) + 'static, + I::Event: MessageGroup<Map = ProxyMap>, +{ + Arc::new(Mutex::new(ImplDispatcher { + _i: ::std::marker::PhantomData, + implementation, + })) +} + +pub(crate) fn default_dispatcher() -> Arc<Mutex<Dispatcher + Send>> { + struct DefaultDisp; + impl Dispatcher for DefaultDisp { + fn dispatch(&mut self, _msg: Message, proxy: ProxyInner, _map: &mut ProxyMap) -> Result<(), ()> { + eprintln!( + "[wayland-client] Received an event for unimplemented object {}@{}.", + proxy.object.interface, proxy.id + ); + Err(()) + } + } + + Arc::new(Mutex::new(DefaultDisp)) +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/proxy.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/proxy.rs new file mode 100644 index 0000000..b2f76aa --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/proxy.rs @@ -0,0 +1,323 @@ +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex}; + +use wayland_commons::map::{Object, ObjectMap, ObjectMetadata}; +use wayland_commons::utils::UserData; +use wayland_commons::wire::{Argument, ArgumentType}; +use wayland_commons::MessageGroup; + +use super::connection::Connection; +use super::queues::QueueBuffer; +use super::{Dispatcher, EventQueueInner}; +use {Interface, Proxy}; + +#[derive(Clone)] +pub(crate) struct ObjectMeta { + pub(crate) buffer: QueueBuffer, + pub(crate) alive: Arc<AtomicBool>, + user_data: Arc<UserData>, + pub(crate) dispatcher: Arc<Mutex<Dispatcher>>, + pub(crate) server_destroyed: bool, + pub(crate) client_destroyed: bool, +} + +impl ObjectMetadata for ObjectMeta { + fn child(&self) -> ObjectMeta { + ObjectMeta { + buffer: self.buffer.clone(), + alive: Arc::new(AtomicBool::new(true)), + user_data: Arc::new(UserData::empty()), + dispatcher: super::default_dispatcher(), + server_destroyed: false, + client_destroyed: false, + } + } +} + +impl ObjectMeta { + pub(crate) fn new(buffer: QueueBuffer) -> ObjectMeta { + ObjectMeta { + buffer, + alive: Arc::new(AtomicBool::new(true)), + user_data: Arc::new(UserData::empty()), + dispatcher: super::default_dispatcher(), + server_destroyed: false, + client_destroyed: false, + } + } + + fn dead() -> ObjectMeta { + ObjectMeta { + buffer: super::queues::create_queue_buffer(), + alive: Arc::new(AtomicBool::new(false)), + user_data: Arc::new(UserData::empty()), + dispatcher: super::default_dispatcher(), + server_destroyed: true, + client_destroyed: true, + } + } +} + +#[derive(Clone)] +pub(crate) struct ProxyInner { + pub(crate) map: Arc<Mutex<ObjectMap<ObjectMeta>>>, + pub(crate) connection: Arc<Mutex<Connection>>, + pub(crate) object: Object<ObjectMeta>, + pub(crate) id: u32, +} + +impl ProxyInner { + pub(crate) fn from_id( + id: u32, + map: Arc<Mutex<ObjectMap<ObjectMeta>>>, + connection: Arc<Mutex<Connection>>, + ) -> Option<ProxyInner> { + let me = map.lock().unwrap().find(id); + me.map(|obj| ProxyInner { + map, + connection, + id, + object: obj, + }) + } + + pub(crate) fn is_interface<I: Interface>(&self) -> bool { + self.object.is_interface::<I>() + } + + pub(crate) fn is_alive(&self) -> bool { + self.object.meta.alive.load(Ordering::Acquire) + } + + pub fn version(&self) -> u32 { + self.object.version + } + + pub(crate) fn id(&self) -> u32 { + if self.is_alive() { + self.id + } else { + 0 + } + } + + pub(crate) fn get_user_data<UD: 'static>(&self) -> Option<&UD> { + self.object.meta.user_data.get::<UD>() + } + + pub(crate) fn send<I: Interface>(&self, msg: I::Request) { + // grab the connection lock before anything else + // this avoids the risk of marking ourselves dead while an other + // thread is sending a message an accidentally sending that message + // after ours if ours is a destructor + let mut conn_lock = self.connection.lock().unwrap(); + if !self.is_alive() { + return; + } + let destructor = msg.is_destructor(); + let msg = msg.into_raw(self.id); + if ::std::env::var_os("WAYLAND_DEBUG").is_some() { + println!( + " -> {}@{}: {} {:?}", + I::NAME, + self.id, + self.object.requests[msg.opcode as usize].name, + msg.args + ); + } + // TODO: figure our if this can fail and still be recoverable ? + let _ = conn_lock.write_message(&msg).expect("Sending a message failed."); + if destructor { + self.object.meta.alive.store(false, Ordering::Release); + { + // cleanup the map as appropriate + let mut map = conn_lock.map.lock().unwrap(); + let server_destroyed = map + .with(self.id, |obj| { + obj.meta.client_destroyed = true; + obj.meta.server_destroyed + }) + .unwrap_or(false); + if server_destroyed { + map.remove(self.id); + } + } + } + } + + pub(crate) fn send_constructor<I, J>( + &self, + msg: I::Request, + version: Option<u32>, + ) -> Result<NewProxyInner, ()> + where + I: Interface, + J: Interface, + { + // grab the connection lock before anything else + // this avoids the risk or races during object creation + let mut conn_lock = self.connection.lock().unwrap(); + if !self.is_alive() { + return Err(()); + } + let destructor = msg.is_destructor(); + let mut msg = msg.into_raw(self.id); + if ::std::env::var_os("WAYLAND_DEBUG").is_some() { + println!( + " -> {}@{}: {} {:?}", + I::NAME, + self.id, + self.object.requests[msg.opcode as usize].name, + msg.args + ); + } + + let opcode = msg.opcode; + + // sanity check + let mut nid_idx = I::Request::MESSAGES[opcode as usize] + .signature + .iter() + .position(|&t| t == ArgumentType::NewId) + .expect("Trying to use 'send_constructor' with a message not creating any object."); + + if let Some(o) = I::Request::child(opcode, 1, &()) { + if !o.is_interface::<J>() { + panic!("Trying to use 'send_constructor' with the wrong return type. Required interface {} but the message creates interface {}") + } + } else { + // there is no target interface in the protocol, this is a generic object-creating + // function (likely wl_registry.bind), the newid arg will thus expand to (str, u32, obj) + nid_idx += 2; + } + // insert the newly created object in the message + let newproxy = match &mut msg.args[nid_idx] { + &mut Argument::NewId(ref mut newid) => { + let newp = match version { + Some(v) => self.child_versioned::<J>(v), + None => self.child::<J>(), + }; + *newid = newp.id; + newp + } + _ => unreachable!(), + }; + + let _ = conn_lock.write_message(&msg).expect("Sending a message failed."); + if destructor { + self.object.meta.alive.store(false, Ordering::Release); + { + // cleanup the map as appropriate + let mut map = conn_lock.map.lock().unwrap(); + let server_destroyed = map + .with(self.id, |obj| { + obj.meta.client_destroyed = true; + obj.meta.server_destroyed + }) + .unwrap_or(false); + if server_destroyed { + map.remove(self.id); + } + } + } + + Ok(newproxy) + } + + pub(crate) fn equals(&self, other: &ProxyInner) -> bool { + self.is_alive() && Arc::ptr_eq(&self.object.meta.alive, &other.object.meta.alive) + } + + pub(crate) fn make_wrapper(&self, queue: &EventQueueInner) -> Result<ProxyInner, ()> { + let mut wrapper = self.clone(); + wrapper.object.meta.buffer = queue.buffer.clone(); + Ok(wrapper) + } + + pub(crate) fn child<I: Interface>(&self) -> NewProxyInner { + self.child_versioned::<I>(self.object.version) + } + + pub(crate) fn child_versioned<I: Interface>(&self, version: u32) -> NewProxyInner { + let new_object = Object::from_interface::<I>(version, self.object.meta.child()); + let new_id = self.map.lock().unwrap().client_insert_new(new_object); + NewProxyInner { + map: self.map.clone(), + connection: self.connection.clone(), + id: new_id, + } + } + + pub(crate) fn child_placeholder(&self) -> ProxyInner { + ProxyInner { + map: self.map.clone(), + connection: self.connection.clone(), + object: Object::placeholder(self.object.meta.child()), + id: 0, + } + } +} + +pub(crate) struct NewProxyInner { + map: Arc<Mutex<ObjectMap<ObjectMeta>>>, + connection: Arc<Mutex<Connection>>, + id: u32, +} + +impl NewProxyInner { + pub(crate) fn from_id( + id: u32, + map: Arc<Mutex<ObjectMap<ObjectMeta>>>, + connection: Arc<Mutex<Connection>>, + ) -> Option<NewProxyInner> { + if map.lock().unwrap().find(id).is_some() { + Some(NewProxyInner { map, connection, id }) + } else { + None + } + } + + /// Racy method, if called, must be called before any event to this object + /// is read from the socket, or it'll end up in the wrong queue... + pub(crate) unsafe fn assign_queue(&self, queue: &EventQueueInner) { + let _ = self.map.lock().unwrap().with(self.id, |obj| { + obj.meta.buffer = queue.buffer.clone(); + }); + } + + // Invariants: Impl is either `Send` or we are on the same thread as the target event loop + pub(crate) unsafe fn implement<I: Interface, F>( + self, + implementation: F, + user_data: UserData, + ) -> ProxyInner + where + F: FnMut(I::Event, Proxy<I>) + 'static, + I::Event: MessageGroup<Map = super::ProxyMap>, + { + let object = self.map.lock().unwrap().with(self.id, |obj| { + obj.meta.dispatcher = super::make_dispatcher(implementation); + obj.meta.user_data = Arc::new(user_data); + obj.clone() + }); + + let object = match object { + Ok(obj) => obj, + Err(()) => { + // We are trying to implement a non-existent object + // This is either a bug in the lib (a NewProxy was created while it should not + // have been possible) or an object was created and the server destroyed it + // before it could be implemented. + // Thus, we just create a dummy already-dead Proxy + Object::from_interface::<I>(1, ObjectMeta::dead()) + } + }; + + ProxyInner { + map: self.map, + connection: self.connection, + id: self.id, + object, + } + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/queues.rs b/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/queues.rs new file mode 100644 index 0000000..2488704 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/src/rust_imp/queues.rs @@ -0,0 +1,217 @@ +use std::cell::Cell; +use std::collections::VecDeque; +use std::io; +use std::os::unix::io::AsRawFd; +use std::rc::Rc; +use std::sync::{Arc, Mutex}; + +use nix::poll::{poll, PollFlags, PollFd}; + +use wayland_commons::map::ObjectMap; +use wayland_commons::utils::UserData; +use wayland_commons::wire::Message; + +use super::connection::{Connection, Error as CError}; +use super::proxy::{ObjectMeta, ProxyInner}; + +pub(crate) type QueueBuffer = Arc<Mutex<VecDeque<Message>>>; + +pub(crate) fn create_queue_buffer() -> QueueBuffer { + Arc::new(Mutex::new(VecDeque::new())) +} + +pub(crate) struct EventQueueInner { + pub(crate) connection: Arc<Mutex<Connection>>, + pub(crate) map: Arc<Mutex<ObjectMap<ObjectMeta>>>, + pub(crate) buffer: QueueBuffer, + display_buffer: QueueBuffer, +} + +impl EventQueueInner { + pub(crate) fn new(connection: Arc<Mutex<Connection>>, buffer: Option<QueueBuffer>) -> EventQueueInner { + let (map, display_buffer) = { + let cx = connection.lock().unwrap(); + (cx.map.clone(), cx.display_buffer.clone()) + }; + EventQueueInner { + connection, + map, + buffer: buffer.unwrap_or_else(create_queue_buffer), + display_buffer, + } + } + + #[cfg(feature = "eventloop")] + pub(crate) fn get_connection_fd(&self) -> ::std::os::unix::io::RawFd { + self.connection.lock().unwrap().socket.get_socket().as_raw_fd() + } + + pub(crate) fn dispatch(&self) -> io::Result<u32> { + // don't read events if there are some pending + if let Err(()) = self.prepare_read() { + return self.dispatch_pending(); + } + + // temporarily retrieve the socket Fd, only using it for POLL-ing! + let socket_fd; + { + // Flush the outgoing socket + let mut conn_lock = self.connection.lock().unwrap(); + socket_fd = conn_lock.socket.get_socket().as_raw_fd(); + loop { + match conn_lock.flush() { + Ok(_) => break, + Err(::nix::Error::Sys(::nix::errno::Errno::EAGAIN)) => { + // EAGAIN, we need to wait before writing, so we poll the socket + let poll_ret = poll(&mut [PollFd::new(socket_fd, PollFlags::POLLOUT)], -1); + match poll_ret { + Ok(_) => continue, + Err(::nix::Error::Sys(e)) => { + self.cancel_read(); + return Err(e.into()); + } + Err(_) => unreachable!(), + } + } + Err(::nix::Error::Sys(e)) => { + if e != ::nix::errno::Errno::EPIPE { + // don't abort on EPIPE, so we can continue reading + // to get the protocol error + self.cancel_read(); + return Err(e.into()); + } + } + Err(_) => unreachable!(), + } + } + } + + // wait for incoming messages to arrive + match poll(&mut [PollFd::new(socket_fd, PollFlags::POLLIN)], -1) { + Ok(_) => (), + Err(::nix::Error::Sys(e)) => { + self.cancel_read(); + return Err(e.into()); + } + Err(_) => unreachable!(), + } + + match self.read_events() { + Ok(_) => (), + Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { + // we waited for read readiness be then received a WouldBlock error + // this means that an other thread was also reading events and read them + // under our nose + // this is alright, continue + } + Err(e) => return Err(e), + } + + self.dispatch_pending() + } + + fn dispatch_buffer(&self, buffer: &mut VecDeque<Message>) -> io::Result<u32> { + let mut count = 0; + let mut proxymap = super::ProxyMap::make(self.map.clone(), self.connection.clone()); + for msg in buffer.drain(..) { + let id = msg.sender_id; + if let Some(proxy) = ProxyInner::from_id(id, self.map.clone(), self.connection.clone()) { + let object = proxy.object.clone(); + let mut dispatcher = object.meta.dispatcher.lock().unwrap(); + if let Err(()) = dispatcher.dispatch(msg, proxy, &mut proxymap) { + return Err(io::Error::new( + io::ErrorKind::Other, + format!("Dispatch for object {}@{} errored.", object.interface, id), + )); + } else { + count += 1; + } + } else { + return Err(io::Error::new( + io::ErrorKind::Other, + format!("Received an event for unknown object {}.", id), + )); + } + } + Ok(count) + } + + pub(crate) fn dispatch_pending(&self) -> io::Result<u32> { + // First always dispatch the display buffer + let display_dispatched = { + let mut buffer = self.display_buffer.lock().unwrap(); + self.dispatch_buffer(&mut *buffer) + }?; + + // Then our actual buffer + let self_dispatched = { + let mut buffer = self.buffer.lock().unwrap(); + self.dispatch_buffer(&mut *buffer) + }?; + + Ok(display_dispatched + self_dispatched) + } + + pub(crate) fn sync_roundtrip(&self) -> io::Result<u32> { + use protocol::wl_callback::{Event as CbEvent, WlCallback}; + use protocol::wl_display::{RequestsTrait as DisplayRequests, WlDisplay}; + use Proxy; + // first retrieve the display and make a wrapper for it in this event queue + let display: Proxy<WlDisplay> = Proxy::wrap( + ProxyInner::from_id(1, self.map.clone(), self.connection.clone()) + .unwrap() + .make_wrapper(self) + .unwrap(), + ); + + let done = Rc::new(Cell::new(false)); + let ret = display.sync(|np| { + Proxy::wrap(unsafe { + let done2 = done.clone(); + np.inner.implement::<WlCallback, _>( + move |CbEvent::Done { .. }, _| { + done2.set(true); + }, + UserData::empty(), + ) + }) + }); + + if let Err(()) = ret { + return Err(::nix::errno::Errno::EPROTO.into()); + } + + let mut dispatched = 0; + + loop { + dispatched += self.dispatch()?; + if done.get() { + return Ok(dispatched); + } + } + } + + pub(crate) fn prepare_read(&self) -> Result<(), ()> { + if !self.buffer.lock().unwrap().is_empty() { + return Err(()); + } + + // TODO: un-mock + Ok(()) + } + + pub(crate) fn read_events(&self) -> io::Result<i32> { + // TODO: integrate more properly with prepare read with a fence + match self.connection.lock().unwrap().read_events() { + Ok(n) => Ok(n as i32), + Err(CError::Protocol) => Err(::nix::errno::Errno::EPROTO.into()), + Err(CError::Parse(_)) => Err(::nix::errno::Errno::EPROTO.into()), + Err(CError::Nix(::nix::Error::Sys(errno))) => Err(errno.into()), + Err(CError::Nix(_)) => unreachable!(), + } + } + + pub(crate) fn cancel_read(&self) { + // TODO: un-mock + } +} diff --git a/third_party/cargo/vendor/wayland-client-0.21.13/wayland.xml b/third_party/cargo/vendor/wayland-client-0.21.13/wayland.xml new file mode 100644 index 0000000..3f2d967 --- /dev/null +++ b/third_party/cargo/vendor/wayland-client-0.21.13/wayland.xml @@ -0,0 +1,2693 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="wayland"> + + <copyright> + Copyright © 2008-2011 Kristian Høgsberg + Copyright © 2010-2011 Intel Corporation + Copyright © 2012-2013 Collabora, Ltd. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice (including the + next paragraph) shall be included in all copies or substantial + portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + </copyright> + + <interface name="wl_display" version="1"> + <description summary="core global object"> + The core global object. This is a special singleton object. It + is used for internal Wayland protocol features. + </description> + + <request name="sync"> + <description summary="asynchronous roundtrip"> + The sync request asks the server to emit the 'done' event + on the returned wl_callback object. Since requests are + handled in-order and events are delivered in-order, this can + be used as a barrier to ensure all previous requests and the + resulting events have been handled. + + The object returned by this request will be destroyed by the + compositor after the callback is fired and as such the client must not + attempt to use it after that point. + + The callback_data passed in the callback is the event serial. + </description> + <arg name="callback" type="new_id" interface="wl_callback" + summary="callback object for the sync request"/> + </request> + + <request name="get_registry"> + <description summary="get global registry object"> + This request creates a registry object that allows the client + to list and bind the global objects available from the + compositor. + </description> + <arg name="registry" type="new_id" interface="wl_registry" + summary="global registry object"/> + </request> + + <event name="error"> + <description summary="fatal error event"> + The error event is sent out when a fatal (non-recoverable) + error has occurred. The object_id argument is the object + where the error occurred, most often in response to a request + to that object. The code identifies the error and is defined + by the object interface. As such, each interface defines its + own set of error codes. The message is a brief description + of the error, for (debugging) convenience. + </description> + <arg name="object_id" type="object" summary="object where the error occurred"/> + <arg name="code" type="uint" summary="error code"/> + <arg name="message" type="string" summary="error description"/> + </event> + + <enum name="error"> + <description summary="global error values"> + These errors are global and can be emitted in response to any + server request. + </description> + <entry name="invalid_object" value="0" + summary="server couldn't find object"/> + <entry name="invalid_method" value="1" + summary="method doesn't exist on the specified interface"/> + <entry name="no_memory" value="2" + summary="server is out of memory"/> + </enum> + + <event name="delete_id"> + <description summary="acknowledge object ID deletion"> + This event is used internally by the object ID management + logic. When a client deletes an object, the server will send + this event to acknowledge that it has seen the delete request. + When the client receives this event, it will know that it can + safely reuse the object ID. + </description> + <arg name="id" type="uint" summary="deleted object ID"/> + </event> + </interface> + + <interface name="wl_registry" version="1"> + <description summary="global registry object"> + The global registry object. The server has a number of global + objects that are available to all clients. These objects + typically represent an actual object in the server (for example, + an input device) or they are singleton objects that provide + extension functionality. + + When a client creates a registry object, the registry object + will emit a global event for each global currently in the + registry. Globals come and go as a result of device or + monitor hotplugs, reconfiguration or other events, and the + registry will send out global and global_remove events to + keep the client up to date with the changes. To mark the end + of the initial burst of events, the client can use the + wl_display.sync request immediately after calling + wl_display.get_registry. + + A client can bind to a global object by using the bind + request. This creates a client-side handle that lets the object + emit events to the client and lets the client invoke requests on + the object. + </description> + + <request name="bind"> + <description summary="bind an object to the display"> + Binds a new, client-created object to the server using the + specified name as the identifier. + </description> + <arg name="name" type="uint" summary="unique numeric name of the object"/> + <arg name="id" type="new_id" summary="bounded object"/> + </request> + + <event name="global"> + <description summary="announce global object"> + Notify the client of global objects. + + The event notifies the client that a global object with + the given name is now available, and it implements the + given version of the given interface. + </description> + <arg name="name" type="uint" summary="numeric name of the global object"/> + <arg name="interface" type="string" summary="interface implemented by the object"/> + <arg name="version" type="uint" summary="interface version"/> + </event> + + <event name="global_remove"> + <description summary="announce removal of global object"> + Notify the client of removed global objects. + + This event notifies the client that the global identified + by name is no longer available. If the client bound to + the global using the bind request, the client should now + destroy that object. + + The object remains valid and requests to the object will be + ignored until the client destroys it, to avoid races between + the global going away and a client sending a request to it. + </description> + <arg name="name" type="uint" summary="numeric name of the global object"/> + </event> + </interface> + + <interface name="wl_callback" version="1"> + <description summary="callback object"> + Clients can handle the 'done' event to get notified when + the related request is done. + </description> + + <event name="done"> + <description summary="done event"> + Notify the client when the related request is done. + </description> + <arg name="callback_data" type="uint" summary="request-specific data for the callback"/> + </event> + </interface> + + <interface name="wl_compositor" version="4"> + <description summary="the compositor singleton"> + A compositor. This object is a singleton global. The + compositor is in charge of combining the contents of multiple + surfaces into one displayable output. + </description> + + <request name="create_surface"> + <description summary="create new surface"> + Ask the compositor to create a new surface. + </description> + <arg name="id" type="new_id" interface="wl_surface" summary="the new surface"/> + </request> + + <request name="create_region"> + <description summary="create new region"> + Ask the compositor to create a new region. + </description> + <arg name="id" type="new_id" interface="wl_region" summary="the new region"/> + </request> + </interface> + + <interface name="wl_shm_pool" version="1"> + <description summary="a shared memory pool"> + The wl_shm_pool object encapsulates a piece of memory shared + between the compositor and client. Through the wl_shm_pool + object, the client can allocate shared memory wl_buffer objects. + All objects created through the same pool share the same + underlying mapped memory. Reusing the mapped memory avoids the + setup/teardown overhead and is useful when interactively resizing + a surface or for many small buffers. + </description> + + <request name="create_buffer"> + <description summary="create a buffer from the pool"> + Create a wl_buffer object from the pool. + + The buffer is created offset bytes into the pool and has + width and height as specified. The stride argument specifies + the number of bytes from the beginning of one row to the beginning + of the next. The format is the pixel format of the buffer and + must be one of those advertised through the wl_shm.format event. + + A buffer will keep a reference to the pool it was created from + so it is valid to destroy the pool immediately after creating + a buffer from it. + </description> + + <arg name="id" type="new_id" interface="wl_buffer" summary="buffer to create"/> + <arg name="offset" type="int" summary="buffer byte offset within the pool"/> + <arg name="width" type="int" summary="buffer width, in pixels"/> + <arg name="height" type="int" summary="buffer height, in pixels"/> + <arg name="stride" type="int" summary="number of bytes from the beginning of one row to the beginning of the next row"/> + <arg name="format" type="uint" enum="wl_shm.format" summary="buffer pixel format"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the pool"> + Destroy the shared memory pool. + + The mmapped memory will be released when all + buffers that have been created from this pool + are gone. + </description> + </request> + + <request name="resize"> + <description summary="change the size of the pool mapping"> + This request will cause the server to remap the backing memory + for the pool from the file descriptor passed when the pool was + created, but using the new size. This request can only be + used to make the pool bigger. + </description> + + <arg name="size" type="int" summary="new size of the pool, in bytes"/> + </request> + </interface> + + <interface name="wl_shm" version="1"> + <description summary="shared memory support"> + A global singleton object that provides support for shared + memory. + + Clients can create wl_shm_pool objects using the create_pool + request. + + At connection setup time, the wl_shm object emits one or more + format events to inform clients about the valid pixel formats + that can be used for buffers. + </description> + + <enum name="error"> + <description summary="wl_shm error values"> + These errors can be emitted in response to wl_shm requests. + </description> + <entry name="invalid_format" value="0" summary="buffer format is not known"/> + <entry name="invalid_stride" value="1" summary="invalid size or stride during pool or buffer creation"/> + <entry name="invalid_fd" value="2" summary="mmapping the file descriptor failed"/> + </enum> + + <enum name="format"> + <description summary="pixel formats"> + This describes the memory layout of an individual pixel. + + All renderers should support argb8888 and xrgb8888 but any other + formats are optional and may not be supported by the particular + renderer in use. + + The drm format codes match the #defines in drm_fourcc.h. + The formats actually supported by the compositor will be + reported by the format event. + </description> + <entry name="argb8888" value="0" summary="32-bit ARGB format, [31:0] A:R:G:B 8:8:8:8 little endian"/> + <entry name="xrgb8888" value="1" summary="32-bit RGB format, [31:0] x:R:G:B 8:8:8:8 little endian"/> + <entry name="c8" value="0x20203843" summary="8-bit color index format, [7:0] C"/> + <entry name="rgb332" value="0x38424752" summary="8-bit RGB format, [7:0] R:G:B 3:3:2"/> + <entry name="bgr233" value="0x38524742" summary="8-bit BGR format, [7:0] B:G:R 2:3:3"/> + <entry name="xrgb4444" value="0x32315258" summary="16-bit xRGB format, [15:0] x:R:G:B 4:4:4:4 little endian"/> + <entry name="xbgr4444" value="0x32314258" summary="16-bit xBGR format, [15:0] x:B:G:R 4:4:4:4 little endian"/> + <entry name="rgbx4444" value="0x32315852" summary="16-bit RGBx format, [15:0] R:G:B:x 4:4:4:4 little endian"/> + <entry name="bgrx4444" value="0x32315842" summary="16-bit BGRx format, [15:0] B:G:R:x 4:4:4:4 little endian"/> + <entry name="argb4444" value="0x32315241" summary="16-bit ARGB format, [15:0] A:R:G:B 4:4:4:4 little endian"/> + <entry name="abgr4444" value="0x32314241" summary="16-bit ABGR format, [15:0] A:B:G:R 4:4:4:4 little endian"/> + <entry name="rgba4444" value="0x32314152" summary="16-bit RBGA format, [15:0] R:G:B:A 4:4:4:4 little endian"/> + <entry name="bgra4444" value="0x32314142" summary="16-bit BGRA format, [15:0] B:G:R:A 4:4:4:4 little endian"/> + <entry name="xrgb1555" value="0x35315258" summary="16-bit xRGB format, [15:0] x:R:G:B 1:5:5:5 little endian"/> + <entry name="xbgr1555" value="0x35314258" summary="16-bit xBGR 1555 format, [15:0] x:B:G:R 1:5:5:5 little endian"/> + <entry name="rgbx5551" value="0x35315852" summary="16-bit RGBx 5551 format, [15:0] R:G:B:x 5:5:5:1 little endian"/> + <entry name="bgrx5551" value="0x35315842" summary="16-bit BGRx 5551 format, [15:0] B:G:R:x 5:5:5:1 little endian"/> + <entry name="argb1555" value="0x35315241" summary="16-bit ARGB 1555 format, [15:0] A:R:G:B 1:5:5:5 little endian"/> + <entry name="abgr1555" value="0x35314241" summary="16-bit ABGR 1555 format, [15:0] A:B:G:R 1:5:5:5 little endian"/> + <entry name="rgba5551" value="0x35314152" summary="16-bit RGBA 5551 format, [15:0] R:G:B:A 5:5:5:1 little endian"/> + <entry name="bgra5551" value="0x35314142" summary="16-bit BGRA 5551 format, [15:0] B:G:R:A 5:5:5:1 little endian"/> + <entry name="rgb565" value="0x36314752" summary="16-bit RGB 565 format, [15:0] R:G:B 5:6:5 little endian"/> + <entry name="bgr565" value="0x36314742" summary="16-bit BGR 565 format, [15:0] B:G:R 5:6:5 little endian"/> + <entry name="rgb888" value="0x34324752" summary="24-bit RGB format, [23:0] R:G:B little endian"/> + <entry name="bgr888" value="0x34324742" summary="24-bit BGR format, [23:0] B:G:R little endian"/> + <entry name="xbgr8888" value="0x34324258" summary="32-bit xBGR format, [31:0] x:B:G:R 8:8:8:8 little endian"/> + <entry name="rgbx8888" value="0x34325852" summary="32-bit RGBx format, [31:0] R:G:B:x 8:8:8:8 little endian"/> + <entry name="bgrx8888" value="0x34325842" summary="32-bit BGRx format, [31:0] B:G:R:x 8:8:8:8 little endian"/> + <entry name="abgr8888" value="0x34324241" summary="32-bit ABGR format, [31:0] A:B:G:R 8:8:8:8 little endian"/> + <entry name="rgba8888" value="0x34324152" summary="32-bit RGBA format, [31:0] R:G:B:A 8:8:8:8 little endian"/> + <entry name="bgra8888" value="0x34324142" summary="32-bit BGRA format, [31:0] B:G:R:A 8:8:8:8 little endian"/> + <entry name="xrgb2101010" value="0x30335258" summary="32-bit xRGB format, [31:0] x:R:G:B 2:10:10:10 little endian"/> + <entry name="xbgr2101010" value="0x30334258" summary="32-bit xBGR format, [31:0] x:B:G:R 2:10:10:10 little endian"/> + <entry name="rgbx1010102" value="0x30335852" summary="32-bit RGBx format, [31:0] R:G:B:x 10:10:10:2 little endian"/> + <entry name="bgrx1010102" value="0x30335842" summary="32-bit BGRx format, [31:0] B:G:R:x 10:10:10:2 little endian"/> + <entry name="argb2101010" value="0x30335241" summary="32-bit ARGB format, [31:0] A:R:G:B 2:10:10:10 little endian"/> + <entry name="abgr2101010" value="0x30334241" summary="32-bit ABGR format, [31:0] A:B:G:R 2:10:10:10 little endian"/> + <entry name="rgba1010102" value="0x30334152" summary="32-bit RGBA format, [31:0] R:G:B:A 10:10:10:2 little endian"/> + <entry name="bgra1010102" value="0x30334142" summary="32-bit BGRA format, [31:0] B:G:R:A 10:10:10:2 little endian"/> + <entry name="yuyv" value="0x56595559" summary="packed YCbCr format, [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian"/> + <entry name="yvyu" value="0x55595659" summary="packed YCbCr format, [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian"/> + <entry name="uyvy" value="0x59565955" summary="packed YCbCr format, [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian"/> + <entry name="vyuy" value="0x59555956" summary="packed YCbCr format, [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian"/> + <entry name="ayuv" value="0x56555941" summary="packed AYCbCr format, [31:0] A:Y:Cb:Cr 8:8:8:8 little endian"/> + <entry name="nv12" value="0x3231564e" summary="2 plane YCbCr Cr:Cb format, 2x2 subsampled Cr:Cb plane"/> + <entry name="nv21" value="0x3132564e" summary="2 plane YCbCr Cb:Cr format, 2x2 subsampled Cb:Cr plane"/> + <entry name="nv16" value="0x3631564e" summary="2 plane YCbCr Cr:Cb format, 2x1 subsampled Cr:Cb plane"/> + <entry name="nv61" value="0x3136564e" summary="2 plane YCbCr Cb:Cr format, 2x1 subsampled Cb:Cr plane"/> + <entry name="yuv410" value="0x39565559" summary="3 plane YCbCr format, 4x4 subsampled Cb (1) and Cr (2) planes"/> + <entry name="yvu410" value="0x39555659" summary="3 plane YCbCr format, 4x4 subsampled Cr (1) and Cb (2) planes"/> + <entry name="yuv411" value="0x31315559" summary="3 plane YCbCr format, 4x1 subsampled Cb (1) and Cr (2) planes"/> + <entry name="yvu411" value="0x31315659" summary="3 plane YCbCr format, 4x1 subsampled Cr (1) and Cb (2) planes"/> + <entry name="yuv420" value="0x32315559" summary="3 plane YCbCr format, 2x2 subsampled Cb (1) and Cr (2) planes"/> + <entry name="yvu420" value="0x32315659" summary="3 plane YCbCr format, 2x2 subsampled Cr (1) and Cb (2) planes"/> + <entry name="yuv422" value="0x36315559" summary="3 plane YCbCr format, 2x1 subsampled Cb (1) and Cr (2) planes"/> + <entry name="yvu422" value="0x36315659" summary="3 plane YCbCr format, 2x1 subsampled Cr (1) and Cb (2) planes"/> + <entry name="yuv444" value="0x34325559" summary="3 plane YCbCr format, non-subsampled Cb (1) and Cr (2) planes"/> + <entry name="yvu444" value="0x34325659" summary="3 plane YCbCr format, non-subsampled Cr (1) and Cb (2) planes"/> + </enum> + + <request name="create_pool"> + <description summary="create a shm pool"> + Create a new wl_shm_pool object. + + The pool can be used to create shared memory based buffer + objects. The server will mmap size bytes of the passed file + descriptor, to use as backing memory for the pool. + </description> + + <arg name="id" type="new_id" interface="wl_shm_pool" summary="pool to create"/> + <arg name="fd" type="fd" summary="file descriptor for the pool"/> + <arg name="size" type="int" summary="pool size, in bytes"/> + </request> + + <event name="format"> + <description summary="pixel format description"> + Informs the client about a valid pixel format that + can be used for buffers. Known formats include + argb8888 and xrgb8888. + </description> + <arg name="format" type="uint" enum="format" summary="buffer pixel format"/> + </event> + </interface> + + <interface name="wl_buffer" version="1"> + <description summary="content for a wl_surface"> + A buffer provides the content for a wl_surface. Buffers are + created through factory interfaces such as wl_drm, wl_shm or + similar. It has a width and a height and can be attached to a + wl_surface, but the mechanism by which a client provides and + updates the contents is defined by the buffer factory interface. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy a buffer"> + Destroy a buffer. If and how you need to release the backing + storage is defined by the buffer factory interface. + + For possible side-effects to a surface, see wl_surface.attach. + </description> + </request> + + <event name="release"> + <description summary="compositor releases buffer"> + Sent when this wl_buffer is no longer used by the compositor. + The client is now free to reuse or destroy this buffer and its + backing storage. + + If a client receives a release event before the frame callback + requested in the same wl_surface.commit that attaches this + wl_buffer to a surface, then the client is immediately free to + reuse the buffer and its backing storage, and does not need a + second buffer for the next surface content update. Typically + this is possible, when the compositor maintains a copy of the + wl_surface contents, e.g. as a GL texture. This is an important + optimization for GL(ES) compositors with wl_shm clients. + </description> + </event> + </interface> + + <interface name="wl_data_offer" version="3"> + <description summary="offer to transfer data"> + A wl_data_offer represents a piece of data offered for transfer + by another client (the source client). It is used by the + copy-and-paste and drag-and-drop mechanisms. The offer + describes the different mime types that the data can be + converted to and provides the mechanism for transferring the + data directly from the source client. + </description> + + <enum name="error"> + <entry name="invalid_finish" value="0" + summary="finish request was called untimely"/> + <entry name="invalid_action_mask" value="1" + summary="action mask contains invalid values"/> + <entry name="invalid_action" value="2" + summary="action argument has an invalid value"/> + <entry name="invalid_offer" value="3" + summary="offer doesn't accept this request"/> + </enum> + + <request name="accept"> + <description summary="accept one of the offered mime types"> + Indicate that the client can accept the given mime type, or + NULL for not accepted. + + For objects of version 2 or older, this request is used by the + client to give feedback whether the client can receive the given + mime type, or NULL if none is accepted; the feedback does not + determine whether the drag-and-drop operation succeeds or not. + + For objects of version 3 or newer, this request determines the + final result of the drag-and-drop operation. If the end result + is that no mime types were accepted, the drag-and-drop operation + will be cancelled and the corresponding drag source will receive + wl_data_source.cancelled. Clients may still use this event in + conjunction with wl_data_source.action for feedback. + </description> + + <arg name="serial" type="uint" summary="serial number of the accept request"/> + <arg name="mime_type" type="string" allow-null="true" summary="mime type accepted by the client"/> + </request> + + <request name="receive"> + <description summary="request that the data is transferred"> + To transfer the offered data, the client issues this request + and indicates the mime type it wants to receive. The transfer + happens through the passed file descriptor (typically created + with the pipe system call). The source client writes the data + in the mime type representation requested and then closes the + file descriptor. + + The receiving client reads from the read end of the pipe until + EOF and then closes its end, at which point the transfer is + complete. + + This request may happen multiple times for different mime types, + both before and after wl_data_device.drop. Drag-and-drop destination + clients may preemptively fetch data or examine it more closely to + determine acceptance. + </description> + <arg name="mime_type" type="string" summary="mime type desired by receiver"/> + <arg name="fd" type="fd" summary="file descriptor for data transfer"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy data offer"> + Destroy the data offer. + </description> + </request> + + <event name="offer"> + <description summary="advertise offered mime type"> + Sent immediately after creating the wl_data_offer object. One + event per offered mime type. + </description> + + <arg name="mime_type" type="string" summary="offered mime type"/> + </event> + + <!-- Version 3 additions --> + + <request name="finish" since="3"> + <description summary="the offer will no longer be used"> + Notifies the compositor that the drag destination successfully + finished the drag-and-drop operation. + + Upon receiving this request, the compositor will emit + wl_data_source.dnd_finished on the drag source client. + + It is a client error to perform other requests than + wl_data_offer.destroy after this one. It is also an error to perform + this request after a NULL mime type has been set in + wl_data_offer.accept or no action was received through + wl_data_offer.action. + </description> + </request> + + <request name="set_actions" since="3"> + <description summary="set the available/preferred drag-and-drop actions"> + Sets the actions that the destination side client supports for + this operation. This request may trigger the emission of + wl_data_source.action and wl_data_offer.action events if the compositor + needs to change the selected action. + + This request can be called multiple times throughout the + drag-and-drop operation, typically in response to wl_data_device.enter + or wl_data_device.motion events. + + This request determines the final result of the drag-and-drop + operation. If the end result is that no action is accepted, + the drag source will receive wl_drag_source.cancelled. + + The dnd_actions argument must contain only values expressed in the + wl_data_device_manager.dnd_actions enum, and the preferred_action + argument must only contain one of those values set, otherwise it + will result in a protocol error. + + While managing an "ask" action, the destination drag-and-drop client + may perform further wl_data_offer.receive requests, and is expected + to perform one last wl_data_offer.set_actions request with a preferred + action other than "ask" (and optionally wl_data_offer.accept) before + requesting wl_data_offer.finish, in order to convey the action selected + by the user. If the preferred action is not in the + wl_data_offer.source_actions mask, an error will be raised. + + If the "ask" action is dismissed (e.g. user cancellation), the client + is expected to perform wl_data_offer.destroy right away. + + This request can only be made on drag-and-drop offers, a protocol error + will be raised otherwise. + </description> + <arg name="dnd_actions" type="uint" summary="actions supported by the destination client"/> + <arg name="preferred_action" type="uint" summary="action preferred by the destination client"/> + </request> + + <event name="source_actions" since="3"> + <description summary="notify the source-side available actions"> + This event indicates the actions offered by the data source. It + will be sent right after wl_data_device.enter, or anytime the source + side changes its offered actions through wl_data_source.set_actions. + </description> + <arg name="source_actions" type="uint" summary="actions offered by the data source"/> + </event> + + <event name="action" since="3"> + <description summary="notify the selected action"> + This event indicates the action selected by the compositor after + matching the source/destination side actions. Only one action (or + none) will be offered here. + + This event can be emitted multiple times during the drag-and-drop + operation in response to destination side action changes through + wl_data_offer.set_actions. + + This event will no longer be emitted after wl_data_device.drop + happened on the drag-and-drop destination, the client must + honor the last action received, or the last preferred one set + through wl_data_offer.set_actions when handling an "ask" action. + + Compositors may also change the selected action on the fly, mainly + in response to keyboard modifier changes during the drag-and-drop + operation. + + The most recent action received is always the valid one. Prior to + receiving wl_data_device.drop, the chosen action may change (e.g. + due to keyboard modifiers being pressed). At the time of receiving + wl_data_device.drop the drag-and-drop destination must honor the + last action received. + + Action changes may still happen after wl_data_device.drop, + especially on "ask" actions, where the drag-and-drop destination + may choose another action afterwards. Action changes happening + at this stage are always the result of inter-client negotiation, the + compositor shall no longer be able to induce a different action. + + Upon "ask" actions, it is expected that the drag-and-drop destination + may potentially choose a different action and/or mime type, + based on wl_data_offer.source_actions and finally chosen by the + user (e.g. popping up a menu with the available options). The + final wl_data_offer.set_actions and wl_data_offer.accept requests + must happen before the call to wl_data_offer.finish. + </description> + <arg name="dnd_action" type="uint" summary="action selected by the compositor"/> + </event> + </interface> + + <interface name="wl_data_source" version="3"> + <description summary="offer to transfer data"> + The wl_data_source object is the source side of a wl_data_offer. + It is created by the source client in a data transfer and + provides a way to describe the offered data and a way to respond + to requests to transfer the data. + </description> + + <enum name="error"> + <entry name="invalid_action_mask" value="0" + summary="action mask contains invalid values"/> + <entry name="invalid_source" value="1" + summary="source doesn't accept this request"/> + </enum> + + <request name="offer"> + <description summary="add an offered mime type"> + This request adds a mime type to the set of mime types + advertised to targets. Can be called several times to offer + multiple types. + </description> + <arg name="mime_type" type="string" summary="mime type offered by the data source"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the data source"> + Destroy the data source. + </description> + </request> + + <event name="target"> + <description summary="a target accepts an offered mime type"> + Sent when a target accepts pointer_focus or motion events. If + a target does not accept any of the offered types, type is NULL. + + Used for feedback during drag-and-drop. + </description> + + <arg name="mime_type" type="string" allow-null="true" summary="mime type accepted by the target"/> + </event> + + <event name="send"> + <description summary="send the data"> + Request for data from the client. Send the data as the + specified mime type over the passed file descriptor, then + close it. + </description> + + <arg name="mime_type" type="string" summary="mime type for the data"/> + <arg name="fd" type="fd" summary="file descriptor for the data"/> + </event> + + <event name="cancelled"> + <description summary="selection was cancelled"> + This data source is no longer valid. There are several reasons why + this could happen: + + - The data source has been replaced by another data source. + - The drag-and-drop operation was performed, but the drop destination + did not accept any of the mime types offered through + wl_data_source.target. + - The drag-and-drop operation was performed, but the drop destination + did not select any of the actions present in the mask offered through + wl_data_source.action. + - The drag-and-drop operation was performed but didn't happen over a + surface. + - The compositor cancelled the drag-and-drop operation (e.g. compositor + dependent timeouts to avoid stale drag-and-drop transfers). + + The client should clean up and destroy this data source. + + For objects of version 2 or older, wl_data_source.cancelled will + only be emitted if the data source was replaced by another data + source. + </description> + </event> + + <!-- Version 3 additions --> + + <request name="set_actions" since="3"> + <description summary="set the available drag-and-drop actions"> + Sets the actions that the source side client supports for this + operation. This request may trigger wl_data_source.action and + wl_data_offer.action events if the compositor needs to change the + selected action. + + The dnd_actions argument must contain only values expressed in the + wl_data_device_manager.dnd_actions enum, otherwise it will result + in a protocol error. + + This request must be made once only, and can only be made on sources + used in drag-and-drop, so it must be performed before + wl_data_device.start_drag. Attempting to use the source other than + for drag-and-drop will raise a protocol error. + </description> + <arg name="dnd_actions" type="uint" summary="actions supported by the data source"/> + </request> + + <event name="dnd_drop_performed" since="3"> + <description summary="the drag-and-drop operation physically finished"> + The user performed the drop action. This event does not indicate + acceptance, wl_data_source.cancelled may still be emitted afterwards + if the drop destination does not accept any mime type. + + However, this event might however not be received if the compositor + cancelled the drag-and-drop operation before this event could happen. + + Note that the data_source may still be used in the future and should + not be destroyed here. + </description> + </event> + + <event name="dnd_finished" since="3"> + <description summary="the drag-and-drop operation concluded"> + The drop destination finished interoperating with this data + source, so the client is now free to destroy this data source and + free all associated data. + + If the action used to perform the operation was "move", the + source can now delete the transferred data. + </description> + </event> + + <event name="action" since="3"> + <description summary="notify the selected action"> + This event indicates the action selected by the compositor after + matching the source/destination side actions. Only one action (or + none) will be offered here. + + This event can be emitted multiple times during the drag-and-drop + operation, mainly in response to destination side changes through + wl_data_offer.set_actions, and as the data device enters/leaves + surfaces. + + It is only possible to receive this event after + wl_data_source.dnd_drop_performed if the drag-and-drop operation + ended in an "ask" action, in which case the final wl_data_source.action + event will happen immediately before wl_data_source.dnd_finished. + + Compositors may also change the selected action on the fly, mainly + in response to keyboard modifier changes during the drag-and-drop + operation. + + The most recent action received is always the valid one. The chosen + action may change alongside negotiation (e.g. an "ask" action can turn + into a "move" operation), so the effects of the final action must + always be applied in wl_data_offer.dnd_finished. + + Clients can trigger cursor surface changes from this point, so + they reflect the current action. + </description> + <arg name="dnd_action" type="uint" summary="action selected by the compositor"/> + </event> + </interface> + + <interface name="wl_data_device" version="3"> + <description summary="data transfer device"> + There is one wl_data_device per seat which can be obtained + from the global wl_data_device_manager singleton. + + A wl_data_device provides access to inter-client data transfer + mechanisms such as copy-and-paste and drag-and-drop. + </description> + + <enum name="error"> + <entry name="role" value="0" summary="given wl_surface has another role"/> + </enum> + + <request name="start_drag"> + <description summary="start drag-and-drop operation"> + This request asks the compositor to start a drag-and-drop + operation on behalf of the client. + + The source argument is the data source that provides the data + for the eventual data transfer. If source is NULL, enter, leave + and motion events are sent only to the client that initiated the + drag and the client is expected to handle the data passing + internally. + + The origin surface is the surface where the drag originates and + the client must have an active implicit grab that matches the + serial. + + The icon surface is an optional (can be NULL) surface that + provides an icon to be moved around with the cursor. Initially, + the top-left corner of the icon surface is placed at the cursor + hotspot, but subsequent wl_surface.attach request can move the + relative position. Attach requests must be confirmed with + wl_surface.commit as usual. The icon surface is given the role of + a drag-and-drop icon. If the icon surface already has another role, + it raises a protocol error. + + The current and pending input regions of the icon wl_surface are + cleared, and wl_surface.set_input_region is ignored until the + wl_surface is no longer used as the icon surface. When the use + as an icon ends, the current and pending input regions become + undefined, and the wl_surface is unmapped. + </description> + <arg name="source" type="object" interface="wl_data_source" allow-null="true" summary="data source for the eventual transfer"/> + <arg name="origin" type="object" interface="wl_surface" summary="surface where the drag originates"/> + <arg name="icon" type="object" interface="wl_surface" allow-null="true" summary="drag-and-drop icon surface"/> + <arg name="serial" type="uint" summary="serial number of the implicit grab on the origin"/> + </request> + + <request name="set_selection"> + <description summary="copy data to the selection"> + This request asks the compositor to set the selection + to the data from the source on behalf of the client. + + To unset the selection, set the source to NULL. + </description> + <arg name="source" type="object" interface="wl_data_source" allow-null="true" summary="data source for the selection"/> + <arg name="serial" type="uint" summary="serial number of the event that triggered this request"/> + </request> + + <event name="data_offer"> + <description summary="introduce a new wl_data_offer"> + The data_offer event introduces a new wl_data_offer object, + which will subsequently be used in either the + data_device.enter event (for drag-and-drop) or the + data_device.selection event (for selections). Immediately + following the data_device_data_offer event, the new data_offer + object will send out data_offer.offer events to describe the + mime types it offers. + </description> + + <arg name="id" type="new_id" interface="wl_data_offer" summary="the new data_offer object"/> + </event> + + <event name="enter"> + <description summary="initiate drag-and-drop session"> + This event is sent when an active drag-and-drop pointer enters + a surface owned by the client. The position of the pointer at + enter time is provided by the x and y arguments, in surface-local + coordinates. + </description> + + <arg name="serial" type="uint" summary="serial number of the enter event"/> + <arg name="surface" type="object" interface="wl_surface" summary="client surface entered"/> + <arg name="x" type="fixed" summary="surface-local x coordinate"/> + <arg name="y" type="fixed" summary="surface-local y coordinate"/> + <arg name="id" type="object" interface="wl_data_offer" allow-null="true" + summary="source data_offer object"/> + </event> + + <event name="leave"> + <description summary="end drag-and-drop session"> + This event is sent when the drag-and-drop pointer leaves the + surface and the session ends. The client must destroy the + wl_data_offer introduced at enter time at this point. + </description> + </event> + + <event name="motion"> + <description summary="drag-and-drop session motion"> + This event is sent when the drag-and-drop pointer moves within + the currently focused surface. The new position of the pointer + is provided by the x and y arguments, in surface-local + coordinates. + </description> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="x" type="fixed" summary="surface-local x coordinate"/> + <arg name="y" type="fixed" summary="surface-local y coordinate"/> + </event> + + <event name="drop"> + <description summary="end drag-and-drop session successfully"> + The event is sent when a drag-and-drop operation is ended + because the implicit grab is removed. + + The drag-and-drop destination is expected to honor the last action + received through wl_data_offer.action, if the resulting action is + "copy" or "move", the destination can still perform + wl_data_offer.receive requests, and is expected to end all + transfers with a wl_data_offer.finish request. + + If the resulting action is "ask", the action will not be considered + final. The drag-and-drop destination is expected to perform one last + wl_data_offer.set_actions request, or wl_data_offer.destroy in order + to cancel the operation. + </description> + </event> + + <event name="selection"> + <description summary="advertise new selection"> + The selection event is sent out to notify the client of a new + wl_data_offer for the selection for this device. The + data_device.data_offer and the data_offer.offer events are + sent out immediately before this event to introduce the data + offer object. The selection event is sent to a client + immediately before receiving keyboard focus and when a new + selection is set while the client has keyboard focus. The + data_offer is valid until a new data_offer or NULL is received + or until the client loses keyboard focus. The client must + destroy the previous selection data_offer, if any, upon receiving + this event. + </description> + <arg name="id" type="object" interface="wl_data_offer" allow-null="true" + summary="selection data_offer object"/> + </event> + + <!-- Version 2 additions --> + + <request name="release" type="destructor" since="2"> + <description summary="destroy data device"> + This request destroys the data device. + </description> + </request> + </interface> + + <interface name="wl_data_device_manager" version="3"> + <description summary="data transfer interface"> + The wl_data_device_manager is a singleton global object that + provides access to inter-client data transfer mechanisms such as + copy-and-paste and drag-and-drop. These mechanisms are tied to + a wl_seat and this interface lets a client get a wl_data_device + corresponding to a wl_seat. + + Depending on the version bound, the objects created from the bound + wl_data_device_manager object will have different requirements for + functioning properly. See wl_data_source.set_actions, + wl_data_offer.accept and wl_data_offer.finish for details. + </description> + + <request name="create_data_source"> + <description summary="create a new data source"> + Create a new data source. + </description> + <arg name="id" type="new_id" interface="wl_data_source" summary="data source to create"/> + </request> + + <request name="get_data_device"> + <description summary="create a new data device"> + Create a new data device for a given seat. + </description> + <arg name="id" type="new_id" interface="wl_data_device" summary="data device to create"/> + <arg name="seat" type="object" interface="wl_seat" summary="seat associated with the data device"/> + </request> + + <!-- Version 3 additions --> + + <enum name="dnd_action" bitfield="true" since="3"> + <description summary="drag and drop actions"> + This is a bitmask of the available/preferred actions in a + drag-and-drop operation. + + In the compositor, the selected action is a result of matching the + actions offered by the source and destination sides. "action" events + with a "none" action will be sent to both source and destination if + there is no match. All further checks will effectively happen on + (source actions ∩ destination actions). + + In addition, compositors may also pick different actions in + reaction to key modifiers being pressed. One common design that + is used in major toolkits (and the behavior recommended for + compositors) is: + + - If no modifiers are pressed, the first match (in bit order) + will be used. + - Pressing Shift selects "move", if enabled in the mask. + - Pressing Control selects "copy", if enabled in the mask. + + Behavior beyond that is considered implementation-dependent. + Compositors may for example bind other modifiers (like Alt/Meta) + or drags initiated with other buttons than BTN_LEFT to specific + actions (e.g. "ask"). + </description> + <entry name="none" value="0" summary="no action"/> + <entry name="copy" value="1" summary="copy action"/> + <entry name="move" value="2" summary="move action"/> + <entry name="ask" value="4" summary="ask action"/> + </enum> + </interface> + + <interface name="wl_shell" version="1"> + <description summary="create desktop-style surfaces"> + This interface is implemented by servers that provide + desktop-style user interfaces. + + It allows clients to associate a wl_shell_surface with + a basic surface. + </description> + + <enum name="error"> + <entry name="role" value="0" summary="given wl_surface has another role"/> + </enum> + + <request name="get_shell_surface"> + <description summary="create a shell surface from a surface"> + Create a shell surface for an existing surface. This gives + the wl_surface the role of a shell surface. If the wl_surface + already has another role, it raises a protocol error. + + Only one shell surface can be associated with a given surface. + </description> + <arg name="id" type="new_id" interface="wl_shell_surface" summary="shell surface to create"/> + <arg name="surface" type="object" interface="wl_surface" summary="surface to be given the shell surface role"/> + </request> + </interface> + + <interface name="wl_shell_surface" version="1"> + <description summary="desktop-style metadata interface"> + An interface that may be implemented by a wl_surface, for + implementations that provide a desktop-style user interface. + + It provides requests to treat surfaces like toplevel, fullscreen + or popup windows, move, resize or maximize them, associate + metadata like title and class, etc. + + On the server side the object is automatically destroyed when + the related wl_surface is destroyed. On the client side, + wl_shell_surface_destroy() must be called before destroying + the wl_surface object. + </description> + + <request name="pong"> + <description summary="respond to a ping event"> + A client must respond to a ping event with a pong request or + the client may be deemed unresponsive. + </description> + <arg name="serial" type="uint" summary="serial number of the ping event"/> + </request> + + <request name="move"> + <description summary="start an interactive move"> + Start a pointer-driven move of the surface. + + This request must be used in response to a button press event. + The server may ignore move requests depending on the state of + the surface (e.g. fullscreen or maximized). + </description> + <arg name="seat" type="object" interface="wl_seat" summary="seat whose pointer is used"/> + <arg name="serial" type="uint" summary="serial number of the implicit grab on the pointer"/> + </request> + + <enum name="resize" bitfield="true"> + <description summary="edge values for resizing"> + These values are used to indicate which edge of a surface + is being dragged in a resize operation. The server may + use this information to adapt its behavior, e.g. choose + an appropriate cursor image. + </description> + <entry name="none" value="0" summary="no edge"/> + <entry name="top" value="1" summary="top edge"/> + <entry name="bottom" value="2" summary="bottom edge"/> + <entry name="left" value="4" summary="left edge"/> + <entry name="top_left" value="5" summary="top and left edges"/> + <entry name="bottom_left" value="6" summary="bottom and left edges"/> + <entry name="right" value="8" summary="right edge"/> + <entry name="top_right" value="9" summary="top and right edges"/> + <entry name="bottom_right" value="10" summary="bottom and right edges"/> + </enum> + + <request name="resize"> + <description summary="start an interactive resize"> + Start a pointer-driven resizing of the surface. + + This request must be used in response to a button press event. + The server may ignore resize requests depending on the state of + the surface (e.g. fullscreen or maximized). + </description> + <arg name="seat" type="object" interface="wl_seat" summary="seat whose pointer is used"/> + <arg name="serial" type="uint" summary="serial number of the implicit grab on the pointer"/> + <arg name="edges" type="uint" enum="resize" summary="which edge or corner is being dragged"/> + </request> + + <request name="set_toplevel"> + <description summary="make the surface a toplevel surface"> + Map the surface as a toplevel surface. + + A toplevel surface is not fullscreen, maximized or transient. + </description> + </request> + + <enum name="transient" bitfield="true"> + <description summary="details of transient behaviour"> + These flags specify details of the expected behaviour + of transient surfaces. Used in the set_transient request. + </description> + <entry name="inactive" value="0x1" summary="do not set keyboard focus"/> + </enum> + + <request name="set_transient"> + <description summary="make the surface a transient surface"> + Map the surface relative to an existing surface. + + The x and y arguments specify the location of the upper left + corner of the surface relative to the upper left corner of the + parent surface, in surface-local coordinates. + + The flags argument controls details of the transient behaviour. + </description> + + <arg name="parent" type="object" interface="wl_surface" summary="parent surface"/> + <arg name="x" type="int" summary="surface-local x coordinate"/> + <arg name="y" type="int" summary="surface-local y coordinate"/> + <arg name="flags" type="uint" enum="transient" summary="transient surface behavior"/> + </request> + + <enum name="fullscreen_method"> + <description summary="different method to set the surface fullscreen"> + Hints to indicate to the compositor how to deal with a conflict + between the dimensions of the surface and the dimensions of the + output. The compositor is free to ignore this parameter. + </description> + <entry name="default" value="0" summary="no preference, apply default policy"/> + <entry name="scale" value="1" summary="scale, preserve the surface's aspect ratio and center on output"/> + <entry name="driver" value="2" summary="switch output mode to the smallest mode that can fit the surface, add black borders to compensate size mismatch"/> + <entry name="fill" value="3" summary="no upscaling, center on output and add black borders to compensate size mismatch"/> + </enum> + + <request name="set_fullscreen"> + <description summary="make the surface a fullscreen surface"> + Map the surface as a fullscreen surface. + + If an output parameter is given then the surface will be made + fullscreen on that output. If the client does not specify the + output then the compositor will apply its policy - usually + choosing the output on which the surface has the biggest surface + area. + + The client may specify a method to resolve a size conflict + between the output size and the surface size - this is provided + through the method parameter. + + The framerate parameter is used only when the method is set + to "driver", to indicate the preferred framerate. A value of 0 + indicates that the client does not care about framerate. The + framerate is specified in mHz, that is framerate of 60000 is 60Hz. + + A method of "scale" or "driver" implies a scaling operation of + the surface, either via a direct scaling operation or a change of + the output mode. This will override any kind of output scaling, so + that mapping a surface with a buffer size equal to the mode can + fill the screen independent of buffer_scale. + + A method of "fill" means we don't scale up the buffer, however + any output scale is applied. This means that you may run into + an edge case where the application maps a buffer with the same + size of the output mode but buffer_scale 1 (thus making a + surface larger than the output). In this case it is allowed to + downscale the results to fit the screen. + + The compositor must reply to this request with a configure event + with the dimensions for the output on which the surface will + be made fullscreen. + </description> + <arg name="method" type="uint" enum="fullscreen_method" summary="method for resolving size conflict"/> + <arg name="framerate" type="uint" summary="framerate in mHz"/> + <arg name="output" type="object" interface="wl_output" allow-null="true" + summary="output on which the surface is to be fullscreen"/> + </request> + + <request name="set_popup"> + <description summary="make the surface a popup surface"> + Map the surface as a popup. + + A popup surface is a transient surface with an added pointer + grab. + + An existing implicit grab will be changed to owner-events mode, + and the popup grab will continue after the implicit grab ends + (i.e. releasing the mouse button does not cause the popup to + be unmapped). + + The popup grab continues until the window is destroyed or a + mouse button is pressed in any other client's window. A click + in any of the client's surfaces is reported as normal, however, + clicks in other clients' surfaces will be discarded and trigger + the callback. + + The x and y arguments specify the location of the upper left + corner of the surface relative to the upper left corner of the + parent surface, in surface-local coordinates. + </description> + + <arg name="seat" type="object" interface="wl_seat" summary="seat whose pointer is used"/> + <arg name="serial" type="uint" summary="serial number of the implicit grab on the pointer"/> + <arg name="parent" type="object" interface="wl_surface" summary="parent surface"/> + <arg name="x" type="int" summary="surface-local x coordinate"/> + <arg name="y" type="int" summary="surface-local y coordinate"/> + <arg name="flags" type="uint" enum="transient" summary="transient surface behavior"/> + </request> + + <request name="set_maximized"> + <description summary="make the surface a maximized surface"> + Map the surface as a maximized surface. + + If an output parameter is given then the surface will be + maximized on that output. If the client does not specify the + output then the compositor will apply its policy - usually + choosing the output on which the surface has the biggest surface + area. + + The compositor will reply with a configure event telling + the expected new surface size. The operation is completed + on the next buffer attach to this surface. + + A maximized surface typically fills the entire output it is + bound to, except for desktop elements such as panels. This is + the main difference between a maximized shell surface and a + fullscreen shell surface. + + The details depend on the compositor implementation. + </description> + <arg name="output" type="object" interface="wl_output" allow-null="true" + summary="output on which the surface is to be maximized"/> + </request> + + <request name="set_title"> + <description summary="set surface title"> + Set a short title for the surface. + + This string may be used to identify the surface in a task bar, + window list, or other user interface elements provided by the + compositor. + + The string must be encoded in UTF-8. + </description> + <arg name="title" type="string" summary="surface title"/> + </request> + + <request name="set_class"> + <description summary="set surface class"> + Set a class for the surface. + + The surface class identifies the general class of applications + to which the surface belongs. A common convention is to use the + file name (or the full path if it is a non-standard location) of + the application's .desktop file as the class. + </description> + <arg name="class_" type="string" summary="surface class"/> + </request> + + <event name="ping"> + <description summary="ping client"> + Ping a client to check if it is receiving events and sending + requests. A client is expected to reply with a pong request. + </description> + <arg name="serial" type="uint" summary="serial number of the ping"/> + </event> + + <event name="configure"> + <description summary="suggest resize"> + The configure event asks the client to resize its surface. + + The size is a hint, in the sense that the client is free to + ignore it if it doesn't resize, pick a smaller size (to + satisfy aspect ratio or resize in steps of NxM pixels). + + The edges parameter provides a hint about how the surface + was resized. The client may use this information to decide + how to adjust its content to the new size (e.g. a scrolling + area might adjust its content position to leave the viewable + content unmoved). + + The client is free to dismiss all but the last configure + event it received. + + The width and height arguments specify the size of the window + in surface-local coordinates. + </description> + + <arg name="edges" type="uint" enum="resize" summary="how the surface was resized"/> + <arg name="width" type="int" summary="new width of the surface"/> + <arg name="height" type="int" summary="new height of the surface"/> + </event> + + <event name="popup_done"> + <description summary="popup interaction is done"> + The popup_done event is sent out when a popup grab is broken, + that is, when the user clicks a surface that doesn't belong + to the client owning the popup surface. + </description> + </event> + </interface> + + <interface name="wl_surface" version="4"> + <description summary="an onscreen surface"> + A surface is a rectangular area that is displayed on the screen. + It has a location, size and pixel contents. + + The size of a surface (and relative positions on it) is described + in surface-local coordinates, which may differ from the buffer + coordinates of the pixel content, in case a buffer_transform + or a buffer_scale is used. + + A surface without a "role" is fairly useless: a compositor does + not know where, when or how to present it. The role is the + purpose of a wl_surface. Examples of roles are a cursor for a + pointer (as set by wl_pointer.set_cursor), a drag icon + (wl_data_device.start_drag), a sub-surface + (wl_subcompositor.get_subsurface), and a window as defined by a + shell protocol (e.g. wl_shell.get_shell_surface). + + A surface can have only one role at a time. Initially a + wl_surface does not have a role. Once a wl_surface is given a + role, it is set permanently for the whole lifetime of the + wl_surface object. Giving the current role again is allowed, + unless explicitly forbidden by the relevant interface + specification. + + Surface roles are given by requests in other interfaces such as + wl_pointer.set_cursor. The request should explicitly mention + that this request gives a role to a wl_surface. Often, this + request also creates a new protocol object that represents the + role and adds additional functionality to wl_surface. When a + client wants to destroy a wl_surface, they must destroy this 'role + object' before the wl_surface. + + Destroying the role object does not remove the role from the + wl_surface, but it may stop the wl_surface from "playing the role". + For instance, if a wl_subsurface object is destroyed, the wl_surface + it was created for will be unmapped and forget its position and + z-order. It is allowed to create a wl_subsurface for the same + wl_surface again, but it is not allowed to use the wl_surface as + a cursor (cursor is a different role than sub-surface, and role + switching is not allowed). + </description> + + <enum name="error"> + <description summary="wl_surface error values"> + These errors can be emitted in response to wl_surface requests. + </description> + <entry name="invalid_scale" value="0" summary="buffer scale value is invalid"/> + <entry name="invalid_transform" value="1" summary="buffer transform value is invalid"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="delete surface"> + Deletes the surface and invalidates its object ID. + </description> + </request> + + <request name="attach"> + <description summary="set the surface contents"> + Set a buffer as the content of this surface. + + The new size of the surface is calculated based on the buffer + size transformed by the inverse buffer_transform and the + inverse buffer_scale. This means that the supplied buffer + must be an integer multiple of the buffer_scale. + + The x and y arguments specify the location of the new pending + buffer's upper left corner, relative to the current buffer's upper + left corner, in surface-local coordinates. In other words, the + x and y, combined with the new surface size define in which + directions the surface's size changes. + + Surface contents are double-buffered state, see wl_surface.commit. + + The initial surface contents are void; there is no content. + wl_surface.attach assigns the given wl_buffer as the pending + wl_buffer. wl_surface.commit makes the pending wl_buffer the new + surface contents, and the size of the surface becomes the size + calculated from the wl_buffer, as described above. After commit, + there is no pending buffer until the next attach. + + Committing a pending wl_buffer allows the compositor to read the + pixels in the wl_buffer. The compositor may access the pixels at + any time after the wl_surface.commit request. When the compositor + will not access the pixels anymore, it will send the + wl_buffer.release event. Only after receiving wl_buffer.release, + the client may reuse the wl_buffer. A wl_buffer that has been + attached and then replaced by another attach instead of committed + will not receive a release event, and is not used by the + compositor. + + Destroying the wl_buffer after wl_buffer.release does not change + the surface contents. However, if the client destroys the + wl_buffer before receiving the wl_buffer.release event, the surface + contents become undefined immediately. + + If wl_surface.attach is sent with a NULL wl_buffer, the + following wl_surface.commit will remove the surface content. + </description> + + <arg name="buffer" type="object" interface="wl_buffer" allow-null="true" + summary="buffer of surface contents"/> + <arg name="x" type="int" summary="surface-local x coordinate"/> + <arg name="y" type="int" summary="surface-local y coordinate"/> + </request> + + <request name="damage"> + <description summary="mark part of the surface damaged"> + This request is used to describe the regions where the pending + buffer is different from the current surface contents, and where + the surface therefore needs to be repainted. The compositor + ignores the parts of the damage that fall outside of the surface. + + Damage is double-buffered state, see wl_surface.commit. + + The damage rectangle is specified in surface-local coordinates, + where x and y specify the upper left corner of the damage rectangle. + + The initial value for pending damage is empty: no damage. + wl_surface.damage adds pending damage: the new pending damage + is the union of old pending damage and the given rectangle. + + wl_surface.commit assigns pending damage as the current damage, + and clears pending damage. The server will clear the current + damage as it repaints the surface. + + Alternatively, damage can be posted with wl_surface.damage_buffer + which uses buffer coordinates instead of surface coordinates, + and is probably the preferred and intuitive way of doing this. + </description> + + <arg name="x" type="int" summary="surface-local x coordinate"/> + <arg name="y" type="int" summary="surface-local y coordinate"/> + <arg name="width" type="int" summary="width of damage rectangle"/> + <arg name="height" type="int" summary="height of damage rectangle"/> + </request> + + <request name="frame"> + <description summary="request a frame throttling hint"> + Request a notification when it is a good time to start drawing a new + frame, by creating a frame callback. This is useful for throttling + redrawing operations, and driving animations. + + When a client is animating on a wl_surface, it can use the 'frame' + request to get notified when it is a good time to draw and commit the + next frame of animation. If the client commits an update earlier than + that, it is likely that some updates will not make it to the display, + and the client is wasting resources by drawing too often. + + The frame request will take effect on the next wl_surface.commit. + The notification will only be posted for one frame unless + requested again. For a wl_surface, the notifications are posted in + the order the frame requests were committed. + + The server must send the notifications so that a client + will not send excessive updates, while still allowing + the highest possible update rate for clients that wait for the reply + before drawing again. The server should give some time for the client + to draw and commit after sending the frame callback events to let it + hit the next output refresh. + + A server should avoid signaling the frame callbacks if the + surface is not visible in any way, e.g. the surface is off-screen, + or completely obscured by other opaque surfaces. + + The object returned by this request will be destroyed by the + compositor after the callback is fired and as such the client must not + attempt to use it after that point. + + The callback_data passed in the callback is the current time, in + milliseconds, with an undefined base. + </description> + + <arg name="callback" type="new_id" interface="wl_callback" summary="callback object for the frame request"/> + </request> + + <request name="set_opaque_region"> + <description summary="set opaque region"> + This request sets the region of the surface that contains + opaque content. + + The opaque region is an optimization hint for the compositor + that lets it optimize the redrawing of content behind opaque + regions. Setting an opaque region is not required for correct + behaviour, but marking transparent content as opaque will result + in repaint artifacts. + + The opaque region is specified in surface-local coordinates. + + The compositor ignores the parts of the opaque region that fall + outside of the surface. + + Opaque region is double-buffered state, see wl_surface.commit. + + wl_surface.set_opaque_region changes the pending opaque region. + wl_surface.commit copies the pending region to the current region. + Otherwise, the pending and current regions are never changed. + + The initial value for an opaque region is empty. Setting the pending + opaque region has copy semantics, and the wl_region object can be + destroyed immediately. A NULL wl_region causes the pending opaque + region to be set to empty. + </description> + + <arg name="region" type="object" interface="wl_region" allow-null="true" + summary="opaque region of the surface"/> + </request> + + <request name="set_input_region"> + <description summary="set input region"> + This request sets the region of the surface that can receive + pointer and touch events. + + Input events happening outside of this region will try the next + surface in the server surface stack. The compositor ignores the + parts of the input region that fall outside of the surface. + + The input region is specified in surface-local coordinates. + + Input region is double-buffered state, see wl_surface.commit. + + wl_surface.set_input_region changes the pending input region. + wl_surface.commit copies the pending region to the current region. + Otherwise the pending and current regions are never changed, + except cursor and icon surfaces are special cases, see + wl_pointer.set_cursor and wl_data_device.start_drag. + + The initial value for an input region is infinite. That means the + whole surface will accept input. Setting the pending input region + has copy semantics, and the wl_region object can be destroyed + immediately. A NULL wl_region causes the input region to be set + to infinite. + </description> + + <arg name="region" type="object" interface="wl_region" allow-null="true" + summary="input region of the surface"/> + </request> + + <request name="commit"> + <description summary="commit pending surface state"> + Surface state (input, opaque, and damage regions, attached buffers, + etc.) is double-buffered. Protocol requests modify the pending state, + as opposed to the current state in use by the compositor. A commit + request atomically applies all pending state, replacing the current + state. After commit, the new pending state is as documented for each + related request. + + On commit, a pending wl_buffer is applied first, and all other state + second. This means that all coordinates in double-buffered state are + relative to the new wl_buffer coming into use, except for + wl_surface.attach itself. If there is no pending wl_buffer, the + coordinates are relative to the current surface contents. + + All requests that need a commit to become effective are documented + to affect double-buffered state. + + Other interfaces may add further double-buffered surface state. + </description> + </request> + + <event name="enter"> + <description summary="surface enters an output"> + This is emitted whenever a surface's creation, movement, or resizing + results in some part of it being within the scanout region of an + output. + + Note that a surface may be overlapping with zero or more outputs. + </description> + <arg name="output" type="object" interface="wl_output" summary="output entered by the surface"/> + </event> + + <event name="leave"> + <description summary="surface leaves an output"> + This is emitted whenever a surface's creation, movement, or resizing + results in it no longer having any part of it within the scanout region + of an output. + </description> + <arg name="output" type="object" interface="wl_output" summary="output left by the surface"/> + </event> + + <!-- Version 2 additions --> + + <request name="set_buffer_transform" since="2"> + <description summary="sets the buffer transformation"> + This request sets an optional transformation on how the compositor + interprets the contents of the buffer attached to the surface. The + accepted values for the transform parameter are the values for + wl_output.transform. + + Buffer transform is double-buffered state, see wl_surface.commit. + + A newly created surface has its buffer transformation set to normal. + + wl_surface.set_buffer_transform changes the pending buffer + transformation. wl_surface.commit copies the pending buffer + transformation to the current one. Otherwise, the pending and current + values are never changed. + + The purpose of this request is to allow clients to render content + according to the output transform, thus permitting the compositor to + use certain optimizations even if the display is rotated. Using + hardware overlays and scanning out a client buffer for fullscreen + surfaces are examples of such optimizations. Those optimizations are + highly dependent on the compositor implementation, so the use of this + request should be considered on a case-by-case basis. + + Note that if the transform value includes 90 or 270 degree rotation, + the width of the buffer will become the surface height and the height + of the buffer will become the surface width. + + If transform is not one of the values from the + wl_output.transform enum the invalid_transform protocol error + is raised. + </description> + <arg name="transform" type="int" enum="wl_output.transform" + summary="transform for interpreting buffer contents"/> + </request> + + <!-- Version 3 additions --> + + <request name="set_buffer_scale" since="3"> + <description summary="sets the buffer scaling factor"> + This request sets an optional scaling factor on how the compositor + interprets the contents of the buffer attached to the window. + + Buffer scale is double-buffered state, see wl_surface.commit. + + A newly created surface has its buffer scale set to 1. + + wl_surface.set_buffer_scale changes the pending buffer scale. + wl_surface.commit copies the pending buffer scale to the current one. + Otherwise, the pending and current values are never changed. + + The purpose of this request is to allow clients to supply higher + resolution buffer data for use on high resolution outputs. It is + intended that you pick the same buffer scale as the scale of the + output that the surface is displayed on. This means the compositor + can avoid scaling when rendering the surface on that output. + + Note that if the scale is larger than 1, then you have to attach + a buffer that is larger (by a factor of scale in each dimension) + than the desired surface size. + + If scale is not positive the invalid_scale protocol error is + raised. + </description> + <arg name="scale" type="int" + summary="positive scale for interpreting buffer contents"/> + </request> + + <!-- Version 4 additions --> + <request name="damage_buffer" since="4"> + <description summary="mark part of the surface damaged using buffer coordinates"> + This request is used to describe the regions where the pending + buffer is different from the current surface contents, and where + the surface therefore needs to be repainted. The compositor + ignores the parts of the damage that fall outside of the surface. + + Damage is double-buffered state, see wl_surface.commit. + + The damage rectangle is specified in buffer coordinates, + where x and y specify the upper left corner of the damage rectangle. + + The initial value for pending damage is empty: no damage. + wl_surface.damage_buffer adds pending damage: the new pending + damage is the union of old pending damage and the given rectangle. + + wl_surface.commit assigns pending damage as the current damage, + and clears pending damage. The server will clear the current + damage as it repaints the surface. + + This request differs from wl_surface.damage in only one way - it + takes damage in buffer coordinates instead of surface-local + coordinates. While this generally is more intuitive than surface + coordinates, it is especially desirable when using wp_viewport + or when a drawing library (like EGL) is unaware of buffer scale + and buffer transform. + + Note: Because buffer transformation changes and damage requests may + be interleaved in the protocol stream, it is impossible to determine + the actual mapping between surface and buffer damage until + wl_surface.commit time. Therefore, compositors wishing to take both + kinds of damage into account will have to accumulate damage from the + two requests separately and only transform from one to the other + after receiving the wl_surface.commit. + </description> + + <arg name="x" type="int" summary="buffer-local x coordinate"/> + <arg name="y" type="int" summary="buffer-local y coordinate"/> + <arg name="width" type="int" summary="width of damage rectangle"/> + <arg name="height" type="int" summary="height of damage rectangle"/> + </request> + </interface> + + <interface name="wl_seat" version="5"> + <description summary="group of input devices"> + A seat is a group of keyboards, pointer and touch devices. This + object is published as a global during start up, or when such a + device is hot plugged. A seat typically has a pointer and + maintains a keyboard focus and a pointer focus. + </description> + + <enum name="capability" bitfield="true"> + <description summary="seat capability bitmask"> + This is a bitmask of capabilities this seat has; if a member is + set, then it is present on the seat. + </description> + <entry name="pointer" value="1" summary="the seat has pointer devices"/> + <entry name="keyboard" value="2" summary="the seat has one or more keyboards"/> + <entry name="touch" value="4" summary="the seat has touch devices"/> + </enum> + + <event name="capabilities"> + <description summary="seat capabilities changed"> + This is emitted whenever a seat gains or loses the pointer, + keyboard or touch capabilities. The argument is a capability + enum containing the complete set of capabilities this seat has. + + When the pointer capability is added, a client may create a + wl_pointer object using the wl_seat.get_pointer request. This object + will receive pointer events until the capability is removed in the + future. + + When the pointer capability is removed, a client should destroy the + wl_pointer objects associated with the seat where the capability was + removed, using the wl_pointer.release request. No further pointer + events will be received on these objects. + + In some compositors, if a seat regains the pointer capability and a + client has a previously obtained wl_pointer object of version 4 or + less, that object may start sending pointer events again. This + behavior is considered a misinterpretation of the intended behavior + and must not be relied upon by the client. wl_pointer objects of + version 5 or later must not send events if created before the most + recent event notifying the client of an added pointer capability. + + The above behavior also applies to wl_keyboard and wl_touch with the + keyboard and touch capabilities, respectively. + </description> + <arg name="capabilities" type="uint" enum="capability" summary="capabilities of the seat"/> + </event> + + <request name="get_pointer"> + <description summary="return pointer object"> + The ID provided will be initialized to the wl_pointer interface + for this seat. + + This request only takes effect if the seat has the pointer + capability, or has had the pointer capability in the past. + It is a protocol violation to issue this request on a seat that has + never had the pointer capability. + </description> + <arg name="id" type="new_id" interface="wl_pointer" summary="seat pointer"/> + </request> + + <request name="get_keyboard"> + <description summary="return keyboard object"> + The ID provided will be initialized to the wl_keyboard interface + for this seat. + + This request only takes effect if the seat has the keyboard + capability, or has had the keyboard capability in the past. + It is a protocol violation to issue this request on a seat that has + never had the keyboard capability. + </description> + <arg name="id" type="new_id" interface="wl_keyboard" summary="seat keyboard"/> + </request> + + <request name="get_touch"> + <description summary="return touch object"> + The ID provided will be initialized to the wl_touch interface + for this seat. + + This request only takes effect if the seat has the touch + capability, or has had the touch capability in the past. + It is a protocol violation to issue this request on a seat that has + never had the touch capability. + </description> + <arg name="id" type="new_id" interface="wl_touch" summary="seat touch interface"/> + </request> + + <!-- Version 2 additions --> + + <event name="name" since="2"> + <description summary="unique identifier for this seat"> + In a multiseat configuration this can be used by the client to help + identify which physical devices the seat represents. Based on + the seat configuration used by the compositor. + </description> + <arg name="name" type="string" summary="seat identifier"/> + </event> + + <!-- Version 5 additions --> + + <request name="release" type="destructor" since="5"> + <description summary="release the seat object"> + Using this request a client can tell the server that it is not going to + use the seat object anymore. + </description> + </request> + + </interface> + + <interface name="wl_pointer" version="5"> + <description summary="pointer input device"> + The wl_pointer interface represents one or more input devices, + such as mice, which control the pointer location and pointer_focus + of a seat. + + The wl_pointer interface generates motion, enter and leave + events for the surfaces that the pointer is located over, + and button and axis events for button presses, button releases + and scrolling. + </description> + + <enum name="error"> + <entry name="role" value="0" summary="given wl_surface has another role"/> + </enum> + + <request name="set_cursor"> + <description summary="set the pointer surface"> + Set the pointer surface, i.e., the surface that contains the + pointer image (cursor). This request gives the surface the role + of a cursor. If the surface already has another role, it raises + a protocol error. + + The cursor actually changes only if the pointer + focus for this device is one of the requesting client's surfaces + or the surface parameter is the current pointer surface. If + there was a previous surface set with this request it is + replaced. If surface is NULL, the pointer image is hidden. + + The parameters hotspot_x and hotspot_y define the position of + the pointer surface relative to the pointer location. Its + top-left corner is always at (x, y) - (hotspot_x, hotspot_y), + where (x, y) are the coordinates of the pointer location, in + surface-local coordinates. + + On surface.attach requests to the pointer surface, hotspot_x + and hotspot_y are decremented by the x and y parameters + passed to the request. Attach must be confirmed by + wl_surface.commit as usual. + + The hotspot can also be updated by passing the currently set + pointer surface to this request with new values for hotspot_x + and hotspot_y. + + The current and pending input regions of the wl_surface are + cleared, and wl_surface.set_input_region is ignored until the + wl_surface is no longer used as the cursor. When the use as a + cursor ends, the current and pending input regions become + undefined, and the wl_surface is unmapped. + </description> + + <arg name="serial" type="uint" summary="serial number of the enter event"/> + <arg name="surface" type="object" interface="wl_surface" allow-null="true" + summary="pointer surface"/> + <arg name="hotspot_x" type="int" summary="surface-local x coordinate"/> + <arg name="hotspot_y" type="int" summary="surface-local y coordinate"/> + </request> + + <event name="enter"> + <description summary="enter event"> + Notification that this seat's pointer is focused on a certain + surface. + + When a seat's focus enters a surface, the pointer image + is undefined and a client should respond to this event by setting + an appropriate pointer image with the set_cursor request. + </description> + + <arg name="serial" type="uint" summary="serial number of the enter event"/> + <arg name="surface" type="object" interface="wl_surface" summary="surface entered by the pointer"/> + <arg name="surface_x" type="fixed" summary="surface-local x coordinate"/> + <arg name="surface_y" type="fixed" summary="surface-local y coordinate"/> + </event> + + <event name="leave"> + <description summary="leave event"> + Notification that this seat's pointer is no longer focused on + a certain surface. + + The leave notification is sent before the enter notification + for the new focus. + </description> + <arg name="serial" type="uint" summary="serial number of the leave event"/> + <arg name="surface" type="object" interface="wl_surface" summary="surface left by the pointer"/> + </event> + + <event name="motion"> + <description summary="pointer motion event"> + Notification of pointer location change. The arguments + surface_x and surface_y are the location relative to the + focused surface. + </description> + + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="surface_x" type="fixed" summary="surface-local x coordinate"/> + <arg name="surface_y" type="fixed" summary="surface-local y coordinate"/> + </event> + + <enum name="button_state"> + <description summary="physical button state"> + Describes the physical state of a button that produced the button + event. + </description> + <entry name="released" value="0" summary="the button is not pressed"/> + <entry name="pressed" value="1" summary="the button is pressed"/> + </enum> + + <event name="button"> + <description summary="pointer button event"> + Mouse button click and release notifications. + + The location of the click is given by the last motion or + enter event. + The time argument is a timestamp with millisecond + granularity, with an undefined base. + </description> + + <arg name="serial" type="uint" summary="serial number of the button event"/> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="button" type="uint" summary="button that produced the event"/> + <arg name="state" type="uint" enum="button_state" summary="physical state of the button"/> + </event> + + <enum name="axis"> + <description summary="axis types"> + Describes the axis types of scroll events. + </description> + <entry name="vertical_scroll" value="0" summary="vertical axis"/> + <entry name="horizontal_scroll" value="1" summary="horizontal axis"/> + </enum> + + <event name="axis"> + <description summary="axis event"> + Scroll and other axis notifications. + + For scroll events (vertical and horizontal scroll axes), the + value parameter is the length of a vector along the specified + axis in a coordinate space identical to those of motion events, + representing a relative movement along the specified axis. + + For devices that support movements non-parallel to axes multiple + axis events will be emitted. + + When applicable, for example for touch pads, the server can + choose to emit scroll events where the motion vector is + equivalent to a motion event vector. + + When applicable, a client can transform its content relative to the + scroll distance. + </description> + + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="axis" type="uint" enum="axis" summary="axis type"/> + <arg name="value" type="fixed" summary="length of vector in surface-local coordinate space"/> + </event> + + <!-- Version 3 additions --> + + <request name="release" type="destructor" since="3"> + <description summary="release the pointer object"> + Using this request a client can tell the server that it is not going to + use the pointer object anymore. + + This request destroys the pointer proxy object, so clients must not call + wl_pointer_destroy() after using this request. + </description> + </request> + + <!-- Version 5 additions --> + + <event name="frame" since="5"> + <description summary="end of a pointer event sequence"> + Indicates the end of a set of events that logically belong together. + A client is expected to accumulate the data in all events within the + frame before proceeding. + + All wl_pointer events before a wl_pointer.frame event belong + logically together. For example, in a diagonal scroll motion the + compositor will send an optional wl_pointer.axis_source event, two + wl_pointer.axis events (horizontal and vertical) and finally a + wl_pointer.frame event. The client may use this information to + calculate a diagonal vector for scrolling. + + When multiple wl_pointer.axis events occur within the same frame, + the motion vector is the combined motion of all events. + When a wl_pointer.axis and a wl_pointer.axis_stop event occur within + the same frame, this indicates that axis movement in one axis has + stopped but continues in the other axis. + When multiple wl_pointer.axis_stop events occur within the same + frame, this indicates that these axes stopped in the same instance. + + A wl_pointer.frame event is sent for every logical event group, + even if the group only contains a single wl_pointer event. + Specifically, a client may get a sequence: motion, frame, button, + frame, axis, frame, axis_stop, frame. + + The wl_pointer.enter and wl_pointer.leave events are logical events + generated by the compositor and not the hardware. These events are + also grouped by a wl_pointer.frame. When a pointer moves from one + surface to another, a compositor should group the + wl_pointer.leave event within the same wl_pointer.frame. + However, a client must not rely on wl_pointer.leave and + wl_pointer.enter being in the same wl_pointer.frame. + Compositor-specific policies may require the wl_pointer.leave and + wl_pointer.enter event being split across multiple wl_pointer.frame + groups. + </description> + </event> + + <enum name="axis_source"> + <description summary="axis source types"> + Describes the source types for axis events. This indicates to the + client how an axis event was physically generated; a client may + adjust the user interface accordingly. For example, scroll events + from a "finger" source may be in a smooth coordinate space with + kinetic scrolling whereas a "wheel" source may be in discrete steps + of a number of lines. + + The "continuous" axis source is a device generating events in a + continuous coordinate space, but using something other than a + finger. One example for this source is button-based scrolling where + the vertical motion of a device is converted to scroll events while + a button is held down. + </description> + <entry name="wheel" value="0" summary="a physical wheel" /> + <entry name="finger" value="1" summary="finger on a touch surface" /> + <entry name="continuous" value="2" summary="continuous coordinate space"/> + </enum> + + <event name="axis_source" since="5"> + <description summary="axis source event"> + Source information for scroll and other axes. + + This event does not occur on its own. It is sent before a + wl_pointer.frame event and carries the source information for + all events within that frame. + + The source specifies how this event was generated. If the source is + wl_pointer.axis_source.finger, a wl_pointer.axis_stop event will be + sent when the user lifts the finger off the device. + + If the source is wl_pointer axis_source.wheel or + wl_pointer.axis_source.continuous, a wl_pointer.axis_stop event may + or may not be sent. Whether a compositor sends an axis_stop event + for these sources is hardware-specific and implementation-dependent; + clients must not rely on receiving an axis_stop event for these + scroll sources and should treat scroll sequences from these scroll + sources as unterminated by default. + + This event is optional. If the source is unknown for a particular + axis event sequence, no event is sent. + Only one wl_pointer.axis_source event is permitted per frame. + + The order of wl_pointer.axis_discrete and wl_pointer.axis_source is + not guaranteed. + </description> + <arg name="axis_source" type="uint" enum="axis_source" summary="source of the axis event"/> + </event> + + <event name="axis_stop" since="5"> + <description summary="axis stop event"> + Stop notification for scroll and other axes. + + For some wl_pointer.axis_source types, a wl_pointer.axis_stop event + is sent to notify a client that the axis sequence has terminated. + This enables the client to implement kinetic scrolling. + See the wl_pointer.axis_source documentation for information on when + this event may be generated. + + Any wl_pointer.axis events with the same axis_source after this + event should be considered as the start of a new axis motion. + + The timestamp is to be interpreted identical to the timestamp in the + wl_pointer.axis event. The timestamp value may be the same as a + preceding wl_pointer.axis event. + </description> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="axis" type="uint" enum="axis" summary="the axis stopped with this event"/> + </event> + + <event name="axis_discrete" since="5"> + <description summary="axis click event"> + Discrete step information for scroll and other axes. + + This event carries the axis value of the wl_pointer.axis event in + discrete steps (e.g. mouse wheel clicks). + + This event does not occur on its own, it is coupled with a + wl_pointer.axis event that represents this axis value on a + continuous scale. The protocol guarantees that each axis_discrete + event is always followed by exactly one axis event with the same + axis number within the same wl_pointer.frame. Note that the protocol + allows for other events to occur between the axis_discrete and + its coupled axis event, including other axis_discrete or axis + events. + + This event is optional; continuous scrolling devices + like two-finger scrolling on touchpads do not have discrete + steps and do not generate this event. + + The discrete value carries the directional information. e.g. a value + of -2 is two steps towards the negative direction of this axis. + + The axis number is identical to the axis number in the associated + axis event. + + The order of wl_pointer.axis_discrete and wl_pointer.axis_source is + not guaranteed. + </description> + <arg name="axis" type="uint" enum="axis" summary="axis type"/> + <arg name="discrete" type="int" summary="number of steps"/> + </event> + </interface> + + <interface name="wl_keyboard" version="5"> + <description summary="keyboard input device"> + The wl_keyboard interface represents one or more keyboards + associated with a seat. + </description> + + <enum name="keymap_format"> + <description summary="keyboard mapping format"> + This specifies the format of the keymap provided to the + client with the wl_keyboard.keymap event. + </description> + <entry name="no_keymap" value="0" + summary="no keymap; client must understand how to interpret the raw keycode"/> + <entry name="xkb_v1" value="1" + summary="libxkbcommon compatible; to determine the xkb keycode, clients must add 8 to the key event keycode"/> + </enum> + + <event name="keymap"> + <description summary="keyboard mapping"> + This event provides a file descriptor to the client which can be + memory-mapped to provide a keyboard mapping description. + </description> + <arg name="format" type="uint" enum="keymap_format" summary="keymap format"/> + <arg name="fd" type="fd" summary="keymap file descriptor"/> + <arg name="size" type="uint" summary="keymap size, in bytes"/> + </event> + + <event name="enter"> + <description summary="enter event"> + Notification that this seat's keyboard focus is on a certain + surface. + </description> + <arg name="serial" type="uint" summary="serial number of the enter event"/> + <arg name="surface" type="object" interface="wl_surface" summary="surface gaining keyboard focus"/> + <arg name="keys" type="array" summary="the currently pressed keys"/> + </event> + + <event name="leave"> + <description summary="leave event"> + Notification that this seat's keyboard focus is no longer on + a certain surface. + + The leave notification is sent before the enter notification + for the new focus. + </description> + <arg name="serial" type="uint" summary="serial number of the leave event"/> + <arg name="surface" type="object" interface="wl_surface" summary="surface that lost keyboard focus"/> + </event> + + <enum name="key_state"> + <description summary="physical key state"> + Describes the physical state of a key that produced the key event. + </description> + <entry name="released" value="0" summary="key is not pressed"/> + <entry name="pressed" value="1" summary="key is pressed"/> + </enum> + + <event name="key"> + <description summary="key event"> + A key was pressed or released. + The time argument is a timestamp with millisecond + granularity, with an undefined base. + </description> + + <arg name="serial" type="uint" summary="serial number of the key event"/> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="key" type="uint" summary="key that produced the event"/> + <arg name="state" type="uint" enum="key_state" summary="physical state of the key"/> + </event> + + <event name="modifiers"> + <description summary="modifier and group state"> + Notifies clients that the modifier and/or group state has + changed, and it should update its local state. + </description> + + <arg name="serial" type="uint" summary="serial number of the modifiers event"/> + <arg name="mods_depressed" type="uint" summary="depressed modifiers"/> + <arg name="mods_latched" type="uint" summary="latched modifiers"/> + <arg name="mods_locked" type="uint" summary="locked modifiers"/> + <arg name="group" type="uint" summary="keyboard layout"/> + </event> + + <!-- Version 3 additions --> + + <request name="release" type="destructor" since="3"> + <description summary="release the keyboard object"/> + </request> + + <!-- Version 4 additions --> + + <event name="repeat_info" since="4"> + <description summary="repeat rate and delay"> + Informs the client about the keyboard's repeat rate and delay. + + This event is sent as soon as the wl_keyboard object has been created, + and is guaranteed to be received by the client before any key press + event. + + Negative values for either rate or delay are illegal. A rate of zero + will disable any repeating (regardless of the value of delay). + + This event can be sent later on as well with a new value if necessary, + so clients should continue listening for the event past the creation + of wl_keyboard. + </description> + + <arg name="rate" type="int" + summary="the rate of repeating keys in characters per second"/> + <arg name="delay" type="int" + summary="delay in milliseconds since key down until repeating starts"/> + </event> + </interface> + + <interface name="wl_touch" version="5"> + <description summary="touchscreen input device"> + The wl_touch interface represents a touchscreen + associated with a seat. + + Touch interactions can consist of one or more contacts. + For each contact, a series of events is generated, starting + with a down event, followed by zero or more motion events, + and ending with an up event. Events relating to the same + contact point can be identified by the ID of the sequence. + </description> + + <event name="down"> + <description summary="touch down event and beginning of a touch sequence"> + A new touch point has appeared on the surface. This touch point is + assigned a unique ID. Future events from this touch point reference + this ID. The ID ceases to be valid after a touch up event and may be + reused in the future. + </description> + <arg name="serial" type="uint" summary="serial number of the touch down event"/> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="surface" type="object" interface="wl_surface" summary="surface touched"/> + <arg name="id" type="int" summary="the unique ID of this touch point"/> + <arg name="x" type="fixed" summary="surface-local x coordinate"/> + <arg name="y" type="fixed" summary="surface-local y coordinate"/> + </event> + + <event name="up"> + <description summary="end of a touch event sequence"> + The touch point has disappeared. No further events will be sent for + this touch point and the touch point's ID is released and may be + reused in a future touch down event. + </description> + <arg name="serial" type="uint" summary="serial number of the touch up event"/> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="id" type="int" summary="the unique ID of this touch point"/> + </event> + + <event name="motion"> + <description summary="update of touch point coordinates"> + A touch point has changed coordinates. + </description> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="id" type="int" summary="the unique ID of this touch point"/> + <arg name="x" type="fixed" summary="surface-local x coordinate"/> + <arg name="y" type="fixed" summary="surface-local y coordinate"/> + </event> + + <event name="frame"> + <description summary="end of touch frame event"> + Indicates the end of a contact point list. + </description> + </event> + + <event name="cancel"> + <description summary="touch session cancelled"> + Sent if the compositor decides the touch stream is a global + gesture. No further events are sent to the clients from that + particular gesture. Touch cancellation applies to all touch points + currently active on this client's surface. The client is + responsible for finalizing the touch points, future touch points on + this surface may reuse the touch point ID. + </description> + </event> + + <!-- Version 3 additions --> + + <request name="release" type="destructor" since="3"> + <description summary="release the touch object"/> + </request> + </interface> + + <interface name="wl_output" version="3"> + <description summary="compositor output region"> + An output describes part of the compositor geometry. The + compositor works in the 'compositor coordinate system' and an + output corresponds to a rectangular area in that space that is + actually visible. This typically corresponds to a monitor that + displays part of the compositor space. This object is published + as global during start up, or when a monitor is hotplugged. + </description> + + <enum name="subpixel"> + <description summary="subpixel geometry information"> + This enumeration describes how the physical + pixels on an output are laid out. + </description> + <entry name="unknown" value="0" summary="unknown geometry"/> + <entry name="none" value="1" summary="no geometry"/> + <entry name="horizontal_rgb" value="2" summary="horizontal RGB"/> + <entry name="horizontal_bgr" value="3" summary="horizontal BGR"/> + <entry name="vertical_rgb" value="4" summary="vertical RGB"/> + <entry name="vertical_bgr" value="5" summary="vertical BGR"/> + </enum> + + <enum name="transform"> + <description summary="transform from framebuffer to output"> + This describes the transform that a compositor will apply to a + surface to compensate for the rotation or mirroring of an + output device. + + The flipped values correspond to an initial flip around a + vertical axis followed by rotation. + + The purpose is mainly to allow clients to render accordingly and + tell the compositor, so that for fullscreen surfaces, the + compositor will still be able to scan out directly from client + surfaces. + </description> + + <entry name="normal" value="0" summary="no transform"/> + <entry name="90" value="1" summary="90 degrees counter-clockwise"/> + <entry name="180" value="2" summary="180 degrees counter-clockwise"/> + <entry name="270" value="3" summary="270 degrees counter-clockwise"/> + <entry name="flipped" value="4" summary="180 degree flip around a vertical axis"/> + <entry name="flipped_90" value="5" summary="flip and rotate 90 degrees counter-clockwise"/> + <entry name="flipped_180" value="6" summary="flip and rotate 180 degrees counter-clockwise"/> + <entry name="flipped_270" value="7" summary="flip and rotate 270 degrees counter-clockwise"/> + </enum> + + <event name="geometry"> + <description summary="properties of the output"> + The geometry event describes geometric properties of the output. + The event is sent when binding to the output object and whenever + any of the properties change. + </description> + <arg name="x" type="int" + summary="x position within the global compositor space"/> + <arg name="y" type="int" + summary="y position within the global compositor space"/> + <arg name="physical_width" type="int" + summary="width in millimeters of the output"/> + <arg name="physical_height" type="int" + summary="height in millimeters of the output"/> + <arg name="subpixel" type="int" enum="subpixel" + summary="subpixel orientation of the output"/> + <arg name="make" type="string" + summary="textual description of the manufacturer"/> + <arg name="model" type="string" + summary="textual description of the model"/> + <arg name="transform" type="int" enum="transform" + summary="transform that maps framebuffer to output"/> + </event> + + <enum name="mode" bitfield="true"> + <description summary="mode information"> + These flags describe properties of an output mode. + They are used in the flags bitfield of the mode event. + </description> + <entry name="current" value="0x1" + summary="indicates this is the current mode"/> + <entry name="preferred" value="0x2" + summary="indicates this is the preferred mode"/> + </enum> + + <event name="mode"> + <description summary="advertise available modes for the output"> + The mode event describes an available mode for the output. + + The event is sent when binding to the output object and there + will always be one mode, the current mode. The event is sent + again if an output changes mode, for the mode that is now + current. In other words, the current mode is always the last + mode that was received with the current flag set. + + The size of a mode is given in physical hardware units of + the output device. This is not necessarily the same as + the output size in the global compositor space. For instance, + the output may be scaled, as described in wl_output.scale, + or transformed, as described in wl_output.transform. + </description> + <arg name="flags" type="uint" enum="mode" summary="bitfield of mode flags"/> + <arg name="width" type="int" summary="width of the mode in hardware units"/> + <arg name="height" type="int" summary="height of the mode in hardware units"/> + <arg name="refresh" type="int" summary="vertical refresh rate in mHz"/> + </event> + + <!-- Version 2 additions --> + + <event name="done" since="2"> + <description summary="sent all information about output"> + This event is sent after all other properties have been + sent after binding to the output object and after any + other property changes done after that. This allows + changes to the output properties to be seen as + atomic, even if they happen via multiple events. + </description> + </event> + + <event name="scale" since="2"> + <description summary="output scaling properties"> + This event contains scaling geometry information + that is not in the geometry event. It may be sent after + binding the output object or if the output scale changes + later. If it is not sent, the client should assume a + scale of 1. + + A scale larger than 1 means that the compositor will + automatically scale surface buffers by this amount + when rendering. This is used for very high resolution + displays where applications rendering at the native + resolution would be too small to be legible. + + It is intended that scaling aware clients track the + current output of a surface, and if it is on a scaled + output it should use wl_surface.set_buffer_scale with + the scale of the output. That way the compositor can + avoid scaling the surface, and the client can supply + a higher detail image. + </description> + <arg name="factor" type="int" summary="scaling factor of output"/> + </event> + + <!-- Version 3 additions --> + + <request name="release" type="destructor" since="3"> + <description summary="release the output object"> + Using this request a client can tell the server that it is not going to + use the output object anymore. + </description> + </request> + </interface> + + <interface name="wl_region" version="1"> + <description summary="region interface"> + A region object describes an area. + + Region objects are used to describe the opaque and input + regions of a surface. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy region"> + Destroy the region. This will invalidate the object ID. + </description> + </request> + + <request name="add"> + <description summary="add rectangle to region"> + Add the specified rectangle to the region. + </description> + + <arg name="x" type="int" summary="region-local x coordinate"/> + <arg name="y" type="int" summary="region-local y coordinate"/> + <arg name="width" type="int" summary="rectangle width"/> + <arg name="height" type="int" summary="rectangle height"/> + </request> + + <request name="subtract"> + <description summary="subtract rectangle from region"> + Subtract the specified rectangle from the region. + </description> + + <arg name="x" type="int" summary="region-local x coordinate"/> + <arg name="y" type="int" summary="region-local y coordinate"/> + <arg name="width" type="int" summary="rectangle width"/> + <arg name="height" type="int" summary="rectangle height"/> + </request> + </interface> + + <interface name="wl_subcompositor" version="1"> + <description summary="sub-surface compositing"> + The global interface exposing sub-surface compositing capabilities. + A wl_surface, that has sub-surfaces associated, is called the + parent surface. Sub-surfaces can be arbitrarily nested and create + a tree of sub-surfaces. + + The root surface in a tree of sub-surfaces is the main + surface. The main surface cannot be a sub-surface, because + sub-surfaces must always have a parent. + + A main surface with its sub-surfaces forms a (compound) window. + For window management purposes, this set of wl_surface objects is + to be considered as a single window, and it should also behave as + such. + + The aim of sub-surfaces is to offload some of the compositing work + within a window from clients to the compositor. A prime example is + a video player with decorations and video in separate wl_surface + objects. This should allow the compositor to pass YUV video buffer + processing to dedicated overlay hardware when possible. + </description> + + <request name="destroy" type="destructor"> + <description summary="unbind from the subcompositor interface"> + Informs the server that the client will not be using this + protocol object anymore. This does not affect any other + objects, wl_subsurface objects included. + </description> + </request> + + <enum name="error"> + <entry name="bad_surface" value="0" + summary="the to-be sub-surface is invalid"/> + </enum> + + <request name="get_subsurface"> + <description summary="give a surface the role sub-surface"> + Create a sub-surface interface for the given surface, and + associate it with the given parent surface. This turns a + plain wl_surface into a sub-surface. + + The to-be sub-surface must not already have another role, and it + must not have an existing wl_subsurface object. Otherwise a protocol + error is raised. + </description> + + <arg name="id" type="new_id" interface="wl_subsurface" + summary="the new sub-surface object ID"/> + <arg name="surface" type="object" interface="wl_surface" + summary="the surface to be turned into a sub-surface"/> + <arg name="parent" type="object" interface="wl_surface" + summary="the parent surface"/> + </request> + </interface> + + <interface name="wl_subsurface" version="1"> + <description summary="sub-surface interface to a wl_surface"> + An additional interface to a wl_surface object, which has been + made a sub-surface. A sub-surface has one parent surface. A + sub-surface's size and position are not limited to that of the parent. + Particularly, a sub-surface is not automatically clipped to its + parent's area. + + A sub-surface becomes mapped, when a non-NULL wl_buffer is applied + and the parent surface is mapped. The order of which one happens + first is irrelevant. A sub-surface is hidden if the parent becomes + hidden, or if a NULL wl_buffer is applied. These rules apply + recursively through the tree of surfaces. + + The behaviour of a wl_surface.commit request on a sub-surface + depends on the sub-surface's mode. The possible modes are + synchronized and desynchronized, see methods + wl_subsurface.set_sync and wl_subsurface.set_desync. Synchronized + mode caches the wl_surface state to be applied when the parent's + state gets applied, and desynchronized mode applies the pending + wl_surface state directly. A sub-surface is initially in the + synchronized mode. + + Sub-surfaces have also other kind of state, which is managed by + wl_subsurface requests, as opposed to wl_surface requests. This + state includes the sub-surface position relative to the parent + surface (wl_subsurface.set_position), and the stacking order of + the parent and its sub-surfaces (wl_subsurface.place_above and + .place_below). This state is applied when the parent surface's + wl_surface state is applied, regardless of the sub-surface's mode. + As the exception, set_sync and set_desync are effective immediately. + + The main surface can be thought to be always in desynchronized mode, + since it does not have a parent in the sub-surfaces sense. + + Even if a sub-surface is in desynchronized mode, it will behave as + in synchronized mode, if its parent surface behaves as in + synchronized mode. This rule is applied recursively throughout the + tree of surfaces. This means, that one can set a sub-surface into + synchronized mode, and then assume that all its child and grand-child + sub-surfaces are synchronized, too, without explicitly setting them. + + If the wl_surface associated with the wl_subsurface is destroyed, the + wl_subsurface object becomes inert. Note, that destroying either object + takes effect immediately. If you need to synchronize the removal + of a sub-surface to the parent surface update, unmap the sub-surface + first by attaching a NULL wl_buffer, update parent, and then destroy + the sub-surface. + + If the parent wl_surface object is destroyed, the sub-surface is + unmapped. + </description> + + <request name="destroy" type="destructor"> + <description summary="remove sub-surface interface"> + The sub-surface interface is removed from the wl_surface object + that was turned into a sub-surface with a + wl_subcompositor.get_subsurface request. The wl_surface's association + to the parent is deleted, and the wl_surface loses its role as + a sub-surface. The wl_surface is unmapped. + </description> + </request> + + <enum name="error"> + <entry name="bad_surface" value="0" + summary="wl_surface is not a sibling or the parent"/> + </enum> + + <request name="set_position"> + <description summary="reposition the sub-surface"> + This schedules a sub-surface position change. + The sub-surface will be moved so that its origin (top left + corner pixel) will be at the location x, y of the parent surface + coordinate system. The coordinates are not restricted to the parent + surface area. Negative values are allowed. + + The scheduled coordinates will take effect whenever the state of the + parent surface is applied. When this happens depends on whether the + parent surface is in synchronized mode or not. See + wl_subsurface.set_sync and wl_subsurface.set_desync for details. + + If more than one set_position request is invoked by the client before + the commit of the parent surface, the position of a new request always + replaces the scheduled position from any previous request. + + The initial position is 0, 0. + </description> + + <arg name="x" type="int" summary="x coordinate in the parent surface"/> + <arg name="y" type="int" summary="y coordinate in the parent surface"/> + </request> + + <request name="place_above"> + <description summary="restack the sub-surface"> + This sub-surface is taken from the stack, and put back just + above the reference surface, changing the z-order of the sub-surfaces. + The reference surface must be one of the sibling surfaces, or the + parent surface. Using any other surface, including this sub-surface, + will cause a protocol error. + + The z-order is double-buffered. Requests are handled in order and + applied immediately to a pending state. The final pending state is + copied to the active state the next time the state of the parent + surface is applied. When this happens depends on whether the parent + surface is in synchronized mode or not. See wl_subsurface.set_sync and + wl_subsurface.set_desync for details. + + A new sub-surface is initially added as the top-most in the stack + of its siblings and parent. + </description> + + <arg name="sibling" type="object" interface="wl_surface" + summary="the reference surface"/> + </request> + + <request name="place_below"> + <description summary="restack the sub-surface"> + The sub-surface is placed just below the reference surface. + See wl_subsurface.place_above. + </description> + + <arg name="sibling" type="object" interface="wl_surface" + summary="the reference surface"/> + </request> + + <request name="set_sync"> + <description summary="set sub-surface to synchronized mode"> + Change the commit behaviour of the sub-surface to synchronized + mode, also described as the parent dependent mode. + + In synchronized mode, wl_surface.commit on a sub-surface will + accumulate the committed state in a cache, but the state will + not be applied and hence will not change the compositor output. + The cached state is applied to the sub-surface immediately after + the parent surface's state is applied. This ensures atomic + updates of the parent and all its synchronized sub-surfaces. + Applying the cached state will invalidate the cache, so further + parent surface commits do not (re-)apply old state. + + See wl_subsurface for the recursive effect of this mode. + </description> + </request> + + <request name="set_desync"> + <description summary="set sub-surface to desynchronized mode"> + Change the commit behaviour of the sub-surface to desynchronized + mode, also described as independent or freely running mode. + + In desynchronized mode, wl_surface.commit on a sub-surface will + apply the pending state directly, without caching, as happens + normally with a wl_surface. Calling wl_surface.commit on the + parent surface has no effect on the sub-surface's wl_surface + state. This mode allows a sub-surface to be updated on its own. + + If cached state exists when wl_surface.commit is called in + desynchronized mode, the pending state is added to the cached + state, and applied as a whole. This invalidates the cache. + + Note: even if a sub-surface is set to desynchronized, a parent + sub-surface may override it to behave as synchronized. For details, + see wl_subsurface. + + If a surface's parent surface behaves as desynchronized, then + the cached state is applied on set_desync. + </description> + </request> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-commons-0.21.13/.cargo-checksum.json b/third_party/cargo/vendor/wayland-commons-0.21.13/.cargo-checksum.json new file mode 100644 index 0000000..78c8bbc --- /dev/null +++ b/third_party/cargo/vendor/wayland-commons-0.21.13/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"ab1744e0e86130ee3328269776f4f785429d1c29d80df12e12c1c93168f7231a","examples/manual_global_list.rs":"fac2187f3b1aa082bb3c8f2668054dcfffa4816e2e968d1718008926e0976cf7","src/lib.rs":"3be65d189d91786984e5843ab6e1e12ca974315c195026089c87426413cadc50","src/map.rs":"7c635519a8a9802ad8253d6283e3f64050df44794688f42f66040c888095e36c","src/socket.rs":"211262fad5942b73cf448d694351a455e4d39cfd365304edbfdec663fe161cc7","src/utils.rs":"c281feb8ed87037733e59c5bd681f2222d5c0a85e4158250e17b3dc0a12cee87","src/wire.rs":"679ff119cbb8de6ff0f37ec593abb5c4e1b42153ac60116e9c97c14efdb73867"},"package":"40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec"} \ No newline at end of file diff --git a/third_party/cargo/vendor/wayland-commons-0.21.13/BUILD b/third_party/cargo/vendor/wayland-commons-0.21.13/BUILD new file mode 100644 index 0000000..5a47e42 --- /dev/null +++ b/third_party/cargo/vendor/wayland-commons-0.21.13/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "manual_global_list" with type "example" omitted + +rust_library( + name = "wayland_commons", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/nix-0.14.1:nix", + "//third_party/cargo/vendor/wayland-sys-0.21.13:wayland_sys", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.21.13", + crate_features = [ + "native_lib", + "wayland-sys", + ], +) + diff --git a/third_party/cargo/vendor/wayland-commons-0.21.13/Cargo.toml b/third_party/cargo/vendor/wayland-commons-0.21.13/Cargo.toml new file mode 100644 index 0000000..bb2acec --- /dev/null +++ b/third_party/cargo/vendor/wayland-commons-0.21.13/Cargo.toml @@ -0,0 +1,33 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "wayland-commons" +version = "0.21.13" +authors = ["Victor Berger <victor.berger@m4x.org>"] +description = "Common types and structures used by wayland-client and wayland-server." +documentation = "https://smithay.github.io/wayland-rs/wayland_commons/" +keywords = ["wayland"] +categories = ["gui", "api-bindings"] +license = "MIT" +repository = "https://github.com/smithay/wayland-rs" +[dependencies.nix] +version = "0.14.1" + +[dependencies.wayland-sys] +version = "0.21.13" +optional = true + +[features] +native_lib = ["wayland-sys"] +[badges.travis-ci] +repository = "Smithay/wayland-rs" diff --git a/third_party/cargo/vendor/wayland-commons-0.21.13/examples/manual_global_list.rs b/third_party/cargo/vendor/wayland-commons-0.21.13/examples/manual_global_list.rs new file mode 100644 index 0000000..50dd889 --- /dev/null +++ b/third_party/cargo/vendor/wayland-commons-0.21.13/examples/manual_global_list.rs @@ -0,0 +1,54 @@ +extern crate wayland_commons as wc; + +use std::env; +use std::os::unix::io::{FromRawFd, IntoRawFd}; +use std::os::unix::net::UnixStream; +use std::path::PathBuf; + +use wc::socket::{BufferedSocket, Socket}; +use wc::wire::{Argument, ArgumentType, Message, MessageDesc}; + +fn main() { + let xdg_dir = env::var_os("XDG_RUNTIME_DIR").unwrap(); + let mut path: PathBuf = xdg_dir.into(); + path.push("wayland-0"); + + let socket = UnixStream::connect(path).unwrap(); + let mut socket = BufferedSocket::new(unsafe { Socket::from_raw_fd(socket.into_raw_fd()) }); + + socket + .write_message(&Message { + sender_id: 1, // wl_display + opcode: 1, // get registry + args: vec![ + Argument::NewId(2), // id of the created registry + ], + }) + .unwrap(); + + socket.flush().unwrap(); + + ::std::thread::sleep(::std::time::Duration::from_millis(500)); // sleep 0.5 seconds + + let ret = socket.read_messages( + |id, opcode| match (id, opcode) { + (2, 0) => Some(&GLOBAL_EVENT.signature), + _ => None, + }, + |msg| { + println!("{:?}", msg); + true + }, + ); + println!("{:?}", ret); +} + +/* + * The registry interface + */ + +const GLOBAL_EVENT: MessageDesc = MessageDesc { + name: "global", + signature: &[ArgumentType::Uint, ArgumentType::Str, ArgumentType::Uint], + since: 1, +}; diff --git a/third_party/cargo/vendor/wayland-commons-0.21.13/src/lib.rs b/third_party/cargo/vendor/wayland-commons-0.21.13/src/lib.rs new file mode 100644 index 0000000..cf4c626 --- /dev/null +++ b/third_party/cargo/vendor/wayland-commons-0.21.13/src/lib.rs @@ -0,0 +1,151 @@ +//! Common definitions for wayland +//! +//! This crate hosts common type and traits used to represent wayland messages +//! and routines in the `wayland-client` and `wayland-server` crates. +//! +//! This notably includes the `Interface` trait, which can exhaustively describe +//! any wayland interface. Its implementations are intended to be generated by the +//! `wayland-scanner` crate. +//! +//! The principal user-facing definition provided by this crate is the `Implementation` +//! trait, which as a user of `wayland-client` or `wayland-server` you will be using +//! to define objects able to handle the messages your program receives. Note that +//! this trait is auto-implemented for closures with appropriate signature, for +//! convenience. + +#![warn(missing_docs)] + +#[macro_use] +extern crate nix; +#[cfg(feature = "native_lib")] +extern crate wayland_sys; +#[cfg(feature = "native_lib")] +use std::os::raw::c_void; +#[cfg(feature = "native_lib")] +use wayland_sys::common as syscom; + +pub mod map; +pub mod socket; +pub mod utils; +pub mod wire; + +/// A group of messages +/// +/// This represents a group of message that can be serialized on the protocol wire. +/// Typically the set of events or requests of a single interface. +/// +/// Implementations of this trait are supposed to be +/// generated using the `wayland-scanner` crate. +pub trait MessageGroup: Sized { + /// Wire representation of this MessageGroup + const MESSAGES: &'static [wire::MessageDesc]; + /// The wrapper type for ObjectMap allowing the mapping of Object and + /// NewId arguments to the object map during parsing. + type Map; + /// The opcode of this message + fn opcode(&self) -> u16; + /// Whether this message is a destructor + /// + /// If it is, once send or receive the associated object cannot be used any more. + fn is_destructor(&self) -> bool; + /// Retrieve the child `Object` associated with this message if any + fn child<Meta: self::map::ObjectMetadata>( + opcode: u16, + version: u32, + meta: &Meta, + ) -> Option<::map::Object<Meta>>; + /// Construct a message from its raw representation + fn from_raw(msg: wire::Message, map: &mut Self::Map) -> Result<Self, ()>; + /// Turn this message into its raw representation + fn into_raw(self, send_id: u32) -> wire::Message; + #[cfg(feature = "native_lib")] + /// Construct a message of this group from its C representation + unsafe fn from_raw_c(obj: *mut c_void, opcode: u32, args: *const syscom::wl_argument) + -> Result<Self, ()>; + #[cfg(feature = "native_lib")] + /// Build a C representation of this message + /// + /// It can only be accessed from the provided closure, and this consumes + /// the message. + fn as_raw_c_in<F, T>(self, f: F) -> T + where + F: FnOnce(u32, &mut [syscom::wl_argument]) -> T; +} + +/// The description of a wayland interface +/// +/// Implementations of this trait are supposed to be +/// generated using the `wayland-scanner` crate. +pub trait Interface: 'static { + /// Set of requests associated to this interface + /// + /// Requests are messages from the client to the server + type Request: MessageGroup + 'static; + /// Set of events associated to this interface + /// + /// Events are messages from the server to the client + type Event: MessageGroup + 'static; + /// Name of this interface + const NAME: &'static str; + /// Maximum supported version of this interface + const VERSION: u32; + #[cfg(feature = "native_lib")] + /// Pointer to the C representation of this interface + fn c_interface() -> *const ::syscom::wl_interface; +} + +/// Anonymous interface +/// +/// A special Interface implementation representing an +/// handle to an object for which the interface is not known. +pub struct AnonymousObject; + +/// An empty enum representing a MessageGroup with no messages +pub enum NoMessage {} + +impl Interface for AnonymousObject { + type Request = NoMessage; + type Event = NoMessage; + const NAME: &'static str = "<anonymous>"; + const VERSION: u32 = 0; + #[cfg(feature = "native_lib")] + fn c_interface() -> *const ::syscom::wl_interface { + ::std::ptr::null() + } +} + +#[cfg_attr(tarpaulin, skip)] +impl MessageGroup for NoMessage { + const MESSAGES: &'static [wire::MessageDesc] = &[]; + type Map = (); + fn is_destructor(&self) -> bool { + match *self {} + } + fn opcode(&self) -> u16 { + match *self {} + } + fn child<M: self::map::ObjectMetadata>(_: u16, _: u32, _: &M) -> Option<::map::Object<M>> { + None + } + fn from_raw(_: wire::Message, _: &mut ()) -> Result<Self, ()> { + Err(()) + } + fn into_raw(self, _: u32) -> wire::Message { + match self {} + } + #[cfg(feature = "native_lib")] + unsafe fn from_raw_c( + _obj: *mut c_void, + _opcode: u32, + _args: *const syscom::wl_argument, + ) -> Result<Self, ()> { + Err(()) + } + #[cfg(feature = "native_lib")] + fn as_raw_c_in<F, T>(self, _f: F) -> T + where + F: FnOnce(u32, &mut [syscom::wl_argument]) -> T, + { + match self {} + } +} diff --git a/third_party/cargo/vendor/wayland-commons-0.21.13/src/map.rs b/third_party/cargo/vendor/wayland-commons-0.21.13/src/map.rs new file mode 100644 index 0000000..9dfc8d3 --- /dev/null +++ b/third_party/cargo/vendor/wayland-commons-0.21.13/src/map.rs @@ -0,0 +1,230 @@ +//! Wayland objects map + +use {Interface, MessageGroup, NoMessage}; + +/// Limit separating server-created from client-created objects IDs in the namespace +pub const SERVER_ID_LIMIT: u32 = 0xFF000000; + +/// A trait representing the metadata a wayland implementation +/// may attach to an object. +pub trait ObjectMetadata: Clone { + /// Create the metadata for a child object + /// + /// Mostly needed for client side, to propagate the event queues + fn child(&self) -> Self; +} + +impl ObjectMetadata for () { + fn child(&self) -> () { + () + } +} + +/// The representation of a protocol object +#[derive(Clone)] +pub struct Object<Meta: ObjectMetadata> { + /// Interface name of this object + pub interface: &'static str, + /// Version of this object + pub version: u32, + /// Description of the requests of this object + pub requests: &'static [::wire::MessageDesc], + /// Description of the events of this object + pub events: &'static [::wire::MessageDesc], + /// Metadata associated to this object (ex: its event queue client side) + pub meta: Meta, + /// A function which, from an opcode, a version, and the Meta, creates a child + /// object associated with this event if any + pub childs_from_events: fn(u16, u32, &Meta) -> Option<Object<Meta>>, + /// A function which, from an opcode, a version, and the Meta, creates a child + /// object associated with this request if any + pub childs_from_requests: fn(u16, u32, &Meta) -> Option<Object<Meta>>, +} + +impl<Meta: ObjectMetadata> Object<Meta> { + /// Create an Object corresponding to given interface and version + pub fn from_interface<I: Interface>(version: u32, meta: Meta) -> Object<Meta> { + Object { + interface: I::NAME, + version: version, + requests: I::Request::MESSAGES, + events: I::Event::MESSAGES, + meta: meta, + childs_from_events: childs_from::<I::Event, Meta>, + childs_from_requests: childs_from::<I::Request, Meta>, + } + } + + /// Create an optional `Object` corresponding to the possible `new_id` associated + /// with given event opcode + pub fn event_child(&self, opcode: u16) -> Option<Object<Meta>> { + (self.childs_from_events)(opcode, self.version, &self.meta) + } + + /// Create an optional `Object` corresponding to the possible `new_id` associated + /// with given request opcode + pub fn request_child(&self, opcode: u16) -> Option<Object<Meta>> { + (self.childs_from_requests)(opcode, self.version, &self.meta) + } + + /// Check whether this object is of given interface + pub fn is_interface<I: Interface>(&self) -> bool { + // TODO: we might want to be more robust than that + self.interface == I::NAME + } + + /// Create a placeholder object that will be filled-in by the message logic + pub fn placeholder(meta: Meta) -> Object<Meta> { + Object { + interface: "", + version: 0, + requests: &[], + events: &[], + meta: meta, + childs_from_events: childs_from::<NoMessage, Meta>, + childs_from_requests: childs_from::<NoMessage, Meta>, + } + } +} + +fn childs_from<M: MessageGroup, Meta: ObjectMetadata>( + opcode: u16, + version: u32, + meta: &Meta, +) -> Option<Object<Meta>> { + M::child(opcode, version, meta) +} + +/// A holder for the object store of a connection +/// +/// Keeps track of which object id is associated to which +/// interface object, and which is currently unused. +pub struct ObjectMap<Meta: ObjectMetadata> { + client_objects: Vec<Option<Object<Meta>>>, + server_objects: Vec<Option<Object<Meta>>>, +} + +impl<Meta: ObjectMetadata> ObjectMap<Meta> { + /// Create a new empty object map + pub fn new() -> ObjectMap<Meta> { + ObjectMap { + client_objects: Vec::new(), + server_objects: Vec::new(), + } + } + + /// Find an object in the store + pub fn find(&self, id: u32) -> Option<Object<Meta>> { + if id >= SERVER_ID_LIMIT { + self.server_objects + .get((id - SERVER_ID_LIMIT) as usize) + .and_then(|x| x.clone()) + } else { + self.client_objects.get((id - 1) as usize).and_then(|x| x.clone()) + } + } + + /// Remove an object from the store + /// + /// Does nothing if the object didn't previously exists + pub fn remove(&mut self, id: u32) { + if id >= SERVER_ID_LIMIT { + if let Some(place) = self.server_objects.get_mut((id - SERVER_ID_LIMIT) as usize) { + *place = None; + } + } else { + if let Some(place) = self.client_objects.get_mut((id - 1) as usize) { + *place = None; + } + } + } + + /// Insert given object for given id + /// + /// Can fail if the requested id is not the next free id of this store. + /// (In which case this is a protocol error) + pub fn insert_at(&mut self, id: u32, object: Object<Meta>) -> Result<(), ()> { + if id >= SERVER_ID_LIMIT { + insert_in_at(&mut self.server_objects, (id - SERVER_ID_LIMIT) as usize, object) + } else { + insert_in_at(&mut self.client_objects, (id - 1) as usize, object) + } + } + + /// Allocate a new id for an object in the client namespace + pub fn client_insert_new(&mut self, object: Object<Meta>) -> u32 { + insert_in(&mut self.client_objects, object) + 1 + } + + /// Allocate a new id for an object in the server namespace + pub fn server_insert_new(&mut self, object: Object<Meta>) -> u32 { + insert_in(&mut self.server_objects, object) + SERVER_ID_LIMIT + } + + /// Mutably access an object of the map + pub fn with<T, F: FnOnce(&mut Object<Meta>) -> T>(&mut self, id: u32, f: F) -> Result<T, ()> { + if id >= SERVER_ID_LIMIT { + if let Some(&mut Some(ref mut obj)) = self.server_objects.get_mut((id - SERVER_ID_LIMIT) as usize) + { + Ok(f(obj)) + } else { + Err(()) + } + } else { + if let Some(&mut Some(ref mut obj)) = self.client_objects.get_mut((id - 1) as usize) { + Ok(f(obj)) + } else { + Err(()) + } + } + } + + /// Mutably access all objects of the map in sequence + pub fn with_all<F: FnMut(u32, &mut Object<Meta>)>(&mut self, mut f: F) { + for (id, place) in self.client_objects.iter_mut().enumerate() { + if let Some(ref mut obj) = *place { + f(id as u32 + 1, obj); + } + } + for (id, place) in self.server_objects.iter_mut().enumerate() { + if let Some(ref mut obj) = *place { + f(id as u32 + SERVER_ID_LIMIT, obj); + } + } + } +} + +// insert a new object in a store at the first free place +fn insert_in<Meta: ObjectMetadata>(store: &mut Vec<Option<Object<Meta>>>, object: Object<Meta>) -> u32 { + match store.iter().position(|o| o.is_none()) { + Some(id) => { + store[id] = Some(object); + id as u32 + } + None => { + store.push(Some(object)); + (store.len() - 1) as u32 + } + } +} + +// insert an object at a given place in a store +fn insert_in_at<Meta: ObjectMetadata>( + store: &mut Vec<Option<Object<Meta>>>, + id: usize, + object: Object<Meta>, +) -> Result<(), ()> { + if id > store.len() { + Err(()) + } else if id == store.len() { + store.push(Some(object)); + Ok(()) + } else { + let previous = &mut store[id]; + if !previous.is_none() { + return Err(()); + } + *previous = Some(object); + Ok(()) + } +} diff --git a/third_party/cargo/vendor/wayland-commons-0.21.13/src/socket.rs b/third_party/cargo/vendor/wayland-commons-0.21.13/src/socket.rs new file mode 100644 index 0000000..450cd36 --- /dev/null +++ b/third_party/cargo/vendor/wayland-commons-0.21.13/src/socket.rs @@ -0,0 +1,661 @@ +//! Wayland socket manipulation + +use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; + +use nix::sys::socket; +use nix::sys::uio; +use nix::Result as NixResult; + +use wire::{ArgumentType, Message, MessageParseError, MessageWriteError}; + +/// Maximum number of FD that can be sent in a single socket message +pub const MAX_FDS_OUT: usize = 28; +/// Maximum number of bytes that can be sent in a single socket message +pub const MAX_BYTES_OUT: usize = 4096; + +/* + * Socket + */ + +/// A wayland socket +pub struct Socket { + fd: RawFd, +} + +impl Socket { + /// Send a single message to the socket + /// + /// A single socket message can contain several wayland messages + /// + /// The `fds` slice should not be longer than `MAX_FDS_OUT`, and the `bytes` + /// slice should not be longer than `MAX_BYTES_OUT` otherwise the receiving + /// end may lose some data. + pub fn send_msg(&self, bytes: &[u8], fds: &[RawFd]) -> NixResult<()> { + let iov = [uio::IoVec::from_slice(bytes)]; + if fds.len() > 0 { + let cmsgs = [socket::ControlMessage::ScmRights(fds)]; + socket::sendmsg(self.fd, &iov, &cmsgs, socket::MsgFlags::MSG_DONTWAIT, None)?; + } else { + socket::sendmsg(self.fd, &iov, &[], socket::MsgFlags::MSG_DONTWAIT, None)?; + }; + Ok(()) + } + + /// Receive a single message from the socket + /// + /// Return the number of bytes received and the number of Fds received. + /// + /// Errors with `WouldBlock` is no message is available. + /// + /// A single socket message can contain several wayland messages. + /// + /// The `buffer` slice should be at least `MAX_BYTES_OUT` long and the `fds` + /// slice `MAX_FDS_OUT` long, otherwise some data of the received message may + /// be lost. + pub fn rcv_msg(&self, buffer: &mut [u8], fds: &mut [RawFd]) -> NixResult<(usize, usize)> { + let mut cmsg = cmsg_space!([RawFd; MAX_FDS_OUT]); + let iov = [uio::IoVec::from_mut_slice(buffer)]; + + let msg = socket::recvmsg(self.fd, &iov[..], Some(&mut cmsg), socket::MsgFlags::MSG_DONTWAIT)?; + + let mut fd_count = 0; + let received_fds = msg.cmsgs().flat_map(|cmsg| { + match cmsg { + socket::ControlMessageOwned::ScmRights(s) => s, + _ => Vec::new(), + } + }); + for (fd, place) in received_fds.zip(fds.iter_mut()) { + fd_count += 1; + *place = fd; + } + Ok((msg.bytes, fd_count)) + } +} + +impl FromRawFd for Socket { + unsafe fn from_raw_fd(fd: RawFd) -> Socket { + Socket { fd } + } +} + +impl AsRawFd for Socket { + fn as_raw_fd(&self) -> RawFd { + self.fd + } +} + +impl IntoRawFd for Socket { + fn into_raw_fd(self) -> RawFd { + self.fd + } +} + +impl Drop for Socket { + fn drop(&mut self) { + let _ = ::nix::unistd::close(self.fd); + } +} + +/* + * BufferedSocket + */ + +/// An adapter around a raw Socket that directly handles buffering and +/// conversion from/to wayland messages +pub struct BufferedSocket { + socket: Socket, + in_data: Buffer<u32>, + in_fds: Buffer<RawFd>, + out_data: Buffer<u32>, + out_fds: Buffer<RawFd>, +} + +impl BufferedSocket { + /// Wrap a Socket into a Buffered Socket + pub fn new(socket: Socket) -> BufferedSocket { + BufferedSocket { + socket: socket, + in_data: Buffer::new(2 * MAX_BYTES_OUT / 4), // Incoming buffers are twice as big in order to be + in_fds: Buffer::new(2 * MAX_FDS_OUT), // able to store leftover data if needed + out_data: Buffer::new(MAX_BYTES_OUT / 4), + out_fds: Buffer::new(MAX_FDS_OUT), + } + } + + /// Get direct access to the underlying socket + pub fn get_socket(&mut self) -> &mut Socket { + &mut self.socket + } + + /// Retrieve ownership of the underlying Socket + /// + /// Any leftover content in the internal buffers will be lost + pub fn into_socket(self) -> Socket { + self.socket + } + + /// Flush the contents of the outgoing buffer into the socket + pub fn flush(&mut self) -> NixResult<()> { + { + let words = self.out_data.get_contents(); + let bytes = unsafe { ::std::slice::from_raw_parts(words.as_ptr() as *const u8, words.len() * 4) }; + let fds = self.out_fds.get_contents(); + self.socket.send_msg(bytes, fds)?; + } + self.out_data.clear(); + self.out_fds.clear(); + Ok(()) + } + + // internal method + // + // attempts to write a message in the internal out buffers, + // returns true if successful + // + // if false is returned, it means there is not enough space + // in the buffer + fn attempt_write_message(&mut self, msg: &Message) -> NixResult<bool> { + match msg.write_to_buffers( + self.out_data.get_writable_storage(), + self.out_fds.get_writable_storage(), + ) { + Ok((bytes_out, fds_out)) => { + self.out_data.advance(bytes_out); + self.out_fds.advance(fds_out); + Ok(true) + } + Err(MessageWriteError::BufferTooSmall) => Ok(false), + Err(MessageWriteError::DupFdFailed(e)) => Err(e), + } + } + + /// Write a message to the outgoing buffer + /// + /// This method may flush the internal buffer if necessary (if it is full). + /// + /// If the message is too big to fit in the buffer, the error `Error::Sys(E2BIG)` + /// will be returned. + pub fn write_message(&mut self, msg: &Message) -> NixResult<()> { + if !self.attempt_write_message(msg)? { + // the attempt failed, there is not enough space in the buffer + // we need to flush it + self.flush()?; + if !self.attempt_write_message(msg)? { + // If this fails again, this means the message is too big + // to be transmitted at all + return Err(::nix::Error::Sys(::nix::errno::Errno::E2BIG)); + } + } + Ok(()) + } + + /// Try to fill the incoming buffers of this socket, to prepare + /// a new round of parsing. + pub fn fill_incoming_buffers(&mut self) -> NixResult<()> { + // clear the buffers if they have no content + if !self.in_data.has_content() { + self.in_data.clear(); + } + if !self.in_fds.has_content() { + self.in_fds.clear(); + } + // receive a message + let (in_bytes, in_fds) = { + let words = self.in_data.get_writable_storage(); + let bytes = + unsafe { ::std::slice::from_raw_parts_mut(words.as_ptr() as *mut u8, words.len() * 4) }; + let fds = self.in_fds.get_writable_storage(); + self.socket.rcv_msg(bytes, fds)? + }; + if in_bytes == 0 { + // the other end of the socket was closed + return Err(::nix::Error::Sys(::nix::errno::Errno::EPIPE)); + } + // advance the storage + self.in_data + .advance(in_bytes / 4 + if in_bytes % 4 > 0 { 1 } else { 0 }); + self.in_fds.advance(in_fds); + Ok(()) + } + + /// Read and deserialize a single message from the incoming buffers socket + /// + /// This method requires one closure that given an object id and an opcode, + /// must provide the signature of the associated request/event, in the form of + /// a `&'static [ArgumentType]`. If it returns `None`, meaning that + /// the couple object/opcode does not exist, an error will be returned. + /// + /// There are 3 possibilities of return value: + /// + /// - `Ok(Ok(msg))`: no error occurred, this is the message + /// - `Ok(Err(e))`: either a malformed message was encountered or we need more data, + /// in the latter case you need to try calling `fill_incoming_buffers()`. + /// - `Err(e)`: an I/O error occurred reading from the socked, details are in `e` + /// (this can be a "wouldblock" error, which just means that no message is available + /// to read) + pub fn read_one_message<F>(&mut self, mut signature: F) -> Result<Message, MessageParseError> + where + F: FnMut(u32, u16) -> Option<&'static [ArgumentType]>, + { + let (msg, read_data, read_fd) = { + let data = self.in_data.get_contents(); + let fds = self.in_fds.get_contents(); + if data.len() < 2 { + return Err(MessageParseError::MissingData); + } + let object_id = data[0]; + let opcode = (data[1] & 0x0000FFFF) as u16; + if let Some(sig) = signature(object_id, opcode) { + match Message::from_raw(data, sig, fds) { + Ok((msg, rest_data, rest_fds)) => { + (msg, data.len() - rest_data.len(), fds.len() - rest_fds.len()) + } + // TODO: gracefully handle wayland messages split across unix messages ? + Err(e) => return Err(e), + } + } else { + // no signature found ? + return Err(MessageParseError::Malformed); + } + }; + + self.in_data.offset(read_data); + self.in_fds.offset(read_fd); + + Ok(msg) + } + + /// Read and deserialize messages from the socket + /// + /// This method requires two closures: + /// + /// - The first one, given an object id and an opcode, must provide + /// the signature of the associated request/event, in the form of + /// a `&'static [ArgumentType]`. If it returns `None`, meaning that + /// the couple object/opcode does not exist, the parsing will be + /// prematurely interrupted and this method will return a + /// `MessageParseError::Malformed` error. + /// - The second closure is charged to process the parsed message. If it + /// returns `false`, the iteration will be prematurely stopped. + /// + /// In both cases of early stopping, the remaining unused data will be left + /// in the buffers, and will start to be processed at the next call of this + /// method. + /// + /// There are 3 possibilities of return value: + /// + /// - `Ok(Ok(n))`: no error occurred, `n` messages where processed + /// - `Ok(Err(MessageParseError::Malformed))`: a malformed message was encountered + /// (this is a protocol error and is supposed to be fatal to the connection). + /// - `Err(e)`: an I/O error occurred reading from the socked, details are in `e` + /// (this can be a "wouldblock" error, which just means that no message is available + /// to read) + pub fn read_messages<F1, F2>( + &mut self, + mut signature: F1, + mut callback: F2, + ) -> NixResult<Result<usize, MessageParseError>> + where + F1: FnMut(u32, u16) -> Option<&'static [ArgumentType]>, + F2: FnMut(Message) -> bool, + { + // message parsing + let mut dispatched = 0; + + loop { + let mut err = None; + // first parse any leftover messages + loop { + match self.read_one_message(&mut signature) { + Ok(msg) => { + let keep_going = callback(msg); + dispatched += 1; + if !keep_going { + break; + } + } + Err(e) => { + err = Some(e); + break; + } + } + } + + // copy back any leftover content to the front of the buffer + self.in_data.move_to_front(); + self.in_fds.move_to_front(); + + if let Some(MessageParseError::Malformed) = err { + // early stop here + return Ok(Err(MessageParseError::Malformed)); + } + + if err.is_none() && self.in_data.has_content() { + // we stopped reading without error while there is content? That means + // the user requested an early stopping + return Ok(Ok(dispatched)); + } + + // now, try to get more data + match self.fill_incoming_buffers() { + Ok(()) => (), + Err(e @ ::nix::Error::Sys(::nix::errno::Errno::EAGAIN)) => { + // stop looping, returning Ok() or EAGAIN depending on whether messages + // were dispatched + if dispatched == 0 { + return Err(e); + } else { + break; + } + } + Err(e) => return Err(e), + } + } + + Ok(Ok(dispatched)) + } +} + +/* + * Buffer + */ + +struct Buffer<T: Copy> { + storage: Vec<T>, + occupied: usize, + offset: usize, +} + +impl<T: Copy + Default> Buffer<T> { + fn new(size: usize) -> Buffer<T> { + Buffer { + storage: vec![T::default(); size], + occupied: 0, + offset: 0, + } + } + + /// Check if this buffer has content to read + fn has_content(&self) -> bool { + self.occupied > self.offset + } + + /// Advance the internal counter of occupied space + fn advance(&mut self, bytes: usize) { + self.occupied += bytes; + } + + /// Advance the read offset of current occupied space + fn offset(&mut self, bytes: usize) { + self.offset += bytes; + } + + /// Clears the contents of the buffer + /// + /// This only sets the counter of occupied space back to zero, + /// allowing previous content to be overwritten. + fn clear(&mut self) { + self.occupied = 0; + self.offset = 0; + } + + /// Get the current contents of the occupied space of the buffer + fn get_contents(&self) -> &[T] { + &self.storage[(self.offset)..(self.occupied)] + } + + /// Get mutable access to the unoccupied space of the buffer + fn get_writable_storage(&mut self) -> &mut [T] { + &mut self.storage[(self.occupied)..] + } + + /// Move the unread contents of the buffer to the front, to ensure + /// maximal write space availability + fn move_to_front(&mut self) { + unsafe { + ::std::ptr::copy( + &self.storage[self.offset] as *const T, + &mut self.storage[0] as *mut T, + self.occupied - self.offset, + ); + } + self.occupied -= self.offset; + self.offset = 0; + } +} + +#[cfg(test)] +mod tests { + use super::*; + use wire::{Argument, ArgumentType, Message}; + + use std::ffi::CString; + + fn same_file(a: RawFd, b: RawFd) -> bool { + let stat1 = ::nix::sys::stat::fstat(a).unwrap(); + let stat2 = ::nix::sys::stat::fstat(b).unwrap(); + stat1.st_dev == stat2.st_dev && stat1.st_ino == stat2.st_ino + } + + // check if two messages are equal + // + // if arguments contain FDs, check that the fd point to + // the same file, rather than are the same number. + fn assert_eq_msgs(msg1: &Message, msg2: &Message) { + assert_eq!(msg1.sender_id, msg2.sender_id); + assert_eq!(msg1.opcode, msg2.opcode); + assert_eq!(msg1.args.len(), msg2.args.len()); + for (arg1, arg2) in msg1.args.iter().zip(msg2.args.iter()) { + if let (&Argument::Fd(fd1), &Argument::Fd(fd2)) = (arg1, arg2) { + assert!(same_file(fd1, fd2)); + } else { + assert_eq!(arg1, arg2); + } + } + } + + #[test] + fn write_read_cycle() { + let msg = Message { + sender_id: 42, + opcode: 7, + args: vec![ + Argument::Uint(3), + Argument::Fixed(-89), + Argument::Str(CString::new(&b"I like trains!"[..]).unwrap()), + Argument::Array(vec![1, 2, 3, 4, 5, 6, 7, 8, 9]), + Argument::Object(88), + Argument::NewId(56), + Argument::Int(-25), + ], + }; + + let (client, server) = ::std::os::unix::net::UnixStream::pair().unwrap(); + let mut client = BufferedSocket::new(unsafe { Socket::from_raw_fd(client.into_raw_fd()) }); + let mut server = BufferedSocket::new(unsafe { Socket::from_raw_fd(server.into_raw_fd()) }); + + client.write_message(&msg).unwrap(); + client.flush().unwrap(); + + static SIGNATURE: &'static [ArgumentType] = &[ + ArgumentType::Uint, + ArgumentType::Fixed, + ArgumentType::Str, + ArgumentType::Array, + ArgumentType::Object, + ArgumentType::NewId, + ArgumentType::Int, + ]; + + let ret = server + .read_messages( + |sender_id, opcode| { + if sender_id == 42 && opcode == 7 { + Some(SIGNATURE) + } else { + None + } + }, + |message| { + assert_eq_msgs(&message, &msg); + true + }, + ) + .unwrap() + .unwrap(); + + assert_eq!(ret, 1); + } + + #[test] + fn write_read_cycle_fd() { + let msg = Message { + sender_id: 42, + opcode: 7, + args: vec![ + Argument::Fd(1), // stdin + Argument::Fd(0), // stdout + ], + }; + + let (client, server) = ::std::os::unix::net::UnixStream::pair().unwrap(); + let mut client = BufferedSocket::new(unsafe { Socket::from_raw_fd(client.into_raw_fd()) }); + let mut server = BufferedSocket::new(unsafe { Socket::from_raw_fd(server.into_raw_fd()) }); + + client.write_message(&msg).unwrap(); + client.flush().unwrap(); + + static SIGNATURE: &'static [ArgumentType] = &[ArgumentType::Fd, ArgumentType::Fd]; + + let ret = server + .read_messages( + |sender_id, opcode| { + if sender_id == 42 && opcode == 7 { + Some(SIGNATURE) + } else { + None + } + }, + |message| { + assert_eq_msgs(&message, &msg); + true + }, + ) + .unwrap() + .unwrap(); + + assert_eq!(ret, 1); + } + + #[test] + fn write_read_cycle_multiple() { + let messages = [ + Message { + sender_id: 42, + opcode: 0, + args: vec![ + Argument::Int(42), + Argument::Str(CString::new(&b"I like trains"[..]).unwrap()), + ], + }, + Message { + sender_id: 42, + opcode: 1, + args: vec![ + Argument::Fd(1), // stdin + Argument::Fd(0), // stdout + ], + }, + Message { + sender_id: 42, + opcode: 2, + args: vec![ + Argument::Uint(3), + Argument::Fd(2), // stderr + ], + }, + ]; + + static SIGNATURES: &'static [&'static [ArgumentType]] = &[ + &[ArgumentType::Int, ArgumentType::Str], + &[ArgumentType::Fd, ArgumentType::Fd], + &[ArgumentType::Uint, ArgumentType::Fd], + ]; + + let (client, server) = ::std::os::unix::net::UnixStream::pair().unwrap(); + let mut client = BufferedSocket::new(unsafe { Socket::from_raw_fd(client.into_raw_fd()) }); + let mut server = BufferedSocket::new(unsafe { Socket::from_raw_fd(server.into_raw_fd()) }); + + for msg in &messages { + client.write_message(msg).unwrap(); + } + client.flush().unwrap(); + + let mut recv_msgs = Vec::new(); + let ret = server + .read_messages( + |sender_id, opcode| { + if sender_id == 42 { + Some(SIGNATURES[opcode as usize]) + } else { + None + } + }, + |message| { + recv_msgs.push(message); + true + }, + ) + .unwrap() + .unwrap(); + + assert_eq!(ret, 3); + assert_eq!(recv_msgs.len(), 3); + for (msg1, msg2) in messages.iter().zip(recv_msgs.iter()) { + assert_eq_msgs(msg1, msg2); + } + } + + #[test] + fn parse_with_string_len_multiple_of_4() { + let msg = Message { + sender_id: 2, + opcode: 0, + args: vec![ + Argument::Uint(18), + Argument::Str(CString::new(&b"wl_shell"[..]).unwrap()), + Argument::Uint(1), + ], + }; + + let (client, server) = ::std::os::unix::net::UnixStream::pair().unwrap(); + let mut client = BufferedSocket::new(unsafe { Socket::from_raw_fd(client.into_raw_fd()) }); + let mut server = BufferedSocket::new(unsafe { Socket::from_raw_fd(server.into_raw_fd()) }); + + client.write_message(&msg).unwrap(); + client.flush().unwrap(); + + static SIGNATURE: &'static [ArgumentType] = + &[ArgumentType::Uint, ArgumentType::Str, ArgumentType::Uint]; + + let ret = server + .read_messages( + |sender_id, opcode| { + if sender_id == 2 && opcode == 0 { + Some(SIGNATURE) + } else { + None + } + }, + |message| { + assert_eq_msgs(&message, &msg); + true + }, + ) + .unwrap() + .unwrap(); + + assert_eq!(ret, 1); + } +} diff --git a/third_party/cargo/vendor/wayland-commons-0.21.13/src/utils.rs b/third_party/cargo/vendor/wayland-commons-0.21.13/src/utils.rs new file mode 100644 index 0000000..a322a16 --- /dev/null +++ b/third_party/cargo/vendor/wayland-commons-0.21.13/src/utils.rs @@ -0,0 +1,264 @@ +//! Various utilities used for other implementations + +use std::any::Any; +use std::thread::{self, ThreadId}; + +use self::list::AppendList; + +/// A wrapper for user data, able to store any type, and correctly +/// handling access from a wrong thread +pub struct UserData { + inner: UserDataInner, +} + +enum UserDataInner { + ThreadSafe(Box<Any + Send + Sync + 'static>), + NonThreadSafe(Box<Any + 'static>, ThreadId), + Empty, +} + +// UserData itself is always threadsafe, as it only gives access to its +// content if it is send+sync or we are on the right thread +unsafe impl Send for UserData {} +unsafe impl Sync for UserData {} + +impl UserData { + /// Create a new `UserData` using a threadsafe type + /// + /// Its contents can be accessed from any thread. + pub fn new_threadsafe<T: Send + Sync + 'static>(value: T) -> UserData { + UserData { + inner: UserDataInner::ThreadSafe(Box::new(value)), + } + } + + /// Create a new `UserData` using a non-threadsafe type + /// + /// Its contents can only be accessed from the same thread as the one you + /// are creating it. + pub fn new<T: 'static>(value: T) -> UserData { + UserData { + inner: UserDataInner::NonThreadSafe(Box::new(value), thread::current().id()), + } + } + + /// Create a new `UserData` containing nothing + pub fn empty() -> UserData { + UserData { + inner: UserDataInner::Empty, + } + } + + /// Attempt to access the wrapped user data + /// + /// Will return `None` if either: + /// + /// - The requested type `T` does not match the type used for construction + /// - This `UserData` has been created using the non-threadsafe variant and access + /// is attempted from an other thread than the one it was created on + pub fn get<T: 'static>(&self) -> Option<&T> { + match self.inner { + UserDataInner::ThreadSafe(ref val) => Any::downcast_ref::<T>(&**val), + UserDataInner::NonThreadSafe(ref val, threadid) => { + // only give access if we are on the right thread + if threadid == thread::current().id() { + Any::downcast_ref::<T>(&**val) + } else { + None + } + } + UserDataInner::Empty => None, + } + } +} + +/// A storage able to store several values of `UserData` +/// of different types. It behaves similarly to a `TypeMap`. +pub struct UserDataMap { + list: AppendList<UserData>, +} + +impl UserDataMap { + /// Create a new map + pub fn new() -> UserDataMap { + UserDataMap { + list: AppendList::new(), + } + } + + /// Attempt to access the wrapped user data of a given type + /// + /// Will return `None` if no value of type `T` is stored in this `UserDataMap` + /// and accessible from this thread + pub fn get<T: 'static>(&self) -> Option<&T> { + for user_data in &self.list { + if let Some(val) = user_data.get::<T>() { + return Some(val); + } + } + None + } + + /// Insert a value in the map if it is not already there + /// + /// This is the non-threadsafe variant, the type you insert don't have to be + /// threadsafe, but they will not be visible from other threads (even if they are + /// actually threadsafe). + /// + /// If the value does not already exists, the closure is called to create it and + /// this function returns `true`. If the value already exists, the closure is not + /// called, and this function returns `false`. + pub fn insert_if_missing<T: 'static, F: FnOnce() -> T>(&self, init: F) -> bool { + if self.get::<T>().is_some() { + return false; + } + self.list.append(UserData::new(init())); + true + } + + /// Insert a value in the map if it is not already there + /// + /// This is the threadsafe variant, the type you insert must be threadsafe and will + /// be visible from all threads. + /// + /// If the value does not already exists, the closure is called to create it and + /// this function returns `true`. If the value already exists, the closure is not + /// called, and this function returns `false`. + pub fn insert_if_missing_threadsafe<T: Send + Sync + 'static, F: FnOnce() -> T>(&self, init: F) -> bool { + if self.get::<T>().is_some() { + return false; + } + self.list.append(UserData::new_threadsafe(init())); + true + } +} + +mod list { + /* + * This is a lock-free append-only list, it is used as an implementation + * detail of the UserDataMap. + * + * It was extracted from https://github.com/Diggsey/lockless under MIT license + * Copyright © Diggory Blake <diggsey@googlemail.com> + */ + + use std::sync::atomic::{AtomicPtr, Ordering}; + use std::{mem, ptr}; + + type NodePtr<T> = Option<Box<Node<T>>>; + + #[derive(Debug)] + struct Node<T> { + value: T, + next: AppendList<T>, + } + + #[derive(Debug)] + pub struct AppendList<T>(AtomicPtr<Node<T>>); + + impl<T> AppendList<T> { + fn into_raw(ptr: NodePtr<T>) -> *mut Node<T> { + match ptr { + Some(b) => Box::into_raw(b), + None => ptr::null_mut(), + } + } + unsafe fn from_raw(ptr: *mut Node<T>) -> NodePtr<T> { + if ptr == ptr::null_mut() { + None + } else { + Some(Box::from_raw(ptr)) + } + } + + fn new_internal(ptr: NodePtr<T>) -> Self { + AppendList(AtomicPtr::new(Self::into_raw(ptr))) + } + + pub fn new() -> Self { + Self::new_internal(None) + } + + pub fn append(&self, value: T) { + self.append_list(AppendList::new_internal(Some(Box::new(Node { + value: value, + next: AppendList::new(), + })))); + } + + unsafe fn append_ptr(&self, p: *mut Node<T>) { + loop { + match self + .0 + .compare_exchange_weak(ptr::null_mut(), p, Ordering::AcqRel, Ordering::Acquire) + { + Ok(_) => return, + Err(head) => { + if !head.is_null() { + return (*head).next.append_ptr(p); + } + } + } + } + } + + pub fn append_list(&self, other: AppendList<T>) { + let p = other.0.load(Ordering::Acquire); + mem::forget(other); + unsafe { self.append_ptr(p) }; + } + + pub fn iter(&self) -> AppendListIterator<T> { + AppendListIterator(&self.0) + } + } + + impl<'a, T> IntoIterator for &'a AppendList<T> { + type Item = &'a T; + type IntoIter = AppendListIterator<'a, T>; + + fn into_iter(self) -> AppendListIterator<'a, T> { + self.iter() + } + } + + impl<T> Drop for AppendList<T> { + fn drop(&mut self) { + unsafe { Self::from_raw(mem::replace(self.0.get_mut(), ptr::null_mut())) }; + } + } + + #[derive(Debug)] + pub struct AppendListIterator<'a, T: 'a>(&'a AtomicPtr<Node<T>>); + + impl<'a, T: 'a> Iterator for AppendListIterator<'a, T> { + type Item = &'a T; + + fn next(&mut self) -> Option<&'a T> { + let p = self.0.load(Ordering::Acquire); + if p.is_null() { + None + } else { + unsafe { + self.0 = &(*p).next.0; + Some(&(*p).value) + } + } + } + } +} + +#[cfg(test)] +mod tests { + use super::UserDataMap; + + #[test] + fn insert_twice() { + let map = UserDataMap::new(); + + assert_eq!(map.get::<usize>(), None); + assert!(map.insert_if_missing(|| 42usize)); + assert!(!map.insert_if_missing(|| 43usize)); + assert_eq!(map.get::<usize>(), Some(&42)); + } +} diff --git a/third_party/cargo/vendor/wayland-commons-0.21.13/src/wire.rs b/third_party/cargo/vendor/wayland-commons-0.21.13/src/wire.rs new file mode 100644 index 0000000..1fd0018 --- /dev/null +++ b/third_party/cargo/vendor/wayland-commons-0.21.13/src/wire.rs @@ -0,0 +1,430 @@ +//! Types and routines used to manipulate arguments from the wire format + +use std::ffi::{CStr, CString}; +use std::os::unix::io::RawFd; +use std::ptr; + +use nix::errno::Errno; +use nix::{Error as NixError, Result as NixResult}; + +/// Wire metadata of a given message +pub struct MessageDesc { + /// Name of this message + pub name: &'static str, + /// Signature of the message + pub signature: &'static [ArgumentType], + /// Minimum required version of the interface + pub since: u32, +} + +/// Enum of possible argument types as recognized by the wire +#[derive(Copy, Clone, PartialEq, Debug)] +pub enum ArgumentType { + /// i32 + Int, + /// u32 + Uint, + /// fixed point, 1/256 precision + Fixed, + /// CString + Str, + /// id of a wayland object + Object, + /// id of a newly created wayland object + NewId, + /// Vec<u8> + Array, + /// RawFd + Fd, +} + +/// Enum of possible argument as recognized by the wire, including values +#[derive(Clone, PartialEq, Debug)] +pub enum Argument { + /// i32 + Int(i32), + /// u32 + Uint(u32), + /// fixed point, 1/256 precision + Fixed(i32), + /// CString + Str(CString), + /// id of a wayland object + Object(u32), + /// id of a newly created wayland object + NewId(u32), + /// Vec<u8> + Array(Vec<u8>), + /// RawFd + Fd(RawFd), +} + +impl Argument { + /// Retrieve the type of a given argument instance + pub fn get_type(&self) -> ArgumentType { + match *self { + Argument::Int(_) => ArgumentType::Int, + Argument::Uint(_) => ArgumentType::Uint, + Argument::Fixed(_) => ArgumentType::Fixed, + Argument::Str(_) => ArgumentType::Str, + Argument::Object(_) => ArgumentType::Object, + Argument::NewId(_) => ArgumentType::NewId, + Argument::Array(_) => ArgumentType::Array, + Argument::Fd(_) => ArgumentType::Fd, + } + } +} + +/// A wire message +#[derive(Debug, Clone, PartialEq)] +pub struct Message { + /// ID of the object sending this message + pub sender_id: u32, + /// Opcode of the message + pub opcode: u16, + /// Arguments of the message + pub args: Vec<Argument>, +} + +/// Error generated when trying to serialize a message into buffers +#[derive(Debug, Clone)] +pub enum MessageWriteError { + /// The buffer is too small to hold the message contents + BufferTooSmall, + /// The message contains a FD that could not be dup-ed + DupFdFailed(::nix::Error), +} + +impl ::std::error::Error for MessageWriteError { + fn description(&self) -> &str { + match *self { + MessageWriteError::BufferTooSmall => "The provided buffer is too small to hold message content.", + MessageWriteError::DupFdFailed(_) => { + "The message contains a file descriptor that could not be dup()-ed." + } + } + } +} + +impl ::std::fmt::Display for MessageWriteError { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { + f.write_str(::std::error::Error::description(self)) + } +} + +/// Error generated when trying to deserialize a message from buffers +#[derive(Debug, Clone)] +pub enum MessageParseError { + /// The message references a FD but the buffer FD is empty + MissingFD, + /// More data is needed to deserialize the message + MissingData, + /// The message is malformed and cannot be parsed + Malformed, +} + +impl ::std::error::Error for MessageParseError { + fn description(&self) -> &str { + match *self { + MessageParseError::MissingFD => "The message references a FD but the buffer FD is empty.", + MessageParseError::MissingData => "More data is needed to deserialize the message", + MessageParseError::Malformed => "The message is malformed and cannot be parsed", + } + } +} + +impl ::std::fmt::Display for MessageParseError { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { + f.write_str(::std::error::Error::description(self)) + } +} + +impl Message { + /// Serialize the contents of this message into provided buffers + /// + /// Returns the number of elements written in each buffer + /// + /// Any serialized Fd will be `dup()`-ed in the process + pub fn write_to_buffers<'a, 'b>( + &self, + payload: &'a mut [u32], + mut fds: &'b mut [RawFd], + ) -> Result<(usize, usize), MessageWriteError> { + let orig_payload_len = payload.len(); + let orig_fds_len = fds.len(); + // Helper function to write a u32 or a RawFd to its buffer + fn write_buf<'a, T>(u: T, payload: &'a mut [T]) -> Result<&'a mut [T], MessageWriteError> { + if let Some((head, tail)) = payload.split_first_mut() { + *head = u; + Ok(tail) + } else { + Err(MessageWriteError::BufferTooSmall) + } + } + + // Helper function to write byte arrays in payload + fn write_array_to_payload<'a>( + array: &[u8], + payload: &'a mut [u32], + ) -> Result<&'a mut [u32], MessageWriteError> { + let array_len = array.len(); + let word_len = array_len / 4 + if array_len % 4 != 0 { 1 } else { 0 }; + // need enough space to store the whole array with padding and a size header + if payload.len() < 1 + word_len { + return Err(MessageWriteError::BufferTooSmall); + } + // size header + payload[0] = array_len as u32; + let (buffer_slice, rest) = payload[1..].split_at_mut(word_len); + unsafe { + ptr::copy(array.as_ptr(), buffer_slice.as_mut_ptr() as *mut u8, array_len); + } + Ok(rest) + } + + let free_size = payload.len(); + if free_size < 2 { + return Err(MessageWriteError::BufferTooSmall); + } + + let (header, mut payload) = payload.split_at_mut(2); + + // we store all fds we dup-ed in this, which will auto-close + // them on drop, if any of the `?` early-returns + let mut pending_fds = FdStore::new(); + + // write the contents in the buffer + for arg in &self.args { + // Just to make the borrow checker happy + let old_payload = payload; + match *arg { + Argument::Int(i) => payload = write_buf(i as u32, old_payload)?, + Argument::Uint(u) => payload = write_buf(u, old_payload)?, + Argument::Fixed(f) => payload = write_buf(f as u32, old_payload)?, + Argument::Str(ref s) => { + payload = write_array_to_payload(s.as_bytes_with_nul(), old_payload)?; + } + Argument::Object(o) => payload = write_buf(o, old_payload)?, + Argument::NewId(n) => payload = write_buf(n, old_payload)?, + Argument::Array(ref a) => { + payload = write_array_to_payload(&a, old_payload)?; + } + Argument::Fd(fd) => { + let old_fds = fds; + let dup_fd = dup_fd_cloexec(fd).map_err(MessageWriteError::DupFdFailed)?; + pending_fds.push(dup_fd); + fds = write_buf(dup_fd, old_fds)?; + payload = old_payload; + } + } + } + + // we reached here, all writing was successful + // no FD needs to be closed + pending_fds.clear(); + + let wrote_size = (free_size - payload.len()) * 4; + header[0] = self.sender_id; + header[1] = ((wrote_size as u32) << 16) | self.opcode as u32; + Ok((orig_payload_len - payload.len(), orig_fds_len - fds.len())) + } + + /// Attempts to parse a single wayland message with the given signature. + /// + /// If the buffers contains several messages, only the first one will be parsed, + /// and the unused tail of the buffers is returned. If a single message was present, + /// the returned slices should thus be empty. + /// + /// Errors if the message is malformed. + pub fn from_raw<'a, 'b>( + raw: &'a [u32], + signature: &[ArgumentType], + fds: &'b [RawFd], + ) -> Result<(Message, &'a [u32], &'b [RawFd]), MessageParseError> { + // helper function to read arrays + fn read_array_from_payload( + array_len: usize, + payload: &[u32], + ) -> Result<(&[u8], &[u32]), MessageParseError> { + let word_len = array_len / 4 + if array_len % 4 != 0 { 1 } else { 0 }; + if word_len > payload.len() { + return Err(MessageParseError::MissingData); + } + let (array_contents, rest) = payload.split_at(word_len); + let array = + unsafe { ::std::slice::from_raw_parts(array_contents.as_ptr() as *const u8, array_len) }; + Ok((array, rest)) + } + + if raw.len() < 2 { + return Err(MessageParseError::MissingData); + } + + let sender_id = raw[0]; + let word_2 = raw[1]; + let opcode = (word_2 & 0x0000FFFF) as u16; + let len = (word_2 >> 16) as usize / 4; + + if len < 2 || len > raw.len() { + return Err(MessageParseError::Malformed); + } + + let (mut payload, rest) = raw.split_at(len); + payload = &payload[2..]; + let mut fds = fds; + + let arguments = signature + .iter() + .map(|argtype| { + if let ArgumentType::Fd = *argtype { + // don't consume input but fd + if let Some((&front, tail)) = fds.split_first() { + fds = tail; + Ok(Argument::Fd(front)) + } else { + Err(MessageParseError::MissingFD) + } + } else if let Some((&front, mut tail)) = payload.split_first() { + let arg = match *argtype { + ArgumentType::Int => Ok(Argument::Int(front as i32)), + ArgumentType::Uint => Ok(Argument::Uint(front)), + ArgumentType::Fixed => Ok(Argument::Fixed(front as i32)), + ArgumentType::Str => { + read_array_from_payload(front as usize, tail).and_then(|(v, rest)| { + tail = rest; + match CStr::from_bytes_with_nul(v) { + Ok(s) => Ok(Argument::Str(s.into())), + Err(_) => Err(MessageParseError::Malformed), + } + }) + } + ArgumentType::Object => Ok(Argument::Object(front)), + ArgumentType::NewId => Ok(Argument::NewId(front)), + ArgumentType::Array => { + read_array_from_payload(front as usize, tail).map(|(v, rest)| { + tail = rest; + Argument::Array(v.into()) + }) + } + ArgumentType::Fd => unreachable!(), + }; + payload = tail; + arg + } else { + Err(MessageParseError::MissingData) + } + }) + .collect::<Result<Vec<_>, MessageParseError>>()?; + + let msg = Message { + sender_id: sender_id, + opcode: opcode, + args: arguments, + }; + Ok((msg, rest, fds)) + } +} + +/// Duplicate a `RawFd` and set the CLOEXEC flag on the copy +pub fn dup_fd_cloexec(fd: RawFd) -> NixResult<RawFd> { + use nix::fcntl; + match fcntl::fcntl(fd, fcntl::FcntlArg::F_DUPFD_CLOEXEC(0)) { + Ok(newfd) => Ok(newfd), + Err(NixError::Sys(Errno::EINVAL)) => { + // F_DUPFD_CLOEXEC is not recognized, kernel too old, fallback + // to setting CLOEXEC manually + let newfd = fcntl::fcntl(fd, fcntl::FcntlArg::F_DUPFD(0))?; + + let flags = fcntl::fcntl(newfd, fcntl::FcntlArg::F_GETFD); + let result = flags + .map(|f| fcntl::FdFlag::from_bits(f).unwrap() | fcntl::FdFlag::FD_CLOEXEC) + .and_then(|f| fcntl::fcntl(newfd, fcntl::FcntlArg::F_SETFD(f))); + match result { + Ok(_) => { + // setting the O_CLOEXEC worked + return Ok(newfd); + } + Err(e) => { + // something went wrong in F_GETFD or F_SETFD + let _ = ::nix::unistd::close(newfd); + return Err(e); + } + } + } + Err(e) => Err(e), + } +} + +/* + * utility struct that closes every FD it contains on drop + */ + +struct FdStore { + fds: Vec<RawFd>, +} + +impl FdStore { + fn new() -> FdStore { + FdStore { fds: Vec::new() } + } + fn push(&mut self, fd: RawFd) { + self.fds.push(fd); + } + fn clear(&mut self) { + self.fds.clear(); + } +} + +impl Drop for FdStore { + fn drop(&mut self) { + use nix::unistd::close; + for fd in self.fds.drain(..) { + // not much can be done if we can't close that anyway... + let _ = close(fd); + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn into_from_raw_cycle() { + let mut bytes_buffer = vec![0; 1024]; + let mut fd_buffer = vec![0; 10]; + + let msg = Message { + sender_id: 42, + opcode: 7, + args: vec![ + Argument::Uint(3), + Argument::Fixed(-89), + Argument::Str(CString::new(&b"I like trains!"[..]).unwrap()), + Argument::Array(vec![1, 2, 3, 4, 5, 6, 7, 8, 9]), + Argument::Object(88), + Argument::NewId(56), + Argument::Int(-25), + ], + }; + // write the message to the buffers + msg.write_to_buffers(&mut bytes_buffer[..], &mut fd_buffer[..]) + .unwrap(); + // read them back + let (rebuilt, _, _) = Message::from_raw( + &bytes_buffer[..], + &[ + ArgumentType::Uint, + ArgumentType::Fixed, + ArgumentType::Str, + ArgumentType::Array, + ArgumentType::Object, + ArgumentType::NewId, + ArgumentType::Int, + ], + &fd_buffer[..], + ) + .unwrap(); + assert_eq!(rebuilt, msg); + } +} diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/.cargo-checksum.json b/third_party/cargo/vendor/wayland-protocols-0.21.13/.cargo-checksum.json new file mode 100644 index 0000000..ba4319d --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"35d0032ee41e41311ff8ee21897e51f57a380fc33262a5b6157990720877e359","build.rs":"a27ab53bc4390f9a5d6a0e8cda05c75f2ffdc7982bfd7459590af4c096a65dc9","protocols/COPYING":"f1a2b233e8a9a71c40f4aa885be08a0842ac85bb8588703c1dd7e6e6502e3124","protocols/Makefile.am":"34dc7d2f58b3198934c2970e59490aa580d185fa6919182185f0e1cbb6701681","protocols/README":"6235172d64cda3d4db3838d0097849d730e65d35c078ff8da731bdfdd22d4de1","protocols/autogen.sh":"fb26c092df7235733e756dfd869bdec34b8dd56ce7577b5028162c09c64004d8","protocols/configure.ac":"490c2460e2b559c9b700cd929c8bc30a84f4e53b82471b3fad30ae57f5225c11","protocols/m4/compat.m4":"9eba9db73f60337a674d58b9634c2706ea6d202d71c741c4008b5ff1458e6f3a","protocols/stable/presentation-time/README":"abed5978a4b5a05317382359aa1fdd4782be447894b9480a096e9110605a249c","protocols/stable/presentation-time/presentation-time.xml":"b3c6e755f8d5c9dcec771da23f99a6a2119cea3cc21acd78962a352d0d55e87e","protocols/stable/viewporter/README":"71e33de1e94da4a2e9b76f37edbf3dc8af3d4828c0165dba57751b2784f74110","protocols/stable/viewporter/viewporter.xml":"d5da5c61107c53062c7a73093bd72676a0d643fa04eb1867411126600a75fc54","protocols/stable/xdg-shell/README":"4981eb1b38b6c42ff5aa12ab3db46270650d364876fa82dbd05470529726f057","protocols/stable/xdg-shell/xdg-shell.xml":"8b7d47297ecde5f8cc557ae3bb7289a4c66ddde471c83698b697c867a2d59046","protocols/tests/scan.sh":"b219a2d2c5b7ffa52107cd31124a9909714472e31645a2278acd21decbeb14cd","protocols/unstable/fullscreen-shell/README":"fe3f21d4566d0b5aefc167649b2cb38f7b741a4e53f8c5d88b5dff05482bb098","protocols/unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml":"df718b7803ca72b3128e9b8d2eb5870810e677e3c1cd1d154194d03132dfb8e1","protocols/unstable/idle-inhibit/README":"98f814aa1ca5ba42ba9c9aed64e56381c9b8d7dd5dc5610d552830f8fa7787c6","protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml":"c2ac9f002c6669ca6c02eb9b587b8e9108e3ce6deab4a2de58b576f4f864ca38","protocols/unstable/input-method/README":"ea783a7a4180f5ee0efd5ed62e33a972fd1127636db44e0dd863e2dc46a7c27e","protocols/unstable/input-method/input-method-unstable-v1.xml":"e04464e22eee9ac67e21c3316c8bb47293656902c2f26b91ebdd8b40eeba03a0","protocols/unstable/input-timestamps/README":"ef92f7fba49eb9a31db2ea9f8c0577ce1f6f4ef57e499041a38d21501115e0e5","protocols/unstable/input-timestamps/input-timestamps-unstable-v1.xml":"92d9911f070407d470458f59ffdee5406ce3b6368270a93e6ecd9f4f71368bb0","protocols/unstable/keyboard-shortcuts-inhibit/README":"a2cd9366dca159c60a42c797c0305f81d4ff12f0064cb14ae1b78988ae1c17af","protocols/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml":"9117d9e8ec02e9a3c3c55803b41e1227e76986f555f7c12eeb29f796fa63e69b","protocols/unstable/linux-dmabuf/README":"5ada0cec13f52f52430a98154c27cb405ccba4da291a1ab846251a0bf8a5dff0","protocols/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml":"8eca77ac6c622df8c50c97b911d6f15b452d9ddf1a6b52c48131c702be80b655","protocols/unstable/linux-explicit-synchronization/README":"db6d7d851ae553ab96e601a20d9d33803a3974acfc6cf8434996c12c966b90a1","protocols/unstable/linux-explicit-synchronization/linux-explicit-synchronization-unstable-v1.xml":"9a2aaefd7155a4cb69ac391b675702ac1536581fbf1b722c4cb96d1eb61f7079","protocols/unstable/pointer-constraints/README":"29bcf3cfe32b5926a00daf02f7c8a5bb0b17a1a9d9bee5d049f0317a61f41a40","protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml":"b40a5fe19883efef0a274ef82dea47b6a8af4647af58950ab7c6da3058f3a949","protocols/unstable/pointer-gestures/README":"a0c8e7c53549c19489dd55c5f375a0a7c3bfddcceb808a43a973469f4878b2f8","protocols/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml":"006323608b43a918cf6fcce3284975f40bac5d64a5ac79082bd277b40806907f","protocols/unstable/primary-selection/README":"3ae6bd7bab5c760106a055652626c0159a3c367f8ab64b0334048b7319b10811","protocols/unstable/primary-selection/primary-selection-unstable-v1.xml":"d568482ba84df6e531698b1f531810860995ca24d69495427fe43aee6017f52c","protocols/unstable/relative-pointer/README":"a5351dbb5ed63f2ee041024fb62795c7b6649cc98f4ce50239c1f1bfac36ffe2","protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml":"ab4930dd3084f732b6fdd12ee6dbd0a112a758ed8a57b170366391dbeb1a22ff","protocols/unstable/tablet/README":"f3806bd15b53446cea26c58f366b0382fd737362b257e4e60d26a574e128d0cd","protocols/unstable/tablet/tablet-unstable-v1.xml":"2816521e2716a98faa6f4f026527ec0912f8876136d58527ec3356553471fc6d","protocols/unstable/tablet/tablet-unstable-v2.xml":"c74d1aa4e44c9e2873f924707bcaf0becaaa77bf5de081cb7a4d8b06bebc2219","protocols/unstable/text-input/README":"d40c094a1f8bcbc0b0225d36acf1c5e5201d3cde87fea089991e9161f56ce846","protocols/unstable/text-input/text-input-unstable-v1.xml":"e65ec8126415e9ce992f806bbd2df0cd5efc6b07ce32aa96b2024abaa1240be5","protocols/unstable/text-input/text-input-unstable-v3.xml":"89ba8a5c5beb1a234f575cf6af477e47c70f28fdd5c21b9b2ab924762f0bc4e8","protocols/unstable/xdg-decoration/README":"8c53e37e9c192c01aba19a28def43ec9c60703acb64c85874e641c0f715e82ff","protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml":"4c52b8e737ade1a08da98d6d88329b8f76f2d3933732a5c13a454b5ea0e9ec03","protocols/unstable/xdg-foreign/README":"2d8c20c991a6e54748c84ffa8f81b153758fe58de39174c660f9422eba2ad1e7","protocols/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml":"7727851ec43bf5897826248932d2e30a5a5b9257b6fab4afbb257d73adda088c","protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml":"bed5b5cf1483e216ab896c4fe86d296ea37a9283b31abf5e5b6fc82605f2e24f","protocols/unstable/xdg-output/README":"0220f9818bef87130c98acc8a571e78fe0c2ac26eff3a2f40c4cd48f542a2a0b","protocols/unstable/xdg-output/xdg-output-unstable-v1.xml":"bed7321b8325ba4c9c79936e1b89b713d7b822d54e3aeec5e7f20f03819534c8","protocols/unstable/xdg-shell/README":"a8a1af606073829cd2aef5a54f98455726999e71f8162dc55ec6ab647212a3b4","protocols/unstable/xdg-shell/xdg-shell-unstable-v5.xml":"864ab0ac02e89c6e6079a97876123cf6003b5a219d8dc0d5a0496d4bce7b5ffc","protocols/unstable/xdg-shell/xdg-shell-unstable-v6.xml":"15b9922317144e81aec6872ee0ed78d563efdba13ba88592bda71696120a41d2","protocols/unstable/xwayland-keyboard-grab/README":"5d888ca7848d68817843bfd0832da842ec70acc6466c776e80f6c128c225100e","protocols/unstable/xwayland-keyboard-grab/xwayland-keyboard-grab-unstable-v1.xml":"fcc1e24ec465c209de576f75bf87438b8339e4da42051a3f26b48916292c7c6f","protocols/wayland-protocols-uninstalled.pc.in":"9b1a4fa6257e150bd7e9ba93ee351f7b27612bd2b25b054478191e12b1a71fb2","protocols/wayland-protocols.pc.in":"07d52e8f3b5572437128b2524f593203afec230c6ff38d7ca51cffc4ef2221cb","src/lib.rs":"5d8dd68193c0036cea60c578af0a3fe563fe6df0975568fdf11626c673be3dca","src/protocol_macro.rs":"1b301f7b9a1dab5cce28c3a5993d50cd4a4cc966c86bd166e247256e37697e71","src/stable.rs":"d13c56aee42c9fac0944232ede57e9a3b0c8ecaba0e5ca15f0e5cb9f318a88b9","src/unstable.rs":"02dab0d16b86cb8f95090c3bdef295862a0bea340fbc8dd0bf345772c14100ba","src/wlr.rs":"f175fbff097213a28b0170f2d8cf761d0c988ff7d810db01a1462554d1857448","wlr-protocols/Makefile":"a1f4d578ab5566a812d393f945ad0675e7710cfe4ca6f74621868a194234d428","wlr-protocols/check.sh":"6d1f75568915d08bc7f6df0c3c0a234b0eee7b045a7fb8f21a0d2e46f691194f","wlr-protocols/unstable/wlr-data-control-unstable-v1.xml":"ed3489d0d41b58aba13dccf0de913f19d30ef850c56331d9abd0684fe89c0aff","wlr-protocols/unstable/wlr-export-dmabuf-unstable-v1.xml":"0653d993fb10163c45124bc3748717a59b49c6460fec9100282e17a38c6fc2f9","wlr-protocols/unstable/wlr-foreign-toplevel-management-unstable-v1.xml":"0d724a81ad4ab059ce4fd500f6dcfb836ad1c72b174d116a82f1d0245b1fd160","wlr-protocols/unstable/wlr-gamma-control-unstable-v1.xml":"779ac19d63855f2211d9af735e0b2b9376b8ef070155ea9b8df64d2d9464d370","wlr-protocols/unstable/wlr-input-inhibitor-unstable-v1.xml":"6f56c6650302feb9456f54a9705cc9b3a93b265f593a95f40bad329dcb9cbf58","wlr-protocols/unstable/wlr-layer-shell-unstable-v1.xml":"f4228ad1a603c3eb6b22b5f1c8eb71e30c8fe8c3fadfad75fd7d5091fbadf672","wlr-protocols/unstable/wlr-screencopy-unstable-v1.xml":"a273cbbbbc4860738eaf6aa7d9845fea5df9cd85204bfa8014937c716441cdba","wlr-protocols/wlr-protocols.pc.in":"1853341442197bf0310d76bf4172a9b491ecbd6358478cc3ee51ba01948d93c6"},"package":"4afde2ea2a428eee6d7d2c8584fdbe8b82eee8b6c353e129a434cd6e07f42145"} \ No newline at end of file diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/BUILD b/third_party/cargo/vendor/wayland-protocols-0.21.13/BUILD new file mode 100644 index 0000000..d5e3ea3 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/BUILD @@ -0,0 +1,102 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + +rust_binary( + name = "wayland_protocols_build_script", + srcs = glob(["**/*.rs"]), + crate_root = "build.rs", + edition = "2015", + deps = [ + "//third_party/cargo/vendor/wayland-scanner-0.21.13:wayland_scanner", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + crate_features = [ + "client", + "native_client", + "native_lib", + "unstable_protocols", + "wayland-client", + "wayland-sys", + ], + data = glob(["*"]), + version = "0.21.13", + visibility = ["//visibility:private"], +) + +genrule( + name = "wayland_protocols_build_script_executor", + srcs = glob(["*", "**/*.rs"]), + outs = ["wayland_protocols_out_dir_outputs.tar.gz"], + tools = [ + ":wayland_protocols_build_script", + ], + tags = ["no-sandbox"], + cmd = "mkdir -p $$(dirname $@)/wayland_protocols_out_dir_outputs/;" + + " (export CARGO_MANIFEST_DIR=\"$$PWD/$$(dirname $(location :Cargo.toml))\";" + # TODO(acmcarther): This needs to be revisited as part of the cross compilation story. + # See also: https://github.com/google/cargo-raze/pull/54 + + " export TARGET='x86_64-unknown-linux-gnu';" + + " export RUST_BACKTRACE=1;" + + " export CARGO_FEATURE_CLIENT=1;" + + " export CARGO_FEATURE_NATIVE_CLIENT=1;" + + " export CARGO_FEATURE_NATIVE_LIB=1;" + + " export CARGO_FEATURE_UNSTABLE_PROTOCOLS=1;" + + " export CARGO_FEATURE_WAYLAND_CLIENT=1;" + + " export CARGO_FEATURE_WAYLAND_SYS=1;" + + " export OUT_DIR=$$PWD/$$(dirname $@)/wayland_protocols_out_dir_outputs;" + + " export BINARY_PATH=\"$$PWD/$(location :wayland_protocols_build_script)\";" + + " export OUT_TAR=$$PWD/$@;" + + " cd $$(dirname $(location :Cargo.toml)) && $$BINARY_PATH && tar -czf $$OUT_TAR -C $$OUT_DIR .)" +) + + +rust_library( + name = "wayland_protocols", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/bitflags-1.2.1:bitflags", + "//third_party/cargo/vendor/wayland-client-0.21.13:wayland_client", + "//third_party/cargo/vendor/wayland-commons-0.21.13:wayland_commons", + "//third_party/cargo/vendor/wayland-sys-0.21.13:wayland_sys", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + out_dir_tar = ":wayland_protocols_build_script_executor", + version = "0.21.13", + crate_features = [ + "client", + "native_client", + "native_lib", + "unstable_protocols", + "wayland-client", + "wayland-sys", + ], +) + diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/Cargo.toml b/third_party/cargo/vendor/wayland-protocols-0.21.13/Cargo.toml new file mode 100644 index 0000000..5d4efbd --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/Cargo.toml @@ -0,0 +1,54 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "wayland-protocols" +version = "0.21.13" +authors = ["Victor Berger <victor.berger@m4x.org>"] +build = "build.rs" +description = "Generated API for the officials wayland protocol extensions" +documentation = "https://smithay.github.io/wayland-rs/wayland_protocols/" +keywords = ["wayland", "client", "server", "protocol", "extension"] +categories = ["gui", "api-bindings"] +license = "MIT" +repository = "https://github.com/smithay/wayland-rs" +[package.metadata.docs.rs] +all-features = true +[dependencies.bitflags] +version = "1.0" + +[dependencies.wayland-client] +version = "0.21.13" +optional = true + +[dependencies.wayland-commons] +version = "0.21.13" + +[dependencies.wayland-server] +version = "0.21.13" +optional = true + +[dependencies.wayland-sys] +version = "0.21.13" +optional = true +[build-dependencies.wayland-scanner] +version = "0.21.13" + +[features] +client = ["wayland-client"] +native_client = ["client", "native_lib", "wayland-client/native_lib"] +native_lib = ["wayland-sys"] +native_server = ["server", "native_lib", "wayland-server/native_lib"] +server = ["wayland-server"] +unstable_protocols = [] +[badges.travis-ci] +repository = "Smithay/wayland-rs" diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/build.rs b/third_party/cargo/vendor/wayland-protocols-0.21.13/build.rs new file mode 100644 index 0000000..cd68b4e --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/build.rs @@ -0,0 +1,126 @@ +extern crate wayland_scanner; + +use std::env::var; +use std::path::Path; +use wayland_scanner::*; + +static STABLE_PROTOCOLS: &'static [&'static str] = &["presentation-time", "viewporter", "xdg-shell"]; + +static UNSTABLE_PROTOCOLS: &'static [(&'static str, &'static [&'static str])] = &[ + ("fullscreen-shell", &["v1"]), + ("idle-inhibit", &["v1"]), + ("input-method", &["v1"]), + ("input-timestamps", &["v1"]), + ("keyboard-shortcuts-inhibit", &["v1"]), + ("linux-dmabuf", &["v1"]), + ("linux-explicit-synchronization", &["v1"]), + ("pointer-constraints", &["v1"]), + ("pointer-gestures", &["v1"]), + ("primary-selection", &["v1"]), + ("relative-pointer", &["v1"]), + ("tablet", &["v1", "v2"]), + ("text-input", &["v1", "v3"]), + ("xdg-decoration", &["v1"]), + ("xdg-foreign", &["v1", "v2"]), + ("xdg-output", &["v1"]), + ("xdg-shell", &["v5", "v6"]), + ("xwayland-keyboard-grab", &["v1"]), +]; + +static WLR_UNSTABLE_PROTOCOLS: &'static [(&'static str, &'static [&'static str])] = &[ + ("wlr-data-control", &["v1"]), + ("wlr-export-dmabuf", &["v1"]), + ("wlr-foreign-toplevel-management", &["v1"]), + ("wlr-gamma-control", &["v1"]), + ("wlr-input-inhibitor", &["v1"]), + ("wlr-layer-shell", &["v1"]), + ("wlr-screencopy", &["v1"]), +]; + +fn generate_protocol(name: &str, protocol_file: &Path, out_dir: &Path, client: bool, server: bool) { + if var("CARGO_FEATURE_NATIVE_LIB").ok().is_some() { + generate_c_interfaces(&protocol_file, out_dir.join(&format!("{}_c_interfaces.rs", name))); + + if client { + generate_c_code( + &protocol_file, + out_dir.join(&format!("{}_c_client_api.rs", name)), + Side::Client, + ); + } + + if server { + generate_c_code( + &protocol_file, + out_dir.join(&format!("{}_c_server_api.rs", name)), + Side::Server, + ); + } + } else { + if client { + generate_rust_code( + &protocol_file, + out_dir.join(&format!("{}_rust_client_api.rs", name)), + Side::Client, + ); + } + + if server { + generate_rust_code( + &protocol_file, + out_dir.join(&format!("{}_rust_server_api.rs", name)), + Side::Server, + ); + } + } +} + +fn main() { + let out_dir_str = var("OUT_DIR").unwrap(); + let out_dir = Path::new(&out_dir_str); + + let client = var("CARGO_FEATURE_CLIENT").ok().is_some(); + let server = var("CARGO_FEATURE_SERVER").ok().is_some(); + + for name in STABLE_PROTOCOLS { + let file = format!("{name}/{name}.xml", name = name); + generate_protocol( + name, + &Path::new("./protocols/stable").join(&file), + out_dir, + client, + server, + ); + } + + if var("CARGO_FEATURE_UNSTABLE_PROTOCOLS").ok().is_some() { + for &(name, versions) in UNSTABLE_PROTOCOLS { + for version in versions { + let file = format!( + "{name}/{name}-unstable-{version}.xml", + name = name, + version = version + ); + generate_protocol( + &format!("{name}-{version}", name = name, version = version), + &Path::new("./protocols/unstable").join(file), + out_dir, + client, + server, + ); + } + } + for &(name, versions) in WLR_UNSTABLE_PROTOCOLS { + for version in versions { + let file = format!("{name}-unstable-{version}.xml", name = name, version = version); + generate_protocol( + &format!("{name}-{version}", name = name, version = version), + &Path::new("./wlr-protocols/unstable").join(file), + out_dir, + client, + server, + ); + } + } + } +} diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/COPYING b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/COPYING new file mode 100644 index 0000000..8ab3291 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/COPYING @@ -0,0 +1,33 @@ +Copyright © 2008-2013 Kristian Høgsberg +Copyright © 2010-2013 Intel Corporation +Copyright © 2013 Rafael Antognolli +Copyright © 2013 Jasper St. Pierre +Copyright © 2014 Jonas Ådahl +Copyright © 2014 Jason Ekstrand +Copyright © 2014-2015 Collabora, Ltd. +Copyright © 2015 Red Hat Inc. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +--- + +The above is the version of the MIT "Expat" License used by X.org: + + http://cgit.freedesktop.org/xorg/xserver/tree/COPYING diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/Makefile.am b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/Makefile.am new file mode 100644 index 0000000..345ae6a --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/Makefile.am @@ -0,0 +1,51 @@ +ACLOCAL_AMFLAGS = -I m4 + +unstable_protocols = \ + unstable/pointer-gestures/pointer-gestures-unstable-v1.xml \ + unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml \ + unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml \ + unstable/text-input/text-input-unstable-v1.xml \ + unstable/text-input/text-input-unstable-v3.xml \ + unstable/input-method/input-method-unstable-v1.xml \ + unstable/xdg-shell/xdg-shell-unstable-v5.xml \ + unstable/xdg-shell/xdg-shell-unstable-v6.xml \ + unstable/relative-pointer/relative-pointer-unstable-v1.xml \ + unstable/pointer-constraints/pointer-constraints-unstable-v1.xml \ + unstable/tablet/tablet-unstable-v1.xml \ + unstable/tablet/tablet-unstable-v2.xml \ + unstable/xdg-foreign/xdg-foreign-unstable-v1.xml \ + unstable/xdg-foreign/xdg-foreign-unstable-v2.xml \ + unstable/idle-inhibit/idle-inhibit-unstable-v1.xml \ + unstable/xwayland-keyboard-grab/xwayland-keyboard-grab-unstable-v1.xml \ + unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml \ + unstable/xdg-output/xdg-output-unstable-v1.xml \ + unstable/input-timestamps/input-timestamps-unstable-v1.xml \ + unstable/xdg-decoration/xdg-decoration-unstable-v1.xml \ + unstable/linux-explicit-synchronization/linux-explicit-synchronization-unstable-v1.xml \ + unstable/primary-selection/primary-selection-unstable-v1.xml \ + $(NULL) + +stable_protocols = \ + stable/presentation-time/presentation-time.xml \ + stable/viewporter/viewporter.xml \ + stable/xdg-shell/xdg-shell.xml \ + $(NULL) + +nobase_dist_pkgdata_DATA = \ + $(unstable_protocols) \ + $(stable_protocols) \ + $(NULL) + +dist_noinst_DATA = \ + $(sort $(foreach p,$(unstable_protocols),$(dir $p)README)) \ + $(sort $(foreach p,$(stable_protocols),$(dir $p)README)) \ + $(NULL) + +noarch_pkgconfig_DATA = wayland-protocols.pc + +dist_check_SCRIPTS = tests/scan.sh + +TESTS = $(unstable_protocols) $(stable_protocols) +TEST_EXTENSIONS = .xml +AM_TESTS_ENVIRONMENT = SCANNER='$(wayland_scanner)'; export SCANNER; +XML_LOG_COMPILER = $(srcdir)/tests/scan.sh diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/README new file mode 100644 index 0000000..da1f1d5 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/README @@ -0,0 +1,141 @@ +Wayland protocols +----------------- + +wayland-protocols contains Wayland protocols that add functionality not +available in the Wayland core protocol. Such protocols either add +completely new functionality, or extend the functionality of some other +protocol either in Wayland core, or some other protocol in +wayland-protocols. + +A protocol in wayland-protocols consists of a directory containing a set +of XML files containing the protocol specification, and a README file +containing detailed state and a list of maintainers. + +Protocol directory tree structure +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Protocols may be 'stable', 'unstable' or 'deprecated', and the interface +and protocol names as well as place in the directory tree will reflect +this. + +A stable protocol is a protocol which has been declared stable by +the maintainers. Changes to such protocols will always be backward +compatible. + +An unstable protocol is a protocol currently under development and this +will be reflected in the protocol and interface names. See <<Unstable +naming convention>>. + +A deprecated protocol is a protocol that has either been replaced by some +other protocol, or declared undesirable for some other reason. No more +changes will be made to a deprecated protocol. + +Depending on which of the above states the protocol is in, the protocol +is placed within the toplevel directory containing the protocols with the +same state. Stable protocols are placed in the +stable/+ directory, +unstable protocols are placed in the +unstable/+ directory, and +deprecated protocols are placed in the +deprecated/+ directory. + +Protocol development procedure +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +To propose a new protocol, create a patch adding the relevant files and +Makefile.am entry to the wayland-protocols git repository with the +explanation and motivation in the commit message. Then send the patch to +the wayland-devel@lists.freedesktop.org mailing list using +'git send-email' with the subject prefix 'RFC wayland-protocols' or +'PATCH wayland-protocols' depending on what state the protocol is in. + +To propose changes to existing protocols, create a patch with the +changes and send it to the list mentioned above while also CC:ing the +maintainers mentioned in the README file. Use the same rule for adding a +subject prefix as above and method for sending the patch. + +If the changes are backward incompatible changes to an unstable protocol, +see <<Unstable protocol changes>>. + +Interface naming convention +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +All protocols should avoid using generic namespaces or no namespaces in +the protocol interface names in order to minimize risk that the generated +C API collides with other C API. Interface names that may collide with +interface names from other protocols should also be avoided. + +For generic protocols not limited to certain configurations (such as +specific desktop environment or operating system) the +wp_+ prefix +should be used on all interfaces in the protocol. + +For operating system specific protocols, the interfaces should be +prefixed with both +wp_+ and the operating system, for example ++wp_linux_+, or +wp_freebsd_+, etc. + +Unstable naming convention +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Unstable protocols have a special naming convention in order to make it +possible to make discoverable backward incompatible changes. + +An unstable protocol has at least two versions: the major version, which +represents backward incompatible changes, and the minor version, which +represents backward compatible changes to the interfaces in the protocol. + +The major version is part of the XML file name, the protocol name in the +XML, and interface names in the protocol. + +Minor versions are the version attributes of the interfaces in the XML. +There may be more than one minor version per protocol, if there are more +than one global. + +The XML file and protocol name also has the word 'unstable' in them, and +all of the interfaces in the protocol are prefixed with +z+ and +suffixed with the major version number. + +For example, an unstable protocol called foo-bar with major version 2 +containing the two interfaces wp_foo and wp_bar both minor version 1 will +be placed in the directory +unstable/foo-bar/+ consisting of one file +called +README+ and one called +foo-bar-unstable-v2.xml+. The XML file +will consist of two interfaces called +zwp_foo_v2+ and +zwp_bar_v2+ with +the +version+ attribute set to +1+. + +Unstable protocol changes +~~~~~~~~~~~~~~~~~~~~~~~~~ +During the development of a new protocol it is possible that backward +incompatible changes are needed. Such a change needs to be represented +in the major and minor versions of the protocol. + +Assuming a backward incompatible change is needed, the procedure for how to +do so is the following: + + . Make a copy of the XML file with the major version increased by +1+. + . Increase the major version number in the protocol XML by +1+. + . Increase the major version number in all of the interfaces in the + XML by +1+. + . Reset the minor version number (interface version attribute) of all + the interfaces to +1+. + +Backward compatible changes within a major unstable version can be done +in the regular way as done in core Wayland or in stable protocols. + +Declaring a protocol stable +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Once it is decided that a protocol should be declared stable, meaning no +more backward incompatible changes will ever be allowed, one last +breakage is needed. + +The procedure of doing this is the following: + + . Create a new directory in the +stable/+ toplevel directory with the + same name as the protocol directory in the +unstable/+ directory. + . Copy the final version of the XML that is the version that was + decided to be declared stable into the new directory. The target name + should be the same name as the protocol directory but with the +.xml+ + suffix. + . Rename the name of the protocol in the XML by removing the + 'unstable' part and the major version number. + . Remove the +z+ prefix and the major version number suffix from all + of the interfaces in the protocol. + . Reset all of the interface version attributes to +1+. + . Update the +README+ file in the unstable directory and create a new + +README+ file in the new directory. + +Releases +~~~~~~~~ +Each release of wayland-protocols finalizes the version of the protocols +to their state they had at that time. diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/autogen.sh b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/autogen.sh new file mode 100755 index 0000000..b08bc83 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/autogen.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +test -n "$srcdir" || srcdir=`dirname "$0"` +test -n "$srcdir" || srcdir=. +( + cd "$srcdir" && + autoreconf --force -v --install +) || exit +test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/configure.ac b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/configure.ac new file mode 100644 index 0000000..83188e9 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/configure.ac @@ -0,0 +1,45 @@ +AC_PREREQ([2.64]) + +m4_define([wayland_protocols_major_version], [1]) +m4_define([wayland_protocols_minor_version], [17]) +m4_define([wayland_protocols_version], + [wayland_protocols_major_version.wayland_protocols_minor_version]) + +AC_INIT([wayland-protocols], + [wayland_protocols_version], + [https://bugs.freedesktop.org/enter_bug.cgi?product=Wayland&component=wayland&version=unspecified], + [wayland-protocols], + [http://wayland.freedesktop.org/]) + +AC_CONFIG_MACRO_DIR([m4]) + +AC_SUBST([WAYLAND_PROTOCOLS_VERSION], [wayland_protocols_version]) + +AC_ARG_VAR([wayland_scanner], [The wayland-scanner executable]) +AC_PATH_PROG([wayland_scanner], [wayland-scanner]) +if test x$wayland_scanner = x; then + if test "x$cross_compiling" != "xyes"; then + PKG_CHECK_MODULES(WAYLAND_SCANNER, [wayland-scanner]) + wayland_scanner=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner` + else + AC_MSG_WARN([You are cross compiling without wayland-scanner in your path. make check will fail.]) + fi +fi + +AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz tar-ustar]) + +AM_SILENT_RULES([yes]) + +PKG_NOARCH_INSTALLDIR + +AC_CONFIG_FILES([ + Makefile + wayland-protocols.pc + wayland-protocols-uninstalled.pc + ]) +AC_OUTPUT + +AC_MSG_RESULT([ + Version ${WAYLAND_PROTOCOLS_VERSION} + Prefix ${prefix} + ]) diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/m4/compat.m4 b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/m4/compat.m4 new file mode 100644 index 0000000..290ef03 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/m4/compat.m4 @@ -0,0 +1,12 @@ +dnl noarch_pkgconfigdir only available in pkg-config 0.27 and newer +dnl http://lists.freedesktop.org/archives/pkg-config/2012-July/000875.html +dnl Ubuntu 14.04 provides only pkg-config 0.26 so lacks this function. +dnl +dnl The Wayland project maintains automated builds for Ubuntu 14.04 in +dnl a Launchpad PPA. 14.04 is a Long Term Support distro release, which +dnl will reach EOL April 2019, however the Wayland PPA may stop targeting +dnl it some time after the next LTS release (April 2016). +m4_ifndef([PKG_NOARCH_INSTALLDIR], [AC_DEFUN([PKG_NOARCH_INSTALLDIR], [ + noarch_pkgconfigdir='${datadir}'/pkgconfig + AC_SUBST([noarch_pkgconfigdir]) +])]) diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/presentation-time/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/presentation-time/README new file mode 100644 index 0000000..c7781ea --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/presentation-time/README @@ -0,0 +1,5 @@ +Presentation time protocol + +Maintainers: +Pekka Paalanen <pekka.paalanen@collabora.co.uk> + diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/presentation-time/presentation-time.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/presentation-time/presentation-time.xml new file mode 100644 index 0000000..a46994c --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/presentation-time/presentation-time.xml @@ -0,0 +1,266 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="presentation_time"> +<!-- wrap:70 --> + + <copyright> + Copyright © 2013-2014 Collabora, Ltd. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="wp_presentation" version="1"> + <description summary="timed presentation related wl_surface requests"> + +<!-- Introduction --> + + The main feature of this interface is accurate presentation + timing feedback to ensure smooth video playback while maintaining + audio/video synchronization. Some features use the concept of a + presentation clock, which is defined in the + presentation.clock_id event. + + A content update for a wl_surface is submitted by a + wl_surface.commit request. Request 'feedback' associates with + the wl_surface.commit and provides feedback on the content + update, particularly the final realized presentation time. + +<!-- Completing presentation --> + + When the final realized presentation time is available, e.g. + after a framebuffer flip completes, the requested + presentation_feedback.presented events are sent. The final + presentation time can differ from the compositor's predicted + display update time and the update's target time, especially + when the compositor misses its target vertical blanking period. + </description> + + <enum name="error"> + <description summary="fatal presentation errors"> + These fatal protocol errors may be emitted in response to + illegal presentation requests. + </description> + <entry name="invalid_timestamp" value="0" + summary="invalid value in tv_nsec"/> + <entry name="invalid_flag" value="1" + summary="invalid flag"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="unbind from the presentation interface"> + Informs the server that the client will no longer be using + this protocol object. Existing objects created by this object + are not affected. + </description> + </request> + + <request name="feedback"> + <description summary="request presentation feedback information"> + Request presentation feedback for the current content submission + on the given surface. This creates a new presentation_feedback + object, which will deliver the feedback information once. If + multiple presentation_feedback objects are created for the same + submission, they will all deliver the same information. + + For details on what information is returned, see the + presentation_feedback interface. + </description> + <arg name="surface" type="object" interface="wl_surface" + summary="target surface"/> + <arg name="callback" type="new_id" interface="wp_presentation_feedback" + summary="new feedback object"/> + </request> + + <event name="clock_id"> + <description summary="clock ID for timestamps"> + This event tells the client in which clock domain the + compositor interprets the timestamps used by the presentation + extension. This clock is called the presentation clock. + + The compositor sends this event when the client binds to the + presentation interface. The presentation clock does not change + during the lifetime of the client connection. + + The clock identifier is platform dependent. On Linux/glibc, + the identifier value is one of the clockid_t values accepted + by clock_gettime(). clock_gettime() is defined by + POSIX.1-2001. + + Timestamps in this clock domain are expressed as tv_sec_hi, + tv_sec_lo, tv_nsec triples, each component being an unsigned + 32-bit value. Whole seconds are in tv_sec which is a 64-bit + value combined from tv_sec_hi and tv_sec_lo, and the + additional fractional part in tv_nsec as nanoseconds. Hence, + for valid timestamps tv_nsec must be in [0, 999999999]. + + Note that clock_id applies only to the presentation clock, + and implies nothing about e.g. the timestamps used in the + Wayland core protocol input events. + + Compositors should prefer a clock which does not jump and is + not slewed e.g. by NTP. The absolute value of the clock is + irrelevant. Precision of one millisecond or better is + recommended. Clients must be able to query the current clock + value directly, not by asking the compositor. + </description> + <arg name="clk_id" type="uint" summary="platform clock identifier"/> + </event> + + </interface> + + <interface name="wp_presentation_feedback" version="1"> + <description summary="presentation time feedback event"> + A presentation_feedback object returns an indication that a + wl_surface content update has become visible to the user. + One object corresponds to one content update submission + (wl_surface.commit). There are two possible outcomes: the + content update is presented to the user, and a presentation + timestamp delivered; or, the user did not see the content + update because it was superseded or its surface destroyed, + and the content update is discarded. + + Once a presentation_feedback object has delivered a 'presented' + or 'discarded' event it is automatically destroyed. + </description> + + <event name="sync_output"> + <description summary="presentation synchronized to this output"> + As presentation can be synchronized to only one output at a + time, this event tells which output it was. This event is only + sent prior to the presented event. + + As clients may bind to the same global wl_output multiple + times, this event is sent for each bound instance that matches + the synchronized output. If a client has not bound to the + right wl_output global at all, this event is not sent. + </description> + <arg name="output" type="object" interface="wl_output" + summary="presentation output"/> + </event> + + <enum name="kind"> + <description summary="bitmask of flags in presented event"> + These flags provide information about how the presentation of + the related content update was done. The intent is to help + clients assess the reliability of the feedback and the visual + quality with respect to possible tearing and timings. The + flags are: + + VSYNC: + The presentation was synchronized to the "vertical retrace" by + the display hardware such that tearing does not happen. + Relying on user space scheduling is not acceptable for this + flag. If presentation is done by a copy to the active + frontbuffer, then it must guarantee that tearing cannot + happen. + + HW_CLOCK: + The display hardware provided measurements that the hardware + driver converted into a presentation timestamp. Sampling a + clock in user space is not acceptable for this flag. + + HW_COMPLETION: + The display hardware signalled that it started using the new + image content. The opposite of this is e.g. a timer being used + to guess when the display hardware has switched to the new + image content. + + ZERO_COPY: + The presentation of this update was done zero-copy. This means + the buffer from the client was given to display hardware as + is, without copying it. Compositing with OpenGL counts as + copying, even if textured directly from the client buffer. + Possible zero-copy cases include direct scanout of a + fullscreen surface and a surface on a hardware overlay. + </description> + <entry name="vsync" value="0x1" summary="presentation was vsync'd"/> + <entry name="hw_clock" value="0x2" + summary="hardware provided the presentation timestamp"/> + <entry name="hw_completion" value="0x4" + summary="hardware signalled the start of the presentation"/> + <entry name="zero_copy" value="0x8" + summary="presentation was done zero-copy"/> + </enum> + + <event name="presented"> + <description summary="the content update was displayed"> + The associated content update was displayed to the user at the + indicated time (tv_sec_hi/lo, tv_nsec). For the interpretation of + the timestamp, see presentation.clock_id event. + + The timestamp corresponds to the time when the content update + turned into light the first time on the surface's main output. + Compositors may approximate this from the framebuffer flip + completion events from the system, and the latency of the + physical display path if known. + + This event is preceded by all related sync_output events + telling which output's refresh cycle the feedback corresponds + to, i.e. the main output for the surface. Compositors are + recommended to choose the output containing the largest part + of the wl_surface, or keeping the output they previously + chose. Having a stable presentation output association helps + clients predict future output refreshes (vblank). + + The 'refresh' argument gives the compositor's prediction of how + many nanoseconds after tv_sec, tv_nsec the very next output + refresh may occur. This is to further aid clients in + predicting future refreshes, i.e., estimating the timestamps + targeting the next few vblanks. If such prediction cannot + usefully be done, the argument is zero. + + If the output does not have a constant refresh rate, explicit + video mode switches excluded, then the refresh argument must + be zero. + + The 64-bit value combined from seq_hi and seq_lo is the value + of the output's vertical retrace counter when the content + update was first scanned out to the display. This value must + be compatible with the definition of MSC in + GLX_OML_sync_control specification. Note, that if the display + path has a non-zero latency, the time instant specified by + this counter may differ from the timestamp's. + + If the output does not have a concept of vertical retrace or a + refresh cycle, or the output device is self-refreshing without + a way to query the refresh count, then the arguments seq_hi + and seq_lo must be zero. + </description> + <arg name="tv_sec_hi" type="uint" + summary="high 32 bits of the seconds part of the presentation timestamp"/> + <arg name="tv_sec_lo" type="uint" + summary="low 32 bits of the seconds part of the presentation timestamp"/> + <arg name="tv_nsec" type="uint" + summary="nanoseconds part of the presentation timestamp"/> + <arg name="refresh" type="uint" summary="nanoseconds till next refresh"/> + <arg name="seq_hi" type="uint" + summary="high 32 bits of refresh counter"/> + <arg name="seq_lo" type="uint" + summary="low 32 bits of refresh counter"/> + <arg name="flags" type="uint" summary="combination of 'kind' values"/> + </event> + + <event name="discarded"> + <description summary="the content update was not displayed"> + The content update was never displayed to the user. + </description> + </event> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/viewporter/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/viewporter/README new file mode 100644 index 0000000..e09057b --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/viewporter/README @@ -0,0 +1,7 @@ +Viewporter: cropping and scaling extension for surface contents + +Previously known as wl_scaler. + +Maintainers: +Pekka Paalanen <pekka.paalanen@collabora.co.uk> + diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/viewporter/viewporter.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/viewporter/viewporter.xml new file mode 100644 index 0000000..c732d8c --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/viewporter/viewporter.xml @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="viewporter"> + + <copyright> + Copyright © 2013-2016 Collabora, Ltd. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="wp_viewporter" version="1"> + <description summary="surface cropping and scaling"> + The global interface exposing surface cropping and scaling + capabilities is used to instantiate an interface extension for a + wl_surface object. This extended interface will then allow + cropping and scaling the surface contents, effectively + disconnecting the direct relationship between the buffer and the + surface size. + </description> + + <request name="destroy" type="destructor"> + <description summary="unbind from the cropping and scaling interface"> + Informs the server that the client will not be using this + protocol object anymore. This does not affect any other objects, + wp_viewport objects included. + </description> + </request> + + <enum name="error"> + <entry name="viewport_exists" value="0" + summary="the surface already has a viewport object associated"/> + </enum> + + <request name="get_viewport"> + <description summary="extend surface interface for crop and scale"> + Instantiate an interface extension for the given wl_surface to + crop and scale its content. If the given wl_surface already has + a wp_viewport object associated, the viewport_exists + protocol error is raised. + </description> + <arg name="id" type="new_id" interface="wp_viewport" + summary="the new viewport interface id"/> + <arg name="surface" type="object" interface="wl_surface" + summary="the surface"/> + </request> + </interface> + + <interface name="wp_viewport" version="1"> + <description summary="crop and scale interface to a wl_surface"> + An additional interface to a wl_surface object, which allows the + client to specify the cropping and scaling of the surface + contents. + + This interface works with two concepts: the source rectangle (src_x, + src_y, src_width, src_height), and the destination size (dst_width, + dst_height). The contents of the source rectangle are scaled to the + destination size, and content outside the source rectangle is ignored. + This state is double-buffered, and is applied on the next + wl_surface.commit. + + The two parts of crop and scale state are independent: the source + rectangle, and the destination size. Initially both are unset, that + is, no scaling is applied. The whole of the current wl_buffer is + used as the source, and the surface size is as defined in + wl_surface.attach. + + If the destination size is set, it causes the surface size to become + dst_width, dst_height. The source (rectangle) is scaled to exactly + this size. This overrides whatever the attached wl_buffer size is, + unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface + has no content and therefore no size. Otherwise, the size is always + at least 1x1 in surface local coordinates. + + If the source rectangle is set, it defines what area of the wl_buffer is + taken as the source. If the source rectangle is set and the destination + size is not set, then src_width and src_height must be integers, and the + surface size becomes the source rectangle size. This results in cropping + without scaling. If src_width or src_height are not integers and + destination size is not set, the bad_size protocol error is raised when + the surface state is applied. + + The coordinate transformations from buffer pixel coordinates up to + the surface-local coordinates happen in the following order: + 1. buffer_transform (wl_surface.set_buffer_transform) + 2. buffer_scale (wl_surface.set_buffer_scale) + 3. crop and scale (wp_viewport.set*) + This means, that the source rectangle coordinates of crop and scale + are given in the coordinates after the buffer transform and scale, + i.e. in the coordinates that would be the surface-local coordinates + if the crop and scale was not applied. + + If src_x or src_y are negative, the bad_value protocol error is raised. + Otherwise, if the source rectangle is partially or completely outside of + the non-NULL wl_buffer, then the out_of_buffer protocol error is raised + when the surface state is applied. A NULL wl_buffer does not raise the + out_of_buffer error. + + The x, y arguments of wl_surface.attach are applied as normal to + the surface. They indicate how many pixels to remove from the + surface size from the left and the top. In other words, they are + still in the surface-local coordinate system, just like dst_width + and dst_height are. + + If the wl_surface associated with the wp_viewport is destroyed, + all wp_viewport requests except 'destroy' raise the protocol error + no_surface. + + If the wp_viewport object is destroyed, the crop and scale + state is removed from the wl_surface. The change will be applied + on the next wl_surface.commit. + </description> + + <request name="destroy" type="destructor"> + <description summary="remove scaling and cropping from the surface"> + The associated wl_surface's crop and scale state is removed. + The change is applied on the next wl_surface.commit. + </description> + </request> + + <enum name="error"> + <entry name="bad_value" value="0" + summary="negative or zero values in width or height"/> + <entry name="bad_size" value="1" + summary="destination size is not integer"/> + <entry name="out_of_buffer" value="2" + summary="source rectangle extends outside of the content area"/> + <entry name="no_surface" value="3" + summary="the wl_surface was destroyed"/> + </enum> + + <request name="set_source"> + <description summary="set the source rectangle for cropping"> + Set the source rectangle of the associated wl_surface. See + wp_viewport for the description, and relation to the wl_buffer + size. + + If all of x, y, width and height are -1.0, the source rectangle is + unset instead. Any other set of values where width or height are zero + or negative, or x or y are negative, raise the bad_value protocol + error. + + The crop and scale state is double-buffered state, and will be + applied on the next wl_surface.commit. + </description> + <arg name="x" type="fixed" summary="source rectangle x"/> + <arg name="y" type="fixed" summary="source rectangle y"/> + <arg name="width" type="fixed" summary="source rectangle width"/> + <arg name="height" type="fixed" summary="source rectangle height"/> + </request> + + <request name="set_destination"> + <description summary="set the surface size for scaling"> + Set the destination size of the associated wl_surface. See + wp_viewport for the description, and relation to the wl_buffer + size. + + If width is -1 and height is -1, the destination size is unset + instead. Any other pair of values for width and height that + contains zero or negative values raises the bad_value protocol + error. + + The crop and scale state is double-buffered state, and will be + applied on the next wl_surface.commit. + </description> + <arg name="width" type="int" summary="surface width"/> + <arg name="height" type="int" summary="surface height"/> + </request> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/xdg-shell/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/xdg-shell/README new file mode 100644 index 0000000..2769abb --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/xdg-shell/README @@ -0,0 +1,5 @@ +xdg shell protocol + +Maintainers: +Jonas Ådahl <jadahl@gmail.com> +Mike Blumenkrantz <zmike@osg.samsung.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/xdg-shell/xdg-shell.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/xdg-shell/xdg-shell.xml new file mode 100644 index 0000000..e259a1f --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/stable/xdg-shell/xdg-shell.xml @@ -0,0 +1,1144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="xdg_shell"> + + <copyright> + Copyright © 2008-2013 Kristian Høgsberg + Copyright © 2013 Rafael Antognolli + Copyright © 2013 Jasper St. Pierre + Copyright © 2010-2013 Intel Corporation + Copyright © 2015-2017 Samsung Electronics Co., Ltd + Copyright © 2015-2017 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="xdg_wm_base" version="2"> + <description summary="create desktop-style surfaces"> + The xdg_wm_base interface is exposed as a global object enabling clients + to turn their wl_surfaces into windows in a desktop environment. It + defines the basic functionality needed for clients and the compositor to + create windows that can be dragged, resized, maximized, etc, as well as + creating transient windows such as popup menus. + </description> + + <enum name="error"> + <entry name="role" value="0" summary="given wl_surface has another role"/> + <entry name="defunct_surfaces" value="1" + summary="xdg_wm_base was destroyed before children"/> + <entry name="not_the_topmost_popup" value="2" + summary="the client tried to map or destroy a non-topmost popup"/> + <entry name="invalid_popup_parent" value="3" + summary="the client specified an invalid popup parent surface"/> + <entry name="invalid_surface_state" value="4" + summary="the client provided an invalid surface state"/> + <entry name="invalid_positioner" value="5" + summary="the client provided an invalid positioner"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="destroy xdg_wm_base"> + Destroy this xdg_wm_base object. + + Destroying a bound xdg_wm_base object while there are surfaces + still alive created by this xdg_wm_base object instance is illegal + and will result in a protocol error. + </description> + </request> + + <request name="create_positioner"> + <description summary="create a positioner object"> + Create a positioner object. A positioner object is used to position + surfaces relative to some parent surface. See the interface description + and xdg_surface.get_popup for details. + </description> + <arg name="id" type="new_id" interface="xdg_positioner"/> + </request> + + <request name="get_xdg_surface"> + <description summary="create a shell surface from a surface"> + This creates an xdg_surface for the given surface. While xdg_surface + itself is not a role, the corresponding surface may only be assigned + a role extending xdg_surface, such as xdg_toplevel or xdg_popup. + + This creates an xdg_surface for the given surface. An xdg_surface is + used as basis to define a role to a given surface, such as xdg_toplevel + or xdg_popup. It also manages functionality shared between xdg_surface + based surface roles. + + See the documentation of xdg_surface for more details about what an + xdg_surface is and how it is used. + </description> + <arg name="id" type="new_id" interface="xdg_surface"/> + <arg name="surface" type="object" interface="wl_surface"/> + </request> + + <request name="pong"> + <description summary="respond to a ping event"> + A client must respond to a ping event with a pong request or + the client may be deemed unresponsive. See xdg_wm_base.ping. + </description> + <arg name="serial" type="uint" summary="serial of the ping event"/> + </request> + + <event name="ping"> + <description summary="check if the client is alive"> + The ping event asks the client if it's still alive. Pass the + serial specified in the event back to the compositor by sending + a "pong" request back with the specified serial. See xdg_wm_base.ping. + + Compositors can use this to determine if the client is still + alive. It's unspecified what will happen if the client doesn't + respond to the ping request, or in what timeframe. Clients should + try to respond in a reasonable amount of time. + + A compositor is free to ping in any way it wants, but a client must + always respond to any xdg_wm_base object it created. + </description> + <arg name="serial" type="uint" summary="pass this to the pong request"/> + </event> + </interface> + + <interface name="xdg_positioner" version="2"> + <description summary="child surface positioner"> + The xdg_positioner provides a collection of rules for the placement of a + child surface relative to a parent surface. Rules can be defined to ensure + the child surface remains within the visible area's borders, and to + specify how the child surface changes its position, such as sliding along + an axis, or flipping around a rectangle. These positioner-created rules are + constrained by the requirement that a child surface must intersect with or + be at least partially adjacent to its parent surface. + + See the various requests for details about possible rules. + + At the time of the request, the compositor makes a copy of the rules + specified by the xdg_positioner. Thus, after the request is complete the + xdg_positioner object can be destroyed or reused; further changes to the + object will have no effect on previous usages. + + For an xdg_positioner object to be considered complete, it must have a + non-zero size set by set_size, and a non-zero anchor rectangle set by + set_anchor_rect. Passing an incomplete xdg_positioner object when + positioning a surface raises an error. + </description> + + <enum name="error"> + <entry name="invalid_input" value="0" summary="invalid input provided"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_positioner object"> + Notify the compositor that the xdg_positioner will no longer be used. + </description> + </request> + + <request name="set_size"> + <description summary="set the size of the to-be positioned rectangle"> + Set the size of the surface that is to be positioned with the positioner + object. The size is in surface-local coordinates and corresponds to the + window geometry. See xdg_surface.set_window_geometry. + + If a zero or negative size is set the invalid_input error is raised. + </description> + <arg name="width" type="int" summary="width of positioned rectangle"/> + <arg name="height" type="int" summary="height of positioned rectangle"/> + </request> + + <request name="set_anchor_rect"> + <description summary="set the anchor rectangle within the parent surface"> + Specify the anchor rectangle within the parent surface that the child + surface will be placed relative to. The rectangle is relative to the + window geometry as defined by xdg_surface.set_window_geometry of the + parent surface. + + When the xdg_positioner object is used to position a child surface, the + anchor rectangle may not extend outside the window geometry of the + positioned child's parent surface. + + If a negative size is set the invalid_input error is raised. + </description> + <arg name="x" type="int" summary="x position of anchor rectangle"/> + <arg name="y" type="int" summary="y position of anchor rectangle"/> + <arg name="width" type="int" summary="width of anchor rectangle"/> + <arg name="height" type="int" summary="height of anchor rectangle"/> + </request> + + <enum name="anchor"> + <entry name="none" value="0"/> + <entry name="top" value="1"/> + <entry name="bottom" value="2"/> + <entry name="left" value="3"/> + <entry name="right" value="4"/> + <entry name="top_left" value="5"/> + <entry name="bottom_left" value="6"/> + <entry name="top_right" value="7"/> + <entry name="bottom_right" value="8"/> + </enum> + + <request name="set_anchor"> + <description summary="set anchor rectangle anchor"> + Defines the anchor point for the anchor rectangle. The specified anchor + is used derive an anchor point that the child surface will be + positioned relative to. If a corner anchor is set (e.g. 'top_left' or + 'bottom_right'), the anchor point will be at the specified corner; + otherwise, the derived anchor point will be centered on the specified + edge, or in the center of the anchor rectangle if no edge is specified. + </description> + <arg name="anchor" type="uint" enum="anchor" + summary="anchor"/> + </request> + + <enum name="gravity"> + <entry name="none" value="0"/> + <entry name="top" value="1"/> + <entry name="bottom" value="2"/> + <entry name="left" value="3"/> + <entry name="right" value="4"/> + <entry name="top_left" value="5"/> + <entry name="bottom_left" value="6"/> + <entry name="top_right" value="7"/> + <entry name="bottom_right" value="8"/> + </enum> + + <request name="set_gravity"> + <description summary="set child surface gravity"> + Defines in what direction a surface should be positioned, relative to + the anchor point of the parent surface. If a corner gravity is + specified (e.g. 'bottom_right' or 'top_left'), then the child surface + will be placed towards the specified gravity; otherwise, the child + surface will be centered over the anchor point on any axis that had no + gravity specified. + </description> + <arg name="gravity" type="uint" enum="gravity" + summary="gravity direction"/> + </request> + + <enum name="constraint_adjustment" bitfield="true"> + <description summary="constraint adjustments"> + The constraint adjustment value define ways the compositor will adjust + the position of the surface, if the unadjusted position would result + in the surface being partly constrained. + + Whether a surface is considered 'constrained' is left to the compositor + to determine. For example, the surface may be partly outside the + compositor's defined 'work area', thus necessitating the child surface's + position be adjusted until it is entirely inside the work area. + + The adjustments can be combined, according to a defined precedence: 1) + Flip, 2) Slide, 3) Resize. + </description> + <entry name="none" value="0"> + <description summary="don't move the child surface when constrained"> + Don't alter the surface position even if it is constrained on some + axis, for example partially outside the edge of an output. + </description> + </entry> + <entry name="slide_x" value="1"> + <description summary="move along the x axis until unconstrained"> + Slide the surface along the x axis until it is no longer constrained. + + First try to slide towards the direction of the gravity on the x axis + until either the edge in the opposite direction of the gravity is + unconstrained or the edge in the direction of the gravity is + constrained. + + Then try to slide towards the opposite direction of the gravity on the + x axis until either the edge in the direction of the gravity is + unconstrained or the edge in the opposite direction of the gravity is + constrained. + </description> + </entry> + <entry name="slide_y" value="2"> + <description summary="move along the y axis until unconstrained"> + Slide the surface along the y axis until it is no longer constrained. + + First try to slide towards the direction of the gravity on the y axis + until either the edge in the opposite direction of the gravity is + unconstrained or the edge in the direction of the gravity is + constrained. + + Then try to slide towards the opposite direction of the gravity on the + y axis until either the edge in the direction of the gravity is + unconstrained or the edge in the opposite direction of the gravity is + constrained. + </description> + </entry> + <entry name="flip_x" value="4"> + <description summary="invert the anchor and gravity on the x axis"> + Invert the anchor and gravity on the x axis if the surface is + constrained on the x axis. For example, if the left edge of the + surface is constrained, the gravity is 'left' and the anchor is + 'left', change the gravity to 'right' and the anchor to 'right'. + + If the adjusted position also ends up being constrained, the resulting + position of the flip_x adjustment will be the one before the + adjustment. + </description> + </entry> + <entry name="flip_y" value="8"> + <description summary="invert the anchor and gravity on the y axis"> + Invert the anchor and gravity on the y axis if the surface is + constrained on the y axis. For example, if the bottom edge of the + surface is constrained, the gravity is 'bottom' and the anchor is + 'bottom', change the gravity to 'top' and the anchor to 'top'. + + The adjusted position is calculated given the original anchor + rectangle and offset, but with the new flipped anchor and gravity + values. + + If the adjusted position also ends up being constrained, the resulting + position of the flip_y adjustment will be the one before the + adjustment. + </description> + </entry> + <entry name="resize_x" value="16"> + <description summary="horizontally resize the surface"> + Resize the surface horizontally so that it is completely + unconstrained. + </description> + </entry> + <entry name="resize_y" value="32"> + <description summary="vertically resize the surface"> + Resize the surface vertically so that it is completely unconstrained. + </description> + </entry> + </enum> + + <request name="set_constraint_adjustment"> + <description summary="set the adjustment to be done when constrained"> + Specify how the window should be positioned if the originally intended + position caused the surface to be constrained, meaning at least + partially outside positioning boundaries set by the compositor. The + adjustment is set by constructing a bitmask describing the adjustment to + be made when the surface is constrained on that axis. + + If no bit for one axis is set, the compositor will assume that the child + surface should not change its position on that axis when constrained. + + If more than one bit for one axis is set, the order of how adjustments + are applied is specified in the corresponding adjustment descriptions. + + The default adjustment is none. + </description> + <arg name="constraint_adjustment" type="uint" + summary="bit mask of constraint adjustments"/> + </request> + + <request name="set_offset"> + <description summary="set surface position offset"> + Specify the surface position offset relative to the position of the + anchor on the anchor rectangle and the anchor on the surface. For + example if the anchor of the anchor rectangle is at (x, y), the surface + has the gravity bottom|right, and the offset is (ox, oy), the calculated + surface position will be (x + ox, y + oy). The offset position of the + surface is the one used for constraint testing. See + set_constraint_adjustment. + + An example use case is placing a popup menu on top of a user interface + element, while aligning the user interface element of the parent surface + with some user interface element placed somewhere in the popup surface. + </description> + <arg name="x" type="int" summary="surface position x offset"/> + <arg name="y" type="int" summary="surface position y offset"/> + </request> + </interface> + + <interface name="xdg_surface" version="2"> + <description summary="desktop user interface surface base interface"> + An interface that may be implemented by a wl_surface, for + implementations that provide a desktop-style user interface. + + It provides a base set of functionality required to construct user + interface elements requiring management by the compositor, such as + toplevel windows, menus, etc. The types of functionality are split into + xdg_surface roles. + + Creating an xdg_surface does not set the role for a wl_surface. In order + to map an xdg_surface, the client must create a role-specific object + using, e.g., get_toplevel, get_popup. The wl_surface for any given + xdg_surface can have at most one role, and may not be assigned any role + not based on xdg_surface. + + A role must be assigned before any other requests are made to the + xdg_surface object. + + The client must call wl_surface.commit on the corresponding wl_surface + for the xdg_surface state to take effect. + + Creating an xdg_surface from a wl_surface which has a buffer attached or + committed is a client error, and any attempts by a client to attach or + manipulate a buffer prior to the first xdg_surface.configure call must + also be treated as errors. + + Mapping an xdg_surface-based role surface is defined as making it + possible for the surface to be shown by the compositor. Note that + a mapped surface is not guaranteed to be visible once it is mapped. + + For an xdg_surface to be mapped by the compositor, the following + conditions must be met: + (1) the client has assigned an xdg_surface-based role to the surface + (2) the client has set and committed the xdg_surface state and the + role-dependent state to the surface + (3) the client has committed a buffer to the surface + + A newly-unmapped surface is considered to have met condition (1) out + of the 3 required conditions for mapping a surface if its role surface + has not been destroyed. + </description> + + <enum name="error"> + <entry name="not_constructed" value="1"/> + <entry name="already_constructed" value="2"/> + <entry name="unconfigured_buffer" value="3"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_surface"> + Destroy the xdg_surface object. An xdg_surface must only be destroyed + after its role object has been destroyed. + </description> + </request> + + <request name="get_toplevel"> + <description summary="assign the xdg_toplevel surface role"> + This creates an xdg_toplevel object for the given xdg_surface and gives + the associated wl_surface the xdg_toplevel role. + + See the documentation of xdg_toplevel for more details about what an + xdg_toplevel is and how it is used. + </description> + <arg name="id" type="new_id" interface="xdg_toplevel"/> + </request> + + <request name="get_popup"> + <description summary="assign the xdg_popup surface role"> + This creates an xdg_popup object for the given xdg_surface and gives + the associated wl_surface the xdg_popup role. + + If null is passed as a parent, a parent surface must be specified using + some other protocol, before committing the initial state. + + See the documentation of xdg_popup for more details about what an + xdg_popup is and how it is used. + </description> + <arg name="id" type="new_id" interface="xdg_popup"/> + <arg name="parent" type="object" interface="xdg_surface" allow-null="true"/> + <arg name="positioner" type="object" interface="xdg_positioner"/> + </request> + + <request name="set_window_geometry"> + <description summary="set the new window geometry"> + The window geometry of a surface is its "visible bounds" from the + user's perspective. Client-side decorations often have invisible + portions like drop-shadows which should be ignored for the + purposes of aligning, placing and constraining windows. + + The window geometry is double buffered, and will be applied at the + time wl_surface.commit of the corresponding wl_surface is called. + + When maintaining a position, the compositor should treat the (x, y) + coordinate of the window geometry as the top left corner of the window. + A client changing the (x, y) window geometry coordinate should in + general not alter the position of the window. + + Once the window geometry of the surface is set, it is not possible to + unset it, and it will remain the same until set_window_geometry is + called again, even if a new subsurface or buffer is attached. + + If never set, the value is the full bounds of the surface, + including any subsurfaces. This updates dynamically on every + commit. This unset is meant for extremely simple clients. + + The arguments are given in the surface-local coordinate space of + the wl_surface associated with this xdg_surface. + + The width and height must be greater than zero. Setting an invalid size + will raise an error. When applied, the effective window geometry will be + the set window geometry clamped to the bounding rectangle of the + combined geometry of the surface of the xdg_surface and the associated + subsurfaces. + </description> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="ack_configure"> + <description summary="ack a configure event"> + When a configure event is received, if a client commits the + surface in response to the configure event, then the client + must make an ack_configure request sometime before the commit + request, passing along the serial of the configure event. + + For instance, for toplevel surfaces the compositor might use this + information to move a surface to the top left only when the client has + drawn itself for the maximized or fullscreen state. + + If the client receives multiple configure events before it + can respond to one, it only has to ack the last configure event. + + A client is not required to commit immediately after sending + an ack_configure request - it may even ack_configure several times + before its next surface commit. + + A client may send multiple ack_configure requests before committing, but + only the last request sent before a commit indicates which configure + event the client really is responding to. + </description> + <arg name="serial" type="uint" summary="the serial from the configure event"/> + </request> + + <event name="configure"> + <description summary="suggest a surface change"> + The configure event marks the end of a configure sequence. A configure + sequence is a set of one or more events configuring the state of the + xdg_surface, including the final xdg_surface.configure event. + + Where applicable, xdg_surface surface roles will during a configure + sequence extend this event as a latched state sent as events before the + xdg_surface.configure event. Such events should be considered to make up + a set of atomically applied configuration states, where the + xdg_surface.configure commits the accumulated state. + + Clients should arrange their surface for the new states, and then send + an ack_configure request with the serial sent in this configure event at + some point before committing the new surface. + + If the client receives multiple configure events before it can respond + to one, it is free to discard all but the last event it received. + </description> + <arg name="serial" type="uint" summary="serial of the configure event"/> + </event> + </interface> + + <interface name="xdg_toplevel" version="2"> + <description summary="toplevel surface"> + This interface defines an xdg_surface role which allows a surface to, + among other things, set window-like properties such as maximize, + fullscreen, and minimize, set application-specific metadata like title and + id, and well as trigger user interactive operations such as interactive + resize and move. + + Unmapping an xdg_toplevel means that the surface cannot be shown + by the compositor until it is explicitly mapped again. + All active operations (e.g., move, resize) are canceled and all + attributes (e.g. title, state, stacking, ...) are discarded for + an xdg_toplevel surface when it is unmapped. + + Attaching a null buffer to a toplevel unmaps the surface. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_toplevel"> + This request destroys the role surface and unmaps the surface; + see "Unmapping" behavior in interface section for details. + </description> + </request> + + <request name="set_parent"> + <description summary="set the parent of this surface"> + Set the "parent" of this surface. This surface should be stacked + above the parent surface and all other ancestor surfaces. + + Parent windows should be set on dialogs, toolboxes, or other + "auxiliary" surfaces, so that the parent is raised when the dialog + is raised. + + Setting a null parent for a child window removes any parent-child + relationship for the child. Setting a null parent for a window which + currently has no parent is a no-op. + + If the parent is unmapped then its children are managed as + though the parent of the now-unmapped parent has become the + parent of this surface. If no parent exists for the now-unmapped + parent then the children are managed as though they have no + parent surface. + </description> + <arg name="parent" type="object" interface="xdg_toplevel" allow-null="true"/> + </request> + + <request name="set_title"> + <description summary="set surface title"> + Set a short title for the surface. + + This string may be used to identify the surface in a task bar, + window list, or other user interface elements provided by the + compositor. + + The string must be encoded in UTF-8. + </description> + <arg name="title" type="string"/> + </request> + + <request name="set_app_id"> + <description summary="set application ID"> + Set an application identifier for the surface. + + The app ID identifies the general class of applications to which + the surface belongs. The compositor can use this to group multiple + surfaces together, or to determine how to launch a new application. + + For D-Bus activatable applications, the app ID is used as the D-Bus + service name. + + The compositor shell will try to group application surfaces together + by their app ID. As a best practice, it is suggested to select app + ID's that match the basename of the application's .desktop file. + For example, "org.freedesktop.FooViewer" where the .desktop file is + "org.freedesktop.FooViewer.desktop". + + See the desktop-entry specification [0] for more details on + application identifiers and how they relate to well-known D-Bus + names and .desktop files. + + [0] http://standards.freedesktop.org/desktop-entry-spec/ + </description> + <arg name="app_id" type="string"/> + </request> + + <request name="show_window_menu"> + <description summary="show the window menu"> + Clients implementing client-side decorations might want to show + a context menu when right-clicking on the decorations, giving the + user a menu that they can use to maximize or minimize the window. + + This request asks the compositor to pop up such a window menu at + the given position, relative to the local surface coordinates of + the parent surface. There are no guarantees as to what menu items + the window menu contains. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. + </description> + <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + <arg name="x" type="int" summary="the x position to pop up the window menu at"/> + <arg name="y" type="int" summary="the y position to pop up the window menu at"/> + </request> + + <request name="move"> + <description summary="start an interactive move"> + Start an interactive, user-driven move of the surface. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. The passed + serial is used to determine the type of interactive move (touch, + pointer, etc). + + The server may ignore move requests depending on the state of + the surface (e.g. fullscreen or maximized), or if the passed serial + is no longer valid. + + If triggered, the surface will lose the focus of the device + (wl_pointer, wl_touch, etc) used for the move. It is up to the + compositor to visually indicate that the move is taking place, such as + updating a pointer cursor, during the move. There is no guarantee + that the device focus will return when the move is completed. + </description> + <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + </request> + + <enum name="resize_edge"> + <description summary="edge values for resizing"> + These values are used to indicate which edge of a surface + is being dragged in a resize operation. + </description> + <entry name="none" value="0"/> + <entry name="top" value="1"/> + <entry name="bottom" value="2"/> + <entry name="left" value="4"/> + <entry name="top_left" value="5"/> + <entry name="bottom_left" value="6"/> + <entry name="right" value="8"/> + <entry name="top_right" value="9"/> + <entry name="bottom_right" value="10"/> + </enum> + + <request name="resize"> + <description summary="start an interactive resize"> + Start a user-driven, interactive resize of the surface. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. The passed + serial is used to determine the type of interactive resize (touch, + pointer, etc). + + The server may ignore resize requests depending on the state of + the surface (e.g. fullscreen or maximized). + + If triggered, the client will receive configure events with the + "resize" state enum value and the expected sizes. See the "resize" + enum value for more details about what is required. The client + must also acknowledge configure events using "ack_configure". After + the resize is completed, the client will receive another "configure" + event without the resize state. + + If triggered, the surface also will lose the focus of the device + (wl_pointer, wl_touch, etc) used for the resize. It is up to the + compositor to visually indicate that the resize is taking place, + such as updating a pointer cursor, during the resize. There is no + guarantee that the device focus will return when the resize is + completed. + + The edges parameter specifies how the surface should be resized, + and is one of the values of the resize_edge enum. The compositor + may use this information to update the surface position for + example when dragging the top left corner. The compositor may also + use this information to adapt its behavior, e.g. choose an + appropriate cursor image. + </description> + <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + <arg name="edges" type="uint" summary="which edge or corner is being dragged"/> + </request> + + <enum name="state"> + <description summary="types of state on the surface"> + The different state values used on the surface. This is designed for + state values like maximized, fullscreen. It is paired with the + configure event to ensure that both the client and the compositor + setting the state can be synchronized. + + States set in this way are double-buffered. They will get applied on + the next commit. + </description> + <entry name="maximized" value="1" summary="the surface is maximized"> + <description summary="the surface is maximized"> + The surface is maximized. The window geometry specified in the configure + event must be obeyed by the client. + + The client should draw without shadow or other + decoration outside of the window geometry. + </description> + </entry> + <entry name="fullscreen" value="2" summary="the surface is fullscreen"> + <description summary="the surface is fullscreen"> + The surface is fullscreen. The window geometry specified in the + configure event is a maximum; the client cannot resize beyond it. For + a surface to cover the whole fullscreened area, the geometry + dimensions must be obeyed by the client. For more details, see + xdg_toplevel.set_fullscreen. + </description> + </entry> + <entry name="resizing" value="3" summary="the surface is being resized"> + <description summary="the surface is being resized"> + The surface is being resized. The window geometry specified in the + configure event is a maximum; the client cannot resize beyond it. + Clients that have aspect ratio or cell sizing configuration can use + a smaller size, however. + </description> + </entry> + <entry name="activated" value="4" summary="the surface is now activated"> + <description summary="the surface is now activated"> + Client window decorations should be painted as if the window is + active. Do not assume this means that the window actually has + keyboard or pointer focus. + </description> + </entry> + <entry name="tiled_left" value="5" since="2"> + <description summary="the surface is tiled"> + The window is currently in a tiled layout and the left edge is + considered to be adjacent to another part of the tiling grid. + </description> + </entry> + <entry name="tiled_right" value="6" since="2"> + <description summary="the surface is tiled"> + The window is currently in a tiled layout and the right edge is + considered to be adjacent to another part of the tiling grid. + </description> + </entry> + <entry name="tiled_top" value="7" since="2"> + <description summary="the surface is tiled"> + The window is currently in a tiled layout and the top edge is + considered to be adjacent to another part of the tiling grid. + </description> + </entry> + <entry name="tiled_bottom" value="8" since="2"> + <description summary="the surface is tiled"> + The window is currently in a tiled layout and the bottom edge is + considered to be adjacent to another part of the tiling grid. + </description> + </entry> + </enum> + + <request name="set_max_size"> + <description summary="set the maximum size"> + Set a maximum size for the window. + + The client can specify a maximum size so that the compositor does + not try to configure the window beyond this size. + + The width and height arguments are in window geometry coordinates. + See xdg_surface.set_window_geometry. + + Values set in this way are double-buffered. They will get applied + on the next commit. + + The compositor can use this information to allow or disallow + different states like maximize or fullscreen and draw accurate + animations. + + Similarly, a tiling window manager may use this information to + place and resize client windows in a more effective way. + + The client should not rely on the compositor to obey the maximum + size. The compositor may decide to ignore the values set by the + client and request a larger size. + + If never set, or a value of zero in the request, means that the + client has no expected maximum size in the given dimension. + As a result, a client wishing to reset the maximum size + to an unspecified state can use zero for width and height in the + request. + + Requesting a maximum size to be smaller than the minimum size of + a surface is illegal and will result in a protocol error. + + The width and height must be greater than or equal to zero. Using + strictly negative values for width and height will result in a + protocol error. + </description> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="set_min_size"> + <description summary="set the minimum size"> + Set a minimum size for the window. + + The client can specify a minimum size so that the compositor does + not try to configure the window below this size. + + The width and height arguments are in window geometry coordinates. + See xdg_surface.set_window_geometry. + + Values set in this way are double-buffered. They will get applied + on the next commit. + + The compositor can use this information to allow or disallow + different states like maximize or fullscreen and draw accurate + animations. + + Similarly, a tiling window manager may use this information to + place and resize client windows in a more effective way. + + The client should not rely on the compositor to obey the minimum + size. The compositor may decide to ignore the values set by the + client and request a smaller size. + + If never set, or a value of zero in the request, means that the + client has no expected minimum size in the given dimension. + As a result, a client wishing to reset the minimum size + to an unspecified state can use zero for width and height in the + request. + + Requesting a minimum size to be larger than the maximum size of + a surface is illegal and will result in a protocol error. + + The width and height must be greater than or equal to zero. Using + strictly negative values for width and height will result in a + protocol error. + </description> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="set_maximized"> + <description summary="maximize the window"> + Maximize the surface. + + After requesting that the surface should be maximized, the compositor + will respond by emitting a configure event. Whether this configure + actually sets the window maximized is subject to compositor policies. + The client must then update its content, drawing in the configured + state. The client must also acknowledge the configure when committing + the new content (see ack_configure). + + It is up to the compositor to decide how and where to maximize the + surface, for example which output and what region of the screen should + be used. + + If the surface was already maximized, the compositor will still emit + a configure event with the "maximized" state. + + If the surface is in a fullscreen state, this request has no direct + effect. It may alter the state the surface is returned to when + unmaximized unless overridden by the compositor. + </description> + </request> + + <request name="unset_maximized"> + <description summary="unmaximize the window"> + Unmaximize the surface. + + After requesting that the surface should be unmaximized, the compositor + will respond by emitting a configure event. Whether this actually + un-maximizes the window is subject to compositor policies. + If available and applicable, the compositor will include the window + geometry dimensions the window had prior to being maximized in the + configure event. The client must then update its content, drawing it in + the configured state. The client must also acknowledge the configure + when committing the new content (see ack_configure). + + It is up to the compositor to position the surface after it was + unmaximized; usually the position the surface had before maximizing, if + applicable. + + If the surface was already not maximized, the compositor will still + emit a configure event without the "maximized" state. + + If the surface is in a fullscreen state, this request has no direct + effect. It may alter the state the surface is returned to when + unmaximized unless overridden by the compositor. + </description> + </request> + + <request name="set_fullscreen"> + <description summary="set the window as fullscreen on an output"> + Make the surface fullscreen. + + After requesting that the surface should be fullscreened, the + compositor will respond by emitting a configure event. Whether the + client is actually put into a fullscreen state is subject to compositor + policies. The client must also acknowledge the configure when + committing the new content (see ack_configure). + + The output passed by the request indicates the client's preference as + to which display it should be set fullscreen on. If this value is NULL, + it's up to the compositor to choose which display will be used to map + this surface. + + If the surface doesn't cover the whole output, the compositor will + position the surface in the center of the output and compensate with + with border fill covering the rest of the output. The content of the + border fill is undefined, but should be assumed to be in some way that + attempts to blend into the surrounding area (e.g. solid black). + + If the fullscreened surface is not opaque, the compositor must make + sure that other screen content not part of the same surface tree (made + up of subsurfaces, popups or similarly coupled surfaces) are not + visible below the fullscreened surface. + </description> + <arg name="output" type="object" interface="wl_output" allow-null="true"/> + </request> + + <request name="unset_fullscreen"> + <description summary="unset the window as fullscreen"> + Make the surface no longer fullscreen. + + After requesting that the surface should be unfullscreened, the + compositor will respond by emitting a configure event. + Whether this actually removes the fullscreen state of the client is + subject to compositor policies. + + Making a surface unfullscreen sets states for the surface based on the following: + * the state(s) it may have had before becoming fullscreen + * any state(s) decided by the compositor + * any state(s) requested by the client while the surface was fullscreen + + The compositor may include the previous window geometry dimensions in + the configure event, if applicable. + + The client must also acknowledge the configure when committing the new + content (see ack_configure). + </description> + </request> + + <request name="set_minimized"> + <description summary="set the window as minimized"> + Request that the compositor minimize your surface. There is no + way to know if the surface is currently minimized, nor is there + any way to unset minimization on this surface. + + If you are looking to throttle redrawing when minimized, please + instead use the wl_surface.frame event for this, as this will + also work with live previews on windows in Alt-Tab, Expose or + similar compositor features. + </description> + </request> + + <event name="configure"> + <description summary="suggest a surface change"> + This configure event asks the client to resize its toplevel surface or + to change its state. The configured state should not be applied + immediately. See xdg_surface.configure for details. + + The width and height arguments specify a hint to the window + about how its surface should be resized in window geometry + coordinates. See set_window_geometry. + + If the width or height arguments are zero, it means the client + should decide its own window dimension. This may happen when the + compositor needs to configure the state of the surface but doesn't + have any information about any previous or expected dimension. + + The states listed in the event specify how the width/height + arguments should be interpreted, and possibly how it should be + drawn. + + Clients must send an ack_configure in response to this event. See + xdg_surface.configure and xdg_surface.ack_configure for details. + </description> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + <arg name="states" type="array"/> + </event> + + <event name="close"> + <description summary="surface wants to be closed"> + The close event is sent by the compositor when the user + wants the surface to be closed. This should be equivalent to + the user clicking the close button in client-side decorations, + if your application has any. + + This is only a request that the user intends to close the + window. The client may choose to ignore this request, or show + a dialog to ask the user to save their data, etc. + </description> + </event> + </interface> + + <interface name="xdg_popup" version="2"> + <description summary="short-lived, popup surfaces for menus"> + A popup surface is a short-lived, temporary surface. It can be used to + implement for example menus, popovers, tooltips and other similar user + interface concepts. + + A popup can be made to take an explicit grab. See xdg_popup.grab for + details. + + When the popup is dismissed, a popup_done event will be sent out, and at + the same time the surface will be unmapped. See the xdg_popup.popup_done + event for details. + + Explicitly destroying the xdg_popup object will also dismiss the popup and + unmap the surface. Clients that want to dismiss the popup when another + surface of their own is clicked should dismiss the popup using the destroy + request. + + A newly created xdg_popup will be stacked on top of all previously created + xdg_popup surfaces associated with the same xdg_toplevel. + + The parent of an xdg_popup must be mapped (see the xdg_surface + description) before the xdg_popup itself. + + The x and y arguments passed when creating the popup object specify + where the top left of the popup should be placed, relative to the + local surface coordinates of the parent surface. See + xdg_surface.get_popup. An xdg_popup must intersect with or be at least + partially adjacent to its parent surface. + + The client must call wl_surface.commit on the corresponding wl_surface + for the xdg_popup state to take effect. + </description> + + <enum name="error"> + <entry name="invalid_grab" value="0" + summary="tried to grab after being mapped"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="remove xdg_popup interface"> + This destroys the popup. Explicitly destroying the xdg_popup + object will also dismiss the popup, and unmap the surface. + + If this xdg_popup is not the "topmost" popup, a protocol error + will be sent. + </description> + </request> + + <request name="grab"> + <description summary="make the popup take an explicit grab"> + This request makes the created popup take an explicit grab. An explicit + grab will be dismissed when the user dismisses the popup, or when the + client destroys the xdg_popup. This can be done by the user clicking + outside the surface, using the keyboard, or even locking the screen + through closing the lid or a timeout. + + If the compositor denies the grab, the popup will be immediately + dismissed. + + This request must be used in response to some sort of user action like a + button press, key press, or touch down event. The serial number of the + event should be passed as 'serial'. + + The parent of a grabbing popup must either be an xdg_toplevel surface or + another xdg_popup with an explicit grab. If the parent is another + xdg_popup it means that the popups are nested, with this popup now being + the topmost popup. + + Nested popups must be destroyed in the reverse order they were created + in, e.g. the only popup you are allowed to destroy at all times is the + topmost one. + + When compositors choose to dismiss a popup, they may dismiss every + nested grabbing popup as well. When a compositor dismisses popups, it + will follow the same dismissing order as required from the client. + + The parent of a grabbing popup must either be another xdg_popup with an + active explicit grab, or an xdg_popup or xdg_toplevel, if there are no + explicit grabs already taken. + + If the topmost grabbing popup is destroyed, the grab will be returned to + the parent of the popup, if that parent previously had an explicit grab. + + If the parent is a grabbing popup which has already been dismissed, this + popup will be immediately dismissed. If the parent is a popup that did + not take an explicit grab, an error will be raised. + + During a popup grab, the client owning the grab will receive pointer + and touch events for all their surfaces as normal (similar to an + "owner-events" grab in X11 parlance), while the top most grabbing popup + will always have keyboard focus. + </description> + <arg name="seat" type="object" interface="wl_seat" + summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + </request> + + <event name="configure"> + <description summary="configure the popup surface"> + This event asks the popup surface to configure itself given the + configuration. The configured state should not be applied immediately. + See xdg_surface.configure for details. + + The x and y arguments represent the position the popup was placed at + given the xdg_positioner rule, relative to the upper left corner of the + window geometry of the parent surface. + </description> + <arg name="x" type="int" + summary="x position relative to parent surface window geometry"/> + <arg name="y" type="int" + summary="y position relative to parent surface window geometry"/> + <arg name="width" type="int" summary="window geometry width"/> + <arg name="height" type="int" summary="window geometry height"/> + </event> + + <event name="popup_done"> + <description summary="popup interaction is done"> + The popup_done event is sent out when a popup is dismissed by the + compositor. The client should destroy the xdg_popup object at this + point. + </description> + </event> + + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/tests/scan.sh b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/tests/scan.sh new file mode 100755 index 0000000..cad6887 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/tests/scan.sh @@ -0,0 +1,11 @@ +#!/bin/sh -e + +if [ "x$SCANNER" = "x" ] ; then + echo "No scanner present, test skipped." 1>&2 + exit 77 +fi + +$SCANNER client-header --strict $1 /dev/null +$SCANNER server-header --strict $1 /dev/null +$SCANNER private-code --strict $1 /dev/null +$SCANNER public-code --strict $1 /dev/null diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/fullscreen-shell/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/fullscreen-shell/README new file mode 100644 index 0000000..5ad740f --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/fullscreen-shell/README @@ -0,0 +1,4 @@ +Fullscreen shell protocol + +Maintainers: +Jason Ekstrand <jason@jlekstrand.net> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml new file mode 100644 index 0000000..1bca7b7 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml @@ -0,0 +1,245 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="fullscreen_shell_unstable_v1"> + + <copyright> + Copyright © 2016 Yong Bakos + Copyright © 2015 Jason Ekstrand + Copyright © 2015 Jonas Ådahl + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="zwp_fullscreen_shell_v1" version="1"> + <description summary="displays a single surface per output"> + Displays a single surface per output. + + This interface provides a mechanism for a single client to display + simple full-screen surfaces. While there technically may be multiple + clients bound to this interface, only one of those clients should be + shown at a time. + + To present a surface, the client uses either the present_surface or + present_surface_for_mode requests. Presenting a surface takes effect + on the next wl_surface.commit. See the individual requests for + details about scaling and mode switches. + + The client can have at most one surface per output at any time. + Requesting a surface to be presented on an output that already has a + surface replaces the previously presented surface. Presenting a null + surface removes its content and effectively disables the output. + Exactly what happens when an output is "disabled" is + compositor-specific. The same surface may be presented on multiple + outputs simultaneously. + + Once a surface is presented on an output, it stays on that output + until either the client removes it or the compositor destroys the + output. This way, the client can update the output's contents by + simply attaching a new buffer. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <request name="release" type="destructor"> + <description summary="release the wl_fullscreen_shell interface"> + Release the binding from the wl_fullscreen_shell interface. + + This destroys the server-side object and frees this binding. If + the client binds to wl_fullscreen_shell multiple times, it may wish + to free some of those bindings. + </description> + </request> + + <enum name="capability"> + <description summary="capabilities advertised by the compositor"> + Various capabilities that can be advertised by the compositor. They + are advertised one-at-a-time when the wl_fullscreen_shell interface is + bound. See the wl_fullscreen_shell.capability event for more details. + + ARBITRARY_MODES: + This is a hint to the client that indicates that the compositor is + capable of setting practically any mode on its outputs. If this + capability is provided, wl_fullscreen_shell.present_surface_for_mode + will almost never fail and clients should feel free to set whatever + mode they like. If the compositor does not advertise this, it may + still support some modes that are not advertised through wl_global.mode + but it is less likely. + + CURSOR_PLANE: + This is a hint to the client that indicates that the compositor can + handle a cursor surface from the client without actually compositing. + This may be because of a hardware cursor plane or some other mechanism. + If the compositor does not advertise this capability then setting + wl_pointer.cursor may degrade performance or be ignored entirely. If + CURSOR_PLANE is not advertised, it is recommended that the client draw + its own cursor and set wl_pointer.cursor(NULL). + </description> + <entry name="arbitrary_modes" value="1" summary="compositor is capable of almost any output mode"/> + <entry name="cursor_plane" value="2" summary="compositor has a separate cursor plane"/> + </enum> + + <event name="capability"> + <description summary="advertises a capability of the compositor"> + Advertises a single capability of the compositor. + + When the wl_fullscreen_shell interface is bound, this event is emitted + once for each capability advertised. Valid capabilities are given by + the wl_fullscreen_shell.capability enum. If clients want to take + advantage of any of these capabilities, they should use a + wl_display.sync request immediately after binding to ensure that they + receive all the capability events. + </description> + <arg name="capability" type="uint"/> + </event> + + <enum name="present_method"> + <description summary="different method to set the surface fullscreen"> + Hints to indicate to the compositor how to deal with a conflict + between the dimensions of the surface and the dimensions of the + output. The compositor is free to ignore this parameter. + </description> + <entry name="default" value="0" summary="no preference, apply default policy"/> + <entry name="center" value="1" summary="center the surface on the output"/> + <entry name="zoom" value="2" summary="scale the surface, preserving aspect ratio, to the largest size that will fit on the output" /> + <entry name="zoom_crop" value="3" summary="scale the surface, preserving aspect ratio, to fully fill the output cropping if needed" /> + <entry name="stretch" value="4" summary="scale the surface to the size of the output ignoring aspect ratio" /> + </enum> + + <request name="present_surface"> + <description summary="present surface for display"> + Present a surface on the given output. + + If the output is null, the compositor will present the surface on + whatever display (or displays) it thinks best. In particular, this + may replace any or all surfaces currently presented so it should + not be used in combination with placing surfaces on specific + outputs. + + The method parameter is a hint to the compositor for how the surface + is to be presented. In particular, it tells the compositor how to + handle a size mismatch between the presented surface and the + output. The compositor is free to ignore this parameter. + + The "zoom", "zoom_crop", and "stretch" methods imply a scaling + operation on the surface. This will override any kind of output + scaling, so the buffer_scale property of the surface is effectively + ignored. + </description> + <arg name="surface" type="object" interface="wl_surface" allow-null="true"/> + <arg name="method" type="uint"/> + <arg name="output" type="object" interface="wl_output" allow-null="true"/> + </request> + + <request name="present_surface_for_mode"> + <description summary="present surface for display at a particular mode"> + Presents a surface on the given output for a particular mode. + + If the current size of the output differs from that of the surface, + the compositor will attempt to change the size of the output to + match the surface. The result of the mode-switch operation will be + returned via the provided wl_fullscreen_shell_mode_feedback object. + + If the current output mode matches the one requested or if the + compositor successfully switches the mode to match the surface, + then the mode_successful event will be sent and the output will + contain the contents of the given surface. If the compositor + cannot match the output size to the surface size, the mode_failed + will be sent and the output will contain the contents of the + previously presented surface (if any). If another surface is + presented on the given output before either of these has a chance + to happen, the present_cancelled event will be sent. + + Due to race conditions and other issues unknown to the client, no + mode-switch operation is guaranteed to succeed. However, if the + mode is one advertised by wl_output.mode or if the compositor + advertises the ARBITRARY_MODES capability, then the client should + expect that the mode-switch operation will usually succeed. + + If the size of the presented surface changes, the resulting output + is undefined. The compositor may attempt to change the output mode + to compensate. However, there is no guarantee that a suitable mode + will be found and the client has no way to be notified of success + or failure. + + The framerate parameter specifies the desired framerate for the + output in mHz. The compositor is free to ignore this parameter. A + value of 0 indicates that the client has no preference. + + If the value of wl_output.scale differs from wl_surface.buffer_scale, + then the compositor may choose a mode that matches either the buffer + size or the surface size. In either case, the surface will fill the + output. + </description> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="output" type="object" interface="wl_output"/> + <arg name="framerate" type="int"/> + <arg name="feedback" type="new_id" interface="zwp_fullscreen_shell_mode_feedback_v1"/> + </request> + + <enum name="error"> + <description summary="wl_fullscreen_shell error values"> + These errors can be emitted in response to wl_fullscreen_shell requests. + </description> + <entry name="invalid_method" value="0" summary="present_method is not known"/> + </enum> + </interface> + + <interface name="zwp_fullscreen_shell_mode_feedback_v1" version="1"> + <event name="mode_successful"> + <description summary="mode switch succeeded"> + This event indicates that the attempted mode switch operation was + successful. A surface of the size requested in the mode switch + will fill the output without scaling. + + Upon receiving this event, the client should destroy the + wl_fullscreen_shell_mode_feedback object. + </description> + </event> + + <event name="mode_failed"> + <description summary="mode switch failed"> + This event indicates that the attempted mode switch operation + failed. This may be because the requested output mode is not + possible or it may mean that the compositor does not want to allow it. + + Upon receiving this event, the client should destroy the + wl_fullscreen_shell_mode_feedback object. + </description> + </event> + + <event name="present_cancelled"> + <description summary="mode switch cancelled"> + This event indicates that the attempted mode switch operation was + cancelled. Most likely this is because the client requested a + second mode switch before the first one completed. + + Upon receiving this event, the client should destroy the + wl_fullscreen_shell_mode_feedback object. + </description> + </event> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/idle-inhibit/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/idle-inhibit/README new file mode 100644 index 0000000..396e871 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/idle-inhibit/README @@ -0,0 +1,4 @@ +Screensaver inhibition protocol + +Maintainers: +Bryce Harrington <bryce@osg.samsung.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml new file mode 100644 index 0000000..9c06cdc --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="idle_inhibit_unstable_v1"> + + <copyright> + Copyright © 2015 Samsung Electronics Co., Ltd + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="zwp_idle_inhibit_manager_v1" version="1"> + <description summary="control behavior when display idles"> + This interface permits inhibiting the idle behavior such as screen + blanking, locking, and screensaving. The client binds the idle manager + globally, then creates idle-inhibitor objects for each surface. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the idle inhibitor object"> + Destroy the inhibit manager. + </description> + </request> + + <request name="create_inhibitor"> + <description summary="create a new inhibitor object"> + Create a new inhibitor object associated with the given surface. + </description> + <arg name="id" type="new_id" interface="zwp_idle_inhibitor_v1"/> + <arg name="surface" type="object" interface="wl_surface" + summary="the surface that inhibits the idle behavior"/> + </request> + + </interface> + + <interface name="zwp_idle_inhibitor_v1" version="1"> + <description summary="context object for inhibiting idle behavior"> + An idle inhibitor prevents the output that the associated surface is + visible on from being set to a state where it is not visually usable due + to lack of user interaction (e.g. blanked, dimmed, locked, set to power + save, etc.) Any screensaver processes are also blocked from displaying. + + If the surface is destroyed, unmapped, becomes occluded, loses + visibility, or otherwise becomes not visually relevant for the user, the + idle inhibitor will not be honored by the compositor; if the surface + subsequently regains visibility the inhibitor takes effect once again. + Likewise, the inhibitor isn't honored if the system was already idled at + the time the inhibitor was established, although if the system later + de-idles and re-idles the inhibitor will take effect. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the idle inhibitor object"> + Remove the inhibitor effect from the associated wl_surface. + </description> + </request> + + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-method/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-method/README new file mode 100644 index 0000000..c95ba72 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-method/README @@ -0,0 +1,4 @@ +Input method protocol + +Maintainers: +Jan Arne Petersen <janarne@gmail.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-method/input-method-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-method/input-method-unstable-v1.xml new file mode 100644 index 0000000..e9d93ba --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-method/input-method-unstable-v1.xml @@ -0,0 +1,305 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="input_method_unstable_v1"> + + <copyright> + Copyright © 2012, 2013 Intel Corporation + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="zwp_input_method_context_v1" version="1"> + <description summary="input method context"> + Corresponds to a text input on the input method side. An input method context + is created on text input activation on the input method side. It allows + receiving information about the text input from the application via events. + Input method contexts do not keep state after deactivation and should be + destroyed after deactivation is handled. + + Text is generally UTF-8 encoded, indices and lengths are in bytes. + + Serials are used to synchronize the state between the text input and + an input method. New serials are sent by the text input in the + commit_state request and are used by the input method to indicate + the known text input state in events like preedit_string, commit_string, + and keysym. The text input can then ignore events from the input method + which are based on an outdated state (for example after a reset). + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <request name="destroy" type="destructor"/> + + <request name="commit_string"> + <description summary="commit string"> + Send the commit string text for insertion to the application. + + The text to commit could be either just a single character after a key + press or the result of some composing (pre-edit). It could be also an + empty text when some text should be removed (see + delete_surrounding_text) or when the input cursor should be moved (see + cursor_position). + + Any previously set composing text will be removed. + </description> + <arg name="serial" type="uint" summary="serial of the latest known text input state"/> + <arg name="text" type="string"/> + </request> + + <request name="preedit_string"> + <description summary="pre-edit string"> + Send the pre-edit string text to the application text input. + + The commit text can be used to replace the pre-edit text on reset (for + example on unfocus). + + Previously sent preedit_style and preedit_cursor requests are also + processed by the text_input. + </description> + <arg name="serial" type="uint" summary="serial of the latest known text input state"/> + <arg name="text" type="string"/> + <arg name="commit" type="string"/> + </request> + + <request name="preedit_styling"> + <description summary="pre-edit styling"> + Set the styling information on composing text. The style is applied for + length in bytes from index relative to the beginning of + the composing text (as byte offset). Multiple styles can + be applied to a composing text. + + This request should be sent before sending a preedit_string request. + </description> + <arg name="index" type="uint"/> + <arg name="length" type="uint"/> + <arg name="style" type="uint"/> + </request> + + <request name="preedit_cursor"> + <description summary="pre-edit cursor"> + Set the cursor position inside the composing text (as byte offset) + relative to the start of the composing text. + + When index is negative no cursor should be displayed. + + This request should be sent before sending a preedit_string request. + </description> + <arg name="index" type="int"/> + </request> + + <request name="delete_surrounding_text"> + <description summary="delete text"> + Remove the surrounding text. + + This request will be handled on the text_input side directly following + a commit_string request. + </description> + <arg name="index" type="int"/> + <arg name="length" type="uint"/> + </request> + + <request name="cursor_position"> + <description summary="set cursor to a new position"> + Set the cursor and anchor to a new position. Index is the new cursor + position in bytes (when >= 0 this is relative to the end of the inserted text, + otherwise it is relative to the beginning of the inserted text). Anchor is + the new anchor position in bytes (when >= 0 this is relative to the end of the + inserted text, otherwise it is relative to the beginning of the inserted + text). When there should be no selected text, anchor should be the same + as index. + + This request will be handled on the text_input side directly following + a commit_string request. + </description> + <arg name="index" type="int"/> + <arg name="anchor" type="int"/> + </request> + + <request name="modifiers_map"> + <arg name="map" type="array"/> + </request> + + <request name="keysym"> + <description summary="keysym"> + Notify when a key event was sent. Key events should not be used for + normal text input operations, which should be done with commit_string, + delete_surrounding_text, etc. The key event follows the wl_keyboard key + event convention. Sym is an XKB keysym, state is a wl_keyboard key_state. + </description> + <arg name="serial" type="uint" summary="serial of the latest known text input state"/> + <arg name="time" type="uint"/> + <arg name="sym" type="uint"/> + <arg name="state" type="uint"/> + <arg name="modifiers" type="uint"/> + </request> + + <request name="grab_keyboard"> + <description summary="grab hardware keyboard"> + Allow an input method to receive hardware keyboard input and process + key events to generate text events (with pre-edit) over the wire. This + allows input methods which compose multiple key events for inputting + text like it is done for CJK languages. + </description> + <arg name="keyboard" type="new_id" interface="wl_keyboard"/> + </request> + + <request name="key"> + <description summary="forward key event"> + Forward a wl_keyboard::key event to the client that was not processed + by the input method itself. Should be used when filtering key events + with grab_keyboard. The arguments should be the ones from the + wl_keyboard::key event. + + For generating custom key events use the keysym request instead. + </description> + <arg name="serial" type="uint" summary="serial from wl_keyboard::key"/> + <arg name="time" type="uint" summary="time from wl_keyboard::key"/> + <arg name="key" type="uint" summary="key from wl_keyboard::key"/> + <arg name="state" type="uint" summary="state from wl_keyboard::key"/> + </request> + + <request name="modifiers"> + <description summary="forward modifiers event"> + Forward a wl_keyboard::modifiers event to the client that was not + processed by the input method itself. Should be used when filtering + key events with grab_keyboard. The arguments should be the ones + from the wl_keyboard::modifiers event. + </description> + <arg name="serial" type="uint" summary="serial from wl_keyboard::modifiers"/> + <arg name="mods_depressed" type="uint" summary="mods_depressed from wl_keyboard::modifiers"/> + <arg name="mods_latched" type="uint" summary="mods_latched from wl_keyboard::modifiers"/> + <arg name="mods_locked" type="uint" summary="mods_locked from wl_keyboard::modifiers"/> + <arg name="group" type="uint" summary="group from wl_keyboard::modifiers"/> + </request> + + <request name="language"> + <arg name="serial" type="uint" summary="serial of the latest known text input state"/> + <arg name="language" type="string"/> + </request> + + <request name="text_direction"> + <arg name="serial" type="uint" summary="serial of the latest known text input state"/> + <arg name="direction" type="uint"/> + </request> + + <event name="surrounding_text"> + <description summary="surrounding text event"> + The plain surrounding text around the input position. Cursor is the + position in bytes within the surrounding text relative to the beginning + of the text. Anchor is the position in bytes of the selection anchor + within the surrounding text relative to the beginning of the text. If + there is no selected text then anchor is the same as cursor. + </description> + <arg name="text" type="string"/> + <arg name="cursor" type="uint"/> + <arg name="anchor" type="uint"/> + </event> + + <event name="reset"> + </event> + + <event name="content_type"> + <arg name="hint" type="uint"/> + <arg name="purpose" type="uint"/> + </event> + + <event name="invoke_action"> + <arg name="button" type="uint"/> + <arg name="index" type="uint"/> + </event> + + <event name="commit_state"> + <arg name="serial" type="uint" summary="serial of text input state"/> + </event> + + <event name="preferred_language"> + <arg name="language" type="string"/> + </event> + </interface> + + <interface name="zwp_input_method_v1" version="1"> + <description summary="input method"> + An input method object is responsible for composing text in response to + input from hardware or virtual keyboards. There is one input method + object per seat. On activate there is a new input method context object + created which allows the input method to communicate with the text input. + </description> + + <event name="activate"> + <description summary="activate event"> + A text input was activated. Creates an input method context object + which allows communication with the text input. + </description> + <arg name="id" type="new_id" interface="zwp_input_method_context_v1"/> + </event> + + <event name="deactivate"> + <description summary="deactivate event"> + The text input corresponding to the context argument was deactivated. + The input method context should be destroyed after deactivation is + handled. + </description> + <arg name="context" type="object" interface="zwp_input_method_context_v1"/> + </event> + </interface> + + <interface name="zwp_input_panel_v1" version="1"> + <description summary="interface for implementing keyboards"> + Only one client can bind this interface at a time. + </description> + + <request name="get_input_panel_surface"> + <arg name="id" type="new_id" interface="zwp_input_panel_surface_v1"/> + <arg name="surface" type="object" interface="wl_surface"/> + </request> + </interface> + + <interface name="zwp_input_panel_surface_v1" version="1"> + <enum name="position"> + <entry name="center_bottom" value="0"/> + </enum> + + <request name="set_toplevel"> + <description summary="set the surface type as a keyboard"> + Set the input_panel_surface type to keyboard. + + A keyboard surface is only shown when a text input is active. + </description> + <arg name="output" type="object" interface="wl_output"/> + <arg name="position" type="uint"/> + </request> + + <request name="set_overlay_panel"> + <description summary="set the surface type as an overlay panel"> + Set the input_panel_surface to be an overlay panel. + + This is shown near the input cursor above the application window when + a text input is active. + </description> + </request> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-timestamps/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-timestamps/README new file mode 100644 index 0000000..3e82890 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-timestamps/README @@ -0,0 +1,4 @@ +High-resolution timestamps for input events. + +Maintainers: +Alexandros Frantzis <alexandros.frantzis@collabora.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-timestamps/input-timestamps-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-timestamps/input-timestamps-unstable-v1.xml new file mode 100644 index 0000000..7c5e082 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/input-timestamps/input-timestamps-unstable-v1.xml @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="input_timestamps_unstable_v1"> + + <copyright> + Copyright © 2017 Collabora, Ltd. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="High-resolution timestamps for input events"> + This protocol specifies a way for a client to request and receive + high-resolution timestamps for input events. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <interface name="zwp_input_timestamps_manager_v1" version="1"> + <description summary="context object for high-resolution input timestamps"> + A global interface used for requesting high-resolution timestamps + for input events. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the input timestamps manager object"> + Informs the server that the client will no longer be using this + protocol object. Existing objects created by this object are not + affected. + </description> + </request> + + <request name="get_keyboard_timestamps"> + <description summary="subscribe to high-resolution keyboard timestamp events"> + Creates a new input timestamps object that represents a subscription + to high-resolution timestamp events for all wl_keyboard events that + carry a timestamp. + + If the associated wl_keyboard object is invalidated, either through + client action (e.g. release) or server-side changes, the input + timestamps object becomes inert and the client should destroy it + by calling zwp_input_timestamps_v1.destroy. + </description> + <arg name="id" type="new_id" interface="zwp_input_timestamps_v1"/> + <arg name="keyboard" type="object" interface="wl_keyboard" + summary="the wl_keyboard object for which to get timestamp events"/> + </request> + + <request name="get_pointer_timestamps"> + <description summary="subscribe to high-resolution pointer timestamp events"> + Creates a new input timestamps object that represents a subscription + to high-resolution timestamp events for all wl_pointer events that + carry a timestamp. + + If the associated wl_pointer object is invalidated, either through + client action (e.g. release) or server-side changes, the input + timestamps object becomes inert and the client should destroy it + by calling zwp_input_timestamps_v1.destroy. + </description> + <arg name="id" type="new_id" interface="zwp_input_timestamps_v1"/> + <arg name="pointer" type="object" interface="wl_pointer" + summary="the wl_pointer object for which to get timestamp events"/> + </request> + + <request name="get_touch_timestamps"> + <description summary="subscribe to high-resolution touch timestamp events"> + Creates a new input timestamps object that represents a subscription + to high-resolution timestamp events for all wl_touch events that + carry a timestamp. + + If the associated wl_touch object becomes invalid, either through + client action (e.g. release) or server-side changes, the input + timestamps object becomes inert and the client should destroy it + by calling zwp_input_timestamps_v1.destroy. + </description> + <arg name="id" type="new_id" interface="zwp_input_timestamps_v1"/> + <arg name="touch" type="object" interface="wl_touch" + summary="the wl_touch object for which to get timestamp events"/> + </request> + </interface> + + <interface name="zwp_input_timestamps_v1" version="1"> + <description summary="context object for input timestamps"> + Provides high-resolution timestamp events for a set of subscribed input + events. The set of subscribed input events is determined by the + zwp_input_timestamps_manager_v1 request used to create this object. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the input timestamps object"> + Informs the server that the client will no longer be using this + protocol object. After the server processes the request, no more + timestamp events will be emitted. + </description> + </request> + + <event name="timestamp"> + <description summary="high-resolution timestamp event"> + The timestamp event is associated with the first subsequent input event + carrying a timestamp which belongs to the set of input events this + object is subscribed to. + + The timestamp provided by this event is a high-resolution version of + the timestamp argument of the associated input event. The provided + timestamp is in the same clock domain and is at least as accurate as + the associated input event timestamp. + + The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples, + each component being an unsigned 32-bit value. Whole seconds are in + tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo, + and the additional fractional part in tv_nsec as nanoseconds. Hence, + for valid timestamps tv_nsec must be in [0, 999999999]. + </description> + <arg name="tv_sec_hi" type="uint" + summary="high 32 bits of the seconds part of the timestamp"/> + <arg name="tv_sec_lo" type="uint" + summary="low 32 bits of the seconds part of the timestamp"/> + <arg name="tv_nsec" type="uint" + summary="nanoseconds part of the timestamp"/> + </event> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/keyboard-shortcuts-inhibit/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/keyboard-shortcuts-inhibit/README new file mode 100644 index 0000000..63ff335 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/keyboard-shortcuts-inhibit/README @@ -0,0 +1,4 @@ +Compositor shortcuts inhibit protocol + +Maintainers: +Olivier Fourdan <ofourdan@redhat.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml new file mode 100644 index 0000000..2774876 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml @@ -0,0 +1,143 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="keyboard_shortcuts_inhibit_unstable_v1"> + + <copyright> + Copyright © 2017 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="Protocol for inhibiting the compositor keyboard shortcuts"> + This protocol specifies a way for a client to request the compositor + to ignore its own keyboard shortcuts for a given seat, so that all + key events from that seat get forwarded to a surface. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible + changes may be added together with the corresponding interface + version bump. + Backward incompatible changes are done by bumping the version + number in the protocol and interface names and resetting the + interface version. Once the protocol is to be declared stable, + the 'z' prefix and the version number in the protocol and + interface names are removed and the interface version number is + reset. + </description> + + <interface name="zwp_keyboard_shortcuts_inhibit_manager_v1" version="1"> + <description summary="context object for keyboard grab_manager"> + A global interface used for inhibiting the compositor keyboard shortcuts. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the keyboard shortcuts inhibitor object"> + Destroy the keyboard shortcuts inhibitor manager. + </description> + </request> + + <request name="inhibit_shortcuts"> + <description summary="create a new keyboard shortcuts inhibitor object"> + Create a new keyboard shortcuts inhibitor object associated with + the given surface for the given seat. + + If shortcuts are already inhibited for the specified seat and surface, + a protocol error "already_inhibited" is raised by the compositor. + </description> + <arg name="id" type="new_id" interface="zwp_keyboard_shortcuts_inhibitor_v1"/> + <arg name="surface" type="object" interface="wl_surface" + summary="the surface that inhibits the keyboard shortcuts behavior"/> + <arg name="seat" type="object" interface="wl_seat" + summary="the wl_seat for which keyboard shortcuts should be disabled"/> + </request> + + <enum name="error"> + <entry name="already_inhibited" + value="0" + summary="the shortcuts are already inhibited for this surface"/> + </enum> + </interface> + + <interface name="zwp_keyboard_shortcuts_inhibitor_v1" version="1"> + <description summary="context object for keyboard shortcuts inhibitor"> + A keyboard shortcuts inhibitor instructs the compositor to ignore + its own keyboard shortcuts when the associated surface has keyboard + focus. As a result, when the surface has keyboard focus on the given + seat, it will receive all key events originating from the specified + seat, even those which would normally be caught by the compositor for + its own shortcuts. + + The Wayland compositor is however under no obligation to disable + all of its shortcuts, and may keep some special key combo for its own + use, including but not limited to one allowing the user to forcibly + restore normal keyboard events routing in the case of an unwilling + client. The compositor may also use the same key combo to reactivate + an existing shortcut inhibitor that was previously deactivated on + user request. + + When the compositor restores its own keyboard shortcuts, an + "inactive" event is emitted to notify the client that the keyboard + shortcuts inhibitor is not effectively active for the surface and + seat any more, and the client should not expect to receive all + keyboard events. + + When the keyboard shortcuts inhibitor is inactive, the client has + no way to forcibly reactivate the keyboard shortcuts inhibitor. + + The user can chose to re-enable a previously deactivated keyboard + shortcuts inhibitor using any mechanism the compositor may offer, + in which case the compositor will send an "active" event to notify + the client. + + If the surface is destroyed, unmapped, or loses the seat's keyboard + focus, the keyboard shortcuts inhibitor becomes irrelevant and the + compositor will restore its own keyboard shortcuts but no "inactive" + event is emitted in this case. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the keyboard shortcuts inhibitor object"> + Remove the keyboard shortcuts inhibitor from the associated wl_surface. + </description> + </request> + + <event name="active"> + <description summary="shortcuts are inhibited"> + This event indicates that the shortcut inhibitor is active. + + The compositor sends this event every time compositor shortcuts + are inhibited on behalf of the surface. When active, the client + may receive input events normally reserved by the compositor + (see zwp_keyboard_shortcuts_inhibitor_v1). + + This occurs typically when the initial request "inhibit_shortcuts" + first becomes active or when the user instructs the compositor to + re-enable and existing shortcuts inhibitor using any mechanism + offered by the compositor. + </description> + </event> + + <event name="inactive"> + <description summary="shortcuts are restored"> + This event indicates that the shortcuts inhibitor is inactive, + normal shortcuts processing is restored by the compositor. + </description> + </event> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-dmabuf/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-dmabuf/README new file mode 100644 index 0000000..cdedf98 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-dmabuf/README @@ -0,0 +1,5 @@ +Linux DMA-BUF protocol + +Maintainers: +Pekka Paalanen <pekka.paalanen@collabora.co.uk> +Daniel Stone <daniels@collabora.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml new file mode 100644 index 0000000..154afe2 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml @@ -0,0 +1,348 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="linux_dmabuf_unstable_v1"> + + <copyright> + Copyright © 2014, 2015 Collabora, Ltd. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="zwp_linux_dmabuf_v1" version="3"> + <description summary="factory for creating dmabuf-based wl_buffers"> + Following the interfaces from: + https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt + and the Linux DRM sub-system's AddFb2 ioctl. + + This interface offers ways to create generic dmabuf-based + wl_buffers. Immediately after a client binds to this interface, + the set of supported formats and format modifiers is sent with + 'format' and 'modifier' events. + + The following are required from clients: + + - Clients must ensure that either all data in the dma-buf is + coherent for all subsequent read access or that coherency is + correctly handled by the underlying kernel-side dma-buf + implementation. + + - Don't make any more attachments after sending the buffer to the + compositor. Making more attachments later increases the risk of + the compositor not being able to use (re-import) an existing + dmabuf-based wl_buffer. + + The underlying graphics stack must ensure the following: + + - The dmabuf file descriptors relayed to the server will stay valid + for the whole lifetime of the wl_buffer. This means the server may + at any time use those fds to import the dmabuf into any kernel + sub-system that might accept it. + + To create a wl_buffer from one or more dmabufs, a client creates a + zwp_linux_dmabuf_params_v1 object with a zwp_linux_dmabuf_v1.create_params + request. All planes required by the intended format are added with + the 'add' request. Finally, a 'create' or 'create_immed' request is + issued, which has the following outcome depending on the import success. + + The 'create' request, + - on success, triggers a 'created' event which provides the final + wl_buffer to the client. + - on failure, triggers a 'failed' event to convey that the server + cannot use the dmabufs received from the client. + + For the 'create_immed' request, + - on success, the server immediately imports the added dmabufs to + create a wl_buffer. No event is sent from the server in this case. + - on failure, the server can choose to either: + - terminate the client by raising a fatal error. + - mark the wl_buffer as failed, and send a 'failed' event to the + client. If the client uses a failed wl_buffer as an argument to any + request, the behaviour is compositor implementation-defined. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <request name="destroy" type="destructor"> + <description summary="unbind the factory"> + Objects created through this interface, especially wl_buffers, will + remain valid. + </description> + </request> + + <request name="create_params"> + <description summary="create a temporary object for buffer parameters"> + This temporary object is used to collect multiple dmabuf handles into + a single batch to create a wl_buffer. It can only be used once and + should be destroyed after a 'created' or 'failed' event has been + received. + </description> + <arg name="params_id" type="new_id" interface="zwp_linux_buffer_params_v1" + summary="the new temporary"/> + </request> + + <event name="format"> + <description summary="supported buffer format"> + This event advertises one buffer format that the server supports. + All the supported formats are advertised once when the client + binds to this interface. A roundtrip after binding guarantees + that the client has received all supported formats. + + For the definition of the format codes, see the + zwp_linux_buffer_params_v1::create request. + + Warning: the 'format' event is likely to be deprecated and replaced + with the 'modifier' event introduced in zwp_linux_dmabuf_v1 + version 3, described below. Please refrain from using the information + received from this event. + </description> + <arg name="format" type="uint" summary="DRM_FORMAT code"/> + </event> + + <event name="modifier" since="3"> + <description summary="supported buffer format modifier"> + This event advertises the formats that the server supports, along with + the modifiers supported for each format. All the supported modifiers + for all the supported formats are advertised once when the client + binds to this interface. A roundtrip after binding guarantees that + the client has received all supported format-modifier pairs. + + For the definition of the format and modifier codes, see the + zwp_linux_buffer_params_v1::create request. + </description> + <arg name="format" type="uint" summary="DRM_FORMAT code"/> + <arg name="modifier_hi" type="uint" + summary="high 32 bits of layout modifier"/> + <arg name="modifier_lo" type="uint" + summary="low 32 bits of layout modifier"/> + </event> + </interface> + + <interface name="zwp_linux_buffer_params_v1" version="3"> + <description summary="parameters for creating a dmabuf-based wl_buffer"> + This temporary object is a collection of dmabufs and other + parameters that together form a single logical buffer. The temporary + object may eventually create one wl_buffer unless cancelled by + destroying it before requesting 'create'. + + Single-planar formats only require one dmabuf, however + multi-planar formats may require more than one dmabuf. For all + formats, an 'add' request must be called once per plane (even if the + underlying dmabuf fd is identical). + + You must use consecutive plane indices ('plane_idx' argument for 'add') + from zero to the number of planes used by the drm_fourcc format code. + All planes required by the format must be given exactly once, but can + be given in any order. Each plane index can be set only once. + </description> + + <enum name="error"> + <entry name="already_used" value="0" + summary="the dmabuf_batch object has already been used to create a wl_buffer"/> + <entry name="plane_idx" value="1" + summary="plane index out of bounds"/> + <entry name="plane_set" value="2" + summary="the plane index was already set"/> + <entry name="incomplete" value="3" + summary="missing or too many planes to create a buffer"/> + <entry name="invalid_format" value="4" + summary="format not supported"/> + <entry name="invalid_dimensions" value="5" + summary="invalid width or height"/> + <entry name="out_of_bounds" value="6" + summary="offset + stride * height goes out of dmabuf bounds"/> + <entry name="invalid_wl_buffer" value="7" + summary="invalid wl_buffer resulted from importing dmabufs via + the create_immed request on given buffer_params"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="delete this object, used or not"> + Cleans up the temporary data sent to the server for dmabuf-based + wl_buffer creation. + </description> + </request> + + <request name="add"> + <description summary="add a dmabuf to the temporary set"> + This request adds one dmabuf to the set in this + zwp_linux_buffer_params_v1. + + The 64-bit unsigned value combined from modifier_hi and modifier_lo + is the dmabuf layout modifier. DRM AddFB2 ioctl calls this the + fb modifier, which is defined in drm_mode.h of Linux UAPI. + This is an opaque token. Drivers use this token to express tiling, + compression, etc. driver-specific modifications to the base format + defined by the DRM fourcc code. + + This request raises the PLANE_IDX error if plane_idx is too large. + The error PLANE_SET is raised if attempting to set a plane that + was already set. + </description> + <arg name="fd" type="fd" summary="dmabuf fd"/> + <arg name="plane_idx" type="uint" summary="plane index"/> + <arg name="offset" type="uint" summary="offset in bytes"/> + <arg name="stride" type="uint" summary="stride in bytes"/> + <arg name="modifier_hi" type="uint" + summary="high 32 bits of layout modifier"/> + <arg name="modifier_lo" type="uint" + summary="low 32 bits of layout modifier"/> + </request> + + <enum name="flags"> + <entry name="y_invert" value="1" summary="contents are y-inverted"/> + <entry name="interlaced" value="2" summary="content is interlaced"/> + <entry name="bottom_first" value="4" summary="bottom field first"/> + </enum> + + <request name="create"> + <description summary="create a wl_buffer from the given dmabufs"> + This asks for creation of a wl_buffer from the added dmabuf + buffers. The wl_buffer is not created immediately but returned via + the 'created' event if the dmabuf sharing succeeds. The sharing + may fail at runtime for reasons a client cannot predict, in + which case the 'failed' event is triggered. + + The 'format' argument is a DRM_FORMAT code, as defined by the + libdrm's drm_fourcc.h. The Linux kernel's DRM sub-system is the + authoritative source on how the format codes should work. + + The 'flags' is a bitfield of the flags defined in enum "flags". + 'y_invert' means the that the image needs to be y-flipped. + + Flag 'interlaced' means that the frame in the buffer is not + progressive as usual, but interlaced. An interlaced buffer as + supported here must always contain both top and bottom fields. + The top field always begins on the first pixel row. The temporal + ordering between the two fields is top field first, unless + 'bottom_first' is specified. It is undefined whether 'bottom_first' + is ignored if 'interlaced' is not set. + + This protocol does not convey any information about field rate, + duration, or timing, other than the relative ordering between the + two fields in one buffer. A compositor may have to estimate the + intended field rate from the incoming buffer rate. It is undefined + whether the time of receiving wl_surface.commit with a new buffer + attached, applying the wl_surface state, wl_surface.frame callback + trigger, presentation, or any other point in the compositor cycle + is used to measure the frame or field times. There is no support + for detecting missed or late frames/fields/buffers either, and + there is no support whatsoever for cooperating with interlaced + compositor output. + + The composited image quality resulting from the use of interlaced + buffers is explicitly undefined. A compositor may use elaborate + hardware features or software to deinterlace and create progressive + output frames from a sequence of interlaced input buffers, or it + may produce substandard image quality. However, compositors that + cannot guarantee reasonable image quality in all cases are recommended + to just reject all interlaced buffers. + + Any argument errors, including non-positive width or height, + mismatch between the number of planes and the format, bad + format, bad offset or stride, may be indicated by fatal protocol + errors: INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS, + OUT_OF_BOUNDS. + + Dmabuf import errors in the server that are not obvious client + bugs are returned via the 'failed' event as non-fatal. This + allows attempting dmabuf sharing and falling back in the client + if it fails. + + This request can be sent only once in the object's lifetime, after + which the only legal request is destroy. This object should be + destroyed after issuing a 'create' request. Attempting to use this + object after issuing 'create' raises ALREADY_USED protocol error. + + It is not mandatory to issue 'create'. If a client wants to + cancel the buffer creation, it can just destroy this object. + </description> + <arg name="width" type="int" summary="base plane width in pixels"/> + <arg name="height" type="int" summary="base plane height in pixels"/> + <arg name="format" type="uint" summary="DRM_FORMAT code"/> + <arg name="flags" type="uint" summary="see enum flags"/> + </request> + + <event name="created"> + <description summary="buffer creation succeeded"> + This event indicates that the attempted buffer creation was + successful. It provides the new wl_buffer referencing the dmabuf(s). + + Upon receiving this event, the client should destroy the + zlinux_dmabuf_params object. + </description> + <arg name="buffer" type="new_id" interface="wl_buffer" + summary="the newly created wl_buffer"/> + </event> + + <event name="failed"> + <description summary="buffer creation failed"> + This event indicates that the attempted buffer creation has + failed. It usually means that one of the dmabuf constraints + has not been fulfilled. + + Upon receiving this event, the client should destroy the + zlinux_buffer_params object. + </description> + </event> + + <request name="create_immed" since="2"> + <description summary="immediately create a wl_buffer from the given + dmabufs"> + This asks for immediate creation of a wl_buffer by importing the + added dmabufs. + + In case of import success, no event is sent from the server, and the + wl_buffer is ready to be used by the client. + + Upon import failure, either of the following may happen, as seen fit + by the implementation: + - the client is terminated with one of the following fatal protocol + errors: + - INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS, OUT_OF_BOUNDS, + in case of argument errors such as mismatch between the number + of planes and the format, bad format, non-positive width or + height, or bad offset or stride. + - INVALID_WL_BUFFER, in case the cause for failure is unknown or + plaform specific. + - the server creates an invalid wl_buffer, marks it as failed and + sends a 'failed' event to the client. The result of using this + invalid wl_buffer as an argument in any request by the client is + defined by the compositor implementation. + + This takes the same arguments as a 'create' request, and obeys the + same restrictions. + </description> + <arg name="buffer_id" type="new_id" interface="wl_buffer" + summary="id for the newly created wl_buffer"/> + <arg name="width" type="int" summary="base plane width in pixels"/> + <arg name="height" type="int" summary="base plane height in pixels"/> + <arg name="format" type="uint" summary="DRM_FORMAT code"/> + <arg name="flags" type="uint" summary="see enum flags"/> + </request> + + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-explicit-synchronization/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-explicit-synchronization/README new file mode 100644 index 0000000..59bcb6f --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-explicit-synchronization/README @@ -0,0 +1,5 @@ +Linux explicit synchronization (dma-fence) protocol + +Maintainers: +Daniel Stone <daniels@collabora.com> +Alexandros Frantzis <alexandros.frantzis@collabora.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-explicit-synchronization/linux-explicit-synchronization-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-explicit-synchronization/linux-explicit-synchronization-unstable-v1.xml new file mode 100644 index 0000000..d0a8cf0 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/linux-explicit-synchronization/linux-explicit-synchronization-unstable-v1.xml @@ -0,0 +1,256 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="zwp_linux_explicit_synchronization_unstable_v1"> + + <copyright> + Copyright 2016 The Chromium Authors. + Copyright 2017 Intel Corporation + Copyright 2018 Collabora, Ltd + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="zwp_linux_explicit_synchronization_v1" version="2"> + <description summary="protocol for providing explicit synchronization"> + This global is a factory interface, allowing clients to request + explicit synchronization for buffers on a per-surface basis. + + See zwp_linux_surface_synchronization_v1 for more information. + + This interface is derived from Chromium's + zcr_linux_explicit_synchronization_v1. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy explicit synchronization factory object"> + Destroy this explicit synchronization factory object. Other objects, + including zwp_linux_surface_synchronization_v1 objects created by this + factory, shall not be affected by this request. + </description> + </request> + + <enum name="error"> + <entry name="synchronization_exists" value="0" + summary="the surface already has a synchronization object associated"/> + </enum> + + <request name="get_synchronization"> + <description summary="extend surface interface for explicit synchronization"> + Instantiate an interface extension for the given wl_surface to provide + explicit synchronization. + + If the given wl_surface already has an explicit synchronization object + associated, the synchronization_exists protocol error is raised. + + Graphics APIs, like EGL or Vulkan, that manage the buffer queue and + commits of a wl_surface themselves, are likely to be using this + extension internally. If a client is using such an API for a + wl_surface, it should not directly use this extension on that surface, + to avoid raising a synchronization_exists protocol error. + </description> + + <arg name="id" type="new_id" + interface="zwp_linux_surface_synchronization_v1" + summary="the new synchronization interface id"/> + <arg name="surface" type="object" interface="wl_surface" + summary="the surface"/> + </request> + </interface> + + <interface name="zwp_linux_surface_synchronization_v1" version="2"> + <description summary="per-surface explicit synchronization support"> + This object implements per-surface explicit synchronization. + + Synchronization refers to co-ordination of pipelined operations performed + on buffers. Most GPU clients will schedule an asynchronous operation to + render to the buffer, then immediately send the buffer to the compositor + to be attached to a surface. + + In implicit synchronization, ensuring that the rendering operation is + complete before the compositor displays the buffer is an implementation + detail handled by either the kernel or userspace graphics driver. + + By contrast, in explicit synchronization, dma_fence objects mark when the + asynchronous operations are complete. When submitting a buffer, the + client provides an acquire fence which will be waited on before the + compositor accesses the buffer. The Wayland server, through a + zwp_linux_buffer_release_v1 object, will inform the client with an event + which may be accompanied by a release fence, when the compositor will no + longer access the buffer contents due to the specific commit that + requested the release event. + + Each surface can be associated with only one object of this interface at + any time. + + In version 1 of this interface, explicit synchronization is only + guaranteed to be supported for buffers created with any version of the + wp_linux_dmabuf buffer factory. Version 2 additionally guarantees + explicit synchronization support for opaque EGL buffers, which is a type + of platform specific buffers described in the EGL_WL_bind_wayland_display + extension. Compositors are free to support explicit synchronization for + additional buffer types. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy synchronization object"> + Destroy this explicit synchronization object. + + Any fence set by this object with set_acquire_fence since the last + commit will be discarded by the server. Any fences set by this object + before the last commit are not affected. + + zwp_linux_buffer_release_v1 objects created by this object are not + affected by this request. + </description> + </request> + + <enum name="error"> + <entry name="invalid_fence" value="0" + summary="the fence specified by the client could not be imported"/> + <entry name="duplicate_fence" value="1" + summary="multiple fences added for a single surface commit"/> + <entry name="duplicate_release" value="2" + summary="multiple releases added for a single surface commit"/> + <entry name="no_surface" value="3" + summary="the associated wl_surface was destroyed"/> + <entry name="unsupported_buffer" value="4" + summary="the buffer does not support explicit synchronization"/> + <entry name="no_buffer" value="5" + summary="no buffer was attached"/> + </enum> + + <request name="set_acquire_fence"> + <description summary="set the acquire fence"> + Set the acquire fence that must be signaled before the compositor + may sample from the buffer attached with wl_surface.attach. The fence + is a dma_fence kernel object. + + The acquire fence is double-buffered state, and will be applied on the + next wl_surface.commit request for the associated surface. Thus, it + applies only to the buffer that is attached to the surface at commit + time. + + If the provided fd is not a valid dma_fence fd, then an INVALID_FENCE + error is raised. + + If a fence has already been attached during the same commit cycle, a + DUPLICATE_FENCE error is raised. + + If the associated wl_surface was destroyed, a NO_SURFACE error is + raised. + + If at surface commit time the attached buffer does not support explicit + synchronization, an UNSUPPORTED_BUFFER error is raised. + + If at surface commit time there is no buffer attached, a NO_BUFFER + error is raised. + </description> + <arg name="fd" type="fd" summary="acquire fence fd"/> + </request> + + <request name="get_release"> + <description summary="release fence for last-attached buffer"> + Create a listener for the release of the buffer attached by the + client with wl_surface.attach. See zwp_linux_buffer_release_v1 + documentation for more information. + + The release object is double-buffered state, and will be associated + with the buffer that is attached to the surface at wl_surface.commit + time. + + If a zwp_linux_buffer_release_v1 object has already been requested for + the surface in the same commit cycle, a DUPLICATE_RELEASE error is + raised. + + If the associated wl_surface was destroyed, a NO_SURFACE error + is raised. + + If at surface commit time there is no buffer attached, a NO_BUFFER + error is raised. + </description> + <arg name="release" type="new_id" interface="zwp_linux_buffer_release_v1" + summary="new zwp_linux_buffer_release_v1 object"/> + </request> + </interface> + + <interface name="zwp_linux_buffer_release_v1" version="1"> + <description summary="buffer release explicit synchronization"> + This object is instantiated in response to a + zwp_linux_surface_synchronization_v1.get_release request. + + It provides an alternative to wl_buffer.release events, providing a + unique release from a single wl_surface.commit request. The release event + also supports explicit synchronization, providing a fence FD for the + client to synchronize against. + + Exactly one event, either a fenced_release or an immediate_release, will + be emitted for the wl_surface.commit request. The compositor can choose + release by release which event it uses. + + This event does not replace wl_buffer.release events; servers are still + required to send those events. + + Once a buffer release object has delivered a 'fenced_release' or an + 'immediate_release' event it is automatically destroyed. + </description> + + <event name="fenced_release"> + <description summary="release buffer with fence"> + Sent when the compositor has finalised its usage of the associated + buffer for the relevant commit, providing a dma_fence which will be + signaled when all operations by the compositor on that buffer for that + commit have finished. + + Once the fence has signaled, and assuming the associated buffer is not + pending release from other wl_surface.commit requests, no additional + explicit or implicit synchronization is required to safely reuse or + destroy the buffer. + + This event destroys the zwp_linux_buffer_release_v1 object. + </description> + <arg name="fence" type="fd" summary="fence for last operation on buffer"/> + </event> + + <event name="immediate_release"> + <description summary="release buffer immediately"> + Sent when the compositor has finalised its usage of the associated + buffer for the relevant commit, and either performed no operations + using it, or has a guarantee that all its operations on that buffer for + that commit have finished. + + Once this event is received, and assuming the associated buffer is not + pending release from other wl_surface.commit requests, no additional + explicit or implicit synchronization is required to safely reuse or + destroy the buffer. + + This event destroys the zwp_linux_buffer_release_v1 object. + </description> + </event> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-constraints/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-constraints/README new file mode 100644 index 0000000..8a242f8 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-constraints/README @@ -0,0 +1,4 @@ +Pointer constraints protocol + +Maintainers: +Jonas Ådahl <jadahl@gmail.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml new file mode 100644 index 0000000..4e67a13 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml @@ -0,0 +1,339 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="pointer_constraints_unstable_v1"> + + <copyright> + Copyright © 2014 Jonas Ådahl + Copyright © 2015 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="protocol for constraining pointer motions"> + This protocol specifies a set of interfaces used for adding constraints to + the motion of a pointer. Possible constraints include confining pointer + motions to a given region, or locking it to its current position. + + In order to constrain the pointer, a client must first bind the global + interface "wp_pointer_constraints" which, if a compositor supports pointer + constraints, is exposed by the registry. Using the bound global object, the + client uses the request that corresponds to the type of constraint it wants + to make. See wp_pointer_constraints for more details. + + Warning! The protocol described in this file is experimental and backward + incompatible changes may be made. Backward compatible changes may be added + together with the corresponding interface version bump. Backward + incompatible changes are done by bumping the version number in the protocol + and interface names and resetting the interface version. Once the protocol + is to be declared stable, the 'z' prefix and the version number in the + protocol and interface names are removed and the interface version number is + reset. + </description> + + <interface name="zwp_pointer_constraints_v1" version="1"> + <description summary="constrain the movement of a pointer"> + The global interface exposing pointer constraining functionality. It + exposes two requests: lock_pointer for locking the pointer to its + position, and confine_pointer for locking the pointer to a region. + + The lock_pointer and confine_pointer requests create the objects + wp_locked_pointer and wp_confined_pointer respectively, and the client can + use these objects to interact with the lock. + + For any surface, only one lock or confinement may be active across all + wl_pointer objects of the same seat. If a lock or confinement is requested + when another lock or confinement is active or requested on the same surface + and with any of the wl_pointer objects of the same seat, an + 'already_constrained' error will be raised. + </description> + + <enum name="error"> + <description summary="wp_pointer_constraints error values"> + These errors can be emitted in response to wp_pointer_constraints + requests. + </description> + <entry name="already_constrained" value="1" + summary="pointer constraint already requested on that surface"/> + </enum> + + <enum name="lifetime"> + <description summary="constraint lifetime"> + These values represent different lifetime semantics. They are passed + as arguments to the factory requests to specify how the constraint + lifetimes should be managed. + </description> + <entry name="oneshot" value="1"> + <description summary="the pointer constraint is defunct once deactivated"> + A oneshot pointer constraint will never reactivate once it has been + deactivated. See the corresponding deactivation event + (wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for + details. + </description> + </entry> + <entry name="persistent" value="2"> + <description summary="the pointer constraint may reactivate"> + A persistent pointer constraint may again reactivate once it has + been deactivated. See the corresponding deactivation event + (wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for + details. + </description> + </entry> + </enum> + + <request name="destroy" type="destructor"> + <description summary="destroy the pointer constraints manager object"> + Used by the client to notify the server that it will no longer use this + pointer constraints object. + </description> + </request> + + <request name="lock_pointer"> + <description summary="lock pointer to a position"> + The lock_pointer request lets the client request to disable movements of + the virtual pointer (i.e. the cursor), effectively locking the pointer + to a position. This request may not take effect immediately; in the + future, when the compositor deems implementation-specific constraints + are satisfied, the pointer lock will be activated and the compositor + sends a locked event. + + The protocol provides no guarantee that the constraints are ever + satisfied, and does not require the compositor to send an error if the + constraints cannot ever be satisfied. It is thus possible to request a + lock that will never activate. + + There may not be another pointer constraint of any kind requested or + active on the surface for any of the wl_pointer objects of the seat of + the passed pointer when requesting a lock. If there is, an error will be + raised. See general pointer lock documentation for more details. + + The intersection of the region passed with this request and the input + region of the surface is used to determine where the pointer must be + in order for the lock to activate. It is up to the compositor whether to + warp the pointer or require some kind of user interaction for the lock + to activate. If the region is null the surface input region is used. + + A surface may receive pointer focus without the lock being activated. + + The request creates a new object wp_locked_pointer which is used to + interact with the lock as well as receive updates about its state. See + the the description of wp_locked_pointer for further information. + + Note that while a pointer is locked, the wl_pointer objects of the + corresponding seat will not emit any wl_pointer.motion events, but + relative motion events will still be emitted via wp_relative_pointer + objects of the same seat. wl_pointer.axis and wl_pointer.button events + are unaffected. + </description> + <arg name="id" type="new_id" interface="zwp_locked_pointer_v1"/> + <arg name="surface" type="object" interface="wl_surface" + summary="surface to lock pointer to"/> + <arg name="pointer" type="object" interface="wl_pointer" + summary="the pointer that should be locked"/> + <arg name="region" type="object" interface="wl_region" allow-null="true" + summary="region of surface"/> + <arg name="lifetime" type="uint" summary="lock lifetime"/> + </request> + + <request name="confine_pointer"> + <description summary="confine pointer to a region"> + The confine_pointer request lets the client request to confine the + pointer cursor to a given region. This request may not take effect + immediately; in the future, when the compositor deems implementation- + specific constraints are satisfied, the pointer confinement will be + activated and the compositor sends a confined event. + + The intersection of the region passed with this request and the input + region of the surface is used to determine where the pointer must be + in order for the confinement to activate. It is up to the compositor + whether to warp the pointer or require some kind of user interaction for + the confinement to activate. If the region is null the surface input + region is used. + + The request will create a new object wp_confined_pointer which is used + to interact with the confinement as well as receive updates about its + state. See the the description of wp_confined_pointer for further + information. + </description> + <arg name="id" type="new_id" interface="zwp_confined_pointer_v1"/> + <arg name="surface" type="object" interface="wl_surface" + summary="surface to lock pointer to"/> + <arg name="pointer" type="object" interface="wl_pointer" + summary="the pointer that should be confined"/> + <arg name="region" type="object" interface="wl_region" allow-null="true" + summary="region of surface"/> + <arg name="lifetime" type="uint" summary="confinement lifetime"/> + </request> + </interface> + + <interface name="zwp_locked_pointer_v1" version="1"> + <description summary="receive relative pointer motion events"> + The wp_locked_pointer interface represents a locked pointer state. + + While the lock of this object is active, the wl_pointer objects of the + associated seat will not emit any wl_pointer.motion events. + + This object will send the event 'locked' when the lock is activated. + Whenever the lock is activated, it is guaranteed that the locked surface + will already have received pointer focus and that the pointer will be + within the region passed to the request creating this object. + + To unlock the pointer, send the destroy request. This will also destroy + the wp_locked_pointer object. + + If the compositor decides to unlock the pointer the unlocked event is + sent. See wp_locked_pointer.unlock for details. + + When unlocking, the compositor may warp the cursor position to the set + cursor position hint. If it does, it will not result in any relative + motion events emitted via wp_relative_pointer. + + If the surface the lock was requested on is destroyed and the lock is not + yet activated, the wp_locked_pointer object is now defunct and must be + destroyed. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the locked pointer object"> + Destroy the locked pointer object. If applicable, the compositor will + unlock the pointer. + </description> + </request> + + <request name="set_cursor_position_hint"> + <description summary="set the pointer cursor position hint"> + Set the cursor position hint relative to the top left corner of the + surface. + + If the client is drawing its own cursor, it should update the position + hint to the position of its own cursor. A compositor may use this + information to warp the pointer upon unlock in order to avoid pointer + jumps. + + The cursor position hint is double buffered. The new hint will only take + effect when the associated surface gets it pending state applied. See + wl_surface.commit for details. + </description> + <arg name="surface_x" type="fixed" + summary="surface-local x coordinate"/> + <arg name="surface_y" type="fixed" + summary="surface-local y coordinate"/> + </request> + + <request name="set_region"> + <description summary="set a new lock region"> + Set a new region used to lock the pointer. + + The new lock region is double-buffered. The new lock region will + only take effect when the associated surface gets its pending state + applied. See wl_surface.commit for details. + + For details about the lock region, see wp_locked_pointer. + </description> + <arg name="region" type="object" interface="wl_region" allow-null="true" + summary="region of surface"/> + </request> + + <event name="locked"> + <description summary="lock activation event"> + Notification that the pointer lock of the seat's pointer is activated. + </description> + </event> + + <event name="unlocked"> + <description summary="lock deactivation event"> + Notification that the pointer lock of the seat's pointer is no longer + active. If this is a oneshot pointer lock (see + wp_pointer_constraints.lifetime) this object is now defunct and should + be destroyed. If this is a persistent pointer lock (see + wp_pointer_constraints.lifetime) this pointer lock may again + reactivate in the future. + </description> + </event> + </interface> + + <interface name="zwp_confined_pointer_v1" version="1"> + <description summary="confined pointer object"> + The wp_confined_pointer interface represents a confined pointer state. + + This object will send the event 'confined' when the confinement is + activated. Whenever the confinement is activated, it is guaranteed that + the surface the pointer is confined to will already have received pointer + focus and that the pointer will be within the region passed to the request + creating this object. It is up to the compositor to decide whether this + requires some user interaction and if the pointer will warp to within the + passed region if outside. + + To unconfine the pointer, send the destroy request. This will also destroy + the wp_confined_pointer object. + + If the compositor decides to unconfine the pointer the unconfined event is + sent. The wp_confined_pointer object is at this point defunct and should + be destroyed. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the confined pointer object"> + Destroy the confined pointer object. If applicable, the compositor will + unconfine the pointer. + </description> + </request> + + <request name="set_region"> + <description summary="set a new confine region"> + Set a new region used to confine the pointer. + + The new confine region is double-buffered. The new confine region will + only take effect when the associated surface gets its pending state + applied. See wl_surface.commit for details. + + If the confinement is active when the new confinement region is applied + and the pointer ends up outside of newly applied region, the pointer may + warped to a position within the new confinement region. If warped, a + wl_pointer.motion event will be emitted, but no + wp_relative_pointer.relative_motion event. + + The compositor may also, instead of using the new region, unconfine the + pointer. + + For details about the confine region, see wp_confined_pointer. + </description> + <arg name="region" type="object" interface="wl_region" allow-null="true" + summary="region of surface"/> + </request> + + <event name="confined"> + <description summary="pointer confined"> + Notification that the pointer confinement of the seat's pointer is + activated. + </description> + </event> + + <event name="unconfined"> + <description summary="pointer unconfined"> + Notification that the pointer confinement of the seat's pointer is no + longer active. If this is a oneshot pointer confinement (see + wp_pointer_constraints.lifetime) this object is now defunct and should + be destroyed. If this is a persistent pointer confinement (see + wp_pointer_constraints.lifetime) this pointer confinement may again + reactivate in the future. + </description> + </event> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-gestures/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-gestures/README new file mode 100644 index 0000000..a419632 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-gestures/README @@ -0,0 +1,4 @@ +Pointer gestures protocol + +Maintainers: +Carlos Garnacho <carlosg@gnome.org> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml new file mode 100644 index 0000000..5b7132c --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml @@ -0,0 +1,177 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="pointer_gestures_unstable_v1"> + + <interface name="zwp_pointer_gestures_v1" version="1"> + <description summary="touchpad gestures"> + A global interface to provide semantic touchpad gestures for a given + pointer. + + Two gestures are currently supported: swipe and zoom/rotate. + All gestures follow a three-stage cycle: begin, update, end and + are identified by a unique id. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <request name="get_swipe_gesture"> + <description summary="get swipe gesture"> + Create a swipe gesture object. See the + wl_pointer_gesture_swipe interface for details. + </description> + <arg name="id" type="new_id" interface="zwp_pointer_gesture_swipe_v1"/> + <arg name="pointer" type="object" interface="wl_pointer"/> + </request> + + <request name="get_pinch_gesture"> + <description summary="get pinch gesture"> + Create a pinch gesture object. See the + wl_pointer_gesture_pinch interface for details. + </description> + <arg name="id" type="new_id" interface="zwp_pointer_gesture_pinch_v1"/> + <arg name="pointer" type="object" interface="wl_pointer"/> + </request> + </interface> + + <interface name="zwp_pointer_gesture_swipe_v1" version="1"> + <description summary="a swipe gesture object"> + A swipe gesture object notifies a client about a multi-finger swipe + gesture detected on an indirect input device such as a touchpad. + The gesture is usually initiated by multiple fingers moving in the + same direction but once initiated the direction may change. + The precise conditions of when such a gesture is detected are + implementation-dependent. + + A gesture consists of three stages: begin, update (optional) and end. + There cannot be multiple simultaneous pinch or swipe gestures on a + same pointer/seat, how compositors prevent these situations is + implementation-dependent. + + A gesture may be cancelled by the compositor or the hardware. + Clients should not consider performing permanent or irreversible + actions until the end of a gesture has been received. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the pointer swipe gesture object"/> + </request> + + <event name="begin"> + <description summary="multi-finger swipe begin"> + This event is sent when a multi-finger swipe gesture is detected + on the device. + </description> + <arg name="serial" type="uint"/> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="fingers" type="uint" summary="number of fingers"/> + </event> + + <event name="update"> + <description summary="multi-finger swipe motion"> + This event is sent when a multi-finger swipe gesture changes the + position of the logical center. + + The dx and dy coordinates are relative coordinates of the logical + center of the gesture compared to the previous event. + </description> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="dx" type="fixed" summary="delta x coordinate in surface coordinate space"/> + <arg name="dy" type="fixed" summary="delta y coordinate in surface coordinate space"/> + </event> + + <event name="end"> + <description summary="multi-finger swipe end"> + This event is sent when a multi-finger swipe gesture ceases to + be valid. This may happen when one or more fingers are lifted or + the gesture is cancelled. + + When a gesture is cancelled, the client should undo state changes + caused by this gesture. What causes a gesture to be cancelled is + implementation-dependent. + </description> + <arg name="serial" type="uint"/> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="cancelled" type="int" summary="1 if the gesture was cancelled, 0 otherwise"/> + </event> + </interface> + + <interface name="zwp_pointer_gesture_pinch_v1" version="1"> + <description summary="a pinch gesture object"> + A pinch gesture object notifies a client about a multi-finger pinch + gesture detected on an indirect input device such as a touchpad. + The gesture is usually initiated by multiple fingers moving towards + each other or away from each other, or by two or more fingers rotating + around a logical center of gravity. The precise conditions of when + such a gesture is detected are implementation-dependent. + + A gesture consists of three stages: begin, update (optional) and end. + There cannot be multiple simultaneous pinch or swipe gestures on a + same pointer/seat, how compositors prevent these situations is + implementation-dependent. + + A gesture may be cancelled by the compositor or the hardware. + Clients should not consider performing permanent or irreversible + actions until the end of a gesture has been received. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the pinch gesture object"/> + </request> + + <event name="begin"> + <description summary="multi-finger pinch begin"> + This event is sent when a multi-finger pinch gesture is detected + on the device. + </description> + <arg name="serial" type="uint"/> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="fingers" type="uint" summary="number of fingers"/> + </event> + + <event name="update"> + <description summary="multi-finger pinch motion"> + This event is sent when a multi-finger pinch gesture changes the + position of the logical center, the rotation or the relative scale. + + The dx and dy coordinates are relative coordinates in the + surface coordinate space of the logical center of the gesture. + + The scale factor is an absolute scale compared to the + pointer_gesture_pinch.begin event, e.g. a scale of 2 means the fingers + are now twice as far apart as on pointer_gesture_pinch.begin. + + The rotation is the relative angle in degrees clockwise compared to the previous + pointer_gesture_pinch.begin or pointer_gesture_pinch.update event. + </description> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="dx" type="fixed" summary="delta x coordinate in surface coordinate space"/> + <arg name="dy" type="fixed" summary="delta y coordinate in surface coordinate space"/> + <arg name="scale" type="fixed" summary="scale relative to the initial finger position"/> + <arg name="rotation" type="fixed" summary="angle in degrees cw relative to the previous event"/> + </event> + + <event name="end"> + <description summary="multi-finger pinch end"> + This event is sent when a multi-finger pinch gesture ceases to + be valid. This may happen when one or more fingers are lifted or + the gesture is cancelled. + + When a gesture is cancelled, the client should undo state changes + caused by this gesture. What causes a gesture to be cancelled is + implementation-dependent. + </description> + <arg name="serial" type="uint"/> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + <arg name="cancelled" type="int" summary="1 if the gesture was cancelled, 0 otherwise"/> + </event> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/primary-selection/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/primary-selection/README new file mode 100644 index 0000000..ae0a402 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/primary-selection/README @@ -0,0 +1,4 @@ +Primary selection protocol + +Maintainers: +Simon Ser <contact@emersion.fr> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/primary-selection/primary-selection-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/primary-selection/primary-selection-unstable-v1.xml new file mode 100644 index 0000000..e5a39e3 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/primary-selection/primary-selection-unstable-v1.xml @@ -0,0 +1,225 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="wp_primary_selection_unstable_v1"> + <copyright> + Copyright © 2015, 2016 Red Hat + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="Primary selection protocol"> + This protocol provides the ability to have a primary selection device to + match that of the X server. This primary selection is a shortcut to the + common clipboard selection, where text just needs to be selected in order + to allow copying it elsewhere. The de facto way to perform this action + is the middle mouse button, although it is not limited to this one. + + Clients wishing to honor primary selection should create a primary + selection source and set it as the selection through + wp_primary_selection_device.set_selection whenever the text selection + changes. In order to minimize calls in pointer-driven text selection, + it should happen only once after the operation finished. Similarly, + a NULL source should be set when text is unselected. + + wp_primary_selection_offer objects are first announced through the + wp_primary_selection_device.data_offer event. Immediately after this event, + the primary data offer will emit wp_primary_selection_offer.offer events + to let know of the mime types being offered. + + When the primary selection changes, the client with the keyboard focus + will receive wp_primary_selection_device.selection events. Only the client + with the keyboard focus will receive such events with a non-NULL + wp_primary_selection_offer. Across keyboard focus changes, previously + focused clients will receive wp_primary_selection_device.events with a + NULL wp_primary_selection_offer. + + In order to request the primary selection data, the client must pass + a recent serial pertaining to the press event that is triggering the + operation, if the compositor deems the serial valid and recent, the + wp_primary_selection_source.send event will happen in the other end + to let the transfer begin. The client owning the primary selection + should write the requested data, and close the file descriptor + immediately. + + If the primary selection owner client disappeared during the transfer, + the client reading the data will receive a + wp_primary_selection_device.selection event with a NULL + wp_primary_selection_offer, the client should take this as a hint + to finish the reads related to the no longer existing offer. + + The primary selection owner should be checking for errors during + writes, merely cancelling the ongoing transfer if any happened. + </description> + + <interface name="zwp_primary_selection_device_manager_v1" version="1"> + <description summary="X primary selection emulation"> + The primary selection device manager is a singleton global object that + provides access to the primary selection. It allows to create + wp_primary_selection_source objects, as well as retrieving the per-seat + wp_primary_selection_device objects. + </description> + + <request name="create_source"> + <description summary="create a new primary selection source"> + Create a new primary selection source. + </description> + <arg name="id" type="new_id" interface="zwp_primary_selection_source_v1"/> + </request> + + <request name="get_device"> + <description summary="create a new primary selection device"> + Create a new data device for a given seat. + </description> + <arg name="id" type="new_id" interface="zwp_primary_selection_device_v1"/> + <arg name="seat" type="object" interface="wl_seat"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the primary selection device manager"> + Destroy the primary selection device manager. + </description> + </request> + </interface> + + <interface name="zwp_primary_selection_device_v1" version="1"> + <request name="set_selection"> + <description summary="set the primary selection"> + Replaces the current selection. The previous owner of the primary + selection will receive a wp_primary_selection_source.cancelled event. + + To unset the selection, set the source to NULL. + </description> + <arg name="source" type="object" interface="zwp_primary_selection_source_v1" allow-null="true"/> + <arg name="serial" type="uint" summary="serial of the event that triggered this request"/> + </request> + + <event name="data_offer"> + <description summary="introduce a new wp_primary_selection_offer"> + Introduces a new wp_primary_selection_offer object that may be used + to receive the current primary selection. Immediately following this + event, the new wp_primary_selection_offer object will send + wp_primary_selection_offer.offer events to describe the offered mime + types. + </description> + <arg name="offer" type="new_id" interface="zwp_primary_selection_offer_v1"/> + </event> + + <event name="selection"> + <description summary="advertise a new primary selection"> + The wp_primary_selection_device.selection event is sent to notify the + client of a new primary selection. This event is sent after the + wp_primary_selection.data_offer event introducing this object, and after + the offer has announced its mimetypes through + wp_primary_selection_offer.offer. + + The data_offer is valid until a new offer or NULL is received + or until the client loses keyboard focus. The client must destroy the + previous selection data_offer, if any, upon receiving this event. + </description> + <arg name="id" type="object" interface="zwp_primary_selection_offer_v1" allow-null="true"/> + </event> + + <request name="destroy" type="destructor"> + <description summary="destroy the primary selection device"> + Destroy the primary selection device. + </description> + </request> + </interface> + + <interface name="zwp_primary_selection_offer_v1" version="1"> + <description summary="offer to transfer primary selection contents"> + A wp_primary_selection_offer represents an offer to transfer the contents + of the primary selection clipboard to the client. Similar to + wl_data_offer, the offer also describes the mime types that the data can + be converted to and provides the mechanisms for transferring the data + directly to the client. + </description> + + <request name="receive"> + <description summary="request that the data is transferred"> + To transfer the contents of the primary selection clipboard, the client + issues this request and indicates the mime type that it wants to + receive. The transfer happens through the passed file descriptor + (typically created with the pipe system call). The source client writes + the data in the mime type representation requested and then closes the + file descriptor. + + The receiving client reads from the read end of the pipe until EOF and + closes its end, at which point the transfer is complete. + </description> + <arg name="mime_type" type="string"/> + <arg name="fd" type="fd"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the primary selection offer"> + Destroy the primary selection offer. + </description> + </request> + + <event name="offer"> + <description summary="advertise offered mime type"> + Sent immediately after creating announcing the + wp_primary_selection_offer through + wp_primary_selection_device.data_offer. One event is sent per offered + mime type. + </description> + <arg name="mime_type" type="string"/> + </event> + </interface> + + <interface name="zwp_primary_selection_source_v1" version="1"> + <description summary="offer to replace the contents of the primary selection"> + The source side of a wp_primary_selection_offer, it provides a way to + describe the offered data and respond to requests to transfer the + requested contents of the primary selection clipboard. + </description> + + <request name="offer"> + <description summary="add an offered mime type"> + This request adds a mime type to the set of mime types advertised to + targets. Can be called several times to offer multiple types. + </description> + <arg name="mime_type" type="string"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the primary selection source"> + Destroy the primary selection source. + </description> + </request> + + <event name="send"> + <description summary="send the primary selection contents"> + Request for the current primary selection contents from the client. + Send the specified mime type over the passed file descriptor, then + close it. + </description> + <arg name="mime_type" type="string"/> + <arg name="fd" type="fd"/> + </event> + + <event name="cancelled"> + <description summary="request for primary selection contents was canceled"> + This primary selection source is no longer valid. The client should + clean up and destroy this primary selection source. + </description> + </event> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/relative-pointer/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/relative-pointer/README new file mode 100644 index 0000000..64c42a1 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/relative-pointer/README @@ -0,0 +1,4 @@ +Relative pointer protocol + +Maintainers: +Jonas Ådahl <jadahl@gmail.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml new file mode 100644 index 0000000..ca6f81d --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="relative_pointer_unstable_v1"> + + <copyright> + Copyright © 2014 Jonas Ådahl + Copyright © 2015 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="protocol for relative pointer motion events"> + This protocol specifies a set of interfaces used for making clients able to + receive relative pointer events not obstructed by barriers (such as the + monitor edge or other pointer barriers). + + To start receiving relative pointer events, a client must first bind the + global interface "wp_relative_pointer_manager" which, if a compositor + supports relative pointer motion events, is exposed by the registry. After + having created the relative pointer manager proxy object, the client uses + it to create the actual relative pointer object using the + "get_relative_pointer" request given a wl_pointer. The relative pointer + motion events will then, when applicable, be transmitted via the proxy of + the newly created relative pointer object. See the documentation of the + relative pointer interface for more details. + + Warning! The protocol described in this file is experimental and backward + incompatible changes may be made. Backward compatible changes may be added + together with the corresponding interface version bump. Backward + incompatible changes are done by bumping the version number in the protocol + and interface names and resetting the interface version. Once the protocol + is to be declared stable, the 'z' prefix and the version number in the + protocol and interface names are removed and the interface version number is + reset. + </description> + + <interface name="zwp_relative_pointer_manager_v1" version="1"> + <description summary="get relative pointer objects"> + A global interface used for getting the relative pointer object for a + given pointer. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the relative pointer manager object"> + Used by the client to notify the server that it will no longer use this + relative pointer manager object. + </description> + </request> + + <request name="get_relative_pointer"> + <description summary="get a relative pointer object"> + Create a relative pointer interface given a wl_pointer object. See the + wp_relative_pointer interface for more details. + </description> + <arg name="id" type="new_id" interface="zwp_relative_pointer_v1"/> + <arg name="pointer" type="object" interface="wl_pointer"/> + </request> + </interface> + + <interface name="zwp_relative_pointer_v1" version="1"> + <description summary="relative pointer object"> + A wp_relative_pointer object is an extension to the wl_pointer interface + used for emitting relative pointer events. It shares the same focus as + wl_pointer objects of the same seat and will only emit events when it has + focus. + </description> + + <request name="destroy" type="destructor"> + <description summary="release the relative pointer object"/> + </request> + + <event name="relative_motion"> + <description summary="relative pointer motion"> + Relative x/y pointer motion from the pointer of the seat associated with + this object. + + A relative motion is in the same dimension as regular wl_pointer motion + events, except they do not represent an absolute position. For example, + moving a pointer from (x, y) to (x', y') would have the equivalent + relative motion (x' - x, y' - y). If a pointer motion caused the + absolute pointer position to be clipped by for example the edge of the + monitor, the relative motion is unaffected by the clipping and will + represent the unclipped motion. + + This event also contains non-accelerated motion deltas. The + non-accelerated delta is, when applicable, the regular pointer motion + delta as it was before having applied motion acceleration and other + transformations such as normalization. + + Note that the non-accelerated delta does not represent 'raw' events as + they were read from some device. Pointer motion acceleration is device- + and configuration-specific and non-accelerated deltas and accelerated + deltas may have the same value on some devices. + + Relative motions are not coupled to wl_pointer.motion events, and can be + sent in combination with such events, but also independently. There may + also be scenarios where wl_pointer.motion is sent, but there is no + relative motion. The order of an absolute and relative motion event + originating from the same physical motion is not guaranteed. + + If the client needs button events or focus state, it can receive them + from a wl_pointer object of the same seat that the wp_relative_pointer + object is associated with. + </description> + <arg name="utime_hi" type="uint" + summary="high 32 bits of a 64 bit timestamp with microsecond granularity"/> + <arg name="utime_lo" type="uint" + summary="low 32 bits of a 64 bit timestamp with microsecond granularity"/> + <arg name="dx" type="fixed" + summary="the x component of the motion vector"/> + <arg name="dy" type="fixed" + summary="the y component of the motion vector"/> + <arg name="dx_unaccel" type="fixed" + summary="the x component of the unaccelerated motion vector"/> + <arg name="dy_unaccel" type="fixed" + summary="the y component of the unaccelerated motion vector"/> + </event> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/tablet/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/tablet/README new file mode 100644 index 0000000..7ba8e77 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/tablet/README @@ -0,0 +1,4 @@ +Tablet protocol + +Maintainers: +Peter Hutterer <peter.hutterer@who-t.net> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/tablet/tablet-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/tablet/tablet-unstable-v1.xml new file mode 100644 index 0000000..6db9c05 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/tablet/tablet-unstable-v1.xml @@ -0,0 +1,640 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="tablet_unstable_v1"> + + <copyright> + Copyright 2014 © Stephen "Lyude" Chandler Paul + Copyright 2015-2016 © Red Hat, Inc. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice (including the + next paragraph) shall be included in all copies or substantial + portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + </copyright> + + <description summary="Wayland protocol for graphics tablets"> + This description provides a high-level overview of the interplay between + the interfaces defined this protocol. For details, see the protocol + specification. + + More than one tablet may exist, and device-specifics matter. Tablets are + not represented by a single virtual device like wl_pointer. A client + binds to the tablet manager object which is just a proxy object. From + that, the client requests wp_tablet_manager.get_tablet_seat(wl_seat) + and that returns the actual interface that has all the tablets. With + this indirection, we can avoid merging wp_tablet into the actual Wayland + protocol, a long-term benefit. + + The wp_tablet_seat sends a "tablet added" event for each tablet + connected. That event is followed by descriptive events about the + hardware; currently that includes events for name, vid/pid and + a wp_tablet.path event that describes a local path. This path can be + used to uniquely identify a tablet or get more information through + libwacom. Emulated or nested tablets can skip any of those, e.g. a + virtual tablet may not have a vid/pid. The sequence of descriptive + events is terminated by a wp_tablet.done event to signal that a client + may now finalize any initialization for that tablet. + + Events from tablets require a tool in proximity. Tools are also managed + by the tablet seat; a "tool added" event is sent whenever a tool is new + to the compositor. That event is followed by a number of descriptive + events about the hardware; currently that includes capabilities, + hardware id and serial number, and tool type. Similar to the tablet + interface, a wp_tablet_tool.done event is sent to terminate that initial + sequence. + + Any event from a tool happens on the wp_tablet_tool interface. When the + tool gets into proximity of the tablet, a proximity_in event is sent on + the wp_tablet_tool interface, listing the tablet and the surface. That + event is followed by a motion event with the coordinates. After that, + it's the usual motion, axis, button, etc. events. The protocol's + serialisation means events are grouped by wp_tablet_tool.frame events. + + Two special events (that don't exist in X) are down and up. They signal + "tip touching the surface". For tablets without real proximity + detection, the sequence is: proximity_in, motion, down, frame. + + When the tool leaves proximity, a proximity_out event is sent. If any + button is still down, a button release event is sent before this + proximity event. These button events are sent in the same frame as the + proximity event to signal to the client that the buttons were held when + the tool left proximity. + + If the tool moves out of the surface but stays in proximity (i.e. + between windows), compositor-specific grab policies apply. This usually + means that the proximity-out is delayed until all buttons are released. + + Moving a tool physically from one tablet to the other has no real effect + on the protocol, since we already have the tool object from the "tool + added" event. All the information is already there and the proximity + events on both tablets are all a client needs to reconstruct what + happened. + + Some extra axes are normalized, i.e. the client knows the range as + specified in the protocol (e.g. [0, 65535]), the granularity however is + unknown. The current normalized axes are pressure, distance, and slider. + + Other extra axes are in physical units as specified in the protocol. + The current extra axes with physical units are tilt, rotation and + wheel rotation. + + Since tablets work independently of the pointer controlled by the mouse, + the focus handling is independent too and controlled by proximity. + The wp_tablet_tool.set_cursor request sets a tool-specific cursor. + This cursor surface may be the same as the mouse cursor, and it may be + the same across tools but it is possible to be more fine-grained. For + example, a client may set different cursors for the pen and eraser. + + Tools are generally independent of tablets and it is + compositor-specific policy when a tool can be removed. Common approaches + will likely include some form of removing a tool when all tablets the + tool was used on are removed. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <interface name="zwp_tablet_manager_v1" version="1"> + <description summary="controller object for graphic tablet devices"> + An object that provides access to the graphics tablets available on this + system. All tablets are associated with a seat, to get access to the + actual tablets, use wp_tablet_manager.get_tablet_seat. + </description> + + <request name="get_tablet_seat"> + <description summary="get the tablet seat"> + Get the wp_tablet_seat object for the given seat. This object + provides access to all graphics tablets in this seat. + </description> + <arg name="tablet_seat" type="new_id" interface="zwp_tablet_seat_v1"/> + <arg name="seat" type="object" interface="wl_seat" summary="The wl_seat object to retrieve the tablets for" /> + </request> + + <request name="destroy" type="destructor"> + <description summary="release the memory for the tablet manager object"> + Destroy the wp_tablet_manager object. Objects created from this + object are unaffected and should be destroyed separately. + </description> + </request> + </interface> + + <interface name="zwp_tablet_seat_v1" version="1"> + <description summary="controller object for graphic tablet devices of a seat"> + An object that provides access to the graphics tablets available on this + seat. After binding to this interface, the compositor sends a set of + wp_tablet_seat.tablet_added and wp_tablet_seat.tool_added events. + </description> + + <request name="destroy" type="destructor"> + <description summary="release the memory for the tablet seat object"> + Destroy the wp_tablet_seat object. Objects created from this + object are unaffected and should be destroyed separately. + </description> + </request> + + <event name="tablet_added"> + <description summary="new device notification"> + This event is sent whenever a new tablet becomes available on this + seat. This event only provides the object id of the tablet, any + static information about the tablet (device name, vid/pid, etc.) is + sent through the wp_tablet interface. + </description> + <arg name="id" type="new_id" interface="zwp_tablet_v1" summary="the newly added graphics tablet"/> + </event> + + <event name="tool_added"> + <description summary="a new tool has been used with a tablet"> + This event is sent whenever a tool that has not previously been used + with a tablet comes into use. This event only provides the object id + of the tool; any static information about the tool (capabilities, + type, etc.) is sent through the wp_tablet_tool interface. + </description> + <arg name="id" type="new_id" interface="zwp_tablet_tool_v1" summary="the newly added tablet tool"/> + </event> + </interface> + + <interface name="zwp_tablet_tool_v1" version="1"> + <description summary="a physical tablet tool"> + An object that represents a physical tool that has been, or is + currently in use with a tablet in this seat. Each wp_tablet_tool + object stays valid until the client destroys it; the compositor + reuses the wp_tablet_tool object to indicate that the object's + respective physical tool has come into proximity of a tablet again. + + A wp_tablet_tool object's relation to a physical tool depends on the + tablet's ability to report serial numbers. If the tablet supports + this capability, then the object represents a specific physical tool + and can be identified even when used on multiple tablets. + + A tablet tool has a number of static characteristics, e.g. tool type, + hardware_serial and capabilities. These capabilities are sent in an + event sequence after the wp_tablet_seat.tool_added event before any + actual events from this tool. This initial event sequence is + terminated by a wp_tablet_tool.done event. + + Tablet tool events are grouped by wp_tablet_tool.frame events. + Any events received before a wp_tablet_tool.frame event should be + considered part of the same hardware state change. + </description> + + <request name="set_cursor"> + <description summary="set the tablet tool's surface"> + Sets the surface of the cursor used for this tool on the given + tablet. This request only takes effect if the tool is in proximity + of one of the requesting client's surfaces or the surface parameter + is the current pointer surface. If there was a previous surface set + with this request it is replaced. If surface is NULL, the cursor + image is hidden. + + The parameters hotspot_x and hotspot_y define the position of the + pointer surface relative to the pointer location. Its top-left corner + is always at (x, y) - (hotspot_x, hotspot_y), where (x, y) are the + coordinates of the pointer location, in surface-local coordinates. + + On surface.attach requests to the pointer surface, hotspot_x and + hotspot_y are decremented by the x and y parameters passed to the + request. Attach must be confirmed by wl_surface.commit as usual. + + The hotspot can also be updated by passing the currently set pointer + surface to this request with new values for hotspot_x and hotspot_y. + + The current and pending input regions of the wl_surface are cleared, + and wl_surface.set_input_region is ignored until the wl_surface is no + longer used as the cursor. When the use as a cursor ends, the current + and pending input regions become undefined, and the wl_surface is + unmapped. + + This request gives the surface the role of a cursor. The role + assigned by this request is the same as assigned by + wl_pointer.set_cursor meaning the same surface can be + used both as a wl_pointer cursor and a wp_tablet cursor. If the + surface already has another role, it raises a protocol error. + The surface may be used on multiple tablets and across multiple + seats. + </description> + <arg name="serial" type="uint" summary="serial of the enter event"/> + <arg name="surface" type="object" interface="wl_surface" allow-null="true"/> + <arg name="hotspot_x" type="int" summary="surface-local x coordinate"/> + <arg name="hotspot_y" type="int" summary="surface-local y coordinate"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the tool object"> + This destroys the client's resource for this tool object. + </description> + </request> + + <enum name="type"> + <description summary="a physical tool type"> + Describes the physical type of a tool. The physical type of a tool + generally defines its base usage. + + The mouse tool represents a mouse-shaped tool that is not a relative + device but bound to the tablet's surface, providing absolute + coordinates. + + The lens tool is a mouse-shaped tool with an attached lens to + provide precision focus. + </description> + <entry name="pen" value="0x140" summary="Pen"/> + <entry name="eraser" value="0x141" summary="Eraser"/> + <entry name="brush" value="0x142" summary="Brush"/> + <entry name="pencil" value="0x143" summary="Pencil"/> + <entry name="airbrush" value="0x144" summary="Airbrush"/> + <entry name="finger" value="0x145" summary="Finger"/> + <entry name="mouse" value="0x146" summary="Mouse"/> + <entry name="lens" value="0x147" summary="Lens"/> + </enum> + + <event name="type"> + <description summary="tool type"> + The tool type is the high-level type of the tool and usually decides + the interaction expected from this tool. + + This event is sent in the initial burst of events before the + wp_tablet_tool.done event. + </description> + <arg name="tool_type" type="uint" enum="type" summary="the physical tool type"/> + </event> + + <event name="hardware_serial"> + <description summary="unique hardware serial number of the tool"> + If the physical tool can be identified by a unique 64-bit serial + number, this event notifies the client of this serial number. + + If multiple tablets are available in the same seat and the tool is + uniquely identifiable by the serial number, that tool may move + between tablets. + + Otherwise, if the tool has no serial number and this event is + missing, the tool is tied to the tablet it first comes into + proximity with. Even if the physical tool is used on multiple + tablets, separate wp_tablet_tool objects will be created, one per + tablet. + + This event is sent in the initial burst of events before the + wp_tablet_tool.done event. + </description> + <arg name="hardware_serial_hi" type="uint" summary="the unique serial number of the tool, most significant bits"/> + <arg name="hardware_serial_lo" type="uint" summary="the unique serial number of the tool, least significant bits"/> + </event> + + <event name="hardware_id_wacom"> + <description summary="hardware id notification in Wacom's format"> + This event notifies the client of a hardware id available on this tool. + + The hardware id is a device-specific 64-bit id that provides extra + information about the tool in use, beyond the wl_tool.type + enumeration. The format of the id is specific to tablets made by + Wacom Inc. For example, the hardware id of a Wacom Grip + Pen (a stylus) is 0x802. + + This event is sent in the initial burst of events before the + wp_tablet_tool.done event. + </description> + <arg name="hardware_id_hi" type="uint" summary="the hardware id, most significant bits"/> + <arg name="hardware_id_lo" type="uint" summary="the hardware id, least significant bits"/> + </event> + + <enum name="capability"> + <description summary="capability flags for a tool"> + Describes extra capabilities on a tablet. + + Any tool must provide x and y values, extra axes are + device-specific. + </description> + <entry name="tilt" value="1" summary="Tilt axes"/> + <entry name="pressure" value="2" summary="Pressure axis"/> + <entry name="distance" value="3" summary="Distance axis"/> + <entry name="rotation" value="4" summary="Z-rotation axis"/> + <entry name="slider" value="5" summary="Slider axis"/> + <entry name="wheel" value="6" summary="Wheel axis"/> + </enum> + + <event name="capability"> + <description summary="tool capability notification"> + This event notifies the client of any capabilities of this tool, + beyond the main set of x/y axes and tip up/down detection. + + One event is sent for each extra capability available on this tool. + + This event is sent in the initial burst of events before the + wp_tablet_tool.done event. + </description> + <arg name="capability" type="uint" enum="capability" summary="the capability"/> + </event> + + <event name="done"> + <description summary="tool description events sequence complete"> + This event signals the end of the initial burst of descriptive + events. A client may consider the static description of the tool to + be complete and finalize initialization of the tool. + </description> + </event> + + <event name="removed"> + <description summary="tool removed"> + This event is sent when the tool is removed from the system and will + send no further events. Should the physical tool come back into + proximity later, a new wp_tablet_tool object will be created. + + It is compositor-dependent when a tool is removed. A compositor may + remove a tool on proximity out, tablet removal or any other reason. + A compositor may also keep a tool alive until shutdown. + + If the tool is currently in proximity, a proximity_out event will be + sent before the removed event. See wp_tablet_tool.proximity_out for + the handling of any buttons logically down. + + When this event is received, the client must wp_tablet_tool.destroy + the object. + </description> + </event> + + <event name="proximity_in"> + <description summary="proximity in event"> + Notification that this tool is focused on a certain surface. + + This event can be received when the tool has moved from one surface to + another, or when the tool has come back into proximity above the + surface. + + If any button is logically down when the tool comes into proximity, + the respective button event is sent after the proximity_in event but + within the same frame as the proximity_in event. + </description> + <arg name="serial" type="uint"/> + <arg name="tablet" type="object" interface="zwp_tablet_v1" summary="The tablet the tool is in proximity of"/> + <arg name="surface" type="object" interface="wl_surface" summary="The current surface the tablet tool is over"/> + </event> + + <event name="proximity_out"> + <description summary="proximity out event"> + Notification that this tool has either left proximity, or is no + longer focused on a certain surface. + + When the tablet tool leaves proximity of the tablet, button release + events are sent for each button that was held down at the time of + leaving proximity. These events are sent before the proximity_out + event but within the same wp_tablet.frame. + + If the tool stays within proximity of the tablet, but the focus + changes from one surface to another, a button release event may not + be sent until the button is actually released or the tool leaves the + proximity of the tablet. + </description> + </event> + + <event name="down"> + <description summary="tablet tool is making contact"> + Sent whenever the tablet tool comes in contact with the surface of the + tablet. + + If the tool is already in contact with the tablet when entering the + input region, the client owning said region will receive a + wp_tablet.proximity_in event, followed by a wp_tablet.down + event and a wp_tablet.frame event. + + Note that this event describes logical contact, not physical + contact. On some devices, a compositor may not consider a tool in + logical contact until a minimum physical pressure threshold is + exceeded. + </description> + <arg name="serial" type="uint"/> + </event> + + <event name="up"> + <description summary="tablet tool is no longer making contact"> + Sent whenever the tablet tool stops making contact with the surface of + the tablet, or when the tablet tool moves out of the input region + and the compositor grab (if any) is dismissed. + + If the tablet tool moves out of the input region while in contact + with the surface of the tablet and the compositor does not have an + ongoing grab on the surface, the client owning said region will + receive a wp_tablet.up event, followed by a wp_tablet.proximity_out + event and a wp_tablet.frame event. If the compositor has an ongoing + grab on this device, this event sequence is sent whenever the grab + is dismissed in the future. + + Note that this event describes logical contact, not physical + contact. On some devices, a compositor may not consider a tool out + of logical contact until physical pressure falls below a specific + threshold. + </description> + </event> + + <event name="motion"> + <description summary="motion event"> + Sent whenever a tablet tool moves. + </description> + <arg name="x" type="fixed" summary="surface-local x coordinate"/> + <arg name="y" type="fixed" summary="surface-local y coordinate"/> + </event> + + <event name="pressure"> + <description summary="pressure change event"> + Sent whenever the pressure axis on a tool changes. The value of this + event is normalized to a value between 0 and 65535. + + Note that pressure may be nonzero even when a tool is not in logical + contact. See the down and up events for more details. + </description> + <arg name="pressure" type="uint" summary="The current pressure value"/> + </event> + + <event name="distance"> + <description summary="distance change event"> + Sent whenever the distance axis on a tool changes. The value of this + event is normalized to a value between 0 and 65535. + + Note that distance may be nonzero even when a tool is not in logical + contact. See the down and up events for more details. + </description> + <arg name="distance" type="uint" summary="The current distance value"/> + </event> + + <event name="tilt"> + <description summary="tilt change event"> + Sent whenever one or both of the tilt axes on a tool change. Each tilt + value is in 0.01 of a degree, relative to the z-axis of the tablet. + The angle is positive when the top of a tool tilts along the + positive x or y axis. + </description> + <arg name="tilt_x" type="int" summary="The current value of the X tilt axis"/> + <arg name="tilt_y" type="int" summary="The current value of the Y tilt axis"/> + </event> + + <event name="rotation"> + <description summary="z-rotation change event"> + Sent whenever the z-rotation axis on the tool changes. The + rotation value is in 0.01 of a degree clockwise from the tool's + logical neutral position. + </description> + <arg name="degrees" type="int" summary="The current rotation of the Z axis"/> + </event> + + <event name="slider"> + <description summary="Slider position change event"> + Sent whenever the slider position on the tool changes. The + value is normalized between -65535 and 65535, with 0 as the logical + neutral position of the slider. + + The slider is available on e.g. the Wacom Airbrush tool. + </description> + <arg name="position" type="int" summary="The current position of slider"/> + </event> + + <event name="wheel"> + <description summary="Wheel delta event"> + Sent whenever the wheel on the tool emits an event. This event + contains two values for the same axis change. The degrees value is + in 0.01 of a degree in the same orientation as the + wl_pointer.vertical_scroll axis. The clicks value is in discrete + logical clicks of the mouse wheel. This value may be zero if the + movement of the wheel was less than one logical click. + + Clients should choose either value and avoid mixing degrees and + clicks. The compositor may accumulate values smaller than a logical + click and emulate click events when a certain threshold is met. + Thus, wl_tablet_tool.wheel events with non-zero clicks values may + have different degrees values. + </description> + <arg name="degrees" type="int" summary="The wheel delta in 0.01 of a degree"/> + <arg name="clicks" type="int" summary="The wheel delta in discrete clicks"/> + </event> + + <enum name="button_state"> + <description summary="physical button state"> + Describes the physical state of a button that produced the button event. + </description> + <entry name="released" value="0" summary="button is not pressed"/> + <entry name="pressed" value="1" summary="button is pressed"/> + </enum> + + <event name="button"> + <description summary="button event"> + Sent whenever a button on the tool is pressed or released. + + If a button is held down when the tool moves in or out of proximity, + button events are generated by the compositor. See + wp_tablet_tool.proximity_in and wp_tablet_tool.proximity_out for + details. + </description> + <arg name="serial" type="uint"/> + <arg name="button" type="uint" summary="The button whose state has changed"/> + <arg name="state" type="uint" enum="button_state" summary="Whether the button was pressed or released"/> + </event> + + <event name="frame"> + <description summary="frame event"> + Marks the end of a series of axis and/or button updates from the + tablet. The Wayland protocol requires axis updates to be sent + sequentially, however all events within a frame should be considered + one hardware event. + </description> + <arg name="time" type="uint" summary="The time of the event with millisecond granularity"/> + </event> + + <enum name="error"> + <entry name="role" value="0" summary="given wl_surface has another role"/> + </enum> + </interface> + + <interface name="zwp_tablet_v1" version="1"> + <description summary="graphics tablet device"> + The wp_tablet interface represents one graphics tablet device. The + tablet interface itself does not generate events; all events are + generated by wp_tablet_tool objects when in proximity above a tablet. + + A tablet has a number of static characteristics, e.g. device name and + pid/vid. These capabilities are sent in an event sequence after the + wp_tablet_seat.tablet_added event. This initial event sequence is + terminated by a wp_tablet.done event. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the tablet object"> + This destroys the client's resource for this tablet object. + </description> + </request> + + <event name="name"> + <description summary="tablet device name"> + This event is sent in the initial burst of events before the + wp_tablet.done event. + </description> + <arg name="name" type="string" summary="the device name"/> + </event> + + <event name="id"> + <description summary="tablet device USB vendor/product id"> + This event is sent in the initial burst of events before the + wp_tablet.done event. + </description> + <arg name="vid" type="uint" summary="USB vendor id"/> + <arg name="pid" type="uint" summary="USB product id"/> + </event> + + <event name="path"> + <description summary="path to the device"> + A system-specific device path that indicates which device is behind + this wp_tablet. This information may be used to gather additional + information about the device, e.g. through libwacom. + + A device may have more than one device path. If so, multiple + wp_tablet.path events are sent. A device may be emulated and not + have a device path, and in that case this event will not be sent. + + The format of the path is unspecified, it may be a device node, a + sysfs path, or some other identifier. It is up to the client to + identify the string provided. + + This event is sent in the initial burst of events before the + wp_tablet.done event. + </description> + <arg name="path" type="string" summary="path to local device"/> + </event> + + <event name="done"> + <description summary="tablet description events sequence complete"> + This event is sent immediately to signal the end of the initial + burst of descriptive events. A client may consider the static + description of the tablet to be complete and finalize initialization + of the tablet. + </description> + </event> + + <event name="removed"> + <description summary="tablet removed event"> + Sent when the tablet has been removed from the system. When a tablet + is removed, some tools may be removed. + + When this event is received, the client must wp_tablet.destroy + the object. + </description> + </event> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/tablet/tablet-unstable-v2.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/tablet/tablet-unstable-v2.xml new file mode 100644 index 0000000..b286d96 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/tablet/tablet-unstable-v2.xml @@ -0,0 +1,1178 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="tablet_unstable_v2"> + + <copyright> + Copyright 2014 © Stephen "Lyude" Chandler Paul + Copyright 2015-2016 © Red Hat, Inc. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice (including the + next paragraph) shall be included in all copies or substantial + portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + </copyright> + + <description summary="Wayland protocol for graphics tablets"> + This description provides a high-level overview of the interplay between + the interfaces defined this protocol. For details, see the protocol + specification. + + More than one tablet may exist, and device-specifics matter. Tablets are + not represented by a single virtual device like wl_pointer. A client + binds to the tablet manager object which is just a proxy object. From + that, the client requests wp_tablet_manager.get_tablet_seat(wl_seat) + and that returns the actual interface that has all the tablets. With + this indirection, we can avoid merging wp_tablet into the actual Wayland + protocol, a long-term benefit. + + The wp_tablet_seat sends a "tablet added" event for each tablet + connected. That event is followed by descriptive events about the + hardware; currently that includes events for name, vid/pid and + a wp_tablet.path event that describes a local path. This path can be + used to uniquely identify a tablet or get more information through + libwacom. Emulated or nested tablets can skip any of those, e.g. a + virtual tablet may not have a vid/pid. The sequence of descriptive + events is terminated by a wp_tablet.done event to signal that a client + may now finalize any initialization for that tablet. + + Events from tablets require a tool in proximity. Tools are also managed + by the tablet seat; a "tool added" event is sent whenever a tool is new + to the compositor. That event is followed by a number of descriptive + events about the hardware; currently that includes capabilities, + hardware id and serial number, and tool type. Similar to the tablet + interface, a wp_tablet_tool.done event is sent to terminate that initial + sequence. + + Any event from a tool happens on the wp_tablet_tool interface. When the + tool gets into proximity of the tablet, a proximity_in event is sent on + the wp_tablet_tool interface, listing the tablet and the surface. That + event is followed by a motion event with the coordinates. After that, + it's the usual motion, axis, button, etc. events. The protocol's + serialisation means events are grouped by wp_tablet_tool.frame events. + + Two special events (that don't exist in X) are down and up. They signal + "tip touching the surface". For tablets without real proximity + detection, the sequence is: proximity_in, motion, down, frame. + + When the tool leaves proximity, a proximity_out event is sent. If any + button is still down, a button release event is sent before this + proximity event. These button events are sent in the same frame as the + proximity event to signal to the client that the buttons were held when + the tool left proximity. + + If the tool moves out of the surface but stays in proximity (i.e. + between windows), compositor-specific grab policies apply. This usually + means that the proximity-out is delayed until all buttons are released. + + Moving a tool physically from one tablet to the other has no real effect + on the protocol, since we already have the tool object from the "tool + added" event. All the information is already there and the proximity + events on both tablets are all a client needs to reconstruct what + happened. + + Some extra axes are normalized, i.e. the client knows the range as + specified in the protocol (e.g. [0, 65535]), the granularity however is + unknown. The current normalized axes are pressure, distance, and slider. + + Other extra axes are in physical units as specified in the protocol. + The current extra axes with physical units are tilt, rotation and + wheel rotation. + + Since tablets work independently of the pointer controlled by the mouse, + the focus handling is independent too and controlled by proximity. + The wp_tablet_tool.set_cursor request sets a tool-specific cursor. + This cursor surface may be the same as the mouse cursor, and it may be + the same across tools but it is possible to be more fine-grained. For + example, a client may set different cursors for the pen and eraser. + + Tools are generally independent of tablets and it is + compositor-specific policy when a tool can be removed. Common approaches + will likely include some form of removing a tool when all tablets the + tool was used on are removed. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <interface name="zwp_tablet_manager_v2" version="1"> + <description summary="controller object for graphic tablet devices"> + An object that provides access to the graphics tablets available on this + system. All tablets are associated with a seat, to get access to the + actual tablets, use wp_tablet_manager.get_tablet_seat. + </description> + + <request name="get_tablet_seat"> + <description summary="get the tablet seat"> + Get the wp_tablet_seat object for the given seat. This object + provides access to all graphics tablets in this seat. + </description> + <arg name="tablet_seat" type="new_id" interface="zwp_tablet_seat_v2"/> + <arg name="seat" type="object" interface="wl_seat" summary="The wl_seat object to retrieve the tablets for" /> + </request> + + <request name="destroy" type="destructor"> + <description summary="release the memory for the tablet manager object"> + Destroy the wp_tablet_manager object. Objects created from this + object are unaffected and should be destroyed separately. + </description> + </request> + </interface> + + <interface name="zwp_tablet_seat_v2" version="1"> + <description summary="controller object for graphic tablet devices of a seat"> + An object that provides access to the graphics tablets available on this + seat. After binding to this interface, the compositor sends a set of + wp_tablet_seat.tablet_added and wp_tablet_seat.tool_added events. + </description> + + <request name="destroy" type="destructor"> + <description summary="release the memory for the tablet seat object"> + Destroy the wp_tablet_seat object. Objects created from this + object are unaffected and should be destroyed separately. + </description> + </request> + + <event name="tablet_added"> + <description summary="new device notification"> + This event is sent whenever a new tablet becomes available on this + seat. This event only provides the object id of the tablet, any + static information about the tablet (device name, vid/pid, etc.) is + sent through the wp_tablet interface. + </description> + <arg name="id" type="new_id" interface="zwp_tablet_v2" summary="the newly added graphics tablet"/> + </event> + + <event name="tool_added"> + <description summary="a new tool has been used with a tablet"> + This event is sent whenever a tool that has not previously been used + with a tablet comes into use. This event only provides the object id + of the tool; any static information about the tool (capabilities, + type, etc.) is sent through the wp_tablet_tool interface. + </description> + <arg name="id" type="new_id" interface="zwp_tablet_tool_v2" summary="the newly added tablet tool"/> + </event> + + <event name="pad_added"> + <description summary="new pad notification"> + This event is sent whenever a new pad is known to the system. Typically, + pads are physically attached to tablets and a pad_added event is + sent immediately after the wp_tablet_seat.tablet_added. + However, some standalone pad devices logically attach to tablets at + runtime, and the client must wait for wp_tablet_pad.enter to know + the tablet a pad is attached to. + + This event only provides the object id of the pad. All further + features (buttons, strips, rings) are sent through the wp_tablet_pad + interface. + </description> + <arg name="id" type="new_id" interface="zwp_tablet_pad_v2" summary="the newly added pad"/> + </event> + </interface> + + <interface name="zwp_tablet_tool_v2" version="1"> + <description summary="a physical tablet tool"> + An object that represents a physical tool that has been, or is + currently in use with a tablet in this seat. Each wp_tablet_tool + object stays valid until the client destroys it; the compositor + reuses the wp_tablet_tool object to indicate that the object's + respective physical tool has come into proximity of a tablet again. + + A wp_tablet_tool object's relation to a physical tool depends on the + tablet's ability to report serial numbers. If the tablet supports + this capability, then the object represents a specific physical tool + and can be identified even when used on multiple tablets. + + A tablet tool has a number of static characteristics, e.g. tool type, + hardware_serial and capabilities. These capabilities are sent in an + event sequence after the wp_tablet_seat.tool_added event before any + actual events from this tool. This initial event sequence is + terminated by a wp_tablet_tool.done event. + + Tablet tool events are grouped by wp_tablet_tool.frame events. + Any events received before a wp_tablet_tool.frame event should be + considered part of the same hardware state change. + </description> + + <request name="set_cursor"> + <description summary="set the tablet tool's surface"> + Sets the surface of the cursor used for this tool on the given + tablet. This request only takes effect if the tool is in proximity + of one of the requesting client's surfaces or the surface parameter + is the current pointer surface. If there was a previous surface set + with this request it is replaced. If surface is NULL, the cursor + image is hidden. + + The parameters hotspot_x and hotspot_y define the position of the + pointer surface relative to the pointer location. Its top-left corner + is always at (x, y) - (hotspot_x, hotspot_y), where (x, y) are the + coordinates of the pointer location, in surface-local coordinates. + + On surface.attach requests to the pointer surface, hotspot_x and + hotspot_y are decremented by the x and y parameters passed to the + request. Attach must be confirmed by wl_surface.commit as usual. + + The hotspot can also be updated by passing the currently set pointer + surface to this request with new values for hotspot_x and hotspot_y. + + The current and pending input regions of the wl_surface are cleared, + and wl_surface.set_input_region is ignored until the wl_surface is no + longer used as the cursor. When the use as a cursor ends, the current + and pending input regions become undefined, and the wl_surface is + unmapped. + + This request gives the surface the role of a wp_tablet_tool cursor. A + surface may only ever be used as the cursor surface for one + wp_tablet_tool. If the surface already has another role or has + previously been used as cursor surface for a different tool, a + protocol error is raised. + </description> + <arg name="serial" type="uint" summary="serial of the enter event"/> + <arg name="surface" type="object" interface="wl_surface" allow-null="true"/> + <arg name="hotspot_x" type="int" summary="surface-local x coordinate"/> + <arg name="hotspot_y" type="int" summary="surface-local y coordinate"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the tool object"> + This destroys the client's resource for this tool object. + </description> + </request> + + <enum name="type"> + <description summary="a physical tool type"> + Describes the physical type of a tool. The physical type of a tool + generally defines its base usage. + + The mouse tool represents a mouse-shaped tool that is not a relative + device but bound to the tablet's surface, providing absolute + coordinates. + + The lens tool is a mouse-shaped tool with an attached lens to + provide precision focus. + </description> + <entry name="pen" value="0x140" summary="Pen"/> + <entry name="eraser" value="0x141" summary="Eraser"/> + <entry name="brush" value="0x142" summary="Brush"/> + <entry name="pencil" value="0x143" summary="Pencil"/> + <entry name="airbrush" value="0x144" summary="Airbrush"/> + <entry name="finger" value="0x145" summary="Finger"/> + <entry name="mouse" value="0x146" summary="Mouse"/> + <entry name="lens" value="0x147" summary="Lens"/> + </enum> + + <event name="type"> + <description summary="tool type"> + The tool type is the high-level type of the tool and usually decides + the interaction expected from this tool. + + This event is sent in the initial burst of events before the + wp_tablet_tool.done event. + </description> + <arg name="tool_type" type="uint" enum="type" summary="the physical tool type"/> + </event> + + <event name="hardware_serial"> + <description summary="unique hardware serial number of the tool"> + If the physical tool can be identified by a unique 64-bit serial + number, this event notifies the client of this serial number. + + If multiple tablets are available in the same seat and the tool is + uniquely identifiable by the serial number, that tool may move + between tablets. + + Otherwise, if the tool has no serial number and this event is + missing, the tool is tied to the tablet it first comes into + proximity with. Even if the physical tool is used on multiple + tablets, separate wp_tablet_tool objects will be created, one per + tablet. + + This event is sent in the initial burst of events before the + wp_tablet_tool.done event. + </description> + <arg name="hardware_serial_hi" type="uint" summary="the unique serial number of the tool, most significant bits"/> + <arg name="hardware_serial_lo" type="uint" summary="the unique serial number of the tool, least significant bits"/> + </event> + + <event name="hardware_id_wacom"> + <description summary="hardware id notification in Wacom's format"> + This event notifies the client of a hardware id available on this tool. + + The hardware id is a device-specific 64-bit id that provides extra + information about the tool in use, beyond the wl_tool.type + enumeration. The format of the id is specific to tablets made by + Wacom Inc. For example, the hardware id of a Wacom Grip + Pen (a stylus) is 0x802. + + This event is sent in the initial burst of events before the + wp_tablet_tool.done event. + </description> + <arg name="hardware_id_hi" type="uint" summary="the hardware id, most significant bits"/> + <arg name="hardware_id_lo" type="uint" summary="the hardware id, least significant bits"/> + </event> + + <enum name="capability"> + <description summary="capability flags for a tool"> + Describes extra capabilities on a tablet. + + Any tool must provide x and y values, extra axes are + device-specific. + </description> + <entry name="tilt" value="1" summary="Tilt axes"/> + <entry name="pressure" value="2" summary="Pressure axis"/> + <entry name="distance" value="3" summary="Distance axis"/> + <entry name="rotation" value="4" summary="Z-rotation axis"/> + <entry name="slider" value="5" summary="Slider axis"/> + <entry name="wheel" value="6" summary="Wheel axis"/> + </enum> + + <event name="capability"> + <description summary="tool capability notification"> + This event notifies the client of any capabilities of this tool, + beyond the main set of x/y axes and tip up/down detection. + + One event is sent for each extra capability available on this tool. + + This event is sent in the initial burst of events before the + wp_tablet_tool.done event. + </description> + <arg name="capability" type="uint" enum="capability" summary="the capability"/> + </event> + + <event name="done"> + <description summary="tool description events sequence complete"> + This event signals the end of the initial burst of descriptive + events. A client may consider the static description of the tool to + be complete and finalize initialization of the tool. + </description> + </event> + + <event name="removed"> + <description summary="tool removed"> + This event is sent when the tool is removed from the system and will + send no further events. Should the physical tool come back into + proximity later, a new wp_tablet_tool object will be created. + + It is compositor-dependent when a tool is removed. A compositor may + remove a tool on proximity out, tablet removal or any other reason. + A compositor may also keep a tool alive until shutdown. + + If the tool is currently in proximity, a proximity_out event will be + sent before the removed event. See wp_tablet_tool.proximity_out for + the handling of any buttons logically down. + + When this event is received, the client must wp_tablet_tool.destroy + the object. + </description> + </event> + + <event name="proximity_in"> + <description summary="proximity in event"> + Notification that this tool is focused on a certain surface. + + This event can be received when the tool has moved from one surface to + another, or when the tool has come back into proximity above the + surface. + + If any button is logically down when the tool comes into proximity, + the respective button event is sent after the proximity_in event but + within the same frame as the proximity_in event. + </description> + <arg name="serial" type="uint"/> + <arg name="tablet" type="object" interface="zwp_tablet_v2" summary="The tablet the tool is in proximity of"/> + <arg name="surface" type="object" interface="wl_surface" summary="The current surface the tablet tool is over"/> + </event> + + <event name="proximity_out"> + <description summary="proximity out event"> + Notification that this tool has either left proximity, or is no + longer focused on a certain surface. + + When the tablet tool leaves proximity of the tablet, button release + events are sent for each button that was held down at the time of + leaving proximity. These events are sent before the proximity_out + event but within the same wp_tablet.frame. + + If the tool stays within proximity of the tablet, but the focus + changes from one surface to another, a button release event may not + be sent until the button is actually released or the tool leaves the + proximity of the tablet. + </description> + </event> + + <event name="down"> + <description summary="tablet tool is making contact"> + Sent whenever the tablet tool comes in contact with the surface of the + tablet. + + If the tool is already in contact with the tablet when entering the + input region, the client owning said region will receive a + wp_tablet.proximity_in event, followed by a wp_tablet.down + event and a wp_tablet.frame event. + + Note that this event describes logical contact, not physical + contact. On some devices, a compositor may not consider a tool in + logical contact until a minimum physical pressure threshold is + exceeded. + </description> + <arg name="serial" type="uint"/> + </event> + + <event name="up"> + <description summary="tablet tool is no longer making contact"> + Sent whenever the tablet tool stops making contact with the surface of + the tablet, or when the tablet tool moves out of the input region + and the compositor grab (if any) is dismissed. + + If the tablet tool moves out of the input region while in contact + with the surface of the tablet and the compositor does not have an + ongoing grab on the surface, the client owning said region will + receive a wp_tablet.up event, followed by a wp_tablet.proximity_out + event and a wp_tablet.frame event. If the compositor has an ongoing + grab on this device, this event sequence is sent whenever the grab + is dismissed in the future. + + Note that this event describes logical contact, not physical + contact. On some devices, a compositor may not consider a tool out + of logical contact until physical pressure falls below a specific + threshold. + </description> + </event> + + <event name="motion"> + <description summary="motion event"> + Sent whenever a tablet tool moves. + </description> + <arg name="x" type="fixed" summary="surface-local x coordinate"/> + <arg name="y" type="fixed" summary="surface-local y coordinate"/> + </event> + + <event name="pressure"> + <description summary="pressure change event"> + Sent whenever the pressure axis on a tool changes. The value of this + event is normalized to a value between 0 and 65535. + + Note that pressure may be nonzero even when a tool is not in logical + contact. See the down and up events for more details. + </description> + <arg name="pressure" type="uint" summary="The current pressure value"/> + </event> + + <event name="distance"> + <description summary="distance change event"> + Sent whenever the distance axis on a tool changes. The value of this + event is normalized to a value between 0 and 65535. + + Note that distance may be nonzero even when a tool is not in logical + contact. See the down and up events for more details. + </description> + <arg name="distance" type="uint" summary="The current distance value"/> + </event> + + <event name="tilt"> + <description summary="tilt change event"> + Sent whenever one or both of the tilt axes on a tool change. Each tilt + value is in degrees, relative to the z-axis of the tablet. + The angle is positive when the top of a tool tilts along the + positive x or y axis. + </description> + <arg name="tilt_x" type="fixed" summary="The current value of the X tilt axis"/> + <arg name="tilt_y" type="fixed" summary="The current value of the Y tilt axis"/> + </event> + + <event name="rotation"> + <description summary="z-rotation change event"> + Sent whenever the z-rotation axis on the tool changes. The + rotation value is in degrees clockwise from the tool's + logical neutral position. + </description> + <arg name="degrees" type="fixed" summary="The current rotation of the Z axis"/> + </event> + + <event name="slider"> + <description summary="Slider position change event"> + Sent whenever the slider position on the tool changes. The + value is normalized between -65535 and 65535, with 0 as the logical + neutral position of the slider. + + The slider is available on e.g. the Wacom Airbrush tool. + </description> + <arg name="position" type="int" summary="The current position of slider"/> + </event> + + <event name="wheel"> + <description summary="Wheel delta event"> + Sent whenever the wheel on the tool emits an event. This event + contains two values for the same axis change. The degrees value is + in the same orientation as the wl_pointer.vertical_scroll axis. The + clicks value is in discrete logical clicks of the mouse wheel. This + value may be zero if the movement of the wheel was less + than one logical click. + + Clients should choose either value and avoid mixing degrees and + clicks. The compositor may accumulate values smaller than a logical + click and emulate click events when a certain threshold is met. + Thus, wl_tablet_tool.wheel events with non-zero clicks values may + have different degrees values. + </description> + <arg name="degrees" type="fixed" summary="The wheel delta in degrees"/> + <arg name="clicks" type="int" summary="The wheel delta in discrete clicks"/> + </event> + + <enum name="button_state"> + <description summary="physical button state"> + Describes the physical state of a button that produced the button event. + </description> + <entry name="released" value="0" summary="button is not pressed"/> + <entry name="pressed" value="1" summary="button is pressed"/> + </enum> + + <event name="button"> + <description summary="button event"> + Sent whenever a button on the tool is pressed or released. + + If a button is held down when the tool moves in or out of proximity, + button events are generated by the compositor. See + wp_tablet_tool.proximity_in and wp_tablet_tool.proximity_out for + details. + </description> + <arg name="serial" type="uint"/> + <arg name="button" type="uint" summary="The button whose state has changed"/> + <arg name="state" type="uint" enum="button_state" summary="Whether the button was pressed or released"/> + </event> + + <event name="frame"> + <description summary="frame event"> + Marks the end of a series of axis and/or button updates from the + tablet. The Wayland protocol requires axis updates to be sent + sequentially, however all events within a frame should be considered + one hardware event. + </description> + <arg name="time" type="uint" summary="The time of the event with millisecond granularity"/> + </event> + + <enum name="error"> + <entry name="role" value="0" summary="given wl_surface has another role"/> + </enum> + </interface> + + <interface name="zwp_tablet_v2" version="1"> + <description summary="graphics tablet device"> + The wp_tablet interface represents one graphics tablet device. The + tablet interface itself does not generate events; all events are + generated by wp_tablet_tool objects when in proximity above a tablet. + + A tablet has a number of static characteristics, e.g. device name and + pid/vid. These capabilities are sent in an event sequence after the + wp_tablet_seat.tablet_added event. This initial event sequence is + terminated by a wp_tablet.done event. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the tablet object"> + This destroys the client's resource for this tablet object. + </description> + </request> + + <event name="name"> + <description summary="tablet device name"> + This event is sent in the initial burst of events before the + wp_tablet.done event. + </description> + <arg name="name" type="string" summary="the device name"/> + </event> + + <event name="id"> + <description summary="tablet device USB vendor/product id"> + This event is sent in the initial burst of events before the + wp_tablet.done event. + </description> + <arg name="vid" type="uint" summary="USB vendor id"/> + <arg name="pid" type="uint" summary="USB product id"/> + </event> + + <event name="path"> + <description summary="path to the device"> + A system-specific device path that indicates which device is behind + this wp_tablet. This information may be used to gather additional + information about the device, e.g. through libwacom. + + A device may have more than one device path. If so, multiple + wp_tablet.path events are sent. A device may be emulated and not + have a device path, and in that case this event will not be sent. + + The format of the path is unspecified, it may be a device node, a + sysfs path, or some other identifier. It is up to the client to + identify the string provided. + + This event is sent in the initial burst of events before the + wp_tablet.done event. + </description> + <arg name="path" type="string" summary="path to local device"/> + </event> + + <event name="done"> + <description summary="tablet description events sequence complete"> + This event is sent immediately to signal the end of the initial + burst of descriptive events. A client may consider the static + description of the tablet to be complete and finalize initialization + of the tablet. + </description> + </event> + + <event name="removed"> + <description summary="tablet removed event"> + Sent when the tablet has been removed from the system. When a tablet + is removed, some tools may be removed. + + When this event is received, the client must wp_tablet.destroy + the object. + </description> + </event> + </interface> + + <interface name="zwp_tablet_pad_ring_v2" version="1"> + <description summary="pad ring"> + A circular interaction area, such as the touch ring on the Wacom Intuos + Pro series tablets. + + Events on a ring are logically grouped by the wl_tablet_pad_ring.frame + event. + </description> + + <request name="set_feedback"> + <description summary="set compositor feedback"> + Request that the compositor use the provided feedback string + associated with this ring. This request should be issued immediately + after a wp_tablet_pad_group.mode_switch event from the corresponding + group is received, or whenever the ring is mapped to a different + action. See wp_tablet_pad_group.mode_switch for more details. + + Clients are encouraged to provide context-aware descriptions for + the actions associated with the ring; compositors may use this + information to offer visual feedback about the button layout + (eg. on-screen displays). + + The provided string 'description' is a UTF-8 encoded string to be + associated with this ring, and is considered user-visible; general + internationalization rules apply. + + The serial argument will be that of the last + wp_tablet_pad_group.mode_switch event received for the group of this + ring. Requests providing other serials than the most recent one will be + ignored. + </description> + <arg name="description" type="string" summary="ring description"/> + <arg name="serial" type="uint" summary="serial of the mode switch event"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the ring object"> + This destroys the client's resource for this ring object. + </description> + </request> + + <enum name="source"> + <description summary="ring axis source"> + Describes the source types for ring events. This indicates to the + client how a ring event was physically generated; a client may + adjust the user interface accordingly. For example, events + from a "finger" source may trigger kinetic scrolling. + </description> + <entry name="finger" value="1" summary="finger"/> + </enum> + + <event name="source"> + <description summary="ring event source"> + Source information for ring events. + + This event does not occur on its own. It is sent before a + wp_tablet_pad_ring.frame event and carries the source information + for all events within that frame. + + The source specifies how this event was generated. If the source is + wp_tablet_pad_ring.source.finger, a wp_tablet_pad_ring.stop event + will be sent when the user lifts the finger off the device. + + This event is optional. If the source is unknown for an interaction, + no event is sent. + </description> + <arg name="source" type="uint" enum="source" summary="the event source"/> + </event> + + <event name="angle"> + <description summary="angle changed"> + Sent whenever the angle on a ring changes. + + The angle is provided in degrees clockwise from the logical + north of the ring in the pad's current rotation. + </description> + <arg name="degrees" type="fixed" summary="the current angle in degrees"/> + </event> + + <event name="stop"> + <description summary="interaction stopped"> + Stop notification for ring events. + + For some wp_tablet_pad_ring.source types, a wp_tablet_pad_ring.stop + event is sent to notify a client that the interaction with the ring + has terminated. This enables the client to implement kinetic scrolling. + See the wp_tablet_pad_ring.source documentation for information on + when this event may be generated. + + Any wp_tablet_pad_ring.angle events with the same source after this + event should be considered as the start of a new interaction. + </description> + </event> + + <event name="frame"> + <description summary="end of a ring event sequence"> + Indicates the end of a set of ring events that logically belong + together. A client is expected to accumulate the data in all events + within the frame before proceeding. + + All wp_tablet_pad_ring events before a wp_tablet_pad_ring.frame event belong + logically together. For example, on termination of a finger interaction + on a ring the compositor will send a wp_tablet_pad_ring.source event, + a wp_tablet_pad_ring.stop event and a wp_tablet_pad_ring.frame event. + + A wp_tablet_pad_ring.frame event is sent for every logical event + group, even if the group only contains a single wp_tablet_pad_ring + event. Specifically, a client may get a sequence: angle, frame, + angle, frame, etc. + </description> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + </event> + </interface> + + <interface name="zwp_tablet_pad_strip_v2" version="1"> + <description summary="pad strip"> + A linear interaction area, such as the strips found in Wacom Cintiq + models. + + Events on a strip are logically grouped by the wl_tablet_pad_strip.frame + event. + </description> + + <request name="set_feedback"> + <description summary="set compositor feedback"> + Requests the compositor to use the provided feedback string + associated with this strip. This request should be issued immediately + after a wp_tablet_pad_group.mode_switch event from the corresponding + group is received, or whenever the strip is mapped to a different + action. See wp_tablet_pad_group.mode_switch for more details. + + Clients are encouraged to provide context-aware descriptions for + the actions associated with the strip, and compositors may use this + information to offer visual feedback about the button layout + (eg. on-screen displays). + + The provided string 'description' is a UTF-8 encoded string to be + associated with this ring, and is considered user-visible; general + internationalization rules apply. + + The serial argument will be that of the last + wp_tablet_pad_group.mode_switch event received for the group of this + strip. Requests providing other serials than the most recent one will be + ignored. + </description> + <arg name="description" type="string" summary="strip description"/> + <arg name="serial" type="uint" summary="serial of the mode switch event"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the strip object"> + This destroys the client's resource for this strip object. + </description> + </request> + + <enum name="source"> + <description summary="strip axis source"> + Describes the source types for strip events. This indicates to the + client how a strip event was physically generated; a client may + adjust the user interface accordingly. For example, events + from a "finger" source may trigger kinetic scrolling. + </description> + <entry name="finger" value="1" summary="finger"/> + </enum> + + <event name="source"> + <description summary="strip event source"> + Source information for strip events. + + This event does not occur on its own. It is sent before a + wp_tablet_pad_strip.frame event and carries the source information + for all events within that frame. + + The source specifies how this event was generated. If the source is + wp_tablet_pad_strip.source.finger, a wp_tablet_pad_strip.stop event + will be sent when the user lifts their finger off the device. + + This event is optional. If the source is unknown for an interaction, + no event is sent. + </description> + <arg name="source" type="uint" enum="source" summary="the event source"/> + </event> + + <event name="position"> + <description summary="position changed"> + Sent whenever the position on a strip changes. + + The position is normalized to a range of [0, 65535], the 0-value + represents the top-most and/or left-most position of the strip in + the pad's current rotation. + </description> + <arg name="position" type="uint" summary="the current position"/> + </event> + + <event name="stop"> + <description summary="interaction stopped"> + Stop notification for strip events. + + For some wp_tablet_pad_strip.source types, a wp_tablet_pad_strip.stop + event is sent to notify a client that the interaction with the strip + has terminated. This enables the client to implement kinetic + scrolling. See the wp_tablet_pad_strip.source documentation for + information on when this event may be generated. + + Any wp_tablet_pad_strip.position events with the same source after this + event should be considered as the start of a new interaction. + </description> + </event> + + <event name="frame"> + <description summary="end of a strip event sequence"> + Indicates the end of a set of events that represent one logical + hardware strip event. A client is expected to accumulate the data + in all events within the frame before proceeding. + + All wp_tablet_pad_strip events before a wp_tablet_pad_strip.frame event belong + logically together. For example, on termination of a finger interaction + on a strip the compositor will send a wp_tablet_pad_strip.source event, + a wp_tablet_pad_strip.stop event and a wp_tablet_pad_strip.frame + event. + + A wp_tablet_pad_strip.frame event is sent for every logical event + group, even if the group only contains a single wp_tablet_pad_strip + event. Specifically, a client may get a sequence: position, frame, + position, frame, etc. + </description> + <arg name="time" type="uint" summary="timestamp with millisecond granularity"/> + </event> + </interface> + + <interface name="zwp_tablet_pad_group_v2" version="1"> + <description summary="a set of buttons, rings and strips"> + A pad group describes a distinct (sub)set of buttons, rings and strips + present in the tablet. The criteria of this grouping is usually positional, + eg. if a tablet has buttons on the left and right side, 2 groups will be + presented. The physical arrangement of groups is undisclosed and may + change on the fly. + + Pad groups will announce their features during pad initialization. Between + the corresponding wp_tablet_pad.group event and wp_tablet_pad_group.done, the + pad group will announce the buttons, rings and strips contained in it, + plus the number of supported modes. + + Modes are a mechanism to allow multiple groups of actions for every element + in the pad group. The number of groups and available modes in each is + persistent across device plugs. The current mode is user-switchable, it + will be announced through the wp_tablet_pad_group.mode_switch event both + whenever it is switched, and after wp_tablet_pad.enter. + + The current mode logically applies to all elements in the pad group, + although it is at clients' discretion whether to actually perform different + actions, and/or issue the respective .set_feedback requests to notify the + compositor. See the wp_tablet_pad_group.mode_switch event for more details. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the pad object"> + Destroy the wp_tablet_pad_group object. Objects created from this object + are unaffected and should be destroyed separately. + </description> + </request> + + <event name="buttons"> + <description summary="buttons announced"> + Sent on wp_tablet_pad_group initialization to announce the available + buttons in the group. Button indices start at 0, a button may only be + in one group at a time. + + This event is first sent in the initial burst of events before the + wp_tablet_pad_group.done event. + + Some buttons are reserved by the compositor. These buttons may not be + assigned to any wp_tablet_pad_group. Compositors may broadcast this + event in the case of changes to the mapping of these reserved buttons. + If the compositor happens to reserve all buttons in a group, this event + will be sent with an empty array. + </description> + <arg name="buttons" type="array" summary="buttons in this group"/> + </event> + + <event name="ring"> + <description summary="ring announced"> + Sent on wp_tablet_pad_group initialization to announce available rings. + One event is sent for each ring available on this pad group. + + This event is sent in the initial burst of events before the + wp_tablet_pad_group.done event. + </description> + <arg name="ring" type="new_id" interface="zwp_tablet_pad_ring_v2"/> + </event> + + <event name="strip"> + <description summary="strip announced"> + Sent on wp_tablet_pad initialization to announce available strips. + One event is sent for each strip available on this pad group. + + This event is sent in the initial burst of events before the + wp_tablet_pad_group.done event. + </description> + <arg name="strip" type="new_id" interface="zwp_tablet_pad_strip_v2"/> + </event> + + <event name="modes"> + <description summary="mode-switch ability announced"> + Sent on wp_tablet_pad_group initialization to announce that the pad + group may switch between modes. A client may use a mode to store a + specific configuration for buttons, rings and strips and use the + wl_tablet_pad_group.mode_switch event to toggle between these + configurations. Mode indices start at 0. + + Switching modes is compositor-dependent. See the + wp_tablet_pad_group.mode_switch event for more details. + + This event is sent in the initial burst of events before the + wp_tablet_pad_group.done event. This event is only sent when more than + more than one mode is available. + </description> + <arg name="modes" type="uint" summary="the number of modes"/> + </event> + + <event name="done"> + <description summary="tablet group description events sequence complete"> + This event is sent immediately to signal the end of the initial + burst of descriptive events. A client may consider the static + description of the tablet to be complete and finalize initialization + of the tablet group. + </description> + </event> + + <event name="mode_switch"> + <description summary="mode switch event"> + Notification that the mode was switched. + + A mode applies to all buttons, rings and strips in a group + simultaneously, but a client is not required to assign different actions + for each mode. For example, a client may have mode-specific button + mappings but map the ring to vertical scrolling in all modes. Mode + indices start at 0. + + Switching modes is compositor-dependent. The compositor may provide + visual cues to the client about the mode, e.g. by toggling LEDs on + the tablet device. Mode-switching may be software-controlled or + controlled by one or more physical buttons. For example, on a Wacom + Intuos Pro, the button inside the ring may be assigned to switch + between modes. + + The compositor will also send this event after wp_tablet_pad.enter on + each group in order to notify of the current mode. Groups that only + feature one mode will use mode=0 when emitting this event. + + If a button action in the new mode differs from the action in the + previous mode, the client should immediately issue a + wp_tablet_pad.set_feedback request for each changed button. + + If a ring or strip action in the new mode differs from the action + in the previous mode, the client should immediately issue a + wp_tablet_ring.set_feedback or wp_tablet_strip.set_feedback request + for each changed ring or strip. + </description> + <arg name="time" type="uint" summary="the time of the event with millisecond granularity"/> + <arg name="serial" type="uint"/> + <arg name="mode" type="uint" summary="the new mode of the pad"/> + </event> + </interface> + + <interface name="zwp_tablet_pad_v2" version="1"> + <description summary="a set of buttons, rings and strips"> + A pad device is a set of buttons, rings and strips + usually physically present on the tablet device itself. Some + exceptions exist where the pad device is physically detached, e.g. the + Wacom ExpressKey Remote. + + Pad devices have no axes that control the cursor and are generally + auxiliary devices to the tool devices used on the tablet surface. + + A pad device has a number of static characteristics, e.g. the number + of rings. These capabilities are sent in an event sequence after the + wp_tablet_seat.pad_added event before any actual events from this pad. + This initial event sequence is terminated by a wp_tablet_pad.done + event. + + All pad features (buttons, rings and strips) are logically divided into + groups and all pads have at least one group. The available groups are + notified through the wp_tablet_pad.group event; the compositor will + emit one event per group before emitting wp_tablet_pad.done. + + Groups may have multiple modes. Modes allow clients to map multiple + actions to a single pad feature. Only one mode can be active per group, + although different groups may have different active modes. + </description> + + <request name="set_feedback"> + <description summary="set compositor feedback"> + Requests the compositor to use the provided feedback string + associated with this button. This request should be issued immediately + after a wp_tablet_pad_group.mode_switch event from the corresponding + group is received, or whenever a button is mapped to a different + action. See wp_tablet_pad_group.mode_switch for more details. + + Clients are encouraged to provide context-aware descriptions for + the actions associated with each button, and compositors may use + this information to offer visual feedback on the button layout + (e.g. on-screen displays). + + Button indices start at 0. Setting the feedback string on a button + that is reserved by the compositor (i.e. not belonging to any + wp_tablet_pad_group) does not generate an error but the compositor + is free to ignore the request. + + The provided string 'description' is a UTF-8 encoded string to be + associated with this ring, and is considered user-visible; general + internationalization rules apply. + + The serial argument will be that of the last + wp_tablet_pad_group.mode_switch event received for the group of this + button. Requests providing other serials than the most recent one will + be ignored. + </description> + <arg name="button" type="uint" summary="button index"/> + <arg name="description" type="string" summary="button description"/> + <arg name="serial" type="uint" summary="serial of the mode switch event"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the pad object"> + Destroy the wp_tablet_pad object. Objects created from this object + are unaffected and should be destroyed separately. + </description> + </request> + + <event name="group"> + <description summary="group announced"> + Sent on wp_tablet_pad initialization to announce available groups. + One event is sent for each pad group available. + + This event is sent in the initial burst of events before the + wp_tablet_pad.done event. At least one group will be announced. + </description> + <arg name="pad_group" type="new_id" interface="zwp_tablet_pad_group_v2"/> + </event> + + <event name="path"> + <description summary="path to the device"> + A system-specific device path that indicates which device is behind + this wp_tablet_pad. This information may be used to gather additional + information about the device, e.g. through libwacom. + + The format of the path is unspecified, it may be a device node, a + sysfs path, or some other identifier. It is up to the client to + identify the string provided. + + This event is sent in the initial burst of events before the + wp_tablet_pad.done event. + </description> + <arg name="path" type="string" summary="path to local device"/> + </event> + + <event name="buttons"> + <description summary="buttons announced"> + Sent on wp_tablet_pad initialization to announce the available + buttons. + + This event is sent in the initial burst of events before the + wp_tablet_pad.done event. This event is only sent when at least one + button is available. + </description> + <arg name="buttons" type="uint" summary="the number of buttons"/> + </event> + + <event name="done"> + <description summary="pad description event sequence complete"> + This event signals the end of the initial burst of descriptive + events. A client may consider the static description of the pad to + be complete and finalize initialization of the pad. + </description> + </event> + + <enum name="button_state"> + <description summary="physical button state"> + Describes the physical state of a button that caused the button + event. + </description> + <entry name="released" value="0" summary="the button is not pressed"/> + <entry name="pressed" value="1" summary="the button is pressed"/> + </enum> + + <event name="button"> + <description summary="physical button state"> + Sent whenever the physical state of a button changes. + </description> + <arg name="time" type="uint" summary="the time of the event with millisecond granularity"/> + <arg name="button" type="uint" summary="the index of the button that changed state"/> + <arg name="state" type="uint" enum="button_state"/> + </event> + + <event name="enter"> + <description summary="enter event"> + Notification that this pad is focused on the specified surface. + </description> + <arg name="serial" type="uint" summary="serial number of the enter event"/> + <arg name="tablet" type="object" interface="zwp_tablet_v2" summary="the tablet the pad is attached to"/> + <arg name="surface" type="object" interface="wl_surface" summary="surface the pad is focused on"/> + </event> + + <event name="leave"> + <description summary="enter event"> + Notification that this pad is no longer focused on the specified + surface. + </description> + <arg name="serial" type="uint" summary="serial number of the leave event"/> + <arg name="surface" type="object" interface="wl_surface" summary="surface the pad is no longer focused on"/> + </event> + + <event name="removed"> + <description summary="pad removed event"> + Sent when the pad has been removed from the system. When a tablet + is removed its pad(s) will be removed too. + + When this event is received, the client must destroy all rings, strips + and groups that were offered by this pad, and issue wp_tablet_pad.destroy + the pad itself. + </description> + </event> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/text-input/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/text-input/README new file mode 100644 index 0000000..afa4bac --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/text-input/README @@ -0,0 +1,4 @@ +Text input protocol + +Maintainers: +Jan Arne Petersen <janarne@gmail.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/text-input/text-input-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/text-input/text-input-unstable-v1.xml new file mode 100644 index 0000000..29a217e --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/text-input/text-input-unstable-v1.xml @@ -0,0 +1,385 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="text_input_unstable_v1"> + + <copyright> + Copyright © 2012, 2013 Intel Corporation + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="zwp_text_input_v1" version="1"> + <description summary="text input"> + An object used for text input. Adds support for text input and input + methods to applications. A text_input object is created from a + wl_text_input_manager and corresponds typically to a text entry in an + application. + + Requests are used to activate/deactivate the text_input object and set + state information like surrounding and selected text or the content type. + The information about entered text is sent to the text_input object via + the pre-edit and commit events. Using this interface removes the need + for applications to directly process hardware key events and compose text + out of them. + + Text is generally UTF-8 encoded, indices and lengths are in bytes. + + Serials are used to synchronize the state between the text input and + an input method. New serials are sent by the text input in the + commit_state request and are used by the input method to indicate + the known text input state in events like preedit_string, commit_string, + and keysym. The text input can then ignore events from the input method + which are based on an outdated state (for example after a reset). + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <request name="activate"> + <description summary="request activation"> + Requests the text_input object to be activated (typically when the + text entry gets focus). + + The seat argument is a wl_seat which maintains the focus for this + activation. The surface argument is a wl_surface assigned to the + text_input object and tracked for focus lost. The enter event + is emitted on successful activation. + </description> + <arg name="seat" type="object" interface="wl_seat"/> + <arg name="surface" type="object" interface="wl_surface"/> + </request> + + <request name="deactivate"> + <description summary="request deactivation"> + Requests the text_input object to be deactivated (typically when the + text entry lost focus). The seat argument is a wl_seat which was used + for activation. + </description> + <arg name="seat" type="object" interface="wl_seat"/> + </request> + + <request name="show_input_panel"> + <description summary="show input panels"> + Requests input panels (virtual keyboard) to show. + </description> + </request> + + <request name="hide_input_panel"> + <description summary="hide input panels"> + Requests input panels (virtual keyboard) to hide. + </description> + </request> + + <request name="reset"> + <description summary="reset"> + Should be called by an editor widget when the input state should be + reset, for example after the text was changed outside of the normal + input method flow. + </description> + </request> + + <request name="set_surrounding_text"> + <description summary="sets the surrounding text"> + Sets the plain surrounding text around the input position. Text is + UTF-8 encoded. Cursor is the byte offset within the + surrounding text. Anchor is the byte offset of the + selection anchor within the surrounding text. If there is no selected + text anchor, then it is the same as cursor. + </description> + <arg name="text" type="string"/> + <arg name="cursor" type="uint"/> + <arg name="anchor" type="uint"/> + </request> + + <enum name="content_hint"> + <description summary="content hint"> + Content hint is a bitmask to allow to modify the behavior of the text + input. + </description> + <entry name="none" value="0x0" summary="no special behaviour"/> + <entry name="default" value="0x7" summary="auto completion, correction and capitalization"/> + <entry name="password" value="0xc0" summary="hidden and sensitive text"/> + <entry name="auto_completion" value="0x1" summary="suggest word completions"/> + <entry name="auto_correction" value="0x2" summary="suggest word corrections"/> + <entry name="auto_capitalization" value="0x4" summary="switch to uppercase letters at the start of a sentence"/> + <entry name="lowercase" value="0x8" summary="prefer lowercase letters"/> + <entry name="uppercase" value="0x10" summary="prefer uppercase letters"/> + <entry name="titlecase" value="0x20" summary="prefer casing for titles and headings (can be language dependent)"/> + <entry name="hidden_text" value="0x40" summary="characters should be hidden"/> + <entry name="sensitive_data" value="0x80" summary="typed text should not be stored"/> + <entry name="latin" value="0x100" summary="just latin characters should be entered"/> + <entry name="multiline" value="0x200" summary="the text input is multiline"/> + </enum> + + <enum name="content_purpose"> + <description summary="content purpose"> + The content purpose allows to specify the primary purpose of a text + input. + + This allows an input method to show special purpose input panels with + extra characters or to disallow some characters. + </description> + <entry name="normal" value="0" summary="default input, allowing all characters"/> + <entry name="alpha" value="1" summary="allow only alphabetic characters"/> + <entry name="digits" value="2" summary="allow only digits"/> + <entry name="number" value="3" summary="input a number (including decimal separator and sign)"/> + <entry name="phone" value="4" summary="input a phone number"/> + <entry name="url" value="5" summary="input an URL"/> + <entry name="email" value="6" summary="input an email address"/> + <entry name="name" value="7" summary="input a name of a person"/> + <entry name="password" value="8" summary="input a password (combine with password or sensitive_data hint)"/> + <entry name="date" value="9" summary="input a date"/> + <entry name="time" value="10" summary="input a time"/> + <entry name="datetime" value="11" summary="input a date and time"/> + <entry name="terminal" value="12" summary="input for a terminal"/> + </enum> + + <request name="set_content_type"> + <description summary="set content purpose and hint"> + Sets the content purpose and content hint. While the purpose is the + basic purpose of an input field, the hint flags allow to modify some + of the behavior. + + When no content type is explicitly set, a normal content purpose with + default hints (auto completion, auto correction, auto capitalization) + should be assumed. + </description> + <arg name="hint" type="uint"/> + <arg name="purpose" type="uint"/> + </request> + + <request name="set_cursor_rectangle"> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="set_preferred_language"> + <description summary="sets preferred language"> + Sets a specific language. This allows for example a virtual keyboard to + show a language specific layout. The "language" argument is an RFC-3066 + format language tag. + + It could be used for example in a word processor to indicate the + language of the currently edited document or in an instant message + application which tracks languages of contacts. + </description> + <arg name="language" type="string"/> + </request> + + <request name="commit_state"> + <arg name="serial" type="uint" summary="used to identify the known state"/> + </request> + + <request name="invoke_action"> + <arg name="button" type="uint"/> + <arg name="index" type="uint"/> + </request> + + <event name="enter"> + <description summary="enter event"> + Notify the text_input object when it received focus. Typically in + response to an activate request. + </description> + <arg name="surface" type="object" interface="wl_surface"/> + </event> + + <event name="leave"> + <description summary="leave event"> + Notify the text_input object when it lost focus. Either in response + to a deactivate request or when the assigned surface lost focus or was + destroyed. + </description> + </event> + + <event name="modifiers_map"> + <description summary="modifiers map"> + Transfer an array of 0-terminated modifier names. The position in + the array is the index of the modifier as used in the modifiers + bitmask in the keysym event. + </description> + <arg name="map" type="array"/> + </event> + + <event name="input_panel_state"> + <description summary="state of the input panel"> + Notify when the visibility state of the input panel changed. + </description> + <arg name="state" type="uint"/> + </event> + + <event name="preedit_string"> + <description summary="pre-edit"> + Notify when a new composing text (pre-edit) should be set around the + current cursor position. Any previously set composing text should + be removed. + + The commit text can be used to replace the preedit text on reset + (for example on unfocus). + + The text input should also handle all preedit_style and preedit_cursor + events occurring directly before preedit_string. + </description> + <arg name="serial" type="uint" summary="serial of the latest known text input state"/> + <arg name="text" type="string"/> + <arg name="commit" type="string"/> + </event> + + <enum name="preedit_style"> + <entry name="default" value="0" summary="default style for composing text"/> + <entry name="none" value="1" summary="style should be the same as in non-composing text"/> + <entry name="active" value="2"/> + <entry name="inactive" value="3"/> + <entry name="highlight" value="4"/> + <entry name="underline" value="5"/> + <entry name="selection" value="6"/> + <entry name="incorrect" value="7"/> + </enum> + + <event name="preedit_styling"> + <description summary="pre-edit styling"> + Sets styling information on composing text. The style is applied for + length bytes from index relative to the beginning of the composing + text (as byte offset). Multiple styles can + be applied to a composing text by sending multiple preedit_styling + events. + + This event is handled as part of a following preedit_string event. + </description> + <arg name="index" type="uint"/> + <arg name="length" type="uint"/> + <arg name="style" type="uint"/> + </event> + + <event name="preedit_cursor"> + <description summary="pre-edit cursor"> + Sets the cursor position inside the composing text (as byte + offset) relative to the start of the composing text. When index is a + negative number no cursor is shown. + + This event is handled as part of a following preedit_string event. + </description> + <arg name="index" type="int"/> + </event> + + <event name="commit_string"> + <description summary="commit"> + Notify when text should be inserted into the editor widget. The text to + commit could be either just a single character after a key press or the + result of some composing (pre-edit). It could also be an empty text + when some text should be removed (see delete_surrounding_text) or when + the input cursor should be moved (see cursor_position). + + Any previously set composing text should be removed. + </description> + <arg name="serial" type="uint" summary="serial of the latest known text input state"/> + <arg name="text" type="string"/> + </event> + + <event name="cursor_position"> + <description summary="set cursor to new position"> + Notify when the cursor or anchor position should be modified. + + This event should be handled as part of a following commit_string + event. + </description> + <arg name="index" type="int"/> + <arg name="anchor" type="int"/> + </event> + + <event name="delete_surrounding_text"> + <description summary="delete surrounding text"> + Notify when the text around the current cursor position should be + deleted. + + Index is relative to the current cursor (in bytes). + Length is the length of deleted text (in bytes). + + This event should be handled as part of a following commit_string + event. + </description> + <arg name="index" type="int"/> + <arg name="length" type="uint"/> + </event> + + <event name="keysym"> + <description summary="keysym"> + Notify when a key event was sent. Key events should not be used + for normal text input operations, which should be done with + commit_string, delete_surrounding_text, etc. The key event follows + the wl_keyboard key event convention. Sym is an XKB keysym, state a + wl_keyboard key_state. Modifiers are a mask for effective modifiers + (where the modifier indices are set by the modifiers_map event) + </description> + <arg name="serial" type="uint" summary="serial of the latest known text input state"/> + <arg name="time" type="uint"/> + <arg name="sym" type="uint"/> + <arg name="state" type="uint"/> + <arg name="modifiers" type="uint"/> + </event> + + <event name="language"> + <description summary="language"> + Sets the language of the input text. The "language" argument is an + RFC-3066 format language tag. + </description> + <arg name="serial" type="uint" summary="serial of the latest known text input state"/> + <arg name="language" type="string"/> + </event> + + <enum name="text_direction"> + <entry name="auto" value="0" summary="automatic text direction based on text and language"/> + <entry name="ltr" value="1" summary="left-to-right"/> + <entry name="rtl" value="2" summary="right-to-left"/> + </enum> + + <event name="text_direction"> + <description summary="text direction"> + Sets the text direction of input text. + + It is mainly needed for showing an input cursor on the correct side of + the editor when there is no input done yet and making sure neutral + direction text is laid out properly. + </description> + <arg name="serial" type="uint" summary="serial of the latest known text input state"/> + <arg name="direction" type="uint"/> + </event> + </interface> + + <interface name="zwp_text_input_manager_v1" version="1"> + <description summary="text input manager"> + A factory for text_input objects. This object is a global singleton. + </description> + + <request name="create_text_input"> + <description summary="create text input"> + Creates a new text_input object. + </description> + <arg name="id" type="new_id" interface="zwp_text_input_v1"/> + </request> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/text-input/text-input-unstable-v3.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/text-input/text-input-unstable-v3.xml new file mode 100644 index 0000000..8b710fd --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/text-input/text-input-unstable-v3.xml @@ -0,0 +1,441 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<protocol name="text_input_unstable_v3"> + <copyright> + Copyright © 2012, 2013 Intel Corporation + Copyright © 2015, 2016 Jan Arne Petersen + Copyright © 2017, 2018 Red Hat, Inc. + Copyright © 2018 Purism SPC + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + the copyright holders not be used in advertising or publicity + pertaining to distribution of the software without specific, + written prior permission. The copyright holders make no + representations about the suitability of this software for any + purpose. It is provided "as is" without express or implied + warranty. + + THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + THIS SOFTWARE. + </copyright> + + <description summary="Protocol for composing text"> + This protocol allows compositors to act as input methods and to send text + to applications. A text input object is used to manage state of what are + typically text entry fields in the application. + + This document adheres to the RFC 2119 when using words like "must", + "should", "may", etc. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <interface name="zwp_text_input_v3" version="1"> + <description summary="text input"> + The zwp_text_input_v3 interface represents text input and input methods + associated with a seat. It provides enter/leave events to follow the + text input focus for a seat. + + Requests are used to enable/disable the text-input object and set + state information like surrounding and selected text or the content type. + The information about the entered text is sent to the text-input object + via the preedit_string and commit_string events. + + Text is valid UTF-8 encoded, indices and lengths are in bytes. Indices + must not point to middle bytes inside a code point: they must either + point to the first byte of a code point or to the end of the buffer. + Lengths must be measured between two valid indices. + + Focus moving throughout surfaces will result in the emission of + zwp_text_input_v3.enter and zwp_text_input_v3.leave events. The focused + surface must commit zwp_text_input_v3.enable and + zwp_text_input_v3.disable requests as the keyboard focus moves across + editable and non-editable elements of the UI. Those two requests are not + expected to be paired with each other, the compositor must be able to + handle consecutive series of the same request. + + State is sent by the state requests (set_surrounding_text, + set_content_type and set_cursor_rectangle) and a commit request. After an + enter event or disable request all state information is invalidated and + needs to be resent by the client. + </description> + + <request name="destroy" type="destructor"> + <description summary="Destroy the wp_text_input"> + Destroy the wp_text_input object. Also disables all surfaces enabled + through this wp_text_input object. + </description> + </request> + + <request name="enable"> + <description summary="Request text input to be enabled"> + Requests text input on the surface previously obtained from the enter + event. + + This request must be issued every time the active text input changes + to a new one, including within the current surface. Use + zwp_text_input_v3.disable when there is no longer any input focus on + the current surface. + + This request resets all state associated with previous enable, disable, + set_surrounding_text, set_text_change_cause, set_content_type, and + set_cursor_rectangle requests, as well as the state associated with + preedit_string, commit_string, and delete_surrounding_text events. + + The set_surrounding_text, set_content_type and set_cursor_rectangle + requests must follow if the text input supports the necessary + functionality. + + State set with this request is double-buffered. It will get applied on + the next zwp_text_input_v3.commit request, and stay valid until the + next committed enable or disable request. + + The changes must be applied by the compositor after issuing a + zwp_text_input_v3.commit request. + </description> + </request> + + <request name="disable"> + <description summary="Disable text input on a surface"> + Explicitly disable text input on the current surface (typically when + there is no focus on any text entry inside the surface). + + State set with this request is double-buffered. It will get applied on + the next zwp_text_input_v3.commit request. + </description> + </request> + + <request name="set_surrounding_text"> + <description summary="sets the surrounding text"> + Sets the surrounding plain text around the input, excluding the preedit + text. + + The client should notify the compositor of any changes in any of the + values carried with this request, including changes caused by handling + incoming text-input events as well as changes caused by other + mechanisms like keyboard typing. + + If the client is unaware of the text around the cursor, it should not + issue this request, to signify lack of support to the compositor. + + Text is UTF-8 encoded, and should include the cursor position, the + complete selection and additional characters before and after them. + There is a maximum length of wayland messages, so text can not be + longer than 4000 bytes. + + Cursor is the byte offset of the cursor within text buffer. + + Anchor is the byte offset of the selection anchor within text buffer. + If there is no selected text, anchor is the same as cursor. + + If any preedit text is present, it is replaced with a cursor for the + purpose of this event. + + Values set with this request are double-buffered. They will get applied + on the next zwp_text_input_v3.commit request, and stay valid until the + next committed enable or disable request. + + The initial state for affected fields is empty, meaning that the text + input does not support sending surrounding text. If the empty values + get applied, subsequent attempts to change them may have no effect. + </description> + <arg name="text" type="string"/> + <arg name="cursor" type="int"/> + <arg name="anchor" type="int"/> + </request> + + <enum name="change_cause"> + <description summary="text change reason"> + Reason for the change of surrounding text or cursor posision. + </description> + <entry name="input_method" value="0" summary="input method caused the change"/> + <entry name="other" value="1" summary="something else than the input method caused the change"/> + </enum> + + <request name="set_text_change_cause"> + <description summary="indicates the cause of surrounding text change"> + Tells the compositor why the text surrounding the cursor changed. + + Whenever the client detects an external change in text, cursor, or + anchor posision, it must issue this request to the compositor. This + request is intended to give the input method a chance to update the + preedit text in an appropriate way, e.g. by removing it when the user + starts typing with a keyboard. + + cause describes the source of the change. + + The value set with this request is double-buffered. It must be applied + and reset to initial at the next zwp_text_input_v3.commit request. + + The initial value of cause is input_method. + </description> + <arg name="cause" type="uint" enum="change_cause"/> + </request> + + <enum name="content_hint" bitfield="true"> + <description summary="content hint"> + Content hint is a bitmask to allow to modify the behavior of the text + input. + </description> + <entry name="none" value="0x0" summary="no special behavior"/> + <entry name="completion" value="0x1" summary="suggest word completions"/> + <entry name="spellcheck" value="0x2" summary="suggest word corrections"/> + <entry name="auto_capitalization" value="0x4" summary="switch to uppercase letters at the start of a sentence"/> + <entry name="lowercase" value="0x8" summary="prefer lowercase letters"/> + <entry name="uppercase" value="0x10" summary="prefer uppercase letters"/> + <entry name="titlecase" value="0x20" summary="prefer casing for titles and headings (can be language dependent)"/> + <entry name="hidden_text" value="0x40" summary="characters should be hidden"/> + <entry name="sensitive_data" value="0x80" summary="typed text should not be stored"/> + <entry name="latin" value="0x100" summary="just Latin characters should be entered"/> + <entry name="multiline" value="0x200" summary="the text input is multiline"/> + </enum> + + <enum name="content_purpose"> + <description summary="content purpose"> + The content purpose allows to specify the primary purpose of a text + input. + + This allows an input method to show special purpose input panels with + extra characters or to disallow some characters. + </description> + <entry name="normal" value="0" summary="default input, allowing all characters"/> + <entry name="alpha" value="1" summary="allow only alphabetic characters"/> + <entry name="digits" value="2" summary="allow only digits"/> + <entry name="number" value="3" summary="input a number (including decimal separator and sign)"/> + <entry name="phone" value="4" summary="input a phone number"/> + <entry name="url" value="5" summary="input an URL"/> + <entry name="email" value="6" summary="input an email address"/> + <entry name="name" value="7" summary="input a name of a person"/> + <entry name="password" value="8" summary="input a password (combine with sensitive_data hint)"/> + <entry name="pin" value="9" summary="input is a numeric password (combine with sensitive_data hint)"/> + <entry name="date" value="10" summary="input a date"/> + <entry name="time" value="11" summary="input a time"/> + <entry name="datetime" value="12" summary="input a date and time"/> + <entry name="terminal" value="13" summary="input for a terminal"/> + </enum> + + <request name="set_content_type"> + <description summary="set content purpose and hint"> + Sets the content purpose and content hint. While the purpose is the + basic purpose of an input field, the hint flags allow to modify some of + the behavior. + + Values set with this request are double-buffered. They will get applied + on the next zwp_text_input_v3.commit request. + Subsequent attempts to update them may have no effect. The values + remain valid until the next committed enable or disable request. + + The initial value for hint is none, and the initial value for purpose + is normal. + </description> + <arg name="hint" type="uint" enum="content_hint"/> + <arg name="purpose" type="uint" enum="content_purpose"/> + </request> + + <request name="set_cursor_rectangle"> + <description summary="set cursor position"> + Marks an area around the cursor as a x, y, width, height rectangle in + surface local coordinates. + + Allows the compositor to put a window with word suggestions near the + cursor, without obstructing the text being input. + + If the client is unaware of the position of edited text, it should not + issue this request, to signify lack of support to the compositor. + + Values set with this request are double-buffered. They will get applied + on the next zwp_text_input_v3.commit request, and stay valid until the + next committed enable or disable request. + + The initial values describing a cursor rectangle are empty. That means + the text input does not support describing the cursor area. If the + empty values get applied, subsequent attempts to change them may have + no effect. + </description> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="commit"> + <description summary="commit state"> + Atomically applies state changes recently sent to the compositor. + + The commit request establishes and updates the state of the client, and + must be issued after any changes to apply them. + + Text input state (enabled status, content purpose, content hint, + surrounding text and change cause, cursor rectangle) is conceptually + double-buffered within the context of a text input, i.e. between a + committed enable request and the following committed enable or disable + request. + + Protocol requests modify the pending state, as opposed to the current + state in use by the input method. A commit request atomically applies + all pending state, replacing the current state. After commit, the new + pending state is as documented for each related request. + + Requests are applied in the order of arrival. + + Neither current nor pending state are modified unless noted otherwise. + + The compositor must count the number of commit requests coming from + each zwp_text_input_v3 object and use the count as the serial in done + events. + </description> + </request> + + <event name="enter"> + <description summary="enter event"> + Notification that this seat's text-input focus is on a certain surface. + + When the seat has the keyboard capability the text-input focus follows + the keyboard focus. This event sets the current surface for the + text-input object. + </description> + <arg name="surface" type="object" interface="wl_surface"/> + </event> + + <event name="leave"> + <description summary="leave event"> + Notification that this seat's text-input focus is no longer on a + certain surface. The client should reset any preedit string previously + set. + + The leave notification clears the current surface. It is sent before + the enter notification for the new focus. + + When the seat has the keyboard capability the text-input focus follows + the keyboard focus. + </description> + <arg name="surface" type="object" interface="wl_surface"/> + </event> + + <event name="preedit_string"> + <description summary="pre-edit"> + Notify when a new composing text (pre-edit) should be set at the + current cursor position. Any previously set composing text must be + removed. Any previously existing selected text must be removed. + + The argument text contains the pre-edit string buffer. + + The parameters cursor_begin and cursor_end are counted in bytes + relative to the beginning of the submitted text buffer. Cursor should + be hidden when both are equal to -1. + + They could be represented by the client as a line if both values are + the same, or as a text highlight otherwise. + + Values set with this event are double-buffered. They must be applied + and reset to initial on the next zwp_text_input_v3.done event. + + The initial value of text is an empty string, and cursor_begin, + cursor_end and cursor_hidden are all 0. + </description> + <arg name="text" type="string" allow-null="true"/> + <arg name="cursor_begin" type="int"/> + <arg name="cursor_end" type="int"/> + </event> + + <event name="commit_string"> + <description summary="text commit"> + Notify when text should be inserted into the editor widget. The text to + commit could be either just a single character after a key press or the + result of some composing (pre-edit). + + Values set with this event are double-buffered. They must be applied + and reset to initial on the next zwp_text_input_v3.done event. + + The initial value of text is an empty string. + </description> + <arg name="text" type="string" allow-null="true"/> + </event> + + <event name="delete_surrounding_text"> + <description summary="delete surrounding text"> + Notify when the text around the current cursor position should be + deleted. + + Before_length and after_length are the number of bytes before and after + the current cursor index (excluding the selection) to delete. + + If a preedit text is present, in effect before_length is counted from + the beginning of it, and after_length from its end (see done event + sequence). + + Values set with this event are double-buffered. They must be applied + and reset to initial on the next zwp_text_input_v3.done event. + + The initial values of both before_length and after_length are 0. + </description> + <arg name="before_length" type="uint" summary="length of text before current cursor position"/> + <arg name="after_length" type="uint" summary="length of text after current cursor position"/> + </event> + + <event name="done"> + <description summary="apply changes"> + Instruct the application to apply changes to state requested by the + preedit_string, commit_string and delete_surrounding_text events. The + state relating to these events is double-buffered, and each one + modifies the pending state. This event replaces the current state with + the pending state. + + The application must proceed by evaluating the changes in the following + order: + + 1. Replace existing preedit string with the cursor. + 2. Delete requested surrounding text. + 3. Insert commit string with the cursor at its end. + 4. Calculate surrounding text to send. + 5. Insert new preedit text in cursor position. + 6. Place cursor inside preedit text. + + The serial number reflects the last state of the zwp_text_input_v3 + object known to the compositor. The value of the serial argument must + be equal to the number of commit requests already issued on that object. + When the client receives a done event with a serial different than the + number of past commit requests, it must proceed as normal, except it + should not change the current state of the zwp_text_input_v3 object. + </description> + <arg name="serial" type="uint"/> + </event> + </interface> + + <interface name="zwp_text_input_manager_v3" version="1"> + <description summary="text input manager"> + A factory for text-input objects. This object is a global singleton. + </description> + + <request name="destroy" type="destructor"> + <description summary="Destroy the wp_text_input_manager"> + Destroy the wp_text_input_manager object. + </description> + </request> + + <request name="get_text_input"> + <description summary="create a new text input object"> + Creates a new text-input object for a given seat. + </description> + <arg name="id" type="new_id" interface="zwp_text_input_v3"/> + <arg name="seat" type="object" interface="wl_seat"/> + </request> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-decoration/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-decoration/README new file mode 100644 index 0000000..73f0c52 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-decoration/README @@ -0,0 +1,4 @@ +xdg_decoration protocol + +Maintainers: +Simon Ser <contact@emersion.fr> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml new file mode 100644 index 0000000..378e8ff --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="xdg_decoration_unstable_v1"> + <copyright> + Copyright © 2018 Simon Ser + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="zxdg_decoration_manager_v1" version="1"> + <description summary="window decoration manager"> + This interface allows a compositor to announce support for server-side + decorations. + + A window decoration is a set of window controls as deemed appropriate by + the party managing them, such as user interface components used to move, + resize and change a window's state. + + A client can use this protocol to request being decorated by a supporting + compositor. + + If compositor and client do not negotiate the use of a server-side + decoration using this protocol, clients continue to self-decorate as they + see fit. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the decoration manager object"> + Destroy the decoration manager. This doesn't destroy objects created + with the manager. + </description> + </request> + + <request name="get_toplevel_decoration"> + <description summary="create a new toplevel decoration object"> + Create a new decoration object associated with the given toplevel. + + Creating an xdg_toplevel_decoration from an xdg_toplevel which has a + buffer attached or committed is a client error, and any attempts by a + client to attach or manipulate a buffer prior to the first + xdg_toplevel_decoration.configure event must also be treated as + errors. + </description> + <arg name="id" type="new_id" interface="zxdg_toplevel_decoration_v1"/> + <arg name="toplevel" type="object" interface="xdg_toplevel"/> + </request> + </interface> + + <interface name="zxdg_toplevel_decoration_v1" version="1"> + <description summary="decoration object for a toplevel surface"> + The decoration object allows the compositor to toggle server-side window + decorations for a toplevel surface. The client can request to switch to + another mode. + + The xdg_toplevel_decoration object must be destroyed before its + xdg_toplevel. + </description> + + <enum name="error"> + <entry name="unconfigured_buffer" value="0" + summary="xdg_toplevel has a buffer attached before configure"/> + <entry name="already_constructed" value="1" + summary="xdg_toplevel already has a decoration object"/> + <entry name="orphaned" value="2" + summary="xdg_toplevel destroyed before the decoration object"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="destroy the decoration object"> + Switch back to a mode without any server-side decorations at the next + commit. + </description> + </request> + + <enum name="mode"> + <description summary="window decoration modes"> + These values describe window decoration modes. + </description> + <entry name="client_side" value="1" + summary="no server-side window decoration"/> + <entry name="server_side" value="2" + summary="server-side window decoration"/> + </enum> + + <request name="set_mode"> + <description summary="set the decoration mode"> + Set the toplevel surface decoration mode. This informs the compositor + that the client prefers the provided decoration mode. + + After requesting a decoration mode, the compositor will respond by + emitting a xdg_surface.configure event. The client should then update + its content, drawing it without decorations if the received mode is + server-side decorations. The client must also acknowledge the configure + when committing the new content (see xdg_surface.ack_configure). + + The compositor can decide not to use the client's mode and enforce a + different mode instead. + + Clients whose decoration mode depend on the xdg_toplevel state may send + a set_mode request in response to a xdg_surface.configure event and wait + for the next xdg_surface.configure event to prevent unwanted state. + Such clients are responsible for preventing configure loops and must + make sure not to send multiple successive set_mode requests with the + same decoration mode. + </description> + <arg name="mode" type="uint" enum="mode" summary="the decoration mode"/> + </request> + + <request name="unset_mode"> + <description summary="unset the decoration mode"> + Unset the toplevel surface decoration mode. This informs the compositor + that the client doesn't prefer a particular decoration mode. + + This request has the same semantics as set_mode. + </description> + </request> + + <event name="configure"> + <description summary="suggest a surface change"> + The configure event asks the client to change its decoration mode. The + configured state should not be applied immediately. Clients must send an + ack_configure in response to this event. See xdg_surface.configure and + xdg_surface.ack_configure for details. + + A configure event can be sent at any time. The specified mode must be + obeyed by the client. + </description> + <arg name="mode" type="uint" enum="mode" summary="the decoration mode"/> + </event> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-foreign/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-foreign/README new file mode 100644 index 0000000..f5bcb83 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-foreign/README @@ -0,0 +1,4 @@ +xdg foreign protocol + +Maintainers: +Jonas Ådahl <jadahl@gmail.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml new file mode 100644 index 0000000..062b090 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="xdg_foreign_unstable_v1"> + + <copyright> + Copyright © 2015-2016 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="Protocol for exporting xdg surface handles"> + This protocol specifies a way for making it possible to reference a surface + of a different client. With such a reference, a client can, by using the + interfaces provided by this protocol, manipulate the relationship between + its own surfaces and the surface of some other client. For example, stack + some of its own surface above the other clients surface. + + In order for a client A to get a reference of a surface of client B, client + B must first export its surface using xdg_exporter.export. Upon doing this, + client B will receive a handle (a unique string) that it may share with + client A in some way (for example D-Bus). After client A has received the + handle from client B, it may use xdg_importer.import to create a reference + to the surface client B just exported. See the corresponding requests for + details. + + A possible use case for this is out-of-process dialogs. For example when a + sandboxed client without file system access needs the user to select a file + on the file system, given sandbox environment support, it can export its + surface, passing the exported surface handle to an unsandboxed process that + can show a file browser dialog and stack it above the sandboxed client's + surface. + + Warning! The protocol described in this file is experimental and backward + incompatible changes may be made. Backward compatible changes may be added + together with the corresponding interface version bump. Backward + incompatible changes are done by bumping the version number in the protocol + and interface names and resetting the interface version. Once the protocol + is to be declared stable, the 'z' prefix and the version number in the + protocol and interface names are removed and the interface version number is + reset. + </description> + + <interface name="zxdg_exporter_v1" version="1"> + <description summary="interface for exporting surfaces"> + A global interface used for exporting surfaces that can later be imported + using xdg_importer. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_exporter object"> + Notify the compositor that the xdg_exporter object will no longer be + used. + </description> + </request> + + <request name="export"> + <description summary="export a surface"> + The export request exports the passed surface so that it can later be + imported via xdg_importer. When called, a new xdg_exported object will + be created and xdg_exported.handle will be sent immediately. See the + corresponding interface and event for details. + + A surface may be exported multiple times, and each exported handle may + be used to create a xdg_imported multiple times. Only xdg_surface + surfaces may be exported. + </description> + <arg name="id" type="new_id" interface="zxdg_exported_v1" + summary="the new xdg_exported object"/> + <arg name="surface" type="object" interface="wl_surface" + summary="the surface to export"/> + </request> + </interface> + + <interface name="zxdg_importer_v1" version="1"> + <description summary="interface for importing surfaces"> + A global interface used for importing surfaces exported by xdg_exporter. + With this interface, a client can create a reference to a surface of + another client. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_importer object"> + Notify the compositor that the xdg_importer object will no longer be + used. + </description> + </request> + + <request name="import"> + <description summary="import a surface"> + The import request imports a surface from any client given a handle + retrieved by exporting said surface using xdg_exporter.export. When + called, a new xdg_imported object will be created. This new object + represents the imported surface, and the importing client can + manipulate its relationship using it. See xdg_imported for details. + </description> + <arg name="id" type="new_id" interface="zxdg_imported_v1" + summary="the new xdg_imported object"/> + <arg name="handle" type="string" + summary="the exported surface handle"/> + </request> + </interface> + + <interface name="zxdg_exported_v1" version="1"> + <description summary="an exported surface handle"> + A xdg_exported object represents an exported reference to a surface. The + exported surface may be referenced as long as the xdg_exported object not + destroyed. Destroying the xdg_exported invalidates any relationship the + importer may have established using xdg_imported. + </description> + + <request name="destroy" type="destructor"> + <description summary="unexport the exported surface"> + Revoke the previously exported surface. This invalidates any + relationship the importer may have set up using the xdg_imported created + given the handle sent via xdg_exported.handle. + </description> + </request> + + <event name="handle"> + <description summary="the exported surface handle"> + The handle event contains the unique handle of this exported surface + reference. It may be shared with any client, which then can use it to + import the surface by calling xdg_importer.import. A handle may be + used to import the surface multiple times. + </description> + <arg name="handle" type="string" summary="the exported surface handle"/> + </event> + </interface> + + <interface name="zxdg_imported_v1" version="1"> + <description summary="an imported surface handle"> + A xdg_imported object represents an imported reference to surface exported + by some client. A client can use this interface to manipulate + relationships between its own surfaces and the imported surface. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_imported object"> + Notify the compositor that it will no longer use the xdg_imported + object. Any relationship that may have been set up will at this point + be invalidated. + </description> + </request> + + <request name="set_parent_of"> + <description summary="set as the parent of some surface"> + Set the imported surface as the parent of some surface of the client. + The passed surface must be a toplevel xdg_surface. Calling this function + sets up a surface to surface relation with the same stacking and positioning + semantics as xdg_surface.set_parent. + </description> + <arg name="surface" type="object" interface="wl_surface" + summary="the child surface"/> + </request> + + <event name="destroyed"> + <description summary="the imported surface handle has been destroyed"> + The imported surface handle has been destroyed and any relationship set + up has been invalidated. This may happen for various reasons, for + example if the exported surface or the exported surface handle has been + destroyed, if the handle used for importing was invalid. + </description> + </event> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml new file mode 100644 index 0000000..bf46fa8 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="xdg_foreign_unstable_v2"> + + <copyright> + Copyright © 2015-2016 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="Protocol for exporting xdg surface handles"> + This protocol specifies a way for making it possible to reference a surface + of a different client. With such a reference, a client can, by using the + interfaces provided by this protocol, manipulate the relationship between + its own surfaces and the surface of some other client. For example, stack + some of its own surface above the other clients surface. + + In order for a client A to get a reference of a surface of client B, client + B must first export its surface using xdg_exporter.export_toplevel. Upon + doing this, client B will receive a handle (a unique string) that it may + share with client A in some way (for example D-Bus). After client A has + received the handle from client B, it may use xdg_importer.import_toplevel + to create a reference to the surface client B just exported. See the + corresponding requests for details. + + A possible use case for this is out-of-process dialogs. For example when a + sandboxed client without file system access needs the user to select a file + on the file system, given sandbox environment support, it can export its + surface, passing the exported surface handle to an unsandboxed process that + can show a file browser dialog and stack it above the sandboxed client's + surface. + + Warning! The protocol described in this file is experimental and backward + incompatible changes may be made. Backward compatible changes may be added + together with the corresponding interface version bump. Backward + incompatible changes are done by bumping the version number in the protocol + and interface names and resetting the interface version. Once the protocol + is to be declared stable, the 'z' prefix and the version number in the + protocol and interface names are removed and the interface version number is + reset. + </description> + + <interface name="zxdg_exporter_v2" version="1"> + <description summary="interface for exporting surfaces"> + A global interface used for exporting surfaces that can later be imported + using xdg_importer. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_exporter object"> + Notify the compositor that the xdg_exporter object will no longer be + used. + </description> + </request> + + <request name="export_toplevel"> + <description summary="export a toplevel surface"> + The export_toplevel request exports the passed surface so that it can later be + imported via xdg_importer. When called, a new xdg_exported object will + be created and xdg_exported.handle will be sent immediately. See the + corresponding interface and event for details. + + A surface may be exported multiple times, and each exported handle may + be used to create a xdg_imported multiple times. Only xdg_toplevel + equivalent surfaces may be exported. + </description> + <arg name="id" type="new_id" interface="zxdg_exported_v2" + summary="the new xdg_exported object"/> + <arg name="surface" type="object" interface="wl_surface" + summary="the surface to export"/> + </request> + </interface> + + <interface name="zxdg_importer_v2" version="1"> + <description summary="interface for importing surfaces"> + A global interface used for importing surfaces exported by xdg_exporter. + With this interface, a client can create a reference to a surface of + another client. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_importer object"> + Notify the compositor that the xdg_importer object will no longer be + used. + </description> + </request> + + <request name="import_toplevel"> + <description summary="import a toplevel surface"> + The import_toplevel request imports a surface from any client given a handle + retrieved by exporting said surface using xdg_exporter.export_toplevel. + When called, a new xdg_imported object will be created. This new object + represents the imported surface, and the importing client can + manipulate its relationship using it. See xdg_imported for details. + </description> + <arg name="id" type="new_id" interface="zxdg_imported_v2" + summary="the new xdg_imported object"/> + <arg name="handle" type="string" + summary="the exported surface handle"/> + </request> + </interface> + + <interface name="zxdg_exported_v2" version="1"> + <description summary="an exported surface handle"> + A xdg_exported object represents an exported reference to a surface. The + exported surface may be referenced as long as the xdg_exported object not + destroyed. Destroying the xdg_exported invalidates any relationship the + importer may have established using xdg_imported. + </description> + + <request name="destroy" type="destructor"> + <description summary="unexport the exported surface"> + Revoke the previously exported surface. This invalidates any + relationship the importer may have set up using the xdg_imported created + given the handle sent via xdg_exported.handle. + </description> + </request> + + <event name="handle"> + <description summary="the exported surface handle"> + The handle event contains the unique handle of this exported surface + reference. It may be shared with any client, which then can use it to + import the surface by calling xdg_importer.import_toplevel. A handle + may be used to import the surface multiple times. + </description> + <arg name="handle" type="string" summary="the exported surface handle"/> + </event> + </interface> + + <interface name="zxdg_imported_v2" version="1"> + <description summary="an imported surface handle"> + A xdg_imported object represents an imported reference to surface exported + by some client. A client can use this interface to manipulate + relationships between its own surfaces and the imported surface. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_imported object"> + Notify the compositor that it will no longer use the xdg_imported + object. Any relationship that may have been set up will at this point + be invalidated. + </description> + </request> + + <request name="set_parent_of"> + <description summary="set as the parent of some surface"> + Set the imported surface as the parent of some surface of the client. + The passed surface must be a xdg_toplevel equivalent. Calling this + function sets up a surface to surface relation with the same stacking + and positioning semantics as xdg_toplevel.set_parent. + </description> + <arg name="surface" type="object" interface="wl_surface" + summary="the child surface"/> + </request> + + <event name="destroyed"> + <description summary="the imported surface handle has been destroyed"> + The imported surface handle has been destroyed and any relationship set + up has been invalidated. This may happen for various reasons, for + example if the exported surface or the exported surface handle has been + destroyed, if the handle used for importing was invalid. + </description> + </event> + </interface> + +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-output/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-output/README new file mode 100644 index 0000000..e42b711 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-output/README @@ -0,0 +1,4 @@ +xdg_output protocol + +Maintainers: +Olivier Fourdan <ofourdan@redhat.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-output/xdg-output-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-output/xdg-output-unstable-v1.xml new file mode 100644 index 0000000..ccbfe1c --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-output/xdg-output-unstable-v1.xml @@ -0,0 +1,209 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="xdg_output_unstable_v1"> + + <copyright> + Copyright © 2017 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="Protocol to describe output regions"> + This protocol aims at describing outputs in a way which is more in line + with the concept of an output on desktop oriented systems. + + Some information are more specific to the concept of an output for + a desktop oriented system and may not make sense in other applications, + such as IVI systems for example. + + Typically, the global compositor space on a desktop system is made of + a contiguous or overlapping set of rectangular regions. + + Some of the information provided in this protocol might be identical + to their counterparts already available from wl_output, in which case + the information provided by this protocol should be preferred to their + equivalent in wl_output. The goal is to move the desktop specific + concepts (such as output location within the global compositor space, + the connector name and types, etc.) out of the core wl_output protocol. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible + changes may be added together with the corresponding interface + version bump. + Backward incompatible changes are done by bumping the version + number in the protocol and interface names and resetting the + interface version. Once the protocol is to be declared stable, + the 'z' prefix and the version number in the protocol and + interface names are removed and the interface version number is + reset. + </description> + + <interface name="zxdg_output_manager_v1" version="2"> + <description summary="manage xdg_output objects"> + A global factory interface for xdg_output objects. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_output_manager object"> + Using this request a client can tell the server that it is not + going to use the xdg_output_manager object anymore. + + Any objects already created through this instance are not affected. + </description> + </request> + + <request name="get_xdg_output"> + <description summary="create an xdg output from a wl_output"> + This creates a new xdg_output object for the given wl_output. + </description> + <arg name="id" type="new_id" interface="zxdg_output_v1"/> + <arg name="output" type="object" interface="wl_output"/> + </request> + </interface> + + <interface name="zxdg_output_v1" version="2"> + <description summary="compositor logical output region"> + An xdg_output describes part of the compositor geometry. + + This typically corresponds to a monitor that displays part of the + compositor space. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_output object"> + Using this request a client can tell the server that it is not + going to use the xdg_output object anymore. + </description> + </request> + + <event name="logical_position"> + <description summary="position of the output within the global compositor space"> + The position event describes the location of the wl_output within + the global compositor space. + + The logical_position event is sent after creating an xdg_output + (see xdg_output_manager.get_xdg_output) and whenever the location + of the output changes within the global compositor space. + </description> + <arg name="x" type="int" + summary="x position within the global compositor space"/> + <arg name="y" type="int" + summary="y position within the global compositor space"/> + </event> + + <event name="logical_size"> + <description summary="size of the output in the global compositor space"> + The logical_size event describes the size of the output in the + global compositor space. + + For example, a surface without any buffer scale, transformation + nor rotation set, with the size matching the logical_size will + have the same size as the corresponding output when displayed. + + Most regular Wayland clients should not pay attention to the + logical size and would rather rely on xdg_shell interfaces. + + Some clients such as Xwayland, however, need this to configure + their surfaces in the global compositor space as the compositor + may apply a different scale from what is advertised by the output + scaling property (to achieve fractional scaling, for example). + + For example, for a wl_output mode 3840×2160 and a scale factor 2: + + - A compositor not scaling the surface buffers will advertise a + logical size of 3840×2160, + + - A compositor automatically scaling the surface buffers will + advertise a logical size of 1920×1080, + + - A compositor using a fractional scale of 1.5 will advertise a + logical size to 2560×1620. + + For example, for a wl_output mode 1920×1080 and a 90 degree rotation, + the compositor will advertise a logical size of 1080x1920. + + The logical_size event is sent after creating an xdg_output + (see xdg_output_manager.get_xdg_output) and whenever the logical + size of the output changes, either as a result of a change in the + applied scale or because of a change in the corresponding output + mode(see wl_output.mode) or transform (see wl_output.transform). + </description> + <arg name="width" type="int" + summary="width in global compositor space"/> + <arg name="height" type="int" + summary="height in global compositor space"/> + </event> + + <event name="done"> + <description summary="all information about the output have been sent"> + This event is sent after all other properties of an xdg_output + have been sent. + + This allows changes to the xdg_output properties to be seen as + atomic, even if they happen via multiple events. + </description> + </event> + + <!-- Version 2 additions --> + + <event name="name" since="2"> + <description summary="name of this output"> + Many compositors will assign names to their outputs, show them to the + user, allow them to be configured by name, etc. The client may wish to + know this name as well to offer the user similar behaviors. + + The naming convention is compositor defined, but limited to + alphanumeric characters and dashes (-). Each name is unique among all + wl_output globals, but if a wl_output global is destroyed the same name + may be reused later. The names will also remain consistent across + sessions with the same hardware and software configuration. + + Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. However, do + not assume that the name is a reflection of an underlying DRM + connector, X11 connection, etc. + + The name event is sent after creating an xdg_output (see + xdg_output_manager.get_xdg_output). This event is only sent once per + xdg_output, and the name does not change over the lifetime of the + wl_output global. + </description> + <arg name="name" type="string" summary="output name"/> + </event> + + <event name="description" since="2"> + <description summary="human-readable description of this output"> + Many compositors can produce human-readable descriptions of their + outputs. The client may wish to know this description as well, to + communicate the user for various purposes. + + The description is a UTF-8 string with no convention defined for its + contents. Examples might include 'Foocorp 11" Display' or 'Virtual X11 + output via :1'. + + The description event is sent after creating an xdg_output (see + xdg_output_manager.get_xdg_output). This event is only sent once per + xdg_output, and the description does not change over the lifetime of + the wl_output global. The description is optional, and may not be sent + at all. + </description> + <arg name="description" type="string" summary="output description"/> + </event> + + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-shell/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-shell/README new file mode 100644 index 0000000..96ae4ef --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-shell/README @@ -0,0 +1,4 @@ +xdg shell protocol + +Maintainers: +Jasper St. Pierre <jstpierre@mecheye.net> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-shell/xdg-shell-unstable-v5.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-shell/xdg-shell-unstable-v5.xml new file mode 100644 index 0000000..ef0180d --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-shell/xdg-shell-unstable-v5.xml @@ -0,0 +1,623 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="xdg_shell_unstable_v5"> + + <copyright> + Copyright © 2008-2013 Kristian Høgsberg + Copyright © 2013 Rafael Antognolli + Copyright © 2013 Jasper St. Pierre + Copyright © 2010-2013 Intel Corporation + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="xdg_shell" version="1"> + <description summary="create desktop-style surfaces"> + xdg_shell allows clients to turn a wl_surface into a "real window" + which can be dragged, resized, stacked, and moved around by the + user. Everything about this interface is suited towards traditional + desktop environments. + </description> + + <enum name="version"> + <description summary="latest protocol version"> + The 'current' member of this enum gives the version of the + protocol. Implementations can compare this to the version + they implement using static_assert to ensure the protocol and + implementation versions match. + </description> + <entry name="current" value="5" summary="Always the latest version"/> + </enum> + + <enum name="error"> + <entry name="role" value="0" summary="given wl_surface has another role"/> + <entry name="defunct_surfaces" value="1" summary="xdg_shell was destroyed before children"/> + <entry name="not_the_topmost_popup" value="2" summary="the client tried to map or destroy a non-topmost popup"/> + <entry name="invalid_popup_parent" value="3" summary="the client specified an invalid popup parent surface"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="destroy xdg_shell"> + Destroy this xdg_shell object. + + Destroying a bound xdg_shell object while there are surfaces + still alive created by this xdg_shell object instance is illegal + and will result in a protocol error. + </description> + </request> + + <request name="use_unstable_version"> + <description summary="enable use of this unstable version"> + Negotiate the unstable version of the interface. This + mechanism is in place to ensure client and server agree on the + unstable versions of the protocol that they speak or exit + cleanly if they don't agree. This request will go away once + the xdg-shell protocol is stable. + </description> + <arg name="version" type="int"/> + </request> + + <request name="get_xdg_surface"> + <description summary="create a shell surface from a surface"> + This creates an xdg_surface for the given surface and gives it the + xdg_surface role. A wl_surface can only be given an xdg_surface role + once. If get_xdg_surface is called with a wl_surface that already has + an active xdg_surface associated with it, or if it had any other role, + an error is raised. + + See the documentation of xdg_surface for more details about what an + xdg_surface is and how it is used. + </description> + <arg name="id" type="new_id" interface="xdg_surface"/> + <arg name="surface" type="object" interface="wl_surface"/> + </request> + + <request name="get_xdg_popup"> + <description summary="create a popup for a surface"> + This creates an xdg_popup for the given surface and gives it the + xdg_popup role. A wl_surface can only be given an xdg_popup role + once. If get_xdg_popup is called with a wl_surface that already has + an active xdg_popup associated with it, or if it had any other role, + an error is raised. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. + + See the documentation of xdg_popup for more details about what an + xdg_popup is and how it is used. + </description> + <arg name="id" type="new_id" interface="xdg_popup"/> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="parent" type="object" interface="wl_surface"/> + <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + </request> + + <event name="ping"> + <description summary="check if the client is alive"> + The ping event asks the client if it's still alive. Pass the + serial specified in the event back to the compositor by sending + a "pong" request back with the specified serial. + + Compositors can use this to determine if the client is still + alive. It's unspecified what will happen if the client doesn't + respond to the ping request, or in what timeframe. Clients should + try to respond in a reasonable amount of time. + + A compositor is free to ping in any way it wants, but a client must + always respond to any xdg_shell object it created. + </description> + <arg name="serial" type="uint" summary="pass this to the pong request"/> + </event> + + <request name="pong"> + <description summary="respond to a ping event"> + A client must respond to a ping event with a pong request or + the client may be deemed unresponsive. + </description> + <arg name="serial" type="uint" summary="serial of the ping event"/> + </request> + </interface> + + <interface name="xdg_surface" version="1"> + <description summary="A desktop window"> + An interface that may be implemented by a wl_surface, for + implementations that provide a desktop-style user interface. + + It provides requests to treat surfaces like windows, allowing to set + properties like maximized, fullscreen, minimized, and to move and resize + them, and associate metadata like title and app id. + + The client must call wl_surface.commit on the corresponding wl_surface + for the xdg_surface state to take effect. Prior to committing the new + state, it can set up initial configuration, such as maximizing or setting + a window geometry. + + Even without attaching a buffer the compositor must respond to initial + committed configuration, for instance sending a configure event with + expected window geometry if the client maximized its surface during + initialization. + + For a surface to be mapped by the compositor the client must have + committed both an xdg_surface state and a buffer. + </description> + + <request name="destroy" type="destructor"> + <description summary="Destroy the xdg_surface"> + Unmap and destroy the window. The window will be effectively + hidden from the user's point of view, and all state like + maximization, fullscreen, and so on, will be lost. + </description> + </request> + + <request name="set_parent"> + <description summary="set the parent of this surface"> + Set the "parent" of this surface. This window should be stacked + above a parent. The parent surface must be mapped as long as this + surface is mapped. + + Parent windows should be set on dialogs, toolboxes, or other + "auxiliary" surfaces, so that the parent is raised when the dialog + is raised. + </description> + <arg name="parent" type="object" interface="xdg_surface" allow-null="true"/> + </request> + + <request name="set_title"> + <description summary="set surface title"> + Set a short title for the surface. + + This string may be used to identify the surface in a task bar, + window list, or other user interface elements provided by the + compositor. + + The string must be encoded in UTF-8. + </description> + <arg name="title" type="string"/> + </request> + + <request name="set_app_id"> + <description summary="set application ID"> + Set an application identifier for the surface. + + The app ID identifies the general class of applications to which + the surface belongs. The compositor can use this to group multiple + surfaces together, or to determine how to launch a new application. + + For D-Bus activatable applications, the app ID is used as the D-Bus + service name. + + The compositor shell will try to group application surfaces together + by their app ID. As a best practice, it is suggested to select app + ID's that match the basename of the application's .desktop file. + For example, "org.freedesktop.FooViewer" where the .desktop file is + "org.freedesktop.FooViewer.desktop". + + See the desktop-entry specification [0] for more details on + application identifiers and how they relate to well-known D-Bus + names and .desktop files. + + [0] http://standards.freedesktop.org/desktop-entry-spec/ + </description> + <arg name="app_id" type="string"/> + </request> + + <request name="show_window_menu"> + <description summary="show the window menu"> + Clients implementing client-side decorations might want to show + a context menu when right-clicking on the decorations, giving the + user a menu that they can use to maximize or minimize the window. + + This request asks the compositor to pop up such a window menu at + the given position, relative to the local surface coordinates of + the parent surface. There are no guarantees as to what menu items + the window menu contains. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. + </description> + <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + <arg name="x" type="int" summary="the x position to pop up the window menu at"/> + <arg name="y" type="int" summary="the y position to pop up the window menu at"/> + </request> + + <request name="move"> + <description summary="start an interactive move"> + Start an interactive, user-driven move of the surface. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. The passed + serial is used to determine the type of interactive move (touch, + pointer, etc). + + The server may ignore move requests depending on the state of + the surface (e.g. fullscreen or maximized), or if the passed serial + is no longer valid. + + If triggered, the surface will lose the focus of the device + (wl_pointer, wl_touch, etc) used for the move. It is up to the + compositor to visually indicate that the move is taking place, such as + updating a pointer cursor, during the move. There is no guarantee + that the device focus will return when the move is completed. + </description> + <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + </request> + + <enum name="resize_edge"> + <description summary="edge values for resizing"> + These values are used to indicate which edge of a surface + is being dragged in a resize operation. + </description> + <entry name="none" value="0"/> + <entry name="top" value="1"/> + <entry name="bottom" value="2"/> + <entry name="left" value="4"/> + <entry name="top_left" value="5"/> + <entry name="bottom_left" value="6"/> + <entry name="right" value="8"/> + <entry name="top_right" value="9"/> + <entry name="bottom_right" value="10"/> + </enum> + + <request name="resize"> + <description summary="start an interactive resize"> + Start a user-driven, interactive resize of the surface. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. The passed + serial is used to determine the type of interactive resize (touch, + pointer, etc). + + The server may ignore resize requests depending on the state of + the surface (e.g. fullscreen or maximized). + + If triggered, the client will receive configure events with the + "resize" state enum value and the expected sizes. See the "resize" + enum value for more details about what is required. The client + must also acknowledge configure events using "ack_configure". After + the resize is completed, the client will receive another "configure" + event without the resize state. + + If triggered, the surface also will lose the focus of the device + (wl_pointer, wl_touch, etc) used for the resize. It is up to the + compositor to visually indicate that the resize is taking place, + such as updating a pointer cursor, during the resize. There is no + guarantee that the device focus will return when the resize is + completed. + + The edges parameter specifies how the surface should be resized, + and is one of the values of the resize_edge enum. The compositor + may use this information to update the surface position for + example when dragging the top left corner. The compositor may also + use this information to adapt its behavior, e.g. choose an + appropriate cursor image. + </description> + <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + <arg name="edges" type="uint" summary="which edge or corner is being dragged"/> + </request> + + <enum name="state"> + <description summary="types of state on the surface"> + The different state values used on the surface. This is designed for + state values like maximized, fullscreen. It is paired with the + configure event to ensure that both the client and the compositor + setting the state can be synchronized. + + States set in this way are double-buffered. They will get applied on + the next commit. + + Desktop environments may extend this enum by taking up a range of + values and documenting the range they chose in this description. + They are not required to document the values for the range that they + chose. Ideally, any good extensions from a desktop environment should + make its way into standardization into this enum. + + The current reserved ranges are: + + 0x0000 - 0x0FFF: xdg-shell core values, documented below. + 0x1000 - 0x1FFF: GNOME + 0x2000 - 0x2FFF: EFL + </description> + <entry name="maximized" value="1" summary="the surface is maximized"> + <description summary="the surface is maximized"> + The surface is maximized. The window geometry specified in the configure + event must be obeyed by the client. + </description> + </entry> + <entry name="fullscreen" value="2" summary="the surface is fullscreen"> + <description summary="the surface is fullscreen"> + The surface is fullscreen. The window geometry specified in the configure + event must be obeyed by the client. + </description> + </entry> + <entry name="resizing" value="3" summary="the surface is being resized"> + <description summary="the surface is being resized"> + The surface is being resized. The window geometry specified in the + configure event is a maximum; the client cannot resize beyond it. + Clients that have aspect ratio or cell sizing configuration can use + a smaller size, however. + </description> + </entry> + <entry name="activated" value="4" summary="the surface is now activated"> + <description summary="the surface is now activated"> + Client window decorations should be painted as if the window is + active. Do not assume this means that the window actually has + keyboard or pointer focus. + </description> + </entry> + </enum> + + <event name="configure"> + <description summary="suggest a surface change"> + The configure event asks the client to resize its surface or to + change its state. + + The width and height arguments specify a hint to the window + about how its surface should be resized in window geometry + coordinates. See set_window_geometry. + + If the width or height arguments are zero, it means the client + should decide its own window dimension. This may happen when the + compositor need to configure the state of the surface but doesn't + have any information about any previous or expected dimension. + + The states listed in the event specify how the width/height + arguments should be interpreted, and possibly how it should be + drawn. + + Clients should arrange their surface for the new size and + states, and then send a ack_configure request with the serial + sent in this configure event at some point before committing + the new surface. + + If the client receives multiple configure events before it + can respond to one, it is free to discard all but the last + event it received. + </description> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + <arg name="states" type="array"/> + <arg name="serial" type="uint"/> + </event> + + <request name="ack_configure"> + <description summary="ack a configure event"> + When a configure event is received, if a client commits the + surface in response to the configure event, then the client + must make an ack_configure request sometime before the commit + request, passing along the serial of the configure event. + + For instance, the compositor might use this information to move + a surface to the top left only when the client has drawn itself + for the maximized or fullscreen state. + + If the client receives multiple configure events before it + can respond to one, it only has to ack the last configure event. + + A client is not required to commit immediately after sending + an ack_configure request - it may even ack_configure several times + before its next surface commit. + + The compositor expects that the most recently received + ack_configure request at the time of a commit indicates which + configure event the client is responding to. + </description> + <arg name="serial" type="uint" summary="the serial from the configure event"/> + </request> + + <request name="set_window_geometry"> + <description summary="set the new window geometry"> + The window geometry of a window is its "visible bounds" from the + user's perspective. Client-side decorations often have invisible + portions like drop-shadows which should be ignored for the + purposes of aligning, placing and constraining windows. + + The window geometry is double buffered, and will be applied at the + time wl_surface.commit of the corresponding wl_surface is called. + + Once the window geometry of the surface is set once, it is not + possible to unset it, and it will remain the same until + set_window_geometry is called again, even if a new subsurface or + buffer is attached. + + If never set, the value is the full bounds of the surface, + including any subsurfaces. This updates dynamically on every + commit. This unset mode is meant for extremely simple clients. + + If responding to a configure event, the window geometry in here + must respect the sizing negotiations specified by the states in + the configure event. + + The arguments are given in the surface local coordinate space of + the wl_surface associated with this xdg_surface. + + The width and height must be greater than zero. + </description> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="set_maximized"> + <description summary="maximize the window"> + Maximize the surface. + + After requesting that the surface should be maximized, the compositor + will respond by emitting a configure event with the "maximized" state + and the required window geometry. The client should then update its + content, drawing it in a maximized state, i.e. without shadow or other + decoration outside of the window geometry. The client must also + acknowledge the configure when committing the new content (see + ack_configure). + + It is up to the compositor to decide how and where to maximize the + surface, for example which output and what region of the screen should + be used. + + If the surface was already maximized, the compositor will still emit + a configure event with the "maximized" state. + </description> + </request> + + <request name="unset_maximized"> + <description summary="unmaximize the window"> + Unmaximize the surface. + + After requesting that the surface should be unmaximized, the compositor + will respond by emitting a configure event without the "maximized" + state. If available, the compositor will include the window geometry + dimensions the window had prior to being maximized in the configure + request. The client must then update its content, drawing it in a + regular state, i.e. potentially with shadow, etc. The client must also + acknowledge the configure when committing the new content (see + ack_configure). + + It is up to the compositor to position the surface after it was + unmaximized; usually the position the surface had before maximizing, if + applicable. + + If the surface was already not maximized, the compositor will still + emit a configure event without the "maximized" state. + </description> + </request> + + <request name="set_fullscreen"> + <description summary="set the window as fullscreen on a monitor"> + Make the surface fullscreen. + + You can specify an output that you would prefer to be fullscreen. + If this value is NULL, it's up to the compositor to choose which + display will be used to map this surface. + + If the surface doesn't cover the whole output, the compositor will + position the surface in the center of the output and compensate with + black borders filling the rest of the output. + </description> + <arg name="output" type="object" interface="wl_output" allow-null="true"/> + </request> + <request name="unset_fullscreen" /> + + <request name="set_minimized"> + <description summary="set the window as minimized"> + Request that the compositor minimize your surface. There is no + way to know if the surface is currently minimized, nor is there + any way to unset minimization on this surface. + + If you are looking to throttle redrawing when minimized, please + instead use the wl_surface.frame event for this, as this will + also work with live previews on windows in Alt-Tab, Expose or + similar compositor features. + </description> + </request> + + <event name="close"> + <description summary="surface wants to be closed"> + The close event is sent by the compositor when the user + wants the surface to be closed. This should be equivalent to + the user clicking the close button in client-side decorations, + if your application has any... + + This is only a request that the user intends to close your + window. The client may choose to ignore this request, or show + a dialog to ask the user to save their data... + </description> + </event> + </interface> + + <interface name="xdg_popup" version="1"> + <description summary="short-lived, popup surfaces for menus"> + A popup surface is a short-lived, temporary surface that can be + used to implement menus. It takes an explicit grab on the surface + that will be dismissed when the user dismisses the popup. This can + be done by the user clicking outside the surface, using the keyboard, + or even locking the screen through closing the lid or a timeout. + + When the popup is dismissed, a popup_done event will be sent out, + and at the same time the surface will be unmapped. The xdg_popup + object is now inert and cannot be reactivated, so clients should + destroy it. Explicitly destroying the xdg_popup object will also + dismiss the popup and unmap the surface. + + Clients will receive events for all their surfaces during this + grab (which is an "owner-events" grab in X11 parlance). This is + done so that users can navigate through submenus and other + "nested" popup windows without having to dismiss the topmost + popup. + + Clients that want to dismiss the popup when another surface of + their own is clicked should dismiss the popup using the destroy + request. + + The parent surface must have either an xdg_surface or xdg_popup + role. + + Specifying an xdg_popup for the parent means that the popups are + nested, with this popup now being the topmost popup. Nested + popups must be destroyed in the reverse order they were created + in, e.g. the only popup you are allowed to destroy at all times + is the topmost one. + + If there is an existing popup when creating a new popup, the + parent must be the current topmost popup. + + A parent surface must be mapped before the new popup is mapped. + + When compositors choose to dismiss a popup, they will likely + dismiss every nested popup as well. When a compositor dismisses + popups, it will follow the same dismissing order as required + from the client. + + The x and y arguments passed when creating the popup object specify + where the top left of the popup should be placed, relative to the + local surface coordinates of the parent surface. See + xdg_shell.get_xdg_popup. + + The client must call wl_surface.commit on the corresponding wl_surface + for the xdg_popup state to take effect. + + For a surface to be mapped by the compositor the client must have + committed both the xdg_popup state and a buffer. + </description> + + <request name="destroy" type="destructor"> + <description summary="remove xdg_popup interface"> + This destroys the popup. Explicitly destroying the xdg_popup + object will also dismiss the popup, and unmap the surface. + + If this xdg_popup is not the "topmost" popup, a protocol error + will be sent. + </description> + </request> + + <event name="popup_done"> + <description summary="popup interaction is done"> + The popup_done event is sent out when a popup is dismissed by the + compositor. The client should destroy the xdg_popup object at this + point. + </description> + </event> + + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-shell/xdg-shell-unstable-v6.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-shell/xdg-shell-unstable-v6.xml new file mode 100644 index 0000000..1c0f924 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xdg-shell/xdg-shell-unstable-v6.xml @@ -0,0 +1,1044 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="xdg_shell_unstable_v6"> + + <copyright> + Copyright © 2008-2013 Kristian Høgsberg + Copyright © 2013 Rafael Antognolli + Copyright © 2013 Jasper St. Pierre + Copyright © 2010-2013 Intel Corporation + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="zxdg_shell_v6" version="1"> + <description summary="create desktop-style surfaces"> + xdg_shell allows clients to turn a wl_surface into a "real window" + which can be dragged, resized, stacked, and moved around by the + user. Everything about this interface is suited towards traditional + desktop environments. + </description> + + <enum name="error"> + <entry name="role" value="0" summary="given wl_surface has another role"/> + <entry name="defunct_surfaces" value="1" + summary="xdg_shell was destroyed before children"/> + <entry name="not_the_topmost_popup" value="2" + summary="the client tried to map or destroy a non-topmost popup"/> + <entry name="invalid_popup_parent" value="3" + summary="the client specified an invalid popup parent surface"/> + <entry name="invalid_surface_state" value="4" + summary="the client provided an invalid surface state"/> + <entry name="invalid_positioner" value="5" + summary="the client provided an invalid positioner"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="destroy xdg_shell"> + Destroy this xdg_shell object. + + Destroying a bound xdg_shell object while there are surfaces + still alive created by this xdg_shell object instance is illegal + and will result in a protocol error. + </description> + </request> + + <request name="create_positioner"> + <description summary="create a positioner object"> + Create a positioner object. A positioner object is used to position + surfaces relative to some parent surface. See the interface description + and xdg_surface.get_popup for details. + </description> + <arg name="id" type="new_id" interface="zxdg_positioner_v6"/> + </request> + + <request name="get_xdg_surface"> + <description summary="create a shell surface from a surface"> + This creates an xdg_surface for the given surface. While xdg_surface + itself is not a role, the corresponding surface may only be assigned + a role extending xdg_surface, such as xdg_toplevel or xdg_popup. + + This creates an xdg_surface for the given surface. An xdg_surface is + used as basis to define a role to a given surface, such as xdg_toplevel + or xdg_popup. It also manages functionality shared between xdg_surface + based surface roles. + + See the documentation of xdg_surface for more details about what an + xdg_surface is and how it is used. + </description> + <arg name="id" type="new_id" interface="zxdg_surface_v6"/> + <arg name="surface" type="object" interface="wl_surface"/> + </request> + + <request name="pong"> + <description summary="respond to a ping event"> + A client must respond to a ping event with a pong request or + the client may be deemed unresponsive. See xdg_shell.ping. + </description> + <arg name="serial" type="uint" summary="serial of the ping event"/> + </request> + + <event name="ping"> + <description summary="check if the client is alive"> + The ping event asks the client if it's still alive. Pass the + serial specified in the event back to the compositor by sending + a "pong" request back with the specified serial. See xdg_shell.ping. + + Compositors can use this to determine if the client is still + alive. It's unspecified what will happen if the client doesn't + respond to the ping request, or in what timeframe. Clients should + try to respond in a reasonable amount of time. + + A compositor is free to ping in any way it wants, but a client must + always respond to any xdg_shell object it created. + </description> + <arg name="serial" type="uint" summary="pass this to the pong request"/> + </event> + </interface> + + <interface name="zxdg_positioner_v6" version="1"> + <description summary="child surface positioner"> + The xdg_positioner provides a collection of rules for the placement of a + child surface relative to a parent surface. Rules can be defined to ensure + the child surface remains within the visible area's borders, and to + specify how the child surface changes its position, such as sliding along + an axis, or flipping around a rectangle. These positioner-created rules are + constrained by the requirement that a child surface must intersect with or + be at least partially adjacent to its parent surface. + + See the various requests for details about possible rules. + + At the time of the request, the compositor makes a copy of the rules + specified by the xdg_positioner. Thus, after the request is complete the + xdg_positioner object can be destroyed or reused; further changes to the + object will have no effect on previous usages. + + For an xdg_positioner object to be considered complete, it must have a + non-zero size set by set_size, and a non-zero anchor rectangle set by + set_anchor_rect. Passing an incomplete xdg_positioner object when + positioning a surface raises an error. + </description> + + <enum name="error"> + <entry name="invalid_input" value="0" summary="invalid input provided"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_positioner object"> + Notify the compositor that the xdg_positioner will no longer be used. + </description> + </request> + + <request name="set_size"> + <description summary="set the size of the to-be positioned rectangle"> + Set the size of the surface that is to be positioned with the positioner + object. The size is in surface-local coordinates and corresponds to the + window geometry. See xdg_surface.set_window_geometry. + + If a zero or negative size is set the invalid_input error is raised. + </description> + <arg name="width" type="int" summary="width of positioned rectangle"/> + <arg name="height" type="int" summary="height of positioned rectangle"/> + </request> + + <request name="set_anchor_rect"> + <description summary="set the anchor rectangle within the parent surface"> + Specify the anchor rectangle within the parent surface that the child + surface will be placed relative to. The rectangle is relative to the + window geometry as defined by xdg_surface.set_window_geometry of the + parent surface. The rectangle must be at least 1x1 large. + + When the xdg_positioner object is used to position a child surface, the + anchor rectangle may not extend outside the window geometry of the + positioned child's parent surface. + + If a zero or negative size is set the invalid_input error is raised. + </description> + <arg name="x" type="int" summary="x position of anchor rectangle"/> + <arg name="y" type="int" summary="y position of anchor rectangle"/> + <arg name="width" type="int" summary="width of anchor rectangle"/> + <arg name="height" type="int" summary="height of anchor rectangle"/> + </request> + + <enum name="anchor" bitfield="true"> + <entry name="none" value="0" + summary="the center of the anchor rectangle"/> + <entry name="top" value="1" + summary="the top edge of the anchor rectangle"/> + <entry name="bottom" value="2" + summary="the bottom edge of the anchor rectangle"/> + <entry name="left" value="4" + summary="the left edge of the anchor rectangle"/> + <entry name="right" value="8" + summary="the right edge of the anchor rectangle"/> + </enum> + + <request name="set_anchor"> + <description summary="set anchor rectangle anchor edges"> + Defines a set of edges for the anchor rectangle. These are used to + derive an anchor point that the child surface will be positioned + relative to. If two orthogonal edges are specified (e.g. 'top' and + 'left'), then the anchor point will be the intersection of the edges + (e.g. the top left position of the rectangle); otherwise, the derived + anchor point will be centered on the specified edge, or in the center of + the anchor rectangle if no edge is specified. + + If two parallel anchor edges are specified (e.g. 'left' and 'right'), + the invalid_input error is raised. + </description> + <arg name="anchor" type="uint" enum="anchor" + summary="bit mask of anchor edges"/> + </request> + + <enum name="gravity" bitfield="true"> + <entry name="none" value="0" + summary="center over the anchor edge"/> + <entry name="top" value="1" + summary="position above the anchor edge"/> + <entry name="bottom" value="2" + summary="position below the anchor edge"/> + <entry name="left" value="4" + summary="position to the left of the anchor edge"/> + <entry name="right" value="8" + summary="position to the right of the anchor edge"/> + </enum> + + <request name="set_gravity"> + <description summary="set child surface gravity"> + Defines in what direction a surface should be positioned, relative to + the anchor point of the parent surface. If two orthogonal gravities are + specified (e.g. 'bottom' and 'right'), then the child surface will be + placed in the specified direction; otherwise, the child surface will be + centered over the anchor point on any axis that had no gravity + specified. + + If two parallel gravities are specified (e.g. 'left' and 'right'), the + invalid_input error is raised. + </description> + <arg name="gravity" type="uint" enum="gravity" + summary="bit mask of gravity directions"/> + </request> + + <enum name="constraint_adjustment" bitfield="true"> + <description summary="constraint adjustments"> + The constraint adjustment value define ways the compositor will adjust + the position of the surface, if the unadjusted position would result + in the surface being partly constrained. + + Whether a surface is considered 'constrained' is left to the compositor + to determine. For example, the surface may be partly outside the + compositor's defined 'work area', thus necessitating the child surface's + position be adjusted until it is entirely inside the work area. + + The adjustments can be combined, according to a defined precedence: 1) + Flip, 2) Slide, 3) Resize. + </description> + <entry name="none" value="0"> + <description summary="don't move the child surface when constrained"> + Don't alter the surface position even if it is constrained on some + axis, for example partially outside the edge of a monitor. + </description> + </entry> + <entry name="slide_x" value="1"> + <description summary="move along the x axis until unconstrained"> + Slide the surface along the x axis until it is no longer constrained. + + First try to slide towards the direction of the gravity on the x axis + until either the edge in the opposite direction of the gravity is + unconstrained or the edge in the direction of the gravity is + constrained. + + Then try to slide towards the opposite direction of the gravity on the + x axis until either the edge in the direction of the gravity is + unconstrained or the edge in the opposite direction of the gravity is + constrained. + </description> + </entry> + <entry name="slide_y" value="2"> + <description summary="move along the y axis until unconstrained"> + Slide the surface along the y axis until it is no longer constrained. + + First try to slide towards the direction of the gravity on the y axis + until either the edge in the opposite direction of the gravity is + unconstrained or the edge in the direction of the gravity is + constrained. + + Then try to slide towards the opposite direction of the gravity on the + y axis until either the edge in the direction of the gravity is + unconstrained or the edge in the opposite direction of the gravity is + constrained. + </description> + </entry> + <entry name="flip_x" value="4"> + <description summary="invert the anchor and gravity on the x axis"> + Invert the anchor and gravity on the x axis if the surface is + constrained on the x axis. For example, if the left edge of the + surface is constrained, the gravity is 'left' and the anchor is + 'left', change the gravity to 'right' and the anchor to 'right'. + + If the adjusted position also ends up being constrained, the resulting + position of the flip_x adjustment will be the one before the + adjustment. + </description> + </entry> + <entry name="flip_y" value="8"> + <description summary="invert the anchor and gravity on the y axis"> + Invert the anchor and gravity on the y axis if the surface is + constrained on the y axis. For example, if the bottom edge of the + surface is constrained, the gravity is 'bottom' and the anchor is + 'bottom', change the gravity to 'top' and the anchor to 'top'. + + If the adjusted position also ends up being constrained, the resulting + position of the flip_y adjustment will be the one before the + adjustment. + </description> + </entry> + <entry name="resize_x" value="16"> + <description summary="horizontally resize the surface"> + Resize the surface horizontally so that it is completely + unconstrained. + </description> + </entry> + <entry name="resize_y" value="32"> + <description summary="vertically resize the surface"> + Resize the surface vertically so that it is completely unconstrained. + </description> + </entry> + </enum> + + <request name="set_constraint_adjustment"> + <description summary="set the adjustment to be done when constrained"> + Specify how the window should be positioned if the originally intended + position caused the surface to be constrained, meaning at least + partially outside positioning boundaries set by the compositor. The + adjustment is set by constructing a bitmask describing the adjustment to + be made when the surface is constrained on that axis. + + If no bit for one axis is set, the compositor will assume that the child + surface should not change its position on that axis when constrained. + + If more than one bit for one axis is set, the order of how adjustments + are applied is specified in the corresponding adjustment descriptions. + + The default adjustment is none. + </description> + <arg name="constraint_adjustment" type="uint" + summary="bit mask of constraint adjustments"/> + </request> + + <request name="set_offset"> + <description summary="set surface position offset"> + Specify the surface position offset relative to the position of the + anchor on the anchor rectangle and the anchor on the surface. For + example if the anchor of the anchor rectangle is at (x, y), the surface + has the gravity bottom|right, and the offset is (ox, oy), the calculated + surface position will be (x + ox, y + oy). The offset position of the + surface is the one used for constraint testing. See + set_constraint_adjustment. + + An example use case is placing a popup menu on top of a user interface + element, while aligning the user interface element of the parent surface + with some user interface element placed somewhere in the popup surface. + </description> + <arg name="x" type="int" summary="surface position x offset"/> + <arg name="y" type="int" summary="surface position y offset"/> + </request> + </interface> + + <interface name="zxdg_surface_v6" version="1"> + <description summary="desktop user interface surface base interface"> + An interface that may be implemented by a wl_surface, for + implementations that provide a desktop-style user interface. + + It provides a base set of functionality required to construct user + interface elements requiring management by the compositor, such as + toplevel windows, menus, etc. The types of functionality are split into + xdg_surface roles. + + Creating an xdg_surface does not set the role for a wl_surface. In order + to map an xdg_surface, the client must create a role-specific object + using, e.g., get_toplevel, get_popup. The wl_surface for any given + xdg_surface can have at most one role, and may not be assigned any role + not based on xdg_surface. + + A role must be assigned before any other requests are made to the + xdg_surface object. + + The client must call wl_surface.commit on the corresponding wl_surface + for the xdg_surface state to take effect. + + Creating an xdg_surface from a wl_surface which has a buffer attached or + committed is a client error, and any attempts by a client to attach or + manipulate a buffer prior to the first xdg_surface.configure call must + also be treated as errors. + + For a surface to be mapped by the compositor, the following conditions + must be met: (1) the client has assigned a xdg_surface based role to the + surface, (2) the client has set and committed the xdg_surface state and + the role dependent state to the surface and (3) the client has committed a + buffer to the surface. + </description> + + <enum name="error"> + <entry name="not_constructed" value="1"/> + <entry name="already_constructed" value="2"/> + <entry name="unconfigured_buffer" value="3"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_surface"> + Destroy the xdg_surface object. An xdg_surface must only be destroyed + after its role object has been destroyed. + </description> + </request> + + <request name="get_toplevel"> + <description summary="assign the xdg_toplevel surface role"> + This creates an xdg_toplevel object for the given xdg_surface and gives + the associated wl_surface the xdg_toplevel role. + + See the documentation of xdg_toplevel for more details about what an + xdg_toplevel is and how it is used. + </description> + <arg name="id" type="new_id" interface="zxdg_toplevel_v6"/> + </request> + + <request name="get_popup"> + <description summary="assign the xdg_popup surface role"> + This creates an xdg_popup object for the given xdg_surface and gives the + associated wl_surface the xdg_popup role. + + See the documentation of xdg_popup for more details about what an + xdg_popup is and how it is used. + </description> + <arg name="id" type="new_id" interface="zxdg_popup_v6"/> + <arg name="parent" type="object" interface="zxdg_surface_v6"/> + <arg name="positioner" type="object" interface="zxdg_positioner_v6"/> + </request> + + <request name="set_window_geometry"> + <description summary="set the new window geometry"> + The window geometry of a surface is its "visible bounds" from the + user's perspective. Client-side decorations often have invisible + portions like drop-shadows which should be ignored for the + purposes of aligning, placing and constraining windows. + + The window geometry is double buffered, and will be applied at the + time wl_surface.commit of the corresponding wl_surface is called. + + Once the window geometry of the surface is set, it is not possible to + unset it, and it will remain the same until set_window_geometry is + called again, even if a new subsurface or buffer is attached. + + If never set, the value is the full bounds of the surface, + including any subsurfaces. This updates dynamically on every + commit. This unset is meant for extremely simple clients. + + The arguments are given in the surface-local coordinate space of + the wl_surface associated with this xdg_surface. + + The width and height must be greater than zero. Setting an invalid size + will raise an error. When applied, the effective window geometry will be + the set window geometry clamped to the bounding rectangle of the + combined geometry of the surface of the xdg_surface and the associated + subsurfaces. + </description> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="ack_configure"> + <description summary="ack a configure event"> + When a configure event is received, if a client commits the + surface in response to the configure event, then the client + must make an ack_configure request sometime before the commit + request, passing along the serial of the configure event. + + For instance, for toplevel surfaces the compositor might use this + information to move a surface to the top left only when the client has + drawn itself for the maximized or fullscreen state. + + If the client receives multiple configure events before it + can respond to one, it only has to ack the last configure event. + + A client is not required to commit immediately after sending + an ack_configure request - it may even ack_configure several times + before its next surface commit. + + A client may send multiple ack_configure requests before committing, but + only the last request sent before a commit indicates which configure + event the client really is responding to. + </description> + <arg name="serial" type="uint" summary="the serial from the configure event"/> + </request> + + <event name="configure"> + <description summary="suggest a surface change"> + The configure event marks the end of a configure sequence. A configure + sequence is a set of one or more events configuring the state of the + xdg_surface, including the final xdg_surface.configure event. + + Where applicable, xdg_surface surface roles will during a configure + sequence extend this event as a latched state sent as events before the + xdg_surface.configure event. Such events should be considered to make up + a set of atomically applied configuration states, where the + xdg_surface.configure commits the accumulated state. + + Clients should arrange their surface for the new states, and then send + an ack_configure request with the serial sent in this configure event at + some point before committing the new surface. + + If the client receives multiple configure events before it can respond + to one, it is free to discard all but the last event it received. + </description> + <arg name="serial" type="uint" summary="serial of the configure event"/> + </event> + </interface> + + <interface name="zxdg_toplevel_v6" version="1"> + <description summary="toplevel surface"> + This interface defines an xdg_surface role which allows a surface to, + among other things, set window-like properties such as maximize, + fullscreen, and minimize, set application-specific metadata like title and + id, and well as trigger user interactive operations such as interactive + resize and move. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_toplevel"> + Unmap and destroy the window. The window will be effectively + hidden from the user's point of view, and all state like + maximization, fullscreen, and so on, will be lost. + </description> + </request> + + <request name="set_parent"> + <description summary="set the parent of this surface"> + Set the "parent" of this surface. This window should be stacked + above a parent. The parent surface must be mapped as long as this + surface is mapped. + + Parent windows should be set on dialogs, toolboxes, or other + "auxiliary" surfaces, so that the parent is raised when the dialog + is raised. + </description> + <arg name="parent" type="object" interface="zxdg_toplevel_v6" allow-null="true"/> + </request> + + <request name="set_title"> + <description summary="set surface title"> + Set a short title for the surface. + + This string may be used to identify the surface in a task bar, + window list, or other user interface elements provided by the + compositor. + + The string must be encoded in UTF-8. + </description> + <arg name="title" type="string"/> + </request> + + <request name="set_app_id"> + <description summary="set application ID"> + Set an application identifier for the surface. + + The app ID identifies the general class of applications to which + the surface belongs. The compositor can use this to group multiple + surfaces together, or to determine how to launch a new application. + + For D-Bus activatable applications, the app ID is used as the D-Bus + service name. + + The compositor shell will try to group application surfaces together + by their app ID. As a best practice, it is suggested to select app + ID's that match the basename of the application's .desktop file. + For example, "org.freedesktop.FooViewer" where the .desktop file is + "org.freedesktop.FooViewer.desktop". + + See the desktop-entry specification [0] for more details on + application identifiers and how they relate to well-known D-Bus + names and .desktop files. + + [0] http://standards.freedesktop.org/desktop-entry-spec/ + </description> + <arg name="app_id" type="string"/> + </request> + + <request name="show_window_menu"> + <description summary="show the window menu"> + Clients implementing client-side decorations might want to show + a context menu when right-clicking on the decorations, giving the + user a menu that they can use to maximize or minimize the window. + + This request asks the compositor to pop up such a window menu at + the given position, relative to the local surface coordinates of + the parent surface. There are no guarantees as to what menu items + the window menu contains. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. + </description> + <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + <arg name="x" type="int" summary="the x position to pop up the window menu at"/> + <arg name="y" type="int" summary="the y position to pop up the window menu at"/> + </request> + + <request name="move"> + <description summary="start an interactive move"> + Start an interactive, user-driven move of the surface. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. The passed + serial is used to determine the type of interactive move (touch, + pointer, etc). + + The server may ignore move requests depending on the state of + the surface (e.g. fullscreen or maximized), or if the passed serial + is no longer valid. + + If triggered, the surface will lose the focus of the device + (wl_pointer, wl_touch, etc) used for the move. It is up to the + compositor to visually indicate that the move is taking place, such as + updating a pointer cursor, during the move. There is no guarantee + that the device focus will return when the move is completed. + </description> + <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + </request> + + <enum name="resize_edge"> + <description summary="edge values for resizing"> + These values are used to indicate which edge of a surface + is being dragged in a resize operation. + </description> + <entry name="none" value="0"/> + <entry name="top" value="1"/> + <entry name="bottom" value="2"/> + <entry name="left" value="4"/> + <entry name="top_left" value="5"/> + <entry name="bottom_left" value="6"/> + <entry name="right" value="8"/> + <entry name="top_right" value="9"/> + <entry name="bottom_right" value="10"/> + </enum> + + <request name="resize"> + <description summary="start an interactive resize"> + Start a user-driven, interactive resize of the surface. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. The passed + serial is used to determine the type of interactive resize (touch, + pointer, etc). + + The server may ignore resize requests depending on the state of + the surface (e.g. fullscreen or maximized). + + If triggered, the client will receive configure events with the + "resize" state enum value and the expected sizes. See the "resize" + enum value for more details about what is required. The client + must also acknowledge configure events using "ack_configure". After + the resize is completed, the client will receive another "configure" + event without the resize state. + + If triggered, the surface also will lose the focus of the device + (wl_pointer, wl_touch, etc) used for the resize. It is up to the + compositor to visually indicate that the resize is taking place, + such as updating a pointer cursor, during the resize. There is no + guarantee that the device focus will return when the resize is + completed. + + The edges parameter specifies how the surface should be resized, + and is one of the values of the resize_edge enum. The compositor + may use this information to update the surface position for + example when dragging the top left corner. The compositor may also + use this information to adapt its behavior, e.g. choose an + appropriate cursor image. + </description> + <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + <arg name="edges" type="uint" summary="which edge or corner is being dragged"/> + </request> + + <enum name="state"> + <description summary="types of state on the surface"> + The different state values used on the surface. This is designed for + state values like maximized, fullscreen. It is paired with the + configure event to ensure that both the client and the compositor + setting the state can be synchronized. + + States set in this way are double-buffered. They will get applied on + the next commit. + </description> + <entry name="maximized" value="1" summary="the surface is maximized"> + <description summary="the surface is maximized"> + The surface is maximized. The window geometry specified in the configure + event must be obeyed by the client. + </description> + </entry> + <entry name="fullscreen" value="2" summary="the surface is fullscreen"> + <description summary="the surface is fullscreen"> + The surface is fullscreen. The window geometry specified in the configure + event must be obeyed by the client. + </description> + </entry> + <entry name="resizing" value="3" summary="the surface is being resized"> + <description summary="the surface is being resized"> + The surface is being resized. The window geometry specified in the + configure event is a maximum; the client cannot resize beyond it. + Clients that have aspect ratio or cell sizing configuration can use + a smaller size, however. + </description> + </entry> + <entry name="activated" value="4" summary="the surface is now activated"> + <description summary="the surface is now activated"> + Client window decorations should be painted as if the window is + active. Do not assume this means that the window actually has + keyboard or pointer focus. + </description> + </entry> + </enum> + + <request name="set_max_size"> + <description summary="set the maximum size"> + Set a maximum size for the window. + + The client can specify a maximum size so that the compositor does + not try to configure the window beyond this size. + + The width and height arguments are in window geometry coordinates. + See xdg_surface.set_window_geometry. + + Values set in this way are double-buffered. They will get applied + on the next commit. + + The compositor can use this information to allow or disallow + different states like maximize or fullscreen and draw accurate + animations. + + Similarly, a tiling window manager may use this information to + place and resize client windows in a more effective way. + + The client should not rely on the compositor to obey the maximum + size. The compositor may decide to ignore the values set by the + client and request a larger size. + + If never set, or a value of zero in the request, means that the + client has no expected maximum size in the given dimension. + As a result, a client wishing to reset the maximum size + to an unspecified state can use zero for width and height in the + request. + + Requesting a maximum size to be smaller than the minimum size of + a surface is illegal and will result in a protocol error. + + The width and height must be greater than or equal to zero. Using + strictly negative values for width and height will result in a + protocol error. + </description> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="set_min_size"> + <description summary="set the minimum size"> + Set a minimum size for the window. + + The client can specify a minimum size so that the compositor does + not try to configure the window below this size. + + The width and height arguments are in window geometry coordinates. + See xdg_surface.set_window_geometry. + + Values set in this way are double-buffered. They will get applied + on the next commit. + + The compositor can use this information to allow or disallow + different states like maximize or fullscreen and draw accurate + animations. + + Similarly, a tiling window manager may use this information to + place and resize client windows in a more effective way. + + The client should not rely on the compositor to obey the minimum + size. The compositor may decide to ignore the values set by the + client and request a smaller size. + + If never set, or a value of zero in the request, means that the + client has no expected minimum size in the given dimension. + As a result, a client wishing to reset the minimum size + to an unspecified state can use zero for width and height in the + request. + + Requesting a minimum size to be larger than the maximum size of + a surface is illegal and will result in a protocol error. + + The width and height must be greater than or equal to zero. Using + strictly negative values for width and height will result in a + protocol error. + </description> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="set_maximized"> + <description summary="maximize the window"> + Maximize the surface. + + After requesting that the surface should be maximized, the compositor + will respond by emitting a configure event with the "maximized" state + and the required window geometry. The client should then update its + content, drawing it in a maximized state, i.e. without shadow or other + decoration outside of the window geometry. The client must also + acknowledge the configure when committing the new content (see + ack_configure). + + It is up to the compositor to decide how and where to maximize the + surface, for example which output and what region of the screen should + be used. + + If the surface was already maximized, the compositor will still emit + a configure event with the "maximized" state. + </description> + </request> + + <request name="unset_maximized"> + <description summary="unmaximize the window"> + Unmaximize the surface. + + After requesting that the surface should be unmaximized, the compositor + will respond by emitting a configure event without the "maximized" + state. If available, the compositor will include the window geometry + dimensions the window had prior to being maximized in the configure + request. The client must then update its content, drawing it in a + regular state, i.e. potentially with shadow, etc. The client must also + acknowledge the configure when committing the new content (see + ack_configure). + + It is up to the compositor to position the surface after it was + unmaximized; usually the position the surface had before maximizing, if + applicable. + + If the surface was already not maximized, the compositor will still + emit a configure event without the "maximized" state. + </description> + </request> + + <request name="set_fullscreen"> + <description summary="set the window as fullscreen on a monitor"> + Make the surface fullscreen. + + You can specify an output that you would prefer to be fullscreen. + If this value is NULL, it's up to the compositor to choose which + display will be used to map this surface. + + If the surface doesn't cover the whole output, the compositor will + position the surface in the center of the output and compensate with + black borders filling the rest of the output. + </description> + <arg name="output" type="object" interface="wl_output" allow-null="true"/> + </request> + <request name="unset_fullscreen" /> + + <request name="set_minimized"> + <description summary="set the window as minimized"> + Request that the compositor minimize your surface. There is no + way to know if the surface is currently minimized, nor is there + any way to unset minimization on this surface. + + If you are looking to throttle redrawing when minimized, please + instead use the wl_surface.frame event for this, as this will + also work with live previews on windows in Alt-Tab, Expose or + similar compositor features. + </description> + </request> + + <event name="configure"> + <description summary="suggest a surface change"> + This configure event asks the client to resize its toplevel surface or + to change its state. The configured state should not be applied + immediately. See xdg_surface.configure for details. + + The width and height arguments specify a hint to the window + about how its surface should be resized in window geometry + coordinates. See set_window_geometry. + + If the width or height arguments are zero, it means the client + should decide its own window dimension. This may happen when the + compositor needs to configure the state of the surface but doesn't + have any information about any previous or expected dimension. + + The states listed in the event specify how the width/height + arguments should be interpreted, and possibly how it should be + drawn. + + Clients must send an ack_configure in response to this event. See + xdg_surface.configure and xdg_surface.ack_configure for details. + </description> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + <arg name="states" type="array"/> + </event> + + <event name="close"> + <description summary="surface wants to be closed"> + The close event is sent by the compositor when the user + wants the surface to be closed. This should be equivalent to + the user clicking the close button in client-side decorations, + if your application has any. + + This is only a request that the user intends to close the + window. The client may choose to ignore this request, or show + a dialog to ask the user to save their data, etc. + </description> + </event> + </interface> + + <interface name="zxdg_popup_v6" version="1"> + <description summary="short-lived, popup surfaces for menus"> + A popup surface is a short-lived, temporary surface. It can be used to + implement for example menus, popovers, tooltips and other similar user + interface concepts. + + A popup can be made to take an explicit grab. See xdg_popup.grab for + details. + + When the popup is dismissed, a popup_done event will be sent out, and at + the same time the surface will be unmapped. See the xdg_popup.popup_done + event for details. + + Explicitly destroying the xdg_popup object will also dismiss the popup and + unmap the surface. Clients that want to dismiss the popup when another + surface of their own is clicked should dismiss the popup using the destroy + request. + + The parent surface must have either the xdg_toplevel or xdg_popup surface + role. + + A newly created xdg_popup will be stacked on top of all previously created + xdg_popup surfaces associated with the same xdg_toplevel. + + The parent of an xdg_popup must be mapped (see the xdg_surface + description) before the xdg_popup itself. + + The x and y arguments passed when creating the popup object specify + where the top left of the popup should be placed, relative to the + local surface coordinates of the parent surface. See + xdg_surface.get_popup. An xdg_popup must intersect with or be at least + partially adjacent to its parent surface. + + The client must call wl_surface.commit on the corresponding wl_surface + for the xdg_popup state to take effect. + </description> + + <enum name="error"> + <entry name="invalid_grab" value="0" + summary="tried to grab after being mapped"/> + </enum> + + <request name="destroy" type="destructor"> + <description summary="remove xdg_popup interface"> + This destroys the popup. Explicitly destroying the xdg_popup + object will also dismiss the popup, and unmap the surface. + + If this xdg_popup is not the "topmost" popup, a protocol error + will be sent. + </description> + </request> + + <request name="grab"> + <description summary="make the popup take an explicit grab"> + This request makes the created popup take an explicit grab. An explicit + grab will be dismissed when the user dismisses the popup, or when the + client destroys the xdg_popup. This can be done by the user clicking + outside the surface, using the keyboard, or even locking the screen + through closing the lid or a timeout. + + If the compositor denies the grab, the popup will be immediately + dismissed. + + This request must be used in response to some sort of user action like a + button press, key press, or touch down event. The serial number of the + event should be passed as 'serial'. + + The parent of a grabbing popup must either be an xdg_toplevel surface or + another xdg_popup with an explicit grab. If the parent is another + xdg_popup it means that the popups are nested, with this popup now being + the topmost popup. + + Nested popups must be destroyed in the reverse order they were created + in, e.g. the only popup you are allowed to destroy at all times is the + topmost one. + + When compositors choose to dismiss a popup, they may dismiss every + nested grabbing popup as well. When a compositor dismisses popups, it + will follow the same dismissing order as required from the client. + + The parent of a grabbing popup must either be another xdg_popup with an + active explicit grab, or an xdg_popup or xdg_toplevel, if there are no + explicit grabs already taken. + + If the topmost grabbing popup is destroyed, the grab will be returned to + the parent of the popup, if that parent previously had an explicit grab. + + If the parent is a grabbing popup which has already been dismissed, this + popup will be immediately dismissed. If the parent is a popup that did + not take an explicit grab, an error will be raised. + + During a popup grab, the client owning the grab will receive pointer + and touch events for all their surfaces as normal (similar to an + "owner-events" grab in X11 parlance), while the top most grabbing popup + will always have keyboard focus. + </description> + <arg name="seat" type="object" interface="wl_seat" + summary="the wl_seat of the user event"/> + <arg name="serial" type="uint" summary="the serial of the user event"/> + </request> + + <event name="configure"> + <description summary="configure the popup surface"> + This event asks the popup surface to configure itself given the + configuration. The configured state should not be applied immediately. + See xdg_surface.configure for details. + + The x and y arguments represent the position the popup was placed at + given the xdg_positioner rule, relative to the upper left corner of the + window geometry of the parent surface. + </description> + <arg name="x" type="int" + summary="x position relative to parent surface window geometry"/> + <arg name="y" type="int" + summary="y position relative to parent surface window geometry"/> + <arg name="width" type="int" summary="window geometry width"/> + <arg name="height" type="int" summary="window geometry height"/> + </event> + + <event name="popup_done"> + <description summary="popup interaction is done"> + The popup_done event is sent out when a popup is dismissed by the + compositor. The client should destroy the xdg_popup object at this + point. + </description> + </event> + + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xwayland-keyboard-grab/README b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xwayland-keyboard-grab/README new file mode 100644 index 0000000..dbe45a5 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xwayland-keyboard-grab/README @@ -0,0 +1,4 @@ +Xwayland keyboard grabbing protocol + +Maintainers: +Olivier Fourdan <ofourdan@redhat.com> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xwayland-keyboard-grab/xwayland-keyboard-grab-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xwayland-keyboard-grab/xwayland-keyboard-grab-unstable-v1.xml new file mode 100644 index 0000000..be4992f --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/unstable/xwayland-keyboard-grab/xwayland-keyboard-grab-unstable-v1.xml @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="xwayland_keyboard_grab_unstable_v1"> + + <copyright> + Copyright © 2017 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="Protocol for grabbing the keyboard from Xwayland"> + This protocol is application-specific to meet the needs of the X11 + protocol through Xwayland. It provides a way for Xwayland to request + all keyboard events to be forwarded to a surface even when the + surface does not have keyboard focus. + + In the X11 protocol, a client may request an "active grab" on the + keyboard. On success, all key events are reported only to the + grabbing X11 client. For details, see XGrabKeyboard(3). + + The core Wayland protocol does not have a notion of an active + keyboard grab. When running in Xwayland, X11 applications may + acquire an active grab inside Xwayland but that cannot be translated + to the Wayland compositor who may set the input focus to some other + surface. In doing so, it breaks the X11 client assumption that all + key events are reported to the grabbing client. + + This protocol specifies a way for Xwayland to request all keyboard + be directed to the given surface. The protocol does not guarantee + that the compositor will honor this request and it does not + prescribe user interfaces on how to handle the respond. For example, + a compositor may inform the user that all key events are now + forwarded to the given client surface, or it may ask the user for + permission to do so. + + Compositors are required to restrict access to this application + specific protocol to Xwayland alone. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible + changes may be added together with the corresponding interface + version bump. + Backward incompatible changes are done by bumping the version + number in the protocol and interface names and resetting the + interface version. Once the protocol is to be declared stable, + the 'z' prefix and the version number in the protocol and + interface names are removed and the interface version number is + reset. + </description> + + <interface name="zwp_xwayland_keyboard_grab_manager_v1" version="1"> + <description summary="context object for keyboard grab manager"> + A global interface used for grabbing the keyboard. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the keyboard grab manager"> + Destroy the keyboard grab manager. + </description> + </request> + + <request name="grab_keyboard"> + <description summary="grab the keyboard to a surface"> + The grab_keyboard request asks for a grab of the keyboard, forcing + the keyboard focus for the given seat upon the given surface. + + The protocol provides no guarantee that the grab is ever satisfied, + and does not require the compositor to send an error if the grab + cannot ever be satisfied. It is thus possible to request a keyboard + grab that will never be effective. + + The protocol: + + * does not guarantee that the grab itself is applied for a surface, + the grab request may be silently ignored by the compositor, + * does not guarantee that any events are sent to this client even + if the grab is applied to a surface, + * does not guarantee that events sent to this client are exhaustive, + a compositor may filter some events for its own consumption, + * does not guarantee that events sent to this client are continuous, + a compositor may change and reroute keyboard events while the grab + is nominally active. + </description> + + <arg name="id" type="new_id" interface="zwp_xwayland_keyboard_grab_v1"/> + <arg name="surface" type="object" interface="wl_surface" + summary="surface to report keyboard events to"/> + <arg name="seat" type="object" interface="wl_seat" + summary="the seat for which the keyboard should be grabbed"/> + </request> + </interface> + + <interface name="zwp_xwayland_keyboard_grab_v1" version="1"> + <description summary="interface for grabbing the keyboard"> + A global interface used for grabbing the keyboard. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the grabbed keyboard object"> + Destroy the grabbed keyboard object. If applicable, the compositor + will ungrab the keyboard. + </description> + </request> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/wayland-protocols-uninstalled.pc.in b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/wayland-protocols-uninstalled.pc.in new file mode 100644 index 0000000..cf7adf2 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/wayland-protocols-uninstalled.pc.in @@ -0,0 +1,5 @@ +pkgdatadir=@abs_top_srcdir@ + +Name: Wayland Protocols +Description: Wayland protocol files (not installed) +Version: @WAYLAND_PROTOCOLS_VERSION@ diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/wayland-protocols.pc.in b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/wayland-protocols.pc.in new file mode 100644 index 0000000..379be06 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/protocols/wayland-protocols.pc.in @@ -0,0 +1,7 @@ +prefix=@prefix@ +datarootdir=@datarootdir@ +pkgdatadir=${pc_sysrootdir}@datadir@/@PACKAGE@ + +Name: Wayland Protocols +Description: Wayland protocol files +Version: @WAYLAND_PROTOCOLS_VERSION@ diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/src/lib.rs b/third_party/cargo/vendor/wayland-protocols-0.21.13/src/lib.rs new file mode 100644 index 0000000..a8f2a2c --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/src/lib.rs @@ -0,0 +1,43 @@ +//! This crate provides bindings to the official wayland protocol extensions +//! provided in https://cgit.freedesktop.org/wayland/wayland-protocols +//! +//! These bindings are built on top of the crates wayland-client and wayland-server. +//! +//! Each protocol module contains a `client` and a `server` submodules, for each side of the +//! protocol. The creation of these modules (and the dependency on the associated crate) is +//! controlled by the two cargo features `client` and `server`. +//! +//! The cargo feature `unstable_protocols` adds an `unstable` module, containing bindings +//! to protocols that are not yet considered stable. As such, no stability guarantee is +//! given for these protocols. +//! +//! Some protocols require unstable rust features, the inclusion of them is controlled +//! by the cargo feature `nightly`. + +#![warn(missing_docs)] + +#[cfg(feature = "client")] +extern crate wayland_client; + +#[cfg(feature = "server")] +extern crate wayland_server; + +extern crate wayland_commons; + +#[cfg(feature = "native_lib")] +#[macro_use] +extern crate wayland_sys; + +#[macro_use] +extern crate bitflags; + +#[macro_use] +mod protocol_macro; + +#[cfg(feature = "unstable_protocols")] +pub mod unstable; + +pub mod wlr; + +mod stable; +pub use stable::*; diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/src/protocol_macro.rs b/third_party/cargo/vendor/wayland-protocols-0.21.13/src/protocol_macro.rs new file mode 100644 index 0000000..0290987 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/src/protocol_macro.rs @@ -0,0 +1,112 @@ +#[macro_escape] +macro_rules! wayland_protocol( + ($name: expr, [$(($import: ident, $interface: ident)),*], [$(($prot_name:ident, $prot_import: ident, $prot_iface: ident)),*]) => { + #[cfg(feature = "client")] + pub use self::generated::client; + + #[cfg(feature = "server")] + pub use self::generated::server; + + #[cfg(all(feature = "native_lib", any(feature = "client", feature = "server")))] + pub use self::generated::c_interfaces; + + #[cfg(all(not(feature = "native_lib"), any(feature = "client", feature = "server")))] + mod generated { + #![allow(dead_code,non_camel_case_types,unused_unsafe,unused_variables)] + #![allow(non_upper_case_globals,non_snake_case,unused_imports)] + #![allow(missing_docs)] + + #[cfg(feature = "client")] + pub mod client { + //! Client-side API of this protocol + pub(crate) use wayland_client::{NewProxy, Proxy, ProxyMap}; + pub(crate) use wayland_commons::map::{Object, ObjectMetadata}; + pub(crate) use wayland_commons::{AnonymousObject, Interface, MessageGroup}; + pub(crate) use wayland_commons::wire::{Argument, MessageDesc, ArgumentType, Message}; + pub(crate) use wayland_client::protocol::{$($import),*}; + $( + pub(crate) use ::$prot_name::client::$prot_import; + )* + include!(concat!(env!("OUT_DIR"), "/", $name, "_rust_client_api.rs")); + } + + #[cfg(feature = "server")] + pub mod server { + //! Server-side API of this protocol + pub(crate) use wayland_server::{NewResource, Resource, ResourceMap}; + pub(crate) use wayland_commons::map::{Object, ObjectMetadata}; + pub(crate) use wayland_commons::{AnonymousObject, Interface, MessageGroup}; + pub(crate) use wayland_commons::wire::{Argument, MessageDesc, ArgumentType, Message}; + pub(crate) use wayland_server::protocol::{$($import),*}; + $( + pub(crate) use ::$prot_name::server::$prot_import; + )* + include!(concat!(env!("OUT_DIR"), "/", $name, "_rust_server_api.rs")); + } + } + + #[cfg(all(feature = "native_lib", any(feature = "client", feature = "server")))] + mod generated { + #![allow(dead_code,non_camel_case_types,unused_unsafe,unused_variables)] + #![allow(non_upper_case_globals,non_snake_case,unused_imports)] + #![allow(missing_docs)] + + pub mod c_interfaces { + //! C interfaces for this protocol + + // import client or server, both are the same anyway + #[cfg(feature = "client")] + pub use wayland_client::sys::protocol_interfaces::{$($interface),*}; + #[cfg(all(not(feature = "client"), feature = "server"))] + pub use wayland_server::sys::protocol_interfaces::{$($interface),*}; + $( + pub(crate) use ::$prot_name::c_interfaces::$prot_iface; + )* + include!(concat!(env!("OUT_DIR"), "/", $name, "_c_interfaces.rs")); + } + + #[cfg(feature = "client")] + pub mod client { + //! Client-side API of this protocol + pub(crate) use wayland_client::{NewProxy, Proxy, ProxyMap}; + pub(crate) use wayland_commons::map::{Object, ObjectMetadata}; + pub(crate) use wayland_commons::{AnonymousObject, Interface, MessageGroup}; + pub(crate) use wayland_commons::wire::{Argument, MessageDesc, ArgumentType, Message}; + pub(crate) use wayland_sys as sys; + pub(crate) use wayland_client::protocol::{$($import),*}; + $( + pub(crate) use ::$prot_name::client::$prot_import; + )* + include!(concat!(env!("OUT_DIR"), "/", $name, "_c_client_api.rs")); + } + + #[cfg(feature = "server")] + pub mod server { + //! Server-side API of this protocol + pub(crate) use wayland_server::{NewResource, Resource, ResourceMap}; + pub(crate) use wayland_commons::map::{Object, ObjectMetadata}; + pub(crate) use wayland_commons::{AnonymousObject, Interface, MessageGroup}; + pub(crate) use wayland_commons::wire::{Argument, MessageDesc, ArgumentType, Message}; + pub(crate) use wayland_sys as sys; + pub(crate) use wayland_server::protocol::{$($import),*}; + $( + pub(crate) use ::$prot_name::server::$prot_import; + )* + include!(concat!(env!("OUT_DIR"), "/", $name, "_c_server_api.rs")); + } + } + } +); + +#[cfg(feature = "unstable_protocols")] +#[macro_escape] +macro_rules! wayland_protocol_versioned( + ($name: expr, [$($version: ident),*], $std_imports:tt, $prot_imports:tt) => { + $( + #[allow(missing_docs)] + pub mod $version { + wayland_protocol!(concat!($name, "-", stringify!($version)), $std_imports, $prot_imports); + } + )* + } +); diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/src/stable.rs b/third_party/cargo/vendor/wayland-protocols-0.21.13/src/stable.rs new file mode 100644 index 0000000..89cc47b --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/src/stable.rs @@ -0,0 +1,47 @@ +#![cfg_attr(rustfmt, rustfmt_skip)] + +pub mod presentation_time { + //! Presentation time protocol + //! + //! Allows precise feedback on presentation timing for example for smooth video playback. + + wayland_protocol!( + "presentation-time", + [ + (wl_surface, wl_surface_interface), + (wl_output, wl_output_interface) + ], + [] + ); +} + +pub mod xdg_shell { + //! XDG Shell protocol + //! + //! Exposes the `xdg_wm_base` global, which deprecates and replace `wl_shell`. + + wayland_protocol!( + "xdg-shell", + [ + (wl_seat, wl_seat_interface), + (wl_surface, wl_surface_interface), + (wl_output, wl_output_interface) + ], + [] + ); +} + +pub mod viewporter { + //! Viewporter protocol + //! + //! Gives the capability to scale and crop surfaces, decorrelating the surface dimensions from + //! the size of the buffer. + + wayland_protocol!( + "viewporter", + [ + (wl_surface, wl_surface_interface) + ], + [] + ); +} diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/src/unstable.rs b/third_party/cargo/vendor/wayland-protocols-0.21.13/src/unstable.rs new file mode 100644 index 0000000..95c5528 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/src/unstable.rs @@ -0,0 +1,441 @@ +//! Unstable protocols from wayland-protocols +//! +//! The protocols described in this module are experimental and +//! backward incompatible changes may be made. Backward compatible +//! changes may be added together with the corresponding interface +//! version bump. +//! +//! Backward incompatible changes are done by bumping the version +//! number in the protocol and interface names and resetting the +//! interface version. Once the protocol is to be declared stable, +//! the 'z' prefix and the version number in the protocol and +//! interface names are removed and the interface version number is +//! reset. + +#![cfg_attr(rustfmt, rustfmt_skip)] + +pub mod fullscreen_shell { + //! Fullscreen shell protocol + + wayland_protocol_versioned!( + "fullscreen-shell", + [v1], + [ + (wl_surface, wl_surface_interface), + (wl_output, wl_output_interface) + ], + [] + ); +} + +pub mod idle_inhibit { + //! Screensaver inhibition protocol + + wayland_protocol_versioned!( + "idle-inhibit", + [v1], + [(wl_surface, wl_surface_interface)], + [] + ); +} + + +pub mod input_method { + //! Input method protocol + + wayland_protocol_versioned!( + "input-method", + [v1], + [ + (wl_surface, wl_surface_interface), + (wl_output, wl_output_interface), + (wl_keyboard, wl_keyboard_interface) + ], + [] + ); +} + +pub mod input_timestamps { + //! Input timestamps protocol + + wayland_protocol_versioned!( + "input-timestamps", + [v1], + [ + (wl_keyboard, wl_keyboard_interface), + (wl_pointer, wl_pointer_interface), + (wl_touch, wl_touch_interface) + ], + [] + ); +} + +pub mod keyboard_shortcuts_inhibit { + //! Protocol for inhibiting the compositor keyboard shortcuts + //! + //! This protocol specifies a way for a client to request the compositor + //! to ignore its own keyboard shortcuts for a given seat, so that all + //! key events from that seat get forwarded to a surface. + + wayland_protocol_versioned!( + "keyboard-shortcuts-inhibit", + [v1], + [ + (wl_seat, wl_seat_interface), + (wl_surface, wl_surface_interface) + ], + [] + ); +} + +pub mod linux_dmabuf { + //! Linux DMA-BUF protocol + + wayland_protocol_versioned!( + "linux-dmabuf", + [v1], + [(wl_buffer, wl_buffer_interface)], + [] + ); +} + +pub mod linux_explicit_synchronization { + //! Linux explicit synchronization protocol + + wayland_protocol_versioned!( + "linux-explicit-synchronization", + [v1], + [ + (wl_surface, wl_surface_interface) + ], + [] + ); +} + +pub mod pointer_constraints { + //! protocol for constraining pointer motions + //! + //! This protocol specifies a set of interfaces used for adding constraints to + //! the motion of a pointer. Possible constraints include confining pointer + //! motions to a given region, or locking it to its current position. + //! + //! In order to constrain the pointer, a client must first bind the global + //! interface "wp_pointer_constraints" which, if a compositor supports pointer + //! constraints, is exposed by the registry. Using the bound global object, the + //! client uses the request that corresponds to the type of constraint it wants + //! to make. See wp_pointer_constraints for more details. + + wayland_protocol_versioned!( + "pointer-constraints", + [v1], + [ + (wl_surface, wl_surface_interface), + (wl_pointer, wl_pointer_interface), + (wl_region, wl_region_interface) + ], + [] + ); +} + +pub mod pointer_gestures { + //! Pointer gestures protocol + + wayland_protocol_versioned!( + "pointer-gestures", + [v1], + [ + (wl_surface, wl_surface_interface), + (wl_pointer, wl_pointer_interface) + ], + [] + ); +} + +pub mod primary_selection { + //! Primary selection protocol + + wayland_protocol_versioned!( + "primary-selection", + [v1], + [ + (wl_seat, wl_seat_interface) + ], + [] + ); +} + +pub mod relative_pointer { + //! protocol for relative pointer motion events + //! + //! This protocol specifies a set of interfaces used for making clients able to + //! receive relative pointer events not obstructed by barriers (such as the + //! monitor edge or other pointer barriers). + //! + //! To start receiving relative pointer events, a client must first bind the + //! global interface "wp_relative_pointer_manager" which, if a compositor + //! supports relative pointer motion events, is exposed by the registry. After + //! having created the relative pointer manager proxy object, the client uses + //! it to create the actual relative pointer object using the + //! "get_relative_pointer" request given a wl_pointer. The relative pointer + //! motion events will then, when applicable, be transmitted via the proxy of + //! the newly created relative pointer object. See the documentation of the + //! relative pointer interface for more details. + + wayland_protocol_versioned!( + "relative-pointer", + [v1], + [(wl_pointer, wl_pointer_interface)], + [] + ); +} + +pub mod tablet { + //! Wayland protocol for graphics tablets + //! + //! This description provides a high-level overview of the interplay between + //! the interfaces defined this protocol. For details, see the protocol + //! specification. + //! + //! More than one tablet may exist, and device-specifics matter. Tablets are + //! not represented by a single virtual device like wl_pointer. A client + //! binds to the tablet manager object which is just a proxy object. From + //! that, the client requests wp_tablet_manager.get_tablet_seat(wl_seat) + //! and that returns the actual interface that has all the tablets. With + //! this indirection, we can avoid merging wp_tablet into the actual Wayland + //! protocol, a long-term benefit. + //! + //! The wp_tablet_seat sends a "tablet added" event for each tablet + //! connected. That event is followed by descriptive events about the + //! hardware; currently that includes events for name, vid/pid and + //! a wp_tablet.path event that describes a local path. This path can be + //! used to uniquely identify a tablet or get more information through + //! libwacom. Emulated or nested tablets can skip any of those, e.g. a + //! virtual tablet may not have a vid/pid. The sequence of descriptive + //! events is terminated by a wp_tablet.done event to signal that a client + //! may now finalize any initialization for that tablet. + //! + //! Events from tablets require a tool in proximity. Tools are also managed + //! by the tablet seat; a "tool added" event is sent whenever a tool is new + //! to the compositor. That event is followed by a number of descriptive + //! events about the hardware; currently that includes capabilities, + //! hardware id and serial number, and tool type. Similar to the tablet + //! interface, a wp_tablet_tool.done event is sent to terminate that initial + //! sequence. + //! + //! Any event from a tool happens on the wp_tablet_tool interface. When the + //! tool gets into proximity of the tablet, a proximity_in event is sent on + //! the wp_tablet_tool interface, listing the tablet and the surface. That + //! event is followed by a motion event with the coordinates. After that, + //! it's the usual motion, axis, button, etc. events. The protocol's + //! serialisation means events are grouped by wp_tablet_tool.frame events. + //! + //! Two special events (that don't exist in X) are down and up. They signal + //! "tip touching the surface". For tablets without real proximity + //! detection, the sequence is: proximity_in, motion, down, frame. + //! + //! When the tool leaves proximity, a proximity_out event is sent. If any + //! button is still down, a button release event is sent before this + //! proximity event. These button events are sent in the same frame as the + //! proximity event to signal to the client that the buttons were held when + //! the tool left proximity. + //! + //! If the tool moves out of the surface but stays in proximity (i.e. + //! between windows), compositor-specific grab policies apply. This usually + //! means that the proximity-out is delayed until all buttons are released. + //! + //! Moving a tool physically from one tablet to the other has no real effect + //! on the protocol, since we already have the tool object from the "tool + //! added" event. All the information is already there and the proximity + //! events on both tablets are all a client needs to reconstruct what + //! happened. + //! + //! Some extra axes are normalized, i.e. the client knows the range as + //! specified in the protocol (e.g. [0, 65535]), the granularity however is + //! unknown. The current normalized axes are pressure, distance, and slider. + //! + //! Other extra axes are in physical units as specified in the protocol. + //! The current extra axes with physical units are tilt, rotation and + //! wheel rotation. + //! + //! Since tablets work independently of the pointer controlled by the mouse, + //! the focus handling is independent too and controlled by proximity. + //! The wp_tablet_tool.set_cursor request sets a tool-specific cursor. + //! This cursor surface may be the same as the mouse cursor, and it may be + //! the same across tools but it is possible to be more fine-grained. For + //! example, a client may set different cursors for the pen and eraser. + //! + //! Tools are generally independent of tablets and it is + //! compositor-specific policy when a tool can be removed. Common approaches + //! will likely include some form of removing a tool when all tablets the + //! tool was used on are removed. + + wayland_protocol_versioned!( + "tablet", + [v1, v2], + [ + (wl_seat, wl_seat_interface), + (wl_surface, wl_surface_interface) + ], + [] + ); +} + +pub mod text_input { + //! Text input protocol + + wayland_protocol_versioned!( + "text-input", + [v1, v3], + [ + (wl_seat, wl_seat_interface), + (wl_surface, wl_surface_interface) + ], + [] + ); +} + +pub mod xdg_decoration { + //! This interface allows a compositor to announce support for server-side + //! decorations. + + //! A window decoration is a set of window controls as deemed appropriate by + //! the party managing them, such as user interface components used to move, + //! resize and change a window's state. + + //! A client can use this protocol to request being decorated by a supporting + //! compositor. + + //! If compositor and client do not negotiate the use of a server-side + //! decoration using this protocol, clients continue to self-decorate as they + //! see fit. + + wayland_protocol_versioned!( + "xdg-decoration", + [v1], + [], + [ + (xdg_shell, xdg_toplevel, xdg_toplevel_interface) + ] + ); +} + +pub mod xdg_foreign { + //! Protocol for exporting xdg surface handles + //! + //! This protocol specifies a way for making it possible to reference a surface + //! of a different client. With such a reference, a client can, by using the + //! interfaces provided by this protocol, manipulate the relationship between + //! its own surfaces and the surface of some other client. For example, stack + //! some of its own surface above the other clients surface. + //! + //! In order for a client A to get a reference of a surface of client B, client + //! B must first export its surface using xdg_exporter.export. Upon doing this, + //! client B will receive a handle (a unique string) that it may share with + //! client A in some way (for example D-Bus). After client A has received the + //! handle from client B, it may use xdg_importer.import to create a reference + //! to the surface client B just exported. See the corresponding requests for + //! details. + //! + //! A possible use case for this is out-of-process dialogs. For example when a + //! sandboxed client without file system access needs the user to select a file + //! on the file system, given sandbox environment support, it can export its + //! surface, passing the exported surface handle to an unsandboxed process that + //! can show a file browser dialog and stack it above the sandboxed client's + //! surface. + + wayland_protocol_versioned!( + "xdg-foreign", + [v1, v2], + [(wl_surface, wl_surface_interface)], + [] + ); +} + +pub mod xdg_output { + //! Protocol to describe output regions + //! + //! This protocol aims at describing outputs in a way which is more in line + //! with the concept of an output on desktop oriented systems. + //! + //! Some information are more specific to the concept of an output for + //! a desktop oriented system and may not make sense in other applications, + //! such as IVI systems for example. + //! + //! Typically, the global compositor space on a desktop system is made of + //! a contiguous or overlapping set of rectangular regions. + //! + //! Some of the information provided in this protocol might be identical + //! to their counterparts already available from wl_output, in which case + //! the information provided by this protocol should be preferred to their + //! equivalent in wl_output. The goal is to move the desktop specific + //! concepts (such as output location within the global compositor space, + //! the connector name and types, etc.) out of the core wl_output protocol. + + wayland_protocol_versioned!( + "xdg-output", + [v1], + [(wl_output, wl_output_interface)], + [] + ); +} + +pub mod xdg_shell { + //! XDG Shell protocol + //! + //! These are the old, unstable versions of the now stable XDG Shell protocol. + //! + //! They remain here for compatibility reasons, allowing you to support older + //! clients/server not yet implementing the new protocol. + + wayland_protocol_versioned!( + "xdg-shell", + [v5, v6], + [ + (wl_surface, wl_surface_interface), + (wl_output, wl_output_interface), + (wl_seat, wl_seat_interface) + ], + [] + ); +} + +pub mod xwayland_keyboard_grab { + //! Protocol for grabbing the keyboard from Xwayland + //! + //! This protocol is application-specific to meet the needs of the X11 + //! protocol through Xwayland. It provides a way for Xwayland to request + //! all keyboard events to be forwarded to a surface even when the + //! surface does not have keyboard focus. + //! + //! In the X11 protocol, a client may request an "active grab" on the + //! keyboard. On success, all key events are reported only to the + //! grabbing X11 client. For details, see XGrabKeyboard(3). + //! + //! The core Wayland protocol does not have a notion of an active + //! keyboard grab. When running in Xwayland, X11 applications may + //! acquire an active grab inside Xwayland but that cannot be translated + //! to the Wayland compositor who may set the input focus to some other + //! surface. In doing so, it breaks the X11 client assumption that all + //! key events are reported to the grabbing client. + //! + //! This protocol specifies a way for Xwayland to request all keyboard + //! be directed to the given surface. The protocol does not guarantee + //! that the compositor will honor this request and it does not + //! prescribe user interfaces on how to handle the respond. For example, + //! a compositor may inform the user that all key events are now + //! forwarded to the given client surface, or it may ask the user for + //! permission to do so. + //! + //! Compositors are required to restrict access to this application + //! specific protocol to Xwayland alone. + + wayland_protocol_versioned!( + "xwayland-keyboard-grab", + [v1], + [ + (wl_seat, wl_seat_interface), + (wl_surface, wl_surface_interface) + ], + [] + ); +} diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/src/wlr.rs b/third_party/cargo/vendor/wayland-protocols-0.21.13/src/wlr.rs new file mode 100644 index 0000000..2ab96ec --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/src/wlr.rs @@ -0,0 +1,130 @@ +//! wlr-procotols extension family +//! +//! This module regroup bindings to the protocol extensions from +//! [wlr-protocols](https://github.com/swaywm/wlr-protocols). + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#[cfg(feature = "unstable_protocols")] +pub mod unstable { + //! Unstable protocols from wlr-protocols + //! + //! The protocols described in this module are experimental and + //! backward incompatible changes may be made. Backward compatible + //! changes may be added together with the corresponding interface + //! version bump. + //! + //! Backward incompatible changes are done by bumping the version + //! number in the protocol and interface names and resetting the + //! interface version. Once the protocol is to be declared stable, + //! the 'z' prefix and the version number in the protocol and + //! interface names are removed and the interface version number is + //! reset. + + pub mod data_control { + //! Control data devices, particularly the clipboard. + //! + //! An interface to control data devices, particularly to manage the current selection and + //! take the role of a clipboard manager. + + wayland_protocol_versioned!( + "wlr-data-control", + [v1], + [ + (wl_seat, wl_seat_interface) + ], + [] + ); + } + + pub mod export_dmabuf { + //! A protocol for low overhead screen content capturing + //! + //! An interface to capture surfaces in an efficient way by exporting DMA-BUFs. + + wayland_protocol_versioned!( + "wlr-export-dmabuf", + [v1], + [ + (wl_output, wl_output_interface) + ], + [] + ); + } + + pub mod foreign_toplevel { + //! List and control opened apps + //! + //! Use for creating taskbars and docks. + + wayland_protocol_versioned!( + "wlr-foreign-toplevel-management", + [v1], + [ + (wl_seat, wl_seat_interface), + (wl_surface, wl_surface_interface), + (wl_output, wl_output_interface) + ], + [] + ); + } + + pub mod gamma_control { + //! Manage gamma tables of outputs. + //! + //! This protocol allows a privileged client to set the gamma tables for outputs. + + wayland_protocol_versioned!( + "wlr-gamma-control", + [v1], + [ + (wl_output, wl_output_interface) + ], + [] + ); + } + + pub mod input_inhibitor { + //! Inhibits input events to other clients + + wayland_protocol_versioned!( + "wlr-input-inhibitor", + [v1], + [], + [] + ); + } + + pub mod layer_shell { + //! Layered shell protocol + + wayland_protocol_versioned!( + "wlr-layer-shell", + [v1], + [ + (wl_output, wl_output_interface), + (wl_surface, wl_surface_interface) + ], + [ + (xdg_shell, xdg_popup, xdg_popup_interface) + ] + ); + } + + pub mod screencopy { + //! Screen content capturing on client buffers + //! + //! This protocol allows clients to ask the compositor to copy part of the + //! screen content to a client buffer. + + wayland_protocol_versioned!( + "wlr-screencopy", + [v1], + [ + (wl_buffer, wl_buffer_interface), + (wl_output, wl_output_interface) + ], + [] + ); + } +} diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/Makefile b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/Makefile new file mode 100644 index 0000000..4716187 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/Makefile @@ -0,0 +1,38 @@ +PREFIX=/usr +DATADIR=$${datarootdir} +DATAROOTDIR=$${prefix}/share + +unstable_protocols = \ + unstable/wlr-export-dmabuf-unstable-v1.xml \ + unstable/wlr-gamma-control-unstable-v1.xml \ + unstable/wlr-input-inhibitor-unstable-v1.xml \ + unstable/wlr-layer-shell-unstable-v1.xml \ + unstable/wlr-screencopy-unstable-v1.xml + +check: + ./check.sh + +clean: + rm -f wlr-protocols.pc + +wlr-protocols.pc: wlr-protocols.pc.in + sed \ + -e 's:@prefix@:$(PREFIX):g' \ + -e 's:@datadir@:$(DATADIR):g' \ + -e 's:@datarootdir@:$(DATAROOTDIR):g' \ + <$< >$@ + +install-unstable: $(unstable_protocols) + mkdir -p $(DESTDIR)$(PREFIX)/share/wlr-protocols/unstable + for protocol in $^ ; \ + do \ + install -Dm644 $$protocol \ + $(DESTDIR)$(PREFIX)/share/wlr-protocols/$$protocol ; \ + done + +install-pc: wlr-protocols.pc + mkdir -p $(DESTDIR)$(PREFIX)/share/pkgconfig/ + install -Dm644 wlr-protocols.pc \ + $(DESTDIR)$(PREFIX)/share/pkgconfig/wlr-protocols.pc + +install: install-unstable install-pc diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/check.sh b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/check.sh new file mode 100755 index 0000000..33fa26d --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/check.sh @@ -0,0 +1,9 @@ +#!/bin/sh -eux + +for f in $(echo unstable/*.xml) +do + wayland-scanner -s client-header "$f" /dev/null + wayland-scanner -s server-header "$f" /dev/null + wayland-scanner -s public-code "$f" /dev/null + wayland-scanner -s private-code "$f" /dev/null +done diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-data-control-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-data-control-unstable-v1.xml new file mode 100644 index 0000000..a588755 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-data-control-unstable-v1.xml @@ -0,0 +1,224 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="wlr_data_control_unstable_v1"> + <copyright> + Copyright © 2018 Simon Ser + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + the copyright holders not be used in advertising or publicity + pertaining to distribution of the software without specific, + written prior permission. The copyright holders make no + representations about the suitability of this software for any + purpose. It is provided "as is" without express or implied + warranty. + + THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + THIS SOFTWARE. + </copyright> + + <description summary="control data devices"> + This protocol allows a privileged client to control data devices. In + particular, the client will be able to manage the current selection and take + the role of a clipboard manager. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <interface name="zwlr_data_control_manager_v1" version="1"> + <description summary="manager to control data devices"> + This interface is a manager that allows creating per-seat data device + controls. + </description> + + <request name="create_data_source"> + <description summary="create a new data source"> + Create a new data source. + </description> + <arg name="id" type="new_id" interface="zwlr_data_control_source_v1" + summary="data source to create"/> + </request> + + <request name="get_data_device"> + <description summary="get a data device for a seat"> + Create a data device that can be used to manage a seat's selection. + </description> + <arg name="id" type="new_id" interface="zwlr_data_control_device_v1"/> + <arg name="seat" type="object" interface="wl_seat"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the manager"> + All objects created by the manager will still remain valid, until their + appropriate destroy request has been called. + </description> + </request> + </interface> + + <interface name="zwlr_data_control_device_v1" version="1"> + <description summary="manage a data device for a seat"> + This interface allows a client to manage a seat's selection. + + When the seat is destroyed, this object becomes inert. + </description> + + <request name="set_selection"> + <description summary="copy data to the selection"> + All objects created by the device will still remain valid, until their + appropriate destroy request has been called. + </description> + <arg name="source" type="object" interface="zwlr_data_control_source_v1" + allow-null="true"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy this data device"> + Destroys the data device object. + </description> + </request> + + <event name="data_offer"> + <description summary="introduce a new wlr_data_control_offer"> + The data_offer event introduces a new wlr_data_control_offer object, + which will subsequently be used in the wlr_data_control_device.selection + event. Immediately following the wlr_data_control_device.data_offer + event, the new data_offer object will send out + wlr_data_control_offer.offer events to describe the MIME types it + offers. + + This event replaces the previous data offer, which should be destroyed + by the client. + </description> + <arg name="id" type="new_id" interface="zwlr_data_control_offer_v1"/> + </event> + + <event name="selection"> + <description summary="introduce a new wlr_data_control_offer"> + The selection event is sent out to notify the client of a new + wlr_data_control_offer for the selection for this device. The + wlr_data_control_device.data_offer and the wlr_data_control_offer.offer + events are sent out immediately before this event to introduce the data + offer object. The selection event is sent to a client when a new + selection is set. The wlr_data_control_offer is valid until a new + wlr_data_control_offer or NULL is received. The client must destroy the + previous selection wlr_data_control_offer, if any, upon receiving this + event. + </description> + <arg name="id" type="object" interface="zwlr_data_control_offer_v1" + allow-null="true"/> + </event> + + <event name="finished"> + <description summary="this data control is no longer valid"> + This data control object is no longer valid and should be destroyed by + the client. + </description> + </event> + </interface> + + <interface name="zwlr_data_control_source_v1" version="1"> + <description summary="offer to transfer data"> + The wlr_data_control_source object is the source side of a + wlr_data_control_offer. It is created by the source client in a data + transfer and provides a way to describe the offered data and a way to + respond to requests to transfer the data. + </description> + + <enum name="error"> + <entry name="invalid_offer" value="1" + summary="offer sent after wlr_data_control_device.set_selection"/> + </enum> + + <request name="offer"> + <description summary="add an offered MIME type"> + This request adds a MIME type to the set of MIME types advertised to + targets. Can be called several times to offer multiple types. + + Calling this after wlr_data_control_device.set_selection is a protocol + error. + </description> + <arg name="mime_type" type="string" + summary="MIME type offered by the data source"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy this source"> + Destroys the data source object. + </description> + </request> + + <event name="send"> + <description summary="send the data"> + Request for data from the client. Send the data as the specified MIME + type over the passed file descriptor, then close it. + </description> + <arg name="mime_type" type="string" summary="MIME type for the data"/> + <arg name="fd" type="fd" summary="file descriptor for the data"/> + </event> + + <event name="cancelled"> + <description summary="selection was cancelled"> + This data source is no longer valid. The data source has been replaced + by another data source. + + The client should clean up and destroy this data source. + </description> + </event> + </interface> + + <interface name="zwlr_data_control_offer_v1" version="1"> + <description summary="offer to transfer data"> + A wlr_data_control_offer represents a piece of data offered for transfer + by another client (the source client). The offer describes the different + MIME types that the data can be converted to and provides the mechanism + for transferring the data directly from the source client. + </description> + + <request name="receive"> + <description summary="request that the data is transferred"> + To transfer the offered data, the client issues this request and + indicates the MIME type it wants to receive. The transfer happens + through the passed file descriptor (typically created with the pipe + system call). The source client writes the data in the MIME type + representation requested and then closes the file descriptor. + + The receiving client reads from the read end of the pipe until EOF and + then closes its end, at which point the transfer is complete. + + This request may happen multiple times for different MIME types. + </description> + <arg name="mime_type" type="string" + summary="MIME type desired by receiver"/> + <arg name="fd" type="fd" summary="file descriptor for data transfer"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy this offer"> + Destroys the data offer object. + </description> + </request> + + <event name="offer"> + <description summary="advertise offered MIME type"> + Sent immediately after creating the wlr_data_control_offer object. + One event per offered MIME type. + </description> + <arg name="mime_type" type="string" summary="offered MIME type"/> + </event> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-export-dmabuf-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-export-dmabuf-unstable-v1.xml new file mode 100644 index 0000000..751f7ef --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-export-dmabuf-unstable-v1.xml @@ -0,0 +1,203 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="wlr_export_dmabuf_unstable_v1"> + <copyright> + Copyright © 2018 Rostislav Pehlivanov + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="a protocol for low overhead screen content capturing"> + An interface to capture surfaces in an efficient way by exporting DMA-BUFs. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <interface name="zwlr_export_dmabuf_manager_v1" version="1"> + <description summary="manager to inform clients and begin capturing"> + This object is a manager with which to start capturing from sources. + </description> + + <request name="capture_output"> + <description summary="capture a frame from an output"> + Capture the next frame of a an entire output. + </description> + <arg name="frame" type="new_id" interface="zwlr_export_dmabuf_frame_v1"/> + <arg name="overlay_cursor" type="int" + summary="include custom client hardware cursor on top of the frame"/> + <arg name="output" type="object" interface="wl_output"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the manager"> + All objects created by the manager will still remain valid, until their + appropriate destroy request has been called. + </description> + </request> + </interface> + + <interface name="zwlr_export_dmabuf_frame_v1" version="1"> + <description summary="a DMA-BUF frame"> + This object represents a single DMA-BUF frame. + + If the capture is successful, the compositor will first send a "frame" + event, followed by one or several "object". When the frame is available + for readout, the "ready" event is sent. + + If the capture failed, the "cancel" event is sent. This can happen anytime + before the "ready" event. + + Once either a "ready" or a "cancel" event is received, the client should + destroy the frame. Once an "object" event is received, the client is + responsible for closing the associated file descriptor. + + All frames are read-only and may not be written into or altered. + </description> + + <enum name="flags"> + <description summary="frame flags"> + Special flags that should be respected by the client. + </description> + <entry name="transient" value="0x1" + summary="clients should copy frame before processing"/> + </enum> + + <event name="frame"> + <description summary="a frame description"> + Main event supplying the client with information about the frame. If the + capture didn't fail, this event is always emitted first before any other + events. + + This event is followed by a number of "object" as specified by the + "num_objects" argument. + </description> + <arg name="width" type="uint" + summary="frame width in pixels"/> + <arg name="height" type="uint" + summary="frame height in pixels"/> + <arg name="offset_x" type="uint" + summary="crop offset for the x axis"/> + <arg name="offset_y" type="uint" + summary="crop offset for the y axis"/> + <arg name="buffer_flags" type="uint" + summary="flags which indicate properties (invert, interlacing), + has the same values as zwp_linux_buffer_params_v1:flags"/> + <arg name="flags" type="uint" enum="flags" + summary="indicates special frame features"/> + <arg name="format" type="uint" + summary="format of the frame (DRM_FORMAT_*)"/> + <arg name="mod_high" type="uint" + summary="drm format modifier, high"/> + <arg name="mod_low" type="uint" + summary="drm format modifier, low"/> + <arg name="num_objects" type="uint" + summary="indicates how many objects (FDs) the frame has (max 4)"/> + </event> + + <event name="object"> + <description summary="an object description"> + Event which serves to supply the client with the file descriptors + containing the data for each object. + + After receiving this event, the client must always close the file + descriptor as soon as they're done with it and even if the frame fails. + </description> + <arg name="index" type="uint" + summary="index of the current object"/> + <arg name="fd" type="fd" + summary="fd of the current object"/> + <arg name="size" type="uint" + summary="size in bytes for the current object"/> + <arg name="offset" type="uint" + summary="starting point for the data in the object's fd"/> + <arg name="stride" type="uint" + summary="line size in bytes"/> + <arg name="plane_index" type="uint" + summary="index of the the plane the data in the object applies to"/> + </event> + + <event name="ready"> + <description summary="indicates frame is available for reading"> + This event is sent as soon as the frame is presented, indicating it is + available for reading. This event includes the time at which + presentation happened at. + + The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples, + each component being an unsigned 32-bit value. Whole seconds are in + tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo, + and the additional fractional part in tv_nsec as nanoseconds. Hence, + for valid timestamps tv_nsec must be in [0, 999999999]. The seconds part + may have an arbitrary offset at start. + + After receiving this event, the client should destroy this object. + </description> + <arg name="tv_sec_hi" type="uint" + summary="high 32 bits of the seconds part of the timestamp"/> + <arg name="tv_sec_lo" type="uint" + summary="low 32 bits of the seconds part of the timestamp"/> + <arg name="tv_nsec" type="uint" + summary="nanoseconds part of the timestamp"/> + </event> + + <enum name="cancel_reason"> + <description summary="cancel reason"> + Indicates reason for cancelling the frame. + </description> + <entry name="temporary" value="0" + summary="temporary error, source will produce more frames"/> + <entry name="permanent" value="1" + summary="fatal error, source will not produce frames"/> + <entry name="resizing" value="2" + summary="temporary error, source will produce more frames"/> + </enum> + + <event name="cancel"> + <description summary="indicates the frame is no longer valid"> + If the capture failed or if the frame is no longer valid after the + "frame" event has been emitted, this event will be used to inform the + client to scrap the frame. + + If the failure is temporary, the client may capture again the same + source. If the failure is permanent, any further attempts to capture the + same source will fail again. + + After receiving this event, the client should destroy this object. + </description> + <arg name="reason" type="uint" enum="cancel_reason" + summary="indicates a reason for cancelling this frame capture"/> + </event> + + <request name="destroy" type="destructor"> + <description summary="delete this object, used or not"> + Unreferences the frame. This request must be called as soon as its no + longer used. + + It can be called at any time by the client. The client will still have + to close any FDs it has been given. + </description> + </request> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-foreign-toplevel-management-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-foreign-toplevel-management-unstable-v1.xml new file mode 100644 index 0000000..234d953 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-foreign-toplevel-management-unstable-v1.xml @@ -0,0 +1,235 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="wlr_foreign_toplevel_management_unstable_v1"> + <copyright> + Copyright © 2018 Ilia Bozhinov + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + the copyright holders not be used in advertising or publicity + pertaining to distribution of the software without specific, + written prior permission. The copyright holders make no + representations about the suitability of this software for any + purpose. It is provided "as is" without express or implied + warranty. + + THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + THIS SOFTWARE. + </copyright> + + <interface name="zwlr_foreign_toplevel_manager_v1" version="1"> + <description summary="list and control opened apps"> + The purpose of this protocol is to enable the creation of taskbars + and docks by providing them with a list of opened applications and + letting them request certain actions on them, like maximizing, etc. + + After a client binds the zwlr_foreign_toplevel_manager_v1, each opened + toplevel window will be sent via the toplevel event + </description> + + <event name="toplevel"> + <description summary="a toplevel has been created"> + This event is emitted whenever a new toplevel window is created. It + is emitted for all toplevels, regardless of the app that has created + them. + + All initial details of the toplevel(title, app_id, states, etc.) will + be sent immediately after this event via the corresponding events in + zwlr_foreign_toplevel_handle_v1. + </description> + <arg name="toplevel" type="new_id" interface="zwlr_foreign_toplevel_handle_v1"/> + </event> + + <request name="stop"> + <description summary="stop sending events"> + Indicates the client no longer wishes to receive events for new toplevels. + However the compositor may emit further toplevel_created events, until + the finished event is emitted. + + The client must not send any more requests after this one. + </description> + </request> + + <event name="finished"> + <description summary="the compositor has finished with the toplevel manager"> + This event indicates that the compositor is done sending events to the + zwlr_foreign_toplevel_manager_v1. The server will destroy the object + immediately after sending this request, so it will become invalid and + the client should free any resources associated with it. + </description> + </event> + </interface> + + <interface name="zwlr_foreign_toplevel_handle_v1" version="1"> + <description summary="an opened toplevel"> + A zwlr_foreign_toplevel_handle_v1 object represents an opened toplevel + window. Each app may have multiple opened toplevels. + + Each toplevel has a list of outputs it is visible on, conveyed to the + client with the output_enter and output_leave events. + </description> + + <event name="title"> + <description summary="title change"> + This event is emitted whenever the title of the toplevel changes. + </description> + <arg name="title" type="string"/> + </event> + + <event name="app_id"> + <description summary="app-id change"> + This event is emitted whenever the app-id of the toplevel changes. + </description> + <arg name="app_id" type="string"/> + </event> + + <event name="output_enter"> + <description summary="toplevel entered an output"> + This event is emitted whenever the toplevel becomes visible on + the given output. A toplevel may be visible on multiple outputs. + </description> + <arg name="output" type="object" interface="wl_output"/> + </event> + + <event name="output_leave"> + <description summary="toplevel left an output"> + This event is emitted whenever the toplevel stops being visible on + the given output. It is guaranteed that an entered-output event + with the same output has been emitted before this event. + </description> + <arg name="output" type="object" interface="wl_output"/> + </event> + + <request name="set_maximized"> + <description summary="requests that the toplevel be maximized"> + Requests that the toplevel be maximized. If the maximized state actually + changes, this will be indicated by the state event. + </description> + </request> + + <request name="unset_maximized"> + <description summary="requests that the toplevel be unmaximized"> + Requests that the toplevel be unmaximized. If the maximized state actually + changes, this will be indicated by the state event. + </description> + </request> + + <request name="set_minimized"> + <description summary="requests that the toplevel be minimized"> + Requests that the toplevel be minimized. If the minimized state actually + changes, this will be indicated by the state event. + </description> + </request> + + <request name="unset_minimized"> + <description summary="requests that the toplevel be unminimized"> + Requests that the toplevel be unminimized. If the minimized state actually + changes, this will be indicated by the state event. + </description> + </request> + + <request name="activate"> + <description summary="activate the toplevel"> + Request that this toplevel be activated on the given seat. + There is no guarantee the toplevel will be actually activated. + </description> + <arg name="seat" type="object" interface="wl_seat"/> + </request> + + <enum name="state"> + <description summary="types of states on the toplevel"> + The different states that a toplevel can have. These have the same meaning + as the states with the same names defined in xdg-toplevel + </description> + + <entry name="maximized" value="0" summary="the toplevel is maximized"/> + <entry name="minimized" value="1" summary="the toplevel is minimized"/> + <entry name="activated" value="2" summary="the toplevel is active"/> + </enum> + + <event name="state"> + <description summary="the toplevel state changed"> + This event is emitted immediately after the zlw_foreign_toplevel_handle_v1 + is created and each time the toplevel state changes, either because of a + compositor action or because of a request in this protocol. + </description> + + <arg name="state" type="array"/> + </event> + + <event name="done"> + <description summary="all information about the toplevel has been sent"> + This event is sent after all changes in the toplevel state have been + sent. + + This allows changes to the zwlr_foreign_toplevel_handle_v1 properties + to be seen as atomic, even if they happen via multiple events. + </description> + </event> + + <request name="close"> + <description summary="request that the toplevel be closed"> + Send a request to the toplevel to close itself. The compositor would + typically use a shell-specific method to carry out this request, for + example by sending the xdg_toplevel.close event. However, this gives + no guarantees the toplevel will actually be destroyed. If and when + this happens, the zwlr_foreign_toplevel_handle_v1.closed event will + be emitted. + </description> + </request> + + <request name="set_rectangle"> + <description summary="the rectangle which represents the toplevel"> + The rectangle of the surface specified in this request corresponds to + the place where the app using this protocol represents the given toplevel. + It can be used by the compositor as a hint for some operations, e.g + minimizing. The client is however not required to set this, in which + case the compositor is free to decide some default value. + + If the client specifies more than one rectangle, only the last one is + considered. + + The dimensions are given in surface-local coordinates. + Setting width=height=0 removes the already-set rectangle. + </description> + + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <enum name="error"> + <entry name="invalid_rectangle" value="0" + summary="the provided rectangle is invalid"/> + </enum> + + <event name="closed"> + <description summary="this toplevel has been destroyed"> + This event means the toplevel has been destroyed. It is guaranteed there + won't be any more events for this zwlr_foreign_toplevel_handle_v1. The + toplevel itself becomes inert so any requests will be ignored except the + destroy request. + </description> + </event> + + <request name="destroy" type="destructor"> + <description summary="destroy the zwlr_foreign_toplevel_handle_v1 object"> + Destroys the zwlr_foreign_toplevel_handle_v1 object. + + This request should be called either when the client does not want to + use the toplevel anymore or after the closed event to finalize the + destruction of the object. + </description> + </request> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-gamma-control-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-gamma-control-unstable-v1.xml new file mode 100644 index 0000000..7577661 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-gamma-control-unstable-v1.xml @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="wlr_gamma_control_unstable_v1"> + <copyright> + Copyright © 2015 Giulio camuffo + Copyright © 2018 Simon Ser + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + the copyright holders not be used in advertising or publicity + pertaining to distribution of the software without specific, + written prior permission. The copyright holders make no + representations about the suitability of this software for any + purpose. It is provided "as is" without express or implied + warranty. + + THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + THIS SOFTWARE. + </copyright> + + <description summary="manage gamma tables of outputs"> + This protocol allows a privileged client to set the gamma tables for + outputs. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <interface name="zwlr_gamma_control_manager_v1" version="1"> + <description summary="manager to create per-output gamma controls"> + This interface is a manager that allows creating per-output gamma + controls. + </description> + + <request name="get_gamma_control"> + <description summary="get a gamma control for an output"> + Create a gamma control that can be used to adjust gamma tables for the + provided output. + </description> + <arg name="id" type="new_id" interface="zwlr_gamma_control_v1"/> + <arg name="output" type="object" interface="wl_output"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the manager"> + All objects created by the manager will still remain valid, until their + appropriate destroy request has been called. + </description> + </request> + </interface> + + <interface name="zwlr_gamma_control_v1" version="1"> + <description summary="adjust gamma tables for an output"> + This interface allows a client to adjust gamma tables for a particular + output. + + The client will receive the gamma size, and will then be able to set gamma + tables. At any time the compositor can send a failed event indicating that + this object is no longer valid. + + There can only be at most one gamma control object per output, which + has exclusive access to this particular output. When the gamma control + object is destroyed, the gamma table is restored to its original value. + </description> + + <event name="gamma_size"> + <description summary="size of gamma ramps"> + Advertise the size of each gamma ramp. + + This event is sent immediately when the gamma control object is created. + </description> + <arg name="size" type="uint" summary="number of elements in a ramp"/> + </event> + + <enum name="error"> + <entry name="invalid_gamma" value="1" summary="invalid gamma tables"/> + </enum> + + <request name="set_gamma"> + <description summary="set the gamma table"> + Set the gamma table. The file descriptor can be memory-mapped to provide + the raw gamma table, which contains successive gamma ramps for the red, + green and blue channels. Each gamma ramp is an array of 16-byte unsigned + integers which has the same length as the gamma size. + + The file descriptor data must have the same length as three times the + gamma size. + </description> + <arg name="fd" type="fd" summary="gamma table file descriptor"/> + </request> + + <event name="failed"> + <description summary="object no longer valid"> + This event indicates that the gamma control is no longer valid. This + can happen for a number of reasons, including: + - The output doesn't support gamma tables + - Setting the gamma tables failed + - Another client already has exclusive gamma control for this output + - The compositor has transfered gamma control to another client + + Upon receiving this event, the client should destroy this object. + </description> + </event> + + <request name="destroy" type="destructor"> + <description summary="destroy this control"> + Destroys the gamma control object. If the object is still valid, this + restores the original gamma tables. + </description> + </request> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-input-inhibitor-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-input-inhibitor-unstable-v1.xml new file mode 100644 index 0000000..6f4c246 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-input-inhibitor-unstable-v1.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="wlr_input_inhibit_unstable_v1"> + <copyright> + Copyright © 2018 Drew DeVault + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + the copyright holders not be used in advertising or publicity + pertaining to distribution of the software without specific, + written prior permission. The copyright holders make no + representations about the suitability of this software for any + purpose. It is provided "as is" without express or implied + warranty. + + THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + THIS SOFTWARE. + </copyright> + + <interface name="zwlr_input_inhibit_manager_v1" version="1"> + <description summary="inhibits input events to other clients"> + Clients can use this interface to prevent input events from being sent to + any surfaces but its own, which is useful for example in lock screen + software. It is assumed that access to this interface will be locked down + to whitelisted clients by the compositor. + </description> + + <request name="get_inhibitor"> + <description summary="inhibit input to other clients"> + Activates the input inhibitor. As long as the inhibitor is active, the + compositor will not send input events to other clients. + </description> + <arg name="id" type="new_id" interface="zwlr_input_inhibitor_v1"/> + </request> + + <enum name="error"> + <entry name="already_inhibited" value="0" summary="an input inhibitor is already in use on the compositor"/> + </enum> + </interface> + + <interface name="zwlr_input_inhibitor_v1" version="1"> + <description summary="inhibits input to other clients"> + While this resource exists, input to clients other than the owner of the + inhibitor resource will not receive input events. Any client which + previously had focus will receive a leave event and will not be given + focus again. The client that owns this resource will receive all input + events normally. The compositor will also disable all of its own input + processing (such as keyboard shortcuts) while the inhibitor is active. + + The compositor may continue to send input events to selected clients, + such as an on-screen keyboard (via the input-method protocol). + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the input inhibitor object"> + Destroy the inhibitor and allow other clients to receive input. + </description> + </request> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-layer-shell-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-layer-shell-unstable-v1.xml new file mode 100644 index 0000000..90b8bc8 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-layer-shell-unstable-v1.xml @@ -0,0 +1,285 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="wlr_layer_shell_unstable_v1"> + <copyright> + Copyright © 2017 Drew DeVault + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + the copyright holders not be used in advertising or publicity + pertaining to distribution of the software without specific, + written prior permission. The copyright holders make no + representations about the suitability of this software for any + purpose. It is provided "as is" without express or implied + warranty. + + THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + THIS SOFTWARE. + </copyright> + + <interface name="zwlr_layer_shell_v1" version="1"> + <description summary="create surfaces that are layers of the desktop"> + Clients can use this interface to assign the surface_layer role to + wl_surfaces. Such surfaces are assigned to a "layer" of the output and + rendered with a defined z-depth respective to each other. They may also be + anchored to the edges and corners of a screen and specify input handling + semantics. This interface should be suitable for the implementation of + many desktop shell components, and a broad number of other applications + that interact with the desktop. + </description> + + <request name="get_layer_surface"> + <description summary="create a layer_surface from a surface"> + Create a layer surface for an existing surface. This assigns the role of + layer_surface, or raises a protocol error if another role is already + assigned. + + Creating a layer surface from a wl_surface which has a buffer attached + or committed is a client error, and any attempts by a client to attach + or manipulate a buffer prior to the first layer_surface.configure call + must also be treated as errors. + + You may pass NULL for output to allow the compositor to decide which + output to use. Generally this will be the one that the user most + recently interacted with. + + Clients can specify a namespace that defines the purpose of the layer + surface. + </description> + <arg name="id" type="new_id" interface="zwlr_layer_surface_v1"/> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="output" type="object" interface="wl_output" allow-null="true"/> + <arg name="layer" type="uint" enum="layer" summary="layer to add this surface to"/> + <arg name="namespace" type="string" summary="namespace for the layer surface"/> + </request> + + <enum name="error"> + <entry name="role" value="0" summary="wl_surface has another role"/> + <entry name="invalid_layer" value="1" summary="layer value is invalid"/> + <entry name="already_constructed" value="2" summary="wl_surface has a buffer attached or committed"/> + </enum> + + <enum name="layer"> + <description summary="available layers for surfaces"> + These values indicate which layers a surface can be rendered in. They + are ordered by z depth, bottom-most first. Traditional shell surfaces + will typically be rendered between the bottom and top layers. + Fullscreen shell surfaces are typically rendered at the top layer. + Multiple surfaces can share a single layer, and ordering within a + single layer is undefined. + </description> + + <entry name="background" value="0"/> + <entry name="bottom" value="1"/> + <entry name="top" value="2"/> + <entry name="overlay" value="3"/> + </enum> + </interface> + + <interface name="zwlr_layer_surface_v1" version="1"> + <description summary="layer metadata interface"> + An interface that may be implemented by a wl_surface, for surfaces that + are designed to be rendered as a layer of a stacked desktop-like + environment. + + Layer surface state (size, anchor, exclusive zone, margin, interactivity) + is double-buffered, and will be applied at the time wl_surface.commit of + the corresponding wl_surface is called. + </description> + + <request name="set_size"> + <description summary="sets the size of the surface"> + Sets the size of the surface in surface-local coordinates. The + compositor will display the surface centered with respect to its + anchors. + + If you pass 0 for either value, the compositor will assign it and + inform you of the assignment in the configure event. You must set your + anchor to opposite edges in the dimensions you omit; not doing so is a + protocol error. Both values are 0 by default. + + Size is double-buffered, see wl_surface.commit. + </description> + <arg name="width" type="uint"/> + <arg name="height" type="uint"/> + </request> + + <request name="set_anchor"> + <description summary="configures the anchor point of the surface"> + Requests that the compositor anchor the surface to the specified edges + and corners. If two orthogonal edges are specified (e.g. 'top' and + 'left'), then the anchor point will be the intersection of the edges + (e.g. the top left corner of the output); otherwise the anchor point + will be centered on that edge, or in the center if none is specified. + + Anchor is double-buffered, see wl_surface.commit. + </description> + <arg name="anchor" type="uint" enum="anchor"/> + </request> + + <request name="set_exclusive_zone"> + <description summary="configures the exclusive geometry of this surface"> + Requests that the compositor avoids occluding an area of the surface + with other surfaces. The compositor's use of this information is + implementation-dependent - do not assume that this region will not + actually be occluded. + + A positive value is only meaningful if the surface is anchored to an + edge, rather than a corner. The zone is the number of surface-local + coordinates from the edge that is considered exclusive. + + Surfaces that do not wish to have an exclusive zone may instead specify + how they should interact with surfaces that do. If set to zero, the + surface indicates that it would like to be moved to avoid occluding + surfaces with a positive exclusive zone. If set to -1, the surface + indicates that it would not like to be moved to accommodate for other + surfaces, and the compositor should extend it all the way to the edges + it is anchored to. + + For example, a panel might set its exclusive zone to 10, so that + maximized shell surfaces are not shown on top of it. A notification + might set its exclusive zone to 0, so that it is moved to avoid + occluding the panel, but shell surfaces are shown underneath it. A + wallpaper or lock screen might set their exclusive zone to -1, so that + they stretch below or over the panel. + + The default value is 0. + + Exclusive zone is double-buffered, see wl_surface.commit. + </description> + <arg name="zone" type="int"/> + </request> + + <request name="set_margin"> + <description summary="sets a margin from the anchor point"> + Requests that the surface be placed some distance away from the anchor + point on the output, in surface-local coordinates. Setting this value + for edges you are not anchored to has no effect. + + The exclusive zone includes the margin. + + Margin is double-buffered, see wl_surface.commit. + </description> + <arg name="top" type="int"/> + <arg name="right" type="int"/> + <arg name="bottom" type="int"/> + <arg name="left" type="int"/> + </request> + + <request name="set_keyboard_interactivity"> + <description summary="requests keyboard events"> + Set to 1 to request that the seat send keyboard events to this layer + surface. For layers below the shell surface layer, the seat will use + normal focus semantics. For layers above the shell surface layers, the + seat will always give exclusive keyboard focus to the top-most layer + which has keyboard interactivity set to true. + + Layer surfaces receive pointer, touch, and tablet events normally. If + you do not want to receive them, set the input region on your surface + to an empty region. + + Events is double-buffered, see wl_surface.commit. + </description> + <arg name="keyboard_interactivity" type="uint"/> + </request> + + <request name="get_popup"> + <description summary="assign this layer_surface as an xdg_popup parent"> + This assigns an xdg_popup's parent to this layer_surface. This popup + should have been created via xdg_surface::get_popup with the parent set + to NULL, and this request must be invoked before committing the popup's + initial state. + + See the documentation of xdg_popup for more details about what an + xdg_popup is and how it is used. + </description> + <arg name="popup" type="object" interface="xdg_popup"/> + </request> + + <request name="ack_configure"> + <description summary="ack a configure event"> + When a configure event is received, if a client commits the + surface in response to the configure event, then the client + must make an ack_configure request sometime before the commit + request, passing along the serial of the configure event. + + If the client receives multiple configure events before it + can respond to one, it only has to ack the last configure event. + + A client is not required to commit immediately after sending + an ack_configure request - it may even ack_configure several times + before its next surface commit. + + A client may send multiple ack_configure requests before committing, but + only the last request sent before a commit indicates which configure + event the client really is responding to. + </description> + <arg name="serial" type="uint" summary="the serial from the configure event"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the layer_surface"> + This request destroys the layer surface. + </description> + </request> + + <event name="configure"> + <description summary="suggest a surface change"> + The configure event asks the client to resize its surface. + + Clients should arrange their surface for the new states, and then send + an ack_configure request with the serial sent in this configure event at + some point before committing the new surface. + + The client is free to dismiss all but the last configure event it + received. + + The width and height arguments specify the size of the window in + surface-local coordinates. + + The size is a hint, in the sense that the client is free to ignore it if + it doesn't resize, pick a smaller size (to satisfy aspect ratio or + resize in steps of NxM pixels). If the client picks a smaller size and + is anchored to two opposite anchors (e.g. 'top' and 'bottom'), the + surface will be centered on this axis. + + If the width or height arguments are zero, it means the client should + decide its own window dimension. + </description> + <arg name="serial" type="uint"/> + <arg name="width" type="uint"/> + <arg name="height" type="uint"/> + </event> + + <event name="closed"> + <description summary="surface should be closed"> + The closed event is sent by the compositor when the surface will no + longer be shown. The output may have been destroyed or the user may + have asked for it to be removed. Further changes to the surface will be + ignored. The client should destroy the resource after receiving this + event, and create a new surface if they so choose. + </description> + </event> + + <enum name="error"> + <entry name="invalid_surface_state" value="0" summary="provided surface state is invalid"/> + <entry name="invalid_size" value="1" summary="size is invalid"/> + <entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/> + </enum> + + <enum name="anchor" bitfield="true"> + <entry name="top" value="1" summary="the top edge of the anchor rectangle"/> + <entry name="bottom" value="2" summary="the bottom edge of the anchor rectangle"/> + <entry name="left" value="4" summary="the left edge of the anchor rectangle"/> + <entry name="right" value="8" summary="the right edge of the anchor rectangle"/> + </enum> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-screencopy-unstable-v1.xml b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-screencopy-unstable-v1.xml new file mode 100644 index 0000000..a7a2d17 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/unstable/wlr-screencopy-unstable-v1.xml @@ -0,0 +1,179 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="wlr_screencopy_unstable_v1"> + <copyright> + Copyright © 2018 Simon Ser + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="screen content capturing on client buffers"> + This protocol allows clients to ask the compositor to copy part of the + screen content to a client buffer. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <interface name="zwlr_screencopy_manager_v1" version="1"> + <description summary="manager to inform clients and begin capturing"> + This object is a manager which offers requests to start capturing from a + source. + </description> + + <request name="capture_output"> + <description summary="capture an output"> + Capture the next frame of an entire output. + </description> + <arg name="frame" type="new_id" interface="zwlr_screencopy_frame_v1"/> + <arg name="overlay_cursor" type="int" + summary="composite cursor onto the frame"/> + <arg name="output" type="object" interface="wl_output"/> + </request> + + <request name="capture_output_region"> + <description summary="capture an output's region"> + Capture the next frame of an output's region. + + The region is given in output logical coordinates, see + xdg_output.logical_size. The region will be clipped to the output's + extents. + </description> + <arg name="frame" type="new_id" interface="zwlr_screencopy_frame_v1"/> + <arg name="overlay_cursor" type="int" + summary="composite cursor onto the frame"/> + <arg name="output" type="object" interface="wl_output"/> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the manager"> + All objects created by the manager will still remain valid, until their + appropriate destroy request has been called. + </description> + </request> + </interface> + + <interface name="zwlr_screencopy_frame_v1" version="1"> + <description summary="a frame ready for copy"> + This object represents a single frame. + + When created, a "buffer" event will be sent. The client will then be able + to send a "copy" request. If the capture is successful, the compositor + will send a "flags" followed by a "ready" event. + + If the capture failed, the "failed" event is sent. This can happen anytime + before the "ready" event. + + Once either a "ready" or a "failed" event is received, the client should + destroy the frame. + </description> + + <event name="buffer"> + <description summary="buffer information"> + Provides information about the frame's buffer. This event is sent once + as soon as the frame is created. + + The client should then create a buffer with the provided attributes, and + send a "copy" request. + </description> + <arg name="format" type="uint" summary="buffer format"/> + <arg name="width" type="uint" summary="buffer width"/> + <arg name="height" type="uint" summary="buffer height"/> + <arg name="stride" type="uint" summary="buffer stride"/> + </event> + + <request name="copy"> + <description summary="copy the frame"> + Copy the frame to the supplied buffer. The buffer must have a the + correct size, see zwlr_screencopy_frame_v1.buffer. The buffer needs to + have a supported format. + + If the frame is successfully copied, a "flags" and a "ready" events are + sent. Otherwise, a "failed" event is sent. + </description> + <arg name="buffer" type="object" interface="wl_buffer"/> + </request> + + <enum name="error"> + <entry name="already_used" value="0" + summary="the object has already been used to copy a wl_buffer"/> + <entry name="invalid_buffer" value="1" + summary="buffer attributes are invalid"/> + </enum> + + <enum name="flags" bitfield="true"> + <entry name="y_invert" value="1" summary="contents are y-inverted"/> + </enum> + + <event name="flags"> + <description summary="frame flags"> + Provides flags about the frame. This event is sent once before the + "ready" event. + </description> + <arg name="flags" type="uint" enum="flags" summary="frame flags"/> + </event> + + <event name="ready"> + <description summary="indicates frame is available for reading"> + Called as soon as the frame is copied, indicating it is available + for reading. This event includes the time at which presentation happened + at. + + The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples, + each component being an unsigned 32-bit value. Whole seconds are in + tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo, + and the additional fractional part in tv_nsec as nanoseconds. Hence, + for valid timestamps tv_nsec must be in [0, 999999999]. The seconds part + may have an arbitrary offset at start. + + After receiving this event, the client should destroy the object. + </description> + <arg name="tv_sec_hi" type="uint" + summary="high 32 bits of the seconds part of the timestamp"/> + <arg name="tv_sec_lo" type="uint" + summary="low 32 bits of the seconds part of the timestamp"/> + <arg name="tv_nsec" type="uint" + summary="nanoseconds part of the timestamp"/> + </event> + + <event name="failed"> + <description summary="frame copy failed"> + This event indicates that the attempted frame copy has failed. + + After receiving this event, the client should destroy the object. + </description> + </event> + + <request name="destroy" type="destructor"> + <description summary="delete this object, used or not"> + Destroys the frame. This request can be sent at any time by the client. + </description> + </request> + </interface> +</protocol> diff --git a/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/wlr-protocols.pc.in b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/wlr-protocols.pc.in new file mode 100644 index 0000000..5acfbe8 --- /dev/null +++ b/third_party/cargo/vendor/wayland-protocols-0.21.13/wlr-protocols/wlr-protocols.pc.in @@ -0,0 +1,7 @@ +prefix=@prefix@ +datarootdir=@datarootdir@ +pkgdatadir=${pc_sysrootdir}@datadir@/wlr-protocols + +Name: wlroots Wayland protocols +Description: Wayland protocol files +Version: 1.0 diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/.cargo-checksum.json b/third_party/cargo/vendor/wayland-scanner-0.21.13/.cargo-checksum.json new file mode 100644 index 0000000..3d62316 --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"a06188ab384389c22726dcdccd1d26abc6ffd93ed4cc0eca07de5e42a4c76247","src/c_code_gen.rs":"0db7cb379a56b3ca7774972e6d6c425c1c7048b9a98316e4129c526e9f85bfff","src/c_interface_gen.rs":"0f55a6df7b7c9cbec4a447f38f292ae9e6a7d880e8694bd0a433a4b16cb0bc3a","src/common_gen.rs":"d95bc9a97a63d7123e900d041d47b3b9149b44417b6c52c368e8eb97691f3e90","src/lib.rs":"e50f841cb2f308913fffea2c55f71ca22e9403d23df5e566691409f3dbaec222","src/parse.rs":"1defa09caf64ef3a6659bcf98e2881c12d1531e693b9bdb73f3cf0ba2c0ac254","src/protocol.rs":"7c0d1cda4de54aeb0cb5c45f506049055d7b3247f5b278401027ecdaace51059","src/rust_code_gen.rs":"7da53df062f4f4f0ad3aa4b46c45b0caeab0302ed3d7dcf4a9413c1aea569088","src/side.rs":"398d55c387cdacd6febc5029d211f87e2b1b3b0ddb65fa66f567815dffb0510b","src/util.rs":"44cf7c4d70bbee39a5fca39e284d6549d66ed22fa9b93c6c21fc9fe8d16edf82"},"package":"bf3828c568714507315ee425a9529edc4a4aa9901409e373e9e0027e7622b79e"} \ No newline at end of file diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/BUILD b/third_party/cargo/vendor/wayland-scanner-0.21.13/BUILD new file mode 100644 index 0000000..2f223f7 --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/BUILD @@ -0,0 +1,45 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "wayland_scanner", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/proc-macro2-0.4.30:proc_macro2", + "//third_party/cargo/vendor/quote-0.6.13:quote", + "//third_party/cargo/vendor/xml-rs-0.8.0:xml_rs", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.21.13", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/Cargo.toml b/third_party/cargo/vendor/wayland-scanner-0.21.13/Cargo.toml new file mode 100644 index 0000000..32670f5 --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/Cargo.toml @@ -0,0 +1,32 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "wayland-scanner" +version = "0.21.13" +authors = ["Victor Berger <victor.berger@m4x.org>"] +description = "Wayland Scanner for generating rust APIs from XML wayland protocol files. Intented for use with wayland-sys. You should only need this crate if you are working on custom wayland protocol extensions. Look at the crate wayland-client for usable bindings." +documentation = "https://smithay.github.io/wayland-rs/wayland_scanner/" +keywords = ["wayland", "codegen"] +categories = ["gui", "api-bindings"] +license = "MIT" +repository = "https://github.com/smithay/wayland-rs" +[dependencies.proc-macro2] +version = "0.4.24" + +[dependencies.quote] +version = "0.6.10" + +[dependencies.xml-rs] +version = ">=0.7, <0.9" +[badges.travis-ci] +repository = "Smithay/wayland-rs" diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/src/c_code_gen.rs b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/c_code_gen.rs new file mode 100644 index 0000000..d466c36 --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/c_code_gen.rs @@ -0,0 +1,508 @@ +use std::iter; + +use proc_macro2::{Ident, Literal, Span, TokenStream}; + +use common_gen::*; +use protocol::*; +use util::*; +use Side; + +pub(crate) fn generate_protocol_client(protocol: Protocol) -> TokenStream { + let modules = protocol.interfaces.iter().map(|iface| { + let doc_attr = iface.description.as_ref().map(description_to_doc_attr); + let mod_name = Ident::new(&iface.name, Span::call_site()); + let iface_name = Ident::new(&snake_to_camel(&iface.name), Span::call_site()); + + let enums = &iface.enums; + + let ident = Ident::new("Request", Span::call_site()); + let requests = gen_messagegroup( + &ident, + Side::Client, + false, + &iface.requests, + Some(messagegroup_c_addon(&ident, Side::Client, false, &iface.requests)), + ); + + let ident = Ident::new("Event", Span::call_site()); + let events = gen_messagegroup( + &ident, + Side::Client, + true, + &iface.events, + Some(messagegroup_c_addon(&ident, Side::Client, true, &iface.events)), + ); + + let interface = gen_interface( + &iface_name, + &iface.name, + iface.version, + Some(interface_c_addon(&iface.name)), + ); + + let client_methods = gen_client_methods(&iface_name, &iface.requests); + let sinces = gen_since_constants(&iface.requests, &iface.events); + + quote! { + #doc_attr + pub mod #mod_name { + use super::{ + Proxy, NewProxy, AnonymousObject, Interface, MessageGroup, MessageDesc, ArgumentType, + Object, Message, Argument, ObjectMetadata + }; + use super::sys::common::{wl_argument, wl_interface, wl_array}; + use super::sys::client::*; + + #(#enums)* + #requests + #events + #interface + #client_methods + #sinces + } + } + }); + + quote! { + #(#modules)* + } +} + +pub(crate) fn generate_protocol_server(protocol: Protocol) -> TokenStream { + let modules = protocol + .interfaces + .iter() + // display and registry are handled specially + .filter(|iface| iface.name != "wl_display" && iface.name != "wl_registry") + .map(|iface| { + let doc_attr = iface.description.as_ref().map(description_to_doc_attr); + let mod_name = Ident::new(&iface.name, Span::call_site()); + + let enums = &iface.enums; + + let ident = Ident::new("Request", Span::call_site()); + let requests = gen_messagegroup( + &ident, + Side::Server, + true, + &iface.requests, + Some(messagegroup_c_addon(&ident, Side::Server, true, &iface.requests)), + ); + + let ident = Ident::new("Event", Span::call_site()); + let events = gen_messagegroup( + &ident, + Side::Server, + false, + &iface.events, + Some(messagegroup_c_addon(&ident, Side::Server, false, &iface.events)), + ); + + let interface = gen_interface( + &Ident::new(&snake_to_camel(&iface.name), Span::call_site()), + &iface.name, + iface.version, + Some(interface_c_addon(&iface.name)), + ); + let sinces = gen_since_constants(&iface.requests, &iface.events); + + quote! { + #doc_attr + pub mod #mod_name { + use super::{ + Resource, NewResource, AnonymousObject, Interface, MessageGroup, MessageDesc, + ArgumentType, Object, Message, Argument, ObjectMetadata + }; + use super::sys::common::{wl_argument, wl_interface, wl_array}; + use super::sys::server::*; + + #(#enums)* + #requests + #events + #interface + #sinces + } + } + }); + + quote! { + #(#modules)* + } +} + +fn messagegroup_c_addon(name: &Ident, side: Side, receiver: bool, messages: &[Message]) -> TokenStream { + let from_raw_c_body = if receiver { + let match_arms = messages + .iter() + .enumerate() + .map(|(i, msg)| { + let pattern = Literal::u16_unsuffixed(i as u16); + let msg_name = Ident::new(&snake_to_camel(&msg.name), Span::call_site()); + let msg_name_qualified = quote!(#name::#msg_name); + let (args_binding, result) = if msg.args.is_empty() { + (None, msg_name_qualified) + } else { + let len = Literal::usize_unsuffixed(msg.args.len()); + + let fields = msg.args.iter().enumerate().map(|(j, arg)| { + let field_name = Ident::new(&arg.name, Span::call_site()); + + let idx = Literal::usize_unsuffixed(j); + let field_value = match arg.typ { + Type::Uint => { + if let Some(ref enu) = arg.enum_ { + let enum_type = dotted_to_relname(enu); + quote!(#enum_type::from_raw(_args[#idx].u).ok_or(())?) + } else { + quote!(_args[#idx].u) + } + } + Type::Int => { + if let Some(ref enu) = arg.enum_ { + let enum_type = dotted_to_relname(enu); + quote!(#enum_type::from_raw(_args[#idx].i as u32).ok_or(())?) + } else { + quote!(_args[#idx].i) + } + } + Type::Fixed => quote!((_args[#idx].f as f64) / 256.), + Type::String => { + let string_conversion = quote! { + ::std::ffi::CStr::from_ptr(_args[#idx].s).to_string_lossy().into_owned() + }; + + if arg.allow_null { + quote! { + if _args[#idx].s.is_null() { None } else { Some(#string_conversion) } + } + } else { + string_conversion + } + } + Type::Array => { + let array_conversion = quote! { + { + let array = &*_args[#idx].a; + ::std::slice::from_raw_parts(array.data as *const u8, array.size) + .to_owned() + } + }; + + if arg.allow_null { + quote! { + if _args[#idx].a.is_null() { None } else { Some(#array_conversion) } + } + } else { + array_conversion + } + } + Type::Fd => quote!(_args[#idx].h), + Type::Object => { + let object_name = side.object_name(); + let object_conversion = if let Some(ref iface) = arg.interface { + let iface_mod = Ident::new(iface, Span::call_site()); + let iface_type = Ident::new(&snake_to_camel(iface), Span::call_site()); + + quote! { + #object_name::<super::#iface_mod::#iface_type>::from_c_ptr( + _args[#idx].o as *mut _, + ) + } + } else { + quote! { + #object_name::<AnonymousObject>::from_c_ptr(_args[#idx].o as *mut _) + } + }; + + if arg.allow_null { + quote! { + if _args[#idx].o.is_null() { None } else { Some(#object_conversion) } + } + } else { + object_conversion + } + } + Type::NewId => { + let new_id_conversion = if let Some(ref iface) = arg.interface { + let iface_mod = Ident::new(iface, Span::call_site()); + let iface_type = Ident::new(&snake_to_camel(iface), Span::call_site()); + + match side { + Side::Client => { + quote! { + NewProxy::<super::#iface_mod::#iface_type>::from_c_ptr( + _args[#idx].o as *mut _ + ) + } + } + Side::Server => { + quote! { + { + let client = ffi_dispatch!( + WAYLAND_SERVER_HANDLE, + wl_resource_get_client, + obj as *mut _ + ); + let version = ffi_dispatch!( + WAYLAND_SERVER_HANDLE, + wl_resource_get_version, + obj as *mut _ + ); + let new_ptr = ffi_dispatch!( + WAYLAND_SERVER_HANDLE, + wl_resource_create, + client, + super::#iface_mod::#iface_type::c_interface(), + version, + _args[#idx].n + ); + + NewResource::<super::#iface_mod::#iface_type>::from_c_ptr( + new_ptr + ) + } + } + } + } + } else { + // bind-like function + quote!(panic!("Cannot unserialize anonymous new id.")) + }; + + if arg.allow_null { + quote! { + if _args[#idx].o.is_null() { None } else { Some(#new_id_conversion) } + } + } else { + new_id_conversion + } + } + Type::Destructor => panic!("An argument cannot have type \"destructor\"."), + }; + + quote!(#field_name: #field_value) + }); + + let result = quote! { + #msg_name_qualified { + #(#fields,)* + } + }; + + let args_binding = quote! { + let _args = ::std::slice::from_raw_parts(args, #len); + }; + + (Some(args_binding), result) + }; + + quote! { + #pattern => { + #args_binding + Ok(#result) + } + } + }) + .chain(iter::once(quote!(_ => return Err(())))); + + quote! { + match opcode { + #(#match_arms,)* + } + } + } else { + let panic_message = format!("{}::from_raw_c can not be used {:?}-side.", name, side); + quote!(panic!(#panic_message)) + }; + + let as_raw_c_in_body = if receiver { + let panic_message = format!("{}::as_raw_c_in can not be used {:?}-side.", name, side); + quote!(panic!(#panic_message)) + } else { + let match_arms = messages.iter().enumerate().map(|(i, msg)| { + let msg_name = Ident::new(&snake_to_camel(&msg.name), Span::call_site()); + let pattern = if msg.args.is_empty() { + quote!(#name::#msg_name) + } else { + let fields = msg + .args + .iter() + .map(|arg| Ident::new(&arg.name, Span::call_site())); + + quote!(#name::#msg_name { #(#fields),* }) + }; + + let buffer_len = Literal::usize_unsuffixed( + msg.args.len() + + 2 * msg + .args + .iter() + .filter(|arg| arg.typ == Type::NewId && arg.interface.is_none()) + .count(), + ); + + let mut j = 0; + let args_array_init_stmts = msg.args.iter().map(|arg| { + let idx = Literal::usize_unsuffixed(j); + let arg_name = Ident::new(&arg.name, Span::call_site()); + + let res = match arg.typ { + Type::Uint => { + if arg.enum_.is_some() { + quote! { + _args_array[#idx].u = #arg_name.to_raw(); + } + } else { + quote! { + _args_array[#idx].u = #arg_name; + } + } + } + Type::Int => { + if arg.enum_.is_some() { + quote! { + _args_array[#idx].i = #arg_name.to_raw() as i32; + } + } else { + quote! { + _args_array[#idx].i = #arg_name; + } + } + } + Type::Fixed => quote! { + _args_array[#idx].f = (#arg_name * 256.) as i32; + }, + Type::String => { + let arg_variable = Ident::new(&format!("_arg_{}", j), Span::call_site()); + if arg.allow_null { + quote! { + let #arg_variable = #arg_name.map(|s| ::std::ffi::CString::new(s).unwrap()); + _args_array[#idx].s = + #arg_variable.map(|s| s.as_ptr()).unwrap_or(::std::ptr::null()); + } + } else { + quote! { + let #arg_variable = ::std::ffi::CString::new(#arg_name).unwrap(); + _args_array[#idx].s = #arg_variable.as_ptr(); + } + } + } + Type::Array => { + let arg_variable = Ident::new(&format!("_arg_{}", j), Span::call_site()); + if arg.allow_null { + quote! { + let #arg_variable = #arg_name.as_ref().map(|vec| wl_array { + size: vec.len(), + alloc: vec.capacity(), + data: vec.as_ptr() as *mut _, + }); + _args_array[#idx].a = #arg_variable + .as_ref() + .map(|a| a as *const wl_array) + .unwrap_or(::std::ptr::null()); + } + } else { + quote! { + let #arg_variable = wl_array { + size: #arg_name.len(), + alloc: #arg_name.capacity(), + data: #arg_name.as_ptr() as *mut _, + }; + _args_array[#idx].a = &#arg_variable; + } + } + } + Type::Fd => quote! { + _args_array[#idx].h = #arg_name; + }, + Type::Object => { + if arg.allow_null { + quote! { + _args_array[#idx].o = #arg_name + .map(|o| o.c_ptr() as *mut _) + .unwrap_or(::std::ptr::null_mut()); + } + } else { + quote! { + _args_array[#idx].o = #arg_name.c_ptr() as *mut _; + } + } + } + Type::NewId => { + if arg.interface.is_some() { + quote! { + _args_array[#idx].o = #arg_name.c_ptr() as *mut _; + } + } else { + assert!( + side != Side::Server, + "Cannot serialize anonymous NewID from server." + ); + + // The arg is actually (string, uint, NULL) + let arg_variable = Ident::new(&format!("_arg_{}_s", j), Span::call_site()); + let idx1 = Literal::usize_unsuffixed(j + 1); + let idx2 = Literal::usize_unsuffixed(j + 2); + + let res = quote! { + let #arg_variable = ::std::ffi::CString::new(#arg_name.0).unwrap(); + _args_array[#idx].s = #arg_variable.as_ptr(); + _args_array[#idx1].u = #arg_name.1; + _args_array[#idx2].o = ::std::ptr::null_mut(); + }; + + j += 2; + + res + } + } + Type::Destructor => panic!("An argument cannot have type \"destructor\"."), + }; + + j += 1; + + res + }); + + let idx = Literal::u32_unsuffixed(i as u32); + + quote! { + #pattern => { + let mut _args_array: [wl_argument; #buffer_len] = unsafe { ::std::mem::zeroed() }; + #(#args_array_init_stmts)* + + f(#idx, &mut _args_array) + } + } + }); + + quote! { + match self { + #(#match_arms,)* + } + } + }; + + quote! { + unsafe fn from_raw_c( + obj: *mut ::std::os::raw::c_void, + opcode: u32, + args: *const wl_argument, + ) -> Result<#name, ()> { + #from_raw_c_body + } + + fn as_raw_c_in<F, T>(self, f: F) -> T where F: FnOnce(u32, &mut [wl_argument]) -> T { + #as_raw_c_in_body + } + } +} + +fn interface_c_addon(low_name: &str) -> TokenStream { + let mod_name = Ident::new(&format!("{}_interface", low_name), Span::call_site()); + quote! { + fn c_interface() -> *const wl_interface { + unsafe { &super::super::c_interfaces::#mod_name } + } + } +} diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/src/c_interface_gen.rs b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/c_interface_gen.rs new file mode 100644 index 0000000..5cff8b5 --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/c_interface_gen.rs @@ -0,0 +1,176 @@ +use std::cmp; +use std::iter::repeat; + +use proc_macro2::{Ident, Literal, Span, TokenStream}; + +use protocol::*; +use util::null_terminated_byte_string_literal; + +pub(crate) fn generate_interfaces(protocol: Protocol) -> TokenStream { + let longest_nulls = protocol.interfaces.iter().fold(0, |max, interface| { + let request_longest_null = interface.requests.iter().fold(0, |max, request| { + if request.all_null() { + cmp::max(request.args.len(), max) + } else { + max + } + }); + let events_longest_null = interface.events.iter().fold(0, |max, event| { + if event.all_null() { + cmp::max(event.args.len(), max) + } else { + max + } + }); + cmp::max(max, cmp::max(request_longest_null, events_longest_null)) + }); + + let types_null_len = Literal::usize_unsuffixed(longest_nulls); + + let nulls = repeat(quote!(NULLPTR as *const wl_interface)).take(longest_nulls); + + let interfaces = protocol.interfaces.iter().map(|interface| { + let requests = gen_messages(interface, &interface.requests, "requests"); + let events = gen_messages(interface, &interface.events, "events"); + + let interface_ident = Ident::new(&format!("{}_interface", interface.name), Span::call_site()); + let name_value = null_terminated_byte_string_literal(&interface.name); + let version_value = Literal::i32_unsuffixed(interface.version as i32); + let request_count_value = Literal::i32_unsuffixed(interface.requests.len() as i32); + let requests_value = if interface.requests.is_empty() { + quote!(NULLPTR as *const wl_message) + } else { + let requests_ident = Ident::new(&format!("{}_requests", interface.name), Span::call_site()); + quote!(unsafe { &#requests_ident as *const _ }) + }; + let event_count_value = Literal::i32_unsuffixed(interface.events.len() as i32); + let events_value = if interface.events.is_empty() { + quote!(NULLPTR as *const wl_message) + } else { + let events_ident = Ident::new(&format!("{}_events", interface.name), Span::call_site()); + quote!(unsafe { &#events_ident as *const _ }) + }; + + quote!( + #requests + #events + + pub static mut #interface_ident: wl_interface = wl_interface { + name: #name_value as *const u8 as *const c_char, + version: #version_value, + request_count: #request_count_value, + requests: #requests_value, + event_count: #event_count_value, + events: #events_value, + }; + ) + }); + + quote! { + use std::os::raw::{c_char, c_void}; + use wayland_sys::common::*; + + const NULLPTR: *const c_void = 0 as *const c_void; + static mut types_null: [*const wl_interface; #types_null_len] = [ + #(#nulls,)* + ]; + + #(#interfaces)* + } +} + +fn gen_messages(interface: &Interface, messages: &[Message], which: &str) -> TokenStream { + if messages.is_empty() { + return TokenStream::new(); + } + + let types_arrays = messages.iter().filter_map(|msg| { + if msg.all_null() { + None + } else { + let array_ident = Ident::new( + &format!("{}_{}_{}_types", interface.name, which, msg.name), + Span::call_site(), + ); + let array_len = Literal::usize_unsuffixed(msg.args.len()); + let array_values = msg.args.iter().map(|arg| match (arg.typ, &arg.interface) { + (Type::Object, &Some(ref inter)) | (Type::NewId, &Some(ref inter)) => { + let interface_ident = Ident::new(&format!("{}_interface", inter), Span::call_site()); + quote!(unsafe { &#interface_ident as *const wl_interface }) + } + _ => quote!(NULLPTR as *const wl_interface), + }); + + Some(quote! { + static mut #array_ident: [*const wl_interface; #array_len] = [ + #(#array_values,)* + ]; + }) + } + }); + + let message_array_ident = Ident::new(&format!("{}_{}", interface.name, which), Span::call_site()); + let message_array_len = Literal::usize_unsuffixed(messages.len()); + let message_array_values = messages.iter().map(|msg| { + let name_value = null_terminated_byte_string_literal(&msg.name); + let signature_value = Literal::byte_string(&message_signature(msg)); + + let types_ident = if msg.all_null() { + Ident::new("types_null", Span::call_site()) + } else { + Ident::new( + &format!("{}_{}_{}_types", interface.name, which, msg.name), + Span::call_site(), + ) + }; + + quote! { + wl_message { + name: #name_value as *const u8 as *const c_char, + signature: #signature_value as *const u8 as *const c_char, + types: unsafe { &#types_ident as *const _ }, + } + } + }); + + quote! { + #(#types_arrays)* + + pub static mut #message_array_ident: [wl_message; #message_array_len] = [ + #(#message_array_values,)* + ]; + } +} + +fn message_signature(msg: &Message) -> Vec<u8> { + let mut res = Vec::new(); + + if msg.since > 1 { + res.extend_from_slice(msg.since.to_string().as_bytes()); + } + + for arg in &msg.args { + if arg.typ.nullable() && arg.allow_null { + res.push(b'?'); + } + match arg.typ { + Type::NewId => { + if arg.interface.is_none() { + res.extend_from_slice(b"su"); + } + res.push(b'n'); + } + Type::Uint => res.push(b'u'), + Type::Fixed => res.push(b'f'), + Type::String => res.push(b's'), + Type::Object => res.push(b'o'), + Type::Array => res.push(b'a'), + Type::Fd => res.push(b'h'), + Type::Int => res.push(b'i'), + _ => {} + } + } + + res.push(0); + res +} diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/src/common_gen.rs b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/common_gen.rs new file mode 100644 index 0000000..a82fdda --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/common_gen.rs @@ -0,0 +1,827 @@ +#[allow(unused_imports)] +#[allow(deprecated)] +use std::ascii::AsciiExt; +use std::iter; + +use proc_macro2::{Ident, Literal, Span, TokenStream}; +use quote::ToTokens; + +use protocol::*; +use util::*; +use Side; + +pub(crate) fn to_doc_attr(text: &str) -> TokenStream { + let text = text + .lines() + .map(|line| line.trim()) + .collect::<Vec<_>>() + .join("\n"); + let text = text.trim(); + + quote!(#[doc = #text]) +} + +pub(crate) fn description_to_doc_attr(&(ref short, ref long): &(String, String)) -> TokenStream { + to_doc_attr(&format!("{}\n\n{}", short, long)) +} + +impl ToTokens for Enum { + fn to_tokens(&self, tokens: &mut TokenStream) { + let enum_decl; + let enum_impl; + + let doc_attr = self.description.as_ref().map(description_to_doc_attr); + let ident = Ident::new(&snake_to_camel(&self.name), Span::call_site()); + + if self.bitfield { + let entries = self.entries.iter().map(|entry| { + let doc_attr = entry + .description + .as_ref() + .map(description_to_doc_attr) + .or_else(|| entry.summary.as_ref().map(|s| to_doc_attr(s))); + + let prefix = if entry.name.chars().next().unwrap().is_numeric() { + "_" + } else { + "" + }; + let ident = Ident::new( + &format!("{}{}", prefix, snake_to_camel(&entry.name)), + Span::call_site(), + ); + + let value = Literal::u32_unsuffixed(entry.value); + + quote! { + #doc_attr + const #ident = #value; + } + }); + + enum_decl = quote! { + bitflags! { + #doc_attr + pub struct #ident: u32 { + #(#entries)* + } + } + }; + enum_impl = quote! { + impl #ident { + pub fn from_raw(n: u32) -> Option<#ident> { + Some(#ident::from_bits_truncate(n)) + } + + pub fn to_raw(&self) -> u32 { + self.bits() + } + } + }; + } else { + let variants = self.entries.iter().map(|entry| { + let doc_attr = entry + .description + .as_ref() + .map(description_to_doc_attr) + .or_else(|| entry.summary.as_ref().map(|s| to_doc_attr(s))); + + let prefix = if entry.name.chars().next().unwrap().is_numeric() { + "_" + } else { + "" + }; + let variant = Ident::new( + &format!("{}{}", prefix, snake_to_camel(&entry.name)), + Span::call_site(), + ); + + let value = Literal::u32_unsuffixed(entry.value); + + quote! { + #doc_attr + #variant = #value + } + }); + + enum_decl = quote! { + #doc_attr + #[repr(u32)] + #[derive(Copy, Clone, Debug, PartialEq)] + pub enum #ident { + #(#variants,)* + } + }; + + let match_arms = self.entries.iter().map(|entry| { + let value = Literal::u32_unsuffixed(entry.value); + + let prefix = if entry.name.chars().next().unwrap().is_numeric() { + "_" + } else { + "" + }; + let variant = Ident::new( + &format!("{}{}", prefix, snake_to_camel(&entry.name)), + Span::call_site(), + ); + + quote! { + #value => Some(#ident::#variant) + } + }); + + enum_impl = quote! { + impl #ident { + pub fn from_raw(n: u32) -> Option<#ident> { + match n { + #(#match_arms,)* + _ => Option::None + } + } + + pub fn to_raw(&self) -> u32 { + *self as u32 + } + } + }; + } + + enum_decl.to_tokens(tokens); + enum_impl.to_tokens(tokens); + } +} + +pub(crate) fn gen_since_constants(requests: &[Message], events: &[Message]) -> TokenStream { + let req_constants = requests.iter().map(|msg| { + let cstname = Ident::new( + &format!("REQ_{}_SINCE", msg.name.to_ascii_uppercase()), + Span::call_site(), + ); + let since = msg.since; + quote! { + /// The minimal object version supporting this request + pub const #cstname: u16 = #since; + } + }); + let evt_constants = events.iter().map(|msg| { + let cstname = Ident::new( + &format!("EVT_{}_SINCE", msg.name.to_ascii_uppercase()), + Span::call_site(), + ); + let since = msg.since; + quote! { + /// The minimal object version supporting this event + pub const #cstname: u16 = #since; + } + }); + + quote! { + #(#req_constants)* + #(#evt_constants)* + } +} + +pub(crate) fn gen_messagegroup( + name: &Ident, + side: Side, + receiver: bool, + messages: &[Message], + addon: Option<TokenStream>, +) -> TokenStream { + let variants = messages.iter().map(|msg| { + let mut docs = String::new(); + if let Some((ref short, ref long)) = msg.description { + docs += &format!("{}\n\n{}\n", short, long.trim()); + } + if let Some(Type::Destructor) = msg.typ { + docs += &format!( + "\nThis is a destructor, once {} this object cannot be used any longer.", + if receiver { "received" } else { "sent" }, + ); + } + if msg.since > 1 { + docs += &format!("\nOnly available since version {} of the interface", msg.since); + } + + let doc_attr = to_doc_attr(&docs); + let msg_name = Ident::new(&snake_to_camel(&msg.name), Span::call_site()); + let msg_variant_decl = if msg.args.is_empty() { + msg_name.into_token_stream() + } else { + let fields = msg.args.iter().map(|arg| { + let field_name = Ident::new(&arg.name, Span::call_site()); + let field_type_inner = if let Some(ref enu) = arg.enum_ { + dotted_to_relname(enu) + } else { + match arg.typ { + Type::Uint => quote!(u32), + Type::Int => quote!(i32), + Type::Fixed => quote!(f64), + Type::String => quote!(String), + Type::Array => quote!(Vec<u8>), + Type::Fd => quote!(::std::os::unix::io::RawFd), + Type::Object => { + let object_name = side.object_name(); + if let Some(ref iface) = arg.interface { + let iface_mod = Ident::new(&iface, Span::call_site()); + let iface_type = Ident::new(&snake_to_camel(iface), Span::call_site()); + quote!(#object_name<super::#iface_mod::#iface_type>) + } else { + quote!(#object_name<AnonymousObject>) + } + } + Type::NewId => { + let prefix = if receiver { "New" } else { "" }; + let object_name = + Ident::new(&format!("{}{}", prefix, side.object_name()), Span::call_site()); + if let Some(ref iface) = arg.interface { + let iface_mod = Ident::new(&iface, Span::call_site()); + let iface_type = Ident::new(&snake_to_camel(iface), Span::call_site()); + quote!(#object_name<super::#iface_mod::#iface_type>) + } else { + // bind-like function + quote!((String, u32, #object_name<AnonymousObject>)) + } + } + Type::Destructor => panic!("An argument cannot have type \"destructor\"."), + } + }; + + let field_type = if arg.allow_null { + quote!(Option<#field_type_inner>) + } else { + field_type_inner.into_token_stream() + }; + + quote! { + #field_name: #field_type + } + }); + + quote! { + #msg_name { + #(#fields,)* + } + } + }; + + quote! { + #doc_attr + #msg_variant_decl + } + }); + + let message_array_values = messages.iter().map(|msg| { + let name_value = &msg.name; + let since_value = Literal::u16_unsuffixed(msg.since); + let signature_values = msg.args.iter().map(|arg| { + let common_type = arg.typ.common_type(); + quote!(super::ArgumentType::#common_type) + }); + + quote! { + super::MessageDesc { + name: #name_value, + since: #since_value, + signature: &[ + #(#signature_values,)* + ], + } + } + }); + + let map_type = if side == Side::Client { + quote!(ProxyMap) + } else { + quote!(ResourceMap) + }; + + // Can't be a closure because closures are never Copy / Clone in rustc < 1.26.0, and we supports 1.21.0 + fn map_fn((ref msg, ref name): (&Message, &Ident)) -> TokenStream { + let msg_type = Ident::new(&snake_to_camel(&msg.name), Span::call_site()); + let msg_type_qualified = quote!(#name::#msg_type); + + if msg.args.is_empty() { + msg_type_qualified + } else { + quote!(#msg_type_qualified { .. }) + } + }; + + let message_match_patterns = messages.iter().zip(iter::repeat(name)).map(map_fn); + + let mut is_destructor_match_arms = messages + .iter() + .zip(message_match_patterns.clone()) + .filter(|&(msg, _)| msg.typ == Some(Type::Destructor)) + .map(|(_, pattern)| quote!(#pattern => true)) + .collect::<Vec<_>>(); + + if messages.len() > is_destructor_match_arms.len() { + is_destructor_match_arms.push(quote!(_ => false)); + } + + let opcode_match_arms = message_match_patterns.enumerate().map(|(opcode, pattern)| { + let value = Literal::u16_unsuffixed(opcode as u16); + quote!(#pattern => #value) + }); + + let child_match_arms = messages + .iter() + .enumerate() + .filter_map(|(opcode, msg)| { + let mut it = msg.args.iter().filter_map(|a| { + if a.typ == Type::NewId { + a.interface.as_ref() + } else { + None + } + }); + + it.next().map(|new_iface| { + assert!( + it.next().is_none(), + "Got a message with more than one new_id in {}.{}", + name, + msg.name + ); + + let pattern = Literal::u16_unsuffixed(opcode as u16); + let new_iface_mod = Ident::new(new_iface, Span::call_site()); + let new_iface_type = Ident::new(&snake_to_camel(new_iface), Span::call_site()); + + quote! { + #pattern => Some(Object::from_interface::<super::#new_iface_mod::#new_iface_type>( + version, + meta.child(), + )) + } + }) + }) + .chain(iter::once(quote!(_ => None))); + + let from_raw_body = if receiver { + let match_arms = messages + .iter() + .enumerate() + .map(|(opcode, msg)| { + let pattern = Literal::u16_unsuffixed(opcode as u16); + let msg_type = Ident::new(&snake_to_camel(&msg.name), Span::call_site()); + let msg_type_qualified = quote!(#name::#msg_type); + + let block = if msg.args.is_empty() { + quote!(Ok(#msg_type_qualified)) + } else { + let fields = msg.args.iter().map(|arg| { + let field_name = Ident::new(&arg.name, Span::call_site()); + let some_code_path = match arg.typ { + Type::Int => { + if let Some(ref enu) = arg.enum_ { + let enum_ident = dotted_to_relname(enu); + quote!(#enum_ident::from_raw(val as u32).ok_or(())?) + } else { + quote!(val) + } + } + Type::Uint => { + if let Some(ref enu) = arg.enum_ { + let enum_ident = dotted_to_relname(enu); + quote!(#enum_ident::from_raw(val).ok_or(())?) + } else { + quote!(val) + } + } + Type::Fixed => quote!((val as f64) / 256.), + Type::Array => { + if arg.allow_null { + quote!(if val.len() == 0 { None } else { Some(val) }) + } else { + quote!(val) + } + } + Type::String => { + let string_conversion = quote! { + let s = String::from_utf8(val.into_bytes()) + .unwrap_or_else(|e| String::from_utf8_lossy(&e.into_bytes()).into()); + }; + + if arg.allow_null { + quote! { + #string_conversion + if s.len() == 0 { None } else { Some(s) } + } + } else { + quote! { + #string_conversion + s + } + } + } + Type::Fd => quote!(val), + Type::Object => { + let map_lookup = quote!(map.get(val).ok_or(())?); + if arg.allow_null { + quote!(if val == 0 { None } else { Some(#map_lookup) }) + } else { + map_lookup + } + } + Type::NewId => { + let map_lookup = quote!(map.get_new(val).ok_or(())?); + if arg.allow_null { + quote!(if val == 0 { None } else { Some(#map_lookup) }) + } else { + map_lookup + } + } + Type::Destructor => panic!("An argument cannot have type destructor!"), + }; + + let common_type = arg.typ.common_type(); + + quote! { + #field_name: { + if let Some(Argument::#common_type(val)) = args.next() { + #some_code_path + } else { + return Err(()); + } + } + } + }); + + quote! { + { + let mut args = msg.args.into_iter(); + + Ok(#msg_type_qualified { + #(#fields,)* + }) + } + } + }; + + quote!(#pattern => #block) + }) + .chain(iter::once(quote!(_ => Err(())))); + + quote! { + match msg.opcode { + #(#match_arms,)* + } + } + } else { + let panic_message = format!("{}::from_raw can not be used {:?}-side.", name, side); + quote!(panic!(#panic_message)) + }; + + let into_raw_body = if receiver { + let panic_message = format!("{}::into_raw can not be used {:?}-side.", name, side); + quote!(panic!(#panic_message)) + } else { + let match_arms = messages.iter().enumerate().map(|(opcode, msg)| { + let msg_type = Ident::new(&snake_to_camel(&msg.name), Span::call_site()); + let msg_type_qualified = quote!(#name::#msg_type); + + let pattern = if msg.args.is_empty() { + msg_type_qualified + } else { + let fields = msg + .args + .iter() + .map(|arg| Ident::new(&arg.name, Span::call_site())); + quote!(#msg_type_qualified { #(#fields),* }) + }; + + let opcode_value = Literal::u16_unsuffixed(opcode as u16); + let args_values = msg.args.iter().map(|arg| { + let arg_ident = Ident::new(&arg.name, Span::call_site()); + match arg.typ { + Type::Int => { + if arg.enum_.is_some() { + quote!(Argument::Int(#arg_ident.to_raw() as i32)) + } else { + quote!(Argument::Int(#arg_ident)) + } + } + Type::Uint => { + if arg.enum_.is_some() { + quote!(Argument::Uint(#arg_ident.to_raw())) + } else { + quote!(Argument::Uint(#arg_ident)) + } + } + Type::Fixed => quote!(Argument::Fixed((#arg_ident * 256.) as i32)), + Type::String => { + if arg.allow_null { + quote! { + Argument::Str(unsafe { + ::std::ffi::CString::from_vec_unchecked( + #arg_ident.map(Into::into).unwrap_or_else(Vec::new), + ) + }) + } + } else { + quote! { + Argument::Str(unsafe { + ::std::ffi::CString::from_vec_unchecked(#arg_ident.into()) + }) + } + } + } + Type::Array => { + if arg.allow_null { + quote!(Argument::Array(#arg_ident.unwrap_or_else(Vec::new))) + } else { + quote!(Argument::Array(#arg_ident)) + } + } + Type::Fd => quote!(Argument::Fd(#arg_ident)), + Type::NewId => { + if arg.interface.is_some() { + quote!(Argument::NewId(#arg_ident.id())) + } else { + quote! { + Argument::Str(unsafe { + ::std::ffi::CString::from_vec_unchecked(#arg_ident.0.into()) + }), + Argument::Uint(#arg_ident.1), + Argument::NewId(#arg_ident.2.id()) + } + } + } + Type::Object => { + if arg.allow_null { + quote!(Argument::Object(#arg_ident.map(|o| o.id()).unwrap_or(0))) + } else { + quote!(Argument::Object(#arg_ident.id())) + } + } + Type::Destructor => panic!("An argument cannot have type Destructor"), + } + }); + + quote!(#pattern => Message { + sender_id: sender_id, + opcode: #opcode_value, + args: vec![ + #(#args_values,)* + ], + }) + }); + + quote! { + match self { + #(#match_arms,)* + } + } + }; + + quote! { + pub enum #name { + #(#variants,)* + } + + impl super::MessageGroup for #name { + const MESSAGES: &'static [super::MessageDesc] = &[ + #(#message_array_values,)* + ]; + + type Map = super::#map_type; + + fn is_destructor(&self) -> bool { + match *self { + #(#is_destructor_match_arms,)* + } + } + + fn opcode(&self) -> u16 { + match *self { + #(#opcode_match_arms,)* + } + } + + fn child<Meta: ObjectMetadata>(opcode: u16, version: u32, meta: &Meta) -> Option<Object<Meta>> { + match opcode { + #(#child_match_arms,)* + } + } + + fn from_raw(msg: Message, map: &mut Self::Map) -> Result<Self, ()> { + #from_raw_body + } + + fn into_raw(self, sender_id: u32) -> Message { + #into_raw_body + } + + #addon + } + } +} + +pub(crate) fn gen_interface( + name: &Ident, + low_name: &str, + version: u32, + addon: Option<TokenStream>, +) -> TokenStream { + let version_lit = Literal::u32_unsuffixed(version); + + quote! { + pub struct #name; + + impl Interface for #name { + type Request = Request; + type Event = Event; + const NAME: &'static str = #low_name; + const VERSION: u32 = #version_lit; + + #addon + } + } +} + +pub fn method_prototype<'a>(iname: &Ident, msg: &'a Message) -> (TokenStream, Option<&'a Arg>) { + let mut it = msg.args.iter().filter(|arg| arg.typ == Type::NewId); + let newid = it.next(); + assert!( + newid.is_none() || it.next().is_none(), + "Request {}.{} returns more than one new_id", + iname, + msg.name + ); + + let fn_name = Ident::new( + &format!("{}{}", if is_keyword(&msg.name) { "_" } else { "" }, msg.name), + Span::call_site(), + ); + + let mut args = Vec::new(); + + let generics = if let Some(arg) = newid { + if arg.interface.is_none() { + args.push(quote!(version: u32)); + Some(quote!(T: Interface, F)) + } else { + Some(quote!(F)) + } + } else { + None + }; + + args.extend(msg.args.iter().filter_map(|arg| { + let arg_type_inner = if let Some(ref name) = arg.enum_ { + dotted_to_relname(name) + } else { + match arg.typ { + Type::Object => arg + .interface + .as_ref() + .map(|iface| { + let iface_mod = Ident::new(iface, Span::call_site()); + let iface_type = Ident::new(&snake_to_camel(iface), Span::call_site()); + quote!(&Proxy<super::#iface_mod::#iface_type>) + }) + .unwrap_or(quote!(&Proxy<super::AnonymousObject>)), + Type::NewId => { + // client-side, the return-type handles that + return None; + } + _ => arg.typ.rust_type(), + } + }; + + let arg_name = Ident::new( + &format!("{}{}", if is_keyword(&arg.name) { "_" } else { "" }, arg.name), + Span::call_site(), + ); + + let arg_type = if arg.allow_null { + quote!(Option<#arg_type_inner>) + } else { + arg_type_inner + }; + + Some(quote!(#arg_name: #arg_type)) + })); + + if newid.is_some() { + args.push(quote!(implementor: F)); + } + + let (return_type, where_bounds) = if let Some(arg) = newid { + match arg.interface { + Some(ref iface) => { + let iface_mod = Ident::new(&iface, Span::call_site()); + let iface_type = Ident::new(&snake_to_camel(&iface), Span::call_site()); + + ( + quote!(Result<Proxy<super::#iface_mod::#iface_type>, ()>), + Some(quote! { + where F: FnOnce( + NewProxy<super::#iface_mod::#iface_type>, + ) -> Proxy<super::#iface_mod::#iface_type> + }), + ) + } + None => ( + quote!(Result<Proxy<T>, ()>), + Some(quote!(where F: FnOnce(NewProxy<T>) -> Proxy<T>)), + ), + } + } else { + (quote!(()), None) + }; + + let prototype = quote! { + fn #fn_name#(<#generics>)*(&self, #(#args),*) -> #return_type #where_bounds + }; + + (prototype, newid) +} + +pub(crate) fn gen_client_methods(name: &Ident, messages: &[Message]) -> TokenStream { + let methods = messages.iter().map(|msg| { + let mut docs = String::new(); + if let Some((ref short, ref long)) = msg.description { + docs += &format!("{}\n\n{}\n", short, long); + } + if let Some(Type::Destructor) = msg.typ { + docs += "\nThis is a destructor, you cannot send requests to this object any longer once this method is called."; + } + if msg.since > 1 { + docs += &format!("\nOnly available since version {} of the interface.", msg.since); + } + + let doc_attr = to_doc_attr(&docs); + let (proto, _) = method_prototype(name, &msg); + + quote! { + #doc_attr + #proto; + } + }); + + let method_impls = messages.iter().map(|msg| { + let msg_name = Ident::new(&snake_to_camel(&msg.name), Span::call_site()); + let (proto, return_type) = method_prototype(name, &msg); + + let msg_init = if msg.args.is_empty() { + TokenStream::new() + } else { + let args = msg.args.iter().map(|arg| { + let arg_name = Ident::new(&arg.name, Span::call_site()); + let arg_value = match arg.typ { + Type::NewId => { + if arg.interface.is_some() { + quote!(self.child_placeholder()) + } else { + quote!((T::NAME.into(), version, self.child_placeholder())) + } + } + Type::Object => { + if arg.allow_null { + quote!(#arg_name.map(|o| o.clone())) + } else { + quote!(#arg_name.clone()) + } + } + _ => quote!(#arg_name), + }; + + quote!(#arg_name: #arg_value) + }); + + quote!({ #(#args),* }) + }; + + let send_stmt = match return_type { + Some(ret_type) if ret_type.interface.is_none() => { + quote!(self.send_constructor(msg, implementor, Some(version))) + } + Some(_) => quote!(self.send_constructor(msg, implementor, None)), + None => quote! { + self.send(msg); + }, + }; + + quote! { + #proto { + let msg = Request::#msg_name #msg_init; + #send_stmt + } + } + }); + + quote! { + pub trait RequestsTrait { + #(#methods)* + } + + impl RequestsTrait for Proxy<#name> { + #(#method_impls)* + } + } +} diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/src/lib.rs b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/lib.rs new file mode 100644 index 0000000..8e12c56 --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/lib.rs @@ -0,0 +1,263 @@ +//! Wayland scanner crate +//! +//! +//! This crate is a rust equivalent of the wayland-scanner tool from the +//! official wayland C library. +//! +//! You can use in your build script to generate the rust code for any +//! wayland protocol file, to use alongside the `wayland_client` and +//! `wayland_server` crate to build your applications. +//! +//! ## How to use this crate +//! +//! This crate is to be used in a build script. It provides you two +//! functions, `generate_c_code` and `generate_c_interfaces`. They'll +//! allow you to generate the code to use with the `wayland_client` or +//! `wayland_server` crates for any XML wayland protocol file (NB: you don't +//! need to do it for the core protocol, which is already included in both crates). +//! +//! First, have the XML files you want to use in your project, somewhere the build script +//! will be able to read them. +//! +//! Then, you'll need to invoke both `generate_c_interfaces` *and* `generate_c_code` for +//! each of these files. +//! +//! A sample build script: +//! +//! ```no_run +//! extern crate wayland_scanner; +//! +//! use std::env::var; +//! use std::path::Path; +//! +//! use wayland_scanner::{Side, generate_c_code, generate_c_interfaces}; +//! +//! fn main() { +//! // Location of the xml file, relative to the `Cargo.toml` +//! let protocol_file = "./my_protocol.xml"; +//! +//! // Target directory for the generate files +//! let out_dir_str = var("OUT_DIR").unwrap(); +//! let out_dir = Path::new(&out_dir_str); +//! +//! generate_c_code( +//! protocol_file, +//! out_dir.join("my_protocol_api.rs"), +//! Side::Client, // Replace by `Side::Server` for server-side code +//! ); +//! +//! // interfaces are the same for client and server +//! generate_c_interfaces( +//! protocol_file, +//! out_dir.join("my_protocol_interfaces.rs") +//! ); +//! } +//! ``` +//! +//! The above example will output two `.rs` files in the `OUT_DIR` defined by +//! cargo. Then, you'll need to include these two generated files (using the +//! macro of the same name) to make this code available in your crate. +//! +//! ```ignore +//! // The generated code will import stuff from wayland_sys +//! extern crate wayland_sys; +//! extern crate wayland_client; +//! +//! // Re-export only the actual code, and then only use this re-export +//! // The `generated` module below is just some boilerplate to properly isolate stuff +//! // and avoid exposing internal details. +//! // +//! // You can use all the types from my_protocol as if they went from `wayland_client::protocol`. +//! pub use generated::client as my_protocol; +//! +//! mod generated { +//! // The generated code tends to trigger a lot of warnings +//! // so we isolate it into a very permissive module +//! #![allow(dead_code,non_camel_case_types,unused_unsafe,unused_variables)] +//! #![allow(non_upper_case_globals,non_snake_case,unused_imports)] +//! +//! pub mod interfaces { +//! // include the interfaces, they just need to be accessible to the generated code +//! // so this module is `pub` so that it can be imported by the other one. +//! include!(concat!(env!("OUT_DIR"), "/my_protocol_interfaces.rs")); +//! } +//! +//! pub mod client { +//! // If you protocol interacts with objects from other protocols, you'll need to import +//! // their modules, like so: +//! pub(crate) use wayland_client::protocol::{wl_surface, wl_region}; +//! include!(concat!(env!("OUT_DIR"), "/my_protocol_code.rs")); +//! } +//! } +//! ``` + +#![recursion_limit = "128"] +#![warn(missing_docs)] + +extern crate proc_macro2; +#[macro_use] +extern crate quote; +extern crate xml; + +use std::fs::{File, OpenOptions}; +use std::io::{Read, Write}; +use std::path::Path; +use std::process::Command; + +mod c_code_gen; +mod c_interface_gen; +mod common_gen; +mod parse; +mod protocol; +mod rust_code_gen; +mod side; +mod util; + +pub use side::Side; + +fn load_xml<P: AsRef<Path>>(prot: P) -> protocol::Protocol { + let pfile = File::open(prot.as_ref()).expect(&format!( + "Unable to open protocol file `{}`.", + prot.as_ref().display() + )); + parse::parse_stream(pfile) +} + +/// Generate the interfaces for a protocol +/// +/// See this crate's toplevel documentation for details. +/// +/// Args: +/// +/// - `protocol`: a path to the XML file describing the protocol, absolute or relative to +/// the build script using this function. +/// - `target`: the path of the file to store this interfaces in. +pub fn generate_c_interfaces<P1: AsRef<Path>, P2: AsRef<Path>>(protocol: P1, target: P2) { + let protocol = load_xml(protocol); + + { + let mut out = OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open(&target) + .unwrap(); + write!(&mut out, "{}", c_interface_gen::generate_interfaces(protocol)).unwrap(); + } + + let _ = Command::new("rustfmt").arg(target.as_ref()).status(); +} + +/// Generate the code for a protocol using the Rust implementation +/// +/// See this crate toplevel documentation for details. +/// +/// Args: +/// +/// - `protocol`: a path to the XML file describing the protocol, absolute or relative to +/// the build script using this function. +/// - `target`: the path of the file to store the code in. +/// - `side`: the side (client or server) to generate code for. +pub fn generate_rust_code<P1: AsRef<Path>, P2: AsRef<Path>>(prot: P1, target: P2, side: Side) { + let protocol = load_xml(prot); + + { + let mut out = OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open(&target) + .unwrap(); + let output = match side { + Side::Client => rust_code_gen::generate_protocol_client(protocol), + Side::Server => rust_code_gen::generate_protocol_server(protocol), + }; + + write!(&mut out, "{}", output).unwrap(); + } + + let _ = Command::new("rustfmt").arg(target.as_ref()).status(); +} + +/// Generate the code for a protocol using the C system libs +/// +/// See this crate toplevel documentation for details. +/// +/// Args: +/// +/// - `protocol`: a path to the XML file describing the protocol, absolute or relative to +/// the build script using this function. +/// - `target`: the path of the file to store the code in. +/// - `side`: the side (client or server) to generate code for. +pub fn generate_c_code<P1: AsRef<Path>, P2: AsRef<Path>>(prot: P1, target: P2, side: Side) { + let protocol = load_xml(prot); + + { + let mut out = OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open(&target) + .unwrap(); + + let output = match side { + Side::Client => c_code_gen::generate_protocol_client(protocol), + Side::Server => c_code_gen::generate_protocol_server(protocol), + }; + + write!(&mut out, "{}", output).unwrap(); + } + + let _ = Command::new("rustfmt").arg(target.as_ref()).status(); +} + +/// Generate the interfaces for a protocol from/to IO streams +/// +/// Like `generate_c_interfaces`, but takes IO Streams directly rather than filenames +/// +/// Args: +/// +/// - `protocol`: an object `Read`-able containing the XML protocol file +/// - `target`: a `Write`-able object to which the generated code will be outputted to +pub fn generate_c_interfaces_streams<P1: Read, P2: Write>(protocol: P1, target: &mut P2) { + let protocol = parse::parse_stream(protocol); + write!(target, "{}", c_interface_gen::generate_interfaces(protocol)).unwrap(); +} + +/// Generate the code for a protocol from/to IO streams using the rust implementation +/// +/// Like `generate_code`, but takes IO Streams directly rather than filenames +/// +/// Args: +/// +/// - `protocol`: an object `Read`-able containing the XML protocol file +/// - `target`: a `Write`-able object to which the generated code will be outputted to +/// - `side`: the side (client or server) to generate code for. +pub fn generate_rust_code_streams<P1: Read, P2: Write>(protocol: P1, target: &mut P2, side: Side) { + let protocol = parse::parse_stream(protocol); + let output = match side { + Side::Client => rust_code_gen::generate_protocol_client(protocol), + Side::Server => rust_code_gen::generate_protocol_server(protocol), + }; + + write!(target, "{}", output).unwrap(); +} + +/// Generate the code for a protocol from/to IO streams using the C system libs +/// +/// Like `generate_code`, but takes IO Streams directly rather than filenames +/// +/// Args: +/// +/// - `protocol`: an object `Read`-able containing the XML protocol file +/// - `target`: a `Write`-able object to which the generated code will be outputted to +/// - `side`: the side (client or server) to generate code for. +pub fn generate_c_code_streams<P1: Read, P2: Write>(protocol: P1, target: &mut P2, side: Side) { + let protocol = parse::parse_stream(protocol); + let output = match side { + Side::Client => c_code_gen::generate_protocol_client(protocol), + Side::Server => c_code_gen::generate_protocol_server(protocol), + }; + + write!(target, "{}", output.clone()).unwrap(); +} diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/src/parse.rs b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/parse.rs new file mode 100644 index 0000000..1b38356 --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/parse.rs @@ -0,0 +1,303 @@ +use protocol::*; +use std::io::Read; +use xml::attribute::OwnedAttribute; +use xml::reader::ParserConfig; +use xml::reader::XmlEvent; +use xml::EventReader; + +macro_rules! extract_from( + ($it: expr => $pattern: pat => $result: expr) => ( + match $it.next() { + Ok($pattern) => { $result }, + e => panic!("Ill-formed protocol file: {:?}", e) + } + ) +); + +macro_rules! extract_end_tag( + ($it: expr => $tag: expr) => ( + extract_from!($it => XmlEvent::EndElement { name } => { + assert!(name.local_name == $tag, "Ill-formed protocol file"); + }); + ) +); + +pub fn parse_stream<S: Read>(stream: S) -> Protocol { + let mut reader = EventReader::new_with_config(stream, ParserConfig::new().trim_whitespace(true)); + reader.next().expect("Could not read from event reader"); + let mut protocol = parse_protocol(reader); + + // yay, hardcoding things + if protocol.name == "wayland" { + // wl_callback has actually a destructor *event*, but the wayland specification + // format does not handle this. + // Luckily, wayland-scanner does, so we inject it + for interface in &mut protocol.interfaces { + if interface.name == "wl_callback" { + let done_event = &mut interface.events[0]; + assert!(done_event.name == "done"); + done_event.typ = Some(Type::Destructor); + } + } + } + + protocol +} + +fn parse_protocol<R: Read>(mut reader: EventReader<R>) -> Protocol { + let mut protocol = extract_from!( + reader => XmlEvent::StartElement { name, attributes, .. } => { + assert!(name.local_name == "protocol", "Missing protocol toplevel tag"); + assert!(attributes[0].name.local_name == "name", "Protocol must have a name"); + Protocol::new(attributes[0].value.clone()) + } + ); + + loop { + match reader.next() { + Ok(XmlEvent::StartElement { name, attributes, .. }) => { + match &name.local_name[..] { + "copyright" => { + // parse the copyright + let copyright = match reader.next() { + Ok(XmlEvent::Characters(copyright)) | Ok(XmlEvent::CData(copyright)) => copyright, + e => panic!("Ill-formed protocol file: {:?}", e), + }; + + extract_end_tag!(reader => "copyright"); + protocol.copyright = Some(copyright); + } + "interface" => { + protocol.interfaces.push(parse_interface(&mut reader, attributes)); + } + "description" => { + protocol.description = Some(parse_description(&mut reader, attributes)); + } + _ => panic!( + "Ill-formed protocol file: unexpected token `{}` in protocol {}", + name.local_name, protocol.name + ), + } + } + Ok(XmlEvent::EndElement { name }) => { + assert!( + name.local_name == "protocol", + "Unexpected closing token `{}`", + name.local_name + ); + break; + } + e => panic!("Ill-formed protocol file: {:?}", e), + } + } + + protocol +} + +fn parse_interface<R: Read>(reader: &mut EventReader<R>, attrs: Vec<OwnedAttribute>) -> Interface { + let mut interface = Interface::new(); + for attr in attrs { + match &attr.name.local_name[..] { + "name" => interface.name = attr.value, + "version" => interface.version = attr.value.parse().unwrap(), + _ => {} + } + } + + loop { + match reader.next() { + Ok(XmlEvent::StartElement { name, attributes, .. }) => match &name.local_name[..] { + "description" => interface.description = Some(parse_description(reader, attributes)), + "request" => interface.requests.push(parse_request(reader, attributes)), + "event" => interface.events.push(parse_event(reader, attributes)), + "enum" => interface.enums.push(parse_enum(reader, attributes)), + _ => panic!("Unexpected tocken: `{}`", name.local_name), + }, + Ok(XmlEvent::EndElement { ref name }) if name.local_name == "interface" => break, + _ => {} + } + } + + interface +} + +fn parse_description<R: Read>(reader: &mut EventReader<R>, attrs: Vec<OwnedAttribute>) -> (String, String) { + let mut summary = String::new(); + for attr in attrs { + match &attr.name.local_name[..] { + "summary" => summary = attr.value.split_whitespace().collect::<Vec<_>>().join(" "), + _ => {} + } + } + + let description = match reader.next() { + Ok(XmlEvent::Characters(txt)) => { + extract_end_tag!(reader => "description"); + txt + } + Ok(XmlEvent::EndElement { ref name }) if name.local_name == "description" => String::new(), + e => panic!("Ill-formed protocol file: {:?}", e), + }; + + (summary, description) +} + +fn parse_request<R: Read>(reader: &mut EventReader<R>, attrs: Vec<OwnedAttribute>) -> Message { + let mut request = Message::new(); + for attr in attrs { + match &attr.name.local_name[..] { + "name" => request.name = attr.value, + "type" => request.typ = Some(parse_type(&attr.value)), + "since" => request.since = attr.value.parse().unwrap(), + _ => {} + } + } + + loop { + match reader.next() { + Ok(XmlEvent::StartElement { name, attributes, .. }) => match &name.local_name[..] { + "description" => request.description = Some(parse_description(reader, attributes)), + "arg" => request.args.push(parse_arg(reader, attributes)), + _ => panic!("Unexpected tocken: `{}`", name.local_name), + }, + Ok(XmlEvent::EndElement { ref name }) if name.local_name == "request" => break, + _ => {} + } + } + + request +} + +fn parse_enum<R: Read>(reader: &mut EventReader<R>, attrs: Vec<OwnedAttribute>) -> Enum { + let mut enu = Enum::new(); + for attr in attrs { + match &attr.name.local_name[..] { + "name" => enu.name = attr.value, + "since" => enu.since = attr.value.parse().unwrap(), + "bitfield" => { + if &attr.value[..] == "true" { + enu.bitfield = true + } + } + _ => {} + } + } + + loop { + match reader.next() { + Ok(XmlEvent::StartElement { name, attributes, .. }) => match &name.local_name[..] { + "description" => enu.description = Some(parse_description(reader, attributes)), + "entry" => enu.entries.push(parse_entry(reader, attributes)), + _ => panic!("Unexpected tocken: `{}`", name.local_name), + }, + Ok(XmlEvent::EndElement { ref name }) if name.local_name == "enum" => break, + _ => {} + } + } + + enu +} + +fn parse_event<R: Read>(reader: &mut EventReader<R>, attrs: Vec<OwnedAttribute>) -> Message { + let mut event = Message::new(); + for attr in attrs { + match &attr.name.local_name[..] { + "name" => event.name = attr.value, + "since" => event.since = attr.value.parse().unwrap(), + _ => {} + } + } + + loop { + match reader.next() { + Ok(XmlEvent::StartElement { name, attributes, .. }) => match &name.local_name[..] { + "description" => event.description = Some(parse_description(reader, attributes)), + "arg" => event.args.push(parse_arg(reader, attributes)), + _ => panic!("Unexpected tocken: `{}`", name.local_name), + }, + Ok(XmlEvent::EndElement { ref name }) if name.local_name == "event" => break, + _ => {} + } + } + + event +} + +fn parse_arg<R: Read>(reader: &mut EventReader<R>, attrs: Vec<OwnedAttribute>) -> Arg { + let mut arg = Arg::new(); + for attr in attrs { + match &attr.name.local_name[..] { + "name" => arg.name = attr.value, + "type" => arg.typ = parse_type(&attr.value), + "summary" => arg.summary = Some(attr.value.split_whitespace().collect::<Vec<_>>().join(" ")), + "interface" => arg.interface = Some(attr.value), + "allow-null" => { + if attr.value == "true" { + arg.allow_null = true + } + } + "enum" => arg.enum_ = Some(attr.value), + _ => {} + } + } + + loop { + match reader.next() { + Ok(XmlEvent::StartElement { name, attributes, .. }) => match &name.local_name[..] { + "description" => arg.description = Some(parse_description(reader, attributes)), + _ => panic!("Unexpected tocken: `{}`", name.local_name), + }, + Ok(XmlEvent::EndElement { ref name }) if name.local_name == "arg" => break, + _ => {} + } + } + + arg +} + +fn parse_type(txt: &str) -> Type { + match txt { + "int" => Type::Int, + "uint" => Type::Uint, + "fixed" => Type::Fixed, + "string" => Type::String, + "object" => Type::Object, + "new_id" => Type::NewId, + "array" => Type::Array, + "fd" => Type::Fd, + "destructor" => Type::Destructor, + e => panic!("Unexpected type: {}", e), + } +} + +fn parse_entry<R: Read>(reader: &mut EventReader<R>, attrs: Vec<OwnedAttribute>) -> Entry { + let mut entry = Entry::new(); + for attr in attrs { + match &attr.name.local_name[..] { + "name" => entry.name = attr.value, + "value" => { + entry.value = if attr.value.starts_with("0x") { + u32::from_str_radix(&attr.value[2..], 16).unwrap() + } else { + attr.value.parse().unwrap() + }; + } + "since" => entry.since = attr.value.parse().unwrap(), + "summary" => entry.summary = Some(attr.value.split_whitespace().collect::<Vec<_>>().join(" ")), + _ => {} + } + } + + loop { + match reader.next() { + Ok(XmlEvent::StartElement { name, attributes, .. }) => match &name.local_name[..] { + "description" => entry.description = Some(parse_description(reader, attributes)), + _ => panic!("Unexpected tocken: `{}`", name.local_name), + }, + Ok(XmlEvent::EndElement { ref name }) if name.local_name == "entry" => break, + _ => {} + } + } + + entry +} diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/src/protocol.rs b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/protocol.rs new file mode 100644 index 0000000..c81eacd --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/protocol.rs @@ -0,0 +1,188 @@ +use proc_macro2::TokenStream; + +#[derive(Clone, Debug)] +pub struct Protocol { + pub name: String, + pub copyright: Option<String>, + pub description: Option<(String, String)>, + pub interfaces: Vec<Interface>, +} + +impl Protocol { + pub fn new(name: String) -> Protocol { + Protocol { + name, + copyright: None, + description: None, + interfaces: Vec::new(), + } + } +} + +#[derive(Clone, Debug)] +pub struct Interface { + pub name: String, + pub version: u32, + pub description: Option<(String, String)>, + pub requests: Vec<Message>, + pub events: Vec<Message>, + pub enums: Vec<Enum>, +} + +impl Interface { + pub fn new() -> Interface { + Interface { + name: String::new(), + version: 1, + description: None, + requests: Vec::new(), + events: Vec::new(), + enums: Vec::new(), + } + } +} + +#[derive(Clone, Debug)] +pub struct Message { + pub name: String, + pub typ: Option<Type>, + pub since: u16, + pub description: Option<(String, String)>, + pub args: Vec<Arg>, + pub type_index: usize, +} + +impl Message { + pub fn new() -> Message { + Message { + name: String::new(), + typ: None, + since: 1, + description: None, + args: Vec::new(), + type_index: 0, + } + } + + pub fn all_null(&self) -> bool { + self.args + .iter() + .all(|a| !((a.typ == Type::Object || a.typ == Type::NewId) && a.interface.is_some())) + } +} + +#[derive(Clone, Debug)] +pub struct Arg { + pub name: String, + pub typ: Type, + pub interface: Option<String>, + pub summary: Option<String>, + pub description: Option<(String, String)>, + pub allow_null: bool, + pub enum_: Option<String>, +} + +impl Arg { + pub fn new() -> Arg { + Arg { + name: String::new(), + typ: Type::Object, + interface: None, + summary: None, + description: None, + allow_null: false, + enum_: None, + } + } +} + +#[derive(Clone, Debug)] +pub struct Enum { + pub name: String, + pub since: u16, + pub description: Option<(String, String)>, + pub entries: Vec<Entry>, + pub bitfield: bool, +} + +impl Enum { + pub fn new() -> Enum { + Enum { + name: String::new(), + since: 1, + description: None, + entries: Vec::new(), + bitfield: false, + } + } +} + +#[derive(Clone, Debug)] +pub struct Entry { + pub name: String, + pub value: u32, + pub since: u16, + pub description: Option<(String, String)>, + pub summary: Option<String>, +} + +impl Entry { + pub fn new() -> Entry { + Entry { + name: String::new(), + value: 0, + since: 1, + description: None, + summary: None, + } + } +} + +#[derive(Debug, PartialEq, Eq, Copy, Clone)] +pub enum Type { + Int, + Uint, + Fixed, + String, + Object, + NewId, + Array, + Fd, + Destructor, +} + +impl Type { + pub fn nullable(&self) -> bool { + match *self { + Type::String | Type::Object | Type::NewId | Type::Array => true, + _ => false, + } + } + + pub fn rust_type(&self) -> TokenStream { + match *self { + Type::Int => quote!(i32), + Type::Uint => quote!(u32), + Type::Fixed => quote!(f64), + Type::Array => quote!(Vec<u8>), + Type::Fd => quote!(::std::os::unix::io::RawFd), + Type::String => quote!(String), + Type::Object => quote!(ProxyId), + _ => quote!(()), + } + } + + pub fn common_type(&self) -> TokenStream { + match *self { + Type::Int => quote!(Int), + Type::Uint => quote!(Uint), + Type::Fixed => quote!(Fixed), + Type::Array => quote!(Array), + Type::Fd => quote!(Fd), + Type::String => quote!(Str), + Type::Object => quote!(Object), + Type::NewId => quote!(NewId), + Type::Destructor => panic!("Destructor is not a valid argument type."), + } + } +} diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/src/rust_code_gen.rs b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/rust_code_gen.rs new file mode 100644 index 0000000..e9a7c43 --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/rust_code_gen.rs @@ -0,0 +1,114 @@ +use proc_macro2::{Ident, Span, TokenStream}; + +use common_gen::*; +use protocol::*; +use util::*; +use Side; + +pub(crate) fn generate_protocol_client(protocol: Protocol) -> TokenStream { + let modules = protocol.interfaces.iter().map(|iface| { + let doc_attr = iface.description.as_ref().map(description_to_doc_attr); + let mod_name = Ident::new(&iface.name, Span::call_site()); + let iface_name = Ident::new(&snake_to_camel(&iface.name), Span::call_site()); + + let enums = &iface.enums; + let requests = gen_messagegroup( + &Ident::new("Request", Span::call_site()), + Side::Client, + false, + &iface.requests, + None, + ); + let events = gen_messagegroup( + &Ident::new("Event", Span::call_site()), + Side::Client, + true, + &iface.events, + None, + ); + let interface = gen_interface( + &iface_name, + &iface.name, + iface.version, + None, + ); + let client_methods = gen_client_methods(&iface_name, &iface.requests); + let sinces = gen_since_constants(&iface.requests, &iface.events); + + quote! { + #doc_attr + pub mod #mod_name { + use super::{ + Proxy, NewProxy, AnonymousObject, Interface, MessageGroup, MessageDesc, ArgumentType, Object, + Message, Argument, ObjectMetadata, + }; + + #(#enums)* + #requests + #events + #interface + #client_methods + #sinces + } + } + }); + + quote! { + #(#modules)* + } +} + +pub(crate) fn generate_protocol_server(protocol: Protocol) -> TokenStream { + let modules = protocol + .interfaces + .iter() + // display and registry are handled specially + .filter(|iface| iface.name != "wl_display" && iface.name != "wl_registry") + .map(|iface| { + let doc_attr = iface.description.as_ref().map(description_to_doc_attr); + let mod_name = Ident::new(&iface.name, Span::call_site()); + + let enums = &iface.enums; + let requests = gen_messagegroup( + &Ident::new("Request", Span::call_site()), + Side::Server, + true, + &iface.requests, + None, + ); + let events = gen_messagegroup( + &Ident::new("Event", Span::call_site()), + Side::Server, + false, + &iface.events, + None, + ); + let interface = gen_interface( + &Ident::new(&snake_to_camel(&iface.name), Span::call_site()), + &iface.name, + iface.version, + None, + ); + let sinces = gen_since_constants(&iface.requests, &iface.events); + + quote! { + #doc_attr + pub mod #mod_name { + use super::{ + Resource, NewResource, AnonymousObject, Interface, MessageGroup, MessageDesc, + ArgumentType, Object, Message, Argument, ObjectMetadata + }; + + #(#enums)* + #requests + #events + #interface + #sinces + } + } + }); + + quote! { + #(#modules)* + } +} diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/src/side.rs b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/side.rs new file mode 100644 index 0000000..c8ea7b5 --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/side.rs @@ -0,0 +1,27 @@ +use proc_macro2::{Ident, Span}; + +use self::Side::{Client, Server}; + +/// Side to generate +/// +/// This enum represents the two possible sides of +/// the protocol API that can be generated. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub enum Side { + /// wayland client applications + Client, + /// wayland compositors + Server, +} + +impl Side { + pub(crate) fn object_name(&self) -> Ident { + Ident::new( + match *self { + Client => "Proxy", + Server => "Resource", + }, + Span::call_site(), + ) + } +} diff --git a/third_party/cargo/vendor/wayland-scanner-0.21.13/src/util.rs b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/util.rs new file mode 100644 index 0000000..cb7bfcc --- /dev/null +++ b/third_party/cargo/vendor/wayland-scanner-0.21.13/src/util.rs @@ -0,0 +1,56 @@ +#[allow(unused_imports)] +#[allow(deprecated)] +use std::ascii::AsciiExt; + +use proc_macro2::{Ident, Literal, Span, TokenStream}; +use quote::ToTokens; + +pub fn is_keyword(txt: &str) -> bool { + match txt { + "abstract" | "alignof" | "as" | "become" | "box" | "break" | "const" | "continue" | "crate" + | "do" | "else" | "enum" | "extern" | "false" | "final" | "fn" | "for" | "if" | "impl" | "in" + | "let" | "loop" | "macro" | "match" | "mod" | "move" | "mut" | "offsetof" | "override" | "priv" + | "proc" | "pub" | "pure" | "ref" | "return" | "Self" | "self" | "sizeof" | "static" | "struct" + | "super" | "trait" | "true" | "type" | "typeof" | "unsafe" | "unsized" | "use" | "virtual" + | "where" | "while" | "yield" => true, + _ => false, + } +} + +pub fn snake_to_camel(input: &str) -> String { + input + .split('_') + .flat_map(|s| { + let mut first = true; + s.chars().map(move |c| { + if first { + first = false; + c.to_ascii_uppercase() + } else { + c + } + }) + }) + .collect() +} + +pub fn dotted_to_relname(input: &str) -> TokenStream { + let mut it = input.split('.'); + match (it.next(), it.next()) { + (Some(module), Some(name)) => { + let module = Ident::new(module, Span::call_site()); + let ident = Ident::new(&snake_to_camel(name), Span::call_site()); + quote!(super::#module::#ident) + } + (Some(name), None) => Ident::new(&snake_to_camel(name), Span::call_site()).into_token_stream(), + _ => unreachable!(), + } +} + +pub fn null_terminated_byte_string_literal(string: &str) -> Literal { + let mut val = Vec::with_capacity(string.len() + 1); + val.extend_from_slice(string.as_bytes()); + val.push(0); + + Literal::byte_string(&val) +} diff --git a/third_party/cargo/vendor/wayland-sys-0.21.13/.cargo-checksum.json b/third_party/cargo/vendor/wayland-sys-0.21.13/.cargo-checksum.json new file mode 100644 index 0000000..fbd7b4c --- /dev/null +++ b/third_party/cargo/vendor/wayland-sys-0.21.13/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"7cddc896d877462c39607c425bb316cf81b82a399220d1a588d8aa19f8b4274c","src/client.rs":"7dbbf4fb912bbec1c10432477481090d5a1b9ac9ebe9fa3b81c72d241242e2aa","src/common.rs":"774f90ec31abc6e068fe35d97a259025d55f565988a7f1f2d12c13ef0ae144ed","src/cursor.rs":"ceb17c70bda7afa6ab3c9bfcde9bfcea40428349fee8c6320fadf5ee06c5ebae","src/egl.rs":"97d58a5d7fbe31ef8f9db1149e20c60182852eb76568837a96147b5dc0ed9146","src/lib.rs":"1fed396945858ed84b56800b4dc3aee2ff2d3036d5bfc336becb05ce8d991e1f","src/server.rs":"7021ed5a52c6ddb23860fcf535c31fbd27907269df928bf90eb60bc24b757999"},"package":"520ab0fd578017a0ee2206623ba9ef4afe5e8f23ca7b42f6acfba2f4e66b1628"} \ No newline at end of file diff --git a/third_party/cargo/vendor/wayland-sys-0.21.13/BUILD b/third_party/cargo/vendor/wayland-sys-0.21.13/BUILD new file mode 100644 index 0000000..56c9877 --- /dev/null +++ b/third_party/cargo/vendor/wayland-sys-0.21.13/BUILD @@ -0,0 +1,50 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "wayland_sys", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/dlib-0.4.1:dlib", + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.21.13", + crate_features = [ + "client", + "cursor", + "dlib", + "dlopen", + "egl", + "lazy_static", + ], +) + diff --git a/third_party/cargo/vendor/wayland-sys-0.21.13/Cargo.toml b/third_party/cargo/vendor/wayland-sys-0.21.13/Cargo.toml new file mode 100644 index 0000000..f0313c3 --- /dev/null +++ b/third_party/cargo/vendor/wayland-sys-0.21.13/Cargo.toml @@ -0,0 +1,42 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "wayland-sys" +version = "0.21.13" +authors = ["Victor Berger <victor.berger@m4x.org>"] +description = "FFI bindings to the various libwayland-*.so libraries. You should only need this crate if you are working on custom wayland protocol extensions. Look at the crate wayland-client for usable bindings." +documentation = "https://smithay.github.io/wayland-rs/wayland_sys/" +categories = ["external-ffi-bindings"] +license = "MIT" +repository = "https://github.com/smithay/wayland-rs" +[package.metadata.docs.rs] +all-features = true +[dependencies.dlib] +version = "0.4" + +[dependencies.lazy_static] +version = "1" +optional = true + +[dependencies.libc] +version = "0.2" +optional = true + +[features] +client = [] +cursor = [] +dlopen = ["dlib/dlopen", "lazy_static"] +egl = [] +server = ["libc"] +[badges.travis-ci] +repository = "Smithay/wayland-rs" diff --git a/third_party/cargo/vendor/wayland-sys-0.21.13/src/client.rs b/third_party/cargo/vendor/wayland-sys-0.21.13/src/client.rs new file mode 100644 index 0000000..dfe22cc --- /dev/null +++ b/third_party/cargo/vendor/wayland-sys-0.21.13/src/client.rs @@ -0,0 +1,121 @@ +//! Bindings to the client library `libwayland-client.so` +//! +//! The generated handle is named `WAYLAND_CLIENT_HANDLE` + +#![cfg_attr(rustfmt, rustfmt_skip)] + +use super::common::*; +use std::os::raw::{c_char, c_int, c_void}; + +pub enum wl_proxy {} +pub enum wl_display {} +pub enum wl_event_queue {} + +external_library!(WaylandClient, "wayland-client", + functions: + // display creation and destruction + fn wl_display_connect_to_fd(c_int) -> *mut wl_display, + fn wl_display_connect(*const c_char) -> *mut wl_display, + fn wl_display_disconnect(*mut wl_display) -> (), + fn wl_display_get_fd(*mut wl_display) -> c_int, + // display events handling + fn wl_display_roundtrip(*mut wl_display) -> c_int, + fn wl_display_read_events(*mut wl_display) -> c_int, + fn wl_display_prepare_read(*mut wl_display) -> c_int, + fn wl_display_cancel_read(*mut wl_display) -> (), + fn wl_display_dispatch(*mut wl_display) -> c_int, + fn wl_display_dispatch_pending(*mut wl_display) -> c_int, + // error handling + fn wl_display_get_error(*mut wl_display) -> c_int, + fn wl_display_get_protocol_error(*mut wl_display, *mut *mut wl_interface, *mut u32) -> u32, + // requests handling + fn wl_display_flush(*mut wl_display) -> c_int, + + // event queues + fn wl_event_queue_destroy(*mut wl_event_queue) -> (), + fn wl_display_create_queue(*mut wl_display) -> *mut wl_event_queue, + fn wl_display_roundtrip_queue(*mut wl_display, *mut wl_event_queue) -> c_int, + fn wl_display_prepare_read_queue(*mut wl_display, *mut wl_event_queue) -> c_int, + fn wl_display_dispatch_queue(*mut wl_display, *mut wl_event_queue) -> c_int, + fn wl_display_dispatch_queue_pending(*mut wl_display, *mut wl_event_queue) -> c_int, + + // proxys + fn wl_proxy_create(*mut wl_proxy, *const wl_interface) -> *mut wl_proxy, + fn wl_proxy_destroy(*mut wl_proxy) -> (), + fn wl_proxy_add_listener(*mut wl_proxy, *mut extern fn(), *mut c_void) -> c_int, + fn wl_proxy_get_listener(*mut wl_proxy) -> *const c_void, + fn wl_proxy_add_dispatcher(*mut wl_proxy, wl_dispatcher_func_t, *const c_void, *mut c_void) -> c_int, + fn wl_proxy_marshal_array_constructor(*mut wl_proxy, u32, *mut wl_argument, *const wl_interface) -> *mut wl_proxy, + fn wl_proxy_marshal_array_constructor_versioned(*mut wl_proxy, u32, *mut wl_argument, *const wl_interface, u32) -> *mut wl_proxy, + fn wl_proxy_marshal_array(*mut wl_proxy, u32, *mut wl_argument ) -> (), + fn wl_proxy_set_user_data(*mut wl_proxy, *mut c_void) -> (), + fn wl_proxy_get_user_data(*mut wl_proxy) -> *mut c_void, + fn wl_proxy_get_id(*mut wl_proxy) -> u32, + fn wl_proxy_get_class(*mut wl_proxy) -> *const c_char, + fn wl_proxy_set_queue(*mut wl_proxy, *mut wl_event_queue) -> (), + fn wl_proxy_get_version(*mut wl_proxy) -> u32, + fn wl_proxy_create_wrapper(*mut wl_proxy) -> *mut wl_proxy, + fn wl_proxy_wrapper_destroy(*mut wl_proxy) -> (), + + // log + fn wl_log_set_handler_client(wl_log_func_t) -> (), + + // lists + fn wl_list_init(*mut wl_list) -> (), + fn wl_list_insert(*mut wl_list, *mut wl_list) -> (), + fn wl_list_remove(*mut wl_list) -> (), + fn wl_list_length(*const wl_list) -> c_int, + fn wl_list_empty(*const wl_list) -> c_int, + fn wl_list_insert_list(*mut wl_list,*mut wl_list) -> (), + + // arrays + fn wl_array_init(*mut wl_array) -> (), + fn wl_array_release(*mut wl_array) -> (), + fn wl_array_add(*mut wl_array,usize) -> (), + fn wl_array_copy(*mut wl_array, *mut wl_array) -> (), + + varargs: + fn wl_proxy_marshal_constructor(*mut wl_proxy, u32, *const wl_interface) -> *mut wl_proxy, + fn wl_proxy_marshal_constructor_versioned(*mut wl_proxy, u32, *const wl_interface, u32) -> *mut wl_proxy, + fn wl_proxy_marshal(*mut wl_proxy, u32) -> (), +); + +#[cfg(feature = "dlopen")] +lazy_static!( + pub static ref WAYLAND_CLIENT_OPTION: Option<WaylandClient> = { + // This is a workaround for Ubuntu 17.04, which doesn't have a bare symlink + // for libwayland-client.so but does have it with the version numbers for + // whatever reason. + // + // We could do some trickery with str slices but that is more trouble + // than its worth + let versions = ["libwayland-client.so", + "libwayland-client.so.0"]; + for ver in &versions { + match WaylandClient::open(ver) { + Ok(h) => return Some(h), + Err(::dlib::DlError::NotFound) => continue, + Err(::dlib::DlError::MissingSymbol(s)) => { + if ::std::env::var_os("WAYLAND_RS_DEBUG").is_some() { + // only print debug messages if WAYLAND_RS_DEBUG is set + eprintln!("[wayland-client] Found library {} cannot be used: symbol {} is missing.", ver, s); + } + return None; + } + } + } + None + }; + pub static ref WAYLAND_CLIENT_HANDLE: &'static WaylandClient = { + WAYLAND_CLIENT_OPTION.as_ref().expect("Library libwayland-client.so could not be loaded.") + }; +); + +#[cfg(not(feature = "dlopen"))] +pub fn is_lib_available() -> bool { + true +} +#[cfg(feature = "dlopen")] +pub fn is_lib_available() -> bool { + WAYLAND_CLIENT_OPTION.is_some() +} diff --git a/third_party/cargo/vendor/wayland-sys-0.21.13/src/common.rs b/third_party/cargo/vendor/wayland-sys-0.21.13/src/common.rs new file mode 100644 index 0000000..7681d9b --- /dev/null +++ b/third_party/cargo/vendor/wayland-sys-0.21.13/src/common.rs @@ -0,0 +1,71 @@ +//! Various types and functions that are used by both the client and the server +//! libraries. + +use std::os::raw::{c_char, c_int, c_void}; +use std::os::unix::io::RawFd; + +#[repr(C)] +pub struct wl_message { + pub name: *const c_char, + pub signature: *const c_char, + pub types: *const *const wl_interface, +} + +#[repr(C)] +pub struct wl_interface { + pub name: *const c_char, + pub version: c_int, + pub request_count: c_int, + pub requests: *const wl_message, + pub event_count: c_int, + pub events: *const wl_message, +} + +#[repr(C)] +pub struct wl_list { + pub prev: *mut wl_list, + pub next: *mut wl_list, +} + +#[repr(C)] +pub struct wl_array { + pub size: usize, + pub alloc: usize, + pub data: *mut c_void, +} + +pub type wl_fixed_t = i32; + +pub fn wl_fixed_to_double(f: wl_fixed_t) -> f64 { + f as f64 / 256. +} + +pub fn wl_fixed_from_double(d: f64) -> wl_fixed_t { + (d * 256.) as i32 +} + +pub fn wl_fixed_to_int(f: wl_fixed_t) -> i32 { + f / 256 +} + +pub fn wl_fixed_from_int(i: i32) -> wl_fixed_t { + i * 256 +} + +// must be the appropriate size +// can contain i32, u32 and pointers +#[repr(C)] +pub union wl_argument { + pub i: i32, + pub u: u32, + pub f: wl_fixed_t, + pub s: *const c_char, + pub o: *const c_void, + pub n: u32, + pub a: *const wl_array, + pub h: RawFd, +} + +pub type wl_dispatcher_func_t = + unsafe extern "C" fn(*const c_void, *mut c_void, u32, *const wl_message, *const wl_argument) -> c_int; +pub type wl_log_func_t = unsafe extern "C" fn(*const c_char, ...); diff --git a/third_party/cargo/vendor/wayland-sys-0.21.13/src/cursor.rs b/third_party/cargo/vendor/wayland-sys-0.21.13/src/cursor.rs new file mode 100644 index 0000000..73e1644 --- /dev/null +++ b/third_party/cargo/vendor/wayland-sys-0.21.13/src/cursor.rs @@ -0,0 +1,80 @@ +//! Bindings to the `wayland-cursor.so` library +//! +//! The created handle is named `WAYLAND_CURSOR_HANDLE`. + +use client::wl_proxy; +use std::os::raw::{c_char, c_int, c_uint}; + +pub enum wl_cursor_theme {} + +#[repr(C)] +pub struct wl_cursor_image { + /// actual width + pub width: u32, + /// actual height + pub height: u32, + /// hot spot x (must be inside image) + pub hotspot_x: u32, + /// hot spot y (must be inside image) + pub hotspot_y: u32, + /// animation delay to next frame + pub delay: u32, +} + +#[repr(C)] +pub struct wl_cursor { + pub image_count: c_uint, + pub images: *mut *mut wl_cursor_image, + pub name: *mut c_char, +} + +external_library!(WaylandCursor, "wayland-cursor", + functions: + fn wl_cursor_theme_load(*const c_char, c_int, *mut wl_proxy) -> *mut wl_cursor_theme, + fn wl_cursor_theme_destroy(*mut wl_cursor_theme) -> (), + fn wl_cursor_theme_get_cursor(*mut wl_cursor_theme, *const c_char) -> *mut wl_cursor, + fn wl_cursor_image_get_buffer(*mut wl_cursor_image) -> *mut wl_proxy, + fn wl_cursor_frame(*mut wl_cursor, u32) -> c_int, + fn wl_cursor_frame_and_duration(*mut wl_cursor, u32, *mut u32) -> c_int, +); + +#[cfg(feature = "dlopen")] +lazy_static!( + pub static ref WAYLAND_CURSOR_OPTION: Option<WaylandCursor> = { + // This is a workaround for Ubuntu 17.04, which doesn't have a bare symlink + // for libwayland-client.so but does have it with the version numbers for + // whatever reason. + // + // We could do some trickery with str slices but that is more trouble + // than its worth + let versions = ["libwayland-cursor.so", + "libwayland-cursor.so.0"]; + + for ver in &versions { + match WaylandCursor::open(ver) { + Ok(h) => return Some(h), + Err(::dlib::DlError::NotFound) => continue, + Err(::dlib::DlError::MissingSymbol(s)) => { + if ::std::env::var_os("WAYLAND_RS_DEBUG").is_some() { + // only print debug messages if WAYLAND_RS_DEBUG is set + eprintln!("[wayland-client] Found library {} cannot be used: symbol {} is missing.", ver, s); + } + return None; + } + } + } + None + }; + pub static ref WAYLAND_CURSOR_HANDLE: &'static WaylandCursor = { + WAYLAND_CURSOR_OPTION.as_ref().expect("Library libwayland-cursor.so could not be loaded.") + }; +); + +#[cfg(not(feature = "dlopen"))] +pub fn is_lib_available() -> bool { + true +} +#[cfg(feature = "dlopen")] +pub fn is_lib_available() -> bool { + WAYLAND_CURSOR_OPTION.is_some() +} diff --git a/third_party/cargo/vendor/wayland-sys-0.21.13/src/egl.rs b/third_party/cargo/vendor/wayland-sys-0.21.13/src/egl.rs new file mode 100644 index 0000000..4c48d38 --- /dev/null +++ b/third_party/cargo/vendor/wayland-sys-0.21.13/src/egl.rs @@ -0,0 +1,59 @@ +//! Bindings to the EGL library `libwayland-egl.so` +//! +//! This lib allows to create EGL surfaces out of wayland surfaces. +//! +//! The created handle is named `WAYLAND_EGl_HANDLE`. + +use client::wl_proxy; +use std::os::raw::c_int; + +pub enum wl_egl_window {} + +external_library!(WaylandEgl, "wayland-egl", + functions: + fn wl_egl_window_create(*mut wl_proxy, c_int, c_int) -> *mut wl_egl_window, + fn wl_egl_window_destroy(*mut wl_egl_window) -> (), + fn wl_egl_window_resize(*mut wl_egl_window, c_int, c_int, c_int, c_int) -> (), + fn wl_egl_window_get_attached_size(*mut wl_egl_window, *mut c_int, *mut c_int) -> (), +); + +#[cfg(feature = "dlopen")] +lazy_static!( + pub static ref WAYLAND_EGL_OPTION: Option<WaylandEgl> = { + // This is a workaround for Ubuntu 17.04, which doesn't have a bare symlink + // for libwayland-client.so but does have it with the version numbers for + // whatever reason. + // + // We could do some trickery with str slices but that is more trouble + // than its worth + let versions = ["libwayland-egl.so", + "libwayland-egl.so.1"]; + + for ver in &versions { + match WaylandEgl::open(ver) { + Ok(h) => return Some(h), + Err(::dlib::DlError::NotFound) => continue, + Err(::dlib::DlError::MissingSymbol(s)) => { + if ::std::env::var_os("WAYLAND_RS_DEBUG").is_some() { + // only print debug messages if WAYLAND_RS_DEBUG is set + eprintln!("[wayland-client] Found library {} cannot be used: symbol {} is missing.", ver, s); + } + return None; + } + } + } + None + }; + pub static ref WAYLAND_EGL_HANDLE: &'static WaylandEgl = { + WAYLAND_EGL_OPTION.as_ref().expect("Library libwayland-egl.so could not be loaded.") + }; +); + +#[cfg(not(feature = "dlopen"))] +pub fn is_lib_available() -> bool { + true +} +#[cfg(feature = "dlopen")] +pub fn is_lib_available() -> bool { + WAYLAND_EGL_OPTION.is_some() +} diff --git a/third_party/cargo/vendor/wayland-sys-0.21.13/src/lib.rs b/third_party/cargo/vendor/wayland-sys-0.21.13/src/lib.rs new file mode 100644 index 0000000..fbb65bc --- /dev/null +++ b/third_party/cargo/vendor/wayland-sys-0.21.13/src/lib.rs @@ -0,0 +1,94 @@ +//! FFI bindings to the wayland system libraries. +//! +//! The names exported by this crate should *not* be used directly, but though +//! the `ffi_dispatch` macro like this: +//! +//! ```ignore +//! ffi_dispatch!(HANDLE_NAME, func_name, arg1, arg2, arg3); +//! ``` +//! +//! Where `HANDLE_NAME` is the name of the handle generated if the cargo feature +//! `dlopen` is on. +//! +//! For this to work, you must ensure every needed symbol is in scope (aka the static handle +//! if `dlopen` is on, the extern function if not). The easiest way to do this is to glob import +//! the appropriate module. For example: +//! +//! ```ignore +//! #[macro_use] extern crate wayland_sys; +//! +//! use wayland_sys::client::*; +//! +//! fn main() { +//! let display_ptr = unsafe { +//! ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_connect, ::std::ptr::null()) +//! }; +//! } +//! ``` +//! +//! Each module except `common` corresponds to a system library. They all define a function named +//! `is_lib_available()` which returns a boolean depending on whether the lib could be loaded. +//! They always return true if the feature `dlopen` is absent, as the lib is then directly linked. + +#![allow(non_camel_case_types)] + +// If compiling with neither the `client` or `server` feature (non-sensical but +// it's what happens when running `cargo test --all` from the workspace root), +// dlib isn't actually used. This is not an issue, so don't warn about it. +#[allow(unused_imports)] +#[macro_use] +extern crate dlib; + +// Same as with dlib, only that it's a little harder to accidentally trigger +// (dlopen feature enabled, client and server features disabled) +#[allow(unused_imports)] +#[cfg(feature = "dlopen")] +#[macro_use] +extern crate lazy_static; + +#[cfg(feature = "server")] +extern crate libc; + +/// Magic pointer for wayland objects managed by wayland-client or wayland-server +/// +/// This static serves no purpose other than existing, and thus providing a stable pointer +/// to something we know what it is. +/// +/// It is used internally by wayland-client, wayland-server and wayland-scanner to ensure safety +/// regarding to wayland objects that are created by some other library. +pub static RUST_MANAGED: u8 = 42; + +pub mod common; + +#[cfg(feature = "client")] +pub mod client; + +#[cfg(feature = "server")] +pub mod server; + +#[cfg(all(feature = "egl", feature = "client"))] +pub mod egl; + +#[cfg(all(feature = "cursor", feature = "client"))] +pub mod cursor; + +#[cfg(feature = "server")] +pub use libc::{gid_t, pid_t, uid_t}; + +// Small hack while #[macro_reexport] is not stable + +#[cfg(feature = "dlopen")] +#[macro_export] +macro_rules! ffi_dispatch( + ($handle: ident, $func: ident, $($arg: expr),*) => ( + ($handle.$func)($($arg),*) + ) +); + +#[cfg(not(feature = "dlopen"))] +#[macro_export] +macro_rules! ffi_dispatch( + ($handle: ident, $func: ident, $($arg: expr),*) => ( + $func($($arg),*) + ) +); diff --git a/third_party/cargo/vendor/wayland-sys-0.21.13/src/server.rs b/third_party/cargo/vendor/wayland-sys-0.21.13/src/server.rs new file mode 100644 index 0000000..753f186 --- /dev/null +++ b/third_party/cargo/vendor/wayland-sys-0.21.13/src/server.rs @@ -0,0 +1,302 @@ +//! Bindings to the client library `libwayland-server.so` +//! +//! The generated handle is named `WAYLAND_SERVER_HANDLE` + +#![cfg_attr(rustfmt, rustfmt_skip)] + +use super::common::*; +use libc::{gid_t, pid_t, uid_t}; +use std::os::raw::{c_char, c_int, c_void}; + +pub enum wl_client {} +pub enum wl_display {} +pub enum wl_event_loop {} +pub enum wl_event_source {} +pub enum wl_global {} +pub enum wl_resource {} +pub enum wl_shm_buffer {} + +pub type wl_event_loop_fd_func_t = unsafe extern "C" fn(c_int, u32, *mut c_void) -> c_int; +pub type wl_event_loop_timer_func_t = unsafe extern "C" fn(*mut c_void) -> c_int; +pub type wl_event_loop_signal_func_t = unsafe extern "C" fn(c_int, *mut c_void) -> c_int; +pub type wl_event_loop_idle_func_t = unsafe extern "C" fn(*mut c_void) -> (); +pub type wl_global_bind_func_t = unsafe extern "C" fn(*mut wl_client, *mut c_void, u32, u32) -> (); +pub type wl_notify_func_t = unsafe extern "C" fn(*mut wl_listener, *mut c_void) -> (); +pub type wl_resource_destroy_func_t = unsafe extern "C" fn(*mut wl_resource) -> (); +pub type wl_display_global_filter_func_t = unsafe extern "C" fn(*const wl_client, *const wl_global, *mut c_void) -> bool; + +#[repr(C)] +pub struct wl_listener { + pub link: wl_list, + pub notify: wl_notify_func_t, +} + +#[repr(C)] +pub struct wl_signal { + pub listener_list: wl_list, +} + +external_library!(WaylandServer, "wayland-server", + functions: + // wl_client + fn wl_client_flush(*mut wl_client) -> (), + fn wl_client_destroy(*mut wl_client) -> (), + fn wl_client_get_display(*mut wl_client) -> *mut wl_display, + fn wl_client_get_credentials(*mut wl_client, *mut pid_t, *mut uid_t, *mut gid_t) -> (), + fn wl_client_get_object(*mut wl_client, u32) -> *mut wl_resource, + fn wl_client_add_destroy_listener(*mut wl_client, *mut wl_listener) -> (), + fn wl_client_get_destroy_listener(*mut wl_client, wl_notify_func_t) -> *mut wl_listener, + fn wl_client_post_no_memory(*mut wl_client) -> (), + fn wl_resource_create(*mut wl_client, *const wl_interface, c_int, u32) -> *mut wl_resource, + // wl_display + fn wl_client_create(*mut wl_display, c_int) -> *mut wl_client, + fn wl_display_create() -> *mut wl_display, + fn wl_display_destroy(*mut wl_display) -> (), + fn wl_display_destroy_clients(*mut wl_display) -> (), + fn wl_display_get_serial(*mut wl_display) -> u32, + fn wl_display_next_serial(*mut wl_display) -> u32, + fn wl_display_add_socket(*mut wl_display, *const c_char) -> c_int, + fn wl_display_add_socket_auto(*mut wl_display) -> *const c_char, + fn wl_display_add_socket_fd(*mut wl_display, c_int) -> c_int, + fn wl_display_add_shm_format(*mut wl_display, u32) -> *mut u32, + fn wl_display_get_event_loop(*mut wl_display) -> *mut wl_event_loop, + fn wl_display_terminate(*mut wl_display) -> (), + fn wl_display_run(*mut wl_display) -> (), + fn wl_display_flush_clients(*mut wl_display) -> (), + fn wl_display_add_destroy_listener(*mut wl_display, *mut wl_listener) -> (), + fn wl_display_get_destroy_listener(*mut wl_display, wl_notify_func_t) -> *mut wl_listener, + fn wl_global_create(*mut wl_display, *const wl_interface, c_int, *mut c_void, wl_global_bind_func_t) -> *mut wl_global, + fn wl_display_init_shm(*mut wl_display) -> c_int, + fn wl_display_add_client_created_listener(*mut wl_display, *mut wl_listener) -> (), + fn wl_display_set_global_filter(*mut wl_display, wl_display_global_filter_func_t, *mut c_void) -> (), + // wl_event_loop + fn wl_event_loop_create() -> *mut wl_event_loop, + fn wl_event_loop_destroy(*mut wl_event_loop) -> (), + fn wl_event_loop_add_fd(*mut wl_event_loop, c_int, u32, wl_event_loop_fd_func_t, *mut c_void) -> *mut wl_event_source, + fn wl_event_loop_add_timer(*mut wl_event_loop, wl_event_loop_timer_func_t, *mut c_void) -> *mut wl_event_source, + fn wl_event_loop_add_signal(*mut wl_event_loop, c_int, wl_event_loop_signal_func_t, *mut c_void) -> *mut wl_event_source, + fn wl_event_loop_dispatch(*mut wl_event_loop, c_int) -> c_int, + fn wl_event_loop_dispatch_idle(*mut wl_event_loop) -> (), + fn wl_event_loop_add_idle(*mut wl_event_loop, wl_event_loop_idle_func_t, *mut c_void) -> *mut wl_event_source, + fn wl_event_loop_get_fd(*mut wl_event_loop) -> c_int, + fn wl_event_loop_add_destroy_listener(*mut wl_event_loop, *mut wl_listener) -> (), + fn wl_event_loop_get_destroy_listener(*mut wl_event_loop, wl_notify_func_t) -> *mut wl_listener, + // wl_event_source + fn wl_event_source_fd_update(*mut wl_event_source, u32) -> c_int, + fn wl_event_source_timer_update(*mut wl_event_source, c_int) -> c_int, + fn wl_event_source_remove(*mut wl_event_source) -> c_int, + fn wl_event_source_check(*mut wl_event_source) -> (), + // wl_global + fn wl_global_destroy(*mut wl_global) -> (), + fn wl_global_get_user_data(*const wl_global) -> *mut c_void, + // wl_resource + fn wl_resource_post_event_array(*mut wl_resource, u32, *mut wl_argument) -> (), + fn wl_resource_queue_event_array(*mut wl_resource, u32, *mut wl_argument) -> (), + fn wl_resource_post_no_memory(*mut wl_resource) -> (), + fn wl_resource_set_implementation(*mut wl_resource, *const c_void, *mut c_void, Option<wl_resource_destroy_func_t>) -> (), + fn wl_resource_set_dispatcher(*mut wl_resource, wl_dispatcher_func_t, *const c_void, *mut c_void, Option<wl_resource_destroy_func_t>) -> (), + fn wl_resource_destroy(*mut wl_resource) -> (), + fn wl_resource_get_client(*mut wl_resource) -> *mut wl_client, + fn wl_resource_get_id(*mut wl_resource) -> u32, + fn wl_resource_get_link(*mut wl_resource) -> *mut wl_list, + fn wl_resource_from_link(*mut wl_list) -> *mut wl_resource, + fn wl_resource_find_for_client(*mut wl_list, *mut wl_client) -> (), + fn wl_resource_set_user_data(*mut wl_resource, *mut c_void) -> (), + fn wl_resource_get_user_data(*mut wl_resource) -> *mut c_void, + fn wl_resource_get_version(*mut wl_resource) -> c_int, + fn wl_resource_set_destructor(*mut wl_resource, Option<wl_resource_destroy_func_t>) -> (), + fn wl_resource_instance_of(*mut wl_resource, *const wl_interface, *const c_void) -> c_int, + fn wl_resource_add_destroy_listener(*mut wl_resource, wl_notify_func_t) -> (), + fn wl_resource_get_destroy_listener(*mut wl_resource,wl_notify_func_t) -> *mut wl_listener, + // wl_shm + fn wl_shm_buffer_begin_access(*mut wl_shm_buffer) -> (), + fn wl_shm_buffer_end_access(*mut wl_shm_buffer) -> (), + fn wl_shm_buffer_get(*mut wl_resource) -> *mut wl_shm_buffer, + fn wl_shm_buffer_get_data(*mut wl_shm_buffer) -> *mut c_void, + fn wl_shm_buffer_get_stride(*mut wl_shm_buffer) -> i32, + fn wl_shm_buffer_get_format(*mut wl_shm_buffer) -> u32, + fn wl_shm_buffer_get_width(*mut wl_shm_buffer) -> i32, + fn wl_shm_buffer_get_height(*mut wl_shm_buffer) -> i32, + // wl_log + fn wl_log_set_handler_server(wl_log_func_t) -> (), + // wl_list + fn wl_list_init(*mut wl_list) -> (), + fn wl_list_insert(*mut wl_list, *mut wl_list) -> (), + fn wl_list_remove(*mut wl_list) -> (), + fn wl_list_length(*const wl_list) -> c_int, + fn wl_list_empty(*const wl_list) -> c_int, + fn wl_list_insert_list(*mut wl_list,*mut wl_list) -> (), + + // arrays + fn wl_array_init(*mut wl_array) -> (), + fn wl_array_release(*mut wl_array) -> (), + fn wl_array_add(*mut wl_array,usize) -> (), + fn wl_array_copy(*mut wl_array, *mut wl_array) -> (), + varargs: + fn wl_resource_post_event(*mut wl_resource, u32) -> (), + fn wl_resource_queue_event(*mut wl_resource, u32) -> (), + fn wl_resource_post_error(*mut wl_resource, u32, *const c_char) -> (), +); + +#[cfg(feature = "dlopen")] +lazy_static!( + pub static ref WAYLAND_SERVER_OPTION: Option<WaylandServer> = { + // This is a workaround for Ubuntu 17.04, which doesn't have a bare symlink + // for libwayland-server.so but does have it with the version numbers for + // whatever reason. + // + // We could do some trickery with str slices but that is more trouble + // than its worth + let versions = ["libwayland-server.so", + "libwayland-server.so.0"]; + for ver in &versions { + match WaylandServer::open(ver) { + Ok(h) => return Some(h), + Err(::dlib::DlError::NotFound) => continue, + Err(::dlib::DlError::MissingSymbol(s)) => { + if ::std::env::var_os("WAYLAND_RS_DEBUG").is_some() { + // only print debug messages if WAYLAND_RS_DEBUG is set + eprintln!("[wayland-server] Found library {} cannot be used: symbol {} is missing.", ver, s); + } + return None; + } + } + } + None + }; + pub static ref WAYLAND_SERVER_HANDLE: &'static WaylandServer = { + WAYLAND_SERVER_OPTION.as_ref().expect("Library libwayland-server.so could not be loaded.") + }; +); + +#[cfg(not(feature = "dlopen"))] +pub fn is_lib_available() -> bool { + true +} +#[cfg(feature = "dlopen")] +pub fn is_lib_available() -> bool { + WAYLAND_SERVER_OPTION.is_some() +} + +pub mod signal { + #[cfg(not(feature = "dlopen"))] + use super::{wl_list_init, wl_list_insert}; + use super::{wl_listener, wl_notify_func_t, wl_signal}; + #[cfg(feature = "dlopen")] + use super::WAYLAND_SERVER_HANDLE as WSH; + use common::wl_list; + use std::os::raw::c_void; + use std::ptr; + + // TODO: Is this really not UB ? + macro_rules! offset_of( + ($ty:ty, $field:ident) => { + &(*(0 as *const $ty)).$field as *const _ as usize + } + ); + + macro_rules! container_of( + ($ptr: expr, $container: ty, $field: ident) => { + ($ptr as *mut u8).offset(-(offset_of!($container, $field) as isize)) as *mut $container + } + ); + + macro_rules! list_for_each( + ($pos: ident, $head:expr, $container: ty, $field: ident, $action: block) => { + let mut $pos = container_of!((*$head).next, $container, $field); + while &mut (*$pos).$field as *mut _ != $head { + $action; + $pos = container_of!((*$pos).$field.next, $container, $field); + } + } + ); + + macro_rules! list_for_each_safe( + ($pos: ident, $head: expr, $container: ty, $field: ident, $action: block) => { + let mut $pos = container_of!((*$head).next, $container, $field); + let mut tmp = container_of!((*$pos).$field.next, $container, $field); + while &mut (*$pos).$field as *mut _ != $head { + $action; + $pos = tmp; + tmp = container_of!((*$pos).$field.next, $container, $field); + } + } + ); + + pub unsafe fn wl_signal_init(signal: *mut wl_signal) { + ffi_dispatch!(WSH, wl_list_init, &mut (*signal).listener_list); + } + + pub unsafe fn wl_signal_add(signal: *mut wl_signal, listener: *mut wl_listener) { + ffi_dispatch!( + WSH, + wl_list_insert, + (*signal).listener_list.prev, + &mut (*listener).link + ) + } + + pub unsafe fn wl_signal_get(signal: *mut wl_signal, notify: wl_notify_func_t) -> *mut wl_listener { + list_for_each!( + l, + &mut (*signal).listener_list as *mut wl_list, + wl_listener, + link, + { + if (*l).notify == notify { + return l; + } + } + ); + + ptr::null_mut() + } + + pub unsafe fn wl_signal_emit(signal: *mut wl_signal, data: *mut c_void) { + list_for_each_safe!( + l, + &mut (*signal).listener_list as *mut wl_list, + wl_listener, + link, + { + ((*l).notify)(l, data); + } + ); + } + + #[repr(C)] + struct ListenerWithUserData { + listener: wl_listener, + user_data: *mut c_void + } + + pub fn rust_listener_create(notify: wl_notify_func_t) -> *mut wl_listener { + let data = Box::into_raw(Box::new(ListenerWithUserData { + listener: wl_listener { + link: wl_list { + prev: ptr::null_mut(), + next: ptr::null_mut() + }, + notify + }, + user_data: ptr::null_mut() + })); + + unsafe { &mut (*data).listener as *mut wl_listener } + } + + pub unsafe fn rust_listener_get_user_data(listener: *mut wl_listener) -> *mut c_void { + let data = container_of!(listener, ListenerWithUserData, listener); + (*data).user_data + } + + pub unsafe fn rust_listener_set_user_data(listener: *mut wl_listener, user_data: *mut c_void) { + let data = container_of!(listener, ListenerWithUserData, listener); + (*data).user_data = user_data + } + + pub unsafe fn rust_listener_destroy(listener: *mut wl_listener) { + let data = container_of!(listener, ListenerWithUserData, listener); + let _ = Box::from_raw(data); + } +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/.cargo-checksum.json b/third_party/cargo/vendor/winapi-0.3.8/.cargo-checksum.json new file mode 100644 index 0000000..d3c10ae --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"5abcbc529ad49ebcb07dc6d86e4a531fa8eba3bfa277d43888da813875205362","LICENSE-APACHE":"b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1","LICENSE-MIT":"ce7bc3499fee93d5022ef430d5e4201e79a6d9154f3974e42f41349f0569e09b","README.md":"e15c8581746742647e66415bd50156be53c258925a53112fdd412755064b990c","build.rs":"b531daf8ace1bad14778552b4eacd5c278fba1b16711223051f8a084a583314c","src/km/d3dkmthk.rs":"5fcafcbcf558bb9d7a1dde128dcb34f6b69bc6e8f8f5ff2017044bb64ad3a7c4","src/km/mod.rs":"d93c57482cc3a011f87b8d95d8da8fc52a1c5c053b9a143d781c276871cd1dd1","src/lib.rs":"c9dd767b72d5975a938b0c837c8939fa77054a97b9d96faa39113cfc7c0fe34f","src/macros.rs":"529d00ecca3966e234fd15499072fb125580563ea40157e89b90acd1e5b4c650","src/shared/basetsd.rs":"82ba6ee78e4ebbf097529708b48bac2e15e0f013d6727d2bd3485a545a42f883","src/shared/bcrypt.rs":"fdf4f601cf9ed10d1968e719d55164920520aaef0ba3ed98e4323bb10f53a15e","src/shared/bthdef.rs":"7441eaefe97c5040c5e35c35b82a7d2ac9a537daa29d07e07f08932378c971b5","src/shared/bthioctl.rs":"27d5e0683812a986e27eb6750cf6e7f1a6cf43e16f0146f9b25c862053243857","src/shared/bthsdpdef.rs":"5afc812a716305a50b3e68433c2e82188138ead84bab054ecadeb8e69e71b2dd","src/shared/bugcodes.rs":"cd953c51b2840aa2038a4796f880b2757ba5617be41e527944d95a3d8e8a3be0","src/shared/cderr.rs":"e7a6f1bae38bf7c250cdfd62e78fa14c8c802a474a5af37a7d66843bd414b9f1","src/shared/cfg.rs":"44ad361ebeaf518407e1e503fdb266954001c725257ff6f2227e2b8057e7b740","src/shared/d3d9.rs":"69fc61ad552bef9be90f5a78ffdd6c6cb4823451994c8fcea21afd912e052a37","src/shared/d3d9caps.rs":"29019590dbbda387c6996727d0a997d975cbd384e650b75c80c1c5bf01d92380","src/shared/d3d9types.rs":"b6d81f06499632376bef88e6285a45b2de197bd656f8a7195f5ed5c172a351ca","src/shared/d3dkmdt.rs":"50d8f2845a30cdc771d1415125d2904717932e1a0a9befbc0cd2915272580f22","src/shared/d3dukmdt.rs":"c649d821aa1894713ed5289be94b9d71f8ee19a14fdab0c7fc5af937d1df59e9","src/shared/dcomptypes.rs":"5cde7f756a06f387968e68079dafc589d85a550d9919828947abbf1fd1c95844","src/shared/devguid.rs":"20adafca4117d5aa0cd69f7f8d73d30085e80c6213946e50a8c7a05017132d8c","src/shared/devpkey.rs":"e5005b0155a06494aa97a912310d78c420e8cfa9305149b5f61400b9614aaf88","src/shared/devpropdef.rs":"f1b625bb946801689461c212afb8576d55652765729707931451d306650ad0ef","src/shared/dinputd.rs":"a9a2122adc1638076e85f135bdc2d2871072b6e2592fc86df03e26854f9d42e6","src/shared/dxgi.rs":"6d0404a4aef7be936bf9ebc8ac661c780ea678184f514ae0e69e463a60d34e66","src/shared/dxgi1_2.rs":"58cf2ec110852dfb3b05b0cb4a470852b645d5067df6931382a2d7c564dfd12b","src/shared/dxgi1_3.rs":"b612bf52e4028cf9b975a1984d30081893bd59f61fdbdc8c8f69245301af1e74","src/shared/dxgi1_4.rs":"e8fb0c4d7fbfd6c6dfc82e689c6d621fe03ae6581727c92e4d1850ef4232affa","src/shared/dxgi1_5.rs":"02f876b56707c7b7ff4357235ba423d3fba804aee024b87bdd68ba72ce24f896","src/shared/dxgi1_6.rs":"fac06d941ad2a79144988ef8c2106afcfa4049043853f2e31b13c79baa572d5f","src/shared/dxgiformat.rs":"746cb2e9c719c6d07e68305e047f56a90b7309e76bca236727d1ffeada56c2e9","src/shared/dxgitype.rs":"37c007614096e034dffd149ef479c38accf56475f9539d441b287bcfde9204bb","src/shared/evntprov.rs":"abf75f0a63b569603b8de45bc3891778831f62b9b76294cc888e32ac19fc0002","src/shared/evntrace.rs":"f09226bdba29311259a338e082fb9641c9a7c59dbaf0bc8a6e432b4dff88b341","src/shared/guiddef.rs":"3fd75e1ec6583325b7b50afb5e04cd1dbedec19b66c92349df82104b19edd2d6","src/shared/hidclass.rs":"6dcc661b29596c64ffdd17d6ff3d08c4072aae59c6f083ea1ec8cd145b800b20","src/shared/hidpi.rs":"7429e18c49bd3358edbce4d9fa0bc2236ef7be9423267748cd4a7d340c61529c","src/shared/hidsdi.rs":"27043582707d242c8483dce865b8463c0b8e0ed0f9bb5eff62aba019ed014fd5","src/shared/hidusage.rs":"23f6fceb8901da93b95637439892f52132bf072966a8e577d22b94a460031b27","src/shared/ifdef.rs":"d1367f30e92948b0612f7e96494e1e49f0467faad656677b89065949d9343911","src/shared/in6addr.rs":"a854ce17d724cfc78fbe4235ae76aeedabfd5c879ab9eab4b78895da1c4f3c6c","src/shared/inaddr.rs":"8cb93acdb7cdf5e9a34504bccbf5ad2fe000810d3866c3c6d0a778d033cf9ff3","src/shared/intsafe.rs":"030ad79543efe5bae6c6dfaff77077458a4bc876582a201f3155129a684cb1d1","src/shared/ks.rs":"90b4f80d97a1c914bbecb7ae11eb11ad45959f80540014bf70518e5688a514a0","src/shared/ksmedia.rs":"258dfaba65bbc2c76e567d41b96d5d10c2eb07281bf35b246bbeb9e918a053b4","src/shared/ktmtypes.rs":"6434171e5657c236ea20603113a8fe19ad465da8d92ef152831604cfe8d14aa9","src/shared/lmcons.rs":"a730be5fd0ef2d682986547cbeada8d6343fc9e72c063cd900b747f22cc08d34","src/shared/minwindef.rs":"08960523fa4c5c883536d88c458b2f01c3a3e611587d9eabe0fa3bf0f3cd6672","src/shared/mmreg.rs":"b9364cfe8c392fb1b791e62907df3c77426fa8c96ac78df2e991bcce667c718f","src/shared/mod.rs":"8481f974665520f1a604f1696be48db177616c7511fbe1f42cf2efbc745ba969","src/shared/mstcpip.rs":"b500e6c96dab2ffc9ab0b11be1159d768cc737252e446b65674130792a42abbe","src/shared/mswsockdef.rs":"275c695b2d98535af9250cf343ee414bbf71e186dddf80b68767d96342c31f1d","src/shared/netioapi.rs":"eaec4aa81a22dc7bb889661b843679a008c5a2c194a207940fb130b98ea5887b","src/shared/ntddscsi.rs":"b61d548dae4ed529ce76c8f7dcdc91888dc8304d6df8346e36b0818c6c7a856e","src/shared/ntddser.rs":"0c34546f7d3fdb2d3db72703b0c9f1a138ed1ef60f332f32efdceb3ed0632e85","src/shared/ntdef.rs":"c7b37accffd34a36db0504e8782250c5e366ccc8e5c7e2e2eb33715d5704061b","src/shared/ntstatus.rs":"e7363938783f8ccd66bfa2c74a4b070e31eeeb452cabdb12b686fff9fa54938f","src/shared/qos.rs":"a57fe6c5a46f203391d61040a6f0cd39fc7f440092e9155e9425785e5d816687","src/shared/rpc.rs":"ac52ba80fbbabf2e259bb815658ef4505e9e2c06b53247f666f23439c4d0e4d8","src/shared/rpcdce.rs":"f80b7b5425fde8f3da4941a7e2ce7802ae35eb6801641baf97e9deb6a4ab77b1","src/shared/rpcndr.rs":"2cc5b29942edf284544c7301c913fdbe324348111d7438a7ee2aa7031d5b6bf0","src/shared/sddl.rs":"2a542f70ee6bc4476060cfe7568bf33331dbcb4a698fece44686d4ac03eae1d6","src/shared/sspi.rs":"a347b97201ae645638ffaf7b5ab198a7710b45dcfc4246d5df24fab31ab367bf","src/shared/stralign.rs":"7f9c793ccdbd1a7d0b495a56824803c88ad9aa84fc4fc33af646befa10ca75e1","src/shared/transportsettingcommon.rs":"0791e5ddad518fa316f30bde5139a87343189a8c582e33b376e87923b6edf42b","src/shared/tvout.rs":"0a5b43d53916c9dd3a6e1637eb230068d91bf5de517b38eaefd1fb759470e551","src/shared/usb.rs":"1fee88fe372172058d52365bc764c21ad189084991b1de2ba94c1d863007f9e7","src/shared/usbiodef.rs":"ae2550d17e23ac8265a9cb983423ccc7740a1a41404a9b7ac62082ed53c626df","src/shared/usbspec.rs":"e787df4b0f7bb8b92fff4354689a1b3ed332d54f777c79560b7bba3db04273c1","src/shared/windef.rs":"3b0fa697ec4a57f9016c0bfb01df1768636c1eb6c8c4bfd5a9f16ba7d6bfee68","src/shared/windowsx.rs":"72e7f99f70a1a30f34f00bff8147e7837d2be8a9b93f005fecf1bddcd20f7988","src/shared/winerror.rs":"07890d7360fde1c5df53685024fc289476c22aff8ad23eeda3013e4866a7b951","src/shared/winusbio.rs":"871b050e4dec58e371542ab6c8277a5c6f57b9364bee08b1f3b7b0d9117b9cda","src/shared/wmistr.rs":"0a5431b57488503975d0c6c3aebbf2f56bffae2462b4c89e22220b100a52f70d","src/shared/wnnc.rs":"7e893b55d96fe43280cb39a6568773ff2c747cbfce13e201619d8ffaa3936cb1","src/shared/ws2def.rs":"62293f8c9211e01a9596b82dc186f9caf706f2d7ebd50a19b2bbdeaee965fb8a","src/shared/ws2ipdef.rs":"5c94ea40f541ae972c3c5fc665678bffa85bcc7b654250669779fbc2b90d2b48","src/shared/wtypes.rs":"d7788392196e15d52a5c8331e85272dde9f1c6857dc0a06b41ae5ac21502de60","src/shared/wtypesbase.rs":"d4d98d3777d6a581827fb8b96d5d57b531e80df49ec013ecf962a0aa8809b6f7","src/um/accctrl.rs":"679b937a10fa0017ef9fb7cd34996431f5fe0fa679d7abcfd6f4bbab80c8982b","src/um/aclapi.rs":"7867f7668606c0f258ccb238f49f560d42fd54da2a757d52fa42bb4c051aa730","src/um/appmgmt.rs":"613882eefac180d2d35d944d4164047febc773bf2ebe6a4008f11ed160b68c5c","src/um/audioclient.rs":"75ceab15c1aa67b7b1998064f42080d82a45d93003b98e700bc2733f3de959be","src/um/audiosessiontypes.rs":"ddf7a9bc055c3ebe2e15a7c338b881cceca6409f4798e164f655f619be7ba49a","src/um/avrt.rs":"b89918c5abd0397b6aa84f7fa6aa79561968a09ebc391bfe03aa706893a95980","src/um/bits.rs":"a191ee7f82ca76e46cac004e313221fa02d8f8e6c8e46d90636ba7252eb85a71","src/um/bits10_1.rs":"e0b31c2567c51d01d615b369749f694829124f17f1767b8a2281a15584c1e5d6","src/um/bits1_5.rs":"f6a93879e400d4a4c055454c3a06d764f7b8852955bfbf09d62d33bc2677bca8","src/um/bits2_0.rs":"528aa9c961c6c7162e7fffdd24e5db1c2e5f9af152d57e7376f630c723d6fc9e","src/um/bits2_5.rs":"7a9198eff2e158d1acb94d7f595ffa0e368c119b39d193e269222b5545b44409","src/um/bits3_0.rs":"5a15c736b866d9254cb7dddc687f5fa1a7f58afa58abd9112e2a6875f44a0b31","src/um/bits4_0.rs":"65b44b5f7f20e4d0717b7e8d9f2f3a5294366f5afe3afdb8757fceafa1a05aa7","src/um/bits5_0.rs":"f0c20fba6e3f5715e17f29df6d38e8fbb9ddaecdd628ac9c1de894abc413a74f","src/um/bitscfg.rs":"450b47c52b56b11be7162b8a011544d655aba324646809aa2e3c314257c07b1a","src/um/bitsmsg.rs":"a2f363a63c5b8e8321b07bc21801e1f30ab440651f653dc90bcb168d73ed62b9","src/um/bluetoothapis.rs":"8a54cd097c4497b1ce6d79824f0aaa2710e192c0df61bb50089b247120a75c10","src/um/bluetoothleapis.rs":"18f400319c73a827c161da5db18a8dbcf6d09242dbee43e199c72ab5026fdb4e","src/um/bthledef.rs":"6681986618978443c684e46105818c9a1ec1e901903a759bd50e72f8a3c7cb92","src/um/cfgmgr32.rs":"a792fca9294f5a66982394aa4d2891a46f99c062932eb91227b4b63ac23e7fcd","src/um/cguid.rs":"f4fdbb78adfde4741072cf234929275bd90e29be4d66d348c5d18bbdae592930","src/um/combaseapi.rs":"1d9fb12901320c2200384f67851f52557aa4e996acc35dd186440acea1d40fdf","src/um/coml2api.rs":"bed0e0a3845595c559e5d314cb2c46c0bce98366045c7d8e8e36f8020eaba106","src/um/commapi.rs":"cb63fa3cd67f36cbcc93f904ecffa72fd5fb13c1b56b84de9a0764b5c868acd2","src/um/commctrl.rs":"6019c3dbb9726bb0740c1c20cc108b7de2ad71f0621d850786e565403dd7549d","src/um/commdlg.rs":"c4b1a110f12d6151a3b064e8f3a4bf151f3f672545ef8fb11d74591f595e4827","src/um/commoncontrols.rs":"cd7f16faad2c6c12a2e7ffe71a7772b1376ee671f79e4f38d2fd92bb36e343db","src/um/consoleapi.rs":"4ec6603dff08256ad987fa3dca69d80d1e9253df77383cb4e3b228e8332959f1","src/um/corsym.rs":"8898dae9630572cd97221ab5a96790c53b9c0dd186a0c6d17c4541c671a48c4f","src/um/d2d1.rs":"16537910e193935f8c2ad95aa00761811e0ce798273ab944b7939fc06a299ef3","src/um/d2d1_1.rs":"072997a09f1eeee65fafe4f1b56184b9e384ff319afa1e3d7a1b39d5c31c252b","src/um/d2d1_2.rs":"5f8dbf676cf1c5967b92af1cc6ced54fe0dd66d2336ea89f9a3b7b371193fec6","src/um/d2d1_3.rs":"1c0571ca7fa43e028df63525ee50cc4edb9bfa60408c7c5c116aa827d65fdfac","src/um/d2d1effectauthor.rs":"6c3bc41c58079ef0eb1b3724c009cbc229bbdf3e87d0734fc1c38ed5c74d3d6a","src/um/d2d1effects.rs":"f175c39ca436e56f42e1040aadc283ded95d9020961a8f46cd70ff9bc134fdc4","src/um/d2d1effects_1.rs":"686ec154074f5d18f15cc2c1fd20cc374679a530efef9cc172fb7deb3f31cd1d","src/um/d2d1effects_2.rs":"88d71ac86e022eaf2a177553ecfdf62eeee7635d3ca701765939923a4527be69","src/um/d2d1svg.rs":"1c53c6471356d5aee85a386cbd10588de785bd3525e82d26c21bc47b9122ca19","src/um/d2dbasetypes.rs":"0e12de4e806b447dfd49bb8c26d5d7ef6eb37b04dab27949e2ca081b3cf7c6c4","src/um/d3d.rs":"7dd42d427b88371a9400ba94648872d8d7bb93b223c502de0ac1b2fd28226d7e","src/um/d3d10.rs":"3b078996204e310684bb287ac47bff1eb2bd9ff88c0660798943ddba7cd14bc4","src/um/d3d10_1.rs":"d03b2b0cd59ef6596291b4aede08722428f86493c2c849b0bcf8692f2560c4db","src/um/d3d10_1shader.rs":"a4e38cc140251776487dc74c2d66f75e5fea649663d057044e433f75063edf05","src/um/d3d10effect.rs":"e832315707a4b46b33f7c0e33dce3b6f17616c62ac5b50b45cbd24436280e3d3","src/um/d3d10misc.rs":"e7e6722dcc500b83ef6ce3b1a57872a224c9f8a6abd0c2b77b2f88ac9f66a2ec","src/um/d3d10sdklayers.rs":"3a9aa4930464a256700c00b46c9ee82480072e715ebfbd70a3c5fe25fe427850","src/um/d3d10shader.rs":"413d9d1fde20be1e260ead840425dfa19fad2afa6d71a07a3e7f629413052ab0","src/um/d3d11.rs":"5e7bc7a34a602c67c6819472d2986117000a81bce60e168874932d9ba8733f96","src/um/d3d11_1.rs":"e8a356a54a538dec4ad6716afe603dfe5e33a53950912dc82701fb6d029444f1","src/um/d3d11_2.rs":"a45ee94622c66f41919987c512ff39221236f8d0380161842b2a94a7b4ed44d4","src/um/d3d11_3.rs":"cce13ed510b82328ca99d15baeddd2e50743f24bd522cd7be36da47aa7c8f1d1","src/um/d3d11_4.rs":"c90bb2813303236339b405b05965964e5773efd505b20461cd008b12cff7b4ac","src/um/d3d11on12.rs":"07125e00377b771baefd110e0f0aafdd45dd859e04b2451d00b0a896a98c30bd","src/um/d3d11sdklayers.rs":"2287f35dd5a0758dfc4fde881db7482a12b6250082ff4515e84e73ecaa5cc8e2","src/um/d3d11shader.rs":"04d51f2e0ebccab2cc4581f9d4b3871d7fb93671c09f4f5ba683882e717410fd","src/um/d3d11tokenizedprogramformat.rs":"8e1f0c28ffc77cc5044792a2f7598f1d0961381e5e7ebc0227547fd98becf68e","src/um/d3d12.rs":"bd21d87e6d94cd85ff3d399016a66a0891c45fa5faa59bf952c29c450105cbc8","src/um/d3d12sdklayers.rs":"86ab09318bf76a09f74c6b2d9358d327d84d6d2d94f1b8f274385633138e480a","src/um/d3d12shader.rs":"8467f66d0f42d8690c92c236c376fde937bf349c6bb3307ade3b2682b0e7d89a","src/um/d3dcommon.rs":"0b06fab050a6df0f9b2e19bbf0278dbc7de6177dfa706e6548daf0283e26d0d7","src/um/d3dcompiler.rs":"d753cfcc79d25ddec5774ff3ac8204265a86d5a0411b77087525874d4bcf52a3","src/um/d3dcsx.rs":"090aef3c9249996b4a510b6a5a47761a4f2dd45f035b8828f153b7c09e72bd6b","src/um/d3dx10core.rs":"9f2972e822a060c0d48f6d21ea9438d98729799f4fff4db5b01c2ac89ee421ca","src/um/d3dx10math.rs":"5ce6ca6e6aaa7062ae44ce28aefcd2b63d4fef32816168875affd1c8f33664a2","src/um/d3dx10mesh.rs":"2db94de70109544e45357ae31a71ee6262baa9d8f58e806e1014b047d12e1316","src/um/datetimeapi.rs":"18bfa8543eca805077c58d7316c1acaa7de20cf212dc2ba1337a06fb0cb250dd","src/um/davclnt.rs":"c902c7042a4550795c938f3d241219ff8fae09c13bcd3595d2e2e90306922c31","src/um/dbghelp.rs":"1968bc9789aa01853d53a7e7e1ca5e4d07452f1007ab53247ebbc27e60ca376e","src/um/dbt.rs":"2b584edc0f8676ad5248d556169a7b7a305c3418775c93d99be3e643ad2121a3","src/um/dcommon.rs":"677e479b28423b9d7123430176255e97a16eb25f3bb3b402dc3c1faff6072c88","src/um/dcomp.rs":"b40233a4c47663ea8f556ae1049bd19c733e958f77a88fbc7d6cbd8e0e29138b","src/um/dcompanimation.rs":"9329be3851035cedcf4abe8c87db0742004d4e8c0cae281cbb11a6f3b9087ef1","src/um/dde.rs":"da038629b562c93c12b4d638be66cd82685aaf7156f2d27dc20daa74ef77886d","src/um/ddraw.rs":"a1e3da10e1e592bc65b7262a4c4556b7c3786d42422d123a8ef31c163cc67035","src/um/ddrawi.rs":"c18a8b17635a90fa513f2fba7b582e4756b3633b04908fc2a8e471a6c462e7fc","src/um/ddrawint.rs":"fbcf216bb1541d329f8e7a503965011c98cfffb86790d71cb78022560b0890cc","src/um/debugapi.rs":"a8ca228fcb6219c703f9b13b7931eb9f39662f523949a8e6addcb6cae0f9425e","src/um/devicetopology.rs":"c3f568fe855315f24e73738e7b4782befd9486f898aafcc12193d8b5d470e312","src/um/dinput.rs":"921b0281b24af2e4d9ba915313ed52203d4db5c89a0ef230b9ba36b494c220f4","src/um/dispex.rs":"7590032e356e878881cb75b4206ea09e13fbb1943891da8f31bb1513ba896d6e","src/um/dmksctl.rs":"0eb12a9812509d29c4294dbb6e75f9c0a0a4cd02a6a3979aec4cced465e891cd","src/um/dmusicc.rs":"d35c225338948b3a5fc7b183e31075597d600562cf2ea2b78f8950e923394f5f","src/um/docobj.rs":"c69b5ca5c250ef13cdc3aa0998111e49d3460b653633e96eac1202ab1e489976","src/um/documenttarget.rs":"8bfa4bf273def86bf1347d094a683be9ef39a588a9e27e968d49109988ca57e6","src/um/dpa_dsa.rs":"79d53e29ad2239b69e13f2a96d7546d0f3ea4611a1b1730a703a51afc0933dc0","src/um/dpapi.rs":"04508bd13782b6c64308acd53aefab1edcaee4ec89d7ccba0e30591f42d80493","src/um/dsgetdc.rs":"1d8cc7685b05023ba9698f169dd211aa0692afb608d570c6aa84de40e864c7ae","src/um/dsound.rs":"79e1e9efdc647eb998f0e9806c7b7281962f766a64532c270adc30a64037bb7d","src/um/dsrole.rs":"3fd27de63346253cab1a25900414a208a23656416c21141aaa6a2d33e7ee1ded","src/um/dvp.rs":"eb6297c5f943fd25a143c3285f0d9197b674df76f2342810d407772ba1223322","src/um/dwmapi.rs":"d0bcf2b922b8fc00d261577470e5068fd87fe534b27880402ec7a43de76f017d","src/um/dwrite.rs":"b9922cd2a72d643b44991325632a0b13a2f71e1971a601c2f23f17970a678129","src/um/dwrite_1.rs":"052df22764399d9ae66bb1348f3aad281785494afa2abab17c0a0fc15f7a2142","src/um/dwrite_2.rs":"d6a161504e838133591e0c75c0b0846c81de413b257383168153b81ebea5afdc","src/um/dwrite_3.rs":"b32293ccf2d1a8bfc1a4de5127e1355ca726f87216cff1502f2e748e01d09c62","src/um/dxdiag.rs":"0204000ad50bcbc3f9a1924aa382b40c3690f838eaa3cede2afb26bd853940be","src/um/dxfile.rs":"ea74680af320a259178219e420e6748d3c3751d1f9f8210cbfe46390ecb11fd8","src/um/dxgidebug.rs":"42b61771af0c558e8703646c97882f19638c12e02a97d1256379d6ba01e36b22","src/um/dxva2api.rs":"c05c03c249c8c91bf0fd6ca24a68c6fafd634b682c83b544f2c2b3c98b6dc89c","src/um/dxvahd.rs":"7510f79d0e72199ee5307f6880297bec7e5d47c908b9aaeac85cc4cc010511b3","src/um/enclaveapi.rs":"25c4f026ece797f73dc5fca45d965f220c62de94056c8e137b2cdf6e7db1e403","src/um/endpointvolume.rs":"ed3373501104fdb22e0fcd724e537ea36e79592579f5902f4ed4c67cfc071826","src/um/errhandlingapi.rs":"7ea8bee9bf4462335f25995b6e0215c06cd0149f2e55f5af46fbb40cbccc0e1e","src/um/evntcons.rs":"297bbdf96b7f9bdbcd6b7a8696e4b65fff7731b5fba52257387d03cdaeed25f9","src/um/exdisp.rs":"e479ef946e3e2b79dd6464ba474bac01721fd333cbe3d40bb34361d4c383373f","src/um/fibersapi.rs":"3d6e922f8abccdc2c505c30be99be39476915b97d6a428ec112ae9eab870e5ba","src/um/fileapi.rs":"8d7bb66047dd3d599097d1191d4d7ea6f27133c8a29c8420e0e36a817902c3e5","src/um/functiondiscoverykeys_devpkey.rs":"7c5cdd3c82a50942e6e7523d837d330f3891d1ed647f7af82bb27aa76b9765d7","src/um/gl/gl.rs":"39805ae68cd88b7e4bd81a8ce8d9805d3f9cb1b84616967796f76d188b3d8caf","src/um/gl/mod.rs":"b1b873c59fb0900c783949b5132738cf102357a19d2485a89b984f72d73c9288","src/um/handleapi.rs":"de90727411aef9ccc9c0f6a75c739dd682f66165ca85321bc8db6736e85253f7","src/um/heapapi.rs":"9d6bb1e3c05af574fd719ca3f8098c39dc637a2913a16a30e3a23ea4a822885f","src/um/highlevelmonitorconfigurationapi.rs":"b9ec30fd83407e0ba371e95c1cfcc91059607db6f67b5d2506f4f95871b2bcac","src/um/http.rs":"77e329ced9753253289b4faa70981590514aadd7ff408d7174102e1cbf84ed69","src/um/imm.rs":"1272b7f59ea87c4923cbf7aa5f35c1454db56f4d5a5cd97dbe6a3f407e50ff7d","src/um/interlockedapi.rs":"e6f8149b979099dc50816487d893f1943f1004cd9a6b1ee56eb564c7783c5cf6","src/um/ioapiset.rs":"871a1d24183a5e54ce29b86921cbe493d26a5c815f4c498c9068bb1eb92a67de","src/um/jobapi.rs":"4d5e4e86461b66be148fc2e4760fd01a9a54042a1c95ed5f3b89e000f4ceaef5","src/um/jobapi2.rs":"dadff8f24ab1d6847c0c234a8ff013906c3f7fa8523f2c5173d19bd13a7b1b55","src/um/knownfolders.rs":"5e5d204d5dcf3ec3098e6d3f1f1d660a63f43b691773cca946899b8b19bc196a","src/um/ktmw32.rs":"70ca3f285930c526fbaf5820e8b33d4132c6ecccaa4c4acf1dea506b6c8f5cb4","src/um/libloaderapi.rs":"cf640966ffe68af913b06acfeddedae01c47d334dbb51a5c1ff91f7ec94efb98","src/um/lmaccess.rs":"cf88ff16fbaacbfdaa896269f0fc97c0c1ac2a855b864eec96770418e74494e8","src/um/lmalert.rs":"78804ca021fa4c75bd0f6ceedc4f3ab7e8cf75cfec8a84e1bde7ecc639b823e5","src/um/lmapibuf.rs":"2530a2918f2b37cd0657802b40f890538ff2eccd94258b4b1154a666120ec652","src/um/lmat.rs":"0b1db5e4432a7eb77eff4655e814f510d7d30cd3189c44a52a938876ee863134","src/um/lmdfs.rs":"31c278a63e3f25d8bbf2e3d43c5ced5a64db18d20514a4bf5d4098a5fb0564fd","src/um/lmerrlog.rs":"ca8316152fdb7ce03ce6575b3784764f55a8c17461ac9e8f50f0770ac527d9db","src/um/lmjoin.rs":"c5e5ecf52d711a6d31b8256752b86652c26f2371994437b30f4a7ba2b56ba8c1","src/um/lmmsg.rs":"902f78f089287fa6bf31cefe7d523de9a963950add1a4847f474f537e30bcaed","src/um/lmremutl.rs":"901c1dc5bd48e4f554fbd28834c8e069ca6aa0758cf700277eaab0dddfd5979c","src/um/lmrepl.rs":"2aca07f6c3c0b9f7b25568a350073243d38e6d30ed6c358dcb63168709d424ff","src/um/lmserver.rs":"e06dc9db8cb4999074385ea7b31a6c9760ec4c607fe897278305e429d19a5df2","src/um/lmshare.rs":"788dc0d46a491ec312a343a835c9e16993ec31688c97a3eb8c6947a56a358a5f","src/um/lmstats.rs":"8f30ce095997e7fc91b3114814bacdc9bcd1555540aa803c77ec760711d2abb5","src/um/lmsvc.rs":"e21bbd4514df2a4034ad7000e7c7705994c762dbd55f1acd7ad018108476546e","src/um/lmuse.rs":"cd6b1bcbd7cc483c8e0a9a6530a15d7bf1dc15125a2b6867fae21c805f4c4481","src/um/lmwksta.rs":"48f7a141d071feff3e89a0951134fc3c3693bf8419db144b1ecf79277b759901","src/um/lowlevelmonitorconfigurationapi.rs":"443b99e0ce868417230fa137a7a0ac419e4ac916e70f4cd493e8644c4fbb1604","src/um/lsalookup.rs":"e590e29feef6ed1c650fa37d2838139cb3f24b17dfa353b9ed05b375ecbf5740","src/um/memoryapi.rs":"3c98dc6862515a2fa1d5fe1fe07029df757a0812503f1ad185c909104b6b086b","src/um/minschannel.rs":"f61ee574a448f587283c05476bfc64cd427f19fb8d24c34b5fe4dbdc87db3a3d","src/um/minwinbase.rs":"8f0b8c595b472cda996d76bc1738471f5bc0bdb7ddd55f76b7ca7f75d143f27b","src/um/mmdeviceapi.rs":"95119649cdf7aecfca2efd4f2d5062c59c0a1b13419dff61469aed26394aa5ff","src/um/mmeapi.rs":"88a4119036d9386c96af4018c11ef95f247ea0eaeb54f6626b2dbd7ea5862b1a","src/um/mmsystem.rs":"ffefe67a61f7f89bfe7331eb85abc8bdb4b72f95ffe7a26b25db7f5b746c5aad","src/um/mod.rs":"9b6806d09126da4b071ad216898d526e1ce60e1fc957b73fc30bb2c8e49971ba","src/um/msaatext.rs":"b2cfbe373634bad9a5dd365279d8c5c3a541c99ae0379ed140d4551a3e8b3d10","src/um/mscat.rs":"ddeef0621b10396c91d9aa340fa4480d0ed70e0e2579f95ae18f805c54309498","src/um/mschapp.rs":"4a18fade84eb823c950aa175ec082217bf08c6f4b5a64af996b7fcdaf12cce5b","src/um/mssip.rs":"6e2d7a112939a3cd00ff07009a3966c926136ffbdf888a0dc61ecf5a32d438d4","src/um/mswsock.rs":"9d6c5d32a974415a71a279deaa41674377aa639d01db044359c5e9226488002f","src/um/namedpipeapi.rs":"37d84469cb27291b5e2649273fc51fa34609fa988823034efcd42751aef80748","src/um/namespaceapi.rs":"8b68775a6f52d33b19f450b5dc47a0d9d7e0b50f2623b78dc21b74721913dfd7","src/um/nb30.rs":"ef375c5ef62de9846f884cc572c124dfa478dac3e3a582fa6b6ff8e9fedce92e","src/um/ncrypt.rs":"87bf4e6422462efa5b201fef64e6938b900ceacac699c724c8b22581dc419243","src/um/ntlsa.rs":"62af59c8f68dc511ccccc2f4e071dd3fdf3bc5c8a5e79f7c251f7815bd95d712","src/um/ntsecapi.rs":"e9626865a9dbfb45503f6c211f2af4763476ece0951a31065081ee610eef275f","src/um/oaidl.rs":"534c297edf34085ca85af813029c31bddd281e178f28789903d7cf206b2a6154","src/um/objbase.rs":"05c2cec2b50a1381569fa5fed7a7224e3c996ba6d6de281a94c698541f53ef9d","src/um/objidl.rs":"b4975ca093d1e9c60293bc425741b6128abe39a5ecbde0d7e54a7c6bd38f6dde","src/um/objidlbase.rs":"0868d95ab7554e0e99445f32e4ba19ef41703aae7d1f88b5ccfb65fc69cd246e","src/um/ocidl.rs":"bff12022b3564a323932e9807c225409fa701bda37b1037a94ecb99aa4c38dd0","src/um/ole2.rs":"1ae2519d7b3bec95faa463e78bcc696c3648582e1586c0874781500479385200","src/um/oleauto.rs":"8753b9021e80b229d9445fa059484b55c63392ce63a0673a12eda00934eda666","src/um/olectl.rs":"1deff809b5e01f256828425847d2222024f99e95de47bdb8900ccd9771f5000a","src/um/oleidl.rs":"4f3697c1d0d46b637032c5c510eca203b35eadfc484d2f2d96ac918406214ac2","src/um/opmapi.rs":"2bd12e1ac2d8070962ddca7b3bb1871b7ae40171e3f8ff1edee0559c9dec8ce5","src/um/pdh.rs":"165cf4703fa7215f025dad77da06beaa0f9a00df5bef246bc381ac24e8f06d89","src/um/perflib.rs":"c3a672382f25960aac899cafaec54f99a963230aea48b3bc7a025333b67b1428","src/um/physicalmonitorenumerationapi.rs":"cbb8d7ec3ef5492004fe032d3140f6043b9f86f12e68fb5815b9b08e9ff07191","src/um/playsoundapi.rs":"ef3dd57bb0aaf43020f1c9a9e5919a48d09b0a02b3fcf471847ea7f83623ad0e","src/um/portabledevice.rs":"deea01e14db3588de59863b7906491db91e9d23d35563c95a45fc1ad8f005f35","src/um/portabledeviceapi.rs":"941d33a939e45d3d72cbac2a7815ec68b30b9cb15258e406cfe2c7154abd86d4","src/um/portabledevicetypes.rs":"3c617d453009f216a13670cb122987b6f7b1cea8d745e12ec1dfb12a567a37de","src/um/powerbase.rs":"dc146d82e3475cfa589494d56ab37b79a9045df41f7ac04d1cf6179b7905630a","src/um/powersetting.rs":"995763ac42347af74958ba3b8d6988dc7a232c12e376df089a035de872754bcb","src/um/powrprof.rs":"913f90486eb7bbfece23cc31ab7dea639a9b5bd26125c43ed556d20a49d36588","src/um/processenv.rs":"08c210447fe68eb7a2d109f6cb972d180b4d4c5a5ff9afc0effa2be4d4afb17a","src/um/processsnapshot.rs":"64ab19f429bfabc4e34c311e77e71b1130a908f87905ed5444128aa28afd94d1","src/um/processthreadsapi.rs":"fe6ed629796cecbec847a3acb49a3a61499df951fce53f73f64b2069ef622848","src/um/processtopologyapi.rs":"6585d8016bcce106c61a93ffef27d292d194390014f572f39e11108c9237fc7c","src/um/profileapi.rs":"acd4bade4ea7700a87dc7cb1de1f2d507222a1f180d630bb7d3f833b9fb9e66b","src/um/propidl.rs":"5fc5bd30aae34b2c4ccb895e6f4cd18ad1f76fada5c43ff2bf7b1bfbc95bed3b","src/um/propkey.rs":"f643f0c82914623bf4f8dac89444923e4ce9d1e817839f504d26d1f2678b5bc5","src/um/propkeydef.rs":"4ad252db7f7e2ef6036fc1038626e4d2aee87df969c291b8b56cf52e2c263c73","src/um/propsys.rs":"ce3a51c6a459c862d34b4230a8574b72885bff5d691b4fe0ad233ca74e155f19","src/um/prsht.rs":"8ec88e21b0b631cfacdbec2a372f149bf08e161f7ac497b492a68dee65b8a5de","src/um/psapi.rs":"b809d780525a29e7a637a5a780defee09ee4804c1231e3adcb63a69bfe5c3bc9","src/um/realtimeapiset.rs":"9d81b0be632bc47792b64200f53265f10566d23e1c1c553b7dffea735df0cf4a","src/um/reason.rs":"549d332c627a67e685feacf78422ff1a0344c5702fb80b3c59aeebf445e3219a","src/um/restartmanager.rs":"3927a5474e00ac780136f13d34299098a55cf62824660aed0afdf7cd8f595d6f","src/um/restrictederrorinfo.rs":"92b894ebcdd96bbf103e5fd7bc1788dc6a0c3122b92c792ff82f9805d96d8f0f","src/um/rmxfguid.rs":"daa2c44163ff6f561d449e4d80e9da0720367d254d699d0d1e70b8f8dc4753b6","src/um/sapi.rs":"b1bcf84ddf76b2276a4f297f9cebf02da17b9f4a218a861da1cf4e941ccea6d8","src/um/sapi51.rs":"9312df143531e651017bbfb15e5214ed562522a779f52b71c83eea3628f321dd","src/um/sapi53.rs":"52e5dfe376218af9ef61475e007a420a855e32e4ee50bc3a2448cc746ffdc5ae","src/um/sapiddk.rs":"9a02d38c3d7d8de18e50e4625a58870a3f60ab6d30af05f32d2f72aafb1227fa","src/um/sapiddk51.rs":"7b4f2fca16380588265e1040b86252a797bd52a0f57672b7a558370659ba827f","src/um/schannel.rs":"877a45c94d58aa2c1cb391082efdfcc637798f1608d9c7b7fad3df6ed21e85a6","src/um/securityappcontainer.rs":"da4f8a62469551df54895954f1b5a3213ce3b30c696d213099a9d84bc4c6cc28","src/um/securitybaseapi.rs":"3bef5511f753cd421046d218e72fc11f2d030e45dab41ac0ceeb12dce247b6c4","src/um/servprov.rs":"078e0fb30bbe7f98bf1f7a149a54d47fd94a343eb0c9c8e4b7db01b1acee8a94","src/um/setupapi.rs":"041d74c2f2b89ea490684c3578e6624552c3f0fce46641b9b515cef57aae7d75","src/um/shellapi.rs":"7821b1d66b1e5f1d0c14c289f201108f32e4784d9eed6a2d20e7a9207670e3a7","src/um/shellscalingapi.rs":"f71f7e28f50788072dafc774e1d596c1f3be5e141770647c3662e0a9e3382f5b","src/um/shlobj.rs":"2401dd1b5115aa3aa77071b2b3f865693a6c4a329782c56f2409eb2f811e3e38","src/um/shobjidl.rs":"1f4f0f8a1f8a8739c481f8d2bcee3c7b032c8309f6fe9a673fd993737187890d","src/um/shobjidl_core.rs":"6112b8907680e12753914d1799b8a9e0137d16e9029fef808d00c62b738ae1c2","src/um/shtypes.rs":"56ecaf1a140ced304f72ffad40cc039c9441cf23a6769c316cf1b208ab969911","src/um/spapidef.rs":"33c5640efed3a3a2fff39a8ce6f6b7116d782bb5c6e14dfdd28fa99d34e2a163","src/um/spellcheck.rs":"e503bc995ff697992c75dfac32821fe6e8e05fee3183a3f3114e854430b0642c","src/um/sporder.rs":"231daffd462139a12f82154a7d86269fba81769c9fac1ce6004d249fa004e83f","src/um/sql.rs":"796be1297cbddd6dedc4f50fb6c23be7aeb62d4e99a2bafd9c1ef4491c542899","src/um/sqlext.rs":"53a0a990ed2a07c3cd3ecdb9151c1a1324cdfcb073fce137844c13e1ffdd683e","src/um/sqltypes.rs":"d612b65d1a1e693e7aa524fa1017e46faccfbd9cf8b054f40d18edaeb2360237","src/um/sqlucode.rs":"98f702ff84f471b54d0085d8e8cdf48b240dcd357166d19f4bad36886f592816","src/um/sspi.rs":"ebdada76c11c250e5a86c01ce4d4645180f81ef0b0f798511b2db18039d0251e","src/um/stringapiset.rs":"d2189a2af906f0fd38ac646eabb77558205e45c04f366c5bffc840b74cfe0aa1","src/um/strmif.rs":"feaddd73ce6cf17f8f0d7f48ebc2e5e2c25b6e9407e812bc31d048c66918c1d1","src/um/subauth.rs":"35200a700b6530cd4740b1e06021e8feece191dc25fd511bbba595a76541f39d","src/um/synchapi.rs":"6fc3c10bc643dfbaefb404614ca1b56aff506651c0a5f74db48fa682e919f510","src/um/sysinfoapi.rs":"0d46b6ec5932d7660993d6d8aab3a35b5548a34e2c072bdaf69e11a7cc1250cf","src/um/systemtopologyapi.rs":"324eadb5b5c63f8d39b7f1609e95ba9141cca74d775f8e7d4da9e0c3a6793340","src/um/taskschd.rs":"4d6bd2126245da589d120391419f7b2e21ef2cb1003c8119cf7d697883c53e00","src/um/textstor.rs":"df98ffff6afd789ed1d745547ffb8f0b9602ffa756c6afaa1b582249eee37e40","src/um/threadpoolapiset.rs":"8592e647532c79a730e01a6d7c9fbc95ef03b27c05add10b657d2df2c9f8f485","src/um/threadpoollegacyapiset.rs":"e1984f442cca48c1b706778f458a1631fa783883a6999ecf66aea2845b578f19","src/um/timeapi.rs":"71dafc528d31466af0ec57e1be6697410e859f377d791b20f059c874ebb2b974","src/um/timezoneapi.rs":"67e11f24f28651e9739cd203ae8801d283740d6ae8243e76f2af85b041475551","src/um/tlhelp32.rs":"e19aabb5212c6f357a102bda20f9aaaa91b19081bdf55f8c5dcd27500806b9a6","src/um/unknwnbase.rs":"56f8a56b7adbb7510bb990e92c626af46df884a356d5f8f2be776c2245d00f19","src/um/urlhist.rs":"ea0619e685ed7ea8f7f602ba142789f2bada3e397352a998999a8399b5b2120e","src/um/urlmon.rs":"8b2bf7cf12742cc8679f381961ab98551e0fa87abd96c8381b47f5feebaf3132","src/um/userenv.rs":"87624ffe6dead461a24302281eeba755d5af8f6a854211e9749d9ecb3e2f0094","src/um/usp10.rs":"cfba2b23a1e140592d4fa6f8c4a0b243cde12c5000a130d91e9a712f85a94d27","src/um/utilapiset.rs":"860578b704b208e3b7714834ada6e02f6cc0505fdac0ae6214ce6cdc01c0d3c8","src/um/uxtheme.rs":"30d4231c974cd1147ae650b0f5a34d0cb2df3ec64c1b9794c85ce83b9a54ef11","src/um/vsbackup.rs":"a6688644b9034a1d830b672fb3c0f7d38158ecd63af53392870629906c9a8c7e","src/um/vss.rs":"d1731203e029d0a5c23a427f2dabc8f789f512ef1f1bdd15ebd7c7322c7cea4f","src/um/vsserror.rs":"f35c941c9cb034667e6c344bb0ebd2935baf9ecbf32ef7d5988f19d8f3df089a","src/um/vswriter.rs":"9e48f7ecbeadf0db7bae2476f577a4895bcf04843dd4ac4fbdb7db6bd03926a4","src/um/wbemads.rs":"9d2ae66e77f4c0bc50ccb1cccd269ca515d799e298d437ce06085d7b81dd443d","src/um/wbemcli.rs":"9af6eba597f1ed8081d2f5ea3ccadcb17b40d63c8134d6fe40b3eda06b5a3c8f","src/um/wbemdisp.rs":"f6d45ad8a9ec8d9a5c86c74d3163e7fb2d180a09ea96782a6c6a69797128c61a","src/um/wbemprov.rs":"13e29281c2d6a930068754cefdf699ba9d59826b8b3d39c0726fa2e9d680a3a3","src/um/wbemtran.rs":"e5abd15d360926810b06f9b2486223ad7416fbf0884f3a701faab29dbd250023","src/um/wct.rs":"0db574400292a398f026385517d7c5c17e9a2a5dae75898438cdd98ea8ef50a2","src/um/werapi.rs":"27be0a45fdc78a49f2103646fa358425a2b409c30a773e83b91cd0571bd2fa5d","src/um/winbase.rs":"f96f3212dd0fa8d370ea552316730427a0b831e6ca5de030da56998b8372495c","src/um/wincodec.rs":"e6154a593974593ca992a9ee3752617f1abd6a6270bc21b1d5b1b2bd92c35c1a","src/um/wincodecsdk.rs":"f62c504e1f49e385eace2e92f7a11435615c3b95d2eb03adf03dd9b4816952fe","src/um/wincon.rs":"26709392100dcb843e239c72f0740cafa7504e68fd0f9a77441d0153742dc3ee","src/um/wincontypes.rs":"1d0977849850bc937a9a7dfc853ee732bbb7c0aa54c14c74de9635afb8db304d","src/um/wincred.rs":"e28c7f7cf7c2b317823e76bac4bb7b640007be339a93925abb8bc77a0983341e","src/um/wincrypt.rs":"47e1c68038a38dff8e89fdfc22e895327dc26cacf7bd1c75004a2fb08f095e3b","src/um/windowsceip.rs":"754fc7ccea015c4c00e1bcf19b92d16801f50ce37c1fc889fbc7494f8634c9d3","src/um/winefs.rs":"4684a567089f70db9372cd4bbe8875e04d6668d537b1e1ef1a70b3f47d1ea0f1","src/um/winevt.rs":"d11dd7357b0d6d55e2fb6b0ad692eab9d5668a35ac9a19e5d5887aa9d7373c33","src/um/wingdi.rs":"14f1eb7584db72ce4a2fcc53f9b3cb5a54e0e74b95333b96cc16106376c90adc","src/um/winhttp.rs":"a28b7d5b45e215faeca04f7fc25ffc0369e1cbcde12b61980276307e1c67a245","src/um/wininet.rs":"501cd35f233de092c45fef2c0003fd864670122dd7b63702d7fe6c1d7b3dc7f9","src/um/winineti.rs":"b6288aa923100568c09e4350ac9340dcf582629f52e91eb6b195ffbca1619549","src/um/winioctl.rs":"744fc84e30f198995db261d1de09d4a13e2937be5325d7888c840aa0d60ad7be","src/um/winnetwk.rs":"b0153509998e107790099ce1a160e38bd095b2b6bac9ddf7d1b2490db609f3b6","src/um/winnls.rs":"d55d3470239da9551b61a58abd47e71ab7cd55a13223baffba33fde6a44c677b","src/um/winnt.rs":"70812b62d4bb151c2ed5a307ff71b678bffe2a32c5a1969e4986a0fb1d8be697","src/um/winreg.rs":"64e327128f0e62e8f45a55e39b915d3bcc7645c0222632f6226ff505e4bd7e20","src/um/winsafer.rs":"4680859e90029ad4447ac226f667f3290d99c7a0bff8e17c595f2bdca2d63fd3","src/um/winscard.rs":"3e55793eb45ac8770adb94227b0a9431fb3545bbe1b46e40234ad51d9432152c","src/um/winsmcrd.rs":"622c977577ec7a1820b94bba1d1b34686a406c7516d03683c6e89177a5d580a6","src/um/winsock2.rs":"00494aec15b71ed6a58377caf45d33cda7feacdc15cf7cfbc0503a20be48303d","src/um/winspool.rs":"69f443b90a6dff35b09e701f7190b67aded9389ccab44960239a15d50cfd7012","src/um/winsvc.rs":"204ec6b8270c0f7c3d409638cc76acd97929d65678d4a8101e17f786acfa0689","src/um/winusb.rs":"8c7ac644694d02166f531e1b2d1f6363347703a8f3a75fc30df4e30f8886c8a8","src/um/winuser.rs":"efdd25cfc7245bafcb6d44bdf46eb32b4f2ea922ddc0ab681b91884cfa9c89c6","src/um/winver.rs":"aa2b3097709177507db69887e905cca198371edf4338c6a4264442bf09b85c13","src/um/wow64apiset.rs":"91c7ea2cc1cf67ebac303e8b8ca288f97f7dce331b35a9e05d24598a18f760f4","src/um/wpdmtpextensions.rs":"443482e1c3e56846a770beaab9da0e2cd0d316671d9c09a29551938cee426058","src/um/ws2bth.rs":"dcdbbce04e0afb2a2206d912b9b6012bb83145adbd7b21fea5e6d585f20d7e4b","src/um/ws2spi.rs":"09ace81f4cabba4a6b823cf7956d2b64dc05556b498525758969ee76d6c2b328","src/um/ws2tcpip.rs":"11ef57db8079c80808d66c690a9939445bd7b426a3eabcbfb024056110cebe94","src/um/xinput.rs":"69f27b977eceeaa310aed92fa96183e4d831ed00007839ec3366022fe928f229","src/vc/excpt.rs":"2185de9facc033bb12513f0c2c851bae67d7999d92eef93a7b548450f8327f30","src/vc/limits.rs":"d185e499e763ca8d44a25bc0436d89bbd0449ce2d8d462ab769b771ab6037b9b","src/vc/mod.rs":"83e90f960b0bb188ccb564014c0331c205faca0ab1631b1f97424c9f301ac133","src/vc/vadefs.rs":"922df6214f27177b5a260196a3ef8423afcf2c4684948f527b24bae35a6371e8","src/vc/vcruntime.rs":"f56e53bca9d825c72a8f184ff1094931eca11a28ae504be7030e0cea29e5ac3f","src/winrt/activation.rs":"8815db03763114f8f70473e851aa32f998c9d6640edf2b46449035f4d0a21099","src/winrt/hstring.rs":"80373e386d521e69703fdd21e809633f6a7cbbab569dfa4fb186d85b451bb817","src/winrt/inspectable.rs":"6ead05e5c87d59c7c01636a1fcfda188747c35f95d9bf0d557c2d10f3332bf2e","src/winrt/mod.rs":"98cbd2088dd2f7c25a1d9b608fe49b5fc90bafcec94eb80fd8da4b3437ea47c8","src/winrt/roapi.rs":"7590576112f23d17650ad716785a801eab0ebc2db7b65829f57c0fe704ab583b","src/winrt/robuffer.rs":"5000d5cb33ebf77f801ab68f55ad14f36fb55663f0d4a203b26669445040cff3","src/winrt/roerrorapi.rs":"716b0ef60d9d9d0538f894e9c7d5413b398de33280f3308186873b993024c0b0","src/winrt/winstring.rs":"d7318e090000ca3bc644a6310d36a27179e3cc5624a1e35c20ec0dc332057b53"},"package":"8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"} \ No newline at end of file diff --git a/third_party/cargo/vendor/winapi-0.3.8/BUILD b/third_party/cargo/vendor/winapi-0.3.8/BUILD new file mode 100644 index 0000000..feef361 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/BUILD @@ -0,0 +1,75 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "winapi", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.3.8", + crate_features = [ + "basetsd", + "combaseapi", + "consoleapi", + "dwmapi", + "errhandlingapi", + "fileapi", + "handleapi", + "hidusage", + "libloaderapi", + "memoryapi", + "minwinbase", + "minwindef", + "ntsecapi", + "ntstatus", + "objbase", + "ole2", + "processenv", + "processthreadsapi", + "profileapi", + "shellapi", + "shellscalingapi", + "shobjidl_core", + "std", + "sysinfoapi", + "unknwnbase", + "winbase", + "wincon", + "windowsx", + "winerror", + "wingdi", + "winnt", + "winuser", + ], +) + diff --git a/third_party/cargo/vendor/winapi-0.3.8/Cargo.toml b/third_party/cargo/vendor/winapi-0.3.8/Cargo.toml new file mode 100644 index 0000000..040d361 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/Cargo.toml @@ -0,0 +1,411 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "winapi" +version = "0.3.8" +authors = ["Peter Atashian <retep998@gmail.com>"] +build = "build.rs" +include = ["/src/**/*", "/Cargo.toml", "/LICENSE-MIT", "/LICENSE-APACHE", "/build.rs", "/README.md"] +description = "Raw FFI bindings for all of Windows API." +documentation = "https://docs.rs/winapi/*/x86_64-pc-windows-msvc/winapi/" +readme = "README.md" +keywords = ["windows", "ffi", "win32", "com", "directx"] +categories = ["external-ffi-bindings", "no-std", "os::windows-apis"] +license = "MIT/Apache-2.0" +repository = "https://github.com/retep998/winapi-rs" +[package.metadata.docs.rs] +default-target = "x86_64-pc-windows-msvc" +features = ["everything", "impl-debug", "impl-default"] + +[features] +accctrl = [] +aclapi = [] +activation = [] +appmgmt = [] +audioclient = [] +audiosessiontypes = [] +avrt = [] +basetsd = [] +bcrypt = [] +bits = [] +bits10_1 = [] +bits1_5 = [] +bits2_0 = [] +bits2_5 = [] +bits3_0 = [] +bits4_0 = [] +bits5_0 = [] +bitscfg = [] +bitsmsg = [] +bluetoothapis = [] +bluetoothleapis = [] +bthdef = [] +bthioctl = [] +bthledef = [] +bthsdpdef = [] +bugcodes = [] +cderr = [] +cfg = [] +cfgmgr32 = [] +cguid = [] +combaseapi = [] +coml2api = [] +commapi = [] +commctrl = [] +commdlg = [] +commoncontrols = [] +consoleapi = [] +corsym = [] +d2d1 = [] +d2d1_1 = [] +d2d1_2 = [] +d2d1_3 = [] +d2d1effectauthor = [] +d2d1effects = [] +d2d1effects_1 = [] +d2d1effects_2 = [] +d2d1svg = [] +d2dbasetypes = [] +d3d = [] +d3d10 = [] +d3d10_1 = [] +d3d10_1shader = [] +d3d10effect = [] +d3d10misc = [] +d3d10sdklayers = [] +d3d10shader = [] +d3d11 = [] +d3d11_1 = [] +d3d11_2 = [] +d3d11_3 = [] +d3d11_4 = [] +d3d11on12 = [] +d3d11sdklayers = [] +d3d11shader = [] +d3d11tokenizedprogramformat = [] +d3d12 = [] +d3d12sdklayers = [] +d3d12shader = [] +d3d9 = [] +d3d9caps = [] +d3d9types = [] +d3dcommon = [] +d3dcompiler = [] +d3dcsx = [] +d3dkmdt = [] +d3dkmthk = [] +d3dukmdt = [] +d3dx10core = [] +d3dx10math = [] +d3dx10mesh = [] +datetimeapi = [] +davclnt = [] +dbghelp = [] +dbt = [] +dcommon = [] +dcomp = [] +dcompanimation = [] +dcomptypes = [] +dde = [] +ddraw = [] +ddrawi = [] +ddrawint = [] +debug = ["impl-debug"] +debugapi = [] +devguid = [] +devicetopology = [] +devpkey = [] +devpropdef = [] +dinput = [] +dinputd = [] +dispex = [] +dmksctl = [] +dmusicc = [] +docobj = [] +documenttarget = [] +dpa_dsa = [] +dpapi = [] +dsgetdc = [] +dsound = [] +dsrole = [] +dvp = [] +dwmapi = [] +dwrite = [] +dwrite_1 = [] +dwrite_2 = [] +dwrite_3 = [] +dxdiag = [] +dxfile = [] +dxgi = [] +dxgi1_2 = [] +dxgi1_3 = [] +dxgi1_4 = [] +dxgi1_5 = [] +dxgi1_6 = [] +dxgidebug = [] +dxgiformat = [] +dxgitype = [] +dxva2api = [] +dxvahd = [] +enclaveapi = [] +endpointvolume = [] +errhandlingapi = [] +everything = [] +evntcons = [] +evntprov = [] +evntrace = [] +excpt = [] +exdisp = [] +fibersapi = [] +fileapi = [] +functiondiscoverykeys_devpkey = [] +gl-gl = [] +guiddef = [] +handleapi = [] +heapapi = [] +hidclass = [] +hidpi = [] +hidsdi = [] +hidusage = [] +highlevelmonitorconfigurationapi = [] +hstring = [] +http = [] +ifdef = [] +imm = [] +impl-debug = [] +impl-default = [] +in6addr = [] +inaddr = [] +inspectable = [] +interlockedapi = [] +intsafe = [] +ioapiset = [] +jobapi = [] +jobapi2 = [] +knownfolders = [] +ks = [] +ksmedia = [] +ktmtypes = [] +ktmw32 = [] +libloaderapi = [] +limits = [] +lmaccess = [] +lmalert = [] +lmapibuf = [] +lmat = [] +lmcons = [] +lmdfs = [] +lmerrlog = [] +lmjoin = [] +lmmsg = [] +lmremutl = [] +lmrepl = [] +lmserver = [] +lmshare = [] +lmstats = [] +lmsvc = [] +lmuse = [] +lmwksta = [] +lowlevelmonitorconfigurationapi = [] +lsalookup = [] +memoryapi = [] +minschannel = [] +minwinbase = [] +minwindef = [] +mmdeviceapi = [] +mmeapi = [] +mmreg = [] +mmsystem = [] +msaatext = [] +mscat = [] +mschapp = [] +mssip = [] +mstcpip = [] +mswsock = [] +mswsockdef = [] +namedpipeapi = [] +namespaceapi = [] +nb30 = [] +ncrypt = [] +netioapi = [] +ntddscsi = [] +ntddser = [] +ntdef = [] +ntlsa = [] +ntsecapi = [] +ntstatus = [] +oaidl = [] +objbase = [] +objidl = [] +objidlbase = [] +ocidl = [] +ole2 = [] +oleauto = [] +olectl = [] +oleidl = [] +opmapi = [] +pdh = [] +perflib = [] +physicalmonitorenumerationapi = [] +playsoundapi = [] +portabledevice = [] +portabledeviceapi = [] +portabledevicetypes = [] +powerbase = [] +powersetting = [] +powrprof = [] +processenv = [] +processsnapshot = [] +processthreadsapi = [] +processtopologyapi = [] +profileapi = [] +propidl = [] +propkey = [] +propkeydef = [] +propsys = [] +prsht = [] +psapi = [] +qos = [] +realtimeapiset = [] +reason = [] +restartmanager = [] +restrictederrorinfo = [] +rmxfguid = [] +roapi = [] +robuffer = [] +roerrorapi = [] +rpc = [] +rpcdce = [] +rpcndr = [] +sapi = [] +sapi51 = [] +sapi53 = [] +sapiddk = [] +sapiddk51 = [] +schannel = [] +sddl = [] +securityappcontainer = [] +securitybaseapi = [] +servprov = [] +setupapi = [] +shellapi = [] +shellscalingapi = [] +shlobj = [] +shobjidl = [] +shobjidl_core = [] +shtypes = [] +spapidef = [] +spellcheck = [] +sporder = [] +sql = [] +sqlext = [] +sqltypes = [] +sqlucode = [] +sspi = [] +std = [] +stralign = [] +stringapiset = [] +strmif = [] +subauth = [] +synchapi = [] +sysinfoapi = [] +systemtopologyapi = [] +taskschd = [] +textstor = [] +threadpoolapiset = [] +threadpoollegacyapiset = [] +timeapi = [] +timezoneapi = [] +tlhelp32 = [] +transportsettingcommon = [] +tvout = [] +unknwnbase = [] +urlhist = [] +urlmon = [] +usb = [] +usbiodef = [] +usbspec = [] +userenv = [] +usp10 = [] +utilapiset = [] +uxtheme = [] +vadefs = [] +vcruntime = [] +vsbackup = [] +vss = [] +vsserror = [] +vswriter = [] +wbemads = [] +wbemcli = [] +wbemdisp = [] +wbemprov = [] +wbemtran = [] +wct = [] +werapi = [] +winbase = [] +wincodec = [] +wincodecsdk = [] +wincon = [] +wincontypes = [] +wincred = [] +wincrypt = [] +windef = [] +windowsceip = [] +windowsx = [] +winefs = [] +winerror = [] +winevt = [] +wingdi = [] +winhttp = [] +wininet = [] +winineti = [] +winioctl = [] +winnetwk = [] +winnls = [] +winnt = [] +winreg = [] +winsafer = [] +winscard = [] +winsmcrd = [] +winsock2 = [] +winspool = [] +winstring = [] +winsvc = [] +winusb = [] +winusbio = [] +winuser = [] +winver = [] +wmistr = [] +wnnc = [] +wow64apiset = [] +wpdmtpextensions = [] +ws2bth = [] +ws2def = [] +ws2ipdef = [] +ws2spi = [] +ws2tcpip = [] +wtypes = [] +wtypesbase = [] +xinput = [] +[target.i686-pc-windows-gnu.dependencies.winapi-i686-pc-windows-gnu] +version = "0.4" +[target.x86_64-pc-windows-gnu.dependencies.winapi-x86_64-pc-windows-gnu] +version = "0.4" +[badges.appveyor] +branch = "0.3" +repository = "retep998/winapi-rs" +service = "github" + +[badges.travis-ci] +branch = "0.3" +repository = "retep998/winapi-rs" diff --git a/third_party/cargo/vendor/winapi-0.3.8/LICENSE-APACHE b/third_party/cargo/vendor/winapi-0.3.8/LICENSE-APACHE new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/third_party/cargo/vendor/winapi-0.3.8/LICENSE-MIT b/third_party/cargo/vendor/winapi-0.3.8/LICENSE-MIT new file mode 100644 index 0000000..6f1b4c8 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) 2015-2018 The winapi-rs Developers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/winapi-0.3.8/README.md b/third_party/cargo/vendor/winapi-0.3.8/README.md new file mode 100644 index 0000000..0d8d39c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/README.md @@ -0,0 +1,89 @@ +# winapi-rs +[![Build status](https://ci.appveyor.com/api/projects/status/i47oonf5e7qm5utq/branch/0.3?svg=true)](https://ci.appveyor.com/project/retep998/winapi-rs/branch/0.3) +[![Build Status](https://travis-ci.org/retep998/winapi-rs.svg?branch=0.3)](https://travis-ci.org/retep998/winapi-rs) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/retep998/winapi-rs) +[![Crates.io](https://img.shields.io/crates/v/winapi.svg)](https://crates.io/crates/winapi) +![Lines of Code](https://tokei.rs/b1/github/retep998/winapi-rs) +![100% unsafe](https://img.shields.io/badge/unsafe-100%25-blue.svg) +[![Open issues](https://img.shields.io/github/issues-raw/retep998/winapi-rs.svg)](https://github.com/retep998/winapi-rs/issues) +[![License](https://img.shields.io/crates/l/winapi.svg)](https://github.com/retep998/winapi-rs) + + +[Documentation](https://docs.rs/winapi/*/x86_64-pc-windows-msvc/winapi/) + +Official IRC channel: #winapi on [Mozilla IRC](https://wiki.mozilla.org/IRC) + +This crate provides raw FFI bindings to all of Windows API. They are gathered by hand using the Windows 10 SDK from Microsoft. I aim to replace all existing Windows FFI in other crates with this crate through the "[Embrace, extend, and extinguish](http://en.wikipedia.org/wiki/Embrace,_extend_and_extinguish)" technique. + +If this crate is missing something you need, feel free to create an issue, open a pull request, or contact me via [other means](http://www.rustaceans.org/retep998). + +This crate depends on Rust 1.6 or newer on Windows. On other platforms this crate is a no-op and should compile with Rust 1.2 or newer. + +## Frequently asked questions ## + +### How do I create an instance of a union? + +Use `std::mem::zeroed()` to create an instance of the union, and then assign the value you want using one of the variant methods. + +### Why am I getting errors about unresolved imports? + +Each module is gated on a feature flag, so you must enable the appropriate feature to gain access to those items. For example, if you want to use something from `winapi::um::winuser` you must enable the `winuser` feature. + +### How do I know which module an item is defined in? + +You can use the search functionality in the [documentation](https://docs.rs/winapi/*/x86_64-pc-windows-msvc/winapi/) to find where items are defined. + +### Why is there no documentation on how to use anything? + +This crate is nothing more than raw bindings to Windows API. If you wish to know how to use the various functionality in Windows API, you can look up the various items on [MSDN](https://msdn.microsoft.com/en-us/library/windows/desktop/aa906039) which is full of detailed documentation. + +### Can I use this library in `no_std` projects? + +Yes, absolutely! By default the `std` feature of `winapi` is disabled, allowing you to write Windows applications using nothing but `core` and `winapi`. + +### Why is `winapi`'s `HANDLE` incompatible with `std`'s `HANDLE`? + +Because `winapi` does not depend on `std` by default, it has to define `c_void` itself instead of using `std::os::raw::c_void`. However, if you enable the `std` feature of `winapi` then it will re-export `c_void` from `std` and cause `winapi`'s `HANDLE` to be the same type as `std`'s `HANDLE`. + +### Should I still use those `-sys` crates such as `kernel32-sys`? + +No. Those crates are a legacy of how `winapi` 0.2 was organized. Starting with `winapi` 0.3 all definitions are directly in `winapi` itself, and so there is no longer any need to use those `-sys` crates. + +## Example ## + +Cargo.toml: +```toml +[target.'cfg(windows)'.dependencies] +winapi = { version = "0.3", features = ["winuser"] } +``` +main.rs: +```Rust +#[cfg(windows)] extern crate winapi; +use std::io::Error; + +#[cfg(windows)] +fn print_message(msg: &str) -> Result<i32, Error> { + use std::ffi::OsStr; + use std::iter::once; + use std::os::windows::ffi::OsStrExt; + use std::ptr::null_mut; + use winapi::um::winuser::{MB_OK, MessageBoxW}; + let wide: Vec<u16> = OsStr::new(msg).encode_wide().chain(once(0)).collect(); + let ret = unsafe { + MessageBoxW(null_mut(), wide.as_ptr(), wide.as_ptr(), MB_OK) + }; + if ret == 0 { Err(Error::last_os_error()) } + else { Ok(ret) } +} +#[cfg(not(windows))] +fn print_message(msg: &str) -> Result<(), Error> { + println!("{}", msg); + Ok(()) +} +fn main() { + print_message("Hello, world!").unwrap(); +} +``` + +## Financial Support +Do you use `winapi` in your projects? If so, you may be interested in financially supporting me on [Patreon](https://www.patreon.com/retep998). Companies in particular are especially encouraged to donate (I'm looking at you [Microsoft](https://github.com/Azure/iotedge/tree/master/edgelet)). diff --git a/third_party/cargo/vendor/winapi-0.3.8/build.rs b/third_party/cargo/vendor/winapi-0.3.8/build.rs new file mode 100644 index 0000000..3259f14 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/build.rs @@ -0,0 +1,497 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use std::cell::Cell; +use std::collections::HashMap; +use std::env::var; +// (header name, &[header dependencies], &[library dependencies]) +const DATA: &'static [(&'static str, &'static [&'static str], &'static [&'static str])] = &[ + // km + ("d3dkmthk", &["basetsd", "d3dukmdt", "minwindef", "ntdef", "windef"], &[]), + // mmos + // shared + ("basetsd", &[], &[]), + ("bcrypt", &["minwindef", "winnt"], &["bcrypt"]), + ("bthdef", &["bthsdpdef", "guiddef", "minwindef", "ntdef"], &[]), + ("bthioctl", &["bthdef", "bthsdpdef", "minwindef", "ntdef", "winioctl"], &[]), + ("bthsdpdef", &["guiddef", "minwindef", "ntdef"], &[]), + ("bugcodes", &["ntdef"], &[]), + ("cderr", &["minwindef"], &[]), + ("cfg", &["minwindef"], &[]), + ("d3d9", &["basetsd", "d3d9caps", "d3d9types", "guiddef", "minwindef", "unknwnbase", "windef", "wingdi", "winnt"], &["d3d9"]), + ("d3d9caps", &["d3d9types", "guiddef", "minwindef", "winnt"], &[]), + ("d3d9types", &["basetsd", "guiddef", "minwindef", "windef", "winnt"], &[]), + ("d3dkmdt", &["basetsd", "minwindef", "ntdef"], &[]), + ("d3dukmdt", &["basetsd", "guiddef", "minwindef", "ntdef"], &[]), + ("dcomptypes", &["dxgitype", "minwindef", "winnt"], &[]), + ("devguid", &[], &[]), + ("devpkey", &["devpropdef"], &[]), + ("devpropdef", &["guiddef", "minwindef", "winnt"], &[]), + ("dinputd", &[], &[]), + ("dxgi", &["basetsd", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxgi"]), + ("dxgi1_2", &["basetsd", "dxgi", "dxgiformat", "dxgitype", "guiddef", "minwinbase", "minwindef", "unknwnbase", "windef", "winnt"], &[]), + ("dxgi1_3", &["dxgi", "dxgi1_2", "dxgiformat", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxgi"]), + ("dxgi1_4", &["basetsd", "dxgi1_2", "dxgi1_3", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]), + ("dxgi1_5", &["basetsd", "dxgi", "dxgi1_2", "dxgi1_3", "dxgi1_4", "dxgiformat", "minwindef", "unknwnbase", "winnt"], &[]), + ("dxgi1_6", &["basetsd", "dxgi1_2", "dxgi1_4", "dxgi1_5", "dxgitype", "guiddef", "minwindef", "windef", "winnt"], &[]), + ("dxgiformat", &[], &[]), + ("dxgitype", &["d3d9types", "dxgiformat", "minwindef"], &[]), + ("enclaveapi", &["basetsd", "minwinbase", "minwindef", "ntdef", "winnt"], &["kernel32"]), + ("evntprov", &["basetsd", "guiddef", "minwindef", "winnt"], &["advapi32"]), + ("evntrace", &["basetsd", "evntcons", "evntprov", "guiddef", "handleapi", "minwindef", "timezoneapi", "vadefs", "winnt", "wmistr"], &["advapi32"]), + ("guiddef", &[], &[]), + ("hidclass", &["guiddef", "minwindef", "winioctl", "winnt"], &[]), + ("hidpi", &["hidusage", "minwindef", "ntdef", "ntstatus", "winnt"], &["hid"]), + ("hidsdi", &["guiddef", "hidpi", "minwindef", "winnt"], &["hid"]), + ("hidusage", &["minwindef"], &[]), + ("ifdef", &["basetsd", "minwindef"], &[]), + ("in6addr", &["minwindef"], &[]), + ("inaddr", &["minwindef"], &[]), + ("intsafe", &[], &[]), + ("ks", &[], &[]), + ("ksmedia", &["minwindef"], &[]), + ("ktmtypes", &["guiddef", "minwindef", "winnt"], &[]), + ("lmcons", &["minwindef", "winnt"], &[]), + ("minwindef", &["basetsd", "ntdef"], &[]), + ("mmreg", &["guiddef", "minwindef"], &[]), + ("mstcpip", &["basetsd", "guiddef", "in6addr", "inaddr", "minwindef", "winnt", "ws2def"], &["ntdll"]), + ("mswsockdef", &["minwindef", "winnt", "ws2def"], &[]), + ("netioapi", &["basetsd", "guiddef", "ifdef", "minwindef", "ntdef"], &["iphlpapi"]), + ("ntddscsi", &["basetsd", "minwindef", "ntdef", "winioctl", "winnt"], &[]), + ("ntddser", &["devpropdef"], &[]), + ("ntdef", &["basetsd", "guiddef"], &[]), + ("ntstatus", &["ntdef"], &[]), + ("qos", &["minwindef"], &[]), + ("rpc", &[], &[]), + ("rpcdce", &["guiddef", "minwindef", "rpc"], &[]), + ("rpcndr", &[], &[]), + ("sddl", &["basetsd", "minwindef", "winnt"], &["advapi32"]), + ("sspi", &["basetsd", "guiddef", "minwindef", "subauth", "wincred", "winnt"], &["credui", "secur32"]), + ("stralign", &["vcruntime", "winnt"], &["kernel32"]), + ("transportsettingcommon", &["guiddef"], &[]), + ("tvout", &["guiddef", "minwindef"], &[]), + ("usb", &["minwindef", "usbspec", "winnt"], &[]), + ("usbiodef", &["guiddef", "minwindef", "winioctl", "winnt"], &[]), + ("usbspec", &["basetsd", "guiddef", "minwindef", "winnt"], &[]), + ("windef", &["minwindef", "winnt"], &[]), + ("windowsx", &["minwindef"], &[]), + ("winerror", &["minwindef", "wtypesbase"], &[]), + ("winusbio", &["minwindef", "usb"], &[]), + ("wmistr", &["basetsd", "guiddef", "minwindef", "winnt"], &[]), + ("wnnc", &["minwindef"], &[]), + ("ws2def", &["basetsd", "guiddef", "inaddr", "minwindef", "vcruntime", "winnt"], &[]), + ("ws2ipdef", &["in6addr", "inaddr", "minwindef", "ws2def"], &[]), + ("wtypes", &["guiddef", "minwindef", "ntdef", "rpcndr", "wingdi", "wtypesbase"], &[]), + ("wtypesbase", &["minwindef", "rpcndr", "winnt"], &[]), + // ucrt + // um + ("accctrl", &["guiddef", "minwindef", "winbase", "winnt"], &[]), + ("aclapi", &["accctrl", "guiddef", "minwindef", "winnt"], &["advapi32"]), + ("appmgmt", &["guiddef", "minwindef", "winnt"], &["advapi32"]), + ("audioclient", &["audiosessiontypes", "basetsd", "guiddef", "minwindef", "mmreg", "strmif", "unknwnbase", "winerror", "winnt", "wtypesbase"], &[]), + ("audiosessiontypes", &["minwindef"], &[]), + ("avrt", &["guiddef", "minwindef", "winnt"], &["avrt"]), + ("bits", &["basetsd", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]), + ("bits10_1", &["basetsd", "bits", "bits2_0", "bits3_0", "bits5_0", "minwindef", "winnt"], &[]), + ("bits1_5", &["basetsd", "bits", "rpcndr", "winnt"], &[]), + ("bits2_0", &["basetsd", "bits", "bits1_5", "minwindef", "winnt"], &[]), + ("bits2_5", &["minwindef", "rpcndr", "unknwnbase", "winnt"], &[]), + ("bits3_0", &["basetsd", "bits", "bits2_0", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]), + ("bits4_0", &["basetsd", "bits3_0", "minwindef", "unknwnbase", "winnt"], &[]), + ("bits5_0", &["basetsd", "bits1_5", "bits3_0", "bits4_0", "guiddef", "minwindef", "winnt"], &[]), + ("bitscfg", &["guiddef", "oaidl", "unknwnbase", "winnt", "wtypes"], &["oleaut32"]), + ("bitsmsg", &["minwindef"], &[]), + ("bluetoothapis", &["bthdef", "bthsdpdef", "guiddef", "minwinbase", "minwindef", "windef", "winnt"], &["bthprops"]), + ("bluetoothleapis", &["bthledef", "minwindef", "winerror", "winnt"], &["bluetoothapis"]), + ("bthledef", &["basetsd", "guiddef", "minwindef", "winnt"], &[]), + ("cfgmgr32", &["basetsd", "cfg", "devpropdef", "guiddef", "minwindef", "winnt", "winreg"], &["cfgmgr32"]), + ("cguid", &[], &[]), + ("combaseapi", &["basetsd", "guiddef", "minwindef", "objidl", "objidlbase", "propidl", "rpcdce", "unknwnbase", "winnt", "wtypesbase"], &["ole32"]), + ("coml2api", &["minwindef"], &[]), + ("commapi", &["minwinbase", "minwindef", "winbase", "winnt"], &["kernel32"]), + ("commctrl", &["basetsd", "commoncontrols", "guiddef", "minwinbase", "minwindef", "vcruntime", "windef", "winnt", "winuser"], &["comctl32"]), + ("commdlg", &["basetsd", "minwindef", "prsht", "unknwnbase", "windef", "wingdi", "winnt", "winuser"], &["comdlg32"]), + ("commoncontrols", &["commctrl", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["comctl32"]), + ("consoleapi", &["minwindef", "wincon", "wincontypes", "winnt"], &["kernel32"]), + ("corsym", &["basetsd", "objidlbase", "unknwnbase", "winnt"], &[]), + ("d2d1", &["basetsd", "d2dbasetypes", "d3dcommon", "dcommon", "dwrite", "dxgi", "guiddef", "minwindef", "unknwnbase", "wincodec", "windef", "winnt"], &["d2d1"]), + ("d2d1_1", &["basetsd", "d2d1", "d2d1effectauthor", "d2dbasetypes", "dcommon", "documenttarget", "dwrite", "dxgi", "dxgiformat", "guiddef", "minwindef", "objidlbase", "unknwnbase", "wincodec", "winnt"], &["d2d1"]), + ("d2d1_2", &["d2d1", "d2d1_1", "dxgi", "minwindef", "winnt"], &["d2d1"]), + ("d2d1_3", &["basetsd", "d2d1", "d2d1_1", "d2d1_2", "d2d1effects", "d2d1svg", "dcommon", "dwrite", "dxgi", "dxgitype", "minwindef", "ntdef", "objidlbase", "wincodec", "winerror"], &["d2d1"]), + ("d2d1effectauthor", &["basetsd", "d2d1", "d2d1_1", "d2dbasetypes", "d3dcommon", "dxgiformat", "guiddef", "minwindef", "ntdef", "unknwnbase", "wincodec"], &[]), + ("d2d1effects", &[], &[]), + ("d2d1effects_1", &[], &[]), + ("d2d1effects_2", &[], &[]), + ("d2d1svg", &["basetsd", "d2d1", "d2d1_1", "guiddef", "minwindef", "ntdef", "objidlbase", "winerror"], &[]), + ("d2dbasetypes", &["d3d9types", "dcommon"], &[]), + ("d3d", &[], &[]), + ("d3d10", &["d3dcommon"], &[]), + ("d3d10_1", &[], &[]), + ("d3d10_1shader", &[], &[]), + ("d3d10effect", &[], &[]), + ("d3d10misc", &[], &[]), + ("d3d10sdklayers", &[], &[]), + ("d3d10shader", &["d3d10", "d3dcommon", "minwindef", "unknwnbase", "winnt"], &[]), + ("d3d11", &["basetsd", "d3dcommon", "dxgi", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["d3d11"]), + ("d3d11_1", &["basetsd", "d3d11", "d3dcommon", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]), + ("d3d11_2", &["basetsd", "d3d11", "d3d11_1", "dxgiformat", "minwindef", "winnt"], &[]), + ("d3d11_3", &[], &[]), + ("d3d11_4", &[], &[]), + ("d3d11on12", &["d3d11", "d3d12", "d3dcommon", "guiddef", "minwindef", "unknwnbase", "winnt"], &["d3d11"]), + ("d3d11sdklayers", &["basetsd", "d3d11", "dxgi", "minwindef", "unknwnbase", "winnt"], &[]), + ("d3d11shader", &["basetsd", "d3dcommon", "minwindef", "unknwnbase", "winnt"], &[]), + ("d3d11tokenizedprogramformat", &["minwindef"], &[]), + ("d3d12", &["basetsd", "d3dcommon", "dxgiformat", "dxgitype", "guiddef", "minwinbase", "minwindef", "unknwnbase", "windef", "winnt"], &["d3d12"]), + ("d3d12sdklayers", &["basetsd", "d3d12", "minwindef", "unknwnbase", "winnt"], &[]), + ("d3d12shader", &["basetsd", "d3dcommon", "minwindef", "unknwnbase", "winnt"], &[]), + ("d3dcommon", &["basetsd", "minwindef", "unknwnbase", "winnt"], &[]), + ("d3dcompiler", &["basetsd", "d3d11shader", "d3dcommon", "guiddef", "minwindef", "winnt"], &["d3dcompiler"]), + ("d3dcsx", &[], &[]), + ("d3dx10core", &[], &[]), + ("d3dx10math", &[], &[]), + ("d3dx10mesh", &[], &[]), + ("datetimeapi", &["minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("davclnt", &["minwindef", "winnt"], &["netapi32"]), + ("dbghelp", &["basetsd", "guiddef", "minwindef", "vcruntime", "winnt"], &["dbghelp"]), + ("dbt", &["basetsd", "guiddef", "minwindef", "winnt", "winuser"], &[]), + ("dcommon", &["basetsd", "dxgiformat", "minwindef", "windef"], &[]), + ("dcomp", &["d2d1", "d2d1_1", "d2d1effects", "d2dbasetypes", "d3d9types", "d3dcommon", "dcompanimation", "dcomptypes", "dxgi", "dxgi1_2", "dxgiformat", "guiddef", "minwinbase", "minwindef", "ntdef", "unknwnbase", "windef"], &["dcomp"]), + ("dcompanimation", &["ntdef", "unknwnbase"], &[]), + ("dde", &["basetsd", "minwindef"], &["user32"]), + ("ddraw", &[], &[]), + ("ddrawi", &[], &[]), + ("ddrawint", &[], &[]), + ("debugapi", &["minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("devicetopology", &["guiddef", "minwindef", "unknwnbase", "windef", "winnt", "wtypes"], &[]), + ("dinput", &[], &[]), + ("dispex", &["basetsd", "guiddef", "minwindef", "oaidl", "servprov", "unknwnbase", "winerror", "winnt", "wtypes"], &[]), + ("dmksctl", &[], &[]), + ("dmusicc", &[], &[]), + ("docobj", &["guiddef", "minwindef", "oaidl", "unknwnbase", "winnt"], &[]), + ("documenttarget", &["basetsd", "guiddef", "ntdef", "unknwnbase"], &[]), + ("dpa_dsa", &["basetsd", "minwindef", "winnt"], &["comctl32"]), + ("dpapi", &["minwindef", "wincrypt", "windef", "winnt"], &["crypt32"]), + ("dsgetdc", &["guiddef", "minwindef", "ntsecapi", "winnt", "ws2def"], &["netapi32"]), + ("dsound", &["guiddef", "minwindef", "mmsystem", "unknwnbase", "windef", "winerror", "winnt"], &["dsound"]), + ("dsrole", &["guiddef", "minwindef", "winnt"], &["netapi32"]), + ("dvp", &[], &[]), + ("dwmapi", &["basetsd", "minwindef", "uxtheme", "windef", "winnt"], &["dwmapi"]), + ("dwrite", &["basetsd", "d2d1", "dcommon", "guiddef", "minwindef", "unknwnbase", "windef", "winerror", "wingdi", "winnt"], &["dwrite"]), + ("dwrite_1", &["basetsd", "dcommon", "dwrite", "minwindef", "winnt"], &[]), + ("dwrite_2", &["basetsd", "d3d9types", "dcommon", "dwrite", "dwrite_1", "minwindef", "unknwnbase", "winnt"], &[]), + ("dwrite_3", &["basetsd", "dcommon", "dwrite", "dwrite_1", "dwrite_2", "minwindef", "unknwnbase", "wingdi", "winnt"], &[]), + ("dxdiag", &[], &[]), + ("dxfile", &[], &[]), + ("dxgidebug", &["basetsd", "guiddef", "minwindef", "unknwnbase", "winnt"], &["dxgi"]), + ("dxva2api", &["basetsd", "d3d9", "d3d9types", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxva2"]), + ("dxvahd", &["d3d9", "d3d9types", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxva2"]), + ("endpointvolume", &["basetsd", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]), + ("errhandlingapi", &["basetsd", "minwindef", "winnt"], &["kernel32"]), + ("evntcons", &["basetsd", "evntprov", "evntrace", "guiddef", "minwindef", "winnt"], &["advapi32"]), + ("exdisp", &["basetsd", "docobj", "oaidl", "ocidl", "winnt", "wtypes"], &[]), + ("fibersapi", &["minwindef", "winnt"], &["kernel32"]), + ("fileapi", &["minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("functiondiscoverykeys_devpkey", &["wtypes"], &[]), + ("gl-gl", &[], &["opengl32"]), + ("handleapi", &["minwindef", "winnt"], &["kernel32"]), + ("heapapi", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("highlevelmonitorconfigurationapi", &["minwindef", "physicalmonitorenumerationapi", "winnt"], &["dxva2"]), + ("http", &["guiddef", "minwinbase", "minwindef", "sspi", "winnt", "ws2def"], &["winhttp"]), + ("imm", &["minwindef", "windef"], &["imm32"]), + ("interlockedapi", &["minwindef", "winnt"], &["kernel32"]), + ("ioapiset", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("jobapi", &["minwindef", "winnt"], &["kernel32"]), + ("jobapi2", &["basetsd", "minwinbase", "minwindef", "ntdef", "winnt"], &["kernel32"]), + ("knownfolders", &[], &[]), + ("ktmw32", &["guiddef", "minwinbase", "minwindef", "winnt"], &["ktmw32"]), + ("libloaderapi", &["basetsd", "minwindef", "winnt"], &["kernel32", "user32"]), + ("lmaccess", &["basetsd", "lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmalert", &["lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmapibuf", &["lmcons", "minwindef"], &["netapi32"]), + ("lmat", &["basetsd", "lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmdfs", &["guiddef", "lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmerrlog", &["minwindef", "winnt"], &[]), + ("lmjoin", &["lmcons", "minwindef", "wincrypt", "winnt"], &["netapi32"]), + ("lmmsg", &["lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmremutl", &["lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmrepl", &["lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmserver", &["guiddef", "lmcons", "minwindef", "winnt", "winsvc"], &["advapi32", "netapi32"]), + ("lmshare", &["basetsd", "guiddef", "lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmstats", &["lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmsvc", &["lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmuse", &["lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lmwksta", &["lmcons", "minwindef", "winnt"], &["netapi32"]), + ("lowlevelmonitorconfigurationapi", &["minwindef", "physicalmonitorenumerationapi", "winnt"], &["dxva2"]), + ("lsalookup", &["guiddef", "minwindef", "ntdef", "winnt"], &["advapi32"]), + ("memoryapi", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("minschannel", &["guiddef", "minwindef", "wincrypt", "winnt"], &[]), + ("minwinbase", &["basetsd", "minwindef", "ntstatus", "winnt"], &[]), + ("mmdeviceapi", &["guiddef", "minwindef", "propidl", "propsys", "unknwnbase", "winnt", "wtypes"], &["mmdevapi"]), + ("mmeapi", &["basetsd", "imm", "minwindef", "mmsystem", "winnt"], &["winmm"]), + ("mmsystem", &["basetsd", "minwindef", "mmreg", "winnt"], &[]), + ("msaatext", &[], &[]), + ("mscat", &["guiddef", "minwindef", "mssip", "wincrypt", "winnt"], &[]), + ("mschapp", &["basetsd", "minwindef", "winnt"], &["advapi32"]), + ("mssip", &["guiddef", "minwindef", "mscat", "wincrypt", "winnt"], &["crypt32"]), + ("mswsock", &["minwinbase", "minwindef", "mswsockdef", "winnt", "winsock2", "ws2def"], &["mswsock"]), + ("namedpipeapi", &["minwinbase", "minwindef", "winnt"], &["advapi32", "kernel32"]), + ("namespaceapi", &["minwinbase", "minwindef", "ntdef", "winnt"], &["kernel32"]), + ("nb30", &["minwindef", "winnt"], &["netapi32"]), + ("ncrypt", &["basetsd", "bcrypt", "minwindef", "winnt"], &["ncrypt"]), + ("ntlsa", &["basetsd", "guiddef", "lsalookup", "minwindef", "ntdef", "ntsecapi", "subauth", "winnt"], &["advapi32"]), + ("ntsecapi", &["basetsd", "guiddef", "lsalookup", "minwindef", "ntdef", "sspi", "subauth", "winnt"], &["advapi32"]), + ("oaidl", &["basetsd", "guiddef", "minwindef", "rpcndr", "unknwnbase", "winnt", "wtypes", "wtypesbase"], &[]), + ("objbase", &["combaseapi", "minwindef", "winnt"], &["ole32"]), + ("objidl", &["basetsd", "guiddef", "minwindef", "ntdef", "objidlbase", "unknwnbase", "windef", "winnt", "wtypes", "wtypesbase"], &[]), + ("objidlbase", &["basetsd", "guiddef", "minwindef", "unknwnbase", "winnt", "wtypesbase"], &[]), + ("ocidl", &["guiddef", "minwindef", "ntdef", "oaidl", "unknwnbase", "wtypes", "wtypesbase"], &[]), + ("ole2", &["minwindef", "oleidl", "windef", "winnt"], &["ole32"]), + ("oleauto", &["basetsd", "minwinbase", "minwindef", "oaidl", "winnt", "wtypes", "wtypesbase"], &["oleaut32"]), + ("olectl", &["winerror", "winnt"], &[]), + ("oleidl", &["minwindef", "ntdef", "objidl", "unknwnbase", "windef"], &[]), + ("opmapi", &["basetsd", "d3d9", "d3d9types", "dxva2api", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxva2"]), + ("pdh", &["basetsd", "guiddef", "minwindef", "windef", "winnt"], &["pdh"]), + ("perflib", &["basetsd", "guiddef", "minwinbase", "minwindef", "winnt"], &["advapi32"]), + ("physicalmonitorenumerationapi", &["d3d9", "minwindef", "windef", "winnt"], &["dxva2"]), + ("playsoundapi", &["minwindef", "winnt"], &["winmm"]), + ("portabledevice", &["basetsd", "wtypes"], &[]), + ("portabledeviceapi", &["guiddef", "minwindef", "objidlbase", "portabledevicetypes", "propkeydef", "unknwnbase", "winnt"], &[]), + ("portabledevicetypes", &["guiddef", "minwindef", "propidl", "propkeydef", "propsys", "unknwnbase", "winnt", "wtypes"], &[]), + ("powerbase", &["minwindef", "winnt", "winuser"], &["powrprof"]), + ("powersetting", &["guiddef", "minwindef", "winnt", "winuser"], &["powrprof"]), + ("powrprof", &["guiddef", "minwindef", "winnt", "winreg"], &["powrprof"]), + ("processenv", &["minwindef", "winnt"], &["kernel32"]), + ("processsnapshot", &["basetsd", "minwindef", "winnt"], &["kernel32"]), + ("processthreadsapi", &["basetsd", "guiddef", "minwinbase", "minwindef", "winnt"], &["advapi32", "kernel32"]), + ("processtopologyapi", &["minwindef", "winnt"], &["kernel32"]), + ("profileapi", &["minwindef", "winnt"], &["kernel32"]), + ("propidl", &["guiddef", "minwindef", "ntdef", "oaidl", "objidlbase", "unknwnbase", "wtypes", "wtypesbase"], &["ole32"]), + ("propkey", &["minwindef", "ntdef", "wtypes"], &[]), + ("propkeydef", &["guiddef", "wtypes"], &[]), + ("propsys", &["minwindef", "propidl", "propkeydef", "unknwnbase", "winnt", "wtypes"], &[]), + ("prsht", &["basetsd", "minwindef", "windef", "winnt", "winuser"], &["comctl32"]), + ("psapi", &["basetsd", "minwindef", "winnt"], &["kernel32", "psapi"]), + ("realtimeapiset", &["basetsd", "minwindef", "winnt"], &["kernel32"]), + ("reason", &["minwindef"], &[]), + ("restartmanager", &["minwindef", "winnt"], &["rstrtmgr"]), + ("restrictederrorinfo", &["unknwnbase", "winnt", "wtypes"], &[]), + ("rmxfguid", &[], &[]), + ("sapi", &["guiddef", "minwindef", "sapi53", "unknwnbase", "winnt"], &[]), + ("sapi51", &["guiddef", "minwindef", "mmreg", "oaidl", "objidlbase", "rpcndr", "servprov", "unknwnbase", "windef", "winnt", "wtypes", "wtypesbase"], &[]), + ("sapi53", &["guiddef", "minwindef", "oaidl", "sapi51", "unknwnbase", "urlmon", "winnt", "wtypes"], &[]), + ("sapiddk", &["guiddef", "minwindef", "sapi", "sapiddk51", "unknwnbase", "winnt"], &[]), + ("sapiddk51", &["guiddef", "minwindef", "mmreg", "oaidl", "objidlbase", "sapi", "unknwnbase", "windef", "winnt"], &[]), + ("schannel", &["guiddef", "minwindef", "wincrypt", "windef", "winnt"], &[]), + ("securityappcontainer", &["minwindef", "winnt"], &["kernel32"]), + ("securitybaseapi", &["guiddef", "minwinbase", "minwindef", "winnt"], &["advapi32", "kernel32"]), + ("servprov", &["guiddef", "unknwnbase", "winnt"], &[]), + ("setupapi", &["basetsd", "commctrl", "devpropdef", "guiddef", "minwindef", "prsht", "spapidef", "windef", "winnt", "winreg"], &["setupapi"]), + ("shellapi", &["basetsd", "guiddef", "minwinbase", "minwindef", "processthreadsapi", "windef", "winnt", "winuser"], &["shell32", "shlwapi"]), + ("shellscalingapi", &["minwindef", "windef", "winnt"], &["shcore"]), + ("shlobj", &["guiddef", "minwinbase", "minwindef", "shtypes", "windef", "winnt"], &["shell32"]), + ("shobjidl", &["guiddef", "minwindef", "objidl", "propkeydef", "propsys", "shobjidl_core", "shtypes", "unknwnbase", "windef", "winnt"], &[]), + ("shobjidl_core", &["commctrl", "guiddef", "minwindef", "objidl", "unknwnbase", "windef", "winnt"], &[]), + ("shtypes", &["guiddef", "minwindef", "winnt"], &[]), + ("spapidef", &["minwindef", "winnt"], &[]), + ("spellcheck", &["minwindef", "ntdef", "objidlbase", "unknwnbase", "winerror"], &[]), + ("sporder", &["guiddef", "minwindef"], &["sporder"]), + ("sql", &["sqltypes"], &["odbc32"]), + ("sqlext", &["sql", "sqltypes"], &[]), + ("sqltypes", &["basetsd", "guiddef", "windef"], &[]), + ("sqlucode", &["sqltypes"], &["odbc32"]), + ("stringapiset", &["minwindef", "winnls", "winnt"], &["kernel32"]), + ("strmif", &["winnt"], &[]), + ("subauth", &["minwindef", "winnt"], &[]), + ("synchapi", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32", "synchronization"]), + ("sysinfoapi", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("systemtopologyapi", &["minwindef", "winnt"], &["kernel32"]), + ("taskschd", &["minwinbase", "minwindef", "oaidl", "unknwnbase", "winnt", "wtypes"], &[]), + ("textstor", &[], &[]), + ("threadpoolapiset", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("threadpoollegacyapiset", &["minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("timeapi", &["minwindef", "mmsystem"], &["winmm"]), + ("timezoneapi", &["minwinbase", "minwindef", "winnt"], &["advapi32", "kernel32"]), + ("tlhelp32", &["basetsd", "minwindef", "winnt"], &["kernel32"]), + ("unknwnbase", &["guiddef", "minwindef", "winnt"], &[]), + ("urlhist", &["docobj", "guiddef", "minwindef", "unknwnbase", "winnt", "wtypesbase"], &[]), + ("urlmon", &["minwindef", "unknwnbase", "winnt"], &[]), + ("userenv", &["minwindef", "winnt", "winreg"], &["userenv"]), + ("usp10", &["minwindef", "ntdef", "windef", "winerror", "wingdi", "winnt"], &["usp10"]), + ("utilapiset", &["minwindef", "ntdef"], &["kernel32"]), + ("uxtheme", &["commctrl", "minwindef", "windef", "wingdi", "winnt"], &["uxtheme"]), + ("vsbackup", &["guiddef", "minwindef", "unknwnbase", "vss", "vswriter", "winnt", "wtypes"], &["vssapi"]), + ("vss", &["guiddef", "minwindef", "unknwnbase", "winnt"], &[]), + ("vsserror", &["winnt"], &[]), + ("vswriter", &["minwindef", "unknwnbase", "vss", "winnt", "wtypes"], &[]), + ("wbemads", &["oaidl", "wbemdisp", "winerror", "wtypes"], &[]), + ("wbemcli", &["minwindef", "oaidl", "rpcndr", "unknwnbase", "winerror", "winnt", "wtypes"], &[]), + ("wbemdisp", &["oaidl", "unknwnbase", "winerror", "wtypes"], &[]), + ("wbemprov", &["minwindef", "oaidl", "unknwnbase", "wbemcli", "winerror", "winnt", "wtypes"], &[]), + ("wbemtran", &["guiddef", "minwindef", "unknwnbase", "wbemcli", "winerror", "winnt", "wtypes"], &[]), + ("wct", &["basetsd", "guiddef", "minwindef", "winnt"], &["advapi32"]), + ("werapi", &["minwindef", "winnt"], &["kernel32", "wer"]), + ("winbase", &["basetsd", "cfgmgr32", "fileapi", "guiddef", "libloaderapi", "minwinbase", "minwindef", "processthreadsapi", "vadefs", "windef", "winnt"], &["kernel32"]), + ("wincodec", &["basetsd", "d2d1", "d2d1_1", "dcommon", "dxgiformat", "dxgitype", "guiddef", "minwindef", "ntdef", "objidlbase", "ocidl", "propidl", "unknwnbase", "windef", "winerror", "winnt"], &["windowscodecs"]), + ("wincodecsdk", &["guiddef", "minwindef", "oaidl", "objidl", "objidlbase", "ocidl", "propidl", "unknwnbase", "wincodec", "winnt", "wtypes"], &["ole32", "oleaut32", "windowscodecs"]), + ("wincon", &["minwinbase", "minwindef", "wincontypes", "windef", "wingdi", "winnt"], &["kernel32"]), + ("wincontypes", &["minwindef", "winnt"], &[]), + ("wincred", &["minwindef", "sspi", "windef", "winnt"], &["advapi32", "credui"]), + ("wincrypt", &["basetsd", "bcrypt", "guiddef", "minwinbase", "minwindef", "ncrypt", "vcruntime", "winnt"], &["advapi32", "crypt32", "cryptnet"]), + ("windowsceip", &["minwindef"], &["kernel32"]), + ("winefs", &["basetsd", "minwinbase", "minwindef", "wincrypt", "winnt"], &["advapi32"]), + ("winevt", &["basetsd", "guiddef", "minwinbase", "minwindef", "vcruntime", "winnt"], &["wevtapi"]), + ("wingdi", &["basetsd", "minwindef", "windef", "winnt"], &["gdi32", "msimg32", "opengl32", "winspool"]), + ("winhttp", &["basetsd", "minwinbase", "minwindef", "winnt"], &["winhttp"]), + ("wininet", &["basetsd", "minwinbase", "minwindef", "ntdef", "windef", "winineti", "winnt"], &["wininet"]), + ("winineti", &["minwindef"], &[]), + ("winioctl", &["basetsd", "devpropdef", "guiddef", "minwindef", "winnt"], &[]), + ("winnetwk", &["basetsd", "minwindef", "windef", "winerror", "winnt"], &["mpr"]), + ("winnls", &["basetsd", "guiddef", "minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("winnt", &["basetsd", "excpt", "guiddef", "ktmtypes", "minwindef", "ntdef", "vcruntime"], &["kernel32"]), + ("winreg", &["basetsd", "minwinbase", "minwindef", "winnt"], &["advapi32"]), + ("winsafer", &["basetsd", "guiddef", "minwindef", "wincrypt", "windef", "winnt"], &["advapi32"]), + ("winscard", &["basetsd", "guiddef", "minwindef", "rpcdce", "windef", "winnt", "winsmcrd"], &["winscard"]), + ("winsmcrd", &["minwindef", "winioctl"], &[]), + ("winsock2", &["basetsd", "guiddef", "inaddr", "minwinbase", "minwindef", "qos", "winbase", "windef", "winerror", "winnt", "ws2def", "wtypesbase"], &["ws2_32"]), + ("winspool", &["guiddef", "minwinbase", "minwindef", "vcruntime", "windef", "winerror", "wingdi", "winnt"], &["winspool"]), + ("winsvc", &["minwindef", "winnt"], &["advapi32"]), + ("winusb", &["minwinbase", "minwindef", "usb", "usbspec", "winnt", "winusbio"], &["winusb"]), + ("winuser", &["basetsd", "guiddef", "limits", "minwinbase", "minwindef", "vadefs", "windef", "wingdi", "winnt"], &["user32"]), + ("winver", &["minwindef", "winnt"], &["kernel32", "version"]), + ("wow64apiset", &["minwindef", "winnt"], &["kernel32"]), + ("wpdmtpextensions", &["wtypes"], &[]), + ("ws2bth", &["bthdef", "bthsdpdef", "guiddef", "minwindef", "winnt", "ws2def"], &[]), + ("ws2spi", &["basetsd", "guiddef", "minwindef", "vcruntime", "windef", "winnt", "winsock2", "ws2def", "wtypesbase"], &["ws2_32"]), + ("ws2tcpip", &["guiddef", "minwinbase", "minwindef", "mstcpip", "vcruntime", "winerror", "winnt", "winsock2", "ws2def", "wtypesbase"], &["fwpuclnt", "ws2_32"]), + ("xinput", &["guiddef", "minwindef", "winnt"], &["xinput"]), + // vc + ("excpt", &[], &[]), + ("limits", &[], &[]), + ("vadefs", &[], &[]), + ("vcruntime", &[], &[]), + // winrt + ("activation", &["inspectable", "winnt"], &[]), + ("hstring", &["winnt"], &[]), + ("inspectable", &["guiddef", "hstring", "minwindef", "unknwnbase", "winnt"], &[]), + ("roapi", &["activation", "basetsd", "guiddef", "hstring", "inspectable", "objidl", "winnt"], &["runtimeobject"]), + ("robuffer", &["objidl", "winnt"], &["runtimeobject"]), + ("roerrorapi", &["basetsd", "hstring", "minwindef", "restrictederrorinfo", "unknwnbase", "winnt"], &["runtimeobject"]), + ("winstring", &["basetsd", "hstring", "minwindef", "winnt"], &["runtimeobject"]), +]; +struct Header { + required: bool, + included: Cell<bool>, + dependencies: &'static [&'static str], + libraries: &'static [&'static str], +} +struct Graph(HashMap<&'static str, Header>); +impl Graph { + fn generate() -> Graph { + Graph(DATA.iter().map(|&(name, dependencies, libraries)| { + let header = Header { + required: false, + included: Cell::new(false), + dependencies: dependencies, + libraries: libraries, + }; + (name, header) + }).collect()) + } + fn identify_required(&mut self) { + for (name, header) in &mut self.0 { + if let Ok(_) = var(&format!("CARGO_FEATURE_{}", name.to_uppercase())) { + header.required = true; + header.included.set(true); + } + } + } + fn check_everything(&self) { + if let Ok(_) = var("CARGO_FEATURE_EVERYTHING") { + for (_, header) in &self.0 { + header.included.set(true); + } + } + } + fn resolve_dependencies(&self) { + let mut done = false; + while !done { + done = true; + for (_, header) in &self.0 { + if header.included.get() { + for dep in header.dependencies { + let dep = &self.0.get(dep).expect(dep); + if !dep.included.get() { + done = false; + dep.included.set(true); + } + } + } + } + } + } + fn emit_features(&self) { + for (name, header) in &self.0 { + if header.included.get() && !header.required { + println!("cargo:rustc-cfg=feature=\"{}\"", name); + } + } + } + fn emit_libraries(&self) { + let mut libs = self.0.iter().filter(|&(_, header)| { + header.included.get() + }).flat_map(|(_, header)| { + header.libraries.iter() + }).collect::<Vec<_>>(); + libs.sort(); + libs.dedup(); + // FIXME Temporary hacks until build script is redesigned. + libs.retain(|&&lib| match &*var("TARGET").unwrap() { + "aarch64-pc-windows-msvc" | "thumbv7a-pc-windows-msvc" => { + if lib == "opengl32" { false } + else { true } + }, + _ => true, + }); + let prefix = library_prefix(); + let kind = library_kind(); + for lib in libs { + println!("cargo:rustc-link-lib={}={}{}", kind, prefix, lib); + } + } +} +fn library_prefix() -> &'static str { + if var("TARGET").map(|target| + target == "i686-pc-windows-gnu" || target == "x86_64-pc-windows-gnu" + ).unwrap_or(false) && var("WINAPI_NO_BUNDLED_LIBRARIES").is_err() { + "winapi_" + } else { + "" + } +} +fn library_kind() -> &'static str { + if var("WINAPI_STATIC_NOBUNDLE").is_ok() { + "static-nobundle" + } else { + "dylib" + } +} +fn try_everything() { + let mut graph = Graph::generate(); + graph.identify_required(); + graph.check_everything(); + graph.resolve_dependencies(); + graph.emit_features(); + graph.emit_libraries(); +} +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=WINAPI_NO_BUNDLED_LIBRARIES"); + println!("cargo:rerun-if-env-changed=WINAPI_STATIC_NOBUNDLE"); + let target = var("TARGET").unwrap(); + let target: Vec<_> = target.split('-').collect(); + if target.get(2) == Some(&"windows") { + try_everything(); + } +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/km/d3dkmthk.rs b/third_party/cargo/vendor/winapi-0.3.8/src/km/d3dkmthk.rs new file mode 100644 index 0000000..9ac551c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/km/d3dkmthk.rs @@ -0,0 +1,312 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! longhorn display driver model kernel mode thunk interfaces +use shared::basetsd::{UINT32, UINT64}; +use shared::d3dukmdt::{ + D3DDDICB_SIGNALFLAGS, D3DDDI_ALLOCATIONLIST, D3DDDI_CREATECONTEXTFLAGS, + D3DDDI_MAX_BROADCAST_CONTEXT, D3DDDI_MAX_OBJECT_SIGNALED, D3DDDI_MAX_OBJECT_WAITED_ON, + D3DDDI_PATCHLOCATIONLIST, D3DDDI_SYNCHRONIZATIONOBJECTINFO, + D3DDDI_SYNCHRONIZATIONOBJECTINFO2, D3DDDI_VIDEO_PRESENT_SOURCE_ID, D3DGPU_VIRTUAL_ADDRESS, + D3DKMT_HANDLE, +}; +use shared::minwindef::{BOOL, UCHAR, UINT, ULONG}; +use shared::ntdef::{HANDLE, LUID, PCWSTR, ULONGLONG, VOID, WCHAR}; +use shared::windef::HDC; +STRUCT!{struct D3DKMT_CREATEDEVICEFLAGS { + bitfield: UINT, +}} +BITFIELD!{D3DKMT_CREATEDEVICEFLAGS bitfield: UINT [ + LegacyMode set_LegacyMode[0..1], + RequestVSync set_RequestVSync[1..2], + DisableGpuTimeout set_DisableGpuTimeout[2..3], + Reserved set_Reserved[3..32], +]} +UNION!{union D3DKMT_CREATEDEVICE_u { + [usize; 1], + hAdapter hAdapter_mut: D3DKMT_HANDLE, + pAdapter pAdapter_mut: *mut VOID, +}} +STRUCT!{struct D3DKMT_CREATEDEVICE { + u: D3DKMT_CREATEDEVICE_u, + Flags: D3DKMT_CREATEDEVICEFLAGS, + hDevice: D3DKMT_HANDLE, + pCommandBuffer: *mut VOID, + CommandBufferSize: UINT, + pAllocationList: *mut D3DDDI_ALLOCATIONLIST, + AllocationListSize: UINT, + pPatchLocationList: *mut D3DDDI_PATCHLOCATIONLIST, + PatchLocationListSize: UINT, +}} +STRUCT!{struct D3DKMT_DESTROYDEVICE { + hDevice: D3DKMT_HANDLE, +}} +ENUM!{enum D3DKMT_CLIENTHINT { + D3DKMT_CLIENTHINT_UNKNOWN = 0, + D3DKMT_CLIENTHINT_OPENGL = 1, + D3DKMT_CLIENTHINT_CDD = 2, + D3DKMT_CLIENTHINT_DX7 = 7, + D3DKMT_CLIENTHINT_DX8 = 8, + D3DKMT_CLIENTHINT_DX9 = 9, + D3DKMT_CLIENTHINT_DX10 = 10, +}} +STRUCT!{struct D3DKMT_CREATECONTEXT { + hDevice: D3DKMT_HANDLE, + NodeOrdinal: UINT, + EngineAffinity: UINT, + Flags: D3DDDI_CREATECONTEXTFLAGS, + pPrivateDriverData: *mut VOID, + PrivateDriverDataSize: UINT, + ClientHint: D3DKMT_CLIENTHINT, + hContext: D3DKMT_HANDLE, + pCommandBuffer: *mut VOID, + CommandBufferSize: UINT, + pAllocationList: *mut D3DDDI_ALLOCATIONLIST, + AllocationListSize: UINT, + pPatchLocationList: *mut D3DDDI_PATCHLOCATIONLIST, + PatchLocationListSize: UINT, + CommandBuffer: D3DGPU_VIRTUAL_ADDRESS, +}} +STRUCT!{struct D3DKMT_DESTROYCONTEXT { + hContext: D3DKMT_HANDLE, +}} +STRUCT!{struct D3DKMT_CREATESYNCHRONIZATIONOBJECT { + hDevice: D3DKMT_HANDLE, + Info: D3DDDI_SYNCHRONIZATIONOBJECTINFO, + hSyncObject: D3DKMT_HANDLE, +}} +STRUCT!{struct D3DKMT_CREATESYNCHRONIZATIONOBJECT2 { + hDevice: D3DKMT_HANDLE, + Info: D3DDDI_SYNCHRONIZATIONOBJECTINFO2, + hSyncObject: D3DKMT_HANDLE, +}} +STRUCT!{struct D3DKMT_DESTROYSYNCHRONIZATIONOBJECT { + hSyncObject: D3DKMT_HANDLE, +}} +STRUCT!{struct D3DKMT_OPENSYNCHRONIZATIONOBJECT { + hSharedHandle: D3DKMT_HANDLE, + hSyncObject: D3DKMT_HANDLE, + Reserved: [UINT64; 8], +}} +STRUCT!{struct D3DKMT_WAITFORSYNCHRONIZATIONOBJECT { + hContext: D3DKMT_HANDLE, + ObjectCount: UINT, + ObjectHandleArray: [D3DKMT_HANDLE; D3DDDI_MAX_OBJECT_WAITED_ON], +}} +STRUCT!{struct D3DKMT_WAITFORSYNCHRONIZATIONOBJECT2_Fence { + FenceValue: UINT64, +}} +UNION!{union D3DKMT_WAITFORSYNCHRONIZATIONOBJECT2_u { + [u64; 8], + Fence Fence_mut: D3DKMT_WAITFORSYNCHRONIZATIONOBJECT2_Fence, + Reserved Reserved_mut: [UINT64; 8], +}} +STRUCT!{struct D3DKMT_WAITFORSYNCHRONIZATIONOBJECT2 { + hContext: D3DKMT_HANDLE, + ObjectCount: UINT, + ObjectHandleArray: [D3DKMT_HANDLE; D3DDDI_MAX_OBJECT_WAITED_ON], + u: D3DKMT_WAITFORSYNCHRONIZATIONOBJECT2_u, +}} +STRUCT!{struct D3DKMT_SIGNALSYNCHRONIZATIONOBJECT { + hContext: D3DKMT_HANDLE, + ObjectCount: UINT, + ObjectHandleArray: [D3DKMT_HANDLE; D3DDDI_MAX_OBJECT_SIGNALED], + Flags: D3DDDICB_SIGNALFLAGS, +}} +STRUCT!{struct D3DKMT_SIGNALSYNCHRONIZATIONOBJECT2_Fence { + FenceValue: UINT64, +}} +UNION!{union D3DKMT_SIGNALSYNCHRONIZATIONOBJECT2_u { + [u64; 8], + Fence Fence_mut: D3DKMT_SIGNALSYNCHRONIZATIONOBJECT2_Fence, + CpuEventHandle CpuEventHandle_mut: HANDLE, + Reserved Reserved_mut: [UINT64; 8], +}} +STRUCT!{struct D3DKMT_SIGNALSYNCHRONIZATIONOBJECT2 { + hContext: D3DKMT_HANDLE, + ObjectCount: UINT, + ObjectHandleArray: [D3DKMT_HANDLE; D3DDDI_MAX_OBJECT_SIGNALED], + Flags: D3DDDICB_SIGNALFLAGS, + BroadcastContextCount: ULONG, + BroadcastContext: [D3DKMT_HANDLE; D3DDDI_MAX_BROADCAST_CONTEXT], + u: D3DKMT_SIGNALSYNCHRONIZATIONOBJECT2_u, +}} +//1512 +STRUCT!{struct D3DKMT_SEGMENTSIZEINFO { + DedicatedVideoMemorySize: ULONGLONG, + DedicatedSystemMemorySize: ULONGLONG, + SharedSystemMemorySize: ULONGLONG, +}} +//1617 +STRUCT!{struct D3DKMT_ADAPTERTYPE { + Value: UINT, +}} +BITFIELD!{D3DKMT_ADAPTERTYPE Value: UINT [ + RenderSupported set_RenderSupported[0..1], + DisplaySupported set_DisplaySupported[1..2], + SoftwareDevice set_SoftwareDevice[2..3], + PostDevice set_PostDevice[3..4], + HybridDiscrete set_HybridDiscrete[4..5], + HybridIntegrated set_HybridIntegrated[5..6], + IndirectDisplayDevice set_IndirectDisplayDevice[6..7], + Paravirtualized set_Paravirtualized[7..8], + ACGSupported set_ACGSupported[8..9], + SupportSetTimingsFromVidPn set_SupportSetTimingsFromVidPn[9..10], + Detachable set_Detachable[10..11], + Reserved set_Reserved[11..32], +]} +//1852 +STRUCT!{struct D3DKMT_NODE_PERFDATA { + NodeOrdinal: UINT32, + PhysicalAdapterIndex: UINT32, + Frequency: ULONGLONG, + MaxFrequency: ULONGLONG, + MaxFrequencyOC: ULONGLONG, + Voltage: ULONG, + VoltageMax: ULONG, + VoltageMaxOC: ULONG, + MaxTransitionLatency: ULONGLONG, +}} +STRUCT!{struct D3DKMT_ADAPTER_PERFDATA { + PhysicalAdapterIndex: UINT32, + MemoryFrequency: ULONGLONG, + MaxMemoryFrequency: ULONGLONG, + MaxMemoryFrequencyOC: ULONGLONG, + MemoryBandwidth: ULONGLONG, + PCIEBandwidth: ULONGLONG, + FanRPM: ULONG, + Power: ULONG, + Temperature: ULONG, + PowerStateOverride: UCHAR, +}} +STRUCT!{struct D3DKMT_ADAPTER_PERFDATACAPS { + PhysicalAdapterIndex: UINT32, + MaxMemoryBandwidth: ULONGLONG, + MaxPCIEBandwidth: ULONGLONG, + MaxFanRPM: ULONG, + TemperatureMax: ULONG, + TemperatureWarning: ULONG, +}} +pub const DXGK_MAX_GPUVERSION_NAME_LENGTH: usize = 32; +STRUCT!{struct D3DKMT_GPUVERSION { + PhysicalAdapterIndex: UINT32, + BiosVersion: [WCHAR; DXGK_MAX_GPUVERSION_NAME_LENGTH], + GpuArchitecture: [WCHAR; DXGK_MAX_GPUVERSION_NAME_LENGTH], +}} +ENUM!{enum KMTQUERYADAPTERINFOTYPE { + KMTQAITYPE_UMDRIVERPRIVATE = 0, + KMTQAITYPE_UMDRIVERNAME = 1, + KMTQAITYPE_UMOPENGLINFO = 2, + KMTQAITYPE_GETSEGMENTSIZE = 3, + KMTQAITYPE_ADAPTERGUID = 4, + KMTQAITYPE_FLIPQUEUEINFO = 5, + KMTQAITYPE_ADAPTERADDRESS = 6, + KMTQAITYPE_SETWORKINGSETINFO = 7, + KMTQAITYPE_ADAPTERREGISTRYINFO = 8, + KMTQAITYPE_CURRENTDISPLAYMODE = 9, + KMTQAITYPE_MODELIST = 10, + KMTQAITYPE_CHECKDRIVERUPDATESTATUS = 11, + KMTQAITYPE_VIRTUALADDRESSINFO = 12, + KMTQAITYPE_DRIVERVERSION = 13, + KMTQAITYPE_ADAPTERTYPE = 15, + KMTQAITYPE_OUTPUTDUPLCONTEXTSCOUNT = 16, + KMTQAITYPE_WDDM_1_2_CAPS = 17, + KMTQAITYPE_UMD_DRIVER_VERSION = 18, + KMTQAITYPE_DIRECTFLIP_SUPPORT = 19, + KMTQAITYPE_MULTIPLANEOVERLAY_SUPPORT = 20, + KMTQAITYPE_DLIST_DRIVER_NAME = 21, + KMTQAITYPE_WDDM_1_3_CAPS = 22, + KMTQAITYPE_MULTIPLANEOVERLAY_HUD_SUPPORT = 23, + KMTQAITYPE_WDDM_2_0_CAPS = 24, + KMTQAITYPE_NODEMETADATA = 25, + KMTQAITYPE_CPDRIVERNAME = 26, + KMTQAITYPE_XBOX = 27, + KMTQAITYPE_INDEPENDENTFLIP_SUPPORT = 28, + KMTQAITYPE_MIRACASTCOMPANIONDRIVERNAME = 29, + KMTQAITYPE_PHYSICALADAPTERCOUNT = 30, + KMTQAITYPE_PHYSICALADAPTERDEVICEIDS = 31, + KMTQAITYPE_DRIVERCAPS_EXT = 32, + KMTQAITYPE_QUERY_MIRACAST_DRIVER_TYPE = 33, + KMTQAITYPE_QUERY_GPUMMU_CAPS = 34, + KMTQAITYPE_QUERY_MULTIPLANEOVERLAY_DECODE_SUPPORT = 35, + KMTQAITYPE_QUERY_HW_PROTECTION_TEARDOWN_COUNT = 36, + KMTQAITYPE_QUERY_ISBADDRIVERFORHWPROTECTIONDISABLED = 37, + KMTQAITYPE_MULTIPLANEOVERLAY_SECONDARY_SUPPORT = 38, + KMTQAITYPE_INDEPENDENTFLIP_SECONDARY_SUPPORT = 39, + KMTQAITYPE_PANELFITTER_SUPPORT = 40, + KMTQAITYPE_PHYSICALADAPTERPNPKEY = 41, + KMTQAITYPE_GETSEGMENTGROUPSIZE = 42, + KMTQAITYPE_MPO3DDI_SUPPORT = 43, + KMTQAITYPE_HWDRM_SUPPORT = 44, + KMTQAITYPE_MPOKERNELCAPS_SUPPORT = 45, + KMTQAITYPE_MULTIPLANEOVERLAY_STRETCH_SUPPORT = 46, + KMTQAITYPE_GET_DEVICE_VIDPN_OWNERSHIP_INFO = 47, + KMTQAITYPE_QUERYREGISTRY = 48, + KMTQAITYPE_KMD_DRIVER_VERSION = 49, + KMTQAITYPE_BLOCKLIST_KERNEL = 50, + KMTQAITYPE_BLOCKLIST_RUNTIME = 51, + KMTQAITYPE_ADAPTERGUID_RENDER = 52, + KMTQAITYPE_ADAPTERADDRESS_RENDER = 53, + KMTQAITYPE_ADAPTERREGISTRYINFO_RENDER = 54, + KMTQAITYPE_CHECKDRIVERUPDATESTATUS_RENDER = 55, + KMTQAITYPE_DRIVERVERSION_RENDER = 56, + KMTQAITYPE_ADAPTERTYPE_RENDER = 57, + KMTQAITYPE_WDDM_1_2_CAPS_RENDER = 58, + KMTQAITYPE_WDDM_1_3_CAPS_RENDER = 59, + KMTQAITYPE_QUERY_ADAPTER_UNIQUE_GUID = 60, + KMTQAITYPE_NODEPERFDATA = 61, + KMTQAITYPE_ADAPTERPERFDATA = 62, + KMTQAITYPE_ADAPTERPERFDATA_CAPS = 63, + KMTQUITYPE_GPUVERSION = 64, +}} +STRUCT!{struct D3DKMT_QUERYADAPTERINFO { + hAdapter: D3DKMT_HANDLE, + Type: KMTQUERYADAPTERINFOTYPE, + pPrivateDriverData: *mut VOID, + PrivateDriverDataSize: UINT, +}} +STRUCT!{struct D3DKMT_OPENADAPTERFROMHDC { + hDc: HDC, + hAdapter: D3DKMT_HANDLE, + AdapterLuid: LUID, + VidPnSourceId: D3DDDI_VIDEO_PRESENT_SOURCE_ID, +}} +STRUCT!{struct D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME { + DeviceName: [WCHAR; 32], + hAdapter: D3DKMT_HANDLE, + AdapterLuid: LUID, + VidPnSourceId: D3DDDI_VIDEO_PRESENT_SOURCE_ID, +}} +STRUCT!{struct D3DKMT_OPENADAPTERFROMDEVICENAME { + pDeviceName: PCWSTR, + hAdapter: D3DKMT_HANDLE, + AdapterLuid: LUID, +}} +pub const MAX_ENUM_ADAPTERS: usize = 16; +STRUCT!{struct D3DKMT_ADAPTERINFO { + hAdapter: D3DKMT_HANDLE, + AdapterLuid: LUID, + NumOfSources: ULONG, + bPresentMoveRegionsPreferred: BOOL, +}} +STRUCT!{struct D3DKMT_ENUMADAPTERS { + NumAdapters: ULONG, + Adapters: [D3DKMT_ADAPTERINFO; MAX_ENUM_ADAPTERS], +}} +STRUCT!{struct D3DKMT_ENUMADAPTERS2 { + NumAdapters: ULONG, + pAdapters: *mut D3DKMT_ADAPTERINFO, +}} +STRUCT!{struct D3DKMT_OPENADAPTERFROMLUID { + AdapterLuid: LUID, + hAdapter: D3DKMT_HANDLE, +}} +STRUCT!{struct D3DKMT_QUERYREMOTEVIDPNSOURCEFROMGDIDISPLAYNAME { + DeviceName: [WCHAR; 32], + VidPnSourceId: D3DDDI_VIDEO_PRESENT_SOURCE_ID, +}} +STRUCT!{struct D3DKMT_CLOSEADAPTER { + hAdapter: D3DKMT_HANDLE, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/km/mod.rs b/third_party/cargo/vendor/winapi-0.3.8/src/km/mod.rs new file mode 100644 index 0000000..480f195 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/km/mod.rs @@ -0,0 +1,7 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Headers for kernel mode +#[cfg(feature = "d3dkmthk")] pub mod d3dkmthk; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/lib.rs b/third_party/cargo/vendor/winapi-0.3.8/src/lib.rs new file mode 100644 index 0000000..5dc8fb4 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/lib.rs @@ -0,0 +1,70 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +#![cfg(windows)] +#![deny(unused, unused_qualifications)] +#![warn(unused_attributes)] +#![allow(bad_style, overflowing_literals, unused_macros)] +#![recursion_limit = "2563"] +#![no_std] +//Uncomment as needed or once minimum Rust version is bumped to 1.18 +//#![cfg_attr(feature = "cargo-clippy", warn(clippy::pedantic))] +//#![cfg_attr(feature = "cargo-clippy", allow(clippy::absurd_extreme_comparisons, clippy::cast_lossless, clippy::cast_possible_truncation, clippy::cast_possible_wrap, clippy::cast_precision_loss, clippy::cast_ptr_alignment, clippy::cast_sign_loss, clippy::const_static_lifetime, clippy::doc_markdown, clippy::empty_enum, clippy::erasing_op, clippy::excessive_precision, clippy::expl_impl_clone_on_copy, clippy::identity_op, clippy::if_not_else, clippy::many_single_char_names, clippy::module_inception, clippy::cast_possible_truncation, clippy::too_many_arguments, clippy::transmute_int_to_float, clippy::trivially_copy_pass_by_ref, clippy::unreadable_literal, clippy::unseparated_literal_suffix, clippy::used_underscore_binding))] + +#[cfg(feature = "std")] +extern crate std; + +/// Hack for exported macros +#[doc(hidden)] +pub extern crate core as _core; + +// Modules +#[macro_use] +mod macros; +pub mod km; +pub mod shared; +pub mod um; +pub mod vc; +pub mod winrt; + +/// Built in primitive types provided by the C language +pub mod ctypes { + #[cfg(feature = "std")] + pub use std::os::raw::c_void; + #[cfg(not(feature = "std"))] + pub enum c_void {} + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type __int8 = i8; + pub type __uint8 = u8; + pub type __int16 = i16; + pub type __uint16 = u16; + pub type __int32 = i32; + pub type __uint32 = u32; + pub type __int64 = i64; + pub type __uint64 = u64; + pub type wchar_t = u16; +} +// This trait should be implemented for all COM interfaces +pub trait Interface { + // Returns the IID of the Interface + fn uuidof() -> shared::guiddef::GUID; +} +// This trait should be implemented for all COM classes +pub trait Class { + // Returns the CLSID of the Class + fn uuidof() -> shared::guiddef::GUID; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/macros.rs b/third_party/cargo/vendor/winapi-0.3.8/src/macros.rs new file mode 100644 index 0000000..d6b133f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/macros.rs @@ -0,0 +1,440 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Macros to make things easier to define +macro_rules! DECLARE_HANDLE { + ($name:ident, $inner:ident) => { + pub enum $inner {} + pub type $name = *mut $inner; + }; +} +macro_rules! MAKE_HRESULT { + ($sev:expr, $fac:expr, $code:expr) => { + ($sev << 31) | ($fac << 16) | $code + } +} +macro_rules! MAKE_SCODE { + ($sev:expr, $fac:expr, $code:expr) => { + ($sev << 31) | ($fac << 16) | $code + } +} +macro_rules! HIDP_ERROR_CODES { + ($sev:expr, $code:expr) => { + ($sev << 28) | (FACILITY_HID_ERROR_CODE << 16) | $code + } +} +macro_rules! MAKEFOURCC { + ($a:expr, $b:expr, $c:expr, $d:expr) => { + ($a as u32) | (($b as u32) << 8) | (($c as u32) << 16) | (($d as u32) << 24) + } +} +#[macro_export] +macro_rules! DEFINE_GUID { + ( + $name:ident, $l:expr, $w1:expr, $w2:expr, + $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr + ) => { + pub const $name: $crate::shared::guiddef::GUID = $crate::shared::guiddef::GUID { + Data1: $l, + Data2: $w1, + Data3: $w2, + Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + }; + } +} +macro_rules! DEFINE_BLUETOOTH_UUID128 { + ($name:ident, $shortId:expr) => { + DEFINE_GUID!{$name, + $shortId as u32, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB} + } +} +#[macro_export] +macro_rules! DEFINE_PROPERTYKEY { + ( + $name:ident, $l:expr, $w1:expr, $w2:expr, + $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr, + $pid:expr + ) => { + pub const $name: PROPERTYKEY + = PROPERTYKEY { + fmtid: $crate::shared::guiddef::GUID { + Data1: $l, + Data2: $w1, + Data3: $w2, + Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + }, + pid: $pid, + }; + } +} +#[macro_export] +macro_rules! DEFINE_DEVPROPKEY { + ( + $name:ident, $l:expr, $w1:expr, $w2:expr, + $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr, + $pid:expr + ) => { + pub const $name: DEVPROPKEY = DEVPROPKEY { + fmtid: $crate::shared::guiddef::GUID { + Data1: $l, + Data2: $w1, + Data3: $w2, + Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + }, + pid: $pid, + }; + } +} +macro_rules! CTL_CODE { + ($DeviceType:expr, $Function:expr, $Method:expr, $Access:expr) => { + ($DeviceType << 16) | ($Access << 14) | ($Function << 2) | $Method + } +} +macro_rules! BTH_CTL { + ($id:expr) => { + CTL_CODE!(FILE_DEVICE_BLUETOOTH, $id, METHOD_BUFFERED, FILE_ANY_ACCESS) + }; +} +macro_rules! BTH_KERNEL_CTL { + ($id:expr) => { + CTL_CODE!(FILE_DEVICE_BLUETOOTH, $id, METHOD_NEITHER, FILE_ANY_ACCESS) + }; +} +macro_rules! HID_CTL_CODE { + ($id:expr) => { + CTL_CODE!(FILE_DEVICE_KEYBOARD, $id, METHOD_NEITHER, FILE_ANY_ACCESS) + } +} +macro_rules! HID_BUFFER_CTL_CODE { + ($id:expr) => { + CTL_CODE!(FILE_DEVICE_KEYBOARD, $id, METHOD_BUFFERED, FILE_ANY_ACCESS) + } +} +macro_rules! HID_IN_CTL_CODE { + ($id:expr) => { + CTL_CODE!(FILE_DEVICE_KEYBOARD, $id, METHOD_IN_DIRECT, FILE_ANY_ACCESS) + } +} +macro_rules! HID_OUT_CTL_CODE { + ($id:expr) => { + CTL_CODE!(FILE_DEVICE_KEYBOARD, $id, METHOD_OUT_DIRECT, FILE_ANY_ACCESS) + } +} +macro_rules! AUDCLNT_ERR { + ($n:expr) => { + MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_AUDCLNT, $n) + }; +} +macro_rules! AUDCLNT_SUCCESS { + ($n:expr) => { + MAKE_SCODE!(SEVERITY_SUCCESS, FACILITY_AUDCLNT, $n) + }; +} +macro_rules! BCRYPT_MAKE_INTERFACE_VERSION { + ($major:expr, $minor:expr) => { + $crate::shared::bcrypt::BCRYPT_INTERFACE_VERSION { + MajorVersion: $major, MinorVersion: $minor, + } + } +} +macro_rules! MAKEINTRESOURCE { + ($i:expr) => { $i as u16 as usize as LPWSTR } +} +#[macro_export] +macro_rules! RIDL { + (#[uuid($l:expr, $w1:expr, $w2:expr, + $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr)] + class $class:ident;) => ( + pub enum $class {} + impl $crate::Class for $class { + #[inline] + fn uuidof() -> $crate::shared::guiddef::GUID { + $crate::shared::guiddef::GUID { + Data1: $l, + Data2: $w1, + Data3: $w2, + Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + } + } + } + ); + (#[uuid($($uuid:expr),+)] + interface $interface:ident ($vtbl:ident) {$( + $(#[$($attrs:tt)*])* fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, + )+}) => ( + RIDL!{@vtbl $interface $vtbl () $( + $(#[$($attrs)*])* fn $method($($p: $t,)*) -> $rtr, + )+} + #[repr(C)] + pub struct $interface { + pub lpVtbl: *const $vtbl, + } + impl $interface { + $(RIDL!{@method $(#[$($attrs)*])* fn $method($($p: $t,)*) -> $rtr})+ + } + RIDL!{@uuid $interface $($uuid),+} + ); + (#[uuid($($uuid:expr),+)] + interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) {}) => ( + RIDL!{@vtbl $interface $vtbl (pub parent: $pvtbl,)} + #[repr(C)] + pub struct $interface { + pub lpVtbl: *const $vtbl, + } + RIDL!{@deref $interface $pinterface} + RIDL!{@uuid $interface $($uuid),+} + ); + (#[uuid($($uuid:expr),+)] + interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) {$( + $(#[$($attrs:tt)*])* fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, + )+}) => ( + RIDL!{@vtbl $interface $vtbl (pub parent: $pvtbl,) $( + $(#[$($attrs)*])* fn $method($($p: $t,)*) -> $rtr, + )+} + #[repr(C)] + pub struct $interface { + pub lpVtbl: *const $vtbl, + } + impl $interface { + $(RIDL!{@method $(#[$($attrs)*])* fn $method($($p: $t,)*) -> $rtr})+ + } + RIDL!{@deref $interface $pinterface} + RIDL!{@uuid $interface $($uuid),+} + ); + (@deref $interface:ident $pinterface:ident) => ( + impl $crate::_core::ops::Deref for $interface { + type Target = $pinterface; + #[inline] + fn deref(&self) -> &$pinterface { + unsafe { &*(self as *const $interface as *const $pinterface) } + } + } + ); + (@method fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty) => ( + #[inline] pub unsafe fn $method(&self, $($p: $t,)*) -> $rtr { + ((*self.lpVtbl).$method)(self as *const _ as *mut _, $($p,)*) + } + ); + (@method #[fixme] fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty) => ( + #[inline] pub unsafe fn $method(&self, $($p: $t,)*) -> $rtr { + let mut ret = $crate::_core::mem::uninitialized(); + ((*self.lpVtbl).$method)(self as *const _ as *mut _, &mut ret, $($p,)*); + ret + } + ); + (@vtbl $interface:ident $vtbl:ident ($($fields:tt)*) + $(fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty,)* + ) => ( + RIDL!{@item #[repr(C)] + pub struct $vtbl { + $($fields)* + $(pub $method: unsafe extern "system" fn( + This: *mut $interface, + $($p: $t,)* + ) -> $rtr,)* + }} + ); + (@vtbl $interface:ident $vtbl:ident ($($fields:tt)*) + fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, + $($tail:tt)*) => ( + RIDL!{@vtbl $interface $vtbl ( + $($fields)* + pub $method: unsafe extern "system" fn( + This: *mut $interface, + $($p: $t,)* + ) -> $rtr, + ) $($tail)*} + ); + (@vtbl $interface:ident $vtbl:ident ($($fields:tt)*) + #[fixme] fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, + $($tail:tt)*) => ( + RIDL!{@vtbl $interface $vtbl ( + $($fields)* + pub $method: unsafe extern "system" fn( + This: *mut $interface, + ret: *mut $rtr, + $($p: $t,)* + ) -> *mut $rtr, + ) $($tail)*} + ); + (@uuid $interface:ident + $l:expr, $w1:expr, $w2:expr, + $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr + ) => ( + impl $crate::Interface for $interface { + #[inline] + fn uuidof() -> $crate::shared::guiddef::GUID { + $crate::shared::guiddef::GUID { + Data1: $l, + Data2: $w1, + Data3: $w2, + Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + } + } + } + ); + (@item $thing:item) => ($thing); +} +macro_rules! UNION { + ($(#[$attrs:meta])* union $name:ident { + [$stype:ty; $ssize:expr], + $($variant:ident $variant_mut:ident: $ftype:ty,)+ + }) => ( + #[repr(C)] $(#[$attrs])* + pub struct $name([$stype; $ssize]); + impl Copy for $name {} + impl Clone for $name { + #[inline] + fn clone(&self) -> $name { *self } + } + #[cfg(feature = "impl-default")] + impl Default for $name { + #[inline] + fn default() -> $name { unsafe { $crate::_core::mem::zeroed() } } + } + impl $name {$( + #[inline] + pub unsafe fn $variant(&self) -> &$ftype { + &*(self as *const _ as *const $ftype) + } + #[inline] + pub unsafe fn $variant_mut(&mut self) -> &mut $ftype { + &mut *(self as *mut _ as *mut $ftype) + } + )+} + ); + ($(#[$attrs:meta])* union $name:ident { + [$stype32:ty; $ssize32:expr] [$stype64:ty; $ssize64:expr], + $($variant:ident $variant_mut:ident: $ftype:ty,)+ + }) => ( + #[repr(C)] $(#[$attrs])* #[cfg(target_pointer_width = "32")] + pub struct $name([$stype32; $ssize32]); + #[repr(C)] $(#[$attrs])* #[cfg(target_pointer_width = "64")] + pub struct $name([$stype64; $ssize64]); + impl Copy for $name {} + impl Clone for $name { + #[inline] + fn clone(&self) -> $name { *self } + } + #[cfg(feature = "impl-default")] + impl Default for $name { + #[inline] + fn default() -> $name { unsafe { $crate::_core::mem::zeroed() } } + } + impl $name {$( + #[inline] + pub unsafe fn $variant(&self) -> &$ftype { + &*(self as *const _ as *const $ftype) + } + #[inline] + pub unsafe fn $variant_mut(&mut self) -> &mut $ftype { + &mut *(self as *mut _ as *mut $ftype) + } + )+} + ); +} +macro_rules! BITFIELD { + ($base:ident $field:ident: $fieldtype:ty [ + $($thing:ident $set_thing:ident[$r:expr],)+ + ]) => { + impl $base {$( + #[inline] + pub fn $thing(&self) -> $fieldtype { + let size = $crate::core::mem::size_of::<$fieldtype>() * 8; + self.$field << (size - $r.end) >> (size - $r.end + $r.start) + } + #[inline] + pub fn $set_thing(&mut self, val: $fieldtype) { + let mask = ((1 << ($r.end - $r.start)) - 1) << $r.start; + self.$field &= !mask; + self.$field |= (val << $r.start) & mask; + } + )+} + } +} +#[macro_export] +macro_rules! ENUM { + {enum $name:ident { $($variant:ident = $value:expr,)+ }} => { + pub type $name = u32; + $(pub const $variant: $name = $value;)+ + }; + {enum $name:ident { $variant:ident = $value:expr, $($rest:tt)* }} => { + pub type $name = u32; + pub const $variant: $name = $value; + ENUM!{@gen $name $variant, $($rest)*} + }; + {enum $name:ident { $variant:ident, $($rest:tt)* }} => { + ENUM!{enum $name { $variant = 0, $($rest)* }} + }; + {@gen $name:ident $base:ident,} => {}; + {@gen $name:ident $base:ident, $variant:ident = $value:expr, $($rest:tt)*} => { + pub const $variant: $name = $value; + ENUM!{@gen $name $variant, $($rest)*} + }; + {@gen $name:ident $base:ident, $variant:ident, $($rest:tt)*} => { + pub const $variant: $name = $base + 1u32; + ENUM!{@gen $name $variant, $($rest)*} + }; +} +#[macro_export] +macro_rules! STRUCT { + (#[debug] $($rest:tt)*) => ( + STRUCT!{#[cfg_attr(feature = "impl-debug", derive(Debug))] $($rest)*} + ); + ($(#[$attrs:meta])* struct $name:ident { + $($field:ident: $ftype:ty,)+ + }) => ( + #[repr(C)] #[derive(Copy)] $(#[$attrs])* + pub struct $name { + $(pub $field: $ftype,)+ + } + impl Clone for $name { + #[inline] + fn clone(&self) -> $name { *self } + } + #[cfg(feature = "impl-default")] + impl Default for $name { + #[inline] + fn default() -> $name { unsafe { $crate::_core::mem::zeroed() } } + } + ); +} +macro_rules! IFDEF { + ($($thing:item)*) => ($($thing)*) +} +macro_rules! FN { + (stdcall $func:ident($($t:ty,)*) -> $ret:ty) => ( + pub type $func = Option<unsafe extern "system" fn($($t,)*) -> $ret>; + ); + (stdcall $func:ident($($p:ident: $t:ty,)*) -> $ret:ty) => ( + pub type $func = Option<unsafe extern "system" fn($($p: $t,)*) -> $ret>; + ); + (cdecl $func:ident($($t:ty,)*) -> $ret:ty) => ( + pub type $func = Option<unsafe extern "C" fn($($t,)*) -> $ret>; + ); + (cdecl $func:ident($($p:ident: $t:ty,)*) -> $ret:ty) => ( + pub type $func = Option<unsafe extern "C" fn($($p: $t,)*) -> $ret>; + ); +} +macro_rules! _WSAIO { + ($x:expr, $y:expr) => { + $crate::shared::ws2def::IOC_VOID | $x | $y + } +} +macro_rules! _WSAIOR { + ($x:expr, $y:expr) => { + $crate::shared::ws2def::IOC_OUT | $x | $y + } +} +macro_rules! _WSAIOW { + ($x:expr, $y:expr) => { + $crate::shared::ws2def::IOC_IN | $x | $y + } +} +macro_rules! _WSAIORW { + ($x:expr, $y:expr) => { + $crate::shared::ws2def::IOC_INOUT | $x | $y + } +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/basetsd.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/basetsd.rs new file mode 100644 index 0000000..b3b7123 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/basetsd.rs @@ -0,0 +1,70 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Type definitions for the basic sized types. +use ctypes::{__int64, __uint64, c_int, c_schar, c_short, c_uchar, c_uint, c_ushort}; +pub type POINTER_64_INT = usize; +pub type INT8 = c_schar; +pub type PINT8 = *mut c_schar; +pub type INT16 = c_short; +pub type PINT16 = *mut c_short; +pub type INT32 = c_int; +pub type PINT32 = *mut c_int; +pub type INT64 = __int64; +pub type PINT64 = *mut __int64; +pub type UINT8 = c_uchar; +pub type PUINT8 = *mut c_uchar; +pub type UINT16 = c_ushort; +pub type PUINT16 = *mut c_ushort; +pub type UINT32 = c_uint; +pub type PUINT32 = *mut c_uint; +pub type UINT64 = __uint64; +pub type PUINT64 = *mut __uint64; +pub type LONG32 = c_int; +pub type PLONG32 = *mut c_int; +pub type ULONG32 = c_uint; +pub type PULONG32 = *mut c_uint; +pub type DWORD32 = c_uint; +pub type PDWORD32 = *mut c_uint; +pub type INT_PTR = isize; +pub type PINT_PTR = *mut isize; +pub type UINT_PTR = usize; +pub type PUINT_PTR = *mut usize; +pub type LONG_PTR = isize; +pub type PLONG_PTR = *mut isize; +pub type ULONG_PTR = usize; +pub type PULONG_PTR = *mut usize; +pub type SHANDLE_PTR = isize; +pub type HANDLE_PTR = usize; +#[cfg(target_pointer_width = "32")] +pub type UHALF_PTR = c_ushort; +#[cfg(target_pointer_width = "64")] +pub type UHALF_PTR = c_uint; +#[cfg(target_pointer_width = "32")] +pub type PUHALF_PTR = *mut c_ushort; +#[cfg(target_pointer_width = "64")] +pub type PUHALF_PTR = *mut c_uint; +#[cfg(target_pointer_width = "32")] +pub type HALF_PTR = c_short; +#[cfg(target_pointer_width = "64")] +pub type HALF_PTR = c_int; +#[cfg(target_pointer_width = "32")] +pub type PHALF_PTR = *mut c_short; +#[cfg(target_pointer_width = "64")] +pub type PHALF_PTR = *mut c_int; +pub type SIZE_T = ULONG_PTR; +pub type PSIZE_T = *mut ULONG_PTR; +pub type SSIZE_T = LONG_PTR; +pub type PSSIZE_T = *mut LONG_PTR; +pub type DWORD_PTR = ULONG_PTR; +pub type PDWORD_PTR = *mut ULONG_PTR; +pub type LONG64 = __int64; +pub type PLONG64 = *mut __int64; +pub type ULONG64 = __uint64; +pub type PULONG64 = *mut __uint64; +pub type DWORD64 = __uint64; +pub type PDWORD64 = *mut __uint64; +pub type KAFFINITY = ULONG_PTR; +pub type PKAFFINITY = *mut KAFFINITY; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/bcrypt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/bcrypt.rs new file mode 100644 index 0000000..4fa88ef --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/bcrypt.rs @@ -0,0 +1,1001 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Cryptographic Primitive API Prototypes and Definitions +use shared::minwindef::{PUCHAR, UCHAR, ULONG, USHORT}; +use um::winnt::{BOOLEAN, HANDLE, LONG, LPCWSTR, LPWSTR, PVOID, PWSTR, ULONGLONG, VOID}; +pub type NTSTATUS = LONG; +pub type PNTSTATUS = *mut NTSTATUS; +#[inline] +pub fn BCRYPT_SUCCESS(Status: NTSTATUS) -> bool { + Status >= 0 +} +pub const BCRYPT_OBJECT_ALIGNMENT: usize = 16; +pub const BCRYPT_KDF_HASH: &'static str = "HASH"; +pub const BCRYPT_KDF_HMAC: &'static str = "HMAC"; +pub const BCRYPT_KDF_TLS_PRF: &'static str = "TLS_PRF"; +pub const BCRYPT_KDF_SP80056A_CONCAT: &'static str = "SP800_56A_CONCAT"; +pub const BCRYPT_KDF_RAW_SECRET: &'static str = "TRUNCATE"; +pub const KDF_HASH_ALGORITHM: ULONG = 0x0; +pub const KDF_SECRET_PREPEND: ULONG = 0x1; +pub const KDF_SECRET_APPEND: ULONG = 0x2; +pub const KDF_HMAC_KEY: ULONG = 0x3; +pub const KDF_TLS_PRF_LABEL: ULONG = 0x4; +pub const KDF_TLS_PRF_SEED: ULONG = 0x5; +pub const KDF_SECRET_HANDLE: ULONG = 0x6; +pub const KDF_TLS_PRF_PROTOCOL: ULONG = 0x7; +pub const KDF_ALGORITHMID: ULONG = 0x8; +pub const KDF_PARTYUINFO: ULONG = 0x9; +pub const KDF_PARTYVINFO: ULONG = 0xA; +pub const KDF_SUPPPUBINFO: ULONG = 0xB; +pub const KDF_SUPPPRIVINFO: ULONG = 0xC; +pub const KDF_LABEL: ULONG = 0xD; +pub const KDF_CONTEXT: ULONG = 0xE; +pub const KDF_SALT: ULONG = 0xF; +pub const KDF_ITERATION_COUNT: ULONG = 0x10; +pub const KDF_GENERIC_PARAMETER: ULONG = 0x11; +pub const KDF_KEYBITLENGTH: ULONG = 0x12; +pub const KDF_USE_SECRET_AS_HMAC_KEY_FLAG: ULONG = 0x1; +STRUCT!{struct BCRYPT_KEY_LENGTHS_STRUCT { + dwMinLength: ULONG, + dwMaxLength: ULONG, + dwIncrement: ULONG, +}} +pub type BCRYPT_AUTH_TAG_LENGTHS_STRUCT = BCRYPT_KEY_LENGTHS_STRUCT; +STRUCT!{struct BCRYPT_OID { + cbOID: ULONG, + pbOID: PUCHAR, +}} +STRUCT!{struct BCRYPT_OID_LIST { + dwOIDCount: ULONG, + pOIDs: *mut BCRYPT_OID, +}} +STRUCT!{struct BCRYPT_PKCS1_PADDING_INFO { + pszAlgId: LPCWSTR, +}} +STRUCT!{struct BCRYPT_PSS_PADDING_INFO { + pszAlgId: LPCWSTR, + cbSalt: ULONG, +}} +STRUCT!{struct BCRYPT_OAEP_PADDING_INFO { + pszAlgId: LPCWSTR, + pbLabel: PUCHAR, + cbLabel: ULONG, +}} +pub const BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION: ULONG = 1; +pub const BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG: ULONG = 0x00000001; +pub const BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG: ULONG = 0x00000002; +STRUCT!{struct BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO { + cbSize: ULONG, + dwInfoVersion: ULONG, + pbNonce: PUCHAR, + cbNonce: ULONG, + pbAuthData: PUCHAR, + cbAuthData: ULONG, + pbTag: PUCHAR, + cbTag: ULONG, + pbMacContext: PUCHAR, + cbMacContext: ULONG, + cbAAD: ULONG, + cbData: ULONGLONG, + dwFlags: ULONG, +}} +pub type PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO = *mut BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO; +pub const BCRYPT_OPAQUE_KEY_BLOB: &'static str = "OpaqueKeyBlob"; +pub const BCRYPT_KEY_DATA_BLOB: &'static str = "KeyDataBlob"; +pub const BCRYPT_AES_WRAP_KEY_BLOB: &'static str = "Rfc3565KeyWrapBlob"; +pub const BCRYPT_OBJECT_LENGTH: &'static str = "ObjectLength"; +pub const BCRYPT_ALGORITHM_NAME: &'static str = "AlgorithmName"; +pub const BCRYPT_PROVIDER_HANDLE: &'static str = "ProviderHandle"; +pub const BCRYPT_CHAINING_MODE: &'static str = "ChainingMode"; +pub const BCRYPT_BLOCK_LENGTH: &'static str = "BlockLength"; +pub const BCRYPT_KEY_LENGTH: &'static str = "KeyLength"; +pub const BCRYPT_KEY_OBJECT_LENGTH: &'static str = "KeyObjectLength"; +pub const BCRYPT_KEY_STRENGTH: &'static str = "KeyStrength"; +pub const BCRYPT_KEY_LENGTHS: &'static str = "KeyLengths"; +pub const BCRYPT_BLOCK_SIZE_LIST: &'static str = "BlockSizeList"; +pub const BCRYPT_EFFECTIVE_KEY_LENGTH: &'static str = "EffectiveKeyLength"; +pub const BCRYPT_HASH_LENGTH: &'static str = "HashDigestLength"; +pub const BCRYPT_HASH_OID_LIST: &'static str = "HashOIDList"; +pub const BCRYPT_PADDING_SCHEMES: &'static str = "PaddingSchemes"; +pub const BCRYPT_SIGNATURE_LENGTH: &'static str = "SignatureLength"; +pub const BCRYPT_HASH_BLOCK_LENGTH: &'static str = "HashBlockLength"; +pub const BCRYPT_AUTH_TAG_LENGTH: &'static str = "AuthTagLength"; +pub const BCRYPT_PRIMITIVE_TYPE: &'static str = "PrimitiveType"; +pub const BCRYPT_IS_KEYED_HASH: &'static str = "IsKeyedHash"; +pub const BCRYPT_IS_REUSABLE_HASH: &'static str = "IsReusableHash"; +pub const BCRYPT_MESSAGE_BLOCK_LENGTH: &'static str = "MessageBlockLength"; +pub const BCRYPT_PUBLIC_KEY_LENGTH: &'static str = "PublicKeyLength"; +pub const BCRYPT_PCP_PLATFORM_TYPE_PROPERTY: &'static str = "PCP_PLATFORM_TYPE"; +pub const BCRYPT_PCP_PROVIDER_VERSION_PROPERTY: &'static str = "PCP_PROVIDER_VERSION"; +pub const BCRYPT_MULTI_OBJECT_LENGTH: &'static str = "MultiObjectLength"; +pub const BCRYPT_INITIALIZATION_VECTOR: &'static str = "IV"; +pub const BCRYPT_CHAIN_MODE_NA: &'static str = "ChainingModeN/A"; +pub const BCRYPT_CHAIN_MODE_CBC: &'static str = "ChainingModeCBC"; +pub const BCRYPT_CHAIN_MODE_ECB: &'static str = "ChainingModeECB"; +pub const BCRYPT_CHAIN_MODE_CFB: &'static str = "ChainingModeCFB"; +pub const BCRYPT_CHAIN_MODE_CCM: &'static str = "ChainingModeCCM"; +pub const BCRYPT_CHAIN_MODE_GCM: &'static str = "ChainingModeGCM"; +pub const BCRYPT_PROV_DISPATCH: ULONG = 0x00000001; +pub const BCRYPT_BLOCK_PADDING: ULONG = 0x00000001; +pub const BCRYPT_PAD_NONE: ULONG = 0x00000001; +pub const BCRYPT_PAD_PKCS1: ULONG = 0x00000002; +pub const BCRYPT_PAD_OAEP: ULONG = 0x00000004; +pub const BCRYPT_PAD_PSS: ULONG = 0x00000008; +pub const BCRYPT_PAD_PKCS1_OPTIONAL_HASH_OID: ULONG = 0x00000010; +pub const BCRYPTBUFFER_VERSION: ULONG = 0; +STRUCT!{struct BCryptBuffer { + cbBuffer: ULONG, + BufferType: ULONG, + pvBuffer: PVOID, +}} +pub type PBCryptBuffer = *mut BCryptBuffer; +STRUCT!{struct BCryptBufferDesc { + ulVersion: ULONG, + cBuffers: ULONG, + pBuffers: PBCryptBuffer, +}} +pub type PBCryptBufferDesc = *mut BCryptBufferDesc; +pub type BCRYPT_HANDLE = PVOID; +pub type BCRYPT_ALG_HANDLE = PVOID; +pub type BCRYPT_KEY_HANDLE = PVOID; +pub type BCRYPT_HASH_HANDLE = PVOID; +pub type BCRYPT_SECRET_HANDLE = PVOID; +pub const BCRYPT_PUBLIC_KEY_BLOB: &'static str = "PUBLICBLOB"; +pub const BCRYPT_PRIVATE_KEY_BLOB: &'static str = "PRIVATEBLOB"; +STRUCT!{struct BCRYPT_KEY_BLOB { + Magic: ULONG, +}} +pub const BCRYPT_RSAPUBLIC_BLOB: &'static str = "RSAPUBLICBLOB"; +pub const BCRYPT_RSAPRIVATE_BLOB: &'static str = "RSAPRIVATEBLOB"; +pub const LEGACY_RSAPUBLIC_BLOB: &'static str = "CAPIPUBLICBLOB"; +pub const LEGACY_RSAPRIVATE_BLOB: &'static str = "CAPIPRIVATEBLOB"; +pub const BCRYPT_RSAPUBLIC_MAGIC: ULONG = 0x31415352; +pub const BCRYPT_RSAPRIVATE_MAGIC: ULONG = 0x32415352; +STRUCT!{struct BCRYPT_RSAKEY_BLOB { + Magic: ULONG, + BitLength: ULONG, + cbPublicExp: ULONG, + cbModulus: ULONG, + cbPrime1: ULONG, + cbPrime2: ULONG, +}} +pub const BCRYPT_RSAFULLPRIVATE_BLOB: &'static str = "RSAFULLPRIVATEBLOB"; +pub const BCRYPT_RSAFULLPRIVATE_MAGIC: ULONG = 0x33415352; +pub const BCRYPT_GLOBAL_PARAMETERS: &'static str = "SecretAgreementParam"; +pub const BCRYPT_PRIVATE_KEY: &'static str = "PrivKeyVal"; +pub const BCRYPT_ECCPUBLIC_BLOB: &'static str = "ECCPUBLICBLOB"; +pub const BCRYPT_ECCPRIVATE_BLOB: &'static str = "ECCPRIVATEBLOB"; +pub const BCRYPT_ECCFULLPUBLIC_BLOB: &'static str = "ECCFULLPUBLICBLOB"; +pub const BCRYPT_ECCFULLPRIVATE_BLOB: &'static str = "ECCFULLPRIVATEBLOB"; +pub const SSL_ECCPUBLIC_BLOB: &'static str = "SSLECCPUBLICBLOB"; +pub const BCRYPT_ECDH_PUBLIC_P256_MAGIC: ULONG = 0x314B4345; +pub const BCRYPT_ECDH_PRIVATE_P256_MAGIC: ULONG = 0x324B4345; +pub const BCRYPT_ECDH_PUBLIC_P384_MAGIC: ULONG = 0x334B4345; +pub const BCRYPT_ECDH_PRIVATE_P384_MAGIC: ULONG = 0x344B4345; +pub const BCRYPT_ECDH_PUBLIC_P521_MAGIC: ULONG = 0x354B4345; +pub const BCRYPT_ECDH_PRIVATE_P521_MAGIC: ULONG = 0x364B4345; +pub const BCRYPT_ECDH_PUBLIC_GENERIC_MAGIC: ULONG = 0x504B4345; +pub const BCRYPT_ECDH_PRIVATE_GENERIC_MAGIC: ULONG = 0x564B4345; +pub const BCRYPT_ECDSA_PUBLIC_P256_MAGIC: ULONG = 0x31534345; +pub const BCRYPT_ECDSA_PRIVATE_P256_MAGIC: ULONG = 0x32534345; +pub const BCRYPT_ECDSA_PUBLIC_P384_MAGIC: ULONG = 0x33534345; +pub const BCRYPT_ECDSA_PRIVATE_P384_MAGIC: ULONG = 0x34534345; +pub const BCRYPT_ECDSA_PUBLIC_P521_MAGIC: ULONG = 0x35534345; +pub const BCRYPT_ECDSA_PRIVATE_P521_MAGIC: ULONG = 0x36534345; +pub const BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC: ULONG = 0x50444345; +pub const BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC: ULONG = 0x56444345; +STRUCT!{struct BCRYPT_ECCKEY_BLOB { + dwMagic: ULONG, + cbKey: ULONG, +}} +pub type PBCRYPT_ECCKEY_BLOB = *mut BCRYPT_ECCKEY_BLOB; +STRUCT!{struct SSL_ECCKEY_BLOB { + dwCurveType: ULONG, + cbKey: ULONG, +}} +pub type PSSL_ECCKEY_BLOB = *mut SSL_ECCKEY_BLOB; +pub const BCRYPT_ECC_FULLKEY_BLOB_V1: ULONG = 0x1; +ENUM!{enum ECC_CURVE_TYPE_ENUM { + BCRYPT_ECC_PRIME_SHORT_WEIERSTRASS_CURVE = 0x1, + BCRYPT_ECC_PRIME_TWISTED_EDWARDS_CURVE = 0x2, + BCRYPT_ECC_PRIME_MONTGOMERY_CURVE = 0x3, +}} +ENUM!{enum ECC_CURVE_ALG_ID_ENUM { + BCRYPT_NO_CURVE_GENERATION_ALG_ID = 0x0, +}} +STRUCT!{struct BCRYPT_ECCFULLKEY_BLOB { + dwMagic: ULONG, + dwVersion: ULONG, + dwCurveType: ECC_CURVE_TYPE_ENUM, + dwCurveGenerationAlgId: ECC_CURVE_ALG_ID_ENUM, + cbFieldLength: ULONG, + cbSubgroupOrder: ULONG, + cbCofactor: ULONG, + cbSeed: ULONG, +}} +pub type PBCRYPT_ECCFULLKEY_BLOB = *mut BCRYPT_ECCFULLKEY_BLOB; +pub const BCRYPT_DH_PUBLIC_BLOB: &'static str = "DHPUBLICBLOB"; +pub const BCRYPT_DH_PRIVATE_BLOB: &'static str = "DHPRIVATEBLOB"; +pub const LEGACY_DH_PUBLIC_BLOB: &'static str = "CAPIDHPUBLICBLOB"; +pub const LEGACY_DH_PRIVATE_BLOB: &'static str = "CAPIDHPRIVATEBLOB"; +pub const BCRYPT_DH_PUBLIC_MAGIC: ULONG = 0x42504844; +pub const BCRYPT_DH_PRIVATE_MAGIC: ULONG = 0x56504844; +STRUCT!{struct BCRYPT_DH_KEY_BLOB { + dwMagic: ULONG, + cbKey: ULONG, +}} +pub type PBCRYPT_DH_KEY_BLOB = *mut BCRYPT_DH_KEY_BLOB; +pub const BCRYPT_DH_PARAMETERS: &'static str = "DHParameters"; +pub const BCRYPT_DH_PARAMETERS_MAGIC: ULONG = 0x4d504844; +STRUCT!{struct BCRYPT_DH_PARAMETER_HEADER { + cbLength: ULONG, + dwMagic: ULONG, + cbKeyLength: ULONG, +}} +pub const BCRYPT_DSA_PUBLIC_BLOB: &'static str = "DSAPUBLICBLOB"; +pub const BCRYPT_DSA_PRIVATE_BLOB: &'static str = "DSAPRIVATEBLOB"; +pub const LEGACY_DSA_PUBLIC_BLOB: &'static str = "CAPIDSAPUBLICBLOB"; +pub const LEGACY_DSA_PRIVATE_BLOB: &'static str = "CAPIDSAPRIVATEBLOB"; +pub const LEGACY_DSA_V2_PUBLIC_BLOB: &'static str = "V2CAPIDSAPUBLICBLOB"; +pub const LEGACY_DSA_V2_PRIVATE_BLOB: &'static str = "V2CAPIDSAPRIVATEBLOB"; +pub const BCRYPT_DSA_PUBLIC_MAGIC: ULONG = 0x42505344; +pub const BCRYPT_DSA_PRIVATE_MAGIC: ULONG = 0x56505344; +pub const BCRYPT_DSA_PUBLIC_MAGIC_V2: ULONG = 0x32425044; +pub const BCRYPT_DSA_PRIVATE_MAGIC_V2: ULONG = 0x32565044; +STRUCT!{struct BCRYPT_DSA_KEY_BLOB { + dwMagic: ULONG, + cbKey: ULONG, + Count: [UCHAR; 4], + Seed: [UCHAR; 20], + q: [UCHAR; 20], +}} +pub type PBCRYPT_DSA_KEY_BLOB = *mut BCRYPT_DSA_KEY_BLOB; +ENUM!{enum HASHALGORITHM_ENUM { + DSA_HASH_ALGORITHM_SHA1, + DSA_HASH_ALGORITHM_SHA256, + DSA_HASH_ALGORITHM_SHA512, +}} +ENUM!{enum DSAFIPSVERSION_ENUM { + DSA_FIPS186_2, + DSA_FIPS186_3, +}} +STRUCT!{struct BCRYPT_DSA_KEY_BLOB_V2 { + dwMagic: ULONG, + cbKey: ULONG, + hashAlgorithm: HASHALGORITHM_ENUM, + standardVersion: DSAFIPSVERSION_ENUM, + cbSeedLength: ULONG, + cbGroupSize: ULONG, + Count: [UCHAR; 4], +}} +pub type PBCRYPT_DSA_KEY_BLOB_V2 = *mut BCRYPT_DSA_KEY_BLOB_V2; +STRUCT!{struct BCRYPT_KEY_DATA_BLOB_HEADER { + dwMagic: ULONG, + dwVersion: ULONG, + cbKeyData: ULONG, +}} +pub type PBCRYPT_KEY_DATA_BLOB_HEADER = *mut BCRYPT_KEY_DATA_BLOB_HEADER; +pub const BCRYPT_KEY_DATA_BLOB_MAGIC: ULONG = 0x4d42444b; +pub const BCRYPT_KEY_DATA_BLOB_VERSION1: ULONG = 0x1; +pub const BCRYPT_DSA_PARAMETERS: &'static str = "DSAParameters"; +pub const BCRYPT_DSA_PARAMETERS_MAGIC: ULONG = 0x4d505344; +pub const BCRYPT_DSA_PARAMETERS_MAGIC_V2: ULONG = 0x324d5044; +STRUCT!{struct BCRYPT_DSA_PARAMETER_HEADER { + cbLength: ULONG, + dwMagic: ULONG, + cbKeyLength: ULONG, + Count: [UCHAR; 4], + Seed: [UCHAR; 20], + q: [UCHAR; 20], +}} +STRUCT!{struct BCRYPT_DSA_PARAMETER_HEADER_V2 { + cbLength: ULONG, + dwMagic: ULONG, + cbKeyLength: ULONG, + hashAlgorithm: HASHALGORITHM_ENUM, + standardVersion: DSAFIPSVERSION_ENUM, + cbSeedLength: ULONG, + cbGroupSize: ULONG, + Count: [UCHAR; 4], +}} +pub const BCRYPT_ECC_PARAMETERS: &'static str = "ECCParameters"; +pub const BCRYPT_ECC_CURVE_NAME: &'static str = "ECCCurveName"; +pub const BCRYPT_ECC_CURVE_NAME_LIST: &'static str = "ECCCurveNameList"; +pub const BCRYPT_ECC_PARAMETERS_MAGIC: ULONG = 0x50434345; +STRUCT!{struct BCRYPT_ECC_CURVE_NAMES { + dwEccCurveNames: ULONG, + pEccCurveNames: LPWSTR, +}} +pub const BCRYPT_ECC_CURVE_BRAINPOOLP160R1: &'static str = "brainpoolP160r1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP160T1: &'static str = "brainpoolP160t1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP192R1: &'static str = "brainpoolP192r1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP192T1: &'static str = "brainpoolP192t1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP224R1: &'static str = "brainpoolP224r1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP224T1: &'static str = "brainpoolP224t1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP256R1: &'static str = "brainpoolP256r1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP256T1: &'static str = "brainpoolP256t1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP320R1: &'static str = "brainpoolP320r1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP320T1: &'static str = "brainpoolP320t1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP384R1: &'static str = "brainpoolP384r1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP384T1: &'static str = "brainpoolP384t1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP512R1: &'static str = "brainpoolP512r1"; +pub const BCRYPT_ECC_CURVE_BRAINPOOLP512T1: &'static str = "brainpoolP512t1"; +pub const BCRYPT_ECC_CURVE_25519: &'static str = "curve25519"; +pub const BCRYPT_ECC_CURVE_EC192WAPI: &'static str = "ec192wapi"; +pub const BCRYPT_ECC_CURVE_NISTP192: &'static str = "nistP192"; +pub const BCRYPT_ECC_CURVE_NISTP224: &'static str = "nistP224"; +pub const BCRYPT_ECC_CURVE_NISTP256: &'static str = "nistP256"; +pub const BCRYPT_ECC_CURVE_NISTP384: &'static str = "nistP384"; +pub const BCRYPT_ECC_CURVE_NISTP521: &'static str = "nistP521"; +pub const BCRYPT_ECC_CURVE_NUMSP256T1: &'static str = "numsP256t1"; +pub const BCRYPT_ECC_CURVE_NUMSP384T1: &'static str = "numsP384t1"; +pub const BCRYPT_ECC_CURVE_NUMSP512T1: &'static str = "numsP512t1"; +pub const BCRYPT_ECC_CURVE_SECP160K1: &'static str = "secP160k1"; +pub const BCRYPT_ECC_CURVE_SECP160R1: &'static str = "secP160r1"; +pub const BCRYPT_ECC_CURVE_SECP160R2: &'static str = "secP160r2"; +pub const BCRYPT_ECC_CURVE_SECP192K1: &'static str = "secP192k1"; +pub const BCRYPT_ECC_CURVE_SECP192R1: &'static str = "secP192r1"; +pub const BCRYPT_ECC_CURVE_SECP224K1: &'static str = "secP224k1"; +pub const BCRYPT_ECC_CURVE_SECP224R1: &'static str = "secP224r1"; +pub const BCRYPT_ECC_CURVE_SECP256K1: &'static str = "secP256k1"; +pub const BCRYPT_ECC_CURVE_SECP256R1: &'static str = "secP256r1"; +pub const BCRYPT_ECC_CURVE_SECP384R1: &'static str = "secP384r1"; +pub const BCRYPT_ECC_CURVE_SECP521R1: &'static str = "secP521r1"; +pub const BCRYPT_ECC_CURVE_WTLS7: &'static str = "wtls7"; +pub const BCRYPT_ECC_CURVE_WTLS9: &'static str = "wtls9"; +pub const BCRYPT_ECC_CURVE_WTLS12: &'static str = "wtls12"; +pub const BCRYPT_ECC_CURVE_X962P192V1: &'static str = "x962P192v1"; +pub const BCRYPT_ECC_CURVE_X962P192V2: &'static str = "x962P192v2"; +pub const BCRYPT_ECC_CURVE_X962P192V3: &'static str = "x962P192v3"; +pub const BCRYPT_ECC_CURVE_X962P239V1: &'static str = "x962P239v1"; +pub const BCRYPT_ECC_CURVE_X962P239V2: &'static str = "x962P239v2"; +pub const BCRYPT_ECC_CURVE_X962P239V3: &'static str = "x962P239v3"; +pub const BCRYPT_ECC_CURVE_X962P256V1: &'static str = "x962P256v1"; +ENUM!{enum BCRYPT_HASH_OPERATION_TYPE { + BCRYPT_HASH_OPERATION_HASH_DATA = 1, + BCRYPT_HASH_OPERATION_FINISH_HASH = 2, +}} +STRUCT!{struct BCRYPT_MULTI_HASH_OPERATION { + iHash: ULONG, + hashOperation: BCRYPT_HASH_OPERATION_TYPE, + pbBuffer: PUCHAR, + cbBuffer: ULONG, +}} +ENUM!{enum BCRYPT_MULTI_OPERATION_TYPE { + BCRYPT_OPERATION_TYPE_HASH = 1, +}} +STRUCT!{struct BCRYPT_MULTI_OBJECT_LENGTH_STRUCT { + cbPerObject: ULONG, + cbPerElement: ULONG, +}} +pub const MS_PRIMITIVE_PROVIDER: &'static str = "Microsoft Primitive Provider"; +pub const MS_PLATFORM_CRYPTO_PROVIDER: &'static str = "Microsoft Platform Crypto Provider"; +pub const BCRYPT_RSA_ALGORITHM: &'static str = "RSA"; +pub const BCRYPT_RSA_SIGN_ALGORITHM: &'static str = "RSA_SIGN"; +pub const BCRYPT_DH_ALGORITHM: &'static str = "DH"; +pub const BCRYPT_DSA_ALGORITHM: &'static str = "DSA"; +pub const BCRYPT_RC2_ALGORITHM: &'static str = "RC2"; +pub const BCRYPT_RC4_ALGORITHM: &'static str = "RC4"; +pub const BCRYPT_AES_ALGORITHM: &'static str = "AES"; +pub const BCRYPT_DES_ALGORITHM: &'static str = "DES"; +pub const BCRYPT_DESX_ALGORITHM: &'static str = "DESX"; +pub const BCRYPT_3DES_ALGORITHM: &'static str = "3DES"; +pub const BCRYPT_3DES_112_ALGORITHM: &'static str = "3DES_112"; +pub const BCRYPT_MD2_ALGORITHM: &'static str = "MD2"; +pub const BCRYPT_MD4_ALGORITHM: &'static str = "MD4"; +pub const BCRYPT_MD5_ALGORITHM: &'static str = "MD5"; +pub const BCRYPT_SHA1_ALGORITHM: &'static str = "SHA1"; +pub const BCRYPT_SHA256_ALGORITHM: &'static str = "SHA256"; +pub const BCRYPT_SHA384_ALGORITHM: &'static str = "SHA384"; +pub const BCRYPT_SHA512_ALGORITHM: &'static str = "SHA512"; +pub const BCRYPT_AES_GMAC_ALGORITHM: &'static str = "AES-GMAC"; +pub const BCRYPT_AES_CMAC_ALGORITHM: &'static str = "AES-CMAC"; +pub const BCRYPT_ECDSA_P256_ALGORITHM: &'static str = "ECDSA_P256"; +pub const BCRYPT_ECDSA_P384_ALGORITHM: &'static str = "ECDSA_P384"; +pub const BCRYPT_ECDSA_P521_ALGORITHM: &'static str = "ECDSA_P521"; +pub const BCRYPT_ECDH_P256_ALGORITHM: &'static str = "ECDH_P256"; +pub const BCRYPT_ECDH_P384_ALGORITHM: &'static str = "ECDH_P384"; +pub const BCRYPT_ECDH_P521_ALGORITHM: &'static str = "ECDH_P521"; +pub const BCRYPT_RNG_ALGORITHM: &'static str = "RNG"; +pub const BCRYPT_RNG_FIPS186_DSA_ALGORITHM: &'static str = "FIPS186DSARNG"; +pub const BCRYPT_RNG_DUAL_EC_ALGORITHM: &'static str = "DUALECRNG"; +pub const BCRYPT_SP800108_CTR_HMAC_ALGORITHM: &'static str = "SP800_108_CTR_HMAC"; +pub const BCRYPT_SP80056A_CONCAT_ALGORITHM: &'static str = "SP800_56A_CONCAT"; +pub const BCRYPT_PBKDF2_ALGORITHM: &'static str = "PBKDF2"; +pub const BCRYPT_CAPI_KDF_ALGORITHM: &'static str = "CAPI_KDF"; +pub const BCRYPT_TLS1_1_KDF_ALGORITHM: &'static str = "TLS1_1_KDF"; +pub const BCRYPT_TLS1_2_KDF_ALGORITHM: &'static str = "TLS1_2_KDF"; +pub const BCRYPT_ECDSA_ALGORITHM: &'static str = "ECDSA"; +pub const BCRYPT_ECDH_ALGORITHM: &'static str = "ECDH"; +pub const BCRYPT_XTS_AES_ALGORITHM: &'static str = "XTS-AES"; +pub const BCRYPT_CIPHER_INTERFACE: ULONG = 0x00000001; +pub const BCRYPT_HASH_INTERFACE: ULONG = 0x00000002; +pub const BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE: ULONG = 0x00000003; +pub const BCRYPT_SECRET_AGREEMENT_INTERFACE: ULONG = 0x00000004; +pub const BCRYPT_SIGNATURE_INTERFACE: ULONG = 0x00000005; +pub const BCRYPT_RNG_INTERFACE: ULONG = 0x00000006; +pub const BCRYPT_KEY_DERIVATION_INTERFACE: ULONG = 0x00000007; +pub const BCRYPT_MD2_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000001 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_MD4_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000011 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_MD5_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000021 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_SHA1_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000031 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_SHA256_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000041 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_SHA384_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000051 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_SHA512_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000061 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_RC4_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000071 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_RNG_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000081 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_HMAC_MD5_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000091 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_HMAC_SHA1_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000000a1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_HMAC_SHA256_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000000b1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_HMAC_SHA384_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000000c1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_HMAC_SHA512_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000000d1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_RSA_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000000e1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_ECDSA_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000000f1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_AES_CMAC_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000101 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_AES_GMAC_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000111 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_HMAC_MD2_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000121 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_HMAC_MD4_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000131 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_3DES_CBC_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000141 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_3DES_ECB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000151 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_3DES_CFB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000161 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_3DES_112_CBC_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000171 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_3DES_112_ECB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000181 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_3DES_112_CFB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000191 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_AES_CBC_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000001a1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_AES_ECB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000001b1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_AES_CFB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000001c1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_AES_CCM_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000001d1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_AES_GCM_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000001e1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_DES_CBC_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000001f1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_DES_ECB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000201 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_DES_CFB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000211 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_DESX_CBC_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000221 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_DESX_ECB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000231 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_DESX_CFB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000241 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_RC2_CBC_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000251 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_RC2_ECB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000261 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_RC2_CFB_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000271 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_DH_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000281 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_ECDH_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000291 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_ECDH_P256_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000002a1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_ECDH_P384_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000002b1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_ECDH_P521_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000002c1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_DSA_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000002d1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_ECDSA_P256_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000002e1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_ECDSA_P384_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x000002f1 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_ECDSA_P521_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000301 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_RSA_SIGN_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000311 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_CAPI_KDF_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000321 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_PBKDF2_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000331 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_SP800108_CTR_HMAC_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000341 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_SP80056A_CONCAT_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000351 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_TLS1_1_KDF_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000361 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_TLS1_2_KDF_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000371 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_XTS_AES_ALG_HANDLE: BCRYPT_ALG_HANDLE = 0x00000381 as BCRYPT_ALG_HANDLE; +pub const BCRYPT_ALG_HANDLE_HMAC_FLAG: ULONG = 0x00000008; +pub const BCRYPT_CAPI_AES_FLAG: ULONG = 0x00000010; +pub const BCRYPT_HASH_REUSABLE_FLAG: ULONG = 0x00000020; +pub const BCRYPT_BUFFERS_LOCKED_FLAG: ULONG = 0x00000040; +pub const BCRYPT_EXTENDED_KEYSIZE: ULONG = 0x00000080; +pub const BCRYPT_ENABLE_INCOMPATIBLE_FIPS_CHECKS: ULONG = 0x00000100; +extern "system" { + pub fn BCryptOpenAlgorithmProvider( + phAlgorithm: *mut BCRYPT_ALG_HANDLE, + pszAlgId: LPCWSTR, + pszImplementation: LPCWSTR, + dwFlags: ULONG, + ) -> NTSTATUS; +} +pub const BCRYPT_CIPHER_OPERATION: ULONG = 0x00000001; +pub const BCRYPT_HASH_OPERATION: ULONG = 0x00000002; +pub const BCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION: ULONG = 0x00000004; +pub const BCRYPT_SECRET_AGREEMENT_OPERATION: ULONG = 0x00000008; +pub const BCRYPT_SIGNATURE_OPERATION: ULONG = 0x00000010; +pub const BCRYPT_RNG_OPERATION: ULONG = 0x00000020; +pub const BCRYPT_KEY_DERIVATION_OPERATION: ULONG = 0x00000040; +STRUCT!{struct BCRYPT_ALGORITHM_IDENTIFIER { + pszName: LPWSTR, + dwClass: ULONG, + dwFlags: ULONG, +}} +extern "system" { + pub fn BCryptEnumAlgorithms( + dwAlgOperations: ULONG, + pAlgCount: *mut ULONG, + ppAlgList: *mut *mut BCRYPT_ALGORITHM_IDENTIFIER, + dwFlags: ULONG, + ) -> NTSTATUS; +} +STRUCT!{struct BCRYPT_PROVIDER_NAME { + pszProviderName: LPWSTR, +}} +extern "system" { + pub fn BCryptEnumProviders( + pszAlgId: LPCWSTR, + pImplCount: *mut ULONG, + ppImplList: *mut *mut BCRYPT_PROVIDER_NAME, + dwFlags: ULONG, + ) -> NTSTATUS; +} +pub const BCRYPT_PUBLIC_KEY_FLAG: ULONG = 0x00000001; +pub const BCRYPT_PRIVATE_KEY_FLAG: ULONG = 0x00000002; +extern "system" { + pub fn BCryptGetProperty( + hObject: BCRYPT_HANDLE, + pszProperty: LPCWSTR, + pbOutput: PUCHAR, + cbOutput: ULONG, + pcbResult: *mut ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptSetProperty( + hObject: BCRYPT_HANDLE, + pszProperty: LPCWSTR, + pbInput: PUCHAR, + cbInput: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptCloseAlgorithmProvider( + hAlgorithm: BCRYPT_ALG_HANDLE, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptFreeBuffer( + pvBuffer: PVOID, + ); + pub fn BCryptGenerateSymmetricKey( + hAlgorithm: BCRYPT_ALG_HANDLE, + phKey: *mut BCRYPT_KEY_HANDLE, + pbKeyObject: PUCHAR, + cbKeyObject: ULONG, + pbSecret: PUCHAR, + cbSecret: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptGenerateKeyPair( + hAlgorithm: BCRYPT_ALG_HANDLE, + phKey: *mut BCRYPT_KEY_HANDLE, + dwLength: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptEncrypt( + hKey: BCRYPT_KEY_HANDLE, + pbInput: PUCHAR, + cbInput: ULONG, + pPaddingInfo: *mut VOID, + pbIV: PUCHAR, + cbIV: ULONG, + pbOutput: PUCHAR, + cbOutput: ULONG, + pcbResult: *mut ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptDecrypt( + hKey: BCRYPT_KEY_HANDLE, + pbInput: PUCHAR, + cbInput: ULONG, + pPaddingInfo: *mut VOID, + pbIV: PUCHAR, + cbIV: ULONG, + pbOutput: PUCHAR, + cbOutput: ULONG, + pcbResult: *mut ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptExportKey( + hKey: BCRYPT_KEY_HANDLE, + hExportKey: BCRYPT_KEY_HANDLE, + pszBlobType: LPCWSTR, + pbOutput: PUCHAR, + cbOutput: ULONG, + pcbResult: *mut ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptImportKey( + hAlgorithm: BCRYPT_ALG_HANDLE, + hImportKey: BCRYPT_KEY_HANDLE, + pszBlobType: LPCWSTR, + phKey: *mut BCRYPT_KEY_HANDLE, + pbKeyObject: PUCHAR, + cbKeyObject: ULONG, + pbInput: PUCHAR, + cbInput: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; +} +pub const BCRYPT_NO_KEY_VALIDATION: ULONG = 0x00000008; +extern "system" { + pub fn BCryptImportKeyPair( + hAlgorithm: BCRYPT_ALG_HANDLE, + hImportKey: BCRYPT_KEY_HANDLE, + pszBlobType: LPCWSTR, + phKey: *mut BCRYPT_KEY_HANDLE, + pbInput: PUCHAR, + cbInput: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptDuplicateKey( + hKey: BCRYPT_KEY_HANDLE, + phNewKey: *mut BCRYPT_KEY_HANDLE, + pbKeyObject: PUCHAR, + cbKeyObject: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptFinalizeKeyPair( + hKey: BCRYPT_KEY_HANDLE, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptDestroyKey( + hKey: BCRYPT_KEY_HANDLE, + ) -> NTSTATUS; + pub fn BCryptDestroySecret( + hSecret: BCRYPT_SECRET_HANDLE, + ) -> NTSTATUS; + pub fn BCryptSignHash( + hKey: BCRYPT_KEY_HANDLE, + pPaddingInfo: *mut VOID, + pbInput: PUCHAR, + cbInput: ULONG, + pbOutput: PUCHAR, + cbOutput: ULONG, + pcbResult: *mut ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptVerifySignature( + hKey: BCRYPT_KEY_HANDLE, + pPaddingInfo: *mut VOID, + pbHash: PUCHAR, + cbHash: ULONG, + pbSignature: PUCHAR, + cbSignature: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptSecretAgreement( + hPrivKey: BCRYPT_KEY_HANDLE, + hPubKey: BCRYPT_KEY_HANDLE, + phAgreedSecret: *mut BCRYPT_SECRET_HANDLE, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptDeriveKey( + hSharedSecret: BCRYPT_SECRET_HANDLE, + pwszKDF: LPCWSTR, + pParameterList: *mut BCryptBufferDesc, + pbDerivedKey: PUCHAR, + cbDerivedKey: ULONG, + pcbResult: *mut ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptKeyDerivation( + hKey: BCRYPT_KEY_HANDLE, + pParameterList: *mut BCryptBufferDesc, + pbDerivedKey: PUCHAR, + cbDerivedKey: ULONG, + pcbResult: *mut ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptCreateHash( + hAlgorithm: BCRYPT_ALG_HANDLE, + phHash: *mut BCRYPT_HASH_HANDLE, + pbHashObject: PUCHAR, + cbHashObject: ULONG, + pbSecret: PUCHAR, + cbSecret: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptHashData( + hHash: BCRYPT_HASH_HANDLE, + pbInput: PUCHAR, + cbInput: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptFinishHash( + hHash: BCRYPT_HASH_HANDLE, + pbOutput: PUCHAR, + cbOutput: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptCreateMultiHash( + hAlgorithm: BCRYPT_ALG_HANDLE, + phHash: *mut BCRYPT_HASH_HANDLE, + nHashes: ULONG, + pbHashObject: PUCHAR, + cbHashObject: ULONG, + pbSecret: PUCHAR, + cbSecret: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptProcessMultiOperations( + hObject: BCRYPT_HANDLE, + operationType: BCRYPT_MULTI_OPERATION_TYPE, + pOperations: PVOID, + cbOperations: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptDuplicateHash( + hHash: BCRYPT_HASH_HANDLE, + phNewHash: *mut BCRYPT_HASH_HANDLE, + pbHashObject: PUCHAR, + cbHashObject: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptDestroyHash( + hHash: BCRYPT_HASH_HANDLE, + ) -> NTSTATUS; + pub fn BCryptHash( + hAlgorithm: BCRYPT_ALG_HANDLE, + pbSecret: PUCHAR, + cbSecret: ULONG, + pbInput: PUCHAR, + cbInput: ULONG, + pbOutput: PUCHAR, + cbOutput: ULONG, + ) -> NTSTATUS; +} +pub const BCRYPT_RNG_USE_ENTROPY_IN_BUFFER: ULONG = 0x00000001; +pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG: ULONG = 0x00000002; +extern "system" { + pub fn BCryptGenRandom( + hAlgorithm: BCRYPT_ALG_HANDLE, + pbBuffer: PUCHAR, + cbBuffer: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptDeriveKeyCapi( + hHash: BCRYPT_HASH_HANDLE, + hTargetAlg: BCRYPT_ALG_HANDLE, + pbDerivedKey: PUCHAR, + cbDerivedKey: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; + pub fn BCryptDeriveKeyPBKDF2( + hPrf: BCRYPT_ALG_HANDLE, + pbPassword: PUCHAR, + cbPassword: ULONG, + pbSalt: PUCHAR, + cbSalt: ULONG, + cIterations: ULONGLONG, + pbDerivedKey: PUCHAR, + cbDerivedKey: ULONG, + dwFlags: ULONG, + ) -> NTSTATUS; +} +STRUCT!{struct BCRYPT_INTERFACE_VERSION { + MajorVersion: USHORT, + MinorVersion: USHORT, +}} +pub type PBCRYPT_INTERFACE_VERSION = *mut BCRYPT_INTERFACE_VERSION; +#[inline] +pub fn BCRYPT_IS_INTERFACE_VERSION_COMPATIBLE( + loader: BCRYPT_INTERFACE_VERSION, + provider: BCRYPT_INTERFACE_VERSION, +) -> bool { + loader.MajorVersion <= provider.MajorVersion +} +pub const BCRYPT_CIPHER_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = + BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); +pub const BCRYPT_HASH_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = + BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); +pub const BCRYPT_HASH_INTERFACE_MAJORVERSION_2: USHORT = 2; +pub const BCRYPT_HASH_INTERFACE_VERSION_2: BCRYPT_INTERFACE_VERSION = + BCRYPT_MAKE_INTERFACE_VERSION!(BCRYPT_HASH_INTERFACE_MAJORVERSION_2, 0); +pub const BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = + BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); +pub const BCRYPT_SECRET_AGREEMENT_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = + BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); +pub const BCRYPT_SIGNATURE_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = + BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); +pub const BCRYPT_RNG_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = + BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); +pub const CRYPT_MIN_DEPENDENCIES: ULONG = 0x00000001; +pub const CRYPT_PROCESS_ISOLATE: ULONG = 0x00010000; +pub const CRYPT_UM: ULONG = 0x00000001; +pub const CRYPT_KM: ULONG = 0x00000002; +pub const CRYPT_MM: ULONG = 0x00000003; +pub const CRYPT_ANY: ULONG = 0x00000004; +pub const CRYPT_OVERWRITE: ULONG = 0x00000001; +pub const CRYPT_LOCAL: ULONG = 0x00000001; +pub const CRYPT_DOMAIN: ULONG = 0x00000002; +pub const CRYPT_EXCLUSIVE: ULONG = 0x00000001; +pub const CRYPT_OVERRIDE: ULONG = 0x00010000; +pub const CRYPT_ALL_FUNCTIONS: ULONG = 0x00000001; +pub const CRYPT_ALL_PROVIDERS: ULONG = 0x00000002; +pub const CRYPT_PRIORITY_TOP: ULONG = 0x00000000; +pub const CRYPT_PRIORITY_BOTTOM: ULONG = 0xFFFFFFFF; +pub const CRYPT_DEFAULT_CONTEXT: &'static str = "Default"; +STRUCT!{struct CRYPT_INTERFACE_REG { + dwInterface: ULONG, + dwFlags: ULONG, + cFunctions: ULONG, + rgpszFunctions: *mut PWSTR, +}} +pub type PCRYPT_INTERFACE_REG = *mut CRYPT_INTERFACE_REG; +STRUCT!{struct CRYPT_IMAGE_REG { + pszImage: PWSTR, + cInterfaces: ULONG, + rgpInterfaces: *mut PCRYPT_INTERFACE_REG, +}} +pub type PCRYPT_IMAGE_REG = *mut CRYPT_IMAGE_REG; +STRUCT!{struct CRYPT_PROVIDER_REG { + cAliases: ULONG, + rgpszAliases: *mut PWSTR, + pUM: PCRYPT_IMAGE_REG, + pKM: PCRYPT_IMAGE_REG, +}} +pub type PCRYPT_PROVIDER_REG = *mut CRYPT_PROVIDER_REG; +STRUCT!{struct CRYPT_PROVIDERS { + cProviders: ULONG, + rgpszProviders: *mut PWSTR, +}} +pub type PCRYPT_PROVIDERS = *mut CRYPT_PROVIDERS; +STRUCT!{struct CRYPT_CONTEXT_CONFIG { + dwFlags: ULONG, + dwReserved: ULONG, +}} +pub type PCRYPT_CONTEXT_CONFIG = *mut CRYPT_CONTEXT_CONFIG; +STRUCT!{struct CRYPT_CONTEXT_FUNCTION_CONFIG { + dwFlags: ULONG, + dwReserved: ULONG, +}} +pub type PCRYPT_CONTEXT_FUNCTION_CONFIG = *mut CRYPT_CONTEXT_FUNCTION_CONFIG; +STRUCT!{struct CRYPT_CONTEXTS { + cContexts: ULONG, + rgpszContexts: *mut PWSTR, +}} +pub type PCRYPT_CONTEXTS = *mut CRYPT_CONTEXTS; +STRUCT!{struct CRYPT_CONTEXT_FUNCTIONS { + cFunctions: ULONG, + rgpszFunctions: *mut PWSTR, +}} +pub type PCRYPT_CONTEXT_FUNCTIONS = *mut CRYPT_CONTEXT_FUNCTIONS; +STRUCT!{struct CRYPT_CONTEXT_FUNCTION_PROVIDERS { + cProviders: ULONG, + rgpszProviders: *mut PWSTR, +}} +pub type PCRYPT_CONTEXT_FUNCTION_PROVIDERS = *mut CRYPT_CONTEXT_FUNCTION_PROVIDERS; +STRUCT!{struct CRYPT_PROPERTY_REF { + pszProperty: PWSTR, + cbValue: ULONG, + pbValue: PUCHAR, +}} +pub type PCRYPT_PROPERTY_REF = *mut CRYPT_PROPERTY_REF; +STRUCT!{struct CRYPT_IMAGE_REF { + pszImage: PWSTR, + dwFlags: ULONG, +}} +pub type PCRYPT_IMAGE_REF = *mut CRYPT_IMAGE_REF; +STRUCT!{struct CRYPT_PROVIDER_REF { + dwInterface: ULONG, + pszFunction: PWSTR, + pszProvider: PWSTR, + cProperties: ULONG, + rgpProperties: *mut PCRYPT_PROPERTY_REF, + pUM: PCRYPT_IMAGE_REF, + pKM: PCRYPT_IMAGE_REF, +}} +pub type PCRYPT_PROVIDER_REF = *mut CRYPT_PROVIDER_REF; +STRUCT!{struct CRYPT_PROVIDER_REFS { + cProviders: ULONG, + rgpProviders: *mut PCRYPT_PROVIDER_REF, +}} +pub type PCRYPT_PROVIDER_REFS = *mut CRYPT_PROVIDER_REFS; +extern "system" { + pub fn BCryptQueryProviderRegistration( + pszProvider: LPCWSTR, + dwMode: ULONG, + dwInterface: ULONG, + pcbBuffer: *mut ULONG, + ppBuffer: *mut PCRYPT_PROVIDER_REG, + ) -> NTSTATUS; + pub fn BCryptEnumRegisteredProviders( + pcbBuffer: *mut ULONG, + ppBuffer: *mut PCRYPT_PROVIDERS, + ) -> NTSTATUS; + pub fn BCryptCreateContext( + dwTable: ULONG, + pszContext: LPCWSTR, + pConfig: PCRYPT_CONTEXT_CONFIG, + ) -> NTSTATUS; + pub fn BCryptDeleteContext( + dwTable: ULONG, + pszContext: LPCWSTR, + ) -> NTSTATUS; + pub fn BCryptEnumContexts( + dwTable: ULONG, + pcbBuffer: *mut ULONG, + ppBuffer: *mut PCRYPT_CONTEXTS, + ) -> NTSTATUS; + pub fn BCryptConfigureContext( + dwTable: ULONG, + pszContext: LPCWSTR, + pConfig: PCRYPT_CONTEXT_CONFIG, + ) -> NTSTATUS; + pub fn BCryptQueryContextConfiguration( + dwTable: ULONG, + pszContext: LPCWSTR, + pcbBuffer: *mut ULONG, + ppBuffer: *mut PCRYPT_CONTEXT_CONFIG, + ) -> NTSTATUS; + pub fn BCryptAddContextFunction( + dwTable: ULONG, + pszContext: LPCWSTR, + dwInterface: ULONG, + pszFunction: LPCWSTR, + dwPosition: ULONG, + ) -> NTSTATUS; + pub fn BCryptRemoveContextFunction( + dwTable: ULONG, + pszContext: LPCWSTR, + dwInterface: ULONG, + pszFunction: LPCWSTR, + ) -> NTSTATUS; + pub fn BCryptEnumContextFunctions( + dwTable: ULONG, + pszContext: LPCWSTR, + dwInterface: ULONG, + pcbBuffer: *mut ULONG, + ppBuffer: *mut PCRYPT_CONTEXT_FUNCTIONS, + ) -> NTSTATUS; + pub fn BCryptConfigureContextFunction( + dwTable: ULONG, + pszContext: LPCWSTR, + dwInterface: ULONG, + pszFunction: LPCWSTR, + pConfig: PCRYPT_CONTEXT_FUNCTION_CONFIG, + ) -> NTSTATUS; + pub fn BCryptQueryContextFunctionConfiguration( + dwTable: ULONG, + pszContext: LPCWSTR, + dwInterface: ULONG, + pszFunction: LPCWSTR, + pcbBuffer: *mut ULONG, + ppBuffer: *mut PCRYPT_CONTEXT_FUNCTION_CONFIG, + ) -> NTSTATUS; + pub fn BCryptEnumContextFunctionProviders( + dwTable: ULONG, + pszContext: LPCWSTR, + dwInterface: ULONG, + pszFunction: LPCWSTR, + pcbBuffer: *mut ULONG, + ppBuffer: *mut PCRYPT_CONTEXT_FUNCTION_PROVIDERS, + ) -> NTSTATUS; + pub fn BCryptSetContextFunctionProperty( + dwTable: ULONG, + pszContext: LPCWSTR, + dwInterface: ULONG, + pszFunction: LPCWSTR, + pszProperty: LPCWSTR, + cbValue: ULONG, + pbValue: PUCHAR, + ) -> NTSTATUS; + pub fn BCryptQueryContextFunctionProperty( + dwTable: ULONG, + pszContext: LPCWSTR, + dwInterface: ULONG, + pszFunction: LPCWSTR, + pszProperty: LPCWSTR, + pcbValue: *mut ULONG, + ppbValue: *mut PUCHAR, + ) -> NTSTATUS; + pub fn BCryptRegisterConfigChangeNotify( + phEvent: *mut HANDLE, + ) -> NTSTATUS; + pub fn BCryptUnregisterConfigChangeNotify( + hEvent: HANDLE, + ) -> NTSTATUS; + pub fn BCryptResolveProviders( + pszContext: LPCWSTR, + dwInterface: ULONG, + pszFunction: LPCWSTR, + pszProvider: LPCWSTR, + dwMode: ULONG, + dwFlags: ULONG, + pcbBuffer: *mut ULONG, + ppBuffer: *mut PCRYPT_PROVIDER_REFS, + ) -> NTSTATUS; + pub fn BCryptGetFipsAlgorithmMode( + pfEnabled: *mut BOOLEAN, + ) -> NTSTATUS; + pub fn CngGetFipsAlgorithmMode() -> BOOLEAN; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/bthdef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/bthdef.rs new file mode 100644 index 0000000..42a797c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/bthdef.rs @@ -0,0 +1,1103 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::bthsdpdef::SDP_ERROR; +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, UCHAR, ULONG, USHORT}; +use shared::ntdef::{CHAR, ULONGLONG}; +pub const BTH_MAJORVERSION: DWORD = 2; +pub const BTH_MINORVERSION: DWORD = 1; +DEFINE_GUID!{GUID_BTHPORT_DEVICE_INTERFACE, + 0x850302a, 0xb344, 0x4fda, 0x9b, 0xe9, 0x90, 0x57, 0x6b, 0x8d, 0x46, 0xf0} +DEFINE_GUID!{GUID_BTH_RFCOMM_SERVICE_DEVICE_INTERFACE, + 0xb142fc3e, 0xfa4e, 0x460b, 0x8a, 0xbc, 0x07, 0x2b, 0x62, 0x8b, 0x3c, 0x70} +DEFINE_GUID!{GUID_BLUETOOTH_RADIO_IN_RANGE, + 0xea3b5b82, 0x26ee, 0x450e, 0xb0, 0xd8, 0xd2, 0x6f, 0xe3, 0x0a, 0x38, 0x69} +DEFINE_GUID!{GUID_BLUETOOTH_RADIO_OUT_OF_RANGE, + 0xe28867c9, 0xc2aa, 0x4ced, 0xb9, 0x69, 0x45, 0x70, 0x86, 0x60, 0x37, 0xc4} +DEFINE_GUID!{GUID_BLUETOOTH_L2CAP_EVENT, + 0x7eae4030, 0xb709, 0x4aa8, 0xac, 0x55, 0xe9, 0x53, 0x82, 0x9c, 0x9d, 0xaa} +DEFINE_GUID!{GUID_BLUETOOTH_HCI_EVENT, + 0xfc240062, 0x1541, 0x49be, 0xb4, 0x63, 0x84, 0xc4, 0xdc, 0xd7, 0xbf, 0x7f} +DEFINE_GUID!{GUID_BLUETOOTH_AUTHENTICATION_REQUEST, + 0x5DC9136D, 0x996C, 0x46DB, 0x84, 0xF5, 0x32, 0xC0, 0xA3, 0xF4, 0x73, 0x52} +DEFINE_GUID!{GUID_BLUETOOTH_KEYPRESS_EVENT, + 0xD668DFCD, 0x0F4E, 0x4EFC, 0xBF, 0xE0, 0x39, 0x2E, 0xEE, 0xC5, 0x10, 0x9C} +DEFINE_GUID!{GUID_BLUETOOTH_HCI_VENDOR_EVENT, + 0x547247e6, 0x45bb, 0x4c33, 0xaf, 0x8c, 0xc0, 0x0e, 0xfe, 0x15, 0xa7, 0x1d} +DEFINE_GUID!{Bluetooth_Base_UUID, + 0x00000000, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB} +pub const SDP_PROTOCOL_UUID16: USHORT = 0x0001; +pub const UDP_PROTOCOL_UUID16: USHORT = 0x0002; +pub const RFCOMM_PROTOCOL_UUID16: USHORT = 0x0003; +pub const TCP_PROTOCOL_UUID16: USHORT = 0x0004; +pub const TCSBIN_PROTOCOL_UUID16: USHORT = 0x0005; +pub const TCSAT_PROTOCOL_UUID16: USHORT = 0x0006; +pub const ATT_PROTOCOL_UUID16: USHORT = 0x0007; +pub const OBEX_PROTOCOL_UUID16: USHORT = 0x0008; +pub const IP_PROTOCOL_UUID16: USHORT = 0x0009; +pub const FTP_PROTOCOL_UUID16: USHORT = 0x000A; +pub const HTTP_PROTOCOL_UUID16: USHORT = 0x000C; +pub const WSP_PROTOCOL_UUID16: USHORT = 0x000E; +pub const BNEP_PROTOCOL_UUID16: USHORT = 0x000F; +pub const UPNP_PROTOCOL_UUID16: USHORT = 0x0010; +pub const HID_PROTOCOL_UUID16: USHORT = 0x0011; +pub const HCCC_PROTOCOL_UUID16: USHORT = 0x0012; +pub const HCDC_PROTOCOL_UUID16: USHORT = 0x0014; +pub const HCN_PROTOCOL_UUID16: USHORT = 0x0016; +pub const AVCTP_PROTOCOL_UUID16: USHORT = 0x0017; +pub const AVDTP_PROTOCOL_UUID16: USHORT = 0x0019; +pub const CMPT_PROTOCOL_UUID16: USHORT = 0x001B; +pub const UDI_C_PLANE_PROTOCOL_UUID16: USHORT = 0x001D; +pub const L2CAP_PROTOCOL_UUID16: USHORT = 0x0100; +DEFINE_BLUETOOTH_UUID128!{SDP_PROTOCOL_UUID, SDP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{UDP_PROTOCOL_UUID, UDP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{RFCOMM_PROTOCOL_UUID, RFCOMM_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{TCP_PROTOCOL_UUID, TCP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{TCSBIN_PROTOCOL_UUID, TCSBIN_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{TCSAT_PROTOCOL_UUID, TCSAT_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{ATT_PROTOCOL_UUID, ATT_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{OBEX_PROTOCOL_UUID, OBEX_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{IP_PROTOCOL_UUID, IP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{FTP_PROTOCOL_UUID, FTP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{HTTP_PROTOCOL_UUID, HTTP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{WSP_PROTOCOL_UUID, WSP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{BNEP_PROTOCOL_UUID, BNEP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{UPNP_PROTOCOL_UUID, UPNP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{HID_PROTOCOL_UUID, HID_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{HCCC_PROTOCOL_UUID, HCCC_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{HCDC_PROTOCOL_UUID, HCDC_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{HCN_PROTOCOL_UUID, HCN_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{AVCTP_PROTOCOL_UUID, AVCTP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{AVDTP_PROTOCOL_UUID, AVDTP_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{CMPT_PROTOCOL_UUID, CMPT_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{UDI_C_PLANE_PROTOCOL_UUID, UDI_C_PLANE_PROTOCOL_UUID16} +DEFINE_BLUETOOTH_UUID128!{L2CAP_PROTOCOL_UUID, L2CAP_PROTOCOL_UUID16} +pub const ServiceDiscoveryServerServiceClassID_UUID16: USHORT = 0x1000; +pub const BrowseGroupDescriptorServiceClassID_UUID16: USHORT = 0x1001; +pub const PublicBrowseGroupServiceClassID_UUID16: USHORT = 0x1002; +pub const SerialPortServiceClassID_UUID16: USHORT = 0x1101; +pub const LANAccessUsingPPPServiceClassID_UUID16: USHORT = 0x1102; +pub const DialupNetworkingServiceClassID_UUID16: USHORT = 0x1103; +pub const IrMCSyncServiceClassID_UUID16: USHORT = 0x1104; +pub const OBEXObjectPushServiceClassID_UUID16: USHORT = 0x1105; +pub const OBEXFileTransferServiceClassID_UUID16: USHORT = 0x1106; +pub const IrMcSyncCommandServiceClassID_UUID16: USHORT = 0x1107; +pub const HeadsetServiceClassID_UUID16: USHORT = 0x1108; +pub const CordlessTelephonyServiceClassID_UUID16: USHORT = 0x1109; +pub const AudioSourceServiceClassID_UUID16: USHORT = 0x110A; +pub const AudioSinkServiceClassID_UUID16: USHORT = 0x110B; +pub const AVRemoteControlTargetServiceClassID_UUID16: USHORT = 0x110C; +pub const AVRemoteControlServiceClassID_UUID16: USHORT = 0x110E; +pub const AVRemoteControlControllerServiceClass_UUID16: USHORT = 0x110F; +pub const IntercomServiceClassID_UUID16: USHORT = 0x1110; +pub const FaxServiceClassID_UUID16: USHORT = 0x1111; +pub const HeadsetAudioGatewayServiceClassID_UUID16: USHORT = 0x1112; +pub const WAPServiceClassID_UUID16: USHORT = 0x1113; +pub const WAPClientServiceClassID_UUID16: USHORT = 0x1114; +pub const PANUServiceClassID_UUID16: USHORT = 0x1115; +pub const NAPServiceClassID_UUID16: USHORT = 0x1116; +pub const GNServiceClassID_UUID16: USHORT = 0x1117; +pub const DirectPrintingServiceClassID_UUID16: USHORT = 0x1118; +pub const ReferencePrintingServiceClassID_UUID16: USHORT = 0x1119; +pub const ImagingResponderServiceClassID_UUID16: USHORT = 0x111B; +pub const ImagingAutomaticArchiveServiceClassID_UUID16: USHORT = 0x111C; +pub const ImagingReferenceObjectsServiceClassID_UUID16: USHORT = 0x111D; +pub const HandsfreeServiceClassID_UUID16: USHORT = 0x111E; +pub const HandsfreeAudioGatewayServiceClassID_UUID16: USHORT = 0x111F; +pub const DirectPrintingReferenceObjectsServiceClassID_UUID16: USHORT = 0x1120; +pub const ReflectsUIServiceClassID_UUID16: USHORT = 0x1121; +pub const PrintingStatusServiceClassID_UUID16: USHORT = 0x1123; +pub const HumanInterfaceDeviceServiceClassID_UUID16: USHORT = 0x1124; +pub const HCRPrintServiceClassID_UUID16: USHORT = 0x1126; +pub const HCRScanServiceClassID_UUID16: USHORT = 0x1127; +pub const CommonISDNAccessServiceClassID_UUID16: USHORT = 0x1128; +pub const VideoConferencingGWServiceClassID_UUID16: USHORT = 0x1129; +pub const UDIMTServiceClassID_UUID16: USHORT = 0x112A; +pub const UDITAServiceClassID_UUID16: USHORT = 0x112B; +pub const AudioVideoServiceClassID_UUID16: USHORT = 0x112C; +pub const SimAccessServiceClassID_UUID16: USHORT = 0x112D; +pub const PhonebookAccessPceServiceClassID_UUID16: USHORT = 0x112E; +pub const PhonebookAccessPseServiceClassID_UUID16: USHORT = 0x112F; +pub const HeadsetHSServiceClassID_UUID16: USHORT = 0x1131; +pub const MessageAccessServerServiceClassID_UUID16: USHORT = 0x1132; +pub const MessageNotificationServerServiceClassID_UUID16: USHORT = 0x1133; +pub const GNSSServerServiceClassID_UUID16: USHORT = 0x1136; +pub const ThreeDimensionalDisplayServiceClassID_UUID16: USHORT = 0x1137; +pub const ThreeDimensionalGlassesServiceClassID_UUID16: USHORT = 0x1138; +pub const MPSServiceClassID_UUID16: USHORT = 0x113B; +pub const CTNAccessServiceClassID_UUID16: USHORT = 0x113C; +pub const CTNNotificationServiceClassID_UUID16: USHORT = 0x113D; +pub const PnPInformationServiceClassID_UUID16: USHORT = 0x1200; +pub const GenericNetworkingServiceClassID_UUID16: USHORT = 0x1201; +pub const GenericFileTransferServiceClassID_UUID16: USHORT = 0x1202; +pub const GenericAudioServiceClassID_UUID16: USHORT = 0x1203; +pub const GenericTelephonyServiceClassID_UUID16: USHORT = 0x1204; +pub const UPnpServiceClassID_UUID16: USHORT = 0x1205; +pub const UPnpIpServiceClassID_UUID16: USHORT = 0x1206; +pub const ESdpUpnpIpPanServiceClassID_UUID16: USHORT = 0x1300; +pub const ESdpUpnpIpLapServiceClassID_UUID16: USHORT = 0x1301; +pub const ESdpUpnpL2capServiceClassID_UUID16: USHORT = 0x1302; +pub const VideoSourceServiceClassID_UUID16: USHORT = 0x1303; +pub const VideoSinkServiceClassID_UUID16: USHORT = 0x1304; +pub const HealthDeviceProfileSourceServiceClassID_UUID16: USHORT = 0x1401; +pub const HealthDeviceProfileSinkServiceClassID_UUID16: USHORT = 0x1402; +DEFINE_BLUETOOTH_UUID128!{ServiceDiscoveryServerServiceClassID_UUID, + ServiceDiscoveryServerServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{BrowseGroupDescriptorServiceClassID_UUID, + BrowseGroupDescriptorServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{PublicBrowseGroupServiceClass_UUID, + PublicBrowseGroupServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{SerialPortServiceClass_UUID, + SerialPortServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{LANAccessUsingPPPServiceClass_UUID, + LANAccessUsingPPPServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{DialupNetworkingServiceClass_UUID, + DialupNetworkingServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{IrMCSyncServiceClass_UUID, + IrMCSyncServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{OBEXObjectPushServiceClass_UUID, + OBEXObjectPushServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{OBEXFileTransferServiceClass_UUID, + OBEXFileTransferServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{IrMCSyncCommandServiceClass_UUID, + IrMcSyncCommandServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HeadsetServiceClass_UUID, + HeadsetServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{CordlessTelephonyServiceClass_UUID, + CordlessTelephonyServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{AudioSourceServiceClass_UUID, + AudioSourceServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{AudioSinkServiceClass_UUID, + AudioSinkServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{AVRemoteControlTargetServiceClass_UUID, + AVRemoteControlTargetServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{AVRemoteControlServiceClass_UUID, + AVRemoteControlServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{AVRemoteControlControllerServiceClass_UUID, + AVRemoteControlControllerServiceClass_UUID16} +DEFINE_BLUETOOTH_UUID128!{IntercomServiceClass_UUID, + IntercomServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{FaxServiceClass_UUID, + FaxServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HeadsetAudioGatewayServiceClass_UUID, + HeadsetAudioGatewayServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{WAPServiceClass_UUID, + WAPServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{WAPClientServiceClass_UUID, + WAPClientServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{PANUServiceClass_UUID, + PANUServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{NAPServiceClass_UUID, + NAPServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{GNServiceClass_UUID, + GNServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{DirectPrintingServiceClass_UUID, + DirectPrintingServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ReferencePrintingServiceClass_UUID, + ReferencePrintingServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ImagingResponderServiceClass_UUID, + ImagingResponderServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ImagingAutomaticArchiveServiceClass_UUID, + ImagingAutomaticArchiveServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ImagingReferenceObjectsServiceClass_UUID, + ImagingReferenceObjectsServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HandsfreeServiceClass_UUID, + HandsfreeServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HandsfreeAudioGatewayServiceClass_UUID, + HandsfreeAudioGatewayServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{DirectPrintingReferenceObjectsServiceClass_UUID, + DirectPrintingReferenceObjectsServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ReflectedUIServiceClass_UUID, + ReflectsUIServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{PrintingStatusServiceClass_UUID, + PrintingStatusServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HumanInterfaceDeviceServiceClass_UUID, + HumanInterfaceDeviceServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HCRPrintServiceClass_UUID, + HCRPrintServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HCRScanServiceClass_UUID, + HCRScanServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{CommonISDNAccessServiceClass_UUID, + CommonISDNAccessServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{VideoConferencingGWServiceClass_UUID, + VideoConferencingGWServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{UDIMTServiceClass_UUID, + UDIMTServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{UDITAServiceClass_UUID, + UDITAServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{AudioVideoServiceClass_UUID, + AudioVideoServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{SimAccessServiceClass_UUID, + SimAccessServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{PhonebookAccessPceServiceClass_UUID, + PhonebookAccessPceServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{PhonebookAccessPseServiceClass_UUID, + PhonebookAccessPseServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HeadsetHSServiceClass_UUID, + HeadsetHSServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{MessageAccessServerServiceClass_UUID, + MessageAccessServerServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{MessageNotificationServerServiceClass_UUID, + MessageNotificationServerServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{GNSSServerServiceClass_UUID, + GNSSServerServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ThreeDimensionalDisplayServiceClass_UUID, + ThreeDimensionalDisplayServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ThreeDimensionalGlassesServiceClass_UUID, + ThreeDimensionalGlassesServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{MPSServiceClass_UUID, + MPSServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{CTNAccessServiceClass_UUID, + CTNAccessServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{CTNNotificationServiceClass_UUID, + CTNNotificationServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{PnPInformationServiceClass_UUID, + PnPInformationServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{GenericNetworkingServiceClass_UUID, + GenericNetworkingServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{GenericFileTransferServiceClass_UUID, + GenericFileTransferServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{GenericAudioServiceClass_UUID, + GenericAudioServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{GenericTelephonyServiceClass_UUID, + GenericTelephonyServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{UPnpServiceClass_UUID, + UPnpServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{UPnpIpServiceClass_UUID, + UPnpIpServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ESdpUpnpIpPanServiceClass_UUID, + ESdpUpnpIpPanServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ESdpUpnpIpLapServiceClass_UUID, + ESdpUpnpIpLapServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ESdpUpnpL2capServiceClass_UUID, + ESdpUpnpL2capServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{VideoSourceServiceClass_UUID, + VideoSourceServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{VideoSinkServiceClass_UUID, + VideoSinkServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HealthDeviceProfileSourceServiceClass_UUID, + HealthDeviceProfileSourceServiceClassID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HealthDeviceProfileSinkServiceClass_UUID, + HealthDeviceProfileSinkServiceClassID_UUID16} +pub const AdvancedAudioDistributionProfileID_UUID16: USHORT = 0x110D; +pub const ImagingServiceProfileID_UUID16: USHORT = 0x111A; +pub const BasicPrintingProfileID_UUID16: USHORT = 0x1122; +pub const HardcopyCableReplacementProfileID_UUID16: USHORT = 0x1125; +pub const PhonebookAccessProfileID_UUID16: USHORT = 0x1130; +pub const MessageAccessProfileID_UUID16: USHORT = 0x1134; +pub const GNSSProfileID_UUID16: USHORT = 0x1135; +pub const ThreeDimensionalSynchronizationProfileID_UUID16: USHORT = 0x1139; +pub const MPSProfileID_UUID16: USHORT = 0x113A; +pub const CTNProfileID_UUID16: USHORT = 0x113E; +pub const VideoDistributionProfileID_UUID16: USHORT = 0x1305; +pub const HealthDeviceProfileID_UUID16: USHORT = 0x1400; +DEFINE_BLUETOOTH_UUID128!{AdvancedAudioDistributionProfile_UUID, + AdvancedAudioDistributionProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ImagingServiceProfile_UUID, + ImagingServiceProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{BasicPrintingProfile_UUID, + BasicPrintingProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HardcopyCableReplacementProfile_UUID, + HardcopyCableReplacementProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{PhonebookAccessProfile_UUID, + PhonebookAccessProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{MessageAccessProfile_UUID, + MessageAccessProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{GNSSProfile_UUID, + GNSSProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{ThreeDimensionalSynchronizationProfile_UUID, + ThreeDimensionalSynchronizationProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{MPSProfile_UUID, + MPSProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{CTNProfile_UUID, + CTNProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{VideoDistributionProfile_UUID, + VideoDistributionProfileID_UUID16} +DEFINE_BLUETOOTH_UUID128!{HealthDeviceProfile_UUID, + HealthDeviceProfileID_UUID16} +pub const VideoConferencingServiceClass_UUID: GUID = AVRemoteControlControllerServiceClass_UUID; +pub const VideoConferencingServiceClassID_UUID16: USHORT + = AVRemoteControlControllerServiceClass_UUID16; +pub const HN_PROTOCOL_UUID: GUID = HCN_PROTOCOL_UUID; +pub const BasicPringingServiceClass_UUID: GUID = BasicPrintingProfile_UUID; +pub const CommonISDNAccessServiceClass_UUID16: USHORT = CommonISDNAccessServiceClassID_UUID16; +pub const VideoConferencingGWServiceClass_UUID16: USHORT + = VideoConferencingGWServiceClassID_UUID16; +pub const UDIMTServiceClass_UUID16: USHORT = UDIMTServiceClassID_UUID16; +pub const UDITAServiceClass_UUID16: USHORT = UDITAServiceClassID_UUID16; +pub const AudioVideoServiceClass_UUID16: USHORT = AudioVideoServiceClassID_UUID16; +pub const CordlessServiceClassID_UUID16: USHORT = CordlessTelephonyServiceClassID_UUID16; +pub const AudioSinkSourceServiceClassID_UUID16: USHORT = AudioSinkServiceClassID_UUID16; +pub const AdvancedAudioDistributionServiceClassID_UUID16: USHORT + = AdvancedAudioDistributionProfileID_UUID16; +pub const ImagingServiceClassID_UUID16: USHORT = ImagingServiceProfileID_UUID16; +pub const BasicPrintingServiceClassID_UUID16: USHORT = BasicPrintingProfileID_UUID16; +pub const HardcopyCableReplacementServiceClassID_UUID16: USHORT + = HardcopyCableReplacementProfileID_UUID16; +pub const AdvancedAudioDistributionServiceClass_UUID: GUID = AdvancedAudioDistributionProfile_UUID; +pub const ImagingServiceClass_UUID: GUID = ImagingServiceProfile_UUID; +pub const BasicPrintingServiceClass_UUID: GUID = BasicPrintingProfile_UUID; +pub const HardcopyCableReplacementServiceClass_UUID: GUID = HardcopyCableReplacementProfile_UUID; +pub const VideoDistributionServiceClass_UUID: GUID = VideoDistributionProfile_UUID; +pub const BTH_MAX_NAME_SIZE: usize = 248; +pub const BTH_MAX_PIN_SIZE: usize = 16; +pub const BTH_LINK_KEY_LENGTH: usize = 16; +pub const BTH_MFG_ERICSSON: u16 = 0; +pub const BTH_MFG_NOKIA: u16 = 1; +pub const BTH_MFG_INTEL: u16 = 2; +pub const BTH_MFG_IBM: u16 = 3; +pub const BTH_MFG_TOSHIBA: u16 = 4; +pub const BTH_MFG_3COM: u16 = 5; +pub const BTH_MFG_MICROSOFT: u16 = 6; +pub const BTH_MFG_LUCENT: u16 = 7; +pub const BTH_MFG_MOTOROLA: u16 = 8; +pub const BTH_MFG_INFINEON: u16 = 9; +pub const BTH_MFG_CSR: u16 = 10; +pub const BTH_MFG_SILICONWAVE: u16 = 11; +pub const BTH_MFG_DIGIANSWER: u16 = 12; +pub const BTH_MFG_TI: u16 = 13; +pub const BTH_MFG_PARTHUS: u16 = 14; +pub const BTH_MFG_BROADCOM: u16 = 15; +pub const BTH_MFG_MITEL: u16 = 16; +pub const BTH_MFG_WIDCOMM: u16 = 17; +pub const BTH_MFG_ZEEVO: u16 = 18; +pub const BTH_MFG_ATMEL: u16 = 19; +pub const BTH_MFG_MITSIBUSHI: u16 = 20; +pub const BTH_MFG_RTX_TELECOM: u16 = 21; +pub const BTH_MFG_KC_TECHNOLOGY: u16 = 22; +pub const BTH_MFG_NEWLOGIC: u16 = 23; +pub const BTH_MFG_TRANSILICA: u16 = 24; +pub const BTH_MFG_ROHDE_SCHWARZ: u16 = 25; +pub const BTH_MFG_TTPCOM: u16 = 26; +pub const BTH_MFG_SIGNIA: u16 = 27; +pub const BTH_MFG_CONEXANT: u16 = 28; +pub const BTH_MFG_QUALCOMM: u16 = 29; +pub const BTH_MFG_INVENTEL: u16 = 30; +pub const BTH_MFG_AVM_BERLIN: u16 = 31; +pub const BTH_MFG_BANDSPEED: u16 = 32; +pub const BTH_MFG_MANSELLA: u16 = 33; +pub const BTH_MFG_NEC: u16 = 34; +pub const BTH_MFG_WAVEPLUS_TECHNOLOGY_CO: u16 = 35; +pub const BTH_MFG_ALCATEL: u16 = 36; +pub const BTH_MFG_PHILIPS_SEMICONDUCTOR: u16 = 37; +pub const BTH_MFG_C_TECHNOLOGIES: u16 = 38; +pub const BTH_MFG_OPEN_INTERFACE: u16 = 39; +pub const BTH_MFG_RF_MICRO_DEVICES: u16 = 40; +pub const BTH_MFG_HITACHI: u16 = 41; +pub const BTH_MFG_SYMBOL_TECHNOLOGIES: u16 = 42; +pub const BTH_MFG_TENOVIS: u16 = 43; +pub const BTH_MFG_MACRONIX_INTERNATIONAL: u16 = 44; +pub const BTH_MFG_APPLE: u16 = 76; +pub const BTH_MFG_NORDIC_SEMICONDUCTORS_ASA: u16 = 89; +pub const BTH_MFG_ARUBA_NETWORKS: u16 = 283; +pub const BTH_MFG_INTERNAL_USE: u16 = 65535; +pub type BTH_ADDR = ULONGLONG; +pub type PBTH_ADDR = *mut ULONGLONG; +pub type BTH_COD = ULONG; +pub type PBTH_COD = *mut ULONG; +pub type BTH_LAP = ULONG; +pub type PBTH_LAP = *mut ULONG; +pub const BTH_ADDR_NULL: BTH_ADDR = 0x0000000000000000; +pub const NAP_MASK: u64 = 0xFFFF00000000; +pub const SAP_MASK: u64 = 0x0000FFFFFFFF; +pub const NAP_BIT_OFFSET: u8 = 8 * 4; +pub const SAP_BIT_OFFSET: u8 = 0; +#[inline] +pub fn GET_NAP(addr: BTH_ADDR) -> u16 { + ((addr & NAP_MASK) >> NAP_BIT_OFFSET) as u16 +} +#[inline] +pub fn GET_SAP(addr: BTH_ADDR) -> u32 { + ((addr & SAP_MASK) >> SAP_BIT_OFFSET) as u32 +} +#[inline] +pub fn SET_NAP(nap: u16) -> BTH_ADDR { + (nap as u64) << NAP_BIT_OFFSET +} +#[inline] +pub fn SET_SAP(sap: u32) -> BTH_ADDR { + (sap as u64) << SAP_BIT_OFFSET +} +#[inline] +pub fn SET_NAP_SAP(nap: u16, sap: u32) -> BTH_ADDR { + SET_NAP(nap) | SET_SAP(sap) +} +pub const COD_FORMAT_BIT_OFFSET: u8 = 0; +pub const COD_MINOR_BIT_OFFSET: u8 = 2; +pub const COD_MAJOR_BIT_OFFSET: u8 = 8 * 1; +pub const COD_SERVICE_BIT_OFFSET: u8 = 8 * 1 + 5; +pub const COD_FORMAT_MASK: u32 = 0x000003; +pub const COD_MINOR_MASK: u32 = 0x0000FC; +pub const COD_MAJOR_MASK: u32 = 0x001F00; +pub const COD_SERVICE_MASK: u32 = 0xFFE000; +#[inline] +pub fn GET_COD_FORMAT(cod: BTH_COD) -> u8 { + ((cod & COD_FORMAT_MASK) >> COD_FORMAT_BIT_OFFSET) as u8 +} +#[inline] +pub fn GET_COD_MINOR(cod: BTH_COD) -> u8 { + ((cod & COD_MINOR_MASK) >> COD_MINOR_BIT_OFFSET) as u8 +} +#[inline] +pub fn GET_COD_MAJOR(cod: BTH_COD) -> u8 { + ((cod & COD_MAJOR_MASK) >> COD_MAJOR_BIT_OFFSET) as u8 +} +#[inline] +pub fn GET_COD_SERVICE(cod: BTH_COD) -> u16 { + ((cod & COD_SERVICE_MASK) >> COD_SERVICE_BIT_OFFSET) as u16 +} +#[inline] +pub fn SET_COD_MINOR(cod: BTH_COD, minor: u8) -> BTH_COD { + (cod & !COD_MINOR_MASK) | ((minor as u32) << COD_MINOR_BIT_OFFSET) +} +#[inline] +pub fn SET_COD_MAJOR(cod: BTH_COD, major: u8) -> BTH_COD { + (cod & !COD_MAJOR_MASK) | ((major as u32) << COD_MAJOR_BIT_OFFSET) +} +#[inline] +pub fn SET_COD_SERVICE(cod: BTH_COD, service: u16) -> BTH_COD { + (cod & !COD_SERVICE_MASK) | ((service as u32) << COD_SERVICE_BIT_OFFSET) +} +pub const COD_VERSION: u32 = 0x0; +pub const COD_SERVICE_LIMITED: u16 = 0x0001; +pub const COD_SERVICE_POSITIONING: u16 = 0x0008; +pub const COD_SERVICE_NETWORKING: u16 = 0x0010; +pub const COD_SERVICE_RENDERING: u16 = 0x0020; +pub const COD_SERVICE_CAPTURING: u16 = 0x0040; +pub const COD_SERVICE_OBJECT_XFER: u16 = 0x0080; +pub const COD_SERVICE_AUDIO: u16 = 0x0100; +pub const COD_SERVICE_TELEPHONY: u16 = 0x0200; +pub const COD_SERVICE_INFORMATION: u16 = 0x0400; +pub const COD_SERVICE_VALID_MASK: u16 = COD_SERVICE_LIMITED | COD_SERVICE_POSITIONING + | COD_SERVICE_NETWORKING | COD_SERVICE_RENDERING | COD_SERVICE_CAPTURING + | COD_SERVICE_OBJECT_XFER | COD_SERVICE_AUDIO | COD_SERVICE_TELEPHONY + | COD_SERVICE_INFORMATION; +pub const COD_SERVICE_MAX_COUNT: usize = 9; +pub const COD_MAJOR_MISCELLANEOUS: u8 = 0x00; +pub const COD_MAJOR_COMPUTER: u8 = 0x01; +pub const COD_MAJOR_PHONE: u8 = 0x02; +pub const COD_MAJOR_LAN_ACCESS: u8 = 0x03; +pub const COD_MAJOR_AUDIO: u8 = 0x04; +pub const COD_MAJOR_PERIPHERAL: u8 = 0x05; +pub const COD_MAJOR_IMAGING: u8 = 0x06; +pub const COD_MAJOR_WEARABLE: u8 = 0x07; +pub const COD_MAJOR_TOY: u8 = 0x08; +pub const COD_MAJOR_HEALTH: u8 = 0x09; +pub const COD_MAJOR_UNCLASSIFIED: u8 = 0x1F; +pub const COD_COMPUTER_MINOR_UNCLASSIFIED: u8 = 0x00; +pub const COD_COMPUTER_MINOR_DESKTOP: u8 = 0x01; +pub const COD_COMPUTER_MINOR_SERVER: u8 = 0x02; +pub const COD_COMPUTER_MINOR_LAPTOP: u8 = 0x03; +pub const COD_COMPUTER_MINOR_HANDHELD: u8 = 0x04; +pub const COD_COMPUTER_MINOR_PALM: u8 = 0x05; +pub const COD_COMPUTER_MINOR_WEARABLE: u8 = 0x06; +pub const COD_PHONE_MINOR_UNCLASSIFIED: u8 = 0x00; +pub const COD_PHONE_MINOR_CELLULAR: u8 = 0x01; +pub const COD_PHONE_MINOR_CORDLESS: u8 = 0x02; +pub const COD_PHONE_MINOR_SMART: u8 = 0x03; +pub const COD_PHONE_MINOR_WIRED_MODEM: u8 = 0x04; +pub const COD_AUDIO_MINOR_UNCLASSIFIED: u8 = 0x00; +pub const COD_AUDIO_MINOR_HEADSET: u8 = 0x01; +pub const COD_AUDIO_MINOR_HANDS_FREE: u8 = 0x02; +pub const COD_AUDIO_MINOR_HEADSET_HANDS_FREE: u8 = 0x03; +pub const COD_AUDIO_MINOR_MICROPHONE: u8 = 0x04; +pub const COD_AUDIO_MINOR_LOUDSPEAKER: u8 = 0x05; +pub const COD_AUDIO_MINOR_HEADPHONES: u8 = 0x06; +pub const COD_AUDIO_MINOR_PORTABLE_AUDIO: u8 = 0x07; +pub const COD_AUDIO_MINOR_CAR_AUDIO: u8 = 0x08; +pub const COD_AUDIO_MINOR_SET_TOP_BOX: u8 = 0x09; +pub const COD_AUDIO_MINOR_HIFI_AUDIO: u8 = 0x0A; +pub const COD_AUDIO_MINOR_VCR: u8 = 0x0B; +pub const COD_AUDIO_MINOR_VIDEO_CAMERA: u8 = 0x0C; +pub const COD_AUDIO_MINOR_CAMCORDER: u8 = 0x0D; +pub const COD_AUDIO_MINOR_VIDEO_MONITOR: u8 = 0x0E; +pub const COD_AUDIO_MINOR_VIDEO_DISPLAY_LOUDSPEAKER: u8 = 0x0F; +pub const COD_AUDIO_MINOR_VIDEO_DISPLAY_CONFERENCING: u8 = 0x10; +pub const COD_AUDIO_MINOR_GAMING_TOY: u8 = 0x12; +pub const COD_PERIPHERAL_MINOR_KEYBOARD_MASK: u8 = 0x10; +pub const COD_PERIPHERAL_MINOR_POINTER_MASK: u8 = 0x20; +pub const COD_PERIPHERAL_MINOR_NO_CATEGORY: u8 = 0x00; +pub const COD_PERIPHERAL_MINOR_JOYSTICK: u8 = 0x01; +pub const COD_PERIPHERAL_MINOR_GAMEPAD: u8 = 0x02; +pub const COD_PERIPHERAL_MINOR_REMOTE_CONTROL: u8 = 0x03; +pub const COD_PERIPHERAL_MINOR_SENSING: u8 = 0x04; +pub const COD_IMAGING_MINOR_DISPLAY_MASK: u8 = 0x04; +pub const COD_IMAGING_MINOR_CAMERA_MASK: u8 = 0x08; +pub const COD_IMAGING_MINOR_SCANNER_MASK: u8 = 0x10; +pub const COD_IMAGING_MINOR_PRINTER_MASK: u8 = 0x20; +pub const COD_WEARABLE_MINOR_WRIST_WATCH: u8 = 0x01; +pub const COD_WEARABLE_MINOR_PAGER: u8 = 0x02; +pub const COD_WEARABLE_MINOR_JACKET: u8 = 0x03; +pub const COD_WEARABLE_MINOR_HELMET: u8 = 0x04; +pub const COD_WEARABLE_MINOR_GLASSES: u8 = 0x05; +pub const COD_TOY_MINOR_ROBOT: u8 = 0x01; +pub const COD_TOY_MINOR_VEHICLE: u8 = 0x02; +pub const COD_TOY_MINOR_DOLL_ACTION_FIGURE: u8 = 0x03; +pub const COD_TOY_MINOR_CONTROLLER: u8 = 0x04; +pub const COD_TOY_MINOR_GAME: u8 = 0x05; +pub const COD_HEALTH_MINOR_BLOOD_PRESSURE_MONITOR: u8 = 0x01; +pub const COD_HEALTH_MINOR_THERMOMETER: u8 = 0x02; +pub const COD_HEALTH_MINOR_WEIGHING_SCALE: u8 = 0x03; +pub const COD_HEALTH_MINOR_GLUCOSE_METER: u8 = 0x04; +pub const COD_HEALTH_MINOR_PULSE_OXIMETER: u8 = 0x05; +pub const COD_HEALTH_MINOR_HEART_PULSE_MONITOR: u8 = 0x06; +pub const COD_HEALTH_MINOR_HEALTH_DATA_DISPLAY: u8 = 0x07; +pub const COD_HEALTH_MINOR_STEP_COUNTER: u8 = 0x08; +pub const COD_LAN_ACCESS_BIT_OFFSET: u8 = 5; +pub const COD_LAN_MINOR_MASK: u32 = 0x00001C; +pub const COD_LAN_ACCESS_MASK: u32 = 0x0000E0; +#[inline] +pub fn GET_COD_LAN_MINOR(cod: BTH_COD) -> u8 { + ((cod & COD_LAN_MINOR_MASK) >> COD_MINOR_BIT_OFFSET) as u8 +} +#[inline] +pub fn GET_COD_LAN_ACCESS(cod: BTH_COD) -> u8 { + ((cod & COD_LAN_ACCESS_MASK) >> COD_LAN_ACCESS_BIT_OFFSET) as u8 +} +pub const COD_LAN_MINOR_UNCLASSIFIED: u8 = 0x00; +pub const COD_LAN_ACCESS_0_USED: u8 = 0x00; +pub const COD_LAN_ACCESS_17_USED: u8 = 0x01; +pub const COD_LAN_ACCESS_33_USED: u8 = 0x02; +pub const COD_LAN_ACCESS_50_USED: u8 = 0x03; +pub const COD_LAN_ACCESS_67_USED: u8 = 0x04; +pub const COD_LAN_ACCESS_83_USED: u8 = 0x05; +pub const COD_LAN_ACCESS_99_USED: u8 = 0x06; +pub const COD_LAN_ACCESS_FULL: u8 = 0x07; +pub const BTH_EIR_FLAGS_ID: u8 = 0x01; +pub const BTH_EIR_16_UUIDS_PARTIAL_ID: u8 = 0x02; +pub const BTH_EIR_16_UUIDS_COMPLETE_ID: u8 = 0x03; +pub const BTH_EIR_32_UUIDS_PARTIAL_ID: u8 = 0x04; +pub const BTH_EIR_32_UUIDS_COMPLETE_ID: u8 = 0x05; +pub const BTH_EIR_128_UUIDS_PARTIAL_ID: u8 = 0x06; +pub const BTH_EIR_128_UUIDS_COMPLETE_ID: u8 = 0x07; +pub const BTH_EIR_LOCAL_NAME_PARTIAL_ID: u8 = 0x08; +pub const BTH_EIR_LOCAL_NAME_COMPLETE_ID: u8 = 0x09; +pub const BTH_EIR_TX_POWER_LEVEL_ID: u8 = 0x0A; +pub const BTH_EIR_OOB_OPT_DATA_LEN_ID: u8 = 0x0B; +pub const BTH_EIR_OOB_BD_ADDR_ID: u8 = 0x0C; +pub const BTH_EIR_OOB_COD_ID: u8 = 0x0D; +pub const BTH_EIR_OOB_SP_HASH_ID: u8 = 0x0E; +pub const BTH_EIR_OOB_SP_RANDOMIZER_ID: u8 = 0x0F; +pub const BTH_EIR_MANUFACTURER_ID: u8 = 0xFF; +pub const BTH_EIR_SIZE: usize = 240; +// #define LAP_GIAC_INIT { 0x33, 0x8B, 0x9E } +// #define LAP_LIAC_INIT { 0x00, 0x8B, 0x9E } +pub const LAP_GIAC_VALUE: BTH_LAP = 0x009E8B33; +pub const LAP_LIAC_VALUE: BTH_LAP = 0x009E8B00; +pub const BTH_ADDR_IAC_FIRST: BTH_ADDR = 0x9E8B00; +pub const BTH_ADDR_IAC_LAST: BTH_ADDR = 0x9E8B3f; +pub const BTH_ADDR_LIAC: BTH_ADDR = 0x9E8B00; +pub const BTH_ADDR_GIAC: BTH_ADDR = 0x9E8B33; +pub type BTHSTATUS = UCHAR; +pub type PBTHSTATUS = *mut UCHAR; +#[inline] +pub fn BTH_ERROR(btStatus: BTHSTATUS) -> bool { + btStatus != BTH_ERROR_SUCCESS +} +#[inline] +pub fn BTH_SUCCESS(btStatus: BTHSTATUS) -> bool { + btStatus == BTH_ERROR_SUCCESS +} +pub const BTH_ERROR_SUCCESS: BTHSTATUS = 0x00; +pub const BTH_ERROR_UNKNOWN_HCI_COMMAND: BTHSTATUS = 0x01; +pub const BTH_ERROR_NO_CONNECTION: BTHSTATUS = 0x02; +pub const BTH_ERROR_HARDWARE_FAILURE: BTHSTATUS = 0x03; +pub const BTH_ERROR_PAGE_TIMEOUT: BTHSTATUS = 0x04; +pub const BTH_ERROR_AUTHENTICATION_FAILURE: BTHSTATUS = 0x05; +pub const BTH_ERROR_KEY_MISSING: BTHSTATUS = 0x06; +pub const BTH_ERROR_MEMORY_FULL: BTHSTATUS = 0x07; +pub const BTH_ERROR_CONNECTION_TIMEOUT: BTHSTATUS = 0x08; +pub const BTH_ERROR_MAX_NUMBER_OF_CONNECTIONS: BTHSTATUS = 0x09; +pub const BTH_ERROR_MAX_NUMBER_OF_SCO_CONNECTIONS: BTHSTATUS = 0x0a; +pub const BTH_ERROR_ACL_CONNECTION_ALREADY_EXISTS: BTHSTATUS = 0x0b; +pub const BTH_ERROR_COMMAND_DISALLOWED: BTHSTATUS = 0x0c; +pub const BTH_ERROR_HOST_REJECTED_LIMITED_RESOURCES: BTHSTATUS = 0x0d; +pub const BTH_ERROR_HOST_REJECTED_SECURITY_REASONS: BTHSTATUS = 0x0e; +pub const BTH_ERROR_HOST_REJECTED_PERSONAL_DEVICE: BTHSTATUS = 0x0f; +pub const BTH_ERROR_HOST_TIMEOUT: BTHSTATUS = 0x10; +pub const BTH_ERROR_UNSUPPORTED_FEATURE_OR_PARAMETER: BTHSTATUS = 0x11; +pub const BTH_ERROR_INVALID_HCI_PARAMETER: BTHSTATUS = 0x12; +pub const BTH_ERROR_REMOTE_USER_ENDED_CONNECTION: BTHSTATUS = 0x13; +pub const BTH_ERROR_REMOTE_LOW_RESOURCES: BTHSTATUS = 0x14; +pub const BTH_ERROR_REMOTE_POWERING_OFF: BTHSTATUS = 0x15; +pub const BTH_ERROR_LOCAL_HOST_TERMINATED_CONNECTION: BTHSTATUS = 0x16; +pub const BTH_ERROR_REPEATED_ATTEMPTS: BTHSTATUS = 0x17; +pub const BTH_ERROR_PAIRING_NOT_ALLOWED: BTHSTATUS = 0x18; +pub const BTH_ERROR_UKNOWN_LMP_PDU: BTHSTATUS = 0x19; +pub const BTH_ERROR_UNSUPPORTED_REMOTE_FEATURE: BTHSTATUS = 0x1a; +pub const BTH_ERROR_SCO_OFFSET_REJECTED: BTHSTATUS = 0x1b; +pub const BTH_ERROR_SCO_INTERVAL_REJECTED: BTHSTATUS = 0x1c; +pub const BTH_ERROR_SCO_AIRMODE_REJECTED: BTHSTATUS = 0x1d; +pub const BTH_ERROR_INVALID_LMP_PARAMETERS: BTHSTATUS = 0x1e; +pub const BTH_ERROR_UNSPECIFIED_ERROR: BTHSTATUS = 0x1f; +pub const BTH_ERROR_UNSUPPORTED_LMP_PARM_VALUE: BTHSTATUS = 0x20; +pub const BTH_ERROR_ROLE_CHANGE_NOT_ALLOWED: BTHSTATUS = 0x21; +pub const BTH_ERROR_LMP_RESPONSE_TIMEOUT: BTHSTATUS = 0x22; +pub const BTH_ERROR_LMP_TRANSACTION_COLLISION: BTHSTATUS = 0x23; +pub const BTH_ERROR_LMP_PDU_NOT_ALLOWED: BTHSTATUS = 0x24; +pub const BTH_ERROR_ENCRYPTION_MODE_NOT_ACCEPTABLE: BTHSTATUS = 0x25; +pub const BTH_ERROR_UNIT_KEY_NOT_USED: BTHSTATUS = 0x26; +pub const BTH_ERROR_QOS_IS_NOT_SUPPORTED: BTHSTATUS = 0x27; +pub const BTH_ERROR_INSTANT_PASSED: BTHSTATUS = 0x28; +pub const BTH_ERROR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED: BTHSTATUS = 0x29; +pub const BTH_ERROR_DIFFERENT_TRANSACTION_COLLISION: BTHSTATUS = 0x2a; +pub const BTH_ERROR_QOS_UNACCEPTABLE_PARAMETER: BTHSTATUS = 0x2c; +pub const BTH_ERROR_QOS_REJECTED: BTHSTATUS = 0x2d; +pub const BTH_ERROR_CHANNEL_CLASSIFICATION_NOT_SUPPORTED: BTHSTATUS = 0x2e; +pub const BTH_ERROR_INSUFFICIENT_SECURITY: BTHSTATUS = 0x2f; +pub const BTH_ERROR_PARAMETER_OUT_OF_MANDATORY_RANGE: BTHSTATUS = 0x30; +pub const BTH_ERROR_ROLE_SWITCH_PENDING: BTHSTATUS = 0x32; +pub const BTH_ERROR_RESERVED_SLOT_VIOLATION: BTHSTATUS = 0x34; +pub const BTH_ERROR_ROLE_SWITCH_FAILED: BTHSTATUS = 0x35; +pub const BTH_ERROR_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE: BTHSTATUS = 0x36; +pub const BTH_ERROR_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST: BTHSTATUS = 0x37; +pub const BTH_ERROR_HOST_BUSY_PAIRING: BTHSTATUS = 0x38; +pub const BTH_ERROR_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND: BTHSTATUS = 0x39; +pub const BTH_ERROR_CONTROLLER_BUSY: BTHSTATUS = 0x3a; +pub const BTH_ERROR_UNACCEPTABLE_CONNECTION_INTERVAL: BTHSTATUS = 0x3b; +pub const BTH_ERROR_DIRECTED_ADVERTISING_TIMEOUT: BTHSTATUS = 0x3c; +pub const BTH_ERROR_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE: BTHSTATUS = 0x3d; +pub const BTH_ERROR_CONNECTION_FAILED_TO_BE_ESTABLISHED: BTHSTATUS = 0x3e; +pub const BTH_ERROR_MAC_CONNECTION_FAILED: BTHSTATUS = 0x3f; +pub const BTH_ERROR_UNSPECIFIED: BTHSTATUS = 0xFF; +pub const L2CAP_MIN_MTU: u16 = 48; +pub const L2CAP_MAX_MTU: u16 = 0xFFFF; +pub const L2CAP_DEFAULT_MTU: u16 = 672; +pub const MAX_L2CAP_PING_DATA_LENGTH: usize = 44; +pub const MAX_L2CAP_INFO_DATA_LENGTH: usize = 44; +pub const BDIF_ADDRESS: u32 = 0x00000001; +pub const BDIF_COD: u32 = 0x00000002; +pub const BDIF_NAME: u32 = 0x00000004; +pub const BDIF_PAIRED: u32 = 0x00000008; +pub const BDIF_PERSONAL: u32 = 0x00000010; +pub const BDIF_CONNECTED: u32 = 0x00000020; +pub const BDIF_SHORT_NAME: u32 = 0x00000040; +pub const BDIF_VISIBLE: u32 = 0x00000080; +pub const BDIF_SSP_SUPPORTED: u32 = 0x00000100; +pub const BDIF_SSP_PAIRED: u32 = 0x00000200; +pub const BDIF_SSP_MITM_PROTECTED: u32 = 0x00000400; +pub const BDIF_RSSI: u32 = 0x00001000; +pub const BDIF_EIR: u32 = 0x00002000; +pub const BDIF_BR: u32 = 0x00004000; +pub const BDIF_LE: u32 = 0x00008000; +pub const BDIF_LE_PAIRED: u32 = 0x00010000; +pub const BDIF_LE_PERSONAL: u32 = 0x00020000; +pub const BDIF_LE_MITM_PROTECTED: u32 = 0x00040000; +pub const BDIF_LE_PRIVACY_ENABLED: u32 = 0x00080000; +pub const BDIF_LE_RANDOM_ADDRESS_TYPE: u32 = 0x00100000; +pub const BDIF_LE_DISCOVERABLE: u32 = 0x00200000; +pub const BDIF_LE_NAME: u32 = 0x00400000; +pub const BDIF_LE_VISIBLE: u32 = 0x00800000; +pub const BDIF_LE_CONNECTED: u32 = 0x01000000; +pub const BDIF_LE_CONNECTABLE: u32 = 0x02000000; +pub const BDIF_CONNECTION_INBOUND: u32 = 0x04000000; +pub const BDIF_BR_SECURE_CONNECTION_PAIRED: u32 = 0x08000000; +pub const BDIF_LE_SECURE_CONNECTION_PAIRED: u32 = 0x10000000; +pub const BDIF_VALID_FLAGS: u32 = BDIF_ADDRESS | BDIF_COD | BDIF_NAME | BDIF_PAIRED + | BDIF_PERSONAL | BDIF_CONNECTED | BDIF_SHORT_NAME | BDIF_VISIBLE | BDIF_RSSI | BDIF_EIR + | BDIF_SSP_PAIRED | BDIF_SSP_MITM_PROTECTED | BDIF_BR | BDIF_LE | BDIF_LE_PAIRED + | BDIF_LE_PERSONAL | BDIF_LE_MITM_PROTECTED | BDIF_LE_PRIVACY_ENABLED + | BDIF_LE_RANDOM_ADDRESS_TYPE | BDIF_LE_DISCOVERABLE | BDIF_LE_NAME | BDIF_LE_VISIBLE + | BDIF_LE_CONNECTED | BDIF_LE_CONNECTABLE | BDIF_CONNECTION_INBOUND + | BDIF_BR_SECURE_CONNECTION_PAIRED | BDIF_LE_SECURE_CONNECTION_PAIRED; +STRUCT!{struct BTH_DEVICE_INFO { + flags: ULONG, + address: BTH_ADDR, + classOfDevice: BTH_COD, + name: [CHAR; BTH_MAX_NAME_SIZE], +}} +pub type PBTH_DEVICE_INFO = *mut BTH_DEVICE_INFO; +STRUCT!{struct BTH_RADIO_IN_RANGE { + deviceInfo: BTH_DEVICE_INFO, + previousDeviceFlags: ULONG, +}} +pub type PBTH_RADIO_IN_RANGE = *mut BTH_RADIO_IN_RANGE; +STRUCT!{struct BTH_L2CAP_EVENT_INFO { + bthAddress: BTH_ADDR, + psm: USHORT, + connected: UCHAR, + initiated: UCHAR, +}} +pub type PBTH_L2CAP_EVENT_INFO = *mut BTH_L2CAP_EVENT_INFO; +pub const HCI_CONNECTION_TYPE_ACL: u8 = 1; +pub const HCI_CONNECTION_TYPE_SCO: u8 = 2; +pub const HCI_CONNECTION_TYPE_LE: u8 = 3; +pub const HCI_CONNNECTION_TYPE_ACL: u8 = HCI_CONNECTION_TYPE_ACL; +pub const HCI_CONNNECTION_TYPE_SCO: u8 = HCI_CONNECTION_TYPE_SCO; +STRUCT!{struct BTH_HCI_EVENT_INFO { + bthAddress: BTH_ADDR, + connectionType: UCHAR, + connected: UCHAR, +}} +pub type PBTH_HCI_EVENT_INFO = *mut BTH_HCI_EVENT_INFO; +ENUM!{enum IO_CAPABILITY { + IoCaps_DisplayOnly = 0x00, + IoCaps_DisplayYesNo = 0x01, + IoCaps_KeyboardOnly = 0x02, + IoCaps_NoInputNoOutput = 0x03, + IoCaps_Undefined = 0xff, +}} +ENUM!{enum AUTHENTICATION_REQUIREMENTS { + MITMProtectionNotRequired = 0x00, + MITMProtectionRequired = 0x01, + MITMProtectionNotRequiredBonding = 0x02, + MITMProtectionRequiredBonding = 0x03, + MITMProtectionNotRequiredGeneralBonding = 0x04, + MITMProtectionRequiredGeneralBonding = 0x05, + MITMProtectionNotDefined = 0xff, +}} +#[inline] +pub fn IsMITMProtectionRequired(requirements: AUTHENTICATION_REQUIREMENTS) -> bool { + MITMProtectionRequired == requirements || MITMProtectionRequiredBonding == requirements + || MITMProtectionRequiredGeneralBonding == requirements +} +pub const BTH_MAX_SERVICE_NAME_SIZE: usize = 256; +pub const MAX_UUIDS_IN_QUERY: usize = 12; +pub const BTH_VID_DEFAULT_VALUE: u16 = 0xFFFF; +pub const SDP_ERROR_INVALID_SDP_VERSION: u16 = 0x0001; +pub const SDP_ERROR_INVALID_RECORD_HANDLE: u16 = 0x0002; +pub const SDP_ERROR_INVALID_REQUEST_SYNTAX: u16 = 0x0003; +pub const SDP_ERROR_INVALID_PDU_SIZE: u16 = 0x0004; +pub const SDP_ERROR_INVALID_CONTINUATION_STATE: u16 = 0x0005; +pub const SDP_ERROR_INSUFFICIENT_RESOURCES: u16 = 0x0006; +pub const SDP_ERROR_SUCCESS: SDP_ERROR = 0x0000; +pub const SDP_ERROR_SERVER_INVALID_RESPONSE: SDP_ERROR = 0x0100; +pub const SDP_ERROR_SERVER_RESPONSE_DID_NOT_PARSE: SDP_ERROR = 0x0200; +pub const SDP_ERROR_SERVER_BAD_FORMAT: SDP_ERROR = 0x0300; +pub const SDP_ERROR_COULD_NOT_SEND_CONTINUE: SDP_ERROR = 0x0400; +pub const SDP_ERROR_RESPONSE_TOO_LARGE: SDP_ERROR = 0x0500; +pub const SDP_ATTRIB_RECORD_HANDLE: u16 = 0x0000; +pub const SDP_ATTRIB_CLASS_ID_LIST: u16 = 0x0001; +pub const SDP_ATTRIB_RECORD_STATE: u16 = 0x0002; +pub const SDP_ATTRIB_SERVICE_ID: u16 = 0x0003; +pub const SDP_ATTRIB_PROTOCOL_DESCRIPTOR_LIST: u16 = 0x0004; +pub const SDP_ATTRIB_BROWSE_GROUP_LIST: u16 = 0x0005; +pub const SDP_ATTRIB_LANG_BASE_ATTRIB_ID_LIST: u16 = 0x0006; +pub const SDP_ATTRIB_INFO_TIME_TO_LIVE: u16 = 0x0007; +pub const SDP_ATTRIB_AVAILABILITY: u16 = 0x0008; +pub const SDP_ATTRIB_PROFILE_DESCRIPTOR_LIST: u16 = 0x0009; +pub const SDP_ATTRIB_DOCUMENTATION_URL: u16 = 0x000A; +pub const SDP_ATTRIB_CLIENT_EXECUTABLE_URL: u16 = 0x000B; +pub const SDP_ATTRIB_ICON_URL: u16 = 0x000C; +pub const SDP_ATTRIB_ADDITIONAL_PROTOCOL_DESCRIPTOR_LIST: u16 = 0x000D; +pub const SDP_ATTRIB_PROFILE_SPECIFIC: u16 = 0x0200; +pub const LANG_BASE_LANGUAGE_INDEX: u16 = 0x0000; +pub const LANG_BASE_ENCODING_INDEX: u16 = 0x0001; +pub const LANG_BASE_OFFSET_INDEX: u16 = 0x0002; +pub const LANG_DEFAULT_ID: u16 = 0x0100; +pub const LANGUAGE_EN_US: u16 = 0x656E; +pub const ENCODING_UTF_8: u16 = 0x006A; +pub const STRING_NAME_OFFSET: u16 = 0x0000; +pub const STRING_DESCRIPTION_OFFSET: u16 = 0x0001; +pub const STRING_PROVIDER_NAME_OFFSET: u16 = 0x0002; +pub const SDP_ATTRIB_SDP_VERSION_NUMBER_LIST: u16 = 0x0200; +pub const SDP_ATTRIB_SDP_DATABASE_STATE: u16 = 0x0201; +pub const SDP_ATTRIB_BROWSE_GROUP_ID: u16 = 0x0200; +pub const SDP_ATTRIB_CORDLESS_EXTERNAL_NETWORK: u16 = 0x0301; +pub const SDP_ATTRIB_FAX_CLASS_1_SUPPORT: u16 = 0x0302; +pub const SDP_ATTRIB_FAX_CLASS_2_0_SUPPORT: u16 = 0x0303; +pub const SDP_ATTRIB_FAX_CLASS_2_SUPPORT: u16 = 0x0304; +pub const SDP_ATTRIB_FAX_AUDIO_FEEDBACK_SUPPORT: u16 = 0x0305; +pub const SDP_ATTRIB_HEADSET_REMOTE_AUDIO_VOLUME_CONTROL: u16 = 0x0302; +pub const SDP_ATTRIB_LAN_LPSUBNET: u16 = 0x0200; +pub const SDP_ATTRIB_OBJECT_PUSH_SUPPORTED_FORMATS_LIST: u16 = 0x0303; +pub const SDP_ATTRIB_SYNCH_SUPPORTED_DATA_STORES_LIST: u16 = 0x0301; +pub const SDP_ATTRIB_SERVICE_VERSION: u16 = 0x0300; +pub const SDP_ATTRIB_PAN_NETWORK_ADDRESS: u16 = 0x0306; +pub const SDP_ATTRIB_PAN_WAP_GATEWAY: u16 = 0x0307; +pub const SDP_ATTRIB_PAN_HOME_PAGE_URL: u16 = 0x0308; +pub const SDP_ATTRIB_PAN_WAP_STACK_TYPE: u16 = 0x0309; +pub const SDP_ATTRIB_PAN_SECURITY_DESCRIPTION: u16 = 0x030A; +pub const SDP_ATTRIB_PAN_NET_ACCESS_TYPE: u16 = 0x030B; +pub const SDP_ATTRIB_PAN_MAX_NET_ACCESS_RATE: u16 = 0x030C; +pub const SDP_ATTRIB_IMAGING_SUPPORTED_CAPABILITIES: u16 = 0x0310; +pub const SDP_ATTRIB_IMAGING_SUPPORTED_FEATURES: u16 = 0x0311; +pub const SDP_ATTRIB_IMAGING_SUPPORTED_FUNCTIONS: u16 = 0x0312; +pub const SDP_ATTRIB_IMAGING_TOTAL_DATA_CAPACITY: u16 = 0x0313; +pub const SDP_ATTRIB_DI_SPECIFICATION_ID: u16 = 0x0200; +pub const SDP_ATTRIB_DI_VENDOR_ID: u16 = 0x0201; +pub const SDP_ATTRIB_DI_PRODUCT_ID: u16 = 0x0202; +pub const SDP_ATTRIB_DI_VERSION: u16 = 0x0203; +pub const SDP_ATTRIB_DI_PRIMARY_RECORD: u16 = 0x0204; +pub const SDP_ATTRIB_DI_VENDOR_ID_SOURCE: u16 = 0x0205; +pub const SDP_ATTRIB_HID_DEVICE_RELEASE_NUMBER: u16 = 0x0200; +pub const SDP_ATTRIB_HID_PARSER_VERSION: u16 = 0x0201; +pub const SDP_ATTRIB_HID_DEVICE_SUBCLASS: u16 = 0x0202; +pub const SDP_ATTRIB_HID_COUNTRY_CODE: u16 = 0x0203; +pub const SDP_ATTRIB_HID_VIRTUAL_CABLE: u16 = 0x0204; +pub const SDP_ATTRIB_HID_RECONNECT_INITIATE: u16 = 0x0205; +pub const SDP_ATTRIB_HID_DESCRIPTOR_LIST: u16 = 0x0206; +pub const SDP_ATTRIB_HID_LANG_ID_BASE_LIST: u16 = 0x0207; +pub const SDP_ATTRIB_HID_SDP_DISABLE: u16 = 0x0208; +pub const SDP_ATTRIB_HID_BATTERY_POWER: u16 = 0x0209; +pub const SDP_ATTRIB_HID_REMOTE_WAKE: u16 = 0x020A; +pub const SDP_ATTRIB_HID_PROFILE_VERSION: u16 = 0x020B; +pub const SDP_ATTRIB_HID_SUPERVISION_TIMEOUT: u16 = 0x020C; +pub const SDP_ATTRIB_HID_NORMALLY_CONNECTABLE: u16 = 0x020D; +pub const SDP_ATTRIB_HID_BOOT_DEVICE: u16 = 0x020E; +pub const SDP_ATTRIB_HID_SSR_HOST_MAX_LATENCY: u16 = 0x020F; +pub const SDP_ATTRIB_HID_SSR_HOST_MIN_TIMEOUT: u16 = 0x0210; +pub const CORDLESS_EXTERNAL_NETWORK_PSTN: u8 = 0x01; +pub const CORDLESS_EXTERNAL_NETWORK_ISDN: u8 = 0x02; +pub const CORDLESS_EXTERNAL_NETWORK_GSM: u8 = 0x03; +pub const CORDLESS_EXTERNAL_NETWORK_CDMA: u8 = 0x04; +pub const CORDLESS_EXTERNAL_NETWORK_ANALOG_CELLULAR: u8 = 0x05; +pub const CORDLESS_EXTERNAL_NETWORK_PACKET_SWITCHED: u8 = 0x06; +pub const CORDLESS_EXTERNAL_NETWORK_OTHER: u8 = 0x07; +pub const OBJECT_PUSH_FORMAT_VCARD_2_1: u8 = 0x01; +pub const OBJECT_PUSH_FORMAT_VCARD_3_0: u8 = 0x02; +pub const OBJECT_PUSH_FORMAT_VCAL_1_0: u8 = 0x03; +pub const OBJECT_PUSH_FORMAT_ICAL_2_0: u8 = 0x04; +pub const OBJECT_PUSH_FORMAT_VNOTE: u8 = 0x05; +pub const OBJECT_PUSH_FORMAT_VMESSAGE: u8 = 0x06; +pub const OBJECT_PUSH_FORMAT_ANY: u8 = 0xFF; +pub const SYNCH_DATA_STORE_PHONEBOOK: u8 = 0x01; +pub const SYNCH_DATA_STORE_CALENDAR: u8 = 0x03; +pub const SYNCH_DATA_STORE_NOTES: u8 = 0x05; +pub const SYNCH_DATA_STORE_MESSAGES: u8 = 0x06; +pub const DI_VENDOR_ID_SOURCE_BLUETOOTH_SIG: u16 = 0x0001; +pub const DI_VENDOR_ID_SOURCE_USB_IF: u16 = 0x0002; +pub const PSM_SDP: u16 = 0x0001; +pub const PSM_RFCOMM: u16 = 0x0003; +pub const PSM_TCS_BIN: u16 = 0x0005; +pub const PSM_TCS_BIN_CORDLESS: u16 = 0x0007; +pub const PSM_BNEP: u16 = 0x000F; +pub const PSM_HID_CONTROL: u16 = 0x0011; +pub const PSM_HID_INTERRUPT: u16 = 0x0013; +pub const PSM_UPNP: u16 = 0x0015; +pub const PSM_AVCTP: u16 = 0x0017; +pub const PSM_AVDTP: u16 = 0x0019; +pub const PSM_AVCTP_BROWSE: u16 = 0x001B; +pub const PSM_UDI_C_PLANE: u16 = 0x001D; +pub const PSM_ATT: u16 = 0x001F; +pub const PSM_3DSP: u16 = 0x0021; +pub const PSM_LE_IPSP: u16 = 0x0023; +pub const STR_ADDR_FMTA: &'static str = "(%02x:%02x:%02x:%02x:%02x:%02x)\0"; +// #define STR_ADDR_FMTW L"(%02x:%02x:%02x:%02x:%02x:%02x)" +pub const STR_ADDR_SHORT_FMTA: &'static str = "%04x%08x\0"; +// #define STR_ADDR_SHORT_FMTW L"%04x%08x" +pub const STR_USBHCI_CLASS_HARDWAREIDA: &'static str = "USB\\Class_E0&SubClass_01&Prot_01\0"; +// #define STR_USBHCI_CLASS_HARDWAREIDW L"USB\\Class_E0&SubClass_01&Prot_01" +#[inline] +pub fn GET_BITS(field: u64, offset: u8, mask: u64) -> u64 { + (field >> offset) & mask +} +#[inline] +pub fn GET_BIT(field: u64, offset: u8) -> u64 { + GET_BITS(field, offset, 1) +} +#[inline] +pub fn LMP_3_SLOT_PACKETS(x: u64) -> u64 { + GET_BIT(x, 0) +} +#[inline] +pub fn LMP_5_SLOT_PACKETS(x: u64) -> u64 { + GET_BIT(x, 1) +} +#[inline] +pub fn LMP_ENCRYPTION(x: u64) -> u64 { + GET_BIT(x, 2) +} +#[inline] +pub fn LMP_SLOT_OFFSET(x: u64) -> u64 { + GET_BIT(x, 3) +} +#[inline] +pub fn LMP_TIMING_ACCURACY(x: u64) -> u64 { + GET_BIT(x, 4) +} +#[inline] +pub fn LMP_SWITCH(x: u64) -> u64 { + GET_BIT(x, 5) +} +#[inline] +pub fn LMP_HOLD_MODE(x: u64) -> u64 { + GET_BIT(x, 6) +} +#[inline] +pub fn LMP_SNIFF_MODE(x: u64) -> u64 { + GET_BIT(x, 7) +} +#[inline] +pub fn LMP_PARK_MODE(x: u64) -> u64 { + GET_BIT(x, 8) +} +#[inline] +pub fn LMP_RSSI(x: u64) -> u64 { + GET_BIT(x, 9) +} +#[inline] +pub fn LMP_CHANNEL_QUALITY_DRIVEN_MODE(x: u64) -> u64 { + GET_BIT(x, 10) +} +#[inline] +pub fn LMP_SCO_LINK(x: u64) -> u64 { + GET_BIT(x, 11) +} +#[inline] +pub fn LMP_HV2_PACKETS(x: u64) -> u64 { + GET_BIT(x, 12) +} +#[inline] +pub fn LMP_HV3_PACKETS(x: u64) -> u64 { + GET_BIT(x, 13) +} +#[inline] +pub fn LMP_MU_LAW_LOG(x: u64) -> u64 { + GET_BIT(x, 14) +} +#[inline] +pub fn LMP_A_LAW_LOG(x: u64) -> u64 { + GET_BIT(x, 15) +} +#[inline] +pub fn LMP_CVSD(x: u64) -> u64 { + GET_BIT(x, 16) +} +#[inline] +pub fn LMP_PAGING_SCHEME(x: u64) -> u64 { + GET_BIT(x, 17) +} +#[inline] +pub fn LMP_POWER_CONTROL(x: u64) -> u64 { + GET_BIT(x, 18) +} +#[inline] +pub fn LMP_TRANSPARENT_SCO_DATA(x: u64) -> u64 { + GET_BIT(x, 19) +} +#[inline] +pub fn LMP_FLOW_CONTROL_LAG(x: u64) -> u64 { + GET_BITS(x, 20, 0x3) +} +#[inline] +pub fn LMP_BROADCAST_ENCRYPTION(x: u64) -> u64 { + GET_BIT(x, 23) +} +#[inline] +pub fn LMP_ENHANCED_DATA_RATE_ACL_2MBPS_MODE(x: u64) -> u64 { + GET_BIT(x, 25) +} +#[inline] +pub fn LMP_ENHANCED_DATA_RATE_ACL_3MBPS_MODE(x: u64) -> u64 { + GET_BIT(x, 26) +} +#[inline] +pub fn LMP_ENHANCED_INQUIRY_SCAN(x: u64) -> u64 { + GET_BIT(x, 27) +} +#[inline] +pub fn LMP_INTERLACED_INQUIRY_SCAN(x: u64) -> u64 { + GET_BIT(x, 28) +} +#[inline] +pub fn LMP_INTERLACED_PAGE_SCAN(x: u64) -> u64 { + GET_BIT(x, 29) +} +#[inline] +pub fn LMP_RSSI_WITH_INQUIRY_RESULTS(x: u64) -> u64 { + GET_BIT(x, 30) +} +#[inline] +pub fn LMP_ESCO_LINK(x: u64) -> u64 { + GET_BIT(x, 31) +} +#[inline] +pub fn LMP_EV4_PACKETS(x: u64) -> u64 { + GET_BIT(x, 32) +} +#[inline] +pub fn LMP_EV5_PACKETS(x: u64) -> u64 { + GET_BIT(x, 33) +} +#[inline] +pub fn LMP_AFH_CAPABLE_SLAVE(x: u64) -> u64 { + GET_BIT(x, 35) +} +#[inline] +pub fn LMP_AFH_CLASSIFICATION_SLAVE(x: u64) -> u64 { + GET_BIT(x, 36) +} +#[inline] +pub fn LMP_BR_EDR_NOT_SUPPORTED(x: u64) -> u64 { + GET_BIT(x, 37) +} +#[inline] +pub fn LMP_LE_SUPPORTED(x: u64) -> u64 { + GET_BIT(x, 38) +} +#[inline] +pub fn LMP_3SLOT_EDR_ACL_PACKETS(x: u64) -> u64 { + GET_BIT(x, 39) +} +#[inline] +pub fn LMP_5SLOT_EDR_ACL_PACKETS(x: u64) -> u64 { + GET_BIT(x, 40) +} +#[inline] +pub fn LMP_SNIFF_SUBRATING(x: u64) -> u64 { + GET_BIT(x, 41) +} +#[inline] +pub fn LMP_PAUSE_ENCRYPTION(x: u64) -> u64 { + GET_BIT(x, 42) +} +#[inline] +pub fn LMP_AFH_CAPABLE_MASTER(x: u64) -> u64 { + GET_BIT(x, 43) +} +#[inline] +pub fn LMP_AFH_CLASSIFICATION_MASTER(x: u64) -> u64 { + GET_BIT(x, 44) +} +#[inline] +pub fn LMP_EDR_ESCO_2MBPS_MODE(x: u64) -> u64 { + GET_BIT(x, 45) +} +#[inline] +pub fn LMP_EDR_ESCO_3MBPS_MODE(x: u64) -> u64 { + GET_BIT(x, 46) +} +#[inline] +pub fn LMP_3SLOT_EDR_ESCO_PACKETS(x: u64) -> u64 { + GET_BIT(x, 47) +} +#[inline] +pub fn LMP_EXTENDED_INQUIRY_RESPONSE(x: u64) -> u64 { + GET_BIT(x, 48) +} +#[inline] +pub fn LMP_SIMULT_LE_BR_TO_SAME_DEV(x: u64) -> u64 { + GET_BIT(x, 49) +} +#[inline] +pub fn LMP_SECURE_SIMPLE_PAIRING(x: u64) -> u64 { + GET_BIT(x, 51) +} +#[inline] +pub fn LMP_ENCAPSULATED_PDU(x: u64) -> u64 { + GET_BIT(x, 52) +} +#[inline] +pub fn LMP_ERRONEOUS_DATA_REPORTING(x: u64) -> u64 { + GET_BIT(x, 53) +} +#[inline] +pub fn LMP_NON_FLUSHABLE_PACKET_BOUNDARY_FLAG(x: u64) -> u64 { + GET_BIT(x, 54) +} +#[inline] +pub fn LMP_LINK_SUPERVISION_TIMEOUT_CHANGED_EVENT(x: u64) -> u64 { + GET_BIT(x, 56) +} +#[inline] +pub fn LMP_INQUIRY_RESPONSE_TX_POWER_LEVEL(x: u64) -> u64 { + GET_BIT(x, 57) +} +#[inline] +pub fn LMP_EXTENDED_FEATURES(x: u64) -> u64 { + GET_BIT(x, 63) +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/bthioctl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/bthioctl.rs new file mode 100644 index 0000000..78ca6b7 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/bthioctl.rs @@ -0,0 +1,151 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::bthdef::{BTH_ADDR, BTH_DEVICE_INFO, MAX_UUIDS_IN_QUERY}; +use shared::bthsdpdef::{SdpAttributeRange, SdpQueryUuid}; +use shared::minwindef::{DWORD, UCHAR, ULONG, USHORT}; +use shared::ntdef::{BOOLEAN, ULONGLONG}; +use um::winioctl::{FILE_ANY_ACCESS, FILE_DEVICE_BLUETOOTH, METHOD_BUFFERED, METHOD_NEITHER}; +pub const BTH_IOCTL_BASE: DWORD = 0; +pub const IOCTL_INTERNAL_BTH_SUBMIT_BRB: DWORD = BTH_KERNEL_CTL!(BTH_IOCTL_BASE + 0x00); +pub const IOCTL_INTERNAL_BTHENUM_GET_ENUMINFO: DWORD = BTH_KERNEL_CTL!(BTH_IOCTL_BASE + 0x01); +pub const IOCTL_INTERNAL_BTHENUM_GET_DEVINFO: DWORD = BTH_KERNEL_CTL!(BTH_IOCTL_BASE + 0x02); +pub const IOCTL_BTH_GET_LOCAL_INFO: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x00); +pub const IOCTL_BTH_GET_RADIO_INFO: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x01); +pub const IOCTL_BTH_GET_DEVICE_INFO: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x02); +pub const IOCTL_BTH_DISCONNECT_DEVICE: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x03); +pub const IOCTL_BTH_HCI_VENDOR_COMMAND: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x14); +pub const IOCTL_BTH_SDP_CONNECT: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x80); +pub const IOCTL_BTH_SDP_DISCONNECT: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x81); +pub const IOCTL_BTH_SDP_SERVICE_SEARCH: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x82); +pub const IOCTL_BTH_SDP_ATTRIBUTE_SEARCH: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x83); +pub const IOCTL_BTH_SDP_SERVICE_ATTRIBUTE_SEARCH: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x84); +pub const IOCTL_BTH_SDP_SUBMIT_RECORD: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x85); +pub const IOCTL_BTH_SDP_REMOVE_RECORD: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x86); +pub const IOCTL_BTH_SDP_SUBMIT_RECORD_WITH_INFO: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x87); +pub const IOCTL_BTH_GET_HOST_SUPPORTED_FEATURES: DWORD = BTH_CTL!(BTH_IOCTL_BASE + 0x88); +STRUCT!{#[repr(packed)] struct BTH_DEVICE_INFO_LIST { + numOfDevices: ULONG, + deviceList: [BTH_DEVICE_INFO; 1], +}} +pub type PBTH_DEVICE_INFO_LIST = *mut BTH_DEVICE_INFO_LIST; +STRUCT!{#[repr(packed)] struct BTH_RADIO_INFO { + lmpSupportedFeatures: ULONGLONG, + mfg: USHORT, + lmpSubversion: USHORT, + lmpVersion: UCHAR, +}} +pub type PBTH_RADIO_INFO = *mut BTH_RADIO_INFO; +STRUCT!{#[repr(packed)] struct BTH_LOCAL_RADIO_INFO { + localInfo: BTH_DEVICE_INFO, + flags: ULONG, + hciRevision: USHORT, + hciVersion: UCHAR, + radioInfo: BTH_RADIO_INFO, +}} +pub type PBTH_LOCAL_RADIO_INFO = *mut BTH_LOCAL_RADIO_INFO; +pub const SDP_CONNECT_CACHE: ULONG = 0x00000001; +pub const SDP_CONNECT_ALLOW_PIN: ULONG = 0x00000002; +pub const SDP_REQUEST_TO_DEFAULT: UCHAR = 0; +pub const SDP_REQUEST_TO_MIN: UCHAR = 10; +pub const SDP_REQUEST_TO_MAX: UCHAR = 45; +pub const SERVICE_OPTION_DO_NOT_PUBLISH: ULONG = 0x00000002; +pub const SERVICE_OPTION_NO_PUBLIC_BROWSE: ULONG = 0x00000004; +pub const SERVICE_OPTION_DO_NOT_PUBLISH_EIR: ULONG = 0x00000008; +pub const SERVICE_SECURITY_USE_DEFAULTS: ULONG = 0x00000000; +pub const SERVICE_SECURITY_NONE: ULONG = 0x00000001; +pub const SERVICE_SECURITY_AUTHORIZE: ULONG = 0x00000002; +pub const SERVICE_SECURITY_AUTHENTICATE: ULONG = 0x00000004; +pub const SERVICE_SECURITY_ENCRYPT_REQUIRED: ULONG = 0x00000010; +pub const SERVICE_SECURITY_ENCRYPT_OPTIONAL: ULONG = 0x00000020; +pub const SERVICE_SECURITY_DISABLED: ULONG = 0x10000000; +pub const SERVICE_SECURITY_NO_ASK: ULONG = 0x20000000; +pub const SDP_SEARCH_NO_PARSE_CHECK: ULONG = 0x00000001; +pub const SDP_SEARCH_NO_FORMAT_CHECK: ULONG = 0x00000002; +pub type HANDLE_SDP = ULONGLONG; +pub type PHANDLE_SDP = *mut ULONGLONG; +pub type HANDLE_SDP_TYPE = HANDLE_SDP; +pub const HANDLE_SDP_NULL: HANDLE_SDP = 0x0; +pub const HANDLE_SDP_LOCAL: HANDLE_SDP = -2i64 as u64; +STRUCT!{#[repr(packed)] struct BTH_SDP_CONNECT { + bthAddress: BTH_ADDR, + fSdpConnect: ULONG, + hConnection: HANDLE_SDP_TYPE, + requestTimeout: UCHAR, +}} +pub type PBTH_SDP_CONNECT = *mut BTH_SDP_CONNECT; +STRUCT!{#[repr(packed)] struct BTH_SDP_DISCONNECT { + hConnection: HANDLE_SDP_TYPE, +}} +pub type PBTH_SDP_DISCONNECT = *mut BTH_SDP_DISCONNECT; +STRUCT!{#[repr(packed)] struct BTH_SDP_RECORD { + fSecurity: ULONG, + fOptions: ULONG, + fCodService: ULONG, + recordLength: ULONG, + record: [UCHAR; 1], +}} +pub type PBTH_SDP_RECORD = *mut BTH_SDP_RECORD; +STRUCT!{#[repr(packed)] struct BTH_SDP_SERVICE_SEARCH_REQUEST { + hConnection: HANDLE_SDP_TYPE, + uuids: [SdpQueryUuid; MAX_UUIDS_IN_QUERY], +}} +pub type PBTH_SDP_SERVICE_SEARCH_REQUEST = *mut BTH_SDP_SERVICE_SEARCH_REQUEST; +STRUCT!{#[repr(packed)] struct BTH_SDP_ATTRIBUTE_SEARCH_REQUEST { + hConnection: HANDLE_SDP_TYPE, + searchFlags: ULONG, + recordHandle: ULONG, + range: [SdpAttributeRange; 1], +}} +pub type PBTH_SDP_ATTRIBUTE_SEARCH_REQUEST = *mut BTH_SDP_ATTRIBUTE_SEARCH_REQUEST; +STRUCT!{#[repr(packed)] struct BTH_SDP_SERVICE_ATTRIBUTE_SEARCH_REQUEST { + hConnection: HANDLE_SDP_TYPE, + searchFlags: ULONG, + uuids: [SdpQueryUuid; MAX_UUIDS_IN_QUERY], + range: [SdpAttributeRange; 1], +}} +pub type PBTH_SDP_SERVICE_ATTRIBUTE_SEARCH_REQUEST = *mut BTH_SDP_SERVICE_ATTRIBUTE_SEARCH_REQUEST; +STRUCT!{#[repr(packed)] struct BTH_SDP_STREAM_RESPONSE { + requiredSize: ULONG, + responseSize: ULONG, + response: [UCHAR; 1], +}} +pub type PBTH_SDP_STREAM_RESPONSE = *mut BTH_SDP_STREAM_RESPONSE; +STRUCT!{#[repr(packed)] struct BTH_COMMAND_HEADER { + OpCode: USHORT, + TotalParameterLength: UCHAR, +}} +pub type PBTH_COMMAND_HEADER = *mut BTH_COMMAND_HEADER; +STRUCT!{#[repr(packed)] struct BTH_VENDOR_SPECIFIC_COMMAND { + ManufacturerId: ULONG, + LmpVersion: UCHAR, + MatchAnySinglePattern: BOOLEAN, + HciHeader: BTH_COMMAND_HEADER, + Data: [UCHAR; 1], +}} +pub type PBTH_VENDOR_SPECIFIC_COMMAND = *mut BTH_VENDOR_SPECIFIC_COMMAND; +STRUCT!{#[repr(packed)] struct BTH_VENDOR_PATTERN { + Offset: UCHAR, + Size: UCHAR, + Pattern: [UCHAR; 1], +}} +pub type PBTH_VENDOR_PATTERN = *mut BTH_VENDOR_PATTERN; +STRUCT!{#[repr(packed)] struct BTH_VENDOR_EVENT_INFO { + BthAddress: BTH_ADDR, + EventSize: ULONG, + EventInfo: [UCHAR; 1], +}} +pub type PBTH_VENDOR_EVENT_INFO = *mut BTH_VENDOR_EVENT_INFO; +pub const BTH_HOST_FEATURE_ENHANCED_RETRANSMISSION_MODE: ULONGLONG = 0x0000000000000001; +pub const BTH_HOST_FEATURE_STREAMING_MODE: ULONGLONG = 0x0000000000000002; +pub const BTH_HOST_FEATURE_LOW_ENERGY: ULONGLONG = 0x0000000000000004; +pub const BTH_HOST_FEATURE_SCO_HCI: ULONGLONG = 0x0000000000000008; +pub const BTH_HOST_FEATURE_SCO_HCIBYPASS: ULONGLONG = 0x0000000000000010; +STRUCT!{#[repr(packed)] struct BTH_HOST_FEATURE_MASK { + Mask: ULONGLONG, + Reserved1: ULONGLONG, + Reserved2: ULONGLONG, +}} +pub type PBTH_HOST_FEATURE_MASK = *mut BTH_HOST_FEATURE_MASK; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/bthsdpdef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/bthsdpdef.rs new file mode 100644 index 0000000..4416fab --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/bthsdpdef.rs @@ -0,0 +1,68 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::GUID; +use shared::minwindef::{ULONG, USHORT}; +use shared::ntdef::{LONGLONG, ULONGLONG}; +STRUCT!{struct SDP_LARGE_INTEGER_16 { + LowPart: ULONGLONG, + HighPart: LONGLONG, +}} +STRUCT!{struct SDP_ULARGE_INTEGER_16 { + LowPart: ULONGLONG, + HighPart: ULONGLONG, +}} +pub type PSDP_ULARGE_INTEGER_16 = *mut SDP_ULARGE_INTEGER_16; +pub type LPSDP_ULARGE_INTEGER_16 = *mut SDP_ULARGE_INTEGER_16; +pub type PSDP_LARGE_INTEGER_16 = *mut SDP_LARGE_INTEGER_16; +pub type LPSDP_LARGE_INTEGER_16 = *mut SDP_LARGE_INTEGER_16; +ENUM!{enum NodeContainerType { + NodeContainerTypeSequence, + NodeContainerTypeAlternative, +}} +pub type SDP_ERROR = USHORT; +pub type PSDP_ERROR = *mut USHORT; +ENUM!{enum SDP_TYPE { + SDP_TYPE_NIL = 0x00, + SDP_TYPE_UINT = 0x01, + SDP_TYPE_INT = 0x02, + SDP_TYPE_UUID = 0x03, + SDP_TYPE_STRING = 0x04, + SDP_TYPE_BOOLEAN = 0x05, + SDP_TYPE_SEQUENCE = 0x06, + SDP_TYPE_ALTERNATIVE = 0x07, + SDP_TYPE_URL = 0x08, + SDP_TYPE_CONTAINER = 0x20, +}} +ENUM!{enum SDP_SPECIFICTYPE { + SDP_ST_NONE = 0x0000, + SDP_ST_UINT8 = 0x0010, + SDP_ST_UINT16 = 0x0110, + SDP_ST_UINT32 = 0x0210, + SDP_ST_UINT64 = 0x0310, + SDP_ST_UINT128 = 0x0410, + SDP_ST_INT8 = 0x0020, + SDP_ST_INT16 = 0x0120, + SDP_ST_INT32 = 0x0220, + SDP_ST_INT64 = 0x0320, + SDP_ST_INT128 = 0x0420, + SDP_ST_UUID16 = 0x0130, + SDP_ST_UUID32 = 0x0220, + SDP_ST_UUID128 = 0x0430, +}} +STRUCT!{struct SdpAttributeRange { + minAttribute: USHORT, + maxAttribute: USHORT, +}} +UNION!{union SdpQueryUuidUnion { + [u32; 4], + uuid128 uuid128_mut: GUID, + uuid32 uuid32_mut: ULONG, + uuid16 uuid16_mut: USHORT, +}} +STRUCT!{struct SdpQueryUuid { + u: SdpQueryUuidUnion, + uuidType: USHORT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/bugcodes.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/bugcodes.rs new file mode 100644 index 0000000..3e2bd49 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/bugcodes.rs @@ -0,0 +1,456 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Definitions of system bug check codes +use shared::ntdef::ULONG; +pub const HARDWARE_PROFILE_UNDOCKED_STRING: ULONG = 0x40010001; +pub const HARDWARE_PROFILE_DOCKED_STRING: ULONG = 0x40010002; +pub const HARDWARE_PROFILE_UNKNOWN_STRING: ULONG = 0x40010003; +pub const WINDOWS_NT_BANNER: ULONG = 0x4000007E; +pub const WINDOWS_NT_CSD_STRING: ULONG = 0x40000087; +pub const WINDOWS_NT_INFO_STRING: ULONG = 0x40000088; +pub const WINDOWS_NT_MP_STRING: ULONG = 0x40000089; +pub const THREAD_TERMINATE_HELD_MUTEX: ULONG = 0x4000008A; +pub const WINDOWS_NT_INFO_STRING_PLURAL: ULONG = 0x4000009D; +pub const WINDOWS_NT_RC_STRING: ULONG = 0x4000009E; +pub const APC_INDEX_MISMATCH: ULONG = 0x00000001; +pub const DEVICE_QUEUE_NOT_BUSY: ULONG = 0x00000002; +pub const INVALID_AFFINITY_SET: ULONG = 0x00000003; +pub const INVALID_DATA_ACCESS_TRAP: ULONG = 0x00000004; +pub const INVALID_PROCESS_ATTACH_ATTEMPT: ULONG = 0x00000005; +pub const INVALID_PROCESS_DETACH_ATTEMPT: ULONG = 0x00000006; +pub const INVALID_SOFTWARE_INTERRUPT: ULONG = 0x00000007; +pub const IRQL_NOT_DISPATCH_LEVEL: ULONG = 0x00000008; +pub const IRQL_NOT_GREATER_OR_EQUAL: ULONG = 0x00000009; +pub const IRQL_NOT_LESS_OR_EQUAL: ULONG = 0x0000000A; +pub const NO_EXCEPTION_HANDLING_SUPPORT: ULONG = 0x0000000B; +pub const MAXIMUM_WAIT_OBJECTS_EXCEEDED: ULONG = 0x0000000C; +pub const MUTEX_LEVEL_NUMBER_VIOLATION: ULONG = 0x0000000D; +pub const NO_USER_MODE_CONTEXT: ULONG = 0x0000000E; +pub const SPIN_LOCK_ALREADY_OWNED: ULONG = 0x0000000F; +pub const SPIN_LOCK_NOT_OWNED: ULONG = 0x00000010; +pub const THREAD_NOT_MUTEX_OWNER: ULONG = 0x00000011; +pub const TRAP_CAUSE_UNKNOWN: ULONG = 0x00000012; +pub const EMPTY_THREAD_REAPER_LIST: ULONG = 0x00000013; +pub const CREATE_DELETE_LOCK_NOT_LOCKED: ULONG = 0x00000014; +pub const LAST_CHANCE_CALLED_FROM_KMODE: ULONG = 0x00000015; +pub const CID_HANDLE_CREATION: ULONG = 0x00000016; +pub const CID_HANDLE_DELETION: ULONG = 0x00000017; +pub const REFERENCE_BY_POINTER: ULONG = 0x00000018; +pub const BAD_POOL_HEADER: ULONG = 0x00000019; +pub const MEMORY_MANAGEMENT: ULONG = 0x0000001A; +pub const PFN_SHARE_COUNT: ULONG = 0x0000001B; +pub const PFN_REFERENCE_COUNT: ULONG = 0x0000001C; +pub const NO_SPIN_LOCK_AVAILABLE: ULONG = 0x0000001D; +pub const KMODE_EXCEPTION_NOT_HANDLED: ULONG = 0x0000001E; +pub const SHARED_RESOURCE_CONV_ERROR: ULONG = 0x0000001F; +pub const KERNEL_APC_PENDING_DURING_EXIT: ULONG = 0x00000020; +pub const QUOTA_UNDERFLOW: ULONG = 0x00000021; +pub const FILE_SYSTEM: ULONG = 0x00000022; +pub const FAT_FILE_SYSTEM: ULONG = 0x00000023; +pub const NTFS_FILE_SYSTEM: ULONG = 0x00000024; +pub const NPFS_FILE_SYSTEM: ULONG = 0x00000025; +pub const CDFS_FILE_SYSTEM: ULONG = 0x00000026; +pub const RDR_FILE_SYSTEM: ULONG = 0x00000027; +pub const CORRUPT_ACCESS_TOKEN: ULONG = 0x00000028; +pub const SECURITY_SYSTEM: ULONG = 0x00000029; +pub const INCONSISTENT_IRP: ULONG = 0x0000002A; +pub const PANIC_STACK_SWITCH: ULONG = 0x0000002B; +pub const PORT_DRIVER_INTERNAL: ULONG = 0x0000002C; +pub const SCSI_DISK_DRIVER_INTERNAL: ULONG = 0x0000002D; +pub const DATA_BUS_ERROR: ULONG = 0x0000002E; +pub const INSTRUCTION_BUS_ERROR: ULONG = 0x0000002F; +pub const SET_OF_INVALID_CONTEXT: ULONG = 0x00000030; +pub const PHASE0_INITIALIZATION_FAILED: ULONG = 0x00000031; +pub const PHASE1_INITIALIZATION_FAILED: ULONG = 0x00000032; +pub const UNEXPECTED_INITIALIZATION_CALL: ULONG = 0x00000033; +pub const CACHE_MANAGER: ULONG = 0x00000034; +pub const NO_MORE_IRP_STACK_LOCATIONS: ULONG = 0x00000035; +pub const DEVICE_REFERENCE_COUNT_NOT_ZERO: ULONG = 0x00000036; +pub const FLOPPY_INTERNAL_ERROR: ULONG = 0x00000037; +pub const SERIAL_DRIVER_INTERNAL: ULONG = 0x00000038; +pub const SYSTEM_EXIT_OWNED_MUTEX: ULONG = 0x00000039; +pub const SYSTEM_UNWIND_PREVIOUS_USER: ULONG = 0x0000003A; +pub const SYSTEM_SERVICE_EXCEPTION: ULONG = 0x0000003B; +pub const INTERRUPT_UNWIND_ATTEMPTED: ULONG = 0x0000003C; +pub const INTERRUPT_EXCEPTION_NOT_HANDLED: ULONG = 0x0000003D; +pub const MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED: ULONG = 0x0000003E; +pub const NO_MORE_SYSTEM_PTES: ULONG = 0x0000003F; +pub const TARGET_MDL_TOO_SMALL: ULONG = 0x00000040; +pub const MUST_SUCCEED_POOL_EMPTY: ULONG = 0x00000041; +pub const ATDISK_DRIVER_INTERNAL: ULONG = 0x00000042; +pub const NO_SUCH_PARTITION: ULONG = 0x00000043; +pub const MULTIPLE_IRP_COMPLETE_REQUESTS: ULONG = 0x00000044; +pub const INSUFFICIENT_SYSTEM_MAP_REGS: ULONG = 0x00000045; +pub const DEREF_UNKNOWN_LOGON_SESSION: ULONG = 0x00000046; +pub const REF_UNKNOWN_LOGON_SESSION: ULONG = 0x00000047; +pub const CANCEL_STATE_IN_COMPLETED_IRP: ULONG = 0x00000048; +pub const PAGE_FAULT_WITH_INTERRUPTS_OFF: ULONG = 0x00000049; +pub const IRQL_GT_ZERO_AT_SYSTEM_SERVICE: ULONG = 0x0000004A; +pub const STREAMS_INTERNAL_ERROR: ULONG = 0x0000004B; +pub const FATAL_UNHANDLED_HARD_ERROR: ULONG = 0x0000004C; +pub const NO_PAGES_AVAILABLE: ULONG = 0x0000004D; +pub const PFN_LIST_CORRUPT: ULONG = 0x0000004E; +pub const NDIS_INTERNAL_ERROR: ULONG = 0x0000004F; +pub const PAGE_FAULT_IN_NONPAGED_AREA: ULONG = 0x00000050; +pub const PAGE_FAULT_IN_NONPAGED_AREA_M: ULONG = 0x10000050; +pub const REGISTRY_ERROR: ULONG = 0x00000051; +pub const MAILSLOT_FILE_SYSTEM: ULONG = 0x00000052; +pub const NO_BOOT_DEVICE: ULONG = 0x00000053; +pub const LM_SERVER_INTERNAL_ERROR: ULONG = 0x00000054; +pub const DATA_COHERENCY_EXCEPTION: ULONG = 0x00000055; +pub const INSTRUCTION_COHERENCY_EXCEPTION: ULONG = 0x00000056; +pub const XNS_INTERNAL_ERROR: ULONG = 0x00000057; +pub const VOLMGRX_INTERNAL_ERROR: ULONG = 0x00000058; +pub const PINBALL_FILE_SYSTEM: ULONG = 0x00000059; +pub const CRITICAL_SERVICE_FAILED: ULONG = 0x0000005A; +pub const SET_ENV_VAR_FAILED: ULONG = 0x0000005B; +pub const HAL_INITIALIZATION_FAILED: ULONG = 0x0000005C; +pub const UNSUPPORTED_PROCESSOR: ULONG = 0x0000005D; +pub const OBJECT_INITIALIZATION_FAILED: ULONG = 0x0000005E; +pub const SECURITY_INITIALIZATION_FAILED: ULONG = 0x0000005F; +pub const PROCESS_INITIALIZATION_FAILED: ULONG = 0x00000060; +pub const HAL1_INITIALIZATION_FAILED: ULONG = 0x00000061; +pub const OBJECT1_INITIALIZATION_FAILED: ULONG = 0x00000062; +pub const SECURITY1_INITIALIZATION_FAILED: ULONG = 0x00000063; +pub const SYMBOLIC_INITIALIZATION_FAILED: ULONG = 0x00000064; +pub const MEMORY1_INITIALIZATION_FAILED: ULONG = 0x00000065; +pub const CACHE_INITIALIZATION_FAILED: ULONG = 0x00000066; +pub const CONFIG_INITIALIZATION_FAILED: ULONG = 0x00000067; +pub const FILE_INITIALIZATION_FAILED: ULONG = 0x00000068; +pub const IO1_INITIALIZATION_FAILED: ULONG = 0x00000069; +pub const LPC_INITIALIZATION_FAILED: ULONG = 0x0000006A; +pub const PROCESS1_INITIALIZATION_FAILED: ULONG = 0x0000006B; +pub const REFMON_INITIALIZATION_FAILED: ULONG = 0x0000006C; +pub const SESSION1_INITIALIZATION_FAILED: ULONG = 0x0000006D; +pub const BOOTPROC_INITIALIZATION_FAILED: ULONG = 0x0000006E; +pub const VSL_INITIALIZATION_FAILED: ULONG = 0x0000006F; +pub const SOFT_RESTART_FATAL_ERROR: ULONG = 0x00000070; +pub const ASSIGN_DRIVE_LETTERS_FAILED: ULONG = 0x00000072; +pub const CONFIG_LIST_FAILED: ULONG = 0x00000073; +pub const BAD_SYSTEM_CONFIG_INFO: ULONG = 0x00000074; +pub const CANNOT_WRITE_CONFIGURATION: ULONG = 0x00000075; +pub const PROCESS_HAS_LOCKED_PAGES: ULONG = 0x00000076; +pub const KERNEL_STACK_INPAGE_ERROR: ULONG = 0x00000077; +pub const PHASE0_EXCEPTION: ULONG = 0x00000078; +pub const MISMATCHED_HAL: ULONG = 0x00000079; +pub const KERNEL_DATA_INPAGE_ERROR: ULONG = 0x0000007A; +pub const INACCESSIBLE_BOOT_DEVICE: ULONG = 0x0000007B; +pub const BUGCODE_NDIS_DRIVER: ULONG = 0x0000007C; +pub const INSTALL_MORE_MEMORY: ULONG = 0x0000007D; +pub const SYSTEM_THREAD_EXCEPTION_NOT_HANDLED: ULONG = 0x0000007E; +pub const SYSTEM_THREAD_EXCEPTION_NOT_HANDLED_M: ULONG = 0x1000007E; +pub const UNEXPECTED_KERNEL_MODE_TRAP: ULONG = 0x0000007F; +pub const UNEXPECTED_KERNEL_MODE_TRAP_M: ULONG = 0x1000007F; +pub const NMI_HARDWARE_FAILURE: ULONG = 0x00000080; +pub const SPIN_LOCK_INIT_FAILURE: ULONG = 0x00000081; +pub const DFS_FILE_SYSTEM: ULONG = 0x00000082; +pub const OFS_FILE_SYSTEM: ULONG = 0x00000083; +pub const RECOM_DRIVER: ULONG = 0x00000084; +pub const SETUP_FAILURE: ULONG = 0x00000085; +pub const AUDIT_FAILURE: ULONG = 0x00000086; +pub const MBR_CHECKSUM_MISMATCH: ULONG = 0x0000008B; +pub const KERNEL_MODE_EXCEPTION_NOT_HANDLED: ULONG = 0x0000008E; +pub const KERNEL_MODE_EXCEPTION_NOT_HANDLED_M: ULONG = 0x1000008E; +pub const PP0_INITIALIZATION_FAILED: ULONG = 0x0000008F; +pub const PP1_INITIALIZATION_FAILED: ULONG = 0x00000090; +pub const WIN32K_INIT_OR_RIT_FAILURE: ULONG = 0x00000091; +pub const UP_DRIVER_ON_MP_SYSTEM: ULONG = 0x00000092; +pub const INVALID_KERNEL_HANDLE: ULONG = 0x00000093; +pub const KERNEL_STACK_LOCKED_AT_EXIT: ULONG = 0x00000094; +pub const PNP_INTERNAL_ERROR: ULONG = 0x00000095; +pub const INVALID_WORK_QUEUE_ITEM: ULONG = 0x00000096; +pub const BOUND_IMAGE_UNSUPPORTED: ULONG = 0x00000097; +pub const END_OF_NT_EVALUATION_PERIOD: ULONG = 0x00000098; +pub const INVALID_REGION_OR_SEGMENT: ULONG = 0x00000099; +pub const SYSTEM_LICENSE_VIOLATION: ULONG = 0x0000009A; +pub const UDFS_FILE_SYSTEM: ULONG = 0x0000009B; +pub const MACHINE_CHECK_EXCEPTION: ULONG = 0x0000009C; +pub const USER_MODE_HEALTH_MONITOR: ULONG = 0x0000009E; +pub const DRIVER_POWER_STATE_FAILURE: ULONG = 0x0000009F; +pub const INTERNAL_POWER_ERROR: ULONG = 0x000000A0; +pub const PCI_BUS_DRIVER_INTERNAL: ULONG = 0x000000A1; +pub const MEMORY_IMAGE_CORRUPT: ULONG = 0x000000A2; +pub const ACPI_DRIVER_INTERNAL: ULONG = 0x000000A3; +pub const CNSS_FILE_SYSTEM_FILTER: ULONG = 0x000000A4; +pub const ACPI_BIOS_ERROR: ULONG = 0x000000A5; +pub const FP_EMULATION_ERROR: ULONG = 0x000000A6; +pub const BAD_EXHANDLE: ULONG = 0x000000A7; +pub const BOOTING_IN_SAFEMODE_MINIMAL: ULONG = 0x000000A8; +pub const BOOTING_IN_SAFEMODE_NETWORK: ULONG = 0x000000A9; +pub const BOOTING_IN_SAFEMODE_DSREPAIR: ULONG = 0x000000AA; +pub const SESSION_HAS_VALID_POOL_ON_EXIT: ULONG = 0x000000AB; +pub const HAL_MEMORY_ALLOCATION: ULONG = 0x000000AC; +pub const VIDEO_DRIVER_DEBUG_REPORT_REQUEST: ULONG = 0x400000AD; +pub const BGI_DETECTED_VIOLATION: ULONG = 0x000000B1; +pub const VIDEO_DRIVER_INIT_FAILURE: ULONG = 0x000000B4; +pub const BOOTLOG_LOADED: ULONG = 0x000000B5; +pub const BOOTLOG_NOT_LOADED: ULONG = 0x000000B6; +pub const BOOTLOG_ENABLED: ULONG = 0x000000B7; +pub const ATTEMPTED_SWITCH_FROM_DPC: ULONG = 0x000000B8; +pub const CHIPSET_DETECTED_ERROR: ULONG = 0x000000B9; +pub const SESSION_HAS_VALID_VIEWS_ON_EXIT: ULONG = 0x000000BA; +pub const NETWORK_BOOT_INITIALIZATION_FAILED: ULONG = 0x000000BB; +pub const NETWORK_BOOT_DUPLICATE_ADDRESS: ULONG = 0x000000BC; +pub const INVALID_HIBERNATED_STATE: ULONG = 0x000000BD; +pub const ATTEMPTED_WRITE_TO_READONLY_MEMORY: ULONG = 0x000000BE; +pub const MUTEX_ALREADY_OWNED: ULONG = 0x000000BF; +pub const PCI_CONFIG_SPACE_ACCESS_FAILURE: ULONG = 0x000000C0; +pub const SPECIAL_POOL_DETECTED_MEMORY_CORRUPTION: ULONG = 0x000000C1; +pub const BAD_POOL_CALLER: ULONG = 0x000000C2; +pub const SYSTEM_IMAGE_BAD_SIGNATURE: ULONG = 0x000000C3; +pub const DRIVER_VERIFIER_DETECTED_VIOLATION: ULONG = 0x000000C4; +pub const DRIVER_CORRUPTED_EXPOOL: ULONG = 0x000000C5; +pub const DRIVER_CAUGHT_MODIFYING_FREED_POOL: ULONG = 0x000000C6; +pub const TIMER_OR_DPC_INVALID: ULONG = 0x000000C7; +pub const IRQL_UNEXPECTED_VALUE: ULONG = 0x000000C8; +pub const DRIVER_VERIFIER_IOMANAGER_VIOLATION: ULONG = 0x000000C9; +pub const PNP_DETECTED_FATAL_ERROR: ULONG = 0x000000CA; +pub const DRIVER_LEFT_LOCKED_PAGES_IN_PROCESS: ULONG = 0x000000CB; +pub const PAGE_FAULT_IN_FREED_SPECIAL_POOL: ULONG = 0x000000CC; +pub const PAGE_FAULT_BEYOND_END_OF_ALLOCATION: ULONG = 0x000000CD; +pub const DRIVER_UNLOADED_WITHOUT_CANCELLING_PENDING_OPERATIONS: ULONG = 0x000000CE; +pub const TERMINAL_SERVER_DRIVER_MADE_INCORRECT_MEMORY_REFERENCE: ULONG = 0x000000CF; +pub const DRIVER_CORRUPTED_MMPOOL: ULONG = 0x000000D0; +pub const DRIVER_IRQL_NOT_LESS_OR_EQUAL: ULONG = 0x000000D1; +pub const BUGCODE_ID_DRIVER: ULONG = 0x000000D2; +pub const DRIVER_PORTION_MUST_BE_NONPAGED: ULONG = 0x000000D3; +pub const SYSTEM_SCAN_AT_RAISED_IRQL_CAUGHT_IMPROPER_DRIVER_UNLOAD: ULONG = 0x000000D4; +pub const DRIVER_PAGE_FAULT_IN_FREED_SPECIAL_POOL: ULONG = 0x000000D5; +pub const DRIVER_PAGE_FAULT_BEYOND_END_OF_ALLOCATION: ULONG = 0x000000D6; +pub const DRIVER_PAGE_FAULT_BEYOND_END_OF_ALLOCATION_M: ULONG = 0x100000D6; +pub const DRIVER_UNMAPPING_INVALID_VIEW: ULONG = 0x000000D7; +pub const DRIVER_USED_EXCESSIVE_PTES: ULONG = 0x000000D8; +pub const LOCKED_PAGES_TRACKER_CORRUPTION: ULONG = 0x000000D9; +pub const SYSTEM_PTE_MISUSE: ULONG = 0x000000DA; +pub const DRIVER_CORRUPTED_SYSPTES: ULONG = 0x000000DB; +pub const DRIVER_INVALID_STACK_ACCESS: ULONG = 0x000000DC; +pub const POOL_CORRUPTION_IN_FILE_AREA: ULONG = 0x000000DE; +pub const IMPERSONATING_WORKER_THREAD: ULONG = 0x000000DF; +pub const ACPI_BIOS_FATAL_ERROR: ULONG = 0x000000E0; +pub const WORKER_THREAD_RETURNED_AT_BAD_IRQL: ULONG = 0x000000E1; +pub const MANUALLY_INITIATED_CRASH: ULONG = 0x000000E2; +pub const RESOURCE_NOT_OWNED: ULONG = 0x000000E3; +pub const WORKER_INVALID: ULONG = 0x000000E4; +pub const POWER_FAILURE_SIMULATE: ULONG = 0x000000E5; +pub const DRIVER_VERIFIER_DMA_VIOLATION: ULONG = 0x000000E6; +pub const INVALID_FLOATING_POINT_STATE: ULONG = 0x000000E7; +pub const INVALID_CANCEL_OF_FILE_OPEN: ULONG = 0x000000E8; +pub const ACTIVE_EX_WORKER_THREAD_TERMINATION: ULONG = 0x000000E9; +pub const SAVER_UNSPECIFIED: ULONG = 0x0000F000; +pub const SAVER_BLANKSCREEN: ULONG = 0x0000F002; +pub const SAVER_INPUT: ULONG = 0x0000F003; +pub const SAVER_WATCHDOG: ULONG = 0x0000F004; +pub const SAVER_STARTNOTVISIBLE: ULONG = 0x0000F005; +pub const SAVER_NAVIGATIONMODEL: ULONG = 0x0000F006; +pub const SAVER_OUTOFMEMORY: ULONG = 0x0000F007; +pub const SAVER_GRAPHICS: ULONG = 0x0000F008; +pub const SAVER_NAVSERVERTIMEOUT: ULONG = 0x0000F009; +pub const SAVER_CHROMEPROCESSCRASH: ULONG = 0x0000F00A; +pub const SAVER_NOTIFICATIONDISMISSAL: ULONG = 0x0000F00B; +pub const SAVER_SPEECHDISMISSAL: ULONG = 0x0000F00C; +pub const SAVER_CALLDISMISSAL: ULONG = 0x0000F00D; +pub const SAVER_APPBARDISMISSAL: ULONG = 0x0000F00E; +pub const SAVER_RILADAPTATIONCRASH: ULONG = 0x0000F00F; +pub const SAVER_APPLISTUNREACHABLE: ULONG = 0x0000F010; +pub const SAVER_REPORTNOTIFICATIONFAILURE: ULONG = 0x0000F011; +pub const SAVER_UNEXPECTEDSHUTDOWN: ULONG = 0x0000F012; +pub const SAVER_RPCFAILURE: ULONG = 0x0000F013; +pub const SAVER_AUXILIARYFULLDUMP: ULONG = 0x0000F014; +pub const SAVER_ACCOUNTPROVSVCINITFAILURE: ULONG = 0x0000F015; +pub const SAVER_MTBFCOMMANDTIMEOUT: ULONG = 0x00000315; +pub const SAVER_MTBFCOMMANDHANG: ULONG = 0x0000F101; +pub const SAVER_MTBFPASSBUGCHECK: ULONG = 0x0000F102; +pub const SAVER_MTBFIOERROR: ULONG = 0x0000F103; +pub const SAVER_RENDERTHREADHANG: ULONG = 0x0000F200; +pub const SAVER_RENDERMOBILEUIOOM: ULONG = 0x0000F201; +pub const SAVER_DEVICEUPDATEUNSPECIFIED: ULONG = 0x0000F300; +pub const SAVER_AUDIODRIVERHANG: ULONG = 0x0000F400; +pub const SAVER_BATTERYPULLOUT: ULONG = 0x0000F500; +pub const SAVER_MEDIACORETESTHANG: ULONG = 0x0000F600; +pub const SAVER_RESOURCEMANAGEMENT: ULONG = 0x0000F700; +pub const SAVER_CAPTURESERVICE: ULONG = 0x0000F800; +pub const SAVER_WAITFORSHELLREADY: ULONG = 0x0000F900; +pub const SAVER_NONRESPONSIVEPROCESS: ULONG = 0x00000194; +pub const SAVER_SICKAPPLICATION: ULONG = 0x00008866; +pub const THREAD_STUCK_IN_DEVICE_DRIVER: ULONG = 0x000000EA; +pub const THREAD_STUCK_IN_DEVICE_DRIVER_M: ULONG = 0x100000EA; +pub const DIRTY_MAPPED_PAGES_CONGESTION: ULONG = 0x000000EB; +pub const SESSION_HAS_VALID_SPECIAL_POOL_ON_EXIT: ULONG = 0x000000EC; +pub const UNMOUNTABLE_BOOT_VOLUME: ULONG = 0x000000ED; +pub const CRITICAL_PROCESS_DIED: ULONG = 0x000000EF; +pub const STORAGE_MINIPORT_ERROR: ULONG = 0x000000F0; +pub const SCSI_VERIFIER_DETECTED_VIOLATION: ULONG = 0x000000F1; +pub const HARDWARE_INTERRUPT_STORM: ULONG = 0x000000F2; +pub const DISORDERLY_SHUTDOWN: ULONG = 0x000000F3; +pub const CRITICAL_OBJECT_TERMINATION: ULONG = 0x000000F4; +pub const FLTMGR_FILE_SYSTEM: ULONG = 0x000000F5; +pub const PCI_VERIFIER_DETECTED_VIOLATION: ULONG = 0x000000F6; +pub const DRIVER_OVERRAN_STACK_BUFFER: ULONG = 0x000000F7; +pub const RAMDISK_BOOT_INITIALIZATION_FAILED: ULONG = 0x000000F8; +pub const DRIVER_RETURNED_STATUS_REPARSE_FOR_VOLUME_OPEN: ULONG = 0x000000F9; +pub const HTTP_DRIVER_CORRUPTED: ULONG = 0x000000FA; +pub const RECURSIVE_MACHINE_CHECK: ULONG = 0x000000FB; +pub const ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY: ULONG = 0x000000FC; +pub const DIRTY_NOWRITE_PAGES_CONGESTION: ULONG = 0x000000FD; +pub const BUGCODE_USB_DRIVER: ULONG = 0x000000FE; +pub const BC_BLUETOOTH_VERIFIER_FAULT: ULONG = 0x00000BFE; +pub const BC_BTHMINI_VERIFIER_FAULT: ULONG = 0x00000BFF; +pub const RESERVE_QUEUE_OVERFLOW: ULONG = 0x000000FF; +pub const LOADER_BLOCK_MISMATCH: ULONG = 0x00000100; +pub const CLOCK_WATCHDOG_TIMEOUT: ULONG = 0x00000101; +pub const DPC_WATCHDOG_TIMEOUT: ULONG = 0x00000102; +pub const MUP_FILE_SYSTEM: ULONG = 0x00000103; +pub const AGP_INVALID_ACCESS: ULONG = 0x00000104; +pub const AGP_GART_CORRUPTION: ULONG = 0x00000105; +pub const AGP_ILLEGALLY_REPROGRAMMED: ULONG = 0x00000106; +pub const KERNEL_EXPAND_STACK_ACTIVE: ULONG = 0x00000107; +pub const THIRD_PARTY_FILE_SYSTEM_FAILURE: ULONG = 0x00000108; +pub const CRITICAL_STRUCTURE_CORRUPTION: ULONG = 0x00000109; +pub const APP_TAGGING_INITIALIZATION_FAILED: ULONG = 0x0000010A; +pub const DFSC_FILE_SYSTEM: ULONG = 0x0000010B; +pub const FSRTL_EXTRA_CREATE_PARAMETER_VIOLATION: ULONG = 0x0000010C; +pub const WDF_VIOLATION: ULONG = 0x0000010D; +pub const VIDEO_MEMORY_MANAGEMENT_INTERNAL: ULONG = 0x0000010E; +pub const DRIVER_INVALID_CRUNTIME_PARAMETER: ULONG = 0x00000110; +pub const RECURSIVE_NMI: ULONG = 0x00000111; +pub const MSRPC_STATE_VIOLATION: ULONG = 0x00000112; +pub const VIDEO_DXGKRNL_FATAL_ERROR: ULONG = 0x00000113; +pub const VIDEO_SHADOW_DRIVER_FATAL_ERROR: ULONG = 0x00000114; +pub const AGP_INTERNAL: ULONG = 0x00000115; +pub const VIDEO_TDR_FAILURE: ULONG = 0x00000116; +pub const VIDEO_TDR_TIMEOUT_DETECTED: ULONG = 0x00000117; +pub const NTHV_GUEST_ERROR: ULONG = 0x00000118; +pub const VIDEO_SCHEDULER_INTERNAL_ERROR: ULONG = 0x00000119; +pub const EM_INITIALIZATION_ERROR: ULONG = 0x0000011A; +pub const DRIVER_RETURNED_HOLDING_CANCEL_LOCK: ULONG = 0x0000011B; +pub const ATTEMPTED_WRITE_TO_CM_PROTECTED_STORAGE: ULONG = 0x0000011C; +pub const EVENT_TRACING_FATAL_ERROR: ULONG = 0x0000011D; +pub const TOO_MANY_RECURSIVE_FAULTS: ULONG = 0x0000011E; +pub const INVALID_DRIVER_HANDLE: ULONG = 0x0000011F; +pub const BITLOCKER_FATAL_ERROR: ULONG = 0x00000120; +pub const DRIVER_VIOLATION: ULONG = 0x00000121; +pub const WHEA_INTERNAL_ERROR: ULONG = 0x00000122; +pub const CRYPTO_SELF_TEST_FAILURE: ULONG = 0x00000123; +pub const WHEA_UNCORRECTABLE_ERROR: ULONG = 0x00000124; +pub const NMR_INVALID_STATE: ULONG = 0x00000125; +pub const NETIO_INVALID_POOL_CALLER: ULONG = 0x00000126; +pub const PAGE_NOT_ZERO: ULONG = 0x00000127; +pub const WORKER_THREAD_RETURNED_WITH_BAD_IO_PRIORITY: ULONG = 0x00000128; +pub const WORKER_THREAD_RETURNED_WITH_BAD_PAGING_IO_PRIORITY: ULONG = 0x00000129; +pub const MUI_NO_VALID_SYSTEM_LANGUAGE: ULONG = 0x0000012A; +pub const FAULTY_HARDWARE_CORRUPTED_PAGE: ULONG = 0x0000012B; +pub const EXFAT_FILE_SYSTEM: ULONG = 0x0000012C; +pub const VOLSNAP_OVERLAPPED_TABLE_ACCESS: ULONG = 0x0000012D; +pub const INVALID_MDL_RANGE: ULONG = 0x0000012E; +pub const VHD_BOOT_INITIALIZATION_FAILED: ULONG = 0x0000012F; +pub const DYNAMIC_ADD_PROCESSOR_MISMATCH: ULONG = 0x00000130; +pub const INVALID_EXTENDED_PROCESSOR_STATE: ULONG = 0x00000131; +pub const RESOURCE_OWNER_POINTER_INVALID: ULONG = 0x00000132; +pub const DPC_WATCHDOG_VIOLATION: ULONG = 0x00000133; +pub const DRIVE_EXTENDER: ULONG = 0x00000134; +pub const REGISTRY_FILTER_DRIVER_EXCEPTION: ULONG = 0x00000135; +pub const VHD_BOOT_HOST_VOLUME_NOT_ENOUGH_SPACE: ULONG = 0x00000136; +pub const WIN32K_HANDLE_MANAGER: ULONG = 0x00000137; +pub const GPIO_CONTROLLER_DRIVER_ERROR: ULONG = 0x00000138; +pub const KERNEL_SECURITY_CHECK_FAILURE: ULONG = 0x00000139; +pub const KERNEL_MODE_HEAP_CORRUPTION: ULONG = 0x0000013A; +pub const PASSIVE_INTERRUPT_ERROR: ULONG = 0x0000013B; +pub const INVALID_IO_BOOST_STATE: ULONG = 0x0000013C; +pub const CRITICAL_INITIALIZATION_FAILURE: ULONG = 0x0000013D; +pub const ERRATA_WORKAROUND_UNSUCCESSFUL: ULONG = 0x0000013E; +pub const STORAGE_DEVICE_ABNORMALITY_DETECTED: ULONG = 0x00000140; +pub const VIDEO_ENGINE_TIMEOUT_DETECTED: ULONG = 0x00000141; +pub const VIDEO_TDR_APPLICATION_BLOCKED: ULONG = 0x00000142; +pub const PROCESSOR_DRIVER_INTERNAL: ULONG = 0x00000143; +pub const BUGCODE_USB3_DRIVER: ULONG = 0x00000144; +pub const SECURE_BOOT_VIOLATION: ULONG = 0x00000145; +pub const NDIS_NET_BUFFER_LIST_INFO_ILLEGALLY_TRANSFERRED: ULONG = 0x00000146; +pub const ABNORMAL_RESET_DETECTED: ULONG = 0x00000147; +pub const IO_OBJECT_INVALID: ULONG = 0x00000148; +pub const REFS_FILE_SYSTEM: ULONG = 0x00000149; +pub const KERNEL_WMI_INTERNAL: ULONG = 0x0000014A; +pub const SOC_SUBSYSTEM_FAILURE: ULONG = 0x0000014B; +pub const FATAL_ABNORMAL_RESET_ERROR: ULONG = 0x0000014C; +pub const EXCEPTION_SCOPE_INVALID: ULONG = 0x0000014D; +pub const SOC_CRITICAL_DEVICE_REMOVED: ULONG = 0x0000014E; +pub const PDC_WATCHDOG_TIMEOUT: ULONG = 0x0000014F; +pub const TCPIP_AOAC_NIC_ACTIVE_REFERENCE_LEAK: ULONG = 0x00000150; +pub const UNSUPPORTED_INSTRUCTION_MODE: ULONG = 0x00000151; +pub const INVALID_PUSH_LOCK_FLAGS: ULONG = 0x00000152; +pub const KERNEL_LOCK_ENTRY_LEAKED_ON_THREAD_TERMINATION: ULONG = 0x00000153; +pub const UNEXPECTED_STORE_EXCEPTION: ULONG = 0x00000154; +pub const OS_DATA_TAMPERING: ULONG = 0x00000155; +pub const WINSOCK_DETECTED_HUNG_CLOSESOCKET_LIVEDUMP: ULONG = 0x00000156; +pub const KERNEL_THREAD_PRIORITY_FLOOR_VIOLATION: ULONG = 0x00000157; +pub const ILLEGAL_IOMMU_PAGE_FAULT: ULONG = 0x00000158; +pub const HAL_ILLEGAL_IOMMU_PAGE_FAULT: ULONG = 0x00000159; +pub const SDBUS_INTERNAL_ERROR: ULONG = 0x0000015A; +pub const WORKER_THREAD_RETURNED_WITH_SYSTEM_PAGE_PRIORITY_ACTIVE: ULONG = 0x0000015B; +pub const PDC_WATCHDOG_TIMEOUT_LIVEDUMP: ULONG = 0x0000015C; +pub const SOC_SUBSYSTEM_FAILURE_LIVEDUMP: ULONG = 0x0000015D; +pub const BUGCODE_NDIS_DRIVER_LIVE_DUMP: ULONG = 0x0000015E; +pub const CONNECTED_STANDBY_WATCHDOG_TIMEOUT_LIVEDUMP: ULONG = 0x0000015F; +pub const WIN32K_ATOMIC_CHECK_FAILURE: ULONG = 0x00000160; +pub const LIVE_SYSTEM_DUMP: ULONG = 0x00000161; +pub const KERNEL_AUTO_BOOST_INVALID_LOCK_RELEASE: ULONG = 0x00000162; +pub const WORKER_THREAD_TEST_CONDITION: ULONG = 0x00000163; +pub const WIN32K_CRITICAL_FAILURE: ULONG = 0x00000164; +pub const CLUSTER_CSV_STATUS_IO_TIMEOUT_LIVEDUMP: ULONG = 0x00000165; +pub const CLUSTER_RESOURCE_CALL_TIMEOUT_LIVEDUMP: ULONG = 0x00000166; +pub const CLUSTER_CSV_SNAPSHOT_DEVICE_INFO_TIMEOUT_LIVEDUMP: ULONG = 0x00000167; +pub const CLUSTER_CSV_STATE_TRANSITION_TIMEOUT_LIVEDUMP: ULONG = 0x00000168; +pub const CLUSTER_CSV_VOLUME_ARRIVAL_LIVEDUMP: ULONG = 0x00000169; +pub const CLUSTER_CSV_VOLUME_REMOVAL_LIVEDUMP: ULONG = 0x0000016A; +pub const CLUSTER_CSV_CLUSTER_WATCHDOG_LIVEDUMP: ULONG = 0x0000016B; +pub const INVALID_RUNDOWN_PROTECTION_FLAGS: ULONG = 0x0000016C; +pub const INVALID_SLOT_ALLOCATOR_FLAGS: ULONG = 0x0000016D; +pub const ERESOURCE_INVALID_RELEASE: ULONG = 0x0000016E; +pub const CLUSTER_CSV_STATE_TRANSITION_INTERVAL_TIMEOUT_LIVEDUMP: ULONG = 0x0000016F; +pub const CLUSTER_CSV_CLUSSVC_DISCONNECT_WATCHDOG: ULONG = 0x00000170; +pub const CRYPTO_LIBRARY_INTERNAL_ERROR: ULONG = 0x00000171; +pub const COREMSGCALL_INTERNAL_ERROR: ULONG = 0x00000173; +pub const COREMSG_INTERNAL_ERROR: ULONG = 0x00000174; +pub const PREVIOUS_FATAL_ABNORMAL_RESET_ERROR: ULONG = 0x00000175; +pub const ELAM_DRIVER_DETECTED_FATAL_ERROR: ULONG = 0x00000178; +pub const PDC_LOCK_WATCHDOG_LIVEDUMP: ULONG = 0x0000017C; +pub const PDC_UNEXPECTED_REVOCATION_LIVEDUMP: ULONG = 0x0000017D; +pub const WVR_LIVEDUMP_REPLICATION_IOCONTEXT_TIMEOUT: ULONG = 0x00000180; +pub const WVR_LIVEDUMP_STATE_TRANSITION_TIMEOUT: ULONG = 0x00000181; +pub const WVR_LIVEDUMP_RECOVERY_IOCONTEXT_TIMEOUT: ULONG = 0x00000182; +pub const WVR_LIVEDUMP_APP_IO_TIMEOUT: ULONG = 0x00000183; +pub const WVR_LIVEDUMP_MANUALLY_INITIATED: ULONG = 0x00000184; +pub const WVR_LIVEDUMP_STATE_FAILURE: ULONG = 0x00000185; +pub const WVR_LIVEDUMP_CRITICAL_ERROR: ULONG = 0x00000186; +pub const VIDEO_DWMINIT_TIMEOUT_FALLBACK_BDD: ULONG = 0x00000187; +pub const CLUSTER_CSVFS_LIVEDUMP: ULONG = 0x00000188; +pub const BAD_OBJECT_HEADER: ULONG = 0x00000189; +pub const SILO_CORRUPT: ULONG = 0x0000018A; +pub const SECURE_KERNEL_ERROR: ULONG = 0x0000018B; +pub const HYPERGUARD_VIOLATION: ULONG = 0x0000018C; +pub const WIN32K_CRITICAL_FAILURE_LIVEDUMP: ULONG = 0x00000190; +pub const PF_DETECTED_CORRUPTION: ULONG = 0x00000191; +pub const KERNEL_AUTO_BOOST_LOCK_ACQUISITION_WITH_RAISED_IRQL: ULONG = 0x00000192; +pub const VIDEO_DXGKRNL_LIVEDUMP: ULONG = 0x00000193; +pub const KERNEL_STORAGE_SLOT_IN_USE: ULONG = 0x00000199; +pub const SMB_SERVER_LIVEDUMP: ULONG = 0x00000195; +pub const LOADER_ROLLBACK_DETECTED: ULONG = 0x00000196; +pub const WIN32K_SECURITY_FAILURE: ULONG = 0x00000197; +pub const UFX_LIVEDUMP: ULONG = 0x00000198; +pub const WORKER_THREAD_RETURNED_WHILE_ATTACHED_TO_SILO: ULONG = 0x0000019A; +pub const TTM_FATAL_ERROR: ULONG = 0x0000019B; +pub const WIN32K_POWER_WATCHDOG_TIMEOUT: ULONG = 0x0000019C; +pub const CLUSTER_SVHDX_LIVEDUMP: ULONG = 0x0000019D; +pub const DRIVER_VERIFIER_DETECTED_VIOLATION_LIVEDUMP: ULONG = 0x000001C4; +pub const IO_THREADPOOL_DEADLOCK_LIVEDUMP: ULONG = 0x000001C5; +pub const XBOX_CORRUPTED_IMAGE: ULONG = 0x00000357; +pub const XBOX_INVERTED_FUNCTION_TABLE_OVERFLOW: ULONG = 0x00000358; +pub const XBOX_CORRUPTED_IMAGE_BASE: ULONG = 0x00000359; +pub const XBOX_360_SYSTEM_CRASH: ULONG = 0x00000360; +pub const XBOX_360_SYSTEM_CRASH_RESERVED: ULONG = 0x00000420; +pub const HYPERVISOR_ERROR: ULONG = 0x00020001; +pub const WINLOGON_FATAL_ERROR: ULONG = 0xC000021A; +pub const MANUALLY_INITIATED_CRASH1: ULONG = 0xDEADDEAD; +pub const BUGCHECK_CONTEXT_MODIFIER: ULONG = 0x80000000; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/cderr.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/cderr.rs new file mode 100644 index 0000000..07ea187 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/cderr.rs @@ -0,0 +1,44 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Common dialog error return codes +use shared::minwindef::DWORD; +pub const CDERR_DIALOGFAILURE: DWORD = 0xFFFF; +pub const CDERR_GENERALCODES: DWORD = 0x0000; +pub const CDERR_STRUCTSIZE: DWORD = 0x0001; +pub const CDERR_INITIALIZATION: DWORD = 0x0002; +pub const CDERR_NOTEMPLATE: DWORD = 0x0003; +pub const CDERR_NOHINSTANCE: DWORD = 0x0004; +pub const CDERR_LOADSTRFAILURE: DWORD = 0x0005; +pub const CDERR_FINDRESFAILURE: DWORD = 0x0006; +pub const CDERR_LOADRESFAILURE: DWORD = 0x0007; +pub const CDERR_LOCKRESFAILURE: DWORD = 0x0008; +pub const CDERR_MEMALLOCFAILURE: DWORD = 0x0009; +pub const CDERR_MEMLOCKFAILURE: DWORD = 0x000A; +pub const CDERR_NOHOOK: DWORD = 0x000B; +pub const CDERR_REGISTERMSGFAIL: DWORD = 0x000C; +pub const PDERR_PRINTERCODES: DWORD = 0x1000; +pub const PDERR_SETUPFAILURE: DWORD = 0x1001; +pub const PDERR_PARSEFAILURE: DWORD = 0x1002; +pub const PDERR_RETDEFFAILURE: DWORD = 0x1003; +pub const PDERR_LOADDRVFAILURE: DWORD = 0x1004; +pub const PDERR_GETDEVMODEFAIL: DWORD = 0x1005; +pub const PDERR_INITFAILURE: DWORD = 0x1006; +pub const PDERR_NODEVICES: DWORD = 0x1007; +pub const PDERR_NODEFAULTPRN: DWORD = 0x1008; +pub const PDERR_DNDMMISMATCH: DWORD = 0x1009; +pub const PDERR_CREATEICFAILURE: DWORD = 0x100A; +pub const PDERR_PRINTERNOTFOUND: DWORD = 0x100B; +pub const PDERR_DEFAULTDIFFERENT: DWORD = 0x100C; +pub const CFERR_CHOOSEFONTCODES: DWORD = 0x2000; +pub const CFERR_NOFONTS: DWORD = 0x2001; +pub const CFERR_MAXLESSTHANMIN: DWORD = 0x2002; +pub const FNERR_FILENAMECODES: DWORD = 0x3000; +pub const FNERR_SUBCLASSFAILURE: DWORD = 0x3001; +pub const FNERR_INVALIDFILENAME: DWORD = 0x3002; +pub const FNERR_BUFFERTOOSMALL: DWORD = 0x3003; +pub const FRERR_FINDREPLACECODES: DWORD = 0x4000; +pub const FRERR_BUFFERLENGTHZERO: DWORD = 0x4001; +pub const CCERR_CHOOSECOLORCODES: DWORD = 0x5000; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/cfg.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/cfg.rs new file mode 100644 index 0000000..4abe383 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/cfg.rs @@ -0,0 +1,138 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! common Configuration Manager definitions for both user mode and kernel mode code +use shared::minwindef::{DWORD, ULONG}; +ENUM!{enum PNP_VETO_TYPE { + PNP_VetoTypeUnknown, + PNP_VetoLegacyDevice, + PNP_VetoPendingClose, + PNP_VetoWindowsApp, + PNP_VetoWindowsService, + PNP_VetoOutstandingOpen, + PNP_VetoDevice, + PNP_VetoDriver, + PNP_VetoIllegalDeviceRequest, + PNP_VetoInsufficientPower, + PNP_VetoNonDisableable, + PNP_VetoLegacyDriver, + PNP_VetoInsufficientRights, +}} +pub type PPNP_VETO_TYPE = *mut PNP_VETO_TYPE; +pub const CM_PROB_NOT_CONFIGURED: DWORD = 0x00000001; +pub const CM_PROB_DEVLOADER_FAILED: DWORD = 0x00000002; +pub const CM_PROB_OUT_OF_MEMORY: DWORD = 0x00000003; +pub const CM_PROB_ENTRY_IS_WRONG_TYPE: DWORD = 0x00000004; +pub const CM_PROB_LACKED_ARBITRATOR: DWORD = 0x00000005; +pub const CM_PROB_BOOT_CONFIG_CONFLICT: DWORD = 0x00000006; +pub const CM_PROB_FAILED_FILTER: DWORD = 0x00000007; +pub const CM_PROB_DEVLOADER_NOT_FOUND: DWORD = 0x00000008; +pub const CM_PROB_INVALID_DATA: DWORD = 0x00000009; +pub const CM_PROB_FAILED_START: DWORD = 0x0000000A; +pub const CM_PROB_LIAR: DWORD = 0x0000000B; +pub const CM_PROB_NORMAL_CONFLICT: DWORD = 0x0000000C; +pub const CM_PROB_NOT_VERIFIED: DWORD = 0x0000000D; +pub const CM_PROB_NEED_RESTART: DWORD = 0x0000000E; +pub const CM_PROB_REENUMERATION: DWORD = 0x0000000F; +pub const CM_PROB_PARTIAL_LOG_CONF: DWORD = 0x00000010; +pub const CM_PROB_UNKNOWN_RESOURCE: DWORD = 0x00000011; +pub const CM_PROB_REINSTALL: DWORD = 0x00000012; +pub const CM_PROB_REGISTRY: DWORD = 0x00000013; +pub const CM_PROB_VXDLDR: DWORD = 0x00000014; +pub const CM_PROB_WILL_BE_REMOVED: DWORD = 0x00000015; +pub const CM_PROB_DISABLED: DWORD = 0x00000016; +pub const CM_PROB_DEVLOADER_NOT_READY: DWORD = 0x00000017; +pub const CM_PROB_DEVICE_NOT_THERE: DWORD = 0x00000018; +pub const CM_PROB_MOVED: DWORD = 0x00000019; +pub const CM_PROB_TOO_EARLY: DWORD = 0x0000001A; +pub const CM_PROB_NO_VALID_LOG_CONF: DWORD = 0x0000001B; +pub const CM_PROB_FAILED_INSTALL: DWORD = 0x0000001C; +pub const CM_PROB_HARDWARE_DISABLED: DWORD = 0x0000001D; +pub const CM_PROB_CANT_SHARE_IRQ: DWORD = 0x0000001E; +pub const CM_PROB_FAILED_ADD: DWORD = 0x0000001F; +pub const CM_PROB_DISABLED_SERVICE: DWORD = 0x00000020; +pub const CM_PROB_TRANSLATION_FAILED: DWORD = 0x00000021; +pub const CM_PROB_NO_SOFTCONFIG: DWORD = 0x00000022; +pub const CM_PROB_BIOS_TABLE: DWORD = 0x00000023; +pub const CM_PROB_IRQ_TRANSLATION_FAILED: DWORD = 0x00000024; +pub const CM_PROB_FAILED_DRIVER_ENTRY: DWORD = 0x00000025; +pub const CM_PROB_DRIVER_FAILED_PRIOR_UNLOAD: DWORD = 0x00000026; +pub const CM_PROB_DRIVER_FAILED_LOAD: DWORD = 0x00000027; +pub const CM_PROB_DRIVER_SERVICE_KEY_INVALID: DWORD = 0x00000028; +pub const CM_PROB_LEGACY_SERVICE_NO_DEVICES: DWORD = 0x00000029; +pub const CM_PROB_DUPLICATE_DEVICE: DWORD = 0x0000002A; +pub const CM_PROB_FAILED_POST_START: DWORD = 0x0000002B; +pub const CM_PROB_HALTED: DWORD = 0x0000002C; +pub const CM_PROB_PHANTOM: DWORD = 0x0000002D; +pub const CM_PROB_SYSTEM_SHUTDOWN: DWORD = 0x0000002E; +pub const CM_PROB_HELD_FOR_EJECT: DWORD = 0x0000002F; +pub const CM_PROB_DRIVER_BLOCKED: DWORD = 0x00000030; +pub const CM_PROB_REGISTRY_TOO_LARGE: DWORD = 0x00000031; +pub const CM_PROB_SETPROPERTIES_FAILED: DWORD = 0x00000032; +pub const CM_PROB_WAITING_ON_DEPENDENCY: DWORD = 0x00000033; +pub const CM_PROB_UNSIGNED_DRIVER: DWORD = 0x00000034; +pub const CM_PROB_USED_BY_DEBUGGER: DWORD = 0x00000035; +pub const NUM_CM_PROB_V1: DWORD = 0x00000025; +pub const NUM_CM_PROB_V2: DWORD = 0x00000032; +pub const NUM_CM_PROB_V3: DWORD = 0x00000033; +pub const NUM_CM_PROB_V4: DWORD = 0x00000034; +pub const NUM_CM_PROB_V5: DWORD = 0x00000035; +pub const NUM_CM_PROB_V6: DWORD = 0x00000036; +pub const DN_ROOT_ENUMERATED: DWORD = 0x00000001; +pub const DN_DRIVER_LOADED: DWORD = 0x00000002; +pub const DN_ENUM_LOADED: DWORD = 0x00000004; +pub const DN_STARTED: DWORD = 0x00000008; +pub const DN_MANUAL: DWORD = 0x00000010; +pub const DN_NEED_TO_ENUM: DWORD = 0x00000020; +pub const DN_NOT_FIRST_TIME: DWORD = 0x00000040; +pub const DN_HARDWARE_ENUM: DWORD = 0x00000080; +pub const DN_LIAR: DWORD = 0x00000100; +pub const DN_HAS_MARK: DWORD = 0x00000200; +pub const DN_HAS_PROBLEM: DWORD = 0x00000400; +pub const DN_FILTERED: DWORD = 0x00000800; +pub const DN_MOVED: DWORD = 0x00001000; +pub const DN_DISABLEABLE: DWORD = 0x00002000; +pub const DN_REMOVABLE: DWORD = 0x00004000; +pub const DN_PRIVATE_PROBLEM: DWORD = 0x00008000; +pub const DN_MF_PARENT: DWORD = 0x00010000; +pub const DN_MF_CHILD: DWORD = 0x00020000; +pub const DN_WILL_BE_REMOVED: DWORD = 0x00040000; +pub const DN_NOT_FIRST_TIMEE: DWORD = 0x00080000; +pub const DN_STOP_FREE_RES: DWORD = 0x00100000; +pub const DN_REBAL_CANDIDATE: DWORD = 0x00200000; +pub const DN_BAD_PARTIAL: DWORD = 0x00400000; +pub const DN_NT_ENUMERATOR: DWORD = 0x00800000; +pub const DN_NT_DRIVER: DWORD = 0x01000000; +pub const DN_NEEDS_LOCKING: DWORD = 0x02000000; +pub const DN_ARM_WAKEUP: DWORD = 0x04000000; +pub const DN_APM_ENUMERATOR: DWORD = 0x08000000; +pub const DN_APM_DRIVER: DWORD = 0x10000000; +pub const DN_SILENT_INSTALL: DWORD = 0x20000000; +pub const DN_NO_SHOW_IN_DM: DWORD = 0x40000000; +pub const DN_BOOT_LOG_PROB: DWORD = 0x80000000; +pub const DN_NEED_RESTART: DWORD = DN_LIAR; +pub const DN_DRIVER_BLOCKED: DWORD = DN_NOT_FIRST_TIME; +pub const DN_LEGACY_DRIVER: DWORD = DN_MOVED; +pub const DN_CHILD_WITH_INVALID_ID: DWORD = DN_HAS_MARK; +pub const DN_DEVICE_DISCONNECTED: DWORD = DN_NEEDS_LOCKING; +pub const DN_CHANGEABLE_FLAGS: DWORD = DN_NOT_FIRST_TIME + DN_HARDWARE_ENUM + DN_HAS_MARK + + DN_DISABLEABLE + DN_REMOVABLE + DN_MF_CHILD + DN_MF_PARENT + DN_NOT_FIRST_TIMEE + + DN_STOP_FREE_RES + DN_REBAL_CANDIDATE + DN_NT_ENUMERATOR + DN_NT_DRIVER + DN_SILENT_INSTALL + + DN_NO_SHOW_IN_DM; +pub const LCPRI_FORCECONFIG: ULONG = 0x00000000; +pub const LCPRI_BOOTCONFIG: ULONG = 0x00000001; +pub const LCPRI_DESIRED: ULONG = 0x00002000; +pub const LCPRI_NORMAL: ULONG = 0x00003000; +pub const LCPRI_LASTBESTCONFIG: ULONG = 0x00003FFF; +pub const LCPRI_SUBOPTIMAL: ULONG = 0x00005000; +pub const LCPRI_LASTSOFTCONFIG: ULONG = 0x00007FFF; +pub const LCPRI_RESTART: ULONG = 0x00008000; +pub const LCPRI_REBOOT: ULONG = 0x00009000; +pub const LCPRI_POWEROFF: ULONG = 0x0000A000; +pub const LCPRI_HARDRECONFIG: ULONG = 0x0000C000; +pub const LCPRI_HARDWIRED: ULONG = 0x0000E000; +pub const LCPRI_IMPOSSIBLE: ULONG = 0x0000F000; +pub const LCPRI_DISABLED: ULONG = 0x0000FFFF; +pub const MAX_LCPRI: ULONG = 0x0000FFFF; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3d9.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3d9.rs new file mode 100644 index 0000000..437c811 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3d9.rs @@ -0,0 +1,1268 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Direct3D include file +use shared::basetsd::UINT32; +use shared::d3d9caps::{D3DCAPS9, D3DCONTENTPROTECTIONCAPS, D3DOVERLAYCAPS}; +use shared::d3d9types::{ + D3DADAPTER_IDENTIFIER9, D3DAUTHENTICATEDCHANNELTYPE, D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT, + D3DBACKBUFFER_TYPE, D3DBOX, D3DCLIPSTATUS9, D3DCOLOR, D3DCOMPOSERECTSOP, D3DCUBEMAP_FACES, + D3DDEVICE_CREATION_PARAMETERS, D3DDEVTYPE, D3DDISPLAYMODE, D3DDISPLAYMODEEX, + D3DDISPLAYMODEFILTER, D3DDISPLAYROTATION, D3DENCRYPTED_BLOCK_INFO, D3DFORMAT, D3DGAMMARAMP, + D3DINDEXBUFFER_DESC, D3DLIGHT9, D3DLOCKED_BOX, D3DLOCKED_RECT, D3DMATERIAL9, D3DMATRIX, + D3DMULTISAMPLE_TYPE, D3DPOOL, D3DPRESENTSTATS, D3DPRESENT_PARAMETERS, D3DPRIMITIVETYPE, + D3DQUERYTYPE, D3DRASTER_STATUS, D3DRECT, D3DRECTPATCH_INFO, D3DRENDERSTATETYPE, + D3DRESOURCETYPE, D3DSAMPLERSTATETYPE, D3DSTATEBLOCKTYPE, D3DSURFACE_DESC, D3DTEXTUREFILTERTYPE, + D3DTEXTURESTAGESTATETYPE, D3DTRANSFORMSTATETYPE, D3DTRIPATCH_INFO, D3DVERTEXBUFFER_DESC, + D3DVERTEXELEMENT9, D3DVIEWPORT9, D3DVOLUME_DESC, +}; +use shared::guiddef::{GUID, IID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, INT, UINT}; +use shared::windef::{HDC, HMONITOR, HWND, POINT, RECT}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::wingdi::{PALETTEENTRY, RGNDATA}; +use um::winnt::{HANDLE, HRESULT, LPCWSTR, LUID, VOID}; +pub const D3D_SDK_VERSION: DWORD = 32; +pub const D3D9b_SDK_VERSION: DWORD = 31; +DEFINE_GUID!{IID_IDirect3D9, + 0x81bdcbca, 0x64d4, 0x426d, 0xae, 0x8d, 0xad, 0x01, 0x47, 0xf4, 0x27, 0x5c} +DEFINE_GUID!{IID_IDirect3DDevice9, + 0xd0223b96, 0xbf7a, 0x43fd, 0x92, 0xbd, 0xa4, 0x3b, 0x0d, 0x82, 0xb9, 0xeb} +DEFINE_GUID!{IID_IDirect3DResource9, + 0x05eec05d, 0x8f7d, 0x4362, 0xb9, 0x99, 0xd1, 0xba, 0xf3, 0x57, 0xc7, 0x04} +DEFINE_GUID!{IID_IDirect3DBaseTexture9, + 0x580ca87e, 0x1d3c, 0x4d54, 0x99, 0x1d, 0xb7, 0xd3, 0xe3, 0xc2, 0x98, 0xce} +DEFINE_GUID!{IID_IDirect3DTexture9, + 0x85c31227, 0x3de5, 0x4f00, 0x9b, 0x3a, 0xf1, 0x1a, 0xc3, 0x8c, 0x18, 0xb5} +DEFINE_GUID!{IID_IDirect3DCubeTexture9, + 0xfff32f81, 0xd953, 0x473a, 0x92, 0x23, 0x93, 0xd6, 0x52, 0xab, 0xa9, 0x3f} +DEFINE_GUID!{IID_IDirect3DVolumeTexture9, + 0x2518526c, 0xe789, 0x4111, 0xa7, 0xb9, 0x47, 0xef, 0x32, 0x8d, 0x13, 0xe6} +DEFINE_GUID!{IID_IDirect3DVertexBuffer9, + 0xb64bb1b5, 0xfd70, 0x4df6, 0xbf, 0x91, 0x19, 0xd0, 0xa1, 0x24, 0x55, 0xe3} +DEFINE_GUID!{IID_IDirect3DIndexBuffer9, + 0x7c9dd65e, 0xd3f7, 0x4529, 0xac, 0xee, 0x78, 0x58, 0x30, 0xac, 0xde, 0x35} +DEFINE_GUID!{IID_IDirect3DSurface9, + 0x0cfbaf3a, 0x9ff6, 0x429a, 0x99, 0xb3, 0xa2, 0x79, 0x6a, 0xf8, 0xb8, 0x9b} +DEFINE_GUID!{IID_IDirect3DVolume9, + 0x24f416e6, 0x1f67, 0x4aa7, 0xb8, 0x8e, 0xd3, 0x3f, 0x6f, 0x31, 0x28, 0xa1} +DEFINE_GUID!{IID_IDirect3DSwapChain9, + 0x794950f2, 0xadfc, 0x458a, 0x90, 0x5e, 0x10, 0xa1, 0x0b, 0x0b, 0x50, 0x3b} +DEFINE_GUID!{IID_IDirect3DVertexDeclaration9, + 0xdd13c59c, 0x36fa, 0x4098, 0xa8, 0xfb, 0xc7, 0xed, 0x39, 0xdc, 0x85, 0x46} +DEFINE_GUID!{IID_IDirect3DVertexShader9, + 0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36} +DEFINE_GUID!{IID_IDirect3DPixelShader9, + 0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89} +DEFINE_GUID!{IID_IDirect3DStateBlock9, + 0xb07c4fe5, 0x310d, 0x4ba8, 0xa2, 0x3c, 0x4f, 0x0f, 0x20, 0x6f, 0x21, 0x8b} +DEFINE_GUID!{IID_IDirect3DQuery9, + 0xd9771460, 0xa695, 0x4f26, 0xbb, 0xd3, 0x27, 0xb8, 0x40, 0xb5, 0x41, 0xcc} +DEFINE_GUID!{IID_HelperName, + 0xe4a36723, 0xfdfe, 0x4b22, 0xb1, 0x46, 0x3c, 0x04, 0xc0, 0x7f, 0x4c, 0xc8} +DEFINE_GUID!{IID_IDirect3D9Ex, + 0x02177241, 0x69fc, 0x400c, 0x8f, 0xf1, 0x93, 0xa4, 0x4d, 0xf6, 0x86, 0x1d} +DEFINE_GUID!{IID_IDirect3DDevice9Ex, + 0xb18b10ce, 0x2649, 0x405a, 0x87, 0x0f, 0x95, 0xf7, 0x77, 0xd4, 0x31, 0x3a} +DEFINE_GUID!{IID_IDirect3DSwapChain9Ex, + 0x91886caf, 0x1c3d, 0x4d2e, 0xa0, 0xab, 0x3e, 0x4c, 0x7d, 0x8d, 0x33, 0x03} +DEFINE_GUID!{IID_IDirect3D9ExOverlayExtension, + 0x187aeb13, 0xaaf5, 0x4c59, 0x87, 0x6d, 0xe0, 0x59, 0x08, 0x8c, 0x0d, 0xf8} +DEFINE_GUID!{IID_IDirect3DDevice9Video, + 0x26dc4561, 0xa1ee, 0x4ae7, 0x96, 0xda, 0x11, 0x8a, 0x36, 0xc0, 0xec, 0x95} +DEFINE_GUID!{IID_IDirect3DAuthenticatedChannel9, + 0xff24beee, 0xda21, 0x4beb, 0x98, 0xb5, 0xd2, 0xf8, 0x99, 0xf9, 0x8a, 0xf9} +DEFINE_GUID!{IID_IDirect3DCryptoSession9, + 0xfa0ab799, 0x7a9c, 0x48ca, 0x8c, 0x5b, 0x23, 0x7e, 0x71, 0xa5, 0x44, 0x34} +extern "system" { + pub fn Direct3DCreate9( + SDKVersion: UINT, + ) -> *mut IDirect3D9; + pub fn D3DPERF_BeginEvent( + col: D3DCOLOR, + wszName: LPCWSTR, + ) -> INT; + pub fn D3DPERF_EndEvent() -> INT; + pub fn D3DPERF_SetMarker( + col: D3DCOLOR, + wszName: LPCWSTR, + ) -> (); + pub fn D3DPERF_SetRegion( + col: D3DCOLOR, + wszName: LPCWSTR, + ) -> (); + pub fn D3DPERF_QueryRepeatFrame() -> BOOL; + pub fn D3DPERF_SetOptions( + dwOptions: DWORD, + ) -> (); + pub fn D3DPERF_GetStatus() -> DWORD; +} +RIDL!{#[uuid(0x81bdcbca, 0x64d4, 0x426d, 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c)] +interface IDirect3D9(IDirect3D9Vtbl): IUnknown(IUnknownVtbl) { + fn RegisterSoftwareDevice( + pInitializeFunction: *mut VOID, + ) -> HRESULT, + fn GetAdapterCount() -> UINT, + fn GetAdapterIdentifier( + Adapter: UINT, + Flags: DWORD, + pIdentifier: *mut D3DADAPTER_IDENTIFIER9, + ) -> HRESULT, + fn GetAdapterModeCount( + Adapter: UINT, + Format: D3DFORMAT, + ) -> UINT, + fn EnumAdapterModes( + Adapter: UINT, + Format: D3DFORMAT, + Mode: UINT, + pMode: *mut D3DDISPLAYMODE, + ) -> HRESULT, + fn GetAdapterDisplayMode( + Adapter: UINT, + pMode: *mut D3DDISPLAYMODE, + ) -> HRESULT, + fn CheckDeviceType( + Adapter: UINT, + DevType: D3DDEVTYPE, + AdapterFormat: D3DFORMAT, + BackBufferFormat: D3DFORMAT, + bWindowed: BOOL, + ) -> HRESULT, + fn CheckDeviceFormat( + Adapter: UINT, + DeviceType: D3DDEVTYPE, + AdapterFormat: D3DFORMAT, + Usage: DWORD, + RType: D3DRESOURCETYPE, + CheckFormat: D3DFORMAT, + ) -> HRESULT, + fn CheckDeviceMultiSampleType( + Adapter: UINT, + DeviceType: D3DDEVTYPE, + SurfaceFormat: D3DFORMAT, + Windowed: BOOL, + MultiSampleType: D3DMULTISAMPLE_TYPE, + pQualityLevels: *mut DWORD, + ) -> HRESULT, + fn CheckDepthStencilMatch( + Adapter: UINT, + DeviceType: D3DDEVTYPE, + AdapterFormat: D3DFORMAT, + RenderTargetFormat: D3DFORMAT, + DepthStencilFormat: D3DFORMAT, + ) -> HRESULT, + fn CheckDeviceFormatConversion( + Adapter: UINT, + DeviceType: D3DDEVTYPE, + SourceFormat: D3DFORMAT, + TargetFormat: D3DFORMAT, + ) -> HRESULT, + fn GetDeviceCaps( + Adapter: UINT, + DeviceType: D3DDEVTYPE, + pCaps: *mut D3DCAPS9, + ) -> HRESULT, + fn GetAdapterMonitor( + Adapter: UINT, + ) -> HMONITOR, + fn CreateDevice( + Adapter: UINT, + DeviceType: D3DDEVTYPE, + hFocusWindow: HWND, + BehaviorFlags: DWORD, + pPresentationParameters: *mut D3DPRESENT_PARAMETERS, + ppReturnedDeviceInterface: *mut *mut IDirect3DDevice9, + ) -> HRESULT, +}} +pub type LPDIRECT3D9 = *mut IDirect3D9; +pub type PDIRECT3D9 = *mut IDirect3D9; +RIDL!{#[uuid(0xd0223b96, 0xbf7a, 0x43fd, 0x92, 0xbd, 0xa4, 0x3b, 0xd, 0x82, 0xb9, 0xeb)] +interface IDirect3DDevice9(IDirect3DDevice9Vtbl): IUnknown(IUnknownVtbl) { + fn TestCooperativeLevel() -> HRESULT, + fn GetAvailableTextureMem() -> UINT, + fn EvictManagedResources() -> HRESULT, + fn GetDirect3D( + ppD3D9: *mut *mut IDirect3D9, + ) -> HRESULT, + fn GetDeviceCaps( + pCaps: *mut D3DCAPS9, + ) -> HRESULT, + fn GetDisplayMode( + iSwapChain: UINT, + pMode: *mut D3DDISPLAYMODE, + ) -> HRESULT, + fn GetCreationParameters( + pParameters: *mut D3DDEVICE_CREATION_PARAMETERS, + ) -> HRESULT, + fn SetCursorProperties( + XHotSpot: UINT, + YHotSpot: UINT, + pCursorBitmap: *mut IDirect3DSurface9, + ) -> HRESULT, + fn SetCursorPosition( + X: INT, + Y: INT, + Flags: DWORD, + ) -> (), + fn ShowCursor( + bShow: BOOL, + ) -> BOOL, + fn CreateAdditionalSwapChain( + pPresentationParameters: *mut D3DPRESENT_PARAMETERS, + pSwapChain: *mut *mut IDirect3DSwapChain9, + ) -> HRESULT, + fn GetSwapChain( + iSwapChain: UINT, + pSwapChain: *mut *mut IDirect3DSwapChain9, + ) -> HRESULT, + fn GetNumberOfSwapChains() -> UINT, + fn Reset( + pPresentationParameters: *mut D3DPRESENT_PARAMETERS, + ) -> HRESULT, + fn Present( + pSourceRect: *const RECT, + pDestRect: *const RECT, + hDestWindowOverride: HWND, + pDirtyRegion: *const RGNDATA, + ) -> HRESULT, + fn GetBackBuffer( + iSwapChain: UINT, + iBackBuffer: UINT, + Type: D3DBACKBUFFER_TYPE, + ppBackBuffer: *mut *mut IDirect3DSurface9, + ) -> HRESULT, + fn GetRasterStatus( + iSwapChain: UINT, + pRasterStatus: *mut D3DRASTER_STATUS, + ) -> HRESULT, + fn SetDialogBoxMode( + bEnableDialogs: BOOL, + ) -> HRESULT, + fn SetGammaRamp( + iSwapChain: UINT, + Flags: DWORD, + pRamp: *const D3DGAMMARAMP, + ) -> (), + fn GetGammaRamp( + iSwapChain: UINT, + pRamp: *mut D3DGAMMARAMP, + ) -> (), + fn CreateTexture( + Width: UINT, + Height: UINT, + Levels: UINT, + Usage: DWORD, + Format: D3DFORMAT, + Pool: D3DPOOL, + ppTexture: *mut *mut IDirect3DTexture9, + pSharedHandle: *mut HANDLE, + ) -> HRESULT, + fn CreateVolumeTexture( + Width: UINT, + Height: UINT, + Depth: UINT, + Levels: UINT, + Usage: DWORD, + Format: D3DFORMAT, + Pool: D3DPOOL, + ppVolumeTexture: *mut *mut IDirect3DVolumeTexture9, + pSharedHandle: *mut HANDLE, + ) -> HRESULT, + fn CreateCubeTexture( + EdgeLength: UINT, + Levels: UINT, + Usage: DWORD, + Format: D3DFORMAT, + Pool: D3DPOOL, + ppCubeTexture: *mut *mut IDirect3DCubeTexture9, + pSharedHandle: *mut HANDLE, + ) -> HRESULT, + fn CreateVertexBuffer( + Length: UINT, + Usage: DWORD, + FVF: DWORD, + Pool: D3DPOOL, + ppVertexBuffer: *mut *mut IDirect3DVertexBuffer9, + pSharedHandle: *mut HANDLE, + ) -> HRESULT, + fn CreateIndexBuffer( + Length: UINT, + Usage: DWORD, + Format: D3DFORMAT, + Pool: D3DPOOL, + ppIndexBuffer: *mut *mut IDirect3DIndexBuffer9, + pSharedHandle: *mut HANDLE, + ) -> HRESULT, + fn CreateRenderTarget( + Width: UINT, + Height: UINT, + Format: D3DFORMAT, + MultiSample: D3DMULTISAMPLE_TYPE, + MultisampleQuality: DWORD, + Lockable: BOOL, + ppSurface: *mut *mut IDirect3DSurface9, + pSharedHandle: *mut HANDLE, + ) -> HRESULT, + fn CreateDepthStencilSurface( + Width: UINT, + Height: UINT, + Format: D3DFORMAT, + MultiSample: D3DMULTISAMPLE_TYPE, + MultisampleQuality: DWORD, + Discard: BOOL, + ppSurface: *mut *mut IDirect3DSurface9, + pSharedHandle: *mut HANDLE, + ) -> HRESULT, + fn UpdateSurface( + pSourceSurface: *mut IDirect3DSurface9, + pSourceRect: *const RECT, + pDestinationSurface: *mut IDirect3DSurface9, + pDestPoint: *const POINT, + ) -> HRESULT, + fn UpdateTexture( + pSourceTexture: *mut IDirect3DBaseTexture9, + pDestinationTexture: *mut IDirect3DBaseTexture9, + ) -> HRESULT, + fn GetRenderTargetData( + pRenderTarget: *mut IDirect3DSurface9, + pDestSurface: *mut IDirect3DSurface9, + ) -> HRESULT, + fn GetFrontBufferData( + iSwapChain: UINT, + pDestSurface: *mut IDirect3DSurface9, + ) -> HRESULT, + fn StretchRect( + pSourceSurface: *mut IDirect3DSurface9, + pSourceRect: *const RECT, + pDestSurface: *mut IDirect3DSurface9, + pDestRect: *const RECT, + Filter: D3DTEXTUREFILTERTYPE, + ) -> HRESULT, + fn ColorFill( + pSurface: *mut IDirect3DSurface9, + pRect: *const RECT, + color: D3DCOLOR, + ) -> HRESULT, + fn CreateOffscreenPlainSurface( + Width: UINT, + Height: UINT, + Format: D3DFORMAT, + Pool: D3DPOOL, + ppSurface: *mut *mut IDirect3DSurface9, + pSharedHandle: *mut HANDLE, + ) -> HRESULT, + fn SetRenderTarget( + RenderTargetIndex: DWORD, + pRenderTarget: *mut IDirect3DSurface9, + ) -> HRESULT, + fn GetRenderTarget( + RenderTargetIndex: DWORD, + ppRenderTarget: *mut *mut IDirect3DSurface9, + ) -> HRESULT, + fn SetDepthStencilSurface( + pNewZStencil: *mut IDirect3DSurface9, + ) -> HRESULT, + fn GetDepthStencilSurface( + ppZStencilSurface: *mut *mut IDirect3DSurface9, + ) -> HRESULT, + fn BeginScene() -> HRESULT, + fn EndScene() -> HRESULT, + fn Clear( + Count: DWORD, + pRects: *const D3DRECT, + Flags: DWORD, + Color: D3DCOLOR, + Z: FLOAT, + Stencil: DWORD, + ) -> HRESULT, + fn SetTransform( + State: D3DTRANSFORMSTATETYPE, + pMatrix: *const D3DMATRIX, + ) -> HRESULT, + fn GetTransform( + State: D3DTRANSFORMSTATETYPE, + pMatrix: *mut D3DMATRIX, + ) -> HRESULT, + fn MultiplyTransform( + arg1: D3DTRANSFORMSTATETYPE, + arg2: *const D3DMATRIX, + ) -> HRESULT, + fn SetViewport( + pViewport: *const D3DVIEWPORT9, + ) -> HRESULT, + fn GetViewport( + pViewport: *mut D3DVIEWPORT9, + ) -> HRESULT, + fn SetMaterial( + pMaterial: *const D3DMATERIAL9, + ) -> HRESULT, + fn GetMaterial( + pMaterial: *mut D3DMATERIAL9, + ) -> HRESULT, + fn SetLight( + Index: DWORD, + arg1: *const D3DLIGHT9, + ) -> HRESULT, + fn GetLight( + Index: DWORD, + arg1: *mut D3DLIGHT9, + ) -> HRESULT, + fn LightEnable( + Index: DWORD, + Enable: BOOL, + ) -> HRESULT, + fn GetLightEnable( + Index: DWORD, + pEnable: *mut BOOL, + ) -> HRESULT, + fn SetClipPlane( + Index: DWORD, + pPlane: *const FLOAT, + ) -> HRESULT, + fn GetClipPlane( + Index: DWORD, + pPlane: *mut FLOAT, + ) -> HRESULT, + fn SetRenderState( + State: D3DRENDERSTATETYPE, + Value: DWORD, + ) -> HRESULT, + fn GetRenderState( + State: D3DRENDERSTATETYPE, + pValue: *mut DWORD, + ) -> HRESULT, + fn CreateStateBlock( + Type: D3DSTATEBLOCKTYPE, + ppSB: *mut *mut IDirect3DStateBlock9, + ) -> HRESULT, + fn BeginStateBlock() -> HRESULT, + fn EndStateBlock( + ppSB: *mut *mut IDirect3DStateBlock9, + ) -> HRESULT, + fn SetClipStatus( + pClipStatus: *const D3DCLIPSTATUS9, + ) -> HRESULT, + fn GetClipStatus( + pClipStatus: *mut D3DCLIPSTATUS9, + ) -> HRESULT, + fn GetTexture( + Stage: DWORD, + ppTexture: *mut *mut IDirect3DBaseTexture9, + ) -> HRESULT, + fn SetTexture( + Stage: DWORD, + pTexture: *mut IDirect3DBaseTexture9, + ) -> HRESULT, + fn GetTextureStageState( + Stage: DWORD, + Type: D3DTEXTURESTAGESTATETYPE, + pValue: *mut DWORD, + ) -> HRESULT, + fn SetTextureStageState( + Stage: DWORD, + Type: D3DTEXTURESTAGESTATETYPE, + Value: DWORD, + ) -> HRESULT, + fn GetSamplerState( + Sampler: DWORD, + Type: D3DSAMPLERSTATETYPE, + pValue: *mut DWORD, + ) -> HRESULT, + fn SetSamplerState( + Sampler: DWORD, + Type: D3DSAMPLERSTATETYPE, + Value: DWORD, + ) -> HRESULT, + fn ValidateDevice( + pNumPasses: *mut DWORD, + ) -> HRESULT, + fn SetPaletteEntries( + PaletteNumber: UINT, + pEntries: *const PALETTEENTRY, + ) -> HRESULT, + fn GetPaletteEntries( + PaletteNumber: UINT, + pEntries: *mut PALETTEENTRY, + ) -> HRESULT, + fn SetCurrentTexturePalette( + PaletteNumber: UINT, + ) -> HRESULT, + fn GetCurrentTexturePalette( + PaletteNumber: *mut UINT, + ) -> HRESULT, + fn SetScissorRect( + pRect: *const RECT, + ) -> HRESULT, + fn GetScissorRect( + pRect: *mut RECT, + ) -> HRESULT, + fn SetSoftwareVertexProcessing( + bSoftware: BOOL, + ) -> HRESULT, + fn GetSoftwareVertexProcessing() -> BOOL, + fn SetNPatchMode( + nSegments: FLOAT, + ) -> HRESULT, + fn GetNPatchMode() -> FLOAT, + fn DrawPrimitive( + PrimitiveType: D3DPRIMITIVETYPE, + StartVertex: UINT, + PrimitiveCount: UINT, + ) -> HRESULT, + fn DrawIndexedPrimitive( + arg1: D3DPRIMITIVETYPE, + BaseVertexIndex: INT, + MinVertexIndex: UINT, + NumVertices: UINT, + startIndex: UINT, + primCount: UINT, + ) -> HRESULT, + fn DrawPrimitiveUP( + PrimitiveType: D3DPRIMITIVETYPE, + PrimitiveCount: UINT, + pVertexStreamZeroData: *const VOID, + VertexStreamZeroStride: UINT, + ) -> HRESULT, + fn DrawIndexedPrimitiveUP( + PrimitiveType: D3DPRIMITIVETYPE, + MinVertexIndex: UINT, + NumVertices: UINT, + PrimitiveCount: UINT, + pIndexData: *const VOID, + IndexDataFormat: D3DFORMAT, + pVertexStreamZeroData: *const VOID, + VertexStreamZeroStride: UINT, + ) -> HRESULT, + fn ProcessVertices( + SrcStartIndex: UINT, + DestIndex: UINT, + VertexCount: UINT, + pDestBuffer: *mut IDirect3DVertexBuffer9, + pVertexDecl: *mut IDirect3DVertexDeclaration9, + Flags: DWORD, + ) -> HRESULT, + fn CreateVertexDeclaration( + pVertexElements: *const D3DVERTEXELEMENT9, + ppDecl: *mut *mut IDirect3DVertexDeclaration9, + ) -> HRESULT, + fn SetVertexDeclaration( + pDecl: *mut IDirect3DVertexDeclaration9, + ) -> HRESULT, + fn GetVertexDeclaration( + ppDecl: *mut *mut IDirect3DVertexDeclaration9, + ) -> HRESULT, + fn SetFVF( + FVF: DWORD, + ) -> HRESULT, + fn GetFVF( + pFVF: *mut DWORD, + ) -> HRESULT, + fn CreateVertexShader( + pFunction: *const DWORD, + ppShader: *mut *mut IDirect3DVertexShader9, + ) -> HRESULT, + fn SetVertexShader( + pShader: *mut IDirect3DVertexShader9, + ) -> HRESULT, + fn GetVertexShader( + ppShader: *mut *mut IDirect3DVertexShader9, + ) -> HRESULT, + fn SetVertexShaderConstantF( + StartRegister: UINT, + pConstantData: *const FLOAT, + Vector4fCount: UINT, + ) -> HRESULT, + fn GetVertexShaderConstantF( + StartRegister: UINT, + pConstantData: *mut FLOAT, + Vector4fCount: UINT, + ) -> HRESULT, + fn SetVertexShaderConstantI( + StartRegister: UINT, + pConstantData: *const INT, + Vector4iCount: UINT, + ) -> HRESULT, + fn GetVertexShaderConstantI( + StartRegister: UINT, + pConstantData: *mut INT, + Vector4iCount: UINT, + ) -> HRESULT, + fn SetVertexShaderConstantB( + StartRegister: UINT, + pConstantData: *const BOOL, + BoolCount: UINT, + ) -> HRESULT, + fn GetVertexShaderConstantB( + StartRegister: UINT, + pConstantData: *mut BOOL, + BoolCount: UINT, + ) -> HRESULT, + fn SetStreamSource( + StreamNumber: UINT, + pStreamData: *mut IDirect3DVertexBuffer9, + OffsetInBytes: UINT, + Stride: UINT, + ) -> HRESULT, + fn GetStreamSource( + StreamNumber: UINT, + ppStreamData: *mut *mut IDirect3DVertexBuffer9, + pOffsetInBytes: *mut UINT, + pStride: *mut UINT, + ) -> HRESULT, + fn SetStreamSourceFreq( + StreamNumber: UINT, + Setting: UINT, + ) -> HRESULT, + fn GetStreamSourceFreq( + StreamNumber: UINT, + pSetting: *mut UINT, + ) -> HRESULT, + fn SetIndices( + pIndexData: *mut IDirect3DIndexBuffer9, + ) -> HRESULT, + fn GetIndices( + ppIndexData: *mut *mut IDirect3DIndexBuffer9, + ) -> HRESULT, + fn CreatePixelShader( + pFunction: *const DWORD, + ppShader: *mut *mut IDirect3DPixelShader9, + ) -> HRESULT, + fn SetPixelShader( + pShader: *mut IDirect3DPixelShader9, + ) -> HRESULT, + fn GetPixelShader( + ppShader: *mut *mut IDirect3DPixelShader9, + ) -> HRESULT, + fn SetPixelShaderConstantF( + StartRegister: UINT, + pConstantData: *const FLOAT, + Vector4fCount: UINT, + ) -> HRESULT, + fn GetPixelShaderConstantF( + StartRegister: UINT, + pConstantData: *mut FLOAT, + Vector4fCount: UINT, + ) -> HRESULT, + fn SetPixelShaderConstantI( + StartRegister: UINT, + pConstantData: *const INT, + Vector4iCount: UINT, + ) -> HRESULT, + fn GetPixelShaderConstantI( + StartRegister: UINT, + pConstantData: *mut INT, + Vector4iCount: UINT, + ) -> HRESULT, + fn SetPixelShaderConstantB( + StartRegister: UINT, + pConstantData: *const BOOL, + BoolCount: UINT, + ) -> HRESULT, + fn GetPixelShaderConstantB( + StartRegister: UINT, + pConstantData: *mut BOOL, + BoolCount: UINT, + ) -> HRESULT, + fn DrawRectPatch( + Handle: UINT, + pNumSegs: *const FLOAT, + pRectPatchInfo: *const D3DRECTPATCH_INFO, + ) -> HRESULT, + fn DrawTriPatch( + Handle: UINT, + pNumSegs: *const FLOAT, + pTriPatchInfo: *const D3DTRIPATCH_INFO, + ) -> HRESULT, + fn DeletePatch( + Handle: UINT, + ) -> HRESULT, + fn CreateQuery( + Type: D3DQUERYTYPE, + ppQuery: *mut *mut IDirect3DQuery9, + ) -> HRESULT, +}} +pub type LPDIRECT3DDEVICE9 = *mut IDirect3DDevice9; +pub type PDIRECT3DDEVICE9 = *mut IDirect3DDevice9; +RIDL!{#[uuid(0xb07c4fe5, 0x310d, 0x4ba8, 0xa2, 0x3c, 0x4f, 0xf, 0x20, 0x6f, 0x21, 0x8b)] +interface IDirect3DStateBlock9(IDirect3DStateBlock9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice( + ppDevice: *mut *mut IDirect3DDevice9, + ) -> HRESULT, + fn Capture() -> HRESULT, + fn Apply() -> HRESULT, +}} +pub type LPDIRECT3DSTATEBLOCK9 = *mut IDirect3DStateBlock9; +pub type PDIRECT3DSTATEBLOCK9 = *mut IDirect3DStateBlock9; +RIDL!{#[uuid(0x794950f2, 0xadfc, 0x458a, 0x90, 0x5e, 0x10, 0xa1, 0xb, 0xb, 0x50, 0x3b)] +interface IDirect3DSwapChain9(IDirect3DSwapChain9Vtbl): IUnknown(IUnknownVtbl) { + fn Present( + pSourceRect: *const RECT, + pDestRect: *const RECT, + hDestWindowOverride: HWND, + pDirtyRegion: *const RGNDATA, + dwFlags: DWORD, + ) -> HRESULT, + fn GetFrontBufferData( + pDestSurface: *mut IDirect3DSurface9, + ) -> HRESULT, + fn GetBackBuffer( + iBackBuffer: UINT, + Type: D3DBACKBUFFER_TYPE, + ppBackBuffer: *mut *mut IDirect3DSurface9, + ) -> HRESULT, + fn GetRasterStatus( + pRasterStatus: *mut D3DRASTER_STATUS, + ) -> HRESULT, + fn GetDisplayMode( + pMode: *mut D3DDISPLAYMODE, + ) -> HRESULT, + fn GetDevice( + ppDevice: *mut *mut IDirect3DDevice9, + ) -> HRESULT, + fn GetPresentParameters( + pPresentationParameters: *mut D3DPRESENT_PARAMETERS, + ) -> HRESULT, +}} +pub type LPDIRECT3DSWAPCHAIN9 = *mut IDirect3DSwapChain9; +pub type PDIRECT3DSWAPCHAIN9 = *mut IDirect3DSwapChain9; +RIDL!{#[uuid(0x5eec05d, 0x8f7d, 0x4362, 0xb9, 0x99, 0xd1, 0xba, 0xf3, 0x57, 0xc7, 0x4)] +interface IDirect3DResource9(IDirect3DResource9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice( + ppDevice: *mut *mut IDirect3DDevice9, + ) -> HRESULT, + fn SetPrivateData( + refguid: *const GUID, + pData: *const VOID, + SizeOfData: DWORD, + Flags: DWORD, + ) -> HRESULT, + fn GetPrivateData( + refguid: *const GUID, + pData: *mut VOID, + pSizeOfData: *mut DWORD, + ) -> HRESULT, + fn FreePrivateData( + refguid: *const GUID, + ) -> HRESULT, + fn SetPriority( + PriorityNew: DWORD, + ) -> DWORD, + fn GetPriority() -> DWORD, + fn PreLoad() -> (), + fn GetType() -> D3DRESOURCETYPE, +}} +pub type LPDIRECT3DRESOURCE9 = *mut IDirect3DResource9; +pub type PDIRECT3DRESOURCE9 = *mut IDirect3DResource9; +RIDL!{#[uuid(0xdd13c59c, 0x36fa, 0x4098, 0xa8, 0xfb, 0xc7, 0xed, 0x39, 0xdc, 0x85, 0x46)] +interface IDirect3DVertexDeclaration9(IDirect3DVertexDeclaration9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice( + ppDevice: *mut *mut IDirect3DDevice9, + ) -> HRESULT, + fn GetDeclaration( + pElement: *mut D3DVERTEXELEMENT9, + pNumElements: *mut UINT, + ) -> HRESULT, +}} +pub type LPDIRECT3DVERTEXDECLARATION9 = *mut IDirect3DVertexDeclaration9; +pub type PDIRECT3DVERTEXDECLARATION9 = *mut IDirect3DVertexDeclaration9; +RIDL!{#[uuid(0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36)] +interface IDirect3DVertexShader9(IDirect3DVertexShader9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice( + ppDevice: *mut *mut IDirect3DDevice9, + ) -> HRESULT, + fn GetFunction( + arg1: *mut VOID, + pSizeOfData: *mut UINT, + ) -> HRESULT, +}} +pub type LPDIRECT3DVERTEXSHADER9 = *mut IDirect3DVertexShader9; +pub type PDIRECT3DVERTEXSHADER9 = *mut IDirect3DVertexShader9; +RIDL!{#[uuid(0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89)] +interface IDirect3DPixelShader9(IDirect3DPixelShader9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice( + ppDevice: *mut *mut IDirect3DDevice9, + ) -> HRESULT, + fn GetFunction( + arg1: *mut VOID, + pSizeOfData: *mut UINT, + ) -> HRESULT, +}} +pub type LPDIRECT3DPIXELSHADER9 = *mut IDirect3DPixelShader9; +pub type PDIRECT3DPIXELSHADER9 = *mut IDirect3DPixelShader9; +RIDL!{#[uuid(0x580ca87e, 0x1d3c, 0x4d54, 0x99, 0x1d, 0xb7, 0xd3, 0xe3, 0xc2, 0x98, 0xce)] +interface IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl): + IDirect3DResource9(IDirect3DResource9Vtbl) { + fn SetLOD( + LODNew: DWORD, + ) -> DWORD, + fn GetLOD() -> DWORD, + fn GetLevelCount() -> DWORD, + fn SetAutoGenFilterType( + FilterType: D3DTEXTUREFILTERTYPE, + ) -> HRESULT, + fn GetAutoGenFilterType() -> D3DTEXTUREFILTERTYPE, + fn GenerateMipSubLevels() -> (), +}} +pub type LPDIRECT3DBASETEXTURE9 = *mut IDirect3DBaseTexture9; +pub type PDIRECT3DBASETEXTURE9 = *mut IDirect3DBaseTexture9; +RIDL!{#[uuid(0x85c31227, 0x3de5, 0x4f00, 0x9b, 0x3a, 0xf1, 0x1a, 0xc3, 0x8c, 0x18, 0xb5)] +interface IDirect3DTexture9(IDirect3DTexture9Vtbl): + IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl) { + fn GetLevelDesc( + Level: UINT, + pDesc: *mut D3DSURFACE_DESC, + ) -> HRESULT, + fn GetSurfaceLevel( + Level: UINT, + ppSurfaceLevel: *mut *mut IDirect3DSurface9, + ) -> HRESULT, + fn LockRect( + Level: UINT, + pLockedRect: *mut D3DLOCKED_RECT, + pRect: *const RECT, + Flags: DWORD, + ) -> HRESULT, + fn UnlockRect( + Level: UINT, + ) -> HRESULT, + fn AddDirtyRect( + pDirtyRect: *const RECT, + ) -> HRESULT, +}} +pub type LPDIRECT3DTEXTURE9 = *mut IDirect3DTexture9; +pub type PDIRECT3DTEXTURE9 = *mut IDirect3DTexture9; +RIDL!{#[uuid(0x2518526c, 0xe789, 0x4111, 0xa7, 0xb9, 0x47, 0xef, 0x32, 0x8d, 0x13, 0xe6)] +interface IDirect3DVolumeTexture9(IDirect3DVolumeTexture9Vtbl): + IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl) { + fn GetLevelDesc( + Level: UINT, + pDesc: *mut D3DVOLUME_DESC, + ) -> HRESULT, + fn GetVolumeLevel( + Level: UINT, + ppVolumeLevel: *mut *mut IDirect3DVolume9, + ) -> HRESULT, + fn LockBox( + Level: UINT, + pLockedVolume: *mut D3DLOCKED_BOX, + pBox: *const D3DBOX, + Flags: DWORD, + ) -> HRESULT, + fn UnlockBox( + Level: UINT, + ) -> HRESULT, + fn AddDirtyBox( + pDirtyBox: *const D3DBOX, + ) -> HRESULT, +}} +pub type LPDIRECT3DVOLUMETEXTURE9 = *mut IDirect3DVolumeTexture9; +pub type PDIRECT3DVOLUMETEXTURE9 = *mut IDirect3DVolumeTexture9; +RIDL!{#[uuid(0xfff32f81, 0xd953, 0x473a, 0x92, 0x23, 0x93, 0xd6, 0x52, 0xab, 0xa9, 0x3f)] +interface IDirect3DCubeTexture9(IDirect3DCubeTexture9Vtbl): + IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl) { + fn GetLevelDesc( + Level: UINT, + pDesc: *mut D3DSURFACE_DESC, + ) -> HRESULT, + fn GetCubeMapSurface( + FaceType: D3DCUBEMAP_FACES, + Level: UINT, + ppCubeMapSurface: *mut *mut IDirect3DSurface9, + ) -> HRESULT, + fn LockRect( + FaceType: D3DCUBEMAP_FACES, + Level: UINT, + pLockedRect: *mut D3DLOCKED_RECT, + pRect: *const RECT, + Flags: DWORD, + ) -> HRESULT, + fn UnlockRect( + FaceType: D3DCUBEMAP_FACES, + Level: UINT, + ) -> HRESULT, + fn AddDirtyRect( + FaceType: D3DCUBEMAP_FACES, + pDirtyRect: *const RECT, + ) -> HRESULT, +}} +pub type LPDIRECT3DCUBETEXTURE9 = *mut IDirect3DCubeTexture9; +pub type PDIRECT3DCUBETEXTURE9 = *mut IDirect3DCubeTexture9; +RIDL!{#[uuid(0xb64bb1b5, 0xfd70, 0x4df6, 0xbf, 0x91, 0x19, 0xd0, 0xa1, 0x24, 0x55, 0xe3)] +interface IDirect3DVertexBuffer9(IDirect3DVertexBuffer9Vtbl): + IDirect3DResource9(IDirect3DResource9Vtbl) { + fn Lock( + OffsetToLock: UINT, + SizeToLock: UINT, + ppbData: *mut *mut VOID, + Flags: DWORD, + ) -> HRESULT, + fn Unlock() -> HRESULT, + fn GetDesc( + pDesc: *mut D3DVERTEXBUFFER_DESC, + ) -> HRESULT, +}} +pub type LPDIRECT3DVERTEXBUFFER9 = *mut IDirect3DVertexBuffer9; +pub type PDIRECT3DVERTEXBUFFER9 = *mut IDirect3DVertexBuffer9; +RIDL!{#[uuid(0x7c9dd65e, 0xd3f7, 0x4529, 0xac, 0xee, 0x78, 0x58, 0x30, 0xac, 0xde, 0x35)] +interface IDirect3DIndexBuffer9(IDirect3DIndexBuffer9Vtbl): + IDirect3DResource9(IDirect3DResource9Vtbl) { + fn Lock( + OffsetToLock: UINT, + SizeToLock: UINT, + ppbData: *mut *mut VOID, + Flags: DWORD, + ) -> HRESULT, + fn Unlock() -> HRESULT, + fn GetDesc( + pDesc: *mut D3DINDEXBUFFER_DESC, + ) -> HRESULT, +}} +pub type LPDIRECT3DINDEXBUFFER9 = *mut IDirect3DIndexBuffer9; +pub type PDIRECT3DINDEXBUFFER9 = *mut IDirect3DIndexBuffer9; +RIDL!{#[uuid(0xcfbaf3a, 0x9ff6, 0x429a, 0x99, 0xb3, 0xa2, 0x79, 0x6a, 0xf8, 0xb8, 0x9b)] +interface IDirect3DSurface9(IDirect3DSurface9Vtbl): IDirect3DResource9(IDirect3DResource9Vtbl) { + fn GetContainer( + riid: *const IID, + ppContainer: *mut *mut VOID, + ) -> HRESULT, + fn GetDesc( + pDesc: *mut D3DSURFACE_DESC, + ) -> HRESULT, + fn LockRect( + pLockedRect: *mut D3DLOCKED_RECT, + pRect: *const RECT, + Flags: DWORD, + ) -> HRESULT, + fn UnlockRect() -> HRESULT, + fn GetDC( + phdc: *mut HDC, + ) -> HRESULT, + fn ReleaseDC( + hdc: HDC, + ) -> HRESULT, +}} +pub type LPDIRECT3DSURFACE9 = *mut IDirect3DSurface9; +pub type PDIRECT3DSURFACE9 = *mut IDirect3DSurface9; +RIDL!{#[uuid(0x24f416e6, 0x1f67, 0x4aa7, 0xb8, 0x8e, 0xd3, 0x3f, 0x6f, 0x31, 0x28, 0xa1)] +interface IDirect3DVolume9(IDirect3DVolume9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice( + ppDevice: *mut *mut IDirect3DDevice9, + ) -> HRESULT, + fn SetPrivateData( + refguid: *const GUID, + pData: *const VOID, + SizeOfData: DWORD, + Flags: DWORD, + ) -> HRESULT, + fn GetPrivateData( + refguid: *const GUID, + pData: *mut VOID, + pSizeOfData: *mut DWORD, + ) -> HRESULT, + fn FreePrivateData( + refguid: *const GUID, + ) -> HRESULT, + fn GetContainer( + riid: *const IID, + ppContainer: *mut *mut VOID, + ) -> HRESULT, + fn GetDesc( + pDesc: *mut D3DVOLUME_DESC, + ) -> HRESULT, + fn LockBox( + pLockedVolume: *mut D3DLOCKED_BOX, + pBox: *const D3DBOX, + Flags: DWORD, + ) -> HRESULT, + fn UnlockBox() -> HRESULT, +}} +pub type LPDIRECT3DVOLUME9 = *mut IDirect3DVolume9; +pub type PDIRECT3DVOLUME9 = *mut IDirect3DVolume9; +RIDL!{#[uuid(0xd9771460, 0xa695, 0x4f26, 0xbb, 0xd3, 0x27, 0xb8, 0x40, 0xb5, 0x41, 0xcc)] +interface IDirect3DQuery9(IDirect3DQuery9Vtbl): IUnknown(IUnknownVtbl) { + fn GetDevice( + ppDevice: *mut *mut IDirect3DDevice9, + ) -> HRESULT, + fn GetType() -> D3DRESOURCETYPE, + fn GetDataSize() -> DWORD, + fn Issue( + dwIssueFlags: DWORD, + ) -> HRESULT, + fn GetData( + pData: *mut VOID, + dwSize: DWORD, + dwGetDataFlags: DWORD, + ) -> HRESULT, +}} +pub type LPDIRECT3DQUERY9 = *mut IDirect3DQuery9; +pub type PDIRECT3DQUERY9 = *mut IDirect3DQuery9; +pub const D3DCREATE_FPU_PRESERVE: DWORD = 0x2; +pub const D3DCREATE_MULTITHREADED: DWORD = 0x4; +pub const D3DCREATE_PUREDEVICE: DWORD = 0x10; +pub const D3DCREATE_SOFTWARE_VERTEXPROCESSING: DWORD = 0x20; +pub const D3DCREATE_HARDWARE_VERTEXPROCESSING: DWORD = 0x40; +pub const D3DCREATE_MIXED_VERTEXPROCESSING: DWORD = 0x80; +pub const D3DCREATE_DISABLE_DRIVER_MANAGEMENT: DWORD = 0x100; +pub const D3DCREATE_ADAPTERGROUP_DEVICE: DWORD = 0x200; +pub const D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX: DWORD = 0x400; +pub const D3DCREATE_NOWINDOWCHANGES: DWORD = 0x800; +pub const D3DCREATE_DISABLE_PSGP_THREADING: DWORD = 0x2000; +pub const D3DCREATE_ENABLE_PRESENTSTATS: DWORD = 0x4000; +pub const D3DCREATE_DISABLE_PRESENTSTATS: DWORD = 0x8000; +pub const D3DCREATE_SCREENSAVER: DWORD = 0x10000000; +pub const D3DADAPTER_DEFAULT: DWORD = 0; +extern "system" { + pub fn Direct3DCreate9Ex( + SDKVersion: UINT, + arg1: *mut *mut IDirect3D9Ex, + ) -> HRESULT; +} +RIDL!{#[uuid(0x02177241, 0x69fc, 0x400c, 0x8f, 0xf1, 0x93, 0xa4, 0x4d, 0xf6, 0x86, 0x1d)] +interface IDirect3D9Ex(IDirect3D9ExVtbl): IDirect3D9(IDirect3D9Vtbl) { + fn GetAdapterModeCountEx( + Adapter: UINT, + pFilter: *const D3DDISPLAYMODEFILTER, + ) -> UINT, + fn EnumAdapterModesEx( + Adapter: UINT, + pFilter: *const D3DDISPLAYMODEFILTER, + Mode: UINT, + pMode: *mut D3DDISPLAYMODEEX, + ) -> HRESULT, + fn GetAdapterDisplayModeEx( + Adapter: UINT, + pMode: *mut D3DDISPLAYMODEEX, + pRotation: *mut D3DDISPLAYROTATION, + ) -> HRESULT, + fn CreateDeviceEx( + Adapter: UINT, + DeviceType: D3DDEVTYPE, + hFocusWindow: HWND, + BehaviorFlags: DWORD, + pPresentationParameters: *mut D3DPRESENT_PARAMETERS, + pFullscreenDisplayMode: *mut D3DDISPLAYMODEEX, + ppReturnedDeviceInterface: *mut *mut IDirect3DDevice9Ex, + ) -> HRESULT, + fn GetAdapterLUID( + Adapter: UINT, + pLUID: *mut LUID, + ) -> HRESULT, +}} +pub type LPDIRECT3D9EX = *mut IDirect3D9Ex; +pub type PDIRECT3D9EX = *mut IDirect3D9Ex; +RIDL!{#[uuid(0xb18b10ce, 0x2649, 0x405a, 0x87, 0xf, 0x95, 0xf7, 0x77, 0xd4, 0x31, 0x3a)] +interface IDirect3DDevice9Ex(IDirect3DDevice9ExVtbl): IDirect3DDevice9(IDirect3DDevice9Vtbl) { + fn SetConvolutionMonoKernel( + width: UINT, + height: UINT, + rows: *mut FLOAT, + columns: *mut FLOAT, + ) -> HRESULT, + fn ComposeRects( + pSrc: *mut IDirect3DSurface9, + pDst: *mut IDirect3DSurface9, + pSrcRectDescs: *mut IDirect3DVertexBuffer9, + NumRects: UINT, + pDstRectDescs: *mut IDirect3DVertexBuffer9, + Operation: D3DCOMPOSERECTSOP, + Xoffset: INT, + Yoffset: INT, + ) -> HRESULT, + fn PresentEx( + pSourceRect: *const RECT, + pDestRect: *const RECT, + hDestWindowOverride: HWND, + pDirtyRegion: *const RGNDATA, + dwFlags: DWORD, + ) -> HRESULT, + fn GetGPUThreadPriority( + pPriority: *mut INT, + ) -> HRESULT, + fn SetGPUThreadPriority( + Priority: INT, + ) -> HRESULT, + fn WaitForVBlank( + iSwapChain: UINT, + ) -> HRESULT, + fn CheckResourceResidency( + pResourceArray: *mut *mut IDirect3DResource9, + NumResources: UINT32, + ) -> HRESULT, + fn SetMaximumFrameLatency( + MaxLatency: UINT, + ) -> HRESULT, + fn GetMaximumFrameLatency( + pMaxLatency: *mut UINT, + ) -> HRESULT, + fn CheckDeviceState( + hDestinationWindow: HWND, + ) -> HRESULT, + fn CreateRenderTargetEx( + Width: UINT, + Height: UINT, + Format: D3DFORMAT, + MultiSample: D3DMULTISAMPLE_TYPE, + MultisampleQuality: DWORD, + Lockable: BOOL, + ppSurface: *mut *mut IDirect3DSurface9, + pSharedHandle: *mut HANDLE, + Usage: DWORD, + ) -> HRESULT, + fn CreateOffscreenPlainSurfaceEx( + Width: UINT, + Height: UINT, + Format: D3DFORMAT, + Pool: D3DPOOL, + ppSurface: *mut *mut IDirect3DSurface9, + pSharedHandle: *mut HANDLE, + Usage: DWORD, + ) -> HRESULT, + fn CreateDepthStencilSurfaceEx( + Width: UINT, + Height: UINT, + Format: D3DFORMAT, + MultiSample: D3DMULTISAMPLE_TYPE, + MultisampleQuality: DWORD, + Discard: BOOL, + ppSurface: *mut *mut IDirect3DSurface9, + pSharedHandle: *mut HANDLE, + Usage: DWORD, + ) -> HRESULT, + fn ResetEx( + pPresentationParameters: *mut D3DPRESENT_PARAMETERS, + pFullscreenDisplayMode: *mut D3DDISPLAYMODEEX, + ) -> HRESULT, + fn GetDisplayModeEx( + iSwapChain: UINT, + pMode: *mut D3DDISPLAYMODEEX, + pRotation: *mut D3DDISPLAYROTATION, + ) -> HRESULT, +}} +pub type LPDIRECT3DDEVICE9EX = *mut IDirect3DDevice9Ex; +pub type PDIRECT3DDEVICE9EX = *mut IDirect3DDevice9Ex; +RIDL!{#[uuid(0x91886caf, 0x1c3d, 0x4d2e, 0xa0, 0xab, 0x3e, 0x4c, 0x7d, 0x8d, 0x33, 0x3)] +interface IDirect3DSwapChain9Ex(IDirect3DSwapChain9ExVtbl): + IDirect3DSwapChain9(IDirect3DSwapChain9Vtbl) { + fn GetLastPresentCount( + pLastPresentCount: *mut UINT, + ) -> HRESULT, + fn GetPresentStats( + pPresentationStatistics: *mut D3DPRESENTSTATS, + ) -> HRESULT, + fn GetDisplayModeEx( + pMode: *mut D3DDISPLAYMODEEX, + pRotation: *mut D3DDISPLAYROTATION, + ) -> HRESULT, +}} +pub type LPDIRECT3DSWAPCHAIN9EX = *mut IDirect3DSwapChain9Ex; +pub type PDIRECT3DSWAPCHAIN9EX = *mut IDirect3DSwapChain9Ex; +RIDL!{#[uuid(0x187aeb13, 0xaaf5, 0x4c59, 0x87, 0x6d, 0xe0, 0x59, 0x8, 0x8c, 0xd, 0xf8)] +interface IDirect3D9ExOverlayExtension(IDirect3D9ExOverlayExtensionVtbl): IUnknown(IUnknownVtbl) { + fn CheckDeviceOverlayType( + Adapter: UINT, + DevType: D3DDEVTYPE, + OverlayWidth: UINT, + OverlayHeight: UINT, + OverlayFormat: D3DFORMAT, + pDisplayMode: *mut D3DDISPLAYMODEEX, + DisplayRotation: D3DDISPLAYROTATION, + pOverlayCaps: *mut D3DOVERLAYCAPS, + ) -> HRESULT, +}} +pub type LPDIRECT3D9EXOVERLAYEXTENSION = *mut IDirect3D9ExOverlayExtension; +pub type PDIRECT3D9EXOVERLAYEXTENSION = *mut IDirect3D9ExOverlayExtension; +RIDL!{#[uuid(0x26dc4561, 0xa1ee, 0x4ae7, 0x96, 0xda, 0x11, 0x8a, 0x36, 0xc0, 0xec, 0x95)] +interface IDirect3DDevice9Video(IDirect3DDevice9VideoVtbl): IUnknown(IUnknownVtbl) { + fn GetContentProtectionCaps( + pCryptoType: *const GUID, + pDecodeProfile: *const GUID, + pCaps: *mut D3DCONTENTPROTECTIONCAPS, + ) -> HRESULT, + fn CreateAuthenticatedChannel( + ChannelType: D3DAUTHENTICATEDCHANNELTYPE, + ppAuthenticatedChannel: *mut *mut IDirect3DAuthenticatedChannel9, + pChannelHandle: *mut HANDLE, + ) -> HRESULT, + fn CreateCryptoSession( + pCryptoType: *const GUID, + pDecodeProfile: *const GUID, + ppCryptoSession: *mut *mut IDirect3DCryptoSession9, + pCryptoHandle: *mut HANDLE, + ) -> HRESULT, +}} +pub type LPDIRECT3DDEVICE9VIDEO = *mut IDirect3DDevice9Video; +pub type PDIRECT3DDEVICE9VIDEO = *mut IDirect3DDevice9Video; +RIDL!{#[uuid(0xff24beee, 0xda21, 0x4beb, 0x98, 0xb5, 0xd2, 0xf8, 0x99, 0xf9, 0x8a, 0xf9)] +interface IDirect3DAuthenticatedChannel9(IDirect3DAuthenticatedChannel9Vtbl): + IUnknown(IUnknownVtbl) { + fn GetCertificateSize( + pCertificateSize: *mut UINT, + ) -> HRESULT, + fn GetCertificate( + CertifacteSize: UINT, + ppCertificate: *mut BYTE, + ) -> HRESULT, + fn NegotiateKeyExchange( + DataSize: UINT, + pData: *mut VOID, + ) -> HRESULT, + fn Query( + InputSize: UINT, + pInput: *const VOID, + OutputSize: UINT, + pOutput: *mut VOID, + ) -> HRESULT, + fn Configure( + InputSize: UINT, + pInput: *const VOID, + pOutput: *mut D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT, + ) -> HRESULT, +}} +pub type LPDIRECT3DAUTHENTICATEDCHANNEL9 = *mut IDirect3DAuthenticatedChannel9; +pub type PDIRECT3DAUTHENTICATEDCHANNEL9 = *mut IDirect3DAuthenticatedChannel9; +RIDL!{#[uuid(0xfa0ab799, 0x7a9c, 0x48ca, 0x8c, 0x5b, 0x23, 0x7e, 0x71, 0xa5, 0x44, 0x34)] +interface IDirect3DCryptoSession9(IDirect3DCryptoSession9Vtbl): IUnknown(IUnknownVtbl) { + fn GetCertificateSize( + pCertificateSize: *mut UINT, + ) -> HRESULT, + fn GetCertificate( + CertifacteSize: UINT, + ppCertificate: *mut BYTE, + ) -> HRESULT, + fn NegotiateKeyExchange( + DataSize: UINT, + pData: *mut VOID, + ) -> HRESULT, + fn EncryptionBlt( + pSrcSurface: *mut IDirect3DSurface9, + pDstSurface: *mut IDirect3DSurface9, + DstSurfaceSize: UINT, + pIV: *mut VOID, + ) -> HRESULT, + fn DecryptionBlt( + pSrcSurface: *mut IDirect3DSurface9, + pDstSurface: *mut IDirect3DSurface9, + SrcSurfaceSize: UINT, + pEncryptedBlockInfo: *mut D3DENCRYPTED_BLOCK_INFO, + pContentKey: *mut VOID, + pIV: *mut VOID, + ) -> HRESULT, + fn GetSurfacePitch( + pSrcSurface: *mut IDirect3DSurface9, + pSurfacePitch: *mut UINT, + ) -> HRESULT, + fn StartSessionKeyRefresh( + pRandomNumber: *mut VOID, + RandomNumberSize: UINT, + ) -> HRESULT, + fn FinishSessionKeyRefresh() -> HRESULT, + fn GetEncryptionBltKey( + pReadbackKey: *mut VOID, + KeySize: UINT, + ) -> HRESULT, +}} +pub type LPDIRECT3DCRYPTOSESSION9 = *mut IDirect3DCryptoSession9; +pub type PDIRECT3DCRYPTOSESSION9 = *mut IDirect3DCryptoSession9; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3d9caps.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3d9caps.rs new file mode 100644 index 0000000..e806e08 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3d9caps.rs @@ -0,0 +1,366 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Direct3D capabilities include file +use ctypes::c_float; +use shared::d3d9types::D3DDEVTYPE; +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, INT, UINT}; +use um::winnt::ULONGLONG; +STRUCT!{struct D3DVSHADERCAPS2_0 { + Caps: DWORD, + DynamicFlowControlDepth: INT, + NumTemps: INT, + StaticFlowControlDepth: INT, +}} +pub const D3DVS20CAPS_PREDICATION: DWORD = 1 << 0; +pub const D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH: DWORD = 24; +pub const D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH: DWORD = 0; +pub const D3DVS20_MAX_NUMTEMPS: DWORD = 32; +pub const D3DVS20_MIN_NUMTEMPS: DWORD = 12; +pub const D3DVS20_MAX_STATICFLOWCONTROLDEPTH: DWORD = 4; +pub const D3DVS20_MIN_STATICFLOWCONTROLDEPTH: DWORD = 1; +STRUCT!{struct D3DPSHADERCAPS2_0 { + Caps: DWORD, + DynamicFlowControlDepth: INT, + NumTemps: INT, + StaticFlowControlDepth: INT, + NumInstructionSlots: INT, +}} +pub const D3DPS20CAPS_ARBITRARYSWIZZLE: DWORD = 1 << 0; +pub const D3DPS20CAPS_GRADIENTINSTRUCTIONS: DWORD = 1 << 1; +pub const D3DPS20CAPS_PREDICATION: DWORD = 1 << 2; +pub const D3DPS20CAPS_NODEPENDENTREADLIMIT: DWORD = 1 << 3; +pub const D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT: DWORD = 1 << 4; +pub const D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH: DWORD = 24; +pub const D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH: DWORD = 0; +pub const D3DPS20_MAX_NUMTEMPS: DWORD = 32; +pub const D3DPS20_MIN_NUMTEMPS: DWORD = 12; +pub const D3DPS20_MAX_STATICFLOWCONTROLDEPTH: DWORD = 4; +pub const D3DPS20_MIN_STATICFLOWCONTROLDEPTH: DWORD = 0; +pub const D3DPS20_MAX_NUMINSTRUCTIONSLOTS: DWORD = 512; +pub const D3DPS20_MIN_NUMINSTRUCTIONSLOTS: DWORD = 96; +pub const D3DMIN30SHADERINSTRUCTIONS: DWORD = 512; +pub const D3DMAX30SHADERINSTRUCTIONS: DWORD = 32768; +STRUCT!{struct D3DOVERLAYCAPS { + Caps: UINT, + MaxOverlayDisplayWidth: UINT, + MaxOverlayDisplayHeight: UINT, +}} +pub const D3DOVERLAYCAPS_FULLRANGERGB: DWORD = 0x00000001; +pub const D3DOVERLAYCAPS_LIMITEDRANGERGB: DWORD = 0x00000002; +pub const D3DOVERLAYCAPS_YCbCr_BT601: DWORD = 0x00000004; +pub const D3DOVERLAYCAPS_YCbCr_BT709: DWORD = 0x00000008; +pub const D3DOVERLAYCAPS_YCbCr_BT601_xvYCC: DWORD = 0x00000010; +pub const D3DOVERLAYCAPS_YCbCr_BT709_xvYCC: DWORD = 0x00000020; +pub const D3DOVERLAYCAPS_STRETCHX: DWORD = 0x00000040; +pub const D3DOVERLAYCAPS_STRETCHY: DWORD = 0x00000080; +// FIXME packed(4) +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct D3DCONTENTPROTECTIONCAPS { + Caps: DWORD, + KeyExchangeType: GUID, + BufferAlignmentStart: UINT, + BlockAlignmentSize: UINT, + ProtectedMemorySize: ULONGLONG, +}} +pub const D3DCPCAPS_SOFTWARE: DWORD = 0x00000001; +pub const D3DCPCAPS_HARDWARE: DWORD = 0x00000002; +pub const D3DCPCAPS_PROTECTIONALWAYSON: DWORD = 0x00000004; +pub const D3DCPCAPS_PARTIALDECRYPTION: DWORD = 0x00000008; +pub const D3DCPCAPS_CONTENTKEY: DWORD = 0x00000010; +pub const D3DCPCAPS_FRESHENSESSIONKEY: DWORD = 0x00000020; +pub const D3DCPCAPS_ENCRYPTEDREADBACK: DWORD = 0x00000040; +pub const D3DCPCAPS_ENCRYPTEDREADBACKKEY: DWORD = 0x00000080; +pub const D3DCPCAPS_SEQUENTIAL_CTR_IV: DWORD = 0x00000100; +pub const D3DCPCAPS_ENCRYPTSLICEDATAONLY: DWORD = 0x00000200; +DEFINE_GUID!{D3DCRYPTOTYPE_AES128_CTR, + 0x9b6bd711, 0x4f74, 0x41c9, 0x9e, 0x7b, 0x0b, 0xe2, 0xd7, 0xd9, 0x3b, 0x4f} +DEFINE_GUID!{D3DCRYPTOTYPE_PROPRIETARY, + 0xab4e9afd, 0x1d1c, 0x46e6, 0xa7, 0x2f, 0x08, 0x69, 0x91, 0x7b, 0x0d, 0xe8} +DEFINE_GUID!{D3DKEYEXCHANGE_RSAES_OAEP, + 0xc1949895, 0xd72a, 0x4a1d, 0x8e, 0x5d, 0xed, 0x85, 0x7d, 0x17, 0x15, 0x20} +DEFINE_GUID!{D3DKEYEXCHANGE_DXVA, + 0x43d3775c, 0x38e5, 0x4924, 0x8d, 0x86, 0xd3, 0xfc, 0xcf, 0x15, 0x3e, 0x9b} +STRUCT!{struct D3DCAPS9 { + DeviceType: D3DDEVTYPE, + AdapterOrdinal: UINT, + Caps: DWORD, + Caps2: DWORD, + Caps3: DWORD, + PresentationIntervals: DWORD, + CursorCaps: DWORD, + DevCaps: DWORD, + PrimitiveMiscCaps: DWORD, + RasterCaps: DWORD, + ZCmpCaps: DWORD, + SrcBlendCaps: DWORD, + DestBlendCaps: DWORD, + AlphaCmpCaps: DWORD, + ShadeCaps: DWORD, + TextureCaps: DWORD, + TextureFilterCaps: DWORD, + CubeTextureFilterCaps: DWORD, + VolumeTextureFilterCaps: DWORD, + TextureAddressCaps: DWORD, + VolumeTextureAddressCaps: DWORD, + LineCaps: DWORD, + MaxTextureWidth: DWORD, + MaxTextureHeight: DWORD, + MaxVolumeExtent: DWORD, + MaxTextureRepeat: DWORD, + MaxTextureAspectRatio: DWORD, + MaxAnisotropy: DWORD, + MaxVertexW: c_float, + GuardBandLeft: c_float, + GuardBandTop: c_float, + GuardBandRight: c_float, + GuardBandBottom: c_float, + ExtentsAdjust: c_float, + StencilCaps: DWORD, + FVFCaps: DWORD, + TextureOpCaps: DWORD, + MaxTextureBlendStages: DWORD, + MaxSimultaneousTextures: DWORD, + VertexProcessingCaps: DWORD, + MaxActiveLights: DWORD, + MaxUserClipPlanes: DWORD, + MaxVertexBlendMatrices: DWORD, + MaxVertexBlendMatrixIndex: DWORD, + MaxPointSize: c_float, + MaxPrimitiveCount: DWORD, + MaxVertexIndex: DWORD, + MaxStreams: DWORD, + MaxStreamStride: DWORD, + VertexShaderVersion: DWORD, + MaxVertexShaderConst: DWORD, + PixelShaderVersion: DWORD, + PixelShader1xMaxValue: c_float, + DevCaps2: DWORD, + MaxNpatchTessellationLevel: c_float, + Reserved5: DWORD, + MasterAdapterOrdinal: UINT, + AdapterOrdinalInGroup: UINT, + NumberOfAdaptersInGroup: UINT, + DeclTypes: DWORD, + NumSimultaneousRTs: DWORD, + StretchRectFilterCaps: DWORD, + VS20Caps: D3DVSHADERCAPS2_0, + PS20Caps: D3DPSHADERCAPS2_0, + VertexTextureFilterCaps: DWORD, + MaxVShaderInstructionsExecuted: DWORD, + MaxPShaderInstructionsExecuted: DWORD, + MaxVertexShader30InstructionSlots: DWORD, + MaxPixelShader30InstructionSlots: DWORD, +}} +pub const D3DCAPS_OVERLAY: DWORD = 0x00000800; +pub const D3DCAPS_READ_SCANLINE: DWORD = 0x00020000; +pub const D3DCAPS2_FULLSCREENGAMMA: DWORD = 0x00020000; +pub const D3DCAPS2_CANCALIBRATEGAMMA: DWORD = 0x00100000; +pub const D3DCAPS2_RESERVED: DWORD = 0x02000000; +pub const D3DCAPS2_CANMANAGERESOURCE: DWORD = 0x10000000; +pub const D3DCAPS2_DYNAMICTEXTURES: DWORD = 0x20000000; +pub const D3DCAPS2_CANAUTOGENMIPMAP: DWORD = 0x40000000; +pub const D3DCAPS2_CANSHARERESOURCE: DWORD = 0x80000000; +pub const D3DCAPS3_RESERVED: DWORD = 0x8000001f; +pub const D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD: DWORD = 0x00000020; +pub const D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION: DWORD = 0x00000080; +pub const D3DCAPS3_COPY_TO_VIDMEM: DWORD = 0x00000100; +pub const D3DCAPS3_COPY_TO_SYSTEMMEM: DWORD = 0x00000200; +pub const D3DCAPS3_DXVAHD: DWORD = 0x00000400; +pub const D3DCAPS3_DXVAHD_LIMITED: DWORD = 0x00000800; +pub const D3DPRESENT_INTERVAL_DEFAULT: DWORD = 0x00000000; +pub const D3DPRESENT_INTERVAL_ONE: DWORD = 0x00000001; +pub const D3DPRESENT_INTERVAL_TWO: DWORD = 0x00000002; +pub const D3DPRESENT_INTERVAL_THREE: DWORD = 0x00000004; +pub const D3DPRESENT_INTERVAL_FOUR: DWORD = 0x00000008; +pub const D3DPRESENT_INTERVAL_IMMEDIATE: DWORD = 0x80000000; +pub const D3DCURSORCAPS_COLOR: DWORD = 0x00000001; +pub const D3DCURSORCAPS_LOWRES: DWORD = 0x00000002; +pub const D3DDEVCAPS_EXECUTESYSTEMMEMORY: DWORD = 0x00000010; +pub const D3DDEVCAPS_EXECUTEVIDEOMEMORY: DWORD = 0x00000020; +pub const D3DDEVCAPS_TLVERTEXSYSTEMMEMORY: DWORD = 0x00000040; +pub const D3DDEVCAPS_TLVERTEXVIDEOMEMORY: DWORD = 0x00000080; +pub const D3DDEVCAPS_TEXTURESYSTEMMEMORY: DWORD = 0x00000100; +pub const D3DDEVCAPS_TEXTUREVIDEOMEMORY: DWORD = 0x00000200; +pub const D3DDEVCAPS_DRAWPRIMTLVERTEX: DWORD = 0x00000400; +pub const D3DDEVCAPS_CANRENDERAFTERFLIP: DWORD = 0x00000800; +pub const D3DDEVCAPS_TEXTURENONLOCALVIDMEM: DWORD = 0x00001000; +pub const D3DDEVCAPS_DRAWPRIMITIVES2: DWORD = 0x00002000; +pub const D3DDEVCAPS_SEPARATETEXTUREMEMORIES: DWORD = 0x00004000; +pub const D3DDEVCAPS_DRAWPRIMITIVES2EX: DWORD = 0x00008000; +pub const D3DDEVCAPS_HWTRANSFORMANDLIGHT: DWORD = 0x00010000; +pub const D3DDEVCAPS_CANBLTSYSTONONLOCAL: DWORD = 0x00020000; +pub const D3DDEVCAPS_HWRASTERIZATION: DWORD = 0x00080000; +pub const D3DDEVCAPS_PUREDEVICE: DWORD = 0x00100000; +pub const D3DDEVCAPS_QUINTICRTPATCHES: DWORD = 0x00200000; +pub const D3DDEVCAPS_RTPATCHES: DWORD = 0x00400000; +pub const D3DDEVCAPS_RTPATCHHANDLEZERO: DWORD = 0x00800000; +pub const D3DDEVCAPS_NPATCHES: DWORD = 0x01000000; +pub const D3DPMISCCAPS_MASKZ: DWORD = 0x00000002; +pub const D3DPMISCCAPS_CULLNONE: DWORD = 0x00000010; +pub const D3DPMISCCAPS_CULLCW: DWORD = 0x00000020; +pub const D3DPMISCCAPS_CULLCCW: DWORD = 0x00000040; +pub const D3DPMISCCAPS_COLORWRITEENABLE: DWORD = 0x00000080; +pub const D3DPMISCCAPS_CLIPPLANESCALEDPOINTS: DWORD = 0x00000100; +pub const D3DPMISCCAPS_CLIPTLVERTS: DWORD = 0x00000200; +pub const D3DPMISCCAPS_TSSARGTEMP: DWORD = 0x00000400; +pub const D3DPMISCCAPS_BLENDOP: DWORD = 0x00000800; +pub const D3DPMISCCAPS_NULLREFERENCE: DWORD = 0x00001000; +pub const D3DPMISCCAPS_INDEPENDENTWRITEMASKS: DWORD = 0x00004000; +pub const D3DPMISCCAPS_PERSTAGECONSTANT: DWORD = 0x00008000; +pub const D3DPMISCCAPS_FOGANDSPECULARALPHA: DWORD = 0x00010000; +pub const D3DPMISCCAPS_SEPARATEALPHABLEND: DWORD = 0x00020000; +pub const D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS: DWORD = 0x00040000; +pub const D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING: DWORD = 0x00080000; +pub const D3DPMISCCAPS_FOGVERTEXCLAMPED: DWORD = 0x00100000; +pub const D3DPMISCCAPS_POSTBLENDSRGBCONVERT: DWORD = 0x00200000; +pub const D3DLINECAPS_TEXTURE: DWORD = 0x00000001; +pub const D3DLINECAPS_ZTEST: DWORD = 0x00000002; +pub const D3DLINECAPS_BLEND: DWORD = 0x00000004; +pub const D3DLINECAPS_ALPHACMP: DWORD = 0x00000008; +pub const D3DLINECAPS_FOG: DWORD = 0x00000010; +pub const D3DLINECAPS_ANTIALIAS: DWORD = 0x00000020; +pub const D3DPRASTERCAPS_DITHER: DWORD = 0x00000001; +pub const D3DPRASTERCAPS_ZTEST: DWORD = 0x00000010; +pub const D3DPRASTERCAPS_FOGVERTEX: DWORD = 0x00000080; +pub const D3DPRASTERCAPS_FOGTABLE: DWORD = 0x00000100; +pub const D3DPRASTERCAPS_MIPMAPLODBIAS: DWORD = 0x00002000; +pub const D3DPRASTERCAPS_ZBUFFERLESSHSR: DWORD = 0x00008000; +pub const D3DPRASTERCAPS_FOGRANGE: DWORD = 0x00010000; +pub const D3DPRASTERCAPS_ANISOTROPY: DWORD = 0x00020000; +pub const D3DPRASTERCAPS_WBUFFER: DWORD = 0x00040000; +pub const D3DPRASTERCAPS_WFOG: DWORD = 0x00100000; +pub const D3DPRASTERCAPS_ZFOG: DWORD = 0x00200000; +pub const D3DPRASTERCAPS_COLORPERSPECTIVE: DWORD = 0x00400000; +pub const D3DPRASTERCAPS_SCISSORTEST: DWORD = 0x01000000; +pub const D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS: DWORD = 0x02000000; +pub const D3DPRASTERCAPS_DEPTHBIAS: DWORD = 0x04000000; +pub const D3DPRASTERCAPS_MULTISAMPLE_TOGGLE: DWORD = 0x08000000; +pub const D3DPCMPCAPS_NEVER: DWORD = 0x00000001; +pub const D3DPCMPCAPS_LESS: DWORD = 0x00000002; +pub const D3DPCMPCAPS_EQUAL: DWORD = 0x00000004; +pub const D3DPCMPCAPS_LESSEQUAL: DWORD = 0x00000008; +pub const D3DPCMPCAPS_GREATER: DWORD = 0x00000010; +pub const D3DPCMPCAPS_NOTEQUAL: DWORD = 0x00000020; +pub const D3DPCMPCAPS_GREATEREQUAL: DWORD = 0x00000040; +pub const D3DPCMPCAPS_ALWAYS: DWORD = 0x00000080; +pub const D3DPBLENDCAPS_ZERO: DWORD = 0x00000001; +pub const D3DPBLENDCAPS_ONE: DWORD = 0x00000002; +pub const D3DPBLENDCAPS_SRCCOLOR: DWORD = 0x00000004; +pub const D3DPBLENDCAPS_INVSRCCOLOR: DWORD = 0x00000008; +pub const D3DPBLENDCAPS_SRCALPHA: DWORD = 0x00000010; +pub const D3DPBLENDCAPS_INVSRCALPHA: DWORD = 0x00000020; +pub const D3DPBLENDCAPS_DESTALPHA: DWORD = 0x00000040; +pub const D3DPBLENDCAPS_INVDESTALPHA: DWORD = 0x00000080; +pub const D3DPBLENDCAPS_DESTCOLOR: DWORD = 0x00000100; +pub const D3DPBLENDCAPS_INVDESTCOLOR: DWORD = 0x00000200; +pub const D3DPBLENDCAPS_SRCALPHASAT: DWORD = 0x00000400; +pub const D3DPBLENDCAPS_BOTHSRCALPHA: DWORD = 0x00000800; +pub const D3DPBLENDCAPS_BOTHINVSRCALPHA: DWORD = 0x00001000; +pub const D3DPBLENDCAPS_BLENDFACTOR: DWORD = 0x00002000; +pub const D3DPBLENDCAPS_SRCCOLOR2: DWORD = 0x00004000; +pub const D3DPBLENDCAPS_INVSRCCOLOR2: DWORD = 0x00008000; +pub const D3DPSHADECAPS_COLORGOURAUDRGB: DWORD = 0x00000008; +pub const D3DPSHADECAPS_SPECULARGOURAUDRGB: DWORD = 0x00000200; +pub const D3DPSHADECAPS_ALPHAGOURAUDBLEND: DWORD = 0x00004000; +pub const D3DPSHADECAPS_FOGGOURAUD: DWORD = 0x00080000; +pub const D3DPTEXTURECAPS_PERSPECTIVE: DWORD = 0x00000001; +pub const D3DPTEXTURECAPS_POW2: DWORD = 0x00000002; +pub const D3DPTEXTURECAPS_ALPHA: DWORD = 0x00000004; +pub const D3DPTEXTURECAPS_SQUAREONLY: DWORD = 0x00000020; +pub const D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE: DWORD = 0x00000040; +pub const D3DPTEXTURECAPS_ALPHAPALETTE: DWORD = 0x00000080; +pub const D3DPTEXTURECAPS_NONPOW2CONDITIONAL: DWORD = 0x00000100; +pub const D3DPTEXTURECAPS_PROJECTED: DWORD = 0x00000400; +pub const D3DPTEXTURECAPS_CUBEMAP: DWORD = 0x00000800; +pub const D3DPTEXTURECAPS_VOLUMEMAP: DWORD = 0x00002000; +pub const D3DPTEXTURECAPS_MIPMAP: DWORD = 0x00004000; +pub const D3DPTEXTURECAPS_MIPVOLUMEMAP: DWORD = 0x00008000; +pub const D3DPTEXTURECAPS_MIPCUBEMAP: DWORD = 0x00010000; +pub const D3DPTEXTURECAPS_CUBEMAP_POW2: DWORD = 0x00020000; +pub const D3DPTEXTURECAPS_VOLUMEMAP_POW2: DWORD = 0x00040000; +pub const D3DPTEXTURECAPS_NOPROJECTEDBUMPENV: DWORD = 0x00200000; +pub const D3DPTFILTERCAPS_MINFPOINT: DWORD = 0x00000100; +pub const D3DPTFILTERCAPS_MINFLINEAR: DWORD = 0x00000200; +pub const D3DPTFILTERCAPS_MINFANISOTROPIC: DWORD = 0x00000400; +pub const D3DPTFILTERCAPS_MINFPYRAMIDALQUAD: DWORD = 0x00000800; +pub const D3DPTFILTERCAPS_MINFGAUSSIANQUAD: DWORD = 0x00001000; +pub const D3DPTFILTERCAPS_MIPFPOINT: DWORD = 0x00010000; +pub const D3DPTFILTERCAPS_MIPFLINEAR: DWORD = 0x00020000; +pub const D3DPTFILTERCAPS_CONVOLUTIONMONO: DWORD = 0x00040000; +pub const D3DPTFILTERCAPS_MAGFPOINT: DWORD = 0x01000000; +pub const D3DPTFILTERCAPS_MAGFLINEAR: DWORD = 0x02000000; +pub const D3DPTFILTERCAPS_MAGFANISOTROPIC: DWORD = 0x04000000; +pub const D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD: DWORD = 0x08000000; +pub const D3DPTFILTERCAPS_MAGFGAUSSIANQUAD: DWORD = 0x10000000; +pub const D3DPTADDRESSCAPS_WRAP: DWORD = 0x00000001; +pub const D3DPTADDRESSCAPS_MIRROR: DWORD = 0x00000002; +pub const D3DPTADDRESSCAPS_CLAMP: DWORD = 0x00000004; +pub const D3DPTADDRESSCAPS_BORDER: DWORD = 0x00000008; +pub const D3DPTADDRESSCAPS_INDEPENDENTUV: DWORD = 0x00000010; +pub const D3DPTADDRESSCAPS_MIRRORONCE: DWORD = 0x00000020; +pub const D3DSTENCILCAPS_KEEP: DWORD = 0x00000001; +pub const D3DSTENCILCAPS_ZERO: DWORD = 0x00000002; +pub const D3DSTENCILCAPS_REPLACE: DWORD = 0x00000004; +pub const D3DSTENCILCAPS_INCRSAT: DWORD = 0x00000008; +pub const D3DSTENCILCAPS_DECRSAT: DWORD = 0x00000010; +pub const D3DSTENCILCAPS_INVERT: DWORD = 0x00000020; +pub const D3DSTENCILCAPS_INCR: DWORD = 0x00000040; +pub const D3DSTENCILCAPS_DECR: DWORD = 0x00000080; +pub const D3DSTENCILCAPS_TWOSIDED: DWORD = 0x00000100; +pub const D3DTEXOPCAPS_DISABLE: DWORD = 0x00000001; +pub const D3DTEXOPCAPS_SELECTARG1: DWORD = 0x00000002; +pub const D3DTEXOPCAPS_SELECTARG2: DWORD = 0x00000004; +pub const D3DTEXOPCAPS_MODULATE: DWORD = 0x00000008; +pub const D3DTEXOPCAPS_MODULATE2X: DWORD = 0x00000010; +pub const D3DTEXOPCAPS_MODULATE4X: DWORD = 0x00000020; +pub const D3DTEXOPCAPS_ADD: DWORD = 0x00000040; +pub const D3DTEXOPCAPS_ADDSIGNED: DWORD = 0x00000080; +pub const D3DTEXOPCAPS_ADDSIGNED2X: DWORD = 0x00000100; +pub const D3DTEXOPCAPS_SUBTRACT: DWORD = 0x00000200; +pub const D3DTEXOPCAPS_ADDSMOOTH: DWORD = 0x00000400; +pub const D3DTEXOPCAPS_BLENDDIFFUSEALPHA: DWORD = 0x00000800; +pub const D3DTEXOPCAPS_BLENDTEXTUREALPHA: DWORD = 0x00001000; +pub const D3DTEXOPCAPS_BLENDFACTORALPHA: DWORD = 0x00002000; +pub const D3DTEXOPCAPS_BLENDTEXTUREALPHAPM: DWORD = 0x00004000; +pub const D3DTEXOPCAPS_BLENDCURRENTALPHA: DWORD = 0x00008000; +pub const D3DTEXOPCAPS_PREMODULATE: DWORD = 0x00010000; +pub const D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR: DWORD = 0x00020000; +pub const D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA: DWORD = 0x00040000; +pub const D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR: DWORD = 0x00080000; +pub const D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA: DWORD = 0x00100000; +pub const D3DTEXOPCAPS_BUMPENVMAP: DWORD = 0x00200000; +pub const D3DTEXOPCAPS_BUMPENVMAPLUMINANCE: DWORD = 0x00400000; +pub const D3DTEXOPCAPS_DOTPRODUCT3: DWORD = 0x00800000; +pub const D3DTEXOPCAPS_MULTIPLYADD: DWORD = 0x01000000; +pub const D3DTEXOPCAPS_LERP: DWORD = 0x02000000; +pub const D3DFVFCAPS_TEXCOORDCOUNTMASK: DWORD = 0x0000ffff; +pub const D3DFVFCAPS_DONOTSTRIPELEMENTS: DWORD = 0x00080000; +pub const D3DFVFCAPS_PSIZE: DWORD = 0x00100000; +pub const D3DVTXPCAPS_TEXGEN: DWORD = 0x00000001; +pub const D3DVTXPCAPS_MATERIALSOURCE7: DWORD = 0x00000002; +pub const D3DVTXPCAPS_DIRECTIONALLIGHTS: DWORD = 0x00000008; +pub const D3DVTXPCAPS_POSITIONALLIGHTS: DWORD = 0x00000010; +pub const D3DVTXPCAPS_LOCALVIEWER: DWORD = 0x00000020; +pub const D3DVTXPCAPS_TWEENING: DWORD = 0x00000040; +pub const D3DVTXPCAPS_TEXGEN_SPHEREMAP: DWORD = 0x00000100; +pub const D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER: DWORD = 0x00000200; +pub const D3DDEVCAPS2_STREAMOFFSET: DWORD = 0x00000001; +pub const D3DDEVCAPS2_DMAPNPATCH: DWORD = 0x00000002; +pub const D3DDEVCAPS2_ADAPTIVETESSRTPATCH: DWORD = 0x00000004; +pub const D3DDEVCAPS2_ADAPTIVETESSNPATCH: DWORD = 0x00000008; +pub const D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES: DWORD = 0x00000010; +pub const D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH: DWORD = 0x00000020; +pub const D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET: DWORD = 0x00000040; +pub const D3DDTCAPS_UBYTE4: DWORD = 0x00000001; +pub const D3DDTCAPS_UBYTE4N: DWORD = 0x00000002; +pub const D3DDTCAPS_SHORT2N: DWORD = 0x00000004; +pub const D3DDTCAPS_SHORT4N: DWORD = 0x00000008; +pub const D3DDTCAPS_USHORT2N: DWORD = 0x00000010; +pub const D3DDTCAPS_USHORT4N: DWORD = 0x00000020; +pub const D3DDTCAPS_UDEC3: DWORD = 0x00000040; +pub const D3DDTCAPS_DEC3N: DWORD = 0x00000080; +pub const D3DDTCAPS_FLOAT16_2: DWORD = 0x00000100; +pub const D3DDTCAPS_FLOAT16_4: DWORD = 0x00000200; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3d9types.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3d9types.rs new file mode 100644 index 0000000..e794d27 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3d9types.rs @@ -0,0 +1,1487 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Direct3D capabilities include file +use ctypes::{c_char, c_float, c_void}; +use shared::basetsd::UINT64; +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, INT, UINT, USHORT, WORD}; +use shared::windef::HWND; +use um::winnt::{HANDLE, HRESULT, LARGE_INTEGER, LONG, SHORT}; +pub type D3DCOLOR = DWORD; +#[inline] +pub fn D3DCOLOR_ARGB(a: DWORD, r: DWORD, g: DWORD, b: DWORD) -> D3DCOLOR { + (((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)) as D3DCOLOR +} +#[inline] +pub fn D3DCOLOR_RGBA(r: DWORD, g: DWORD, b: DWORD, a: DWORD) -> D3DCOLOR { + D3DCOLOR_ARGB(a, r, g, b) +} +#[inline] +pub fn D3DCOLOR_XRGB(r: DWORD, g: DWORD, b: DWORD) -> D3DCOLOR { + D3DCOLOR_ARGB(0xff, r, g, b) +} +#[inline] +pub fn D3DCOLOR_XYUV(y: DWORD, u: DWORD, v: DWORD) -> D3DCOLOR { + D3DCOLOR_ARGB(0xff, y, u, v) +} +#[inline] +pub fn D3DCOLOR_AYUV(a: DWORD, y: DWORD, u: DWORD, v: DWORD) -> D3DCOLOR { + D3DCOLOR_ARGB(a, y, u, v) +} +#[inline] +pub fn D3DCOLOR_COLORVALUE(r: f32, g: f32, b: f32, a: f32) -> D3DCOLOR { + D3DCOLOR_ARGB( + (r * 255f32) as DWORD, + (g * 255f32) as DWORD, + (b * 255f32) as DWORD, + (a * 255f32) as DWORD, + ) +} +STRUCT!{struct D3DVECTOR { + x: c_float, + y: c_float, + z: c_float, +}} +STRUCT!{struct D3DCOLORVALUE { + r: c_float, + g: c_float, + b: c_float, + a: c_float, +}} +STRUCT!{struct D3DRECT { + x1: LONG, + y1: LONG, + x2: LONG, + y2: LONG, +}} +STRUCT!{struct D3DMATRIX { + m: [[c_float; 4]; 4], +}} +STRUCT!{struct D3DVIEWPORT9 { + X: DWORD, + Y: DWORD, + Width: DWORD, + Height: DWORD, + MinZ: c_float, + MaxZ: c_float, +}} +pub const D3DMAXUSERCLIPPLANES: DWORD = 32; +pub const D3DCLIPPLANE0: DWORD = 1 << 0; +pub const D3DCLIPPLANE1: DWORD = 1 << 1; +pub const D3DCLIPPLANE2: DWORD = 1 << 2; +pub const D3DCLIPPLANE3: DWORD = 1 << 3; +pub const D3DCLIPPLANE4: DWORD = 1 << 4; +pub const D3DCLIPPLANE5: DWORD = 1 << 5; +pub const D3DCS_LEFT: DWORD = 0x00000001; +pub const D3DCS_RIGHT: DWORD = 0x00000002; +pub const D3DCS_TOP: DWORD = 0x00000004; +pub const D3DCS_BOTTOM: DWORD = 0x00000008; +pub const D3DCS_FRONT: DWORD = 0x00000010; +pub const D3DCS_BACK: DWORD = 0x00000020; +pub const D3DCS_PLANE0: DWORD = 0x00000040; +pub const D3DCS_PLANE1: DWORD = 0x00000080; +pub const D3DCS_PLANE2: DWORD = 0x00000100; +pub const D3DCS_PLANE3: DWORD = 0x00000200; +pub const D3DCS_PLANE4: DWORD = 0x00000400; +pub const D3DCS_PLANE5: DWORD = 0x00000800; +pub const D3DCS_ALL: DWORD = D3DCS_LEFT | D3DCS_RIGHT | D3DCS_TOP | D3DCS_BOTTOM | D3DCS_FRONT + | D3DCS_BACK | D3DCS_PLANE0 | D3DCS_PLANE1 | D3DCS_PLANE2 | D3DCS_PLANE3 | D3DCS_PLANE4 + | D3DCS_PLANE5; +STRUCT!{struct D3DCLIPSTATUS9 { + ClipUnion: DWORD, + ClipIntersection: DWORD, +}} +STRUCT!{struct D3DMATERIAL9 { + Diffuse: D3DCOLORVALUE, + Ambient: D3DCOLORVALUE, + Specular: D3DCOLORVALUE, + Emissive: D3DCOLORVALUE, + Power: c_float, +}} +ENUM!{enum D3DLIGHTTYPE { + D3DLIGHT_POINT = 1, + D3DLIGHT_SPOT = 2, + D3DLIGHT_DIRECTIONAL = 3, +}} +STRUCT!{struct D3DLIGHT9 { + Type: D3DLIGHTTYPE, + Diffuse: D3DCOLORVALUE, + Specular: D3DCOLORVALUE, + Ambient: D3DCOLORVALUE, + Position: D3DVECTOR, + Direction: D3DVECTOR, + Range: c_float, + Falloff: c_float, + Attenuation0: c_float, + Attenuation1: c_float, + Attenuation2: c_float, + Theta: c_float, + Phi: c_float, +}} +pub const D3DCLEAR_TARGET: DWORD = 0x00000001; +pub const D3DCLEAR_ZBUFFER: DWORD = 0x00000002; +pub const D3DCLEAR_STENCIL: DWORD = 0x00000004; +ENUM!{enum D3DSHADEMODE { + D3DSHADE_FLAT = 1, + D3DSHADE_GOURAUD = 2, + D3DSHADE_PHONG = 3, +}} +ENUM!{enum D3DFILLMODE { + D3DFILL_POINT = 1, + D3DFILL_WIREFRAME = 2, + D3DFILL_SOLID = 3, +}} +ENUM!{enum D3DBLEND { + D3DBLEND_ZERO = 1, + D3DBLEND_ONE = 2, + D3DBLEND_SRCCOLOR = 3, + D3DBLEND_INVSRCCOLOR = 4, + D3DBLEND_SRCALPHA = 5, + D3DBLEND_INVSRCALPHA = 6, + D3DBLEND_DESTALPHA = 7, + D3DBLEND_INVDESTALPHA = 8, + D3DBLEND_DESTCOLOR = 9, + D3DBLEND_INVDESTCOLOR = 10, + D3DBLEND_SRCALPHASAT = 11, + D3DBLEND_BOTHSRCALPHA = 12, + D3DBLEND_BOTHINVSRCALPHA = 13, + D3DBLEND_BLENDFACTOR = 14, + D3DBLEND_INVBLENDFACTOR = 15, + D3DBLEND_SRCCOLOR2 = 16, + D3DBLEND_INVSRCCOLOR2 = 17, +}} +ENUM!{enum D3DBLENDOP { + D3DBLENDOP_ADD = 1, + D3DBLENDOP_SUBTRACT = 2, + D3DBLENDOP_REVSUBTRACT = 3, + D3DBLENDOP_MIN = 4, + D3DBLENDOP_MAX = 5, +}} +ENUM!{enum D3DTEXTUREADDRESS { + D3DTADDRESS_WRAP = 1, + D3DTADDRESS_MIRROR = 2, + D3DTADDRESS_CLAMP = 3, + D3DTADDRESS_BORDER = 4, + D3DTADDRESS_MIRRORONCE = 5, +}} +ENUM!{enum D3DCULL { + D3DCULL_NONE = 1, + D3DCULL_CW = 2, + D3DCULL_CCW = 3, +}} +ENUM!{enum D3DCMPFUNC { + D3DCMP_NEVER = 1, + D3DCMP_LESS = 2, + D3DCMP_EQUAL = 3, + D3DCMP_LESSEQUAL = 4, + D3DCMP_GREATER = 5, + D3DCMP_NOTEQUAL = 6, + D3DCMP_GREATEREQUAL = 7, + D3DCMP_ALWAYS = 8, +}} +ENUM!{enum D3DSTENCILOP { + D3DSTENCILOP_KEEP = 1, + D3DSTENCILOP_ZERO = 2, + D3DSTENCILOP_REPLACE = 3, + D3DSTENCILOP_INCRSAT = 4, + D3DSTENCILOP_DECRSAT = 5, + D3DSTENCILOP_INVERT = 6, + D3DSTENCILOP_INCR = 7, + D3DSTENCILOP_DECR = 8, +}} +ENUM!{enum D3DFOGMODE { + D3DFOG_NONE = 0, + D3DFOG_EXP = 1, + D3DFOG_EXP2 = 2, + D3DFOG_LINEAR = 3, +}} +ENUM!{enum D3DZBUFFERTYPE { + D3DZB_FALSE = 0, + D3DZB_TRUE = 1, + D3DZB_USEW = 2, +}} +ENUM!{enum D3DPRIMITIVETYPE { + D3DPT_POINTLIST = 1, + D3DPT_LINELIST = 2, + D3DPT_LINESTRIP = 3, + D3DPT_TRIANGLELIST = 4, + D3DPT_TRIANGLESTRIP = 5, + D3DPT_TRIANGLEFAN = 6, +}} +ENUM!{enum D3DTRANSFORMSTATETYPE { + D3DTS_VIEW = 2, + D3DTS_PROJECTION = 3, + D3DTS_TEXTURE0 = 16, + D3DTS_TEXTURE1 = 17, + D3DTS_TEXTURE2 = 18, + D3DTS_TEXTURE3 = 19, + D3DTS_TEXTURE4 = 20, + D3DTS_TEXTURE5 = 21, + D3DTS_TEXTURE6 = 22, + D3DTS_TEXTURE7 = 23, +}} +macro_rules! D3DTS_WORLDMATRIX { + ($index:expr) => ($index + 256) +} +pub const D3DTS_WORLD: D3DTRANSFORMSTATETYPE = D3DTS_WORLDMATRIX!(0); +pub const D3DTS_WORLD1: D3DTRANSFORMSTATETYPE = D3DTS_WORLDMATRIX!(1); +pub const D3DTS_WORLD2: D3DTRANSFORMSTATETYPE = D3DTS_WORLDMATRIX!(2); +pub const D3DTS_WORLD3: D3DTRANSFORMSTATETYPE = D3DTS_WORLDMATRIX!(3); +ENUM!{enum D3DRENDERSTATETYPE { + D3DRS_ZENABLE = 7, + D3DRS_FILLMODE = 8, + D3DRS_SHADEMODE = 9, + D3DRS_ZWRITEENABLE = 14, + D3DRS_ALPHATESTENABLE = 15, + D3DRS_LASTPIXEL = 16, + D3DRS_SRCBLEND = 19, + D3DRS_DESTBLEND = 20, + D3DRS_CULLMODE = 22, + D3DRS_ZFUNC = 23, + D3DRS_ALPHAREF = 24, + D3DRS_ALPHAFUNC = 25, + D3DRS_DITHERENABLE = 26, + D3DRS_ALPHABLENDENABLE = 27, + D3DRS_FOGENABLE = 28, + D3DRS_SPECULARENABLE = 29, + D3DRS_FOGCOLOR = 34, + D3DRS_FOGTABLEMODE = 35, + D3DRS_FOGSTART = 36, + D3DRS_FOGEND = 37, + D3DRS_FOGDENSITY = 38, + D3DRS_RANGEFOGENABLE = 48, + D3DRS_STENCILENABLE = 52, + D3DRS_STENCILFAIL = 53, + D3DRS_STENCILZFAIL = 54, + D3DRS_STENCILPASS = 55, + D3DRS_STENCILFUNC = 56, + D3DRS_STENCILREF = 57, + D3DRS_STENCILMASK = 58, + D3DRS_STENCILWRITEMASK = 59, + D3DRS_TEXTUREFACTOR = 60, + D3DRS_WRAP0 = 128, + D3DRS_WRAP1 = 129, + D3DRS_WRAP2 = 130, + D3DRS_WRAP3 = 131, + D3DRS_WRAP4 = 132, + D3DRS_WRAP5 = 133, + D3DRS_WRAP6 = 134, + D3DRS_WRAP7 = 135, + D3DRS_CLIPPING = 136, + D3DRS_LIGHTING = 137, + D3DRS_AMBIENT = 139, + D3DRS_FOGVERTEXMODE = 140, + D3DRS_COLORVERTEX = 141, + D3DRS_LOCALVIEWER = 142, + D3DRS_NORMALIZENORMALS = 143, + D3DRS_DIFFUSEMATERIALSOURCE = 145, + D3DRS_SPECULARMATERIALSOURCE = 146, + D3DRS_AMBIENTMATERIALSOURCE = 147, + D3DRS_EMISSIVEMATERIALSOURCE = 148, + D3DRS_VERTEXBLEND = 151, + D3DRS_CLIPPLANEENABLE = 152, + D3DRS_POINTSIZE = 154, + D3DRS_POINTSIZE_MIN = 155, + D3DRS_POINTSPRITEENABLE = 156, + D3DRS_POINTSCALEENABLE = 157, + D3DRS_POINTSCALE_A = 158, + D3DRS_POINTSCALE_B = 159, + D3DRS_POINTSCALE_C = 160, + D3DRS_MULTISAMPLEANTIALIAS = 161, + D3DRS_MULTISAMPLEMASK = 162, + D3DRS_PATCHEDGESTYLE = 163, + D3DRS_DEBUGMONITORTOKEN = 165, + D3DRS_POINTSIZE_MAX = 166, + D3DRS_INDEXEDVERTEXBLENDENABLE = 167, + D3DRS_COLORWRITEENABLE = 168, + D3DRS_TWEENFACTOR = 170, + D3DRS_BLENDOP = 171, + D3DRS_POSITIONDEGREE = 172, + D3DRS_NORMALDEGREE = 173, + D3DRS_SCISSORTESTENABLE = 174, + D3DRS_SLOPESCALEDEPTHBIAS = 175, + D3DRS_ANTIALIASEDLINEENABLE = 176, + D3DRS_MINTESSELLATIONLEVEL = 178, + D3DRS_MAXTESSELLATIONLEVEL = 179, + D3DRS_ADAPTIVETESS_X = 180, + D3DRS_ADAPTIVETESS_Y = 181, + D3DRS_ADAPTIVETESS_Z = 182, + D3DRS_ADAPTIVETESS_W = 183, + D3DRS_ENABLEADAPTIVETESSELLATION = 184, + D3DRS_TWOSIDEDSTENCILMODE = 185, + D3DRS_CCW_STENCILFAIL = 186, + D3DRS_CCW_STENCILZFAIL = 187, + D3DRS_CCW_STENCILPASS = 188, + D3DRS_CCW_STENCILFUNC = 189, + D3DRS_COLORWRITEENABLE1 = 190, + D3DRS_COLORWRITEENABLE2 = 191, + D3DRS_COLORWRITEENABLE3 = 192, + D3DRS_BLENDFACTOR = 193, + D3DRS_SRGBWRITEENABLE = 194, + D3DRS_DEPTHBIAS = 195, + D3DRS_WRAP8 = 198, + D3DRS_WRAP9 = 199, + D3DRS_WRAP10 = 200, + D3DRS_WRAP11 = 201, + D3DRS_WRAP12 = 202, + D3DRS_WRAP13 = 203, + D3DRS_WRAP14 = 204, + D3DRS_WRAP15 = 205, + D3DRS_SEPARATEALPHABLENDENABLE = 206, + D3DRS_SRCBLENDALPHA = 207, + D3DRS_DESTBLENDALPHA = 208, + D3DRS_BLENDOPALPHA = 209, +}} +pub const D3D_MAX_SIMULTANEOUS_RENDERTARGETS: DWORD = 4; +ENUM!{enum D3DMATERIALCOLORSOURCE { + D3DMCS_MATERIAL = 0, + D3DMCS_COLOR1 = 1, + D3DMCS_COLOR2 = 2, +}} +pub const D3DRENDERSTATE_WRAPBIAS: DWORD = 128; +pub const D3DWRAP_U: DWORD = 0x00000001; +pub const D3DWRAP_V: DWORD = 0x00000002; +pub const D3DWRAP_W: DWORD = 0x00000004; +pub const D3DWRAPCOORD_0: DWORD = 0x00000001; +pub const D3DWRAPCOORD_1: DWORD = 0x00000002; +pub const D3DWRAPCOORD_2: DWORD = 0x00000004; +pub const D3DWRAPCOORD_3: DWORD = 0x00000008; +pub const D3DCOLORWRITEENABLE_RED: DWORD = 1 << 0; +pub const D3DCOLORWRITEENABLE_GREEN: DWORD = 1 << 1; +pub const D3DCOLORWRITEENABLE_BLUE: DWORD = 1 << 2; +pub const D3DCOLORWRITEENABLE_ALPHA: DWORD = 1 << 3; +ENUM!{enum D3DTEXTURESTAGESTATETYPE { + D3DTSS_COLOROP = 1, + D3DTSS_COLORARG1 = 2, + D3DTSS_COLORARG2 = 3, + D3DTSS_ALPHAOP = 4, + D3DTSS_ALPHAARG1 = 5, + D3DTSS_ALPHAARG2 = 6, + D3DTSS_BUMPENVMAT00 = 7, + D3DTSS_BUMPENVMAT01 = 8, + D3DTSS_BUMPENVMAT10 = 9, + D3DTSS_BUMPENVMAT11 = 10, + D3DTSS_TEXCOORDINDEX = 11, + D3DTSS_BUMPENVLSCALE = 22, + D3DTSS_BUMPENVLOFFSET = 23, + D3DTSS_TEXTURETRANSFORMFLAGS = 24, + D3DTSS_COLORARG0 = 26, + D3DTSS_ALPHAARG0 = 27, + D3DTSS_RESULTARG = 28, + D3DTSS_CONSTANT = 32, +}} +ENUM!{enum D3DSAMPLERSTATETYPE { + D3DSAMP_ADDRESSU = 1, + D3DSAMP_ADDRESSV = 2, + D3DSAMP_ADDRESSW = 3, + D3DSAMP_BORDERCOLOR = 4, + D3DSAMP_MAGFILTER = 5, + D3DSAMP_MINFILTER = 6, + D3DSAMP_MIPFILTER = 7, + D3DSAMP_MIPMAPLODBIAS = 8, + D3DSAMP_MAXMIPLEVEL = 9, + D3DSAMP_MAXANISOTROPY = 10, + D3DSAMP_SRGBTEXTURE = 11, + D3DSAMP_ELEMENTINDEX = 12, + D3DSAMP_DMAPOFFSET = 13, +}} +pub const D3DDMAPSAMPLER: DWORD = 256; +pub const D3DVERTEXTEXTURESAMPLER0: DWORD = D3DDMAPSAMPLER + 1; +pub const D3DVERTEXTEXTURESAMPLER1: DWORD = D3DDMAPSAMPLER + 2; +pub const D3DVERTEXTEXTURESAMPLER2: DWORD = D3DDMAPSAMPLER + 3; +pub const D3DVERTEXTEXTURESAMPLER3: DWORD = D3DDMAPSAMPLER + 4; +pub const D3DTSS_TCI_PASSTHRU: DWORD = 0x00000000; +pub const D3DTSS_TCI_CAMERASPACENORMAL: DWORD = 0x00010000; +pub const D3DTSS_TCI_CAMERASPACEPOSITION: DWORD = 0x00020000; +pub const D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR: DWORD = 0x00030000; +pub const D3DTSS_TCI_SPHEREMAP: DWORD = 0x00040000; +ENUM!{enum D3DTEXTUREOP { + D3DTOP_DISABLE = 1, + D3DTOP_SELECTARG1 = 2, + D3DTOP_SELECTARG2 = 3, + D3DTOP_MODULATE = 4, + D3DTOP_MODULATE2X = 5, + D3DTOP_MODULATE4X = 6, + D3DTOP_ADD = 7, + D3DTOP_ADDSIGNED = 8, + D3DTOP_ADDSIGNED2X = 9, + D3DTOP_SUBTRACT = 10, + D3DTOP_ADDSMOOTH = 11, + D3DTOP_BLENDDIFFUSEALPHA = 12, + D3DTOP_BLENDTEXTUREALPHA = 13, + D3DTOP_BLENDFACTORALPHA = 14, + D3DTOP_BLENDTEXTUREALPHAPM = 15, + D3DTOP_BLENDCURRENTALPHA = 16, + D3DTOP_PREMODULATE = 17, + D3DTOP_MODULATEALPHA_ADDCOLOR = 18, + D3DTOP_MODULATECOLOR_ADDALPHA = 19, + D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20, + D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21, + D3DTOP_BUMPENVMAP = 22, + D3DTOP_BUMPENVMAPLUMINANCE = 23, + D3DTOP_DOTPRODUCT3 = 24, + D3DTOP_MULTIPLYADD = 25, + D3DTOP_LERP = 26, +}} +pub const D3DTA_SELECTMASK: DWORD = 0x0000000f; +pub const D3DTA_DIFFUSE: DWORD = 0x00000000; +pub const D3DTA_CURRENT: DWORD = 0x00000001; +pub const D3DTA_TEXTURE: DWORD = 0x00000002; +pub const D3DTA_TFACTOR: DWORD = 0x00000003; +pub const D3DTA_SPECULAR: DWORD = 0x00000004; +pub const D3DTA_TEMP: DWORD = 0x00000005; +pub const D3DTA_CONSTANT: DWORD = 0x00000006; +pub const D3DTA_COMPLEMENT: DWORD = 0x00000010; +pub const D3DTA_ALPHAREPLICATE: DWORD = 0x00000020; +ENUM!{enum D3DTEXTUREFILTERTYPE { + D3DTEXF_NONE = 0, + D3DTEXF_POINT = 1, + D3DTEXF_LINEAR = 2, + D3DTEXF_ANISOTROPIC = 3, + D3DTEXF_PYRAMIDALQUAD = 6, + D3DTEXF_GAUSSIANQUAD = 7, + D3DTEXF_CONVOLUTIONMONO = 8, +}} +pub const D3DPV_DONOTCOPYDATA: DWORD = 1 << 0; +pub const D3DFVF_RESERVED0: DWORD = 0x001; +pub const D3DFVF_POSITION_MASK: DWORD = 0x400E; +pub const D3DFVF_XYZ: DWORD = 0x002; +pub const D3DFVF_XYZRHW: DWORD = 0x004; +pub const D3DFVF_XYZB1: DWORD = 0x006; +pub const D3DFVF_XYZB2: DWORD = 0x008; +pub const D3DFVF_XYZB3: DWORD = 0x00a; +pub const D3DFVF_XYZB4: DWORD = 0x00c; +pub const D3DFVF_XYZB5: DWORD = 0x00e; +pub const D3DFVF_XYZW: DWORD = 0x4002; +pub const D3DFVF_NORMAL: DWORD = 0x010; +pub const D3DFVF_PSIZE: DWORD = 0x020; +pub const D3DFVF_DIFFUSE: DWORD = 0x040; +pub const D3DFVF_SPECULAR: DWORD = 0x080; +pub const D3DFVF_TEXCOUNT_MASK: DWORD = 0xf00; +pub const D3DFVF_TEXCOUNT_SHIFT: DWORD = 8; +pub const D3DFVF_TEX0: DWORD = 0x000; +pub const D3DFVF_TEX1: DWORD = 0x100; +pub const D3DFVF_TEX2: DWORD = 0x200; +pub const D3DFVF_TEX3: DWORD = 0x300; +pub const D3DFVF_TEX4: DWORD = 0x400; +pub const D3DFVF_TEX5: DWORD = 0x500; +pub const D3DFVF_TEX6: DWORD = 0x600; +pub const D3DFVF_TEX7: DWORD = 0x700; +pub const D3DFVF_TEX8: DWORD = 0x800; +pub const D3DFVF_LASTBETA_UBYTE4: DWORD = 0x1000; +pub const D3DFVF_LASTBETA_D3DCOLOR: DWORD = 0x8000; +pub const D3DFVF_RESERVED2: DWORD = 0x6000; +ENUM!{enum D3DDECLUSAGE { + D3DDECLUSAGE_POSITION = 0, + D3DDECLUSAGE_BLENDWEIGHT, + D3DDECLUSAGE_BLENDINDICES, + D3DDECLUSAGE_NORMAL, + D3DDECLUSAGE_PSIZE, + D3DDECLUSAGE_TEXCOORD, + D3DDECLUSAGE_TANGENT, + D3DDECLUSAGE_BINORMAL, + D3DDECLUSAGE_TESSFACTOR, + D3DDECLUSAGE_POSITIONT, + D3DDECLUSAGE_COLOR, + D3DDECLUSAGE_FOG, + D3DDECLUSAGE_DEPTH, + D3DDECLUSAGE_SAMPLE, +}} +pub const MAXD3DDECLUSAGE: D3DDECLUSAGE = D3DDECLUSAGE_SAMPLE; +pub const MAXD3DDECLUSAGEINDEX: DWORD = 15; +pub const MAXD3DDECLLENGTH: DWORD = 64; +ENUM!{enum D3DDECLMETHOD { + D3DDECLMETHOD_DEFAULT = 0, + D3DDECLMETHOD_PARTIALU, + D3DDECLMETHOD_PARTIALV, + D3DDECLMETHOD_CROSSUV, + D3DDECLMETHOD_UV, + D3DDECLMETHOD_LOOKUP, + D3DDECLMETHOD_LOOKUPPRESAMPLED, +}} +pub const MAXD3DDECLMETHOD: D3DDECLMETHOD = D3DDECLMETHOD_LOOKUPPRESAMPLED; +ENUM!{enum D3DDECLTYPE { + D3DDECLTYPE_FLOAT1 = 0, + D3DDECLTYPE_FLOAT2 = 1, + D3DDECLTYPE_FLOAT3 = 2, + D3DDECLTYPE_FLOAT4 = 3, + D3DDECLTYPE_D3DCOLOR = 4, + D3DDECLTYPE_UBYTE4 = 5, + D3DDECLTYPE_SHORT2 = 6, + D3DDECLTYPE_SHORT4 = 7, + D3DDECLTYPE_UBYTE4N = 8, + D3DDECLTYPE_SHORT2N = 9, + D3DDECLTYPE_SHORT4N = 10, + D3DDECLTYPE_USHORT2N = 11, + D3DDECLTYPE_USHORT4N = 12, + D3DDECLTYPE_UDEC3 = 13, + D3DDECLTYPE_DEC3N = 14, + D3DDECLTYPE_FLOAT16_2 = 15, + D3DDECLTYPE_FLOAT16_4 = 16, + D3DDECLTYPE_UNUSED = 17, +}} +pub const MAXD3DDECLTYPE: D3DDECLTYPE = D3DDECLTYPE_UNUSED; +STRUCT!{struct D3DVERTEXELEMENT9 { + Stream: WORD, + Offset: WORD, + Type: BYTE, + Method: BYTE, + Usage: BYTE, + UsageIndex: BYTE, +}} +pub type LPD3DVERTEXELEMENT9 = *mut D3DVERTEXELEMENT9; +pub const D3DDECL_END: D3DVERTEXELEMENT9 = D3DVERTEXELEMENT9 { + Stream: 0xFF, + Offset: 0, + Type: D3DDECLTYPE_UNUSED as BYTE, + Method: 0, + Usage: 0, + UsageIndex: 0, +}; +pub const D3DDP_MAXTEXCOORD: DWORD = 8; +pub const D3DSTREAMSOURCE_INDEXEDDATA: DWORD = 1 << 30; +pub const D3DSTREAMSOURCE_INSTANCEDATA: DWORD = 2 << 30; +pub const D3DSI_OPCODE_MASK: DWORD = 0x0000FFFF; +pub const D3DSI_INSTLENGTH_MASK: DWORD = 0x0F000000; +pub const D3DSI_INSTLENGTH_SHIFT: DWORD = 24; +ENUM!{enum D3DSHADER_INSTRUCTION_OPCODE_TYPE { + D3DSIO_NOP = 0, + D3DSIO_MOV, + D3DSIO_ADD, + D3DSIO_SUB, + D3DSIO_MAD, + D3DSIO_MUL, + D3DSIO_RCP, + D3DSIO_RSQ, + D3DSIO_DP3, + D3DSIO_DP4, + D3DSIO_MIN, + D3DSIO_MAX, + D3DSIO_SLT, + D3DSIO_SGE, + D3DSIO_EXP, + D3DSIO_LOG, + D3DSIO_LIT, + D3DSIO_DST, + D3DSIO_LRP, + D3DSIO_FRC, + D3DSIO_M4x4, + D3DSIO_M4x3, + D3DSIO_M3x4, + D3DSIO_M3x3, + D3DSIO_M3x2, + D3DSIO_CALL, + D3DSIO_CALLNZ, + D3DSIO_LOOP, + D3DSIO_RET, + D3DSIO_ENDLOOP, + D3DSIO_LABEL, + D3DSIO_DCL, + D3DSIO_POW, + D3DSIO_CRS, + D3DSIO_SGN, + D3DSIO_ABS, + D3DSIO_NRM, + D3DSIO_SINCOS, + D3DSIO_REP, + D3DSIO_ENDREP, + D3DSIO_IF, + D3DSIO_IFC, + D3DSIO_ELSE, + D3DSIO_ENDIF, + D3DSIO_BREAK, + D3DSIO_BREAKC, + D3DSIO_MOVA, + D3DSIO_DEFB, + D3DSIO_DEFI, + D3DSIO_TEXCOORD = 64, + D3DSIO_TEXKILL, + D3DSIO_TEX, + D3DSIO_TEXBEM, + D3DSIO_TEXBEML, + D3DSIO_TEXREG2AR, + D3DSIO_TEXREG2GB, + D3DSIO_TEXM3x2PAD, + D3DSIO_TEXM3x2TEX, + D3DSIO_TEXM3x3PAD, + D3DSIO_TEXM3x3TEX, + D3DSIO_RESERVED0, + D3DSIO_TEXM3x3SPEC, + D3DSIO_TEXM3x3VSPEC, + D3DSIO_EXPP, + D3DSIO_LOGP, + D3DSIO_CND, + D3DSIO_DEF, + D3DSIO_TEXREG2RGB, + D3DSIO_TEXDP3TEX, + D3DSIO_TEXM3x2DEPTH, + D3DSIO_TEXDP3, + D3DSIO_TEXM3x3, + D3DSIO_TEXDEPTH, + D3DSIO_CMP, + D3DSIO_BEM, + D3DSIO_DP2ADD, + D3DSIO_DSX, + D3DSIO_DSY, + D3DSIO_TEXLDD, + D3DSIO_SETP, + D3DSIO_TEXLDL, + D3DSIO_BREAKP, + D3DSIO_PHASE = 0xFFFD, + D3DSIO_COMMENT = 0xFFFE, + D3DSIO_END = 0xFFFF, +}} +pub const D3DSI_COISSUE: DWORD = 0x40000000; +pub const D3DSP_OPCODESPECIFICCONTROL_MASK: DWORD = 0x00ff0000; +pub const D3DSP_OPCODESPECIFICCONTROL_SHIFT: DWORD = 16; +pub const D3DSI_TEXLD_PROJECT: DWORD = 0x01 << D3DSP_OPCODESPECIFICCONTROL_SHIFT; +pub const D3DSI_TEXLD_BIAS: DWORD = 0x02 << D3DSP_OPCODESPECIFICCONTROL_SHIFT; +ENUM!{enum D3DSHADER_COMPARISON { + D3DSPC_RESERVED0 = 0, + D3DSPC_GT = 1, + D3DSPC_EQ = 2, + D3DSPC_GE = 3, + D3DSPC_LT = 4, + D3DSPC_NE = 5, + D3DSPC_LE = 6, + D3DSPC_RESERVED1 = 7, +}} +pub const D3DSHADER_COMPARISON_SHIFT: DWORD = D3DSP_OPCODESPECIFICCONTROL_SHIFT; +pub const D3DSHADER_COMPARISON_MASK: DWORD = 0x7 << D3DSHADER_COMPARISON_SHIFT; +pub const D3DSHADER_INSTRUCTION_PREDICATED: DWORD = 0x1 << 28; +pub const D3DSP_DCL_USAGE_SHIFT: DWORD = 0; +pub const D3DSP_DCL_USAGE_MASK: DWORD = 0x0000000f; +pub const D3DSP_DCL_USAGEINDEX_SHIFT: DWORD = 16; +pub const D3DSP_DCL_USAGEINDEX_MASK: DWORD = 0x000f0000; +pub const D3DSP_TEXTURETYPE_SHIFT: DWORD = 27; +pub const D3DSP_TEXTURETYPE_MASK: DWORD = 0x78000000; +ENUM!{enum D3DSAMPLER_TEXTURE_TYPE { + D3DSTT_UNKNOWN = 0 << D3DSP_TEXTURETYPE_SHIFT, + D3DSTT_2D = 2 << D3DSP_TEXTURETYPE_SHIFT, + D3DSTT_CUBE = 3 << D3DSP_TEXTURETYPE_SHIFT, + D3DSTT_VOLUME = 4 << D3DSP_TEXTURETYPE_SHIFT, +}} +pub const D3DSP_REGNUM_MASK: DWORD = 0x000007FF; +pub const D3DSP_WRITEMASK_0: DWORD = 0x00010000; +pub const D3DSP_WRITEMASK_1: DWORD = 0x00020000; +pub const D3DSP_WRITEMASK_2: DWORD = 0x00040000; +pub const D3DSP_WRITEMASK_3: DWORD = 0x00080000; +pub const D3DSP_WRITEMASK_ALL: DWORD = 0x000F0000; +pub const D3DSP_DSTMOD_SHIFT: DWORD = 20; +pub const D3DSP_DSTMOD_MASK: DWORD = 0x00F00000; +pub const D3DSPDM_NONE: DWORD = 0 << D3DSP_DSTMOD_SHIFT; +pub const D3DSPDM_SATURATE: DWORD = 1 << D3DSP_DSTMOD_SHIFT; +pub const D3DSPDM_PARTIALPRECISION: DWORD = 2 << D3DSP_DSTMOD_SHIFT; +pub const D3DSPDM_MSAMPCENTROID: DWORD = 4 << D3DSP_DSTMOD_SHIFT; +pub const D3DSP_DSTSHIFT_SHIFT: DWORD = 24; +pub const D3DSP_DSTSHIFT_MASK: DWORD = 0x0F000000; +pub const D3DSP_REGTYPE_SHIFT: DWORD = 28; +pub const D3DSP_REGTYPE_SHIFT2: DWORD = 8; +pub const D3DSP_REGTYPE_MASK: DWORD = 0x70000000; +pub const D3DSP_REGTYPE_MASK2: DWORD = 0x00001800; +ENUM!{enum D3DSHADER_PARAM_REGISTER_TYPE { + D3DSPR_TEMP = 0, + D3DSPR_INPUT = 1, + D3DSPR_CONST = 2, + D3DSPR_ADDR = 3, + D3DSPR_TEXTURE = 3, + D3DSPR_RASTOUT = 4, + D3DSPR_ATTROUT = 5, + D3DSPR_TEXCRDOUT = 6, + D3DSPR_OUTPUT = 6, + D3DSPR_CONSTINT = 7, + D3DSPR_COLOROUT = 8, + D3DSPR_DEPTHOUT = 9, + D3DSPR_SAMPLER = 10, + D3DSPR_CONST2 = 11, + D3DSPR_CONST3 = 12, + D3DSPR_CONST4 = 13, + D3DSPR_CONSTBOOL = 14, + D3DSPR_LOOP = 15, + D3DSPR_TEMPFLOAT16 = 16, + D3DSPR_MISCTYPE = 17, + D3DSPR_LABEL = 18, + D3DSPR_PREDICATE = 19, +}} +ENUM!{enum D3DSHADER_MISCTYPE_OFFSETS { + D3DSMO_POSITION = 0, + D3DSMO_FACE = 1, +}} +ENUM!{enum D3DVS_RASTOUT_OFFSETS { + D3DSRO_POSITION = 0, + D3DSRO_FOG, + D3DSRO_POINT_SIZE, +}} +pub const D3DVS_ADDRESSMODE_SHIFT: DWORD = 13; +pub const D3DVS_ADDRESSMODE_MASK: DWORD = 1 << D3DVS_ADDRESSMODE_SHIFT; +ENUM!{enum D3DVS_ADDRESSMODE_TYPE { + D3DVS_ADDRMODE_ABSOLUTE = 0 << D3DVS_ADDRESSMODE_SHIFT, + D3DVS_ADDRMODE_RELATIVE = 1 << D3DVS_ADDRESSMODE_SHIFT, +}} +pub const D3DSHADER_ADDRESSMODE_SHIFT: DWORD = 13; +pub const D3DSHADER_ADDRESSMODE_MASK: DWORD = 1 << D3DSHADER_ADDRESSMODE_SHIFT; +ENUM!{enum D3DSHADER_ADDRESSMODE_TYPE { + D3DSHADER_ADDRMODE_ABSOLUTE = 0 << D3DSHADER_ADDRESSMODE_SHIFT, + D3DSHADER_ADDRMODE_RELATIVE = 1 << D3DSHADER_ADDRESSMODE_SHIFT, +}} +pub const D3DVS_SWIZZLE_SHIFT: DWORD = 16; +pub const D3DVS_SWIZZLE_MASK: DWORD = 0x00FF0000; +pub const D3DVS_X_X: DWORD = 0 << D3DVS_SWIZZLE_SHIFT; +pub const D3DVS_X_Y: DWORD = 1 << D3DVS_SWIZZLE_SHIFT; +pub const D3DVS_X_Z: DWORD = 2 << D3DVS_SWIZZLE_SHIFT; +pub const D3DVS_X_W: DWORD = 3 << D3DVS_SWIZZLE_SHIFT; +pub const D3DVS_Y_X: DWORD = 0 << (D3DVS_SWIZZLE_SHIFT + 2); +pub const D3DVS_Y_Y: DWORD = 1 << (D3DVS_SWIZZLE_SHIFT + 2); +pub const D3DVS_Y_Z: DWORD = 2 << (D3DVS_SWIZZLE_SHIFT + 2); +pub const D3DVS_Y_W: DWORD = 3 << (D3DVS_SWIZZLE_SHIFT + 2); +pub const D3DVS_Z_X: DWORD = 0 << (D3DVS_SWIZZLE_SHIFT + 4); +pub const D3DVS_Z_Y: DWORD = 1 << (D3DVS_SWIZZLE_SHIFT + 4); +pub const D3DVS_Z_Z: DWORD = 2 << (D3DVS_SWIZZLE_SHIFT + 4); +pub const D3DVS_Z_W: DWORD = 3 << (D3DVS_SWIZZLE_SHIFT + 4); +pub const D3DVS_W_X: DWORD = 0 << (D3DVS_SWIZZLE_SHIFT + 6); +pub const D3DVS_W_Y: DWORD = 1 << (D3DVS_SWIZZLE_SHIFT + 6); +pub const D3DVS_W_Z: DWORD = 2 << (D3DVS_SWIZZLE_SHIFT + 6); +pub const D3DVS_W_W: DWORD = 3 << (D3DVS_SWIZZLE_SHIFT + 6); +pub const D3DVS_NOSWIZZLE: DWORD = D3DVS_X_X | D3DVS_Y_Y | D3DVS_Z_Z | D3DVS_W_W; +pub const D3DSP_SWIZZLE_SHIFT: DWORD = 16; +pub const D3DSP_SWIZZLE_MASK: DWORD = 0x00FF0000; +pub const D3DSP_NOSWIZZLE: DWORD = (0 << (D3DSP_SWIZZLE_SHIFT + 0)) + | (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | (2 << (D3DSP_SWIZZLE_SHIFT + 4)) + | (3 << (D3DSP_SWIZZLE_SHIFT + 6)); +pub const D3DSP_REPLICATERED: DWORD = (0 << (D3DSP_SWIZZLE_SHIFT + 0)) + | (0 << (D3DSP_SWIZZLE_SHIFT + 2)) | (0 << (D3DSP_SWIZZLE_SHIFT + 4)) + | (0 << (D3DSP_SWIZZLE_SHIFT + 6)); +pub const D3DSP_REPLICATEGREEN: DWORD = (1 << (D3DSP_SWIZZLE_SHIFT + 0)) + | (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | (1 << (D3DSP_SWIZZLE_SHIFT + 4)) + | (1 << (D3DSP_SWIZZLE_SHIFT + 6)); +pub const D3DSP_REPLICATEBLUE: DWORD = (2 << (D3DSP_SWIZZLE_SHIFT + 0)) + | (2 << (D3DSP_SWIZZLE_SHIFT + 2)) | (2 << (D3DSP_SWIZZLE_SHIFT + 4)) + | (2 << (D3DSP_SWIZZLE_SHIFT + 6)); +pub const D3DSP_REPLICATEALPHA: DWORD = (3 << (D3DSP_SWIZZLE_SHIFT + 0)) + | (3 << (D3DSP_SWIZZLE_SHIFT + 2)) | (3 << (D3DSP_SWIZZLE_SHIFT + 4)) + | (3 << (D3DSP_SWIZZLE_SHIFT + 6)); +pub const D3DSP_SRCMOD_SHIFT: DWORD = 24; +pub const D3DSP_SRCMOD_MASK: DWORD = 0x0F000000; +ENUM!{enum D3DSHADER_PARAM_SRCMOD_TYPE { + D3DSPSM_NONE = 0 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_NEG = 1 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_BIAS = 2 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_BIASNEG = 3 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_SIGN = 4 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_SIGNNEG = 5 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_COMP = 6 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_X2 = 7 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_X2NEG = 8 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_DZ = 9 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_DW = 10 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_ABS = 11 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_ABSNEG = 12 << D3DSP_SRCMOD_SHIFT, + D3DSPSM_NOT = 13 << D3DSP_SRCMOD_SHIFT, +}} +pub const D3DSP_MIN_PRECISION_SHIFT: DWORD = 14; +pub const D3DSP_MIN_PRECISION_MASK: DWORD = 0x0000C000; +ENUM!{enum D3DSHADER_MIN_PRECISION { + D3DMP_DEFAULT = 0, + D3DMP_16 = 1, + D3DMP_2_8 = 2, +}} +pub const D3DSI_COMMENTSIZE_SHIFT: DWORD = 16; +pub const D3DSI_COMMENTSIZE_MASK: DWORD = 0x7FFF0000; +pub const D3DPS_END: DWORD = 0x0000FFFF; +pub const D3DVS_END: DWORD = 0x0000FFFF; +ENUM!{enum D3DBASISTYPE { + D3DBASIS_BEZIER = 0, + D3DBASIS_BSPLINE = 1, + D3DBASIS_CATMULL_ROM = 2, +}} +ENUM!{enum D3DDEGREETYPE { + D3DDEGREE_LINEAR = 1, + D3DDEGREE_QUADRATIC = 2, + D3DDEGREE_CUBIC = 3, + D3DDEGREE_QUINTIC = 5, +}} +ENUM!{enum D3DPATCHEDGESTYLE { + D3DPATCHEDGE_DISCRETE = 0, + D3DPATCHEDGE_CONTINUOUS = 1, +}} +ENUM!{enum D3DSTATEBLOCKTYPE { + D3DSBT_ALL = 1, + D3DSBT_PIXELSTATE = 2, + D3DSBT_VERTEXSTATE = 3, +}} +ENUM!{enum D3DVERTEXBLENDFLAGS { + D3DVBF_DISABLE = 0, + D3DVBF_1WEIGHTS = 1, + D3DVBF_2WEIGHTS = 2, + D3DVBF_3WEIGHTS = 3, + D3DVBF_TWEENING = 255, + D3DVBF_0WEIGHTS = 256, +}} +ENUM!{enum D3DTEXTURETRANSFORMFLAGS { + D3DTTFF_DISABLE = 0, + D3DTTFF_COUNT1 = 1, + D3DTTFF_COUNT2 = 2, + D3DTTFF_COUNT3 = 3, + D3DTTFF_COUNT4 = 4, + D3DTTFF_PROJECTED = 256, +}} +pub const D3DFVF_TEXTUREFORMAT2: DWORD = 0; +pub const D3DFVF_TEXTUREFORMAT1: DWORD = 3; +pub const D3DFVF_TEXTUREFORMAT3: DWORD = 1; +pub const D3DFVF_TEXTUREFORMAT4: DWORD = 2; +ENUM!{enum D3DDEVTYPE { + D3DDEVTYPE_HAL = 1, + D3DDEVTYPE_REF = 2, + D3DDEVTYPE_SW = 3, + D3DDEVTYPE_NULLREF = 4, +}} +ENUM!{enum D3DMULTISAMPLE_TYPE { + D3DMULTISAMPLE_NONE = 0, + D3DMULTISAMPLE_NONMASKABLE = 1, + D3DMULTISAMPLE_2_SAMPLES = 2, + D3DMULTISAMPLE_3_SAMPLES = 3, + D3DMULTISAMPLE_4_SAMPLES = 4, + D3DMULTISAMPLE_5_SAMPLES = 5, + D3DMULTISAMPLE_6_SAMPLES = 6, + D3DMULTISAMPLE_7_SAMPLES = 7, + D3DMULTISAMPLE_8_SAMPLES = 8, + D3DMULTISAMPLE_9_SAMPLES = 9, + D3DMULTISAMPLE_10_SAMPLES = 10, + D3DMULTISAMPLE_11_SAMPLES = 11, + D3DMULTISAMPLE_12_SAMPLES = 12, + D3DMULTISAMPLE_13_SAMPLES = 13, + D3DMULTISAMPLE_14_SAMPLES = 14, + D3DMULTISAMPLE_15_SAMPLES = 15, + D3DMULTISAMPLE_16_SAMPLES = 16, +}} +ENUM!{enum D3DFORMAT { + D3DFMT_UNKNOWN = 0, + D3DFMT_R8G8B8 = 20, + D3DFMT_A8R8G8B8 = 21, + D3DFMT_X8R8G8B8 = 22, + D3DFMT_R5G6B5 = 23, + D3DFMT_X1R5G5B5 = 24, + D3DFMT_A1R5G5B5 = 25, + D3DFMT_A4R4G4B4 = 26, + D3DFMT_R3G3B2 = 27, + D3DFMT_A8 = 28, + D3DFMT_A8R3G3B2 = 29, + D3DFMT_X4R4G4B4 = 30, + D3DFMT_A2B10G10R10 = 31, + D3DFMT_A8B8G8R8 = 32, + D3DFMT_X8B8G8R8 = 33, + D3DFMT_G16R16 = 34, + D3DFMT_A2R10G10B10 = 35, + D3DFMT_A16B16G16R16 = 36, + D3DFMT_A8P8 = 40, + D3DFMT_P8 = 41, + D3DFMT_L8 = 50, + D3DFMT_A8L8 = 51, + D3DFMT_A4L4 = 52, + D3DFMT_V8U8 = 60, + D3DFMT_L6V5U5 = 61, + D3DFMT_X8L8V8U8 = 62, + D3DFMT_Q8W8V8U8 = 63, + D3DFMT_V16U16 = 64, + D3DFMT_A2W10V10U10 = 67, + D3DFMT_UYVY = MAKEFOURCC!(b'U', b'Y', b'V', b'Y'), + D3DFMT_R8G8_B8G8 = MAKEFOURCC!(b'R', b'G', b'B', b'G'), + D3DFMT_YUY2 = MAKEFOURCC!(b'Y', b'U', b'Y', b'2'), + D3DFMT_G8R8_G8B8 = MAKEFOURCC!(b'G', b'R', b'G', b'B'), + D3DFMT_DXT1 = MAKEFOURCC!(b'D', b'X', b'T', b'1'), + D3DFMT_DXT2 = MAKEFOURCC!(b'D', b'X', b'T', b'2'), + D3DFMT_DXT3 = MAKEFOURCC!(b'D', b'X', b'T', b'3'), + D3DFMT_DXT4 = MAKEFOURCC!(b'D', b'X', b'T', b'4'), + D3DFMT_DXT5 = MAKEFOURCC!(b'D', b'X', b'T', b'5'), + D3DFMT_D16_LOCKABLE = 70, + D3DFMT_D32 = 71, + D3DFMT_D15S1 = 73, + D3DFMT_D24S8 = 75, + D3DFMT_D24X8 = 77, + D3DFMT_D24X4S4 = 79, + D3DFMT_D16 = 80, + D3DFMT_D32F_LOCKABLE = 82, + D3DFMT_D24FS8 = 83, + D3DFMT_D32_LOCKABLE = 84, + D3DFMT_S8_LOCKABLE = 85, + D3DFMT_L16 = 81, + D3DFMT_VERTEXDATA = 100, + D3DFMT_INDEX16 = 101, + D3DFMT_INDEX32 = 102, + D3DFMT_Q16W16V16U16 = 110, + D3DFMT_MULTI2_ARGB8 = MAKEFOURCC!(b'M', b'E', b'T', b'1'), + D3DFMT_R16F = 111, + D3DFMT_G16R16F = 112, + D3DFMT_A16B16G16R16F = 113, + D3DFMT_R32F = 114, + D3DFMT_G32R32F = 115, + D3DFMT_A32B32G32R32F = 116, + D3DFMT_CxV8U8 = 117, + D3DFMT_A1 = 118, + D3DFMT_A2B10G10R10_XR_BIAS = 119, + D3DFMT_BINARYBUFFER = 199, +}} +STRUCT!{struct D3DDISPLAYMODE { + Width: UINT, + Height: UINT, + RefreshRate: UINT, + Format: D3DFORMAT, +}} +STRUCT!{struct D3DDEVICE_CREATION_PARAMETERS { + AdapterOrdinal: UINT, + DeviceType: D3DDEVTYPE, + hFocusWindow: HWND, + BehaviorFlags: DWORD, +}} +ENUM!{enum D3DSWAPEFFECT { + D3DSWAPEFFECT_DISCARD = 1, + D3DSWAPEFFECT_FLIP = 2, + D3DSWAPEFFECT_COPY = 3, + D3DSWAPEFFECT_OVERLAY = 4, + D3DSWAPEFFECT_FLIPEX = 5, +}} +ENUM!{enum D3DPOOL { + D3DPOOL_DEFAULT = 0, + D3DPOOL_MANAGED = 1, + D3DPOOL_SYSTEMMEM = 2, + D3DPOOL_SCRATCH = 3, +}} +pub const D3DPRESENT_RATE_DEFAULT: DWORD = 0x00000000; +STRUCT!{struct D3DPRESENT_PARAMETERS { + BackBufferWidth: UINT, + BackBufferHeight: UINT, + BackBufferFormat: D3DFORMAT, + BackBufferCount: UINT, + MultiSampleType: D3DMULTISAMPLE_TYPE, + MultiSampleQuality: DWORD, + SwapEffect: D3DSWAPEFFECT, + hDeviceWindow: HWND, + Windowed: BOOL, + EnableAutoDepthStencil: BOOL, + AutoDepthStencilFormat: D3DFORMAT, + Flags: DWORD, + FullScreen_RefreshRateInHz: UINT, + PresentationInterval: UINT, +}} +pub const D3DPRESENTFLAG_LOCKABLE_BACKBUFFER: DWORD = 0x00000001; +pub const D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL: DWORD = 0x00000002; +pub const D3DPRESENTFLAG_DEVICECLIP: DWORD = 0x00000004; +pub const D3DPRESENTFLAG_VIDEO: DWORD = 0x00000010; +pub const D3DPRESENTFLAG_NOAUTOROTATE: DWORD = 0x00000020; +pub const D3DPRESENTFLAG_UNPRUNEDMODE: DWORD = 0x00000040; +pub const D3DPRESENTFLAG_OVERLAY_LIMITEDRGB: DWORD = 0x00000080; +pub const D3DPRESENTFLAG_OVERLAY_YCbCr_BT709: DWORD = 0x00000100; +pub const D3DPRESENTFLAG_OVERLAY_YCbCr_xvYCC: DWORD = 0x00000200; +pub const D3DPRESENTFLAG_RESTRICTED_CONTENT: DWORD = 0x00000400; +pub const D3DPRESENTFLAG_RESTRICT_SHARED_RESOURCE_DRIVER: DWORD = 0x00000800; +STRUCT!{struct D3DGAMMARAMP { + red: [WORD; 256], + green: [WORD; 256], + blue: [WORD; 256], +}} +ENUM!{enum D3DBACKBUFFER_TYPE { + D3DBACKBUFFER_TYPE_MONO = 0, + D3DBACKBUFFER_TYPE_LEFT = 1, + D3DBACKBUFFER_TYPE_RIGHT = 2, +}} +ENUM!{enum D3DRESOURCETYPE { + D3DRTYPE_SURFACE = 1, + D3DRTYPE_VOLUME = 2, + D3DRTYPE_TEXTURE = 3, + D3DRTYPE_VOLUMETEXTURE = 4, + D3DRTYPE_CUBETEXTURE = 5, + D3DRTYPE_VERTEXBUFFER = 6, + D3DRTYPE_INDEXBUFFER = 7, +}} +pub const D3DUSAGE_RENDERTARGET: DWORD = 0x00000001; +pub const D3DUSAGE_DEPTHSTENCIL: DWORD = 0x00000002; +pub const D3DUSAGE_DYNAMIC: DWORD = 0x00000200; +pub const D3DUSAGE_NONSECURE: DWORD = 0x00800000; +pub const D3DUSAGE_AUTOGENMIPMAP: DWORD = 0x00000400; +pub const D3DUSAGE_DMAP: DWORD = 0x00004000; +pub const D3DUSAGE_QUERY_LEGACYBUMPMAP: DWORD = 0x00008000; +pub const D3DUSAGE_QUERY_SRGBREAD: DWORD = 0x00010000; +pub const D3DUSAGE_QUERY_FILTER: DWORD = 0x00020000; +pub const D3DUSAGE_QUERY_SRGBWRITE: DWORD = 0x00040000; +pub const D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING: DWORD = 0x00080000; +pub const D3DUSAGE_QUERY_VERTEXTEXTURE: DWORD = 0x00100000; +pub const D3DUSAGE_QUERY_WRAPANDMIP: DWORD = 0x00200000; +pub const D3DUSAGE_WRITEONLY: DWORD = 0x00000008; +pub const D3DUSAGE_SOFTWAREPROCESSING: DWORD = 0x00000010; +pub const D3DUSAGE_DONOTCLIP: DWORD = 0x00000020; +pub const D3DUSAGE_POINTS: DWORD = 0x00000040; +pub const D3DUSAGE_RTPATCHES: DWORD = 0x00000080; +pub const D3DUSAGE_NPATCHES: DWORD = 0x00000100; +pub const D3DUSAGE_TEXTAPI: DWORD = 0x10000000; +pub const D3DUSAGE_RESTRICTED_CONTENT: DWORD = 0x00000800; +pub const D3DUSAGE_RESTRICT_SHARED_RESOURCE: DWORD = 0x00002000; +pub const D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER: DWORD = 0x00001000; +ENUM!{enum D3DCUBEMAP_FACES { + D3DCUBEMAP_FACE_POSITIVE_X = 0, + D3DCUBEMAP_FACE_NEGATIVE_X = 1, + D3DCUBEMAP_FACE_POSITIVE_Y = 2, + D3DCUBEMAP_FACE_NEGATIVE_Y = 3, + D3DCUBEMAP_FACE_POSITIVE_Z = 4, + D3DCUBEMAP_FACE_NEGATIVE_Z = 5, +}} +pub const D3DLOCK_READONLY: DWORD = 0x00000010; +pub const D3DLOCK_DISCARD: DWORD = 0x00002000; +pub const D3DLOCK_NOOVERWRITE: DWORD = 0x00001000; +pub const D3DLOCK_NOSYSLOCK: DWORD = 0x00000800; +pub const D3DLOCK_DONOTWAIT: DWORD = 0x00004000; +pub const D3DLOCK_NO_DIRTY_UPDATE: DWORD = 0x00008000; +STRUCT!{struct D3DVERTEXBUFFER_DESC { + Format: D3DFORMAT, + Type: D3DRESOURCETYPE, + Usage: DWORD, + Pool: D3DPOOL, + Size: UINT, + FVF: DWORD, +}} +STRUCT!{struct D3DINDEXBUFFER_DESC { + Format: D3DFORMAT, + Type: D3DRESOURCETYPE, + Usage: DWORD, + Pool: D3DPOOL, + Size: UINT, +}} +STRUCT!{struct D3DSURFACE_DESC { + Format: D3DFORMAT, + Type: D3DRESOURCETYPE, + Usage: DWORD, + Pool: D3DPOOL, + MultiSampleType: D3DMULTISAMPLE_TYPE, + MultiSampleQuality: DWORD, + Width: UINT, + Height: UINT, +}} +STRUCT!{struct D3DVOLUME_DESC { + Format: D3DFORMAT, + Type: D3DRESOURCETYPE, + Usage: DWORD, + Pool: D3DPOOL, + Width: UINT, + Height: UINT, + Depth: UINT, +}} +STRUCT!{struct D3DLOCKED_RECT { + Pitch: INT, + pBits: *mut c_void, +}} +STRUCT!{struct D3DBOX { + Left: UINT, + Top: UINT, + Right: UINT, + Bottom: UINT, + Front: UINT, + Back: UINT, +}} +STRUCT!{struct D3DLOCKED_BOX { + RowPitch: INT, + SlicePitch: INT, + pBits: *mut c_void, +}} +STRUCT!{struct D3DRANGE { + Offset: UINT, + Size: UINT, +}} +STRUCT!{struct D3DRECTPATCH_INFO { + StartVertexOffsetWidth: UINT, + StartVertexOffsetHeight: UINT, + Width: UINT, + Height: UINT, + Stride: UINT, + Basis: D3DBASISTYPE, + Degree: D3DDEGREETYPE, +}} +STRUCT!{struct D3DTRIPATCH_INFO { + StartVertexOffset: UINT, + NumVertices: UINT, + Basis: D3DBASISTYPE, + Degree: D3DDEGREETYPE, +}} +pub const MAX_DEVICE_IDENTIFIER_STRING: usize = 512; +// FIXME packed(4) +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct D3DADAPTER_IDENTIFIER9 { + Driver: [c_char; MAX_DEVICE_IDENTIFIER_STRING], + Description: [c_char; MAX_DEVICE_IDENTIFIER_STRING], + DeviceName: [c_char; 32], + DriverVersion: LARGE_INTEGER, + VendorId: DWORD, + DeviceId: DWORD, + SubSysId: DWORD, + Revision: DWORD, + DeviceIdentifier: GUID, + WHQLLevel: DWORD, +}} +STRUCT!{struct D3DRASTER_STATUS { + InVBlank: BOOL, + ScanLine: UINT, +}} +ENUM!{enum D3DDEBUGMONITORTOKENS { + D3DDMT_ENABLE = 0, + D3DDMT_DISABLE = 1, +}} +ENUM!{enum D3DQUERYTYPE { + D3DQUERYTYPE_VCACHE = 4, + D3DQUERYTYPE_RESOURCEMANAGER = 5, + D3DQUERYTYPE_VERTEXSTATS = 6, + D3DQUERYTYPE_EVENT = 8, + D3DQUERYTYPE_OCCLUSION = 9, + D3DQUERYTYPE_TIMESTAMP = 10, + D3DQUERYTYPE_TIMESTAMPDISJOINT = 11, + D3DQUERYTYPE_TIMESTAMPFREQ = 12, + D3DQUERYTYPE_PIPELINETIMINGS = 13, + D3DQUERYTYPE_INTERFACETIMINGS = 14, + D3DQUERYTYPE_VERTEXTIMINGS = 15, + D3DQUERYTYPE_PIXELTIMINGS = 16, + D3DQUERYTYPE_BANDWIDTHTIMINGS = 17, + D3DQUERYTYPE_CACHEUTILIZATION = 18, + D3DQUERYTYPE_MEMORYPRESSURE = 19, +}} +pub const D3DISSUE_END: DWORD = 1 << 0; +pub const D3DISSUE_BEGIN: DWORD = 1 << 1; +pub const D3DGETDATA_FLUSH: DWORD = 1 << 0; +STRUCT!{struct D3DRESOURCESTATS { + bThrashing: BOOL, + ApproxBytesDownloaded: DWORD, + NumEvicts: DWORD, + NumVidCreates: DWORD, + LastPri: DWORD, + NumUsed: DWORD, + NumUsedInVidMem: DWORD, + WorkingSet: DWORD, + WorkingSetBytes: DWORD, + TotalManaged: DWORD, + TotalBytes: DWORD, +}} +pub const D3DRTYPECOUNT: usize = D3DRTYPE_INDEXBUFFER as usize + 1; +STRUCT!{struct D3DDEVINFO_RESOURCEMANAGER { + stats: [D3DRESOURCESTATS; D3DRTYPECOUNT], +}} +pub type LPD3DDEVINFO_RESOURCEMANAGER = *mut D3DDEVINFO_RESOURCEMANAGER; +STRUCT!{struct D3DDEVINFO_D3DVERTEXSTATS { + NumRenderedTriangles: DWORD, + NumExtraClippingTriangles: DWORD, +}} +pub type LPD3DDEVINFO_D3DVERTEXSTATS = *mut D3DDEVINFO_D3DVERTEXSTATS; +STRUCT!{struct D3DDEVINFO_VCACHE { + Pattern: DWORD, + OptMethod: DWORD, + CacheSize: DWORD, + MagicNumber: DWORD, +}} +pub type LPD3DDEVINFO_VCACHE = *mut D3DDEVINFO_VCACHE; +STRUCT!{struct D3DDEVINFO_D3D9PIPELINETIMINGS { + VertexProcessingTimePercent: FLOAT, + PixelProcessingTimePercent: FLOAT, + OtherGPUProcessingTimePercent: FLOAT, + GPUIdleTimePercent: FLOAT, +}} +STRUCT!{struct D3DDEVINFO_D3D9INTERFACETIMINGS { + WaitingForGPUToUseApplicationResourceTimePercent: FLOAT, + WaitingForGPUToAcceptMoreCommandsTimePercent: FLOAT, + WaitingForGPUToStayWithinLatencyTimePercent: FLOAT, + WaitingForGPUExclusiveResourceTimePercent: FLOAT, + WaitingForGPUOtherTimePercent: FLOAT, +}} +STRUCT!{struct D3DDEVINFO_D3D9STAGETIMINGS { + MemoryProcessingPercent: FLOAT, + ComputationProcessingPercent: FLOAT, +}} +STRUCT!{struct D3DDEVINFO_D3D9BANDWIDTHTIMINGS { + MaxBandwidthUtilized: FLOAT, + FrontEndUploadMemoryUtilizedPercent: FLOAT, + VertexRateUtilizedPercent: FLOAT, + TriangleSetupRateUtilizedPercent: FLOAT, + FillRateUtilizedPercent: FLOAT, +}} +STRUCT!{struct D3DDEVINFO_D3D9CACHEUTILIZATION { + TextureCacheHitRate: FLOAT, + PostTransformVertexCacheHitRate: FLOAT, +}} +// FIXME packed(4) +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct D3DMEMORYPRESSURE { + BytesEvictedFromProcess: UINT64, + SizeOfInefficientAllocation: UINT64, + LevelOfEfficiency: DWORD, +}} +ENUM!{enum D3DCOMPOSERECTSOP { + D3DCOMPOSERECTS_COPY = 1, + D3DCOMPOSERECTS_OR = 2, + D3DCOMPOSERECTS_AND = 3, + D3DCOMPOSERECTS_NEG = 4, +}} +STRUCT!{struct D3DCOMPOSERECTDESC { + X: USHORT, + Y: USHORT, + Width: USHORT, + Height: USHORT, +}} +STRUCT!{struct D3DCOMPOSERECTDESTINATION { + SrcRectIndex: USHORT, + Reserved: USHORT, + X: SHORT, + Y: SHORT, +}} +pub const D3DCOMPOSERECTS_MAXNUMRECTS: DWORD = 0xFFFF; +pub const D3DCONVOLUTIONMONO_MAXWIDTH: DWORD = 7; +pub const D3DCONVOLUTIONMONO_MAXHEIGHT: DWORD = D3DCONVOLUTIONMONO_MAXWIDTH; +pub const D3DFMT_A1_SURFACE_MAXWIDTH: DWORD = 8192; +pub const D3DFMT_A1_SURFACE_MAXHEIGHT: DWORD = 2048; +// FIXME packed(4) +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct D3DPRESENTSTATS { + PresentCount: UINT, + PresentRefreshCount: UINT, + SyncRefreshCount: UINT, + SyncQPCTime: LARGE_INTEGER, + SyncGPUTime: LARGE_INTEGER, +}} +ENUM!{enum D3DSCANLINEORDERING { + D3DSCANLINEORDERING_UNKNOWN = 0, + D3DSCANLINEORDERING_PROGRESSIVE = 1, + D3DSCANLINEORDERING_INTERLACED = 2, +}} +STRUCT!{struct D3DDISPLAYMODEEX { + Size: UINT, + Width: UINT, + Height: UINT, + RefreshRate: UINT, + Format: D3DFORMAT, + ScanLineOrdering: D3DSCANLINEORDERING, +}} +STRUCT!{struct D3DDISPLAYMODEFILTER { + Size: UINT, + Format: D3DFORMAT, + ScanLineOrdering: D3DSCANLINEORDERING, +}} +ENUM!{enum D3DDISPLAYROTATION { + D3DDISPLAYROTATION_IDENTITY = 1, + D3DDISPLAYROTATION_90 = 2, + D3DDISPLAYROTATION_180 = 3, + D3DDISPLAYROTATION_270 = 4, +}} +pub const D3D9_RESOURCE_PRIORITY_MINIMUM: DWORD = 0x28000000; +pub const D3D9_RESOURCE_PRIORITY_LOW: DWORD = 0x50000000; +pub const D3D9_RESOURCE_PRIORITY_NORMAL: DWORD = 0x78000000; +pub const D3D9_RESOURCE_PRIORITY_HIGH: DWORD = 0xa0000000; +pub const D3D9_RESOURCE_PRIORITY_MAXIMUM: DWORD = 0xc8000000; +pub const D3D_OMAC_SIZE: usize = 16; +STRUCT!{struct D3D_OMAC { + Omac: [BYTE; D3D_OMAC_SIZE], +}} +ENUM!{enum D3DAUTHENTICATEDCHANNELTYPE { + D3DAUTHENTICATEDCHANNEL_D3D9 = 1, + D3DAUTHENTICATEDCHANNEL_DRIVER_SOFTWARE = 2, + D3DAUTHENTICATEDCHANNEL_DRIVER_HARDWARE = 3, +}} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERY_INPUT { + QueryType: GUID, + hChannel: HANDLE, + SequenceNumber: UINT, +}} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT { + omac: D3D_OMAC, + QueryType: GUID, + hChannel: HANDLE, + SequenceNumber: UINT, + ReturnCode: HRESULT, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_PROTECTION, + 0xa84eb584, 0xc495, 0x48aa, 0xb9, 0x4d, 0x8b, 0xd2, 0xd6, 0xfb, 0xce, 0x5} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS { + Value: UINT, +}} +BITFIELD!{D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS Value: UINT [ + ProtectionEnabled set_ProtectionEnabled[0..1], + OverlayOrFullscreenRequired set_OverlayOrFullscreenRequired[1..2], +]} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + ProtectionFlags: D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_CHANNELTYPE, + 0xbc1b18a5, 0xb1fb, 0x42ab, 0xbd, 0x94, 0xb5, 0x82, 0x8b, 0x4b, 0xf7, 0xbe} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + ChannelType: D3DAUTHENTICATEDCHANNELTYPE, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_DEVICEHANDLE, + 0xec1c539d, 0x8cff, 0x4e2a, 0xbc, 0xc4, 0xf5, 0x69, 0x2f, 0x99, 0xf4, 0x80} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + DeviceHandle: HANDLE, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_CRYPTOSESSION, + 0x2634499e, 0xd018, 0x4d74, 0xac, 0x17, 0x7f, 0x72, 0x40, 0x59, 0x52, 0x8d} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT { + Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, + DXVA2DecodeHandle: HANDLE, +}} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + DXVA2DecodeHandle: HANDLE, + CryptoSessionHandle: HANDLE, + DeviceHandle: HANDLE, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESSCOUNT, + 0xdb207b3, 0x9450, 0x46a6, 0x82, 0xde, 0x1b, 0x96, 0xd4, 0x4f, 0x9c, 0xf2} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + NumRestrictedSharedResourceProcesses: UINT, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESS, + 0x649bbadb, 0xf0f4, 0x4639, 0xa1, 0x5b, 0x24, 0x39, 0x3f, 0xc3, 0xab, 0xac} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT { + Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, + ProcessIndex: UINT, +}} +ENUM!{enum D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE { + PROCESSIDTYPE_UNKNOWN = 0, + PROCESSIDTYPE_DWM = 1, + PROCESSIDTYPE_HANDLE = 2, +}} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + ProcessIndex: UINT, + ProcessIdentifer: D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE, + ProcessHandle: HANDLE, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_UNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT, + 0x12f0bd6, 0xe662, 0x4474, 0xbe, 0xfd, 0xaa, 0x53, 0xe5, 0x14, 0x3c, 0x6d} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + NumUnrestrictedProtectedSharedResources: UINT, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_OUTPUTIDCOUNT, + 0x2c042b5e, 0x8c07, 0x46d5, 0xaa, 0xbe, 0x8f, 0x75, 0xcb, 0xad, 0x4c, 0x31} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT { + Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, + DeviceHandle: HANDLE, + CryptoSessionHandle: HANDLE, +}} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + DeviceHandle: HANDLE, + CryptoSessionHandle: HANDLE, + NumOutputIDs: UINT, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_OUTPUTID, + 0x839ddca3, 0x9b4e, 0x41e4, 0xb0, 0x53, 0x89, 0x2b, 0xd2, 0xa1, 0x1e, 0xe7} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT { + Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, + DeviceHandle: HANDLE, + CryptoSessionHandle: HANDLE, + OutputIDIndex: UINT, +}} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + DeviceHandle: HANDLE, + CryptoSessionHandle: HANDLE, + OutputIDIndex: UINT, + OutputID: UINT64, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_ACCESSIBILITYATTRIBUTES, + 0x6214d9d2, 0x432c, 0x4abb, 0x9f, 0xce, 0x21, 0x6e, 0xea, 0x26, 0x9e, 0x3b} +ENUM!{enum D3DBUSTYPE { + D3DBUSTYPE_OTHER = 0x00000000, + D3DBUSTYPE_PCI = 0x00000001, + D3DBUSTYPE_PCIX = 0x00000002, + D3DBUSTYPE_PCIEXPRESS = 0x00000003, + D3DBUSTYPE_AGP = 0x00000004, + D3DBUSIMPL_MODIFIER_INSIDE_OF_CHIPSET = 0x00010000, + MD3DBUSIMPL_ODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP = 0x00020000, + D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x00030000, + D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR = 0x00040000, + D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x00050000, + D3DBUSIMPL_MODIFIER_NON_STANDARD = 0x80000000, +}} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + BusType: D3DBUSTYPE, + bAccessibleInContiguousBlocks: BOOL, + bAccessibleInNonContiguousBlocks: BOOL, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUIDCOUNT, + 0xb30f7066, 0x203c, 0x4b07, 0x93, 0xfc, 0xce, 0xaa, 0xfd, 0x61, 0x24, 0x1e} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + NumEncryptionGuids: UINT, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUID, + 0xf83a5958, 0xe986, 0x4bda, 0xbe, 0xb0, 0x41, 0x1f, 0x6a, 0x7a, 0x1, 0xb7} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT { + Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, + EncryptionGuidIndex: UINT, +}} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + EncryptionGuidIndex: UINT, + EncryptionGuid: GUID, +}} +DEFINE_GUID!{D3DAUTHENTICATEDQUERY_CURRENTENCRYPTIONWHENACCESSIBLE, + 0xec1791c7, 0xdad3, 0x4f15, 0x9e, 0xc3, 0xfa, 0xa9, 0x3d, 0x60, 0xd4, 0xf0} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT { + Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, + EncryptionGuid: GUID, +}} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT { + omac: D3D_OMAC, + ConfigureType: GUID, + hChannel: HANDLE, + SequenceNumber: UINT, +}} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT { + omac: D3D_OMAC, + ConfigureType: GUID, + hChannel: HANDLE, + SequenceNumber: UINT, + ReturnCode: HRESULT, +}} +DEFINE_GUID!{D3DAUTHENTICATEDCONFIGURE_INITIALIZE, + 0x6114bdb, 0x3523, 0x470a, 0x8d, 0xca, 0xfb, 0xc2, 0x84, 0x51, 0x54, 0xf0} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE { + Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, + StartSequenceQuery: UINT, + StartSequenceConfigure: UINT, +}} +DEFINE_GUID!{D3DAUTHENTICATEDCONFIGURE_PROTECTION, + 0x50455658, 0x3f47, 0x4362, 0xbf, 0x99, 0xbf, 0xdf, 0xcd, 0xe9, 0xed, 0x29} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION { + Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, + Protections: D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS, +}} +DEFINE_GUID!{D3DAUTHENTICATEDCONFIGURE_CRYPTOSESSION, + 0x6346cc54, 0x2cfc, 0x4ad4, 0x82, 0x24, 0xd1, 0x58, 0x37, 0xde, 0x77, 0x0} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION { + Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, + DXVA2DecodeHandle: HANDLE, + CryptoSessionHandle: HANDLE, + DeviceHandle: HANDLE, +}} +DEFINE_GUID!{D3DAUTHENTICATEDCONFIGURE_SHAREDRESOURCE, + 0x772d047, 0x1b40, 0x48e8, 0x9c, 0xa6, 0xb5, 0xf5, 0x10, 0xde, 0x9f, 0x1} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE { + Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, + ProcessIdentiferType: D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE, + ProcessHandle: HANDLE, + AllowAccess: BOOL, +}} +DEFINE_GUID!{D3DAUTHENTICATEDCONFIGURE_ENCRYPTIONWHENACCESSIBLE, + 0x41fff286, 0x6ae0, 0x4d43, 0x9d, 0x55, 0xa4, 0x6e, 0x9e, 0xfd, 0x15, 0x8a} +STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION { + Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, + EncryptionGuid: GUID, +}} +STRUCT!{struct D3DENCRYPTED_BLOCK_INFO { + NumEncryptedBytesAtBeginning: UINT, + NumBytesInSkipPattern: UINT, + NumBytesInEncryptPattern: UINT, +}} +STRUCT!{struct D3DAES_CTR_IV { + IV: UINT64, + Count: UINT64, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3dkmdt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3dkmdt.rs new file mode 100644 index 0000000..89d574f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3dkmdt.rs @@ -0,0 +1,45 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Longhorn Display Driver Model (LDDM) kernel mode data type definitions +use shared::basetsd::UINT32; +use shared::minwindef::UINT; +use shared::ntdef::{BOOLEAN, WCHAR}; +//1932 +pub const DXGK_MAX_METADATA_NAME_LENGTH: usize = 32; +ENUM!{enum DXGK_ENGINE_TYPE { + DXGK_ENGINE_TYPE_OTHER, + DXGK_ENGINE_TYPE_3D, + DXGK_ENGINE_TYPE_VIDEO_DECODE, + DXGK_ENGINE_TYPE_VIDEO_ENCODE, + DXGK_ENGINE_TYPE_VIDEO_PROCESSING, + DXGK_ENGINE_TYPE_SCENE_ASSEMBLY, + DXGK_ENGINE_TYPE_COPY, + DXGK_ENGINE_TYPE_OVERLAY, + DXGK_ENGINE_TYPE_CRYPTO, + DXGK_ENGINE_TYPE_MAX, +}} +STRUCT!{#[repr(packed)] struct DXGK_NODEMETADATA_FLAGS { + Value: UINT32, +}} +BITFIELD!{DXGK_NODEMETADATA_FLAGS Value: UINT32 [ + ContextSchedulingSupported set_ContextSchedulingSupported[0..1], + RingBufferFenceRelease set_RingBufferFenceRelease[1..2], + SupportTrackedWorkload set_SupportTrackedWorkload[2..3], + Reserved set_Reserved[3..16], + MaxInFlightHwQueueBuffers set_MaxInFlightHwQueueBuffers[16..32], +]} +STRUCT!{#[repr(packed)] struct DXGK_NODEMETADATA { + EngineType: DXGK_ENGINE_TYPE, + FriendlyName: [WCHAR; DXGK_MAX_METADATA_NAME_LENGTH], + Flags: DXGK_NODEMETADATA_FLAGS, + GpuMmuSupported: BOOLEAN, + IoMmuSupported: BOOLEAN, +}} +//2100 +STRUCT!{#[repr(packed)] struct D3DKMT_NODEMETADATA { + NodeOrdinalAndAdapterIndex: UINT, + NodeData: DXGK_NODEMETADATA, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3dukmdt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3dukmdt.rs new file mode 100644 index 0000000..16a34d1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/d3dukmdt.rs @@ -0,0 +1,416 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Longhorn Display Driver Model (LDDM) user/kernel mode shared data type definitions. +use shared::basetsd::{UINT64, ULONG_PTR}; +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, UINT, ULONG}; +use shared::ntdef::{HANDLE, LUID, ULONGLONG, VOID}; +pub const DXGKDDI_INTERFACE_VERSION_VISTA: ULONG = 0x1052; +pub const DXGKDDI_INTERFACE_VERSION_VISTA_SP1: ULONG = 0x1053; +pub const DXGKDDI_INTERFACE_VERSION_WIN7: ULONG = 0x2005; +pub const DXGKDDI_INTERFACE_VERSION_WIN8: ULONG = 0x300E; +pub const DXGKDDI_INTERFACE_VERSION_WDDM1_3: ULONG = 0x4002; +pub const DXGKDDI_INTERFACE_VERSION_WDDM1_3_PATH_INDEPENDENT_ROTATION: ULONG = 0x4003; +pub const DXGKDDI_INTERFACE_VERSION_WDDM2_0: ULONG = 0x5023; +pub const DXGKDDI_INTERFACE_VERSION_WDDM2_1: ULONG = 0x6003; +pub const DXGKDDI_INTERFACE_VERSION_WDDM2_1_5: ULONG = 0x6010; +pub const DXGKDDI_INTERFACE_VERSION_WDDM2_2: ULONG = 0x700A; +pub const DXGKDDI_INTERFACE_VERSION_WDDM2_3: ULONG = 0x8001; +pub const DXGKDDI_INTERFACE_VERSION_WDDM2_4: ULONG = 0x9006; +pub const DXGKDDI_INTERFACE_VERSION_WDDM2_5: ULONG = 0xA00B; +#[inline] +pub fn IS_OFFICIAL_DDI_INTERFACE_VERSION(version: ULONG) -> bool { + (version == DXGKDDI_INTERFACE_VERSION_VISTA) || + (version == DXGKDDI_INTERFACE_VERSION_VISTA_SP1) || + (version == DXGKDDI_INTERFACE_VERSION_WIN7) || + (version == DXGKDDI_INTERFACE_VERSION_WIN8) || + (version == DXGKDDI_INTERFACE_VERSION_WDDM1_3) || + (version == DXGKDDI_INTERFACE_VERSION_WDDM1_3_PATH_INDEPENDENT_ROTATION) || + (version == DXGKDDI_INTERFACE_VERSION_WDDM2_0) || + (version == DXGKDDI_INTERFACE_VERSION_WDDM2_1) || + (version == DXGKDDI_INTERFACE_VERSION_WDDM2_1_5) || + (version == DXGKDDI_INTERFACE_VERSION_WDDM2_2) || + (version == DXGKDDI_INTERFACE_VERSION_WDDM2_3) || + (version == DXGKDDI_INTERFACE_VERSION_WDDM2_4) || + (version == DXGKDDI_INTERFACE_VERSION_WDDM2_5) +} +pub const DXGKDDI_INTERFACE_VERSION: ULONG = DXGKDDI_INTERFACE_VERSION_WDDM2_5; +pub const D3D_UMD_INTERFACE_VERSION_VISTA: ULONG = 0x000C; +pub const D3D_UMD_INTERFACE_VERSION_WIN7: ULONG = 0x2003; +pub const D3D_UMD_INTERFACE_VERSION_WIN8_M3: ULONG = 0x3001; +pub const D3D_UMD_INTERFACE_VERSION_WIN8_CP: ULONG = 0x3002; +pub const D3D_UMD_INTERFACE_VERSION_WIN8_RC: ULONG = 0x3003; +pub const D3D_UMD_INTERFACE_VERSION_WIN8: ULONG = 0x3004; +pub const D3D_UMD_INTERFACE_VERSION_WDDM1_3: ULONG = 0x4002; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_0_M1: ULONG = 0x5000; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_0_M1_3: ULONG = 0x5001; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_0_M2_2: ULONG = 0x5002; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_0: ULONG = 0x5002; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_1_1: ULONG = 0x6000; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_1_2: ULONG = 0x6001; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_1_3: ULONG = 0x6002; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_1_4: ULONG = 0x6003; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_1: ULONG = D3D_UMD_INTERFACE_VERSION_WDDM2_1_4; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_2_1: ULONG = 0x7000; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_2_2: ULONG = 0x7001; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_2: ULONG = D3D_UMD_INTERFACE_VERSION_WDDM2_2_2; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_3_1: ULONG = 0x8000; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_3_2: ULONG = 0x8001; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_3: ULONG = D3D_UMD_INTERFACE_VERSION_WDDM2_3_2; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_4_1: ULONG = 0x9000; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_4_2: ULONG = 0x9001; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_4: ULONG = D3D_UMD_INTERFACE_VERSION_WDDM2_4_2; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_5_1: ULONG = 0xA000; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_5_2: ULONG = 0xA001; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_5_3: ULONG = 0xA002; +pub const D3D_UMD_INTERFACE_VERSION_WDDM2_5: ULONG = D3D_UMD_INTERFACE_VERSION_WDDM2_5_3; +pub const D3D_UMD_INTERFACE_VERSION: ULONG = D3D_UMD_INTERFACE_VERSION_WDDM2_5; +pub type D3DGPU_VIRTUAL_ADDRESS = ULONGLONG; +pub type D3DGPU_SIZE_T = ULONGLONG; +pub const D3DGPU_UNIQUE_DRIVER_PROTECTION: ULONGLONG = 0x8000000000000000; +pub const DXGK_MAX_PAGE_TABLE_LEVEL_COUNT: UINT = 6; +pub const DXGK_MIN_PAGE_TABLE_LEVEL_COUNT: UINT = 2; +STRUCT!{struct GPUP_DRIVER_ESCAPE_INPUT { + vfLUID: LUID, +}} +pub type PGPUP_DRIVER_ESCAPE_INPUT = *mut GPUP_DRIVER_ESCAPE_INPUT; +ENUM!{enum DXGKVGPU_ESCAPE_TYPE { + DXGKVGPU_ESCAPE_TYPE_READ_PCI_CONFIG = 0, + DXGKVGPU_ESCAPE_TYPE_WRITE_PCI_CONFIG = 1, + DXGKVGPU_ESCAPE_TYPE_INITIALIZE = 2, + DXGKVGPU_ESCAPE_TYPE_RELEASE = 3, + DXGKVGPU_ESCAPE_TYPE_GET_VGPU_TYPE = 4, + DXGKVGPU_ESCAPE_TYPE_POWERTRANSITIONCOMPLETE = 5, +}} +STRUCT!{struct DXGKVGPU_ESCAPE_HEAD { + Luid: GPUP_DRIVER_ESCAPE_INPUT, + Type: DXGKVGPU_ESCAPE_TYPE, +}} +STRUCT!{struct DXGKVGPU_ESCAPE_READ_PCI_CONFIG { + Header: DXGKVGPU_ESCAPE_HEAD, + Offset: UINT, + Size: UINT, +}} +STRUCT!{struct DXGKVGPU_ESCAPE_WRITE_PCI_CONFIG { + Header: DXGKVGPU_ESCAPE_HEAD, + Offset: UINT, + Size: UINT, +}} +STRUCT!{struct DXGKVGPU_ESCAPE_READ_VGPU_TYPE { + Header: DXGKVGPU_ESCAPE_HEAD, +}} +STRUCT!{struct DXGKVGPU_ESCAPE_POWERTRANSITIONCOMPLETE { + Header: DXGKVGPU_ESCAPE_HEAD, + PowerState: UINT, +}} +STRUCT!{struct DXGKVGPU_ESCAPE_INITIALIZE { + Header: DXGKVGPU_ESCAPE_HEAD, + VmGuid: GUID, +}} +STRUCT!{struct DXGKVGPU_ESCAPE_RELEASE { + Header: DXGKVGPU_ESCAPE_HEAD, +}} +ENUM!{enum DXGK_PTE_PAGE_SIZE { + DXGK_PTE_PAGE_TABLE_PAGE_4KB = 0, + DXGK_PTE_PAGE_TABLE_PAGE_64KB = 1, +}} +UNION!{union DXGK_PTE_u { + [u64; 1], + PageAddress PageAddress_mut: ULONGLONG, + PageTableAddress PageTableAddress_mut: ULONGLONG, +}} +STRUCT!{struct DXGK_PTE { + Flags: ULONGLONG, + u: DXGK_PTE_u, +}} +BITFIELD!{DXGK_PTE Flags: ULONGLONG [ + Valid set_Valid[0..1], + Zero set_Zero[1..2], + CacheCoherent set_CacheCoherent[2..3], + ReadOnly set_ReadOnly[3..4], + NoExecute set_NoExecute[4..5], + Segment set_Segment[5..10], + LargePage set_LargePage[10..11], + PhysicalAdapterIndex set_PhysicalAdapterIndex[11..17], + PageTablePageSize set_PageTablePageSize[17..19], + SystemReserved0 set_SystemReserved0[19..20], + Reserved set_Reserved[20..64], +]} +pub const D3DGPU_NULL: D3DGPU_VIRTUAL_ADDRESS = 0; +pub const D3DDDI_MAX_WRITTEN_PRIMARIES: usize = 16; +pub const D3DDDI_MAX_MPO_PRESENT_DIRTY_RECTS: usize = 0xFFF; +STRUCT!{struct D3DGPU_PHYSICAL_ADDRESS { + SegmentId: UINT, + SegmentOffset: UINT64, +}} +pub type D3DDDI_VIDEO_PRESENT_SOURCE_ID = UINT; +pub type D3DDDI_VIDEO_PRESENT_TARGET_ID = UINT; +pub type D3DKMT_HANDLE = UINT; +STRUCT!{struct D3DDDI_RATIONAL { + Numerator: UINT, + Denominator: UINT, +}} +STRUCT!{struct D3DDDI_ALLOCATIONINFO { + hAllocation: D3DKMT_HANDLE, + pSystemMem: *const VOID, + pPrivateDriverData: *mut VOID, + PrivateDriverDataSize: UINT, + VidPnSourceId: D3DDDI_VIDEO_PRESENT_SOURCE_ID, + Flags: UINT, +}} +BITFIELD!{D3DDDI_ALLOCATIONINFO Flags: UINT [ + Primary set_Primary[0..1], + Stereo set_Stereo[1..2], + Reserved set_Reserved[2..32], +]} +UNION!{union D3DDDI_ALLOCATIONINFO2_u1 { + [usize; 1], + hSection hSection_mut: HANDLE, + pSystemMem pSystemMem_mut: *const VOID, +}} +UNION!{union D3DDDI_ALLOCATIONINFO2_u2 { + [usize; 1], + Priority Priority_mut: UINT, + Unused Unused_mut: ULONG_PTR, +}} +STRUCT!{struct D3DDDI_ALLOCATIONINFO2 { + hAllocation: D3DKMT_HANDLE, + u1: D3DDDI_ALLOCATIONINFO2_u1, + pPrivateDriverData: *mut VOID, + PrivateDriverDataSize: UINT, + VidPnSourceId: D3DDDI_VIDEO_PRESENT_SOURCE_ID, + Flags: UINT, + GpuVirtualAddress: D3DGPU_VIRTUAL_ADDRESS, + u2: D3DDDI_ALLOCATIONINFO2_u2, + Reserved: [ULONG_PTR; 5], +}} +BITFIELD!{D3DDDI_ALLOCATIONINFO2 Flags: UINT [ + Primary set_Primary[0..1], + Stereo set_Stereo[1..2], + OverridePriority set_OverridePriority[2..3], + Reserved set_Reserved[3..32], +]} +STRUCT!{struct D3DDDI_OPENALLOCATIONINFO { + hAllocation: D3DKMT_HANDLE, + pPrivateDriverData: *const VOID, + PrivateDriverDataSize: UINT, +}} +STRUCT!{struct D3DDDI_OPENALLOCATIONINFO2 { + hAllocation: D3DKMT_HANDLE, + pPrivateDriverData: *const VOID, + PrivateDriverDataSize: UINT, + GpuVirtualAddress: D3DGPU_VIRTUAL_ADDRESS, + Reserved: [ULONG_PTR; 6], +}} +ENUM!{enum D3DDDI_OFFER_PRIORITY { + D3DDDI_OFFER_PRIORITY_NONE = 0, + D3DDDI_OFFER_PRIORITY_LOW = 1, + D3DDDI_OFFER_PRIORITY_NORMAL, + D3DDDI_OFFER_PRIORITY_HIGH, + D3DDDI_OFFER_PRIORITY_AUTO, +}} +STRUCT!{struct D3DDDI_ALLOCATIONLIST { + hAllocation: D3DKMT_HANDLE, + Value: UINT, +}} +BITFIELD!{D3DDDI_ALLOCATIONLIST Value: UINT [ + WriteOperation set_WriteOperation[0..1], + DoNotRetireInstance set_DoNotRetireInstance[1..2], + OfferPriority set_OfferPriority[2..5], + Reserved set_Reserved[5..32], +]} +STRUCT!{struct D3DDDI_PATCHLOCATIONLIST { + AllocationIndex: UINT, + Value: UINT, + DriverId: UINT, + AllocationOffset: UINT, + PatchOffset: UINT, + SplitOffset: UINT, +}} +BITFIELD!{D3DDDI_PATCHLOCATIONLIST Value: UINT [ + SlotId set_SlotId[0..24], + Reserved set_Reserved[24..32], +]} +STRUCT!{struct D3DDDICB_LOCKFLAGS { + Value: UINT, +}} +BITFIELD!{D3DDDICB_LOCKFLAGS Value: UINT [ + ReadOnly set_ReadOnly[0..1], + WriteOnly set_WriteOnly[1..2], + DonotWait set_DonotWait[2..3], + IgnoreSync set_IgnoreSync[3..4], + LockEntire set_LockEntire[4..5], + DonotEvict set_DonotEvict[5..6], + AcquireAperture set_AcquireAperture[6..7], + Discard set_Discard[7..8], + NoExistingReference set_NoExistingReference[8..9], + UseAlternateVA set_UseAlternateVA[9..10], + IgnoreReadSync set_IgnoreReadSync[10..11], + Reserved set_Reserved[11..32], +]} +STRUCT!{struct D3DDDICB_LOCK2FLAGS { + Value: UINT, +}} +BITFIELD!{D3DDDICB_LOCK2FLAGS Value: UINT [ + Reserved set_Reserved[0..32], +]} +STRUCT!{struct D3DDDICB_DESTROYALLOCATION2FLAGS { + Value: UINT, +}} +BITFIELD!{D3DDDICB_DESTROYALLOCATION2FLAGS Value: UINT [ + AssumeNotInUse set_AssumeNotInUse[0..1], + SynchronousDestroy set_SynchronousDestroy[1..2], + Reserved set_Reserved[2..31], + SystemUseOnly set_SystemUseOnly[31..32], +]} +STRUCT!{struct D3DDDI_ESCAPEFLAGS { + Value: UINT, +}} +BITFIELD!{D3DDDI_ESCAPEFLAGS Value: UINT [ + HardwareAccess set_HardwareAccess[0..1], + DeviceStatusQuery set_DeviceStatusQuery[1..2], + ChangeFrameLatency set_ChangeFrameLatency[2..3], + NoAdapterSynchronization set_NoAdapterSynchronization[3..4], + Reserved set_Reserved[4..5], + VirtualMachineData set_VirtualMachineData[5..6], + DriverKnownEscape set_DriverKnownEscape[6..7], + DriverCommonEscape set_DriverCommonEscape[7..8], + Reserved2 set_Reserved2[8..24], +]} +ENUM!{enum D3DDDI_DRIVERESCAPETYPE { + D3DDDI_DRIVERESCAPETYPE_TRANSLATEALLOCATIONHANDLE = 0, + D3DDDI_DRIVERESCAPETYPE_TRANSLATERESOURCEHANDLE = 1, + D3DDDI_DRIVERESCAPETYPE_MAX, +}} +STRUCT!{struct D3DDDI_DRIVERESCAPE_TRANSLATEALLOCATIONEHANDLE { + EscapeType: D3DDDI_DRIVERESCAPETYPE, + hAllocation: D3DKMT_HANDLE, +}} +STRUCT!{struct D3DDDI_DRIVERESCAPE_TRANSLATERESOURCEHANDLE { + EscapeType: D3DDDI_DRIVERESCAPETYPE, + hResource: D3DKMT_HANDLE, +}} +STRUCT!{struct D3DDDI_CREATECONTEXTFLAGS { + Value: UINT, +}} +BITFIELD!{D3DDDI_CREATECONTEXTFLAGS Value: UINT [ + NullRendering set_NullRendering[0..1], + InitialData set_InitialData[1..2], + DisableGpuTimeout set_DisableGpuTimeout[2..3], + SynchronizationOnly set_SynchronizationOnly[3..4], + HwQueueSupported set_HwQueueSupported[4..5], + Reserved set_Reserved[5..32], +]} +//1188 +STRUCT!{struct D3DDDICB_SIGNALFLAGS { + Value: UINT, +}} +BITFIELD!{D3DDDICB_SIGNALFLAGS Value: UINT [ + SignalAtSubmission set_SignalAtSubmission[0..1], + EnqueueCpuEvent set_EnqueueCpuEvent[1..2], + AllowFenceRewind set_AllowFenceRewind[2..3], + Reserved set_Reserved[3..31], + DXGK_SIGNAL_FLAG_INTERNAL0 set_DXGK_SIGNAL_FLAG_INTERNAL0[31..32], +]} +pub const D3DDDI_MAX_OBJECT_WAITED_ON: usize = 32; +pub const D3DDDI_MAX_OBJECT_SIGNALED: usize = 32; +ENUM!{enum D3DDDI_SYNCHRONIZATIONOBJECT_TYPE { + D3DDDI_SYNCHRONIZATION_MUTEX = 1, + D3DDDI_SEMAPHORE = 2, + D3DDDI_FENCE = 3, + D3DDDI_CPU_NOTIFICATION = 4, + D3DDDI_MONITORED_FENCE = 5, + D3DDDI_PERIODIC_MONITORED_FENCE = 6, + D3DDDI_SYNCHRONIZATION_TYPE_LIMIT, +}} +//1553 +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO_u_SynchronizationMutex { + InitialState: BOOL, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO_u_Semaphore { + MaxCount: UINT, + InitialCount: UINT, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO_u_Reserved { + Reserved: [UINT; 16], +}} +UNION!{union D3DDDI_SYNCHRONIZATIONOBJECTINFO_u { + [u32; 16], + SynchronizationMutex SynchronizationMutex_mut: + D3DDDI_SYNCHRONIZATIONOBJECTINFO_u_SynchronizationMutex, + Semaphore Semaphore_mut: D3DDDI_SYNCHRONIZATIONOBJECTINFO_u_Semaphore, + Reserved Reserved_mut: D3DDDI_SYNCHRONIZATIONOBJECTINFO_u_Reserved, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO { + Type: D3DDDI_SYNCHRONIZATIONOBJECT_TYPE, + u: D3DDDI_SYNCHRONIZATIONOBJECTINFO_u, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECT_FLAGS { + Value: UINT, +}} +BITFIELD!{D3DDDI_SYNCHRONIZATIONOBJECT_FLAGS Value: UINT [ + Shared set_Shared[0..1], + NtSecuritySharing set_NtSecuritySharing[1..2], + CrossAdapter set_CrossAdapter[2..3], + TopOfPipeline set_TopOfPipeline[3..4], + NoSignal set_NoSignal[4..5], + NoWait set_NoWait[5..6], + NoSignalMaxValueOnTdr set_NoSignalMaxValueOnTdr[6..7], + NoGPUAccess set_NoGPUAccess[7..8], + Reserved set_Reserved[8..31], + D3DDDI_SYNCHRONIZATIONOBJECT_FLAGS_RESERVED0 + set_D3DDDI_SYNCHRONIZATIONOBJECT_FLAGS_RESERVED0[31..32], +]} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_SynchronizationMutex { + InitialState: BOOL, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_Semaphore { + MaxCount: UINT, + InitialCount: UINT, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_Fence { + FenceValue: UINT64, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_CPUNotification { + Event: HANDLE, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_MonitoredFence { + InitialFenceValue: UINT64, + FenceValueCPUVirtualAddress: *mut VOID, + FenceValueGPUVirtualAddress: D3DGPU_VIRTUAL_ADDRESS, + EngineAffinity: UINT, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_PeriodicMonitoredFence { + hAdapter: D3DKMT_HANDLE, + VidPnTargetId: D3DDDI_VIDEO_PRESENT_TARGET_ID, + Time: UINT64, + FenceValueCPUVirtualAddress: *mut VOID, + FenceValueGPUVirtualAddress: D3DGPU_VIRTUAL_ADDRESS, + EngineAffinity: UINT, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_Reserved { + Reserved: [UINT64; 8], +}} +UNION!{union D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u { + [u64; 8], + SynchronizationMutex SynchronizationMutex_mut: + D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_SynchronizationMutex, + Semaphore Semaphore_mut: D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_Semaphore, + Fence Fence_mut: D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_Fence, + CPUNotification CPUNotification_mut: D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_CPUNotification, + MonitoredFence MonitoredFence_mut: D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_MonitoredFence, + PeriodicMonitoredFence PeriodicMonitoredFence_mut: + D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_PeriodicMonitoredFence, + Reserved Reserved_mut: D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u_Reserved, +}} +STRUCT!{struct D3DDDI_SYNCHRONIZATIONOBJECTINFO2 { + Type: D3DDDI_SYNCHRONIZATIONOBJECT_TYPE, + Flags: D3DDDI_SYNCHRONIZATIONOBJECT_FLAGS, + u: D3DDDI_SYNCHRONIZATIONOBJECTINFO2_u, + SharedHandle: D3DKMT_HANDLE, +}} +//1778 +pub const D3DDDI_MAX_BROADCAST_CONTEXT: usize = 64; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/dcomptypes.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dcomptypes.rs new file mode 100644 index 0000000..4d45d3c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dcomptypes.rs @@ -0,0 +1,50 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dcomptypes.h +use shared::dxgitype::DXGI_RATIONAL; +use shared::minwindef::DWORD; +use um::winnt::LARGE_INTEGER; +ENUM!{enum DCOMPOSITION_BITMAP_INTERPOLATION_MODE { + DCOMPOSITION_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR = 0, + DCOMPOSITION_BITMAP_INTERPOLATION_MODE_LINEAR = 1, + DCOMPOSITION_BITMAP_INTERPOLATION_MODE_INHERIT = 0xffffffff, +}} +ENUM!{enum DCOMPOSITION_BORDER_MODE { + DCOMPOSITION_BORDER_MODE_SOFT = 0, + DCOMPOSITION_BORDER_MODE_HARD = 1, + DCOMPOSITION_BORDER_MODE_INHERIT = 0xffffffff, +}} +ENUM!{enum DCOMPOSITION_COMPOSITE_MODE { + DCOMPOSITION_COMPOSITE_MODE_SOURCE_OVER = 0, + DCOMPOSITION_COMPOSITE_MODE_DESTINATION_INVERT = 1, + DCOMPOSITION_COMPOSITE_MODE_MIN_BLEND = 2, + DCOMPOSITION_COMPOSITE_MODE_INHERIT = 0xffffffff, +}} +ENUM!{enum DCOMPOSITION_BACKFACE_VISIBILITY { + DCOMPOSITION_BACKFACE_VISIBILITY_VISIBLE = 0, + DCOMPOSITION_BACKFACE_VISIBILITY_HIDDEN = 1, + DCOMPOSITION_BACKFACE_VISIBILITY_INHERIT = 0xffffffff, +}} +ENUM!{enum DCOMPOSITION_OPACITY_MODE { + DCOMPOSITION_OPACITY_MODE_LAYER = 0, + DCOMPOSITION_OPACITY_MODE_MULTIPLY = 1, + DCOMPOSITION_OPACITY_MODE_INHERIT = 0xffffffff, +}} +ENUM!{enum DCOMPOSITION_DEPTH_MODE { + DCOMPOSITION_DEPTH_MODE_TREE = 0, + DCOMPOSITION_DEPTH_MODE_SPATIAL = 1, + DCOMPOSITION_DEPTH_MODE_INHERIT = 0xffffffff, +}} +STRUCT!{struct DCOMPOSITION_FRAME_STATISTICS { + lastFrameTime: LARGE_INTEGER, + currentCompositionRate: DXGI_RATIONAL, + currentTime: LARGE_INTEGER, + timeFrequency: LARGE_INTEGER, + nextEstimatedFrameTime: LARGE_INTEGER, +}} +pub const COMPOSITIONOBJECT_READ: DWORD = 0x0001; +pub const COMPOSITIONOBJECT_WRITE: DWORD = 0x0002; +pub const COMPOSITIONOBJECT_ALL_ACCESS: DWORD = COMPOSITIONOBJECT_READ | COMPOSITIONOBJECT_WRITE; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/devguid.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/devguid.rs new file mode 100644 index 0000000..f163037 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/devguid.rs @@ -0,0 +1,178 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Defines GUIDs for device classes used in Plug & Play. +DEFINE_GUID!{GUID_DEVCLASS_1394, + 0x6bdd1fc1, 0x810f, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f} +DEFINE_GUID!{GUID_DEVCLASS_1394DEBUG, + 0x66f250d6, 0x7801, 0x4a64, 0xb1, 0x39, 0xee, 0xa8, 0x0a, 0x45, 0x0b, 0x24} +DEFINE_GUID!{GUID_DEVCLASS_61883, + 0x7ebefbc0, 0x3200, 0x11d2, 0xb4, 0xc2, 0x00, 0xa0, 0xc9, 0x69, 0x7d, 0x07} +DEFINE_GUID!{GUID_DEVCLASS_ADAPTER, + 0x4d36e964, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_APMSUPPORT, + 0xd45b1c18, 0xc8fa, 0x11d1, 0x9f, 0x77, 0x00, 0x00, 0xf8, 0x05, 0xf5, 0x30} +DEFINE_GUID!{GUID_DEVCLASS_AVC, + 0xc06ff265, 0xae09, 0x48f0, 0x81, 0x2c, 0x16, 0x75, 0x3d, 0x7c, 0xba, 0x83} +DEFINE_GUID!{GUID_DEVCLASS_BATTERY, + 0x72631e54, 0x78a4, 0x11d0, 0xbc, 0xf7, 0x00, 0xaa, 0x00, 0xb7, 0xb3, 0x2a} +DEFINE_GUID!{GUID_DEVCLASS_BIOMETRIC, + 0x53d29ef7, 0x377c, 0x4d14, 0x86, 0x4b, 0xeb, 0x3a, 0x85, 0x76, 0x93, 0x59} +DEFINE_GUID!{GUID_DEVCLASS_BLUETOOTH, + 0xe0cbf06c, 0xcd8b, 0x4647, 0xbb, 0x8a, 0x26, 0x3b, 0x43, 0xf0, 0xf9, 0x74} +DEFINE_GUID!{GUID_DEVCLASS_CDROM, + 0x4d36e965, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_COMPUTER, + 0x4d36e966, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_DECODER, + 0x6bdd1fc2, 0x810f, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f} +DEFINE_GUID!{GUID_DEVCLASS_DISKDRIVE, + 0x4d36e967, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_DISPLAY, + 0x4d36e968, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_DOT4, + 0x48721b56, 0x6795, 0x11d2, 0xb1, 0xa8, 0x00, 0x80, 0xc7, 0x2e, 0x74, 0xa2} +DEFINE_GUID!{GUID_DEVCLASS_DOT4PRINT, + 0x49ce6ac8, 0x6f86, 0x11d2, 0xb1, 0xe5, 0x00, 0x80, 0xc7, 0x2e, 0x74, 0xa2} +DEFINE_GUID!{GUID_DEVCLASS_ENUM1394, + 0xc459df55, 0xdb08, 0x11d1, 0xb0, 0x09, 0x00, 0xa0, 0xc9, 0x08, 0x1f, 0xf6} +DEFINE_GUID!{GUID_DEVCLASS_FDC, + 0x4d36e969, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_FLOPPYDISK, + 0x4d36e980, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_GPS, + 0x6bdd1fc3, 0x810f, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f} +DEFINE_GUID!{GUID_DEVCLASS_HDC, + 0x4d36e96a, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_HIDCLASS, + 0x745a17a0, 0x74d3, 0x11d0, 0xb6, 0xfe, 0x00, 0xa0, 0xc9, 0x0f, 0x57, 0xda} +DEFINE_GUID!{GUID_DEVCLASS_IMAGE, + 0x6bdd1fc6, 0x810f, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f} +DEFINE_GUID!{GUID_DEVCLASS_INFINIBAND, + 0x30ef7132, 0xd858, 0x4a0c, 0xac, 0x24, 0xb9, 0x02, 0x8a, 0x5c, 0xca, 0x3f} +DEFINE_GUID!{GUID_DEVCLASS_INFRARED, + 0x6bdd1fc5, 0x810f, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f} +DEFINE_GUID!{GUID_DEVCLASS_KEYBOARD, + 0x4d36e96b, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_LEGACYDRIVER, + 0x8ecc055d, 0x047f, 0x11d1, 0xa5, 0x37, 0x00, 0x00, 0xf8, 0x75, 0x3e, 0xd1} +DEFINE_GUID!{GUID_DEVCLASS_MEDIA, + 0x4d36e96c, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_MEDIUM_CHANGER, + 0xce5939ae, 0xebde, 0x11d0, 0xb1, 0x81, 0x00, 0x00, 0xf8, 0x75, 0x3e, 0xc4} +DEFINE_GUID!{GUID_DEVCLASS_MODEM, + 0x4d36e96d, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_MEMORY, + 0x5099944a, 0xf6b9, 0x4057, 0xa0, 0x56, 0x8c, 0x55, 0x02, 0x28, 0x54, 0x4c} +DEFINE_GUID!{GUID_DEVCLASS_MONITOR, + 0x4d36e96e, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_MOUSE, + 0x4d36e96f, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_MTD, + 0x4d36e970, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_MULTIFUNCTION, + 0x4d36e971, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_MULTIPORTSERIAL, + 0x50906cb8, 0xba12, 0x11d1, 0xbf, 0x5d, 0x00, 0x00, 0xf8, 0x05, 0xf5, 0x30} +DEFINE_GUID!{GUID_DEVCLASS_NET, + 0x4d36e972, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_NETCLIENT, + 0x4d36e973, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_NETSERVICE, + 0x4d36e974, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_NETTRANS, + 0x4d36e975, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_NODRIVER, + 0x4d36e976, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_PCMCIA, + 0x4d36e977, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_PNPPRINTERS, + 0x4658ee7e, 0xf050, 0x11d1, 0xb6, 0xbd, 0x00, 0xc0, 0x4f, 0xa3, 0x72, 0xa7} +DEFINE_GUID!{GUID_DEVCLASS_PORTS, + 0x4d36e978, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_PRINTER, + 0x4d36e979, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_PRINTERUPGRADE, + 0x4d36e97a, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_PROCESSOR, + 0x50127dc3, 0x0f36, 0x415e, 0xa6, 0xcc, 0x4c, 0xb3, 0xbe, 0x91, 0x0B, 0x65} +DEFINE_GUID!{GUID_DEVCLASS_SBP2, + 0xd48179be, 0xec20, 0x11d1, 0xb6, 0xb8, 0x00, 0xc0, 0x4f, 0xa3, 0x72, 0xa7} +DEFINE_GUID!{GUID_DEVCLASS_SCSIADAPTER, + 0x4d36e97b, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_SECURITYACCELERATOR, + 0x268c95a1, 0xedfe, 0x11d3, 0x95, 0xc3, 0x00, 0x10, 0xdc, 0x40, 0x50, 0xa5} +DEFINE_GUID!{GUID_DEVCLASS_SENSOR, + 0x5175d334, 0xc371, 0x4806, 0xb3, 0xba, 0x71, 0xfd, 0x53, 0xc9, 0x25, 0x8d} +DEFINE_GUID!{GUID_DEVCLASS_SIDESHOW, + 0x997b5d8d, 0xc442, 0x4f2e, 0xba, 0xf3, 0x9c, 0x8e, 0x67, 0x1e, 0x9e, 0x21} +DEFINE_GUID!{GUID_DEVCLASS_SMARTCARDREADER, + 0x50dd5230, 0xba8a, 0x11d1, 0xbf, 0x5d, 0x00, 0x00, 0xf8, 0x05, 0xf5, 0x30} +DEFINE_GUID!{GUID_DEVCLASS_SOUND, + 0x4d36e97c, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_SYSTEM, + 0x4d36e97d, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_TAPEDRIVE, + 0x6d807884, 0x7d21, 0x11cf, 0x80, 0x1c, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_UNKNOWN, + 0x4d36e97e, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_DEVCLASS_USB, + 0x36fc9e60, 0xc465, 0x11cf, 0x80, 0x56, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_DEVCLASS_VOLUME, + 0x71a27cdd, 0x812a, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f} +DEFINE_GUID!{GUID_DEVCLASS_VOLUMESNAPSHOT, + 0x533c5b84, 0xec70, 0x11d2, 0x95, 0x05, 0x00, 0xc0, 0x4f, 0x79, 0xde, 0xaf} +DEFINE_GUID!{GUID_DEVCLASS_WCEUSBS, + 0x25dbce51, 0x6c8f, 0x4a72, 0x8a, 0x6d, 0xb5, 0x4c, 0x2b, 0x4f, 0xc8, 0x35} +DEFINE_GUID!{GUID_DEVCLASS_WPD, + 0xeec5ad98, 0x8080, 0x425f, 0x92, 0x2a, 0xda, 0xbf, 0x3d, 0xe3, 0xf6, 0x9a} +DEFINE_GUID!{GUID_DEVCLASS_EHSTORAGESILO, + 0x9da2b80f, 0xf89f, 0x4a49, 0xa5, 0xc2, 0x51, 0x1b, 0x08, 0x5b, 0x9e, 0x8a} +DEFINE_GUID!{GUID_DEVCLASS_FIRMWARE, + 0xf2e7dd72, 0x6468, 0x4e36, 0xb6, 0xf1, 0x64, 0x88, 0xf4, 0x2c, 0x1b, 0x52} +DEFINE_GUID!{GUID_DEVCLASS_EXTENSION, + 0xe2f84ce7, 0x8efa, 0x411c, 0xaa, 0x69, 0x97, 0x45, 0x4c, 0xa4, 0xcb, 0x57} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_TOP, + 0xb369baf4, 0x5568, 0x4e82, 0xa8, 0x7e, 0xa9, 0x3e, 0xb1, 0x6b, 0xca, 0x87} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_ACTIVITYMONITOR, + 0xb86dff51, 0xa31e, 0x4bac, 0xb3, 0xcf, 0xe8, 0xcf, 0xe7, 0x5c, 0x9f, 0xc2} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_UNDELETE, + 0xfe8f1572, 0xc67a, 0x48c0, 0xbb, 0xac, 0x0b, 0x5c, 0x6d, 0x66, 0xca, 0xfb} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_ANTIVIRUS, + 0xb1d1a169, 0xc54f, 0x4379, 0x81, 0xdb, 0xbe, 0xe7, 0xd8, 0x8d, 0x74, 0x54} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_REPLICATION, + 0x48d3ebc4, 0x4cf8, 0x48ff, 0xb8, 0x69, 0x9c, 0x68, 0xad, 0x42, 0xeb, 0x9f} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_CONTINUOUSBACKUP, + 0x71aa14f8, 0x6fad, 0x4622, 0xad, 0x77, 0x92, 0xbb, 0x9d, 0x7e, 0x69, 0x47} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_CONTENTSCREENER, + 0x3e3f0674, 0xc83c, 0x4558, 0xbb, 0x26, 0x98, 0x20, 0xe1, 0xeb, 0xa5, 0xc5} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_QUOTAMANAGEMENT, + 0x8503c911, 0xa6c7, 0x4919, 0x8f, 0x79, 0x50, 0x28, 0xf5, 0x86, 0x6b, 0x0c} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_SYSTEMRECOVERY, + 0x2db15374, 0x706e, 0x4131, 0xa0, 0xc7, 0xd7, 0xc7, 0x8e, 0xb0, 0x28, 0x9a} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_CFSMETADATASERVER, + 0xcdcf0939, 0xb75b, 0x4630, 0xbf, 0x76, 0x80, 0xf7, 0xba, 0x65, 0x58, 0x84} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_HSM, + 0xd546500a, 0x2aeb, 0x45f6, 0x94, 0x82, 0xf4, 0xb1, 0x79, 0x9c, 0x31, 0x77} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_COMPRESSION, + 0xf3586baf, 0xb5aa, 0x49b5, 0x8d, 0x6c, 0x05, 0x69, 0x28, 0x4c, 0x63, 0x9f} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_ENCRYPTION, + 0xa0a701c0, 0xa511, 0x42ff, 0xaa, 0x6c, 0x06, 0xdc, 0x03, 0x95, 0x57, 0x6f} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_VIRTUALIZATION, + 0xf75a86c0, 0x10d8, 0x4c3a, 0xb2, 0x33, 0xed, 0x60, 0xe4, 0xcd, 0xfa, 0xac} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_PHYSICALQUOTAMANAGEMENT, + 0x6a0a8e78, 0xbba6, 0x4fc4, 0xa7, 0x09, 0x1e, 0x33, 0xcd, 0x09, 0xd6, 0x7e} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_OPENFILEBACKUP, + 0xf8ecafa6, 0x66d1, 0x41a5, 0x89, 0x9b, 0x66, 0x58, 0x5d, 0x72, 0x16, 0xb7} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_SECURITYENHANCER, + 0xd02bc3da, 0x0c8e, 0x4945, 0x9b, 0xd5, 0xf1, 0x88, 0x3c, 0x22, 0x6c, 0x8c} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_COPYPROTECTION, + 0x89786ff1, 0x9c12, 0x402f, 0x9c, 0x9e, 0x17, 0x75, 0x3c, 0x7f, 0x43, 0x75} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_BOTTOM, + 0x37765ea0, 0x5958, 0x4fc9, 0xb0, 0x4b, 0x2f, 0xdf, 0xef, 0x97, 0xe5, 0x9e} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_SYSTEM, + 0x5d1b9aaa, 0x01e2, 0x46af, 0x84, 0x9f, 0x27, 0x2b, 0x3f, 0x32, 0x4c, 0x46} +DEFINE_GUID!{GUID_DEVCLASS_FSFILTER_INFRASTRUCTURE, + 0xe55fa6f9, 0x128c, 0x4d04, 0xab, 0xab, 0x63, 0x0c, 0x74, 0xb1, 0x45, 0x3a} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/devpkey.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/devpkey.rs new file mode 100644 index 0000000..db68557 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/devpkey.rs @@ -0,0 +1,401 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! Defines property keys for the Plug and Play Device Property API. +use shared::devpropdef::DEVPROPKEY; +DEFINE_DEVPROPKEY!{DEVPKEY_NAME, + 0xb725f130, 0x47ef, 0x101a, 0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac, 10} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DeviceDesc, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_HardwareIds, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_CompatibleIds, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 4} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Service, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 6} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Class, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 9} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ClassGuid, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 10} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Driver, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 11} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ConfigFlags, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 12} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Manufacturer, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 13} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_FriendlyName, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_LocationInfo, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 15} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_PDOName, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 16} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Capabilities, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 17} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_UINumber, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 18} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_UpperFilters, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 19} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_LowerFilters, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 20} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_BusTypeGuid, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 21} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_LegacyBusType, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 22} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_BusNumber, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 23} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_EnumeratorName, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 24} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Security, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 25} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_SecuritySDS, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 26} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DevType, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 27} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Exclusive, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 28} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Characteristics, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 29} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Address, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 30} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_UINumberDescFormat, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 31} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_PowerData, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 32} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_RemovalPolicy, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 33} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_RemovalPolicyDefault, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 34} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_RemovalPolicyOverride, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 35} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_InstallState, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 36} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_LocationPaths, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 37} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_BaseContainerId, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 38} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_InstanceId, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 256} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DevNodeStatus, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ProblemCode, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_EjectionRelations, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 4} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_RemovalRelations, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 5} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_PowerRelations, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 6} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_BusRelations, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 7} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Parent, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 8} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Children, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 9} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Siblings, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 10} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_TransportRelations, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 11} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ProblemStatus, + 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 12} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Reported, + 0x80497100, 0x8c73, 0x48b9, 0xaa, 0xd9, 0xce, 0x38, 0x7e, 0x19, 0xc5, 0x6e, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Legacy, + 0x80497100, 0x8c73, 0x48b9, 0xaa, 0xd9, 0xce, 0x38, 0x7e, 0x19, 0xc5, 0x6e, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ContainerId, + 0x8c7ed206, 0x3f8a, 0x4827, 0xb3, 0xab, 0xae, 0x9e, 0x1f, 0xae, 0xfc, 0x6c, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_InLocalMachineContainer, + 0x8c7ed206, 0x3f8a, 0x4827, 0xb3, 0xab, 0xae, 0x9e, 0x1f, 0xae, 0xfc, 0x6c, 4} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Model, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 39} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ModelId, + 0x80d81ea6, 0x7473, 0x4b0c, 0x82, 0x16, 0xef, 0xc1, 0x1a, 0x2c, 0x4c, 0x8b, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_FriendlyNameAttributes, + 0x80d81ea6, 0x7473, 0x4b0c, 0x82, 0x16, 0xef, 0xc1, 0x1a, 0x2c, 0x4c, 0x8b, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ManufacturerAttributes, + 0x80d81ea6, 0x7473, 0x4b0c, 0x82, 0x16, 0xef, 0xc1, 0x1a, 0x2c, 0x4c, 0x8b, 4} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_PresenceNotForDevice, + 0x80d81ea6, 0x7473, 0x4b0c, 0x82, 0x16, 0xef, 0xc1, 0x1a, 0x2c, 0x4c, 0x8b, 5} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_SignalStrength, + 0x80d81ea6, 0x7473, 0x4b0c, 0x82, 0x16, 0xef, 0xc1, 0x1a, 0x2c, 0x4c, 0x8b, 6} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_IsAssociateableByUserAction, + 0x80d81ea6, 0x7473, 0x4b0c, 0x82, 0x16, 0xef, 0xc1, 0x1a, 0x2c, 0x4c, 0x8b, 7} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ShowInUninstallUI, + 0x80d81ea6, 0x7473, 0x4b0c, 0x82, 0x16, 0xef, 0xc1, 0x1a, 0x2c, 0x4c, 0x8b, 8} +pub const DEVPKEY_Numa_Proximity_Domain: DEVPROPKEY = DEVPKEY_Device_Numa_Proximity_Domain; +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Numa_Proximity_Domain, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 1} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DHP_Rebalance_Policy, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Numa_Node, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_BusReportedDeviceDesc, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 4} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_IsPresent, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 5} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_HasProblem, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 6} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ConfigurationId, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 7} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ReportedDeviceIdsHash, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 8} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_PhysicalDeviceLocation, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 9} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_BiosDeviceName, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 10} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverProblemDesc, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 11} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DebuggerSafe, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 12} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_PostInstallInProgress, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 13} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_Stack, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 14} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ExtendedConfigurationIds, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 15} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_IsRebootRequired, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 16} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_FirmwareDate, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 17} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_FirmwareVersion, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 18} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_FirmwareRevision, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 19} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DependencyProviders, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 20} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DependencyDependents, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 21} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_SoftRestartSupported, + 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 22} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_SessionId, + 0x83da6326, 0x97a6, 0x4088, 0x94, 0x53, 0xa1, 0x92, 0x3f, 0x57, 0x3b, 0x29, 6} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_InstallDate, + 0x83da6326, 0x97a6, 0x4088, 0x94, 0x53, 0xa1, 0x92, 0x3f, 0x57, 0x3b, 0x29, 100} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_FirstInstallDate, + 0x83da6326, 0x97a6, 0x4088, 0x94, 0x53, 0xa1, 0x92, 0x3f, 0x57, 0x3b, 0x29, 101} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_LastArrivalDate, + 0x83da6326, 0x97a6, 0x4088, 0x94, 0x53, 0xa1, 0x92, 0x3f, 0x57, 0x3b, 0x29, 102} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_LastRemovalDate, + 0x83da6326, 0x97a6, 0x4088, 0x94, 0x53, 0xa1, 0x92, 0x3f, 0x57, 0x3b, 0x29, 103} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverDate, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverVersion, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverDesc, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 4} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverInfPath, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 5} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverInfSection, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 6} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverInfSectionExt, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 7} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_MatchingDeviceId, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 8} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverProvider, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 9} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverPropPageProvider, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 10} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverCoInstallers, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 11} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ResourcePickerTags, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 12} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_ResourcePickerExceptions, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 13} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverRank, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 14} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_DriverLogoLevel, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 15} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_NoConnectSound, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 17} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_GenericDriverInstalled, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 18} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_AdditionalSoftwareRequested, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 19} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_SafeRemovalRequired, + 0xafd97640, 0x86a3, 0x4210, 0xb6, 0x7c, 0x28, 0x9c, 0x41, 0xaa, 0xbe, 0x55, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_Device_SafeRemovalRequiredOverride, + 0xafd97640, 0x86a3, 0x4210, 0xb6, 0x7c, 0x28, 0x9c, 0x41, 0xaa, 0xbe, 0x55, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_DrvPkg_Model, + 0xcf73bb51, 0x3abf, 0x44a2, 0x85, 0xe0, 0x9a, 0x3d, 0xc7, 0xa1, 0x21, 0x32, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_DrvPkg_VendorWebSite, + 0xcf73bb51, 0x3abf, 0x44a2, 0x85, 0xe0, 0x9a, 0x3d, 0xc7, 0xa1, 0x21, 0x32, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_DrvPkg_DetailedDescription, + 0xcf73bb51, 0x3abf, 0x44a2, 0x85, 0xe0, 0x9a, 0x3d, 0xc7, 0xa1, 0x21, 0x32, 4} +DEFINE_DEVPROPKEY!{DEVPKEY_DrvPkg_DocumentationLink, + 0xcf73bb51, 0x3abf, 0x44a2, 0x85, 0xe0, 0x9a, 0x3d, 0xc7, 0xa1, 0x21, 0x32, 5} +DEFINE_DEVPROPKEY!{DEVPKEY_DrvPkg_Icon, + 0xcf73bb51, 0x3abf, 0x44a2, 0x85, 0xe0, 0x9a, 0x3d, 0xc7, 0xa1, 0x21, 0x32, 6} +DEFINE_DEVPROPKEY!{DEVPKEY_DrvPkg_BrandingIcon, + 0xcf73bb51, 0x3abf, 0x44a2, 0x85, 0xe0, 0x9a, 0x3d, 0xc7, 0xa1, 0x21, 0x32, 7} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_UpperFilters, + 0x4321918b, 0xf69e, 0x470d, 0xa5, 0xde, 0x4d, 0x88, 0xc7, 0x5a, 0xd2, 0x4b, 19} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_LowerFilters, + 0x4321918b, 0xf69e, 0x470d, 0xa5, 0xde, 0x4d, 0x88, 0xc7, 0x5a, 0xd2, 0x4b, 20} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_Security, + 0x4321918b, 0xf69e, 0x470d, 0xa5, 0xde, 0x4d, 0x88, 0xc7, 0x5a, 0xd2, 0x4b, 25} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_SecuritySDS, + 0x4321918b, 0xf69e, 0x470d, 0xa5, 0xde, 0x4d, 0x88, 0xc7, 0x5a, 0xd2, 0x4b, 26} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_DevType, + 0x4321918b, 0xf69e, 0x470d, 0xa5, 0xde, 0x4d, 0x88, 0xc7, 0x5a, 0xd2, 0x4b, 27} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_Exclusive, + 0x4321918b, 0xf69e, 0x470d, 0xa5, 0xde, 0x4d, 0x88, 0xc7, 0x5a, 0xd2, 0x4b, 28} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_Characteristics, + 0x4321918b, 0xf69e, 0x470d, 0xa5, 0xde, 0x4d, 0x88, 0xc7, 0x5a, 0xd2, 0x4b, 29} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_Name, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_ClassName, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_Icon, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 4} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_ClassInstaller, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 5} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_PropPageProvider, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 6} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_NoInstallClass, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 7} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_NoDisplayClass, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 8} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_SilentInstall, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 9} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_NoUseClass, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 10} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_DefaultService, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 11} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_IconPath, + 0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66, 12} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_DHPRebalanceOptOut, + 0xd14d3ef3, 0x66cf, 0x4ba2, 0x9d, 0x38, 0x0d, 0xdb, 0x37, 0xab, 0x47, 0x01, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceClass_ClassCoInstallers, + 0x713d1703, 0xa2e2, 0x49f5, 0x92, 0x14, 0x56, 0x47, 0x2e, 0xf3, 0xda, 0x5c, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceInterface_FriendlyName, + 0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceInterface_Enabled, + 0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceInterface_ClassGuid, + 0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22, 4} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceInterface_ReferenceString, + 0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22, 5} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceInterface_Restricted, + 0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22, 6} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceInterfaceClass_DefaultInterface, + 0x14c83a99, 0x0b3f, 0x44b7, 0xbe, 0x4c, 0xa1, 0x78, 0xd3, 0x99, 0x05, 0x64, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceInterfaceClass_Name, + 0x14c83a99, 0x0b3f, 0x44b7, 0xbe, 0x4c, 0xa1, 0x78, 0xd3, 0x99, 0x05, 0x64, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_Address, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 51} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_DiscoveryMethod, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 52} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsEncrypted, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 53} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsAuthenticated, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 54} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsConnected, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 55} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsPaired, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 56} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_Icon, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 57} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_Version, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 65} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_Last_Seen, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 66} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_Last_Connected, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 67} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsShowInDisconnectedState, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 68} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsLocalMachine, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 70} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_MetadataPath, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 71} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsMetadataSearchInProgress, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 72} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_MetadataChecksum, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 73} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsNotInterestingForDisplay, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 74} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_LaunchDeviceStageOnDeviceConnect, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 76} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_LaunchDeviceStageFromExplorer, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 77} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_BaselineExperienceId, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 78} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsDeviceUniquelyIdentifiable, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 79} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_AssociationArray, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 80} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_DeviceDescription1, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 81} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_DeviceDescription2, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 82} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_HasProblem, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 83} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsSharedDevice, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 84} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsNetworkDevice, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 85} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsDefaultDevice, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 86} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_MetadataCabinet, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 87} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_RequiresPairingElevation, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 88} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_ExperienceId, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 89} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_Category, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 90} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_Category_Desc_Singular, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 91} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_Category_Desc_Plural, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 92} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_Category_Icon, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 93} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_CategoryGroup_Desc, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 94} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_CategoryGroup_Icon, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 95} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_PrimaryCategory, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 97} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_UnpairUninstall, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 98} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_RequiresUninstallElevation, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 99} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_DeviceFunctionSubRank, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 100} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_AlwaysShowDeviceAsConnected, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 101} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_ConfigFlags, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 105} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_PrivilegedPackageFamilyNames, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 106} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_CustomPrivilegedPackageFamilyNames, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 107} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_IsRebootRequired, + 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 108} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_FriendlyName, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 12288} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_Manufacturer, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 8192} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_ModelName, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 8194} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_ModelNumber, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 8195} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceContainer_InstallInProgress, + 0x83da6326, 0x97a6, 0x4088, 0x94, 0x53, 0xa1, 0x92, 0x3f, 0x57, 0x3b, 0x29, 9} +pub const DEVPKEY_DeviceDisplay_DiscoveryMethod: DEVPROPKEY + = DEVPKEY_DeviceContainer_DiscoveryMethod; +pub const DEVPKEY_DeviceDisplay_IsShowInDisconnectedState: DEVPROPKEY + = DEVPKEY_DeviceContainer_IsShowInDisconnectedState; +pub const DEVPKEY_DeviceDisplay_IsNotInterestingForDisplay: DEVPROPKEY + = DEVPKEY_DeviceContainer_IsNotInterestingForDisplay; +pub const DEVPKEY_DeviceDisplay_IsNetworkDevice: DEVPROPKEY + = DEVPKEY_DeviceContainer_IsNetworkDevice; +pub const DEVPKEY_DeviceDisplay_Category: DEVPROPKEY = DEVPKEY_DeviceContainer_Category; +pub const DEVPKEY_DeviceDisplay_UnpairUninstall: DEVPROPKEY + = DEVPKEY_DeviceContainer_UnpairUninstall; +pub const DEVPKEY_DeviceDisplay_RequiresUninstallElevation: DEVPROPKEY + = DEVPKEY_DeviceContainer_RequiresUninstallElevation; +pub const DEVPKEY_DeviceDisplay_AlwaysShowDeviceAsConnected: DEVPROPKEY + = DEVPKEY_DeviceContainer_AlwaysShowDeviceAsConnected; +DEFINE_DEVPROPKEY!{DEVPKEY_DevQuery_ObjectType, + 0x13673f42, 0xa3d6, 0x49f6, 0xb4, 0xda, 0xae, 0x46, 0xe0, 0xc5, 0x23, 0x7c, 2} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/devpropdef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/devpropdef.rs new file mode 100644 index 0000000..1e9388a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/devpropdef.rs @@ -0,0 +1,83 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Defines property types and keys for the Plug and Play Device Property API +use shared::guiddef::{GUID, IsEqualGUID}; +use shared::minwindef::ULONG; +use um::winnt::{CHAR, PCWSTR, PVOID}; +pub type DEVPROPTYPE = ULONG; +pub type PDEVPROPTYPE = *mut ULONG; +pub const DEVPROP_TYPEMOD_ARRAY: DEVPROPTYPE = 0x00001000; +pub const DEVPROP_TYPEMOD_LIST: DEVPROPTYPE = 0x00002000; +pub const DEVPROP_TYPE_EMPTY: DEVPROPTYPE = 0x00000000; +pub const DEVPROP_TYPE_NULL: DEVPROPTYPE = 0x00000001; +pub const DEVPROP_TYPE_SBYTE: DEVPROPTYPE = 0x00000002; +pub const DEVPROP_TYPE_BYTE: DEVPROPTYPE = 0x00000003; +pub const DEVPROP_TYPE_INT16: DEVPROPTYPE = 0x00000004; +pub const DEVPROP_TYPE_UINT16: DEVPROPTYPE = 0x00000005; +pub const DEVPROP_TYPE_INT32: DEVPROPTYPE = 0x00000006; +pub const DEVPROP_TYPE_UINT32: DEVPROPTYPE = 0x00000007; +pub const DEVPROP_TYPE_INT64: DEVPROPTYPE = 0x00000008; +pub const DEVPROP_TYPE_UINT64: DEVPROPTYPE = 0x00000009; +pub const DEVPROP_TYPE_FLOAT: DEVPROPTYPE = 0x0000000A; +pub const DEVPROP_TYPE_DOUBLE: DEVPROPTYPE = 0x0000000B; +pub const DEVPROP_TYPE_DECIMAL: DEVPROPTYPE = 0x0000000C; +pub const DEVPROP_TYPE_GUID: DEVPROPTYPE = 0x0000000D; +pub const DEVPROP_TYPE_CURRENCY: DEVPROPTYPE = 0x0000000E; +pub const DEVPROP_TYPE_DATE: DEVPROPTYPE = 0x0000000F; +pub const DEVPROP_TYPE_FILETIME: DEVPROPTYPE = 0x00000010; +pub const DEVPROP_TYPE_BOOLEAN: DEVPROPTYPE = 0x00000011; +pub const DEVPROP_TYPE_STRING: DEVPROPTYPE = 0x00000012; +pub const DEVPROP_TYPE_STRING_LIST: DEVPROPTYPE = DEVPROP_TYPE_STRING | DEVPROP_TYPEMOD_LIST; +pub const DEVPROP_TYPE_SECURITY_DESCRIPTOR: DEVPROPTYPE = 0x00000013; +pub const DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING: DEVPROPTYPE = 0x00000014; +pub const DEVPROP_TYPE_DEVPROPKEY: DEVPROPTYPE = 0x00000015; +pub const DEVPROP_TYPE_DEVPROPTYPE: DEVPROPTYPE = 0x00000016; +pub const DEVPROP_TYPE_BINARY: DEVPROPTYPE = DEVPROP_TYPE_BYTE | DEVPROP_TYPEMOD_ARRAY; +pub const DEVPROP_TYPE_ERROR: DEVPROPTYPE = 0x00000017; +pub const DEVPROP_TYPE_NTSTATUS: DEVPROPTYPE = 0x00000018; +pub const DEVPROP_TYPE_STRING_INDIRECT: DEVPROPTYPE = 0x00000019; +pub const MAX_DEVPROP_TYPE: DEVPROPTYPE = 0x00000019; +pub const MAX_DEVPROP_TYPEMOD: DEVPROPTYPE = 0x00002000; +pub const DEVPROP_MASK_TYPE: DEVPROPTYPE = 0x00000FFF; +pub const DEVPROP_MASK_TYPEMOD: DEVPROPTYPE = 0x0000F000; +pub type DEVPROP_BOOLEAN = CHAR; +pub type PDEVPROP_BOOLEAN = *mut CHAR; +pub const DEVPROP_TRUE: DEVPROP_BOOLEAN = -1; +pub const DEVPROP_FALSE: DEVPROP_BOOLEAN = 0; +pub type DEVPROPGUID = GUID; +pub type PDEVPROPGUID = *mut GUID; +pub type DEVPROPID = ULONG; +pub type PDEVPROPID = *mut ULONG; +STRUCT!{struct DEVPROPKEY { + fmtid: DEVPROPGUID, + pid: DEVPROPID, +}} +pub type PDEVPROPKEY = *mut DEVPROPKEY; +#[inline] +pub fn IsEqualDevPropKey(a: &DEVPROPKEY, b: &DEVPROPKEY) -> bool { + (a.pid == b.pid) && IsEqualGUID(&a.fmtid, &b.fmtid) +} +ENUM!{enum DEVPROPSTORE { + DEVPROP_STORE_SYSTEM, + DEVPROP_STORE_USER, +}} +pub type PDEVPROPSTORE = *mut DEVPROPSTORE; +STRUCT!{struct DEVPROPCOMPKEY { + Key: DEVPROPKEY, + Store: DEVPROPSTORE, + LocaleName: PCWSTR, +}} +pub type PDEVPROPCOMPKEY = *mut DEVPROPCOMPKEY; +// IsEqualLocaleName +// IsEqualDevPropCompKey +STRUCT!{struct DEVPROPERTY { + CompKey: DEVPROPCOMPKEY, + Type: DEVPROPTYPE, + BufferSize: ULONG, + Buffer: PVOID, +}} +pub type PDEVPROPERTY = *mut DEVPROPERTY; +pub const DEVPROPID_FIRST_USABLE: DEVPROPID = 2; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/dinputd.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dinputd.rs new file mode 100644 index 0000000..ceb9ffd --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dinputd.rs @@ -0,0 +1,21 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_IDirectInputEffectDriver, + 0x02538130, 0x898f, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{IID_IDirectInputJoyConfig, + 0x1de12ab1, 0xc9f5, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{IID_IDirectInputPIDDriver, + 0xeec6993a, 0xb3fd, 0x11d2, 0xa9, 0x16, 0x00, 0xc0, 0x4f, 0xb9, 0x86, 0x38} +DEFINE_GUID!{IID_IDirectInputJoyConfig8, + 0xeb0d7dfa, 0x1990, 0x4f27, 0xb4, 0xd6, 0xed, 0xf2, 0xee, 0xc4, 0xa4, 0x4c} +DEFINE_GUID!{GUID_KeyboardClass, + 0x4d36e96b, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_MediaClass, + 0x4d36e96c, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_MouseClass, + 0x4d36e96f, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18} +DEFINE_GUID!{GUID_HIDClass, + 0x745a17a0, 0x74d3, 0x11d0, 0xb6, 0xfe, 0x00, 0xa0, 0xc9, 0x0f, 0x57, 0xda} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi.rs new file mode 100644 index 0000000..0e87858 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi.rs @@ -0,0 +1,411 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dxgi.h +use ctypes::c_void; +use shared::basetsd::{SIZE_T, UINT64}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::dxgitype::{ + DXGI_GAMMA_CONTROL, DXGI_GAMMA_CONTROL_CAPABILITIES, DXGI_MODE_DESC, DXGI_MODE_ROTATION, + DXGI_SAMPLE_DESC, DXGI_USAGE, +}; +use shared::guiddef::{REFGUID, REFIID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, HMODULE, UINT}; +use shared::windef::{HDC, HMONITOR, HWND, RECT}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, INT, LARGE_INTEGER, LUID, WCHAR}; +STRUCT!{struct DXGI_FRAME_STATISTICS { + PresentCount: UINT, + PresentRefreshCount: UINT, + SyncRefreshCount: UINT, + SyncQPCTime: LARGE_INTEGER, + SyncGPUTime: LARGE_INTEGER, +}} +STRUCT!{struct DXGI_MAPPED_RECT { + Pitch: INT, + pBits: *mut BYTE, +}} +STRUCT!{struct DXGI_ADAPTER_DESC { + Description: [WCHAR; 128], + VendorId: UINT, + DeviceId: UINT, + SubSysId: UINT, + Revision: UINT, + DedicatedVideoMemory: SIZE_T, + DedicatedSystemMemory: SIZE_T, + SharedSystemMemory: SIZE_T, + AdapterLuid: LUID, +}} +STRUCT!{struct DXGI_OUTPUT_DESC { + DeviceName: [WCHAR; 32], + DesktopCoordinates: RECT, + AttachedToDesktop: BOOL, + Rotation: DXGI_MODE_ROTATION, + Monitor: HMONITOR, +}} +STRUCT!{struct DXGI_SHARED_RESOURCE { + Handle: HANDLE, +}} +pub const DXGI_RESOURCE_PRIORITY_MINIMUM: DWORD = 0x28000000; +pub const DXGI_RESOURCE_PRIORITY_LOW: DWORD = 0x50000000; +pub const DXGI_RESOURCE_PRIORITY_NORMAL: DWORD = 0x78000000; +pub const DXGI_RESOURCE_PRIORITY_HIGH: DWORD = 0xa0000000; +pub const DXGI_RESOURCE_PRIORITY_MAXIMUM: DWORD = 0xc8000000; +ENUM!{enum DXGI_RESIDENCY { + DXGI_RESIDENCY_FULLY_RESIDENT = 1, + DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2, + DXGI_RESIDENCY_EVICTED_TO_DISK = 3, +}} +STRUCT!{struct DXGI_SURFACE_DESC { + Width: UINT, + Height: UINT, + Format: DXGI_FORMAT, + SampleDesc: DXGI_SAMPLE_DESC, +}} +ENUM!{enum DXGI_SWAP_EFFECT { + DXGI_SWAP_EFFECT_DISCARD = 0, + DXGI_SWAP_EFFECT_SEQUENTIAL = 1, + DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL = 3, + DXGI_SWAP_EFFECT_FLIP_DISCARD = 4, +}} +ENUM!{enum DXGI_SWAP_CHAIN_FLAG { + DXGI_SWAP_CHAIN_FLAG_NONPREROTATED = 1, + DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH = 2, + DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE = 4, + DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT = 8, + DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER = 16, + DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY = 32, + DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT = 64, + DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER = 128, + DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO = 256, + DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO = 512, + DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED = 1024, + DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING = 2048, +}} +STRUCT!{struct DXGI_SWAP_CHAIN_DESC { + BufferDesc: DXGI_MODE_DESC, + SampleDesc: DXGI_SAMPLE_DESC, + BufferUsage: DXGI_USAGE, + BufferCount: UINT, + OutputWindow: HWND, + Windowed: BOOL, + SwapEffect: DXGI_SWAP_EFFECT, + Flags: UINT, +}} +RIDL!{#[uuid(0xaec22fb8, 0x76f3, 0x4639, 0x9b, 0xe0, 0x28, 0xeb, 0x43, 0xa6, 0x7a, 0x2e)] +interface IDXGIObject(IDXGIObjectVtbl): IUnknown(IUnknownVtbl) { + fn SetPrivateData( + Name: REFGUID, + DataSize: UINT, + pData: *const c_void, + ) -> HRESULT, + fn SetPrivateDataInterface( + Name: REFGUID, + pUnknown: *const IUnknown, + ) -> HRESULT, + fn GetPrivateData( + Name: REFGUID, + pDataSize: *mut UINT, + pData: *mut c_void, + ) -> HRESULT, + fn GetParent( + riid: REFIID, + ppParent: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3d3e0379, 0xf9de, 0x4d58, 0xbb, 0x6c, 0x18, 0xd6, 0x29, 0x92, 0xf1, 0xa6)] +interface IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl): IDXGIObject(IDXGIObjectVtbl) { + fn GetDevice( + riid: REFIID, + ppDevice: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x035f3ab4, 0x482e, 0x4e50, 0xb4, 0x1f, 0x8a, 0x7f, 0x8b, 0xd8, 0x96, 0x0b)] +interface IDXGIResource(IDXGIResourceVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { + fn GetSharedHandle( + pSharedHandle: *mut HANDLE, + ) -> HRESULT, + fn GetUsage( + pUsage: *mut DXGI_USAGE, + ) -> HRESULT, + fn SetEvictionPriority( + EvictionPriority: UINT, + ) -> HRESULT, + fn GetEvictionPriority( + pEvictionPriority: *mut UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9d8e1289, 0xd7b3, 0x465f, 0x81, 0x26, 0x25, 0x0e, 0x34, 0x9a, 0xf8, 0x5d)] +interface IDXGIKeyedMutex(IDXGIKeyedMutexVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { + fn AcquireSync( + Key: UINT64, + dwMilliseconds: DWORD, + ) -> HRESULT, + fn ReleaseSync( + Key: UINT64, + ) -> HRESULT, +}} +pub const DXGI_MAP_READ: UINT = 1; +pub const DXGI_MAP_WRITE: UINT = 2; +pub const DXGI_MAP_DISCARD: UINT = 4; +RIDL!{#[uuid(0xcafcb56c, 0x6ac3, 0x4889, 0xbf, 0x47, 0x9e, 0x23, 0xbb, 0xd2, 0x60, 0xec)] +interface IDXGISurface(IDXGISurfaceVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { + fn GetDesc( + pDesc: *mut DXGI_SURFACE_DESC, + ) -> HRESULT, + fn Map( + pLockedRect: *mut DXGI_MAPPED_RECT, + MapFlags: UINT, + ) -> HRESULT, + fn Unmap() -> HRESULT, +}} +RIDL!{#[uuid(0x4ae63092, 0x6327, 0x4c1b, 0x80, 0xae, 0xbf, 0xe1, 0x2e, 0xa3, 0x2b, 0x86)] +interface IDXGISurface1(IDXGISurface1Vtbl): IDXGISurface(IDXGISurfaceVtbl) { + fn GetDC( + Discard: BOOL, + phdc: *mut HDC, + ) -> HRESULT, + fn ReleaseDC( + pDirtyRect: *mut RECT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2411e7e1, 0x12ac, 0x4ccf, 0xbd, 0x14, 0x97, 0x98, 0xe8, 0x53, 0x4d, 0xc0)] +interface IDXGIAdapter(IDXGIAdapterVtbl): IDXGIObject(IDXGIObjectVtbl) { + fn EnumOutputs( + Output: UINT, + ppOutput: *mut *mut IDXGIOutput, + ) -> HRESULT, + fn GetDesc( + pDesc: *mut DXGI_ADAPTER_DESC, + ) -> HRESULT, + fn CheckInterfaceSupport( + InterfaceName: REFGUID, + pUMDVersion: *mut LARGE_INTEGER, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xae02eedb, 0xc735, 0x4690, 0x8d, 0x52, 0x5a, 0x8d, 0xc2, 0x02, 0x13, 0xaa)] +interface IDXGIOutput(IDXGIOutputVtbl): IDXGIObject(IDXGIObjectVtbl) { + fn GetDesc( + pDesc: *mut DXGI_OUTPUT_DESC, + ) -> HRESULT, + fn GetDisplayModeList( + EnumFormat: DXGI_FORMAT, + Flags: UINT, + pNumModes: *mut UINT, + pDesc: *mut DXGI_MODE_DESC, + ) -> HRESULT, + fn FindClosestMatchingMode( + pModeToMatch: *const DXGI_MODE_DESC, + pClosestMatch: *mut DXGI_MODE_DESC, + pConcernedDevice: *mut IUnknown, + ) -> HRESULT, + fn WaitForVBlank() -> HRESULT, + fn TakeOwnership( + pDevice: *mut IUnknown, + Exclusive: BOOL, + ) -> HRESULT, + fn ReleaseOwnership() -> (), + fn GetGammaControlCapabilities( + pGammaCaps: *mut DXGI_GAMMA_CONTROL_CAPABILITIES, + ) -> HRESULT, + fn SetGammaControl( + pArray: *const DXGI_GAMMA_CONTROL, + ) -> HRESULT, + fn GetGammaControl( + pArray: *mut DXGI_GAMMA_CONTROL, + ) -> HRESULT, + fn SetDisplaySurface( + pScanoutSurface: *mut IDXGISurface, + ) -> HRESULT, + fn GetDisplaySurfaceData( + pDestination: *mut IDXGISurface, + ) -> HRESULT, + fn GetFrameStatistics( + pStats: *mut DXGI_FRAME_STATISTICS, + ) -> HRESULT, +}} +pub const DXGI_MAX_SWAP_CHAIN_BUFFERS: DWORD = 16; +pub const DXGI_PRESENT_TEST: DWORD = 0x00000001; +pub const DXGI_PRESENT_DO_NOT_SEQUENCE: DWORD = 0x00000002; +pub const DXGI_PRESENT_RESTART: DWORD = 0x00000004; +pub const DXGI_PRESENT_DO_NOT_WAIT: DWORD = 0x00000008; +pub const DXGI_PRESENT_STEREO_PREFER_RIGHT: DWORD = 0x00000010; +pub const DXGI_PRESENT_STEREO_TEMPORARY_MONO: DWORD = 0x00000020; +pub const DXGI_PRESENT_RESTRICT_TO_OUTPUT: DWORD = 0x00000040; +pub const DXGI_PRESENT_USE_DURATION: DWORD = 0x00000100; +pub const DXGI_PRESENT_ALLOW_TEARING: DWORD = 0x00000200; +pub const DXGI_ENUM_MODES_INTERLACED: UINT = 1; +pub const DXGI_ENUM_MODES_SCALING: UINT = 2; +RIDL!{#[uuid(0x310d36a0, 0xd2e7, 0x4c0a, 0xaa, 0x04, 0x6a, 0x9d, 0x23, 0xb8, 0x88, 0x6a)] +interface IDXGISwapChain(IDXGISwapChainVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { + fn Present( + SyncInterval: UINT, + Flags: UINT, + ) -> HRESULT, + fn GetBuffer( + Buffer: UINT, + riid: REFIID, + ppSurface: *mut *mut c_void, + ) -> HRESULT, + fn SetFullscreenState( + Fullscreen: BOOL, + pTarget: *mut IDXGIOutput, + ) -> HRESULT, + fn GetFullscreenState( + pFullscreen: *mut BOOL, + ppTarget: *mut *mut IDXGIOutput, + ) -> HRESULT, + fn GetDesc( + pDesc: *mut DXGI_SWAP_CHAIN_DESC, + ) -> HRESULT, + fn ResizeBuffers( + BufferCount: UINT, + Width: UINT, + Height: UINT, + NewFormat: DXGI_FORMAT, + SwapChainFlags: UINT, + ) -> HRESULT, + fn ResizeTarget( + pNewTargetParameters: *const DXGI_MODE_DESC, + ) -> HRESULT, + fn GetContainingOutput( + ppOutput: *mut *mut IDXGIOutput, + ) -> HRESULT, + fn GetFrameStatistics( + pStats: *mut DXGI_FRAME_STATISTICS, + ) -> HRESULT, + fn GetLastPresentCount( + pLastPresentCount: *mut UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7b7166ec, 0x21c7, 0x44ae, 0xb2, 0x1a, 0xc9, 0xae, 0x32, 0x1a, 0xe3, 0x69)] +interface IDXGIFactory(IDXGIFactoryVtbl): IDXGIObject(IDXGIObjectVtbl) { + fn EnumAdapters( + Adapter: UINT, + ppAdapter: *mut *mut IDXGIAdapter, + ) -> HRESULT, + fn MakeWindowAssociation( + WindowHandle: HWND, + Flags: UINT, + ) -> HRESULT, + fn GetWindowAssociation( + pWindowHandle: *mut HWND, + ) -> HRESULT, + fn CreateSwapChain( + pDevice: *mut IUnknown, + pDesc: *mut DXGI_SWAP_CHAIN_DESC, + ppSwapChain: *mut *mut IDXGISwapChain, + ) -> HRESULT, + fn CreateSoftwareAdapter( + Module: HMODULE, + ppAdapter: *mut *mut IDXGIAdapter, + ) -> HRESULT, +}} +extern "system" { + pub fn CreateDXGIFactory( + riid: REFIID, + ppFactory: *mut *mut c_void, + ) -> HRESULT; + pub fn CreateDXGIFactory1( + riid: REFIID, + ppFactory: *mut *mut c_void, + ) -> HRESULT; +} +RIDL!{#[uuid(0x54ec77fa, 0x1377, 0x44e6, 0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c)] +interface IDXGIDevice(IDXGIDeviceVtbl): IDXGIObject(IDXGIObjectVtbl) { + fn GetAdapter( + pAdapter: *mut *mut IDXGIAdapter, + ) -> HRESULT, + fn CreateSurface( + pDesc: *const DXGI_SURFACE_DESC, + NumSurfaces: UINT, + Usage: DXGI_USAGE, + pSharedResource: *const DXGI_SHARED_RESOURCE, + ppSurface: *mut *mut IDXGISurface, + ) -> HRESULT, + fn QueryResourceResidency( + ppResources: *const *mut IUnknown, + pResidencyStatus: *mut DXGI_RESIDENCY, + NumResources: UINT, + ) -> HRESULT, + fn SetGPUThreadPriority( + Priority: INT, + ) -> HRESULT, + fn GetGPUThreadPriority( + pPriority: *mut INT, + ) -> HRESULT, +}} +ENUM!{enum DXGI_ADAPTER_FLAG { + DXGI_ADAPTER_FLAG_NONE, + DXGI_ADAPTER_FLAG_REMOTE, + DXGI_ADAPTER_FLAG_SOFTWARE, +}} +STRUCT!{struct DXGI_ADAPTER_DESC1 { + Description: [WCHAR; 128], + VendorId: UINT, + DeviceId: UINT, + SubSysId: UINT, + Revision: UINT, + DedicatedVideoMemory: SIZE_T, + DedicatedSystemMemory: SIZE_T, + SharedSystemMemory: SIZE_T, + AdapterLuid: LUID, + Flags: UINT, +}} +STRUCT!{struct DXGI_DISPLAY_COLOR_SPACE { + PrimaryCoordinates: [[FLOAT; 2]; 8], + WhitePoints: [[FLOAT; 2]; 16], +}} +RIDL!{#[uuid(0x770aae78, 0xf26f, 0x4dba, 0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87)] +interface IDXGIFactory1(IDXGIFactory1Vtbl): IDXGIFactory(IDXGIFactoryVtbl) { + fn EnumAdapters1( + Adapter: UINT, + ppAdapter: *mut *mut IDXGIAdapter1, + ) -> HRESULT, + fn IsCurrent() -> BOOL, +}} +RIDL!{#[uuid(0x29038f61, 0x3839, 0x4626, 0x91, 0xfd, 0x08, 0x68, 0x79, 0x01, 0x1a, 0x05)] +interface IDXGIAdapter1(IDXGIAdapter1Vtbl): IDXGIAdapter(IDXGIAdapterVtbl) { + fn GetDesc1( + pDesc: *mut DXGI_ADAPTER_DESC1, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x77db970f, 0x6276, 0x48ba, 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c)] +interface IDXGIDevice1(IDXGIDevice1Vtbl): IDXGIDevice(IDXGIDeviceVtbl) { + fn SetMaximumFrameLatency( + MaxLatency: UINT, + ) -> HRESULT, + fn GetMaximumFrameLatency( + pMaxLatency: *mut UINT, + ) -> HRESULT, +}} +DEFINE_GUID!{IID_IDXGIObject, + 0xaec22fb8, 0x76f3, 0x4639, 0x9b, 0xe0, 0x28, 0xeb, 0x43, 0xa6, 0x7a, 0x2e} +DEFINE_GUID!{IID_IDXGIDeviceSubObject, + 0x3d3e0379, 0xf9de, 0x4d58, 0xbb, 0x6c, 0x18, 0xd6, 0x29, 0x92, 0xf1, 0xa6} +DEFINE_GUID!{IID_IDXGIResource, + 0x035f3ab4, 0x482e, 0x4e50, 0xb4, 0x1f, 0x8a, 0x7f, 0x8b, 0xd8, 0x96, 0x0b} +DEFINE_GUID!{IID_IDXGIKeyedMutex, + 0x9d8e1289, 0xd7b3, 0x465f, 0x81, 0x26, 0x25, 0x0e, 0x34, 0x9a, 0xf8, 0x5d} +DEFINE_GUID!{IID_IDXGISurface, + 0xcafcb56c, 0x6ac3, 0x4889, 0xbf, 0x47, 0x9e, 0x23, 0xbb, 0xd2, 0x60, 0xec} +DEFINE_GUID!{IID_IDXGISurface1, + 0x4ae63092, 0x6327, 0x4c1b, 0x80, 0xae, 0xbf, 0xe1, 0x2e, 0xa3, 0x2b, 0x86} +DEFINE_GUID!{IID_IDXGIAdapter, + 0x2411e7e1, 0x12ac, 0x4ccf, 0xbd, 0x14, 0x97, 0x98, 0xe8, 0x53, 0x4d, 0xc0} +DEFINE_GUID!{IID_IDXGIOutput, + 0xae02eedb, 0xc735, 0x4690, 0x8d, 0x52, 0x5a, 0x8d, 0xc2, 0x02, 0x13, 0xaa} +DEFINE_GUID!{IID_IDXGISwapChain, + 0x310d36a0, 0xd2e7, 0x4c0a, 0xaa, 0x04, 0x6a, 0x9d, 0x23, 0xb8, 0x88, 0x6a} +DEFINE_GUID!{IID_IDXGIFactory, + 0x7b7166ec, 0x21c7, 0x44ae, 0xb2, 0x1a, 0xc9, 0xae, 0x32, 0x1a, 0xe3, 0x69} +DEFINE_GUID!{IID_IDXGIDevice, + 0x54ec77fa, 0x1377, 0x44e6, 0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c} +DEFINE_GUID!{IID_IDXGIFactory1, + 0x770aae78, 0xf26f, 0x4dba, 0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87} +DEFINE_GUID!{IID_IDXGIAdapter1, + 0x29038f61, 0x3839, 0x4626, 0x91, 0xfd, 0x08, 0x68, 0x79, 0x01, 0x1a, 0x05} +DEFINE_GUID!{IID_IDXGIDevice1, + 0x77db970f, 0x6276, 0x48ba, 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_2.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_2.rs new file mode 100644 index 0000000..941f15e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_2.rs @@ -0,0 +1,355 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dxgi1_2.h +use ctypes::c_void; +use shared::basetsd::SIZE_T; +use shared::dxgi::{ + DXGI_MAPPED_RECT, DXGI_SWAP_EFFECT, IDXGIAdapter1, IDXGIAdapter1Vtbl, IDXGIDevice1, + IDXGIDevice1Vtbl, IDXGIFactory1, IDXGIFactory1Vtbl, IDXGIObject, IDXGIObjectVtbl, IDXGIOutput, + IDXGIOutputVtbl, IDXGIResource, IDXGIResourceVtbl, IDXGISurface1, IDXGISurface1Vtbl, + IDXGISwapChain, IDXGISwapChainVtbl, +}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::dxgitype::{ + DXGI_MODE_DESC, DXGI_MODE_ROTATION, DXGI_MODE_SCALING, DXGI_MODE_SCANLINE_ORDER, DXGI_RATIONAL, + DXGI_RGBA, DXGI_SAMPLE_DESC, DXGI_USAGE, +}; +use shared::guiddef::REFGUID; +use shared::minwindef::{BOOL, DWORD, UINT}; +use shared::windef::{HWND, POINT, RECT}; +use um::minwinbase::SECURITY_ATTRIBUTES; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, LARGE_INTEGER, LPCWSTR, LUID, WCHAR}; +ENUM!{enum DXGI_ALPHA_MODE { + DXGI_ALPHA_MODE_UNSPECIFIED = 0, + DXGI_ALPHA_MODE_PREMULTIPLIED = 1, + DXGI_ALPHA_MODE_STRAIGHT = 2, + DXGI_ALPHA_MODE_IGNORE = 3, + DXGI_ALPHA_MODE_FORCE_DWORD = 0xFFFFFFFF, +}} +ENUM!{enum DXGI_COMPUTE_PREEMPTION_GRANULARITY { + DXGI_COMPUTE_PREEMPTION_DMA_BUFFER_BOUNDARY = 0, + DXGI_COMPUTE_PREEMPTION_DISPATCH_BOUNDARY = 1, + DXGI_COMPUTE_PREEMPTION_THREAD_GROUP_BOUNDARY = 2, + DXGI_COMPUTE_PREEMPTION_THREAD_BOUNDARY = 3, + DXGI_COMPUTE_PREEMPTION_INSTRUCTION_BOUNDARY = 4, +}} +ENUM!{enum DXGI_GRAPHICS_PREEMPTION_GRANULARITY { + DXGI_GRAPHICS_PREEMPTION_DMA_BUFFER_BOUNDARY = 0, + DXGI_GRAPHICS_PREEMPTION_PRIMITIVE_BOUNDARY = 1, + DXGI_GRAPHICS_PREEMPTION_TRIANGLE_BOUNDARY = 2, + DXGI_GRAPHICS_PREEMPTION_PIXEL_BOUNDARY = 3, + DXGI_GRAPHICS_PREEMPTION_INSTRUCTION_BOUNDARY = 4, +}} +ENUM!{enum DXGI_OUTDUPL_POINTER_SHAPE_TYPE { + DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MONOCHROME = 1, + DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR = 2, + DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR = 4, +}} +ENUM!{enum DXGI_SCALING { + DXGI_SCALING_STRETCH = 0, + DXGI_SCALING_NONE = 1, + DXGI_SCALING_ASPECT_RATIO_STRETCH = 2, +}} +ENUM!{enum _DXGI_OFFER_RESOURCE_PRIORITY { + DXGI_OFFER_RESOURCE_PRIORITY_LOW = 1, + DXGI_OFFER_RESOURCE_PRIORITY_NORMAL = 2, + DXGI_OFFER_RESOURCE_PRIORITY_HIGH = 3, +}} +STRUCT!{struct DXGI_ADAPTER_DESC2 { + Description: [WCHAR; 128], + VendorId: UINT, + DeviceId: UINT, + SubSysId: UINT, + Revision: UINT, + DedicatedVideoMemory: SIZE_T, + DedicatedSystemMemory: SIZE_T, + SharedSystemMemory: SIZE_T, + AdapterLuid: LUID, + Flags: UINT, + GraphicsPreemptionGranularity: DXGI_GRAPHICS_PREEMPTION_GRANULARITY, + ComputePreemptionGranularity: DXGI_COMPUTE_PREEMPTION_GRANULARITY, +}} +STRUCT!{struct DXGI_MODE_DESC1 { + Width: UINT, + Height: UINT, + RefreshRate: DXGI_RATIONAL, + Format: DXGI_FORMAT, + ScanlineOrdering: DXGI_MODE_SCANLINE_ORDER, + Scaling: DXGI_MODE_SCALING, + Stereo: BOOL, +}} +STRUCT!{struct DXGI_OUTDUPL_DESC { + ModeDesc: DXGI_MODE_DESC, + Rotation: DXGI_MODE_ROTATION, + DesktopImageInSystemMemory: BOOL, +}} +STRUCT!{struct DXGI_OUTDUPL_FRAME_INFO { + LastPresentTime: LARGE_INTEGER, + LastMouseUpdateTime: LARGE_INTEGER, + AccumulatedFrames: UINT, + RectsCoalesced: BOOL, + ProtectedContentMaskedOut: BOOL, + PointerPosition: DXGI_OUTDUPL_POINTER_POSITION, + TotalMetadataBufferSize: UINT, + PointerShapeBufferSize: UINT, +}} +STRUCT!{struct DXGI_OUTDUPL_MOVE_RECT { + SourcePoint: POINT, + DestinationRect: RECT, +}} +STRUCT!{struct DXGI_OUTDUPL_POINTER_POSITION { + Position: POINT, + Visible: BOOL, +}} +STRUCT!{struct DXGI_OUTDUPL_POINTER_SHAPE_INFO { + Type: UINT, + Width: UINT, + Height: UINT, + Pitch: UINT, + HotSpot: POINT, +}} +STRUCT!{struct DXGI_PRESENT_PARAMETERS { + DirtyRectsCount: UINT, + pDirtyRects: *mut RECT, + pScrollRect: *mut RECT, + pScrollOffset: *mut POINT, +}} +STRUCT!{struct DXGI_SWAP_CHAIN_DESC1 { + Width: UINT, + Height: UINT, + Format: DXGI_FORMAT, + Stereo: BOOL, + SampleDesc: DXGI_SAMPLE_DESC, + BufferUsage: DXGI_USAGE, + BufferCount: UINT, + Scaling: DXGI_SCALING, + SwapEffect: DXGI_SWAP_EFFECT, + AlphaMode: DXGI_ALPHA_MODE, + Flags: UINT, +}} +STRUCT!{struct DXGI_SWAP_CHAIN_FULLSCREEN_DESC { + RefreshRate: DXGI_RATIONAL, + ScanlineOrdering: DXGI_MODE_SCANLINE_ORDER, + Scaling: DXGI_MODE_SCALING, + Windowed: BOOL, +}} +RIDL!{#[uuid(0x0aa1ae0a, 0xfa0e, 0x4b84, 0x86, 0x44, 0xe0, 0x5f, 0xf8, 0xe5, 0xac, 0xb5)] +interface IDXGIAdapter2(IDXGIAdapter2Vtbl): IDXGIAdapter1(IDXGIAdapter1Vtbl) { + fn GetDesc2( + pDesc: *mut DXGI_ADAPTER_DESC2, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x05008617, 0xfbfd, 0x4051, 0xa7, 0x90, 0x14, 0x48, 0x84, 0xb4, 0xf6, 0xa9)] +interface IDXGIDevice2(IDXGIDevice2Vtbl): IDXGIDevice1(IDXGIDevice1Vtbl) { + fn OfferResources( + NumResources: UINT, + ppResources: *mut *mut IDXGIResource, + Priority: DXGI_OFFER_RESOURCE_PRIORITY, + ) -> HRESULT, + fn ReclaimResources( + NumResources: UINT, + ppResources: *mut *mut IDXGIResource, + pDiscarded: *mut BOOL, + ) -> HRESULT, + fn EnqueueSetEvent( + hEvent: HANDLE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xea9dbf1a, 0xc88e, 0x4486, 0x85, 0x4a, 0x98, 0xaa, 0x01, 0x38, 0xf3, 0x0c)] +interface IDXGIDisplayControl(IDXGIDisplayControlVtbl): IUnknown(IUnknownVtbl) { + fn IsStereoEnabled() -> BOOL, + fn SetStereoEnabled( + enabled: BOOL, + ) -> (), +}} +RIDL!{#[uuid(0x50c83a1c, 0xe072, 0x4c48, 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0)] +interface IDXGIFactory2(IDXGIFactory2Vtbl): IDXGIFactory1(IDXGIFactory1Vtbl) { + fn IsWindowedStereoEnabled() -> BOOL, + fn CreateSwapChainForHwnd( + pDevice: *mut IUnknown, + hWnd: HWND, + pDesc: *const DXGI_SWAP_CHAIN_DESC1, + pFullscreenDesc: *const DXGI_SWAP_CHAIN_FULLSCREEN_DESC, + pRestrictToOutput: *mut IDXGIOutput, + ppSwapChain: *mut *mut IDXGISwapChain1, + ) -> HRESULT, + fn CreateSwapChainForCoreWindow( + pDevice: *mut IUnknown, + pWindow: *mut IUnknown, + pDesc: *const DXGI_SWAP_CHAIN_DESC1, + pRestrictToOutput: *mut IDXGIOutput, + ppSwapChain: *mut *mut IDXGISwapChain1, + ) -> HRESULT, + fn GetSharedResourceAdapterLuid( + hResource: HANDLE, + pLuid: *mut LUID, + ) -> HRESULT, + fn RegisterStereoStatusWindow( + WindowHandle: HWND, + wMsg: UINT, + pdwCookie: *mut DWORD, + ) -> HRESULT, + fn RegisterStereoStatusEvent( + hEvent: HANDLE, + pdwCookie: *mut DWORD, + ) -> HRESULT, + fn UnregisterStereoStatus( + dwCookie: DWORD, + ) -> (), + fn RegisterOcclusionStatusWindow( + WindowHandle: HWND, + wMsg: UINT, + pdwCookie: *mut DWORD, + ) -> HRESULT, + fn RegisterOcclusionStatusEvent( + hEvent: HANDLE, + pdwCookie: *mut DWORD, + ) -> HRESULT, + fn UnregisterOcclusionStatus( + dwCookie: DWORD, + ) -> (), + fn CreateSwapChainForComposition( + pDevice: *mut IUnknown, + pDesc: *const DXGI_SWAP_CHAIN_DESC1, + pRestrictToOutput: *mut IDXGIOutput, + ppSwapChain: *mut *mut IDXGISwapChain1, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00cddea8, 0x939b, 0x4b83, 0xa3, 0x40, 0xa6, 0x85, 0x22, 0x66, 0x66, 0xcc)] +interface IDXGIOutput1(IDXGIOutput1Vtbl): IDXGIOutput(IDXGIOutputVtbl) { + fn GetDisplayModeList1( + EnumFormat: DXGI_FORMAT, + Flags: UINT, + pNumModes: *mut UINT, + pDesc: *mut DXGI_MODE_DESC1, + ) -> HRESULT, + fn FindClosestMatchingMode1( + pModeToMatch: *const DXGI_MODE_DESC1, + pClosestMatch: *mut DXGI_MODE_DESC1, + pConcernedDevice: *mut IUnknown, + ) -> HRESULT, + fn GetDisplaySurfaceData1( + pDestination: *mut IDXGIResource, + ) -> HRESULT, + fn DuplicateOutput( + pDevice: *mut IUnknown, + ppOutputDuplication: *mut *mut IDXGIOutputDuplication, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x191cfac3, 0xa341, 0x470d, 0xb2, 0x6e, 0xa8, 0x64, 0xf4, 0x28, 0x31, 0x9c)] +interface IDXGIOutputDuplication(IDXGIOutputDuplicationVtbl): IDXGIObject(IDXGIObjectVtbl) { + fn GetDesc( + pDesc: *mut DXGI_OUTDUPL_DESC, + ) -> (), + fn AcquireNextFrame( + TimeoutInMilliseconds: UINT, + pFrameInfo: *mut DXGI_OUTDUPL_FRAME_INFO, + ppDesktopResource: *mut *mut IDXGIResource, + ) -> HRESULT, + fn GetFrameDirtyRects( + DirtyRectsBufferSize: UINT, + pDirtyRectsBuffer: *mut RECT, + pDirtyRectsBufferSizeRequired: *mut UINT, + ) -> HRESULT, + fn GetFrameMoveRects( + MoveRectsBufferSize: UINT, + pMoveRectBuffer: *mut DXGI_OUTDUPL_MOVE_RECT, + pMoveRectsBufferSizeRequired: *mut UINT, + ) -> HRESULT, + fn GetFramePointerShape( + PointerShapeBufferSize: UINT, + pPointerShapeBuffer: *mut c_void, + pPointerShapeBufferSizeRequired: *mut UINT, + pPointerShapeInfo: *mut DXGI_OUTDUPL_POINTER_SHAPE_INFO, + ) -> HRESULT, + fn MapDesktopSurface( + pLockedRect: *mut DXGI_MAPPED_RECT, + ) -> HRESULT, + fn UnMapDesktopSurface() -> HRESULT, + fn ReleaseFrame() -> HRESULT, +}} +RIDL!{#[uuid(0x30961379, 0x4609, 0x4a41, 0x99, 0x8e, 0x54, 0xfe, 0x56, 0x7e, 0xe0, 0xc1)] +interface IDXGIResource1(IDXGIResource1Vtbl): IDXGIResource(IDXGIResourceVtbl) { + fn CreateSubresourceSurface( + index: UINT, + ppSurface: *mut *mut IDXGISurface2, + ) -> HRESULT, + fn CreateSharedHandle( + pAttributes: *const SECURITY_ATTRIBUTES, + dwAccess: DWORD, + lpName: LPCWSTR, + pHandle: *mut HANDLE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xaba496dd, 0xb617, 0x4cb8, 0xa8, 0x66, 0xbc, 0x44, 0xd7, 0xeb, 0x1f, 0xa2)] +interface IDXGISurface2(IDXGISurface2Vtbl): IDXGISurface1(IDXGISurface1Vtbl) { + fn GetResource( + riid: REFGUID, + ppParentResource: *mut *mut c_void, + pSubresourceIndex: *mut UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x790a45f7, 0x0d42, 0x4876, 0x98, 0x3a, 0x0a, 0x55, 0xcf, 0xe6, 0xf4, 0xaa)] +interface IDXGISwapChain1(IDXGISwapChain1Vtbl): IDXGISwapChain(IDXGISwapChainVtbl) { + fn GetDesc1( + pDesc: *mut DXGI_SWAP_CHAIN_DESC1, + ) -> HRESULT, + fn GetFullscreenDesc( + pDesc: *mut DXGI_SWAP_CHAIN_FULLSCREEN_DESC, + ) -> HRESULT, + fn GetHwnd( + pHwnd: *mut HWND, + ) -> HRESULT, + fn GetCoreWindow( + refiid: REFGUID, + ppUnk: *mut *mut c_void, + ) -> HRESULT, + fn Present1( + SyncInterval: UINT, + PresentFlags: UINT, + pPresentParameters: *const DXGI_PRESENT_PARAMETERS, + ) -> HRESULT, + fn IsTemporaryMonoSupported() -> BOOL, + fn GetRestrictToOutput( + ppRestrictToOutput: *mut *mut IDXGIOutput, + ) -> HRESULT, + fn SetBackgroundColor( + pColor: *const DXGI_RGBA, + ) -> HRESULT, + fn GetBackgroundColor( + pColor: *mut DXGI_RGBA, + ) -> HRESULT, + fn SetRotation( + Rotation: DXGI_MODE_ROTATION, + ) -> HRESULT, + fn GetRotation( + pRotation: *mut DXGI_MODE_ROTATION, + ) -> HRESULT, +}} +pub type DXGI_OFFER_RESOURCE_PRIORITY = _DXGI_OFFER_RESOURCE_PRIORITY; +pub const DXGI_ENUM_MODES_DISABLED_STEREO: UINT = 8; +pub const DXGI_ENUM_MODES_STEREO: UINT = 4; +pub const DXGI_SHARED_RESOURCE_READ: UINT = 0x80000000; +pub const DXGI_SHARED_RESOURCE_WRITE: UINT = 1; +DEFINE_GUID!{IID_IDXGIDisplayControl, + 0xea9dbf1a, 0xc88e, 0x4486, 0x85, 0x4a, 0x98, 0xaa, 0x01, 0x38, 0xf3, 0x0c} +DEFINE_GUID!{IID_IDXGIOutputDuplication, + 0x191cfac3, 0xa341, 0x470d, 0xb2, 0x6e, 0xa8, 0x64, 0xf4, 0x28, 0x31, 0x9c} +DEFINE_GUID!{IID_IDXGISurface2, + 0xaba496dd, 0xb617, 0x4cb8, 0xa8, 0x66, 0xbc, 0x44, 0xd7, 0xeb, 0x1f, 0xa2} +DEFINE_GUID!{IID_IDXGIResource1, + 0x30961379, 0x4609, 0x4a41, 0x99, 0x8e, 0x54, 0xfe, 0x56, 0x7e, 0xe0, 0xc1} +DEFINE_GUID!{IID_IDXGIDevice2, + 0x05008617, 0xfbfd, 0x4051, 0xa7, 0x90, 0x14, 0x48, 0x84, 0xb4, 0xf6, 0xa9} +DEFINE_GUID!{IID_IDXGISwapChain1, + 0x790a45f7, 0x0d42, 0x4876, 0x98, 0x3a, 0x0a, 0x55, 0xcf, 0xe6, 0xf4, 0xaa} +DEFINE_GUID!{IID_IDXGIFactory2, + 0x50c83a1c, 0xe072, 0x4c48, 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0} +DEFINE_GUID!{IID_IDXGIAdapter2, + 0x0aa1ae0a, 0xfa0e, 0x4b84, 0x86, 0x44, 0xe0, 0x5f, 0xf8, 0xe5, 0xac, 0xb5} +DEFINE_GUID!{IID_IDXGIOutput1, + 0x00cddea8, 0x939b, 0x4b83, 0xa3, 0x40, 0xa6, 0x85, 0x22, 0x66, 0x66, 0xcc} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_3.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_3.rs new file mode 100644 index 0000000..caf346a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_3.rs @@ -0,0 +1,190 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dxgi1_3.h +use ctypes::c_void; +use shared::dxgi::{IDXGIOutput, IDXGIResource}; +use shared::dxgi1_2::{ + DXGI_SWAP_CHAIN_DESC1, IDXGIDevice2, IDXGIDevice2Vtbl, IDXGIFactory2, IDXGIFactory2Vtbl, + IDXGIOutput1, IDXGIOutput1Vtbl, IDXGISwapChain1, IDXGISwapChain1Vtbl, +}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::guiddef::REFIID; +use shared::minwindef::{BOOL, FLOAT, UINT}; +use shared::windef::RECT; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, LARGE_INTEGER}; +ENUM!{enum DXGI_FRAME_PRESENTATION_MODE { + DXGI_FRAME_PRESENTATION_MODE_COMPOSED = 0, + DXGI_FRAME_PRESENTATION_MODE_OVERLAY = 1, + DXGI_FRAME_PRESENTATION_MODE_NONE = 2, + DXGI_FRAME_PRESENTATION_MODE_COMPOSITION_FAILURE = 3, +}} +ENUM!{enum DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS { + DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_NOMINAL_RANGE = 0x1, + DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_BT709 = 0x2, + DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_xvYCC = 0x4, +}} +ENUM!{enum DXGI_OVERLAY_SUPPORT_FLAG { + DXGI_OVERLAY_SUPPORT_FLAG_DIRECT = 0x1, + DXGI_OVERLAY_SUPPORT_FLAG_SCALING = 0x2, +}} +STRUCT!{struct DXGI_DECODE_SWAP_CHAIN_DESC { + Flags: UINT, +}} +STRUCT!{struct DXGI_FRAME_STATISTICS_MEDIA { + PresentCount: UINT, + PresentRefreshCount: UINT, + SyncRefreshCount: UINT, + SyncQPCTime: LARGE_INTEGER, + SyncGPUTime: LARGE_INTEGER, + CompositionMode: DXGI_FRAME_PRESENTATION_MODE, + ApprovedPresentDuration: UINT, +}} +STRUCT!{struct DXGI_MATRIX_3X2_F { + _11: FLOAT, + _12: FLOAT, + _21: FLOAT, + _22: FLOAT, + _31: FLOAT, + _32: FLOAT, +}} +RIDL!{#[uuid(0x2633066b, 0x4514, 0x4c7a, 0x8f, 0xd8, 0x12, 0xea, 0x98, 0x05, 0x9d, 0x18)] +interface IDXGIDecodeSwapChain(IDXGIDecodeSwapChainVtbl): IUnknown(IUnknownVtbl) { + fn PresentBuffer( + BufferToPresent: UINT, + SyncInterval: UINT, + Flags: UINT, + ) -> HRESULT, + fn SetSourceRect( + pRect: *const RECT, + ) -> HRESULT, + fn SetTargetRect( + pRect: *const RECT, + ) -> HRESULT, + fn SetDestSize( + Width: UINT, + Height: UINT, + ) -> HRESULT, + fn GetSourceRect( + pRect: *mut RECT, + ) -> HRESULT, + fn GetTargetRect( + pRect: *mut RECT, + ) -> HRESULT, + fn GetDestSize( + pWidth: *mut UINT, + pHeight: *mut UINT, + ) -> HRESULT, + fn SetColorSpace( + ColorSpace: DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS, + ) -> HRESULT, + fn GetColorSpace() -> DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS, +}} +extern "system" { + pub fn CreateDXGIFactory2( + Flags: UINT, + riid: REFIID, + ppFactory: *mut *mut c_void, + ) -> HRESULT; + pub fn DXGIGetDebugInterface1( + Flags: UINT, + riid: REFIID, + pDebug: *mut *mut c_void, + ) -> HRESULT; +} +RIDL!{#[uuid(0x6007896c, 0x3244, 0x4afd, 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23)] +interface IDXGIDevice3(IDXGIDevice3Vtbl): IDXGIDevice2(IDXGIDevice2Vtbl) { + fn Trim() -> (), +}} +RIDL!{#[uuid(0x25483823, 0xcd46, 0x4c7d, 0x86, 0xca, 0x47, 0xaa, 0x95, 0xb8, 0x37, 0xbd)] +interface IDXGIFactory3(IDXGIFactory3Vtbl): IDXGIFactory2(IDXGIFactory2Vtbl) { + fn GetCreationFlags() -> UINT, +}} +RIDL!{#[uuid(0x41e7d1f2, 0xa591, 0x4f7b, 0xa2, 0xe5, 0xfa, 0x9c, 0x84, 0x3e, 0x1c, 0x12)] +interface IDXGIFactoryMedia(IDXGIFactoryMediaVtbl): IUnknown(IUnknownVtbl) { + fn CreateSwapChainForCompositionSurfaceHandle( + pDevice: *mut IUnknown, + hSurface: HANDLE, + pDesc: *const DXGI_SWAP_CHAIN_DESC1, + pRestrictToOutput: *mut IDXGIOutput, + ppSwapChain: *mut *mut IDXGISwapChain1, + ) -> HRESULT, + fn CreateDecodeSwapChainForCompositionSurfaceHandle( + pDevice: *mut IUnknown, + hSurface: HANDLE, + pDesc: *mut DXGI_DECODE_SWAP_CHAIN_DESC, + pYuvDecodeBuffers: *mut IDXGIResource, + pRestrictToOutput: *mut IDXGIOutput, + ppSwapChain: *mut *mut IDXGIDecodeSwapChain, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x595e39d1, 0x2724, 0x4663, 0x99, 0xb1, 0xda, 0x96, 0x9d, 0xe2, 0x83, 0x64)] +interface IDXGIOutput2(IDXGIOutput2Vtbl): IDXGIOutput1(IDXGIOutput1Vtbl) { + fn SupportsOverlays() -> BOOL, +}} +RIDL!{#[uuid(0x8a6bb301, 0x7e7e, 0x41f4, 0xa8, 0xe0, 0x5b, 0x32, 0xf7, 0xf9, 0x9b, 0x18)] +interface IDXGIOutput3(IDXGIOutput3Vtbl): IDXGIOutput2(IDXGIOutput2Vtbl) { + fn CheckOverlaySupport( + EnumFormat: DXGI_FORMAT, + pConcernedDevice: *mut IUnknown, + pFlags: *mut UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa8be2ac4, 0x199f, 0x4946, 0xb3, 0x31, 0x79, 0x59, 0x9f, 0xb9, 0x8d, 0xe7)] +interface IDXGISwapChain2(IDXGISwapChain2Vtbl): IDXGISwapChain1(IDXGISwapChain1Vtbl) { + fn SetSourceSize( + Width: UINT, + Height: UINT, + ) -> HRESULT, + fn GetSourceSize( + pWidth: *mut UINT, + pHeight: *mut UINT, + ) -> HRESULT, + fn SetMaximumFrameLatency( + MaxLatency: UINT, + ) -> HRESULT, + fn GetMaximumFrameLatency( + pMaxLatency: *mut UINT, + ) -> HRESULT, + fn GetFrameLatencyWaitableObject() -> HANDLE, + fn SetMatrixTransform( + pMatrix: *const DXGI_MATRIX_3X2_F, + ) -> HRESULT, + fn GetMatrixTransform( + pMatrix: *mut DXGI_MATRIX_3X2_F, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdd95b90b, 0xf05f, 0x4f6a, 0xbd, 0x65, 0x25, 0xbf, 0xb2, 0x64, 0xbd, 0x84)] +interface IDXGISwapChainMedia(IDXGISwapChainMediaVtbl): IUnknown(IUnknownVtbl) { + fn GetFrameStatisticsMedia( + pStats: *mut DXGI_FRAME_STATISTICS_MEDIA, + ) -> HRESULT, + fn SetPresentDuration( + Duration: UINT, + ) -> HRESULT, + fn CheckPresentDurationSupport( + DesiredPresentDuration: UINT, + pClosestSmallerPresentDuration: *mut UINT, + pClosestLargerPresentDuration: *mut UINT, + ) -> HRESULT, +}} +pub const DXGI_CREATE_FACTORY_DEBUG: UINT = 0x1; +DEFINE_GUID!{IID_IDXGIDevice3, + 0x6007896c, 0x3244, 0x4afd, 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23} +DEFINE_GUID!{IID_IDXGISwapChain2, + 0xa8be2ac4, 0x199f, 0x4946, 0xb3, 0x31, 0x79, 0x59, 0x9f, 0xb9, 0x8d, 0xe7} +DEFINE_GUID!{IID_IDXGIOutput2, + 0x595e39d1, 0x2724, 0x4663, 0x99, 0xb1, 0xda, 0x96, 0x9d, 0xe2, 0x83, 0x64} +DEFINE_GUID!{IID_IDXGIFactory3, + 0x25483823, 0xcd46, 0x4c7d, 0x86, 0xca, 0x47, 0xaa, 0x95, 0xb8, 0x37, 0xbd} +DEFINE_GUID!{IID_IDXGIDecodeSwapChain, + 0x2633066b, 0x4514, 0x4c7a, 0x8f, 0xd8, 0x12, 0xea, 0x98, 0x05, 0x9d, 0x18} +DEFINE_GUID!{IID_IDXGIFactoryMedia, + 0x41e7d1f2, 0xa591, 0x4f7b, 0xa2, 0xe5, 0xfa, 0x9c, 0x84, 0x3e, 0x1c, 0x12} +DEFINE_GUID!{IID_IDXGISwapChainMedia, + 0xdd95b90b, 0xf05f, 0x4f6a, 0xbd, 0x65, 0x25, 0xbf, 0xb2, 0x64, 0xbd, 0x84} +DEFINE_GUID!{IID_IDXGIOutput3, + 0x8a6bb301, 0x7e7e, 0x41f4, 0xa8, 0xe0, 0x5b, 0x32, 0xf7, 0xf9, 0x9b, 0x18} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_4.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_4.rs new file mode 100644 index 0000000..53269e8 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_4.rs @@ -0,0 +1,112 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dxgi1_4.h +use ctypes::c_void; +use shared::basetsd::UINT64; +use shared::dxgi1_2::{IDXGIAdapter2, IDXGIAdapter2Vtbl}; +use shared::dxgi1_3::{ + IDXGIFactory3, IDXGIFactory3Vtbl, IDXGIOutput3, IDXGIOutput3Vtbl, IDXGISwapChain2, + IDXGISwapChain2Vtbl, +}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::dxgitype::DXGI_COLOR_SPACE_TYPE; +use shared::guiddef::REFGUID; +use shared::minwindef::{DWORD, UINT}; +use um::unknwnbase::IUnknown; +use um::winnt::{HANDLE, HRESULT, LUID}; +ENUM!{enum DXGI_MEMORY_SEGMENT_GROUP { + DXGI_MEMORY_SEGMENT_GROUP_LOCAL = 0, + DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL = 1, +}} +ENUM!{enum DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG { + DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG_PRESENT = 0x1, +}} +ENUM!{enum DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG { + DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT = 0x1, + DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_OVERLAY_PRESENT = 0x2, +}} +STRUCT!{struct DXGI_QUERY_VIDEO_MEMORY_INFO { + Budget: UINT64, + CurrentUsage: UINT64, + AvailableForReservation: UINT64, + CurrentReservation: UINT64, +}} +RIDL!{#[uuid(0x645967a4, 0x1392, 0x4310, 0xa7, 0x98, 0x80, 0x53, 0xce, 0x3e, 0x93, 0xfd)] +interface IDXGIAdapter3(IDXGIAdapter3Vtbl): IDXGIAdapter2(IDXGIAdapter2Vtbl) { + fn RegisterHardwareContentProtectionTeardownStatusEvent( + hEvent: HANDLE, + pdwCookie: *mut DWORD, + ) -> HRESULT, + fn UnregisterHardwareContentProtectionTeardownStatus( + dwCookie: DWORD, + ) -> (), + fn QueryVideoMemoryInfo( + NodeIndex: UINT, + MemorySegmentGroup: DXGI_MEMORY_SEGMENT_GROUP, + pVideoMemoryInfo: *mut DXGI_QUERY_VIDEO_MEMORY_INFO, + ) -> HRESULT, + fn SetVideoMemoryReservation( + NodeIndex: UINT, + MemorySegmentGroup: DXGI_MEMORY_SEGMENT_GROUP, + Reservation: UINT64, + ) -> HRESULT, + fn RegisterVideoMemoryBudgetChangeNotificationEvent( + hEvent: HANDLE, + pdwCookie: *mut DWORD, + ) -> HRESULT, + fn UnregisterVideoMemoryBudgetChangeNotification( + dwCookie: DWORD, + ) -> (), +}} +RIDL!{#[uuid(0x1bc6ea02, 0xef36, 0x464f, 0xbf, 0x0c, 0x21, 0xca, 0x39, 0xe5, 0x16, 0x8a)] +interface IDXGIFactory4(IDXGIFactory4Vtbl): IDXGIFactory3(IDXGIFactory3Vtbl) { + fn EnumAdapterByLuid( + AdapterLuid: LUID, + riid: REFGUID, + ppvAdapter: *mut *mut c_void, + ) -> HRESULT, + fn EnumWarpAdapter( + riid: REFGUID, + ppvAdapter: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdc7dca35, 0x2196, 0x414d, 0x9f, 0x53, 0x61, 0x78, 0x84, 0x03, 0x2a, 0x60)] +interface IDXGIOutput4(IDXGIOutput4Vtbl): IDXGIOutput3(IDXGIOutput3Vtbl) { + fn CheckOverlayColorSpaceSupport( + Format: DXGI_FORMAT, + ColorSpace: DXGI_COLOR_SPACE_TYPE, + pConcernedDevice: *mut IUnknown, + pFlags: *mut UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x94d99bdb, 0xf1f8, 0x4ab0, 0xb2, 0x36, 0x7d, 0xa0, 0x17, 0x0e, 0xda, 0xb1)] +interface IDXGISwapChain3(IDXGISwapChain3Vtbl): IDXGISwapChain2(IDXGISwapChain2Vtbl) { + fn GetCurrentBackBufferIndex() -> UINT, + fn CheckColorSpaceSupport( + ColorSpace: DXGI_COLOR_SPACE_TYPE, + pColorSpaceSupport: *mut UINT, + ) -> HRESULT, + fn SetColorSpace1( + ColorSpace: DXGI_COLOR_SPACE_TYPE, + ) -> HRESULT, + fn ResizeBuffers1( + BufferCount: UINT, + Width: UINT, + Height: UINT, + Format: DXGI_FORMAT, + SwapChainFlags: UINT, + pCreationNodeMask: *const UINT, + ppPresentQueue: *mut *mut IUnknown, + ) -> HRESULT, +}} +DEFINE_GUID!{IID_IDXGISwapChain3, + 0x94d99bdb, 0xf1f8, 0x4ab0, 0xb2, 0x36, 0x7d, 0xa0, 0x17, 0x0e, 0xda, 0xb1} +DEFINE_GUID!{IID_IDXGIOutput4, + 0xdc7dca35, 0x2196, 0x414d, 0x9f, 0x53, 0x61, 0x78, 0x84, 0x03, 0x2a, 0x60} +DEFINE_GUID!{IID_IDXGIFactory4, + 0x1bc6ea02, 0xef36, 0x464f, 0xbf, 0x0c, 0x21, 0xca, 0x39, 0xe5, 0x16, 0x8a} +DEFINE_GUID!{IID_IDXGIAdapter3, + 0x645967a4, 0x1392, 0x4310, 0xa7, 0x98, 0x80, 0x53, 0xce, 0x3e, 0x93, 0xfd} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_5.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_5.rs new file mode 100644 index 0000000..a0500a2 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_5.rs @@ -0,0 +1,92 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dxgi1_5.h +use ctypes::c_void; +use shared::basetsd::UINT16; +use shared::dxgi::IDXGIResource; +use shared::dxgi1_2::{DXGI_OFFER_RESOURCE_PRIORITY, IDXGIOutputDuplication}; +use shared::dxgi1_3::{IDXGIDevice3, IDXGIDevice3Vtbl}; +use shared::dxgi1_4::{ + IDXGIFactory4, IDXGIFactory4Vtbl, IDXGIOutput4, IDXGIOutput4Vtbl, IDXGISwapChain3, + IDXGISwapChain3Vtbl, +}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::minwindef::UINT; +use um::unknwnbase::IUnknown; +use um::winnt::HRESULT; +RIDL!{#[uuid(0x80a07424, 0xab52, 0x42eb, 0x83, 0x3c, 0x0c, 0x42, 0xfd, 0x28, 0x2d, 0x98)] +interface IDXGIOutput5(IDXGIOutput5Vtbl): IDXGIOutput4(IDXGIOutput4Vtbl) { + fn DuplicateOutput1( + pDevice: *mut IUnknown, + Flags: UINT, + SupportedFormatsCount: UINT, + pSupportedFormats: *const DXGI_FORMAT, + ppOutputDuplication: *mut *mut IDXGIOutputDuplication, + )-> HRESULT, +}} +ENUM!{enum DXGI_HDR_METADATA_TYPE { + DXGI_HDR_METADATA_TYPE_NONE = 0, + DXGI_HDR_METADATA_TYPE_HDR10 = 1, +}} +STRUCT!{struct DXGI_HDR_METADATA_HDR10 { + RedPrimary: [UINT16; 2], + GreenPrimary: [UINT16; 2], + BluePrimary: [UINT16; 2], + WhitePoint: [UINT16; 2], + MaxMasteringLuminance: UINT, + MinMasteringLuminance: UINT, + MaxContentLightLevel: UINT16, + MaxFrameAverageLightLevel: UINT16, +}} +RIDL!{#[uuid(0x3d585d5a, 0xbd4a, 0x489e, 0xb1, 0xf4, 0x3d, 0xbc, 0xb6, 0x45, 0x2f, 0xfb)] +interface IDXGISwapChain4(IDXGISwapChain4Vtbl): IDXGISwapChain3(IDXGISwapChain3Vtbl) { + fn SetHDRMetaData( + Type: DXGI_HDR_METADATA_TYPE, + Size: UINT, + pMetaData: *mut c_void, + )-> HRESULT, +}} +ENUM!{enum DXGI_OFFER_RESOURCE_FLAGS { + DXGI_OFFER_RESOURCE_FLAG_ALLOW_DECOMMIT = 0x1, +}} +ENUM!{enum DXGI_RECLAIM_RESOURCE_RESULTS { + DXGI_RECLAIM_RESOURCE_RESULT_OK = 0, + DXGI_RECLAIM_RESOURCE_RESULT_DISCARDED = 1, + DXGI_RECLAIM_RESOURCE_RESULT_NOT_COMMITTED = 2, +}} +RIDL!{#[uuid(0x95b4f95f, 0xd8da, 0x4ca4, 0x9e, 0xe6, 0x3b, 0x76, 0xd5, 0x96, 0x8a, 0x10)] +interface IDXGIDevice4(IDXGIDevice4Vtbl): IDXGIDevice3(IDXGIDevice3Vtbl) { + fn OfferResources1( + NumResources: UINT, + ppResources: *mut *mut IDXGIResource, + Priority: DXGI_OFFER_RESOURCE_PRIORITY, + Flags: UINT, + ) -> HRESULT, + fn ReclaimResources1( + NumResources: UINT, + ppResources: *mut *mut IDXGIResource, + pResults: *mut DXGI_RECLAIM_RESOURCE_RESULTS, + ) -> HRESULT, +}} +ENUM!{enum DXGI_FEATURE { + DXGI_FEATURE_PRESENT_ALLOW_TEARING = 0, +}} +RIDL!{#[uuid(0x7632e1f5, 0xee65, 0x4dca, 0x87, 0xfd, 0x84, 0xcd, 0x75, 0xf8, 0x83, 0x8d)] +interface IDXGIFactory5(IDXGIFactory5Vtbl): IDXGIFactory4(IDXGIFactory4Vtbl) { + fn CheckFeatureSupport( + Feature: DXGI_FEATURE, + pFeatureSupportData: *mut c_void, + FeatureSupportDataSize: UINT, + ) -> HRESULT, +}} +DEFINE_GUID!{IID_IDXGIOutput5, + 0x80A07424, 0xAB52, 0x42EB, 0x83, 0x3C, 0x0C, 0x42, 0xFD, 0x28, 0x2D, 0x98} +DEFINE_GUID!{IID_IDXGISwapChain4, + 0x3D585D5A, 0xBD4A, 0x489E, 0xB1, 0xF4, 0x3D, 0xBC, 0xB6, 0x45, 0x2F, 0xFB} +DEFINE_GUID!{IID_IDXGIDevice4, + 0x95B4F95F, 0xD8DA, 0x4CA4, 0x9E, 0xE6, 0x3B, 0x76, 0xD5, 0x96, 0x8A, 0x10} +DEFINE_GUID!{IID_IDXGIFactory5, + 0x7632e1f5, 0xee65, 0x4dca, 0x87, 0xfd, 0x84, 0xcd, 0x75, 0xf8, 0x83, 0x8d} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_6.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_6.rs new file mode 100644 index 0000000..30af205 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgi1_6.rs @@ -0,0 +1,98 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dxgi1_6.h +use ctypes::c_void; +use shared::basetsd::SIZE_T; +use shared::dxgi1_2::{ + DXGI_COMPUTE_PREEMPTION_GRANULARITY, DXGI_GRAPHICS_PREEMPTION_GRANULARITY, +}; +use shared::dxgi1_4::{IDXGIAdapter3, IDXGIAdapter3Vtbl}; +use shared::dxgi1_5::{IDXGIFactory5, IDXGIFactory5Vtbl, IDXGIOutput5, IDXGIOutput5Vtbl}; +use shared::dxgitype::{DXGI_COLOR_SPACE_TYPE, DXGI_MODE_ROTATION}; +use shared::guiddef::REFIID; +use shared::minwindef::{BOOL, FLOAT, UINT}; +use shared::windef::{HMONITOR, RECT}; +use um::winnt::{HRESULT, LUID, WCHAR}; +ENUM!{enum DXGI_ADAPTER_FLAG3 { + DXGI_ADAPTER_FLAG3_NONE = 0, + DXGI_ADAPTER_FLAG3_REMOTE = 1, + DXGI_ADAPTER_FLAG3_SOFTWARE = 2, + DXGI_ADAPTER_FLAG3_ACG_COMPATIBLE = 4, + DXGI_ADAPTER_FLAG3_SUPPORT_MONITORED_FENCES = 8, + DXGI_ADAPTER_FLAG3_SUPPORT_NON_MONITORED_FENCES = 0x10, + DXGI_ADAPTER_FLAG3_KEYED_MUTEX_CONFORMANCE = 0x20, + DXGI_ADAPTER_FLAG3_FORCE_DWORD = 0xFFFFFFFF, +}} +STRUCT!{struct DXGI_ADAPTER_DESC3 { + Description: [WCHAR; 128], + VendorID: UINT, + DeviceID: UINT, + SubSysID: UINT, + Revision: UINT, + DedicatedVideoMemory: SIZE_T, + DedicatedSystemMemory: SIZE_T, + SharedSystemMemory: SIZE_T, + AdapterLuid: LUID, + Flags: DXGI_ADAPTER_FLAG3, + GraphicsPreemptionGranularity: DXGI_GRAPHICS_PREEMPTION_GRANULARITY, + ComputePreemptionGranularity: DXGI_COMPUTE_PREEMPTION_GRANULARITY, +}} +RIDL!{#[uuid(0x3c8d99d1, 0x4fbf, 0x4181, 0xa8, 0x2c, 0xaf, 0x66, 0xbf, 0x7b, 0xd2, 0x4e)] +interface IDXGIAdapter4(IDXGIAdapter4Vtbl): IDXGIAdapter3(IDXGIAdapter3Vtbl) { + fn GetDesc3( + pDesc: *mut DXGI_ADAPTER_DESC3, + ) -> HRESULT, +}} +STRUCT!{struct DXGI_OUTPUT_DESC1 { + DeviceName: [WCHAR; 32], + DesktopCoordinates: RECT, + AttachedToDesktop: BOOL, + Rotation: DXGI_MODE_ROTATION, + Monitor: HMONITOR, + BitsPerColor: UINT, + ColorSpace: DXGI_COLOR_SPACE_TYPE, + RedPrimary: [FLOAT; 2], + GreenPrimary: [FLOAT; 2], + BluePrimary: [FLOAT; 2], + WhitePoint: [FLOAT; 2], + MinLuminance: FLOAT, + MaxLuminance: FLOAT, + MaxFullFrameLuminance: FLOAT, +}} +ENUM!{enum DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAGS { + DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_FULLSCREEN = 1, + DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_WINDOWED = 2, + DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_CURSOR_STRETCHED = 4, +}} +RIDL!{#[uuid(0x068346e8, 0xaaec, 0x4b84, 0xad, 0xd7, 0x13, 0x7f, 0x51, 0x3f, 0x77, 0xa1)] +interface IDXGIOutput6(IDXGIOutput6Vtbl): IDXGIOutput5(IDXGIOutput5Vtbl) { + fn GetDesc1( + pDesc: *mut DXGI_OUTPUT_DESC1, + ) -> HRESULT, + fn CheckHardwareCompositionSupport( + pFlags: *mut UINT, + ) -> HRESULT, +}} +ENUM!{enum DXGI_GPU_PREFERENCE { + DXGI_GPU_PREFERENCE_UNSPECIFIED = 0, + DXGI_GPU_PREFERENCE_MINIMUM_POWER = 1, + DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE = 2, +}} +RIDL!{#[uuid(0xc1b6694f, 0xff09, 0x44a9, 0xb0, 0x3c, 0x77, 0x90, 0x0a, 0x0a, 0x1d, 0x17)] +interface IDXGIFactory6(IDXGIFactory6Vtbl): IDXGIFactory5(IDXGIFactory5Vtbl) { + fn EnumAdapterByGpuPreference( + Adapter: UINT, + GpuPreference: DXGI_GPU_PREFERENCE, + riid: REFIID, + ppvAdapter: *mut *mut c_void, + ) -> HRESULT, +}} +DEFINE_GUID!{IID_IDXGIAdapter4, + 0x3c8d99d1, 0x4fbf, 0x4181, 0xa8, 0x2c, 0xaf, 0x66, 0xbf, 0x7b, 0xd2, 0x4e} +DEFINE_GUID!{IID_IDXGIOutput6, + 0x068346e8, 0xaaec, 0x4b84, 0xad, 0xd7, 0x13, 0x7f, 0x51, 0x3f, 0x77, 0xa1} +DEFINE_GUID!{IID_IDXGIFactory6, + 0xc1b6694f, 0xff09, 0x44a9, 0xb0, 0x3c, 0x77, 0x90, 0x0a, 0x0a, 0x1d, 0x17} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgiformat.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgiformat.rs new file mode 100644 index 0000000..84cd23f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgiformat.rs @@ -0,0 +1,127 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dxgiformat.h +ENUM!{enum DXGI_FORMAT { + DXGI_FORMAT_UNKNOWN = 0, + DXGI_FORMAT_R32G32B32A32_TYPELESS = 1, + DXGI_FORMAT_R32G32B32A32_FLOAT = 2, + DXGI_FORMAT_R32G32B32A32_UINT = 3, + DXGI_FORMAT_R32G32B32A32_SINT = 4, + DXGI_FORMAT_R32G32B32_TYPELESS = 5, + DXGI_FORMAT_R32G32B32_FLOAT = 6, + DXGI_FORMAT_R32G32B32_UINT = 7, + DXGI_FORMAT_R32G32B32_SINT = 8, + DXGI_FORMAT_R16G16B16A16_TYPELESS = 9, + DXGI_FORMAT_R16G16B16A16_FLOAT = 10, + DXGI_FORMAT_R16G16B16A16_UNORM = 11, + DXGI_FORMAT_R16G16B16A16_UINT = 12, + DXGI_FORMAT_R16G16B16A16_SNORM = 13, + DXGI_FORMAT_R16G16B16A16_SINT = 14, + DXGI_FORMAT_R32G32_TYPELESS = 15, + DXGI_FORMAT_R32G32_FLOAT = 16, + DXGI_FORMAT_R32G32_UINT = 17, + DXGI_FORMAT_R32G32_SINT = 18, + DXGI_FORMAT_R32G8X24_TYPELESS = 19, + DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20, + DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21, + DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22, + DXGI_FORMAT_R10G10B10A2_TYPELESS = 23, + DXGI_FORMAT_R10G10B10A2_UNORM = 24, + DXGI_FORMAT_R10G10B10A2_UINT = 25, + DXGI_FORMAT_R11G11B10_FLOAT = 26, + DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, + DXGI_FORMAT_R8G8B8A8_UNORM = 28, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, + DXGI_FORMAT_R8G8B8A8_UINT = 30, + DXGI_FORMAT_R8G8B8A8_SNORM = 31, + DXGI_FORMAT_R8G8B8A8_SINT = 32, + DXGI_FORMAT_R16G16_TYPELESS = 33, + DXGI_FORMAT_R16G16_FLOAT = 34, + DXGI_FORMAT_R16G16_UNORM = 35, + DXGI_FORMAT_R16G16_UINT = 36, + DXGI_FORMAT_R16G16_SNORM = 37, + DXGI_FORMAT_R16G16_SINT = 38, + DXGI_FORMAT_R32_TYPELESS = 39, + DXGI_FORMAT_D32_FLOAT = 40, + DXGI_FORMAT_R32_FLOAT = 41, + DXGI_FORMAT_R32_UINT = 42, + DXGI_FORMAT_R32_SINT = 43, + DXGI_FORMAT_R24G8_TYPELESS = 44, + DXGI_FORMAT_D24_UNORM_S8_UINT = 45, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46, + DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47, + DXGI_FORMAT_R8G8_TYPELESS = 48, + DXGI_FORMAT_R8G8_UNORM = 49, + DXGI_FORMAT_R8G8_UINT = 50, + DXGI_FORMAT_R8G8_SNORM = 51, + DXGI_FORMAT_R8G8_SINT = 52, + DXGI_FORMAT_R16_TYPELESS = 53, + DXGI_FORMAT_R16_FLOAT = 54, + DXGI_FORMAT_D16_UNORM = 55, + DXGI_FORMAT_R16_UNORM = 56, + DXGI_FORMAT_R16_UINT = 57, + DXGI_FORMAT_R16_SNORM = 58, + DXGI_FORMAT_R16_SINT = 59, + DXGI_FORMAT_R8_TYPELESS = 60, + DXGI_FORMAT_R8_UNORM = 61, + DXGI_FORMAT_R8_UINT = 62, + DXGI_FORMAT_R8_SNORM = 63, + DXGI_FORMAT_R8_SINT = 64, + DXGI_FORMAT_A8_UNORM = 65, + DXGI_FORMAT_R1_UNORM = 66, + DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67, + DXGI_FORMAT_R8G8_B8G8_UNORM = 68, + DXGI_FORMAT_G8R8_G8B8_UNORM = 69, + DXGI_FORMAT_BC1_TYPELESS = 70, + DXGI_FORMAT_BC1_UNORM = 71, + DXGI_FORMAT_BC1_UNORM_SRGB = 72, + DXGI_FORMAT_BC2_TYPELESS = 73, + DXGI_FORMAT_BC2_UNORM = 74, + DXGI_FORMAT_BC2_UNORM_SRGB = 75, + DXGI_FORMAT_BC3_TYPELESS = 76, + DXGI_FORMAT_BC3_UNORM = 77, + DXGI_FORMAT_BC3_UNORM_SRGB = 78, + DXGI_FORMAT_BC4_TYPELESS = 79, + DXGI_FORMAT_BC4_UNORM = 80, + DXGI_FORMAT_BC4_SNORM = 81, + DXGI_FORMAT_BC5_TYPELESS = 82, + DXGI_FORMAT_BC5_UNORM = 83, + DXGI_FORMAT_BC5_SNORM = 84, + DXGI_FORMAT_B5G6R5_UNORM = 85, + DXGI_FORMAT_B5G5R5A1_UNORM = 86, + DXGI_FORMAT_B8G8R8A8_UNORM = 87, + DXGI_FORMAT_B8G8R8X8_UNORM = 88, + DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89, + DXGI_FORMAT_B8G8R8A8_TYPELESS = 90, + DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91, + DXGI_FORMAT_B8G8R8X8_TYPELESS = 92, + DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93, + DXGI_FORMAT_BC6H_TYPELESS = 94, + DXGI_FORMAT_BC6H_UF16 = 95, + DXGI_FORMAT_BC6H_SF16 = 96, + DXGI_FORMAT_BC7_TYPELESS = 97, + DXGI_FORMAT_BC7_UNORM = 98, + DXGI_FORMAT_BC7_UNORM_SRGB = 99, + DXGI_FORMAT_AYUV = 100, + DXGI_FORMAT_Y410 = 101, + DXGI_FORMAT_Y416 = 102, + DXGI_FORMAT_NV12 = 103, + DXGI_FORMAT_P010 = 104, + DXGI_FORMAT_P016 = 105, + DXGI_FORMAT_420_OPAQUE = 106, + DXGI_FORMAT_YUY2 = 107, + DXGI_FORMAT_Y210 = 108, + DXGI_FORMAT_Y216 = 109, + DXGI_FORMAT_NV11 = 110, + DXGI_FORMAT_AI44 = 111, + DXGI_FORMAT_IA44 = 112, + DXGI_FORMAT_P8 = 113, + DXGI_FORMAT_A8P8 = 114, + DXGI_FORMAT_B4G4R4A4_UNORM = 115, + DXGI_FORMAT_P208 = 130, + DXGI_FORMAT_V208 = 131, + DXGI_FORMAT_V408 = 132, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgitype.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgitype.rs new file mode 100644 index 0000000..d09dccd --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/dxgitype.rs @@ -0,0 +1,109 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dxgitype.h +use shared::d3d9types::D3DCOLORVALUE; +use shared::dxgiformat::DXGI_FORMAT; +use shared::minwindef::{BOOL, BYTE, DWORD, UINT}; +pub const DXGI_CPU_ACCESS_NONE: DWORD = 0; +pub const DXGI_CPU_ACCESS_DYNAMIC: DWORD = 1; +pub const DXGI_CPU_ACCESS_READ_WRITE: DWORD = 2; +pub const DXGI_CPU_ACCESS_SCRATCH: DWORD = 3; +pub const DXGI_CPU_ACCESS_FIELD: DWORD = 15; +ENUM!{enum DXGI_USAGE { + DXGI_USAGE_SHADER_INPUT = 1 << (0 + 4), + DXGI_USAGE_RENDER_TARGET_OUTPUT = 1 << (1 + 4), + DXGI_USAGE_BACK_BUFFER = 1 << (2 + 4), + DXGI_USAGE_SHARED = 1 << (3 + 4), + DXGI_USAGE_READ_ONLY = 1 << (4 + 4), + DXGI_USAGE_DISCARD_ON_PRESENT = 1 << (5 + 4), + DXGI_USAGE_UNORDERED_ACCESS = 1 << (6 + 4), +}} +STRUCT!{struct DXGI_RGB { + Red: f32, + Green: f32, + Blue: f32, +}} +pub type DXGI_RGBA = D3DCOLORVALUE; +STRUCT!{struct DXGI_GAMMA_CONTROL { + Scale: DXGI_RGB, + Offset: DXGI_RGB, + GammaCurve: [DXGI_RGB; 1025], +}} +STRUCT!{struct DXGI_GAMMA_CONTROL_CAPABILITIES { + ScaleAndOffsetSupported: BOOL, + MaxConvertedValue: f32, + MinConvertedValue: f32, + NumGammaControlPoints: UINT, + ControlPointPositions: [f32; 1025], +}} +STRUCT!{struct DXGI_RATIONAL { + Numerator: UINT, + Denominator: UINT, +}} +ENUM!{enum DXGI_MODE_SCANLINE_ORDER { + DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED, + DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE, + DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST, + DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST, +}} +ENUM!{enum DXGI_MODE_SCALING { + DXGI_MODE_SCALING_UNSPECIFIED, + DXGI_MODE_SCALING_CENTERED, + DXGI_MODE_SCALING_STRETCHED, +}} +ENUM!{enum DXGI_MODE_ROTATION { + DXGI_MODE_ROTATION_UNSPECIFIED, + DXGI_MODE_ROTATION_IDENTITY, + DXGI_MODE_ROTATION_ROTATE90, + DXGI_MODE_ROTATION_ROTATE180, + DXGI_MODE_ROTATION_ROTATE270, +}} +STRUCT!{struct DXGI_MODE_DESC { + Width: UINT, + Height: UINT, + RefreshRate: DXGI_RATIONAL, + Format: DXGI_FORMAT, + ScanlineOrdering: DXGI_MODE_SCANLINE_ORDER, + Scaling: DXGI_MODE_SCALING, +}} +STRUCT!{struct DXGI_SAMPLE_DESC { + Count: UINT, + Quality: UINT, +}} +STRUCT!{struct DXGI_JPEG_DC_HUFFMAN_TABLE { + CodeCounts: [BYTE; 12], + CodeValues: [BYTE; 12], +}} +STRUCT!{struct DXGI_JPEG_AC_HUFFMAN_TABLE { + CodeCounts: [BYTE; 16], + CodeValues: [BYTE; 162], +}} +STRUCT!{struct DXGI_JPEG_QUANTIZATION_TABLE { + Elements: [BYTE; 64], +}} +ENUM!{enum DXGI_COLOR_SPACE_TYPE { + DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 = 0, + DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 = 1, + DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709 = 2, + DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P2020 = 3, + DXGI_COLOR_SPACE_RESERVED = 4, + DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601 = 5, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 = 6, + DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601 = 7, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 = 8, + DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709 = 9, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020 = 10, + DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 = 11, + DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 = 12, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020 = 13, + DXGI_COLOR_SPACE_RGB_STUDIO_G2084_NONE_P2020 = 14, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_TOPLEFT_P2020 = 15, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_TOPLEFT_P2020 = 16, + DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020 = 17, + DXGI_COLOR_SPACE_CUSTOM = 0xFFFFFFFF, +}} +pub const DXGI_CENTER_MULTISAMPLE_QUALITY_PATTERN: UINT = 0xfffffffe; +pub const DXGI_STANDARD_MULTISAMPLE_QUALITY_PATTERN: UINT = 0xffffffff; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/evntprov.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/evntprov.rs new file mode 100644 index 0000000..455ff5d --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/evntprov.rs @@ -0,0 +1,309 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{SIZE_T, ULONG64}; +use shared::guiddef::{LPCGUID, LPGUID}; +use shared::minwindef::{UCHAR, ULONG, USHORT}; +use um::winnt::{ANYSIZE_ARRAY, BOOLEAN, PCWSTR, PVOID, ULONGLONG, VOID}; +pub const EVENT_MIN_LEVEL: UCHAR = 0; +pub const EVENT_MAX_LEVEL: UCHAR = 0xff; +pub const EVENT_ACTIVITY_CTRL_GET_ID: ULONG = 1; +pub const EVENT_ACTIVITY_CTRL_SET_ID: ULONG = 2; +pub const EVENT_ACTIVITY_CTRL_CREATE_ID: ULONG = 3; +pub const EVENT_ACTIVITY_CTRL_GET_SET_ID: ULONG = 4; +pub const EVENT_ACTIVITY_CTRL_CREATE_SET_ID: ULONG = 5; +pub const MAX_EVENT_DATA_DESCRIPTORS: SIZE_T = 128; +pub const MAX_EVENT_FILTER_DATA_SIZE: SIZE_T = 1024; +pub const MAX_EVENT_FILTER_PAYLOAD_SIZE: SIZE_T = 4096; +pub const MAX_EVENT_FILTER_EVENT_NAME_SIZE: SIZE_T = 4096; +pub const MAX_EVENT_FILTERS_COUNT: SIZE_T = 8; +pub const MAX_EVENT_FILTER_PID_COUNT: SIZE_T = 8; +pub const MAX_EVENT_FILTER_EVENT_ID_COUNT: SIZE_T = 64; +pub const EVENT_FILTER_TYPE_NONE: ULONG = 0x00000000; +pub const EVENT_FILTER_TYPE_SCHEMATIZED: ULONG = 0x80000000; +pub const EVENT_FILTER_TYPE_SYSTEM_FLAGS: ULONG = 0x80000001; +pub const EVENT_FILTER_TYPE_TRACEHANDLE: ULONG = 0x80000002; +pub const EVENT_FILTER_TYPE_PID: ULONG = 0x80000004; +pub const EVENT_FILTER_TYPE_EXECUTABLE_NAME: ULONG = 0x80000008; +pub const EVENT_FILTER_TYPE_PACKAGE_ID: ULONG = 0x80000010; +pub const EVENT_FILTER_TYPE_PACKAGE_APP_ID: ULONG = 0x80000020; +pub const EVENT_FILTER_TYPE_PAYLOAD: ULONG = 0x80000100; +pub const EVENT_FILTER_TYPE_EVENT_ID: ULONG = 0x80000200; +pub const EVENT_FILTER_TYPE_EVENT_NAME: ULONG = 0x80000400; +pub const EVENT_FILTER_TYPE_STACKWALK: ULONG = 0x80001000; +pub const EVENT_FILTER_TYPE_STACKWALK_NAME: ULONG = 0x80001000; +pub const EVENT_FILTER_TYPE_STACKWALK_LEVEL_KW: ULONG = 0x80004000; +pub const EVENT_DATA_DESCRIPTOR_TYPE_NONE: UCHAR = 0; +pub const EVENT_DATA_DESCRIPTOR_TYPE_EVENT_METADATA: UCHAR = 1; +pub const EVENT_DATA_DESCRIPTOR_TYPE_PROVIDER_METADATA: UCHAR = 2; +pub const EVENT_DATA_DESCRIPTOR_TYPE_TIMESTAMP_OVERRIDE: UCHAR = 3; +pub const EVENT_WRITE_FLAG_NO_FAULTING: ULONG = 0x00000001; +pub const EVENT_WRITE_FLAG_INPRIVATE: ULONG = 0x00000002; +pub type REGHANDLE = ULONGLONG; +pub type PREGHANDLE = *mut REGHANDLE; +STRUCT!{struct EVENT_DATA_DESCRIPTOR_u_s { + Type: UCHAR, + Reserved1: UCHAR, + Reserved2: USHORT, +}} +UNION!{union EVENT_DATA_DESCRIPTOR_u { + [u32; 1], + Reserved Reserved_mut: ULONG, + s s_mut: EVENT_DATA_DESCRIPTOR_u_s, +}} +STRUCT!{struct EVENT_DATA_DESCRIPTOR { + Ptr: ULONGLONG, + Size: ULONG, + u: EVENT_DATA_DESCRIPTOR_u, +}} +pub type PEVENT_DATA_DESCRIPTOR = *mut EVENT_DATA_DESCRIPTOR; +STRUCT!{struct EVENT_DESCRIPTOR { + Id: USHORT, + Version: UCHAR, + Channel: UCHAR, + Level: UCHAR, + Opcode: UCHAR, + Task: USHORT, + Keyword: ULONGLONG, +}} +pub type PEVENT_DESCRIPTOR = *mut EVENT_DESCRIPTOR; +pub type PCEVENT_DESCRIPTOR = *const EVENT_DESCRIPTOR; +STRUCT!{struct EVENT_FILTER_DESCRIPTOR { + Ptr: ULONGLONG, + Size: ULONG, + Type: ULONG, +}} +pub type PEVENT_FILTER_DESCRIPTOR = *mut EVENT_FILTER_DESCRIPTOR; +STRUCT!{struct EVENT_FILTER_HEADER { + Id: USHORT, + Version: UCHAR, + Reserved: [UCHAR; 5], + InstanceId: ULONGLONG, + Size: ULONG, + NextOffset: ULONG, +}} +pub type PEVENT_FILTER_HEADER = *mut EVENT_FILTER_HEADER; +STRUCT!{struct EVENT_FILTER_EVENT_ID { + FilterIn: BOOLEAN, + Reserved: UCHAR, + Count: USHORT, + Events: [USHORT; ANYSIZE_ARRAY], +}} +pub type PEVENT_FILTER_EVENT_ID = *mut EVENT_FILTER_EVENT_ID; +STRUCT!{struct EVENT_FILTER_EVENT_NAME { + MatchAnyKeyword: ULONGLONG, + MatchAllKeyword: ULONGLONG, + Level: UCHAR, + FilterIn: BOOLEAN, + NameCount: USHORT, + Names: [UCHAR; ANYSIZE_ARRAY], +}} +pub type PEVENT_FILTER_EVENT_NAME = *mut EVENT_FILTER_EVENT_NAME; +STRUCT!{struct EVENT_FILTER_LEVEL_KW { + MatchAnyKeyword: ULONGLONG, + MatchAllKeyword: ULONGLONG, + Level: UCHAR, + FilterIn: BOOLEAN, +}} +ENUM!{enum EVENT_INFO_CLASS { + EventProviderBinaryTrackInfo, + EventProviderSetReserved1, + EventProviderSetTraits, + EventProviderUseDescriptorType, + MaxEventInfo, +}} +FN!{stdcall PENABLECALLBACK( + SourceId: LPCGUID, + IsEnabled: ULONG, + Level: UCHAR, + MatchAnyKeyword: ULONGLONG, + MatchAllKeyword: ULONGLONG, + FilterData: PEVENT_FILTER_DESCRIPTOR, + CallbackContext: PVOID, +) -> ()} +extern "system" { + pub fn EventRegister( + ProviderId: LPCGUID, + EnableCallback: PENABLECALLBACK, + CallbackContext: PVOID, + RegHandle: PREGHANDLE, + ) -> ULONG; + pub fn EventUnregister( + RegHandle: REGHANDLE, + ) -> ULONG; + pub fn EventSetInformation( + RegHandle: REGHANDLE, + InformationClass: EVENT_INFO_CLASS, + EventInformation: PVOID, + InformationLength: ULONG, + ) -> ULONG; + pub fn EventEnabled( + RegHandle: REGHANDLE, + EventDescriptor: PCEVENT_DESCRIPTOR, + ) -> BOOLEAN; + pub fn EventProviderEnabled( + RegHandle: REGHANDLE, + Level: UCHAR, + Keyword: ULONGLONG, + ) -> BOOLEAN; + pub fn EventWrite( + RegHandle: REGHANDLE, + EventDescriptor: PCEVENT_DESCRIPTOR, + UserDataCount: ULONG, + UserData: PEVENT_DATA_DESCRIPTOR, + ) -> ULONG; + pub fn EventWriteTransfer( + RegHandle: REGHANDLE, + EventDescriptor: PCEVENT_DESCRIPTOR, + ActivityId: LPCGUID, + RelatedActivityId: LPCGUID, + UserDataCount: ULONG, + UserData: PEVENT_DATA_DESCRIPTOR, + ) -> ULONG; + pub fn EventWriteEx( + RegHandle: REGHANDLE, + EventDescriptor: PCEVENT_DESCRIPTOR, + Filter: ULONG64, + Flags: ULONG, + ActivityId: LPCGUID, + RelatedActivityId: LPCGUID, + UserDataCount: ULONG, + UserData: PEVENT_DATA_DESCRIPTOR, + ) -> ULONG; + pub fn EventWriteString( + RegHandle: REGHANDLE, + Level: UCHAR, + Keyword: ULONGLONG, + EventString: PCWSTR, + ) -> ULONG; + pub fn EventActivityIdControl( + ControlCode: ULONG, + ActivityId: LPGUID, + ) -> ULONG; +} +#[inline] +pub unsafe fn EventDataDescCreate( + EventDataDescriptor: PEVENT_DATA_DESCRIPTOR, + DataPtr: *const VOID, + DataSize: ULONG, +) { + (*EventDataDescriptor).Ptr = DataPtr as ULONGLONG; + (*EventDataDescriptor).Size = DataSize; + *(*EventDataDescriptor).u.Reserved_mut() = 0; +} +#[inline] +pub unsafe fn EventDescCreate( + EventDescriptor: PEVENT_DESCRIPTOR, + Id: USHORT, + Version: UCHAR, + Channel: UCHAR, + Level: UCHAR, + Task: USHORT, + Opcode: UCHAR, + Keyword: ULONGLONG, +) { + (*EventDescriptor).Id = Id; + (*EventDescriptor).Version = Version; + (*EventDescriptor).Channel = Channel; + (*EventDescriptor).Level = Level; + (*EventDescriptor).Task = Task; + (*EventDescriptor).Opcode = Opcode; + (*EventDescriptor).Keyword = Keyword; +} +#[inline] +pub unsafe fn EventDescZero(EventDescriptor: PEVENT_DESCRIPTOR) { + use core::ptr::write_bytes; + // FIXME: 16 = sizeof::<EVENT_DESCRIPTOR>() + write_bytes(EventDescriptor, 0, 16); +} +#[inline] +pub unsafe fn EventDescGetId(EventDescriptor: PCEVENT_DESCRIPTOR) -> USHORT { + (*EventDescriptor).Id +} +#[inline] +pub unsafe fn EventDescGetVersion(EventDescriptor: PCEVENT_DESCRIPTOR) -> UCHAR { + (*EventDescriptor).Version +} +#[inline] +pub unsafe fn EventDescGetTask(EventDescriptor: PCEVENT_DESCRIPTOR) -> USHORT { + (*EventDescriptor).Task +} +#[inline] +pub unsafe fn EventDescGetOpcode(EventDescriptor: PCEVENT_DESCRIPTOR) -> UCHAR { + (*EventDescriptor).Opcode +} +#[inline] +pub unsafe fn EventDescGetChannel(EventDescriptor: PCEVENT_DESCRIPTOR) -> UCHAR { + (*EventDescriptor).Channel +} +#[inline] +pub unsafe fn EventDescGetLevel(EventDescriptor: PCEVENT_DESCRIPTOR) -> UCHAR { + (*EventDescriptor).Level +} +#[inline] +pub unsafe fn EventDescGetKeyword(EventDescriptor: PCEVENT_DESCRIPTOR) -> ULONGLONG { + (*EventDescriptor).Keyword +} +#[inline] +pub unsafe fn EventDescSetId(EventDescriptor: PEVENT_DESCRIPTOR, Id: USHORT) -> PEVENT_DESCRIPTOR { + (*EventDescriptor).Id = Id; + EventDescriptor +} +#[inline] +pub unsafe fn EventDescSetVersion( + EventDescriptor: PEVENT_DESCRIPTOR, + Version: UCHAR, +) -> PEVENT_DESCRIPTOR { + (*EventDescriptor).Version = Version; + EventDescriptor +} +#[inline] +pub unsafe fn EventDescSetTask( + EventDescriptor: PEVENT_DESCRIPTOR, + Task: USHORT, +) -> PEVENT_DESCRIPTOR { + (*EventDescriptor).Task = Task; + EventDescriptor +} +#[inline] +pub unsafe fn EventDescSetOpcode( + EventDescriptor: PEVENT_DESCRIPTOR, + Opcode: UCHAR, +) -> PEVENT_DESCRIPTOR { + (*EventDescriptor).Opcode = Opcode; + EventDescriptor +} +#[inline] +pub unsafe fn EventDescSetLevel( + EventDescriptor: PEVENT_DESCRIPTOR, + Level: UCHAR, +) -> PEVENT_DESCRIPTOR { + (*EventDescriptor).Level = Level; + EventDescriptor +} +#[inline] +pub unsafe fn EventDescSetChannel( + EventDescriptor: PEVENT_DESCRIPTOR, + Channel: UCHAR, +) -> PEVENT_DESCRIPTOR { + (*EventDescriptor).Channel = Channel; + EventDescriptor +} +#[inline] +pub unsafe fn EventDescSetKeyword( + EventDescriptor: PEVENT_DESCRIPTOR, + Keyword: ULONGLONG, +) -> PEVENT_DESCRIPTOR { + (*EventDescriptor).Keyword = Keyword; + EventDescriptor +} +#[inline] +pub unsafe fn EventDescOrKeyword( + EventDescriptor: PEVENT_DESCRIPTOR, + Keyword: ULONGLONG, +) -> PEVENT_DESCRIPTOR { + (*EventDescriptor).Keyword |= Keyword; + EventDescriptor +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/evntrace.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/evntrace.rs new file mode 100644 index 0000000..23a93ee --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/evntrace.rs @@ -0,0 +1,990 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{SIZE_T, ULONG32, ULONG64}; +use shared::evntprov::PEVENT_FILTER_DESCRIPTOR; +use shared::guiddef::{GUID, LPCGUID, LPGUID}; +use shared::minwindef::{DWORD, LPFILETIME, PULONG, UCHAR, UINT, ULONG, USHORT}; +use shared::wmistr::{WMIDPREQUESTCODE, WNODE_HEADER}; +use um::evntcons::PEVENT_RECORD; +use um::handleapi::INVALID_HANDLE_VALUE; +use um::timezoneapi::TIME_ZONE_INFORMATION; +use um::winnt::{ + ANYSIZE_ARRAY, BOOLEAN, HANDLE, LARGE_INTEGER, LONG, LONGLONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, + PVOID, ULONGLONG, WCHAR +}; +use vc::vadefs::va_list; +DEFINE_GUID!{EventTraceGuid, + 0x68fdd900, 0x4a3e, 0x11d1, 0x84, 0xf4, 0x00, 0x00, 0xf8, 0x04, 0x64, 0xe3} +DEFINE_GUID!{SystemTraceControlGuid, + 0x9e814aad, 0x3204, 0x11d2, 0x9a, 0x82, 0x00, 0x60, 0x08, 0xa8, 0x69, 0x39} +DEFINE_GUID!{EventTraceConfigGuid, + 0x01853a65, 0x418f, 0x4f36, 0xae, 0xfc, 0xdc, 0x0f, 0x1d, 0x2f, 0xd2, 0x35} +DEFINE_GUID!{DefaultTraceSecurityGuid, + 0x0811c1af, 0x7a07, 0x4a06, 0x82, 0xed, 0x86, 0x94, 0x55, 0xcd, 0xf7, 0x13} +DEFINE_GUID!{PrivateLoggerNotificationGuid, + 0x3595ab5c, 0x042a, 0x4c8e, 0xb9, 0x42, 0x2d, 0x05, 0x9b, 0xfe, 0xb1, 0xb1} +pub const KERNEL_LOGGER_NAME: &'static str = "NT Kernel Logger"; +pub const GLOBAL_LOGGER_NAME: &'static str = "GlobalLogger"; +pub const EVENT_LOGGER_NAME: &'static str = "EventLog"; +pub const DIAG_LOGGER_NAME: &'static str = "DiagLog"; +pub const MAX_MOF_FIELDS: SIZE_T = 16; +DECLARE_HANDLE!{TRACEHANDLE, __TRACEHANDLE} +pub type PTRACEHANDLE = *mut TRACEHANDLE; +pub const EVENT_TRACE_TYPE_INFO: DWORD = 0x00; +pub const EVENT_TRACE_TYPE_START: DWORD = 0x01; +pub const EVENT_TRACE_TYPE_END: DWORD = 0x02; +pub const EVENT_TRACE_TYPE_STOP: DWORD = 0x02; +pub const EVENT_TRACE_TYPE_DC_START: DWORD = 0x03; +pub const EVENT_TRACE_TYPE_DC_END: DWORD = 0x04; +pub const EVENT_TRACE_TYPE_EXTENSION: DWORD = 0x05; +pub const EVENT_TRACE_TYPE_REPLY: DWORD = 0x06; +pub const EVENT_TRACE_TYPE_DEQUEUE: DWORD = 0x07; +pub const EVENT_TRACE_TYPE_RESUME: DWORD = 0x07; +pub const EVENT_TRACE_TYPE_CHECKPOINT: DWORD = 0x08; +pub const EVENT_TRACE_TYPE_SUSPEND: DWORD = 0x08; +pub const EVENT_TRACE_TYPE_WINEVT_SEND: DWORD = 0x09; +pub const EVENT_TRACE_TYPE_WINEVT_RECEIVE: DWORD = 0xF0; +pub const TRACE_LEVEL_CRITICAL: UCHAR = 1; +pub const TRACE_LEVEL_ERROR: UCHAR = 2; +pub const TRACE_LEVEL_WARNING: UCHAR = 3; +pub const TRACE_LEVEL_INFORMATION: UCHAR = 4; +pub const TRACE_LEVEL_VERBOSE: UCHAR = 5; +pub const TRACE_LEVEL_RESERVED6: UCHAR = 6; +pub const TRACE_LEVEL_RESERVED7: UCHAR = 7; +pub const TRACE_LEVEL_RESERVED8: UCHAR = 8; +pub const TRACE_LEVEL_RESERVED9: UCHAR = 9; +pub const EVENT_TRACE_TYPE_LOAD: DWORD = 0x0A; +pub const EVENT_TRACE_TYPE_TERMINATE: DWORD = 0x0B; +pub const EVENT_TRACE_TYPE_IO_READ: DWORD = 0x0A; +pub const EVENT_TRACE_TYPE_IO_WRITE: DWORD = 0x0B; +pub const EVENT_TRACE_TYPE_IO_READ_INIT: DWORD = 0x0C; +pub const EVENT_TRACE_TYPE_IO_WRITE_INIT: DWORD = 0x0D; +pub const EVENT_TRACE_TYPE_IO_FLUSH: DWORD = 0x0E; +pub const EVENT_TRACE_TYPE_IO_FLUSH_INIT: DWORD = 0x0F; +pub const EVENT_TRACE_TYPE_IO_REDIRECTED_INIT: DWORD = 0x10; +pub const EVENT_TRACE_TYPE_MM_TF: DWORD = 0x0A; +pub const EVENT_TRACE_TYPE_MM_DZF: DWORD = 0x0B; +pub const EVENT_TRACE_TYPE_MM_COW: DWORD = 0x0C; +pub const EVENT_TRACE_TYPE_MM_GPF: DWORD = 0x0D; +pub const EVENT_TRACE_TYPE_MM_HPF: DWORD = 0x0E; +pub const EVENT_TRACE_TYPE_MM_AV: DWORD = 0x0F; +pub const EVENT_TRACE_TYPE_SEND: DWORD = 0x0A; +pub const EVENT_TRACE_TYPE_RECEIVE: DWORD = 0x0B; +pub const EVENT_TRACE_TYPE_CONNECT: DWORD = 0x0C; +pub const EVENT_TRACE_TYPE_DISCONNECT: DWORD = 0x0D; +pub const EVENT_TRACE_TYPE_RETRANSMIT: DWORD = 0x0E; +pub const EVENT_TRACE_TYPE_ACCEPT: DWORD = 0x0F; +pub const EVENT_TRACE_TYPE_RECONNECT: DWORD = 0x10; +pub const EVENT_TRACE_TYPE_CONNFAIL: DWORD = 0x11; +pub const EVENT_TRACE_TYPE_COPY_TCP: DWORD = 0x12; +pub const EVENT_TRACE_TYPE_COPY_ARP: DWORD = 0x13; +pub const EVENT_TRACE_TYPE_ACKFULL: DWORD = 0x14; +pub const EVENT_TRACE_TYPE_ACKPART: DWORD = 0x15; +pub const EVENT_TRACE_TYPE_ACKDUP: DWORD = 0x16; +pub const EVENT_TRACE_TYPE_GUIDMAP: DWORD = 0x0A; +pub const EVENT_TRACE_TYPE_CONFIG: DWORD = 0x0B; +pub const EVENT_TRACE_TYPE_SIDINFO: DWORD = 0x0C; +pub const EVENT_TRACE_TYPE_SECURITY: DWORD = 0x0D; +pub const EVENT_TRACE_TYPE_DBGID_RSDS: DWORD = 0x40; +pub const EVENT_TRACE_TYPE_REGCREATE: DWORD = 0x0A; +pub const EVENT_TRACE_TYPE_REGOPEN: DWORD = 0x0B; +pub const EVENT_TRACE_TYPE_REGDELETE: DWORD = 0x0C; +pub const EVENT_TRACE_TYPE_REGQUERY: DWORD = 0x0D; +pub const EVENT_TRACE_TYPE_REGSETVALUE: DWORD = 0x0E; +pub const EVENT_TRACE_TYPE_REGDELETEVALUE: DWORD = 0x0F; +pub const EVENT_TRACE_TYPE_REGQUERYVALUE: DWORD = 0x10; +pub const EVENT_TRACE_TYPE_REGENUMERATEKEY: DWORD = 0x11; +pub const EVENT_TRACE_TYPE_REGENUMERATEVALUEKEY: DWORD = 0x12; +pub const EVENT_TRACE_TYPE_REGQUERYMULTIPLEVALUE: DWORD = 0x13; +pub const EVENT_TRACE_TYPE_REGSETINFORMATION: DWORD = 0x14; +pub const EVENT_TRACE_TYPE_REGFLUSH: DWORD = 0x15; +pub const EVENT_TRACE_TYPE_REGKCBCREATE: DWORD = 0x16; +pub const EVENT_TRACE_TYPE_REGKCBDELETE: DWORD = 0x17; +pub const EVENT_TRACE_TYPE_REGKCBRUNDOWNBEGIN: DWORD = 0x18; +pub const EVENT_TRACE_TYPE_REGKCBRUNDOWNEND: DWORD = 0x19; +pub const EVENT_TRACE_TYPE_REGVIRTUALIZE: DWORD = 0x1A; +pub const EVENT_TRACE_TYPE_REGCLOSE: DWORD = 0x1B; +pub const EVENT_TRACE_TYPE_REGSETSECURITY: DWORD = 0x1C; +pub const EVENT_TRACE_TYPE_REGQUERYSECURITY: DWORD = 0x1D; +pub const EVENT_TRACE_TYPE_REGCOMMIT: DWORD = 0x1E; +pub const EVENT_TRACE_TYPE_REGPREPARE: DWORD = 0x1F; +pub const EVENT_TRACE_TYPE_REGROLLBACK: DWORD = 0x20; +pub const EVENT_TRACE_TYPE_REGMOUNTHIVE: DWORD = 0x21; +pub const EVENT_TRACE_TYPE_CONFIG_CPU: DWORD = 0x0A; +pub const EVENT_TRACE_TYPE_CONFIG_PHYSICALDISK: DWORD = 0x0B; +pub const EVENT_TRACE_TYPE_CONFIG_LOGICALDISK: DWORD = 0x0C; +pub const EVENT_TRACE_TYPE_CONFIG_NIC: DWORD = 0x0D; +pub const EVENT_TRACE_TYPE_CONFIG_VIDEO: DWORD = 0x0E; +pub const EVENT_TRACE_TYPE_CONFIG_SERVICES: DWORD = 0x0F; +pub const EVENT_TRACE_TYPE_CONFIG_POWER: DWORD = 0x10; +pub const EVENT_TRACE_TYPE_CONFIG_NETINFO: DWORD = 0x11; +pub const EVENT_TRACE_TYPE_CONFIG_OPTICALMEDIA: DWORD = 0x12; +pub const EVENT_TRACE_TYPE_CONFIG_IRQ: DWORD = 0x15; +pub const EVENT_TRACE_TYPE_CONFIG_PNP: DWORD = 0x16; +pub const EVENT_TRACE_TYPE_CONFIG_IDECHANNEL: DWORD = 0x17; +pub const EVENT_TRACE_TYPE_CONFIG_NUMANODE: DWORD = 0x18; +pub const EVENT_TRACE_TYPE_CONFIG_PLATFORM: DWORD = 0x19; +pub const EVENT_TRACE_TYPE_CONFIG_PROCESSORGROUP: DWORD = 0x1A; +pub const EVENT_TRACE_TYPE_CONFIG_PROCESSORNUMBER: DWORD = 0x1B; +pub const EVENT_TRACE_TYPE_CONFIG_DPI: DWORD = 0x1C; +pub const EVENT_TRACE_TYPE_CONFIG_CI_INFO: DWORD = 0x1D; +pub const EVENT_TRACE_TYPE_CONFIG_MACHINEID: DWORD = 0x1E; +pub const EVENT_TRACE_TYPE_CONFIG_DEFRAG: DWORD = 0x1F; +pub const EVENT_TRACE_TYPE_CONFIG_MOBILEPLATFORM: DWORD = 0x20; +pub const EVENT_TRACE_TYPE_CONFIG_DEVICEFAMILY: DWORD = 0x21; +pub const EVENT_TRACE_TYPE_CONFIG_FLIGHTID: DWORD = 0x22; +pub const EVENT_TRACE_TYPE_CONFIG_PROCESSOR: DWORD = 0x23; +pub const EVENT_TRACE_TYPE_OPTICAL_IO_READ: DWORD = 0x37; +pub const EVENT_TRACE_TYPE_OPTICAL_IO_WRITE: DWORD = 0x38; +pub const EVENT_TRACE_TYPE_OPTICAL_IO_FLUSH: DWORD = 0x39; +pub const EVENT_TRACE_TYPE_OPTICAL_IO_READ_INIT: DWORD = 0x3a; +pub const EVENT_TRACE_TYPE_OPTICAL_IO_WRITE_INIT: DWORD = 0x3b; +pub const EVENT_TRACE_TYPE_OPTICAL_IO_FLUSH_INIT: DWORD = 0x3c; +pub const EVENT_TRACE_TYPE_FLT_PREOP_INIT: DWORD = 0x60; +pub const EVENT_TRACE_TYPE_FLT_POSTOP_INIT: DWORD = 0x61; +pub const EVENT_TRACE_TYPE_FLT_PREOP_COMPLETION: DWORD = 0x62; +pub const EVENT_TRACE_TYPE_FLT_POSTOP_COMPLETION: DWORD = 0x63; +pub const EVENT_TRACE_TYPE_FLT_PREOP_FAILURE: DWORD = 0x64; +pub const EVENT_TRACE_TYPE_FLT_POSTOP_FAILURE: DWORD = 0x65; +pub const EVENT_TRACE_FLAG_PROCESS: DWORD = 0x00000001; +pub const EVENT_TRACE_FLAG_THREAD: DWORD = 0x00000002; +pub const EVENT_TRACE_FLAG_IMAGE_LOAD: DWORD = 0x00000004; +pub const EVENT_TRACE_FLAG_DISK_IO: DWORD = 0x00000100; +pub const EVENT_TRACE_FLAG_DISK_FILE_IO: DWORD = 0x00000200; +pub const EVENT_TRACE_FLAG_MEMORY_PAGE_FAULTS: DWORD = 0x00001000; +pub const EVENT_TRACE_FLAG_MEMORY_HARD_FAULTS: DWORD = 0x00002000; +pub const EVENT_TRACE_FLAG_NETWORK_TCPIP: DWORD = 0x00010000; +pub const EVENT_TRACE_FLAG_REGISTRY: DWORD = 0x00020000; +pub const EVENT_TRACE_FLAG_DBGPRINT: DWORD = 0x00040000; +pub const EVENT_TRACE_FLAG_PROCESS_COUNTERS: DWORD = 0x00000008; +pub const EVENT_TRACE_FLAG_CSWITCH: DWORD = 0x00000010; +pub const EVENT_TRACE_FLAG_DPC: DWORD = 0x00000020; +pub const EVENT_TRACE_FLAG_INTERRUPT: DWORD = 0x00000040; +pub const EVENT_TRACE_FLAG_SYSTEMCALL: DWORD = 0x00000080; +pub const EVENT_TRACE_FLAG_DISK_IO_INIT: DWORD = 0x00000400; +pub const EVENT_TRACE_FLAG_ALPC: DWORD = 0x00100000; +pub const EVENT_TRACE_FLAG_SPLIT_IO: DWORD = 0x00200000; +pub const EVENT_TRACE_FLAG_DRIVER: DWORD = 0x00800000; +pub const EVENT_TRACE_FLAG_PROFILE: DWORD = 0x01000000; +pub const EVENT_TRACE_FLAG_FILE_IO: DWORD = 0x02000000; +pub const EVENT_TRACE_FLAG_FILE_IO_INIT: DWORD = 0x04000000; +pub const EVENT_TRACE_FLAG_DISPATCHER: DWORD = 0x00000800; +pub const EVENT_TRACE_FLAG_VIRTUAL_ALLOC: DWORD = 0x00004000; +pub const EVENT_TRACE_FLAG_VAMAP: DWORD = 0x00008000; +pub const EVENT_TRACE_FLAG_NO_SYSCONFIG: DWORD = 0x10000000; +pub const EVENT_TRACE_FLAG_JOB: DWORD = 0x00080000; +pub const EVENT_TRACE_FLAG_DEBUG_EVENTS: DWORD = 0x00400000; +pub const EVENT_TRACE_FLAG_EXTENSION: DWORD = 0x80000000; +pub const EVENT_TRACE_FLAG_FORWARD_WMI: DWORD = 0x40000000; +pub const EVENT_TRACE_FLAG_ENABLE_RESERVE: DWORD = 0x20000000; +pub const EVENT_TRACE_FILE_MODE_NONE: DWORD = 0x00000000; +pub const EVENT_TRACE_FILE_MODE_SEQUENTIAL: DWORD = 0x00000001; +pub const EVENT_TRACE_FILE_MODE_CIRCULAR: DWORD = 0x00000002; +pub const EVENT_TRACE_FILE_MODE_APPEND: DWORD = 0x00000004; +pub const EVENT_TRACE_REAL_TIME_MODE: DWORD = 0x00000100; +pub const EVENT_TRACE_DELAY_OPEN_FILE_MODE: DWORD = 0x00000200; +pub const EVENT_TRACE_BUFFERING_MODE: DWORD = 0x00000400; +pub const EVENT_TRACE_PRIVATE_LOGGER_MODE: DWORD = 0x00000800; +pub const EVENT_TRACE_ADD_HEADER_MODE: DWORD = 0x00001000; +pub const EVENT_TRACE_USE_GLOBAL_SEQUENCE: DWORD = 0x00004000; +pub const EVENT_TRACE_USE_LOCAL_SEQUENCE: DWORD = 0x00008000; +pub const EVENT_TRACE_RELOG_MODE: DWORD = 0x00010000; +pub const EVENT_TRACE_USE_PAGED_MEMORY: DWORD = 0x01000000; +pub const EVENT_TRACE_FILE_MODE_NEWFILE: DWORD = 0x00000008; +pub const EVENT_TRACE_FILE_MODE_PREALLOCATE: DWORD = 0x00000020; +pub const EVENT_TRACE_NONSTOPPABLE_MODE: DWORD = 0x00000040; +pub const EVENT_TRACE_SECURE_MODE: DWORD = 0x00000080; +pub const EVENT_TRACE_USE_KBYTES_FOR_SIZE: DWORD = 0x00002000; +pub const EVENT_TRACE_PRIVATE_IN_PROC: DWORD = 0x00020000; +pub const EVENT_TRACE_MODE_RESERVED: DWORD = 0x00100000; +pub const EVENT_TRACE_NO_PER_PROCESSOR_BUFFERING: DWORD = 0x10000000; +pub const EVENT_TRACE_SYSTEM_LOGGER_MODE: DWORD = 0x02000000; +pub const EVENT_TRACE_ADDTO_TRIAGE_DUMP: DWORD = 0x80000000; +pub const EVENT_TRACE_STOP_ON_HYBRID_SHUTDOWN: DWORD = 0x00400000; +pub const EVENT_TRACE_PERSIST_ON_HYBRID_SHUTDOWN: DWORD = 0x00800000; +pub const EVENT_TRACE_INDEPENDENT_SESSION_MODE: DWORD = 0x08000000; +pub const EVENT_TRACE_COMPRESSED_MODE: DWORD = 0x04000000; +pub const EVENT_TRACE_CONTROL_QUERY: DWORD = 0; +pub const EVENT_TRACE_CONTROL_STOP: DWORD = 1; +pub const EVENT_TRACE_CONTROL_UPDATE: DWORD = 2; +pub const EVENT_TRACE_CONTROL_FLUSH: DWORD = 3; +pub const TRACE_MESSAGE_SEQUENCE: DWORD = 1; +pub const TRACE_MESSAGE_GUID: DWORD = 2; +pub const TRACE_MESSAGE_COMPONENTID: DWORD = 4; +pub const TRACE_MESSAGE_TIMESTAMP: DWORD = 8; +pub const TRACE_MESSAGE_PERFORMANCE_TIMESTAMP: DWORD = 16; +pub const TRACE_MESSAGE_SYSTEMINFO: DWORD = 32; +pub const TRACE_MESSAGE_POINTER32: DWORD = 0x0040; +pub const TRACE_MESSAGE_POINTER64: DWORD = 0x0080; +pub const TRACE_MESSAGE_FLAG_MASK: DWORD = 0xFFFF; +pub const TRACE_MESSAGE_MAXIMUM_SIZE: SIZE_T = 64 * 1024; +pub const EVENT_TRACE_USE_PROCTIME: DWORD = 0x0001; +pub const EVENT_TRACE_USE_NOCPUTIME: DWORD = 0x0002; +pub const TRACE_HEADER_FLAG_USE_TIMESTAMP: DWORD = 0x00000200; +pub const TRACE_HEADER_FLAG_TRACED_GUID: DWORD = 0x00020000; +pub const TRACE_HEADER_FLAG_LOG_WNODE: DWORD = 0x00040000; +pub const TRACE_HEADER_FLAG_USE_GUID_PTR: DWORD = 0x00080000; +pub const TRACE_HEADER_FLAG_USE_MOF_PTR: DWORD = 0x00100000; +ENUM!{enum ETW_COMPRESSION_RESUMPTION_MODE { + EtwCompressionModeRestart = 0, + EtwCompressionModeNoDisable = 1, + EtwCompressionModeNoRestart = 2, +}} +STRUCT!{struct EVENT_TRACE_HEADER_u1_s { + HeaderType: UCHAR, + MarkerFlags: UCHAR, +}} +UNION!{union EVENT_TRACE_HEADER_u1 { + [u16; 1], + FieldTypeFlags FieldTypeFlags_mut: USHORT, + s s_mut: EVENT_TRACE_HEADER_u1_s, +}} +STRUCT!{struct EVENT_TRACE_HEADER_u2_CLASS { + Type: UCHAR, + Level: UCHAR, + Version: USHORT, +}} +UNION!{union EVENT_TRACE_HEADER_u2 { + [u32; 1], + Version Version_mut: ULONG, + Class Class_mut: EVENT_TRACE_HEADER_u2_CLASS, +}} +UNION!{union EVENT_TRACE_HEADER_u3 { + [u64; 2], + Guid Guid_mut: GUID, + GuidPtr GuidPtr_mut: ULONGLONG, +}} +STRUCT!{struct EVENT_TRACE_HEADER_u4_s1 { + ClientContext: ULONG, + Flags: ULONG, +}} +STRUCT!{struct EVENT_TRACE_HEADER_u4_s2 { + KernelTime: ULONG, + UserTime: ULONG, +}} +UNION!{union EVENT_TRACE_HEADER_u4 { + [u64; 1], + s1 s1_mut: EVENT_TRACE_HEADER_u4_s1, + s2 s2_mut: EVENT_TRACE_HEADER_u4_s2, + ProcessorTime ProcessorTime_mut: ULONG64, +}} +STRUCT!{struct EVENT_TRACE_HEADER { + Size: USHORT, + u1: EVENT_TRACE_HEADER_u1, + u2: EVENT_TRACE_HEADER_u2, + ThreadId: ULONG, + ProcessId: ULONG, + TimeStamp: LARGE_INTEGER, + u3: EVENT_TRACE_HEADER_u3, + u4: EVENT_TRACE_HEADER_u4, +}} +pub type PEVENT_TRACE_HEADER = *mut EVENT_TRACE_HEADER; +STRUCT!{struct EVENT_INSTANCE_HEADER_u1_s { + HeaderType: UCHAR, + MarkerFlags: UCHAR, +}} +UNION!{union EVENT_INSTANCE_HEADER_u1 { + [u16; 1], + FieldTypeFlags FieldTypeFlags_mut: USHORT, + s s_mut: EVENT_INSTANCE_HEADER_u1_s, +}} +STRUCT!{struct EVENT_INSTANCE_HEADER_u2_CLASS { + Type: UCHAR, + Level: UCHAR, + Version: USHORT, +}} +UNION!{union EVENT_INSTANCE_HEADER_u2 { + [u32; 1], + Version Version_mut: ULONG, + Class Class_mut: EVENT_INSTANCE_HEADER_u2_CLASS, +}} +STRUCT!{struct EVENT_INSTANCE_HEADER_u3_s1 { + KernelTime: ULONG, + UserTime: ULONG, +}} +STRUCT!{struct EVENT_INSTANCE_HEADER_u3_s2 { + EventId: ULONG, + Flags: ULONG, +}} +UNION!{union EVENT_INSTANCE_HEADER_u3 { + [u64; 1], + s1 s1_mut: EVENT_INSTANCE_HEADER_u3_s1, + ProcessorTime ProcessorTime_mut: ULONG64, + s2 s2_mut: EVENT_INSTANCE_HEADER_u3_s2, +}} +STRUCT!{struct EVENT_INSTANCE_HEADER { + Size: USHORT, + u1: EVENT_INSTANCE_HEADER_u1, + u2: EVENT_INSTANCE_HEADER_u2, + ThreadId: ULONG, + ProcessId: ULONG, + TimeStamp: LARGE_INTEGER, + RegHandle: ULONGLONG, + InstanceId: ULONG, + ParentInstanceId: ULONG, + u3: EVENT_INSTANCE_HEADER_u3, + ParentRegHandle: ULONGLONG, +}} +pub type PEVENT_INSTANCE_HEADER = *mut EVENT_INSTANCE_HEADER; +pub const ETW_NULL_TYPE_VALUE: ULONG = 0; +pub const ETW_OBJECT_TYPE_VALUE: ULONG = 1; +pub const ETW_STRING_TYPE_VALUE: ULONG = 2; +pub const ETW_SBYTE_TYPE_VALUE: ULONG = 3; +pub const ETW_BYTE_TYPE_VALUE: ULONG = 4; +pub const ETW_INT16_TYPE_VALUE: ULONG = 5; +pub const ETW_UINT16_TYPE_VALUE: ULONG = 6; +pub const ETW_INT32_TYPE_VALUE: ULONG = 7; +pub const ETW_UINT32_TYPE_VALUE: ULONG = 8; +pub const ETW_INT64_TYPE_VALUE: ULONG = 9; +pub const ETW_UINT64_TYPE_VALUE: ULONG = 10; +pub const ETW_CHAR_TYPE_VALUE: ULONG = 11; +pub const ETW_SINGLE_TYPE_VALUE: ULONG = 12; +pub const ETW_DOUBLE_TYPE_VALUE: ULONG = 13; +pub const ETW_BOOLEAN_TYPE_VALUE: ULONG = 14; +pub const ETW_DECIMAL_TYPE_VALUE: ULONG = 15; +pub const ETW_GUID_TYPE_VALUE: ULONG = 101; +pub const ETW_ASCIICHAR_TYPE_VALUE: ULONG = 102; +pub const ETW_ASCIISTRING_TYPE_VALUE: ULONG = 103; +pub const ETW_COUNTED_STRING_TYPE_VALUE: ULONG = 104; +pub const ETW_POINTER_TYPE_VALUE: ULONG = 105; +pub const ETW_SIZET_TYPE_VALUE: ULONG = 106; +pub const ETW_HIDDEN_TYPE_VALUE: ULONG = 107; +pub const ETW_BOOL_TYPE_VALUE: ULONG = 108; +pub const ETW_COUNTED_ANSISTRING_TYPE_VALUE: ULONG = 109; +pub const ETW_REVERSED_COUNTED_STRING_TYPE_VALUE: ULONG = 110; +pub const ETW_REVERSED_COUNTED_ANSISTRING_TYPE_VALUE: ULONG = 111; +pub const ETW_NON_NULL_TERMINATED_STRING_TYPE_VALUE: ULONG = 112; +pub const ETW_REDUCED_ANSISTRING_TYPE_VALUE: ULONG = 113; +pub const ETW_REDUCED_STRING_TYPE_VALUE: ULONG = 114; +pub const ETW_SID_TYPE_VALUE: ULONG = 115; +pub const ETW_VARIANT_TYPE_VALUE: ULONG = 116; +pub const ETW_PTVECTOR_TYPE_VALUE: ULONG = 117; +pub const ETW_WMITIME_TYPE_VALUE: ULONG = 118; +pub const ETW_DATETIME_TYPE_VALUE: ULONG = 119; +pub const ETW_REFRENCE_TYPE_VALUE: ULONG = 120; +// TODO: DEFINE_TRACE_MOF_FIELD +STRUCT!{struct MOF_FIELD { + DataPtr: ULONG64, + Length: ULONG, + DataType: ULONG, +}} +pub type PMOF_FIELD = *mut MOF_FIELD; +STRUCT!{struct TRACE_LOGFILE_HEADER_u1_VERSIONDETAIL { + MajorVersion: UCHAR, + MinorVersion: UCHAR, + SubVersion: UCHAR, + SubMinorVersion: UCHAR, +}} +UNION!{union TRACE_LOGFILE_HEADER_u1 { + [u32; 1], + Version Version_mut: ULONG, + VersionDetail VersionDetail_mut: TRACE_LOGFILE_HEADER_u1_VERSIONDETAIL, +}} +STRUCT!{struct TRACE_LOGFILE_HEADER_u2_s { + StartBuffers: ULONG, + PointerSize: ULONG, + EventsLost: ULONG, + CpuSpeedInMHz: ULONG, +}} +UNION!{union TRACE_LOGFILE_HEADER_u2 { + [u32; 4], + LogInstanceGuid LogInstanceGuid_mut: GUID, + s s_mut: TRACE_LOGFILE_HEADER_u2_s, +}} +STRUCT!{struct TRACE_LOGFILE_HEADER { + BufferSize: ULONG, + u1: TRACE_LOGFILE_HEADER_u1, + ProviderVersion: ULONG, + NumberOfProcessors: ULONG, + EndTime: LARGE_INTEGER, + TimerResolution: ULONG, + MaximumFileSize: ULONG, + LogFileMode: ULONG, + BuffersWritten: ULONG, + u2: TRACE_LOGFILE_HEADER_u2, + LoggerName: LPWSTR, + LogFileName: LPWSTR, + TimeZone: TIME_ZONE_INFORMATION, + BootTime: LARGE_INTEGER, + PrefFreq: LARGE_INTEGER, + StartTime: LARGE_INTEGER, + ReservedFlags: ULONG, + BuffersLost: ULONG, +}} +pub type PTRACE_LOGFILE_HEADER = *mut TRACE_LOGFILE_HEADER; +STRUCT!{struct TRACE_LOGFILE_HEADER32 { + BufferSize: ULONG, + u1: TRACE_LOGFILE_HEADER_u1, + ProviderVersion: ULONG, + NumberOfProcessors: ULONG, + EndTime: LARGE_INTEGER, + TimerResolution: ULONG, + MaximumFileSize: ULONG, + LogFileMode: ULONG, + BuffersWritten: ULONG, + u2: TRACE_LOGFILE_HEADER_u2, + LoggerName: ULONG32, + LogFileName: ULONG32, + TimeZone: TIME_ZONE_INFORMATION, + BootTime: LARGE_INTEGER, + PrefFreq: LARGE_INTEGER, + StartTime: LARGE_INTEGER, + ReservedFlags: ULONG, + BuffersLost: ULONG, +}} +pub type PTRACE_LOGFILE_HEADER32 = *mut TRACE_LOGFILE_HEADER32; +STRUCT!{struct TRACE_LOGFILE_HEADER64 { + BufferSize: ULONG, + u1: TRACE_LOGFILE_HEADER_u1, + ProviderVersion: ULONG, + NumberOfProcessors: ULONG, + EndTime: LARGE_INTEGER, + TimerResolution: ULONG, + MaximumFileSize: ULONG, + LogFileMode: ULONG, + BuffersWritten: ULONG, + u2: TRACE_LOGFILE_HEADER_u2, + LoggerName: ULONG64, + LogFileName: ULONG64, + TimeZone: TIME_ZONE_INFORMATION, + BootTime: LARGE_INTEGER, + PrefFreq: LARGE_INTEGER, + StartTime: LARGE_INTEGER, + ReservedFlags: ULONG, + BuffersLost: ULONG, +}} +pub type PTRACE_LOGFILE_HEADER64 = *mut TRACE_LOGFILE_HEADER64; +STRUCT!{struct EVENT_INSTANCE_INFO { + RegHandle: HANDLE, + InstanceId: ULONG, +}} +pub type PEVENT_INSTANCE_INFO = *mut EVENT_INSTANCE_INFO; +UNION!{union EVENT_TRACE_PROPERTIES_u { + [u32; 1], + AgeLimit AgeLimit_mut: LONG, + FlushThreshold FlushThreshold_mut: LONG, +}} +STRUCT!{struct EVENT_TRACE_PROPERTIES { + Wnode: WNODE_HEADER, + BufferSize: ULONG, + MinimumBuffers: ULONG, + MaximumBuffers: ULONG, + MaximumFileSize: ULONG, + LogFileMode: ULONG, + FlushTimer: ULONG, + EnableFlags: ULONG, + u: EVENT_TRACE_PROPERTIES_u, + NumberOfBuffers: ULONG, + FreeBuffers: ULONG, + EventsLost: ULONG, + BuffersWritten: ULONG, + LogBuffersLost: ULONG, + RealTimeBuffersLost: ULONG, + LoggerThreadId: HANDLE, + LogFileNameOffset: ULONG, + LoggerNameOffset: ULONG, +}} +pub type PEVENT_TRACE_PROPERTIES = *mut EVENT_TRACE_PROPERTIES; +UNION!{union EVENT_TRACE_PROPERTIES_V2_u1 { + [u32; 1], + AgeLimit AgeLimit_mut: LONG, + FlushThreshold FlushThreshold_mut: LONG, +}} +STRUCT!{struct EVENT_TRACE_PROPERTIES_V2_u2_s { + bitfield: ULONG, +}} +BITFIELD!{EVENT_TRACE_PROPERTIES_V2_u2_s bitfield: ULONG [ + VersionNumber set_VersionNumber[0..8], +]} +UNION!{union EVENT_TRACE_PROPERTIES_V2_u2 { + [u32; 1], + s s_mut: EVENT_TRACE_PROPERTIES_V2_u2_s, + V2Control V2Control_mut: ULONG, +}} +STRUCT!{struct EVENT_TRACE_PROPERTIES_V2_u3_s { + bitfield: ULONG, +}} +BITFIELD!{EVENT_TRACE_PROPERTIES_V2_u3_s bitfield: ULONG [ + Wow set_Wow[0..1], +]} +UNION!{union EVENT_TRACE_PROPERTIES_V2_u3 { + [u64; 1], + s s_mut: EVENT_TRACE_PROPERTIES_V2_u3_s, + V2Options V2Options_mut: ULONG64, +}} +STRUCT!{struct EVENT_TRACE_PROPERTIES_V2 { + Wnode: WNODE_HEADER, + BufferSize: ULONG, + MinimumBuffers: ULONG, + MaximumBuffers: ULONG, + MaximumFileSize: ULONG, + LogFileMode: ULONG, + FlushTimer: ULONG, + EnableFlags: ULONG, + u1: EVENT_TRACE_PROPERTIES_u, + NumberOfBuffers: ULONG, + FreeBuffers: ULONG, + EventsLost: ULONG, + BuffersWritten: ULONG, + LogBuffersLost: ULONG, + RealTimeBuffersLost: ULONG, + LoggerThreadId: HANDLE, + LogFileNameOffset: ULONG, + LoggerNameOffset: ULONG, + u2: EVENT_TRACE_PROPERTIES_V2_u2, + FilterDescCount: ULONG, + FilterDesc: PEVENT_FILTER_DESCRIPTOR, + u3: EVENT_TRACE_PROPERTIES_V2_u3, +}} +pub type PEVENT_TRACE_PROPERTIES_V2 = *mut EVENT_TRACE_PROPERTIES_V2; +STRUCT!{struct TRACE_GUID_REGISTRATION { + Guid: LPCGUID, + RegHandle: HANDLE, +}} +pub type PTRACE_GUID_REGISTRATION = *mut TRACE_GUID_REGISTRATION; +STRUCT!{struct TRACE_GUID_PROPERTIES { + Guid: GUID, + GuidType: ULONG, + LoggerId: ULONG, + EnableLevel: ULONG, + EnableFlags: ULONG, + IsEnable: BOOLEAN, +}} +pub type PTRACE_GUID_PROPERTIES = *mut TRACE_GUID_PROPERTIES; +STRUCT!{struct ETW_BUFFER_CONTEXT_u_s { + ProcessorNumber: UCHAR, + Alignment: UCHAR, +}} +UNION!{union ETW_BUFFER_CONTEXT_u { + [u16; 1], + s s_mut: ETW_BUFFER_CONTEXT_u_s, + ProcessorIndex ProcessorIndex_mut: USHORT, +}} +STRUCT!{struct ETW_BUFFER_CONTEXT { + u: ETW_BUFFER_CONTEXT_u, + LoggerId: USHORT, +}} +pub type PETW_BUFFER_CONTEXT = *mut ETW_BUFFER_CONTEXT; +pub const TRACE_PROVIDER_FLAG_LEGACY: ULONG = 0x00000001; +pub const TRACE_PROVIDER_FLAG_PRE_ENABLE: ULONG = 0x00000002; +STRUCT!{struct TRACE_ENABLE_INFO { + IsEnabled: ULONG, + Level: UCHAR, + Reserved1: UCHAR, + LoggerId: USHORT, + EnabledProperty: ULONG, + Reserved2: ULONG, + MatchAnyKeyword: ULONGLONG, + MatchAllKeyword: ULONGLONG, +}} +pub type PTRACE_ENABLE_INFO = *mut TRACE_ENABLE_INFO; +STRUCT!{struct TRACE_PROVIDER_INSTANCE_INFO { + NameOffset: ULONG, + EnableCount: ULONG, + Pid: ULONG, + Flags: ULONG, +}} +pub type PTRACE_PROVIDER_INSTANCE_INFO = *mut TRACE_PROVIDER_INSTANCE_INFO; +STRUCT!{struct TRACE_GUID_INFO { + InstanceCount: ULONG, + Reserved: ULONG, +}} +pub type PTRACE_GUID_INFO = *mut TRACE_GUID_INFO; +STRUCT!{struct PROFILE_SOURCE_INFO { + NextEntryOffset: ULONG, + Source: ULONG, + MinInterval: ULONG, + MaxInterval: ULONG, + Reserved: ULONG64, + Description: [WCHAR; ANYSIZE_ARRAY], +}} +pub type PPROFILE_SOURCE_INFO = *mut PROFILE_SOURCE_INFO; +UNION!{union EVENT_TRACE_u { + [u32; 1], + ClientContext ClientContext_mut: ULONG, + BufferContext BufferContext_mut: ETW_BUFFER_CONTEXT, +}} +STRUCT!{struct EVENT_TRACE { + Header: EVENT_TRACE_HEADER, + InstanceId: ULONG, + ParentInstanceId: ULONG, + ParentGuid: GUID, + MofData: PVOID, + MofLength: ULONG, + u: EVENT_TRACE_u, +}} +pub type PEVENT_TRACE = *mut EVENT_TRACE; +pub const EVENT_CONTROL_CODE_DISABLE_PROVIDER: ULONG = 0; +pub const EVENT_CONTROL_CODE_ENABLE_PROVIDER: ULONG = 1; +pub const EVENT_CONTROL_CODE_CAPTURE_STATE: ULONG = 2; +FN!{stdcall PEVENT_TRACE_BUFFER_CALLBACKW( + PEVENT_TRACE_LOGFILEW, +) -> ULONG} +FN!{stdcall PEVENT_TRACE_BUFFER_CALLBACKA( + PEVENT_TRACE_LOGFILEA, +) -> ULONG} +FN!{stdcall PEVENT_CALLBACK( + pEvent: PEVENT_TRACE, +) -> ()} +FN!{stdcall PEVENT_RECORD_CALLBACK( + EventRecord: PEVENT_RECORD, +) -> ()} +FN!{stdcall WMIDPREQUEST( + RequestCode: WMIDPREQUESTCODE, + RequestContext: PVOID, + BufferSize: *mut ULONG, + Buffer: PVOID, +) -> ULONG} +UNION!{union EVENT_TRACE_LOGFILE_u1 { + [u32; 1], + LogFileMode LogFileMode_mut: ULONG, + ProcessTraceMode ProcessTraceMode_mut: ULONG, +}} +UNION!{union EVENT_TRACE_LOGFILE_u2 { + [u32; 1] [u64; 1], + EventCallback EventCallback_mut: PEVENT_CALLBACK, + EventRecordCallback EventRecordCallback_mut: PEVENT_RECORD_CALLBACK, +}} +STRUCT!{struct EVENT_TRACE_LOGFILEW { + LogFileName: LPWSTR, + LoggerName: LPWSTR, + CurrentTime: LONGLONG, + BuffersRead: ULONG, + u1: EVENT_TRACE_LOGFILE_u1, + CurrentEvent: EVENT_TRACE, + LogfileHeader: TRACE_LOGFILE_HEADER, + BufferCallback: PEVENT_TRACE_BUFFER_CALLBACKW, + BufferSize: ULONG, + Filled: ULONG, + EventsLost: ULONG, + u2: EVENT_TRACE_LOGFILE_u2, + IsKernelTrace: ULONG, + Context: PVOID, +}} +pub type PEVENT_TRACE_LOGFILEW = *mut EVENT_TRACE_LOGFILEW; +STRUCT!{struct EVENT_TRACE_LOGFILEA { + LogFileName: LPSTR, + LoggerName: LPSTR, + CurrentTime: LONGLONG, + BuffersRead: ULONG, + u1: EVENT_TRACE_LOGFILE_u1, + CurrentEvent: EVENT_TRACE, + LogfileHeader: TRACE_LOGFILE_HEADER, + BufferCallback: PEVENT_TRACE_BUFFER_CALLBACKA, + BufferSize: ULONG, + Filled: ULONG, + EventsLost: ULONG, + u2: EVENT_TRACE_LOGFILE_u2, + IsKernelTrace: ULONG, + Context: PVOID, +}} +pub type PEVENT_TRACE_LOGFILEA = *mut EVENT_TRACE_LOGFILEA; +extern "system" { + pub fn StartTraceW( + SessionHandle: PTRACEHANDLE, + SessionName: LPCWSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ) -> ULONG; + pub fn StartTraceA( + SessionHandle: PTRACEHANDLE, + SessionName: LPCSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ) -> ULONG; + pub fn StopTraceW( + SessionHandle: TRACEHANDLE, + SessionName: LPCWSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ) -> ULONG; + pub fn StopTraceA( + SessionHandle: TRACEHANDLE, + SessionName: LPCSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ) -> ULONG; + pub fn QueryTraceW( + SessionHandle: TRACEHANDLE, + SessionName: LPCWSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ) -> ULONG; + pub fn QueryTraceA( + SessionHandle: TRACEHANDLE, + SessionName: LPCSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ) -> ULONG; + pub fn UpdateTraceW( + SessionHandle: TRACEHANDLE, + SessionName: LPCWSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ) -> ULONG; + pub fn UpdateTraceA( + SessionHandle: TRACEHANDLE, + SessionName: LPCSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ) -> ULONG; + pub fn FlushTraceW( + SessionHandle: TRACEHANDLE, + SessionName: LPCWSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ) -> ULONG; + pub fn FlushTraceA( + SessionHandle: TRACEHANDLE, + SessionName: LPCSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ) -> ULONG; + pub fn ControlTraceW( + SessionHandle: TRACEHANDLE, + SessionName: LPCWSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ControlCode: ULONG, + ) -> ULONG; + pub fn ControlTraceA( + SessionHandle: TRACEHANDLE, + SessionName: LPCSTR, + Properties: PEVENT_TRACE_PROPERTIES, + ControlCode: ULONG, + ) -> ULONG; + pub fn QueryAllTracesW( + PropertyArray: *mut PEVENT_TRACE_PROPERTIES, + PropertyArrayCount: ULONG, + SessionCount: PULONG, + ) -> ULONG; + pub fn QueryAllTracesA( + PropertyArray: *mut PEVENT_TRACE_PROPERTIES, + PropertyArrayCount: ULONG, + SessionCount: PULONG, + ) -> ULONG; + pub fn EnableTrace( + Enable: ULONG, + EnableFlag: ULONG, + EnableLevel: ULONG, + ControlGuid: LPCGUID, + SessionHandle: TRACEHANDLE, + ) -> ULONG; + pub fn EnableTraceEx( + ProviderId: LPCGUID, + SourceId: LPCGUID, + TraceHandle: TRACEHANDLE, + IsEnabled: ULONG, + Level: UCHAR, + MatchAnyKeyword: ULONGLONG, + MatchAllKeyword: ULONGLONG, + EnableProperty: ULONG, + EnableFilterDesc: PEVENT_FILTER_DESCRIPTOR, + ) -> ULONG; +} +pub const ENABLE_TRACE_PARAMETERS_VERSION: ULONG = 1; +pub const ENABLE_TRACE_PARAMETERS_VERSION_2: ULONG = 2; +STRUCT!{struct ENABLE_TRACE_PARAMETERS_V1 { + Version: ULONG, + EnableProperty: ULONG, + ControlFlags: ULONG, + SourceId: GUID, + EnableFilterDesc: PEVENT_FILTER_DESCRIPTOR, +}} +pub type PENABLE_TRACE_PARAMETERS_V1 = *mut ENABLE_TRACE_PARAMETERS_V1; +STRUCT!{struct ENABLE_TRACE_PARAMETERS { + Version: ULONG, + EnableProperty: ULONG, + ControlFlags: ULONG, + SourceId: GUID, + EnableFilterDesc: PEVENT_FILTER_DESCRIPTOR, + FilterDescCount: ULONG, +}} +pub type PENABLE_TRACE_PARAMETERS = *mut ENABLE_TRACE_PARAMETERS; +extern "system" { + pub fn EnableTraceEx2( + TraceHandle: TRACEHANDLE, + ProviderId: LPCGUID, + ControlCode: ULONG, + Level: UCHAR, + MatchAnyKeyword: ULONGLONG, + MatchAllKeyword: ULONGLONG, + Timeout: ULONG, + EnableParameters: PENABLE_TRACE_PARAMETERS, + ) -> ULONG; +} +ENUM!{enum TRACE_QUERY_INFO_CLASS { + TraceGuidQueryList, + TraceGuidQueryInfo, + TraceGuidQueryProcess, + TraceStackTracingInfo, + TraceSystemTraceEnableFlagsInfo, + TraceSampledProfileIntervalInfo, + TraceProfileSourceConfigInfo, + TraceProfileSourceListInfo, + TracePmcEventListInfo, + TracePmcCounterListInfo, + TraceSetDisallowList, + TraceVersionInfo, + TraceGroupQueryList, + TraceGroupQueryInfo, + TraceDisallowListQuery, + TraceCompressionInfo, + TracePeriodicCaptureStateListInfo, + TracePeriodicCaptureStateInfo, + TraceProviderBinaryTracking, + TraceMaxLoggersQuery, + MaxTraceSetInfoClass, +}} +pub type TRACE_INFO_CLASS = TRACE_QUERY_INFO_CLASS; +extern "system" { + pub fn EnumerateTraceGuidsEx( + TraceQueryInfoClass: TRACE_QUERY_INFO_CLASS, + InBuffer: PVOID, + InBufferSize: ULONG, + OutBuffer: PVOID, + OutBufferSize: ULONG, + ReturnLength: PULONG, + ) -> ULONG; +} +STRUCT!{struct CLASSIC_EVENT_ID { + EventGuid: GUID, + Type: UCHAR, + Reserved: [UCHAR; 7], +}} +pub type PCLASSIC_EVENT_ID = *mut CLASSIC_EVENT_ID; +STRUCT!{struct TRACE_PROFILE_INTERVAL { + Source: ULONG, + Interval: ULONG, +}} +pub type PTRACE_PROFILE_INTERVAL = *mut TRACE_PROFILE_INTERVAL; +STRUCT!{struct TRACE_VERSION_INFO { + EtwTraceProcessingVersion: UINT, + Reserved: UINT, +}} +pub type PTRACE_VERSION_INFO = *mut TRACE_VERSION_INFO; +STRUCT!{struct TRACE_PERIODIC_CAPTURE_STATE_INFO { + CaptureStateFrequencyInSeconds: ULONG, + ProviderCount: USHORT, + Reserved: USHORT, +}} +pub type PTRACE_PERIODIC_CAPTURE_STATE_INFO = *mut TRACE_PERIODIC_CAPTURE_STATE_INFO; +extern "system" { + pub fn TraceSetInformation( + SessionHandle: TRACEHANDLE, + InformationClass: TRACE_INFO_CLASS, + TraceInformation: PVOID, + InformationLength: ULONG, + ) -> ULONG; + pub fn TraceQueryInformation( + SessionHandle: TRACEHANDLE, + InformationClass: TRACE_QUERY_INFO_CLASS, + TraceInformation: PVOID, + InformationLength: ULONG, + ReturnLength: PULONG, + ) -> ULONG; + pub fn CreateTraceInstanceId( + RegHandle: HANDLE, + pInstInfo: PEVENT_INSTANCE_INFO, + ) -> ULONG; + pub fn TraceEvent( + SessionHandle: TRACEHANDLE, + EventTrace: PEVENT_TRACE_HEADER, + ) -> ULONG; + pub fn TraceEventInstance( + SessionHandle: TRACEHANDLE, + EventTrace: PEVENT_TRACE_HEADER, + pInstInfo: PEVENT_INSTANCE_INFO, + pParentInstInfo: PEVENT_INSTANCE_INFO, + ) -> ULONG; + pub fn RegisterTraceGuidsW( + RequestAddress: WMIDPREQUEST, + RequestContext: PVOID, + ControlGuid: LPCGUID, + GuidCount: ULONG, + TraceGuidReg: PTRACE_GUID_REGISTRATION, + MofImagePath: LPCWSTR, + MofResourceName: LPCWSTR, + RegistrationHandle: PTRACEHANDLE, + ) -> ULONG; + pub fn RegisterTraceGuidsA( + RequestAddress: WMIDPREQUEST, + RequestContext: PVOID, + ControlGuid: LPCGUID, + GuidCount: ULONG, + TraceGuidReg: PTRACE_GUID_REGISTRATION, + MofImagePath: LPCSTR, + MofResourceName: LPCSTR, + RegistrationHandle: PTRACEHANDLE, + ) -> ULONG; + pub fn EnumerateTraceGuids( + GuidPropertiesArray: *mut PTRACE_GUID_PROPERTIES, + PropertyArrayCount: ULONG, + GuidCount: PULONG, + ) -> ULONG; + pub fn UnregisterTraceGuids( + RegistrationHandle: TRACEHANDLE, + ) -> ULONG; + pub fn GetTraceLoggerHandle( + Buffer: PVOID, + ) -> TRACEHANDLE; + pub fn GetTraceEnableLevel( + SessionHandle: TRACEHANDLE, + ) -> UCHAR; + pub fn GetTraceEnableFlags( + SessionHandle: TRACEHANDLE, + ) -> ULONG; + pub fn OpenTraceW( + Logfile: PEVENT_TRACE_LOGFILEW, + ) -> TRACEHANDLE; + pub fn ProcessTrace( + HandleArray: PTRACEHANDLE, + HandleCount: ULONG, + StartTime: LPFILETIME, + EndTime: LPFILETIME, + ) -> ULONG; + pub fn CloseTrace( + TraceHandle: TRACEHANDLE, + ) -> ULONG; +} +ENUM!{enum ETW_PROCESS_HANDLE_INFO_TYPE { + EtwQueryPartitionInformation = 1, + EtwQueryProcessHandleInfoMax, +}} +STRUCT!{struct ETW_TRACE_PARTITION_INFORMATION { + PartitionId: GUID, + ParentId: GUID, + Reserved: ULONG64, + PartitionType: ULONG, +}} +pub type PETW_TRACE_PARTITION_INFORMATION = *mut ETW_TRACE_PARTITION_INFORMATION; +extern "system" { + pub fn QueryTraceProcessingHandle( + ProcessingHandle: TRACEHANDLE, + InformationClass: ETW_PROCESS_HANDLE_INFO_TYPE, + InBuffer: PVOID, + InBufferSize: ULONG, + OutBuffer: PVOID, + OutBufferSize: ULONG, + ReturnLength: PULONG, + ) -> ULONG; + pub fn OpenTraceA( + Logfile: PEVENT_TRACE_LOGFILEA, + ) -> TRACEHANDLE; + pub fn SetTraceCallback( + pGuid: LPCGUID, + EventCallback: PEVENT_CALLBACK, + ) -> ULONG; + pub fn RemoveTraceCallback( + pGuid: LPCGUID, + ) -> ULONG; +} +extern "C" { + pub fn TraceMessage( + SessionHandle: TRACEHANDLE, + MessageFlags: ULONG, + MessageGuid: LPGUID, + MessageNumber: USHORT, + ... + ) -> ULONG; + pub fn TraceMessageVa( + SessionHandle: TRACEHANDLE, + MessageFlags: ULONG, + MessageGuid: LPGUID, + MessageNumber: USHORT, + MessageArgList: va_list, + ); +} +pub const INVALID_PROCESSTRACE_HANDLE: TRACEHANDLE = INVALID_HANDLE_VALUE as TRACEHANDLE; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/guiddef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/guiddef.rs new file mode 100644 index 0000000..dcd39dc --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/guiddef.rs @@ -0,0 +1,36 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! GUID definition +use ctypes::{c_uchar, c_ulong, c_ushort}; +STRUCT!{#[debug] struct GUID { + Data1: c_ulong, + Data2: c_ushort, + Data3: c_ushort, + Data4: [c_uchar; 8], +}} +pub type LPGUID = *mut GUID; +pub type LPCGUID = *const GUID; +pub type IID = GUID; +pub type LPIID = *mut IID; +pub use self::IsEqualGUID as IsEqualIID; +pub type CLSID = GUID; +pub type LPCLSID = *mut CLSID; +pub use self::IsEqualGUID as IsEqualCLSID; +pub type FMTID = GUID; +pub type LPFMTID = *mut FMTID; +pub use self::IsEqualGUID as IsEqualFMTID; +pub type REFGUID = *const GUID; +pub type REFIID = *const IID; +pub type REFCLSID = *const IID; +pub type REFFMTID = *const IID; +DEFINE_GUID!{IID_NULL, + 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} +#[inline] +pub fn IsEqualGUID(g1: &GUID, g2: &GUID) -> bool { + let a = unsafe { &*(g1 as *const _ as *const [u32; 4]) }; + let b = unsafe { &*(g2 as *const _ as *const [u32; 4]) }; + a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3] +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidclass.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidclass.rs new file mode 100644 index 0000000..c65c14f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidclass.rs @@ -0,0 +1,68 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, PUCHAR, UCHAR, ULONG, USHORT}; +use um::winioctl::{ + FILE_ANY_ACCESS, FILE_DEVICE_KEYBOARD, METHOD_BUFFERED, METHOD_IN_DIRECT, METHOD_NEITHER, + METHOD_OUT_DIRECT, +}; +use um::winnt::BOOLEAN; +DEFINE_GUID!{GUID_DEVINTERFACE_HID, + 0x4D1E55B2, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30} +pub const GUID_CLASS_INPUT: GUID = GUID_DEVINTERFACE_HID; +DEFINE_GUID!{GUID_HID_INTERFACE_NOTIFY, + 0x2c4e2e88, 0x25e6, 0x4c33, 0x88, 0x2f, 0x3d, 0x82, 0xe6, 0x07, 0x36, 0x81} +DEFINE_GUID!{GUID_HID_INTERFACE_HIDPARSE, + 0xf5c315a5, 0x69ac, 0x4bc2, 0x92, 0x79, 0xd0, 0xb6, 0x45, 0x76, 0xf4, 0x4b} +// FIXME devpropkey stuff +pub const HID_REVISION: DWORD = 0x00000001; +pub const IOCTL_HID_GET_DRIVER_CONFIG: DWORD = HID_BUFFER_CTL_CODE!(100); +pub const IOCTL_HID_SET_DRIVER_CONFIG: DWORD = HID_BUFFER_CTL_CODE!(101); +pub const IOCTL_HID_GET_POLL_FREQUENCY_MSEC: DWORD = HID_BUFFER_CTL_CODE!(102); +pub const IOCTL_HID_SET_POLL_FREQUENCY_MSEC: DWORD = HID_BUFFER_CTL_CODE!(103); +pub const IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS: DWORD = HID_BUFFER_CTL_CODE!(104); +pub const IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS: DWORD = HID_BUFFER_CTL_CODE!(105); +pub const IOCTL_HID_GET_COLLECTION_INFORMATION: DWORD = HID_BUFFER_CTL_CODE!(106); +pub const IOCTL_HID_ENABLE_WAKE_ON_SX: DWORD = HID_BUFFER_CTL_CODE!(107); +pub const IOCTL_HID_SET_S0_IDLE_TIMEOUT: DWORD = HID_BUFFER_CTL_CODE!(108); +pub const IOCTL_HID_GET_COLLECTION_DESCRIPTOR: DWORD = HID_CTL_CODE!(100); +pub const IOCTL_HID_FLUSH_QUEUE: DWORD = HID_CTL_CODE!(101); +pub const IOCTL_HID_SET_FEATURE: DWORD = HID_IN_CTL_CODE!(100); +pub const IOCTL_HID_SET_OUTPUT_REPORT: DWORD = HID_IN_CTL_CODE!(101); +pub const IOCTL_HID_GET_FEATURE: DWORD = HID_OUT_CTL_CODE!(100); +pub const IOCTL_GET_PHYSICAL_DESCRIPTOR: DWORD = HID_OUT_CTL_CODE!(102); +pub const IOCTL_HID_GET_HARDWARE_ID: DWORD = HID_OUT_CTL_CODE!(103); +pub const IOCTL_HID_GET_INPUT_REPORT: DWORD = HID_OUT_CTL_CODE!(104); +pub const IOCTL_HID_GET_OUTPUT_REPORT: DWORD = HID_OUT_CTL_CODE!(105); +pub const IOCTL_HID_GET_MANUFACTURER_STRING: DWORD = HID_OUT_CTL_CODE!(110); +pub const IOCTL_HID_GET_PRODUCT_STRING: DWORD = HID_OUT_CTL_CODE!(111); +pub const IOCTL_HID_GET_SERIALNUMBER_STRING: DWORD = HID_OUT_CTL_CODE!(112); +pub const IOCTL_HID_GET_INDEXED_STRING: DWORD = HID_OUT_CTL_CODE!(120); +pub const IOCTL_HID_GET_MS_GENRE_DESCRIPTOR: DWORD = HID_OUT_CTL_CODE!(121); +pub const IOCTL_HID_ENABLE_SECURE_READ: DWORD = HID_CTL_CODE!(130); +pub const IOCTL_HID_DISABLE_SECURE_READ: DWORD = HID_CTL_CODE!(131); +pub const IOCTL_HID_DEVICERESET_NOTIFICATION: DWORD = HID_CTL_CODE!(140); +STRUCT!{struct HID_XFER_PACKET { + reportBuffer: PUCHAR, + reportBufferLen: ULONG, + reportId: UCHAR, +}} +pub type PHID_XFER_PACKET = *mut HID_XFER_PACKET; +//FIXME Stuff for NT_INCLUDED +STRUCT!{struct HID_COLLECTION_INFORMATION { + DescriptorSize: ULONG, + Polled: BOOLEAN, + Reserved1: [UCHAR; 1], + VendorID: USHORT, + ProductID: USHORT, + VersionNumber: USHORT, +}} +pub type PHID_COLLECTION_INFORMATION = *mut HID_COLLECTION_INFORMATION; +STRUCT!{struct HID_DRIVER_CONFIG { + Size: ULONG, + RingBufferSize: ULONG, +}} +pub type PHID_DRIVER_CONFIG = *mut HID_DRIVER_CONFIG; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidpi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidpi.rs new file mode 100644 index 0000000..ea02292 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidpi.rs @@ -0,0 +1,393 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::hidusage::{PUSAGE, USAGE}; +use shared::minwindef::{PUCHAR, PULONG, PUSHORT, UCHAR, ULONG, USHORT}; +use shared::ntdef::NTSTATUS; +use shared::ntstatus::FACILITY_HID_ERROR_CODE; +use um::winnt::{BOOLEAN, LONG, PCHAR, PLONG, PVOID}; +pub const HIDP_LINK_COLLECTION_ROOT: USHORT = -1i16 as u16; +pub const HIDP_LINK_COLLECTION_UNSPECIFIED: USHORT = 0; +ENUM!{enum HIDP_REPORT_TYPE { + HidP_Input, + HidP_Output, + HidP_Feature, +}} +STRUCT!{struct USAGE_AND_PAGE { + Usage: USAGE, + UsagePage: USAGE, +}} +pub type PUSAGE_AND_PAGE = *mut USAGE_AND_PAGE; +// HidP_IsSameUsageAndPage +STRUCT!{struct HIDP_CAPS_Range { + UsageMin: USAGE, + UsageMax: USAGE, + StringMin: USHORT, + StringMax: USHORT, + DesignatorMin: USHORT, + DesignatorMax: USHORT, + DataIndexMin: USHORT, + DataIndexMax: USHORT, +}} +STRUCT!{struct HIDP_CAPS_NotRange { + Usage: USAGE, + Reserved1: USAGE, + StringIndex: USHORT, + Reserved2: USHORT, + DesignatorIndex: USHORT, + Reserved3: USHORT, + DataIndex: USHORT, + Reserved4: USHORT, +}} +UNION!{union HIDP_CAPS_u { + [u16; 8], + Range Range_mut: HIDP_CAPS_Range, + NotRange NotRange_mut: HIDP_CAPS_NotRange, +}} +STRUCT!{struct HIDP_BUTTON_CAPS { + UsagePage: USAGE, + ReportID: UCHAR, + IsAlias: BOOLEAN, + BitField: USHORT, + LinkCollection: USHORT, + LinkUsage: USAGE, + LinkUsagePage: USAGE, + IsRange: BOOLEAN, + IsStringRange: BOOLEAN, + IsDesignatorRange: BOOLEAN, + IsAbsolute: BOOLEAN, + Reserved: [ULONG; 10], + u: HIDP_CAPS_u, +}} +pub type PHIDP_BUTTON_CAPS = *mut HIDP_BUTTON_CAPS; +STRUCT!{struct HIDP_VALUE_CAPS { + UsagePage: USAGE, + ReportID: UCHAR, + IsAlias: BOOLEAN, + BitField: USHORT, + LinkCollection: USHORT, + LinkUsage: USAGE, + LinkUsagePage: USAGE, + IsRange: BOOLEAN, + IsStringRange: BOOLEAN, + IsDesignatorRange: BOOLEAN, + IsAbsolute: BOOLEAN, + HasNull: BOOLEAN, + Reserved: UCHAR, + BitSize: USHORT, + ReportCount: USHORT, + Reserved2: [USHORT; 5], + UnitsExp: ULONG, + Units: ULONG, + LogicalMin: LONG, + LogicalMax: LONG, + PhysicalMin: LONG, + PhysicalMax: LONG, + u: HIDP_CAPS_u, +}} +pub type PHIDP_VALUE_CAPS = *mut HIDP_VALUE_CAPS; +STRUCT!{struct HIDP_LINK_COLLECTION_NODE { + LinkUsage: USAGE, + LinkUsagePage: USAGE, + Parent: USHORT, + NumberOfChildren: USHORT, + NextSibling: USHORT, + FirstChild: USHORT, + bit_fields: ULONG, + UserContext: PVOID, +}} +BITFIELD!{HIDP_LINK_COLLECTION_NODE bit_fields: ULONG [ + CollectionType set_CollectionType[0..8], + IsAlias set_IsAlias[8..9], +]} +pub type PHIDP_LINK_COLLECTION_NODE = *mut HIDP_LINK_COLLECTION_NODE; +pub type PHIDP_REPORT_DESCRIPTOR = PUCHAR; +pub enum HIDP_PREPARSED_DATA {} +pub type PHIDP_PREPARSED_DATA = *mut HIDP_PREPARSED_DATA; +STRUCT!{struct HIDP_CAPS { + Usage: USAGE, + UsagePage: USAGE, + InputReportByteLength: USHORT, + OutputReportByteLength: USHORT, + FeatureReportByteLength: USHORT, + Reserved: [USHORT; 17], + NumberLinkCollectionNodes: USHORT, + NumberInputButtonCaps: USHORT, + NumberInputValueCaps: USHORT, + NumberInputDataIndices: USHORT, + NumberOutputButtonCaps: USHORT, + NumberOutputValueCaps: USHORT, + NumberOutputDataIndices: USHORT, + NumberFeatureButtonCaps: USHORT, + NumberFeatureValueCaps: USHORT, + NumberFeatureDataIndices: USHORT, +}} +pub type PHIDP_CAPS = *mut HIDP_CAPS; +UNION!{union HIDP_DATA_u { + [u32; 1], + RawValue RawValue_mut: ULONG, + On On_mut: BOOLEAN, +}} +STRUCT!{struct HIDP_DATA { + DataIndex: USHORT, + Reserved: USHORT, + u: HIDP_DATA_u, +}} +pub type PHIDP_DATA = *mut HIDP_DATA; +STRUCT!{struct HIDP_UNKNOWN_TOKEN { + Token: UCHAR, + Reserved: [UCHAR; 3], + BitField: ULONG, +}} +pub type PHIDP_UNKNOWN_TOKEN = *mut HIDP_UNKNOWN_TOKEN; +STRUCT!{struct HIDP_EXTENDED_ATTRIBUTES { + NumGlobalUnknowns: UCHAR, + Reserved: [UCHAR; 3], + GlobalUnknowns: PHIDP_UNKNOWN_TOKEN, + Data: [ULONG; 1], +}} +pub type PHIDP_EXTENDED_ATTRIBUTES = *mut HIDP_EXTENDED_ATTRIBUTES; +extern "system" { + pub fn HidP_GetCaps( + PreparsedData: PHIDP_PREPARSED_DATA, + Capabilities: PHIDP_CAPS, + ) -> NTSTATUS; + pub fn HidP_GetLinkCollectionNodes( + LinkCollectionNodes: PHIDP_LINK_COLLECTION_NODE, + LinkCollectionNodesLength: PULONG, + PreparsedData: PHIDP_PREPARSED_DATA, + ) -> NTSTATUS; + pub fn HidP_GetSpecificButtonCaps( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + Usage: USAGE, + ButtonCaps: PHIDP_BUTTON_CAPS, + ButtonCapsLength: PUSHORT, + PreparsedData: PHIDP_PREPARSED_DATA, + ) -> NTSTATUS; + pub fn HidP_GetButtonCaps( + ReportType: HIDP_REPORT_TYPE, + ButtonCaps: PHIDP_BUTTON_CAPS, + ButtonCapsLength: PUSHORT, + PreparsedData: PHIDP_PREPARSED_DATA, + ) -> NTSTATUS; + pub fn HidP_GetSpecificValueCaps( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + Usage: USAGE, + ValueCaps: PHIDP_VALUE_CAPS, + ValueCapsLength: PUSHORT, + PreparsedData: PHIDP_PREPARSED_DATA, + ) -> NTSTATUS; + pub fn HidP_GetValueCaps( + ReportType: HIDP_REPORT_TYPE, + ValueCaps: PHIDP_VALUE_CAPS, + ValueCapsLength: PUSHORT, + PreparsedData: PHIDP_PREPARSED_DATA, + ) -> NTSTATUS; + pub fn HidP_GetExtendedAttributes( + ReportType: HIDP_REPORT_TYPE, + DataIndex: USHORT, + PreparsedData: PHIDP_PREPARSED_DATA, + Attributes: PHIDP_EXTENDED_ATTRIBUTES, + LengthAttributes: PULONG, + ) -> NTSTATUS; + pub fn HidP_InitializeReportForID( + ReportType: HIDP_REPORT_TYPE, + ReportID: UCHAR, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_SetData( + ReportType: HIDP_REPORT_TYPE, + DataList: PHIDP_DATA, + DataLength: PULONG, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_GetData( + ReportType: HIDP_REPORT_TYPE, + DataList: PHIDP_DATA, + DataLength: PULONG, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_MaxDataListLength( + ReportType: HIDP_REPORT_TYPE, + PreparsedData: PHIDP_PREPARSED_DATA, + ) -> ULONG; + pub fn HidP_SetUsages( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + UsageList: PUSAGE, + UsageLength: PULONG, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_UnsetUsages( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + UsageList: PUSAGE, + UsageLength: PULONG, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_GetUsages( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + UsageList: PUSAGE, + UsageLength: PULONG, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_GetUsagesEx( + ReportType: HIDP_REPORT_TYPE, + LinkCollection: USHORT, + ButtonList: PUSAGE_AND_PAGE, + UsageLength: *mut ULONG, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_MaxUsageListLength( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + PreparsedData: PHIDP_PREPARSED_DATA, + ) -> ULONG; + pub fn HidP_SetUsageValue( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + Usage: USAGE, + UsageValue: ULONG, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_SetScaledUsageValue( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + Usage: USAGE, + UsageValue: LONG, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_SetUsageValueArray( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + Usage: USAGE, + UsageValue: PCHAR, + UsageValueByteLength: USHORT, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_GetUsageValue( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + Usage: USAGE, + UsageValue: PULONG, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_GetScaledUsageValue( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + Usage: USAGE, + UsageValue: PLONG, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_GetUsageValueArray( + ReportType: HIDP_REPORT_TYPE, + UsagePage: USAGE, + LinkCollection: USHORT, + Usage: USAGE, + UsageValue: PCHAR, + UsageValueByteLength: USHORT, + PreparsedData: PHIDP_PREPARSED_DATA, + Report: PCHAR, + ReportLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_UsageListDifference( + PreviousUsageList: PUSAGE, + CurrentUsageList: PUSAGE, + BreakUsageList: PUSAGE, + MakeUsageList: PUSAGE, + UsageListLength: ULONG, + ) -> NTSTATUS; + pub fn HidP_TranslateUsagesToI8042ScanCodes( + ChangedUsageList: PUSAGE, + UsageListLength: ULONG, + KeyAction: HIDP_KEYBOARD_DIRECTION, + ModifierState: PHIDP_KEYBOARD_MODIFIER_STATE, + InsertCodesProcedure: PHIDP_INSERT_SCANCODES, + InsertCodesContext: PVOID, + ) -> NTSTATUS; +} +ENUM!{enum HIDP_KEYBOARD_DIRECTION { + HidP_Keyboard_Break, + HidP_Keyboard_Make, +}} +STRUCT!{struct HIDP_KEYBOARD_MODIFIER_STATE { + ul: ULONG, +}} +BITFIELD!{HIDP_KEYBOARD_MODIFIER_STATE ul: ULONG [ + LeftControl set_LeftControl[0..1], + LeftShift set_LeftShift[1..2], + LeftAlt set_LeftAlt[2..3], + LeftGUI set_LeftGUI[3..4], + RightControl set_RightControl[4..5], + RightShift set_RightShift[5..6], + RightAlt set_RightAlt[6..7], + RigthGUI set_RigthGUI[7..8], + CapsLock set_CapsLock[8..9], + ScollLock set_ScollLock[9..10], + NumLock set_NumLock[10..11], +]} +pub type PHIDP_KEYBOARD_MODIFIER_STATE = *mut HIDP_KEYBOARD_MODIFIER_STATE; +FN!{stdcall PHIDP_INSERT_SCANCODES( + Context: PVOID, + NewScanCodes: PCHAR, + Length: ULONG, +) -> BOOLEAN} +pub const HIDP_STATUS_SUCCESS: NTSTATUS = HIDP_ERROR_CODES!(0x0, 0); +pub const HIDP_STATUS_NULL: NTSTATUS = HIDP_ERROR_CODES!(0x8, 1); +pub const HIDP_STATUS_INVALID_PREPARSED_DATA: NTSTATUS = HIDP_ERROR_CODES!(0xC, 1); +pub const HIDP_STATUS_INVALID_REPORT_TYPE: NTSTATUS = HIDP_ERROR_CODES!(0xC, 2); +pub const HIDP_STATUS_INVALID_REPORT_LENGTH: NTSTATUS = HIDP_ERROR_CODES!(0xC, 3); +pub const HIDP_STATUS_USAGE_NOT_FOUND: NTSTATUS = HIDP_ERROR_CODES!(0xC, 4); +pub const HIDP_STATUS_VALUE_OUT_OF_RANGE: NTSTATUS = HIDP_ERROR_CODES!(0xC, 5); +pub const HIDP_STATUS_BAD_LOG_PHY_VALUES: NTSTATUS = HIDP_ERROR_CODES!(0xC, 6); +pub const HIDP_STATUS_BUFFER_TOO_SMALL: NTSTATUS = HIDP_ERROR_CODES!(0xC, 7); +pub const HIDP_STATUS_INTERNAL_ERROR: NTSTATUS = HIDP_ERROR_CODES!(0xC, 8); +pub const HIDP_STATUS_I8042_TRANS_UNKNOWN: NTSTATUS = HIDP_ERROR_CODES!(0xC, 9); +pub const HIDP_STATUS_INCOMPATIBLE_REPORT_ID: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xA); +pub const HIDP_STATUS_NOT_VALUE_ARRAY: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xB); +pub const HIDP_STATUS_IS_VALUE_ARRAY: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xC); +pub const HIDP_STATUS_DATA_INDEX_NOT_FOUND: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xD); +pub const HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xE); +pub const HIDP_STATUS_BUTTON_NOT_PRESSED: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xF); +pub const HIDP_STATUS_REPORT_DOES_NOT_EXIST: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0x10); +pub const HIDP_STATUS_NOT_IMPLEMENTED: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0x20); +pub const HIDP_STATUS_I8242_TRANS_UNKNOWN: NTSTATUS = HIDP_STATUS_I8042_TRANS_UNKNOWN; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidsdi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidsdi.rs new file mode 100644 index 0000000..ebdd3ed --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidsdi.rs @@ -0,0 +1,110 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::LPGUID; +use shared::hidpi::PHIDP_PREPARSED_DATA; +use shared::minwindef::{PULONG, ULONG, USHORT}; +use um::winnt::{BOOLEAN, HANDLE, PVOID}; +STRUCT!{struct HIDD_CONFIGURATION { + cookie: PVOID, + size: ULONG, + RingBufferSize: ULONG, +}} +pub type PHIDD_CONFIGURATION = *mut HIDD_CONFIGURATION; +STRUCT!{struct HIDD_ATTRIBUTES { + Size: ULONG, + VendorID: USHORT, + ProductID: USHORT, + VersionNumber: USHORT, +}} +pub type PHIDD_ATTRIBUTES = *mut HIDD_ATTRIBUTES; +extern "system" { + pub fn HidD_GetAttributes( + HidDeviceObject: HANDLE, + Attributes: PHIDD_ATTRIBUTES, + ) -> BOOLEAN; + pub fn HidD_GetHidGuid( + HidGuid: LPGUID, + ); + pub fn HidD_GetPreparsedData( + HidDeviceObject: HANDLE, + PreparsedData: *mut PHIDP_PREPARSED_DATA, + ) -> BOOLEAN; + pub fn HidD_FreePreparsedData( + PreparsedData: PHIDP_PREPARSED_DATA, + ) -> BOOLEAN; + pub fn HidD_FlushQueue( + HidDeviceObject: HANDLE, + ) -> BOOLEAN; + pub fn HidD_GetConfiguration( + HidDeviceObject: HANDLE, + Configuration: PHIDD_CONFIGURATION, + ConfigurationLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_SetConfiguration( + HidDeviceObject: HANDLE, + Configuration: PHIDD_CONFIGURATION, + ConfigurationLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_GetFeature( + HidDeviceObject: HANDLE, + ReportBuffer: PVOID, + ReportBufferLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_SetFeature( + HidDeviceObject: HANDLE, + ReportBuffer: PVOID, + ReportBufferLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_GetInputReport( + HidDeviceObject: HANDLE, + ReportBuffer: PVOID, + ReportBufferLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_SetOutputReport( + HidDeviceObject: HANDLE, + ReportBuffer: PVOID, + ReportBufferLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_GetNumInputBuffers( + HidDeviceObject: HANDLE, + NumberBuffers: PULONG, + ) -> BOOLEAN; + pub fn HidD_SetNumInputBuffers( + HidDeviceObject: HANDLE, + NumberBuffers: ULONG, + ) -> BOOLEAN; + pub fn HidD_GetPhysicalDescriptor( + HidDeviceObject: HANDLE, + Buffer: PVOID, + BufferLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_GetManufacturerString( + HidDeviceObject: HANDLE, + Buffer: PVOID, + BufferLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_GetProductString( + HidDeviceObject: HANDLE, + Buffer: PVOID, + BufferLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_GetIndexedString( + HidDeviceObject: HANDLE, + StringIndex: ULONG, + Buffer: PVOID, + BufferLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_GetSerialNumberString( + HidDeviceObject: HANDLE, + Buffer: PVOID, + BufferLength: ULONG, + ) -> BOOLEAN; + pub fn HidD_GetMsGenreDescriptor( + HidDeviceObject: HANDLE, + Buffer: PVOID, + BufferLength: ULONG, + ) -> BOOLEAN; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidusage.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidusage.rs new file mode 100644 index 0000000..a483bf2 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/hidusage.rs @@ -0,0 +1,274 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::USHORT; +pub type USAGE = USHORT; +pub type PUSAGE = *mut USAGE; +pub const HID_USAGE_PAGE_UNDEFINED: USAGE = 0x00; +pub const HID_USAGE_PAGE_GENERIC: USAGE = 0x01; +pub const HID_USAGE_PAGE_SIMULATION: USAGE = 0x02; +pub const HID_USAGE_PAGE_VR: USAGE = 0x03; +pub const HID_USAGE_PAGE_SPORT: USAGE = 0x04; +pub const HID_USAGE_PAGE_GAME: USAGE = 0x05; +pub const HID_USAGE_PAGE_KEYBOARD: USAGE = 0x07; +pub const HID_USAGE_PAGE_LED: USAGE = 0x08; +pub const HID_USAGE_PAGE_BUTTON: USAGE = 0x09; +pub const HID_USAGE_PAGE_ORDINAL: USAGE = 0x0A; +pub const HID_USAGE_PAGE_TELEPHONY: USAGE = 0x0B; +pub const HID_USAGE_PAGE_CONSUMER: USAGE = 0x0C; +pub const HID_USAGE_PAGE_DIGITIZER: USAGE = 0x0D; +pub const HID_USAGE_PAGE_UNICODE: USAGE = 0x10; +pub const HID_USAGE_PAGE_ALPHANUMERIC: USAGE = 0x14; +pub const HID_USAGE_PAGE_SENSOR: USAGE = 0x20; +pub const HID_USAGE_PAGE_BARCODE_SCANNER: USAGE = 0x8C; +pub const HID_USAGE_PAGE_WEIGHING_DEVICE: USAGE = 0x8D; +pub const HID_USAGE_PAGE_MAGNETIC_STRIPE_READER: USAGE = 0x8E; +pub const HID_USAGE_PAGE_CAMERA_CONTROL: USAGE = 0x90; +pub const HID_USAGE_PAGE_MICROSOFT_BLUETOOTH_HANDSFREE: USAGE = 0xFFF3; +pub const HID_USAGE_PAGE_VENDOR_DEFINED_BEGIN: USAGE = 0xFF00; +pub const HID_USAGE_PAGE_VENDOR_DEFINED_END: USAGE = 0xFFFF; +pub const HID_USAGE_GENERIC_POINTER: USAGE = 0x01; +pub const HID_USAGE_GENERIC_MOUSE: USAGE = 0x02; +pub const HID_USAGE_GENERIC_JOYSTICK: USAGE = 0x04; +pub const HID_USAGE_GENERIC_GAMEPAD: USAGE = 0x05; +pub const HID_USAGE_GENERIC_KEYBOARD: USAGE = 0x06; +pub const HID_USAGE_GENERIC_KEYPAD: USAGE = 0x07; +pub const HID_USAGE_GENERIC_PORTABLE_DEVICE_CONTROL: USAGE = 0x0D; +pub const HID_USAGE_GENERIC_SYSTEM_CTL: USAGE = 0x80; +pub const HID_USAGE_GENERIC_X: USAGE = 0x30; +pub const HID_USAGE_GENERIC_Y: USAGE = 0x31; +pub const HID_USAGE_GENERIC_Z: USAGE = 0x32; +pub const HID_USAGE_GENERIC_RX: USAGE = 0x33; +pub const HID_USAGE_GENERIC_RY: USAGE = 0x34; +pub const HID_USAGE_GENERIC_RZ: USAGE = 0x35; +pub const HID_USAGE_GENERIC_SLIDER: USAGE = 0x36; +pub const HID_USAGE_GENERIC_DIAL: USAGE = 0x37; +pub const HID_USAGE_GENERIC_WHEEL: USAGE = 0x38; +pub const HID_USAGE_GENERIC_HATSWITCH: USAGE = 0x39; +pub const HID_USAGE_GENERIC_COUNTED_BUFFER: USAGE = 0x3A; +pub const HID_USAGE_GENERIC_BYTE_COUNT: USAGE = 0x3B; +pub const HID_USAGE_GENERIC_MOTION_WAKEUP: USAGE = 0x3C; +pub const HID_USAGE_GENERIC_VX: USAGE = 0x40; +pub const HID_USAGE_GENERIC_VY: USAGE = 0x41; +pub const HID_USAGE_GENERIC_VZ: USAGE = 0x42; +pub const HID_USAGE_GENERIC_VBRX: USAGE = 0x43; +pub const HID_USAGE_GENERIC_VBRY: USAGE = 0x44; +pub const HID_USAGE_GENERIC_VBRZ: USAGE = 0x45; +pub const HID_USAGE_GENERIC_VNO: USAGE = 0x46; +pub const HID_USAGE_GENERIC_RESOLUTION_MULTIPLIER: USAGE = 0x48; +pub const HID_USAGE_GENERIC_SYSCTL_POWER: USAGE = 0x81; +pub const HID_USAGE_GENERIC_SYSCTL_SLEEP: USAGE = 0x82; +pub const HID_USAGE_GENERIC_SYSCTL_WAKE: USAGE = 0x83; +pub const HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU: USAGE = 0x84; +pub const HID_USAGE_GENERIC_SYSCTL_MAIN_MENU: USAGE = 0x85; +pub const HID_USAGE_GENERIC_SYSCTL_APP_MENU: USAGE = 0x86; +pub const HID_USAGE_GENERIC_SYSCTL_HELP_MENU: USAGE = 0x87; +pub const HID_USAGE_GENERIC_SYSCTL_MENU_EXIT: USAGE = 0x88; +pub const HID_USAGE_GENERIC_SYSCTL_MENU_SELECT: USAGE = 0x89; +pub const HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT: USAGE = 0x8A; +pub const HID_USAGE_GENERIC_SYSCTL_MENU_LEFT: USAGE = 0x8B; +pub const HID_USAGE_GENERIC_SYSCTL_MENU_UP: USAGE = 0x8C; +pub const HID_USAGE_GENERIC_SYSCTL_MENU_DOWN: USAGE = 0x8D; +pub const HID_USAGE_GENERIC_SYSTEM_DISPLAY_ROTATION_LOCK_BUTTON: USAGE = 0xC9; +pub const HID_USAGE_GENERIC_SYSTEM_DISPLAY_ROTATION_LOCK_SLIDER_SWITCH: USAGE = 0xCA; +pub const HID_USAGE_GENERIC_CONTROL_ENABLE: USAGE = 0xCB; +pub const HID_USAGE_SIMULATION_RUDDER: USAGE = 0xBA; +pub const HID_USAGE_SIMULATION_THROTTLE: USAGE = 0xBB; +pub const HID_USAGE_KEYBOARD_NOEVENT: USAGE = 0x00; +pub const HID_USAGE_KEYBOARD_ROLLOVER: USAGE = 0x01; +pub const HID_USAGE_KEYBOARD_POSTFAIL: USAGE = 0x02; +pub const HID_USAGE_KEYBOARD_UNDEFINED: USAGE = 0x03; +pub const HID_USAGE_KEYBOARD_aA: USAGE = 0x04; +pub const HID_USAGE_KEYBOARD_zZ: USAGE = 0x1D; +pub const HID_USAGE_KEYBOARD_ONE: USAGE = 0x1E; +pub const HID_USAGE_KEYBOARD_ZERO: USAGE = 0x27; +pub const HID_USAGE_KEYBOARD_LCTRL: USAGE = 0xE0; +pub const HID_USAGE_KEYBOARD_LSHFT: USAGE = 0xE1; +pub const HID_USAGE_KEYBOARD_LALT: USAGE = 0xE2; +pub const HID_USAGE_KEYBOARD_LGUI: USAGE = 0xE3; +pub const HID_USAGE_KEYBOARD_RCTRL: USAGE = 0xE4; +pub const HID_USAGE_KEYBOARD_RSHFT: USAGE = 0xE5; +pub const HID_USAGE_KEYBOARD_RALT: USAGE = 0xE6; +pub const HID_USAGE_KEYBOARD_RGUI: USAGE = 0xE7; +pub const HID_USAGE_KEYBOARD_SCROLL_LOCK: USAGE = 0x47; +pub const HID_USAGE_KEYBOARD_NUM_LOCK: USAGE = 0x53; +pub const HID_USAGE_KEYBOARD_CAPS_LOCK: USAGE = 0x39; +pub const HID_USAGE_KEYBOARD_F1: USAGE = 0x3A; +pub const HID_USAGE_KEYBOARD_F2: USAGE = 0x3B; +pub const HID_USAGE_KEYBOARD_F3: USAGE = 0x3C; +pub const HID_USAGE_KEYBOARD_F4: USAGE = 0x3D; +pub const HID_USAGE_KEYBOARD_F5: USAGE = 0x3E; +pub const HID_USAGE_KEYBOARD_F6: USAGE = 0x3F; +pub const HID_USAGE_KEYBOARD_F7: USAGE = 0x40; +pub const HID_USAGE_KEYBOARD_F8: USAGE = 0x41; +pub const HID_USAGE_KEYBOARD_F9: USAGE = 0x42; +pub const HID_USAGE_KEYBOARD_F10: USAGE = 0x43; +pub const HID_USAGE_KEYBOARD_F11: USAGE = 0x44; +pub const HID_USAGE_KEYBOARD_F12: USAGE = 0x45; +pub const HID_USAGE_KEYBOARD_F13: USAGE = 0x68; +pub const HID_USAGE_KEYBOARD_F14: USAGE = 0x69; +pub const HID_USAGE_KEYBOARD_F15: USAGE = 0x6A; +pub const HID_USAGE_KEYBOARD_F16: USAGE = 0x6B; +pub const HID_USAGE_KEYBOARD_F17: USAGE = 0x6C; +pub const HID_USAGE_KEYBOARD_F18: USAGE = 0x6D; +pub const HID_USAGE_KEYBOARD_F19: USAGE = 0x6E; +pub const HID_USAGE_KEYBOARD_F20: USAGE = 0x6F; +pub const HID_USAGE_KEYBOARD_F21: USAGE = 0x70; +pub const HID_USAGE_KEYBOARD_F22: USAGE = 0x71; +pub const HID_USAGE_KEYBOARD_F23: USAGE = 0x72; +pub const HID_USAGE_KEYBOARD_F24: USAGE = 0x73; +pub const HID_USAGE_KEYBOARD_RETURN: USAGE = 0x28; +pub const HID_USAGE_KEYBOARD_ESCAPE: USAGE = 0x29; +pub const HID_USAGE_KEYBOARD_DELETE: USAGE = 0x2A; +pub const HID_USAGE_KEYBOARD_PRINT_SCREEN: USAGE = 0x46; +pub const HID_USAGE_KEYBOARD_DELETE_FORWARD: USAGE = 0x4C; +pub const HID_USAGE_LED_NUM_LOCK: USAGE = 0x01; +pub const HID_USAGE_LED_CAPS_LOCK: USAGE = 0x02; +pub const HID_USAGE_LED_SCROLL_LOCK: USAGE = 0x03; +pub const HID_USAGE_LED_COMPOSE: USAGE = 0x04; +pub const HID_USAGE_LED_KANA: USAGE = 0x05; +pub const HID_USAGE_LED_POWER: USAGE = 0x06; +pub const HID_USAGE_LED_SHIFT: USAGE = 0x07; +pub const HID_USAGE_LED_DO_NOT_DISTURB: USAGE = 0x08; +pub const HID_USAGE_LED_MUTE: USAGE = 0x09; +pub const HID_USAGE_LED_TONE_ENABLE: USAGE = 0x0A; +pub const HID_USAGE_LED_HIGH_CUT_FILTER: USAGE = 0x0B; +pub const HID_USAGE_LED_LOW_CUT_FILTER: USAGE = 0x0C; +pub const HID_USAGE_LED_EQUALIZER_ENABLE: USAGE = 0x0D; +pub const HID_USAGE_LED_SOUND_FIELD_ON: USAGE = 0x0E; +pub const HID_USAGE_LED_SURROUND_FIELD_ON: USAGE = 0x0F; +pub const HID_USAGE_LED_REPEAT: USAGE = 0x10; +pub const HID_USAGE_LED_STEREO: USAGE = 0x11; +pub const HID_USAGE_LED_SAMPLING_RATE_DETECT: USAGE = 0x12; +pub const HID_USAGE_LED_SPINNING: USAGE = 0x13; +pub const HID_USAGE_LED_CAV: USAGE = 0x14; +pub const HID_USAGE_LED_CLV: USAGE = 0x15; +pub const HID_USAGE_LED_RECORDING_FORMAT_DET: USAGE = 0x16; +pub const HID_USAGE_LED_OFF_HOOK: USAGE = 0x17; +pub const HID_USAGE_LED_RING: USAGE = 0x18; +pub const HID_USAGE_LED_MESSAGE_WAITING: USAGE = 0x19; +pub const HID_USAGE_LED_DATA_MODE: USAGE = 0x1A; +pub const HID_USAGE_LED_BATTERY_OPERATION: USAGE = 0x1B; +pub const HID_USAGE_LED_BATTERY_OK: USAGE = 0x1C; +pub const HID_USAGE_LED_BATTERY_LOW: USAGE = 0x1D; +pub const HID_USAGE_LED_SPEAKER: USAGE = 0x1E; +pub const HID_USAGE_LED_HEAD_SET: USAGE = 0x1F; +pub const HID_USAGE_LED_HOLD: USAGE = 0x20; +pub const HID_USAGE_LED_MICROPHONE: USAGE = 0x21; +pub const HID_USAGE_LED_COVERAGE: USAGE = 0x22; +pub const HID_USAGE_LED_NIGHT_MODE: USAGE = 0x23; +pub const HID_USAGE_LED_SEND_CALLS: USAGE = 0x24; +pub const HID_USAGE_LED_CALL_PICKUP: USAGE = 0x25; +pub const HID_USAGE_LED_CONFERENCE: USAGE = 0x26; +pub const HID_USAGE_LED_STAND_BY: USAGE = 0x27; +pub const HID_USAGE_LED_CAMERA_ON: USAGE = 0x28; +pub const HID_USAGE_LED_CAMERA_OFF: USAGE = 0x29; +pub const HID_USAGE_LED_ON_LINE: USAGE = 0x2A; +pub const HID_USAGE_LED_OFF_LINE: USAGE = 0x2B; +pub const HID_USAGE_LED_BUSY: USAGE = 0x2C; +pub const HID_USAGE_LED_READY: USAGE = 0x2D; +pub const HID_USAGE_LED_PAPER_OUT: USAGE = 0x2E; +pub const HID_USAGE_LED_PAPER_JAM: USAGE = 0x2F; +pub const HID_USAGE_LED_REMOTE: USAGE = 0x30; +pub const HID_USAGE_LED_FORWARD: USAGE = 0x31; +pub const HID_USAGE_LED_REVERSE: USAGE = 0x32; +pub const HID_USAGE_LED_STOP: USAGE = 0x33; +pub const HID_USAGE_LED_REWIND: USAGE = 0x34; +pub const HID_USAGE_LED_FAST_FORWARD: USAGE = 0x35; +pub const HID_USAGE_LED_PLAY: USAGE = 0x36; +pub const HID_USAGE_LED_PAUSE: USAGE = 0x37; +pub const HID_USAGE_LED_RECORD: USAGE = 0x38; +pub const HID_USAGE_LED_ERROR: USAGE = 0x39; +pub const HID_USAGE_LED_SELECTED_INDICATOR: USAGE = 0x3A; +pub const HID_USAGE_LED_IN_USE_INDICATOR: USAGE = 0x3B; +pub const HID_USAGE_LED_MULTI_MODE_INDICATOR: USAGE = 0x3C; +pub const HID_USAGE_LED_INDICATOR_ON: USAGE = 0x3D; +pub const HID_USAGE_LED_INDICATOR_FLASH: USAGE = 0x3E; +pub const HID_USAGE_LED_INDICATOR_SLOW_BLINK: USAGE = 0x3F; +pub const HID_USAGE_LED_INDICATOR_FAST_BLINK: USAGE = 0x40; +pub const HID_USAGE_LED_INDICATOR_OFF: USAGE = 0x41; +pub const HID_USAGE_LED_FLASH_ON_TIME: USAGE = 0x42; +pub const HID_USAGE_LED_SLOW_BLINK_ON_TIME: USAGE = 0x43; +pub const HID_USAGE_LED_SLOW_BLINK_OFF_TIME: USAGE = 0x44; +pub const HID_USAGE_LED_FAST_BLINK_ON_TIME: USAGE = 0x45; +pub const HID_USAGE_LED_FAST_BLINK_OFF_TIME: USAGE = 0x46; +pub const HID_USAGE_LED_INDICATOR_COLOR: USAGE = 0x47; +pub const HID_USAGE_LED_RED: USAGE = 0x48; +pub const HID_USAGE_LED_GREEN: USAGE = 0x49; +pub const HID_USAGE_LED_AMBER: USAGE = 0x4A; +pub const HID_USAGE_LED_GENERIC_INDICATOR: USAGE = 0x4B; +pub const HID_USAGE_TELEPHONY_PHONE: USAGE = 0x01; +pub const HID_USAGE_TELEPHONY_ANSWERING_MACHINE: USAGE = 0x02; +pub const HID_USAGE_TELEPHONY_MESSAGE_CONTROLS: USAGE = 0x03; +pub const HID_USAGE_TELEPHONY_HANDSET: USAGE = 0x04; +pub const HID_USAGE_TELEPHONY_HEADSET: USAGE = 0x05; +pub const HID_USAGE_TELEPHONY_KEYPAD: USAGE = 0x06; +pub const HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON: USAGE = 0x07; +pub const HID_USAGE_TELEPHONY_REDIAL: USAGE = 0x24; +pub const HID_USAGE_TELEPHONY_TRANSFER: USAGE = 0x25; +pub const HID_USAGE_TELEPHONY_DROP: USAGE = 0x26; +pub const HID_USAGE_TELEPHONY_LINE: USAGE = 0x2A; +pub const HID_USAGE_TELEPHONY_RING_ENABLE: USAGE = 0x2D; +pub const HID_USAGE_TELEPHONY_SEND: USAGE = 0x31; +pub const HID_USAGE_TELEPHONY_KEYPAD_0: USAGE = 0xB0; +pub const HID_USAGE_TELEPHONY_KEYPAD_D: USAGE = 0xBF; +pub const HID_USAGE_TELEPHONY_HOST_AVAILABLE: USAGE = 0xF1; +pub const HID_USAGE_CONSUMERCTRL: USAGE = 0x01; +pub const HID_USAGE_CONSUMER_CHANNEL_INCREMENT: USAGE = 0x9C; +pub const HID_USAGE_CONSUMER_CHANNEL_DECREMENT: USAGE = 0x9D; +pub const HID_USAGE_CONSUMER_PLAY: USAGE = 0xB0; +pub const HID_USAGE_CONSUMER_PAUSE: USAGE = 0xB1; +pub const HID_USAGE_CONSUMER_RECORD: USAGE = 0xB2; +pub const HID_USAGE_CONSUMER_FAST_FORWARD: USAGE = 0xB3; +pub const HID_USAGE_CONSUMER_REWIND: USAGE = 0xB4; +pub const HID_USAGE_CONSUMER_SCAN_NEXT_TRACK: USAGE = 0xB5; +pub const HID_USAGE_CONSUMER_SCAN_PREV_TRACK: USAGE = 0xB6; +pub const HID_USAGE_CONSUMER_STOP: USAGE = 0xB7; +pub const HID_USAGE_CONSUMER_PLAY_PAUSE: USAGE = 0xCD; +pub const HID_USAGE_CONSUMER_VOLUME: USAGE = 0xE0; +pub const HID_USAGE_CONSUMER_BALANCE: USAGE = 0xE1; +pub const HID_USAGE_CONSUMER_MUTE: USAGE = 0xE2; +pub const HID_USAGE_CONSUMER_BASS: USAGE = 0xE3; +pub const HID_USAGE_CONSUMER_TREBLE: USAGE = 0xE4; +pub const HID_USAGE_CONSUMER_BASS_BOOST: USAGE = 0xE5; +pub const HID_USAGE_CONSUMER_SURROUND_MODE: USAGE = 0xE6; +pub const HID_USAGE_CONSUMER_LOUDNESS: USAGE = 0xE7; +pub const HID_USAGE_CONSUMER_MPX: USAGE = 0xE8; +pub const HID_USAGE_CONSUMER_VOLUME_INCREMENT: USAGE = 0xE9; +pub const HID_USAGE_CONSUMER_VOLUME_DECREMENT: USAGE = 0xEA; +pub const HID_USAGE_CONSUMER_BASS_INCREMENT: USAGE = 0x152; +pub const HID_USAGE_CONSUMER_BASS_DECREMENT: USAGE = 0x153; +pub const HID_USAGE_CONSUMER_TREBLE_INCREMENT: USAGE = 0x154; +pub const HID_USAGE_CONSUMER_TREBLE_DECREMENT: USAGE = 0x155; +pub const HID_USAGE_CONSUMER_AL_CONFIGURATION: USAGE = 0x183; +pub const HID_USAGE_CONSUMER_AL_EMAIL: USAGE = 0x18A; +pub const HID_USAGE_CONSUMER_AL_CALCULATOR: USAGE = 0x192; +pub const HID_USAGE_CONSUMER_AL_BROWSER: USAGE = 0x194; +pub const HID_USAGE_CONSUMER_AC_SEARCH: USAGE = 0x221; +pub const HID_USAGE_CONSUMER_AC_GOTO: USAGE = 0x222; +pub const HID_USAGE_CONSUMER_AC_HOME: USAGE = 0x223; +pub const HID_USAGE_CONSUMER_AC_BACK: USAGE = 0x224; +pub const HID_USAGE_CONSUMER_AC_FORWARD: USAGE = 0x225; +pub const HID_USAGE_CONSUMER_AC_STOP: USAGE = 0x226; +pub const HID_USAGE_CONSUMER_AC_REFRESH: USAGE = 0x227; +pub const HID_USAGE_CONSUMER_AC_PREVIOUS: USAGE = 0x228; +pub const HID_USAGE_CONSUMER_AC_NEXT: USAGE = 0x229; +pub const HID_USAGE_CONSUMER_AC_BOOKMARKS: USAGE = 0x22A; +pub const HID_USAGE_CONSUMER_AC_PAN: USAGE = 0x238; +pub const HID_USAGE_CONSUMER_EXTENDED_KEYBOARD_ATTRIBUTES_COLLECTION: USAGE = 0x2C0; +pub const HID_USAGE_CONSUMER_KEYBOARD_FORM_FACTOR: USAGE = 0x2C1; +pub const HID_USAGE_CONSUMER_KEYBOARD_KEY_TYPE: USAGE = 0x2C2; +pub const HID_USAGE_CONSUMER_KEYBOARD_PHYSICAL_LAYOUT: USAGE = 0x2C3; +pub const HID_USAGE_CONSUMER_VENDOR_SPECIFIC_KEYBOARD_PHYSICAL_LAYOUT: USAGE = 0x2C4; +pub const HID_USAGE_CONSUMER_KEYBOARD_IETF_LANGUAGE_TAG_INDEX: USAGE = 0x2C5; +pub const HID_USAGE_CONSUMER_IMPLEMENTED_KEYBOARD_INPUT_ASSIST_CONTROLS: USAGE = 0x2C6; +pub const HID_USAGE_DIGITIZER_PEN: USAGE = 0x02; +pub const HID_USAGE_DIGITIZER_IN_RANGE: USAGE = 0x32; +pub const HID_USAGE_DIGITIZER_TIP_SWITCH: USAGE = 0x42; +pub const HID_USAGE_DIGITIZER_BARREL_SWITCH: USAGE = 0x44; +pub const HID_USAGE_CAMERA_AUTO_FOCUS: USAGE = 0x20; +pub const HID_USAGE_CAMERA_SHUTTER: USAGE = 0x21; +pub const HID_USAGE_MS_BTH_HF_DIALNUMBER: USAGE = 0x21; +pub const HID_USAGE_MS_BTH_HF_DIALMEMORY: USAGE = 0x22; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/ifdef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ifdef.rs new file mode 100644 index 0000000..e64527a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ifdef.rs @@ -0,0 +1,22 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{UINT16, ULONG64}; +use shared::minwindef::ULONG; +STRUCT!{struct NET_LUID_LH { + Value: ULONG64, +}} +BITFIELD!{NET_LUID_LH Value: ULONG64 [ + Reserved set_Reserved[0..24], + NetLuidIndex set_NetLuidIndex[24..48], + IfType set_IfType[48..64], +]} +pub type PNET_LUID_LH = *mut NET_LUID_LH; +pub type NET_LUID = NET_LUID_LH; +pub type PNET_LUID = *mut NET_LUID; +pub type NET_IFINDEX = ULONG; +pub type PNET_IFINDEX = *mut ULONG; +pub type NET_IFTYPE = UINT16; +pub type PNET_IFTYPE = *mut UINT16; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/in6addr.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/in6addr.rs new file mode 100644 index 0000000..6ed9382 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/in6addr.rs @@ -0,0 +1,17 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{UCHAR, USHORT}; +UNION!{union in6_addr_u { + [u16; 8], + Byte Byte_mut: [UCHAR; 16], + Word Word_mut: [USHORT; 8], +}} +STRUCT!{struct in6_addr { + u: in6_addr_u, +}} +pub type IN6_ADDR = in6_addr; +pub type PIN6_ADDR = *mut IN6_ADDR; +pub type LPIN6_ADDR = *mut IN6_ADDR; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/inaddr.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/inaddr.rs new file mode 100644 index 0000000..c56e1ea --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/inaddr.rs @@ -0,0 +1,29 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! IPv4 Internet address +use shared::minwindef::{UCHAR, ULONG, USHORT}; +STRUCT!{struct in_addr_S_un_b { + s_b1: UCHAR, + s_b2: UCHAR, + s_b3: UCHAR, + s_b4: UCHAR, +}} +STRUCT!{struct in_addr_S_un_w { + s_w1: USHORT, + s_w2: USHORT, +}} +UNION!{union in_addr_S_un { + [u32; 1], + S_un_b S_un_b_mut: in_addr_S_un_b, + S_un_w S_un_w_mut: in_addr_S_un_w, + S_addr S_addr_mut: ULONG, +}} +STRUCT!{struct in_addr { + S_un: in_addr_S_un, +}} +pub type IN_ADDR = in_addr; +pub type PIN_ADDR = *mut in_addr; +pub type LPIN_ADDR = *mut in_addr; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/intsafe.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/intsafe.rs new file mode 100644 index 0000000..916dc0e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/intsafe.rs @@ -0,0 +1,5 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/ks.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ks.rs new file mode 100644 index 0000000..3a2ab10 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ks.rs @@ -0,0 +1,63 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +// Licensed under the MIT License <LICENSE.md> +//! Mappings for the contents of ks.h +DEFINE_GUID!{KSCATEGORY_BRIDGE, + 0x085AFF00, 0x62CE, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_CAPTURE, + 0x65E8773D, 0x8F56, 0x11D0, 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_VIDEO_CAMERA, + 0xe5323777, 0xf976, 0x4f5b, 0x9b, 0x55, 0xb9, 0x46, 0x99, 0xc4, 0x6e, 0x44} +DEFINE_GUID!{KSCATEGORY_SENSOR_CAMERA, + 0x24e552d7, 0x6523, 0x47f7, 0xa6, 0x47, 0xd3, 0x46, 0x5b, 0xf1, 0xf5, 0xca} +DEFINE_GUID!{KSCATEGORY_SENSOR_GROUP, + 0x669C7214, 0x0A88, 0x4311, 0xA7, 0xF3, 0x4E, 0x79, 0x82, 0x0E, 0x33, 0xBD} +DEFINE_GUID!{KSCATEGORY_RENDER, + 0x65E8773E, 0x8F56, 0x11D0, 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_MIXER, + 0xAD809C00, 0x7B88, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_SPLITTER, + 0x0A4252A0, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_DATACOMPRESSOR, + 0x1E84C900, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_DATADECOMPRESSOR, + 0x2721AE20, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_DATATRANSFORM, + 0x2EB07EA0, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSMFT_CATEGORY_VIDEO_DECODER, + 0xd6c02d4b, 0x6833, 0x45b4, 0x97, 0x1a, 0x05, 0xa4, 0xb0, 0x4b, 0xab, 0x91} +DEFINE_GUID!{KSMFT_CATEGORY_VIDEO_ENCODER, + 0xf79eac7d, 0xe545, 0x4387, 0xbd, 0xee, 0xd6, 0x47, 0xd7, 0xbd, 0xe4, 0x2a} +DEFINE_GUID!{KSMFT_CATEGORY_VIDEO_EFFECT, + 0x12e17c21, 0x532c, 0x4a6e, 0x8a, 0x1c, 0x40, 0x82, 0x5a, 0x73, 0x63, 0x97} +DEFINE_GUID!{KSMFT_CATEGORY_MULTIPLEXER, + 0x059c561e, 0x05ae, 0x4b61, 0xb6, 0x9d, 0x55, 0xb6, 0x1e, 0xe5, 0x4a, 0x7b} +DEFINE_GUID!{KSMFT_CATEGORY_DEMULTIPLEXER, + 0xa8700a7a, 0x939b, 0x44c5, 0x99, 0xd7, 0x76, 0x22, 0x6b, 0x23, 0xb3, 0xf1} +DEFINE_GUID!{KSMFT_CATEGORY_AUDIO_DECODER, + 0x9ea73fb4, 0xef7a, 0x4559, 0x8d, 0x5d, 0x71, 0x9d, 0x8f, 0x04, 0x26, 0xc7} +DEFINE_GUID!{KSMFT_CATEGORY_AUDIO_ENCODER, + 0x91c64bd0, 0xf91e, 0x4d8c, 0x92, 0x76, 0xdb, 0x24, 0x82, 0x79, 0xd9, 0x75} +DEFINE_GUID!{KSMFT_CATEGORY_AUDIO_EFFECT, + 0x11064c48, 0x3648, 0x4ed0, 0x93, 0x2e, 0x05, 0xce, 0x8a, 0xc8, 0x11, 0xb7} +DEFINE_GUID!{KSMFT_CATEGORY_VIDEO_PROCESSOR, + 0x302ea3fc, 0xaa5f, 0x47f9, 0x9f, 0x7a, 0xc2, 0x18, 0x8b, 0xb1, 0x63, 0x02} +DEFINE_GUID!{KSMFT_CATEGORY_OTHER, + 0x90175d57, 0xb7ea, 0x4901, 0xae, 0xb3, 0x93, 0x3a, 0x87, 0x47, 0x75, 0x6f} +DEFINE_GUID!{KSCATEGORY_COMMUNICATIONSTRANSFORM, + 0xCF1DDA2C, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_INTERFACETRANSFORM, + 0xCF1DDA2D, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_MEDIUMTRANSFORM, + 0xCF1DDA2E, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_FILESYSTEM, + 0x760FED5E, 0x9357, 0x11D0, 0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_CLOCK, + 0x53172480, 0x4791, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_PROXY, + 0x97EBAACA, 0x95BD, 0x11D0, 0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_QUALITY, + 0x97EBAACB, 0x95BD, 0x11D0, 0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/ksmedia.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ksmedia.rs new file mode 100644 index 0000000..cd64037 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ksmedia.rs @@ -0,0 +1,110 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +// Licensed under the MIT License <LICENSE.md> +//! Mappings for the contents of ksmedia.h +use shared::minwindef::DWORD; +DEFINE_GUID!{KSCATEGORY_AUDIO, + 0x6994AD04, 0x93EF, 0x11D0, 0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_VIDEO, + 0x6994AD05, 0x93EF, 0x11D0, 0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_REALTIME, + 0xEB115FFC, 0x10C8, 0x4964, 0x83, 0x1D, 0x6D, 0xCB, 0x02, 0xE6, 0xF2, 0x3F} +DEFINE_GUID!{KSCATEGORY_TEXT, + 0x6994AD06, 0x93EF, 0x11D0, 0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_NETWORK, + 0x67C9CC3C, 0x69C4, 0x11D2, 0x87, 0x59, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_TOPOLOGY, + 0xDDA54A40, 0x1E4C, 0x11D1, 0xA0, 0x50, 0x40, 0x57, 0x05, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_VIRTUAL, + 0x3503EAC4, 0x1F26, 0x11D1, 0x8A, 0xB0, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_ACOUSTIC_ECHO_CANCEL, + 0xBF963D80, 0xC559, 0x11D0, 0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1} +DEFINE_GUID!{KSCATEGORY_SYSAUDIO, + 0xA7C7A5B1, 0x5AF3, 0x11D1, 0x9C, 0xED, 0x00, 0xA0, 0x24, 0xBF, 0x04, 0x07} +DEFINE_GUID!{KSCATEGORY_WDMAUD, + 0x3E227E76, 0x690D, 0x11D2, 0x81, 0x61, 0x00, 0x00, 0xF8, 0x77, 0x5B, 0xF1} +DEFINE_GUID!{KSCATEGORY_AUDIO_GFX, + 0x9BAF9572, 0x340C, 0x11D3, 0xAB, 0xDC, 0x00, 0xA0, 0xC9, 0x0A, 0xB1, 0x6F} +DEFINE_GUID!{KSCATEGORY_AUDIO_SPLITTER, + 0x9EA331FA, 0xB91B, 0x45F8, 0x92, 0x85, 0xBD, 0x2B, 0xC7, 0x7A, 0xFC, 0xDE} +DEFINE_GUID!{KSCATEGORY_AUDIO_DEVICE, + 0xFBF6F530, 0x07B9, 0x11D2, 0xA7, 0x1E, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88} +DEFINE_GUID!{KSCATEGORY_PREFERRED_WAVEOUT_DEVICE, + 0xD6C5066E, 0x72C1, 0x11D2, 0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88} +DEFINE_GUID!{KSCATEGORY_PREFERRED_WAVEIN_DEVICE, + 0xD6C50671, 0x72C1, 0x11D2, 0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88} +DEFINE_GUID!{KSCATEGORY_PREFERRED_MIDIOUT_DEVICE, + 0xD6C50674, 0x72C1, 0x11D2, 0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88} +DEFINE_GUID!{KSCATEGORY_WDMAUD_USE_PIN_NAME, + 0x47A4FA20, 0xA251, 0x11D1, 0xA0, 0x50, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88} +DEFINE_GUID!{KSCATEGORY_ESCALANTE_PLATFORM_DRIVER, + 0x74F3AEA8, 0x9768, 0x11D1, 0x8E, 0x07, 0x00, 0xA0, 0xC9, 0x5E, 0xC2, 0x2E} +DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_ANALOG, + 0x6DBA3190, 0x67BD, 0x11CF, 0xA0, 0xF7, 0x00, 0x20, 0xAF, 0xD1, 0x56, 0xE4} +DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_PCM, + 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71} +DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, + 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71} +DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_DRM, + 0x00000009, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71} +DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_ALAW, + 0x00000006, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71} +DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_MULAW, + 0x00000007, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71} +DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_ADPCM, + 0x00000002, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71} +DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_MPEG, + 0x00000050, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71} +//1720 +pub const SPEAKER_FRONT_LEFT: DWORD = 0x1; +pub const SPEAKER_FRONT_RIGHT: DWORD = 0x2; +pub const SPEAKER_FRONT_CENTER: DWORD = 0x4; +pub const SPEAKER_LOW_FREQUENCY: DWORD = 0x8; +pub const SPEAKER_BACK_LEFT: DWORD = 0x10; +pub const SPEAKER_BACK_RIGHT: DWORD = 0x20; +pub const SPEAKER_FRONT_LEFT_OF_CENTER: DWORD = 0x40; +pub const SPEAKER_FRONT_RIGHT_OF_CENTER: DWORD = 0x80; +pub const SPEAKER_BACK_CENTER: DWORD = 0x100; +pub const SPEAKER_SIDE_LEFT: DWORD = 0x200; +pub const SPEAKER_SIDE_RIGHT: DWORD = 0x400; +pub const SPEAKER_TOP_CENTER: DWORD = 0x800; +pub const SPEAKER_TOP_FRONT_LEFT: DWORD = 0x1000; +pub const SPEAKER_TOP_FRONT_CENTER: DWORD = 0x2000; +pub const SPEAKER_TOP_FRONT_RIGHT: DWORD = 0x4000; +pub const SPEAKER_TOP_BACK_LEFT: DWORD = 0x8000; +pub const SPEAKER_TOP_BACK_CENTER: DWORD = 0x10000; +pub const SPEAKER_TOP_BACK_RIGHT: DWORD = 0x20000; +pub const SPEAKER_RESERVED: DWORD = 0x7FFC0000; +pub const SPEAKER_ALL: DWORD = 0x80000000; +pub const KSAUDIO_SPEAKER_DIRECTOUT: DWORD = 0; +pub const KSAUDIO_SPEAKER_MONO: DWORD = SPEAKER_FRONT_CENTER; +pub const KSAUDIO_SPEAKER_1POINT1: DWORD = SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY; +pub const KSAUDIO_SPEAKER_STEREO: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; +pub const KSAUDIO_SPEAKER_2POINT1: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_LOW_FREQUENCY; +pub const KSAUDIO_SPEAKER_3POINT0: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_FRONT_CENTER; +pub const KSAUDIO_SPEAKER_3POINT1: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY; +pub const KSAUDIO_SPEAKER_QUAD: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; +pub const KSAUDIO_SPEAKER_SURROUND: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER; +pub const KSAUDIO_SPEAKER_5POINT0: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_FRONT_CENTER | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; +pub const KSAUDIO_SPEAKER_5POINT1: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; +pub const KSAUDIO_SPEAKER_7POINT0: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_FRONT_CENTER | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT + | SPEAKER_SIDE_RIGHT; +pub const KSAUDIO_SPEAKER_7POINT1: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT + | SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER; +pub const KSAUDIO_SPEAKER_5POINT1_SURROUND: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; +pub const KSAUDIO_SPEAKER_7POINT1_SURROUND: DWORD = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT + | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT + | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/ktmtypes.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ktmtypes.rs new file mode 100644 index 0000000..77394e2 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ktmtypes.rs @@ -0,0 +1,138 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Common types for KTM exposed at both the Nt- and Win32-layer +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, ULONG}; +use um::winnt::{LARGE_INTEGER, PVOID, WCHAR}; +pub type UOW = GUID; +pub type PUOW = *mut GUID; +pub type CRM_PROTOCOL_ID = GUID; +pub type PCRM_PROTOCOL_ID = *mut GUID; +pub const TRANSACTION_MANAGER_VOLATILE: ULONG = 0x00000001; +pub const TRANSACTION_MANAGER_COMMIT_DEFAULT: ULONG = 0x00000000; +pub const TRANSACTION_MANAGER_COMMIT_SYSTEM_VOLUME: ULONG = 0x00000002; +pub const TRANSACTION_MANAGER_COMMIT_SYSTEM_HIVES: ULONG = 0x00000004; +pub const TRANSACTION_MANAGER_COMMIT_LOWEST: ULONG = 0x00000008; +pub const TRANSACTION_MANAGER_CORRUPT_FOR_RECOVERY: ULONG = 0x00000010; +pub const TRANSACTION_MANAGER_CORRUPT_FOR_PROGRESS: ULONG = 0x00000020; +pub const TRANSACTION_MANAGER_MAXIMUM_OPTION: ULONG = 0x0000003F; +pub const TRANSACTION_DO_NOT_PROMOTE: DWORD = 0x00000001; +pub const TRANSACTION_MAXIMUM_OPTION: DWORD = 0x00000001; +pub const RESOURCE_MANAGER_VOLATILE: DWORD = 0x00000001; +pub const RESOURCE_MANAGER_COMMUNICATION: DWORD = 0x00000002; +pub const RESOURCE_MANAGER_MAXIMUM_OPTION: DWORD = 0x00000003; +pub const CRM_PROTOCOL_EXPLICIT_MARSHAL_ONLY: DWORD = 0x00000001; +pub const CRM_PROTOCOL_DYNAMIC_MARSHAL_INFO: DWORD = 0x00000002; +pub const CRM_PROTOCOL_MAXIMUM_OPTION: DWORD = 0x00000003; +pub const ENLISTMENT_SUPERIOR: ULONG = 0x00000001; +pub const ENLISTMENT_MAXIMUM_OPTION: ULONG = 0x00000001; +pub type NOTIFICATION_MASK = ULONG; +pub const TRANSACTION_NOTIFY_MASK: ULONG = 0x3FFFFFFF; +pub const TRANSACTION_NOTIFY_PREPREPARE: ULONG = 0x00000001; +pub const TRANSACTION_NOTIFY_PREPARE: ULONG = 0x00000002; +pub const TRANSACTION_NOTIFY_COMMIT: ULONG = 0x00000004; +pub const TRANSACTION_NOTIFY_ROLLBACK: ULONG = 0x00000008; +pub const TRANSACTION_NOTIFY_PREPREPARE_COMPLETE: ULONG = 0x00000010; +pub const TRANSACTION_NOTIFY_PREPARE_COMPLETE: ULONG = 0x00000020; +pub const TRANSACTION_NOTIFY_COMMIT_COMPLETE: ULONG = 0x00000040; +pub const TRANSACTION_NOTIFY_ROLLBACK_COMPLETE: ULONG = 0x00000080; +pub const TRANSACTION_NOTIFY_RECOVER: ULONG = 0x00000100; +pub const TRANSACTION_NOTIFY_SINGLE_PHASE_COMMIT: ULONG = 0x00000200; +pub const TRANSACTION_NOTIFY_DELEGATE_COMMIT: ULONG = 0x00000400; +pub const TRANSACTION_NOTIFY_RECOVER_QUERY: ULONG = 0x00000800; +pub const TRANSACTION_NOTIFY_ENLIST_PREPREPARE: ULONG = 0x00001000; +pub const TRANSACTION_NOTIFY_LAST_RECOVER: ULONG = 0x00002000; +pub const TRANSACTION_NOTIFY_INDOUBT: ULONG = 0x00004000; +pub const TRANSACTION_NOTIFY_PROPAGATE_PULL: ULONG = 0x00008000; +pub const TRANSACTION_NOTIFY_PROPAGATE_PUSH: ULONG = 0x00010000; +pub const TRANSACTION_NOTIFY_MARSHAL: ULONG = 0x00020000; +pub const TRANSACTION_NOTIFY_ENLIST_MASK: ULONG = 0x00040000; +pub const TRANSACTION_NOTIFY_RM_DISCONNECTED: ULONG = 0x01000000; +pub const TRANSACTION_NOTIFY_TM_ONLINE: ULONG = 0x02000000; +pub const TRANSACTION_NOTIFY_COMMIT_REQUEST: ULONG = 0x04000000; +pub const TRANSACTION_NOTIFY_PROMOTE: ULONG = 0x08000000; +pub const TRANSACTION_NOTIFY_PROMOTE_NEW: ULONG = 0x10000000; +pub const TRANSACTION_NOTIFY_REQUEST_OUTCOME: ULONG = 0x20000000; +pub const TRANSACTION_NOTIFY_COMMIT_FINALIZE: ULONG = 0x40000000; +pub const TRANSACTIONMANAGER_OBJECT_PATH: &'static str = "\\TransactionManager\\"; +pub const TRANSACTION_OBJECT_PATH: &'static str = "\\Transaction\\"; +pub const ENLISTMENT_OBJECT_PATH: &'static str = "\\Enlistment\\"; +pub const RESOURCE_MANAGER_OBJECT_PATH: &'static str = "\\ResourceManager\\"; +STRUCT!{struct TRANSACTION_NOTIFICATION { + TransactionKey: PVOID, + TransactionNotification: ULONG, + TmVirtualClock: LARGE_INTEGER, + ArgumentLength: ULONG, +}} +pub type PTRANSACTION_NOTIFICATION = *mut TRANSACTION_NOTIFICATION; +STRUCT!{struct TRANSACTION_NOTIFICATION_RECOVERY_ARGUMENT { + EnlistmentId: GUID, + UOW: UOW, +}} +pub type PTRANSACTION_NOTIFICATION_RECOVERY_ARGUMENT + = *mut TRANSACTION_NOTIFICATION_RECOVERY_ARGUMENT; +pub const TRANSACTION_NOTIFICATION_TM_ONLINE_FLAG_IS_CLUSTERED: ULONG = 0x1; +STRUCT!{struct TRANSACTION_NOTIFICATION_TM_ONLINE_ARGUMENT { + TmIdentity: GUID, + Flags: ULONG, +}} +pub type PTRANSACTION_NOTIFICATION_TM_ONLINE_ARGUMENT + = *mut TRANSACTION_NOTIFICATION_TM_ONLINE_ARGUMENT; +pub type SAVEPOINT_ID = ULONG; +pub type PSAVEPOINT_ID = *mut ULONG; +STRUCT!{struct TRANSACTION_NOTIFICATION_SAVEPOINT_ARGUMENT { + SavepointId: SAVEPOINT_ID, +}} +pub type PTRANSACTION_NOTIFICATION_SAVEPOINT_ARGUMENT + = *mut TRANSACTION_NOTIFICATION_SAVEPOINT_ARGUMENT; +STRUCT!{struct TRANSACTION_NOTIFICATION_PROPAGATE_ARGUMENT { + PropagationCookie: ULONG, + UOW: GUID, + TmIdentity: GUID, + BufferLength: ULONG, +}} +pub type PTRANSACTION_NOTIFICATION_PROPAGATE_ARGUMENT + = *mut TRANSACTION_NOTIFICATION_PROPAGATE_ARGUMENT; +STRUCT!{struct TRANSACTION_NOTIFICATION_MARSHAL_ARGUMENT { + MarshalCookie: ULONG, + UOW: GUID, +}} +pub type PTRANSACTION_NOTIFICATION_MARSHAL_ARGUMENT + = *mut TRANSACTION_NOTIFICATION_MARSHAL_ARGUMENT; +pub type TRANSACTION_NOTIFICATION_PROMOTE_ARGUMENT = TRANSACTION_NOTIFICATION_PROPAGATE_ARGUMENT; +pub type PTRANSACTION_NOTIFICATION_PROMOTE_ARGUMENT + = *mut TRANSACTION_NOTIFICATION_PROPAGATE_ARGUMENT; +pub const KTM_MARSHAL_BLOB_VERSION_MAJOR: ULONG = 1; +pub const KTM_MARSHAL_BLOB_VERSION_MINOR: ULONG = 1; +pub const MAX_TRANSACTION_DESCRIPTION_LENGTH: usize = 64; +pub const MAX_RESOURCEMANAGER_DESCRIPTION_LENGTH: usize = 64; +STRUCT!{struct KCRM_MARSHAL_HEADER { + VersionMajor: ULONG, + VersionMinor: ULONG, + NumProtocols: ULONG, + Unused: ULONG, +}} +pub type PKCRM_MARSHAL_HEADER = *mut KCRM_MARSHAL_HEADER; +pub type PRKCRM_MARSHAL_HEADER = *mut KCRM_MARSHAL_HEADER; +STRUCT!{struct KCRM_TRANSACTION_BLOB { + UOW: UOW, + TmIdentity: GUID, + IsolationLevel: ULONG, + IsolationFlags: ULONG, + Timeout: ULONG, + Description: [WCHAR; MAX_TRANSACTION_DESCRIPTION_LENGTH], +}} +pub type PKCRM_TRANSACTION_BLOB = *mut KCRM_TRANSACTION_BLOB; +pub type PRKCRM_TRANSACTION_BLOB = *mut KCRM_TRANSACTION_BLOB; +STRUCT!{struct KCRM_PROTOCOL_BLOB { + ProtocolId: CRM_PROTOCOL_ID, + StaticInfoLength: ULONG, + TransactionIdInfoLength: ULONG, + Unused1: ULONG, + Unused2: ULONG, +}} +pub type PKCRM_PROTOCOL_BLOB = *mut KCRM_PROTOCOL_BLOB; +pub type PRKCRM_PROTOCOL_BLOB = *mut KCRM_PROTOCOL_BLOB; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/lmcons.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/lmcons.rs new file mode 100644 index 0000000..ca2819b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/lmcons.rs @@ -0,0 +1,60 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This file contains constants used throughout the LAN Manager API header files. +use shared::minwindef::DWORD; +use um::winnt::{LPCWSTR, LPWSTR}; +pub const CNLEN: DWORD = 15; +pub const LM20_CNLEN: DWORD = 15; +pub const DNLEN: DWORD = CNLEN; +pub const LM20_DNLEN: DWORD = LM20_CNLEN; +pub const UNCLEN: DWORD = CNLEN + 2; +pub const LM20_UNCLEN: DWORD = LM20_CNLEN + 2; +pub const NNLEN: DWORD = 80; +pub const LM20_NNLEN: DWORD = 12; +pub const RMLEN: DWORD = UNCLEN + 1 + NNLEN; +pub const LM20_RMLEN: DWORD = LM20_UNCLEN + 1 + LM20_NNLEN; +pub const SNLEN: usize = 80; +pub const LM20_SNLEN: DWORD = 15; +pub const STXTLEN: DWORD = 256; +pub const LM20_STXTLEN: DWORD = 63; +pub const PATHLEN: DWORD = 256; +pub const LM20_PATHLEN: DWORD = 256; +pub const DEVLEN: DWORD = 80; +pub const LM20_DEVLEN: DWORD = 8; +pub const EVLEN: usize = 16; +pub const UNLEN: DWORD = 256; +pub const LM20_UNLEN: DWORD = 20; +pub const GNLEN: DWORD = UNLEN; +pub const LM20_GNLEN: DWORD = LM20_UNLEN; +pub const PWLEN: DWORD = 256; +pub const LM20_PWLEN: DWORD = 14; +pub const SHPWLEN: DWORD = 8; +pub const CLTYPE_LEN: DWORD = 12; +pub const MAXCOMMENTSZ: DWORD = 256; +pub const LM20_MAXCOMMENTSZ: DWORD = 48; +pub const QNLEN: DWORD = NNLEN; +pub const LM20_QNLEN: DWORD = LM20_NNLEN; +pub const ALERTSZ: DWORD = 128; +pub const MAXDEVENTRIES: DWORD = 4 * 8; // FIXME: sizeof(int) instead of 4 +pub const NETBIOS_NAME_LEN: DWORD = 16; +pub const MAX_PREFERRED_LENGTH: DWORD = -1i32 as u32; +pub const CRYPT_KEY_LEN: DWORD = 7; +pub const CRYPT_TXT_LEN: DWORD = 8; +pub const ENCRYPTED_PWLEN: usize = 16; +pub const SESSION_PWLEN: DWORD = 24; +pub const SESSION_CRYPT_KLEN: DWORD = 21; +pub const PARM_ERROR_UNKNOWN: DWORD = -1i32 as u32; +pub const PARM_ERROR_NONE: DWORD = 0; +pub const PARMNUM_BASE_INFOLEVEL: DWORD = 1000; +pub type LMSTR = LPWSTR; +pub type LMCSTR = LPCWSTR; +pub type NET_API_STATUS = DWORD; +pub type API_RET_TYPE = NET_API_STATUS; +pub const PLATFORM_ID_DOS: DWORD = 300; +pub const PLATFORM_ID_OS2: DWORD = 400; +pub const PLATFORM_ID_NT: DWORD = 500; +pub const PLATFORM_ID_OSF: DWORD = 600; +pub const PLATFORM_ID_VMS: DWORD = 700; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/minwindef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/minwindef.rs new file mode 100644 index 0000000..6c2e38d --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/minwindef.rs @@ -0,0 +1,102 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Basic Windows Type Definitions for minwin partition +use ctypes::{c_char, c_float, c_int, c_long, c_uchar, c_uint, c_ulong, c_ushort, c_void}; +use shared::basetsd::{LONG_PTR, UINT_PTR}; +use shared::ntdef::{HANDLE, LONG}; +pub type ULONG = c_ulong; +pub type PULONG = *mut ULONG; +pub type USHORT = c_ushort; +pub type PUSHORT = *mut USHORT; +pub type UCHAR = c_uchar; +pub type PUCHAR = *mut UCHAR; +pub type PSZ = *mut c_char; +pub const MAX_PATH: usize = 260; +pub const FALSE: BOOL = 0; +pub const TRUE: BOOL = 1; +pub type DWORD = c_ulong; +pub type BOOL = c_int; +pub type BYTE = c_uchar; +pub type WORD = c_ushort; +pub type FLOAT = c_float; +pub type PFLOAT = *mut FLOAT; +pub type PBOOL = *mut BOOL; +pub type LPBOOL = *mut BOOL; +pub type PBYTE = *mut BYTE; +pub type LPBYTE = *mut BYTE; +pub type PINT = *mut c_int; +pub type LPINT = *mut c_int; +pub type PWORD = *mut WORD; +pub type LPWORD = *mut WORD; +pub type LPLONG = *mut c_long; +pub type PDWORD = *mut DWORD; +pub type LPDWORD = *mut DWORD; +pub type LPVOID = *mut c_void; +pub type LPCVOID = *const c_void; +pub type INT = c_int; +pub type UINT = c_uint; +pub type PUINT = *mut c_uint; +pub type WPARAM = UINT_PTR; +pub type LPARAM = LONG_PTR; +pub type LRESULT = LONG_PTR; +#[inline] +pub fn MAKEWORD(a: BYTE, b: BYTE) -> WORD { + (a as WORD) | ((b as WORD) << 8) +} +#[inline] +pub fn MAKELONG(a: WORD, b: WORD) -> LONG { + ((a as DWORD) | ((b as DWORD) << 16)) as LONG +} +#[inline] +pub fn LOWORD(l: DWORD) -> WORD { + (l & 0xffff) as WORD +} +#[inline] +pub fn HIWORD(l: DWORD) -> WORD { + ((l >> 16) & 0xffff) as WORD +} +#[inline] +pub fn LOBYTE(l: WORD) -> BYTE { + (l & 0xff) as BYTE +} +#[inline] +pub fn HIBYTE(l: WORD) -> BYTE { + ((l >> 8) & 0xff) as BYTE +} +pub type SPHANDLE = *mut HANDLE; +pub type LPHANDLE = *mut HANDLE; +pub type HGLOBAL = HANDLE; +pub type HLOCAL = HANDLE; +pub type GLOBALHANDLE = HANDLE; +pub type LOCALHANDLE = HANDLE; +pub enum __some_function {} +/// Pointer to a function with unknown type signature. +pub type FARPROC = *mut __some_function; +/// Pointer to a function with unknown type signature. +pub type NEARPROC = *mut __some_function; +/// Pointer to a function with unknown type signature. +pub type PROC = *mut __some_function; +pub type ATOM = WORD; +DECLARE_HANDLE!{HKEY, HKEY__} +pub type PHKEY = *mut HKEY; +DECLARE_HANDLE!{HMETAFILE, HMETAFILE__} +DECLARE_HANDLE!{HINSTANCE, HINSTANCE__} +pub type HMODULE = HINSTANCE; +DECLARE_HANDLE!{HRGN, HRGN__} +DECLARE_HANDLE!{HRSRC, HRSRC__} +DECLARE_HANDLE!{HSPRITE, HSPRITE__} +DECLARE_HANDLE!{HLSURF, HLSURF__} +DECLARE_HANDLE!{HSTR, HSTR__} +DECLARE_HANDLE!{HTASK, HTASK__} +DECLARE_HANDLE!{HWINSTA, HWINSTA__} +DECLARE_HANDLE!{HKL, HKL__} +pub type HFILE = c_int; +STRUCT!{#[debug] struct FILETIME { + dwLowDateTime: DWORD, + dwHighDateTime: DWORD, +}} +pub type PFILETIME = *mut FILETIME; +pub type LPFILETIME = *mut FILETIME; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/mmreg.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/mmreg.rs new file mode 100644 index 0000000..06ad900 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/mmreg.rs @@ -0,0 +1,309 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, WORD}; +pub const WAVE_FORMAT_UNKNOWN: WORD = 0x0000; +pub const WAVE_FORMAT_PCM: WORD = 0x0001; +pub const WAVE_FORMAT_ADPCM: WORD = 0x0002; +pub const WAVE_FORMAT_IEEE_FLOAT: WORD = 0x0003; +pub const WAVE_FORMAT_VSELP: WORD = 0x0004; +pub const WAVE_FORMAT_IBM_CVSD: WORD = 0x0005; +pub const WAVE_FORMAT_ALAW: WORD = 0x0006; +pub const WAVE_FORMAT_MULAW: WORD = 0x0007; +pub const WAVE_FORMAT_DTS: WORD = 0x0008; +pub const WAVE_FORMAT_DRM: WORD = 0x0009; +pub const WAVE_FORMAT_WMAVOICE9: WORD = 0x000A; +pub const WAVE_FORMAT_WMAVOICE10: WORD = 0x000B; +pub const WAVE_FORMAT_OKI_ADPCM: WORD = 0x0010; +pub const WAVE_FORMAT_DVI_ADPCM: WORD = 0x0011; +pub const WAVE_FORMAT_IMA_ADPCM: WORD = WAVE_FORMAT_DVI_ADPCM; +pub const WAVE_FORMAT_MEDIASPACE_ADPCM: WORD = 0x0012; +pub const WAVE_FORMAT_SIERRA_ADPCM: WORD = 0x0013; +pub const WAVE_FORMAT_G723_ADPCM: WORD = 0x0014; +pub const WAVE_FORMAT_DIGISTD: WORD = 0x0015; +pub const WAVE_FORMAT_DIGIFIX: WORD = 0x0016; +pub const WAVE_FORMAT_DIALOGIC_OKI_ADPCM: WORD = 0x0017; +pub const WAVE_FORMAT_MEDIAVISION_ADPCM: WORD = 0x0018; +pub const WAVE_FORMAT_CU_CODEC: WORD = 0x0019; +pub const WAVE_FORMAT_HP_DYN_VOICE: WORD = 0x001A; +pub const WAVE_FORMAT_YAMAHA_ADPCM: WORD = 0x0020; +pub const WAVE_FORMAT_SONARC: WORD = 0x0021; +pub const WAVE_FORMAT_DSPGROUP_TRUESPEECH: WORD = 0x0022; +pub const WAVE_FORMAT_ECHOSC1: WORD = 0x0023; +pub const WAVE_FORMAT_AUDIOFILE_AF36: WORD = 0x0024; +pub const WAVE_FORMAT_APTX: WORD = 0x0025; +pub const WAVE_FORMAT_AUDIOFILE_AF10: WORD = 0x0026; +pub const WAVE_FORMAT_PROSODY_1612: WORD = 0x0027; +pub const WAVE_FORMAT_LRC: WORD = 0x0028; +pub const WAVE_FORMAT_DOLBY_AC2: WORD = 0x0030; +pub const WAVE_FORMAT_GSM610: WORD = 0x0031; +pub const WAVE_FORMAT_MSNAUDIO: WORD = 0x0032; +pub const WAVE_FORMAT_ANTEX_ADPCME: WORD = 0x0033; +pub const WAVE_FORMAT_CONTROL_RES_VQLPC: WORD = 0x0034; +pub const WAVE_FORMAT_DIGIREAL: WORD = 0x0035; +pub const WAVE_FORMAT_DIGIADPCM: WORD = 0x0036; +pub const WAVE_FORMAT_CONTROL_RES_CR10: WORD = 0x0037; +pub const WAVE_FORMAT_NMS_VBXADPCM: WORD = 0x0038; +pub const WAVE_FORMAT_CS_IMAADPCM: WORD = 0x0039; +pub const WAVE_FORMAT_ECHOSC3: WORD = 0x003A; +pub const WAVE_FORMAT_ROCKWELL_ADPCM: WORD = 0x003B; +pub const WAVE_FORMAT_ROCKWELL_DIGITALK: WORD = 0x003C; +pub const WAVE_FORMAT_XEBEC: WORD = 0x003D; +pub const WAVE_FORMAT_G721_ADPCM: WORD = 0x0040; +pub const WAVE_FORMAT_G728_CELP: WORD = 0x0041; +pub const WAVE_FORMAT_MSG723: WORD = 0x0042; +pub const WAVE_FORMAT_INTEL_G723_1: WORD = 0x0043; +pub const WAVE_FORMAT_INTEL_G729: WORD = 0x0044; +pub const WAVE_FORMAT_SHARP_G726: WORD = 0x0045; +pub const WAVE_FORMAT_MPEG: WORD = 0x0050; +pub const WAVE_FORMAT_RT24: WORD = 0x0052; +pub const WAVE_FORMAT_PAC: WORD = 0x0053; +pub const WAVE_FORMAT_MPEGLAYER3: WORD = 0x0055; +pub const WAVE_FORMAT_LUCENT_G723: WORD = 0x0059; +pub const WAVE_FORMAT_CIRRUS: WORD = 0x0060; +pub const WAVE_FORMAT_ESPCM: WORD = 0x0061; +pub const WAVE_FORMAT_VOXWARE: WORD = 0x0062; +pub const WAVE_FORMAT_CANOPUS_ATRAC: WORD = 0x0063; +pub const WAVE_FORMAT_G726_ADPCM: WORD = 0x0064; +pub const WAVE_FORMAT_G722_ADPCM: WORD = 0x0065; +pub const WAVE_FORMAT_DSAT: WORD = 0x0066; +pub const WAVE_FORMAT_DSAT_DISPLAY: WORD = 0x0067; +pub const WAVE_FORMAT_VOXWARE_BYTE_ALIGNED: WORD = 0x0069; +pub const WAVE_FORMAT_VOXWARE_AC8: WORD = 0x0070; +pub const WAVE_FORMAT_VOXWARE_AC10: WORD = 0x0071; +pub const WAVE_FORMAT_VOXWARE_AC16: WORD = 0x0072; +pub const WAVE_FORMAT_VOXWARE_AC20: WORD = 0x0073; +pub const WAVE_FORMAT_VOXWARE_RT24: WORD = 0x0074; +pub const WAVE_FORMAT_VOXWARE_RT29: WORD = 0x0075; +pub const WAVE_FORMAT_VOXWARE_RT29HW: WORD = 0x0076; +pub const WAVE_FORMAT_VOXWARE_VR12: WORD = 0x0077; +pub const WAVE_FORMAT_VOXWARE_VR18: WORD = 0x0078; +pub const WAVE_FORMAT_VOXWARE_TQ40: WORD = 0x0079; +pub const WAVE_FORMAT_VOXWARE_SC3: WORD = 0x007A; +pub const WAVE_FORMAT_VOXWARE_SC3_1: WORD = 0x007B; +pub const WAVE_FORMAT_SOFTSOUND: WORD = 0x0080; +pub const WAVE_FORMAT_VOXWARE_TQ60: WORD = 0x0081; +pub const WAVE_FORMAT_MSRT24: WORD = 0x0082; +pub const WAVE_FORMAT_G729A: WORD = 0x0083; +pub const WAVE_FORMAT_MVI_MVI2: WORD = 0x0084; +pub const WAVE_FORMAT_DF_G726: WORD = 0x0085; +pub const WAVE_FORMAT_DF_GSM610: WORD = 0x0086; +pub const WAVE_FORMAT_ISIAUDIO: WORD = 0x0088; +pub const WAVE_FORMAT_ONLIVE: WORD = 0x0089; +pub const WAVE_FORMAT_MULTITUDE_FT_SX20: WORD = 0x008A; +pub const WAVE_FORMAT_INFOCOM_ITS_G721_ADPCM: WORD = 0x008B; +pub const WAVE_FORMAT_CONVEDIA_G729: WORD = 0x008C; +pub const WAVE_FORMAT_CONGRUENCY: WORD = 0x008D; +pub const WAVE_FORMAT_SBC24: WORD = 0x0091; +pub const WAVE_FORMAT_DOLBY_AC3_SPDIF: WORD = 0x0092; +pub const WAVE_FORMAT_MEDIASONIC_G723: WORD = 0x0093; +pub const WAVE_FORMAT_PROSODY_8KBPS: WORD = 0x0094; +pub const WAVE_FORMAT_ZYXEL_ADPCM: WORD = 0x0097; +pub const WAVE_FORMAT_PHILIPS_LPCBB: WORD = 0x0098; +pub const WAVE_FORMAT_PACKED: WORD = 0x0099; +pub const WAVE_FORMAT_MALDEN_PHONYTALK: WORD = 0x00A0; +pub const WAVE_FORMAT_RACAL_RECORDER_GSM: WORD = 0x00A1; +pub const WAVE_FORMAT_RACAL_RECORDER_G720_A: WORD = 0x00A2; +pub const WAVE_FORMAT_RACAL_RECORDER_G723_1: WORD = 0x00A3; +pub const WAVE_FORMAT_RACAL_RECORDER_TETRA_ACELP: WORD = 0x00A4; +pub const WAVE_FORMAT_NEC_AAC: WORD = 0x00B0; +pub const WAVE_FORMAT_RAW_AAC1: WORD = 0x00FF; +pub const WAVE_FORMAT_RHETOREX_ADPCM: WORD = 0x0100; +pub const WAVE_FORMAT_IRAT: WORD = 0x0101; +pub const WAVE_FORMAT_VIVO_G723: WORD = 0x0111; +pub const WAVE_FORMAT_VIVO_SIREN: WORD = 0x0112; +pub const WAVE_FORMAT_PHILIPS_CELP: WORD = 0x0120; +pub const WAVE_FORMAT_PHILIPS_GRUNDIG: WORD = 0x0121; +pub const WAVE_FORMAT_DIGITAL_G723: WORD = 0x0123; +pub const WAVE_FORMAT_SANYO_LD_ADPCM: WORD = 0x0125; +pub const WAVE_FORMAT_SIPROLAB_ACEPLNET: WORD = 0x0130; +pub const WAVE_FORMAT_SIPROLAB_ACELP4800: WORD = 0x0131; +pub const WAVE_FORMAT_SIPROLAB_ACELP8V3: WORD = 0x0132; +pub const WAVE_FORMAT_SIPROLAB_G729: WORD = 0x0133; +pub const WAVE_FORMAT_SIPROLAB_G729A: WORD = 0x0134; +pub const WAVE_FORMAT_SIPROLAB_KELVIN: WORD = 0x0135; +pub const WAVE_FORMAT_VOICEAGE_AMR: WORD = 0x0136; +pub const WAVE_FORMAT_G726ADPCM: WORD = 0x0140; +pub const WAVE_FORMAT_DICTAPHONE_CELP68: WORD = 0x0141; +pub const WAVE_FORMAT_DICTAPHONE_CELP54: WORD = 0x0142; +pub const WAVE_FORMAT_QUALCOMM_PUREVOICE: WORD = 0x0150; +pub const WAVE_FORMAT_QUALCOMM_HALFRATE: WORD = 0x0151; +pub const WAVE_FORMAT_TUBGSM: WORD = 0x0155; +pub const WAVE_FORMAT_MSAUDIO1: WORD = 0x0160; +pub const WAVE_FORMAT_WMAUDIO2: WORD = 0x0161; +pub const WAVE_FORMAT_WMAUDIO3: WORD = 0x0162; +pub const WAVE_FORMAT_WMAUDIO_LOSSLESS: WORD = 0x0163; +pub const WAVE_FORMAT_WMASPDIF: WORD = 0x0164; +pub const WAVE_FORMAT_UNISYS_NAP_ADPCM: WORD = 0x0170; +pub const WAVE_FORMAT_UNISYS_NAP_ULAW: WORD = 0x0171; +pub const WAVE_FORMAT_UNISYS_NAP_ALAW: WORD = 0x0172; +pub const WAVE_FORMAT_UNISYS_NAP_16K: WORD = 0x0173; +pub const WAVE_FORMAT_SYCOM_ACM_SYC008: WORD = 0x0174; +pub const WAVE_FORMAT_SYCOM_ACM_SYC701_G726L: WORD = 0x0175; +pub const WAVE_FORMAT_SYCOM_ACM_SYC701_CELP54: WORD = 0x0176; +pub const WAVE_FORMAT_SYCOM_ACM_SYC701_CELP68: WORD = 0x0177; +pub const WAVE_FORMAT_KNOWLEDGE_ADVENTURE_ADPCM: WORD = 0x0178; +pub const WAVE_FORMAT_FRAUNHOFER_IIS_MPEG2_AAC: WORD = 0x0180; +pub const WAVE_FORMAT_DTS_DS: WORD = 0x0190; +pub const WAVE_FORMAT_CREATIVE_ADPCM: WORD = 0x0200; +pub const WAVE_FORMAT_CREATIVE_FASTSPEECH8: WORD = 0x0202; +pub const WAVE_FORMAT_CREATIVE_FASTSPEECH10: WORD = 0x0203; +pub const WAVE_FORMAT_UHER_ADPCM: WORD = 0x0210; +pub const WAVE_FORMAT_ULEAD_DV_AUDIO: WORD = 0x0215; +pub const WAVE_FORMAT_ULEAD_DV_AUDIO_1: WORD = 0x0216; +pub const WAVE_FORMAT_QUARTERDECK: WORD = 0x0220; +pub const WAVE_FORMAT_ILINK_VC: WORD = 0x0230; +pub const WAVE_FORMAT_RAW_SPORT: WORD = 0x0240; +pub const WAVE_FORMAT_ESST_AC3: WORD = 0x0241; +pub const WAVE_FORMAT_GENERIC_PASSTHRU: WORD = 0x0249; +pub const WAVE_FORMAT_IPI_HSX: WORD = 0x0250; +pub const WAVE_FORMAT_IPI_RPELP: WORD = 0x0251; +pub const WAVE_FORMAT_CS2: WORD = 0x0260; +pub const WAVE_FORMAT_SONY_SCX: WORD = 0x0270; +pub const WAVE_FORMAT_SONY_SCY: WORD = 0x0271; +pub const WAVE_FORMAT_SONY_ATRAC3: WORD = 0x0272; +pub const WAVE_FORMAT_SONY_SPC: WORD = 0x0273; +pub const WAVE_FORMAT_TELUM_AUDIO: WORD = 0x0280; +pub const WAVE_FORMAT_TELUM_IA_AUDIO: WORD = 0x0281; +pub const WAVE_FORMAT_NORCOM_VOICE_SYSTEMS_ADPCM: WORD = 0x0285; +pub const WAVE_FORMAT_FM_TOWNS_SND: WORD = 0x0300; +pub const WAVE_FORMAT_MICRONAS: WORD = 0x0350; +pub const WAVE_FORMAT_MICRONAS_CELP833: WORD = 0x0351; +pub const WAVE_FORMAT_BTV_DIGITAL: WORD = 0x0400; +pub const WAVE_FORMAT_INTEL_MUSIC_CODER: WORD = 0x0401; +pub const WAVE_FORMAT_INDEO_AUDIO: WORD = 0x0402; +pub const WAVE_FORMAT_QDESIGN_MUSIC: WORD = 0x0450; +pub const WAVE_FORMAT_ON2_VP7_AUDIO: WORD = 0x0500; +pub const WAVE_FORMAT_ON2_VP6_AUDIO: WORD = 0x0501; +pub const WAVE_FORMAT_VME_VMPCM: WORD = 0x0680; +pub const WAVE_FORMAT_TPC: WORD = 0x0681; +pub const WAVE_FORMAT_LIGHTWAVE_LOSSLESS: WORD = 0x08AE; +pub const WAVE_FORMAT_OLIGSM: WORD = 0x1000; +pub const WAVE_FORMAT_OLIADPCM: WORD = 0x1001; +pub const WAVE_FORMAT_OLICELP: WORD = 0x1002; +pub const WAVE_FORMAT_OLISBC: WORD = 0x1003; +pub const WAVE_FORMAT_OLIOPR: WORD = 0x1004; +pub const WAVE_FORMAT_LH_CODEC: WORD = 0x1100; +pub const WAVE_FORMAT_LH_CODEC_CELP: WORD = 0x1101; +pub const WAVE_FORMAT_LH_CODEC_SBC8: WORD = 0x1102; +pub const WAVE_FORMAT_LH_CODEC_SBC12: WORD = 0x1103; +pub const WAVE_FORMAT_LH_CODEC_SBC16: WORD = 0x1104; +pub const WAVE_FORMAT_NORRIS: WORD = 0x1400; +pub const WAVE_FORMAT_ISIAUDIO_2: WORD = 0x1401; +pub const WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS: WORD = 0x1500; +pub const WAVE_FORMAT_MPEG_ADTS_AAC: WORD = 0x1600; +pub const WAVE_FORMAT_MPEG_RAW_AAC: WORD = 0x1601; +pub const WAVE_FORMAT_MPEG_LOAS: WORD = 0x1602; +pub const WAVE_FORMAT_NOKIA_MPEG_ADTS_AAC: WORD = 0x1608; +pub const WAVE_FORMAT_NOKIA_MPEG_RAW_AAC: WORD = 0x1609; +pub const WAVE_FORMAT_VODAFONE_MPEG_ADTS_AAC: WORD = 0x160A; +pub const WAVE_FORMAT_VODAFONE_MPEG_RAW_AAC: WORD = 0x160B; +pub const WAVE_FORMAT_MPEG_HEAAC: WORD = 0x1610; +pub const WAVE_FORMAT_VOXWARE_RT24_SPEECH: WORD = 0x181C; +pub const WAVE_FORMAT_SONICFOUNDRY_LOSSLESS: WORD = 0x1971; +pub const WAVE_FORMAT_INNINGS_TELECOM_ADPCM: WORD = 0x1979; +pub const WAVE_FORMAT_LUCENT_SX8300P: WORD = 0x1C07; +pub const WAVE_FORMAT_LUCENT_SX5363S: WORD = 0x1C0C; +pub const WAVE_FORMAT_CUSEEME: WORD = 0x1F03; +pub const WAVE_FORMAT_NTCSOFT_ALF2CM_ACM: WORD = 0x1FC4; +pub const WAVE_FORMAT_DVM: WORD = 0x2000; +pub const WAVE_FORMAT_DTS2: WORD = 0x2001; +pub const WAVE_FORMAT_MAKEAVIS: WORD = 0x3313; +pub const WAVE_FORMAT_DIVIO_MPEG4_AAC: WORD = 0x4143; +pub const WAVE_FORMAT_NOKIA_ADAPTIVE_MULTIRATE: WORD = 0x4201; +pub const WAVE_FORMAT_DIVIO_G726: WORD = 0x4243; +pub const WAVE_FORMAT_LEAD_SPEECH: WORD = 0x434C; +pub const WAVE_FORMAT_LEAD_VORBIS: WORD = 0x564C; +pub const WAVE_FORMAT_WAVPACK_AUDIO: WORD = 0x5756; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_1: WORD = 0x674F; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_2: WORD = 0x6750; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_3: WORD = 0x6751; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_1_PLUS: WORD = 0x676F; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_2_PLUS: WORD = 0x6770; +pub const WAVE_FORMAT_OGG_VORBIS_MODE_3_PLUS: WORD = 0x6771; +pub const WAVE_FORMAT_3COM_NBX: WORD = 0x7000; +pub const WAVE_FORMAT_FAAD_AAC: WORD = 0x706D; +pub const WAVE_FORMAT_AMR_NB: WORD = 0x7361; +pub const WAVE_FORMAT_AMR_WB: WORD = 0x7362; +pub const WAVE_FORMAT_AMR_WP: WORD = 0x7363; +pub const WAVE_FORMAT_GSM_AMR_CBR: WORD = 0x7A21; +pub const WAVE_FORMAT_GSM_AMR_VBR_SID: WORD = 0x7A22; +pub const WAVE_FORMAT_COMVERSE_INFOSYS_G723_1: WORD = 0xA100; +pub const WAVE_FORMAT_COMVERSE_INFOSYS_AVQSBC: WORD = 0xA101; +pub const WAVE_FORMAT_COMVERSE_INFOSYS_SBC: WORD = 0xA102; +pub const WAVE_FORMAT_SYMBOL_G729_A: WORD = 0xA103; +pub const WAVE_FORMAT_VOICEAGE_AMR_WB: WORD = 0xA104; +pub const WAVE_FORMAT_INGENIENT_G726: WORD = 0xA105; +pub const WAVE_FORMAT_MPEG4_AAC: WORD = 0xA106; +pub const WAVE_FORMAT_ENCORE_G726: WORD = 0xA107; +pub const WAVE_FORMAT_ZOLL_ASAO: WORD = 0xA108; +pub const WAVE_FORMAT_SPEEX_VOICE: WORD = 0xA109; +pub const WAVE_FORMAT_VIANIX_MASC: WORD = 0xA10A; +pub const WAVE_FORMAT_WM9_SPECTRUM_ANALYZER: WORD = 0xA10B; +pub const WAVE_FORMAT_WMF_SPECTRUM_ANAYZER: WORD = 0xA10C; +pub const WAVE_FORMAT_GSM_610: WORD = 0xA10D; +pub const WAVE_FORMAT_GSM_620: WORD = 0xA10E; +pub const WAVE_FORMAT_GSM_660: WORD = 0xA10F; +pub const WAVE_FORMAT_GSM_690: WORD = 0xA110; +pub const WAVE_FORMAT_GSM_ADAPTIVE_MULTIRATE_WB: WORD = 0xA111; +pub const WAVE_FORMAT_POLYCOM_G722: WORD = 0xA112; +pub const WAVE_FORMAT_POLYCOM_G728: WORD = 0xA113; +pub const WAVE_FORMAT_POLYCOM_G729_A: WORD = 0xA114; +pub const WAVE_FORMAT_POLYCOM_SIREN: WORD = 0xA115; +pub const WAVE_FORMAT_GLOBAL_IP_ILBC: WORD = 0xA116; +pub const WAVE_FORMAT_RADIOTIME_TIME_SHIFT_RADIO: WORD = 0xA117; +pub const WAVE_FORMAT_NICE_ACA: WORD = 0xA118; +pub const WAVE_FORMAT_NICE_ADPCM: WORD = 0xA119; +pub const WAVE_FORMAT_VOCORD_G721: WORD = 0xA11A; +pub const WAVE_FORMAT_VOCORD_G726: WORD = 0xA11B; +pub const WAVE_FORMAT_VOCORD_G722_1: WORD = 0xA11C; +pub const WAVE_FORMAT_VOCORD_G728: WORD = 0xA11D; +pub const WAVE_FORMAT_VOCORD_G729: WORD = 0xA11E; +pub const WAVE_FORMAT_VOCORD_G729_A: WORD = 0xA11F; +pub const WAVE_FORMAT_VOCORD_G723_1: WORD = 0xA120; +pub const WAVE_FORMAT_VOCORD_LBC: WORD = 0xA121; +pub const WAVE_FORMAT_NICE_G728: WORD = 0xA122; +pub const WAVE_FORMAT_FRACE_TELECOM_G729: WORD = 0xA123; +pub const WAVE_FORMAT_CODIAN: WORD = 0xA124; +pub const WAVE_FORMAT_FLAC: WORD = 0xF1AC; +pub const WAVE_FORMAT_EXTENSIBLE: WORD = 0xFFFE; +pub const WAVE_FORMAT_DEVELOPMENT: WORD = 0xFFFF; +//2557 +pub const SPEAKER_FRONT_LEFT: DWORD = 0x1; +pub const SPEAKER_FRONT_RIGHT: DWORD = 0x2; +pub const SPEAKER_FRONT_CENTER: DWORD = 0x4; +pub const SPEAKER_LOW_FREQUENCY: DWORD = 0x8; +pub const SPEAKER_BACK_LEFT: DWORD = 0x10; +pub const SPEAKER_BACK_RIGHT: DWORD = 0x20; +pub const SPEAKER_FRONT_LEFT_OF_CENTER: DWORD = 0x40; +pub const SPEAKER_FRONT_RIGHT_OF_CENTER: DWORD = 0x80; +pub const SPEAKER_BACK_CENTER: DWORD = 0x100; +pub const SPEAKER_SIDE_LEFT: DWORD = 0x200; +pub const SPEAKER_SIDE_RIGHT: DWORD = 0x400; +pub const SPEAKER_TOP_CENTER: DWORD = 0x800; +pub const SPEAKER_TOP_FRONT_LEFT: DWORD = 0x1000; +pub const SPEAKER_TOP_FRONT_CENTER: DWORD = 0x2000; +pub const SPEAKER_TOP_FRONT_RIGHT: DWORD = 0x4000; +pub const SPEAKER_TOP_BACK_LEFT: DWORD = 0x8000; +pub const SPEAKER_TOP_BACK_CENTER: DWORD = 0x10000; +pub const SPEAKER_TOP_BACK_RIGHT: DWORD = 0x20000; +pub const SPEAKER_RESERVED: DWORD = 0x7FFC0000; +pub const SPEAKER_ALL: DWORD = 0x80000000; +STRUCT!{#[repr(packed)] struct WAVEFORMATEX { + wFormatTag: WORD, + nChannels: WORD, + nSamplesPerSec: DWORD, + nAvgBytesPerSec: DWORD, + nBlockAlign: WORD, + wBitsPerSample: WORD, + cbSize: WORD, +}} +STRUCT!{#[repr(packed)] struct WAVEFORMATEXTENSIBLE { + Format: WAVEFORMATEX, + Samples: WORD, + dwChannelMask: DWORD, + SubFormat: GUID, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/mod.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/mod.rs new file mode 100644 index 0000000..6867fa0 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/mod.rs @@ -0,0 +1,78 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Headers shared between user mode and kernel mode +#[cfg(feature = "basetsd")] pub mod basetsd; +#[cfg(feature = "bcrypt")] pub mod bcrypt; +#[cfg(feature = "bthdef")] pub mod bthdef; +#[cfg(feature = "bthioctl")] pub mod bthioctl; +#[cfg(feature = "bthsdpdef")] pub mod bthsdpdef; +#[cfg(feature = "bugcodes")] pub mod bugcodes; +#[cfg(feature = "cderr")] pub mod cderr; +#[cfg(feature = "cfg")] pub mod cfg; +#[cfg(feature = "d3d9")] pub mod d3d9; +#[cfg(feature = "d3d9caps")] pub mod d3d9caps; +#[cfg(feature = "d3d9types")] pub mod d3d9types; +#[cfg(feature = "d3dkmdt")] pub mod d3dkmdt; +#[cfg(feature = "d3dukmdt")] pub mod d3dukmdt; +#[cfg(feature = "dcomptypes")] pub mod dcomptypes; +#[cfg(feature = "devguid")] pub mod devguid; +#[cfg(feature = "devpkey")] pub mod devpkey; +#[cfg(feature = "devpropdef")] pub mod devpropdef; +#[cfg(feature = "dinputd")] pub mod dinputd; +#[cfg(feature = "dxgi")] pub mod dxgi; +#[cfg(feature = "dxgi1_2")] pub mod dxgi1_2; +#[cfg(feature = "dxgi1_3")] pub mod dxgi1_3; +#[cfg(feature = "dxgi1_4")] pub mod dxgi1_4; +#[cfg(feature = "dxgi1_5")] pub mod dxgi1_5; +#[cfg(feature = "dxgi1_6")] pub mod dxgi1_6; +#[cfg(feature = "dxgiformat")] pub mod dxgiformat; +#[cfg(feature = "dxgitype")] pub mod dxgitype; +#[cfg(feature = "evntprov")] pub mod evntprov; +#[cfg(feature = "evntrace")] pub mod evntrace; +pub mod guiddef; +#[cfg(feature = "hidclass")] pub mod hidclass; +#[cfg(feature = "hidpi")] pub mod hidpi; +#[cfg(feature = "hidsdi")] pub mod hidsdi; +#[cfg(feature = "hidusage")] pub mod hidusage; +#[cfg(feature = "ifdef")] pub mod ifdef; +#[cfg(feature = "in6addr")] pub mod in6addr; +#[cfg(feature = "inaddr")] pub mod inaddr; +#[cfg(feature = "intsafe")] pub mod intsafe; +#[cfg(feature = "ks")] pub mod ks; +#[cfg(feature = "ksmedia")] pub mod ksmedia; +#[cfg(feature = "ktmtypes")] pub mod ktmtypes; +#[cfg(feature = "lmcons")] pub mod lmcons; +#[cfg(feature = "minwindef")] pub mod minwindef; +#[cfg(feature = "mmreg")] pub mod mmreg; +#[cfg(feature = "mstcpip")] pub mod mstcpip; +#[cfg(feature = "mswsockdef")] pub mod mswsockdef; +#[cfg(feature = "netioapi")] pub mod netioapi; +#[cfg(feature = "ntddscsi")] pub mod ntddscsi; +#[cfg(feature = "ntddser")] pub mod ntddser; +#[cfg(feature = "ntdef")] pub mod ntdef; +#[cfg(feature = "ntstatus")] pub mod ntstatus; +#[cfg(feature = "qos")] pub mod qos; +#[cfg(feature = "rpc")] pub mod rpc; +#[cfg(feature = "rpcdce")] pub mod rpcdce; +#[cfg(feature = "rpcndr")] pub mod rpcndr; +#[cfg(feature = "sddl")] pub mod sddl; +#[cfg(feature = "sspi")] pub mod sspi; +#[cfg(feature = "stralign")] pub mod stralign; +#[cfg(feature = "transportsettingcommon")] pub mod transportsettingcommon; +#[cfg(feature = "tvout")] pub mod tvout; +#[cfg(feature = "usb")] pub mod usb; +#[cfg(feature = "usbiodef")] pub mod usbiodef; +#[cfg(feature = "usbspec")] pub mod usbspec; +#[cfg(feature = "windef")] pub mod windef; +#[cfg(feature = "windowsx")] pub mod windowsx; +#[cfg(feature = "winerror")] pub mod winerror; +#[cfg(feature = "winusbio")] pub mod winusbio; +#[cfg(feature = "wmistr")] pub mod wmistr; +#[cfg(feature = "wnnc")] pub mod wnnc; +#[cfg(feature = "ws2def")] pub mod ws2def; +#[cfg(feature = "ws2ipdef")] pub mod ws2ipdef; +#[cfg(feature = "wtypes")] pub mod wtypes; +#[cfg(feature = "wtypesbase")] pub mod wtypesbase; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/mstcpip.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/mstcpip.rs new file mode 100644 index 0000000..fe20725 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/mstcpip.rs @@ -0,0 +1,492 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! This module contains Microsoft-specific extensions to the core Winsock definitions. +use ctypes::wchar_t; +use shared::basetsd::{UINT32, UINT64, ULONG64}; +use shared::guiddef::GUID; +use shared::in6addr::IN6_ADDR; +use shared::inaddr::IN_ADDR; +use shared::minwindef::{DWORD, PULONG, PUSHORT, UCHAR, ULONG, USHORT}; +use shared::ws2def::{ + INADDR_ANY, INADDR_BROADCAST, INADDR_NONE, IOC_VENDOR, SOCKADDR_IN, + SOCKADDR_STORAGE, +}; +use um::winnt::{BOOLEAN, LONG, LPCWSTR, PCSTR, PCWSTR, PSTR, PWSTR}; +DEFINE_GUID!{SOCKET_DEFAULT2_QM_POLICY, + 0xaec2ef9c, 0x3a4d, 0x4d3e, 0x88, 0x42, 0x23, 0x99, 0x42, 0xe3, 0x9a, 0x47} +DEFINE_GUID!{REAL_TIME_NOTIFICATION_CAPABILITY, + 0x6b59819a, 0x5cae, 0x492d, 0xa9, 0x01, 0x2a, 0x3c, 0x2c, 0x50, 0x16, 0x4f} +DEFINE_GUID!{REAL_TIME_NOTIFICATION_CAPABILITY_EX, + 0x6843da03, 0x154a, 0x4616, 0xa5, 0x08, 0x44, 0x37, 0x12, 0x95, 0xf9, 0x6b} +DEFINE_GUID!{ASSOCIATE_NAMERES_CONTEXT, + 0x59a38b67, 0xd4fe, 0x46e1, 0xba, 0x3c, 0x87, 0xea, 0x74, 0xca, 0x30, 0x49} +ENUM!{enum TCPSTATE { + TCPSTATE_CLOSED, + TCPSTATE_LISTEN, + TCPSTATE_SYN_SENT, + TCPSTATE_SYN_RCVD, + TCPSTATE_ESTABLISHED, + TCPSTATE_FIN_WAIT_1, + TCPSTATE_FIN_WAIT_2, + TCPSTATE_CLOSE_WAIT, + TCPSTATE_CLOSING, + TCPSTATE_LAST_ACK, + TCPSTATE_TIME_WAIT, + TCPSTATE_MAX, +}} +STRUCT!{struct TRANSPORT_SETTING_ID { + Guid: GUID, +}} +pub type PTRANSPORT_SETTING_ID = *mut TRANSPORT_SETTING_ID; +STRUCT!{struct tcp_keepalive { + onoff: ULONG, + keepalivetime: ULONG, + keepaliveinterval: ULONG, +}} +ENUM!{enum CONTROL_CHANNEL_TRIGGER_STATUS { + CONTROL_CHANNEL_TRIGGER_STATUS_INVALID = 0, + CONTROL_CHANNEL_TRIGGER_STATUS_SOFTWARE_SLOT_ALLOCATED = 1, + CONTROL_CHANNEL_TRIGGER_STATUS_HARDWARE_SLOT_ALLOCATED = 2, + CONTROL_CHANNEL_TRIGGER_STATUS_POLICY_ERROR = 3, + CONTROL_CHANNEL_TRIGGER_STATUS_SYSTEM_ERROR = 4, + CONTROL_CHANNEL_TRIGGER_STATUS_TRANSPORT_DISCONNECTED = 5, + CONTROL_CHANNEL_TRIGGER_STATUS_SERVICE_UNAVAILABLE = 6, +}} +pub type PCONTROL_CHANNEL_TRIGGER_STATUS = *mut CONTROL_CHANNEL_TRIGGER_STATUS; +pub const CONTROL_CHANNEL_TRIGGER_STATUS_MAX: u32 = CONTROL_CHANNEL_TRIGGER_STATUS_SYSTEM_ERROR; +STRUCT!{struct REAL_TIME_NOTIFICATION_SETTING_INPUT { + TransportSettingId: TRANSPORT_SETTING_ID, + BrokerEventGuid: GUID, +}} +pub type PREAL_TIME_NOTIFICATION_SETTING_INPUT = *mut REAL_TIME_NOTIFICATION_SETTING_INPUT; +STRUCT!{struct REAL_TIME_NOTIFICATION_SETTING_INPUT_EX { + TransportSettingId: TRANSPORT_SETTING_ID, + BrokerEventGuid: GUID, + Unmark: BOOLEAN, +}} +pub type PREAL_TIME_NOTIFICATION_SETTING_INPUT_EX = *mut REAL_TIME_NOTIFICATION_SETTING_INPUT_EX; +STRUCT!{struct REAL_TIME_NOTIFICATION_SETTING_OUTPUT { + ChannelStatus: CONTROL_CHANNEL_TRIGGER_STATUS, +}} +pub type PREAL_TIME_NOTIFICATION_SETTING_OUTPUT = *mut REAL_TIME_NOTIFICATION_SETTING_OUTPUT; +STRUCT!{struct ASSOCIATE_NAMERES_CONTEXT_INPUT { + TransportSettingId: TRANSPORT_SETTING_ID, + Handle: UINT64, +}} +pub type PASSOCIATE_NAMERES_CONTEXT_INPUT = *mut ASSOCIATE_NAMERES_CONTEXT_INPUT; +pub const SIO_RCVALL: DWORD = _WSAIOW!(IOC_VENDOR,1); +pub const SIO_RCVALL_MCAST: DWORD = _WSAIOW!(IOC_VENDOR,2); +pub const SIO_RCVALL_IGMPMCAST: DWORD = _WSAIOW!(IOC_VENDOR,3); +pub const SIO_KEEPALIVE_VALS: DWORD = _WSAIOW!(IOC_VENDOR,4); +pub const SIO_ABSORB_RTRALERT: DWORD = _WSAIOW!(IOC_VENDOR,5); +pub const SIO_UCAST_IF: DWORD = _WSAIOW!(IOC_VENDOR,6); +pub const SIO_LIMIT_BROADCASTS: DWORD = _WSAIOW!(IOC_VENDOR,7); +pub const SIO_INDEX_BIND: DWORD = _WSAIOW!(IOC_VENDOR,8); +pub const SIO_INDEX_MCASTIF: DWORD = _WSAIOW!(IOC_VENDOR,9); +pub const SIO_INDEX_ADD_MCAST: DWORD = _WSAIOW!(IOC_VENDOR,10); +pub const SIO_INDEX_DEL_MCAST: DWORD = _WSAIOW!(IOC_VENDOR,11); +pub const SIO_RCVALL_MCAST_IF: DWORD = _WSAIOW!(IOC_VENDOR,13); +pub const SIO_RCVALL_IF: DWORD = _WSAIOW!(IOC_VENDOR,14); +pub const SIO_LOOPBACK_FAST_PATH: DWORD = _WSAIOW!(IOC_VENDOR,16); +pub const SIO_TCP_INITIAL_RTO: DWORD = _WSAIOW!(IOC_VENDOR,17); +pub const SIO_APPLY_TRANSPORT_SETTING: DWORD = _WSAIOW!(IOC_VENDOR,19); +pub const SIO_QUERY_TRANSPORT_SETTING: DWORD = _WSAIOW!(IOC_VENDOR,20); +pub const SIO_TCP_SET_ICW: DWORD = _WSAIOW!(IOC_VENDOR,22); +pub const SIO_TCP_SET_ACK_FREQUENCY: DWORD = _WSAIOW!(IOC_VENDOR,23); +pub const SIO_TCP_INFO: DWORD = _WSAIORW!(IOC_VENDOR,39); +ENUM!{enum RCVALL_VALUE { + RCVALL_OFF = 0, + RCVALL_ON = 1, + RCVALL_SOCKETLEVELONLY = 2, + RCVALL_IPLEVEL = 3, +}} +pub type PRCVALL_VALUE = *mut RCVALL_VALUE; +STRUCT!{struct RCVALL_IF { + Mode: RCVALL_VALUE, + Interface: ULONG, +}} +pub type PRCVALL_IF = *mut RCVALL_IF; +pub const TCP_INITIAL_RTO_UNSPECIFIED_RTT: USHORT = -1i16 as u16; +pub const TCP_INITIAL_RTO_UNSPECIFIED_MAX_SYN_RETRANSMISSIONS: UCHAR = -1i8 as u8; +pub const TCP_INITIAL_RTO_DEFAULT_RTT: USHORT = 0; +pub const TCP_INITIAL_RTO_DEFAULT_MAX_SYN_RETRANSMISSIONS: UCHAR = 0; +STRUCT!{struct TCP_INITIAL_RTO_PARAMETERS { + Rtt: USHORT, + MaxSynRetransmissions: UCHAR, +}} +pub type PTCP_INITIAL_RTO_PARAMETERS = *mut TCP_INITIAL_RTO_PARAMETERS; +ENUM!{enum TCP_ICW_LEVEL { + TCP_ICW_LEVEL_DEFAULT = 0, + TCP_ICW_LEVEL_HIGH = 1, + TCP_ICW_LEVEL_VERY_HIGH = 2, + TCP_ICW_LEVEL_AGGRESSIVE = 3, + TCP_ICW_LEVEL_EXPERIMENTAL = 4, + TCP_ICW_LEVEL_COMPAT = 254, + TCP_ICW_LEVEL_MAX = 255, +}} +pub type PTCP_ICW_LEVEL = *mut TCP_ICW_LEVEL; +STRUCT!{struct TCP_ICW_PARAMETERS { + Level: TCP_ICW_LEVEL, +}} +pub type PTCP_ICW_PARAMETERS = *mut TCP_ICW_PARAMETERS; +STRUCT!{struct TCP_ACK_FREQUENCY_PARAMETERS { + TcpDelayedAckFrequency: UCHAR, +}} +pub type PTCP_ACK_FREQUENCY_PARAMETERS = *mut TCP_ACK_FREQUENCY_PARAMETERS; +STRUCT!{struct TCP_INFO_v0 { + State: TCPSTATE, + Mss: ULONG, + ConnectionTimeMs: ULONG64, + TimestampsEnabled: BOOLEAN, + RttUs: ULONG, + MinRttUs: ULONG, + BytesInFlight: ULONG, + Cwnd: ULONG, + SndWnd: ULONG, + RcvWnd: ULONG, + RcvBuf: ULONG, + BytesOut: ULONG64, + BytesIn: ULONG64, + BytesReordered: ULONG, + BytesRetrans: ULONG, + FastRetrans: ULONG, + DupAcksIn: ULONG, + TimeoutEpisodes: ULONG, + SynRetrans: UCHAR, +}} +pub type PTCP_INFO_v0 = *mut TCP_INFO_v0; +pub const SIO_ACQUIRE_PORT_RESERVATION: DWORD = _WSAIOW!(IOC_VENDOR, 100); +pub const SIO_RELEASE_PORT_RESERVATION: DWORD = _WSAIOW!(IOC_VENDOR, 101); +pub const SIO_ASSOCIATE_PORT_RESERVATION: DWORD = _WSAIOW!(IOC_VENDOR, 102); +STRUCT!{struct INET_PORT_RANGE { + StartPort: USHORT, + NumberOfPorts: USHORT, +}} +pub type PINET_PORT_RANGE = *mut INET_PORT_RANGE; +pub type INET_PORT_RESERVATION = INET_PORT_RANGE; +pub type PINET_PORT_RESERVATION = *mut INET_PORT_RANGE; +STRUCT!{struct INET_PORT_RESERVATION_TOKEN { + Token: ULONG64, +}} +pub type PINET_PORT_RESERVATION_TOKEN = *mut INET_PORT_RESERVATION_TOKEN; +STRUCT!{struct INET_PORT_RESERVATION_INSTANCE { + Reservation: INET_PORT_RESERVATION, + Token: INET_PORT_RESERVATION_TOKEN, +}} +pub type PINET_PORT_RESERVATION_INSTANCE = *mut INET_PORT_RESERVATION_INSTANCE; +STRUCT!{struct INET_PORT_RESERVATION_INFORMATION { + OwningPid: ULONG, +}} +pub type PINET_PORT_RESERVATION_INFORMATION = *mut INET_PORT_RESERVATION_INFORMATION; +pub const SIO_SET_SECURITY: DWORD = _WSAIOW!(IOC_VENDOR, 200); +pub const SIO_QUERY_SECURITY: DWORD = _WSAIORW!(IOC_VENDOR, 201); +pub const SIO_SET_PEER_TARGET_NAME: DWORD = _WSAIOW!(IOC_VENDOR, 202); +pub const SIO_DELETE_PEER_TARGET_NAME: DWORD = _WSAIOW!(IOC_VENDOR, 203); +pub const SIO_QUERY_WFP_CONNECTION_REDIRECT_RECORDS: DWORD = _WSAIOW!(IOC_VENDOR, 220); +pub const SIO_QUERY_WFP_CONNECTION_REDIRECT_CONTEXT: DWORD = _WSAIOW!(IOC_VENDOR, 221); +pub const SIO_SET_WFP_CONNECTION_REDIRECT_RECORDS: DWORD = _WSAIOW!(IOC_VENDOR, 222); +pub const SIO_SOCKET_USAGE_NOTIFICATION: DWORD = _WSAIOW!(IOC_VENDOR, 204); +ENUM!{enum SOCKET_USAGE_TYPE { + SYSTEM_CRITICAL_SOCKET = 1, +}} +ENUM!{enum SOCKET_SECURITY_PROTOCOL { + SOCKET_SECURITY_PROTOCOL_DEFAULT, + SOCKET_SECURITY_PROTOCOL_IPSEC, + SOCKET_SECURITY_PROTOCOL_IPSEC2, + SOCKET_SECURITY_PROTOCOL_INVALID, +}} +STRUCT!{struct SOCKET_SECURITY_SETTINGS { + SecurityProtocol: SOCKET_SECURITY_PROTOCOL, + SecurityFlags: ULONG, +}} +pub const SOCKET_SETTINGS_IPSEC_SKIP_FILTER_INSTANTIATION: ULONG = 0x1; +pub const SOCKET_SETTINGS_IPSEC_OPTIONAL_PEER_NAME_VERIFICATION: ULONG = 0x2; +pub const SOCKET_SETTINGS_IPSEC_ALLOW_FIRST_INBOUND_PKT_UNENCRYPTED: ULONG = 0x4; +pub const SOCKET_SETTINGS_IPSEC_PEER_NAME_IS_RAW_FORMAT: ULONG = 0x8; +STRUCT!{struct SOCKET_SECURITY_SETTINGS_IPSEC { + SecurityProtocol: SOCKET_SECURITY_PROTOCOL, + SecurityFlags: ULONG, + IpsecFlags: ULONG, + AuthipMMPolicyKey: GUID, + AuthipQMPolicyKey: GUID, + Reserved: GUID, + Reserved2: UINT64, + UserNameStringLen: ULONG, + DomainNameStringLen: ULONG, + PasswordStringLen: ULONG, + AllStrings: [wchar_t; 0], +}} +STRUCT!{struct SOCKET_PEER_TARGET_NAME { + SecurityProtocol: SOCKET_SECURITY_PROTOCOL, + PeerAddress: SOCKADDR_STORAGE, + PeerTargetNameStringLen: ULONG, + AllStrings: [wchar_t; 0], +}} +STRUCT!{struct SOCKET_SECURITY_QUERY_TEMPLATE { + SecurityProtocol: SOCKET_SECURITY_PROTOCOL, + PeerAddress: SOCKADDR_STORAGE, + PeerTokenAccessMask: ULONG, +}} +pub const SOCKET_QUERY_IPSEC2_ABORT_CONNECTION_ON_FIELD_CHANGE: ULONG = 0x1; +pub const SOCKET_QUERY_IPSEC2_FIELD_MASK_MM_SA_ID: ULONG = 0x1; +pub const SOCKET_QUERY_IPSEC2_FIELD_MASK_QM_SA_ID: ULONG = 0x2; +STRUCT!{struct SOCKET_SECURITY_QUERY_TEMPLATE_IPSEC2 { + SecurityProtocol: SOCKET_SECURITY_PROTOCOL, + PeerAddress: SOCKADDR_STORAGE, + PeerTokenAccessMask: ULONG, + Flags: ULONG, + FieldMask: ULONG, +}} +pub const SOCKET_INFO_CONNECTION_SECURED: ULONG = 0x1; +pub const SOCKET_INFO_CONNECTION_ENCRYPTED: ULONG = 0x2; +pub const SOCKET_INFO_CONNECTION_IMPERSONATED: ULONG = 0x4; +STRUCT!{struct SOCKET_SECURITY_QUERY_INFO { + SecurityProtocol: SOCKET_SECURITY_PROTOCOL, + Flags: ULONG, + PeerApplicationAccessTokenHandle: UINT64, + PeerMachineAccessTokenHandle: UINT64, +}} +STRUCT!{struct SOCKET_SECURITY_QUERY_INFO_IPSEC2 { + SecurityProtocol: SOCKET_SECURITY_PROTOCOL, + Flags: ULONG, + PeerApplicationAccessTokenHandle: UINT64, + PeerMachineAccessTokenHandle: UINT64, + MmSaId: UINT64, + QmSaId: UINT64, + NegotiationWinerr: UINT32, + SaLookupContext: GUID, +}} +pub const SIO_QUERY_WFP_ALE_ENDPOINT_HANDLE: DWORD = _WSAIOR!(IOC_VENDOR, 205); +pub const SIO_QUERY_RSS_SCALABILITY_INFO: DWORD = _WSAIOR!(IOC_VENDOR, 210); +STRUCT!{struct RSS_SCALABILITY_INFO { + RssEnabled: BOOLEAN, +}} +pub type PRSS_SCALABILITY_INFO = *mut RSS_SCALABILITY_INFO; +#[inline] +pub fn IN4_CLASSA(i: LONG) -> bool { + (i & 0x80) == 0 +} +#[inline] +pub fn IN4_CLASSB(i: LONG) -> bool { + (i & 0xc0) == 0x80 +} +#[inline] +pub fn IN4_CLASSC(i: LONG) -> bool { + (i & 0xe0) == 0xc0 +} +#[inline] +pub fn IN4_CLASSD(i: LONG) -> bool { + (i & 0xf0) == 0xe0 +} +#[inline] +pub fn IN4_MULTICAST(i: LONG) -> bool { + IN4_CLASSD(i) +} +pub const IN4ADDR_ANY: ULONG = INADDR_ANY; +pub const IN4ADDR_LOOPBACK: ULONG = 0x0100007f; +pub const IN4ADDR_BROADCAST: ULONG = INADDR_BROADCAST; +pub const IN4ADDR_NONE: ULONG = INADDR_NONE; +pub const IN4ADDR_LOOPBACKPREFIX_LENGTH: usize = 8; +pub const IN4ADDR_LINKLOCALPREFIX_LENGTH: usize = 16; +pub const IN4ADDR_MULTICASTPREFIX_LENGTH: usize = 4; +#[inline] +pub fn IN4_ADDR_EQUAL(a: &IN_ADDR, b: &IN_ADDR) -> bool { + unsafe { *a.S_un.S_addr() == *b.S_un.S_addr() } +} +#[inline] +pub fn IN4_UNALIGNED_ADDR_EQUAL(a: &IN_ADDR, b: &IN_ADDR) -> bool { + unsafe { *a.S_un.S_addr() == *b.S_un.S_addr() } +} +#[inline] +pub fn IN4_IS_ADDR_UNSPECIFIED(a: &IN_ADDR) -> bool { + unsafe { *a.S_un.S_addr() == IN4ADDR_ANY } +} +#[inline] +pub fn IN4_IS_UNALIGNED_ADDR_UNSPECIFIED(a: &IN_ADDR) -> bool { + unsafe { *a.S_un.S_addr() == IN4ADDR_ANY } +} +#[inline] +pub fn IN4_IS_ADDR_LOOPBACK(a: &IN_ADDR) -> bool { + unsafe { a.S_un.S_un_b().s_b1 == 0x7f } +} +#[inline] +pub fn IN4_IS_UNALIGNED_ADDR_LOOPBACK(a: &IN_ADDR) -> bool { + unsafe { a.S_un.S_un_b().s_b1 == 0x7f } +} +#[inline] +pub fn IN4_IS_ADDR_BROADCAST(a: &IN_ADDR) -> bool { + unsafe { *a.S_un.S_addr() == IN4ADDR_BROADCAST } +} +#[inline] +pub fn IN4_IS_UNALIGNED_ADDR_BROADCAST(a: &IN_ADDR) -> bool { + unsafe { *a.S_un.S_addr() == IN4ADDR_BROADCAST } +} +#[inline] +pub fn IN4_IS_ADDR_MULTICAST(a: &IN_ADDR) -> bool { + IN4_MULTICAST(unsafe { *a.S_un.S_addr() as LONG }) +} +#[inline] +pub fn IN4_IS_UNALIGNED_ADDR_MULTICAST(a: &IN_ADDR) -> bool { + IN4_MULTICAST(unsafe { *a.S_un.S_addr() as LONG }) +} +#[inline] +pub fn IN4_IS_ADDR_LINKLOCAL(a: &IN_ADDR) -> bool { + unsafe { (*a.S_un.S_addr() & 0xffff) == 0xfea9 } +} +#[inline] +pub fn IN4_IS_UNALIGNED_ADDR_LINKLOCAL(a: &IN_ADDR) -> bool { + unsafe { (*a.S_un.S_addr() & 0xffff) == 0xfea9 } +} +#[inline] +pub fn IN4_IS_ADDR_SITELOCAL(_: &IN_ADDR) -> bool { + false +} +#[inline] +pub fn IN4_IS_UNALIGNED_ADDR_SITELOCAL(_: &IN_ADDR) -> bool { + false +} +#[inline] +pub fn IN4_IS_ADDR_RFC1918(a: &IN_ADDR) -> bool { + let s_addr = unsafe { *a.S_un.S_addr() }; + ((s_addr & 0x00ff) == 0x0a) || ((s_addr & 0xf0ff) == 0x10ac) || ((s_addr & 0xffff) == 0xa8c0) +} +#[inline] +pub fn IN4_IS_UNALIGNED_ADDR_RFC1918(a: &IN_ADDR) -> bool { + IN4_IS_ADDR_RFC1918(a) +} +#[inline] +pub fn IN4_IS_ADDR_MC_LINKLOCAL(a: &IN_ADDR) -> bool { + unsafe { (*a.S_un.S_addr() & 0xffffff) == 0xe0 } +} +#[inline] +pub fn IN4_IS_ADDR_MC_ADMINLOCAL(a: &IN_ADDR) -> bool { + unsafe { (*a.S_un.S_addr() & 0xffff) == 0xffef } +} +#[inline] +pub fn IN4_IS_ADDR_MC_SITELOCAL(a: &IN_ADDR) -> bool { + let first = unsafe { (*a.S_un.S_addr() & 0xff) == 0xef }; + first && !IN4_IS_ADDR_MC_ADMINLOCAL(a) +} +#[inline] +pub fn IN4ADDR_ISANY(a: &SOCKADDR_IN) -> bool { + IN4_IS_ADDR_UNSPECIFIED(&a.sin_addr) +} +#[inline] +pub fn IN4ADDR_ISLOOPBACK(a: &SOCKADDR_IN) -> bool { + IN4_IS_ADDR_LOOPBACK(&a.sin_addr) +} +extern "system" { + pub fn RtlIpv4AddressToStringA( + Addr: *const IN_ADDR, + S: PSTR, + ) -> PSTR; + pub fn RtlIpv4AddressToStringExA( + Address: *const IN_ADDR, + Port: USHORT, + AddressString: PSTR, + AddressStringLength: PULONG, + ) -> LONG; + pub fn RtlIpv4AddressToStringW( + Addr: *const IN_ADDR, + S: PWSTR, + ) -> PWSTR; + pub fn RtlIpv4AddressToStringExW( + Address: *const IN_ADDR, + Port: USHORT, + AddressString: PWSTR, + AddressStringLength: PULONG, + ) -> LONG; + pub fn RtlIpv4StringToAddressA( + S: PCSTR, + Strict: BOOLEAN, + Terminator: *mut PCSTR, + Addr: *mut IN_ADDR, + ) -> LONG; + pub fn RtlIpv4StringToAddressExA( + AddressString: PCSTR, + Strict: BOOLEAN, + Address: *mut IN_ADDR, + Port: PUSHORT, + ) -> LONG; + pub fn RtlIpv4StringToAddressW( + S: PCWSTR, + Strict: BOOLEAN, + Terminator: *mut LPCWSTR, + Addr: *mut IN_ADDR, + ) -> LONG; + pub fn RtlIpv4StringToAddressExW( + AddressString: PCWSTR, + Strict: BOOLEAN, + Address: *mut IN_ADDR, + Port: PUSHORT, + ) -> LONG; + pub fn RtlIpv6AddressToStringA( + Addr: *const IN6_ADDR, + S: PSTR, + ) -> PSTR; + pub fn RtlIpv6AddressToStringExA( + Address: *const IN6_ADDR, + ScopeId: ULONG, + Port: USHORT, + AddressString: PSTR, + AddressStringLength: PULONG, + ) -> LONG; + pub fn RtlIpv6AddressToStringW( + Addr: *const IN6_ADDR, + S: PWSTR, + ) -> PWSTR; + pub fn RtlIpv6AddressToStringExW( + Address: *const IN6_ADDR, + ScopeId: ULONG, + Port: USHORT, + AddressString: PWSTR, + AddressStringLength: PULONG, + ) -> LONG; + pub fn RtlIpv6StringToAddressA( + S: PCSTR, + Terminator: *mut PCSTR, + Addr: *mut IN6_ADDR, + ) -> LONG; + pub fn RtlIpv6StringToAddressExA( + AddressString: PCSTR, + Address: *mut IN6_ADDR, + ScopeId: PULONG, + Port: PUSHORT, + ) -> LONG; + pub fn RtlIpv6StringToAddressW( + S: PCWSTR, + Terminator: *mut PCWSTR, + Addr: *mut IN6_ADDR, + ) -> LONG; + pub fn RtlIpv6StringToAddressExW( + AddressString: PCWSTR, + Address: *mut IN6_ADDR, + ScopeId: PULONG, + Port: PUSHORT, + ) -> LONG; +} +DECLARE_HANDLE!{DL_EUI48, _DL_EUI48} +pub type PDL_EUI48 = *mut DL_EUI48; +extern "system" { + pub fn RtlEthernetAddressToStringA( + Addr: *const DL_EUI48, + S: PSTR, + ) -> PSTR; + pub fn RtlEthernetAddressToStringW( + Addr: *const DL_EUI48, + S: PWSTR, + ) -> PWSTR; + pub fn RtlEthernetStringToAddressA( + S: PCSTR, + Terminator: *mut PCSTR, + Addr: *mut DL_EUI48, + ) -> LONG; + pub fn RtlEthernetStringToAddressW( + S: PCWSTR, + Terminator: *mut LPCWSTR, + Addr: *mut DL_EUI48, + ) -> LONG; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/mswsockdef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/mswsockdef.rs new file mode 100644 index 0000000..b62cf29 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/mswsockdef.rs @@ -0,0 +1,48 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{DWORD, ULONG}; +use shared::ws2def::IOC_VENDOR; +use um::winnt::{LONG, PVOID, ULONGLONG}; +pub const SIO_SET_COMPATIBILITY_MODE: DWORD = _WSAIOW!(IOC_VENDOR, 300); +ENUM!{enum WSA_COMPATIBILITY_BEHAVIOR_ID { + WsaBehaviorAll = 0, + WsaBehaviorReceiveBuffering, + WsaBehaviorAutoTuning, +}} +pub type PWSA_COMPATIBILITY_BEHAVIOR_ID = *mut WSA_COMPATIBILITY_BEHAVIOR_ID; +STRUCT!{struct WSA_COMPATIBILITY_MODE { + BehaviorId: WSA_COMPATIBILITY_BEHAVIOR_ID, + TargetOsVersion: ULONG, +}} +pub type PWSA_COMPATIBILITY_MODE = *mut WSA_COMPATIBILITY_MODE; +pub type RIO_BUFFERID = PVOID; +pub type PRIO_BUFFERID = *mut PVOID; +pub type RIO_CQ = PVOID; +pub type PRIO_CQ = *mut PVOID; +pub type RIO_RQ = PVOID; +pub type PRIO_RQ = *mut PVOID; +STRUCT!{struct RIORESULT { + Status: LONG, + BytesTransferred: ULONG, + SocketContext: ULONGLONG, + RequestContext: ULONGLONG, +}} +pub type PRIORESULT = *mut RIORESULT; +STRUCT!{struct RIO_BUF { + BufferId: RIO_BUFFERID, + Offset: ULONG, + Length: ULONG, +}} +pub type PRIO_BUF = *mut RIO_BUF; +pub const RIO_MSG_DONT_NOTIFY: DWORD = 0x00000001; +pub const RIO_MSG_DEFER: DWORD = 0x00000002; +pub const RIO_MSG_WAITALL: DWORD = 0x00000004; +pub const RIO_MSG_COMMIT_ONLY: DWORD = 0x00000008; +pub const RIO_INVALID_BUFFERID: RIO_BUFFERID = 0xFFFFFFFF as RIO_BUFFERID; +pub const RIO_INVALID_CQ: RIO_CQ = 0 as RIO_CQ; +pub const RIO_INVALID_RQ: RIO_RQ = 0 as RIO_RQ; +pub const RIO_MAX_CQ_SIZE: DWORD = 0x8000000; +pub const RIO_CORRUPT_CQ: ULONG = 0xFFFFFFFF; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/netioapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/netioapi.rs new file mode 100644 index 0000000..e8788e5 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/netioapi.rs @@ -0,0 +1,57 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::SIZE_T; +use shared::guiddef::GUID; +use shared::ifdef::{NET_IFINDEX, NET_LUID, PNET_IFINDEX, PNET_LUID}; +use shared::minwindef::DWORD; +use shared::ntdef::{CHAR, PSTR, PWSTR, WCHAR}; +pub type NETIO_STATUS = DWORD; +pub type NETIOAPI_API = NETIO_STATUS; +extern "system" { + pub fn ConvertInterfaceNameToLuidA( + InterfaceName: *const CHAR, + InterfaceLuid: *mut NET_LUID, + ) -> NETIOAPI_API; + pub fn ConvertInterfaceNameToLuidW( + InterfaceName: *const WCHAR, + InterfaceLuid: *mut NET_LUID, + ) -> NETIOAPI_API; + pub fn ConvertInterfaceLuidToNameA( + InterfaceLuid: *const NET_LUID, + InterfaceName: PSTR, + Length: SIZE_T, + ) -> NETIOAPI_API; + pub fn ConvertInterfaceLuidToNameW( + InterfaceLuid: *const NET_LUID, + InterfaceName: PWSTR, + Length: SIZE_T, + ) -> NETIOAPI_API; + pub fn ConvertInterfaceLuidToIndex( + InterfaceLuid: *const NET_LUID, + InterfaceIndex: PNET_IFINDEX, + ) -> NETIOAPI_API; + pub fn ConvertInterfaceIndexToLuid( + InterfaceIndex: NET_IFINDEX, + InterfaceLuid: PNET_LUID, + ) -> NETIOAPI_API; + pub fn ConvertInterfaceLuidToAlias( + InterfaceLuid: *const NET_LUID, + InterfaceAlias: PWSTR, + Length: SIZE_T, + ) -> NETIOAPI_API; + pub fn ConvertInterfaceAliasToLuid( + InterfaceAlias: *const WCHAR, + InterfaceLuid: PNET_LUID, + ) -> NETIOAPI_API; + pub fn ConvertInterfaceLuidToGuid( + InterfaceLuid: *const NET_LUID, + InterfaceGuid: *mut GUID, + ) -> NETIOAPI_API; + pub fn ConvertInterfaceGuidToLuid( + InterfaceGuid: *const GUID, + InterfaceLuid: PNET_LUID, + ) -> NETIOAPI_API; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntddscsi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntddscsi.rs new file mode 100644 index 0000000..ac47ec4 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntddscsi.rs @@ -0,0 +1,834 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Constants and types for accessing SCSI port adapters. +use shared::basetsd::{ULONG32, ULONG_PTR}; +use shared::minwindef::{UCHAR, ULONG, USHORT}; +use shared::ntdef::{LARGE_INTEGER, LONG, LONGLONG, PVOID, ULONGLONG, VOID, WCHAR}; +use um::winioctl::{ + DEVICE_TYPE, FILE_ANY_ACCESS, FILE_DEVICE_CONTROLLER, FILE_READ_ACCESS, + FILE_WRITE_ACCESS, METHOD_BUFFERED +}; +use um::winnt::{ANYSIZE_ARRAY, BOOLEAN, PBOOLEAN}; +DEFINE_GUID!{ScsiRawInterfaceGuid, + 0x53f56309, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{WmiScsiAddressGuid, + 0x53f5630f, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +pub const IOCTL_SCSI_BASE: DEVICE_TYPE = FILE_DEVICE_CONTROLLER; +pub const FILE_DEVICE_SCSI: ULONG = 0x0000001; +pub const DD_SCSI_DEVICE_NAME: &'static str = "\\Device\\ScsiPort"; +pub const IOCTL_SCSI_PASS_THROUGH: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_SCSI_MINIPORT: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_SCSI_GET_INQUIRY_DATA: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0403, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SCSI_GET_CAPABILITIES: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SCSI_PASS_THROUGH_DIRECT: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_SCSI_GET_ADDRESS: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SCSI_RESCAN_BUS: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0407, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SCSI_GET_DUMP_POINTERS: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0408, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SCSI_FREE_DUMP_POINTERS: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0409, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_IDE_PASS_THROUGH: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x040a, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_ATA_PASS_THROUGH: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x040b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_ATA_PASS_THROUGH_DIRECT: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x040c, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_ATA_MINIPORT: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x040d, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_MINIPORT_PROCESS_SERVICE_IRP: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x040e, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_MPIO_PASS_THROUGH_PATH: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x040f, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_MPIO_PASS_THROUGH_PATH_DIRECT: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0410, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_SCSI_PASS_THROUGH_EX: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0411, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_SCSI_PASS_THROUGH_DIRECT_EX: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0412, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_MPIO_PASS_THROUGH_PATH_EX: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0413, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_MPIO_PASS_THROUGH_PATH_DIRECT_EX: ULONG = + CTL_CODE!(IOCTL_SCSI_BASE, 0x0414, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_SCSI_MINIPORT_NVCACHE: ULONG = ((FILE_DEVICE_SCSI << 16) + 0x0600); +pub const IOCTL_SCSI_MINIPORT_HYBRID: ULONG = ((FILE_DEVICE_SCSI << 16) + 0x0620); +pub const IOCTL_SCSI_MINIPORT_FIRMWARE: ULONG = ((FILE_DEVICE_SCSI << 16) + 0x0780); +STRUCT!{struct SCSI_PASS_THROUGH { + Length: USHORT, + ScsiStatus: UCHAR, + PathId: UCHAR, + TargetId: UCHAR, + Lun: UCHAR, + CdbLength: UCHAR, + SenseInfoLength: UCHAR, + DataIn: UCHAR, + DataTransferLength: ULONG, + TimeOutValue: ULONG, + DataBufferOffset: ULONG_PTR, + SenseInfoOffset: ULONG, + Cdb: [UCHAR; 16], +}} +pub type PSCSI_PASS_THROUGH = *mut SCSI_PASS_THROUGH; +STRUCT!{struct SCSI_PASS_THROUGH_DIRECT { + Length: USHORT, + ScsiStatus: UCHAR, + PathId: UCHAR, + TargetId: UCHAR, + Lun: UCHAR, + CdbLength: UCHAR, + SenseInfoLength: UCHAR, + DataIn: UCHAR, + DataTransferLength: ULONG, + TimeOutValue: ULONG, + DataBuffer: PVOID, + SenseInfoOffset: ULONG, + Cdb: [UCHAR; 16], +}} +pub type PSCSI_PASS_THROUGH_DIRECT = *mut SCSI_PASS_THROUGH_DIRECT; +STRUCT!{struct SCSI_PASS_THROUGH32 { + Length: USHORT, + ScsiStatus: UCHAR, + PathId: UCHAR, + TargetId: UCHAR, + Lun: UCHAR, + CdbLength: UCHAR, + SenseInfoLength: UCHAR, + DataIn: UCHAR, + DataTransferLength: ULONG, + TimeOutValue: ULONG, + DataBufferOffset: ULONG32, + SenseInfoOffset: ULONG, + Cdb: [UCHAR; 16], +}} +#[cfg(target_arch = "x86_64")] +IFDEF!{ +pub type PSCSI_PASS_THROUGH32 = *mut SCSI_PASS_THROUGH32; +STRUCT!{struct SCSI_PASS_THROUGH_DIRECT32 { + Length: USHORT, + ScsiStatus: UCHAR, + PathId: UCHAR, + TargetId: UCHAR, + Lun: UCHAR, + CdbLength: UCHAR, + SenseInfoLength: UCHAR, + DataIn: UCHAR, + DataTransferLength: ULONG, + TimeOutValue: ULONG, + DataBuffer: ULONG32, // Rust doesn't have anything like __ptr32 + SenseInfoOffset: ULONG, + Cdb: [UCHAR; 16], +}} +pub type PSCSI_PASS_THROUGH_DIRECT32 = *mut SCSI_PASS_THROUGH_DIRECT32; +} +STRUCT!{struct SCSI_PASS_THROUGH_EX { + Version: ULONG, + Length: ULONG, + CdbLength: ULONG, + StorAddressLength: ULONG, + ScsiStatus: UCHAR, + SenseInfolength: UCHAR, + DataDirection: UCHAR, + Reserved: UCHAR, + TimeOutValue: ULONG, + StorAddressOffset: ULONG, + SenseInfoOffset: ULONG, + DataOutTransferLength: ULONG, + DataInTransferLength: ULONG, + DataOutBufferOffset: ULONG_PTR, + DataInBufferOffset: ULONG_PTR, + Cdb: [UCHAR; ANYSIZE_ARRAY], +}} +pub type PSCSI_PASS_THROUGH_EX = *mut SCSI_PASS_THROUGH_EX; +STRUCT!{struct SCSI_PASS_THROUGH_DIRECT_EX { + Version: ULONG, + Length: ULONG, + CdbLength: ULONG, + StorAddressLength: ULONG, + ScsiStatus: UCHAR, + SenseInfolength: UCHAR, + DataDirection: UCHAR, + Reserved: UCHAR, + TimeOutValue: ULONG, + StorAddressOffset: ULONG, + SenseInfoOffset: ULONG, + DataOutTransferLength: ULONG, + DataInTransferLength: ULONG, + DataOutBuffer: *mut VOID, + DataInBuffer: *mut VOID, + Cdb: [UCHAR; ANYSIZE_ARRAY], +}} +pub type PSCSI_PASS_THROUGH_DIRECT_EX = *mut SCSI_PASS_THROUGH_DIRECT_EX; +#[cfg(target_arch = "x86_64")] +IFDEF!{ +STRUCT!{struct SCSI_PASS_THROUGH32_EX { + Version: ULONG, + Length: ULONG, + CdbLength: ULONG, + StorAddressLength: ULONG, + ScsiStatus: UCHAR, + SenseInfolength: UCHAR, + DataDirection: UCHAR, + Reserved: UCHAR, + TimeOutValue: ULONG, + StorAddressOffset: ULONG, + SenseInfoOffset: ULONG, + DataOutTransferLength: ULONG, + DataInTransferLength: ULONG, + DataOutBufferOffset: ULONG32, + DataInBufferOffset: ULONG32, + Cdb: [UCHAR; ANYSIZE_ARRAY], +}} +pub type PSCSI_PASS_THROUGH32_EX = *mut SCSI_PASS_THROUGH32_EX; +STRUCT!{struct SCSI_PASS_THROUGH_DIRECT32_EX { + Version: ULONG, + Length: ULONG, + CdbLength: ULONG, + StorAddressLength: ULONG, + ScsiStatus: UCHAR, + SenseInfolength: UCHAR, + DataDirection: UCHAR, + Reserved: UCHAR, + TimeOutValue: ULONG, + StorAddressOffset: ULONG, + SenseInfoOffset: ULONG, + DataOutTransferLength: ULONG, + DataInTransferLength: ULONG, + DataOutBuffer: ULONG32, + DataInBuffer: ULONG32, + Cdb: [UCHAR; ANYSIZE_ARRAY], +}} +pub type PSCSI_PASS_THROUGH_DIRECT32_EX = *mut SCSI_PASS_THROUGH_DIRECT32_EX; +} +STRUCT!{struct ATA_PASS_THROUGH_EX { + Length: USHORT, + AtaFlags: USHORT, + PathId: UCHAR, + TargetId: UCHAR, + Lun: UCHAR, + ReservedAsUchar: UCHAR, + DataTransferLength: ULONG, + TimeOutValue: ULONG, + ReservedAsUlong: ULONG, + DataBufferOffset: ULONG_PTR, + PreviousTaskFile: [UCHAR; 8], + CurrentTaskFile: [UCHAR; 8], +}} +pub type PATA_PASS_THROUGH_EX = *mut ATA_PASS_THROUGH_EX; +STRUCT!{struct ATA_PASS_THROUGH_DIRECT { + Length: USHORT, + AtaFlags: USHORT, + PathId: UCHAR, + TargetId: UCHAR, + Lun: UCHAR, + ReservedAsUchar: UCHAR, + DataTransferLength: ULONG, + TimeOutValue: ULONG, + ReservedAsUlong: ULONG, + DataBuffer: PVOID, + PreviousTaskFile: [UCHAR; 8], + CurrentTaskFile: [UCHAR; 8], +}} +pub type PATA_PASS_THROUGH_DIRECT = *mut ATA_PASS_THROUGH_DIRECT; +#[cfg(target_arch = "x86_64")] +IFDEF!{ +STRUCT!{struct ATA_PASS_THROUGH_EX32 { + Length: USHORT, + AtaFlags: USHORT, + PathId: UCHAR, + TargetId: UCHAR, + Lun: UCHAR, + ReservedAsUchar: UCHAR, + DataTransferLength: ULONG, + TimeOutValue: ULONG, + ReservedAsUlong: ULONG, + DataBufferOffset: ULONG32, + PreviousTaskFile: [UCHAR; 8], + CurrentTaskFile: [UCHAR; 8], +}} +pub type PATA_PASS_THROUGH_EX32 = *mut ATA_PASS_THROUGH_EX32; +STRUCT!{struct ATA_PASS_THROUGH_DIRECT32 { + Length: USHORT, + AtaFlags: USHORT, + PathId: UCHAR, + TargetId: UCHAR, + Lun: UCHAR, + ReservedAsUchar: UCHAR, + DataTransferLength: ULONG, + TimeOutValue: ULONG, + ReservedAsUlong: ULONG, + DataBuffer: ULONG32, + PreviousTaskFile: [UCHAR; 8], + CurrentTaskFile: [UCHAR; 8], +}} +pub type PATA_PASS_THROUGH_DIRECT32 = *mut ATA_PASS_THROUGH_DIRECT32; +} +pub const ATA_FLAGS_DRDY_REQUIRED: USHORT = 1 << 0; +pub const ATA_FLAGS_DATA_IN: USHORT = 1 << 1; +pub const ATA_FLAGS_DATA_OUT: USHORT = 1 << 2; +pub const ATA_FLAGS_48BIT_COMMAND: USHORT = 1 << 3; +pub const ATA_FLAGS_USE_DMA: USHORT = 1 << 4; +pub const ATA_FLAGS_NO_MULTIPLE: USHORT = 1 << 5; +STRUCT!{struct IDE_IO_CONTROL { + HeaderLength: ULONG, + Signature: [UCHAR; 8], + Timeout: ULONG, + ControlCode: ULONG, + ReturnStatus: ULONG, + DataLength: ULONG, +}} +pub type PIDE_IO_CONTROL = *mut IDE_IO_CONTROL; +STRUCT!{struct MPIO_PASS_THROUGH_PATH { + PassThrough: SCSI_PASS_THROUGH, + Version: ULONG, + Length: USHORT, + Flags: UCHAR, + PortNumber: UCHAR, + MpioPathId: ULONGLONG, +}} +pub type PMPIO_PASS_THROUGH_PATH = *mut MPIO_PASS_THROUGH_PATH; +STRUCT!{struct MPIO_PASS_THROUGH_PATH_DIRECT { + PassThrough: SCSI_PASS_THROUGH_DIRECT, + Version: ULONG, + Length: USHORT, + Flags: UCHAR, + PortNumber: UCHAR, + MpioPathId: ULONGLONG, +}} +pub type PMPIO_PASS_THROUGH_PATH_DIRECT = *mut MPIO_PASS_THROUGH_PATH_DIRECT; +STRUCT!{struct MPIO_PASS_THROUGH_PATH_EX { + PassThroughOffset: ULONG, + Version: ULONG, + Length: USHORT, + Flags: UCHAR, + PortNumber: UCHAR, + MpioPathId: ULONGLONG, +}} +pub type PMPIO_PASS_THROUGH_PATH_EX = *mut MPIO_PASS_THROUGH_PATH_EX; +STRUCT!{struct MPIO_PASS_THROUGH_PATH_DIRECT_EX { + PassThroughOffset: ULONG, + Version: ULONG, + Length: USHORT, + Flags: UCHAR, + PortNumber: UCHAR, + MpioPathId: ULONGLONG, +}} +pub type PMPIO_PASS_THROUGH_PATH_DIRECT_EX = *mut MPIO_PASS_THROUGH_PATH_DIRECT_EX; +#[cfg(target_arch = "x86_64")] +IFDEF!{ +STRUCT!{struct MPIO_PASS_THROUGH_PATH32 { + PassThrough: SCSI_PASS_THROUGH32, + Version: ULONG, + Length: USHORT, + Flags: UCHAR, + PortNumber: UCHAR, + MpioPathId: ULONGLONG, +}} +pub type PMPIO_PASS_THROUGH_PATH32 = *mut MPIO_PASS_THROUGH_PATH32; +STRUCT!{struct MPIO_PASS_THROUGH_PATH_DIRECT32 { + PassThrough: SCSI_PASS_THROUGH_DIRECT32, + Version: ULONG, + Length: USHORT, + Flags: UCHAR, + PortNumber: UCHAR, + MpioPathId: ULONGLONG, +}} +pub type PMPIO_PASS_THROUGH_PATH_DIRECT32 = *mut MPIO_PASS_THROUGH_PATH_DIRECT32; +STRUCT!{struct MPIO_PASS_THROUGH_PATH32_EX { + PassThroughOffset: ULONG, + Version: ULONG, + Length: USHORT, + Flags: UCHAR, + PortNumber: UCHAR, + MpioPathId: ULONGLONG, +}} +pub type PMPIO_PASS_THROUGH_PATH32_EX = *mut MPIO_PASS_THROUGH_PATH32_EX; +STRUCT!{struct MPIO_PASS_THROUGH_PATH_DIRECT32_EX { + PassThroughOffset: ULONG, + Version: ULONG, + Length: USHORT, + Flags: UCHAR, + PortNumber: UCHAR, + MpioPathId: ULONGLONG, +}} +pub type PMPIO_PASS_THROUGH_PATH_DIRECT32_EX = *mut MPIO_PASS_THROUGH_PATH_DIRECT32_EX; +} +STRUCT!{struct SCSI_BUS_DATA { + NumberOfLogicalUnits: UCHAR, + InitiatorBusId: UCHAR, + InquiryDataOffset: ULONG, +}} +pub type PSCSI_BUS_DATA = *mut SCSI_BUS_DATA; +STRUCT!{struct SCSI_ADAPTER_BUS_INFO { + NumberOfBuses: UCHAR, + BusData: [SCSI_BUS_DATA; 1], +}} +pub type PSCSI_ADAPTER_BUS_INFO = *mut SCSI_ADAPTER_BUS_INFO; +STRUCT!{struct SCSI_INQUIRY_DATA { + PathId: UCHAR, + TargetId: UCHAR, + Lun: UCHAR, + DeviceClaimed: BOOLEAN, + InquiryDataLength: ULONG, + NextInquiryDataOffset: ULONG, + InquiryData: [UCHAR; 1], +}} +pub type PSCSI_INQUIRY_DATA = *mut SCSI_INQUIRY_DATA; +pub const IOCTL_MINIPORT_SIGNATURE_SCSIDISK: &'static str = "SCSIDISK"; +pub const IOCTL_MINIPORT_SIGNATURE_HYBRDISK: &'static str = "HYBRDISK"; +pub const IOCTL_MINIPORT_SIGNATURE_DSM_NOTIFICATION: &'static str = "MPDSM "; +pub const IOCTL_MINIPORT_SIGNATURE_DSM_GENERAL: &'static str = "MPDSMGEN"; +pub const IOCTL_MINIPORT_SIGNATURE_FIRMWARE: &'static str = "FIRMWARE"; +pub const IOCTL_MINIPORT_SIGNATURE_QUERY_PROTOCOL: &'static str = "PROTOCOL"; +pub const IOCTL_MINIPORT_SIGNATURE_QUERY_TEMPERATURE: &'static str = "TEMPERAT"; +pub const IOCTL_MINIPORT_SIGNATURE_SET_TEMPERATURE_THRESHOLD: &'static str = "SETTEMPT"; +pub const IOCTL_MINIPORT_SIGNATURE_QUERY_PHYSICAL_TOPOLOGY: &'static str = "TOPOLOGY"; +STRUCT!{struct SRB_IO_CONTROL { + HeaderLength: ULONG, + Signature: [UCHAR; 8], + Timeout: ULONG, + ControlCode: ULONG, + ReturnCode: ULONG, + Length: ULONG, +}} +pub type PSRB_IO_CONTROL = *mut SRB_IO_CONTROL; +STRUCT!{struct NVCACHE_REQUEST_BLOCK { + NRBSize: ULONG, + Function: USHORT, + NRBFlags: ULONG, + NRBStatus: ULONG, + Count: ULONG, + LBA: ULONGLONG, + DataBufSize: ULONG, + NVCacheStatus: ULONG, + NVCacheSubStatus: ULONG, +}} +pub type PNVCACHE_REQUEST_BLOCK = *mut NVCACHE_REQUEST_BLOCK; +pub const NRB_FUNCTION_NVCACHE_INFO: USHORT = 0xEC; +pub const NRB_FUNCTION_SPINDLE_STATUS: USHORT = 0xE5; +pub const NRB_FUNCTION_NVCACHE_POWER_MODE_SET: USHORT = 0x00; +pub const NRB_FUNCTION_NVCACHE_POWER_MODE_RETURN: USHORT = 0x01; +pub const NRB_FUNCTION_FLUSH_NVCACHE: USHORT = 0x14; +pub const NRB_FUNCTION_QUERY_PINNED_SET: USHORT = 0x12; +pub const NRB_FUNCTION_QUERY_CACHE_MISS: USHORT = 0x13; +pub const NRB_FUNCTION_ADD_LBAS_PINNED_SET: USHORT = 0x10; +pub const NRB_FUNCTION_REMOVE_LBAS_PINNED_SET: USHORT = 0x11; +pub const NRB_FUNCTION_QUERY_ASCENDER_STATUS: USHORT = 0xD0; +pub const NRB_FUNCTION_QUERY_HYBRID_DISK_STATUS: USHORT = 0xD1; +pub const NRB_FUNCTION_PASS_HINT_PAYLOAD: USHORT = 0xE0; +pub const NRB_FUNCTION_NVSEPARATED_INFO: USHORT = 0xc0; +pub const NRB_FUNCTION_NVSEPARATED_FLUSH: USHORT = 0xc1; +pub const NRB_FUNCTION_NVSEPARATED_WB_DISABLE: USHORT = 0xc2; +pub const NRB_FUNCTION_NVSEPARATED_WB_REVERT_DEFAULT: USHORT = 0xc3; +pub const NRB_SUCCESS: ULONG = 0; +pub const NRB_ILLEGAL_REQUEST: ULONG = 1; +pub const NRB_INVALID_PARAMETER: ULONG = 2; +pub const NRB_INPUT_DATA_OVERRUN: ULONG = 3; +pub const NRB_INPUT_DATA_UNDERRUN: ULONG = 4; +pub const NRB_OUTPUT_DATA_OVERRUN: ULONG = 5; +pub const NRB_OUTPUT_DATA_UNDERRUN: ULONG = 6; +STRUCT!{struct NV_FEATURE_PARAMETER { + NVPowerModeEnabled: USHORT, + NVParameterReserv1: USHORT, + NVCmdEnabled: USHORT, + NVParameterReserv2: USHORT, + NVPowerModeVer: USHORT, + NVCmdVer: USHORT, + NVSize: ULONG, + NVReadSpeed: USHORT, + NVWrtSpeed: USHORT, + DeviceSpinUpTime: ULONG, +}} +pub type PNV_FEATURE_PARAMETER = *mut NV_FEATURE_PARAMETER; +STRUCT!{struct NVCACHE_HINT_PAYLOAD { + Command: UCHAR, + Feature7_0: UCHAR, + Feature15_8: UCHAR, + Count15_8: UCHAR, + LBA7_0: UCHAR, + LBA15_8: UCHAR, + LBA23_16: UCHAR, + LBA31_24: UCHAR, + LBA39_32: UCHAR, + LBA47_40: UCHAR, + Auxiliary7_0: UCHAR, + Auxiliary23_16: UCHAR, + Reserved: [UCHAR; 4], +}} +pub type PNVCACHE_HINT_PAYLOAD = *mut NVCACHE_HINT_PAYLOAD; +STRUCT!{struct NV_SEP_CACHE_PARAMETER { + Version: ULONG, + Size: ULONG, + Flags: NV_SEP_CACHE_PARAMETER_Flags, + WriteCacheType: UCHAR, + WriteCacheTypeEffective: UCHAR, + ParameterReserve1: [UCHAR; 3], +}} +pub type PNV_SEP_CACHE_PARAMETER = *mut NV_SEP_CACHE_PARAMETER; +UNION!{union NV_SEP_CACHE_PARAMETER_Flags { + [u8; 1], + CacheFlags CacheFlags_mut: NV_SEP_CACHE_PARAMETER_Flags_CacheFlags, + CacheFlagsSet CacheFlagsSet_mut: UCHAR, +}} +STRUCT!{struct NV_SEP_CACHE_PARAMETER_Flags_CacheFlags { + Bitfield: UCHAR, +}} +BITFIELD!{NV_SEP_CACHE_PARAMETER_Flags_CacheFlags Bitfield: UCHAR [ + WriteCacheEnabled set_WriteCacheEnabled[0..1], + WriteCacheChangeable set_WriteCacheChangeable[1..2], + WriteThroughIOSupported set_WriteThroughIOSupported[2..3], + FlushCacheSupported set_FlushCacheSupported[3..4], + ReservedBits set_ReservedBits[4..8], +]} +pub const NV_SEP_CACHE_PARAMETER_VERSION_1: ULONG = 1; +pub const NV_SEP_CACHE_PARAMETER_VERSION: ULONG = NV_SEP_CACHE_PARAMETER_VERSION_1; +ENUM!{enum NV_SEP_WRITE_CACHE_TYPE { + NVSEPWriteCacheTypeUnknown = 0, + NVSEPWriteCacheTypeNone = 1, + NVSEPWriteCacheTypeWriteBack = 2, + NVSEPWriteCacheTypeWriteThrough = 3, +}} +pub type PNV_SEP_WRITE_CACHE_TYPE = *mut NV_SEP_WRITE_CACHE_TYPE; +STRUCT!{struct MP_DEVICE_DATA_SET_RANGE { + StartingOffset: LONGLONG, + LengthInBytes: ULONGLONG, +}} +pub type PMP_DEVICE_DATA_SET_RANGE = *mut MP_DEVICE_DATA_SET_RANGE; +STRUCT!{struct DSM_NOTIFICATION_REQUEST_BLOCK { + Size: ULONG, + Version: ULONG, + NotifyFlags: ULONG, + DataSetProfile: ULONG, + Reserved: [ULONG; 3], + DataSetRangesCount: ULONG, + DataSetRanges: [MP_DEVICE_DATA_SET_RANGE; ANYSIZE_ARRAY], +}} +pub type PDSM_NOTIFICATION_REQUEST_BLOCK = *mut DSM_NOTIFICATION_REQUEST_BLOCK; +pub const MINIPORT_DSM_NOTIFICATION_VERSION_1: ULONG = 1; +pub const MINIPORT_DSM_NOTIFICATION_VERSION: ULONG = MINIPORT_DSM_NOTIFICATION_VERSION_1; +pub const MINIPORT_DSM_PROFILE_UNKNOWN: ULONG = 0; +pub const MINIPORT_DSM_PROFILE_PAGE_FILE: ULONG = 1; +pub const MINIPORT_DSM_PROFILE_HIBERNATION_FILE: ULONG = 2; +pub const MINIPORT_DSM_PROFILE_CRASHDUMP_FILE: ULONG = 3; +pub const MINIPORT_DSM_NOTIFY_FLAG_BEGIN: ULONG = 0x00000001; +pub const MINIPORT_DSM_NOTIFY_FLAG_END: ULONG = 0x00000002; +pub const HYBRID_FUNCTION_GET_INFO: ULONG = 0x01; +pub const HYBRID_FUNCTION_DISABLE_CACHING_MEDIUM: ULONG = 0x10; +pub const HYBRID_FUNCTION_ENABLE_CACHING_MEDIUM: ULONG = 0x11; +pub const HYBRID_FUNCTION_SET_DIRTY_THRESHOLD: ULONG = 0x12; +pub const HYBRID_FUNCTION_DEMOTE_BY_SIZE: ULONG = 0x13; +pub const HYBRID_STATUS_SUCCESS: ULONG = 0x0; +pub const HYBRID_STATUS_ILLEGAL_REQUEST: ULONG = 0x1; +pub const HYBRID_STATUS_INVALID_PARAMETER: ULONG = 0x2; +pub const HYBRID_STATUS_OUTPUT_BUFFER_TOO_SMALL: ULONG = 0x3; +pub const HYBRID_STATUS_ENABLE_REFCOUNT_HOLD: ULONG = 0x10; +pub const HYBRID_REQUEST_BLOCK_STRUCTURE_VERSION: ULONG = 0x1; +STRUCT!{struct HYBRID_REQUEST_BLOCK { + Version: ULONG, + Size: ULONG, + Function: ULONG, + Flags: ULONG, + DataBufferOffset: ULONG, + DataBufferLength: ULONG, +}} +pub type PHYBRID_REQUEST_BLOCK = *mut HYBRID_REQUEST_BLOCK; +ENUM!{enum NVCACHE_TYPE { + NvCacheTypeUnknown = 0, + NvCacheTypeNone = 1, + NvCacheTypeWriteBack = 2, + NvCacheTypeWriteThrough = 3, +}} +ENUM!{enum NVCACHE_STATUS { + NvCacheStatusUnknown = 0, + NvCacheStatusDisabling = 1, + NvCacheStatusDisabled = 2, + NvCacheStatusEnabled = 3, +}} +STRUCT!{struct NVCACHE_PRIORITY_LEVEL_DESCRIPTOR { + PriorityLevel: UCHAR, + Reserved0: [UCHAR; 3], + ConsumedNVMSizeFraction: ULONG, + ConsumedMappingResourcesFraction: ULONG, + ConsumedNVMSizeForDirtyDataFraction: ULONG, + ConsumedMappingResourcesForDirtyDataFraction: ULONG, + Reserved1: ULONG, +}} +pub type PNVCACHE_PRIORITY_LEVEL_DESCRIPTOR = *mut NVCACHE_PRIORITY_LEVEL_DESCRIPTOR; +pub const HYBRID_REQUEST_INFO_STRUCTURE_VERSION: ULONG = 1; +STRUCT!{struct HYBRID_INFORMATION { + Version: ULONG, + Size: ULONG, + HybridSupported: BOOLEAN, + Status: NVCACHE_STATUS, + CacheTypeEffective: NVCACHE_TYPE, + CacheTypeDefault: NVCACHE_TYPE, + FractionBase: ULONG, + CacheSize: ULONGLONG, + Attributes: HYBRID_INFORMATION_Attributes, + Priorities: HYBRID_INFORMATION_Priorities, +}} +pub type PHYBRID_INFORMATION = *mut HYBRID_INFORMATION; +STRUCT!{struct HYBRID_INFORMATION_Attributes { + Bitfield: ULONG, +}} +BITFIELD!{HYBRID_INFORMATION_Attributes Bitfield: ULONG [ + WriteCacheChangeable set_WriteCacheChangeable[0..1], + WriteThroughIoSupported set_WriteThroughIoSupported[1..2], + FlushCacheSupported set_FlushCacheSupported[2..3], + Removable set_Removable[3..4], + ReservedBits set_ReservedBits[4..32], +]} +STRUCT!{struct HYBRID_INFORMATION_Priorities { + PriorityLevelCount: UCHAR, + MaxPriorityBehavior: BOOLEAN, + OptimalWriteGranularity: UCHAR, + Reserved: UCHAR, + DirtyThresholdLow: ULONG, + DirtyThresholdHigh: ULONG, + SupportedCommands: HYBRID_INFORMATION_Priorities_SupportedCommands, + Priority: [NVCACHE_PRIORITY_LEVEL_DESCRIPTOR; 0], +}} +STRUCT!{struct HYBRID_INFORMATION_Priorities_SupportedCommands { + Bitfield: ULONG, + MaxEvictCommands: ULONG, + MaxLbaRangeCountForEvict: ULONG, + MaxLbaRangeCountForChangeLba: ULONG, +}} +BITFIELD!{HYBRID_INFORMATION_Priorities_SupportedCommands Bitfield: ULONG [ + CacheDisable set_CacheDisable[0..1], + SetDirtyThreshold set_SetDirtyThreshold[1..2], + PriorityDemoteBySize set_PriorityDemoteBySize[2..3], + PriorityChangeByLbaRange set_PriorityChangeByLbaRange[3..4], + Evict set_Evict[4..5], + ReservedBits set_ReservedBits[5..32], +]} +STRUCT!{struct HYBRID_DIRTY_THRESHOLDS { + Version: ULONG, + Size: ULONG, + DirtyLowThreshold: ULONG, + DirtyHighThreshold: ULONG, +}} +pub type PHYBRID_DIRTY_THRESHOLDS = *mut HYBRID_DIRTY_THRESHOLDS; +STRUCT!{struct HYBRID_DEMOTE_BY_SIZE { + Version: ULONG, + Size: ULONG, + SourcePriority: UCHAR, + TargetPriority: UCHAR, + Reserved0: USHORT, + Reserved1: ULONG, + LbaCount: ULONGLONG, +}} +pub type PHYBRID_DEMOTE_BY_SIZE = *mut HYBRID_DEMOTE_BY_SIZE; +pub const FIRMWARE_FUNCTION_GET_INFO: ULONG = 0x01; +pub const FIRMWARE_FUNCTION_DOWNLOAD: ULONG = 0x02; +pub const FIRMWARE_FUNCTION_ACTIVATE: ULONG = 0x03; +pub const FIRMWARE_STATUS_SUCCESS: ULONG = 0x0; +pub const FIRMWARE_STATUS_ERROR: ULONG = 0x1; +pub const FIRMWARE_STATUS_ILLEGAL_REQUEST: ULONG = 0x2; +pub const FIRMWARE_STATUS_INVALID_PARAMETER: ULONG = 0x3; +pub const FIRMWARE_STATUS_INPUT_BUFFER_TOO_BIG: ULONG = 0x4; +pub const FIRMWARE_STATUS_OUTPUT_BUFFER_TOO_SMALL: ULONG = 0x5; +pub const FIRMWARE_STATUS_INVALID_SLOT: ULONG = 0x6; +pub const FIRMWARE_STATUS_INVALID_IMAGE: ULONG = 0x7; +pub const FIRMWARE_STATUS_CONTROLLER_ERROR: ULONG = 0x10; +pub const FIRMWARE_STATUS_POWER_CYCLE_REQUIRED: ULONG = 0x20; +pub const FIRMWARE_STATUS_DEVICE_ERROR: ULONG = 0x40; +pub const FIRMWARE_STATUS_INTERFACE_CRC_ERROR: ULONG = 0x80; +pub const FIRMWARE_STATUS_UNCORRECTABLE_DATA_ERROR: ULONG = 0x81; +pub const FIRMWARE_STATUS_MEDIA_CHANGE: ULONG = 0x82; +pub const FIRMWARE_STATUS_ID_NOT_FOUND: ULONG = 0x83; +pub const FIRMWARE_STATUS_MEDIA_CHANGE_REQUEST: ULONG = 0x84; +pub const FIRMWARE_STATUS_COMMAND_ABORT: ULONG = 0x85; +pub const FIRMWARE_STATUS_END_OF_MEDIA: ULONG = 0x86; +pub const FIRMWARE_STATUS_ILLEGAL_LENGTH: ULONG = 0x87; +pub const FIRMWARE_REQUEST_BLOCK_STRUCTURE_VERSION: ULONG = 0x1; +STRUCT!{struct FIRMWARE_REQUEST_BLOCK { + Version: ULONG, + Size: ULONG, + Function: ULONG, + Flags: ULONG, + DataBufferOffset: ULONG, + DataBufferLength: ULONG, +}} +pub type PFIRMWARE_REQUEST_BLOCK = *mut FIRMWARE_REQUEST_BLOCK; +pub const FIRMWARE_REQUEST_FLAG_CONTROLLER: ULONG = 0x00000001; +pub const FIRMWARE_REQUEST_FLAG_LAST_SEGMENT: ULONG = 0x00000002; +pub const FIRMWARE_REQUEST_FLAG_SWITCH_TO_EXISTING_FIRMWARE: ULONG = 0x80000000; +pub const STORAGE_FIRMWARE_INFO_STRUCTURE_VERSION: ULONG = 0x1; +pub const STORAGE_FIRMWARE_INFO_STRUCTURE_VERSION_V2: ULONG = 0x2; +pub const STORAGE_FIRMWARE_INFO_INVALID_SLOT: UCHAR = 0xFF; +STRUCT!{struct STORAGE_FIRMWARE_SLOT_INFO { + SlotNumber: UCHAR, + ReadOnly: BOOLEAN, + Reserved: [UCHAR; 6], + Revision: STORAGE_FIRMWARE_SLOT_INFO_Revision, +}} +pub type PSTORAGE_FIRMWARE_SLOT_INFO = *mut STORAGE_FIRMWARE_SLOT_INFO; +UNION!{union STORAGE_FIRMWARE_SLOT_INFO_Revision { + [u64; 1], + Info Info_mut: [UCHAR; 8], + AsUlonglong AsUlonglong_mut: ULONGLONG, +}} +pub const STORAGE_FIRMWARE_SLOT_INFO_V2_REVISION_LENGTH: usize = 16; +STRUCT!{struct STORAGE_FIRMWARE_SLOT_INFO_V2 { + SlotNumber: UCHAR, + ReadOnly: BOOLEAN, + Reserved: [UCHAR; 6], + Revision: [UCHAR; STORAGE_FIRMWARE_SLOT_INFO_V2_REVISION_LENGTH], +}} +pub type PSTORAGE_FIRMWARE_SLOT_INFO_V2 = *mut STORAGE_FIRMWARE_SLOT_INFO_V2; +STRUCT!{struct STORAGE_FIRMWARE_INFO { + Version: ULONG, + Size: ULONG, + UpgradeSupport: BOOLEAN, + SlotCount: UCHAR, + ActiveSlot: UCHAR, + PendingActivateSlot: UCHAR, + Reserved: ULONG, + Slot: [STORAGE_FIRMWARE_SLOT_INFO; 0], +}} +pub type PSTORAGE_FIRMWARE_INFO = *mut STORAGE_FIRMWARE_INFO; +STRUCT!{struct STORAGE_FIRMWARE_INFO_V2 { + Version: ULONG, + Size: ULONG, + UpgradeSupport: BOOLEAN, + SlotCount: UCHAR, + ActiveSlot: UCHAR, + PendingActivateSlot: UCHAR, + FirmwareShared: BOOLEAN, + Reserved: [UCHAR; 3], + ImagePayloadAlignment: ULONG, + ImagePayloadMaxSize: ULONG, + Slot: [STORAGE_FIRMWARE_SLOT_INFO_V2; 0], +}} +pub type PSTORAGE_FIRMWARE_INFO_V2 = *mut STORAGE_FIRMWARE_INFO_V2; +pub const STORAGE_FIRMWARE_DOWNLOAD_STRUCTURE_VERSION: ULONG = 0x1; +pub const STORAGE_FIRMWARE_DOWNLOAD_STRUCTURE_VERSION_V2: ULONG = 0x2; +STRUCT!{struct STORAGE_FIRMWARE_DOWNLOAD { + Version: ULONG, + Size: ULONG, + Offset: ULONGLONG, + BufferSize: ULONGLONG, + ImageBuffer: [UCHAR; 0], +}} +pub type PSTORAGE_FIRMWARE_DOWNLOAD = *mut STORAGE_FIRMWARE_DOWNLOAD; +STRUCT!{struct STORAGE_FIRMWARE_DOWNLOAD_V2 { + Version: ULONG, + Size: ULONG, + Offset: ULONGLONG, + BufferSize: ULONGLONG, + Slot: UCHAR, + Reserved: [UCHAR; 7], + ImageBuffer: [UCHAR; 0], +}} +pub type PSTORAGE_FIRMWARE_DOWNLOAD_V2 = *mut STORAGE_FIRMWARE_DOWNLOAD_V2; +pub const STORAGE_FIRMWARE_ACTIVATE_STRUCTURE_VERSION: ULONG = 0x1; +STRUCT!{struct STORAGE_FIRMWARE_ACTIVATE { + Version: ULONG, + Size: ULONG, + SlotToActivate: UCHAR, + Reserved0: [UCHAR; 3], +}} +pub type PSTORAGE_FIRMWARE_ACTIVATE = *mut STORAGE_FIRMWARE_ACTIVATE; +STRUCT!{struct IO_SCSI_CAPABILITIES { + Length: ULONG, + MaximumTransferLength: ULONG, + MaximumPhysicalPages: ULONG, + SupportedAsynchronousEvents: ULONG, + AlignmentMask: ULONG, + TaggedQueuing: BOOLEAN, + AdapterScansDown: BOOLEAN, + AdapterUsesPio: BOOLEAN, +}} +pub type PIO_SCSI_CAPABILITIES = *mut IO_SCSI_CAPABILITIES; +STRUCT!{struct SCSI_ADDRESS { + Length: ULONG, + PortNumber: UCHAR, + PathId: UCHAR, + TargetId: UCHAR, + Lun: UCHAR, +}} +pub type PSCSI_ADDRESS = *mut SCSI_ADDRESS; +pub const DUMP_POINTERS_VERSION_1: ULONG = 1; +pub const DUMP_POINTERS_VERSION_2: ULONG = 2; +pub const DUMP_POINTERS_VERSION_3: ULONG = 3; +pub const DUMP_POINTERS_VERSION_4: ULONG = 4; +pub const DUMP_DRIVER_NAME_LENGTH: usize = 15; +FN!{cdecl DUMP_DEVICE_POWERON_ROUTINE( + Context: PVOID, +) -> LONG} +pub type PDUMP_DEVICE_POWERON_ROUTINE = *mut DUMP_DEVICE_POWERON_ROUTINE; +STRUCT!{struct DUMP_POINTERS_VERSION { + Version: ULONG, + Size: ULONG, +}} +pub type PDUMP_POINTERS_VERSION = *mut DUMP_POINTERS_VERSION; +STRUCT!{struct DUMP_POINTERS { + AdapterObject: PVOID, // struct _ADAPTER_OBJECT * + MappedRegisterBase: PVOID, + DumpData: PVOID, + CommonBufferVa: PVOID, + CommonBufferPa: LARGE_INTEGER, + CommonBufferSize: ULONG, + AllocateCommonBuffers: BOOLEAN, + UseDiskDump: BOOLEAN, + Spare1: [UCHAR; 2], + DeviceObject: PVOID, +}} +pub type PDUMP_POINTERS = *mut DUMP_POINTERS; +STRUCT!{struct DUMP_POINTERS_EX { + Header: DUMP_POINTERS_VERSION, + DumpData: PVOID, + CommonBufferVa: PVOID, + CommonBufferSize: ULONG, + AllocateCommonBuffers: BOOLEAN, + DeviceObject: PVOID, + DriverList: PVOID, + dwPortFlags: ULONG, + MaxDeviceDumpSectionSize: ULONG, + MaxDeviceDumpLevel: ULONG, + MaxTransferSize: ULONG, + AdapterObject: PVOID, + MappedRegisterBase: PVOID, + DeviceReady: PBOOLEAN, + DumpDevicePowerOn: PDUMP_DEVICE_POWERON_ROUTINE, + DumpDevicePowerOnContext: PVOID, +}} +pub type PDUMP_POINTERS_EX = *mut DUMP_POINTERS_EX; +// TODO: Revisit these definitions when const size_of and offset_of! arrive. +#[cfg(target_pointer_width = "32")] +IFDEF!{ +pub const DUMP_POINTERS_EX_V2_SIZE: ULONG = 32; +pub const DUMP_POINTERS_EX_V3_SIZE: ULONG = 60; +pub const DUMP_POINTERS_EX_V4_SIZE: ULONG = 68; +} +#[cfg(target_pointer_width = "64")] +IFDEF!{ +pub const DUMP_POINTERS_EX_V2_SIZE: ULONG = 48; +pub const DUMP_POINTERS_EX_V3_SIZE: ULONG = 88; +pub const DUMP_POINTERS_EX_V4_SIZE: ULONG = 104; +} +pub const DUMP_EX_FLAG_SUPPORT_64BITMEMORY: ULONG = 0x00000001; +pub const DUMP_EX_FLAG_SUPPORT_DD_TELEMETRY: ULONG = 0x00000002; +pub const DUMP_EX_FLAG_RESUME_SUPPORT: ULONG = 0x00000004; +STRUCT!{struct DUMP_DRIVER { + DumpDriverList: PVOID, + DriverName: [WCHAR; DUMP_DRIVER_NAME_LENGTH], + BaseName: [WCHAR; DUMP_DRIVER_NAME_LENGTH], +}} +pub type PDUMP_DRIVER = *mut DUMP_DRIVER; +pub const SCSI_IOCTL_DATA_OUT: UCHAR = 0; +pub const SCSI_IOCTL_DATA_IN: UCHAR = 1; +pub const SCSI_IOCTL_DATA_UNSPECIFIED: UCHAR = 2; +pub const SCSI_IOCTL_DATA_BIDIRECTIONAL: UCHAR = 3; +pub const MPIO_IOCTL_FLAG_USE_PATHID: UCHAR = 1; +pub const MPIO_IOCTL_FLAG_USE_SCSIADDRESS: UCHAR = 2; +pub const MPIO_IOCTL_FLAG_INVOLVE_DSM: UCHAR = 4; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntddser.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntddser.rs new file mode 100644 index 0000000..d37b7f6 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntddser.rs @@ -0,0 +1,17 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! This is the include file that defines all constants and types for accessing the Serial device. +use shared::devpropdef::DEVPROPKEY; +DEFINE_GUID!{GUID_DEVINTERFACE_COMPORT, + 0x86E0D1E0, 0x8089, 0x11D0, 0x9C, 0xE4, 0x08, 0x00, 0x3E, 0x30, 0x1F, 0x73} +DEFINE_GUID!{GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR, + 0x4D36E978, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceInterface_Serial_UsbVendorId, + 0x4C6BF15C, 0x4C03, 0x4AAC, 0x91, 0xF5, 0x64, 0xC0, 0xF8, 0x52, 0xBC, 0xF4, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceInterface_Serial_UsbProductId, + 0x4C6BF15C, 0x4C03, 0x4AAC, 0x91, 0xF5, 0x64, 0xC0, 0xF8, 0x52, 0xBC, 0xF4, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_DeviceInterface_Serial_PortName, + 0x4C6BF15C, 0x4C03, 0x4AAC, 0x91, 0xF5, 0x64, 0xC0, 0xF8, 0x52, 0xBC, 0xF4, 4} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntdef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntdef.rs new file mode 100644 index 0000000..2a4e120 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntdef.rs @@ -0,0 +1,1073 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Type definitions for the basic types. +use ctypes::{ + __int64, __uint64, c_char, c_double, c_int, c_long, c_schar, c_short, c_uchar, c_ulong, + c_ushort, c_void, wchar_t +}; +use shared::basetsd::{KAFFINITY, LONG_PTR, ULONG64, ULONG_PTR}; +use shared::guiddef::GUID; +#[cfg(target_arch = "x86_64")] +IFDEF!{ +pub const MAX_NATURAL_ALIGNMENT: usize = 8; +pub const MEMORY_ALLOCATION_ALIGNMENT: usize = 16; +} +#[cfg(not(target_arch = "x86_64"))] +IFDEF!{ +pub const MAX_NATURAL_ALIGNMENT: usize = 4; +pub const MEMORY_ALLOCATION_ALIGNMENT: usize = 8; +} +#[cfg(any(target_arch = "x86_64", target_arch = "x86"))] +pub const SYSTEM_CACHE_ALIGNMENT_SIZE: usize = 64; +#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))] +pub const SYSTEM_CACHE_ALIGNMENT_SIZE: usize = 128; +pub type PVOID = *mut c_void; +pub type PVOID64 = u64; // This is a 64-bit pointer, even when in 32-bit +pub type VOID = c_void; +pub type CHAR = c_char; +pub type SHORT = c_short; +pub type LONG = c_long; +pub type INT = c_int; +pub type WCHAR = wchar_t; +pub type PWCHAR = *mut WCHAR; +pub type LPWCH = *mut WCHAR; +pub type PWCH = *mut WCHAR; +pub type LPCWCH = *const WCHAR; +pub type PCWCH = *const WCHAR; +pub type NWPSTR = *mut WCHAR; +pub type LPWSTR = *mut WCHAR; +pub type LPTSTR = LPSTR; +pub type PWSTR = *mut WCHAR; +pub type PZPWSTR = *mut PWSTR; +pub type PCZPWSTR = *const PWSTR; +pub type LPUWSTR = *mut WCHAR; // Unaligned pointer +pub type PUWSTR = *mut WCHAR; // Unaligned pointer +pub type LPCWSTR = *const WCHAR; +pub type PCWSTR = *const WCHAR; +pub type PZPCWSTR = *mut PCWSTR; +pub type PCZPCWSTR = *const PCWSTR; +pub type LPCUWSTR = *const WCHAR; // Unaligned pointer +pub type PCUWSTR = *const WCHAR; // Unaligned pointer +pub type PZZWSTR = *mut WCHAR; +pub type PCZZWSTR = *const WCHAR; +pub type PUZZWSTR = *mut WCHAR; // Unaligned pointer +pub type PCUZZWSTR = *const WCHAR; // Unaligned pointer +pub type PNZWCH = *mut WCHAR; +pub type PCNZWCH = *const WCHAR; +pub type PUNZWCH = *mut WCHAR; // Unaligned pointer +pub type PCUNZWCH = *const WCHAR; // Unaligned pointer +pub type LPCWCHAR = *const WCHAR; +pub type PCWCHAR = *const WCHAR; +pub type LPCUWCHAR = *const WCHAR; // Unaligned pointer +pub type PCUWCHAR = *const WCHAR; // Unaligned pointer +pub type UCSCHAR = c_ulong; +pub const UCSCHAR_INVALID_CHARACTER: UCSCHAR = 0xffffffff; +pub const MIN_UCSCHAR: UCSCHAR = 0; +pub const MAX_UCSCHAR: UCSCHAR = 0x0010FFFF; +pub type PUCSCHAR = *mut UCSCHAR; +pub type PCUCSCHAR = *const UCSCHAR; +pub type PUCSSTR = *mut UCSCHAR; +pub type PUUCSSTR = *mut UCSCHAR; // Unaligned pointer +pub type PCUCSSTR = *const UCSCHAR; +pub type PCUUCSSTR = *const UCSCHAR; // Unaligned pointer +pub type PUUCSCHAR = *mut UCSCHAR; // Unaligned pointer +pub type PCUUCSCHAR = *const UCSCHAR; // Unaligned pointer +pub type PCHAR = *mut CHAR; +pub type LPCH = *mut CHAR; +pub type PCH = *mut CHAR; +pub type LPCCH = *const CHAR; +pub type PCCH = *const CHAR; +pub type NPSTR = *mut CHAR; +pub type LPSTR = *mut CHAR; +pub type PSTR = *mut CHAR; +pub type PZPSTR = *mut PSTR; +pub type PCZPSTR = *const PSTR; +pub type LPCSTR = *const CHAR; +pub type PCSTR = *const CHAR; +pub type PZPCSTR = *mut PCSTR; +pub type PCZPCSTR = *const PCSTR; +pub type PZZSTR = *mut CHAR; +pub type PCZZSTR = *const CHAR; +pub type PNZCH = *mut CHAR; +pub type PCNZCH = *const CHAR; +// Skipping TCHAR things +pub type DOUBLE = c_double; +STRUCT!{struct QUAD { + UseThisFieldToCopy: __int64, +}} +pub type PSHORT = *mut SHORT; +pub type PLONG = *mut LONG; +pub type PQUAD = *mut QUAD; +pub type UCHAR = c_uchar; +pub type USHORT = c_ushort; +pub type ULONG = c_ulong; +pub type UQUAD = QUAD; +pub type PUCHAR = *mut UCHAR; +pub type PUSHORT = *mut USHORT; +pub type PULONG = *mut ULONG; +pub type PUQUAD = *mut UQUAD; +pub type PCUCHAR = *const UCHAR; +pub type PCUSHORT = *const USHORT; +pub type PCULONG = *const ULONG; +pub type PCUQUAD = *const UQUAD; +pub type SCHAR = c_schar; +pub type PSCHAR = *mut SCHAR; +pub type PCSCHAR = *const SCHAR; +pub const ALL_PROCESSOR_GROUPS: USHORT = 0xffff; +STRUCT!{struct PROCESSOR_NUMBER { + Group: USHORT, + Number: UCHAR, + Reserved: UCHAR, +}} +pub type PPROCESSOR_NUMBER = *mut PROCESSOR_NUMBER; +STRUCT!{struct GROUP_AFFINITY { + Mask: KAFFINITY, + Group: USHORT, + Reserved: [USHORT; 3], +}} +pub type PGROUP_AFFINITY = *mut GROUP_AFFINITY; +#[cfg(target_arch = "x86_64")] +pub const MAXIMUM_PROC_PER_GROUP: UCHAR = 64; +#[cfg(not(target_arch = "x86_64"))] +pub const MAXIMUM_PROC_PER_GROUP: UCHAR = 32; +pub const MAXIMUM_PROCESSORS: UCHAR = MAXIMUM_PROC_PER_GROUP; +pub type HANDLE = *mut c_void; +pub type PHANDLE = *mut HANDLE; +pub type FCHAR = UCHAR; +pub type FSHORT = USHORT; +pub type FLONG = ULONG; +pub type HRESULT = c_long; +pub const OBJ_HANDLE_TAGBITS: usize = 0x00000003; +pub type CCHAR = c_char; +pub type CSHORT = c_short; +pub type CLONG = ULONG; +pub type PCCHAR = *mut CCHAR; +pub type PCSHORT = *mut CSHORT; +pub type PCLONG = *mut CLONG; +pub type LCID = ULONG; +pub type PLCID = PULONG; +pub type LANGID = USHORT; +ENUM!{enum COMPARTMENT_ID { + UNSPECIFIED_COMPARTMENT_ID = 0, + DEFAULT_COMPARTMENT_ID, +}} +pub type PCOMPARTMENT_ID = *mut COMPARTMENT_ID; +pub type LOGICAL = ULONG; +pub type PLOGICAL = *mut ULONG; +pub type NTSTATUS = LONG; +pub type PNTSTATUS = *mut NTSTATUS; +pub type PCNTSTATUS = *const NTSTATUS; +#[inline] +pub fn NT_SUCCESS(Status: NTSTATUS) -> bool { + Status >= 0 +} +#[inline] +pub fn NT_INFORMATION(Status: NTSTATUS) -> bool { + ((Status as ULONG) >> 30) == 1 +} +#[inline] +pub fn NT_WARNING(Status: NTSTATUS) -> bool { + ((Status as ULONG) >> 30) == 2 +} +#[inline] +pub fn NT_ERROR(Status: NTSTATUS) -> bool { + ((Status as ULONG) >> 30) == 3 +} +pub const APPLICATION_ERROR_MASK: ULONG = 0x20000000; +pub const ERROR_SEVERITY_SUCCESS: ULONG = 0x00000000; +pub const ERROR_SEVERITY_INFORMATIONAL: ULONG = 0x40000000; +pub const ERROR_SEVERITY_WARNING: ULONG = 0x80000000; +pub const ERROR_SEVERITY_ERROR: ULONG = 0xC0000000; +pub type SECURITY_STATUS = c_long; +pub type TIME = LARGE_INTEGER; +pub type PTIME = *mut TIME; +STRUCT!{struct FLOAT128 { + LowPart: __int64, + HighPart: __int64, +}} +pub type PFLOAT128 = *mut FLOAT128; +pub type LONGLONG = __int64; +pub type ULONGLONG = __uint64; +pub const MAXLONGLONG: LONGLONG = 0x7fffffffffffffff; +pub type PLONGLONG = *mut LONGLONG; +pub type PULONGLONG = *mut ULONGLONG; +pub type USN = LONGLONG; +UNION!{union LARGE_INTEGER { + [i64; 1], + s s_mut: LARGE_INTEGER_s, + QuadPart QuadPart_mut: LONGLONG, +}} +STRUCT!{struct LARGE_INTEGER_s { + LowPart: ULONG, + HighPart: LONG, +}} +pub type PLARGE_INTEGER = *mut LARGE_INTEGER; +UNION!{union ULARGE_INTEGER { + [u64; 1], + s s_mut: ULARGE_INTEGER_s, + QuadPart QuadPart_mut: ULONGLONG, +}} +STRUCT!{struct ULARGE_INTEGER_s { + LowPart: ULONG, + HighPart: ULONG, +}} +pub type PULARGE_INTEGER = *mut ULARGE_INTEGER; +pub type RTL_REFERENCE_COUNT = LONG_PTR; +pub type PRTL_REFERENCE_COUNT = *mut RTL_REFERENCE_COUNT; +STRUCT!{struct LUID { + LowPart: ULONG, + HighPart: LONG, +}} +pub type PLUID = *mut LUID; +pub type DWORDLONG = ULONGLONG; +pub type PDWORDLONG = *mut DWORDLONG; +pub type PHYSICAL_ADDRESS = LARGE_INTEGER; +pub type PPHYSICAL_ADDRESS = *mut PHYSICAL_ADDRESS; +ENUM!{enum EVENT_TYPE { + NotificationEvent, + SynchronizationEvent, +}} +ENUM!{enum TIMER_TYPE { + NotificationTimer, + SynchronizationTimer, +}} +ENUM!{enum WAIT_TYPE { + WaitAll, + WaitAny, + WaitNotification, + WaitDequeue, +}} +pub type PSZ = *mut CHAR; +pub type PCSZ = *const c_char; +pub type RTL_STRING_LENGTH_TYPE = USHORT; +STRUCT!{struct STRING { + Length: USHORT, + MaximumLength: USHORT, + Buffer: PCHAR, +}} +pub type PSTRING = *mut STRING; +pub type ANSI_STRING = STRING; +pub type PANSI_STRING = PSTRING; +pub type OEM_STRING = STRING; +pub type POEM_STRING = PSTRING; +pub type PCOEM_STRING = *const STRING; +STRUCT!{struct CSTRING { + Length: USHORT, + MaximumLength: USHORT, + Buffer: *const c_char, +}} +pub type PCSTRING = *mut CSTRING; +pub const ANSI_NULL: CHAR = 0; +pub type CANSI_STRING = STRING; +pub type PCANSI_STRING = PSTRING; +STRUCT!{struct UNICODE_STRING { + Length: USHORT, + MaximumLength: USHORT, + Buffer: PWCH, +}} +pub type PUNICODE_STRING = *mut UNICODE_STRING; +pub type PCUNICODE_STRING = *const UNICODE_STRING; +pub const UNICODE_NULL: WCHAR = 0; +pub const UNICODE_STRING_MAX_BYTES: USHORT = 65534; +pub const UNICODE_STRING_MAX_CHARS: usize = 32767; +pub type BOOLEAN = UCHAR; +pub type PBOOLEAN = *mut BOOLEAN; +STRUCT!{struct LIST_ENTRY { + Flink: *mut LIST_ENTRY, + Blink: *mut LIST_ENTRY, +}} +pub type PLIST_ENTRY = *mut LIST_ENTRY; +pub type PRLIST_ENTRY = *mut LIST_ENTRY; // Restricted pointer +STRUCT!{struct SINGLE_LIST_ENTRY { + Next: *mut SINGLE_LIST_ENTRY, +}} +pub type PSINGLE_LIST_ENTRY = *mut SINGLE_LIST_ENTRY; +STRUCT!{struct RTL_BALANCED_NODE { + u: RTL_BALANCED_NODE_u, + ParentValue: ULONG_PTR, +}} +UNION!{union RTL_BALANCED_NODE_u { + [usize; 2], + Children Children_mut: [*mut RTL_BALANCED_NODE; 2], + s s_mut: RTL_BALANCED_NODE_s, +}} +STRUCT!{struct RTL_BALANCED_NODE_s { + Left: *mut RTL_BALANCED_NODE, + Right: *mut RTL_BALANCED_NODE, +}} +pub const RTL_BALANCED_NODE_RESERVED_PARENT_MASK: ULONG_PTR = 3; +pub type PRTL_BALANCED_NODE = *mut RTL_BALANCED_NODE; +#[inline] +pub unsafe fn RTL_BALANCED_NODE_GET_PARENT_POINTER( + Node: PRTL_BALANCED_NODE, +) -> PRTL_BALANCED_NODE { + ((*Node).ParentValue & !RTL_BALANCED_NODE_RESERVED_PARENT_MASK) as *mut RTL_BALANCED_NODE +} +STRUCT!{struct LIST_ENTRY32 { + Flink: ULONG, + Blink: ULONG, +}} +pub type PLIST_ENTRY32 = *mut LIST_ENTRY32; +STRUCT!{struct LIST_ENTRY64 { + Flink: ULONGLONG, + Blink: ULONGLONG, +}} +pub type PLIST_ENTRY64 = *mut LIST_ENTRY64; +STRUCT!{struct SINGLE_LIST_ENTRY32 { + Next: ULONG, +}} +pub type PSINGLE_LIST_ENTRY32 = *mut SINGLE_LIST_ENTRY32; +#[inline] +pub unsafe fn ListEntry32To64(l32: PLIST_ENTRY32, l64: PLIST_ENTRY64) { + (*l64).Flink = (*l32).Flink as ULONGLONG; + (*l64).Blink = (*l32).Blink as ULONGLONG; +} +#[inline] +pub unsafe fn ListEntry64To32(l64: PLIST_ENTRY64, l32: PLIST_ENTRY32) { + (*l32).Flink = (*l64).Flink as ULONG; + (*l32).Blink = (*l64).Blink as ULONG; +} +STRUCT!{struct WNF_STATE_NAME { + Data: [ULONG; 2], +}} +pub type PWNF_STATE_NAME = *mut WNF_STATE_NAME; +pub type PCWNF_STATE_NAME = *const WNF_STATE_NAME; +STRUCT!{struct STRING32 { + Length: USHORT, + MaximumLength: USHORT, + Buffer: ULONG, +}} +pub type PSTRING32 = *mut STRING32; +pub type UNICODE_STRING32 = STRING32; +pub type PUNICODE_STRING32 = *mut UNICODE_STRING32; +pub type ANSI_STRING32 = STRING32; +pub type PANSI_STRING32 = *mut ANSI_STRING32; +STRUCT!{struct STRING64 { + Length: USHORT, + MaximumLength: USHORT, + Buffer: ULONGLONG, +}} +pub type PSTRING64 = *mut STRING64; +pub type UNICODE_STRING64 = STRING64; +pub type PUNICODE_STRING64 = *mut UNICODE_STRING64; +pub type ANSI_STRING64 = STRING64; +pub type PANSI_STRING64 = *mut ANSI_STRING64; +pub const OBJ_INHERIT: ULONG = 0x00000002; +pub const OBJ_PERMANENT: ULONG = 0x00000010; +pub const OBJ_EXCLUSIVE: ULONG = 0x00000020; +pub const OBJ_CASE_INSENSITIVE: ULONG = 0x00000040; +pub const OBJ_OPENIF: ULONG = 0x00000080; +pub const OBJ_OPENLINK: ULONG = 0x00000100; +pub const OBJ_KERNEL_HANDLE: ULONG = 0x00000200; +pub const OBJ_FORCE_ACCESS_CHECK: ULONG = 0x00000400; +pub const OBJ_IGNORE_IMPERSONATED_DEVICEMAP: ULONG = 0x00000800; +pub const OBJ_DONT_REPARSE: ULONG = 0x00001000; +pub const OBJ_VALID_ATTRIBUTES: ULONG = 0x00001FF2; +STRUCT!{struct OBJECT_ATTRIBUTES64 { + Length: ULONG, + RootDirectory: ULONG64, + ObjectName: ULONG64, + Attributes: ULONG, + SecurityDescriptor: ULONG64, + SecurityQualityOfService: ULONG64, +}} +pub type POBJECT_ATTRIBUTES64 = *mut OBJECT_ATTRIBUTES64; +pub type PCOBJECT_ATTRIBUTES64 = *const OBJECT_ATTRIBUTES64; +STRUCT!{struct OBJECT_ATTRIBUTES32 { + Length: ULONG, + RootDirectory: ULONG, + ObjectName: ULONG, + Attributes: ULONG, + SecurityDescriptor: ULONG, + SecurityQualityOfService: ULONG, +}} +pub type POBJECT_ATTRIBUTES32 = *mut OBJECT_ATTRIBUTES32; +pub type PCOBJECT_ATTRIBUTES32 = *const OBJECT_ATTRIBUTES32; +STRUCT!{struct OBJECT_ATTRIBUTES { + Length: ULONG, + RootDirectory: HANDLE, + ObjectName: PUNICODE_STRING, + Attributes: ULONG, + SecurityDescriptor: PVOID, + SecurityQualityOfService: PVOID, +}} +pub type POBJECT_ATTRIBUTES = *mut OBJECT_ATTRIBUTES; +pub type PCOBJECT_ATTRIBUTES = *const OBJECT_ATTRIBUTES; +#[inline] +pub unsafe fn InitializeObjectAttributes( + p: POBJECT_ATTRIBUTES, + n: PUNICODE_STRING, + a: ULONG, + r: HANDLE, + s: PVOID, +) { + use core::mem::size_of; + (*p).Length = size_of::<OBJECT_ATTRIBUTES>() as ULONG; + (*p).RootDirectory = r; + (*p).Attributes = a; + (*p).ObjectName = n; + (*p).SecurityDescriptor = s; + (*p).SecurityQualityOfService = NULL; +} +pub const FALSE: BOOLEAN = 0; +pub const TRUE: BOOLEAN = 1; +pub const NULL: PVOID = 0 as PVOID; +pub const NULL64: PVOID64 = 0; +STRUCT!{struct OBJECTID { + Lineage: GUID, + Uniquifier: ULONG, +}} +pub const MINCHAR: CHAR = 0x80; +pub const MAXCHAR: CHAR = 0x7f; +pub const MINSHORT: SHORT = 0x8000; +pub const MAXSHORT: SHORT = 0x7fff; +pub const MINLONG: LONG = 0x80000000; +pub const MAXLONG: LONG = 0x7fffffff; +pub const MAXUCHAR: UCHAR = 0xff; +pub const MAXUSHORT: USHORT = 0xffff; +pub const MAXULONG: ULONG = 0xffffffff; +// PEXCEPTION_ROUTINE: Can't define here, because it needs EXCEPTION_RECORD and CONTEXT. +pub type KIRQL = UCHAR; +pub type PKIRQL = *mut KIRQL; +ENUM!{enum NT_PRODUCT_TYPE { + NtProductWinNt = 1, + NtProductLanManNt, + NtProductServer, +}} +pub type PNT_PRODUCT_TYPE = *mut NT_PRODUCT_TYPE; +ENUM!{enum SUITE_TYPE { + SmallBusiness, + Enterprise, + BackOffice, + CommunicationServer, + TerminalServer, + SmallBusinessRestricted, + EmbeddedNT, + DataCenter, + SingleUserTS, + Personal, + Blade, + EmbeddedRestricted, + SecurityAppliance, + StorageServer, + ComputeServer, + WHServer, + PhoneNT, + MaxSuiteType, +}} +pub const VER_SERVER_NT: ULONG = 0x80000000; +pub const VER_WORKSTATION_NT: ULONG = 0x40000000; +pub const VER_SUITE_SMALLBUSINESS: ULONG = 0x00000001; +pub const VER_SUITE_ENTERPRISE: ULONG = 0x00000002; +pub const VER_SUITE_BACKOFFICE: ULONG = 0x00000004; +pub const VER_SUITE_COMMUNICATIONS: ULONG = 0x00000008; +pub const VER_SUITE_TERMINAL: ULONG = 0x00000010; +pub const VER_SUITE_SMALLBUSINESS_RESTRICTED: ULONG = 0x00000020; +pub const VER_SUITE_EMBEDDEDNT: ULONG = 0x00000040; +pub const VER_SUITE_DATACENTER: ULONG = 0x00000080; +pub const VER_SUITE_SINGLEUSERTS: ULONG = 0x00000100; +pub const VER_SUITE_PERSONAL: ULONG = 0x00000200; +pub const VER_SUITE_BLADE: ULONG = 0x00000400; +pub const VER_SUITE_EMBEDDED_RESTRICTED: ULONG = 0x00000800; +pub const VER_SUITE_SECURITY_APPLIANCE: ULONG = 0x00001000; +pub const VER_SUITE_STORAGE_SERVER: ULONG = 0x00002000; +pub const VER_SUITE_COMPUTE_SERVER: ULONG = 0x00004000; +pub const VER_SUITE_WH_SERVER: ULONG = 0x00008000; +pub const PRODUCT_UNDEFINED: ULONG = 0x00000000; +pub const PRODUCT_ULTIMATE: ULONG = 0x00000001; +pub const PRODUCT_HOME_BASIC: ULONG = 0x00000002; +pub const PRODUCT_HOME_PREMIUM: ULONG = 0x00000003; +pub const PRODUCT_ENTERPRISE: ULONG = 0x00000004; +pub const PRODUCT_HOME_BASIC_N: ULONG = 0x00000005; +pub const PRODUCT_BUSINESS: ULONG = 0x00000006; +pub const PRODUCT_STANDARD_SERVER: ULONG = 0x00000007; +pub const PRODUCT_DATACENTER_SERVER: ULONG = 0x00000008; +pub const PRODUCT_SMALLBUSINESS_SERVER: ULONG = 0x00000009; +pub const PRODUCT_ENTERPRISE_SERVER: ULONG = 0x0000000A; +pub const PRODUCT_STARTER: ULONG = 0x0000000B; +pub const PRODUCT_DATACENTER_SERVER_CORE: ULONG = 0x0000000C; +pub const PRODUCT_STANDARD_SERVER_CORE: ULONG = 0x0000000D; +pub const PRODUCT_ENTERPRISE_SERVER_CORE: ULONG = 0x0000000E; +pub const PRODUCT_ENTERPRISE_SERVER_IA64: ULONG = 0x0000000F; +pub const PRODUCT_BUSINESS_N: ULONG = 0x00000010; +pub const PRODUCT_WEB_SERVER: ULONG = 0x00000011; +pub const PRODUCT_CLUSTER_SERVER: ULONG = 0x00000012; +pub const PRODUCT_HOME_SERVER: ULONG = 0x00000013; +pub const PRODUCT_STORAGE_EXPRESS_SERVER: ULONG = 0x00000014; +pub const PRODUCT_STORAGE_STANDARD_SERVER: ULONG = 0x00000015; +pub const PRODUCT_STORAGE_WORKGROUP_SERVER: ULONG = 0x00000016; +pub const PRODUCT_STORAGE_ENTERPRISE_SERVER: ULONG = 0x00000017; +pub const PRODUCT_SERVER_FOR_SMALLBUSINESS: ULONG = 0x00000018; +pub const PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: ULONG = 0x00000019; +pub const PRODUCT_HOME_PREMIUM_N: ULONG = 0x0000001A; +pub const PRODUCT_ENTERPRISE_N: ULONG = 0x0000001B; +pub const PRODUCT_ULTIMATE_N: ULONG = 0x0000001C; +pub const PRODUCT_WEB_SERVER_CORE: ULONG = 0x0000001D; +pub const PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT: ULONG = 0x0000001E; +pub const PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY: ULONG = 0x0000001F; +pub const PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING: ULONG = 0x00000020; +pub const PRODUCT_SERVER_FOUNDATION: ULONG = 0x00000021; +pub const PRODUCT_HOME_PREMIUM_SERVER: ULONG = 0x00000022; +pub const PRODUCT_SERVER_FOR_SMALLBUSINESS_V: ULONG = 0x00000023; +pub const PRODUCT_STANDARD_SERVER_V: ULONG = 0x00000024; +pub const PRODUCT_DATACENTER_SERVER_V: ULONG = 0x00000025; +pub const PRODUCT_ENTERPRISE_SERVER_V: ULONG = 0x00000026; +pub const PRODUCT_DATACENTER_SERVER_CORE_V: ULONG = 0x00000027; +pub const PRODUCT_STANDARD_SERVER_CORE_V: ULONG = 0x00000028; +pub const PRODUCT_ENTERPRISE_SERVER_CORE_V: ULONG = 0x00000029; +pub const PRODUCT_HYPERV: ULONG = 0x0000002A; +pub const PRODUCT_STORAGE_EXPRESS_SERVER_CORE: ULONG = 0x0000002B; +pub const PRODUCT_STORAGE_STANDARD_SERVER_CORE: ULONG = 0x0000002C; +pub const PRODUCT_STORAGE_WORKGROUP_SERVER_CORE: ULONG = 0x0000002D; +pub const PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE: ULONG = 0x0000002E; +pub const PRODUCT_STARTER_N: ULONG = 0x0000002F; +pub const PRODUCT_PROFESSIONAL: ULONG = 0x00000030; +pub const PRODUCT_PROFESSIONAL_N: ULONG = 0x00000031; +pub const PRODUCT_SB_SOLUTION_SERVER: ULONG = 0x00000032; +pub const PRODUCT_SERVER_FOR_SB_SOLUTIONS: ULONG = 0x00000033; +pub const PRODUCT_STANDARD_SERVER_SOLUTIONS: ULONG = 0x00000034; +pub const PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE: ULONG = 0x00000035; +pub const PRODUCT_SB_SOLUTION_SERVER_EM: ULONG = 0x00000036; +pub const PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM: ULONG = 0x00000037; +pub const PRODUCT_SOLUTION_EMBEDDEDSERVER: ULONG = 0x00000038; +pub const PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE: ULONG = 0x00000039; +pub const PRODUCT_PROFESSIONAL_EMBEDDED: ULONG = 0x0000003A; +pub const PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT: ULONG = 0x0000003B; +pub const PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL: ULONG = 0x0000003C; +pub const PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC: ULONG = 0x0000003D; +pub const PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC: ULONG = 0x0000003E; +pub const PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE: ULONG = 0x0000003F; +pub const PRODUCT_CLUSTER_SERVER_V: ULONG = 0x00000040; +pub const PRODUCT_EMBEDDED: ULONG = 0x00000041; +pub const PRODUCT_STARTER_E: ULONG = 0x00000042; +pub const PRODUCT_HOME_BASIC_E: ULONG = 0x00000043; +pub const PRODUCT_HOME_PREMIUM_E: ULONG = 0x00000044; +pub const PRODUCT_PROFESSIONAL_E: ULONG = 0x00000045; +pub const PRODUCT_ENTERPRISE_E: ULONG = 0x00000046; +pub const PRODUCT_ULTIMATE_E: ULONG = 0x00000047; +pub const PRODUCT_ENTERPRISE_EVALUATION: ULONG = 0x00000048; +pub const PRODUCT_MULTIPOINT_STANDARD_SERVER: ULONG = 0x0000004C; +pub const PRODUCT_MULTIPOINT_PREMIUM_SERVER: ULONG = 0x0000004D; +pub const PRODUCT_STANDARD_EVALUATION_SERVER: ULONG = 0x0000004F; +pub const PRODUCT_DATACENTER_EVALUATION_SERVER: ULONG = 0x00000050; +pub const PRODUCT_ENTERPRISE_N_EVALUATION: ULONG = 0x00000054; +pub const PRODUCT_EMBEDDED_AUTOMOTIVE: ULONG = 0x00000055; +pub const PRODUCT_EMBEDDED_INDUSTRY_A: ULONG = 0x00000056; +pub const PRODUCT_THINPC: ULONG = 0x00000057; +pub const PRODUCT_EMBEDDED_A: ULONG = 0x00000058; +pub const PRODUCT_EMBEDDED_INDUSTRY: ULONG = 0x00000059; +pub const PRODUCT_EMBEDDED_E: ULONG = 0x0000005A; +pub const PRODUCT_EMBEDDED_INDUSTRY_E: ULONG = 0x0000005B; +pub const PRODUCT_EMBEDDED_INDUSTRY_A_E: ULONG = 0x0000005C; +pub const PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER: ULONG = 0x0000005F; +pub const PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER: ULONG = 0x00000060; +pub const PRODUCT_CORE_ARM: ULONG = 0x00000061; +pub const PRODUCT_CORE_N: ULONG = 0x00000062; +pub const PRODUCT_CORE_COUNTRYSPECIFIC: ULONG = 0x00000063; +pub const PRODUCT_CORE_SINGLELANGUAGE: ULONG = 0x00000064; +pub const PRODUCT_CORE: ULONG = 0x00000065; +pub const PRODUCT_PROFESSIONAL_WMC: ULONG = 0x00000067; +pub const PRODUCT_MOBILE_CORE: ULONG = 0x00000068; +pub const PRODUCT_EMBEDDED_INDUSTRY_EVAL: ULONG = 0x00000069; +pub const PRODUCT_EMBEDDED_INDUSTRY_E_EVAL: ULONG = 0x0000006A; +pub const PRODUCT_EMBEDDED_EVAL: ULONG = 0x0000006B; +pub const PRODUCT_EMBEDDED_E_EVAL: ULONG = 0x0000006C; +pub const PRODUCT_NANO_SERVER: ULONG = 0x0000006D; +pub const PRODUCT_CLOUD_STORAGE_SERVER: ULONG = 0x0000006E; +pub const PRODUCT_CORE_CONNECTED: ULONG = 0x0000006F; +pub const PRODUCT_PROFESSIONAL_STUDENT: ULONG = 0x00000070; +pub const PRODUCT_CORE_CONNECTED_N: ULONG = 0x00000071; +pub const PRODUCT_PROFESSIONAL_STUDENT_N: ULONG = 0x00000072; +pub const PRODUCT_CORE_CONNECTED_SINGLELANGUAGE: ULONG = 0x00000073; +pub const PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC: ULONG = 0x00000074; +pub const PRODUCT_CONNECTED_CAR: ULONG = 0x00000075; +pub const PRODUCT_INDUSTRY_HANDHELD: ULONG = 0x00000076; +pub const PRODUCT_PPI_PRO: ULONG = 0x00000077; +pub const PRODUCT_ARM64_SERVER: ULONG = 0x00000078; +pub const PRODUCT_EDUCATION: ULONG = 0x00000079; +pub const PRODUCT_EDUCATION_N: ULONG = 0x0000007A; +pub const PRODUCT_IOTUAP: ULONG = 0x0000007B; +pub const PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER: ULONG = 0x0000007C; +pub const PRODUCT_ENTERPRISE_S: ULONG = 0x0000007D; +pub const PRODUCT_ENTERPRISE_S_N: ULONG = 0x0000007E; +pub const PRODUCT_PROFESSIONAL_S: ULONG = 0x0000007F; +pub const PRODUCT_PROFESSIONAL_S_N: ULONG = 0x00000080; +pub const PRODUCT_ENTERPRISE_S_EVALUATION: ULONG = 0x00000081; +pub const PRODUCT_ENTERPRISE_S_N_EVALUATION: ULONG = 0x00000082; +pub const PRODUCT_HOLOGRAPHIC: ULONG = 0x00000087; +pub const PRODUCT_PRO_SINGLE_LANGUAGE: ULONG = 0x0000008A; +pub const PRODUCT_PRO_CHINA: ULONG = 0x0000008B; +pub const PRODUCT_ENTERPRISE_SUBSCRIPTION: ULONG = 0x0000008C; +pub const PRODUCT_ENTERPRISE_SUBSCRIPTION_N: ULONG = 0x0000008D; +pub const PRODUCT_DATACENTER_NANO_SERVER: ULONG = 0x0000008F; +pub const PRODUCT_STANDARD_NANO_SERVER: ULONG = 0x00000090; +pub const PRODUCT_DATACENTER_A_SERVER_CORE: ULONG = 0x00000091; +pub const PRODUCT_STANDARD_A_SERVER_CORE: ULONG = 0x00000092; +pub const PRODUCT_DATACENTER_WS_SERVER_CORE: ULONG = 0x00000093; +pub const PRODUCT_STANDARD_WS_SERVER_CORE: ULONG = 0x00000094; +pub const PRODUCT_UTILITY_VM: ULONG = 0x00000095; +pub const PRODUCT_DATACENTER_EVALUATION_SERVER_CORE: ULONG = 0x0000009F; +pub const PRODUCT_STANDARD_EVALUATION_SERVER_CORE: ULONG = 0x000000A0; +pub const PRODUCT_PRO_WORKSTATION: ULONG = 0x000000A1; +pub const PRODUCT_PRO_WORKSTATION_N: ULONG = 0x000000A2; +pub const PRODUCT_PRO_FOR_EDUCATION: ULONG = 0x000000A4; +pub const PRODUCT_PRO_FOR_EDUCATION_N: ULONG = 0x000000A5; +pub const PRODUCT_AZURE_SERVER_CORE: ULONG = 0x000000A8; +pub const PRODUCT_AZURE_NANO_SERVER: ULONG = 0x000000A9; +pub const PRODUCT_UNLICENSED: ULONG = 0xABCDABCD; +pub const LANG_NEUTRAL: USHORT = 0x00; +pub const LANG_INVARIANT: USHORT = 0x7f; +pub const LANG_AFRIKAANS: USHORT = 0x36; +pub const LANG_ALBANIAN: USHORT = 0x1c; +pub const LANG_ALSATIAN: USHORT = 0x84; +pub const LANG_AMHARIC: USHORT = 0x5e; +pub const LANG_ARABIC: USHORT = 0x01; +pub const LANG_ARMENIAN: USHORT = 0x2b; +pub const LANG_ASSAMESE: USHORT = 0x4d; +pub const LANG_AZERI: USHORT = 0x2c; +pub const LANG_AZERBAIJANI: USHORT = 0x2c; +pub const LANG_BANGLA: USHORT = 0x45; +pub const LANG_BASHKIR: USHORT = 0x6d; +pub const LANG_BASQUE: USHORT = 0x2d; +pub const LANG_BELARUSIAN: USHORT = 0x23; +pub const LANG_BENGALI: USHORT = 0x45; +pub const LANG_BRETON: USHORT = 0x7e; +pub const LANG_BOSNIAN: USHORT = 0x1a; +pub const LANG_BOSNIAN_NEUTRAL: USHORT = 0x781a; +pub const LANG_BULGARIAN: USHORT = 0x02; +pub const LANG_CATALAN: USHORT = 0x03; +pub const LANG_CENTRAL_KURDISH: USHORT = 0x92; +pub const LANG_CHEROKEE: USHORT = 0x5c; +pub const LANG_CHINESE: USHORT = 0x04; +pub const LANG_CHINESE_SIMPLIFIED: USHORT = 0x04; +pub const LANG_CHINESE_TRADITIONAL: USHORT = 0x7c04; +pub const LANG_CORSICAN: USHORT = 0x83; +pub const LANG_CROATIAN: USHORT = 0x1a; +pub const LANG_CZECH: USHORT = 0x05; +pub const LANG_DANISH: USHORT = 0x06; +pub const LANG_DARI: USHORT = 0x8c; +pub const LANG_DIVEHI: USHORT = 0x65; +pub const LANG_DUTCH: USHORT = 0x13; +pub const LANG_ENGLISH: USHORT = 0x09; +pub const LANG_ESTONIAN: USHORT = 0x25; +pub const LANG_FAEROESE: USHORT = 0x38; +pub const LANG_FARSI: USHORT = 0x29; +pub const LANG_FILIPINO: USHORT = 0x64; +pub const LANG_FINNISH: USHORT = 0x0b; +pub const LANG_FRENCH: USHORT = 0x0c; +pub const LANG_FRISIAN: USHORT = 0x62; +pub const LANG_FULAH: USHORT = 0x67; +pub const LANG_GALICIAN: USHORT = 0x56; +pub const LANG_GEORGIAN: USHORT = 0x37; +pub const LANG_GERMAN: USHORT = 0x07; +pub const LANG_GREEK: USHORT = 0x08; +pub const LANG_GREENLANDIC: USHORT = 0x6f; +pub const LANG_GUJARATI: USHORT = 0x47; +pub const LANG_HAUSA: USHORT = 0x68; +pub const LANG_HAWAIIAN: USHORT = 0x75; +pub const LANG_HEBREW: USHORT = 0x0d; +pub const LANG_HINDI: USHORT = 0x39; +pub const LANG_HUNGARIAN: USHORT = 0x0e; +pub const LANG_ICELANDIC: USHORT = 0x0f; +pub const LANG_IGBO: USHORT = 0x70; +pub const LANG_INDONESIAN: USHORT = 0x21; +pub const LANG_INUKTITUT: USHORT = 0x5d; +pub const LANG_IRISH: USHORT = 0x3c; +pub const LANG_ITALIAN: USHORT = 0x10; +pub const LANG_JAPANESE: USHORT = 0x11; +pub const LANG_KANNADA: USHORT = 0x4b; +pub const LANG_KASHMIRI: USHORT = 0x60; +pub const LANG_KAZAK: USHORT = 0x3f; +pub const LANG_KHMER: USHORT = 0x53; +pub const LANG_KICHE: USHORT = 0x86; +pub const LANG_KINYARWANDA: USHORT = 0x87; +pub const LANG_KONKANI: USHORT = 0x57; +pub const LANG_KOREAN: USHORT = 0x12; +pub const LANG_KYRGYZ: USHORT = 0x40; +pub const LANG_LAO: USHORT = 0x54; +pub const LANG_LATVIAN: USHORT = 0x26; +pub const LANG_LITHUANIAN: USHORT = 0x27; +pub const LANG_LOWER_SORBIAN: USHORT = 0x2e; +pub const LANG_LUXEMBOURGISH: USHORT = 0x6e; +pub const LANG_MACEDONIAN: USHORT = 0x2f; +pub const LANG_MALAY: USHORT = 0x3e; +pub const LANG_MALAYALAM: USHORT = 0x4c; +pub const LANG_MALTESE: USHORT = 0x3a; +pub const LANG_MANIPURI: USHORT = 0x58; +pub const LANG_MAORI: USHORT = 0x81; +pub const LANG_MAPUDUNGUN: USHORT = 0x7a; +pub const LANG_MARATHI: USHORT = 0x4e; +pub const LANG_MOHAWK: USHORT = 0x7c; +pub const LANG_MONGOLIAN: USHORT = 0x50; +pub const LANG_NEPALI: USHORT = 0x61; +pub const LANG_NORWEGIAN: USHORT = 0x14; +pub const LANG_OCCITAN: USHORT = 0x82; +pub const LANG_ODIA: USHORT = 0x48; +pub const LANG_ORIYA: USHORT = 0x48; +pub const LANG_PASHTO: USHORT = 0x63; +pub const LANG_PERSIAN: USHORT = 0x29; +pub const LANG_POLISH: USHORT = 0x15; +pub const LANG_PORTUGUESE: USHORT = 0x16; +pub const LANG_PULAR: USHORT = 0x67; +pub const LANG_PUNJABI: USHORT = 0x46; +pub const LANG_QUECHUA: USHORT = 0x6b; +pub const LANG_ROMANIAN: USHORT = 0x18; +pub const LANG_ROMANSH: USHORT = 0x17; +pub const LANG_RUSSIAN: USHORT = 0x19; +pub const LANG_SAKHA: USHORT = 0x85; +pub const LANG_SAMI: USHORT = 0x3b; +pub const LANG_SANSKRIT: USHORT = 0x4f; +pub const LANG_SCOTTISH_GAELIC: USHORT = 0x91; +pub const LANG_SERBIAN: USHORT = 0x1a; +pub const LANG_SERBIAN_NEUTRAL: USHORT = 0x7c1a; +pub const LANG_SINDHI: USHORT = 0x59; +pub const LANG_SINHALESE: USHORT = 0x5b; +pub const LANG_SLOVAK: USHORT = 0x1b; +pub const LANG_SLOVENIAN: USHORT = 0x24; +pub const LANG_SOTHO: USHORT = 0x6c; +pub const LANG_SPANISH: USHORT = 0x0a; +pub const LANG_SWAHILI: USHORT = 0x41; +pub const LANG_SWEDISH: USHORT = 0x1d; +pub const LANG_SYRIAC: USHORT = 0x5a; +pub const LANG_TAJIK: USHORT = 0x28; +pub const LANG_TAMAZIGHT: USHORT = 0x5f; +pub const LANG_TAMIL: USHORT = 0x49; +pub const LANG_TATAR: USHORT = 0x44; +pub const LANG_TELUGU: USHORT = 0x4a; +pub const LANG_THAI: USHORT = 0x1e; +pub const LANG_TIBETAN: USHORT = 0x51; +pub const LANG_TIGRIGNA: USHORT = 0x73; +pub const LANG_TIGRINYA: USHORT = 0x73; +pub const LANG_TSWANA: USHORT = 0x32; +pub const LANG_TURKISH: USHORT = 0x1f; +pub const LANG_TURKMEN: USHORT = 0x42; +pub const LANG_UIGHUR: USHORT = 0x80; +pub const LANG_UKRAINIAN: USHORT = 0x22; +pub const LANG_UPPER_SORBIAN: USHORT = 0x2e; +pub const LANG_URDU: USHORT = 0x20; +pub const LANG_UZBEK: USHORT = 0x43; +pub const LANG_VALENCIAN: USHORT = 0x03; +pub const LANG_VIETNAMESE: USHORT = 0x2a; +pub const LANG_WELSH: USHORT = 0x52; +pub const LANG_WOLOF: USHORT = 0x88; +pub const LANG_XHOSA: USHORT = 0x34; +pub const LANG_YAKUT: USHORT = 0x85; +pub const LANG_YI: USHORT = 0x78; +pub const LANG_YORUBA: USHORT = 0x6a; +pub const LANG_ZULU: USHORT = 0x35; +pub const SUBLANG_NEUTRAL: USHORT = 0x00; +pub const SUBLANG_DEFAULT: USHORT = 0x01; +pub const SUBLANG_SYS_DEFAULT: USHORT = 0x02; +pub const SUBLANG_CUSTOM_DEFAULT: USHORT = 0x03; +pub const SUBLANG_CUSTOM_UNSPECIFIED: USHORT = 0x04; +pub const SUBLANG_UI_CUSTOM_DEFAULT: USHORT = 0x05; +pub const SUBLANG_AFRIKAANS_SOUTH_AFRICA: USHORT = 0x01; +pub const SUBLANG_ALBANIAN_ALBANIA: USHORT = 0x01; +pub const SUBLANG_ALSATIAN_FRANCE: USHORT = 0x01; +pub const SUBLANG_AMHARIC_ETHIOPIA: USHORT = 0x01; +pub const SUBLANG_ARABIC_SAUDI_ARABIA: USHORT = 0x01; +pub const SUBLANG_ARABIC_IRAQ: USHORT = 0x02; +pub const SUBLANG_ARABIC_EGYPT: USHORT = 0x03; +pub const SUBLANG_ARABIC_LIBYA: USHORT = 0x04; +pub const SUBLANG_ARABIC_ALGERIA: USHORT = 0x05; +pub const SUBLANG_ARABIC_MOROCCO: USHORT = 0x06; +pub const SUBLANG_ARABIC_TUNISIA: USHORT = 0x07; +pub const SUBLANG_ARABIC_OMAN: USHORT = 0x08; +pub const SUBLANG_ARABIC_YEMEN: USHORT = 0x09; +pub const SUBLANG_ARABIC_SYRIA: USHORT = 0x0a; +pub const SUBLANG_ARABIC_JORDAN: USHORT = 0x0b; +pub const SUBLANG_ARABIC_LEBANON: USHORT = 0x0c; +pub const SUBLANG_ARABIC_KUWAIT: USHORT = 0x0d; +pub const SUBLANG_ARABIC_UAE: USHORT = 0x0e; +pub const SUBLANG_ARABIC_BAHRAIN: USHORT = 0x0f; +pub const SUBLANG_ARABIC_QATAR: USHORT = 0x10; +pub const SUBLANG_ARMENIAN_ARMENIA: USHORT = 0x01; +pub const SUBLANG_ASSAMESE_INDIA: USHORT = 0x01; +pub const SUBLANG_AZERI_LATIN: USHORT = 0x01; +pub const SUBLANG_AZERI_CYRILLIC: USHORT = 0x02; +pub const SUBLANG_AZERBAIJANI_AZERBAIJAN_LATIN: USHORT = 0x01; +pub const SUBLANG_AZERBAIJANI_AZERBAIJAN_CYRILLIC: USHORT = 0x02; +pub const SUBLANG_BANGLA_INDIA: USHORT = 0x01; +pub const SUBLANG_BANGLA_BANGLADESH: USHORT = 0x02; +pub const SUBLANG_BASHKIR_RUSSIA: USHORT = 0x01; +pub const SUBLANG_BASQUE_BASQUE: USHORT = 0x01; +pub const SUBLANG_BELARUSIAN_BELARUS: USHORT = 0x01; +pub const SUBLANG_BENGALI_INDIA: USHORT = 0x01; +pub const SUBLANG_BENGALI_BANGLADESH: USHORT = 0x02; +pub const SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN: USHORT = 0x05; +pub const SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC: USHORT = 0x08; +pub const SUBLANG_BRETON_FRANCE: USHORT = 0x01; +pub const SUBLANG_BULGARIAN_BULGARIA: USHORT = 0x01; +pub const SUBLANG_CATALAN_CATALAN: USHORT = 0x01; +pub const SUBLANG_CENTRAL_KURDISH_IRAQ: USHORT = 0x01; +pub const SUBLANG_CHEROKEE_CHEROKEE: USHORT = 0x01; +pub const SUBLANG_CHINESE_TRADITIONAL: USHORT = 0x01; +pub const SUBLANG_CHINESE_SIMPLIFIED: USHORT = 0x02; +pub const SUBLANG_CHINESE_HONGKONG: USHORT = 0x03; +pub const SUBLANG_CHINESE_SINGAPORE: USHORT = 0x04; +pub const SUBLANG_CHINESE_MACAU: USHORT = 0x05; +pub const SUBLANG_CORSICAN_FRANCE: USHORT = 0x01; +pub const SUBLANG_CZECH_CZECH_REPUBLIC: USHORT = 0x01; +pub const SUBLANG_CROATIAN_CROATIA: USHORT = 0x01; +pub const SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN: USHORT = 0x04; +pub const SUBLANG_DANISH_DENMARK: USHORT = 0x01; +pub const SUBLANG_DARI_AFGHANISTAN: USHORT = 0x01; +pub const SUBLANG_DIVEHI_MALDIVES: USHORT = 0x01; +pub const SUBLANG_DUTCH: USHORT = 0x01; +pub const SUBLANG_DUTCH_BELGIAN: USHORT = 0x02; +pub const SUBLANG_ENGLISH_US: USHORT = 0x01; +pub const SUBLANG_ENGLISH_UK: USHORT = 0x02; +pub const SUBLANG_ENGLISH_AUS: USHORT = 0x03; +pub const SUBLANG_ENGLISH_CAN: USHORT = 0x04; +pub const SUBLANG_ENGLISH_NZ: USHORT = 0x05; +pub const SUBLANG_ENGLISH_EIRE: USHORT = 0x06; +pub const SUBLANG_ENGLISH_SOUTH_AFRICA: USHORT = 0x07; +pub const SUBLANG_ENGLISH_JAMAICA: USHORT = 0x08; +pub const SUBLANG_ENGLISH_CARIBBEAN: USHORT = 0x09; +pub const SUBLANG_ENGLISH_BELIZE: USHORT = 0x0a; +pub const SUBLANG_ENGLISH_TRINIDAD: USHORT = 0x0b; +pub const SUBLANG_ENGLISH_ZIMBABWE: USHORT = 0x0c; +pub const SUBLANG_ENGLISH_PHILIPPINES: USHORT = 0x0d; +pub const SUBLANG_ENGLISH_INDIA: USHORT = 0x10; +pub const SUBLANG_ENGLISH_MALAYSIA: USHORT = 0x11; +pub const SUBLANG_ENGLISH_SINGAPORE: USHORT = 0x12; +pub const SUBLANG_ESTONIAN_ESTONIA: USHORT = 0x01; +pub const SUBLANG_FAEROESE_FAROE_ISLANDS: USHORT = 0x01; +pub const SUBLANG_FILIPINO_PHILIPPINES: USHORT = 0x01; +pub const SUBLANG_FINNISH_FINLAND: USHORT = 0x01; +pub const SUBLANG_FRENCH: USHORT = 0x01; +pub const SUBLANG_FRENCH_BELGIAN: USHORT = 0x02; +pub const SUBLANG_FRENCH_CANADIAN: USHORT = 0x03; +pub const SUBLANG_FRENCH_SWISS: USHORT = 0x04; +pub const SUBLANG_FRENCH_LUXEMBOURG: USHORT = 0x05; +pub const SUBLANG_FRENCH_MONACO: USHORT = 0x06; +pub const SUBLANG_FRISIAN_NETHERLANDS: USHORT = 0x01; +pub const SUBLANG_FULAH_SENEGAL: USHORT = 0x02; +pub const SUBLANG_GALICIAN_GALICIAN: USHORT = 0x01; +pub const SUBLANG_GEORGIAN_GEORGIA: USHORT = 0x01; +pub const SUBLANG_GERMAN: USHORT = 0x01; +pub const SUBLANG_GERMAN_SWISS: USHORT = 0x02; +pub const SUBLANG_GERMAN_AUSTRIAN: USHORT = 0x03; +pub const SUBLANG_GERMAN_LUXEMBOURG: USHORT = 0x04; +pub const SUBLANG_GERMAN_LIECHTENSTEIN: USHORT = 0x05; +pub const SUBLANG_GREEK_GREECE: USHORT = 0x01; +pub const SUBLANG_GREENLANDIC_GREENLAND: USHORT = 0x01; +pub const SUBLANG_GUJARATI_INDIA: USHORT = 0x01; +pub const SUBLANG_HAUSA_NIGERIA_LATIN: USHORT = 0x01; +pub const SUBLANG_HAWAIIAN_US: USHORT = 0x01; +pub const SUBLANG_HEBREW_ISRAEL: USHORT = 0x01; +pub const SUBLANG_HINDI_INDIA: USHORT = 0x01; +pub const SUBLANG_HUNGARIAN_HUNGARY: USHORT = 0x01; +pub const SUBLANG_ICELANDIC_ICELAND: USHORT = 0x01; +pub const SUBLANG_IGBO_NIGERIA: USHORT = 0x01; +pub const SUBLANG_INDONESIAN_INDONESIA: USHORT = 0x01; +pub const SUBLANG_INUKTITUT_CANADA: USHORT = 0x01; +pub const SUBLANG_INUKTITUT_CANADA_LATIN: USHORT = 0x02; +pub const SUBLANG_IRISH_IRELAND: USHORT = 0x02; +pub const SUBLANG_ITALIAN: USHORT = 0x01; +pub const SUBLANG_ITALIAN_SWISS: USHORT = 0x02; +pub const SUBLANG_JAPANESE_JAPAN: USHORT = 0x01; +pub const SUBLANG_KANNADA_INDIA: USHORT = 0x01; +pub const SUBLANG_KASHMIRI_SASIA: USHORT = 0x02; +pub const SUBLANG_KASHMIRI_INDIA: USHORT = 0x02; +pub const SUBLANG_KAZAK_KAZAKHSTAN: USHORT = 0x01; +pub const SUBLANG_KHMER_CAMBODIA: USHORT = 0x01; +pub const SUBLANG_KICHE_GUATEMALA: USHORT = 0x01; +pub const SUBLANG_KINYARWANDA_RWANDA: USHORT = 0x01; +pub const SUBLANG_KONKANI_INDIA: USHORT = 0x01; +pub const SUBLANG_KOREAN: USHORT = 0x01; +pub const SUBLANG_KYRGYZ_KYRGYZSTAN: USHORT = 0x01; +pub const SUBLANG_LAO_LAO: USHORT = 0x01; +pub const SUBLANG_LATVIAN_LATVIA: USHORT = 0x01; +pub const SUBLANG_LITHUANIAN: USHORT = 0x01; +pub const SUBLANG_LOWER_SORBIAN_GERMANY: USHORT = 0x02; +pub const SUBLANG_LUXEMBOURGISH_LUXEMBOURG: USHORT = 0x01; +pub const SUBLANG_MACEDONIAN_MACEDONIA: USHORT = 0x01; +pub const SUBLANG_MALAY_MALAYSIA: USHORT = 0x01; +pub const SUBLANG_MALAY_BRUNEI_DARUSSALAM: USHORT = 0x02; +pub const SUBLANG_MALAYALAM_INDIA: USHORT = 0x01; +pub const SUBLANG_MALTESE_MALTA: USHORT = 0x01; +pub const SUBLANG_MAORI_NEW_ZEALAND: USHORT = 0x01; +pub const SUBLANG_MAPUDUNGUN_CHILE: USHORT = 0x01; +pub const SUBLANG_MARATHI_INDIA: USHORT = 0x01; +pub const SUBLANG_MOHAWK_MOHAWK: USHORT = 0x01; +pub const SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA: USHORT = 0x01; +pub const SUBLANG_MONGOLIAN_PRC: USHORT = 0x02; +pub const SUBLANG_NEPALI_INDIA: USHORT = 0x02; +pub const SUBLANG_NEPALI_NEPAL: USHORT = 0x01; +pub const SUBLANG_NORWEGIAN_BOKMAL: USHORT = 0x01; +pub const SUBLANG_NORWEGIAN_NYNORSK: USHORT = 0x02; +pub const SUBLANG_OCCITAN_FRANCE: USHORT = 0x01; +pub const SUBLANG_ODIA_INDIA: USHORT = 0x01; +pub const SUBLANG_ORIYA_INDIA: USHORT = 0x01; +pub const SUBLANG_PASHTO_AFGHANISTAN: USHORT = 0x01; +pub const SUBLANG_PERSIAN_IRAN: USHORT = 0x01; +pub const SUBLANG_POLISH_POLAND: USHORT = 0x01; +pub const SUBLANG_PORTUGUESE: USHORT = 0x02; +pub const SUBLANG_PORTUGUESE_BRAZILIAN: USHORT = 0x01; +pub const SUBLANG_PULAR_SENEGAL: USHORT = 0x02; +pub const SUBLANG_PUNJABI_INDIA: USHORT = 0x01; +pub const SUBLANG_PUNJABI_PAKISTAN: USHORT = 0x02; +pub const SUBLANG_QUECHUA_BOLIVIA: USHORT = 0x01; +pub const SUBLANG_QUECHUA_ECUADOR: USHORT = 0x02; +pub const SUBLANG_QUECHUA_PERU: USHORT = 0x03; +pub const SUBLANG_ROMANIAN_ROMANIA: USHORT = 0x01; +pub const SUBLANG_ROMANSH_SWITZERLAND: USHORT = 0x01; +pub const SUBLANG_RUSSIAN_RUSSIA: USHORT = 0x01; +pub const SUBLANG_SAKHA_RUSSIA: USHORT = 0x01; +pub const SUBLANG_SAMI_NORTHERN_NORWAY: USHORT = 0x01; +pub const SUBLANG_SAMI_NORTHERN_SWEDEN: USHORT = 0x02; +pub const SUBLANG_SAMI_NORTHERN_FINLAND: USHORT = 0x03; +pub const SUBLANG_SAMI_LULE_NORWAY: USHORT = 0x04; +pub const SUBLANG_SAMI_LULE_SWEDEN: USHORT = 0x05; +pub const SUBLANG_SAMI_SOUTHERN_NORWAY: USHORT = 0x06; +pub const SUBLANG_SAMI_SOUTHERN_SWEDEN: USHORT = 0x07; +pub const SUBLANG_SAMI_SKOLT_FINLAND: USHORT = 0x08; +pub const SUBLANG_SAMI_INARI_FINLAND: USHORT = 0x09; +pub const SUBLANG_SANSKRIT_INDIA: USHORT = 0x01; +pub const SUBLANG_SCOTTISH_GAELIC: USHORT = 0x01; +pub const SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN: USHORT = 0x06; +pub const SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC: USHORT = 0x07; +pub const SUBLANG_SERBIAN_MONTENEGRO_LATIN: USHORT = 0x0b; +pub const SUBLANG_SERBIAN_MONTENEGRO_CYRILLIC: USHORT = 0x0c; +pub const SUBLANG_SERBIAN_SERBIA_LATIN: USHORT = 0x09; +pub const SUBLANG_SERBIAN_SERBIA_CYRILLIC: USHORT = 0x0a; +pub const SUBLANG_SERBIAN_CROATIA: USHORT = 0x01; +pub const SUBLANG_SERBIAN_LATIN: USHORT = 0x02; +pub const SUBLANG_SERBIAN_CYRILLIC: USHORT = 0x03; +pub const SUBLANG_SINDHI_INDIA: USHORT = 0x01; +pub const SUBLANG_SINDHI_PAKISTAN: USHORT = 0x02; +pub const SUBLANG_SINDHI_AFGHANISTAN: USHORT = 0x02; +pub const SUBLANG_SINHALESE_SRI_LANKA: USHORT = 0x01; +pub const SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA: USHORT = 0x01; +pub const SUBLANG_SLOVAK_SLOVAKIA: USHORT = 0x01; +pub const SUBLANG_SLOVENIAN_SLOVENIA: USHORT = 0x01; +pub const SUBLANG_SPANISH: USHORT = 0x01; +pub const SUBLANG_SPANISH_MEXICAN: USHORT = 0x02; +pub const SUBLANG_SPANISH_MODERN: USHORT = 0x03; +pub const SUBLANG_SPANISH_GUATEMALA: USHORT = 0x04; +pub const SUBLANG_SPANISH_COSTA_RICA: USHORT = 0x05; +pub const SUBLANG_SPANISH_PANAMA: USHORT = 0x06; +pub const SUBLANG_SPANISH_DOMINICAN_REPUBLIC: USHORT = 0x07; +pub const SUBLANG_SPANISH_VENEZUELA: USHORT = 0x08; +pub const SUBLANG_SPANISH_COLOMBIA: USHORT = 0x09; +pub const SUBLANG_SPANISH_PERU: USHORT = 0x0a; +pub const SUBLANG_SPANISH_ARGENTINA: USHORT = 0x0b; +pub const SUBLANG_SPANISH_ECUADOR: USHORT = 0x0c; +pub const SUBLANG_SPANISH_CHILE: USHORT = 0x0d; +pub const SUBLANG_SPANISH_URUGUAY: USHORT = 0x0e; +pub const SUBLANG_SPANISH_PARAGUAY: USHORT = 0x0f; +pub const SUBLANG_SPANISH_BOLIVIA: USHORT = 0x10; +pub const SUBLANG_SPANISH_EL_SALVADOR: USHORT = 0x11; +pub const SUBLANG_SPANISH_HONDURAS: USHORT = 0x12; +pub const SUBLANG_SPANISH_NICARAGUA: USHORT = 0x13; +pub const SUBLANG_SPANISH_PUERTO_RICO: USHORT = 0x14; +pub const SUBLANG_SPANISH_US: USHORT = 0x15; +pub const SUBLANG_SWAHILI_KENYA: USHORT = 0x01; +pub const SUBLANG_SWEDISH: USHORT = 0x01; +pub const SUBLANG_SWEDISH_FINLAND: USHORT = 0x02; +pub const SUBLANG_SYRIAC_SYRIA: USHORT = 0x01; +pub const SUBLANG_TAJIK_TAJIKISTAN: USHORT = 0x01; +pub const SUBLANG_TAMAZIGHT_ALGERIA_LATIN: USHORT = 0x02; +pub const SUBLANG_TAMAZIGHT_MOROCCO_TIFINAGH: USHORT = 0x04; +pub const SUBLANG_TAMIL_INDIA: USHORT = 0x01; +pub const SUBLANG_TAMIL_SRI_LANKA: USHORT = 0x02; +pub const SUBLANG_TATAR_RUSSIA: USHORT = 0x01; +pub const SUBLANG_TELUGU_INDIA: USHORT = 0x01; +pub const SUBLANG_THAI_THAILAND: USHORT = 0x01; +pub const SUBLANG_TIBETAN_PRC: USHORT = 0x01; +pub const SUBLANG_TIGRIGNA_ERITREA: USHORT = 0x02; +pub const SUBLANG_TIGRINYA_ERITREA: USHORT = 0x02; +pub const SUBLANG_TIGRINYA_ETHIOPIA: USHORT = 0x01; +pub const SUBLANG_TSWANA_BOTSWANA: USHORT = 0x02; +pub const SUBLANG_TSWANA_SOUTH_AFRICA: USHORT = 0x01; +pub const SUBLANG_TURKISH_TURKEY: USHORT = 0x01; +pub const SUBLANG_TURKMEN_TURKMENISTAN: USHORT = 0x01; +pub const SUBLANG_UIGHUR_PRC: USHORT = 0x01; +pub const SUBLANG_UKRAINIAN_UKRAINE: USHORT = 0x01; +pub const SUBLANG_UPPER_SORBIAN_GERMANY: USHORT = 0x01; +pub const SUBLANG_URDU_PAKISTAN: USHORT = 0x01; +pub const SUBLANG_URDU_INDIA: USHORT = 0x02; +pub const SUBLANG_UZBEK_LATIN: USHORT = 0x01; +pub const SUBLANG_UZBEK_CYRILLIC: USHORT = 0x02; +pub const SUBLANG_VALENCIAN_VALENCIA: USHORT = 0x02; +pub const SUBLANG_VIETNAMESE_VIETNAM: USHORT = 0x01; +pub const SUBLANG_WELSH_UNITED_KINGDOM: USHORT = 0x01; +pub const SUBLANG_WOLOF_SENEGAL: USHORT = 0x01; +pub const SUBLANG_XHOSA_SOUTH_AFRICA: USHORT = 0x01; +pub const SUBLANG_YAKUT_RUSSIA: USHORT = 0x01; +pub const SUBLANG_YI_PRC: USHORT = 0x01; +pub const SUBLANG_YORUBA_NIGERIA: USHORT = 0x01; +pub const SUBLANG_ZULU_SOUTH_AFRICA: USHORT = 0x01; +pub const SORT_DEFAULT: USHORT = 0x0; +pub const SORT_INVARIANT_MATH: USHORT = 0x1; +pub const SORT_JAPANESE_XJIS: USHORT = 0x0; +pub const SORT_JAPANESE_UNICODE: USHORT = 0x1; +pub const SORT_JAPANESE_RADICALSTROKE: USHORT = 0x4; +pub const SORT_CHINESE_BIG5: USHORT = 0x0; +pub const SORT_CHINESE_PRCP: USHORT = 0x0; +pub const SORT_CHINESE_UNICODE: USHORT = 0x1; +pub const SORT_CHINESE_PRC: USHORT = 0x2; +pub const SORT_CHINESE_BOPOMOFO: USHORT = 0x3; +pub const SORT_CHINESE_RADICALSTROKE: USHORT = 0x4; +pub const SORT_KOREAN_KSC: USHORT = 0x0; +pub const SORT_KOREAN_UNICODE: USHORT = 0x1; +pub const SORT_GERMAN_PHONE_BOOK: USHORT = 0x1; +pub const SORT_HUNGARIAN_DEFAULT: USHORT = 0x0; +pub const SORT_HUNGARIAN_TECHNICAL: USHORT = 0x1; +pub const SORT_GEORGIAN_TRADITIONAL: USHORT = 0x0; +pub const SORT_GEORGIAN_MODERN: USHORT = 0x1; +macro_rules! MAKELANGID { + ($p:expr, $s:expr) => { + (($s as USHORT) << 10) | ($p as USHORT) + } +} +#[inline] +pub fn MAKELANGID(p: USHORT, s: USHORT) -> LANGID { (s << 10) | p } +#[inline] +pub fn PRIMARYLANGID(lgid: LANGID) -> USHORT { lgid & 0x3ff } +#[inline] +pub fn SUBLANGID(lgid: LANGID) -> USHORT { lgid >> 10 } +pub const NLS_VALID_LOCALE_MASK: ULONG = 0x000fffff; +macro_rules! MAKELCID { + ($lgid:expr, $srtid:expr) => { + (($srtid as ULONG) << 16) | ($lgid as ULONG) + } +} +#[inline] +pub fn MAKELCID(lgid: LANGID, srtid: USHORT) -> LCID { + ((srtid as ULONG) << 16) | (lgid as ULONG) +} +#[inline] +pub fn MAKESORTLCID(lgid: LANGID, srtid: USHORT, ver: USHORT) -> LCID { + MAKELCID(lgid, srtid) | ((ver as ULONG) << 20) +} +#[inline] +pub fn LANGIDFROMLCID(lcid: LCID) -> LANGID { lcid as LANGID } +#[inline] +pub fn SORTIDFROMLCID(lcid: LCID) -> USHORT { ((lcid >> 16) & 0xf) as USHORT } +#[inline] +pub fn SORTVERSIONFROMLCID(lcid: LCID) -> USHORT { ((lcid >> 16) & 0xf) as USHORT } +pub const LOCALE_NAME_MAX_LENGTH: usize = 85; +pub const LANG_SYSTEM_DEFAULT: LANGID = MAKELANGID!(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT); +pub const LANG_USER_DEFAULT: LANGID = MAKELANGID!(LANG_NEUTRAL, SUBLANG_DEFAULT); +pub const LOCALE_SYSTEM_DEFAULT: LCID = MAKELCID!(LANG_SYSTEM_DEFAULT, SORT_DEFAULT); +pub const LOCALE_USER_DEFAULT: LCID = MAKELCID!(LANG_USER_DEFAULT, SORT_DEFAULT); +pub const LOCALE_CUSTOM_DEFAULT: LCID + = MAKELCID!(MAKELANGID!(LANG_NEUTRAL, SUBLANG_CUSTOM_DEFAULT), SORT_DEFAULT); +pub const LOCALE_CUSTOM_UNSPECIFIED: LCID + = MAKELCID!(MAKELANGID!(LANG_NEUTRAL, SUBLANG_CUSTOM_UNSPECIFIED), SORT_DEFAULT); +pub const LOCALE_CUSTOM_UI_DEFAULT: LCID + = MAKELCID!(MAKELANGID!(LANG_NEUTRAL, SUBLANG_UI_CUSTOM_DEFAULT), SORT_DEFAULT); +pub const LOCALE_NEUTRAL: LCID + = MAKELCID!(MAKELANGID!(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT); +pub const LOCALE_INVARIANT: LCID + = MAKELCID!(MAKELANGID!(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT); +pub const LOCALE_TRANSIENT_KEYBOARD1: LCID = 0x2000; +pub const LOCALE_TRANSIENT_KEYBOARD2: LCID = 0x2400; +pub const LOCALE_TRANSIENT_KEYBOARD3: LCID = 0x2800; +pub const LOCALE_TRANSIENT_KEYBOARD4: LCID = 0x2c00; +pub const LOCALE_UNASSIGNED_LCID: LCID = LOCALE_CUSTOM_UNSPECIFIED; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntstatus.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntstatus.rs new file mode 100644 index 0000000..c369c22 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ntstatus.rs @@ -0,0 +1,2574 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Constant definitions for the NTSTATUS values. +use shared::ntdef::NTSTATUS; +pub const STATUS_WAIT_0: NTSTATUS = 0x00000000; +pub const FACILITY_VSM: NTSTATUS = 0x45; +pub const FACILITY_VOLSNAP: NTSTATUS = 0x50; +pub const FACILITY_VOLMGR: NTSTATUS = 0x38; +pub const FACILITY_VIRTUALIZATION: NTSTATUS = 0x37; +pub const FACILITY_VIDEO: NTSTATUS = 0x1B; +pub const FACILITY_USB_ERROR_CODE: NTSTATUS = 0x10; +pub const FACILITY_TRANSACTION: NTSTATUS = 0x19; +pub const FACILITY_TPM: NTSTATUS = 0x29; +pub const FACILITY_TERMINAL_SERVER: NTSTATUS = 0xA; +pub const FACILITY_SXS_ERROR_CODE: NTSTATUS = 0x15; +pub const FACILITY_NTSSPI: NTSTATUS = 0x9; +pub const FACILITY_SPACES: NTSTATUS = 0xE7; +pub const FACILITY_SMB: NTSTATUS = 0x5D; +pub const FACILITY_SYSTEM_INTEGRITY: NTSTATUS = 0xE9; +pub const FACILITY_SHARED_VHDX: NTSTATUS = 0x5C; +pub const FACILITY_SECUREBOOT: NTSTATUS = 0x43; +pub const FACILITY_SECURITY_CORE: NTSTATUS = 0xE8; +pub const FACILITY_SDBUS: NTSTATUS = 0x51; +pub const FACILITY_RTPM: NTSTATUS = 0x2A; +pub const FACILITY_RPC_STUBS: NTSTATUS = 0x3; +pub const FACILITY_RPC_RUNTIME: NTSTATUS = 0x2; +pub const FACILITY_RESUME_KEY_FILTER: NTSTATUS = 0x40; +pub const FACILITY_RDBSS: NTSTATUS = 0x41; +pub const FACILITY_PLATFORM_MANIFEST: NTSTATUS = 0xEB; +pub const FACILITY_NTWIN32: NTSTATUS = 0x7; +pub const FACILITY_WIN32K_NTUSER: NTSTATUS = 0x3E; +pub const FACILITY_WIN32K_NTGDI: NTSTATUS = 0x3F; +pub const FACILITY_NDIS_ERROR_CODE: NTSTATUS = 0x23; +pub const FACILTIY_MUI_ERROR_CODE: NTSTATUS = 0xB; +pub const FACILITY_MONITOR: NTSTATUS = 0x1D; +pub const FACILITY_MAXIMUM_VALUE: NTSTATUS = 0xEC; +pub const FACILITY_LICENSING: NTSTATUS = 0xEA; +pub const FACILITY_IPSEC: NTSTATUS = 0x36; +pub const FACILITY_IO_ERROR_CODE: NTSTATUS = 0x4; +pub const FACILITY_INTERIX: NTSTATUS = 0x99; +pub const FACILITY_HYPERVISOR: NTSTATUS = 0x35; +pub const FACILITY_HID_ERROR_CODE: NTSTATUS = 0x11; +pub const FACILITY_GRAPHICS_KERNEL: NTSTATUS = 0x1E; +pub const FACILITY_FWP_ERROR_CODE: NTSTATUS = 0x22; +pub const FACILITY_FVE_ERROR_CODE: NTSTATUS = 0x21; +pub const FACILITY_FIREWIRE_ERROR_CODE: NTSTATUS = 0x12; +pub const FACILITY_FILTER_MANAGER: NTSTATUS = 0x1C; +pub const FACILITY_DRIVER_FRAMEWORK: NTSTATUS = 0x20; +pub const FACILITY_DEBUGGER: NTSTATUS = 0x1; +pub const FACILITY_COMMONLOG: NTSTATUS = 0x1A; +pub const FACILITY_CODCLASS_ERROR_CODE: NTSTATUS = 0x6; +pub const FACILITY_CLUSTER_ERROR_CODE: NTSTATUS = 0x13; +pub const FACILITY_NTCERT: NTSTATUS = 0x8; +pub const FACILITY_BTH_ATT: NTSTATUS = 0x42; +pub const FACILITY_BCD_ERROR_CODE: NTSTATUS = 0x39; +pub const FACILITY_AUDIO_KERNEL: NTSTATUS = 0x44; +pub const FACILITY_ACPI_ERROR_CODE: NTSTATUS = 0x14; +pub const STATUS_SEVERITY_WARNING: NTSTATUS = 0x2; +pub const STATUS_SEVERITY_SUCCESS: NTSTATUS = 0x0; +pub const STATUS_SEVERITY_INFORMATIONAL: NTSTATUS = 0x1; +pub const STATUS_SEVERITY_ERROR: NTSTATUS = 0x3; +pub const STATUS_SUCCESS: NTSTATUS = 0x00000000; +pub const STATUS_WAIT_1: NTSTATUS = 0x00000001; +pub const STATUS_WAIT_2: NTSTATUS = 0x00000002; +pub const STATUS_WAIT_3: NTSTATUS = 0x00000003; +pub const STATUS_WAIT_63: NTSTATUS = 0x0000003F; +pub const STATUS_ABANDONED: NTSTATUS = 0x00000080; +pub const STATUS_ABANDONED_WAIT_0: NTSTATUS = 0x00000080; +pub const STATUS_ABANDONED_WAIT_63: NTSTATUS = 0x000000BF; +pub const STATUS_USER_APC: NTSTATUS = 0x000000C0; +pub const STATUS_ALREADY_COMPLETE: NTSTATUS = 0x000000FF; +pub const STATUS_KERNEL_APC: NTSTATUS = 0x00000100; +pub const STATUS_ALERTED: NTSTATUS = 0x00000101; +pub const STATUS_TIMEOUT: NTSTATUS = 0x00000102; +pub const STATUS_PENDING: NTSTATUS = 0x00000103; +pub const STATUS_REPARSE: NTSTATUS = 0x00000104; +pub const STATUS_MORE_ENTRIES: NTSTATUS = 0x00000105; +pub const STATUS_NOT_ALL_ASSIGNED: NTSTATUS = 0x00000106; +pub const STATUS_SOME_NOT_MAPPED: NTSTATUS = 0x00000107; +pub const STATUS_OPLOCK_BREAK_IN_PROGRESS: NTSTATUS = 0x00000108; +pub const STATUS_VOLUME_MOUNTED: NTSTATUS = 0x00000109; +pub const STATUS_RXACT_COMMITTED: NTSTATUS = 0x0000010A; +pub const STATUS_NOTIFY_CLEANUP: NTSTATUS = 0x0000010B; +pub const STATUS_NOTIFY_ENUM_DIR: NTSTATUS = 0x0000010C; +pub const STATUS_NO_QUOTAS_FOR_ACCOUNT: NTSTATUS = 0x0000010D; +pub const STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED: NTSTATUS = 0x0000010E; +pub const STATUS_PAGE_FAULT_TRANSITION: NTSTATUS = 0x00000110; +pub const STATUS_PAGE_FAULT_DEMAND_ZERO: NTSTATUS = 0x00000111; +pub const STATUS_PAGE_FAULT_COPY_ON_WRITE: NTSTATUS = 0x00000112; +pub const STATUS_PAGE_FAULT_GUARD_PAGE: NTSTATUS = 0x00000113; +pub const STATUS_PAGE_FAULT_PAGING_FILE: NTSTATUS = 0x00000114; +pub const STATUS_CACHE_PAGE_LOCKED: NTSTATUS = 0x00000115; +pub const STATUS_CRASH_DUMP: NTSTATUS = 0x00000116; +pub const STATUS_BUFFER_ALL_ZEROS: NTSTATUS = 0x00000117; +pub const STATUS_REPARSE_OBJECT: NTSTATUS = 0x00000118; +pub const STATUS_RESOURCE_REQUIREMENTS_CHANGED: NTSTATUS = 0x00000119; +pub const STATUS_TRANSLATION_COMPLETE: NTSTATUS = 0x00000120; +pub const STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY: NTSTATUS = 0x00000121; +pub const STATUS_NOTHING_TO_TERMINATE: NTSTATUS = 0x00000122; +pub const STATUS_PROCESS_NOT_IN_JOB: NTSTATUS = 0x00000123; +pub const STATUS_PROCESS_IN_JOB: NTSTATUS = 0x00000124; +pub const STATUS_VOLSNAP_HIBERNATE_READY: NTSTATUS = 0x00000125; +pub const STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY: NTSTATUS = 0x00000126; +pub const STATUS_INTERRUPT_VECTOR_ALREADY_CONNECTED: NTSTATUS = 0x00000127; +pub const STATUS_INTERRUPT_STILL_CONNECTED: NTSTATUS = 0x00000128; +pub const STATUS_PROCESS_CLONED: NTSTATUS = 0x00000129; +pub const STATUS_FILE_LOCKED_WITH_ONLY_READERS: NTSTATUS = 0x0000012A; +pub const STATUS_FILE_LOCKED_WITH_WRITERS: NTSTATUS = 0x0000012B; +pub const STATUS_VALID_IMAGE_HASH: NTSTATUS = 0x0000012C; +pub const STATUS_VALID_CATALOG_HASH: NTSTATUS = 0x0000012D; +pub const STATUS_VALID_STRONG_CODE_HASH: NTSTATUS = 0x0000012E; +pub const STATUS_GHOSTED: NTSTATUS = 0x0000012F; +pub const STATUS_RESOURCEMANAGER_READ_ONLY: NTSTATUS = 0x00000202; +pub const STATUS_RING_PREVIOUSLY_EMPTY: NTSTATUS = 0x00000210; +pub const STATUS_RING_PREVIOUSLY_FULL: NTSTATUS = 0x00000211; +pub const STATUS_RING_PREVIOUSLY_ABOVE_QUOTA: NTSTATUS = 0x00000212; +pub const STATUS_RING_NEWLY_EMPTY: NTSTATUS = 0x00000213; +pub const STATUS_RING_SIGNAL_OPPOSITE_ENDPOINT: NTSTATUS = 0x00000214; +pub const STATUS_OPLOCK_SWITCHED_TO_NEW_HANDLE: NTSTATUS = 0x00000215; +pub const STATUS_OPLOCK_HANDLE_CLOSED: NTSTATUS = 0x00000216; +pub const STATUS_WAIT_FOR_OPLOCK: NTSTATUS = 0x00000367; +pub const STATUS_REPARSE_GLOBAL: NTSTATUS = 0x00000368; +pub const DBG_EXCEPTION_HANDLED: NTSTATUS = 0x00010001; +pub const DBG_CONTINUE: NTSTATUS = 0x00010002; +pub const STATUS_FLT_IO_COMPLETE: NTSTATUS = 0x001C0001; +pub const STATUS_OBJECT_NAME_EXISTS: NTSTATUS = 0x40000000; +pub const STATUS_THREAD_WAS_SUSPENDED: NTSTATUS = 0x40000001; +pub const STATUS_WORKING_SET_LIMIT_RANGE: NTSTATUS = 0x40000002; +pub const STATUS_IMAGE_NOT_AT_BASE: NTSTATUS = 0x40000003; +pub const STATUS_RXACT_STATE_CREATED: NTSTATUS = 0x40000004; +pub const STATUS_SEGMENT_NOTIFICATION: NTSTATUS = 0x40000005; +pub const STATUS_LOCAL_USER_SESSION_KEY: NTSTATUS = 0x40000006; +pub const STATUS_BAD_CURRENT_DIRECTORY: NTSTATUS = 0x40000007; +pub const STATUS_SERIAL_MORE_WRITES: NTSTATUS = 0x40000008; +pub const STATUS_REGISTRY_RECOVERED: NTSTATUS = 0x40000009; +pub const STATUS_FT_READ_RECOVERY_FROM_BACKUP: NTSTATUS = 0x4000000A; +pub const STATUS_FT_WRITE_RECOVERY: NTSTATUS = 0x4000000B; +pub const STATUS_SERIAL_COUNTER_TIMEOUT: NTSTATUS = 0x4000000C; +pub const STATUS_NULL_LM_PASSWORD: NTSTATUS = 0x4000000D; +pub const STATUS_IMAGE_MACHINE_TYPE_MISMATCH: NTSTATUS = 0x4000000E; +pub const STATUS_RECEIVE_PARTIAL: NTSTATUS = 0x4000000F; +pub const STATUS_RECEIVE_EXPEDITED: NTSTATUS = 0x40000010; +pub const STATUS_RECEIVE_PARTIAL_EXPEDITED: NTSTATUS = 0x40000011; +pub const STATUS_EVENT_DONE: NTSTATUS = 0x40000012; +pub const STATUS_EVENT_PENDING: NTSTATUS = 0x40000013; +pub const STATUS_CHECKING_FILE_SYSTEM: NTSTATUS = 0x40000014; +pub const STATUS_FATAL_APP_EXIT: NTSTATUS = 0x40000015; +pub const STATUS_PREDEFINED_HANDLE: NTSTATUS = 0x40000016; +pub const STATUS_WAS_UNLOCKED: NTSTATUS = 0x40000017; +pub const STATUS_SERVICE_NOTIFICATION: NTSTATUS = 0x40000018; +pub const STATUS_WAS_LOCKED: NTSTATUS = 0x40000019; +pub const STATUS_LOG_HARD_ERROR: NTSTATUS = 0x4000001A; +pub const STATUS_ALREADY_WIN32: NTSTATUS = 0x4000001B; +pub const STATUS_WX86_UNSIMULATE: NTSTATUS = 0x4000001C; +pub const STATUS_WX86_CONTINUE: NTSTATUS = 0x4000001D; +pub const STATUS_WX86_SINGLE_STEP: NTSTATUS = 0x4000001E; +pub const STATUS_WX86_BREAKPOINT: NTSTATUS = 0x4000001F; +pub const STATUS_WX86_EXCEPTION_CONTINUE: NTSTATUS = 0x40000020; +pub const STATUS_WX86_EXCEPTION_LASTCHANCE: NTSTATUS = 0x40000021; +pub const STATUS_WX86_EXCEPTION_CHAIN: NTSTATUS = 0x40000022; +pub const STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE: NTSTATUS = 0x40000023; +pub const STATUS_NO_YIELD_PERFORMED: NTSTATUS = 0x40000024; +pub const STATUS_TIMER_RESUME_IGNORED: NTSTATUS = 0x40000025; +pub const STATUS_ARBITRATION_UNHANDLED: NTSTATUS = 0x40000026; +pub const STATUS_CARDBUS_NOT_SUPPORTED: NTSTATUS = 0x40000027; +pub const STATUS_WX86_CREATEWX86TIB: NTSTATUS = 0x40000028; +pub const STATUS_MP_PROCESSOR_MISMATCH: NTSTATUS = 0x40000029; +pub const STATUS_HIBERNATED: NTSTATUS = 0x4000002A; +pub const STATUS_RESUME_HIBERNATION: NTSTATUS = 0x4000002B; +pub const STATUS_FIRMWARE_UPDATED: NTSTATUS = 0x4000002C; +pub const STATUS_DRIVERS_LEAKING_LOCKED_PAGES: NTSTATUS = 0x4000002D; +pub const STATUS_MESSAGE_RETRIEVED: NTSTATUS = 0x4000002E; +pub const STATUS_SYSTEM_POWERSTATE_TRANSITION: NTSTATUS = 0x4000002F; +pub const STATUS_ALPC_CHECK_COMPLETION_LIST: NTSTATUS = 0x40000030; +pub const STATUS_SYSTEM_POWERSTATE_COMPLEX_TRANSITION: NTSTATUS = 0x40000031; +pub const STATUS_ACCESS_AUDIT_BY_POLICY: NTSTATUS = 0x40000032; +pub const STATUS_ABANDON_HIBERFILE: NTSTATUS = 0x40000033; +pub const STATUS_BIZRULES_NOT_ENABLED: NTSTATUS = 0x40000034; +pub const STATUS_FT_READ_FROM_COPY: NTSTATUS = 0x40000035; +pub const STATUS_IMAGE_AT_DIFFERENT_BASE: NTSTATUS = 0x40000036; +pub const DBG_REPLY_LATER: NTSTATUS = 0x40010001; +pub const DBG_UNABLE_TO_PROVIDE_HANDLE: NTSTATUS = 0x40010002; +pub const DBG_TERMINATE_THREAD: NTSTATUS = 0x40010003; +pub const DBG_TERMINATE_PROCESS: NTSTATUS = 0x40010004; +pub const DBG_CONTROL_C: NTSTATUS = 0x40010005; +pub const DBG_PRINTEXCEPTION_C: NTSTATUS = 0x40010006; +pub const DBG_RIPEXCEPTION: NTSTATUS = 0x40010007; +pub const DBG_CONTROL_BREAK: NTSTATUS = 0x40010008; +pub const DBG_COMMAND_EXCEPTION: NTSTATUS = 0x40010009; +pub const DBG_PRINTEXCEPTION_WIDE_C: NTSTATUS = 0x4001000A; +pub const STATUS_HEURISTIC_DAMAGE_POSSIBLE: NTSTATUS = 0x40190001; +pub const STATUS_GUARD_PAGE_VIOLATION: NTSTATUS = 0x80000001; +pub const STATUS_DATATYPE_MISALIGNMENT: NTSTATUS = 0x80000002; +pub const STATUS_BREAKPOINT: NTSTATUS = 0x80000003; +pub const STATUS_SINGLE_STEP: NTSTATUS = 0x80000004; +pub const STATUS_BUFFER_OVERFLOW: NTSTATUS = 0x80000005; +pub const STATUS_NO_MORE_FILES: NTSTATUS = 0x80000006; +pub const STATUS_WAKE_SYSTEM_DEBUGGER: NTSTATUS = 0x80000007; +pub const STATUS_HANDLES_CLOSED: NTSTATUS = 0x8000000A; +pub const STATUS_NO_INHERITANCE: NTSTATUS = 0x8000000B; +pub const STATUS_GUID_SUBSTITUTION_MADE: NTSTATUS = 0x8000000C; +pub const STATUS_PARTIAL_COPY: NTSTATUS = 0x8000000D; +pub const STATUS_DEVICE_PAPER_EMPTY: NTSTATUS = 0x8000000E; +pub const STATUS_DEVICE_POWERED_OFF: NTSTATUS = 0x8000000F; +pub const STATUS_DEVICE_OFF_LINE: NTSTATUS = 0x80000010; +pub const STATUS_DEVICE_BUSY: NTSTATUS = 0x80000011; +pub const STATUS_NO_MORE_EAS: NTSTATUS = 0x80000012; +pub const STATUS_INVALID_EA_NAME: NTSTATUS = 0x80000013; +pub const STATUS_EA_LIST_INCONSISTENT: NTSTATUS = 0x80000014; +pub const STATUS_INVALID_EA_FLAG: NTSTATUS = 0x80000015; +pub const STATUS_VERIFY_REQUIRED: NTSTATUS = 0x80000016; +pub const STATUS_EXTRANEOUS_INFORMATION: NTSTATUS = 0x80000017; +pub const STATUS_RXACT_COMMIT_NECESSARY: NTSTATUS = 0x80000018; +pub const STATUS_NO_MORE_ENTRIES: NTSTATUS = 0x8000001A; +pub const STATUS_FILEMARK_DETECTED: NTSTATUS = 0x8000001B; +pub const STATUS_MEDIA_CHANGED: NTSTATUS = 0x8000001C; +pub const STATUS_BUS_RESET: NTSTATUS = 0x8000001D; +pub const STATUS_END_OF_MEDIA: NTSTATUS = 0x8000001E; +pub const STATUS_BEGINNING_OF_MEDIA: NTSTATUS = 0x8000001F; +pub const STATUS_MEDIA_CHECK: NTSTATUS = 0x80000020; +pub const STATUS_SETMARK_DETECTED: NTSTATUS = 0x80000021; +pub const STATUS_NO_DATA_DETECTED: NTSTATUS = 0x80000022; +pub const STATUS_REDIRECTOR_HAS_OPEN_HANDLES: NTSTATUS = 0x80000023; +pub const STATUS_SERVER_HAS_OPEN_HANDLES: NTSTATUS = 0x80000024; +pub const STATUS_ALREADY_DISCONNECTED: NTSTATUS = 0x80000025; +pub const STATUS_LONGJUMP: NTSTATUS = 0x80000026; +pub const STATUS_CLEANER_CARTRIDGE_INSTALLED: NTSTATUS = 0x80000027; +pub const STATUS_PLUGPLAY_QUERY_VETOED: NTSTATUS = 0x80000028; +pub const STATUS_UNWIND_CONSOLIDATE: NTSTATUS = 0x80000029; +pub const STATUS_REGISTRY_HIVE_RECOVERED: NTSTATUS = 0x8000002A; +pub const STATUS_DLL_MIGHT_BE_INSECURE: NTSTATUS = 0x8000002B; +pub const STATUS_DLL_MIGHT_BE_INCOMPATIBLE: NTSTATUS = 0x8000002C; +pub const STATUS_STOPPED_ON_SYMLINK: NTSTATUS = 0x8000002D; +pub const STATUS_CANNOT_GRANT_REQUESTED_OPLOCK: NTSTATUS = 0x8000002E; +pub const STATUS_NO_ACE_CONDITION: NTSTATUS = 0x8000002F; +pub const STATUS_DEVICE_SUPPORT_IN_PROGRESS: NTSTATUS = 0x80000030; +pub const STATUS_DEVICE_POWER_CYCLE_REQUIRED: NTSTATUS = 0x80000031; +pub const STATUS_NO_WORK_DONE: NTSTATUS = 0x80000032; +pub const DBG_EXCEPTION_NOT_HANDLED: NTSTATUS = 0x80010001; +pub const STATUS_CLUSTER_NODE_ALREADY_UP: NTSTATUS = 0x80130001; +pub const STATUS_CLUSTER_NODE_ALREADY_DOWN: NTSTATUS = 0x80130002; +pub const STATUS_CLUSTER_NETWORK_ALREADY_ONLINE: NTSTATUS = 0x80130003; +pub const STATUS_CLUSTER_NETWORK_ALREADY_OFFLINE: NTSTATUS = 0x80130004; +pub const STATUS_CLUSTER_NODE_ALREADY_MEMBER: NTSTATUS = 0x80130005; +pub const STATUS_FLT_BUFFER_TOO_SMALL: NTSTATUS = 0x801C0001; +pub const STATUS_FVE_PARTIAL_METADATA: NTSTATUS = 0x80210001; +pub const STATUS_FVE_TRANSIENT_STATE: NTSTATUS = 0x80210002; +pub const STATUS_CLOUD_FILE_PROPERTY_BLOB_CHECKSUM_MISMATCH: NTSTATUS = 0x8000CF00; +pub const STATUS_UNSUCCESSFUL: NTSTATUS = 0xC0000001; +pub const STATUS_NOT_IMPLEMENTED: NTSTATUS = 0xC0000002; +pub const STATUS_INVALID_INFO_CLASS: NTSTATUS = 0xC0000003; +pub const STATUS_INFO_LENGTH_MISMATCH: NTSTATUS = 0xC0000004; +pub const STATUS_ACCESS_VIOLATION: NTSTATUS = 0xC0000005; +pub const STATUS_IN_PAGE_ERROR: NTSTATUS = 0xC0000006; +pub const STATUS_PAGEFILE_QUOTA: NTSTATUS = 0xC0000007; +pub const STATUS_INVALID_HANDLE: NTSTATUS = 0xC0000008; +pub const STATUS_BAD_INITIAL_STACK: NTSTATUS = 0xC0000009; +pub const STATUS_BAD_INITIAL_PC: NTSTATUS = 0xC000000A; +pub const STATUS_INVALID_CID: NTSTATUS = 0xC000000B; +pub const STATUS_TIMER_NOT_CANCELED: NTSTATUS = 0xC000000C; +pub const STATUS_INVALID_PARAMETER: NTSTATUS = 0xC000000D; +pub const STATUS_NO_SUCH_DEVICE: NTSTATUS = 0xC000000E; +pub const STATUS_NO_SUCH_FILE: NTSTATUS = 0xC000000F; +pub const STATUS_INVALID_DEVICE_REQUEST: NTSTATUS = 0xC0000010; +pub const STATUS_END_OF_FILE: NTSTATUS = 0xC0000011; +pub const STATUS_WRONG_VOLUME: NTSTATUS = 0xC0000012; +pub const STATUS_NO_MEDIA_IN_DEVICE: NTSTATUS = 0xC0000013; +pub const STATUS_UNRECOGNIZED_MEDIA: NTSTATUS = 0xC0000014; +pub const STATUS_NONEXISTENT_SECTOR: NTSTATUS = 0xC0000015; +pub const STATUS_MORE_PROCESSING_REQUIRED: NTSTATUS = 0xC0000016; +pub const STATUS_NO_MEMORY: NTSTATUS = 0xC0000017; +pub const STATUS_CONFLICTING_ADDRESSES: NTSTATUS = 0xC0000018; +pub const STATUS_NOT_MAPPED_VIEW: NTSTATUS = 0xC0000019; +pub const STATUS_UNABLE_TO_FREE_VM: NTSTATUS = 0xC000001A; +pub const STATUS_UNABLE_TO_DELETE_SECTION: NTSTATUS = 0xC000001B; +pub const STATUS_INVALID_SYSTEM_SERVICE: NTSTATUS = 0xC000001C; +pub const STATUS_ILLEGAL_INSTRUCTION: NTSTATUS = 0xC000001D; +pub const STATUS_INVALID_LOCK_SEQUENCE: NTSTATUS = 0xC000001E; +pub const STATUS_INVALID_VIEW_SIZE: NTSTATUS = 0xC000001F; +pub const STATUS_INVALID_FILE_FOR_SECTION: NTSTATUS = 0xC0000020; +pub const STATUS_ALREADY_COMMITTED: NTSTATUS = 0xC0000021; +pub const STATUS_ACCESS_DENIED: NTSTATUS = 0xC0000022; +pub const STATUS_BUFFER_TOO_SMALL: NTSTATUS = 0xC0000023; +pub const STATUS_OBJECT_TYPE_MISMATCH: NTSTATUS = 0xC0000024; +pub const STATUS_NONCONTINUABLE_EXCEPTION: NTSTATUS = 0xC0000025; +pub const STATUS_INVALID_DISPOSITION: NTSTATUS = 0xC0000026; +pub const STATUS_UNWIND: NTSTATUS = 0xC0000027; +pub const STATUS_BAD_STACK: NTSTATUS = 0xC0000028; +pub const STATUS_INVALID_UNWIND_TARGET: NTSTATUS = 0xC0000029; +pub const STATUS_NOT_LOCKED: NTSTATUS = 0xC000002A; +pub const STATUS_PARITY_ERROR: NTSTATUS = 0xC000002B; +pub const STATUS_UNABLE_TO_DECOMMIT_VM: NTSTATUS = 0xC000002C; +pub const STATUS_NOT_COMMITTED: NTSTATUS = 0xC000002D; +pub const STATUS_INVALID_PORT_ATTRIBUTES: NTSTATUS = 0xC000002E; +pub const STATUS_PORT_MESSAGE_TOO_LONG: NTSTATUS = 0xC000002F; +pub const STATUS_INVALID_PARAMETER_MIX: NTSTATUS = 0xC0000030; +pub const STATUS_INVALID_QUOTA_LOWER: NTSTATUS = 0xC0000031; +pub const STATUS_DISK_CORRUPT_ERROR: NTSTATUS = 0xC0000032; +pub const STATUS_OBJECT_NAME_INVALID: NTSTATUS = 0xC0000033; +pub const STATUS_OBJECT_NAME_NOT_FOUND: NTSTATUS = 0xC0000034; +pub const STATUS_OBJECT_NAME_COLLISION: NTSTATUS = 0xC0000035; +pub const STATUS_PORT_DO_NOT_DISTURB: NTSTATUS = 0xC0000036; +pub const STATUS_PORT_DISCONNECTED: NTSTATUS = 0xC0000037; +pub const STATUS_DEVICE_ALREADY_ATTACHED: NTSTATUS = 0xC0000038; +pub const STATUS_OBJECT_PATH_INVALID: NTSTATUS = 0xC0000039; +pub const STATUS_OBJECT_PATH_NOT_FOUND: NTSTATUS = 0xC000003A; +pub const STATUS_OBJECT_PATH_SYNTAX_BAD: NTSTATUS = 0xC000003B; +pub const STATUS_DATA_OVERRUN: NTSTATUS = 0xC000003C; +pub const STATUS_DATA_LATE_ERROR: NTSTATUS = 0xC000003D; +pub const STATUS_DATA_ERROR: NTSTATUS = 0xC000003E; +pub const STATUS_CRC_ERROR: NTSTATUS = 0xC000003F; +pub const STATUS_SECTION_TOO_BIG: NTSTATUS = 0xC0000040; +pub const STATUS_PORT_CONNECTION_REFUSED: NTSTATUS = 0xC0000041; +pub const STATUS_INVALID_PORT_HANDLE: NTSTATUS = 0xC0000042; +pub const STATUS_SHARING_VIOLATION: NTSTATUS = 0xC0000043; +pub const STATUS_QUOTA_EXCEEDED: NTSTATUS = 0xC0000044; +pub const STATUS_INVALID_PAGE_PROTECTION: NTSTATUS = 0xC0000045; +pub const STATUS_MUTANT_NOT_OWNED: NTSTATUS = 0xC0000046; +pub const STATUS_SEMAPHORE_LIMIT_EXCEEDED: NTSTATUS = 0xC0000047; +pub const STATUS_PORT_ALREADY_SET: NTSTATUS = 0xC0000048; +pub const STATUS_SECTION_NOT_IMAGE: NTSTATUS = 0xC0000049; +pub const STATUS_SUSPEND_COUNT_EXCEEDED: NTSTATUS = 0xC000004A; +pub const STATUS_THREAD_IS_TERMINATING: NTSTATUS = 0xC000004B; +pub const STATUS_BAD_WORKING_SET_LIMIT: NTSTATUS = 0xC000004C; +pub const STATUS_INCOMPATIBLE_FILE_MAP: NTSTATUS = 0xC000004D; +pub const STATUS_SECTION_PROTECTION: NTSTATUS = 0xC000004E; +pub const STATUS_EAS_NOT_SUPPORTED: NTSTATUS = 0xC000004F; +pub const STATUS_EA_TOO_LARGE: NTSTATUS = 0xC0000050; +pub const STATUS_NONEXISTENT_EA_ENTRY: NTSTATUS = 0xC0000051; +pub const STATUS_NO_EAS_ON_FILE: NTSTATUS = 0xC0000052; +pub const STATUS_EA_CORRUPT_ERROR: NTSTATUS = 0xC0000053; +pub const STATUS_FILE_LOCK_CONFLICT: NTSTATUS = 0xC0000054; +pub const STATUS_LOCK_NOT_GRANTED: NTSTATUS = 0xC0000055; +pub const STATUS_DELETE_PENDING: NTSTATUS = 0xC0000056; +pub const STATUS_CTL_FILE_NOT_SUPPORTED: NTSTATUS = 0xC0000057; +pub const STATUS_UNKNOWN_REVISION: NTSTATUS = 0xC0000058; +pub const STATUS_REVISION_MISMATCH: NTSTATUS = 0xC0000059; +pub const STATUS_INVALID_OWNER: NTSTATUS = 0xC000005A; +pub const STATUS_INVALID_PRIMARY_GROUP: NTSTATUS = 0xC000005B; +pub const STATUS_NO_IMPERSONATION_TOKEN: NTSTATUS = 0xC000005C; +pub const STATUS_CANT_DISABLE_MANDATORY: NTSTATUS = 0xC000005D; +pub const STATUS_NO_LOGON_SERVERS: NTSTATUS = 0xC000005E; +pub const STATUS_NO_SUCH_LOGON_SESSION: NTSTATUS = 0xC000005F; +pub const STATUS_NO_SUCH_PRIVILEGE: NTSTATUS = 0xC0000060; +pub const STATUS_PRIVILEGE_NOT_HELD: NTSTATUS = 0xC0000061; +pub const STATUS_INVALID_ACCOUNT_NAME: NTSTATUS = 0xC0000062; +pub const STATUS_USER_EXISTS: NTSTATUS = 0xC0000063; +pub const STATUS_NO_SUCH_USER: NTSTATUS = 0xC0000064; +pub const STATUS_GROUP_EXISTS: NTSTATUS = 0xC0000065; +pub const STATUS_NO_SUCH_GROUP: NTSTATUS = 0xC0000066; +pub const STATUS_MEMBER_IN_GROUP: NTSTATUS = 0xC0000067; +pub const STATUS_MEMBER_NOT_IN_GROUP: NTSTATUS = 0xC0000068; +pub const STATUS_LAST_ADMIN: NTSTATUS = 0xC0000069; +pub const STATUS_WRONG_PASSWORD: NTSTATUS = 0xC000006A; +pub const STATUS_ILL_FORMED_PASSWORD: NTSTATUS = 0xC000006B; +pub const STATUS_PASSWORD_RESTRICTION: NTSTATUS = 0xC000006C; +pub const STATUS_LOGON_FAILURE: NTSTATUS = 0xC000006D; +pub const STATUS_ACCOUNT_RESTRICTION: NTSTATUS = 0xC000006E; +pub const STATUS_INVALID_LOGON_HOURS: NTSTATUS = 0xC000006F; +pub const STATUS_INVALID_WORKSTATION: NTSTATUS = 0xC0000070; +pub const STATUS_PASSWORD_EXPIRED: NTSTATUS = 0xC0000071; +pub const STATUS_ACCOUNT_DISABLED: NTSTATUS = 0xC0000072; +pub const STATUS_NONE_MAPPED: NTSTATUS = 0xC0000073; +pub const STATUS_TOO_MANY_LUIDS_REQUESTED: NTSTATUS = 0xC0000074; +pub const STATUS_LUIDS_EXHAUSTED: NTSTATUS = 0xC0000075; +pub const STATUS_INVALID_SUB_AUTHORITY: NTSTATUS = 0xC0000076; +pub const STATUS_INVALID_ACL: NTSTATUS = 0xC0000077; +pub const STATUS_INVALID_SID: NTSTATUS = 0xC0000078; +pub const STATUS_INVALID_SECURITY_DESCR: NTSTATUS = 0xC0000079; +pub const STATUS_PROCEDURE_NOT_FOUND: NTSTATUS = 0xC000007A; +pub const STATUS_INVALID_IMAGE_FORMAT: NTSTATUS = 0xC000007B; +pub const STATUS_NO_TOKEN: NTSTATUS = 0xC000007C; +pub const STATUS_BAD_INHERITANCE_ACL: NTSTATUS = 0xC000007D; +pub const STATUS_RANGE_NOT_LOCKED: NTSTATUS = 0xC000007E; +pub const STATUS_DISK_FULL: NTSTATUS = 0xC000007F; +pub const STATUS_SERVER_DISABLED: NTSTATUS = 0xC0000080; +pub const STATUS_SERVER_NOT_DISABLED: NTSTATUS = 0xC0000081; +pub const STATUS_TOO_MANY_GUIDS_REQUESTED: NTSTATUS = 0xC0000082; +pub const STATUS_GUIDS_EXHAUSTED: NTSTATUS = 0xC0000083; +pub const STATUS_INVALID_ID_AUTHORITY: NTSTATUS = 0xC0000084; +pub const STATUS_AGENTS_EXHAUSTED: NTSTATUS = 0xC0000085; +pub const STATUS_INVALID_VOLUME_LABEL: NTSTATUS = 0xC0000086; +pub const STATUS_SECTION_NOT_EXTENDED: NTSTATUS = 0xC0000087; +pub const STATUS_NOT_MAPPED_DATA: NTSTATUS = 0xC0000088; +pub const STATUS_RESOURCE_DATA_NOT_FOUND: NTSTATUS = 0xC0000089; +pub const STATUS_RESOURCE_TYPE_NOT_FOUND: NTSTATUS = 0xC000008A; +pub const STATUS_RESOURCE_NAME_NOT_FOUND: NTSTATUS = 0xC000008B; +pub const STATUS_ARRAY_BOUNDS_EXCEEDED: NTSTATUS = 0xC000008C; +pub const STATUS_FLOAT_DENORMAL_OPERAND: NTSTATUS = 0xC000008D; +pub const STATUS_FLOAT_DIVIDE_BY_ZERO: NTSTATUS = 0xC000008E; +pub const STATUS_FLOAT_INEXACT_RESULT: NTSTATUS = 0xC000008F; +pub const STATUS_FLOAT_INVALID_OPERATION: NTSTATUS = 0xC0000090; +pub const STATUS_FLOAT_OVERFLOW: NTSTATUS = 0xC0000091; +pub const STATUS_FLOAT_STACK_CHECK: NTSTATUS = 0xC0000092; +pub const STATUS_FLOAT_UNDERFLOW: NTSTATUS = 0xC0000093; +pub const STATUS_INTEGER_DIVIDE_BY_ZERO: NTSTATUS = 0xC0000094; +pub const STATUS_INTEGER_OVERFLOW: NTSTATUS = 0xC0000095; +pub const STATUS_PRIVILEGED_INSTRUCTION: NTSTATUS = 0xC0000096; +pub const STATUS_TOO_MANY_PAGING_FILES: NTSTATUS = 0xC0000097; +pub const STATUS_FILE_INVALID: NTSTATUS = 0xC0000098; +pub const STATUS_ALLOTTED_SPACE_EXCEEDED: NTSTATUS = 0xC0000099; +pub const STATUS_INSUFFICIENT_RESOURCES: NTSTATUS = 0xC000009A; +pub const STATUS_DFS_EXIT_PATH_FOUND: NTSTATUS = 0xC000009B; +pub const STATUS_DEVICE_DATA_ERROR: NTSTATUS = 0xC000009C; +pub const STATUS_DEVICE_NOT_CONNECTED: NTSTATUS = 0xC000009D; +pub const STATUS_DEVICE_POWER_FAILURE: NTSTATUS = 0xC000009E; +pub const STATUS_FREE_VM_NOT_AT_BASE: NTSTATUS = 0xC000009F; +pub const STATUS_MEMORY_NOT_ALLOCATED: NTSTATUS = 0xC00000A0; +pub const STATUS_WORKING_SET_QUOTA: NTSTATUS = 0xC00000A1; +pub const STATUS_MEDIA_WRITE_PROTECTED: NTSTATUS = 0xC00000A2; +pub const STATUS_DEVICE_NOT_READY: NTSTATUS = 0xC00000A3; +pub const STATUS_INVALID_GROUP_ATTRIBUTES: NTSTATUS = 0xC00000A4; +pub const STATUS_BAD_IMPERSONATION_LEVEL: NTSTATUS = 0xC00000A5; +pub const STATUS_CANT_OPEN_ANONYMOUS: NTSTATUS = 0xC00000A6; +pub const STATUS_BAD_VALIDATION_CLASS: NTSTATUS = 0xC00000A7; +pub const STATUS_BAD_TOKEN_TYPE: NTSTATUS = 0xC00000A8; +pub const STATUS_BAD_MASTER_BOOT_RECORD: NTSTATUS = 0xC00000A9; +pub const STATUS_INSTRUCTION_MISALIGNMENT: NTSTATUS = 0xC00000AA; +pub const STATUS_INSTANCE_NOT_AVAILABLE: NTSTATUS = 0xC00000AB; +pub const STATUS_PIPE_NOT_AVAILABLE: NTSTATUS = 0xC00000AC; +pub const STATUS_INVALID_PIPE_STATE: NTSTATUS = 0xC00000AD; +pub const STATUS_PIPE_BUSY: NTSTATUS = 0xC00000AE; +pub const STATUS_ILLEGAL_FUNCTION: NTSTATUS = 0xC00000AF; +pub const STATUS_PIPE_DISCONNECTED: NTSTATUS = 0xC00000B0; +pub const STATUS_PIPE_CLOSING: NTSTATUS = 0xC00000B1; +pub const STATUS_PIPE_CONNECTED: NTSTATUS = 0xC00000B2; +pub const STATUS_PIPE_LISTENING: NTSTATUS = 0xC00000B3; +pub const STATUS_INVALID_READ_MODE: NTSTATUS = 0xC00000B4; +pub const STATUS_IO_TIMEOUT: NTSTATUS = 0xC00000B5; +pub const STATUS_FILE_FORCED_CLOSED: NTSTATUS = 0xC00000B6; +pub const STATUS_PROFILING_NOT_STARTED: NTSTATUS = 0xC00000B7; +pub const STATUS_PROFILING_NOT_STOPPED: NTSTATUS = 0xC00000B8; +pub const STATUS_COULD_NOT_INTERPRET: NTSTATUS = 0xC00000B9; +pub const STATUS_FILE_IS_A_DIRECTORY: NTSTATUS = 0xC00000BA; +pub const STATUS_NOT_SUPPORTED: NTSTATUS = 0xC00000BB; +pub const STATUS_REMOTE_NOT_LISTENING: NTSTATUS = 0xC00000BC; +pub const STATUS_DUPLICATE_NAME: NTSTATUS = 0xC00000BD; +pub const STATUS_BAD_NETWORK_PATH: NTSTATUS = 0xC00000BE; +pub const STATUS_NETWORK_BUSY: NTSTATUS = 0xC00000BF; +pub const STATUS_DEVICE_DOES_NOT_EXIST: NTSTATUS = 0xC00000C0; +pub const STATUS_TOO_MANY_COMMANDS: NTSTATUS = 0xC00000C1; +pub const STATUS_ADAPTER_HARDWARE_ERROR: NTSTATUS = 0xC00000C2; +pub const STATUS_INVALID_NETWORK_RESPONSE: NTSTATUS = 0xC00000C3; +pub const STATUS_UNEXPECTED_NETWORK_ERROR: NTSTATUS = 0xC00000C4; +pub const STATUS_BAD_REMOTE_ADAPTER: NTSTATUS = 0xC00000C5; +pub const STATUS_PRINT_QUEUE_FULL: NTSTATUS = 0xC00000C6; +pub const STATUS_NO_SPOOL_SPACE: NTSTATUS = 0xC00000C7; +pub const STATUS_PRINT_CANCELLED: NTSTATUS = 0xC00000C8; +pub const STATUS_NETWORK_NAME_DELETED: NTSTATUS = 0xC00000C9; +pub const STATUS_NETWORK_ACCESS_DENIED: NTSTATUS = 0xC00000CA; +pub const STATUS_BAD_DEVICE_TYPE: NTSTATUS = 0xC00000CB; +pub const STATUS_BAD_NETWORK_NAME: NTSTATUS = 0xC00000CC; +pub const STATUS_TOO_MANY_NAMES: NTSTATUS = 0xC00000CD; +pub const STATUS_TOO_MANY_SESSIONS: NTSTATUS = 0xC00000CE; +pub const STATUS_SHARING_PAUSED: NTSTATUS = 0xC00000CF; +pub const STATUS_REQUEST_NOT_ACCEPTED: NTSTATUS = 0xC00000D0; +pub const STATUS_REDIRECTOR_PAUSED: NTSTATUS = 0xC00000D1; +pub const STATUS_NET_WRITE_FAULT: NTSTATUS = 0xC00000D2; +pub const STATUS_PROFILING_AT_LIMIT: NTSTATUS = 0xC00000D3; +pub const STATUS_NOT_SAME_DEVICE: NTSTATUS = 0xC00000D4; +pub const STATUS_FILE_RENAMED: NTSTATUS = 0xC00000D5; +pub const STATUS_VIRTUAL_CIRCUIT_CLOSED: NTSTATUS = 0xC00000D6; +pub const STATUS_NO_SECURITY_ON_OBJECT: NTSTATUS = 0xC00000D7; +pub const STATUS_CANT_WAIT: NTSTATUS = 0xC00000D8; +pub const STATUS_PIPE_EMPTY: NTSTATUS = 0xC00000D9; +pub const STATUS_CANT_ACCESS_DOMAIN_INFO: NTSTATUS = 0xC00000DA; +pub const STATUS_CANT_TERMINATE_SELF: NTSTATUS = 0xC00000DB; +pub const STATUS_INVALID_SERVER_STATE: NTSTATUS = 0xC00000DC; +pub const STATUS_INVALID_DOMAIN_STATE: NTSTATUS = 0xC00000DD; +pub const STATUS_INVALID_DOMAIN_ROLE: NTSTATUS = 0xC00000DE; +pub const STATUS_NO_SUCH_DOMAIN: NTSTATUS = 0xC00000DF; +pub const STATUS_DOMAIN_EXISTS: NTSTATUS = 0xC00000E0; +pub const STATUS_DOMAIN_LIMIT_EXCEEDED: NTSTATUS = 0xC00000E1; +pub const STATUS_OPLOCK_NOT_GRANTED: NTSTATUS = 0xC00000E2; +pub const STATUS_INVALID_OPLOCK_PROTOCOL: NTSTATUS = 0xC00000E3; +pub const STATUS_INTERNAL_DB_CORRUPTION: NTSTATUS = 0xC00000E4; +pub const STATUS_INTERNAL_ERROR: NTSTATUS = 0xC00000E5; +pub const STATUS_GENERIC_NOT_MAPPED: NTSTATUS = 0xC00000E6; +pub const STATUS_BAD_DESCRIPTOR_FORMAT: NTSTATUS = 0xC00000E7; +pub const STATUS_INVALID_USER_BUFFER: NTSTATUS = 0xC00000E8; +pub const STATUS_UNEXPECTED_IO_ERROR: NTSTATUS = 0xC00000E9; +pub const STATUS_UNEXPECTED_MM_CREATE_ERR: NTSTATUS = 0xC00000EA; +pub const STATUS_UNEXPECTED_MM_MAP_ERROR: NTSTATUS = 0xC00000EB; +pub const STATUS_UNEXPECTED_MM_EXTEND_ERR: NTSTATUS = 0xC00000EC; +pub const STATUS_NOT_LOGON_PROCESS: NTSTATUS = 0xC00000ED; +pub const STATUS_LOGON_SESSION_EXISTS: NTSTATUS = 0xC00000EE; +pub const STATUS_INVALID_PARAMETER_1: NTSTATUS = 0xC00000EF; +pub const STATUS_INVALID_PARAMETER_2: NTSTATUS = 0xC00000F0; +pub const STATUS_INVALID_PARAMETER_3: NTSTATUS = 0xC00000F1; +pub const STATUS_INVALID_PARAMETER_4: NTSTATUS = 0xC00000F2; +pub const STATUS_INVALID_PARAMETER_5: NTSTATUS = 0xC00000F3; +pub const STATUS_INVALID_PARAMETER_6: NTSTATUS = 0xC00000F4; +pub const STATUS_INVALID_PARAMETER_7: NTSTATUS = 0xC00000F5; +pub const STATUS_INVALID_PARAMETER_8: NTSTATUS = 0xC00000F6; +pub const STATUS_INVALID_PARAMETER_9: NTSTATUS = 0xC00000F7; +pub const STATUS_INVALID_PARAMETER_10: NTSTATUS = 0xC00000F8; +pub const STATUS_INVALID_PARAMETER_11: NTSTATUS = 0xC00000F9; +pub const STATUS_INVALID_PARAMETER_12: NTSTATUS = 0xC00000FA; +pub const STATUS_REDIRECTOR_NOT_STARTED: NTSTATUS = 0xC00000FB; +pub const STATUS_REDIRECTOR_STARTED: NTSTATUS = 0xC00000FC; +pub const STATUS_STACK_OVERFLOW: NTSTATUS = 0xC00000FD; +pub const STATUS_NO_SUCH_PACKAGE: NTSTATUS = 0xC00000FE; +pub const STATUS_BAD_FUNCTION_TABLE: NTSTATUS = 0xC00000FF; +pub const STATUS_VARIABLE_NOT_FOUND: NTSTATUS = 0xC0000100; +pub const STATUS_DIRECTORY_NOT_EMPTY: NTSTATUS = 0xC0000101; +pub const STATUS_FILE_CORRUPT_ERROR: NTSTATUS = 0xC0000102; +pub const STATUS_NOT_A_DIRECTORY: NTSTATUS = 0xC0000103; +pub const STATUS_BAD_LOGON_SESSION_STATE: NTSTATUS = 0xC0000104; +pub const STATUS_LOGON_SESSION_COLLISION: NTSTATUS = 0xC0000105; +pub const STATUS_NAME_TOO_LONG: NTSTATUS = 0xC0000106; +pub const STATUS_FILES_OPEN: NTSTATUS = 0xC0000107; +pub const STATUS_CONNECTION_IN_USE: NTSTATUS = 0xC0000108; +pub const STATUS_MESSAGE_NOT_FOUND: NTSTATUS = 0xC0000109; +pub const STATUS_PROCESS_IS_TERMINATING: NTSTATUS = 0xC000010A; +pub const STATUS_INVALID_LOGON_TYPE: NTSTATUS = 0xC000010B; +pub const STATUS_NO_GUID_TRANSLATION: NTSTATUS = 0xC000010C; +pub const STATUS_CANNOT_IMPERSONATE: NTSTATUS = 0xC000010D; +pub const STATUS_IMAGE_ALREADY_LOADED: NTSTATUS = 0xC000010E; +pub const STATUS_ABIOS_NOT_PRESENT: NTSTATUS = 0xC000010F; +pub const STATUS_ABIOS_LID_NOT_EXIST: NTSTATUS = 0xC0000110; +pub const STATUS_ABIOS_LID_ALREADY_OWNED: NTSTATUS = 0xC0000111; +pub const STATUS_ABIOS_NOT_LID_OWNER: NTSTATUS = 0xC0000112; +pub const STATUS_ABIOS_INVALID_COMMAND: NTSTATUS = 0xC0000113; +pub const STATUS_ABIOS_INVALID_LID: NTSTATUS = 0xC0000114; +pub const STATUS_ABIOS_SELECTOR_NOT_AVAILABLE: NTSTATUS = 0xC0000115; +pub const STATUS_ABIOS_INVALID_SELECTOR: NTSTATUS = 0xC0000116; +pub const STATUS_NO_LDT: NTSTATUS = 0xC0000117; +pub const STATUS_INVALID_LDT_SIZE: NTSTATUS = 0xC0000118; +pub const STATUS_INVALID_LDT_OFFSET: NTSTATUS = 0xC0000119; +pub const STATUS_INVALID_LDT_DESCRIPTOR: NTSTATUS = 0xC000011A; +pub const STATUS_INVALID_IMAGE_NE_FORMAT: NTSTATUS = 0xC000011B; +pub const STATUS_RXACT_INVALID_STATE: NTSTATUS = 0xC000011C; +pub const STATUS_RXACT_COMMIT_FAILURE: NTSTATUS = 0xC000011D; +pub const STATUS_MAPPED_FILE_SIZE_ZERO: NTSTATUS = 0xC000011E; +pub const STATUS_TOO_MANY_OPENED_FILES: NTSTATUS = 0xC000011F; +pub const STATUS_CANCELLED: NTSTATUS = 0xC0000120; +pub const STATUS_CANNOT_DELETE: NTSTATUS = 0xC0000121; +pub const STATUS_INVALID_COMPUTER_NAME: NTSTATUS = 0xC0000122; +pub const STATUS_FILE_DELETED: NTSTATUS = 0xC0000123; +pub const STATUS_SPECIAL_ACCOUNT: NTSTATUS = 0xC0000124; +pub const STATUS_SPECIAL_GROUP: NTSTATUS = 0xC0000125; +pub const STATUS_SPECIAL_USER: NTSTATUS = 0xC0000126; +pub const STATUS_MEMBERS_PRIMARY_GROUP: NTSTATUS = 0xC0000127; +pub const STATUS_FILE_CLOSED: NTSTATUS = 0xC0000128; +pub const STATUS_TOO_MANY_THREADS: NTSTATUS = 0xC0000129; +pub const STATUS_THREAD_NOT_IN_PROCESS: NTSTATUS = 0xC000012A; +pub const STATUS_TOKEN_ALREADY_IN_USE: NTSTATUS = 0xC000012B; +pub const STATUS_PAGEFILE_QUOTA_EXCEEDED: NTSTATUS = 0xC000012C; +pub const STATUS_COMMITMENT_LIMIT: NTSTATUS = 0xC000012D; +pub const STATUS_INVALID_IMAGE_LE_FORMAT: NTSTATUS = 0xC000012E; +pub const STATUS_INVALID_IMAGE_NOT_MZ: NTSTATUS = 0xC000012F; +pub const STATUS_INVALID_IMAGE_PROTECT: NTSTATUS = 0xC0000130; +pub const STATUS_INVALID_IMAGE_WIN_16: NTSTATUS = 0xC0000131; +pub const STATUS_LOGON_SERVER_CONFLICT: NTSTATUS = 0xC0000132; +pub const STATUS_TIME_DIFFERENCE_AT_DC: NTSTATUS = 0xC0000133; +pub const STATUS_SYNCHRONIZATION_REQUIRED: NTSTATUS = 0xC0000134; +pub const STATUS_DLL_NOT_FOUND: NTSTATUS = 0xC0000135; +pub const STATUS_OPEN_FAILED: NTSTATUS = 0xC0000136; +pub const STATUS_IO_PRIVILEGE_FAILED: NTSTATUS = 0xC0000137; +pub const STATUS_ORDINAL_NOT_FOUND: NTSTATUS = 0xC0000138; +pub const STATUS_ENTRYPOINT_NOT_FOUND: NTSTATUS = 0xC0000139; +pub const STATUS_CONTROL_C_EXIT: NTSTATUS = 0xC000013A; +pub const STATUS_LOCAL_DISCONNECT: NTSTATUS = 0xC000013B; +pub const STATUS_REMOTE_DISCONNECT: NTSTATUS = 0xC000013C; +pub const STATUS_REMOTE_RESOURCES: NTSTATUS = 0xC000013D; +pub const STATUS_LINK_FAILED: NTSTATUS = 0xC000013E; +pub const STATUS_LINK_TIMEOUT: NTSTATUS = 0xC000013F; +pub const STATUS_INVALID_CONNECTION: NTSTATUS = 0xC0000140; +pub const STATUS_INVALID_ADDRESS: NTSTATUS = 0xC0000141; +pub const STATUS_DLL_INIT_FAILED: NTSTATUS = 0xC0000142; +pub const STATUS_MISSING_SYSTEMFILE: NTSTATUS = 0xC0000143; +pub const STATUS_UNHANDLED_EXCEPTION: NTSTATUS = 0xC0000144; +pub const STATUS_APP_INIT_FAILURE: NTSTATUS = 0xC0000145; +pub const STATUS_PAGEFILE_CREATE_FAILED: NTSTATUS = 0xC0000146; +pub const STATUS_NO_PAGEFILE: NTSTATUS = 0xC0000147; +pub const STATUS_INVALID_LEVEL: NTSTATUS = 0xC0000148; +pub const STATUS_WRONG_PASSWORD_CORE: NTSTATUS = 0xC0000149; +pub const STATUS_ILLEGAL_FLOAT_CONTEXT: NTSTATUS = 0xC000014A; +pub const STATUS_PIPE_BROKEN: NTSTATUS = 0xC000014B; +pub const STATUS_REGISTRY_CORRUPT: NTSTATUS = 0xC000014C; +pub const STATUS_REGISTRY_IO_FAILED: NTSTATUS = 0xC000014D; +pub const STATUS_NO_EVENT_PAIR: NTSTATUS = 0xC000014E; +pub const STATUS_UNRECOGNIZED_VOLUME: NTSTATUS = 0xC000014F; +pub const STATUS_SERIAL_NO_DEVICE_INITED: NTSTATUS = 0xC0000150; +pub const STATUS_NO_SUCH_ALIAS: NTSTATUS = 0xC0000151; +pub const STATUS_MEMBER_NOT_IN_ALIAS: NTSTATUS = 0xC0000152; +pub const STATUS_MEMBER_IN_ALIAS: NTSTATUS = 0xC0000153; +pub const STATUS_ALIAS_EXISTS: NTSTATUS = 0xC0000154; +pub const STATUS_LOGON_NOT_GRANTED: NTSTATUS = 0xC0000155; +pub const STATUS_TOO_MANY_SECRETS: NTSTATUS = 0xC0000156; +pub const STATUS_SECRET_TOO_LONG: NTSTATUS = 0xC0000157; +pub const STATUS_INTERNAL_DB_ERROR: NTSTATUS = 0xC0000158; +pub const STATUS_FULLSCREEN_MODE: NTSTATUS = 0xC0000159; +pub const STATUS_TOO_MANY_CONTEXT_IDS: NTSTATUS = 0xC000015A; +pub const STATUS_LOGON_TYPE_NOT_GRANTED: NTSTATUS = 0xC000015B; +pub const STATUS_NOT_REGISTRY_FILE: NTSTATUS = 0xC000015C; +pub const STATUS_NT_CROSS_ENCRYPTION_REQUIRED: NTSTATUS = 0xC000015D; +pub const STATUS_DOMAIN_CTRLR_CONFIG_ERROR: NTSTATUS = 0xC000015E; +pub const STATUS_FT_MISSING_MEMBER: NTSTATUS = 0xC000015F; +pub const STATUS_ILL_FORMED_SERVICE_ENTRY: NTSTATUS = 0xC0000160; +pub const STATUS_ILLEGAL_CHARACTER: NTSTATUS = 0xC0000161; +pub const STATUS_UNMAPPABLE_CHARACTER: NTSTATUS = 0xC0000162; +pub const STATUS_UNDEFINED_CHARACTER: NTSTATUS = 0xC0000163; +pub const STATUS_FLOPPY_VOLUME: NTSTATUS = 0xC0000164; +pub const STATUS_FLOPPY_ID_MARK_NOT_FOUND: NTSTATUS = 0xC0000165; +pub const STATUS_FLOPPY_WRONG_CYLINDER: NTSTATUS = 0xC0000166; +pub const STATUS_FLOPPY_UNKNOWN_ERROR: NTSTATUS = 0xC0000167; +pub const STATUS_FLOPPY_BAD_REGISTERS: NTSTATUS = 0xC0000168; +pub const STATUS_DISK_RECALIBRATE_FAILED: NTSTATUS = 0xC0000169; +pub const STATUS_DISK_OPERATION_FAILED: NTSTATUS = 0xC000016A; +pub const STATUS_DISK_RESET_FAILED: NTSTATUS = 0xC000016B; +pub const STATUS_SHARED_IRQ_BUSY: NTSTATUS = 0xC000016C; +pub const STATUS_FT_ORPHANING: NTSTATUS = 0xC000016D; +pub const STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT: NTSTATUS = 0xC000016E; +pub const STATUS_PARTITION_FAILURE: NTSTATUS = 0xC0000172; +pub const STATUS_INVALID_BLOCK_LENGTH: NTSTATUS = 0xC0000173; +pub const STATUS_DEVICE_NOT_PARTITIONED: NTSTATUS = 0xC0000174; +pub const STATUS_UNABLE_TO_LOCK_MEDIA: NTSTATUS = 0xC0000175; +pub const STATUS_UNABLE_TO_UNLOAD_MEDIA: NTSTATUS = 0xC0000176; +pub const STATUS_EOM_OVERFLOW: NTSTATUS = 0xC0000177; +pub const STATUS_NO_MEDIA: NTSTATUS = 0xC0000178; +pub const STATUS_NO_SUCH_MEMBER: NTSTATUS = 0xC000017A; +pub const STATUS_INVALID_MEMBER: NTSTATUS = 0xC000017B; +pub const STATUS_KEY_DELETED: NTSTATUS = 0xC000017C; +pub const STATUS_NO_LOG_SPACE: NTSTATUS = 0xC000017D; +pub const STATUS_TOO_MANY_SIDS: NTSTATUS = 0xC000017E; +pub const STATUS_LM_CROSS_ENCRYPTION_REQUIRED: NTSTATUS = 0xC000017F; +pub const STATUS_KEY_HAS_CHILDREN: NTSTATUS = 0xC0000180; +pub const STATUS_CHILD_MUST_BE_VOLATILE: NTSTATUS = 0xC0000181; +pub const STATUS_DEVICE_CONFIGURATION_ERROR: NTSTATUS = 0xC0000182; +pub const STATUS_DRIVER_INTERNAL_ERROR: NTSTATUS = 0xC0000183; +pub const STATUS_INVALID_DEVICE_STATE: NTSTATUS = 0xC0000184; +pub const STATUS_IO_DEVICE_ERROR: NTSTATUS = 0xC0000185; +pub const STATUS_DEVICE_PROTOCOL_ERROR: NTSTATUS = 0xC0000186; +pub const STATUS_BACKUP_CONTROLLER: NTSTATUS = 0xC0000187; +pub const STATUS_LOG_FILE_FULL: NTSTATUS = 0xC0000188; +pub const STATUS_TOO_LATE: NTSTATUS = 0xC0000189; +pub const STATUS_NO_TRUST_LSA_SECRET: NTSTATUS = 0xC000018A; +pub const STATUS_NO_TRUST_SAM_ACCOUNT: NTSTATUS = 0xC000018B; +pub const STATUS_TRUSTED_DOMAIN_FAILURE: NTSTATUS = 0xC000018C; +pub const STATUS_TRUSTED_RELATIONSHIP_FAILURE: NTSTATUS = 0xC000018D; +pub const STATUS_EVENTLOG_FILE_CORRUPT: NTSTATUS = 0xC000018E; +pub const STATUS_EVENTLOG_CANT_START: NTSTATUS = 0xC000018F; +pub const STATUS_TRUST_FAILURE: NTSTATUS = 0xC0000190; +pub const STATUS_MUTANT_LIMIT_EXCEEDED: NTSTATUS = 0xC0000191; +pub const STATUS_NETLOGON_NOT_STARTED: NTSTATUS = 0xC0000192; +pub const STATUS_ACCOUNT_EXPIRED: NTSTATUS = 0xC0000193; +pub const STATUS_POSSIBLE_DEADLOCK: NTSTATUS = 0xC0000194; +pub const STATUS_NETWORK_CREDENTIAL_CONFLICT: NTSTATUS = 0xC0000195; +pub const STATUS_REMOTE_SESSION_LIMIT: NTSTATUS = 0xC0000196; +pub const STATUS_EVENTLOG_FILE_CHANGED: NTSTATUS = 0xC0000197; +pub const STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT: NTSTATUS = 0xC0000198; +pub const STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT: NTSTATUS = 0xC0000199; +pub const STATUS_NOLOGON_SERVER_TRUST_ACCOUNT: NTSTATUS = 0xC000019A; +pub const STATUS_DOMAIN_TRUST_INCONSISTENT: NTSTATUS = 0xC000019B; +pub const STATUS_FS_DRIVER_REQUIRED: NTSTATUS = 0xC000019C; +pub const STATUS_IMAGE_ALREADY_LOADED_AS_DLL: NTSTATUS = 0xC000019D; +pub const STATUS_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING: NTSTATUS + = 0xC000019E; +pub const STATUS_SHORT_NAMES_NOT_ENABLED_ON_VOLUME: NTSTATUS = 0xC000019F; +pub const STATUS_SECURITY_STREAM_IS_INCONSISTENT: NTSTATUS = 0xC00001A0; +pub const STATUS_INVALID_LOCK_RANGE: NTSTATUS = 0xC00001A1; +pub const STATUS_INVALID_ACE_CONDITION: NTSTATUS = 0xC00001A2; +pub const STATUS_IMAGE_SUBSYSTEM_NOT_PRESENT: NTSTATUS = 0xC00001A3; +pub const STATUS_NOTIFICATION_GUID_ALREADY_DEFINED: NTSTATUS = 0xC00001A4; +pub const STATUS_INVALID_EXCEPTION_HANDLER: NTSTATUS = 0xC00001A5; +pub const STATUS_DUPLICATE_PRIVILEGES: NTSTATUS = 0xC00001A6; +pub const STATUS_NOT_ALLOWED_ON_SYSTEM_FILE: NTSTATUS = 0xC00001A7; +pub const STATUS_REPAIR_NEEDED: NTSTATUS = 0xC00001A8; +pub const STATUS_QUOTA_NOT_ENABLED: NTSTATUS = 0xC00001A9; +pub const STATUS_NO_APPLICATION_PACKAGE: NTSTATUS = 0xC00001AA; +pub const STATUS_FILE_METADATA_OPTIMIZATION_IN_PROGRESS: NTSTATUS = 0xC00001AB; +pub const STATUS_NOT_SAME_OBJECT: NTSTATUS = 0xC00001AC; +pub const STATUS_FATAL_MEMORY_EXHAUSTION: NTSTATUS = 0xC00001AD; +pub const STATUS_ERROR_PROCESS_NOT_IN_JOB: NTSTATUS = 0xC00001AE; +pub const STATUS_CPU_SET_INVALID: NTSTATUS = 0xC00001AF; +pub const STATUS_NETWORK_OPEN_RESTRICTION: NTSTATUS = 0xC0000201; +pub const STATUS_NO_USER_SESSION_KEY: NTSTATUS = 0xC0000202; +pub const STATUS_USER_SESSION_DELETED: NTSTATUS = 0xC0000203; +pub const STATUS_RESOURCE_LANG_NOT_FOUND: NTSTATUS = 0xC0000204; +pub const STATUS_INSUFF_SERVER_RESOURCES: NTSTATUS = 0xC0000205; +pub const STATUS_INVALID_BUFFER_SIZE: NTSTATUS = 0xC0000206; +pub const STATUS_INVALID_ADDRESS_COMPONENT: NTSTATUS = 0xC0000207; +pub const STATUS_INVALID_ADDRESS_WILDCARD: NTSTATUS = 0xC0000208; +pub const STATUS_TOO_MANY_ADDRESSES: NTSTATUS = 0xC0000209; +pub const STATUS_ADDRESS_ALREADY_EXISTS: NTSTATUS = 0xC000020A; +pub const STATUS_ADDRESS_CLOSED: NTSTATUS = 0xC000020B; +pub const STATUS_CONNECTION_DISCONNECTED: NTSTATUS = 0xC000020C; +pub const STATUS_CONNECTION_RESET: NTSTATUS = 0xC000020D; +pub const STATUS_TOO_MANY_NODES: NTSTATUS = 0xC000020E; +pub const STATUS_TRANSACTION_ABORTED: NTSTATUS = 0xC000020F; +pub const STATUS_TRANSACTION_TIMED_OUT: NTSTATUS = 0xC0000210; +pub const STATUS_TRANSACTION_NO_RELEASE: NTSTATUS = 0xC0000211; +pub const STATUS_TRANSACTION_NO_MATCH: NTSTATUS = 0xC0000212; +pub const STATUS_TRANSACTION_RESPONDED: NTSTATUS = 0xC0000213; +pub const STATUS_TRANSACTION_INVALID_ID: NTSTATUS = 0xC0000214; +pub const STATUS_TRANSACTION_INVALID_TYPE: NTSTATUS = 0xC0000215; +pub const STATUS_NOT_SERVER_SESSION: NTSTATUS = 0xC0000216; +pub const STATUS_NOT_CLIENT_SESSION: NTSTATUS = 0xC0000217; +pub const STATUS_CANNOT_LOAD_REGISTRY_FILE: NTSTATUS = 0xC0000218; +pub const STATUS_DEBUG_ATTACH_FAILED: NTSTATUS = 0xC0000219; +pub const STATUS_SYSTEM_PROCESS_TERMINATED: NTSTATUS = 0xC000021A; +pub const STATUS_DATA_NOT_ACCEPTED: NTSTATUS = 0xC000021B; +pub const STATUS_NO_BROWSER_SERVERS_FOUND: NTSTATUS = 0xC000021C; +pub const STATUS_VDM_HARD_ERROR: NTSTATUS = 0xC000021D; +pub const STATUS_DRIVER_CANCEL_TIMEOUT: NTSTATUS = 0xC000021E; +pub const STATUS_REPLY_MESSAGE_MISMATCH: NTSTATUS = 0xC000021F; +pub const STATUS_MAPPED_ALIGNMENT: NTSTATUS = 0xC0000220; +pub const STATUS_IMAGE_CHECKSUM_MISMATCH: NTSTATUS = 0xC0000221; +pub const STATUS_LOST_WRITEBEHIND_DATA: NTSTATUS = 0xC0000222; +pub const STATUS_CLIENT_SERVER_PARAMETERS_INVALID: NTSTATUS = 0xC0000223; +pub const STATUS_PASSWORD_MUST_CHANGE: NTSTATUS = 0xC0000224; +pub const STATUS_NOT_FOUND: NTSTATUS = 0xC0000225; +pub const STATUS_NOT_TINY_STREAM: NTSTATUS = 0xC0000226; +pub const STATUS_RECOVERY_FAILURE: NTSTATUS = 0xC0000227; +pub const STATUS_STACK_OVERFLOW_READ: NTSTATUS = 0xC0000228; +pub const STATUS_FAIL_CHECK: NTSTATUS = 0xC0000229; +pub const STATUS_DUPLICATE_OBJECTID: NTSTATUS = 0xC000022A; +pub const STATUS_OBJECTID_EXISTS: NTSTATUS = 0xC000022B; +pub const STATUS_CONVERT_TO_LARGE: NTSTATUS = 0xC000022C; +pub const STATUS_RETRY: NTSTATUS = 0xC000022D; +pub const STATUS_FOUND_OUT_OF_SCOPE: NTSTATUS = 0xC000022E; +pub const STATUS_ALLOCATE_BUCKET: NTSTATUS = 0xC000022F; +pub const STATUS_PROPSET_NOT_FOUND: NTSTATUS = 0xC0000230; +pub const STATUS_MARSHALL_OVERFLOW: NTSTATUS = 0xC0000231; +pub const STATUS_INVALID_VARIANT: NTSTATUS = 0xC0000232; +pub const STATUS_DOMAIN_CONTROLLER_NOT_FOUND: NTSTATUS = 0xC0000233; +pub const STATUS_ACCOUNT_LOCKED_OUT: NTSTATUS = 0xC0000234; +pub const STATUS_HANDLE_NOT_CLOSABLE: NTSTATUS = 0xC0000235; +pub const STATUS_CONNECTION_REFUSED: NTSTATUS = 0xC0000236; +pub const STATUS_GRACEFUL_DISCONNECT: NTSTATUS = 0xC0000237; +pub const STATUS_ADDRESS_ALREADY_ASSOCIATED: NTSTATUS = 0xC0000238; +pub const STATUS_ADDRESS_NOT_ASSOCIATED: NTSTATUS = 0xC0000239; +pub const STATUS_CONNECTION_INVALID: NTSTATUS = 0xC000023A; +pub const STATUS_CONNECTION_ACTIVE: NTSTATUS = 0xC000023B; +pub const STATUS_NETWORK_UNREACHABLE: NTSTATUS = 0xC000023C; +pub const STATUS_HOST_UNREACHABLE: NTSTATUS = 0xC000023D; +pub const STATUS_PROTOCOL_UNREACHABLE: NTSTATUS = 0xC000023E; +pub const STATUS_PORT_UNREACHABLE: NTSTATUS = 0xC000023F; +pub const STATUS_REQUEST_ABORTED: NTSTATUS = 0xC0000240; +pub const STATUS_CONNECTION_ABORTED: NTSTATUS = 0xC0000241; +pub const STATUS_BAD_COMPRESSION_BUFFER: NTSTATUS = 0xC0000242; +pub const STATUS_USER_MAPPED_FILE: NTSTATUS = 0xC0000243; +pub const STATUS_AUDIT_FAILED: NTSTATUS = 0xC0000244; +pub const STATUS_TIMER_RESOLUTION_NOT_SET: NTSTATUS = 0xC0000245; +pub const STATUS_CONNECTION_COUNT_LIMIT: NTSTATUS = 0xC0000246; +pub const STATUS_LOGIN_TIME_RESTRICTION: NTSTATUS = 0xC0000247; +pub const STATUS_LOGIN_WKSTA_RESTRICTION: NTSTATUS = 0xC0000248; +pub const STATUS_IMAGE_MP_UP_MISMATCH: NTSTATUS = 0xC0000249; +pub const STATUS_INSUFFICIENT_LOGON_INFO: NTSTATUS = 0xC0000250; +pub const STATUS_BAD_DLL_ENTRYPOINT: NTSTATUS = 0xC0000251; +pub const STATUS_BAD_SERVICE_ENTRYPOINT: NTSTATUS = 0xC0000252; +pub const STATUS_LPC_REPLY_LOST: NTSTATUS = 0xC0000253; +pub const STATUS_IP_ADDRESS_CONFLICT1: NTSTATUS = 0xC0000254; +pub const STATUS_IP_ADDRESS_CONFLICT2: NTSTATUS = 0xC0000255; +pub const STATUS_REGISTRY_QUOTA_LIMIT: NTSTATUS = 0xC0000256; +pub const STATUS_PATH_NOT_COVERED: NTSTATUS = 0xC0000257; +pub const STATUS_NO_CALLBACK_ACTIVE: NTSTATUS = 0xC0000258; +pub const STATUS_LICENSE_QUOTA_EXCEEDED: NTSTATUS = 0xC0000259; +pub const STATUS_PWD_TOO_SHORT: NTSTATUS = 0xC000025A; +pub const STATUS_PWD_TOO_RECENT: NTSTATUS = 0xC000025B; +pub const STATUS_PWD_HISTORY_CONFLICT: NTSTATUS = 0xC000025C; +pub const STATUS_PLUGPLAY_NO_DEVICE: NTSTATUS = 0xC000025E; +pub const STATUS_UNSUPPORTED_COMPRESSION: NTSTATUS = 0xC000025F; +pub const STATUS_INVALID_HW_PROFILE: NTSTATUS = 0xC0000260; +pub const STATUS_INVALID_PLUGPLAY_DEVICE_PATH: NTSTATUS = 0xC0000261; +pub const STATUS_DRIVER_ORDINAL_NOT_FOUND: NTSTATUS = 0xC0000262; +pub const STATUS_DRIVER_ENTRYPOINT_NOT_FOUND: NTSTATUS = 0xC0000263; +pub const STATUS_RESOURCE_NOT_OWNED: NTSTATUS = 0xC0000264; +pub const STATUS_TOO_MANY_LINKS: NTSTATUS = 0xC0000265; +pub const STATUS_QUOTA_LIST_INCONSISTENT: NTSTATUS = 0xC0000266; +pub const STATUS_FILE_IS_OFFLINE: NTSTATUS = 0xC0000267; +pub const STATUS_EVALUATION_EXPIRATION: NTSTATUS = 0xC0000268; +pub const STATUS_ILLEGAL_DLL_RELOCATION: NTSTATUS = 0xC0000269; +pub const STATUS_LICENSE_VIOLATION: NTSTATUS = 0xC000026A; +pub const STATUS_DLL_INIT_FAILED_LOGOFF: NTSTATUS = 0xC000026B; +pub const STATUS_DRIVER_UNABLE_TO_LOAD: NTSTATUS = 0xC000026C; +pub const STATUS_DFS_UNAVAILABLE: NTSTATUS = 0xC000026D; +pub const STATUS_VOLUME_DISMOUNTED: NTSTATUS = 0xC000026E; +pub const STATUS_WX86_INTERNAL_ERROR: NTSTATUS = 0xC000026F; +pub const STATUS_WX86_FLOAT_STACK_CHECK: NTSTATUS = 0xC0000270; +pub const STATUS_VALIDATE_CONTINUE: NTSTATUS = 0xC0000271; +pub const STATUS_NO_MATCH: NTSTATUS = 0xC0000272; +pub const STATUS_NO_MORE_MATCHES: NTSTATUS = 0xC0000273; +pub const STATUS_NOT_A_REPARSE_POINT: NTSTATUS = 0xC0000275; +pub const STATUS_IO_REPARSE_TAG_INVALID: NTSTATUS = 0xC0000276; +pub const STATUS_IO_REPARSE_TAG_MISMATCH: NTSTATUS = 0xC0000277; +pub const STATUS_IO_REPARSE_DATA_INVALID: NTSTATUS = 0xC0000278; +pub const STATUS_IO_REPARSE_TAG_NOT_HANDLED: NTSTATUS = 0xC0000279; +pub const STATUS_PWD_TOO_LONG: NTSTATUS = 0xC000027A; +pub const STATUS_STOWED_EXCEPTION: NTSTATUS = 0xC000027B; +pub const STATUS_REPARSE_POINT_NOT_RESOLVED: NTSTATUS = 0xC0000280; +pub const STATUS_DIRECTORY_IS_A_REPARSE_POINT: NTSTATUS = 0xC0000281; +pub const STATUS_RANGE_LIST_CONFLICT: NTSTATUS = 0xC0000282; +pub const STATUS_SOURCE_ELEMENT_EMPTY: NTSTATUS = 0xC0000283; +pub const STATUS_DESTINATION_ELEMENT_FULL: NTSTATUS = 0xC0000284; +pub const STATUS_ILLEGAL_ELEMENT_ADDRESS: NTSTATUS = 0xC0000285; +pub const STATUS_MAGAZINE_NOT_PRESENT: NTSTATUS = 0xC0000286; +pub const STATUS_REINITIALIZATION_NEEDED: NTSTATUS = 0xC0000287; +pub const STATUS_DEVICE_REQUIRES_CLEANING: NTSTATUS = 0x80000288; +pub const STATUS_DEVICE_DOOR_OPEN: NTSTATUS = 0x80000289; +pub const STATUS_ENCRYPTION_FAILED: NTSTATUS = 0xC000028A; +pub const STATUS_DECRYPTION_FAILED: NTSTATUS = 0xC000028B; +pub const STATUS_RANGE_NOT_FOUND: NTSTATUS = 0xC000028C; +pub const STATUS_NO_RECOVERY_POLICY: NTSTATUS = 0xC000028D; +pub const STATUS_NO_EFS: NTSTATUS = 0xC000028E; +pub const STATUS_WRONG_EFS: NTSTATUS = 0xC000028F; +pub const STATUS_NO_USER_KEYS: NTSTATUS = 0xC0000290; +pub const STATUS_FILE_NOT_ENCRYPTED: NTSTATUS = 0xC0000291; +pub const STATUS_NOT_EXPORT_FORMAT: NTSTATUS = 0xC0000292; +pub const STATUS_FILE_ENCRYPTED: NTSTATUS = 0xC0000293; +pub const STATUS_WAKE_SYSTEM: NTSTATUS = 0x40000294; +pub const STATUS_WMI_GUID_NOT_FOUND: NTSTATUS = 0xC0000295; +pub const STATUS_WMI_INSTANCE_NOT_FOUND: NTSTATUS = 0xC0000296; +pub const STATUS_WMI_ITEMID_NOT_FOUND: NTSTATUS = 0xC0000297; +pub const STATUS_WMI_TRY_AGAIN: NTSTATUS = 0xC0000298; +pub const STATUS_SHARED_POLICY: NTSTATUS = 0xC0000299; +pub const STATUS_POLICY_OBJECT_NOT_FOUND: NTSTATUS = 0xC000029A; +pub const STATUS_POLICY_ONLY_IN_DS: NTSTATUS = 0xC000029B; +pub const STATUS_VOLUME_NOT_UPGRADED: NTSTATUS = 0xC000029C; +pub const STATUS_REMOTE_STORAGE_NOT_ACTIVE: NTSTATUS = 0xC000029D; +pub const STATUS_REMOTE_STORAGE_MEDIA_ERROR: NTSTATUS = 0xC000029E; +pub const STATUS_NO_TRACKING_SERVICE: NTSTATUS = 0xC000029F; +pub const STATUS_SERVER_SID_MISMATCH: NTSTATUS = 0xC00002A0; +pub const STATUS_DS_NO_ATTRIBUTE_OR_VALUE: NTSTATUS = 0xC00002A1; +pub const STATUS_DS_INVALID_ATTRIBUTE_SYNTAX: NTSTATUS = 0xC00002A2; +pub const STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED: NTSTATUS = 0xC00002A3; +pub const STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS: NTSTATUS = 0xC00002A4; +pub const STATUS_DS_BUSY: NTSTATUS = 0xC00002A5; +pub const STATUS_DS_UNAVAILABLE: NTSTATUS = 0xC00002A6; +pub const STATUS_DS_NO_RIDS_ALLOCATED: NTSTATUS = 0xC00002A7; +pub const STATUS_DS_NO_MORE_RIDS: NTSTATUS = 0xC00002A8; +pub const STATUS_DS_INCORRECT_ROLE_OWNER: NTSTATUS = 0xC00002A9; +pub const STATUS_DS_RIDMGR_INIT_ERROR: NTSTATUS = 0xC00002AA; +pub const STATUS_DS_OBJ_CLASS_VIOLATION: NTSTATUS = 0xC00002AB; +pub const STATUS_DS_CANT_ON_NON_LEAF: NTSTATUS = 0xC00002AC; +pub const STATUS_DS_CANT_ON_RDN: NTSTATUS = 0xC00002AD; +pub const STATUS_DS_CANT_MOD_OBJ_CLASS: NTSTATUS = 0xC00002AE; +pub const STATUS_DS_CROSS_DOM_MOVE_FAILED: NTSTATUS = 0xC00002AF; +pub const STATUS_DS_GC_NOT_AVAILABLE: NTSTATUS = 0xC00002B0; +pub const STATUS_DIRECTORY_SERVICE_REQUIRED: NTSTATUS = 0xC00002B1; +pub const STATUS_REPARSE_ATTRIBUTE_CONFLICT: NTSTATUS = 0xC00002B2; +pub const STATUS_CANT_ENABLE_DENY_ONLY: NTSTATUS = 0xC00002B3; +pub const STATUS_FLOAT_MULTIPLE_FAULTS: NTSTATUS = 0xC00002B4; +pub const STATUS_FLOAT_MULTIPLE_TRAPS: NTSTATUS = 0xC00002B5; +pub const STATUS_DEVICE_REMOVED: NTSTATUS = 0xC00002B6; +pub const STATUS_JOURNAL_DELETE_IN_PROGRESS: NTSTATUS = 0xC00002B7; +pub const STATUS_JOURNAL_NOT_ACTIVE: NTSTATUS = 0xC00002B8; +pub const STATUS_NOINTERFACE: NTSTATUS = 0xC00002B9; +pub const STATUS_DS_RIDMGR_DISABLED: NTSTATUS = 0xC00002BA; +pub const STATUS_DS_ADMIN_LIMIT_EXCEEDED: NTSTATUS = 0xC00002C1; +pub const STATUS_DRIVER_FAILED_SLEEP: NTSTATUS = 0xC00002C2; +pub const STATUS_MUTUAL_AUTHENTICATION_FAILED: NTSTATUS = 0xC00002C3; +pub const STATUS_CORRUPT_SYSTEM_FILE: NTSTATUS = 0xC00002C4; +pub const STATUS_DATATYPE_MISALIGNMENT_ERROR: NTSTATUS = 0xC00002C5; +pub const STATUS_WMI_READ_ONLY: NTSTATUS = 0xC00002C6; +pub const STATUS_WMI_SET_FAILURE: NTSTATUS = 0xC00002C7; +pub const STATUS_COMMITMENT_MINIMUM: NTSTATUS = 0xC00002C8; +pub const STATUS_REG_NAT_CONSUMPTION: NTSTATUS = 0xC00002C9; +pub const STATUS_TRANSPORT_FULL: NTSTATUS = 0xC00002CA; +pub const STATUS_DS_SAM_INIT_FAILURE: NTSTATUS = 0xC00002CB; +pub const STATUS_ONLY_IF_CONNECTED: NTSTATUS = 0xC00002CC; +pub const STATUS_DS_SENSITIVE_GROUP_VIOLATION: NTSTATUS = 0xC00002CD; +pub const STATUS_PNP_RESTART_ENUMERATION: NTSTATUS = 0xC00002CE; +pub const STATUS_JOURNAL_ENTRY_DELETED: NTSTATUS = 0xC00002CF; +pub const STATUS_DS_CANT_MOD_PRIMARYGROUPID: NTSTATUS = 0xC00002D0; +pub const STATUS_SYSTEM_IMAGE_BAD_SIGNATURE: NTSTATUS = 0xC00002D1; +pub const STATUS_PNP_REBOOT_REQUIRED: NTSTATUS = 0xC00002D2; +pub const STATUS_POWER_STATE_INVALID: NTSTATUS = 0xC00002D3; +pub const STATUS_DS_INVALID_GROUP_TYPE: NTSTATUS = 0xC00002D4; +pub const STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN: NTSTATUS = 0xC00002D5; +pub const STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN: NTSTATUS = 0xC00002D6; +pub const STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER: NTSTATUS = 0xC00002D7; +pub const STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER: NTSTATUS = 0xC00002D8; +pub const STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER: NTSTATUS = 0xC00002D9; +pub const STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER: NTSTATUS = 0xC00002DA; +pub const STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER: NTSTATUS = 0xC00002DB; +pub const STATUS_DS_HAVE_PRIMARY_MEMBERS: NTSTATUS = 0xC00002DC; +pub const STATUS_WMI_NOT_SUPPORTED: NTSTATUS = 0xC00002DD; +pub const STATUS_INSUFFICIENT_POWER: NTSTATUS = 0xC00002DE; +pub const STATUS_SAM_NEED_BOOTKEY_PASSWORD: NTSTATUS = 0xC00002DF; +pub const STATUS_SAM_NEED_BOOTKEY_FLOPPY: NTSTATUS = 0xC00002E0; +pub const STATUS_DS_CANT_START: NTSTATUS = 0xC00002E1; +pub const STATUS_DS_INIT_FAILURE: NTSTATUS = 0xC00002E2; +pub const STATUS_SAM_INIT_FAILURE: NTSTATUS = 0xC00002E3; +pub const STATUS_DS_GC_REQUIRED: NTSTATUS = 0xC00002E4; +pub const STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY: NTSTATUS = 0xC00002E5; +pub const STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS: NTSTATUS = 0xC00002E6; +pub const STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED: NTSTATUS = 0xC00002E7; +pub const STATUS_MULTIPLE_FAULT_VIOLATION: NTSTATUS = 0xC00002E8; +pub const STATUS_CURRENT_DOMAIN_NOT_ALLOWED: NTSTATUS = 0xC00002E9; +pub const STATUS_CANNOT_MAKE: NTSTATUS = 0xC00002EA; +pub const STATUS_SYSTEM_SHUTDOWN: NTSTATUS = 0xC00002EB; +pub const STATUS_DS_INIT_FAILURE_CONSOLE: NTSTATUS = 0xC00002EC; +pub const STATUS_DS_SAM_INIT_FAILURE_CONSOLE: NTSTATUS = 0xC00002ED; +pub const STATUS_UNFINISHED_CONTEXT_DELETED: NTSTATUS = 0xC00002EE; +pub const STATUS_NO_TGT_REPLY: NTSTATUS = 0xC00002EF; +pub const STATUS_OBJECTID_NOT_FOUND: NTSTATUS = 0xC00002F0; +pub const STATUS_NO_IP_ADDRESSES: NTSTATUS = 0xC00002F1; +pub const STATUS_WRONG_CREDENTIAL_HANDLE: NTSTATUS = 0xC00002F2; +pub const STATUS_CRYPTO_SYSTEM_INVALID: NTSTATUS = 0xC00002F3; +pub const STATUS_MAX_REFERRALS_EXCEEDED: NTSTATUS = 0xC00002F4; +pub const STATUS_MUST_BE_KDC: NTSTATUS = 0xC00002F5; +pub const STATUS_STRONG_CRYPTO_NOT_SUPPORTED: NTSTATUS = 0xC00002F6; +pub const STATUS_TOO_MANY_PRINCIPALS: NTSTATUS = 0xC00002F7; +pub const STATUS_NO_PA_DATA: NTSTATUS = 0xC00002F8; +pub const STATUS_PKINIT_NAME_MISMATCH: NTSTATUS = 0xC00002F9; +pub const STATUS_SMARTCARD_LOGON_REQUIRED: NTSTATUS = 0xC00002FA; +pub const STATUS_KDC_INVALID_REQUEST: NTSTATUS = 0xC00002FB; +pub const STATUS_KDC_UNABLE_TO_REFER: NTSTATUS = 0xC00002FC; +pub const STATUS_KDC_UNKNOWN_ETYPE: NTSTATUS = 0xC00002FD; +pub const STATUS_SHUTDOWN_IN_PROGRESS: NTSTATUS = 0xC00002FE; +pub const STATUS_SERVER_SHUTDOWN_IN_PROGRESS: NTSTATUS = 0xC00002FF; +pub const STATUS_NOT_SUPPORTED_ON_SBS: NTSTATUS = 0xC0000300; +pub const STATUS_WMI_GUID_DISCONNECTED: NTSTATUS = 0xC0000301; +pub const STATUS_WMI_ALREADY_DISABLED: NTSTATUS = 0xC0000302; +pub const STATUS_WMI_ALREADY_ENABLED: NTSTATUS = 0xC0000303; +pub const STATUS_MFT_TOO_FRAGMENTED: NTSTATUS = 0xC0000304; +pub const STATUS_COPY_PROTECTION_FAILURE: NTSTATUS = 0xC0000305; +pub const STATUS_CSS_AUTHENTICATION_FAILURE: NTSTATUS = 0xC0000306; +pub const STATUS_CSS_KEY_NOT_PRESENT: NTSTATUS = 0xC0000307; +pub const STATUS_CSS_KEY_NOT_ESTABLISHED: NTSTATUS = 0xC0000308; +pub const STATUS_CSS_SCRAMBLED_SECTOR: NTSTATUS = 0xC0000309; +pub const STATUS_CSS_REGION_MISMATCH: NTSTATUS = 0xC000030A; +pub const STATUS_CSS_RESETS_EXHAUSTED: NTSTATUS = 0xC000030B; +pub const STATUS_PASSWORD_CHANGE_REQUIRED: NTSTATUS = 0xC000030C; +pub const STATUS_PKINIT_FAILURE: NTSTATUS = 0xC0000320; +pub const STATUS_SMARTCARD_SUBSYSTEM_FAILURE: NTSTATUS = 0xC0000321; +pub const STATUS_NO_KERB_KEY: NTSTATUS = 0xC0000322; +pub const STATUS_HOST_DOWN: NTSTATUS = 0xC0000350; +pub const STATUS_UNSUPPORTED_PREAUTH: NTSTATUS = 0xC0000351; +pub const STATUS_EFS_ALG_BLOB_TOO_BIG: NTSTATUS = 0xC0000352; +pub const STATUS_PORT_NOT_SET: NTSTATUS = 0xC0000353; +pub const STATUS_DEBUGGER_INACTIVE: NTSTATUS = 0xC0000354; +pub const STATUS_DS_VERSION_CHECK_FAILURE: NTSTATUS = 0xC0000355; +pub const STATUS_AUDITING_DISABLED: NTSTATUS = 0xC0000356; +pub const STATUS_PRENT4_MACHINE_ACCOUNT: NTSTATUS = 0xC0000357; +pub const STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER: NTSTATUS = 0xC0000358; +pub const STATUS_INVALID_IMAGE_WIN_32: NTSTATUS = 0xC0000359; +pub const STATUS_INVALID_IMAGE_WIN_64: NTSTATUS = 0xC000035A; +pub const STATUS_BAD_BINDINGS: NTSTATUS = 0xC000035B; +pub const STATUS_NETWORK_SESSION_EXPIRED: NTSTATUS = 0xC000035C; +pub const STATUS_APPHELP_BLOCK: NTSTATUS = 0xC000035D; +pub const STATUS_ALL_SIDS_FILTERED: NTSTATUS = 0xC000035E; +pub const STATUS_NOT_SAFE_MODE_DRIVER: NTSTATUS = 0xC000035F; +pub const STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT: NTSTATUS = 0xC0000361; +pub const STATUS_ACCESS_DISABLED_BY_POLICY_PATH: NTSTATUS = 0xC0000362; +pub const STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER: NTSTATUS = 0xC0000363; +pub const STATUS_ACCESS_DISABLED_BY_POLICY_OTHER: NTSTATUS = 0xC0000364; +pub const STATUS_FAILED_DRIVER_ENTRY: NTSTATUS = 0xC0000365; +pub const STATUS_DEVICE_ENUMERATION_ERROR: NTSTATUS = 0xC0000366; +pub const STATUS_MOUNT_POINT_NOT_RESOLVED: NTSTATUS = 0xC0000368; +pub const STATUS_INVALID_DEVICE_OBJECT_PARAMETER: NTSTATUS = 0xC0000369; +pub const STATUS_MCA_OCCURED: NTSTATUS = 0xC000036A; +pub const STATUS_DRIVER_BLOCKED_CRITICAL: NTSTATUS = 0xC000036B; +pub const STATUS_DRIVER_BLOCKED: NTSTATUS = 0xC000036C; +pub const STATUS_DRIVER_DATABASE_ERROR: NTSTATUS = 0xC000036D; +pub const STATUS_SYSTEM_HIVE_TOO_LARGE: NTSTATUS = 0xC000036E; +pub const STATUS_INVALID_IMPORT_OF_NON_DLL: NTSTATUS = 0xC000036F; +pub const STATUS_DS_SHUTTING_DOWN: NTSTATUS = 0x40000370; +pub const STATUS_NO_SECRETS: NTSTATUS = 0xC0000371; +pub const STATUS_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY: NTSTATUS = 0xC0000372; +pub const STATUS_FAILED_STACK_SWITCH: NTSTATUS = 0xC0000373; +pub const STATUS_HEAP_CORRUPTION: NTSTATUS = 0xC0000374; +pub const STATUS_SMARTCARD_WRONG_PIN: NTSTATUS = 0xC0000380; +pub const STATUS_SMARTCARD_CARD_BLOCKED: NTSTATUS = 0xC0000381; +pub const STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED: NTSTATUS = 0xC0000382; +pub const STATUS_SMARTCARD_NO_CARD: NTSTATUS = 0xC0000383; +pub const STATUS_SMARTCARD_NO_KEY_CONTAINER: NTSTATUS = 0xC0000384; +pub const STATUS_SMARTCARD_NO_CERTIFICATE: NTSTATUS = 0xC0000385; +pub const STATUS_SMARTCARD_NO_KEYSET: NTSTATUS = 0xC0000386; +pub const STATUS_SMARTCARD_IO_ERROR: NTSTATUS = 0xC0000387; +pub const STATUS_DOWNGRADE_DETECTED: NTSTATUS = 0xC0000388; +pub const STATUS_SMARTCARD_CERT_REVOKED: NTSTATUS = 0xC0000389; +pub const STATUS_ISSUING_CA_UNTRUSTED: NTSTATUS = 0xC000038A; +pub const STATUS_REVOCATION_OFFLINE_C: NTSTATUS = 0xC000038B; +pub const STATUS_PKINIT_CLIENT_FAILURE: NTSTATUS = 0xC000038C; +pub const STATUS_SMARTCARD_CERT_EXPIRED: NTSTATUS = 0xC000038D; +pub const STATUS_DRIVER_FAILED_PRIOR_UNLOAD: NTSTATUS = 0xC000038E; +pub const STATUS_SMARTCARD_SILENT_CONTEXT: NTSTATUS = 0xC000038F; +pub const STATUS_PER_USER_TRUST_QUOTA_EXCEEDED: NTSTATUS = 0xC0000401; +pub const STATUS_ALL_USER_TRUST_QUOTA_EXCEEDED: NTSTATUS = 0xC0000402; +pub const STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED: NTSTATUS = 0xC0000403; +pub const STATUS_DS_NAME_NOT_UNIQUE: NTSTATUS = 0xC0000404; +pub const STATUS_DS_DUPLICATE_ID_FOUND: NTSTATUS = 0xC0000405; +pub const STATUS_DS_GROUP_CONVERSION_ERROR: NTSTATUS = 0xC0000406; +pub const STATUS_VOLSNAP_PREPARE_HIBERNATE: NTSTATUS = 0xC0000407; +pub const STATUS_USER2USER_REQUIRED: NTSTATUS = 0xC0000408; +pub const STATUS_STACK_BUFFER_OVERRUN: NTSTATUS = 0xC0000409; +pub const STATUS_NO_S4U_PROT_SUPPORT: NTSTATUS = 0xC000040A; +pub const STATUS_CROSSREALM_DELEGATION_FAILURE: NTSTATUS = 0xC000040B; +pub const STATUS_REVOCATION_OFFLINE_KDC: NTSTATUS = 0xC000040C; +pub const STATUS_ISSUING_CA_UNTRUSTED_KDC: NTSTATUS = 0xC000040D; +pub const STATUS_KDC_CERT_EXPIRED: NTSTATUS = 0xC000040E; +pub const STATUS_KDC_CERT_REVOKED: NTSTATUS = 0xC000040F; +pub const STATUS_PARAMETER_QUOTA_EXCEEDED: NTSTATUS = 0xC0000410; +pub const STATUS_HIBERNATION_FAILURE: NTSTATUS = 0xC0000411; +pub const STATUS_DELAY_LOAD_FAILED: NTSTATUS = 0xC0000412; +pub const STATUS_AUTHENTICATION_FIREWALL_FAILED: NTSTATUS = 0xC0000413; +pub const STATUS_VDM_DISALLOWED: NTSTATUS = 0xC0000414; +pub const STATUS_HUNG_DISPLAY_DRIVER_THREAD: NTSTATUS = 0xC0000415; +pub const STATUS_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE: NTSTATUS + = 0xC0000416; +pub const STATUS_INVALID_CRUNTIME_PARAMETER: NTSTATUS = 0xC0000417; +pub const STATUS_NTLM_BLOCKED: NTSTATUS = 0xC0000418; +pub const STATUS_DS_SRC_SID_EXISTS_IN_FOREST: NTSTATUS = 0xC0000419; +pub const STATUS_DS_DOMAIN_NAME_EXISTS_IN_FOREST: NTSTATUS = 0xC000041A; +pub const STATUS_DS_FLAT_NAME_EXISTS_IN_FOREST: NTSTATUS = 0xC000041B; +pub const STATUS_INVALID_USER_PRINCIPAL_NAME: NTSTATUS = 0xC000041C; +pub const STATUS_FATAL_USER_CALLBACK_EXCEPTION: NTSTATUS = 0xC000041D; +pub const STATUS_ASSERTION_FAILURE: NTSTATUS = 0xC0000420; +pub const STATUS_VERIFIER_STOP: NTSTATUS = 0xC0000421; +pub const STATUS_CALLBACK_POP_STACK: NTSTATUS = 0xC0000423; +pub const STATUS_INCOMPATIBLE_DRIVER_BLOCKED: NTSTATUS = 0xC0000424; +pub const STATUS_HIVE_UNLOADED: NTSTATUS = 0xC0000425; +pub const STATUS_COMPRESSION_DISABLED: NTSTATUS = 0xC0000426; +pub const STATUS_FILE_SYSTEM_LIMITATION: NTSTATUS = 0xC0000427; +pub const STATUS_INVALID_IMAGE_HASH: NTSTATUS = 0xC0000428; +pub const STATUS_NOT_CAPABLE: NTSTATUS = 0xC0000429; +pub const STATUS_REQUEST_OUT_OF_SEQUENCE: NTSTATUS = 0xC000042A; +pub const STATUS_IMPLEMENTATION_LIMIT: NTSTATUS = 0xC000042B; +pub const STATUS_ELEVATION_REQUIRED: NTSTATUS = 0xC000042C; +pub const STATUS_NO_SECURITY_CONTEXT: NTSTATUS = 0xC000042D; +pub const STATUS_PKU2U_CERT_FAILURE: NTSTATUS = 0xC000042F; +pub const STATUS_BEYOND_VDL: NTSTATUS = 0xC0000432; +pub const STATUS_ENCOUNTERED_WRITE_IN_PROGRESS: NTSTATUS = 0xC0000433; +pub const STATUS_PTE_CHANGED: NTSTATUS = 0xC0000434; +pub const STATUS_PURGE_FAILED: NTSTATUS = 0xC0000435; +pub const STATUS_CRED_REQUIRES_CONFIRMATION: NTSTATUS = 0xC0000440; +pub const STATUS_CS_ENCRYPTION_INVALID_SERVER_RESPONSE: NTSTATUS = 0xC0000441; +pub const STATUS_CS_ENCRYPTION_UNSUPPORTED_SERVER: NTSTATUS = 0xC0000442; +pub const STATUS_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE: NTSTATUS = 0xC0000443; +pub const STATUS_CS_ENCRYPTION_NEW_ENCRYPTED_FILE: NTSTATUS = 0xC0000444; +pub const STATUS_CS_ENCRYPTION_FILE_NOT_CSE: NTSTATUS = 0xC0000445; +pub const STATUS_INVALID_LABEL: NTSTATUS = 0xC0000446; +pub const STATUS_DRIVER_PROCESS_TERMINATED: NTSTATUS = 0xC0000450; +pub const STATUS_AMBIGUOUS_SYSTEM_DEVICE: NTSTATUS = 0xC0000451; +pub const STATUS_SYSTEM_DEVICE_NOT_FOUND: NTSTATUS = 0xC0000452; +pub const STATUS_RESTART_BOOT_APPLICATION: NTSTATUS = 0xC0000453; +pub const STATUS_INSUFFICIENT_NVRAM_RESOURCES: NTSTATUS = 0xC0000454; +pub const STATUS_INVALID_SESSION: NTSTATUS = 0xC0000455; +pub const STATUS_THREAD_ALREADY_IN_SESSION: NTSTATUS = 0xC0000456; +pub const STATUS_THREAD_NOT_IN_SESSION: NTSTATUS = 0xC0000457; +pub const STATUS_INVALID_WEIGHT: NTSTATUS = 0xC0000458; +pub const STATUS_REQUEST_PAUSED: NTSTATUS = 0xC0000459; +pub const STATUS_NO_RANGES_PROCESSED: NTSTATUS = 0xC0000460; +pub const STATUS_DISK_RESOURCES_EXHAUSTED: NTSTATUS = 0xC0000461; +pub const STATUS_NEEDS_REMEDIATION: NTSTATUS = 0xC0000462; +pub const STATUS_DEVICE_FEATURE_NOT_SUPPORTED: NTSTATUS = 0xC0000463; +pub const STATUS_DEVICE_UNREACHABLE: NTSTATUS = 0xC0000464; +pub const STATUS_INVALID_TOKEN: NTSTATUS = 0xC0000465; +pub const STATUS_SERVER_UNAVAILABLE: NTSTATUS = 0xC0000466; +pub const STATUS_FILE_NOT_AVAILABLE: NTSTATUS = 0xC0000467; +pub const STATUS_DEVICE_INSUFFICIENT_RESOURCES: NTSTATUS = 0xC0000468; +pub const STATUS_PACKAGE_UPDATING: NTSTATUS = 0xC0000469; +pub const STATUS_NOT_READ_FROM_COPY: NTSTATUS = 0xC000046A; +pub const STATUS_FT_WRITE_FAILURE: NTSTATUS = 0xC000046B; +pub const STATUS_FT_DI_SCAN_REQUIRED: NTSTATUS = 0xC000046C; +pub const STATUS_OBJECT_NOT_EXTERNALLY_BACKED: NTSTATUS = 0xC000046D; +pub const STATUS_EXTERNAL_BACKING_PROVIDER_UNKNOWN: NTSTATUS = 0xC000046E; +pub const STATUS_COMPRESSION_NOT_BENEFICIAL: NTSTATUS = 0xC000046F; +pub const STATUS_DATA_CHECKSUM_ERROR: NTSTATUS = 0xC0000470; +pub const STATUS_INTERMIXED_KERNEL_EA_OPERATION: NTSTATUS = 0xC0000471; +pub const STATUS_TRIM_READ_ZERO_NOT_SUPPORTED: NTSTATUS = 0xC0000472; +pub const STATUS_TOO_MANY_SEGMENT_DESCRIPTORS: NTSTATUS = 0xC0000473; +pub const STATUS_INVALID_OFFSET_ALIGNMENT: NTSTATUS = 0xC0000474; +pub const STATUS_INVALID_FIELD_IN_PARAMETER_LIST: NTSTATUS = 0xC0000475; +pub const STATUS_OPERATION_IN_PROGRESS: NTSTATUS = 0xC0000476; +pub const STATUS_INVALID_INITIATOR_TARGET_PATH: NTSTATUS = 0xC0000477; +pub const STATUS_SCRUB_DATA_DISABLED: NTSTATUS = 0xC0000478; +pub const STATUS_NOT_REDUNDANT_STORAGE: NTSTATUS = 0xC0000479; +pub const STATUS_RESIDENT_FILE_NOT_SUPPORTED: NTSTATUS = 0xC000047A; +pub const STATUS_COMPRESSED_FILE_NOT_SUPPORTED: NTSTATUS = 0xC000047B; +pub const STATUS_DIRECTORY_NOT_SUPPORTED: NTSTATUS = 0xC000047C; +pub const STATUS_IO_OPERATION_TIMEOUT: NTSTATUS = 0xC000047D; +pub const STATUS_SYSTEM_NEEDS_REMEDIATION: NTSTATUS = 0xC000047E; +pub const STATUS_APPX_INTEGRITY_FAILURE_CLR_NGEN: NTSTATUS = 0xC000047F; +pub const STATUS_SHARE_UNAVAILABLE: NTSTATUS = 0xC0000480; +pub const STATUS_APISET_NOT_HOSTED: NTSTATUS = 0xC0000481; +pub const STATUS_APISET_NOT_PRESENT: NTSTATUS = 0xC0000482; +pub const STATUS_DEVICE_HARDWARE_ERROR: NTSTATUS = 0xC0000483; +pub const STATUS_FIRMWARE_SLOT_INVALID: NTSTATUS = 0xC0000484; +pub const STATUS_FIRMWARE_IMAGE_INVALID: NTSTATUS = 0xC0000485; +pub const STATUS_STORAGE_TOPOLOGY_ID_MISMATCH: NTSTATUS = 0xC0000486; +pub const STATUS_WIM_NOT_BOOTABLE: NTSTATUS = 0xC0000487; +pub const STATUS_BLOCKED_BY_PARENTAL_CONTROLS: NTSTATUS = 0xC0000488; +pub const STATUS_NEEDS_REGISTRATION: NTSTATUS = 0xC0000489; +pub const STATUS_QUOTA_ACTIVITY: NTSTATUS = 0xC000048A; +pub const STATUS_CALLBACK_INVOKE_INLINE: NTSTATUS = 0xC000048B; +pub const STATUS_BLOCK_TOO_MANY_REFERENCES: NTSTATUS = 0xC000048C; +pub const STATUS_MARKED_TO_DISALLOW_WRITES: NTSTATUS = 0xC000048D; +pub const STATUS_NETWORK_ACCESS_DENIED_EDP: NTSTATUS = 0xC000048E; +pub const STATUS_ENCLAVE_FAILURE: NTSTATUS = 0xC000048F; +pub const STATUS_PNP_NO_COMPAT_DRIVERS: NTSTATUS = 0xC0000490; +pub const STATUS_PNP_DRIVER_PACKAGE_NOT_FOUND: NTSTATUS = 0xC0000491; +pub const STATUS_PNP_DRIVER_CONFIGURATION_NOT_FOUND: NTSTATUS = 0xC0000492; +pub const STATUS_PNP_DRIVER_CONFIGURATION_INCOMPLETE: NTSTATUS = 0xC0000493; +pub const STATUS_PNP_FUNCTION_DRIVER_REQUIRED: NTSTATUS = 0xC0000494; +pub const STATUS_PNP_DEVICE_CONFIGURATION_PENDING: NTSTATUS = 0xC0000495; +pub const STATUS_DEVICE_HINT_NAME_BUFFER_TOO_SMALL: NTSTATUS = 0xC0000496; +pub const STATUS_PACKAGE_NOT_AVAILABLE: NTSTATUS = 0xC0000497; +pub const STATUS_DEVICE_IN_MAINTENANCE: NTSTATUS = 0xC0000499; +pub const STATUS_NOT_SUPPORTED_ON_DAX: NTSTATUS = 0xC000049A; +pub const STATUS_FREE_SPACE_TOO_FRAGMENTED: NTSTATUS = 0xC000049B; +pub const STATUS_DAX_MAPPING_EXISTS: NTSTATUS = 0xC000049C; +pub const STATUS_CHILD_PROCESS_BLOCKED: NTSTATUS = 0xC000049D; +pub const STATUS_STORAGE_LOST_DATA_PERSISTENCE: NTSTATUS = 0xC000049E; +pub const STATUS_INVALID_TASK_NAME: NTSTATUS = 0xC0000500; +pub const STATUS_INVALID_TASK_INDEX: NTSTATUS = 0xC0000501; +pub const STATUS_THREAD_ALREADY_IN_TASK: NTSTATUS = 0xC0000502; +pub const STATUS_CALLBACK_BYPASS: NTSTATUS = 0xC0000503; +pub const STATUS_UNDEFINED_SCOPE: NTSTATUS = 0xC0000504; +pub const STATUS_INVALID_CAP: NTSTATUS = 0xC0000505; +pub const STATUS_NOT_GUI_PROCESS: NTSTATUS = 0xC0000506; +pub const STATUS_DEVICE_HUNG: NTSTATUS = 0xC0000507; +pub const STATUS_CONTAINER_ASSIGNED: NTSTATUS = 0xC0000508; +pub const STATUS_JOB_NO_CONTAINER: NTSTATUS = 0xC0000509; +pub const STATUS_DEVICE_UNRESPONSIVE: NTSTATUS = 0xC000050A; +pub const STATUS_REPARSE_POINT_ENCOUNTERED: NTSTATUS = 0xC000050B; +pub const STATUS_FAIL_FAST_EXCEPTION: NTSTATUS = 0xC0000602; +pub const STATUS_IMAGE_CERT_REVOKED: NTSTATUS = 0xC0000603; +pub const STATUS_DYNAMIC_CODE_BLOCKED: NTSTATUS = 0xC0000604; +pub const STATUS_IMAGE_CERT_EXPIRED: NTSTATUS = 0xC0000605; +pub const STATUS_PORT_CLOSED: NTSTATUS = 0xC0000700; +pub const STATUS_MESSAGE_LOST: NTSTATUS = 0xC0000701; +pub const STATUS_INVALID_MESSAGE: NTSTATUS = 0xC0000702; +pub const STATUS_REQUEST_CANCELED: NTSTATUS = 0xC0000703; +pub const STATUS_RECURSIVE_DISPATCH: NTSTATUS = 0xC0000704; +pub const STATUS_LPC_RECEIVE_BUFFER_EXPECTED: NTSTATUS = 0xC0000705; +pub const STATUS_LPC_INVALID_CONNECTION_USAGE: NTSTATUS = 0xC0000706; +pub const STATUS_LPC_REQUESTS_NOT_ALLOWED: NTSTATUS = 0xC0000707; +pub const STATUS_RESOURCE_IN_USE: NTSTATUS = 0xC0000708; +pub const STATUS_HARDWARE_MEMORY_ERROR: NTSTATUS = 0xC0000709; +pub const STATUS_THREADPOOL_HANDLE_EXCEPTION: NTSTATUS = 0xC000070A; +pub const STATUS_THREADPOOL_SET_EVENT_ON_COMPLETION_FAILED: NTSTATUS = 0xC000070B; +pub const STATUS_THREADPOOL_RELEASE_SEMAPHORE_ON_COMPLETION_FAILED: NTSTATUS + = 0xC000070C; +pub const STATUS_THREADPOOL_RELEASE_MUTEX_ON_COMPLETION_FAILED: NTSTATUS = 0xC000070D; +pub const STATUS_THREADPOOL_FREE_LIBRARY_ON_COMPLETION_FAILED: NTSTATUS = 0xC000070E; +pub const STATUS_THREADPOOL_RELEASED_DURING_OPERATION: NTSTATUS = 0xC000070F; +pub const STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING: NTSTATUS = 0xC0000710; +pub const STATUS_APC_RETURNED_WHILE_IMPERSONATING: NTSTATUS = 0xC0000711; +pub const STATUS_PROCESS_IS_PROTECTED: NTSTATUS = 0xC0000712; +pub const STATUS_MCA_EXCEPTION: NTSTATUS = 0xC0000713; +pub const STATUS_CERTIFICATE_MAPPING_NOT_UNIQUE: NTSTATUS = 0xC0000714; +pub const STATUS_SYMLINK_CLASS_DISABLED: NTSTATUS = 0xC0000715; +pub const STATUS_INVALID_IDN_NORMALIZATION: NTSTATUS = 0xC0000716; +pub const STATUS_NO_UNICODE_TRANSLATION: NTSTATUS = 0xC0000717; +pub const STATUS_ALREADY_REGISTERED: NTSTATUS = 0xC0000718; +pub const STATUS_CONTEXT_MISMATCH: NTSTATUS = 0xC0000719; +pub const STATUS_PORT_ALREADY_HAS_COMPLETION_LIST: NTSTATUS = 0xC000071A; +pub const STATUS_CALLBACK_RETURNED_THREAD_PRIORITY: NTSTATUS = 0xC000071B; +pub const STATUS_INVALID_THREAD: NTSTATUS = 0xC000071C; +pub const STATUS_CALLBACK_RETURNED_TRANSACTION: NTSTATUS = 0xC000071D; +pub const STATUS_CALLBACK_RETURNED_LDR_LOCK: NTSTATUS = 0xC000071E; +pub const STATUS_CALLBACK_RETURNED_LANG: NTSTATUS = 0xC000071F; +pub const STATUS_CALLBACK_RETURNED_PRI_BACK: NTSTATUS = 0xC0000720; +pub const STATUS_CALLBACK_RETURNED_THREAD_AFFINITY: NTSTATUS = 0xC0000721; +pub const STATUS_LPC_HANDLE_COUNT_EXCEEDED: NTSTATUS = 0xC0000722; +pub const STATUS_DISK_REPAIR_DISABLED: NTSTATUS = 0xC0000800; +pub const STATUS_DS_DOMAIN_RENAME_IN_PROGRESS: NTSTATUS = 0xC0000801; +pub const STATUS_DISK_QUOTA_EXCEEDED: NTSTATUS = 0xC0000802; +pub const STATUS_DATA_LOST_REPAIR: NTSTATUS = 0x80000803; +pub const STATUS_CONTENT_BLOCKED: NTSTATUS = 0xC0000804; +pub const STATUS_BAD_CLUSTERS: NTSTATUS = 0xC0000805; +pub const STATUS_VOLUME_DIRTY: NTSTATUS = 0xC0000806; +pub const STATUS_DISK_REPAIR_REDIRECTED: NTSTATUS = 0x40000807; +pub const STATUS_DISK_REPAIR_UNSUCCESSFUL: NTSTATUS = 0xC0000808; +pub const STATUS_CORRUPT_LOG_OVERFULL: NTSTATUS = 0xC0000809; +pub const STATUS_CORRUPT_LOG_CORRUPTED: NTSTATUS = 0xC000080A; +pub const STATUS_CORRUPT_LOG_UNAVAILABLE: NTSTATUS = 0xC000080B; +pub const STATUS_CORRUPT_LOG_DELETED_FULL: NTSTATUS = 0xC000080C; +pub const STATUS_CORRUPT_LOG_CLEARED: NTSTATUS = 0xC000080D; +pub const STATUS_ORPHAN_NAME_EXHAUSTED: NTSTATUS = 0xC000080E; +pub const STATUS_PROACTIVE_SCAN_IN_PROGRESS: NTSTATUS = 0xC000080F; +pub const STATUS_ENCRYPTED_IO_NOT_POSSIBLE: NTSTATUS = 0xC0000810; +pub const STATUS_CORRUPT_LOG_UPLEVEL_RECORDS: NTSTATUS = 0xC0000811; +pub const STATUS_FILE_CHECKED_OUT: NTSTATUS = 0xC0000901; +pub const STATUS_CHECKOUT_REQUIRED: NTSTATUS = 0xC0000902; +pub const STATUS_BAD_FILE_TYPE: NTSTATUS = 0xC0000903; +pub const STATUS_FILE_TOO_LARGE: NTSTATUS = 0xC0000904; +pub const STATUS_FORMS_AUTH_REQUIRED: NTSTATUS = 0xC0000905; +pub const STATUS_VIRUS_INFECTED: NTSTATUS = 0xC0000906; +pub const STATUS_VIRUS_DELETED: NTSTATUS = 0xC0000907; +pub const STATUS_BAD_MCFG_TABLE: NTSTATUS = 0xC0000908; +pub const STATUS_CANNOT_BREAK_OPLOCK: NTSTATUS = 0xC0000909; +pub const STATUS_BAD_KEY: NTSTATUS = 0xC000090A; +pub const STATUS_BAD_DATA: NTSTATUS = 0xC000090B; +pub const STATUS_NO_KEY: NTSTATUS = 0xC000090C; +pub const STATUS_FILE_HANDLE_REVOKED: NTSTATUS = 0xC0000910; +pub const STATUS_WOW_ASSERTION: NTSTATUS = 0xC0009898; +pub const STATUS_INVALID_SIGNATURE: NTSTATUS = 0xC000A000; +pub const STATUS_HMAC_NOT_SUPPORTED: NTSTATUS = 0xC000A001; +pub const STATUS_AUTH_TAG_MISMATCH: NTSTATUS = 0xC000A002; +pub const STATUS_INVALID_STATE_TRANSITION: NTSTATUS = 0xC000A003; +pub const STATUS_INVALID_KERNEL_INFO_VERSION: NTSTATUS = 0xC000A004; +pub const STATUS_INVALID_PEP_INFO_VERSION: NTSTATUS = 0xC000A005; +pub const STATUS_HANDLE_REVOKED: NTSTATUS = 0xC000A006; +pub const STATUS_EOF_ON_GHOSTED_RANGE: NTSTATUS = 0xC000A007; +pub const STATUS_IPSEC_QUEUE_OVERFLOW: NTSTATUS = 0xC000A010; +pub const STATUS_ND_QUEUE_OVERFLOW: NTSTATUS = 0xC000A011; +pub const STATUS_HOPLIMIT_EXCEEDED: NTSTATUS = 0xC000A012; +pub const STATUS_PROTOCOL_NOT_SUPPORTED: NTSTATUS = 0xC000A013; +pub const STATUS_FASTPATH_REJECTED: NTSTATUS = 0xC000A014; +pub const STATUS_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED: NTSTATUS = 0xC000A080; +pub const STATUS_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR: NTSTATUS = 0xC000A081; +pub const STATUS_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR: NTSTATUS = 0xC000A082; +pub const STATUS_XML_PARSE_ERROR: NTSTATUS = 0xC000A083; +pub const STATUS_XMLDSIG_ERROR: NTSTATUS = 0xC000A084; +pub const STATUS_WRONG_COMPARTMENT: NTSTATUS = 0xC000A085; +pub const STATUS_AUTHIP_FAILURE: NTSTATUS = 0xC000A086; +pub const STATUS_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS: NTSTATUS = 0xC000A087; +pub const STATUS_DS_OID_NOT_FOUND: NTSTATUS = 0xC000A088; +pub const STATUS_INCORRECT_ACCOUNT_TYPE: NTSTATUS = 0xC000A089; +pub const STATUS_HASH_NOT_SUPPORTED: NTSTATUS = 0xC000A100; +pub const STATUS_HASH_NOT_PRESENT: NTSTATUS = 0xC000A101; +pub const STATUS_SECONDARY_IC_PROVIDER_NOT_REGISTERED: NTSTATUS = 0xC000A121; +pub const STATUS_GPIO_CLIENT_INFORMATION_INVALID: NTSTATUS = 0xC000A122; +pub const STATUS_GPIO_VERSION_NOT_SUPPORTED: NTSTATUS = 0xC000A123; +pub const STATUS_GPIO_INVALID_REGISTRATION_PACKET: NTSTATUS = 0xC000A124; +pub const STATUS_GPIO_OPERATION_DENIED: NTSTATUS = 0xC000A125; +pub const STATUS_GPIO_INCOMPATIBLE_CONNECT_MODE: NTSTATUS = 0xC000A126; +pub const STATUS_GPIO_INTERRUPT_ALREADY_UNMASKED: NTSTATUS = 0x8000A127; +pub const STATUS_CANNOT_SWITCH_RUNLEVEL: NTSTATUS = 0xC000A141; +pub const STATUS_INVALID_RUNLEVEL_SETTING: NTSTATUS = 0xC000A142; +pub const STATUS_RUNLEVEL_SWITCH_TIMEOUT: NTSTATUS = 0xC000A143; +pub const STATUS_SERVICES_FAILED_AUTOSTART: NTSTATUS = 0x4000A144; +pub const STATUS_RUNLEVEL_SWITCH_AGENT_TIMEOUT: NTSTATUS = 0xC000A145; +pub const STATUS_RUNLEVEL_SWITCH_IN_PROGRESS: NTSTATUS = 0xC000A146; +pub const STATUS_NOT_APPCONTAINER: NTSTATUS = 0xC000A200; +pub const STATUS_NOT_SUPPORTED_IN_APPCONTAINER: NTSTATUS = 0xC000A201; +pub const STATUS_INVALID_PACKAGE_SID_LENGTH: NTSTATUS = 0xC000A202; +pub const STATUS_APP_DATA_NOT_FOUND: NTSTATUS = 0xC000A281; +pub const STATUS_APP_DATA_EXPIRED: NTSTATUS = 0xC000A282; +pub const STATUS_APP_DATA_CORRUPT: NTSTATUS = 0xC000A283; +pub const STATUS_APP_DATA_LIMIT_EXCEEDED: NTSTATUS = 0xC000A284; +pub const STATUS_APP_DATA_REBOOT_REQUIRED: NTSTATUS = 0xC000A285; +pub const STATUS_OFFLOAD_READ_FLT_NOT_SUPPORTED: NTSTATUS = 0xC000A2A1; +pub const STATUS_OFFLOAD_WRITE_FLT_NOT_SUPPORTED: NTSTATUS = 0xC000A2A2; +pub const STATUS_OFFLOAD_READ_FILE_NOT_SUPPORTED: NTSTATUS = 0xC000A2A3; +pub const STATUS_OFFLOAD_WRITE_FILE_NOT_SUPPORTED: NTSTATUS = 0xC000A2A4; +pub const STATUS_CLOUD_FILE_PROVIDER_UNKNOWN: NTSTATUS = 0xC000CF00; +pub const STATUS_CLOUD_FILE_PROVIDER_NOT_RUNNING: NTSTATUS = 0xC000CF01; +pub const STATUS_CLOUD_FILE_METADATA_CORRUPT: NTSTATUS = 0xC000CF02; +pub const STATUS_CLOUD_FILE_METADATA_TOO_LARGE: NTSTATUS = 0xC000CF03; +pub const STATUS_CLOUD_FILE_PROPERTY_BLOB_TOO_LARGE: NTSTATUS = 0x8000CF04; +pub const DBG_NO_STATE_CHANGE: NTSTATUS = 0xC0010001; +pub const DBG_APP_NOT_IDLE: NTSTATUS = 0xC0010002; +pub const RPC_NT_INVALID_STRING_BINDING: NTSTATUS = 0xC0020001; +pub const RPC_NT_WRONG_KIND_OF_BINDING: NTSTATUS = 0xC0020002; +pub const RPC_NT_INVALID_BINDING: NTSTATUS = 0xC0020003; +pub const RPC_NT_PROTSEQ_NOT_SUPPORTED: NTSTATUS = 0xC0020004; +pub const RPC_NT_INVALID_RPC_PROTSEQ: NTSTATUS = 0xC0020005; +pub const RPC_NT_INVALID_STRING_UUID: NTSTATUS = 0xC0020006; +pub const RPC_NT_INVALID_ENDPOINT_FORMAT: NTSTATUS = 0xC0020007; +pub const RPC_NT_INVALID_NET_ADDR: NTSTATUS = 0xC0020008; +pub const RPC_NT_NO_ENDPOINT_FOUND: NTSTATUS = 0xC0020009; +pub const RPC_NT_INVALID_TIMEOUT: NTSTATUS = 0xC002000A; +pub const RPC_NT_OBJECT_NOT_FOUND: NTSTATUS = 0xC002000B; +pub const RPC_NT_ALREADY_REGISTERED: NTSTATUS = 0xC002000C; +pub const RPC_NT_TYPE_ALREADY_REGISTERED: NTSTATUS = 0xC002000D; +pub const RPC_NT_ALREADY_LISTENING: NTSTATUS = 0xC002000E; +pub const RPC_NT_NO_PROTSEQS_REGISTERED: NTSTATUS = 0xC002000F; +pub const RPC_NT_NOT_LISTENING: NTSTATUS = 0xC0020010; +pub const RPC_NT_UNKNOWN_MGR_TYPE: NTSTATUS = 0xC0020011; +pub const RPC_NT_UNKNOWN_IF: NTSTATUS = 0xC0020012; +pub const RPC_NT_NO_BINDINGS: NTSTATUS = 0xC0020013; +pub const RPC_NT_NO_PROTSEQS: NTSTATUS = 0xC0020014; +pub const RPC_NT_CANT_CREATE_ENDPOINT: NTSTATUS = 0xC0020015; +pub const RPC_NT_OUT_OF_RESOURCES: NTSTATUS = 0xC0020016; +pub const RPC_NT_SERVER_UNAVAILABLE: NTSTATUS = 0xC0020017; +pub const RPC_NT_SERVER_TOO_BUSY: NTSTATUS = 0xC0020018; +pub const RPC_NT_INVALID_NETWORK_OPTIONS: NTSTATUS = 0xC0020019; +pub const RPC_NT_NO_CALL_ACTIVE: NTSTATUS = 0xC002001A; +pub const RPC_NT_CALL_FAILED: NTSTATUS = 0xC002001B; +pub const RPC_NT_CALL_FAILED_DNE: NTSTATUS = 0xC002001C; +pub const RPC_NT_PROTOCOL_ERROR: NTSTATUS = 0xC002001D; +pub const RPC_NT_UNSUPPORTED_TRANS_SYN: NTSTATUS = 0xC002001F; +pub const RPC_NT_UNSUPPORTED_TYPE: NTSTATUS = 0xC0020021; +pub const RPC_NT_INVALID_TAG: NTSTATUS = 0xC0020022; +pub const RPC_NT_INVALID_BOUND: NTSTATUS = 0xC0020023; +pub const RPC_NT_NO_ENTRY_NAME: NTSTATUS = 0xC0020024; +pub const RPC_NT_INVALID_NAME_SYNTAX: NTSTATUS = 0xC0020025; +pub const RPC_NT_UNSUPPORTED_NAME_SYNTAX: NTSTATUS = 0xC0020026; +pub const RPC_NT_UUID_NO_ADDRESS: NTSTATUS = 0xC0020028; +pub const RPC_NT_DUPLICATE_ENDPOINT: NTSTATUS = 0xC0020029; +pub const RPC_NT_UNKNOWN_AUTHN_TYPE: NTSTATUS = 0xC002002A; +pub const RPC_NT_MAX_CALLS_TOO_SMALL: NTSTATUS = 0xC002002B; +pub const RPC_NT_STRING_TOO_LONG: NTSTATUS = 0xC002002C; +pub const RPC_NT_PROTSEQ_NOT_FOUND: NTSTATUS = 0xC002002D; +pub const RPC_NT_PROCNUM_OUT_OF_RANGE: NTSTATUS = 0xC002002E; +pub const RPC_NT_BINDING_HAS_NO_AUTH: NTSTATUS = 0xC002002F; +pub const RPC_NT_UNKNOWN_AUTHN_SERVICE: NTSTATUS = 0xC0020030; +pub const RPC_NT_UNKNOWN_AUTHN_LEVEL: NTSTATUS = 0xC0020031; +pub const RPC_NT_INVALID_AUTH_IDENTITY: NTSTATUS = 0xC0020032; +pub const RPC_NT_UNKNOWN_AUTHZ_SERVICE: NTSTATUS = 0xC0020033; +pub const EPT_NT_INVALID_ENTRY: NTSTATUS = 0xC0020034; +pub const EPT_NT_CANT_PERFORM_OP: NTSTATUS = 0xC0020035; +pub const EPT_NT_NOT_REGISTERED: NTSTATUS = 0xC0020036; +pub const RPC_NT_NOTHING_TO_EXPORT: NTSTATUS = 0xC0020037; +pub const RPC_NT_INCOMPLETE_NAME: NTSTATUS = 0xC0020038; +pub const RPC_NT_INVALID_VERS_OPTION: NTSTATUS = 0xC0020039; +pub const RPC_NT_NO_MORE_MEMBERS: NTSTATUS = 0xC002003A; +pub const RPC_NT_NOT_ALL_OBJS_UNEXPORTED: NTSTATUS = 0xC002003B; +pub const RPC_NT_INTERFACE_NOT_FOUND: NTSTATUS = 0xC002003C; +pub const RPC_NT_ENTRY_ALREADY_EXISTS: NTSTATUS = 0xC002003D; +pub const RPC_NT_ENTRY_NOT_FOUND: NTSTATUS = 0xC002003E; +pub const RPC_NT_NAME_SERVICE_UNAVAILABLE: NTSTATUS = 0xC002003F; +pub const RPC_NT_INVALID_NAF_ID: NTSTATUS = 0xC0020040; +pub const RPC_NT_CANNOT_SUPPORT: NTSTATUS = 0xC0020041; +pub const RPC_NT_NO_CONTEXT_AVAILABLE: NTSTATUS = 0xC0020042; +pub const RPC_NT_INTERNAL_ERROR: NTSTATUS = 0xC0020043; +pub const RPC_NT_ZERO_DIVIDE: NTSTATUS = 0xC0020044; +pub const RPC_NT_ADDRESS_ERROR: NTSTATUS = 0xC0020045; +pub const RPC_NT_FP_DIV_ZERO: NTSTATUS = 0xC0020046; +pub const RPC_NT_FP_UNDERFLOW: NTSTATUS = 0xC0020047; +pub const RPC_NT_FP_OVERFLOW: NTSTATUS = 0xC0020048; +pub const RPC_NT_NO_MORE_ENTRIES: NTSTATUS = 0xC0030001; +pub const RPC_NT_SS_CHAR_TRANS_OPEN_FAIL: NTSTATUS = 0xC0030002; +pub const RPC_NT_SS_CHAR_TRANS_SHORT_FILE: NTSTATUS = 0xC0030003; +pub const RPC_NT_SS_IN_NULL_CONTEXT: NTSTATUS = 0xC0030004; +pub const RPC_NT_SS_CONTEXT_MISMATCH: NTSTATUS = 0xC0030005; +pub const RPC_NT_SS_CONTEXT_DAMAGED: NTSTATUS = 0xC0030006; +pub const RPC_NT_SS_HANDLES_MISMATCH: NTSTATUS = 0xC0030007; +pub const RPC_NT_SS_CANNOT_GET_CALL_HANDLE: NTSTATUS = 0xC0030008; +pub const RPC_NT_NULL_REF_POINTER: NTSTATUS = 0xC0030009; +pub const RPC_NT_ENUM_VALUE_OUT_OF_RANGE: NTSTATUS = 0xC003000A; +pub const RPC_NT_BYTE_COUNT_TOO_SMALL: NTSTATUS = 0xC003000B; +pub const RPC_NT_BAD_STUB_DATA: NTSTATUS = 0xC003000C; +pub const RPC_NT_CALL_IN_PROGRESS: NTSTATUS = 0xC0020049; +pub const RPC_NT_NO_MORE_BINDINGS: NTSTATUS = 0xC002004A; +pub const RPC_NT_GROUP_MEMBER_NOT_FOUND: NTSTATUS = 0xC002004B; +pub const EPT_NT_CANT_CREATE: NTSTATUS = 0xC002004C; +pub const RPC_NT_INVALID_OBJECT: NTSTATUS = 0xC002004D; +pub const RPC_NT_NO_INTERFACES: NTSTATUS = 0xC002004F; +pub const RPC_NT_CALL_CANCELLED: NTSTATUS = 0xC0020050; +pub const RPC_NT_BINDING_INCOMPLETE: NTSTATUS = 0xC0020051; +pub const RPC_NT_COMM_FAILURE: NTSTATUS = 0xC0020052; +pub const RPC_NT_UNSUPPORTED_AUTHN_LEVEL: NTSTATUS = 0xC0020053; +pub const RPC_NT_NO_PRINC_NAME: NTSTATUS = 0xC0020054; +pub const RPC_NT_NOT_RPC_ERROR: NTSTATUS = 0xC0020055; +pub const RPC_NT_UUID_LOCAL_ONLY: NTSTATUS = 0x40020056; +pub const RPC_NT_SEC_PKG_ERROR: NTSTATUS = 0xC0020057; +pub const RPC_NT_NOT_CANCELLED: NTSTATUS = 0xC0020058; +pub const RPC_NT_INVALID_ES_ACTION: NTSTATUS = 0xC0030059; +pub const RPC_NT_WRONG_ES_VERSION: NTSTATUS = 0xC003005A; +pub const RPC_NT_WRONG_STUB_VERSION: NTSTATUS = 0xC003005B; +pub const RPC_NT_INVALID_PIPE_OBJECT: NTSTATUS = 0xC003005C; +pub const RPC_NT_INVALID_PIPE_OPERATION: NTSTATUS = 0xC003005D; +pub const RPC_NT_WRONG_PIPE_VERSION: NTSTATUS = 0xC003005E; +pub const RPC_NT_PIPE_CLOSED: NTSTATUS = 0xC003005F; +pub const RPC_NT_PIPE_DISCIPLINE_ERROR: NTSTATUS = 0xC0030060; +pub const RPC_NT_PIPE_EMPTY: NTSTATUS = 0xC0030061; +pub const RPC_NT_INVALID_ASYNC_HANDLE: NTSTATUS = 0xC0020062; +pub const RPC_NT_INVALID_ASYNC_CALL: NTSTATUS = 0xC0020063; +pub const RPC_NT_PROXY_ACCESS_DENIED: NTSTATUS = 0xC0020064; +pub const RPC_NT_COOKIE_AUTH_FAILED: NTSTATUS = 0xC0020065; +pub const RPC_NT_SEND_INCOMPLETE: NTSTATUS = 0x400200AF; +pub const STATUS_ACPI_INVALID_OPCODE: NTSTATUS = 0xC0140001; +pub const STATUS_ACPI_STACK_OVERFLOW: NTSTATUS = 0xC0140002; +pub const STATUS_ACPI_ASSERT_FAILED: NTSTATUS = 0xC0140003; +pub const STATUS_ACPI_INVALID_INDEX: NTSTATUS = 0xC0140004; +pub const STATUS_ACPI_INVALID_ARGUMENT: NTSTATUS = 0xC0140005; +pub const STATUS_ACPI_FATAL: NTSTATUS = 0xC0140006; +pub const STATUS_ACPI_INVALID_SUPERNAME: NTSTATUS = 0xC0140007; +pub const STATUS_ACPI_INVALID_ARGTYPE: NTSTATUS = 0xC0140008; +pub const STATUS_ACPI_INVALID_OBJTYPE: NTSTATUS = 0xC0140009; +pub const STATUS_ACPI_INVALID_TARGETTYPE: NTSTATUS = 0xC014000A; +pub const STATUS_ACPI_INCORRECT_ARGUMENT_COUNT: NTSTATUS = 0xC014000B; +pub const STATUS_ACPI_ADDRESS_NOT_MAPPED: NTSTATUS = 0xC014000C; +pub const STATUS_ACPI_INVALID_EVENTTYPE: NTSTATUS = 0xC014000D; +pub const STATUS_ACPI_HANDLER_COLLISION: NTSTATUS = 0xC014000E; +pub const STATUS_ACPI_INVALID_DATA: NTSTATUS = 0xC014000F; +pub const STATUS_ACPI_INVALID_REGION: NTSTATUS = 0xC0140010; +pub const STATUS_ACPI_INVALID_ACCESS_SIZE: NTSTATUS = 0xC0140011; +pub const STATUS_ACPI_ACQUIRE_GLOBAL_LOCK: NTSTATUS = 0xC0140012; +pub const STATUS_ACPI_ALREADY_INITIALIZED: NTSTATUS = 0xC0140013; +pub const STATUS_ACPI_NOT_INITIALIZED: NTSTATUS = 0xC0140014; +pub const STATUS_ACPI_INVALID_MUTEX_LEVEL: NTSTATUS = 0xC0140015; +pub const STATUS_ACPI_MUTEX_NOT_OWNED: NTSTATUS = 0xC0140016; +pub const STATUS_ACPI_MUTEX_NOT_OWNER: NTSTATUS = 0xC0140017; +pub const STATUS_ACPI_RS_ACCESS: NTSTATUS = 0xC0140018; +pub const STATUS_ACPI_INVALID_TABLE: NTSTATUS = 0xC0140019; +pub const STATUS_ACPI_REG_HANDLER_FAILED: NTSTATUS = 0xC0140020; +pub const STATUS_ACPI_POWER_REQUEST_FAILED: NTSTATUS = 0xC0140021; +pub const STATUS_CTX_WINSTATION_NAME_INVALID: NTSTATUS = 0xC00A0001; +pub const STATUS_CTX_INVALID_PD: NTSTATUS = 0xC00A0002; +pub const STATUS_CTX_PD_NOT_FOUND: NTSTATUS = 0xC00A0003; +pub const STATUS_CTX_CDM_CONNECT: NTSTATUS = 0x400A0004; +pub const STATUS_CTX_CDM_DISCONNECT: NTSTATUS = 0x400A0005; +pub const STATUS_CTX_CLOSE_PENDING: NTSTATUS = 0xC00A0006; +pub const STATUS_CTX_NO_OUTBUF: NTSTATUS = 0xC00A0007; +pub const STATUS_CTX_MODEM_INF_NOT_FOUND: NTSTATUS = 0xC00A0008; +pub const STATUS_CTX_INVALID_MODEMNAME: NTSTATUS = 0xC00A0009; +pub const STATUS_CTX_RESPONSE_ERROR: NTSTATUS = 0xC00A000A; +pub const STATUS_CTX_MODEM_RESPONSE_TIMEOUT: NTSTATUS = 0xC00A000B; +pub const STATUS_CTX_MODEM_RESPONSE_NO_CARRIER: NTSTATUS = 0xC00A000C; +pub const STATUS_CTX_MODEM_RESPONSE_NO_DIALTONE: NTSTATUS = 0xC00A000D; +pub const STATUS_CTX_MODEM_RESPONSE_BUSY: NTSTATUS = 0xC00A000E; +pub const STATUS_CTX_MODEM_RESPONSE_VOICE: NTSTATUS = 0xC00A000F; +pub const STATUS_CTX_TD_ERROR: NTSTATUS = 0xC00A0010; +pub const STATUS_CTX_LICENSE_CLIENT_INVALID: NTSTATUS = 0xC00A0012; +pub const STATUS_CTX_LICENSE_NOT_AVAILABLE: NTSTATUS = 0xC00A0013; +pub const STATUS_CTX_LICENSE_EXPIRED: NTSTATUS = 0xC00A0014; +pub const STATUS_CTX_WINSTATION_NOT_FOUND: NTSTATUS = 0xC00A0015; +pub const STATUS_CTX_WINSTATION_NAME_COLLISION: NTSTATUS = 0xC00A0016; +pub const STATUS_CTX_WINSTATION_BUSY: NTSTATUS = 0xC00A0017; +pub const STATUS_CTX_BAD_VIDEO_MODE: NTSTATUS = 0xC00A0018; +pub const STATUS_CTX_GRAPHICS_INVALID: NTSTATUS = 0xC00A0022; +pub const STATUS_CTX_NOT_CONSOLE: NTSTATUS = 0xC00A0024; +pub const STATUS_CTX_CLIENT_QUERY_TIMEOUT: NTSTATUS = 0xC00A0026; +pub const STATUS_CTX_CONSOLE_DISCONNECT: NTSTATUS = 0xC00A0027; +pub const STATUS_CTX_CONSOLE_CONNECT: NTSTATUS = 0xC00A0028; +pub const STATUS_CTX_SHADOW_DENIED: NTSTATUS = 0xC00A002A; +pub const STATUS_CTX_WINSTATION_ACCESS_DENIED: NTSTATUS = 0xC00A002B; +pub const STATUS_CTX_INVALID_WD: NTSTATUS = 0xC00A002E; +pub const STATUS_CTX_WD_NOT_FOUND: NTSTATUS = 0xC00A002F; +pub const STATUS_CTX_SHADOW_INVALID: NTSTATUS = 0xC00A0030; +pub const STATUS_CTX_SHADOW_DISABLED: NTSTATUS = 0xC00A0031; +pub const STATUS_RDP_PROTOCOL_ERROR: NTSTATUS = 0xC00A0032; +pub const STATUS_CTX_CLIENT_LICENSE_NOT_SET: NTSTATUS = 0xC00A0033; +pub const STATUS_CTX_CLIENT_LICENSE_IN_USE: NTSTATUS = 0xC00A0034; +pub const STATUS_CTX_SHADOW_ENDED_BY_MODE_CHANGE: NTSTATUS = 0xC00A0035; +pub const STATUS_CTX_SHADOW_NOT_RUNNING: NTSTATUS = 0xC00A0036; +pub const STATUS_CTX_LOGON_DISABLED: NTSTATUS = 0xC00A0037; +pub const STATUS_CTX_SECURITY_LAYER_ERROR: NTSTATUS = 0xC00A0038; +pub const STATUS_TS_INCOMPATIBLE_SESSIONS: NTSTATUS = 0xC00A0039; +pub const STATUS_TS_VIDEO_SUBSYSTEM_ERROR: NTSTATUS = 0xC00A003A; +pub const STATUS_PNP_BAD_MPS_TABLE: NTSTATUS = 0xC0040035; +pub const STATUS_PNP_TRANSLATION_FAILED: NTSTATUS = 0xC0040036; +pub const STATUS_PNP_IRQ_TRANSLATION_FAILED: NTSTATUS = 0xC0040037; +pub const STATUS_PNP_INVALID_ID: NTSTATUS = 0xC0040038; +pub const STATUS_IO_REISSUE_AS_CACHED: NTSTATUS = 0xC0040039; +pub const STATUS_MUI_FILE_NOT_FOUND: NTSTATUS = 0xC00B0001; +pub const STATUS_MUI_INVALID_FILE: NTSTATUS = 0xC00B0002; +pub const STATUS_MUI_INVALID_RC_CONFIG: NTSTATUS = 0xC00B0003; +pub const STATUS_MUI_INVALID_LOCALE_NAME: NTSTATUS = 0xC00B0004; +pub const STATUS_MUI_INVALID_ULTIMATEFALLBACK_NAME: NTSTATUS = 0xC00B0005; +pub const STATUS_MUI_FILE_NOT_LOADED: NTSTATUS = 0xC00B0006; +pub const STATUS_RESOURCE_ENUM_USER_STOP: NTSTATUS = 0xC00B0007; +//FILTER_FLT_NTSTATUS_FROM_HRESULT +pub const STATUS_FLT_NO_HANDLER_DEFINED: NTSTATUS = 0xC01C0001; +pub const STATUS_FLT_CONTEXT_ALREADY_DEFINED: NTSTATUS = 0xC01C0002; +pub const STATUS_FLT_INVALID_ASYNCHRONOUS_REQUEST: NTSTATUS = 0xC01C0003; +pub const STATUS_FLT_DISALLOW_FAST_IO: NTSTATUS = 0xC01C0004; +pub const STATUS_FLT_INVALID_NAME_REQUEST: NTSTATUS = 0xC01C0005; +pub const STATUS_FLT_NOT_SAFE_TO_POST_OPERATION: NTSTATUS = 0xC01C0006; +pub const STATUS_FLT_NOT_INITIALIZED: NTSTATUS = 0xC01C0007; +pub const STATUS_FLT_FILTER_NOT_READY: NTSTATUS = 0xC01C0008; +pub const STATUS_FLT_POST_OPERATION_CLEANUP: NTSTATUS = 0xC01C0009; +pub const STATUS_FLT_INTERNAL_ERROR: NTSTATUS = 0xC01C000A; +pub const STATUS_FLT_DELETING_OBJECT: NTSTATUS = 0xC01C000B; +pub const STATUS_FLT_MUST_BE_NONPAGED_POOL: NTSTATUS = 0xC01C000C; +pub const STATUS_FLT_DUPLICATE_ENTRY: NTSTATUS = 0xC01C000D; +pub const STATUS_FLT_CBDQ_DISABLED: NTSTATUS = 0xC01C000E; +pub const STATUS_FLT_DO_NOT_ATTACH: NTSTATUS = 0xC01C000F; +pub const STATUS_FLT_DO_NOT_DETACH: NTSTATUS = 0xC01C0010; +pub const STATUS_FLT_INSTANCE_ALTITUDE_COLLISION: NTSTATUS = 0xC01C0011; +pub const STATUS_FLT_INSTANCE_NAME_COLLISION: NTSTATUS = 0xC01C0012; +pub const STATUS_FLT_FILTER_NOT_FOUND: NTSTATUS = 0xC01C0013; +pub const STATUS_FLT_VOLUME_NOT_FOUND: NTSTATUS = 0xC01C0014; +pub const STATUS_FLT_INSTANCE_NOT_FOUND: NTSTATUS = 0xC01C0015; +pub const STATUS_FLT_CONTEXT_ALLOCATION_NOT_FOUND: NTSTATUS = 0xC01C0016; +pub const STATUS_FLT_INVALID_CONTEXT_REGISTRATION: NTSTATUS = 0xC01C0017; +pub const STATUS_FLT_NAME_CACHE_MISS: NTSTATUS = 0xC01C0018; +pub const STATUS_FLT_NO_DEVICE_OBJECT: NTSTATUS = 0xC01C0019; +pub const STATUS_FLT_VOLUME_ALREADY_MOUNTED: NTSTATUS = 0xC01C001A; +pub const STATUS_FLT_ALREADY_ENLISTED: NTSTATUS = 0xC01C001B; +pub const STATUS_FLT_CONTEXT_ALREADY_LINKED: NTSTATUS = 0xC01C001C; +pub const STATUS_FLT_NO_WAITER_FOR_REPLY: NTSTATUS = 0xC01C0020; +pub const STATUS_FLT_REGISTRATION_BUSY: NTSTATUS = 0xC01C0023; +pub const STATUS_SXS_SECTION_NOT_FOUND: NTSTATUS = 0xC0150001; +pub const STATUS_SXS_CANT_GEN_ACTCTX: NTSTATUS = 0xC0150002; +pub const STATUS_SXS_INVALID_ACTCTXDATA_FORMAT: NTSTATUS = 0xC0150003; +pub const STATUS_SXS_ASSEMBLY_NOT_FOUND: NTSTATUS = 0xC0150004; +pub const STATUS_SXS_MANIFEST_FORMAT_ERROR: NTSTATUS = 0xC0150005; +pub const STATUS_SXS_MANIFEST_PARSE_ERROR: NTSTATUS = 0xC0150006; +pub const STATUS_SXS_ACTIVATION_CONTEXT_DISABLED: NTSTATUS = 0xC0150007; +pub const STATUS_SXS_KEY_NOT_FOUND: NTSTATUS = 0xC0150008; +pub const STATUS_SXS_VERSION_CONFLICT: NTSTATUS = 0xC0150009; +pub const STATUS_SXS_WRONG_SECTION_TYPE: NTSTATUS = 0xC015000A; +pub const STATUS_SXS_THREAD_QUERIES_DISABLED: NTSTATUS = 0xC015000B; +pub const STATUS_SXS_ASSEMBLY_MISSING: NTSTATUS = 0xC015000C; +pub const STATUS_SXS_RELEASE_ACTIVATION_CONTEXT: NTSTATUS = 0x4015000D; +pub const STATUS_SXS_PROCESS_DEFAULT_ALREADY_SET: NTSTATUS = 0xC015000E; +pub const STATUS_SXS_EARLY_DEACTIVATION: NTSTATUS = 0xC015000F; +pub const STATUS_SXS_INVALID_DEACTIVATION: NTSTATUS = 0xC0150010; +pub const STATUS_SXS_MULTIPLE_DEACTIVATION: NTSTATUS = 0xC0150011; +pub const STATUS_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY: NTSTATUS = 0xC0150012; +pub const STATUS_SXS_PROCESS_TERMINATION_REQUESTED: NTSTATUS = 0xC0150013; +pub const STATUS_SXS_CORRUPT_ACTIVATION_STACK: NTSTATUS = 0xC0150014; +pub const STATUS_SXS_CORRUPTION: NTSTATUS = 0xC0150015; +pub const STATUS_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE: NTSTATUS = 0xC0150016; +pub const STATUS_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME: NTSTATUS = 0xC0150017; +pub const STATUS_SXS_IDENTITY_DUPLICATE_ATTRIBUTE: NTSTATUS = 0xC0150018; +pub const STATUS_SXS_IDENTITY_PARSE_ERROR: NTSTATUS = 0xC0150019; +pub const STATUS_SXS_COMPONENT_STORE_CORRUPT: NTSTATUS = 0xC015001A; +pub const STATUS_SXS_FILE_HASH_MISMATCH: NTSTATUS = 0xC015001B; +pub const STATUS_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT: NTSTATUS + = 0xC015001C; +pub const STATUS_SXS_IDENTITIES_DIFFERENT: NTSTATUS = 0xC015001D; +pub const STATUS_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT: NTSTATUS = 0xC015001E; +pub const STATUS_SXS_FILE_NOT_PART_OF_ASSEMBLY: NTSTATUS = 0xC015001F; +pub const STATUS_ADVANCED_INSTALLER_FAILED: NTSTATUS = 0xC0150020; +pub const STATUS_XML_ENCODING_MISMATCH: NTSTATUS = 0xC0150021; +pub const STATUS_SXS_MANIFEST_TOO_BIG: NTSTATUS = 0xC0150022; +pub const STATUS_SXS_SETTING_NOT_REGISTERED: NTSTATUS = 0xC0150023; +pub const STATUS_SXS_TRANSACTION_CLOSURE_INCOMPLETE: NTSTATUS = 0xC0150024; +pub const STATUS_SMI_PRIMITIVE_INSTALLER_FAILED: NTSTATUS = 0xC0150025; +pub const STATUS_GENERIC_COMMAND_FAILED: NTSTATUS = 0xC0150026; +pub const STATUS_SXS_FILE_HASH_MISSING: NTSTATUS = 0xC0150027; +pub const STATUS_CLUSTER_INVALID_NODE: NTSTATUS = 0xC0130001; +pub const STATUS_CLUSTER_NODE_EXISTS: NTSTATUS = 0xC0130002; +pub const STATUS_CLUSTER_JOIN_IN_PROGRESS: NTSTATUS = 0xC0130003; +pub const STATUS_CLUSTER_NODE_NOT_FOUND: NTSTATUS = 0xC0130004; +pub const STATUS_CLUSTER_LOCAL_NODE_NOT_FOUND: NTSTATUS = 0xC0130005; +pub const STATUS_CLUSTER_NETWORK_EXISTS: NTSTATUS = 0xC0130006; +pub const STATUS_CLUSTER_NETWORK_NOT_FOUND: NTSTATUS = 0xC0130007; +pub const STATUS_CLUSTER_NETINTERFACE_EXISTS: NTSTATUS = 0xC0130008; +pub const STATUS_CLUSTER_NETINTERFACE_NOT_FOUND: NTSTATUS = 0xC0130009; +pub const STATUS_CLUSTER_INVALID_REQUEST: NTSTATUS = 0xC013000A; +pub const STATUS_CLUSTER_INVALID_NETWORK_PROVIDER: NTSTATUS = 0xC013000B; +pub const STATUS_CLUSTER_NODE_DOWN: NTSTATUS = 0xC013000C; +pub const STATUS_CLUSTER_NODE_UNREACHABLE: NTSTATUS = 0xC013000D; +pub const STATUS_CLUSTER_NODE_NOT_MEMBER: NTSTATUS = 0xC013000E; +pub const STATUS_CLUSTER_JOIN_NOT_IN_PROGRESS: NTSTATUS = 0xC013000F; +pub const STATUS_CLUSTER_INVALID_NETWORK: NTSTATUS = 0xC0130010; +pub const STATUS_CLUSTER_NO_NET_ADAPTERS: NTSTATUS = 0xC0130011; +pub const STATUS_CLUSTER_NODE_UP: NTSTATUS = 0xC0130012; +pub const STATUS_CLUSTER_NODE_PAUSED: NTSTATUS = 0xC0130013; +pub const STATUS_CLUSTER_NODE_NOT_PAUSED: NTSTATUS = 0xC0130014; +pub const STATUS_CLUSTER_NO_SECURITY_CONTEXT: NTSTATUS = 0xC0130015; +pub const STATUS_CLUSTER_NETWORK_NOT_INTERNAL: NTSTATUS = 0xC0130016; +pub const STATUS_CLUSTER_POISONED: NTSTATUS = 0xC0130017; +pub const STATUS_CLUSTER_NON_CSV_PATH: NTSTATUS = 0xC0130018; +pub const STATUS_CLUSTER_CSV_VOLUME_NOT_LOCAL: NTSTATUS = 0xC0130019; +pub const STATUS_CLUSTER_CSV_READ_OPLOCK_BREAK_IN_PROGRESS: NTSTATUS = 0xC0130020; +pub const STATUS_CLUSTER_CSV_AUTO_PAUSE_ERROR: NTSTATUS = 0xC0130021; +pub const STATUS_CLUSTER_CSV_REDIRECTED: NTSTATUS = 0xC0130022; +pub const STATUS_CLUSTER_CSV_NOT_REDIRECTED: NTSTATUS = 0xC0130023; +pub const STATUS_CLUSTER_CSV_VOLUME_DRAINING: NTSTATUS = 0xC0130024; +pub const STATUS_CLUSTER_CSV_SNAPSHOT_CREATION_IN_PROGRESS: NTSTATUS = 0xC0130025; +pub const STATUS_CLUSTER_CSV_VOLUME_DRAINING_SUCCEEDED_DOWNLEVEL: NTSTATUS = 0xC0130026; +pub const STATUS_CLUSTER_CSV_NO_SNAPSHOTS: NTSTATUS = 0xC0130027; +pub const STATUS_CSV_IO_PAUSE_TIMEOUT: NTSTATUS = 0xC0130028; +pub const STATUS_CLUSTER_CSV_INVALID_HANDLE: NTSTATUS = 0xC0130029; +pub const STATUS_CLUSTER_CSV_SUPPORTED_ONLY_ON_COORDINATOR: NTSTATUS = 0xC0130030; +pub const STATUS_TRANSACTIONAL_CONFLICT: NTSTATUS = 0xC0190001; +pub const STATUS_INVALID_TRANSACTION: NTSTATUS = 0xC0190002; +pub const STATUS_TRANSACTION_NOT_ACTIVE: NTSTATUS = 0xC0190003; +pub const STATUS_TM_INITIALIZATION_FAILED: NTSTATUS = 0xC0190004; +pub const STATUS_RM_NOT_ACTIVE: NTSTATUS = 0xC0190005; +pub const STATUS_RM_METADATA_CORRUPT: NTSTATUS = 0xC0190006; +pub const STATUS_TRANSACTION_NOT_JOINED: NTSTATUS = 0xC0190007; +pub const STATUS_DIRECTORY_NOT_RM: NTSTATUS = 0xC0190008; +pub const STATUS_COULD_NOT_RESIZE_LOG: NTSTATUS = 0x80190009; +pub const STATUS_TRANSACTIONS_UNSUPPORTED_REMOTE: NTSTATUS = 0xC019000A; +pub const STATUS_LOG_RESIZE_INVALID_SIZE: NTSTATUS = 0xC019000B; +pub const STATUS_REMOTE_FILE_VERSION_MISMATCH: NTSTATUS = 0xC019000C; +pub const STATUS_CRM_PROTOCOL_ALREADY_EXISTS: NTSTATUS = 0xC019000F; +pub const STATUS_TRANSACTION_PROPAGATION_FAILED: NTSTATUS = 0xC0190010; +pub const STATUS_CRM_PROTOCOL_NOT_FOUND: NTSTATUS = 0xC0190011; +pub const STATUS_TRANSACTION_SUPERIOR_EXISTS: NTSTATUS = 0xC0190012; +pub const STATUS_TRANSACTION_REQUEST_NOT_VALID: NTSTATUS = 0xC0190013; +pub const STATUS_TRANSACTION_NOT_REQUESTED: NTSTATUS = 0xC0190014; +pub const STATUS_TRANSACTION_ALREADY_ABORTED: NTSTATUS = 0xC0190015; +pub const STATUS_TRANSACTION_ALREADY_COMMITTED: NTSTATUS = 0xC0190016; +pub const STATUS_TRANSACTION_INVALID_MARSHALL_BUFFER: NTSTATUS = 0xC0190017; +pub const STATUS_CURRENT_TRANSACTION_NOT_VALID: NTSTATUS = 0xC0190018; +pub const STATUS_LOG_GROWTH_FAILED: NTSTATUS = 0xC0190019; +pub const STATUS_OBJECT_NO_LONGER_EXISTS: NTSTATUS = 0xC0190021; +pub const STATUS_STREAM_MINIVERSION_NOT_FOUND: NTSTATUS = 0xC0190022; +pub const STATUS_STREAM_MINIVERSION_NOT_VALID: NTSTATUS = 0xC0190023; +pub const STATUS_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION: NTSTATUS + = 0xC0190024; +pub const STATUS_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT: NTSTATUS = 0xC0190025; +pub const STATUS_CANT_CREATE_MORE_STREAM_MINIVERSIONS: NTSTATUS = 0xC0190026; +pub const STATUS_HANDLE_NO_LONGER_VALID: NTSTATUS = 0xC0190028; +pub const STATUS_NO_TXF_METADATA: NTSTATUS = 0x80190029; +pub const STATUS_LOG_CORRUPTION_DETECTED: NTSTATUS = 0xC0190030; +pub const STATUS_CANT_RECOVER_WITH_HANDLE_OPEN: NTSTATUS = 0x80190031; +pub const STATUS_RM_DISCONNECTED: NTSTATUS = 0xC0190032; +pub const STATUS_ENLISTMENT_NOT_SUPERIOR: NTSTATUS = 0xC0190033; +pub const STATUS_RECOVERY_NOT_NEEDED: NTSTATUS = 0x40190034; +pub const STATUS_RM_ALREADY_STARTED: NTSTATUS = 0x40190035; +pub const STATUS_FILE_IDENTITY_NOT_PERSISTENT: NTSTATUS = 0xC0190036; +pub const STATUS_CANT_BREAK_TRANSACTIONAL_DEPENDENCY: NTSTATUS = 0xC0190037; +pub const STATUS_CANT_CROSS_RM_BOUNDARY: NTSTATUS = 0xC0190038; +pub const STATUS_TXF_DIR_NOT_EMPTY: NTSTATUS = 0xC0190039; +pub const STATUS_INDOUBT_TRANSACTIONS_EXIST: NTSTATUS = 0xC019003A; +pub const STATUS_TM_VOLATILE: NTSTATUS = 0xC019003B; +pub const STATUS_ROLLBACK_TIMER_EXPIRED: NTSTATUS = 0xC019003C; +pub const STATUS_TXF_ATTRIBUTE_CORRUPT: NTSTATUS = 0xC019003D; +pub const STATUS_EFS_NOT_ALLOWED_IN_TRANSACTION: NTSTATUS = 0xC019003E; +pub const STATUS_TRANSACTIONAL_OPEN_NOT_ALLOWED: NTSTATUS = 0xC019003F; +pub const STATUS_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE: NTSTATUS = 0xC0190040; +pub const STATUS_TXF_METADATA_ALREADY_PRESENT: NTSTATUS = 0x80190041; +pub const STATUS_TRANSACTION_SCOPE_CALLBACKS_NOT_SET: NTSTATUS = 0x80190042; +pub const STATUS_TRANSACTION_REQUIRED_PROMOTION: NTSTATUS = 0xC0190043; +pub const STATUS_CANNOT_EXECUTE_FILE_IN_TRANSACTION: NTSTATUS = 0xC0190044; +pub const STATUS_TRANSACTIONS_NOT_FROZEN: NTSTATUS = 0xC0190045; +pub const STATUS_TRANSACTION_FREEZE_IN_PROGRESS: NTSTATUS = 0xC0190046; +pub const STATUS_NOT_SNAPSHOT_VOLUME: NTSTATUS = 0xC0190047; +pub const STATUS_NO_SAVEPOINT_WITH_OPEN_FILES: NTSTATUS = 0xC0190048; +pub const STATUS_SPARSE_NOT_ALLOWED_IN_TRANSACTION: NTSTATUS = 0xC0190049; +pub const STATUS_TM_IDENTITY_MISMATCH: NTSTATUS = 0xC019004A; +pub const STATUS_FLOATED_SECTION: NTSTATUS = 0xC019004B; +pub const STATUS_CANNOT_ACCEPT_TRANSACTED_WORK: NTSTATUS = 0xC019004C; +pub const STATUS_CANNOT_ABORT_TRANSACTIONS: NTSTATUS = 0xC019004D; +pub const STATUS_TRANSACTION_NOT_FOUND: NTSTATUS = 0xC019004E; +pub const STATUS_RESOURCEMANAGER_NOT_FOUND: NTSTATUS = 0xC019004F; +pub const STATUS_ENLISTMENT_NOT_FOUND: NTSTATUS = 0xC0190050; +pub const STATUS_TRANSACTIONMANAGER_NOT_FOUND: NTSTATUS = 0xC0190051; +pub const STATUS_TRANSACTIONMANAGER_NOT_ONLINE: NTSTATUS = 0xC0190052; +pub const STATUS_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION: NTSTATUS = 0xC0190053; +pub const STATUS_TRANSACTION_NOT_ROOT: NTSTATUS = 0xC0190054; +pub const STATUS_TRANSACTION_OBJECT_EXPIRED: NTSTATUS = 0xC0190055; +pub const STATUS_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION: NTSTATUS = 0xC0190056; +pub const STATUS_TRANSACTION_RESPONSE_NOT_ENLISTED: NTSTATUS = 0xC0190057; +pub const STATUS_TRANSACTION_RECORD_TOO_LONG: NTSTATUS = 0xC0190058; +pub const STATUS_NO_LINK_TRACKING_IN_TRANSACTION: NTSTATUS = 0xC0190059; +pub const STATUS_OPERATION_NOT_SUPPORTED_IN_TRANSACTION: NTSTATUS = 0xC019005A; +pub const STATUS_TRANSACTION_INTEGRITY_VIOLATED: NTSTATUS = 0xC019005B; +pub const STATUS_TRANSACTIONMANAGER_IDENTITY_MISMATCH: NTSTATUS = 0xC019005C; +pub const STATUS_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT: NTSTATUS = 0xC019005D; +pub const STATUS_TRANSACTION_MUST_WRITETHROUGH: NTSTATUS = 0xC019005E; +pub const STATUS_TRANSACTION_NO_SUPERIOR: NTSTATUS = 0xC019005F; +pub const STATUS_EXPIRED_HANDLE: NTSTATUS = 0xC0190060; +pub const STATUS_TRANSACTION_NOT_ENLISTED: NTSTATUS = 0xC0190061; +pub const STATUS_LOG_SECTOR_INVALID: NTSTATUS = 0xC01A0001; +pub const STATUS_LOG_SECTOR_PARITY_INVALID: NTSTATUS = 0xC01A0002; +pub const STATUS_LOG_SECTOR_REMAPPED: NTSTATUS = 0xC01A0003; +pub const STATUS_LOG_BLOCK_INCOMPLETE: NTSTATUS = 0xC01A0004; +pub const STATUS_LOG_INVALID_RANGE: NTSTATUS = 0xC01A0005; +pub const STATUS_LOG_BLOCKS_EXHAUSTED: NTSTATUS = 0xC01A0006; +pub const STATUS_LOG_READ_CONTEXT_INVALID: NTSTATUS = 0xC01A0007; +pub const STATUS_LOG_RESTART_INVALID: NTSTATUS = 0xC01A0008; +pub const STATUS_LOG_BLOCK_VERSION: NTSTATUS = 0xC01A0009; +pub const STATUS_LOG_BLOCK_INVALID: NTSTATUS = 0xC01A000A; +pub const STATUS_LOG_READ_MODE_INVALID: NTSTATUS = 0xC01A000B; +pub const STATUS_LOG_NO_RESTART: NTSTATUS = 0x401A000C; +pub const STATUS_LOG_METADATA_CORRUPT: NTSTATUS = 0xC01A000D; +pub const STATUS_LOG_METADATA_INVALID: NTSTATUS = 0xC01A000E; +pub const STATUS_LOG_METADATA_INCONSISTENT: NTSTATUS = 0xC01A000F; +pub const STATUS_LOG_RESERVATION_INVALID: NTSTATUS = 0xC01A0010; +pub const STATUS_LOG_CANT_DELETE: NTSTATUS = 0xC01A0011; +pub const STATUS_LOG_CONTAINER_LIMIT_EXCEEDED: NTSTATUS = 0xC01A0012; +pub const STATUS_LOG_START_OF_LOG: NTSTATUS = 0xC01A0013; +pub const STATUS_LOG_POLICY_ALREADY_INSTALLED: NTSTATUS = 0xC01A0014; +pub const STATUS_LOG_POLICY_NOT_INSTALLED: NTSTATUS = 0xC01A0015; +pub const STATUS_LOG_POLICY_INVALID: NTSTATUS = 0xC01A0016; +pub const STATUS_LOG_POLICY_CONFLICT: NTSTATUS = 0xC01A0017; +pub const STATUS_LOG_PINNED_ARCHIVE_TAIL: NTSTATUS = 0xC01A0018; +pub const STATUS_LOG_RECORD_NONEXISTENT: NTSTATUS = 0xC01A0019; +pub const STATUS_LOG_RECORDS_RESERVED_INVALID: NTSTATUS = 0xC01A001A; +pub const STATUS_LOG_SPACE_RESERVED_INVALID: NTSTATUS = 0xC01A001B; +pub const STATUS_LOG_TAIL_INVALID: NTSTATUS = 0xC01A001C; +pub const STATUS_LOG_FULL: NTSTATUS = 0xC01A001D; +pub const STATUS_LOG_MULTIPLEXED: NTSTATUS = 0xC01A001E; +pub const STATUS_LOG_DEDICATED: NTSTATUS = 0xC01A001F; +pub const STATUS_LOG_ARCHIVE_NOT_IN_PROGRESS: NTSTATUS = 0xC01A0020; +pub const STATUS_LOG_ARCHIVE_IN_PROGRESS: NTSTATUS = 0xC01A0021; +pub const STATUS_LOG_EPHEMERAL: NTSTATUS = 0xC01A0022; +pub const STATUS_LOG_NOT_ENOUGH_CONTAINERS: NTSTATUS = 0xC01A0023; +pub const STATUS_LOG_CLIENT_ALREADY_REGISTERED: NTSTATUS = 0xC01A0024; +pub const STATUS_LOG_CLIENT_NOT_REGISTERED: NTSTATUS = 0xC01A0025; +pub const STATUS_LOG_FULL_HANDLER_IN_PROGRESS: NTSTATUS = 0xC01A0026; +pub const STATUS_LOG_CONTAINER_READ_FAILED: NTSTATUS = 0xC01A0027; +pub const STATUS_LOG_CONTAINER_WRITE_FAILED: NTSTATUS = 0xC01A0028; +pub const STATUS_LOG_CONTAINER_OPEN_FAILED: NTSTATUS = 0xC01A0029; +pub const STATUS_LOG_CONTAINER_STATE_INVALID: NTSTATUS = 0xC01A002A; +pub const STATUS_LOG_STATE_INVALID: NTSTATUS = 0xC01A002B; +pub const STATUS_LOG_PINNED: NTSTATUS = 0xC01A002C; +pub const STATUS_LOG_METADATA_FLUSH_FAILED: NTSTATUS = 0xC01A002D; +pub const STATUS_LOG_INCONSISTENT_SECURITY: NTSTATUS = 0xC01A002E; +pub const STATUS_LOG_APPENDED_FLUSH_FAILED: NTSTATUS = 0xC01A002F; +pub const STATUS_LOG_PINNED_RESERVATION: NTSTATUS = 0xC01A0030; +pub const STATUS_VIDEO_HUNG_DISPLAY_DRIVER_THREAD: NTSTATUS = 0xC01B00EA; +pub const STATUS_VIDEO_HUNG_DISPLAY_DRIVER_THREAD_RECOVERED: NTSTATUS = 0x801B00EB; +pub const STATUS_VIDEO_DRIVER_DEBUG_REPORT_REQUEST: NTSTATUS = 0x401B00EC; +pub const STATUS_MONITOR_NO_DESCRIPTOR: NTSTATUS = 0xC01D0001; +pub const STATUS_MONITOR_UNKNOWN_DESCRIPTOR_FORMAT: NTSTATUS = 0xC01D0002; +pub const STATUS_MONITOR_INVALID_DESCRIPTOR_CHECKSUM: NTSTATUS = 0xC01D0003; +pub const STATUS_MONITOR_INVALID_STANDARD_TIMING_BLOCK: NTSTATUS = 0xC01D0004; +pub const STATUS_MONITOR_WMI_DATABLOCK_REGISTRATION_FAILED: NTSTATUS = 0xC01D0005; +pub const STATUS_MONITOR_INVALID_SERIAL_NUMBER_MONDSC_BLOCK: NTSTATUS = 0xC01D0006; +pub const STATUS_MONITOR_INVALID_USER_FRIENDLY_MONDSC_BLOCK: NTSTATUS = 0xC01D0007; +pub const STATUS_MONITOR_NO_MORE_DESCRIPTOR_DATA: NTSTATUS = 0xC01D0008; +pub const STATUS_MONITOR_INVALID_DETAILED_TIMING_BLOCK: NTSTATUS = 0xC01D0009; +pub const STATUS_MONITOR_INVALID_MANUFACTURE_DATE: NTSTATUS = 0xC01D000A; +pub const STATUS_GRAPHICS_NOT_EXCLUSIVE_MODE_OWNER: NTSTATUS = 0xC01E0000; +pub const STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER: NTSTATUS = 0xC01E0001; +pub const STATUS_GRAPHICS_INVALID_DISPLAY_ADAPTER: NTSTATUS = 0xC01E0002; +pub const STATUS_GRAPHICS_ADAPTER_WAS_RESET: NTSTATUS = 0xC01E0003; +pub const STATUS_GRAPHICS_INVALID_DRIVER_MODEL: NTSTATUS = 0xC01E0004; +pub const STATUS_GRAPHICS_PRESENT_MODE_CHANGED: NTSTATUS = 0xC01E0005; +pub const STATUS_GRAPHICS_PRESENT_OCCLUDED: NTSTATUS = 0xC01E0006; +pub const STATUS_GRAPHICS_PRESENT_DENIED: NTSTATUS = 0xC01E0007; +pub const STATUS_GRAPHICS_CANNOTCOLORCONVERT: NTSTATUS = 0xC01E0008; +pub const STATUS_GRAPHICS_DRIVER_MISMATCH: NTSTATUS = 0xC01E0009; +pub const STATUS_GRAPHICS_PARTIAL_DATA_POPULATED: NTSTATUS = 0x401E000A; +pub const STATUS_GRAPHICS_PRESENT_REDIRECTION_DISABLED: NTSTATUS = 0xC01E000B; +pub const STATUS_GRAPHICS_PRESENT_UNOCCLUDED: NTSTATUS = 0xC01E000C; +pub const STATUS_GRAPHICS_WINDOWDC_NOT_AVAILABLE: NTSTATUS = 0xC01E000D; +pub const STATUS_GRAPHICS_WINDOWLESS_PRESENT_DISABLED: NTSTATUS = 0xC01E000E; +pub const STATUS_GRAPHICS_NO_VIDEO_MEMORY: NTSTATUS = 0xC01E0100; +pub const STATUS_GRAPHICS_CANT_LOCK_MEMORY: NTSTATUS = 0xC01E0101; +pub const STATUS_GRAPHICS_ALLOCATION_BUSY: NTSTATUS = 0xC01E0102; +pub const STATUS_GRAPHICS_TOO_MANY_REFERENCES: NTSTATUS = 0xC01E0103; +pub const STATUS_GRAPHICS_TRY_AGAIN_LATER: NTSTATUS = 0xC01E0104; +pub const STATUS_GRAPHICS_TRY_AGAIN_NOW: NTSTATUS = 0xC01E0105; +pub const STATUS_GRAPHICS_ALLOCATION_INVALID: NTSTATUS = 0xC01E0106; +pub const STATUS_GRAPHICS_UNSWIZZLING_APERTURE_UNAVAILABLE: NTSTATUS = 0xC01E0107; +pub const STATUS_GRAPHICS_UNSWIZZLING_APERTURE_UNSUPPORTED: NTSTATUS = 0xC01E0108; +pub const STATUS_GRAPHICS_CANT_EVICT_PINNED_ALLOCATION: NTSTATUS = 0xC01E0109; +pub const STATUS_GRAPHICS_INVALID_ALLOCATION_USAGE: NTSTATUS = 0xC01E0110; +pub const STATUS_GRAPHICS_CANT_RENDER_LOCKED_ALLOCATION: NTSTATUS = 0xC01E0111; +pub const STATUS_GRAPHICS_ALLOCATION_CLOSED: NTSTATUS = 0xC01E0112; +pub const STATUS_GRAPHICS_INVALID_ALLOCATION_INSTANCE: NTSTATUS = 0xC01E0113; +pub const STATUS_GRAPHICS_INVALID_ALLOCATION_HANDLE: NTSTATUS = 0xC01E0114; +pub const STATUS_GRAPHICS_WRONG_ALLOCATION_DEVICE: NTSTATUS = 0xC01E0115; +pub const STATUS_GRAPHICS_ALLOCATION_CONTENT_LOST: NTSTATUS = 0xC01E0116; +pub const STATUS_GRAPHICS_GPU_EXCEPTION_ON_DEVICE: NTSTATUS = 0xC01E0200; +pub const STATUS_GRAPHICS_SKIP_ALLOCATION_PREPARATION: NTSTATUS = 0x401E0201; +pub const STATUS_GRAPHICS_INVALID_VIDPN_TOPOLOGY: NTSTATUS = 0xC01E0300; +pub const STATUS_GRAPHICS_VIDPN_TOPOLOGY_NOT_SUPPORTED: NTSTATUS = 0xC01E0301; +pub const STATUS_GRAPHICS_VIDPN_TOPOLOGY_CURRENTLY_NOT_SUPPORTED: NTSTATUS = 0xC01E0302; +pub const STATUS_GRAPHICS_INVALID_VIDPN: NTSTATUS = 0xC01E0303; +pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE: NTSTATUS = 0xC01E0304; +pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET: NTSTATUS = 0xC01E0305; +pub const STATUS_GRAPHICS_VIDPN_MODALITY_NOT_SUPPORTED: NTSTATUS = 0xC01E0306; +pub const STATUS_GRAPHICS_MODE_NOT_PINNED: NTSTATUS = 0x401E0307; +pub const STATUS_GRAPHICS_INVALID_VIDPN_SOURCEMODESET: NTSTATUS = 0xC01E0308; +pub const STATUS_GRAPHICS_INVALID_VIDPN_TARGETMODESET: NTSTATUS = 0xC01E0309; +pub const STATUS_GRAPHICS_INVALID_FREQUENCY: NTSTATUS = 0xC01E030A; +pub const STATUS_GRAPHICS_INVALID_ACTIVE_REGION: NTSTATUS = 0xC01E030B; +pub const STATUS_GRAPHICS_INVALID_TOTAL_REGION: NTSTATUS = 0xC01E030C; +pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE_MODE: NTSTATUS = 0xC01E0310; +pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET_MODE: NTSTATUS = 0xC01E0311; +pub const STATUS_GRAPHICS_PINNED_MODE_MUST_REMAIN_IN_SET: NTSTATUS = 0xC01E0312; +pub const STATUS_GRAPHICS_PATH_ALREADY_IN_TOPOLOGY: NTSTATUS = 0xC01E0313; +pub const STATUS_GRAPHICS_MODE_ALREADY_IN_MODESET: NTSTATUS = 0xC01E0314; +pub const STATUS_GRAPHICS_INVALID_VIDEOPRESENTSOURCESET: NTSTATUS = 0xC01E0315; +pub const STATUS_GRAPHICS_INVALID_VIDEOPRESENTTARGETSET: NTSTATUS = 0xC01E0316; +pub const STATUS_GRAPHICS_SOURCE_ALREADY_IN_SET: NTSTATUS = 0xC01E0317; +pub const STATUS_GRAPHICS_TARGET_ALREADY_IN_SET: NTSTATUS = 0xC01E0318; +pub const STATUS_GRAPHICS_INVALID_VIDPN_PRESENT_PATH: NTSTATUS = 0xC01E0319; +pub const STATUS_GRAPHICS_NO_RECOMMENDED_VIDPN_TOPOLOGY: NTSTATUS = 0xC01E031A; +pub const STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGESET: NTSTATUS = 0xC01E031B; +pub const STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE: NTSTATUS = 0xC01E031C; +pub const STATUS_GRAPHICS_FREQUENCYRANGE_NOT_IN_SET: NTSTATUS = 0xC01E031D; +pub const STATUS_GRAPHICS_NO_PREFERRED_MODE: NTSTATUS = 0x401E031E; +pub const STATUS_GRAPHICS_FREQUENCYRANGE_ALREADY_IN_SET: NTSTATUS = 0xC01E031F; +pub const STATUS_GRAPHICS_STALE_MODESET: NTSTATUS = 0xC01E0320; +pub const STATUS_GRAPHICS_INVALID_MONITOR_SOURCEMODESET: NTSTATUS = 0xC01E0321; +pub const STATUS_GRAPHICS_INVALID_MONITOR_SOURCE_MODE: NTSTATUS = 0xC01E0322; +pub const STATUS_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN: NTSTATUS = 0xC01E0323; +pub const STATUS_GRAPHICS_MODE_ID_MUST_BE_UNIQUE: NTSTATUS = 0xC01E0324; +pub const STATUS_GRAPHICS_EMPTY_ADAPTER_MONITOR_MODE_SUPPORT_INTERSECTION: NTSTATUS + = 0xC01E0325; +pub const STATUS_GRAPHICS_VIDEO_PRESENT_TARGETS_LESS_THAN_SOURCES: NTSTATUS = 0xC01E0326; +pub const STATUS_GRAPHICS_PATH_NOT_IN_TOPOLOGY: NTSTATUS = 0xC01E0327; +pub const STATUS_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_SOURCE: NTSTATUS = 0xC01E0328; +pub const STATUS_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_TARGET: NTSTATUS = 0xC01E0329; +pub const STATUS_GRAPHICS_INVALID_MONITORDESCRIPTORSET: NTSTATUS = 0xC01E032A; +pub const STATUS_GRAPHICS_INVALID_MONITORDESCRIPTOR: NTSTATUS = 0xC01E032B; +pub const STATUS_GRAPHICS_MONITORDESCRIPTOR_NOT_IN_SET: NTSTATUS = 0xC01E032C; +pub const STATUS_GRAPHICS_MONITORDESCRIPTOR_ALREADY_IN_SET: NTSTATUS = 0xC01E032D; +pub const STATUS_GRAPHICS_MONITORDESCRIPTOR_ID_MUST_BE_UNIQUE: NTSTATUS = 0xC01E032E; +pub const STATUS_GRAPHICS_INVALID_VIDPN_TARGET_SUBSET_TYPE: NTSTATUS = 0xC01E032F; +pub const STATUS_GRAPHICS_RESOURCES_NOT_RELATED: NTSTATUS = 0xC01E0330; +pub const STATUS_GRAPHICS_SOURCE_ID_MUST_BE_UNIQUE: NTSTATUS = 0xC01E0331; +pub const STATUS_GRAPHICS_TARGET_ID_MUST_BE_UNIQUE: NTSTATUS = 0xC01E0332; +pub const STATUS_GRAPHICS_NO_AVAILABLE_VIDPN_TARGET: NTSTATUS = 0xC01E0333; +pub const STATUS_GRAPHICS_MONITOR_COULD_NOT_BE_ASSOCIATED_WITH_ADAPTER: NTSTATUS + = 0xC01E0334; +pub const STATUS_GRAPHICS_NO_VIDPNMGR: NTSTATUS = 0xC01E0335; +pub const STATUS_GRAPHICS_NO_ACTIVE_VIDPN: NTSTATUS = 0xC01E0336; +pub const STATUS_GRAPHICS_STALE_VIDPN_TOPOLOGY: NTSTATUS = 0xC01E0337; +pub const STATUS_GRAPHICS_MONITOR_NOT_CONNECTED: NTSTATUS = 0xC01E0338; +pub const STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY: NTSTATUS = 0xC01E0339; +pub const STATUS_GRAPHICS_INVALID_PRIMARYSURFACE_SIZE: NTSTATUS = 0xC01E033A; +pub const STATUS_GRAPHICS_INVALID_VISIBLEREGION_SIZE: NTSTATUS = 0xC01E033B; +pub const STATUS_GRAPHICS_INVALID_STRIDE: NTSTATUS = 0xC01E033C; +pub const STATUS_GRAPHICS_INVALID_PIXELFORMAT: NTSTATUS = 0xC01E033D; +pub const STATUS_GRAPHICS_INVALID_COLORBASIS: NTSTATUS = 0xC01E033E; +pub const STATUS_GRAPHICS_INVALID_PIXELVALUEACCESSMODE: NTSTATUS = 0xC01E033F; +pub const STATUS_GRAPHICS_TARGET_NOT_IN_TOPOLOGY: NTSTATUS = 0xC01E0340; +pub const STATUS_GRAPHICS_NO_DISPLAY_MODE_MANAGEMENT_SUPPORT: NTSTATUS = 0xC01E0341; +pub const STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE: NTSTATUS = 0xC01E0342; +pub const STATUS_GRAPHICS_CANT_ACCESS_ACTIVE_VIDPN: NTSTATUS = 0xC01E0343; +pub const STATUS_GRAPHICS_INVALID_PATH_IMPORTANCE_ORDINAL: NTSTATUS = 0xC01E0344; +pub const STATUS_GRAPHICS_INVALID_PATH_CONTENT_GEOMETRY_TRANSFORMATION: NTSTATUS + = 0xC01E0345; +pub const STATUS_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_SUPPORTED: NTSTATUS + = 0xC01E0346; +pub const STATUS_GRAPHICS_INVALID_GAMMA_RAMP: NTSTATUS = 0xC01E0347; +pub const STATUS_GRAPHICS_GAMMA_RAMP_NOT_SUPPORTED: NTSTATUS = 0xC01E0348; +pub const STATUS_GRAPHICS_MULTISAMPLING_NOT_SUPPORTED: NTSTATUS = 0xC01E0349; +pub const STATUS_GRAPHICS_MODE_NOT_IN_MODESET: NTSTATUS = 0xC01E034A; +pub const STATUS_GRAPHICS_DATASET_IS_EMPTY: NTSTATUS = 0x401E034B; +pub const STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET: NTSTATUS = 0x401E034C; +pub const STATUS_GRAPHICS_INVALID_VIDPN_TOPOLOGY_RECOMMENDATION_REASON: NTSTATUS + = 0xC01E034D; +pub const STATUS_GRAPHICS_INVALID_PATH_CONTENT_TYPE: NTSTATUS = 0xC01E034E; +pub const STATUS_GRAPHICS_INVALID_COPYPROTECTION_TYPE: NTSTATUS = 0xC01E034F; +pub const STATUS_GRAPHICS_UNASSIGNED_MODESET_ALREADY_EXISTS: NTSTATUS = 0xC01E0350; +pub const STATUS_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_PINNED: NTSTATUS = 0x401E0351; +pub const STATUS_GRAPHICS_INVALID_SCANLINE_ORDERING: NTSTATUS = 0xC01E0352; +pub const STATUS_GRAPHICS_TOPOLOGY_CHANGES_NOT_ALLOWED: NTSTATUS = 0xC01E0353; +pub const STATUS_GRAPHICS_NO_AVAILABLE_IMPORTANCE_ORDINALS: NTSTATUS = 0xC01E0354; +pub const STATUS_GRAPHICS_INCOMPATIBLE_PRIVATE_FORMAT: NTSTATUS = 0xC01E0355; +pub const STATUS_GRAPHICS_INVALID_MODE_PRUNING_ALGORITHM: NTSTATUS = 0xC01E0356; +pub const STATUS_GRAPHICS_INVALID_MONITOR_CAPABILITY_ORIGIN: NTSTATUS = 0xC01E0357; +pub const STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE_CONSTRAINT: NTSTATUS + = 0xC01E0358; +pub const STATUS_GRAPHICS_MAX_NUM_PATHS_REACHED: NTSTATUS = 0xC01E0359; +pub const STATUS_GRAPHICS_CANCEL_VIDPN_TOPOLOGY_AUGMENTATION: NTSTATUS = 0xC01E035A; +pub const STATUS_GRAPHICS_INVALID_CLIENT_TYPE: NTSTATUS = 0xC01E035B; +pub const STATUS_GRAPHICS_CLIENTVIDPN_NOT_SET: NTSTATUS = 0xC01E035C; +pub const STATUS_GRAPHICS_SPECIFIED_CHILD_ALREADY_CONNECTED: NTSTATUS = 0xC01E0400; +pub const STATUS_GRAPHICS_CHILD_DESCRIPTOR_NOT_SUPPORTED: NTSTATUS = 0xC01E0401; +pub const STATUS_GRAPHICS_UNKNOWN_CHILD_STATUS: NTSTATUS = 0x401E042F; +pub const STATUS_GRAPHICS_NOT_A_LINKED_ADAPTER: NTSTATUS = 0xC01E0430; +pub const STATUS_GRAPHICS_LEADLINK_NOT_ENUMERATED: NTSTATUS = 0xC01E0431; +pub const STATUS_GRAPHICS_CHAINLINKS_NOT_ENUMERATED: NTSTATUS = 0xC01E0432; +pub const STATUS_GRAPHICS_ADAPTER_CHAIN_NOT_READY: NTSTATUS = 0xC01E0433; +pub const STATUS_GRAPHICS_CHAINLINKS_NOT_STARTED: NTSTATUS = 0xC01E0434; +pub const STATUS_GRAPHICS_CHAINLINKS_NOT_POWERED_ON: NTSTATUS = 0xC01E0435; +pub const STATUS_GRAPHICS_INCONSISTENT_DEVICE_LINK_STATE: NTSTATUS = 0xC01E0436; +pub const STATUS_GRAPHICS_LEADLINK_START_DEFERRED: NTSTATUS = 0x401E0437; +pub const STATUS_GRAPHICS_NOT_POST_DEVICE_DRIVER: NTSTATUS = 0xC01E0438; +pub const STATUS_GRAPHICS_POLLING_TOO_FREQUENTLY: NTSTATUS = 0x401E0439; +pub const STATUS_GRAPHICS_START_DEFERRED: NTSTATUS = 0x401E043A; +pub const STATUS_GRAPHICS_ADAPTER_ACCESS_NOT_EXCLUDED: NTSTATUS = 0xC01E043B; +pub const STATUS_GRAPHICS_DEPENDABLE_CHILD_STATUS: NTSTATUS = 0x401E043C; +pub const STATUS_GRAPHICS_OPM_NOT_SUPPORTED: NTSTATUS = 0xC01E0500; +pub const STATUS_GRAPHICS_COPP_NOT_SUPPORTED: NTSTATUS = 0xC01E0501; +pub const STATUS_GRAPHICS_UAB_NOT_SUPPORTED: NTSTATUS = 0xC01E0502; +pub const STATUS_GRAPHICS_OPM_INVALID_ENCRYPTED_PARAMETERS: NTSTATUS = 0xC01E0503; +pub const STATUS_GRAPHICS_OPM_NO_PROTECTED_OUTPUTS_EXIST: NTSTATUS = 0xC01E0505; +pub const STATUS_GRAPHICS_OPM_INTERNAL_ERROR: NTSTATUS = 0xC01E050B; +pub const STATUS_GRAPHICS_OPM_INVALID_HANDLE: NTSTATUS = 0xC01E050C; +pub const STATUS_GRAPHICS_PVP_INVALID_CERTIFICATE_LENGTH: NTSTATUS = 0xC01E050E; +pub const STATUS_GRAPHICS_OPM_SPANNING_MODE_ENABLED: NTSTATUS = 0xC01E050F; +pub const STATUS_GRAPHICS_OPM_THEATER_MODE_ENABLED: NTSTATUS = 0xC01E0510; +pub const STATUS_GRAPHICS_PVP_HFS_FAILED: NTSTATUS = 0xC01E0511; +pub const STATUS_GRAPHICS_OPM_INVALID_SRM: NTSTATUS = 0xC01E0512; +pub const STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_HDCP: NTSTATUS = 0xC01E0513; +pub const STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_ACP: NTSTATUS = 0xC01E0514; +pub const STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_CGMSA: NTSTATUS = 0xC01E0515; +pub const STATUS_GRAPHICS_OPM_HDCP_SRM_NEVER_SET: NTSTATUS = 0xC01E0516; +pub const STATUS_GRAPHICS_OPM_RESOLUTION_TOO_HIGH: NTSTATUS = 0xC01E0517; +pub const STATUS_GRAPHICS_OPM_ALL_HDCP_HARDWARE_ALREADY_IN_USE: NTSTATUS = 0xC01E0518; +pub const STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_NO_LONGER_EXISTS: NTSTATUS = 0xC01E051A; +pub const STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_DOES_NOT_HAVE_COPP_SEMANTICS: NTSTATUS + = 0xC01E051C; +pub const STATUS_GRAPHICS_OPM_INVALID_INFORMATION_REQUEST: NTSTATUS = 0xC01E051D; +pub const STATUS_GRAPHICS_OPM_DRIVER_INTERNAL_ERROR: NTSTATUS = 0xC01E051E; +pub const STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_DOES_NOT_HAVE_OPM_SEMANTICS: NTSTATUS + = 0xC01E051F; +pub const STATUS_GRAPHICS_OPM_SIGNALING_NOT_SUPPORTED: NTSTATUS = 0xC01E0520; +pub const STATUS_GRAPHICS_OPM_INVALID_CONFIGURATION_REQUEST: NTSTATUS = 0xC01E0521; +pub const STATUS_GRAPHICS_I2C_NOT_SUPPORTED: NTSTATUS = 0xC01E0580; +pub const STATUS_GRAPHICS_I2C_DEVICE_DOES_NOT_EXIST: NTSTATUS = 0xC01E0581; +pub const STATUS_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA: NTSTATUS = 0xC01E0582; +pub const STATUS_GRAPHICS_I2C_ERROR_RECEIVING_DATA: NTSTATUS = 0xC01E0583; +pub const STATUS_GRAPHICS_DDCCI_VCP_NOT_SUPPORTED: NTSTATUS = 0xC01E0584; +pub const STATUS_GRAPHICS_DDCCI_INVALID_DATA: NTSTATUS = 0xC01E0585; +pub const STATUS_GRAPHICS_DDCCI_MONITOR_RETURNED_INVALID_TIMING_STATUS_BYTE: NTSTATUS + = 0xC01E0586; +pub const STATUS_GRAPHICS_DDCCI_INVALID_CAPABILITIES_STRING: NTSTATUS = 0xC01E0587; +pub const STATUS_GRAPHICS_MCA_INTERNAL_ERROR: NTSTATUS = 0xC01E0588; +pub const STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_COMMAND: NTSTATUS = 0xC01E0589; +pub const STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_LENGTH: NTSTATUS = 0xC01E058A; +pub const STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_CHECKSUM: NTSTATUS = 0xC01E058B; +pub const STATUS_GRAPHICS_INVALID_PHYSICAL_MONITOR_HANDLE: NTSTATUS = 0xC01E058C; +pub const STATUS_GRAPHICS_MONITOR_NO_LONGER_EXISTS: NTSTATUS = 0xC01E058D; +pub const STATUS_GRAPHICS_ONLY_CONSOLE_SESSION_SUPPORTED: NTSTATUS = 0xC01E05E0; +pub const STATUS_GRAPHICS_NO_DISPLAY_DEVICE_CORRESPONDS_TO_NAME: NTSTATUS = 0xC01E05E1; +pub const STATUS_GRAPHICS_DISPLAY_DEVICE_NOT_ATTACHED_TO_DESKTOP: NTSTATUS = 0xC01E05E2; +pub const STATUS_GRAPHICS_MIRRORING_DEVICES_NOT_SUPPORTED: NTSTATUS = 0xC01E05E3; +pub const STATUS_GRAPHICS_INVALID_POINTER: NTSTATUS = 0xC01E05E4; +pub const STATUS_GRAPHICS_NO_MONITORS_CORRESPOND_TO_DISPLAY_DEVICE: NTSTATUS + = 0xC01E05E5; +pub const STATUS_GRAPHICS_PARAMETER_ARRAY_TOO_SMALL: NTSTATUS = 0xC01E05E6; +pub const STATUS_GRAPHICS_INTERNAL_ERROR: NTSTATUS = 0xC01E05E7; +pub const STATUS_GRAPHICS_SESSION_TYPE_CHANGE_IN_PROGRESS: NTSTATUS = 0xC01E05E8; +pub const STATUS_FVE_LOCKED_VOLUME: NTSTATUS = 0xC0210000; +pub const STATUS_FVE_NOT_ENCRYPTED: NTSTATUS = 0xC0210001; +pub const STATUS_FVE_BAD_INFORMATION: NTSTATUS = 0xC0210002; +pub const STATUS_FVE_TOO_SMALL: NTSTATUS = 0xC0210003; +pub const STATUS_FVE_FAILED_WRONG_FS: NTSTATUS = 0xC0210004; +pub const STATUS_FVE_BAD_PARTITION_SIZE: NTSTATUS = 0xC0210005; +pub const STATUS_FVE_FS_NOT_EXTENDED: NTSTATUS = 0xC0210006; +pub const STATUS_FVE_FS_MOUNTED: NTSTATUS = 0xC0210007; +pub const STATUS_FVE_NO_LICENSE: NTSTATUS = 0xC0210008; +pub const STATUS_FVE_ACTION_NOT_ALLOWED: NTSTATUS = 0xC0210009; +pub const STATUS_FVE_BAD_DATA: NTSTATUS = 0xC021000A; +pub const STATUS_FVE_VOLUME_NOT_BOUND: NTSTATUS = 0xC021000B; +pub const STATUS_FVE_NOT_DATA_VOLUME: NTSTATUS = 0xC021000C; +pub const STATUS_FVE_CONV_READ_ERROR: NTSTATUS = 0xC021000D; +pub const STATUS_FVE_CONV_WRITE_ERROR: NTSTATUS = 0xC021000E; +pub const STATUS_FVE_OVERLAPPED_UPDATE: NTSTATUS = 0xC021000F; +pub const STATUS_FVE_FAILED_SECTOR_SIZE: NTSTATUS = 0xC0210010; +pub const STATUS_FVE_FAILED_AUTHENTICATION: NTSTATUS = 0xC0210011; +pub const STATUS_FVE_NOT_OS_VOLUME: NTSTATUS = 0xC0210012; +pub const STATUS_FVE_KEYFILE_NOT_FOUND: NTSTATUS = 0xC0210013; +pub const STATUS_FVE_KEYFILE_INVALID: NTSTATUS = 0xC0210014; +pub const STATUS_FVE_KEYFILE_NO_VMK: NTSTATUS = 0xC0210015; +pub const STATUS_FVE_TPM_DISABLED: NTSTATUS = 0xC0210016; +pub const STATUS_FVE_TPM_SRK_AUTH_NOT_ZERO: NTSTATUS = 0xC0210017; +pub const STATUS_FVE_TPM_INVALID_PCR: NTSTATUS = 0xC0210018; +pub const STATUS_FVE_TPM_NO_VMK: NTSTATUS = 0xC0210019; +pub const STATUS_FVE_PIN_INVALID: NTSTATUS = 0xC021001A; +pub const STATUS_FVE_AUTH_INVALID_APPLICATION: NTSTATUS = 0xC021001B; +pub const STATUS_FVE_AUTH_INVALID_CONFIG: NTSTATUS = 0xC021001C; +pub const STATUS_FVE_DEBUGGER_ENABLED: NTSTATUS = 0xC021001D; +pub const STATUS_FVE_DRY_RUN_FAILED: NTSTATUS = 0xC021001E; +pub const STATUS_FVE_BAD_METADATA_POINTER: NTSTATUS = 0xC021001F; +pub const STATUS_FVE_OLD_METADATA_COPY: NTSTATUS = 0xC0210020; +pub const STATUS_FVE_REBOOT_REQUIRED: NTSTATUS = 0xC0210021; +pub const STATUS_FVE_RAW_ACCESS: NTSTATUS = 0xC0210022; +pub const STATUS_FVE_RAW_BLOCKED: NTSTATUS = 0xC0210023; +pub const STATUS_FVE_NO_AUTOUNLOCK_MASTER_KEY: NTSTATUS = 0xC0210024; +pub const STATUS_FVE_MOR_FAILED: NTSTATUS = 0xC0210025; +pub const STATUS_FVE_NO_FEATURE_LICENSE: NTSTATUS = 0xC0210026; +pub const STATUS_FVE_POLICY_USER_DISABLE_RDV_NOT_ALLOWED: NTSTATUS = 0xC0210027; +pub const STATUS_FVE_CONV_RECOVERY_FAILED: NTSTATUS = 0xC0210028; +pub const STATUS_FVE_VIRTUALIZED_SPACE_TOO_BIG: NTSTATUS = 0xC0210029; +pub const STATUS_FVE_INVALID_DATUM_TYPE: NTSTATUS = 0xC021002A; +pub const STATUS_FVE_VOLUME_TOO_SMALL: NTSTATUS = 0xC0210030; +pub const STATUS_FVE_ENH_PIN_INVALID: NTSTATUS = 0xC0210031; +pub const STATUS_FVE_FULL_ENCRYPTION_NOT_ALLOWED_ON_TP_STORAGE: NTSTATUS = 0xC0210032; +pub const STATUS_FVE_WIPE_NOT_ALLOWED_ON_TP_STORAGE: NTSTATUS = 0xC0210033; +pub const STATUS_FVE_NOT_ALLOWED_ON_CSV_STACK: NTSTATUS = 0xC0210034; +pub const STATUS_FVE_NOT_ALLOWED_ON_CLUSTER: NTSTATUS = 0xC0210035; +pub const STATUS_FVE_NOT_ALLOWED_TO_UPGRADE_WHILE_CONVERTING: NTSTATUS = 0xC0210036; +pub const STATUS_FVE_WIPE_CANCEL_NOT_APPLICABLE: NTSTATUS = 0xC0210037; +pub const STATUS_FVE_EDRIVE_DRY_RUN_FAILED: NTSTATUS = 0xC0210038; +pub const STATUS_FVE_SECUREBOOT_DISABLED: NTSTATUS = 0xC0210039; +pub const STATUS_FVE_SECUREBOOT_CONFIG_CHANGE: NTSTATUS = 0xC021003A; +pub const STATUS_FVE_DEVICE_LOCKEDOUT: NTSTATUS = 0xC021003B; +pub const STATUS_FVE_VOLUME_EXTEND_PREVENTS_EOW_DECRYPT: NTSTATUS = 0xC021003C; +pub const STATUS_FVE_NOT_DE_VOLUME: NTSTATUS = 0xC021003D; +pub const STATUS_FVE_PROTECTION_DISABLED: NTSTATUS = 0xC021003E; +pub const STATUS_FVE_PROTECTION_CANNOT_BE_DISABLED: NTSTATUS = 0xC021003F; +pub const STATUS_FWP_CALLOUT_NOT_FOUND: NTSTATUS = 0xC0220001; +pub const STATUS_FWP_CONDITION_NOT_FOUND: NTSTATUS = 0xC0220002; +pub const STATUS_FWP_FILTER_NOT_FOUND: NTSTATUS = 0xC0220003; +pub const STATUS_FWP_LAYER_NOT_FOUND: NTSTATUS = 0xC0220004; +pub const STATUS_FWP_PROVIDER_NOT_FOUND: NTSTATUS = 0xC0220005; +pub const STATUS_FWP_PROVIDER_CONTEXT_NOT_FOUND: NTSTATUS = 0xC0220006; +pub const STATUS_FWP_SUBLAYER_NOT_FOUND: NTSTATUS = 0xC0220007; +pub const STATUS_FWP_NOT_FOUND: NTSTATUS = 0xC0220008; +pub const STATUS_FWP_ALREADY_EXISTS: NTSTATUS = 0xC0220009; +pub const STATUS_FWP_IN_USE: NTSTATUS = 0xC022000A; +pub const STATUS_FWP_DYNAMIC_SESSION_IN_PROGRESS: NTSTATUS = 0xC022000B; +pub const STATUS_FWP_WRONG_SESSION: NTSTATUS = 0xC022000C; +pub const STATUS_FWP_NO_TXN_IN_PROGRESS: NTSTATUS = 0xC022000D; +pub const STATUS_FWP_TXN_IN_PROGRESS: NTSTATUS = 0xC022000E; +pub const STATUS_FWP_TXN_ABORTED: NTSTATUS = 0xC022000F; +pub const STATUS_FWP_SESSION_ABORTED: NTSTATUS = 0xC0220010; +pub const STATUS_FWP_INCOMPATIBLE_TXN: NTSTATUS = 0xC0220011; +pub const STATUS_FWP_TIMEOUT: NTSTATUS = 0xC0220012; +pub const STATUS_FWP_NET_EVENTS_DISABLED: NTSTATUS = 0xC0220013; +pub const STATUS_FWP_INCOMPATIBLE_LAYER: NTSTATUS = 0xC0220014; +pub const STATUS_FWP_KM_CLIENTS_ONLY: NTSTATUS = 0xC0220015; +pub const STATUS_FWP_LIFETIME_MISMATCH: NTSTATUS = 0xC0220016; +pub const STATUS_FWP_BUILTIN_OBJECT: NTSTATUS = 0xC0220017; +pub const STATUS_FWP_TOO_MANY_CALLOUTS: NTSTATUS = 0xC0220018; +pub const STATUS_FWP_NOTIFICATION_DROPPED: NTSTATUS = 0xC0220019; +pub const STATUS_FWP_TRAFFIC_MISMATCH: NTSTATUS = 0xC022001A; +pub const STATUS_FWP_INCOMPATIBLE_SA_STATE: NTSTATUS = 0xC022001B; +pub const STATUS_FWP_NULL_POINTER: NTSTATUS = 0xC022001C; +pub const STATUS_FWP_INVALID_ENUMERATOR: NTSTATUS = 0xC022001D; +pub const STATUS_FWP_INVALID_FLAGS: NTSTATUS = 0xC022001E; +pub const STATUS_FWP_INVALID_NET_MASK: NTSTATUS = 0xC022001F; +pub const STATUS_FWP_INVALID_RANGE: NTSTATUS = 0xC0220020; +pub const STATUS_FWP_INVALID_INTERVAL: NTSTATUS = 0xC0220021; +pub const STATUS_FWP_ZERO_LENGTH_ARRAY: NTSTATUS = 0xC0220022; +pub const STATUS_FWP_NULL_DISPLAY_NAME: NTSTATUS = 0xC0220023; +pub const STATUS_FWP_INVALID_ACTION_TYPE: NTSTATUS = 0xC0220024; +pub const STATUS_FWP_INVALID_WEIGHT: NTSTATUS = 0xC0220025; +pub const STATUS_FWP_MATCH_TYPE_MISMATCH: NTSTATUS = 0xC0220026; +pub const STATUS_FWP_TYPE_MISMATCH: NTSTATUS = 0xC0220027; +pub const STATUS_FWP_OUT_OF_BOUNDS: NTSTATUS = 0xC0220028; +pub const STATUS_FWP_RESERVED: NTSTATUS = 0xC0220029; +pub const STATUS_FWP_DUPLICATE_CONDITION: NTSTATUS = 0xC022002A; +pub const STATUS_FWP_DUPLICATE_KEYMOD: NTSTATUS = 0xC022002B; +pub const STATUS_FWP_ACTION_INCOMPATIBLE_WITH_LAYER: NTSTATUS = 0xC022002C; +pub const STATUS_FWP_ACTION_INCOMPATIBLE_WITH_SUBLAYER: NTSTATUS = 0xC022002D; +pub const STATUS_FWP_CONTEXT_INCOMPATIBLE_WITH_LAYER: NTSTATUS = 0xC022002E; +pub const STATUS_FWP_CONTEXT_INCOMPATIBLE_WITH_CALLOUT: NTSTATUS = 0xC022002F; +pub const STATUS_FWP_INCOMPATIBLE_AUTH_METHOD: NTSTATUS = 0xC0220030; +pub const STATUS_FWP_INCOMPATIBLE_DH_GROUP: NTSTATUS = 0xC0220031; +pub const STATUS_FWP_EM_NOT_SUPPORTED: NTSTATUS = 0xC0220032; +pub const STATUS_FWP_NEVER_MATCH: NTSTATUS = 0xC0220033; +pub const STATUS_FWP_PROVIDER_CONTEXT_MISMATCH: NTSTATUS = 0xC0220034; +pub const STATUS_FWP_INVALID_PARAMETER: NTSTATUS = 0xC0220035; +pub const STATUS_FWP_TOO_MANY_SUBLAYERS: NTSTATUS = 0xC0220036; +pub const STATUS_FWP_CALLOUT_NOTIFICATION_FAILED: NTSTATUS = 0xC0220037; +pub const STATUS_FWP_INVALID_AUTH_TRANSFORM: NTSTATUS = 0xC0220038; +pub const STATUS_FWP_INVALID_CIPHER_TRANSFORM: NTSTATUS = 0xC0220039; +pub const STATUS_FWP_INCOMPATIBLE_CIPHER_TRANSFORM: NTSTATUS = 0xC022003A; +pub const STATUS_FWP_INVALID_TRANSFORM_COMBINATION: NTSTATUS = 0xC022003B; +pub const STATUS_FWP_DUPLICATE_AUTH_METHOD: NTSTATUS = 0xC022003C; +pub const STATUS_FWP_INVALID_TUNNEL_ENDPOINT: NTSTATUS = 0xC022003D; +pub const STATUS_FWP_L2_DRIVER_NOT_READY: NTSTATUS = 0xC022003E; +pub const STATUS_FWP_KEY_DICTATOR_ALREADY_REGISTERED: NTSTATUS = 0xC022003F; +pub const STATUS_FWP_KEY_DICTATION_INVALID_KEYING_MATERIAL: NTSTATUS = 0xC0220040; +pub const STATUS_FWP_CONNECTIONS_DISABLED: NTSTATUS = 0xC0220041; +pub const STATUS_FWP_INVALID_DNS_NAME: NTSTATUS = 0xC0220042; +pub const STATUS_FWP_STILL_ON: NTSTATUS = 0xC0220043; +pub const STATUS_FWP_IKEEXT_NOT_RUNNING: NTSTATUS = 0xC0220044; +pub const STATUS_FWP_TCPIP_NOT_READY: NTSTATUS = 0xC0220100; +pub const STATUS_FWP_INJECT_HANDLE_CLOSING: NTSTATUS = 0xC0220101; +pub const STATUS_FWP_INJECT_HANDLE_STALE: NTSTATUS = 0xC0220102; +pub const STATUS_FWP_CANNOT_PEND: NTSTATUS = 0xC0220103; +pub const STATUS_FWP_DROP_NOICMP: NTSTATUS = 0xC0220104; +pub const STATUS_NDIS_CLOSING: NTSTATUS = 0xC0230002; +pub const STATUS_NDIS_BAD_VERSION: NTSTATUS = 0xC0230004; +pub const STATUS_NDIS_BAD_CHARACTERISTICS: NTSTATUS = 0xC0230005; +pub const STATUS_NDIS_ADAPTER_NOT_FOUND: NTSTATUS = 0xC0230006; +pub const STATUS_NDIS_OPEN_FAILED: NTSTATUS = 0xC0230007; +pub const STATUS_NDIS_DEVICE_FAILED: NTSTATUS = 0xC0230008; +pub const STATUS_NDIS_MULTICAST_FULL: NTSTATUS = 0xC0230009; +pub const STATUS_NDIS_MULTICAST_EXISTS: NTSTATUS = 0xC023000A; +pub const STATUS_NDIS_MULTICAST_NOT_FOUND: NTSTATUS = 0xC023000B; +pub const STATUS_NDIS_REQUEST_ABORTED: NTSTATUS = 0xC023000C; +pub const STATUS_NDIS_RESET_IN_PROGRESS: NTSTATUS = 0xC023000D; +pub const STATUS_NDIS_NOT_SUPPORTED: NTSTATUS = 0xC02300BB; +pub const STATUS_NDIS_INVALID_PACKET: NTSTATUS = 0xC023000F; +pub const STATUS_NDIS_ADAPTER_NOT_READY: NTSTATUS = 0xC0230011; +pub const STATUS_NDIS_INVALID_LENGTH: NTSTATUS = 0xC0230014; +pub const STATUS_NDIS_INVALID_DATA: NTSTATUS = 0xC0230015; +pub const STATUS_NDIS_BUFFER_TOO_SHORT: NTSTATUS = 0xC0230016; +pub const STATUS_NDIS_INVALID_OID: NTSTATUS = 0xC0230017; +pub const STATUS_NDIS_ADAPTER_REMOVED: NTSTATUS = 0xC0230018; +pub const STATUS_NDIS_UNSUPPORTED_MEDIA: NTSTATUS = 0xC0230019; +pub const STATUS_NDIS_GROUP_ADDRESS_IN_USE: NTSTATUS = 0xC023001A; +pub const STATUS_NDIS_FILE_NOT_FOUND: NTSTATUS = 0xC023001B; +pub const STATUS_NDIS_ERROR_READING_FILE: NTSTATUS = 0xC023001C; +pub const STATUS_NDIS_ALREADY_MAPPED: NTSTATUS = 0xC023001D; +pub const STATUS_NDIS_RESOURCE_CONFLICT: NTSTATUS = 0xC023001E; +pub const STATUS_NDIS_MEDIA_DISCONNECTED: NTSTATUS = 0xC023001F; +pub const STATUS_NDIS_INVALID_ADDRESS: NTSTATUS = 0xC0230022; +pub const STATUS_NDIS_INVALID_DEVICE_REQUEST: NTSTATUS = 0xC0230010; +pub const STATUS_NDIS_PAUSED: NTSTATUS = 0xC023002A; +pub const STATUS_NDIS_INTERFACE_NOT_FOUND: NTSTATUS = 0xC023002B; +pub const STATUS_NDIS_UNSUPPORTED_REVISION: NTSTATUS = 0xC023002C; +pub const STATUS_NDIS_INVALID_PORT: NTSTATUS = 0xC023002D; +pub const STATUS_NDIS_INVALID_PORT_STATE: NTSTATUS = 0xC023002E; +pub const STATUS_NDIS_LOW_POWER_STATE: NTSTATUS = 0xC023002F; +pub const STATUS_NDIS_REINIT_REQUIRED: NTSTATUS = 0xC0230030; +pub const STATUS_NDIS_DOT11_AUTO_CONFIG_ENABLED: NTSTATUS = 0xC0232000; +pub const STATUS_NDIS_DOT11_MEDIA_IN_USE: NTSTATUS = 0xC0232001; +pub const STATUS_NDIS_DOT11_POWER_STATE_INVALID: NTSTATUS = 0xC0232002; +pub const STATUS_NDIS_PM_WOL_PATTERN_LIST_FULL: NTSTATUS = 0xC0232003; +pub const STATUS_NDIS_PM_PROTOCOL_OFFLOAD_LIST_FULL: NTSTATUS = 0xC0232004; +pub const STATUS_NDIS_DOT11_AP_CHANNEL_CURRENTLY_NOT_AVAILABLE: NTSTATUS = 0xC0232005; +pub const STATUS_NDIS_DOT11_AP_BAND_CURRENTLY_NOT_AVAILABLE: NTSTATUS = 0xC0232006; +pub const STATUS_NDIS_DOT11_AP_CHANNEL_NOT_ALLOWED: NTSTATUS = 0xC0232007; +pub const STATUS_NDIS_DOT11_AP_BAND_NOT_ALLOWED: NTSTATUS = 0xC0232008; +pub const STATUS_NDIS_INDICATION_REQUIRED: NTSTATUS = 0x40230001; +pub const STATUS_NDIS_OFFLOAD_POLICY: NTSTATUS = 0xC023100F; +pub const STATUS_NDIS_OFFLOAD_CONNECTION_REJECTED: NTSTATUS = 0xC0231012; +pub const STATUS_NDIS_OFFLOAD_PATH_REJECTED: NTSTATUS = 0xC0231013; +pub const STATUS_TPM_ERROR_MASK: NTSTATUS = 0xC0290000; +pub const STATUS_TPM_AUTHFAIL: NTSTATUS = 0xC0290001; +pub const STATUS_TPM_BADINDEX: NTSTATUS = 0xC0290002; +pub const STATUS_TPM_BAD_PARAMETER: NTSTATUS = 0xC0290003; +pub const STATUS_TPM_AUDITFAILURE: NTSTATUS = 0xC0290004; +pub const STATUS_TPM_CLEAR_DISABLED: NTSTATUS = 0xC0290005; +pub const STATUS_TPM_DEACTIVATED: NTSTATUS = 0xC0290006; +pub const STATUS_TPM_DISABLED: NTSTATUS = 0xC0290007; +pub const STATUS_TPM_DISABLED_CMD: NTSTATUS = 0xC0290008; +pub const STATUS_TPM_FAIL: NTSTATUS = 0xC0290009; +pub const STATUS_TPM_BAD_ORDINAL: NTSTATUS = 0xC029000A; +pub const STATUS_TPM_INSTALL_DISABLED: NTSTATUS = 0xC029000B; +pub const STATUS_TPM_INVALID_KEYHANDLE: NTSTATUS = 0xC029000C; +pub const STATUS_TPM_KEYNOTFOUND: NTSTATUS = 0xC029000D; +pub const STATUS_TPM_INAPPROPRIATE_ENC: NTSTATUS = 0xC029000E; +pub const STATUS_TPM_MIGRATEFAIL: NTSTATUS = 0xC029000F; +pub const STATUS_TPM_INVALID_PCR_INFO: NTSTATUS = 0xC0290010; +pub const STATUS_TPM_NOSPACE: NTSTATUS = 0xC0290011; +pub const STATUS_TPM_NOSRK: NTSTATUS = 0xC0290012; +pub const STATUS_TPM_NOTSEALED_BLOB: NTSTATUS = 0xC0290013; +pub const STATUS_TPM_OWNER_SET: NTSTATUS = 0xC0290014; +pub const STATUS_TPM_RESOURCES: NTSTATUS = 0xC0290015; +pub const STATUS_TPM_SHORTRANDOM: NTSTATUS = 0xC0290016; +pub const STATUS_TPM_SIZE: NTSTATUS = 0xC0290017; +pub const STATUS_TPM_WRONGPCRVAL: NTSTATUS = 0xC0290018; +pub const STATUS_TPM_BAD_PARAM_SIZE: NTSTATUS = 0xC0290019; +pub const STATUS_TPM_SHA_THREAD: NTSTATUS = 0xC029001A; +pub const STATUS_TPM_SHA_ERROR: NTSTATUS = 0xC029001B; +pub const STATUS_TPM_FAILEDSELFTEST: NTSTATUS = 0xC029001C; +pub const STATUS_TPM_AUTH2FAIL: NTSTATUS = 0xC029001D; +pub const STATUS_TPM_BADTAG: NTSTATUS = 0xC029001E; +pub const STATUS_TPM_IOERROR: NTSTATUS = 0xC029001F; +pub const STATUS_TPM_ENCRYPT_ERROR: NTSTATUS = 0xC0290020; +pub const STATUS_TPM_DECRYPT_ERROR: NTSTATUS = 0xC0290021; +pub const STATUS_TPM_INVALID_AUTHHANDLE: NTSTATUS = 0xC0290022; +pub const STATUS_TPM_NO_ENDORSEMENT: NTSTATUS = 0xC0290023; +pub const STATUS_TPM_INVALID_KEYUSAGE: NTSTATUS = 0xC0290024; +pub const STATUS_TPM_WRONG_ENTITYTYPE: NTSTATUS = 0xC0290025; +pub const STATUS_TPM_INVALID_POSTINIT: NTSTATUS = 0xC0290026; +pub const STATUS_TPM_INAPPROPRIATE_SIG: NTSTATUS = 0xC0290027; +pub const STATUS_TPM_BAD_KEY_PROPERTY: NTSTATUS = 0xC0290028; +pub const STATUS_TPM_BAD_MIGRATION: NTSTATUS = 0xC0290029; +pub const STATUS_TPM_BAD_SCHEME: NTSTATUS = 0xC029002A; +pub const STATUS_TPM_BAD_DATASIZE: NTSTATUS = 0xC029002B; +pub const STATUS_TPM_BAD_MODE: NTSTATUS = 0xC029002C; +pub const STATUS_TPM_BAD_PRESENCE: NTSTATUS = 0xC029002D; +pub const STATUS_TPM_BAD_VERSION: NTSTATUS = 0xC029002E; +pub const STATUS_TPM_NO_WRAP_TRANSPORT: NTSTATUS = 0xC029002F; +pub const STATUS_TPM_AUDITFAIL_UNSUCCESSFUL: NTSTATUS = 0xC0290030; +pub const STATUS_TPM_AUDITFAIL_SUCCESSFUL: NTSTATUS = 0xC0290031; +pub const STATUS_TPM_NOTRESETABLE: NTSTATUS = 0xC0290032; +pub const STATUS_TPM_NOTLOCAL: NTSTATUS = 0xC0290033; +pub const STATUS_TPM_BAD_TYPE: NTSTATUS = 0xC0290034; +pub const STATUS_TPM_INVALID_RESOURCE: NTSTATUS = 0xC0290035; +pub const STATUS_TPM_NOTFIPS: NTSTATUS = 0xC0290036; +pub const STATUS_TPM_INVALID_FAMILY: NTSTATUS = 0xC0290037; +pub const STATUS_TPM_NO_NV_PERMISSION: NTSTATUS = 0xC0290038; +pub const STATUS_TPM_REQUIRES_SIGN: NTSTATUS = 0xC0290039; +pub const STATUS_TPM_KEY_NOTSUPPORTED: NTSTATUS = 0xC029003A; +pub const STATUS_TPM_AUTH_CONFLICT: NTSTATUS = 0xC029003B; +pub const STATUS_TPM_AREA_LOCKED: NTSTATUS = 0xC029003C; +pub const STATUS_TPM_BAD_LOCALITY: NTSTATUS = 0xC029003D; +pub const STATUS_TPM_READ_ONLY: NTSTATUS = 0xC029003E; +pub const STATUS_TPM_PER_NOWRITE: NTSTATUS = 0xC029003F; +pub const STATUS_TPM_FAMILYCOUNT: NTSTATUS = 0xC0290040; +pub const STATUS_TPM_WRITE_LOCKED: NTSTATUS = 0xC0290041; +pub const STATUS_TPM_BAD_ATTRIBUTES: NTSTATUS = 0xC0290042; +pub const STATUS_TPM_INVALID_STRUCTURE: NTSTATUS = 0xC0290043; +pub const STATUS_TPM_KEY_OWNER_CONTROL: NTSTATUS = 0xC0290044; +pub const STATUS_TPM_BAD_COUNTER: NTSTATUS = 0xC0290045; +pub const STATUS_TPM_NOT_FULLWRITE: NTSTATUS = 0xC0290046; +pub const STATUS_TPM_CONTEXT_GAP: NTSTATUS = 0xC0290047; +pub const STATUS_TPM_MAXNVWRITES: NTSTATUS = 0xC0290048; +pub const STATUS_TPM_NOOPERATOR: NTSTATUS = 0xC0290049; +pub const STATUS_TPM_RESOURCEMISSING: NTSTATUS = 0xC029004A; +pub const STATUS_TPM_DELEGATE_LOCK: NTSTATUS = 0xC029004B; +pub const STATUS_TPM_DELEGATE_FAMILY: NTSTATUS = 0xC029004C; +pub const STATUS_TPM_DELEGATE_ADMIN: NTSTATUS = 0xC029004D; +pub const STATUS_TPM_TRANSPORT_NOTEXCLUSIVE: NTSTATUS = 0xC029004E; +pub const STATUS_TPM_OWNER_CONTROL: NTSTATUS = 0xC029004F; +pub const STATUS_TPM_DAA_RESOURCES: NTSTATUS = 0xC0290050; +pub const STATUS_TPM_DAA_INPUT_DATA0: NTSTATUS = 0xC0290051; +pub const STATUS_TPM_DAA_INPUT_DATA1: NTSTATUS = 0xC0290052; +pub const STATUS_TPM_DAA_ISSUER_SETTINGS: NTSTATUS = 0xC0290053; +pub const STATUS_TPM_DAA_TPM_SETTINGS: NTSTATUS = 0xC0290054; +pub const STATUS_TPM_DAA_STAGE: NTSTATUS = 0xC0290055; +pub const STATUS_TPM_DAA_ISSUER_VALIDITY: NTSTATUS = 0xC0290056; +pub const STATUS_TPM_DAA_WRONG_W: NTSTATUS = 0xC0290057; +pub const STATUS_TPM_BAD_HANDLE: NTSTATUS = 0xC0290058; +pub const STATUS_TPM_BAD_DELEGATE: NTSTATUS = 0xC0290059; +pub const STATUS_TPM_BADCONTEXT: NTSTATUS = 0xC029005A; +pub const STATUS_TPM_TOOMANYCONTEXTS: NTSTATUS = 0xC029005B; +pub const STATUS_TPM_MA_TICKET_SIGNATURE: NTSTATUS = 0xC029005C; +pub const STATUS_TPM_MA_DESTINATION: NTSTATUS = 0xC029005D; +pub const STATUS_TPM_MA_SOURCE: NTSTATUS = 0xC029005E; +pub const STATUS_TPM_MA_AUTHORITY: NTSTATUS = 0xC029005F; +pub const STATUS_TPM_PERMANENTEK: NTSTATUS = 0xC0290061; +pub const STATUS_TPM_BAD_SIGNATURE: NTSTATUS = 0xC0290062; +pub const STATUS_TPM_NOCONTEXTSPACE: NTSTATUS = 0xC0290063; +pub const STATUS_TPM_COMMAND_BLOCKED: NTSTATUS = 0xC0290400; +pub const STATUS_TPM_INVALID_HANDLE: NTSTATUS = 0xC0290401; +pub const STATUS_TPM_DUPLICATE_VHANDLE: NTSTATUS = 0xC0290402; +pub const STATUS_TPM_EMBEDDED_COMMAND_BLOCKED: NTSTATUS = 0xC0290403; +pub const STATUS_TPM_EMBEDDED_COMMAND_UNSUPPORTED: NTSTATUS = 0xC0290404; +pub const STATUS_TPM_RETRY: NTSTATUS = 0xC0290800; +pub const STATUS_TPM_NEEDS_SELFTEST: NTSTATUS = 0xC0290801; +pub const STATUS_TPM_DOING_SELFTEST: NTSTATUS = 0xC0290802; +pub const STATUS_TPM_DEFEND_LOCK_RUNNING: NTSTATUS = 0xC0290803; +pub const STATUS_TPM_COMMAND_CANCELED: NTSTATUS = 0xC0291001; +pub const STATUS_TPM_TOO_MANY_CONTEXTS: NTSTATUS = 0xC0291002; +pub const STATUS_TPM_NOT_FOUND: NTSTATUS = 0xC0291003; +pub const STATUS_TPM_ACCESS_DENIED: NTSTATUS = 0xC0291004; +pub const STATUS_TPM_INSUFFICIENT_BUFFER: NTSTATUS = 0xC0291005; +pub const STATUS_TPM_PPI_FUNCTION_UNSUPPORTED: NTSTATUS = 0xC0291006; +pub const STATUS_PCP_ERROR_MASK: NTSTATUS = 0xC0292000; +pub const STATUS_PCP_DEVICE_NOT_READY: NTSTATUS = 0xC0292001; +pub const STATUS_PCP_INVALID_HANDLE: NTSTATUS = 0xC0292002; +pub const STATUS_PCP_INVALID_PARAMETER: NTSTATUS = 0xC0292003; +pub const STATUS_PCP_FLAG_NOT_SUPPORTED: NTSTATUS = 0xC0292004; +pub const STATUS_PCP_NOT_SUPPORTED: NTSTATUS = 0xC0292005; +pub const STATUS_PCP_BUFFER_TOO_SMALL: NTSTATUS = 0xC0292006; +pub const STATUS_PCP_INTERNAL_ERROR: NTSTATUS = 0xC0292007; +pub const STATUS_PCP_AUTHENTICATION_FAILED: NTSTATUS = 0xC0292008; +pub const STATUS_PCP_AUTHENTICATION_IGNORED: NTSTATUS = 0xC0292009; +pub const STATUS_PCP_POLICY_NOT_FOUND: NTSTATUS = 0xC029200A; +pub const STATUS_PCP_PROFILE_NOT_FOUND: NTSTATUS = 0xC029200B; +pub const STATUS_PCP_VALIDATION_FAILED: NTSTATUS = 0xC029200C; +pub const STATUS_PCP_DEVICE_NOT_FOUND: NTSTATUS = 0xC029200D; +pub const STATUS_RTPM_CONTEXT_CONTINUE: NTSTATUS = 0x00293000; +pub const STATUS_RTPM_CONTEXT_COMPLETE: NTSTATUS = 0x00293001; +pub const STATUS_RTPM_NO_RESULT: NTSTATUS = 0xC0293002; +pub const STATUS_RTPM_PCR_READ_INCOMPLETE: NTSTATUS = 0xC0293003; +pub const STATUS_RTPM_INVALID_CONTEXT: NTSTATUS = 0xC0293004; +pub const STATUS_RTPM_UNSUPPORTED_CMD: NTSTATUS = 0xC0293005; +pub const STATUS_HV_INVALID_HYPERCALL_CODE: NTSTATUS = 0xC0350002; +pub const STATUS_HV_INVALID_HYPERCALL_INPUT: NTSTATUS = 0xC0350003; +pub const STATUS_HV_INVALID_ALIGNMENT: NTSTATUS = 0xC0350004; +pub const STATUS_HV_INVALID_PARAMETER: NTSTATUS = 0xC0350005; +pub const STATUS_HV_ACCESS_DENIED: NTSTATUS = 0xC0350006; +pub const STATUS_HV_INVALID_PARTITION_STATE: NTSTATUS = 0xC0350007; +pub const STATUS_HV_OPERATION_DENIED: NTSTATUS = 0xC0350008; +pub const STATUS_HV_UNKNOWN_PROPERTY: NTSTATUS = 0xC0350009; +pub const STATUS_HV_PROPERTY_VALUE_OUT_OF_RANGE: NTSTATUS = 0xC035000A; +pub const STATUS_HV_INSUFFICIENT_MEMORY: NTSTATUS = 0xC035000B; +pub const STATUS_HV_PARTITION_TOO_DEEP: NTSTATUS = 0xC035000C; +pub const STATUS_HV_INVALID_PARTITION_ID: NTSTATUS = 0xC035000D; +pub const STATUS_HV_INVALID_VP_INDEX: NTSTATUS = 0xC035000E; +pub const STATUS_HV_INVALID_PORT_ID: NTSTATUS = 0xC0350011; +pub const STATUS_HV_INVALID_CONNECTION_ID: NTSTATUS = 0xC0350012; +pub const STATUS_HV_INSUFFICIENT_BUFFERS: NTSTATUS = 0xC0350013; +pub const STATUS_HV_NOT_ACKNOWLEDGED: NTSTATUS = 0xC0350014; +pub const STATUS_HV_INVALID_VP_STATE: NTSTATUS = 0xC0350015; +pub const STATUS_HV_ACKNOWLEDGED: NTSTATUS = 0xC0350016; +pub const STATUS_HV_INVALID_SAVE_RESTORE_STATE: NTSTATUS = 0xC0350017; +pub const STATUS_HV_INVALID_SYNIC_STATE: NTSTATUS = 0xC0350018; +pub const STATUS_HV_OBJECT_IN_USE: NTSTATUS = 0xC0350019; +pub const STATUS_HV_INVALID_PROXIMITY_DOMAIN_INFO: NTSTATUS = 0xC035001A; +pub const STATUS_HV_NO_DATA: NTSTATUS = 0xC035001B; +pub const STATUS_HV_INACTIVE: NTSTATUS = 0xC035001C; +pub const STATUS_HV_NO_RESOURCES: NTSTATUS = 0xC035001D; +pub const STATUS_HV_FEATURE_UNAVAILABLE: NTSTATUS = 0xC035001E; +pub const STATUS_HV_INSUFFICIENT_BUFFER: NTSTATUS = 0xC0350033; +pub const STATUS_HV_INSUFFICIENT_DEVICE_DOMAINS: NTSTATUS = 0xC0350038; +pub const STATUS_HV_CPUID_FEATURE_VALIDATION_ERROR: NTSTATUS = 0xC035003C; +pub const STATUS_HV_CPUID_XSAVE_FEATURE_VALIDATION_ERROR: NTSTATUS = 0xC035003D; +pub const STATUS_HV_PROCESSOR_STARTUP_TIMEOUT: NTSTATUS = 0xC035003E; +pub const STATUS_HV_SMX_ENABLED: NTSTATUS = 0xC035003F; +pub const STATUS_HV_INVALID_LP_INDEX: NTSTATUS = 0xC0350041; +pub const STATUS_HV_INVALID_REGISTER_VALUE: NTSTATUS = 0xC0350050; +pub const STATUS_HV_INVALID_VTL_STATE: NTSTATUS = 0xC0350051; +pub const STATUS_HV_NX_NOT_DETECTED: NTSTATUS = 0xC0350055; +pub const STATUS_HV_INVALID_DEVICE_ID: NTSTATUS = 0xC0350057; +pub const STATUS_HV_INVALID_DEVICE_STATE: NTSTATUS = 0xC0350058; +pub const STATUS_HV_PENDING_PAGE_REQUESTS: NTSTATUS = 0x00350059; +pub const STATUS_HV_PAGE_REQUEST_INVALID: NTSTATUS = 0xC0350060; +pub const STATUS_HV_INVALID_CPU_GROUP_ID: NTSTATUS = 0xC035006F; +pub const STATUS_HV_INVALID_CPU_GROUP_STATE: NTSTATUS = 0xC0350070; +pub const STATUS_HV_NOT_ALLOWED_WITH_NESTED_VIRT_ACTIVE: NTSTATUS = 0xC0350071; +pub const STATUS_HV_NOT_PRESENT: NTSTATUS = 0xC0351000; +pub const STATUS_VID_DUPLICATE_HANDLER: NTSTATUS = 0xC0370001; +pub const STATUS_VID_TOO_MANY_HANDLERS: NTSTATUS = 0xC0370002; +pub const STATUS_VID_QUEUE_FULL: NTSTATUS = 0xC0370003; +pub const STATUS_VID_HANDLER_NOT_PRESENT: NTSTATUS = 0xC0370004; +pub const STATUS_VID_INVALID_OBJECT_NAME: NTSTATUS = 0xC0370005; +pub const STATUS_VID_PARTITION_NAME_TOO_LONG: NTSTATUS = 0xC0370006; +pub const STATUS_VID_MESSAGE_QUEUE_NAME_TOO_LONG: NTSTATUS = 0xC0370007; +pub const STATUS_VID_PARTITION_ALREADY_EXISTS: NTSTATUS = 0xC0370008; +pub const STATUS_VID_PARTITION_DOES_NOT_EXIST: NTSTATUS = 0xC0370009; +pub const STATUS_VID_PARTITION_NAME_NOT_FOUND: NTSTATUS = 0xC037000A; +pub const STATUS_VID_MESSAGE_QUEUE_ALREADY_EXISTS: NTSTATUS = 0xC037000B; +pub const STATUS_VID_EXCEEDED_MBP_ENTRY_MAP_LIMIT: NTSTATUS = 0xC037000C; +pub const STATUS_VID_MB_STILL_REFERENCED: NTSTATUS = 0xC037000D; +pub const STATUS_VID_CHILD_GPA_PAGE_SET_CORRUPTED: NTSTATUS = 0xC037000E; +pub const STATUS_VID_INVALID_NUMA_SETTINGS: NTSTATUS = 0xC037000F; +pub const STATUS_VID_INVALID_NUMA_NODE_INDEX: NTSTATUS = 0xC0370010; +pub const STATUS_VID_NOTIFICATION_QUEUE_ALREADY_ASSOCIATED: NTSTATUS = 0xC0370011; +pub const STATUS_VID_INVALID_MEMORY_BLOCK_HANDLE: NTSTATUS = 0xC0370012; +pub const STATUS_VID_PAGE_RANGE_OVERFLOW: NTSTATUS = 0xC0370013; +pub const STATUS_VID_INVALID_MESSAGE_QUEUE_HANDLE: NTSTATUS = 0xC0370014; +pub const STATUS_VID_INVALID_GPA_RANGE_HANDLE: NTSTATUS = 0xC0370015; +pub const STATUS_VID_NO_MEMORY_BLOCK_NOTIFICATION_QUEUE: NTSTATUS = 0xC0370016; +pub const STATUS_VID_MEMORY_BLOCK_LOCK_COUNT_EXCEEDED: NTSTATUS = 0xC0370017; +pub const STATUS_VID_INVALID_PPM_HANDLE: NTSTATUS = 0xC0370018; +pub const STATUS_VID_MBPS_ARE_LOCKED: NTSTATUS = 0xC0370019; +pub const STATUS_VID_MESSAGE_QUEUE_CLOSED: NTSTATUS = 0xC037001A; +pub const STATUS_VID_VIRTUAL_PROCESSOR_LIMIT_EXCEEDED: NTSTATUS = 0xC037001B; +pub const STATUS_VID_STOP_PENDING: NTSTATUS = 0xC037001C; +pub const STATUS_VID_INVALID_PROCESSOR_STATE: NTSTATUS = 0xC037001D; +pub const STATUS_VID_EXCEEDED_KM_CONTEXT_COUNT_LIMIT: NTSTATUS = 0xC037001E; +pub const STATUS_VID_KM_INTERFACE_ALREADY_INITIALIZED: NTSTATUS = 0xC037001F; +pub const STATUS_VID_MB_PROPERTY_ALREADY_SET_RESET: NTSTATUS = 0xC0370020; +pub const STATUS_VID_MMIO_RANGE_DESTROYED: NTSTATUS = 0xC0370021; +pub const STATUS_VID_INVALID_CHILD_GPA_PAGE_SET: NTSTATUS = 0xC0370022; +pub const STATUS_VID_RESERVE_PAGE_SET_IS_BEING_USED: NTSTATUS = 0xC0370023; +pub const STATUS_VID_RESERVE_PAGE_SET_TOO_SMALL: NTSTATUS = 0xC0370024; +pub const STATUS_VID_MBP_ALREADY_LOCKED_USING_RESERVED_PAGE: NTSTATUS = 0xC0370025; +pub const STATUS_VID_MBP_COUNT_EXCEEDED_LIMIT: NTSTATUS = 0xC0370026; +pub const STATUS_VID_SAVED_STATE_CORRUPT: NTSTATUS = 0xC0370027; +pub const STATUS_VID_SAVED_STATE_UNRECOGNIZED_ITEM: NTSTATUS = 0xC0370028; +pub const STATUS_VID_SAVED_STATE_INCOMPATIBLE: NTSTATUS = 0xC0370029; +pub const STATUS_VID_VTL_ACCESS_DENIED: NTSTATUS = 0xC037002A; +pub const STATUS_VID_REMOTE_NODE_PARENT_GPA_PAGES_USED: NTSTATUS = 0x80370001; +pub const STATUS_IPSEC_BAD_SPI: NTSTATUS = 0xC0360001; +pub const STATUS_IPSEC_SA_LIFETIME_EXPIRED: NTSTATUS = 0xC0360002; +pub const STATUS_IPSEC_WRONG_SA: NTSTATUS = 0xC0360003; +pub const STATUS_IPSEC_REPLAY_CHECK_FAILED: NTSTATUS = 0xC0360004; +pub const STATUS_IPSEC_INVALID_PACKET: NTSTATUS = 0xC0360005; +pub const STATUS_IPSEC_INTEGRITY_CHECK_FAILED: NTSTATUS = 0xC0360006; +pub const STATUS_IPSEC_CLEAR_TEXT_DROP: NTSTATUS = 0xC0360007; +pub const STATUS_IPSEC_AUTH_FIREWALL_DROP: NTSTATUS = 0xC0360008; +pub const STATUS_IPSEC_THROTTLE_DROP: NTSTATUS = 0xC0360009; +pub const STATUS_IPSEC_DOSP_BLOCK: NTSTATUS = 0xC0368000; +pub const STATUS_IPSEC_DOSP_RECEIVED_MULTICAST: NTSTATUS = 0xC0368001; +pub const STATUS_IPSEC_DOSP_INVALID_PACKET: NTSTATUS = 0xC0368002; +pub const STATUS_IPSEC_DOSP_STATE_LOOKUP_FAILED: NTSTATUS = 0xC0368003; +pub const STATUS_IPSEC_DOSP_MAX_ENTRIES: NTSTATUS = 0xC0368004; +pub const STATUS_IPSEC_DOSP_KEYMOD_NOT_ALLOWED: NTSTATUS = 0xC0368005; +pub const STATUS_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES: NTSTATUS = 0xC0368006; +pub const STATUS_VOLMGR_INCOMPLETE_REGENERATION: NTSTATUS = 0x80380001; +pub const STATUS_VOLMGR_INCOMPLETE_DISK_MIGRATION: NTSTATUS = 0x80380002; +pub const STATUS_VOLMGR_DATABASE_FULL: NTSTATUS = 0xC0380001; +pub const STATUS_VOLMGR_DISK_CONFIGURATION_CORRUPTED: NTSTATUS = 0xC0380002; +pub const STATUS_VOLMGR_DISK_CONFIGURATION_NOT_IN_SYNC: NTSTATUS = 0xC0380003; +pub const STATUS_VOLMGR_PACK_CONFIG_UPDATE_FAILED: NTSTATUS = 0xC0380004; +pub const STATUS_VOLMGR_DISK_CONTAINS_NON_SIMPLE_VOLUME: NTSTATUS = 0xC0380005; +pub const STATUS_VOLMGR_DISK_DUPLICATE: NTSTATUS = 0xC0380006; +pub const STATUS_VOLMGR_DISK_DYNAMIC: NTSTATUS = 0xC0380007; +pub const STATUS_VOLMGR_DISK_ID_INVALID: NTSTATUS = 0xC0380008; +pub const STATUS_VOLMGR_DISK_INVALID: NTSTATUS = 0xC0380009; +pub const STATUS_VOLMGR_DISK_LAST_VOTER: NTSTATUS = 0xC038000A; +pub const STATUS_VOLMGR_DISK_LAYOUT_INVALID: NTSTATUS = 0xC038000B; +pub const STATUS_VOLMGR_DISK_LAYOUT_NON_BASIC_BETWEEN_BASIC_PARTITIONS: NTSTATUS + = 0xC038000C; +pub const STATUS_VOLMGR_DISK_LAYOUT_NOT_CYLINDER_ALIGNED: NTSTATUS = 0xC038000D; +pub const STATUS_VOLMGR_DISK_LAYOUT_PARTITIONS_TOO_SMALL: NTSTATUS = 0xC038000E; +pub const STATUS_VOLMGR_DISK_LAYOUT_PRIMARY_BETWEEN_LOGICAL_PARTITIONS: NTSTATUS + = 0xC038000F; +pub const STATUS_VOLMGR_DISK_LAYOUT_TOO_MANY_PARTITIONS: NTSTATUS = 0xC0380010; +pub const STATUS_VOLMGR_DISK_MISSING: NTSTATUS = 0xC0380011; +pub const STATUS_VOLMGR_DISK_NOT_EMPTY: NTSTATUS = 0xC0380012; +pub const STATUS_VOLMGR_DISK_NOT_ENOUGH_SPACE: NTSTATUS = 0xC0380013; +pub const STATUS_VOLMGR_DISK_REVECTORING_FAILED: NTSTATUS = 0xC0380014; +pub const STATUS_VOLMGR_DISK_SECTOR_SIZE_INVALID: NTSTATUS = 0xC0380015; +pub const STATUS_VOLMGR_DISK_SET_NOT_CONTAINED: NTSTATUS = 0xC0380016; +pub const STATUS_VOLMGR_DISK_USED_BY_MULTIPLE_MEMBERS: NTSTATUS = 0xC0380017; +pub const STATUS_VOLMGR_DISK_USED_BY_MULTIPLE_PLEXES: NTSTATUS = 0xC0380018; +pub const STATUS_VOLMGR_DYNAMIC_DISK_NOT_SUPPORTED: NTSTATUS = 0xC0380019; +pub const STATUS_VOLMGR_EXTENT_ALREADY_USED: NTSTATUS = 0xC038001A; +pub const STATUS_VOLMGR_EXTENT_NOT_CONTIGUOUS: NTSTATUS = 0xC038001B; +pub const STATUS_VOLMGR_EXTENT_NOT_IN_PUBLIC_REGION: NTSTATUS = 0xC038001C; +pub const STATUS_VOLMGR_EXTENT_NOT_SECTOR_ALIGNED: NTSTATUS = 0xC038001D; +pub const STATUS_VOLMGR_EXTENT_OVERLAPS_EBR_PARTITION: NTSTATUS = 0xC038001E; +pub const STATUS_VOLMGR_EXTENT_VOLUME_LENGTHS_DO_NOT_MATCH: NTSTATUS = 0xC038001F; +pub const STATUS_VOLMGR_FAULT_TOLERANT_NOT_SUPPORTED: NTSTATUS = 0xC0380020; +pub const STATUS_VOLMGR_INTERLEAVE_LENGTH_INVALID: NTSTATUS = 0xC0380021; +pub const STATUS_VOLMGR_MAXIMUM_REGISTERED_USERS: NTSTATUS = 0xC0380022; +pub const STATUS_VOLMGR_MEMBER_IN_SYNC: NTSTATUS = 0xC0380023; +pub const STATUS_VOLMGR_MEMBER_INDEX_DUPLICATE: NTSTATUS = 0xC0380024; +pub const STATUS_VOLMGR_MEMBER_INDEX_INVALID: NTSTATUS = 0xC0380025; +pub const STATUS_VOLMGR_MEMBER_MISSING: NTSTATUS = 0xC0380026; +pub const STATUS_VOLMGR_MEMBER_NOT_DETACHED: NTSTATUS = 0xC0380027; +pub const STATUS_VOLMGR_MEMBER_REGENERATING: NTSTATUS = 0xC0380028; +pub const STATUS_VOLMGR_ALL_DISKS_FAILED: NTSTATUS = 0xC0380029; +pub const STATUS_VOLMGR_NO_REGISTERED_USERS: NTSTATUS = 0xC038002A; +pub const STATUS_VOLMGR_NO_SUCH_USER: NTSTATUS = 0xC038002B; +pub const STATUS_VOLMGR_NOTIFICATION_RESET: NTSTATUS = 0xC038002C; +pub const STATUS_VOLMGR_NUMBER_OF_MEMBERS_INVALID: NTSTATUS = 0xC038002D; +pub const STATUS_VOLMGR_NUMBER_OF_PLEXES_INVALID: NTSTATUS = 0xC038002E; +pub const STATUS_VOLMGR_PACK_DUPLICATE: NTSTATUS = 0xC038002F; +pub const STATUS_VOLMGR_PACK_ID_INVALID: NTSTATUS = 0xC0380030; +pub const STATUS_VOLMGR_PACK_INVALID: NTSTATUS = 0xC0380031; +pub const STATUS_VOLMGR_PACK_NAME_INVALID: NTSTATUS = 0xC0380032; +pub const STATUS_VOLMGR_PACK_OFFLINE: NTSTATUS = 0xC0380033; +pub const STATUS_VOLMGR_PACK_HAS_QUORUM: NTSTATUS = 0xC0380034; +pub const STATUS_VOLMGR_PACK_WITHOUT_QUORUM: NTSTATUS = 0xC0380035; +pub const STATUS_VOLMGR_PARTITION_STYLE_INVALID: NTSTATUS = 0xC0380036; +pub const STATUS_VOLMGR_PARTITION_UPDATE_FAILED: NTSTATUS = 0xC0380037; +pub const STATUS_VOLMGR_PLEX_IN_SYNC: NTSTATUS = 0xC0380038; +pub const STATUS_VOLMGR_PLEX_INDEX_DUPLICATE: NTSTATUS = 0xC0380039; +pub const STATUS_VOLMGR_PLEX_INDEX_INVALID: NTSTATUS = 0xC038003A; +pub const STATUS_VOLMGR_PLEX_LAST_ACTIVE: NTSTATUS = 0xC038003B; +pub const STATUS_VOLMGR_PLEX_MISSING: NTSTATUS = 0xC038003C; +pub const STATUS_VOLMGR_PLEX_REGENERATING: NTSTATUS = 0xC038003D; +pub const STATUS_VOLMGR_PLEX_TYPE_INVALID: NTSTATUS = 0xC038003E; +pub const STATUS_VOLMGR_PLEX_NOT_RAID5: NTSTATUS = 0xC038003F; +pub const STATUS_VOLMGR_PLEX_NOT_SIMPLE: NTSTATUS = 0xC0380040; +pub const STATUS_VOLMGR_STRUCTURE_SIZE_INVALID: NTSTATUS = 0xC0380041; +pub const STATUS_VOLMGR_TOO_MANY_NOTIFICATION_REQUESTS: NTSTATUS = 0xC0380042; +pub const STATUS_VOLMGR_TRANSACTION_IN_PROGRESS: NTSTATUS = 0xC0380043; +pub const STATUS_VOLMGR_UNEXPECTED_DISK_LAYOUT_CHANGE: NTSTATUS = 0xC0380044; +pub const STATUS_VOLMGR_VOLUME_CONTAINS_MISSING_DISK: NTSTATUS = 0xC0380045; +pub const STATUS_VOLMGR_VOLUME_ID_INVALID: NTSTATUS = 0xC0380046; +pub const STATUS_VOLMGR_VOLUME_LENGTH_INVALID: NTSTATUS = 0xC0380047; +pub const STATUS_VOLMGR_VOLUME_LENGTH_NOT_SECTOR_SIZE_MULTIPLE: NTSTATUS = 0xC0380048; +pub const STATUS_VOLMGR_VOLUME_NOT_MIRRORED: NTSTATUS = 0xC0380049; +pub const STATUS_VOLMGR_VOLUME_NOT_RETAINED: NTSTATUS = 0xC038004A; +pub const STATUS_VOLMGR_VOLUME_OFFLINE: NTSTATUS = 0xC038004B; +pub const STATUS_VOLMGR_VOLUME_RETAINED: NTSTATUS = 0xC038004C; +pub const STATUS_VOLMGR_NUMBER_OF_EXTENTS_INVALID: NTSTATUS = 0xC038004D; +pub const STATUS_VOLMGR_DIFFERENT_SECTOR_SIZE: NTSTATUS = 0xC038004E; +pub const STATUS_VOLMGR_BAD_BOOT_DISK: NTSTATUS = 0xC038004F; +pub const STATUS_VOLMGR_PACK_CONFIG_OFFLINE: NTSTATUS = 0xC0380050; +pub const STATUS_VOLMGR_PACK_CONFIG_ONLINE: NTSTATUS = 0xC0380051; +pub const STATUS_VOLMGR_NOT_PRIMARY_PACK: NTSTATUS = 0xC0380052; +pub const STATUS_VOLMGR_PACK_LOG_UPDATE_FAILED: NTSTATUS = 0xC0380053; +pub const STATUS_VOLMGR_NUMBER_OF_DISKS_IN_PLEX_INVALID: NTSTATUS = 0xC0380054; +pub const STATUS_VOLMGR_NUMBER_OF_DISKS_IN_MEMBER_INVALID: NTSTATUS = 0xC0380055; +pub const STATUS_VOLMGR_VOLUME_MIRRORED: NTSTATUS = 0xC0380056; +pub const STATUS_VOLMGR_PLEX_NOT_SIMPLE_SPANNED: NTSTATUS = 0xC0380057; +pub const STATUS_VOLMGR_NO_VALID_LOG_COPIES: NTSTATUS = 0xC0380058; +pub const STATUS_VOLMGR_PRIMARY_PACK_PRESENT: NTSTATUS = 0xC0380059; +pub const STATUS_VOLMGR_NUMBER_OF_DISKS_INVALID: NTSTATUS = 0xC038005A; +pub const STATUS_VOLMGR_MIRROR_NOT_SUPPORTED: NTSTATUS = 0xC038005B; +pub const STATUS_VOLMGR_RAID5_NOT_SUPPORTED: NTSTATUS = 0xC038005C; +pub const STATUS_BCD_NOT_ALL_ENTRIES_IMPORTED: NTSTATUS = 0x80390001; +pub const STATUS_BCD_TOO_MANY_ELEMENTS: NTSTATUS = 0xC0390002; +pub const STATUS_BCD_NOT_ALL_ENTRIES_SYNCHRONIZED: NTSTATUS = 0x80390003; +pub const STATUS_VHD_DRIVE_FOOTER_MISSING: NTSTATUS = 0xC03A0001; +pub const STATUS_VHD_DRIVE_FOOTER_CHECKSUM_MISMATCH: NTSTATUS = 0xC03A0002; +pub const STATUS_VHD_DRIVE_FOOTER_CORRUPT: NTSTATUS = 0xC03A0003; +pub const STATUS_VHD_FORMAT_UNKNOWN: NTSTATUS = 0xC03A0004; +pub const STATUS_VHD_FORMAT_UNSUPPORTED_VERSION: NTSTATUS = 0xC03A0005; +pub const STATUS_VHD_SPARSE_HEADER_CHECKSUM_MISMATCH: NTSTATUS = 0xC03A0006; +pub const STATUS_VHD_SPARSE_HEADER_UNSUPPORTED_VERSION: NTSTATUS = 0xC03A0007; +pub const STATUS_VHD_SPARSE_HEADER_CORRUPT: NTSTATUS = 0xC03A0008; +pub const STATUS_VHD_BLOCK_ALLOCATION_FAILURE: NTSTATUS = 0xC03A0009; +pub const STATUS_VHD_BLOCK_ALLOCATION_TABLE_CORRUPT: NTSTATUS = 0xC03A000A; +pub const STATUS_VHD_INVALID_BLOCK_SIZE: NTSTATUS = 0xC03A000B; +pub const STATUS_VHD_BITMAP_MISMATCH: NTSTATUS = 0xC03A000C; +pub const STATUS_VHD_PARENT_VHD_NOT_FOUND: NTSTATUS = 0xC03A000D; +pub const STATUS_VHD_CHILD_PARENT_ID_MISMATCH: NTSTATUS = 0xC03A000E; +pub const STATUS_VHD_CHILD_PARENT_TIMESTAMP_MISMATCH: NTSTATUS = 0xC03A000F; +pub const STATUS_VHD_METADATA_READ_FAILURE: NTSTATUS = 0xC03A0010; +pub const STATUS_VHD_METADATA_WRITE_FAILURE: NTSTATUS = 0xC03A0011; +pub const STATUS_VHD_INVALID_SIZE: NTSTATUS = 0xC03A0012; +pub const STATUS_VHD_INVALID_FILE_SIZE: NTSTATUS = 0xC03A0013; +pub const STATUS_VIRTDISK_PROVIDER_NOT_FOUND: NTSTATUS = 0xC03A0014; +pub const STATUS_VIRTDISK_NOT_VIRTUAL_DISK: NTSTATUS = 0xC03A0015; +pub const STATUS_VHD_PARENT_VHD_ACCESS_DENIED: NTSTATUS = 0xC03A0016; +pub const STATUS_VHD_CHILD_PARENT_SIZE_MISMATCH: NTSTATUS = 0xC03A0017; +pub const STATUS_VHD_DIFFERENCING_CHAIN_CYCLE_DETECTED: NTSTATUS = 0xC03A0018; +pub const STATUS_VHD_DIFFERENCING_CHAIN_ERROR_IN_PARENT: NTSTATUS = 0xC03A0019; +pub const STATUS_VIRTUAL_DISK_LIMITATION: NTSTATUS = 0xC03A001A; +pub const STATUS_VHD_INVALID_TYPE: NTSTATUS = 0xC03A001B; +pub const STATUS_VHD_INVALID_STATE: NTSTATUS = 0xC03A001C; +pub const STATUS_VIRTDISK_UNSUPPORTED_DISK_SECTOR_SIZE: NTSTATUS = 0xC03A001D; +pub const STATUS_VIRTDISK_DISK_ALREADY_OWNED: NTSTATUS = 0xC03A001E; +pub const STATUS_VIRTDISK_DISK_ONLINE_AND_WRITABLE: NTSTATUS = 0xC03A001F; +pub const STATUS_CTLOG_TRACKING_NOT_INITIALIZED: NTSTATUS = 0xC03A0020; +pub const STATUS_CTLOG_LOGFILE_SIZE_EXCEEDED_MAXSIZE: NTSTATUS = 0xC03A0021; +pub const STATUS_CTLOG_VHD_CHANGED_OFFLINE: NTSTATUS = 0xC03A0022; +pub const STATUS_CTLOG_INVALID_TRACKING_STATE: NTSTATUS = 0xC03A0023; +pub const STATUS_CTLOG_INCONSISTENT_TRACKING_FILE: NTSTATUS = 0xC03A0024; +pub const STATUS_VHD_METADATA_FULL: NTSTATUS = 0xC03A0028; +pub const STATUS_VHD_INVALID_CHANGE_TRACKING_ID: NTSTATUS = 0xC03A0029; +pub const STATUS_VHD_CHANGE_TRACKING_DISABLED: NTSTATUS = 0xC03A002A; +pub const STATUS_VHD_MISSING_CHANGE_TRACKING_INFORMATION: NTSTATUS = 0xC03A0030; +pub const STATUS_VHD_RESIZE_WOULD_TRUNCATE_DATA: NTSTATUS = 0xC03A0031; +pub const STATUS_VHD_COULD_NOT_COMPUTE_MINIMUM_VIRTUAL_SIZE: NTSTATUS = 0xC03A0032; +pub const STATUS_VHD_ALREADY_AT_OR_BELOW_MINIMUM_VIRTUAL_SIZE: NTSTATUS = 0xC03A0033; +pub const STATUS_QUERY_STORAGE_ERROR: NTSTATUS = 0x803A0001; +pub const STATUS_RKF_KEY_NOT_FOUND: NTSTATUS = 0xC0400001; +pub const STATUS_RKF_DUPLICATE_KEY: NTSTATUS = 0xC0400002; +pub const STATUS_RKF_BLOB_FULL: NTSTATUS = 0xC0400003; +pub const STATUS_RKF_STORE_FULL: NTSTATUS = 0xC0400004; +pub const STATUS_RKF_FILE_BLOCKED: NTSTATUS = 0xC0400005; +pub const STATUS_RKF_ACTIVE_KEY: NTSTATUS = 0xC0400006; +pub const STATUS_RDBSS_RESTART_OPERATION: NTSTATUS = 0xC0410001; +pub const STATUS_RDBSS_CONTINUE_OPERATION: NTSTATUS = 0xC0410002; +pub const STATUS_RDBSS_POST_OPERATION: NTSTATUS = 0xC0410003; +pub const STATUS_BTH_ATT_INVALID_HANDLE: NTSTATUS = 0xC0420001; +pub const STATUS_BTH_ATT_READ_NOT_PERMITTED: NTSTATUS = 0xC0420002; +pub const STATUS_BTH_ATT_WRITE_NOT_PERMITTED: NTSTATUS = 0xC0420003; +pub const STATUS_BTH_ATT_INVALID_PDU: NTSTATUS = 0xC0420004; +pub const STATUS_BTH_ATT_INSUFFICIENT_AUTHENTICATION: NTSTATUS = 0xC0420005; +pub const STATUS_BTH_ATT_REQUEST_NOT_SUPPORTED: NTSTATUS = 0xC0420006; +pub const STATUS_BTH_ATT_INVALID_OFFSET: NTSTATUS = 0xC0420007; +pub const STATUS_BTH_ATT_INSUFFICIENT_AUTHORIZATION: NTSTATUS = 0xC0420008; +pub const STATUS_BTH_ATT_PREPARE_QUEUE_FULL: NTSTATUS = 0xC0420009; +pub const STATUS_BTH_ATT_ATTRIBUTE_NOT_FOUND: NTSTATUS = 0xC042000A; +pub const STATUS_BTH_ATT_ATTRIBUTE_NOT_LONG: NTSTATUS = 0xC042000B; +pub const STATUS_BTH_ATT_INSUFFICIENT_ENCRYPTION_KEY_SIZE: NTSTATUS = 0xC042000C; +pub const STATUS_BTH_ATT_INVALID_ATTRIBUTE_VALUE_LENGTH: NTSTATUS = 0xC042000D; +pub const STATUS_BTH_ATT_UNLIKELY: NTSTATUS = 0xC042000E; +pub const STATUS_BTH_ATT_INSUFFICIENT_ENCRYPTION: NTSTATUS = 0xC042000F; +pub const STATUS_BTH_ATT_UNSUPPORTED_GROUP_TYPE: NTSTATUS = 0xC0420010; +pub const STATUS_BTH_ATT_INSUFFICIENT_RESOURCES: NTSTATUS = 0xC0420011; +pub const STATUS_BTH_ATT_UNKNOWN_ERROR: NTSTATUS = 0xC0421000; +pub const STATUS_SECUREBOOT_ROLLBACK_DETECTED: NTSTATUS = 0xC0430001; +pub const STATUS_SECUREBOOT_POLICY_VIOLATION: NTSTATUS = 0xC0430002; +pub const STATUS_SECUREBOOT_INVALID_POLICY: NTSTATUS = 0xC0430003; +pub const STATUS_SECUREBOOT_POLICY_PUBLISHER_NOT_FOUND: NTSTATUS = 0xC0430004; +pub const STATUS_SECUREBOOT_POLICY_NOT_SIGNED: NTSTATUS = 0xC0430005; +pub const STATUS_SECUREBOOT_NOT_ENABLED: NTSTATUS = 0x80430006; +pub const STATUS_SECUREBOOT_FILE_REPLACED: NTSTATUS = 0xC0430007; +pub const STATUS_SECUREBOOT_POLICY_NOT_AUTHORIZED: NTSTATUS = 0xC0430008; +pub const STATUS_SECUREBOOT_POLICY_UNKNOWN: NTSTATUS = 0xC0430009; +pub const STATUS_SECUREBOOT_POLICY_MISSING_ANTIROLLBACKVERSION: NTSTATUS = 0xC043000A; +pub const STATUS_SECUREBOOT_PLATFORM_ID_MISMATCH: NTSTATUS = 0xC043000B; +pub const STATUS_SECUREBOOT_POLICY_ROLLBACK_DETECTED: NTSTATUS = 0xC043000C; +pub const STATUS_SECUREBOOT_POLICY_UPGRADE_MISMATCH: NTSTATUS = 0xC043000D; +pub const STATUS_SECUREBOOT_REQUIRED_POLICY_FILE_MISSING: NTSTATUS = 0xC043000E; +pub const STATUS_SECUREBOOT_NOT_BASE_POLICY: NTSTATUS = 0xC043000F; +pub const STATUS_SECUREBOOT_NOT_SUPPLEMENTAL_POLICY: NTSTATUS = 0xC0430010; +pub const STATUS_PLATFORM_MANIFEST_NOT_AUTHORIZED: NTSTATUS = 0xC0EB0001; +pub const STATUS_PLATFORM_MANIFEST_INVALID: NTSTATUS = 0xC0EB0002; +pub const STATUS_PLATFORM_MANIFEST_FILE_NOT_AUTHORIZED: NTSTATUS = 0xC0EB0003; +pub const STATUS_PLATFORM_MANIFEST_CATALOG_NOT_AUTHORIZED: NTSTATUS = 0xC0EB0004; +pub const STATUS_PLATFORM_MANIFEST_BINARY_ID_NOT_FOUND: NTSTATUS = 0xC0EB0005; +pub const STATUS_PLATFORM_MANIFEST_NOT_ACTIVE: NTSTATUS = 0xC0EB0006; +pub const STATUS_PLATFORM_MANIFEST_NOT_SIGNED: NTSTATUS = 0xC0EB0007; +pub const STATUS_SYSTEM_INTEGRITY_ROLLBACK_DETECTED: NTSTATUS = 0xC0E90001; +pub const STATUS_SYSTEM_INTEGRITY_POLICY_VIOLATION: NTSTATUS = 0xC0E90002; +pub const STATUS_SYSTEM_INTEGRITY_INVALID_POLICY: NTSTATUS = 0xC0E90003; +pub const STATUS_SYSTEM_INTEGRITY_POLICY_NOT_SIGNED: NTSTATUS = 0xC0E90004; +pub const STATUS_NO_APPLICABLE_APP_LICENSES_FOUND: NTSTATUS = 0xC0EA0001; +pub const STATUS_CLIP_LICENSE_NOT_FOUND: NTSTATUS = 0xC0EA0002; +pub const STATUS_CLIP_DEVICE_LICENSE_MISSING: NTSTATUS = 0xC0EA0003; +pub const STATUS_CLIP_LICENSE_INVALID_SIGNATURE: NTSTATUS = 0xC0EA0004; +pub const STATUS_CLIP_KEYHOLDER_LICENSE_MISSING_OR_INVALID: NTSTATUS = 0xC0EA0005; +pub const STATUS_CLIP_LICENSE_EXPIRED: NTSTATUS = 0xC0EA0006; +pub const STATUS_CLIP_LICENSE_SIGNED_BY_UNKNOWN_SOURCE: NTSTATUS = 0xC0EA0007; +pub const STATUS_CLIP_LICENSE_NOT_SIGNED: NTSTATUS = 0xC0EA0008; +pub const STATUS_CLIP_LICENSE_HARDWARE_ID_OUT_OF_TOLERANCE: NTSTATUS = 0xC0EA0009; +pub const STATUS_CLIP_LICENSE_DEVICE_ID_MISMATCH: NTSTATUS = 0xC0EA000A; +pub const STATUS_AUDIO_ENGINE_NODE_NOT_FOUND: NTSTATUS = 0xC0440001; +pub const STATUS_HDAUDIO_EMPTY_CONNECTION_LIST: NTSTATUS = 0xC0440002; +pub const STATUS_HDAUDIO_CONNECTION_LIST_NOT_SUPPORTED: NTSTATUS = 0xC0440003; +pub const STATUS_HDAUDIO_NO_LOGICAL_DEVICES_CREATED: NTSTATUS = 0xC0440004; +pub const STATUS_HDAUDIO_NULL_LINKED_LIST_ENTRY: NTSTATUS = 0xC0440005; +pub const STATUS_SPACES_REPAIRED: NTSTATUS = 0x00E70000; +pub const STATUS_SPACES_PAUSE: NTSTATUS = 0x00E70001; +pub const STATUS_SPACES_COMPLETE: NTSTATUS = 0x00E70002; +pub const STATUS_SPACES_FAULT_DOMAIN_TYPE_INVALID: NTSTATUS = 0xC0E70001; +pub const STATUS_SPACES_RESILIENCY_TYPE_INVALID: NTSTATUS = 0xC0E70003; +pub const STATUS_SPACES_DRIVE_SECTOR_SIZE_INVALID: NTSTATUS = 0xC0E70004; +pub const STATUS_SPACES_DRIVE_REDUNDANCY_INVALID: NTSTATUS = 0xC0E70006; +pub const STATUS_SPACES_NUMBER_OF_DATA_COPIES_INVALID: NTSTATUS = 0xC0E70007; +pub const STATUS_SPACES_INTERLEAVE_LENGTH_INVALID: NTSTATUS = 0xC0E70009; +pub const STATUS_SPACES_NUMBER_OF_COLUMNS_INVALID: NTSTATUS = 0xC0E7000A; +pub const STATUS_SPACES_NOT_ENOUGH_DRIVES: NTSTATUS = 0xC0E7000B; +pub const STATUS_SPACES_EXTENDED_ERROR: NTSTATUS = 0xC0E7000C; +pub const STATUS_SPACES_PROVISIONING_TYPE_INVALID: NTSTATUS = 0xC0E7000D; +pub const STATUS_SPACES_ALLOCATION_SIZE_INVALID: NTSTATUS = 0xC0E7000E; +pub const STATUS_SPACES_ENCLOSURE_AWARE_INVALID: NTSTATUS = 0xC0E7000F; +pub const STATUS_SPACES_WRITE_CACHE_SIZE_INVALID: NTSTATUS = 0xC0E70010; +pub const STATUS_SPACES_NUMBER_OF_GROUPS_INVALID: NTSTATUS = 0xC0E70011; +pub const STATUS_SPACES_DRIVE_OPERATIONAL_STATE_INVALID: NTSTATUS = 0xC0E70012; +pub const STATUS_SPACES_UPDATE_COLUMN_STATE: NTSTATUS = 0xC0E70013; +pub const STATUS_SPACES_MAP_REQUIRED: NTSTATUS = 0xC0E70014; +pub const STATUS_SPACES_UNSUPPORTED_VERSION: NTSTATUS = 0xC0E70015; +pub const STATUS_SPACES_CORRUPT_METADATA: NTSTATUS = 0xC0E70016; +pub const STATUS_SPACES_DRT_FULL: NTSTATUS = 0xC0E70017; +pub const STATUS_SPACES_INCONSISTENCY: NTSTATUS = 0xC0E70018; +pub const STATUS_SPACES_LOG_NOT_READY: NTSTATUS = 0xC0E70019; +pub const STATUS_SPACES_NO_REDUNDANCY: NTSTATUS = 0xC0E7001A; +pub const STATUS_SPACES_DRIVE_NOT_READY: NTSTATUS = 0xC0E7001B; +pub const STATUS_SPACES_DRIVE_SPLIT: NTSTATUS = 0xC0E7001C; +pub const STATUS_SPACES_DRIVE_LOST_DATA: NTSTATUS = 0xC0E7001D; +pub const STATUS_VOLSNAP_BOOTFILE_NOT_VALID: NTSTATUS = 0xC0500003; +pub const STATUS_VOLSNAP_ACTIVATION_TIMEOUT: NTSTATUS = 0xC0500004; +pub const STATUS_IO_PREEMPTED: NTSTATUS = 0xC0510001; +pub const STATUS_SVHDX_ERROR_STORED: NTSTATUS = 0xC05C0000; +pub const STATUS_SVHDX_ERROR_NOT_AVAILABLE: NTSTATUS = 0xC05CFF00; +pub const STATUS_SVHDX_UNIT_ATTENTION_AVAILABLE: NTSTATUS = 0xC05CFF01; +pub const STATUS_SVHDX_UNIT_ATTENTION_CAPACITY_DATA_CHANGED: NTSTATUS = 0xC05CFF02; +pub const STATUS_SVHDX_UNIT_ATTENTION_RESERVATIONS_PREEMPTED: NTSTATUS = 0xC05CFF03; +pub const STATUS_SVHDX_UNIT_ATTENTION_RESERVATIONS_RELEASED: NTSTATUS = 0xC05CFF04; +pub const STATUS_SVHDX_UNIT_ATTENTION_REGISTRATIONS_PREEMPTED: NTSTATUS = 0xC05CFF05; +pub const STATUS_SVHDX_UNIT_ATTENTION_OPERATING_DEFINITION_CHANGED: NTSTATUS + = 0xC05CFF06; +pub const STATUS_SVHDX_RESERVATION_CONFLICT: NTSTATUS = 0xC05CFF07; +pub const STATUS_SVHDX_WRONG_FILE_TYPE: NTSTATUS = 0xC05CFF08; +pub const STATUS_SVHDX_VERSION_MISMATCH: NTSTATUS = 0xC05CFF09; +pub const STATUS_VHD_SHARED: NTSTATUS = 0xC05CFF0A; +pub const STATUS_SVHDX_NO_INITIATOR: NTSTATUS = 0xC05CFF0B; +pub const STATUS_VHDSET_BACKING_STORAGE_NOT_FOUND: NTSTATUS = 0xC05CFF0C; +pub const STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP: NTSTATUS = 0xC05D0000; +pub const STATUS_SMB_BAD_CLUSTER_DIALECT: NTSTATUS = 0xC05D0001; +pub const STATUS_SMB_GUEST_LOGON_BLOCKED: NTSTATUS = 0xC05D0002; +pub const STATUS_SECCORE_INVALID_COMMAND: NTSTATUS = 0xC0E80000; +pub const STATUS_VSM_NOT_INITIALIZED: NTSTATUS = 0xC0450000; +pub const STATUS_VSM_DMA_PROTECTION_NOT_IN_USE: NTSTATUS = 0xC0450001; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/qos.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/qos.rs new file mode 100644 index 0000000..5117bd2 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/qos.rs @@ -0,0 +1,20 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! QoS definitions for NDIS components. +use shared::minwindef::ULONG; +pub type SERVICETYPE = ULONG; +STRUCT!{struct FLOWSPEC { + TokenRate: ULONG, + TokenBucketSize: ULONG, + PeakBandwidth: ULONG, + Latency: ULONG, + DelayVariation: ULONG, + ServiceType: SERVICETYPE, + MaxSduSize: ULONG, + MinimumPolicedSize: ULONG, +}} +pub type PFLOWSPEC = *mut FLOWSPEC; +pub type LPFLOWSPEC = *mut FLOWSPEC; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/rpc.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/rpc.rs new file mode 100644 index 0000000..5af7e09 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/rpc.rs @@ -0,0 +1,9 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Master include file for RPC applications. +use ctypes::{c_long, c_void}; +pub type I_RPC_HANDLE = *mut c_void; +pub type RPC_STATUS = c_long; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/rpcdce.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/rpcdce.rs new file mode 100644 index 0000000..ab2879d --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/rpcdce.rs @@ -0,0 +1,563 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module contains the DCE RPC runtime APIs. +use ctypes::{c_int, c_uchar, c_uint, c_ulong, c_ushort, c_void, wchar_t}; +use shared::guiddef::GUID; +use shared::minwindef::DWORD; +use shared::rpc::{I_RPC_HANDLE, RPC_STATUS}; +pub type RPC_CSTR = *mut c_uchar; +pub type RPC_WSTR = *mut wchar_t; +pub type RPC_CWSTR = *const wchar_t; +pub type RPC_BINDING_HANDLE = I_RPC_HANDLE; +pub type handle_t = RPC_BINDING_HANDLE; +pub type rpc_binding_handle_t = RPC_BINDING_HANDLE; +pub type UUID = GUID; +pub type uuid_t = UUID; +STRUCT!{struct RPC_BINDING_VECTOR { + Count: c_ulong, + BindingH: [RPC_BINDING_HANDLE; 1], +}} +pub type rpc_binding_vector_t = RPC_BINDING_VECTOR; +STRUCT!{struct UUID_VECTOR { + Count: c_ulong, + Uuid: [*mut UUID; 1], +}} +pub type uuid_vector_t = UUID_VECTOR; +pub type RPC_IF_HANDLE = *mut c_void; +STRUCT!{struct RPC_IF_ID { + Uuid: UUID, + VersMajor: c_ushort, + VersMinor: c_ushort, +}} +pub const RPC_C_BINDING_INFINITE_TIMEOUT: DWORD = 10; +pub const RPC_C_BINDING_MIN_TIMEOUT: DWORD = 0; +pub const RPC_C_BINDING_DEFAULT_TIMEOUT: DWORD = 5; +pub const RPC_C_BINDING_MAX_TIMEOUT: DWORD = 9; +pub const RPC_C_CANCEL_INFINITE_TIMEOUT: c_int = -1; +pub const RPC_C_LISTEN_MAX_CALLS_DEFAULT: DWORD = 1234; +pub const RPC_C_PROTSEQ_MAX_REQS_DEFAULT: DWORD = 10; +pub const RPC_C_BIND_TO_ALL_NICS: DWORD = 1; +pub const RPC_C_USE_INTERNET_PORT: DWORD = 0x1; +pub const RPC_C_USE_INTRANET_PORT: DWORD = 0x2; +pub const RPC_C_DONT_FAIL: DWORD = 0x4; +pub const RPC_C_RPCHTTP_USE_LOAD_BALANCE: DWORD = 0x8; +pub const RPC_C_MQ_TEMPORARY: DWORD = 0x0000; +pub const RPC_C_MQ_PERMANENT: DWORD = 0x0001; +pub const RPC_C_MQ_CLEAR_ON_OPEN: DWORD = 0x0002; +pub const RPC_C_MQ_USE_EXISTING_SECURITY: DWORD = 0x0004; +pub const RPC_C_MQ_AUTHN_LEVEL_NONE: DWORD = 0x0000; +pub const RPC_C_MQ_AUTHN_LEVEL_PKT_INTEGRITY: DWORD = 0x0008; +pub const RPC_C_MQ_AUTHN_LEVEL_PKT_PRIVACY: DWORD = 0x0010; +pub const RPC_C_OPT_MQ_DELIVERY: DWORD = 1; +pub const RPC_C_OPT_MQ_PRIORITY: DWORD = 2; +pub const RPC_C_OPT_MQ_JOURNAL: DWORD = 3; +pub const RPC_C_OPT_MQ_ACKNOWLEDGE: DWORD = 4; +pub const RPC_C_OPT_MQ_AUTHN_SERVICE: DWORD = 5; +pub const RPC_C_OPT_MQ_AUTHN_LEVEL: DWORD = 6; +pub const RPC_C_OPT_MQ_TIME_TO_REACH_QUEUE: DWORD = 7; +pub const RPC_C_OPT_MQ_TIME_TO_BE_RECEIVED: DWORD = 8; +pub const RPC_C_OPT_BINDING_NONCAUSAL: DWORD = 9; +pub const RPC_C_OPT_SECURITY_CALLBACK: DWORD = 10; +pub const RPC_C_OPT_UNIQUE_BINDING: DWORD = 11; +pub const RPC_C_OPT_CALL_TIMEOUT: DWORD = 12; +pub const RPC_C_OPT_DONT_LINGER: DWORD = 13; +pub const RPC_C_OPT_TRUST_PEER: DWORD = 14; +pub const RPC_C_OPT_ASYNC_BLOCK: DWORD = 15; +pub const RPC_C_OPT_OPTIMIZE_TIME: DWORD = 16; +pub const RPC_C_OPT_MAX_OPTIONS: DWORD = 17; +pub const RPC_C_MQ_EXPRESS: DWORD = 0; +pub const RPC_C_MQ_RECOVERABLE: DWORD = 1; +pub const RPC_C_MQ_JOURNAL_NONE: DWORD = 0; +pub const RPC_C_MQ_JOURNAL_DEADLETTER: DWORD = 1; +pub const RPC_C_MQ_JOURNAL_ALWAYS: DWORD = 2; +pub const RPC_C_FULL_CERT_CHAIN: DWORD = 0x0001; +STRUCT!{struct RPC_PROTSEQ_VECTORA { + Count: c_uint, + Protseq: [*mut c_uchar; 1], +}} +STRUCT!{struct RPC_PROTSEQ_VECTORW { + Count: c_uint, + Protseq: [*mut c_ushort; 1], +}} +STRUCT!{struct RPC_POLICY { + Length: c_uint, + EndpointFlags: c_ulong, + NICFlags: c_ulong, +}} +pub type PRPC_POLICY = *mut RPC_POLICY; +FN!{stdcall RPC_OBJECT_INQ_FN( + ObjectUuid: *mut UUID, + TypeUuid: *mut UUID, + Status: *mut RPC_STATUS, +) -> ()} +FN!{stdcall RPC_IF_CALLBACK_FN( + InterfaceUuid: RPC_IF_HANDLE, + Context: *mut c_void, +) -> RPC_STATUS} +FN!{stdcall RPC_SECURITY_CALLBACK_FN( + Context: *mut c_void, +) -> ()} +pub type RPC_MGR_EPV = c_void; +STRUCT!{struct RPC_STATS_VECTOR { + Count: c_uint, + Stats: [c_ulong; 1], +}} +pub const RPC_C_STATS_CALLS_IN: c_ulong = 0; +pub const RPC_C_STATS_CALLS_OUT: c_ulong = 1; +pub const RPC_C_STATS_PKTS_IN: c_ulong = 2; +pub const RPC_C_STATS_PKTS_OUT: c_ulong = 3; +STRUCT!{struct RPC_IF_ID_VECTOR { + Count: c_ulong, + IfId: [*mut RPC_IF_ID; 1], +}} +pub type RPC_AUTH_IDENTITY_HANDLE = *mut c_void; +pub type RPC_AUTHZ_HANDLE = *mut c_void; +pub const RPC_C_AUTHN_LEVEL_DEFAULT: DWORD = 0; +pub const RPC_C_AUTHN_LEVEL_NONE: DWORD = 1; +pub const RPC_C_AUTHN_LEVEL_CONNECT: DWORD = 2; +pub const RPC_C_AUTHN_LEVEL_CALL: DWORD = 3; +pub const RPC_C_AUTHN_LEVEL_PKT: DWORD = 4; +pub const RPC_C_AUTHN_LEVEL_PKT_INTEGRITY: DWORD = 5; +pub const RPC_C_AUTHN_LEVEL_PKT_PRIVACY: DWORD = 6; +pub const RPC_C_IMP_LEVEL_DEFAULT: DWORD = 0; +pub const RPC_C_IMP_LEVEL_ANONYMOUS: DWORD = 1; +pub const RPC_C_IMP_LEVEL_IDENTIFY: DWORD = 2; +pub const RPC_C_IMP_LEVEL_IMPERSONATE: DWORD = 3; +pub const RPC_C_IMP_LEVEL_DELEGATE: DWORD = 4; +pub const RPC_C_QOS_IDENTITY_STATIC: DWORD = 0; +pub const RPC_C_QOS_IDENTITY_DYNAMIC: DWORD = 1; +pub const RPC_C_QOS_CAPABILITIES_DEFAULT: DWORD = 0x0; +pub const RPC_C_QOS_CAPABILITIES_MUTUAL_AUTH: DWORD = 0x1; +pub const RPC_C_QOS_CAPABILITIES_MAKE_FULLSIC: DWORD = 0x2; +pub const RPC_C_QOS_CAPABILITIES_ANY_AUTHORITY: DWORD = 0x4; +pub const RPC_C_QOS_CAPABILITIES_IGNORE_DELEGATE_FAILURE: DWORD = 0x8; +pub const RPC_C_QOS_CAPABILITIES_LOCAL_MA_HINT: DWORD = 0x10; +pub const RPC_C_QOS_CAPABILITIES_SCHANNEL_FULL_AUTH_IDENTITY: DWORD = 0x20; +pub const RPC_C_PROTECT_LEVEL_DEFAULT: DWORD = RPC_C_AUTHN_LEVEL_DEFAULT; +pub const RPC_C_PROTECT_LEVEL_NONE: DWORD = RPC_C_AUTHN_LEVEL_NONE; +pub const RPC_C_PROTECT_LEVEL_CONNECT: DWORD = RPC_C_AUTHN_LEVEL_CONNECT; +pub const RPC_C_PROTECT_LEVEL_CALL: DWORD = RPC_C_AUTHN_LEVEL_CALL; +pub const RPC_C_PROTECT_LEVEL_PKT: DWORD = RPC_C_AUTHN_LEVEL_PKT; +pub const RPC_C_PROTECT_LEVEL_PKT_INTEGRITY: DWORD = RPC_C_AUTHN_LEVEL_PKT_INTEGRITY; +pub const RPC_C_PROTECT_LEVEL_PKT_PRIVACY: DWORD = RPC_C_AUTHN_LEVEL_PKT_PRIVACY; +pub const RPC_C_AUTHN_NONE: DWORD = 0; +pub const RPC_C_AUTHN_DCE_PRIVATE: DWORD = 1; +pub const RPC_C_AUTHN_DCE_PUBLIC: DWORD = 2; +pub const RPC_C_AUTHN_DEC_PUBLIC: DWORD = 4; +pub const RPC_C_AUTHN_GSS_NEGOTIATE: DWORD = 9; +pub const RPC_C_AUTHN_WINNT: DWORD = 10; +pub const RPC_C_AUTHN_GSS_SCHANNEL: DWORD = 14; +pub const RPC_C_AUTHN_GSS_KERBEROS: DWORD = 16; +pub const RPC_C_AUTHN_DPA: DWORD = 17; +pub const RPC_C_AUTHN_MSN: DWORD = 18; +pub const RPC_C_AUTHN_DIGEST: DWORD = 21; +pub const RPC_C_AUTHN_KERNEL: DWORD = 20; +pub const RPC_C_AUTHN_NEGO_EXTENDER: DWORD = 30; +pub const RPC_C_AUTHN_PKU2U: DWORD = 31; +pub const RPC_C_AUTHN_LIVE_SSP: DWORD = 32; +pub const RPC_C_AUTHN_LIVEXP_SSP: DWORD = 35; +pub const RPC_C_AUTHN_MSONLINE: DWORD = 82; +pub const RPC_C_AUTHN_MQ: DWORD = 100; +pub const RPC_C_AUTHN_DEFAULT: DWORD = 0xFFFFFFFF; +pub const RPC_C_NO_CREDENTIALS: DWORD = 0xFFFFFFFF; +pub const RPC_C_SECURITY_QOS_VERSION: DWORD = 1; +pub const RPC_C_SECURITY_QOS_VERSION_1: DWORD = 1; +STRUCT!{struct RPC_SECURITY_QOS { + Version: c_ulong, + Capabilities: c_ulong, + IdentityTracking: c_ulong, + ImpersonationType: c_ulong, +}} +pub type PRPC_SECURITY_QOS = *mut RPC_SECURITY_QOS; +STRUCT!{struct SEC_WINNT_AUTH_IDENTITY_W { + User: *mut c_ushort, + UserLength: c_ulong, + Domain: *mut c_ushort, + DomainLength: c_ulong, + Password: *mut c_ushort, + PasswordLength: c_ulong, + Flags: c_ulong, +}} +pub type PSEC_WINNT_AUTH_IDENTITY_W = *mut SEC_WINNT_AUTH_IDENTITY_W; +STRUCT!{struct SEC_WINNT_AUTH_IDENTITY_A { + User: *mut c_uchar, + UserLength: c_ulong, + Domain: *mut c_uchar, + DomainLength: c_ulong, + Password: *mut c_uchar, + PasswordLength: c_ulong, + Flags: c_ulong, +}} +pub type PSEC_WINNT_AUTH_IDENTITY_A = *mut SEC_WINNT_AUTH_IDENTITY_A; +pub const RPC_C_AUTHN_INFO_TYPE_HTTP: c_ulong = 1; +pub const RPC_C_HTTP_AUTHN_TARGET_SERVER: c_ulong = 1; +pub const RPC_C_HTTP_AUTHN_TARGET_PROXY: c_ulong = 2; +pub const RPC_C_HTTP_AUTHN_SCHEME_BASIC: c_ulong = 0x00000001; +pub const RPC_C_HTTP_AUTHN_SCHEME_NTLM: c_ulong = 0x00000002; +pub const RPC_C_HTTP_AUTHN_SCHEME_PASSPORT: c_ulong = 0x00000004; +pub const RPC_C_HTTP_AUTHN_SCHEME_DIGEST: c_ulong = 0x00000008; +pub const RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE: c_ulong = 0x00000010; +pub const RPC_C_HTTP_AUTHN_SCHEME_CERT: c_ulong = 0x00010000; +pub const RPC_C_HTTP_FLAG_USE_SSL: c_ulong = 1; +pub const RPC_C_HTTP_FLAG_USE_FIRST_AUTH_SCHEME: c_ulong = 2; +pub const RPC_C_HTTP_FLAG_IGNORE_CERT_CN_INVALID: c_ulong = 8; +pub const RPC_C_HTTP_FLAG_ENABLE_CERT_REVOCATION_CHECK: c_ulong = 16; +STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_W { + TransportCredentials: *mut SEC_WINNT_AUTH_IDENTITY_W, + Flags: c_ulong, + AuthenticationTarget: c_ulong, + NumberOfAuthnSchemes: c_ulong, + AuthnSchemes: *mut c_ulong, + ServerCertificateSubject: *mut c_ushort, +}} +pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_W = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_W; +STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_A { + TransportCredentials: *mut SEC_WINNT_AUTH_IDENTITY_A, + Flags: c_ulong, + AuthenticationTarget: c_ulong, + NumberOfAuthnSchemes: c_ulong, + AuthnSchemes: *mut c_ulong, + ServerCertificateSubject: *mut c_uchar, +}} +pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_A = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_A; +STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_V2_W { + TransportCredentials: *mut SEC_WINNT_AUTH_IDENTITY_W, + Flags: c_ulong, + AuthenticationTarget: c_ulong, + NumberOfAuthnSchemes: c_ulong, + AuthnSchemes: *mut c_ulong, + ServerCertificateSubject: *mut c_ushort, + ProxyCredentials: *mut SEC_WINNT_AUTH_IDENTITY_W, + NumberOfProxyAuthnSchemes: c_ulong, + ProxyAuthnSchemes: *mut c_ulong, +}} +pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_V2_W = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_V2_W; +STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_V2_A { + TransportCredentials: *mut SEC_WINNT_AUTH_IDENTITY_A, + Flags: c_ulong, + AuthenticationTarget: c_ulong, + NumberOfAuthnSchemes: c_ulong, + AuthnSchemes: *mut c_ulong, + ServerCertificateSubject: *mut c_uchar, + ProxyCredentials: *mut SEC_WINNT_AUTH_IDENTITY_A, + NumberOfProxyAuthnSchemes: c_ulong, + ProxyAuthnSchemes: *mut c_ulong, +}} +pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_V2_A = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_V2_A; +STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_V3_W { + TransportCredentials: RPC_AUTH_IDENTITY_HANDLE, + Flags: c_ulong, + AuthenticationTarget: c_ulong, + NumberOfAuthnSchemes: c_ulong, + AuthnSchemes: *mut c_ulong, + ServerCertificateSubject: *mut c_ushort, + ProxyCredentials: *mut RPC_AUTH_IDENTITY_HANDLE, + NumberOfProxyAuthnSchemes: c_ulong, + ProxyAuthnSchemes: *mut c_ulong, +}} +pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_V3_W = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_V3_W; +STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_V3_A { + TransportCredentials: RPC_AUTH_IDENTITY_HANDLE, + Flags: c_ulong, + AuthenticationTarget: c_ulong, + NumberOfAuthnSchemes: c_ulong, + AuthnSchemes: *mut c_ulong, + ServerCertificateSubject: *mut c_uchar, + ProxyCredentials: *mut RPC_AUTH_IDENTITY_HANDLE, + NumberOfProxyAuthnSchemes: c_ulong, + ProxyAuthnSchemes: *mut c_ulong, +}} +pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_V3_A = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_V3_A; +STRUCT!{struct RPC_SECURITY_QOS_V2_W_union { + HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_W, +}} +STRUCT!{struct RPC_SECURITY_QOS_V2_W { + Version: c_ulong, + Capabilities: c_ulong, + IdentityTracking: c_ulong, + ImpersonationType: c_ulong, + AdditionalSecurityInfoType: c_ulong, + u: RPC_SECURITY_QOS_V2_W_union, +}} +pub type PRPC_SECURITY_QOS_V2_W = *mut RPC_SECURITY_QOS_V2_W; +STRUCT!{struct RPC_SECURITY_QOS_V2_A_union { + HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_A, +}} +STRUCT!{struct RPC_SECURITY_QOS_V2_A { + Version: c_ulong, + Capabilities: c_ulong, + IdentityTracking: c_ulong, + ImpersonationType: c_ulong, + AdditionalSecurityInfoType: c_ulong, + u: RPC_SECURITY_QOS_V2_A_union, +}} +pub type PRPC_SECURITY_QOS_V2_A = *mut RPC_SECURITY_QOS_V2_A; +STRUCT!{struct RPC_SECURITY_QOS_V3_W_union { + HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_W, +}} +STRUCT!{struct RPC_SECURITY_QOS_V3_W { + Version: c_ulong, + Capabilities: c_ulong, + IdentityTracking: c_ulong, + ImpersonationType: c_ulong, + AdditionalSecurityInfoType: c_ulong, + u: RPC_SECURITY_QOS_V3_W_union, + Sid: *mut c_void, +}} +pub type PRPC_SECURITY_QOS_V3_W = *mut RPC_SECURITY_QOS_V3_W; +STRUCT!{struct RPC_SECURITY_QOS_V3_A_union { + HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_A, +}} +STRUCT!{struct RPC_SECURITY_QOS_V3_A { + Version: c_ulong, + Capabilities: c_ulong, + IdentityTracking: c_ulong, + ImpersonationType: c_ulong, + AdditionalSecurityInfoType: c_ulong, + u: RPC_SECURITY_QOS_V3_A_union, + Sid: *mut c_void, +}} +pub type PRPC_SECURITY_QOS_V3_A = *mut RPC_SECURITY_QOS_V3_A; +STRUCT!{struct RPC_SECURITY_QOS_V4_W_union { + HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_W, +}} +STRUCT!{struct RPC_SECURITY_QOS_V4_W { + Version: c_ulong, + Capabilities: c_ulong, + IdentityTracking: c_ulong, + ImpersonationType: c_ulong, + AdditionalSecurityInfoType: c_ulong, + u: RPC_SECURITY_QOS_V4_W_union, + Sid: *mut c_void, + EffectiveOnly: c_uint, +}} +pub type PRPC_SECURITY_QOS_V4_W = *mut RPC_SECURITY_QOS_V4_W; +STRUCT!{struct RPC_SECURITY_QOS_V4_A_union { + HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_A, +}} +STRUCT!{struct RPC_SECURITY_QOS_V4_A { + Version: c_ulong, + Capabilities: c_ulong, + IdentityTracking: c_ulong, + ImpersonationType: c_ulong, + AdditionalSecurityInfoType: c_ulong, + u: RPC_SECURITY_QOS_V4_A_union, + Sid: *mut c_void, + EffectiveOnly: c_uint, +}} +pub type PRPC_SECURITY_QOS_V4_A = *mut RPC_SECURITY_QOS_V4_A; +STRUCT!{struct RPC_SECURITY_QOS_V5_W_union { + HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_W, +}} +STRUCT!{struct RPC_SECURITY_QOS_V5_W { + Version: c_ulong, + Capabilities: c_ulong, + IdentityTracking: c_ulong, + ImpersonationType: c_ulong, + AdditionalSecurityInfoType: c_ulong, + u: RPC_SECURITY_QOS_V5_W_union, + Sid: *mut c_void, + EffectiveOnly: c_uint, + ServerSecurityDescriptor: *mut c_void, +}} +pub type PRPC_SECURITY_QOS_V5_W = *mut RPC_SECURITY_QOS_V5_W; +STRUCT!{struct RPC_SECURITY_QOS_V5_A_union { + HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_A, +}} +STRUCT!{struct RPC_SECURITY_QOS_V5_A { + Version: c_ulong, + Capabilities: c_ulong, + IdentityTracking: c_ulong, + ImpersonationType: c_ulong, + AdditionalSecurityInfoType: c_ulong, + u: RPC_SECURITY_QOS_V5_A_union, + Sid: *mut c_void, + EffectiveOnly: c_uint, + ServerSecurityDescriptor: *mut c_void, +}} +pub type PRPC_SECURITY_QOS_V5_A = *mut RPC_SECURITY_QOS_V5_A; +pub const RPC_PROTSEQ_TCP: c_ulong = 0x1; +pub const RPC_PROTSEQ_NMP: c_ulong = 0x2; +pub const RPC_PROTSEQ_LRPC: c_ulong = 0x3; +pub const RPC_PROTSEQ_HTTP: c_ulong = 0x4; +pub const RPC_BHT_OBJECT_UUID_VALID: c_ulong = 0x1; +pub const RPC_BHO_NONCAUSAL: c_ulong = 0x1; +pub const RPC_BHO_DONTLINGER: c_ulong = 0x2; +pub const RPC_BHO_EXCLUSIVE_AND_GUARANTEED: c_ulong = 0x4; +STRUCT!{struct RPC_BINDING_HANDLE_TEMPLATE_V1_W_union { + Reserved: *mut c_ushort, +}} +STRUCT!{struct RPC_BINDING_HANDLE_TEMPLATE_V1_W { + Version: c_ulong, + Flags: c_ulong, + ProtocolSequence: c_ulong, + NetworkAddress: *mut c_ushort, + StringEndpoint: *mut c_ushort, + u1: RPC_BINDING_HANDLE_TEMPLATE_V1_W_union, + ObjectUuid: UUID, +}} +pub type PRPC_BINDING_HANDLE_TEMPLATE_V1_W = *mut RPC_BINDING_HANDLE_TEMPLATE_V1_W; +STRUCT!{struct RPC_BINDING_HANDLE_TEMPLATE_V1_A_union { + Reserved: *mut c_uchar, +}} +STRUCT!{struct RPC_BINDING_HANDLE_TEMPLATE_V1_A { + Version: c_ulong, + Flags: c_ulong, + ProtocolSequence: c_ulong, + NetworkAddress: *mut c_uchar, + StringEndpoint: *mut c_uchar, + u1: RPC_BINDING_HANDLE_TEMPLATE_V1_A_union, + ObjectUuid: UUID, +}} +pub type PRPC_BINDING_HANDLE_TEMPLATE_V1_A = *mut RPC_BINDING_HANDLE_TEMPLATE_V1_A; +STRUCT!{struct RPC_BINDING_HANDLE_SECURITY_V1_W { + Version: c_ulong, + ServerPrincName: *mut c_ushort, + AuthnLevel: c_ulong, + AuthnSvc: c_ulong, + AuthIdentity: *mut SEC_WINNT_AUTH_IDENTITY_W, + SecurityQos: *mut RPC_SECURITY_QOS, +}} +pub type PRPC_BINDING_HANDLE_SECURITY_V1_W = *mut RPC_BINDING_HANDLE_SECURITY_V1_W; +STRUCT!{struct RPC_BINDING_HANDLE_SECURITY_V1_A { + Version: c_ulong, + ServerPrincName: *mut c_uchar, + AuthnLevel: c_ulong, + AuthnSvc: c_ulong, + AuthIdentity: *mut SEC_WINNT_AUTH_IDENTITY_A, + SecurityQos: *mut RPC_SECURITY_QOS, +}} +pub type PRPC_BINDING_HANDLE_SECURITY_V1_A = *mut RPC_BINDING_HANDLE_SECURITY_V1_A; +STRUCT!{struct RPC_BINDING_HANDLE_OPTIONS_V1 { + Version: c_ulong, + Flags: c_ulong, + ComTimeout: c_ulong, + CallTimeout: c_ulong, +}} +pub type PRPC_BINDING_HANDLE_OPTIONS_V1 = *mut RPC_BINDING_HANDLE_OPTIONS_V1; +ENUM!{enum RPC_HTTP_REDIRECTOR_STAGE { + RPCHTTP_RS_REDIRECT = 1, + RPCHTTP_RS_ACCESS_1, + RPCHTTP_RS_SESSION, + RPCHTTP_RS_ACCESS_2, + RPCHTTP_RS_INTERFACE, +}} +FN!{stdcall RPC_NEW_HTTP_PROXY_CHANNEL( + RedirectorStage: RPC_HTTP_REDIRECTOR_STAGE, + ServerName: RPC_WSTR, + ServerPort: RPC_WSTR, + RemoteUser: RPC_WSTR, + AuthType: RPC_WSTR, + ResourceUuid: *mut c_void, + SessionId: *mut c_void, + Interface: *mut c_void, + Reserved: *mut c_void, + Flags: c_ulong, + NewServerName: *mut RPC_WSTR, + NewServerPort: *mut RPC_WSTR, +) -> RPC_STATUS} +FN!{stdcall RPC_HTTP_PROXY_FREE_STRING( + String: RPC_WSTR, +) -> ()} +pub const RPC_C_AUTHZ_NONE: DWORD = 0; +pub const RPC_C_AUTHZ_NAME: DWORD = 1; +pub const RPC_C_AUTHZ_DCE: DWORD = 2; +pub const RPC_C_AUTHZ_DEFAULT: DWORD = 0xffffffff; +FN!{stdcall RPC_AUTH_KEY_RETRIEVAL_FN( + Arg: *mut c_void, + ServerPrincName: RPC_WSTR, + KeyVer: c_ulong, + Key: *mut *mut c_void, + Status: *mut RPC_STATUS, +) -> ()} +STRUCT!{struct RPC_CLIENT_INFORMATION1 { + UserName: *mut c_uchar, + ComputerName: *mut c_uchar, + Privilege: c_ushort, + AuthFlags: c_ulong, +}} +pub type PRPC_CLIENT_INFORMATION1 = *mut RPC_CLIENT_INFORMATION1; +pub type RPC_EP_INQ_HANDLE = *mut I_RPC_HANDLE; +pub const RPC_C_EP_ALL_ELTS: c_ulong = 0; +pub const RPC_C_EP_MATCH_BY_IF: c_ulong = 1; +pub const RPC_C_EP_MATCH_BY_OBJ: c_ulong = 2; +pub const RPC_C_EP_MATCH_BY_BOTH: c_ulong = 3; +pub const RPC_C_VERS_ALL: c_ulong = 1; +pub const RPC_C_VERS_COMPATIBLE: c_ulong = 2; +pub const RPC_C_VERS_EXACT: c_ulong = 3; +pub const RPC_C_VERS_MAJOR_ONLY: c_ulong = 4; +pub const RPC_C_VERS_UPTO: c_ulong = 5; +FN!{stdcall RPC_MGMT_AUTHORIZATION_FN( + ClientBinding: RPC_BINDING_HANDLE, + RequestedMgmtOperation: c_ulong, + Status: *mut RPC_STATUS, +) -> c_int} +pub const RPC_C_MGMT_INQ_IF_IDS: c_ulong = 0; +pub const RPC_C_MGMT_INQ_PRINC_NAME: c_ulong = 1; +pub const RPC_C_MGMT_INQ_STATS: c_ulong = 2; +pub const RPC_C_MGMT_IS_SERVER_LISTEN: c_ulong = 3; +pub const RPC_C_MGMT_STOP_SERVER_LISTEN: c_ulong = 4; +pub const RPC_IF_AUTOLISTEN: c_uint = 0x0001; +pub const RPC_IF_OLE: c_uint = 0x0002; +pub const RPC_IF_ALLOW_UNKNOWN_AUTHORITY: c_uint = 0x0004; +pub const RPC_IF_ALLOW_SECURE_ONLY: c_uint = 0x0008; +pub const RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH: c_uint = 0x0010; +pub const RPC_IF_ALLOW_LOCAL_ONLY: c_uint = 0x0020; +pub const RPC_IF_SEC_NO_CACHE: c_uint = 0x0040; +pub const RPC_IF_SEC_CACHE_PER_PROC: c_uint = 0x0080; +pub const RPC_IF_ASYNC_CALLBACK: c_uint = 0x0100; +pub const RPC_FW_IF_FLAG_DCOM: c_uint = 0x0001; +pub type RPC_INTERFACE_GROUP = *mut c_void; +pub type PRPC_INTERFACE_GROUP = *mut *mut c_void; +STRUCT!{struct RPC_ENDPOINT_TEMPLATEW { + Version: c_ulong, + ProtSeq: RPC_WSTR, + Endpoint: RPC_WSTR, + SecurityDescriptor: *mut c_void, + Backlog: c_ulong, +}} +pub type PRPC_ENDPOINT_TEMPLATEW = *mut RPC_ENDPOINT_TEMPLATEW; +STRUCT!{struct RPC_ENDPOINT_TEMPLATEA { + Version: c_ulong, + ProtSeq: RPC_CSTR, + Endpoint: RPC_CSTR, + SecurityDescriptor: *mut c_void, + Backlog: c_ulong, +}} +pub type PRPC_ENDPOINT_TEMPLATEA = *mut RPC_ENDPOINT_TEMPLATEA; +STRUCT!{struct RPC_INTERFACE_TEMPLATEA { + Version: c_ulong, + IfSpec: RPC_IF_HANDLE, + MgrTypeUuid: *mut UUID, + MgrEpv: *mut RPC_MGR_EPV, + Flags: c_uint, + MaxCalls: c_uint, + MaxRpcSize: c_uint, + IfCallback: *mut RPC_IF_CALLBACK_FN, + UuidVector: *mut UUID_VECTOR, + Annotation: RPC_CSTR, + SecurityDescriptor: *mut c_void, +}} +pub type PRPC_INTERFACE_TEMPLATEA = *mut RPC_INTERFACE_TEMPLATEA; +STRUCT!{struct RPC_INTERFACE_TEMPLATEW { + Version: c_ulong, + IfSpec: RPC_IF_HANDLE, + MgrTypeUuid: *mut UUID, + MgrEpv: *mut RPC_MGR_EPV, + Flags: c_uint, + MaxCalls: c_uint, + MaxRpcSize: c_uint, + IfCallback: *mut RPC_IF_CALLBACK_FN, + UuidVector: *mut UUID_VECTOR, + Annotation: RPC_WSTR, + SecurityDescriptor: *mut c_void, +}} +pub type PRPC_INTERFACE_TEMPLATEW = *mut RPC_INTERFACE_TEMPLATEW; +FN!{stdcall RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN( + IfGroup: RPC_INTERFACE_GROUP, + IdleCallbackContext: *mut c_void, + IsGroupIdle: c_ulong, +) -> ()} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/rpcndr.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/rpcndr.rs new file mode 100644 index 0000000..b65a3da --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/rpcndr.rs @@ -0,0 +1,25 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{__int64, __uint64, c_char, c_uchar, c_ulong}; +pub const NDR_CHAR_REP_MASK: c_ulong = 0x0000000F; +pub const NDR_INT_REP_MASK: c_ulong = 0x000000F0; +pub const NDR_FLOAT_REP_MASK: c_ulong = 0x0000FF00; +pub const NDR_LITTLE_ENDIAN: c_ulong = 0x00000010; +pub const NDR_BIG_ENDIAN: c_ulong = 0x00000000; +pub const NDR_IEEE_FLOAT: c_ulong = 0x00000000; +pub const NDR_VAX_FLOAT: c_ulong = 0x00000100; +pub const NDR_IBM_FLOAT: c_ulong = 0x00000300; +pub const NDR_ASCII_CHAR: c_ulong = 0x00000000; +pub const NDR_EBCDIC_CHAR: c_ulong = 0x00000001; +pub const NDR_LOCAL_DATA_REPRESENTATION: c_ulong = 0x00000010; +pub const NDR_LOCAL_ENDIAN: c_ulong = NDR_LITTLE_ENDIAN; +pub type small = c_char; +pub type byte = c_uchar; +pub type cs_byte = byte; +pub type boolean = c_uchar; +pub type hyper = __int64; +pub type MIDL_uhyper = __uint64; +// TODO Finish the rest diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/sddl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/sddl.rs new file mode 100644 index 0000000..cf64387 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/sddl.rs @@ -0,0 +1,217 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::SIZE_T; +use shared::minwindef::{BOOL, DWORD, PULONG, UCHAR}; +use um::winnt::{LPCSTR, LPCWSTR, LPSTR, LPWSTR, PSECURITY_DESCRIPTOR, PSID, SECURITY_INFORMATION}; +pub const SDDL_REVISION_1: UCHAR = 1; +pub const SDDL_REVISION: UCHAR = SDDL_REVISION_1; +pub const SDDL_OWNER: &'static str = "O"; +pub const SDDL_GROUP: &'static str = "G"; +pub const SDDL_DACL: &'static str = "D"; +pub const SDDL_SACL: &'static str = "S"; +pub const SDDL_PROTECTED: &'static str = "P"; +pub const SDDL_AUTO_INHERIT_REQ: &'static str = "AR"; +pub const SDDL_AUTO_INHERITED: &'static str = "AI"; +pub const SDDL_NULL_ACL: &'static str = "NO_ACCESS_CONTROL"; +pub const SDDL_ACCESS_ALLOWED: &'static str = "A"; +pub const SDDL_ACCESS_DENIED: &'static str = "D"; +pub const SDDL_OBJECT_ACCESS_ALLOWED: &'static str = "OA"; +pub const SDDL_OBJECT_ACCESS_DENIED: &'static str = "OD"; +pub const SDDL_AUDIT: &'static str = "AU"; +pub const SDDL_ALARM: &'static str = "AL"; +pub const SDDL_OBJECT_AUDIT: &'static str = "OU"; +pub const SDDL_OBJECT_ALARM: &'static str = "OL"; +pub const SDDL_MANDATORY_LABEL: &'static str = "ML"; +pub const SDDL_PROCESS_TRUST_LABEL: &'static str = "TL"; +pub const SDDL_CALLBACK_ACCESS_ALLOWED: &'static str = "XA"; +pub const SDDL_CALLBACK_ACCESS_DENIED: &'static str = "XD"; +pub const SDDL_RESOURCE_ATTRIBUTE: &'static str = "RA"; +pub const SDDL_SCOPED_POLICY_ID: &'static str = "SP"; +pub const SDDL_CALLBACK_AUDIT: &'static str = "XU"; +pub const SDDL_CALLBACK_OBJECT_ACCESS_ALLOWED: &'static str = "ZA"; +pub const SDDL_ACCESS_FILTER: &'static str = "FL"; +pub const SDDL_INT: &'static str = "TI"; +pub const SDDL_UINT: &'static str = "TU"; +pub const SDDL_WSTRING: &'static str = "TS"; +pub const SDDL_SID: &'static str = "TD"; +pub const SDDL_BLOB: &'static str = "TX"; +pub const SDDL_BOOLEAN: &'static str = "TB"; +pub const SDDL_CONTAINER_INHERIT: &'static str = "CI"; +pub const SDDL_OBJECT_INHERIT: &'static str = "OI"; +pub const SDDL_NO_PROPAGATE: &'static str = "NP"; +pub const SDDL_INHERIT_ONLY: &'static str = "IO"; +pub const SDDL_INHERITED: &'static str = "ID"; +pub const SDDL_TRUST_PROTECTED_FILTER: &'static str = "TP"; +pub const SDDL_AUDIT_SUCCESS: &'static str = "SA"; +pub const SDDL_AUDIT_FAILURE: &'static str = "FA"; +pub const SDDL_READ_PROPERTY: &'static str = "RP"; +pub const SDDL_WRITE_PROPERTY: &'static str = "WP"; +pub const SDDL_CREATE_CHILD: &'static str = "CC"; +pub const SDDL_DELETE_CHILD: &'static str = "DC"; +pub const SDDL_LIST_CHILDREN: &'static str = "LC"; +pub const SDDL_SELF_WRITE: &'static str = "SW"; +pub const SDDL_LIST_OBJECT: &'static str = "LO"; +pub const SDDL_DELETE_TREE: &'static str = "DT"; +pub const SDDL_CONTROL_ACCESS: &'static str = "CR"; +pub const SDDL_READ_CONTROL: &'static str = "RC"; +pub const SDDL_WRITE_DAC: &'static str = "WD"; +pub const SDDL_WRITE_OWNER: &'static str = "WO"; +pub const SDDL_STANDARD_DELETE: &'static str = "SD"; +pub const SDDL_GENERIC_ALL: &'static str = "GA"; +pub const SDDL_GENERIC_READ: &'static str = "GR"; +pub const SDDL_GENERIC_WRITE: &'static str = "GW"; +pub const SDDL_GENERIC_EXECUTE: &'static str = "GX"; +pub const SDDL_FILE_ALL: &'static str = "FA"; +pub const SDDL_FILE_READ: &'static str = "FR"; +pub const SDDL_FILE_WRITE: &'static str = "FW"; +pub const SDDL_FILE_EXECUTE: &'static str = "FX"; +pub const SDDL_KEY_ALL: &'static str = "KA"; +pub const SDDL_KEY_READ: &'static str = "KR"; +pub const SDDL_KEY_WRITE: &'static str = "KW"; +pub const SDDL_KEY_EXECUTE: &'static str = "KX"; +pub const SDDL_NO_WRITE_UP: &'static str = "NW"; +pub const SDDL_NO_READ_UP: &'static str = "NR"; +pub const SDDL_NO_EXECUTE_UP: &'static str = "NX"; +pub const SDDL_ALIAS_SIZE: SIZE_T = 2; +pub const SDDL_DOMAIN_ADMINISTRATORS: &'static str = "DA"; +pub const SDDL_DOMAIN_GUESTS: &'static str = "DG"; +pub const SDDL_DOMAIN_USERS: &'static str = "DU"; +pub const SDDL_ENTERPRISE_DOMAIN_CONTROLLERS: &'static str = "ED"; +pub const SDDL_DOMAIN_DOMAIN_CONTROLLERS: &'static str = "DD"; +pub const SDDL_DOMAIN_COMPUTERS: &'static str = "DC"; +pub const SDDL_BUILTIN_ADMINISTRATORS: &'static str = "BA"; +pub const SDDL_BUILTIN_GUESTS: &'static str = "BG"; +pub const SDDL_BUILTIN_USERS: &'static str = "BU"; +pub const SDDL_LOCAL_ADMIN: &'static str = "LA"; +pub const SDDL_LOCAL_GUEST: &'static str = "LG"; +pub const SDDL_ACCOUNT_OPERATORS: &'static str = "AO"; +pub const SDDL_BACKUP_OPERATORS: &'static str = "BO"; +pub const SDDL_PRINTER_OPERATORS: &'static str = "PO"; +pub const SDDL_SERVER_OPERATORS: &'static str = "SO"; +pub const SDDL_AUTHENTICATED_USERS: &'static str = "AU"; +pub const SDDL_PERSONAL_SELF: &'static str = "PS"; +pub const SDDL_CREATOR_OWNER: &'static str = "CO"; +pub const SDDL_CREATOR_GROUP: &'static str = "CG"; +pub const SDDL_LOCAL_SYSTEM: &'static str = "SY"; +pub const SDDL_POWER_USERS: &'static str = "PU"; +pub const SDDL_EVERYONE: &'static str = "WD"; +pub const SDDL_REPLICATOR: &'static str = "RE"; +pub const SDDL_INTERACTIVE: &'static str = "IU"; +pub const SDDL_NETWORK: &'static str = "NU"; +pub const SDDL_SERVICE: &'static str = "SU"; +pub const SDDL_RESTRICTED_CODE: &'static str = "RC"; +pub const SDDL_WRITE_RESTRICTED_CODE: &'static str = "WR"; +pub const SDDL_ANONYMOUS: &'static str = "AN"; +pub const SDDL_SCHEMA_ADMINISTRATORS: &'static str = "SA"; +pub const SDDL_CERT_SERV_ADMINISTRATORS: &'static str = "CA"; +pub const SDDL_RAS_SERVERS: &'static str = "RS"; +pub const SDDL_ENTERPRISE_ADMINS: &'static str = "EA"; +pub const SDDL_GROUP_POLICY_ADMINS: &'static str = "PA"; +pub const SDDL_ALIAS_PREW2KCOMPACC: &'static str = "RU"; +pub const SDDL_LOCAL_SERVICE: &'static str = "LS"; +pub const SDDL_NETWORK_SERVICE: &'static str = "NS"; +pub const SDDL_REMOTE_DESKTOP: &'static str = "RD"; +pub const SDDL_NETWORK_CONFIGURATION_OPS: &'static str = "NO"; +pub const SDDL_PERFMON_USERS: &'static str = "MU"; +pub const SDDL_PERFLOG_USERS: &'static str = "LU"; +pub const SDDL_IIS_USERS: &'static str = "IS"; +pub const SDDL_CRYPTO_OPERATORS: &'static str = "CY"; +pub const SDDL_OWNER_RIGHTS: &'static str = "OW"; +pub const SDDL_EVENT_LOG_READERS: &'static str = "ER"; +pub const SDDL_ENTERPRISE_RO_DCs: &'static str = "RO"; +pub const SDDL_CERTSVC_DCOM_ACCESS: &'static str = "CD"; +pub const SDDL_ALL_APP_PACKAGES: &'static str = "AC"; +pub const SDDL_RDS_REMOTE_ACCESS_SERVERS: &'static str = "RA"; +pub const SDDL_RDS_ENDPOINT_SERVERS: &'static str = "ES"; +pub const SDDL_RDS_MANAGEMENT_SERVERS: &'static str = "MS"; +pub const SDDL_USER_MODE_DRIVERS: &'static str = "UD"; +pub const SDDL_HYPER_V_ADMINS: &'static str = "HA"; +pub const SDDL_CLONEABLE_CONTROLLERS: &'static str = "CN"; +pub const SDDL_ACCESS_CONTROL_ASSISTANCE_OPS: &'static str = "AA"; +pub const SDDL_REMOTE_MANAGEMENT_USERS: &'static str = "RM"; +pub const SDDL_AUTHORITY_ASSERTED: &'static str = "AS"; +pub const SDDL_SERVICE_ASSERTED: &'static str = "SS"; +pub const SDDL_PROTECTED_USERS: &'static str = "AP"; +pub const SDDL_KEY_ADMINS: &'static str = "KA"; +pub const SDDL_ENTERPRISE_KEY_ADMINS: &'static str = "EK"; +pub const SDDL_ML_LOW: &'static str = "LW"; +pub const SDDL_ML_MEDIUM: &'static str = "ME"; +pub const SDDL_ML_MEDIUM_PLUS: &'static str = "MP"; +pub const SDDL_ML_HIGH: &'static str = "HI"; +pub const SDDL_ML_SYSTEM: &'static str = "SI"; +pub const SDDL_SEPERATORC: char = ';'; +pub const SDDL_DELIMINATORC: char = ':'; +pub const SDDL_ACE_BEGINC: char = '('; +pub const SDDL_ACE_ENDC: char = ')'; +pub const SDDL_SPACEC: char = ' '; +pub const SDDL_ACE_COND_BEGINC: char = '('; +pub const SDDL_ACE_COND_ENDC: char = ')'; +pub const SDDL_ACE_COND_STRING_BEGINC: char = '"'; +pub const SDDL_ACE_COND_STRING_ENDC: char = '"'; +pub const SDDL_ACE_COND_COMPOSITEVALUE_BEGINC: char = '{'; +pub const SDDL_ACE_COND_COMPOSITEVALUE_ENDC: char = '}'; +pub const SDDL_ACE_COND_COMPOSITEVALUE_SEPERATORC: char = ','; +pub const SDDL_ACE_COND_BLOB_PREFIXC: char = '#'; +pub const SDDL_ACE_COND_SID_BEGINC: char = '('; +pub const SDDL_ACE_COND_SID_ENDC: char = ')'; +pub const SDDL_SEPERATOR: &'static str = ";"; +pub const SDDL_DELIMINATOR: &'static str = ":"; +pub const SDDL_ACE_BEGIN: &'static str = "("; +pub const SDDL_ACE_END: &'static str = ")"; +pub const SDDL_ACE_COND_BEGIN: &'static str = "("; +pub const SDDL_ACE_COND_END: &'static str = ")"; +pub const SDDL_SPACE: &'static str = " "; +pub const SDDL_ACE_COND_BLOB_PREFIX: &'static str = "#"; +pub const SDDL_ACE_COND_SID_PREFIX: &'static str = "SID"; +pub const SDDL_ACE_COND_ATTRIBUTE_PREFIX: &'static str = "@"; +pub const SDDL_ACE_COND_USER_ATTRIBUTE_PREFIX: &'static str = "@USER."; +pub const SDDL_ACE_COND_RESOURCE_ATTRIBUTE_PREFIX: &'static str = "@RESOURCE."; +pub const SDDL_ACE_COND_DEVICE_ATTRIBUTE_PREFIX: &'static str = "@DEVICE."; +pub const SDDL_ACE_COND_TOKEN_ATTRIBUTE_PREFIX: &'static str = "@TOKEN."; +extern "system" { + pub fn ConvertSidToStringSidA( + Sid: PSID, + StringSid: *mut LPSTR, + ) -> BOOL; + pub fn ConvertSidToStringSidW( + Sid: PSID, + StringSid: *mut LPWSTR, + ) -> BOOL; + pub fn ConvertStringSidToSidA( + StringSid: LPCSTR, + Sid: *mut PSID, + ) -> BOOL; + pub fn ConvertStringSidToSidW( + StringSid: LPCWSTR, + Sid: *mut PSID, + ) -> BOOL; + pub fn ConvertStringSecurityDescriptorToSecurityDescriptorA( + StringSecurityDescriptor: LPCSTR, + StringSDRevision: DWORD, + SecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + SecurityDescriptorSize: PULONG, + ) -> BOOL; + pub fn ConvertStringSecurityDescriptorToSecurityDescriptorW( + StringSecurityDescriptor: LPCWSTR, + StringSDRevision: DWORD, + SecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + SecurityDescriptorSize: PULONG, + ) -> BOOL; + pub fn ConvertSecurityDescriptorToStringSecurityDescriptorA( + SecurityDescriptor: PSECURITY_DESCRIPTOR, + RequestedStringSDRevision: DWORD, + SecurityInformation: SECURITY_INFORMATION, + StringSecurityDescriptor: *mut LPSTR, + StringSecurityDescriptorLen: PULONG, + ) -> BOOL; + pub fn ConvertSecurityDescriptorToStringSecurityDescriptorW( + SecurityDescriptor: PSECURITY_DESCRIPTOR, + RequestedStringSDRevision: DWORD, + SecurityInformation: SECURITY_INFORMATION, + StringSecurityDescriptor: *mut LPWSTR, + StringSecurityDescriptorLen: PULONG, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/sspi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/sspi.rs new file mode 100644 index 0000000..3b7c2d6 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/sspi.rs @@ -0,0 +1,1074 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Security Support Provider Interface Prototypes and structure definitions +use ctypes::{c_char, c_int, c_uchar, c_ulong, c_ushort, c_void}; +use shared::basetsd::ULONG_PTR; +use shared::guiddef::GUID; +use shared::minwindef::{PUCHAR, ULONG, USHORT}; +use um::subauth::PUNICODE_STRING; +use um::wincred::{PCREDUI_INFOA, PCREDUI_INFOW}; +use um::winnt::{ + ANYSIZE_ARRAY, BOOLEAN, CHAR, HANDLE, LARGE_INTEGER, LONG, LPSTR, LPWSTR, LUID, PCSTR, PCWSTR, + PVOID, WCHAR +}; +pub type SEC_WCHAR = WCHAR; +pub type SEC_CHAR = CHAR; +pub type SECURITY_STATUS = LONG; +STRUCT!{struct SecHandle { + dwLower: ULONG_PTR, + dwUpper: ULONG_PTR, +}} +pub type PSecHandle = *mut SecHandle; +pub const SEC_DELETED_HANDLE: ULONG_PTR = 2; +pub type CredHandle = SecHandle; +pub type PCredHandle = PSecHandle; +pub type CtxtHandle = SecHandle; +pub type PCtxtHandle = PSecHandle; +pub type SECURITY_INTEGER = LARGE_INTEGER; +pub type PSECURITY_INTEGER = *mut LARGE_INTEGER; +pub type TimeStamp = SECURITY_INTEGER; +pub type PTimeStamp = *mut SECURITY_INTEGER; +STRUCT!{struct SECURITY_STRING { + Length: c_ushort, + MaximumLength: c_ushort, + Buffer: *mut c_ushort, +}} +pub type PSECURITY_STRING = *mut SECURITY_STRING; +STRUCT!{struct SecPkgInfoW { + fCapabilities: c_ulong, + wVersion: c_ushort, + wRPCID: c_ushort, + cbMaxToken: c_ulong, + Name: *mut SEC_WCHAR, + Comment: *mut SEC_WCHAR, +}} +pub type PSecPkgInfoW = *mut SecPkgInfoW; +STRUCT!{struct SecPkgInfoA { + fCapabilities: c_ulong, + wVersion: c_ushort, + wRPCID: c_ushort, + cbMaxToken: c_ulong, + Name: *mut SEC_CHAR, + Comment: *mut SEC_CHAR, +}} +pub type PSecPkgInfoA = *mut SecPkgInfoA; +pub const SECPKG_FLAG_INTEGRITY: c_ulong = 0x00000001; +pub const SECPKG_FLAG_PRIVACY: c_ulong = 0x00000002; +pub const SECPKG_FLAG_TOKEN_ONLY: c_ulong = 0x00000004; +pub const SECPKG_FLAG_DATAGRAM: c_ulong = 0x00000008; +pub const SECPKG_FLAG_CONNECTION: c_ulong = 0x00000010; +pub const SECPKG_FLAG_MULTI_REQUIRED: c_ulong = 0x00000020; +pub const SECPKG_FLAG_CLIENT_ONLY: c_ulong = 0x00000040; +pub const SECPKG_FLAG_EXTENDED_ERROR: c_ulong = 0x00000080; +pub const SECPKG_FLAG_IMPERSONATION: c_ulong = 0x00000100; +pub const SECPKG_FLAG_ACCEPT_WIN32_NAME: c_ulong = 0x00000200; +pub const SECPKG_FLAG_STREAM: c_ulong = 0x00000400; +pub const SECPKG_FLAG_NEGOTIABLE: c_ulong = 0x00000800; +pub const SECPKG_FLAG_GSS_COMPATIBLE: c_ulong = 0x00001000; +pub const SECPKG_FLAG_LOGON: c_ulong = 0x00002000; +pub const SECPKG_FLAG_ASCII_BUFFERS: c_ulong = 0x00004000; +pub const SECPKG_FLAG_FRAGMENT: c_ulong = 0x00008000; +pub const SECPKG_FLAG_MUTUAL_AUTH: c_ulong = 0x00010000; +pub const SECPKG_FLAG_DELEGATION: c_ulong = 0x00020000; +pub const SECPKG_FLAG_READONLY_WITH_CHECKSUM: c_ulong = 0x00040000; +pub const SECPKG_FLAG_RESTRICTED_TOKENS: c_ulong = 0x00080000; +pub const SECPKG_FLAG_NEGO_EXTENDER: c_ulong = 0x00100000; +pub const SECPKG_FLAG_NEGOTIABLE2: c_ulong = 0x00200000; +pub const SECPKG_FLAG_APPCONTAINER_PASSTHROUGH: c_ulong = 0x00400000; +pub const SECPKG_FLAG_APPCONTAINER_CHECKS: c_ulong = 0x00800000; +pub const SECPKG_ID_NONE: c_ulong = 0xFFFF; +pub const SECPKG_CALLFLAGS_APPCONTAINER: c_ulong = 0x00000001; +pub const SECPKG_CALLFLAGS_APPCONTAINER_AUTHCAPABLE: c_ulong = 0x00000002; +pub const SECPKG_CALLFLAGS_FORCE_SUPPLIED: c_ulong = 0x00000004; +STRUCT!{struct SecBuffer { + cbBuffer: c_ulong, + BufferType: c_ulong, + pvBuffer: *mut c_void, +}} +pub type PSecBuffer = *mut SecBuffer; +STRUCT!{struct SecBufferDesc { + ulVersion: c_ulong, + cBuffers: c_ulong, + pBuffers: PSecBuffer, +}} +pub type PSecBufferDesc = *mut SecBufferDesc; +pub const SECBUFFER_VERSION: c_ulong = 0; +pub const SECBUFFER_EMPTY: c_ulong = 0; +pub const SECBUFFER_DATA: c_ulong = 1; +pub const SECBUFFER_TOKEN: c_ulong = 2; +pub const SECBUFFER_PKG_PARAMS: c_ulong = 3; +pub const SECBUFFER_MISSING: c_ulong = 4; +pub const SECBUFFER_EXTRA: c_ulong = 5; +pub const SECBUFFER_STREAM_TRAILER: c_ulong = 6; +pub const SECBUFFER_STREAM_HEADER: c_ulong = 7; +pub const SECBUFFER_NEGOTIATION_INFO: c_ulong = 8; +pub const SECBUFFER_PADDING: c_ulong = 9; +pub const SECBUFFER_STREAM: c_ulong = 10; +pub const SECBUFFER_MECHLIST: c_ulong = 11; +pub const SECBUFFER_MECHLIST_SIGNATURE: c_ulong = 12; +pub const SECBUFFER_TARGET: c_ulong = 13; +pub const SECBUFFER_CHANNEL_BINDINGS: c_ulong = 14; +pub const SECBUFFER_CHANGE_PASS_RESPONSE: c_ulong = 15; +pub const SECBUFFER_TARGET_HOST: c_ulong = 16; +pub const SECBUFFER_ALERT: c_ulong = 17; +pub const SECBUFFER_APPLICATION_PROTOCOLS: c_ulong = 18; +pub const SECBUFFER_ATTRMASK: c_ulong = 0xF0000000; +pub const SECBUFFER_READONLY: c_ulong = 0x80000000; +pub const SECBUFFER_READONLY_WITH_CHECKSUM: c_ulong = 0x10000000; +pub const SECBUFFER_RESERVED: c_ulong = 0x60000000; +STRUCT!{struct SEC_NEGOTIATION_INFO { + Size: c_ulong, + NameLength: c_ulong, + Name: *mut SEC_WCHAR, + Reserved: *mut c_void, +}} +pub type PSEC_NEGOTIATION_INFO = *mut SEC_NEGOTIATION_INFO; +STRUCT!{struct SEC_CHANNEL_BINDINGS { + dwInitiatorAddrType: c_ulong, + cbInitiatorLength: c_ulong, + dwInitiatorOffset: c_ulong, + dwAcceptorAddrType: c_ulong, + cbAcceptorLength: c_ulong, + dwAcceptorOffset: c_ulong, + cbApplicationDataLength: c_ulong, + dwApplicationDataOffset: c_ulong, +}} +pub type PSEC_CHANNEL_BINDINGS = *mut SEC_CHANNEL_BINDINGS; +ENUM!{enum SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT { + SecApplicationProtocolNegotiationExt_None, + SecApplicationProtocolNegotiationExt_NPN, + SecApplicationProtocolNegotiationExt_ALPN, +}} +pub type PSEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT = *mut SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT; +STRUCT!{struct SEC_APPLICATION_PROTOCOL_LIST { + ProtoNegoExt: SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT, + ProtocolListSize: c_ushort, + ProtocolList: [c_uchar; 0], +}} +pub type PSEC_APPLICATION_PROTOCOL_LIST = *mut SEC_APPLICATION_PROTOCOL_LIST; +STRUCT!{struct SEC_APPLICATION_PROTOCOLS { + ProtocolListsSize: c_ulong, + ProtocolLists: [SEC_APPLICATION_PROTOCOL_LIST; ANYSIZE_ARRAY], +}} +pub type PSEC_APPLICATION_PROTOCOLS = *mut SEC_APPLICATION_PROTOCOLS; +pub const SECURITY_NATIVE_DREP: c_ulong = 0x00000010; +pub const SECURITY_NETWORK_DREP: c_ulong = 0x00000000; +pub const SECPKG_CRED_INBOUND: c_ulong = 0x00000001; +pub const SECPKG_CRED_OUTBOUND: c_ulong = 0x00000002; +pub const SECPKG_CRED_BOTH: c_ulong = 0x00000003; +pub const SECPKG_CRED_DEFAULT: c_ulong = 0x00000004; +pub const SECPKG_CRED_RESERVED: c_ulong = 0xF0000000; +pub const SECPKG_CRED_AUTOLOGON_RESTRICTED: c_ulong = 0x00000010; +pub const SECPKG_CRED_PROCESS_POLICY_ONLY: c_ulong = 0x00000020; +pub const ISC_REQ_DELEGATE: c_ulong = 0x00000001; +pub const ISC_REQ_MUTUAL_AUTH: c_ulong = 0x00000002; +pub const ISC_REQ_REPLAY_DETECT: c_ulong = 0x00000004; +pub const ISC_REQ_SEQUENCE_DETECT: c_ulong = 0x00000008; +pub const ISC_REQ_CONFIDENTIALITY: c_ulong = 0x00000010; +pub const ISC_REQ_USE_SESSION_KEY: c_ulong = 0x00000020; +pub const ISC_REQ_PROMPT_FOR_CREDS: c_ulong = 0x00000040; +pub const ISC_REQ_USE_SUPPLIED_CREDS: c_ulong = 0x00000080; +pub const ISC_REQ_ALLOCATE_MEMORY: c_ulong = 0x00000100; +pub const ISC_REQ_USE_DCE_STYLE: c_ulong = 0x00000200; +pub const ISC_REQ_DATAGRAM: c_ulong = 0x00000400; +pub const ISC_REQ_CONNECTION: c_ulong = 0x00000800; +pub const ISC_REQ_CALL_LEVEL: c_ulong = 0x00001000; +pub const ISC_REQ_FRAGMENT_SUPPLIED: c_ulong = 0x00002000; +pub const ISC_REQ_EXTENDED_ERROR: c_ulong = 0x00004000; +pub const ISC_REQ_STREAM: c_ulong = 0x00008000; +pub const ISC_REQ_INTEGRITY: c_ulong = 0x00010000; +pub const ISC_REQ_IDENTIFY: c_ulong = 0x00020000; +pub const ISC_REQ_NULL_SESSION: c_ulong = 0x00040000; +pub const ISC_REQ_MANUAL_CRED_VALIDATION: c_ulong = 0x00080000; +pub const ISC_REQ_RESERVED1: c_ulong = 0x00100000; +pub const ISC_REQ_FRAGMENT_TO_FIT: c_ulong = 0x00200000; +pub const ISC_REQ_FORWARD_CREDENTIALS: c_ulong = 0x00400000; +pub const ISC_REQ_NO_INTEGRITY: c_ulong = 0x00800000; +pub const ISC_REQ_USE_HTTP_STYLE: c_ulong = 0x01000000; +pub const ISC_REQ_UNVERIFIED_TARGET_NAME: c_ulong = 0x20000000; +pub const ISC_REQ_CONFIDENTIALITY_ONLY: c_ulong = 0x40000000; +pub const ISC_RET_DELEGATE: c_ulong = 0x00000001; +pub const ISC_RET_MUTUAL_AUTH: c_ulong = 0x00000002; +pub const ISC_RET_REPLAY_DETECT: c_ulong = 0x00000004; +pub const ISC_RET_SEQUENCE_DETECT: c_ulong = 0x00000008; +pub const ISC_RET_CONFIDENTIALITY: c_ulong = 0x00000010; +pub const ISC_RET_USE_SESSION_KEY: c_ulong = 0x00000020; +pub const ISC_RET_USED_COLLECTED_CREDS: c_ulong = 0x00000040; +pub const ISC_RET_USED_SUPPLIED_CREDS: c_ulong = 0x00000080; +pub const ISC_RET_ALLOCATED_MEMORY: c_ulong = 0x00000100; +pub const ISC_RET_USED_DCE_STYLE: c_ulong = 0x00000200; +pub const ISC_RET_DATAGRAM: c_ulong = 0x00000400; +pub const ISC_RET_CONNECTION: c_ulong = 0x00000800; +pub const ISC_RET_INTERMEDIATE_RETURN: c_ulong = 0x00001000; +pub const ISC_RET_CALL_LEVEL: c_ulong = 0x00002000; +pub const ISC_RET_EXTENDED_ERROR: c_ulong = 0x00004000; +pub const ISC_RET_STREAM: c_ulong = 0x00008000; +pub const ISC_RET_INTEGRITY: c_ulong = 0x00010000; +pub const ISC_RET_IDENTIFY: c_ulong = 0x00020000; +pub const ISC_RET_NULL_SESSION: c_ulong = 0x00040000; +pub const ISC_RET_MANUAL_CRED_VALIDATION: c_ulong = 0x00080000; +pub const ISC_RET_RESERVED1: c_ulong = 0x00100000; +pub const ISC_RET_FRAGMENT_ONLY: c_ulong = 0x00200000; +pub const ISC_RET_FORWARD_CREDENTIALS: c_ulong = 0x00400000; +pub const ISC_RET_USED_HTTP_STYLE: c_ulong = 0x01000000; +pub const ISC_RET_NO_ADDITIONAL_TOKEN: c_ulong = 0x02000000; +pub const ISC_RET_REAUTHENTICATION: c_ulong = 0x08000000; +pub const ISC_RET_CONFIDENTIALITY_ONLY: c_ulong = 0x40000000; +pub const ASC_REQ_DELEGATE: c_ulong = 0x00000001; +pub const ASC_REQ_MUTUAL_AUTH: c_ulong = 0x00000002; +pub const ASC_REQ_REPLAY_DETECT: c_ulong = 0x00000004; +pub const ASC_REQ_SEQUENCE_DETECT: c_ulong = 0x00000008; +pub const ASC_REQ_CONFIDENTIALITY: c_ulong = 0x00000010; +pub const ASC_REQ_USE_SESSION_KEY: c_ulong = 0x00000020; +pub const ASC_REQ_SESSION_TICKET: c_ulong = 0x00000040; +pub const ASC_REQ_ALLOCATE_MEMORY: c_ulong = 0x00000100; +pub const ASC_REQ_USE_DCE_STYLE: c_ulong = 0x00000200; +pub const ASC_REQ_DATAGRAM: c_ulong = 0x00000400; +pub const ASC_REQ_CONNECTION: c_ulong = 0x00000800; +pub const ASC_REQ_CALL_LEVEL: c_ulong = 0x00001000; +pub const ASC_REQ_EXTENDED_ERROR: c_ulong = 0x00008000; +pub const ASC_REQ_STREAM: c_ulong = 0x00010000; +pub const ASC_REQ_INTEGRITY: c_ulong = 0x00020000; +pub const ASC_REQ_LICENSING: c_ulong = 0x00040000; +pub const ASC_REQ_IDENTIFY: c_ulong = 0x00080000; +pub const ASC_REQ_ALLOW_NULL_SESSION: c_ulong = 0x00100000; +pub const ASC_REQ_ALLOW_NON_USER_LOGONS: c_ulong = 0x00200000; +pub const ASC_REQ_ALLOW_CONTEXT_REPLAY: c_ulong = 0x00400000; +pub const ASC_REQ_FRAGMENT_TO_FIT: c_ulong = 0x00800000; +pub const ASC_REQ_FRAGMENT_SUPPLIED: c_ulong = 0x00002000; +pub const ASC_REQ_NO_TOKEN: c_ulong = 0x01000000; +pub const ASC_REQ_PROXY_BINDINGS: c_ulong = 0x04000000; +pub const ASC_REQ_ALLOW_MISSING_BINDINGS: c_ulong = 0x10000000; +pub const ASC_RET_DELEGATE: c_ulong = 0x00000001; +pub const ASC_RET_MUTUAL_AUTH: c_ulong = 0x00000002; +pub const ASC_RET_REPLAY_DETECT: c_ulong = 0x00000004; +pub const ASC_RET_SEQUENCE_DETECT: c_ulong = 0x00000008; +pub const ASC_RET_CONFIDENTIALITY: c_ulong = 0x00000010; +pub const ASC_RET_USE_SESSION_KEY: c_ulong = 0x00000020; +pub const ASC_RET_SESSION_TICKET: c_ulong = 0x00000040; +pub const ASC_RET_ALLOCATED_MEMORY: c_ulong = 0x00000100; +pub const ASC_RET_USED_DCE_STYLE: c_ulong = 0x00000200; +pub const ASC_RET_DATAGRAM: c_ulong = 0x00000400; +pub const ASC_RET_CONNECTION: c_ulong = 0x00000800; +pub const ASC_RET_CALL_LEVEL: c_ulong = 0x00002000; +pub const ASC_RET_THIRD_LEG_FAILED: c_ulong = 0x00004000; +pub const ASC_RET_EXTENDED_ERROR: c_ulong = 0x00008000; +pub const ASC_RET_STREAM: c_ulong = 0x00010000; +pub const ASC_RET_INTEGRITY: c_ulong = 0x00020000; +pub const ASC_RET_LICENSING: c_ulong = 0x00040000; +pub const ASC_RET_IDENTIFY: c_ulong = 0x00080000; +pub const ASC_RET_NULL_SESSION: c_ulong = 0x00100000; +pub const ASC_RET_ALLOW_NON_USER_LOGONS: c_ulong = 0x00200000; +pub const ASC_RET_ALLOW_CONTEXT_REPLAY: c_ulong = 0x00400000; +pub const ASC_RET_FRAGMENT_ONLY: c_ulong = 0x00800000; +pub const ASC_RET_NO_TOKEN: c_ulong = 0x01000000; +pub const ASC_RET_NO_ADDITIONAL_TOKEN: c_ulong = 0x02000000; +pub const SECPKG_CRED_ATTR_NAMES: c_ulong = 1; +pub const SECPKG_CRED_ATTR_SSI_PROVIDER: c_ulong = 2; +pub const SECPKG_CRED_ATTR_KDC_PROXY_SETTINGS: c_ulong = 3; +pub const SECPKG_CRED_ATTR_CERT: c_ulong = 4; +STRUCT!{struct SecPkgCredentials_NamesW { + sUserName: *mut SEC_WCHAR, +}} +pub type PSecPkgCredentials_NamesW = *mut SecPkgCredentials_NamesW; +STRUCT!{struct SecPkgCredentials_NamesA { + sUserName: *mut SEC_CHAR, +}} +pub type PSecPkgCredentials_NamesA = *mut SecPkgCredentials_NamesA; +STRUCT!{struct SecPkgCredentials_SSIProviderW { + sProviderName: *mut SEC_WCHAR, + ProviderInfoLength: c_ulong, + ProviderInfo: *mut c_char, +}} +pub type PSecPkgCredentials_SSIProviderW = *mut SecPkgCredentials_SSIProviderW; +STRUCT!{struct SecPkgCredentials_SSIProviderA { + sProviderName: *mut SEC_CHAR, + ProviderInfoLength: c_ulong, + ProviderInfo: *mut c_char, +}} +pub type PSecPkgCredentials_SSIProviderA = *mut SecPkgCredentials_SSIProviderA; +pub const KDC_PROXY_SETTINGS_V1: ULONG = 1; +pub const KDC_PROXY_SETTINGS_FLAGS_FORCEPROXY: ULONG = 0x1; +STRUCT!{struct SecPkgCredentials_KdcProxySettingsW { + Version: ULONG, + Flags: ULONG, + ProxyServerOffset: USHORT, + ProxyServerLength: USHORT, + ClientTlsCredOffset: USHORT, + ClientTlsCredLength: USHORT, +}} +pub type PSecPkgCredentials_KdcProxySettingsW = *mut SecPkgCredentials_KdcProxySettingsW; +STRUCT!{struct SecPkgCredentials_Cert { + EncodedCertSize: c_ulong, + EncodedCert: *mut c_uchar, +}} +pub type PSecPkgCredentials_Cert = *mut SecPkgCredentials_Cert; +pub const SECPKG_ATTR_SIZES: c_ulong = 0; +pub const SECPKG_ATTR_NAMES: c_ulong = 1; +pub const SECPKG_ATTR_LIFESPAN: c_ulong = 2; +pub const SECPKG_ATTR_DCE_INFO: c_ulong = 3; +pub const SECPKG_ATTR_STREAM_SIZES: c_ulong = 4; +pub const SECPKG_ATTR_KEY_INFO: c_ulong = 5; +pub const SECPKG_ATTR_AUTHORITY: c_ulong = 6; +pub const SECPKG_ATTR_PROTO_INFO: c_ulong = 7; +pub const SECPKG_ATTR_PASSWORD_EXPIRY: c_ulong = 8; +pub const SECPKG_ATTR_SESSION_KEY: c_ulong = 9; +pub const SECPKG_ATTR_PACKAGE_INFO: c_ulong = 10; +pub const SECPKG_ATTR_USER_FLAGS: c_ulong = 11; +pub const SECPKG_ATTR_NEGOTIATION_INFO: c_ulong = 12; +pub const SECPKG_ATTR_NATIVE_NAMES: c_ulong = 13; +pub const SECPKG_ATTR_FLAGS: c_ulong = 14; +pub const SECPKG_ATTR_USE_VALIDATED: c_ulong = 15; +pub const SECPKG_ATTR_CREDENTIAL_NAME: c_ulong = 16; +pub const SECPKG_ATTR_TARGET_INFORMATION: c_ulong = 17; +pub const SECPKG_ATTR_ACCESS_TOKEN: c_ulong = 18; +pub const SECPKG_ATTR_TARGET: c_ulong = 19; +pub const SECPKG_ATTR_AUTHENTICATION_ID: c_ulong = 20; +pub const SECPKG_ATTR_LOGOFF_TIME: c_ulong = 21; +pub const SECPKG_ATTR_NEGO_KEYS: c_ulong = 22; +pub const SECPKG_ATTR_PROMPTING_NEEDED: c_ulong = 24; +pub const SECPKG_ATTR_UNIQUE_BINDINGS: c_ulong = 25; +pub const SECPKG_ATTR_ENDPOINT_BINDINGS: c_ulong = 26; +pub const SECPKG_ATTR_CLIENT_SPECIFIED_TARGET: c_ulong = 27; +pub const SECPKG_ATTR_LAST_CLIENT_TOKEN_STATUS: c_ulong = 30; +pub const SECPKG_ATTR_NEGO_PKG_INFO: c_ulong = 31; +pub const SECPKG_ATTR_NEGO_STATUS: c_ulong = 32; +pub const SECPKG_ATTR_CONTEXT_DELETED: c_ulong = 33; +pub const SECPKG_ATTR_DTLS_MTU: c_ulong = 34; +pub const SECPKG_ATTR_DATAGRAM_SIZES: c_ulong = SECPKG_ATTR_STREAM_SIZES; +pub const SECPKG_ATTR_SUBJECT_SECURITY_ATTRIBUTES: c_ulong = 128; +pub const SECPKG_ATTR_APPLICATION_PROTOCOL: c_ulong = 35; +STRUCT!{struct SecPkgContext_SubjectAttributes { + AttributeInfo: *mut c_void, +}} +pub type PSecPkgContext_SubjectAttributes = *mut SecPkgContext_SubjectAttributes; +pub const SECPKG_ATTR_NEGO_INFO_FLAG_NO_KERBEROS: c_ulong = 0x1; +pub const SECPKG_ATTR_NEGO_INFO_FLAG_NO_NTLM: c_ulong = 0x2; +ENUM!{enum SECPKG_CRED_CLASS { + SecPkgCredClass_None = 0, + SecPkgCredClass_Ephemeral = 10, + SecPkgCredClass_PersistedGeneric = 20, + SecPkgCredClass_PersistedSpecific = 30, + SecPkgCredClass_Explicit = 40, +}} +pub type PSECPKG_CRED_CLASS = *mut SECPKG_CRED_CLASS; +STRUCT!{struct SecPkgContext_CredInfo { + CredClass: SECPKG_CRED_CLASS, + IsPromptingNeeded: c_ulong, +}} +pub type PSecPkgContext_CredInfo = *mut SecPkgContext_CredInfo; +STRUCT!{struct SecPkgContext_NegoPackageInfo { + PackageMask: c_ulong, +}} +pub type PSecPkgContext_NegoPackageInfo = *mut SecPkgContext_NegoPackageInfo; +STRUCT!{struct SecPkgContext_NegoStatus { + LastStatus: c_ulong, +}} +pub type PSecPkgContext_NegoStatus = *mut SecPkgContext_NegoStatus; +STRUCT!{struct SecPkgContext_Sizes { + cbMaxToken: c_ulong, + cbMaxSignature: c_ulong, + cbBlockSize: c_ulong, + cbSecurityTrailer: c_ulong, +}} +pub type PSecPkgContext_Sizes = *mut SecPkgContext_Sizes; +STRUCT!{struct SecPkgContext_StreamSizes { + cbHeader: c_ulong, + cbTrailer: c_ulong, + cbMaximumMessage: c_ulong, + cBuffers: c_ulong, + cbBlockSize: c_ulong, +}} +pub type PSecPkgContext_StreamSizes = *mut SecPkgContext_StreamSizes; +pub type SecPkgContext_DatagramSizes = SecPkgContext_StreamSizes; +pub type PSecPkgContext_DatagramSizes = PSecPkgContext_StreamSizes; +STRUCT!{struct SecPkgContext_NamesW { + sUserName: *mut SEC_WCHAR, +}} +pub type PSecPkgContext_NamesW = *mut SecPkgContext_NamesW; +ENUM!{enum SECPKG_ATTR_LCT_STATUS { + SecPkgAttrLastClientTokenYes, + SecPkgAttrLastClientTokenNo, + SecPkgAttrLastClientTokenMaybe, +}} +pub type PSECPKG_ATTR_LCT_STATUS = *mut SECPKG_ATTR_LCT_STATUS; +STRUCT!{struct SecPkgContext_LastClientTokenStatus { + LastClientTokenStatus: SECPKG_ATTR_LCT_STATUS, +}} +pub type PSecPkgContext_LastClientTokenStatus = *mut SecPkgContext_LastClientTokenStatus; +STRUCT!{struct SecPkgContext_NamesA { + sUserName: *mut SEC_CHAR, +}} +pub type PSecPkgContext_NamesA = *mut SecPkgContext_NamesA; +STRUCT!{struct SecPkgContext_Lifespan { + tsStart: TimeStamp, + tsExpiry: TimeStamp, +}} +pub type PSecPkgContext_Lifespan = *mut SecPkgContext_Lifespan; +STRUCT!{struct SecPkgContext_DceInfo { + AuthzSvc: c_ulong, + pPac: *mut c_void, +}} +pub type PSecPkgContext_DceInfo = *mut SecPkgContext_DceInfo; +STRUCT!{struct SecPkgContext_KeyInfoA { + sSignatureAlgorithmName: *mut SEC_CHAR, + sEncryptAlgorithmName: *mut SEC_CHAR, + KeySize: c_ulong, + SignatureAlgorithm: c_ulong, + EncryptAlgorithm: c_ulong, +}} +pub type PSecPkgContext_KeyInfoA = *mut SecPkgContext_KeyInfoA; +STRUCT!{struct SecPkgContext_KeyInfoW { + sSignatureAlgorithmName: *mut SEC_WCHAR, + sEncryptAlgorithmName: *mut SEC_WCHAR, + KeySize: c_ulong, + SignatureAlgorithm: c_ulong, + EncryptAlgorithm: c_ulong, +}} +pub type PSecPkgContext_KeyInfoW = *mut SecPkgContext_KeyInfoW; +STRUCT!{struct SecPkgContext_AuthorityA { + sAuthorityName: *mut SEC_CHAR, +}} +pub type PSecPkgContext_AuthorityA = *mut SecPkgContext_AuthorityA; +STRUCT!{struct SecPkgContext_AuthorityW { + sAuthorityName: *mut SEC_WCHAR, +}} +pub type PSecPkgContext_AuthorityW = *mut SecPkgContext_AuthorityW; +STRUCT!{struct SecPkgContext_ProtoInfoA { + sProtocolName: *mut SEC_CHAR, + majorVersion: c_ulong, + minorVersion: c_ulong, +}} +pub type PSecPkgContext_ProtoInfoA = *mut SecPkgContext_ProtoInfoA; +STRUCT!{struct SecPkgContext_ProtoInfoW { + sProtocolName: *mut SEC_WCHAR, + majorVersion: c_ulong, + minorVersion: c_ulong, +}} +pub type PSecPkgContext_ProtoInfoW = *mut SecPkgContext_ProtoInfoW; +STRUCT!{struct SecPkgContext_PasswordExpiry { + tsPasswordExpires: TimeStamp, +}} +pub type PSecPkgContext_PasswordExpiry = *mut SecPkgContext_PasswordExpiry; +STRUCT!{struct SecPkgContext_LogoffTime { + tsLogoffTime: TimeStamp, +}} +pub type PSecPkgContext_LogoffTime = *mut SecPkgContext_LogoffTime; +STRUCT!{struct SecPkgContext_SessionKey { + SessionKeyLength: c_ulong, + SessionKey: *mut c_uchar, +}} +pub type PSecPkgContext_SessionKey = *mut SecPkgContext_SessionKey; +STRUCT!{struct SecPkgContext_NegoKeys { + KeyType: c_ulong, + KeyLength: c_ushort, + KeyValue: *mut c_uchar, + VerifyKeyType: c_ulong, + VerifyKeyLength: c_ushort, + VerifyKeyValue: *mut c_uchar, +}} +pub type PSecPkgContext_NegoKeys = *mut SecPkgContext_NegoKeys; +STRUCT!{struct SecPkgContext_PackageInfoW { + PackageInfo: PSecPkgInfoW, +}} +pub type PSecPkgContext_PackageInfoW = *mut SecPkgContext_PackageInfoW; +STRUCT!{struct SecPkgContext_PackageInfoA { + PackageInfo: PSecPkgInfoA, +}} +pub type PSecPkgContext_PackageInfoA = *mut SecPkgContext_PackageInfoA; +STRUCT!{struct SecPkgContext_UserFlags { + UserFlags: c_ulong, +}} +pub type PSecPkgContext_UserFlags = *mut SecPkgContext_UserFlags; +STRUCT!{struct SecPkgContext_Flags { + Flags: c_ulong, +}} +pub type PSecPkgContext_Flags = *mut SecPkgContext_Flags; +STRUCT!{struct SecPkgContext_NegotiationInfoA { + PackageInfo: PSecPkgInfoA, + NegotiationState: c_ulong, +}} +pub type PSecPkgContext_NegotiationInfoA = *mut SecPkgContext_NegotiationInfoA; +STRUCT!{struct SecPkgContext_NegotiationInfoW { + PackageInfo: PSecPkgInfoW, + NegotiationState: c_ulong, +}} +pub type PSecPkgContext_NegotiationInfoW = *mut SecPkgContext_NegotiationInfoW; +pub const SECPKG_NEGOTIATION_COMPLETE: c_ulong = 0; +pub const SECPKG_NEGOTIATION_OPTIMISTIC: c_ulong = 1; +pub const SECPKG_NEGOTIATION_IN_PROGRESS: c_ulong = 2; +pub const SECPKG_NEGOTIATION_DIRECT: c_ulong = 3; +pub const SECPKG_NEGOTIATION_TRY_MULTICRED: c_ulong = 4; +STRUCT!{struct SecPkgContext_NativeNamesW { + sClientName: *mut SEC_WCHAR, + sServerName: *mut SEC_WCHAR, +}} +pub type PSecPkgContext_NativeNamesW = *mut SecPkgContext_NativeNamesW; +STRUCT!{struct SecPkgContext_NativeNamesA { + sClientName: *mut SEC_CHAR, + sServerName: *mut SEC_CHAR, +}} +pub type PSecPkgContext_NativeNamesA = *mut SecPkgContext_NativeNamesA; +STRUCT!{struct SecPkgContext_CredentialNameW { + CredentialType: c_ulong, + sCredentialName: *mut SEC_WCHAR, +}} +pub type PSecPkgContext_CredentialNameW = *mut SecPkgContext_CredentialNameW; +STRUCT!{struct SecPkgContext_CredentialNameA { + CredentialType: c_ulong, + sCredentialName: *mut SEC_CHAR, +}} +pub type PSecPkgContext_CredentialNameA = *mut SecPkgContext_CredentialNameA; +STRUCT!{struct SecPkgContext_AccessToken { + AccessToken: *mut c_void, +}} +pub type PSecPkgContext_AccessToken = *mut SecPkgContext_AccessToken; +STRUCT!{struct SecPkgContext_TargetInformation { + MarshalledTargetInfoLength: c_ulong, + MarshalledTargetInfo: *mut c_uchar, +}} +pub type PSecPkgContext_TargetInformation = *mut SecPkgContext_TargetInformation; +STRUCT!{struct SecPkgContext_AuthzID { + AuthzIDLength: c_ulong, + AuthzID: *mut c_char, +}} +pub type PSecPkgContext_AuthzID = *mut SecPkgContext_AuthzID; +STRUCT!{struct SecPkgContext_Target { + TargetLength: c_ulong, + Target: *mut c_char, +}} +pub type PSecPkgContext_Target = *mut SecPkgContext_Target; +STRUCT!{struct SecPkgContext_ClientSpecifiedTarget { + sTargetName: *mut SEC_WCHAR, +}} +pub type PSecPkgContext_ClientSpecifiedTarget = *mut SecPkgContext_ClientSpecifiedTarget; +STRUCT!{struct SecPkgContext_Bindings { + BindingsLength: c_ulong, + Bindings: *mut SEC_CHANNEL_BINDINGS, +}} +pub type PSecPkgContext_Bindings = *mut SecPkgContext_Bindings; +ENUM!{enum SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS { + SecApplicationProtocolNegotiationStatus_None, + SecApplicationProtocolNegotiationStatus_Success, + SecApplicationProtocolNegotiationStatus_SelectedClientOnly, +}} +pub type PSEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS = + *mut SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS; +pub const MAX_PROTOCOL_ID_SIZE: usize = 0xff; +STRUCT!{struct SecPkgContext_ApplicationProtocol { + ProtoNegoStatus: SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS, + ProtoNegoExt: SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT, + ProtocolIdSize: c_uchar, + ProtocolId: [c_uchar; MAX_PROTOCOL_ID_SIZE], +}} +pub type PSecPkgContext_ApplicationProtocol = *mut SecPkgContext_ApplicationProtocol; +FN!{stdcall SEC_GET_KEY_FN( + Arg: *mut c_void, + Principal: *mut c_void, + KeyVer: c_ulong, + Key: *mut *mut c_void, + Status: *mut SECURITY_STATUS, +) -> ()} +pub const SECPKG_CONTEXT_EXPORT_RESET_NEW: c_ulong = 0x00000001; +pub const SECPKG_CONTEXT_EXPORT_DELETE_OLD: c_ulong = 0x00000002; +pub const SECPKG_CONTEXT_EXPORT_TO_KERNEL: c_ulong = 0x00000004; +extern "system" { + pub fn AcquireCredentialsHandleW( + pszPrincipal: LPWSTR, + pszPackage: LPWSTR, + fCredentialUse: c_ulong, + pvLogonId: *mut c_void, + pAuthData: *mut c_void, + pGetKeyFn: SEC_GET_KEY_FN, + pvGetKeyArgument: *mut c_void, + phCredential: PCredHandle, + ptsExpiry: PTimeStamp, + ) -> SECURITY_STATUS; +} +FN!{stdcall ACQUIRE_CREDENTIALS_HANDLE_FN_W( + *mut SEC_WCHAR, + *mut SEC_WCHAR, + c_ulong, + *mut c_void, + *mut c_void, + SEC_GET_KEY_FN, + *mut c_void, + PCredHandle, + PTimeStamp, +) -> SECURITY_STATUS} +extern "system" { + pub fn AcquireCredentialsHandleA( + pszPrincipal: LPSTR, + pszPackage: LPSTR, + fCredentialUse: c_ulong, + pvLogonId: *mut c_void, + pAuthData: *mut c_void, + pGetKeyFn: SEC_GET_KEY_FN, + pvGetKeyArgument: *mut c_void, + phCredential: PCredHandle, + ptsExpiry: PTimeStamp, + ) -> SECURITY_STATUS; +} +FN!{stdcall ACQUIRE_CREDENTIALS_HANDLE_FN_A( + *mut SEC_CHAR, + *mut SEC_CHAR, + c_ulong, + *mut c_void, + *mut c_void, + SEC_GET_KEY_FN, + *mut c_void, + PCredHandle, + PTimeStamp, +) -> SECURITY_STATUS} +extern "system" { + pub fn FreeCredentialsHandle( + phCredential: PCredHandle, + ) -> SECURITY_STATUS; +} +FN!{stdcall FREE_CREDENTIALS_HANDLE_FN( + PCredHandle, +) -> SECURITY_STATUS} +extern "system" { + pub fn AddCredentialsW( + hCredentials: PCredHandle, + pszPrincipal: LPWSTR, + pszPackage: LPWSTR, + fCredentialUse: c_ulong, + pAuthData: *mut c_void, + pGetKeyFn: SEC_GET_KEY_FN, + pvGetKeyArgument: *mut c_void, + ptsExpiry: PTimeStamp, + ) -> SECURITY_STATUS; +} +FN!{stdcall ADD_CREDENTIALS_FN_W( + PCredHandle, + *mut SEC_WCHAR, + *mut SEC_WCHAR, + c_ulong, + *mut c_void, + SEC_GET_KEY_FN, + *mut c_void, + PTimeStamp, +) -> SECURITY_STATUS} +extern "system" { + pub fn AddCredentialsA( + hCredentials: PCredHandle, + pszPrincipal: LPSTR, + pszPackage: LPSTR, + fCredentialUse: c_ulong, + pAuthData: *mut c_void, + pGetKeyFn: SEC_GET_KEY_FN, + pvGetKeyArgument: *mut c_void, + ptsExpiry: PTimeStamp, + ) -> SECURITY_STATUS; +} +FN!{stdcall ADD_CREDENTIALS_FN_A( + PCredHandle, + *mut SEC_CHAR, + *mut SEC_CHAR, + c_ulong, + *mut c_void, + SEC_GET_KEY_FN, + *mut c_void, + PTimeStamp, +) -> SECURITY_STATUS} +extern "system" { + // pub fn spiCreateAsyncContext(); + // pub fn SspiFreeAsyncContext(); + // pub fn SspiReinitAsyncContext(); + // pub fn SspiSetAsyncNotifyCallback(); + // pub fn SspiAsyncContextRequiresNotify(); + // pub fn SspiGetAsyncCallStatus(); + // pub fn SspiAcquireCredentialsHandleAsyncW(); + // pub fn SspiAcquireCredentialsHandleAsyncA(); + // pub fn SspiInitializeSecurityContextAsyncW(); + // pub fn SspiInitializeSecurityContextAsyncA(); + // pub fn SspiAcceptSecurityContextAsync(); + // pub fn SspiFreeCredentialsHandleAsync(); + // pub fn SspiDeleteSecurityContextAsync(); + pub fn ChangeAccountPasswordW( + pszPackageName: *mut SEC_WCHAR, + pszDomainName: *mut SEC_WCHAR, + pszAccountName: *mut SEC_WCHAR, + pszOldPassword: *mut SEC_WCHAR, + pszNewPassword: *mut SEC_WCHAR, + bImpersonating: BOOLEAN, + dwReserved: c_ulong, + pOutput: PSecBufferDesc, + ) -> SECURITY_STATUS; +} +FN!{stdcall CHANGE_PASSWORD_FN_W( + *mut SEC_WCHAR, + *mut SEC_WCHAR, + *mut SEC_WCHAR, + *mut SEC_WCHAR, + *mut SEC_WCHAR, + BOOLEAN, + c_ulong, + PSecBufferDesc, +) -> SECURITY_STATUS} +extern "system" { + pub fn ChangeAccountPasswordA( + pszPackageName: *mut SEC_CHAR, + pszDomainName: *mut SEC_CHAR, + pszAccountName: *mut SEC_CHAR, + pszOldPassword: *mut SEC_CHAR, + pszNewPassword: *mut SEC_CHAR, + bImpersonating: BOOLEAN, + dwReserved: c_ulong, + pOutput: PSecBufferDesc, + ) -> SECURITY_STATUS; +} +FN!{stdcall CHANGE_PASSWORD_FN_A( + *mut SEC_CHAR, + *mut SEC_CHAR, + *mut SEC_CHAR, + *mut SEC_CHAR, + *mut SEC_CHAR, + BOOLEAN, + c_ulong, + PSecBufferDesc, +) -> SECURITY_STATUS} +extern "system" { + pub fn InitializeSecurityContextW( + phCredential: PCredHandle, + phContext: PCtxtHandle, + pszTargetName: *mut SEC_WCHAR, + fContextReq: c_ulong, + Reserved1: c_ulong, + TargetDataRep: c_ulong, + pInput: PSecBufferDesc, + Reserved2: c_ulong, + phNewContext: PCtxtHandle, + pOutput: PSecBufferDesc, + pfContextAttr: *mut c_ulong, + ptsExpiry: PTimeStamp, + ) -> SECURITY_STATUS; +} +// INITIALIZE_SECURITY_CONTEXT_FN_W +extern "system" { + pub fn InitializeSecurityContextA( + phCredential: PCredHandle, + phContext: PCtxtHandle, + pszTargetName: *mut SEC_CHAR, + fContextReq: c_ulong, + Reserved1: c_ulong, + TargetDataRep: c_ulong, + pInput: PSecBufferDesc, + Reserved2: c_ulong, + phNewContext: PCtxtHandle, + pOutput: PSecBufferDesc, + pfContextAttr: *mut c_ulong, + ptsExpiry: PTimeStamp, + ) -> SECURITY_STATUS; + pub fn AcceptSecurityContext( + phCredential: PCredHandle, + phContext: PCtxtHandle, + pInput: PSecBufferDesc, + fContextReq: c_ulong, + TargetDataRep: c_ulong, + phNewContext: PCtxtHandle, + pOutput: PSecBufferDesc, + pfContextAttr: *mut c_ulong, + ptsExpiry: PTimeStamp, + ) -> SECURITY_STATUS; + pub fn CompleteAuthToken( + phContext: PCtxtHandle, + pToken: PSecBufferDesc, + ) -> SECURITY_STATUS; + pub fn ImpersonateSecurityContext( + phContext: PCtxtHandle, + ) -> SECURITY_STATUS; + pub fn RevertSecurityContext( + phContext: PCtxtHandle, + ) -> SECURITY_STATUS; + pub fn QuerySecurityContextToken( + phContext: PCtxtHandle, + Token: *mut *mut c_void, + ) -> SECURITY_STATUS; + pub fn DeleteSecurityContext( + phContext: PCtxtHandle, + ) -> SECURITY_STATUS; + pub fn ApplyControlToken( + phContext: PCtxtHandle, + pInput: PSecBufferDesc, + ) -> SECURITY_STATUS; + pub fn QueryContextAttributesW( + phContext: PCtxtHandle, + ulAttribute: c_ulong, + pBuffer: *mut c_void, + ) -> SECURITY_STATUS; + // pub fn QueryContextAttributesExW(); + pub fn QueryContextAttributesA( + phContext: PCtxtHandle, + ulAttribute: c_ulong, + pBuffer: *mut c_void, + ) -> SECURITY_STATUS; + // pub fn QueryContextAttributesExA(); + pub fn SetContextAttributesW( + phContext: PCtxtHandle, + ulAttribute: c_ulong, + pBuffer: *mut c_void, + cbBuffer: c_ulong, + ) -> SECURITY_STATUS; + pub fn SetContextAttributesA( + phContext: PCtxtHandle, + ulAttribute: c_ulong, + pBuffer: *mut c_void, + cbBuffer: c_ulong, + ) -> SECURITY_STATUS; + pub fn QueryCredentialsAttributesW( + phCredential: PCredHandle, + ulAttribute: c_ulong, + pBuffer: *mut c_void, + ) -> SECURITY_STATUS; + // pub fn QueryCredentialsAttributesExW(); + pub fn QueryCredentialsAttributesA( + phCredential: PCredHandle, + ulAttribute: c_ulong, + pBuffer: *mut c_void, + ) -> SECURITY_STATUS; + // pub fn QueryCredentialsAttributesExA(); + pub fn SetCredentialsAttributesW( + phCredential: PCredHandle, + ulAttribute: c_ulong, + pBuffer: *mut c_void, + cbBuffer: c_ulong, + ) -> SECURITY_STATUS; + pub fn SetCredentialsAttributesA( + phCredential: PCredHandle, + ulAttribute: c_ulong, + pBuffer: *mut c_void, + cbBuffer: c_ulong, + ) -> SECURITY_STATUS; + pub fn FreeContextBuffer( + pvContextBuffer: PVOID, + ) -> SECURITY_STATUS; + pub fn MakeSignature( + phContext: PCtxtHandle, + fQOP: c_ulong, + pMessage: PSecBufferDesc, + MessageSeqNo: c_ulong, + ) -> SECURITY_STATUS; + pub fn VerifySignature( + phContext: PCtxtHandle, + pMessage: PSecBufferDesc, + MessageSeqNo: c_ulong, + pfQOP: *mut c_ulong, + ) -> SECURITY_STATUS; + pub fn EncryptMessage( + phContext: PCtxtHandle, + fQOP: c_ulong, + pMessage: PSecBufferDesc, + MessageSeqNo: c_ulong, + ) -> SECURITY_STATUS; + pub fn DecryptMessage( + phContext: PCtxtHandle, + pMessage: PSecBufferDesc, + MessageSeqNo: c_ulong, + pfQOP: *mut c_ulong, + ) -> SECURITY_STATUS; + pub fn EnumerateSecurityPackagesW( + pcPackages: *mut c_ulong, + ppPackageInfo: *mut PSecPkgInfoW, + ) -> SECURITY_STATUS; + pub fn EnumerateSecurityPackagesA( + pcPackages: *mut c_ulong, + ppPackageInfo: *mut PSecPkgInfoA, + ) -> SECURITY_STATUS; + pub fn QuerySecurityPackageInfoW( + pszPackageName: LPWSTR, + ppPackageInfo: *mut PSecPkgInfoW, + ) -> SECURITY_STATUS; + pub fn QuerySecurityPackageInfoA( + pszPackageName: LPSTR, + ppPackageInfo: *mut PSecPkgInfoA, + ) -> SECURITY_STATUS; +} +ENUM!{enum SecDelegationType { + SecFull, + SecService, + SecTree, + SecDirectory, + SecObject, +}} +pub type PSecDelegationType = *mut SecDelegationType; +extern "system" { + // pub fn DelegateSecurityContext(); + pub fn ExportSecurityContext( + phContext: PCtxtHandle, + fFlags: ULONG, + pPackedContext: PSecBuffer, + pToken: *mut *mut c_void, + ) -> SECURITY_STATUS; + pub fn ImportSecurityContextW( + pszPackage: LPWSTR, + pPackedContext: PSecBuffer, + Token: *mut c_void, + phContext: PCtxtHandle, + ) -> SECURITY_STATUS; + pub fn ImportSecurityContextA( + pszPackage: LPSTR, + pPackedContext: PSecBuffer, + Token: *mut c_void, + phContext: PCtxtHandle, + ) -> SECURITY_STATUS; +// pub fn SecMakeSPN(); +// pub fn SecMakeSPNEx(); +// pub fn SecMakeSPNEx2(); +// pub fn SecLookupAccountSid(); +// pub fn SecLookupAccountName(); +// pub fn SecLookupWellKnownSid(); +} +extern "system" { + // pub fn InitSecurityInterfaceA(); + // pub fn InitSecurityInterfaceW(); + // pub fn SaslEnumerateProfilesA(); + // pub fn SaslEnumerateProfilesW(); + // pub fn SaslGetProfilePackageA(); + // pub fn SaslGetProfilePackageW(); + // pub fn SaslIdentifyPackageA(); + // pub fn SaslIdentifyPackageW(); + // pub fn SaslInitializeSecurityContextW(); + // pub fn SaslInitializeSecurityContextA(); + // pub fn SaslAcceptSecurityContext(); + // pub fn SaslSetContextOption(); + // pub fn SaslGetContextOption(); +} +pub type PSEC_WINNT_AUTH_IDENTITY_OPAQUE = PVOID; +extern "system" { + pub fn SspiPromptForCredentialsW( + pszTargetName: PCWSTR, + pUiInfo: PCREDUI_INFOW, + dwAuthError: c_ulong, + pszPackage: PCWSTR, + pInputAuthIdentity: PSEC_WINNT_AUTH_IDENTITY_OPAQUE, + ppAuthIdentity: *mut PSEC_WINNT_AUTH_IDENTITY_OPAQUE, + pfSave: *mut c_int, + dwFlags: c_ulong, + ) -> c_ulong; + pub fn SspiPromptForCredentialsA( + pszTargetName: PCSTR, + pUiInfo: PCREDUI_INFOA, + dwAuthError: c_ulong, + pszPackage: PCSTR, + pInputAuthIdentity: PSEC_WINNT_AUTH_IDENTITY_OPAQUE, + ppAuthIdentity: *mut PSEC_WINNT_AUTH_IDENTITY_OPAQUE, + pfSave: *mut c_int, + dwFlags: c_ulong, + ) -> c_ulong; +} +STRUCT!{struct SEC_WINNT_AUTH_BYTE_VECTOR { + ByteArrayOffset: c_ulong, + ByteArrayLength: c_ushort, +}} +pub type PSEC_WINNT_AUTH_BYTE_VECTOR = *mut SEC_WINNT_AUTH_BYTE_VECTOR; +STRUCT!{struct SEC_WINNT_AUTH_DATA { + CredType: GUID, + CredData: SEC_WINNT_AUTH_BYTE_VECTOR, +}} +pub type PSEC_WINNT_AUTH_DATA = *mut SEC_WINNT_AUTH_DATA; +STRUCT!{struct SEC_WINNT_AUTH_PACKED_CREDENTIALS { + cbHeaderLength: c_ushort, + cbStructureLength: c_ushort, + AuthData: SEC_WINNT_AUTH_DATA, +}} +pub type PSEC_WINNT_AUTH_PACKED_CREDENTIALS = *mut SEC_WINNT_AUTH_PACKED_CREDENTIALS; +DEFINE_GUID!{SEC_WINNT_AUTH_DATA_TYPE_PASSWORD, + 0x28bfc32f, 0x10f6, 0x4738, 0x98, 0xd1, 0x1a, 0xc0, 0x61, 0xdf, 0x71, 0x6a} +DEFINE_GUID!{SEC_WINNT_AUTH_DATA_TYPE_CERT, + 0x235f69ad, 0x73fb, 0x4dbc, 0x82, 0x3, 0x6, 0x29, 0xe7, 0x39, 0x33, 0x9b} +STRUCT!{struct SEC_WINNT_AUTH_DATA_PASSWORD { + UnicodePassword: SEC_WINNT_AUTH_BYTE_VECTOR, +}} +pub type PSEC_WINNT_AUTH_DATA_PASSWORD = *mut SEC_WINNT_AUTH_DATA_PASSWORD; +DEFINE_GUID!{SEC_WINNT_AUTH_DATA_TYPE_CSP_DATA, + 0x68fd9879, 0x79c, 0x4dfe, 0x82, 0x81, 0x57, 0x8a, 0xad, 0xc1, 0xc1, 0x0} +// GUID SEC_WINNT_AUTH_DATA_TYPE_SMARTCARD_CONTEXTS +STRUCT!{struct SEC_WINNT_AUTH_CERTIFICATE_DATA { + cbHeaderLength: c_ushort, + cbStructureLength: c_ushort, + Certificate: SEC_WINNT_AUTH_BYTE_VECTOR, +}} +pub type PSEC_WINNT_AUTH_CERTIFICATE_DATA = *mut SEC_WINNT_AUTH_CERTIFICATE_DATA; +STRUCT!{struct SEC_WINNT_CREDUI_CONTEXT_VECTOR { + CredUIContextArrayOffset: ULONG, + CredUIContextCount: USHORT, +}} +pub type PSEC_WINNT_CREDUI_CONTEXT_VECTOR = *mut SEC_WINNT_CREDUI_CONTEXT_VECTOR; +STRUCT!{struct SEC_WINNT_AUTH_SHORT_VECTOR { + ShortArrayOffset: ULONG, + ShortArrayCount: USHORT, +}} +pub type PSEC_WINNT_AUTH_SHORT_VECTOR = *mut SEC_WINNT_AUTH_SHORT_VECTOR; +extern "system" { + pub fn SspiGetCredUIContext( + ContextHandle: HANDLE, + CredType: *mut GUID, + LogonId: *mut LUID, + CredUIContexts: *mut PSEC_WINNT_CREDUI_CONTEXT_VECTOR, + TokenHandle: *mut HANDLE, + ) -> SECURITY_STATUS; + pub fn SspiUpdateCredentials( + ContextHandle: HANDLE, + CredType: *mut GUID, + FlatCredUIContextLength: ULONG, + FlatCredUIContext: PUCHAR, + ) -> SECURITY_STATUS; +} +STRUCT!{struct CREDUIWIN_MARSHALED_CONTEXT { + StructureType: GUID, + cbHeaderLength: USHORT, + LogonId: LUID, + MarshaledDataType: GUID, + MarshaledDataOffset: ULONG, + MarshaledDataLength: USHORT, +}} +pub type PCREDUIWIN_MARSHALED_CONTEXT = *mut CREDUIWIN_MARSHALED_CONTEXT; +STRUCT!{struct SEC_WINNT_CREDUI_CONTEXT { + cbHeaderLength: USHORT, + CredUIContextHandle: HANDLE, + UIInfo: PCREDUI_INFOW, + dwAuthError: ULONG, + pInputAuthIdentity: PSEC_WINNT_AUTH_IDENTITY_OPAQUE, + TargetName: PUNICODE_STRING, +}} +pub type PSEC_WINNT_CREDUI_CONTEXT = *mut SEC_WINNT_CREDUI_CONTEXT; +// GUID CREDUIWIN_STRUCTURE_TYPE_SSPIPFC +// GUID SSPIPFC_STRUCTURE_TYPE_CREDUI_CONTEXT +extern "system" { + pub fn SspiUnmarshalCredUIContext( + MarshaledCredUIContext: PUCHAR, + MarshaledCredUIContextLength: ULONG, + CredUIContext: *mut PSEC_WINNT_CREDUI_CONTEXT, + ) -> SECURITY_STATUS; + // pub fn SspiPrepareForCredRead(); + // pub fn SspiPrepareForCredWrite(); + // pub fn SspiEncryptAuthIdentity(); + // pub fn SspiEncryptAuthIdentityEx(); + // pub fn SspiDecryptAuthIdentity(); + // pub fn SspiDecryptAuthIdentityEx(); + // pub fn SspiIsAuthIdentityEncrypted(); + // pub fn SspiEncodeAuthIdentityAsStrings(); + // pub fn SspiValidateAuthIdentity(); + // pub fn SspiCopyAuthIdentity(); + // pub fn SspiFreeAuthIdentity(); + // pub fn SspiZeroAuthIdentity(); + // pub fn SspiLocalFree(); + // pub fn SspiEncodeStringsAsAuthIdentity(); + // pub fn SspiCompareAuthIdentities(); + // pub fn SspiMarshalAuthIdentity(); + // pub fn SspiUnmarshalAuthIdentity(); + pub fn SspiIsPromptingNeeded( + ErrorOrNtStatus: c_ulong, + ) -> BOOLEAN; + // pub fn SspiGetTargetHostName(); + // pub fn SspiExcludePackage(); + // pub fn AddSecurityPackageA(); + // pub fn AddSecurityPackageW(); + // pub fn DeleteSecurityPackageA(); + // pub fn DeleteSecurityPackageW(); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/stralign.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/stralign.rs new file mode 100644 index 0000000..2e2a703 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/stralign.rs @@ -0,0 +1,40 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_int; +use um::winnt::{LPCUWSTR, PCUWSTR, PUWSTR, WCHAR}; +use vc::vcruntime::size_t; +extern "system" { + pub fn uaw_lstrcmpW( + String1: PCUWSTR, + String2: PCUWSTR, + ) -> c_int; + pub fn uaw_lstrcmpiW( + String1: PCUWSTR, + String2: PCUWSTR, + ) -> c_int; + pub fn uaw_lstrlenW( + String: LPCUWSTR, + ) -> c_int; + pub fn uaw_wcschr( + String: PCUWSTR, + Character: WCHAR, + ) -> PUWSTR; + pub fn uaw_wcscpy( + Destination: PUWSTR, + Source: PCUWSTR, + ) -> PUWSTR; + pub fn uaw_wcsicmp( + String1: PCUWSTR, + String2: PCUWSTR, + ) -> c_int; + pub fn uaw_wcslen( + String: PCUWSTR, + ) -> size_t; + pub fn uaw_wcsrchr( + String: PCUWSTR, + Character: WCHAR, + ) -> PUWSTR; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/transportsettingcommon.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/transportsettingcommon.rs new file mode 100644 index 0000000..2f5f6fb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/transportsettingcommon.rs @@ -0,0 +1,10 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::GUID; +STRUCT!{struct TRANSPORT_SETTING_ID { + Guid: GUID, +}} +pub type PTRANSPORT_SETTING_ID = *mut TRANSPORT_SETTING_ID; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/tvout.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/tvout.rs new file mode 100644 index 0000000..f691bdf --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/tvout.rs @@ -0,0 +1,72 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::GUID; +use shared::minwindef::{UCHAR, ULONG}; +STRUCT!{struct VIDEOPARAMETERS { + Guid: GUID, + dwOffset: ULONG, + dwCommand: ULONG, + dwFlags: ULONG, + dwMode: ULONG, + dwTVStandard: ULONG, + dwAvailableModes: ULONG, + dwAvailableTVStandard: ULONG, + dwFlickerFilter: ULONG, + dwOverScanX: ULONG, + dwOverScanY: ULONG, + dwMaxUnscaledX: ULONG, + dwMaxUnscaledY: ULONG, + dwPositionX: ULONG, + dwPositionY: ULONG, + dwBrightness: ULONG, + dwContrast: ULONG, + dwCPType: ULONG, + dwCPCommand: ULONG, + dwCPStandard: ULONG, + dwCPKey: ULONG, + bCP_APSTriggerBits: ULONG, + bOEMCopyProtection: [UCHAR; 256], +}} +pub type PVIDEOPARAMETERS = *mut VIDEOPARAMETERS; +pub type LPVIDEOPARAMETERS = *mut VIDEOPARAMETERS; +pub const VP_COMMAND_GET: ULONG = 0x0001; +pub const VP_COMMAND_SET: ULONG = 0x0002; +pub const VP_FLAGS_TV_MODE: ULONG = 0x0001; +pub const VP_FLAGS_TV_STANDARD: ULONG = 0x0002; +pub const VP_FLAGS_FLICKER: ULONG = 0x0004; +pub const VP_FLAGS_OVERSCAN: ULONG = 0x0008; +pub const VP_FLAGS_MAX_UNSCALED: ULONG = 0x0010; +pub const VP_FLAGS_POSITION: ULONG = 0x0020; +pub const VP_FLAGS_BRIGHTNESS: ULONG = 0x0040; +pub const VP_FLAGS_CONTRAST: ULONG = 0x0080; +pub const VP_FLAGS_COPYPROTECT: ULONG = 0x0100; +pub const VP_MODE_WIN_GRAPHICS: ULONG = 0x0001; +pub const VP_MODE_TV_PLAYBACK: ULONG = 0x0002; +pub const VP_TV_STANDARD_NTSC_M: ULONG = 0x0001; +pub const VP_TV_STANDARD_NTSC_M_J: ULONG = 0x0002; +pub const VP_TV_STANDARD_PAL_B: ULONG = 0x0004; +pub const VP_TV_STANDARD_PAL_D: ULONG = 0x0008; +pub const VP_TV_STANDARD_PAL_H: ULONG = 0x0010; +pub const VP_TV_STANDARD_PAL_I: ULONG = 0x0020; +pub const VP_TV_STANDARD_PAL_M: ULONG = 0x0040; +pub const VP_TV_STANDARD_PAL_N: ULONG = 0x0080; +pub const VP_TV_STANDARD_SECAM_B: ULONG = 0x0100; +pub const VP_TV_STANDARD_SECAM_D: ULONG = 0x0200; +pub const VP_TV_STANDARD_SECAM_G: ULONG = 0x0400; +pub const VP_TV_STANDARD_SECAM_H: ULONG = 0x0800; +pub const VP_TV_STANDARD_SECAM_K: ULONG = 0x1000; +pub const VP_TV_STANDARD_SECAM_K1: ULONG = 0x2000; +pub const VP_TV_STANDARD_SECAM_L: ULONG = 0x4000; +pub const VP_TV_STANDARD_WIN_VGA: ULONG = 0x8000; +pub const VP_TV_STANDARD_NTSC_433: ULONG = 0x00010000; +pub const VP_TV_STANDARD_PAL_G: ULONG = 0x00020000; +pub const VP_TV_STANDARD_PAL_60: ULONG = 0x00040000; +pub const VP_TV_STANDARD_SECAM_L1: ULONG = 0x00080000; +pub const VP_CP_TYPE_APS_TRIGGER: ULONG = 0x0001; +pub const VP_CP_TYPE_MACROVISION: ULONG = 0x0002; +pub const VP_CP_CMD_ACTIVATE: ULONG = 0x0001; +pub const VP_CP_CMD_DEACTIVATE: ULONG = 0x0002; +pub const VP_CP_CMD_CHANGE: ULONG = 0x0004; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/usb.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/usb.rs new file mode 100644 index 0000000..f6bd3b7 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/usb.rs @@ -0,0 +1,523 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! USB Definitions. +use shared::minwindef::{UCHAR, ULONG, USHORT}; +use shared::usbspec::{ + PUSB_CONFIGURATION_DESCRIPTOR, USB_DEVICE_DESCRIPTOR, USB_ENDPOINT_DIRECTION_MASK, +}; +use um::winnt::{LONG, PVOID, WCHAR}; +pub type PRIP = PVOID; +pub type PMDL = PVOID; +pub const USBDI_VERSION: ULONG = 0x00000600; +pub const USB_PORTATTR_NO_CONNECTOR: ULONG = 0x00000001; +pub const USB_PORTATTR_SHARED_USB2: ULONG = 0x00000002; +pub const USB_PORTATTR_MINI_CONNECTOR: ULONG = 0x00000004; +pub const USB_PORTATTR_OEM_CONNECTOR: ULONG = 0x00000008; +pub const USB_PORTATTR_OWNED_BY_CC: ULONG = 0x01000000; +pub const USB_PORTATTR_NO_OVERCURRENT_UI: ULONG = 0x02000000; +ENUM!{enum USB_CONTROLLER_FLAVOR { + USB_HcGeneric = 0, + OHCI_Generic = 100, + OHCI_Hydra, + OHCI_NEC, + UHCI_Generic = 200, + UHCI_Piix4 = 201, + UHCI_Piix3 = 202, + UHCI_Ich2 = 203, + UHCI_Reserved204 = 204, + UHCI_Ich1 = 205, + UHCI_Ich3m = 206, + UHCI_Ich4 = 207, + UHCI_Ich5 = 208, + UHCI_Ich6 = 209, + UHCI_Intel = 249, + UHCI_VIA = 250, + UHCI_VIA_x01 = 251, + UHCI_VIA_x02 = 252, + UHCI_VIA_x03 = 253, + UHCI_VIA_x04 = 254, + UHCI_VIA_x0E_FIFO = 264, + EHCI_Generic = 1000, + EHCI_NEC = 2000, + EHCI_Lucent = 3000, + EHCI_NVIDIA_Tegra2 = 4000, + EHCI_NVIDIA_Tegra3 = 4001, + EHCI_Intel_Medfield = 5001, +}} +pub const USB_DEFAULT_DEVICE_ADDRESS: UCHAR = 0; +pub const USB_DEFAULT_ENDPOINT_ADDRESS: UCHAR = 0; +pub const USB_DEFAULT_MAX_PACKET: USHORT = 64; +pub const URB_FUNCTION_SELECT_CONFIGURATION: USHORT = 0x0000; +pub const URB_FUNCTION_SELECT_INTERFACE: USHORT = 0x0001; +pub const URB_FUNCTION_ABORT_PIPE: USHORT = 0x0002; +pub const URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL: USHORT = 0x0003; +pub const URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL: USHORT = 0x0004; +pub const URB_FUNCTION_GET_FRAME_LENGTH: USHORT = 0x0005; +pub const URB_FUNCTION_SET_FRAME_LENGTH: USHORT = 0x0006; +pub const URB_FUNCTION_GET_CURRENT_FRAME_NUMBER: USHORT = 0x0007; +pub const URB_FUNCTION_CONTROL_TRANSFER: USHORT = 0x0008; +pub const URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: USHORT = 0x0009; +pub const URB_FUNCTION_ISOCH_TRANSFER: USHORT = 0x000A; +pub const URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE: USHORT = 0x000B; +pub const URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE: USHORT = 0x000C; +pub const URB_FUNCTION_SET_FEATURE_TO_DEVICE: USHORT = 0x000D; +pub const URB_FUNCTION_SET_FEATURE_TO_INTERFACE: USHORT = 0x000E; +pub const URB_FUNCTION_SET_FEATURE_TO_ENDPOINT: USHORT = 0x000F; +pub const URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE: USHORT = 0x0010; +pub const URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE: USHORT = 0x0011; +pub const URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT: USHORT = 0x0012; +pub const URB_FUNCTION_GET_STATUS_FROM_DEVICE: USHORT = 0x0013; +pub const URB_FUNCTION_GET_STATUS_FROM_INTERFACE: USHORT = 0x0014; +pub const URB_FUNCTION_GET_STATUS_FROM_ENDPOINT: USHORT = 0x0015; +pub const URB_FUNCTION_RESERVED_0X0016: USHORT = 0x0016; +pub const URB_FUNCTION_VENDOR_DEVICE: USHORT = 0x0017; +pub const URB_FUNCTION_VENDOR_INTERFACE: USHORT = 0x0018; +pub const URB_FUNCTION_VENDOR_ENDPOINT: USHORT = 0x0019; +pub const URB_FUNCTION_CLASS_DEVICE: USHORT = 0x001A; +pub const URB_FUNCTION_CLASS_INTERFACE: USHORT = 0x001B; +pub const URB_FUNCTION_CLASS_ENDPOINT: USHORT = 0x001C; +pub const URB_FUNCTION_RESERVE_0X001D: USHORT = 0x001D; +pub const URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL: USHORT = 0x001E; +pub const URB_FUNCTION_CLASS_OTHER: USHORT = 0x001F; +pub const URB_FUNCTION_VENDOR_OTHER: USHORT = 0x0020; +pub const URB_FUNCTION_GET_STATUS_FROM_OTHER: USHORT = 0x0021; +pub const URB_FUNCTION_CLEAR_FEATURE_TO_OTHER: USHORT = 0x0022; +pub const URB_FUNCTION_SET_FEATURE_TO_OTHER: USHORT = 0x0023; +pub const URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT: USHORT = 0x0024; +pub const URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT: USHORT = 0x0025; +pub const URB_FUNCTION_GET_CONFIGURATION: USHORT = 0x0026; +pub const URB_FUNCTION_GET_INTERFACE: USHORT = 0x0027; +pub const URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE: USHORT = 0x0028; +pub const URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE: USHORT = 0x0029; +pub const URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR: USHORT = 0x002A; +pub const URB_FUNCTION_SYNC_RESET_PIPE: USHORT = 0x0030; +pub const URB_FUNCTION_SYNC_CLEAR_STALL: USHORT = 0x0031; +pub const URB_FUNCTION_CONTROL_TRANSFER_EX: USHORT = 0x0032; +pub const URB_FUNCTION_RESERVE_0X0033: USHORT = 0x0033; +pub const URB_FUNCTION_RESERVE_0X0034: USHORT = 0x0034; +pub const URB_FUNCTION_OPEN_STATIC_STREAMS: USHORT = 0x0035; +pub const URB_FUNCTION_CLOSE_STATIC_STREAMS: USHORT = 0x0036; +pub const URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER_USING_CHAINED_MDL: USHORT = 0x0037; +pub const URB_FUNCTION_ISOCH_TRANSFER_USING_CHAINED_MDL: USHORT = 0x0038; +pub const URB_FUNCTION_RESERVE_0X002B: USHORT = 0x002B; +pub const URB_FUNCTION_RESERVE_0X002C: USHORT = 0x002C; +pub const URB_FUNCTION_RESERVE_0X002D: USHORT = 0x002D; +pub const URB_FUNCTION_RESERVE_0X002E: USHORT = 0x002E; +pub const URB_FUNCTION_RESERVE_0X002F: USHORT = 0x002F; +pub const URB_FUNCTION_RESET_PIPE: USHORT = URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL; +pub const USBD_SHORT_TRANSFER_OK: ULONG = 0x00000002; +pub const USBD_START_ISO_TRANSFER_ASAP: ULONG = 0x00000004; +pub const USBD_DEFAULT_PIPE_TRANSFER: ULONG = 0x00000008; +pub const USBD_TRANSFER_DIRECTION_OUT: ULONG = 0; +pub const USBD_TRANSFER_DIRECTION_IN: ULONG = 1; +pub const USBD_TRANSFER_DIRECTION: ULONG = USBD_TRANSFER_DIRECTION_IN; +#[inline] +pub fn USBD_TRANSFER_DIRECTION_FLAG(flags: ULONG) -> ULONG { + flags & USBD_TRANSFER_DIRECTION +} +pub const VALID_TRANSFER_FLAGS_MASK: ULONG = USBD_SHORT_TRANSFER_OK | USBD_TRANSFER_DIRECTION + | USBD_START_ISO_TRANSFER_ASAP | USBD_DEFAULT_PIPE_TRANSFER; +pub const USBD_ISO_START_FRAME_RANGE: ULONG = 1024; +pub type USBD_STATUS = LONG; +#[inline] +pub fn USBD_SUCCESS(Status: USBD_STATUS) -> bool { + Status >= 0 +} +#[inline] +pub fn USBD_PENDING(Status: ULONG) -> bool { + (Status >> 30) == 1 +} +pub const USBD_STATUS_SUCCESS: USBD_STATUS = 0x00000000; +pub const USBD_STATUS_PORT_OPERATION_PENDING: USBD_STATUS = 0x00000001; +pub const USBD_STATUS_PENDING: USBD_STATUS = 0x40000000; +pub const USBD_STATUS_CRC: USBD_STATUS = 0xC0000001; +pub const USBD_STATUS_BTSTUFF: USBD_STATUS = 0xC0000002; +pub const USBD_STATUS_DATA_TOGGLE_MISMATCH: USBD_STATUS = 0xC0000003; +pub const USBD_STATUS_STALL_PID: USBD_STATUS = 0xC0000004; +pub const USBD_STATUS_DEV_NOT_RESPONDING: USBD_STATUS = 0xC0000005; +pub const USBD_STATUS_PID_CHECK_FAILURE: USBD_STATUS = 0xC0000006; +pub const USBD_STATUS_UNEXPECTED_PID: USBD_STATUS = 0xC0000007; +pub const USBD_STATUS_DATA_OVERRUN: USBD_STATUS = 0xC0000008; +pub const USBD_STATUS_DATA_UNDERRUN: USBD_STATUS = 0xC0000009; +pub const USBD_STATUS_RESERVED1: USBD_STATUS = 0xC000000A; +pub const USBD_STATUS_RESERVED2: USBD_STATUS = 0xC000000B; +pub const USBD_STATUS_BUFFER_OVERRUN: USBD_STATUS = 0xC000000C; +pub const USBD_STATUS_BUFFER_UNDERRUN: USBD_STATUS = 0xC000000D; +pub const USBD_STATUS_NOT_ACCESSED: USBD_STATUS = 0xC000000F; +pub const USBD_STATUS_FIFO: USBD_STATUS = 0xC0000010; +pub const USBD_STATUS_XACT_ERROR: USBD_STATUS = 0xC0000011; +pub const USBD_STATUS_BABBLE_DETECTED: USBD_STATUS = 0xC0000012; +pub const USBD_STATUS_DATA_BUFFER_ERROR: USBD_STATUS = 0xC0000013; +pub const USBD_STATUS_NO_PING_RESPONSE: USBD_STATUS = 0xC0000014; +pub const USBD_STATUS_INVALID_STREAM_TYPE: USBD_STATUS = 0xC0000015; +pub const USBD_STATUS_INVALID_STREAM_ID: USBD_STATUS = 0xC0000016; +pub const USBD_STATUS_ENDPOINT_HALTED: USBD_STATUS = 0xC0000030; +pub const USBD_STATUS_INVALID_URB_FUNCTION: USBD_STATUS = 0x80000200; +pub const USBD_STATUS_INVALID_PARAMETER: USBD_STATUS = 0x80000300; +pub const USBD_STATUS_ERROR_BUSY: USBD_STATUS = 0x80000400; +pub const USBD_STATUS_INVALID_PIPE_HANDLE: USBD_STATUS = 0x80000600; +pub const USBD_STATUS_NO_BANDWIDTH: USBD_STATUS = 0x80000700; +pub const USBD_STATUS_INTERNAL_HC_ERROR: USBD_STATUS = 0x80000800; +pub const USBD_STATUS_ERROR_SHORT_TRANSFER: USBD_STATUS = 0x80000900; +pub const USBD_STATUS_BAD_START_FRAME: USBD_STATUS = 0xC0000A00; +pub const USBD_STATUS_ISOCH_REQUEST_FAILED: USBD_STATUS = 0xC0000B00; +pub const USBD_STATUS_FRAME_CONTROL_OWNED: USBD_STATUS = 0xC0000C00; +pub const USBD_STATUS_FRAME_CONTROL_NOT_OWNED: USBD_STATUS = 0xC0000D00; +pub const USBD_STATUS_NOT_SUPPORTED: USBD_STATUS = 0xC0000E00; +pub const USBD_STATUS_INAVLID_CONFIGURATION_DESCRIPTOR: USBD_STATUS = 0xC0000F00; +pub const USBD_STATUS_INVALID_CONFIGURATION_DESCRIPTOR: USBD_STATUS = 0xC0000F00; +pub const USBD_STATUS_INSUFFICIENT_RESOURCES: USBD_STATUS = 0xC0001000; +pub const USBD_STATUS_SET_CONFIG_FAILED: USBD_STATUS = 0xC0002000; +pub const USBD_STATUS_BUFFER_TOO_SMALL: USBD_STATUS = 0xC0003000; +pub const USBD_STATUS_INTERFACE_NOT_FOUND: USBD_STATUS = 0xC0004000; +pub const USBD_STATUS_INAVLID_PIPE_FLAGS: USBD_STATUS = 0xC0005000; +pub const USBD_STATUS_TIMEOUT: USBD_STATUS = 0xC0006000; +pub const USBD_STATUS_DEVICE_GONE: USBD_STATUS = 0xC0007000; +pub const USBD_STATUS_STATUS_NOT_MAPPED: USBD_STATUS = 0xC0008000; +pub const USBD_STATUS_HUB_INTERNAL_ERROR: USBD_STATUS = 0xC0009000; +pub const USBD_STATUS_CANCELED: USBD_STATUS = 0xC0010000; +pub const USBD_STATUS_ISO_NOT_ACCESSED_BY_HW: USBD_STATUS = 0xC0020000; +pub const USBD_STATUS_ISO_TD_ERROR: USBD_STATUS = 0xC0030000; +pub const USBD_STATUS_ISO_NA_LATE_USBPORT: USBD_STATUS = 0xC0040000; +pub const USBD_STATUS_ISO_NOT_ACCESSED_LATE: USBD_STATUS = 0xC0050000; +pub const USBD_STATUS_BAD_DESCRIPTOR: USBD_STATUS = 0xC0100000; +pub const USBD_STATUS_BAD_DESCRIPTOR_BLEN: USBD_STATUS = 0xC0100001; +pub const USBD_STATUS_BAD_DESCRIPTOR_TYPE: USBD_STATUS = 0xC0100002; +pub const USBD_STATUS_BAD_INTERFACE_DESCRIPTOR: USBD_STATUS = 0xC0100003; +pub const USBD_STATUS_BAD_ENDPOINT_DESCRIPTOR: USBD_STATUS = 0xC0100004; +pub const USBD_STATUS_BAD_INTERFACE_ASSOC_DESCRIPTOR: USBD_STATUS = 0xC0100005; +pub const USBD_STATUS_BAD_CONFIG_DESC_LENGTH: USBD_STATUS = 0xC0100006; +pub const USBD_STATUS_BAD_NUMBER_OF_INTERFACES: USBD_STATUS = 0xC0100007; +pub const USBD_STATUS_BAD_NUMBER_OF_ENDPOINTS: USBD_STATUS = 0xC0100008; +pub const USBD_STATUS_BAD_ENDPOINT_ADDRESS: USBD_STATUS = 0xC0100009; +pub type USBD_PIPE_HANDLE = PVOID; +pub type USBD_CONFIGURATION_HANDLE = PVOID; +pub type USBD_INTERFACE_HANDLE = PVOID; +pub const USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE: ULONG = 0xFFFFFFFF; +STRUCT!{struct USBD_VERSION_INFORMATION { + USBDI_Version: ULONG, + Supported_USB_Version: ULONG, +}} +pub type PUSBD_VERSION_INFORMATION = *mut USBD_VERSION_INFORMATION; +ENUM!{enum USBD_PIPE_TYPE { + UsbdPipeTypeControl, + UsbdPipeTypeIsochronous, + UsbdPipeTypeBulk, + UsbdPipeTypeInterrupt, +}} +#[inline] +pub fn USBD_PIPE_DIRECTION_IN(pipeInformation: &USBD_PIPE_INFORMATION) -> UCHAR { + pipeInformation.EndpointAddress & USB_ENDPOINT_DIRECTION_MASK +} +STRUCT!{struct USBD_DEVICE_INFORMATION { + OffsetNext: ULONG, + UsbdDeviceHandle: PVOID, + DeviceDescriptor: USB_DEVICE_DESCRIPTOR, +}} +pub type PUSBD_DEVICE_INFORMATION = *mut USBD_DEVICE_INFORMATION; +STRUCT!{struct USBD_PIPE_INFORMATION { + MaximumPacketSize: USHORT, + EndpointAddress: UCHAR, + Interval: UCHAR, + PipeType: USBD_PIPE_TYPE, + PipeHandle: USBD_PIPE_HANDLE, + MaximumTransferSize: ULONG, + PipeFlags: ULONG, +}} +pub type PUSBD_PIPE_INFORMATION = *mut USBD_PIPE_INFORMATION; +pub const USBD_PF_CHANGE_MAX_PACKET: ULONG = 0x00000001; +pub const USBD_PF_SHORT_PACKET_OPT: ULONG = 0x00000002; +pub const USBD_PF_ENABLE_RT_THREAD_ACCESS: ULONG = 0x00000004; +pub const USBD_PF_MAP_ADD_TRANSFERS: ULONG = 0x00000008; +pub const USBD_PF_VALID_MASK: ULONG = USBD_PF_CHANGE_MAX_PACKET | USBD_PF_SHORT_PACKET_OPT + | USBD_PF_ENABLE_RT_THREAD_ACCESS | USBD_PF_MAP_ADD_TRANSFERS; +STRUCT!{struct USBD_INTERFACE_INFORMATION { + Length: USHORT, + InterfaceNumber: UCHAR, + AlternateSetting: UCHAR, + Class: UCHAR, + SubClass: UCHAR, + Protocol: UCHAR, + Reserved: UCHAR, + InterfaceHandle: USBD_INTERFACE_HANDLE, + NumberOfPipes: ULONG, + Pipes: [USBD_PIPE_INFORMATION; 1], +}} +pub type PUSBD_INTERFACE_INFORMATION = *mut USBD_INTERFACE_INFORMATION; +STRUCT!{struct URB_HCD_AREA { + Reserved8: [PVOID; 8], +}} +STRUCT!{struct URB_HEADER { + Length: USHORT, + Function: USHORT, + Status: USBD_STATUS, + UsbdDeviceHandle: PVOID, + UsbdFlags: ULONG, +}} +STRUCT!{struct URB_SELECT_INTERFACE { + Hdr: URB_HEADER, + ConfigurationHandle: USBD_CONFIGURATION_HANDLE, + Interface: USBD_INTERFACE_INFORMATION, +}} +STRUCT!{struct URB_SELECT_CONFIGURATION { + Hdr: URB_HEADER, + ConfigurationDescriptor: PUSB_CONFIGURATION_DESCRIPTOR, + ConfigurationHandle: USBD_CONFIGURATION_HANDLE, + Interface: USBD_INTERFACE_INFORMATION, +}} +STRUCT!{struct URB_PIPE_REQUEST { + Hdr: URB_HEADER, + PipeHandle: USBD_PIPE_HANDLE, + Reserved: ULONG, +}} +STRUCT!{struct URB_FRAME_LENGTH_CONTROL { + Hdr: URB_HEADER, +}} +STRUCT!{struct URB_GET_FRAME_LENGTH { + Hdr: URB_HEADER, + FrameLength: ULONG, + FrameNumber: ULONG, +}} +STRUCT!{struct URB_SET_FRAME_LENGTH { + Hdr: URB_HEADER, + FrameLengthDelta: LONG, +}} +STRUCT!{struct URB_GET_CURRENT_FRAME_NUMBER { + Hdr: URB_HEADER, + FrameNumber: ULONG, +}} +STRUCT!{struct URB_CONTROL_DESCRIPTOR_REQUEST { + Hdr: URB_HEADER, + Reserved: PVOID, + Reserved0: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + UrbLink: *mut URB, + hca: URB_HCD_AREA, + Reserved1: USHORT, + Index: UCHAR, + DescriptorType: UCHAR, + LanguageId: USHORT, + Reserved2: USHORT, +}} +STRUCT!{struct URB_CONTROL_GET_STATUS_REQUEST { + Hdr: URB_HEADER, + Reserved: PVOID, + Reserved0: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + UrbLink: *mut URB, + hca: URB_HCD_AREA, + Reserved1: [UCHAR; 4], + Index: USHORT, + Reserved2: USHORT, +}} +STRUCT!{struct URB_CONTROL_FEATURE_REQUEST { + Hdr: URB_HEADER, + Reserved: PVOID, + Reserved2: ULONG, + Reserved3: ULONG, + Reserved4: PVOID, + Reserved5: PMDL, + UrbLink: *mut URB, + hca: URB_HCD_AREA, + Reserved0: USHORT, + FeatureSelector: USHORT, + Index: USHORT, + Reserved1: USHORT, +}} +STRUCT!{struct URB_CONTROL_VENDOR_OR_CLASS_REQUEST { + Hdr: URB_HEADER, + Reserved: PVOID, + TransferFlags: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + UrbLink: *mut URB, + hca: URB_HCD_AREA, + RequestTypeReservedBits: UCHAR, + Request: UCHAR, + Value: USHORT, + Index: USHORT, + Reserved1: USHORT, +}} +STRUCT!{struct URB_CONTROL_GET_INTERFACE_REQUEST { + Hdr: URB_HEADER, + Reserved: PVOID, + Reserved0: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + UrbLink: *mut URB, + hca: URB_HCD_AREA, + Reserved1: [UCHAR; 4], + Interface: USHORT, + Reserved2: USHORT, +}} +STRUCT!{struct URB_CONTROL_GET_CONFIGURATION_REQUEST { + Hdr: URB_HEADER, + Reserved: PVOID, + Reserved0: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + UrbLink: *mut URB, + hca: URB_HCD_AREA, + Reserved1: [UCHAR; 8], +}} +pub const OS_STRING_DESCRIPTOR_INDEX: UCHAR = 0xEE; +pub const MS_GENRE_DESCRIPTOR_INDEX: USHORT = 0x0001; +pub const MS_POWER_DESCRIPTOR_INDEX: USHORT = 0x0002; +pub const MS_OS_STRING_SIGNATURE: &'static str = "MSFT100"; +pub const MS_OS_FLAGS_CONTAINERID: UCHAR = 0x02; +UNION!{union OS_STRING_u { + [u8; 1], + bPad bPad_mut: UCHAR, + bFlags bFlags_mut: UCHAR, +}} +STRUCT!{struct OS_STRING { + bLength: UCHAR, + bDescriptorType: UCHAR, + MicrosoftString: [WCHAR; 7], + bVendorCode: UCHAR, + u: OS_STRING_u, +}} +pub type POS_STRING = *mut OS_STRING; +STRUCT!{struct URB_OS_FEATURE_DESCRIPTOR_REQUEST { + Hdr: URB_HEADER, + Reserved: PVOID, + Reserved0: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + UrbLink: *mut URB, + hca: URB_HCD_AREA, + BitField: UCHAR, + Reserved2: UCHAR, + InterfaceNumber: UCHAR, + MS_PageIndex: UCHAR, + MS_FeatureDescriptorIndex: USHORT, + Reserved3: USHORT, +}} +BITFIELD!{URB_OS_FEATURE_DESCRIPTOR_REQUEST BitField: UCHAR [ + Recipient set_Recipient[0..5], + Reserved1 set_Reserved1[5..8], +]} +STRUCT!{struct URB_CONTROL_TRANSFER { + Hdr: URB_HEADER, + PipeHandle: USBD_PIPE_HANDLE, + TransferFlags: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + UrbLink: *mut URB, + hca: URB_HCD_AREA, + SetupPacket: [UCHAR; 8], +}} +#[cfg(target_pointer_width = "64")] +STRUCT!{struct URB_CONTROL_TRANSFER_EX { + Hdr: URB_HEADER, + PipeHandle: USBD_PIPE_HANDLE, + TransferFlags: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + Timeout: ULONG, + Pad: ULONG, + hca: URB_HCD_AREA, + SetupPacket: [UCHAR; 8], +}} +#[cfg(target_pointer_width = "32")] +STRUCT!{struct URB_CONTROL_TRANSFER_EX { + Hdr: URB_HEADER, + PipeHandle: USBD_PIPE_HANDLE, + TransferFlags: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + Timeout: ULONG, + hca: URB_HCD_AREA, + SetupPacket: [UCHAR; 8], +}} +STRUCT!{struct URB_BULK_OR_INTERRUPT_TRANSFER { + Hdr: URB_HEADER, + PipeHandle: USBD_PIPE_HANDLE, + TransferFlags: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + UrbLink: *mut URB, + hca: URB_HCD_AREA, +}} +STRUCT!{struct USBD_ISO_PACKET_DESCRIPTOR { + Offset: ULONG, + Length: ULONG, + Status: USBD_STATUS, +}} +pub type PUSBD_ISO_PACKET_DESCRIPTOR = *mut USBD_ISO_PACKET_DESCRIPTOR; +STRUCT!{struct URB_ISOCH_TRANSFER { + Hdr: URB_HEADER, + PipeHandle: USBD_PIPE_HANDLE, + TransferFlags: ULONG, + TransferBufferLength: ULONG, + TransferBuffer: PVOID, + TransferBufferMDL: PMDL, + UrbLink: *mut URB, + hca: URB_HCD_AREA, + StartFrame: ULONG, + NumberOfPackets: ULONG, + ErrorCount: ULONG, + IsoPacket: [USBD_ISO_PACKET_DESCRIPTOR; 1], +}} +pub const URB_OPEN_STATIC_STREAMS_VERSION_100: USHORT = 0x100; +STRUCT!{struct USBD_STREAM_INFORMATION { + PipeHandle: USBD_PIPE_HANDLE, + StreamID: ULONG, + MaximumTransferSize: ULONG, + PipeFlags: ULONG, +}} +pub type PUSBD_STREAM_INFORMATION = *mut USBD_STREAM_INFORMATION; +STRUCT!{struct URB_OPEN_STATIC_STREAMS { + Hdr: URB_HEADER, + PipeHandle: USBD_PIPE_HANDLE, + NumberOfStreams: ULONG, + StreamInfoVersion: USHORT, + StreamInfoSize: USHORT, + Streams: PUSBD_STREAM_INFORMATION, +}} +UNION!{union URB_u { + [u32; 24] [u64; 19], + UrbHeader UrbHeader_mut: URB_HEADER, + UrbSelectInterface UrbSelectInterface_mut: URB_SELECT_INTERFACE, + UrbSelectConfiguration UrbSelectConfiguration_mut: URB_SELECT_CONFIGURATION, + UrbPipeRequest UrbPipeRequest_mut: URB_PIPE_REQUEST, + UrbFrameLengthControl UrbFrameLengthControl_mut: URB_FRAME_LENGTH_CONTROL, + UrbGetFrameLength UrbGetFrameLength_mut: URB_GET_FRAME_LENGTH, + UrbSetFrameLength UrbSetFrameLength_mut: URB_SET_FRAME_LENGTH, + UrbGetCurrentFrameNumber UrbGetCurrentFrameNumber_mut: URB_GET_CURRENT_FRAME_NUMBER, + UrbControlTransfer UrbControlTransfer_mut: URB_CONTROL_TRANSFER, + UrbControlTransferEx UrbControlTransferEx_mut: URB_CONTROL_TRANSFER_EX, + UrbBulkOrInterruptTransfer UrbBulkOrInterruptTransfer_mut: URB_BULK_OR_INTERRUPT_TRANSFER, + UrbIsochronousTransfer UrbIsochronousTransfer_mut: URB_ISOCH_TRANSFER, + UrbControlDescriptorRequest UrbControlDescriptorRequest_mut: URB_CONTROL_DESCRIPTOR_REQUEST, + UrbControlGetStatusRequest UrbControlGetStatusRequest_mut: URB_CONTROL_GET_STATUS_REQUEST, + UrbControlFeatureRequest UrbControlFeatureRequest_mut: URB_CONTROL_FEATURE_REQUEST, + UrbControlVendorClassRequest UrbControlVendorClassRequest_mut: + URB_CONTROL_VENDOR_OR_CLASS_REQUEST, + UrbControlGetInterfaceRequest UrbControlGetInterfaceRequest_mut: + URB_CONTROL_GET_INTERFACE_REQUEST, + UrbControlGetConfigurationRequest UrbControlGetConfigurationRequest_mut: + URB_CONTROL_GET_CONFIGURATION_REQUEST, + UrbOSFeatureDescriptorRequest UrbOSFeatureDescriptorRequest_mut: + URB_OS_FEATURE_DESCRIPTOR_REQUEST, + UrbOpenStaticStreams UrbOpenStaticStreams_mut: URB_OPEN_STATIC_STREAMS, +}} +STRUCT!{struct URB { + u: URB_u, +}} +pub type PURB = *mut URB; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/usbiodef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/usbiodef.rs new file mode 100644 index 0000000..e9028c6 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/usbiodef.rs @@ -0,0 +1,112 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! Common header file for all USB IOCTLs defined for +//! the core stack. We define them in this single header file +//! so that we can maintain backward compatibilty with older +//! versions of the stack. +use shared::guiddef::GUID; +use shared::minwindef::ULONG; +use um::winioctl::{FILE_ANY_ACCESS, FILE_DEVICE_UNKNOWN, METHOD_BUFFERED, METHOD_NEITHER}; +use um::winnt::PVOID; +pub const USB_SUBMIT_URB: ULONG = 0; +pub const USB_RESET_PORT: ULONG = 1; +pub const USB_GET_ROOTHUB_PDO: ULONG = 3; +pub const USB_GET_PORT_STATUS: ULONG = 4; +pub const USB_ENABLE_PORT: ULONG = 5; +pub const USB_GET_HUB_COUNT: ULONG = 6; +pub const USB_CYCLE_PORT: ULONG = 7; +pub const USB_GET_HUB_NAME: ULONG = 8; +pub const USB_IDLE_NOTIFICATION: ULONG = 9; +pub const USB_RECORD_FAILURE: ULONG = 10; +pub const USB_GET_BUS_INFO: ULONG = 264; +pub const USB_GET_CONTROLLER_NAME: ULONG = 265; +pub const USB_GET_BUSGUID_INFO: ULONG = 266; +pub const USB_GET_PARENT_HUB_INFO: ULONG = 267; +pub const USB_GET_DEVICE_HANDLE: ULONG = 268; +pub const USB_GET_DEVICE_HANDLE_EX: ULONG = 269; +pub const USB_GET_TT_DEVICE_HANDLE: ULONG = 270; +pub const USB_GET_TOPOLOGY_ADDRESS: ULONG = 271; +pub const USB_IDLE_NOTIFICATION_EX: ULONG = 272; +pub const USB_REQ_GLOBAL_SUSPEND: ULONG = 273; +pub const USB_REQ_GLOBAL_RESUME: ULONG = 274; +pub const USB_GET_HUB_CONFIG_INFO: ULONG = 275; +pub const USB_FAIL_GET_STATUS: ULONG = 280; +pub const USB_REGISTER_COMPOSITE_DEVICE: ULONG = 0; +pub const USB_UNREGISTER_COMPOSITE_DEVICE: ULONG = 1; +pub const USB_REQUEST_REMOTE_WAKE_NOTIFICATION: ULONG = 2; +pub const HCD_GET_STATS_1: ULONG = 255; +pub const HCD_DIAGNOSTIC_MODE_ON: ULONG = 256; +pub const HCD_DIAGNOSTIC_MODE_OFF: ULONG = 257; +pub const HCD_GET_ROOT_HUB_NAME: ULONG = 258; +pub const HCD_GET_DRIVERKEY_NAME: ULONG = 265; +pub const HCD_GET_STATS_2: ULONG = 266; +pub const HCD_DISABLE_PORT: ULONG = 268; +pub const HCD_ENABLE_PORT: ULONG = 269; +pub const HCD_USER_REQUEST: ULONG = 270; +pub const HCD_TRACE_READ_REQUEST: ULONG = 275; +pub const USB_GET_NODE_INFORMATION: ULONG = 258; +pub const USB_GET_NODE_CONNECTION_INFORMATION: ULONG = 259; +pub const USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION: ULONG = 260; +pub const USB_GET_NODE_CONNECTION_NAME: ULONG = 261; +pub const USB_DIAG_IGNORE_HUBS_ON: ULONG = 262; +pub const USB_DIAG_IGNORE_HUBS_OFF: ULONG = 263; +pub const USB_GET_NODE_CONNECTION_DRIVERKEY_NAME: ULONG = 264; +pub const USB_GET_HUB_CAPABILITIES: ULONG = 271; +pub const USB_GET_NODE_CONNECTION_ATTRIBUTES: ULONG = 272; +pub const USB_HUB_CYCLE_PORT: ULONG = 273; +pub const USB_GET_NODE_CONNECTION_INFORMATION_EX: ULONG = 274; +pub const USB_RESET_HUB: ULONG = 275; +pub const USB_GET_HUB_CAPABILITIES_EX: ULONG = 276; +pub const USB_GET_HUB_INFORMATION_EX: ULONG = 277; +pub const USB_GET_PORT_CONNECTOR_PROPERTIES: ULONG = 278; +pub const USB_GET_NODE_CONNECTION_INFORMATION_EX_V2: ULONG = 279; +DEFINE_GUID!{GUID_DEVINTERFACE_USB_HUB, + 0xf18a0e88, 0xc30c, 0x11d0, 0x88, 0x15, 0x00, 0xa0, 0xc9, 0x06, 0xbe, 0xd8} +DEFINE_GUID!{GUID_DEVINTERFACE_USB_DEVICE, + 0xA5DCBF10, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED} +DEFINE_GUID!{GUID_DEVINTERFACE_USB_HOST_CONTROLLER, + 0x3abf6f2d, 0x71c4, 0x462a, 0x8a, 0x92, 0x1e, 0x68, 0x61, 0xe6, 0xaf, 0x27} +DEFINE_GUID!{GUID_USB_WMI_STD_DATA, + 0x4E623B20, 0xCB14, 0x11D1, 0xB3, 0x31, 0x00, 0xA0, 0xC9, 0x59, 0xBB, 0xD2} +DEFINE_GUID!{GUID_USB_WMI_STD_NOTIFICATION, + 0x4E623B20, 0xCB14, 0x11D1, 0xB3, 0x31, 0x00, 0xA0, 0xC9, 0x59, 0xBB, 0xD2} +DEFINE_GUID!{GUID_USB_WMI_DEVICE_PERF_INFO, + 0x66c1aa3c, 0x499f, 0x49a0, 0xa9, 0xa5, 0x61, 0xe2, 0x35, 0x9f, 0x64, 0x7} +DEFINE_GUID!{GUID_USB_WMI_NODE_INFO, + 0x9c179357, 0xdc7a, 0x4f41, 0xb6, 0x6b, 0x32, 0x3b, 0x9d, 0xdc, 0xb5, 0xb1} +DEFINE_GUID!{GUID_USB_WMI_TRACING, + 0x3a61881b, 0xb4e6, 0x4bf9, 0xae, 0xf, 0x3c, 0xd8, 0xf3, 0x94, 0xe5, 0x2f} +DEFINE_GUID!{GUID_USB_TRANSFER_TRACING, + 0x681eb8aa, 0x403d, 0x452c, 0x9f, 0x8a, 0xf0, 0x61, 0x6f, 0xac, 0x95, 0x40} +DEFINE_GUID!{GUID_USB_PERFORMANCE_TRACING, + 0xd5de77a6, 0x6ae9, 0x425c, 0xb1, 0xe2, 0xf5, 0x61, 0x5f, 0xd3, 0x48, 0xa9} +DEFINE_GUID!{GUID_USB_WMI_SURPRISE_REMOVAL_NOTIFICATION, + 0x9bbbf831, 0xa2f2, 0x43b4, 0x96, 0xd1, 0x86, 0x94, 0x4b, 0x59, 0x14, 0xb3} +pub const GUID_CLASS_USBHUB: GUID = GUID_DEVINTERFACE_USB_HUB; +pub const GUID_CLASS_USB_DEVICE: GUID = GUID_DEVINTERFACE_USB_DEVICE; +pub const GUID_CLASS_USB_HOST_CONTROLLER: GUID = GUID_DEVINTERFACE_USB_HOST_CONTROLLER; +pub const FILE_DEVICE_USB: ULONG = FILE_DEVICE_UNKNOWN; +#[inline] +pub fn USB_CTL(id: ULONG) -> ULONG { + CTL_CODE!(FILE_DEVICE_USB, id, METHOD_BUFFERED, FILE_ANY_ACCESS) +} +#[inline] +pub fn USB_KERNEL_CTL(id: ULONG) -> ULONG { + CTL_CODE!(FILE_DEVICE_USB, id, METHOD_NEITHER, FILE_ANY_ACCESS) +} +#[inline] +pub fn USB_KERNEL_CTL_BUFFERED(id: ULONG) -> ULONG { + CTL_CODE!(FILE_DEVICE_USB, id, METHOD_BUFFERED, FILE_ANY_ACCESS) +} +// No calling convention was specified in the code +FN!{stdcall USB_IDLE_CALLBACK( + Context: PVOID, +) -> ()} +STRUCT!{struct USB_IDLE_CALLBACK_INFO { + IdleCallback: USB_IDLE_CALLBACK, + IdleContext: PVOID, +}} +pub type PUSB_IDLE_CALLBACK_INFO = *mut USB_IDLE_CALLBACK_INFO; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/usbspec.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/usbspec.rs new file mode 100644 index 0000000..5fae43e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/usbspec.rs @@ -0,0 +1,860 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! USB Spec Definitions. +use shared::basetsd::ULONG64; +use shared::guiddef::GUID; +use shared::minwindef::{UCHAR, ULONG, USHORT}; +use um::winnt::WCHAR; +ENUM!{enum USB_DEVICE_SPEED { + UsbLowSpeed = 0, + UsbFullSpeed, + UsbHighSpeed, + UsbSuperSpeed, +}} +ENUM!{enum USB_DEVICE_TYPE { + Usb11Device = 0, + Usb20Device, +}} +STRUCT!{#[repr(packed)] struct BM_REQUEST_TYPE { + B: UCHAR, +}} +BITFIELD!{BM_REQUEST_TYPE B: UCHAR [ + Recipient set_Recipient[0..2], + Reserved set_Reserved[2..5], + Type set_Type[5..7], + Dir set_Dir[7..8], +]} +pub type PBM_REQUEST_TYPE = *mut BM_REQUEST_TYPE; +STRUCT!{#[repr(packed)] struct USB_DEFAULT_PIPE_SETUP_PACKET_wValue_s { + LowByte: UCHAR, + HiByte: UCHAR, +}} +UNION!{#[repr(packed)] union USB_DEFAULT_PIPE_SETUP_PACKET_wValue { + [u16; 1], + s s_mut: USB_DEFAULT_PIPE_SETUP_PACKET_wValue_s, + W W_mut: USHORT, +}} +STRUCT!{#[repr(packed)] struct USB_DEFAULT_PIPE_SETUP_PACKET_wIndex_s { + LowByte: UCHAR, + HiByte: UCHAR, +}} +UNION!{#[repr(packed)] union USB_DEFAULT_PIPE_SETUP_PACKET_wIndex { + [u16; 1], + s s_mut: USB_DEFAULT_PIPE_SETUP_PACKET_wIndex_s, + W W_mut: USHORT, +}} +STRUCT!{#[repr(packed)] struct USB_DEFAULT_PIPE_SETUP_PACKET { + bmRequestType: BM_REQUEST_TYPE, + bRequest: UCHAR, + wValue: USB_DEFAULT_PIPE_SETUP_PACKET_wValue, + wIndex: USB_DEFAULT_PIPE_SETUP_PACKET_wIndex, + wLength: USHORT, +}} +pub type PUSB_DEFAULT_PIPE_SETUP_PACKET = *mut USB_DEFAULT_PIPE_SETUP_PACKET; +pub const BMREQUEST_HOST_TO_DEVICE: UCHAR = 0; +pub const BMREQUEST_DEVICE_TO_HOST: UCHAR = 1; +pub const BMREQUEST_STANDARD: UCHAR = 0; +pub const BMREQUEST_CLASS: UCHAR = 1; +pub const BMREQUEST_VENDOR: UCHAR = 2; +pub const BMREQUEST_TO_DEVICE: UCHAR = 0; +pub const BMREQUEST_TO_INTERFACE: UCHAR = 1; +pub const BMREQUEST_TO_ENDPOINT: UCHAR = 2; +pub const BMREQUEST_TO_OTHER: UCHAR = 3; +#[inline] +pub fn USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d: UCHAR, i: UCHAR) -> USHORT { + (d as USHORT) << 8 | (i as USHORT) +} +pub const USB_REQUEST_GET_STATUS: UCHAR = 0x00; +pub const USB_REQUEST_CLEAR_FEATURE: UCHAR = 0x01; +pub const USB_REQUEST_SET_FEATURE: UCHAR = 0x03; +pub const USB_REQUEST_SET_ADDRESS: UCHAR = 0x05; +pub const USB_REQUEST_GET_DESCRIPTOR: UCHAR = 0x06; +pub const USB_REQUEST_SET_DESCRIPTOR: UCHAR = 0x07; +pub const USB_REQUEST_GET_CONFIGURATION: UCHAR = 0x08; +pub const USB_REQUEST_SET_CONFIGURATION: UCHAR = 0x09; +pub const USB_REQUEST_GET_INTERFACE: UCHAR = 0x0A; +pub const USB_REQUEST_SET_INTERFACE: UCHAR = 0x0B; +pub const USB_REQUEST_SYNC_FRAME: UCHAR = 0x0C; +pub const USB_REQUEST_SET_SEL: UCHAR = 0x30; +pub const USB_REQUEST_ISOCH_DELAY: UCHAR = 0x31; +pub const USB_DEVICE_DESCRIPTOR_TYPE: UCHAR = 0x01; +pub const USB_CONFIGURATION_DESCRIPTOR_TYPE: UCHAR = 0x02; +pub const USB_STRING_DESCRIPTOR_TYPE: UCHAR = 0x03; +pub const USB_INTERFACE_DESCRIPTOR_TYPE: UCHAR = 0x04; +pub const USB_ENDPOINT_DESCRIPTOR_TYPE: UCHAR = 0x05; +pub const USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE: UCHAR = 0x06; +pub const USB_OTHER_SPEED_CONFIGURATION_DESCRIPTOR_TYPE: UCHAR = 0x07; +pub const USB_INTERFACE_POWER_DESCRIPTOR_TYPE: UCHAR = 0x08; +pub const USB_OTG_DESCRIPTOR_TYPE: UCHAR = 0x09; +pub const USB_DEBUG_DESCRIPTOR_TYPE: UCHAR = 0x0A; +pub const USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE: UCHAR = 0x0B; +pub const USB_BOS_DESCRIPTOR_TYPE: UCHAR = 0x0F; +pub const USB_DEVICE_CAPABILITY_DESCRIPTOR_TYPE: UCHAR = 0x10; +pub const USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_TYPE: UCHAR = 0x30; +pub const USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR_TYPE: UCHAR = 0x31; +pub const USB_RESERVED_DESCRIPTOR_TYPE: UCHAR = 0x06; +pub const USB_CONFIG_POWER_DESCRIPTOR_TYPE: UCHAR = 0x07; +pub const USB_FEATURE_ENDPOINT_STALL: UCHAR = 0x00; +pub const USB_FEATURE_REMOTE_WAKEUP: UCHAR = 0x01; +pub const USB_FEATURE_TEST_MODE: UCHAR = 0x02; +pub const USB_FEATURE_FUNCTION_SUSPEND: UCHAR = 0x00; +pub const USB_FEATURE_U1_ENABLE: UCHAR = 0x30; +pub const USB_FEATURE_U2_ENABLE: UCHAR = 0x31; +pub const USB_FEATURE_LTM_ENABLE: UCHAR = 0x32; +pub const USB_FEATURE_LDM_ENABLE: UCHAR = 0x35; +pub const USB_FEATURE_BATTERY_WAKE_MASK: UCHAR = 0x28; +pub const USB_FEATURE_OS_IS_PD_AWARE: UCHAR = 0x29; +pub const USB_FEATURE_POLICY_MODE: UCHAR = 0x2A; +pub const USB_FEATURE_CHARGING_POLICY: UCHAR = 0x36; +pub const USB_CHARGING_POLICY_DEFAULT: UCHAR = 0x00; +pub const USB_CHARGING_POLICY_ICCHPF: UCHAR = 0x01; +pub const USB_CHARGING_POLICY_ICCLPF: UCHAR = 0x02; +pub const USB_CHARGING_POLICY_NO_POWER: UCHAR = 0x03; +pub const USB_STATUS_PORT_STATUS: UCHAR = 0x00; +pub const USB_STATUS_PD_STATUS: UCHAR = 0x01; +pub const USB_STATUS_EXT_PORT_STATUS: UCHAR = 0x02; +pub const USB_GETSTATUS_SELF_POWERED: UCHAR = 0x01; +pub const USB_GETSTATUS_REMOTE_WAKEUP_ENABLED: UCHAR = 0x02; +pub const USB_GETSTATUS_U1_ENABLE: UCHAR = 0x04; +pub const USB_GETSTATUS_U2_ENABLE: UCHAR = 0x08; +pub const USB_GETSTATUS_LTM_ENABLE: UCHAR = 0x10; +STRUCT!{#[repr(packed)] struct USB_DEVICE_STATUS { + AsUshort16: USHORT, +}} +BITFIELD!{USB_DEVICE_STATUS AsUshort16: USHORT [ + SelfPowered set_SelfPowered[0..1], + RemoteWakeup set_RemoteWakeup[1..2], + U1Enable set_U1Enable[2..3], + U2Enable set_U2Enable[3..4], + LtmEnable set_LtmEnable[4..5], + Reserved set_Reserved[5..16], +]} +pub type PUSB_DEVICE_STATUS = *mut USB_DEVICE_STATUS; +STRUCT!{#[repr(packed)] struct USB_INTERFACE_STATUS { + AsUshort16: USHORT, +}} +BITFIELD!{USB_INTERFACE_STATUS AsUshort16: USHORT [ + RemoteWakeupCapable set_RemoteWakeupCapable[0..1], + RemoteWakeupEnabled set_RemoteWakeupEnabled[1..2], + Reserved set_Reserved[2..16], +]} +pub type PUSB_INTERFACE_STATUS = *mut USB_INTERFACE_STATUS; +STRUCT!{#[repr(packed)] struct USB_ENDPOINT_STATUS { + AsUshort16: USHORT, +}} +BITFIELD!{USB_ENDPOINT_STATUS AsUshort16: USHORT [ + Halt set_Halt[0..1], + Reserved set_Reserved[1..16], +]} +pub type PUSB_ENDPOINT_STATUS = *mut USB_ENDPOINT_STATUS; +STRUCT!{#[repr(packed)] struct USB_COMMON_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, +}} +pub type PUSB_COMMON_DESCRIPTOR = *mut USB_COMMON_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_DEVICE_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bcdUSB: USHORT, + bDeviceClass: UCHAR, + bDeviceSubClass: UCHAR, + bDeviceProtocol: UCHAR, + bMaxPacketSize0: UCHAR, + idVendor: USHORT, + idProduct: USHORT, + bcdDevice: USHORT, + iManufacturer: UCHAR, + iProduct: UCHAR, + iSerialNumber: UCHAR, + bNumConfigurations: UCHAR, +}} +pub type PUSB_DEVICE_DESCRIPTOR = *mut USB_DEVICE_DESCRIPTOR; +pub const USB_DEVICE_CLASS_RESERVED: UCHAR = 0x00; +pub const USB_DEVICE_CLASS_AUDIO: UCHAR = 0x01; +pub const USB_DEVICE_CLASS_COMMUNICATIONS: UCHAR = 0x02; +pub const USB_DEVICE_CLASS_HUMAN_INTERFACE: UCHAR = 0x03; +pub const USB_DEVICE_CLASS_MONITOR: UCHAR = 0x04; +pub const USB_DEVICE_CLASS_PHYSICAL_INTERFACE: UCHAR = 0x05; +pub const USB_DEVICE_CLASS_POWER: UCHAR = 0x06; +pub const USB_DEVICE_CLASS_IMAGE: UCHAR = 0x06; +pub const USB_DEVICE_CLASS_PRINTER: UCHAR = 0x07; +pub const USB_DEVICE_CLASS_STORAGE: UCHAR = 0x08; +pub const USB_DEVICE_CLASS_HUB: UCHAR = 0x09; +pub const USB_DEVICE_CLASS_CDC_DATA: UCHAR = 0x0A; +pub const USB_DEVICE_CLASS_SMART_CARD: UCHAR = 0x0B; +pub const USB_DEVICE_CLASS_CONTENT_SECURITY: UCHAR = 0x0D; +pub const USB_DEVICE_CLASS_VIDEO: UCHAR = 0x0E; +pub const USB_DEVICE_CLASS_PERSONAL_HEALTHCARE: UCHAR = 0x0F; +pub const USB_DEVICE_CLASS_AUDIO_VIDEO: UCHAR = 0x10; +pub const USB_DEVICE_CLASS_BILLBOARD: UCHAR = 0x11; +pub const USB_DEVICE_CLASS_DIAGNOSTIC_DEVICE: UCHAR = 0xDC; +pub const USB_DEVICE_CLASS_WIRELESS_CONTROLLER: UCHAR = 0xE0; +pub const USB_DEVICE_CLASS_MISCELLANEOUS: UCHAR = 0xEF; +pub const USB_DEVICE_CLASS_APPLICATION_SPECIFIC: UCHAR = 0xFE; +pub const USB_DEVICE_CLASS_VENDOR_SPECIFIC: UCHAR = 0xFF; +STRUCT!{#[repr(packed)] struct USB_DEVICE_QUALIFIER_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bcdUSB: USHORT, + bDeviceClass: UCHAR, + bDeviceSubClass: UCHAR, + bDeviceProtocol: UCHAR, + bMaxPacketSize0: UCHAR, + bNumConfigurations: UCHAR, + bReserved: UCHAR, +}} +pub type PUSB_DEVICE_QUALIFIER_DESCRIPTOR = *mut USB_DEVICE_QUALIFIER_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_BOS_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + wTotalLength: USHORT, + bNumDeviceCaps: UCHAR, +}} +pub type PUSB_BOS_DESCRIPTOR = *mut USB_BOS_DESCRIPTOR; +pub const USB_DEVICE_CAPABILITY_WIRELESS_USB: UCHAR = 0x01; +pub const USB_DEVICE_CAPABILITY_USB20_EXTENSION: UCHAR = 0x02; +pub const USB_DEVICE_CAPABILITY_SUPERSPEED_USB: UCHAR = 0x03; +pub const USB_DEVICE_CAPABILITY_CONTAINER_ID: UCHAR = 0x04; +pub const USB_DEVICE_CAPABILITY_PLATFORM: UCHAR = 0x05; +pub const USB_DEVICE_CAPABILITY_POWER_DELIVERY: UCHAR = 0x06; +pub const USB_DEVICE_CAPABILITY_BATTERY_INFO: UCHAR = 0x07; +pub const USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT: UCHAR = 0x08; +pub const USB_DEVICE_CAPABILITY_PD_PROVIDER_PORT: UCHAR = 0x09; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB: UCHAR = 0x0A; +pub const USB_DEVICE_CAPABILITY_PRECISION_TIME_MEASUREMENT: UCHAR = 0x0B; +pub const USB_DEVICE_CAPABILITY_BILLBOARD: UCHAR = 0x0D; +pub const USB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY: UCHAR = 0x10; +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR_bmAttributes { + AsUlong: ULONG, +}} +BITFIELD!{USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR_bmAttributes AsUlong: ULONG [ + Reserved set_Reserved[0..1], + LPMCapable set_LPMCapable[1..2], + BESLAndAlternateHIRDSupported set_BESLAndAlternateHIRDSupported[2..3], + BaselineBESLValid set_BaselineBESLValid[3..4], + DeepBESLValid set_DeepBESLValid[4..5], + Reserved1 set_Reserved1[5..8], + BaselineBESL set_BaselineBESL[8..12], + DeepBESL set_DeepBESL[12..16], + Reserved2 set_Reserved2[16..32], +]} +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bDevCapabilityType: UCHAR, + bmAttributes: USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR_bmAttributes, +}} +pub type PUSB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR + = *mut USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR; +pub const USB_DEVICE_CAPABILITY_USB20_EXTENSION_BMATTRIBUTES_RESERVED_MASK: ULONG = 0xFFFF00E1; +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR_bmAttributes { + AsUlong: ULONG, +}} +BITFIELD!{USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR_bmAttributes AsUlong: ULONG [ + Reserved set_Reserved[0..1], + BatteryCharging set_BatteryCharging[1..2], + USBPowerDelivery set_USBPowerDelivery[2..3], + Provider set_Provider[3..4], + Consumer set_Consumer[4..5], + ChargingPolicy set_ChargingPolicy[5..6], + TypeCCurrent set_TypeCCurrent[6..7], + Reserved2 set_Reserved2[7..8], + ACSupply set_ACSupply[8..9], + Battery set_Battery[9..10], + Other set_Other[10..11], + NumBatteries set_NumBatteries[11..14], + UsesVbus set_UsesVbus[14..15], + Reserved3 set_Reserved3[15..32], +]} +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bDevCapabilityType: UCHAR, + bReserved: UCHAR, + bmAttributes: USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR_bmAttributes, + bmProviderPorts: USHORT, + bmConsumerPorts: USHORT, + bcdBCVersion: USHORT, + bcdPDVersion: USHORT, + bcdUSBTypeCVersion: USHORT, +}} +pub type PUSB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR + = *mut USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR_bmCapabilities { + AsUshort: USHORT, +}} +BITFIELD!{USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR_bmCapabilities AsUshort: USHORT [ + BatteryCharging set_BatteryCharging[0..1], + USBPowerDelivery set_USBPowerDelivery[1..2], + USBTypeCCurrent set_USBTypeCCurrent[2..3], + Reserved set_Reserved[3..16], +]} +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bDevCapabilityType: UCHAR, + bReserved: UCHAR, + bmCapabilities: USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR_bmCapabilities, + wMinVoltage: USHORT, + wMaxVoltage: USHORT, + wReserved: USHORT, + dwMaxOperatingPower: ULONG, + dwMaxPeakPower: ULONG, + dwMaxPeakPowerTime: ULONG, +}} +pub type PUSB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR + = *mut USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bDevCapabilityType: UCHAR, + bmAttributes: UCHAR, + wSpeedsSupported: USHORT, + bFunctionalitySupport: UCHAR, + bU1DevExitLat: UCHAR, + wU2DevExitLat: USHORT, +}} +pub type PUSB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR + = *mut USB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR; +pub const USB_DEVICE_CAPABILITY_SUPERSPEED_BMATTRIBUTES_RESERVED_MASK: UCHAR = 0xFD; +pub const USB_DEVICE_CAPABILITY_SUPERSPEED_BMATTRIBUTES_LTM_CAPABLE: UCHAR = 0x02; +pub const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_RESERVED_MASK: USHORT = 0xFFF0; +pub const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_LOW: USHORT = 0x0001; +pub const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_FULL: USHORT = 0x0002; +pub const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_HIGH: USHORT = 0x0004; +pub const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_SUPER: USHORT = 0x0008; +pub const USB_DEVICE_CAPABILITY_SUPERSPEED_U1_DEVICE_EXIT_MAX_VALUE: UCHAR = 0x0A; +pub const USB_DEVICE_CAPABILITY_SUPERSPEED_U2_DEVICE_EXIT_MAX_VALUE: USHORT = 0x07FF; +pub const USB_DEVICE_CAPABILITY_MAX_U1_LATENCY: UCHAR = 0x0A; +pub const USB_DEVICE_CAPABILITY_MAX_U2_LATENCY: USHORT = 0x07FF; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_BPS: ULONG = 0; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_KBPS: ULONG = 1; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_MBPS: ULONG = 2; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_GBPS: ULONG = 3; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_MODE_SYMMETRIC: ULONG = 0; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_MODE_ASYMMETRIC: ULONG = 1; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_DIR_RX: ULONG = 0; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_DIR_TX: ULONG = 1; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_PROTOCOL_SS: ULONG = 0; +pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_PROTOCOL_SSP: ULONG = 1; +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED { + AsUlong32: ULONG, +}} +BITFIELD!{USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED AsUlong32: ULONG [ + SublinkSpeedAttrID set_SublinkSpeedAttrID[0..4], + LaneSpeedExponent set_LaneSpeedExponent[4..6], + SublinkTypeMode set_SublinkTypeMode[6..7], + SublinkTypeDir set_SublinkTypeDir[7..8], + Reserved set_Reserved[8..14], + LinkProtocol set_LinkProtocol[14..16], + LaneSpeedMantissa set_LaneSpeedMantissa[16..32], +]} +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_bmAttributes { + AsUlong32: ULONG, +}} +BITFIELD!{USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_bmAttributes AsUlong32: ULONG [ + SublinkSpeedAttrCount set_SublinkSpeedAttrCount[0..5], + SublinkSpeedIDCount set_SublinkSpeedIDCount[5..9], + Reserved set_Reserved[9..32], +]} +STRUCT!{#[repr(packed)] + struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_wFunctionalitySupport { + AsUshort: USHORT, +}} +BITFIELD!{ + USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_wFunctionalitySupport AsUshort: USHORT [ + SublinkSpeedAttrID set_SublinkSpeedAttrID[0..4], + Reserved set_Reserved[4..8], + MinRxLaneCount set_MinRxLaneCount[8..12], + MinTxLaneCount set_MinTxLaneCount[12..16], +]} +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bDevCapabilityType: UCHAR, + bReserved: UCHAR, + bmAttributes: USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_bmAttributes, + wFunctionalitySupport: + USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_wFunctionalitySupport, + wReserved: USHORT, + bmSublinkSpeedAttr: [USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED; 1], +}} +pub type PUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR + = *mut USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bDevCapabilityType: UCHAR, + bReserved: UCHAR, + ContainerID: [UCHAR; 16], +}} +pub type PUSB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR + = *mut USB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY_DESCRIPTOR_Function { + bClass: UCHAR, + bSubClass: UCHAR, + bProtocol: UCHAR, +}} +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bDevCapabilityType: UCHAR, + bcdVersion: USHORT, + bConfigurationValue: UCHAR, + bMaxPower: UCHAR, + bNumFunctions: UCHAR, + Function: [USB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY_DESCRIPTOR_Function; 1], +}} +pub type PUSB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY_DESCRIPTOR + = *mut USB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bDevCapabilityType: UCHAR, + bReserved: UCHAR, + PlatformCapabilityUuid: GUID, + CapabililityData: [UCHAR; 1], +}} +pub type PUSB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR + = *mut USB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_VconnPower { + AsUshort: USHORT, +}} +BITFIELD!{USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_VconnPower AsUshort: USHORT [ + VConnPowerNeededForFullFunctionality set_VConnPowerNeededForFullFunctionality[0..3], + Reserved set_Reserved[3..15], + NoVconnPowerRequired set_NoVconnPowerRequired[15..16], +]} +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_AlternateMode { + wSVID: USHORT, + bAlternateMode: UCHAR, + iAlternateModeSetting: UCHAR, +}} +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bDevCapabilityType: UCHAR, + iAddtionalInfoURL: UCHAR, + bNumberOfAlternateModes: UCHAR, + bPreferredAlternateMode: UCHAR, + VconnPower: USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_VconnPower, + bmConfigured: [UCHAR; 32], + bReserved: ULONG, + AlternateMode: [USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_AlternateMode; 1], +}} +pub type PUSB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR + = *mut USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR; +DEFINE_GUID!{GUID_USB_MSOS20_PLATFORM_CAPABILITY_ID, + 0xd8dd60df, 0x4589, 0x4cc7, 0x9c, 0xd2, 0x65, 0x9d, 0x9e, 0x64, 0x8a, 0x9f} +STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bDevCapabilityType: UCHAR, +}} +pub type PUSB_DEVICE_CAPABILITY_DESCRIPTOR = *mut USB_DEVICE_CAPABILITY_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_CONFIGURATION_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + wTotalLength: USHORT, + bNumInterfaces: UCHAR, + bConfigurationValue: UCHAR, + iConfiguration: UCHAR, + bmAttributes: UCHAR, + MaxPower: UCHAR, +}} +pub type PUSB_CONFIGURATION_DESCRIPTOR = *mut USB_CONFIGURATION_DESCRIPTOR; +pub const USB_CONFIG_POWERED_MASK: UCHAR = 0xC0; +pub const USB_CONFIG_BUS_POWERED: UCHAR = 0x80; +pub const USB_CONFIG_SELF_POWERED: UCHAR = 0x40; +pub const USB_CONFIG_REMOTE_WAKEUP: UCHAR = 0x20; +pub const USB_CONFIG_RESERVED: UCHAR = 0x1F; +STRUCT!{#[repr(packed)] struct USB_INTERFACE_ASSOCIATION_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bFirstInterface: UCHAR, + bInterfaceCount: UCHAR, + bFunctionClass: UCHAR, + bFunctionSubClass: UCHAR, + bFunctionProtocol: UCHAR, + iFunction: UCHAR, +}} +pub type PUSB_INTERFACE_ASSOCIATION_DESCRIPTOR = *mut USB_INTERFACE_ASSOCIATION_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_INTERFACE_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bInterfaceNumber: UCHAR, + bAlternateSetting: UCHAR, + bNumEndpoints: UCHAR, + bInterfaceClass: UCHAR, + bInterfaceSubClass: UCHAR, + bInterfaceProtocol: UCHAR, + iInterface: UCHAR, +}} +pub type PUSB_INTERFACE_DESCRIPTOR = *mut USB_INTERFACE_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_ENDPOINT_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bEndpointAddress: UCHAR, + bmAttributes: UCHAR, + wMaxPacketSize: USHORT, + bInterval: UCHAR, +}} +pub type PUSB_ENDPOINT_DESCRIPTOR = *mut USB_ENDPOINT_DESCRIPTOR; +pub const USB_ENDPOINT_DIRECTION_MASK: UCHAR = 0x80; +#[inline] +pub fn USB_ENDPOINT_DIRECTION_OUT(addr: UCHAR) -> UCHAR { + !(addr & USB_ENDPOINT_DIRECTION_MASK) +} +#[inline] +pub fn USB_ENDPOINT_DIRECTION_IN(addr: UCHAR) -> UCHAR { + addr & USB_ENDPOINT_DIRECTION_MASK +} +pub const USB_ENDPOINT_ADDRESS_MASK: UCHAR = 0x0F; +pub const USB_ENDPOINT_TYPE_MASK: UCHAR = 0x03; +pub const USB_ENDPOINT_TYPE_CONTROL: UCHAR = 0x00; +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS: UCHAR = 0x01; +pub const USB_ENDPOINT_TYPE_BULK: UCHAR = 0x02; +pub const USB_ENDPOINT_TYPE_INTERRUPT: UCHAR = 0x03; +pub const USB_ENDPOINT_TYPE_BULK_RESERVED_MASK: UCHAR = 0xFC; +pub const USB_ENDPOINT_TYPE_CONTROL_RESERVED_MASK: UCHAR = 0xFC; +pub const USB_20_ENDPOINT_TYPE_INTERRUPT_RESERVED_MASK: UCHAR = 0xFC; +pub const USB_30_ENDPOINT_TYPE_INTERRUPT_RESERVED_MASK: UCHAR = 0xCC; +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_RESERVED_MASK: UCHAR = 0xC0; +pub const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_MASK: UCHAR = 0x30; +pub const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_PERIODIC: UCHAR = 0x00; +pub const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_NOTIFICATION: UCHAR = 0x10; +pub const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_RESERVED10: UCHAR = 0x20; +pub const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_RESERVED11: UCHAR = 0x30; +#[inline] +pub fn USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE(bmAttr: UCHAR) -> UCHAR { + bmAttr & USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_MASK +} +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_MASK: UCHAR = 0x0C; +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_NO_SYNCHRONIZATION: UCHAR = 0x00; +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_ASYNCHRONOUS: UCHAR = 0x04; +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_ADAPTIVE: UCHAR = 0x08; +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_SYNCHRONOUS: UCHAR = 0x0C; +#[inline] +pub fn USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION(bmAttr: UCHAR) -> UCHAR { + bmAttr & USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_MASK +} +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_MASK: UCHAR = 0x30; +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_DATA_ENDOINT: UCHAR = 0x00; +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_FEEDBACK_ENDPOINT: UCHAR = 0x10; +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_IMPLICIT_FEEDBACK_DATA_ENDPOINT: UCHAR = 0x20; +pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_RESERVED: UCHAR = 0x30; +#[inline] +pub fn USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE(bmAttr: UCHAR) -> UCHAR { + bmAttr & USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_MASK +} +STRUCT!{#[repr(packed)] struct USB_HIGH_SPEED_MAXPACKET { + us: USHORT, +}} +BITFIELD!{USB_HIGH_SPEED_MAXPACKET us: USHORT [ + MaxPacket set_MaxPacket[0..11], + HSmux set_HSmux[11..13], + Reserved set_Reserved[13..16], +]} +pub type PUSB_HIGH_SPEED_MAXPACKET = *mut USB_HIGH_SPEED_MAXPACKET; +pub const USB_ENDPOINT_SUPERSPEED_BULK_MAX_PACKET_SIZE: USHORT = 1024; +pub const USB_ENDPOINT_SUPERSPEED_CONTROL_MAX_PACKET_SIZE: USHORT = 512; +pub const USB_ENDPOINT_SUPERSPEED_ISO_MAX_PACKET_SIZE: USHORT = 1024; +pub const USB_ENDPOINT_SUPERSPEED_INTERRUPT_MAX_PACKET_SIZE: USHORT = 1024; +STRUCT!{#[repr(packed)] struct USB_STRING_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bString: [WCHAR; 1], +}} +pub type PUSB_STRING_DESCRIPTOR = *mut USB_STRING_DESCRIPTOR; +pub const MAXIMUM_USB_STRING_LENGTH: UCHAR = 255; +STRUCT!{#[repr(packed)] struct USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Bulk { + BitField: UCHAR, +}} +BITFIELD!{USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Bulk BitField: UCHAR [ + MaxStreams set_MaxStreams[0..5], + Reserved1 set_Reserved1[5..8], +]} +STRUCT!{#[repr(packed)] + struct USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Isochronous { + BitField: UCHAR, +}} +BITFIELD!{USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Isochronous BitField: UCHAR [ + Mult set_Mult[0..2], + Reserved2 set_Reserved2[2..7], + SspCompanion set_SspCompanion[7..8], +]} +UNION!{#[repr(packed)] union USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes { + [u8; 1], + AsUchar AsUchar_mut: UCHAR, + Bulk Bulk_mut: USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Bulk, + Isochronous Isochronous_mut: + USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Isochronous, +}} +STRUCT!{#[repr(packed)] struct USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bMaxBurst: UCHAR, + bmAttributes: USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes, + wBytesPerInterval: USHORT, +}} +pub type PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR + = *mut USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR; +pub const USB_SUPERSPEED_ISOCHRONOUS_MAX_MULTIPLIER: UCHAR = 2; +STRUCT!{#[repr(packed)] struct USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + wReserved: USHORT, + dwBytesPerInterval: ULONG, +}} +pub type PUSB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR + = *mut USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR; +pub const USB_SUPERSPEEDPLUS_ISOCHRONOUS_MIN_BYTESPERINTERVAL: ULONG = 0xC001; +pub const USB_SUPERSPEEDPLUS_ISOCHRONOUS_MAX_BYTESPERINTERVAL: ULONG = 0xFFFFFF; +STRUCT!{#[repr(packed)] struct USB_HUB_DESCRIPTOR { + bDescriptorLength: UCHAR, + bDescriptorType: UCHAR, + bNumberOfPorts: UCHAR, + wHubCharacteristics: USHORT, + bPowerOnToPowerGood: UCHAR, + bHubControlCurrent: UCHAR, + bRemoveAndPowerMask: [UCHAR; 64], +}} +pub type PUSB_HUB_DESCRIPTOR = *mut USB_HUB_DESCRIPTOR; +pub const USB_20_HUB_DESCRIPTOR_TYPE: UCHAR = 0x29; +STRUCT!{#[repr(packed)] struct USB_30_HUB_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bNumberOfPorts: UCHAR, + wHubCharacteristics: USHORT, + bPowerOnToPowerGood: UCHAR, + bHubControlCurrent: UCHAR, + bHubHdrDecLat: UCHAR, + wHubDelay: USHORT, + DeviceRemovable: USHORT, +}} +pub type PUSB_30_HUB_DESCRIPTOR = *mut USB_30_HUB_DESCRIPTOR; +pub const USB_30_HUB_DESCRIPTOR_TYPE: UCHAR = 0x2A; +pub const USB_REQUEST_GET_STATE: UCHAR = 0x02; +pub const USB_REQUEST_CLEAR_TT_BUFFER: UCHAR = 0x08; +pub const USB_REQUEST_RESET_TT: UCHAR = 0x09; +pub const USB_REQUEST_GET_TT_STATE: UCHAR = 0x0A; +pub const USB_REQUEST_STOP_TT: UCHAR = 0x0B; +pub const USB_REQUEST_SET_HUB_DEPTH: UCHAR = 0x0C; +pub const USB_REQUEST_GET_PORT_ERR_COUNT: UCHAR = 0x0D; +STRUCT!{#[repr(packed)] struct USB_HUB_STATUS { + AsUshort16: USHORT, +}} +BITFIELD!{USB_HUB_STATUS AsUshort16: USHORT [ + LocalPowerLost set_LocalPowerLost[0..1], + OverCurrent set_OverCurrent[1..2], + Reserved set_Reserved[2..16], +]} +pub type PUSB_HUB_STATUS = *mut USB_HUB_STATUS; +STRUCT!{#[repr(packed)] struct USB_HUB_CHANGE { + AsUshort16: USHORT, +}} +BITFIELD!{USB_HUB_CHANGE AsUshort16: USHORT [ + LocalPowerChange set_LocalPowerChange[0..1], + OverCurrentChange set_OverCurrentChange[1..2], + Reserved set_Reserved[2..16], +]} +pub type PUSB_HUB_CHANGE = *mut USB_HUB_CHANGE; +STRUCT!{#[repr(packed)] struct USB_HUB_STATUS_AND_CHANGE_s { + HubStatus: USB_HUB_STATUS, + HubChange: USB_HUB_CHANGE, +}} +UNION!{#[repr(packed)] union USB_HUB_STATUS_AND_CHANGE { + [u32; 1], + AsUlong32 AsUlong32_mut: ULONG, + s s_mut: USB_HUB_STATUS_AND_CHANGE_s, +}} +pub type PUSB_HUB_STATUS_AND_CHANGE = *mut USB_HUB_STATUS_AND_CHANGE; +STRUCT!{#[repr(packed)] struct USB_20_PORT_STATUS { + AsUshort16: USHORT, +}} +BITFIELD!{USB_20_PORT_STATUS AsUshort16: USHORT [ + CurrentConnectStatus set_CurrentConnectStatus[0..1], + PortEnabledDisabled set_PortEnabledDisabled[1..2], + Suspend set_Suspend[2..3], + OverCurrent set_OverCurrent[3..4], + Reset set_Reset[4..5], + L1 set_L1[5..6], + Reserved0 set_Reserved0[6..8], + PortPower set_PortPower[8..9], + LowSpeedDeviceAttached set_LowSpeedDeviceAttached[9..10], + HighSpeedDeviceAttached set_HighSpeedDeviceAttached[10..11], + PortTestMode set_PortTestMode[11..12], + PortIndicatorControl set_PortIndicatorControl[12..13], + Reserved1 set_Reserved1[13..16], +]} +pub type PUSB_20_PORT_STATUS = *mut USB_20_PORT_STATUS; +pub const USB_PORT_STATUS_CONNECT: USHORT = 0x0001; +pub const USB_PORT_STATUS_ENABLE: USHORT = 0x0002; +pub const USB_PORT_STATUS_SUSPEND: USHORT = 0x0004; +pub const USB_PORT_STATUS_OVER_CURRENT: USHORT = 0x0008; +pub const USB_PORT_STATUS_RESET: USHORT = 0x0010; +pub const USB_PORT_STATUS_POWER: USHORT = 0x0100; +pub const USB_PORT_STATUS_LOW_SPEED: USHORT = 0x0200; +pub const USB_PORT_STATUS_HIGH_SPEED: USHORT = 0x0400; +STRUCT!{#[repr(packed)] struct USB_20_PORT_CHANGE { + AsUshort16: USHORT, +}} +BITFIELD!{USB_20_PORT_CHANGE AsUshort16: USHORT [ + ConnectStatusChange set_ConnectStatusChange[0..1], + PortEnableDisableChange set_PortEnableDisableChange[1..2], + SuspendChange set_SuspendChange[2..3], + OverCurrentIndicatorChange set_OverCurrentIndicatorChange[3..4], + ResetChange set_ResetChange[4..5], + Reserved2 set_Reserved2[5..16], +]} +pub type PUSB_20_PORT_CHANGE = *mut USB_20_PORT_CHANGE; +STRUCT!{#[repr(packed)] struct USB_30_PORT_STATUS { + AsUshort16: USHORT, +}} +BITFIELD!{USB_30_PORT_STATUS AsUshort16: USHORT [ + CurrentConnectStatus set_CurrentConnectStatus[0..1], + PortEnabledDisabled set_PortEnabledDisabled[1..2], + Reserved0 set_Reserved0[2..3], + OverCurrent set_OverCurrent[3..4], + Reset set_Reset[4..5], + PortLinkState set_PortLinkState[5..9], + PortPower set_PortPower[9..10], + NegotiatedDeviceSpeed set_NegotiatedDeviceSpeed[10..13], + Reserved1 set_Reserved1[13..16], +]} +pub type PUSB_30_PORT_STATUS = *mut USB_30_PORT_STATUS; +pub const PORT_LINK_STATE_U0: USHORT = 0; +pub const PORT_LINK_STATE_U1: USHORT = 1; +pub const PORT_LINK_STATE_U2: USHORT = 2; +pub const PORT_LINK_STATE_U3: USHORT = 3; +pub const PORT_LINK_STATE_DISABLED: USHORT = 4; +pub const PORT_LINK_STATE_RX_DETECT: USHORT = 5; +pub const PORT_LINK_STATE_INACTIVE: USHORT = 6; +pub const PORT_LINK_STATE_POLLING: USHORT = 7; +pub const PORT_LINK_STATE_RECOVERY: USHORT = 8; +pub const PORT_LINK_STATE_HOT_RESET: USHORT = 9; +pub const PORT_LINK_STATE_COMPLIANCE_MODE: USHORT = 10; +pub const PORT_LINK_STATE_LOOPBACK: USHORT = 11; +pub const PORT_LINK_STATE_TEST_MODE: USHORT = 11; +STRUCT!{#[repr(packed)] struct USB_30_PORT_CHANGE { + AsUshort16: USHORT, +}} +BITFIELD!{USB_30_PORT_CHANGE AsUshort16: USHORT [ + ConnectStatusChange set_ConnectStatusChange[0..1], + Reserved2 set_Reserved2[1..3], + OverCurrentIndicatorChange set_OverCurrentIndicatorChange[3..4], + ResetChange set_ResetChange[4..5], + BHResetChange set_BHResetChange[5..6], + PortLinkStateChange set_PortLinkStateChange[6..7], + PortConfigErrorChange set_PortConfigErrorChange[7..8], + Reserved3 set_Reserved3[8..16], +]} +pub type PUSB_30_PORT_CHANGE = *mut USB_30_PORT_CHANGE; +UNION!{#[repr(packed)] union USB_PORT_STATUS { + [u16; 1], + AsUshort16 AsUshort16_mut: USHORT, + Usb20PortStatus Usb20PortStatus_mut: USB_20_PORT_STATUS, + Usb30PortStatus Usb30PortStatus_mut: USB_30_PORT_STATUS, +}} +pub type PUSB_PORT_STATUS = *mut USB_PORT_STATUS; +UNION!{#[repr(packed)] union USB_PORT_CHANGE { + [u16; 1], + AsUshort16 AsUshort16_mut: USHORT, + Usb20PortChange Usb20PortChange_mut: USB_20_PORT_CHANGE, + Usb30PortChange Usb30PortChange_mut: USB_30_PORT_CHANGE, +}} +pub type PUSB_PORT_CHANGE = *mut USB_PORT_CHANGE; +STRUCT!{#[repr(packed)] struct USB_PORT_EXT_STATUS { + AsUlong32: ULONG, +}} +BITFIELD!{USB_PORT_EXT_STATUS AsUlong32: ULONG [ + RxSublinkSpeedID set_RxSublinkSpeedID[0..4], + TxSublinkSpeedID set_TxSublinkSpeedID[4..8], + RxLaneCount set_RxLaneCount[8..12], + TxLaneCount set_TxLaneCount[12..16], + Reserved set_Reserved[16..32], +]} +pub type PUSB_PORT_EXT_STATUS = *mut USB_PORT_EXT_STATUS; +STRUCT!{#[repr(packed)] struct USB_PORT_STATUS_AND_CHANGE_s { + PortStatus: USB_PORT_STATUS, + PortChange: USB_PORT_CHANGE, +}} +UNION!{#[repr(packed)] union USB_PORT_STATUS_AND_CHANGE { + [u32; 1], + AsUlong32 AsUlong32_mut: ULONG, + s s_mut: USB_PORT_STATUS_AND_CHANGE_s, +}} +pub type PUSB_PORT_STATUS_AND_CHANGE = *mut USB_PORT_STATUS_AND_CHANGE; +STRUCT!{#[repr(packed)] struct USB_PORT_EXT_STATUS_AND_CHANGE_s { + PortStatusChange: USB_PORT_STATUS_AND_CHANGE, + PortExtStatus: USB_PORT_EXT_STATUS, +}} +UNION!{#[repr(packed)] union USB_PORT_EXT_STATUS_AND_CHANGE { + [u64; 1], + AsUlong64 AsUlong64_mut: ULONG64, + s s_mut: USB_PORT_EXT_STATUS_AND_CHANGE_s, +}} +pub type PUSB_PORT_EXT_STATUS_AND_CHANGE = *mut USB_PORT_EXT_STATUS_AND_CHANGE; +STRUCT!{#[repr(packed)] struct USB_HUB_30_PORT_REMOTE_WAKE_MASK { + AsUchar8: UCHAR, +}} +BITFIELD!{USB_HUB_30_PORT_REMOTE_WAKE_MASK AsUchar8: UCHAR [ + ConnectRemoteWakeEnable set_ConnectRemoteWakeEnable[0..1], + DisconnectRemoteWakeEnable set_DisconnectRemoteWakeEnable[1..2], + OverCurrentRemoteWakeEnable set_OverCurrentRemoteWakeEnable[2..3], + Reserved0 set_Reserved0[3..8], +]} +pub type PUSB_HUB_30_PORT_REMOTE_WAKE_MASK = *mut USB_HUB_30_PORT_REMOTE_WAKE_MASK; +STRUCT!{#[repr(packed)] struct USB_FUNCTION_SUSPEND_OPTIONS { + AsUchar: UCHAR, +}} +BITFIELD!{USB_FUNCTION_SUSPEND_OPTIONS AsUchar: UCHAR [ + PowerState set_PowerState[0..1], + RemoteWakeEnabled set_RemoteWakeEnabled[1..2], + Reserved0 set_Reserved0[2..8], +]} +pub type PUSB_FUNCTION_SUSPEND_OPTIONS = *mut USB_FUNCTION_SUSPEND_OPTIONS; +pub const USB_FEATURE_INTERFACE_POWER_D0: USHORT = 0x0002; +pub const USB_FEATURE_INTERFACE_POWER_D1: USHORT = 0x0003; +pub const USB_FEATURE_INTERFACE_POWER_D2: USHORT = 0x0004; +pub const USB_FEATURE_INTERFACE_POWER_D3: USHORT = 0x0005; +pub const USB_SUPPORT_D0_COMMAND: UCHAR = 0x01; +pub const USB_SUPPORT_D1_COMMAND: UCHAR = 0x02; +pub const USB_SUPPORT_D2_COMMAND: UCHAR = 0x04; +pub const USB_SUPPORT_D3_COMMAND: UCHAR = 0x08; +pub const USB_SUPPORT_D1_WAKEUP: UCHAR = 0x10; +pub const USB_SUPPORT_D2_WAKEUP: UCHAR = 0x20; +STRUCT!{#[repr(packed)] struct USB_CONFIGURATION_POWER_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + SelfPowerConsumedD0: [UCHAR; 3], + bPowerSummaryId: UCHAR, + bBusPowerSavingD1: UCHAR, + bSelfPowerSavingD1: UCHAR, + bBusPowerSavingD2: UCHAR, + bSelfPowerSavingD2: UCHAR, + bBusPowerSavingD3: UCHAR, + bSelfPowerSavingD3: UCHAR, + TransitionTimeFromD1: USHORT, + TransitionTimeFromD2: USHORT, + TransitionTimeFromD3: USHORT, +}} +pub type PUSB_CONFIGURATION_POWER_DESCRIPTOR = *mut USB_CONFIGURATION_POWER_DESCRIPTOR; +STRUCT!{#[repr(packed)] struct USB_INTERFACE_POWER_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bmCapabilitiesFlags: UCHAR, + bBusPowerSavingD1: UCHAR, + bSelfPowerSavingD1: UCHAR, + bBusPowerSavingD2: UCHAR, + bSelfPowerSavingD2: UCHAR, + bBusPowerSavingD3: UCHAR, + bSelfPowerSavingD3: UCHAR, + TransitionTimeFromD1: USHORT, + TransitionTimeFromD2: USHORT, + TransitionTimeFromD3: USHORT, +}} +pub type PUSB_INTERFACE_POWER_DESCRIPTOR = *mut USB_INTERFACE_POWER_DESCRIPTOR; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/windef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/windef.rs new file mode 100644 index 0000000..d2e5fe0 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/windef.rs @@ -0,0 +1,125 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Basic Windows Type Definitions +use ctypes::c_void; +use shared::minwindef::{DWORD, HFILE, WORD}; +use um::winnt::{LONG, SHORT}; +DECLARE_HANDLE!{HWND, HWND__} +DECLARE_HANDLE!{HHOOK, HHOOK__} +pub type HGDIOBJ = *mut c_void; +DECLARE_HANDLE!{HACCEL, HACCEL__} +DECLARE_HANDLE!{HBITMAP, HBITMAP__} +DECLARE_HANDLE!{HBRUSH, HBRUSH__} +DECLARE_HANDLE!{HCOLORSPACE, HCOLORSPACE__} +DECLARE_HANDLE!{HDC, HDC__} +DECLARE_HANDLE!{HGLRC, HGLRC__} +DECLARE_HANDLE!{HDESK, HDESK__} +DECLARE_HANDLE!{HENHMETAFILE, HENHMETAFILE__} +DECLARE_HANDLE!{HFONT, HFONT__} +DECLARE_HANDLE!{HICON, HICON__} +DECLARE_HANDLE!{HMENU, HMENU__} +DECLARE_HANDLE!{HPALETTE, HPALETTE__} +DECLARE_HANDLE!{HPEN, HPEN__} +DECLARE_HANDLE!{HWINEVENTHOOK, HWINEVENTHOOK__} +DECLARE_HANDLE!{HMONITOR, HMONITOR__} +DECLARE_HANDLE!{HUMPD, HUMPD__} +pub type HCURSOR = HICON; +pub type COLORREF = DWORD; +pub type LPCOLORREF = *mut DWORD; +pub const HFILE_ERROR: HFILE = -1; +STRUCT!{#[debug] struct RECT { + left: LONG, + top: LONG, + right: LONG, + bottom: LONG, +}} +pub type PRECT = *mut RECT; +pub type NPRECT = *mut RECT; +pub type LPRECT = *mut RECT; +pub type LPCRECT = *const RECT; +STRUCT!{#[debug] struct RECTL { + left: LONG, + top: LONG, + right: LONG, + bottom: LONG, +}} +pub type PRECTL = *mut RECTL; +pub type LPRECTL = *mut RECTL; +pub type LPCRECTL = *const RECTL; +STRUCT!{struct POINT { + x: LONG, + y: LONG, +}} +pub type PPOINT = *mut POINT; +pub type NPPOINT = *mut POINT; +pub type LPPOINT = *mut POINT; +STRUCT!{struct POINTL { + x: LONG, + y: LONG, +}} +pub type PPOINTL = *mut POINTL; +STRUCT!{struct SIZE { + cx: LONG, + cy: LONG, +}} +pub type PSIZE = *mut SIZE; +pub type LPSIZE = *mut SIZE; +pub type SIZEL = SIZE; +pub type PSIZEL = *mut SIZE; +pub type LPSIZEL = *mut SIZE; +STRUCT!{struct POINTS { + x: SHORT, + y: SHORT, +}} +pub type PPOINTS = *mut POINTS; +pub type LPPOINTS = *mut POINTS; +pub const DM_UPDATE: WORD = 1; +pub const DM_COPY: WORD = 2; +pub const DM_PROMPT: WORD = 4; +pub const DM_MODIFY: WORD = 8; +pub const DM_IN_BUFFER: WORD = DM_MODIFY; +pub const DM_IN_PROMPT: WORD = DM_PROMPT; +pub const DM_OUT_BUFFER: WORD = DM_COPY; +pub const DM_OUT_DEFAULT: WORD = DM_UPDATE; +pub const DC_FIELDS: DWORD = 1; +pub const DC_PAPERS: DWORD = 2; +pub const DC_PAPERSIZE: DWORD = 3; +pub const DC_MINEXTENT: DWORD = 4; +pub const DC_MAXEXTENT: DWORD = 5; +pub const DC_BINS: DWORD = 6; +pub const DC_DUPLEX: DWORD = 7; +pub const DC_SIZE: DWORD = 8; +pub const DC_EXTRA: DWORD = 9; +pub const DC_VERSION: DWORD = 10; +pub const DC_DRIVER: DWORD = 11; +pub const DC_BINNAMES: DWORD = 12; +pub const DC_ENUMRESOLUTIONS: DWORD = 13; +pub const DC_FILEDEPENDENCIES: DWORD = 14; +pub const DC_TRUETYPE: DWORD = 15; +pub const DC_PAPERNAMES: DWORD = 16; +pub const DC_ORIENTATION: DWORD = 17; +pub const DC_COPIES: DWORD = 18; +DECLARE_HANDLE!{DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT__} +ENUM!{enum DPI_AWARENESS { + DPI_AWARENESS_INVALID = -1i32 as u32, + DPI_AWARENESS_UNAWARE = 0, + DPI_AWARENESS_SYSTEM_AWARE = 1, + DPI_AWARENESS_PER_MONITOR_AWARE = 2, +}} +pub const DPI_AWARENESS_CONTEXT_UNAWARE: DPI_AWARENESS_CONTEXT = -1isize as DPI_AWARENESS_CONTEXT; +pub const DPI_AWARENESS_CONTEXT_SYSTEM_AWARE: DPI_AWARENESS_CONTEXT + = -2isize as DPI_AWARENESS_CONTEXT; +pub const DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE: DPI_AWARENESS_CONTEXT + = -3isize as DPI_AWARENESS_CONTEXT; +pub const DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2: DPI_AWARENESS_CONTEXT + = -4isize as DPI_AWARENESS_CONTEXT; +pub const DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED: DPI_AWARENESS_CONTEXT + = -5isize as DPI_AWARENESS_CONTEXT; +ENUM!{enum DPI_HOSTING_BEHAVIOR { + DPI_HOSTING_BEHAVIOR_INVALID = -1i32 as u32, + DPI_HOSTING_BEHAVIOR_DEFAULT = 0, + DPI_HOSTING_BEHAVIOR_MIXED = 1, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/windowsx.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/windowsx.rs new file mode 100644 index 0000000..4147aa3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/windowsx.rs @@ -0,0 +1,17 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Macro APIs, window message crackers, and control APIs +use ctypes::{c_int, c_short}; +use shared::minwindef::{DWORD, HIWORD, LOWORD, LPARAM}; +//1233 +#[inline] +pub fn GET_X_LPARAM(lp: LPARAM) -> c_int { + LOWORD(lp as DWORD) as c_short as c_int +} +#[inline] +pub fn GET_Y_LPARAM(lp: LPARAM) -> c_int { + HIWORD(lp as DWORD) as c_short as c_int +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/winerror.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/winerror.rs new file mode 100644 index 0000000..2c29821 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/winerror.rs @@ -0,0 +1,6150 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! error code definitions for the Win32 API functions +use ctypes::{c_long, c_ulong}; +use shared::minwindef::DWORD; +use shared::wtypesbase::SCODE; +pub const FACILITY_XPS: HRESULT = 82; +pub const FACILITY_XAML: HRESULT = 43; +pub const FACILITY_USN: HRESULT = 129; +pub const FACILITY_BLBUI: HRESULT = 128; +pub const FACILITY_SPP: HRESULT = 256; +pub const FACILITY_WSB_ONLINE: HRESULT = 133; +pub const FACILITY_DLS: HRESULT = 153; +pub const FACILITY_BLB_CLI: HRESULT = 121; +pub const FACILITY_BLB: HRESULT = 120; +pub const FACILITY_WSBAPP: HRESULT = 122; +pub const FACILITY_WPN: HRESULT = 62; +pub const FACILITY_WMAAECMA: HRESULT = 1996; +pub const FACILITY_WINRM: HRESULT = 51; +pub const FACILITY_WINPE: HRESULT = 61; +pub const FACILITY_WINDOWSUPDATE: HRESULT = 36; +pub const FACILITY_WINDOWS_STORE: HRESULT = 63; +pub const FACILITY_WINDOWS_SETUP: HRESULT = 48; +pub const FACILITY_WINDOWS_DEFENDER: HRESULT = 80; +pub const FACILITY_WINDOWS_CE: HRESULT = 24; +pub const FACILITY_WINDOWS: HRESULT = 8; +pub const FACILITY_WINCODEC_DWRITE_DWM: HRESULT = 2200; +pub const FACILITY_WIA: HRESULT = 33; +pub const FACILITY_WER: HRESULT = 27; +pub const FACILITY_WEP: HRESULT = 2049; +pub const FACILITY_WEB_SOCKET: HRESULT = 886; +pub const FACILITY_WEB: HRESULT = 885; +pub const FACILITY_USERMODE_VOLSNAP: HRESULT = 130; +pub const FACILITY_USERMODE_VOLMGR: HRESULT = 56; +pub const FACILITY_VISUALCPP: HRESULT = 109; +pub const FACILITY_USERMODE_VIRTUALIZATION: HRESULT = 55; +pub const FACILITY_USERMODE_VHD: HRESULT = 58; +pub const FACILITY_URT: HRESULT = 19; +pub const FACILITY_UMI: HRESULT = 22; +pub const FACILITY_UI: HRESULT = 42; +pub const FACILITY_TPM_SOFTWARE: HRESULT = 41; +pub const FACILITY_TPM_SERVICES: HRESULT = 40; +pub const FACILITY_TIERING: HRESULT = 131; +pub const FACILITY_SYNCENGINE: HRESULT = 2050; +pub const FACILITY_SXS: HRESULT = 23; +pub const FACILITY_STORAGE: HRESULT = 3; +pub const FACILITY_STATE_MANAGEMENT: HRESULT = 34; +pub const FACILITY_SSPI: HRESULT = 9; +pub const FACILITY_USERMODE_SPACES: HRESULT = 231; +pub const FACILITY_SOS: HRESULT = 160; +pub const FACILITY_SCARD: HRESULT = 16; +pub const FACILITY_SHELL: HRESULT = 39; +pub const FACILITY_SETUPAPI: HRESULT = 15; +pub const FACILITY_SECURITY: HRESULT = 9; +pub const FACILITY_SDIAG: HRESULT = 60; +pub const FACILITY_USERMODE_SDBUS: HRESULT = 2305; +pub const FACILITY_RPC: HRESULT = 1; +pub const FACILITY_RESTORE: HRESULT = 256; +pub const FACILITY_SCRIPT: HRESULT = 112; +pub const FACILITY_PARSE: HRESULT = 113; +pub const FACILITY_RAS: HRESULT = 83; +pub const FACILITY_POWERSHELL: HRESULT = 84; +pub const FACILITY_PLA: HRESULT = 48; +pub const FACILITY_PIDGENX: HRESULT = 2561; +pub const FACILITY_P2P_INT: HRESULT = 98; +pub const FACILITY_P2P: HRESULT = 99; +pub const FACILITY_OPC: HRESULT = 81; +pub const FACILITY_ONLINE_ID: HRESULT = 134; +pub const FACILITY_WIN32: HRESULT = 7; +pub const FACILITY_CONTROL: HRESULT = 10; +pub const FACILITY_WEBSERVICES: HRESULT = 61; +pub const FACILITY_NULL: HRESULT = 0; +pub const FACILITY_NDIS: HRESULT = 52; +pub const FACILITY_NAP: HRESULT = 39; +pub const FACILITY_MOBILE: HRESULT = 1793; +pub const FACILITY_METADIRECTORY: HRESULT = 35; +pub const FACILITY_MSMQ: HRESULT = 14; +pub const FACILITY_MEDIASERVER: HRESULT = 13; +pub const FACILITY_MBN: HRESULT = 84; +pub const FACILITY_LINGUISTIC_SERVICES: HRESULT = 305; +pub const FACILITY_LEAP: HRESULT = 2184; +pub const FACILITY_JSCRIPT: HRESULT = 2306; +pub const FACILITY_INTERNET: HRESULT = 12; +pub const FACILITY_ITF: HRESULT = 4; +pub const FACILITY_INPUT: HRESULT = 64; +pub const FACILITY_USERMODE_HYPERVISOR: HRESULT = 53; +pub const FACILITY_ACCELERATOR: HRESULT = 1536; +pub const FACILITY_HTTP: HRESULT = 25; +pub const FACILITY_GRAPHICS: HRESULT = 38; +pub const FACILITY_FWP: HRESULT = 50; +pub const FACILITY_FVE: HRESULT = 49; +pub const FACILITY_USERMODE_FILTER_MANAGER: HRESULT = 31; +pub const FACILITY_EAS: HRESULT = 85; +pub const FACILITY_EAP: HRESULT = 66; +pub const FACILITY_DXGI_DDI: HRESULT = 2171; +pub const FACILITY_DXGI: HRESULT = 2170; +pub const FACILITY_DPLAY: HRESULT = 21; +pub const FACILITY_DMSERVER: HRESULT = 256; +pub const FACILITY_DISPATCH: HRESULT = 2; +pub const FACILITY_DIRECTORYSERVICE: HRESULT = 37; +pub const FACILITY_DIRECTMUSIC: HRESULT = 2168; +pub const FACILITY_DIRECT3D11: HRESULT = 2172; +pub const FACILITY_DIRECT3D10: HRESULT = 2169; +pub const FACILITY_DIRECT2D: HRESULT = 2201; +pub const FACILITY_DAF: HRESULT = 100; +pub const FACILITY_DEPLOYMENT_SERVICES_UTIL: HRESULT = 260; +pub const FACILITY_DEPLOYMENT_SERVICES_TRANSPORT_MANAGEMENT: HRESULT = 272; +pub const FACILITY_DEPLOYMENT_SERVICES_TFTP: HRESULT = 264; +pub const FACILITY_DEPLOYMENT_SERVICES_PXE: HRESULT = 263; +pub const FACILITY_DEPLOYMENT_SERVICES_MULTICAST_SERVER: HRESULT = 289; +pub const FACILITY_DEPLOYMENT_SERVICES_MULTICAST_CLIENT: HRESULT = 290; +pub const FACILITY_DEPLOYMENT_SERVICES_MANAGEMENT: HRESULT = 259; +pub const FACILITY_DEPLOYMENT_SERVICES_IMAGING: HRESULT = 258; +pub const FACILITY_DEPLOYMENT_SERVICES_DRIVER_PROVISIONING: HRESULT = 278; +pub const FACILITY_DEPLOYMENT_SERVICES_SERVER: HRESULT = 257; +pub const FACILITY_DEPLOYMENT_SERVICES_CONTENT_PROVIDER: HRESULT = 293; +pub const FACILITY_DEPLOYMENT_SERVICES_BINLSVC: HRESULT = 261; +pub const FACILITY_DEFRAG: HRESULT = 2304; +pub const FACILITY_DEBUGGERS: HRESULT = 176; +pub const FACILITY_CONFIGURATION: HRESULT = 33; +pub const FACILITY_COMPLUS: HRESULT = 17; +pub const FACILITY_USERMODE_COMMONLOG: HRESULT = 26; +pub const FACILITY_CMI: HRESULT = 54; +pub const FACILITY_CERT: HRESULT = 11; +pub const FACILITY_BLUETOOTH_ATT: HRESULT = 101; +pub const FACILITY_BCD: HRESULT = 57; +pub const FACILITY_BACKGROUNDCOPY: HRESULT = 32; +pub const FACILITY_AUDIOSTREAMING: HRESULT = 1094; +pub const FACILITY_AUDCLNT: HRESULT = 2185; +pub const FACILITY_AUDIO: HRESULT = 102; +pub const FACILITY_ACTION_QUEUE: HRESULT = 44; +pub const FACILITY_ACS: HRESULT = 20; +pub const FACILITY_AAF: HRESULT = 18; +pub const ERROR_SUCCESS: DWORD = 0; +pub const NO_ERROR: DWORD = 0; +pub const SEC_E_OK: HRESULT = 0; +pub const ERROR_INVALID_FUNCTION: DWORD = 1; +pub const ERROR_FILE_NOT_FOUND: DWORD = 2; +pub const ERROR_PATH_NOT_FOUND: DWORD = 3; +pub const ERROR_TOO_MANY_OPEN_FILES: DWORD = 4; +pub const ERROR_ACCESS_DENIED: DWORD = 5; +pub const ERROR_INVALID_HANDLE: DWORD = 6; +pub const ERROR_ARENA_TRASHED: DWORD = 7; +pub const ERROR_NOT_ENOUGH_MEMORY: DWORD = 8; +pub const ERROR_INVALID_BLOCK: DWORD = 9; +pub const ERROR_BAD_ENVIRONMENT: DWORD = 10; +pub const ERROR_BAD_FORMAT: DWORD = 11; +pub const ERROR_INVALID_ACCESS: DWORD = 12; +pub const ERROR_INVALID_DATA: DWORD = 13; +pub const ERROR_OUTOFMEMORY: DWORD = 14; +pub const ERROR_INVALID_DRIVE: DWORD = 15; +pub const ERROR_CURRENT_DIRECTORY: DWORD = 16; +pub const ERROR_NOT_SAME_DEVICE: DWORD = 17; +pub const ERROR_NO_MORE_FILES: DWORD = 18; +pub const ERROR_WRITE_PROTECT: DWORD = 19; +pub const ERROR_BAD_UNIT: DWORD = 20; +pub const ERROR_NOT_READY: DWORD = 21; +pub const ERROR_BAD_COMMAND: DWORD = 22; +pub const ERROR_CRC: DWORD = 23; +pub const ERROR_BAD_LENGTH: DWORD = 24; +pub const ERROR_SEEK: DWORD = 25; +pub const ERROR_NOT_DOS_DISK: DWORD = 26; +pub const ERROR_SECTOR_NOT_FOUND: DWORD = 27; +pub const ERROR_OUT_OF_PAPER: DWORD = 28; +pub const ERROR_WRITE_FAULT: DWORD = 29; +pub const ERROR_READ_FAULT: DWORD = 30; +pub const ERROR_GEN_FAILURE: DWORD = 31; +pub const ERROR_SHARING_VIOLATION: DWORD = 32; +pub const ERROR_LOCK_VIOLATION: DWORD = 33; +pub const ERROR_WRONG_DISK: DWORD = 34; +pub const ERROR_SHARING_BUFFER_EXCEEDED: DWORD = 36; +pub const ERROR_HANDLE_EOF: DWORD = 38; +pub const ERROR_HANDLE_DISK_FULL: DWORD = 39; +pub const ERROR_NOT_SUPPORTED: DWORD = 50; +pub const ERROR_REM_NOT_LIST: DWORD = 51; +pub const ERROR_DUP_NAME: DWORD = 52; +pub const ERROR_BAD_NETPATH: DWORD = 53; +pub const ERROR_NETWORK_BUSY: DWORD = 54; +pub const ERROR_DEV_NOT_EXIST: DWORD = 55; +pub const ERROR_TOO_MANY_CMDS: DWORD = 56; +pub const ERROR_ADAP_HDW_ERR: DWORD = 57; +pub const ERROR_BAD_NET_RESP: DWORD = 58; +pub const ERROR_UNEXP_NET_ERR: DWORD = 59; +pub const ERROR_BAD_REM_ADAP: DWORD = 60; +pub const ERROR_PRINTQ_FULL: DWORD = 61; +pub const ERROR_NO_SPOOL_SPACE: DWORD = 62; +pub const ERROR_PRINT_CANCELLED: DWORD = 63; +pub const ERROR_NETNAME_DELETED: DWORD = 64; +pub const ERROR_NETWORK_ACCESS_DENIED: DWORD = 65; +pub const ERROR_BAD_DEV_TYPE: DWORD = 66; +pub const ERROR_BAD_NET_NAME: DWORD = 67; +pub const ERROR_TOO_MANY_NAMES: DWORD = 68; +pub const ERROR_TOO_MANY_SESS: DWORD = 69; +pub const ERROR_SHARING_PAUSED: DWORD = 70; +pub const ERROR_REQ_NOT_ACCEP: DWORD = 71; +pub const ERROR_REDIR_PAUSED: DWORD = 72; +pub const ERROR_FILE_EXISTS: DWORD = 80; +pub const ERROR_CANNOT_MAKE: DWORD = 82; +pub const ERROR_FAIL_I24: DWORD = 83; +pub const ERROR_OUT_OF_STRUCTURES: DWORD = 84; +pub const ERROR_ALREADY_ASSIGNED: DWORD = 85; +pub const ERROR_INVALID_PASSWORD: DWORD = 86; +pub const ERROR_INVALID_PARAMETER: DWORD = 87; +pub const ERROR_NET_WRITE_FAULT: DWORD = 88; +pub const ERROR_NO_PROC_SLOTS: DWORD = 89; +pub const ERROR_TOO_MANY_SEMAPHORES: DWORD = 100; +pub const ERROR_EXCL_SEM_ALREADY_OWNED: DWORD = 101; +pub const ERROR_SEM_IS_SET: DWORD = 102; +pub const ERROR_TOO_MANY_SEM_REQUESTS: DWORD = 103; +pub const ERROR_INVALID_AT_INTERRUPT_TIME: DWORD = 104; +pub const ERROR_SEM_OWNER_DIED: DWORD = 105; +pub const ERROR_SEM_USER_LIMIT: DWORD = 106; +pub const ERROR_DISK_CHANGE: DWORD = 107; +pub const ERROR_DRIVE_LOCKED: DWORD = 108; +pub const ERROR_BROKEN_PIPE: DWORD = 109; +pub const ERROR_OPEN_FAILED: DWORD = 110; +pub const ERROR_BUFFER_OVERFLOW: DWORD = 111; +pub const ERROR_DISK_FULL: DWORD = 112; +pub const ERROR_NO_MORE_SEARCH_HANDLES: DWORD = 113; +pub const ERROR_INVALID_TARGET_HANDLE: DWORD = 114; +pub const ERROR_INVALID_CATEGORY: DWORD = 117; +pub const ERROR_INVALID_VERIFY_SWITCH: DWORD = 118; +pub const ERROR_BAD_DRIVER_LEVEL: DWORD = 119; +pub const ERROR_CALL_NOT_IMPLEMENTED: DWORD = 120; +pub const ERROR_SEM_TIMEOUT: DWORD = 121; +pub const ERROR_INSUFFICIENT_BUFFER: DWORD = 122; +pub const ERROR_INVALID_NAME: DWORD = 123; +pub const ERROR_INVALID_LEVEL: DWORD = 124; +pub const ERROR_NO_VOLUME_LABEL: DWORD = 125; +pub const ERROR_MOD_NOT_FOUND: DWORD = 126; +pub const ERROR_PROC_NOT_FOUND: DWORD = 127; +pub const ERROR_WAIT_NO_CHILDREN: DWORD = 128; +pub const ERROR_CHILD_NOT_COMPLETE: DWORD = 129; +pub const ERROR_DIRECT_ACCESS_HANDLE: DWORD = 130; +pub const ERROR_NEGATIVE_SEEK: DWORD = 131; +pub const ERROR_SEEK_ON_DEVICE: DWORD = 132; +pub const ERROR_IS_JOIN_TARGET: DWORD = 133; +pub const ERROR_IS_JOINED: DWORD = 134; +pub const ERROR_IS_SUBSTED: DWORD = 135; +pub const ERROR_NOT_JOINED: DWORD = 136; +pub const ERROR_NOT_SUBSTED: DWORD = 137; +pub const ERROR_JOIN_TO_JOIN: DWORD = 138; +pub const ERROR_SUBST_TO_SUBST: DWORD = 139; +pub const ERROR_JOIN_TO_SUBST: DWORD = 140; +pub const ERROR_SUBST_TO_JOIN: DWORD = 141; +pub const ERROR_BUSY_DRIVE: DWORD = 142; +pub const ERROR_SAME_DRIVE: DWORD = 143; +pub const ERROR_DIR_NOT_ROOT: DWORD = 144; +pub const ERROR_DIR_NOT_EMPTY: DWORD = 145; +pub const ERROR_IS_SUBST_PATH: DWORD = 146; +pub const ERROR_IS_JOIN_PATH: DWORD = 147; +pub const ERROR_PATH_BUSY: DWORD = 148; +pub const ERROR_IS_SUBST_TARGET: DWORD = 149; +pub const ERROR_SYSTEM_TRACE: DWORD = 150; +pub const ERROR_INVALID_EVENT_COUNT: DWORD = 151; +pub const ERROR_TOO_MANY_MUXWAITERS: DWORD = 152; +pub const ERROR_INVALID_LIST_FORMAT: DWORD = 153; +pub const ERROR_LABEL_TOO_LONG: DWORD = 154; +pub const ERROR_TOO_MANY_TCBS: DWORD = 155; +pub const ERROR_SIGNAL_REFUSED: DWORD = 156; +pub const ERROR_DISCARDED: DWORD = 157; +pub const ERROR_NOT_LOCKED: DWORD = 158; +pub const ERROR_BAD_THREADID_ADDR: DWORD = 159; +pub const ERROR_BAD_ARGUMENTS: DWORD = 160; +pub const ERROR_BAD_PATHNAME: DWORD = 161; +pub const ERROR_SIGNAL_PENDING: DWORD = 162; +pub const ERROR_MAX_THRDS_REACHED: DWORD = 164; +pub const ERROR_LOCK_FAILED: DWORD = 167; +pub const ERROR_BUSY: DWORD = 170; +pub const ERROR_DEVICE_SUPPORT_IN_PROGRESS: DWORD = 171; +pub const ERROR_CANCEL_VIOLATION: DWORD = 173; +pub const ERROR_ATOMIC_LOCKS_NOT_SUPPORTED: DWORD = 174; +pub const ERROR_INVALID_SEGMENT_NUMBER: DWORD = 180; +pub const ERROR_INVALID_ORDINAL: DWORD = 182; +pub const ERROR_ALREADY_EXISTS: DWORD = 183; +pub const ERROR_INVALID_FLAG_NUMBER: DWORD = 186; +pub const ERROR_SEM_NOT_FOUND: DWORD = 187; +pub const ERROR_INVALID_STARTING_CODESEG: DWORD = 188; +pub const ERROR_INVALID_STACKSEG: DWORD = 189; +pub const ERROR_INVALID_MODULETYPE: DWORD = 190; +pub const ERROR_INVALID_EXE_SIGNATURE: DWORD = 191; +pub const ERROR_EXE_MARKED_INVALID: DWORD = 192; +pub const ERROR_BAD_EXE_FORMAT: DWORD = 193; +pub const ERROR_ITERATED_DATA_EXCEEDS_64k: DWORD = 194; +pub const ERROR_INVALID_MINALLOCSIZE: DWORD = 195; +pub const ERROR_DYNLINK_FROM_INVALID_RING: DWORD = 196; +pub const ERROR_IOPL_NOT_ENABLED: DWORD = 197; +pub const ERROR_INVALID_SEGDPL: DWORD = 198; +pub const ERROR_AUTODATASEG_EXCEEDS_64k: DWORD = 199; +pub const ERROR_RING2SEG_MUST_BE_MOVABLE: DWORD = 200; +pub const ERROR_RELOC_CHAIN_XEEDS_SEGLIM: DWORD = 201; +pub const ERROR_INFLOOP_IN_RELOC_CHAIN: DWORD = 202; +pub const ERROR_ENVVAR_NOT_FOUND: DWORD = 203; +pub const ERROR_NO_SIGNAL_SENT: DWORD = 205; +pub const ERROR_FILENAME_EXCED_RANGE: DWORD = 206; +pub const ERROR_RING2_STACK_IN_USE: DWORD = 207; +pub const ERROR_META_EXPANSION_TOO_LONG: DWORD = 208; +pub const ERROR_INVALID_SIGNAL_NUMBER: DWORD = 209; +pub const ERROR_THREAD_1_INACTIVE: DWORD = 210; +pub const ERROR_LOCKED: DWORD = 212; +pub const ERROR_TOO_MANY_MODULES: DWORD = 214; +pub const ERROR_NESTING_NOT_ALLOWED: DWORD = 215; +pub const ERROR_EXE_MACHINE_TYPE_MISMATCH: DWORD = 216; +pub const ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY: DWORD = 217; +pub const ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY: DWORD = 218; +pub const ERROR_FILE_CHECKED_OUT: DWORD = 220; +pub const ERROR_CHECKOUT_REQUIRED: DWORD = 221; +pub const ERROR_BAD_FILE_TYPE: DWORD = 222; +pub const ERROR_FILE_TOO_LARGE: DWORD = 223; +pub const ERROR_FORMS_AUTH_REQUIRED: DWORD = 224; +pub const ERROR_VIRUS_INFECTED: DWORD = 225; +pub const ERROR_VIRUS_DELETED: DWORD = 226; +pub const ERROR_PIPE_LOCAL: DWORD = 229; +pub const ERROR_BAD_PIPE: DWORD = 230; +pub const ERROR_PIPE_BUSY: DWORD = 231; +pub const ERROR_NO_DATA: DWORD = 232; +pub const ERROR_PIPE_NOT_CONNECTED: DWORD = 233; +pub const ERROR_MORE_DATA: DWORD = 234; +pub const ERROR_VC_DISCONNECTED: DWORD = 240; +pub const ERROR_INVALID_EA_NAME: DWORD = 254; +pub const ERROR_EA_LIST_INCONSISTENT: DWORD = 255; +pub const WAIT_TIMEOUT: DWORD = 258; +pub const ERROR_NO_MORE_ITEMS: DWORD = 259; +pub const ERROR_CANNOT_COPY: DWORD = 266; +pub const ERROR_DIRECTORY: DWORD = 267; +pub const ERROR_EAS_DIDNT_FIT: DWORD = 275; +pub const ERROR_EA_FILE_CORRUPT: DWORD = 276; +pub const ERROR_EA_TABLE_FULL: DWORD = 277; +pub const ERROR_INVALID_EA_HANDLE: DWORD = 278; +pub const ERROR_EAS_NOT_SUPPORTED: DWORD = 282; +pub const ERROR_NOT_OWNER: DWORD = 288; +pub const ERROR_TOO_MANY_POSTS: DWORD = 298; +pub const ERROR_PARTIAL_COPY: DWORD = 299; +pub const ERROR_OPLOCK_NOT_GRANTED: DWORD = 300; +pub const ERROR_INVALID_OPLOCK_PROTOCOL: DWORD = 301; +pub const ERROR_DISK_TOO_FRAGMENTED: DWORD = 302; +pub const ERROR_DELETE_PENDING: DWORD = 303; +pub const ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING: DWORD = 304; +pub const ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME: DWORD = 305; +pub const ERROR_SECURITY_STREAM_IS_INCONSISTENT: DWORD = 306; +pub const ERROR_INVALID_LOCK_RANGE: DWORD = 307; +pub const ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT: DWORD = 308; +pub const ERROR_NOTIFICATION_GUID_ALREADY_DEFINED: DWORD = 309; +pub const ERROR_INVALID_EXCEPTION_HANDLER: DWORD = 310; +pub const ERROR_DUPLICATE_PRIVILEGES: DWORD = 311; +pub const ERROR_NO_RANGES_PROCESSED: DWORD = 312; +pub const ERROR_NOT_ALLOWED_ON_SYSTEM_FILE: DWORD = 313; +pub const ERROR_DISK_RESOURCES_EXHAUSTED: DWORD = 314; +pub const ERROR_INVALID_TOKEN: DWORD = 315; +pub const ERROR_DEVICE_FEATURE_NOT_SUPPORTED: DWORD = 316; +pub const ERROR_MR_MID_NOT_FOUND: DWORD = 317; +pub const ERROR_SCOPE_NOT_FOUND: DWORD = 318; +pub const ERROR_UNDEFINED_SCOPE: DWORD = 319; +pub const ERROR_INVALID_CAP: DWORD = 320; +pub const ERROR_DEVICE_UNREACHABLE: DWORD = 321; +pub const ERROR_DEVICE_NO_RESOURCES: DWORD = 322; +pub const ERROR_DATA_CHECKSUM_ERROR: DWORD = 323; +pub const ERROR_INTERMIXED_KERNEL_EA_OPERATION: DWORD = 324; +pub const ERROR_FILE_LEVEL_TRIM_NOT_SUPPORTED: DWORD = 326; +pub const ERROR_OFFSET_ALIGNMENT_VIOLATION: DWORD = 327; +pub const ERROR_INVALID_FIELD_IN_PARAMETER_LIST: DWORD = 328; +pub const ERROR_OPERATION_IN_PROGRESS: DWORD = 329; +pub const ERROR_BAD_DEVICE_PATH: DWORD = 330; +pub const ERROR_TOO_MANY_DESCRIPTORS: DWORD = 331; +pub const ERROR_SCRUB_DATA_DISABLED: DWORD = 332; +pub const ERROR_NOT_REDUNDANT_STORAGE: DWORD = 333; +pub const ERROR_RESIDENT_FILE_NOT_SUPPORTED: DWORD = 334; +pub const ERROR_COMPRESSED_FILE_NOT_SUPPORTED: DWORD = 335; +pub const ERROR_DIRECTORY_NOT_SUPPORTED: DWORD = 336; +pub const ERROR_NOT_READ_FROM_COPY: DWORD = 337; +pub const ERROR_FT_WRITE_FAILURE: DWORD = 338; +pub const ERROR_FT_DI_SCAN_REQUIRED: DWORD = 339; +pub const ERROR_INVALID_KERNEL_INFO_VERSION: DWORD = 340; +pub const ERROR_INVALID_PEP_INFO_VERSION: DWORD = 341; +pub const ERROR_OBJECT_NOT_EXTERNALLY_BACKED: DWORD = 342; +pub const ERROR_EXTERNAL_BACKING_PROVIDER_UNKNOWN: DWORD = 343; +pub const ERROR_ENCLAVE_FAILURE: DWORD = 349; +pub const ERROR_FAIL_NOACTION_REBOOT: DWORD = 350; +pub const ERROR_FAIL_SHUTDOWN: DWORD = 351; +pub const ERROR_FAIL_RESTART: DWORD = 352; +pub const ERROR_MAX_SESSIONS_REACHED: DWORD = 353; +pub const ERROR_THREAD_MODE_ALREADY_BACKGROUND: DWORD = 400; +pub const ERROR_THREAD_MODE_NOT_BACKGROUND: DWORD = 401; +pub const ERROR_PROCESS_MODE_ALREADY_BACKGROUND: DWORD = 402; +pub const ERROR_PROCESS_MODE_NOT_BACKGROUND: DWORD = 403; +pub const ERROR_DEVICE_HARDWARE_ERROR: DWORD = 483; +pub const ERROR_INVALID_ADDRESS: DWORD = 487; +pub const ERROR_USER_PROFILE_LOAD: DWORD = 500; +pub const ERROR_ARITHMETIC_OVERFLOW: DWORD = 534; +pub const ERROR_PIPE_CONNECTED: DWORD = 535; +pub const ERROR_PIPE_LISTENING: DWORD = 536; +pub const ERROR_VERIFIER_STOP: DWORD = 537; +pub const ERROR_ABIOS_ERROR: DWORD = 538; +pub const ERROR_WX86_WARNING: DWORD = 539; +pub const ERROR_WX86_ERROR: DWORD = 540; +pub const ERROR_TIMER_NOT_CANCELED: DWORD = 541; +pub const ERROR_UNWIND: DWORD = 542; +pub const ERROR_BAD_STACK: DWORD = 543; +pub const ERROR_INVALID_UNWIND_TARGET: DWORD = 544; +pub const ERROR_INVALID_PORT_ATTRIBUTES: DWORD = 545; +pub const ERROR_PORT_MESSAGE_TOO_LONG: DWORD = 546; +pub const ERROR_INVALID_QUOTA_LOWER: DWORD = 547; +pub const ERROR_DEVICE_ALREADY_ATTACHED: DWORD = 548; +pub const ERROR_INSTRUCTION_MISALIGNMENT: DWORD = 549; +pub const ERROR_PROFILING_NOT_STARTED: DWORD = 550; +pub const ERROR_PROFILING_NOT_STOPPED: DWORD = 551; +pub const ERROR_COULD_NOT_INTERPRET: DWORD = 552; +pub const ERROR_PROFILING_AT_LIMIT: DWORD = 553; +pub const ERROR_CANT_WAIT: DWORD = 554; +pub const ERROR_CANT_TERMINATE_SELF: DWORD = 555; +pub const ERROR_UNEXPECTED_MM_CREATE_ERR: DWORD = 556; +pub const ERROR_UNEXPECTED_MM_MAP_ERROR: DWORD = 557; +pub const ERROR_UNEXPECTED_MM_EXTEND_ERR: DWORD = 558; +pub const ERROR_BAD_FUNCTION_TABLE: DWORD = 559; +pub const ERROR_NO_GUID_TRANSLATION: DWORD = 560; +pub const ERROR_INVALID_LDT_SIZE: DWORD = 561; +pub const ERROR_INVALID_LDT_OFFSET: DWORD = 563; +pub const ERROR_INVALID_LDT_DESCRIPTOR: DWORD = 564; +pub const ERROR_TOO_MANY_THREADS: DWORD = 565; +pub const ERROR_THREAD_NOT_IN_PROCESS: DWORD = 566; +pub const ERROR_PAGEFILE_QUOTA_EXCEEDED: DWORD = 567; +pub const ERROR_LOGON_SERVER_CONFLICT: DWORD = 568; +pub const ERROR_SYNCHRONIZATION_REQUIRED: DWORD = 569; +pub const ERROR_NET_OPEN_FAILED: DWORD = 570; +pub const ERROR_IO_PRIVILEGE_FAILED: DWORD = 571; +pub const ERROR_CONTROL_C_EXIT: DWORD = 572; +pub const ERROR_MISSING_SYSTEMFILE: DWORD = 573; +pub const ERROR_UNHANDLED_EXCEPTION: DWORD = 574; +pub const ERROR_APP_INIT_FAILURE: DWORD = 575; +pub const ERROR_PAGEFILE_CREATE_FAILED: DWORD = 576; +pub const ERROR_INVALID_IMAGE_HASH: DWORD = 577; +pub const ERROR_NO_PAGEFILE: DWORD = 578; +pub const ERROR_ILLEGAL_FLOAT_CONTEXT: DWORD = 579; +pub const ERROR_NO_EVENT_PAIR: DWORD = 580; +pub const ERROR_DOMAIN_CTRLR_CONFIG_ERROR: DWORD = 581; +pub const ERROR_ILLEGAL_CHARACTER: DWORD = 582; +pub const ERROR_UNDEFINED_CHARACTER: DWORD = 583; +pub const ERROR_FLOPPY_VOLUME: DWORD = 584; +pub const ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT: DWORD = 585; +pub const ERROR_BACKUP_CONTROLLER: DWORD = 586; +pub const ERROR_MUTANT_LIMIT_EXCEEDED: DWORD = 587; +pub const ERROR_FS_DRIVER_REQUIRED: DWORD = 588; +pub const ERROR_CANNOT_LOAD_REGISTRY_FILE: DWORD = 589; +pub const ERROR_DEBUG_ATTACH_FAILED: DWORD = 590; +pub const ERROR_SYSTEM_PROCESS_TERMINATED: DWORD = 591; +pub const ERROR_DATA_NOT_ACCEPTED: DWORD = 592; +pub const ERROR_VDM_HARD_ERROR: DWORD = 593; +pub const ERROR_DRIVER_CANCEL_TIMEOUT: DWORD = 594; +pub const ERROR_REPLY_MESSAGE_MISMATCH: DWORD = 595; +pub const ERROR_LOST_WRITEBEHIND_DATA: DWORD = 596; +pub const ERROR_CLIENT_SERVER_PARAMETERS_INVALID: DWORD = 597; +pub const ERROR_NOT_TINY_STREAM: DWORD = 598; +pub const ERROR_STACK_OVERFLOW_READ: DWORD = 599; +pub const ERROR_CONVERT_TO_LARGE: DWORD = 600; +pub const ERROR_FOUND_OUT_OF_SCOPE: DWORD = 601; +pub const ERROR_ALLOCATE_BUCKET: DWORD = 602; +pub const ERROR_MARSHALL_OVERFLOW: DWORD = 603; +pub const ERROR_INVALID_VARIANT: DWORD = 604; +pub const ERROR_BAD_COMPRESSION_BUFFER: DWORD = 605; +pub const ERROR_AUDIT_FAILED: DWORD = 606; +pub const ERROR_TIMER_RESOLUTION_NOT_SET: DWORD = 607; +pub const ERROR_INSUFFICIENT_LOGON_INFO: DWORD = 608; +pub const ERROR_BAD_DLL_ENTRYPOINT: DWORD = 609; +pub const ERROR_BAD_SERVICE_ENTRYPOINT: DWORD = 610; +pub const ERROR_IP_ADDRESS_CONFLICT1: DWORD = 611; +pub const ERROR_IP_ADDRESS_CONFLICT2: DWORD = 612; +pub const ERROR_REGISTRY_QUOTA_LIMIT: DWORD = 613; +pub const ERROR_NO_CALLBACK_ACTIVE: DWORD = 614; +pub const ERROR_PWD_TOO_SHORT: DWORD = 615; +pub const ERROR_PWD_TOO_RECENT: DWORD = 616; +pub const ERROR_PWD_HISTORY_CONFLICT: DWORD = 617; +pub const ERROR_UNSUPPORTED_COMPRESSION: DWORD = 618; +pub const ERROR_INVALID_HW_PROFILE: DWORD = 619; +pub const ERROR_INVALID_PLUGPLAY_DEVICE_PATH: DWORD = 620; +pub const ERROR_QUOTA_LIST_INCONSISTENT: DWORD = 621; +pub const ERROR_EVALUATION_EXPIRATION: DWORD = 622; +pub const ERROR_ILLEGAL_DLL_RELOCATION: DWORD = 623; +pub const ERROR_DLL_INIT_FAILED_LOGOFF: DWORD = 624; +pub const ERROR_VALIDATE_CONTINUE: DWORD = 625; +pub const ERROR_NO_MORE_MATCHES: DWORD = 626; +pub const ERROR_RANGE_LIST_CONFLICT: DWORD = 627; +pub const ERROR_SERVER_SID_MISMATCH: DWORD = 628; +pub const ERROR_CANT_ENABLE_DENY_ONLY: DWORD = 629; +pub const ERROR_FLOAT_MULTIPLE_FAULTS: DWORD = 630; +pub const ERROR_FLOAT_MULTIPLE_TRAPS: DWORD = 631; +pub const ERROR_NOINTERFACE: DWORD = 632; +pub const ERROR_DRIVER_FAILED_SLEEP: DWORD = 633; +pub const ERROR_CORRUPT_SYSTEM_FILE: DWORD = 634; +pub const ERROR_COMMITMENT_MINIMUM: DWORD = 635; +pub const ERROR_PNP_RESTART_ENUMERATION: DWORD = 636; +pub const ERROR_SYSTEM_IMAGE_BAD_SIGNATURE: DWORD = 637; +pub const ERROR_PNP_REBOOT_REQUIRED: DWORD = 638; +pub const ERROR_INSUFFICIENT_POWER: DWORD = 639; +pub const ERROR_MULTIPLE_FAULT_VIOLATION: DWORD = 640; +pub const ERROR_SYSTEM_SHUTDOWN: DWORD = 641; +pub const ERROR_PORT_NOT_SET: DWORD = 642; +pub const ERROR_DS_VERSION_CHECK_FAILURE: DWORD = 643; +pub const ERROR_RANGE_NOT_FOUND: DWORD = 644; +pub const ERROR_NOT_SAFE_MODE_DRIVER: DWORD = 646; +pub const ERROR_FAILED_DRIVER_ENTRY: DWORD = 647; +pub const ERROR_DEVICE_ENUMERATION_ERROR: DWORD = 648; +pub const ERROR_MOUNT_POINT_NOT_RESOLVED: DWORD = 649; +pub const ERROR_INVALID_DEVICE_OBJECT_PARAMETER: DWORD = 650; +pub const ERROR_MCA_OCCURED: DWORD = 651; +pub const ERROR_DRIVER_DATABASE_ERROR: DWORD = 652; +pub const ERROR_SYSTEM_HIVE_TOO_LARGE: DWORD = 653; +pub const ERROR_DRIVER_FAILED_PRIOR_UNLOAD: DWORD = 654; +pub const ERROR_VOLSNAP_PREPARE_HIBERNATE: DWORD = 655; +pub const ERROR_HIBERNATION_FAILURE: DWORD = 656; +pub const ERROR_PWD_TOO_LONG: DWORD = 657; +pub const ERROR_FILE_SYSTEM_LIMITATION: DWORD = 665; +pub const ERROR_ASSERTION_FAILURE: DWORD = 668; +pub const ERROR_ACPI_ERROR: DWORD = 669; +pub const ERROR_WOW_ASSERTION: DWORD = 670; +pub const ERROR_PNP_BAD_MPS_TABLE: DWORD = 671; +pub const ERROR_PNP_TRANSLATION_FAILED: DWORD = 672; +pub const ERROR_PNP_IRQ_TRANSLATION_FAILED: DWORD = 673; +pub const ERROR_PNP_INVALID_ID: DWORD = 674; +pub const ERROR_WAKE_SYSTEM_DEBUGGER: DWORD = 675; +pub const ERROR_HANDLES_CLOSED: DWORD = 676; +pub const ERROR_EXTRANEOUS_INFORMATION: DWORD = 677; +pub const ERROR_RXACT_COMMIT_NECESSARY: DWORD = 678; +pub const ERROR_MEDIA_CHECK: DWORD = 679; +pub const ERROR_GUID_SUBSTITUTION_MADE: DWORD = 680; +pub const ERROR_STOPPED_ON_SYMLINK: DWORD = 681; +pub const ERROR_LONGJUMP: DWORD = 682; +pub const ERROR_PLUGPLAY_QUERY_VETOED: DWORD = 683; +pub const ERROR_UNWIND_CONSOLIDATE: DWORD = 684; +pub const ERROR_REGISTRY_HIVE_RECOVERED: DWORD = 685; +pub const ERROR_DLL_MIGHT_BE_INSECURE: DWORD = 686; +pub const ERROR_DLL_MIGHT_BE_INCOMPATIBLE: DWORD = 687; +pub const ERROR_DBG_EXCEPTION_NOT_HANDLED: DWORD = 688; +pub const ERROR_DBG_REPLY_LATER: DWORD = 689; +pub const ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE: DWORD = 690; +pub const ERROR_DBG_TERMINATE_THREAD: DWORD = 691; +pub const ERROR_DBG_TERMINATE_PROCESS: DWORD = 692; +pub const ERROR_DBG_CONTROL_C: DWORD = 693; +pub const ERROR_DBG_PRINTEXCEPTION_C: DWORD = 694; +pub const ERROR_DBG_RIPEXCEPTION: DWORD = 695; +pub const ERROR_DBG_CONTROL_BREAK: DWORD = 696; +pub const ERROR_DBG_COMMAND_EXCEPTION: DWORD = 697; +pub const ERROR_OBJECT_NAME_EXISTS: DWORD = 698; +pub const ERROR_THREAD_WAS_SUSPENDED: DWORD = 699; +pub const ERROR_IMAGE_NOT_AT_BASE: DWORD = 700; +pub const ERROR_RXACT_STATE_CREATED: DWORD = 701; +pub const ERROR_SEGMENT_NOTIFICATION: DWORD = 702; +pub const ERROR_BAD_CURRENT_DIRECTORY: DWORD = 703; +pub const ERROR_FT_READ_RECOVERY_FROM_BACKUP: DWORD = 704; +pub const ERROR_FT_WRITE_RECOVERY: DWORD = 705; +pub const ERROR_IMAGE_MACHINE_TYPE_MISMATCH: DWORD = 706; +pub const ERROR_RECEIVE_PARTIAL: DWORD = 707; +pub const ERROR_RECEIVE_EXPEDITED: DWORD = 708; +pub const ERROR_RECEIVE_PARTIAL_EXPEDITED: DWORD = 709; +pub const ERROR_EVENT_DONE: DWORD = 710; +pub const ERROR_EVENT_PENDING: DWORD = 711; +pub const ERROR_CHECKING_FILE_SYSTEM: DWORD = 712; +pub const ERROR_FATAL_APP_EXIT: DWORD = 713; +pub const ERROR_PREDEFINED_HANDLE: DWORD = 714; +pub const ERROR_WAS_UNLOCKED: DWORD = 715; +pub const ERROR_SERVICE_NOTIFICATION: DWORD = 716; +pub const ERROR_WAS_LOCKED: DWORD = 717; +pub const ERROR_LOG_HARD_ERROR: DWORD = 718; +pub const ERROR_ALREADY_WIN32: DWORD = 719; +pub const ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE: DWORD = 720; +pub const ERROR_NO_YIELD_PERFORMED: DWORD = 721; +pub const ERROR_TIMER_RESUME_IGNORED: DWORD = 722; +pub const ERROR_ARBITRATION_UNHANDLED: DWORD = 723; +pub const ERROR_CARDBUS_NOT_SUPPORTED: DWORD = 724; +pub const ERROR_MP_PROCESSOR_MISMATCH: DWORD = 725; +pub const ERROR_HIBERNATED: DWORD = 726; +pub const ERROR_RESUME_HIBERNATION: DWORD = 727; +pub const ERROR_FIRMWARE_UPDATED: DWORD = 728; +pub const ERROR_DRIVERS_LEAKING_LOCKED_PAGES: DWORD = 729; +pub const ERROR_WAKE_SYSTEM: DWORD = 730; +pub const ERROR_WAIT_1: DWORD = 731; +pub const ERROR_WAIT_2: DWORD = 732; +pub const ERROR_WAIT_3: DWORD = 733; +pub const ERROR_WAIT_63: DWORD = 734; +pub const ERROR_ABANDONED_WAIT_0: DWORD = 735; +pub const ERROR_ABANDONED_WAIT_63: DWORD = 736; +pub const ERROR_USER_APC: DWORD = 737; +pub const ERROR_KERNEL_APC: DWORD = 738; +pub const ERROR_ALERTED: DWORD = 739; +pub const ERROR_ELEVATION_REQUIRED: DWORD = 740; +pub const ERROR_REPARSE: DWORD = 741; +pub const ERROR_OPLOCK_BREAK_IN_PROGRESS: DWORD = 742; +pub const ERROR_VOLUME_MOUNTED: DWORD = 743; +pub const ERROR_RXACT_COMMITTED: DWORD = 744; +pub const ERROR_NOTIFY_CLEANUP: DWORD = 745; +pub const ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED: DWORD = 746; +pub const ERROR_PAGE_FAULT_TRANSITION: DWORD = 747; +pub const ERROR_PAGE_FAULT_DEMAND_ZERO: DWORD = 748; +pub const ERROR_PAGE_FAULT_COPY_ON_WRITE: DWORD = 749; +pub const ERROR_PAGE_FAULT_GUARD_PAGE: DWORD = 750; +pub const ERROR_PAGE_FAULT_PAGING_FILE: DWORD = 751; +pub const ERROR_CACHE_PAGE_LOCKED: DWORD = 752; +pub const ERROR_CRASH_DUMP: DWORD = 753; +pub const ERROR_BUFFER_ALL_ZEROS: DWORD = 754; +pub const ERROR_REPARSE_OBJECT: DWORD = 755; +pub const ERROR_RESOURCE_REQUIREMENTS_CHANGED: DWORD = 756; +pub const ERROR_TRANSLATION_COMPLETE: DWORD = 757; +pub const ERROR_NOTHING_TO_TERMINATE: DWORD = 758; +pub const ERROR_PROCESS_NOT_IN_JOB: DWORD = 759; +pub const ERROR_PROCESS_IN_JOB: DWORD = 760; +pub const ERROR_VOLSNAP_HIBERNATE_READY: DWORD = 761; +pub const ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY: DWORD = 762; +pub const ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED: DWORD = 763; +pub const ERROR_INTERRUPT_STILL_CONNECTED: DWORD = 764; +pub const ERROR_WAIT_FOR_OPLOCK: DWORD = 765; +pub const ERROR_DBG_EXCEPTION_HANDLED: DWORD = 766; +pub const ERROR_DBG_CONTINUE: DWORD = 767; +pub const ERROR_CALLBACK_POP_STACK: DWORD = 768; +pub const ERROR_COMPRESSION_DISABLED: DWORD = 769; +pub const ERROR_CANTFETCHBACKWARDS: DWORD = 770; +pub const ERROR_CANTSCROLLBACKWARDS: DWORD = 771; +pub const ERROR_ROWSNOTRELEASED: DWORD = 772; +pub const ERROR_BAD_ACCESSOR_FLAGS: DWORD = 773; +pub const ERROR_ERRORS_ENCOUNTERED: DWORD = 774; +pub const ERROR_NOT_CAPABLE: DWORD = 775; +pub const ERROR_REQUEST_OUT_OF_SEQUENCE: DWORD = 776; +pub const ERROR_VERSION_PARSE_ERROR: DWORD = 777; +pub const ERROR_BADSTARTPOSITION: DWORD = 778; +pub const ERROR_MEMORY_HARDWARE: DWORD = 779; +pub const ERROR_DISK_REPAIR_DISABLED: DWORD = 780; +pub const ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE: DWORD = 781; +pub const ERROR_SYSTEM_POWERSTATE_TRANSITION: DWORD = 782; +pub const ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION: DWORD = 783; +pub const ERROR_MCA_EXCEPTION: DWORD = 784; +pub const ERROR_ACCESS_AUDIT_BY_POLICY: DWORD = 785; +pub const ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY: DWORD = 786; +pub const ERROR_ABANDON_HIBERFILE: DWORD = 787; +pub const ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED: DWORD = 788; +pub const ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR: DWORD = 789; +pub const ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR: DWORD = 790; +pub const ERROR_BAD_MCFG_TABLE: DWORD = 791; +pub const ERROR_DISK_REPAIR_REDIRECTED: DWORD = 792; +pub const ERROR_DISK_REPAIR_UNSUCCESSFUL: DWORD = 793; +pub const ERROR_CORRUPT_LOG_OVERFULL: DWORD = 794; +pub const ERROR_CORRUPT_LOG_CORRUPTED: DWORD = 795; +pub const ERROR_CORRUPT_LOG_UNAVAILABLE: DWORD = 796; +pub const ERROR_CORRUPT_LOG_DELETED_FULL: DWORD = 797; +pub const ERROR_CORRUPT_LOG_CLEARED: DWORD = 798; +pub const ERROR_ORPHAN_NAME_EXHAUSTED: DWORD = 799; +pub const ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE: DWORD = 800; +pub const ERROR_CANNOT_GRANT_REQUESTED_OPLOCK: DWORD = 801; +pub const ERROR_CANNOT_BREAK_OPLOCK: DWORD = 802; +pub const ERROR_OPLOCK_HANDLE_CLOSED: DWORD = 803; +pub const ERROR_NO_ACE_CONDITION: DWORD = 804; +pub const ERROR_INVALID_ACE_CONDITION: DWORD = 805; +pub const ERROR_FILE_HANDLE_REVOKED: DWORD = 806; +pub const ERROR_IMAGE_AT_DIFFERENT_BASE: DWORD = 807; +pub const ERROR_ENCRYPTED_IO_NOT_POSSIBLE: DWORD = 808; +pub const ERROR_EA_ACCESS_DENIED: DWORD = 994; +pub const ERROR_OPERATION_ABORTED: DWORD = 995; +pub const ERROR_IO_INCOMPLETE: DWORD = 996; +pub const ERROR_IO_PENDING: DWORD = 997; +pub const ERROR_NOACCESS: DWORD = 998; +pub const ERROR_SWAPERROR: DWORD = 999; +pub const ERROR_STACK_OVERFLOW: DWORD = 1001; +pub const ERROR_INVALID_MESSAGE: DWORD = 1002; +pub const ERROR_CAN_NOT_COMPLETE: DWORD = 1003; +pub const ERROR_INVALID_FLAGS: DWORD = 1004; +pub const ERROR_UNRECOGNIZED_VOLUME: DWORD = 1005; +pub const ERROR_FILE_INVALID: DWORD = 1006; +pub const ERROR_FULLSCREEN_MODE: DWORD = 1007; +pub const ERROR_NO_TOKEN: DWORD = 1008; +pub const ERROR_BADDB: DWORD = 1009; +pub const ERROR_BADKEY: DWORD = 1010; +pub const ERROR_CANTOPEN: DWORD = 1011; +pub const ERROR_CANTREAD: DWORD = 1012; +pub const ERROR_CANTWRITE: DWORD = 1013; +pub const ERROR_REGISTRY_RECOVERED: DWORD = 1014; +pub const ERROR_REGISTRY_CORRUPT: DWORD = 1015; +pub const ERROR_REGISTRY_IO_FAILED: DWORD = 1016; +pub const ERROR_NOT_REGISTRY_FILE: DWORD = 1017; +pub const ERROR_KEY_DELETED: DWORD = 1018; +pub const ERROR_NO_LOG_SPACE: DWORD = 1019; +pub const ERROR_KEY_HAS_CHILDREN: DWORD = 1020; +pub const ERROR_CHILD_MUST_BE_VOLATILE: DWORD = 1021; +pub const ERROR_NOTIFY_ENUM_DIR: DWORD = 1022; +pub const ERROR_DEPENDENT_SERVICES_RUNNING: DWORD = 1051; +pub const ERROR_INVALID_SERVICE_CONTROL: DWORD = 1052; +pub const ERROR_SERVICE_REQUEST_TIMEOUT: DWORD = 1053; +pub const ERROR_SERVICE_NO_THREAD: DWORD = 1054; +pub const ERROR_SERVICE_DATABASE_LOCKED: DWORD = 1055; +pub const ERROR_SERVICE_ALREADY_RUNNING: DWORD = 1056; +pub const ERROR_INVALID_SERVICE_ACCOUNT: DWORD = 1057; +pub const ERROR_SERVICE_DISABLED: DWORD = 1058; +pub const ERROR_CIRCULAR_DEPENDENCY: DWORD = 1059; +pub const ERROR_SERVICE_DOES_NOT_EXIST: DWORD = 1060; +pub const ERROR_SERVICE_CANNOT_ACCEPT_CTRL: DWORD = 1061; +pub const ERROR_SERVICE_NOT_ACTIVE: DWORD = 1062; +pub const ERROR_FAILED_SERVICE_CONTROLLER_CONNECT: DWORD = 1063; +pub const ERROR_EXCEPTION_IN_SERVICE: DWORD = 1064; +pub const ERROR_DATABASE_DOES_NOT_EXIST: DWORD = 1065; +pub const ERROR_SERVICE_SPECIFIC_ERROR: DWORD = 1066; +pub const ERROR_PROCESS_ABORTED: DWORD = 1067; +pub const ERROR_SERVICE_DEPENDENCY_FAIL: DWORD = 1068; +pub const ERROR_SERVICE_LOGON_FAILED: DWORD = 1069; +pub const ERROR_SERVICE_START_HANG: DWORD = 1070; +pub const ERROR_INVALID_SERVICE_LOCK: DWORD = 1071; +pub const ERROR_SERVICE_MARKED_FOR_DELETE: DWORD = 1072; +pub const ERROR_SERVICE_EXISTS: DWORD = 1073; +pub const ERROR_ALREADY_RUNNING_LKG: DWORD = 1074; +pub const ERROR_SERVICE_DEPENDENCY_DELETED: DWORD = 1075; +pub const ERROR_BOOT_ALREADY_ACCEPTED: DWORD = 1076; +pub const ERROR_SERVICE_NEVER_STARTED: DWORD = 1077; +pub const ERROR_DUPLICATE_SERVICE_NAME: DWORD = 1078; +pub const ERROR_DIFFERENT_SERVICE_ACCOUNT: DWORD = 1079; +pub const ERROR_CANNOT_DETECT_DRIVER_FAILURE: DWORD = 1080; +pub const ERROR_CANNOT_DETECT_PROCESS_ABORT: DWORD = 1081; +pub const ERROR_NO_RECOVERY_PROGRAM: DWORD = 1082; +pub const ERROR_SERVICE_NOT_IN_EXE: DWORD = 1083; +pub const ERROR_NOT_SAFEBOOT_SERVICE: DWORD = 1084; +pub const ERROR_END_OF_MEDIA: DWORD = 1100; +pub const ERROR_FILEMARK_DETECTED: DWORD = 1101; +pub const ERROR_BEGINNING_OF_MEDIA: DWORD = 1102; +pub const ERROR_SETMARK_DETECTED: DWORD = 1103; +pub const ERROR_NO_DATA_DETECTED: DWORD = 1104; +pub const ERROR_PARTITION_FAILURE: DWORD = 1105; +pub const ERROR_INVALID_BLOCK_LENGTH: DWORD = 1106; +pub const ERROR_DEVICE_NOT_PARTITIONED: DWORD = 1107; +pub const ERROR_UNABLE_TO_LOCK_MEDIA: DWORD = 1108; +pub const ERROR_UNABLE_TO_UNLOAD_MEDIA: DWORD = 1109; +pub const ERROR_MEDIA_CHANGED: DWORD = 1110; +pub const ERROR_BUS_RESET: DWORD = 1111; +pub const ERROR_NO_MEDIA_IN_DRIVE: DWORD = 1112; +pub const ERROR_NO_UNICODE_TRANSLATION: DWORD = 1113; +pub const ERROR_DLL_INIT_FAILED: DWORD = 1114; +pub const ERROR_SHUTDOWN_IN_PROGRESS: DWORD = 1115; +pub const ERROR_NO_SHUTDOWN_IN_PROGRESS: DWORD = 1116; +pub const ERROR_IO_DEVICE: DWORD = 1117; +pub const ERROR_SERIAL_NO_DEVICE: DWORD = 1118; +pub const ERROR_IRQ_BUSY: DWORD = 1119; +pub const ERROR_MORE_WRITES: DWORD = 1120; +pub const ERROR_COUNTER_TIMEOUT: DWORD = 1121; +pub const ERROR_FLOPPY_ID_MARK_NOT_FOUND: DWORD = 1122; +pub const ERROR_FLOPPY_WRONG_CYLINDER: DWORD = 1123; +pub const ERROR_FLOPPY_UNKNOWN_ERROR: DWORD = 1124; +pub const ERROR_FLOPPY_BAD_REGISTERS: DWORD = 1125; +pub const ERROR_DISK_RECALIBRATE_FAILED: DWORD = 1126; +pub const ERROR_DISK_OPERATION_FAILED: DWORD = 1127; +pub const ERROR_DISK_RESET_FAILED: DWORD = 1128; +pub const ERROR_EOM_OVERFLOW: DWORD = 1129; +pub const ERROR_NOT_ENOUGH_SERVER_MEMORY: DWORD = 1130; +pub const ERROR_POSSIBLE_DEADLOCK: DWORD = 1131; +pub const ERROR_MAPPED_ALIGNMENT: DWORD = 1132; +pub const ERROR_SET_POWER_STATE_VETOED: DWORD = 1140; +pub const ERROR_SET_POWER_STATE_FAILED: DWORD = 1141; +pub const ERROR_TOO_MANY_LINKS: DWORD = 1142; +pub const ERROR_OLD_WIN_VERSION: DWORD = 1150; +pub const ERROR_APP_WRONG_OS: DWORD = 1151; +pub const ERROR_SINGLE_INSTANCE_APP: DWORD = 1152; +pub const ERROR_RMODE_APP: DWORD = 1153; +pub const ERROR_INVALID_DLL: DWORD = 1154; +pub const ERROR_NO_ASSOCIATION: DWORD = 1155; +pub const ERROR_DDE_FAIL: DWORD = 1156; +pub const ERROR_DLL_NOT_FOUND: DWORD = 1157; +pub const ERROR_NO_MORE_USER_HANDLES: DWORD = 1158; +pub const ERROR_MESSAGE_SYNC_ONLY: DWORD = 1159; +pub const ERROR_SOURCE_ELEMENT_EMPTY: DWORD = 1160; +pub const ERROR_DESTINATION_ELEMENT_FULL: DWORD = 1161; +pub const ERROR_ILLEGAL_ELEMENT_ADDRESS: DWORD = 1162; +pub const ERROR_MAGAZINE_NOT_PRESENT: DWORD = 1163; +pub const ERROR_DEVICE_REINITIALIZATION_NEEDED: DWORD = 1164; +pub const ERROR_DEVICE_REQUIRES_CLEANING: DWORD = 1165; +pub const ERROR_DEVICE_DOOR_OPEN: DWORD = 1166; +pub const ERROR_DEVICE_NOT_CONNECTED: DWORD = 1167; +pub const ERROR_NOT_FOUND: DWORD = 1168; +pub const ERROR_NO_MATCH: DWORD = 1169; +pub const ERROR_SET_NOT_FOUND: DWORD = 1170; +pub const ERROR_POINT_NOT_FOUND: DWORD = 1171; +pub const ERROR_NO_TRACKING_SERVICE: DWORD = 1172; +pub const ERROR_NO_VOLUME_ID: DWORD = 1173; +pub const ERROR_UNABLE_TO_REMOVE_REPLACED: DWORD = 1175; +pub const ERROR_UNABLE_TO_MOVE_REPLACEMENT: DWORD = 1176; +pub const ERROR_UNABLE_TO_MOVE_REPLACEMENT_2: DWORD = 1177; +pub const ERROR_JOURNAL_DELETE_IN_PROGRESS: DWORD = 1178; +pub const ERROR_JOURNAL_NOT_ACTIVE: DWORD = 1179; +pub const ERROR_POTENTIAL_FILE_FOUND: DWORD = 1180; +pub const ERROR_JOURNAL_ENTRY_DELETED: DWORD = 1181; +pub const ERROR_SHUTDOWN_IS_SCHEDULED: DWORD = 1190; +pub const ERROR_SHUTDOWN_USERS_LOGGED_ON: DWORD = 1191; +pub const ERROR_BAD_DEVICE: DWORD = 1200; +pub const ERROR_CONNECTION_UNAVAIL: DWORD = 1201; +pub const ERROR_DEVICE_ALREADY_REMEMBERED: DWORD = 1202; +pub const ERROR_NO_NET_OR_BAD_PATH: DWORD = 1203; +pub const ERROR_BAD_PROVIDER: DWORD = 1204; +pub const ERROR_CANNOT_OPEN_PROFILE: DWORD = 1205; +pub const ERROR_BAD_PROFILE: DWORD = 1206; +pub const ERROR_NOT_CONTAINER: DWORD = 1207; +pub const ERROR_EXTENDED_ERROR: DWORD = 1208; +pub const ERROR_INVALID_GROUPNAME: DWORD = 1209; +pub const ERROR_INVALID_COMPUTERNAME: DWORD = 1210; +pub const ERROR_INVALID_EVENTNAME: DWORD = 1211; +pub const ERROR_INVALID_DOMAINNAME: DWORD = 1212; +pub const ERROR_INVALID_SERVICENAME: DWORD = 1213; +pub const ERROR_INVALID_NETNAME: DWORD = 1214; +pub const ERROR_INVALID_SHARENAME: DWORD = 1215; +pub const ERROR_INVALID_PASSWORDNAME: DWORD = 1216; +pub const ERROR_INVALID_MESSAGENAME: DWORD = 1217; +pub const ERROR_INVALID_MESSAGEDEST: DWORD = 1218; +pub const ERROR_SESSION_CREDENTIAL_CONFLICT: DWORD = 1219; +pub const ERROR_REMOTE_SESSION_LIMIT_EXCEEDED: DWORD = 1220; +pub const ERROR_DUP_DOMAINNAME: DWORD = 1221; +pub const ERROR_NO_NETWORK: DWORD = 1222; +pub const ERROR_CANCELLED: DWORD = 1223; +pub const ERROR_USER_MAPPED_FILE: DWORD = 1224; +pub const ERROR_CONNECTION_REFUSED: DWORD = 1225; +pub const ERROR_GRACEFUL_DISCONNECT: DWORD = 1226; +pub const ERROR_ADDRESS_ALREADY_ASSOCIATED: DWORD = 1227; +pub const ERROR_ADDRESS_NOT_ASSOCIATED: DWORD = 1228; +pub const ERROR_CONNECTION_INVALID: DWORD = 1229; +pub const ERROR_CONNECTION_ACTIVE: DWORD = 1230; +pub const ERROR_NETWORK_UNREACHABLE: DWORD = 1231; +pub const ERROR_HOST_UNREACHABLE: DWORD = 1232; +pub const ERROR_PROTOCOL_UNREACHABLE: DWORD = 1233; +pub const ERROR_PORT_UNREACHABLE: DWORD = 1234; +pub const ERROR_REQUEST_ABORTED: DWORD = 1235; +pub const ERROR_CONNECTION_ABORTED: DWORD = 1236; +pub const ERROR_RETRY: DWORD = 1237; +pub const ERROR_CONNECTION_COUNT_LIMIT: DWORD = 1238; +pub const ERROR_LOGIN_TIME_RESTRICTION: DWORD = 1239; +pub const ERROR_LOGIN_WKSTA_RESTRICTION: DWORD = 1240; +pub const ERROR_INCORRECT_ADDRESS: DWORD = 1241; +pub const ERROR_ALREADY_REGISTERED: DWORD = 1242; +pub const ERROR_SERVICE_NOT_FOUND: DWORD = 1243; +pub const ERROR_NOT_AUTHENTICATED: DWORD = 1244; +pub const ERROR_NOT_LOGGED_ON: DWORD = 1245; +pub const ERROR_CONTINUE: DWORD = 1246; +pub const ERROR_ALREADY_INITIALIZED: DWORD = 1247; +pub const ERROR_NO_MORE_DEVICES: DWORD = 1248; +pub const ERROR_NO_SUCH_SITE: DWORD = 1249; +pub const ERROR_DOMAIN_CONTROLLER_EXISTS: DWORD = 1250; +pub const ERROR_ONLY_IF_CONNECTED: DWORD = 1251; +pub const ERROR_OVERRIDE_NOCHANGES: DWORD = 1252; +pub const ERROR_BAD_USER_PROFILE: DWORD = 1253; +pub const ERROR_NOT_SUPPORTED_ON_SBS: DWORD = 1254; +pub const ERROR_SERVER_SHUTDOWN_IN_PROGRESS: DWORD = 1255; +pub const ERROR_HOST_DOWN: DWORD = 1256; +pub const ERROR_NON_ACCOUNT_SID: DWORD = 1257; +pub const ERROR_NON_DOMAIN_SID: DWORD = 1258; +pub const ERROR_APPHELP_BLOCK: DWORD = 1259; +pub const ERROR_ACCESS_DISABLED_BY_POLICY: DWORD = 1260; +pub const ERROR_REG_NAT_CONSUMPTION: DWORD = 1261; +pub const ERROR_CSCSHARE_OFFLINE: DWORD = 1262; +pub const ERROR_PKINIT_FAILURE: DWORD = 1263; +pub const ERROR_SMARTCARD_SUBSYSTEM_FAILURE: DWORD = 1264; +pub const ERROR_DOWNGRADE_DETECTED: DWORD = 1265; +pub const ERROR_MACHINE_LOCKED: DWORD = 1271; +pub const ERROR_CALLBACK_SUPPLIED_INVALID_DATA: DWORD = 1273; +pub const ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED: DWORD = 1274; +pub const ERROR_DRIVER_BLOCKED: DWORD = 1275; +pub const ERROR_INVALID_IMPORT_OF_NON_DLL: DWORD = 1276; +pub const ERROR_ACCESS_DISABLED_WEBBLADE: DWORD = 1277; +pub const ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER: DWORD = 1278; +pub const ERROR_RECOVERY_FAILURE: DWORD = 1279; +pub const ERROR_ALREADY_FIBER: DWORD = 1280; +pub const ERROR_ALREADY_THREAD: DWORD = 1281; +pub const ERROR_STACK_BUFFER_OVERRUN: DWORD = 1282; +pub const ERROR_PARAMETER_QUOTA_EXCEEDED: DWORD = 1283; +pub const ERROR_DEBUGGER_INACTIVE: DWORD = 1284; +pub const ERROR_DELAY_LOAD_FAILED: DWORD = 1285; +pub const ERROR_VDM_DISALLOWED: DWORD = 1286; +pub const ERROR_UNIDENTIFIED_ERROR: DWORD = 1287; +pub const ERROR_INVALID_CRUNTIME_PARAMETER: DWORD = 1288; +pub const ERROR_BEYOND_VDL: DWORD = 1289; +pub const ERROR_INCOMPATIBLE_SERVICE_SID_TYPE: DWORD = 1290; +pub const ERROR_DRIVER_PROCESS_TERMINATED: DWORD = 1291; +pub const ERROR_IMPLEMENTATION_LIMIT: DWORD = 1292; +pub const ERROR_PROCESS_IS_PROTECTED: DWORD = 1293; +pub const ERROR_SERVICE_NOTIFY_CLIENT_LAGGING: DWORD = 1294; +pub const ERROR_DISK_QUOTA_EXCEEDED: DWORD = 1295; +pub const ERROR_CONTENT_BLOCKED: DWORD = 1296; +pub const ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE: DWORD = 1297; +pub const ERROR_APP_HANG: DWORD = 1298; +pub const ERROR_INVALID_LABEL: DWORD = 1299; +pub const ERROR_NOT_ALL_ASSIGNED: DWORD = 1300; +pub const ERROR_SOME_NOT_MAPPED: DWORD = 1301; +pub const ERROR_NO_QUOTAS_FOR_ACCOUNT: DWORD = 1302; +pub const ERROR_LOCAL_USER_SESSION_KEY: DWORD = 1303; +pub const ERROR_NULL_LM_PASSWORD: DWORD = 1304; +pub const ERROR_UNKNOWN_REVISION: DWORD = 1305; +pub const ERROR_REVISION_MISMATCH: DWORD = 1306; +pub const ERROR_INVALID_OWNER: DWORD = 1307; +pub const ERROR_INVALID_PRIMARY_GROUP: DWORD = 1308; +pub const ERROR_NO_IMPERSONATION_TOKEN: DWORD = 1309; +pub const ERROR_CANT_DISABLE_MANDATORY: DWORD = 1310; +pub const ERROR_NO_LOGON_SERVERS: DWORD = 1311; +pub const ERROR_NO_SUCH_LOGON_SESSION: DWORD = 1312; +pub const ERROR_NO_SUCH_PRIVILEGE: DWORD = 1313; +pub const ERROR_PRIVILEGE_NOT_HELD: DWORD = 1314; +pub const ERROR_INVALID_ACCOUNT_NAME: DWORD = 1315; +pub const ERROR_USER_EXISTS: DWORD = 1316; +pub const ERROR_NO_SUCH_USER: DWORD = 1317; +pub const ERROR_GROUP_EXISTS: DWORD = 1318; +pub const ERROR_NO_SUCH_GROUP: DWORD = 1319; +pub const ERROR_MEMBER_IN_GROUP: DWORD = 1320; +pub const ERROR_MEMBER_NOT_IN_GROUP: DWORD = 1321; +pub const ERROR_LAST_ADMIN: DWORD = 1322; +pub const ERROR_WRONG_PASSWORD: DWORD = 1323; +pub const ERROR_ILL_FORMED_PASSWORD: DWORD = 1324; +pub const ERROR_PASSWORD_RESTRICTION: DWORD = 1325; +pub const ERROR_LOGON_FAILURE: DWORD = 1326; +pub const ERROR_ACCOUNT_RESTRICTION: DWORD = 1327; +pub const ERROR_INVALID_LOGON_HOURS: DWORD = 1328; +pub const ERROR_INVALID_WORKSTATION: DWORD = 1329; +pub const ERROR_PASSWORD_EXPIRED: DWORD = 1330; +pub const ERROR_ACCOUNT_DISABLED: DWORD = 1331; +pub const ERROR_NONE_MAPPED: DWORD = 1332; +pub const ERROR_TOO_MANY_LUIDS_REQUESTED: DWORD = 1333; +pub const ERROR_LUIDS_EXHAUSTED: DWORD = 1334; +pub const ERROR_INVALID_SUB_AUTHORITY: DWORD = 1335; +pub const ERROR_INVALID_ACL: DWORD = 1336; +pub const ERROR_INVALID_SID: DWORD = 1337; +pub const ERROR_INVALID_SECURITY_DESCR: DWORD = 1338; +pub const ERROR_BAD_INHERITANCE_ACL: DWORD = 1340; +pub const ERROR_SERVER_DISABLED: DWORD = 1341; +pub const ERROR_SERVER_NOT_DISABLED: DWORD = 1342; +pub const ERROR_INVALID_ID_AUTHORITY: DWORD = 1343; +pub const ERROR_ALLOTTED_SPACE_EXCEEDED: DWORD = 1344; +pub const ERROR_INVALID_GROUP_ATTRIBUTES: DWORD = 1345; +pub const ERROR_BAD_IMPERSONATION_LEVEL: DWORD = 1346; +pub const ERROR_CANT_OPEN_ANONYMOUS: DWORD = 1347; +pub const ERROR_BAD_VALIDATION_CLASS: DWORD = 1348; +pub const ERROR_BAD_TOKEN_TYPE: DWORD = 1349; +pub const ERROR_NO_SECURITY_ON_OBJECT: DWORD = 1350; +pub const ERROR_CANT_ACCESS_DOMAIN_INFO: DWORD = 1351; +pub const ERROR_INVALID_SERVER_STATE: DWORD = 1352; +pub const ERROR_INVALID_DOMAIN_STATE: DWORD = 1353; +pub const ERROR_INVALID_DOMAIN_ROLE: DWORD = 1354; +pub const ERROR_NO_SUCH_DOMAIN: DWORD = 1355; +pub const ERROR_DOMAIN_EXISTS: DWORD = 1356; +pub const ERROR_DOMAIN_LIMIT_EXCEEDED: DWORD = 1357; +pub const ERROR_INTERNAL_DB_CORRUPTION: DWORD = 1358; +pub const ERROR_INTERNAL_ERROR: DWORD = 1359; +pub const ERROR_GENERIC_NOT_MAPPED: DWORD = 1360; +pub const ERROR_BAD_DESCRIPTOR_FORMAT: DWORD = 1361; +pub const ERROR_NOT_LOGON_PROCESS: DWORD = 1362; +pub const ERROR_LOGON_SESSION_EXISTS: DWORD = 1363; +pub const ERROR_NO_SUCH_PACKAGE: DWORD = 1364; +pub const ERROR_BAD_LOGON_SESSION_STATE: DWORD = 1365; +pub const ERROR_LOGON_SESSION_COLLISION: DWORD = 1366; +pub const ERROR_INVALID_LOGON_TYPE: DWORD = 1367; +pub const ERROR_CANNOT_IMPERSONATE: DWORD = 1368; +pub const ERROR_RXACT_INVALID_STATE: DWORD = 1369; +pub const ERROR_RXACT_COMMIT_FAILURE: DWORD = 1370; +pub const ERROR_SPECIAL_ACCOUNT: DWORD = 1371; +pub const ERROR_SPECIAL_GROUP: DWORD = 1372; +pub const ERROR_SPECIAL_USER: DWORD = 1373; +pub const ERROR_MEMBERS_PRIMARY_GROUP: DWORD = 1374; +pub const ERROR_TOKEN_ALREADY_IN_USE: DWORD = 1375; +pub const ERROR_NO_SUCH_ALIAS: DWORD = 1376; +pub const ERROR_MEMBER_NOT_IN_ALIAS: DWORD = 1377; +pub const ERROR_MEMBER_IN_ALIAS: DWORD = 1378; +pub const ERROR_ALIAS_EXISTS: DWORD = 1379; +pub const ERROR_LOGON_NOT_GRANTED: DWORD = 1380; +pub const ERROR_TOO_MANY_SECRETS: DWORD = 1381; +pub const ERROR_SECRET_TOO_LONG: DWORD = 1382; +pub const ERROR_INTERNAL_DB_ERROR: DWORD = 1383; +pub const ERROR_TOO_MANY_CONTEXT_IDS: DWORD = 1384; +pub const ERROR_LOGON_TYPE_NOT_GRANTED: DWORD = 1385; +pub const ERROR_NT_CROSS_ENCRYPTION_REQUIRED: DWORD = 1386; +pub const ERROR_NO_SUCH_MEMBER: DWORD = 1387; +pub const ERROR_INVALID_MEMBER: DWORD = 1388; +pub const ERROR_TOO_MANY_SIDS: DWORD = 1389; +pub const ERROR_LM_CROSS_ENCRYPTION_REQUIRED: DWORD = 1390; +pub const ERROR_NO_INHERITANCE: DWORD = 1391; +pub const ERROR_FILE_CORRUPT: DWORD = 1392; +pub const ERROR_DISK_CORRUPT: DWORD = 1393; +pub const ERROR_NO_USER_SESSION_KEY: DWORD = 1394; +pub const ERROR_LICENSE_QUOTA_EXCEEDED: DWORD = 1395; +pub const ERROR_WRONG_TARGET_NAME: DWORD = 1396; +pub const ERROR_MUTUAL_AUTH_FAILED: DWORD = 1397; +pub const ERROR_TIME_SKEW: DWORD = 1398; +pub const ERROR_CURRENT_DOMAIN_NOT_ALLOWED: DWORD = 1399; +pub const ERROR_INVALID_WINDOW_HANDLE: DWORD = 1400; +pub const ERROR_INVALID_MENU_HANDLE: DWORD = 1401; +pub const ERROR_INVALID_CURSOR_HANDLE: DWORD = 1402; +pub const ERROR_INVALID_ACCEL_HANDLE: DWORD = 1403; +pub const ERROR_INVALID_HOOK_HANDLE: DWORD = 1404; +pub const ERROR_INVALID_DWP_HANDLE: DWORD = 1405; +pub const ERROR_TLW_WITH_WSCHILD: DWORD = 1406; +pub const ERROR_CANNOT_FIND_WND_CLASS: DWORD = 1407; +pub const ERROR_WINDOW_OF_OTHER_THREAD: DWORD = 1408; +pub const ERROR_HOTKEY_ALREADY_REGISTERED: DWORD = 1409; +pub const ERROR_CLASS_ALREADY_EXISTS: DWORD = 1410; +pub const ERROR_CLASS_DOES_NOT_EXIST: DWORD = 1411; +pub const ERROR_CLASS_HAS_WINDOWS: DWORD = 1412; +pub const ERROR_INVALID_INDEX: DWORD = 1413; +pub const ERROR_INVALID_ICON_HANDLE: DWORD = 1414; +pub const ERROR_PRIVATE_DIALOG_INDEX: DWORD = 1415; +pub const ERROR_LISTBOX_ID_NOT_FOUND: DWORD = 1416; +pub const ERROR_NO_WILDCARD_CHARACTERS: DWORD = 1417; +pub const ERROR_CLIPBOARD_NOT_OPEN: DWORD = 1418; +pub const ERROR_HOTKEY_NOT_REGISTERED: DWORD = 1419; +pub const ERROR_WINDOW_NOT_DIALOG: DWORD = 1420; +pub const ERROR_CONTROL_ID_NOT_FOUND: DWORD = 1421; +pub const ERROR_INVALID_COMBOBOX_MESSAGE: DWORD = 1422; +pub const ERROR_WINDOW_NOT_COMBOBOX: DWORD = 1423; +pub const ERROR_INVALID_EDIT_HEIGHT: DWORD = 1424; +pub const ERROR_DC_NOT_FOUND: DWORD = 1425; +pub const ERROR_INVALID_HOOK_FILTER: DWORD = 1426; +pub const ERROR_INVALID_FILTER_PROC: DWORD = 1427; +pub const ERROR_HOOK_NEEDS_HMOD: DWORD = 1428; +pub const ERROR_GLOBAL_ONLY_HOOK: DWORD = 1429; +pub const ERROR_JOURNAL_HOOK_SET: DWORD = 1430; +pub const ERROR_HOOK_NOT_INSTALLED: DWORD = 1431; +pub const ERROR_INVALID_LB_MESSAGE: DWORD = 1432; +pub const ERROR_SETCOUNT_ON_BAD_LB: DWORD = 1433; +pub const ERROR_LB_WITHOUT_TABSTOPS: DWORD = 1434; +pub const ERROR_DESTROY_OBJECT_OF_OTHER_THREAD: DWORD = 1435; +pub const ERROR_CHILD_WINDOW_MENU: DWORD = 1436; +pub const ERROR_NO_SYSTEM_MENU: DWORD = 1437; +pub const ERROR_INVALID_MSGBOX_STYLE: DWORD = 1438; +pub const ERROR_INVALID_SPI_VALUE: DWORD = 1439; +pub const ERROR_SCREEN_ALREADY_LOCKED: DWORD = 1440; +pub const ERROR_HWNDS_HAVE_DIFF_PARENT: DWORD = 1441; +pub const ERROR_NOT_CHILD_WINDOW: DWORD = 1442; +pub const ERROR_INVALID_GW_COMMAND: DWORD = 1443; +pub const ERROR_INVALID_THREAD_ID: DWORD = 1444; +pub const ERROR_NON_MDICHILD_WINDOW: DWORD = 1445; +pub const ERROR_POPUP_ALREADY_ACTIVE: DWORD = 1446; +pub const ERROR_NO_SCROLLBARS: DWORD = 1447; +pub const ERROR_INVALID_SCROLLBAR_RANGE: DWORD = 1448; +pub const ERROR_INVALID_SHOWWIN_COMMAND: DWORD = 1449; +pub const ERROR_NO_SYSTEM_RESOURCES: DWORD = 1450; +pub const ERROR_NONPAGED_SYSTEM_RESOURCES: DWORD = 1451; +pub const ERROR_PAGED_SYSTEM_RESOURCES: DWORD = 1452; +pub const ERROR_WORKING_SET_QUOTA: DWORD = 1453; +pub const ERROR_PAGEFILE_QUOTA: DWORD = 1454; +pub const ERROR_COMMITMENT_LIMIT: DWORD = 1455; +pub const ERROR_MENU_ITEM_NOT_FOUND: DWORD = 1456; +pub const ERROR_INVALID_KEYBOARD_HANDLE: DWORD = 1457; +pub const ERROR_HOOK_TYPE_NOT_ALLOWED: DWORD = 1458; +pub const ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION: DWORD = 1459; +pub const ERROR_TIMEOUT: DWORD = 1460; +pub const ERROR_INVALID_MONITOR_HANDLE: DWORD = 1461; +pub const ERROR_INCORRECT_SIZE: DWORD = 1462; +pub const ERROR_SYMLINK_CLASS_DISABLED: DWORD = 1463; +pub const ERROR_SYMLINK_NOT_SUPPORTED: DWORD = 1464; +pub const ERROR_XML_PARSE_ERROR: DWORD = 1465; +pub const ERROR_XMLDSIG_ERROR: DWORD = 1466; +pub const ERROR_RESTART_APPLICATION: DWORD = 1467; +pub const ERROR_WRONG_COMPARTMENT: DWORD = 1468; +pub const ERROR_AUTHIP_FAILURE: DWORD = 1469; +pub const ERROR_NO_NVRAM_RESOURCES: DWORD = 1470; +pub const ERROR_NOT_GUI_PROCESS: DWORD = 1471; +pub const ERROR_EVENTLOG_FILE_CORRUPT: DWORD = 1500; +pub const ERROR_EVENTLOG_CANT_START: DWORD = 1501; +pub const ERROR_LOG_FILE_FULL: DWORD = 1502; +pub const ERROR_EVENTLOG_FILE_CHANGED: DWORD = 1503; +pub const ERROR_INVALID_TASK_NAME: DWORD = 1550; +pub const ERROR_INVALID_TASK_INDEX: DWORD = 1551; +pub const ERROR_THREAD_ALREADY_IN_TASK: DWORD = 1552; +pub const ERROR_INSTALL_SERVICE_FAILURE: DWORD = 1601; +pub const ERROR_INSTALL_USEREXIT: DWORD = 1602; +pub const ERROR_INSTALL_FAILURE: DWORD = 1603; +pub const ERROR_INSTALL_SUSPEND: DWORD = 1604; +pub const ERROR_UNKNOWN_PRODUCT: DWORD = 1605; +pub const ERROR_UNKNOWN_FEATURE: DWORD = 1606; +pub const ERROR_UNKNOWN_COMPONENT: DWORD = 1607; +pub const ERROR_UNKNOWN_PROPERTY: DWORD = 1608; +pub const ERROR_INVALID_HANDLE_STATE: DWORD = 1609; +pub const ERROR_BAD_CONFIGURATION: DWORD = 1610; +pub const ERROR_INDEX_ABSENT: DWORD = 1611; +pub const ERROR_INSTALL_SOURCE_ABSENT: DWORD = 1612; +pub const ERROR_INSTALL_PACKAGE_VERSION: DWORD = 1613; +pub const ERROR_PRODUCT_UNINSTALLED: DWORD = 1614; +pub const ERROR_BAD_QUERY_SYNTAX: DWORD = 1615; +pub const ERROR_INVALID_FIELD: DWORD = 1616; +pub const ERROR_DEVICE_REMOVED: DWORD = 1617; +pub const ERROR_INSTALL_ALREADY_RUNNING: DWORD = 1618; +pub const ERROR_INSTALL_PACKAGE_OPEN_FAILED: DWORD = 1619; +pub const ERROR_INSTALL_PACKAGE_INVALID: DWORD = 1620; +pub const ERROR_INSTALL_UI_FAILURE: DWORD = 1621; +pub const ERROR_INSTALL_LOG_FAILURE: DWORD = 1622; +pub const ERROR_INSTALL_LANGUAGE_UNSUPPORTED: DWORD = 1623; +pub const ERROR_INSTALL_TRANSFORM_FAILURE: DWORD = 1624; +pub const ERROR_INSTALL_PACKAGE_REJECTED: DWORD = 1625; +pub const ERROR_FUNCTION_NOT_CALLED: DWORD = 1626; +pub const ERROR_FUNCTION_FAILED: DWORD = 1627; +pub const ERROR_INVALID_TABLE: DWORD = 1628; +pub const ERROR_DATATYPE_MISMATCH: DWORD = 1629; +pub const ERROR_UNSUPPORTED_TYPE: DWORD = 1630; +pub const ERROR_CREATE_FAILED: DWORD = 1631; +pub const ERROR_INSTALL_TEMP_UNWRITABLE: DWORD = 1632; +pub const ERROR_INSTALL_PLATFORM_UNSUPPORTED: DWORD = 1633; +pub const ERROR_INSTALL_NOTUSED: DWORD = 1634; +pub const ERROR_PATCH_PACKAGE_OPEN_FAILED: DWORD = 1635; +pub const ERROR_PATCH_PACKAGE_INVALID: DWORD = 1636; +pub const ERROR_PATCH_PACKAGE_UNSUPPORTED: DWORD = 1637; +pub const ERROR_PRODUCT_VERSION: DWORD = 1638; +pub const ERROR_INVALID_COMMAND_LINE: DWORD = 1639; +pub const ERROR_INSTALL_REMOTE_DISALLOWED: DWORD = 1640; +pub const ERROR_SUCCESS_REBOOT_INITIATED: DWORD = 1641; +pub const ERROR_PATCH_TARGET_NOT_FOUND: DWORD = 1642; +pub const ERROR_PATCH_PACKAGE_REJECTED: DWORD = 1643; +pub const ERROR_INSTALL_TRANSFORM_REJECTED: DWORD = 1644; +pub const ERROR_INSTALL_REMOTE_PROHIBITED: DWORD = 1645; +pub const ERROR_PATCH_REMOVAL_UNSUPPORTED: DWORD = 1646; +pub const ERROR_UNKNOWN_PATCH: DWORD = 1647; +pub const ERROR_PATCH_NO_SEQUENCE: DWORD = 1648; +pub const ERROR_PATCH_REMOVAL_DISALLOWED: DWORD = 1649; +pub const ERROR_INVALID_PATCH_XML: DWORD = 1650; +pub const ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT: DWORD = 1651; +pub const ERROR_INSTALL_SERVICE_SAFEBOOT: DWORD = 1652; +pub const ERROR_FAIL_FAST_EXCEPTION: DWORD = 1653; +pub const ERROR_INSTALL_REJECTED: DWORD = 1654; +pub const ERROR_DYNAMIC_CODE_BLOCKED: DWORD = 1655; +pub const RPC_S_INVALID_STRING_BINDING: DWORD = 1700; +pub const RPC_S_WRONG_KIND_OF_BINDING: DWORD = 1701; +pub const RPC_S_INVALID_BINDING: DWORD = 1702; +pub const RPC_S_PROTSEQ_NOT_SUPPORTED: DWORD = 1703; +pub const RPC_S_INVALID_RPC_PROTSEQ: DWORD = 1704; +pub const RPC_S_INVALID_STRING_UUID: DWORD = 1705; +pub const RPC_S_INVALID_ENDPOINT_FORMAT: DWORD = 1706; +pub const RPC_S_INVALID_NET_ADDR: DWORD = 1707; +pub const RPC_S_NO_ENDPOINT_FOUND: DWORD = 1708; +pub const RPC_S_INVALID_TIMEOUT: DWORD = 1709; +pub const RPC_S_OBJECT_NOT_FOUND: DWORD = 1710; +pub const RPC_S_ALREADY_REGISTERED: DWORD = 1711; +pub const RPC_S_TYPE_ALREADY_REGISTERED: DWORD = 1712; +pub const RPC_S_ALREADY_LISTENING: DWORD = 1713; +pub const RPC_S_NO_PROTSEQS_REGISTERED: DWORD = 1714; +pub const RPC_S_NOT_LISTENING: DWORD = 1715; +pub const RPC_S_UNKNOWN_MGR_TYPE: DWORD = 1716; +pub const RPC_S_UNKNOWN_IF: DWORD = 1717; +pub const RPC_S_NO_BINDINGS: DWORD = 1718; +pub const RPC_S_NO_PROTSEQS: DWORD = 1719; +pub const RPC_S_CANT_CREATE_ENDPOINT: DWORD = 1720; +pub const RPC_S_OUT_OF_RESOURCES: DWORD = 1721; +pub const RPC_S_SERVER_UNAVAILABLE: DWORD = 1722; +pub const RPC_S_SERVER_TOO_BUSY: DWORD = 1723; +pub const RPC_S_INVALID_NETWORK_OPTIONS: DWORD = 1724; +pub const RPC_S_NO_CALL_ACTIVE: DWORD = 1725; +pub const RPC_S_CALL_FAILED: DWORD = 1726; +pub const RPC_S_CALL_FAILED_DNE: DWORD = 1727; +pub const RPC_S_PROTOCOL_ERROR: DWORD = 1728; +pub const RPC_S_PROXY_ACCESS_DENIED: DWORD = 1729; +pub const RPC_S_UNSUPPORTED_TRANS_SYN: DWORD = 1730; +pub const RPC_S_UNSUPPORTED_TYPE: DWORD = 1732; +pub const RPC_S_INVALID_TAG: DWORD = 1733; +pub const RPC_S_INVALID_BOUND: DWORD = 1734; +pub const RPC_S_NO_ENTRY_NAME: DWORD = 1735; +pub const RPC_S_INVALID_NAME_SYNTAX: DWORD = 1736; +pub const RPC_S_UNSUPPORTED_NAME_SYNTAX: DWORD = 1737; +pub const RPC_S_UUID_NO_ADDRESS: DWORD = 1739; +pub const RPC_S_DUPLICATE_ENDPOINT: DWORD = 1740; +pub const RPC_S_UNKNOWN_AUTHN_TYPE: DWORD = 1741; +pub const RPC_S_MAX_CALLS_TOO_SMALL: DWORD = 1742; +pub const RPC_S_STRING_TOO_LONG: DWORD = 1743; +pub const RPC_S_PROTSEQ_NOT_FOUND: DWORD = 1744; +pub const RPC_S_PROCNUM_OUT_OF_RANGE: DWORD = 1745; +pub const RPC_S_BINDING_HAS_NO_AUTH: DWORD = 1746; +pub const RPC_S_UNKNOWN_AUTHN_SERVICE: DWORD = 1747; +pub const RPC_S_UNKNOWN_AUTHN_LEVEL: DWORD = 1748; +pub const RPC_S_INVALID_AUTH_IDENTITY: DWORD = 1749; +pub const RPC_S_UNKNOWN_AUTHZ_SERVICE: DWORD = 1750; +pub const EPT_S_INVALID_ENTRY: DWORD = 1751; +pub const EPT_S_CANT_PERFORM_OP: DWORD = 1752; +pub const EPT_S_NOT_REGISTERED: DWORD = 1753; +pub const RPC_S_NOTHING_TO_EXPORT: DWORD = 1754; +pub const RPC_S_INCOMPLETE_NAME: DWORD = 1755; +pub const RPC_S_INVALID_VERS_OPTION: DWORD = 1756; +pub const RPC_S_NO_MORE_MEMBERS: DWORD = 1757; +pub const RPC_S_NOT_ALL_OBJS_UNEXPORTED: DWORD = 1758; +pub const RPC_S_INTERFACE_NOT_FOUND: DWORD = 1759; +pub const RPC_S_ENTRY_ALREADY_EXISTS: DWORD = 1760; +pub const RPC_S_ENTRY_NOT_FOUND: DWORD = 1761; +pub const RPC_S_NAME_SERVICE_UNAVAILABLE: DWORD = 1762; +pub const RPC_S_INVALID_NAF_ID: DWORD = 1763; +pub const RPC_S_CANNOT_SUPPORT: DWORD = 1764; +pub const RPC_S_NO_CONTEXT_AVAILABLE: DWORD = 1765; +pub const RPC_S_INTERNAL_ERROR: DWORD = 1766; +pub const RPC_S_ZERO_DIVIDE: DWORD = 1767; +pub const RPC_S_ADDRESS_ERROR: DWORD = 1768; +pub const RPC_S_FP_DIV_ZERO: DWORD = 1769; +pub const RPC_S_FP_UNDERFLOW: DWORD = 1770; +pub const RPC_S_FP_OVERFLOW: DWORD = 1771; +pub const RPC_X_NO_MORE_ENTRIES: DWORD = 1772; +pub const RPC_X_SS_CHAR_TRANS_OPEN_FAIL: DWORD = 1773; +pub const RPC_X_SS_CHAR_TRANS_SHORT_FILE: DWORD = 1774; +pub const RPC_X_SS_IN_NULL_CONTEXT: DWORD = 1775; +pub const RPC_X_SS_CONTEXT_DAMAGED: DWORD = 1777; +pub const RPC_X_SS_HANDLES_MISMATCH: DWORD = 1778; +pub const RPC_X_SS_CANNOT_GET_CALL_HANDLE: DWORD = 1779; +pub const RPC_X_NULL_REF_POINTER: DWORD = 1780; +pub const RPC_X_ENUM_VALUE_OUT_OF_RANGE: DWORD = 1781; +pub const RPC_X_BYTE_COUNT_TOO_SMALL: DWORD = 1782; +pub const RPC_X_BAD_STUB_DATA: DWORD = 1783; +pub const ERROR_INVALID_USER_BUFFER: DWORD = 1784; +pub const ERROR_UNRECOGNIZED_MEDIA: DWORD = 1785; +pub const ERROR_NO_TRUST_LSA_SECRET: DWORD = 1786; +pub const ERROR_NO_TRUST_SAM_ACCOUNT: DWORD = 1787; +pub const ERROR_TRUSTED_DOMAIN_FAILURE: DWORD = 1788; +pub const ERROR_TRUSTED_RELATIONSHIP_FAILURE: DWORD = 1789; +pub const ERROR_TRUST_FAILURE: DWORD = 1790; +pub const RPC_S_CALL_IN_PROGRESS: DWORD = 1791; +pub const ERROR_NETLOGON_NOT_STARTED: DWORD = 1792; +pub const ERROR_ACCOUNT_EXPIRED: DWORD = 1793; +pub const ERROR_REDIRECTOR_HAS_OPEN_HANDLES: DWORD = 1794; +pub const ERROR_PRINTER_DRIVER_ALREADY_INSTALLED: DWORD = 1795; +pub const ERROR_UNKNOWN_PORT: DWORD = 1796; +pub const ERROR_UNKNOWN_PRINTER_DRIVER: DWORD = 1797; +pub const ERROR_UNKNOWN_PRINTPROCESSOR: DWORD = 1798; +pub const ERROR_INVALID_SEPARATOR_FILE: DWORD = 1799; +pub const ERROR_INVALID_PRIORITY: DWORD = 1800; +pub const ERROR_INVALID_PRINTER_NAME: DWORD = 1801; +pub const ERROR_PRINTER_ALREADY_EXISTS: DWORD = 1802; +pub const ERROR_INVALID_PRINTER_COMMAND: DWORD = 1803; +pub const ERROR_INVALID_DATATYPE: DWORD = 1804; +pub const ERROR_INVALID_ENVIRONMENT: DWORD = 1805; +pub const RPC_S_NO_MORE_BINDINGS: DWORD = 1806; +pub const ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT: DWORD = 1807; +pub const ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT: DWORD = 1808; +pub const ERROR_NOLOGON_SERVER_TRUST_ACCOUNT: DWORD = 1809; +pub const ERROR_DOMAIN_TRUST_INCONSISTENT: DWORD = 1810; +pub const ERROR_SERVER_HAS_OPEN_HANDLES: DWORD = 1811; +pub const ERROR_RESOURCE_DATA_NOT_FOUND: DWORD = 1812; +pub const ERROR_RESOURCE_TYPE_NOT_FOUND: DWORD = 1813; +pub const ERROR_RESOURCE_NAME_NOT_FOUND: DWORD = 1814; +pub const ERROR_RESOURCE_LANG_NOT_FOUND: DWORD = 1815; +pub const ERROR_NOT_ENOUGH_QUOTA: DWORD = 1816; +pub const RPC_S_NO_INTERFACES: DWORD = 1817; +pub const RPC_S_CALL_CANCELLED: DWORD = 1818; +pub const RPC_S_BINDING_INCOMPLETE: DWORD = 1819; +pub const RPC_S_COMM_FAILURE: DWORD = 1820; +pub const RPC_S_UNSUPPORTED_AUTHN_LEVEL: DWORD = 1821; +pub const RPC_S_NO_PRINC_NAME: DWORD = 1822; +pub const RPC_S_NOT_RPC_ERROR: DWORD = 1823; +pub const RPC_S_UUID_LOCAL_ONLY: DWORD = 1824; +pub const RPC_S_SEC_PKG_ERROR: DWORD = 1825; +pub const RPC_S_NOT_CANCELLED: DWORD = 1826; +pub const RPC_X_INVALID_ES_ACTION: DWORD = 1827; +pub const RPC_X_WRONG_ES_VERSION: DWORD = 1828; +pub const RPC_X_WRONG_STUB_VERSION: DWORD = 1829; +pub const RPC_X_INVALID_PIPE_OBJECT: DWORD = 1830; +pub const RPC_X_WRONG_PIPE_ORDER: DWORD = 1831; +pub const RPC_X_WRONG_PIPE_VERSION: DWORD = 1832; +pub const RPC_S_COOKIE_AUTH_FAILED: DWORD = 1833; +pub const RPC_S_GROUP_MEMBER_NOT_FOUND: DWORD = 1898; +pub const EPT_S_CANT_CREATE: DWORD = 1899; +pub const RPC_S_INVALID_OBJECT: DWORD = 1900; +pub const ERROR_INVALID_TIME: DWORD = 1901; +pub const ERROR_INVALID_FORM_NAME: DWORD = 1902; +pub const ERROR_INVALID_FORM_SIZE: DWORD = 1903; +pub const ERROR_ALREADY_WAITING: DWORD = 1904; +pub const ERROR_PRINTER_DELETED: DWORD = 1905; +pub const ERROR_INVALID_PRINTER_STATE: DWORD = 1906; +pub const ERROR_PASSWORD_MUST_CHANGE: DWORD = 1907; +pub const ERROR_DOMAIN_CONTROLLER_NOT_FOUND: DWORD = 1908; +pub const ERROR_ACCOUNT_LOCKED_OUT: DWORD = 1909; +pub const OR_INVALID_OXID: DWORD = 1910; +pub const OR_INVALID_OID: DWORD = 1911; +pub const OR_INVALID_SET: DWORD = 1912; +pub const RPC_S_SEND_INCOMPLETE: DWORD = 1913; +pub const RPC_S_INVALID_ASYNC_HANDLE: DWORD = 1914; +pub const RPC_S_INVALID_ASYNC_CALL: DWORD = 1915; +pub const RPC_X_PIPE_CLOSED: DWORD = 1916; +pub const RPC_X_PIPE_DISCIPLINE_ERROR: DWORD = 1917; +pub const RPC_X_PIPE_EMPTY: DWORD = 1918; +pub const ERROR_NO_SITENAME: DWORD = 1919; +pub const ERROR_CANT_ACCESS_FILE: DWORD = 1920; +pub const ERROR_CANT_RESOLVE_FILENAME: DWORD = 1921; +pub const RPC_S_ENTRY_TYPE_MISMATCH: DWORD = 1922; +pub const RPC_S_NOT_ALL_OBJS_EXPORTED: DWORD = 1923; +pub const RPC_S_INTERFACE_NOT_EXPORTED: DWORD = 1924; +pub const RPC_S_PROFILE_NOT_ADDED: DWORD = 1925; +pub const RPC_S_PRF_ELT_NOT_ADDED: DWORD = 1926; +pub const RPC_S_PRF_ELT_NOT_REMOVED: DWORD = 1927; +pub const RPC_S_GRP_ELT_NOT_ADDED: DWORD = 1928; +pub const RPC_S_GRP_ELT_NOT_REMOVED: DWORD = 1929; +pub const ERROR_KM_DRIVER_BLOCKED: DWORD = 1930; +pub const ERROR_CONTEXT_EXPIRED: DWORD = 1931; +pub const ERROR_PER_USER_TRUST_QUOTA_EXCEEDED: DWORD = 1932; +pub const ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED: DWORD = 1933; +pub const ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED: DWORD = 1934; +pub const ERROR_AUTHENTICATION_FIREWALL_FAILED: DWORD = 1935; +pub const ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED: DWORD = 1936; +pub const ERROR_NTLM_BLOCKED: DWORD = 1937; +pub const ERROR_PASSWORD_CHANGE_REQUIRED: DWORD = 1938; +pub const ERROR_INVALID_PIXEL_FORMAT: DWORD = 2000; +pub const ERROR_BAD_DRIVER: DWORD = 2001; +pub const ERROR_INVALID_WINDOW_STYLE: DWORD = 2002; +pub const ERROR_METAFILE_NOT_SUPPORTED: DWORD = 2003; +pub const ERROR_TRANSFORM_NOT_SUPPORTED: DWORD = 2004; +pub const ERROR_CLIPPING_NOT_SUPPORTED: DWORD = 2005; +pub const ERROR_INVALID_CMM: DWORD = 2010; +pub const ERROR_INVALID_PROFILE: DWORD = 2011; +pub const ERROR_TAG_NOT_FOUND: DWORD = 2012; +pub const ERROR_TAG_NOT_PRESENT: DWORD = 2013; +pub const ERROR_DUPLICATE_TAG: DWORD = 2014; +pub const ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE: DWORD = 2015; +pub const ERROR_PROFILE_NOT_FOUND: DWORD = 2016; +pub const ERROR_INVALID_COLORSPACE: DWORD = 2017; +pub const ERROR_ICM_NOT_ENABLED: DWORD = 2018; +pub const ERROR_DELETING_ICM_XFORM: DWORD = 2019; +pub const ERROR_INVALID_TRANSFORM: DWORD = 2020; +pub const ERROR_COLORSPACE_MISMATCH: DWORD = 2021; +pub const ERROR_INVALID_COLORINDEX: DWORD = 2022; +pub const ERROR_PROFILE_DOES_NOT_MATCH_DEVICE: DWORD = 2023; +pub const ERROR_CONNECTED_OTHER_PASSWORD: DWORD = 2108; +pub const ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT: DWORD = 2109; +pub const ERROR_BAD_USERNAME: DWORD = 2202; +pub const ERROR_NOT_CONNECTED: DWORD = 2250; +pub const ERROR_OPEN_FILES: DWORD = 2401; +pub const ERROR_ACTIVE_CONNECTIONS: DWORD = 2402; +pub const ERROR_DEVICE_IN_USE: DWORD = 2404; +pub const ERROR_UNKNOWN_PRINT_MONITOR: DWORD = 3000; +pub const ERROR_PRINTER_DRIVER_IN_USE: DWORD = 3001; +pub const ERROR_SPOOL_FILE_NOT_FOUND: DWORD = 3002; +pub const ERROR_SPL_NO_STARTDOC: DWORD = 3003; +pub const ERROR_SPL_NO_ADDJOB: DWORD = 3004; +pub const ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED: DWORD = 3005; +pub const ERROR_PRINT_MONITOR_ALREADY_INSTALLED: DWORD = 3006; +pub const ERROR_INVALID_PRINT_MONITOR: DWORD = 3007; +pub const ERROR_PRINT_MONITOR_IN_USE: DWORD = 3008; +pub const ERROR_PRINTER_HAS_JOBS_QUEUED: DWORD = 3009; +pub const ERROR_SUCCESS_REBOOT_REQUIRED: DWORD = 3010; +pub const ERROR_SUCCESS_RESTART_REQUIRED: DWORD = 3011; +pub const ERROR_PRINTER_NOT_FOUND: DWORD = 3012; +pub const ERROR_PRINTER_DRIVER_WARNED: DWORD = 3013; +pub const ERROR_PRINTER_DRIVER_BLOCKED: DWORD = 3014; +pub const ERROR_PRINTER_DRIVER_PACKAGE_IN_USE: DWORD = 3015; +pub const ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND: DWORD = 3016; +pub const ERROR_FAIL_REBOOT_REQUIRED: DWORD = 3017; +pub const ERROR_FAIL_REBOOT_INITIATED: DWORD = 3018; +pub const ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED: DWORD = 3019; +pub const ERROR_PRINT_JOB_RESTART_REQUIRED: DWORD = 3020; +pub const ERROR_INVALID_PRINTER_DRIVER_MANIFEST: DWORD = 3021; +pub const ERROR_PRINTER_NOT_SHAREABLE: DWORD = 3022; +pub const ERROR_REQUEST_PAUSED: DWORD = 3050; +pub const ERROR_IO_REISSUE_AS_CACHED: DWORD = 3950; +pub const ERROR_WINS_INTERNAL: DWORD = 4000; +pub const ERROR_CAN_NOT_DEL_LOCAL_WINS: DWORD = 4001; +pub const ERROR_STATIC_INIT: DWORD = 4002; +pub const ERROR_INC_BACKUP: DWORD = 4003; +pub const ERROR_FULL_BACKUP: DWORD = 4004; +pub const ERROR_REC_NON_EXISTENT: DWORD = 4005; +pub const ERROR_RPL_NOT_ALLOWED: DWORD = 4006; +pub const PEERDIST_ERROR_CONTENTINFO_VERSION_UNSUPPORTED: DWORD = 4050; +pub const PEERDIST_ERROR_CANNOT_PARSE_CONTENTINFO: DWORD = 4051; +pub const PEERDIST_ERROR_MISSING_DATA: DWORD = 4052; +pub const PEERDIST_ERROR_NO_MORE: DWORD = 4053; +pub const PEERDIST_ERROR_NOT_INITIALIZED: DWORD = 4054; +pub const PEERDIST_ERROR_ALREADY_INITIALIZED: DWORD = 4055; +pub const PEERDIST_ERROR_SHUTDOWN_IN_PROGRESS: DWORD = 4056; +pub const PEERDIST_ERROR_INVALIDATED: DWORD = 4057; +pub const PEERDIST_ERROR_ALREADY_EXISTS: DWORD = 4058; +pub const PEERDIST_ERROR_OPERATION_NOTFOUND: DWORD = 4059; +pub const PEERDIST_ERROR_ALREADY_COMPLETED: DWORD = 4060; +pub const PEERDIST_ERROR_OUT_OF_BOUNDS: DWORD = 4061; +pub const PEERDIST_ERROR_VERSION_UNSUPPORTED: DWORD = 4062; +pub const PEERDIST_ERROR_INVALID_CONFIGURATION: DWORD = 4063; +pub const PEERDIST_ERROR_NOT_LICENSED: DWORD = 4064; +pub const PEERDIST_ERROR_SERVICE_UNAVAILABLE: DWORD = 4065; +pub const PEERDIST_ERROR_TRUST_FAILURE: DWORD = 4066; +pub const ERROR_DHCP_ADDRESS_CONFLICT: DWORD = 4100; +pub const ERROR_WMI_GUID_NOT_FOUND: DWORD = 4200; +pub const ERROR_WMI_INSTANCE_NOT_FOUND: DWORD = 4201; +pub const ERROR_WMI_ITEMID_NOT_FOUND: DWORD = 4202; +pub const ERROR_WMI_TRY_AGAIN: DWORD = 4203; +pub const ERROR_WMI_DP_NOT_FOUND: DWORD = 4204; +pub const ERROR_WMI_UNRESOLVED_INSTANCE_REF: DWORD = 4205; +pub const ERROR_WMI_ALREADY_ENABLED: DWORD = 4206; +pub const ERROR_WMI_GUID_DISCONNECTED: DWORD = 4207; +pub const ERROR_WMI_SERVER_UNAVAILABLE: DWORD = 4208; +pub const ERROR_WMI_DP_FAILED: DWORD = 4209; +pub const ERROR_WMI_INVALID_MOF: DWORD = 4210; +pub const ERROR_WMI_INVALID_REGINFO: DWORD = 4211; +pub const ERROR_WMI_ALREADY_DISABLED: DWORD = 4212; +pub const ERROR_WMI_READ_ONLY: DWORD = 4213; +pub const ERROR_WMI_SET_FAILURE: DWORD = 4214; +pub const ERROR_NOT_APPCONTAINER: DWORD = 4250; +pub const ERROR_APPCONTAINER_REQUIRED: DWORD = 4251; +pub const ERROR_NOT_SUPPORTED_IN_APPCONTAINER: DWORD = 4252; +pub const ERROR_INVALID_PACKAGE_SID_LENGTH: DWORD = 4253; +pub const ERROR_INVALID_MEDIA: DWORD = 4300; +pub const ERROR_INVALID_LIBRARY: DWORD = 4301; +pub const ERROR_INVALID_MEDIA_POOL: DWORD = 4302; +pub const ERROR_DRIVE_MEDIA_MISMATCH: DWORD = 4303; +pub const ERROR_MEDIA_OFFLINE: DWORD = 4304; +pub const ERROR_LIBRARY_OFFLINE: DWORD = 4305; +pub const ERROR_EMPTY: DWORD = 4306; +pub const ERROR_NOT_EMPTY: DWORD = 4307; +pub const ERROR_MEDIA_UNAVAILABLE: DWORD = 4308; +pub const ERROR_RESOURCE_DISABLED: DWORD = 4309; +pub const ERROR_INVALID_CLEANER: DWORD = 4310; +pub const ERROR_UNABLE_TO_CLEAN: DWORD = 4311; +pub const ERROR_OBJECT_NOT_FOUND: DWORD = 4312; +pub const ERROR_DATABASE_FAILURE: DWORD = 4313; +pub const ERROR_DATABASE_FULL: DWORD = 4314; +pub const ERROR_MEDIA_INCOMPATIBLE: DWORD = 4315; +pub const ERROR_RESOURCE_NOT_PRESENT: DWORD = 4316; +pub const ERROR_INVALID_OPERATION: DWORD = 4317; +pub const ERROR_MEDIA_NOT_AVAILABLE: DWORD = 4318; +pub const ERROR_DEVICE_NOT_AVAILABLE: DWORD = 4319; +pub const ERROR_REQUEST_REFUSED: DWORD = 4320; +pub const ERROR_INVALID_DRIVE_OBJECT: DWORD = 4321; +pub const ERROR_LIBRARY_FULL: DWORD = 4322; +pub const ERROR_MEDIUM_NOT_ACCESSIBLE: DWORD = 4323; +pub const ERROR_UNABLE_TO_LOAD_MEDIUM: DWORD = 4324; +pub const ERROR_UNABLE_TO_INVENTORY_DRIVE: DWORD = 4325; +pub const ERROR_UNABLE_TO_INVENTORY_SLOT: DWORD = 4326; +pub const ERROR_UNABLE_TO_INVENTORY_TRANSPORT: DWORD = 4327; +pub const ERROR_TRANSPORT_FULL: DWORD = 4328; +pub const ERROR_CONTROLLING_IEPORT: DWORD = 4329; +pub const ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA: DWORD = 4330; +pub const ERROR_CLEANER_SLOT_SET: DWORD = 4331; +pub const ERROR_CLEANER_SLOT_NOT_SET: DWORD = 4332; +pub const ERROR_CLEANER_CARTRIDGE_SPENT: DWORD = 4333; +pub const ERROR_UNEXPECTED_OMID: DWORD = 4334; +pub const ERROR_CANT_DELETE_LAST_ITEM: DWORD = 4335; +pub const ERROR_MESSAGE_EXCEEDS_MAX_SIZE: DWORD = 4336; +pub const ERROR_VOLUME_CONTAINS_SYS_FILES: DWORD = 4337; +pub const ERROR_INDIGENOUS_TYPE: DWORD = 4338; +pub const ERROR_NO_SUPPORTING_DRIVES: DWORD = 4339; +pub const ERROR_CLEANER_CARTRIDGE_INSTALLED: DWORD = 4340; +pub const ERROR_IEPORT_FULL: DWORD = 4341; +pub const ERROR_FILE_OFFLINE: DWORD = 4350; +pub const ERROR_REMOTE_STORAGE_NOT_ACTIVE: DWORD = 4351; +pub const ERROR_REMOTE_STORAGE_MEDIA_ERROR: DWORD = 4352; +pub const ERROR_NOT_A_REPARSE_POINT: DWORD = 4390; +pub const ERROR_REPARSE_ATTRIBUTE_CONFLICT: DWORD = 4391; +pub const ERROR_INVALID_REPARSE_DATA: DWORD = 4392; +pub const ERROR_REPARSE_TAG_INVALID: DWORD = 4393; +pub const ERROR_REPARSE_TAG_MISMATCH: DWORD = 4394; +pub const ERROR_APP_DATA_NOT_FOUND: DWORD = 4400; +pub const ERROR_APP_DATA_EXPIRED: DWORD = 4401; +pub const ERROR_APP_DATA_CORRUPT: DWORD = 4402; +pub const ERROR_APP_DATA_LIMIT_EXCEEDED: DWORD = 4403; +pub const ERROR_APP_DATA_REBOOT_REQUIRED: DWORD = 4404; +pub const ERROR_SECUREBOOT_ROLLBACK_DETECTED: DWORD = 4420; +pub const ERROR_SECUREBOOT_POLICY_VIOLATION: DWORD = 4421; +pub const ERROR_SECUREBOOT_INVALID_POLICY: DWORD = 4422; +pub const ERROR_SECUREBOOT_POLICY_PUBLISHER_NOT_FOUND: DWORD = 4423; +pub const ERROR_SECUREBOOT_POLICY_NOT_SIGNED: DWORD = 4424; +pub const ERROR_SECUREBOOT_NOT_ENABLED: DWORD = 4425; +pub const ERROR_SECUREBOOT_FILE_REPLACED: DWORD = 4426; +pub const ERROR_OFFLOAD_READ_FLT_NOT_SUPPORTED: DWORD = 4440; +pub const ERROR_OFFLOAD_WRITE_FLT_NOT_SUPPORTED: DWORD = 4441; +pub const ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED: DWORD = 4442; +pub const ERROR_OFFLOAD_WRITE_FILE_NOT_SUPPORTED: DWORD = 4443; +pub const ERROR_VOLUME_NOT_SIS_ENABLED: DWORD = 4500; +pub const ERROR_DEPENDENT_RESOURCE_EXISTS: DWORD = 5001; +pub const ERROR_DEPENDENCY_NOT_FOUND: DWORD = 5002; +pub const ERROR_DEPENDENCY_ALREADY_EXISTS: DWORD = 5003; +pub const ERROR_RESOURCE_NOT_ONLINE: DWORD = 5004; +pub const ERROR_HOST_NODE_NOT_AVAILABLE: DWORD = 5005; +pub const ERROR_RESOURCE_NOT_AVAILABLE: DWORD = 5006; +pub const ERROR_RESOURCE_NOT_FOUND: DWORD = 5007; +pub const ERROR_SHUTDOWN_CLUSTER: DWORD = 5008; +pub const ERROR_CANT_EVICT_ACTIVE_NODE: DWORD = 5009; +pub const ERROR_OBJECT_ALREADY_EXISTS: DWORD = 5010; +pub const ERROR_OBJECT_IN_LIST: DWORD = 5011; +pub const ERROR_GROUP_NOT_AVAILABLE: DWORD = 5012; +pub const ERROR_GROUP_NOT_FOUND: DWORD = 5013; +pub const ERROR_GROUP_NOT_ONLINE: DWORD = 5014; +pub const ERROR_HOST_NODE_NOT_RESOURCE_OWNER: DWORD = 5015; +pub const ERROR_HOST_NODE_NOT_GROUP_OWNER: DWORD = 5016; +pub const ERROR_RESMON_CREATE_FAILED: DWORD = 5017; +pub const ERROR_RESMON_ONLINE_FAILED: DWORD = 5018; +pub const ERROR_RESOURCE_ONLINE: DWORD = 5019; +pub const ERROR_QUORUM_RESOURCE: DWORD = 5020; +pub const ERROR_NOT_QUORUM_CAPABLE: DWORD = 5021; +pub const ERROR_CLUSTER_SHUTTING_DOWN: DWORD = 5022; +pub const ERROR_INVALID_STATE: DWORD = 5023; +pub const ERROR_RESOURCE_PROPERTIES_STORED: DWORD = 5024; +pub const ERROR_NOT_QUORUM_CLASS: DWORD = 5025; +pub const ERROR_CORE_RESOURCE: DWORD = 5026; +pub const ERROR_QUORUM_RESOURCE_ONLINE_FAILED: DWORD = 5027; +pub const ERROR_QUORUMLOG_OPEN_FAILED: DWORD = 5028; +pub const ERROR_CLUSTERLOG_CORRUPT: DWORD = 5029; +pub const ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE: DWORD = 5030; +pub const ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE: DWORD = 5031; +pub const ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND: DWORD = 5032; +pub const ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE: DWORD = 5033; +pub const ERROR_QUORUM_OWNER_ALIVE: DWORD = 5034; +pub const ERROR_NETWORK_NOT_AVAILABLE: DWORD = 5035; +pub const ERROR_NODE_NOT_AVAILABLE: DWORD = 5036; +pub const ERROR_ALL_NODES_NOT_AVAILABLE: DWORD = 5037; +pub const ERROR_RESOURCE_FAILED: DWORD = 5038; +pub const ERROR_CLUSTER_INVALID_NODE: DWORD = 5039; +pub const ERROR_CLUSTER_NODE_EXISTS: DWORD = 5040; +pub const ERROR_CLUSTER_JOIN_IN_PROGRESS: DWORD = 5041; +pub const ERROR_CLUSTER_NODE_NOT_FOUND: DWORD = 5042; +pub const ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND: DWORD = 5043; +pub const ERROR_CLUSTER_NETWORK_EXISTS: DWORD = 5044; +pub const ERROR_CLUSTER_NETWORK_NOT_FOUND: DWORD = 5045; +pub const ERROR_CLUSTER_NETINTERFACE_EXISTS: DWORD = 5046; +pub const ERROR_CLUSTER_NETINTERFACE_NOT_FOUND: DWORD = 5047; +pub const ERROR_CLUSTER_INVALID_REQUEST: DWORD = 5048; +pub const ERROR_CLUSTER_INVALID_NETWORK_PROVIDER: DWORD = 5049; +pub const ERROR_CLUSTER_NODE_DOWN: DWORD = 5050; +pub const ERROR_CLUSTER_NODE_UNREACHABLE: DWORD = 5051; +pub const ERROR_CLUSTER_NODE_NOT_MEMBER: DWORD = 5052; +pub const ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS: DWORD = 5053; +pub const ERROR_CLUSTER_INVALID_NETWORK: DWORD = 5054; +pub const ERROR_CLUSTER_NODE_UP: DWORD = 5056; +pub const ERROR_CLUSTER_IPADDR_IN_USE: DWORD = 5057; +pub const ERROR_CLUSTER_NODE_NOT_PAUSED: DWORD = 5058; +pub const ERROR_CLUSTER_NO_SECURITY_CONTEXT: DWORD = 5059; +pub const ERROR_CLUSTER_NETWORK_NOT_INTERNAL: DWORD = 5060; +pub const ERROR_CLUSTER_NODE_ALREADY_UP: DWORD = 5061; +pub const ERROR_CLUSTER_NODE_ALREADY_DOWN: DWORD = 5062; +pub const ERROR_CLUSTER_NETWORK_ALREADY_ONLINE: DWORD = 5063; +pub const ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE: DWORD = 5064; +pub const ERROR_CLUSTER_NODE_ALREADY_MEMBER: DWORD = 5065; +pub const ERROR_CLUSTER_LAST_INTERNAL_NETWORK: DWORD = 5066; +pub const ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS: DWORD = 5067; +pub const ERROR_INVALID_OPERATION_ON_QUORUM: DWORD = 5068; +pub const ERROR_DEPENDENCY_NOT_ALLOWED: DWORD = 5069; +pub const ERROR_CLUSTER_NODE_PAUSED: DWORD = 5070; +pub const ERROR_NODE_CANT_HOST_RESOURCE: DWORD = 5071; +pub const ERROR_CLUSTER_NODE_NOT_READY: DWORD = 5072; +pub const ERROR_CLUSTER_NODE_SHUTTING_DOWN: DWORD = 5073; +pub const ERROR_CLUSTER_JOIN_ABORTED: DWORD = 5074; +pub const ERROR_CLUSTER_INCOMPATIBLE_VERSIONS: DWORD = 5075; +pub const ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED: DWORD = 5076; +pub const ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED: DWORD = 5077; +pub const ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND: DWORD = 5078; +pub const ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED: DWORD = 5079; +pub const ERROR_CLUSTER_RESNAME_NOT_FOUND: DWORD = 5080; +pub const ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED: DWORD = 5081; +pub const ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST: DWORD = 5082; +pub const ERROR_CLUSTER_DATABASE_SEQMISMATCH: DWORD = 5083; +pub const ERROR_RESMON_INVALID_STATE: DWORD = 5084; +pub const ERROR_CLUSTER_GUM_NOT_LOCKER: DWORD = 5085; +pub const ERROR_QUORUM_DISK_NOT_FOUND: DWORD = 5086; +pub const ERROR_DATABASE_BACKUP_CORRUPT: DWORD = 5087; +pub const ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT: DWORD = 5088; +pub const ERROR_RESOURCE_PROPERTY_UNCHANGEABLE: DWORD = 5089; +pub const ERROR_NO_ADMIN_ACCESS_POINT: DWORD = 5090; +pub const ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE: DWORD = 5890; +pub const ERROR_CLUSTER_QUORUMLOG_NOT_FOUND: DWORD = 5891; +pub const ERROR_CLUSTER_MEMBERSHIP_HALT: DWORD = 5892; +pub const ERROR_CLUSTER_INSTANCE_ID_MISMATCH: DWORD = 5893; +pub const ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP: DWORD = 5894; +pub const ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH: DWORD = 5895; +pub const ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP: DWORD = 5896; +pub const ERROR_CLUSTER_PARAMETER_MISMATCH: DWORD = 5897; +pub const ERROR_NODE_CANNOT_BE_CLUSTERED: DWORD = 5898; +pub const ERROR_CLUSTER_WRONG_OS_VERSION: DWORD = 5899; +pub const ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME: DWORD = 5900; +pub const ERROR_CLUSCFG_ALREADY_COMMITTED: DWORD = 5901; +pub const ERROR_CLUSCFG_ROLLBACK_FAILED: DWORD = 5902; +pub const ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT: DWORD = 5903; +pub const ERROR_CLUSTER_OLD_VERSION: DWORD = 5904; +pub const ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME: DWORD = 5905; +pub const ERROR_CLUSTER_NO_NET_ADAPTERS: DWORD = 5906; +pub const ERROR_CLUSTER_POISONED: DWORD = 5907; +pub const ERROR_CLUSTER_GROUP_MOVING: DWORD = 5908; +pub const ERROR_CLUSTER_RESOURCE_TYPE_BUSY: DWORD = 5909; +pub const ERROR_RESOURCE_CALL_TIMED_OUT: DWORD = 5910; +pub const ERROR_INVALID_CLUSTER_IPV6_ADDRESS: DWORD = 5911; +pub const ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION: DWORD = 5912; +pub const ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS: DWORD = 5913; +pub const ERROR_CLUSTER_PARTIAL_SEND: DWORD = 5914; +pub const ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION: DWORD = 5915; +pub const ERROR_CLUSTER_INVALID_STRING_TERMINATION: DWORD = 5916; +pub const ERROR_CLUSTER_INVALID_STRING_FORMAT: DWORD = 5917; +pub const ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS: DWORD = 5918; +pub const ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS: DWORD = 5919; +pub const ERROR_CLUSTER_NULL_DATA: DWORD = 5920; +pub const ERROR_CLUSTER_PARTIAL_READ: DWORD = 5921; +pub const ERROR_CLUSTER_PARTIAL_WRITE: DWORD = 5922; +pub const ERROR_CLUSTER_CANT_DESERIALIZE_DATA: DWORD = 5923; +pub const ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT: DWORD = 5924; +pub const ERROR_CLUSTER_NO_QUORUM: DWORD = 5925; +pub const ERROR_CLUSTER_INVALID_IPV6_NETWORK: DWORD = 5926; +pub const ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK: DWORD = 5927; +pub const ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP: DWORD = 5928; +pub const ERROR_DEPENDENCY_TREE_TOO_COMPLEX: DWORD = 5929; +pub const ERROR_EXCEPTION_IN_RESOURCE_CALL: DWORD = 5930; +pub const ERROR_CLUSTER_RHS_FAILED_INITIALIZATION: DWORD = 5931; +pub const ERROR_CLUSTER_NOT_INSTALLED: DWORD = 5932; +pub const ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE: DWORD = 5933; +pub const ERROR_CLUSTER_MAX_NODES_IN_CLUSTER: DWORD = 5934; +pub const ERROR_CLUSTER_TOO_MANY_NODES: DWORD = 5935; +pub const ERROR_CLUSTER_OBJECT_ALREADY_USED: DWORD = 5936; +pub const ERROR_NONCORE_GROUPS_FOUND: DWORD = 5937; +pub const ERROR_FILE_SHARE_RESOURCE_CONFLICT: DWORD = 5938; +pub const ERROR_CLUSTER_EVICT_INVALID_REQUEST: DWORD = 5939; +pub const ERROR_CLUSTER_SINGLETON_RESOURCE: DWORD = 5940; +pub const ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE: DWORD = 5941; +pub const ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED: DWORD = 5942; +pub const ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR: DWORD = 5943; +pub const ERROR_CLUSTER_GROUP_BUSY: DWORD = 5944; +pub const ERROR_CLUSTER_NOT_SHARED_VOLUME: DWORD = 5945; +pub const ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR: DWORD = 5946; +pub const ERROR_CLUSTER_SHARED_VOLUMES_IN_USE: DWORD = 5947; +pub const ERROR_CLUSTER_USE_SHARED_VOLUMES_API: DWORD = 5948; +pub const ERROR_CLUSTER_BACKUP_IN_PROGRESS: DWORD = 5949; +pub const ERROR_NON_CSV_PATH: DWORD = 5950; +pub const ERROR_CSV_VOLUME_NOT_LOCAL: DWORD = 5951; +pub const ERROR_CLUSTER_WATCHDOG_TERMINATING: DWORD = 5952; +pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_INCOMPATIBLE_NODES: DWORD = 5953; +pub const ERROR_CLUSTER_INVALID_NODE_WEIGHT: DWORD = 5954; +pub const ERROR_CLUSTER_RESOURCE_VETOED_CALL: DWORD = 5955; +pub const ERROR_RESMON_SYSTEM_RESOURCES_LACKING: DWORD = 5956; +pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_DESTINATION: DWORD = 5957; +pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_SOURCE: DWORD = 5958; +pub const ERROR_CLUSTER_GROUP_QUEUED: DWORD = 5959; +pub const ERROR_CLUSTER_RESOURCE_LOCKED_STATUS: DWORD = 5960; +pub const ERROR_CLUSTER_SHARED_VOLUME_FAILOVER_NOT_ALLOWED: DWORD = 5961; +pub const ERROR_CLUSTER_NODE_DRAIN_IN_PROGRESS: DWORD = 5962; +pub const ERROR_CLUSTER_DISK_NOT_CONNECTED: DWORD = 5963; +pub const ERROR_DISK_NOT_CSV_CAPABLE: DWORD = 5964; +pub const ERROR_RESOURCE_NOT_IN_AVAILABLE_STORAGE: DWORD = 5965; +pub const ERROR_CLUSTER_SHARED_VOLUME_REDIRECTED: DWORD = 5966; +pub const ERROR_CLUSTER_SHARED_VOLUME_NOT_REDIRECTED: DWORD = 5967; +pub const ERROR_CLUSTER_CANNOT_RETURN_PROPERTIES: DWORD = 5968; +pub const ERROR_CLUSTER_RESOURCE_CONTAINS_UNSUPPORTED_DIFF_AREA_FOR_SHARED_VOLUMES: DWORD = 5969; +pub const ERROR_CLUSTER_RESOURCE_IS_IN_MAINTENANCE_MODE: DWORD = 5970; +pub const ERROR_CLUSTER_AFFINITY_CONFLICT: DWORD = 5971; +pub const ERROR_CLUSTER_RESOURCE_IS_REPLICA_VIRTUAL_MACHINE: DWORD = 5972; +pub const ERROR_ENCRYPTION_FAILED: DWORD = 6000; +pub const ERROR_DECRYPTION_FAILED: DWORD = 6001; +pub const ERROR_FILE_ENCRYPTED: DWORD = 6002; +pub const ERROR_NO_RECOVERY_POLICY: DWORD = 6003; +pub const ERROR_NO_EFS: DWORD = 6004; +pub const ERROR_WRONG_EFS: DWORD = 6005; +pub const ERROR_NO_USER_KEYS: DWORD = 6006; +pub const ERROR_FILE_NOT_ENCRYPTED: DWORD = 6007; +pub const ERROR_NOT_EXPORT_FORMAT: DWORD = 6008; +pub const ERROR_FILE_READ_ONLY: DWORD = 6009; +pub const ERROR_DIR_EFS_DISALLOWED: DWORD = 6010; +pub const ERROR_EFS_SERVER_NOT_TRUSTED: DWORD = 6011; +pub const ERROR_BAD_RECOVERY_POLICY: DWORD = 6012; +pub const ERROR_EFS_ALG_BLOB_TOO_BIG: DWORD = 6013; +pub const ERROR_VOLUME_NOT_SUPPORT_EFS: DWORD = 6014; +pub const ERROR_EFS_DISABLED: DWORD = 6015; +pub const ERROR_EFS_VERSION_NOT_SUPPORT: DWORD = 6016; +pub const ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE: DWORD = 6017; +pub const ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER: DWORD = 6018; +pub const ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE: DWORD = 6019; +pub const ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE: DWORD = 6020; +pub const ERROR_CS_ENCRYPTION_FILE_NOT_CSE: DWORD = 6021; +pub const ERROR_ENCRYPTION_POLICY_DENIES_OPERATION: DWORD = 6022; +pub const ERROR_NO_BROWSER_SERVERS_FOUND: DWORD = 6118; +pub const SCHED_E_SERVICE_NOT_LOCALSYSTEM: DWORD = 6200; +pub const ERROR_LOG_SECTOR_INVALID: DWORD = 6600; +pub const ERROR_LOG_SECTOR_PARITY_INVALID: DWORD = 6601; +pub const ERROR_LOG_SECTOR_REMAPPED: DWORD = 6602; +pub const ERROR_LOG_BLOCK_INCOMPLETE: DWORD = 6603; +pub const ERROR_LOG_INVALID_RANGE: DWORD = 6604; +pub const ERROR_LOG_BLOCKS_EXHAUSTED: DWORD = 6605; +pub const ERROR_LOG_READ_CONTEXT_INVALID: DWORD = 6606; +pub const ERROR_LOG_RESTART_INVALID: DWORD = 6607; +pub const ERROR_LOG_BLOCK_VERSION: DWORD = 6608; +pub const ERROR_LOG_BLOCK_INVALID: DWORD = 6609; +pub const ERROR_LOG_READ_MODE_INVALID: DWORD = 6610; +pub const ERROR_LOG_NO_RESTART: DWORD = 6611; +pub const ERROR_LOG_METADATA_CORRUPT: DWORD = 6612; +pub const ERROR_LOG_METADATA_INVALID: DWORD = 6613; +pub const ERROR_LOG_METADATA_INCONSISTENT: DWORD = 6614; +pub const ERROR_LOG_RESERVATION_INVALID: DWORD = 6615; +pub const ERROR_LOG_CANT_DELETE: DWORD = 6616; +pub const ERROR_LOG_CONTAINER_LIMIT_EXCEEDED: DWORD = 6617; +pub const ERROR_LOG_START_OF_LOG: DWORD = 6618; +pub const ERROR_LOG_POLICY_ALREADY_INSTALLED: DWORD = 6619; +pub const ERROR_LOG_POLICY_NOT_INSTALLED: DWORD = 6620; +pub const ERROR_LOG_POLICY_INVALID: DWORD = 6621; +pub const ERROR_LOG_POLICY_CONFLICT: DWORD = 6622; +pub const ERROR_LOG_PINNED_ARCHIVE_TAIL: DWORD = 6623; +pub const ERROR_LOG_RECORD_NONEXISTENT: DWORD = 6624; +pub const ERROR_LOG_RECORDS_RESERVED_INVALID: DWORD = 6625; +pub const ERROR_LOG_SPACE_RESERVED_INVALID: DWORD = 6626; +pub const ERROR_LOG_TAIL_INVALID: DWORD = 6627; +pub const ERROR_LOG_FULL: DWORD = 6628; +pub const ERROR_COULD_NOT_RESIZE_LOG: DWORD = 6629; +pub const ERROR_LOG_MULTIPLEXED: DWORD = 6630; +pub const ERROR_LOG_DEDICATED: DWORD = 6631; +pub const ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS: DWORD = 6632; +pub const ERROR_LOG_ARCHIVE_IN_PROGRESS: DWORD = 6633; +pub const ERROR_LOG_EPHEMERAL: DWORD = 6634; +pub const ERROR_LOG_NOT_ENOUGH_CONTAINERS: DWORD = 6635; +pub const ERROR_LOG_CLIENT_ALREADY_REGISTERED: DWORD = 6636; +pub const ERROR_LOG_CLIENT_NOT_REGISTERED: DWORD = 6637; +pub const ERROR_LOG_FULL_HANDLER_IN_PROGRESS: DWORD = 6638; +pub const ERROR_LOG_CONTAINER_READ_FAILED: DWORD = 6639; +pub const ERROR_LOG_CONTAINER_WRITE_FAILED: DWORD = 6640; +pub const ERROR_LOG_CONTAINER_OPEN_FAILED: DWORD = 6641; +pub const ERROR_LOG_CONTAINER_STATE_INVALID: DWORD = 6642; +pub const ERROR_LOG_STATE_INVALID: DWORD = 6643; +pub const ERROR_LOG_PINNED: DWORD = 6644; +pub const ERROR_LOG_METADATA_FLUSH_FAILED: DWORD = 6645; +pub const ERROR_LOG_INCONSISTENT_SECURITY: DWORD = 6646; +pub const ERROR_LOG_APPENDED_FLUSH_FAILED: DWORD = 6647; +pub const ERROR_LOG_PINNED_RESERVATION: DWORD = 6648; +pub const ERROR_INVALID_TRANSACTION: DWORD = 6700; +pub const ERROR_TRANSACTION_NOT_ACTIVE: DWORD = 6701; +pub const ERROR_TRANSACTION_REQUEST_NOT_VALID: DWORD = 6702; +pub const ERROR_TRANSACTION_NOT_REQUESTED: DWORD = 6703; +pub const ERROR_TRANSACTION_ALREADY_ABORTED: DWORD = 6704; +pub const ERROR_TRANSACTION_ALREADY_COMMITTED: DWORD = 6705; +pub const ERROR_TM_INITIALIZATION_FAILED: DWORD = 6706; +pub const ERROR_RESOURCEMANAGER_READ_ONLY: DWORD = 6707; +pub const ERROR_TRANSACTION_NOT_JOINED: DWORD = 6708; +pub const ERROR_TRANSACTION_SUPERIOR_EXISTS: DWORD = 6709; +pub const ERROR_CRM_PROTOCOL_ALREADY_EXISTS: DWORD = 6710; +pub const ERROR_TRANSACTION_PROPAGATION_FAILED: DWORD = 6711; +pub const ERROR_CRM_PROTOCOL_NOT_FOUND: DWORD = 6712; +pub const ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER: DWORD = 6713; +pub const ERROR_CURRENT_TRANSACTION_NOT_VALID: DWORD = 6714; +pub const ERROR_TRANSACTION_NOT_FOUND: DWORD = 6715; +pub const ERROR_RESOURCEMANAGER_NOT_FOUND: DWORD = 6716; +pub const ERROR_ENLISTMENT_NOT_FOUND: DWORD = 6717; +pub const ERROR_TRANSACTIONMANAGER_NOT_FOUND: DWORD = 6718; +pub const ERROR_TRANSACTIONMANAGER_NOT_ONLINE: DWORD = 6719; +pub const ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION: DWORD = 6720; +pub const ERROR_TRANSACTION_NOT_ROOT: DWORD = 6721; +pub const ERROR_TRANSACTION_OBJECT_EXPIRED: DWORD = 6722; +pub const ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED: DWORD = 6723; +pub const ERROR_TRANSACTION_RECORD_TOO_LONG: DWORD = 6724; +pub const ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED: DWORD = 6725; +pub const ERROR_TRANSACTION_INTEGRITY_VIOLATED: DWORD = 6726; +pub const ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH: DWORD = 6727; +pub const ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT: DWORD = 6728; +pub const ERROR_TRANSACTION_MUST_WRITETHROUGH: DWORD = 6729; +pub const ERROR_TRANSACTION_NO_SUPERIOR: DWORD = 6730; +pub const ERROR_HEURISTIC_DAMAGE_POSSIBLE: DWORD = 6731; +pub const ERROR_TRANSACTIONAL_CONFLICT: DWORD = 6800; +pub const ERROR_RM_NOT_ACTIVE: DWORD = 6801; +pub const ERROR_RM_METADATA_CORRUPT: DWORD = 6802; +pub const ERROR_DIRECTORY_NOT_RM: DWORD = 6803; +pub const ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE: DWORD = 6805; +pub const ERROR_LOG_RESIZE_INVALID_SIZE: DWORD = 6806; +pub const ERROR_OBJECT_NO_LONGER_EXISTS: DWORD = 6807; +pub const ERROR_STREAM_MINIVERSION_NOT_FOUND: DWORD = 6808; +pub const ERROR_STREAM_MINIVERSION_NOT_VALID: DWORD = 6809; +pub const ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION: DWORD = 6810; +pub const ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT: DWORD = 6811; +pub const ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS: DWORD = 6812; +pub const ERROR_REMOTE_FILE_VERSION_MISMATCH: DWORD = 6814; +pub const ERROR_HANDLE_NO_LONGER_VALID: DWORD = 6815; +pub const ERROR_NO_TXF_METADATA: DWORD = 6816; +pub const ERROR_LOG_CORRUPTION_DETECTED: DWORD = 6817; +pub const ERROR_CANT_RECOVER_WITH_HANDLE_OPEN: DWORD = 6818; +pub const ERROR_RM_DISCONNECTED: DWORD = 6819; +pub const ERROR_ENLISTMENT_NOT_SUPERIOR: DWORD = 6820; +pub const ERROR_RECOVERY_NOT_NEEDED: DWORD = 6821; +pub const ERROR_RM_ALREADY_STARTED: DWORD = 6822; +pub const ERROR_FILE_IDENTITY_NOT_PERSISTENT: DWORD = 6823; +pub const ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY: DWORD = 6824; +pub const ERROR_CANT_CROSS_RM_BOUNDARY: DWORD = 6825; +pub const ERROR_TXF_DIR_NOT_EMPTY: DWORD = 6826; +pub const ERROR_INDOUBT_TRANSACTIONS_EXIST: DWORD = 6827; +pub const ERROR_TM_VOLATILE: DWORD = 6828; +pub const ERROR_ROLLBACK_TIMER_EXPIRED: DWORD = 6829; +pub const ERROR_TXF_ATTRIBUTE_CORRUPT: DWORD = 6830; +pub const ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION: DWORD = 6831; +pub const ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED: DWORD = 6832; +pub const ERROR_LOG_GROWTH_FAILED: DWORD = 6833; +pub const ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE: DWORD = 6834; +pub const ERROR_TXF_METADATA_ALREADY_PRESENT: DWORD = 6835; +pub const ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET: DWORD = 6836; +pub const ERROR_TRANSACTION_REQUIRED_PROMOTION: DWORD = 6837; +pub const ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION: DWORD = 6838; +pub const ERROR_TRANSACTIONS_NOT_FROZEN: DWORD = 6839; +pub const ERROR_TRANSACTION_FREEZE_IN_PROGRESS: DWORD = 6840; +pub const ERROR_NOT_SNAPSHOT_VOLUME: DWORD = 6841; +pub const ERROR_NO_SAVEPOINT_WITH_OPEN_FILES: DWORD = 6842; +pub const ERROR_DATA_LOST_REPAIR: DWORD = 6843; +pub const ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION: DWORD = 6844; +pub const ERROR_TM_IDENTITY_MISMATCH: DWORD = 6845; +pub const ERROR_FLOATED_SECTION: DWORD = 6846; +pub const ERROR_CANNOT_ACCEPT_TRANSACTED_WORK: DWORD = 6847; +pub const ERROR_CANNOT_ABORT_TRANSACTIONS: DWORD = 6848; +pub const ERROR_BAD_CLUSTERS: DWORD = 6849; +pub const ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION: DWORD = 6850; +pub const ERROR_VOLUME_DIRTY: DWORD = 6851; +pub const ERROR_NO_LINK_TRACKING_IN_TRANSACTION: DWORD = 6852; +pub const ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION: DWORD = 6853; +pub const ERROR_EXPIRED_HANDLE: DWORD = 6854; +pub const ERROR_TRANSACTION_NOT_ENLISTED: DWORD = 6855; +pub const ERROR_CTX_WINSTATION_NAME_INVALID: DWORD = 7001; +pub const ERROR_CTX_INVALID_PD: DWORD = 7002; +pub const ERROR_CTX_PD_NOT_FOUND: DWORD = 7003; +pub const ERROR_CTX_WD_NOT_FOUND: DWORD = 7004; +pub const ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY: DWORD = 7005; +pub const ERROR_CTX_SERVICE_NAME_COLLISION: DWORD = 7006; +pub const ERROR_CTX_CLOSE_PENDING: DWORD = 7007; +pub const ERROR_CTX_NO_OUTBUF: DWORD = 7008; +pub const ERROR_CTX_MODEM_INF_NOT_FOUND: DWORD = 7009; +pub const ERROR_CTX_INVALID_MODEMNAME: DWORD = 7010; +pub const ERROR_CTX_MODEM_RESPONSE_ERROR: DWORD = 7011; +pub const ERROR_CTX_MODEM_RESPONSE_TIMEOUT: DWORD = 7012; +pub const ERROR_CTX_MODEM_RESPONSE_NO_CARRIER: DWORD = 7013; +pub const ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE: DWORD = 7014; +pub const ERROR_CTX_MODEM_RESPONSE_BUSY: DWORD = 7015; +pub const ERROR_CTX_MODEM_RESPONSE_VOICE: DWORD = 7016; +pub const ERROR_CTX_TD_ERROR: DWORD = 7017; +pub const ERROR_CTX_WINSTATION_NOT_FOUND: DWORD = 7022; +pub const ERROR_CTX_WINSTATION_ALREADY_EXISTS: DWORD = 7023; +pub const ERROR_CTX_WINSTATION_BUSY: DWORD = 7024; +pub const ERROR_CTX_BAD_VIDEO_MODE: DWORD = 7025; +pub const ERROR_CTX_GRAPHICS_INVALID: DWORD = 7035; +pub const ERROR_CTX_LOGON_DISABLED: DWORD = 7037; +pub const ERROR_CTX_NOT_CONSOLE: DWORD = 7038; +pub const ERROR_CTX_CLIENT_QUERY_TIMEOUT: DWORD = 7040; +pub const ERROR_CTX_CONSOLE_DISCONNECT: DWORD = 7041; +pub const ERROR_CTX_CONSOLE_CONNECT: DWORD = 7042; +pub const ERROR_CTX_SHADOW_DENIED: DWORD = 7044; +pub const ERROR_CTX_WINSTATION_ACCESS_DENIED: DWORD = 7045; +pub const ERROR_CTX_INVALID_WD: DWORD = 7049; +pub const ERROR_CTX_SHADOW_INVALID: DWORD = 7050; +pub const ERROR_CTX_SHADOW_DISABLED: DWORD = 7051; +pub const ERROR_CTX_CLIENT_LICENSE_IN_USE: DWORD = 7052; +pub const ERROR_CTX_CLIENT_LICENSE_NOT_SET: DWORD = 7053; +pub const ERROR_CTX_LICENSE_NOT_AVAILABLE: DWORD = 7054; +pub const ERROR_CTX_LICENSE_CLIENT_INVALID: DWORD = 7055; +pub const ERROR_CTX_LICENSE_EXPIRED: DWORD = 7056; +pub const ERROR_CTX_SHADOW_NOT_RUNNING: DWORD = 7057; +pub const ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE: DWORD = 7058; +pub const ERROR_ACTIVATION_COUNT_EXCEEDED: DWORD = 7059; +pub const ERROR_CTX_WINSTATIONS_DISABLED: DWORD = 7060; +pub const ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED: DWORD = 7061; +pub const ERROR_CTX_SESSION_IN_USE: DWORD = 7062; +pub const ERROR_CTX_NO_FORCE_LOGOFF: DWORD = 7063; +pub const ERROR_CTX_ACCOUNT_RESTRICTION: DWORD = 7064; +pub const ERROR_RDP_PROTOCOL_ERROR: DWORD = 7065; +pub const ERROR_CTX_CDM_CONNECT: DWORD = 7066; +pub const ERROR_CTX_CDM_DISCONNECT: DWORD = 7067; +pub const ERROR_CTX_SECURITY_LAYER_ERROR: DWORD = 7068; +pub const ERROR_TS_INCOMPATIBLE_SESSIONS: DWORD = 7069; +pub const ERROR_TS_VIDEO_SUBSYSTEM_ERROR: DWORD = 7070; +pub const FRS_ERR_INVALID_API_SEQUENCE: DWORD = 8001; +pub const FRS_ERR_STARTING_SERVICE: DWORD = 8002; +pub const FRS_ERR_STOPPING_SERVICE: DWORD = 8003; +pub const FRS_ERR_INTERNAL_API: DWORD = 8004; +pub const FRS_ERR_INTERNAL: DWORD = 8005; +pub const FRS_ERR_SERVICE_COMM: DWORD = 8006; +pub const FRS_ERR_INSUFFICIENT_PRIV: DWORD = 8007; +pub const FRS_ERR_AUTHENTICATION: DWORD = 8008; +pub const FRS_ERR_PARENT_INSUFFICIENT_PRIV: DWORD = 8009; +pub const FRS_ERR_PARENT_AUTHENTICATION: DWORD = 8010; +pub const FRS_ERR_CHILD_TO_PARENT_COMM: DWORD = 8011; +pub const FRS_ERR_PARENT_TO_CHILD_COMM: DWORD = 8012; +pub const FRS_ERR_SYSVOL_POPULATE: DWORD = 8013; +pub const FRS_ERR_SYSVOL_POPULATE_TIMEOUT: DWORD = 8014; +pub const FRS_ERR_SYSVOL_IS_BUSY: DWORD = 8015; +pub const FRS_ERR_SYSVOL_DEMOTE: DWORD = 8016; +pub const FRS_ERR_INVALID_SERVICE_PARAMETER: DWORD = 8017; +pub const DS_S_SUCCESS: DWORD = NO_ERROR; +pub const ERROR_DS_NOT_INSTALLED: DWORD = 8200; +pub const ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY: DWORD = 8201; +pub const ERROR_DS_NO_ATTRIBUTE_OR_VALUE: DWORD = 8202; +pub const ERROR_DS_INVALID_ATTRIBUTE_SYNTAX: DWORD = 8203; +pub const ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED: DWORD = 8204; +pub const ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS: DWORD = 8205; +pub const ERROR_DS_BUSY: DWORD = 8206; +pub const ERROR_DS_UNAVAILABLE: DWORD = 8207; +pub const ERROR_DS_NO_RIDS_ALLOCATED: DWORD = 8208; +pub const ERROR_DS_NO_MORE_RIDS: DWORD = 8209; +pub const ERROR_DS_INCORRECT_ROLE_OWNER: DWORD = 8210; +pub const ERROR_DS_RIDMGR_INIT_ERROR: DWORD = 8211; +pub const ERROR_DS_OBJ_CLASS_VIOLATION: DWORD = 8212; +pub const ERROR_DS_CANT_ON_NON_LEAF: DWORD = 8213; +pub const ERROR_DS_CANT_ON_RDN: DWORD = 8214; +pub const ERROR_DS_CANT_MOD_OBJ_CLASS: DWORD = 8215; +pub const ERROR_DS_CROSS_DOM_MOVE_ERROR: DWORD = 8216; +pub const ERROR_DS_GC_NOT_AVAILABLE: DWORD = 8217; +pub const ERROR_SHARED_POLICY: DWORD = 8218; +pub const ERROR_POLICY_OBJECT_NOT_FOUND: DWORD = 8219; +pub const ERROR_POLICY_ONLY_IN_DS: DWORD = 8220; +pub const ERROR_PROMOTION_ACTIVE: DWORD = 8221; +pub const ERROR_NO_PROMOTION_ACTIVE: DWORD = 8222; +pub const ERROR_DS_OPERATIONS_ERROR: DWORD = 8224; +pub const ERROR_DS_PROTOCOL_ERROR: DWORD = 8225; +pub const ERROR_DS_TIMELIMIT_EXCEEDED: DWORD = 8226; +pub const ERROR_DS_SIZELIMIT_EXCEEDED: DWORD = 8227; +pub const ERROR_DS_ADMIN_LIMIT_EXCEEDED: DWORD = 8228; +pub const ERROR_DS_COMPARE_FALSE: DWORD = 8229; +pub const ERROR_DS_COMPARE_TRUE: DWORD = 8230; +pub const ERROR_DS_AUTH_METHOD_NOT_SUPPORTED: DWORD = 8231; +pub const ERROR_DS_STRONG_AUTH_REQUIRED: DWORD = 8232; +pub const ERROR_DS_INAPPROPRIATE_AUTH: DWORD = 8233; +pub const ERROR_DS_AUTH_UNKNOWN: DWORD = 8234; +pub const ERROR_DS_REFERRAL: DWORD = 8235; +pub const ERROR_DS_UNAVAILABLE_CRIT_EXTENSION: DWORD = 8236; +pub const ERROR_DS_CONFIDENTIALITY_REQUIRED: DWORD = 8237; +pub const ERROR_DS_INAPPROPRIATE_MATCHING: DWORD = 8238; +pub const ERROR_DS_CONSTRAINT_VIOLATION: DWORD = 8239; +pub const ERROR_DS_NO_SUCH_OBJECT: DWORD = 8240; +pub const ERROR_DS_ALIAS_PROBLEM: DWORD = 8241; +pub const ERROR_DS_INVALID_DN_SYNTAX: DWORD = 8242; +pub const ERROR_DS_IS_LEAF: DWORD = 8243; +pub const ERROR_DS_ALIAS_DEREF_PROBLEM: DWORD = 8244; +pub const ERROR_DS_UNWILLING_TO_PERFORM: DWORD = 8245; +pub const ERROR_DS_LOOP_DETECT: DWORD = 8246; +pub const ERROR_DS_NAMING_VIOLATION: DWORD = 8247; +pub const ERROR_DS_OBJECT_RESULTS_TOO_LARGE: DWORD = 8248; +pub const ERROR_DS_AFFECTS_MULTIPLE_DSAS: DWORD = 8249; +pub const ERROR_DS_SERVER_DOWN: DWORD = 8250; +pub const ERROR_DS_LOCAL_ERROR: DWORD = 8251; +pub const ERROR_DS_ENCODING_ERROR: DWORD = 8252; +pub const ERROR_DS_DECODING_ERROR: DWORD = 8253; +pub const ERROR_DS_FILTER_UNKNOWN: DWORD = 8254; +pub const ERROR_DS_PARAM_ERROR: DWORD = 8255; +pub const ERROR_DS_NOT_SUPPORTED: DWORD = 8256; +pub const ERROR_DS_NO_RESULTS_RETURNED: DWORD = 8257; +pub const ERROR_DS_CONTROL_NOT_FOUND: DWORD = 8258; +pub const ERROR_DS_CLIENT_LOOP: DWORD = 8259; +pub const ERROR_DS_REFERRAL_LIMIT_EXCEEDED: DWORD = 8260; +pub const ERROR_DS_SORT_CONTROL_MISSING: DWORD = 8261; +pub const ERROR_DS_OFFSET_RANGE_ERROR: DWORD = 8262; +pub const ERROR_DS_RIDMGR_DISABLED: DWORD = 8263; +pub const ERROR_DS_ROOT_MUST_BE_NC: DWORD = 8301; +pub const ERROR_DS_ADD_REPLICA_INHIBITED: DWORD = 8302; +pub const ERROR_DS_ATT_NOT_DEF_IN_SCHEMA: DWORD = 8303; +pub const ERROR_DS_MAX_OBJ_SIZE_EXCEEDED: DWORD = 8304; +pub const ERROR_DS_OBJ_STRING_NAME_EXISTS: DWORD = 8305; +pub const ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA: DWORD = 8306; +pub const ERROR_DS_RDN_DOESNT_MATCH_SCHEMA: DWORD = 8307; +pub const ERROR_DS_NO_REQUESTED_ATTS_FOUND: DWORD = 8308; +pub const ERROR_DS_USER_BUFFER_TO_SMALL: DWORD = 8309; +pub const ERROR_DS_ATT_IS_NOT_ON_OBJ: DWORD = 8310; +pub const ERROR_DS_ILLEGAL_MOD_OPERATION: DWORD = 8311; +pub const ERROR_DS_OBJ_TOO_LARGE: DWORD = 8312; +pub const ERROR_DS_BAD_INSTANCE_TYPE: DWORD = 8313; +pub const ERROR_DS_MASTERDSA_REQUIRED: DWORD = 8314; +pub const ERROR_DS_OBJECT_CLASS_REQUIRED: DWORD = 8315; +pub const ERROR_DS_MISSING_REQUIRED_ATT: DWORD = 8316; +pub const ERROR_DS_ATT_NOT_DEF_FOR_CLASS: DWORD = 8317; +pub const ERROR_DS_ATT_ALREADY_EXISTS: DWORD = 8318; +pub const ERROR_DS_CANT_ADD_ATT_VALUES: DWORD = 8320; +pub const ERROR_DS_SINGLE_VALUE_CONSTRAINT: DWORD = 8321; +pub const ERROR_DS_RANGE_CONSTRAINT: DWORD = 8322; +pub const ERROR_DS_ATT_VAL_ALREADY_EXISTS: DWORD = 8323; +pub const ERROR_DS_CANT_REM_MISSING_ATT: DWORD = 8324; +pub const ERROR_DS_CANT_REM_MISSING_ATT_VAL: DWORD = 8325; +pub const ERROR_DS_ROOT_CANT_BE_SUBREF: DWORD = 8326; +pub const ERROR_DS_NO_CHAINING: DWORD = 8327; +pub const ERROR_DS_NO_CHAINED_EVAL: DWORD = 8328; +pub const ERROR_DS_NO_PARENT_OBJECT: DWORD = 8329; +pub const ERROR_DS_PARENT_IS_AN_ALIAS: DWORD = 8330; +pub const ERROR_DS_CANT_MIX_MASTER_AND_REPS: DWORD = 8331; +pub const ERROR_DS_CHILDREN_EXIST: DWORD = 8332; +pub const ERROR_DS_OBJ_NOT_FOUND: DWORD = 8333; +pub const ERROR_DS_ALIASED_OBJ_MISSING: DWORD = 8334; +pub const ERROR_DS_BAD_NAME_SYNTAX: DWORD = 8335; +pub const ERROR_DS_ALIAS_POINTS_TO_ALIAS: DWORD = 8336; +pub const ERROR_DS_CANT_DEREF_ALIAS: DWORD = 8337; +pub const ERROR_DS_OUT_OF_SCOPE: DWORD = 8338; +pub const ERROR_DS_OBJECT_BEING_REMOVED: DWORD = 8339; +pub const ERROR_DS_CANT_DELETE_DSA_OBJ: DWORD = 8340; +pub const ERROR_DS_GENERIC_ERROR: DWORD = 8341; +pub const ERROR_DS_DSA_MUST_BE_INT_MASTER: DWORD = 8342; +pub const ERROR_DS_CLASS_NOT_DSA: DWORD = 8343; +pub const ERROR_DS_INSUFF_ACCESS_RIGHTS: DWORD = 8344; +pub const ERROR_DS_ILLEGAL_SUPERIOR: DWORD = 8345; +pub const ERROR_DS_ATTRIBUTE_OWNED_BY_SAM: DWORD = 8346; +pub const ERROR_DS_NAME_TOO_MANY_PARTS: DWORD = 8347; +pub const ERROR_DS_NAME_TOO_LONG: DWORD = 8348; +pub const ERROR_DS_NAME_VALUE_TOO_LONG: DWORD = 8349; +pub const ERROR_DS_NAME_UNPARSEABLE: DWORD = 8350; +pub const ERROR_DS_NAME_TYPE_UNKNOWN: DWORD = 8351; +pub const ERROR_DS_NOT_AN_OBJECT: DWORD = 8352; +pub const ERROR_DS_SEC_DESC_TOO_SHORT: DWORD = 8353; +pub const ERROR_DS_SEC_DESC_INVALID: DWORD = 8354; +pub const ERROR_DS_NO_DELETED_NAME: DWORD = 8355; +pub const ERROR_DS_SUBREF_MUST_HAVE_PARENT: DWORD = 8356; +pub const ERROR_DS_NCNAME_MUST_BE_NC: DWORD = 8357; +pub const ERROR_DS_CANT_ADD_SYSTEM_ONLY: DWORD = 8358; +pub const ERROR_DS_CLASS_MUST_BE_CONCRETE: DWORD = 8359; +pub const ERROR_DS_INVALID_DMD: DWORD = 8360; +pub const ERROR_DS_OBJ_GUID_EXISTS: DWORD = 8361; +pub const ERROR_DS_NOT_ON_BACKLINK: DWORD = 8362; +pub const ERROR_DS_NO_CROSSREF_FOR_NC: DWORD = 8363; +pub const ERROR_DS_SHUTTING_DOWN: DWORD = 8364; +pub const ERROR_DS_UNKNOWN_OPERATION: DWORD = 8365; +pub const ERROR_DS_INVALID_ROLE_OWNER: DWORD = 8366; +pub const ERROR_DS_COULDNT_CONTACT_FSMO: DWORD = 8367; +pub const ERROR_DS_CROSS_NC_DN_RENAME: DWORD = 8368; +pub const ERROR_DS_CANT_MOD_SYSTEM_ONLY: DWORD = 8369; +pub const ERROR_DS_REPLICATOR_ONLY: DWORD = 8370; +pub const ERROR_DS_OBJ_CLASS_NOT_DEFINED: DWORD = 8371; +pub const ERROR_DS_OBJ_CLASS_NOT_SUBCLASS: DWORD = 8372; +pub const ERROR_DS_NAME_REFERENCE_INVALID: DWORD = 8373; +pub const ERROR_DS_CROSS_REF_EXISTS: DWORD = 8374; +pub const ERROR_DS_CANT_DEL_MASTER_CROSSREF: DWORD = 8375; +pub const ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD: DWORD = 8376; +pub const ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX: DWORD = 8377; +pub const ERROR_DS_DUP_RDN: DWORD = 8378; +pub const ERROR_DS_DUP_OID: DWORD = 8379; +pub const ERROR_DS_DUP_MAPI_ID: DWORD = 8380; +pub const ERROR_DS_DUP_SCHEMA_ID_GUID: DWORD = 8381; +pub const ERROR_DS_DUP_LDAP_DISPLAY_NAME: DWORD = 8382; +pub const ERROR_DS_SEMANTIC_ATT_TEST: DWORD = 8383; +pub const ERROR_DS_SYNTAX_MISMATCH: DWORD = 8384; +pub const ERROR_DS_EXISTS_IN_MUST_HAVE: DWORD = 8385; +pub const ERROR_DS_EXISTS_IN_MAY_HAVE: DWORD = 8386; +pub const ERROR_DS_NONEXISTENT_MAY_HAVE: DWORD = 8387; +pub const ERROR_DS_NONEXISTENT_MUST_HAVE: DWORD = 8388; +pub const ERROR_DS_AUX_CLS_TEST_FAIL: DWORD = 8389; +pub const ERROR_DS_NONEXISTENT_POSS_SUP: DWORD = 8390; +pub const ERROR_DS_SUB_CLS_TEST_FAIL: DWORD = 8391; +pub const ERROR_DS_BAD_RDN_ATT_ID_SYNTAX: DWORD = 8392; +pub const ERROR_DS_EXISTS_IN_AUX_CLS: DWORD = 8393; +pub const ERROR_DS_EXISTS_IN_SUB_CLS: DWORD = 8394; +pub const ERROR_DS_EXISTS_IN_POSS_SUP: DWORD = 8395; +pub const ERROR_DS_RECALCSCHEMA_FAILED: DWORD = 8396; +pub const ERROR_DS_TREE_DELETE_NOT_FINISHED: DWORD = 8397; +pub const ERROR_DS_CANT_DELETE: DWORD = 8398; +pub const ERROR_DS_ATT_SCHEMA_REQ_ID: DWORD = 8399; +pub const ERROR_DS_BAD_ATT_SCHEMA_SYNTAX: DWORD = 8400; +pub const ERROR_DS_CANT_CACHE_ATT: DWORD = 8401; +pub const ERROR_DS_CANT_CACHE_CLASS: DWORD = 8402; +pub const ERROR_DS_CANT_REMOVE_ATT_CACHE: DWORD = 8403; +pub const ERROR_DS_CANT_REMOVE_CLASS_CACHE: DWORD = 8404; +pub const ERROR_DS_CANT_RETRIEVE_DN: DWORD = 8405; +pub const ERROR_DS_MISSING_SUPREF: DWORD = 8406; +pub const ERROR_DS_CANT_RETRIEVE_INSTANCE: DWORD = 8407; +pub const ERROR_DS_CODE_INCONSISTENCY: DWORD = 8408; +pub const ERROR_DS_DATABASE_ERROR: DWORD = 8409; +pub const ERROR_DS_GOVERNSID_MISSING: DWORD = 8410; +pub const ERROR_DS_MISSING_EXPECTED_ATT: DWORD = 8411; +pub const ERROR_DS_NCNAME_MISSING_CR_REF: DWORD = 8412; +pub const ERROR_DS_SECURITY_CHECKING_ERROR: DWORD = 8413; +pub const ERROR_DS_SCHEMA_NOT_LOADED: DWORD = 8414; +pub const ERROR_DS_SCHEMA_ALLOC_FAILED: DWORD = 8415; +pub const ERROR_DS_ATT_SCHEMA_REQ_SYNTAX: DWORD = 8416; +pub const ERROR_DS_GCVERIFY_ERROR: DWORD = 8417; +pub const ERROR_DS_DRA_SCHEMA_MISMATCH: DWORD = 8418; +pub const ERROR_DS_CANT_FIND_DSA_OBJ: DWORD = 8419; +pub const ERROR_DS_CANT_FIND_EXPECTED_NC: DWORD = 8420; +pub const ERROR_DS_CANT_FIND_NC_IN_CACHE: DWORD = 8421; +pub const ERROR_DS_CANT_RETRIEVE_CHILD: DWORD = 8422; +pub const ERROR_DS_SECURITY_ILLEGAL_MODIFY: DWORD = 8423; +pub const ERROR_DS_CANT_REPLACE_HIDDEN_REC: DWORD = 8424; +pub const ERROR_DS_BAD_HIERARCHY_FILE: DWORD = 8425; +pub const ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED: DWORD = 8426; +pub const ERROR_DS_CONFIG_PARAM_MISSING: DWORD = 8427; +pub const ERROR_DS_COUNTING_AB_INDICES_FAILED: DWORD = 8428; +pub const ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED: DWORD = 8429; +pub const ERROR_DS_INTERNAL_FAILURE: DWORD = 8430; +pub const ERROR_DS_UNKNOWN_ERROR: DWORD = 8431; +pub const ERROR_DS_ROOT_REQUIRES_CLASS_TOP: DWORD = 8432; +pub const ERROR_DS_REFUSING_FSMO_ROLES: DWORD = 8433; +pub const ERROR_DS_MISSING_FSMO_SETTINGS: DWORD = 8434; +pub const ERROR_DS_UNABLE_TO_SURRENDER_ROLES: DWORD = 8435; +pub const ERROR_DS_DRA_GENERIC: DWORD = 8436; +pub const ERROR_DS_DRA_INVALID_PARAMETER: DWORD = 8437; +pub const ERROR_DS_DRA_BUSY: DWORD = 8438; +pub const ERROR_DS_DRA_BAD_DN: DWORD = 8439; +pub const ERROR_DS_DRA_BAD_NC: DWORD = 8440; +pub const ERROR_DS_DRA_DN_EXISTS: DWORD = 8441; +pub const ERROR_DS_DRA_INTERNAL_ERROR: DWORD = 8442; +pub const ERROR_DS_DRA_INCONSISTENT_DIT: DWORD = 8443; +pub const ERROR_DS_DRA_CONNECTION_FAILED: DWORD = 8444; +pub const ERROR_DS_DRA_BAD_INSTANCE_TYPE: DWORD = 8445; +pub const ERROR_DS_DRA_OUT_OF_MEM: DWORD = 8446; +pub const ERROR_DS_DRA_MAIL_PROBLEM: DWORD = 8447; +pub const ERROR_DS_DRA_REF_ALREADY_EXISTS: DWORD = 8448; +pub const ERROR_DS_DRA_REF_NOT_FOUND: DWORD = 8449; +pub const ERROR_DS_DRA_OBJ_IS_REP_SOURCE: DWORD = 8450; +pub const ERROR_DS_DRA_DB_ERROR: DWORD = 8451; +pub const ERROR_DS_DRA_NO_REPLICA: DWORD = 8452; +pub const ERROR_DS_DRA_ACCESS_DENIED: DWORD = 8453; +pub const ERROR_DS_DRA_NOT_SUPPORTED: DWORD = 8454; +pub const ERROR_DS_DRA_RPC_CANCELLED: DWORD = 8455; +pub const ERROR_DS_DRA_SOURCE_DISABLED: DWORD = 8456; +pub const ERROR_DS_DRA_SINK_DISABLED: DWORD = 8457; +pub const ERROR_DS_DRA_NAME_COLLISION: DWORD = 8458; +pub const ERROR_DS_DRA_SOURCE_REINSTALLED: DWORD = 8459; +pub const ERROR_DS_DRA_MISSING_PARENT: DWORD = 8460; +pub const ERROR_DS_DRA_PREEMPTED: DWORD = 8461; +pub const ERROR_DS_DRA_ABANDON_SYNC: DWORD = 8462; +pub const ERROR_DS_DRA_SHUTDOWN: DWORD = 8463; +pub const ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET: DWORD = 8464; +pub const ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA: DWORD = 8465; +pub const ERROR_DS_DRA_EXTN_CONNECTION_FAILED: DWORD = 8466; +pub const ERROR_DS_INSTALL_SCHEMA_MISMATCH: DWORD = 8467; +pub const ERROR_DS_DUP_LINK_ID: DWORD = 8468; +pub const ERROR_DS_NAME_ERROR_RESOLVING: DWORD = 8469; +pub const ERROR_DS_NAME_ERROR_NOT_FOUND: DWORD = 8470; +pub const ERROR_DS_NAME_ERROR_NOT_UNIQUE: DWORD = 8471; +pub const ERROR_DS_NAME_ERROR_NO_MAPPING: DWORD = 8472; +pub const ERROR_DS_NAME_ERROR_DOMAIN_ONLY: DWORD = 8473; +pub const ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING: DWORD = 8474; +pub const ERROR_DS_CONSTRUCTED_ATT_MOD: DWORD = 8475; +pub const ERROR_DS_WRONG_OM_OBJ_CLASS: DWORD = 8476; +pub const ERROR_DS_DRA_REPL_PENDING: DWORD = 8477; +pub const ERROR_DS_DS_REQUIRED: DWORD = 8478; +pub const ERROR_DS_INVALID_LDAP_DISPLAY_NAME: DWORD = 8479; +pub const ERROR_DS_NON_BASE_SEARCH: DWORD = 8480; +pub const ERROR_DS_CANT_RETRIEVE_ATTS: DWORD = 8481; +pub const ERROR_DS_BACKLINK_WITHOUT_LINK: DWORD = 8482; +pub const ERROR_DS_EPOCH_MISMATCH: DWORD = 8483; +pub const ERROR_DS_SRC_NAME_MISMATCH: DWORD = 8484; +pub const ERROR_DS_SRC_AND_DST_NC_IDENTICAL: DWORD = 8485; +pub const ERROR_DS_DST_NC_MISMATCH: DWORD = 8486; +pub const ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC: DWORD = 8487; +pub const ERROR_DS_SRC_GUID_MISMATCH: DWORD = 8488; +pub const ERROR_DS_CANT_MOVE_DELETED_OBJECT: DWORD = 8489; +pub const ERROR_DS_PDC_OPERATION_IN_PROGRESS: DWORD = 8490; +pub const ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD: DWORD = 8491; +pub const ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION: DWORD = 8492; +pub const ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS: DWORD = 8493; +pub const ERROR_DS_NC_MUST_HAVE_NC_PARENT: DWORD = 8494; +pub const ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE: DWORD = 8495; +pub const ERROR_DS_DST_DOMAIN_NOT_NATIVE: DWORD = 8496; +pub const ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER: DWORD = 8497; +pub const ERROR_DS_CANT_MOVE_ACCOUNT_GROUP: DWORD = 8498; +pub const ERROR_DS_CANT_MOVE_RESOURCE_GROUP: DWORD = 8499; +pub const ERROR_DS_INVALID_SEARCH_FLAG: DWORD = 8500; +pub const ERROR_DS_NO_TREE_DELETE_ABOVE_NC: DWORD = 8501; +pub const ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE: DWORD = 8502; +pub const ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE: DWORD = 8503; +pub const ERROR_DS_SAM_INIT_FAILURE: DWORD = 8504; +pub const ERROR_DS_SENSITIVE_GROUP_VIOLATION: DWORD = 8505; +pub const ERROR_DS_CANT_MOD_PRIMARYGROUPID: DWORD = 8506; +pub const ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD: DWORD = 8507; +pub const ERROR_DS_NONSAFE_SCHEMA_CHANGE: DWORD = 8508; +pub const ERROR_DS_SCHEMA_UPDATE_DISALLOWED: DWORD = 8509; +pub const ERROR_DS_CANT_CREATE_UNDER_SCHEMA: DWORD = 8510; +pub const ERROR_DS_INSTALL_NO_SRC_SCH_VERSION: DWORD = 8511; +pub const ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE: DWORD = 8512; +pub const ERROR_DS_INVALID_GROUP_TYPE: DWORD = 8513; +pub const ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN: DWORD = 8514; +pub const ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN: DWORD = 8515; +pub const ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER: DWORD = 8516; +pub const ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER: DWORD = 8517; +pub const ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER: DWORD = 8518; +pub const ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER: DWORD = 8519; +pub const ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER: DWORD = 8520; +pub const ERROR_DS_HAVE_PRIMARY_MEMBERS: DWORD = 8521; +pub const ERROR_DS_STRING_SD_CONVERSION_FAILED: DWORD = 8522; +pub const ERROR_DS_NAMING_MASTER_GC: DWORD = 8523; +pub const ERROR_DS_DNS_LOOKUP_FAILURE: DWORD = 8524; +pub const ERROR_DS_COULDNT_UPDATE_SPNS: DWORD = 8525; +pub const ERROR_DS_CANT_RETRIEVE_SD: DWORD = 8526; +pub const ERROR_DS_KEY_NOT_UNIQUE: DWORD = 8527; +pub const ERROR_DS_WRONG_LINKED_ATT_SYNTAX: DWORD = 8528; +pub const ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD: DWORD = 8529; +pub const ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY: DWORD = 8530; +pub const ERROR_DS_CANT_START: DWORD = 8531; +pub const ERROR_DS_INIT_FAILURE: DWORD = 8532; +pub const ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION: DWORD = 8533; +pub const ERROR_DS_SOURCE_DOMAIN_IN_FOREST: DWORD = 8534; +pub const ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST: DWORD = 8535; +pub const ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED: DWORD = 8536; +pub const ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN: DWORD = 8537; +pub const ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER: DWORD = 8538; +pub const ERROR_DS_SRC_SID_EXISTS_IN_FOREST: DWORD = 8539; +pub const ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH: DWORD = 8540; +pub const ERROR_SAM_INIT_FAILURE: DWORD = 8541; +pub const ERROR_DS_DRA_SCHEMA_INFO_SHIP: DWORD = 8542; +pub const ERROR_DS_DRA_SCHEMA_CONFLICT: DWORD = 8543; +pub const ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT: DWORD = 8544; +pub const ERROR_DS_DRA_OBJ_NC_MISMATCH: DWORD = 8545; +pub const ERROR_DS_NC_STILL_HAS_DSAS: DWORD = 8546; +pub const ERROR_DS_GC_REQUIRED: DWORD = 8547; +pub const ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY: DWORD = 8548; +pub const ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS: DWORD = 8549; +pub const ERROR_DS_CANT_ADD_TO_GC: DWORD = 8550; +pub const ERROR_DS_NO_CHECKPOINT_WITH_PDC: DWORD = 8551; +pub const ERROR_DS_SOURCE_AUDITING_NOT_ENABLED: DWORD = 8552; +pub const ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC: DWORD = 8553; +pub const ERROR_DS_INVALID_NAME_FOR_SPN: DWORD = 8554; +pub const ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS: DWORD = 8555; +pub const ERROR_DS_UNICODEPWD_NOT_IN_QUOTES: DWORD = 8556; +pub const ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED: DWORD = 8557; +pub const ERROR_DS_MUST_BE_RUN_ON_DST_DC: DWORD = 8558; +pub const ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER: DWORD = 8559; +pub const ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ: DWORD = 8560; +pub const ERROR_DS_INIT_FAILURE_CONSOLE: DWORD = 8561; +pub const ERROR_DS_SAM_INIT_FAILURE_CONSOLE: DWORD = 8562; +pub const ERROR_DS_FOREST_VERSION_TOO_HIGH: DWORD = 8563; +pub const ERROR_DS_DOMAIN_VERSION_TOO_HIGH: DWORD = 8564; +pub const ERROR_DS_FOREST_VERSION_TOO_LOW: DWORD = 8565; +pub const ERROR_DS_DOMAIN_VERSION_TOO_LOW: DWORD = 8566; +pub const ERROR_DS_INCOMPATIBLE_VERSION: DWORD = 8567; +pub const ERROR_DS_LOW_DSA_VERSION: DWORD = 8568; +pub const ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN: DWORD = 8569; +pub const ERROR_DS_NOT_SUPPORTED_SORT_ORDER: DWORD = 8570; +pub const ERROR_DS_NAME_NOT_UNIQUE: DWORD = 8571; +pub const ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4: DWORD = 8572; +pub const ERROR_DS_OUT_OF_VERSION_STORE: DWORD = 8573; +pub const ERROR_DS_INCOMPATIBLE_CONTROLS_USED: DWORD = 8574; +pub const ERROR_DS_NO_REF_DOMAIN: DWORD = 8575; +pub const ERROR_DS_RESERVED_LINK_ID: DWORD = 8576; +pub const ERROR_DS_LINK_ID_NOT_AVAILABLE: DWORD = 8577; +pub const ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER: DWORD = 8578; +pub const ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE: DWORD = 8579; +pub const ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC: DWORD = 8580; +pub const ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG: DWORD = 8581; +pub const ERROR_DS_MODIFYDN_WRONG_GRANDPARENT: DWORD = 8582; +pub const ERROR_DS_NAME_ERROR_TRUST_REFERRAL: DWORD = 8583; +pub const ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER: DWORD = 8584; +pub const ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD: DWORD = 8585; +pub const ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2: DWORD = 8586; +pub const ERROR_DS_THREAD_LIMIT_EXCEEDED: DWORD = 8587; +pub const ERROR_DS_NOT_CLOSEST: DWORD = 8588; +pub const ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF: DWORD = 8589; +pub const ERROR_DS_SINGLE_USER_MODE_FAILED: DWORD = 8590; +pub const ERROR_DS_NTDSCRIPT_SYNTAX_ERROR: DWORD = 8591; +pub const ERROR_DS_NTDSCRIPT_PROCESS_ERROR: DWORD = 8592; +pub const ERROR_DS_DIFFERENT_REPL_EPOCHS: DWORD = 8593; +pub const ERROR_DS_DRS_EXTENSIONS_CHANGED: DWORD = 8594; +pub const ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR: DWORD = 8595; +pub const ERROR_DS_NO_MSDS_INTID: DWORD = 8596; +pub const ERROR_DS_DUP_MSDS_INTID: DWORD = 8597; +pub const ERROR_DS_EXISTS_IN_RDNATTID: DWORD = 8598; +pub const ERROR_DS_AUTHORIZATION_FAILED: DWORD = 8599; +pub const ERROR_DS_INVALID_SCRIPT: DWORD = 8600; +pub const ERROR_DS_REMOTE_CROSSREF_OP_FAILED: DWORD = 8601; +pub const ERROR_DS_CROSS_REF_BUSY: DWORD = 8602; +pub const ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN: DWORD = 8603; +pub const ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC: DWORD = 8604; +pub const ERROR_DS_DUPLICATE_ID_FOUND: DWORD = 8605; +pub const ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT: DWORD = 8606; +pub const ERROR_DS_GROUP_CONVERSION_ERROR: DWORD = 8607; +pub const ERROR_DS_CANT_MOVE_APP_BASIC_GROUP: DWORD = 8608; +pub const ERROR_DS_CANT_MOVE_APP_QUERY_GROUP: DWORD = 8609; +pub const ERROR_DS_ROLE_NOT_VERIFIED: DWORD = 8610; +pub const ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL: DWORD = 8611; +pub const ERROR_DS_DOMAIN_RENAME_IN_PROGRESS: DWORD = 8612; +pub const ERROR_DS_EXISTING_AD_CHILD_NC: DWORD = 8613; +pub const ERROR_DS_REPL_LIFETIME_EXCEEDED: DWORD = 8614; +pub const ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER: DWORD = 8615; +pub const ERROR_DS_LDAP_SEND_QUEUE_FULL: DWORD = 8616; +pub const ERROR_DS_DRA_OUT_SCHEDULE_WINDOW: DWORD = 8617; +pub const ERROR_DS_POLICY_NOT_KNOWN: DWORD = 8618; +pub const ERROR_NO_SITE_SETTINGS_OBJECT: DWORD = 8619; +pub const ERROR_NO_SECRETS: DWORD = 8620; +pub const ERROR_NO_WRITABLE_DC_FOUND: DWORD = 8621; +pub const ERROR_DS_NO_SERVER_OBJECT: DWORD = 8622; +pub const ERROR_DS_NO_NTDSA_OBJECT: DWORD = 8623; +pub const ERROR_DS_NON_ASQ_SEARCH: DWORD = 8624; +pub const ERROR_DS_AUDIT_FAILURE: DWORD = 8625; +pub const ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE: DWORD = 8626; +pub const ERROR_DS_INVALID_SEARCH_FLAG_TUPLE: DWORD = 8627; +pub const ERROR_DS_HIERARCHY_TABLE_TOO_DEEP: DWORD = 8628; +pub const ERROR_DS_DRA_CORRUPT_UTD_VECTOR: DWORD = 8629; +pub const ERROR_DS_DRA_SECRETS_DENIED: DWORD = 8630; +pub const ERROR_DS_RESERVED_MAPI_ID: DWORD = 8631; +pub const ERROR_DS_MAPI_ID_NOT_AVAILABLE: DWORD = 8632; +pub const ERROR_DS_DRA_MISSING_KRBTGT_SECRET: DWORD = 8633; +pub const ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST: DWORD = 8634; +pub const ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST: DWORD = 8635; +pub const ERROR_INVALID_USER_PRINCIPAL_NAME: DWORD = 8636; +pub const ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS: DWORD = 8637; +pub const ERROR_DS_OID_NOT_FOUND: DWORD = 8638; +pub const ERROR_DS_DRA_RECYCLED_TARGET: DWORD = 8639; +pub const ERROR_DS_DISALLOWED_NC_REDIRECT: DWORD = 8640; +pub const ERROR_DS_HIGH_ADLDS_FFL: DWORD = 8641; +pub const ERROR_DS_HIGH_DSA_VERSION: DWORD = 8642; +pub const ERROR_DS_LOW_ADLDS_FFL: DWORD = 8643; +pub const ERROR_DOMAIN_SID_SAME_AS_LOCAL_WORKSTATION: DWORD = 8644; +pub const ERROR_DS_UNDELETE_SAM_VALIDATION_FAILED: DWORD = 8645; +pub const ERROR_INCORRECT_ACCOUNT_TYPE: DWORD = 8646; +pub const ERROR_DS_SPN_VALUE_NOT_UNIQUE_IN_FOREST: DWORD = 8647; +pub const ERROR_DS_UPN_VALUE_NOT_UNIQUE_IN_FOREST: DWORD = 8648; +pub const DNS_ERROR_RESPONSE_CODES_BASE: DWORD = 9000; +pub const DNS_ERROR_RCODE_NO_ERROR: DWORD = NO_ERROR; +pub const DNS_ERROR_MASK: DWORD = 0x00002328; +pub const DNS_ERROR_RCODE_FORMAT_ERROR: DWORD = 9001; +pub const DNS_ERROR_RCODE_SERVER_FAILURE: DWORD = 9002; +pub const DNS_ERROR_RCODE_NAME_ERROR: DWORD = 9003; +pub const DNS_ERROR_RCODE_NOT_IMPLEMENTED: DWORD = 9004; +pub const DNS_ERROR_RCODE_REFUSED: DWORD = 9005; +pub const DNS_ERROR_RCODE_YXDOMAIN: DWORD = 9006; +pub const DNS_ERROR_RCODE_YXRRSET: DWORD = 9007; +pub const DNS_ERROR_RCODE_NXRRSET: DWORD = 9008; +pub const DNS_ERROR_RCODE_NOTAUTH: DWORD = 9009; +pub const DNS_ERROR_RCODE_NOTZONE: DWORD = 9010; +pub const DNS_ERROR_RCODE_BADSIG: DWORD = 9016; +pub const DNS_ERROR_RCODE_BADKEY: DWORD = 9017; +pub const DNS_ERROR_RCODE_BADTIME: DWORD = 9018; +pub const DNS_ERROR_RCODE_LAST: DWORD = DNS_ERROR_RCODE_BADTIME; +pub const DNS_ERROR_DNSSEC_BASE: DWORD = 9100; +pub const DNS_ERROR_KEYMASTER_REQUIRED: DWORD = 9101; +pub const DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE: DWORD = 9102; +pub const DNS_ERROR_NSEC3_INCOMPATIBLE_WITH_RSA_SHA1: DWORD = 9103; +pub const DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS: DWORD = 9104; +pub const DNS_ERROR_UNSUPPORTED_ALGORITHM: DWORD = 9105; +pub const DNS_ERROR_INVALID_KEY_SIZE: DWORD = 9106; +pub const DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE: DWORD = 9107; +pub const DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION: DWORD = 9108; +pub const DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR: DWORD = 9109; +pub const DNS_ERROR_UNEXPECTED_CNG_ERROR: DWORD = 9110; +pub const DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION: DWORD = 9111; +pub const DNS_ERROR_KSP_NOT_ACCESSIBLE: DWORD = 9112; +pub const DNS_ERROR_TOO_MANY_SKDS: DWORD = 9113; +pub const DNS_ERROR_INVALID_ROLLOVER_PERIOD: DWORD = 9114; +pub const DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET: DWORD = 9115; +pub const DNS_ERROR_ROLLOVER_IN_PROGRESS: DWORD = 9116; +pub const DNS_ERROR_STANDBY_KEY_NOT_PRESENT: DWORD = 9117; +pub const DNS_ERROR_NOT_ALLOWED_ON_ZSK: DWORD = 9118; +pub const DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD: DWORD = 9119; +pub const DNS_ERROR_ROLLOVER_ALREADY_QUEUED: DWORD = 9120; +pub const DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE: DWORD = 9121; +pub const DNS_ERROR_BAD_KEYMASTER: DWORD = 9122; +pub const DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD: DWORD = 9123; +pub const DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT: DWORD = 9124; +pub const DNS_ERROR_DNSSEC_IS_DISABLED: DWORD = 9125; +pub const DNS_ERROR_INVALID_XML: DWORD = 9126; +pub const DNS_ERROR_NO_VALID_TRUST_ANCHORS: DWORD = 9127; +pub const DNS_ERROR_ROLLOVER_NOT_POKEABLE: DWORD = 9128; +pub const DNS_ERROR_NSEC3_NAME_COLLISION: DWORD = 9129; +pub const DNS_ERROR_NSEC_INCOMPATIBLE_WITH_NSEC3_RSA_SHA1: DWORD = 9130; +pub const DNS_ERROR_PACKET_FMT_BASE: DWORD = 9500; +pub const DNS_INFO_NO_RECORDS: DWORD = 9501; +pub const DNS_ERROR_BAD_PACKET: DWORD = 9502; +pub const DNS_ERROR_NO_PACKET: DWORD = 9503; +pub const DNS_ERROR_RCODE: DWORD = 9504; +pub const DNS_ERROR_UNSECURE_PACKET: DWORD = 9505; +pub const DNS_STATUS_PACKET_UNSECURE: DWORD = DNS_ERROR_UNSECURE_PACKET; +pub const DNS_REQUEST_PENDING: DWORD = 9506; +pub const DNS_ERROR_NO_MEMORY: DWORD = ERROR_OUTOFMEMORY; +pub const DNS_ERROR_INVALID_NAME: DWORD = ERROR_INVALID_NAME; +pub const DNS_ERROR_INVALID_DATA: DWORD = ERROR_INVALID_DATA; +pub const DNS_ERROR_GENERAL_API_BASE: DWORD = 9550; +pub const DNS_ERROR_INVALID_TYPE: DWORD = 9551; +pub const DNS_ERROR_INVALID_IP_ADDRESS: DWORD = 9552; +pub const DNS_ERROR_INVALID_PROPERTY: DWORD = 9553; +pub const DNS_ERROR_TRY_AGAIN_LATER: DWORD = 9554; +pub const DNS_ERROR_NOT_UNIQUE: DWORD = 9555; +pub const DNS_ERROR_NON_RFC_NAME: DWORD = 9556; +pub const DNS_STATUS_FQDN: DWORD = 9557; +pub const DNS_STATUS_DOTTED_NAME: DWORD = 9558; +pub const DNS_STATUS_SINGLE_PART_NAME: DWORD = 9559; +pub const DNS_ERROR_INVALID_NAME_CHAR: DWORD = 9560; +pub const DNS_ERROR_NUMERIC_NAME: DWORD = 9561; +pub const DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER: DWORD = 9562; +pub const DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION: DWORD = 9563; +pub const DNS_ERROR_CANNOT_FIND_ROOT_HINTS: DWORD = 9564; +pub const DNS_ERROR_INCONSISTENT_ROOT_HINTS: DWORD = 9565; +pub const DNS_ERROR_DWORD_VALUE_TOO_SMALL: DWORD = 9566; +pub const DNS_ERROR_DWORD_VALUE_TOO_LARGE: DWORD = 9567; +pub const DNS_ERROR_BACKGROUND_LOADING: DWORD = 9568; +pub const DNS_ERROR_NOT_ALLOWED_ON_RODC: DWORD = 9569; +pub const DNS_ERROR_NOT_ALLOWED_UNDER_DNAME: DWORD = 9570; +pub const DNS_ERROR_DELEGATION_REQUIRED: DWORD = 9571; +pub const DNS_ERROR_INVALID_POLICY_TABLE: DWORD = 9572; +pub const DNS_ERROR_ZONE_BASE: DWORD = 9600; +pub const DNS_ERROR_ZONE_DOES_NOT_EXIST: DWORD = 9601; +pub const DNS_ERROR_NO_ZONE_INFO: DWORD = 9602; +pub const DNS_ERROR_INVALID_ZONE_OPERATION: DWORD = 9603; +pub const DNS_ERROR_ZONE_CONFIGURATION_ERROR: DWORD = 9604; +pub const DNS_ERROR_ZONE_HAS_NO_SOA_RECORD: DWORD = 9605; +pub const DNS_ERROR_ZONE_HAS_NO_NS_RECORDS: DWORD = 9606; +pub const DNS_ERROR_ZONE_LOCKED: DWORD = 9607; +pub const DNS_ERROR_ZONE_CREATION_FAILED: DWORD = 9608; +pub const DNS_ERROR_ZONE_ALREADY_EXISTS: DWORD = 9609; +pub const DNS_ERROR_AUTOZONE_ALREADY_EXISTS: DWORD = 9610; +pub const DNS_ERROR_INVALID_ZONE_TYPE: DWORD = 9611; +pub const DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP: DWORD = 9612; +pub const DNS_ERROR_ZONE_NOT_SECONDARY: DWORD = 9613; +pub const DNS_ERROR_NEED_SECONDARY_ADDRESSES: DWORD = 9614; +pub const DNS_ERROR_WINS_INIT_FAILED: DWORD = 9615; +pub const DNS_ERROR_NEED_WINS_SERVERS: DWORD = 9616; +pub const DNS_ERROR_NBSTAT_INIT_FAILED: DWORD = 9617; +pub const DNS_ERROR_SOA_DELETE_INVALID: DWORD = 9618; +pub const DNS_ERROR_FORWARDER_ALREADY_EXISTS: DWORD = 9619; +pub const DNS_ERROR_ZONE_REQUIRES_MASTER_IP: DWORD = 9620; +pub const DNS_ERROR_ZONE_IS_SHUTDOWN: DWORD = 9621; +pub const DNS_ERROR_ZONE_LOCKED_FOR_SIGNING: DWORD = 9622; +pub const DNS_ERROR_DATAFILE_BASE: DWORD = 9650; +pub const DNS_ERROR_PRIMARY_REQUIRES_DATAFILE: DWORD = 9651; +pub const DNS_ERROR_INVALID_DATAFILE_NAME: DWORD = 9652; +pub const DNS_ERROR_DATAFILE_OPEN_FAILURE: DWORD = 9653; +pub const DNS_ERROR_FILE_WRITEBACK_FAILED: DWORD = 9654; +pub const DNS_ERROR_DATAFILE_PARSING: DWORD = 9655; +pub const DNS_ERROR_DATABASE_BASE: DWORD = 9700; +pub const DNS_ERROR_RECORD_DOES_NOT_EXIST: DWORD = 9701; +pub const DNS_ERROR_RECORD_FORMAT: DWORD = 9702; +pub const DNS_ERROR_NODE_CREATION_FAILED: DWORD = 9703; +pub const DNS_ERROR_UNKNOWN_RECORD_TYPE: DWORD = 9704; +pub const DNS_ERROR_RECORD_TIMED_OUT: DWORD = 9705; +pub const DNS_ERROR_NAME_NOT_IN_ZONE: DWORD = 9706; +pub const DNS_ERROR_CNAME_LOOP: DWORD = 9707; +pub const DNS_ERROR_NODE_IS_CNAME: DWORD = 9708; +pub const DNS_ERROR_CNAME_COLLISION: DWORD = 9709; +pub const DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT: DWORD = 9710; +pub const DNS_ERROR_RECORD_ALREADY_EXISTS: DWORD = 9711; +pub const DNS_ERROR_SECONDARY_DATA: DWORD = 9712; +pub const DNS_ERROR_NO_CREATE_CACHE_DATA: DWORD = 9713; +pub const DNS_ERROR_NAME_DOES_NOT_EXIST: DWORD = 9714; +pub const DNS_WARNING_PTR_CREATE_FAILED: DWORD = 9715; +pub const DNS_WARNING_DOMAIN_UNDELETED: DWORD = 9716; +pub const DNS_ERROR_DS_UNAVAILABLE: DWORD = 9717; +pub const DNS_ERROR_DS_ZONE_ALREADY_EXISTS: DWORD = 9718; +pub const DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE: DWORD = 9719; +pub const DNS_ERROR_NODE_IS_DNAME: DWORD = 9720; +pub const DNS_ERROR_DNAME_COLLISION: DWORD = 9721; +pub const DNS_ERROR_ALIAS_LOOP: DWORD = 9722; +pub const DNS_ERROR_OPERATION_BASE: DWORD = 9750; +pub const DNS_INFO_AXFR_COMPLETE: DWORD = 9751; +pub const DNS_ERROR_AXFR: DWORD = 9752; +pub const DNS_INFO_ADDED_LOCAL_WINS: DWORD = 9753; +pub const DNS_ERROR_SECURE_BASE: DWORD = 9800; +pub const DNS_STATUS_CONTINUE_NEEDED: DWORD = 9801; +pub const DNS_ERROR_SETUP_BASE: DWORD = 9850; +pub const DNS_ERROR_NO_TCPIP: DWORD = 9851; +pub const DNS_ERROR_NO_DNS_SERVERS: DWORD = 9852; +pub const DNS_ERROR_DP_BASE: DWORD = 9900; +pub const DNS_ERROR_DP_DOES_NOT_EXIST: DWORD = 9901; +pub const DNS_ERROR_DP_ALREADY_EXISTS: DWORD = 9902; +pub const DNS_ERROR_DP_NOT_ENLISTED: DWORD = 9903; +pub const DNS_ERROR_DP_ALREADY_ENLISTED: DWORD = 9904; +pub const DNS_ERROR_DP_NOT_AVAILABLE: DWORD = 9905; +pub const DNS_ERROR_DP_FSMO_ERROR: DWORD = 9906; +pub const DNS_ERROR_ZONESCOPE_ALREADY_EXISTS: DWORD = 9951; +pub const DNS_ERROR_ZONESCOPE_DOES_NOT_EXIST: DWORD = 9952; +pub const DNS_ERROR_DEFAULT_ZONESCOPE: DWORD = 9953; +pub const DNS_ERROR_INVALID_ZONESCOPE_NAME: DWORD = 9954; +pub const DNS_ERROR_NOT_ALLOWED_WITH_ZONESCOPES: DWORD = 9955; +pub const DNS_ERROR_LOAD_ZONESCOPE_FAILED: DWORD = 9956; +pub const DNS_ERROR_ZONESCOPE_FILE_WRITEBACK_FAILED: DWORD = 9957; +pub const DNS_ERROR_INVALID_SCOPE_NAME: DWORD = 9958; +pub const DNS_ERROR_SCOPE_DOES_NOT_EXIST: DWORD = 9959; +pub const DNS_ERROR_DEFAULT_SCOPE: DWORD = 9960; +pub const DNS_ERROR_INVALID_SCOPE_OPERATION: DWORD = 9961; +pub const DNS_ERROR_SCOPE_LOCKED: DWORD = 9962; +pub const DNS_ERROR_SCOPE_ALREADY_EXISTS: DWORD = 9963; +pub const WSABASEERR: DWORD = 10000; +pub const WSAEINTR: DWORD = 10004; +pub const WSAEBADF: DWORD = 10009; +pub const WSAEACCES: DWORD = 10013; +pub const WSAEFAULT: DWORD = 10014; +pub const WSAEINVAL: DWORD = 10022; +pub const WSAEMFILE: DWORD = 10024; +pub const WSAEWOULDBLOCK: DWORD = 10035; +pub const WSAEINPROGRESS: DWORD = 10036; +pub const WSAEALREADY: DWORD = 10037; +pub const WSAENOTSOCK: DWORD = 10038; +pub const WSAEDESTADDRREQ: DWORD = 10039; +pub const WSAEMSGSIZE: DWORD = 10040; +pub const WSAEPROTOTYPE: DWORD = 10041; +pub const WSAENOPROTOOPT: DWORD = 10042; +pub const WSAEPROTONOSUPPORT: DWORD = 10043; +pub const WSAESOCKTNOSUPPORT: DWORD = 10044; +pub const WSAEOPNOTSUPP: DWORD = 10045; +pub const WSAEPFNOSUPPORT: DWORD = 10046; +pub const WSAEAFNOSUPPORT: DWORD = 10047; +pub const WSAEADDRINUSE: DWORD = 10048; +pub const WSAEADDRNOTAVAIL: DWORD = 10049; +pub const WSAENETDOWN: DWORD = 10050; +pub const WSAENETUNREACH: DWORD = 10051; +pub const WSAENETRESET: DWORD = 10052; +pub const WSAECONNABORTED: DWORD = 10053; +pub const WSAECONNRESET: DWORD = 10054; +pub const WSAENOBUFS: DWORD = 10055; +pub const WSAEISCONN: DWORD = 10056; +pub const WSAENOTCONN: DWORD = 10057; +pub const WSAESHUTDOWN: DWORD = 10058; +pub const WSAETOOMANYREFS: DWORD = 10059; +pub const WSAETIMEDOUT: DWORD = 10060; +pub const WSAECONNREFUSED: DWORD = 10061; +pub const WSAELOOP: DWORD = 10062; +pub const WSAENAMETOOLONG: DWORD = 10063; +pub const WSAEHOSTDOWN: DWORD = 10064; +pub const WSAEHOSTUNREACH: DWORD = 10065; +pub const WSAENOTEMPTY: DWORD = 10066; +pub const WSAEPROCLIM: DWORD = 10067; +pub const WSAEUSERS: DWORD = 10068; +pub const WSAEDQUOT: DWORD = 10069; +pub const WSAESTALE: DWORD = 10070; +pub const WSAEREMOTE: DWORD = 10071; +pub const WSASYSNOTREADY: DWORD = 10091; +pub const WSAVERNOTSUPPORTED: DWORD = 10092; +pub const WSANOTINITIALISED: DWORD = 10093; +pub const WSAEDISCON: DWORD = 10101; +pub const WSAENOMORE: DWORD = 10102; +pub const WSAECANCELLED: DWORD = 10103; +pub const WSAEINVALIDPROCTABLE: DWORD = 10104; +pub const WSAEINVALIDPROVIDER: DWORD = 10105; +pub const WSAEPROVIDERFAILEDINIT: DWORD = 10106; +pub const WSASYSCALLFAILURE: DWORD = 10107; +pub const WSASERVICE_NOT_FOUND: DWORD = 10108; +pub const WSATYPE_NOT_FOUND: DWORD = 10109; +pub const WSA_E_NO_MORE: DWORD = 10110; +pub const WSA_E_CANCELLED: DWORD = 10111; +pub const WSAEREFUSED: DWORD = 10112; +pub const WSAHOST_NOT_FOUND: DWORD = 11001; +pub const WSATRY_AGAIN: DWORD = 11002; +pub const WSANO_RECOVERY: DWORD = 11003; +pub const WSANO_DATA: DWORD = 11004; +pub const WSA_QOS_RECEIVERS: DWORD = 11005; +pub const WSA_QOS_SENDERS: DWORD = 11006; +pub const WSA_QOS_NO_SENDERS: DWORD = 11007; +pub const WSA_QOS_NO_RECEIVERS: DWORD = 11008; +pub const WSA_QOS_REQUEST_CONFIRMED: DWORD = 11009; +pub const WSA_QOS_ADMISSION_FAILURE: DWORD = 11010; +pub const WSA_QOS_POLICY_FAILURE: DWORD = 11011; +pub const WSA_QOS_BAD_STYLE: DWORD = 11012; +pub const WSA_QOS_BAD_OBJECT: DWORD = 11013; +pub const WSA_QOS_TRAFFIC_CTRL_ERROR: DWORD = 11014; +pub const WSA_QOS_GENERIC_ERROR: DWORD = 11015; +pub const WSA_QOS_ESERVICETYPE: DWORD = 11016; +pub const WSA_QOS_EFLOWSPEC: DWORD = 11017; +pub const WSA_QOS_EPROVSPECBUF: DWORD = 11018; +pub const WSA_QOS_EFILTERSTYLE: DWORD = 11019; +pub const WSA_QOS_EFILTERTYPE: DWORD = 11020; +pub const WSA_QOS_EFILTERCOUNT: DWORD = 11021; +pub const WSA_QOS_EOBJLENGTH: DWORD = 11022; +pub const WSA_QOS_EFLOWCOUNT: DWORD = 11023; +pub const WSA_QOS_EUNKOWNPSOBJ: DWORD = 11024; +pub const WSA_QOS_EPOLICYOBJ: DWORD = 11025; +pub const WSA_QOS_EFLOWDESC: DWORD = 11026; +pub const WSA_QOS_EPSFLOWSPEC: DWORD = 11027; +pub const WSA_QOS_EPSFILTERSPEC: DWORD = 11028; +pub const WSA_QOS_ESDMODEOBJ: DWORD = 11029; +pub const WSA_QOS_ESHAPERATEOBJ: DWORD = 11030; +pub const WSA_QOS_RESERVED_PETYPE: DWORD = 11031; +pub const WSA_SECURE_HOST_NOT_FOUND: DWORD = 11032; +pub const WSA_IPSEC_NAME_POLICY_ERROR: DWORD = 11033; +pub const ERROR_IPSEC_QM_POLICY_EXISTS: DWORD = 13000; +pub const ERROR_IPSEC_QM_POLICY_NOT_FOUND: DWORD = 13001; +pub const ERROR_IPSEC_QM_POLICY_IN_USE: DWORD = 13002; +pub const ERROR_IPSEC_MM_POLICY_EXISTS: DWORD = 13003; +pub const ERROR_IPSEC_MM_POLICY_NOT_FOUND: DWORD = 13004; +pub const ERROR_IPSEC_MM_POLICY_IN_USE: DWORD = 13005; +pub const ERROR_IPSEC_MM_FILTER_EXISTS: DWORD = 13006; +pub const ERROR_IPSEC_MM_FILTER_NOT_FOUND: DWORD = 13007; +pub const ERROR_IPSEC_TRANSPORT_FILTER_EXISTS: DWORD = 13008; +pub const ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND: DWORD = 13009; +pub const ERROR_IPSEC_MM_AUTH_EXISTS: DWORD = 13010; +pub const ERROR_IPSEC_MM_AUTH_NOT_FOUND: DWORD = 13011; +pub const ERROR_IPSEC_MM_AUTH_IN_USE: DWORD = 13012; +pub const ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND: DWORD = 13013; +pub const ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND: DWORD = 13014; +pub const ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND: DWORD = 13015; +pub const ERROR_IPSEC_TUNNEL_FILTER_EXISTS: DWORD = 13016; +pub const ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND: DWORD = 13017; +pub const ERROR_IPSEC_MM_FILTER_PENDING_DELETION: DWORD = 13018; +pub const ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION: DWORD = 13019; +pub const ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION: DWORD = 13020; +pub const ERROR_IPSEC_MM_POLICY_PENDING_DELETION: DWORD = 13021; +pub const ERROR_IPSEC_MM_AUTH_PENDING_DELETION: DWORD = 13022; +pub const ERROR_IPSEC_QM_POLICY_PENDING_DELETION: DWORD = 13023; +pub const WARNING_IPSEC_MM_POLICY_PRUNED: DWORD = 13024; +pub const WARNING_IPSEC_QM_POLICY_PRUNED: DWORD = 13025; +pub const ERROR_IPSEC_IKE_NEG_STATUS_BEGIN: DWORD = 13800; +pub const ERROR_IPSEC_IKE_AUTH_FAIL: DWORD = 13801; +pub const ERROR_IPSEC_IKE_ATTRIB_FAIL: DWORD = 13802; +pub const ERROR_IPSEC_IKE_NEGOTIATION_PENDING: DWORD = 13803; +pub const ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR: DWORD = 13804; +pub const ERROR_IPSEC_IKE_TIMED_OUT: DWORD = 13805; +pub const ERROR_IPSEC_IKE_NO_CERT: DWORD = 13806; +pub const ERROR_IPSEC_IKE_SA_DELETED: DWORD = 13807; +pub const ERROR_IPSEC_IKE_SA_REAPED: DWORD = 13808; +pub const ERROR_IPSEC_IKE_MM_ACQUIRE_DROP: DWORD = 13809; +pub const ERROR_IPSEC_IKE_QM_ACQUIRE_DROP: DWORD = 13810; +pub const ERROR_IPSEC_IKE_QUEUE_DROP_MM: DWORD = 13811; +pub const ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM: DWORD = 13812; +pub const ERROR_IPSEC_IKE_DROP_NO_RESPONSE: DWORD = 13813; +pub const ERROR_IPSEC_IKE_MM_DELAY_DROP: DWORD = 13814; +pub const ERROR_IPSEC_IKE_QM_DELAY_DROP: DWORD = 13815; +pub const ERROR_IPSEC_IKE_ERROR: DWORD = 13816; +pub const ERROR_IPSEC_IKE_CRL_FAILED: DWORD = 13817; +pub const ERROR_IPSEC_IKE_INVALID_KEY_USAGE: DWORD = 13818; +pub const ERROR_IPSEC_IKE_INVALID_CERT_TYPE: DWORD = 13819; +pub const ERROR_IPSEC_IKE_NO_PRIVATE_KEY: DWORD = 13820; +pub const ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY: DWORD = 13821; +pub const ERROR_IPSEC_IKE_DH_FAIL: DWORD = 13822; +pub const ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED: DWORD = 13823; +pub const ERROR_IPSEC_IKE_INVALID_HEADER: DWORD = 13824; +pub const ERROR_IPSEC_IKE_NO_POLICY: DWORD = 13825; +pub const ERROR_IPSEC_IKE_INVALID_SIGNATURE: DWORD = 13826; +pub const ERROR_IPSEC_IKE_KERBEROS_ERROR: DWORD = 13827; +pub const ERROR_IPSEC_IKE_NO_PUBLIC_KEY: DWORD = 13828; +pub const ERROR_IPSEC_IKE_PROCESS_ERR: DWORD = 13829; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_SA: DWORD = 13830; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_PROP: DWORD = 13831; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_TRANS: DWORD = 13832; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_KE: DWORD = 13833; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_ID: DWORD = 13834; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_CERT: DWORD = 13835; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ: DWORD = 13836; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_HASH: DWORD = 13837; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_SIG: DWORD = 13838; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_NONCE: DWORD = 13839; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY: DWORD = 13840; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_DELETE: DWORD = 13841; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR: DWORD = 13842; +pub const ERROR_IPSEC_IKE_INVALID_PAYLOAD: DWORD = 13843; +pub const ERROR_IPSEC_IKE_LOAD_SOFT_SA: DWORD = 13844; +pub const ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN: DWORD = 13845; +pub const ERROR_IPSEC_IKE_INVALID_COOKIE: DWORD = 13846; +pub const ERROR_IPSEC_IKE_NO_PEER_CERT: DWORD = 13847; +pub const ERROR_IPSEC_IKE_PEER_CRL_FAILED: DWORD = 13848; +pub const ERROR_IPSEC_IKE_POLICY_CHANGE: DWORD = 13849; +pub const ERROR_IPSEC_IKE_NO_MM_POLICY: DWORD = 13850; +pub const ERROR_IPSEC_IKE_NOTCBPRIV: DWORD = 13851; +pub const ERROR_IPSEC_IKE_SECLOADFAIL: DWORD = 13852; +pub const ERROR_IPSEC_IKE_FAILSSPINIT: DWORD = 13853; +pub const ERROR_IPSEC_IKE_FAILQUERYSSP: DWORD = 13854; +pub const ERROR_IPSEC_IKE_SRVACQFAIL: DWORD = 13855; +pub const ERROR_IPSEC_IKE_SRVQUERYCRED: DWORD = 13856; +pub const ERROR_IPSEC_IKE_GETSPIFAIL: DWORD = 13857; +pub const ERROR_IPSEC_IKE_INVALID_FILTER: DWORD = 13858; +pub const ERROR_IPSEC_IKE_OUT_OF_MEMORY: DWORD = 13859; +pub const ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED: DWORD = 13860; +pub const ERROR_IPSEC_IKE_INVALID_POLICY: DWORD = 13861; +pub const ERROR_IPSEC_IKE_UNKNOWN_DOI: DWORD = 13862; +pub const ERROR_IPSEC_IKE_INVALID_SITUATION: DWORD = 13863; +pub const ERROR_IPSEC_IKE_DH_FAILURE: DWORD = 13864; +pub const ERROR_IPSEC_IKE_INVALID_GROUP: DWORD = 13865; +pub const ERROR_IPSEC_IKE_ENCRYPT: DWORD = 13866; +pub const ERROR_IPSEC_IKE_DECRYPT: DWORD = 13867; +pub const ERROR_IPSEC_IKE_POLICY_MATCH: DWORD = 13868; +pub const ERROR_IPSEC_IKE_UNSUPPORTED_ID: DWORD = 13869; +pub const ERROR_IPSEC_IKE_INVALID_HASH: DWORD = 13870; +pub const ERROR_IPSEC_IKE_INVALID_HASH_ALG: DWORD = 13871; +pub const ERROR_IPSEC_IKE_INVALID_HASH_SIZE: DWORD = 13872; +pub const ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG: DWORD = 13873; +pub const ERROR_IPSEC_IKE_INVALID_AUTH_ALG: DWORD = 13874; +pub const ERROR_IPSEC_IKE_INVALID_SIG: DWORD = 13875; +pub const ERROR_IPSEC_IKE_LOAD_FAILED: DWORD = 13876; +pub const ERROR_IPSEC_IKE_RPC_DELETE: DWORD = 13877; +pub const ERROR_IPSEC_IKE_BENIGN_REINIT: DWORD = 13878; +pub const ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY: DWORD = 13879; +pub const ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION: DWORD = 13880; +pub const ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN: DWORD = 13881; +pub const ERROR_IPSEC_IKE_MM_LIMIT: DWORD = 13882; +pub const ERROR_IPSEC_IKE_NEGOTIATION_DISABLED: DWORD = 13883; +pub const ERROR_IPSEC_IKE_QM_LIMIT: DWORD = 13884; +pub const ERROR_IPSEC_IKE_MM_EXPIRED: DWORD = 13885; +pub const ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID: DWORD = 13886; +pub const ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH: DWORD = 13887; +pub const ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID: DWORD = 13888; +pub const ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD: DWORD = 13889; +pub const ERROR_IPSEC_IKE_DOS_COOKIE_SENT: DWORD = 13890; +pub const ERROR_IPSEC_IKE_SHUTTING_DOWN: DWORD = 13891; +pub const ERROR_IPSEC_IKE_CGA_AUTH_FAILED: DWORD = 13892; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_NATOA: DWORD = 13893; +pub const ERROR_IPSEC_IKE_INVALID_MM_FOR_QM: DWORD = 13894; +pub const ERROR_IPSEC_IKE_QM_EXPIRED: DWORD = 13895; +pub const ERROR_IPSEC_IKE_TOO_MANY_FILTERS: DWORD = 13896; +pub const ERROR_IPSEC_IKE_NEG_STATUS_END: DWORD = 13897; +pub const ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL: DWORD = 13898; +pub const ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE: DWORD = 13899; +pub const ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING: DWORD = 13900; +pub const ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING: DWORD = 13901; +pub const ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS: DWORD = 13902; +pub const ERROR_IPSEC_IKE_RATELIMIT_DROP: DWORD = 13903; +pub const ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE: DWORD = 13904; +pub const ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE: DWORD = 13905; +pub const ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE: DWORD = 13906; +pub const ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY: DWORD = 13907; +pub const ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE: DWORD = 13908; +pub const ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END: DWORD = 13909; +pub const ERROR_IPSEC_BAD_SPI: DWORD = 13910; +pub const ERROR_IPSEC_SA_LIFETIME_EXPIRED: DWORD = 13911; +pub const ERROR_IPSEC_WRONG_SA: DWORD = 13912; +pub const ERROR_IPSEC_REPLAY_CHECK_FAILED: DWORD = 13913; +pub const ERROR_IPSEC_INVALID_PACKET: DWORD = 13914; +pub const ERROR_IPSEC_INTEGRITY_CHECK_FAILED: DWORD = 13915; +pub const ERROR_IPSEC_CLEAR_TEXT_DROP: DWORD = 13916; +pub const ERROR_IPSEC_AUTH_FIREWALL_DROP: DWORD = 13917; +pub const ERROR_IPSEC_THROTTLE_DROP: DWORD = 13918; +pub const ERROR_IPSEC_DOSP_BLOCK: DWORD = 13925; +pub const ERROR_IPSEC_DOSP_RECEIVED_MULTICAST: DWORD = 13926; +pub const ERROR_IPSEC_DOSP_INVALID_PACKET: DWORD = 13927; +pub const ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED: DWORD = 13928; +pub const ERROR_IPSEC_DOSP_MAX_ENTRIES: DWORD = 13929; +pub const ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED: DWORD = 13930; +pub const ERROR_IPSEC_DOSP_NOT_INSTALLED: DWORD = 13931; +pub const ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES: DWORD = 13932; +pub const ERROR_SXS_SECTION_NOT_FOUND: DWORD = 14000; +pub const ERROR_SXS_CANT_GEN_ACTCTX: DWORD = 14001; +pub const ERROR_SXS_INVALID_ACTCTXDATA_FORMAT: DWORD = 14002; +pub const ERROR_SXS_ASSEMBLY_NOT_FOUND: DWORD = 14003; +pub const ERROR_SXS_MANIFEST_FORMAT_ERROR: DWORD = 14004; +pub const ERROR_SXS_MANIFEST_PARSE_ERROR: DWORD = 14005; +pub const ERROR_SXS_ACTIVATION_CONTEXT_DISABLED: DWORD = 14006; +pub const ERROR_SXS_KEY_NOT_FOUND: DWORD = 14007; +pub const ERROR_SXS_VERSION_CONFLICT: DWORD = 14008; +pub const ERROR_SXS_WRONG_SECTION_TYPE: DWORD = 14009; +pub const ERROR_SXS_THREAD_QUERIES_DISABLED: DWORD = 14010; +pub const ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET: DWORD = 14011; +pub const ERROR_SXS_UNKNOWN_ENCODING_GROUP: DWORD = 14012; +pub const ERROR_SXS_UNKNOWN_ENCODING: DWORD = 14013; +pub const ERROR_SXS_INVALID_XML_NAMESPACE_URI: DWORD = 14014; +pub const ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED: DWORD = 14015; +pub const ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED: DWORD = 14016; +pub const ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE: DWORD = 14017; +pub const ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE: DWORD = 14018; +pub const ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE: DWORD = 14019; +pub const ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT: DWORD = 14020; +pub const ERROR_SXS_DUPLICATE_DLL_NAME: DWORD = 14021; +pub const ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME: DWORD = 14022; +pub const ERROR_SXS_DUPLICATE_CLSID: DWORD = 14023; +pub const ERROR_SXS_DUPLICATE_IID: DWORD = 14024; +pub const ERROR_SXS_DUPLICATE_TLBID: DWORD = 14025; +pub const ERROR_SXS_DUPLICATE_PROGID: DWORD = 14026; +pub const ERROR_SXS_DUPLICATE_ASSEMBLY_NAME: DWORD = 14027; +pub const ERROR_SXS_FILE_HASH_MISMATCH: DWORD = 14028; +pub const ERROR_SXS_POLICY_PARSE_ERROR: DWORD = 14029; +pub const ERROR_SXS_XML_E_MISSINGQUOTE: DWORD = 14030; +pub const ERROR_SXS_XML_E_COMMENTSYNTAX: DWORD = 14031; +pub const ERROR_SXS_XML_E_BADSTARTNAMECHAR: DWORD = 14032; +pub const ERROR_SXS_XML_E_BADNAMECHAR: DWORD = 14033; +pub const ERROR_SXS_XML_E_BADCHARINSTRING: DWORD = 14034; +pub const ERROR_SXS_XML_E_XMLDECLSYNTAX: DWORD = 14035; +pub const ERROR_SXS_XML_E_BADCHARDATA: DWORD = 14036; +pub const ERROR_SXS_XML_E_MISSINGWHITESPACE: DWORD = 14037; +pub const ERROR_SXS_XML_E_EXPECTINGTAGEND: DWORD = 14038; +pub const ERROR_SXS_XML_E_MISSINGSEMICOLON: DWORD = 14039; +pub const ERROR_SXS_XML_E_UNBALANCEDPAREN: DWORD = 14040; +pub const ERROR_SXS_XML_E_INTERNALERROR: DWORD = 14041; +pub const ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE: DWORD = 14042; +pub const ERROR_SXS_XML_E_INCOMPLETE_ENCODING: DWORD = 14043; +pub const ERROR_SXS_XML_E_MISSING_PAREN: DWORD = 14044; +pub const ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE: DWORD = 14045; +pub const ERROR_SXS_XML_E_MULTIPLE_COLONS: DWORD = 14046; +pub const ERROR_SXS_XML_E_INVALID_DECIMAL: DWORD = 14047; +pub const ERROR_SXS_XML_E_INVALID_HEXIDECIMAL: DWORD = 14048; +pub const ERROR_SXS_XML_E_INVALID_UNICODE: DWORD = 14049; +pub const ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK: DWORD = 14050; +pub const ERROR_SXS_XML_E_UNEXPECTEDENDTAG: DWORD = 14051; +pub const ERROR_SXS_XML_E_UNCLOSEDTAG: DWORD = 14052; +pub const ERROR_SXS_XML_E_DUPLICATEATTRIBUTE: DWORD = 14053; +pub const ERROR_SXS_XML_E_MULTIPLEROOTS: DWORD = 14054; +pub const ERROR_SXS_XML_E_INVALIDATROOTLEVEL: DWORD = 14055; +pub const ERROR_SXS_XML_E_BADXMLDECL: DWORD = 14056; +pub const ERROR_SXS_XML_E_MISSINGROOT: DWORD = 14057; +pub const ERROR_SXS_XML_E_UNEXPECTEDEOF: DWORD = 14058; +pub const ERROR_SXS_XML_E_BADPEREFINSUBSET: DWORD = 14059; +pub const ERROR_SXS_XML_E_UNCLOSEDSTARTTAG: DWORD = 14060; +pub const ERROR_SXS_XML_E_UNCLOSEDENDTAG: DWORD = 14061; +pub const ERROR_SXS_XML_E_UNCLOSEDSTRING: DWORD = 14062; +pub const ERROR_SXS_XML_E_UNCLOSEDCOMMENT: DWORD = 14063; +pub const ERROR_SXS_XML_E_UNCLOSEDDECL: DWORD = 14064; +pub const ERROR_SXS_XML_E_UNCLOSEDCDATA: DWORD = 14065; +pub const ERROR_SXS_XML_E_RESERVEDNAMESPACE: DWORD = 14066; +pub const ERROR_SXS_XML_E_INVALIDENCODING: DWORD = 14067; +pub const ERROR_SXS_XML_E_INVALIDSWITCH: DWORD = 14068; +pub const ERROR_SXS_XML_E_BADXMLCASE: DWORD = 14069; +pub const ERROR_SXS_XML_E_INVALID_STANDALONE: DWORD = 14070; +pub const ERROR_SXS_XML_E_UNEXPECTED_STANDALONE: DWORD = 14071; +pub const ERROR_SXS_XML_E_INVALID_VERSION: DWORD = 14072; +pub const ERROR_SXS_XML_E_MISSINGEQUALS: DWORD = 14073; +pub const ERROR_SXS_PROTECTION_RECOVERY_FAILED: DWORD = 14074; +pub const ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT: DWORD = 14075; +pub const ERROR_SXS_PROTECTION_CATALOG_NOT_VALID: DWORD = 14076; +pub const ERROR_SXS_UNTRANSLATABLE_HRESULT: DWORD = 14077; +pub const ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING: DWORD = 14078; +pub const ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE: DWORD = 14079; +pub const ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME: DWORD = 14080; +pub const ERROR_SXS_ASSEMBLY_MISSING: DWORD = 14081; +pub const ERROR_SXS_CORRUPT_ACTIVATION_STACK: DWORD = 14082; +pub const ERROR_SXS_CORRUPTION: DWORD = 14083; +pub const ERROR_SXS_EARLY_DEACTIVATION: DWORD = 14084; +pub const ERROR_SXS_INVALID_DEACTIVATION: DWORD = 14085; +pub const ERROR_SXS_MULTIPLE_DEACTIVATION: DWORD = 14086; +pub const ERROR_SXS_PROCESS_TERMINATION_REQUESTED: DWORD = 14087; +pub const ERROR_SXS_RELEASE_ACTIVATION_CONTEXT: DWORD = 14088; +pub const ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY: DWORD = 14089; +pub const ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE: DWORD = 14090; +pub const ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME: DWORD = 14091; +pub const ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE: DWORD = 14092; +pub const ERROR_SXS_IDENTITY_PARSE_ERROR: DWORD = 14093; +pub const ERROR_MALFORMED_SUBSTITUTION_STRING: DWORD = 14094; +pub const ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN: DWORD = 14095; +pub const ERROR_UNMAPPED_SUBSTITUTION_STRING: DWORD = 14096; +pub const ERROR_SXS_ASSEMBLY_NOT_LOCKED: DWORD = 14097; +pub const ERROR_SXS_COMPONENT_STORE_CORRUPT: DWORD = 14098; +pub const ERROR_ADVANCED_INSTALLER_FAILED: DWORD = 14099; +pub const ERROR_XML_ENCODING_MISMATCH: DWORD = 14100; +pub const ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT: DWORD = 14101; +pub const ERROR_SXS_IDENTITIES_DIFFERENT: DWORD = 14102; +pub const ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT: DWORD = 14103; +pub const ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY: DWORD = 14104; +pub const ERROR_SXS_MANIFEST_TOO_BIG: DWORD = 14105; +pub const ERROR_SXS_SETTING_NOT_REGISTERED: DWORD = 14106; +pub const ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE: DWORD = 14107; +pub const ERROR_SMI_PRIMITIVE_INSTALLER_FAILED: DWORD = 14108; +pub const ERROR_GENERIC_COMMAND_FAILED: DWORD = 14109; +pub const ERROR_SXS_FILE_HASH_MISSING: DWORD = 14110; +pub const ERROR_EVT_INVALID_CHANNEL_PATH: DWORD = 15000; +pub const ERROR_EVT_INVALID_QUERY: DWORD = 15001; +pub const ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND: DWORD = 15002; +pub const ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND: DWORD = 15003; +pub const ERROR_EVT_INVALID_PUBLISHER_NAME: DWORD = 15004; +pub const ERROR_EVT_INVALID_EVENT_DATA: DWORD = 15005; +pub const ERROR_EVT_CHANNEL_NOT_FOUND: DWORD = 15007; +pub const ERROR_EVT_MALFORMED_XML_TEXT: DWORD = 15008; +pub const ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL: DWORD = 15009; +pub const ERROR_EVT_CONFIGURATION_ERROR: DWORD = 15010; +pub const ERROR_EVT_QUERY_RESULT_STALE: DWORD = 15011; +pub const ERROR_EVT_QUERY_RESULT_INVALID_POSITION: DWORD = 15012; +pub const ERROR_EVT_NON_VALIDATING_MSXML: DWORD = 15013; +pub const ERROR_EVT_FILTER_ALREADYSCOPED: DWORD = 15014; +pub const ERROR_EVT_FILTER_NOTELTSET: DWORD = 15015; +pub const ERROR_EVT_FILTER_INVARG: DWORD = 15016; +pub const ERROR_EVT_FILTER_INVTEST: DWORD = 15017; +pub const ERROR_EVT_FILTER_INVTYPE: DWORD = 15018; +pub const ERROR_EVT_FILTER_PARSEERR: DWORD = 15019; +pub const ERROR_EVT_FILTER_UNSUPPORTEDOP: DWORD = 15020; +pub const ERROR_EVT_FILTER_UNEXPECTEDTOKEN: DWORD = 15021; +pub const ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL: DWORD = 15022; +pub const ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE: DWORD = 15023; +pub const ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE: DWORD = 15024; +pub const ERROR_EVT_CHANNEL_CANNOT_ACTIVATE: DWORD = 15025; +pub const ERROR_EVT_FILTER_TOO_COMPLEX: DWORD = 15026; +pub const ERROR_EVT_MESSAGE_NOT_FOUND: DWORD = 15027; +pub const ERROR_EVT_MESSAGE_ID_NOT_FOUND: DWORD = 15028; +pub const ERROR_EVT_UNRESOLVED_VALUE_INSERT: DWORD = 15029; +pub const ERROR_EVT_UNRESOLVED_PARAMETER_INSERT: DWORD = 15030; +pub const ERROR_EVT_MAX_INSERTS_REACHED: DWORD = 15031; +pub const ERROR_EVT_EVENT_DEFINITION_NOT_FOUND: DWORD = 15032; +pub const ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND: DWORD = 15033; +pub const ERROR_EVT_VERSION_TOO_OLD: DWORD = 15034; +pub const ERROR_EVT_VERSION_TOO_NEW: DWORD = 15035; +pub const ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY: DWORD = 15036; +pub const ERROR_EVT_PUBLISHER_DISABLED: DWORD = 15037; +pub const ERROR_EVT_FILTER_OUT_OF_RANGE: DWORD = 15038; +pub const ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE: DWORD = 15080; +pub const ERROR_EC_LOG_DISABLED: DWORD = 15081; +pub const ERROR_EC_CIRCULAR_FORWARDING: DWORD = 15082; +pub const ERROR_EC_CREDSTORE_FULL: DWORD = 15083; +pub const ERROR_EC_CRED_NOT_FOUND: DWORD = 15084; +pub const ERROR_EC_NO_ACTIVE_CHANNEL: DWORD = 15085; +pub const ERROR_MUI_FILE_NOT_FOUND: DWORD = 15100; +pub const ERROR_MUI_INVALID_FILE: DWORD = 15101; +pub const ERROR_MUI_INVALID_RC_CONFIG: DWORD = 15102; +pub const ERROR_MUI_INVALID_LOCALE_NAME: DWORD = 15103; +pub const ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME: DWORD = 15104; +pub const ERROR_MUI_FILE_NOT_LOADED: DWORD = 15105; +pub const ERROR_RESOURCE_ENUM_USER_STOP: DWORD = 15106; +pub const ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED: DWORD = 15107; +pub const ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME: DWORD = 15108; +pub const ERROR_MRM_RUNTIME_NO_DEFAULT_OR_NEUTRAL_RESOURCE: DWORD = 15110; +pub const ERROR_MRM_INVALID_PRICONFIG: DWORD = 15111; +pub const ERROR_MRM_INVALID_FILE_TYPE: DWORD = 15112; +pub const ERROR_MRM_UNKNOWN_QUALIFIER: DWORD = 15113; +pub const ERROR_MRM_INVALID_QUALIFIER_VALUE: DWORD = 15114; +pub const ERROR_MRM_NO_CANDIDATE: DWORD = 15115; +pub const ERROR_MRM_NO_MATCH_OR_DEFAULT_CANDIDATE: DWORD = 15116; +pub const ERROR_MRM_RESOURCE_TYPE_MISMATCH: DWORD = 15117; +pub const ERROR_MRM_DUPLICATE_MAP_NAME: DWORD = 15118; +pub const ERROR_MRM_DUPLICATE_ENTRY: DWORD = 15119; +pub const ERROR_MRM_INVALID_RESOURCE_IDENTIFIER: DWORD = 15120; +pub const ERROR_MRM_FILEPATH_TOO_LONG: DWORD = 15121; +pub const ERROR_MRM_UNSUPPORTED_DIRECTORY_TYPE: DWORD = 15122; +pub const ERROR_MRM_INVALID_PRI_FILE: DWORD = 15126; +pub const ERROR_MRM_NAMED_RESOURCE_NOT_FOUND: DWORD = 15127; +pub const ERROR_MRM_MAP_NOT_FOUND: DWORD = 15135; +pub const ERROR_MRM_UNSUPPORTED_PROFILE_TYPE: DWORD = 15136; +pub const ERROR_MRM_INVALID_QUALIFIER_OPERATOR: DWORD = 15137; +pub const ERROR_MRM_INDETERMINATE_QUALIFIER_VALUE: DWORD = 15138; +pub const ERROR_MRM_AUTOMERGE_ENABLED: DWORD = 15139; +pub const ERROR_MRM_TOO_MANY_RESOURCES: DWORD = 15140; +pub const ERROR_MRM_UNSUPPORTED_FILE_TYPE_FOR_MERGE: DWORD = 15141; +pub const ERROR_MRM_UNSUPPORTED_FILE_TYPE_FOR_LOAD_UNLOAD_PRI_FILE: DWORD = 15142; +pub const ERROR_MRM_NO_CURRENT_VIEW_ON_THREAD: DWORD = 15143; +pub const ERROR_DIFFERENT_PROFILE_RESOURCE_MANAGER_EXIST: DWORD = 15144; +pub const ERROR_OPERATION_NOT_ALLOWED_FROM_SYSTEM_COMPONENT: DWORD = 15145; +pub const ERROR_MRM_DIRECT_REF_TO_NON_DEFAULT_RESOURCE: DWORD = 15146; +pub const ERROR_MRM_GENERATION_COUNT_MISMATCH: DWORD = 15147; +pub const ERROR_MCA_INVALID_CAPABILITIES_STRING: DWORD = 15200; +pub const ERROR_MCA_INVALID_VCP_VERSION: DWORD = 15201; +pub const ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION: DWORD = 15202; +pub const ERROR_MCA_MCCS_VERSION_MISMATCH: DWORD = 15203; +pub const ERROR_MCA_UNSUPPORTED_MCCS_VERSION: DWORD = 15204; +pub const ERROR_MCA_INTERNAL_ERROR: DWORD = 15205; +pub const ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED: DWORD = 15206; +pub const ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE: DWORD = 15207; +pub const ERROR_AMBIGUOUS_SYSTEM_DEVICE: DWORD = 15250; +pub const ERROR_SYSTEM_DEVICE_NOT_FOUND: DWORD = 15299; +pub const ERROR_HASH_NOT_SUPPORTED: DWORD = 15300; +pub const ERROR_HASH_NOT_PRESENT: DWORD = 15301; +pub const ERROR_SECONDARY_IC_PROVIDER_NOT_REGISTERED: DWORD = 15321; +pub const ERROR_GPIO_CLIENT_INFORMATION_INVALID: DWORD = 15322; +pub const ERROR_GPIO_VERSION_NOT_SUPPORTED: DWORD = 15323; +pub const ERROR_GPIO_INVALID_REGISTRATION_PACKET: DWORD = 15324; +pub const ERROR_GPIO_OPERATION_DENIED: DWORD = 15325; +pub const ERROR_GPIO_INCOMPATIBLE_CONNECT_MODE: DWORD = 15326; +pub const ERROR_GPIO_INTERRUPT_ALREADY_UNMASKED: DWORD = 15327; +pub const ERROR_CANNOT_SWITCH_RUNLEVEL: DWORD = 15400; +pub const ERROR_INVALID_RUNLEVEL_SETTING: DWORD = 15401; +pub const ERROR_RUNLEVEL_SWITCH_TIMEOUT: DWORD = 15402; +pub const ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT: DWORD = 15403; +pub const ERROR_RUNLEVEL_SWITCH_IN_PROGRESS: DWORD = 15404; +pub const ERROR_SERVICES_FAILED_AUTOSTART: DWORD = 15405; +pub const ERROR_COM_TASK_STOP_PENDING: DWORD = 15501; +pub const ERROR_INSTALL_OPEN_PACKAGE_FAILED: DWORD = 15600; +pub const ERROR_INSTALL_PACKAGE_NOT_FOUND: DWORD = 15601; +pub const ERROR_INSTALL_INVALID_PACKAGE: DWORD = 15602; +pub const ERROR_INSTALL_RESOLVE_DEPENDENCY_FAILED: DWORD = 15603; +pub const ERROR_INSTALL_OUT_OF_DISK_SPACE: DWORD = 15604; +pub const ERROR_INSTALL_NETWORK_FAILURE: DWORD = 15605; +pub const ERROR_INSTALL_REGISTRATION_FAILURE: DWORD = 15606; +pub const ERROR_INSTALL_DEREGISTRATION_FAILURE: DWORD = 15607; +pub const ERROR_INSTALL_CANCEL: DWORD = 15608; +pub const ERROR_INSTALL_FAILED: DWORD = 15609; +pub const ERROR_REMOVE_FAILED: DWORD = 15610; +pub const ERROR_PACKAGE_ALREADY_EXISTS: DWORD = 15611; +pub const ERROR_NEEDS_REMEDIATION: DWORD = 15612; +pub const ERROR_INSTALL_PREREQUISITE_FAILED: DWORD = 15613; +pub const ERROR_PACKAGE_REPOSITORY_CORRUPTED: DWORD = 15614; +pub const ERROR_INSTALL_POLICY_FAILURE: DWORD = 15615; +pub const ERROR_PACKAGE_UPDATING: DWORD = 15616; +pub const ERROR_DEPLOYMENT_BLOCKED_BY_POLICY: DWORD = 15617; +pub const ERROR_PACKAGES_IN_USE: DWORD = 15618; +pub const ERROR_RECOVERY_FILE_CORRUPT: DWORD = 15619; +pub const ERROR_INVALID_STAGED_SIGNATURE: DWORD = 15620; +pub const ERROR_DELETING_EXISTING_APPLICATIONDATA_STORE_FAILED: DWORD = 15621; +pub const ERROR_INSTALL_PACKAGE_DOWNGRADE: DWORD = 15622; +pub const ERROR_SYSTEM_NEEDS_REMEDIATION: DWORD = 15623; +pub const ERROR_APPX_INTEGRITY_FAILURE_CLR_NGEN: DWORD = 15624; +pub const ERROR_RESILIENCY_FILE_CORRUPT: DWORD = 15625; +pub const ERROR_INSTALL_FIREWALL_SERVICE_NOT_RUNNING: DWORD = 15626; +pub const APPMODEL_ERROR_NO_PACKAGE: DWORD = 15700; +pub const APPMODEL_ERROR_PACKAGE_RUNTIME_CORRUPT: DWORD = 15701; +pub const APPMODEL_ERROR_PACKAGE_IDENTITY_CORRUPT: DWORD = 15702; +pub const APPMODEL_ERROR_NO_APPLICATION: DWORD = 15703; +pub const APPMODEL_ERROR_DYNAMIC_PROPERTY_READ_FAILED: DWORD = 15704; +pub const APPMODEL_ERROR_DYNAMIC_PROPERTY_INVALID: DWORD = 15705; +pub const ERROR_STATE_LOAD_STORE_FAILED: DWORD = 15800; +pub const ERROR_STATE_GET_VERSION_FAILED: DWORD = 15801; +pub const ERROR_STATE_SET_VERSION_FAILED: DWORD = 15802; +pub const ERROR_STATE_STRUCTURED_RESET_FAILED: DWORD = 15803; +pub const ERROR_STATE_OPEN_CONTAINER_FAILED: DWORD = 15804; +pub const ERROR_STATE_CREATE_CONTAINER_FAILED: DWORD = 15805; +pub const ERROR_STATE_DELETE_CONTAINER_FAILED: DWORD = 15806; +pub const ERROR_STATE_READ_SETTING_FAILED: DWORD = 15807; +pub const ERROR_STATE_WRITE_SETTING_FAILED: DWORD = 15808; +pub const ERROR_STATE_DELETE_SETTING_FAILED: DWORD = 15809; +pub const ERROR_STATE_QUERY_SETTING_FAILED: DWORD = 15810; +pub const ERROR_STATE_READ_COMPOSITE_SETTING_FAILED: DWORD = 15811; +pub const ERROR_STATE_WRITE_COMPOSITE_SETTING_FAILED: DWORD = 15812; +pub const ERROR_STATE_ENUMERATE_CONTAINER_FAILED: DWORD = 15813; +pub const ERROR_STATE_ENUMERATE_SETTINGS_FAILED: DWORD = 15814; +pub const ERROR_STATE_COMPOSITE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED: DWORD = 15815; +pub const ERROR_STATE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED: DWORD = 15816; +pub const ERROR_STATE_SETTING_NAME_SIZE_LIMIT_EXCEEDED: DWORD = 15817; +pub const ERROR_STATE_CONTAINER_NAME_SIZE_LIMIT_EXCEEDED: DWORD = 15818; +pub const ERROR_API_UNAVAILABLE: DWORD = 15841; +pub const STORE_ERROR_UNLICENSED: DWORD = 15861; +pub const STORE_ERROR_UNLICENSED_USER: DWORD = 15862; +pub const STORE_ERROR_PENDING_COM_TRANSACTION: DWORD = 15863; +pub const STORE_ERROR_LICENSE_REVOKED: DWORD = 15864; +pub const SEVERITY_SUCCESS: HRESULT = 0; +pub const SEVERITY_ERROR: HRESULT = 1; +#[inline] +pub fn SUCCEEDED(hr: HRESULT) -> bool { + hr >= 0 +} +#[inline] +pub fn FAILED(hr: HRESULT) -> bool { + hr < 0 +} +#[inline] +pub fn IS_ERROR(hr: HRESULT) -> bool { + (hr as u32) >> 31 == (SEVERITY_ERROR as u32) +} +#[inline] +pub fn HRESULT_CODE(hr: HRESULT) -> HRESULT { + hr & 0xFFFF +} +#[inline] +pub fn SCODE_CODE(sc: SCODE) -> HRESULT { + sc & 0xFFFF +} +#[inline] +pub fn HRESULT_FACILITY(hr: HRESULT) -> HRESULT { + (hr >> 16) & 0x1fff +} +#[inline] +pub fn SCODE_FACILITY(sc: SCODE) -> HRESULT { + (sc >> 16) & 0x1fff +} +#[inline] +pub fn HRESULT_SEVERITY(hr: HRESULT) -> HRESULT { + (hr >> 31) & 0x1 +} +#[inline] +pub fn SCODE_SEVERITY(sc: SCODE) -> HRESULT { + (sc >> 31) & 0x1 +} +#[inline] +pub fn MAKE_HRESULT(sev: HRESULT, fac: HRESULT, code: HRESULT) -> HRESULT { + (sev << 31) | (fac << 16) | code +} +#[inline] +pub fn MAKE_SCODE(sev: HRESULT, fac: HRESULT, code: HRESULT) -> SCODE { + (sev << 31) | (fac << 16) | code +} +pub const FACILITY_NT_BIT: HRESULT = 0x10000000; +#[inline] +pub fn HRESULT_FROM_WIN32(x: c_ulong) -> HRESULT { + if x as i32 <= 0 { + x as i32 + } else { + ((x & 0x0000FFFF) | ((FACILITY_WIN32 as u32) << 16) | 0x80000000) as i32 + } +} +pub type HRESULT = c_long; +#[inline] +pub fn HRESULT_FROM_NT(x: c_ulong) -> HRESULT { + (x | FACILITY_NT_BIT as u32) as i32 +} +pub const NOERROR: HRESULT = 0; +pub const E_UNEXPECTED: HRESULT = 0x8000FFFF; +pub const E_NOTIMPL: HRESULT = 0x80004001; +pub const E_OUTOFMEMORY: HRESULT = 0x8007000E; +pub const E_INVALIDARG: HRESULT = 0x80070057; +pub const E_NOINTERFACE: HRESULT = 0x80004002; +pub const E_POINTER: HRESULT = 0x80004003; +pub const E_HANDLE: HRESULT = 0x80070006; +pub const E_ABORT: HRESULT = 0x80004004; +pub const E_FAIL: HRESULT = 0x80004005; +pub const E_ACCESSDENIED: HRESULT = 0x80070005; +pub const E_PENDING: HRESULT = 0x8000000A; +pub const E_BOUNDS: HRESULT = 0x8000000B; +pub const E_CHANGED_STATE: HRESULT = 0x8000000C; +pub const E_ILLEGAL_STATE_CHANGE: HRESULT = 0x8000000D; +pub const E_ILLEGAL_METHOD_CALL: HRESULT = 0x8000000E; +pub const RO_E_METADATA_NAME_NOT_FOUND: HRESULT = 0x8000000F; +pub const RO_E_METADATA_NAME_IS_NAMESPACE: HRESULT = 0x80000010; +pub const RO_E_METADATA_INVALID_TYPE_FORMAT: HRESULT = 0x80000011; +pub const RO_E_INVALID_METADATA_FILE: HRESULT = 0x80000012; +pub const RO_E_CLOSED: HRESULT = 0x80000013; +pub const RO_E_EXCLUSIVE_WRITE: HRESULT = 0x80000014; +pub const RO_E_CHANGE_NOTIFICATION_IN_PROGRESS: HRESULT = 0x80000015; +pub const RO_E_ERROR_STRING_NOT_FOUND: HRESULT = 0x80000016; +pub const E_STRING_NOT_NULL_TERMINATED: HRESULT = 0x80000017; +pub const E_ILLEGAL_DELEGATE_ASSIGNMENT: HRESULT = 0x80000018; +pub const E_ASYNC_OPERATION_NOT_STARTED: HRESULT = 0x80000019; +pub const E_APPLICATION_EXITING: HRESULT = 0x8000001A; +pub const E_APPLICATION_VIEW_EXITING: HRESULT = 0x8000001B; +pub const RO_E_MUST_BE_AGILE: HRESULT = 0x8000001C; +pub const RO_E_UNSUPPORTED_FROM_MTA: HRESULT = 0x8000001D; +pub const RO_E_COMMITTED: HRESULT = 0x8000001E; +pub const RO_E_BLOCKED_CROSS_ASTA_CALL: HRESULT = 0x8000001F; +pub const CO_E_INIT_TLS: HRESULT = 0x80004006; +pub const CO_E_INIT_SHARED_ALLOCATOR: HRESULT = 0x80004007; +pub const CO_E_INIT_MEMORY_ALLOCATOR: HRESULT = 0x80004008; +pub const CO_E_INIT_CLASS_CACHE: HRESULT = 0x80004009; +pub const CO_E_INIT_RPC_CHANNEL: HRESULT = 0x8000400A; +pub const CO_E_INIT_TLS_SET_CHANNEL_CONTROL: HRESULT = 0x8000400B; +pub const CO_E_INIT_TLS_CHANNEL_CONTROL: HRESULT = 0x8000400C; +pub const CO_E_INIT_UNACCEPTED_USER_ALLOCATOR: HRESULT = 0x8000400D; +pub const CO_E_INIT_SCM_MUTEX_EXISTS: HRESULT = 0x8000400E; +pub const CO_E_INIT_SCM_FILE_MAPPING_EXISTS: HRESULT = 0x8000400F; +pub const CO_E_INIT_SCM_MAP_VIEW_OF_FILE: HRESULT = 0x80004010; +pub const CO_E_INIT_SCM_EXEC_FAILURE: HRESULT = 0x80004011; +pub const CO_E_INIT_ONLY_SINGLE_THREADED: HRESULT = 0x80004012; +pub const CO_E_CANT_REMOTE: HRESULT = 0x80004013; +pub const CO_E_BAD_SERVER_NAME: HRESULT = 0x80004014; +pub const CO_E_WRONG_SERVER_IDENTITY: HRESULT = 0x80004015; +pub const CO_E_OLE1DDE_DISABLED: HRESULT = 0x80004016; +pub const CO_E_RUNAS_SYNTAX: HRESULT = 0x80004017; +pub const CO_E_CREATEPROCESS_FAILURE: HRESULT = 0x80004018; +pub const CO_E_RUNAS_CREATEPROCESS_FAILURE: HRESULT = 0x80004019; +pub const CO_E_RUNAS_LOGON_FAILURE: HRESULT = 0x8000401A; +pub const CO_E_LAUNCH_PERMSSION_DENIED: HRESULT = 0x8000401B; +pub const CO_E_START_SERVICE_FAILURE: HRESULT = 0x8000401C; +pub const CO_E_REMOTE_COMMUNICATION_FAILURE: HRESULT = 0x8000401D; +pub const CO_E_SERVER_START_TIMEOUT: HRESULT = 0x8000401E; +pub const CO_E_CLSREG_INCONSISTENT: HRESULT = 0x8000401F; +pub const CO_E_IIDREG_INCONSISTENT: HRESULT = 0x80004020; +pub const CO_E_NOT_SUPPORTED: HRESULT = 0x80004021; +pub const CO_E_RELOAD_DLL: HRESULT = 0x80004022; +pub const CO_E_MSI_ERROR: HRESULT = 0x80004023; +pub const CO_E_ATTEMPT_TO_CREATE_OUTSIDE_CLIENT_CONTEXT: HRESULT = 0x80004024; +pub const CO_E_SERVER_PAUSED: HRESULT = 0x80004025; +pub const CO_E_SERVER_NOT_PAUSED: HRESULT = 0x80004026; +pub const CO_E_CLASS_DISABLED: HRESULT = 0x80004027; +pub const CO_E_CLRNOTAVAILABLE: HRESULT = 0x80004028; +pub const CO_E_ASYNC_WORK_REJECTED: HRESULT = 0x80004029; +pub const CO_E_SERVER_INIT_TIMEOUT: HRESULT = 0x8000402A; +pub const CO_E_NO_SECCTX_IN_ACTIVATE: HRESULT = 0x8000402B; +pub const CO_E_TRACKER_CONFIG: HRESULT = 0x80004030; +pub const CO_E_THREADPOOL_CONFIG: HRESULT = 0x80004031; +pub const CO_E_SXS_CONFIG: HRESULT = 0x80004032; +pub const CO_E_MALFORMED_SPN: HRESULT = 0x80004033; +pub const CO_E_UNREVOKED_REGISTRATION_ON_APARTMENT_SHUTDOWN: HRESULT = 0x80004034; +pub const CO_E_PREMATURE_STUB_RUNDOWN: HRESULT = 0x80004035; +pub const S_OK: HRESULT = 0; +pub const S_FALSE: HRESULT = 1; +pub const OLE_E_FIRST: HRESULT = 0x80040000; +pub const OLE_E_LAST: HRESULT = 0x800400FF; +pub const OLE_S_FIRST: HRESULT = 0x00040000; +pub const OLE_S_LAST: HRESULT = 0x000400FF; +pub const OLE_E_OLEVERB: HRESULT = 0x80040000; +pub const OLE_E_ADVF: HRESULT = 0x80040001; +pub const OLE_E_ENUM_NOMORE: HRESULT = 0x80040002; +pub const OLE_E_ADVISENOTSUPPORTED: HRESULT = 0x80040003; +pub const OLE_E_NOCONNECTION: HRESULT = 0x80040004; +pub const OLE_E_NOTRUNNING: HRESULT = 0x80040005; +pub const OLE_E_NOCACHE: HRESULT = 0x80040006; +pub const OLE_E_BLANK: HRESULT = 0x80040007; +pub const OLE_E_CLASSDIFF: HRESULT = 0x80040008; +pub const OLE_E_CANT_GETMONIKER: HRESULT = 0x80040009; +pub const OLE_E_CANT_BINDTOSOURCE: HRESULT = 0x8004000A; +pub const OLE_E_STATIC: HRESULT = 0x8004000B; +pub const OLE_E_PROMPTSAVECANCELLED: HRESULT = 0x8004000C; +pub const OLE_E_INVALIDRECT: HRESULT = 0x8004000D; +pub const OLE_E_WRONGCOMPOBJ: HRESULT = 0x8004000E; +pub const OLE_E_INVALIDHWND: HRESULT = 0x8004000F; +pub const OLE_E_NOT_INPLACEACTIVE: HRESULT = 0x80040010; +pub const OLE_E_CANTCONVERT: HRESULT = 0x80040011; +pub const OLE_E_NOSTORAGE: HRESULT = 0x80040012; +pub const DV_E_FORMATETC: HRESULT = 0x80040064; +pub const DV_E_DVTARGETDEVICE: HRESULT = 0x80040065; +pub const DV_E_STGMEDIUM: HRESULT = 0x80040066; +pub const DV_E_STATDATA: HRESULT = 0x80040067; +pub const DV_E_LINDEX: HRESULT = 0x80040068; +pub const DV_E_TYMED: HRESULT = 0x80040069; +pub const DV_E_CLIPFORMAT: HRESULT = 0x8004006A; +pub const DV_E_DVASPECT: HRESULT = 0x8004006B; +pub const DV_E_DVTARGETDEVICE_SIZE: HRESULT = 0x8004006C; +pub const DV_E_NOIVIEWOBJECT: HRESULT = 0x8004006D; +pub const DRAGDROP_E_FIRST: HRESULT = 0x80040100; +pub const DRAGDROP_E_LAST: HRESULT = 0x8004010F; +pub const DRAGDROP_S_FIRST: HRESULT = 0x00040100; +pub const DRAGDROP_S_LAST: HRESULT = 0x0004010F; +pub const DRAGDROP_E_NOTREGISTERED: HRESULT = 0x80040100; +pub const DRAGDROP_E_ALREADYREGISTERED: HRESULT = 0x80040101; +pub const DRAGDROP_E_INVALIDHWND: HRESULT = 0x80040102; +pub const DRAGDROP_E_CONCURRENT_DRAG_ATTEMPTED: HRESULT = 0x80040103; +pub const CLASSFACTORY_E_FIRST: HRESULT = 0x80040110; +pub const CLASSFACTORY_E_LAST: HRESULT = 0x8004011F; +pub const CLASSFACTORY_S_FIRST: HRESULT = 0x00040110; +pub const CLASSFACTORY_S_LAST: HRESULT = 0x0004011F; +pub const CLASS_E_NOAGGREGATION: HRESULT = 0x80040110; +pub const CLASS_E_CLASSNOTAVAILABLE: HRESULT = 0x80040111; +pub const CLASS_E_NOTLICENSED: HRESULT = 0x80040112; +pub const MARSHAL_E_FIRST: HRESULT = 0x80040120; +pub const MARSHAL_E_LAST: HRESULT = 0x8004012F; +pub const MARSHAL_S_FIRST: HRESULT = 0x00040120; +pub const MARSHAL_S_LAST: HRESULT = 0x0004012F; +pub const DATA_E_FIRST: HRESULT = 0x80040130; +pub const DATA_E_LAST: HRESULT = 0x8004013F; +pub const DATA_S_FIRST: HRESULT = 0x00040130; +pub const DATA_S_LAST: HRESULT = 0x0004013F; +pub const VIEW_E_FIRST: HRESULT = 0x80040140; +pub const VIEW_E_LAST: HRESULT = 0x8004014F; +pub const VIEW_S_FIRST: HRESULT = 0x00040140; +pub const VIEW_S_LAST: HRESULT = 0x0004014F; +pub const VIEW_E_DRAW: HRESULT = 0x80040140; +pub const REGDB_E_FIRST: HRESULT = 0x80040150; +pub const REGDB_E_LAST: HRESULT = 0x8004015F; +pub const REGDB_S_FIRST: HRESULT = 0x00040150; +pub const REGDB_S_LAST: HRESULT = 0x0004015F; +pub const REGDB_E_READREGDB: HRESULT = 0x80040150; +pub const REGDB_E_WRITEREGDB: HRESULT = 0x80040151; +pub const REGDB_E_KEYMISSING: HRESULT = 0x80040152; +pub const REGDB_E_INVALIDVALUE: HRESULT = 0x80040153; +pub const REGDB_E_CLASSNOTREG: HRESULT = 0x80040154; +pub const REGDB_E_IIDNOTREG: HRESULT = 0x80040155; +pub const REGDB_E_BADTHREADINGMODEL: HRESULT = 0x80040156; +pub const CAT_E_FIRST: HRESULT = 0x80040160; +pub const CAT_E_LAST: HRESULT = 0x80040161; +pub const CAT_E_CATIDNOEXIST: HRESULT = 0x80040160; +pub const CAT_E_NODESCRIPTION: HRESULT = 0x80040161; +pub const CS_E_FIRST: HRESULT = 0x80040164; +pub const CS_E_LAST: HRESULT = 0x8004016F; +pub const CS_E_PACKAGE_NOTFOUND: HRESULT = 0x80040164; +pub const CS_E_NOT_DELETABLE: HRESULT = 0x80040165; +pub const CS_E_CLASS_NOTFOUND: HRESULT = 0x80040166; +pub const CS_E_INVALID_VERSION: HRESULT = 0x80040167; +pub const CS_E_NO_CLASSSTORE: HRESULT = 0x80040168; +pub const CS_E_OBJECT_NOTFOUND: HRESULT = 0x80040169; +pub const CS_E_OBJECT_ALREADY_EXISTS: HRESULT = 0x8004016A; +pub const CS_E_INVALID_PATH: HRESULT = 0x8004016B; +pub const CS_E_NETWORK_ERROR: HRESULT = 0x8004016C; +pub const CS_E_ADMIN_LIMIT_EXCEEDED: HRESULT = 0x8004016D; +pub const CS_E_SCHEMA_MISMATCH: HRESULT = 0x8004016E; +pub const CS_E_INTERNAL_ERROR: HRESULT = 0x8004016F; +pub const CACHE_E_FIRST: HRESULT = 0x80040170; +pub const CACHE_E_LAST: HRESULT = 0x8004017F; +pub const CACHE_S_FIRST: HRESULT = 0x00040170; +pub const CACHE_S_LAST: HRESULT = 0x0004017F; +pub const CACHE_E_NOCACHE_UPDATED: HRESULT = 0x80040170; +pub const OLEOBJ_E_FIRST: HRESULT = 0x80040180; +pub const OLEOBJ_E_LAST: HRESULT = 0x8004018F; +pub const OLEOBJ_S_FIRST: HRESULT = 0x00040180; +pub const OLEOBJ_S_LAST: HRESULT = 0x0004018F; +pub const OLEOBJ_E_NOVERBS: HRESULT = 0x80040180; +pub const OLEOBJ_E_INVALIDVERB: HRESULT = 0x80040181; +pub const CLIENTSITE_E_FIRST: HRESULT = 0x80040190; +pub const CLIENTSITE_E_LAST: HRESULT = 0x8004019F; +pub const CLIENTSITE_S_FIRST: HRESULT = 0x00040190; +pub const CLIENTSITE_S_LAST: HRESULT = 0x0004019F; +pub const INPLACE_E_NOTUNDOABLE: HRESULT = 0x800401A0; +pub const INPLACE_E_NOTOOLSPACE: HRESULT = 0x800401A1; +pub const INPLACE_E_FIRST: HRESULT = 0x800401A0; +pub const INPLACE_E_LAST: HRESULT = 0x800401AF; +pub const INPLACE_S_FIRST: HRESULT = 0x000401A0; +pub const INPLACE_S_LAST: HRESULT = 0x000401AF; +pub const ENUM_E_FIRST: HRESULT = 0x800401B0; +pub const ENUM_E_LAST: HRESULT = 0x800401BF; +pub const ENUM_S_FIRST: HRESULT = 0x000401B0; +pub const ENUM_S_LAST: HRESULT = 0x000401BF; +pub const CONVERT10_E_FIRST: HRESULT = 0x800401C0; +pub const CONVERT10_E_LAST: HRESULT = 0x800401CF; +pub const CONVERT10_S_FIRST: HRESULT = 0x000401C0; +pub const CONVERT10_S_LAST: HRESULT = 0x000401CF; +pub const CONVERT10_E_OLESTREAM_GET: HRESULT = 0x800401C0; +pub const CONVERT10_E_OLESTREAM_PUT: HRESULT = 0x800401C1; +pub const CONVERT10_E_OLESTREAM_FMT: HRESULT = 0x800401C2; +pub const CONVERT10_E_OLESTREAM_BITMAP_TO_DIB: HRESULT = 0x800401C3; +pub const CONVERT10_E_STG_FMT: HRESULT = 0x800401C4; +pub const CONVERT10_E_STG_NO_STD_STREAM: HRESULT = 0x800401C5; +pub const CONVERT10_E_STG_DIB_TO_BITMAP: HRESULT = 0x800401C6; +pub const CLIPBRD_E_FIRST: HRESULT = 0x800401D0; +pub const CLIPBRD_E_LAST: HRESULT = 0x800401DF; +pub const CLIPBRD_S_FIRST: HRESULT = 0x000401D0; +pub const CLIPBRD_S_LAST: HRESULT = 0x000401DF; +pub const CLIPBRD_E_CANT_OPEN: HRESULT = 0x800401D0; +pub const CLIPBRD_E_CANT_EMPTY: HRESULT = 0x800401D1; +pub const CLIPBRD_E_CANT_SET: HRESULT = 0x800401D2; +pub const CLIPBRD_E_BAD_DATA: HRESULT = 0x800401D3; +pub const CLIPBRD_E_CANT_CLOSE: HRESULT = 0x800401D4; +pub const MK_E_FIRST: HRESULT = 0x800401E0; +pub const MK_E_LAST: HRESULT = 0x800401EF; +pub const MK_S_FIRST: HRESULT = 0x000401E0; +pub const MK_S_LAST: HRESULT = 0x000401EF; +pub const MK_E_CONNECTMANUALLY: HRESULT = 0x800401E0; +pub const MK_E_EXCEEDEDDEADLINE: HRESULT = 0x800401E1; +pub const MK_E_NEEDGENERIC: HRESULT = 0x800401E2; +pub const MK_E_UNAVAILABLE: HRESULT = 0x800401E3; +pub const MK_E_SYNTAX: HRESULT = 0x800401E4; +pub const MK_E_NOOBJECT: HRESULT = 0x800401E5; +pub const MK_E_INVALIDEXTENSION: HRESULT = 0x800401E6; +pub const MK_E_INTERMEDIATEINTERFACENOTSUPPORTED: HRESULT = 0x800401E7; +pub const MK_E_NOTBINDABLE: HRESULT = 0x800401E8; +pub const MK_E_NOTBOUND: HRESULT = 0x800401E9; +pub const MK_E_CANTOPENFILE: HRESULT = 0x800401EA; +pub const MK_E_MUSTBOTHERUSER: HRESULT = 0x800401EB; +pub const MK_E_NOINVERSE: HRESULT = 0x800401EC; +pub const MK_E_NOSTORAGE: HRESULT = 0x800401ED; +pub const MK_E_NOPREFIX: HRESULT = 0x800401EE; +pub const MK_E_ENUMERATION_FAILED: HRESULT = 0x800401EF; +pub const CO_E_FIRST: HRESULT = 0x800401F0; +pub const CO_E_LAST: HRESULT = 0x800401FF; +pub const CO_S_FIRST: HRESULT = 0x000401F0; +pub const CO_S_LAST: HRESULT = 0x000401FF; +pub const CO_E_NOTINITIALIZED: HRESULT = 0x800401F0; +pub const CO_E_ALREADYINITIALIZED: HRESULT = 0x800401F1; +pub const CO_E_CANTDETERMINECLASS: HRESULT = 0x800401F2; +pub const CO_E_CLASSSTRING: HRESULT = 0x800401F3; +pub const CO_E_IIDSTRING: HRESULT = 0x800401F4; +pub const CO_E_APPNOTFOUND: HRESULT = 0x800401F5; +pub const CO_E_APPSINGLEUSE: HRESULT = 0x800401F6; +pub const CO_E_ERRORINAPP: HRESULT = 0x800401F7; +pub const CO_E_DLLNOTFOUND: HRESULT = 0x800401F8; +pub const CO_E_ERRORINDLL: HRESULT = 0x800401F9; +pub const CO_E_WRONGOSFORAPP: HRESULT = 0x800401FA; +pub const CO_E_OBJNOTREG: HRESULT = 0x800401FB; +pub const CO_E_OBJISREG: HRESULT = 0x800401FC; +pub const CO_E_OBJNOTCONNECTED: HRESULT = 0x800401FD; +pub const CO_E_APPDIDNTREG: HRESULT = 0x800401FE; +pub const CO_E_RELEASED: HRESULT = 0x800401FF; +pub const EVENT_E_FIRST: HRESULT = 0x80040200; +pub const EVENT_E_LAST: HRESULT = 0x8004021F; +pub const EVENT_S_FIRST: HRESULT = 0x00040200; +pub const EVENT_S_LAST: HRESULT = 0x0004021F; +pub const EVENT_S_SOME_SUBSCRIBERS_FAILED: HRESULT = 0x00040200; +pub const EVENT_E_ALL_SUBSCRIBERS_FAILED: HRESULT = 0x80040201; +pub const EVENT_S_NOSUBSCRIBERS: HRESULT = 0x00040202; +pub const EVENT_E_QUERYSYNTAX: HRESULT = 0x80040203; +pub const EVENT_E_QUERYFIELD: HRESULT = 0x80040204; +pub const EVENT_E_INTERNALEXCEPTION: HRESULT = 0x80040205; +pub const EVENT_E_INTERNALERROR: HRESULT = 0x80040206; +pub const EVENT_E_INVALID_PER_USER_SID: HRESULT = 0x80040207; +pub const EVENT_E_USER_EXCEPTION: HRESULT = 0x80040208; +pub const EVENT_E_TOO_MANY_METHODS: HRESULT = 0x80040209; +pub const EVENT_E_MISSING_EVENTCLASS: HRESULT = 0x8004020A; +pub const EVENT_E_NOT_ALL_REMOVED: HRESULT = 0x8004020B; +pub const EVENT_E_COMPLUS_NOT_INSTALLED: HRESULT = 0x8004020C; +pub const EVENT_E_CANT_MODIFY_OR_DELETE_UNCONFIGURED_OBJECT: HRESULT = 0x8004020D; +pub const EVENT_E_CANT_MODIFY_OR_DELETE_CONFIGURED_OBJECT: HRESULT = 0x8004020E; +pub const EVENT_E_INVALID_EVENT_CLASS_PARTITION: HRESULT = 0x8004020F; +pub const EVENT_E_PER_USER_SID_NOT_LOGGED_ON: HRESULT = 0x80040210; +pub const TPC_E_INVALID_PROPERTY: HRESULT = 0x80040241; +pub const TPC_E_NO_DEFAULT_TABLET: HRESULT = 0x80040212; +pub const TPC_E_UNKNOWN_PROPERTY: HRESULT = 0x8004021B; +pub const TPC_E_INVALID_INPUT_RECT: HRESULT = 0x80040219; +pub const TPC_E_INVALID_STROKE: HRESULT = 0x80040222; +pub const TPC_E_INITIALIZE_FAIL: HRESULT = 0x80040223; +pub const TPC_E_NOT_RELEVANT: HRESULT = 0x80040232; +pub const TPC_E_INVALID_PACKET_DESCRIPTION: HRESULT = 0x80040233; +pub const TPC_E_RECOGNIZER_NOT_REGISTERED: HRESULT = 0x80040235; +pub const TPC_E_INVALID_RIGHTS: HRESULT = 0x80040236; +pub const TPC_E_OUT_OF_ORDER_CALL: HRESULT = 0x80040237; +pub const TPC_E_QUEUE_FULL: HRESULT = 0x80040238; +pub const TPC_E_INVALID_CONFIGURATION: HRESULT = 0x80040239; +pub const TPC_E_INVALID_DATA_FROM_RECOGNIZER: HRESULT = 0x8004023A; +pub const TPC_S_TRUNCATED: HRESULT = 0x00040252; +pub const TPC_S_INTERRUPTED: HRESULT = 0x00040253; +pub const TPC_S_NO_DATA_TO_PROCESS: HRESULT = 0x00040254; +pub const XACT_E_FIRST: HRESULT = 0x8004D000; +pub const XACT_E_LAST: HRESULT = 0x8004D02B; +pub const XACT_S_FIRST: HRESULT = 0x0004D000; +pub const XACT_S_LAST: HRESULT = 0x0004D010; +pub const XACT_E_ALREADYOTHERSINGLEPHASE: HRESULT = 0x8004D000; +pub const XACT_E_CANTRETAIN: HRESULT = 0x8004D001; +pub const XACT_E_COMMITFAILED: HRESULT = 0x8004D002; +pub const XACT_E_COMMITPREVENTED: HRESULT = 0x8004D003; +pub const XACT_E_HEURISTICABORT: HRESULT = 0x8004D004; +pub const XACT_E_HEURISTICCOMMIT: HRESULT = 0x8004D005; +pub const XACT_E_HEURISTICDAMAGE: HRESULT = 0x8004D006; +pub const XACT_E_HEURISTICDANGER: HRESULT = 0x8004D007; +pub const XACT_E_ISOLATIONLEVEL: HRESULT = 0x8004D008; +pub const XACT_E_NOASYNC: HRESULT = 0x8004D009; +pub const XACT_E_NOENLIST: HRESULT = 0x8004D00A; +pub const XACT_E_NOISORETAIN: HRESULT = 0x8004D00B; +pub const XACT_E_NORESOURCE: HRESULT = 0x8004D00C; +pub const XACT_E_NOTCURRENT: HRESULT = 0x8004D00D; +pub const XACT_E_NOTRANSACTION: HRESULT = 0x8004D00E; +pub const XACT_E_NOTSUPPORTED: HRESULT = 0x8004D00F; +pub const XACT_E_UNKNOWNRMGRID: HRESULT = 0x8004D010; +pub const XACT_E_WRONGSTATE: HRESULT = 0x8004D011; +pub const XACT_E_WRONGUOW: HRESULT = 0x8004D012; +pub const XACT_E_XTIONEXISTS: HRESULT = 0x8004D013; +pub const XACT_E_NOIMPORTOBJECT: HRESULT = 0x8004D014; +pub const XACT_E_INVALIDCOOKIE: HRESULT = 0x8004D015; +pub const XACT_E_INDOUBT: HRESULT = 0x8004D016; +pub const XACT_E_NOTIMEOUT: HRESULT = 0x8004D017; +pub const XACT_E_ALREADYINPROGRESS: HRESULT = 0x8004D018; +pub const XACT_E_ABORTED: HRESULT = 0x8004D019; +pub const XACT_E_LOGFULL: HRESULT = 0x8004D01A; +pub const XACT_E_TMNOTAVAILABLE: HRESULT = 0x8004D01B; +pub const XACT_E_CONNECTION_DOWN: HRESULT = 0x8004D01C; +pub const XACT_E_CONNECTION_DENIED: HRESULT = 0x8004D01D; +pub const XACT_E_REENLISTTIMEOUT: HRESULT = 0x8004D01E; +pub const XACT_E_TIP_CONNECT_FAILED: HRESULT = 0x8004D01F; +pub const XACT_E_TIP_PROTOCOL_ERROR: HRESULT = 0x8004D020; +pub const XACT_E_TIP_PULL_FAILED: HRESULT = 0x8004D021; +pub const XACT_E_DEST_TMNOTAVAILABLE: HRESULT = 0x8004D022; +pub const XACT_E_TIP_DISABLED: HRESULT = 0x8004D023; +pub const XACT_E_NETWORK_TX_DISABLED: HRESULT = 0x8004D024; +pub const XACT_E_PARTNER_NETWORK_TX_DISABLED: HRESULT = 0x8004D025; +pub const XACT_E_XA_TX_DISABLED: HRESULT = 0x8004D026; +pub const XACT_E_UNABLE_TO_READ_DTC_CONFIG: HRESULT = 0x8004D027; +pub const XACT_E_UNABLE_TO_LOAD_DTC_PROXY: HRESULT = 0x8004D028; +pub const XACT_E_ABORTING: HRESULT = 0x8004D029; +pub const XACT_E_PUSH_COMM_FAILURE: HRESULT = 0x8004D02A; +pub const XACT_E_PULL_COMM_FAILURE: HRESULT = 0x8004D02B; +pub const XACT_E_LU_TX_DISABLED: HRESULT = 0x8004D02C; +pub const XACT_E_CLERKNOTFOUND: HRESULT = 0x8004D080; +pub const XACT_E_CLERKEXISTS: HRESULT = 0x8004D081; +pub const XACT_E_RECOVERYINPROGRESS: HRESULT = 0x8004D082; +pub const XACT_E_TRANSACTIONCLOSED: HRESULT = 0x8004D083; +pub const XACT_E_INVALIDLSN: HRESULT = 0x8004D084; +pub const XACT_E_REPLAYREQUEST: HRESULT = 0x8004D085; +pub const XACT_S_ASYNC: HRESULT = 0x0004D000; +pub const XACT_S_DEFECT: HRESULT = 0x0004D001; +pub const XACT_S_READONLY: HRESULT = 0x0004D002; +pub const XACT_S_SOMENORETAIN: HRESULT = 0x0004D003; +pub const XACT_S_OKINFORM: HRESULT = 0x0004D004; +pub const XACT_S_MADECHANGESCONTENT: HRESULT = 0x0004D005; +pub const XACT_S_MADECHANGESINFORM: HRESULT = 0x0004D006; +pub const XACT_S_ALLNORETAIN: HRESULT = 0x0004D007; +pub const XACT_S_ABORTING: HRESULT = 0x0004D008; +pub const XACT_S_SINGLEPHASE: HRESULT = 0x0004D009; +pub const XACT_S_LOCALLY_OK: HRESULT = 0x0004D00A; +pub const XACT_S_LASTRESOURCEMANAGER: HRESULT = 0x0004D010; +pub const CONTEXT_E_FIRST: HRESULT = 0x8004E000; +pub const CONTEXT_E_LAST: HRESULT = 0x8004E02F; +pub const CONTEXT_S_FIRST: HRESULT = 0x0004E000; +pub const CONTEXT_S_LAST: HRESULT = 0x0004E02F; +pub const CONTEXT_E_ABORTED: HRESULT = 0x8004E002; +pub const CONTEXT_E_ABORTING: HRESULT = 0x8004E003; +pub const CONTEXT_E_NOCONTEXT: HRESULT = 0x8004E004; +pub const CONTEXT_E_WOULD_DEADLOCK: HRESULT = 0x8004E005; +pub const CONTEXT_E_SYNCH_TIMEOUT: HRESULT = 0x8004E006; +pub const CONTEXT_E_OLDREF: HRESULT = 0x8004E007; +pub const CONTEXT_E_ROLENOTFOUND: HRESULT = 0x8004E00C; +pub const CONTEXT_E_TMNOTAVAILABLE: HRESULT = 0x8004E00F; +pub const CO_E_ACTIVATIONFAILED: HRESULT = 0x8004E021; +pub const CO_E_ACTIVATIONFAILED_EVENTLOGGED: HRESULT = 0x8004E022; +pub const CO_E_ACTIVATIONFAILED_CATALOGERROR: HRESULT = 0x8004E023; +pub const CO_E_ACTIVATIONFAILED_TIMEOUT: HRESULT = 0x8004E024; +pub const CO_E_INITIALIZATIONFAILED: HRESULT = 0x8004E025; +pub const CONTEXT_E_NOJIT: HRESULT = 0x8004E026; +pub const CONTEXT_E_NOTRANSACTION: HRESULT = 0x8004E027; +pub const CO_E_THREADINGMODEL_CHANGED: HRESULT = 0x8004E028; +pub const CO_E_NOIISINTRINSICS: HRESULT = 0x8004E029; +pub const CO_E_NOCOOKIES: HRESULT = 0x8004E02A; +pub const CO_E_DBERROR: HRESULT = 0x8004E02B; +pub const CO_E_NOTPOOLED: HRESULT = 0x8004E02C; +pub const CO_E_NOTCONSTRUCTED: HRESULT = 0x8004E02D; +pub const CO_E_NOSYNCHRONIZATION: HRESULT = 0x8004E02E; +pub const CO_E_ISOLEVELMISMATCH: HRESULT = 0x8004E02F; +pub const CO_E_CALL_OUT_OF_TX_SCOPE_NOT_ALLOWED: HRESULT = 0x8004E030; +pub const CO_E_EXIT_TRANSACTION_SCOPE_NOT_CALLED: HRESULT = 0x8004E031; +pub const OLE_S_USEREG: HRESULT = 0x00040000; +pub const OLE_S_STATIC: HRESULT = 0x00040001; +pub const OLE_S_MAC_CLIPFORMAT: HRESULT = 0x00040002; +pub const DRAGDROP_S_DROP: HRESULT = 0x00040100; +pub const DRAGDROP_S_CANCEL: HRESULT = 0x00040101; +pub const DRAGDROP_S_USEDEFAULTCURSORS: HRESULT = 0x00040102; +pub const DATA_S_SAMEFORMATETC: HRESULT = 0x00040130; +pub const VIEW_S_ALREADY_FROZEN: HRESULT = 0x00040140; +pub const CACHE_S_FORMATETC_NOTSUPPORTED: HRESULT = 0x00040170; +pub const CACHE_S_SAMECACHE: HRESULT = 0x00040171; +pub const CACHE_S_SOMECACHES_NOTUPDATED: HRESULT = 0x00040172; +pub const OLEOBJ_S_INVALIDVERB: HRESULT = 0x00040180; +pub const OLEOBJ_S_CANNOT_DOVERB_NOW: HRESULT = 0x00040181; +pub const OLEOBJ_S_INVALIDHWND: HRESULT = 0x00040182; +pub const INPLACE_S_TRUNCATED: HRESULT = 0x000401A0; +pub const CONVERT10_S_NO_PRESENTATION: HRESULT = 0x000401C0; +pub const MK_S_REDUCED_TO_SELF: HRESULT = 0x000401E2; +pub const MK_S_ME: HRESULT = 0x000401E4; +pub const MK_S_HIM: HRESULT = 0x000401E5; +pub const MK_S_US: HRESULT = 0x000401E6; +pub const MK_S_MONIKERALREADYREGISTERED: HRESULT = 0x000401E7; +pub const SCHED_S_TASK_READY: HRESULT = 0x00041300; +pub const SCHED_S_TASK_RUNNING: HRESULT = 0x00041301; +pub const SCHED_S_TASK_DISABLED: HRESULT = 0x00041302; +pub const SCHED_S_TASK_HAS_NOT_RUN: HRESULT = 0x00041303; +pub const SCHED_S_TASK_NO_MORE_RUNS: HRESULT = 0x00041304; +pub const SCHED_S_TASK_NOT_SCHEDULED: HRESULT = 0x00041305; +pub const SCHED_S_TASK_TERMINATED: HRESULT = 0x00041306; +pub const SCHED_S_TASK_NO_VALID_TRIGGERS: HRESULT = 0x00041307; +pub const SCHED_S_EVENT_TRIGGER: HRESULT = 0x00041308; +pub const SCHED_E_TRIGGER_NOT_FOUND: HRESULT = 0x80041309; +pub const SCHED_E_TASK_NOT_READY: HRESULT = 0x8004130A; +pub const SCHED_E_TASK_NOT_RUNNING: HRESULT = 0x8004130B; +pub const SCHED_E_SERVICE_NOT_INSTALLED: HRESULT = 0x8004130C; +pub const SCHED_E_CANNOT_OPEN_TASK: HRESULT = 0x8004130D; +pub const SCHED_E_INVALID_TASK: HRESULT = 0x8004130E; +pub const SCHED_E_ACCOUNT_INFORMATION_NOT_SET: HRESULT = 0x8004130F; +pub const SCHED_E_ACCOUNT_NAME_NOT_FOUND: HRESULT = 0x80041310; +pub const SCHED_E_ACCOUNT_DBASE_CORRUPT: HRESULT = 0x80041311; +pub const SCHED_E_NO_SECURITY_SERVICES: HRESULT = 0x80041312; +pub const SCHED_E_UNKNOWN_OBJECT_VERSION: HRESULT = 0x80041313; +pub const SCHED_E_UNSUPPORTED_ACCOUNT_OPTION: HRESULT = 0x80041314; +pub const SCHED_E_SERVICE_NOT_RUNNING: HRESULT = 0x80041315; +pub const SCHED_E_UNEXPECTEDNODE: HRESULT = 0x80041316; +pub const SCHED_E_NAMESPACE: HRESULT = 0x80041317; +pub const SCHED_E_INVALIDVALUE: HRESULT = 0x80041318; +pub const SCHED_E_MISSINGNODE: HRESULT = 0x80041319; +pub const SCHED_E_MALFORMEDXML: HRESULT = 0x8004131A; +pub const SCHED_S_SOME_TRIGGERS_FAILED: HRESULT = 0x0004131B; +pub const SCHED_S_BATCH_LOGON_PROBLEM: HRESULT = 0x0004131C; +pub const SCHED_E_TOO_MANY_NODES: HRESULT = 0x8004131D; +pub const SCHED_E_PAST_END_BOUNDARY: HRESULT = 0x8004131E; +pub const SCHED_E_ALREADY_RUNNING: HRESULT = 0x8004131F; +pub const SCHED_E_USER_NOT_LOGGED_ON: HRESULT = 0x80041320; +pub const SCHED_E_INVALID_TASK_HASH: HRESULT = 0x80041321; +pub const SCHED_E_SERVICE_NOT_AVAILABLE: HRESULT = 0x80041322; +pub const SCHED_E_SERVICE_TOO_BUSY: HRESULT = 0x80041323; +pub const SCHED_E_TASK_ATTEMPTED: HRESULT = 0x80041324; +pub const SCHED_S_TASK_QUEUED: HRESULT = 0x00041325; +pub const SCHED_E_TASK_DISABLED: HRESULT = 0x80041326; +pub const SCHED_E_TASK_NOT_V1_COMPAT: HRESULT = 0x80041327; +pub const SCHED_E_START_ON_DEMAND: HRESULT = 0x80041328; +pub const SCHED_E_TASK_NOT_UBPM_COMPAT: HRESULT = 0x80041329; +pub const SCHED_E_DEPRECATED_FEATURE_USED: HRESULT = 0x80041330; +pub const CO_E_CLASS_CREATE_FAILED: HRESULT = 0x80080001; +pub const CO_E_SCM_ERROR: HRESULT = 0x80080002; +pub const CO_E_SCM_RPC_FAILURE: HRESULT = 0x80080003; +pub const CO_E_BAD_PATH: HRESULT = 0x80080004; +pub const CO_E_SERVER_EXEC_FAILURE: HRESULT = 0x80080005; +pub const CO_E_OBJSRV_RPC_FAILURE: HRESULT = 0x80080006; +pub const MK_E_NO_NORMALIZED: HRESULT = 0x80080007; +pub const CO_E_SERVER_STOPPING: HRESULT = 0x80080008; +pub const MEM_E_INVALID_ROOT: HRESULT = 0x80080009; +pub const MEM_E_INVALID_LINK: HRESULT = 0x80080010; +pub const MEM_E_INVALID_SIZE: HRESULT = 0x80080011; +pub const CO_S_NOTALLINTERFACES: HRESULT = 0x00080012; +pub const CO_S_MACHINENAMENOTFOUND: HRESULT = 0x00080013; +pub const CO_E_MISSING_DISPLAYNAME: HRESULT = 0x80080015; +pub const CO_E_RUNAS_VALUE_MUST_BE_AAA: HRESULT = 0x80080016; +pub const CO_E_ELEVATION_DISABLED: HRESULT = 0x80080017; +pub const APPX_E_PACKAGING_INTERNAL: HRESULT = 0x80080200; +pub const APPX_E_INTERLEAVING_NOT_ALLOWED: HRESULT = 0x80080201; +pub const APPX_E_RELATIONSHIPS_NOT_ALLOWED: HRESULT = 0x80080202; +pub const APPX_E_MISSING_REQUIRED_FILE: HRESULT = 0x80080203; +pub const APPX_E_INVALID_MANIFEST: HRESULT = 0x80080204; +pub const APPX_E_INVALID_BLOCKMAP: HRESULT = 0x80080205; +pub const APPX_E_CORRUPT_CONTENT: HRESULT = 0x80080206; +pub const APPX_E_BLOCK_HASH_INVALID: HRESULT = 0x80080207; +pub const APPX_E_REQUESTED_RANGE_TOO_LARGE: HRESULT = 0x80080208; +pub const APPX_E_INVALID_SIP_CLIENT_DATA: HRESULT = 0x80080209; +pub const BT_E_SPURIOUS_ACTIVATION: HRESULT = 0x80080300; +pub const DISP_E_UNKNOWNINTERFACE: HRESULT = 0x80020001; +pub const DISP_E_MEMBERNOTFOUND: HRESULT = 0x80020003; +pub const DISP_E_PARAMNOTFOUND: HRESULT = 0x80020004; +pub const DISP_E_TYPEMISMATCH: HRESULT = 0x80020005; +pub const DISP_E_UNKNOWNNAME: HRESULT = 0x80020006; +pub const DISP_E_NONAMEDARGS: HRESULT = 0x80020007; +pub const DISP_E_BADVARTYPE: HRESULT = 0x80020008; +pub const DISP_E_EXCEPTION: HRESULT = 0x80020009; +pub const DISP_E_OVERFLOW: HRESULT = 0x8002000A; +pub const DISP_E_BADINDEX: HRESULT = 0x8002000B; +pub const DISP_E_UNKNOWNLCID: HRESULT = 0x8002000C; +pub const DISP_E_ARRAYISLOCKED: HRESULT = 0x8002000D; +pub const DISP_E_BADPARAMCOUNT: HRESULT = 0x8002000E; +pub const DISP_E_PARAMNOTOPTIONAL: HRESULT = 0x8002000F; +pub const DISP_E_BADCALLEE: HRESULT = 0x80020010; +pub const DISP_E_NOTACOLLECTION: HRESULT = 0x80020011; +pub const DISP_E_DIVBYZERO: HRESULT = 0x80020012; +pub const DISP_E_BUFFERTOOSMALL: HRESULT = 0x80020013; +pub const TYPE_E_BUFFERTOOSMALL: HRESULT = 0x80028016; +pub const TYPE_E_FIELDNOTFOUND: HRESULT = 0x80028017; +pub const TYPE_E_INVDATAREAD: HRESULT = 0x80028018; +pub const TYPE_E_UNSUPFORMAT: HRESULT = 0x80028019; +pub const TYPE_E_REGISTRYACCESS: HRESULT = 0x8002801C; +pub const TYPE_E_LIBNOTREGISTERED: HRESULT = 0x8002801D; +pub const TYPE_E_UNDEFINEDTYPE: HRESULT = 0x80028027; +pub const TYPE_E_QUALIFIEDNAMEDISALLOWED: HRESULT = 0x80028028; +pub const TYPE_E_INVALIDSTATE: HRESULT = 0x80028029; +pub const TYPE_E_WRONGTYPEKIND: HRESULT = 0x8002802A; +pub const TYPE_E_ELEMENTNOTFOUND: HRESULT = 0x8002802B; +pub const TYPE_E_AMBIGUOUSNAME: HRESULT = 0x8002802C; +pub const TYPE_E_NAMECONFLICT: HRESULT = 0x8002802D; +pub const TYPE_E_UNKNOWNLCID: HRESULT = 0x8002802E; +pub const TYPE_E_DLLFUNCTIONNOTFOUND: HRESULT = 0x8002802F; +pub const TYPE_E_BADMODULEKIND: HRESULT = 0x800288BD; +pub const TYPE_E_SIZETOOBIG: HRESULT = 0x800288C5; +pub const TYPE_E_DUPLICATEID: HRESULT = 0x800288C6; +pub const TYPE_E_INVALIDID: HRESULT = 0x800288CF; +pub const TYPE_E_TYPEMISMATCH: HRESULT = 0x80028CA0; +pub const TYPE_E_OUTOFBOUNDS: HRESULT = 0x80028CA1; +pub const TYPE_E_IOERROR: HRESULT = 0x80028CA2; +pub const TYPE_E_CANTCREATETMPFILE: HRESULT = 0x80028CA3; +pub const TYPE_E_CANTLOADLIBRARY: HRESULT = 0x80029C4A; +pub const TYPE_E_INCONSISTENTPROPFUNCS: HRESULT = 0x80029C83; +pub const TYPE_E_CIRCULARTYPE: HRESULT = 0x80029C84; +pub const STG_E_INVALIDFUNCTION: HRESULT = 0x80030001; +pub const STG_E_FILENOTFOUND: HRESULT = 0x80030002; +pub const STG_E_PATHNOTFOUND: HRESULT = 0x80030003; +pub const STG_E_TOOMANYOPENFILES: HRESULT = 0x80030004; +pub const STG_E_ACCESSDENIED: HRESULT = 0x80030005; +pub const STG_E_INVALIDHANDLE: HRESULT = 0x80030006; +pub const STG_E_INSUFFICIENTMEMORY: HRESULT = 0x80030008; +pub const STG_E_INVALIDPOINTER: HRESULT = 0x80030009; +pub const STG_E_NOMOREFILES: HRESULT = 0x80030012; +pub const STG_E_DISKISWRITEPROTECTED: HRESULT = 0x80030013; +pub const STG_E_SEEKERROR: HRESULT = 0x80030019; +pub const STG_E_WRITEFAULT: HRESULT = 0x8003001D; +pub const STG_E_READFAULT: HRESULT = 0x8003001E; +pub const STG_E_SHAREVIOLATION: HRESULT = 0x80030020; +pub const STG_E_LOCKVIOLATION: HRESULT = 0x80030021; +pub const STG_E_FILEALREADYEXISTS: HRESULT = 0x80030050; +pub const STG_E_INVALIDPARAMETER: HRESULT = 0x80030057; +pub const STG_E_MEDIUMFULL: HRESULT = 0x80030070; +pub const STG_E_PROPSETMISMATCHED: HRESULT = 0x800300F0; +pub const STG_E_ABNORMALAPIEXIT: HRESULT = 0x800300FA; +pub const STG_E_INVALIDHEADER: HRESULT = 0x800300FB; +pub const STG_E_INVALIDNAME: HRESULT = 0x800300FC; +pub const STG_E_UNKNOWN: HRESULT = 0x800300FD; +pub const STG_E_UNIMPLEMENTEDFUNCTION: HRESULT = 0x800300FE; +pub const STG_E_INVALIDFLAG: HRESULT = 0x800300FF; +pub const STG_E_INUSE: HRESULT = 0x80030100; +pub const STG_E_NOTCURRENT: HRESULT = 0x80030101; +pub const STG_E_REVERTED: HRESULT = 0x80030102; +pub const STG_E_CANTSAVE: HRESULT = 0x80030103; +pub const STG_E_OLDFORMAT: HRESULT = 0x80030104; +pub const STG_E_OLDDLL: HRESULT = 0x80030105; +pub const STG_E_SHAREREQUIRED: HRESULT = 0x80030106; +pub const STG_E_NOTFILEBASEDSTORAGE: HRESULT = 0x80030107; +pub const STG_E_EXTANTMARSHALLINGS: HRESULT = 0x80030108; +pub const STG_E_DOCFILECORRUPT: HRESULT = 0x80030109; +pub const STG_E_BADBASEADDRESS: HRESULT = 0x80030110; +pub const STG_E_DOCFILETOOLARGE: HRESULT = 0x80030111; +pub const STG_E_NOTSIMPLEFORMAT: HRESULT = 0x80030112; +pub const STG_E_INCOMPLETE: HRESULT = 0x80030201; +pub const STG_E_TERMINATED: HRESULT = 0x80030202; +pub const STG_S_CONVERTED: HRESULT = 0x00030200; +pub const STG_S_BLOCK: HRESULT = 0x00030201; +pub const STG_S_RETRYNOW: HRESULT = 0x00030202; +pub const STG_S_MONITORING: HRESULT = 0x00030203; +pub const STG_S_MULTIPLEOPENS: HRESULT = 0x00030204; +pub const STG_S_CONSOLIDATIONFAILED: HRESULT = 0x00030205; +pub const STG_S_CANNOTCONSOLIDATE: HRESULT = 0x00030206; +pub const STG_E_STATUS_COPY_PROTECTION_FAILURE: HRESULT = 0x80030305; +pub const STG_E_CSS_AUTHENTICATION_FAILURE: HRESULT = 0x80030306; +pub const STG_E_CSS_KEY_NOT_PRESENT: HRESULT = 0x80030307; +pub const STG_E_CSS_KEY_NOT_ESTABLISHED: HRESULT = 0x80030308; +pub const STG_E_CSS_SCRAMBLED_SECTOR: HRESULT = 0x80030309; +pub const STG_E_CSS_REGION_MISMATCH: HRESULT = 0x8003030A; +pub const STG_E_RESETS_EXHAUSTED: HRESULT = 0x8003030B; +pub const RPC_E_CALL_REJECTED: HRESULT = 0x80010001; +pub const RPC_E_CALL_CANCELED: HRESULT = 0x80010002; +pub const RPC_E_CANTPOST_INSENDCALL: HRESULT = 0x80010003; +pub const RPC_E_CANTCALLOUT_INASYNCCALL: HRESULT = 0x80010004; +pub const RPC_E_CANTCALLOUT_INEXTERNALCALL: HRESULT = 0x80010005; +pub const RPC_E_CONNECTION_TERMINATED: HRESULT = 0x80010006; +pub const RPC_E_SERVER_DIED: HRESULT = 0x80010007; +pub const RPC_E_CLIENT_DIED: HRESULT = 0x80010008; +pub const RPC_E_INVALID_DATAPACKET: HRESULT = 0x80010009; +pub const RPC_E_CANTTRANSMIT_CALL: HRESULT = 0x8001000A; +pub const RPC_E_CLIENT_CANTMARSHAL_DATA: HRESULT = 0x8001000B; +pub const RPC_E_CLIENT_CANTUNMARSHAL_DATA: HRESULT = 0x8001000C; +pub const RPC_E_SERVER_CANTMARSHAL_DATA: HRESULT = 0x8001000D; +pub const RPC_E_SERVER_CANTUNMARSHAL_DATA: HRESULT = 0x8001000E; +pub const RPC_E_INVALID_DATA: HRESULT = 0x8001000F; +pub const RPC_E_INVALID_PARAMETER: HRESULT = 0x80010010; +pub const RPC_E_CANTCALLOUT_AGAIN: HRESULT = 0x80010011; +pub const RPC_E_SERVER_DIED_DNE: HRESULT = 0x80010012; +pub const RPC_E_SYS_CALL_FAILED: HRESULT = 0x80010100; +pub const RPC_E_OUT_OF_RESOURCES: HRESULT = 0x80010101; +pub const RPC_E_ATTEMPTED_MULTITHREAD: HRESULT = 0x80010102; +pub const RPC_E_NOT_REGISTERED: HRESULT = 0x80010103; +pub const RPC_E_FAULT: HRESULT = 0x80010104; +pub const RPC_E_SERVERFAULT: HRESULT = 0x80010105; +pub const RPC_E_CHANGED_MODE: HRESULT = 0x80010106; +pub const RPC_E_INVALIDMETHOD: HRESULT = 0x80010107; +pub const RPC_E_DISCONNECTED: HRESULT = 0x80010108; +pub const RPC_E_RETRY: HRESULT = 0x80010109; +pub const RPC_E_SERVERCALL_RETRYLATER: HRESULT = 0x8001010A; +pub const RPC_E_SERVERCALL_REJECTED: HRESULT = 0x8001010B; +pub const RPC_E_INVALID_CALLDATA: HRESULT = 0x8001010C; +pub const RPC_E_CANTCALLOUT_ININPUTSYNCCALL: HRESULT = 0x8001010D; +pub const RPC_E_WRONG_THREAD: HRESULT = 0x8001010E; +pub const RPC_E_THREAD_NOT_INIT: HRESULT = 0x8001010F; +pub const RPC_E_VERSION_MISMATCH: HRESULT = 0x80010110; +pub const RPC_E_INVALID_HEADER: HRESULT = 0x80010111; +pub const RPC_E_INVALID_EXTENSION: HRESULT = 0x80010112; +pub const RPC_E_INVALID_IPID: HRESULT = 0x80010113; +pub const RPC_E_INVALID_OBJECT: HRESULT = 0x80010114; +pub const RPC_S_CALLPENDING: HRESULT = 0x80010115; +pub const RPC_S_WAITONTIMER: HRESULT = 0x80010116; +pub const RPC_E_CALL_COMPLETE: HRESULT = 0x80010117; +pub const RPC_E_UNSECURE_CALL: HRESULT = 0x80010118; +pub const RPC_E_TOO_LATE: HRESULT = 0x80010119; +pub const RPC_E_NO_GOOD_SECURITY_PACKAGES: HRESULT = 0x8001011A; +pub const RPC_E_ACCESS_DENIED: HRESULT = 0x8001011B; +pub const RPC_E_REMOTE_DISABLED: HRESULT = 0x8001011C; +pub const RPC_E_INVALID_OBJREF: HRESULT = 0x8001011D; +pub const RPC_E_NO_CONTEXT: HRESULT = 0x8001011E; +pub const RPC_E_TIMEOUT: HRESULT = 0x8001011F; +pub const RPC_E_NO_SYNC: HRESULT = 0x80010120; +pub const RPC_E_FULLSIC_REQUIRED: HRESULT = 0x80010121; +pub const RPC_E_INVALID_STD_NAME: HRESULT = 0x80010122; +pub const CO_E_FAILEDTOIMPERSONATE: HRESULT = 0x80010123; +pub const CO_E_FAILEDTOGETSECCTX: HRESULT = 0x80010124; +pub const CO_E_FAILEDTOOPENTHREADTOKEN: HRESULT = 0x80010125; +pub const CO_E_FAILEDTOGETTOKENINFO: HRESULT = 0x80010126; +pub const CO_E_TRUSTEEDOESNTMATCHCLIENT: HRESULT = 0x80010127; +pub const CO_E_FAILEDTOQUERYCLIENTBLANKET: HRESULT = 0x80010128; +pub const CO_E_FAILEDTOSETDACL: HRESULT = 0x80010129; +pub const CO_E_ACCESSCHECKFAILED: HRESULT = 0x8001012A; +pub const CO_E_NETACCESSAPIFAILED: HRESULT = 0x8001012B; +pub const CO_E_WRONGTRUSTEENAMESYNTAX: HRESULT = 0x8001012C; +pub const CO_E_INVALIDSID: HRESULT = 0x8001012D; +pub const CO_E_CONVERSIONFAILED: HRESULT = 0x8001012E; +pub const CO_E_NOMATCHINGSIDFOUND: HRESULT = 0x8001012F; +pub const CO_E_LOOKUPACCSIDFAILED: HRESULT = 0x80010130; +pub const CO_E_NOMATCHINGNAMEFOUND: HRESULT = 0x80010131; +pub const CO_E_LOOKUPACCNAMEFAILED: HRESULT = 0x80010132; +pub const CO_E_SETSERLHNDLFAILED: HRESULT = 0x80010133; +pub const CO_E_FAILEDTOGETWINDIR: HRESULT = 0x80010134; +pub const CO_E_PATHTOOLONG: HRESULT = 0x80010135; +pub const CO_E_FAILEDTOGENUUID: HRESULT = 0x80010136; +pub const CO_E_FAILEDTOCREATEFILE: HRESULT = 0x80010137; +pub const CO_E_FAILEDTOCLOSEHANDLE: HRESULT = 0x80010138; +pub const CO_E_EXCEEDSYSACLLIMIT: HRESULT = 0x80010139; +pub const CO_E_ACESINWRONGORDER: HRESULT = 0x8001013A; +pub const CO_E_INCOMPATIBLESTREAMVERSION: HRESULT = 0x8001013B; +pub const CO_E_FAILEDTOOPENPROCESSTOKEN: HRESULT = 0x8001013C; +pub const CO_E_DECODEFAILED: HRESULT = 0x8001013D; +pub const CO_E_ACNOTINITIALIZED: HRESULT = 0x8001013F; +pub const CO_E_CANCEL_DISABLED: HRESULT = 0x80010140; +pub const RPC_E_UNEXPECTED: HRESULT = 0x8001FFFF; +pub const ERROR_AUDITING_DISABLED: HRESULT = 0xC0090001; +pub const ERROR_ALL_SIDS_FILTERED: HRESULT = 0xC0090002; +pub const ERROR_BIZRULES_NOT_ENABLED: HRESULT = 0xC0090003; +pub const NTE_BAD_UID: HRESULT = 0x80090001; +pub const NTE_BAD_HASH: HRESULT = 0x80090002; +pub const NTE_BAD_KEY: HRESULT = 0x80090003; +pub const NTE_BAD_LEN: HRESULT = 0x80090004; +pub const NTE_BAD_DATA: HRESULT = 0x80090005; +pub const NTE_BAD_SIGNATURE: HRESULT = 0x80090006; +pub const NTE_BAD_VER: HRESULT = 0x80090007; +pub const NTE_BAD_ALGID: HRESULT = 0x80090008; +pub const NTE_BAD_FLAGS: HRESULT = 0x80090009; +pub const NTE_BAD_TYPE: HRESULT = 0x8009000A; +pub const NTE_BAD_KEY_STATE: HRESULT = 0x8009000B; +pub const NTE_BAD_HASH_STATE: HRESULT = 0x8009000C; +pub const NTE_NO_KEY: HRESULT = 0x8009000D; +pub const NTE_NO_MEMORY: HRESULT = 0x8009000E; +pub const NTE_EXISTS: HRESULT = 0x8009000F; +pub const NTE_PERM: HRESULT = 0x80090010; +pub const NTE_NOT_FOUND: HRESULT = 0x80090011; +pub const NTE_DOUBLE_ENCRYPT: HRESULT = 0x80090012; +pub const NTE_BAD_PROVIDER: HRESULT = 0x80090013; +pub const NTE_BAD_PROV_TYPE: HRESULT = 0x80090014; +pub const NTE_BAD_PUBLIC_KEY: HRESULT = 0x80090015; +pub const NTE_BAD_KEYSET: HRESULT = 0x80090016; +pub const NTE_PROV_TYPE_NOT_DEF: HRESULT = 0x80090017; +pub const NTE_PROV_TYPE_ENTRY_BAD: HRESULT = 0x80090018; +pub const NTE_KEYSET_NOT_DEF: HRESULT = 0x80090019; +pub const NTE_KEYSET_ENTRY_BAD: HRESULT = 0x8009001A; +pub const NTE_PROV_TYPE_NO_MATCH: HRESULT = 0x8009001B; +pub const NTE_SIGNATURE_FILE_BAD: HRESULT = 0x8009001C; +pub const NTE_PROVIDER_DLL_FAIL: HRESULT = 0x8009001D; +pub const NTE_PROV_DLL_NOT_FOUND: HRESULT = 0x8009001E; +pub const NTE_BAD_KEYSET_PARAM: HRESULT = 0x8009001F; +pub const NTE_FAIL: HRESULT = 0x80090020; +pub const NTE_SYS_ERR: HRESULT = 0x80090021; +pub const NTE_SILENT_CONTEXT: HRESULT = 0x80090022; +pub const NTE_TOKEN_KEYSET_STORAGE_FULL: HRESULT = 0x80090023; +pub const NTE_TEMPORARY_PROFILE: HRESULT = 0x80090024; +pub const NTE_FIXEDPARAMETER: HRESULT = 0x80090025; +pub const NTE_INVALID_HANDLE: HRESULT = 0x80090026; +pub const NTE_INVALID_PARAMETER: HRESULT = 0x80090027; +pub const NTE_BUFFER_TOO_SMALL: HRESULT = 0x80090028; +pub const NTE_NOT_SUPPORTED: HRESULT = 0x80090029; +pub const NTE_NO_MORE_ITEMS: HRESULT = 0x8009002A; +pub const NTE_BUFFERS_OVERLAP: HRESULT = 0x8009002B; +pub const NTE_DECRYPTION_FAILURE: HRESULT = 0x8009002C; +pub const NTE_INTERNAL_ERROR: HRESULT = 0x8009002D; +pub const NTE_UI_REQUIRED: HRESULT = 0x8009002E; +pub const NTE_HMAC_NOT_SUPPORTED: HRESULT = 0x8009002F; +pub const NTE_DEVICE_NOT_READY: HRESULT = 0x80090030; +pub const NTE_AUTHENTICATION_IGNORED: HRESULT = 0x80090031; +pub const NTE_VALIDATION_FAILED: HRESULT = 0x80090032; +pub const NTE_INCORRECT_PASSWORD: HRESULT = 0x80090033; +pub const NTE_ENCRYPTION_FAILURE: HRESULT = 0x80090034; +pub const NTE_DEVICE_NOT_FOUND: HRESULT = 0x80090035; +pub const SEC_E_INSUFFICIENT_MEMORY: HRESULT = 0x80090300; +pub const SEC_E_INVALID_HANDLE: HRESULT = 0x80090301; +pub const SEC_E_UNSUPPORTED_FUNCTION: HRESULT = 0x80090302; +pub const SEC_E_TARGET_UNKNOWN: HRESULT = 0x80090303; +pub const SEC_E_INTERNAL_ERROR: HRESULT = 0x80090304; +pub const SEC_E_SECPKG_NOT_FOUND: HRESULT = 0x80090305; +pub const SEC_E_NOT_OWNER: HRESULT = 0x80090306; +pub const SEC_E_CANNOT_INSTALL: HRESULT = 0x80090307; +pub const SEC_E_INVALID_TOKEN: HRESULT = 0x80090308; +pub const SEC_E_CANNOT_PACK: HRESULT = 0x80090309; +pub const SEC_E_QOP_NOT_SUPPORTED: HRESULT = 0x8009030A; +pub const SEC_E_NO_IMPERSONATION: HRESULT = 0x8009030B; +pub const SEC_E_LOGON_DENIED: HRESULT = 0x8009030C; +pub const SEC_E_UNKNOWN_CREDENTIALS: HRESULT = 0x8009030D; +pub const SEC_E_NO_CREDENTIALS: HRESULT = 0x8009030E; +pub const SEC_E_MESSAGE_ALTERED: HRESULT = 0x8009030F; +pub const SEC_E_OUT_OF_SEQUENCE: HRESULT = 0x80090310; +pub const SEC_E_NO_AUTHENTICATING_AUTHORITY: HRESULT = 0x80090311; +pub const SEC_I_CONTINUE_NEEDED: HRESULT = 0x00090312; +pub const SEC_I_COMPLETE_NEEDED: HRESULT = 0x00090313; +pub const SEC_I_COMPLETE_AND_CONTINUE: HRESULT = 0x00090314; +pub const SEC_I_LOCAL_LOGON: HRESULT = 0x00090315; +pub const SEC_E_BAD_PKGID: HRESULT = 0x80090316; +pub const SEC_E_CONTEXT_EXPIRED: HRESULT = 0x80090317; +pub const SEC_I_CONTEXT_EXPIRED: HRESULT = 0x00090317; +pub const SEC_E_INCOMPLETE_MESSAGE: HRESULT = 0x80090318; +pub const SEC_E_INCOMPLETE_CREDENTIALS: HRESULT = 0x80090320; +pub const SEC_E_BUFFER_TOO_SMALL: HRESULT = 0x80090321; +pub const SEC_I_INCOMPLETE_CREDENTIALS: HRESULT = 0x00090320; +pub const SEC_I_RENEGOTIATE: HRESULT = 0x00090321; +pub const SEC_E_WRONG_PRINCIPAL: HRESULT = 0x80090322; +pub const SEC_I_NO_LSA_CONTEXT: HRESULT = 0x00090323; +pub const SEC_E_TIME_SKEW: HRESULT = 0x80090324; +pub const SEC_E_UNTRUSTED_ROOT: HRESULT = 0x80090325; +pub const SEC_E_ILLEGAL_MESSAGE: HRESULT = 0x80090326; +pub const SEC_E_CERT_UNKNOWN: HRESULT = 0x80090327; +pub const SEC_E_CERT_EXPIRED: HRESULT = 0x80090328; +pub const SEC_E_ENCRYPT_FAILURE: HRESULT = 0x80090329; +pub const SEC_E_DECRYPT_FAILURE: HRESULT = 0x80090330; +pub const SEC_E_ALGORITHM_MISMATCH: HRESULT = 0x80090331; +pub const SEC_E_SECURITY_QOS_FAILED: HRESULT = 0x80090332; +pub const SEC_E_UNFINISHED_CONTEXT_DELETED: HRESULT = 0x80090333; +pub const SEC_E_NO_TGT_REPLY: HRESULT = 0x80090334; +pub const SEC_E_NO_IP_ADDRESSES: HRESULT = 0x80090335; +pub const SEC_E_WRONG_CREDENTIAL_HANDLE: HRESULT = 0x80090336; +pub const SEC_E_CRYPTO_SYSTEM_INVALID: HRESULT = 0x80090337; +pub const SEC_E_MAX_REFERRALS_EXCEEDED: HRESULT = 0x80090338; +pub const SEC_E_MUST_BE_KDC: HRESULT = 0x80090339; +pub const SEC_E_STRONG_CRYPTO_NOT_SUPPORTED: HRESULT = 0x8009033A; +pub const SEC_E_TOO_MANY_PRINCIPALS: HRESULT = 0x8009033B; +pub const SEC_E_NO_PA_DATA: HRESULT = 0x8009033C; +pub const SEC_E_PKINIT_NAME_MISMATCH: HRESULT = 0x8009033D; +pub const SEC_E_SMARTCARD_LOGON_REQUIRED: HRESULT = 0x8009033E; +pub const SEC_E_SHUTDOWN_IN_PROGRESS: HRESULT = 0x8009033F; +pub const SEC_E_KDC_INVALID_REQUEST: HRESULT = 0x80090340; +pub const SEC_E_KDC_UNABLE_TO_REFER: HRESULT = 0x80090341; +pub const SEC_E_KDC_UNKNOWN_ETYPE: HRESULT = 0x80090342; +pub const SEC_E_UNSUPPORTED_PREAUTH: HRESULT = 0x80090343; +pub const SEC_E_DELEGATION_REQUIRED: HRESULT = 0x80090345; +pub const SEC_E_BAD_BINDINGS: HRESULT = 0x80090346; +pub const SEC_E_MULTIPLE_ACCOUNTS: HRESULT = 0x80090347; +pub const SEC_E_NO_KERB_KEY: HRESULT = 0x80090348; +pub const SEC_E_CERT_WRONG_USAGE: HRESULT = 0x80090349; +pub const SEC_E_DOWNGRADE_DETECTED: HRESULT = 0x80090350; +pub const SEC_E_SMARTCARD_CERT_REVOKED: HRESULT = 0x80090351; +pub const SEC_E_ISSUING_CA_UNTRUSTED: HRESULT = 0x80090352; +pub const SEC_E_REVOCATION_OFFLINE_C: HRESULT = 0x80090353; +pub const SEC_E_PKINIT_CLIENT_FAILURE: HRESULT = 0x80090354; +pub const SEC_E_SMARTCARD_CERT_EXPIRED: HRESULT = 0x80090355; +pub const SEC_E_NO_S4U_PROT_SUPPORT: HRESULT = 0x80090356; +pub const SEC_E_CROSSREALM_DELEGATION_FAILURE: HRESULT = 0x80090357; +pub const SEC_E_REVOCATION_OFFLINE_KDC: HRESULT = 0x80090358; +pub const SEC_E_ISSUING_CA_UNTRUSTED_KDC: HRESULT = 0x80090359; +pub const SEC_E_KDC_CERT_EXPIRED: HRESULT = 0x8009035A; +pub const SEC_E_KDC_CERT_REVOKED: HRESULT = 0x8009035B; +pub const SEC_I_SIGNATURE_NEEDED: HRESULT = 0x0009035C; +pub const SEC_E_INVALID_PARAMETER: HRESULT = 0x8009035D; +pub const SEC_E_DELEGATION_POLICY: HRESULT = 0x8009035E; +pub const SEC_E_POLICY_NLTM_ONLY: HRESULT = 0x8009035F; +pub const SEC_I_NO_RENEGOTIATION: HRESULT = 0x00090360; +pub const SEC_E_NO_CONTEXT: HRESULT = 0x80090361; +pub const SEC_E_PKU2U_CERT_FAILURE: HRESULT = 0x80090362; +pub const SEC_E_MUTUAL_AUTH_FAILED: HRESULT = 0x80090363; +pub const SEC_I_MESSAGE_FRAGMENT: HRESULT = 0x00090364; +pub const SEC_E_ONLY_HTTPS_ALLOWED: HRESULT = 0x80090365; +pub const SEC_I_CONTINUE_NEEDED_MESSAGE_OK: HRESULT = 0x00090366; +pub const SEC_E_APPLICATION_PROTOCOL_MISMATCH: HRESULT = 0x80090367; +pub const SEC_E_NO_SPM: HRESULT = SEC_E_INTERNAL_ERROR; +pub const SEC_E_NOT_SUPPORTED: HRESULT = SEC_E_UNSUPPORTED_FUNCTION; +pub const CRYPT_E_MSG_ERROR: HRESULT = 0x80091001; +pub const CRYPT_E_UNKNOWN_ALGO: HRESULT = 0x80091002; +pub const CRYPT_E_OID_FORMAT: HRESULT = 0x80091003; +pub const CRYPT_E_INVALID_MSG_TYPE: HRESULT = 0x80091004; +pub const CRYPT_E_UNEXPECTED_ENCODING: HRESULT = 0x80091005; +pub const CRYPT_E_AUTH_ATTR_MISSING: HRESULT = 0x80091006; +pub const CRYPT_E_HASH_VALUE: HRESULT = 0x80091007; +pub const CRYPT_E_INVALID_INDEX: HRESULT = 0x80091008; +pub const CRYPT_E_ALREADY_DECRYPTED: HRESULT = 0x80091009; +pub const CRYPT_E_NOT_DECRYPTED: HRESULT = 0x8009100A; +pub const CRYPT_E_RECIPIENT_NOT_FOUND: HRESULT = 0x8009100B; +pub const CRYPT_E_CONTROL_TYPE: HRESULT = 0x8009100C; +pub const CRYPT_E_ISSUER_SERIALNUMBER: HRESULT = 0x8009100D; +pub const CRYPT_E_SIGNER_NOT_FOUND: HRESULT = 0x8009100E; +pub const CRYPT_E_ATTRIBUTES_MISSING: HRESULT = 0x8009100F; +pub const CRYPT_E_STREAM_MSG_NOT_READY: HRESULT = 0x80091010; +pub const CRYPT_E_STREAM_INSUFFICIENT_DATA: HRESULT = 0x80091011; +pub const CRYPT_I_NEW_PROTECTION_REQUIRED: HRESULT = 0x00091012; +pub const CRYPT_E_BAD_LEN: HRESULT = 0x80092001; +pub const CRYPT_E_BAD_ENCODE: HRESULT = 0x80092002; +pub const CRYPT_E_FILE_ERROR: HRESULT = 0x80092003; +pub const CRYPT_E_NOT_FOUND: HRESULT = 0x80092004; +pub const CRYPT_E_EXISTS: HRESULT = 0x80092005; +pub const CRYPT_E_NO_PROVIDER: HRESULT = 0x80092006; +pub const CRYPT_E_SELF_SIGNED: HRESULT = 0x80092007; +pub const CRYPT_E_DELETED_PREV: HRESULT = 0x80092008; +pub const CRYPT_E_NO_MATCH: HRESULT = 0x80092009; +pub const CRYPT_E_UNEXPECTED_MSG_TYPE: HRESULT = 0x8009200A; +pub const CRYPT_E_NO_KEY_PROPERTY: HRESULT = 0x8009200B; +pub const CRYPT_E_NO_DECRYPT_CERT: HRESULT = 0x8009200C; +pub const CRYPT_E_BAD_MSG: HRESULT = 0x8009200D; +pub const CRYPT_E_NO_SIGNER: HRESULT = 0x8009200E; +pub const CRYPT_E_PENDING_CLOSE: HRESULT = 0x8009200F; +pub const CRYPT_E_REVOKED: HRESULT = 0x80092010; +pub const CRYPT_E_NO_REVOCATION_DLL: HRESULT = 0x80092011; +pub const CRYPT_E_NO_REVOCATION_CHECK: HRESULT = 0x80092012; +pub const CRYPT_E_REVOCATION_OFFLINE: HRESULT = 0x80092013; +pub const CRYPT_E_NOT_IN_REVOCATION_DATABASE: HRESULT = 0x80092014; +pub const CRYPT_E_INVALID_NUMERIC_STRING: HRESULT = 0x80092020; +pub const CRYPT_E_INVALID_PRINTABLE_STRING: HRESULT = 0x80092021; +pub const CRYPT_E_INVALID_IA5_STRING: HRESULT = 0x80092022; +pub const CRYPT_E_INVALID_X500_STRING: HRESULT = 0x80092023; +pub const CRYPT_E_NOT_CHAR_STRING: HRESULT = 0x80092024; +pub const CRYPT_E_FILERESIZED: HRESULT = 0x80092025; +pub const CRYPT_E_SECURITY_SETTINGS: HRESULT = 0x80092026; +pub const CRYPT_E_NO_VERIFY_USAGE_DLL: HRESULT = 0x80092027; +pub const CRYPT_E_NO_VERIFY_USAGE_CHECK: HRESULT = 0x80092028; +pub const CRYPT_E_VERIFY_USAGE_OFFLINE: HRESULT = 0x80092029; +pub const CRYPT_E_NOT_IN_CTL: HRESULT = 0x8009202A; +pub const CRYPT_E_NO_TRUSTED_SIGNER: HRESULT = 0x8009202B; +pub const CRYPT_E_MISSING_PUBKEY_PARA: HRESULT = 0x8009202C; +pub const CRYPT_E_OBJECT_LOCATOR_OBJECT_NOT_FOUND: HRESULT = 0x8009202D; +pub const CRYPT_E_OSS_ERROR: HRESULT = 0x80093000; +pub const OSS_MORE_BUF: HRESULT = 0x80093001; +pub const OSS_NEGATIVE_UINTEGER: HRESULT = 0x80093002; +pub const OSS_PDU_RANGE: HRESULT = 0x80093003; +pub const OSS_MORE_INPUT: HRESULT = 0x80093004; +pub const OSS_DATA_ERROR: HRESULT = 0x80093005; +pub const OSS_BAD_ARG: HRESULT = 0x80093006; +pub const OSS_BAD_VERSION: HRESULT = 0x80093007; +pub const OSS_OUT_MEMORY: HRESULT = 0x80093008; +pub const OSS_PDU_MISMATCH: HRESULT = 0x80093009; +pub const OSS_LIMITED: HRESULT = 0x8009300A; +pub const OSS_BAD_PTR: HRESULT = 0x8009300B; +pub const OSS_BAD_TIME: HRESULT = 0x8009300C; +pub const OSS_INDEFINITE_NOT_SUPPORTED: HRESULT = 0x8009300D; +pub const OSS_MEM_ERROR: HRESULT = 0x8009300E; +pub const OSS_BAD_TABLE: HRESULT = 0x8009300F; +pub const OSS_TOO_LONG: HRESULT = 0x80093010; +pub const OSS_CONSTRAINT_VIOLATED: HRESULT = 0x80093011; +pub const OSS_FATAL_ERROR: HRESULT = 0x80093012; +pub const OSS_ACCESS_SERIALIZATION_ERROR: HRESULT = 0x80093013; +pub const OSS_NULL_TBL: HRESULT = 0x80093014; +pub const OSS_NULL_FCN: HRESULT = 0x80093015; +pub const OSS_BAD_ENCRULES: HRESULT = 0x80093016; +pub const OSS_UNAVAIL_ENCRULES: HRESULT = 0x80093017; +pub const OSS_CANT_OPEN_TRACE_WINDOW: HRESULT = 0x80093018; +pub const OSS_UNIMPLEMENTED: HRESULT = 0x80093019; +pub const OSS_OID_DLL_NOT_LINKED: HRESULT = 0x8009301A; +pub const OSS_CANT_OPEN_TRACE_FILE: HRESULT = 0x8009301B; +pub const OSS_TRACE_FILE_ALREADY_OPEN: HRESULT = 0x8009301C; +pub const OSS_TABLE_MISMATCH: HRESULT = 0x8009301D; +pub const OSS_TYPE_NOT_SUPPORTED: HRESULT = 0x8009301E; +pub const OSS_REAL_DLL_NOT_LINKED: HRESULT = 0x8009301F; +pub const OSS_REAL_CODE_NOT_LINKED: HRESULT = 0x80093020; +pub const OSS_OUT_OF_RANGE: HRESULT = 0x80093021; +pub const OSS_COPIER_DLL_NOT_LINKED: HRESULT = 0x80093022; +pub const OSS_CONSTRAINT_DLL_NOT_LINKED: HRESULT = 0x80093023; +pub const OSS_COMPARATOR_DLL_NOT_LINKED: HRESULT = 0x80093024; +pub const OSS_COMPARATOR_CODE_NOT_LINKED: HRESULT = 0x80093025; +pub const OSS_MEM_MGR_DLL_NOT_LINKED: HRESULT = 0x80093026; +pub const OSS_PDV_DLL_NOT_LINKED: HRESULT = 0x80093027; +pub const OSS_PDV_CODE_NOT_LINKED: HRESULT = 0x80093028; +pub const OSS_API_DLL_NOT_LINKED: HRESULT = 0x80093029; +pub const OSS_BERDER_DLL_NOT_LINKED: HRESULT = 0x8009302A; +pub const OSS_PER_DLL_NOT_LINKED: HRESULT = 0x8009302B; +pub const OSS_OPEN_TYPE_ERROR: HRESULT = 0x8009302C; +pub const OSS_MUTEX_NOT_CREATED: HRESULT = 0x8009302D; +pub const OSS_CANT_CLOSE_TRACE_FILE: HRESULT = 0x8009302E; +pub const CRYPT_E_ASN1_ERROR: HRESULT = 0x80093100; +pub const CRYPT_E_ASN1_INTERNAL: HRESULT = 0x80093101; +pub const CRYPT_E_ASN1_EOD: HRESULT = 0x80093102; +pub const CRYPT_E_ASN1_CORRUPT: HRESULT = 0x80093103; +pub const CRYPT_E_ASN1_LARGE: HRESULT = 0x80093104; +pub const CRYPT_E_ASN1_CONSTRAINT: HRESULT = 0x80093105; +pub const CRYPT_E_ASN1_MEMORY: HRESULT = 0x80093106; +pub const CRYPT_E_ASN1_OVERFLOW: HRESULT = 0x80093107; +pub const CRYPT_E_ASN1_BADPDU: HRESULT = 0x80093108; +pub const CRYPT_E_ASN1_BADARGS: HRESULT = 0x80093109; +pub const CRYPT_E_ASN1_BADREAL: HRESULT = 0x8009310A; +pub const CRYPT_E_ASN1_BADTAG: HRESULT = 0x8009310B; +pub const CRYPT_E_ASN1_CHOICE: HRESULT = 0x8009310C; +pub const CRYPT_E_ASN1_RULE: HRESULT = 0x8009310D; +pub const CRYPT_E_ASN1_UTF8: HRESULT = 0x8009310E; +pub const CRYPT_E_ASN1_PDU_TYPE: HRESULT = 0x80093133; +pub const CRYPT_E_ASN1_NYI: HRESULT = 0x80093134; +pub const CRYPT_E_ASN1_EXTENDED: HRESULT = 0x80093201; +pub const CRYPT_E_ASN1_NOEOD: HRESULT = 0x80093202; +pub const CERTSRV_E_BAD_REQUESTSUBJECT: HRESULT = 0x80094001; +pub const CERTSRV_E_NO_REQUEST: HRESULT = 0x80094002; +pub const CERTSRV_E_BAD_REQUESTSTATUS: HRESULT = 0x80094003; +pub const CERTSRV_E_PROPERTY_EMPTY: HRESULT = 0x80094004; +pub const CERTSRV_E_INVALID_CA_CERTIFICATE: HRESULT = 0x80094005; +pub const CERTSRV_E_SERVER_SUSPENDED: HRESULT = 0x80094006; +pub const CERTSRV_E_ENCODING_LENGTH: HRESULT = 0x80094007; +pub const CERTSRV_E_ROLECONFLICT: HRESULT = 0x80094008; +pub const CERTSRV_E_RESTRICTEDOFFICER: HRESULT = 0x80094009; +pub const CERTSRV_E_KEY_ARCHIVAL_NOT_CONFIGURED: HRESULT = 0x8009400A; +pub const CERTSRV_E_NO_VALID_KRA: HRESULT = 0x8009400B; +pub const CERTSRV_E_BAD_REQUEST_KEY_ARCHIVAL: HRESULT = 0x8009400C; +pub const CERTSRV_E_NO_CAADMIN_DEFINED: HRESULT = 0x8009400D; +pub const CERTSRV_E_BAD_RENEWAL_CERT_ATTRIBUTE: HRESULT = 0x8009400E; +pub const CERTSRV_E_NO_DB_SESSIONS: HRESULT = 0x8009400F; +pub const CERTSRV_E_ALIGNMENT_FAULT: HRESULT = 0x80094010; +pub const CERTSRV_E_ENROLL_DENIED: HRESULT = 0x80094011; +pub const CERTSRV_E_TEMPLATE_DENIED: HRESULT = 0x80094012; +pub const CERTSRV_E_DOWNLEVEL_DC_SSL_OR_UPGRADE: HRESULT = 0x80094013; +pub const CERTSRV_E_ADMIN_DENIED_REQUEST: HRESULT = 0x80094014; +pub const CERTSRV_E_NO_POLICY_SERVER: HRESULT = 0x80094015; +pub const CERTSRV_E_WEAK_SIGNATURE_OR_KEY: HRESULT = 0x80094016; +pub const CERTSRV_E_KEY_ATTESTATION_NOT_SUPPORTED: HRESULT = 0x80094017; +pub const CERTSRV_E_ENCRYPTION_CERT_REQUIRED: HRESULT = 0x80094018; +pub const CERTSRV_E_UNSUPPORTED_CERT_TYPE: HRESULT = 0x80094800; +pub const CERTSRV_E_NO_CERT_TYPE: HRESULT = 0x80094801; +pub const CERTSRV_E_TEMPLATE_CONFLICT: HRESULT = 0x80094802; +pub const CERTSRV_E_SUBJECT_ALT_NAME_REQUIRED: HRESULT = 0x80094803; +pub const CERTSRV_E_ARCHIVED_KEY_REQUIRED: HRESULT = 0x80094804; +pub const CERTSRV_E_SMIME_REQUIRED: HRESULT = 0x80094805; +pub const CERTSRV_E_BAD_RENEWAL_SUBJECT: HRESULT = 0x80094806; +pub const CERTSRV_E_BAD_TEMPLATE_VERSION: HRESULT = 0x80094807; +pub const CERTSRV_E_TEMPLATE_POLICY_REQUIRED: HRESULT = 0x80094808; +pub const CERTSRV_E_SIGNATURE_POLICY_REQUIRED: HRESULT = 0x80094809; +pub const CERTSRV_E_SIGNATURE_COUNT: HRESULT = 0x8009480A; +pub const CERTSRV_E_SIGNATURE_REJECTED: HRESULT = 0x8009480B; +pub const CERTSRV_E_ISSUANCE_POLICY_REQUIRED: HRESULT = 0x8009480C; +pub const CERTSRV_E_SUBJECT_UPN_REQUIRED: HRESULT = 0x8009480D; +pub const CERTSRV_E_SUBJECT_DIRECTORY_GUID_REQUIRED: HRESULT = 0x8009480E; +pub const CERTSRV_E_SUBJECT_DNS_REQUIRED: HRESULT = 0x8009480F; +pub const CERTSRV_E_ARCHIVED_KEY_UNEXPECTED: HRESULT = 0x80094810; +pub const CERTSRV_E_KEY_LENGTH: HRESULT = 0x80094811; +pub const CERTSRV_E_SUBJECT_EMAIL_REQUIRED: HRESULT = 0x80094812; +pub const CERTSRV_E_UNKNOWN_CERT_TYPE: HRESULT = 0x80094813; +pub const CERTSRV_E_CERT_TYPE_OVERLAP: HRESULT = 0x80094814; +pub const CERTSRV_E_TOO_MANY_SIGNATURES: HRESULT = 0x80094815; +pub const CERTSRV_E_RENEWAL_BAD_PUBLIC_KEY: HRESULT = 0x80094816; +pub const CERTSRV_E_INVALID_EK: HRESULT = 0x80094817; +pub const CERTSRV_E_INVALID_IDBINDING: HRESULT = 0x80094818; +pub const CERTSRV_E_INVALID_ATTESTATION: HRESULT = 0x80094819; +pub const CERTSRV_E_KEY_ATTESTATION: HRESULT = 0x8009481A; +pub const CERTSRV_E_CORRUPT_KEY_ATTESTATION: HRESULT = 0x8009481B; +pub const CERTSRV_E_EXPIRED_CHALLENGE: HRESULT = 0x8009481C; +pub const CERTSRV_E_INVALID_RESPONSE: HRESULT = 0x8009481D; +pub const CERTSRV_E_INVALID_REQUESTID: HRESULT = 0x8009481E; +pub const XENROLL_E_KEY_NOT_EXPORTABLE: HRESULT = 0x80095000; +pub const XENROLL_E_CANNOT_ADD_ROOT_CERT: HRESULT = 0x80095001; +pub const XENROLL_E_RESPONSE_KA_HASH_NOT_FOUND: HRESULT = 0x80095002; +pub const XENROLL_E_RESPONSE_UNEXPECTED_KA_HASH: HRESULT = 0x80095003; +pub const XENROLL_E_RESPONSE_KA_HASH_MISMATCH: HRESULT = 0x80095004; +pub const XENROLL_E_KEYSPEC_SMIME_MISMATCH: HRESULT = 0x80095005; +pub const TRUST_E_SYSTEM_ERROR: HRESULT = 0x80096001; +pub const TRUST_E_NO_SIGNER_CERT: HRESULT = 0x80096002; +pub const TRUST_E_COUNTER_SIGNER: HRESULT = 0x80096003; +pub const TRUST_E_CERT_SIGNATURE: HRESULT = 0x80096004; +pub const TRUST_E_TIME_STAMP: HRESULT = 0x80096005; +pub const TRUST_E_BAD_DIGEST: HRESULT = 0x80096010; +pub const TRUST_E_BASIC_CONSTRAINTS: HRESULT = 0x80096019; +pub const TRUST_E_FINANCIAL_CRITERIA: HRESULT = 0x8009601E; +pub const MSSIPOTF_E_OUTOFMEMRANGE: HRESULT = 0x80097001; +pub const MSSIPOTF_E_CANTGETOBJECT: HRESULT = 0x80097002; +pub const MSSIPOTF_E_NOHEADTABLE: HRESULT = 0x80097003; +pub const MSSIPOTF_E_BAD_MAGICNUMBER: HRESULT = 0x80097004; +pub const MSSIPOTF_E_BAD_OFFSET_TABLE: HRESULT = 0x80097005; +pub const MSSIPOTF_E_TABLE_TAGORDER: HRESULT = 0x80097006; +pub const MSSIPOTF_E_TABLE_LONGWORD: HRESULT = 0x80097007; +pub const MSSIPOTF_E_BAD_FIRST_TABLE_PLACEMENT: HRESULT = 0x80097008; +pub const MSSIPOTF_E_TABLES_OVERLAP: HRESULT = 0x80097009; +pub const MSSIPOTF_E_TABLE_PADBYTES: HRESULT = 0x8009700A; +pub const MSSIPOTF_E_FILETOOSMALL: HRESULT = 0x8009700B; +pub const MSSIPOTF_E_TABLE_CHECKSUM: HRESULT = 0x8009700C; +pub const MSSIPOTF_E_FILE_CHECKSUM: HRESULT = 0x8009700D; +pub const MSSIPOTF_E_FAILED_POLICY: HRESULT = 0x80097010; +pub const MSSIPOTF_E_FAILED_HINTS_CHECK: HRESULT = 0x80097011; +pub const MSSIPOTF_E_NOT_OPENTYPE: HRESULT = 0x80097012; +pub const MSSIPOTF_E_FILE: HRESULT = 0x80097013; +pub const MSSIPOTF_E_CRYPT: HRESULT = 0x80097014; +pub const MSSIPOTF_E_BADVERSION: HRESULT = 0x80097015; +pub const MSSIPOTF_E_DSIG_STRUCTURE: HRESULT = 0x80097016; +pub const MSSIPOTF_E_PCONST_CHECK: HRESULT = 0x80097017; +pub const MSSIPOTF_E_STRUCTURE: HRESULT = 0x80097018; +pub const ERROR_CRED_REQUIRES_CONFIRMATION: HRESULT = 0x80097019; +pub const NTE_OP_OK: HRESULT = 0; +pub const TRUST_E_PROVIDER_UNKNOWN: HRESULT = 0x800B0001; +pub const TRUST_E_ACTION_UNKNOWN: HRESULT = 0x800B0002; +pub const TRUST_E_SUBJECT_FORM_UNKNOWN: HRESULT = 0x800B0003; +pub const TRUST_E_SUBJECT_NOT_TRUSTED: HRESULT = 0x800B0004; +pub const DIGSIG_E_ENCODE: HRESULT = 0x800B0005; +pub const DIGSIG_E_DECODE: HRESULT = 0x800B0006; +pub const DIGSIG_E_EXTENSIBILITY: HRESULT = 0x800B0007; +pub const DIGSIG_E_CRYPTO: HRESULT = 0x800B0008; +pub const PERSIST_E_SIZEDEFINITE: HRESULT = 0x800B0009; +pub const PERSIST_E_SIZEINDEFINITE: HRESULT = 0x800B000A; +pub const PERSIST_E_NOTSELFSIZING: HRESULT = 0x800B000B; +pub const TRUST_E_NOSIGNATURE: HRESULT = 0x800B0100; +pub const CERT_E_EXPIRED: HRESULT = 0x800B0101; +pub const CERT_E_VALIDITYPERIODNESTING: HRESULT = 0x800B0102; +pub const CERT_E_ROLE: HRESULT = 0x800B0103; +pub const CERT_E_PATHLENCONST: HRESULT = 0x800B0104; +pub const CERT_E_CRITICAL: HRESULT = 0x800B0105; +pub const CERT_E_PURPOSE: HRESULT = 0x800B0106; +pub const CERT_E_ISSUERCHAINING: HRESULT = 0x800B0107; +pub const CERT_E_MALFORMED: HRESULT = 0x800B0108; +pub const CERT_E_UNTRUSTEDROOT: HRESULT = 0x800B0109; +pub const CERT_E_CHAINING: HRESULT = 0x800B010A; +pub const TRUST_E_FAIL: HRESULT = 0x800B010B; +pub const CERT_E_REVOKED: HRESULT = 0x800B010C; +pub const CERT_E_UNTRUSTEDTESTROOT: HRESULT = 0x800B010D; +pub const CERT_E_REVOCATION_FAILURE: HRESULT = 0x800B010E; +pub const CERT_E_CN_NO_MATCH: HRESULT = 0x800B010F; +pub const CERT_E_WRONG_USAGE: HRESULT = 0x800B0110; +pub const TRUST_E_EXPLICIT_DISTRUST: HRESULT = 0x800B0111; +pub const CERT_E_UNTRUSTEDCA: HRESULT = 0x800B0112; +pub const CERT_E_INVALID_POLICY: HRESULT = 0x800B0113; +pub const CERT_E_INVALID_NAME: HRESULT = 0x800B0114; +pub const SPAPI_E_EXPECTED_SECTION_NAME: HRESULT = 0x800F0000; +pub const SPAPI_E_BAD_SECTION_NAME_LINE: HRESULT = 0x800F0001; +pub const SPAPI_E_SECTION_NAME_TOO_LONG: HRESULT = 0x800F0002; +pub const SPAPI_E_GENERAL_SYNTAX: HRESULT = 0x800F0003; +pub const SPAPI_E_WRONG_INF_STYLE: HRESULT = 0x800F0100; +pub const SPAPI_E_SECTION_NOT_FOUND: HRESULT = 0x800F0101; +pub const SPAPI_E_LINE_NOT_FOUND: HRESULT = 0x800F0102; +pub const SPAPI_E_NO_BACKUP: HRESULT = 0x800F0103; +pub const SPAPI_E_NO_ASSOCIATED_CLASS: HRESULT = 0x800F0200; +pub const SPAPI_E_CLASS_MISMATCH: HRESULT = 0x800F0201; +pub const SPAPI_E_DUPLICATE_FOUND: HRESULT = 0x800F0202; +pub const SPAPI_E_NO_DRIVER_SELECTED: HRESULT = 0x800F0203; +pub const SPAPI_E_KEY_DOES_NOT_EXIST: HRESULT = 0x800F0204; +pub const SPAPI_E_INVALID_DEVINST_NAME: HRESULT = 0x800F0205; +pub const SPAPI_E_INVALID_CLASS: HRESULT = 0x800F0206; +pub const SPAPI_E_DEVINST_ALREADY_EXISTS: HRESULT = 0x800F0207; +pub const SPAPI_E_DEVINFO_NOT_REGISTERED: HRESULT = 0x800F0208; +pub const SPAPI_E_INVALID_REG_PROPERTY: HRESULT = 0x800F0209; +pub const SPAPI_E_NO_INF: HRESULT = 0x800F020A; +pub const SPAPI_E_NO_SUCH_DEVINST: HRESULT = 0x800F020B; +pub const SPAPI_E_CANT_LOAD_CLASS_ICON: HRESULT = 0x800F020C; +pub const SPAPI_E_INVALID_CLASS_INSTALLER: HRESULT = 0x800F020D; +pub const SPAPI_E_DI_DO_DEFAULT: HRESULT = 0x800F020E; +pub const SPAPI_E_DI_NOFILECOPY: HRESULT = 0x800F020F; +pub const SPAPI_E_INVALID_HWPROFILE: HRESULT = 0x800F0210; +pub const SPAPI_E_NO_DEVICE_SELECTED: HRESULT = 0x800F0211; +pub const SPAPI_E_DEVINFO_LIST_LOCKED: HRESULT = 0x800F0212; +pub const SPAPI_E_DEVINFO_DATA_LOCKED: HRESULT = 0x800F0213; +pub const SPAPI_E_DI_BAD_PATH: HRESULT = 0x800F0214; +pub const SPAPI_E_NO_CLASSINSTALL_PARAMS: HRESULT = 0x800F0215; +pub const SPAPI_E_FILEQUEUE_LOCKED: HRESULT = 0x800F0216; +pub const SPAPI_E_BAD_SERVICE_INSTALLSECT: HRESULT = 0x800F0217; +pub const SPAPI_E_NO_CLASS_DRIVER_LIST: HRESULT = 0x800F0218; +pub const SPAPI_E_NO_ASSOCIATED_SERVICE: HRESULT = 0x800F0219; +pub const SPAPI_E_NO_DEFAULT_DEVICE_INTERFACE: HRESULT = 0x800F021A; +pub const SPAPI_E_DEVICE_INTERFACE_ACTIVE: HRESULT = 0x800F021B; +pub const SPAPI_E_DEVICE_INTERFACE_REMOVED: HRESULT = 0x800F021C; +pub const SPAPI_E_BAD_INTERFACE_INSTALLSECT: HRESULT = 0x800F021D; +pub const SPAPI_E_NO_SUCH_INTERFACE_CLASS: HRESULT = 0x800F021E; +pub const SPAPI_E_INVALID_REFERENCE_STRING: HRESULT = 0x800F021F; +pub const SPAPI_E_INVALID_MACHINENAME: HRESULT = 0x800F0220; +pub const SPAPI_E_REMOTE_COMM_FAILURE: HRESULT = 0x800F0221; +pub const SPAPI_E_MACHINE_UNAVAILABLE: HRESULT = 0x800F0222; +pub const SPAPI_E_NO_CONFIGMGR_SERVICES: HRESULT = 0x800F0223; +pub const SPAPI_E_INVALID_PROPPAGE_PROVIDER: HRESULT = 0x800F0224; +pub const SPAPI_E_NO_SUCH_DEVICE_INTERFACE: HRESULT = 0x800F0225; +pub const SPAPI_E_DI_POSTPROCESSING_REQUIRED: HRESULT = 0x800F0226; +pub const SPAPI_E_INVALID_COINSTALLER: HRESULT = 0x800F0227; +pub const SPAPI_E_NO_COMPAT_DRIVERS: HRESULT = 0x800F0228; +pub const SPAPI_E_NO_DEVICE_ICON: HRESULT = 0x800F0229; +pub const SPAPI_E_INVALID_INF_LOGCONFIG: HRESULT = 0x800F022A; +pub const SPAPI_E_DI_DONT_INSTALL: HRESULT = 0x800F022B; +pub const SPAPI_E_INVALID_FILTER_DRIVER: HRESULT = 0x800F022C; +pub const SPAPI_E_NON_WINDOWS_NT_DRIVER: HRESULT = 0x800F022D; +pub const SPAPI_E_NON_WINDOWS_DRIVER: HRESULT = 0x800F022E; +pub const SPAPI_E_NO_CATALOG_FOR_OEM_INF: HRESULT = 0x800F022F; +pub const SPAPI_E_DEVINSTALL_QUEUE_NONNATIVE: HRESULT = 0x800F0230; +pub const SPAPI_E_NOT_DISABLEABLE: HRESULT = 0x800F0231; +pub const SPAPI_E_CANT_REMOVE_DEVINST: HRESULT = 0x800F0232; +pub const SPAPI_E_INVALID_TARGET: HRESULT = 0x800F0233; +pub const SPAPI_E_DRIVER_NONNATIVE: HRESULT = 0x800F0234; +pub const SPAPI_E_IN_WOW64: HRESULT = 0x800F0235; +pub const SPAPI_E_SET_SYSTEM_RESTORE_POINT: HRESULT = 0x800F0236; +pub const SPAPI_E_INCORRECTLY_COPIED_INF: HRESULT = 0x800F0237; +pub const SPAPI_E_SCE_DISABLED: HRESULT = 0x800F0238; +pub const SPAPI_E_UNKNOWN_EXCEPTION: HRESULT = 0x800F0239; +pub const SPAPI_E_PNP_REGISTRY_ERROR: HRESULT = 0x800F023A; +pub const SPAPI_E_REMOTE_REQUEST_UNSUPPORTED: HRESULT = 0x800F023B; +pub const SPAPI_E_NOT_AN_INSTALLED_OEM_INF: HRESULT = 0x800F023C; +pub const SPAPI_E_INF_IN_USE_BY_DEVICES: HRESULT = 0x800F023D; +pub const SPAPI_E_DI_FUNCTION_OBSOLETE: HRESULT = 0x800F023E; +pub const SPAPI_E_NO_AUTHENTICODE_CATALOG: HRESULT = 0x800F023F; +pub const SPAPI_E_AUTHENTICODE_DISALLOWED: HRESULT = 0x800F0240; +pub const SPAPI_E_AUTHENTICODE_TRUSTED_PUBLISHER: HRESULT = 0x800F0241; +pub const SPAPI_E_AUTHENTICODE_TRUST_NOT_ESTABLISHED: HRESULT = 0x800F0242; +pub const SPAPI_E_AUTHENTICODE_PUBLISHER_NOT_TRUSTED: HRESULT = 0x800F0243; +pub const SPAPI_E_SIGNATURE_OSATTRIBUTE_MISMATCH: HRESULT = 0x800F0244; +pub const SPAPI_E_ONLY_VALIDATE_VIA_AUTHENTICODE: HRESULT = 0x800F0245; +pub const SPAPI_E_DEVICE_INSTALLER_NOT_READY: HRESULT = 0x800F0246; +pub const SPAPI_E_DRIVER_STORE_ADD_FAILED: HRESULT = 0x800F0247; +pub const SPAPI_E_DEVICE_INSTALL_BLOCKED: HRESULT = 0x800F0248; +pub const SPAPI_E_DRIVER_INSTALL_BLOCKED: HRESULT = 0x800F0249; +pub const SPAPI_E_WRONG_INF_TYPE: HRESULT = 0x800F024A; +pub const SPAPI_E_FILE_HASH_NOT_IN_CATALOG: HRESULT = 0x800F024B; +pub const SPAPI_E_DRIVER_STORE_DELETE_FAILED: HRESULT = 0x800F024C; +pub const SPAPI_E_UNRECOVERABLE_STACK_OVERFLOW: HRESULT = 0x800F0300; +pub const SPAPI_E_ERROR_NOT_INSTALLED: HRESULT = 0x800F1000; +pub const SCARD_S_SUCCESS: HRESULT = NO_ERROR as i32; +pub const SCARD_F_INTERNAL_ERROR: HRESULT = 0x80100001; +pub const SCARD_E_CANCELLED: HRESULT = 0x80100002; +pub const SCARD_E_INVALID_HANDLE: HRESULT = 0x80100003; +pub const SCARD_E_INVALID_PARAMETER: HRESULT = 0x80100004; +pub const SCARD_E_INVALID_TARGET: HRESULT = 0x80100005; +pub const SCARD_E_NO_MEMORY: HRESULT = 0x80100006; +pub const SCARD_F_WAITED_TOO_LONG: HRESULT = 0x80100007; +pub const SCARD_E_INSUFFICIENT_BUFFER: HRESULT = 0x80100008; +pub const SCARD_E_UNKNOWN_READER: HRESULT = 0x80100009; +pub const SCARD_E_TIMEOUT: HRESULT = 0x8010000A; +pub const SCARD_E_SHARING_VIOLATION: HRESULT = 0x8010000B; +pub const SCARD_E_NO_SMARTCARD: HRESULT = 0x8010000C; +pub const SCARD_E_UNKNOWN_CARD: HRESULT = 0x8010000D; +pub const SCARD_E_CANT_DISPOSE: HRESULT = 0x8010000E; +pub const SCARD_E_PROTO_MISMATCH: HRESULT = 0x8010000F; +pub const SCARD_E_NOT_READY: HRESULT = 0x80100010; +pub const SCARD_E_INVALID_VALUE: HRESULT = 0x80100011; +pub const SCARD_E_SYSTEM_CANCELLED: HRESULT = 0x80100012; +pub const SCARD_F_COMM_ERROR: HRESULT = 0x80100013; +pub const SCARD_F_UNKNOWN_ERROR: HRESULT = 0x80100014; +pub const SCARD_E_INVALID_ATR: HRESULT = 0x80100015; +pub const SCARD_E_NOT_TRANSACTED: HRESULT = 0x80100016; +pub const SCARD_E_READER_UNAVAILABLE: HRESULT = 0x80100017; +pub const SCARD_P_SHUTDOWN: HRESULT = 0x80100018; +pub const SCARD_E_PCI_TOO_SMALL: HRESULT = 0x80100019; +pub const SCARD_E_READER_UNSUPPORTED: HRESULT = 0x8010001A; +pub const SCARD_E_DUPLICATE_READER: HRESULT = 0x8010001B; +pub const SCARD_E_CARD_UNSUPPORTED: HRESULT = 0x8010001C; +pub const SCARD_E_NO_SERVICE: HRESULT = 0x8010001D; +pub const SCARD_E_SERVICE_STOPPED: HRESULT = 0x8010001E; +pub const SCARD_E_UNEXPECTED: HRESULT = 0x8010001F; +pub const SCARD_E_ICC_INSTALLATION: HRESULT = 0x80100020; +pub const SCARD_E_ICC_CREATEORDER: HRESULT = 0x80100021; +pub const SCARD_E_UNSUPPORTED_FEATURE: HRESULT = 0x80100022; +pub const SCARD_E_DIR_NOT_FOUND: HRESULT = 0x80100023; +pub const SCARD_E_FILE_NOT_FOUND: HRESULT = 0x80100024; +pub const SCARD_E_NO_DIR: HRESULT = 0x80100025; +pub const SCARD_E_NO_FILE: HRESULT = 0x80100026; +pub const SCARD_E_NO_ACCESS: HRESULT = 0x80100027; +pub const SCARD_E_WRITE_TOO_MANY: HRESULT = 0x80100028; +pub const SCARD_E_BAD_SEEK: HRESULT = 0x80100029; +pub const SCARD_E_INVALID_CHV: HRESULT = 0x8010002A; +pub const SCARD_E_UNKNOWN_RES_MNG: HRESULT = 0x8010002B; +pub const SCARD_E_NO_SUCH_CERTIFICATE: HRESULT = 0x8010002C; +pub const SCARD_E_CERTIFICATE_UNAVAILABLE: HRESULT = 0x8010002D; +pub const SCARD_E_NO_READERS_AVAILABLE: HRESULT = 0x8010002E; +pub const SCARD_E_COMM_DATA_LOST: HRESULT = 0x8010002F; +pub const SCARD_E_NO_KEY_CONTAINER: HRESULT = 0x80100030; +pub const SCARD_E_SERVER_TOO_BUSY: HRESULT = 0x80100031; +pub const SCARD_E_PIN_CACHE_EXPIRED: HRESULT = 0x80100032; +pub const SCARD_E_NO_PIN_CACHE: HRESULT = 0x80100033; +pub const SCARD_E_READ_ONLY_CARD: HRESULT = 0x80100034; +pub const SCARD_W_UNSUPPORTED_CARD: HRESULT = 0x80100065; +pub const SCARD_W_UNRESPONSIVE_CARD: HRESULT = 0x80100066; +pub const SCARD_W_UNPOWERED_CARD: HRESULT = 0x80100067; +pub const SCARD_W_RESET_CARD: HRESULT = 0x80100068; +pub const SCARD_W_REMOVED_CARD: HRESULT = 0x80100069; +pub const SCARD_W_SECURITY_VIOLATION: HRESULT = 0x8010006A; +pub const SCARD_W_WRONG_CHV: HRESULT = 0x8010006B; +pub const SCARD_W_CHV_BLOCKED: HRESULT = 0x8010006C; +pub const SCARD_W_EOF: HRESULT = 0x8010006D; +pub const SCARD_W_CANCELLED_BY_USER: HRESULT = 0x8010006E; +pub const SCARD_W_CARD_NOT_AUTHENTICATED: HRESULT = 0x8010006F; +pub const SCARD_W_CACHE_ITEM_NOT_FOUND: HRESULT = 0x80100070; +pub const SCARD_W_CACHE_ITEM_STALE: HRESULT = 0x80100071; +pub const SCARD_W_CACHE_ITEM_TOO_BIG: HRESULT = 0x80100072; +pub const COMADMIN_E_OBJECTERRORS: HRESULT = 0x80110401; +pub const COMADMIN_E_OBJECTINVALID: HRESULT = 0x80110402; +pub const COMADMIN_E_KEYMISSING: HRESULT = 0x80110403; +pub const COMADMIN_E_ALREADYINSTALLED: HRESULT = 0x80110404; +pub const COMADMIN_E_APP_FILE_WRITEFAIL: HRESULT = 0x80110407; +pub const COMADMIN_E_APP_FILE_READFAIL: HRESULT = 0x80110408; +pub const COMADMIN_E_APP_FILE_VERSION: HRESULT = 0x80110409; +pub const COMADMIN_E_BADPATH: HRESULT = 0x8011040A; +pub const COMADMIN_E_APPLICATIONEXISTS: HRESULT = 0x8011040B; +pub const COMADMIN_E_ROLEEXISTS: HRESULT = 0x8011040C; +pub const COMADMIN_E_CANTCOPYFILE: HRESULT = 0x8011040D; +pub const COMADMIN_E_NOUSER: HRESULT = 0x8011040F; +pub const COMADMIN_E_INVALIDUSERIDS: HRESULT = 0x80110410; +pub const COMADMIN_E_NOREGISTRYCLSID: HRESULT = 0x80110411; +pub const COMADMIN_E_BADREGISTRYPROGID: HRESULT = 0x80110412; +pub const COMADMIN_E_AUTHENTICATIONLEVEL: HRESULT = 0x80110413; +pub const COMADMIN_E_USERPASSWDNOTVALID: HRESULT = 0x80110414; +pub const COMADMIN_E_CLSIDORIIDMISMATCH: HRESULT = 0x80110418; +pub const COMADMIN_E_REMOTEINTERFACE: HRESULT = 0x80110419; +pub const COMADMIN_E_DLLREGISTERSERVER: HRESULT = 0x8011041A; +pub const COMADMIN_E_NOSERVERSHARE: HRESULT = 0x8011041B; +pub const COMADMIN_E_DLLLOADFAILED: HRESULT = 0x8011041D; +pub const COMADMIN_E_BADREGISTRYLIBID: HRESULT = 0x8011041E; +pub const COMADMIN_E_APPDIRNOTFOUND: HRESULT = 0x8011041F; +pub const COMADMIN_E_REGISTRARFAILED: HRESULT = 0x80110423; +pub const COMADMIN_E_COMPFILE_DOESNOTEXIST: HRESULT = 0x80110424; +pub const COMADMIN_E_COMPFILE_LOADDLLFAIL: HRESULT = 0x80110425; +pub const COMADMIN_E_COMPFILE_GETCLASSOBJ: HRESULT = 0x80110426; +pub const COMADMIN_E_COMPFILE_CLASSNOTAVAIL: HRESULT = 0x80110427; +pub const COMADMIN_E_COMPFILE_BADTLB: HRESULT = 0x80110428; +pub const COMADMIN_E_COMPFILE_NOTINSTALLABLE: HRESULT = 0x80110429; +pub const COMADMIN_E_NOTCHANGEABLE: HRESULT = 0x8011042A; +pub const COMADMIN_E_NOTDELETEABLE: HRESULT = 0x8011042B; +pub const COMADMIN_E_SESSION: HRESULT = 0x8011042C; +pub const COMADMIN_E_COMP_MOVE_LOCKED: HRESULT = 0x8011042D; +pub const COMADMIN_E_COMP_MOVE_BAD_DEST: HRESULT = 0x8011042E; +pub const COMADMIN_E_REGISTERTLB: HRESULT = 0x80110430; +pub const COMADMIN_E_SYSTEMAPP: HRESULT = 0x80110433; +pub const COMADMIN_E_COMPFILE_NOREGISTRAR: HRESULT = 0x80110434; +pub const COMADMIN_E_COREQCOMPINSTALLED: HRESULT = 0x80110435; +pub const COMADMIN_E_SERVICENOTINSTALLED: HRESULT = 0x80110436; +pub const COMADMIN_E_PROPERTYSAVEFAILED: HRESULT = 0x80110437; +pub const COMADMIN_E_OBJECTEXISTS: HRESULT = 0x80110438; +pub const COMADMIN_E_COMPONENTEXISTS: HRESULT = 0x80110439; +pub const COMADMIN_E_REGFILE_CORRUPT: HRESULT = 0x8011043B; +pub const COMADMIN_E_PROPERTY_OVERFLOW: HRESULT = 0x8011043C; +pub const COMADMIN_E_NOTINREGISTRY: HRESULT = 0x8011043E; +pub const COMADMIN_E_OBJECTNOTPOOLABLE: HRESULT = 0x8011043F; +pub const COMADMIN_E_APPLID_MATCHES_CLSID: HRESULT = 0x80110446; +pub const COMADMIN_E_ROLE_DOES_NOT_EXIST: HRESULT = 0x80110447; +pub const COMADMIN_E_START_APP_NEEDS_COMPONENTS: HRESULT = 0x80110448; +pub const COMADMIN_E_REQUIRES_DIFFERENT_PLATFORM: HRESULT = 0x80110449; +pub const COMADMIN_E_CAN_NOT_EXPORT_APP_PROXY: HRESULT = 0x8011044A; +pub const COMADMIN_E_CAN_NOT_START_APP: HRESULT = 0x8011044B; +pub const COMADMIN_E_CAN_NOT_EXPORT_SYS_APP: HRESULT = 0x8011044C; +pub const COMADMIN_E_CANT_SUBSCRIBE_TO_COMPONENT: HRESULT = 0x8011044D; +pub const COMADMIN_E_EVENTCLASS_CANT_BE_SUBSCRIBER: HRESULT = 0x8011044E; +pub const COMADMIN_E_LIB_APP_PROXY_INCOMPATIBLE: HRESULT = 0x8011044F; +pub const COMADMIN_E_BASE_PARTITION_ONLY: HRESULT = 0x80110450; +pub const COMADMIN_E_START_APP_DISABLED: HRESULT = 0x80110451; +pub const COMADMIN_E_CAT_DUPLICATE_PARTITION_NAME: HRESULT = 0x80110457; +pub const COMADMIN_E_CAT_INVALID_PARTITION_NAME: HRESULT = 0x80110458; +pub const COMADMIN_E_CAT_PARTITION_IN_USE: HRESULT = 0x80110459; +pub const COMADMIN_E_FILE_PARTITION_DUPLICATE_FILES: HRESULT = 0x8011045A; +pub const COMADMIN_E_CAT_IMPORTED_COMPONENTS_NOT_ALLOWED: HRESULT = 0x8011045B; +pub const COMADMIN_E_AMBIGUOUS_APPLICATION_NAME: HRESULT = 0x8011045C; +pub const COMADMIN_E_AMBIGUOUS_PARTITION_NAME: HRESULT = 0x8011045D; +pub const COMADMIN_E_REGDB_NOTINITIALIZED: HRESULT = 0x80110472; +pub const COMADMIN_E_REGDB_NOTOPEN: HRESULT = 0x80110473; +pub const COMADMIN_E_REGDB_SYSTEMERR: HRESULT = 0x80110474; +pub const COMADMIN_E_REGDB_ALREADYRUNNING: HRESULT = 0x80110475; +pub const COMADMIN_E_MIG_VERSIONNOTSUPPORTED: HRESULT = 0x80110480; +pub const COMADMIN_E_MIG_SCHEMANOTFOUND: HRESULT = 0x80110481; +pub const COMADMIN_E_CAT_BITNESSMISMATCH: HRESULT = 0x80110482; +pub const COMADMIN_E_CAT_UNACCEPTABLEBITNESS: HRESULT = 0x80110483; +pub const COMADMIN_E_CAT_WRONGAPPBITNESS: HRESULT = 0x80110484; +pub const COMADMIN_E_CAT_PAUSE_RESUME_NOT_SUPPORTED: HRESULT = 0x80110485; +pub const COMADMIN_E_CAT_SERVERFAULT: HRESULT = 0x80110486; +pub const COMQC_E_APPLICATION_NOT_QUEUED: HRESULT = 0x80110600; +pub const COMQC_E_NO_QUEUEABLE_INTERFACES: HRESULT = 0x80110601; +pub const COMQC_E_QUEUING_SERVICE_NOT_AVAILABLE: HRESULT = 0x80110602; +pub const COMQC_E_NO_IPERSISTSTREAM: HRESULT = 0x80110603; +pub const COMQC_E_BAD_MESSAGE: HRESULT = 0x80110604; +pub const COMQC_E_UNAUTHENTICATED: HRESULT = 0x80110605; +pub const COMQC_E_UNTRUSTED_ENQUEUER: HRESULT = 0x80110606; +pub const MSDTC_E_DUPLICATE_RESOURCE: HRESULT = 0x80110701; +pub const COMADMIN_E_OBJECT_PARENT_MISSING: HRESULT = 0x80110808; +pub const COMADMIN_E_OBJECT_DOES_NOT_EXIST: HRESULT = 0x80110809; +pub const COMADMIN_E_APP_NOT_RUNNING: HRESULT = 0x8011080A; +pub const COMADMIN_E_INVALID_PARTITION: HRESULT = 0x8011080B; +pub const COMADMIN_E_SVCAPP_NOT_POOLABLE_OR_RECYCLABLE: HRESULT = 0x8011080D; +pub const COMADMIN_E_USER_IN_SET: HRESULT = 0x8011080E; +pub const COMADMIN_E_CANTRECYCLELIBRARYAPPS: HRESULT = 0x8011080F; +pub const COMADMIN_E_CANTRECYCLESERVICEAPPS: HRESULT = 0x80110811; +pub const COMADMIN_E_PROCESSALREADYRECYCLED: HRESULT = 0x80110812; +pub const COMADMIN_E_PAUSEDPROCESSMAYNOTBERECYCLED: HRESULT = 0x80110813; +pub const COMADMIN_E_CANTMAKEINPROCSERVICE: HRESULT = 0x80110814; +pub const COMADMIN_E_PROGIDINUSEBYCLSID: HRESULT = 0x80110815; +pub const COMADMIN_E_DEFAULT_PARTITION_NOT_IN_SET: HRESULT = 0x80110816; +pub const COMADMIN_E_RECYCLEDPROCESSMAYNOTBEPAUSED: HRESULT = 0x80110817; +pub const COMADMIN_E_PARTITION_ACCESSDENIED: HRESULT = 0x80110818; +pub const COMADMIN_E_PARTITION_MSI_ONLY: HRESULT = 0x80110819; +pub const COMADMIN_E_LEGACYCOMPS_NOT_ALLOWED_IN_1_0_FORMAT: HRESULT = 0x8011081A; +pub const COMADMIN_E_LEGACYCOMPS_NOT_ALLOWED_IN_NONBASE_PARTITIONS: HRESULT + = 0x8011081B; +pub const COMADMIN_E_COMP_MOVE_SOURCE: HRESULT = 0x8011081C; +pub const COMADMIN_E_COMP_MOVE_DEST: HRESULT = 0x8011081D; +pub const COMADMIN_E_COMP_MOVE_PRIVATE: HRESULT = 0x8011081E; +pub const COMADMIN_E_BASEPARTITION_REQUIRED_IN_SET: HRESULT = 0x8011081F; +pub const COMADMIN_E_CANNOT_ALIAS_EVENTCLASS: HRESULT = 0x80110820; +pub const COMADMIN_E_PRIVATE_ACCESSDENIED: HRESULT = 0x80110821; +pub const COMADMIN_E_SAFERINVALID: HRESULT = 0x80110822; +pub const COMADMIN_E_REGISTRY_ACCESSDENIED: HRESULT = 0x80110823; +pub const COMADMIN_E_PARTITIONS_DISABLED: HRESULT = 0x80110824; +pub const WER_S_REPORT_DEBUG: HRESULT = 0x001B0000; +pub const WER_S_REPORT_UPLOADED: HRESULT = 0x001B0001; +pub const WER_S_REPORT_QUEUED: HRESULT = 0x001B0002; +pub const WER_S_DISABLED: HRESULT = 0x001B0003; +pub const WER_S_SUSPENDED_UPLOAD: HRESULT = 0x001B0004; +pub const WER_S_DISABLED_QUEUE: HRESULT = 0x001B0005; +pub const WER_S_DISABLED_ARCHIVE: HRESULT = 0x001B0006; +pub const WER_S_REPORT_ASYNC: HRESULT = 0x001B0007; +pub const WER_S_IGNORE_ASSERT_INSTANCE: HRESULT = 0x001B0008; +pub const WER_S_IGNORE_ALL_ASSERTS: HRESULT = 0x001B0009; +pub const WER_S_ASSERT_CONTINUE: HRESULT = 0x001B000A; +pub const WER_S_THROTTLED: HRESULT = 0x001B000B; +pub const WER_E_CRASH_FAILURE: HRESULT = 0x801B8000; +pub const WER_E_CANCELED: HRESULT = 0x801B8001; +pub const WER_E_NETWORK_FAILURE: HRESULT = 0x801B8002; +pub const WER_E_NOT_INITIALIZED: HRESULT = 0x801B8003; +pub const WER_E_ALREADY_REPORTING: HRESULT = 0x801B8004; +pub const WER_E_DUMP_THROTTLED: HRESULT = 0x801B8005; +pub const ERROR_FLT_IO_COMPLETE: HRESULT = 0x001F0001; +pub const ERROR_FLT_NO_HANDLER_DEFINED: HRESULT = 0x801F0001; +pub const ERROR_FLT_CONTEXT_ALREADY_DEFINED: HRESULT = 0x801F0002; +pub const ERROR_FLT_INVALID_ASYNCHRONOUS_REQUEST: HRESULT = 0x801F0003; +pub const ERROR_FLT_DISALLOW_FAST_IO: HRESULT = 0x801F0004; +pub const ERROR_FLT_INVALID_NAME_REQUEST: HRESULT = 0x801F0005; +pub const ERROR_FLT_NOT_SAFE_TO_POST_OPERATION: HRESULT = 0x801F0006; +pub const ERROR_FLT_NOT_INITIALIZED: HRESULT = 0x801F0007; +pub const ERROR_FLT_FILTER_NOT_READY: HRESULT = 0x801F0008; +pub const ERROR_FLT_POST_OPERATION_CLEANUP: HRESULT = 0x801F0009; +pub const ERROR_FLT_INTERNAL_ERROR: HRESULT = 0x801F000A; +pub const ERROR_FLT_DELETING_OBJECT: HRESULT = 0x801F000B; +pub const ERROR_FLT_MUST_BE_NONPAGED_POOL: HRESULT = 0x801F000C; +pub const ERROR_FLT_DUPLICATE_ENTRY: HRESULT = 0x801F000D; +pub const ERROR_FLT_CBDQ_DISABLED: HRESULT = 0x801F000E; +pub const ERROR_FLT_DO_NOT_ATTACH: HRESULT = 0x801F000F; +pub const ERROR_FLT_DO_NOT_DETACH: HRESULT = 0x801F0010; +pub const ERROR_FLT_INSTANCE_ALTITUDE_COLLISION: HRESULT = 0x801F0011; +pub const ERROR_FLT_INSTANCE_NAME_COLLISION: HRESULT = 0x801F0012; +pub const ERROR_FLT_FILTER_NOT_FOUND: HRESULT = 0x801F0013; +pub const ERROR_FLT_VOLUME_NOT_FOUND: HRESULT = 0x801F0014; +pub const ERROR_FLT_INSTANCE_NOT_FOUND: HRESULT = 0x801F0015; +pub const ERROR_FLT_CONTEXT_ALLOCATION_NOT_FOUND: HRESULT = 0x801F0016; +pub const ERROR_FLT_INVALID_CONTEXT_REGISTRATION: HRESULT = 0x801F0017; +pub const ERROR_FLT_NAME_CACHE_MISS: HRESULT = 0x801F0018; +pub const ERROR_FLT_NO_DEVICE_OBJECT: HRESULT = 0x801F0019; +pub const ERROR_FLT_VOLUME_ALREADY_MOUNTED: HRESULT = 0x801F001A; +pub const ERROR_FLT_ALREADY_ENLISTED: HRESULT = 0x801F001B; +pub const ERROR_FLT_CONTEXT_ALREADY_LINKED: HRESULT = 0x801F001C; +pub const ERROR_FLT_NO_WAITER_FOR_REPLY: HRESULT = 0x801F0020; +pub const ERROR_FLT_REGISTRATION_BUSY: HRESULT = 0x801F0023; +pub const ERROR_HUNG_DISPLAY_DRIVER_THREAD: HRESULT = 0x80260001; +pub const DWM_E_COMPOSITIONDISABLED: HRESULT = 0x80263001; +pub const DWM_E_REMOTING_NOT_SUPPORTED: HRESULT = 0x80263002; +pub const DWM_E_NO_REDIRECTION_SURFACE_AVAILABLE: HRESULT = 0x80263003; +pub const DWM_E_NOT_QUEUING_PRESENTS: HRESULT = 0x80263004; +pub const DWM_E_ADAPTER_NOT_FOUND: HRESULT = 0x80263005; +pub const DWM_S_GDI_REDIRECTION_SURFACE: HRESULT = 0x00263005; +pub const DWM_E_TEXTURE_TOO_LARGE: HRESULT = 0x80263007; +pub const ERROR_MONITOR_NO_DESCRIPTOR: HRESULT = 0x80261001; +pub const ERROR_MONITOR_UNKNOWN_DESCRIPTOR_FORMAT: HRESULT = 0x80261002; +pub const ERROR_MONITOR_INVALID_DESCRIPTOR_CHECKSUM: HRESULT = 0xC0261003; +pub const ERROR_MONITOR_INVALID_STANDARD_TIMING_BLOCK: HRESULT = 0xC0261004; +pub const ERROR_MONITOR_WMI_DATABLOCK_REGISTRATION_FAILED: HRESULT = 0xC0261005; +pub const ERROR_MONITOR_INVALID_SERIAL_NUMBER_MONDSC_BLOCK: HRESULT = 0xC0261006; +pub const ERROR_MONITOR_INVALID_USER_FRIENDLY_MONDSC_BLOCK: HRESULT = 0xC0261007; +pub const ERROR_MONITOR_NO_MORE_DESCRIPTOR_DATA: HRESULT = 0xC0261008; +pub const ERROR_MONITOR_INVALID_DETAILED_TIMING_BLOCK: HRESULT = 0xC0261009; +pub const ERROR_MONITOR_INVALID_MANUFACTURE_DATE: HRESULT = 0xC026100A; +pub const ERROR_GRAPHICS_NOT_EXCLUSIVE_MODE_OWNER: HRESULT = 0xC0262000; +pub const ERROR_GRAPHICS_INSUFFICIENT_DMA_BUFFER: HRESULT = 0xC0262001; +pub const ERROR_GRAPHICS_INVALID_DISPLAY_ADAPTER: HRESULT = 0xC0262002; +pub const ERROR_GRAPHICS_ADAPTER_WAS_RESET: HRESULT = 0xC0262003; +pub const ERROR_GRAPHICS_INVALID_DRIVER_MODEL: HRESULT = 0xC0262004; +pub const ERROR_GRAPHICS_PRESENT_MODE_CHANGED: HRESULT = 0xC0262005; +pub const ERROR_GRAPHICS_PRESENT_OCCLUDED: HRESULT = 0xC0262006; +pub const ERROR_GRAPHICS_PRESENT_DENIED: HRESULT = 0xC0262007; +pub const ERROR_GRAPHICS_CANNOTCOLORCONVERT: HRESULT = 0xC0262008; +pub const ERROR_GRAPHICS_DRIVER_MISMATCH: HRESULT = 0xC0262009; +pub const ERROR_GRAPHICS_PARTIAL_DATA_POPULATED: HRESULT = 0x4026200A; +pub const ERROR_GRAPHICS_PRESENT_REDIRECTION_DISABLED: HRESULT = 0xC026200B; +pub const ERROR_GRAPHICS_PRESENT_UNOCCLUDED: HRESULT = 0xC026200C; +pub const ERROR_GRAPHICS_WINDOWDC_NOT_AVAILABLE: HRESULT = 0xC026200D; +pub const ERROR_GRAPHICS_WINDOWLESS_PRESENT_DISABLED: HRESULT = 0xC026200E; +pub const ERROR_GRAPHICS_NO_VIDEO_MEMORY: HRESULT = 0xC0262100; +pub const ERROR_GRAPHICS_CANT_LOCK_MEMORY: HRESULT = 0xC0262101; +pub const ERROR_GRAPHICS_ALLOCATION_BUSY: HRESULT = 0xC0262102; +pub const ERROR_GRAPHICS_TOO_MANY_REFERENCES: HRESULT = 0xC0262103; +pub const ERROR_GRAPHICS_TRY_AGAIN_LATER: HRESULT = 0xC0262104; +pub const ERROR_GRAPHICS_TRY_AGAIN_NOW: HRESULT = 0xC0262105; +pub const ERROR_GRAPHICS_ALLOCATION_INVALID: HRESULT = 0xC0262106; +pub const ERROR_GRAPHICS_UNSWIZZLING_APERTURE_UNAVAILABLE: HRESULT = 0xC0262107; +pub const ERROR_GRAPHICS_UNSWIZZLING_APERTURE_UNSUPPORTED: HRESULT = 0xC0262108; +pub const ERROR_GRAPHICS_CANT_EVICT_PINNED_ALLOCATION: HRESULT = 0xC0262109; +pub const ERROR_GRAPHICS_INVALID_ALLOCATION_USAGE: HRESULT = 0xC0262110; +pub const ERROR_GRAPHICS_CANT_RENDER_LOCKED_ALLOCATION: HRESULT = 0xC0262111; +pub const ERROR_GRAPHICS_ALLOCATION_CLOSED: HRESULT = 0xC0262112; +pub const ERROR_GRAPHICS_INVALID_ALLOCATION_INSTANCE: HRESULT = 0xC0262113; +pub const ERROR_GRAPHICS_INVALID_ALLOCATION_HANDLE: HRESULT = 0xC0262114; +pub const ERROR_GRAPHICS_WRONG_ALLOCATION_DEVICE: HRESULT = 0xC0262115; +pub const ERROR_GRAPHICS_ALLOCATION_CONTENT_LOST: HRESULT = 0xC0262116; +pub const ERROR_GRAPHICS_GPU_EXCEPTION_ON_DEVICE: HRESULT = 0xC0262200; +pub const ERROR_GRAPHICS_SKIP_ALLOCATION_PREPARATION: HRESULT = 0x40262201; +pub const ERROR_GRAPHICS_INVALID_VIDPN_TOPOLOGY: HRESULT = 0xC0262300; +pub const ERROR_GRAPHICS_VIDPN_TOPOLOGY_NOT_SUPPORTED: HRESULT = 0xC0262301; +pub const ERROR_GRAPHICS_VIDPN_TOPOLOGY_CURRENTLY_NOT_SUPPORTED: HRESULT + = 0xC0262302; +pub const ERROR_GRAPHICS_INVALID_VIDPN: HRESULT = 0xC0262303; +pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE: HRESULT = 0xC0262304; +pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET: HRESULT = 0xC0262305; +pub const ERROR_GRAPHICS_VIDPN_MODALITY_NOT_SUPPORTED: HRESULT = 0xC0262306; +pub const ERROR_GRAPHICS_MODE_NOT_PINNED: HRESULT = 0x00262307; +pub const ERROR_GRAPHICS_INVALID_VIDPN_SOURCEMODESET: HRESULT = 0xC0262308; +pub const ERROR_GRAPHICS_INVALID_VIDPN_TARGETMODESET: HRESULT = 0xC0262309; +pub const ERROR_GRAPHICS_INVALID_FREQUENCY: HRESULT = 0xC026230A; +pub const ERROR_GRAPHICS_INVALID_ACTIVE_REGION: HRESULT = 0xC026230B; +pub const ERROR_GRAPHICS_INVALID_TOTAL_REGION: HRESULT = 0xC026230C; +pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE_MODE: HRESULT = 0xC0262310; +pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET_MODE: HRESULT = 0xC0262311; +pub const ERROR_GRAPHICS_PINNED_MODE_MUST_REMAIN_IN_SET: HRESULT = 0xC0262312; +pub const ERROR_GRAPHICS_PATH_ALREADY_IN_TOPOLOGY: HRESULT = 0xC0262313; +pub const ERROR_GRAPHICS_MODE_ALREADY_IN_MODESET: HRESULT = 0xC0262314; +pub const ERROR_GRAPHICS_INVALID_VIDEOPRESENTSOURCESET: HRESULT = 0xC0262315; +pub const ERROR_GRAPHICS_INVALID_VIDEOPRESENTTARGETSET: HRESULT = 0xC0262316; +pub const ERROR_GRAPHICS_SOURCE_ALREADY_IN_SET: HRESULT = 0xC0262317; +pub const ERROR_GRAPHICS_TARGET_ALREADY_IN_SET: HRESULT = 0xC0262318; +pub const ERROR_GRAPHICS_INVALID_VIDPN_PRESENT_PATH: HRESULT = 0xC0262319; +pub const ERROR_GRAPHICS_NO_RECOMMENDED_VIDPN_TOPOLOGY: HRESULT = 0xC026231A; +pub const ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGESET: HRESULT = 0xC026231B; +pub const ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE: HRESULT = 0xC026231C; +pub const ERROR_GRAPHICS_FREQUENCYRANGE_NOT_IN_SET: HRESULT = 0xC026231D; +pub const ERROR_GRAPHICS_NO_PREFERRED_MODE: HRESULT = 0x0026231E; +pub const ERROR_GRAPHICS_FREQUENCYRANGE_ALREADY_IN_SET: HRESULT = 0xC026231F; +pub const ERROR_GRAPHICS_STALE_MODESET: HRESULT = 0xC0262320; +pub const ERROR_GRAPHICS_INVALID_MONITOR_SOURCEMODESET: HRESULT = 0xC0262321; +pub const ERROR_GRAPHICS_INVALID_MONITOR_SOURCE_MODE: HRESULT = 0xC0262322; +pub const ERROR_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN: HRESULT = 0xC0262323; +pub const ERROR_GRAPHICS_MODE_ID_MUST_BE_UNIQUE: HRESULT = 0xC0262324; +pub const ERROR_GRAPHICS_EMPTY_ADAPTER_MONITOR_MODE_SUPPORT_INTERSECTION: HRESULT + = 0xC0262325; +pub const ERROR_GRAPHICS_VIDEO_PRESENT_TARGETS_LESS_THAN_SOURCES: HRESULT + = 0xC0262326; +pub const ERROR_GRAPHICS_PATH_NOT_IN_TOPOLOGY: HRESULT = 0xC0262327; +pub const ERROR_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_SOURCE: HRESULT = 0xC0262328; +pub const ERROR_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_TARGET: HRESULT = 0xC0262329; +pub const ERROR_GRAPHICS_INVALID_MONITORDESCRIPTORSET: HRESULT = 0xC026232A; +pub const ERROR_GRAPHICS_INVALID_MONITORDESCRIPTOR: HRESULT = 0xC026232B; +pub const ERROR_GRAPHICS_MONITORDESCRIPTOR_NOT_IN_SET: HRESULT = 0xC026232C; +pub const ERROR_GRAPHICS_MONITORDESCRIPTOR_ALREADY_IN_SET: HRESULT = 0xC026232D; +pub const ERROR_GRAPHICS_MONITORDESCRIPTOR_ID_MUST_BE_UNIQUE: HRESULT = 0xC026232E; +pub const ERROR_GRAPHICS_INVALID_VIDPN_TARGET_SUBSET_TYPE: HRESULT = 0xC026232F; +pub const ERROR_GRAPHICS_RESOURCES_NOT_RELATED: HRESULT = 0xC0262330; +pub const ERROR_GRAPHICS_SOURCE_ID_MUST_BE_UNIQUE: HRESULT = 0xC0262331; +pub const ERROR_GRAPHICS_TARGET_ID_MUST_BE_UNIQUE: HRESULT = 0xC0262332; +pub const ERROR_GRAPHICS_NO_AVAILABLE_VIDPN_TARGET: HRESULT = 0xC0262333; +pub const ERROR_GRAPHICS_MONITOR_COULD_NOT_BE_ASSOCIATED_WITH_ADAPTER: HRESULT + = 0xC0262334; +pub const ERROR_GRAPHICS_NO_VIDPNMGR: HRESULT = 0xC0262335; +pub const ERROR_GRAPHICS_NO_ACTIVE_VIDPN: HRESULT = 0xC0262336; +pub const ERROR_GRAPHICS_STALE_VIDPN_TOPOLOGY: HRESULT = 0xC0262337; +pub const ERROR_GRAPHICS_MONITOR_NOT_CONNECTED: HRESULT = 0xC0262338; +pub const ERROR_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY: HRESULT = 0xC0262339; +pub const ERROR_GRAPHICS_INVALID_PRIMARYSURFACE_SIZE: HRESULT = 0xC026233A; +pub const ERROR_GRAPHICS_INVALID_VISIBLEREGION_SIZE: HRESULT = 0xC026233B; +pub const ERROR_GRAPHICS_INVALID_STRIDE: HRESULT = 0xC026233C; +pub const ERROR_GRAPHICS_INVALID_PIXELFORMAT: HRESULT = 0xC026233D; +pub const ERROR_GRAPHICS_INVALID_COLORBASIS: HRESULT = 0xC026233E; +pub const ERROR_GRAPHICS_INVALID_PIXELVALUEACCESSMODE: HRESULT = 0xC026233F; +pub const ERROR_GRAPHICS_TARGET_NOT_IN_TOPOLOGY: HRESULT = 0xC0262340; +pub const ERROR_GRAPHICS_NO_DISPLAY_MODE_MANAGEMENT_SUPPORT: HRESULT = 0xC0262341; +pub const ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE: HRESULT = 0xC0262342; +pub const ERROR_GRAPHICS_CANT_ACCESS_ACTIVE_VIDPN: HRESULT = 0xC0262343; +pub const ERROR_GRAPHICS_INVALID_PATH_IMPORTANCE_ORDINAL: HRESULT = 0xC0262344; +pub const ERROR_GRAPHICS_INVALID_PATH_CONTENT_GEOMETRY_TRANSFORMATION: HRESULT + = 0xC0262345; +pub const ERROR_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_SUPPORTED: HRESULT + = 0xC0262346; +pub const ERROR_GRAPHICS_INVALID_GAMMA_RAMP: HRESULT = 0xC0262347; +pub const ERROR_GRAPHICS_GAMMA_RAMP_NOT_SUPPORTED: HRESULT = 0xC0262348; +pub const ERROR_GRAPHICS_MULTISAMPLING_NOT_SUPPORTED: HRESULT = 0xC0262349; +pub const ERROR_GRAPHICS_MODE_NOT_IN_MODESET: HRESULT = 0xC026234A; +pub const ERROR_GRAPHICS_DATASET_IS_EMPTY: HRESULT = 0x0026234B; +pub const ERROR_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET: HRESULT = 0x0026234C; +pub const ERROR_GRAPHICS_INVALID_VIDPN_TOPOLOGY_RECOMMENDATION_REASON: HRESULT + = 0xC026234D; +pub const ERROR_GRAPHICS_INVALID_PATH_CONTENT_TYPE: HRESULT = 0xC026234E; +pub const ERROR_GRAPHICS_INVALID_COPYPROTECTION_TYPE: HRESULT = 0xC026234F; +pub const ERROR_GRAPHICS_UNASSIGNED_MODESET_ALREADY_EXISTS: HRESULT = 0xC0262350; +pub const ERROR_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_PINNED: HRESULT = 0x00262351; +pub const ERROR_GRAPHICS_INVALID_SCANLINE_ORDERING: HRESULT = 0xC0262352; +pub const ERROR_GRAPHICS_TOPOLOGY_CHANGES_NOT_ALLOWED: HRESULT = 0xC0262353; +pub const ERROR_GRAPHICS_NO_AVAILABLE_IMPORTANCE_ORDINALS: HRESULT = 0xC0262354; +pub const ERROR_GRAPHICS_INCOMPATIBLE_PRIVATE_FORMAT: HRESULT = 0xC0262355; +pub const ERROR_GRAPHICS_INVALID_MODE_PRUNING_ALGORITHM: HRESULT = 0xC0262356; +pub const ERROR_GRAPHICS_INVALID_MONITOR_CAPABILITY_ORIGIN: HRESULT = 0xC0262357; +pub const ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE_CONSTRAINT: HRESULT + = 0xC0262358; +pub const ERROR_GRAPHICS_MAX_NUM_PATHS_REACHED: HRESULT = 0xC0262359; +pub const ERROR_GRAPHICS_CANCEL_VIDPN_TOPOLOGY_AUGMENTATION: HRESULT = 0xC026235A; +pub const ERROR_GRAPHICS_INVALID_CLIENT_TYPE: HRESULT = 0xC026235B; +pub const ERROR_GRAPHICS_CLIENTVIDPN_NOT_SET: HRESULT = 0xC026235C; +pub const ERROR_GRAPHICS_SPECIFIED_CHILD_ALREADY_CONNECTED: HRESULT = 0xC0262400; +pub const ERROR_GRAPHICS_CHILD_DESCRIPTOR_NOT_SUPPORTED: HRESULT = 0xC0262401; +pub const ERROR_GRAPHICS_UNKNOWN_CHILD_STATUS: HRESULT = 0x4026242F; +pub const ERROR_GRAPHICS_NOT_A_LINKED_ADAPTER: HRESULT = 0xC0262430; +pub const ERROR_GRAPHICS_LEADLINK_NOT_ENUMERATED: HRESULT = 0xC0262431; +pub const ERROR_GRAPHICS_CHAINLINKS_NOT_ENUMERATED: HRESULT = 0xC0262432; +pub const ERROR_GRAPHICS_ADAPTER_CHAIN_NOT_READY: HRESULT = 0xC0262433; +pub const ERROR_GRAPHICS_CHAINLINKS_NOT_STARTED: HRESULT = 0xC0262434; +pub const ERROR_GRAPHICS_CHAINLINKS_NOT_POWERED_ON: HRESULT = 0xC0262435; +pub const ERROR_GRAPHICS_INCONSISTENT_DEVICE_LINK_STATE: HRESULT = 0xC0262436; +pub const ERROR_GRAPHICS_LEADLINK_START_DEFERRED: HRESULT = 0x40262437; +pub const ERROR_GRAPHICS_NOT_POST_DEVICE_DRIVER: HRESULT = 0xC0262438; +pub const ERROR_GRAPHICS_POLLING_TOO_FREQUENTLY: HRESULT = 0x40262439; +pub const ERROR_GRAPHICS_START_DEFERRED: HRESULT = 0x4026243A; +pub const ERROR_GRAPHICS_ADAPTER_ACCESS_NOT_EXCLUDED: HRESULT = 0xC026243B; +pub const ERROR_GRAPHICS_OPM_NOT_SUPPORTED: HRESULT = 0xC0262500; +pub const ERROR_GRAPHICS_COPP_NOT_SUPPORTED: HRESULT = 0xC0262501; +pub const ERROR_GRAPHICS_UAB_NOT_SUPPORTED: HRESULT = 0xC0262502; +pub const ERROR_GRAPHICS_OPM_INVALID_ENCRYPTED_PARAMETERS: HRESULT = 0xC0262503; +pub const ERROR_GRAPHICS_OPM_NO_VIDEO_OUTPUTS_EXIST: HRESULT = 0xC0262505; +pub const ERROR_GRAPHICS_OPM_INTERNAL_ERROR: HRESULT = 0xC026250B; +pub const ERROR_GRAPHICS_OPM_INVALID_HANDLE: HRESULT = 0xC026250C; +pub const ERROR_GRAPHICS_PVP_INVALID_CERTIFICATE_LENGTH: HRESULT = 0xC026250E; +pub const ERROR_GRAPHICS_OPM_SPANNING_MODE_ENABLED: HRESULT = 0xC026250F; +pub const ERROR_GRAPHICS_OPM_THEATER_MODE_ENABLED: HRESULT = 0xC0262510; +pub const ERROR_GRAPHICS_PVP_HFS_FAILED: HRESULT = 0xC0262511; +pub const ERROR_GRAPHICS_OPM_INVALID_SRM: HRESULT = 0xC0262512; +pub const ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_HDCP: HRESULT = 0xC0262513; +pub const ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_ACP: HRESULT = 0xC0262514; +pub const ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_CGMSA: HRESULT = 0xC0262515; +pub const ERROR_GRAPHICS_OPM_HDCP_SRM_NEVER_SET: HRESULT = 0xC0262516; +pub const ERROR_GRAPHICS_OPM_RESOLUTION_TOO_HIGH: HRESULT = 0xC0262517; +pub const ERROR_GRAPHICS_OPM_ALL_HDCP_HARDWARE_ALREADY_IN_USE: HRESULT = 0xC0262518; +pub const ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_NO_LONGER_EXISTS: HRESULT = 0xC026251A; +pub const ERROR_GRAPHICS_OPM_SESSION_TYPE_CHANGE_IN_PROGRESS: HRESULT = 0xC026251B; +pub const ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_DOES_NOT_HAVE_COPP_SEMANTICS: HRESULT + = 0xC026251C; +pub const ERROR_GRAPHICS_OPM_INVALID_INFORMATION_REQUEST: HRESULT = 0xC026251D; +pub const ERROR_GRAPHICS_OPM_DRIVER_INTERNAL_ERROR: HRESULT = 0xC026251E; +pub const ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_DOES_NOT_HAVE_OPM_SEMANTICS: HRESULT + = 0xC026251F; +pub const ERROR_GRAPHICS_OPM_SIGNALING_NOT_SUPPORTED: HRESULT = 0xC0262520; +pub const ERROR_GRAPHICS_OPM_INVALID_CONFIGURATION_REQUEST: HRESULT = 0xC0262521; +pub const ERROR_GRAPHICS_I2C_NOT_SUPPORTED: HRESULT = 0xC0262580; +pub const ERROR_GRAPHICS_I2C_DEVICE_DOES_NOT_EXIST: HRESULT = 0xC0262581; +pub const ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA: HRESULT = 0xC0262582; +pub const ERROR_GRAPHICS_I2C_ERROR_RECEIVING_DATA: HRESULT = 0xC0262583; +pub const ERROR_GRAPHICS_DDCCI_VCP_NOT_SUPPORTED: HRESULT = 0xC0262584; +pub const ERROR_GRAPHICS_DDCCI_INVALID_DATA: HRESULT = 0xC0262585; +pub const ERROR_GRAPHICS_DDCCI_MONITOR_RETURNED_INVALID_TIMING_STATUS_BYTE: HRESULT + = 0xC0262586; +pub const ERROR_GRAPHICS_MCA_INVALID_CAPABILITIES_STRING: HRESULT = 0xC0262587; +pub const ERROR_GRAPHICS_MCA_INTERNAL_ERROR: HRESULT = 0xC0262588; +pub const ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_COMMAND: HRESULT = 0xC0262589; +pub const ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_LENGTH: HRESULT = 0xC026258A; +pub const ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_CHECKSUM: HRESULT = 0xC026258B; +pub const ERROR_GRAPHICS_INVALID_PHYSICAL_MONITOR_HANDLE: HRESULT = 0xC026258C; +pub const ERROR_GRAPHICS_MONITOR_NO_LONGER_EXISTS: HRESULT = 0xC026258D; +pub const ERROR_GRAPHICS_DDCCI_CURRENT_CURRENT_VALUE_GREATER_THAN_MAXIMUM_VALUE: HRESULT + = 0xC02625D8; +pub const ERROR_GRAPHICS_MCA_INVALID_VCP_VERSION: HRESULT = 0xC02625D9; +pub const ERROR_GRAPHICS_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION: HRESULT + = 0xC02625DA; +pub const ERROR_GRAPHICS_MCA_MCCS_VERSION_MISMATCH: HRESULT = 0xC02625DB; +pub const ERROR_GRAPHICS_MCA_UNSUPPORTED_MCCS_VERSION: HRESULT = 0xC02625DC; +pub const ERROR_GRAPHICS_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED: HRESULT = 0xC02625DE; +pub const ERROR_GRAPHICS_MCA_UNSUPPORTED_COLOR_TEMPERATURE: HRESULT = 0xC02625DF; +pub const ERROR_GRAPHICS_ONLY_CONSOLE_SESSION_SUPPORTED: HRESULT = 0xC02625E0; +pub const ERROR_GRAPHICS_NO_DISPLAY_DEVICE_CORRESPONDS_TO_NAME: HRESULT = 0xC02625E1; +pub const ERROR_GRAPHICS_DISPLAY_DEVICE_NOT_ATTACHED_TO_DESKTOP: HRESULT + = 0xC02625E2; +pub const ERROR_GRAPHICS_MIRRORING_DEVICES_NOT_SUPPORTED: HRESULT = 0xC02625E3; +pub const ERROR_GRAPHICS_INVALID_POINTER: HRESULT = 0xC02625E4; +pub const ERROR_GRAPHICS_NO_MONITORS_CORRESPOND_TO_DISPLAY_DEVICE: HRESULT + = 0xC02625E5; +pub const ERROR_GRAPHICS_PARAMETER_ARRAY_TOO_SMALL: HRESULT = 0xC02625E6; +pub const ERROR_GRAPHICS_INTERNAL_ERROR: HRESULT = 0xC02625E7; +pub const ERROR_GRAPHICS_SESSION_TYPE_CHANGE_IN_PROGRESS: HRESULT = 0xC02605E8; +pub const NAP_E_INVALID_PACKET: HRESULT = 0x80270001; +pub const NAP_E_MISSING_SOH: HRESULT = 0x80270002; +pub const NAP_E_CONFLICTING_ID: HRESULT = 0x80270003; +pub const NAP_E_NO_CACHED_SOH: HRESULT = 0x80270004; +pub const NAP_E_STILL_BOUND: HRESULT = 0x80270005; +pub const NAP_E_NOT_REGISTERED: HRESULT = 0x80270006; +pub const NAP_E_NOT_INITIALIZED: HRESULT = 0x80270007; +pub const NAP_E_MISMATCHED_ID: HRESULT = 0x80270008; +pub const NAP_E_NOT_PENDING: HRESULT = 0x80270009; +pub const NAP_E_ID_NOT_FOUND: HRESULT = 0x8027000A; +pub const NAP_E_MAXSIZE_TOO_SMALL: HRESULT = 0x8027000B; +pub const NAP_E_SERVICE_NOT_RUNNING: HRESULT = 0x8027000C; +pub const NAP_S_CERT_ALREADY_PRESENT: HRESULT = 0x0027000D; +pub const NAP_E_ENTITY_DISABLED: HRESULT = 0x8027000E; +pub const NAP_E_NETSH_GROUPPOLICY_ERROR: HRESULT = 0x8027000F; +pub const NAP_E_TOO_MANY_CALLS: HRESULT = 0x80270010; +pub const NAP_E_SHV_CONFIG_EXISTED: HRESULT = 0x80270011; +pub const NAP_E_SHV_CONFIG_NOT_FOUND: HRESULT = 0x80270012; +pub const NAP_E_SHV_TIMEOUT: HRESULT = 0x80270013; +pub const TPM_E_ERROR_MASK: HRESULT = 0x80280000; +pub const TPM_E_AUTHFAIL: HRESULT = 0x80280001; +pub const TPM_E_BADINDEX: HRESULT = 0x80280002; +pub const TPM_E_BAD_PARAMETER: HRESULT = 0x80280003; +pub const TPM_E_AUDITFAILURE: HRESULT = 0x80280004; +pub const TPM_E_CLEAR_DISABLED: HRESULT = 0x80280005; +pub const TPM_E_DEACTIVATED: HRESULT = 0x80280006; +pub const TPM_E_DISABLED: HRESULT = 0x80280007; +pub const TPM_E_DISABLED_CMD: HRESULT = 0x80280008; +pub const TPM_E_FAIL: HRESULT = 0x80280009; +pub const TPM_E_BAD_ORDINAL: HRESULT = 0x8028000A; +pub const TPM_E_INSTALL_DISABLED: HRESULT = 0x8028000B; +pub const TPM_E_INVALID_KEYHANDLE: HRESULT = 0x8028000C; +pub const TPM_E_KEYNOTFOUND: HRESULT = 0x8028000D; +pub const TPM_E_INAPPROPRIATE_ENC: HRESULT = 0x8028000E; +pub const TPM_E_MIGRATEFAIL: HRESULT = 0x8028000F; +pub const TPM_E_INVALID_PCR_INFO: HRESULT = 0x80280010; +pub const TPM_E_NOSPACE: HRESULT = 0x80280011; +pub const TPM_E_NOSRK: HRESULT = 0x80280012; +pub const TPM_E_NOTSEALED_BLOB: HRESULT = 0x80280013; +pub const TPM_E_OWNER_SET: HRESULT = 0x80280014; +pub const TPM_E_RESOURCES: HRESULT = 0x80280015; +pub const TPM_E_SHORTRANDOM: HRESULT = 0x80280016; +pub const TPM_E_SIZE: HRESULT = 0x80280017; +pub const TPM_E_WRONGPCRVAL: HRESULT = 0x80280018; +pub const TPM_E_BAD_PARAM_SIZE: HRESULT = 0x80280019; +pub const TPM_E_SHA_THREAD: HRESULT = 0x8028001A; +pub const TPM_E_SHA_ERROR: HRESULT = 0x8028001B; +pub const TPM_E_FAILEDSELFTEST: HRESULT = 0x8028001C; +pub const TPM_E_AUTH2FAIL: HRESULT = 0x8028001D; +pub const TPM_E_BADTAG: HRESULT = 0x8028001E; +pub const TPM_E_IOERROR: HRESULT = 0x8028001F; +pub const TPM_E_ENCRYPT_ERROR: HRESULT = 0x80280020; +pub const TPM_E_DECRYPT_ERROR: HRESULT = 0x80280021; +pub const TPM_E_INVALID_AUTHHANDLE: HRESULT = 0x80280022; +pub const TPM_E_NO_ENDORSEMENT: HRESULT = 0x80280023; +pub const TPM_E_INVALID_KEYUSAGE: HRESULT = 0x80280024; +pub const TPM_E_WRONG_ENTITYTYPE: HRESULT = 0x80280025; +pub const TPM_E_INVALID_POSTINIT: HRESULT = 0x80280026; +pub const TPM_E_INAPPROPRIATE_SIG: HRESULT = 0x80280027; +pub const TPM_E_BAD_KEY_PROPERTY: HRESULT = 0x80280028; +pub const TPM_E_BAD_MIGRATION: HRESULT = 0x80280029; +pub const TPM_E_BAD_SCHEME: HRESULT = 0x8028002A; +pub const TPM_E_BAD_DATASIZE: HRESULT = 0x8028002B; +pub const TPM_E_BAD_MODE: HRESULT = 0x8028002C; +pub const TPM_E_BAD_PRESENCE: HRESULT = 0x8028002D; +pub const TPM_E_BAD_VERSION: HRESULT = 0x8028002E; +pub const TPM_E_NO_WRAP_TRANSPORT: HRESULT = 0x8028002F; +pub const TPM_E_AUDITFAIL_UNSUCCESSFUL: HRESULT = 0x80280030; +pub const TPM_E_AUDITFAIL_SUCCESSFUL: HRESULT = 0x80280031; +pub const TPM_E_NOTRESETABLE: HRESULT = 0x80280032; +pub const TPM_E_NOTLOCAL: HRESULT = 0x80280033; +pub const TPM_E_BAD_TYPE: HRESULT = 0x80280034; +pub const TPM_E_INVALID_RESOURCE: HRESULT = 0x80280035; +pub const TPM_E_NOTFIPS: HRESULT = 0x80280036; +pub const TPM_E_INVALID_FAMILY: HRESULT = 0x80280037; +pub const TPM_E_NO_NV_PERMISSION: HRESULT = 0x80280038; +pub const TPM_E_REQUIRES_SIGN: HRESULT = 0x80280039; +pub const TPM_E_KEY_NOTSUPPORTED: HRESULT = 0x8028003A; +pub const TPM_E_AUTH_CONFLICT: HRESULT = 0x8028003B; +pub const TPM_E_AREA_LOCKED: HRESULT = 0x8028003C; +pub const TPM_E_BAD_LOCALITY: HRESULT = 0x8028003D; +pub const TPM_E_READ_ONLY: HRESULT = 0x8028003E; +pub const TPM_E_PER_NOWRITE: HRESULT = 0x8028003F; +pub const TPM_E_FAMILYCOUNT: HRESULT = 0x80280040; +pub const TPM_E_WRITE_LOCKED: HRESULT = 0x80280041; +pub const TPM_E_BAD_ATTRIBUTES: HRESULT = 0x80280042; +pub const TPM_E_INVALID_STRUCTURE: HRESULT = 0x80280043; +pub const TPM_E_KEY_OWNER_CONTROL: HRESULT = 0x80280044; +pub const TPM_E_BAD_COUNTER: HRESULT = 0x80280045; +pub const TPM_E_NOT_FULLWRITE: HRESULT = 0x80280046; +pub const TPM_E_CONTEXT_GAP: HRESULT = 0x80280047; +pub const TPM_E_MAXNVWRITES: HRESULT = 0x80280048; +pub const TPM_E_NOOPERATOR: HRESULT = 0x80280049; +pub const TPM_E_RESOURCEMISSING: HRESULT = 0x8028004A; +pub const TPM_E_DELEGATE_LOCK: HRESULT = 0x8028004B; +pub const TPM_E_DELEGATE_FAMILY: HRESULT = 0x8028004C; +pub const TPM_E_DELEGATE_ADMIN: HRESULT = 0x8028004D; +pub const TPM_E_TRANSPORT_NOTEXCLUSIVE: HRESULT = 0x8028004E; +pub const TPM_E_OWNER_CONTROL: HRESULT = 0x8028004F; +pub const TPM_E_DAA_RESOURCES: HRESULT = 0x80280050; +pub const TPM_E_DAA_INPUT_DATA0: HRESULT = 0x80280051; +pub const TPM_E_DAA_INPUT_DATA1: HRESULT = 0x80280052; +pub const TPM_E_DAA_ISSUER_SETTINGS: HRESULT = 0x80280053; +pub const TPM_E_DAA_TPM_SETTINGS: HRESULT = 0x80280054; +pub const TPM_E_DAA_STAGE: HRESULT = 0x80280055; +pub const TPM_E_DAA_ISSUER_VALIDITY: HRESULT = 0x80280056; +pub const TPM_E_DAA_WRONG_W: HRESULT = 0x80280057; +pub const TPM_E_BAD_HANDLE: HRESULT = 0x80280058; +pub const TPM_E_BAD_DELEGATE: HRESULT = 0x80280059; +pub const TPM_E_BADCONTEXT: HRESULT = 0x8028005A; +pub const TPM_E_TOOMANYCONTEXTS: HRESULT = 0x8028005B; +pub const TPM_E_MA_TICKET_SIGNATURE: HRESULT = 0x8028005C; +pub const TPM_E_MA_DESTINATION: HRESULT = 0x8028005D; +pub const TPM_E_MA_SOURCE: HRESULT = 0x8028005E; +pub const TPM_E_MA_AUTHORITY: HRESULT = 0x8028005F; +pub const TPM_E_PERMANENTEK: HRESULT = 0x80280061; +pub const TPM_E_BAD_SIGNATURE: HRESULT = 0x80280062; +pub const TPM_E_NOCONTEXTSPACE: HRESULT = 0x80280063; +pub const TPM_E_COMMAND_BLOCKED: HRESULT = 0x80280400; +pub const TPM_E_INVALID_HANDLE: HRESULT = 0x80280401; +pub const TPM_E_DUPLICATE_VHANDLE: HRESULT = 0x80280402; +pub const TPM_E_EMBEDDED_COMMAND_BLOCKED: HRESULT = 0x80280403; +pub const TPM_E_EMBEDDED_COMMAND_UNSUPPORTED: HRESULT = 0x80280404; +pub const TPM_E_RETRY: HRESULT = 0x80280800; +pub const TPM_E_NEEDS_SELFTEST: HRESULT = 0x80280801; +pub const TPM_E_DOING_SELFTEST: HRESULT = 0x80280802; +pub const TPM_E_DEFEND_LOCK_RUNNING: HRESULT = 0x80280803; +pub const TBS_E_INTERNAL_ERROR: HRESULT = 0x80284001; +pub const TBS_E_BAD_PARAMETER: HRESULT = 0x80284002; +pub const TBS_E_INVALID_OUTPUT_POINTER: HRESULT = 0x80284003; +pub const TBS_E_INVALID_CONTEXT: HRESULT = 0x80284004; +pub const TBS_E_INSUFFICIENT_BUFFER: HRESULT = 0x80284005; +pub const TBS_E_IOERROR: HRESULT = 0x80284006; +pub const TBS_E_INVALID_CONTEXT_PARAM: HRESULT = 0x80284007; +pub const TBS_E_SERVICE_NOT_RUNNING: HRESULT = 0x80284008; +pub const TBS_E_TOO_MANY_TBS_CONTEXTS: HRESULT = 0x80284009; +pub const TBS_E_TOO_MANY_RESOURCES: HRESULT = 0x8028400A; +pub const TBS_E_SERVICE_START_PENDING: HRESULT = 0x8028400B; +pub const TBS_E_PPI_NOT_SUPPORTED: HRESULT = 0x8028400C; +pub const TBS_E_COMMAND_CANCELED: HRESULT = 0x8028400D; +pub const TBS_E_BUFFER_TOO_LARGE: HRESULT = 0x8028400E; +pub const TBS_E_TPM_NOT_FOUND: HRESULT = 0x8028400F; +pub const TBS_E_SERVICE_DISABLED: HRESULT = 0x80284010; +pub const TBS_E_NO_EVENT_LOG: HRESULT = 0x80284011; +pub const TBS_E_ACCESS_DENIED: HRESULT = 0x80284012; +pub const TBS_E_PROVISIONING_NOT_ALLOWED: HRESULT = 0x80284013; +pub const TBS_E_PPI_FUNCTION_UNSUPPORTED: HRESULT = 0x80284014; +pub const TBS_E_OWNERAUTH_NOT_FOUND: HRESULT = 0x80284015; +pub const TBS_E_PROVISIONING_INCOMPLETE: HRESULT = 0x80284016; +pub const TPMAPI_E_INVALID_STATE: HRESULT = 0x80290100; +pub const TPMAPI_E_NOT_ENOUGH_DATA: HRESULT = 0x80290101; +pub const TPMAPI_E_TOO_MUCH_DATA: HRESULT = 0x80290102; +pub const TPMAPI_E_INVALID_OUTPUT_POINTER: HRESULT = 0x80290103; +pub const TPMAPI_E_INVALID_PARAMETER: HRESULT = 0x80290104; +pub const TPMAPI_E_OUT_OF_MEMORY: HRESULT = 0x80290105; +pub const TPMAPI_E_BUFFER_TOO_SMALL: HRESULT = 0x80290106; +pub const TPMAPI_E_INTERNAL_ERROR: HRESULT = 0x80290107; +pub const TPMAPI_E_ACCESS_DENIED: HRESULT = 0x80290108; +pub const TPMAPI_E_AUTHORIZATION_FAILED: HRESULT = 0x80290109; +pub const TPMAPI_E_INVALID_CONTEXT_HANDLE: HRESULT = 0x8029010A; +pub const TPMAPI_E_TBS_COMMUNICATION_ERROR: HRESULT = 0x8029010B; +pub const TPMAPI_E_TPM_COMMAND_ERROR: HRESULT = 0x8029010C; +pub const TPMAPI_E_MESSAGE_TOO_LARGE: HRESULT = 0x8029010D; +pub const TPMAPI_E_INVALID_ENCODING: HRESULT = 0x8029010E; +pub const TPMAPI_E_INVALID_KEY_SIZE: HRESULT = 0x8029010F; +pub const TPMAPI_E_ENCRYPTION_FAILED: HRESULT = 0x80290110; +pub const TPMAPI_E_INVALID_KEY_PARAMS: HRESULT = 0x80290111; +pub const TPMAPI_E_INVALID_MIGRATION_AUTHORIZATION_BLOB: HRESULT = 0x80290112; +pub const TPMAPI_E_INVALID_PCR_INDEX: HRESULT = 0x80290113; +pub const TPMAPI_E_INVALID_DELEGATE_BLOB: HRESULT = 0x80290114; +pub const TPMAPI_E_INVALID_CONTEXT_PARAMS: HRESULT = 0x80290115; +pub const TPMAPI_E_INVALID_KEY_BLOB: HRESULT = 0x80290116; +pub const TPMAPI_E_INVALID_PCR_DATA: HRESULT = 0x80290117; +pub const TPMAPI_E_INVALID_OWNER_AUTH: HRESULT = 0x80290118; +pub const TPMAPI_E_FIPS_RNG_CHECK_FAILED: HRESULT = 0x80290119; +pub const TPMAPI_E_EMPTY_TCG_LOG: HRESULT = 0x8029011A; +pub const TPMAPI_E_INVALID_TCG_LOG_ENTRY: HRESULT = 0x8029011B; +pub const TPMAPI_E_TCG_SEPARATOR_ABSENT: HRESULT = 0x8029011C; +pub const TPMAPI_E_TCG_INVALID_DIGEST_ENTRY: HRESULT = 0x8029011D; +pub const TPMAPI_E_POLICY_DENIES_OPERATION: HRESULT = 0x8029011E; +pub const TBSIMP_E_BUFFER_TOO_SMALL: HRESULT = 0x80290200; +pub const TBSIMP_E_CLEANUP_FAILED: HRESULT = 0x80290201; +pub const TBSIMP_E_INVALID_CONTEXT_HANDLE: HRESULT = 0x80290202; +pub const TBSIMP_E_INVALID_CONTEXT_PARAM: HRESULT = 0x80290203; +pub const TBSIMP_E_TPM_ERROR: HRESULT = 0x80290204; +pub const TBSIMP_E_HASH_BAD_KEY: HRESULT = 0x80290205; +pub const TBSIMP_E_DUPLICATE_VHANDLE: HRESULT = 0x80290206; +pub const TBSIMP_E_INVALID_OUTPUT_POINTER: HRESULT = 0x80290207; +pub const TBSIMP_E_INVALID_PARAMETER: HRESULT = 0x80290208; +pub const TBSIMP_E_RPC_INIT_FAILED: HRESULT = 0x80290209; +pub const TBSIMP_E_SCHEDULER_NOT_RUNNING: HRESULT = 0x8029020A; +pub const TBSIMP_E_COMMAND_CANCELED: HRESULT = 0x8029020B; +pub const TBSIMP_E_OUT_OF_MEMORY: HRESULT = 0x8029020C; +pub const TBSIMP_E_LIST_NO_MORE_ITEMS: HRESULT = 0x8029020D; +pub const TBSIMP_E_LIST_NOT_FOUND: HRESULT = 0x8029020E; +pub const TBSIMP_E_NOT_ENOUGH_SPACE: HRESULT = 0x8029020F; +pub const TBSIMP_E_NOT_ENOUGH_TPM_CONTEXTS: HRESULT = 0x80290210; +pub const TBSIMP_E_COMMAND_FAILED: HRESULT = 0x80290211; +pub const TBSIMP_E_UNKNOWN_ORDINAL: HRESULT = 0x80290212; +pub const TBSIMP_E_RESOURCE_EXPIRED: HRESULT = 0x80290213; +pub const TBSIMP_E_INVALID_RESOURCE: HRESULT = 0x80290214; +pub const TBSIMP_E_NOTHING_TO_UNLOAD: HRESULT = 0x80290215; +pub const TBSIMP_E_HASH_TABLE_FULL: HRESULT = 0x80290216; +pub const TBSIMP_E_TOO_MANY_TBS_CONTEXTS: HRESULT = 0x80290217; +pub const TBSIMP_E_TOO_MANY_RESOURCES: HRESULT = 0x80290218; +pub const TBSIMP_E_PPI_NOT_SUPPORTED: HRESULT = 0x80290219; +pub const TBSIMP_E_TPM_INCOMPATIBLE: HRESULT = 0x8029021A; +pub const TBSIMP_E_NO_EVENT_LOG: HRESULT = 0x8029021B; +pub const TPM_E_PPI_ACPI_FAILURE: HRESULT = 0x80290300; +pub const TPM_E_PPI_USER_ABORT: HRESULT = 0x80290301; +pub const TPM_E_PPI_BIOS_FAILURE: HRESULT = 0x80290302; +pub const TPM_E_PPI_NOT_SUPPORTED: HRESULT = 0x80290303; +pub const TPM_E_PPI_BLOCKED_IN_BIOS: HRESULT = 0x80290304; +pub const TPM_E_PCP_ERROR_MASK: HRESULT = 0x80290400; +pub const TPM_E_PCP_DEVICE_NOT_READY: HRESULT = 0x80290401; +pub const TPM_E_PCP_INVALID_HANDLE: HRESULT = 0x80290402; +pub const TPM_E_PCP_INVALID_PARAMETER: HRESULT = 0x80290403; +pub const TPM_E_PCP_FLAG_NOT_SUPPORTED: HRESULT = 0x80290404; +pub const TPM_E_PCP_NOT_SUPPORTED: HRESULT = 0x80290405; +pub const TPM_E_PCP_BUFFER_TOO_SMALL: HRESULT = 0x80290406; +pub const TPM_E_PCP_INTERNAL_ERROR: HRESULT = 0x80290407; +pub const TPM_E_PCP_AUTHENTICATION_FAILED: HRESULT = 0x80290408; +pub const TPM_E_PCP_AUTHENTICATION_IGNORED: HRESULT = 0x80290409; +pub const TPM_E_PCP_POLICY_NOT_FOUND: HRESULT = 0x8029040A; +pub const TPM_E_PCP_PROFILE_NOT_FOUND: HRESULT = 0x8029040B; +pub const TPM_E_PCP_VALIDATION_FAILED: HRESULT = 0x8029040C; +pub const PLA_E_DCS_NOT_FOUND: HRESULT = 0x80300002; +pub const PLA_E_DCS_IN_USE: HRESULT = 0x803000AA; +pub const PLA_E_TOO_MANY_FOLDERS: HRESULT = 0x80300045; +pub const PLA_E_NO_MIN_DISK: HRESULT = 0x80300070; +pub const PLA_E_DCS_ALREADY_EXISTS: HRESULT = 0x803000B7; +pub const PLA_S_PROPERTY_IGNORED: HRESULT = 0x00300100; +pub const PLA_E_PROPERTY_CONFLICT: HRESULT = 0x80300101; +pub const PLA_E_DCS_SINGLETON_REQUIRED: HRESULT = 0x80300102; +pub const PLA_E_CREDENTIALS_REQUIRED: HRESULT = 0x80300103; +pub const PLA_E_DCS_NOT_RUNNING: HRESULT = 0x80300104; +pub const PLA_E_CONFLICT_INCL_EXCL_API: HRESULT = 0x80300105; +pub const PLA_E_NETWORK_EXE_NOT_VALID: HRESULT = 0x80300106; +pub const PLA_E_EXE_ALREADY_CONFIGURED: HRESULT = 0x80300107; +pub const PLA_E_EXE_PATH_NOT_VALID: HRESULT = 0x80300108; +pub const PLA_E_DC_ALREADY_EXISTS: HRESULT = 0x80300109; +pub const PLA_E_DCS_START_WAIT_TIMEOUT: HRESULT = 0x8030010A; +pub const PLA_E_DC_START_WAIT_TIMEOUT: HRESULT = 0x8030010B; +pub const PLA_E_REPORT_WAIT_TIMEOUT: HRESULT = 0x8030010C; +pub const PLA_E_NO_DUPLICATES: HRESULT = 0x8030010D; +pub const PLA_E_EXE_FULL_PATH_REQUIRED: HRESULT = 0x8030010E; +pub const PLA_E_INVALID_SESSION_NAME: HRESULT = 0x8030010F; +pub const PLA_E_PLA_CHANNEL_NOT_ENABLED: HRESULT = 0x80300110; +pub const PLA_E_TASKSCHED_CHANNEL_NOT_ENABLED: HRESULT = 0x80300111; +pub const PLA_E_RULES_MANAGER_FAILED: HRESULT = 0x80300112; +pub const PLA_E_CABAPI_FAILURE: HRESULT = 0x80300113; +pub const FVE_E_LOCKED_VOLUME: HRESULT = 0x80310000; +pub const FVE_E_NOT_ENCRYPTED: HRESULT = 0x80310001; +pub const FVE_E_NO_TPM_BIOS: HRESULT = 0x80310002; +pub const FVE_E_NO_MBR_METRIC: HRESULT = 0x80310003; +pub const FVE_E_NO_BOOTSECTOR_METRIC: HRESULT = 0x80310004; +pub const FVE_E_NO_BOOTMGR_METRIC: HRESULT = 0x80310005; +pub const FVE_E_WRONG_BOOTMGR: HRESULT = 0x80310006; +pub const FVE_E_SECURE_KEY_REQUIRED: HRESULT = 0x80310007; +pub const FVE_E_NOT_ACTIVATED: HRESULT = 0x80310008; +pub const FVE_E_ACTION_NOT_ALLOWED: HRESULT = 0x80310009; +pub const FVE_E_AD_SCHEMA_NOT_INSTALLED: HRESULT = 0x8031000A; +pub const FVE_E_AD_INVALID_DATATYPE: HRESULT = 0x8031000B; +pub const FVE_E_AD_INVALID_DATASIZE: HRESULT = 0x8031000C; +pub const FVE_E_AD_NO_VALUES: HRESULT = 0x8031000D; +pub const FVE_E_AD_ATTR_NOT_SET: HRESULT = 0x8031000E; +pub const FVE_E_AD_GUID_NOT_FOUND: HRESULT = 0x8031000F; +pub const FVE_E_BAD_INFORMATION: HRESULT = 0x80310010; +pub const FVE_E_TOO_SMALL: HRESULT = 0x80310011; +pub const FVE_E_SYSTEM_VOLUME: HRESULT = 0x80310012; +pub const FVE_E_FAILED_WRONG_FS: HRESULT = 0x80310013; +pub const FVE_E_BAD_PARTITION_SIZE: HRESULT = 0x80310014; +pub const FVE_E_NOT_SUPPORTED: HRESULT = 0x80310015; +pub const FVE_E_BAD_DATA: HRESULT = 0x80310016; +pub const FVE_E_VOLUME_NOT_BOUND: HRESULT = 0x80310017; +pub const FVE_E_TPM_NOT_OWNED: HRESULT = 0x80310018; +pub const FVE_E_NOT_DATA_VOLUME: HRESULT = 0x80310019; +pub const FVE_E_AD_INSUFFICIENT_BUFFER: HRESULT = 0x8031001A; +pub const FVE_E_CONV_READ: HRESULT = 0x8031001B; +pub const FVE_E_CONV_WRITE: HRESULT = 0x8031001C; +pub const FVE_E_KEY_REQUIRED: HRESULT = 0x8031001D; +pub const FVE_E_CLUSTERING_NOT_SUPPORTED: HRESULT = 0x8031001E; +pub const FVE_E_VOLUME_BOUND_ALREADY: HRESULT = 0x8031001F; +pub const FVE_E_OS_NOT_PROTECTED: HRESULT = 0x80310020; +pub const FVE_E_PROTECTION_DISABLED: HRESULT = 0x80310021; +pub const FVE_E_RECOVERY_KEY_REQUIRED: HRESULT = 0x80310022; +pub const FVE_E_FOREIGN_VOLUME: HRESULT = 0x80310023; +pub const FVE_E_OVERLAPPED_UPDATE: HRESULT = 0x80310024; +pub const FVE_E_TPM_SRK_AUTH_NOT_ZERO: HRESULT = 0x80310025; +pub const FVE_E_FAILED_SECTOR_SIZE: HRESULT = 0x80310026; +pub const FVE_E_FAILED_AUTHENTICATION: HRESULT = 0x80310027; +pub const FVE_E_NOT_OS_VOLUME: HRESULT = 0x80310028; +pub const FVE_E_AUTOUNLOCK_ENABLED: HRESULT = 0x80310029; +pub const FVE_E_WRONG_BOOTSECTOR: HRESULT = 0x8031002A; +pub const FVE_E_WRONG_SYSTEM_FS: HRESULT = 0x8031002B; +pub const FVE_E_POLICY_PASSWORD_REQUIRED: HRESULT = 0x8031002C; +pub const FVE_E_CANNOT_SET_FVEK_ENCRYPTED: HRESULT = 0x8031002D; +pub const FVE_E_CANNOT_ENCRYPT_NO_KEY: HRESULT = 0x8031002E; +pub const FVE_E_BOOTABLE_CDDVD: HRESULT = 0x80310030; +pub const FVE_E_PROTECTOR_EXISTS: HRESULT = 0x80310031; +pub const FVE_E_RELATIVE_PATH: HRESULT = 0x80310032; +pub const FVE_E_PROTECTOR_NOT_FOUND: HRESULT = 0x80310033; +pub const FVE_E_INVALID_KEY_FORMAT: HRESULT = 0x80310034; +pub const FVE_E_INVALID_PASSWORD_FORMAT: HRESULT = 0x80310035; +pub const FVE_E_FIPS_RNG_CHECK_FAILED: HRESULT = 0x80310036; +pub const FVE_E_FIPS_PREVENTS_RECOVERY_PASSWORD: HRESULT = 0x80310037; +pub const FVE_E_FIPS_PREVENTS_EXTERNAL_KEY_EXPORT: HRESULT = 0x80310038; +pub const FVE_E_NOT_DECRYPTED: HRESULT = 0x80310039; +pub const FVE_E_INVALID_PROTECTOR_TYPE: HRESULT = 0x8031003A; +pub const FVE_E_NO_PROTECTORS_TO_TEST: HRESULT = 0x8031003B; +pub const FVE_E_KEYFILE_NOT_FOUND: HRESULT = 0x8031003C; +pub const FVE_E_KEYFILE_INVALID: HRESULT = 0x8031003D; +pub const FVE_E_KEYFILE_NO_VMK: HRESULT = 0x8031003E; +pub const FVE_E_TPM_DISABLED: HRESULT = 0x8031003F; +pub const FVE_E_NOT_ALLOWED_IN_SAFE_MODE: HRESULT = 0x80310040; +pub const FVE_E_TPM_INVALID_PCR: HRESULT = 0x80310041; +pub const FVE_E_TPM_NO_VMK: HRESULT = 0x80310042; +pub const FVE_E_PIN_INVALID: HRESULT = 0x80310043; +pub const FVE_E_AUTH_INVALID_APPLICATION: HRESULT = 0x80310044; +pub const FVE_E_AUTH_INVALID_CONFIG: HRESULT = 0x80310045; +pub const FVE_E_FIPS_DISABLE_PROTECTION_NOT_ALLOWED: HRESULT = 0x80310046; +pub const FVE_E_FS_NOT_EXTENDED: HRESULT = 0x80310047; +pub const FVE_E_FIRMWARE_TYPE_NOT_SUPPORTED: HRESULT = 0x80310048; +pub const FVE_E_NO_LICENSE: HRESULT = 0x80310049; +pub const FVE_E_NOT_ON_STACK: HRESULT = 0x8031004A; +pub const FVE_E_FS_MOUNTED: HRESULT = 0x8031004B; +pub const FVE_E_TOKEN_NOT_IMPERSONATED: HRESULT = 0x8031004C; +pub const FVE_E_DRY_RUN_FAILED: HRESULT = 0x8031004D; +pub const FVE_E_REBOOT_REQUIRED: HRESULT = 0x8031004E; +pub const FVE_E_DEBUGGER_ENABLED: HRESULT = 0x8031004F; +pub const FVE_E_RAW_ACCESS: HRESULT = 0x80310050; +pub const FVE_E_RAW_BLOCKED: HRESULT = 0x80310051; +pub const FVE_E_BCD_APPLICATIONS_PATH_INCORRECT: HRESULT = 0x80310052; +pub const FVE_E_NOT_ALLOWED_IN_VERSION: HRESULT = 0x80310053; +pub const FVE_E_NO_AUTOUNLOCK_MASTER_KEY: HRESULT = 0x80310054; +pub const FVE_E_MOR_FAILED: HRESULT = 0x80310055; +pub const FVE_E_HIDDEN_VOLUME: HRESULT = 0x80310056; +pub const FVE_E_TRANSIENT_STATE: HRESULT = 0x80310057; +pub const FVE_E_PUBKEY_NOT_ALLOWED: HRESULT = 0x80310058; +pub const FVE_E_VOLUME_HANDLE_OPEN: HRESULT = 0x80310059; +pub const FVE_E_NO_FEATURE_LICENSE: HRESULT = 0x8031005A; +pub const FVE_E_INVALID_STARTUP_OPTIONS: HRESULT = 0x8031005B; +pub const FVE_E_POLICY_RECOVERY_PASSWORD_NOT_ALLOWED: HRESULT = 0x8031005C; +pub const FVE_E_POLICY_RECOVERY_PASSWORD_REQUIRED: HRESULT = 0x8031005D; +pub const FVE_E_POLICY_RECOVERY_KEY_NOT_ALLOWED: HRESULT = 0x8031005E; +pub const FVE_E_POLICY_RECOVERY_KEY_REQUIRED: HRESULT = 0x8031005F; +pub const FVE_E_POLICY_STARTUP_PIN_NOT_ALLOWED: HRESULT = 0x80310060; +pub const FVE_E_POLICY_STARTUP_PIN_REQUIRED: HRESULT = 0x80310061; +pub const FVE_E_POLICY_STARTUP_KEY_NOT_ALLOWED: HRESULT = 0x80310062; +pub const FVE_E_POLICY_STARTUP_KEY_REQUIRED: HRESULT = 0x80310063; +pub const FVE_E_POLICY_STARTUP_PIN_KEY_NOT_ALLOWED: HRESULT = 0x80310064; +pub const FVE_E_POLICY_STARTUP_PIN_KEY_REQUIRED: HRESULT = 0x80310065; +pub const FVE_E_POLICY_STARTUP_TPM_NOT_ALLOWED: HRESULT = 0x80310066; +pub const FVE_E_POLICY_STARTUP_TPM_REQUIRED: HRESULT = 0x80310067; +pub const FVE_E_POLICY_INVALID_PIN_LENGTH: HRESULT = 0x80310068; +pub const FVE_E_KEY_PROTECTOR_NOT_SUPPORTED: HRESULT = 0x80310069; +pub const FVE_E_POLICY_PASSPHRASE_NOT_ALLOWED: HRESULT = 0x8031006A; +pub const FVE_E_POLICY_PASSPHRASE_REQUIRED: HRESULT = 0x8031006B; +pub const FVE_E_FIPS_PREVENTS_PASSPHRASE: HRESULT = 0x8031006C; +pub const FVE_E_OS_VOLUME_PASSPHRASE_NOT_ALLOWED: HRESULT = 0x8031006D; +pub const FVE_E_INVALID_BITLOCKER_OID: HRESULT = 0x8031006E; +pub const FVE_E_VOLUME_TOO_SMALL: HRESULT = 0x8031006F; +pub const FVE_E_DV_NOT_SUPPORTED_ON_FS: HRESULT = 0x80310070; +pub const FVE_E_DV_NOT_ALLOWED_BY_GP: HRESULT = 0x80310071; +pub const FVE_E_POLICY_USER_CERTIFICATE_NOT_ALLOWED: HRESULT = 0x80310072; +pub const FVE_E_POLICY_USER_CERTIFICATE_REQUIRED: HRESULT = 0x80310073; +pub const FVE_E_POLICY_USER_CERT_MUST_BE_HW: HRESULT = 0x80310074; +pub const FVE_E_POLICY_USER_CONFIGURE_FDV_AUTOUNLOCK_NOT_ALLOWED: HRESULT + = 0x80310075; +pub const FVE_E_POLICY_USER_CONFIGURE_RDV_AUTOUNLOCK_NOT_ALLOWED: HRESULT + = 0x80310076; +pub const FVE_E_POLICY_USER_CONFIGURE_RDV_NOT_ALLOWED: HRESULT = 0x80310077; +pub const FVE_E_POLICY_USER_ENABLE_RDV_NOT_ALLOWED: HRESULT = 0x80310078; +pub const FVE_E_POLICY_USER_DISABLE_RDV_NOT_ALLOWED: HRESULT = 0x80310079; +pub const FVE_E_POLICY_INVALID_PASSPHRASE_LENGTH: HRESULT = 0x80310080; +pub const FVE_E_POLICY_PASSPHRASE_TOO_SIMPLE: HRESULT = 0x80310081; +pub const FVE_E_RECOVERY_PARTITION: HRESULT = 0x80310082; +pub const FVE_E_POLICY_CONFLICT_FDV_RK_OFF_AUK_ON: HRESULT = 0x80310083; +pub const FVE_E_POLICY_CONFLICT_RDV_RK_OFF_AUK_ON: HRESULT = 0x80310084; +pub const FVE_E_NON_BITLOCKER_OID: HRESULT = 0x80310085; +pub const FVE_E_POLICY_PROHIBITS_SELFSIGNED: HRESULT = 0x80310086; +pub const FVE_E_POLICY_CONFLICT_RO_AND_STARTUP_KEY_REQUIRED: HRESULT = 0x80310087; +pub const FVE_E_CONV_RECOVERY_FAILED: HRESULT = 0x80310088; +pub const FVE_E_VIRTUALIZED_SPACE_TOO_BIG: HRESULT = 0x80310089; +pub const FVE_E_POLICY_CONFLICT_OSV_RP_OFF_ADB_ON: HRESULT = 0x80310090; +pub const FVE_E_POLICY_CONFLICT_FDV_RP_OFF_ADB_ON: HRESULT = 0x80310091; +pub const FVE_E_POLICY_CONFLICT_RDV_RP_OFF_ADB_ON: HRESULT = 0x80310092; +pub const FVE_E_NON_BITLOCKER_KU: HRESULT = 0x80310093; +pub const FVE_E_PRIVATEKEY_AUTH_FAILED: HRESULT = 0x80310094; +pub const FVE_E_REMOVAL_OF_DRA_FAILED: HRESULT = 0x80310095; +pub const FVE_E_OPERATION_NOT_SUPPORTED_ON_VISTA_VOLUME: HRESULT = 0x80310096; +pub const FVE_E_CANT_LOCK_AUTOUNLOCK_ENABLED_VOLUME: HRESULT = 0x80310097; +pub const FVE_E_FIPS_HASH_KDF_NOT_ALLOWED: HRESULT = 0x80310098; +pub const FVE_E_ENH_PIN_INVALID: HRESULT = 0x80310099; +pub const FVE_E_INVALID_PIN_CHARS: HRESULT = 0x8031009A; +pub const FVE_E_INVALID_DATUM_TYPE: HRESULT = 0x8031009B; +pub const FVE_E_EFI_ONLY: HRESULT = 0x8031009C; +pub const FVE_E_MULTIPLE_NKP_CERTS: HRESULT = 0x8031009D; +pub const FVE_E_REMOVAL_OF_NKP_FAILED: HRESULT = 0x8031009E; +pub const FVE_E_INVALID_NKP_CERT: HRESULT = 0x8031009F; +pub const FVE_E_NO_EXISTING_PIN: HRESULT = 0x803100A0; +pub const FVE_E_PROTECTOR_CHANGE_PIN_MISMATCH: HRESULT = 0x803100A1; +pub const FVE_E_PIN_PROTECTOR_CHANGE_BY_STD_USER_DISALLOWED: HRESULT = 0x803100A2; +pub const FVE_E_PROTECTOR_CHANGE_MAX_PIN_CHANGE_ATTEMPTS_REACHED: HRESULT + = 0x803100A3; +pub const FVE_E_POLICY_PASSPHRASE_REQUIRES_ASCII: HRESULT = 0x803100A4; +pub const FVE_E_FULL_ENCRYPTION_NOT_ALLOWED_ON_TP_STORAGE: HRESULT = 0x803100A5; +pub const FVE_E_WIPE_NOT_ALLOWED_ON_TP_STORAGE: HRESULT = 0x803100A6; +pub const FVE_E_KEY_LENGTH_NOT_SUPPORTED_BY_EDRIVE: HRESULT = 0x803100A7; +pub const FVE_E_NO_EXISTING_PASSPHRASE: HRESULT = 0x803100A8; +pub const FVE_E_PROTECTOR_CHANGE_PASSPHRASE_MISMATCH: HRESULT = 0x803100A9; +pub const FVE_E_PASSPHRASE_TOO_LONG: HRESULT = 0x803100AA; +pub const FVE_E_NO_PASSPHRASE_WITH_TPM: HRESULT = 0x803100AB; +pub const FVE_E_NO_TPM_WITH_PASSPHRASE: HRESULT = 0x803100AC; +pub const FVE_E_NOT_ALLOWED_ON_CSV_STACK: HRESULT = 0x803100AD; +pub const FVE_E_NOT_ALLOWED_ON_CLUSTER: HRESULT = 0x803100AE; +pub const FVE_E_EDRIVE_NO_FAILOVER_TO_SW: HRESULT = 0x803100AF; +pub const FVE_E_EDRIVE_BAND_IN_USE: HRESULT = 0x803100B0; +pub const FVE_E_EDRIVE_DISALLOWED_BY_GP: HRESULT = 0x803100B1; +pub const FVE_E_EDRIVE_INCOMPATIBLE_VOLUME: HRESULT = 0x803100B2; +pub const FVE_E_NOT_ALLOWED_TO_UPGRADE_WHILE_CONVERTING: HRESULT = 0x803100B3; +pub const FVE_E_EDRIVE_DV_NOT_SUPPORTED: HRESULT = 0x803100B4; +pub const FVE_E_NO_PREBOOT_KEYBOARD_DETECTED: HRESULT = 0x803100B5; +pub const FVE_E_NO_PREBOOT_KEYBOARD_OR_WINRE_DETECTED: HRESULT = 0x803100B6; +pub const FVE_E_POLICY_REQUIRES_STARTUP_PIN_ON_TOUCH_DEVICE: HRESULT = 0x803100B7; +pub const FVE_E_POLICY_REQUIRES_RECOVERY_PASSWORD_ON_TOUCH_DEVICE: HRESULT + = 0x803100B8; +pub const FVE_E_WIPE_CANCEL_NOT_APPLICABLE: HRESULT = 0x803100B9; +pub const FVE_E_SECUREBOOT_DISABLED: HRESULT = 0x803100BA; +pub const FVE_E_SECUREBOOT_CONFIGURATION_INVALID: HRESULT = 0x803100BB; +pub const FVE_E_EDRIVE_DRY_RUN_FAILED: HRESULT = 0x803100BC; +pub const FVE_E_SHADOW_COPY_PRESENT: HRESULT = 0x803100BD; +pub const FVE_E_POLICY_INVALID_ENHANCED_BCD_SETTINGS: HRESULT = 0x803100BE; +pub const FVE_E_EDRIVE_INCOMPATIBLE_FIRMWARE: HRESULT = 0x803100BF; +pub const FVE_E_PROTECTOR_CHANGE_MAX_PASSPHRASE_CHANGE_ATTEMPTS_REACHED: HRESULT + = 0x803100C0; +pub const FVE_E_PASSPHRASE_PROTECTOR_CHANGE_BY_STD_USER_DISALLOWED: HRESULT + = 0x803100C1; +pub const FVE_E_LIVEID_ACCOUNT_SUSPENDED: HRESULT = 0x803100C2; +pub const FVE_E_LIVEID_ACCOUNT_BLOCKED: HRESULT = 0x803100C3; +pub const FVE_E_NOT_PROVISIONED_ON_ALL_VOLUMES: HRESULT = 0x803100C4; +pub const FVE_E_DE_FIXED_DATA_NOT_SUPPORTED: HRESULT = 0x803100C5; +pub const FVE_E_DE_HARDWARE_NOT_COMPLIANT: HRESULT = 0x803100C6; +pub const FVE_E_DE_WINRE_NOT_CONFIGURED: HRESULT = 0x803100C7; +pub const FVE_E_DE_PROTECTION_SUSPENDED: HRESULT = 0x803100C8; +pub const FVE_E_DE_OS_VOLUME_NOT_PROTECTED: HRESULT = 0x803100C9; +pub const FVE_E_DE_DEVICE_LOCKEDOUT: HRESULT = 0x803100CA; +pub const FVE_E_DE_PROTECTION_NOT_YET_ENABLED: HRESULT = 0x803100CB; +pub const FVE_E_INVALID_PIN_CHARS_DETAILED: HRESULT = 0x803100CC; +pub const FVE_E_DEVICE_LOCKOUT_COUNTER_UNAVAILABLE: HRESULT = 0x803100CD; +pub const FVE_E_DEVICELOCKOUT_COUNTER_MISMATCH: HRESULT = 0x803100CE; +pub const FVE_E_BUFFER_TOO_LARGE: HRESULT = 0x803100CF; +pub const FVE_E_NO_SUCH_CAPABILITY_ON_TARGET: HRESULT = 0x803100D0; +pub const FVE_E_DE_PREVENTED_FOR_OS: HRESULT = 0x803100D1; +pub const FVE_E_DE_VOLUME_OPTED_OUT: HRESULT = 0x803100D2; +pub const FVE_E_DE_VOLUME_NOT_SUPPORTED: HRESULT = 0x803100D3; +pub const FVE_E_EOW_NOT_SUPPORTED_IN_VERSION: HRESULT = 0x803100D4; +pub const FVE_E_ADBACKUP_NOT_ENABLED: HRESULT = 0x803100D5; +pub const FVE_E_VOLUME_EXTEND_PREVENTS_EOW_DECRYPT: HRESULT = 0x803100D6; +pub const FVE_E_NOT_DE_VOLUME: HRESULT = 0x803100D7; +pub const FVE_E_PROTECTION_CANNOT_BE_DISABLED: HRESULT = 0x803100D8; +pub const FWP_E_CALLOUT_NOT_FOUND: HRESULT = 0x80320001; +pub const FWP_E_CONDITION_NOT_FOUND: HRESULT = 0x80320002; +pub const FWP_E_FILTER_NOT_FOUND: HRESULT = 0x80320003; +pub const FWP_E_LAYER_NOT_FOUND: HRESULT = 0x80320004; +pub const FWP_E_PROVIDER_NOT_FOUND: HRESULT = 0x80320005; +pub const FWP_E_PROVIDER_CONTEXT_NOT_FOUND: HRESULT = 0x80320006; +pub const FWP_E_SUBLAYER_NOT_FOUND: HRESULT = 0x80320007; +pub const FWP_E_NOT_FOUND: HRESULT = 0x80320008; +pub const FWP_E_ALREADY_EXISTS: HRESULT = 0x80320009; +pub const FWP_E_IN_USE: HRESULT = 0x8032000A; +pub const FWP_E_DYNAMIC_SESSION_IN_PROGRESS: HRESULT = 0x8032000B; +pub const FWP_E_WRONG_SESSION: HRESULT = 0x8032000C; +pub const FWP_E_NO_TXN_IN_PROGRESS: HRESULT = 0x8032000D; +pub const FWP_E_TXN_IN_PROGRESS: HRESULT = 0x8032000E; +pub const FWP_E_TXN_ABORTED: HRESULT = 0x8032000F; +pub const FWP_E_SESSION_ABORTED: HRESULT = 0x80320010; +pub const FWP_E_INCOMPATIBLE_TXN: HRESULT = 0x80320011; +pub const FWP_E_TIMEOUT: HRESULT = 0x80320012; +pub const FWP_E_NET_EVENTS_DISABLED: HRESULT = 0x80320013; +pub const FWP_E_INCOMPATIBLE_LAYER: HRESULT = 0x80320014; +pub const FWP_E_KM_CLIENTS_ONLY: HRESULT = 0x80320015; +pub const FWP_E_LIFETIME_MISMATCH: HRESULT = 0x80320016; +pub const FWP_E_BUILTIN_OBJECT: HRESULT = 0x80320017; +pub const FWP_E_TOO_MANY_CALLOUTS: HRESULT = 0x80320018; +pub const FWP_E_NOTIFICATION_DROPPED: HRESULT = 0x80320019; +pub const FWP_E_TRAFFIC_MISMATCH: HRESULT = 0x8032001A; +pub const FWP_E_INCOMPATIBLE_SA_STATE: HRESULT = 0x8032001B; +pub const FWP_E_NULL_POINTER: HRESULT = 0x8032001C; +pub const FWP_E_INVALID_ENUMERATOR: HRESULT = 0x8032001D; +pub const FWP_E_INVALID_FLAGS: HRESULT = 0x8032001E; +pub const FWP_E_INVALID_NET_MASK: HRESULT = 0x8032001F; +pub const FWP_E_INVALID_RANGE: HRESULT = 0x80320020; +pub const FWP_E_INVALID_INTERVAL: HRESULT = 0x80320021; +pub const FWP_E_ZERO_LENGTH_ARRAY: HRESULT = 0x80320022; +pub const FWP_E_NULL_DISPLAY_NAME: HRESULT = 0x80320023; +pub const FWP_E_INVALID_ACTION_TYPE: HRESULT = 0x80320024; +pub const FWP_E_INVALID_WEIGHT: HRESULT = 0x80320025; +pub const FWP_E_MATCH_TYPE_MISMATCH: HRESULT = 0x80320026; +pub const FWP_E_TYPE_MISMATCH: HRESULT = 0x80320027; +pub const FWP_E_OUT_OF_BOUNDS: HRESULT = 0x80320028; +pub const FWP_E_RESERVED: HRESULT = 0x80320029; +pub const FWP_E_DUPLICATE_CONDITION: HRESULT = 0x8032002A; +pub const FWP_E_DUPLICATE_KEYMOD: HRESULT = 0x8032002B; +pub const FWP_E_ACTION_INCOMPATIBLE_WITH_LAYER: HRESULT = 0x8032002C; +pub const FWP_E_ACTION_INCOMPATIBLE_WITH_SUBLAYER: HRESULT = 0x8032002D; +pub const FWP_E_CONTEXT_INCOMPATIBLE_WITH_LAYER: HRESULT = 0x8032002E; +pub const FWP_E_CONTEXT_INCOMPATIBLE_WITH_CALLOUT: HRESULT = 0x8032002F; +pub const FWP_E_INCOMPATIBLE_AUTH_METHOD: HRESULT = 0x80320030; +pub const FWP_E_INCOMPATIBLE_DH_GROUP: HRESULT = 0x80320031; +pub const FWP_E_EM_NOT_SUPPORTED: HRESULT = 0x80320032; +pub const FWP_E_NEVER_MATCH: HRESULT = 0x80320033; +pub const FWP_E_PROVIDER_CONTEXT_MISMATCH: HRESULT = 0x80320034; +pub const FWP_E_INVALID_PARAMETER: HRESULT = 0x80320035; +pub const FWP_E_TOO_MANY_SUBLAYERS: HRESULT = 0x80320036; +pub const FWP_E_CALLOUT_NOTIFICATION_FAILED: HRESULT = 0x80320037; +pub const FWP_E_INVALID_AUTH_TRANSFORM: HRESULT = 0x80320038; +pub const FWP_E_INVALID_CIPHER_TRANSFORM: HRESULT = 0x80320039; +pub const FWP_E_INCOMPATIBLE_CIPHER_TRANSFORM: HRESULT = 0x8032003A; +pub const FWP_E_INVALID_TRANSFORM_COMBINATION: HRESULT = 0x8032003B; +pub const FWP_E_DUPLICATE_AUTH_METHOD: HRESULT = 0x8032003C; +pub const FWP_E_INVALID_TUNNEL_ENDPOINT: HRESULT = 0x8032003D; +pub const FWP_E_L2_DRIVER_NOT_READY: HRESULT = 0x8032003E; +pub const FWP_E_KEY_DICTATOR_ALREADY_REGISTERED: HRESULT = 0x8032003F; +pub const FWP_E_KEY_DICTATION_INVALID_KEYING_MATERIAL: HRESULT = 0x80320040; +pub const FWP_E_CONNECTIONS_DISABLED: HRESULT = 0x80320041; +pub const FWP_E_INVALID_DNS_NAME: HRESULT = 0x80320042; +pub const FWP_E_STILL_ON: HRESULT = 0x80320043; +pub const FWP_E_IKEEXT_NOT_RUNNING: HRESULT = 0x80320044; +pub const FWP_E_DROP_NOICMP: HRESULT = 0x80320104; +pub const WS_S_ASYNC: HRESULT = 0x003D0000; +pub const WS_S_END: HRESULT = 0x003D0001; +pub const WS_E_INVALID_FORMAT: HRESULT = 0x803D0000; +pub const WS_E_OBJECT_FAULTED: HRESULT = 0x803D0001; +pub const WS_E_NUMERIC_OVERFLOW: HRESULT = 0x803D0002; +pub const WS_E_INVALID_OPERATION: HRESULT = 0x803D0003; +pub const WS_E_OPERATION_ABORTED: HRESULT = 0x803D0004; +pub const WS_E_ENDPOINT_ACCESS_DENIED: HRESULT = 0x803D0005; +pub const WS_E_OPERATION_TIMED_OUT: HRESULT = 0x803D0006; +pub const WS_E_OPERATION_ABANDONED: HRESULT = 0x803D0007; +pub const WS_E_QUOTA_EXCEEDED: HRESULT = 0x803D0008; +pub const WS_E_NO_TRANSLATION_AVAILABLE: HRESULT = 0x803D0009; +pub const WS_E_SECURITY_VERIFICATION_FAILURE: HRESULT = 0x803D000A; +pub const WS_E_ADDRESS_IN_USE: HRESULT = 0x803D000B; +pub const WS_E_ADDRESS_NOT_AVAILABLE: HRESULT = 0x803D000C; +pub const WS_E_ENDPOINT_NOT_FOUND: HRESULT = 0x803D000D; +pub const WS_E_ENDPOINT_NOT_AVAILABLE: HRESULT = 0x803D000E; +pub const WS_E_ENDPOINT_FAILURE: HRESULT = 0x803D000F; +pub const WS_E_ENDPOINT_UNREACHABLE: HRESULT = 0x803D0010; +pub const WS_E_ENDPOINT_ACTION_NOT_SUPPORTED: HRESULT = 0x803D0011; +pub const WS_E_ENDPOINT_TOO_BUSY: HRESULT = 0x803D0012; +pub const WS_E_ENDPOINT_FAULT_RECEIVED: HRESULT = 0x803D0013; +pub const WS_E_ENDPOINT_DISCONNECTED: HRESULT = 0x803D0014; +pub const WS_E_PROXY_FAILURE: HRESULT = 0x803D0015; +pub const WS_E_PROXY_ACCESS_DENIED: HRESULT = 0x803D0016; +pub const WS_E_NOT_SUPPORTED: HRESULT = 0x803D0017; +pub const WS_E_PROXY_REQUIRES_BASIC_AUTH: HRESULT = 0x803D0018; +pub const WS_E_PROXY_REQUIRES_DIGEST_AUTH: HRESULT = 0x803D0019; +pub const WS_E_PROXY_REQUIRES_NTLM_AUTH: HRESULT = 0x803D001A; +pub const WS_E_PROXY_REQUIRES_NEGOTIATE_AUTH: HRESULT = 0x803D001B; +pub const WS_E_SERVER_REQUIRES_BASIC_AUTH: HRESULT = 0x803D001C; +pub const WS_E_SERVER_REQUIRES_DIGEST_AUTH: HRESULT = 0x803D001D; +pub const WS_E_SERVER_REQUIRES_NTLM_AUTH: HRESULT = 0x803D001E; +pub const WS_E_SERVER_REQUIRES_NEGOTIATE_AUTH: HRESULT = 0x803D001F; +pub const WS_E_INVALID_ENDPOINT_URL: HRESULT = 0x803D0020; +pub const WS_E_OTHER: HRESULT = 0x803D0021; +pub const WS_E_SECURITY_TOKEN_EXPIRED: HRESULT = 0x803D0022; +pub const WS_E_SECURITY_SYSTEM_FAILURE: HRESULT = 0x803D0023; +pub const ERROR_NDIS_INTERFACE_CLOSING: HRESULT = 0x80340002; +pub const ERROR_NDIS_BAD_VERSION: HRESULT = 0x80340004; +pub const ERROR_NDIS_BAD_CHARACTERISTICS: HRESULT = 0x80340005; +pub const ERROR_NDIS_ADAPTER_NOT_FOUND: HRESULT = 0x80340006; +pub const ERROR_NDIS_OPEN_FAILED: HRESULT = 0x80340007; +pub const ERROR_NDIS_DEVICE_FAILED: HRESULT = 0x80340008; +pub const ERROR_NDIS_MULTICAST_FULL: HRESULT = 0x80340009; +pub const ERROR_NDIS_MULTICAST_EXISTS: HRESULT = 0x8034000A; +pub const ERROR_NDIS_MULTICAST_NOT_FOUND: HRESULT = 0x8034000B; +pub const ERROR_NDIS_REQUEST_ABORTED: HRESULT = 0x8034000C; +pub const ERROR_NDIS_RESET_IN_PROGRESS: HRESULT = 0x8034000D; +pub const ERROR_NDIS_NOT_SUPPORTED: HRESULT = 0x803400BB; +pub const ERROR_NDIS_INVALID_PACKET: HRESULT = 0x8034000F; +pub const ERROR_NDIS_ADAPTER_NOT_READY: HRESULT = 0x80340011; +pub const ERROR_NDIS_INVALID_LENGTH: HRESULT = 0x80340014; +pub const ERROR_NDIS_INVALID_DATA: HRESULT = 0x80340015; +pub const ERROR_NDIS_BUFFER_TOO_SHORT: HRESULT = 0x80340016; +pub const ERROR_NDIS_INVALID_OID: HRESULT = 0x80340017; +pub const ERROR_NDIS_ADAPTER_REMOVED: HRESULT = 0x80340018; +pub const ERROR_NDIS_UNSUPPORTED_MEDIA: HRESULT = 0x80340019; +pub const ERROR_NDIS_GROUP_ADDRESS_IN_USE: HRESULT = 0x8034001A; +pub const ERROR_NDIS_FILE_NOT_FOUND: HRESULT = 0x8034001B; +pub const ERROR_NDIS_ERROR_READING_FILE: HRESULT = 0x8034001C; +pub const ERROR_NDIS_ALREADY_MAPPED: HRESULT = 0x8034001D; +pub const ERROR_NDIS_RESOURCE_CONFLICT: HRESULT = 0x8034001E; +pub const ERROR_NDIS_MEDIA_DISCONNECTED: HRESULT = 0x8034001F; +pub const ERROR_NDIS_INVALID_ADDRESS: HRESULT = 0x80340022; +pub const ERROR_NDIS_INVALID_DEVICE_REQUEST: HRESULT = 0x80340010; +pub const ERROR_NDIS_PAUSED: HRESULT = 0x8034002A; +pub const ERROR_NDIS_INTERFACE_NOT_FOUND: HRESULT = 0x8034002B; +pub const ERROR_NDIS_UNSUPPORTED_REVISION: HRESULT = 0x8034002C; +pub const ERROR_NDIS_INVALID_PORT: HRESULT = 0x8034002D; +pub const ERROR_NDIS_INVALID_PORT_STATE: HRESULT = 0x8034002E; +pub const ERROR_NDIS_LOW_POWER_STATE: HRESULT = 0x8034002F; +pub const ERROR_NDIS_REINIT_REQUIRED: HRESULT = 0x80340030; +pub const ERROR_NDIS_DOT11_AUTO_CONFIG_ENABLED: HRESULT = 0x80342000; +pub const ERROR_NDIS_DOT11_MEDIA_IN_USE: HRESULT = 0x80342001; +pub const ERROR_NDIS_DOT11_POWER_STATE_INVALID: HRESULT = 0x80342002; +pub const ERROR_NDIS_PM_WOL_PATTERN_LIST_FULL: HRESULT = 0x80342003; +pub const ERROR_NDIS_PM_PROTOCOL_OFFLOAD_LIST_FULL: HRESULT = 0x80342004; +pub const ERROR_NDIS_INDICATION_REQUIRED: HRESULT = 0x00340001; +pub const ERROR_NDIS_OFFLOAD_POLICY: HRESULT = 0xC034100F; +pub const ERROR_NDIS_OFFLOAD_CONNECTION_REJECTED: HRESULT = 0xC0341012; +pub const ERROR_NDIS_OFFLOAD_PATH_REJECTED: HRESULT = 0xC0341013; +pub const ERROR_HV_INVALID_HYPERCALL_CODE: HRESULT = 0xC0350002; +pub const ERROR_HV_INVALID_HYPERCALL_INPUT: HRESULT = 0xC0350003; +pub const ERROR_HV_INVALID_ALIGNMENT: HRESULT = 0xC0350004; +pub const ERROR_HV_INVALID_PARAMETER: HRESULT = 0xC0350005; +pub const ERROR_HV_ACCESS_DENIED: HRESULT = 0xC0350006; +pub const ERROR_HV_INVALID_PARTITION_STATE: HRESULT = 0xC0350007; +pub const ERROR_HV_OPERATION_DENIED: HRESULT = 0xC0350008; +pub const ERROR_HV_UNKNOWN_PROPERTY: HRESULT = 0xC0350009; +pub const ERROR_HV_PROPERTY_VALUE_OUT_OF_RANGE: HRESULT = 0xC035000A; +pub const ERROR_HV_INSUFFICIENT_MEMORY: HRESULT = 0xC035000B; +pub const ERROR_HV_PARTITION_TOO_DEEP: HRESULT = 0xC035000C; +pub const ERROR_HV_INVALID_PARTITION_ID: HRESULT = 0xC035000D; +pub const ERROR_HV_INVALID_VP_INDEX: HRESULT = 0xC035000E; +pub const ERROR_HV_INVALID_PORT_ID: HRESULT = 0xC0350011; +pub const ERROR_HV_INVALID_CONNECTION_ID: HRESULT = 0xC0350012; +pub const ERROR_HV_INSUFFICIENT_BUFFERS: HRESULT = 0xC0350013; +pub const ERROR_HV_NOT_ACKNOWLEDGED: HRESULT = 0xC0350014; +pub const ERROR_HV_ACKNOWLEDGED: HRESULT = 0xC0350016; +pub const ERROR_HV_INVALID_SAVE_RESTORE_STATE: HRESULT = 0xC0350017; +pub const ERROR_HV_INVALID_SYNIC_STATE: HRESULT = 0xC0350018; +pub const ERROR_HV_OBJECT_IN_USE: HRESULT = 0xC0350019; +pub const ERROR_HV_INVALID_PROXIMITY_DOMAIN_INFO: HRESULT = 0xC035001A; +pub const ERROR_HV_NO_DATA: HRESULT = 0xC035001B; +pub const ERROR_HV_INACTIVE: HRESULT = 0xC035001C; +pub const ERROR_HV_NO_RESOURCES: HRESULT = 0xC035001D; +pub const ERROR_HV_FEATURE_UNAVAILABLE: HRESULT = 0xC035001E; +pub const ERROR_HV_INSUFFICIENT_BUFFER: HRESULT = 0xC0350033; +pub const ERROR_HV_INSUFFICIENT_DEVICE_DOMAINS: HRESULT = 0xC0350038; +pub const ERROR_HV_INVALID_LP_INDEX: HRESULT = 0xC0350041; +pub const ERROR_HV_NOT_PRESENT: HRESULT = 0xC0351000; +pub const ERROR_VID_DUPLICATE_HANDLER: HRESULT = 0xC0370001; +pub const ERROR_VID_TOO_MANY_HANDLERS: HRESULT = 0xC0370002; +pub const ERROR_VID_QUEUE_FULL: HRESULT = 0xC0370003; +pub const ERROR_VID_HANDLER_NOT_PRESENT: HRESULT = 0xC0370004; +pub const ERROR_VID_INVALID_OBJECT_NAME: HRESULT = 0xC0370005; +pub const ERROR_VID_PARTITION_NAME_TOO_LONG: HRESULT = 0xC0370006; +pub const ERROR_VID_MESSAGE_QUEUE_NAME_TOO_LONG: HRESULT = 0xC0370007; +pub const ERROR_VID_PARTITION_ALREADY_EXISTS: HRESULT = 0xC0370008; +pub const ERROR_VID_PARTITION_DOES_NOT_EXIST: HRESULT = 0xC0370009; +pub const ERROR_VID_PARTITION_NAME_NOT_FOUND: HRESULT = 0xC037000A; +pub const ERROR_VID_MESSAGE_QUEUE_ALREADY_EXISTS: HRESULT = 0xC037000B; +pub const ERROR_VID_EXCEEDED_MBP_ENTRY_MAP_LIMIT: HRESULT = 0xC037000C; +pub const ERROR_VID_MB_STILL_REFERENCED: HRESULT = 0xC037000D; +pub const ERROR_VID_CHILD_GPA_PAGE_SET_CORRUPTED: HRESULT = 0xC037000E; +pub const ERROR_VID_INVALID_NUMA_SETTINGS: HRESULT = 0xC037000F; +pub const ERROR_VID_INVALID_NUMA_NODE_INDEX: HRESULT = 0xC0370010; +pub const ERROR_VID_NOTIFICATION_QUEUE_ALREADY_ASSOCIATED: HRESULT = 0xC0370011; +pub const ERROR_VID_INVALID_MEMORY_BLOCK_HANDLE: HRESULT = 0xC0370012; +pub const ERROR_VID_PAGE_RANGE_OVERFLOW: HRESULT = 0xC0370013; +pub const ERROR_VID_INVALID_MESSAGE_QUEUE_HANDLE: HRESULT = 0xC0370014; +pub const ERROR_VID_INVALID_GPA_RANGE_HANDLE: HRESULT = 0xC0370015; +pub const ERROR_VID_NO_MEMORY_BLOCK_NOTIFICATION_QUEUE: HRESULT = 0xC0370016; +pub const ERROR_VID_MEMORY_BLOCK_LOCK_COUNT_EXCEEDED: HRESULT = 0xC0370017; +pub const ERROR_VID_INVALID_PPM_HANDLE: HRESULT = 0xC0370018; +pub const ERROR_VID_MBPS_ARE_LOCKED: HRESULT = 0xC0370019; +pub const ERROR_VID_MESSAGE_QUEUE_CLOSED: HRESULT = 0xC037001A; +pub const ERROR_VID_VIRTUAL_PROCESSOR_LIMIT_EXCEEDED: HRESULT = 0xC037001B; +pub const ERROR_VID_STOP_PENDING: HRESULT = 0xC037001C; +pub const ERROR_VID_INVALID_PROCESSOR_STATE: HRESULT = 0xC037001D; +pub const ERROR_VID_EXCEEDED_KM_CONTEXT_COUNT_LIMIT: HRESULT = 0xC037001E; +pub const ERROR_VID_KM_INTERFACE_ALREADY_INITIALIZED: HRESULT = 0xC037001F; +pub const ERROR_VID_MB_PROPERTY_ALREADY_SET_RESET: HRESULT = 0xC0370020; +pub const ERROR_VID_MMIO_RANGE_DESTROYED: HRESULT = 0xC0370021; +pub const ERROR_VID_INVALID_CHILD_GPA_PAGE_SET: HRESULT = 0xC0370022; +pub const ERROR_VID_RESERVE_PAGE_SET_IS_BEING_USED: HRESULT = 0xC0370023; +pub const ERROR_VID_RESERVE_PAGE_SET_TOO_SMALL: HRESULT = 0xC0370024; +pub const ERROR_VID_MBP_ALREADY_LOCKED_USING_RESERVED_PAGE: HRESULT = 0xC0370025; +pub const ERROR_VID_MBP_COUNT_EXCEEDED_LIMIT: HRESULT = 0xC0370026; +pub const ERROR_VID_SAVED_STATE_CORRUPT: HRESULT = 0xC0370027; +pub const ERROR_VID_SAVED_STATE_UNRECOGNIZED_ITEM: HRESULT = 0xC0370028; +pub const ERROR_VID_SAVED_STATE_INCOMPATIBLE: HRESULT = 0xC0370029; +pub const ERROR_VID_REMOTE_NODE_PARENT_GPA_PAGES_USED: HRESULT = 0x80370001; +pub const ERROR_VOLMGR_INCOMPLETE_REGENERATION: HRESULT = 0x80380001; +pub const ERROR_VOLMGR_INCOMPLETE_DISK_MIGRATION: HRESULT = 0x80380002; +pub const ERROR_VOLMGR_DATABASE_FULL: HRESULT = 0xC0380001; +pub const ERROR_VOLMGR_DISK_CONFIGURATION_CORRUPTED: HRESULT = 0xC0380002; +pub const ERROR_VOLMGR_DISK_CONFIGURATION_NOT_IN_SYNC: HRESULT = 0xC0380003; +pub const ERROR_VOLMGR_PACK_CONFIG_UPDATE_FAILED: HRESULT = 0xC0380004; +pub const ERROR_VOLMGR_DISK_CONTAINS_NON_SIMPLE_VOLUME: HRESULT = 0xC0380005; +pub const ERROR_VOLMGR_DISK_DUPLICATE: HRESULT = 0xC0380006; +pub const ERROR_VOLMGR_DISK_DYNAMIC: HRESULT = 0xC0380007; +pub const ERROR_VOLMGR_DISK_ID_INVALID: HRESULT = 0xC0380008; +pub const ERROR_VOLMGR_DISK_INVALID: HRESULT = 0xC0380009; +pub const ERROR_VOLMGR_DISK_LAST_VOTER: HRESULT = 0xC038000A; +pub const ERROR_VOLMGR_DISK_LAYOUT_INVALID: HRESULT = 0xC038000B; +pub const ERROR_VOLMGR_DISK_LAYOUT_NON_BASIC_BETWEEN_BASIC_PARTITIONS: HRESULT + = 0xC038000C; +pub const ERROR_VOLMGR_DISK_LAYOUT_NOT_CYLINDER_ALIGNED: HRESULT = 0xC038000D; +pub const ERROR_VOLMGR_DISK_LAYOUT_PARTITIONS_TOO_SMALL: HRESULT = 0xC038000E; +pub const ERROR_VOLMGR_DISK_LAYOUT_PRIMARY_BETWEEN_LOGICAL_PARTITIONS: HRESULT + = 0xC038000F; +pub const ERROR_VOLMGR_DISK_LAYOUT_TOO_MANY_PARTITIONS: HRESULT = 0xC0380010; +pub const ERROR_VOLMGR_DISK_MISSING: HRESULT = 0xC0380011; +pub const ERROR_VOLMGR_DISK_NOT_EMPTY: HRESULT = 0xC0380012; +pub const ERROR_VOLMGR_DISK_NOT_ENOUGH_SPACE: HRESULT = 0xC0380013; +pub const ERROR_VOLMGR_DISK_REVECTORING_FAILED: HRESULT = 0xC0380014; +pub const ERROR_VOLMGR_DISK_SECTOR_SIZE_INVALID: HRESULT = 0xC0380015; +pub const ERROR_VOLMGR_DISK_SET_NOT_CONTAINED: HRESULT = 0xC0380016; +pub const ERROR_VOLMGR_DISK_USED_BY_MULTIPLE_MEMBERS: HRESULT = 0xC0380017; +pub const ERROR_VOLMGR_DISK_USED_BY_MULTIPLE_PLEXES: HRESULT = 0xC0380018; +pub const ERROR_VOLMGR_DYNAMIC_DISK_NOT_SUPPORTED: HRESULT = 0xC0380019; +pub const ERROR_VOLMGR_EXTENT_ALREADY_USED: HRESULT = 0xC038001A; +pub const ERROR_VOLMGR_EXTENT_NOT_CONTIGUOUS: HRESULT = 0xC038001B; +pub const ERROR_VOLMGR_EXTENT_NOT_IN_PUBLIC_REGION: HRESULT = 0xC038001C; +pub const ERROR_VOLMGR_EXTENT_NOT_SECTOR_ALIGNED: HRESULT = 0xC038001D; +pub const ERROR_VOLMGR_EXTENT_OVERLAPS_EBR_PARTITION: HRESULT = 0xC038001E; +pub const ERROR_VOLMGR_EXTENT_VOLUME_LENGTHS_DO_NOT_MATCH: HRESULT = 0xC038001F; +pub const ERROR_VOLMGR_FAULT_TOLERANT_NOT_SUPPORTED: HRESULT = 0xC0380020; +pub const ERROR_VOLMGR_INTERLEAVE_LENGTH_INVALID: HRESULT = 0xC0380021; +pub const ERROR_VOLMGR_MAXIMUM_REGISTERED_USERS: HRESULT = 0xC0380022; +pub const ERROR_VOLMGR_MEMBER_IN_SYNC: HRESULT = 0xC0380023; +pub const ERROR_VOLMGR_MEMBER_INDEX_DUPLICATE: HRESULT = 0xC0380024; +pub const ERROR_VOLMGR_MEMBER_INDEX_INVALID: HRESULT = 0xC0380025; +pub const ERROR_VOLMGR_MEMBER_MISSING: HRESULT = 0xC0380026; +pub const ERROR_VOLMGR_MEMBER_NOT_DETACHED: HRESULT = 0xC0380027; +pub const ERROR_VOLMGR_MEMBER_REGENERATING: HRESULT = 0xC0380028; +pub const ERROR_VOLMGR_ALL_DISKS_FAILED: HRESULT = 0xC0380029; +pub const ERROR_VOLMGR_NO_REGISTERED_USERS: HRESULT = 0xC038002A; +pub const ERROR_VOLMGR_NO_SUCH_USER: HRESULT = 0xC038002B; +pub const ERROR_VOLMGR_NOTIFICATION_RESET: HRESULT = 0xC038002C; +pub const ERROR_VOLMGR_NUMBER_OF_MEMBERS_INVALID: HRESULT = 0xC038002D; +pub const ERROR_VOLMGR_NUMBER_OF_PLEXES_INVALID: HRESULT = 0xC038002E; +pub const ERROR_VOLMGR_PACK_DUPLICATE: HRESULT = 0xC038002F; +pub const ERROR_VOLMGR_PACK_ID_INVALID: HRESULT = 0xC0380030; +pub const ERROR_VOLMGR_PACK_INVALID: HRESULT = 0xC0380031; +pub const ERROR_VOLMGR_PACK_NAME_INVALID: HRESULT = 0xC0380032; +pub const ERROR_VOLMGR_PACK_OFFLINE: HRESULT = 0xC0380033; +pub const ERROR_VOLMGR_PACK_HAS_QUORUM: HRESULT = 0xC0380034; +pub const ERROR_VOLMGR_PACK_WITHOUT_QUORUM: HRESULT = 0xC0380035; +pub const ERROR_VOLMGR_PARTITION_STYLE_INVALID: HRESULT = 0xC0380036; +pub const ERROR_VOLMGR_PARTITION_UPDATE_FAILED: HRESULT = 0xC0380037; +pub const ERROR_VOLMGR_PLEX_IN_SYNC: HRESULT = 0xC0380038; +pub const ERROR_VOLMGR_PLEX_INDEX_DUPLICATE: HRESULT = 0xC0380039; +pub const ERROR_VOLMGR_PLEX_INDEX_INVALID: HRESULT = 0xC038003A; +pub const ERROR_VOLMGR_PLEX_LAST_ACTIVE: HRESULT = 0xC038003B; +pub const ERROR_VOLMGR_PLEX_MISSING: HRESULT = 0xC038003C; +pub const ERROR_VOLMGR_PLEX_REGENERATING: HRESULT = 0xC038003D; +pub const ERROR_VOLMGR_PLEX_TYPE_INVALID: HRESULT = 0xC038003E; +pub const ERROR_VOLMGR_PLEX_NOT_RAID5: HRESULT = 0xC038003F; +pub const ERROR_VOLMGR_PLEX_NOT_SIMPLE: HRESULT = 0xC0380040; +pub const ERROR_VOLMGR_STRUCTURE_SIZE_INVALID: HRESULT = 0xC0380041; +pub const ERROR_VOLMGR_TOO_MANY_NOTIFICATION_REQUESTS: HRESULT = 0xC0380042; +pub const ERROR_VOLMGR_TRANSACTION_IN_PROGRESS: HRESULT = 0xC0380043; +pub const ERROR_VOLMGR_UNEXPECTED_DISK_LAYOUT_CHANGE: HRESULT = 0xC0380044; +pub const ERROR_VOLMGR_VOLUME_CONTAINS_MISSING_DISK: HRESULT = 0xC0380045; +pub const ERROR_VOLMGR_VOLUME_ID_INVALID: HRESULT = 0xC0380046; +pub const ERROR_VOLMGR_VOLUME_LENGTH_INVALID: HRESULT = 0xC0380047; +pub const ERROR_VOLMGR_VOLUME_LENGTH_NOT_SECTOR_SIZE_MULTIPLE: HRESULT = 0xC0380048; +pub const ERROR_VOLMGR_VOLUME_NOT_MIRRORED: HRESULT = 0xC0380049; +pub const ERROR_VOLMGR_VOLUME_NOT_RETAINED: HRESULT = 0xC038004A; +pub const ERROR_VOLMGR_VOLUME_OFFLINE: HRESULT = 0xC038004B; +pub const ERROR_VOLMGR_VOLUME_RETAINED: HRESULT = 0xC038004C; +pub const ERROR_VOLMGR_NUMBER_OF_EXTENTS_INVALID: HRESULT = 0xC038004D; +pub const ERROR_VOLMGR_DIFFERENT_SECTOR_SIZE: HRESULT = 0xC038004E; +pub const ERROR_VOLMGR_BAD_BOOT_DISK: HRESULT = 0xC038004F; +pub const ERROR_VOLMGR_PACK_CONFIG_OFFLINE: HRESULT = 0xC0380050; +pub const ERROR_VOLMGR_PACK_CONFIG_ONLINE: HRESULT = 0xC0380051; +pub const ERROR_VOLMGR_NOT_PRIMARY_PACK: HRESULT = 0xC0380052; +pub const ERROR_VOLMGR_PACK_LOG_UPDATE_FAILED: HRESULT = 0xC0380053; +pub const ERROR_VOLMGR_NUMBER_OF_DISKS_IN_PLEX_INVALID: HRESULT = 0xC0380054; +pub const ERROR_VOLMGR_NUMBER_OF_DISKS_IN_MEMBER_INVALID: HRESULT = 0xC0380055; +pub const ERROR_VOLMGR_VOLUME_MIRRORED: HRESULT = 0xC0380056; +pub const ERROR_VOLMGR_PLEX_NOT_SIMPLE_SPANNED: HRESULT = 0xC0380057; +pub const ERROR_VOLMGR_NO_VALID_LOG_COPIES: HRESULT = 0xC0380058; +pub const ERROR_VOLMGR_PRIMARY_PACK_PRESENT: HRESULT = 0xC0380059; +pub const ERROR_VOLMGR_NUMBER_OF_DISKS_INVALID: HRESULT = 0xC038005A; +pub const ERROR_VOLMGR_MIRROR_NOT_SUPPORTED: HRESULT = 0xC038005B; +pub const ERROR_VOLMGR_RAID5_NOT_SUPPORTED: HRESULT = 0xC038005C; +pub const ERROR_BCD_NOT_ALL_ENTRIES_IMPORTED: HRESULT = 0x80390001; +pub const ERROR_BCD_TOO_MANY_ELEMENTS: HRESULT = 0xC0390002; +pub const ERROR_BCD_NOT_ALL_ENTRIES_SYNCHRONIZED: HRESULT = 0x80390003; +pub const ERROR_VHD_DRIVE_FOOTER_MISSING: HRESULT = 0xC03A0001; +pub const ERROR_VHD_DRIVE_FOOTER_CHECKSUM_MISMATCH: HRESULT = 0xC03A0002; +pub const ERROR_VHD_DRIVE_FOOTER_CORRUPT: HRESULT = 0xC03A0003; +pub const ERROR_VHD_FORMAT_UNKNOWN: HRESULT = 0xC03A0004; +pub const ERROR_VHD_FORMAT_UNSUPPORTED_VERSION: HRESULT = 0xC03A0005; +pub const ERROR_VHD_SPARSE_HEADER_CHECKSUM_MISMATCH: HRESULT = 0xC03A0006; +pub const ERROR_VHD_SPARSE_HEADER_UNSUPPORTED_VERSION: HRESULT = 0xC03A0007; +pub const ERROR_VHD_SPARSE_HEADER_CORRUPT: HRESULT = 0xC03A0008; +pub const ERROR_VHD_BLOCK_ALLOCATION_FAILURE: HRESULT = 0xC03A0009; +pub const ERROR_VHD_BLOCK_ALLOCATION_TABLE_CORRUPT: HRESULT = 0xC03A000A; +pub const ERROR_VHD_INVALID_BLOCK_SIZE: HRESULT = 0xC03A000B; +pub const ERROR_VHD_BITMAP_MISMATCH: HRESULT = 0xC03A000C; +pub const ERROR_VHD_PARENT_VHD_NOT_FOUND: HRESULT = 0xC03A000D; +pub const ERROR_VHD_CHILD_PARENT_ID_MISMATCH: HRESULT = 0xC03A000E; +pub const ERROR_VHD_CHILD_PARENT_TIMESTAMP_MISMATCH: HRESULT = 0xC03A000F; +pub const ERROR_VHD_METADATA_READ_FAILURE: HRESULT = 0xC03A0010; +pub const ERROR_VHD_METADATA_WRITE_FAILURE: HRESULT = 0xC03A0011; +pub const ERROR_VHD_INVALID_SIZE: HRESULT = 0xC03A0012; +pub const ERROR_VHD_INVALID_FILE_SIZE: HRESULT = 0xC03A0013; +pub const ERROR_VIRTDISK_PROVIDER_NOT_FOUND: HRESULT = 0xC03A0014; +pub const ERROR_VIRTDISK_NOT_VIRTUAL_DISK: HRESULT = 0xC03A0015; +pub const ERROR_VHD_PARENT_VHD_ACCESS_DENIED: HRESULT = 0xC03A0016; +pub const ERROR_VHD_CHILD_PARENT_SIZE_MISMATCH: HRESULT = 0xC03A0017; +pub const ERROR_VHD_DIFFERENCING_CHAIN_CYCLE_DETECTED: HRESULT = 0xC03A0018; +pub const ERROR_VHD_DIFFERENCING_CHAIN_ERROR_IN_PARENT: HRESULT = 0xC03A0019; +pub const ERROR_VIRTUAL_DISK_LIMITATION: HRESULT = 0xC03A001A; +pub const ERROR_VHD_INVALID_TYPE: HRESULT = 0xC03A001B; +pub const ERROR_VHD_INVALID_STATE: HRESULT = 0xC03A001C; +pub const ERROR_VIRTDISK_UNSUPPORTED_DISK_SECTOR_SIZE: HRESULT = 0xC03A001D; +pub const ERROR_VIRTDISK_DISK_ALREADY_OWNED: HRESULT = 0xC03A001E; +pub const ERROR_VIRTDISK_DISK_ONLINE_AND_WRITABLE: HRESULT = 0xC03A001F; +pub const ERROR_CTLOG_TRACKING_NOT_INITIALIZED: HRESULT = 0xC03A0020; +pub const ERROR_CTLOG_LOGFILE_SIZE_EXCEEDED_MAXSIZE: HRESULT = 0xC03A0021; +pub const ERROR_CTLOG_VHD_CHANGED_OFFLINE: HRESULT = 0xC03A0022; +pub const ERROR_CTLOG_INVALID_TRACKING_STATE: HRESULT = 0xC03A0023; +pub const ERROR_CTLOG_INCONSISTENT_TRACKING_FILE: HRESULT = 0xC03A0024; +pub const ERROR_VHD_RESIZE_WOULD_TRUNCATE_DATA: HRESULT = 0xC03A0025; +pub const ERROR_VHD_COULD_NOT_COMPUTE_MINIMUM_VIRTUAL_SIZE: HRESULT = 0xC03A0026; +pub const ERROR_VHD_ALREADY_AT_OR_BELOW_MINIMUM_VIRTUAL_SIZE: HRESULT = 0xC03A0027; +pub const ERROR_VHD_METADATA_FULL: HRESULT = 0xC03A0028; +pub const ERROR_QUERY_STORAGE_ERROR: HRESULT = 0x803A0001; +pub const SDIAG_E_CANCELLED: HRESULT = 0x803C0100; +pub const SDIAG_E_SCRIPT: HRESULT = 0x803C0101; +pub const SDIAG_E_POWERSHELL: HRESULT = 0x803C0102; +pub const SDIAG_E_MANAGEDHOST: HRESULT = 0x803C0103; +pub const SDIAG_E_NOVERIFIER: HRESULT = 0x803C0104; +pub const SDIAG_S_CANNOTRUN: HRESULT = 0x003C0105; +pub const SDIAG_E_DISABLED: HRESULT = 0x803C0106; +pub const SDIAG_E_TRUST: HRESULT = 0x803C0107; +pub const SDIAG_E_CANNOTRUN: HRESULT = 0x803C0108; +pub const SDIAG_E_VERSION: HRESULT = 0x803C0109; +pub const SDIAG_E_RESOURCE: HRESULT = 0x803C010A; +pub const SDIAG_E_ROOTCAUSE: HRESULT = 0x803C010B; +pub const WPN_E_CHANNEL_CLOSED: HRESULT = 0x803E0100; +pub const WPN_E_CHANNEL_REQUEST_NOT_COMPLETE: HRESULT = 0x803E0101; +pub const WPN_E_INVALID_APP: HRESULT = 0x803E0102; +pub const WPN_E_OUTSTANDING_CHANNEL_REQUEST: HRESULT = 0x803E0103; +pub const WPN_E_DUPLICATE_CHANNEL: HRESULT = 0x803E0104; +pub const WPN_E_PLATFORM_UNAVAILABLE: HRESULT = 0x803E0105; +pub const WPN_E_NOTIFICATION_POSTED: HRESULT = 0x803E0106; +pub const WPN_E_NOTIFICATION_HIDDEN: HRESULT = 0x803E0107; +pub const WPN_E_NOTIFICATION_NOT_POSTED: HRESULT = 0x803E0108; +pub const WPN_E_CLOUD_DISABLED: HRESULT = 0x803E0109; +pub const WPN_E_CLOUD_INCAPABLE: HRESULT = 0x803E0110; +pub const WPN_E_CLOUD_AUTH_UNAVAILABLE: HRESULT = 0x803E011A; +pub const WPN_E_CLOUD_SERVICE_UNAVAILABLE: HRESULT = 0x803E011B; +pub const WPN_E_FAILED_LOCK_SCREEN_UPDATE_INTIALIZATION: HRESULT = 0x803E011C; +pub const WPN_E_NOTIFICATION_DISABLED: HRESULT = 0x803E0111; +pub const WPN_E_NOTIFICATION_INCAPABLE: HRESULT = 0x803E0112; +pub const WPN_E_INTERNET_INCAPABLE: HRESULT = 0x803E0113; +pub const WPN_E_NOTIFICATION_TYPE_DISABLED: HRESULT = 0x803E0114; +pub const WPN_E_NOTIFICATION_SIZE: HRESULT = 0x803E0115; +pub const WPN_E_TAG_SIZE: HRESULT = 0x803E0116; +pub const WPN_E_ACCESS_DENIED: HRESULT = 0x803E0117; +pub const WPN_E_DUPLICATE_REGISTRATION: HRESULT = 0x803E0118; +pub const WPN_E_PUSH_NOTIFICATION_INCAPABLE: HRESULT = 0x803E0119; +pub const WPN_E_DEV_ID_SIZE: HRESULT = 0x803E0120; +pub const WPN_E_TAG_ALPHANUMERIC: HRESULT = 0x803E012A; +pub const WPN_E_INVALID_HTTP_STATUS_CODE: HRESULT = 0x803E012B; +pub const WPN_E_OUT_OF_SESSION: HRESULT = 0x803E0200; +pub const WPN_E_POWER_SAVE: HRESULT = 0x803E0201; +pub const WPN_E_IMAGE_NOT_FOUND_IN_CACHE: HRESULT = 0x803E0202; +pub const WPN_E_ALL_URL_NOT_COMPLETED: HRESULT = 0x803E0203; +pub const WPN_E_INVALID_CLOUD_IMAGE: HRESULT = 0x803E0204; +pub const WPN_E_NOTIFICATION_ID_MATCHED: HRESULT = 0x803E0205; +pub const WPN_E_CALLBACK_ALREADY_REGISTERED: HRESULT = 0x803E0206; +pub const WPN_E_TOAST_NOTIFICATION_DROPPED: HRESULT = 0x803E0207; +pub const WPN_E_STORAGE_LOCKED: HRESULT = 0x803E0208; +pub const E_MBN_CONTEXT_NOT_ACTIVATED: HRESULT = 0x80548201; +pub const E_MBN_BAD_SIM: HRESULT = 0x80548202; +pub const E_MBN_DATA_CLASS_NOT_AVAILABLE: HRESULT = 0x80548203; +pub const E_MBN_INVALID_ACCESS_STRING: HRESULT = 0x80548204; +pub const E_MBN_MAX_ACTIVATED_CONTEXTS: HRESULT = 0x80548205; +pub const E_MBN_PACKET_SVC_DETACHED: HRESULT = 0x80548206; +pub const E_MBN_PROVIDER_NOT_VISIBLE: HRESULT = 0x80548207; +pub const E_MBN_RADIO_POWER_OFF: HRESULT = 0x80548208; +pub const E_MBN_SERVICE_NOT_ACTIVATED: HRESULT = 0x80548209; +pub const E_MBN_SIM_NOT_INSERTED: HRESULT = 0x8054820A; +pub const E_MBN_VOICE_CALL_IN_PROGRESS: HRESULT = 0x8054820B; +pub const E_MBN_INVALID_CACHE: HRESULT = 0x8054820C; +pub const E_MBN_NOT_REGISTERED: HRESULT = 0x8054820D; +pub const E_MBN_PROVIDERS_NOT_FOUND: HRESULT = 0x8054820E; +pub const E_MBN_PIN_NOT_SUPPORTED: HRESULT = 0x8054820F; +pub const E_MBN_PIN_REQUIRED: HRESULT = 0x80548210; +pub const E_MBN_PIN_DISABLED: HRESULT = 0x80548211; +pub const E_MBN_FAILURE: HRESULT = 0x80548212; +pub const E_MBN_INVALID_PROFILE: HRESULT = 0x80548218; +pub const E_MBN_DEFAULT_PROFILE_EXIST: HRESULT = 0x80548219; +pub const E_MBN_SMS_ENCODING_NOT_SUPPORTED: HRESULT = 0x80548220; +pub const E_MBN_SMS_FILTER_NOT_SUPPORTED: HRESULT = 0x80548221; +pub const E_MBN_SMS_INVALID_MEMORY_INDEX: HRESULT = 0x80548222; +pub const E_MBN_SMS_LANG_NOT_SUPPORTED: HRESULT = 0x80548223; +pub const E_MBN_SMS_MEMORY_FAILURE: HRESULT = 0x80548224; +pub const E_MBN_SMS_NETWORK_TIMEOUT: HRESULT = 0x80548225; +pub const E_MBN_SMS_UNKNOWN_SMSC_ADDRESS: HRESULT = 0x80548226; +pub const E_MBN_SMS_FORMAT_NOT_SUPPORTED: HRESULT = 0x80548227; +pub const E_MBN_SMS_OPERATION_NOT_ALLOWED: HRESULT = 0x80548228; +pub const E_MBN_SMS_MEMORY_FULL: HRESULT = 0x80548229; +pub const PEER_E_IPV6_NOT_INSTALLED: HRESULT = 0x80630001; +pub const PEER_E_NOT_INITIALIZED: HRESULT = 0x80630002; +pub const PEER_E_CANNOT_START_SERVICE: HRESULT = 0x80630003; +pub const PEER_E_NOT_LICENSED: HRESULT = 0x80630004; +pub const PEER_E_INVALID_GRAPH: HRESULT = 0x80630010; +pub const PEER_E_DBNAME_CHANGED: HRESULT = 0x80630011; +pub const PEER_E_DUPLICATE_GRAPH: HRESULT = 0x80630012; +pub const PEER_E_GRAPH_NOT_READY: HRESULT = 0x80630013; +pub const PEER_E_GRAPH_SHUTTING_DOWN: HRESULT = 0x80630014; +pub const PEER_E_GRAPH_IN_USE: HRESULT = 0x80630015; +pub const PEER_E_INVALID_DATABASE: HRESULT = 0x80630016; +pub const PEER_E_TOO_MANY_ATTRIBUTES: HRESULT = 0x80630017; +pub const PEER_E_CONNECTION_NOT_FOUND: HRESULT = 0x80630103; +pub const PEER_E_CONNECT_SELF: HRESULT = 0x80630106; +pub const PEER_E_ALREADY_LISTENING: HRESULT = 0x80630107; +pub const PEER_E_NODE_NOT_FOUND: HRESULT = 0x80630108; +pub const PEER_E_CONNECTION_FAILED: HRESULT = 0x80630109; +pub const PEER_E_CONNECTION_NOT_AUTHENTICATED: HRESULT = 0x8063010A; +pub const PEER_E_CONNECTION_REFUSED: HRESULT = 0x8063010B; +pub const PEER_E_CLASSIFIER_TOO_LONG: HRESULT = 0x80630201; +pub const PEER_E_TOO_MANY_IDENTITIES: HRESULT = 0x80630202; +pub const PEER_E_NO_KEY_ACCESS: HRESULT = 0x80630203; +pub const PEER_E_GROUPS_EXIST: HRESULT = 0x80630204; +pub const PEER_E_RECORD_NOT_FOUND: HRESULT = 0x80630301; +pub const PEER_E_DATABASE_ACCESSDENIED: HRESULT = 0x80630302; +pub const PEER_E_DBINITIALIZATION_FAILED: HRESULT = 0x80630303; +pub const PEER_E_MAX_RECORD_SIZE_EXCEEDED: HRESULT = 0x80630304; +pub const PEER_E_DATABASE_ALREADY_PRESENT: HRESULT = 0x80630305; +pub const PEER_E_DATABASE_NOT_PRESENT: HRESULT = 0x80630306; +pub const PEER_E_IDENTITY_NOT_FOUND: HRESULT = 0x80630401; +pub const PEER_E_EVENT_HANDLE_NOT_FOUND: HRESULT = 0x80630501; +pub const PEER_E_INVALID_SEARCH: HRESULT = 0x80630601; +pub const PEER_E_INVALID_ATTRIBUTES: HRESULT = 0x80630602; +pub const PEER_E_INVITATION_NOT_TRUSTED: HRESULT = 0x80630701; +pub const PEER_E_CHAIN_TOO_LONG: HRESULT = 0x80630703; +pub const PEER_E_INVALID_TIME_PERIOD: HRESULT = 0x80630705; +pub const PEER_E_CIRCULAR_CHAIN_DETECTED: HRESULT = 0x80630706; +pub const PEER_E_CERT_STORE_CORRUPTED: HRESULT = 0x80630801; +pub const PEER_E_NO_CLOUD: HRESULT = 0x80631001; +pub const PEER_E_CLOUD_NAME_AMBIGUOUS: HRESULT = 0x80631005; +pub const PEER_E_INVALID_RECORD: HRESULT = 0x80632010; +pub const PEER_E_NOT_AUTHORIZED: HRESULT = 0x80632020; +pub const PEER_E_PASSWORD_DOES_NOT_MEET_POLICY: HRESULT = 0x80632021; +pub const PEER_E_DEFERRED_VALIDATION: HRESULT = 0x80632030; +pub const PEER_E_INVALID_GROUP_PROPERTIES: HRESULT = 0x80632040; +pub const PEER_E_INVALID_PEER_NAME: HRESULT = 0x80632050; +pub const PEER_E_INVALID_CLASSIFIER: HRESULT = 0x80632060; +pub const PEER_E_INVALID_FRIENDLY_NAME: HRESULT = 0x80632070; +pub const PEER_E_INVALID_ROLE_PROPERTY: HRESULT = 0x80632071; +pub const PEER_E_INVALID_CLASSIFIER_PROPERTY: HRESULT = 0x80632072; +pub const PEER_E_INVALID_RECORD_EXPIRATION: HRESULT = 0x80632080; +pub const PEER_E_INVALID_CREDENTIAL_INFO: HRESULT = 0x80632081; +pub const PEER_E_INVALID_CREDENTIAL: HRESULT = 0x80632082; +pub const PEER_E_INVALID_RECORD_SIZE: HRESULT = 0x80632083; +pub const PEER_E_UNSUPPORTED_VERSION: HRESULT = 0x80632090; +pub const PEER_E_GROUP_NOT_READY: HRESULT = 0x80632091; +pub const PEER_E_GROUP_IN_USE: HRESULT = 0x80632092; +pub const PEER_E_INVALID_GROUP: HRESULT = 0x80632093; +pub const PEER_E_NO_MEMBERS_FOUND: HRESULT = 0x80632094; +pub const PEER_E_NO_MEMBER_CONNECTIONS: HRESULT = 0x80632095; +pub const PEER_E_UNABLE_TO_LISTEN: HRESULT = 0x80632096; +pub const PEER_E_IDENTITY_DELETED: HRESULT = 0x806320A0; +pub const PEER_E_SERVICE_NOT_AVAILABLE: HRESULT = 0x806320A1; +pub const PEER_E_CONTACT_NOT_FOUND: HRESULT = 0x80636001; +pub const PEER_S_GRAPH_DATA_CREATED: HRESULT = 0x00630001; +pub const PEER_S_NO_EVENT_DATA: HRESULT = 0x00630002; +pub const PEER_S_ALREADY_CONNECTED: HRESULT = 0x00632000; +pub const PEER_S_SUBSCRIPTION_EXISTS: HRESULT = 0x00636000; +pub const PEER_S_NO_CONNECTIVITY: HRESULT = 0x00630005; +pub const PEER_S_ALREADY_A_MEMBER: HRESULT = 0x00630006; +pub const PEER_E_CANNOT_CONVERT_PEER_NAME: HRESULT = 0x80634001; +pub const PEER_E_INVALID_PEER_HOST_NAME: HRESULT = 0x80634002; +pub const PEER_E_NO_MORE: HRESULT = 0x80634003; +pub const PEER_E_PNRP_DUPLICATE_PEER_NAME: HRESULT = 0x80634005; +pub const PEER_E_INVITE_CANCELLED: HRESULT = 0x80637000; +pub const PEER_E_INVITE_RESPONSE_NOT_AVAILABLE: HRESULT = 0x80637001; +pub const PEER_E_NOT_SIGNED_IN: HRESULT = 0x80637003; +pub const PEER_E_PRIVACY_DECLINED: HRESULT = 0x80637004; +pub const PEER_E_TIMEOUT: HRESULT = 0x80637005; +pub const PEER_E_INVALID_ADDRESS: HRESULT = 0x80637007; +pub const PEER_E_FW_EXCEPTION_DISABLED: HRESULT = 0x80637008; +pub const PEER_E_FW_BLOCKED_BY_POLICY: HRESULT = 0x80637009; +pub const PEER_E_FW_BLOCKED_BY_SHIELDS_UP: HRESULT = 0x8063700A; +pub const PEER_E_FW_DECLINED: HRESULT = 0x8063700B; +pub const UI_E_CREATE_FAILED: HRESULT = 0x802A0001; +pub const UI_E_SHUTDOWN_CALLED: HRESULT = 0x802A0002; +pub const UI_E_ILLEGAL_REENTRANCY: HRESULT = 0x802A0003; +pub const UI_E_OBJECT_SEALED: HRESULT = 0x802A0004; +pub const UI_E_VALUE_NOT_SET: HRESULT = 0x802A0005; +pub const UI_E_VALUE_NOT_DETERMINED: HRESULT = 0x802A0006; +pub const UI_E_INVALID_OUTPUT: HRESULT = 0x802A0007; +pub const UI_E_BOOLEAN_EXPECTED: HRESULT = 0x802A0008; +pub const UI_E_DIFFERENT_OWNER: HRESULT = 0x802A0009; +pub const UI_E_AMBIGUOUS_MATCH: HRESULT = 0x802A000A; +pub const UI_E_FP_OVERFLOW: HRESULT = 0x802A000B; +pub const UI_E_WRONG_THREAD: HRESULT = 0x802A000C; +pub const UI_E_STORYBOARD_ACTIVE: HRESULT = 0x802A0101; +pub const UI_E_STORYBOARD_NOT_PLAYING: HRESULT = 0x802A0102; +pub const UI_E_START_KEYFRAME_AFTER_END: HRESULT = 0x802A0103; +pub const UI_E_END_KEYFRAME_NOT_DETERMINED: HRESULT = 0x802A0104; +pub const UI_E_LOOPS_OVERLAP: HRESULT = 0x802A0105; +pub const UI_E_TRANSITION_ALREADY_USED: HRESULT = 0x802A0106; +pub const UI_E_TRANSITION_NOT_IN_STORYBOARD: HRESULT = 0x802A0107; +pub const UI_E_TRANSITION_ECLIPSED: HRESULT = 0x802A0108; +pub const UI_E_TIME_BEFORE_LAST_UPDATE: HRESULT = 0x802A0109; +pub const UI_E_TIMER_CLIENT_ALREADY_CONNECTED: HRESULT = 0x802A010A; +pub const UI_E_INVALID_DIMENSION: HRESULT = 0x802A010B; +pub const UI_E_PRIMITIVE_OUT_OF_BOUNDS: HRESULT = 0x802A010C; +pub const UI_E_WINDOW_CLOSED: HRESULT = 0x802A0201; +pub const E_BLUETOOTH_ATT_INVALID_HANDLE: HRESULT = 0x80650001; +pub const E_BLUETOOTH_ATT_READ_NOT_PERMITTED: HRESULT = 0x80650002; +pub const E_BLUETOOTH_ATT_WRITE_NOT_PERMITTED: HRESULT = 0x80650003; +pub const E_BLUETOOTH_ATT_INVALID_PDU: HRESULT = 0x80650004; +pub const E_BLUETOOTH_ATT_INSUFFICIENT_AUTHENTICATION: HRESULT = 0x80650005; +pub const E_BLUETOOTH_ATT_REQUEST_NOT_SUPPORTED: HRESULT = 0x80650006; +pub const E_BLUETOOTH_ATT_INVALID_OFFSET: HRESULT = 0x80650007; +pub const E_BLUETOOTH_ATT_INSUFFICIENT_AUTHORIZATION: HRESULT = 0x80650008; +pub const E_BLUETOOTH_ATT_PREPARE_QUEUE_FULL: HRESULT = 0x80650009; +pub const E_BLUETOOTH_ATT_ATTRIBUTE_NOT_FOUND: HRESULT = 0x8065000A; +pub const E_BLUETOOTH_ATT_ATTRIBUTE_NOT_LONG: HRESULT = 0x8065000B; +pub const E_BLUETOOTH_ATT_INSUFFICIENT_ENCRYPTION_KEY_SIZE: HRESULT = 0x8065000C; +pub const E_BLUETOOTH_ATT_INVALID_ATTRIBUTE_VALUE_LENGTH: HRESULT = 0x8065000D; +pub const E_BLUETOOTH_ATT_UNLIKELY: HRESULT = 0x8065000E; +pub const E_BLUETOOTH_ATT_INSUFFICIENT_ENCRYPTION: HRESULT = 0x8065000F; +pub const E_BLUETOOTH_ATT_UNSUPPORTED_GROUP_TYPE: HRESULT = 0x80650010; +pub const E_BLUETOOTH_ATT_INSUFFICIENT_RESOURCES: HRESULT = 0x80650011; +pub const E_BLUETOOTH_ATT_UNKNOWN_ERROR: HRESULT = 0x80651000; +pub const E_AUDIO_ENGINE_NODE_NOT_FOUND: HRESULT = 0x80660001; +pub const E_HDAUDIO_EMPTY_CONNECTION_LIST: HRESULT = 0x80660002; +pub const E_HDAUDIO_CONNECTION_LIST_NOT_SUPPORTED: HRESULT = 0x80660003; +pub const E_HDAUDIO_NO_LOGICAL_DEVICES_CREATED: HRESULT = 0x80660004; +pub const E_HDAUDIO_NULL_LINKED_LIST_ENTRY: HRESULT = 0x80660005; +pub const ERROR_SPACES_POOL_WAS_DELETED: HRESULT = 0x00E70001; +pub const ERROR_SPACES_RESILIENCY_TYPE_INVALID: HRESULT = 0x80E70003; +pub const ERROR_SPACES_DRIVE_SECTOR_SIZE_INVALID: HRESULT = 0x80E70004; +pub const ERROR_SPACES_DRIVE_REDUNDANCY_INVALID: HRESULT = 0x80E70006; +pub const ERROR_SPACES_NUMBER_OF_DATA_COPIES_INVALID: HRESULT = 0x80E70007; +pub const ERROR_SPACES_PARITY_LAYOUT_INVALID: HRESULT = 0x80E70008; +pub const ERROR_SPACES_INTERLEAVE_LENGTH_INVALID: HRESULT = 0x80E70009; +pub const ERROR_SPACES_NUMBER_OF_COLUMNS_INVALID: HRESULT = 0x80E7000A; +pub const ERROR_SPACES_NOT_ENOUGH_DRIVES: HRESULT = 0x80E7000B; +pub const ERROR_VOLSNAP_BOOTFILE_NOT_VALID: HRESULT = 0x80820001; +pub const ERROR_TIERING_NOT_SUPPORTED_ON_VOLUME: HRESULT = 0x80830001; +pub const ERROR_TIERING_VOLUME_DISMOUNT_IN_PROGRESS: HRESULT = 0x80830002; +pub const ERROR_TIERING_STORAGE_TIER_NOT_FOUND: HRESULT = 0x80830003; +pub const ERROR_TIERING_INVALID_FILE_ID: HRESULT = 0x80830004; +pub const ERROR_TIERING_WRONG_CLUSTER_NODE: HRESULT = 0x80830005; +pub const ERROR_TIERING_ALREADY_PROCESSING: HRESULT = 0x80830006; +pub const ERROR_TIERING_CANNOT_PIN_OBJECT: HRESULT = 0x80830007; +pub const DXGI_STATUS_OCCLUDED: HRESULT = 0x087A0001; +pub const DXGI_STATUS_CLIPPED: HRESULT = 0x087A0002; +pub const DXGI_STATUS_NO_REDIRECTION: HRESULT = 0x087A0004; +pub const DXGI_STATUS_NO_DESKTOP_ACCESS: HRESULT = 0x087A0005; +pub const DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE: HRESULT = 0x087A0006; +pub const DXGI_STATUS_MODE_CHANGED: HRESULT = 0x087A0007; +pub const DXGI_STATUS_MODE_CHANGE_IN_PROGRESS: HRESULT = 0x087A0008; +pub const DXGI_ERROR_INVALID_CALL: HRESULT = 0x887A0001; +pub const DXGI_ERROR_NOT_FOUND: HRESULT = 0x887A0002; +pub const DXGI_ERROR_MORE_DATA: HRESULT = 0x887A0003; +pub const DXGI_ERROR_UNSUPPORTED: HRESULT = 0x887A0004; +pub const DXGI_ERROR_DEVICE_REMOVED: HRESULT = 0x887A0005; +pub const DXGI_ERROR_DEVICE_HUNG: HRESULT = 0x887A0006; +pub const DXGI_ERROR_DEVICE_RESET: HRESULT = 0x887A0007; +pub const DXGI_ERROR_WAS_STILL_DRAWING: HRESULT = 0x887A000A; +pub const DXGI_ERROR_FRAME_STATISTICS_DISJOINT: HRESULT = 0x887A000B; +pub const DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE: HRESULT = 0x887A000C; +pub const DXGI_ERROR_DRIVER_INTERNAL_ERROR: HRESULT = 0x887A0020; +pub const DXGI_ERROR_NONEXCLUSIVE: HRESULT = 0x887A0021; +pub const DXGI_ERROR_NOT_CURRENTLY_AVAILABLE: HRESULT = 0x887A0022; +pub const DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED: HRESULT = 0x887A0023; +pub const DXGI_ERROR_REMOTE_OUTOFMEMORY: HRESULT = 0x887A0024; +pub const DXGI_ERROR_ACCESS_LOST: HRESULT = 0x887A0026; +pub const DXGI_ERROR_WAIT_TIMEOUT: HRESULT = 0x887A0027; +pub const DXGI_ERROR_SESSION_DISCONNECTED: HRESULT = 0x887A0028; +pub const DXGI_ERROR_RESTRICT_TO_OUTPUT_STALE: HRESULT = 0x887A0029; +pub const DXGI_ERROR_CANNOT_PROTECT_CONTENT: HRESULT = 0x887A002A; +pub const DXGI_ERROR_ACCESS_DENIED: HRESULT = 0x887A002B; +pub const DXGI_ERROR_NAME_ALREADY_EXISTS: HRESULT = 0x887A002C; +pub const DXGI_ERROR_SDK_COMPONENT_MISSING: HRESULT = 0x887A002D; +pub const DXGI_STATUS_UNOCCLUDED: HRESULT = 0x087A0009; +pub const DXGI_STATUS_DDA_WAS_STILL_DRAWING: HRESULT = 0x087A000A; +pub const DXGI_ERROR_MODE_CHANGE_IN_PROGRESS: HRESULT = 0x887A0025; +pub const DXGI_DDI_ERR_WASSTILLDRAWING: HRESULT = 0x887B0001; +pub const DXGI_DDI_ERR_UNSUPPORTED: HRESULT = 0x887B0002; +pub const DXGI_DDI_ERR_NONEXCLUSIVE: HRESULT = 0x887B0003; +pub const D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS: HRESULT = 0x88790001; +pub const D3D10_ERROR_FILE_NOT_FOUND: HRESULT = 0x88790002; +pub const D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS: HRESULT = 0x887C0001; +pub const D3D11_ERROR_FILE_NOT_FOUND: HRESULT = 0x887C0002; +pub const D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS: HRESULT = 0x887C0003; +pub const D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD: HRESULT + = 0x887C0004; +pub const D2DERR_WRONG_STATE: HRESULT = 0x88990001; +pub const D2DERR_NOT_INITIALIZED: HRESULT = 0x88990002; +pub const D2DERR_UNSUPPORTED_OPERATION: HRESULT = 0x88990003; +pub const D2DERR_SCANNER_FAILED: HRESULT = 0x88990004; +pub const D2DERR_SCREEN_ACCESS_DENIED: HRESULT = 0x88990005; +pub const D2DERR_DISPLAY_STATE_INVALID: HRESULT = 0x88990006; +pub const D2DERR_ZERO_VECTOR: HRESULT = 0x88990007; +pub const D2DERR_INTERNAL_ERROR: HRESULT = 0x88990008; +pub const D2DERR_DISPLAY_FORMAT_NOT_SUPPORTED: HRESULT = 0x88990009; +pub const D2DERR_INVALID_CALL: HRESULT = 0x8899000A; +pub const D2DERR_NO_HARDWARE_DEVICE: HRESULT = 0x8899000B; +pub const D2DERR_RECREATE_TARGET: HRESULT = 0x8899000C; +pub const D2DERR_TOO_MANY_SHADER_ELEMENTS: HRESULT = 0x8899000D; +pub const D2DERR_SHADER_COMPILE_FAILED: HRESULT = 0x8899000E; +pub const D2DERR_MAX_TEXTURE_SIZE_EXCEEDED: HRESULT = 0x8899000F; +pub const D2DERR_UNSUPPORTED_VERSION: HRESULT = 0x88990010; +pub const D2DERR_BAD_NUMBER: HRESULT = 0x88990011; +pub const D2DERR_WRONG_FACTORY: HRESULT = 0x88990012; +pub const D2DERR_LAYER_ALREADY_IN_USE: HRESULT = 0x88990013; +pub const D2DERR_POP_CALL_DID_NOT_MATCH_PUSH: HRESULT = 0x88990014; +pub const D2DERR_WRONG_RESOURCE_DOMAIN: HRESULT = 0x88990015; +pub const D2DERR_PUSH_POP_UNBALANCED: HRESULT = 0x88990016; +pub const D2DERR_RENDER_TARGET_HAS_LAYER_OR_CLIPRECT: HRESULT = 0x88990017; +pub const D2DERR_INCOMPATIBLE_BRUSH_TYPES: HRESULT = 0x88990018; +pub const D2DERR_WIN32_ERROR: HRESULT = 0x88990019; +pub const D2DERR_TARGET_NOT_GDI_COMPATIBLE: HRESULT = 0x8899001A; +pub const D2DERR_TEXT_EFFECT_IS_WRONG_TYPE: HRESULT = 0x8899001B; +pub const D2DERR_TEXT_RENDERER_NOT_RELEASED: HRESULT = 0x8899001C; +pub const D2DERR_EXCEEDS_MAX_BITMAP_SIZE: HRESULT = 0x8899001D; +pub const D2DERR_INVALID_GRAPH_CONFIGURATION: HRESULT = 0x8899001E; +pub const D2DERR_INVALID_INTERNAL_GRAPH_CONFIGURATION: HRESULT = 0x8899001F; +pub const D2DERR_CYCLIC_GRAPH: HRESULT = 0x88990020; +pub const D2DERR_BITMAP_CANNOT_DRAW: HRESULT = 0x88990021; +pub const D2DERR_OUTSTANDING_BITMAP_REFERENCES: HRESULT = 0x88990022; +pub const D2DERR_ORIGINAL_TARGET_NOT_BOUND: HRESULT = 0x88990023; +pub const D2DERR_INVALID_TARGET: HRESULT = 0x88990024; +pub const D2DERR_BITMAP_BOUND_AS_TARGET: HRESULT = 0x88990025; +pub const D2DERR_INSUFFICIENT_DEVICE_CAPABILITIES: HRESULT = 0x88990026; +pub const D2DERR_INTERMEDIATE_TOO_LARGE: HRESULT = 0x88990027; +pub const D2DERR_EFFECT_IS_NOT_REGISTERED: HRESULT = 0x88990028; +pub const D2DERR_INVALID_PROPERTY: HRESULT = 0x88990029; +pub const D2DERR_NO_SUBPROPERTIES: HRESULT = 0x8899002A; +pub const D2DERR_PRINT_JOB_CLOSED: HRESULT = 0x8899002B; +pub const D2DERR_PRINT_FORMAT_NOT_SUPPORTED: HRESULT = 0x8899002C; +pub const D2DERR_TOO_MANY_TRANSFORM_INPUTS: HRESULT = 0x8899002D; +pub const DWRITE_E_FILEFORMAT: HRESULT = 0x88985000; +pub const DWRITE_E_UNEXPECTED: HRESULT = 0x88985001; +pub const DWRITE_E_NOFONT: HRESULT = 0x88985002; +pub const DWRITE_E_FILENOTFOUND: HRESULT = 0x88985003; +pub const DWRITE_E_FILEACCESS: HRESULT = 0x88985004; +pub const DWRITE_E_FONTCOLLECTIONOBSOLETE: HRESULT = 0x88985005; +pub const DWRITE_E_ALREADYREGISTERED: HRESULT = 0x88985006; +pub const DWRITE_E_CACHEFORMAT: HRESULT = 0x88985007; +pub const DWRITE_E_CACHEVERSION: HRESULT = 0x88985008; +pub const DWRITE_E_UNSUPPORTEDOPERATION: HRESULT = 0x88985009; +pub const DWRITE_E_TEXTRENDERERINCOMPATIBLE: HRESULT = 0x8898500A; +pub const DWRITE_E_FLOWDIRECTIONCONFLICTS: HRESULT = 0x8898500B; +pub const DWRITE_E_NOCOLOR: HRESULT = 0x8898500C; +pub const WINCODEC_ERR_WRONGSTATE: HRESULT = 0x88982F04; +pub const WINCODEC_ERR_VALUEOUTOFRANGE: HRESULT = 0x88982F05; +pub const WINCODEC_ERR_UNKNOWNIMAGEFORMAT: HRESULT = 0x88982F07; +pub const WINCODEC_ERR_UNSUPPORTEDVERSION: HRESULT = 0x88982F0B; +pub const WINCODEC_ERR_NOTINITIALIZED: HRESULT = 0x88982F0C; +pub const WINCODEC_ERR_ALREADYLOCKED: HRESULT = 0x88982F0D; +pub const WINCODEC_ERR_PROPERTYNOTFOUND: HRESULT = 0x88982F40; +pub const WINCODEC_ERR_PROPERTYNOTSUPPORTED: HRESULT = 0x88982F41; +pub const WINCODEC_ERR_PROPERTYSIZE: HRESULT = 0x88982F42; +pub const WINCODEC_ERR_CODECPRESENT: HRESULT = 0x88982F43; +pub const WINCODEC_ERR_CODECNOTHUMBNAIL: HRESULT = 0x88982F44; +pub const WINCODEC_ERR_PALETTEUNAVAILABLE: HRESULT = 0x88982F45; +pub const WINCODEC_ERR_CODECTOOMANYSCANLINES: HRESULT = 0x88982F46; +pub const WINCODEC_ERR_INTERNALERROR: HRESULT = 0x88982F48; +pub const WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS: HRESULT = 0x88982F49; +pub const WINCODEC_ERR_COMPONENTNOTFOUND: HRESULT = 0x88982F50; +pub const WINCODEC_ERR_IMAGESIZEOUTOFRANGE: HRESULT = 0x88982F51; +pub const WINCODEC_ERR_TOOMUCHMETADATA: HRESULT = 0x88982F52; +pub const WINCODEC_ERR_BADIMAGE: HRESULT = 0x88982F60; +pub const WINCODEC_ERR_BADHEADER: HRESULT = 0x88982F61; +pub const WINCODEC_ERR_FRAMEMISSING: HRESULT = 0x88982F62; +pub const WINCODEC_ERR_BADMETADATAHEADER: HRESULT = 0x88982F63; +pub const WINCODEC_ERR_BADSTREAMDATA: HRESULT = 0x88982F70; +pub const WINCODEC_ERR_STREAMWRITE: HRESULT = 0x88982F71; +pub const WINCODEC_ERR_STREAMREAD: HRESULT = 0x88982F72; +pub const WINCODEC_ERR_STREAMNOTAVAILABLE: HRESULT = 0x88982F73; +pub const WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT: HRESULT = 0x88982F80; +pub const WINCODEC_ERR_UNSUPPORTEDOPERATION: HRESULT = 0x88982F81; +pub const WINCODEC_ERR_INVALIDREGISTRATION: HRESULT = 0x88982F8A; +pub const WINCODEC_ERR_COMPONENTINITIALIZEFAILURE: HRESULT = 0x88982F8B; +pub const WINCODEC_ERR_INSUFFICIENTBUFFER: HRESULT = 0x88982F8C; +pub const WINCODEC_ERR_DUPLICATEMETADATAPRESENT: HRESULT = 0x88982F8D; +pub const WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE: HRESULT = 0x88982F8E; +pub const WINCODEC_ERR_UNEXPECTEDSIZE: HRESULT = 0x88982F8F; +pub const WINCODEC_ERR_INVALIDQUERYREQUEST: HRESULT = 0x88982F90; +pub const WINCODEC_ERR_UNEXPECTEDMETADATATYPE: HRESULT = 0x88982F91; +pub const WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT: HRESULT = 0x88982F92; +pub const WINCODEC_ERR_INVALIDQUERYCHARACTER: HRESULT = 0x88982F93; +pub const WINCODEC_ERR_WIN32ERROR: HRESULT = 0x88982F94; +pub const WINCODEC_ERR_INVALIDPROGRESSIVELEVEL: HRESULT = 0x88982F95; +pub const MILERR_OBJECTBUSY: HRESULT = 0x88980001; +pub const MILERR_INSUFFICIENTBUFFER: HRESULT = 0x88980002; +pub const MILERR_WIN32ERROR: HRESULT = 0x88980003; +pub const MILERR_SCANNER_FAILED: HRESULT = 0x88980004; +pub const MILERR_SCREENACCESSDENIED: HRESULT = 0x88980005; +pub const MILERR_DISPLAYSTATEINVALID: HRESULT = 0x88980006; +pub const MILERR_NONINVERTIBLEMATRIX: HRESULT = 0x88980007; +pub const MILERR_ZEROVECTOR: HRESULT = 0x88980008; +pub const MILERR_TERMINATED: HRESULT = 0x88980009; +pub const MILERR_BADNUMBER: HRESULT = 0x8898000A; +pub const MILERR_INTERNALERROR: HRESULT = 0x88980080; +pub const MILERR_DISPLAYFORMATNOTSUPPORTED: HRESULT = 0x88980084; +pub const MILERR_INVALIDCALL: HRESULT = 0x88980085; +pub const MILERR_ALREADYLOCKED: HRESULT = 0x88980086; +pub const MILERR_NOTLOCKED: HRESULT = 0x88980087; +pub const MILERR_DEVICECANNOTRENDERTEXT: HRESULT = 0x88980088; +pub const MILERR_GLYPHBITMAPMISSED: HRESULT = 0x88980089; +pub const MILERR_MALFORMEDGLYPHCACHE: HRESULT = 0x8898008A; +pub const MILERR_GENERIC_IGNORE: HRESULT = 0x8898008B; +pub const MILERR_MALFORMED_GUIDELINE_DATA: HRESULT = 0x8898008C; +pub const MILERR_NO_HARDWARE_DEVICE: HRESULT = 0x8898008D; +pub const MILERR_NEED_RECREATE_AND_PRESENT: HRESULT = 0x8898008E; +pub const MILERR_ALREADY_INITIALIZED: HRESULT = 0x8898008F; +pub const MILERR_MISMATCHED_SIZE: HRESULT = 0x88980090; +pub const MILERR_NO_REDIRECTION_SURFACE_AVAILABLE: HRESULT = 0x88980091; +pub const MILERR_REMOTING_NOT_SUPPORTED: HRESULT = 0x88980092; +pub const MILERR_QUEUED_PRESENT_NOT_SUPPORTED: HRESULT = 0x88980093; +pub const MILERR_NOT_QUEUING_PRESENTS: HRESULT = 0x88980094; +pub const MILERR_NO_REDIRECTION_SURFACE_RETRY_LATER: HRESULT = 0x88980095; +pub const MILERR_TOOMANYSHADERELEMNTS: HRESULT = 0x88980096; +pub const MILERR_MROW_READLOCK_FAILED: HRESULT = 0x88980097; +pub const MILERR_MROW_UPDATE_FAILED: HRESULT = 0x88980098; +pub const MILERR_SHADER_COMPILE_FAILED: HRESULT = 0x88980099; +pub const MILERR_MAX_TEXTURE_SIZE_EXCEEDED: HRESULT = 0x8898009A; +pub const MILERR_QPC_TIME_WENT_BACKWARD: HRESULT = 0x8898009B; +pub const MILERR_DXGI_ENUMERATION_OUT_OF_SYNC: HRESULT = 0x8898009D; +pub const MILERR_ADAPTER_NOT_FOUND: HRESULT = 0x8898009E; +pub const MILERR_COLORSPACE_NOT_SUPPORTED: HRESULT = 0x8898009F; +pub const MILERR_PREFILTER_NOT_SUPPORTED: HRESULT = 0x889800A0; +pub const MILERR_DISPLAYID_ACCESS_DENIED: HRESULT = 0x889800A1; +pub const UCEERR_INVALIDPACKETHEADER: HRESULT = 0x88980400; +pub const UCEERR_UNKNOWNPACKET: HRESULT = 0x88980401; +pub const UCEERR_ILLEGALPACKET: HRESULT = 0x88980402; +pub const UCEERR_MALFORMEDPACKET: HRESULT = 0x88980403; +pub const UCEERR_ILLEGALHANDLE: HRESULT = 0x88980404; +pub const UCEERR_HANDLELOOKUPFAILED: HRESULT = 0x88980405; +pub const UCEERR_RENDERTHREADFAILURE: HRESULT = 0x88980406; +pub const UCEERR_CTXSTACKFRSTTARGETNULL: HRESULT = 0x88980407; +pub const UCEERR_CONNECTIONIDLOOKUPFAILED: HRESULT = 0x88980408; +pub const UCEERR_BLOCKSFULL: HRESULT = 0x88980409; +pub const UCEERR_MEMORYFAILURE: HRESULT = 0x8898040A; +pub const UCEERR_PACKETRECORDOUTOFRANGE: HRESULT = 0x8898040B; +pub const UCEERR_ILLEGALRECORDTYPE: HRESULT = 0x8898040C; +pub const UCEERR_OUTOFHANDLES: HRESULT = 0x8898040D; +pub const UCEERR_UNCHANGABLE_UPDATE_ATTEMPTED: HRESULT = 0x8898040E; +pub const UCEERR_NO_MULTIPLE_WORKER_THREADS: HRESULT = 0x8898040F; +pub const UCEERR_REMOTINGNOTSUPPORTED: HRESULT = 0x88980410; +pub const UCEERR_MISSINGENDCOMMAND: HRESULT = 0x88980411; +pub const UCEERR_MISSINGBEGINCOMMAND: HRESULT = 0x88980412; +pub const UCEERR_CHANNELSYNCTIMEDOUT: HRESULT = 0x88980413; +pub const UCEERR_CHANNELSYNCABANDONED: HRESULT = 0x88980414; +pub const UCEERR_UNSUPPORTEDTRANSPORTVERSION: HRESULT = 0x88980415; +pub const UCEERR_TRANSPORTUNAVAILABLE: HRESULT = 0x88980416; +pub const UCEERR_FEEDBACK_UNSUPPORTED: HRESULT = 0x88980417; +pub const UCEERR_COMMANDTRANSPORTDENIED: HRESULT = 0x88980418; +pub const UCEERR_GRAPHICSSTREAMUNAVAILABLE: HRESULT = 0x88980419; +pub const UCEERR_GRAPHICSSTREAMALREADYOPEN: HRESULT = 0x88980420; +pub const UCEERR_TRANSPORTDISCONNECTED: HRESULT = 0x88980421; +pub const UCEERR_TRANSPORTOVERLOADED: HRESULT = 0x88980422; +pub const UCEERR_PARTITION_ZOMBIED: HRESULT = 0x88980423; +pub const MILAVERR_NOCLOCK: HRESULT = 0x88980500; +pub const MILAVERR_NOMEDIATYPE: HRESULT = 0x88980501; +pub const MILAVERR_NOVIDEOMIXER: HRESULT = 0x88980502; +pub const MILAVERR_NOVIDEOPRESENTER: HRESULT = 0x88980503; +pub const MILAVERR_NOREADYFRAMES: HRESULT = 0x88980504; +pub const MILAVERR_MODULENOTLOADED: HRESULT = 0x88980505; +pub const MILAVERR_WMPFACTORYNOTREGISTERED: HRESULT = 0x88980506; +pub const MILAVERR_INVALIDWMPVERSION: HRESULT = 0x88980507; +pub const MILAVERR_INSUFFICIENTVIDEORESOURCES: HRESULT = 0x88980508; +pub const MILAVERR_VIDEOACCELERATIONNOTAVAILABLE: HRESULT = 0x88980509; +pub const MILAVERR_REQUESTEDTEXTURETOOBIG: HRESULT = 0x8898050A; +pub const MILAVERR_SEEKFAILED: HRESULT = 0x8898050B; +pub const MILAVERR_UNEXPECTEDWMPFAILURE: HRESULT = 0x8898050C; +pub const MILAVERR_MEDIAPLAYERCLOSED: HRESULT = 0x8898050D; +pub const MILAVERR_UNKNOWNHARDWAREERROR: HRESULT = 0x8898050E; +pub const MILEFFECTSERR_UNKNOWNPROPERTY: HRESULT = 0x8898060E; +pub const MILEFFECTSERR_EFFECTNOTPARTOFGROUP: HRESULT = 0x8898060F; +pub const MILEFFECTSERR_NOINPUTSOURCEATTACHED: HRESULT = 0x88980610; +pub const MILEFFECTSERR_CONNECTORNOTCONNECTED: HRESULT = 0x88980611; +pub const MILEFFECTSERR_CONNECTORNOTASSOCIATEDWITHEFFECT: HRESULT = 0x88980612; +pub const MILEFFECTSERR_RESERVED: HRESULT = 0x88980613; +pub const MILEFFECTSERR_CYCLEDETECTED: HRESULT = 0x88980614; +pub const MILEFFECTSERR_EFFECTINMORETHANONEGRAPH: HRESULT = 0x88980615; +pub const MILEFFECTSERR_EFFECTALREADYINAGRAPH: HRESULT = 0x88980616; +pub const MILEFFECTSERR_EFFECTHASNOCHILDREN: HRESULT = 0x88980617; +pub const MILEFFECTSERR_ALREADYATTACHEDTOLISTENER: HRESULT = 0x88980618; +pub const MILEFFECTSERR_NOTAFFINETRANSFORM: HRESULT = 0x88980619; +pub const MILEFFECTSERR_EMPTYBOUNDS: HRESULT = 0x8898061A; +pub const MILEFFECTSERR_OUTPUTSIZETOOLARGE: HRESULT = 0x8898061B; +pub const DWMERR_STATE_TRANSITION_FAILED: HRESULT = 0x88980700; +pub const DWMERR_THEME_FAILED: HRESULT = 0x88980701; +pub const DWMERR_CATASTROPHIC_FAILURE: HRESULT = 0x88980702; +pub const DCOMPOSITION_ERROR_WINDOW_ALREADY_COMPOSED: HRESULT = 0x88980800; +pub const DCOMPOSITION_ERROR_SURFACE_BEING_RENDERED: HRESULT = 0x88980801; +pub const DCOMPOSITION_ERROR_SURFACE_NOT_BEING_RENDERED: HRESULT = 0x88980802; +pub const ONL_E_INVALID_AUTHENTICATION_TARGET: HRESULT = 0x80860001; +pub const ONL_E_ACCESS_DENIED_BY_TOU: HRESULT = 0x80860002; +pub const ONL_E_INVALID_APPLICATION: HRESULT = 0x80860003; +pub const ONL_E_PASSWORD_UPDATE_REQUIRED: HRESULT = 0x80860004; +pub const ONL_E_ACCOUNT_UPDATE_REQUIRED: HRESULT = 0x80860005; +pub const ONL_E_FORCESIGNIN: HRESULT = 0x80860006; +pub const ONL_E_ACCOUNT_LOCKED: HRESULT = 0x80860007; +pub const ONL_E_PARENTAL_CONSENT_REQUIRED: HRESULT = 0x80860008; +pub const ONL_E_EMAIL_VERIFICATION_REQUIRED: HRESULT = 0x80860009; +pub const ONL_E_ACCOUNT_SUSPENDED_COMPROIMISE: HRESULT = 0x8086000A; +pub const ONL_E_ACCOUNT_SUSPENDED_ABUSE: HRESULT = 0x8086000B; +pub const ONL_E_ACTION_REQUIRED: HRESULT = 0x8086000C; +pub const ONL_CONNECTION_COUNT_LIMIT: HRESULT = 0x8086000D; +pub const ONL_E_CONNECTED_ACCOUNT_CAN_NOT_SIGNOUT: HRESULT = 0x8086000E; +pub const ONL_E_USER_AUTHENTICATION_REQUIRED: HRESULT = 0x8086000F; +pub const ONL_E_REQUEST_THROTTLED: HRESULT = 0x80860010; +pub const FA_E_MAX_PERSISTED_ITEMS_REACHED: HRESULT = 0x80270220; +pub const FA_E_HOMEGROUP_NOT_AVAILABLE: HRESULT = 0x80270222; +pub const E_MONITOR_RESOLUTION_TOO_LOW: HRESULT = 0x80270250; +pub const E_ELEVATED_ACTIVATION_NOT_SUPPORTED: HRESULT = 0x80270251; +pub const E_UAC_DISABLED: HRESULT = 0x80270252; +pub const E_FULL_ADMIN_NOT_SUPPORTED: HRESULT = 0x80270253; +pub const E_APPLICATION_NOT_REGISTERED: HRESULT = 0x80270254; +pub const E_MULTIPLE_EXTENSIONS_FOR_APPLICATION: HRESULT = 0x80270255; +pub const E_MULTIPLE_PACKAGES_FOR_FAMILY: HRESULT = 0x80270256; +pub const E_APPLICATION_MANAGER_NOT_RUNNING: HRESULT = 0x80270257; +pub const S_STORE_LAUNCHED_FOR_REMEDIATION: HRESULT = 0x00270258; +pub const S_APPLICATION_ACTIVATION_ERROR_HANDLED_BY_DIALOG: HRESULT = 0x00270259; +pub const E_APPLICATION_ACTIVATION_TIMED_OUT: HRESULT = 0x8027025A; +pub const E_APPLICATION_ACTIVATION_EXEC_FAILURE: HRESULT = 0x8027025B; +pub const E_APPLICATION_TEMPORARY_LICENSE_ERROR: HRESULT = 0x8027025C; +pub const E_APPLICATION_TRIAL_LICENSE_EXPIRED: HRESULT = 0x8027025D; +pub const E_SKYDRIVE_ROOT_TARGET_FILE_SYSTEM_NOT_SUPPORTED: HRESULT = 0x80270260; +pub const E_SKYDRIVE_ROOT_TARGET_OVERLAP: HRESULT = 0x80270261; +pub const E_SKYDRIVE_ROOT_TARGET_CANNOT_INDEX: HRESULT = 0x80270262; +pub const E_SKYDRIVE_FILE_NOT_UPLOADED: HRESULT = 0x80270263; +pub const E_SKYDRIVE_UPDATE_AVAILABILITY_FAIL: HRESULT = 0x80270264; +pub const E_SKYDRIVE_ROOT_TARGET_VOLUME_ROOT_NOT_SUPPORTED: HRESULT = 0x80270265; +pub const E_SYNCENGINE_FILE_SIZE_OVER_LIMIT: HRESULT = 0x8802B001; +pub const E_SYNCENGINE_FILE_SIZE_EXCEEDS_REMAINING_QUOTA: HRESULT = 0x8802B002; +pub const E_SYNCENGINE_UNSUPPORTED_FILE_NAME: HRESULT = 0x8802B003; +pub const E_SYNCENGINE_FOLDER_ITEM_COUNT_LIMIT_EXCEEDED: HRESULT = 0x8802B004; +pub const E_SYNCENGINE_FILE_SYNC_PARTNER_ERROR: HRESULT = 0x8802B005; +pub const E_SYNCENGINE_SYNC_PAUSED_BY_SERVICE: HRESULT = 0x8802B006; +pub const E_SYNCENGINE_FILE_IDENTIFIER_UNKNOWN: HRESULT = 0x8802C002; +pub const E_SYNCENGINE_SERVICE_AUTHENTICATION_FAILED: HRESULT = 0x8802C003; +pub const E_SYNCENGINE_UNKNOWN_SERVICE_ERROR: HRESULT = 0x8802C004; +pub const E_SYNCENGINE_SERVICE_RETURNED_UNEXPECTED_SIZE: HRESULT = 0x8802C005; +pub const E_SYNCENGINE_REQUEST_BLOCKED_BY_SERVICE: HRESULT = 0x8802C006; +pub const E_SYNCENGINE_REQUEST_BLOCKED_DUE_TO_CLIENT_ERROR: HRESULT = 0x8802C007; +pub const E_SYNCENGINE_FOLDER_INACCESSIBLE: HRESULT = 0x8802D001; +pub const E_SYNCENGINE_UNSUPPORTED_FOLDER_NAME: HRESULT = 0x8802D002; +pub const E_SYNCENGINE_UNSUPPORTED_MARKET: HRESULT = 0x8802D003; +pub const E_SYNCENGINE_PATH_LENGTH_LIMIT_EXCEEDED: HRESULT = 0x8802D004; +pub const E_SYNCENGINE_REMOTE_PATH_LENGTH_LIMIT_EXCEEDED: HRESULT = 0x8802D005; +pub const E_SYNCENGINE_CLIENT_UPDATE_NEEDED: HRESULT = 0x8802D006; +pub const E_SYNCENGINE_PROXY_AUTHENTICATION_REQUIRED: HRESULT = 0x8802D007; +pub const E_SYNCENGINE_STORAGE_SERVICE_PROVISIONING_FAILED: HRESULT = 0x8802D008; +pub const E_SYNCENGINE_UNSUPPORTED_REPARSE_POINT: HRESULT = 0x8802D009; +pub const E_SYNCENGINE_STORAGE_SERVICE_BLOCKED: HRESULT = 0x8802D00A; +pub const E_SYNCENGINE_FOLDER_IN_REDIRECTION: HRESULT = 0x8802D00B; +pub const EAS_E_POLICY_NOT_MANAGED_BY_OS: HRESULT = 0x80550001; +pub const EAS_E_POLICY_COMPLIANT_WITH_ACTIONS: HRESULT = 0x80550002; +pub const EAS_E_REQUESTED_POLICY_NOT_ENFORCEABLE: HRESULT = 0x80550003; +pub const EAS_E_CURRENT_USER_HAS_BLANK_PASSWORD: HRESULT = 0x80550004; +pub const EAS_E_REQUESTED_POLICY_PASSWORD_EXPIRATION_INCOMPATIBLE: HRESULT + = 0x80550005; +pub const EAS_E_USER_CANNOT_CHANGE_PASSWORD: HRESULT = 0x80550006; +pub const EAS_E_ADMINS_HAVE_BLANK_PASSWORD: HRESULT = 0x80550007; +pub const EAS_E_ADMINS_CANNOT_CHANGE_PASSWORD: HRESULT = 0x80550008; +pub const EAS_E_LOCAL_CONTROLLED_USERS_CANNOT_CHANGE_PASSWORD: HRESULT = 0x80550009; +pub const EAS_E_PASSWORD_POLICY_NOT_ENFORCEABLE_FOR_CONNECTED_ADMINS: HRESULT + = 0x8055000A; +pub const EAS_E_CONNECTED_ADMINS_NEED_TO_CHANGE_PASSWORD: HRESULT = 0x8055000B; +pub const EAS_E_PASSWORD_POLICY_NOT_ENFORCEABLE_FOR_CURRENT_CONNECTED_USER: HRESULT + = 0x8055000C; +pub const EAS_E_CURRENT_CONNECTED_USER_NEED_TO_CHANGE_PASSWORD: HRESULT = 0x8055000D; +pub const WEB_E_UNSUPPORTED_FORMAT: HRESULT = 0x83750001; +pub const WEB_E_INVALID_XML: HRESULT = 0x83750002; +pub const WEB_E_MISSING_REQUIRED_ELEMENT: HRESULT = 0x83750003; +pub const WEB_E_MISSING_REQUIRED_ATTRIBUTE: HRESULT = 0x83750004; +pub const WEB_E_UNEXPECTED_CONTENT: HRESULT = 0x83750005; +pub const WEB_E_RESOURCE_TOO_LARGE: HRESULT = 0x83750006; +pub const WEB_E_INVALID_JSON_STRING: HRESULT = 0x83750007; +pub const WEB_E_INVALID_JSON_NUMBER: HRESULT = 0x83750008; +pub const WEB_E_JSON_VALUE_NOT_FOUND: HRESULT = 0x83750009; +pub const HTTP_E_STATUS_UNEXPECTED: HRESULT = 0x80190001; +pub const HTTP_E_STATUS_UNEXPECTED_REDIRECTION: HRESULT = 0x80190003; +pub const HTTP_E_STATUS_UNEXPECTED_CLIENT_ERROR: HRESULT = 0x80190004; +pub const HTTP_E_STATUS_UNEXPECTED_SERVER_ERROR: HRESULT = 0x80190005; +pub const HTTP_E_STATUS_AMBIGUOUS: HRESULT = 0x8019012C; +pub const HTTP_E_STATUS_MOVED: HRESULT = 0x8019012D; +pub const HTTP_E_STATUS_REDIRECT: HRESULT = 0x8019012E; +pub const HTTP_E_STATUS_REDIRECT_METHOD: HRESULT = 0x8019012F; +pub const HTTP_E_STATUS_NOT_MODIFIED: HRESULT = 0x80190130; +pub const HTTP_E_STATUS_USE_PROXY: HRESULT = 0x80190131; +pub const HTTP_E_STATUS_REDIRECT_KEEP_VERB: HRESULT = 0x80190133; +pub const HTTP_E_STATUS_BAD_REQUEST: HRESULT = 0x80190190; +pub const HTTP_E_STATUS_DENIED: HRESULT = 0x80190191; +pub const HTTP_E_STATUS_PAYMENT_REQ: HRESULT = 0x80190192; +pub const HTTP_E_STATUS_FORBIDDEN: HRESULT = 0x80190193; +pub const HTTP_E_STATUS_NOT_FOUND: HRESULT = 0x80190194; +pub const HTTP_E_STATUS_BAD_METHOD: HRESULT = 0x80190195; +pub const HTTP_E_STATUS_NONE_ACCEPTABLE: HRESULT = 0x80190196; +pub const HTTP_E_STATUS_PROXY_AUTH_REQ: HRESULT = 0x80190197; +pub const HTTP_E_STATUS_REQUEST_TIMEOUT: HRESULT = 0x80190198; +pub const HTTP_E_STATUS_CONFLICT: HRESULT = 0x80190199; +pub const HTTP_E_STATUS_GONE: HRESULT = 0x8019019A; +pub const HTTP_E_STATUS_LENGTH_REQUIRED: HRESULT = 0x8019019B; +pub const HTTP_E_STATUS_PRECOND_FAILED: HRESULT = 0x8019019C; +pub const HTTP_E_STATUS_REQUEST_TOO_LARGE: HRESULT = 0x8019019D; +pub const HTTP_E_STATUS_URI_TOO_LONG: HRESULT = 0x8019019E; +pub const HTTP_E_STATUS_UNSUPPORTED_MEDIA: HRESULT = 0x8019019F; +pub const HTTP_E_STATUS_RANGE_NOT_SATISFIABLE: HRESULT = 0x801901A0; +pub const HTTP_E_STATUS_EXPECTATION_FAILED: HRESULT = 0x801901A1; +pub const HTTP_E_STATUS_SERVER_ERROR: HRESULT = 0x801901F4; +pub const HTTP_E_STATUS_NOT_SUPPORTED: HRESULT = 0x801901F5; +pub const HTTP_E_STATUS_BAD_GATEWAY: HRESULT = 0x801901F6; +pub const HTTP_E_STATUS_SERVICE_UNAVAIL: HRESULT = 0x801901F7; +pub const HTTP_E_STATUS_GATEWAY_TIMEOUT: HRESULT = 0x801901F8; +pub const HTTP_E_STATUS_VERSION_NOT_SUP: HRESULT = 0x801901F9; +pub const E_INVALID_PROTOCOL_OPERATION: HRESULT = 0x83760001; +pub const E_INVALID_PROTOCOL_FORMAT: HRESULT = 0x83760002; +pub const E_PROTOCOL_EXTENSIONS_NOT_SUPPORTED: HRESULT = 0x83760003; +pub const E_SUBPROTOCOL_NOT_SUPPORTED: HRESULT = 0x83760004; +pub const E_PROTOCOL_VERSION_NOT_SUPPORTED: HRESULT = 0x83760005; +pub const INPUT_E_OUT_OF_ORDER: HRESULT = 0x80400000; +pub const INPUT_E_REENTRANCY: HRESULT = 0x80400001; +pub const INPUT_E_MULTIMODAL: HRESULT = 0x80400002; +pub const INPUT_E_PACKET: HRESULT = 0x80400003; +pub const INPUT_E_FRAME: HRESULT = 0x80400004; +pub const INPUT_E_HISTORY: HRESULT = 0x80400005; +pub const INPUT_E_DEVICE_INFO: HRESULT = 0x80400006; +pub const INPUT_E_TRANSFORM: HRESULT = 0x80400007; +pub const INPUT_E_DEVICE_PROPERTY: HRESULT = 0x80400008; +pub const INET_E_INVALID_URL: HRESULT = 0x800C0002; +pub const INET_E_NO_SESSION: HRESULT = 0x800C0003; +pub const INET_E_CANNOT_CONNECT: HRESULT = 0x800C0004; +pub const INET_E_RESOURCE_NOT_FOUND: HRESULT = 0x800C0005; +pub const INET_E_OBJECT_NOT_FOUND: HRESULT = 0x800C0006; +pub const INET_E_DATA_NOT_AVAILABLE: HRESULT = 0x800C0007; +pub const INET_E_DOWNLOAD_FAILURE: HRESULT = 0x800C0008; +pub const INET_E_AUTHENTICATION_REQUIRED: HRESULT = 0x800C0009; +pub const INET_E_NO_VALID_MEDIA: HRESULT = 0x800C000A; +pub const INET_E_CONNECTION_TIMEOUT: HRESULT = 0x800C000B; +pub const INET_E_INVALID_REQUEST: HRESULT = 0x800C000C; +pub const INET_E_UNKNOWN_PROTOCOL: HRESULT = 0x800C000D; +pub const INET_E_SECURITY_PROBLEM: HRESULT = 0x800C000E; +pub const INET_E_CANNOT_LOAD_DATA: HRESULT = 0x800C000F; +pub const INET_E_CANNOT_INSTANTIATE_OBJECT: HRESULT = 0x800C0010; +pub const INET_E_INVALID_CERTIFICATE: HRESULT = 0x800C0019; +pub const INET_E_REDIRECT_FAILED: HRESULT = 0x800C0014; +pub const INET_E_REDIRECT_TO_DIR: HRESULT = 0x800C0015; +pub const ERROR_DBG_CREATE_PROCESS_FAILURE_LOCKDOWN: HRESULT = 0x80B00001; +pub const ERROR_DBG_ATTACH_PROCESS_FAILURE_LOCKDOWN: HRESULT = 0x80B00002; +pub const ERROR_DBG_CONNECT_SERVER_FAILURE_LOCKDOWN: HRESULT = 0x80B00003; +pub const ERROR_DBG_START_SERVER_FAILURE_LOCKDOWN: HRESULT = 0x80B00004; +pub const ERROR_IO_PREEMPTED: HRESULT = 0x89010001; +pub const JSCRIPT_E_CANTEXECUTE: HRESULT = 0x89020001; +pub const WEP_E_NOT_PROVISIONED_ON_ALL_VOLUMES: HRESULT = 0x88010001; +pub const WEP_E_FIXED_DATA_NOT_SUPPORTED: HRESULT = 0x88010002; +pub const WEP_E_HARDWARE_NOT_COMPLIANT: HRESULT = 0x88010003; +pub const WEP_E_LOCK_NOT_CONFIGURED: HRESULT = 0x88010004; +pub const WEP_E_PROTECTION_SUSPENDED: HRESULT = 0x88010005; +pub const WEP_E_NO_LICENSE: HRESULT = 0x88010006; +pub const WEP_E_OS_NOT_PROTECTED: HRESULT = 0x88010007; +pub const WEP_E_UNEXPECTED_FAIL: HRESULT = 0x88010008; +pub const WEP_E_BUFFER_TOO_LARGE: HRESULT = 0x88010009; +pub const ERROR_SVHDX_ERROR_STORED: HRESULT = 0xC05C0000; +pub const ERROR_SVHDX_ERROR_NOT_AVAILABLE: HRESULT = 0xC05CFF00; +pub const ERROR_SVHDX_UNIT_ATTENTION_AVAILABLE: HRESULT = 0xC05CFF01; +pub const ERROR_SVHDX_UNIT_ATTENTION_CAPACITY_DATA_CHANGED: HRESULT = 0xC05CFF02; +pub const ERROR_SVHDX_UNIT_ATTENTION_RESERVATIONS_PREEMPTED: HRESULT = 0xC05CFF03; +pub const ERROR_SVHDX_UNIT_ATTENTION_RESERVATIONS_RELEASED: HRESULT = 0xC05CFF04; +pub const ERROR_SVHDX_UNIT_ATTENTION_REGISTRATIONS_PREEMPTED: HRESULT = 0xC05CFF05; +pub const ERROR_SVHDX_UNIT_ATTENTION_OPERATING_DEFINITION_CHANGED: HRESULT + = 0xC05CFF06; +pub const ERROR_SVHDX_RESERVATION_CONFLICT: HRESULT = 0xC05CFF07; +pub const ERROR_SVHDX_WRONG_FILE_TYPE: HRESULT = 0xC05CFF08; +pub const ERROR_SVHDX_VERSION_MISMATCH: HRESULT = 0xC05CFF09; +pub const ERROR_VHD_SHARED: HRESULT = 0xC05CFF0A; +pub const WININET_E_OUT_OF_HANDLES: HRESULT = 0x80072EE1; +pub const WININET_E_TIMEOUT: HRESULT = 0x80072EE2; +pub const WININET_E_EXTENDED_ERROR: HRESULT = 0x80072EE3; +pub const WININET_E_INTERNAL_ERROR: HRESULT = 0x80072EE4; +pub const WININET_E_INVALID_URL: HRESULT = 0x80072EE5; +pub const WININET_E_UNRECOGNIZED_SCHEME: HRESULT = 0x80072EE6; +pub const WININET_E_NAME_NOT_RESOLVED: HRESULT = 0x80072EE7; +pub const WININET_E_PROTOCOL_NOT_FOUND: HRESULT = 0x80072EE8; +pub const WININET_E_INVALID_OPTION: HRESULT = 0x80072EE9; +pub const WININET_E_BAD_OPTION_LENGTH: HRESULT = 0x80072EEA; +pub const WININET_E_OPTION_NOT_SETTABLE: HRESULT = 0x80072EEB; +pub const WININET_E_SHUTDOWN: HRESULT = 0x80072EEC; +pub const WININET_E_INCORRECT_USER_NAME: HRESULT = 0x80072EED; +pub const WININET_E_INCORRECT_PASSWORD: HRESULT = 0x80072EEE; +pub const WININET_E_LOGIN_FAILURE: HRESULT = 0x80072EEF; +pub const WININET_E_INVALID_OPERATION: HRESULT = 0x80072EF0; +pub const WININET_E_OPERATION_CANCELLED: HRESULT = 0x80072EF1; +pub const WININET_E_INCORRECT_HANDLE_TYPE: HRESULT = 0x80072EF2; +pub const WININET_E_INCORRECT_HANDLE_STATE: HRESULT = 0x80072EF3; +pub const WININET_E_NOT_PROXY_REQUEST: HRESULT = 0x80072EF4; +pub const WININET_E_REGISTRY_VALUE_NOT_FOUND: HRESULT = 0x80072EF5; +pub const WININET_E_BAD_REGISTRY_PARAMETER: HRESULT = 0x80072EF6; +pub const WININET_E_NO_DIRECT_ACCESS: HRESULT = 0x80072EF7; +pub const WININET_E_NO_CONTEXT: HRESULT = 0x80072EF8; +pub const WININET_E_NO_CALLBACK: HRESULT = 0x80072EF9; +pub const WININET_E_REQUEST_PENDING: HRESULT = 0x80072EFA; +pub const WININET_E_INCORRECT_FORMAT: HRESULT = 0x80072EFB; +pub const WININET_E_ITEM_NOT_FOUND: HRESULT = 0x80072EFC; +pub const WININET_E_CANNOT_CONNECT: HRESULT = 0x80072EFD; +pub const WININET_E_CONNECTION_ABORTED: HRESULT = 0x80072EFE; +pub const WININET_E_CONNECTION_RESET: HRESULT = 0x80072EFF; +pub const WININET_E_FORCE_RETRY: HRESULT = 0x80072F00; +pub const WININET_E_INVALID_PROXY_REQUEST: HRESULT = 0x80072F01; +pub const WININET_E_NEED_UI: HRESULT = 0x80072F02; +pub const WININET_E_HANDLE_EXISTS: HRESULT = 0x80072F04; +pub const WININET_E_SEC_CERT_DATE_INVALID: HRESULT = 0x80072F05; +pub const WININET_E_SEC_CERT_CN_INVALID: HRESULT = 0x80072F06; +pub const WININET_E_HTTP_TO_HTTPS_ON_REDIR: HRESULT = 0x80072F07; +pub const WININET_E_HTTPS_TO_HTTP_ON_REDIR: HRESULT = 0x80072F08; +pub const WININET_E_MIXED_SECURITY: HRESULT = 0x80072F09; +pub const WININET_E_CHG_POST_IS_NON_SECURE: HRESULT = 0x80072F0A; +pub const WININET_E_POST_IS_NON_SECURE: HRESULT = 0x80072F0B; +pub const WININET_E_CLIENT_AUTH_CERT_NEEDED: HRESULT = 0x80072F0C; +pub const WININET_E_INVALID_CA: HRESULT = 0x80072F0D; +pub const WININET_E_CLIENT_AUTH_NOT_SETUP: HRESULT = 0x80072F0E; +pub const WININET_E_ASYNC_THREAD_FAILED: HRESULT = 0x80072F0F; +pub const WININET_E_REDIRECT_SCHEME_CHANGE: HRESULT = 0x80072F10; +pub const WININET_E_DIALOG_PENDING: HRESULT = 0x80072F11; +pub const WININET_E_RETRY_DIALOG: HRESULT = 0x80072F12; +pub const WININET_E_NO_NEW_CONTAINERS: HRESULT = 0x80072F13; +pub const WININET_E_HTTPS_HTTP_SUBMIT_REDIR: HRESULT = 0x80072F14; +pub const WININET_E_SEC_CERT_ERRORS: HRESULT = 0x80072F17; +pub const WININET_E_SEC_CERT_REV_FAILED: HRESULT = 0x80072F19; +pub const WININET_E_HEADER_NOT_FOUND: HRESULT = 0x80072F76; +pub const WININET_E_DOWNLEVEL_SERVER: HRESULT = 0x80072F77; +pub const WININET_E_INVALID_SERVER_RESPONSE: HRESULT = 0x80072F78; +pub const WININET_E_INVALID_HEADER: HRESULT = 0x80072F79; +pub const WININET_E_INVALID_QUERY_REQUEST: HRESULT = 0x80072F7A; +pub const WININET_E_HEADER_ALREADY_EXISTS: HRESULT = 0x80072F7B; +pub const WININET_E_REDIRECT_FAILED: HRESULT = 0x80072F7C; +pub const WININET_E_SECURITY_CHANNEL_ERROR: HRESULT = 0x80072F7D; +pub const WININET_E_UNABLE_TO_CACHE_FILE: HRESULT = 0x80072F7E; +pub const WININET_E_TCPIP_NOT_INSTALLED: HRESULT = 0x80072F7F; +pub const WININET_E_DISCONNECTED: HRESULT = 0x80072F83; +pub const WININET_E_SERVER_UNREACHABLE: HRESULT = 0x80072F84; +pub const WININET_E_PROXY_SERVER_UNREACHABLE: HRESULT = 0x80072F85; +pub const WININET_E_BAD_AUTO_PROXY_SCRIPT: HRESULT = 0x80072F86; +pub const WININET_E_UNABLE_TO_DOWNLOAD_SCRIPT: HRESULT = 0x80072F87; +pub const WININET_E_SEC_INVALID_CERT: HRESULT = 0x80072F89; +pub const WININET_E_SEC_CERT_REVOKED: HRESULT = 0x80072F8A; +pub const WININET_E_FAILED_DUETOSECURITYCHECK: HRESULT = 0x80072F8B; +pub const WININET_E_NOT_INITIALIZED: HRESULT = 0x80072F8C; +pub const WININET_E_LOGIN_FAILURE_DISPLAY_ENTITY_BODY: HRESULT = 0x80072F8E; +pub const WININET_E_DECODING_FAILED: HRESULT = 0x80072F8F; +pub const WININET_E_NOT_REDIRECTED: HRESULT = 0x80072F80; +pub const WININET_E_COOKIE_NEEDS_CONFIRMATION: HRESULT = 0x80072F81; +pub const WININET_E_COOKIE_DECLINED: HRESULT = 0x80072F82; +pub const WININET_E_REDIRECT_NEEDS_CONFIRMATION: HRESULT = 0x80072F88; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/winusbio.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/winusbio.rs new file mode 100644 index 0000000..8006943 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/winusbio.rs @@ -0,0 +1,38 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Public header for WINUSB +use shared::minwindef::{UCHAR, ULONG, USHORT}; +use shared::usb::USBD_PIPE_TYPE; +pub const SHORT_PACKET_TERMINATE: ULONG = 0x01; +pub const AUTO_CLEAR_STALL: ULONG = 0x02; +pub const PIPE_TRANSFER_TIMEOUT: ULONG = 0x03; +pub const IGNORE_SHORT_PACKETS: ULONG = 0x04; +pub const ALLOW_PARTIAL_READS: ULONG = 0x05; +pub const AUTO_FLUSH: ULONG = 0x06; +pub const RAW_IO: ULONG = 0x07; +pub const MAXIMUM_TRANSFER_SIZE: ULONG = 0x08; +pub const RESET_PIPE_ON_RESUME: ULONG = 0x09; +pub const DEVICE_SPEED: ULONG = 0x01; +pub const LowSpeed: ULONG = 0x01; +pub const FullSpeed: ULONG = 0x02; +pub const HighSpeed: ULONG = 0x03; +DEFINE_GUID!{WinUSB_TestGuid, + 0xda812bff, 0x12c3, 0x46a2, 0x8e, 0x2b, 0xdb, 0xd3, 0xb7, 0x83, 0x4c, 0x43} +STRUCT!{struct WINUSB_PIPE_INFORMATION { + PipeType: USBD_PIPE_TYPE, + PipeId: UCHAR, + MaximumPacketSize: USHORT, + Interval: UCHAR, +}} +pub type PWINUSB_PIPE_INFORMATION = *mut WINUSB_PIPE_INFORMATION; +STRUCT!{struct WINUSB_PIPE_INFORMATION_EX { + PipeType: USBD_PIPE_TYPE, + PipeId: UCHAR, + MaximumPacketSize: USHORT, + Interval: UCHAR, + MaximumBytesPerInterval: ULONG, +}} +pub type PWINUSB_PIPE_INFORMATION_EX = *mut WINUSB_PIPE_INFORMATION_EX; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/wmistr.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/wmistr.rs new file mode 100644 index 0000000..35374e9 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/wmistr.rs @@ -0,0 +1,199 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{ULONG64, ULONG_PTR}; +use shared::guiddef::GUID; +use shared::minwindef::{UCHAR, ULONG}; +use um::winnt::{HANDLE, LARGE_INTEGER, STANDARD_RIGHTS_READ, SYNCHRONIZE, WCHAR}; +STRUCT!{struct WNODE_HEADER_u1_s { + Version: ULONG, + Linkage: ULONG, +}} +UNION!{union WNODE_HEADER_u1 { + [u64; 1], + HistoricalContext HistoricalContext_mut: ULONG64, + s s_mut: WNODE_HEADER_u1_s, +}} +UNION!{union WNODE_HEADER_u2 { + [u64; 1], + CountLost CountLost_mut: ULONG, + KernelHandle KernelHandle_mut: HANDLE, + TimeStamp TimeStamp_mut: LARGE_INTEGER, +}} +STRUCT!{struct WNODE_HEADER { + BufferSize: ULONG, + ProviderId: ULONG, + u1: WNODE_HEADER_u1, + u2: WNODE_HEADER_u2, + Guid: GUID, + ClientContext: ULONG, + Flags: ULONG, +}} +pub type PWNODE_HEADER = *mut WNODE_HEADER; +pub const WNODE_FLAG_ALL_DATA: ULONG = 0x00000001; +pub const WNODE_FLAG_SINGLE_INSTANCE: ULONG = 0x00000002; +pub const WNODE_FLAG_SINGLE_ITEM: ULONG = 0x00000004; +pub const WNODE_FLAG_EVENT_ITEM: ULONG = 0x00000008; +pub const WNODE_FLAG_FIXED_INSTANCE_SIZE: ULONG = 0x00000010; +pub const WNODE_FLAG_TOO_SMALL: ULONG = 0x00000020; +pub const WNODE_FLAG_INSTANCES_SAME: ULONG = 0x00000040; +pub const WNODE_FLAG_STATIC_INSTANCE_NAMES: ULONG = 0x00000080; +pub const WNODE_FLAG_INTERNAL: ULONG = 0x00000100; +pub const WNODE_FLAG_USE_TIMESTAMP: ULONG = 0x00000200; +pub const WNODE_FLAG_PERSIST_EVENT: ULONG = 0x00000400; +pub const WNODE_FLAG_EVENT_REFERENCE: ULONG = 0x00002000; +pub const WNODE_FLAG_ANSI_INSTANCENAMES: ULONG = 0x00004000; +pub const WNODE_FLAG_METHOD_ITEM: ULONG = 0x00008000; +pub const WNODE_FLAG_PDO_INSTANCE_NAMES: ULONG = 0x00010000; +pub const WNODE_FLAG_TRACED_GUID: ULONG = 0x00020000; +pub const WNODE_FLAG_LOG_WNODE: ULONG = 0x00040000; +pub const WNODE_FLAG_USE_GUID_PTR: ULONG = 0x00080000; +pub const WNODE_FLAG_USE_MOF_PTR: ULONG = 0x00100000; +pub const WNODE_FLAG_NO_HEADER: ULONG = 0x00200000; +pub const WNODE_FLAG_SEND_DATA_BLOCK: ULONG = 0x00400000; +pub const WNODE_FLAG_VERSIONED_PROPERTIES: ULONG = 0x00800000; +pub const WNODE_FLAG_SEVERITY_MASK: ULONG = 0xff000000; +STRUCT!{struct OFFSETINSTANCEDATAANDLENGTH { + OffsetInstanceData: ULONG, + LengthInstanceData: ULONG, +}} +pub type POFFSETINSTANCEDATAANDLENGTH = *mut OFFSETINSTANCEDATAANDLENGTH; +UNION!{union WNODE_ALL_DATA_u { + [u32; 2], + FixedInstanceSize FixedInstanceSize_mut: ULONG, + OffsetInstanceDataAndLength OffsetInstanceDataAndLength_mut: + [OFFSETINSTANCEDATAANDLENGTH; 0], +}} +STRUCT!{struct WNODE_ALL_DATA { + WnodeHeader: WNODE_HEADER, + DataBlockOffset: ULONG, + InstanceCount: ULONG, + OffsetInstanceNameOffsets: ULONG, + u: WNODE_ALL_DATA_u, +}} +pub type PWNODE_ALL_DATA = *mut WNODE_ALL_DATA; +STRUCT!{struct WNODE_SINGLE_INSTANCE { + WnodeHeader: WNODE_HEADER, + OffsetInstanceName: ULONG, + InstanceIndex: ULONG, + DataBlockOffset: ULONG, + SizeDataBlock: ULONG, + VariableData: [UCHAR; 0], +}} +pub type PWNODE_SINGLE_INSTANCE = *mut WNODE_SINGLE_INSTANCE; +STRUCT!{struct WNODE_SINGLE_ITEM { + WnodeHeader: WNODE_HEADER, + OffsetInstanceName: ULONG, + InstanceIndex: ULONG, + ItemId: ULONG, + DataBlockOffset: ULONG, + SizeDataItem: ULONG, + VariableData: [UCHAR; 0], +}} +pub type PWNODE_SINGLE_ITEM = *mut WNODE_SINGLE_ITEM; +STRUCT!{struct WNODE_METHOD_ITEM { + WnodeHeader: WNODE_HEADER, + OffsetInstanceName: ULONG, + InstanceIndex: ULONG, + MethodId: ULONG, + DataBlockOffset: ULONG, + SizeDataBlock: ULONG, + VariableData: [UCHAR; 0], +}} +pub type PWNODE_METHOD_ITEM = *mut WNODE_METHOD_ITEM; +STRUCT!{struct WNODE_EVENT_ITEM { + WnodeHeader: WNODE_HEADER, +}} +pub type PWNODE_EVENT_ITEM = *mut WNODE_EVENT_ITEM; +UNION!{union WNODE_EVENT_REFERENCE_u { + [u32; 1], + TargetInstanceIndex TargetInstanceIndex_mut: ULONG, + TargetInstanceName TargetInstanceName_mut: [WCHAR; 0], +}} +STRUCT!{struct WNODE_EVENT_REFERENCE { + WnodeHeader: WNODE_HEADER, + TargetGuid: GUID, + TargetDataBlockSize: ULONG, + u: WNODE_EVENT_REFERENCE_u, +}} +pub type PWNODE_EVENT_REFERENCE = *mut WNODE_EVENT_REFERENCE; +STRUCT!{struct WNODE_TOO_SMALL { + WnodeHeader: WNODE_HEADER, + SizeNeeded: ULONG, +}} +pub type PWNODE_TOO_SMALL = *mut WNODE_TOO_SMALL; +UNION!{union WMIREGGUIDW_u { + [usize; 1], + InstanceNameList InstanceNameList_mut: ULONG, + BaseNameOffset BaseNameOffset_mut: ULONG, + Pdo Pdo_mut: ULONG_PTR, + InstanceInfo InstanceInfo_mut: ULONG_PTR, +}} +STRUCT!{struct WMIREGGUIDW { + Guid: GUID, + Flags: ULONG, + InstanceCount: ULONG, + u: WMIREGGUIDW_u, +}} +pub type PWMIREGGUIDW = *mut WMIREGGUIDW; +pub const WMIREG_FLAG_EXPENSIVE: ULONG = 0x00000001; +pub const WMIREG_FLAG_INSTANCE_LIST: ULONG = 0x00000004; +pub const WMIREG_FLAG_INSTANCE_BASENAME: ULONG = 0x00000008; +pub const WMIREG_FLAG_INSTANCE_PDO: ULONG = 0x00000020; +pub const WMIREG_FLAG_REMOVE_GUID: ULONG = 0x00010000; +pub const WMIREG_FLAG_RESERVED1: ULONG = 0x00020000; +pub const WMIREG_FLAG_RESERVED2: ULONG = 0x00040000; +pub const WMIREG_FLAG_TRACED_GUID: ULONG = 0x00080000; +pub const WMIREG_FLAG_TRACE_CONTROL_GUID: ULONG = 0x00001000; +pub const WMIREG_FLAG_EVENT_ONLY_GUID: ULONG = 0x00000040; +STRUCT!{struct WMIREGINFOW { + BufferSize: ULONG, + NextWmiRegInfo: ULONG, + RegistryPath: ULONG, + MofResourceName: ULONG, + GuidGount: ULONG, + WmiRegGuid: [WMIREGGUIDW; 0], +}} +pub type PWMIREGINFOW = *mut WMIREGINFOW; +ENUM!{enum WMIDPREQUESTCODE { + WMI_GET_ALL_DATA = 0, + WMI_GET_SINGLE_INSTANCE = 1, + WMI_SET_SINGLE_INSTANCE = 2, + WMI_SET_SINGLE_ITEM = 3, + WMI_ENABLE_EVENTS = 4, + WMI_DISABLE_EVENTS = 5, + WMI_ENABLE_COLLECTION = 6, + WMI_DISABLE_COLLECTION = 7, + WMI_REGINFO = 8, + WMI_EXECUTE_METHOD = 9, + WMI_CAPTURE_STATE = 10, +}} +pub const WMI_GUIDTYPE_TRACECONTROL: ULONG = 0; +pub const WMI_GUIDTYPE_TRACE: ULONG = 1; +pub const WMI_GUIDTYPE_DATA: ULONG = 2; +pub const WMI_GUIDTYPE_EVENT: ULONG = 3; +pub const WMIGUID_QUERY: ULONG = 0x0001; +pub const WMIGUID_SET: ULONG = 0x0002; +pub const WMIGUID_NOTIFICATION: ULONG = 0x0004; +pub const WMIGUID_READ_DESCRIPTION: ULONG = 0x0008; +pub const WMIGUID_EXECUTE: ULONG = 0x0010; +pub const TRACELOG_CREATE_REALTIME: ULONG = 0x0020; +pub const TRACELOG_CREATE_ONDISK: ULONG = 0x0040; +pub const TRACELOG_GUID_ENABLE: ULONG = 0x0080; +pub const TRACELOG_ACCESS_KERNEL_LOGGER: ULONG = 0x0100; +pub const TRACELOG_LOG_EVENT: ULONG = 0x0200; +pub const TRACELOG_CREATE_INPROC: ULONG = 0x0200; +pub const TRACELOG_ACCESS_REALTIME: ULONG = 0x0400; +pub const TRACELOG_REGISTER_GUIDS: ULONG = 0x0800; +pub const TRACELOG_JOIN_GROUP: ULONG = 0x1000; +pub const WMIGUID_ALL_ACCESS_WIN2K: ULONG = STANDARD_RIGHTS_READ | WMIGUID_QUERY | WMIGUID_SET + | WMIGUID_NOTIFICATION | WMIGUID_READ_DESCRIPTION | WMIGUID_EXECUTE | TRACELOG_CREATE_REALTIME + | TRACELOG_CREATE_ONDISK | TRACELOG_GUID_ENABLE | TRACELOG_ACCESS_KERNEL_LOGGER + | TRACELOG_CREATE_INPROC | TRACELOG_ACCESS_REALTIME; +pub const WMIGUID_ALL_ACCESS_WINXP: ULONG = WMIGUID_ALL_ACCESS_WIN2K | SYNCHRONIZE + | TRACELOG_REGISTER_GUIDS; +pub const WMIGUID_ALL_ACCESS_RS1: ULONG = WMIGUID_ALL_ACCESS_WINXP | TRACELOG_JOIN_GROUP; +pub const WMIGUID_ALL_ACCESS: ULONG = WMIGUID_ALL_ACCESS_RS1; +pub const WMI_GLOBAL_LOGGER_ID: ULONG = 0x0001; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/wnnc.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/wnnc.rs new file mode 100644 index 0000000..305137c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/wnnc.rs @@ -0,0 +1,77 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Provides the Windows Networking WNNC_NET definitions to winnetwk.h and the IFS Kit. +use shared::minwindef::DWORD; +pub const WNNC_NET_MSNET: DWORD = 0x00010000; +pub const WNNC_NET_SMB: DWORD = 0x00020000; +pub const WNNC_NET_NETWARE: DWORD = 0x00030000; +pub const WNNC_NET_VINES: DWORD = 0x00040000; +pub const WNNC_NET_10NET: DWORD = 0x00050000; +pub const WNNC_NET_LOCUS: DWORD = 0x00060000; +pub const WNNC_NET_SUN_PC_NFS: DWORD = 0x00070000; +pub const WNNC_NET_LANSTEP: DWORD = 0x00080000; +pub const WNNC_NET_9TILES: DWORD = 0x00090000; +pub const WNNC_NET_LANTASTIC: DWORD = 0x000A0000; +pub const WNNC_NET_AS400: DWORD = 0x000B0000; +pub const WNNC_NET_FTP_NFS: DWORD = 0x000C0000; +pub const WNNC_NET_PATHWORKS: DWORD = 0x000D0000; +pub const WNNC_NET_LIFENET: DWORD = 0x000E0000; +pub const WNNC_NET_POWERLAN: DWORD = 0x000F0000; +pub const WNNC_NET_BWNFS: DWORD = 0x00100000; +pub const WNNC_NET_COGENT: DWORD = 0x00110000; +pub const WNNC_NET_FARALLON: DWORD = 0x00120000; +pub const WNNC_NET_APPLETALK: DWORD = 0x00130000; +pub const WNNC_NET_INTERGRAPH: DWORD = 0x00140000; +pub const WNNC_NET_SYMFONET: DWORD = 0x00150000; +pub const WNNC_NET_CLEARCASE: DWORD = 0x00160000; +pub const WNNC_NET_FRONTIER: DWORD = 0x00170000; +pub const WNNC_NET_BMC: DWORD = 0x00180000; +pub const WNNC_NET_DCE: DWORD = 0x00190000; +pub const WNNC_NET_AVID: DWORD = 0x001A0000; +pub const WNNC_NET_DOCUSPACE: DWORD = 0x001B0000; +pub const WNNC_NET_MANGOSOFT: DWORD = 0x001C0000; +pub const WNNC_NET_SERNET: DWORD = 0x001D0000; +pub const WNNC_NET_RIVERFRONT1: DWORD = 0x001E0000; +pub const WNNC_NET_RIVERFRONT2: DWORD = 0x001F0000; +pub const WNNC_NET_DECORB: DWORD = 0x00200000; +pub const WNNC_NET_PROTSTOR: DWORD = 0x00210000; +pub const WNNC_NET_FJ_REDIR: DWORD = 0x00220000; +pub const WNNC_NET_DISTINCT: DWORD = 0x00230000; +pub const WNNC_NET_TWINS: DWORD = 0x00240000; +pub const WNNC_NET_RDR2SAMPLE: DWORD = 0x00250000; +pub const WNNC_NET_CSC: DWORD = 0x00260000; +pub const WNNC_NET_3IN1: DWORD = 0x00270000; +pub const WNNC_NET_EXTENDNET: DWORD = 0x00290000; +pub const WNNC_NET_STAC: DWORD = 0x002A0000; +pub const WNNC_NET_FOXBAT: DWORD = 0x002B0000; +pub const WNNC_NET_YAHOO: DWORD = 0x002C0000; +pub const WNNC_NET_EXIFS: DWORD = 0x002D0000; +pub const WNNC_NET_DAV: DWORD = 0x002E0000; +pub const WNNC_NET_KNOWARE: DWORD = 0x002F0000; +pub const WNNC_NET_OBJECT_DIRE: DWORD = 0x00300000; +pub const WNNC_NET_MASFAX: DWORD = 0x00310000; +pub const WNNC_NET_HOB_NFS: DWORD = 0x00320000; +pub const WNNC_NET_SHIVA: DWORD = 0x00330000; +pub const WNNC_NET_IBMAL: DWORD = 0x00340000; +pub const WNNC_NET_LOCK: DWORD = 0x00350000; +pub const WNNC_NET_TERMSRV: DWORD = 0x00360000; +pub const WNNC_NET_SRT: DWORD = 0x00370000; +pub const WNNC_NET_QUINCY: DWORD = 0x00380000; +pub const WNNC_NET_OPENAFS: DWORD = 0x00390000; +pub const WNNC_NET_AVID1: DWORD = 0x003A0000; +pub const WNNC_NET_DFS: DWORD = 0x003B0000; +pub const WNNC_NET_KWNP: DWORD = 0x003C0000; +pub const WNNC_NET_ZENWORKS: DWORD = 0x003D0000; +pub const WNNC_NET_DRIVEONWEB: DWORD = 0x003E0000; +pub const WNNC_NET_VMWARE: DWORD = 0x003F0000; +pub const WNNC_NET_RSFX: DWORD = 0x00400000; +pub const WNNC_NET_MFILES: DWORD = 0x00410000; +pub const WNNC_NET_MS_NFS: DWORD = 0x00420000; +pub const WNNC_NET_GOOGLE: DWORD = 0x00430000; +pub const WNNC_NET_NDFS: DWORD = 0x00440000; +pub const WNNC_NET_DOCUSHARE: DWORD = 0x00450000; +pub const WNNC_CRED_MANAGER: DWORD = 0xFFFF0000; +pub const WNNC_NET_LANMAN: DWORD = WNNC_NET_SMB; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/ws2def.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ws2def.rs new file mode 100644 index 0000000..484f6d4 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ws2def.rs @@ -0,0 +1,556 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Core definitions for the Winsock2 specification +use ctypes::{__int64, c_char, c_int, c_long, c_short, c_void}; +use shared::basetsd::SIZE_T; +use shared::guiddef::LPGUID; +use shared::inaddr::IN_ADDR; +use shared::minwindef::{DWORD, INT, UCHAR, ULONG, USHORT}; +use um::winnt::{CHAR, HANDLE, LONG, PROCESSOR_NUMBER, PWSTR}; +use vc::vcruntime::size_t; +pub type ADDRESS_FAMILY = USHORT; +pub const AF_UNSPEC: c_int = 0; +pub const AF_UNIX: c_int = 1; +pub const AF_INET: c_int = 2; +pub const AF_IMPLINK: c_int = 3; +pub const AF_PUP: c_int = 4; +pub const AF_CHAOS: c_int = 5; +pub const AF_NS: c_int = 6; +pub const AF_IPX: c_int = AF_NS; +pub const AF_ISO: c_int = 7; +pub const AF_OSI: c_int = AF_ISO; +pub const AF_ECMA: c_int = 8; +pub const AF_DATAKIT: c_int = 9; +pub const AF_CCITT: c_int = 10; +pub const AF_SNA: c_int = 11; +pub const AF_DECnet: c_int = 12; +pub const AF_DLI: c_int = 13; +pub const AF_LAT: c_int = 14; +pub const AF_HYLINK: c_int = 15; +pub const AF_APPLETALK: c_int = 16; +pub const AF_NETBIOS: c_int = 17; +pub const AF_VOICEVIEW: c_int = 18; +pub const AF_FIREFOX: c_int = 19; +pub const AF_UNKNOWN1: c_int = 20; +pub const AF_BAN: c_int = 21; +pub const AF_ATM: c_int = 22; +pub const AF_INET6: c_int = 23; +pub const AF_CLUSTER: c_int = 24; +pub const AF_12844: c_int = 25; +pub const AF_IRDA: c_int = 26; +pub const AF_NETDES: c_int = 28; +pub const AF_TCNPROCESS: c_int = 29; +pub const AF_TCNMESSAGE: c_int = 30; +pub const AF_ICLFXBM: c_int = 31; +pub const AF_BTH: c_int = 32; +pub const AF_LINK: c_int = 33; +pub const AF_HYPERV: c_int = 34; +pub const AF_MAX: c_int = 35; +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOL_SOCKET: c_int = 0xffff; +pub const SO_DEBUG: c_int = 0x0001; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_DONTLINGER: c_int = !SO_LINGER; +pub const SO_EXCLUSIVEADDRUSE: c_int = !SO_REUSEADDR; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; +pub const SO_BSP_STATE: c_int = 0x1009; +pub const SO_GROUP_ID: c_int = 0x2001; +pub const SO_GROUP_PRIORITY: c_int = 0x2002; +pub const SO_MAX_MSG_SIZE: c_int = 0x2003; +pub const SO_CONDITIONAL_ACCEPT: c_int = 0x3002; +pub const SO_PAUSE_ACCEPT: c_int = 0x3003; +pub const SO_COMPARTMENT_ID: c_int = 0x3004; +pub const SO_RANDOMIZE_PORT: c_int = 0x3005; +pub const SO_PORT_SCALABILITY: c_int = 0x3006; +pub const SO_REUSE_UNICASTPORT: c_int = 0x3007; +pub const SO_REUSE_MULTICASTPORT: c_int = 0x3008; +pub const WSK_SO_BASE: c_int = 0x4000; +pub const TCP_NODELAY: c_int = 0x0001; +STRUCT!{struct SOCKADDR { + sa_family: ADDRESS_FAMILY, + sa_data: [CHAR; 14], +}} +pub type PSOCKADDR = *mut SOCKADDR; +pub type LPSOCKADDR = *mut SOCKADDR; +STRUCT!{struct SOCKET_ADDRESS { + lpSockaddr: LPSOCKADDR, + iSockaddrLength: INT, +}} +pub type PSOCKET_ADDRESS = *mut SOCKET_ADDRESS; +pub type LPSOCKET_ADDRESS = *mut SOCKET_ADDRESS; +STRUCT!{struct SOCKET_ADDRESS_LIST { + iAddressCount: INT, + Address: [SOCKET_ADDRESS; 1], +}} +pub type PSOCKET_ADDRESS_LIST = *mut SOCKET_ADDRESS_LIST; +pub type LPSOCKET_ADDRESS_LIST = *mut SOCKET_ADDRESS_LIST; +STRUCT!{struct CSADDR_INFO { + LocalAddr: SOCKET_ADDRESS, + RemoteAddr: SOCKET_ADDRESS, + iSocketType: INT, + iProtocol: INT, +}} +pub type PCSADDR_INFO = *mut CSADDR_INFO; +pub type LPCSADDR_INFO = *mut CSADDR_INFO; +STRUCT!{struct SOCKADDR_STORAGE_LH { + ss_family: ADDRESS_FAMILY, + __ss_pad1: [CHAR; 6], + __ss_align: __int64, + __ss_pad2: [CHAR; 112], +}} +pub type PSOCKADDR_STORAGE_LH = *mut SOCKADDR_STORAGE_LH; +pub type LPSOCKADDR_STORAGE_LH = *mut SOCKADDR_STORAGE_LH; +STRUCT!{struct SOCKADDR_STORAGE_XP { + ss_family: c_short, + __ss_pad1: [CHAR; 6], + __ss_align: __int64, + __ss_pad2: [CHAR; 112], +}} +pub type PSOCKADDR_STORAGE_XP = *mut SOCKADDR_STORAGE_XP; +pub type LPSOCKADDR_STORAGE_XP = *mut SOCKADDR_STORAGE_XP; +pub type SOCKADDR_STORAGE = SOCKADDR_STORAGE_LH; +pub type PSOCKADDR_STORAGE = *mut SOCKADDR_STORAGE; +pub type LPSOCKADDR_STORAGE = *mut SOCKADDR_STORAGE; +STRUCT!{struct SOCKET_PROCESSOR_AFFINITY { + Processor: PROCESSOR_NUMBER, + NumaNodeId: USHORT, + Reserved: USHORT, +}} +pub type PSOCKET_PROCESSOR_AFFINITY = *mut SOCKET_PROCESSOR_AFFINITY; +pub const IOC_UNIX: DWORD = 0x00000000; +pub const IOC_WS2: DWORD = 0x08000000; +pub const IOC_PROTOCOL: DWORD = 0x10000000; +pub const IOC_VENDOR: DWORD = 0x18000000; +pub const IOC_WSK: DWORD = IOC_WS2 | 0x07000000; +pub const SIO_ASSOCIATE_HANDLE: DWORD = _WSAIOW!(IOC_WS2, 1); +pub const SIO_ENABLE_CIRCULAR_QUEUEING: DWORD = _WSAIO!(IOC_WS2, 2); +pub const SIO_FIND_ROUTE: DWORD = _WSAIOR!(IOC_WS2, 3); +pub const SIO_FLUSH: DWORD = _WSAIO!(IOC_WS2, 4); +pub const SIO_GET_BROADCAST_ADDRESS: DWORD = _WSAIOR!(IOC_WS2, 5); +pub const SIO_GET_EXTENSION_FUNCTION_POINTER: DWORD = _WSAIORW!(IOC_WS2, 6); +pub const SIO_GET_QOS: DWORD = _WSAIORW!(IOC_WS2, 7); +pub const SIO_GET_GROUP_QOS: DWORD = _WSAIORW!(IOC_WS2, 8); +pub const SIO_MULTIPOINT_LOOPBACK: DWORD = _WSAIOW!(IOC_WS2, 9); +pub const SIO_MULTICAST_SCOPE: DWORD = _WSAIOW!(IOC_WS2, 10); +pub const SIO_SET_QOS: DWORD = _WSAIOW!(IOC_WS2, 11); +pub const SIO_SET_GROUP_QOS: DWORD = _WSAIOW!(IOC_WS2, 12); +pub const SIO_TRANSLATE_HANDLE: DWORD = _WSAIORW!(IOC_WS2, 13); +pub const SIO_ROUTING_INTERFACE_QUERY: DWORD = _WSAIORW!(IOC_WS2, 20); +pub const SIO_ROUTING_INTERFACE_CHANGE: DWORD = _WSAIOW!(IOC_WS2, 21); +pub const SIO_ADDRESS_LIST_QUERY: DWORD = _WSAIOR!(IOC_WS2, 22); +pub const SIO_ADDRESS_LIST_CHANGE: DWORD = _WSAIO!(IOC_WS2, 23); +pub const SIO_QUERY_TARGET_PNP_HANDLE: DWORD = _WSAIOR!(IOC_WS2, 24); +pub const SIO_QUERY_RSS_PROCESSOR_INFO: DWORD = _WSAIOR!(IOC_WS2, 37); +pub const SIO_ADDRESS_LIST_SORT: DWORD = _WSAIORW!(IOC_WS2, 25); +pub const SIO_RESERVED_1: DWORD = _WSAIOW!(IOC_WS2, 26); +pub const SIO_RESERVED_2: DWORD = _WSAIOW!(IOC_WS2, 33); +pub const SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER: DWORD = _WSAIORW!(IOC_WS2, 36); +pub const IPPROTO_IP: c_int = 0; +ENUM!{enum IPPROTO { + IPPROTO_HOPOPTS = 0, // IPv6 Hop-by-Hop options + IPPROTO_ICMP = 1, + IPPROTO_IGMP = 2, + IPPROTO_GGP = 3, + IPPROTO_IPV4 = 4, + IPPROTO_ST = 5, + IPPROTO_TCP = 6, + IPPROTO_CBT = 7, + IPPROTO_EGP = 8, + IPPROTO_IGP = 9, + IPPROTO_PUP = 12, + IPPROTO_UDP = 17, + IPPROTO_IDP = 22, + IPPROTO_RDP = 27, + IPPROTO_IPV6 = 41, // IPv6 header + IPPROTO_ROUTING = 43, // IPv6 Routing header + IPPROTO_FRAGMENT = 44, // IPv6 fragmentation header + IPPROTO_ESP = 50, // encapsulating security payload + IPPROTO_AH = 51, // authentication header + IPPROTO_ICMPV6 = 58, // ICMPv6 + IPPROTO_NONE = 59, // IPv6 no next header + IPPROTO_DSTOPTS = 60, // IPv6 Destination options + IPPROTO_ND = 77, + IPPROTO_ICLFXBM = 78, + IPPROTO_PIM = 103, + IPPROTO_PGM = 113, + IPPROTO_L2TP = 115, + IPPROTO_SCTP = 132, + IPPROTO_RAW = 255, + IPPROTO_MAX = 256, + IPPROTO_RESERVED_RAW = 257, + IPPROTO_RESERVED_IPSEC = 258, + IPPROTO_RESERVED_IPSECOFFLOAD = 259, + IPPROTO_RESERVED_WNV = 260, + IPPROTO_RESERVED_MAX = 261, +}} +pub type PIPPROTO = *mut IPPROTO; +pub const IPPORT_TCPMUX: USHORT = 1; +pub const IPPORT_ECHO: USHORT = 7; +pub const IPPORT_DISCARD: USHORT = 9; +pub const IPPORT_SYSTAT: USHORT = 11; +pub const IPPORT_DAYTIME: USHORT = 13; +pub const IPPORT_NETSTAT: USHORT = 15; +pub const IPPORT_QOTD: USHORT = 17; +pub const IPPORT_MSP: USHORT = 18; +pub const IPPORT_CHARGEN: USHORT = 19; +pub const IPPORT_FTP_DATA: USHORT = 20; +pub const IPPORT_FTP: USHORT = 21; +pub const IPPORT_TELNET: USHORT = 23; +pub const IPPORT_SMTP: USHORT = 25; +pub const IPPORT_TIMESERVER: USHORT = 37; +pub const IPPORT_NAMESERVER: USHORT = 42; +pub const IPPORT_WHOIS: USHORT = 43; +pub const IPPORT_MTP: USHORT = 57; +pub const IPPORT_TFTP: USHORT = 69; +pub const IPPORT_RJE: USHORT = 77; +pub const IPPORT_FINGER: USHORT = 79; +pub const IPPORT_TTYLINK: USHORT = 87; +pub const IPPORT_SUPDUP: USHORT = 95; +pub const IPPORT_POP3: USHORT = 110; +pub const IPPORT_NTP: USHORT = 123; +pub const IPPORT_EPMAP: USHORT = 135; +pub const IPPORT_NETBIOS_NS: USHORT = 137; +pub const IPPORT_NETBIOS_DGM: USHORT = 138; +pub const IPPORT_NETBIOS_SSN: USHORT = 139; +pub const IPPORT_IMAP: USHORT = 143; +pub const IPPORT_SNMP: USHORT = 161; +pub const IPPORT_SNMP_TRAP: USHORT = 162; +pub const IPPORT_IMAP3: USHORT = 220; +pub const IPPORT_LDAP: USHORT = 389; +pub const IPPORT_HTTPS: USHORT = 443; +pub const IPPORT_MICROSOFT_DS: USHORT = 445; +pub const IPPORT_EXECSERVER: USHORT = 512; +pub const IPPORT_LOGINSERVER: USHORT = 513; +pub const IPPORT_CMDSERVER: USHORT = 514; +pub const IPPORT_EFSSERVER: USHORT = 520; +pub const IPPORT_BIFFUDP: USHORT = 512; +pub const IPPORT_WHOSERVER: USHORT = 513; +pub const IPPORT_ROUTESERVER: USHORT = 520; +pub const IPPORT_RESERVED: USHORT = 1024; +pub const IPPORT_REGISTERED_MIN: USHORT = IPPORT_RESERVED; +pub const IPPORT_REGISTERED_MAX: USHORT = 0xbfff; +pub const IPPORT_DYNAMIC_MIN: USHORT = 0xc000; +pub const IPPORT_DYNAMIC_MAX: USHORT = 0xffff; +#[inline] +pub fn IN_CLASSA(i: LONG) -> bool { + (i & 0x80000000) == 0 +} +pub const IN_CLASSA_NET: LONG = 0xff000000; +pub const IN_CLASSA_NSHIFT: LONG = 24; +pub const IN_CLASSA_HOST: LONG = 0x00ffffff; +pub const IN_CLASSA_MAX: LONG = 128; +#[inline] +pub fn IN_CLASSB(i: LONG) -> bool { + (i as u32 & 0xc0000000) == 0x80000000 +} +pub const IN_CLASSB_NET: LONG = 0xffff0000; +pub const IN_CLASSB_NSHIFT: LONG = 16; +pub const IN_CLASSB_HOST: LONG = 0x0000ffff; +pub const IN_CLASSB_MAX: LONG = 65536; +#[inline] +pub fn IN_CLASSC(i: LONG) -> bool { + (i as u32 & 0xe0000000) == 0xc0000000 +} +pub const IN_CLASSC_NET: LONG = 0xffffff00; +pub const IN_CLASSC_NSHIFT: LONG = 8; +pub const IN_CLASSC_HOST: LONG = 0x000000ff; +#[inline] +pub fn IN_CLASSD(i: c_long) -> bool { + (i as u32 & 0xf0000000) == 0xe0000000 +} +pub const IN_CLASSD_NET: LONG = 0xf0000000; +pub const IN_CLASSD_NSHIFT: LONG = 28; +pub const IN_CLASSD_HOST: LONG = 0x0fffffff; +#[inline] +pub fn IN_MULTICAST(i: c_long) -> bool { + IN_CLASSD(i) +} +pub const INADDR_ANY: ULONG = 0x00000000; +pub const INADDR_LOOPBACK: ULONG = 0x7f000001; +pub const INADDR_BROADCAST: ULONG = 0xffffffff; +pub const INADDR_NONE: ULONG = 0xffffffff; +ENUM!{enum SCOPE_LEVEL { + ScopeLevelInterface = 1, + ScopeLevelLink = 2, + ScopeLevelSubnet = 3, + ScopeLevelAdmin = 4, + ScopeLevelSite = 5, + ScopeLevelOrganization = 8, + ScopeLevelGlobal = 14, + ScopeLevelCount = 16, +}} +STRUCT!{struct SCOPE_ID_u_s { + bitfield: ULONG, +}} +BITFIELD!{SCOPE_ID_u_s bitfield: ULONG [ + Zone set_Zone[0..28], + Level set_Level[28..32], +]} +UNION!{union SCOPE_ID_u { + [u32; 1], + s s_mut: SCOPE_ID_u_s, + Value Value_mut: ULONG, +}} +STRUCT!{struct SCOPE_ID { + u: SCOPE_ID_u, +}} +pub type PSCOPE_ID = *mut SCOPE_ID; +STRUCT!{struct SOCKADDR_IN { + sin_family: ADDRESS_FAMILY, + sin_port: USHORT, + sin_addr: IN_ADDR, + sin_zero: [CHAR; 8], +}} +pub type PSOCKADDR_IN = *mut SOCKADDR_IN; +STRUCT!{struct SOCKADDR_DL { + sdl_family: ADDRESS_FAMILY, + sdl_data: [UCHAR; 8], + sdl_zero: [UCHAR; 4], +}} +pub type PSOCKADDR_DL = *mut SOCKADDR_DL; +pub const IOCPARM_MASK: DWORD = 0x7f; +pub const IOC_VOID: DWORD = 0x20000000; +pub const IOC_OUT: DWORD = 0x40000000; +pub const IOC_IN: DWORD = 0x80000000; +pub const IOC_INOUT: DWORD = IOC_IN | IOC_OUT; +STRUCT!{struct WSABUF { + len: ULONG, + buf: *mut CHAR, +}} +pub type LPWSABUF = *mut WSABUF; +STRUCT!{struct WSAMSG { + name: LPSOCKADDR, + namelen: INT, + lpBuffers: LPWSABUF, + dwBufferCount: ULONG, + Control: WSABUF, + dwFlags: ULONG, +}} +pub type PWSAMSG = *mut WSAMSG; +pub type LPWSAMSG = *mut WSAMSG; +STRUCT!{struct WSACMSGHDR { + cmsg_len: SIZE_T, + cmsg_level: INT, + cmsg_type: INT, +}} +pub type PWSACMSGHDR = *mut WSACMSGHDR; +pub type LPWSACMSGHDR = *mut WSACMSGHDR; +pub type CMSGHDR = WSACMSGHDR; +pub type PCMSGHDR = *mut WSACMSGHDR; +pub const MSG_TRUNC: ULONG = 0x0100; +pub const MSG_CTRUNC: ULONG = 0x0200; +pub const MSG_BCAST: ULONG = 0x0400; +pub const MSG_MCAST: ULONG = 0x0800; +pub const AI_PASSIVE: c_int = 0x00000001; +pub const AI_CANONNAME: c_int = 0x00000002; +pub const AI_NUMERICHOST: c_int = 0x00000004; +pub const AI_NUMERICSERV: c_int = 0x00000008; +pub const AI_DNS_ONLY: c_int = 0x00000010; +pub const AI_ALL: c_int = 0x00000100; +pub const AI_ADDRCONFIG: c_int = 0x00000400; +pub const AI_V4MAPPED: c_int = 0x00000800; +pub const AI_NON_AUTHORITATIVE: c_int = 0x00004000; +pub const AI_SECURE: c_int = 0x00008000; +pub const AI_RETURN_PREFERRED_NAMES: c_int = 0x00010000; +pub const AI_FQDN: c_int = 0x00020000; +pub const AI_FILESERVER: c_int = 0x00040000; +pub const AI_DISABLE_IDN_ENCODING: c_int = 0x00080000; +pub const AI_EXTENDED: c_int = 0x80000000; +pub const AI_RESOLUTION_HANDLE: c_int = 0x40000000; +STRUCT!{struct ADDRINFOA { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: *mut c_char, + ai_addr: *mut SOCKADDR, + ai_next: *mut ADDRINFOA, +}} +pub type PADDRINFOA = *mut ADDRINFOA; +STRUCT!{struct ADDRINFOW { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: PWSTR, + ai_addr: *mut SOCKADDR, + ai_next: *mut ADDRINFOW, +}} +pub type PADDRINFOW = *mut ADDRINFOW; +STRUCT!{struct ADDRINFOEXA { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: *mut c_char, + ai_addr: *mut SOCKADDR, + ai_blob: *mut c_void, + ai_bloblen: size_t, + ai_provider: LPGUID, + ai_next: *mut ADDRINFOEXA, +}} +pub type PADDRINFOEXA = *mut ADDRINFOEXA; +pub type LPADDRINFOEXA = *mut ADDRINFOEXA; +STRUCT!{struct ADDRINFOEXW { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: PWSTR, + ai_addr: *mut SOCKADDR, + ai_blob: *mut c_void, + ai_bloblen: size_t, + ai_provider: LPGUID, + ai_next: *mut ADDRINFOEXW, +}} +pub type PADDRINFOEXW = *mut ADDRINFOEXW; +pub type LPADDRINFOEXW = *mut ADDRINFOEXW; +pub const ADDRINFOEX_VERSION_2: c_int = 2; +pub const ADDRINFOEX_VERSION_3: c_int = 3; +pub const ADDRINFOEX_VERSION_4: c_int = 4; +STRUCT!{struct ADDRINFOEX2A { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: *mut c_char, + ai_addr: *mut SOCKADDR, + ai_blob: *mut c_void, + ai_bloblen: size_t, + ai_provider: LPGUID, + ai_next: *mut ADDRINFOEX2W, + ai_version: c_int, + ai_fqdn: *mut c_char, +}} +pub type PADDRINFOEX2A = *mut ADDRINFOEX2A; +pub type LPADDRINFOEX2A = *mut ADDRINFOEX2A; +STRUCT!{struct ADDRINFOEX2W { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: PWSTR, + ai_addr: *mut SOCKADDR, + ai_blob: *mut c_void, + ai_bloblen: size_t, + ai_provider: LPGUID, + ai_next: *mut ADDRINFOEX2W, + ai_version: c_int, + ai_fqdn: PWSTR, +}} +pub type PADDRINFOEX2W = *mut ADDRINFOEX2W; +pub type LPADDRINFOEX2W = *mut ADDRINFOEX2W; +STRUCT!{struct ADDRINFOEX3A { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: *mut c_char, + ai_addr: *mut SOCKADDR, + ai_blob: *mut c_void, + ai_bloblen: size_t, + ai_provider: LPGUID, + ai_next: *mut ADDRINFOEX3W, + ai_version: c_int, + ai_fqdn: *mut c_char, + ai_interfaceindex: c_int, +}} +pub type PADDRINFOEX3A = *mut ADDRINFOEX3A; +pub type LPADDRINFOEX3A = *mut ADDRINFOEX3A; +STRUCT!{struct ADDRINFOEX3W { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: PWSTR, + ai_addr: *mut SOCKADDR, + ai_blob: *mut c_void, + ai_bloblen: size_t, + ai_provider: LPGUID, + ai_next: *mut ADDRINFOEX3W, + ai_version: c_int, + ai_fqdn: PWSTR, + ai_interfaceindex: c_int, +}} +pub type PADDRINFOEX3W = *mut ADDRINFOEX3W; +pub type LPADDRINFOEX3W = *mut ADDRINFOEX3W; +STRUCT!{struct ADDRINFOEX4 { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: PWSTR, + ai_addr: *mut SOCKADDR, + ai_blob: *mut c_void, + ai_bloblen: size_t, + ai_provider: LPGUID, + ai_next: *mut ADDRINFOEX4, + ai_version: c_int, + ai_fqdn: PWSTR, + ai_interfaceindex: c_int, + ai_resolutionhandle: HANDLE, +}} +pub type PADDRINFOEX4 = *mut ADDRINFOEX4; +pub type LPADDRINFOEX4 = *mut ADDRINFOEX4; +pub const NS_ALL: DWORD = 0; +pub const NS_SAP: DWORD = 1; +pub const NS_NDS: DWORD = 2; +pub const NS_PEER_BROWSE: DWORD = 3; +pub const NS_SLP: DWORD = 5; +pub const NS_DHCP: DWORD = 6; +pub const NS_TCPIP_LOCAL: DWORD = 10; +pub const NS_TCPIP_HOSTS: DWORD = 11; +pub const NS_DNS: DWORD = 12; +pub const NS_NETBT: DWORD = 13; +pub const NS_WINS: DWORD = 14; +pub const NS_NLA: DWORD = 15; +pub const NS_BTH: DWORD = 16; +pub const NS_NBP: DWORD = 20; +pub const NS_MS: DWORD = 30; +pub const NS_STDA: DWORD = 31; +pub const NS_NTDS: DWORD = 32; +pub const NS_EMAIL: DWORD = 37; +pub const NS_PNRPNAME: DWORD = 38; +pub const NS_PNRPCLOUD: DWORD = 39; +pub const NS_X500: DWORD = 40; +pub const NS_NIS: DWORD = 41; +pub const NS_NISPLUS: DWORD = 42; +pub const NS_WRQ: DWORD = 50; +pub const NS_NETDES: DWORD = 60; +pub const NI_NOFQDN: c_int = 0x01; +pub const NI_NUMERICHOST: c_int = 0x02; +pub const NI_NAMEREQD: c_int = 0x04; +pub const NI_NUMERICSERV: c_int = 0x08; +pub const NI_DGRAM: c_int = 0x10; +pub const NI_MAXHOST: c_int = 1025; +pub const NI_MAXSERV: c_int = 32; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/ws2ipdef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ws2ipdef.rs new file mode 100644 index 0000000..b48518e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/ws2ipdef.rs @@ -0,0 +1,92 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! TCP/IP specific information for use by WinSock2 compatible applications. +use ctypes::c_int; +use shared::in6addr::IN6_ADDR; +use shared::inaddr::IN_ADDR; +use shared::minwindef::{ULONG, USHORT}; +use shared::ws2def::{ADDRESS_FAMILY, SCOPE_ID}; +pub const IFF_UP: ULONG = 0x00000001; +pub const IFF_BROADCAST: ULONG = 0x00000002; +pub const IFF_LOOPBACK: ULONG = 0x00000004; +pub const IFF_POINTTOPOINT: ULONG = 0x00000008; +pub const IFF_MULTICAST: ULONG = 0x00000010; +pub const IP_OPTIONS: c_int = 1; +pub const IP_HDRINCL: c_int = 2; +pub const IP_TOS: c_int = 3; +pub const IP_TTL: c_int = 4; +pub const IP_MULTICAST_IF: c_int = 9; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IP_DONTFRAGMENT: c_int = 14; +pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 15; +pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 16; +pub const IP_BLOCK_SOURCE: c_int = 17; +pub const IP_UNBLOCK_SOURCE: c_int = 18; +pub const IP_PKTINFO: c_int = 19; +pub const IP_RECEIVE_BROADCAST: c_int = 22; +pub const IP_RECVDSTADDR: c_int = 25; +UNION!{union SOCKADDR_IN6_LH_u { + [u32; 1], + sin6_scope_id sin6_scope_id_mut: ULONG, + sin6_scope_struct sin6_scope_struct_mut: SCOPE_ID, +}} +STRUCT!{struct SOCKADDR_IN6_LH { + sin6_family: ADDRESS_FAMILY, + sin6_port: USHORT, + sin6_flowinfo: ULONG, + sin6_addr: IN6_ADDR, + u: SOCKADDR_IN6_LH_u, +}} +pub type PSOCKADDR_IN6_LH = *mut SOCKADDR_IN6_LH; +STRUCT!{struct IP_MREQ { + imr_multiaddr: IN_ADDR, + imr_interface: IN_ADDR, +}} +pub type PIP_MREQ = *mut IP_MREQ; +pub const IPV6_HOPOPTS: c_int = 1; +pub const IPV6_HDRINCL: c_int = 2; +pub const IPV6_UNICAST_HOPS: c_int = 4; +pub const IPV6_MULTICAST_IF: c_int = 9; +pub const IPV6_MULTICAST_HOPS: c_int = 10; +pub const IPV6_MULTICAST_LOOP: c_int = 11; +pub const IPV6_ADD_MEMBERSHIP: c_int = 12; +pub const IPV6_JOIN_GROUP: c_int = IPV6_ADD_MEMBERSHIP; +pub const IPV6_DROP_MEMBERSHIP: c_int = 13; +pub const IPV6_LEAVE_GROUP: c_int = IPV6_DROP_MEMBERSHIP; +pub const IPV6_DONTFRAG: c_int = 14; +pub const IPV6_PKTINFO: c_int = 19; +pub const IPV6_HOPLIMIT: c_int = 21; +pub const IPV6_PROTECTION_LEVEL: c_int = 23; +pub const IPV6_RECVIF: c_int = 24; +pub const IPV6_RECVDSTADDR: c_int = 25; +pub const IPV6_CHECKSUM: c_int = 26; +pub const IPV6_V6ONLY: c_int = 27; +pub const IPV6_IFLIST: c_int = 28; +pub const IPV6_ADD_IFLIST: c_int = 29; +pub const IPV6_DEL_IFLIST: c_int = 30; +pub const IPV6_UNICAST_IF: c_int = 31; +pub const IPV6_RTHDR: c_int = 32; +pub const IPV6_RECVRTHDR: c_int = 38; +pub const IPV6_TCLASS: c_int = 39; +pub const IPV6_RECVTCLASS: c_int = 40; +STRUCT!{struct IPV6_MREQ { + ipv6mr_multiaddr: IN6_ADDR, + ipv6mr_interface: ULONG, +}} +pub type PIPV6_MREQ = *mut IPV6_MREQ; +STRUCT!{struct IN_PKTINFO { + ipi_addr: IN_ADDR, + ipi_ifindex: ULONG, +}} +pub type PIN_PKTINFO = *mut IN_PKTINFO; +STRUCT!{struct IN6_PKTINFO { + ipi6_addr: IN6_ADDR, + ipi6_ifindex: ULONG, +}} +pub type PIN6_PKTINFO = *mut IN6_PKTINFO; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/wtypes.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/wtypes.rs new file mode 100644 index 0000000..8b5c888 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/wtypes.rs @@ -0,0 +1,344 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{__int64, c_double, c_short, c_ushort, c_void, wchar_t}; +use shared::guiddef::{CLSID, GUID}; +use shared::minwindef::{BYTE, DWORD, ULONG, USHORT, WORD}; +use shared::ntdef::{LCID, LONG, LONGLONG, ULONGLONG}; +use shared::rpcndr::byte; +use shared::wtypesbase::{ + BYTE_BLOB, DWORD_BLOB, FLAGGED_BYTE_BLOB, FLAGGED_WORD_BLOB, LPOLESTR, OLECHAR +}; +use um::wingdi::LOGPALETTE; +// extern RPC_IF_HANDLE __MIDL_itf_wtypes_0000_0000_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wtypes_0000_0000_v0_0_s_ifspec; +STRUCT!{struct RemHGLOBAL { + fNullHGlobal: LONG, + cbData: ULONG, + data: [byte; 1], +}} +STRUCT!{struct RemHMETAFILEPICT { + mm: LONG, + xExt: LONG, + yExt: LONG, + cbData: ULONG, + data: [byte; 1], +}} +STRUCT!{struct RemHENHMETAFILE { + cbData: ULONG, + data: [byte; 1], +}} +STRUCT!{struct RemHBITMAP { + cbData: ULONG, + data: [byte; 1], +}} +STRUCT!{struct RemHPALETTE { + cbData: ULONG, + data: [byte; 1], +}} +STRUCT!{struct RemHBRUSH { + cbData: ULONG, + data: [byte; 1], +}} +pub const ROTFLAGS_REGISTRATIONKEEPSALIVE: DWORD = 0x1; +pub const ROTFLAGS_ALLOWANYCLIENT: DWORD = 0x2; +pub const ROT_COMPARE_MAX: DWORD = 2048; +ENUM!{enum DVASPECT { + DVASPECT_CONTENT = 1, + DVASPECT_THUMBNAIL = 2, + DVASPECT_ICON = 4, + DVASPECT_DOCPRINT = 8, +}} +ENUM!{enum STGC { + STGC_DEFAULT = 0, + STGC_OVERWRITE = 1, + STGC_ONLYIFCURRENT = 2, + STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4, + STGC_CONSOLIDATE = 8, +}} +ENUM!{enum STGMOVE { + STGMOVE_MOVE = 0, + STGMOVE_COPY = 1, + STGMOVE_SHALLOWCOPY = 2, +}} +ENUM!{enum STATFLAG { + STATFLAG_DEFAULT = 0, + STATFLAG_NONAME = 1, + STATFLAG_NOOPEN = 2, +}} +pub type HCONTEXT = *mut c_void; +pub const WDT_INPROC_CALL: ULONG = 0x48746457; +pub const WDT_REMOTE_CALL: ULONG = 0x52746457; +pub const WDT_INPROC64_CALL: ULONG = 0x50746457; +UNION!{union userCLIPFORMAT_u { + [usize; 1], + dwValue dwValue_mut: DWORD, + pwszName pwszName_mut: *mut wchar_t, +}} +STRUCT!{struct userCLIPFORMAT { + fContext: LONG, + u: userCLIPFORMAT_u, +}} +pub type wireCLIPFORMAT = *mut userCLIPFORMAT; +pub type CLIPFORMAT = WORD; +UNION!{union GDI_NONREMOTE_u { + [usize; 1], + hInproc hInproc_mut: LONG, + hRemote hRemote_mut: *mut DWORD_BLOB, +}} +STRUCT!{struct GDI_NONREMOTE { + fContext: LONG, + u: GDI_NONREMOTE_u, +}} +UNION!{union userHGLOBAL_u { + [u64; 1], + hInproc hInproc_mut: LONG, + hRemote hRemote_mut: *mut FLAGGED_BYTE_BLOB, + hInproc64 hInproc64_mut: __int64, +}} +STRUCT!{struct userHGLOBAL { + fContext: LONG, + u: userHGLOBAL_u, +}} +pub type wireHGLOBAL = *mut userHGLOBAL; +UNION!{union userHMETAFILE_u { + [u64; 1], + hInproc hInproc_mut: LONG, + hRemote hRemote_mut: *mut BYTE_BLOB, + hInproc64 hInproc64_mut: __int64, +}} +STRUCT!{struct userHMETAFILE { + fContext: LONG, + u: userHMETAFILE_u, +}} +STRUCT!{struct remoteMETAFILEPICT { + mm: LONG, + xExt: LONG, + yExt: LONG, + hMF: *mut userHMETAFILE, +}} +UNION!{union userHMETAFILEPICT_u { + [u64; 1], + hInproc hInproc_mut: LONG, + hRemote hRemote_mut: *mut remoteMETAFILEPICT, + hInproc64 hInproc64_mut: __int64, +}} +STRUCT!{struct userHMETAFILEPICT { + fContext: LONG, + u: userHMETAFILEPICT_u, +}} +UNION!{union userHENHMETAFILE_u { + [u64; 1], + hInproc hInproc_mut: LONG, + hRemote hRemote_mut: *mut BYTE_BLOB, + hInproc64 hInproc64_mut: __int64, +}} +STRUCT!{struct userHENHMETAFILE { + fContext: LONG, + u: userHENHMETAFILE_u, +}} +STRUCT!{struct userBITMAP { + bmType: LONG, + bmWidth: LONG, + bmHeight: LONG, + bmWidthBytes: LONG, + bmPlanes: WORD, + bmBitsPixel: WORD, + cbSize: ULONG, + pBuffer: [byte; 1], +}} +UNION!{union userHBITMAP_u { + [u64; 1], + hInproc hInproc_mut: LONG, + hRemote hRemote_mut: *mut userBITMAP, + hInproc64 hInproc64_mut: __int64, +}} +STRUCT!{struct userHBITMAP { + fContext: LONG, + u: userHBITMAP_u, +}} +UNION!{union userHPALETTE_u { + [u64; 1], + hInproc hInproc_mut: LONG, + hRemote hRemote_mut: *mut LOGPALETTE, + hInproc64 hInproc64_mut: __int64, +}} +STRUCT!{struct userHPALETTE { + fContext: LONG, + u: userHPALETTE_u, +}} +UNION!{union RemotableHandle_u { + [u32; 1], + hInproc hInproc_mut: LONG, + hRemote hRemote_mut: LONG, +}} +STRUCT!{struct RemotableHandle { + fContext: LONG, + u: RemotableHandle_u, +}} +pub type wireHWND = *mut RemotableHandle; +pub type wireHMENU = *mut RemotableHandle; +pub type wireHACCEL = *mut RemotableHandle; +pub type wireHBRUSH = *mut RemotableHandle; +pub type wireHFONT = *mut RemotableHandle; +pub type wireHDC = *mut RemotableHandle; +pub type wireHICON = *mut RemotableHandle; +pub type wireHRGN = *mut RemotableHandle; +pub type wireHMONITOR = *mut RemotableHandle; +pub type wireHBITMAP = *mut userHBITMAP; +pub type wireHPALETTE = *mut userHPALETTE; +pub type wireHENHMETAFILE = *mut userHENHMETAFILE; +pub type wireHMETAFILE = *mut userHMETAFILE; +pub type wireHMETAFILEPICT = *mut userHMETAFILEPICT; +pub type HMETAFILEPICT = *mut c_void; +// extern RPC_IF_HANDLE IWinTypes_v0_1_c_ifspec; +// extern RPC_IF_HANDLE IWinTypes_v0_1_s_ifspec; +pub type DATE = c_double; +STRUCT!{struct CY { + int64: LONGLONG, +}} +pub type LPCY = *mut CY; +STRUCT!{struct DECIMAL { + wReserved: USHORT, + scale: BYTE, + sign: BYTE, + Hi32: ULONG, + Lo64: ULONGLONG, +}} +pub const DECIMAL_NEG: BYTE = 0x80; +#[inline] +pub fn DECIMAL_SETZERO(dec: &mut DECIMAL) { + dec.Lo64 = 0; + dec.Hi32 = 0; + dec.scale = 0; + dec.sign = 0; +} +pub type LPDECIMAL = *mut DECIMAL; +pub type wireBSTR = *mut FLAGGED_WORD_BLOB; +pub type BSTR = *mut OLECHAR; +pub type LPBSTR = *mut BSTR; +pub type VARIANT_BOOL = c_short; +STRUCT!{struct BSTRBLOB { + cbSize: ULONG, + pData: *mut BYTE, +}} +pub type LPBSTRBLOB = *mut BSTRBLOB; +pub const VARIANT_TRUE: VARIANT_BOOL = -1; +pub const VARIANT_FALSE: VARIANT_BOOL = 0; +STRUCT!{struct CLIPDATA { + cbSize: ULONG, + ulClipFmt: LONG, + pClipData: *mut BYTE, +}} +#[inline] +pub fn CBPCLIPDATA(clipdata: CLIPDATA) -> ULONG { + clipdata.cbSize - 4 +} +pub type VARTYPE = c_ushort; +ENUM!{enum VARENUM { + VT_EMPTY = 0, + VT_NULL = 1, + VT_I2 = 2, + VT_I4 = 3, + VT_R4 = 4, + VT_R8 = 5, + VT_CY = 6, + VT_DATE = 7, + VT_BSTR = 8, + VT_DISPATCH = 9, + VT_ERROR = 10, + VT_BOOL = 11, + VT_VARIANT = 12, + VT_UNKNOWN = 13, + VT_DECIMAL = 14, + VT_I1 = 16, + VT_UI1 = 17, + VT_UI2 = 18, + VT_UI4 = 19, + VT_I8 = 20, + VT_UI8 = 21, + VT_INT = 22, + VT_UINT = 23, + VT_VOID = 24, + VT_HRESULT = 25, + VT_PTR = 26, + VT_SAFEARRAY = 27, + VT_CARRAY = 28, + VT_USERDEFINED = 29, + VT_LPSTR = 30, + VT_LPWSTR = 31, + VT_RECORD = 36, + VT_INT_PTR = 37, + VT_UINT_PTR = 38, + VT_FILETIME = 64, + VT_BLOB = 65, + VT_STREAM = 66, + VT_STORAGE = 67, + VT_STREAMED_OBJECT = 68, + VT_STORED_OBJECT = 69, + VT_BLOB_OBJECT = 70, + VT_CF = 71, + VT_CLSID = 72, + VT_VERSIONED_STREAM = 73, + VT_BSTR_BLOB = 0xfff, + VT_VECTOR = 0x1000, + VT_ARRAY = 0x2000, + VT_BYREF = 0x4000, + VT_RESERVED = 0x8000, + VT_ILLEGAL = 0xffff, + VT_ILLEGALMASKED = 0xfff, + VT_TYPEMASK = 0xfff, +}} +pub type PROPID = ULONG; +STRUCT!{struct PROPERTYKEY { + fmtid: GUID, + pid: DWORD, +}} +STRUCT!{struct CSPLATFORM { + dwPlatformId: DWORD, + dwVersionHi: DWORD, + dwVersionLo: DWORD, + dwProcessorArch: DWORD, +}} +STRUCT!{struct QUERYCONTEXT { + dwContext: DWORD, + Platform: CSPLATFORM, + Locale: LCID, + dwVersionHi: DWORD, + dwVersionLo: DWORD, +}} +ENUM!{enum TYSPEC { + TYSPEC_CLSID, + TYSPEC_FILEEXT, + TYSPEC_MIMETYPE, + TYSPEC_FILENAME, + TYSPEC_PROGID, + TYSPEC_PACKAGENAME, + TYSPEC_OBJECTID, +}} +STRUCT!{struct uCLSSPEC_ByName { + pPackageName: LPOLESTR, + PolicyId: GUID, +}} +STRUCT!{struct uCLSSPEC_ByObjectId { + ObjectId: GUID, + PolicyId: GUID, +}} +UNION!{union uCLSSPEC_u { + [u32; 8] [u64; 4], + clsid clsid_mut: CLSID, + pFileExt pFileExt_mut: LPOLESTR, + pMimeType pMimeType_mut: LPOLESTR, + pProgId pProgId_mut: LPOLESTR, + pFileName pFileName_mut: LPOLESTR, + ByName ByName_mut: uCLSSPEC_ByName, + ByObjectId ByObjectId_mut: uCLSSPEC_ByObjectId, +}} +STRUCT!{struct uCLSSPEC { + tyspec: DWORD, + u: uCLSSPEC_u, +}} +// extern RPC_IF_HANDLE __MIDL_itf_wtypes_0000_0001_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wtypes_0000_0001_v0_0_s_ifspec; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/shared/wtypesbase.rs b/third_party/cargo/vendor/winapi-0.3.8/src/shared/wtypesbase.rs new file mode 100644 index 0000000..e8ca7ee --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/shared/wtypesbase.rs @@ -0,0 +1,161 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_double, c_short, c_uchar, c_ushort}; +use shared::minwindef::{BYTE, DWORD}; +use shared::rpcndr::{boolean, byte, hyper}; +use um::winnt::{LONG, LPWSTR, WCHAR}; +pub type OLECHAR = WCHAR; +pub type LPOLESTR = *mut OLECHAR; +pub type LPCOLESTR = *const OLECHAR; +pub type UCHAR = c_uchar; +pub type SHORT = c_short; +pub type USHORT = c_ushort; +pub type ULONG = DWORD; +pub type DOUBLE = c_double; +STRUCT!{struct COAUTHIDENTITY { + User: *mut USHORT, + UserLength: ULONG, + Domain: *mut USHORT, + DomainLength: ULONG, + Password: *mut USHORT, + PasswordLength: ULONG, + Flags: ULONG, +}} +STRUCT!{struct COAUTHINFO { + dwAuthnSvc: DWORD, + dwAuthzSvc: DWORD, + pwszServerPrincName: LPWSTR, + dwAuthnLevel: DWORD, + dwImpersonationLevel: DWORD, + pAuthIdentityData: *mut COAUTHIDENTITY, + dwCapabilities: DWORD, +}} +pub type SCODE = LONG; +pub type PSCODE = *mut SCODE; +ENUM!{enum MEMCTX { + MEMCTX_TASK = 1, + MEMCTX_SHARED = 2, + MEMCTX_MACSYSTEM = 3, + MEMCTX_UNKNOWN = -1i32 as u32, + MEMCTX_SAME = -2i32 as u32, +}} +pub const ROTREGFLAGS_ALLOWANYCLIENT: DWORD = 0x1; +pub const APPIDREGFLAGS_ACTIVATE_IUSERVER_INDESKTOP: DWORD = 0x1; +pub const APPIDREGFLAGS_SECURE_SERVER_PROCESS_SD_AND_BIND: DWORD = 0x2; +pub const APPIDREGFLAGS_ISSUE_ACTIVATION_RPC_AT_IDENTIFY: DWORD = 0x4; +pub const APPIDREGFLAGS_IUSERVER_UNMODIFIED_LOGON_TOKEN: DWORD = 0x8; +pub const APPIDREGFLAGS_IUSERVER_SELF_SID_IN_LAUNCH_PERMISSION: DWORD = 0x10; +pub const APPIDREGFLAGS_IUSERVER_ACTIVATE_IN_CLIENT_SESSION_ONLY: DWORD = 0x20; +pub const APPIDREGFLAGS_RESERVED1: DWORD = 0x40; +pub const APPIDREGFLAGS_RESERVED2: DWORD = 0x80; +pub const APPIDREGFLAGS_RESERVED3: DWORD = 0x100; +pub const APPIDREGFLAGS_RESERVED4: DWORD = 0x200; +pub const APPIDREGFLAGS_RESERVED5: DWORD = 0x400; +pub const APPIDREGFLAGS_RESERVED6: DWORD = 0x800; +pub const DCOMSCM_ACTIVATION_USE_ALL_AUTHNSERVICES: DWORD = 0x1; +pub const DCOMSCM_ACTIVATION_DISALLOW_UNSECURE_CALL: DWORD = 0x2; +pub const DCOMSCM_RESOLVE_USE_ALL_AUTHNSERVICES: DWORD = 0x4; +pub const DCOMSCM_RESOLVE_DISALLOW_UNSECURE_CALL: DWORD = 0x8; +pub const DCOMSCM_PING_USE_MID_AUTHNSERVICE: DWORD = 0x10; +pub const DCOMSCM_PING_DISALLOW_UNSECURE_CALL: DWORD = 0x20; +ENUM!{enum CLSCTX { + CLSCTX_INPROC_SERVER = 0x1, + CLSCTX_INPROC_HANDLER = 0x2, + CLSCTX_LOCAL_SERVER = 0x4, + CLSCTX_INPROC_SERVER16 = 0x8, + CLSCTX_REMOTE_SERVER = 0x10, + CLSCTX_INPROC_HANDLER16 = 0x20, + CLSCTX_RESERVED1 = 0x40, + CLSCTX_RESERVED2 = 0x80, + CLSCTX_RESERVED3 = 0x100, + CLSCTX_RESERVED4 = 0x200, + CLSCTX_NO_CODE_DOWNLOAD = 0x400, + CLSCTX_RESERVED5 = 0x800, + CLSCTX_NO_CUSTOM_MARSHAL = 0x1000, + CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000, + CLSCTX_NO_FAILURE_LOG = 0x4000, + CLSCTX_DISABLE_AAA = 0x8000, + CLSCTX_ENABLE_AAA = 0x10000, + CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000, + CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000, + CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000, + CLSCTX_ENABLE_CLOAKING = 0x100000, + CLSCTX_APPCONTAINER = 0x400000, + CLSCTX_ACTIVATE_AAA_AS_IU = 0x800000, + CLSCTX_PS_DLL = 0x80000000, +}} +pub const CLSCTX_VALID_MASK: CLSCTX = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER + | CLSCTX_LOCAL_SERVER | CLSCTX_INPROC_SERVER16 | CLSCTX_REMOTE_SERVER + | CLSCTX_NO_CODE_DOWNLOAD | CLSCTX_NO_CUSTOM_MARSHAL | CLSCTX_ENABLE_CODE_DOWNLOAD + | CLSCTX_NO_FAILURE_LOG | CLSCTX_DISABLE_AAA | CLSCTX_ENABLE_AAA | CLSCTX_FROM_DEFAULT_CONTEXT + | CLSCTX_ACTIVATE_32_BIT_SERVER | CLSCTX_ACTIVATE_64_BIT_SERVER | CLSCTX_ENABLE_CLOAKING + | CLSCTX_APPCONTAINER | CLSCTX_ACTIVATE_AAA_AS_IU | CLSCTX_PS_DLL; +ENUM!{enum MSHLFLAGS { + MSHLFLAGS_NORMAL = 0, + MSHLFLAGS_TABLESTRONG = 1, + MSHLFLAGS_TABLEWEAK = 2, + MSHLFLAGS_NOPING = 4, + MSHLFLAGS_RESERVED1 = 8, + MSHLFLAGS_RESERVED2 = 16, + MSHLFLAGS_RESERVED3 = 32, + MSHLFLAGS_RESERVED4 = 64, +}} +ENUM!{enum MSHCTX { + MSHCTX_LOCAL = 0, + MSHCTX_NOSHAREDMEM = 1, + MSHCTX_DIFFERENTMACHINE = 2, + MSHCTX_INPROC = 3, + MSHCTX_CROSSCTX = 4, +}} +STRUCT!{struct BYTE_BLOB { + clSize: ULONG, + abData: [byte; 1], +}} +pub type UP_BYTE_BLOB = *mut BYTE_BLOB; +STRUCT!{struct WORD_BLOB { + clSize: ULONG, + asData: [c_ushort; 1], +}} +pub type UP_WORD_BLOB = *mut WORD_BLOB; +STRUCT!{struct DWORD_BLOB { + clSize: ULONG, + alData: [ULONG; 1], +}} +pub type UP_DWORD_BLOB = *mut DWORD_BLOB; +STRUCT!{struct FLAGGED_BYTE_BLOB { + fFlags: ULONG, + clSize: ULONG, + abData: [byte; 1], +}} +pub type UP_FLAGGED_BYTE_BLOB = *mut FLAGGED_BYTE_BLOB; +STRUCT!{struct FLAGGED_WORD_BLOB { + fFlags: ULONG, + clSize: ULONG, + alData: [ULONG; 1], +}} +pub type UP_FLAGGED_WORD_BLOB = *mut FLAGGED_WORD_BLOB; +STRUCT!{struct BYTE_SIZEDARR { + clSize: ULONG, + pData: *mut byte, +}} +STRUCT!{struct WORD_SIZEDARR { + clSize: ULONG, + pData: *mut c_ushort, +}} +STRUCT!{struct DWORD_SIZEDARR { + clSize: ULONG, + pData: *mut ULONG, +}} +STRUCT!{struct HYPER_SIZEDARR { + clSize: ULONG, + pData: *mut hyper, +}} +pub type BOOLEAN = boolean; +STRUCT!{struct BLOB { + cbSize: ULONG, + pBlobData: *mut BYTE, +}} +pub type LPBLOB = *mut BLOB; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/accctrl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/accctrl.rs new file mode 100644 index 0000000..829ce57 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/accctrl.rs @@ -0,0 +1,371 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, ULONG}; +use um::winbase::LocalFree; +use um::winnt::{HANDLE, LONG, LPSTR, LPWSTR, PVOID, SID}; +#[inline] +pub unsafe fn AccFree(p: PVOID) -> PVOID { + LocalFree(p) +} +ENUM!{enum SE_OBJECT_TYPE { + SE_UNKNOWN_OBJECT_TYPE = 0, + SE_FILE_OBJECT, + SE_SERVICE, + SE_PRINTER, + SE_REGISTRY_KEY, + SE_LMSHARE, + SE_KERNEL_OBJECT, + SE_WINDOW_OBJECT, + SE_DS_OBJECT, + SE_DS_OBJECT_ALL, + SE_PROVIDER_DEFINED_OBJECT, + SE_WMIGUID_OBJECT, + SE_REGISTRY_WOW64_32KEY, + SE_REGISTRY_WOW64_64KEY, +}} +ENUM!{enum TRUSTEE_TYPE { + TRUSTEE_IS_UNKNOWN, + TRUSTEE_IS_USER, + TRUSTEE_IS_GROUP, + TRUSTEE_IS_DOMAIN, + TRUSTEE_IS_ALIAS, + TRUSTEE_IS_WELL_KNOWN_GROUP, + TRUSTEE_IS_DELETED, + TRUSTEE_IS_INVALID, + TRUSTEE_IS_COMPUTER, +}} +ENUM!{enum TRUSTEE_FORM { + TRUSTEE_IS_SID, + TRUSTEE_IS_NAME, + TRUSTEE_BAD_FORM, + TRUSTEE_IS_OBJECTS_AND_SID, + TRUSTEE_IS_OBJECTS_AND_NAME, +}} +ENUM!{enum MULTIPLE_TRUSTEE_OPERATION { + NO_MULTIPLE_TRUSTEE, + TRUSTEE_IS_IMPERSONATE, +}} +STRUCT!{struct OBJECTS_AND_SID { + ObjectsPresent: DWORD, + ObjectTypeGuid: GUID, + InheritedObjectTypeGuid: GUID, + pSid: *mut SID, +}} +pub type POBJECTS_AND_SID = *mut OBJECTS_AND_SID; +STRUCT!{struct OBJECTS_AND_NAME_A { + ObjectsPresent: DWORD, + ObjectType: SE_OBJECT_TYPE, + ObjectTypeName: LPSTR, + InheritedObjectTypeName: LPSTR, + ptstrName: LPSTR, +}} +pub type POBJECTS_AND_NAME_A = *mut OBJECTS_AND_NAME_A; +STRUCT!{struct OBJECTS_AND_NAME_W { + ObjectsPresent: DWORD, + ObjectType: SE_OBJECT_TYPE, + ObjectTypeName: LPWSTR, + InheritedObjectTypeName: LPWSTR, + ptstrName: LPWSTR, +}} +pub type POBJECTS_AND_NAME_W = *mut OBJECTS_AND_NAME_W; +STRUCT!{struct TRUSTEE_A { + pMultipleTrustee: *mut TRUSTEE_A, + MultipleTrusteeOperation: MULTIPLE_TRUSTEE_OPERATION, + TrusteeForm: TRUSTEE_FORM, + TrusteeType: TRUSTEE_TYPE, + ptstrName: LPSTR, +}} +pub type PTRUSTEE_A = *mut TRUSTEE_A; +pub type TRUSTEEA = TRUSTEE_A; +pub type PTRUSTEEA = PTRUSTEE_A; +STRUCT!{struct TRUSTEE_W { + pMultipleTrustee: *mut TRUSTEE_W, + MultipleTrusteeOperation: MULTIPLE_TRUSTEE_OPERATION, + TrusteeForm: TRUSTEE_FORM, + TrusteeType: TRUSTEE_TYPE, + ptstrName: LPWSTR, +}} +pub type PTRUSTEE_W = *mut TRUSTEE_W; +pub type TRUSTEEW = TRUSTEE_W; +pub type PTRUSTEEW = PTRUSTEE_W; +ENUM!{enum ACCESS_MODE { + NOT_USED_ACCESS = 0, + GRANT_ACCESS, + SET_ACCESS, + DENY_ACCESS, + REVOKE_ACCESS, + SET_AUDIT_SUCCESS, + SET_AUDIT_FAILURE, +}} +pub const NO_INHERITANCE: DWORD = 0x0; +pub const SUB_OBJECTS_ONLY_INHERIT: DWORD = 0x1; +pub const SUB_CONTAINERS_ONLY_INHERIT: DWORD = 0x2; +pub const SUB_CONTAINERS_AND_OBJECTS_INHERIT: DWORD = 0x3; +pub const INHERIT_NO_PROPAGATE: DWORD = 0x4; +pub const INHERIT_ONLY: DWORD = 0x8; +pub const INHERITED_ACCESS_ENTRY: DWORD = 0x10; +pub const INHERITED_PARENT: DWORD = 0x10000000; +pub const INHERITED_GRANDPARENT: DWORD = 0x20000000; +STRUCT!{struct EXPLICIT_ACCESS_A { + grfAccessPermissions: DWORD, + grfAccessMode: ACCESS_MODE, + grfInheritance: DWORD, + Trustee: TRUSTEE_A, +}} +pub type PEXPLICIT_ACCESS_A = *mut EXPLICIT_ACCESS_A; +pub type EXPLICIT_ACCESSA = EXPLICIT_ACCESS_A; +pub type PEXPLICIT_ACCESSA = PEXPLICIT_ACCESS_A; +STRUCT!{struct EXPLICIT_ACCESS_W { + grfAccessPermissions: DWORD, + grfAccessMode: ACCESS_MODE, + grfInheritance: DWORD, + Trustee: TRUSTEE_W, +}} +pub type PEXPLICIT_ACCESS_W = *mut EXPLICIT_ACCESS_W; +pub type EXPLICIT_ACCESSW = EXPLICIT_ACCESS_W; +pub type PEXPLICIT_ACCESSW = PEXPLICIT_ACCESS_W; +pub const ACCCTRL_DEFAULT_PROVIDER: &'static str = "Windows NT Access Provider"; +pub type ACCESS_RIGHTS = ULONG; +pub type PACCESS_RIGHTS = *mut ACCESS_RIGHTS; +pub type INHERIT_FLAGS = ULONG; +pub type PINHERIT_FLAGS = *mut INHERIT_FLAGS; +STRUCT!{struct ACTRL_ACCESS_ENTRYA { + Trustee: TRUSTEE_A, + fAccessFlags: ULONG, + Access: ACCESS_RIGHTS, + ProvSpecificAccess: ACCESS_RIGHTS, + Inheritance: INHERIT_FLAGS, + lpInheritProperty: LPSTR, +}} +pub type PACTRL_ACCESS_ENTRYA = *mut ACTRL_ACCESS_ENTRYA; +STRUCT!{struct ACTRL_ACCESS_ENTRYW { + Trustee: TRUSTEE_W, + fAccessFlags: ULONG, + Access: ACCESS_RIGHTS, + ProvSpecificAccess: ACCESS_RIGHTS, + Inheritance: INHERIT_FLAGS, + lpInheritProperty: LPWSTR, +}} +pub type PACTRL_ACCESS_ENTRYW = *mut ACTRL_ACCESS_ENTRYW; +STRUCT!{struct ACTRL_ACCESS_ENTRY_LISTA { + cEntries: ULONG, + pAccessList: *mut ACTRL_ACCESS_ENTRYA, +}} +pub type PACTRL_ACCESS_ENTRY_LISTA = *mut ACTRL_ACCESS_ENTRY_LISTA; +STRUCT!{struct ACTRL_ACCESS_ENTRY_LISTW { + cEntries: ULONG, + pAccessList: *mut ACTRL_ACCESS_ENTRYW, +}} +pub type PACTRL_ACCESS_ENTRY_LISTW = *mut ACTRL_ACCESS_ENTRY_LISTW; +STRUCT!{struct ACTRL_PROPERTY_ENTRYA { + lpProperty: LPSTR, + pAccessEntryList: PACTRL_ACCESS_ENTRY_LISTA, + fListFlags: ULONG, +}} +pub type PACTRL_PROPERTY_ENTRYA = *mut ACTRL_PROPERTY_ENTRYA; +STRUCT!{struct ACTRL_PROPERTY_ENTRYW { + lpProperty: LPWSTR, + pAccessEntryList: PACTRL_ACCESS_ENTRY_LISTW, + fListFlags: ULONG, +}} +pub type PACTRL_PROPERTY_ENTRYW = *mut ACTRL_PROPERTY_ENTRYW; +STRUCT!{struct ACTRL_ACCESSA { + cEntries: ULONG, + pPropertyAccessList: PACTRL_PROPERTY_ENTRYA, +}} +pub type PACTRL_ACCESSA = *mut ACTRL_ACCESSA; +pub type ACTRL_AUDITA = ACTRL_ACCESSA; +pub type PACTRL_AUDITA = *mut ACTRL_AUDITA; +STRUCT!{struct ACTRL_ACCESSW { + cEntries: ULONG, + pPropertyAccessList: PACTRL_PROPERTY_ENTRYW, +}} +pub type PACTRL_ACCESSW = *mut ACTRL_ACCESSW; +pub type ACTRL_AUDITW = ACTRL_ACCESSW; +pub type PACTRL_AUDITW = *mut ACTRL_AUDITW; +pub const TRUSTEE_ACCESS_ALLOWED: ULONG = 0x00000001; +pub const TRUSTEE_ACCESS_READ: ULONG = 0x00000002; +pub const TRUSTEE_ACCESS_WRITE: ULONG = 0x00000004; +pub const TRUSTEE_ACCESS_EXPLICIT: ULONG = 0x00000001; +pub const TRUSTEE_ACCESS_READ_WRITE: ULONG = TRUSTEE_ACCESS_READ | TRUSTEE_ACCESS_WRITE; +pub const TRUSTEE_ACCESS_ALL: ULONG = 0xFFFFFFFF; +STRUCT!{struct TRUSTEE_ACCESSA { + lpProperty: LPSTR, + Access: ACCESS_RIGHTS, + fAccessFlags: ULONG, + fReturnedAccess: ULONG, +}} +pub type PTRUSTEE_ACCESSA = *mut TRUSTEE_ACCESSA; +STRUCT!{struct TRUSTEE_ACCESSW { + lpProperty: LPWSTR, + Access: ACCESS_RIGHTS, + fAccessFlags: ULONG, + fReturnedAccess: ULONG, +}} +pub type PTRUSTEE_ACCESSW = *mut TRUSTEE_ACCESSW; +pub const ACTRL_RESERVED: ULONG = 0x00000000; +pub const ACTRL_PERM_1: ULONG = 0x00000001; +pub const ACTRL_PERM_2: ULONG = 0x00000002; +pub const ACTRL_PERM_3: ULONG = 0x00000004; +pub const ACTRL_PERM_4: ULONG = 0x00000008; +pub const ACTRL_PERM_5: ULONG = 0x00000010; +pub const ACTRL_PERM_6: ULONG = 0x00000020; +pub const ACTRL_PERM_7: ULONG = 0x00000040; +pub const ACTRL_PERM_8: ULONG = 0x00000080; +pub const ACTRL_PERM_9: ULONG = 0x00000100; +pub const ACTRL_PERM_10: ULONG = 0x00000200; +pub const ACTRL_PERM_11: ULONG = 0x00000400; +pub const ACTRL_PERM_12: ULONG = 0x00000800; +pub const ACTRL_PERM_13: ULONG = 0x00001000; +pub const ACTRL_PERM_14: ULONG = 0x00002000; +pub const ACTRL_PERM_15: ULONG = 0x00004000; +pub const ACTRL_PERM_16: ULONG = 0x00008000; +pub const ACTRL_PERM_17: ULONG = 0x00010000; +pub const ACTRL_PERM_18: ULONG = 0x00020000; +pub const ACTRL_PERM_19: ULONG = 0x00040000; +pub const ACTRL_PERM_20: ULONG = 0x00080000; +pub const ACTRL_ACCESS_ALLOWED: ULONG = 0x00000001; +pub const ACTRL_ACCESS_DENIED: ULONG = 0x00000002; +pub const ACTRL_AUDIT_SUCCESS: ULONG = 0x00000004; +pub const ACTRL_AUDIT_FAILURE: ULONG = 0x00000008; +pub const ACTRL_ACCESS_PROTECTED: ULONG = 0x00000001; +pub const ACTRL_SYSTEM_ACCESS: ULONG = 0x04000000; +pub const ACTRL_DELETE: ULONG = 0x08000000; +pub const ACTRL_READ_CONTROL: ULONG = 0x10000000; +pub const ACTRL_CHANGE_ACCESS: ULONG = 0x20000000; +pub const ACTRL_CHANGE_OWNER: ULONG = 0x40000000; +pub const ACTRL_SYNCHRONIZE: ULONG = 0x80000000; +pub const ACTRL_STD_RIGHTS_ALL: ULONG = 0xf8000000; +pub const ACTRL_STD_RIGHT_REQUIRED: ULONG = ACTRL_STD_RIGHTS_ALL & !ACTRL_SYNCHRONIZE; +pub const ACTRL_DS_OPEN: ULONG = ACTRL_RESERVED; +pub const ACTRL_DS_CREATE_CHILD: ULONG = ACTRL_PERM_1; +pub const ACTRL_DS_DELETE_CHILD: ULONG = ACTRL_PERM_2; +pub const ACTRL_DS_LIST: ULONG = ACTRL_PERM_3; +pub const ACTRL_DS_SELF: ULONG = ACTRL_PERM_4; +pub const ACTRL_DS_READ_PROP: ULONG = ACTRL_PERM_5; +pub const ACTRL_DS_WRITE_PROP: ULONG = ACTRL_PERM_6; +pub const ACTRL_DS_DELETE_TREE: ULONG = ACTRL_PERM_7; +pub const ACTRL_DS_LIST_OBJECT: ULONG = ACTRL_PERM_8; +pub const ACTRL_DS_CONTROL_ACCESS: ULONG = ACTRL_PERM_9; +pub const ACTRL_FILE_READ: ULONG = ACTRL_PERM_1; +pub const ACTRL_FILE_WRITE: ULONG = ACTRL_PERM_2; +pub const ACTRL_FILE_APPEND: ULONG = ACTRL_PERM_3; +pub const ACTRL_FILE_READ_PROP: ULONG = ACTRL_PERM_4; +pub const ACTRL_FILE_WRITE_PROP: ULONG = ACTRL_PERM_5; +pub const ACTRL_FILE_EXECUTE: ULONG = ACTRL_PERM_6; +pub const ACTRL_FILE_READ_ATTRIB: ULONG = ACTRL_PERM_8; +pub const ACTRL_FILE_WRITE_ATTRIB: ULONG = ACTRL_PERM_9; +pub const ACTRL_FILE_CREATE_PIPE: ULONG = ACTRL_PERM_10; +pub const ACTRL_DIR_LIST: ULONG = ACTRL_PERM_1; +pub const ACTRL_DIR_CREATE_OBJECT: ULONG = ACTRL_PERM_2; +pub const ACTRL_DIR_CREATE_CHILD: ULONG = ACTRL_PERM_3; +pub const ACTRL_DIR_DELETE_CHILD: ULONG = ACTRL_PERM_7; +pub const ACTRL_DIR_TRAVERSE: ULONG = ACTRL_PERM_6; +pub const ACTRL_KERNEL_TERMINATE: ULONG = ACTRL_PERM_1; +pub const ACTRL_KERNEL_THREAD: ULONG = ACTRL_PERM_2; +pub const ACTRL_KERNEL_VM: ULONG = ACTRL_PERM_3; +pub const ACTRL_KERNEL_VM_READ: ULONG = ACTRL_PERM_4; +pub const ACTRL_KERNEL_VM_WRITE: ULONG = ACTRL_PERM_5; +pub const ACTRL_KERNEL_DUP_HANDLE: ULONG = ACTRL_PERM_6; +pub const ACTRL_KERNEL_PROCESS: ULONG = ACTRL_PERM_7; +pub const ACTRL_KERNEL_SET_INFO: ULONG = ACTRL_PERM_8; +pub const ACTRL_KERNEL_GET_INFO: ULONG = ACTRL_PERM_9; +pub const ACTRL_KERNEL_CONTROL: ULONG = ACTRL_PERM_10; +pub const ACTRL_KERNEL_ALERT: ULONG = ACTRL_PERM_11; +pub const ACTRL_KERNEL_GET_CONTEXT: ULONG = ACTRL_PERM_12; +pub const ACTRL_KERNEL_SET_CONTEXT: ULONG = ACTRL_PERM_13; +pub const ACTRL_KERNEL_TOKEN: ULONG = ACTRL_PERM_14; +pub const ACTRL_KERNEL_IMPERSONATE: ULONG = ACTRL_PERM_15; +pub const ACTRL_KERNEL_DIMPERSONATE: ULONG = ACTRL_PERM_16; +pub const ACTRL_PRINT_SADMIN: ULONG = ACTRL_PERM_1; +pub const ACTRL_PRINT_SLIST: ULONG = ACTRL_PERM_2; +pub const ACTRL_PRINT_PADMIN: ULONG = ACTRL_PERM_3; +pub const ACTRL_PRINT_PUSE: ULONG = ACTRL_PERM_4; +pub const ACTRL_PRINT_JADMIN: ULONG = ACTRL_PERM_5; +pub const ACTRL_SVC_GET_INFO: ULONG = ACTRL_PERM_1; +pub const ACTRL_SVC_SET_INFO: ULONG = ACTRL_PERM_2; +pub const ACTRL_SVC_STATUS: ULONG = ACTRL_PERM_3; +pub const ACTRL_SVC_LIST: ULONG = ACTRL_PERM_4; +pub const ACTRL_SVC_START: ULONG = ACTRL_PERM_5; +pub const ACTRL_SVC_STOP: ULONG = ACTRL_PERM_6; +pub const ACTRL_SVC_PAUSE: ULONG = ACTRL_PERM_7; +pub const ACTRL_SVC_INTERROGATE: ULONG = ACTRL_PERM_8; +pub const ACTRL_SVC_UCONTROL: ULONG = ACTRL_PERM_9; +pub const ACTRL_REG_QUERY: ULONG = ACTRL_PERM_1; +pub const ACTRL_REG_SET: ULONG = ACTRL_PERM_2; +pub const ACTRL_REG_CREATE_CHILD: ULONG = ACTRL_PERM_3; +pub const ACTRL_REG_LIST: ULONG = ACTRL_PERM_4; +pub const ACTRL_REG_NOTIFY: ULONG = ACTRL_PERM_5; +pub const ACTRL_REG_LINK: ULONG = ACTRL_PERM_6; +pub const ACTRL_WIN_CLIPBRD: ULONG = ACTRL_PERM_1; +pub const ACTRL_WIN_GLOBAL_ATOMS: ULONG = ACTRL_PERM_2; +pub const ACTRL_WIN_CREATE: ULONG = ACTRL_PERM_3; +pub const ACTRL_WIN_LIST_DESK: ULONG = ACTRL_PERM_4; +pub const ACTRL_WIN_LIST: ULONG = ACTRL_PERM_5; +pub const ACTRL_WIN_READ_ATTRIBS: ULONG = ACTRL_PERM_6; +pub const ACTRL_WIN_WRITE_ATTRIBS: ULONG = ACTRL_PERM_7; +pub const ACTRL_WIN_SCREEN: ULONG = ACTRL_PERM_8; +pub const ACTRL_WIN_EXIT: ULONG = ACTRL_PERM_9; +UNION!{union ACTRL_OVERLAPPED_u { + [u32; 1] [u64; 1], + Provider Provider_mut: PVOID, + Reserved1 Reserved1_mut: ULONG, +}} +STRUCT!{struct ACTRL_OVERLAPPED { + u: ACTRL_OVERLAPPED_u, + Reserved2: ULONG, + hEvent: HANDLE, +}} +pub type PACTRL_OVERLAPPED = *mut ACTRL_OVERLAPPED; +STRUCT!{struct ACTRL_ACCESS_INFOA { + fAccessPermission: ULONG, + lpAccessPermissionName: LPSTR, +}} +pub type PACTRL_ACCESS_INFOA = *mut ACTRL_ACCESS_INFOA; +STRUCT!{struct ACTRL_ACCESS_INFOW { + fAccessPermission: ULONG, + lpAccessPermissionName: LPWSTR, +}} +pub type PACTRL_ACCESS_INFOW = *mut ACTRL_ACCESS_INFOW; +STRUCT!{struct ACTRL_CONTROL_INFOA { + lpControlId: LPSTR, + lpControlName: LPSTR, +}} +pub type PACTRL_CONTROL_INFOA = *mut ACTRL_CONTROL_INFOA; +STRUCT!{struct ACTRL_CONTROL_INFOW { + lpControlId: LPWSTR, + lpControlName: LPWSTR, +}} +pub type PACTRL_CONTROL_INFOW = *mut ACTRL_CONTROL_INFOW; +pub const ACTRL_ACCESS_NO_OPTIONS: DWORD = 0x00000000; +pub const ACTRL_ACCESS_SUPPORTS_OBJECT_ENTRIES: DWORD = 0x00000001; +pub const TREE_SEC_INFO_SET: DWORD = 0x00000001; +pub const TREE_SEC_INFO_RESET: DWORD = 0x00000002; +pub const TREE_SEC_INFO_RESET_KEEP_EXPLICIT: DWORD = 0x00000003; +ENUM!{enum PROG_INVOKE_SETTING { + ProgressInvokeNever = 1, + ProgressInvokeEveryObject, + ProgressInvokeOnError, + ProgressCancelOperation, + ProgressRetryOperation, + ProgressInvokePrePostError, +}} +pub type PPROG_INVOKE_SETTING = *mut PROG_INVOKE_SETTING; +STRUCT!{struct FN_OBJECT_MGR_FUNCTS { + Placeholder: ULONG, +}} +pub type PFN_OBJECT_MGR_FUNCTS = *mut FN_OBJECT_MGR_FUNCTS; +STRUCT!{struct INHERITED_FROMA { + GenerationGap: LONG, + AncestorName: LPSTR, +}} +pub type PINHERITED_FROMA = *mut INHERITED_FROMA; +STRUCT!{struct INHERITED_FROMW { + GenerationGap: LONG, + AncestorName: LPWSTR, +}} +pub type PINHERITED_FROMW = *mut INHERITED_FROMW; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/aclapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/aclapi.rs new file mode 100644 index 0000000..5c2c5f1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/aclapi.rs @@ -0,0 +1,362 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, DWORD, PULONG, ULONG, USHORT}; +use um::accctrl::{ + ACCESS_MODE, MULTIPLE_TRUSTEE_OPERATION, PEXPLICIT_ACCESS_A, PEXPLICIT_ACCESS_W, + PFN_OBJECT_MGR_FUNCTS, PINHERITED_FROMA, PINHERITED_FROMW, POBJECTS_AND_NAME_A, + POBJECTS_AND_NAME_W, POBJECTS_AND_SID, PPROG_INVOKE_SETTING, PROG_INVOKE_SETTING, PTRUSTEE_A, + PTRUSTEE_W, SE_OBJECT_TYPE, TRUSTEE_FORM, TRUSTEE_TYPE +}; +use um::winnt::{ + HANDLE, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PACCESS_MASK, PACL, PGENERIC_MAPPING, + PSECURITY_DESCRIPTOR, PSID, PVOID, SECURITY_INFORMATION +}; +FN!{cdecl FN_PROGRESS( + pObjectName: LPWSTR, + Status: DWORD, + pInvokeSetting: PPROG_INVOKE_SETTING, + Args: PVOID, + SecuritySet: BOOL, +) -> ()} +extern "system" { + pub fn SetEntriesInAclA( + cCountOfExplicitEntries: ULONG, + pListOfExplicitEntries: PEXPLICIT_ACCESS_A, + OldAcl: PACL, + NewAcl: *mut PACL, + ) -> DWORD; + pub fn SetEntriesInAclW( + cCountOfExplicitEntries: ULONG, + pListOfExplicitEntries: PEXPLICIT_ACCESS_W, + OldAcl: PACL, + NewAcl: *mut PACL, + ) -> DWORD; + pub fn GetExplicitEntriesFromAclA( + pacl: PACL, + pcCountOfExplicitEntries: PULONG, + pListOfExplicitEntries: *mut PEXPLICIT_ACCESS_A, + ) -> DWORD; + pub fn GetExplicitEntriesFromAclW( + pacl: PACL, + pcCountOfExplicitEntries: PULONG, + pListOfExplicitEntries: *mut PEXPLICIT_ACCESS_W, + ) -> DWORD; + pub fn GetEffectiveRightsFromAclA( + pacl: PACL, + pTrustee: PTRUSTEE_A, + pAccessRight: PACCESS_MASK, + ) -> DWORD; + pub fn GetEffectiveRightsFromAclW( + pacl: PACL, + pTrustee: PTRUSTEE_W, + pAccessRight: PACCESS_MASK, + ) -> DWORD; + pub fn GetAuditedPermissionsFromAclA( + pAcl: PACL, + pTrustee: PTRUSTEE_A, + pSuccessfulAuditedRights: PACCESS_MASK, + pFailedAuditRights: PACCESS_MASK, + ) -> DWORD; + pub fn GetAuditedPermissionsFromAclW( + pAcl: PACL, + pTrustee: PTRUSTEE_W, + pSuccessfulAuditedRights: PACCESS_MASK, + pFailedAuditRights: PACCESS_MASK, + ) -> DWORD; + pub fn GetNamedSecurityInfoA( + pObjectName: LPCSTR, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + ppsidOwner: *mut PSID, + ppsidGroup: *mut PSID, + ppDacl: *mut PACL, + ppSacl: *mut PACL, + ppSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + ) -> DWORD; + pub fn GetNamedSecurityInfoW( + pObjectName: LPCWSTR, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + ppsidOwner: *mut PSID, + ppsidGroup: *mut PSID, + ppDacl: *mut PACL, + ppSacl: *mut PACL, + ppSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + ) -> DWORD; + pub fn GetSecurityInfo( + handle: HANDLE, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + ppsidOwner: *mut PSID, + ppsidGroup: *mut PSID, + ppDacl: *mut PACL, + ppSacl: *mut PACL, + ppSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + ) -> DWORD; + pub fn SetNamedSecurityInfoA( + pObjectame: LPSTR, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + psidOwner: PSID, + psidGroup: PSID, + pDacl: PACL, + pSacl: PACL, + ) -> DWORD; + pub fn SetNamedSecurityInfoW( + pObjectame: LPWSTR, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + psidOwner: PSID, + psidGroup: PSID, + pDacl: PACL, + pSacl: PACL, + ) -> DWORD; + pub fn SetSecurityInfo( + handle: HANDLE, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + psidOwner: PSID, + psidGroup: PSID, + pDacl: PACL, + pSacl: PACL, + ) -> DWORD; + pub fn GetInheritanceSourceA( + pObjectName: LPSTR, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + Container: BOOL, + pObjectClassGuids: *mut *mut GUID, + GuidCount: DWORD, + pAcl: PACL, + pfnArray: PFN_OBJECT_MGR_FUNCTS, + pGenericMapping: PGENERIC_MAPPING, + pInheritArray: PINHERITED_FROMA, + ) -> DWORD; + pub fn GetInheritanceSourceW( + pObjectName: LPWSTR, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + Container: BOOL, + pObjectClassGuids: *mut *mut GUID, + GuidCount: DWORD, + pAcl: PACL, + pfnArray: PFN_OBJECT_MGR_FUNCTS, + pGenericMapping: PGENERIC_MAPPING, + pInheritArray: PINHERITED_FROMW, + ) -> DWORD; + pub fn FreeInheritedFromArray( + pInheritArray: PINHERITED_FROMW, + AceCnt: USHORT, + pfnArray: PFN_OBJECT_MGR_FUNCTS, + ) -> DWORD; + pub fn TreeResetNamedSecurityInfoA( + pObjectName: LPSTR, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + pOwner: PSID, + pGroup: PSID, + pDacl: PACL, + pSacl: PACL, + KeepExplicit: BOOL, + fnProgress: FN_PROGRESS, + ProgressInvokeSetting: PROG_INVOKE_SETTING, + Args: PVOID, + ) -> DWORD; + pub fn TreeResetNamedSecurityInfoW( + pObjectName: LPWSTR, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + pOwner: PSID, + pGroup: PSID, + pDacl: PACL, + pSacl: PACL, + KeepExplicit: BOOL, + fnProgress: FN_PROGRESS, + ProgressInvokeSetting: PROG_INVOKE_SETTING, + Args: PVOID, + ) -> DWORD; + pub fn TreeSetNamedSecurityInfoA( + pObjectName: LPSTR, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + pOwner: PSID, + pGroup: PSID, + pDacl: PACL, + pSacl: PACL, + dwAction: DWORD, + fnProgress: FN_PROGRESS, + ProgressInvokeSetting: PROG_INVOKE_SETTING, + Args: PVOID, + ) -> DWORD; + pub fn TreeSetNamedSecurityInfoW( + pObjectName: LPWSTR, + ObjectType: SE_OBJECT_TYPE, + SecurityInfo: SECURITY_INFORMATION, + pOwner: PSID, + pGroup: PSID, + pDacl: PACL, + pSacl: PACL, + dwAction: DWORD, + fnProgress: FN_PROGRESS, + ProgressInvokeSetting: PROG_INVOKE_SETTING, + Args: PVOID, + ) -> DWORD; + pub fn BuildSecurityDescriptorA( + pOwner: PTRUSTEE_A, + pGroup: PTRUSTEE_A, + cCountOfAccessEntries: ULONG, + pListOfAccessEntries: PEXPLICIT_ACCESS_A, + cCountOfAuditEntries: ULONG, + pListOfAuditEntries: PEXPLICIT_ACCESS_A, + pOldSD: PSECURITY_DESCRIPTOR, + pSizeNewSD: PULONG, + pNewSD: *mut PSECURITY_DESCRIPTOR, + ) -> DWORD; + pub fn BuildSecurityDescriptorW( + pOwner: PTRUSTEE_W, + pGroup: PTRUSTEE_W, + cCountOfAccessEntries: ULONG, + pListOfAccessEntries: PEXPLICIT_ACCESS_W, + cCountOfAuditEntries: ULONG, + pListOfAuditEntries: PEXPLICIT_ACCESS_W, + pOldSD: PSECURITY_DESCRIPTOR, + pSizeNewSD: PULONG, + pNewSD: *mut PSECURITY_DESCRIPTOR, + ) -> DWORD; + pub fn LookupSecurityDescriptorPartsA( + ppOwner: *mut PTRUSTEE_A, + ppGroup: *mut PTRUSTEE_A, + pcCountOfAccessEntries: PULONG, + ppListOfAccessEntries: *mut PEXPLICIT_ACCESS_A, + pcCountOfAuditEntries: PULONG, + ppListOfAuditEntries: *mut PEXPLICIT_ACCESS_A, + pSD: PSECURITY_DESCRIPTOR, + ) -> DWORD; + pub fn LookupSecurityDescriptorPartsW( + ppOwner: *mut PTRUSTEE_W, + ppGroup: *mut PTRUSTEE_W, + pcCountOfAccessEntries: PULONG, + ppListOfAccessEntries: *mut PEXPLICIT_ACCESS_W, + pcCountOfAuditEntries: PULONG, + ppListOfAuditEntries: *mut PEXPLICIT_ACCESS_W, + pSD: PSECURITY_DESCRIPTOR, + ) -> DWORD; + pub fn BuildExplicitAccessWithNameA( + pExplicitAccess: PEXPLICIT_ACCESS_A, + pTrusteeName: LPSTR, + AccessPermissions: DWORD, + AccessMode: ACCESS_MODE, + Inheritance: DWORD, + ); + pub fn BuildExplicitAccessWithNameW( + pExplicitAccess: PEXPLICIT_ACCESS_W, + pTrusteeName: LPWSTR, + AccessPermissions: DWORD, + AccessMode: ACCESS_MODE, + Inheritance: DWORD, + ); + pub fn BuildImpersonateExplicitAccessWithNameA( + pExplicitAccess: PEXPLICIT_ACCESS_A, + pTrusteeName: LPSTR, + pTrustee: PTRUSTEE_A, + AccessPermissions: DWORD, + AccessMode: ACCESS_MODE, + Inheritance: DWORD, + ); + pub fn BuildImpersonateExplicitAccessWithNameW( + pExplicitAccess: PEXPLICIT_ACCESS_W, + pTrusteeName: LPWSTR, + pTrustee: PTRUSTEE_W, + AccessPermissions: DWORD, + AccessMode: ACCESS_MODE, + Inheritance: DWORD, + ); + pub fn BuildTrusteeWithNameA( + pTrustee: PTRUSTEE_A, + pName: LPSTR, + ); + pub fn BuildTrusteeWithNameW( + pTrustee: PTRUSTEE_W, + pName: LPWSTR, + ); + pub fn BuildImpersonateTrusteeA( + pTrustee: PTRUSTEE_A, + pImpersonateTrustee: PTRUSTEE_A, + ); + pub fn BuildImpersonateTrusteeW( + pTrustee: PTRUSTEE_W, + pImpersonateTrustee: PTRUSTEE_W, + ); + pub fn BuildTrusteeWithSidA( + pTrustee: PTRUSTEE_A, + pSid: PSID, + ); + pub fn BuildTrusteeWithSidW( + pTrustee: PTRUSTEE_W, + pSid: PSID, + ); + pub fn BuildTrusteeWithObjectsAndSidA( + pTrustee: PTRUSTEE_A, + pObjSid: POBJECTS_AND_SID, + pObjectGuid: *mut GUID, + pInheritedObjectGuid: *mut GUID, + pSid: PSID, + ); + pub fn BuildTrusteeWithObjectsAndSidW( + pTrustee: PTRUSTEE_W, + pObjSid: POBJECTS_AND_SID, + pObjectGuid: *mut GUID, + pInheritedObjectGuid: *mut GUID, + pSid: PSID, + ); + pub fn BuildTrusteeWithObjectsAndNameA( + pTrustee: PTRUSTEE_A, + pObjName: POBJECTS_AND_NAME_A, + ObjectType: SE_OBJECT_TYPE, + ObjectTypeName: LPSTR, + InheritedObjectTypeName: LPSTR, + Name: LPSTR, + ); + pub fn BuildTrusteeWithObjectsAndNameW( + pTrustee: PTRUSTEE_W, + pObjName: POBJECTS_AND_NAME_W, + ObjectType: SE_OBJECT_TYPE, + ObjectTypeName: LPWSTR, + InheritedObjectTypeName: LPWSTR, + Name: LPWSTR, + ); + pub fn GetTrusteeNameA( + pTrustee: PTRUSTEE_A, + ) -> LPSTR; + pub fn GetTrusteeNameW( + pTrustee: PTRUSTEE_W, + ) -> LPWSTR; + pub fn GetTrusteeTypeA( + pTrustee: PTRUSTEE_A, + ) -> TRUSTEE_TYPE; + pub fn GetTrusteeTypeW( + pTrustee: PTRUSTEE_W, + ) -> TRUSTEE_TYPE; + pub fn GetTrusteeFormA( + pTrustee: PTRUSTEE_A, + ) -> TRUSTEE_FORM; + pub fn GetTrusteeFormW( + pTrustee: PTRUSTEE_W, + ) -> TRUSTEE_FORM; + pub fn GetMultipleTrusteeOperationA( + pTrustee: PTRUSTEE_A, + ) -> MULTIPLE_TRUSTEE_OPERATION; + pub fn GetMultipleTrusteeOperationW( + pTrustee: PTRUSTEE_W, + ) -> MULTIPLE_TRUSTEE_OPERATION; + pub fn GetMultipleTrusteeA( + pTrustee: PTRUSTEE_A, + ) -> PTRUSTEE_A; + pub fn GetMultipleTrusteeW( + pTrustee: PTRUSTEE_W, + ) -> PTRUSTEE_W; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/appmgmt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/appmgmt.rs new file mode 100644 index 0000000..1d7b910 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/appmgmt.rs @@ -0,0 +1,122 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, DWORD, LPDWORD}; +use um::winnt::{LANGID, LCID, LPWSTR, WCHAR}; +ENUM!{enum INSTALLSPECTYPE { + APPNAME = 1, + FILEEXT, + PROGID, + COMCLASS, +}} +STRUCT!{struct INSTALLSPEC_APPNAME { + Name: *mut WCHAR, + GPOId: GUID, +}} +STRUCT!{struct INSTALLSPEC_COMCLASS { + Clsid: GUID, + ClsCtx: DWORD, +}} +UNION!{union INSTALLSPEC { + [u32; 5] [u64; 3], + AppName AppName_mut: INSTALLSPEC_APPNAME, + FileExt FileExt_mut: *mut WCHAR, + ProgId ProgId_mut: *mut WCHAR, + COMClass COMClass_mut: INSTALLSPEC_COMCLASS, +}} +STRUCT!{struct INSTALLDATA { + Type: INSTALLSPECTYPE, + Spec: INSTALLSPEC, +}} +pub type PINSTALLDATA = *mut INSTALLDATA; +ENUM!{enum APPSTATE { + ABSENT, + ASSIGNED, + PUBLISHED, +}} +pub const LOCALSTATE_ASSIGNED: DWORD = 0x1; +pub const LOCALSTATE_PUBLISHED: DWORD = 0x2; +pub const LOCALSTATE_UNINSTALL_UNMANAGED: DWORD = 0x4; +pub const LOCALSTATE_POLICYREMOVE_ORPHAN: DWORD = 0x8; +pub const LOCALSTATE_POLICYREMOVE_UNINSTALL: DWORD = 0x10; +pub const LOCALSTATE_ORPHANED: DWORD = 0x20; +pub const LOCALSTATE_UNINSTALLED: DWORD = 0x40; +STRUCT!{struct LOCALMANAGEDAPPLICATION { + pszDeploymentName: LPWSTR, + pszPolicyName: LPWSTR, + pszProductId: LPWSTR, + dwState: DWORD, +}} +pub type PLOCALMANAGEDAPPLICATION = *mut LOCALMANAGEDAPPLICATION; +pub const MANAGED_APPS_USERAPPLICATIONS: DWORD = 0x1; +pub const MANAGED_APPS_FROMCATEGORY: DWORD = 0x2; +pub const MANAGED_APPS_INFOLEVEL_DEFAULT: DWORD = 0x10000; +pub const MANAGED_APPTYPE_WINDOWSINSTALLER: DWORD = 0x1; +pub const MANAGED_APPTYPE_SETUPEXE: DWORD = 0x2; +pub const MANAGED_APPTYPE_UNSUPPORTED: DWORD = 0x3; +STRUCT!{struct MANAGEDAPPLICATION { + pszPackageName: LPWSTR, + pszPublisher: LPWSTR, + dwVersionHi: DWORD, + dwVersionLo: DWORD, + dwRevision: DWORD, + GpoId: GUID, + pszPolicyName: LPWSTR, + ProductId: GUID, + Language: LANGID, + pszOwner: LPWSTR, + pszCompany: LPWSTR, + pszComments: LPWSTR, + pszContact: LPWSTR, + pszSupportUrl: LPWSTR, + dwPathType: DWORD, + bInstalled: BOOL, +}} +pub type PMANAGEDAPPLICATION = *mut MANAGEDAPPLICATION; +STRUCT!{struct APPCATEGORYINFO { + Locale: LCID, + pszDescription: LPWSTR, + AppCategoryId: GUID, +}} +STRUCT!{struct APPCATEGORYINFOLIST { + cCategory: DWORD, + pCategoryInfo: *mut APPCATEGORYINFO, +}} +extern "system" { + pub fn InstallApplication( + pInstallInfo: PINSTALLDATA, + ) -> DWORD; + pub fn UninstallApplication( + ProductCode: LPWSTR, + dwStatus: DWORD, + ) -> DWORD; + pub fn CommandLineFromMsiDescriptor( + Descriptor: LPWSTR, + CommandLine: LPWSTR, + CommandLineLength: *mut DWORD, + ) -> DWORD; + pub fn GetManagedApplications( + pCategory: *mut GUID, + dwQueryFlags: DWORD, + dwInfoLevel: DWORD, + pdwApps: LPDWORD, + prgManagedApps: *mut PMANAGEDAPPLICATION, + ) -> DWORD; + pub fn GetLocalManagedApplications( + bUserApps: BOOL, + pdwApps: LPDWORD, + prgManagedApps: *mut PMANAGEDAPPLICATION, + ) -> DWORD; + pub fn GetLocalManagedApplicationData( + ProductCode: LPWSTR, + DisplayName: *mut LPWSTR, + SupportUrl: *mut LPWSTR, + ); + pub fn GetManagedApplicationCategories( + dwReserved: DWORD, + pAppCategory: *mut APPCATEGORYINFOLIST, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/audioclient.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/audioclient.rs new file mode 100644 index 0000000..5f7b83e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/audioclient.rs @@ -0,0 +1,172 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! this ALWAYS GENERATED file contains the definitions for the interfaces +use ctypes::c_float; +use shared::basetsd::{UINT32, UINT64}; +use shared::guiddef::{LPCGUID, REFIID}; +use shared::minwindef::{BYTE, DWORD, LPVOID}; +use shared::mmreg::WAVEFORMATEX; +use shared::winerror::{FACILITY_AUDCLNT, SEVERITY_ERROR, SEVERITY_SUCCESS}; +use shared::wtypesbase::SCODE; +use um::audiosessiontypes::AUDCLNT_SHAREMODE; +use um::strmif::REFERENCE_TIME; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT}; +//1627 +pub const AUDCLNT_E_NOT_INITIALIZED: HRESULT = AUDCLNT_ERR!(0x001); +pub const AUDCLNT_E_ALREADY_INITIALIZED: HRESULT = AUDCLNT_ERR!(0x002); +pub const AUDCLNT_E_WRONG_ENDPOINT_TYPE: HRESULT = AUDCLNT_ERR!(0x003); +pub const AUDCLNT_E_DEVICE_INVALIDATED: HRESULT = AUDCLNT_ERR!(0x004); +pub const AUDCLNT_E_NOT_STOPPED: HRESULT = AUDCLNT_ERR!(0x005); +pub const AUDCLNT_E_BUFFER_TOO_LARGE: HRESULT = AUDCLNT_ERR!(0x006); +pub const AUDCLNT_E_OUT_OF_ORDER: HRESULT = AUDCLNT_ERR!(0x007); +pub const AUDCLNT_E_UNSUPPORTED_FORMAT: HRESULT = AUDCLNT_ERR!(0x008); +pub const AUDCLNT_E_INVALID_SIZE: HRESULT = AUDCLNT_ERR!(0x009); +pub const AUDCLNT_E_DEVICE_IN_USE: HRESULT = AUDCLNT_ERR!(0x00a); +pub const AUDCLNT_E_BUFFER_OPERATION_PENDING: HRESULT = AUDCLNT_ERR!(0x00b); +pub const AUDCLNT_E_THREAD_NOT_REGISTERED: HRESULT = AUDCLNT_ERR!(0x00c); +pub const AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED: HRESULT = AUDCLNT_ERR!(0x00e); +pub const AUDCLNT_E_ENDPOINT_CREATE_FAILED: HRESULT = AUDCLNT_ERR!(0x00f); +pub const AUDCLNT_E_SERVICE_NOT_RUNNING: HRESULT = AUDCLNT_ERR!(0x010); +pub const AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED: HRESULT = AUDCLNT_ERR!(0x011); +pub const AUDCLNT_E_EXCLUSIVE_MODE_ONLY: HRESULT = AUDCLNT_ERR!(0x012); +pub const AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL: HRESULT = AUDCLNT_ERR!(0x013); +pub const AUDCLNT_E_EVENTHANDLE_NOT_SET: HRESULT = AUDCLNT_ERR!(0x014); +pub const AUDCLNT_E_INCORRECT_BUFFER_SIZE: HRESULT = AUDCLNT_ERR!(0x015); +pub const AUDCLNT_E_BUFFER_SIZE_ERROR: HRESULT = AUDCLNT_ERR!(0x016); +pub const AUDCLNT_E_CPUUSAGE_EXCEEDED: HRESULT = AUDCLNT_ERR!(0x017); +pub const AUDCLNT_E_BUFFER_ERROR: HRESULT = AUDCLNT_ERR!(0x018); +pub const AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED: HRESULT = AUDCLNT_ERR!(0x019); +pub const AUDCLNT_E_INVALID_DEVICE_PERIOD: HRESULT = AUDCLNT_ERR!(0x020); +pub const AUDCLNT_E_INVALID_STREAM_FLAG: HRESULT = AUDCLNT_ERR!(0x021); +pub const AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE: HRESULT = AUDCLNT_ERR!(0x022); +pub const AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES: HRESULT = AUDCLNT_ERR!(0x023); +pub const AUDCLNT_E_OFFLOAD_MODE_ONLY: HRESULT = AUDCLNT_ERR!(0x024); +pub const AUDCLNT_E_NONOFFLOAD_MODE_ONLY: HRESULT = AUDCLNT_ERR!(0x025); +pub const AUDCLNT_E_RESOURCES_INVALIDATED: HRESULT = AUDCLNT_ERR!(0x026); +pub const AUDCLNT_E_RAW_MODE_UNSUPPORTED: HRESULT = AUDCLNT_ERR!(0x027); +pub const AUDCLNT_S_BUFFER_EMPTY: SCODE = AUDCLNT_SUCCESS!(0x001); +pub const AUDCLNT_S_THREAD_ALREADY_REGISTERED: SCODE = AUDCLNT_SUCCESS!(0x002); +pub const AUDCLNT_S_POSITION_STALLED: SCODE = AUDCLNT_SUCCESS!(0x003); +ENUM!{enum AUDCLNT_BUFFERFLAGS { + AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY = 0x1, + AUDCLNT_BUFFERFLAGS_SILENT = 0x2, + AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR = 0x4, +}} +DEFINE_GUID!{IID_IAudioClient, + 0x1CB9AD4C, 0xDBFA, 0x4c32, 0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2} +DEFINE_GUID!{IID_IAudioRenderClient, + 0xF294ACFC, 0x3146, 0x4483, 0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2} +DEFINE_GUID!{IID_IAudioCaptureClient, + 0xc8adbd64, 0xe71e, 0x48a0, 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17} +DEFINE_GUID!{IID_IAudioClock, + 0xcd63314f, 0x3fba, 0x4a1b, 0x81, 0x2c, 0xef, 0x96, 0x35, 0x87, 0x28, 0xe7} +DEFINE_GUID!{IID_IAudioStreamVolume, + 0x93014887, 0x242d, 0x4068, 0x8a, 0x15, 0xcf, 0x5e, 0x93, 0xb9, 0x0f, 0xe3} +RIDL!{#[uuid(0x1cb9ad4c, 0xdbfa, 0x4c32, 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2)] +interface IAudioClient(IAudioClientVtbl): IUnknown(IUnknownVtbl) { + fn Initialize( + ShareMode: AUDCLNT_SHAREMODE, + StreamFlags: DWORD, + hnsBufferDuration: REFERENCE_TIME, + hnsPeriodicity: REFERENCE_TIME, + pFormat: *const WAVEFORMATEX, + AudioSessionGuid: LPCGUID, + ) -> HRESULT, + fn GetBufferSize( + pNumBufferFrames: *mut UINT32, + ) -> HRESULT, + fn GetStreamLatency( + phnsLatency: *mut REFERENCE_TIME, + ) -> HRESULT, + fn GetCurrentPadding( + pNumPaddingFrames: *mut UINT32, + ) -> HRESULT, + fn IsFormatSupported( + ShareMode: AUDCLNT_SHAREMODE, + pFormat: *const WAVEFORMATEX, + ppClosestMatch: *mut *mut WAVEFORMATEX, + ) -> HRESULT, + fn GetMixFormat( + ppDeviceFormat: *mut *mut WAVEFORMATEX, + ) -> HRESULT, + fn GetDevicePeriod( + phnsDefaultDevicePeriod: *mut REFERENCE_TIME, + phnsMinimumDevicePeriod: *mut REFERENCE_TIME, + ) -> HRESULT, + fn Start() -> HRESULT, + fn Stop() -> HRESULT, + fn Reset() -> HRESULT, + fn SetEventHandle( + eventHandle: HANDLE, + ) -> HRESULT, + fn GetService( + riid: REFIID, + ppv: *mut LPVOID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf294acfc, 0x3146, 0x4483, 0xa7, 0xbf, 0xad, 0xdc, 0xa7, 0xc2, 0x60, 0xe2)] +interface IAudioRenderClient(IAudioRenderClientVtbl): IUnknown(IUnknownVtbl) { + fn GetBuffer( + NumFramesRequested: UINT32, + ppData: *mut *mut BYTE, + ) -> HRESULT, + fn ReleaseBuffer( + NumFramesWritten: UINT32, + dwFlags: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc8adbd64, 0xe71e, 0x48a0, 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17)] +interface IAudioCaptureClient(IAudioCaptureClientVtbl): IUnknown(IUnknownVtbl) { + fn GetBuffer( + ppData: *mut *mut BYTE, + pNumFramesToRead: *mut UINT32, + pdwFlags: *mut DWORD, + pu64DevicePosition: *mut UINT64, + pu64QPCPosition: *mut UINT64, + ) -> HRESULT, + fn ReleaseBuffer( + NumFramesRead: UINT32, + ) -> HRESULT, + fn GetNextPacketSize( + pNumFramesInNextPacket: *mut UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xcd63314f, 0x3fba, 0x4a1b, 0x81, 0x2c, 0xef, 0x96, 0x35, 0x87, 0x28, 0xe7)] +interface IAudioClock(IAudioClockVtbl): IUnknown(IUnknownVtbl) { + fn GetFrequency( + pu64Frequency: *mut UINT64, + ) -> HRESULT, + fn GetPosition( + pu64Position: *mut UINT64, + pu64QPCPosition: *mut UINT64, + ) -> HRESULT, + fn GetCharacteristics( + pdwCharacteristics: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x93014887, 0x242d, 0x4068, 0x8a, 0x15, 0xcf, 0x5e, 0x93, 0xb9, 0x0f, 0xe3)] +interface IAudioStreamVolume(IAudioStreamVolumeVtbl): IUnknown(IUnknownVtbl) { + fn GetChannelCount( + pdwCount: *mut UINT32, + ) -> HRESULT, + fn SetChannelVolume( + dwIndex: UINT32, + fLevel: c_float, + ) -> HRESULT, + fn GetChannelVolume( + dwIndex: UINT32, + pfLevel: *mut c_float, + ) -> HRESULT, + fn SetAllVolumes( + dwCount: UINT32, + pfVolumes: *const c_float, + ) -> HRESULT, + fn GetAllVolumes( + dwCount: UINT32, + pfVolumes: *mut c_float, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/audiosessiontypes.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/audiosessiontypes.rs new file mode 100644 index 0000000..3c64f42 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/audiosessiontypes.rs @@ -0,0 +1,37 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::DWORD; +ENUM!{enum AUDCLNT_SHAREMODE { + AUDCLNT_SHAREMODE_SHARED, + AUDCLNT_SHAREMODE_EXCLUSIVE, +}} +ENUM!{enum AUDIO_STREAM_CATEGORY { + AudioCategory_Other = 0, + AudioCategory_ForegroundOnlyMedia = 1, + AudioCategory_BackgroundCapableMedia = 2, + AudioCategory_Communications = 3, + AudioCategory_Alerts = 4, + AudioCategory_SoundEffects = 5, + AudioCategory_GameEffects = 6, + AudioCategory_GameMedia = 7, + AudioCategory_GameChat = 8, + AudioCategory_Speech = 9, + AudioCategory_Movie = 10, + AudioCategory_Media = 11, +}} +pub const AUDCLNT_STREAMFLAGS_CROSSPROCESS: DWORD = 0x00010000; +pub const AUDCLNT_STREAMFLAGS_LOOPBACK: DWORD = 0x00020000; +pub const AUDCLNT_STREAMFLAGS_EVENTCALLBACK: DWORD = 0x00040000; +pub const AUDCLNT_STREAMFLAGS_NOPERSIST: DWORD = 0x00080000; +pub const AUDCLNT_STREAMFLAGS_RATEADJUST: DWORD = 0x00100000; +pub const AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED: DWORD = 0x10000000; +pub const AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE: DWORD = 0x20000000; +pub const AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED: DWORD = 0x40000000; +ENUM!{enum AudioSessionState { + AudioSessionStateInactive = 0, + AudioSessionStateActive = 1, + AudioSessionStateExpired = 2, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/avrt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/avrt.rs new file mode 100644 index 0000000..62b0e9c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/avrt.rs @@ -0,0 +1,82 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_longlong; +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, LPDWORD, PULONG}; +use um::winnt::{HANDLE, LPCSTR, LPCWSTR, PHANDLE, PLARGE_INTEGER}; +ENUM!{enum AVRT_PRIORITY { + AVRT_PRIORITY_VERYLOW = -2i32 as u32, + AVRT_PRIORITY_LOW, + AVRT_PRIORITY_NORMAL = 0, + AVRT_PRIORITY_HIGH, + AVRT_PRIORITY_CRITICAL, +}} +pub const THREAD_ORDER_GROUP_INFINITE_TIMEOUT: c_longlong = -1; +extern "system" { + pub fn AvSetMmThreadCharacteristicsA( + TaskName: LPCSTR, + TaskIndex: LPDWORD, + ) -> HANDLE; + pub fn AvSetMmThreadCharacteristicsW( + TaskName: LPCWSTR, + TaskIndex: LPDWORD, + ) -> HANDLE; + pub fn AvSetMmMaxThreadCharacteristicsA( + FirstTask: LPCSTR, + SecondTask: LPCSTR, + TaskIndex: LPDWORD, + ) -> HANDLE; + pub fn AvSetMmMaxThreadCharacteristicsW( + FirstTask: LPCWSTR, + SecondTask: LPCWSTR, + TaskIndex: LPDWORD, + ) -> HANDLE; + pub fn AvRevertMmThreadCharacteristics( + avrt_handle: HANDLE, + ) -> BOOL; + pub fn AvSetMmThreadPriority( + AvrtHandle: HANDLE, + Priority: AVRT_PRIORITY, + ) -> BOOL; + pub fn AvRtCreateThreadOrderingGroup( + Context: PHANDLE, + Period: PLARGE_INTEGER, + ThreadOrderingGuid: *mut GUID, + Timeout: PLARGE_INTEGER, + ) -> BOOL; + pub fn AvRtCreateThreadOrderingGroupExA( + Context: PHANDLE, + Period: PLARGE_INTEGER, + ThreadOrderingGuid: *mut GUID, + Timeout: PLARGE_INTEGER, + TaskName: LPCSTR, + )-> BOOL; + pub fn AvRtCreateThreadOrderingGroupExW( + Context: PHANDLE, + Period: PLARGE_INTEGER, + ThreadOrderingGuid: *mut GUID, + Timeout: PLARGE_INTEGER, + TaskName: LPCWSTR, + ) -> BOOL; + pub fn AvRtJoinThreadOrderingGroup( + Context: PHANDLE, + ThreadOrderingGuid: *mut GUID, + Before: BOOL, + ) -> BOOL; + pub fn AvRtWaitOnThreadOrderingGroup( + Context: HANDLE, + ) -> BOOL; + pub fn AvRtLeaveThreadOrderingGroup( + Context: HANDLE, + ) -> BOOL; + pub fn AvRtDeleteThreadOrderingGroup( + Context: HANDLE, + ) -> BOOL; + pub fn AvQuerySystemResponsiveness( + AvrtHandle: HANDLE, + SystemResponsivenessValue: PULONG, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bits.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits.rs new file mode 100644 index 0000000..aef603f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits.rs @@ -0,0 +1,295 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::UINT64; +use shared::guiddef::{GUID, REFGUID}; +use shared::minwindef::{BOOL, DWORD, FILETIME, ULONG}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCWSTR, LPWSTR, WCHAR}; +RIDL!{#[uuid(0x4991d34b, 0x80a1, 0x4291, 0x83, 0xb6, 0x33, 0x28, 0x36, 0x6b, 0x90, 0x97)] +class BackgroundCopyManager;} +pub const BG_SIZE_UNKNOWN: UINT64 = -1i64 as u64; +STRUCT!{struct BG_FILE_PROGRESS { + BytesTotal: UINT64, + BytesTransferred: UINT64, + Completed: BOOL, +}} +RIDL!{#[uuid(0x01b7bd23, 0xfb88, 0x4a77, 0x84, 0x90, 0x58, 0x91, 0xd3, 0xe4, 0x65, 0x3a)] +interface IBackgroundCopyFile(IBackgroundCopyFileVtbl): IUnknown(IUnknownVtbl) { + fn GetRemoteName( + pVal: *mut LPWSTR, + ) -> HRESULT, + fn GetLocalName( + pVal: *mut LPWSTR, + ) -> HRESULT, + fn GetProgress( + pVal: *mut BG_FILE_PROGRESS, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xca51e165, 0xc365, 0x424c, 0x8d, 0x41, 0x24, 0xaa, 0xa4, 0xff, 0x3c, 0x40)] +interface IEnumBackgroundCopyFiles(IEnumBackgroundCopyFilesVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut *mut IBackgroundCopyFile, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumBackgroundCopyFiles, + ) -> HRESULT, + fn GetCount( + puCount: *mut ULONG, + ) -> HRESULT, +}} +ENUM!{enum BG_ERROR_CONTEXT { + BG_ERROR_CONTEXT_NONE = 0, + BG_ERROR_CONTEXT_UNKNOWN = 1, + BG_ERROR_CONTEXT_GENERAL_QUEUE_MANAGER = 2, + BG_ERROR_CONTEXT_QUEUE_MANAGER_NOTIFICATION = 3, + BG_ERROR_CONTEXT_LOCAL_FILE = 4, + BG_ERROR_CONTEXT_REMOTE_FILE = 5, + BG_ERROR_CONTEXT_GENERAL_TRANSPORT = 6, + BG_ERROR_CONTEXT_REMOTE_APPLICATION = 7, +}} +RIDL!{#[uuid(0x19c613a0, 0xfcb8, 0x4f28, 0x81, 0xae, 0x89, 0x7c, 0x3d, 0x07, 0x8f, 0x81)] +interface IBackgroundCopyError(IBackgroundCopyErrorVtbl): IUnknown(IUnknownVtbl) { + fn GetError( + pContext: *mut BG_ERROR_CONTEXT, + pCode: *mut HRESULT, + ) -> HRESULT, + fn GetFile( + pVal: *mut *mut IBackgroundCopyFile, + ) -> HRESULT, + fn GetErrorDescription( + LanguageId: DWORD, + pErrorDescription: *mut LPWSTR, + ) -> HRESULT, + fn GetErrorContextDescription( + LanguageId: DWORD, + pContextDescription: *mut LPWSTR, + ) -> HRESULT, + fn GetProtocol( + pProtocol: *mut LPWSTR, + ) -> HRESULT, +}} +STRUCT!{struct BG_FILE_INFO { + RemoteName: LPWSTR, + LocalName: LPWSTR, +}} +STRUCT!{struct BG_JOB_PROGRESS { + BytesTotal: UINT64, + BytesTransferred: UINT64, + FilesTotal: ULONG, + FilesTransferred: ULONG, +}} +STRUCT!{struct BG_JOB_TIMES { + CreationTime: FILETIME, + ModificationTime: FILETIME, + TransferCompletionTime: FILETIME, +}} +ENUM!{enum BG_JOB_PRIORITY { + BG_JOB_PRIORITY_FOREGROUND = 0, + BG_JOB_PRIORITY_HIGH = BG_JOB_PRIORITY_FOREGROUND + 1, + BG_JOB_PRIORITY_NORMAL = BG_JOB_PRIORITY_HIGH + 1, + BG_JOB_PRIORITY_LOW = BG_JOB_PRIORITY_NORMAL + 1, +}} +ENUM!{enum BG_JOB_STATE { + BG_JOB_STATE_QUEUED = 0, + BG_JOB_STATE_CONNECTING = BG_JOB_STATE_QUEUED + 1, + BG_JOB_STATE_TRANSFERRING = BG_JOB_STATE_CONNECTING + 1, + BG_JOB_STATE_SUSPENDED = BG_JOB_STATE_TRANSFERRING + 1, + BG_JOB_STATE_ERROR = BG_JOB_STATE_SUSPENDED + 1, + BG_JOB_STATE_TRANSIENT_ERROR = BG_JOB_STATE_ERROR + 1, + BG_JOB_STATE_TRANSFERRED = BG_JOB_STATE_TRANSIENT_ERROR + 1, + BG_JOB_STATE_ACKNOWLEDGED = BG_JOB_STATE_TRANSFERRED + 1, + BG_JOB_STATE_CANCELLED = BG_JOB_STATE_ACKNOWLEDGED + 1, +}} +ENUM!{enum BG_JOB_TYPE { + BG_JOB_TYPE_DOWNLOAD = 0, + BG_JOB_TYPE_UPLOAD = BG_JOB_TYPE_DOWNLOAD + 1, + BG_JOB_TYPE_UPLOAD_REPLY = BG_JOB_TYPE_UPLOAD + 1, +}} +ENUM!{enum BG_JOB_PROXY_USAGE { + BG_JOB_PROXY_USAGE_PRECONFIG = 0, + BG_JOB_PROXY_USAGE_NO_PROXY = BG_JOB_PROXY_USAGE_PRECONFIG + 1, + BG_JOB_PROXY_USAGE_OVERRIDE = BG_JOB_PROXY_USAGE_NO_PROXY + 1, + BG_JOB_PROXY_USAGE_AUTODETECT = BG_JOB_PROXY_USAGE_OVERRIDE + 1, +}} +RIDL!{#[uuid(0x37668d37, 0x507e, 0x4160, 0x93, 0x16, 0x26, 0x30, 0x6d, 0x15, 0x0b, 0x12)] +interface IBackgroundCopyJob(IBackgroundCopyJobVtbl): IUnknown(IUnknownVtbl) { + fn AddFileSet( + cFileCount: ULONG, + pFileSet: *mut BG_FILE_INFO, + ) -> HRESULT, + fn AddFile( + RemoteUrl: LPCWSTR, + LocalName: LPCWSTR, + ) -> HRESULT, + fn EnumFiles( + pErrorDescription: *mut *mut IEnumBackgroundCopyFiles, + ) -> HRESULT, + fn Suspend() -> HRESULT, + fn Resume() -> HRESULT, + fn Cancel() -> HRESULT, + fn Complete() -> HRESULT, + fn GetId( + pVal: *mut GUID, + ) -> HRESULT, + fn GetType( + pVal: *mut BG_JOB_TYPE, + ) -> HRESULT, + fn GetProgress( + pVal: *mut BG_JOB_PROGRESS, + ) -> HRESULT, + fn GetTimes( + pVal: *mut BG_JOB_TIMES, + ) -> HRESULT, + fn GetState( + pVal: *mut BG_JOB_STATE, + ) -> HRESULT, + fn GetError( + ppError: *mut *mut IBackgroundCopyError, + ) -> HRESULT, + fn GetOwner( + pVal: *mut LPWSTR, + ) -> HRESULT, + fn SetDisplayName( + Val: LPCWSTR, + ) -> HRESULT, + fn GetDisplayName( + pVal: *mut LPWSTR, + ) -> HRESULT, + fn SetDescription( + Val: LPCWSTR, + ) -> HRESULT, + fn GetDescription( + pVal: *mut LPWSTR, + ) -> HRESULT, + fn SetPriority( + Val: BG_JOB_PRIORITY, + ) -> HRESULT, + fn GetPriority( + pVal: *mut BG_JOB_PRIORITY, + ) -> HRESULT, + fn SetNotifyFlags( + Val: ULONG, + ) -> HRESULT, + fn GetNotifyFlags( + pVal: *mut ULONG, + ) -> HRESULT, + fn SetNotifyInterface( + Val: *mut IUnknown, + ) -> HRESULT, + fn GetNotifyInterface( + pVal: *mut *mut IUnknown, + ) -> HRESULT, + fn SetMinimumRetryDelay( + Seconds: ULONG, + ) -> HRESULT, + fn GetMinimumRetryDelay( + Seconds: *mut ULONG, + ) -> HRESULT, + fn SetNoProgressTimeout( + Seconds: ULONG, + ) -> HRESULT, + fn GetNoProgressTimeout( + Seconds: *mut ULONG, + ) -> HRESULT, + fn GetErrorCount( + Errors: *mut ULONG, + ) -> HRESULT, + fn SetProxySettings( + ProxyUsage: BG_JOB_PROXY_USAGE, + ProxyList: *const WCHAR, + ProxyBypassList: *const WCHAR, + ) -> HRESULT, + fn GetProxySettings( + pProxyUsage: *mut BG_JOB_PROXY_USAGE, + pProxyList: *mut LPWSTR, + pProxyBypassListpProxyList: *mut LPWSTR, + ) -> HRESULT, + fn TakeOwnership() -> HRESULT, +}} +RIDL!{#[uuid(0x1af4f612, 0x3b71, 0x466f, 0x8f, 0x58, 0x7b, 0x6f, 0x73, 0xac, 0x57, 0xad)] +interface IEnumBackgroundCopyJobs(IEnumBackgroundCopyJobsVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut *mut IBackgroundCopyJob, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumBackgroundCopyJobs, + ) -> HRESULT, + fn GetCount( + puCount: *mut ULONG, + ) -> HRESULT, +}} +pub const BG_NOTIFY_JOB_TRANSFERRED: DWORD = 0x0001; +pub const BG_NOTIFY_JOB_ERROR: DWORD = 0x0002; +pub const BG_NOTIFY_DISABLE: DWORD = 0x0004; +pub const BG_NOTIFY_JOB_MODIFICATION: DWORD = 0x0008; +pub const BG_NOTIFY_FILE_TRANSFERRED: DWORD = 0x0010; +pub const BG_NOTIFY_FILE_RANGES_TRANSFERRED: DWORD = 0x0020; +RIDL!{#[uuid(0x97ea99c7, 0x0186, 0x4ad4, 0x8d, 0xf9, 0xc5, 0xb4, 0xe0, 0xed, 0x6b, 0x22)] +interface IBackgroundCopyCallback(IBackgroundCopyCallbackVtbl): IUnknown(IUnknownVtbl) { + fn JobTransferred( + pJob: *mut IBackgroundCopyJob, + ) -> HRESULT, + fn JobError( + pJob: *mut IBackgroundCopyJob, + pError: *mut IBackgroundCopyError, + ) -> HRESULT, + fn JobModification( + pJob: *mut IBackgroundCopyJob, + dwReserved: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xca29d251, 0xb4bb, 0x4679, 0xa3, 0xd9, 0xae, 0x80, 0x06, 0x11, 0x9d, 0x54)] +interface AsyncIBackgroundCopyCallback(AsyncIBackgroundCopyCallbackVtbl): IUnknown(IUnknownVtbl) { + fn Begin_JobTransferred( + pJob: *mut IBackgroundCopyJob, + ) -> HRESULT, + fn Finish_JobTransferred() -> HRESULT, + fn Begin_JobError( + pJob: *mut IBackgroundCopyJob, + pError: *mut IBackgroundCopyError, + ) -> HRESULT, + fn Finish_JobError() -> HRESULT, + fn Begin_JobModification( + pJob: *mut IBackgroundCopyJob, + dwReserved: DWORD, + ) -> HRESULT, + fn Finish_JobModification() -> HRESULT, +}} +pub const BG_JOB_ENUM_ALL_USERS: DWORD = 0x0001; +RIDL!{#[uuid(0x5ce34c0d, 0x0dc9, 0x4c1f, 0x89, 0x7c, 0xda, 0xa1, 0xb7, 0x8c, 0xee, 0x7c)] +interface IBackgroundCopyManager(IBackgroundCopyManagerVtbl): IUnknown(IUnknownVtbl) { + fn CreateJob( + DisplayName: LPCWSTR, + Type: BG_JOB_TYPE, + pJobId: *mut GUID, + ppJob: *mut *mut IBackgroundCopyJob, + ) -> HRESULT, + fn GetJob( + jobID: REFGUID, + ppJob: *mut *mut IBackgroundCopyJob, + ) -> HRESULT, + fn EnumJobs( + dwFlags: DWORD, + ppEnum: *mut *mut IEnumBackgroundCopyJobs, + ) -> HRESULT, + fn GetErrorDescription( + hResult: HRESULT, + LanguageId: DWORD, + pErrorDescription: *mut LPWSTR, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bits10_1.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits10_1.rs new file mode 100644 index 0000000..327161a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits10_1.rs @@ -0,0 +1,37 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::UINT64; +use shared::minwindef::DWORD; +use um::bits::{IBackgroundCopyFile, IBackgroundCopyJob}; +use um::bits2_0::BG_FILE_RANGE; +use um::bits3_0::{IBackgroundCopyCallback2, IBackgroundCopyCallback2Vtbl}; +use um::bits5_0::{IBackgroundCopyFile5, IBackgroundCopyFile5Vtbl}; +use um::winnt::HRESULT; +RIDL!{#[uuid(0x98c97bd2, 0xe32b, 0x4ad8, 0xa5, 0x28, 0x95, 0xfd, 0x8b, 0x16, 0xbd, 0x42)] +interface IBackgroundCopyCallback3(IBackgroundCopyCallback3Vtbl): + IBackgroundCopyCallback2(IBackgroundCopyCallback2Vtbl) { + fn FileRangesTransferred( + job: *mut IBackgroundCopyJob, + file: *mut IBackgroundCopyFile, + rangeCount: DWORD, + ranges: *const BG_FILE_RANGE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xcf6784f7, 0xd677, 0x49fd, 0x93, 0x68, 0xcb, 0x47, 0xae, 0xe9, 0xd1, 0xad)] +interface IBackgroundCopyFile6(IBackgroundCopyFile6Vtbl): + IBackgroundCopyFile5(IBackgroundCopyFile5Vtbl) { + fn UpdateDownloadPosition( + offset: UINT64, + ) -> HRESULT, + fn RequestFileRanges( + rangeCount: DWORD, + ranges: *const BG_FILE_RANGE, + ) -> HRESULT, + fn GetFilledFileRanges( + rangeCount: *mut DWORD, + ranges: *mut *mut BG_FILE_RANGE, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bits1_5.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits1_5.rs new file mode 100644 index 0000000..b2890e7 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits1_5.rs @@ -0,0 +1,70 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::UINT64; +use shared::rpcndr::byte; +use um::bits::{IBackgroundCopyJob, IBackgroundCopyJobVtbl}; +use um::winnt::{HRESULT, LPCWSTR, LPWSTR}; +STRUCT!{struct BG_JOB_REPLY_PROGRESS { + BytesTotal: UINT64, + BytesTransferred: UINT64, +}} +ENUM!{enum BG_AUTH_TARGET { + BG_AUTH_TARGET_SERVER = 1, + BG_AUTH_TARGET_PROXY = BG_AUTH_TARGET_SERVER + 1, +}} +ENUM!{enum BG_AUTH_SCHEME { + BG_AUTH_SCHEME_BASIC = 1, + BG_AUTH_SCHEME_DIGEST = BG_AUTH_SCHEME_BASIC + 1, + BG_AUTH_SCHEME_NTLM = BG_AUTH_SCHEME_DIGEST + 1, + BG_AUTH_SCHEME_NEGOTIATE = BG_AUTH_SCHEME_NTLM + 1, + BG_AUTH_SCHEME_PASSPORT = BG_AUTH_SCHEME_NEGOTIATE + 1, +}} +STRUCT!{struct BG_BASIC_CREDENTIALS { + UserName: LPWSTR, + Password: LPWSTR, +}} +UNION!{union BG_AUTH_CREDENTIALS_UNION { + [usize; 2], + Basic Basic_mut: BG_BASIC_CREDENTIALS, +}} +STRUCT!{struct BG_AUTH_CREDENTIALS { + Target: BG_AUTH_TARGET, + Scheme: BG_AUTH_SCHEME, + Credentials: BG_AUTH_CREDENTIALS_UNION, +}} +pub type PBG_AUTH_CREDENTIALS = *mut BG_AUTH_CREDENTIALS; +RIDL!{#[uuid(0x54b50739, 0x686f, 0x45eb, 0x9d, 0xff, 0xd6, 0xa9, 0xa0, 0xfa, 0xa9, 0xaf)] +interface IBackgroundCopyJob2(IBackgroundCopyJob2Vtbl): + IBackgroundCopyJob(IBackgroundCopyJobVtbl) { + fn SetNotifyCmdLine( + Program: LPCWSTR, + Parameters: LPCWSTR, + ) -> HRESULT, + fn GetNotifyCmdLine( + pProgram: *mut LPWSTR, + pParameters: *mut LPWSTR, + ) -> HRESULT, + fn GetReplyProgress( + pProgress: *mut BG_JOB_REPLY_PROGRESS, + ) -> HRESULT, + fn GetReplyData( + ppBuffer: *mut *mut byte, + pLength: *mut UINT64, + ) -> HRESULT, + fn SetReplyFileName( + ReplyFileName: LPCWSTR, + ) -> HRESULT, + fn GetReplyFileName( + pReplyFileName: *mut LPWSTR, + ) -> HRESULT, + fn SetCredentials( + credentials: *mut BG_AUTH_CREDENTIALS, + ) -> HRESULT, + fn RemoveCredentials( + Target: BG_AUTH_TARGET, + Scheme: BG_AUTH_SCHEME, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bits2_0.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits2_0.rs new file mode 100644 index 0000000..15e5827 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits2_0.rs @@ -0,0 +1,51 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::UINT64; +use shared::minwindef::DWORD; +use um::bits::{IBackgroundCopyFile, IBackgroundCopyFileVtbl}; +use um::bits1_5::{IBackgroundCopyJob2, IBackgroundCopyJob2Vtbl}; +use um::winnt::{HRESULT, LPCWSTR}; +pub const BG_LENGTH_TO_EOF: UINT64 = -1i64 as u64; +STRUCT!{struct BG_FILE_RANGE { + InitialOffset: UINT64, + Length: UINT64, +}} +pub const BG_COPY_FILE_OWNER: DWORD = 1; +pub const BG_COPY_FILE_GROUP: DWORD = 2; +pub const BG_COPY_FILE_DACL: DWORD = 4; +pub const BG_COPY_FILE_SACL: DWORD = 8; +pub const BG_COPY_FILE_ALL: DWORD = 15; +RIDL!{#[uuid(0x443c8934, 0x90ff, 0x48ed, 0xbc, 0xde, 0x26, 0xf5, 0xc7, 0x45, 0x00, 0x42)] +interface IBackgroundCopyJob3(IBackgroundCopyJob3Vtbl): + IBackgroundCopyJob2(IBackgroundCopyJob2Vtbl) { + fn ReplaceRemotePrefix( + OldPrefix: LPCWSTR, + NewPrefix: LPCWSTR, + ) -> HRESULT, + fn AddFileWithRanges( + RemoteUrl: LPCWSTR, + LocalName: LPCWSTR, + RangeCount: DWORD, + Ranges: *mut BG_FILE_RANGE, + ) -> HRESULT, + fn SetFileACLFlags( + Flags: DWORD, + ) -> HRESULT, + fn GetFileACLFlags( + Flags: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x83e81b93, 0x0873, 0x474d, 0x8a, 0x8c, 0xf2, 0x01, 0x8b, 0x1a, 0x93, 0x9c)] +interface IBackgroundCopyFile2(IBackgroundCopyFile2Vtbl): + IBackgroundCopyFile(IBackgroundCopyFileVtbl) { + fn GetFileRanges( + RangeCount: *mut DWORD, + Ranges: *mut *mut BG_FILE_RANGE, + ) -> HRESULT, + fn SetRemoteName( + Val: LPCWSTR, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bits2_5.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits2_5.rs new file mode 100644 index 0000000..50a5b4d --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits2_5.rs @@ -0,0 +1,64 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::ULONG; +use shared::rpcndr::byte; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCWSTR, LPWSTR}; +ENUM!{enum BG_CERT_STORE_LOCATION { + BG_CERT_STORE_LOCATION_CURRENT_USER = 0, + BG_CERT_STORE_LOCATION_LOCAL_MACHINE = BG_CERT_STORE_LOCATION_CURRENT_USER + 1, + BG_CERT_STORE_LOCATION_CURRENT_SERVICE = BG_CERT_STORE_LOCATION_LOCAL_MACHINE + 1, + BG_CERT_STORE_LOCATION_SERVICES = BG_CERT_STORE_LOCATION_CURRENT_SERVICE + 1, + BG_CERT_STORE_LOCATION_USERS = BG_CERT_STORE_LOCATION_SERVICES + 1, + BG_CERT_STORE_LOCATION_CURRENT_USER_GROUP_POLICY = BG_CERT_STORE_LOCATION_USERS + 1, + BG_CERT_STORE_LOCATION_LOCAL_MACHINE_GROUP_POLICY + = BG_CERT_STORE_LOCATION_CURRENT_USER_GROUP_POLICY + 1, + BG_CERT_STORE_LOCATION_LOCAL_MACHINE_ENTERPRISE + = BG_CERT_STORE_LOCATION_LOCAL_MACHINE_GROUP_POLICY + 1, +}} +RIDL!{#[uuid(0xf1bd1079, 0x9f01, 0x4bdc, 0x80, 0x36, 0xf0, 0x9b, 0x70, 0x09, 0x50, 0x66)] +interface IBackgroundCopyJobHttpOptions(IBackgroundCopyJobHttpOptionsVtbl): + IUnknown(IUnknownVtbl) { + fn SetClientCertificateByID( + StoreLocation: BG_CERT_STORE_LOCATION, + StoreName: LPCWSTR, + pCertHashBlob: *mut byte, + ) -> HRESULT, + fn SetClientCertificateByName( + StoreLocation: BG_CERT_STORE_LOCATION, + StoreName: LPCWSTR, + SubjectName: LPCWSTR, + ) -> HRESULT, + fn RemoveClientCertificate() -> HRESULT, + fn GetClientCertificate( + pStoreLocation: *mut BG_CERT_STORE_LOCATION, + pStoreName: *mut LPWSTR, + ppCertHashBlob: *mut *mut byte, + pSubjectName: *mut LPWSTR, + ) -> HRESULT, + fn SetCustomHeaders( + RequestHeaders: LPCWSTR, + ) -> HRESULT, + fn GetCustomHeaders( + pRequestHeaders: *mut LPWSTR, + ) -> HRESULT, + fn SetSecurityFlags( + Flags: ULONG, + ) -> HRESULT, + fn GetSecurityFlags( + pFlags: *mut ULONG, + ) -> HRESULT, +}} +pub const BG_SSL_ENABLE_CRL_CHECK: ULONG = 0x0001; +pub const BG_SSL_IGNORE_CERT_CN_INVALID: ULONG = 0x0002; +pub const BG_SSL_IGNORE_CERT_DATE_INVALID: ULONG = 0x0004; +pub const BG_SSL_IGNORE_UNKNOWN_CA: ULONG = 0x0008; +pub const BG_SSL_IGNORE_CERT_WRONG_USAGE: ULONG = 0x0010; +pub const BG_HTTP_REDIRECT_POLICY_MASK: ULONG = 0x0700; +pub const BG_HTTP_REDIRECT_POLICY_ALLOW_SILENT: ULONG = 0x0000; +pub const BG_HTTP_REDIRECT_POLICY_ALLOW_REPORT: ULONG = 0x0100; +pub const BG_HTTP_REDIRECT_POLICY_DISALLOW: ULONG = 0x0200; +pub const BG_HTTP_REDIRECT_POLICY_ALLOW_HTTPS_TO_HTTP: ULONG = 0x0800; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bits3_0.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits3_0.rs new file mode 100644 index 0000000..478dce6 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits3_0.rs @@ -0,0 +1,179 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::UINT64; +use shared::guiddef::{GUID, REFGUID}; +use shared::minwindef::{BOOL, DWORD, FILETIME, ULONG}; +use um::bits::{ + IBackgroundCopyCallback, IBackgroundCopyCallbackVtbl, IBackgroundCopyFile, IBackgroundCopyJob, +}; +use um::bits2_0::{ + BG_FILE_RANGE, IBackgroundCopyFile2, IBackgroundCopyFile2Vtbl, IBackgroundCopyJob3, + IBackgroundCopyJob3Vtbl, +}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCWSTR, LPWSTR}; +RIDL!{#[uuid(0x659cdeaf, 0x489e, 0x11d9, 0xa9, 0xcd, 0x00, 0x0d, 0x56, 0x96, 0x52, 0x51)] +interface IBitsPeerCacheRecord(IBitsPeerCacheRecordVtbl): IUnknown(IUnknownVtbl) { + fn GetId( + pVal: *mut GUID, + ) -> HRESULT, + fn GetOriginUrl( + pVal: *mut LPWSTR, + ) -> HRESULT, + fn GetFileSize( + pVal: *mut UINT64, + ) -> HRESULT, + fn GetFileModificationTime( + pVal: *mut FILETIME, + ) -> HRESULT, + fn GetLastAccessTime( + pVal: *mut FILETIME, + ) -> HRESULT, + fn IsFileValidated() -> HRESULT, + fn GetFileRanges( + pRangeCount: *mut DWORD, + ppRanges: *mut *mut BG_FILE_RANGE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x659cdea4, 0x489e, 0x11d9, 0xa9, 0xcd, 0x00, 0x0d, 0x56, 0x96, 0x52, 0x51)] +interface IEnumBitsPeerCacheRecords(IEnumBitsPeerCacheRecordsVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut *mut IBitsPeerCacheRecord, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumBitsPeerCacheRecords, + ) -> HRESULT, + fn GetCount( + puCount: *mut ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x659cdea2, 0x489e, 0x11d9, 0xa9, 0xcd, 0x00, 0x0d, 0x56, 0x96, 0x52, 0x51)] +interface IBitsPeer(IBitsPeerVtbl): IUnknown(IUnknownVtbl) { + fn GetPeerName( + pName: *mut LPWSTR, + ) -> HRESULT, + fn IsAuthenticated( + pAuth: *mut BOOL, + ) -> HRESULT, + fn IsAvailable( + pOnline: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x659cdea5, 0x489e, 0x11d9, 0xa9, 0xcd, 0x00, 0x0d, 0x56, 0x96, 0x52, 0x51)] +interface IEnumBitsPeers(IEnumBitsPeersVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut *mut IBitsPeer, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumBitsPeers, + ) -> HRESULT, + fn GetCount( + puCount: *mut ULONG, + ) -> HRESULT, +}} +pub const BG_ENABLE_PEERCACHING_CLIENT: DWORD = 0x0001; +pub const BG_ENABLE_PEERCACHING_SERVER: DWORD = 0x0002; +pub const BG_DISABLE_BRANCH_CACHE: DWORD = 0x0004; +RIDL!{#[uuid(0x659cdead, 0x489e, 0x11d9, 0xa9, 0xcd, 0x00, 0x0d, 0x56, 0x96, 0x52, 0x51)] +interface IBitsPeerCacheAdministration(IBitsPeerCacheAdministrationVtbl): IUnknown(IUnknownVtbl) { + fn GetMaximumCacheSize( + pBytes: *mut DWORD, + ) -> HRESULT, + fn SetMaximumCacheSize( + Bytes: DWORD, + ) -> HRESULT, + fn GetMaximumContentAge( + pSeconds: *mut ULONG, + ) -> HRESULT, + fn SetMaximumContentAge( + Seconds: ULONG, + ) -> HRESULT, + fn GetConfigurationFlags( + pFlags: *mut DWORD, + ) -> HRESULT, + fn SetConfigurationFlags( + Flags: DWORD, + ) -> HRESULT, + fn EnumRecords( + ppEnum: *mut *mut IEnumBitsPeerCacheRecords, + ) -> HRESULT, + fn GetRecord( + ppRecord: *mut *mut IBitsPeerCacheRecord, + ) -> HRESULT, + fn ClearRecords() -> HRESULT, + fn DeleteRecord( + id: REFGUID, + ) -> HRESULT, + fn DeleteUrl( + url: LPCWSTR, + ) -> HRESULT, + fn EnumPeers( + ppEnum: *mut *mut IEnumBitsPeers, + ) -> HRESULT, + fn ClearPeers() -> HRESULT, + fn DiscoverPeers() -> HRESULT, +}} +pub const BG_JOB_ENABLE_PEERCACHING_CLIENT: DWORD = 0x0001; +pub const BG_JOB_ENABLE_PEERCACHING_SERVER: DWORD = 0x0002; +pub const BG_JOB_DISABLE_BRANCH_CACHE: DWORD = 0x0004; +RIDL!{#[uuid(0x659cdeae, 0x489e, 0x11d9, 0xa9, 0xcd, 0x00, 0x0d, 0x56, 0x96, 0x52, 0x51)] +interface IBackgroundCopyJob4(IBackgroundCopyJob4Vtbl): + IBackgroundCopyJob3(IBackgroundCopyJob3Vtbl) { + fn SetPeerCachingFlags( + Flags: DWORD, + ) -> HRESULT, + fn GetPeerCachingFlags( + pFlags: *mut DWORD, + ) -> HRESULT, + fn GetOwnerIntegrityLevel( + pLevel: *mut ULONG, + ) -> HRESULT, + fn GetOwnerElevationState( + pElevated: *mut BOOL, + ) -> HRESULT, + fn SetMaximumDownloadTime( + Timeout: ULONG, + ) -> HRESULT, + fn GetMaximumDownloadTime( + pTimeout: *mut ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x659cdeaa, 0x489e, 0x11d9, 0xa9, 0xcd, 0x00, 0x0d, 0x56, 0x96, 0x52, 0x51)] +interface IBackgroundCopyFile3(IBackgroundCopyFile3Vtbl): + IBackgroundCopyFile2(IBackgroundCopyFile2Vtbl) { + fn GetTemporaryName( + pFilename: *mut LPWSTR, + ) -> HRESULT, + fn SetValidationState( + state: BOOL, + ) -> HRESULT, + fn GetValidationState( + pState: *mut BOOL, + ) -> HRESULT, + fn IsDownloadedFromPeer( + pVal: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x659cdeac, 0x489e, 0x11d9, 0xa9, 0xcd, 0x00, 0x0d, 0x56, 0x96, 0x52, 0x51)] +interface IBackgroundCopyCallback2(IBackgroundCopyCallback2Vtbl): + IBackgroundCopyCallback(IBackgroundCopyCallbackVtbl) { + fn FileTransferred( + pJob: *mut IBackgroundCopyJob, + pFile: *mut IBackgroundCopyFile, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bits4_0.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits4_0.rs new file mode 100644 index 0000000..2cd763a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits4_0.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::PUINT64; +use shared::minwindef::DWORD; +use um::bits3_0::{IBackgroundCopyFile3, IBackgroundCopyFile3Vtbl}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPWSTR}; +RIDL!{#[uuid(0x9a2584c3, 0xf7d2, 0x457a, 0x9a, 0x5e, 0x22, 0xb6, 0x7b, 0xff, 0xc7, 0xd2)] +interface IBitsTokenOptions(IBitsTokenOptionsVtbl): IUnknown(IUnknownVtbl) { + fn SetHelperTokenFlags( + UsageFlags: DWORD, + ) -> HRESULT, + fn GetHelperTokenFlags( + pFlags: *mut DWORD, + ) -> HRESULT, + fn SetHelperToken() -> HRESULT, + fn ClearHelperToken() -> HRESULT, + fn GetHelperTokenSid( + pSid: *mut LPWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xef7e0655, 0x7888, 0x4960, 0xb0, 0xe5, 0x73, 0x08, 0x46, 0xe0, 0x34, 0x92)] +interface IBackgroundCopyFile4(IBackgroundCopyFile4Vtbl): + IBackgroundCopyFile3(IBackgroundCopyFile3Vtbl) { + fn GetPeerDownloadStats( + pFromOrigin: PUINT64, + pFromPeers: PUINT64, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bits5_0.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits5_0.rs new file mode 100644 index 0000000..97166eb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bits5_0.rs @@ -0,0 +1,95 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::UINT64; +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, DWORD}; +use um::bits1_5::BG_AUTH_TARGET; +use um::bits3_0::{IBackgroundCopyJob4, IBackgroundCopyJob4Vtbl}; +use um::bits4_0::{IBackgroundCopyFile4, IBackgroundCopyFile4Vtbl}; +use um::winnt::{HRESULT, LPWSTR}; +pub const BITS_COST_STATE_UNRESTRICTED: DWORD = 0x1; +pub const BITS_COST_STATE_CAPPED_USAGE_UNKNOWN: DWORD = 0x2; +pub const BITS_COST_STATE_BELOW_CAP: DWORD = 0x4; +pub const BITS_COST_STATE_NEAR_CAP: DWORD = 0x8; +pub const BITS_COST_STATE_OVERCAP_CHARGED: DWORD = 0x10; +pub const BITS_COST_STATE_OVERCAP_THROTTLED: DWORD = 0x20; +pub const BITS_COST_STATE_USAGE_BASED: DWORD = 0x40; +pub const BITS_COST_STATE_ROAMING: DWORD = 0x80; +pub const BITS_COST_OPTION_IGNORE_CONGESTION: DWORD = 0x80000000; +pub const BITS_COST_STATE_RESERVED: DWORD = 0x40000000; +pub const BITS_COST_STATE_TRANSFER_NOT_ROAMING: DWORD = BITS_COST_OPTION_IGNORE_CONGESTION + | BITS_COST_STATE_USAGE_BASED | BITS_COST_STATE_OVERCAP_THROTTLED + | BITS_COST_STATE_OVERCAP_CHARGED | BITS_COST_STATE_NEAR_CAP | BITS_COST_STATE_BELOW_CAP + | BITS_COST_STATE_CAPPED_USAGE_UNKNOWN | BITS_COST_STATE_UNRESTRICTED; +pub const BITS_COST_STATE_TRANSFER_NO_SURCHARGE: DWORD = BITS_COST_OPTION_IGNORE_CONGESTION + | BITS_COST_STATE_USAGE_BASED | BITS_COST_STATE_OVERCAP_THROTTLED | BITS_COST_STATE_NEAR_CAP + | BITS_COST_STATE_BELOW_CAP | BITS_COST_STATE_CAPPED_USAGE_UNKNOWN + | BITS_COST_STATE_UNRESTRICTED; +pub const BITS_COST_STATE_TRANSFER_STANDARD: DWORD = BITS_COST_OPTION_IGNORE_CONGESTION + | BITS_COST_STATE_USAGE_BASED | BITS_COST_STATE_OVERCAP_THROTTLED | BITS_COST_STATE_BELOW_CAP + | BITS_COST_STATE_CAPPED_USAGE_UNKNOWN | BITS_COST_STATE_UNRESTRICTED; +pub const BITS_COST_STATE_TRANSFER_UNRESTRICTED: DWORD = BITS_COST_OPTION_IGNORE_CONGESTION + | BITS_COST_STATE_OVERCAP_THROTTLED | BITS_COST_STATE_UNRESTRICTED; +pub const BITS_COST_STATE_TRANSFER_ALWAYS: DWORD = BITS_COST_OPTION_IGNORE_CONGESTION + | BITS_COST_STATE_ROAMING | BITS_COST_STATE_USAGE_BASED | BITS_COST_STATE_OVERCAP_THROTTLED + | BITS_COST_STATE_OVERCAP_CHARGED | BITS_COST_STATE_NEAR_CAP | BITS_COST_STATE_BELOW_CAP + | BITS_COST_STATE_CAPPED_USAGE_UNKNOWN | BITS_COST_STATE_UNRESTRICTED; +ENUM!{enum BITS_JOB_TRANSFER_POLICY { + BITS_JOB_TRANSFER_POLICY_ALWAYS = 0x800000ff, + BITS_JOB_TRANSFER_POLICY_NOT_ROAMING = 0x8000007f, + BITS_JOB_TRANSFER_POLICY_NO_SURCHARGE = 0x8000006f, + BITS_JOB_TRANSFER_POLICY_STANDARD = 0x80000067, + BITS_JOB_TRANSFER_POLICY_UNRESTRICTED = 0x80000021, +}} +ENUM!{enum BITS_JOB_PROPERTY_ID { + BITS_JOB_PROPERTY_ID_COST_FLAGS = 1, + BITS_JOB_PROPERTY_NOTIFICATION_CLSID = 2, + BITS_JOB_PROPERTY_DYNAMIC_CONTENT = 3, + BITS_JOB_PROPERTY_HIGH_PERFORMANCE = 4, + BITS_JOB_PROPERTY_MAX_DOWNLOAD_SIZE = 5, + BITS_JOB_PROPERTY_USE_STORED_CREDENTIALS = 7, + BITS_JOB_PROPERTY_MINIMUM_NOTIFICATION_INTERVAL_MS = 9, + BITS_JOB_PROPERTY_ON_DEMAND_MODE = 10, +}} +UNION!{union BITS_JOB_PROPERTY_VALUE { + [u64; 2], + Dword Dword_mut: DWORD, + ClsID ClsID_mut: GUID, + Enable Enable_mut: BOOL, + Uint64 Uint64_mut: UINT64, + Target Target_mut: BG_AUTH_TARGET, +}} +ENUM!{enum BITS_FILE_PROPERTY_ID { + BITS_FILE_PROPERTY_ID_HTTP_RESPONSE_HEADERS = 1, +}} +UNION!{union BITS_FILE_PROPERTY_VALUE { + [usize; 1], + String String_mut: LPWSTR, +}} +RIDL!{#[uuid(0xe847030c, 0xbbba, 0x4657, 0xaf, 0x6d, 0x48, 0x4a, 0xa4, 0x2b, 0xf1, 0xfe)] +interface IBackgroundCopyJob5(IBackgroundCopyJob5Vtbl): + IBackgroundCopyJob4(IBackgroundCopyJob4Vtbl) { + fn SetProperty( + PropertyId: BITS_JOB_PROPERTY_ID, + PropertyValue: BITS_JOB_PROPERTY_VALUE, + ) -> HRESULT, + fn GetProperty( + PropertyId: BITS_JOB_PROPERTY_ID, + PropertyValue: *mut BITS_JOB_PROPERTY_VALUE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x85c1657f, 0xdafc, 0x40e8, 0x88, 0x34, 0xdf, 0x18, 0xea, 0x25, 0x71, 0x7e)] +interface IBackgroundCopyFile5(IBackgroundCopyFile5Vtbl): + IBackgroundCopyFile4(IBackgroundCopyFile4Vtbl) { + fn SetProperty( + PropertyId: BITS_JOB_PROPERTY_ID, + PropertyValue: BITS_JOB_PROPERTY_VALUE, + ) -> HRESULT, + fn GetProperty( + PropertyId: BITS_JOB_PROPERTY_ID, + PropertyValue: *mut BITS_JOB_PROPERTY_VALUE, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bitscfg.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bitscfg.rs new file mode 100644 index 0000000..3d9f46a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bitscfg.rs @@ -0,0 +1,70 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_uchar, c_ulong}; +use shared::guiddef::REFIID; +use shared::wtypes::BSTR; +use um::oaidl::{IDispatch, IDispatchVtbl}; +use um::unknwnbase::IUnknown; +use um::winnt::HRESULT; +RIDL!{#[uuid(0x29cfbbf7, 0x09e4, 0x4b97, 0xb0, 0xbc, 0xf2, 0x28, 0x7e, 0x3d, 0x8e, 0xb3)] +interface IBITSExtensionSetup(IBITSExtensionSetupVtbl): IDispatch(IDispatchVtbl) { + fn EnableBITSUploads() -> HRESULT, + fn DisableBITSUploads() -> HRESULT, + fn GetCleanupTaskName( + pTaskName: *mut BSTR, + ) -> HRESULT, + fn GetCleanupTask( + riid: REFIID, + ppUnk: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd5d2d542, 0x5503, 0x4e64, 0x8b, 0x48, 0x72, 0xef, 0x91, 0xa3, 0x2e, 0xe1)] +interface IBITSExtensionSetupFactory(IBITSExtensionSetupFactoryVtbl): IDispatch(IDispatchVtbl) { + fn GetObject( + Path: BSTR, + ppExtensionSetup: *mut *mut IBITSExtensionSetup, + ) -> HRESULT, +}} +extern "system" { + pub fn BSTR_UserSize( + pFlags: *mut c_ulong, + Offset: c_ulong, + pBstr: *mut BSTR, + ) -> c_ulong; + pub fn BSTR_UserMarshal( + pFlags: *mut c_ulong, + pBuffer: *mut c_uchar, + pBstr: *mut BSTR, + ) -> *mut c_uchar; + pub fn BSTR_UserUnmarshal( + pFlags: *mut c_ulong, + pBuffer: *mut c_uchar, + pBstr: *mut BSTR, + ) -> *mut c_uchar; + pub fn BSTR_UserFree( + pFlags: *mut c_ulong, + pBstr: *mut BSTR, + ); + pub fn BSTR_UserSize64( + pFlags: *mut c_ulong, + Offset: c_ulong, + pBstr: *mut BSTR, + ) -> c_ulong; + pub fn BSTR_UserMarshal64( + pFlags: *mut c_ulong, + pBuffer: *mut c_uchar, + pBstr: *mut BSTR, + ) -> *mut c_uchar; + pub fn BSTR_UserUnmarshal64( + pFlags: *mut c_ulong, + pBuffer: *mut c_uchar, + pBstr: *mut BSTR, + ) -> *mut c_uchar; + pub fn BSTR_UserFree64( + pFlags: *mut c_ulong, + pBstr: *mut BSTR, + ); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bitsmsg.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bitsmsg.rs new file mode 100644 index 0000000..b7029f7 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bitsmsg.rs @@ -0,0 +1,142 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! error code definitions for the background file copier +use shared::minwindef::DWORD; +pub const BG_E_NOT_FOUND: DWORD = 0x80200001; +pub const BG_E_INVALID_STATE: DWORD = 0x80200002; +pub const BG_E_EMPTY: DWORD = 0x80200003; +pub const BG_E_FILE_NOT_AVAILABLE: DWORD = 0x80200004; +pub const BG_E_PROTOCOL_NOT_AVAILABLE: DWORD = 0x80200005; +pub const BG_S_ERROR_CONTEXT_NONE: DWORD = 0x00200006; +pub const BG_E_ERROR_CONTEXT_UNKNOWN: DWORD = 0x80200007; +pub const BG_E_ERROR_CONTEXT_GENERAL_QUEUE_MANAGER: DWORD = 0x80200008; +pub const BG_E_ERROR_CONTEXT_LOCAL_FILE: DWORD = 0x80200009; +pub const BG_E_ERROR_CONTEXT_REMOTE_FILE: DWORD = 0x8020000A; +pub const BG_E_ERROR_CONTEXT_GENERAL_TRANSPORT: DWORD = 0x8020000B; +pub const BG_E_ERROR_CONTEXT_QUEUE_MANAGER_NOTIFICATION: DWORD = 0x8020000C; +pub const BG_E_DESTINATION_LOCKED: DWORD = 0x8020000D; +pub const BG_E_VOLUME_CHANGED: DWORD = 0x8020000E; +pub const BG_E_ERROR_INFORMATION_UNAVAILABLE: DWORD = 0x8020000F; +pub const BG_E_NETWORK_DISCONNECTED: DWORD = 0x80200010; +pub const BG_E_MISSING_FILE_SIZE: DWORD = 0x80200011; +pub const BG_E_INSUFFICIENT_HTTP_SUPPORT: DWORD = 0x80200012; +pub const BG_E_INSUFFICIENT_RANGE_SUPPORT: DWORD = 0x80200013; +pub const BG_E_REMOTE_NOT_SUPPORTED: DWORD = 0x80200014; +pub const BG_E_NEW_OWNER_DIFF_MAPPING: DWORD = 0x80200015; +pub const BG_E_NEW_OWNER_NO_FILE_ACCESS: DWORD = 0x80200016; +pub const BG_S_PARTIAL_COMPLETE: DWORD = 0x00200017; +pub const BG_E_PROXY_LIST_TOO_LARGE: DWORD = 0x80200018; +pub const BG_E_PROXY_BYPASS_LIST_TOO_LARGE: DWORD = 0x80200019; +pub const BG_S_UNABLE_TO_DELETE_FILES: DWORD = 0x0020001A; +pub const BG_E_INVALID_SERVER_RESPONSE: DWORD = 0x8020001B; +pub const BG_E_TOO_MANY_FILES: DWORD = 0x8020001C; +pub const BG_E_LOCAL_FILE_CHANGED: DWORD = 0x8020001D; +pub const BG_E_ERROR_CONTEXT_REMOTE_APPLICATION: DWORD = 0x8020001E; +pub const BG_E_SESSION_NOT_FOUND: DWORD = 0x8020001F; +pub const BG_E_TOO_LARGE: DWORD = 0x80200020; +pub const BG_E_STRING_TOO_LONG: DWORD = 0x80200021; +pub const BG_E_CLIENT_SERVER_PROTOCOL_MISMATCH: DWORD = 0x80200022; +pub const BG_E_SERVER_EXECUTE_ENABLE: DWORD = 0x80200023; +pub const BG_E_NO_PROGRESS: DWORD = 0x80200024; +pub const BG_E_USERNAME_TOO_LARGE: DWORD = 0x80200025; +pub const BG_E_PASSWORD_TOO_LARGE: DWORD = 0x80200026; +pub const BG_E_INVALID_AUTH_TARGET: DWORD = 0x80200027; +pub const BG_E_INVALID_AUTH_SCHEME: DWORD = 0x80200028; +pub const BG_E_FILE_NOT_FOUND: DWORD = 0x80200029; +pub const BG_S_PROXY_CHANGED: DWORD = 0x0020002A; +pub const BG_E_INVALID_RANGE: DWORD = 0x8020002B; +pub const BG_E_OVERLAPPING_RANGES: DWORD = 0x8020002C; +pub const BG_E_CONNECT_FAILURE: DWORD = 0x8020002D; +pub const BG_E_CONNECTION_CLOSED: DWORD = 0x8020002E; +pub const BG_E_BLOCKED_BY_POLICY: DWORD = 0x8020003E; +pub const BG_E_INVALID_PROXY_INFO: DWORD = 0x8020003F; +pub const BG_E_INVALID_CREDENTIALS: DWORD = 0x80200040; +pub const BG_E_INVALID_HASH_ALGORITHM: DWORD = 0x80200041; +pub const BG_E_RECORD_DELETED: DWORD = 0x80200042; +pub const BG_E_COMMIT_IN_PROGRESS: DWORD = 0x80200043; +pub const BG_E_DISCOVERY_IN_PROGRESS: DWORD = 0x80200044; +pub const BG_E_UPNP_ERROR: DWORD = 0x80200045; +pub const BG_E_TEST_OPTION_BLOCKED_DOWNLOAD: DWORD = 0x80200046; +pub const BG_E_PEERCACHING_DISABLED: DWORD = 0x80200047; +pub const BG_E_BUSYCACHERECORD: DWORD = 0x80200048; +pub const BG_E_TOO_MANY_JOBS_PER_USER: DWORD = 0x80200049; +pub const BG_E_TOO_MANY_JOBS_PER_MACHINE: DWORD = 0x80200050; +pub const BG_E_TOO_MANY_FILES_IN_JOB: DWORD = 0x80200051; +pub const BG_E_TOO_MANY_RANGES_IN_FILE: DWORD = 0x80200052; +pub const BG_E_VALIDATION_FAILED: DWORD = 0x80200053; +pub const BG_E_MAXDOWNLOAD_TIMEOUT: DWORD = 0x80200054; +pub const BG_S_OVERRIDDEN_BY_POLICY: DWORD = 0x00200055; +pub const BG_E_TOKEN_REQUIRED: DWORD = 0x80200056; +pub const BG_E_UNKNOWN_PROPERTY_ID: DWORD = 0x80200057; +pub const BG_E_READ_ONLY_PROPERTY: DWORD = 0x80200058; +pub const BG_E_BLOCKED_BY_COST_TRANSFER_POLICY: DWORD = 0x80200059; +pub const BG_E_PROPERTY_SUPPORTED_FOR_DOWNLOAD_JOBS_ONLY: DWORD = 0x80200060; +pub const BG_E_READ_ONLY_PROPERTY_AFTER_ADDFILE: DWORD = 0x80200061; +pub const BG_E_READ_ONLY_PROPERTY_AFTER_RESUME: DWORD = 0x80200062; +pub const BG_E_MAX_DOWNLOAD_SIZE_INVALID_VALUE: DWORD = 0x80200063; +pub const BG_E_MAX_DOWNLOAD_SIZE_LIMIT_REACHED: DWORD = 0x80200064; +pub const BG_E_STANDBY_MODE: DWORD = 0x80200065; +pub const BG_E_USE_STORED_CREDENTIALS_NOT_SUPPORTED: DWORD = 0x80200066; +pub const BG_E_BLOCKED_BY_BATTERY_POLICY: DWORD = 0x80200067; +pub const BG_E_BLOCKED_BY_BATTERY_SAVER: DWORD = 0x80200068; +pub const BG_E_WATCHDOG_TIMEOUT: DWORD = 0x80200069; +pub const BG_E_APP_PACKAGE_NOT_FOUND: DWORD = 0x8020006A; +pub const BG_E_APP_PACKAGE_SCENARIO_NOT_SUPPORTED: DWORD = 0x8020006B; +pub const BG_E_DATABASE_CORRUPT: DWORD = 0x8020006C; +pub const BG_E_RANDOM_ACCESS_NOT_SUPPORTED: DWORD = 0x8020006D; +pub const BG_E_HTTP_ERROR_100: DWORD = 0x80190064; +pub const BG_E_HTTP_ERROR_101: DWORD = 0x80190065; +pub const BG_E_HTTP_ERROR_200: DWORD = 0x801900C8; +pub const BG_E_HTTP_ERROR_201: DWORD = 0x801900C9; +pub const BG_E_HTTP_ERROR_202: DWORD = 0x801900CA; +pub const BG_E_HTTP_ERROR_203: DWORD = 0x801900CB; +pub const BG_E_HTTP_ERROR_204: DWORD = 0x801900CC; +pub const BG_E_HTTP_ERROR_205: DWORD = 0x801900CD; +pub const BG_E_HTTP_ERROR_206: DWORD = 0x801900CE; +pub const BG_E_HTTP_ERROR_300: DWORD = 0x8019012C; +pub const BG_E_HTTP_ERROR_301: DWORD = 0x8019012D; +pub const BG_E_HTTP_ERROR_302: DWORD = 0x8019012E; +pub const BG_E_HTTP_ERROR_303: DWORD = 0x8019012F; +pub const BG_E_HTTP_ERROR_304: DWORD = 0x80190130; +pub const BG_E_HTTP_ERROR_305: DWORD = 0x80190131; +pub const BG_E_HTTP_ERROR_307: DWORD = 0x80190133; +pub const BG_E_HTTP_ERROR_400: DWORD = 0x80190190; +pub const BG_E_HTTP_ERROR_401: DWORD = 0x80190191; +pub const BG_E_HTTP_ERROR_402: DWORD = 0x80190192; +pub const BG_E_HTTP_ERROR_403: DWORD = 0x80190193; +pub const BG_E_HTTP_ERROR_404: DWORD = 0x80190194; +pub const BG_E_HTTP_ERROR_405: DWORD = 0x80190195; +pub const BG_E_HTTP_ERROR_406: DWORD = 0x80190196; +pub const BG_E_HTTP_ERROR_407: DWORD = 0x80190197; +pub const BG_E_HTTP_ERROR_408: DWORD = 0x80190198; +pub const BG_E_HTTP_ERROR_409: DWORD = 0x80190199; +pub const BG_E_HTTP_ERROR_410: DWORD = 0x8019019A; +pub const BG_E_HTTP_ERROR_411: DWORD = 0x8019019B; +pub const BG_E_HTTP_ERROR_412: DWORD = 0x8019019C; +pub const BG_E_HTTP_ERROR_413: DWORD = 0x8019019D; +pub const BG_E_HTTP_ERROR_414: DWORD = 0x8019019E; +pub const BG_E_HTTP_ERROR_415: DWORD = 0x8019019F; +pub const BG_E_HTTP_ERROR_416: DWORD = 0x801901A0; +pub const BG_E_HTTP_ERROR_417: DWORD = 0x801901A1; +pub const BG_E_HTTP_ERROR_449: DWORD = 0x801901C1; +pub const BG_E_HTTP_ERROR_500: DWORD = 0x801901F4; +pub const BG_E_HTTP_ERROR_501: DWORD = 0x801901F5; +pub const BG_E_HTTP_ERROR_502: DWORD = 0x801901F6; +pub const BG_E_HTTP_ERROR_503: DWORD = 0x801901F7; +pub const BG_E_HTTP_ERROR_504: DWORD = 0x801901F8; +pub const BG_E_HTTP_ERROR_505: DWORD = 0x801901F9; +pub const BITS_MC_JOB_CANCELLED: DWORD = 0x80194000; +pub const BITS_MC_FILE_DELETION_FAILED: DWORD = 0x80194001; +pub const BITS_MC_FILE_DELETION_FAILED_MORE: DWORD = 0x80194002; +pub const BITS_MC_JOB_PROPERTY_CHANGE: DWORD = 0x80194003; +pub const BITS_MC_JOB_TAKE_OWNERSHIP: DWORD = 0x80194004; +pub const BITS_MC_JOB_SCAVENGED: DWORD = 0x80194005; +pub const BITS_MC_JOB_NOTIFICATION_FAILURE: DWORD = 0x80194006; +pub const BITS_MC_STATE_FILE_CORRUPT: DWORD = 0x80194007; +pub const BITS_MC_FAILED_TO_START: DWORD = 0x80194008; +pub const BITS_MC_FATAL_IGD_ERROR: DWORD = 0x80194009; +pub const BITS_MC_PEERCACHING_PORT: DWORD = 0x8019400A; +pub const BITS_MC_WSD_PORT: DWORD = 0x8019400B; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bluetoothapis.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bluetoothapis.rs new file mode 100644 index 0000000..8b75c87 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bluetoothapis.rs @@ -0,0 +1,414 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::bthdef::{AUTHENTICATION_REQUIREMENTS, BTH_ADDR, BTH_MAX_PIN_SIZE}; +use shared::bthsdpdef::{SDP_LARGE_INTEGER_16, SDP_SPECIFICTYPE, SDP_TYPE, SDP_ULARGE_INTEGER_16}; +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, DWORD, LPBYTE, LPVOID, PULONG, UCHAR, ULONG, USHORT}; +use shared::windef::HWND; +use um::minwinbase::SYSTEMTIME; +use um::winnt::{ + CHAR, HANDLE, LONG, LONGLONG, LPCWSTR, LPWSTR, PVOID, PWSTR, SHORT, ULONGLONG, WCHAR, +}; +pub const BLUETOOTH_MAX_NAME_SIZE: usize = 248; +pub const BLUETOOTH_MAX_PASSKEY_SIZE: usize = 16; +pub const BLUETOOTH_MAX_PASSKEY_BUFFER_SIZE: usize = BLUETOOTH_MAX_PASSKEY_SIZE + 1; +pub const BLUETOOTH_MAX_SERVICE_NAME_SIZE: usize = 256; +pub const BLUETOOTH_DEVICE_NAME_SIZE: usize = 256; +pub type BLUETOOTH_ADDRESS = BTH_ADDR; +pub const BLUETOOTH_NULL_ADDRESS: BLUETOOTH_ADDRESS = 0x0; +STRUCT!{struct BLUETOOTH_LOCAL_SERVICE_INFO { + Enabled: BOOL, + btAddr: BLUETOOTH_ADDRESS, + szName: [WCHAR; BLUETOOTH_MAX_SERVICE_NAME_SIZE], + szDeviceString: [WCHAR; BLUETOOTH_DEVICE_NAME_SIZE], +}} +pub type PBLUETOOTH_LOCAL_SERVICE_INFO = *mut BLUETOOTH_LOCAL_SERVICE_INFO; +STRUCT!{struct BLUETOOTH_FIND_RADIO_PARAMS { + dwSize: DWORD, +}} +pub type HBLUETOOTH_RADIO_FIND = HANDLE; +extern "system" { + pub fn BluetoothFindFirstRadio( + pbtfrp: *const BLUETOOTH_FIND_RADIO_PARAMS, + phRadio: *mut HANDLE, + ) -> HBLUETOOTH_RADIO_FIND; + pub fn BluetoothFindNextRadio( + hFind: HBLUETOOTH_RADIO_FIND, + phRadio: *mut HANDLE, + ) -> BOOL; + pub fn BluetoothFindRadioClose( + hFind: HBLUETOOTH_RADIO_FIND, + ) -> BOOL; +} +STRUCT!{struct BLUETOOTH_RADIO_INFO { + dwSize: DWORD, + address: BLUETOOTH_ADDRESS, + szName: [WCHAR; BLUETOOTH_MAX_NAME_SIZE], + ulClassofDevice: ULONG, + lmpSubversion: USHORT, + manufacturer: USHORT, +}} +pub type PBLUETOOTH_RADIO_INFO = *mut BLUETOOTH_RADIO_INFO; +extern "system" { + pub fn BluetoothGetRadioInfo( + hRadio: HANDLE, + pRadioInfo: PBLUETOOTH_RADIO_INFO, + ) -> DWORD; +} +STRUCT!{struct BLUETOOTH_DEVICE_INFO { + dwSize: DWORD, + Address: BLUETOOTH_ADDRESS, + ulClassofDevice: ULONG, + fConnected: BOOL, + fRemembered: BOOL, + fAuthenticated: BOOL, + stLastSeen: SYSTEMTIME, + stLastUsed: SYSTEMTIME, + szName: [WCHAR; BLUETOOTH_MAX_NAME_SIZE], +}} +pub type PBLUETOOTH_DEVICE_INFO = *mut BLUETOOTH_DEVICE_INFO; +ENUM!{enum BLUETOOTH_AUTHENTICATION_METHOD { + BLUETOOTH_AUTHENTICATION_METHOD_LEGACY = 0x1, + BLUETOOTH_AUTHENTICATION_METHOD_OOB, + BLUETOOTH_AUTHENTICATION_METHOD_NUMERIC_COMPARISON, + BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY_NOTIFICATION, + BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY, +}} +pub type PBLUETOOTH_AUTHENTICATION_METHOD = *mut BLUETOOTH_AUTHENTICATION_METHOD; +ENUM!{enum BLUETOOTH_IO_CAPABILITY { + BLUETOOTH_IO_CAPABILITY_DISPLAYONLY = 0x00, + BLUETOOTH_IO_CAPABILITY_DISPLAYYESNO = 0x01, + BLUETOOTH_IO_CAPABILITY_KEYBOARDONLY = 0x02, + BLUETOOTH_IO_CAPABILITY_NOINPUTNOOUTPUT = 0x03, + BLUETOOTH_IO_CAPABILITY_UNDEFINED = 0xff, +}} +ENUM!{enum BLUETOOTH_AUTHENTICATION_REQUIREMENTS { + BLUETOOTH_MITM_ProtectionNotRequired = 0, + BLUETOOTH_MITM_ProtectionRequired = 0x1, + BLUETOOTH_MITM_ProtectionNotRequiredBonding = 0x2, + BLUETOOTH_MITM_ProtectionRequiredBonding = 0x3, + BLUETOOTH_MITM_ProtectionNotRequiredGeneralBonding = 0x4, + BLUETOOTH_MITM_ProtectionRequiredGeneralBonding = 0x5, + BLUETOOTH_MITM_ProtectionNotDefined = 0xff, +}} +UNION!{union BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS_u { + [u32; 1], + Numeric_Value Numeric_Value_mut: ULONG, + Passkey Passkey_mut: ULONG, +}} +STRUCT!{struct BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS { + deviceInfo: BLUETOOTH_DEVICE_INFO, + authenticationMethod: BLUETOOTH_AUTHENTICATION_METHOD, + ioCapability: BLUETOOTH_IO_CAPABILITY, + authenticationRequirements: BLUETOOTH_AUTHENTICATION_REQUIREMENTS, + u: BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS_u, +}} +pub type PBLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS = *mut BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS; +STRUCT!{struct BLUETOOTH_DEVICE_SEARCH_PARAMS { + dwSize: DWORD, + fReturnAuthenticated: BOOL, + fReturnRemembered: BOOL, + fReturnUnknown: BOOL, + fReturnConnected: BOOL, + fIssueInquiry: BOOL, + cTimeoutMultiplier: UCHAR, + hRadio: HANDLE, +}} +pub type HBLUETOOTH_DEVICE_FIND = HANDLE; +extern "system" { + pub fn BluetoothFindFirstDevice( + pbtsp: *const BLUETOOTH_DEVICE_SEARCH_PARAMS, + pbtdi: *mut BLUETOOTH_DEVICE_INFO, + ) -> HBLUETOOTH_DEVICE_FIND; + pub fn BluetoothFindNextDevice( + hFind: HBLUETOOTH_DEVICE_FIND, + pbtdi: *mut BLUETOOTH_DEVICE_INFO, + ) -> BOOL; + pub fn BluetoothFindDeviceClose( + hFind: HBLUETOOTH_DEVICE_FIND, + ) -> BOOL; + pub fn BluetoothGetDeviceInfo( + hRadio: HANDLE, + pbtdi: *mut BLUETOOTH_DEVICE_INFO, + ) -> DWORD; + pub fn BluetoothUpdateDeviceRecord( + pbtdi: *const BLUETOOTH_DEVICE_INFO, + ) -> DWORD; + pub fn BluetoothRemoveDevice( + pAddress: *const BLUETOOTH_ADDRESS, + ) -> DWORD; +} +STRUCT!{struct BLUETOOTH_COD_PAIRS { + ulCODMask: ULONG, + pcszDescription: LPCWSTR, +}} +FN!{stdcall PFN_DEVICE_CALLBACK( + pvParam: LPVOID, + pDevice: *const BLUETOOTH_DEVICE_INFO, +) -> BOOL} +STRUCT!{struct BLUETOOTH_SELECT_DEVICE_PARAMS { + dwSize: DWORD, + cNumOfClasses: ULONG, + prgClassOfDevices: *mut BLUETOOTH_COD_PAIRS, + pszInfo: LPWSTR, + hwndParent: HWND, + fForceAuthentication: BOOL, + fShowAuthenticated: BOOL, + fShowRemembered: BOOL, + fShowUnknown: BOOL, + fAddNewDeviceWizard: BOOL, + fSkipServicesPage: BOOL, + pfnDeviceCallback: PFN_DEVICE_CALLBACK, + pvParam: LPVOID, + cNumDevices: DWORD, + pDevices: PBLUETOOTH_DEVICE_INFO, +}} +extern "system" { + pub fn BluetoothSelectDevices( + pbtsdp: *mut BLUETOOTH_SELECT_DEVICE_PARAMS, + ) -> BOOL; + pub fn BluetoothSelectDevicesFree( + pbtsdp: *mut BLUETOOTH_SELECT_DEVICE_PARAMS, + ) -> BOOL; + pub fn BluetoothDisplayDeviceProperties( + hwndParent: HWND, + pbtdi: *mut BLUETOOTH_DEVICE_INFO, + ) -> BOOL; + // #[deprecated] + pub fn BluetoothAuthenticateDevice( + hwndParent: HWND, + hRadio: HANDLE, + pbtbi: *mut BLUETOOTH_DEVICE_INFO, + pszPasskey: PWSTR, + ulPasskeyLength: ULONG, + ) -> DWORD; +} +STRUCT!{struct BLUETOOTH_PIN_INFO { + pin: [UCHAR; BTH_MAX_PIN_SIZE], + pinLength: UCHAR, +}} +pub type PBLUETOOTH_PIN_INFO = *mut BLUETOOTH_PIN_INFO; +STRUCT!{struct BLUETOOTH_OOB_DATA_INFO { + C: [UCHAR; 16], + R: [UCHAR; 16], +}} +pub type PBLUETOOTH_OOB_DATA_INFO = *mut BLUETOOTH_OOB_DATA_INFO; +STRUCT!{struct BLUETOOTH_NUMERIC_COMPARISON_INFO { + NumericValue: ULONG, +}} +pub type PBLUETOOTH_NUMERIC_COMPARISON_INFO = *mut BLUETOOTH_NUMERIC_COMPARISON_INFO; +STRUCT!{struct BLUETOOTH_PASSKEY_INFO { + passkey: ULONG, +}} +pub type PBLUETOOTH_PASSKEY_INFO = *mut BLUETOOTH_PASSKEY_INFO; +extern "system" { + pub fn BluetoothAuthenticateDeviceEx( + hwndParentIn: HWND, + hRadioIn: HANDLE, + pbtdiInout: *mut BLUETOOTH_DEVICE_INFO, + pbtOobData: PBLUETOOTH_OOB_DATA_INFO, + authenticationRequirement: AUTHENTICATION_REQUIREMENTS, + ) -> DWORD; + // #[deprecated] + pub fn BluetoothAuthenticateMultipleDevices( + hwndParent: HWND, + hRadio: HANDLE, + cDevices: DWORD, + rgbtdi: *mut BLUETOOTH_DEVICE_INFO, + ) -> DWORD; +} +pub const BLUETOOTH_SERVICE_DISABLE: DWORD = 0x00; +pub const BLUETOOTH_SERVICE_ENABLE: DWORD = 0x01; +pub const BLUETOOTH_SERVICE_MASK: DWORD = BLUETOOTH_SERVICE_DISABLE | BLUETOOTH_SERVICE_ENABLE; +extern "system" { + pub fn BluetoothSetServiceState( + hRadio: HANDLE, + pbtdi: *const BLUETOOTH_DEVICE_INFO, + pGuidService: *const GUID, + dwServiceFlags: DWORD, + ) -> DWORD; + pub fn BluetoothEnumerateInstalledServices( + hRadio: HANDLE, + pbtdi: *const BLUETOOTH_DEVICE_INFO, + pcServiceInout: *mut DWORD, + pGuidServices: *mut GUID, + ) -> DWORD; + pub fn BluetoothEnableDiscovery( + hRadio: HANDLE, + fEnabled: BOOL, + ) -> BOOL; + pub fn BluetoothIsDiscoverable( + hRadio: HANDLE, + ) -> BOOL; + pub fn BluetoothEnableIncomingConnections( + hRadio: HANDLE, + fEnabled: BOOL, + ) -> BOOL; + pub fn BluetoothIsConnectable( + hRadio: HANDLE, + ) -> BOOL; +} +pub type HBLUETOOTH_AUTHENTICATION_REGISTRATION = HANDLE; +FN!{stdcall PFN_AUTHENTICATION_CALLBACK( + pvParam: LPVOID, + pDevice: PBLUETOOTH_DEVICE_INFO, +) -> BOOL} +extern "system" { + // #[deprecated] + pub fn BluetoothRegisterForAuthentication( + pbtdi: *const BLUETOOTH_DEVICE_INFO, + phRegHandle: *mut HBLUETOOTH_AUTHENTICATION_REGISTRATION, + pfnCallback: PFN_AUTHENTICATION_CALLBACK, + pvParam: PVOID, + ) -> DWORD; +} +FN!{stdcall PFN_AUTHENTICATION_CALLBACK_EX( + pvParam: LPVOID, + pAuthCallbackParams: PBLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS, +) -> BOOL} +extern "system" { + pub fn BluetoothRegisterForAuthenticationEx( + pbtdiIn: *const BLUETOOTH_DEVICE_INFO, + phRegHandleOut: *mut HBLUETOOTH_AUTHENTICATION_REGISTRATION, + pfnCallbackIn: PFN_AUTHENTICATION_CALLBACK_EX, + pvParam: PVOID, + ) -> DWORD; + pub fn BluetoothUnregisterAuthentication( + hRegHandle: HBLUETOOTH_AUTHENTICATION_REGISTRATION, + ) -> BOOL; + // #[deprecated] + pub fn BluetoothSendAuthenticationResponse( + hRadio: HANDLE, + pbtdi: *const BLUETOOTH_DEVICE_INFO, + pszPasskey: LPCWSTR, + ) -> DWORD; +} +UNION!{union BLUETOOTH_AUTHENTICATE_RESPONSE_u { + [u32; 8], + pinInfo pinInfo_mut: BLUETOOTH_PIN_INFO, + oobInfo oobInfo_mut: BLUETOOTH_OOB_DATA_INFO, + numericCompInfo numericCompInfo_mut: BLUETOOTH_NUMERIC_COMPARISON_INFO, + passkeyInfo passkeyInfo_mut: BLUETOOTH_PASSKEY_INFO, +}} +STRUCT!{struct BLUETOOTH_AUTHENTICATE_RESPONSE { + bthAddressRemote: BLUETOOTH_ADDRESS, + authMethod: BLUETOOTH_AUTHENTICATION_METHOD, + u: BLUETOOTH_AUTHENTICATE_RESPONSE_u, + negativeResponse: UCHAR, +}} +pub type PBLUETOOTH_AUTHENTICATE_RESPONSE = *mut BLUETOOTH_AUTHENTICATE_RESPONSE; +extern "system" { + pub fn BluetoothSendAuthenticationResponseEx( + hRadioIn: HANDLE, + pauthResponse: PBLUETOOTH_AUTHENTICATE_RESPONSE, + ) -> DWORD; +} +STRUCT!{struct SDP_ELEMENT_DATA_data_string { + value: LPBYTE, + length: ULONG, +}} +STRUCT!{struct SDP_ELEMENT_DATA_data_url { + value: LPBYTE, + length: ULONG, +}} +STRUCT!{struct SDP_ELEMENT_DATA_data_sequence { + value: LPBYTE, + length: ULONG, +}} +STRUCT!{struct SDP_ELEMENT_DATA_data_alternative { + value: LPBYTE, + length: ULONG, +}} +UNION!{union SDP_ELEMENT_DATA_data { + [u64; 2], + int128 int128_mut: SDP_LARGE_INTEGER_16, + int64 int64_mut: LONGLONG, + int32 int32_mut: LONG, + int16 int16_mut: SHORT, + int8 int8_mut: CHAR, + uint128 uint128_mut: SDP_ULARGE_INTEGER_16, + uint64 uint64_mut: ULONGLONG, + uint32 uint32_mut: ULONG, + uint16 uint16_mut: USHORT, + uint8 uint8_mut: UCHAR, + booleanVal booleanVal_mut: UCHAR, + uuid128 uuid128_mut: GUID, + uuid32 uuid32_mut: ULONG, + uuid16 uuid16_mut: USHORT, + string string_mut: SDP_ELEMENT_DATA_data_string, + url url_mut: SDP_ELEMENT_DATA_data_url, + sequence sequence_mut: SDP_ELEMENT_DATA_data_sequence, + alternative alternative_mut: SDP_ELEMENT_DATA_data_alternative, +}} +STRUCT!{struct SDP_ELEMENT_DATA { + type_: SDP_TYPE, + specificType: SDP_SPECIFICTYPE, + data: SDP_ELEMENT_DATA_data, +}} +pub type PSDP_ELEMENT_DATA = *mut SDP_ELEMENT_DATA; +extern "system" { + pub fn BluetoothSdpGetElementData( + pSdpStream: LPBYTE, + cbSdpStreamLength: ULONG, + pData: PSDP_ELEMENT_DATA, + ) -> DWORD; +} +pub type HBLUETOOTH_CONTAINER_ELEMENT = HANDLE; +extern "system" { + pub fn BluetoothSdpGetContainerElementData( + pContainerStream: LPBYTE, + cbContainerLength: ULONG, + pElement: *mut HBLUETOOTH_CONTAINER_ELEMENT, + pData: PSDP_ELEMENT_DATA, + ) -> DWORD; + pub fn BluetoothSdpGetAttributeValue( + pRecordStream: LPBYTE, + cbRecordLength: ULONG, + usAttributeId: USHORT, + pAttributeData: PSDP_ELEMENT_DATA, + ) -> DWORD; +} +STRUCT!{struct SDP_STRING_TYPE_DATA { + encoding: USHORT, + mibeNum: USHORT, + attributeId: USHORT, +}} +pub type PSDP_STRING_TYPE_DATA = *mut SDP_STRING_TYPE_DATA; +extern "system" { + pub fn BluetoothSdpGetString( + pRecordStream: LPBYTE, + cbRecordLength: ULONG, + pStringData: PSDP_STRING_TYPE_DATA, + usStringOffset: USHORT, + pszString: PWSTR, + pcchStringLength: PULONG, + ) -> DWORD; +} +FN!{stdcall PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK( + uAttribId: ULONG, + pValueStream: LPBYTE, + cbStreamSize: ULONG, + pvParam: LPVOID, +) -> BOOL} +pub use self::BluetoothSdpEnumAttributes as BluetoothEnumAttributes; +extern "system" { + pub fn BluetoothSdpEnumAttributes( + pSDPStream: LPBYTE, + cbStreamSize: ULONG, + pfnCallback: PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK, + pvParam: LPVOID, + ) -> BOOL; + pub fn BluetoothSetLocalServiceInfo( + hRadioIn: HANDLE, + pClassGuid: *const GUID, + ulInstance: ULONG, + pServiceInfoIn: *const BLUETOOTH_LOCAL_SERVICE_INFO, + ) -> DWORD; + pub fn BluetoothIsVersionAvailable( + MajorVersion: UCHAR, + MinorVersion: UCHAR, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bluetoothleapis.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bluetoothleapis.rs new file mode 100644 index 0000000..bca8f97 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bluetoothleapis.rs @@ -0,0 +1,104 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{ULONG, USHORT}; +use shared::winerror::HRESULT; +use um::bthledef::{ + BLUETOOTH_GATT_EVENT_HANDLE, BTH_LE_GATT_EVENT_TYPE, BTH_LE_GATT_RELIABLE_WRITE_CONTEXT, + PBTH_LE_GATT_CHARACTERISTIC, PBTH_LE_GATT_CHARACTERISTIC_VALUE, PBTH_LE_GATT_DESCRIPTOR, + PBTH_LE_GATT_DESCRIPTOR_VALUE, PBTH_LE_GATT_RELIABLE_WRITE_CONTEXT, PBTH_LE_GATT_SERVICE, + PFNBLUETOOTH_GATT_EVENT_CALLBACK, +}; +use um::winnt::{HANDLE, PVOID}; +extern "system" { + pub fn BluetoothGATTGetServices( + hDevice: HANDLE, + ServicesBufferCount: USHORT, + ServicesBuffer: PBTH_LE_GATT_SERVICE, + ServicesBufferActual: *mut USHORT, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTGetIncludedServices( + hDevice: HANDLE, + ParentService: PBTH_LE_GATT_SERVICE, + IncludedServicesBufferCount: USHORT, + IncludedServicesBuffer: PBTH_LE_GATT_SERVICE, + IncludedServicesBufferActual: *mut USHORT, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTGetCharacteristics( + hDevice: HANDLE, + Service: PBTH_LE_GATT_SERVICE, + CharacteristicsBufferCount: USHORT, + CharacteristicsBuffer: PBTH_LE_GATT_CHARACTERISTIC, + CharacteristicsBufferActual: *mut USHORT, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTGetDescriptors( + hDevice: HANDLE, + Characteristic: PBTH_LE_GATT_CHARACTERISTIC, + DescriptorsBufferCount: USHORT, + DescriptorsBuffer: PBTH_LE_GATT_DESCRIPTOR, + DescriptorsBufferActual: *mut USHORT, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTGetCharacteristicValue( + hDevice: HANDLE, + Characteristic: PBTH_LE_GATT_CHARACTERISTIC, + CharacteristicValueDataSize: ULONG, + CharacteristicValue: PBTH_LE_GATT_CHARACTERISTIC_VALUE, + CharacteristicValueSizeRequired: *mut USHORT, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTGetDescriptorValue( + hDevice: HANDLE, + Descriptor: PBTH_LE_GATT_DESCRIPTOR, + DescriptorValueDataSize: ULONG, + DescriptorValue: PBTH_LE_GATT_DESCRIPTOR_VALUE, + DescriptorValueSizeRequired: *mut USHORT, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTBeginReliableWrite( + hDevice: HANDLE, + ReliableWriteContext: PBTH_LE_GATT_RELIABLE_WRITE_CONTEXT, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTSetCharacteristicValue( + hDevice: HANDLE, + Characteristic: PBTH_LE_GATT_CHARACTERISTIC, + CharacteristicValue: PBTH_LE_GATT_CHARACTERISTIC_VALUE, + ReliableWriteContext: BTH_LE_GATT_RELIABLE_WRITE_CONTEXT, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTEndReliableWrite( + hDevice: HANDLE, + ReliableWriteContext: BTH_LE_GATT_RELIABLE_WRITE_CONTEXT, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTAbortReliableWrite( + hDevice: HANDLE, + ReliableWriteContext: BTH_LE_GATT_RELIABLE_WRITE_CONTEXT, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTSetDescriptorValue( + hDevice: HANDLE, + Descriptor: PBTH_LE_GATT_DESCRIPTOR, + DescriptorValue: PBTH_LE_GATT_DESCRIPTOR_VALUE, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTRegisterEvent( + hService: HANDLE, + EventType: BTH_LE_GATT_EVENT_TYPE, + EventParameterIn: PVOID, + Callback: PFNBLUETOOTH_GATT_EVENT_CALLBACK, + CallbackContext: PVOID, + pEventHandle: *mut BLUETOOTH_GATT_EVENT_HANDLE, + Flags: ULONG, + ) -> HRESULT; + pub fn BluetoothGATTUnregisterEvent( + EventHandle: BLUETOOTH_GATT_EVENT_HANDLE, + Flags: ULONG, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/bthledef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/bthledef.rs new file mode 100644 index 0000000..ca97c32 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/bthledef.rs @@ -0,0 +1,280 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::ULONG64; +use shared::guiddef::{GUID, IsEqualGUID}; +use shared::minwindef::{UCHAR, ULONG, USHORT}; +use um::winnt::{BOOLEAN, HANDLE, PVOID}; +DEFINE_GUID!{GUID_BLUETOOTHLE_DEVICE_INTERFACE, + 0x781aee18, 0x7733, 0x4ce4, 0xad, 0xd0, 0x91, 0xf4, 0x1c, 0x67, 0xb5, 0x92} +DEFINE_GUID!{GUID_BLUETOOTH_GATT_SERVICE_DEVICE_INTERFACE, + 0x6e3bb679, 0x4372, 0x40c8, 0x9e, 0xaa, 0x45, 0x09, 0xdf, 0x26, 0x0c, 0xd8} +DEFINE_GUID!{BTH_LE_ATT_BLUETOOTH_BASE_GUID, + 0x00000000, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB} +pub const BTH_LE_SERVICE_GAP: USHORT = 0x1800; +pub const BTH_LE_SERVICE_GATT: USHORT = 0x1801; +pub const BTH_LE_GATT_ATTRIBUTE_TYPE_PRIMARY_SERVICE: USHORT = 0x2800; +pub const BTH_LE_GATT_ATTRIBUTE_TYPE_SECONDARY_SERVICE: USHORT = 0x2801; +pub const BTH_LE_GATT_ATTRIBUTE_TYPE_INCLUDE: USHORT = 0x2802; +pub const BTH_LE_GATT_ATTRIBUTE_TYPE_CHARACTERISTIC: USHORT = 0x2803; +pub const BTH_LE_GATT_CHARACTERISTIC_DESCRIPTOR_EXTENDED_PROPERTIES: USHORT = 0x2900; +pub const BTH_LE_GATT_CHARACTERISTIC_DESCRIPTOR_USER_DESCRIPTION: USHORT = 0x2901; +pub const BTH_LE_GATT_CHARACTERISTIC_DESCRIPTOR_CLIENT_CONFIGURATION: USHORT = 0x2902; +pub const BTH_LE_GATT_CHARACTERISTIC_DESCRIPTOR_SERVER_CONFIGURATION: USHORT = 0x2903; +pub const BTH_LE_GATT_CHARACTERISTIC_DESCRIPTOR_FORMAT: USHORT = 0x2904; +pub const BTH_LE_GATT_CHARACTERISTIC_DESCRIPTOR_AGGREGATE_FORMAT: USHORT = 0x2905; +pub const BTH_LE_GATT_CHARACTERISTIC_TYPE_DEVICE_NAME: USHORT = 0x2A00; +pub const BTH_LE_GATT_CHARACTERISTIC_TYPE_APPEARANCE: USHORT = 0x2A01; +pub const BTH_LE_GATT_CHARACTERISTIC_TYPE_PERIPHERAL_PRIVACY_FLAG: USHORT = 0x2A02; +pub const BTH_LE_GATT_CHARACTERISTIC_TYPE_RECONNECTION_ADDRESS: USHORT = 0x2A03; +pub const BTH_LE_GATT_CHARACTERISTIC_TYPE_PERIPHERAL_PREFERED_CONNECTION_PARAMETER: USHORT + = 0x2A04; +pub const BTH_LE_GATT_CHARACTERISTIC_TYPE_SERVICE_CHANGED: USHORT = 0x2A05; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_OFFSET: u8 = 0x6; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_MASK: USHORT = 0x3ff; +#[inline] +pub fn BTH_LE_GAP_APPEARANCE_GET_CATEGORY(a: USHORT) -> USHORT { + (a >> BTH_LE_GAP_APPEARANCE_CATEGORY_OFFSET) & BTH_LE_GAP_APPEARANCE_CATEGORY_MASK +} +#[inline] +pub fn BTH_LE_GAP_APPEARANCE_SET_CATEGORY(a: &mut USHORT, c: USHORT) { + *a = (*a & !BTH_LE_GAP_APPEARANCE_CATEGORY_MASK) + | (c << BTH_LE_GAP_APPEARANCE_CATEGORY_OFFSET); +} +pub const BTH_LE_GAP_APPEARANCE_SUB_CATEGORY_MASK: USHORT = 0x3f; +#[inline] +pub fn BTH_LE_GAP_APPEARANCE_GET_SUB_CATEGORY(a: USHORT) -> UCHAR { + (a & BTH_LE_GAP_APPEARANCE_SUB_CATEGORY_MASK) as u8 +} +#[inline] +pub fn BTH_LE_GAP_APPEARANCE_SET_SUB_CATEGORY(a: &mut USHORT, s: UCHAR) { + *a = (*a & !BTH_LE_GAP_APPEARANCE_SUB_CATEGORY_MASK) | (s as u16); +} +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_UNCATEGORIZED: USHORT = 0x0000; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_PHONE: USHORT = 0x0001; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_COMPUTER: USHORT = 0x0002; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_WATCH: USHORT = 0x0003; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_CLOCK: USHORT = 0x0004; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_DISPLAY: USHORT = 0x0005; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_REMOTE_CONTROL: USHORT = 0x0006; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_EYE_GLASSES: USHORT = 0x0007; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_TAG: USHORT = 0x0008; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_KEYRING: USHORT = 0x0009; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_MEDIA_PLAYER: USHORT = 0x000a; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_BARCODE_SCANNER: USHORT = 0x000b; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_THERMOMETER: USHORT = 0x000c; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_HEART_RATE: USHORT = 0x000d; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_BLOOD_PRESSURE: USHORT = 0x000e; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_HID: USHORT = 0x000f; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_GLUCOSE_METER: USHORT = 0x0010; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_RUNNING_WALKING_SENSOR: USHORT = 0x0011; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_CYCLING: USHORT = 0x0012; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_PLUSE_OXIMETER: USHORT = 0x0031; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_WEIGHT_SCALE: USHORT = 0x0032; +pub const BTH_LE_GAP_APPEARANCE_CATEGORY_OUTDOOR_SPORTS_ACTIVITY: USHORT = 0x0051; +pub const BTH_LE_GAP_APPEARANCE_SUBCATEGORY_GENERIC: UCHAR = 0x00; +pub const BTH_LE_GAP_APPEARANCE_WATCH_SUBCATEGORY_SPORTS_WATCH: UCHAR = 0x01; +pub const BTH_LE_GAP_APPEARANCE_THERMOMETER_SUBCATEGORY_EAR: UCHAR = 0x01; +pub const BTH_LE_GAP_APPEARANCE_HEART_RATE_SUBCATEGORY_HEART_RATE_BELT: UCHAR = 0x01; +pub const BTH_LE_GAP_APPEARANCE_BLOOD_PRESSURE_SUBCATEGORY_ARM: UCHAR = 0x01; +pub const BTH_LE_GAP_APPEARANCE_BLOOD_PRESSURE_SUBCATEGORY_WRIST: UCHAR = 0x02; +pub const BTH_LE_GAP_APPEARANCE_HID_SUBCATEGORY_KEYBOARD: UCHAR = 0x01; +pub const BTH_LE_GAP_APPEARANCE_HID_SUBCATEGORY_MOUSE: UCHAR = 0x02; +pub const BTH_LE_GAP_APPEARANCE_HID_SUBCATEGORY_JOYSTICK: UCHAR = 0x03; +pub const BTH_LE_GAP_APPEARANCE_HID_SUBCATEGORY_GAMEPAD: UCHAR = 0x04; +pub const BTH_LE_GAP_APPEARANCE_HID_SUBCATEGORY_DIGITIZER_TABLET: UCHAR = 0x05; +pub const BTH_LE_GAP_APPEARANCE_HID_SUBCATEGORY_CARD_READER: UCHAR = 0x06; +pub const BTH_LE_GAP_APPEARANCE_HID_SUBCATEGORY_DIGITAL_PEN: UCHAR = 0x07; +pub const BTH_LE_GAP_APPEARANCE_HID_SUBCATEGORY_BARCODE_SCANNER: UCHAR = 0x08; +pub const BTH_LE_GAP_APPEARANCE_RUNNING_WALKING_SENSOR_SUBCATEGORY_IN_SHOE: UCHAR = 0x01; +pub const BTH_LE_GAP_APPEARANCE_RUNNING_WALKING_SENSOR_SUBCATEGORY_ON_SHOE: UCHAR = 0x02; +pub const BTH_LE_GAP_APPEARANCE_RUNNING_WALKING_SENSOR_SUBCATEGORY_ON_HIP: UCHAR = 0x03; +pub const BTH_LE_GAP_APPEARANCE_CYCLING_SUBCATEGORY_CYCLING_COMPUTER: UCHAR = 0x01; +pub const BTH_LE_GAP_APPEARANCE_CYCLING_SUBCATEGORY_SPEED_SENSOR: UCHAR = 0x02; +pub const BTH_LE_GAP_APPEARANCE_CYCLING_SUBCATEGORY_CADENCE_SENSOR: UCHAR = 0x03; +pub const BTH_LE_GAP_APPEARANCE_CYCLING_SUBCATEGORY_POWER_SENSOR: UCHAR = 0x04; +pub const BTH_LE_GAP_APPEARANCE_CYCLING_SUBCATEGORY_SPEED_AND_CADENCE_SENSOR: UCHAR = 0x05; +pub const BTH_LE_GAP_APPEARANCE_PULSE_OXIMETER_SUBCATEGORY_FINGERTIP: UCHAR = 0x01; +pub const BTH_LE_GAP_APPEARANCE_PULSE_OXIMETER_SUBCATEGORY_WRIST_WORN: UCHAR = 0x02; +pub const BTH_LE_GAP_APPEARANCE_OUTDOOR_SPORTS_ACTIVITY_SUBCATEGORY_LOCATION_DISPLAY_DEVICE: UCHAR + = 0x01; +pub const + BTH_LE_GAP_APPEARANCE_OUTDOOR_SPORTS_ACTIVITY_SUBCATEGORY_LOCATION_NAVIGATION_DISPLAY_DEVICE: + UCHAR = 0x02; +pub const BTH_LE_GAP_APPEARANCE_OUTDOOR_SPORTS_ACTIVITY_SUBCATEGORY_LOCATION_POD: UCHAR = 0x03; +pub const BTH_LE_GAP_APPEARANCE_OUTDOOR_SPORTS_ACTIVITY_SUBCATEGORY_LOCATION_NAVIGATION_POD: UCHAR + = 0x04; +pub const BTH_LE_GATT_DEFAULT_MAX_INCLUDED_SERVICES_DEPTH: USHORT = 3; +pub const BTH_LE_ATT_TRANSACTION_TIMEOUT: USHORT = 30; +pub const BTH_LE_ATT_MAX_VALUE_SIZE: USHORT = 512; +pub const BTH_LE_ATT_CID: USHORT = 0x0004; +pub const BTHLEENUM_ATT_MTU_MIN: USHORT = 23; +// #define BTHLEENUM_ATT_MTU_MAX (MAX_USHORT) +pub const BTHLEENUM_ATT_MTU_DEFAULT: USHORT = BTHLEENUM_ATT_MTU_MIN; +pub const BTHLEENUM_ATT_MTU_INITIAL_NEGOTIATION: USHORT = 525; +pub const BTH_LE_ERROR_INVALID_HANDLE: USHORT = 0x01; +pub const BTH_LE_ERROR_READ_NOT_PERMITTED: USHORT = 0x02; +pub const BTH_LE_ERROR_WRITE_NOT_PERMITTED: USHORT = 0x03; +pub const BTH_LE_ERROR_INVALID_PDU: USHORT = 0x04; +pub const BTH_LE_ERROR_INSUFFICIENT_AUTHENTICATION: USHORT = 0x05; +pub const BTH_LE_ERROR_REQUEST_NOT_SUPPORTED: USHORT = 0x06; +pub const BTH_LE_ERROR_INVALID_OFFSET: USHORT = 0x07; +pub const BTH_LE_ERROR_INSUFFICIENT_AUTHORIZATION: USHORT = 0x08; +pub const BTH_LE_ERROR_PREPARE_QUEUE_FULL: USHORT = 0x09; +pub const BTH_LE_ERROR_ATTRIBUTE_NOT_FOUND: USHORT = 0x0A; +pub const BTH_LE_ERROR_ATTRIBUTE_NOT_LONG: USHORT = 0x0B; +pub const BTH_LE_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE: USHORT = 0x0C; +pub const BTH_LE_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH: USHORT = 0x0D; +pub const BTH_LE_ERROR_UNLIKELY: USHORT = 0x0E; +pub const BTH_LE_ERROR_INSUFFICIENT_ENCRYPTION: USHORT = 0x0F; +pub const BTH_LE_ERROR_UNSUPPORTED_GROUP_TYPE: USHORT = 0x10; +pub const BTH_LE_ERROR_INSUFFICIENT_RESOURCES: USHORT = 0x11; +pub const BTH_LE_ERROR_UNKNOWN: USHORT = 0x1000; +pub const BLUETOOTH_GATT_FLAG_NONE: ULONG = 0x00000000; +pub const BLUETOOTH_GATT_FLAG_CONNECTION_ENCRYPTED: ULONG = 0x00000001; +pub const BLUETOOTH_GATT_FLAG_CONNECTION_AUTHENTICATED: ULONG = 0x00000002; +pub const BLUETOOTH_GATT_FLAG_FORCE_READ_FROM_DEVICE: ULONG = 0x00000004; +pub const BLUETOOTH_GATT_FLAG_FORCE_READ_FROM_CACHE: ULONG = 0x00000008; +pub const BLUETOOTH_GATT_FLAG_SIGNED_WRITE: ULONG = 0x00000010; +pub const BLUETOOTH_GATT_FLAG_WRITE_WITHOUT_RESPONSE: ULONG = 0x00000020; +pub const BLUETOOTH_GATT_FLAG_RETURN_ALL: ULONG = 0x00000040; +pub const BLUETOOTH_GATT_FLAG_VALID_MASK: ULONG = BLUETOOTH_GATT_FLAG_NONE + | BLUETOOTH_GATT_FLAG_CONNECTION_ENCRYPTED | BLUETOOTH_GATT_FLAG_CONNECTION_AUTHENTICATED + | BLUETOOTH_GATT_FLAG_FORCE_READ_FROM_DEVICE | BLUETOOTH_GATT_FLAG_FORCE_READ_FROM_CACHE + | BLUETOOTH_GATT_FLAG_SIGNED_WRITE | BLUETOOTH_GATT_FLAG_WRITE_WITHOUT_RESPONSE + | BLUETOOTH_GATT_FLAG_RETURN_ALL; +#[inline] +pub fn IS_BLUETOOTH_GATT_FLAG_VALID(f: ULONG) -> bool { + (f & !BLUETOOTH_GATT_FLAG_VALID_MASK) == 0 +} +pub type BLUETOOTH_GATT_EVENT_HANDLE = HANDLE; +UNION!{union BTH_LE_UUID_value { + [u32; 4], + ShortUuid ShortUuid_mut: USHORT, + LongUuid LongUuid_mut: GUID, +}} +STRUCT!{struct BTH_LE_UUID { + IsShortUuid: BOOLEAN, + Value: BTH_LE_UUID_value, +}} +pub type PBTH_LE_UUID = *mut BTH_LE_UUID; +STRUCT!{struct BTH_LE_GATT_SERVICE { + ServiceUuid: BTH_LE_UUID, + AttributeHandle: USHORT, +}} +pub type PBTH_LE_GATT_SERVICE = *mut BTH_LE_GATT_SERVICE; +ENUM!{enum BTH_LE_GATT_DESCRIPTOR_TYPE { + CharacteristicExtendedProperties, + CharacteristicUserDescription, + ClientCharacteristicConfiguration, + ServerCharacteristicConfiguration, + CharacteristicFormat, + CharacteristicAggregateFormat, + CustomDescriptor, +}} +pub type PBTH_LE_GATT_DESCRIPTOR_TYPE = *mut BTH_LE_GATT_DESCRIPTOR_TYPE; +STRUCT!{struct BTH_LE_GATT_CHARACTERISTIC { + ServiceHandle: USHORT, + CharacteristicUuid: BTH_LE_UUID, + AttributeHandle: USHORT, + CharacteristicValueHandle: USHORT, + IsBroadcastable: BOOLEAN, + IsReadable: BOOLEAN, + IsWritable: BOOLEAN, + IsWritableWithoutResponse: BOOLEAN, + IsSignedWritable: BOOLEAN, + IsNotifiable: BOOLEAN, + IsIndicatable: BOOLEAN, + HasExtendedProperties: BOOLEAN, +}} +pub type PBTH_LE_GATT_CHARACTERISTIC = *mut BTH_LE_GATT_CHARACTERISTIC; +STRUCT!{struct BTH_LE_GATT_CHARACTERISTIC_VALUE { + DataSize: ULONG, + Data: [UCHAR; 1], +}} +pub type PBTH_LE_GATT_CHARACTERISTIC_VALUE = *mut BTH_LE_GATT_CHARACTERISTIC_VALUE; +STRUCT!{struct BTH_LE_GATT_DESCRIPTOR { + ServiceHandle: USHORT, + CharacteristicHandle: USHORT, + DescriptorType: BTH_LE_GATT_DESCRIPTOR_TYPE, + DescriptorUuid: BTH_LE_UUID, + AttributeHandle: USHORT, +}} +pub type PBTH_LE_GATT_DESCRIPTOR = *mut BTH_LE_GATT_DESCRIPTOR; +STRUCT!{struct BTH_LE_GATT_DESCRIPTOR_VALUE_u_CharacteristicExtendedProperties { + IsReliableWriteEnabled: BOOLEAN, + IsAuxiliariesWritable: BOOLEAN, +}} +STRUCT!{struct BTH_LE_GATT_DESCRIPTOR_VALUE_u_ClientCharacteristicConfiguration { + IsSubscribeToNotification: BOOLEAN, + IsSubscribeToIndication: BOOLEAN, +}} +STRUCT!{struct BTH_LE_GATT_DESCRIPTOR_VALUE_u_ServerCharacteristicConfiguration { + IsBroadcast: BOOLEAN, +}} +STRUCT!{struct BTH_LE_GATT_DESCRIPTOR_VALUE_u_CharacteristicFormat { + Format: UCHAR, + Exponent: UCHAR, + Unit: BTH_LE_UUID, + NameSpace: UCHAR, + Description: BTH_LE_UUID, +}} +UNION!{union BTH_LE_GATT_DESCRIPTOR_VALUE_u { + [u32; 12], + CharacteristicExtendedProperties CharacteristicExtendedProperties_mut: + BTH_LE_GATT_DESCRIPTOR_VALUE_u_CharacteristicExtendedProperties, + ClientCharacteristicConfiguration ClientCharacteristicConfiguration_mut: + BTH_LE_GATT_DESCRIPTOR_VALUE_u_ClientCharacteristicConfiguration, + ServerCharacteristicConfiguration ServerCharacteristicConfiguration_mut: + BTH_LE_GATT_DESCRIPTOR_VALUE_u_ServerCharacteristicConfiguration, + CharacteristicFormat CharacteristicFormat_mut: + BTH_LE_GATT_DESCRIPTOR_VALUE_u_CharacteristicFormat, +}} +STRUCT!{struct BTH_LE_GATT_DESCRIPTOR_VALUE { + DescriptorType: BTH_LE_GATT_DESCRIPTOR_TYPE, + DescriptorUuid: BTH_LE_UUID, + u: BTH_LE_GATT_DESCRIPTOR_VALUE_u, + DataSize: ULONG, + Data: [UCHAR; 1], +}} +pub type PBTH_LE_GATT_DESCRIPTOR_VALUE = *mut BTH_LE_GATT_DESCRIPTOR_VALUE; +ENUM!{enum BTH_LE_GATT_EVENT_TYPE { + CharacteristicValueChangedEvent, +}} +FN!{stdcall PFNBLUETOOTH_GATT_EVENT_CALLBACK( + EventType: BTH_LE_GATT_EVENT_TYPE, + EventOutParameter: PVOID, + Context: PVOID, +) -> ()} +STRUCT!{struct BLUETOOTH_GATT_VALUE_CHANGED_EVENT_REGISTRATION { + NumCharacteristics: USHORT, + Characteristics: [BTH_LE_GATT_CHARACTERISTIC; 1], +}} +pub type PBLUETOOTH_GATT_VALUE_CHANGED_EVENT_REGISTRATION + = *mut BLUETOOTH_GATT_VALUE_CHANGED_EVENT_REGISTRATION; +STRUCT!{struct BLUETOOTH_GATT_VALUE_CHANGED_EVENT { + ChangedAttributeHandle: USHORT, + CharacteristicValueDataSize: usize, + CharacteristicValue: PBTH_LE_GATT_CHARACTERISTIC_VALUE, +}} +pub type PBLUETOOTH_GATT_VALUE_CHANGED_EVENT = *mut BLUETOOTH_GATT_VALUE_CHANGED_EVENT; +pub type BTH_LE_GATT_RELIABLE_WRITE_CONTEXT = ULONG64; +pub type PBTH_LE_GATT_RELIABLE_WRITE_CONTEXT = *mut ULONG64; +#[inline] +pub fn IsBthLEUuidMatch(uuid1: &BTH_LE_UUID, uuid2: &BTH_LE_UUID) -> bool { + fn is_bluetooth_le_uuid(uuid: &GUID) -> bool { + uuid.Data2 == BTH_LE_ATT_BLUETOOTH_BASE_GUID.Data2 + && uuid.Data3 == BTH_LE_ATT_BLUETOOTH_BASE_GUID.Data3 + && uuid.Data4 == BTH_LE_ATT_BLUETOOTH_BASE_GUID.Data4 + } + unsafe { match (uuid1.IsShortUuid != 0, uuid2.IsShortUuid != 0) { + (true, true) => uuid1.Value.ShortUuid() == uuid2.Value.ShortUuid(), + (false, false) => IsEqualGUID(uuid1.Value.LongUuid(), uuid2.Value.LongUuid()), + (true, false) => is_bluetooth_le_uuid(uuid2.Value.LongUuid()) + && ((*uuid1.Value.ShortUuid()) as u32) == uuid2.Value.LongUuid().Data1, + (false, true) => is_bluetooth_le_uuid(uuid1.Value.LongUuid()) + && ((*uuid2.Value.ShortUuid()) as u32) == uuid1.Value.LongUuid().Data1, + }} +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/cfgmgr32.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/cfgmgr32.rs new file mode 100644 index 0000000..2c4c7f3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/cfgmgr32.rs @@ -0,0 +1,2077 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! user APIs for the Configuration Manager +use shared::basetsd::{DWORD_PTR, ULONG32, ULONG64, ULONG_PTR}; +use shared::cfg::PPNP_VETO_TYPE; +use shared::devpropdef::{DEVPROPKEY, DEVPROPTYPE}; +use shared::guiddef::{GUID, LPGUID}; +use shared::minwindef::{BOOL, BYTE, DWORD, MAX_PATH, PBOOL, PBYTE, PHKEY, PULONG, ULONG, WORD}; +use um::winnt::{ + ANYSIZE_ARRAY, CHAR, DWORDLONG, HANDLE, LARGE_INTEGER, LONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, + PCHAR, PCSTR, PCWSTR, PDWORDLONG, PSTR, PVOID, PWCHAR, PWSTR, ULONGLONG, VOID, WCHAR +}; +use um::winreg::REGSAM; +pub type PCVOID = *const VOID; +pub const MAX_DEVICE_ID_LEN: usize = 200; +pub const MAX_DEVNODE_ID_LEN: usize = MAX_DEVICE_ID_LEN; +pub const MAX_GUID_STRING_LEN: usize = 39; +pub const MAX_CLASS_NAME_LEN: usize = 32; +pub const MAX_PROFILE_LEN: usize = 80; +pub const MAX_CONFIG_VALUE: DWORD = 9999; +pub const MAX_INSTANCE_VALUE: DWORD = 9999; +pub const MAX_MEM_REGISTERS: DWORD = 9; +pub const MAX_IO_PORTS: DWORD = 20; +pub const MAX_IRQS: DWORD = 7; +pub const MAX_DMA_CHANNELS: DWORD = 7; +pub const DWORD_MAX: DWORD = 0xffffffff; +pub const DWORDLONG_MAX: DWORDLONG = 0xffffffffffffffff; +pub const CONFIGMG_VERSION: DWORD = 0x0400; +pub type RETURN_TYPE = DWORD; +pub type CONFIGRET = RETURN_TYPE; +pub type DEVNODE = DWORD; +pub type DEVINST = DWORD; +pub type PDEVNODE = *mut DEVNODE; +pub type PDEVINST = *mut DEVNODE; +pub type DEVNODEID_A = *mut CHAR; +pub type DEVINSTID_A = *mut CHAR; +pub type DEVNODEID_W = *mut WCHAR; +pub type DEVINSTID_W = *mut WCHAR; +pub type LOG_CONF = DWORD_PTR; +pub type PLOG_CONF = *mut LOG_CONF; +pub type RES_DES = DWORD_PTR; +pub type PRES_DES = *mut RES_DES; +pub type RESOURCEID = ULONG; +pub type PRESOURCEID = *mut RESOURCEID; +pub type PRIORITY = ULONG; +pub type PPRIORITY = *mut PRIORITY; +pub type RANGE_LIST = DWORD_PTR; +pub type PRANGE_LIST = *mut RANGE_LIST; +pub type RANGE_ELEMENT = DWORD_PTR; +pub type PRANGE_ELEMENT = *mut RANGE_ELEMENT; +pub type HMACHINE = HANDLE; +pub type PHMACHINE = *mut HMACHINE; +pub type CONFLICT_LIST = ULONG_PTR; +pub type PCONFLICT_LIST = *mut CONFLICT_LIST; +STRUCT!{struct CONFLICT_DETAILS_A { + CD_ulSize: ULONG, + CD_ulMask: ULONG, + CD_dnDevInst: DEVINST, + CD_rdResDes: RES_DES, + CD_ulFlags: ULONG, + CD_szDescription: [CHAR; MAX_PATH], +}} +pub type PCONFLICT_DETAILS_A = *mut CONFLICT_DETAILS_A; +STRUCT!{struct CONFLICT_DETAILS_W { + CD_ulSize: ULONG, + CD_ulMask: ULONG, + CD_dnDevInst: DEVINST, + CD_rdResDes: RES_DES, + CD_ulFlags: ULONG, + CD_szDescription: [WCHAR; MAX_PATH], +}} +pub type PCONFLICT_DETAILS_W = *mut CONFLICT_DETAILS_W; +pub const CM_CDMASK_DEVINST: ULONG = 0x00000001; +pub const CM_CDMASK_RESDES: ULONG = 0x00000002; +pub const CM_CDMASK_FLAGS: ULONG = 0x00000004; +pub const CM_CDMASK_DESCRIPTION: ULONG = 0x00000008; +pub const CM_CDMASK_VALID: ULONG = 0x0000000F; +pub const CM_CDFLAGS_DRIVER: ULONG = 0x00000001; +pub const CM_CDFLAGS_ROOT_OWNED: ULONG = 0x00000002; +pub const CM_CDFLAGS_RESERVED: ULONG = 0x00000004; +pub type REGDISPOSITION = ULONG; +pub const mMD_MemoryType: DWORD = 0x1; +pub const fMD_MemoryType: DWORD = mMD_MemoryType; +pub const fMD_ROM: DWORD = 0x0; +pub const fMD_RAM: DWORD = 0x1; +pub const mMD_32_24: DWORD = 0x2; +pub const fMD_32_24: DWORD = mMD_32_24; +pub const fMD_24: DWORD = 0x0; +pub const fMD_32: DWORD = 0x2; +pub const mMD_Prefetchable: DWORD = 0x4; +pub const fMD_Prefetchable: DWORD = mMD_Prefetchable; +pub const fMD_Pref: DWORD = mMD_Prefetchable; +pub const fMD_PrefetchDisallowed: DWORD = 0x0; +pub const fMD_PrefetchAllowed: DWORD = 0x4; +pub const mMD_Readable: DWORD = 0x8; +pub const fMD_Readable: DWORD = mMD_Readable; +pub const fMD_ReadAllowed: DWORD = 0x0; +pub const fMD_ReadDisallowed: DWORD = 0x8; +pub const mMD_CombinedWrite: DWORD = 0x10; +pub const fMD_CombinedWrite: DWORD = mMD_CombinedWrite; +pub const fMD_CombinedWriteDisallowed: DWORD = 0x0; +pub const fMD_CombinedWriteAllowed: DWORD = 0x10; +pub const mMD_Cacheable: DWORD = 0x20; +pub const fMD_NonCacheable: DWORD = 0x0; +pub const fMD_Cacheable: DWORD = 0x20; +pub const fMD_WINDOW_DECODE: DWORD = 0x40; +pub const fMD_MEMORY_BAR: DWORD = 0x80; +STRUCT!{#[repr(packed)] struct MEM_RANGE { + MR_Align: DWORDLONG, + MR_nBytes: ULONG, + MR_Min: DWORDLONG, + MR_Max: DWORDLONG, + MR_Flags: DWORD, + MR_Reserved: DWORD, +}} +pub type PMEM_RANGE = *mut MEM_RANGE; +STRUCT!{#[repr(packed)] struct MEM_DES { + MD_Count: DWORD, + MD_Type: DWORD, + MD_Alloc_Base: DWORDLONG, + MD_Alloc_End: DWORDLONG, + MD_Flags: DWORD, + MD_Reserved: DWORD, +}} +pub type PMEM_DES = *mut MEM_DES; +STRUCT!{#[repr(packed)] struct MEM_RESOURCE { + MEM_Header: MEM_DES, + MEM_Data: [MEM_RANGE; ANYSIZE_ARRAY], +}} +pub type PMEM_RESOURCE = *mut MEM_RESOURCE; +STRUCT!{#[repr(packed)] struct MEM_LARGE_RANGE { + MLR_Align: DWORDLONG, + MLR_nBytes: ULONGLONG, + MLR_Min: DWORDLONG, + MLR_Max: DWORDLONG, + MLR_Flags: DWORD, + MLR_Reserved: DWORD, +}} +pub type PMEM_LARGE_RANGE = *mut MEM_LARGE_RANGE; +STRUCT!{#[repr(packed)] struct MEM_LARGE_DES { + MLD_Count: DWORD, + MLD_Type: DWORD, + MLD_Alloc_Base: DWORDLONG, + MLD_Alloc_End: DWORDLONG, + MLD_Flags: DWORD, + MLD_Reserved: DWORD, +}} +pub type PMEM_LARGE_DES = *mut MEM_LARGE_DES; +STRUCT!{#[repr(packed)] struct MEM_LARGE_RESOURCE { + MEM_LARGE_Header: MEM_LARGE_DES, + MEM_LARGE_Data: [MEM_LARGE_RANGE; ANYSIZE_ARRAY], +}} +pub type PMEM_LARGE_RESOURCE = *mut MEM_LARGE_RESOURCE; +pub const fIOD_PortType: DWORD = 0x1; +pub const fIOD_Memory: DWORD = 0x0; +pub const fIOD_IO: DWORD = 0x1; +pub const fIOD_DECODE: DWORD = 0x00fc; +pub const fIOD_10_BIT_DECODE: DWORD = 0x0004; +pub const fIOD_12_BIT_DECODE: DWORD = 0x0008; +pub const fIOD_16_BIT_DECODE: DWORD = 0x0010; +pub const fIOD_POSITIVE_DECODE: DWORD = 0x0020; +pub const fIOD_PASSIVE_DECODE: DWORD = 0x0040; +pub const fIOD_WINDOW_DECODE: DWORD = 0x0080; +pub const fIOD_PORT_BAR: DWORD = 0x0100; +pub const IO_ALIAS_10_BIT_DECODE: DWORDLONG = 0x00000004; +pub const IO_ALIAS_12_BIT_DECODE: DWORDLONG = 0x00000010; +pub const IO_ALIAS_16_BIT_DECODE: DWORDLONG = 0x00000000; +pub const IO_ALIAS_POSITIVE_DECODE: DWORDLONG = 0x000000FF; +STRUCT!{#[repr(packed)] struct IO_RANGE { + IOR_Align: DWORDLONG, + IOR_nPorts: DWORD, + IOR_Min: DWORDLONG, + IOR_Max: DWORDLONG, + IOR_RangeFlags: DWORD, + IOR_Alias: DWORDLONG, +}} +pub type PIO_RANGE = *mut IO_RANGE; +STRUCT!{#[repr(packed)] struct IO_DES { + IOD_Count: DWORD, + IOD_Type: DWORD, + IOD_Alloc_Base: DWORDLONG, + IOD_Alloc_End: DWORDLONG, + IOD_DesFlags: DWORD, +}} +pub type PIO_DES = *mut IO_DES; +STRUCT!{#[repr(packed)] struct IO_RESOURCE { + IO_Header: IO_DES, + IO_Data: [IO_RANGE; ANYSIZE_ARRAY], +}} +pub type PIO_RESOURCE = *mut IO_RESOURCE; +pub const mDD_Width: ULONG = 0x3; +pub const fDD_BYTE: ULONG = 0x0; +pub const fDD_WORD: ULONG = 0x1; +pub const fDD_DWORD: ULONG = 0x2; +pub const fDD_BYTE_AND_WORD: ULONG = 0x3; +pub const mDD_BusMaster: ULONG = 0x4; +pub const fDD_NoBusMaster: ULONG = 0x0; +pub const fDD_BusMaster: ULONG = 0x4; +pub const mDD_Type: ULONG = 0x18; +pub const fDD_TypeStandard: ULONG = 0x00; +pub const fDD_TypeA: ULONG = 0x08; +pub const fDD_TypeB: ULONG = 0x10; +pub const fDD_TypeF: ULONG = 0x18; +STRUCT!{#[repr(packed)] struct DMA_RANGE { + DR_Min: ULONG, + DR_Max: ULONG, + DR_Flags: ULONG, +}} +pub type PDMA_RANGE = *mut DMA_RANGE; +STRUCT!{#[repr(packed)] struct DMA_DES { + DD_Count: DWORD, + DD_Type: DWORD, + DD_Flags: DWORD, + DD_Alloc_Chan: ULONG, +}} +pub type PDMA_DES = *mut DMA_DES; +STRUCT!{#[repr(packed)] struct DMA_RESOURCE { + DMA_Header: DMA_DES, + DMA_Data: [DMA_RANGE; ANYSIZE_ARRAY], +}} +pub type PDMA_RESOURCE = *mut DMA_RESOURCE; +pub const mIRQD_Share: ULONG = 0x1; +pub const fIRQD_Exclusive: ULONG = 0x0; +pub const fIRQD_Share: ULONG = 0x1; +pub const fIRQD_Share_Bit: ULONG = 0; +pub const fIRQD_Level_Bit: ULONG = 1; +pub const mIRQD_Edge_Level: ULONG = 0x2; +pub const fIRQD_Level: ULONG = 0x0; +pub const fIRQD_Edge: ULONG = 0x2; +STRUCT!{#[repr(packed)] struct IRQ_RANGE { + IRQR_Min: ULONG, + IRQR_Max: ULONG, + IRQR_Flags: ULONG, +}} +pub type PIRQ_RANGE = *mut IRQ_RANGE; +STRUCT!{#[repr(packed)] struct IRQ_DES_32 { + IRQD_Count: DWORD, + IRQD_Type: DWORD, + IRQD_Flags: DWORD, + IRQD_Alloc_Num: ULONG, + IRQD_Affinity: ULONG32, +}} +pub type PIRQ_DES_32 = *mut IRQ_DES_32; +STRUCT!{#[repr(packed)] struct IRQ_DES_64 { + IRQD_Count: DWORD, + IRQD_Type: DWORD, + IRQD_Flags: DWORD, + IRQD_Alloc_Num: ULONG, + IRQD_Affinity: ULONG64, +}} +pub type PIRQ_DES_64 = *mut IRQ_DES_64; +STRUCT!{#[repr(packed)] struct IRQ_RESOURCE_32 { + IRQ_Header: IRQ_DES_32, + IRQ_Data: [IRQ_RANGE; ANYSIZE_ARRAY], +}} +pub type PIRQ_RESOURCE_32 = *mut IRQ_RESOURCE_32; +STRUCT!{#[repr(packed)] struct IRQ_RESOURCE_64 { + IRQ_Header: IRQ_DES_64, + IRQ_Data: [IRQ_RANGE; ANYSIZE_ARRAY], +}} +pub type PIRQ_RESOURCE_64 = *mut IRQ_RESOURCE_64; +STRUCT!{#[repr(packed)] struct DEVPRIVATE_RANGE { + PR_Data1: DWORD, + PR_Data2: DWORD, + PR_Data3: DWORD, +}} +pub type PDEVPRIVATE_RANGE = *mut DEVPRIVATE_RANGE; +STRUCT!{#[repr(packed)] struct DEVPRIVATE_DES { + PD_Count: DWORD, + PD_Type: DWORD, + PD_Data1: DWORD, + PD_Data2: DWORD, + PD_Data3: DWORD, + PD_Flags: DWORD, +}} +pub type PDEVPRIVATE_DES = *mut DEVPRIVATE_DES; +STRUCT!{#[repr(packed)] struct DEVPRIVATE_RESOURCE { + PRV_Header: DEVPRIVATE_DES, + PRV_Data: [DEVPRIVATE_RANGE; ANYSIZE_ARRAY], +}} +pub type PDEVPRIVATE_RESOURCE = *mut DEVPRIVATE_RESOURCE; +STRUCT!{#[repr(packed)] struct CS_DES { + CSD_SignatureLength: DWORD, + CSD_LegacyDataOffset: DWORD, + CSD_LegacyDataSize: DWORD, + CSD_Flags: DWORD, + CSD_ClassGuid: GUID, + CSD_Signature: [BYTE; ANYSIZE_ARRAY], +}} +pub type PCS_DES = *mut CS_DES; +STRUCT!{#[repr(packed)] struct CS_RESOURCE { + CS_Header: CS_DES, +}} +pub type PCS_RESOURCE = *mut CS_RESOURCE; +pub const mPCD_IO_8_16: DWORD = 0x1; +pub const fPCD_IO_8: DWORD = 0x0; +pub const fPCD_IO_16: DWORD = 0x1; +pub const mPCD_MEM_8_16: DWORD = 0x2; +pub const fPCD_MEM_8: DWORD = 0x0; +pub const fPCD_MEM_16: DWORD = 0x2; +pub const mPCD_MEM_A_C: DWORD = 0xC; +pub const fPCD_MEM1_A: DWORD = 0x4; +pub const fPCD_MEM2_A: DWORD = 0x8; +pub const fPCD_IO_ZW_8: DWORD = 0x10; +pub const fPCD_IO_SRC_16: DWORD = 0x20; +pub const fPCD_IO_WS_16: DWORD = 0x40; +pub const mPCD_MEM_WS: DWORD = 0x300; +pub const fPCD_MEM_WS_ONE: DWORD = 0x100; +pub const fPCD_MEM_WS_TWO: DWORD = 0x200; +pub const fPCD_MEM_WS_THREE: DWORD = 0x300; +pub const fPCD_MEM_A: DWORD = 0x4; +pub const fPCD_ATTRIBUTES_PER_WINDOW: DWORD = 0x8000; +pub const fPCD_IO1_16: DWORD = 0x00010000; +pub const fPCD_IO1_ZW_8: DWORD = 0x00020000; +pub const fPCD_IO1_SRC_16: DWORD = 0x00040000; +pub const fPCD_IO1_WS_16: DWORD = 0x00080000; +pub const fPCD_IO2_16: DWORD = 0x00100000; +pub const fPCD_IO2_ZW_8: DWORD = 0x00200000; +pub const fPCD_IO2_SRC_16: DWORD = 0x00400000; +pub const fPCD_IO2_WS_16: DWORD = 0x00800000; +pub const mPCD_MEM1_WS: DWORD = 0x03000000; +pub const fPCD_MEM1_WS_TWO: DWORD = 0x02000000; +pub const fPCD_MEM1_WS_THREE: DWORD = 0x03000000; +pub const fPCD_MEM1_16: DWORD = 0x04000000; +pub const mPCD_MEM2_WS: DWORD = 0x30000000; +pub const fPCD_MEM2_WS_ONE: DWORD = 0x10000000; +pub const fPCD_MEM2_WS_TWO: DWORD = 0x20000000; +pub const fPCD_MEM2_WS_THREE: DWORD = 0x30000000; +pub const fPCD_MEM2_16: DWORD = 0x40000000; +pub const PCD_MAX_MEMORY: usize = 2; +pub const PCD_MAX_IO: usize = 2; +STRUCT!{#[repr(packed)] struct PCCARD_DES { + PCD_Count: DWORD, + PCD_Type: DWORD, + PCD_Flags: DWORD, + PCD_ConfigIndex: BYTE, + PCD_Reserved: [BYTE; 3], + PCD_MemoryCardBase1: DWORD, + PCD_MemoryCardBase2: DWORD, + PCD_MemoryCardBase: [DWORD; PCD_MAX_MEMORY], + PCD_MemoryFlags: [WORD; PCD_MAX_MEMORY], + PCD_IoFlags: [BYTE; PCD_MAX_IO], +}} +pub type PPCCARD_DES = *mut PCCARD_DES; +STRUCT!{#[repr(packed)] struct PCCARD_RESOURCE { + PcCard_Header: PCCARD_DES, +}} +pub type PPCCARD_RESOURCE = *mut PCCARD_RESOURCE; +pub const mPMF_AUDIO_ENABLE: DWORD = 0x8; +pub const fPMF_AUDIO_ENABLE: DWORD = 0x8; +STRUCT!{#[repr(packed)] struct MFCARD_DES { + PMF_Count: DWORD, + PMF_Type: DWORD, + PMF_Flags: DWORD, + PMF_ConfigOptions: BYTE, + PMF_IoResourceIndex: BYTE, + PMF_Reserved: [BYTE; 2], + PMF_ConfigRegisterBase: DWORD, +}} +pub type PMFCARD_DES = *mut MFCARD_DES; +STRUCT!{#[repr(packed)] struct MFCARD_RESOURCE { + MfCard_Header: MFCARD_DES, +}} +pub type PMFCARD_RESOURCE = *mut MFCARD_RESOURCE; +STRUCT!{#[repr(packed)] struct BUSNUMBER_RANGE { + BUSR_Min: ULONG, + BUSR_Max: ULONG, + BUSR_nBusNumbers: ULONG, + BUSR_Flags: ULONG, +}} +pub type PBUSNUMBER_RANGE = *mut BUSNUMBER_RANGE; +STRUCT!{#[repr(packed)] struct BUSNUMBER_DES { + BUSD_Count: DWORD, + BUSD_Type: DWORD, + BUSD_Flags: DWORD, + BUSD_Alloc_Base: ULONG, + BUSD_Alloc_End: ULONG, +}} +pub type PBUSNUMBER_DES = *mut BUSNUMBER_DES; +STRUCT!{#[repr(packed)] struct BUSNUMBER_RESOURCE { + BusNumber_Header: BUSNUMBER_DES, + BusNumber_Data: [BUSNUMBER_RANGE; ANYSIZE_ARRAY], +}} +pub type PBUSNUMBER_RESOURCE = *mut BUSNUMBER_RESOURCE; +STRUCT!{#[repr(packed)] struct CONNECTION_DES { + COND_Type: DWORD, + COND_Flags: DWORD, + COND_Class: BYTE, + COND_ClassType: BYTE, + COND_Reserved1: BYTE, + COND_Reserved2: BYTE, + COND_Id: LARGE_INTEGER, +}} +pub type PCONNECTION_DES = *mut CONNECTION_DES; +STRUCT!{#[repr(packed)] struct CONNECTION_RESOURCE { + Connection_Header: CONNECTION_DES, +}} +pub type PCONNECTION_RESOURCE = *mut CONNECTION_RESOURCE; +pub const CM_HWPI_NOT_DOCKABLE: DWORD = 0x00000000; +pub const CM_HWPI_UNDOCKED: DWORD = 0x00000001; +pub const CM_HWPI_DOCKED: DWORD = 0x00000002; +STRUCT!{#[repr(packed)] struct HWPROFILEINFO_A { + HWPI_ulHWProfile: ULONG, + HWPI_szFriendlyName: [CHAR; MAX_PROFILE_LEN], + HWPI_dwFlags: DWORD, +}} +pub type PHWPROFILEINFO_A = *mut HWPROFILEINFO_A; +STRUCT!{#[repr(packed)] struct HWPROFILEINFO_W { + HWPI_ulHWProfile: ULONG, + HWPI_szFriendlyName: [WCHAR; MAX_PROFILE_LEN], + HWPI_dwFlags: DWORD, +}} +pub type PHWPROFILEINFO_W = *mut HWPROFILEINFO_W; +pub const ResType_All: RESOURCEID = 0x00000000; +pub const ResType_None: RESOURCEID = 0x00000000; +pub const ResType_Mem: RESOURCEID = 0x00000001; +pub const ResType_IO: RESOURCEID = 0x00000002; +pub const ResType_DMA: RESOURCEID = 0x00000003; +pub const ResType_IRQ: RESOURCEID = 0x00000004; +pub const ResType_DoNotUse: RESOURCEID = 0x00000005; +pub const ResType_BusNumber: RESOURCEID = 0x00000006; +pub const ResType_MemLarge: RESOURCEID = 0x00000007; +pub const ResType_MAX: RESOURCEID = 0x00000007; +pub const ResType_Ignored_Bit: RESOURCEID = 0x00008000; +pub const ResType_ClassSpecific: RESOURCEID = 0x0000FFFF; +pub const ResType_Reserved: RESOURCEID = 0x00008000; +pub const ResType_DevicePrivate: RESOURCEID = 0x00008001; +pub const ResType_PcCardConfig: RESOURCEID = 0x00008002; +pub const ResType_MfCardConfig: RESOURCEID = 0x00008003; +pub const ResType_Connection: RESOURCEID = 0x00008004; +pub const CM_ADD_RANGE_ADDIFCONFLICT: ULONG = 0x00000000; +pub const CM_ADD_RANGE_DONOTADDIFCONFLICT: ULONG = 0x00000001; +pub const CM_ADD_RANGE_BITS: ULONG = 0x00000001; +pub const BASIC_LOG_CONF: ULONG = 0x00000000; +pub const FILTERED_LOG_CONF: ULONG = 0x00000001; +pub const ALLOC_LOG_CONF: ULONG = 0x00000002; +pub const BOOT_LOG_CONF: ULONG = 0x00000003; +pub const FORCED_LOG_CONF: ULONG = 0x00000004; +pub const OVERRIDE_LOG_CONF: ULONG = 0x00000005; +pub const NUM_LOG_CONF: ULONG = 0x00000006; +pub const LOG_CONF_BITS: ULONG = 0x00000007; +pub const PRIORITY_EQUAL_FIRST: ULONG = 0x00000008; +pub const PRIORITY_EQUAL_LAST: ULONG = 0x00000000; +pub const PRIORITY_BIT: ULONG = 0x00000008; +pub const RegDisposition_OpenAlways: REGDISPOSITION = 0x00000000; +pub const RegDisposition_OpenExisting: REGDISPOSITION = 0x00000001; +pub const RegDisposition_Bits: REGDISPOSITION = 0x00000001; +pub const CM_ADD_ID_HARDWARE: ULONG = 0x00000000; +pub const CM_ADD_ID_COMPATIBLE: ULONG = 0x00000001; +pub const CM_ADD_ID_BITS: ULONG = 0x00000001; +pub const CM_CREATE_DEVNODE_NORMAL: ULONG = 0x00000000; +pub const CM_CREATE_DEVNODE_NO_WAIT_INSTALL: ULONG = 0x00000001; +pub const CM_CREATE_DEVNODE_PHANTOM: ULONG = 0x00000002; +pub const CM_CREATE_DEVNODE_GENERATE_ID: ULONG = 0x00000004; +pub const CM_CREATE_DEVNODE_DO_NOT_INSTALL: ULONG = 0x00000008; +pub const CM_CREATE_DEVNODE_BITS: ULONG = 0x0000000F; +pub const CM_CREATE_DEVINST_NORMAL: ULONG = CM_CREATE_DEVNODE_NORMAL; +pub const CM_CREATE_DEVINST_NO_WAIT_INSTALL: ULONG = CM_CREATE_DEVNODE_NO_WAIT_INSTALL; +pub const CM_CREATE_DEVINST_PHANTOM: ULONG = CM_CREATE_DEVNODE_PHANTOM; +pub const CM_CREATE_DEVINST_GENERATE_ID: ULONG = CM_CREATE_DEVNODE_GENERATE_ID; +pub const CM_CREATE_DEVINST_DO_NOT_INSTALL: ULONG = CM_CREATE_DEVNODE_DO_NOT_INSTALL; +pub const CM_CREATE_DEVINST_BITS: ULONG = CM_CREATE_DEVNODE_BITS; +pub const CM_DELETE_CLASS_ONLY: ULONG = 0x00000000; +pub const CM_DELETE_CLASS_SUBKEYS: ULONG = 0x00000001; +pub const CM_DELETE_CLASS_INTERFACE: ULONG = 0x00000002; +pub const CM_DELETE_CLASS_BITS: ULONG = 0x00000003; +pub const CM_ENUMERATE_CLASSES_INSTALLER: ULONG = 0x00000000; +pub const CM_ENUMERATE_CLASSES_INTERFACE: ULONG = 0x00000001; +pub const CM_ENUMERATE_CLASSES_BITS: ULONG = 0x00000001; +pub const CM_DETECT_NEW_PROFILE: ULONG = 0x00000001; +pub const CM_DETECT_CRASHED: ULONG = 0x00000002; +pub const CM_DETECT_HWPROF_FIRST_BOOT: ULONG = 0x00000004; +pub const CM_DETECT_RUN: ULONG = 0x80000000; +pub const CM_DETECT_BITS: ULONG = 0x80000007; +pub const CM_DISABLE_POLITE: ULONG = 0x00000000; +pub const CM_DISABLE_ABSOLUTE: ULONG = 0x00000001; +pub const CM_DISABLE_HARDWARE: ULONG = 0x00000002; +pub const CM_DISABLE_UI_NOT_OK: ULONG = 0x00000004; +pub const CM_DISABLE_BITS: ULONG = 0x00000007; +pub const CM_GETIDLIST_FILTER_NONE: ULONG = 0x00000000; +pub const CM_GETIDLIST_FILTER_ENUMERATOR: ULONG = 0x00000001; +pub const CM_GETIDLIST_FILTER_SERVICE: ULONG = 0x00000002; +pub const CM_GETIDLIST_FILTER_EJECTRELATIONS: ULONG = 0x00000004; +pub const CM_GETIDLIST_FILTER_REMOVALRELATIONS: ULONG = 0x00000008; +pub const CM_GETIDLIST_FILTER_POWERRELATIONS: ULONG = 0x00000010; +pub const CM_GETIDLIST_FILTER_BUSRELATIONS: ULONG = 0x00000020; +pub const CM_GETIDLIST_DONOTGENERATE: ULONG = 0x10000040; +pub const CM_GETIDLIST_FILTER_TRANSPORTRELATIONS: ULONG = 0x00000080; +pub const CM_GETIDLIST_FILTER_PRESENT: ULONG = 0x00000100; +pub const CM_GETIDLIST_FILTER_CLASS: ULONG = 0x00000200; +pub const CM_GETIDLIST_FILTER_BITS: ULONG = 0x100003FF; +pub const CM_GET_DEVICE_INTERFACE_LIST_PRESENT: ULONG = 0x00000000; +pub const CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES: ULONG = 0x00000001; +pub const CM_GET_DEVICE_INTERFACE_LIST_BITS: ULONG = 0x00000001; +pub const CM_DRP_DEVICEDESC: ULONG = 0x00000001; +pub const CM_DRP_HARDWAREID: ULONG = 0x00000002; +pub const CM_DRP_COMPATIBLEIDS: ULONG = 0x00000003; +pub const CM_DRP_UNUSED0: ULONG = 0x00000004; +pub const CM_DRP_SERVICE: ULONG = 0x00000005; +pub const CM_DRP_UNUSED1: ULONG = 0x00000006; +pub const CM_DRP_UNUSED2: ULONG = 0x00000007; +pub const CM_DRP_CLASS: ULONG = 0x00000008; +pub const CM_DRP_CLASSGUID: ULONG = 0x00000009; +pub const CM_DRP_DRIVER: ULONG = 0x0000000A; +pub const CM_DRP_CONFIGFLAGS: ULONG = 0x0000000B; +pub const CM_DRP_MFG: ULONG = 0x0000000C; +pub const CM_DRP_FRIENDLYNAME: ULONG = 0x0000000D; +pub const CM_DRP_LOCATION_INFORMATION: ULONG = 0x0000000E; +pub const CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME: ULONG = 0x0000000F; +pub const CM_DRP_CAPABILITIES: ULONG = 0x00000010; +pub const CM_DRP_UI_NUMBER: ULONG = 0x00000011; +pub const CM_DRP_UPPERFILTERS: ULONG = 0x00000012; +pub const CM_CRP_UPPERFILTERS: ULONG = CM_DRP_UPPERFILTERS; +pub const CM_DRP_LOWERFILTERS: ULONG = 0x00000013; +pub const CM_CRP_LOWERFILTERS: ULONG = CM_DRP_LOWERFILTERS; +pub const CM_DRP_BUSTYPEGUID: ULONG = 0x00000014; +pub const CM_DRP_LEGACYBUSTYPE: ULONG = 0x00000015; +pub const CM_DRP_BUSNUMBER: ULONG = 0x00000016; +pub const CM_DRP_ENUMERATOR_NAME: ULONG = 0x00000017; +pub const CM_DRP_SECURITY: ULONG = 0x00000018; +pub const CM_CRP_SECURITY: ULONG = CM_DRP_SECURITY; +pub const CM_DRP_SECURITY_SDS: ULONG = 0x00000019; +pub const CM_CRP_SECURITY_SDS: ULONG = CM_DRP_SECURITY_SDS; +pub const CM_DRP_DEVTYPE: ULONG = 0x0000001A; +pub const CM_CRP_DEVTYPE: ULONG = CM_DRP_DEVTYPE; +pub const CM_DRP_EXCLUSIVE: ULONG = 0x0000001B; +pub const CM_CRP_EXCLUSIVE: ULONG = CM_DRP_EXCLUSIVE; +pub const CM_DRP_CHARACTERISTICS: ULONG = 0x0000001C; +pub const CM_CRP_CHARACTERISTICS: ULONG = CM_DRP_CHARACTERISTICS; +pub const CM_DRP_ADDRESS: ULONG = 0x0000001D; +pub const CM_DRP_UI_NUMBER_DESC_FORMAT: ULONG = 0x0000001E; +pub const CM_DRP_DEVICE_POWER_DATA: ULONG = 0x0000001F; +pub const CM_DRP_REMOVAL_POLICY: ULONG = 0x00000020; +pub const CM_DRP_REMOVAL_POLICY_HW_DEFAULT: ULONG = 0x00000021; +pub const CM_DRP_REMOVAL_POLICY_OVERRIDE: ULONG = 0x00000022; +pub const CM_DRP_INSTALL_STATE: ULONG = 0x00000023; +pub const CM_DRP_LOCATION_PATHS: ULONG = 0x00000024; +pub const CM_DRP_BASE_CONTAINERID: ULONG = 0x00000025; +pub const CM_DRP_MIN: ULONG = 0x00000001; +pub const CM_CRP_MIN: ULONG = CM_DRP_MIN; +pub const CM_DRP_MAX: ULONG = 0x00000025; +pub const CM_CRP_MAX: ULONG = CM_DRP_MAX; +pub const CM_DEVCAP_LOCKSUPPORTED: ULONG = 0x00000001; +pub const CM_DEVCAP_EJECTSUPPORTED: ULONG = 0x00000002; +pub const CM_DEVCAP_REMOVABLE: ULONG = 0x00000004; +pub const CM_DEVCAP_DOCKDEVICE: ULONG = 0x00000008; +pub const CM_DEVCAP_UNIQUEID: ULONG = 0x00000010; +pub const CM_DEVCAP_SILENTINSTALL: ULONG = 0x00000020; +pub const CM_DEVCAP_RAWDEVICEOK: ULONG = 0x00000040; +pub const CM_DEVCAP_SURPRISEREMOVALOK: ULONG = 0x00000080; +pub const CM_DEVCAP_HARDWAREDISABLED: ULONG = 0x00000100; +pub const CM_DEVCAP_NONDYNAMIC: ULONG = 0x00000200; +pub const CM_REMOVAL_POLICY_EXPECT_NO_REMOVAL: ULONG = 1; +pub const CM_REMOVAL_POLICY_EXPECT_ORDERLY_REMOVAL: ULONG = 2; +pub const CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL: ULONG = 3; +pub const CM_INSTALL_STATE_INSTALLED: ULONG = 0; +pub const CM_INSTALL_STATE_NEEDS_REINSTALL: ULONG = 1; +pub const CM_INSTALL_STATE_FAILED_INSTALL: ULONG = 2; +pub const CM_INSTALL_STATE_FINISH_INSTALL: ULONG = 3; +pub const CM_LOCATE_DEVNODE_NORMAL: ULONG = 0x00000000; +pub const CM_LOCATE_DEVNODE_PHANTOM: ULONG = 0x00000001; +pub const CM_LOCATE_DEVNODE_CANCELREMOVE: ULONG = 0x00000002; +pub const CM_LOCATE_DEVNODE_NOVALIDATION: ULONG = 0x00000004; +pub const CM_LOCATE_DEVNODE_BITS: ULONG = 0x00000007; +pub const CM_LOCATE_DEVINST_NORMAL: ULONG = CM_LOCATE_DEVNODE_NORMAL; +pub const CM_LOCATE_DEVINST_PHANTOM: ULONG = CM_LOCATE_DEVNODE_PHANTOM; +pub const CM_LOCATE_DEVINST_CANCELREMOVE: ULONG = CM_LOCATE_DEVNODE_CANCELREMOVE; +pub const CM_LOCATE_DEVINST_NOVALIDATION: ULONG = CM_LOCATE_DEVNODE_NOVALIDATION; +pub const CM_LOCATE_DEVINST_BITS: ULONG = CM_LOCATE_DEVNODE_BITS; +pub const CM_OPEN_CLASS_KEY_INSTALLER: ULONG = 0x00000000; +pub const CM_OPEN_CLASS_KEY_INTERFACE: ULONG = 0x00000001; +pub const CM_OPEN_CLASS_KEY_BITS: ULONG = 0x00000001; +pub const CM_REMOVE_UI_OK: ULONG = 0x00000000; +pub const CM_REMOVE_UI_NOT_OK: ULONG = 0x00000001; +pub const CM_REMOVE_NO_RESTART: ULONG = 0x00000002; +pub const CM_REMOVE_BITS: ULONG = 0x00000003; +pub const CM_QUERY_REMOVE_UI_OK: ULONG = CM_REMOVE_UI_OK; +pub const CM_QUERY_REMOVE_UI_NOT_OK: ULONG = CM_REMOVE_UI_NOT_OK; +pub const CM_QUERY_REMOVE_BITS: ULONG = CM_QUERY_REMOVE_UI_OK | CM_QUERY_REMOVE_UI_NOT_OK; +pub const CM_REENUMERATE_NORMAL: ULONG = 0x00000000; +pub const CM_REENUMERATE_SYNCHRONOUS: ULONG = 0x00000001; +pub const CM_REENUMERATE_RETRY_INSTALLATION: ULONG = 0x00000002; +pub const CM_REENUMERATE_ASYNCHRONOUS: ULONG = 0x00000004; +pub const CM_REENUMERATE_BITS: ULONG = 0x00000007; +pub const CM_REGISTER_DEVICE_DRIVER_STATIC: ULONG = 0x00000000; +pub const CM_REGISTER_DEVICE_DRIVER_DISABLEABLE: ULONG = 0x00000001; +pub const CM_REGISTER_DEVICE_DRIVER_REMOVABLE: ULONG = 0x00000002; +pub const CM_REGISTER_DEVICE_DRIVER_BITS: ULONG = 0x00000003; +pub const CM_REGISTRY_HARDWARE: ULONG = 0x00000000; +pub const CM_REGISTRY_SOFTWARE: ULONG = 0x00000001; +pub const CM_REGISTRY_USER: ULONG = 0x00000100; +pub const CM_REGISTRY_CONFIG: ULONG = 0x00000200; +pub const CM_REGISTRY_BITS: ULONG = 0x00000301; +pub const CM_SET_DEVNODE_PROBLEM_NORMAL: ULONG = 0x00000000; +pub const CM_SET_DEVNODE_PROBLEM_OVERRIDE: ULONG = 0x00000001; +pub const CM_SET_DEVNODE_PROBLEM_BITS: ULONG = 0x00000001; +pub const CM_SET_DEVINST_PROBLEM_NORMAL: ULONG = CM_SET_DEVNODE_PROBLEM_NORMAL; +pub const CM_SET_DEVINST_PROBLEM_OVERRIDE: ULONG = CM_SET_DEVNODE_PROBLEM_OVERRIDE; +pub const CM_SET_DEVINST_PROBLEM_BITS: ULONG = CM_SET_DEVNODE_PROBLEM_BITS; +pub const CM_SET_HW_PROF_FLAGS_UI_NOT_OK: ULONG = 0x00000001; +pub const CM_SET_HW_PROF_FLAGS_BITS: ULONG = 0x00000001; +pub const CM_SETUP_DEVNODE_READY: ULONG = 0x00000000; +pub const CM_SETUP_DEVINST_READY: ULONG = CM_SETUP_DEVNODE_READY; +pub const CM_SETUP_DOWNLOAD: ULONG = 0x00000001; +pub const CM_SETUP_WRITE_LOG_CONFS: ULONG = 0x00000002; +pub const CM_SETUP_PROP_CHANGE: ULONG = 0x00000003; +pub const CM_SETUP_DEVNODE_RESET: ULONG = 0x00000004; +pub const CM_SETUP_DEVINST_RESET: ULONG = CM_SETUP_DEVNODE_RESET; +pub const CM_SETUP_DEVNODE_CONFIG: ULONG = 0x00000005; +pub const CM_SETUP_DEVINST_CONFIG: ULONG = CM_SETUP_DEVNODE_CONFIG; +pub const CM_SETUP_DEVNODE_CONFIG_CLASS: ULONG = 0x00000006; +pub const CM_SETUP_DEVINST_CONFIG_CLASS: ULONG = CM_SETUP_DEVNODE_CONFIG_CLASS; +pub const CM_SETUP_DEVNODE_CONFIG_EXTENSIONS: ULONG = 0x00000007; +pub const CM_SETUP_DEVINST_CONFIG_EXTENSIONS: ULONG = CM_SETUP_DEVNODE_CONFIG_EXTENSIONS; +pub const CM_SETUP_BITS: ULONG = 0x00000007; +pub const CM_QUERY_ARBITRATOR_RAW: ULONG = 0x00000000; +pub const CM_QUERY_ARBITRATOR_TRANSLATED: ULONG = 0x00000001; +pub const CM_QUERY_ARBITRATOR_BITS: ULONG = 0x00000001; +pub const CM_CUSTOMDEVPROP_MERGE_MULTISZ: ULONG = 0x00000001; +pub const CM_CUSTOMDEVPROP_BITS: ULONG = 0x00000001; +pub const CM_NAME_ATTRIBUTE_NAME_RETRIEVED_FROM_DEVICE: ULONG = 0x1; +pub const CM_NAME_ATTRIBUTE_USER_ASSIGNED_NAME: ULONG = 0x2; +pub const CM_CLASS_PROPERTY_INSTALLER: ULONG = 0x00000000; +pub const CM_CLASS_PROPERTY_INTERFACE: ULONG = 0x00000001; +pub const CM_CLASS_PROPERTY_BITS: ULONG = 0x00000001; +DECLARE_HANDLE!{HCMNOTIFICATION, HCMNOTIFICATION__} +pub type PHCMNOTIFICATION = *mut HCMNOTIFICATION; +pub const CM_NOTIFY_FILTER_FLAG_ALL_INTERFACE_CLASSES: ULONG = 0x00000001; +pub const CM_NOTIFY_FILTER_FLAG_ALL_DEVICE_INSTANCES: ULONG = 0x00000002; +pub const CM_NOTIFY_FILTER_VALID_FLAGS: ULONG = CM_NOTIFY_FILTER_FLAG_ALL_INTERFACE_CLASSES + | CM_NOTIFY_FILTER_FLAG_ALL_DEVICE_INSTANCES; +ENUM!{enum CM_NOTIFY_FILTER_TYPE { + CM_NOTIFY_FILTER_TYPE_DEVICEINTERFACE = 0, + CM_NOTIFY_FILTER_TYPE_DEVICEHANDLE, + CM_NOTIFY_FILTER_TYPE_DEVICEINSTANCE, + CM_NOTIFY_FILTER_TYPE_MAX, +}} +pub type PCM_NOTIFY_FILTER_TYPE = *mut CM_NOTIFY_FILTER_TYPE; +STRUCT!{struct CM_NOTIFY_FILTER_DeviceInterface { + ClassGuid: GUID, +}} +STRUCT!{struct CM_NOTIFY_FILTER_DeviceHandle { + hTarget: HANDLE, +}} +STRUCT!{struct CM_NOTIFY_FILTER_DeviceInstance { + InstanceId: [WCHAR; MAX_DEVICE_ID_LEN], +}} +UNION!{union CM_NOTIFY_FILTER_u { + [u32; 100] [u64; 50], + DeviceInterface DeviceInterface_mut: CM_NOTIFY_FILTER_DeviceInterface, + DeviceHandle DeviceHandle_mut: CM_NOTIFY_FILTER_DeviceHandle, + DeviceInstance DeviceInstance_mut: CM_NOTIFY_FILTER_DeviceInstance, +}} +STRUCT!{struct CM_NOTIFY_FILTER { + cbSize: DWORD, + Flags: DWORD, + FilterType: CM_NOTIFY_FILTER_TYPE, + Reserved: DWORD, + u: CM_NOTIFY_FILTER_u, +}} +pub type PCM_NOTIFY_FILTER = *mut CM_NOTIFY_FILTER; +ENUM!{enum CM_NOTIFY_ACTION { + CM_NOTIFY_ACTION_DEVICEINTERFACEARRIVAL = 0, + CM_NOTIFY_ACTION_DEVICEINTERFACEREMOVAL, + CM_NOTIFY_ACTION_DEVICEQUERYREMOVE, + CM_NOTIFY_ACTION_DEVICEQUERYREMOVEFAILED, + CM_NOTIFY_ACTION_DEVICEREMOVEPENDING, + CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE, + CM_NOTIFY_ACTION_DEVICECUSTOMEVENT, + CM_NOTIFY_ACTION_DEVICEINSTANCEENUMERATED, + CM_NOTIFY_ACTION_DEVICEINSTANCESTARTED, + CM_NOTIFY_ACTION_DEVICEINSTANCEREMOVED, + CM_NOTIFY_ACTION_MAX, +}} +pub type PCM_NOTIFY_ACTION = *mut CM_NOTIFY_ACTION; +STRUCT!{struct CM_NOTIFY_EVENT_DATA_DeviceInterface { + ClassGuid: GUID, + SymbolicLink: [WCHAR; ANYSIZE_ARRAY], +}} +STRUCT!{struct CM_NOTIFY_EVENT_DATA_DeviceHandle { + EventGuid: GUID, + NameOffset: LONG, + DataSize: DWORD, + Data: [BYTE; ANYSIZE_ARRAY], +}} +STRUCT!{struct CM_NOTIFY_EVENT_DATA_DeviceInstance { + InstanceId: [WCHAR; ANYSIZE_ARRAY], +}} +UNION!{union CM_NOTIFY_EVENT_DATA_u { + [u32; 7], + DeviceInterface DeviceInterface_mut: CM_NOTIFY_EVENT_DATA_DeviceInterface, + DeviceHandle DeviceHandle_mut: CM_NOTIFY_EVENT_DATA_DeviceHandle, + DeviceInstance DeviceInstance_mut: CM_NOTIFY_EVENT_DATA_DeviceInstance, +}} +STRUCT!{struct CM_NOTIFY_EVENT_DATA { + FilterType: CM_NOTIFY_FILTER_TYPE, + Reserved: DWORD, + u: CM_NOTIFY_EVENT_DATA_u, +}} +pub type PCM_NOTIFY_EVENT_DATA = *mut CM_NOTIFY_EVENT_DATA; +FN!{stdcall PCM_NOTIFY_CALLBACK( + hNotify: HCMNOTIFICATION, + Context: PVOID, + Action: CM_NOTIFY_ACTION, + EventData: PCM_NOTIFY_EVENT_DATA, + EventDataSize: DWORD, +) -> DWORD} +extern "system" { + pub fn CM_Add_Empty_Log_Conf( + plcLogConf: PLOG_CONF, + dnDevInst: DEVINST, + Priority: PRIORITY, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Add_Empty_Log_Conf_Ex( + plcLogConf: PLOG_CONF, + dnDevInst: DEVINST, + Priority: PRIORITY, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Add_IDA( + dnDevInst: DEVINST, + pszID: PSTR, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Add_IDW( + dnDevInst: DEVINST, + pszID: PWSTR, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Add_ID_ExA( + dnDevInst: DEVINST, + pszID: PSTR, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Add_ID_ExW( + dnDevInst: DEVINST, + pszID: PWSTR, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Add_Range( + ullStartValue: DWORDLONG, + ullEndValue: DWORDLONG, + rlh: RANGE_LIST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Add_Res_Des( + prdResDes: PRES_DES, + lcLogConf: LOG_CONF, + ResourceID: RESOURCEID, + ResourceData: PCVOID, + ResourceLen: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Add_Res_Des_Ex( + prdResDes: PRES_DES, + lcLogConf: LOG_CONF, + ResourceID: RESOURCEID, + ResourceData: PCVOID, + ResourceLen: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Connect_MachineA( + UNCServerName: PCSTR, + phMachine: PHMACHINE, + ) -> CONFIGRET; + pub fn CM_Connect_MachineW( + UNCServerName: PCWSTR, + phMachine: PHMACHINE, + ) -> CONFIGRET; + pub fn CM_Create_DevNodeA( + pdnDevInst: PDEVINST, + pDeviceID: DEVINSTID_A, + dnParent: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Create_DevNodeW( + pdnDevInst: PDEVINST, + pDeviceID: DEVINSTID_W, + dnParent: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Create_DevNode_ExA( + pdnDevInst: PDEVINST, + pDeviceID: DEVINSTID_A, + dnParent: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Create_DevNode_ExW( + pdnDevInst: PDEVINST, + pDeviceID: DEVINSTID_W, + dnParent: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Create_Range_List( + prlh: PRANGE_LIST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Delete_Class_Key( + ClassGuid: LPGUID, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Delete_Class_Key_Ex( + ClassGuid: LPGUID, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Delete_DevNode_Key( + dnDevNode: DEVNODE, + ulHardwareProfile: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Delete_DevNode_Key_Ex( + dnDevNode: DEVNODE, + ulHardwareProfile: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Delete_Range( + ullStartValue: DWORDLONG, + ullEndValue: DWORDLONG, + rlh: RANGE_LIST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Detect_Resource_Conflict( + dnDevInst: DEVINST, + ResourceID: RESOURCEID, + ResourceData: PCVOID, + ResourceLen: ULONG, + pbConflictDetected: PBOOL, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Detect_Resource_Conflict_Ex( + dnDevInst: DEVINST, + ResourceID: RESOURCEID, + ResourceData: PCVOID, + ResourceLen: ULONG, + pbConflictDetected: PBOOL, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Disable_DevNode( + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Disable_DevNode_Ex( + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Disconnect_Machine( + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Dup_Range_List( + rlhOld: RANGE_LIST, + rlhNew: RANGE_LIST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Enable_DevNode( + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Enable_DevNode_Ex( + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Enumerate_Classes( + ulClassIndex: ULONG, + ClassGuid: LPGUID, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Enumerate_Classes_Ex( + ulClassIndex: ULONG, + ClassGuid: LPGUID, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Enumerate_EnumeratorsA( + ulEnumIndex: ULONG, + Buffer: PSTR, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Enumerate_EnumeratorsW( + ulEnumIndex: ULONG, + Buffer: PWSTR, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Enumerate_Enumerators_ExA( + ulEnumIndex: ULONG, + Buffer: PSTR, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Enumerate_Enumerators_ExW( + ulEnumIndex: ULONG, + Buffer: PWSTR, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Find_Range( + pullStart: PDWORDLONG, + ullStart: DWORDLONG, + ulLength: ULONG, + ullAlignment: DWORDLONG, + ullEnd: DWORDLONG, + rlh: RANGE_LIST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_First_Range( + rlh: RANGE_LIST, + pullStart: PDWORDLONG, + pullEnd: PDWORDLONG, + preElement: PRANGE_LIST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Free_Log_Conf( + lcLogConfToBeFreed: LOG_CONF, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Free_Log_Conf_Ex( + lcLogConfToBeFreed: LOG_CONF, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Free_Log_Conf_Handle( + lcLogConf: LOG_CONF, + ) -> CONFIGRET; + pub fn CM_Free_Range_List( + rlh: RANGE_LIST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Free_Res_Des( + prdResDes: PRES_DES, + rdResDes: RES_DES, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Free_Res_Des_Ex( + prdResDes: PRES_DES, + rdResDes: RES_DES, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Free_Res_Des_Handle( + rdResDes: RES_DES, + ) -> CONFIGRET; + pub fn CM_Get_Child( + pdnDevInst: PDEVINST, + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Child_Ex( + pdnDevInst: PDEVINST, + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Class_Key_NameA( + ClassGuid: LPGUID, + pszKeyName: LPSTR, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Class_Key_NameW( + ClassGuid: LPGUID, + pszKeyName: LPWSTR, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Class_Key_Name_ExA( + ClassGuid: LPGUID, + pszKeyName: LPSTR, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Class_Key_Name_ExW( + ClassGuid: LPGUID, + pszKeyName: LPWSTR, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Class_NameA( + ClassGuid: LPGUID, + Buffer: PSTR, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Class_NameW( + ClassGuid: LPGUID, + Buffer: PWSTR, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Class_Name_ExA( + ClassGuid: LPGUID, + Buffer: PSTR, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Class_Name_ExW( + ClassGuid: LPGUID, + Buffer: PWSTR, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Depth( + pulDepth: PULONG, + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Depth_Ex( + pulDepth: PULONG, + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_IDA( + dnDevInst: DEVINST, + Buffer: PSTR, + BufferLen: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_IDW( + dnDevInst: DEVINST, + Buffer: PWSTR, + BufferLen: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_ExA( + dnDevInst: DEVINST, + Buffer: PSTR, + BufferLen: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_ExW( + dnDevInst: DEVINST, + Buffer: PWSTR, + BufferLen: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_ListA( + pszFilter: PCSTR, + Buffer: PCHAR, + BufferLen: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_ListW( + pszFilter: PCWSTR, + Buffer: PWCHAR, + BufferLen: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_List_ExA( + pszFilter: PCSTR, + Buffer: PCHAR, + BufferLen: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_List_ExW( + pszFilter: PCWSTR, + Buffer: PWCHAR, + BufferLen: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_List_SizeA( + pulLen: PULONG, + pszFilter: PCSTR, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_List_SizeW( + pulLen: PULONG, + pszFilter: PCWSTR, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_List_Size_ExA( + pulLen: PULONG, + pszFilter: PCSTR, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_List_Size_ExW( + pulLen: PULONG, + pszFilter: PCWSTR, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_Size( + pulLen: PULONG, + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_ID_Size_Ex( + pulLen: PULONG, + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_PropertyW( + dnDevInst: DEVINST, + PropertyKey: *const DEVPROPKEY, + PropertyType: *mut DEVPROPTYPE, + PropertyBuffer: PBYTE, + PropertyBufferSize: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_PropertyExW( + dnDevInst: DEVINST, + PropertyKey: *const DEVPROPKEY, + PropertyType: *mut DEVPROPTYPE, + PropertyBuffer: PBYTE, + PropertyBufferSize: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_Registry_PropertyA( + dnDevInst: DEVINST, + ulProperty: ULONG, + pulRegDataType: PULONG, + Buffer: PVOID, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_Registry_PropertyW( + dnDevInst: DEVINST, + ulProperty: ULONG, + pulRegDataType: PULONG, + Buffer: PVOID, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_Registry_Property_ExA( + dnDevInst: DEVINST, + ulProperty: ULONG, + pulRegDataType: PULONG, + Buffer: PVOID, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_Registry_Property_ExW( + dnDevInst: DEVINST, + ulProperty: ULONG, + pulRegDataType: PULONG, + Buffer: PVOID, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_Custom_PropertyA( + dnDevInst: DEVINST, + pszCustomPropertyName: PCSTR, + pulRegDataType: PULONG, + Buffer: PVOID, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_Custom_PropertyW( + dnDevInst: DEVINST, + pszCustomPropertyName: PCWSTR, + pulRegDataType: PULONG, + Buffer: PVOID, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_Custom_Property_ExA( + dnDevInst: DEVINST, + pszCustomPropertyName: PCSTR, + pulRegDataType: PULONG, + Buffer: PVOID, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_Custom_Property_ExW( + dnDevInst: DEVINST, + pszCustomPropertyName: PCWSTR, + pulRegDataType: PULONG, + Buffer: PVOID, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_Status( + pulStatus: PULONG, + pulProblemNumber: PULONG, + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_DevNode_Status_Ex( + pulStatus: PULONG, + pulProblemNumber: PULONG, + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_First_Log_Conf( + plcLogConf: PLOG_CONF, + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_First_Log_Conf_Ex( + plcLogConf: PLOG_CONF, + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Global_State( + pulState: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Global_State_Ex( + pulState: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Hardware_Profile_InfoA( + ulIndex: ULONG, + pHWProfileInfo: PHWPROFILEINFO_A, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Hardware_Profile_Info_ExA( + ulIndex: ULONG, + pHWProfileInfo: PHWPROFILEINFO_A, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Hardware_Profile_InfoW( + ulIndex: ULONG, + pHWProfileInfo: PHWPROFILEINFO_W, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Hardware_Profile_Info_ExW( + ulIndex: ULONG, + pHWProfileInfo: PHWPROFILEINFO_W, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_HW_Prof_FlagsA( + pDeviceID: DEVINSTID_A, + ulHardwareProfile: ULONG, + pulValue: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_HW_Prof_FlagsW( + pDeviceID: DEVINSTID_W, + ulHardwareProfile: ULONG, + pulValue: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_HW_Prof_Flags_ExA( + pDeviceID: DEVINSTID_A, + ulHardwareProfile: ULONG, + pulValue: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_HW_Prof_Flags_ExW( + pDeviceID: DEVINSTID_W, + ulHardwareProfile: ULONG, + pulValue: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_AliasA( + pszDeviceInterface: LPCSTR, + AliasInterfaceGuid: LPGUID, + pszAliasDeviceInterface: LPSTR, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_AliasW( + pszDeviceInterface: LPCWSTR, + AliasInterfaceGuid: LPGUID, + pszAliasDeviceInterface: LPWSTR, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_Alias_ExA( + pszDeviceInterface: LPCSTR, + AliasInterfaceGuid: LPGUID, + pszAliasDeviceInterface: LPSTR, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_Alias_ExW( + pszDeviceInterface: LPCWSTR, + AliasInterfaceGuid: LPGUID, + pszAliasDeviceInterface: LPWSTR, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_ListA( + InterfaceClassGuid: LPGUID, + pDeviceID: DEVINSTID_A, + Buffer: PCHAR, + BufferLen: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_ListW( + InterfaceClassGuid: LPGUID, + pDeviceID: DEVINSTID_W, + Buffer: PWCHAR, + BufferLen: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_List_ExA( + InterfaceClassGuid: LPGUID, + pDeviceID: DEVINSTID_A, + Buffer: PCHAR, + BufferLen: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_List_ExW( + InterfaceClassGuid: LPGUID, + pDeviceID: DEVINSTID_W, + Buffer: PWCHAR, + BufferLen: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_List_SizeA( + pulLen: PULONG, + InterfaceClassGuid: LPGUID, + pDeviceID: DEVINSTID_A, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_List_SizeW( + pulLen: PULONG, + InterfaceClassGuid: LPGUID, + pDeviceID: DEVINSTID_W, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_List_Size_ExA( + pulLen: PULONG, + InterfaceClassGuid: LPGUID, + pDeviceID: DEVINSTID_A, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_List_Size_ExW( + pulLen: PULONG, + InterfaceClassGuid: LPGUID, + pDeviceID: DEVINSTID_W, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_PropertyW( + pszDeviceInterface: LPCWSTR, + PropertyKey: *const DEVPROPKEY, + PropertyType: *mut DEVPROPTYPE, + PropertyBuffer: PBYTE, + PropertyBufferSize: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Device_Interface_PropertyExW( + pszDeviceInterface: LPCWSTR, + PropertyKey: *const DEVPROPKEY, + PropertyType: *mut DEVPROPTYPE, + PropertyBuffer: PBYTE, + PropertyBufferSize: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Log_Conf_Priority( + lcLogConf: LOG_CONF, + pPriority: PRIORITY, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Log_Conf_Priority_Ex( + lcLogConf: LOG_CONF, + pPriority: PRIORITY, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Next_Log_Conf( + plcLogConf: PLOG_CONF, + lcLogConf: LOG_CONF, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Next_Log_Conf_Ex( + plcLogConf: PLOG_CONF, + lcLogConf: LOG_CONF, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Parent( + pdnDevInst: PDEVINST, + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Parent_Ex( + pdnDevInst: PDEVINST, + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Res_Des_Data( + rdResDes: RES_DES, + Buffer: PVOID, + BufferLen: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Res_Des_Data_Ex( + rdResDes: RES_DES, + Buffer: PVOID, + BufferLen: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Res_Des_Data_Size( + pulSize: PULONG, + rdResDes: RES_DES, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Res_Des_Data_Size_Ex( + pulSize: PULONG, + rdResDes: RES_DES, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Sibling( + pdnDevInst: PDEVINST, + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Sibling_Ex( + pdnDevInst: PDEVINST, + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Version() -> WORD; + pub fn CM_Get_Version_Ex( + hMachine: HMACHINE, + ) -> WORD; + pub fn CM_Is_Version_Available( + wVersion: WORD, + ) -> BOOL; + pub fn CM_Is_Version_Available_Ex( + wVersion: WORD, + hMachine: HMACHINE, + ) -> BOOL; + pub fn CM_Intersect_Range_List( + rlhOld1: RANGE_LIST, + rlhOld2: RANGE_LIST, + rlhNew: RANGE_LIST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Invert_Range_List( + rlhOld: RANGE_LIST, + rlhNew: RANGE_LIST, + ullMaxValue: DWORDLONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Locate_DevNodeA( + pdnDevInst: PDEVINST, + pDeviceID: DEVINSTID_A, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Locate_DevNodeW( + pdnDevInst: PDEVINST, + pDeviceID: DEVINSTID_W, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Locate_DevNode_ExA( + pdnDevInst: PDEVINST, + pDeviceID: DEVINSTID_A, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Locate_DevNode_ExW( + pdnDevInst: PDEVINST, + pDeviceID: DEVINSTID_W, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Merge_Range_List( + rlhOld1: RANGE_LIST, + rlhOld2: RANGE_LIST, + rlhNew: RANGE_LIST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Modify_Res_Des( + prdResDes: PRES_DES, + rdResDes: RES_DES, + ResourceID: RESOURCEID, + ResourceData: PCVOID, + ResourceLen: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Modify_Res_Des_Ex( + prdResDes: PRES_DES, + rdResDes: RES_DES, + ResourceID: RESOURCEID, + ResourceData: PCVOID, + ResourceLen: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Move_DevNode( + dnFromDevInst: DEVINST, + dnToDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Move_DevNode_Ex( + dnFromDevInst: DEVINST, + dnToDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Next_Range( + preElement: PRANGE_LIST, + pullStart: PDWORDLONG, + pullEnd: PDWORDLONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Next_Res_Des( + prdResDes: PRES_DES, + rdResDes: RES_DES, + ForResource: RESOURCEID, + pResourceID: PRESOURCEID, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Get_Next_Res_Des_Ex( + prdResDes: PRES_DES, + rdResDes: RES_DES, + ForResource: RESOURCEID, + pResourceID: PRESOURCEID, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Open_Class_KeyA( + ClassGuid: LPGUID, + pszClassName: LPCSTR, + samDesired: REGSAM, + Disposition: REGDISPOSITION, + phkClass: PHKEY, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Open_Class_KeyW( + ClassGuid: LPGUID, + pszClassName: LPCWSTR, + samDesired: REGSAM, + Disposition: REGDISPOSITION, + phkClass: PHKEY, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Open_Class_Key_ExA( + ClassGuid: LPGUID, + pszClassName: LPCSTR, + samDesired: REGSAM, + Disposition: REGDISPOSITION, + phkClass: PHKEY, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Open_Class_Key_ExW( + ClassGuid: LPGUID, + pszClassName: LPCWSTR, + samDesired: REGSAM, + Disposition: REGDISPOSITION, + phkClass: PHKEY, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Open_DevNode_Key( + dnDevNode: DEVINST, + samDesired: REGSAM, + ulHardwareProfile: ULONG, + Disposition: REGDISPOSITION, + phkDevice: PHKEY, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Open_DevNode_Key_Ex( + dnDevNode: DEVINST, + samDesired: REGSAM, + ulHardwareProfile: ULONG, + Disposition: REGDISPOSITION, + phkDevice: PHKEY, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Open_Device_Interface_KeyA( + pszDeviceInterface: LPCSTR, + samDesired: REGSAM, + Disposition: REGDISPOSITION, + phkDeviceInterface: PHKEY, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Open_Device_Interface_KeyW( + pszDeviceInterface: LPCWSTR, + samDesired: REGSAM, + Disposition: REGDISPOSITION, + phkDeviceInterface: PHKEY, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Open_Device_Interface_Key_ExA( + pszDeviceInterface: LPCSTR, + samDesired: REGSAM, + Disposition: REGDISPOSITION, + phkDeviceInterface: PHKEY, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Open_Device_Interface_Key_ExW( + pszDeviceInterface: LPCWSTR, + samDesired: REGSAM, + Disposition: REGDISPOSITION, + phkDeviceInterface: PHKEY, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Delete_Device_Interface_KeyA( + pszDeviceInterface: LPCSTR, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Delete_Device_Interface_KeyW( + pszDeviceInterface: LPCWSTR, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Delete_Device_Interface_Key_ExA( + pszDeviceInterface: LPCSTR, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Delete_Device_Interface_Key_ExW( + pszDeviceInterface: LPCWSTR, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Query_Arbitrator_Free_Data( + pData: PVOID, + DataLen: ULONG, + dnDevInst: DEVINST, + ResourceID: RESOURCEID, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Query_Arbitrator_Free_Data_Ex( + pData: PVOID, + DataLen: ULONG, + dnDevInst: DEVINST, + ResourceID: RESOURCEID, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Query_Arbitrator_Free_Size( + pulSize: PULONG, + dnDevInst: DEVINST, + ResourceID: RESOURCEID, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Query_Arbitrator_Free_Size_Ex( + pulSize: PULONG, + dnDevInst: DEVINST, + ResourceID: RESOURCEID, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Query_Remove_SubTree( + dnAncestor: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Query_Remove_SubTree_Ex( + dnAncestor: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Query_And_Remove_SubTreeA( + dnAncestor: DEVINST, + pVetoType: PPNP_VETO_TYPE, + pszVetoName: LPSTR, + ulNameLength: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Query_And_Remove_SubTree_ExA( + dnAncestor: DEVINST, + pVetoType: PPNP_VETO_TYPE, + pszVetoName: LPSTR, + ulNameLength: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Query_And_Remove_SubTreeW( + dnAncestor: DEVINST, + pVetoType: PPNP_VETO_TYPE, + pszVetoName: LPWSTR, + ulNameLength: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Query_And_Remove_SubTree_ExW( + dnAncestor: DEVINST, + pVetoType: PPNP_VETO_TYPE, + pszVetoName: LPWSTR, + ulNameLength: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Request_Device_EjectA( + dnDevInst: DEVINST, + pVetoType: PPNP_VETO_TYPE, + pszVetoName: LPSTR, + ulNameLength: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Request_Device_Eject_ExA( + dnDevInst: DEVINST, + pVetoType: PPNP_VETO_TYPE, + pszVetoName: LPSTR, + ulNameLength: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Request_Device_EjectW( + dnDevInst: DEVINST, + pVetoType: PPNP_VETO_TYPE, + pszVetoName: LPWSTR, + ulNameLength: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Request_Device_Eject_ExW( + dnDevInst: DEVINST, + pVetoType: PPNP_VETO_TYPE, + pszVetoName: LPWSTR, + ulNameLength: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Reenumerate_DevNode( + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Reenumerate_DevNode_Ex( + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Register_Device_InterfaceA( + dnDevInst: DEVINST, + InterfaceClassGuid: LPGUID, + pszReference: LPCSTR, + pszDeviceInterface: LPSTR, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Register_Device_InterfaceW( + dnDevInst: DEVINST, + InterfaceClassGuid: LPGUID, + pszReference: LPCWSTR, + pszDeviceInterface: LPWSTR, + pulLength: PULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Register_Device_Interface_ExA( + dnDevInst: DEVINST, + InterfaceClassGuid: LPGUID, + pszReference: LPCSTR, + pszDeviceInterface: LPSTR, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Register_Device_Interface_ExW( + dnDevInst: DEVINST, + InterfaceClassGuid: LPGUID, + pszReference: LPCWSTR, + pszDeviceInterface: LPWSTR, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Set_DevNode_Problem_Ex( + dnDevInst: DEVINST, + ulProblem: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Set_DevNode_Problem( + dnDevInst: DEVINST, + ulProblem: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Unregister_Device_InterfaceA( + pszDeviceInterface: LPCSTR, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Unregister_Device_InterfaceW( + pszDeviceInterface: LPCWSTR, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Unregister_Device_Interface_ExA( + pszDeviceInterface: LPCSTR, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Unregister_Device_Interface_ExW( + pszDeviceInterface: LPCWSTR, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Register_Device_Driver( + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Register_Device_Driver_Ex( + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Remove_SubTree( + dnAncestor: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Remove_SubTree_Ex( + dnAncestor: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Set_DevNode_Registry_PropertyA( + dnDevInst: DEVINST, + ulProperty: ULONG, + Buffer: PCVOID, + ulLength: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Set_DevNode_Registry_PropertyW( + dnDevInst: DEVINST, + ulProperty: ULONG, + Buffer: PCVOID, + ulLength: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Set_DevNode_Registry_Property_ExA( + dnDevInst: DEVINST, + ulProperty: ULONG, + Buffer: PCVOID, + ulLength: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Set_DevNode_Registry_Property_ExW( + dnDevInst: DEVINST, + ulProperty: ULONG, + Buffer: PCVOID, + ulLength: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Is_Dock_Station_Present( + pbPresent: PBOOL, + ) -> CONFIGRET; + pub fn CM_Is_Dock_Station_Present_Ex( + pbPresent: PBOOL, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Request_Eject_PC() -> CONFIGRET; + pub fn CM_Request_Eject_PC_Ex( + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Set_HW_Prof_FlagsA( + pDeviceID: DEVINSTID_A, + ulConfig: ULONG, + ulValue: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Set_HW_Prof_FlagsW( + pDeviceID: DEVINSTID_W, + ulConfig: ULONG, + ulValue: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Set_HW_Prof_Flags_ExA( + pDeviceID: DEVINSTID_A, + ulConfig: ULONG, + ulValue: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Set_HW_Prof_Flags_ExW( + pDeviceID: DEVINSTID_A, + ulConfig: ULONG, + ulValue: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Setup_DevNode( + dnDevInst: DEVINST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Setup_DevNode_Ex( + dnDevInst: DEVINST, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Test_Range_Available( + ullStartValue: DWORDLONG, + ullEndValue: DWORDLONG, + rlh: RANGE_LIST, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Uninstall_DevNode( + dnDevInst: DEVNODE, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Uninstall_DevNode_Ex( + dnDevInst: DEVNODE, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Run_Detection( + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Run_Detection_Ex( + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Set_HW_Prof( + ulHardwareProfile: ULONG, + ulFlags: ULONG, + ) -> CONFIGRET; + pub fn CM_Set_HW_Prof_Ex( + ulHardwareProfile: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Query_Resource_Conflict_List( + pclConflictList: PCONFLICT_LIST, + dnDevInst: DEVINST, + ResourceID: RESOURCEID, + ResourceData: PCVOID, + ResourceLen: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Free_Resource_Conflict_Handle( + clConflictList: CONFLICT_LIST, + ) -> CONFIGRET; + pub fn CM_Get_Resource_Conflict_Count( + clConflictList: CONFLICT_LIST, + pulCount: PULONG, + ) -> CONFIGRET; + pub fn CM_Get_Resource_Conflict_DetailsA( + clConflictList: CONFLICT_LIST, + ulIndex: ULONG, + pConflictDetails: PCONFLICT_DETAILS_A, + ) -> CONFIGRET; + pub fn CM_Get_Resource_Conflict_DetailsW( + clConflictList: CONFLICT_LIST, + ulIndex: ULONG, + pConflictDetails: PCONFLICT_DETAILS_W, + ) -> CONFIGRET; + pub fn CM_Get_Class_Registry_PropertyW( + ClassGuid: LPGUID, + ulProperty: ULONG, + pulRegDataType: PULONG, + Buffer: PVOID, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Set_Class_Registry_PropertyW( + ClassGuid: LPGUID, + ulProperty: ULONG, + Buffer: PCVOID, + ulLength: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Get_Class_Registry_PropertyA( + ClassGuid: LPGUID, + ulProperty: ULONG, + pulRegDataType: PULONG, + Buffer: PVOID, + pulLength: PULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CM_Set_Class_Registry_PropertyA( + ClassGuid: LPGUID, + ulProperty: ULONG, + Buffer: PCVOID, + ulLength: ULONG, + ulFlags: ULONG, + hMachine: HMACHINE, + ) -> CONFIGRET; + pub fn CMP_WaitNoPendingInstallEvents( + dwTimeout: DWORD, + ) -> DWORD; +} +pub const CR_SUCCESS: CONFIGRET = 0x00000000; +pub const CR_DEFAULT: CONFIGRET = 0x00000001; +pub const CR_OUT_OF_MEMORY: CONFIGRET = 0x00000002; +pub const CR_INVALID_POINTER: CONFIGRET = 0x00000003; +pub const CR_INVALID_FLAG: CONFIGRET = 0x00000004; +pub const CR_INVALID_DEVNODE: CONFIGRET = 0x00000005; +pub const CR_INVALID_DEVINST: CONFIGRET = CR_INVALID_DEVNODE; +pub const CR_INVALID_RES_DES: CONFIGRET = 0x00000006; +pub const CR_INVALID_LOG_CONF: CONFIGRET = 0x00000007; +pub const CR_INVALID_ARBITRATOR: CONFIGRET = 0x00000008; +pub const CR_INVALID_NODELIST: CONFIGRET = 0x00000009; +pub const CR_DEVNODE_HAS_REQS: CONFIGRET = 0x0000000A; +pub const CR_DEVINST_HAS_REQS: CONFIGRET = CR_DEVNODE_HAS_REQS; +pub const CR_INVALID_RESOURCEID: CONFIGRET = 0x0000000B; +pub const CR_DLVXD_NOT_FOUND: CONFIGRET = 0x0000000C; +pub const CR_NO_SUCH_DEVNODE: CONFIGRET = 0x0000000D; +pub const CR_NO_SUCH_DEVINST: CONFIGRET = CR_NO_SUCH_DEVNODE; +pub const CR_NO_MORE_LOG_CONF: CONFIGRET = 0x0000000E; +pub const CR_NO_MORE_RES_DES: CONFIGRET = 0x0000000F; +pub const CR_ALREADY_SUCH_DEVNODE: CONFIGRET = 0x00000010; +pub const CR_ALREADY_SUCH_DEVINST: CONFIGRET = CR_ALREADY_SUCH_DEVNODE; +pub const CR_INVALID_RANGE_LIST: CONFIGRET = 0x00000011; +pub const CR_INVALID_RANGE: CONFIGRET = 0x00000012; +pub const CR_FAILURE: CONFIGRET = 0x00000013; +pub const CR_NO_SUCH_LOGICAL_DEV: CONFIGRET = 0x00000014; +pub const CR_CREATE_BLOCKED: CONFIGRET = 0x00000015; +pub const CR_NOT_SYSTEM_VM: CONFIGRET = 0x00000016; +pub const CR_REMOVE_VETOED: CONFIGRET = 0x00000017; +pub const CR_APM_VETOED: CONFIGRET = 0x00000018; +pub const CR_INVALID_LOAD_TYPE: CONFIGRET = 0x00000019; +pub const CR_BUFFER_SMALL: CONFIGRET = 0x0000001A; +pub const CR_NO_ARBITRATOR: CONFIGRET = 0x0000001B; +pub const CR_NO_REGISTRY_HANDLE: CONFIGRET = 0x0000001C; +pub const CR_REGISTRY_ERROR: CONFIGRET = 0x0000001D; +pub const CR_INVALID_DEVICE_ID: CONFIGRET = 0x0000001E; +pub const CR_INVALID_DATA: CONFIGRET = 0x0000001F; +pub const CR_INVALID_API: CONFIGRET = 0x00000020; +pub const CR_DEVLOADER_NOT_READY: CONFIGRET = 0x00000021; +pub const CR_NEED_RESTART: CONFIGRET = 0x00000022; +pub const CR_NO_MORE_HW_PROFILES: CONFIGRET = 0x00000023; +pub const CR_DEVICE_NOT_THERE: CONFIGRET = 0x00000024; +pub const CR_NO_SUCH_VALUE: CONFIGRET = 0x00000025; +pub const CR_WRONG_TYPE: CONFIGRET = 0x00000026; +pub const CR_INVALID_PRIORITY: CONFIGRET = 0x00000027; +pub const CR_NOT_DISABLEABLE: CONFIGRET = 0x00000028; +pub const CR_FREE_RESOURCES: CONFIGRET = 0x00000029; +pub const CR_QUERY_VETOED: CONFIGRET = 0x0000002A; +pub const CR_CANT_SHARE_IRQ: CONFIGRET = 0x0000002B; +pub const CR_NO_DEPENDENT: CONFIGRET = 0x0000002C; +pub const CR_SAME_RESOURCES: CONFIGRET = 0x0000002D; +pub const CR_NO_SUCH_REGISTRY_KEY: CONFIGRET = 0x0000002E; +pub const CR_INVALID_MACHINENAME: CONFIGRET = 0x0000002F; +pub const CR_REMOTE_COMM_FAILURE: CONFIGRET = 0x00000030; +pub const CR_MACHINE_UNAVAILABLE: CONFIGRET = 0x00000031; +pub const CR_NO_CM_SERVICES: CONFIGRET = 0x00000032; +pub const CR_ACCESS_DENIED: CONFIGRET = 0x00000033; +pub const CR_CALL_NOT_IMPLEMENTED: CONFIGRET = 0x00000034; +pub const CR_INVALID_PROPERTY: CONFIGRET = 0x00000035; +pub const CR_DEVICE_INTERFACE_ACTIVE: CONFIGRET = 0x00000036; +pub const CR_NO_SUCH_DEVICE_INTERFACE: CONFIGRET = 0x00000037; +pub const CR_INVALID_REFERENCE_STRING: CONFIGRET = 0x00000038; +pub const CR_INVALID_CONFLICT_LIST: CONFIGRET = 0x00000039; +pub const CR_INVALID_INDEX: CONFIGRET = 0x0000003A; +pub const CR_INVALID_STRUCTURE_SIZE: CONFIGRET = 0x0000003B; +pub const NUM_CR_RESULTS: CONFIGRET = 0x0000003C; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/cguid.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/cguid.rs new file mode 100644 index 0000000..be7f929 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/cguid.rs @@ -0,0 +1,134 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +// Some of these definitions are commented out because I could not find their value +DEFINE_GUID!{GUID_NULL, + 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} +DEFINE_GUID!{CATID_MARSHALER, + 0x00000003, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IRpcChannel, + 0x00000004, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IRpcStub, + 0x00000005, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IStubManager, + 0x00000006, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IRpcProxy, + 0x00000007, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IProxyManager, + 0x00000008, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IPSFactory, + 0x00000009, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IInternalMoniker, + 0x00000011, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IDfReserved1, + 0x00000013, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IDfReserved2, + 0x00000014, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IDfReserved3, + 0x00000015, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_StdMarshal, + 0x00000017, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +// extern const CLSID CLSID_AggStdMarshal; +DEFINE_GUID!{CLSID_StdAsyncActManager, + 0x00000329, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IStub, + 0x00000026, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IProxy, + 0x00000027, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IEnumGeneric, + 0x00000106, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IEnumHolder, + 0x00000107, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IEnumCallback, + 0x00000108, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IOleManager, + 0x0000011f, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IOlePresObj, + 0x00000120, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IDebug, + 0x00000123, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{IID_IDebugStream, + 0x00000124, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_PSGenObject, + 0x0000030c, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_PSClientSite, + 0x0000030d, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_PSClassObject, + 0x0000030e, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_PSInPlaceActive, + 0x0000030f, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_PSInPlaceFrame, + 0x00000310, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_PSDragDrop, + 0x00000311, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_PSBindCtx, + 0x00000312, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_PSEnumerators, + 0x00000313, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_StaticMetafile, + 0x00000315, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_StaticDib, + 0x00000316, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +// extern const CLSID CID_CDfsVolume; +DEFINE_GUID!{CLSID_DCOMAccessControl, + 0x0000031d, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_GlobalOptions, + 0x0000034b, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_StdGlobalInterfaceTable, + 0x00000323, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_ComBinding, + 0x00000328, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_StdEvent, + 0x0000032b, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_ManualResetEvent, + 0x0000032c, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_SynchronizeContainer, + 0x0000032d, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_AddrControl, + 0x00000348, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_ContextSwitcher, + 0x0000034e, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +// extern const CLSID CLSID_CCDFormKrnl; +// extern const CLSID CLSID_CCDPropertyPage; +// extern const CLSID CLSID_CCDFormDialog; +// extern const CLSID CLSID_CCDCommandButton; +// extern const CLSID CLSID_CCDComboBox; +// extern const CLSID CLSID_CCDTextBox; +// extern const CLSID CLSID_CCDCheckBox; +// extern const CLSID CLSID_CCDLabel; +// extern const CLSID CLSID_CCDOptionButton; +// extern const CLSID CLSID_CCDListBox; +// extern const CLSID CLSID_CCDScrollBar; +// extern const CLSID CLSID_CCDGroupBox; +// extern const CLSID CLSID_CCDGeneralPropertyPage; +// extern const CLSID CLSID_CCDGenericPropertyPage; +// extern const CLSID CLSID_CCDFontPropertyPage; +// extern const CLSID CLSID_CCDColorPropertyPage; +// extern const CLSID CLSID_CCDLabelPropertyPage; +// extern const CLSID CLSID_CCDCheckBoxPropertyPage; +// extern const CLSID CLSID_CCDTextBoxPropertyPage; +// extern const CLSID CLSID_CCDOptionButtonPropertyPage; +// extern const CLSID CLSID_CCDListBoxPropertyPage; +// extern const CLSID CLSID_CCDCommandButtonPropertyPage; +// extern const CLSID CLSID_CCDComboBoxPropertyPage; +// extern const CLSID CLSID_CCDScrollBarPropertyPage; +// extern const CLSID CLSID_CCDGroupBoxPropertyPage; +// extern const CLSID CLSID_CCDXObjectPropertyPage; +// extern const CLSID CLSID_CStdPropertyFrame; +// extern const CLSID CLSID_CFormPropertyPage; +// extern const CLSID CLSID_CGridPropertyPage; +// extern const CLSID CLSID_CWSJArticlePage; +// extern const CLSID CLSID_CSystemPage; +// extern const CLSID CLSID_IdentityUnmarshal; +DEFINE_GUID!{CLSID_InProcFreeMarshaler, + 0x0000033a, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_Picture_Metafile, + 0x00000315, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_Picture_EnhMetafile, + 0x00000319, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{CLSID_Picture_Dib, + 0x00000316, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} +DEFINE_GUID!{GUID_TRISTATE, + 0x6650430a, 0xbe0f, 0x101a, 0x8b, 0xbb, 0x00, 0xaa, 0x00, 0x30, 0x0c, 0xab} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/combaseapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/combaseapi.rs new file mode 100644 index 0000000..823c026 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/combaseapi.rs @@ -0,0 +1,477 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Base Component Object Model defintions. +use ctypes::{c_int, c_void}; +use shared::basetsd::{SIZE_T, UINT64, ULONG_PTR}; +use shared::guiddef::{CLSID, GUID, LPCLSID, LPIID, REFCLSID, REFGUID, REFIID}; +use shared::minwindef::{BOOL, DWORD, FILETIME, HGLOBAL, LPDWORD, LPHANDLE, LPVOID, ULONG}; +use shared::rpcdce::{RPC_AUTHZ_HANDLE, RPC_AUTH_IDENTITY_HANDLE}; +use shared::wtypesbase::{ + CLSCTX, CLSCTX_INPROC_HANDLER, CLSCTX_INPROC_SERVER, CLSCTX_LOCAL_SERVER, CLSCTX_REMOTE_SERVER, + LPCOLESTR, LPOLESTR, OLECHAR, +}; +use um::objidl::SOLE_AUTHENTICATION_SERVICE; +use um::objidlbase::{ + APTTYPE, APTTYPEQUALIFIER, COSERVERINFO, IActivationFilter, IAgileReference, LPMALLOC, + LPMARSHAL, LPSTREAM, LPSURROGATE, MULTI_QI, +}; +use um::propidl::PROPVARIANT; +use um::unknwnbase::{IUnknown, LPUNKNOWN}; +use um::winnt::{HANDLE, HRESULT, LARGE_INTEGER, LONG, PSECURITY_DESCRIPTOR, PVOID, ULARGE_INTEGER}; +#[inline] +pub fn LISet32(li: &mut LARGE_INTEGER, v: DWORD) { + unsafe { + li.u_mut().HighPart = if (v as LONG) < 0 { + -1 + } else { + 0 + }; + li.u_mut().LowPart = v; + } +} +#[inline] +pub fn ULISet32(li: &mut ULARGE_INTEGER, v: DWORD) { + unsafe { + li.u_mut().HighPart = 0; + li.u_mut().LowPart = v; + } +} +pub const CLSCTX_INPROC: CLSCTX = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER; +pub const CLSCTX_ALL: CLSCTX = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER + | CLSCTX_REMOTE_SERVER; +pub const CLSCTX_SERVER: CLSCTX = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER + | CLSCTX_REMOTE_SERVER; +ENUM!{enum REGCLS { + REGCLS_SINGLEUSE = 0, + REGCLS_MULTIPLEUSE = 1, + REGCLS_MULTI_SEPARATE = 2, + REGCLS_SUSPENDED = 4, + REGCLS_SURROGATE = 8, + REGCLS_AGILE = 0x10, +}} +ENUM!{enum COINITBASE { + COINITBASE_MULTITHREADED = 0x0, +}} +extern "system" { + pub fn CoGetMalloc( + dwMemContext: DWORD, + ppMalloc: *mut LPMALLOC, + ) -> HRESULT; + pub fn CreateStreamOnHGlobal( + hGlobal: HGLOBAL, + fDeleteOnRelease: BOOL, + ppstm: *mut LPSTREAM, + ) -> HRESULT; + pub fn GetHGlobalFromStream( + pstm: LPSTREAM, + phglobal: *mut HGLOBAL, + ) -> HRESULT; + pub fn CoUninitialize() -> (); + pub fn CoGetCurrentProcess() -> DWORD; + pub fn CoInitializeEx( + pvReserved: LPVOID, + dwCoInit: DWORD, + ) -> HRESULT; + pub fn CoGetCallerTID( + lpdwTID: LPDWORD, + ) -> HRESULT; + pub fn CoGetCurrentLogicalThreadId( + pguid: *mut GUID, + ) -> HRESULT; + pub fn CoGetContextToken( + pToken: *mut ULONG_PTR, + ) -> HRESULT; + pub fn CoGetDefaultContext( + aptType: APTTYPE, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT; + pub fn CoGetApartmentType( + pAptType: *mut APTTYPE, + pAptQualifier: *mut APTTYPEQUALIFIER, + ) -> HRESULT; +} +STRUCT!{struct ServerInformation { + dwServerPid: DWORD, + dwServerTid: DWORD, + ui64ServerAddress: UINT64, +}} +pub type PServerInformation = *mut ServerInformation; +extern "system" { + pub fn CoDecodeProxy( + dwClientPid: DWORD, + ui64ProxyAddress: UINT64, + pServerInformation: PServerInformation, + ) -> HRESULT; +} +DECLARE_HANDLE!{CO_MTA_USAGE_COOKIE, CO_MTA_USAGE_COOKIE__} +extern "system" { + pub fn CoIncrementMTAUsage( + pCookie: *mut CO_MTA_USAGE_COOKIE, + ) -> HRESULT; + pub fn CoDecrementMTAUsage( + Cookie: CO_MTA_USAGE_COOKIE, + ) -> HRESULT; + pub fn CoAllowUnmarshalerCLSID( + clsid: REFCLSID, + ) -> HRESULT; + pub fn CoGetObjectContext( + riid: REFIID, + ppv: *mut LPVOID, + ) -> HRESULT; + pub fn CoGetClassObject( + rclsid: REFCLSID, + dwClsContext: DWORD, + pvReserved: LPVOID, + riid: REFIID, + ppv: *mut LPVOID, + ) -> HRESULT; + pub fn CoRegisterClassObject( + rclsid: REFCLSID, + pUnk: LPUNKNOWN, + dwClsContext: DWORD, + flags: DWORD, + lpdwRegister: LPDWORD, + ) -> HRESULT; + pub fn CoRevokeClassObject( + dwRegister: DWORD, + ) -> HRESULT; + pub fn CoResumeClassObjects() -> HRESULT; + pub fn CoSuspendClassObjects() -> HRESULT; + pub fn CoAddRefServerProcess() -> ULONG; + pub fn CoReleaseServerProcess() -> ULONG; + pub fn CoGetPSClsid( + riid: REFIID, + pClsid: *mut CLSID, + ) -> HRESULT; + pub fn CoRegisterPSClsid( + riid: REFIID, + rclsid: REFCLSID, + ) -> HRESULT; + pub fn CoRegisterSurrogate( + pSurrogate: LPSURROGATE, + ) -> HRESULT; + pub fn CoGetMarshalSizeMax( + pulSize: *mut ULONG, + riid: REFIID, + pUnk: LPUNKNOWN, + dwDestContext: DWORD, + pvDestContext: LPVOID, + mshlflags: DWORD, + ) -> HRESULT; + pub fn CoMarshalInterface( + pStm: LPSTREAM, + riid: REFIID, + pUnk: LPUNKNOWN, + dwDestContext: DWORD, + pvDestContext: LPVOID, + mshlflags: DWORD, + ) -> HRESULT; + pub fn CoUnmarshalInterface( + pStm: LPSTREAM, + riid: REFIID, + ppv: *mut LPVOID, + ) -> HRESULT; + pub fn CoMarshalHresult( + pstm: LPSTREAM, + hresult: HRESULT, + ) -> HRESULT; + pub fn CoUnmarshalHresult( + pstm: LPSTREAM, + phresult: *mut HRESULT, + ) -> HRESULT; + pub fn CoReleaseMarshalData( + pstm: LPSTREAM, + ) -> HRESULT; + pub fn CoDisconnectObject( + pUnk: LPUNKNOWN, + dwReserved: DWORD, + ) -> HRESULT; + pub fn CoLockObjectExternal( + pUnk: LPUNKNOWN, + fLock: BOOL, + fLastUnlockReleases: BOOL, + ) -> HRESULT; + pub fn CoGetStandardMarshal( + riid: REFIID, + pUnk: LPUNKNOWN, + dwDestContext: DWORD, + pvDestContext: LPVOID, + mshlflags: DWORD, + ppMarshal: *mut LPMARSHAL, + ) -> HRESULT; + pub fn CoGetStdMarshalEx( + pUnkOuter: LPUNKNOWN, + smexflags: DWORD, + ppUnkInner: *mut LPUNKNOWN, + ) -> HRESULT; +} +ENUM!{enum STDMSHLFLAGS { + SMEXF_SERVER = 0x01, + SMEXF_HANDLER = 0x02, +}} +extern "system" { + pub fn CoIsHandlerConnected( + pUnk: LPUNKNOWN, + ) -> BOOL; + pub fn CoMarshalInterThreadInterfaceInStream( + riid: REFIID, + pUnk: LPUNKNOWN, + ppStm: *mut LPSTREAM, + ) -> HRESULT; + pub fn CoGetInterfaceAndReleaseStream( + pStm: LPSTREAM, + iid: REFIID, + ppv: *mut LPVOID, + ) -> HRESULT; + pub fn CoCreateFreeThreadedMarshaler( + punkOuter: LPUNKNOWN, + ppunkMarshal: *mut LPUNKNOWN, + ) -> HRESULT; + pub fn CoFreeUnusedLibraries(); + pub fn CoFreeUnusedLibrariesEx( + dwUnloadDelay: DWORD, + dwReserved: DWORD, + ); + pub fn CoDisconnectContext( + dwTimeout: DWORD, + )-> HRESULT; + pub fn CoInitializeSecurity( + pSecDesc: PSECURITY_DESCRIPTOR, + cAuthSvc: LONG, + asAuthSvc: *mut SOLE_AUTHENTICATION_SERVICE, + pReserved1: *mut c_void, + dwAuthnLevel: DWORD, + dwImpLevel: DWORD, + pAuthList: *mut c_void, + dwCapabilities: DWORD, + pReserved3: *mut c_void, + ) -> HRESULT; + pub fn CoGetCallContext( + riid: REFIID, + ppInterface: *mut *mut c_void, + ) -> HRESULT; + pub fn CoQueryProxyBlanket( + pProxy: *mut IUnknown, + pwAuthnSvc: *mut DWORD, + pAuthzSvc: *mut DWORD, + pServerPrincName: *mut LPOLESTR, + pAuthnLevel: *mut DWORD, + pImpLevel: *mut DWORD, + pAuthInfo: *mut RPC_AUTH_IDENTITY_HANDLE, + pCapabilites: *mut DWORD, + ) -> HRESULT; + pub fn CoSetProxyBlanket( + pProxy: *mut IUnknown, + dwAuthnSvc: DWORD, + dwAuthzSvc: DWORD, + pServerPrincName: *mut OLECHAR, + dwAuthnLevel: DWORD, + dwImpLevel: DWORD, + pAuthInfo: RPC_AUTH_IDENTITY_HANDLE, + dwCapabilities: DWORD, + ) -> HRESULT; + pub fn CoCopyProxy( + pProxy: *mut IUnknown, + ppCopy: *mut *mut IUnknown, + ) -> HRESULT; + pub fn CoQueryClientBlanket( + pAuthnSvc: *mut DWORD, + pAuthzSvc: *mut DWORD, + pServerPrincName: *mut LPOLESTR, + pAuthnLevel: *mut DWORD, + pImpLevel: *mut DWORD, + pPrivs: *mut RPC_AUTHZ_HANDLE, + pCapabilities: *mut DWORD, + ) -> HRESULT; + pub fn CoImpersonateClient() -> HRESULT; + pub fn CoRevertToSelf() -> HRESULT; + pub fn CoQueryAuthenticationServices( + pcAuthSvc: *mut DWORD, + asAuthSvc: *mut *mut SOLE_AUTHENTICATION_SERVICE, + ) -> HRESULT; + pub fn CoSwitchCallContext( + pNewObject: *mut IUnknown, + ppOldObject: *mut *mut IUnknown, + ) -> HRESULT; +} +pub const COM_RIGHTS_EXECUTE: DWORD = 1; +pub const COM_RIGHTS_EXECUTE_LOCAL: DWORD = 2; +pub const COM_RIGHTS_EXECUTE_REMOTE: DWORD = 4; +pub const COM_RIGHTS_ACTIVATE_LOCAL: DWORD = 8; +pub const COM_RIGHTS_ACTIVATE_REMOTE: DWORD = 16; +extern "system" { + pub fn CoCreateInstance( + rclsid: REFCLSID, + pUnkOuter: LPUNKNOWN, + dwClsContext: DWORD, + riid: REFIID, + ppv: *mut LPVOID, + ) -> HRESULT; + pub fn CoCreateInstanceEx( + Clsid: REFCLSID, + punkOuter: *mut IUnknown, + dwClsCtx: DWORD, + pServerInfo: *mut COSERVERINFO, + dwCount: DWORD, + pResults: *mut MULTI_QI, + ) -> HRESULT; + pub fn CoRegisterActivationFilter( + pActivationFilter: *mut IActivationFilter, + ) -> HRESULT; + pub fn CoCreateInstanceFromApp( + Clsid: REFCLSID, + punkOuter: *mut IUnknown, + dwClsCtx: DWORD, + reserved: PVOID, + dwCount: DWORD, + pResults: *mut MULTI_QI, + ) -> HRESULT; + pub fn CoGetCancelObject( + dwThreadId: DWORD, + iid: REFIID, + ppUnk: *mut *mut c_void, + ) -> HRESULT; + pub fn CoSetCancelObject( + pUnk: *mut *mut IUnknown, + ) -> HRESULT; + pub fn CoCancelCall( + dwThreadId: DWORD, + ulTimeout: ULONG, + ) -> HRESULT; + pub fn CoTestCancel() -> HRESULT; + pub fn CoEnableCallCancellation( + pReserved: LPVOID, + ) -> HRESULT; + pub fn CoDisableCallCancellation( + pReserved: LPVOID, + ) -> HRESULT; + pub fn StringFromCLSID( + rclsid: REFCLSID, + lplpsz: *mut LPOLESTR, + ) -> HRESULT; + pub fn CLSIDFromString( + lpsz: LPCOLESTR, + pclsid: LPCLSID, + ) -> HRESULT; + pub fn StringFromIID( + rclsid: REFIID, + lplpsz: *mut LPOLESTR, + ) -> HRESULT; + pub fn IIDFromString( + lpsz: LPCOLESTR, + lpiid: LPIID, + ) -> HRESULT; + pub fn ProgIDFromCLSID( + clsid: REFCLSID, + lplpszProgID: *mut LPOLESTR, + ) -> HRESULT; + pub fn CLSIDFromProgID( + lpszProgID: LPCOLESTR, + lpclsid: LPCLSID, + ) -> HRESULT; + pub fn StringFromGUID2( + rguid: REFGUID, + lpsz: LPOLESTR, + cchMax: c_int, + ) -> c_int; + pub fn CoCreateGuid( + pguid: *mut GUID, + ) -> HRESULT; + pub fn PropVariantCopy( + pvarDest: *mut PROPVARIANT, + pvarSrc: *const PROPVARIANT, + ) -> HRESULT; + pub fn PropVariantClear( + pvar: *mut PROPVARIANT, + ) -> HRESULT; + pub fn FreePropVariantArray( + cVariants: ULONG, + rgvars: *mut PROPVARIANT, + ) -> HRESULT; + pub fn CoWaitForMultipleHandles( + dwFlags: DWORD, + dwTimeout: DWORD, + cHandles: ULONG, + pHandles: LPHANDLE, + lpdwindex: LPDWORD, + ) -> HRESULT; +} +ENUM!{enum COWAIT_FLAGS { + COWAIT_DEFAULT = 0, + COWAIT_WAITALL = 1, + COWAIT_ALERTABLE = 2, + COWAIT_INPUTAVAILABLE = 4, + COWAIT_DISPATCH_CALLS = 8, + COWAIT_DISPATCH_WINDOW_MESSAGES = 0x10, +}} +ENUM!{enum CWMO_FLAGS { + CWMO_DEFAULT = 0, + CWMO_DISPATCH_CALLS = 1, + CWMO_DISPATCH_WINDOW_MESSAGES = 2, +}} +extern "system" { + pub fn CoWaitForMultipleObjects( + dwFlags: DWORD, + dwTimeout: DWORD, + cHandles: ULONG, + pHandles: *const HANDLE, + lpdwindex: LPDWORD, + ) -> HRESULT; +} +pub const CWMO_MAX_HANDLES: ULONG = 56; +extern "system" { + pub fn CoGetTreatAsClass( + clsidOld: REFCLSID, + pClsidNew: LPCLSID, + ) -> HRESULT; + pub fn CoInvalidateRemoteMachineBindings( + pszMachineName: LPOLESTR, + ) -> HRESULT; +} +ENUM!{enum AgileReferenceOptions { + AGILEREFERENCE_DEFAULT = 0, + AGILEREFERENCE_DELAYEDMARSHAL = 1, +}} +extern "system" { + pub fn RoGetAgileReference( + options: AgileReferenceOptions, + riid: REFIID, + pUnk: *mut IUnknown, + ppAgileReference: *mut *mut IAgileReference, + ) -> HRESULT; +} +FN!{stdcall LPFNGETCLASSOBJECT( + REFCLSID, + REFIID, + *mut LPVOID, +) -> HRESULT} +FN!{stdcall LPFNCANUNLOADNOW() -> HRESULT} +extern "system" { + pub fn DllGetClassObject( + rclsid: REFCLSID, + riid: REFIID, + ppv: *mut LPVOID, + ) -> HRESULT; + pub fn DllCanUnloadNow() -> HRESULT; + pub fn CoTaskMemAlloc( + cb: SIZE_T, + ) -> LPVOID; + pub fn CoTaskMemRealloc( + pv: LPVOID, + cb: SIZE_T, + ) -> LPVOID; + pub fn CoTaskMemFree( + pv: LPVOID, + ); + pub fn CoFileTimeNow( + lpFileTime: *mut FILETIME, + ) -> HRESULT; + pub fn CLSIDFromProgIDEx( + lpszProgID: LPCOLESTR, + lpclsid: LPCLSID, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/coml2api.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/coml2api.rs new file mode 100644 index 0000000..449be87 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/coml2api.rs @@ -0,0 +1,10 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! Structured storage, property sets, and related APIs. +use shared::minwindef::DWORD; +pub const STGM_READ: DWORD = 0x00000000; +pub const STGM_WRITE: DWORD = 0x00000001; +pub const STGM_READWRITE: DWORD = 0x00000002; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/commapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/commapi.rs new file mode 100644 index 0000000..433bb78 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/commapi.rs @@ -0,0 +1,87 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_char; +use shared::minwindef::{BOOL, DWORD, LPDWORD}; +use um::minwinbase::LPOVERLAPPED; +use um::winbase::{LPCOMMCONFIG, LPCOMMPROP, LPCOMMTIMEOUTS, LPCOMSTAT, LPDCB}; +use um::winnt::HANDLE; +extern "system" { + pub fn ClearCommBreak( + hFile: HANDLE, + ) -> BOOL; + pub fn ClearCommError( + hFile: HANDLE, + lpErrors: LPDWORD, + lpStat: LPCOMSTAT, + ) -> BOOL; + pub fn SetupComm( + hFile: HANDLE, + dwInQueue: DWORD, + dwOutQueue: DWORD, + ) -> BOOL; + pub fn EscapeCommFunction( + hFile: HANDLE, + dwFunc: DWORD, + ) -> BOOL; + pub fn GetCommConfig( + hCommDev: HANDLE, + lpCC: LPCOMMCONFIG, + lpdwSize: LPDWORD, + ) -> BOOL; + pub fn GetCommMask( + hFile: HANDLE, + lpEvtMask: LPDWORD, + ) -> BOOL; + pub fn GetCommModemStatus( + hFile: HANDLE, + lpModemStat: LPDWORD, + ) -> BOOL; + pub fn GetCommProperties( + hFile: HANDLE, + lpCommProp: LPCOMMPROP, + ) -> BOOL; + pub fn GetCommState( + hFile: HANDLE, + lpDCB: LPDCB, + ) -> BOOL; + pub fn GetCommTimeouts( + hFile: HANDLE, + lpCommTimeouts: LPCOMMTIMEOUTS, + ) -> BOOL; + pub fn PurgeComm( + hFile: HANDLE, + dwFlags: DWORD, + ) -> BOOL; + pub fn SetCommBreak( + hFile: HANDLE, + ) -> BOOL; + pub fn SetCommConfig( + hCommDev: HANDLE, + lpCC: LPCOMMCONFIG, + dwSize: DWORD, + ) -> BOOL; + pub fn SetCommMask( + hFile: HANDLE, + dwEvtMask: DWORD, + ) -> BOOL; + pub fn SetCommState( + hFile: HANDLE, + lpDCB: LPDCB, + ) -> BOOL; + pub fn SetCommTimeouts( + hFile: HANDLE, + lpCommTimeouts: LPCOMMTIMEOUTS, + ) -> BOOL; + pub fn TransmitCommChar( + hFile: HANDLE, + cChar: c_char, + ) -> BOOL; + pub fn WaitCommEvent( + hFile: HANDLE, + lpEvtMask: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/commctrl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/commctrl.rs new file mode 100644 index 0000000..ad92fb1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/commctrl.rs @@ -0,0 +1,4135 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_char, c_int, c_long, c_short, c_void}; +use shared::basetsd::{DWORD_PTR, INT_PTR, LONG_PTR, UINT_PTR}; +#[cfg(target_pointer_width = "64")] use shared::basetsd::PINT_PTR; +use shared::guiddef::{IID, REFIID}; +use shared::minwindef::{ + BOOL, BYTE, DWORD, HINSTANCE, HKEY, INT, LPARAM, LPINT, LRESULT, PUINT, UINT, ULONG, WORD, + WPARAM, +}; +use shared::windef::{ + COLORREF, HBITMAP, HBRUSH, HDC, HICON, HMENU, HPEN, HWND, LPCRECT, LPRECT, POINT, RECT, SIZE, +}; +use um::commoncontrols::IImageList; +use um::minwinbase::SYSTEMTIME; +use um::winnt::{CHAR, LANGID, LONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PCWSTR, PVOID, PWSTR, WCHAR}; +use um::winuser::{ + CB_DELETESTRING, IMAGE_BITMAP, LPSCROLLINFO, LPTRACKMOUSEEVENT, NMHDR, + WINDOWPOS, WM_USER, +}; +use vc::vcruntime::size_t; +pub type HRESULT = c_long; +extern "system" { + pub fn InitCommonControls(); +} +//138 +STRUCT!{struct INITCOMMONCONTROLSEX { + dwSize: DWORD, + dwICC: DWORD, +}} +pub type LPINITCOMMONCONTROLSEX = *mut INITCOMMONCONTROLSEX; +pub const ICC_LISTVIEW_CLASSES: DWORD = 0x1; +pub const ICC_TREEVIEW_CLASSES: DWORD = 0x2; +pub const ICC_BAR_CLASSES: DWORD = 0x4; +pub const ICC_TAB_CLASSES: DWORD = 0x8; +pub const ICC_UPDOWN_CLASS: DWORD = 0x10; +pub const ICC_PROGRESS_CLASS: DWORD = 0x20; +pub const ICC_HOTKEY_CLASS: DWORD = 0x40; +pub const ICC_ANIMATE_CLASS: DWORD = 0x80; +pub const ICC_WIN95_CLASSES: DWORD = 0xFF; +pub const ICC_DATE_CLASSES: DWORD = 0x100; +pub const ICC_USEREX_CLASSES: DWORD = 0x200; +pub const ICC_COOL_CLASSES: DWORD = 0x400; +pub const ICC_INTERNET_CLASSES: DWORD = 0x800; +pub const ICC_PAGESCROLLER_CLASS: DWORD = 0x1000; +pub const ICC_NATIVEFNTCTL_CLASS: DWORD = 0x2000; +pub const ICC_STANDARD_CLASSES: DWORD = 0x4000; +pub const ICC_LINK_CLASS: DWORD = 0x8000; +extern "system" { + pub fn InitCommonControlsEx( + lpInitCtrls: *const INITCOMMONCONTROLSEX, + ) -> BOOL; +} +pub const ODT_HEADER: UINT = 100; +pub const ODT_TAB: UINT = 101; +pub const ODT_LISTVIEW: UINT = 102; +pub const LVM_FIRST: UINT = 0x1000; +pub const TV_FIRST: UINT = 0x1100; +pub const HDM_FIRST: UINT = 0x1200; +pub const TCM_FIRST: UINT = 0x1300; +pub const PGM_FIRST: UINT = 0x1400; +pub const ECM_FIRST: UINT = 0x1500; +pub const BCM_FIRST: UINT = 0x1600; +pub const CBM_FIRST: UINT = 0x1700; +pub const CCM_FIRST: UINT = 0x2000; +pub const CCM_LAST: UINT = CCM_FIRST + 0x200; +pub const CCM_SETBKCOLOR: UINT = CCM_FIRST + 1; +STRUCT!{struct COLORSCHEME { + dwSize: DWORD, + clrBtnHighlight: COLORREF, + clrBtnShadow: COLORREF, +}} +pub type LPCOLORSCHEME = *mut COLORSCHEME; +pub const CCM_SETCOLORSCHEME: UINT = CCM_FIRST + 2; +pub const CCM_GETCOLORSCHEME: UINT = CCM_FIRST + 3; +pub const CCM_GETDROPTARGET: UINT = CCM_FIRST + 4; +pub const CCM_SETUNICODEFORMAT: UINT = CCM_FIRST + 5; +pub const CCM_GETUNICODEFORMAT: UINT = CCM_FIRST + 6; +pub const CCM_SETVERSION: UINT = CCM_FIRST + 7; +pub const CCM_GETVERSION: UINT = CCM_FIRST + 8; +pub const CCM_SETNOTIFYWINDOW: UINT = CCM_FIRST + 9; +pub const CCM_SETWINDOWTHEME: UINT = CCM_FIRST + 0xb; +pub const CCM_DPISCALE: UINT = CCM_FIRST + 0xc; +pub const INFOTIPSIZE: c_int = 1024; +pub const NM_OUTOFMEMORY: UINT = (NM_FIRST as i32 - 1) as u32; +pub const NM_CLICK: UINT = (NM_FIRST as i32 - 2) as u32; +pub const NM_DBLCLK: UINT = (NM_FIRST as i32 - 3) as u32; +pub const NM_RETURN: UINT = (NM_FIRST as i32 - 4) as u32; +pub const NM_RCLICK: UINT = (NM_FIRST as i32 - 5) as u32; +pub const NM_RDBLCLK: UINT = (NM_FIRST as i32 - 6) as u32; +pub const NM_SETFOCUS: UINT = (NM_FIRST as i32 - 7) as u32; +pub const NM_KILLFOCUS: UINT = (NM_FIRST as i32 - 8) as u32; +pub const NM_CUSTOMDRAW: UINT = (NM_FIRST as i32 - 12) as u32; +pub const NM_HOVER: UINT = (NM_FIRST as i32 - 13) as u32; +pub const NM_NCHITTEST: UINT = (NM_FIRST as i32 - 14) as u32; +pub const NM_KEYDOWN: UINT = (NM_FIRST as i32 - 15) as u32; +pub const NM_RELEASEDCAPTURE: UINT = (NM_FIRST as i32 - 16) as u32; +pub const NM_SETCURSOR: UINT = (NM_FIRST as i32 - 17) as u32; +pub const NM_CHAR: UINT = (NM_FIRST as i32 - 18) as u32; +pub const NM_TOOLTIPSCREATED: UINT = (NM_FIRST as i32 - 19) as u32; +pub const NM_LDOWN: UINT = (NM_FIRST as i32 - 20) as u32; +pub const NM_RDOWN: UINT = (NM_FIRST as i32 - 21) as u32; +pub const NM_THEMECHANGED: UINT = (NM_FIRST as i32 - 22) as u32; +pub const NM_FONTCHANGED: UINT = (NM_FIRST as i32 - 23) as u32; +pub const NM_CUSTOMTEXT: UINT = (NM_FIRST as i32 - 24) as u32; +pub const NM_TVSTATEIMAGECHANGING: UINT = (NM_FIRST as i32 - 24) as u32; +STRUCT!{struct NMTOOLTIPSCREATED { + hdr: NMHDR, + hwndToolTips: HWND, +}} +pub type LPNMTOOLTIPSCREATED = *mut NMTOOLTIPSCREATED; +STRUCT!{struct NMMOUSE { + hdr: NMHDR, + dwItemSpec: DWORD_PTR, + dwItemData: DWORD_PTR, + pt: POINT, + dwHitInfo: LPARAM, +}} +pub type LPNMMOUSE = *mut NMMOUSE; +pub type NMCLICK = NMMOUSE; +pub type LPNMCLICK = LPNMMOUSE; +STRUCT!{struct NMOBJECTNOTIFY { + hdr: NMHDR, + iItem: c_int, + piid: *const IID, + pObject: *mut c_void, + hResult: HRESULT, + dwFlags: DWORD, +}} +pub type LPNMOBJECTNOTIFY = *mut NMOBJECTNOTIFY; +STRUCT!{struct NMKEY { + hdr: NMHDR, + nVKey: UINT, + uFlags: UINT, +}} +pub type LPNMKEY = *mut NMKEY; +STRUCT!{struct NMCHAR { + hdr: NMHDR, + ch: UINT, + dwItemPrev: DWORD, + dwItemNext: DWORD, +}} +pub type LPNMCHAR = *mut NMCHAR; +STRUCT!{struct NMCUSTOMTEXT { + hdr: NMHDR, + hDC: HDC, + lpString: LPCWSTR, + nCount: c_int, + lpRect: LPRECT, + uFormat: UINT, + fLink: BOOL, +}} +pub type LPNMCUSTOMTEXT = *mut NMCUSTOMTEXT; +pub const NM_FIRST: UINT = 0; +pub const NM_LAST: UINT = -99i32 as u32; +pub const LVN_FIRST: UINT = -100i32 as u32; +pub const LVN_LAST: UINT = -199i32 as u32; +pub const HDN_FIRST: UINT = -300i32 as u32; +pub const HDN_LAST: UINT = -399i32 as u32; +pub const TVN_FIRST: UINT = -400i32 as u32; +pub const TVN_LAST: UINT = -499i32 as u32; +pub const TTN_FIRST: UINT = -520i32 as u32; +pub const TTN_LAST: UINT = -549i32 as u32; +pub const TCN_FIRST: UINT = -550i32 as u32; +pub const TCN_LAST: UINT = -580i32 as u32; +pub const CDN_FIRST: UINT = -601i32 as u32; +pub const CDN_LAST: UINT = -699i32 as u32; +pub const TBN_FIRST: UINT = -700i32 as u32; +pub const TBN_LAST: UINT = -720i32 as u32; +pub const UDN_FIRST: UINT = -721i32 as u32; +pub const UDN_LAST: UINT = -729i32 as u32; +pub const DTN_FIRST: UINT = -740i32 as u32; +pub const DTN_LAST: UINT = -745i32 as u32; +pub const MCN_FIRST: UINT = -746i32 as u32; +pub const MCN_LAST: UINT = -752i32 as u32; +pub const DTN_FIRST2: UINT = -753i32 as u32; +pub const DTN_LAST2: UINT = -799i32 as u32; +pub const CBEN_FIRST: UINT = -800i32 as u32; +pub const CBEN_LAST: UINT = -830i32 as u32; +pub const RBN_FIRST: UINT = -831i32 as u32; +pub const RBN_LAST: UINT = -859i32 as u32; +pub const IPN_FIRST: UINT = -860i32 as u32; +pub const IPN_LAST: UINT = -879i32 as u32; +pub const SBN_FIRST: UINT = -880i32 as u32; +pub const SBN_LAST: UINT = -899i32 as u32; +pub const PGN_FIRST: UINT = -900i32 as u32; +pub const PGN_LAST: UINT = -950i32 as u32; +pub const WMN_FIRST: UINT = -1000i32 as u32; +pub const WMN_LAST: UINT = -1200i32 as u32; +pub const BCN_FIRST: UINT = -1250i32 as u32; +pub const BCN_LAST: UINT = -1350i32 as u32; +pub const TRBN_FIRST: UINT = -1501i32 as u32; +pub const TRBN_LAST: UINT = -1519i32 as u32; +pub const MSGF_COMMCTRL_BEGINDRAG: c_int = 0x4200; +pub const MSGF_COMMCTRL_SIZEHEADER: c_int = 0x4201; +pub const MSGF_COMMCTRL_DRAGSELECT: c_int = 0x4202; +pub const MSGF_COMMCTRL_TOOLBARCUST: c_int = 0x4203; +pub const CDRF_DODEFAULT: LRESULT = 0x00000000; +pub const CDRF_NEWFONT: LRESULT = 0x00000002; +pub const CDRF_SKIPDEFAULT: LRESULT = 0x00000004; +pub const CDRF_DOERASE: LRESULT = 0x00000008; +pub const CDRF_SKIPPOSTPAINT: LRESULT = 0x00000100; +pub const CDRF_NOTIFYPOSTPAINT: LRESULT = 0x00000010; +pub const CDRF_NOTIFYITEMDRAW: LRESULT = 0x00000020; +pub const CDRF_NOTIFYSUBITEMDRAW: LRESULT = 0x00000020; +pub const CDRF_NOTIFYPOSTERASE: LRESULT = 0x00000040; +pub const CDDS_PREPAINT: DWORD = 0x00000001; +pub const CDDS_POSTPAINT: DWORD = 0x00000002; +pub const CDDS_PREERASE: DWORD = 0x00000003; +pub const CDDS_POSTERASE: DWORD = 0x00000004; +pub const CDDS_ITEM: DWORD = 0x00010000; +pub const CDDS_ITEMPREPAINT: DWORD = CDDS_ITEM | CDDS_PREPAINT; +pub const CDDS_ITEMPOSTPAINT: DWORD = CDDS_ITEM | CDDS_POSTPAINT; +pub const CDDS_ITEMPREERASE: DWORD = CDDS_ITEM | CDDS_PREERASE; +pub const CDDS_ITEMPOSTERASE: DWORD = CDDS_ITEM | CDDS_POSTERASE; +pub const CDDS_SUBITEM: DWORD = 0x00020000; +pub const CDIS_SELECTED: UINT = 0x0001; +pub const CDIS_GRAYED: UINT = 0x0002; +pub const CDIS_DISABLED: UINT = 0x0004; +pub const CDIS_CHECKED: UINT = 0x0008; +pub const CDIS_FOCUS: UINT = 0x0010; +pub const CDIS_DEFAULT: UINT = 0x0020; +pub const CDIS_HOT: UINT = 0x0040; +pub const CDIS_MARKED: UINT = 0x0080; +pub const CDIS_INDETERMINATE: UINT = 0x0100; +pub const CDIS_SHOWKEYBOARDCUES: UINT = 0x0200; +pub const CDIS_NEARHOT: UINT = 0x0400; +pub const CDIS_OTHERSIDEHOT: UINT = 0x0800; +pub const CDIS_DROPHILITED: UINT = 0x1000; +STRUCT!{struct NMCUSTOMDRAW { + hdr: NMHDR, + dwDrawStage: DWORD, + hdc: HDC, + rc: RECT, + dwItemSpec: DWORD_PTR, + uItemState: UINT, + lItemlParam: LPARAM, +}} +pub type LPNMCUSTOMDRAW = *mut NMCUSTOMDRAW; +STRUCT!{struct NMTTCUSTOMDRAW { + nmcd: NMCUSTOMDRAW, + uDrawFlags: UINT, +}} +pub type LPNMTTCUSTOMDRAW = *mut NMTTCUSTOMDRAW; +STRUCT!{struct NMCUSTOMSPLITRECTINFO { + hdr: NMHDR, + rcClient: RECT, + rcButton: RECT, + rcSplit: RECT, +}} +pub type LPNMCUSTOMSPLITRECTINFO = *mut NMCUSTOMSPLITRECTINFO; +pub const NM_GETCUSTOMSPLITRECT: UINT = BCN_FIRST + 0x0003; +pub const CLR_NONE: DWORD = 0xFFFFFFFF; +pub const CLR_DEFAULT: DWORD = 0xFF000000; +pub enum IMAGELIST {} +pub type HIMAGELIST = *mut IMAGELIST; +STRUCT!{struct IMAGELISTDRAWPARAMS { + cbSize: DWORD, + himl: HIMAGELIST, + i: c_int, + hdcDst: HDC, + x: c_int, + y: c_int, + cx: c_int, + cy: c_int, + xBitmap: c_int, + yBitmap: c_int, + rgbBk: COLORREF, + rgbFg: COLORREF, + fStyle: UINT, + dwRop: DWORD, + fState: DWORD, + Frame: DWORD, + crEffect: COLORREF, +}} +pub type LPIMAGELISTDRAWPARAMS = *mut IMAGELISTDRAWPARAMS; +pub const ILC_MASK: UINT = 0x00000001; +pub const ILC_COLOR: UINT = 0x00000000; +pub const ILC_COLORDDB: UINT = 0x000000FE; +pub const ILC_COLOR4: UINT = 0x00000004; +pub const ILC_COLOR8: UINT = 0x00000008; +pub const ILC_COLOR16: UINT = 0x00000010; +pub const ILC_COLOR24: UINT = 0x00000018; +pub const ILC_COLOR32: UINT = 0x00000020; +pub const ILC_PALETTE: UINT = 0x00000800; +pub const ILC_MIRROR: UINT = 0x00002000; +pub const ILC_PERITEMMIRROR: UINT = 0x00008000; +pub const ILC_ORIGINALSIZE: UINT = 0x00010000; +pub const ILC_HIGHQUALITYSCALE: UINT = 0x00020000; +extern "system" { + pub fn ImageList_Create( + cx: c_int, + cy: c_int, + flags: UINT, + cInitial: c_int, + cGrow: c_int, + ) -> HIMAGELIST; + pub fn ImageList_Destroy( + himl: HIMAGELIST, + ) -> BOOL; + pub fn ImageList_GetImageCount( + himl: HIMAGELIST, + ) -> c_int; + pub fn ImageList_SetImageCount( + himl: HIMAGELIST, + uNewCount: UINT, + ) -> BOOL; + pub fn ImageList_Add( + himl: HIMAGELIST, + hbmImage: HBITMAP, + hbmMask: HBITMAP, + ) -> c_int; + pub fn ImageList_ReplaceIcon( + himl: HIMAGELIST, + i: c_int, + hicon: HICON, + ) -> c_int; + pub fn ImageList_SetBkColor( + himl: HIMAGELIST, + clrBk: COLORREF, + ) -> COLORREF; + pub fn ImageList_GetBkColor( + himl: HIMAGELIST, + ) -> COLORREF; + pub fn ImageList_SetOverlayImage( + himl: HIMAGELIST, + iImage: c_int, + iOverlay: c_int, + ) -> BOOL; +} +#[inline] +pub unsafe fn ImageList_AddIcon(himl: HIMAGELIST, hicon: HICON) -> c_int { + ImageList_ReplaceIcon(himl, -1, hicon) +} +pub const ILD_NORMAL: UINT = 0x00000000; +pub const ILD_TRANSPARENT: UINT = 0x00000001; +pub const ILD_MASK: UINT = 0x00000010; +pub const ILD_IMAGE: UINT = 0x00000020; +pub const ILD_ROP: UINT = 0x00000040; +pub const ILD_BLEND25: UINT = 0x00000002; +pub const ILD_BLEND50: UINT = 0x00000004; +pub const ILD_OVERLAYMASK: UINT = 0x00000F00; +#[inline] +pub fn INDEXTOOVERLAYMASK(i: UINT) -> UINT { + i << 8 +} +pub const ILD_PRESERVEALPHA: UINT = 0x00001000; +pub const ILD_SCALE: UINT = 0x00002000; +pub const ILD_DPISCALE: UINT = 0x00004000; +pub const ILD_ASYNC: UINT = 0x00008000; +pub const ILD_SELECTED: UINT = ILD_BLEND50; +pub const ILD_FOCUS: UINT = ILD_BLEND25; +pub const ILD_BLEND: UINT = ILD_BLEND50; +pub const CLR_HILIGHT: DWORD = CLR_DEFAULT; +pub const ILS_NORMAL: DWORD = 0x00000000; +pub const ILS_GLOW: DWORD = 0x00000001; +pub const ILS_SHADOW: DWORD = 0x00000002; +pub const ILS_SATURATE: DWORD = 0x00000004; +pub const ILS_ALPHA: DWORD = 0x00000008; +pub const ILGT_NORMAL: DWORD = 0x00000000; +pub const ILGT_ASYNC : DWORD = 0x00000001; +extern "system" { + pub fn ImageList_Draw( + himl: HIMAGELIST, + i: c_int, + hdcDst: HDC, + x: c_int, + y: c_int, + fStyle: UINT, + ) -> BOOL; +} +pub const HBITMAP_CALLBACK: HBITMAP = -1isize as HBITMAP; +extern "system" { + pub fn ImageList_Replace( + himl: HIMAGELIST, + i: c_int, + hbmImage: HBITMAP, + hbmMask: HBITMAP, + ) -> BOOL; + pub fn ImageList_AddMasked( + himl: HIMAGELIST, + hbmImage: HBITMAP, + crMask: COLORREF, + ) -> c_int; + pub fn ImageList_DrawEx( + himl: HIMAGELIST, + i: c_int, + hdcDst: HDC, + x: c_int, + y: c_int, + dx: c_int, + dy: c_int, + rgbBk: COLORREF, + rgbFg: COLORREF, + fStyle: UINT, + ) -> BOOL; + pub fn ImageList_DrawIndirect( + pimldp: *mut IMAGELISTDRAWPARAMS, + ) -> BOOL; + pub fn ImageList_Remove( + himl: HIMAGELIST, + i: c_int, + ) -> BOOL; + pub fn ImageList_GetIcon( + himl: HIMAGELIST, + i: c_int, + flags: UINT, + ) -> HICON; + pub fn ImageList_LoadImageA( + hi: HINSTANCE, + lpbmp: LPCSTR, + cx: c_int, + cGrow: c_int, + crMask: COLORREF, + uType: UINT, + uFlags: UINT, + ) -> HIMAGELIST; + pub fn ImageList_LoadImageW( + hi: HINSTANCE, + lpbmp: LPCWSTR, + cx: c_int, + cGrow: c_int, + crMask: COLORREF, + uType: UINT, + uFlags: UINT, + ) -> HIMAGELIST; +} +pub const ILCF_MOVE: UINT = 0x00000000; +pub const ILCF_SWAP: UINT = 0x00000001; +extern "system" { + pub fn ImageList_Copy( + himlDst: HIMAGELIST, + iDst: c_int, + himlSrc: HIMAGELIST, + iSrc: c_int, + uFlags: UINT, + ) -> BOOL; + pub fn ImageList_BeginDrag( + himlTrack: HIMAGELIST, + iTrack: c_int, + dxHotspot: c_int, + dyHotspot: c_int, + ) -> BOOL; + pub fn ImageList_EndDrag(); + pub fn ImageList_DragEnter( + hwndLock: HWND, + x: c_int, + y: c_int, + ) -> BOOL; + pub fn ImageList_DragLeave( + hwndLock: HWND, + ) -> BOOL; + pub fn ImageList_DragMove( + x: c_int, + y: c_int, + ) -> BOOL; + pub fn ImageList_SetDragCursorImage( + himlDrag: HIMAGELIST, + iDrag: c_int, + dxHotspot: c_int, + dyHotspot: c_int, + ) -> BOOL; + pub fn ImageList_DragShowNolock( + fShow: BOOL, + ) -> BOOL; + pub fn ImageList_GetDragImage( + ppt: *mut POINT, + pptHotspot: *mut POINT, + ) -> HIMAGELIST; +} +#[inline] +pub unsafe fn ImageList_RemoveAll(himl: HIMAGELIST) -> BOOL { + ImageList_Remove(himl, -1) +} +#[inline] +pub unsafe fn ImageList_ExtractIcon(_: HINSTANCE, himl: HIMAGELIST, i: c_int) -> HICON { + ImageList_GetIcon(himl, i, 0) +} +#[inline] +pub unsafe fn ImageList_LoadBitmap( + hi: HINSTANCE, + lpbmp: LPCWSTR, + cx: c_int, + cGrow: c_int, + crMask: COLORREF, +) -> HIMAGELIST { + ImageList_LoadImageW(hi, lpbmp, cx, cGrow, crMask, IMAGE_BITMAP, 0) +} +pub enum IStream {} +extern "system" { + pub fn ImageList_Read( + pstm: *mut IStream, + ) -> HIMAGELIST; + pub fn ImageList_Write( + himl: HIMAGELIST, + pstm: *mut IStream, + ) -> BOOL; +} +pub const ILP_NORMAL: DWORD = 0; +pub const ILP_DOWNLEVEL: DWORD = 0; +extern "system" { + pub fn ImageList_ReadEx( + dwFlags: DWORD, + pstm: *mut IStream, + riid: REFIID, + ppv: *mut PVOID, + ) -> HRESULT; + pub fn ImageList_WriteEx( + himl: HIMAGELIST, + dwFlags: DWORD, + pstm: *mut IStream, + ) -> HRESULT; +} +STRUCT!{struct IMAGEINFO { + hbmImage: HBITMAP, + hbmMask: HBITMAP, + Unused1: c_int, + Unused2: c_int, + rcImage: RECT, +}} +pub type LPIMAGEINFO = *mut IMAGEINFO; +extern "system" { + pub fn ImageList_GetIconSize( + himl: HIMAGELIST, + cx: *mut c_int, + cy: *mut c_int, + ) -> BOOL; + pub fn ImageList_SetIconSize( + himl: HIMAGELIST, + cx: c_int, + cy: c_int, + ) -> BOOL; + pub fn ImageList_GetImageInfo( + himl: HIMAGELIST, + i: c_int, + pImageInfo: *mut IMAGEINFO, + ) -> BOOL; + pub fn ImageList_Merge( + himl1: HIMAGELIST, + i1: c_int, + himl2: HIMAGELIST, + i2: c_int, + dx: c_int, + dy: c_int, + ) -> HIMAGELIST; + pub fn ImageList_Duplicate( + himl: HIMAGELIST, + ) -> HIMAGELIST; + pub fn HIMAGELIST_QueryInterface( + himl: HIMAGELIST, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT; +} +#[inline] +pub fn IImageListToHIMAGELIST(himl: *mut IImageList) -> HIMAGELIST { + himl as HIMAGELIST +} +pub const WC_HEADER: &'static str = "SysHeader32"; +pub const HDS_HORZ: DWORD = 0x0000; +pub const HDS_BUTTONS: DWORD = 0x0002; +pub const HDS_HOTTRACK: DWORD = 0x0004; +pub const HDS_HIDDEN: DWORD = 0x0008; +pub const HDS_DRAGDROP: DWORD = 0x0040; +pub const HDS_FULLDRAG: DWORD = 0x0080; +pub const HDS_FILTERBAR: DWORD = 0x0100; +pub const HDS_FLAT: DWORD = 0x0200; +pub const HDS_CHECKBOXES: DWORD = 0x0400; +pub const HDS_NOSIZING: DWORD = 0x0800; +pub const HDS_OVERFLOW: DWORD = 0x1000; +pub const HDFT_ISSTRING: UINT = 0x0000; +pub const HDFT_ISNUMBER: UINT = 0x0001; +pub const HDFT_ISDATE: UINT = 0x0002; +pub const HDFT_HASNOVALUE: UINT = 0x8000; +STRUCT!{struct HD_TEXTFILTERA { + pszText: LPSTR, + cchTextMax: INT, +}} +pub type LPHD_TEXTFILTERA = *mut HD_TEXTFILTERA; +STRUCT!{struct HD_TEXTFILTERW { + pszText: LPWSTR, + cchTextMax: INT, +}} +pub type LPHD_TEXTFILTERW = *mut HD_TEXTFILTERW; +STRUCT!{struct HDITEMA { + mask: UINT, + cxy: c_int, + pszText: LPSTR, + hbm: HBITMAP, + cchTextMax: c_int, + fmt: c_int, + lParam: LPARAM, + iImage: c_int, + iOrder: c_int, + _type: UINT, + pvFilter: *mut c_void, + state: UINT, +}} +pub type LPHDITEMA = *mut HDITEMA; +STRUCT!{struct HDITEMW { + mask: UINT, + cxy: c_int, + pszText: LPWSTR, + hbm: HBITMAP, + cchTextMax: c_int, + fmt: c_int, + lParam: LPARAM, + iImage: c_int, + iOrder: c_int, + _type: UINT, + pvFilter: *mut c_void, + state: UINT, +}} +pub type LPHDITEMW = *mut HDITEMW; +pub const HDI_WIDTH: UINT = 0x0001; +pub const HDI_HEIGHT: UINT = HDI_WIDTH; +pub const HDI_TEXT: UINT = 0x0002; +pub const HDI_FORMAT: UINT = 0x0004; +pub const HDI_LPARAM: UINT = 0x0008; +pub const HDI_BITMAP: UINT = 0x0010; +pub const HDI_IMAGE: UINT = 0x0020; +pub const HDI_DI_SETITEM: UINT = 0x0040; +pub const HDI_ORDER: UINT = 0x0080; +pub const HDI_FILTER: UINT = 0x0100; +pub const HDI_STATE: UINT = 0x0200; +pub const HDF_LEFT: c_int = 0x0000; +pub const HDF_RIGHT: c_int = 0x0001; +pub const HDF_CENTER: c_int = 0x0002; +pub const HDF_JUSTIFYMASK: c_int = 0x0003; +pub const HDF_RTLREADING: c_int = 0x0004; +pub const HDF_BITMAP: c_int = 0x2000; +pub const HDF_STRING: c_int = 0x4000; +pub const HDF_OWNERDRAW: c_int = 0x8000; +pub const HDF_IMAGE: c_int = 0x0800; +pub const HDF_BITMAP_ON_RIGHT: c_int = 0x1000; +pub const HDF_SORTUP: c_int = 0x0400; +pub const HDF_SORTDOWN: c_int = 0x0200; +pub const HDF_CHECKBOX: c_int = 0x0040; +pub const HDF_CHECKED: c_int = 0x0080; +pub const HDF_FIXEDWIDTH: c_int = 0x0100; +pub const HDF_SPLITBUTTON: c_int = 0x1000000; +pub const HDIS_FOCUSED: UINT = 0x00000001; +pub const HDM_GETITEMCOUNT: UINT = HDM_FIRST + 0; +pub const HDM_INSERTITEMA: UINT = HDM_FIRST + 1; +pub const HDM_INSERTITEMW: UINT = HDM_FIRST + 10; +pub const HDM_DELETEITEM: UINT = HDM_FIRST + 2; +pub const HDM_GETITEMA: UINT = HDM_FIRST + 3; +pub const HDM_GETITEMW: UINT = HDM_FIRST + 11; +pub const HDM_SETITEMA: UINT = HDM_FIRST + 4; +pub const HDM_SETITEMW: UINT = HDM_FIRST + 12; +STRUCT!{struct HDLAYOUT { + prc: *mut RECT, + pwpos: *mut WINDOWPOS, +}} +pub type LPHDLAYOUT = *mut HDLAYOUT; +pub const HDM_LAYOUT: UINT = HDM_FIRST + 5; +pub const HHT_NOWHERE: UINT = 0x0001; +pub const HHT_ONHEADER: UINT = 0x0002; +pub const HHT_ONDIVIDER: UINT = 0x0004; +pub const HHT_ONDIVOPEN: UINT = 0x0008; +pub const HHT_ONFILTER: UINT = 0x0010; +pub const HHT_ONFILTERBUTTON: UINT = 0x0020; +pub const HHT_ABOVE: UINT = 0x0100; +pub const HHT_BELOW: UINT = 0x0200; +pub const HHT_TORIGHT: UINT = 0x0400; +pub const HHT_TOLEFT: UINT = 0x0800; +pub const HHT_ONITEMSTATEICON: UINT = 0x1000; +pub const HHT_ONDROPDOWN: UINT = 0x2000; +pub const HHT_ONOVERFLOW: UINT = 0x4000; +STRUCT!{struct HDHITTESTINFO { + pt: POINT, + flags: UINT, + iItem: c_int, +}} +pub type LPHDHITTESTINFO = *mut HDHITTESTINFO; +pub type HD_HITTESTINFO = HDHITTESTINFO; +pub const HDSIL_NORMAL: WPARAM = 0; +pub const HDSIL_STATE: WPARAM = 1; +pub const HDM_HITTEST: UINT = HDM_FIRST + 6; +pub const HDM_GETITEMRECT: UINT = HDM_FIRST + 7; +pub const HDM_SETIMAGELIST: UINT = HDM_FIRST + 8; +pub const HDM_GETIMAGELIST: UINT = HDM_FIRST + 9; +pub const HDM_ORDERTOINDEX: UINT = HDM_FIRST + 15; +pub const HDM_CREATEDRAGIMAGE: UINT = HDM_FIRST + 16; +pub const HDM_GETORDERARRAY: UINT = HDM_FIRST + 17; +pub const HDM_SETORDERARRAY: UINT = HDM_FIRST + 18; +pub const HDM_SETHOTDIVIDER: UINT = HDM_FIRST + 19; +pub const HDM_SETBITMAPMARGIN: UINT = HDM_FIRST + 20; +pub const HDM_GETBITMAPMARGIN: UINT = HDM_FIRST + 21; +pub const HDM_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const HDM_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const HDM_SETFILTERCHANGETIMEOUT: UINT = HDM_FIRST + 22; +pub const HDM_EDITFILTER: UINT = HDM_FIRST + 23; +pub const HDM_CLEARFILTER: UINT = HDM_FIRST + 24; +pub const HDM_GETITEMDROPDOWNRECT: UINT = HDM_FIRST + 25; +pub const HDM_GETOVERFLOWRECT: UINT = HDM_FIRST + 26; +pub const HDM_GETFOCUSEDITEM: UINT = HDM_FIRST + 27; +pub const HDM_SETFOCUSEDITEM: UINT = HDM_FIRST + 28; +pub const HDN_ITEMCHANGINGA: UINT = HDN_FIRST - 0; +pub const HDN_ITEMCHANGINGW: UINT = HDN_FIRST - 20; +pub const HDN_ITEMCHANGEDA: UINT = HDN_FIRST - 1; +pub const HDN_ITEMCHANGEDW: UINT = HDN_FIRST - 21; +pub const HDN_ITEMCLICKA: UINT = HDN_FIRST - 2; +pub const HDN_ITEMCLICKW: UINT = HDN_FIRST - 22; +pub const HDN_ITEMDBLCLICKA: UINT = HDN_FIRST - 3; +pub const HDN_ITEMDBLCLICKW: UINT = HDN_FIRST - 23; +pub const HDN_DIVIDERDBLCLICKA: UINT = HDN_FIRST - 5; +pub const HDN_DIVIDERDBLCLICKW: UINT = HDN_FIRST - 25; +pub const HDN_BEGINTRACKA: UINT = HDN_FIRST - 6; +pub const HDN_BEGINTRACKW: UINT = HDN_FIRST - 26; +pub const HDN_ENDTRACKA: UINT = HDN_FIRST - 7; +pub const HDN_ENDTRACKW: UINT = HDN_FIRST - 27; +pub const HDN_TRACKA: UINT = HDN_FIRST - 8; +pub const HDN_TRACKW: UINT = HDN_FIRST - 28; +pub const HDN_GETDISPINFOA: UINT = HDN_FIRST - 9; +pub const HDN_GETDISPINFOW: UINT = HDN_FIRST - 29; +pub const HDN_BEGINDRAG: UINT = HDN_FIRST - 10; +pub const HDN_ENDDRAG: UINT = HDN_FIRST - 11; +pub const HDN_FILTERCHANGE: UINT = HDN_FIRST - 12; +pub const HDN_FILTERBTNCLICK: UINT = HDN_FIRST - 13; +pub const HDN_BEGINFILTEREDIT: UINT = HDN_FIRST - 14; +pub const HDN_ENDFILTEREDIT: UINT = HDN_FIRST - 15; +pub const HDN_ITEMSTATEICONCLICK: UINT = HDN_FIRST - 16; +pub const HDN_ITEMKEYDOWN: UINT = HDN_FIRST - 17; +pub const HDN_DROPDOWN: UINT = HDN_FIRST - 18; +pub const HDN_OVERFLOWCLICK: UINT = HDN_FIRST - 19; +STRUCT!{struct NMHEADERA { + hdr: NMHDR, + iItem: c_int, + iButton: c_int, + pitem: *mut HDITEMA, +}} +pub type LPNMHEADERA = *mut NMHEADERA; +pub type HD_NOTIFYA = NMHEADERA; +STRUCT!{struct NMHEADERW { + hdr: NMHDR, + iItem: c_int, + iButton: c_int, + pitem: *mut HDITEMW, +}} +pub type LPNMHEADERW = *mut NMHEADERW; +pub type HD_NOTIFYW = NMHEADERW; +STRUCT!{struct NMHDDISPINFOW { + hdr: NMHDR, + iItem: c_int, + mask: UINT, + pszText: LPWSTR, + cchTextMax: c_int, + iImage: c_int, + lParam: LPARAM, +}} +pub type LPNMHDDISPINFOW = *mut NMHDDISPINFOW; +STRUCT!{struct NMHDDISPINFOA { + hdr: NMHDR, + iItem: c_int, + mask: UINT, + pszText: LPSTR, + cchTextMax: c_int, + iImage: c_int, + lParam: LPARAM, +}} +pub type LPNMHDDISPINFOA = *mut NMHDDISPINFOA; +STRUCT!{struct NMHDFILTERBTNCLICK { + hdr: NMHDR, + iItem: INT, + rc: RECT, +}} +pub type LPNMHDFILTERBTNCLICK = *mut NMHDFILTERBTNCLICK; +pub const TOOLBARCLASSNAME: &'static str = "ToolbarWindow32"; +#[cfg(target_pointer_width = "32")] +STRUCT!{struct TBBUTTON { + iBitmap: c_int, + idCommand: c_int, + fsState: BYTE, + fsStyle: BYTE, + bReserved: [BYTE; 2], + dwData: DWORD_PTR, + iString: INT_PTR, +}} +#[cfg(target_pointer_width = "64")] +STRUCT!{struct TBBUTTON { + iBitmap: c_int, + idCommand: c_int, + fsState: BYTE, + fsStyle: BYTE, + bReserved: [BYTE; 6], + dwData: DWORD_PTR, + iString: INT_PTR, +}} +pub type PTBBUTTON = *mut TBBUTTON; +pub type LPTBBUTTON = *mut TBBUTTON; +pub type LPCTBBUTTON = *const TBBUTTON; +STRUCT!{struct COLORMAP { + from: COLORREF, + to: COLORREF, +}} +pub type LPCOLORMAP = *mut COLORMAP; +extern "system" { + pub fn CreateToolbarEx( + hwnd: HWND, + ws: DWORD, + wID: UINT, + nBitmaps: c_int, + hBMInst: HINSTANCE, + wBMID: UINT_PTR, + lpButtons: LPCTBBUTTON, + iNumButtons: c_int, + dxButton: c_int, + dyButton: c_int, + dxBitmap: c_int, + dyBitmap: c_int, + uStructSize: UINT, + ) -> HWND; + pub fn CreateMappedBitmap( + hInstance: HINSTANCE, + idBitmap: INT_PTR, + wFlags: UINT, + lpColorMap: LPCOLORMAP, + iNumMaps: c_int, + ) -> HBITMAP; +} +pub const CMB_MASKED: UINT = 0x02; +pub const TBSTATE_CHECKED: BYTE = 0x01; +pub const TBSTATE_PRESSED: BYTE = 0x02; +pub const TBSTATE_ENABLED: BYTE = 0x04; +pub const TBSTATE_HIDDEN: BYTE = 0x08; +pub const TBSTATE_INDETERMINATE: BYTE = 0x10; +pub const TBSTATE_WRAP: BYTE = 0x20; +pub const TBSTATE_ELLIPSES: BYTE = 0x40; +pub const TBSTATE_MARKED: BYTE = 0x80; +pub const TBSTYLE_BUTTON: DWORD = 0x0000; +pub const TBSTYLE_SEP: DWORD = 0x0001; +pub const TBSTYLE_CHECK: DWORD = 0x0002; +pub const TBSTYLE_GROUP: DWORD = 0x0004; +pub const TBSTYLE_CHECKGROUP: DWORD = TBSTYLE_GROUP | TBSTYLE_CHECK; +pub const TBSTYLE_DROPDOWN: DWORD = 0x0008; +pub const TBSTYLE_AUTOSIZE: DWORD = 0x0010; +pub const TBSTYLE_NOPREFIX: DWORD = 0x0020; +pub const TBSTYLE_TOOLTIPS: DWORD = 0x0100; +pub const TBSTYLE_WRAPABLE: DWORD = 0x0200; +pub const TBSTYLE_ALTDRAG: DWORD = 0x0400; +pub const TBSTYLE_FLAT: DWORD = 0x0800; +pub const TBSTYLE_LIST: DWORD = 0x1000; +pub const TBSTYLE_CUSTOMERASE: DWORD = 0x2000; +pub const TBSTYLE_REGISTERDROP: DWORD = 0x4000; +pub const TBSTYLE_TRANSPARENT: DWORD = 0x8000; +pub const TBSTYLE_EX_DRAWDDARROWS: DWORD = 0x00000001; +pub const BTNS_BUTTON: DWORD = TBSTYLE_BUTTON; +pub const BTNS_SEP: DWORD = TBSTYLE_SEP; +pub const BTNS_CHECK: DWORD = TBSTYLE_CHECK; +pub const BTNS_GROUP: DWORD = TBSTYLE_GROUP; +pub const BTNS_CHECKGROUP: DWORD = TBSTYLE_CHECKGROUP; +pub const BTNS_DROPDOWN: DWORD = TBSTYLE_DROPDOWN; +pub const BTNS_AUTOSIZE: DWORD = TBSTYLE_AUTOSIZE; +pub const BTNS_NOPREFIX: DWORD = TBSTYLE_NOPREFIX; +pub const BTNS_SHOWTEXT: DWORD = 0x0040; +pub const BTNS_WHOLEDROPDOWN: DWORD = 0x0080; +pub const TBSTYLE_EX_MIXEDBUTTONS: DWORD = 0x00000008; +pub const TBSTYLE_EX_HIDECLIPPEDBUTTONS: DWORD = 0x00000010; +pub const TBSTYLE_EX_MULTICOLUMN: DWORD = 0x00000002; +pub const TBSTYLE_EX_VERTICAL: DWORD = 0x00000004; +pub const TBSTYLE_EX_DOUBLEBUFFER: DWORD = 0x00000080; +STRUCT!{struct NMTBCUSTOMDRAW { + nmcd: NMCUSTOMDRAW, + hbrMonoDither: HBRUSH, + hbrLines: HBRUSH, + hpenLines: HPEN, + clrText: COLORREF, + clrMark: COLORREF, + clrTextHighlight: COLORREF, + clrBtnFace: COLORREF, + clrBtnHighlight: COLORREF, + clrHighlightHotTrack: COLORREF, + rcText: RECT, + nStringBkMode: c_int, + nHLStringBkMode: c_int, + iListGap: c_int, +}} +pub type LPNMTBCUSTOMDRAW = *mut NMTBCUSTOMDRAW; +pub const TBCDRF_NOEDGES: LRESULT = 0x00010000; +pub const TBCDRF_HILITEHOTTRACK: LRESULT = 0x00020000; +pub const TBCDRF_NOOFFSET: LRESULT = 0x00040000; +pub const TBCDRF_NOMARK: LRESULT = 0x00080000; +pub const TBCDRF_NOETCHEDEFFECT: LRESULT = 0x00100000; +pub const TBCDRF_BLENDICON: LRESULT = 0x00200000; +pub const TBCDRF_NOBACKGROUND: LRESULT = 0x00400000; +pub const TBCDRF_USECDCOLORS: LRESULT = 0x00800000; +pub const TB_ENABLEBUTTON: UINT = WM_USER + 1; +pub const TB_CHECKBUTTON: UINT = WM_USER + 2; +pub const TB_PRESSBUTTON: UINT = WM_USER + 3; +pub const TB_HIDEBUTTON: UINT = WM_USER + 4; +pub const TB_INDETERMINATE: UINT = WM_USER + 5; +pub const TB_MARKBUTTON: UINT = WM_USER + 6; +pub const TB_ISBUTTONENABLED: UINT = WM_USER + 9; +pub const TB_ISBUTTONCHECKED: UINT = WM_USER + 10; +pub const TB_ISBUTTONPRESSED: UINT = WM_USER + 11; +pub const TB_ISBUTTONHIDDEN: UINT = WM_USER + 12; +pub const TB_ISBUTTONINDETERMINATE: UINT = WM_USER + 13; +pub const TB_ISBUTTONHIGHLIGHTED: UINT = WM_USER + 14; +pub const TB_SETSTATE: UINT = WM_USER + 17; +pub const TB_GETSTATE: UINT = WM_USER + 18; +pub const TB_ADDBITMAP: UINT = WM_USER + 19; +STRUCT!{struct TBADDBITMAP { + hInst: HINSTANCE, + nID: UINT_PTR, +}} +pub type LPTBADDBITMAP = *mut TBADDBITMAP; +pub const HINST_COMMCTRL: HINSTANCE = -1isize as HINSTANCE; +pub const IDB_STD_SMALL_COLOR: WPARAM = 0; +pub const IDB_STD_LARGE_COLOR: WPARAM = 1; +pub const IDB_VIEW_SMALL_COLOR: WPARAM = 4; +pub const IDB_VIEW_LARGE_COLOR: WPARAM = 5; +pub const IDB_HIST_SMALL_COLOR: WPARAM = 8; +pub const IDB_HIST_LARGE_COLOR: WPARAM = 9; +pub const IDB_HIST_NORMAL: WPARAM = 12; +pub const IDB_HIST_HOT: WPARAM = 13; +pub const IDB_HIST_DISABLED: WPARAM = 14; +pub const IDB_HIST_PRESSED: WPARAM = 15; +pub const STD_CUT: c_int = 0; +pub const STD_COPY: c_int = 1; +pub const STD_PASTE: c_int = 2; +pub const STD_UNDO: c_int = 3; +pub const STD_REDOW: c_int = 4; +pub const STD_DELETE: c_int = 5; +pub const STD_FILENEW: c_int = 6; +pub const STD_FILEOPEN: c_int = 7; +pub const STD_FILESAVE: c_int = 8; +pub const STD_PRINTPRE: c_int = 9; +pub const STD_PROPERTIES: c_int = 10; +pub const STD_HELP: c_int = 11; +pub const STD_FIND: c_int = 12; +pub const STD_REPLACE: c_int = 13; +pub const STD_PRINT: c_int = 14; +pub const VIEW_LARGEICONS: c_int = 0; +pub const VIEW_SMALLICONS: c_int = 1; +pub const VIEW_LIST: c_int = 2; +pub const VIEW_DETAILS: c_int = 3; +pub const VIEW_SORTNAME: c_int = 4; +pub const VIEW_SORTSIZE: c_int = 5; +pub const VIEW_SORTDATE: c_int = 6; +pub const VIEW_SORTTYPE: c_int = 7; +pub const VIEW_PARENTFOLDER: c_int = 8; +pub const VIEW_NETCONNECT: c_int = 9; +pub const VIEW_NETDISCONNECT: c_int = 10; +pub const VIEW_NEWFOLDER: c_int = 11; +pub const VIEW_VIEWMENU: c_int = 12; +pub const HIST_BACK: c_int = 0; +pub const HIST_FORWARD: c_int = 1; +pub const HIST_FAVORITES: c_int = 2; +pub const HIST_ADDTOFAVORITES: c_int = 3; +pub const HIST_VIEWTREE: c_int = 4; +pub const TB_ADDBUTTONSA: UINT = WM_USER + 20; +pub const TB_INSERTBUTTONA: UINT = WM_USER + 21; +pub const TB_DELETEBUTTON: UINT = WM_USER + 22; +pub const TB_GETBUTTON: UINT = WM_USER + 23; +pub const TB_BUTTONCOUNT: UINT = WM_USER + 24; +pub const TB_COMMANDTOINDEX: UINT = WM_USER + 25; +STRUCT!{struct TBSAVEPARAMSA { + hkr: HKEY, + pszSubKey: LPCSTR, + pszValueName: LPCSTR, +}} +pub type LPTBSAVEPARAMSA = *mut TBSAVEPARAMSA; +STRUCT!{struct TBSAVEPARAMSW { + hkr: HKEY, + pszSubKey: LPCWSTR, + pszValueName: LPCWSTR, +}} +pub type LPTBSAVEPARAMSW = *mut TBSAVEPARAMSW; +pub const TB_SAVERESTOREA: UINT = WM_USER + 26; +pub const TB_SAVERESTOREW: UINT = WM_USER + 76; +pub const TB_CUSTOMIZE: UINT = WM_USER + 27; +pub const TB_ADDSTRINGA: UINT = WM_USER + 28; +pub const TB_ADDSTRINGW: UINT = WM_USER + 77; +pub const TB_GETITEMRECT: UINT = WM_USER + 29; +pub const TB_BUTTONSTRUCTSIZE: UINT = WM_USER + 30; +pub const TB_SETBUTTONSIZE: UINT = WM_USER + 31; +pub const TB_SETBITMAPSIZE: UINT = WM_USER + 32; +pub const TB_AUTOSIZE: UINT = WM_USER + 33; +pub const TB_GETTOOLTIPS: UINT = WM_USER + 35; +pub const TB_SETTOOLTIPS: UINT = WM_USER + 36; +pub const TB_SETPARENT: UINT = WM_USER + 37; +pub const TB_SETROWS: UINT = WM_USER + 39; +pub const TB_GETROWS: UINT = WM_USER + 40; +pub const TB_SETCMDID: UINT = WM_USER + 42; +pub const TB_CHANGEBITMAP: UINT = WM_USER + 43; +pub const TB_GETBITMAP: UINT = WM_USER + 44; +pub const TB_GETBUTTONTEXTA: UINT = WM_USER + 45; +pub const TB_GETBUTTONTEXTW: UINT = WM_USER + 75; +pub const TB_REPLACEBITMAP: UINT = WM_USER + 46; +pub const TB_SETINDENT: UINT = WM_USER + 47; +pub const TB_SETIMAGELIST: UINT = WM_USER + 48; +pub const TB_GETIMAGELIST: UINT = WM_USER + 49; +pub const TB_LOADIMAGES: UINT = WM_USER + 50; +pub const TB_GETRECT: UINT = WM_USER + 51; +pub const TB_SETHOTIMAGELIST: UINT = WM_USER + 52; +pub const TB_GETHOTIMAGELIST: UINT = WM_USER + 53; +pub const TB_SETDISABLEDIMAGELIST: UINT = WM_USER + 54; +pub const TB_GETDISABLEDIMAGELIST: UINT = WM_USER + 55; +pub const TB_SETSTYLE: UINT = WM_USER + 56; +pub const TB_GETSTYLE: UINT = WM_USER + 57; +pub const TB_GETBUTTONSIZE: UINT = WM_USER + 58; +pub const TB_SETBUTTONWIDTH: UINT = WM_USER + 59; +pub const TB_SETMAXTEXTROWS: UINT = WM_USER + 60; +pub const TB_GETTEXTROWS: UINT = WM_USER + 61; +pub const TB_GETOBJECT: UINT = WM_USER + 62; +pub const TB_GETHOTITEM: UINT = WM_USER + 71; +pub const TB_SETHOTITEM: UINT = WM_USER + 72; +pub const TB_SETANCHORHIGHLIGHT: UINT = WM_USER + 73; +pub const TB_GETANCHORHIGHLIGHT: UINT = WM_USER + 74; +pub const TB_MAPACCELERATORA: UINT = WM_USER + 78; +STRUCT!{struct TBINSERTMARK { + iButton: c_int, + dwFlags: DWORD, +}} +pub type LPTBINSERTMARK = *mut TBINSERTMARK; +pub const TBIMHT_AFTER: DWORD = 0x00000001; +pub const TBIMHT_BACKGROUND: DWORD = 0x00000002; +pub const TB_GETINSERTMARK: UINT = WM_USER + 79; +pub const TB_SETINSERTMARK: UINT = WM_USER + 80; +pub const TB_INSERTMARKHITTEST: UINT = WM_USER + 81; +pub const TB_MOVEBUTTON: UINT = WM_USER + 82; +pub const TB_GETMAXSIZE: UINT = WM_USER + 83; +pub const TB_SETEXTENDEDSTYLE: UINT = WM_USER + 84; +pub const TB_GETEXTENDEDSTYLE: UINT = WM_USER + 85; +pub const TB_GETPADDING: UINT = WM_USER + 86; +pub const TB_SETPADDING: UINT = WM_USER + 87; +pub const TB_SETINSERTMARKCOLOR: UINT = WM_USER + 88; +pub const TB_GETINSERTMARKCOLOR: UINT = WM_USER + 89; +pub const TB_SETCOLORSCHEME: UINT = CCM_SETCOLORSCHEME; +pub const TB_GETCOLORSCHEME: UINT = CCM_GETCOLORSCHEME; +pub const TB_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const TB_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const TB_MAPACCELERATORW: UINT = WM_USER + 90; +STRUCT!{struct TBREPLACEBITMAP { + hInstOld: HINSTANCE, + nIDOld: UINT_PTR, + hInstNew: HINSTANCE, + nIDNew: UINT_PTR, + nButtons: c_int, +}} +pub type LPTBREPLACEBITMAP = *mut TBREPLACEBITMAP; +pub const TBBF_LARGE: DWORD = 0x0001; +pub const TB_GETBITMAPFLAGS: UINT = WM_USER + 41; +pub const TBIF_IMAGE: DWORD = 0x00000001; +pub const TBIF_TEXT: DWORD = 0x00000002; +pub const TBIF_STATE: DWORD = 0x00000004; +pub const TBIF_STYLE: DWORD = 0x00000008; +pub const TBIF_LPARAM: DWORD = 0x00000010; +pub const TBIF_COMMAND: DWORD = 0x00000020; +pub const TBIF_SIZE: DWORD = 0x00000040; +pub const TBIF_BYINDEX: DWORD = 0x80000000; +STRUCT!{struct TBBUTTONINFOA { + cbSize: UINT, + dwMask: DWORD, + idCommand: c_int, + iImage: c_int, + fsState: BYTE, + fsStyle: BYTE, + cx: WORD, + lParam: DWORD_PTR, + pszText: LPSTR, + cchText: c_int, +}} +pub type LPTBBUTTONINFOA = *mut TBBUTTONINFOA; +STRUCT!{struct TBBUTTONINFOW { + cbSize: UINT, + dwMask: DWORD, + idCommand: c_int, + iImage: c_int, + fsState: BYTE, + fsStyle: BYTE, + cx: WORD, + lParam: DWORD_PTR, + pszText: LPWSTR, + cchText: c_int, +}} +pub type LPTBBUTTONINFOW = *mut TBBUTTONINFOW; +pub const TB_GETBUTTONINFOW: UINT = WM_USER + 63; +pub const TB_SETBUTTONINFOW: UINT = WM_USER + 64; +pub const TB_GETBUTTONINFOA: UINT = WM_USER + 65; +pub const TB_SETBUTTONINFOA: UINT = WM_USER + 66; +pub const TB_INSERTBUTTONW: UINT = WM_USER + 67; +pub const TB_ADDBUTTONSW: UINT = WM_USER + 68; +pub const TB_HITTEST: UINT = WM_USER + 69; +pub const TB_SETDRAWTEXTFLAGS: UINT = WM_USER + 70; +pub const TB_GETSTRINGW: UINT = WM_USER + 91; +pub const TB_GETSTRINGA: UINT = WM_USER + 92; +pub const TB_SETBOUNDINGSIZE: UINT = WM_USER + 93; +pub const TB_SETHOTITEM2: UINT = WM_USER + 94; +pub const TB_HASACCELERATOR: UINT = WM_USER + 95; +pub const TB_SETLISTGAP: UINT = WM_USER + 96; +pub const TB_GETIMAGELISTCOUNT: UINT = WM_USER + 98; +pub const TB_GETIDEALSIZE: UINT = WM_USER + 99; +pub const TBMF_PAD: DWORD = 0x00000001; +pub const TBMF_BARPAD: DWORD = 0x00000002; +pub const TBMF_BUTTONSPACING: DWORD = 0x00000004; +STRUCT!{struct TBMETRICS { + cbSize: UINT, + dwMask: DWORD, + cxPad: c_int, + cyPad: c_int, + cxBarPad: c_int, + cyBarPad: c_int, + cxButtonSpacing: c_int, + cyButtonSpacing: c_int, +}} +pub type LPTBMETRICS = *mut TBMETRICS; +pub const TB_GETMETRICS: UINT = WM_USER + 101; +pub const TB_SETMETRICS: UINT = WM_USER + 102; +pub const TB_GETITEMDROPDOWNRECT: UINT = WM_USER + 103; +pub const TB_SETPRESSEDIMAGELIST: UINT = WM_USER + 104; +pub const TB_GETPRESSEDIMAGELIST: UINT = WM_USER + 105; +pub const TB_SETWINDOWTHEME: UINT = CCM_SETWINDOWTHEME; +pub const TBN_GETBUTTONINFOA: UINT = TBN_FIRST - 0; +pub const TBN_BEGINDRAG: UINT = TBN_FIRST - 1; +pub const TBN_ENDDRAG: UINT = TBN_FIRST - 2; +pub const TBN_BEGINADJUST: UINT = TBN_FIRST - 3; +pub const TBN_ENDADJUST: UINT = TBN_FIRST - 4; +pub const TBN_RESET: UINT = TBN_FIRST - 5; +pub const TBN_QUERYINSERT: UINT = TBN_FIRST - 6; +pub const TBN_QUERYDELETE: UINT = TBN_FIRST - 7; +pub const TBN_TOOLBARCHANGE: UINT = TBN_FIRST - 8; +pub const TBN_CUSTHELP: UINT = TBN_FIRST - 9; +pub const TBN_DROPDOWN: UINT = TBN_FIRST - 10; +pub const TBN_GETOBJECT: UINT = TBN_FIRST - 12; +STRUCT!{struct NMTBHOTITEM { + hdr: NMHDR, + idOld: c_int, + idNew: c_int, + dwFlags: DWORD, +}} +pub type LPNMTBHOTITEM = *mut NMTBHOTITEM; +pub const HICF_OTHER: DWORD = 0x00000000; +pub const HICF_MOUSE: DWORD = 0x00000001; +pub const HICF_ARROWKEYS: DWORD = 0x00000002; +pub const HICF_ACCELERATOR: DWORD = 0x00000004; +pub const HICF_DUPACCEL: DWORD = 0x00000008; +pub const HICF_ENTERING: DWORD = 0x00000010; +pub const HICF_LEAVING: DWORD = 0x00000020; +pub const HICF_RESELECT: DWORD = 0x00000040; +pub const HICF_LMOUSE: DWORD = 0x00000080; +pub const HICF_TOGGLEDROPDOWN: DWORD = 0x00000100; +pub const TBN_HOTITEMCHANGE: UINT = TBN_FIRST - 13; +pub const TBN_DRAGOUT: UINT = TBN_FIRST - 14; +pub const TBN_DELETINGBUTTON: UINT = TBN_FIRST - 15; +pub const TBN_GETDISPINFOA: UINT = TBN_FIRST - 16; +pub const TBN_GETDISPINFOW: UINT = TBN_FIRST - 17; +pub const TBN_GETINFOTIPA: UINT = TBN_FIRST - 18; +pub const TBN_GETINFOTIPW: UINT = TBN_FIRST - 19; +pub const TBN_GETBUTTONINFOW: UINT = TBN_FIRST - 20; +pub const TBN_RESTORE: UINT = TBN_FIRST - 21; +pub const TBN_SAVE: UINT = TBN_FIRST - 22; +pub const TBN_INITCUSTOMIZE: UINT = TBN_FIRST - 23; +pub const TBNRF_HIDEHELP: LRESULT = 0x00000001; +pub const TBNRF_ENDCUSTOMIZE: LRESULT = 0x00000002; +pub const TBN_WRAPHOTITEM: UINT = TBN_FIRST - 24; +pub const TBN_DUPACCELERATOR: UINT = TBN_FIRST - 25; +pub const TBN_WRAPACCELERATOR: UINT = TBN_FIRST - 26; +pub const TBN_DRAGOVER: UINT = TBN_FIRST - 27; +pub const TBN_MAPACCELERATOR: UINT = TBN_FIRST - 28; +STRUCT!{struct NMTBSAVE { + hdr: NMHDR, + pData: *mut DWORD, + pCurrent: *mut DWORD, + cbData: UINT, + iItem: c_int, + cButtons: c_int, + tbButton: TBBUTTON, +}} +pub type LPNMTBSAVE = *mut NMTBSAVE; +STRUCT!{struct NMTBRESTORE { + hdr: NMHDR, + pData: *mut DWORD, + pCurrent: *mut DWORD, + cbData: UINT, + iItem: c_int, + cButtons: c_int, + cbBytesPerRecord: c_int, + tbButton: TBBUTTON, +}} +pub type LPNMTBRESTORE = *mut NMTBRESTORE; +STRUCT!{struct NMTBGETINFOTIPA { + hdr: NMHDR, + pszText: LPSTR, + cchTextMax: c_int, + iItem: c_int, + lParal: LPARAM, +}} +pub type LPNMTBGETINFOTIPA = *mut NMTBGETINFOTIPA; +STRUCT!{struct NMTBGETINFOTIPW { + hdr: NMHDR, + pszText: LPWSTR, + cchTextMax: c_int, + iItem: c_int, + lParal: LPARAM, +}} +pub type LPNMTBGETINFOTIPW = *mut NMTBGETINFOTIPW; +pub const TBNF_IMAGE: DWORD = 0x00000001; +pub const TBNF_TEXT: DWORD = 0x00000002; +pub const TBNF_DI_SETITEM: DWORD = 0x10000000; +STRUCT!{struct NMTBDISPINFOA { + hdr: NMHDR, + dwMask: DWORD, + idCommand: c_int, + lParam: DWORD_PTR, + iImage: c_int, + pszText: LPSTR, + cchText: c_int, +}} +pub type LPNMTBDISPINFOA = *mut NMTBDISPINFOA; +STRUCT!{struct NMTBDISPINFOW { + hdr: NMHDR, + dwMask: DWORD, + idCommand: c_int, + lParam: DWORD_PTR, + iImage: c_int, + pszText: LPWSTR, + cchText: c_int, +}} +pub type LPNMTBDISPINFOW = *mut NMTBDISPINFOW; +pub const TBDDRET_DEFAULT: LRESULT = 0; +pub const TBDDRET_NODEFAULT: LRESULT = 1; +pub const TBDDRET_TREATPRESSED: LRESULT = 2; +pub type TBNOTIFYA = NMTOOLBARA; +pub type TBNOTIFYW = NMTOOLBARW; +pub type LPTBNOTIFYA = LPNMTOOLBARA; +pub type LPTBNOTIFYW = LPNMTOOLBARW; +STRUCT!{struct NMTOOLBARA { + hdr: NMHDR, + iItem: c_int, + tbButton: TBBUTTON, + cchText: c_int, + pszText: LPSTR, + rcButton: RECT, +}} +pub type LPNMTOOLBARA = *mut NMTOOLBARA; +STRUCT!{struct NMTOOLBARW { + hdr: NMHDR, + iItem: c_int, + tbButton: TBBUTTON, + cchText: c_int, + pszText: LPWSTR, + rcButton: RECT, +}} +pub type LPNMTOOLBARW = *mut NMTOOLBARW; +pub const REBARCLASSNAME: &'static str = "ReBarWindow32"; +pub const RBIM_IMAGELIST: UINT = 0x00000001; +pub const RBS_TOOLTIPS: DWORD = 0x00000100; +pub const RBS_VARHEIGHT: DWORD = 0x00000200; +pub const RBS_BANDBORDERS: DWORD = 0x00000400; +pub const RBS_FIXEDORDER: DWORD = 0x00000800; +pub const RBS_REGISTERDROP: DWORD = 0x00001000; +pub const RBS_AUTOSIZE: DWORD = 0x00002000; +pub const RBS_VERTICALGRIPPER: DWORD = 0x00004000; +pub const RBS_DBLCLKTOGGLE: DWORD = 0x00008000; +STRUCT!{struct REBARINFO { + cbSize: UINT, + fMask: UINT, + himl: HIMAGELIST, +}} +pub type LPREBARINFO = *mut REBARINFO; +pub const RBBS_BREAK: UINT = 0x00000001; +pub const RBBS_FIXEDSIZE: UINT = 0x00000002; +pub const RBBS_CHILDEDGE: UINT = 0x00000004; +pub const RBBS_HIDDEN: UINT = 0x00000008; +pub const RBBS_NOVERT: UINT = 0x00000010; +pub const RBBS_FIXEDBMP: UINT = 0x00000020; +pub const RBBS_VARIABLEHEIGHT: UINT = 0x00000040; +pub const RBBS_GRIPPERALWAYS: UINT = 0x00000080; +pub const RBBS_NOGRIPPER: UINT = 0x00000100; +pub const RBBS_USECHEVRON: UINT = 0x00000200; +pub const RBBS_HIDETITLE: UINT = 0x00000400; +pub const RBBS_TOPALIGN: UINT = 0x00000800; +pub const RBBIM_STYLE: UINT = 0x00000001; +pub const RBBIM_COLORS: UINT = 0x00000002; +pub const RBBIM_TEXT: UINT = 0x00000004; +pub const RBBIM_IMAGE: UINT = 0x00000008; +pub const RBBIM_CHILD: UINT = 0x00000010; +pub const RBBIM_CHILDSIZE: UINT = 0x00000020; +pub const RBBIM_SIZE: UINT = 0x00000040; +pub const RBBIM_BACKGROUND: UINT = 0x00000080; +pub const RBBIM_ID: UINT = 0x00000100; +pub const RBBIM_IDEALSIZE: UINT = 0x00000200; +pub const RBBIM_LPARAM: UINT = 0x00000400; +pub const RBBIM_HEADERSIZE: UINT = 0x00000800; +pub const RBBIM_CHEVRONLOCATION: UINT = 0x00001000; +pub const RBBIM_CHEVRONSTATE: UINT = 0x00002000; +STRUCT!{struct REBARBANDINFOA { + cbSize: UINT, + fMask: UINT, + fStyle: UINT, + clrFore: COLORREF, + clrBack: COLORREF, + lpText: LPSTR, + cch: UINT, + iImage: c_int, + hwndChild: HWND, + cxMinChild: UINT, + cyMinChild: UINT, + cx: UINT, + hbmBack: HBITMAP, + wID: UINT, + cyChild: UINT, + cyMaxChild: UINT, + cyIntegral: UINT, + cxIdeal: UINT, + lParam: LPARAM, + cxHeader: UINT, + rcChevronLocation: RECT, + uChevronState: UINT, +}} +pub type LPREBARBANDINFOA = *mut REBARBANDINFOA; +pub type LPCREBARBANDINFOA = *const REBARBANDINFOA; +STRUCT!{struct REBARBANDINFOW { + cbSize: UINT, + fMask: UINT, + fStyle: UINT, + clrFore: COLORREF, + clrBack: COLORREF, + lpText: LPWSTR, + cch: UINT, + iImage: c_int, + hwndChild: HWND, + cxMinChild: UINT, + cyMinChild: UINT, + cx: UINT, + hbmBack: HBITMAP, + wID: UINT, + cyChild: UINT, + cyMaxChild: UINT, + cyIntegral: UINT, + cxIdeal: UINT, + lParam: LPARAM, + cxHeader: UINT, + rcChevronLocation: RECT, + uChevronState: UINT, +}} +pub type LPREBARBANDINFOW = *mut REBARBANDINFOW; +pub type LPCREBARBANDINFOW = *const REBARBANDINFOW; +pub const RB_INSERTBANDA: UINT = WM_USER + 1; +pub const RB_DELETEBAND: UINT = WM_USER + 2; +pub const RB_GETBARINFO: UINT = WM_USER + 3; +pub const RB_SETBARINFO: UINT = WM_USER + 4; +pub const RB_SETBANDINFOA: UINT = WM_USER + 6; +pub const RB_SETPARENT: UINT = WM_USER + 7; +pub const RB_HITTEST: UINT = WM_USER + 8; +pub const RB_GETRECT: UINT = WM_USER + 9; +pub const RB_INSERTBANDW: UINT = WM_USER + 10; +pub const RB_SETBANDINFOW: UINT = WM_USER + 11; +pub const RB_GETBANDCOUNT: UINT = WM_USER + 12; +pub const RB_GETROWCOUNT: UINT = WM_USER + 13; +pub const RB_GETROWHEIGHT: UINT = WM_USER + 14; +pub const RB_IDTOINDEX: UINT = WM_USER + 16; +pub const RB_GETTOOLTIPS: UINT = WM_USER + 17; +pub const RB_SETTOOLTIPS: UINT = WM_USER + 18; +pub const RB_SETBKCOLOR: UINT = WM_USER + 19; +pub const RB_GETBKCOLOR: UINT = WM_USER + 20; +pub const RB_SETTEXTCOLOR: UINT = WM_USER + 21; +pub const RB_GETTEXTCOLOR: UINT = WM_USER + 22; +pub const RBSTR_CHANGERECT: WPARAM = 0x0001; +pub const RB_SIZETORECT: UINT = WM_USER + 23; +pub const RB_SETCOLORSCHEME: UINT = CCM_SETCOLORSCHEME; +pub const RB_GETCOLORSCHEME: UINT = CCM_GETCOLORSCHEME; +pub const RB_BEGINDRAG: UINT = WM_USER + 24; +pub const RB_ENDDRAG: UINT = WM_USER + 25; +pub const RB_DRAGMOVE: UINT = WM_USER + 26; +pub const RB_GETBARHEIGHT: UINT = WM_USER + 27; +pub const RB_GETBANDINFOW: UINT = WM_USER + 28; +pub const RB_GETBANDINFOA: UINT = WM_USER + 29; +pub const RB_MINIMIZEBAND: UINT = WM_USER + 30; +pub const RB_MAXIMIZEBAND: UINT = WM_USER + 31; +pub const RB_GETDROPTARGET: UINT = CCM_GETDROPTARGET; +pub const RB_GETBANDBORDERS: UINT = WM_USER + 34; +pub const RB_SHOWBAND: UINT = WM_USER + 35; +pub const RB_SETPALETTE: UINT = WM_USER + 37; +pub const RB_GETPALETTE: UINT = WM_USER + 38; +pub const RB_MOVEBAND: UINT = WM_USER + 39; +pub const RB_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const RB_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const RB_GETBANDMARGINS: UINT = WM_USER + 40; +pub const RB_SETWINDOWTHEME: UINT = CCM_SETWINDOWTHEME; +pub const RB_SETEXTENDEDSTYLE: UINT = WM_USER + 41; +pub const RB_GETEXTENDEDSTYLE: UINT = WM_USER + 42; +pub const RB_PUSHCHEVRON: UINT = WM_USER + 43; +pub const RB_SETBANDWIDTH: UINT = WM_USER + 44; +pub const RBN_HEIGHTCHANGE: UINT = RBN_FIRST - 0; +pub const RBN_GETOBJECT: UINT = RBN_FIRST - 1; +pub const RBN_LAYOUTCHANGED: UINT = RBN_FIRST - 2; +pub const RBN_AUTOSIZE: UINT = RBN_FIRST - 3; +pub const RBN_BEGINDRAG: UINT = RBN_FIRST - 4; +pub const RBN_ENDDRAG: UINT = RBN_FIRST - 5; +pub const RBN_DELETINGBAND: UINT = RBN_FIRST - 6; +pub const RBN_DELETEDBAND: UINT = RBN_FIRST - 7; +pub const RBN_CHILDSIZE: UINT = RBN_FIRST - 8; +pub const RBN_CHEVRONPUSHED: UINT = RBN_FIRST - 10; +pub const RBN_SPLITTERDRAG: UINT = RBN_FIRST - 11; +pub const RBN_MINMAX: UINT = RBN_FIRST - 21; +pub const RBN_AUTOBREAK: UINT = RBN_FIRST - 22; +STRUCT!{struct NMREBARCHILDSIZE { + hdr: NMHDR, + uBand: UINT, + wID: UINT, + rcChild: RECT, + rcBand: RECT, +}} +pub type LPNMREBARCHILDSIZE = *mut NMREBARCHILDSIZE; +STRUCT!{struct NMREBAR { + hdr: NMHDR, + dwMask: DWORD, + uBand: UINT, + fStyle: UINT, + wID: UINT, + lParam: LPARAM, +}} +pub type LPNMREBAR = *mut NMREBAR; +pub const RBNM_ID: DWORD = 0x00000001; +pub const RBNM_STYLE: DWORD = 0x00000002; +pub const RBNM_LPARAM: DWORD = 0x00000004; +STRUCT!{struct NMRBAUTOSIZE { + hdr: NMHDR, + fChanged: BOOL, + rcTarget: RECT, + rcActual: RECT, +}} +pub type LPNMRBAUTOSIZE = *mut NMRBAUTOSIZE; +STRUCT!{struct NMREBARCHEVRON { + hdr: NMHDR, + uBand: UINT, + wID: UINT, + lParam: LPARAM, + rc: RECT, + lParamNM: LPARAM, +}} +pub type LPNMREBARCHEVRON = *mut NMREBARCHEVRON; +STRUCT!{struct NMREBARSPLITTER { + hdr: NMHDR, + rcSizing: RECT, +}} +pub type LPNMREBARSPLITTER = *mut NMREBARSPLITTER; +pub const RBAB_AUTOSIZE: UINT = 0x0001; +pub const RBAB_ADDBAND: UINT = 0x0002; +STRUCT!{struct NMREBARAUTOBREAK { + hdr: NMHDR, + uBand: UINT, + wID: UINT, + lParam: LPARAM, + uMsg: UINT, + fStyleCurrent: UINT, + fAutoBreak: UINT, +}} +pub type LPNMREBARAUTOBREAK = *mut NMREBARAUTOBREAK; +pub const RBHT_NOWHERE: UINT = 0x0001; +pub const RBHT_CAPTION: UINT = 0x0002; +pub const RBHT_CLIENT: UINT = 0x0003; +pub const RBHT_GRABBER: UINT = 0x0004; +pub const RBHT_CHEVRON: UINT = 0x0008; +pub const RBHT_SPLITTER: UINT = 0x0010; +STRUCT!{struct RBHITTESTINFO { + pt: POINT, + flags: UINT, + iBand: c_int, +}} +pub type LPRBHITTESTINFO = *mut RBHITTESTINFO; +pub const TOOLTIPS_CLASS: &'static str = "tooltips_class32"; +pub type LPTOOLINFOA = LPTTTOOLINFOA; +pub type LPTOOLINFOW = LPTTTOOLINFOW; +pub type TOOLINFOA = TTTOOLINFOA; +pub type TOOLINFOW = TTTOOLINFOW; +STRUCT!{struct TTTOOLINFOA { + cbSize: UINT, + uFlags: UINT, + hwnd: HWND, + uId: UINT_PTR, + rect: RECT, + hinst: HINSTANCE, + lpszText: LPSTR, + lParam: LPARAM, + lpReserved: *mut c_void, +}} +pub type PTTTOOLINFOA = *mut TTTOOLINFOA; +pub type LPTTTOOLINFOA = *mut TTTOOLINFOA; +STRUCT!{struct TTTOOLINFOW { + cbSize: UINT, + uFlags: UINT, + hwnd: HWND, + uId: UINT_PTR, + rect: RECT, + hinst: HINSTANCE, + lpszText: LPSTR, + lParam: LPARAM, + lpReserved: *mut c_void, +}} +pub type PTTTOOLINFOW = *mut TTTOOLINFOW; +pub type LPTTTOOLINFOW = *mut TTTOOLINFOW; +pub const TTS_ALWAYSTIP: DWORD = 0x01; +pub const TTS_NOPREFIX: DWORD = 0x02; +pub const TTS_NOANIMATE: DWORD = 0x10; +pub const TTS_NOFADE: DWORD = 0x20; +pub const TTS_BALLOON: DWORD = 0x40; +pub const TTS_CLOSE: DWORD = 0x80; +pub const TTS_USEVISUALSTYLE: DWORD = 0x100; +pub const TTF_IDISHWND: UINT = 0x0001; +pub const TTF_CENTERTIP: UINT = 0x0002; +pub const TTF_RTLREADING: UINT = 0x0004; +pub const TTF_SUBCLASS: UINT = 0x0010; +pub const TTF_TRACK: UINT = 0x0020; +pub const TTF_ABSOLUTE: UINT = 0x0080; +pub const TTF_TRANSPARENT: UINT = 0x0100; +pub const TTF_PARSELINKS: UINT = 0x1000; +pub const TTF_DI_SETITEM: UINT = 0x8000; +pub const TTDT_AUTOMATIC: WPARAM = 0; +pub const TTDT_RESHOW: WPARAM = 1; +pub const TTDT_AUTOPOP: WPARAM = 2; +pub const TTDT_INITIAL: WPARAM = 3; +pub const TTI_NONE: WPARAM = 0; +pub const TTI_INFO: WPARAM = 1; +pub const TTI_WARNING: WPARAM = 2; +pub const TTI_ERROR: WPARAM = 3; +pub const TTI_INFO_LARGE: WPARAM = 4; +pub const TTI_WARNING_LARGE: WPARAM = 5; +pub const TTI_ERROR_LARGE: WPARAM = 6; +pub const TTM_ACTIVATE: UINT = WM_USER + 1; +pub const TTM_SETDELAYTIME: UINT = WM_USER + 3; +pub const TTM_ADDTOOLA: UINT = WM_USER + 4; +pub const TTM_ADDTOOLW: UINT = WM_USER + 50; +pub const TTM_DELTOOLA: UINT = WM_USER + 5; +pub const TTM_DELTOOLW: UINT = WM_USER + 51; +pub const TTM_NEWTOOLRECTA: UINT = WM_USER + 6; +pub const TTM_NEWTOOLRECTW: UINT = WM_USER + 52; +pub const TTM_RELAYEVENT: UINT = WM_USER + 7; +pub const TTM_GETTOOLINFOA: UINT = WM_USER + 8; +pub const TTM_GETTOOLINFOW: UINT = WM_USER + 53; +pub const TTM_SETTOOLINFOA: UINT = WM_USER + 9; +pub const TTM_SETTOOLINFOW: UINT = WM_USER + 54; +pub const TTM_HITTESTA: UINT = WM_USER + 10; +pub const TTM_HITTESTW: UINT = WM_USER + 55; +pub const TTM_GETTEXTA: UINT = WM_USER + 11; +pub const TTM_GETTEXTW: UINT = WM_USER + 56; +pub const TTM_UPDATETIPTEXTA: UINT = WM_USER + 12; +pub const TTM_UPDATETIPTEXTW: UINT = WM_USER + 57; +pub const TTM_GETTOOLCOUNT: UINT = WM_USER + 13; +pub const TTM_ENUMTOOLSA: UINT = WM_USER + 14; +pub const TTM_ENUMTOOLSW: UINT = WM_USER + 58; +pub const TTM_GETCURRENTTOOLA: UINT = WM_USER + 15; +pub const TTM_GETCURRENTTOOLW: UINT = WM_USER + 59; +pub const TTM_WINDOWFROMPOINT: UINT = WM_USER + 16; +pub const TTM_TRACKACTIVATE: UINT = WM_USER + 17; +pub const TTM_TRACKPOSITION: UINT = WM_USER + 18; +pub const TTM_SETTIPBKCOLOR: UINT = WM_USER + 19; +pub const TTM_SETTIPTEXTCOLOR: UINT = WM_USER + 20; +pub const TTM_GETDELAYTIME: UINT = WM_USER + 21; +pub const TTM_GETTIPBKCOLOR: UINT = WM_USER + 22; +pub const TTM_GETTIPTEXTCOLOR: UINT = WM_USER + 23; +pub const TTM_SETMAXTIPWIDTH: UINT = WM_USER + 24; +pub const TTM_GETMAXTIPWIDTH: UINT = WM_USER + 25; +pub const TTM_SETMARGIN: UINT = WM_USER + 26; +pub const TTM_GETMARGIN: UINT = WM_USER + 27; +pub const TTM_POP: UINT = WM_USER + 28; +pub const TTM_UPDATE: UINT = WM_USER + 29; +pub const TTM_GETBUBBLESIZE: UINT = WM_USER + 30; +pub const TTM_ADJUSTRECT: UINT = WM_USER + 31; +pub const TTM_SETTITLEA: UINT = WM_USER + 32; +pub const TTM_SETTITLEW: UINT = WM_USER + 33; +pub const TTM_POPUP: UINT = WM_USER + 34; +pub const TTM_GETTITLE: UINT = WM_USER + 35; +STRUCT!{struct TTGETTITLE { + dwSize: DWORD, + uTitleBitmap: UINT, + cch: UINT, + pszTitle: *mut WCHAR, +}} +pub type LPTTGETTITLE = *mut TTGETTITLE; +pub const TTM_SETWINDOWTHEME: UINT = CCM_SETWINDOWTHEME; +pub type LPHITTESTINFOW = LPTTHITTESTINFOW; +pub type LPHITTESTINFOA = LPTTHITTESTINFOA; +STRUCT!{struct TTHITTESTINFOA { + hwnd: HWND, + pt: POINT, + ti: TTTOOLINFOA, +}} +pub type LPTTHITTESTINFOA = *mut TTHITTESTINFOA; +STRUCT!{struct TTHITTESTINFOW { + hwnd: HWND, + pt: POINT, + ti: TTTOOLINFOW, +}} +pub type LPTTHITTESTINFOW = *mut TTHITTESTINFOW; +pub const TTN_GETDISPINFOA: UINT = TTN_FIRST - 0; +pub const TTN_GETDISPINFOW: UINT = TTN_FIRST - 10; +pub const TTN_SHOW: UINT = TTN_FIRST - 1; +pub const TTN_POP: UINT = TTN_FIRST - 2; +pub const TTN_LINKCLICK: UINT = TTN_FIRST - 3; +pub const TTN_NEEDTEXTA: UINT = TTN_GETDISPINFOA; +pub const TTN_NEEDTEXTW: UINT = TTN_GETDISPINFOW; +pub type TOOLTIPTEXTW = NMTTDISPINFOW; +pub type TOOLTIPTEXTA = NMTTDISPINFOA; +pub type LPTOOLTIPTEXTA = LPNMTTDISPINFOA; +pub type LPTOOLTIPTEXTW = LPNMTTDISPINFOW; +STRUCT!{struct NMTTDISPINFOA { + hdr: NMHDR, + lpszText: LPSTR, + szText: [c_char; 80], + hinst: HINSTANCE, + uFlags: UINT, + lParam: LPARAM, +}} +pub type LPNMTTDISPINFOA = *mut NMTTDISPINFOA; +STRUCT!{struct NMTTDISPINFOW { + hdr: NMHDR, + lpszText: LPWSTR, + szText: [WCHAR; 80], + hinst: HINSTANCE, + uFlags: UINT, + lParam: LPARAM, +}} +pub type LPNMTTDISPINFOW = *mut NMTTDISPINFOW; +pub const SBARS_SIZEGRIP: DWORD = 0x0100; +pub const SBARS_TOOLTIPS: DWORD = 0x0800; +pub const SBT_TOOLTIPS: DWORD = 0x0800; +extern "system" { + pub fn DrawStatusTextA( + hDC: HDC, + lprc: LPCRECT, + pszText: LPCSTR, + uFlags: UINT, + ); + pub fn DrawStatusTextW( + hDC: HDC, + lprc: LPCRECT, + pszText: LPCWSTR, + uFlags: UINT, + ); + pub fn CreateStatusWindowA( + style: LONG, + lpszText: LPCSTR, + hwndParent: HWND, + wID: UINT, + ) -> HWND; + pub fn CreateStatusWindowW( + style: LONG, + lpszText: LPCWSTR, + hwndParent: HWND, + wID: UINT, + ) -> HWND; +} +pub const STATUSCLASSNAME: &'static str = "msctls_statusbar32"; +pub const SB_SETTEXTA: UINT = WM_USER + 1; +pub const SB_SETTEXTW: UINT = WM_USER + 11; +pub const SB_GETTEXTA: UINT = WM_USER + 2; +pub const SB_GETTEXTW: UINT = WM_USER + 13; +pub const SB_GETTEXTLENGTHA: UINT = WM_USER + 3; +pub const SB_GETTEXTLENGTHW: UINT = WM_USER + 12; +pub const SB_SETPARTS: UINT = WM_USER + 4; +pub const SB_GETPARTS: UINT = WM_USER + 6; +pub const SB_GETBORDERS: UINT = WM_USER + 7; +pub const SB_SETMINHEIGHT: UINT = WM_USER + 8; +pub const SB_SIMPLE: UINT = WM_USER + 9; +pub const SB_GETRECT: UINT = WM_USER + 10; +pub const SB_ISSIMPLE: UINT = WM_USER + 14; +pub const SB_SETICON: UINT = WM_USER + 15; +pub const SB_SETTIPTEXTA: UINT = WM_USER + 16; +pub const SB_SETTIPTEXTW: UINT = WM_USER + 17; +pub const SB_GETTIPTEXTA: UINT = WM_USER + 18; +pub const SB_GETTIPTEXTW: UINT = WM_USER + 19; +pub const SB_GETICON: UINT = WM_USER + 20; +pub const SB_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const SB_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const SBT_OWNERDRAW: WPARAM = 0x1000; +pub const SBT_NOBORDERS: WPARAM = 0x0100; +pub const SBT_POPOUT: WPARAM = 0x0200; +pub const SBT_RTLREADING: WPARAM = 0x0400; +pub const SBT_NOTABPARSING: WPARAM = 0x0800; +pub const SB_SETBKCOLOR: UINT = CCM_SETBKCOLOR; +pub const SBN_SIMPLEMODECHANGE: UINT = SBN_FIRST - 0; +pub const SB_SIMPLEID: WPARAM = 0x00ff; +extern "system" { + pub fn MenuHelp( + uMsg: UINT, + wParam: WPARAM, + lParam: LPARAM, + hMainMenu: HMENU, + hInst: HINSTANCE, + hwndStatus: HWND, + lpwIDs: *mut UINT, + ); + pub fn ShowHideMenuCtl( + hWnd: HWND, + uFlags: UINT_PTR, + lpInfo: LPINT, + ) -> BOOL; + pub fn GetEffectiveClientRect( + hWnd: HWND, + lprc: LPRECT, + lpInfo: *const INT, + ); +} +pub const TRACKBAR_CLASS: &'static str = "msctls_trackbar32"; +pub const TBS_AUTOTICKS: DWORD = 0x0001; +pub const TBS_VERT: DWORD = 0x0002; +pub const TBS_HORZ: DWORD = 0x0000; +pub const TBS_TOP: DWORD = 0x0004; +pub const TBS_BOTTOM: DWORD = 0x0000; +pub const TBS_LEFT: DWORD = 0x0004; +pub const TBS_RIGHT: DWORD = 0x0000; +pub const TBS_BOTH: DWORD = 0x0008; +pub const TBS_NOTICKS: DWORD = 0x0010; +pub const TBS_ENABLESELRANGE: DWORD = 0x0020; +pub const TBS_FIXEDLENGTH: DWORD = 0x0040; +pub const TBS_NOTHUMB: DWORD = 0x0080; +pub const TBS_TOOLTIPS: DWORD = 0x0100; +pub const TBS_REVERSED: DWORD = 0x0200; +pub const TBS_DOWNISLEFT: DWORD = 0x0400; +pub const TBS_NOTIFYBEFOREMOVE: DWORD = 0x0800; +pub const TBS_TRANSPARENTBKGND: DWORD = 0x1000; +pub const TBM_GETPOS: UINT = WM_USER; +pub const TBM_GETRANGEMIN: UINT = WM_USER + 1; +pub const TBM_GETRANGEMAX: UINT = WM_USER + 2; +pub const TBM_GETTIC: UINT = WM_USER + 3; +pub const TBM_SETTIC: UINT = WM_USER + 4; +pub const TBM_SETPOS: UINT = WM_USER + 5; +pub const TBM_SETRANGE: UINT = WM_USER + 6; +pub const TBM_SETRANGEMIN: UINT = WM_USER + 7; +pub const TBM_SETRANGEMAX: UINT = WM_USER + 8; +pub const TBM_CLEARTICS: UINT = WM_USER + 9; +pub const TBM_SETSEL: UINT = WM_USER + 10; +pub const TBM_SETSELSTART: UINT = WM_USER + 11; +pub const TBM_SETSELEND: UINT = WM_USER + 12; +pub const TBM_GETPTICS: UINT = WM_USER + 14; +pub const TBM_GETTICPOS: UINT = WM_USER + 15; +pub const TBM_GETNUMTICS: UINT = WM_USER + 16; +pub const TBM_GETSELSTART: UINT = WM_USER + 17; +pub const TBM_GETSELEND: UINT = WM_USER + 18; +pub const TBM_CLEARSEL: UINT = WM_USER + 19; +pub const TBM_SETTICFREQ: UINT = WM_USER + 20; +pub const TBM_SETPAGESIZE: UINT = WM_USER + 21; +pub const TBM_GETPAGESIZE: UINT = WM_USER + 22; +pub const TBM_SETLINESIZE: UINT = WM_USER + 23; +pub const TBM_GETLINESIZE: UINT = WM_USER + 24; +pub const TBM_GETTHUMBRECT: UINT = WM_USER + 25; +pub const TBM_GETCHANNELRECT: UINT = WM_USER + 26; +pub const TBM_SETTHUMBLENGTH: UINT = WM_USER + 27; +pub const TBM_GETTHUMBLENGTH: UINT = WM_USER + 28; +pub const TBM_SETTOOLTIPS: UINT = WM_USER + 29; +pub const TBM_GETTOOLTIPS: UINT = WM_USER + 30; +pub const TBM_SETTIPSIDE: UINT = WM_USER + 31; +pub const TBTS_TOP: WPARAM = 0; +pub const TBTS_LEFT: WPARAM = 1; +pub const TBTS_BOTTOM: WPARAM = 2; +pub const TBTS_RIGHT: WPARAM = 3; +pub const TBM_SETBUDDY: UINT = WM_USER + 32; +pub const TBM_GETBUDDY: UINT = WM_USER + 33; +pub const TBM_SETPOSNOTIFY: UINT = WM_USER + 34; +pub const TBM_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const TBM_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const TB_LINEUP: WPARAM = 0; +pub const TB_LINEDOWN: WPARAM = 1; +pub const TB_PAGEUP: WPARAM = 2; +pub const TB_PAGEDOWN: WPARAM = 3; +pub const TB_THUMBPOSITION: WPARAM = 4; +pub const TB_THUMBTRACK: WPARAM = 5; +pub const TB_TOP: WPARAM = 6; +pub const TB_BOTTOM: WPARAM = 7; +pub const TB_ENDTRACK: WPARAM = 8; +pub const TBCD_TICS: DWORD_PTR = 0x0001; +pub const TBCD_THUMB: DWORD_PTR = 0x0001; +pub const TBCD_CHANNEL: DWORD_PTR = 0x0001; +pub const TRBN_THUMBPOSCHANGING: UINT = TRBN_FIRST - 1; +STRUCT!{struct NMTRBTHUMBPOSCHANGING { + hdr: NMHDR, + dwPos: DWORD, + nReason: c_int, +}} +STRUCT!{struct DRAGLISTINFO { + uNotification: UINT, + hWnd: HWND, + ptCursor: POINT, +}} +pub type LPDRAGLISTINFO = *mut DRAGLISTINFO; +pub const DL_BEGINDRAG: UINT = WM_USER + 133; +pub const DL_DRAGGING: UINT = WM_USER + 134; +pub const DL_DROPPED: UINT = WM_USER + 135; +pub const DL_CANCELDRAG: UINT = WM_USER + 136; +pub const DL_CURSORSET: UINT = 0; +pub const DL_STOPCURSOR: UINT = 1; +pub const DL_COPYCURSOR: UINT = 2; +pub const DL_MOVECURSOR: UINT = 3; +pub const DRAGLISTMSGSTRING: &'static str = "commctrl_DragListMsg"; +extern "system" { + pub fn MakeDragList( + hLB: HWND, + ) -> BOOL; + pub fn DrawInsert( + handParent: HWND, + hLB: HWND, + nItem: c_int, + ); + pub fn LBItemFromPt( + hLB: HWND, + pt: POINT, + bAutoScroll: BOOL, + ) -> c_int; +} +pub const UPDOWN_CLASS: &'static str = "msctls_updown32"; +STRUCT!{struct UDACCEL { + nSec: UINT, + nInc: UINT, +}} +pub type LPUDACCEL = *mut UDACCEL; +pub const UD_MAXVAL: c_short = 0x7fff; +pub const UD_MINVAL: c_short = 0 - UD_MAXVAL; +pub const UDS_WRAP: DWORD = 0x0001; +pub const UDS_SETBUDDYINT: DWORD = 0x0002; +pub const UDS_ALIGNRIGHT: DWORD = 0x0004; +pub const UDS_ALIGNLEFT: DWORD = 0x0008; +pub const UDS_AUTOBUDDY: DWORD = 0x0010; +pub const UDS_ARROWKEYS: DWORD = 0x0020; +pub const UDS_HORZ: DWORD = 0x0040; +pub const UDS_NOTHOUSANDS: DWORD = 0x0080; +pub const UDS_HOTTRACK: DWORD = 0x0100; +pub const UDM_SETRANGE: UINT = WM_USER + 101; +pub const UDM_GETRANGE: UINT = WM_USER + 102; +pub const UDM_SETPOS: UINT = WM_USER + 103; +pub const UDM_GETPOS: UINT = WM_USER + 104; +pub const UDM_SETBUDDY: UINT = WM_USER + 105; +pub const UDM_GETBUDDY: UINT = WM_USER + 106; +pub const UDM_SETACCEL: UINT = WM_USER + 107; +pub const UDM_GETACCEL: UINT = WM_USER + 108; +pub const UDM_SETBASE: UINT = WM_USER + 109; +pub const UDM_GETBASE: UINT = WM_USER + 110; +pub const UDM_SETRANGE32: UINT = WM_USER + 111; +pub const UDM_GETRANGE32: UINT = WM_USER + 112; +pub const UDM_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const UDM_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const UDM_SETPOS32: UINT = WM_USER + 113; +pub const UDM_GETPOS32: UINT = WM_USER + 114; +extern "system" { + pub fn CreateUpDownControl( + dwStyle: DWORD, + x: c_int, + y: c_int, + cx: c_int, + cy: c_int, + hParent: HWND, + nID: c_int, + hInst: HINSTANCE, + nBuddy: HWND, + nUpper: c_int, + nLower: c_int, + nPos: c_int, + ) -> HWND; +} +pub type NM_UPDOWN = NMUPDOWN; +pub type LPNM_UPDOWN = LPNMUPDOWN; +STRUCT!{struct NMUPDOWN { + hdr: NMHDR, + iPos: c_int, + iDelta: c_int, +}} +pub type LPNMUPDOWN = *mut NMUPDOWN; +pub const UDN_DELTAPOS: UINT = UDN_FIRST - 1; +pub const PROGRESS_CLASS: &'static str = "msctls_progress32"; +pub const PBS_SMOOTH: DWORD = 0x01; +pub const PBS_VERTICAL: DWORD = 0x04; +pub const PBM_SETRANGE: UINT = WM_USER + 1; +pub const PBM_SETPOS: UINT = WM_USER + 2; +pub const PBM_DELTAPOS: UINT = WM_USER + 3; +pub const PBM_SETSTEP: UINT = WM_USER + 4; +pub const PBM_STEPIT: UINT = WM_USER + 5; +pub const PBM_SETRANGE32: UINT = WM_USER + 6; +STRUCT!{struct PBRANGE { + iLow: c_int, + iHigh: c_int, +}} +pub type LPPBRANGE = *mut PBRANGE; +pub const PBM_GETRANGE: UINT = WM_USER + 7; +pub const PBM_GETPOS: UINT = WM_USER + 8; +pub const PBM_SETBARCOLOR: UINT = WM_USER + 9; +pub const PBM_SETBKCOLOR: UINT = CCM_SETBKCOLOR; +pub const PBS_MARQUEE: DWORD = 0x08; +pub const PBM_SETMARQUEE: UINT = WM_USER + 10; +pub const PBS_SMOOTHREVERSE: DWORD = 0x10; +pub const PBM_GETSTEP: UINT = WM_USER + 13; +pub const PBM_GETBKCOLOR: UINT = WM_USER + 14; +pub const PBM_GETBARCOLOR: UINT = WM_USER + 15; +pub const PBM_SETSTATE: UINT = WM_USER + 16; +pub const PBM_GETSTATE: UINT = WM_USER + 17; +pub const PBST_NORMAL: c_int = 0x0001; +pub const PBST_ERROR: c_int = 0x0002; +pub const PBST_PAUSED: c_int = 0x0003; +pub const HOTKEYF_SHIFT: BYTE = 0x01; +pub const HOTKEYF_CONTROL: BYTE = 0x02; +pub const HOTKEYF_ALT: BYTE = 0x04; +pub const HOTKEYF_EXT: BYTE = 0x08; +pub const HKCOMB_NONE: WPARAM = 0x0001; +pub const HKCOMB_S: WPARAM = 0x0002; +pub const HKCOMB_C: WPARAM = 0x0004; +pub const HKCOMB_A: WPARAM = 0x0008; +pub const HKCOMB_SC: WPARAM = 0x0010; +pub const HKCOMB_SA: WPARAM = 0x0020; +pub const HKCOMB_CA: WPARAM = 0x0040; +pub const HKCOMB_SCA: WPARAM = 0x0080; +pub const HKM_SETHOTKEY: UINT = WM_USER + 1; +pub const HKM_GETHOTKEY: UINT = WM_USER + 2; +pub const HKM_SETRULES: UINT = WM_USER + 3; +pub const HOTKEY_CLASS: &'static str = "msctls_hotkey32"; +pub const CCS_TOP: DWORD = 0x00000001; +pub const CCS_NOMOVEY: DWORD = 0x00000002; +pub const CCS_BOTTOM: DWORD = 0x00000003; +pub const CCS_NORESIZE: DWORD = 0x00000004; +pub const CCS_NOPARENTALIGN: DWORD = 0x00000008; +pub const CCS_ADJUSTABLE: DWORD = 0x00000020; +pub const CCS_NODIVIDER: DWORD = 0x00000040; +pub const CCS_VERT: DWORD = 0x00000080; +pub const CCS_LEFT: DWORD = CCS_VERT | CCS_TOP; +pub const CCS_RIGHT: DWORD = CCS_VERT | CCS_BOTTOM; +pub const CCS_NOMOVEX: DWORD = CCS_VERT | CCS_NOMOVEY; +pub const INVALID_LINK_INDEX: c_int = -1; +pub const MAX_LINKID_TEXT: usize = 48; +pub const L_MAX_URL_LENGTH: usize = 2048 + 32 + 4; +pub const WC_LINK: &'static str = "SysLink"; +pub const LWS_TRANSPARENT: DWORD = 0x0001; +pub const LWS_IGNORERETURN: DWORD = 0x0002; +pub const LWS_NOPREFIX: DWORD = 0x0004; +pub const LWS_USEVISUALSTYLE: DWORD = 0x0008; +pub const LWS_USECUSTOMTEXT: DWORD = 0x0010; +pub const LWS_RIGHT: DWORD = 0x0020; +pub const LIF_ITEMINDEX: UINT = 0x00000001; +pub const LIF_STATE: UINT = 0x00000002; +pub const LIF_ITEMID: UINT = 0x00000004; +pub const LIF_URL: UINT = 0x00000008; +pub const LIS_FOCUSED: UINT = 0x00000001; +pub const LIS_ENABLED: UINT = 0x00000002; +pub const LIS_VISITED: UINT = 0x00000004; +pub const LIS_HOTTRACK: UINT = 0x00000008; +pub const LIS_DEFAULTCOLORS: UINT = 0x00000010; +STRUCT!{struct LITEM { + mask: UINT, + iLink: c_int, + state: UINT, + stateMask: UINT, + szID: [WCHAR; MAX_LINKID_TEXT], + szUrl: [WCHAR; L_MAX_URL_LENGTH], +}} +pub type PLITEM = *mut LITEM; +STRUCT!{struct LHITTESTINFO { + pt: POINT, + item: LITEM, +}} +pub type PLHITTESTINFO = *mut LHITTESTINFO; +STRUCT!{struct NMLINK { + hdr: NMHDR, + item: LITEM, +}} +pub type PNMLINK = *mut NMLINK; +pub const LM_HITTEST: UINT = WM_USER + 0x300; +pub const LM_GETIDEALHEIGHT: UINT = WM_USER + 0x301; +pub const LM_SETITEM: UINT = WM_USER + 0x302; +pub const LM_GETITEM: UINT = WM_USER + 0x303; +pub const LM_GETIDEALSIZE: UINT = LM_GETIDEALHEIGHT; +pub const WC_LISTVIEW: &'static str = "SysListView32"; +pub const LVS_ICON: DWORD = 0x0000; +pub const LVS_REPORT: DWORD = 0x0001; +pub const LVS_SMALLICON: DWORD = 0x0002; +pub const LVS_LIST: DWORD = 0x0003; +pub const LVS_TYPEMASK: DWORD = 0x0003; +pub const LVS_SINGLESEL: DWORD = 0x0004; +pub const LVS_SHOWSELALWAYS: DWORD = 0x0008; +pub const LVS_SORTASCENDING: DWORD = 0x0010; +pub const LVS_SORTDESCENDING: DWORD = 0x0020; +pub const LVS_SHAREIMAGELISTS: DWORD = 0x0040; +pub const LVS_NOLABELWRAP: DWORD = 0x0080; +pub const LVS_AUTOARRANGE: DWORD = 0x0100; +pub const LVS_EDITLABELS: DWORD = 0x0200; +pub const LVS_OWNERDATA: DWORD = 0x1000; +pub const LVS_NOSCROLL: DWORD = 0x2000; +pub const LVS_TYPESTYLEMASK: DWORD = 0xfc00; +pub const LVS_ALIGNTOP: DWORD = 0x0000; +pub const LVS_ALIGNLEFT: DWORD = 0x0800; +pub const LVS_ALIGNMASK: DWORD = 0x0c00; +pub const LVS_OWNERDRAWFIXED: DWORD = 0x0400; +pub const LVS_NOCOLUMNHEADER: DWORD = 0x4000; +pub const LVS_NOSORTHEADER: DWORD = 0x8000; +pub const LVM_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const LVM_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const LVM_GETBKCOLOR: UINT = LVM_FIRST + 0; +pub const LVM_SETBKCOLOR: UINT = LVM_FIRST + 1; +pub const LVM_GETIMAGELIST: UINT = LVM_FIRST + 2; +pub const LVSIL_NORMAL: c_int = 0; +pub const LVSIL_SMALL: c_int = 1; +pub const LVSIL_STATE: c_int = 2; +pub const LVSIL_GROUPHEADER: c_int = 3; +pub const LVM_SETIMAGELIST: UINT = LVM_FIRST + 3; +pub const LVM_GETITEMCOUNT: UINT = LVM_FIRST + 4; +pub const LVIF_TEXT: UINT = 0x00000001; +pub const LVIF_IMAGE: UINT = 0x00000002; +pub const LVIF_PARAM: UINT = 0x00000004; +pub const LVIF_STATE: UINT = 0x00000008; +pub const LVIF_INDENT: UINT = 0x00000010; +pub const LVIF_NORECOMPUTE: UINT = 0x00000800; +pub const LVIF_GROUPID: UINT = 0x00000100; +pub const LVIF_COLUMNS: UINT = 0x00000200; +pub const LVIF_COLFMT: UINT = 0x00010000; +pub const LVIS_FOCUSED: UINT = 0x0001; +pub const LVIS_SELECTED: UINT = 0x0002; +pub const LVIS_CUT: UINT = 0x0004; +pub const LVIS_DROPHILITED: UINT = 0x0008; +pub const LVIS_GLOW: UINT = 0x0010; +pub const LVIS_ACTIVATING: UINT = 0x0020; +pub const LVIS_OVERLAYMASK: UINT = 0x0F00; +pub const LVIS_STATEIMAGEMASK: UINT = 0xF000; +#[inline] +pub fn INDEXTOSTATEIMAGEMASK(i: UINT) -> UINT { + i << 12 +} +pub const I_INDENTCALLBACK: c_int = -1; +pub type LV_ITEMA = LVITEMA; +pub type LV_ITEMW = LVITEMW; +pub const I_GROUPIDCALLBACK: c_int = -1; +pub const I_GROUPIDNONE: c_int = -2; +STRUCT!{struct LVITEMA { + mask: UINT, + iItem: c_int, + iSubItem: c_int, + state: UINT, + stateMask: UINT, + pszText: LPSTR, + cchTextMax: c_int, + iImage: c_int, + lParam: LPARAM, + iIndent: c_int, + iGroupId: c_int, + cColumns: UINT, + puColumns: PUINT, + piColFmt: *mut c_int, + iGroup: c_int, +}} +pub type LPLVITEMA = *mut LVITEMA; +STRUCT!{struct LVITEMW { + mask: UINT, + iItem: c_int, + iSubItem: c_int, + state: UINT, + stateMask: UINT, + pszText: LPWSTR, + cchTextMax: c_int, + iImage: c_int, + lParam: LPARAM, + iIndent: c_int, + iGroupId: c_int, + cColumns: UINT, + puColumns: PUINT, + piColFmt: *mut c_int, + iGroup: c_int, +}} +pub type LPLVITEMW = *mut LVITEMW; +pub const LPSTR_TEXTCALLBACKW: LPWSTR = -1isize as LPWSTR; +pub const LPSTR_TEXTCALLBACKA: LPSTR = -1isize as LPSTR; +pub const I_IMAGECALLBACK: c_int = -1; +pub const I_IMAGENONE: c_int = -2; +pub const I_COLUMNSCALLBACK: UINT = -1i32 as u32; +pub const LVM_GETITEMA: UINT = LVM_FIRST + 5; +pub const LVM_GETITEMW: UINT = LVM_FIRST + 75; +pub const LVM_SETITEMA: UINT = LVM_FIRST + 6; +pub const LVM_SETITEMW: UINT = LVM_FIRST + 76; +pub const LVM_INSERTITEMA: UINT = LVM_FIRST + 7; +pub const LVM_INSERTITEMW: UINT = LVM_FIRST + 77; +pub const LVM_DELETEITEM: UINT = LVM_FIRST + 8; +pub const LVM_DELETEALLITEMS: UINT = LVM_FIRST + 9; +pub const LVM_GETCALLBACKMASK: UINT = LVM_FIRST + 10; +pub const LVM_SETCALLBACKMASK: UINT = LVM_FIRST + 11; +pub const LVNI_ALL: LPARAM = 0x0000; +pub const LVNI_FOCUSED: LPARAM = 0x0001; +pub const LVNI_SELECTED: LPARAM = 0x0002; +pub const LVNI_CUT: LPARAM = 0x0004; +pub const LVNI_DROPHILITED: LPARAM = 0x0008; +pub const LVNI_STATEMASK: LPARAM = LVNI_FOCUSED | LVNI_SELECTED | LVNI_CUT | LVNI_DROPHILITED; +pub const LVNI_VISIBLEORDER: LPARAM = 0x0010; +pub const LVNI_PREVIOUS: LPARAM = 0x0020; +pub const LVNI_VISIBLEONLY: LPARAM = 0x0040; +pub const LVNI_SAMEGROUPONLY: LPARAM = 0x0080; +pub const LVNI_ABOVE: LPARAM = 0x0100; +pub const LVNI_BELOW: LPARAM = 0x0200; +pub const LVNI_TOLEFT: LPARAM = 0x0400; +pub const LVNI_TORIGHT: LPARAM = 0x0800; +pub const LVNI_DIRECTIONMASK: LPARAM = LVNI_ABOVE | LVNI_BELOW | LVNI_TOLEFT | LVNI_TORIGHT; +pub const LVM_GETNEXTITEM: UINT = LVM_FIRST + 12; +pub const LVFI_PARAM: UINT = 0x0001; +pub const LVFI_STRING: UINT = 0x0002; +pub const LVFI_SUBSTRING: UINT = 0x0004; +pub const LVFI_PARTIAL: UINT = 0x0008; +pub const LVFI_WRAP: UINT = 0x0020; +pub const LVFI_NEARESTXY: UINT = 0x0040; +pub type LV_FINDINFOA = LVFINDINFOA; +pub type LV_FINDINFOW = LVFINDINFOW; +STRUCT!{struct LVFINDINFOA { + flags: UINT, + psz: LPCSTR, + lParam: LPARAM, + pt: POINT, + vkDirection: UINT, +}} +pub type LPFINDINFOA = *mut LVFINDINFOA; +STRUCT!{struct LVFINDINFOW { + flags: UINT, + psz: LPCWSTR, + lParam: LPARAM, + pt: POINT, + vkDirection: UINT, +}} +pub type LPFINDINFOW = *mut LVFINDINFOW; +pub const LVM_FINDITEMA: UINT = LVM_FIRST + 13; +pub const LVM_FINDITEMW: UINT = LVM_FIRST + 83; +pub const LVIR_BOUNDS: c_int = 0; +pub const LVIR_ICON: c_int = 1; +pub const LVIR_LABEL: c_int = 2; +pub const LVIR_SELECTBOUNDS: c_int = 3; +pub const LVM_GETITEMRECT: UINT = LVM_FIRST + 14; +pub const LVM_SETITEMPOSITION: UINT = LVM_FIRST + 15; +pub const LVM_GETITEMPOSITION: UINT = LVM_FIRST + 16; +pub const LVM_GETSTRINGWIDTHA: UINT = LVM_FIRST + 17; +pub const LVM_GETSTRINGWIDTHW: UINT = LVM_FIRST + 87; +pub const LVHT_NOWHERE: UINT = 0x00000001; +pub const LVHT_ONITEMICON: UINT = 0x00000002; +pub const LVHT_ONITEMLABEL: UINT = 0x00000004; +pub const LVHT_ONITEMSTATEICON: UINT = 0x00000008; +pub const LVHT_ONITEM: UINT = LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON; +pub const LVHT_ABOVE: UINT = 0x00000008; +pub const LVHT_BELOW: UINT = 0x00000010; +pub const LVHT_TORIGHT: UINT = 0x00000020; +pub const LVHT_TOLEFT: UINT = 0x00000040; +pub const LVHT_EX_GROUP_HEADER: UINT = 0x10000000; +pub const LVHT_EX_GROUP_FOOTER: UINT = 0x20000000; +pub const LVHT_EX_GROUP_COLLAPSE: UINT = 0x40000000; +pub const LVHT_EX_GROUP_BACKGROUND: UINT = 0x80000000; +pub const LVHT_EX_GROUP_STATEICON: UINT = 0x01000000; +pub const LVHT_EX_GROUP_SUBSETLINK: UINT = 0x02000000; +pub const LVHT_EX_GROUP: UINT = LVHT_EX_GROUP_BACKGROUND | LVHT_EX_GROUP_COLLAPSE + | LVHT_EX_GROUP_FOOTER | LVHT_EX_GROUP_HEADER | LVHT_EX_GROUP_STATEICON + | LVHT_EX_GROUP_SUBSETLINK; +pub const LVHT_EX_ONCONTENTS: UINT = 0x04000000; +pub const LVHT_EX_FOOTER: UINT = 0x08000000; +pub type LV_HITTESTINFO = LVHITTESTINFO; +STRUCT!{struct LVHITTESTINFO { + pt: POINT, + flags: UINT, + iItem: c_int, + iSubItem: c_int, + iGroup: c_int, +}} +pub type LPLVHITTESTINFO = *mut LVHITTESTINFO; +pub const LVM_HITTEST: UINT = LVM_FIRST + 18; +pub const LVM_ENSUREVISIBLE: UINT = LVM_FIRST + 19; +pub const LVM_SCROLL: UINT = LVM_FIRST + 20; +pub const LVM_REDRAWITEMS: UINT = LVM_FIRST + 21; +pub const LVA_DEFAULT: WPARAM = 0x0000; +pub const LVA_ALIGNLEFT: WPARAM = 0x0001; +pub const LVA_ALIGNTOP: WPARAM = 0x0002; +pub const LVA_SNAPTOGRID: WPARAM = 0x0005; +pub const LVM_ARRANGE: UINT = LVM_FIRST + 22; +pub const LVM_EDITLABELA: UINT = LVM_FIRST + 23; +pub const LVM_EDITLABELW: UINT = LVM_FIRST + 118; +pub const LVM_GETEDITCONTROL: UINT = LVM_FIRST + 24; +pub type LV_COLUMNA = LVCOLUMNA; +pub type LV_COLUMNW = LVCOLUMNW; +STRUCT!{struct LVCOLUMNA { + mask: UINT, + fmt: c_int, + cx: c_int, + pszText: LPSTR, + cchTextMax: c_int, + iSubItem: c_int, + iImage: c_int, + iOrder: c_int, + cxMin: c_int, + cxDefault: c_int, + cxIdeal: c_int, +}} +pub type LPLVCOLUMNA = *mut LVCOLUMNA; +STRUCT!{struct LVCOLUMNW { + mask: UINT, + fmt: c_int, + cx: c_int, + pszText: LPWSTR, + cchTextMax: c_int, + iSubItem: c_int, + iImage: c_int, + iOrder: c_int, + cxMin: c_int, + cxDefault: c_int, + cxIdeal: c_int, +}} +pub type LPLVCOLUMNW = *mut LVCOLUMNW; +pub const LVCF_FMT: UINT = 0x0001; +pub const LVCF_WIDTH: UINT = 0x0002; +pub const LVCF_TEXT: UINT = 0x0004; +pub const LVCF_SUBITEM: UINT = 0x0008; +pub const LVCF_IMAGE: UINT = 0x0010; +pub const LVCF_ORDER: UINT = 0x0020; +pub const LVCF_MINWIDTH: UINT = 0x0040; +pub const LVCF_DEFAULTWIDTH: UINT = 0x0080; +pub const LVCF_IDEALWIDTH: UINT = 0x0100; +pub const LVCFMT_LEFT: c_int = 0x0000; +pub const LVCFMT_RIGHT: c_int = 0x0001; +pub const LVCFMT_CENTER: c_int = 0x0002; +pub const LVCFMT_JUSTIFYMASK: c_int = 0x0003; +pub const LVCFMT_IMAGE: c_int = 0x0800; +pub const LVCFMT_BITMAP_ON_RIGHT: c_int = 0x1000; +pub const LVCFMT_COL_HAS_IMAGES: c_int = 0x8000; +pub const LVCFMT_FIXED_WIDTH: c_int = 0x00100; +pub const LVCFMT_NO_DPI_SCALE: c_int = 0x40000; +pub const LVCFMT_FIXED_RATIO: c_int = 0x80000; +pub const LVCFMT_LINE_BREAK: c_int = 0x100000; +pub const LVCFMT_FILL: c_int = 0x200000; +pub const LVCFMT_WRAP: c_int = 0x400000; +pub const LVCFMT_NO_TITLE: c_int = 0x800000; +pub const LVCFMT_TILE_PLACEMENTMASK: c_int = LVCFMT_LINE_BREAK | LVCFMT_FILL; +pub const LVCFMT_SPLITBUTTON: c_int = 0x1000000; +pub const LVM_GETCOLUMNA: UINT = LVM_FIRST + 25; +pub const LVM_GETCOLUMNW: UINT = LVM_FIRST + 95; +pub const LVM_SETCOLUMNA: UINT = LVM_FIRST + 26; +pub const LVM_SETCOLUMNW: UINT = LVM_FIRST + 96; +pub const LVM_INSERTCOLUMNA: UINT = LVM_FIRST + 27; +pub const LVM_INSERTCOLUMNW: UINT = LVM_FIRST + 97; +pub const LVM_DELETECOLUMN: UINT = LVM_FIRST + 28; +pub const LVM_GETCOLUMNWIDTH: UINT = LVM_FIRST + 29; +pub const LVSCW_AUTOSIZE: c_int = -1; +pub const LVSCW_AUTOSIZE_USEHEADER: c_int = -2; +pub const LVM_SETCOLUMNWIDTH: UINT = LVM_FIRST + 30; +pub const LVM_GETHEADER: UINT = LVM_FIRST + 31; +pub const LVM_CREATEDRAGIMAGE: UINT = LVM_FIRST + 33; +pub const LVM_GETVIEWRECT: UINT = LVM_FIRST + 34; +pub const LVM_GETTEXTCOLOR: UINT = LVM_FIRST + 35; +pub const LVM_SETTEXTCOLOR: UINT = LVM_FIRST + 36; +pub const LVM_GETTEXTBKCOLOR: UINT = LVM_FIRST + 37; +pub const LVM_SETTEXTBKCOLOR: UINT = LVM_FIRST + 38; +pub const LVM_GETTOPINDEX: UINT = LVM_FIRST + 39; +pub const LVM_GETCOUNTPERPAGE: UINT = LVM_FIRST + 40; +pub const LVM_GETORIGIN: UINT = LVM_FIRST + 41; +pub const LVM_UPDATE: UINT = LVM_FIRST + 42; +pub const LVM_SETITEMSTATE: UINT = LVM_FIRST + 43; +pub const LVM_GETITEMSTATE: UINT = LVM_FIRST + 44; +pub const LVM_GETITEMTEXTA: UINT = LVM_FIRST + 45; +pub const LVM_GETITEMTEXTW: UINT = LVM_FIRST + 115; +pub const LVM_SETITEMTEXTA: UINT = LVM_FIRST + 46; +pub const LVM_SETITEMTEXTW: UINT = LVM_FIRST + 116; +pub const LVSICF_NOINVALIDATEALL: LPARAM = 0x00000001; +pub const LVSICF_NOSCROLL: LPARAM = 0x00000002; +pub const LVM_SETITEMCOUNT: UINT = LVM_FIRST + 47; +FN!{stdcall PFNLVCOMPARE( + LPARAM, + LPARAM, + LPARAM, +) -> c_int} +pub const LVM_SORTITEMS: UINT = LVM_FIRST + 48; +pub const LVM_SETITEMPOSITION32: UINT = LVM_FIRST + 49; +pub const LVM_GETSELECTEDCOUNT: UINT = LVM_FIRST + 50; +pub const LVM_GETITEMSPACING: UINT = LVM_FIRST + 51; +pub const LVM_GETISEARCHSTRINGA: UINT = LVM_FIRST + 52; +pub const LVM_GETISEARCHSTRINGW: UINT = LVM_FIRST + 117; +pub const LVM_SETICONSPACING: UINT = LVM_FIRST + 53; +pub const LVM_SETEXTENDEDLISTVIEWSTYLE: UINT = LVM_FIRST + 54; +pub const LVM_GETEXTENDEDLISTVIEWSTYLE: UINT = LVM_FIRST + 55; +pub const LVS_EX_GRIDLINES: DWORD = 0x00000001; +pub const LVS_EX_SUBITEMIMAGES: DWORD = 0x00000002; +pub const LVS_EX_CHECKBOXES: DWORD = 0x00000004; +pub const LVS_EX_TRACKSELECT: DWORD = 0x00000008; +pub const LVS_EX_HEADERDRAGDROP: DWORD = 0x00000010; +pub const LVS_EX_FULLROWSELECT: DWORD = 0x00000020; +pub const LVS_EX_ONECLICKACTIVATE: DWORD = 0x00000040; +pub const LVS_EX_TWOCLICKACTIVATE: DWORD = 0x00000080; +pub const LVS_EX_FLATSB: DWORD = 0x00000100; +pub const LVS_EX_REGIONAL: DWORD = 0x00000200; +pub const LVS_EX_INFOTIP: DWORD = 0x00000400; +pub const LVS_EX_UNDERLINEHOT: DWORD = 0x00000800; +pub const LVS_EX_UNDERLINECOLD: DWORD = 0x00001000; +pub const LVS_EX_MULTIWORKAREAS: DWORD = 0x00002000; +pub const LVS_EX_LABELTIP: DWORD = 0x00004000; +pub const LVS_EX_BORDERSELECT: DWORD = 0x00008000; +pub const LVS_EX_DOUBLEBUFFER: DWORD = 0x00010000; +pub const LVS_EX_HIDELABELS: DWORD = 0x00020000; +pub const LVS_EX_SINGLEROW: DWORD = 0x00040000; +pub const LVS_EX_SNAPTOGRID: DWORD = 0x00080000; +pub const LVS_EX_SIMPLESELECT: DWORD = 0x00100000; +pub const LVS_EX_JUSTIFYCOLUMNS: DWORD = 0x00200000; +pub const LVS_EX_TRANSPARENTBKGND: DWORD = 0x00400000; +pub const LVS_EX_TRANSPARENTSHADOWTEXT: DWORD = 0x00800000; +pub const LVS_EX_AUTOAUTOARRANGE: DWORD = 0x01000000; +pub const LVS_EX_HEADERINALLVIEWS: DWORD = 0x02000000; +pub const LVS_EX_AUTOCHECKSELECT: DWORD = 0x08000000; +pub const LVS_EX_AUTOSIZECOLUMNS: DWORD = 0x10000000; +pub const LVS_EX_COLUMNSNAPPOINTS: DWORD = 0x40000000; +pub const LVS_EX_COLUMNOVERFLOW: DWORD = 0x80000000; +pub const LVM_GETSUBITEMRECT: UINT = LVM_FIRST + 56; +pub const LVM_SUBITEMHITTEST: UINT = LVM_FIRST + 57; +pub const LVM_SETCOLUMNORDERARRAY: UINT = LVM_FIRST + 58; +pub const LVM_GETCOLUMNORDERARRAY: UINT = LVM_FIRST + 59; +pub const LVM_SETHOTITEM: UINT = LVM_FIRST + 60; +pub const LVM_GETHOTITEM: UINT = LVM_FIRST + 61; +pub const LVM_SETHOTCURSOR: UINT = LVM_FIRST + 62; +pub const LVM_GETHOTCURSOR: UINT = LVM_FIRST + 63; +pub const LVM_APPROXIMATEVIEWRECT: UINT = LVM_FIRST + 64; +pub const LV_MAX_WORKAREAS: WPARAM = 16; +pub const LVM_SETWORKAREAS: UINT = LVM_FIRST + 65; +pub const LVM_GETWORKAREAS: UINT = LVM_FIRST + 70; +pub const LVM_GETNUMBEROFWORKAREAS: UINT = LVM_FIRST + 73; +pub const LVM_GETSELECTIONMARK: UINT = LVM_FIRST + 66; +pub const LVM_SETSELECTIONMARK: UINT = LVM_FIRST + 67; +pub const LVM_SETHOVERTIME: UINT = LVM_FIRST + 71; +pub const LVM_GETHOVERTIME: UINT = LVM_FIRST + 72; +pub const LVM_SETTOOLTIPS: UINT = LVM_FIRST + 74; +pub const LVM_GETTOOLTIPS: UINT = LVM_FIRST + 78; +pub const LVM_SORTITEMSEX: UINT = LVM_FIRST + 81; +STRUCT!{struct LVBKIMAGEA { + ulFlags: ULONG, + hbm: HBITMAP, + pszImage: LPSTR, + cchImageMax: UINT, + xOffsetPercent: c_int, + yOffsetPercent: c_int, +}} +pub type LPLVBKIMAGEA = *mut LVBKIMAGEA; +STRUCT!{struct LVBKIMAGEW { + ulFlags: ULONG, + hbm: HBITMAP, + pszImage: LPWSTR, + cchImageMax: UINT, + xOffsetPercent: c_int, + yOffsetPercent: c_int, +}} +pub type LPLVBKIMAGEW = *mut LVBKIMAGEW; +pub const LVBKIF_SOURCE_NONE: ULONG = 0x00000000; +pub const LVBKIF_SOURCE_HBITMAP: ULONG = 0x00000001; +pub const LVBKIF_SOURCE_URL: ULONG = 0x00000002; +pub const LVBKIF_SOURCE_MASK: ULONG = 0x00000003; +pub const LVBKIF_STYLE_NORMAL: ULONG = 0x00000000; +pub const LVBKIF_STYLE_TILE: ULONG = 0x00000010; +pub const LVBKIF_STYLE_MASK: ULONG = 0x00000010; +pub const LVBKIF_FLAG_TILEOFFSET: ULONG = 0x00000100; +pub const LVBKIF_TYPE_WATERMARK: ULONG = 0x10000000; +pub const LVBKIF_FLAG_ALPHABLEND: ULONG = 0x20000000; +pub const LVM_SETBKIMAGEA: UINT = LVM_FIRST + 68; +pub const LVM_SETBKIMAGEW: UINT = LVM_FIRST + 138; +pub const LVM_GETBKIMAGEA: UINT = LVM_FIRST + 69; +pub const LVM_GETBKIMAGEW: UINT = LVM_FIRST + 139; +pub const LVM_SETSELECTEDCOLUMN: UINT = LVM_FIRST + 140; +pub const LV_VIEW_ICON: DWORD = 0x0000; +pub const LV_VIEW_DETAILS: DWORD = 0x0001; +pub const LV_VIEW_SMALLICON: DWORD = 0x0002; +pub const LV_VIEW_LIST: DWORD = 0x0003; +pub const LV_VIEW_TILE: DWORD = 0x0004; +pub const LV_VIEW_MAX: DWORD = 0x0004; +pub const LVM_SETVIEW: UINT = LVM_FIRST + 142; +pub const LVM_GETVIEW: UINT = LVM_FIRST + 143; +pub const LVGF_NONE: UINT = 0x00000000; +pub const LVGF_HEADER: UINT = 0x00000001; +pub const LVGF_FOOTER: UINT = 0x00000002; +pub const LVGF_STATE: UINT = 0x00000004; +pub const LVGF_ALIGN: UINT = 0x00000008; +pub const LVGF_GROUPID: UINT = 0x00000010; +pub const LVGF_SUBTITLE: UINT = 0x00000100; +pub const LVGF_TASK: UINT = 0x00000200; +pub const LVGF_DESCRIPTIONTOP: UINT = 0x00000400; +pub const LVGF_DESCRIPTIONBOTTOM: UINT = 0x00000800; +pub const LVGF_TITLEIMAGE: UINT = 0x00001000; +pub const LVGF_EXTENDEDIMAGE: UINT = 0x00002000; +pub const LVGF_ITEMS: UINT = 0x00004000; +pub const LVGF_SUBSET: UINT = 0x00008000; +pub const LVGF_SUBSETITEMS: UINT = 0x00010000; +pub const LVGS_NORMAL: UINT = 0x00000000; +pub const LVGS_COLLAPSED: UINT = 0x00000001; +pub const LVGS_HIDDEN: UINT = 0x00000002; +pub const LVGS_NOHEADER: UINT = 0x00000004; +pub const LVGS_COLLAPSIBLE: UINT = 0x00000008; +pub const LVGS_FOCUSED: UINT = 0x00000010; +pub const LVGS_SELECTED: UINT = 0x00000020; +pub const LVGS_SUBSETED: UINT = 0x00000040; +pub const LVGS_SUBSETLINKFOCUSED: UINT = 0x00000080; +pub const LVGA_HEADER_LEFT: UINT = 0x00000001; +pub const LVGA_HEADER_CENTER: UINT = 0x00000002; +pub const LVGA_HEADER_RIGHT: UINT = 0x00000004; +pub const LVGA_FOOTER_LEFT: UINT = 0x00000008; +pub const LVGA_FOOTER_CENTER: UINT = 0x00000010; +pub const LVGA_FOOTER_RIGHT: UINT = 0x00000020; +STRUCT!{struct LVGROUP { + cbSize: UINT, + mask: UINT, + pszHeader: LPWSTR, + cchHeader: c_int, + pszFooter: LPWSTR, + cchFooter: c_int, + iGroupId: c_int, + stateMask: UINT, + state: UINT, + uAlign: UINT, + pszSubtitle: LPWSTR, + cchSubtitle: UINT, + pszTask: LPWSTR, + cchTask: UINT, + pszDescriptionTop: LPWSTR, + cchDescriptionTop: UINT, + pszDescriptionBottom: LPWSTR, + cchDescriptionBottom: UINT, + iTitleImage: c_int, + iExtendedImage: c_int, + iFirstItem: c_int, + cItems: UINT, + pszSubsetTitle: LPWSTR, + cchSubsetTitle: UINT, +}} +pub type PLVGROUP = *mut LVGROUP; +pub const LVM_INSERTGROUP: UINT = LVM_FIRST + 145; +pub const LVM_SETGROUPINFO: UINT = LVM_FIRST + 147; +pub const LVM_GETGROUPINFO: UINT = LVM_FIRST + 149; +pub const LVM_REMOVEGROUP: UINT = LVM_FIRST + 150; +pub const LVM_MOVEGROUP: UINT = LVM_FIRST + 151; +pub const LVM_GETGROUPCOUNT: UINT = LVM_FIRST + 152; +pub const LVM_GETGROUPINFOBYINDEX: UINT = LVM_FIRST + 153; +pub const LVM_MOVEITEMTOGROUP: UINT = LVM_FIRST + 154; +pub const LVGGR_GROUP: LPARAM = 0; +pub const LVGGR_HEADER: LPARAM = 1; +pub const LVGGR_LABEL: LPARAM = 2; +pub const LVGGR_SUBSETLINK: LPARAM = 3; +pub const LVM_GETGROUPRECT: UINT = LVM_FIRST + 98; +pub const LVGMF_NONE: UINT = 0x00000000; +pub const LVGMF_BORDERSIZE: UINT = 0x00000001; +pub const LVGMF_BORDERCOLOR: UINT = 0x00000002; +pub const LVGMF_TEXTCOLOR: UINT = 0x00000004; +STRUCT!{struct LVGROUPMETRICS { + cbSize: UINT, + mask: UINT, + Left: UINT, + Top: UINT, + Right: UINT, + Bottom: UINT, + crLeft: COLORREF, + crTop: COLORREF, + crRight: COLORREF, + crBottom: COLORREF, + crHeader: COLORREF, + crFooter: COLORREF, +}} +pub type PLVGROUPMETRICS = *mut LVGROUPMETRICS; +pub const LVM_SETGROUPMETRICS: UINT = LVM_FIRST + 155; +pub const LVM_GETGROUPMETRICS: UINT = LVM_FIRST + 156; +pub const LVM_ENABLEGROUPVIEW: UINT = LVM_FIRST + 157; +FN!{stdcall PFNLVGROUPCOMPARE( + c_int, + c_int, + *mut c_void, +) -> c_int} +pub const LVM_SORTGROUPS: UINT = LVM_FIRST + 158; +STRUCT!{struct LVINSERTGROUPSORTED { + pfnGroupCompare: PFNLVGROUPCOMPARE, + pvData: *mut c_void, + lvGroup: LVGROUP, +}} +pub type PLVINSERTGROUPSORTED = *mut LVINSERTGROUPSORTED; +pub const LVM_INSERTGROUPSORTED: UINT = LVM_FIRST + 159; +pub const LVM_REMOVEALLGROUPS: UINT = LVM_FIRST + 160; +pub const LVM_HASGROUP: UINT = LVM_FIRST + 161; +pub const LVM_GETGROUPSTATE: UINT = LVM_FIRST + 92; +pub const LVM_GETFOCUSEDGROUP: UINT = LVM_FIRST + 93; +pub const LVTVIF_AUTOSIZE: DWORD = 0x00000000; +pub const LVTVIF_FIXEDWIDTH: DWORD = 0x00000001; +pub const LVTVIF_FIXEDHEIGHT: DWORD = 0x00000002; +pub const LVTVIF_FIXEDSIZE: DWORD = 0x00000003; +pub const LVTVIF_EXTENDED: DWORD = 0x00000004; +pub const LVTVIM_TILESIZE: DWORD = 0x00000001; +pub const LVTVIM_COLUMNS: DWORD = 0x00000002; +pub const LVTVIM_LABELMARGIN: DWORD = 0x00000004; +STRUCT!{struct LVTILEVIEWINFO { + cbSize: UINT, + dwMask: DWORD, + dwFlags: DWORD, + sizeTile: SIZE, + cLines: c_int, + rcLabelMargin: RECT, +}} +pub type PLVTILEVIEWINFO = *mut LVTILEVIEWINFO; +STRUCT!{struct LVTILEINFO { + cbSize: UINT, + iItem: c_int, + cColumns: UINT, + puColumns: PUINT, + piColFmt: *mut c_int, +}} +pub type PLVTILEINFO = *mut LVTILEINFO; +pub const LVM_SETTILEVIEWINFO: UINT = LVM_FIRST + 162; +pub const LVM_GETTILEVIEWINFO: UINT = LVM_FIRST + 163; +pub const LVM_SETTILEINFO: UINT = LVM_FIRST + 164; +pub const LVM_GETTILEINFO: UINT = LVM_FIRST + 165; +STRUCT!{struct LVINSERTMARK { + cbSize: UINT, + dwFlags: DWORD, + iItem: c_int, + dwReserved: DWORD, +}} +pub type LPLVINSERTMARK = *mut LVINSERTMARK; +pub const LVIM_AFTER: DWORD = 0x00000001; +pub const LVM_SETINSERTMARK: UINT = LVM_FIRST + 166; +pub const LVM_GETINSERTMARK: UINT = LVM_FIRST + 167; +pub const LVM_INSERTMARKHITTEST: UINT = LVM_FIRST + 168; +pub const LVM_GETINSERTMARKRECT: UINT = LVM_FIRST + 169; +pub const LVM_SETINSERTMARKCOLOR: UINT = LVM_FIRST + 170; +pub const LVM_GETINSERTMARKCOLOR: UINT = LVM_FIRST + 171; +STRUCT!{struct LVSETINFOTIP { + cbSize: UINT, + dwFlags: DWORD, + pszText: LPWSTR, + iItem: c_int, + iSubItem: c_int, +}} +pub type PLVSETINFOTIP = *mut LVSETINFOTIP; +pub const LVM_SETINFOTIP: UINT = LVM_FIRST + 173; +pub const LVM_GETSELECTEDCOLUMN: UINT = LVM_FIRST + 174; +pub const LVM_ISGROUPVIEWENABLED: UINT = LVM_FIRST + 175; +pub const LVM_GETOUTLINECOLOR: UINT = LVM_FIRST + 176; +pub const LVM_SETOUTLINECOLOR: UINT = LVM_FIRST + 177; +pub const LVM_CANCELEDITLABEL: UINT = LVM_FIRST + 179; +pub const LVM_MAPINDEXTOID: UINT = LVM_FIRST + 180; +pub const LVM_MAPIDTOINDEX: UINT = LVM_FIRST + 181; +pub const LVM_ISITEMVISIBLE: UINT = LVM_FIRST + 182; +pub const LVM_GETEMPTYTEXT: UINT = LVM_FIRST + 204; +pub const LVM_GETFOOTERRECT: UINT = LVM_FIRST + 205; +pub const LVFF_ITEMCOUNT: UINT = 0x00000001; +STRUCT!{struct LVFOOTERINFO { + mask: UINT, + pszText: LPWSTR, + cchTextMax: c_int, + cItems: UINT, +}} +pub type LPLVFOOTERINFO = *mut LVFOOTERINFO; +pub const LVM_GETFOOTERINFO: UINT = LVM_FIRST + 206; +pub const LVM_GETFOOTERITEMRECT: UINT = LVM_FIRST + 207; +pub const LVFIF_TEXT: UINT = 0x00000001; +pub const LVFIF_STATE: UINT = 0x00000002; +pub const LVFIS_FOCUSED: UINT = 0x0001; +STRUCT!{struct LVFOOTERITEM { + mask: UINT, + iItem: c_int, + pszText: LPWSTR, + cchTextMax: c_int, + state: UINT, + stateMask: UINT, +}} +pub type LPLVFOOTERITEM = *mut LVFOOTERITEM; +pub const LVM_GETFOOTERITEM: UINT = LVM_FIRST + 208; +STRUCT!{struct LVITEMINDEX { + iItem: c_int, + iGroup: c_int, +}} +pub type PLVITEMINDEX = *mut LVITEMINDEX; +pub const LVM_GETITEMINDEXRECT: UINT = LVM_FIRST + 209; +pub const LVM_SETITEMINDEXSTATE: UINT = LVM_FIRST + 210; +pub const LVM_GETNEXTITEMINDEX: UINT = LVM_FIRST + 211; +pub type LPNM_LISTVIEW = LPNMLISTVIEW; +pub type NM_LISTVIEW = NMLISTVIEW; +STRUCT!{struct NMLISTVIEW { + hdr: NMHDR, + iItem: c_int, + iSubItem: c_int, + uNewState: UINT, + uOldState: UINT, + uChanged: UINT, + ptAction: POINT, + lParam: LPARAM, +}} +pub type LPNMLISTVIEW = *mut NMLISTVIEW; +STRUCT!{struct NMITEMACTIVATE { + hdr: NMHDR, + iItem: c_int, + iSubItem: c_int, + uNewState: UINT, + uOldState: UINT, + uChanged: UINT, + ptAction: POINT, + lParam: LPARAM, + uKeyFlags: UINT, +}} +pub type LPNMITEMACTIVATE = *mut NMITEMACTIVATE; +pub const LVKF_ALT: UINT = 0x0001; +pub const LVKF_CONTROL: UINT = 0x0002; +pub const LVKF_SHIFT: UINT = 0x0004; +STRUCT!{struct NMLVCUSTOMDRAW { + nmcd: NMCUSTOMDRAW, + clrText: COLORREF, + clrTextBk: COLORREF, + iSubItem: c_int, + dwItemType: DWORD, + clrFace: COLORREF, + iIconEffect: c_int, + iIconPhase: c_int, + iPartId: c_int, + iStateId: c_int, + rcText: RECT, + uAlign: UINT, +}} +pub type LPNMLVCUSTOMDRAW = *mut NMLVCUSTOMDRAW; +pub const LVCDI_ITEM: DWORD = 0x00000000; +pub const LVCDI_GROUP: DWORD = 0x00000001; +pub const LVCDI_ITEMSLIST: DWORD = 0x00000002; +pub const LVCDRF_NOSELECT: LRESULT = 0x00010000; +pub const LVCDRF_NOGROUPFRAME: LRESULT = 0x00020000; +STRUCT!{struct NMLVCACHEHINT { + hdr: NMHDR, + iFrom: c_int, + iTo: c_int, +}} +pub type LPNMLVCACHEHINT = *mut NMLVCACHEHINT; +pub type LPNM_CACHEHINT = LPNMLVCACHEHINT; +pub type PNM_CACHEHINT = LPNMLVCACHEHINT; +pub type NM_CACHEHINT = NMLVCACHEHINT; +STRUCT!{struct NMLVFINDITEMA { + hdr: NMHDR, + iStart: c_int, + lvfi: LVFINDINFOA, +}} +pub type LPNMLVFINDITEMA = *mut NMLVFINDITEMA; +STRUCT!{struct NMLVFINDITEMW { + hdr: NMHDR, + iStart: c_int, + lvfi: LVFINDINFOW, +}} +pub type LPNMLVFINDITEMW = *mut NMLVFINDITEMW; +pub type PNM_FINDITEMA = LPNMLVFINDITEMA; +pub type LPNM_FINDITEMA = LPNMLVFINDITEMA; +pub type NM_FINDITEMA = NMLVFINDITEMA; +pub type PNM_FINDITEMW = LPNMLVFINDITEMW; +pub type LPNM_FINDITEMW = LPNMLVFINDITEMW; +pub type NM_FINDITEMW = NMLVFINDITEMW; +STRUCT!{struct NMLVODSTATECHANGE { + hdr: NMHDR, + iFrom: c_int, + iTo: c_int, + uNewState: UINT, + uOldState: UINT, +}} +pub type LPNMLVODSTATECHANGE = *mut NMLVODSTATECHANGE; +pub type PNM_ODSTATECHANGE = LPNMLVODSTATECHANGE; +pub type LPNM_ODSTATECHANGE = LPNMLVODSTATECHANGE; +pub type NM_ODSTATECHANGE = NMLVODSTATECHANGE; +pub const LVN_ITEMCHANGING: UINT = LVN_FIRST - 0; +pub const LVN_ITEMCHANGED: UINT = LVN_FIRST - 1; +pub const LVN_INSERTITEM: UINT = LVN_FIRST - 2; +pub const LVN_DELETEITEM: UINT = LVN_FIRST - 3; +pub const LVN_DELETEALLITEMS: UINT = LVN_FIRST - 4; +pub const LVN_BEGINLABELEDITA: UINT = LVN_FIRST - 5; +pub const LVN_BEGINLABELEDITW: UINT = LVN_FIRST - 75; +pub const LVN_ENDLABELEDITA: UINT = LVN_FIRST - 6; +pub const LVN_ENDLABELEDITW: UINT = LVN_FIRST - 76; +pub const LVN_COLUMNCLICK: UINT = LVN_FIRST - 8; +pub const LVN_BEGINDRAG: UINT = LVN_FIRST - 9; +pub const LVN_BEGINRDRAG: UINT = LVN_FIRST - 11; +pub const LVN_ODCACHEHINT: UINT = LVN_FIRST - 13; +pub const LVN_ODFINDITEMA: UINT = LVN_FIRST - 52; +pub const LVN_ODFINDITEMW: UINT = LVN_FIRST - 79; +pub const LVN_ITEMACTIVATE: UINT = LVN_FIRST - 14; +pub const LVN_ODSTATECHANGED: UINT = LVN_FIRST - 15; +pub const LVN_HOTTRACK: UINT = LVN_FIRST - 21; +pub const LVN_GETDISPINFOA: UINT = LVN_FIRST - 50; +pub const LVN_GETDISPINFOW: UINT = LVN_FIRST - 77; +pub const LVN_SETDISPINFOA: UINT = LVN_FIRST - 51; +pub const LVN_SETDISPINFOW: UINT = LVN_FIRST - 78; +pub const LVIF_DI_SETITEM: UINT = 0x1000; +pub type LV_DISPINFOA = NMLVDISPINFOA; +pub type LV_DISPINFOW = NMLVDISPINFOW; +STRUCT!{struct NMLVDISPINFOA { + hdr: NMHDR, + item: LVITEMA, +}} +pub type LPNMLVDISPINFOA = *mut NMLVDISPINFOA; +STRUCT!{struct NMLVDISPINFOW { + hdr: NMHDR, + item: LVITEMW, +}} +pub type LPNMLVDISPINFOW = *mut NMLVDISPINFOW; +pub const LVN_KEYDOWN: UINT = LVN_FIRST - 55; +pub type LV_KEYDOWN = NMLVKEYDOWN; +STRUCT!{#[repr(packed)] struct NMLVKEYDOWN { + hdr: NMHDR, + wVKey: WORD, + flags: UINT, +}} +pub type LPNMLVKEYDOWN = *mut NMLVKEYDOWN; +pub const LVN_MARQUEEBEGIN: UINT = LVN_FIRST - 56; +STRUCT!{struct NMLVLINK { + hdr: NMHDR, + link: LITEM, + iItem: c_int, + iSubItem: c_int, +}} +pub type PNMLVLINK = *mut NMLVLINK; +STRUCT!{struct NMLVGETINFOTIPA { + hdr: NMHDR, + dwFlags: DWORD, + pszText: LPSTR, + cchTextMax: c_int, + iItem: c_int, + iSubItem: c_int, + lParam: LPARAM, +}} +pub type LPNMLVGETINFOTIPA = *mut NMLVGETINFOTIPA; +STRUCT!{struct NMLVGETINFOTIPW { + hdr: NMHDR, + dwFlags: DWORD, + pszText: LPWSTR, + cchTextMax: c_int, + iItem: c_int, + iSubItem: c_int, + lParam: LPARAM, +}} +pub type LPNMLVGETINFOTIPW = *mut NMLVGETINFOTIPW; +pub const LVGIT_UNFOLDED: DWORD = 0x0001; +pub const LVN_GETINFOTIPA: UINT = LVN_FIRST - 57; +pub const LVN_GETINFOTIPW: UINT = LVN_FIRST - 58; +pub const LVNSCH_DEFAULT: LPARAM = -1; +pub const LVNSCH_ERROR: LPARAM = -2; +pub const LVNSCH_IGNORE: LPARAM = -3; +pub const LVN_INCREMENTALSEARCHA: UINT = LVN_FIRST - 62; +pub const LVN_INCREMENTALSEARCHW: UINT = LVN_FIRST - 63; +pub const LVN_COLUMNDROPDOWN: UINT = LVN_FIRST - 64; +pub const LVN_COLUMNOVERFLOWCLICK: UINT = LVN_FIRST - 66; +STRUCT!{struct NMLVSCROLL { + hdr: NMHDR, + dx: c_int, + dy: c_int, +}} +pub type LPNMLVSCROLL = *mut NMLVSCROLL; +pub const LVN_BEGINSCROLL: UINT = LVN_FIRST - 80; +pub const LVN_ENDSCROLL: UINT = LVN_FIRST - 81; +pub const LVN_LINKCLICK: UINT = LVN_FIRST - 84; +pub const EMF_CENTERED: DWORD = 0x00000001; +STRUCT!{struct NMLVEMPTYMARKUP { + hdr: NMHDR, + dwFlags: DWORD, + szMarkup: [WCHAR; L_MAX_URL_LENGTH], +}} +pub const LVN_GETEMPTYMARKUP: UINT = LVN_FIRST - 87; +pub const WC_TREEVIEW: &'static str = "SysTreeView32"; +pub const TVS_HASBUTTONS: DWORD = 0x0001; +pub const TVS_HASLINES: DWORD = 0x0002; +pub const TVS_LINESATROOT: DWORD = 0x0004; +pub const TVS_EDITLABELS: DWORD = 0x0008; +pub const TVS_DISABLEDRAGDROP: DWORD = 0x0010; +pub const TVS_SHOWSELALWAYS: DWORD = 0x0020; +pub const TVS_RTLREADING: DWORD = 0x0040; +pub const TVS_NOTOOLTIPS: DWORD = 0x0080; +pub const TVS_CHECKBOXES: DWORD = 0x0100; +pub const TVS_TRACKSELECT: DWORD = 0x0200; +pub const TVS_SINGLEEXPAND: DWORD = 0x0400; +pub const TVS_INFOTIP: DWORD = 0x0800; +pub const TVS_FULLROWSELECT: DWORD = 0x1000; +pub const TVS_NOSCROLL: DWORD = 0x2000; +pub const TVS_NONEVENHEIGHT: DWORD = 0x4000; +pub const TVS_NOHSCROLL: DWORD = 0x8000; +pub const TVS_EX_NOSINGLECOLLAPSE: DWORD = 0x0001; +pub const TVS_EX_MULTISELECT: DWORD = 0x0002; +pub const TVS_EX_DOUBLEBUFFER: DWORD = 0x0004; +pub const TVS_EX_NOINDENTSTATE: DWORD = 0x0008; +pub const TVS_EX_RICHTOOLTIP: DWORD = 0x0010; +pub const TVS_EX_AUTOHSCROLL: DWORD = 0x0020; +pub const TVS_EX_FADEINOUTEXPANDOS: DWORD = 0x0040; +pub const TVS_EX_PARTIALCHECKBOXES: DWORD = 0x0080; +pub const TVS_EX_EXCLUSIONCHECKBOXES: DWORD = 0x0100; +pub const TVS_EX_DIMMEDCHECKBOXES: DWORD = 0x0200; +pub const TVS_EX_DRAWIMAGEASYNC: DWORD = 0x0400; +pub enum TREEITEM {} +pub type HTREEITEM = *mut TREEITEM; +pub const TVIF_TEXT: UINT = 0x0001; +pub const TVIF_IMAGE: UINT = 0x0002; +pub const TVIF_PARAM: UINT = 0x0004; +pub const TVIF_STATE: UINT = 0x0008; +pub const TVIF_HANDLE: UINT = 0x0010; +pub const TVIF_SELECTEDIMAGE: UINT = 0x0020; +pub const TVIF_CHILDREN: UINT = 0x0040; +pub const TVIF_INTEGRAL: UINT = 0x0080; +pub const TVIF_STATEEX: UINT = 0x0100; +pub const TVIF_EXPANDEDIMAGE: UINT = 0x0200; +pub const TVIS_SELECTED: UINT = 0x0002; +pub const TVIS_CUT: UINT = 0x0004; +pub const TVIS_DROPHILITED: UINT = 0x0008; +pub const TVIS_BOLD: UINT = 0x0010; +pub const TVIS_EXPANDED: UINT = 0x0020; +pub const TVIS_EXPANDEDONCE: UINT = 0x0040; +pub const TVIS_EXPANDPARTIAL: UINT = 0x0080; +pub const TVIS_OVERLAYMASK: UINT = 0x0F00; +pub const TVIS_STATEIMAGEMASK: UINT = 0xF000; +pub const TVIS_USERMASK: UINT = 0xF000; +pub const TVIS_EX_FLAT: UINT = 0x0001; +pub const TVIS_EX_DISABLED: UINT = 0x0002; +pub const TVIS_EX_ALL: UINT = 0x0002; +STRUCT!{struct NMTVSTATEIMAGECHANGING { + hdr: NMHDR, + hti: HTREEITEM, + iOldStateImageIndex: c_int, + iNewStateImageIndex: c_int, +}} +pub type LPNMTVSTATEIMAGECHANGING = *mut NMTVSTATEIMAGECHANGING; +pub const I_CHILDRENCALLBACK: c_int = -1; +pub const I_CHILDRENAUTO: c_int = -2; +pub type LPTV_ITEMW = LPTVITEMW; +pub type LPTV_ITEMA = LPTVITEMA; +pub type TV_ITEMW = TVITEMW; +pub type TV_ITEMA = TVITEMA; +STRUCT!{struct TVITEMA { + mask: UINT, + hItem: HTREEITEM, + state: UINT, + stateMask: UINT, + pszText: LPSTR, + cchTextMax: c_int, + iImage: c_int, + iSelectedImage: c_int, + cChildren: c_int, + lParam: LPARAM, +}} +pub type LPTVITEMA = *mut TVITEMA; +STRUCT!{struct TVITEMW { + mask: UINT, + hItem: HTREEITEM, + state: UINT, + stateMask: UINT, + pszText: LPWSTR, + cchTextMax: c_int, + iImage: c_int, + iSelectedImage: c_int, + cChildren: c_int, + lParam: LPARAM, +}} +pub type LPTVITEMW = *mut TVITEMW; +STRUCT!{struct TVITEMEXA { + mask: UINT, + hItem: HTREEITEM, + state: UINT, + stateMask: UINT, + pszText: LPSTR, + cchTextMax: c_int, + iImage: c_int, + iSelectedImage: c_int, + cChildren: c_int, + lParam: LPARAM, + iIntegral: c_int, + uStateEx: UINT, + hwnd: HWND, + iExpandedImage: c_int, + iReserved: c_int, +}} +pub type LPTVITEMEXA = *mut TVITEMEXA; +STRUCT!{struct TVITEMEXW { + mask: UINT, + hItem: HTREEITEM, + state: UINT, + stateMask: UINT, + pszText: LPWSTR, + cchTextMax: c_int, + iImage: c_int, + iSelectedImage: c_int, + cChildren: c_int, + lParam: LPARAM, + iIntegral: c_int, + uStateEx: UINT, + hwnd: HWND, + iExpandedImage: c_int, + iReserved: c_int, +}} +pub type LPTVITEMEXW = *mut TVITEMEXW; +pub const TVI_ROOT: HTREEITEM = -0x10000isize as HTREEITEM; +pub const TVI_FIRST: HTREEITEM = -0x0FFFFisize as HTREEITEM; +pub const TVI_LAST: HTREEITEM = -0x0FFFEisize as HTREEITEM; +pub const TVI_SORT: HTREEITEM = -0x0FFFDisize as HTREEITEM; +pub type LPTV_INSERTSTRUCTA = LPTVINSERTSTRUCTA; +pub type LPTV_INSERTSTRUCTW = LPTVINSERTSTRUCTW; +pub type TV_INSERTSTRUCTA = TVINSERTSTRUCTA; +pub type TV_INSERTSTRUCTW = TVINSERTSTRUCTW; +UNION!{union TVINSERTSTRUCTA_u { + [u32; 15] [u64; 10], + itemex itemex_mut: TVITEMEXA, + item item_mut: TV_ITEMA, +}} +STRUCT!{struct TVINSERTSTRUCTA { + hParent: HTREEITEM, + hInsertAfter: HTREEITEM, + u: TVINSERTSTRUCTA_u, +}} +pub type LPTVINSERTSTRUCTA = *mut TVINSERTSTRUCTA; +UNION!{union TVINSERTSTRUCTW_u { + [u32; 15] [u64; 10], + itemex itemex_mut: TVITEMEXW, + item item_mut: TV_ITEMW, +}} +STRUCT!{struct TVINSERTSTRUCTW { + hParent: HTREEITEM, + hInsertAfter: HTREEITEM, + u: TVINSERTSTRUCTW_u, +}} +pub type LPTVINSERTSTRUCTW = *mut TVINSERTSTRUCTW; +pub const TVM_INSERTITEMA: UINT = TV_FIRST + 0; +pub const TVM_INSERTITEMW: UINT = TV_FIRST + 50; +pub const TVM_DELETEITEM: UINT = TV_FIRST + 1; +pub const TVM_EXPAND: UINT = TV_FIRST + 2; +pub const TVE_COLLAPSE: WPARAM = 0x0001; +pub const TVE_EXPAND: WPARAM = 0x0002; +pub const TVE_TOGGLE: WPARAM = 0x0003; +pub const TVE_EXPANDPARTIAL: WPARAM = 0x4000; +pub const TVE_COLLAPSERESET: WPARAM = 0x8000; +pub const TVM_GETITEMRECT: UINT = TV_FIRST + 4; +pub const TVM_GETCOUNT: UINT = TV_FIRST + 5; +pub const TVM_GETINDENT: UINT = TV_FIRST + 6; +pub const TVM_SETINDENT: UINT = TV_FIRST + 7; +pub const TVM_GETIMAGELIST: UINT = TV_FIRST + 8; +pub const TVSIL_NORMAL: WPARAM = 0; +pub const TVSIL_STATE: WPARAM = 2; +pub const TVM_SETIMAGELIST: UINT = TV_FIRST + 9; +pub const TVM_GETNEXTITEM: UINT = TV_FIRST + 10; +pub const TVGN_ROOT: WPARAM = 0x0000; +pub const TVGN_NEXT: WPARAM = 0x0001; +pub const TVGN_PREVIOUS: WPARAM = 0x0002; +pub const TVGN_PARENT: WPARAM = 0x0003; +pub const TVGN_CHILD: WPARAM = 0x0004; +pub const TVGN_FIRSTVISIBLE: WPARAM = 0x0005; +pub const TVGN_NEXTVISIBLE: WPARAM = 0x0006; +pub const TVGN_PREVIOUSVISIBLE: WPARAM = 0x0007; +pub const TVGN_DROPHILITE: WPARAM = 0x0008; +pub const TVGN_CARET: WPARAM = 0x0009; +pub const TVGN_LASTVISIBLE: WPARAM = 0x000A; +pub const TVGN_NEXTSELECTED: WPARAM = 0x000B; +pub const TVSI_NOSINGLEEXPAND: WPARAM = 0x8000; +pub const TVM_SELECTITEM: UINT = TV_FIRST + 11; +pub const TVM_GETITEMA: UINT = TV_FIRST + 12; +pub const TVM_GETITEMW: UINT = TV_FIRST + 62; +pub const TVM_SETITEMA: UINT = TV_FIRST + 13; +pub const TVM_SETITEMW: UINT = TV_FIRST + 63; +pub const TVM_EDITLABELA: UINT = TV_FIRST + 14; +pub const TVM_EDITLABELW: UINT = TV_FIRST + 65; +pub const TVM_GETEDITCONTROL: UINT = TV_FIRST + 15; +pub const TVM_GETVISIBLECOUNT: UINT = TV_FIRST + 16; +pub const TVM_HITTEST: UINT = TV_FIRST + 17; +pub type LPTV_HITTESTINFO = LPTVHITTESTINFO; +pub type TV_HITTESTINFO = TVHITTESTINFO; +STRUCT!{struct TVHITTESTINFO { + pt: POINT, + flags: UINT, + hItem: HTREEITEM, +}} +pub type LPTVHITTESTINFO = *mut TVHITTESTINFO; +pub const TVHT_NOWHERE: UINT = 0x0001; +pub const TVHT_ONITEMICON: UINT = 0x0002; +pub const TVHT_ONITEMLABEL: UINT = 0x0004; +pub const TVHT_ONITEM: UINT = TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMSTATEICON; +pub const TVHT_ONITEMINDENT: UINT = 0x0008; +pub const TVHT_ONITEMBUTTON: UINT = 0x0010; +pub const TVHT_ONITEMRIGHT: UINT = 0x0020; +pub const TVHT_ONITEMSTATEICON: UINT = 0x0040; +pub const TVHT_ABOVE: UINT = 0x0100; +pub const TVHT_BELOW: UINT = 0x0200; +pub const TVHT_TORIGHT: UINT = 0x0400; +pub const TVHT_TOLEFT: UINT = 0x0800; +pub const TVM_CREATEDRAGIMAGE: UINT = TV_FIRST + 18; +pub const TVM_SORTCHILDREN: UINT = TV_FIRST + 19; +pub const TVM_ENSUREVISIBLE: UINT = TV_FIRST + 20; +pub const TVM_SORTCHILDRENCB: UINT = TV_FIRST + 21; +pub const TVM_ENDEDITLABELNOW: UINT = TV_FIRST + 22; +pub const TVM_GETISEARCHSTRINGA: UINT = TV_FIRST + 23; +pub const TVM_GETISEARCHSTRINGW: UINT = TV_FIRST + 64; +pub const TVM_SETTOOLTIPS: UINT = TV_FIRST + 24; +pub const TVM_GETTOOLTIPS: UINT = TV_FIRST + 25; +pub const TVM_SETINSERTMARK: UINT = TV_FIRST + 26; +pub const TVM_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const TVM_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const TVM_SETITEMHEIGHT: UINT = TV_FIRST + 27; +pub const TVM_GETITEMHEIGHT: UINT = TV_FIRST + 28; +pub const TVM_SETBKCOLOR: UINT = TV_FIRST + 29; +pub const TVM_SETTEXTCOLOR: UINT = TV_FIRST + 30; +pub const TVM_GETBKCOLOR: UINT = TV_FIRST + 31; +pub const TVM_GETTEXTCOLOR: UINT = TV_FIRST + 32; +pub const TVM_SETSCROLLTIME: UINT = TV_FIRST + 33; +pub const TVM_GETSCROLLTIME: UINT = TV_FIRST + 34; +pub const TVM_SETINSERTMARKCOLOR: UINT = TV_FIRST + 37; +pub const TVM_GETINSERTMARKCOLOR: UINT = TV_FIRST + 38; +pub const TVM_SETBORDER: UINT = TV_FIRST + 35; +pub const TVSBF_XBORDER: WPARAM = 0x00000001; +pub const TVSBF_YBORDER: WPARAM = 0x00000002; +pub const TVM_GETITEMSTATE: UINT = TV_FIRST + 39; +pub const TVM_SETLINECOLOR: UINT = TV_FIRST + 40; +pub const TVM_GETLINECOLOR: UINT = TV_FIRST + 41; +pub const TVM_MAPACCIDTOHTREEITEM: UINT = TV_FIRST + 42; +pub const TVM_MAPHTREEITEMTOACCID: UINT = TV_FIRST + 43; +pub const TVM_SETEXTENDEDSTYLE: UINT = TV_FIRST + 44; +pub const TVM_GETEXTENDEDSTYLE: UINT = TV_FIRST + 45; +pub const TVM_SETAUTOSCROLLINFO: UINT = TV_FIRST + 59; +pub const TVM_SETHOT: UINT = TV_FIRST + 58; +pub const TVM_GETSELECTEDCOUNT: UINT = TV_FIRST + 70; +pub const TVM_SHOWINFOTIP: UINT = TV_FIRST + 71; +ENUM!{enum TVITEMPART { + TVGIPR_BUTTON = 0x0001, +}} +STRUCT!{struct TVGETITEMPARTRECTINFO { + hti: HTREEITEM, + prc: *mut RECT, + partID: TVITEMPART, +}} +pub const TVM_GETITEMPARTRECT: UINT = TV_FIRST + 72; +FN!{stdcall PFNTVCOMPARE( + lParam1: LPARAM, + lParam2: LPARAM, + lParamSort: LPARAM, +) -> c_int} +pub type LPTV_SORTCB = LPTVSORTCB; +pub type TV_SORTCB = TVSORTCB; +STRUCT!{struct TVSORTCB { + hParent: HTREEITEM, + lpfnCompare: PFNTVCOMPARE, + lParam: LPARAM, +}} +pub type LPTVSORTCB = *mut TVSORTCB; +pub type LPNM_TREEVIEWA = LPNMTREEVIEWA; +pub type LPNM_TREEVIEWW = LPNMTREEVIEWW; +pub type NM_TREEVIEWA = NMTREEVIEWA; +pub type NM_TREEVIEWW = NMTREEVIEWW; +STRUCT!{struct NMTREEVIEWA { + hdr: NMHDR, + action: UINT, + itemOld: TVITEMA, + itemNew: TVITEMA, + ptDrag: POINT, +}} +pub type LPNMTREEVIEWA = *mut NMTREEVIEWA; +STRUCT!{struct NMTREEVIEWW { + hdr: NMHDR, + action: UINT, + itemOld: TVITEMW, + itemNew: TVITEMW, + ptDrag: POINT, +}} +pub type LPNMTREEVIEWW = *mut NMTREEVIEWW; +pub const TVN_SELCHANGINGA: UINT = TVN_FIRST - 1; +pub const TVN_SELCHANGINGW: UINT = TVN_FIRST - 50; +pub const TVN_SELCHANGEDA: UINT = TVN_FIRST - 2; +pub const TVN_SELCHANGEDW: UINT = TVN_FIRST - 51; +pub const TVC_UNKNOWN: LPARAM = 0x0000; +pub const TVC_BYMOUSE: LPARAM = 0x0001; +pub const TVC_BYKEYBOARD: LPARAM = 0x0002; +pub const TVN_GETDISPINFOA: UINT = TVN_FIRST - 3; +pub const TVN_GETDISPINFOW: UINT = TVN_FIRST - 52; +pub const TVN_SETDISPINFOA: UINT = TVN_FIRST - 4; +pub const TVN_SETDISPINFOW: UINT = TVN_FIRST - 53; +pub const TVIF_DI_SETITEM: UINT = 0x1000; +pub type TV_DISPINFOA = NMTVDISPINFOA; +pub type TV_DISPINFOW = NMTVDISPINFOW; +STRUCT!{struct NMTVDISPINFOA { + hdr: NMHDR, + item: TVITEMA, +}} +pub type LPNMTVDISPINFOA = *mut NMTVDISPINFOA; +STRUCT!{struct NMTVDISPINFOW { + hdr: NMHDR, + item: TVITEMW, +}} +pub type LPNMTVDISPINFOW = *mut NMTVDISPINFOW; +STRUCT!{struct NMTVDISPINFOEXA { + hdr: NMHDR, + item: TVITEMEXA, +}} +pub type LPNMTVDISPINFOEXA = *mut NMTVDISPINFOEXA; +STRUCT!{struct NMTVDISPINFOEXW { + hdr: NMHDR, + item: TVITEMEXW, +}} +pub type LPNMTVDISPINFOEXW = *mut NMTVDISPINFOEXW; +pub type TV_DISPINFOEXA = NMTVDISPINFOEXA; +pub type TV_DISPINFOEXW = NMTVDISPINFOEXW; +pub const TVN_ITEMEXPANDINGA: UINT = TVN_FIRST - 5; +pub const TVN_ITEMEXPANDINGW: UINT = TVN_FIRST - 54; +pub const TVN_ITEMEXPANDEDA: UINT = TVN_FIRST - 6; +pub const TVN_ITEMEXPANDEDW: UINT = TVN_FIRST - 55; +pub const TVN_BEGINDRAGA: UINT = TVN_FIRST - 7; +pub const TVN_BEGINDRAGW: UINT = TVN_FIRST - 56; +pub const TVN_BEGINRDRAGA: UINT = TVN_FIRST - 8; +pub const TVN_BEGINRDRAGW: UINT = TVN_FIRST - 57; +pub const TVN_DELETEITEMA: UINT = TVN_FIRST - 9; +pub const TVN_DELETEITEMW: UINT = TVN_FIRST - 58; +pub const TVN_BEGINLABELEDITA: UINT = TVN_FIRST - 10; +pub const TVN_BEGINLABELEDITW: UINT = TVN_FIRST - 59; +pub const TVN_ENDLABELEDITA: UINT = TVN_FIRST - 11; +pub const TVN_ENDLABELEDITW: UINT = TVN_FIRST - 60; +pub const TVN_KEYDOWN: UINT = TVN_FIRST - 12; +pub const TVN_GETINFOTIPA: UINT = TVN_FIRST - 13; +pub const TVN_GETINFOTIPW: UINT = TVN_FIRST - 14; +pub const TVN_SINGLEEXPAND: UINT = TVN_FIRST - 15; +pub const TVNRET_DEFAULT: LRESULT = 0; +pub const TVNRET_SKIPOLD: LRESULT = 1; +pub const TVNRET_SKIPNEW: LRESULT = 2; +pub const TVN_ITEMCHANGINGA: UINT = TVN_FIRST - 16; +pub const TVN_ITEMCHANGINGW: UINT = TVN_FIRST - 17; +pub const TVN_ITEMCHANGEDA: UINT = TVN_FIRST - 18; +pub const TVN_ITEMCHANGEDW: UINT = TVN_FIRST - 19; +pub const TVN_ASYNCDRAW: UINT = TVN_FIRST - 20; +pub type TV_KEYDOWN = NMTVKEYDOWN; +STRUCT!{#[repr(packed)] struct NMTVKEYDOWN { + hdr: NMHDR, + wVKey: WORD, + flags: UINT, +}} +pub type LPNMTVKEYDOWN = *mut NMTVKEYDOWN; +STRUCT!{struct NMTVCUSTOMDRAW { + nmcd: NMCUSTOMDRAW, + clrText: COLORREF, + clrTextBk: COLORREF, + iLevel: c_int, +}} +pub type LPNMTVCUSTOMDRAW = *mut NMTVCUSTOMDRAW; +STRUCT!{struct NMTVGETINFOTIPA { + hdr: NMHDR, + pszText: LPSTR, + cchTextMax: c_int, + hItem: HTREEITEM, + lParam: LPARAM, +}} +pub type LPNMTVGETINFOTIPA = *mut NMTVGETINFOTIPA; +STRUCT!{struct NMTVGETINFOTIPW { + hdr: NMHDR, + pszText: LPWSTR, + cchTextMax: c_int, + hItem: HTREEITEM, + lParam: LPARAM, +}} +pub type LPNMTVGETINFOTIPW = *mut NMTVGETINFOTIPW; +pub const TVCDRF_NOIMAGES: LRESULT = 0x00010000; +STRUCT!{struct NMTVITEMCHANGE { + hdr: NMHDR, + uChanged: UINT, + hItem: HTREEITEM, + uStateNew: UINT, + uStateOld: UINT, + lParam: LPARAM, +}} +STRUCT!{struct NMTVASYNCDRAW { + hdr: NMHDR, + pimldp: *mut IMAGELISTDRAWPARAMS, + hr: HRESULT, + hItem: HTREEITEM, + lParam: LPARAM, + dwRetFlags: DWORD, + iRetImageIndex: c_int, +}} +pub const WC_COMBOBOXEX: &'static str = "ComboBoxEx32"; +pub const CBEIF_TEXT: UINT = 0x00000001; +pub const CBEIF_IMAGE: UINT = 0x00000002; +pub const CBEIF_SELECTEDIMAGE: UINT = 0x00000004; +pub const CBEIF_OVERLAY: UINT = 0x00000008; +pub const CBEIF_INDENT: UINT = 0x00000010; +pub const CBEIF_LPARAM: UINT = 0x00000020; +pub const CBEIF_DI_SETITEM: UINT = 0x10000000; +STRUCT!{struct COMBOBOXEXITEMA { + mask: UINT, + iItem: INT_PTR, + pszText: LPSTR, + cchTextMax: c_int, + iImage: c_int, + iSelectedImage: c_int, + iOverlay: c_int, + iIndent: c_int, + lParam: LPARAM, +}} +pub type PCOMBOBOXEXITEMA = *mut COMBOBOXEXITEMA; +pub type PCCOMBOBOXEXITEMA = *const COMBOBOXEXITEMA; +STRUCT!{struct COMBOBOXEXITEMW { + mask: UINT, + iItem: INT_PTR, + pszText: LPWSTR, + cchTextMax: c_int, + iImage: c_int, + iSelectedImage: c_int, + iOverlay: c_int, + iIndent: c_int, + lParam: LPARAM, +}} +pub type PCOMBOBOXEXITEMW = *mut COMBOBOXEXITEMW; +pub type PCCOMBOBOXEXITEMW = *const COMBOBOXEXITEMW; +pub const CBEM_INSERTITEMA: UINT = WM_USER + 1; +pub const CBEM_SETIMAGELIST: UINT = WM_USER + 2; +pub const CBEM_GETIMAGELIST: UINT = WM_USER + 3; +pub const CBEM_GETITEMA: UINT = WM_USER + 4; +pub const CBEM_SETITEMA: UINT = WM_USER + 5; +pub const CBEM_DELETEITEM: UINT = CB_DELETESTRING; +pub const CBEM_GETCOMBOCONTROL: UINT = WM_USER + 6; +pub const CBEM_GETEDITCONTROL: UINT = WM_USER + 7; +pub const CBEM_SETEXSTYLE: UINT = WM_USER + 8; +pub const CBEM_SETEXTENDEDSTYLE: UINT = WM_USER + 14; +pub const CBEM_GETEXSTYLE: UINT = WM_USER + 9; +pub const CBEM_GETEXTENDEDSTYLE: UINT = WM_USER + 9; +pub const CBEM_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const CBEM_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const CBEM_HASEDITCHANGED: UINT = WM_USER + 10; +pub const CBEM_INSERTITEMW: UINT = WM_USER + 11; +pub const CBEM_SETITEMW: UINT = WM_USER + 12; +pub const CBEM_GETITEMW: UINT = WM_USER + 13; +pub const CBEM_SETWINDOWTHEME: UINT = CCM_SETWINDOWTHEME; +pub const CBES_EX_NOEDITIMAGE: DWORD = 0x00000001; +pub const CBES_EX_NOEDITIMAGEINDENT: DWORD = 0x00000002; +pub const CBES_EX_PATHWORDBREAKPROC: DWORD = 0x00000004; +pub const CBES_EX_NOSIZELIMIT: DWORD = 0x00000008; +pub const CBES_EX_CASESENSITIVE: DWORD = 0x00000010; +pub const CBES_EX_TEXTENDELLIPSIS: DWORD = 0x00000020; +STRUCT!{struct NMCOMBOBOXEXA { + hdr: NMHDR, + ceItem: COMBOBOXEXITEMA, +}} +pub type PNMCOMBOBOXEXA = *mut NMCOMBOBOXEXA; +STRUCT!{struct NMCOMBOBOXEXW { + hdr: NMHDR, + ceItem: COMBOBOXEXITEMW, +}} +pub type PNMCOMBOBOXEXW = *mut NMCOMBOBOXEXW; +pub const CBEN_GETDISPINFOA: UINT = CBEN_FIRST - 0; +pub const CBEN_INSERTITEM: UINT = CBEN_FIRST - 1; +pub const CBEN_DELETEITEM: UINT = CBEN_FIRST - 2; +pub const CBEN_BEGINEDIT: UINT = CBEN_FIRST - 4; +pub const CBEN_ENDEDITA: UINT = CBEN_FIRST - 5; +pub const CBEN_ENDEDITW: UINT = CBEN_FIRST - 6; +pub const CBEN_GETDISPINFOW: UINT = CBEN_FIRST - 7; +pub const CBEN_DRAGBEGINA: UINT = CBEN_FIRST - 8; +pub const CBEN_DRAGBEGINW: UINT = CBEN_FIRST - 9; +pub const CBENF_KILLFOCUS: c_int = 1; +pub const CBENF_RETURN: c_int = 2; +pub const CBENF_ESCAPE: c_int = 3; +pub const CBENF_DROPDOWN: c_int = 4; +pub const CBEMAXSTRLEN: usize = 260; +STRUCT!{struct NMCBEDRAGBEGINW { + hdr: NMHDR, + iItemid: c_int, + szText: [WCHAR; CBEMAXSTRLEN], +}} +pub type PNMCBEDRAGBEGINW = *mut NMCBEDRAGBEGINW; +pub type LPNMCBEDRAGBEGINW = *mut NMCBEDRAGBEGINW; +STRUCT!{struct NMCBEDRAGBEGINA { + hdr: NMHDR, + iItemid: c_int, + szText: [c_char; CBEMAXSTRLEN], +}} +pub type PNMCBEDRAGBEGINA = *mut NMCBEDRAGBEGINA; +pub type LPNMCBEDRAGBEGINA = *mut NMCBEDRAGBEGINA; +STRUCT!{struct NMCBEENDEDITW { + hdr: NMHDR, + fChanged: BOOL, + iNewSelection: c_int, + szText: [WCHAR; CBEMAXSTRLEN], + iWhy: c_int, +}} +pub type PNMCBEENDEDITW = *mut NMCBEENDEDITW; +pub type LPNMCBEENDEDITW = *mut NMCBEENDEDITW; +STRUCT!{struct NMCBEENDEDITA { + hdr: NMHDR, + fChanged: BOOL, + iNewSelection: c_int, + szText: [c_char; CBEMAXSTRLEN], + iWhy: c_int, +}} +pub type PNMCBEENDEDITA = *mut NMCBEENDEDITA; +pub type LPNMCBEENDEDITA = *mut NMCBEENDEDITA; +pub const WC_TABCONTROL: &'static str = "SysTabControl32"; +pub const TCS_SCROLLOPPOSITE: DWORD = 0x0001; +pub const TCS_BOTTOM: DWORD = 0x0002; +pub const TCS_RIGHT: DWORD = 0x0002; +pub const TCS_MULTISELECT: DWORD = 0x0004; +pub const TCS_FLATBUTTONS: DWORD = 0x0008; +pub const TCS_FORCEICONLEFT: DWORD = 0x0010; +pub const TCS_FORCELABELLEFT: DWORD = 0x0020; +pub const TCS_HOTTRACK: DWORD = 0x0040; +pub const TCS_VERTICAL: DWORD = 0x0080; +pub const TCS_TABS: DWORD = 0x0000; +pub const TCS_BUTTONS: DWORD = 0x0100; +pub const TCS_SINGLELINE: DWORD = 0x0000; +pub const TCS_MULTILINE: DWORD = 0x0200; +pub const TCS_RIGHTJUSTIFY: DWORD = 0x0000; +pub const TCS_FIXEDWIDTH: DWORD = 0x0400; +pub const TCS_RAGGEDRIGHT: DWORD = 0x0800; +pub const TCS_FOCUSONBUTTONDOWN: DWORD = 0x1000; +pub const TCS_OWNERDRAWFIXED: DWORD = 0x2000; +pub const TCS_TOOLTIPS: DWORD = 0x4000; +pub const TCS_FOCUSNEVER: DWORD = 0x8000; +pub const TCS_EX_FLATSEPARATORS: DWORD = 0x00000001; +pub const TCS_EX_REGISTERDROP: DWORD = 0x00000002; +pub const TCM_GETIMAGELIST: UINT = TCM_FIRST + 2; +pub const TCM_SETIMAGELIST: UINT = TCM_FIRST + 3; +pub const TCM_GETITEMCOUNT: UINT = TCM_FIRST + 4; +pub const TCIF_TEXT: UINT = 0x0001; +pub const TCIF_IMAGE: UINT = 0x0002; +pub const TCIF_RTLREADING: UINT = 0x0004; +pub const TCIF_PARAM: UINT = 0x0008; +pub const TCIF_STATE: UINT = 0x0010; +pub const TCIS_BUTTONPRESSED: DWORD = 0x0001; +pub const TCIS_HIGHLIGHTED: DWORD = 0x0002; +pub type TC_ITEMHEADERA = TCITEMHEADERA; +pub type TC_ITEMHEADERW = TCITEMHEADERW; +STRUCT!{struct TCITEMHEADERA { + mask: UINT, + lpReserved1: UINT, + lpReserved2: UINT, + pszText: LPSTR, + cchTextMax: c_int, + iImage: c_int, +}} +pub type LPTCITEMHEADERA = *mut TCITEMHEADERA; +STRUCT!{struct TCITEMHEADERW { + mask: UINT, + lpReserved1: UINT, + lpReserved2: UINT, + pszText: LPWSTR, + cchTextMax: c_int, + iImage: c_int, +}} +pub type LPTCITEMHEADERW = *mut TCITEMHEADERW; +pub type TC_ITEMA = TCITEMA; +pub type TC_ITEMW = TCITEMW; +STRUCT!{struct TCITEMA { + mask: UINT, + dwState: DWORD, + dwStateMask: DWORD, + pszText: LPSTR, + cchTextMax: c_int, + iImage: c_int, + lParam: LPARAM, +}} +pub type LPTCITEMA = *mut TCITEMA; +STRUCT!{struct TCITEMW { + mask: UINT, + dwState: DWORD, + dwStateMask: DWORD, + pszText: LPWSTR, + cchTextMax: c_int, + iImage: c_int, + lParam: LPARAM, +}} +pub type LPTCITEMW = *mut TCITEMW; +pub const TCM_GETITEMA: UINT = TCM_FIRST + 5; +pub const TCM_GETITEMW: UINT = TCM_FIRST + 60; +pub const TCM_SETITEMA: UINT = TCM_FIRST + 6; +pub const TCM_SETITEMW: UINT = TCM_FIRST + 61; +pub const TCM_INSERTITEMA: UINT = TCM_FIRST + 7; +pub const TCM_INSERTITEMW: UINT = TCM_FIRST + 62; +pub const TCM_DELETEITEM: UINT = TCM_FIRST + 8; +pub const TCM_DELETEALLITEMS: UINT = TCM_FIRST + 9; +pub const TCM_GETITEMRECT: UINT = TCM_FIRST + 10; +pub const TCM_GETCURSEL: UINT = TCM_FIRST + 11; +pub const TCM_SETCURSEL: UINT = TCM_FIRST + 12; +pub const TCHT_NOWHERE: UINT = 0x0001; +pub const TCHT_ONITEMICON: UINT = 0x0002; +pub const TCHT_ONITEMLABEL: UINT = 0x0004; +pub const TCHT_ONITEM: UINT = TCHT_ONITEMICON | TCHT_ONITEMLABEL; +pub type LPTC_HITTESTINFO = LPTCHITTESTINFO; +pub type TC_HITTESTINFO = TCHITTESTINFO; +STRUCT!{struct TCHITTESTINFO { + pt: POINT, + flags: UINT, +}} +pub type LPTCHITTESTINFO = *mut TCHITTESTINFO; +pub const TCM_HITTEST: UINT = TCM_FIRST + 13; +pub const TCM_SETITEMEXTRA: UINT = TCM_FIRST + 14; +pub const TCM_ADJUSTRECT: UINT = TCM_FIRST + 40; +pub const TCM_SETITEMSIZE: UINT = TCM_FIRST + 41; +pub const TCM_REMOVEIMAGE: UINT = TCM_FIRST + 42; +pub const TCM_SETPADDING: UINT = TCM_FIRST + 43; +pub const TCM_GETROWCOUNT: UINT = TCM_FIRST + 44; +pub const TCM_GETTOOLTIPS: UINT = TCM_FIRST + 45; +pub const TCM_SETTOOLTIPS: UINT = TCM_FIRST + 46; +pub const TCM_GETCURFOCUS: UINT = TCM_FIRST + 47; +pub const TCM_SETCURFOCUS: UINT = TCM_FIRST + 48; +pub const TCM_SETMINTABWIDTH: UINT = TCM_FIRST + 49; +pub const TCM_DESELECTALL: UINT = TCM_FIRST + 50; +pub const TCM_HIGHLIGHTITEM: UINT = TCM_FIRST + 51; +pub const TCM_SETEXTENDEDSTYLE: UINT = TCM_FIRST + 52; +pub const TCM_GETEXTENDEDSTYLE: UINT = TCM_FIRST + 53; +pub const TCM_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const TCM_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const TCN_KEYDOWN: UINT = TCN_FIRST - 0; +pub type TC_KEYDOWN = NMTCKEYDOWN; +STRUCT!{#[repr(packed)] struct NMTCKEYDOWN { + hdr: NMHDR, + wVKey: WORD, + flags: UINT, +}} +pub const TCN_SELCHANGE: UINT = TCN_FIRST - 1; +pub const TCN_SELCHANGING: UINT = TCN_FIRST - 2; +pub const TCN_GETOBJECT: UINT = TCN_FIRST - 3; +pub const TCN_FOCUSCHANGE: UINT = TCN_FIRST - 4; +pub const ANIMATE_CLASS: &'static str = "SysAnimate32"; +pub const ACS_CENTER: DWORD = 0x0001; +pub const ACS_TRANSPARENT: DWORD = 0x0002; +pub const ACS_AUTOPLAY: DWORD = 0x0004; +pub const ACS_TIMER: DWORD = 0x0008; +pub const ACM_OPENA: UINT = WM_USER + 100; +pub const ACM_OPENW: UINT = WM_USER + 103; +pub const ACM_PLAY: UINT = WM_USER + 101; +pub const ACM_STOP: UINT = WM_USER + 102; +pub const ACM_ISPLAYING: UINT = WM_USER + 104; +pub const ACN_START: WPARAM = 1; +pub const ACN_STOP: WPARAM = 2; +pub const MONTHCAL_CLASS: &'static str = "SysMonthCal32"; +pub type MONTHDAYSTATE = DWORD; +pub type LPMONTHDAYSTATE = *mut DWORD; +pub const MCM_FIRST: UINT = 0x1000; +pub const MCM_GETCURSEL: UINT = MCM_FIRST + 1; +pub const MCM_SETCURSEL: UINT = MCM_FIRST + 2; +pub const MCM_GETMAXSELCOUNT: UINT = MCM_FIRST + 3; +pub const MCM_SETMAXSELCOUNT: UINT = MCM_FIRST + 4; +pub const MCM_GETSELRANGE: UINT = MCM_FIRST + 5; +pub const MCM_SETSELRANGE: UINT = MCM_FIRST + 6; +pub const MCM_GETMONTHRANGE: UINT = MCM_FIRST + 7; +pub const MCM_SETDAYSTATE: UINT = MCM_FIRST + 8; +pub const MCM_GETMINREQRECT: UINT = MCM_FIRST + 9; +pub const MCM_SETCOLOR: UINT = MCM_FIRST + 10; +pub const MCM_GETCOLOR: UINT = MCM_FIRST + 11; +pub const MCSC_BACKGROUND: WPARAM = 0; +pub const MCSC_TEXT: WPARAM = 1; +pub const MCSC_TITLEBK: WPARAM = 2; +pub const MCSC_TITLETEXT: WPARAM = 3; +pub const MCSC_MONTHBK: WPARAM = 4; +pub const MCSC_TRAILINGTEXT: WPARAM = 5; +pub const MCM_SETTODAY: UINT = MCM_FIRST + 12; +pub const MCM_GETTODAY: UINT = MCM_FIRST + 13; +pub const MCM_HITTEST: UINT = MCM_FIRST + 14; +STRUCT!{struct MCHITTESTINFO { + cbSize: UINT, + pt: POINT, + uHit: UINT, + st: SYSTEMTIME, + rc: RECT, + iOffset: c_int, + iRow: c_int, + iCol: c_int, +}} +pub type PMCHITTESTINFO = *mut MCHITTESTINFO; +pub const MCHT_TITLE: UINT = 0x00010000; +pub const MCHT_CALENDAR: UINT = 0x00020000; +pub const MCHT_TODAYLINK: UINT = 0x00030000; +pub const MCHT_CALENDARCONTROL: UINT = 0x00100000; +pub const MCHT_NEXT: UINT = 0x01000000; +pub const MCHT_PREV: UINT = 0x02000000; +pub const MCHT_NOWHERE: UINT = 0x00000000; +pub const MCHT_TITLEBK: UINT = MCHT_TITLE; +pub const MCHT_TITLEMONTH: UINT = MCHT_TITLE | 0x0001; +pub const MCHT_TITLEYEAR: UINT = MCHT_TITLE | 0x0002; +pub const MCHT_TITLEBTNNEXT: UINT = MCHT_TITLE | MCHT_NEXT | 0x0003; +pub const MCHT_TITLEBTNPREV: UINT = MCHT_TITLE | MCHT_PREV | 0x0003; +pub const MCHT_CALENDARBK: UINT = MCHT_CALENDAR; +pub const MCHT_CALENDARDATE: UINT = MCHT_CALENDAR | 0x0001; +pub const MCHT_CALENDARDATENEXT: UINT = MCHT_CALENDARDATE | MCHT_NEXT; +pub const MCHT_CALENDARDATEPREV: UINT = MCHT_CALENDARDATE | MCHT_PREV; +pub const MCHT_CALENDARDAY: UINT = MCHT_CALENDAR | 0x0002; +pub const MCHT_CALENDARWEEKNUM: UINT = MCHT_CALENDAR | 0x0003; +pub const MCHT_CALENDARDATEMIN: UINT = MCHT_CALENDAR | 0x0004; +pub const MCHT_CALENDARDATEMAX: UINT = MCHT_CALENDAR | 0x0005; +pub const MCM_SETFIRSTDAYOFWEEK: UINT = MCM_FIRST + 15; +pub const MCM_GETFIRSTDAYOFWEEK: UINT = MCM_FIRST + 16; +pub const MCM_GETRANGE: UINT = MCM_FIRST + 17; +pub const MCM_SETRANGE: UINT = MCM_FIRST + 18; +pub const MCM_GETMONTHDELTA: UINT = MCM_FIRST + 19; +pub const MCM_SETMONTHDELTA: UINT = MCM_FIRST + 20; +pub const MCM_GETMAXTODAYWIDTH: UINT = MCM_FIRST + 21; +pub const MCM_SETUNICODEFORMAT: UINT = CCM_SETUNICODEFORMAT; +pub const MCM_GETUNICODEFORMAT: UINT = CCM_GETUNICODEFORMAT; +pub const MCMV_MONTH: DWORD = 0; +pub const MCMV_YEAR: DWORD = 1; +pub const MCMV_DECADE: DWORD = 2; +pub const MCMV_CENTURY: DWORD = 3; +pub const MCMV_MAX: DWORD = MCMV_CENTURY; +pub const MCM_GETCURRENTVIEW: UINT = MCM_FIRST + 22; +pub const MCM_GETCALENDARCOUNT: UINT = MCM_FIRST + 23; +pub const MCGIP_CALENDARCONTROL: DWORD = 0; +pub const MCGIP_NEXT: DWORD = 1; +pub const MCGIP_PREV: DWORD = 2; +pub const MCGIP_FOOTER: DWORD = 3; +pub const MCGIP_CALENDAR: DWORD = 4; +pub const MCGIP_CALENDARHEADER: DWORD = 5; +pub const MCGIP_CALENDARBODY: DWORD = 6; +pub const MCGIP_CALENDARROW: DWORD = 7; +pub const MCGIP_CALENDARCELL: DWORD = 8; +pub const MCGIF_DATE: DWORD = 0x00000001; +pub const MCGIF_RECT: DWORD = 0x00000002; +pub const MCGIF_NAME: DWORD = 0x00000004; +STRUCT!{struct MCGRIDINFO { + cbSize: UINT, + dwPart: DWORD, + dwFlags: DWORD, + iCalendar: c_int, + iRow: c_int, + iCol: c_int, + bSelected: BOOL, + stStart: SYSTEMTIME, + stEnd: SYSTEMTIME, + rc: RECT, + pszName: PWSTR, + cchName: size_t, +}} +pub type PMCGRIDINFO = *mut MCGRIDINFO; +pub const MCM_GETCALENDARGRIDINFO: UINT = MCM_FIRST + 24; +pub const MCM_GETCALID: UINT = MCM_FIRST + 27; +pub const MCM_SETCALID: UINT = MCM_FIRST + 28; +pub const MCM_SIZERECTTOMIN: UINT = MCM_FIRST + 29; +pub const MCM_SETCALENDARBORDER: UINT = MCM_FIRST + 30; +pub const MCM_GETCALENDARBORDER: UINT = MCM_FIRST + 31; +pub const MCM_SETCURRENTVIEW: UINT = MCM_FIRST + 32; +STRUCT!{struct NMSELCHANGE { + nmhdr: NMHDR, + stSelStart: SYSTEMTIME, + stSelEnd: SYSTEMTIME, +}} +pub type LPNMSELCHANGE = *mut NMSELCHANGE; +pub const MCN_SELCHANGE: UINT = MCN_FIRST - 3; +STRUCT!{struct NMDAYSTATE { + nmhdr: NMHDR, + stStart: SYSTEMTIME, + cDayState: c_int, + prgDayState: LPMONTHDAYSTATE, +}} +pub type LPNMDAYSTATE = *mut NMDAYSTATE; +pub const MCN_GETDAYSTATE: UINT = MCN_FIRST - 1; +pub type NMSELECT = NMSELCHANGE; +pub type LPNMSELECT = *mut NMSELCHANGE; +pub const MCN_SELECT: UINT = MCN_FIRST; +STRUCT!{struct NMVIEWCHANGE { + nmhdr: NMHDR, + dwOldView: DWORD, + dwNewView: DWORD, +}} +pub type LPNMVIEWCHANGE = *mut NMVIEWCHANGE; +pub const MCN_VIEWCHANGE: UINT = MCN_FIRST - 4; +pub const MCS_DAYSTATE: DWORD = 0x0001; +pub const MCS_MULTISELECT: DWORD = 0x0002; +pub const MCS_WEEKNUMBERS: DWORD = 0x0004; +pub const MCS_NOTODAYCIRCLE: DWORD = 0x0008; +pub const MCS_NOTODAY: DWORD = 0x0010; +pub const MCS_NOTRAILINGDATES: DWORD = 0x0040; +pub const MCS_SHORTDAYSOFWEEK: DWORD = 0x0080; +pub const MCS_NOSELCHANGEONNAV: DWORD = 0x0100; +pub const GMR_VISIBLE: DWORD = 0; +pub const GMR_DAYSTATE: DWORD = 1; +pub const DATETIMEPICK_CLASS: &'static str = "SysDateTimePick32"; +STRUCT!{struct DATETIMEPICKERINFO { + cbSize: UINT, + rcCheck: RECT, + stateCheck: DWORD, + rcButton: RECT, + stateButton: DWORD, + hwndEdit: HWND, + hwndUD: HWND, + hwndDropDown: HWND, +}} +pub type LPDATETIMEPICKERINFO = *mut DATETIMEPICKERINFO; +pub const DTM_FIRST: UINT = 0x1000; +pub const DTM_GETSYSTEMTIME: UINT = DTM_FIRST + 1; +pub const DTM_SETSYSTEMTIME: UINT = DTM_FIRST + 2; +pub const DTM_GETRANGE: UINT = DTM_FIRST + 3; +pub const DTM_SETRANGE: UINT = DTM_FIRST + 4; +pub const DTM_SETFORMATA: UINT = DTM_FIRST + 5; +pub const DTM_SETFORMATW: UINT = DTM_FIRST + 50; +pub const DTM_SETMCCOLOR: UINT = DTM_FIRST + 6; +pub const DTM_GETMCCOLOR: UINT = DTM_FIRST + 7; +pub const DTM_GETMONTHCAL: UINT = DTM_FIRST + 8; +pub const DTM_SETMCFONT: UINT = DTM_FIRST + 9; +pub const DTM_GETMCFONT: UINT = DTM_FIRST + 10; +pub const DTM_SETMCSTYLE: UINT = DTM_FIRST + 11; +pub const DTM_GETMCSTYLE: UINT = DTM_FIRST + 12; +pub const DTM_CLOSEMONTHCAL: UINT = DTM_FIRST + 13; +pub const DTM_GETDATETIMEPICKERINFO: UINT = DTM_FIRST + 14; +pub const DTM_GETIDEALSIZE: UINT = DTM_FIRST + 15; +pub const DTS_UPDOWN: DWORD = 0x0001; +pub const DTS_SHOWNONE: DWORD = 0x0002; +pub const DTS_SHORTDATEFORMAT: DWORD = 0x0000; +pub const DTS_LONGDATEFORMAT: DWORD = 0x0004; +pub const DTS_SHORTDATECENTURYFORMAT: DWORD = 0x000C; +pub const DTS_TIMEFORMAT: DWORD = 0x0009; +pub const DTS_APPCANPARSE: DWORD = 0x0010; +pub const DTS_RIGHTALIGN: DWORD = 0x0020; +pub const DTN_DATETIMECHANGE: UINT = DTN_FIRST2 - 6; +STRUCT!{struct NMDATETIMECHANGE { + nmhdr: NMHDR, + dwFlags: DWORD, + st: SYSTEMTIME, +}} +pub type LPNMDATETIMECHANGE = *mut NMDATETIMECHANGE; +pub const DTN_USERSTRINGA: UINT = DTN_FIRST2 - 5; +pub const DTN_USERSTRINGW: UINT = DTN_FIRST - 5; +STRUCT!{struct NMDATETIMESTRINGA { + nmhdr: NMHDR, + pszUserString: LPCSTR, + st: SYSTEMTIME, + dwFlags: DWORD, +}} +pub type LPNMDATETIMESTRINGA = *mut NMDATETIMESTRINGA; +STRUCT!{struct NMDATETIMESTRINGW { + nmhdr: NMHDR, + pszUserString: LPCWSTR, + st: SYSTEMTIME, + dwFlags: DWORD, +}} +pub type LPNMDATETIMESTRINGW = *mut NMDATETIMESTRINGW; +pub const DTN_WMKEYDOWNA: UINT = DTN_FIRST2 - 4; +pub const DTN_WMKEYDOWNW: UINT = DTN_FIRST - 4; +STRUCT!{struct NMDATETIMEWMKEYDOWNA { + nmhdr: NMHDR, + nVirtKey: c_int, + pszFormat: LPCSTR, + st: SYSTEMTIME, +}} +pub type LPNMDATETIMEWMKEYDOWNA = *mut NMDATETIMEWMKEYDOWNA; +STRUCT!{struct NMDATETIMEWMKEYDOWNW { + nmhdr: NMHDR, + nVirtKey: c_int, + pszFormat: LPCWSTR, + st: SYSTEMTIME, +}} +pub type LPNMDATETIMEWMKEYDOWNW = *mut NMDATETIMEWMKEYDOWNW; +pub const DTN_FORMATA: UINT = DTN_FIRST2 - 3; +pub const DTN_FORMATW: UINT = DTN_FIRST - 3; +STRUCT!{struct NMDATETIMEFORMATA { + nmhdr: NMHDR, + pszFormat: LPCSTR, + st: SYSTEMTIME, + pszDisplay: LPCSTR, + szDisplay: [CHAR; 64], +}} +pub type LPNMDATETIMEFORMATA = *mut NMDATETIMEFORMATA; +STRUCT!{struct NMDATETIMEFORMATW { + nmhdr: NMHDR, + pszFormat: LPCWSTR, + st: SYSTEMTIME, + pszDisplay: LPCWSTR, + szDisplay: [WCHAR; 64], +}} +pub type LPNMDATETIMEFORMATW = *mut NMDATETIMEFORMATW; +pub const DTN_FORMATQUERYA: UINT = DTN_FIRST2 - 2; +pub const DTN_FORMATQUERYW: UINT = DTN_FIRST - 2; +STRUCT!{struct NMDATETIMEFORMATQUERYA { + nmhdr: NMHDR, + pszFormat: LPCSTR, + szMax: SIZE, +}} +pub type LPNMDATETIMEFORMATQUERYA = *mut NMDATETIMEFORMATQUERYA; +STRUCT!{struct NMDATETIMEFORMATQUERYW { + nmhdr: NMHDR, + pszFormat: LPCWSTR, + szMax: SIZE, +}} +pub type LPNMDATETIMEFORMATQUERYW = *mut NMDATETIMEFORMATQUERYW; +pub const DTN_DROPDOWN: UINT = DTN_FIRST2 - 1; +pub const DTN_CLOSEUP: UINT = DTN_FIRST2; +pub const GDTR_MIN: WPARAM = 0x0001; +pub const GDTR_MAX: WPARAM = 0x0002; +pub const GDT_ERROR: LRESULT = -1; +pub const GDT_VALID: LRESULT = 0; +pub const GDT_NONE: LRESULT = 1; +pub const IPM_CLEARADDRESS: UINT = WM_USER + 100; +pub const IPM_SETADDRESS: UINT = WM_USER + 101; +pub const IPM_GETADDRESS: UINT = WM_USER + 102; +pub const IPM_SETRANGE: UINT = WM_USER + 103; +pub const IPM_SETFOCUS: UINT = WM_USER + 104; +pub const IPM_ISBLANK: UINT = WM_USER + 105; +pub const WC_IPADDRESS: &'static str = "SysIPAddress32"; +pub const IPN_FIELDCHANGED: UINT = IPN_FIRST - 0; +STRUCT!{struct NMIPADDRESS { + hdr: NMHDR, + iField: c_int, + iValue: c_int, +}} +pub type LPNMIPADDRESS = *mut NMIPADDRESS; +#[inline] +pub fn MAKEIPRANGE(low: BYTE, high: BYTE) -> LPARAM { + (((high as WORD) << 8) + low as WORD) as LPARAM +} +#[inline] +pub fn MAKEIPADDRESS(b1: DWORD, b2: DWORD, b3: DWORD, b4: DWORD) -> LPARAM { + ((b1 << 24) + (b2 << 16) + (b3 << 8) + b4) as LPARAM +} +#[inline] +pub fn FIRST_IPADDRESS(x: LPARAM) -> BYTE { + ((x >> 24) & 0xff) as BYTE +} +#[inline] +pub fn SECOND_IPADDRESS(x: LPARAM) -> BYTE { + ((x >> 16) & 0xff) as BYTE +} +#[inline] +pub fn THIRD_IPADDRESS(x: LPARAM) -> BYTE { + ((x >> 8) & 0xff) as BYTE +} +#[inline] +pub fn FOURTH_IPADDRESS(x: LPARAM) -> BYTE { + (x & 0xff) as BYTE +} +pub const WC_PAGESCROLLER: &'static str = "SysPager"; +pub const PGS_VERT: DWORD = 0x00000000; +pub const PGS_HORZ: DWORD = 0x00000001; +pub const PGS_AUTOSCROLL: DWORD = 0x00000002; +pub const PGS_DRAGNDROP: DWORD = 0x00000004; +pub const PGF_INVISIBLE: DWORD = 0; +pub const PGF_NORMAL: DWORD = 1; +pub const PGF_GRAYED: DWORD = 2; +pub const PGF_DEPRESSED: DWORD = 4; +pub const PGF_HOT: DWORD = 8; +pub const PGB_TOPORLEFT: c_int = 0; +pub const PGB_BOTTOMORRIGHT: c_int = 1; +pub const PGM_SETCHILD: UINT = PGM_FIRST + 1; +pub const PGM_RECALCSIZE: UINT = PGM_FIRST + 2; +pub const PGM_FORWARDMOUSE: UINT = PGM_FIRST + 3; +pub const PGM_SETBKCOLOR: UINT = PGM_FIRST + 4; +pub const PGM_GETBKCOLOR: UINT = PGM_FIRST + 5; +pub const PGM_SETBORDER: UINT = PGM_FIRST + 6; +pub const PGM_GETBORDER: UINT = PGM_FIRST + 7; +pub const PGM_SETPOS: UINT = PGM_FIRST + 8; +pub const PGM_GETPOS: UINT = PGM_FIRST + 9; +pub const PGM_SETBUTTONSIZE: UINT = PGM_FIRST + 10; +pub const PGM_GETBUTTONSIZE: UINT = PGM_FIRST + 11; +pub const PGM_GETBUTTONSTATE: UINT = PGM_FIRST + 12; +pub const PGM_GETDROPTARGET: UINT = CCM_GETDROPTARGET; +pub const PGM_SETSCROLLINFO: UINT = PGM_FIRST + 13; +pub const PGN_SCROLL: UINT = PGN_FIRST - 1; +pub const PGF_SCROLLUP: c_int = 1; +pub const PGF_SCROLLDOWN: c_int = 2; +pub const PGF_SCROLLLEFT: c_int = 4; +pub const PGF_SCROLLRIGHT: c_int = 8; +pub const PGK_SHIFT: BOOL = 1; +pub const PGK_CONTROL: BOOL = 2; +pub const PGK_MENU: BOOL = 4; +STRUCT!{#[repr(packed)] struct NMPGSCROLL { + hdr: NMHDR, + fwKeys: WORD, + rcParent: RECT, + iDir: c_int, + iXpos: c_int, + iYpos: c_int, + iScroll: c_int, +}} +pub type LPNMPGSCROLL = *mut NMPGSCROLL; +pub const PGN_CALCSIZE: UINT = PGN_FIRST - 2; +pub const PGF_CALCWIDTH: DWORD = 1; +pub const PGF_CALCHEIGHT: DWORD = 2; +STRUCT!{struct NMPGCALCSIZE { + hdr: NMHDR, + dwFlag: DWORD, + iWidth: c_int, + iHeight: c_int, +}} +pub type LPNMPGCALCSIZE = *mut NMPGCALCSIZE; +pub const PGN_HOTITEMCHANGE: UINT = PGN_FIRST - 3; +STRUCT!{struct NMPGHOTITEM { + hdr: NMHDR, + idOld: c_int, + idNew: c_int, + dwFlags: DWORD, +}} +pub type LPNMPGHOTITEM = *mut NMPGHOTITEM; +pub const WC_NATIVEFONTCTL: &'static str = "NativeFontCtl"; +pub const NFS_EDIT: DWORD = 0x0001; +pub const NFS_STATIC: DWORD = 0x0002; +pub const NFS_LISTCOMBO: DWORD = 0x0004; +pub const NFS_BUTTON: DWORD = 0x0008; +pub const NFS_ALL: DWORD = 0x0010; +pub const NFS_USEFONTASSOC: DWORD = 0x0020; +pub const WC_BUTTONA: &'static str = "Button"; +pub const BUTTON_IMAGELIST_ALIGN_LEFT: UINT = 0; +pub const BUTTON_IMAGELIST_ALIGN_RIGHT: UINT = 1; +pub const BUTTON_IMAGELIST_ALIGN_TOP: UINT = 2; +pub const BUTTON_IMAGELIST_ALIGN_BOTTOM: UINT = 3; +pub const BUTTON_IMAGELIST_ALIGN_CENTER: UINT = 4; +STRUCT!{struct BUTTON_IMAGELIST { + himl: HIMAGELIST, + margin: RECT, + uAlign: UINT, +}} +pub type PBUTTON_IMAGELIST = *mut BUTTON_IMAGELIST; +pub const BCM_GETIDEALSIZE: UINT = BCM_FIRST + 0x0001; +pub const BCM_SETIMAGELIST: UINT = BCM_FIRST + 0x0002; +pub const BCM_GETIMAGELIST: UINT = BCM_FIRST + 0x0003; +pub const BCM_SETTEXTMARGIN: UINT = BCM_FIRST + 0x0004; +pub const BCM_GETTEXTMARGIN: UINT = BCM_FIRST + 0x0005; +STRUCT!{struct NMBCHOTITEM { + hdr: NMHDR, + dwFlags: DWORD, +}} +pub type LPNMBCHOTITEM = *mut NMBCHOTITEM; +pub const BCN_HOTITEMCHANGE: UINT = BCN_FIRST + 0x0001; +pub const BS_SPLITBUTTON: UINT = 0x0000000C; +pub const BS_DEFSPLITBUTTON: UINT = 0x0000000D; +pub const BS_COMMANDLINK: UINT = 0x0000000E; +pub const BS_DEFCOMMANDLINK: UINT = 0x0000000F; +pub const BCSIF_GLYPH: UINT = 0x0001; +pub const BCSIF_IMAGE: UINT = 0x0002; +pub const BCSIF_STYLE: UINT = 0x0004; +pub const BCSIF_SIZE: UINT = 0x0008; +pub const BCSS_NOSPLIT: UINT = 0x0001; +pub const BCSS_STRETCH: UINT = 0x0002; +pub const BCSS_ALIGNLEFT: UINT = 0x0004; +pub const BCSS_IMAGE: UINT = 0x0008; +STRUCT!{struct BUTTON_SPLITINFO { + mask: UINT, + himlGlyph: HIMAGELIST, + uSplitStyle: UINT, + size: SIZE, +}} +pub type PBUTTON_SPLITINFO = *mut BUTTON_SPLITINFO; +pub const BCM_SETDROPDOWNSTATE: UINT = BCM_FIRST + 0x0006; +pub const BCM_SETSPLITINFO: UINT = BCM_FIRST + 0x0007; +pub const BCM_GETSPLITINFO: UINT = BCM_FIRST + 0x0008; +pub const BCM_SETNOTE: UINT = BCM_FIRST + 0x0009; +pub const BCM_GETNOTE: UINT = BCM_FIRST + 0x000A; +pub const BCM_GETNOTELENGTH: UINT = BCM_FIRST + 0x000B; +pub const BCM_SETSHIELD: UINT = BCM_FIRST + 0x000C; +pub const BCCL_NOGLYPH: HIMAGELIST = -1isize as HIMAGELIST; +STRUCT!{struct NMBCDROPDOWN { + hdr: NMHDR, + rcButton: RECT, +}} +pub type LPNMBCDROPDOWN = *mut NMBCDROPDOWN; +pub const BCN_DROPDOWN: UINT = BCN_FIRST + 0x0002; +pub const WC_STATIC: &'static str = "Static"; +pub const WC_EDIT: &'static str = "Edit"; +pub const EM_SETCUEBANNER: UINT = ECM_FIRST + 1; +pub const EM_GETCUEBANNER: UINT = ECM_FIRST + 2; +STRUCT!{struct EDITBALLOONTIP { + cbStruct: DWORD, + pszTitle: LPCWSTR, + pszText: LPCWSTR, + ttiIcon: INT, +}} +pub type PEDITBALLOONTIP = *mut EDITBALLOONTIP; +pub const EM_SHOWBALLOONTIP: UINT = ECM_FIRST + 3; +pub const EM_HIDEBALLOONTIP: UINT = ECM_FIRST + 4; +pub const EM_SETHILITE: UINT = ECM_FIRST + 5; +pub const EM_GETHILITE: UINT = ECM_FIRST + 6; +pub const EM_NOSETFOCUS: UINT = ECM_FIRST + 7; +pub const EM_TAKEFOCUS: UINT = ECM_FIRST + 8; +pub const WC_LISTBOX: &'static str = "ListBox"; +pub const WC_COMBOBOX: &'static str = "ComboBox"; +pub const CB_SETMINVISIBLE: UINT = CBM_FIRST + 1; +pub const CB_GETMINVISIBLE: UINT = CBM_FIRST + 2; +pub const CB_SETCUEBANNER: UINT = CBM_FIRST + 3; +pub const CB_GETCUEBANNER: UINT = CBM_FIRST + 4; +pub const WC_SCROLLBAR: &'static str = "ScrollBar"; +FN!{stdcall PFTASKDIALOGCALLBACK( + hwnd: HWND, + msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + lpRefData: LONG_PTR, +) -> HRESULT} +ENUM!{enum TASKDIALOG_FLAGS { + TDF_ENABLE_HYPERLINKS = 0x0001, + TDF_USE_HICON_MAIN = 0x0002, + TDF_USE_HICON_FOOTER = 0x0004, + TDF_ALLOW_DIALOG_CANCELLATION = 0x0008, + TDF_USE_COMMAND_LINKS = 0x0010, + TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020, + TDF_EXPAND_FOOTER_AREA = 0x0040, + TDF_EXPANDED_BY_DEFAULT = 0x0080, + TDF_VERIFICATION_FLAG_CHECKED = 0x0100, + TDF_SHOW_PROGRESS_BAR = 0x0200, + TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400, + TDF_CALLBACK_TIMER = 0x0800, + TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000, + TDF_RTL_LAYOUT = 0x2000, + TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000, + TDF_CAN_BE_MINIMIZED = 0x8000, + TDF_NO_SET_FOREGROUND = 0x00010000, + TDF_SIZE_TO_CONTENT = 0x01000000, +}} +ENUM!{enum TASKDIALOG_MESSAGES { + TDM_NAVIGATE_PAGE = WM_USER + 101, + TDM_CLICK_BUTTON = WM_USER + 102, + TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103, + TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104, + TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105, + TDM_SET_PROGRESS_BAR_POS = WM_USER + 106, + TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107, + TDM_SET_ELEMENT_TEXT = WM_USER + 108, + TDM_CLICK_RADIO_BUTTON = WM_USER + 110, + TDM_ENABLE_BUTTON = WM_USER + 111, + TDM_ENABLE_RADIO_BUTTON = WM_USER + 112, + TDM_CLICK_VERIFICATION = WM_USER + 113, + TDM_UPDATE_ELEMENT_TEXT = WM_USER + 114, + TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER + 115, + TDM_UPDATE_ICON = WM_USER + 116, +}} +ENUM!{enum TASKDIALOG_NOTIFICATIONS { + TDN_CREATED = 0, + TDN_NAVIGATED = 1, + TDN_BUTTON_CLICKED = 2, + TDN_HYPERLINK_CLICKED = 3, + TDN_TIMER = 4, + TDN_DESTROYED = 5, + TDN_RADIO_BUTTON_CLICKED = 6, + TDN_DIALOG_CONSTRUCTED = 7, + TDN_VERIFICATION_CLICKED = 8, + TDN_HELP = 9, + TDN_EXPANDO_BUTTON_CLICKED = 10, +}} +STRUCT!{#[repr(packed)] struct TASKDIALOG_BUTTON { + nButtonID: c_int, + pszButtonText: PCWSTR, +}} +ENUM!{enum TASKDIALOG_ELEMENTS { + TDE_CONTENT, + TDE_EXPANDED_INFORMATION, + TDE_FOOTER, + TDE_MAIN_INSTRUCTION, +}} +ENUM!{enum TASKDIALOG_ICON_ELEMENTS { + TDIE_ICON_MAIN, + TDIE_ICON_FOOTER, +}} +pub const TD_WARNING_ICON: LPWSTR = MAKEINTRESOURCE!(-1i16); +pub const TD_ERROR_ICON: LPWSTR = MAKEINTRESOURCE!(-2i16); +pub const TD_INFORMATION_ICON: LPWSTR = MAKEINTRESOURCE!(-3i16); +pub const TD_SHIELD_ICON: LPWSTR = MAKEINTRESOURCE!(-4i16); +ENUM!{enum TASKDIALOG_COMMON_BUTTON_FLAGS { + TDCBF_OK_BUTTON = 0x0001, + TDCBF_YES_BUTTON = 0x0002, + TDCBF_NO_BUTTON = 0x0004, + TDCBF_CANCEL_BUTTON = 0x0008, + TDCBF_RETRY_BUTTON = 0x0010, + TDCBF_CLOSE_BUTTON = 0x0020, +}} +UNION!{#[repr(packed)] union TASKDIALOGCONFIG_u1 { + [usize; 1], + hMainIcon hMainIcon_mut: HICON, + pszMainIcon pszMainIcon_mut: PCWSTR, +}} +UNION!{#[repr(packed)] union TASKDIALOGCONFIG_u2 { + [usize; 1], + hFooterIcon hFooterIcon_mut: HICON, + pszFooterIcon pszFooterIcon_mut: PCWSTR, +}} +STRUCT!{#[repr(packed)] struct TASKDIALOGCONFIG { + cbSize: UINT, + hwndParent: HWND, + hInstance: HINSTANCE, + dwFlags: TASKDIALOG_FLAGS, + dwCommonButtons: TASKDIALOG_COMMON_BUTTON_FLAGS, + pszWindowTitle: PCWSTR, + u1: TASKDIALOGCONFIG_u1, + pszMainInstruction: PCWSTR, + pszContent: PCWSTR, + cButtons: UINT, + pButtons: *const TASKDIALOG_BUTTON, + nDefaultButton: c_int, + cRadioButtons: UINT, + pRadioButtons: *const TASKDIALOG_BUTTON, + nDefaultRadioButton: c_int, + pszVerificationText: PCWSTR, + pszExpandedInformation: PCWSTR, + pszExpandedControlText: PCWSTR, + pszCollapsedControlText: PCWSTR, + u2: TASKDIALOGCONFIG_u2, + pszFooter: PCWSTR, + pfCallback: PFTASKDIALOGCALLBACK, + lpCallbackData: LONG_PTR, + cxWidth: UINT, +}} +extern "system" { + pub fn TaskDialogIndirect( + pTaskConfig: *const TASKDIALOGCONFIG, + pnButton: *mut c_int, + pnRadioButton: *mut c_int, + pfVerificationFlagChecked: *mut BOOL, + ) -> HRESULT; + pub fn TaskDialog( + hwndOwner: HWND, + hInstance: HINSTANCE, + pszWindowTitle: PCWSTR, + pszMainInstruction: PCWSTR, + pszContent: PCWSTR, + dwCommonButtons: TASKDIALOG_COMMON_BUTTON_FLAGS, + pszIcon: PCWSTR, + pnButton: *mut c_int, + ) -> HRESULT; + pub fn InitMUILanguage( + uiLang: LANGID, + ); + pub fn GetMUILanguage() -> LANGID; + pub fn _TrackMouseEvent( + lpEventTrack: LPTRACKMOUSEEVENT, + ) -> BOOL; +} +pub const WSB_PROP_CYVSCROLL: UINT = 0x00000001; +pub const WSB_PROP_CXHSCROLL: UINT = 0x00000002; +pub const WSB_PROP_CYHSCROLL: UINT = 0x00000004; +pub const WSB_PROP_CXVSCROLL: UINT = 0x00000008; +pub const WSB_PROP_CXHTHUMB: UINT = 0x00000010; +pub const WSB_PROP_CYVTHUMB: UINT = 0x00000020; +pub const WSB_PROP_VBKGCOLOR: UINT = 0x00000040; +pub const WSB_PROP_HBKGCOLOR: UINT = 0x00000080; +pub const WSB_PROP_VSTYLE: UINT = 0x00000100; +pub const WSB_PROP_HSTYLE: UINT = 0x00000200; +pub const WSB_PROP_WINSTYLE: UINT = 0x00000400; +pub const WSB_PROP_PALETTE: UINT = 0x00000800; +pub const WSB_PROP_MASK: UINT = 0x00000FFF; +pub const FSB_FLAT_MODE: INT_PTR = 2; +pub const FSB_ENCARTA_MODE: INT_PTR = 1; +pub const FSB_REGULAR_MODE: INT_PTR = 0; +extern "system" { + pub fn FlatSB_EnableScrollBar( + hWnd: HWND, + wSBflags: c_int, + wArrows: UINT, + ) -> BOOL; + pub fn FlatSB_ShowScrollBar( + hWnd: HWND, + code: c_int, + fShow: BOOL, + ) -> BOOL; + pub fn FlatSB_GetScrollRange( + hWnd: HWND, + code: c_int, + lpMinPos: LPINT, + lpMaxPos: LPINT, + ) -> BOOL; + pub fn FlatSB_GetScrollInfo( + hwnd: HWND, + code: c_int, + lpsi: LPSCROLLINFO, + ) -> BOOL; + pub fn FlatSB_GetScrollPos( + hWnd: HWND, + code: c_int, + ) -> c_int; + pub fn FlatSB_GetScrollProp(hWnd: HWND, + propIndex: c_int, + pValue: LPINT, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn FlatSB_GetScrollPropPtr( + hWnd: HWND, + propIndex: c_int, + pValue: PINT_PTR, + ) -> BOOL; + pub fn FlatSB_SetScrollPos( + hWnd: HWND, + code: c_int, + pos: c_int, + fRedraw: BOOL, + ) -> c_int; + pub fn FlatSB_SetScrollInfo( + hWnd: HWND, + code: c_int, + psi: LPSCROLLINFO, + fRedraw: BOOL, + ) -> c_int; + pub fn FlatSB_SetScrollRange( + hWnd: HWND, + code: c_int, + min: c_int, + max: c_int, + fRedraw: BOOL, + ) -> c_int; + pub fn FlatSB_SetScrollProp( + hWnd: HWND, + index: UINT, + newValue: INT_PTR, + fRedraw: BOOL, + ) -> BOOL; + pub fn InitializeFlatSB( + hWnd: HWND, + ) -> BOOL; + pub fn UninitializeFlatSB( + hWnd: HWND, + ) -> HRESULT; +} +FN!{stdcall SUBCLASSPROC( + hWnd: HWND, + uMsg: UINT, + wParam: WPARAM, + lParam: LPARAM, + uIdSubclass: UINT_PTR, + dwRefData: DWORD_PTR, +) -> LRESULT} +extern "system" { + pub fn SetWindowSubclass( + hWnd: HWND, + pfnSubclass: SUBCLASSPROC, + uIdSubclass: UINT_PTR, + dwRefData: DWORD_PTR, + ) -> BOOL; + pub fn GetWindowSubclass( + hWnd: HWND, + pfnSubclass: SUBCLASSPROC, + uIdSubclass: UINT_PTR, + pdwRefData: *mut DWORD_PTR, + ) -> BOOL; + pub fn RemoveWindowSubclass( + hWnd: HWND, + pfnSubclass: SUBCLASSPROC, + uIdSubclass: UINT_PTR, + ) -> BOOL; + pub fn DefSubclassProc( + hWnd: HWND, + uMsg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; +} +ENUM!{enum REGCLS { + LIM_SMALL, + LIM_LARGE, +}} +extern "system" { + pub fn LoadIconMetric( + hinst: HINSTANCE, + pszName: PCWSTR, + lims: c_int, + phico: *mut HICON, + ) -> HRESULT; + pub fn LoadIconWithScaleDown( + hinst: HINSTANCE, + pszName: PCWSTR, + cx: c_int, + cy: c_int, + phico: *mut HICON, + ) -> HRESULT; + pub fn DrawShadowText( + hdc: HDC, + pszText: LPCWSTR, + cch: UINT, + prc: *mut RECT, + dwFlags: DWORD, + crText: COLORREF, + crShadow: COLORREF, + ixOffset: c_int, + iyOffset: c_int, + ) -> c_int; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/commdlg.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/commdlg.rs new file mode 100644 index 0000000..c9326a6 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/commdlg.rs @@ -0,0 +1,712 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! 32-Bit Common Dialog APIs +use ctypes::{c_short, c_void}; +use shared::basetsd::UINT_PTR; +use shared::minwindef::{ + BOOL, DWORD, HGLOBAL, HINSTANCE, INT, LPARAM, LPVOID, LRESULT, UINT, WORD, WPARAM, +}; +use shared::windef::{COLORREF, HDC, HWND, POINT, RECT}; +use um::prsht::HPROPSHEETPAGE; +use um::unknwnbase::{IUnknown, IUnknownVtbl, LPUNKNOWN}; +use um::wingdi::{DM_COLLATE, DM_COPIES, LPDEVMODEW, LPLOGFONTA, LPLOGFONTW}; +use um::winnt::{HRESULT, LPCSTR, LPCWSTR, LPSTR, LPWSTR}; +use um::winuser::{NMHDR, WM_USER}; +FN!{stdcall LPOFNHOOKPROC( + HWND, + UINT, + WPARAM, + LPARAM, +) -> UINT_PTR} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OPENFILENAME_NT4A { + lStructSize: DWORD, + hwndOwner: HWND, + hInstance: HINSTANCE, + lpstrFilter: LPCSTR, + lpstrCustomFilter: LPSTR, + nMaxCustFilter: DWORD, + nFilterIndex: DWORD, + lpstrFile: LPSTR, + nMaxFile: DWORD, + lpstrFileTitle: LPSTR, + nMaxFileTitle: DWORD, + lpstrInitialDir: LPCSTR, + lpstrTitle: LPCSTR, + Flags: DWORD, + nFileOffset: WORD, + nFileExtension: WORD, + lpstrDefExt: LPCSTR, + lCustData: LPARAM, + lpfnHook: LPOFNHOOKPROC, + lpTemplateName: LPCSTR, +}} +pub type LPOPENFILENAME_NT4A = *mut OPENFILENAME_NT4A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OPENFILENAME_NT4W { + lStructSize: DWORD, + hwndOwner: HWND, + hInstance: HINSTANCE, + lpstrFilter: LPCWSTR, + lpstrCustomFilter: LPWSTR, + nMaxCustFilter: DWORD, + nFilterIndex: DWORD, + lpstrFile: LPWSTR, + nMaxFile: DWORD, + lpstrFileTitle: LPWSTR, + nMaxFileTitle: DWORD, + lpstrInitialDir: LPCWSTR, + lpstrTitle: LPCWSTR, + Flags: DWORD, + nFileOffset: WORD, + nFileExtension: WORD, + lpstrDefExt: LPCWSTR, + lCustData: LPARAM, + lpfnHook: LPOFNHOOKPROC, + lpTemplateName: LPCWSTR, +}} +pub type LPOPENFILENAME_NT4W = *mut OPENFILENAME_NT4W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OPENFILENAMEA { + lStructSize: DWORD, + hwndOwner: HWND, + hInstance: HINSTANCE, + lpstrFilter: LPCSTR, + lpstrCustomFilter: LPSTR, + nMaxCustFilter: DWORD, + nFilterIndex: DWORD, + lpstrFile: LPSTR, + nMaxFile: DWORD, + lpstrFileTitle: LPSTR, + nMaxFileTitle: DWORD, + lpstrInitialDir: LPCSTR, + lpstrTitle: LPCSTR, + Flags: DWORD, + nFileOffset: WORD, + nFileExtension: WORD, + lpstrDefExt: LPCSTR, + lCustData: LPARAM, + lpfnHook: LPOFNHOOKPROC, + lpTemplateName: LPCSTR, + pvReserved: *mut c_void, + dwReserved: DWORD, + FlagsEx: DWORD, +}} +pub type LPOPENFILENAMEA = *mut OPENFILENAMEA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OPENFILENAMEW { + lStructSize: DWORD, + hwndOwner: HWND, + hInstance: HINSTANCE, + lpstrFilter: LPCWSTR, + lpstrCustomFilter: LPWSTR, + nMaxCustFilter: DWORD, + nFilterIndex: DWORD, + lpstrFile: LPWSTR, + nMaxFile: DWORD, + lpstrFileTitle: LPWSTR, + nMaxFileTitle: DWORD, + lpstrInitialDir: LPCWSTR, + lpstrTitle: LPCWSTR, + Flags: DWORD, + nFileOffset: WORD, + nFileExtension: WORD, + lpstrDefExt: LPCWSTR, + lCustData: LPARAM, + lpfnHook: LPOFNHOOKPROC, + lpTemplateName: LPCWSTR, + pvReserved: *mut c_void, + dwReserved: DWORD, + FlagsEx: DWORD, +}} +pub type LPOPENFILENAMEW = *mut OPENFILENAMEW; +extern "system" { + pub fn GetOpenFileNameA( + lpofn: LPOPENFILENAMEA, + ) -> BOOL; + pub fn GetOpenFileNameW( + lpofn: LPOPENFILENAMEW, + ) -> BOOL; + pub fn GetSaveFileNameA( + lpofn: LPOPENFILENAMEA, + ) -> BOOL; + pub fn GetSaveFileNameW( + lpofn: LPOPENFILENAMEW, + ) -> BOOL; + pub fn GetFileTitleA( + lpszFile: LPCSTR, + Buf: LPSTR, + cchSize: WORD, + ) -> c_short; + pub fn GetFileTitleW( + lpszFile: LPCWSTR, + Buf: LPWSTR, + cchSize: WORD, + ) -> c_short; +} +pub const OFN_READONLY: DWORD = 0x00000001; +pub const OFN_OVERWRITEPROMPT: DWORD = 0x00000002; +pub const OFN_HIDEREADONLY: DWORD = 0x00000004; +pub const OFN_NOCHANGEDIR: DWORD = 0x00000008; +pub const OFN_SHOWHELP: DWORD = 0x00000010; +pub const OFN_ENABLEHOOK: DWORD = 0x00000020; +pub const OFN_ENABLETEMPLATE: DWORD = 0x00000040; +pub const OFN_ENABLETEMPLATEHANDLE: DWORD = 0x00000080; +pub const OFN_NOVALIDATE: DWORD = 0x00000100; +pub const OFN_ALLOWMULTISELECT: DWORD = 0x00000200; +pub const OFN_EXTENSIONDIFFERENT: DWORD = 0x00000400; +pub const OFN_PATHMUSTEXIST: DWORD = 0x00000800; +pub const OFN_FILEMUSTEXIST: DWORD = 0x00001000; +pub const OFN_CREATEPROMPT: DWORD = 0x00002000; +pub const OFN_SHAREAWARE: DWORD = 0x00004000; +pub const OFN_NOREADONLYRETURN: DWORD = 0x00008000; +pub const OFN_NOTESTFILECREATE: DWORD = 0x00010000; +pub const OFN_NONETWORKBUTTON: DWORD = 0x00020000; +pub const OFN_NOLONGNAMES: DWORD = 0x00040000; +pub const OFN_EXPLORER: DWORD = 0x00080000; +pub const OFN_NODEREFERENCELINKS: DWORD = 0x00100000; +pub const OFN_LONGNAMES: DWORD = 0x00200000; +pub const OFN_ENABLEINCLUDENOTIFY: DWORD = 0x00400000; +pub const OFN_ENABLESIZING: DWORD = 0x00800000; +pub const OFN_DONTADDTORECENT: DWORD = 0x02000000; +pub const OFN_FORCESHOWHIDDEN: DWORD = 0x10000000; +pub const OFN_EX_NOPLACESBAR: DWORD = 0x00000001; +pub const OFN_SHAREFALLTHROUGH: UINT_PTR = 2; +pub const OFN_SHARENOWARN: UINT_PTR = 1; +pub const OFN_SHAREWARN: UINT_PTR = 0; +FN!{stdcall LPCCHOOKPROC( + HWND, + UINT, + WPARAM, + LPARAM, +) -> UINT_PTR} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OFNOTIFYA { + hdr: NMHDR, + lpOFN: LPOPENFILENAMEA, + pszFile: LPSTR, +}} +pub type LPOFNOTIFYA = *mut OFNOTIFYA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OFNOTIFYW { + hdr: NMHDR, + lpOFN: LPOPENFILENAMEW, + pszFile: LPWSTR, +}} +pub type LPOFNOTIFYW = *mut OFNOTIFYW; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OFNOTIFYEXA { + hdr: NMHDR, + lpOFN: LPOPENFILENAMEA, + psf: LPVOID, + pidl: LPVOID, +}} +pub type LPOFNOTIFYEXA = *mut OFNOTIFYEXA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OFNOTIFYEXW { + hdr: NMHDR, + lpOFN: LPOPENFILENAMEW, + psf: LPVOID, + pidl: LPVOID, +}} +pub type LPOFNOTIFYEXW = *mut OFNOTIFYEXW; +pub const CDN_FIRST: UINT = -601i32 as u32; +pub const CDN_LAST: UINT = -699i32 as u32; +pub const CDN_INITDONE: UINT = CDN_FIRST - 0x0000; +pub const CDN_SELCHANGE: UINT = CDN_FIRST - 0x0001; +pub const CDN_FOLDERCHANGE: UINT = CDN_FIRST - 0x0002; +pub const CDN_SHAREVIOLATION: UINT = CDN_FIRST - 0x0003; +pub const CDN_HELP: UINT = CDN_FIRST - 0x0004; +pub const CDN_FILEOK: UINT = CDN_FIRST - 0x0005; +pub const CDN_TYPECHANGE: UINT = CDN_FIRST - 0x0006; +pub const CDN_INCLUDEITEM: UINT = CDN_FIRST - 0x0007; +pub const CDM_FIRST: UINT = WM_USER + 100; +pub const CDM_LAST: UINT = WM_USER + 200; +pub const CDM_GETSPEC: UINT = CDM_FIRST + 0x0000; +pub const CDM_GETFILEPATH: UINT = CDM_FIRST + 0x0001; +pub const CDM_GETFOLDERPATH: UINT = CDM_FIRST + 0x0002; +pub const CDM_GETFOLDERIDLIST: UINT = CDM_FIRST + 0x0003; +pub const CDM_SETCONTROLTEXT: UINT = CDM_FIRST + 0x0004; +pub const CDM_HIDECONTROL: UINT = CDM_FIRST + 0x0005; +pub const CDM_SETDEFEXT: UINT = CDM_FIRST + 0x0006; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct CHOOSECOLORA { + lStructSize: DWORD, + hwndOwner: HWND, + hInstance: HWND, + rgbResult: COLORREF, + lpCustColors: *mut COLORREF, + Flags: DWORD, + lCustData: LPARAM, + lpfnHook: LPCCHOOKPROC, + lpTemplateName: LPCSTR, +}} +pub type LPCHOOSECOLORA = *mut CHOOSECOLORA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct CHOOSECOLORW { + lStructSize: DWORD, + hwndOwner: HWND, + hInstance: HWND, + rgbResult: COLORREF, + lpCustColors: *mut COLORREF, + Flags: DWORD, + lCustData: LPARAM, + lpfnHook: LPCCHOOKPROC, + lpTemplateName: LPCWSTR, +}} +pub type LPCHOOSECOLORW = *mut CHOOSECOLORW; +extern "system" { + pub fn ChooseColorA( + lpcc: LPCHOOSECOLORA, + ) -> BOOL; + pub fn ChooseColorW( + lpcc: LPCHOOSECOLORW, + ) -> BOOL; +} +pub const CC_RGBINIT: DWORD = 0x00000001; +pub const CC_FULLOPEN: DWORD = 0x00000002; +pub const CC_PREVENTFULLOPEN: DWORD = 0x00000004; +pub const CC_SHOWHELP: DWORD = 0x00000008; +pub const CC_ENABLEHOOK: DWORD = 0x00000010; +pub const CC_ENABLETEMPLATE: DWORD = 0x00000020; +pub const CC_ENABLETEMPLATEHANDLE: DWORD = 0x00000040; +pub const CC_SOLIDCOLOR: DWORD = 0x00000080; +pub const CC_ANYCOLOR: DWORD = 0x00000100; +FN!{stdcall LPFRHOOKPROC( + HWND, + UINT, + WPARAM, + LPARAM, +) -> UINT_PTR} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct FINDREPLACEA { + lStructSize: DWORD, + hwndOwner: HWND, + hInstance: HINSTANCE, + Flags: DWORD, + lpstrFindWhat: LPSTR, + lpstrReplaceWith: LPSTR, + wFindWhatLen: WORD, + wReplaceWithLen: WORD, + lCustData: LPARAM, + lpfnHook: LPFRHOOKPROC, + lpTemplateName: LPCSTR, +}} +pub type LPFINDREPLACEA = *mut FINDREPLACEA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct FINDREPLACEW { + lStructSize: DWORD, + hwndOwner: HWND, + hInstance: HINSTANCE, + Flags: DWORD, + lpstrFindWhat: LPWSTR, + lpstrReplaceWith: LPWSTR, + wFindWhatLen: WORD, + wReplaceWithLen: WORD, + lCustData: LPARAM, + lpfnHook: LPFRHOOKPROC, + lpTemplateName: LPCWSTR, +}} +pub type LPFINDREPLACEW = *mut FINDREPLACEW; +pub const FR_DOWN: DWORD = 0x00000001; +pub const FR_WHOLEWORD: DWORD = 0x00000002; +pub const FR_MATCHCASE: DWORD = 0x00000004; +pub const FR_FINDNEXT: DWORD = 0x00000008; +pub const FR_REPLACE: DWORD = 0x00000010; +pub const FR_REPLACEALL: DWORD = 0x00000020; +pub const FR_DIALOGTERM: DWORD = 0x00000040; +pub const FR_SHOWHELP: DWORD = 0x00000080; +pub const FR_ENABLEHOOK: DWORD = 0x00000100; +pub const FR_ENABLETEMPLATE: DWORD = 0x00000200; +pub const FR_NOUPDOWN: DWORD = 0x00000400; +pub const FR_NOMATCHCASE: DWORD = 0x00000800; +pub const FR_NOWHOLEWORD: DWORD = 0x00001000; +pub const FR_ENABLETEMPLATEHANDLE: DWORD = 0x00002000; +pub const FR_HIDEUPDOWN: DWORD = 0x00004000; +pub const FR_HIDEMATCHCASE: DWORD = 0x00008000; +pub const FR_HIDEWHOLEWORD: DWORD = 0x00010000; +pub const FR_RAW: DWORD = 0x00020000; +pub const FR_MATCHDIAC: DWORD = 0x20000000; +pub const FR_MATCHKASHIDA: DWORD = 0x40000000; +pub const FR_MATCHALEFHAMZA: DWORD = 0x80000000; +extern "system" { + pub fn FindTextA( + lpfr: LPFINDREPLACEA, + ) -> HWND; + pub fn FindTextW( + lpfr: LPFINDREPLACEW, + ) -> HWND; + pub fn ReplaceTextA( + lpfr: LPFINDREPLACEA, + ) -> HWND; + pub fn ReplaceTextW( + lpfr: LPFINDREPLACEW, + ) -> HWND; +} +FN!{stdcall LPCFHOOKPROC( + HWND, + UINT, + WPARAM, + LPARAM, +) -> UINT_PTR} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct CHOOSEFONTA { + lStructSize: DWORD, + hwndOwner: HWND, + hDC: HDC, + lpLogFont: LPLOGFONTA, + iPointSize: INT, + Flags: DWORD, + rgbColors: COLORREF, + lCustData: LPARAM, + lpfnHook: LPCFHOOKPROC, + lpTemplateName: LPCSTR, + hInstance: HINSTANCE, + lpszStyle: LPSTR, + nFontType: WORD, + ___MISSING_ALIGNMENT__: WORD, + nSizeMin: INT, + nSizeMax: INT, +}} +pub type LPCHOOSEFONTA = *mut CHOOSEFONTA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct CHOOSEFONTW { + lStructSize: DWORD, + hwndOwner: HWND, + hDC: HDC, + lpLogFont: LPLOGFONTW, + iPointSize: INT, + Flags: DWORD, + rgbColors: COLORREF, + lCustData: LPARAM, + lpfnHook: LPCFHOOKPROC, + lpTemplateName: LPCWSTR, + hInstance: HINSTANCE, + lpszStyle: LPWSTR, + nFontType: WORD, + ___MISSING_ALIGNMENT__: WORD, + nSizeMin: INT, + nSizeMax: INT, +}} +pub type LPCHOOSEFONTW = *mut CHOOSEFONTW; +extern "system" { + pub fn ChooseFontA( + lpcf: LPCHOOSEFONTA, + ) -> BOOL; + pub fn ChooseFontW( + lpcf: LPCHOOSEFONTW, + ) -> BOOL; +} +pub const CF_SCREENFONTS: DWORD = 0x00000001; +pub const CF_PRINTERFONTS: DWORD = 0x00000002; +pub const CF_BOTH: DWORD = CF_SCREENFONTS | CF_PRINTERFONTS; +pub const CF_SHOWHELP: DWORD = 0x00000004; +pub const CF_ENABLEHOOK: DWORD = 0x00000008; +pub const CF_ENABLETEMPLATE: DWORD = 0x00000010; +pub const CF_ENABLETEMPLATEHANDLE: DWORD = 0x00000020; +pub const CF_INITTOLOGFONTSTRUCT: DWORD = 0x00000040; +pub const CF_USESTYLE: DWORD = 0x00000080; +pub const CF_EFFECTS: DWORD = 0x00000100; +pub const CF_APPLY: DWORD = 0x00000200; +pub const CF_ANSIONLY: DWORD = 0x00000400; +pub const CF_SCRIPTSONLY: DWORD = CF_ANSIONLY; +pub const CF_NOVECTORFONTS: DWORD = 0x00000800; +pub const CF_NOOEMFONTS: DWORD = CF_NOVECTORFONTS; +pub const CF_NOSIMULATIONS: DWORD = 0x00001000; +pub const CF_LIMITSIZE: DWORD = 0x00002000; +pub const CF_FIXEDPITCHONLY: DWORD = 0x00004000; +pub const CF_WYSIWYG: DWORD = 0x00008000; +pub const CF_FORCEFONTEXIST: DWORD = 0x00010000; +pub const CF_SCALABLEONLY: DWORD = 0x00020000; +pub const CF_TTONLY: DWORD = 0x00040000; +pub const CF_NOFACESEL: DWORD = 0x00080000; +pub const CF_NOSTYLESEL: DWORD = 0x00100000; +pub const CF_NOSIZESEL: DWORD = 0x00200000; +pub const CF_SELECTSCRIPT: DWORD = 0x00400000; +pub const CF_NOSCRIPTSEL: DWORD = 0x00800000; +pub const CF_NOVERTFONTS: DWORD = 0x01000000; +pub const CF_INACTIVEFONTS: DWORD = 0x02000000; +pub const SIMULATED_FONTTYPE: WORD = 0x8000; +pub const PRINTER_FONTTYPE: WORD = 0x4000; +pub const SCREEN_FONTTYPE: WORD = 0x2000; +pub const BOLD_FONTTYPE: WORD = 0x0100; +pub const ITALIC_FONTTYPE: WORD = 0x0200; +pub const REGULAR_FONTTYPE: WORD = 0x0400; +pub const PS_OPENTYPE_FONTTYPE: DWORD = 0x10000; +pub const TT_OPENTYPE_FONTTYPE: DWORD = 0x20000; +pub const TYPE1_FONTTYPE: DWORD = 0x40000; +pub const SYMBOL_FONTTYPE: DWORD = 0x80000; +pub const WM_CHOOSEFONT_GETLOGFONT: UINT = WM_USER + 1; +pub const WM_CHOOSEFONT_SETLOGFONT: UINT = WM_USER + 101; +pub const WM_CHOOSEFONT_SETFLAGS: UINT = WM_USER + 102; +pub const CD_LBSELNOITEMS: WORD = -1i16 as u16; +pub const CD_LBSELCHANGE: WORD = 0; +pub const CD_LBSELSUB: WORD = 1; +pub const CD_LBSELADD: WORD = 2; +FN!{stdcall LPPRINTHOOKPROC( + HWND, + UINT, + WPARAM, + LPARAM, +) -> UINT_PTR} +FN!{stdcall LPSETUPHOOKPROC( + HWND, + UINT, + WPARAM, + LPARAM, +) -> UINT_PTR} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct PRINTDLGA { + lStructSize: DWORD, + hwndOwner: HWND, + hDevMode: HGLOBAL, + hDevNames: HGLOBAL, + hDC: HDC, + Flags: DWORD, + nFromPage: WORD, + nToPage: WORD, + nMinPage: WORD, + nMaxPage: WORD, + nCopies: WORD, + hInstance: HINSTANCE, + lCustData: LPARAM, + lpfnPrintHook: LPPRINTHOOKPROC, + lpfnSetupHook: LPSETUPHOOKPROC, + lpPrintTemplateName: LPCSTR, + lpSetupTemplateName: LPCSTR, + hPrintTemplate: HGLOBAL, + hSetupTemplate: HGLOBAL, +}} +pub type LPPRINTDLGA = *mut PRINTDLGA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct PRINTDLGW { + lStructSize: DWORD, + hwndOwner: HWND, + hDevMode: HGLOBAL, + hDevNames: HGLOBAL, + hDC: HDC, + Flags: DWORD, + nFromPage: WORD, + nToPage: WORD, + nMinPage: WORD, + nMaxPage: WORD, + nCopies: WORD, + hInstance: HINSTANCE, + lCustData: LPARAM, + lpfnPrintHook: LPPRINTHOOKPROC, + lpfnSetupHook: LPSETUPHOOKPROC, + lpPrintTemplateName: LPCWSTR, + lpSetupTemplateName: LPCWSTR, + hPrintTemplate: HGLOBAL, + hSetupTemplate: HGLOBAL, +}} +pub type LPPRINTDLGW = *mut PRINTDLGW; +extern "system" { + pub fn PrintDlgA( + pPD: LPPRINTDLGA, + ) -> BOOL; + pub fn PrintDlgW( + pPD: LPPRINTDLGW, + ) -> BOOL; +} +RIDL!{#[uuid(0x5852a2c3, 0x6530, 0x11d1, 0xb6, 0xa3, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9)] +interface IPrintDialogCallback(IPrintDialogCallbackVtbl): IUnknown(IUnknownVtbl) { + fn InitDone() -> HRESULT, + fn SelectionChange() -> HRESULT, + fn HandleMessage( + hDlg: HWND, + uMsg: UINT, + wParam: WPARAM, + lParam: LPARAM, + pResult: *mut LRESULT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x509aaeda, 0x5639, 0x11d1, 0xb6, 0xa1, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9)] +interface IPrintDialogServices(IPrintDialogServicesVtbl): IUnknown(IUnknownVtbl) { + fn GetCurrentDevMode( + pDevMode: LPDEVMODEW, + pcbSize: *mut UINT, + ) -> HRESULT, + fn GetCurrentPrinterName( + pPrinterName: LPWSTR, + pcchSize: *mut UINT, + ) -> HRESULT, + fn GetCurrentPortName( + pPortName: LPWSTR, + pcchSize: *mut UINT, + ) -> HRESULT, +}} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct PRINTPAGERANGE { + nFromPage: DWORD, + nToPage: DWORD, +}} +pub type LPPRINTPAGERANGE = *mut PRINTPAGERANGE; +pub type PCPRINTPAGERANGE = *const PRINTPAGERANGE; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct PRINTDLGEXA { + lStructSize: DWORD, + hwndOwner: HWND, + hDevMode: HGLOBAL, + hDevNames: HGLOBAL, + hDC: HDC, + Flags: DWORD, + Flags2: DWORD, + ExclusionFlags: DWORD, + nPageRanges: DWORD, + nMaxPageRanges: DWORD, + lpPageRanges: LPPRINTPAGERANGE, + nMinPage: DWORD, + nMaxPage: DWORD, + nCopies: DWORD, + hInstance: HINSTANCE, + lpPrintTemplateName: LPCSTR, + lpCallback: LPUNKNOWN, + nPropertyPages: DWORD, + lphPropertyPages: *mut HPROPSHEETPAGE, + nStartPage: DWORD, + dwResultAction: DWORD, +}} +pub type LPPRINTDLGEXA = *mut PRINTDLGEXA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct PRINTDLGEXW { + lStructSize: DWORD, + hwndOwner: HWND, + hDevMode: HGLOBAL, + hDevNames: HGLOBAL, + hDC: HDC, + Flags: DWORD, + Flags2: DWORD, + ExclusionFlags: DWORD, + nPageRanges: DWORD, + nMaxPageRanges: DWORD, + lpPageRanges: LPPRINTPAGERANGE, + nMinPage: DWORD, + nMaxPage: DWORD, + nCopies: DWORD, + hInstance: HINSTANCE, + lpPrintTemplateName: LPCWSTR, + lpCallback: LPUNKNOWN, + nPropertyPages: DWORD, + lphPropertyPages: *mut HPROPSHEETPAGE, + nStartPage: DWORD, + dwResultAction: DWORD, +}} +pub type LPPRINTDLGEXW = *mut PRINTDLGEXW; +extern "system" { + pub fn PrintDlgExA( + pPD: LPPRINTDLGEXA, + ) -> HRESULT; + pub fn PrintDlgExW( + pPD: LPPRINTDLGEXW, + ) -> HRESULT; +} +pub const PD_ALLPAGES: DWORD = 0x00000000; +pub const PD_SELECTION: DWORD = 0x00000001; +pub const PD_PAGENUMS: DWORD = 0x00000002; +pub const PD_NOSELECTION: DWORD = 0x00000004; +pub const PD_NOPAGENUMS: DWORD = 0x00000008; +pub const PD_COLLATE: DWORD = 0x00000010; +pub const PD_PRINTTOFILE: DWORD = 0x00000020; +pub const PD_PRINTSETUP: DWORD = 0x00000040; +pub const PD_NOWARNING: DWORD = 0x00000080; +pub const PD_RETURNDC: DWORD = 0x00000100; +pub const PD_RETURNIC: DWORD = 0x00000200; +pub const PD_RETURNDEFAULT: DWORD = 0x00000400; +pub const PD_SHOWHELP: DWORD = 0x00000800; +pub const PD_ENABLEPRINTHOOK: DWORD = 0x00001000; +pub const PD_ENABLESETUPHOOK: DWORD = 0x00002000; +pub const PD_ENABLEPRINTTEMPLATE: DWORD = 0x00004000; +pub const PD_ENABLESETUPTEMPLATE: DWORD = 0x00008000; +pub const PD_ENABLEPRINTTEMPLATEHANDLE: DWORD = 0x00010000; +pub const PD_ENABLESETUPTEMPLATEHANDLE: DWORD = 0x00020000; +pub const PD_USEDEVMODECOPIES: DWORD = 0x00040000; +pub const PD_USEDEVMODECOPIESANDCOLLATE: DWORD = 0x00040000; +pub const PD_DISABLEPRINTTOFILE: DWORD = 0x00080000; +pub const PD_HIDEPRINTTOFILE: DWORD = 0x00100000; +pub const PD_NONETWORKBUTTON: DWORD = 0x00200000; +pub const PD_CURRENTPAGE: DWORD = 0x00400000; +pub const PD_NOCURRENTPAGE: DWORD = 0x00800000; +pub const PD_EXCLUSIONFLAGS: DWORD = 0x01000000; +pub const PD_USELARGETEMPLATE: DWORD = 0x10000000; +pub const PD_EXCL_COPIESANDCOLLATE: DWORD = DM_COPIES | DM_COLLATE; +pub const START_PAGE_GENERAL: DWORD = 0xffffffff; +pub const PD_RESULT_CANCEL: DWORD = 0; +pub const PD_RESULT_PRINT: DWORD = 1; +pub const PD_RESULT_APPLY: DWORD = 2; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct DEVNAMES { + wDriverOffset: WORD, + wDeviceOffset: WORD, + wOutputOffset: WORD, + wDefault: WORD, +}} +pub type LPDEVNAMES = *mut DEVNAMES; +pub type PCDEVNAMES = *const DEVNAMES; +pub const DN_DEFAULTPRN: WORD = 0x0001; +extern "system" { + pub fn CommDlgExtendedError() -> DWORD; +} +pub const WM_PSD_PAGESETUPDLG: UINT = WM_USER; +pub const WM_PSD_FULLPAGERECT: UINT = WM_USER + 1; +pub const WM_PSD_MINMARGINRECT: UINT = WM_USER + 2; +pub const WM_PSD_MARGINRECT: UINT = WM_USER + 3; +pub const WM_PSD_GREEKTEXTRECT: UINT = WM_USER + 4; +pub const WM_PSD_ENVSTAMPRECT: UINT = WM_USER + 5; +pub const WM_PSD_YAFULLPAGERECT: UINT = WM_USER + 6; +FN!{stdcall LPPAGEPAINTHOOK( + HWND, + UINT, + WPARAM, + LPARAM, +) -> UINT_PTR} +FN!{stdcall LPPAGESETUPHOOK( + HWND, + UINT, + WPARAM, + LPARAM, +) -> UINT_PTR} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct PAGESETUPDLGA { + lStructSize: DWORD, + hwndOwner: HWND, + hDevMode: HGLOBAL, + hDevNames: HGLOBAL, + Flags: DWORD, + ptPaperSize: POINT, + rtMinMargin: RECT, + rtMargin: RECT, + hInstance: HINSTANCE, + lCustData: LPARAM, + lpfnPageSetupHook: LPPAGESETUPHOOK, + lpfnPagePaintHook: LPPAGEPAINTHOOK, + lpPageSetupTemplateName: LPCSTR, + hPageSetupTemplate: HGLOBAL, +}} +pub type LPPAGESETUPDLGA = *mut PAGESETUPDLGA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct PAGESETUPDLGW { + lStructSize: DWORD, + hwndOwner: HWND, + hDevMode: HGLOBAL, + hDevNames: HGLOBAL, + Flags: DWORD, + ptPaperSize: POINT, + rtMinMargin: RECT, + rtMargin: RECT, + hInstance: HINSTANCE, + lCustData: LPARAM, + lpfnPageSetupHook: LPPAGESETUPHOOK, + lpfnPagePaintHook: LPPAGEPAINTHOOK, + lpPageSetupTemplateName: LPCWSTR, + hPageSetupTemplate: HGLOBAL, +}} +pub type LPPAGESETUPDLGW = *mut PAGESETUPDLGW; +extern "system" { + pub fn PageSetupDlgA( + lppsd: LPPAGESETUPDLGA, + ) -> BOOL; + pub fn PageSetupDlgW( + lppsd: LPPAGESETUPDLGW, + ) -> BOOL; +} +pub const PSD_DEFAULTMINMARGINS: DWORD = 0x00000000; +pub const PSD_INWININIINTLMEASURE: DWORD = 0x00000000; +pub const PSD_MINMARGINS: DWORD = 0x00000001; +pub const PSD_MARGINS: DWORD = 0x00000002; +pub const PSD_INTHOUSANDTHSOFINCHES: DWORD = 0x00000004; +pub const PSD_INHUNDREDTHSOFMILLIMETERS: DWORD = 0x00000008; +pub const PSD_DISABLEMARGINS: DWORD = 0x00000010; +pub const PSD_DISABLEPRINTER: DWORD = 0x00000020; +pub const PSD_NOWARNING: DWORD = 0x00000080; +pub const PSD_DISABLEORIENTATION: DWORD = 0x00000100; +pub const PSD_RETURNDEFAULT: DWORD = 0x00000400; +pub const PSD_DISABLEPAPER: DWORD = 0x00000200; +pub const PSD_SHOWHELP: DWORD = 0x00000800; +pub const PSD_ENABLEPAGESETUPHOOK: DWORD = 0x00002000; +pub const PSD_ENABLEPAGESETUPTEMPLATE: DWORD = 0x00008000; +pub const PSD_ENABLEPAGESETUPTEMPLATEHANDLE: DWORD = 0x00020000; +pub const PSD_ENABLEPAGEPAINTHOOK: DWORD = 0x00040000; +pub const PSD_DISABLEPAGEPAINTING: DWORD = 0x00080000; +pub const PSD_NONETWORKBUTTON: DWORD = 0x00200000; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/commoncontrols.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/commoncontrols.rs new file mode 100644 index 0000000..d659e04 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/commoncontrols.rs @@ -0,0 +1,232 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_int, c_void}; +use shared::guiddef::{REFCLSID, REFIID}; +use shared::minwindef::{BOOL, DWORD, LRESULT, UINT}; +use shared::windef::{COLORREF, HBITMAP, HICON, HWND, POINT, RECT}; +use um::commctrl::{IMAGEINFO, IMAGELISTDRAWPARAMS}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::HRESULT; +extern "system" { + pub fn ImageList_CoCreateInstance( + rclsid: REFCLSID, + punkOuter: *const IUnknown, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT; +} +pub const ILIF_ALPHA: DWORD = 0x00000001; +pub const ILIF_LOWQUALITY: DWORD = 0x00000001; +pub const ILDRF_IMAGELOWQUALITY: LRESULT = 0x00000001; +pub const ILDRF_OVERLAYLOWQUALITY: LRESULT = 0x00000010; +RIDL!{#[uuid(0x46eb5926, 0x582e, 0x4017, 0x9f, 0xdf, 0xe8, 0x99, 0x8d, 0xaa, 0x09, 0x50)] +interface IImageList(IImageListVtbl): IUnknown(IUnknownVtbl) { + fn Add( + hbmImage: HBITMAP, + hbmMask: HBITMAP, + pi: *mut c_int, + ) -> HRESULT, + fn ReplaceIcon( + hicon: HICON, + pi: *mut c_int, + ) -> HRESULT, + fn SetOverlayImage( + iImage: c_int, + iOverlay: c_int, + ) -> HRESULT, + fn Replace( + hbmImage: HBITMAP, + hbmMask: HBITMAP, + ) -> HRESULT, + fn AddMasked( + hbmImage: HBITMAP, + crMask: COLORREF, + pi: *mut c_int, + ) -> HRESULT, + fn Draw( + pimldp: *mut IMAGELISTDRAWPARAMS, + ) -> HRESULT, + fn Remove( + i: c_int, + ) -> HRESULT, + fn GetIcon( + i: c_int, + flags: UINT, + picon: *mut HICON, + ) -> HRESULT, + fn GetImageInfo( + i: c_int, + pImageInfo: *mut IMAGEINFO, + ) -> HRESULT, + fn Copy( + iDst: c_int, + punkSrc: *mut IUnknown, + iSrc: c_int, + uFlags: UINT, + ) -> HRESULT, + fn Merge( + i1: c_int, + punk2: *mut IUnknown, + i2: c_int, + dx: c_int, + dy: c_int, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, + fn Clone( + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, + fn GetImageRect( + i: c_int, + prc: *mut RECT, + ) -> HRESULT, + fn GetIconSize( + cx: *mut c_int, + cy: *mut c_int, + ) -> HRESULT, + fn SetIconSize( + cx: c_int, + cy: c_int, + ) -> HRESULT, + fn GetImageCount( + pi: *mut c_int, + ) -> HRESULT, + fn SetImageCount( + uNewCount: UINT, + ) -> HRESULT, + fn SetBkColor( + clrBk: COLORREF, + pclr: *mut COLORREF, + ) -> HRESULT, + fn GetBkColor( + pclr: *mut COLORREF, + ) -> HRESULT, + fn BeginDrag( + iTrack: c_int, + dxHotspot: c_int, + dyHotspot: c_int, + ) -> HRESULT, + fn EndDrag() -> HRESULT, + fn DragEnter( + hwndLock: HWND, + x: c_int, + y: c_int, + ) -> HRESULT, + fn DragLeave( + hwndLock: HWND, + ) -> HRESULT, + fn DragMove( + x: c_int, + y: c_int, + ) -> HRESULT, + fn SetDragCursorImage( + punk: *mut IUnknown, + iDrag: c_int, + dxHotspot: c_int, + dyHotspot: c_int, + ) -> HRESULT, + fn DragShowNolock( + fShow: BOOL, + ) -> HRESULT, + fn GetDragImage( + ppt: *mut POINT, + pptHotspot: *mut POINT, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, + fn GetItemFlags( + dwFlags: *mut DWORD, + ) -> HRESULT, + fn GetOverlayImage( + iOverlay: c_int, + piIndex: *mut c_int, + ) -> HRESULT, +}} +pub const ILR_DEFAULT: DWORD = 0x0000; +pub const ILR_HORIZONTAL_LEFT: DWORD = 0x0000; +pub const ILR_HORIZONTAL_CENTER: DWORD = 0x0001; +pub const ILR_HORIZONTAL_RIGHT: DWORD = 0x0002; +pub const ILR_VERTICAL_TOP: DWORD = 0x0000; +pub const ILR_VERTICAL_CENTER: DWORD = 0x0010; +pub const ILR_VERTICAL_BOTTOM: DWORD = 0x0020; +pub const ILR_SCALE_CLIP: DWORD = 0x0000; +pub const ILR_SCALE_ASPECTRATIO: DWORD = 0x0100; +pub const ILGOS_ALWAYS: DWORD = 0x00000000; +pub const ILGOS_FROMSTANDBY: DWORD = 0x00000001; +pub const ILFIP_ALWAYS: DWORD = 0x00000000; +pub const ILFIP_FROMSTANDBY: DWORD = 0x00000001; +pub const ILDI_PURGE: DWORD = 0x00000001; +pub const ILDI_STANDBY: DWORD = 0x00000002; +pub const ILDI_RESETACCESS: DWORD = 0x00000004; +pub const ILDI_QUERYACCESS: DWORD = 0x00000008; +STRUCT!{struct IMAGELISTSTATS { + cbSize: DWORD, + cAlloc: c_int, + cUsed: c_int, + cStandby: c_int, +}} +RIDL!{#[uuid(0x192b9d83, 0x58fc, 0x457b, 0x90, 0xa0, 0x2b, 0x82, 0xa8, 0xb5, 0xda, 0xe1)] +interface IImageList2(IImageList2Vtbl): IImageList(IImageListVtbl) { + fn Resize( + cxNewIconSize: c_int, + cyNewIconSize: c_int, + ) -> HRESULT, + fn GetOriginalSize( + iImage: c_int, + dwFlags: DWORD, + pcx: *mut c_int, + pcy: *mut c_int, + ) -> HRESULT, + fn SetOriginalSize( + iImage: c_int, + cx: c_int, + cy: c_int, + ) -> HRESULT, + fn SetCallback( + punk: *mut IUnknown, + ) -> HRESULT, + fn GetCallback( + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, + fn ForceImagePresent( + iImage: c_int, + dwFlags: DWORD, + ) -> HRESULT, + fn DiscardImages( + iFirstImage: c_int, + iLastImage: c_int, + dwFlags: DWORD, + ) -> HRESULT, + fn PreloadImages( + pimldp: *mut IMAGELISTDRAWPARAMS, + ) -> HRESULT, + fn GetStatistics( + pils: *mut IMAGELISTSTATS, + ) -> HRESULT, + fn Initialize( + cx: c_int, + cy: c_int, + flags: UINT, + cInitial: c_int, + cGrow: c_int, + ) -> HRESULT, + fn Replace2( + i: c_int, + hbmImage: HBITMAP, + hbmMask: HBITMAP, + punk: *mut IUnknown, + dwFlags: DWORD, + ) -> HRESULT, + fn ReplaceFromImageList( + i: c_int, + pil: *mut IImageList, + iSrc: c_int, + punk: *mut IUnknown, + dwFlags: DWORD, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/consoleapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/consoleapi.rs new file mode 100644 index 0000000..3f5496b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/consoleapi.rs @@ -0,0 +1,91 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-core-console-l1 +use shared::minwindef::{BOOL, DWORD, LPDWORD, LPVOID, UINT}; +use um::wincon::{PCONSOLE_READCONSOLE_CONTROL, PHANDLER_ROUTINE}; +use um::wincontypes::{COORD, HPCON, PINPUT_RECORD}; +use um::winnt::{HANDLE, HRESULT, VOID}; +extern "system" { + pub fn AllocConsole() -> BOOL; + pub fn GetConsoleCP() -> UINT; + pub fn GetConsoleMode( + hConsoleHandle: HANDLE, + lpMode: LPDWORD, + ) -> BOOL; + pub fn GetConsoleOutputCP() -> UINT; + pub fn GetNumberOfConsoleInputEvents( + hConsoleInput: HANDLE, + lpNumberOfEvents: LPDWORD, + ) -> BOOL; + pub fn PeekConsoleInputA( + hConsoleInput: HANDLE, + lpBuffer: PINPUT_RECORD, + nLength: DWORD, + lpNumberOfEventsRead: LPDWORD, + ) -> BOOL; + pub fn ReadConsoleA( + hConsoleInput: HANDLE, + lpBuffer: LPVOID, + nNumberOfCharsToRead: DWORD, + lpNumberOfCharsRead: LPDWORD, + pInputControl: PCONSOLE_READCONSOLE_CONTROL, + ) -> BOOL; + pub fn ReadConsoleW( + hConsoleInput: HANDLE, + lpBuffer: LPVOID, + nNumberOfCharsToRead: DWORD, + lpNumberOfCharsRead: LPDWORD, + pInputControl: PCONSOLE_READCONSOLE_CONTROL, + ) -> BOOL; + pub fn ReadConsoleInputA( + hConsoleInput: HANDLE, + lpBuffer: PINPUT_RECORD, + nLength: DWORD, + lpNumberOfEventsRead: LPDWORD, + ) -> BOOL; + pub fn ReadConsoleInputW( + hConsoleInput: HANDLE, + lpBuffer: PINPUT_RECORD, + nLength: DWORD, + lpNumberOfEventsRead: LPDWORD, + ) -> BOOL; + pub fn SetConsoleCtrlHandler( + HandlerRoutine: PHANDLER_ROUTINE, + Add: BOOL, + ) -> BOOL; + pub fn SetConsoleMode( + hConsoleHandle: HANDLE, + dwMode: DWORD, + ) -> BOOL; + pub fn WriteConsoleA( + hConsoleOutput: HANDLE, + lpBuffer: *const VOID, + nNumberOfCharsToWrite: DWORD, + lpNumberOfCharsWritten: LPDWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn WriteConsoleW( + hConsoleOutput: HANDLE, + lpBuffer: *const VOID, + nNumberOfCharsToWrite: DWORD, + lpNumberOfCharsWritten: LPDWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn CreatePseudoConsole( + size: COORD, + hInput: HANDLE, + hOutput: HANDLE, + dwFlags: DWORD, + phPC: *mut HPCON, + ) -> HRESULT; + pub fn ResizePseudoConsole( + hPC: HPCON, + size: COORD, + ) -> HRESULT; + pub fn ClosePseudoConsole( + hPC: HPCON, + ); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/corsym.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/corsym.rs new file mode 100644 index 0000000..2e7c0f9 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/corsym.rs @@ -0,0 +1,89 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! Common Language Runtime Debugging Symbol Reader/Writer/Binder Interfaces +use shared::basetsd::ULONG32; +use um::objidlbase::IStream; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, WCHAR}; +DEFINE_GUID!{CorSym_LanguageType_C, + 0x63a08714, 0xfc37, 0x11d2, 0x90, 0x4c, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1} +DEFINE_GUID!{CorSym_LanguageType_CPlusPlus, + 0x3a12d0b7, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2} +DEFINE_GUID!{CorSym_LanguageType_CSharp, + 0x3f5162f8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1} +DEFINE_GUID!{CorSym_LanguageType_Basic, + 0x3a12d0b8, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2} +DEFINE_GUID!{CorSym_LanguageType_Java, + 0x3a12d0b4, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2} +DEFINE_GUID!{CorSym_LanguageType_Cobol, + 0xaf046cd1, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc} +DEFINE_GUID!{CorSym_LanguageType_Pascal, + 0xaf046cd2, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc} +DEFINE_GUID!{CorSym_LanguageType_ILAssembly, + 0xaf046cd3, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc} +DEFINE_GUID!{CorSym_LanguageType_JScript, + 0x3a12d0b6, 0xc26c, 0x11d0, 0xb4, 0x42, 0x00, 0xa0, 0x24, 0x4a, 0x1d, 0xd2} +DEFINE_GUID!{CorSym_LanguageType_SMC, + 0xd9b9f7b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x0, 0x0, 0xf8, 0x8, 0x49, 0xbd} +DEFINE_GUID!{CorSym_LanguageType_MCPlusPlus, + 0x4b35fde8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1} +DEFINE_GUID!{CorSym_LanguageVendor_Microsoft, + 0x994b45c4, 0xe6e9, 0x11d2, 0x90, 0x3f, 0x00, 0xc0, 0x4f, 0xa3, 0x02, 0xa1} +DEFINE_GUID!{CorSym_DocumentType_Text, + 0x5a869d0b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x0, 0x0, 0xf8, 0x8, 0x49, 0xbd} +DEFINE_GUID!{CorSym_DocumentType_MC, + 0xeb40cb65, 0x3c1f, 0x4352, 0x9d, 0x7b, 0xba, 0xf, 0xc4, 0x7a, 0x9d, 0x77} +DEFINE_GUID!{CorSym_SourceHash_MD5, + 0x406ea660, 0x64cf, 0x4c82, 0xb6, 0xf0, 0x42, 0xd4, 0x81, 0x72, 0xa7, 0x99} +DEFINE_GUID!{CorSym_SourceHash_SHA1, + 0xff1816ec, 0xaa5e, 0x4d10, 0x87, 0xf7, 0x6f, 0x49, 0x63, 0x83, 0x34, 0x60} +ENUM!{enum CorSymAddrKind { + ADDR_IL_OFFSET = 1, + ADDR_NATIVE_RVA = 2, + ADDR_NATIVE_REGISTER = 3, + ADDR_NATIVE_REGREL = 4, + ADDR_NATIVE_OFFSET = 5, + ADDR_NATIVE_REGREG = 6, + ADDR_NATIVE_REGSTK = 7, + ADDR_NATIVE_STKREG = 8, + ADDR_BITFIELD = 9, + ADDR_NATIVE_ISECTOFFSET = 10, +}} +ENUM!{enum CorSymVarFlag { + VAR_IS_COMP_GEN = 1, +}} +RIDL!{#[uuid(0xaa544d42, 0x28cb, 0x11d3, 0xbd, 0x22, 0x00, 0x00, 0xf8, 0x08, 0x49, 0xbd)] +interface ISymUnmanagedBinder(ISymUnmanagedBinderVtbl): IUnknown(IUnknownVtbl) { + fn GetReaderForFile( + importer: *mut IUnknown, + fileName: *const WCHAR, + searchPath: *const WCHAR, + pRetVal: *mut *mut ISymUnmanagedReader, + ) -> HRESULT, + fn GetReaderFromStream( + importer: *mut IUnknown, + pstream: *mut IStream, + pRetVal: *mut *mut ISymUnmanagedReader, + ) -> HRESULT, +}} +ENUM!{enum CorSymSearchPolicyAttributes { + AllowRegistryAccess = 0x1, + AllowSymbolServerAccess = 0x2, + AllowOriginalPathAccess = 0x4, + AllowReferencePathAccess = 0x8, +}} +RIDL!{#[uuid(0xaccee350, 0x89af, 0x4ccb, 0x8b, 0x40, 0x1c, 0x2c, 0x4c, 0x6f, 0x94, 0x34)] +interface ISymUnmanagedBinder2(ISymUnmanagedBinder2Vtbl): + ISymUnmanagedBinder(ISymUnmanagedBinderVtbl) { + fn GetReaderForFile2( + importer: *mut IUnknown, + fileName: *const WCHAR, + searchPath: *const WCHAR, + searchPolicy: ULONG32, + pRetVal: *mut *mut ISymUnmanagedReader, + ) -> HRESULT, +}} +pub enum ISymUnmanagedReader {} // TODO diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1.rs new file mode 100644 index 0000000..0632e68 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1.rs @@ -0,0 +1,982 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! Mappings for the contents of d2d1.h +use ctypes::c_void; +use shared::basetsd::{UINT32, UINT64}; +use shared::dxgi::IDXGISurface; +use shared::guiddef::REFIID; +use shared::minwindef::{BOOL, DWORD, FLOAT}; +use shared::windef::{HDC, HWND, RECT}; +use um::d2dbasetypes::{ + D2D_COLOR_F, D2D_MATRIX_3X2_F, D2D_POINT_2F, D2D_POINT_2U, D2D_RECT_F, D2D_RECT_U, D2D_SIZE_F, + D2D_SIZE_U, +}; +use um::d3dcommon::{D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_1}; +use um::dcommon::{D2D1_PIXEL_FORMAT, DWRITE_MEASURING_MODE}; +use um::dwrite::{DWRITE_GLYPH_RUN, IDWriteRenderingParams, IDWriteTextFormat, IDWriteTextLayout}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::wincodec::{IWICBitmap, IWICBitmapSource}; +use um::winnt::{HRESULT, WCHAR}; +// Types confirmed affected by the ABI issue: +// D2D1_SIZE_F, D2D1_SIZE_U, D2D1_COLOR_F, D2D1_PIXEL_FORMAT, D2D1_POINT_2F +pub const D2D1_DEFAULT_FLATTENING_TOLERANCE: FLOAT = 0.25; +pub const D2D1_INTERPOLATION_MODE_DEFINITION_NEAREST_NEIGHBOR: DWORD = 0; +pub const D2D1_INTERPOLATION_MODE_DEFINITION_LINEAR: DWORD = 1; +pub const D2D1_INTERPOLATION_MODE_DEFINITION_CUBIC: DWORD = 2; +pub const D2D1_INTERPOLATION_MODE_DEFINITION_MULTI_SAMPLE_LINEAR: DWORD = 3; +pub const D2D1_INTERPOLATION_MODE_DEFINITION_ANISOTROPIC: DWORD = 4; +pub const D2D1_INTERPOLATION_MODE_DEFINITION_HIGH_QUALITY_CUBIC: DWORD = 5; +pub const D2D1_INTERPOLATION_MODE_DEFINITION_FANT: DWORD = 6; +pub const D2D1_INTERPOLATION_MODE_DEFINITION_MIPMAP_LINEAR: DWORD = 7; +ENUM!{enum D2D1_GAMMA { + D2D1_GAMMA_2_2 = 0, + D2D1_GAMMA_1_0 = 1, +}} +ENUM!{enum D2D1_OPACITY_MASK_CONTENT { + D2D1_OPACITY_MASK_CONTENT_GRAPHICS = 0, + D2D1_OPACITY_MASK_CONTENT_TEXT_NATURAL = 1, + D2D1_OPACITY_MASK_CONTENT_TEXT_GDI_COMPATIBLE = 2, +}} +ENUM!{enum D2D1_EXTEND_MODE { + D2D1_EXTEND_MODE_CLAMP = 0, + D2D1_EXTEND_MODE_WRAP = 1, + D2D1_EXTEND_MODE_MIRROR = 2, +}} +ENUM!{enum D2D1_ANTIALIAS_MODE { + D2D1_ANTIALIAS_MODE_PER_PRIMITIVE = 0, + D2D1_ANTIALIAS_MODE_ALIASED = 1, +}} +ENUM!{enum D2D1_TEXT_ANTIALIAS_MODE { + D2D1_TEXT_ANTIALIAS_MODE_DEFAULT = 0, + D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE = 1, + D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE = 2, + D2D1_TEXT_ANTIALIAS_MODE_ALIASED = 3, +}} +ENUM!{enum D2D1_BITMAP_INTERPOLATION_MODE { + D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR = + D2D1_INTERPOLATION_MODE_DEFINITION_NEAREST_NEIGHBOR, + D2D1_BITMAP_INTERPOLATION_MODE_LINEAR = + D2D1_INTERPOLATION_MODE_DEFINITION_LINEAR, +}} +ENUM!{enum D2D1_DRAW_TEXT_OPTIONS { + D2D1_DRAW_TEXT_OPTIONS_NO_SNAP = 0x00000001, + D2D1_DRAW_TEXT_OPTIONS_CLIP = 0x00000002, + D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT = 0x00000004, + D2D1_DRAW_TEXT_OPTIONS_NONE = 0x00000000, +}} +pub type D2D1_POINT_2U = D2D_POINT_2U; +pub type D2D1_POINT_2F = D2D_POINT_2F; +pub type D2D1_RECT_F = D2D_RECT_F; +pub type D2D1_RECT_U = D2D_RECT_U; +pub type D2D1_SIZE_F = D2D_SIZE_F; +pub type D2D1_SIZE_U = D2D_SIZE_U; +pub type D2D1_COLOR_F = D2D_COLOR_F; +pub type D2D1_MATRIX_3X2_F = D2D_MATRIX_3X2_F; +pub type D2D1_TAG = UINT64; +STRUCT!{struct D2D1_BITMAP_PROPERTIES { + pixelFormat: D2D1_PIXEL_FORMAT, + dpiX: FLOAT, + dpiY: FLOAT, +}} +STRUCT!{struct D2D1_GRADIENT_STOP { + position: FLOAT, + color: D2D1_COLOR_F, +}} +STRUCT!{struct D2D1_BRUSH_PROPERTIES { + opacity: FLOAT, + transform: D2D1_MATRIX_3X2_F, +}} +STRUCT!{struct D2D1_BITMAP_BRUSH_PROPERTIES { + extendModeX: D2D1_EXTEND_MODE, + extendModeY: D2D1_EXTEND_MODE, + interpolationMode: D2D1_BITMAP_INTERPOLATION_MODE, +}} +STRUCT!{struct D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES { + startPoint: D2D1_POINT_2F, + endPoint: D2D1_POINT_2F, +}} +STRUCT!{struct D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES { + center: D2D1_POINT_2F, + gradientOriginOffset: D2D1_POINT_2F, + radiusX: FLOAT, + radiusY: FLOAT, +}} +ENUM!{enum D2D1_ARC_SIZE { + D2D1_ARC_SIZE_SMALL = 0, + D2D1_ARC_SIZE_LARGE = 1, +}} +ENUM!{enum D2D1_CAP_STYLE { + D2D1_CAP_STYLE_FLAT = 0, + D2D1_CAP_STYLE_SQUARE = 1, + D2D1_CAP_STYLE_ROUND = 2, + D2D1_CAP_STYLE_TRIANGLE = 3, +}} +ENUM!{enum D2D1_DASH_STYLE { + D2D1_DASH_STYLE_SOLID = 0, + D2D1_DASH_STYLE_DASH = 1, + D2D1_DASH_STYLE_DOT = 2, + D2D1_DASH_STYLE_DASH_DOT = 3, + D2D1_DASH_STYLE_DASH_DOT_DOT = 4, + D2D1_DASH_STYLE_CUSTOM = 5, +}} +ENUM!{enum D2D1_LINE_JOIN { + D2D1_LINE_JOIN_MITER = 0, + D2D1_LINE_JOIN_BEVEL = 1, + D2D1_LINE_JOIN_ROUND = 2, + D2D1_LINE_JOIN_MITER_OR_BEVEL = 3, +}} +ENUM!{enum D2D1_COMBINE_MODE { + D2D1_COMBINE_MODE_UNION = 0, + D2D1_COMBINE_MODE_INTERSECT = 1, + D2D1_COMBINE_MODE_XOR = 2, + D2D1_COMBINE_MODE_EXCLUDE = 3, +}} +ENUM!{enum D2D1_GEOMETRY_RELATION { + D2D1_GEOMETRY_RELATION_UNKNOWN = 0, + D2D1_GEOMETRY_RELATION_DISJOINT = 1, + D2D1_GEOMETRY_RELATION_IS_CONTAINED = 2, + D2D1_GEOMETRY_RELATION_CONTAINS = 3, + D2D1_GEOMETRY_RELATION_OVERLAP = 4, +}} +ENUM!{enum D2D1_GEOMETRY_SIMPLIFICATION_OPTION { + D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES = 0, + D2D1_GEOMETRY_SIMPLIFICATION_OPTION_LINES = 1, +}} +ENUM!{enum D2D1_FIGURE_BEGIN { + D2D1_FIGURE_BEGIN_FILLED = 0, + D2D1_FIGURE_BEGIN_HOLLOW = 1, +}} +ENUM!{enum D2D1_FIGURE_END { + D2D1_FIGURE_END_OPEN = 0, + D2D1_FIGURE_END_CLOSED = 1, +}} +STRUCT!{struct D2D1_BEZIER_SEGMENT { + point1: D2D1_POINT_2F, + point2: D2D1_POINT_2F, + point3: D2D1_POINT_2F, +}} +STRUCT!{struct D2D1_TRIANGLE { + point1: D2D1_POINT_2F, + point2: D2D1_POINT_2F, + point3: D2D1_POINT_2F, +}} +ENUM!{enum D2D1_PATH_SEGMENT { + D2D1_PATH_SEGMENT_NONE = 0x00000000, + D2D1_PATH_SEGMENT_FORCE_UNSTROKED = 0x00000001, + D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN = 0x00000002, +}} +ENUM!{enum D2D1_SWEEP_DIRECTION { + D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE = 0, + D2D1_SWEEP_DIRECTION_CLOCKWISE = 1, +}} +ENUM!{enum D2D1_FILL_MODE { + D2D1_FILL_MODE_ALTERNATE = 0, + D2D1_FILL_MODE_WINDING = 1, +}} +STRUCT!{struct D2D1_ARC_SEGMENT { + point: D2D1_POINT_2F, + size: D2D1_SIZE_F, + rotationAngle: FLOAT, + sweepDirection: D2D1_SWEEP_DIRECTION, + arcSize: D2D1_ARC_SIZE, +}} +STRUCT!{struct D2D1_QUADRATIC_BEZIER_SEGMENT { + point1: D2D1_POINT_2F, + point2: D2D1_POINT_2F, +}} +STRUCT!{struct D2D1_ELLIPSE { + point: D2D1_POINT_2F, + radiusX: FLOAT, + radiusY: FLOAT, +}} +STRUCT!{struct D2D1_ROUNDED_RECT { + rect: D2D1_RECT_F, + radiusX: FLOAT, + radiusY: FLOAT, +}} +STRUCT!{struct D2D1_STROKE_STYLE_PROPERTIES { + startCap: D2D1_CAP_STYLE, + endCap: D2D1_CAP_STYLE, + dashCap: D2D1_CAP_STYLE, + lineJoin: D2D1_LINE_JOIN, + miterLimit: FLOAT, + dashStyle: D2D1_DASH_STYLE, + dashOffset: FLOAT, +}} +ENUM!{enum D2D1_LAYER_OPTIONS { + D2D1_LAYER_OPTIONS_NONE = 0x00000000, + D2D1_LAYER_OPTIONS_INITIALIZE_FOR_CLEARTYPE = 0x00000001, +}} +STRUCT!{struct D2D1_LAYER_PARAMETERS { + contentBounds: D2D1_RECT_F, + geometricMask: *mut ID2D1Geometry, + maskAntialiasMode: D2D1_ANTIALIAS_MODE, + maskTransform: D2D1_MATRIX_3X2_F, + opacity: FLOAT, + opacityBrush: *mut ID2D1Brush, + layerOptions: D2D1_LAYER_OPTIONS, +}} +ENUM!{enum D2D1_WINDOW_STATE { + D2D1_WINDOW_STATE_NONE = 0x0000000, + D2D1_WINDOW_STATE_OCCLUDED = 0x0000001, +}} +ENUM!{enum D2D1_RENDER_TARGET_TYPE { + D2D1_RENDER_TARGET_TYPE_DEFAULT = 0, + D2D1_RENDER_TARGET_TYPE_SOFTWARE = 1, + D2D1_RENDER_TARGET_TYPE_HARDWARE = 2, +}} +ENUM!{enum D2D1_FEATURE_LEVEL { + D2D1_FEATURE_LEVEL_DEFAULT = 0, + D2D1_FEATURE_LEVEL_9 = D3D_FEATURE_LEVEL_9_1, + D2D1_FEATURE_LEVEL_10 = D3D_FEATURE_LEVEL_10_0, +}} +ENUM!{enum D2D1_RENDER_TARGET_USAGE { + D2D1_RENDER_TARGET_USAGE_NONE = 0x00000000, + D2D1_RENDER_TARGET_USAGE_FORCE_BITMAP_REMOTING = 0x00000001, + D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE = 0x00000002, +}} +ENUM!{enum D2D1_PRESENT_OPTIONS { + D2D1_PRESENT_OPTIONS_NONE = 0x00000000, + D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS = 0x00000001, + D2D1_PRESENT_OPTIONS_IMMEDIATELY = 0x00000002, +}} +STRUCT!{struct D2D1_RENDER_TARGET_PROPERTIES { + _type: D2D1_RENDER_TARGET_TYPE, + pixelFormat: D2D1_PIXEL_FORMAT, + dpiX: FLOAT, + dpiY: FLOAT, + usage: D2D1_RENDER_TARGET_USAGE, + minLevel: D2D1_FEATURE_LEVEL, +}} +STRUCT!{struct D2D1_HWND_RENDER_TARGET_PROPERTIES { + hwnd: HWND, + pixelSize: D2D1_SIZE_U, + presentOptions: D2D1_PRESENT_OPTIONS, +}} +ENUM!{enum D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS { + D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE = 0x00000000, + D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_GDI_COMPATIBLE = 0x00000001, +}} +STRUCT!{struct D2D1_DRAWING_STATE_DESCRIPTION { + antialiasMode: D2D1_ANTIALIAS_MODE, + textAntialiasMode: D2D1_TEXT_ANTIALIAS_MODE, + tag1: D2D1_TAG, + tag2: D2D1_TAG, + transform: D2D1_MATRIX_3X2_F, +}} +ENUM!{enum D2D1_DC_INITIALIZE_MODE { + D2D1_DC_INITIALIZE_MODE_COPY = 0, + D2D1_DC_INITIALIZE_MODE_CLEAR = 1, +}} +ENUM!{enum D2D1_DEBUG_LEVEL { + D2D1_DEBUG_LEVEL_NONE = 0, + D2D1_DEBUG_LEVEL_ERROR = 1, + D2D1_DEBUG_LEVEL_WARNING = 2, + D2D1_DEBUG_LEVEL_INFORMATION = 3, +}} +ENUM!{enum D2D1_FACTORY_TYPE { + D2D1_FACTORY_TYPE_SINGLE_THREADED = 0, + D2D1_FACTORY_TYPE_MULTI_THREADED = 1, +}} +STRUCT!{struct D2D1_FACTORY_OPTIONS { + debugLevel: D2D1_DEBUG_LEVEL, +}} +RIDL!{#[uuid(0x2cd90691, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1Resource(ID2D1ResourceVtbl): IUnknown(IUnknownVtbl) { + fn GetFactory( + factory: *mut *mut ID2D1Factory, + ) -> (), +}} +RIDL!{#[uuid(0x65019f75, 0x8da2, 0x497c, 0xb3, 0x2c, 0xdf, 0xa3, 0x4e, 0x48, 0xed, 0xe6)] +interface ID2D1Image(ID2D1ImageVtbl): ID2D1Resource(ID2D1ResourceVtbl) {}} +RIDL!{#[uuid(0xa2296057, 0xea42, 0x4099, 0x98, 0x3b, 0x53, 0x9f, 0xb6, 0x50, 0x54, 0x26)] +interface ID2D1Bitmap(ID2D1BitmapVtbl): ID2D1Image(ID2D1ImageVtbl) { + #[fixme] fn GetSize() -> D2D1_SIZE_F, + #[fixme] fn GetPixelSize() -> D2D1_SIZE_U, + #[fixme] fn GetPixelFormat() -> D2D1_PIXEL_FORMAT, + fn GetDpi( + dpiX: *mut FLOAT, + dpiY: *mut FLOAT, + ) -> (), + fn CopyFromBitmap( + destPoint: *const D2D1_POINT_2U, + bitmap: *mut ID2D1Bitmap, + srcRect: *const D2D1_RECT_U, + ) -> HRESULT, + fn CopyFromRenderTarget( + destPoint: *const D2D1_POINT_2U, + renderTarget: *mut ID2D1RenderTarget, + srcRect: *const D2D1_RECT_U, + ) -> HRESULT, + fn CopyFromMemory( + dstRect: *const D2D1_RECT_U, + srcData: *const c_void, + pitch: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2cd906a7, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1GradientStopCollection(ID2D1GradientStopCollectionVtbl): + ID2D1Resource(ID2D1ResourceVtbl) { + fn GetGradientStopCount() -> UINT32, + fn GetGradientStops( + gradientStops: *mut D2D1_GRADIENT_STOP, + gradientStopsCount: UINT32, + ) -> (), + fn GetColorInterpolationGamma() -> D2D1_GAMMA, + fn GetExtendMode() -> D2D1_EXTEND_MODE, +}} +RIDL!{#[uuid(0x2cd906a8, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1Brush(ID2D1BrushVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn SetOpacity( + opacity: FLOAT, + ) -> (), + fn SetTransform( + transform: *const D2D1_MATRIX_3X2_F, + ) -> (), + fn GetOpacity() -> FLOAT, + fn GetTransform( + transform: *mut D2D1_MATRIX_3X2_F, + ) -> (), +}} +RIDL!{#[uuid(0x2cd906aa, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1BitmapBrush(ID2D1BitmapBrushVtbl): ID2D1Brush(ID2D1BrushVtbl) { + fn SetExtendModeX( + extendModeX: D2D1_EXTEND_MODE, + ) -> (), + fn SetExtendModeY( + extendModeY: D2D1_EXTEND_MODE, + ) -> (), + fn SetInterpolationMode( + interpolationMode: D2D1_BITMAP_INTERPOLATION_MODE, + ) -> (), + fn SetBitmap( + bitmap: *mut ID2D1Bitmap, + ) -> (), + fn GetExtendModeX() -> D2D1_EXTEND_MODE, + fn GetExtendModeY() -> D2D1_EXTEND_MODE, + fn GetInterpolationMode() -> D2D1_BITMAP_INTERPOLATION_MODE, + fn GetBitmap( + bitmap: *mut *mut ID2D1Bitmap, + ) -> (), +}} +RIDL!{#[uuid(0x2cd906a9, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1SolidColorBrush(ID2D1SolidColorBrushVtbl): ID2D1Brush(ID2D1BrushVtbl) { + fn SetColor( + color: *const D2D1_COLOR_F, + ) -> (), + #[fixme] fn GetColor() -> D2D1_COLOR_F, +}} +RIDL!{#[uuid(0x2cd906ab, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1LinearGradientBrush(ID2D1LinearGradientBrushVtbl): ID2D1Brush(ID2D1BrushVtbl) { + fn SetStartPoint( + startPoint: D2D1_POINT_2F, + ) -> (), + fn SetEndPoint( + endPoint: D2D1_POINT_2F, + ) -> (), + #[fixme] fn GetStartPoint() -> D2D1_POINT_2F, + #[fixme] fn GetEndPoint() -> D2D1_POINT_2F, + fn GetGradientStopCollection( + gradientStopCollection: *mut *mut ID2D1GradientStopCollection, + ) -> (), +}} +RIDL!{#[uuid(0x2cd906ac, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1RadialGradientBrush(ID2D1RadialGradientBrushVtbl): ID2D1Brush(ID2D1BrushVtbl) { + fn SetCenter( + center: D2D1_POINT_2F, + ) -> (), + fn SetGradientOriginOffset( + gradientOriginOffset: D2D1_POINT_2F, + ) -> (), + fn SetRadiusX( + radiusX: FLOAT, + ) -> (), + fn SetRadiusY( + radiusY: FLOAT, + ) -> (), + #[fixme] fn GetCenter() -> D2D1_POINT_2F, + #[fixme] fn GetGradientOriginOffset() -> D2D1_POINT_2F, + fn GetRadiusX() -> FLOAT, + fn GetRadiusY() -> FLOAT, + fn GetGradientStopCollection( + gradientStopCollection: *mut *mut ID2D1GradientStopCollection, + ) -> (), +}} +RIDL!{#[uuid(0x2cd9069d, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1StrokeStyle(ID2D1StrokeStyleVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn GetStartCap() -> D2D1_CAP_STYLE, + fn GetEndCap() -> D2D1_CAP_STYLE, + fn GetDashCap() -> D2D1_CAP_STYLE, + fn GetMiterLimit() -> FLOAT, + fn GetLineJoin() -> D2D1_LINE_JOIN, + fn GetDashOffset() -> FLOAT, + fn GetDashStyle() -> D2D1_DASH_STYLE, + fn GetDashesCount() -> UINT32, + fn GetDashes( + dashes: *mut FLOAT, + dashesCount: UINT32, + ) -> (), +}} +RIDL!{#[uuid(0x2cd906a1, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1Geometry(ID2D1GeometryVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn GetBounds( + worldTransform: *const D2D1_MATRIX_3X2_F, + bounds: *mut D2D1_RECT_F, + ) -> HRESULT, + fn GetWidenedBounds( + strokeWidth: FLOAT, + strokeStyle: *mut ID2D1StrokeStyle, + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + bounds: *mut D2D1_RECT_F, + ) -> HRESULT, + fn StrokeContainsPoint( + point: D2D1_POINT_2F, + strokeWidth: FLOAT, + strokeStyle: *mut ID2D1StrokeStyle, + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + contains: *mut BOOL, + ) -> HRESULT, + fn FillContainsPoint( + point: D2D1_POINT_2F, + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + contains: *mut BOOL, + ) -> HRESULT, + fn CompareWithGeometry( + inputGeometry: *mut ID2D1Geometry, + inputGeometryTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + relation: *mut D2D1_GEOMETRY_RELATION, + ) -> HRESULT, + fn Simplify( + simplificationOption: D2D1_GEOMETRY_SIMPLIFICATION_OPTION, + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + geometrySink: *mut ID2D1SimplifiedGeometrySink, + ) -> HRESULT, + fn Tessellate( + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + tessellationSink: *mut ID2D1TessellationSink, + ) -> HRESULT, + fn CombineWithGeometry( + inputGeometry: *mut ID2D1Geometry, + combineMode: D2D1_COMBINE_MODE, + inputGeometryTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + geometrySink: *mut ID2D1SimplifiedGeometrySink, + ) -> HRESULT, + fn Outline( + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + geometrySink: *mut ID2D1SimplifiedGeometrySink, + ) -> HRESULT, + fn ComputeArea( + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + area: *mut FLOAT, + ) -> HRESULT, + fn ComputeLength( + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + length: *mut FLOAT, + ) -> HRESULT, + fn ComputePointAtLength( + length: FLOAT, + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + point: *mut D2D1_POINT_2F, + unitTangentVector: *mut D2D1_POINT_2F, + ) -> HRESULT, + fn Widen( + strokeWidth: FLOAT, + strokeStyle: *mut ID2D1StrokeStyle, + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + geometrySink: *mut ID2D1SimplifiedGeometrySink, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2cd906a2, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1RectangleGeometry(ID2D1RectangleGeometryVtbl): ID2D1Geometry(ID2D1GeometryVtbl) { + fn GetRect( + rect: *mut D2D1_RECT_F, + ) -> (), +}} +RIDL!{#[uuid(0x2cd906a3, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1RoundedRectangleGeometry(ID2D1RoundedRectangleGeometryVtbl): + ID2D1Geometry(ID2D1GeometryVtbl) { + fn GetRoundedRect( + roundedRect: *mut D2D1_ROUNDED_RECT, + ) -> (), +}} +RIDL!{#[uuid(0x2cd906a4, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1EllipseGeometry(ID2D1EllipseGeometryVtbl): ID2D1Geometry(ID2D1GeometryVtbl) { + fn GetEllipse( + ellipse: *mut D2D1_ELLIPSE, + ) -> (), +}} +RIDL!{#[uuid(0x2cd906a6, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1GeometryGroup(ID2D1GeometryGroupVtbl): ID2D1Geometry(ID2D1GeometryVtbl) { + fn GetFillMode() -> D2D1_FILL_MODE, + fn GetSourceGeometryCount() -> UINT32, + fn GetSourceGeometries( + geometries: *mut *mut ID2D1Geometry, + geometriesCount: UINT32, + ) -> (), +}} +RIDL!{#[uuid(0x2cd906bb, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1TransformedGeometry(ID2D1TransformedGeometryVtbl): + ID2D1Geometry(ID2D1GeometryVtbl) { + fn GetSourceGeometry( + sourceGeometry: *mut *mut ID2D1Geometry, + ) -> (), + fn GetTransform( + transform: *mut D2D1_MATRIX_3X2_F, + ) -> (), +}} +RIDL!{#[uuid(0x2cd9069e, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1SimplifiedGeometrySink(ID2D1SimplifiedGeometrySinkVtbl): IUnknown(IUnknownVtbl) { + fn SetFillMode( + fillMode: D2D1_FILL_MODE, + ) -> (), + fn SetSegmentFlags( + vertexFlags: D2D1_PATH_SEGMENT, + ) -> (), + fn BeginFigure( + startPoint: D2D1_POINT_2F, + figureBegin: D2D1_FIGURE_BEGIN, + ) -> (), + fn AddLines( + points: *const D2D1_POINT_2F, + pointsCount: UINT32, + ) -> (), + fn AddBeziers( + beziers: *const D2D1_BEZIER_SEGMENT, + beziersCount: UINT32, + ) -> (), + fn EndFigure( + figureEnd: D2D1_FIGURE_END, + ) -> (), + fn Close() -> HRESULT, +}} +RIDL!{#[uuid(0x2cd9069f, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1GeometrySink(ID2D1GeometrySinkVtbl): + ID2D1SimplifiedGeometrySink(ID2D1SimplifiedGeometrySinkVtbl) { + fn AddLine( + point: D2D1_POINT_2F, + ) -> (), + fn AddBezier( + bezier: *const D2D1_BEZIER_SEGMENT, + ) -> (), + fn AddQuadraticBezier( + bezier: *const D2D1_QUADRATIC_BEZIER_SEGMENT, + ) -> (), + fn AddQuadraticBeziers( + beziers: *const D2D1_QUADRATIC_BEZIER_SEGMENT, + beziersCount: UINT32, + ) -> (), + fn AddArc( + arc: *const D2D1_ARC_SEGMENT, + ) -> (), +}} +RIDL!{#[uuid(0x2cd906c1, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1TessellationSink(ID2D1TessellationSinkVtbl): IUnknown(IUnknownVtbl) { + fn AddTriangles( + triangles: *const D2D1_TRIANGLE, + triangleCount: UINT32, + ) -> (), + fn Close() -> HRESULT, +}} +RIDL!{#[uuid(0x2cd906a5, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1PathGeometry(ID2D1PathGeometryVtbl): ID2D1Geometry(ID2D1GeometryVtbl) { + fn Open( + geometrySink: *mut *mut ID2D1GeometrySink, + ) -> HRESULT, + fn Stream( + geometrySink: *mut ID2D1GeometrySink, + ) -> HRESULT, + fn GetSegmentCount( + count: *mut UINT32, + ) -> HRESULT, + fn GetFigureCount( + count: *mut UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2cd906c2, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1Mesh(ID2D1MeshVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn Open( + tessellationSink: *mut *mut ID2D1TessellationSink, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2cd9069b, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1Layer(ID2D1LayerVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + #[fixme] fn GetSize() -> D2D1_SIZE_F, +}} +RIDL!{#[uuid(0x28506e39, 0xebf6, 0x46a1, 0xbb, 0x47, 0xfd, 0x85, 0x56, 0x5a, 0xb9, 0x57)] +interface ID2D1DrawingStateBlock(ID2D1DrawingStateBlockVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn GetDescription( + stateDescription: *mut D2D1_DRAWING_STATE_DESCRIPTION, + ) -> (), + fn SetDescription( + stateDescription: *const D2D1_DRAWING_STATE_DESCRIPTION, + ) -> (), + fn SetTextRenderingParams( + textRenderingParams: *mut IDWriteRenderingParams, + ) -> (), + fn GetTextRenderingParams( + textRenderingParams: *mut *mut IDWriteRenderingParams, + ) -> (), +}} +RIDL!{#[uuid(0x2cd90694, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1RenderTarget(ID2D1RenderTargetVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn CreateBitmap( + size: D2D1_SIZE_U, + srcData: *const c_void, + pitch: UINT32, + bitmapProperties: *const D2D1_BITMAP_PROPERTIES, + bitmap: *mut *mut ID2D1Bitmap, + ) -> HRESULT, + fn CreateBitmapFromWicBitmap( + wicBitmapSource: *mut IWICBitmapSource, + bitmapProperties: *const D2D1_BITMAP_PROPERTIES, + bitmap: *mut *mut ID2D1Bitmap, + ) -> HRESULT, + fn CreateSharedBitmap( + riid: REFIID, + data: *const c_void, + bitmapProperties: *const D2D1_BITMAP_PROPERTIES, + bitmap: *mut *mut ID2D1Bitmap, + ) -> HRESULT, + fn CreateBitmapBrush( + bitmap: *mut ID2D1Bitmap, + bitmapBrushProperties: *const D2D1_BITMAP_BRUSH_PROPERTIES, + brushProperties: *const D2D1_BRUSH_PROPERTIES, + bitmapBrush: *mut *mut ID2D1BitmapBrush, + ) -> HRESULT, + fn CreateSolidColorBrush( + color: *const D2D1_COLOR_F, + brushProperties: *const D2D1_BRUSH_PROPERTIES, + solidColorBrush: *mut *mut ID2D1SolidColorBrush, + ) -> HRESULT, + fn CreateGradientStopCollection( + gradientStops: *const D2D1_GRADIENT_STOP, + gradientStopsCount: UINT32, + colorInterpolationGamma: D2D1_GAMMA, + extendMode: D2D1_EXTEND_MODE, + gradientStopCollection: *mut *mut ID2D1GradientStopCollection, + ) -> HRESULT, + fn CreateLinearGradientBrush( + linearGradientBrushProperties: *const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES, + brushProperties: *const D2D1_BRUSH_PROPERTIES, + gradientStopCollection: *mut ID2D1GradientStopCollection, + linearGradientBrush: *mut *mut ID2D1LinearGradientBrush, + ) -> HRESULT, + fn CreateRadialGradientBrush( + radialGradientBrushProperties: *const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES, + brushProperties: *const D2D1_BRUSH_PROPERTIES, + gradientStopCollection: *mut ID2D1GradientStopCollection, + radialGradientBrush: *mut *mut ID2D1RadialGradientBrush, + ) -> HRESULT, + fn CreateCompatibleRenderTarget( + desiredSize: *const D2D1_SIZE_F, + desiredPixelSize: *const D2D1_SIZE_U, + desiredFormat: *const D2D1_PIXEL_FORMAT, + options: D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS, + bitmapRenderTarget: *mut *mut ID2D1BitmapRenderTarget, + ) -> HRESULT, + fn CreateLayer( + size: *const D2D1_SIZE_F, + layer: *mut *mut ID2D1Layer, + ) -> HRESULT, + fn CreateMesh( + mesh: *mut *mut ID2D1Mesh, + ) -> HRESULT, + fn DrawLine( + point0: D2D1_POINT_2F, + point1: D2D1_POINT_2F, + brush: *mut ID2D1Brush, + strokeWidth: FLOAT, + strokeStype: *mut ID2D1StrokeStyle, + ) -> (), + fn DrawRectangle( + rect: *const D2D1_RECT_F, + brush: *mut ID2D1Brush, + strokeWidth: FLOAT, + strokeStyle: *mut ID2D1StrokeStyle, + ) -> (), + fn FillRectangle( + rect: *const D2D1_RECT_F, + brush: *mut ID2D1Brush, + ) -> (), + fn DrawRoundedRectangle( + roundedRect: *const D2D1_ROUNDED_RECT, + brush: *mut ID2D1Brush, + strokeWidth: FLOAT, + strokeStyle: *mut ID2D1StrokeStyle, + ) -> (), + fn FillRoundedRectangle( + roundedRect: *const D2D1_ROUNDED_RECT, + brush: *mut ID2D1Brush, + ) -> (), + fn DrawEllipse( + ellipse: *const D2D1_ELLIPSE, + brush: *mut ID2D1Brush, + strokeWidth: FLOAT, + strokeStyle: *mut ID2D1StrokeStyle, + ) -> (), + fn FillEllipse( + ellipse: *const D2D1_ELLIPSE, + brush: *mut ID2D1Brush, + ) -> (), + fn DrawGeometry( + geometry: *mut ID2D1Geometry, + brush: *mut ID2D1Brush, + strokeWidth: FLOAT, + strokeStyle: *mut ID2D1StrokeStyle, + ) -> (), + fn FillGeometry( + geometry: *mut ID2D1Geometry, + brush: *mut ID2D1Brush, + opacityBrush: *mut ID2D1Brush, + ) -> (), + fn FillMesh( + mesh: *mut ID2D1Mesh, + brush: *const ID2D1Brush, + ) -> (), + fn FillOpacityMask( + opacityMask: *mut ID2D1Bitmap, + brush: *mut ID2D1Brush, + content: D2D1_OPACITY_MASK_CONTENT, + destinationRectangle: *const D2D1_RECT_F, + sourceRectangle: *const D2D1_RECT_F, + ) -> (), + fn DrawBitmap( + bitmap: *mut ID2D1Bitmap, + destinationRectangle: *const D2D1_RECT_F, + opacity: FLOAT, + interpolationMode: D2D1_BITMAP_INTERPOLATION_MODE, + sourceRectangle: *const D2D1_RECT_F, + ) -> (), + fn DrawText( + string: *const WCHAR, + stringLength: UINT32, + textFormat: *mut IDWriteTextFormat, + layoutRect: *const D2D1_RECT_F, + defaultForegroundBrush: *mut ID2D1Brush, + options: D2D1_DRAW_TEXT_OPTIONS, + measuringMode: DWRITE_MEASURING_MODE, + ) -> (), + fn DrawTextLayout( + origin: D2D1_POINT_2F, + textLayout: *mut IDWriteTextLayout, + defaultForegroundBrush: *mut ID2D1Brush, + options: D2D1_DRAW_TEXT_OPTIONS, + ) -> (), + fn DrawGlyphRun( + baselineOrigin: D2D1_POINT_2F, + glyphRun: *const DWRITE_GLYPH_RUN, + foregroundBrush: *mut ID2D1Brush, + measuringMode: DWRITE_MEASURING_MODE, + ) -> (), + fn SetTransform( + transform: *const D2D1_MATRIX_3X2_F, + ) -> (), + fn GetTransform( + transform: *mut D2D1_MATRIX_3X2_F, + ) -> (), + fn SetAntialiasMode( + antialiasMode: D2D1_ANTIALIAS_MODE, + ) -> (), + fn GetAntialiasMode() -> D2D1_ANTIALIAS_MODE, + fn SetTextAntialiasMode( + textAntialiasMode: D2D1_TEXT_ANTIALIAS_MODE, + ) -> (), + fn GetTextAntialiasMode() -> D2D1_TEXT_ANTIALIAS_MODE, + fn SetTextRenderingParams( + textRenderingParams: *mut IDWriteRenderingParams, + ) -> (), + fn GetTextRenderingParams( + textRenderingParams: *mut *mut IDWriteRenderingParams, + ) -> (), + fn SetTags( + tag1: D2D1_TAG, + tag2: D2D1_TAG, + ) -> (), + fn GetTags( + tag1: *mut D2D1_TAG, + tag2: *mut D2D1_TAG, + ) -> (), + fn PushLayer( + layerParameters: *const D2D1_LAYER_PARAMETERS, + layer: *mut ID2D1Layer, + ) -> (), + fn PopLayer() -> (), + fn Flush( + tag1: *mut D2D1_TAG, + tag2: *mut D2D1_TAG, + ) -> HRESULT, + fn SaveDrawingState( + drawingStateBlock: *mut ID2D1DrawingStateBlock, + ) -> (), + fn RestoreDrawingState( + drawingStateBlock: *mut ID2D1DrawingStateBlock, + ) -> (), + fn PushAxisAlignedClip( + clipRect: *const D2D1_RECT_F, + antialiasMode: D2D1_ANTIALIAS_MODE, + ) -> (), + fn PopAxisAlignedClip() -> (), + fn Clear( + clearColor: *const D2D1_COLOR_F, + ) -> (), + fn BeginDraw() -> (), + fn EndDraw( + tag1: *mut D2D1_TAG, + tag2: *mut D2D1_TAG, + ) -> HRESULT, + #[fixme] fn GetPixelFormat() -> D2D1_PIXEL_FORMAT, + fn SetDpi( + dpiX: FLOAT, + dpiY: FLOAT, + ) -> (), + fn GetDpi( + dpiX: *mut FLOAT, + dpiY: *mut FLOAT, + ) -> (), + #[fixme] fn GetSize() -> D2D1_SIZE_F, + #[fixme] fn GetPixelSize() -> D2D1_SIZE_U, + fn GetMaximumBitmapSize() -> UINT32, + fn IsSupported( + renderTargetProperties: *const D2D1_RENDER_TARGET_PROPERTIES, + ) -> BOOL, +}} +RIDL!{#[uuid(0x2cd90695, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1BitmapRenderTarget(ID2D1BitmapRenderTargetVtbl): + ID2D1RenderTarget(ID2D1RenderTargetVtbl) { + fn GetBitmap( + bitmap: *mut *mut ID2D1Bitmap, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2cd90698, 0x12e2, 0x11dc, 0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9)] +interface ID2D1HwndRenderTarget(ID2D1HwndRenderTargetVtbl): + ID2D1RenderTarget(ID2D1RenderTargetVtbl) { + fn CheckWindowState() -> D2D1_WINDOW_STATE, + fn Resize( + pixelSize: *const D2D1_SIZE_U, + ) -> HRESULT, + fn GetHwnd() -> HWND, +}} +RIDL!{#[uuid(0xe0db51c3, 0x6f77, 0x4bae, 0xb3, 0xd5, 0xe4, 0x75, 0x09, 0xb3, 0x58, 0x38)] +interface ID2D1GdiInteropRenderTarget(ID2D1GdiInteropRenderTargetVtbl): IUnknown(IUnknownVtbl) { + fn GetDC( + mode: D2D1_DC_INITIALIZE_MODE, + hdc: *mut HDC, + ) -> HRESULT, + fn ReleaseDC( + update: *const RECT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1c51bc64, 0xde61, 0x46fd, 0x98, 0x99, 0x63, 0xa5, 0xd8, 0xf0, 0x39, 0x50)] +interface ID2D1DCRenderTarget(ID2D1DCRenderTargetVtbl): ID2D1RenderTarget(ID2D1RenderTargetVtbl) { + fn BindDC( + hDC: HDC, + pSubRect: *const RECT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x06152247, 0x6f50, 0x465a, 0x92, 0x45, 0x11, 0x8b, 0xfd, 0x3b, 0x60, 0x07)] +interface ID2D1Factory(ID2D1FactoryVtbl): IUnknown(IUnknownVtbl) { + fn ReloadSystemMetrics() -> HRESULT, + fn GetDesktopDpi( + dpiX: *mut FLOAT, + dpiY: *mut FLOAT, + ) -> (), + fn CreateRectangleGeometry( + rectangle: *const D2D1_RECT_F, + rectangleGeometry: *mut *mut ID2D1RectangleGeometry, + ) -> HRESULT, + fn CreateRoundedRectangleGeometry( + roundedRectangle: *const D2D1_ROUNDED_RECT, + roundedRectangleGeometry: *mut *mut ID2D1RoundedRectangleGeometry, + ) -> HRESULT, + fn CreateEllipseGeometry( + ellipse: *const D2D1_ELLIPSE, + ellipseGeometry: *mut *mut ID2D1EllipseGeometry, + ) -> HRESULT, + fn CreateGeometryGroup( + fillMode: D2D1_FILL_MODE, + geometries: *mut *mut ID2D1Geometry, + geometriesCount: UINT32, + geometryGroup: *mut *mut ID2D1GeometryGroup, + ) -> HRESULT, + fn CreateTransformedGeometry( + sourceGeometry: *mut ID2D1Geometry, + transform: *const D2D1_MATRIX_3X2_F, + transformedGeometry: *mut *mut ID2D1TransformedGeometry, + ) -> HRESULT, + fn CreatePathGeometry( + pathGeometry: *mut *mut ID2D1PathGeometry, + ) -> HRESULT, + fn CreateStrokeStyle( + strokeStyleProperties: *const D2D1_STROKE_STYLE_PROPERTIES, + dashes: *const FLOAT, + dashesCount: UINT32, + strokeStyle: *mut *mut ID2D1StrokeStyle, + ) -> HRESULT, + fn CreateDrawingStateBlock( + drawingStateDescription: *const D2D1_DRAWING_STATE_DESCRIPTION, + textRenderingParams: *mut IDWriteRenderingParams, + drawingStateBlock: *mut *mut ID2D1DrawingStateBlock, + ) -> HRESULT, + fn CreateWicBitmapRenderTarget( + target: *mut IWICBitmap, + renderTargetProperties: *const D2D1_RENDER_TARGET_PROPERTIES, + renderTarget: *mut *mut ID2D1RenderTarget, + ) -> HRESULT, + fn CreateHwndRenderTarget( + renderTargetProperties: *const D2D1_RENDER_TARGET_PROPERTIES, + hwndRenderTargetProperties: *const D2D1_HWND_RENDER_TARGET_PROPERTIES, + hwndRenderTarget: *mut *mut ID2D1HwndRenderTarget, + ) -> HRESULT, + fn CreateDxgiSurfaceRenderTarget( + dxgiSurface: *mut IDXGISurface, + renderTargetProperties: *const D2D1_RENDER_TARGET_PROPERTIES, + renderTarget: *mut *mut ID2D1RenderTarget, + ) -> HRESULT, + fn CreateDCRenderTarget( + renderTargetProperties: *const D2D1_RENDER_TARGET_PROPERTIES, + dcRenderTarget: *mut *mut ID2D1DCRenderTarget, + ) -> HRESULT, +}} +extern "system" { + pub fn D2D1CreateFactory( + factoryType: D2D1_FACTORY_TYPE, + riid: REFIID, + pFactoryOptions: *const D2D1_FACTORY_OPTIONS, + ppIFactory: *mut *mut c_void, + ) -> HRESULT; + pub fn D2D1MakeRotateMatrix( + angle: FLOAT, + center: D2D1_POINT_2F, + matrix: *mut D2D1_MATRIX_3X2_F, + ); + pub fn D2D1MakeSkewMatrix( + angleX: FLOAT, + angleY: FLOAT, + center: D2D1_POINT_2F, + matrix: *mut D2D1_MATRIX_3X2_F, + ); + pub fn D2D1IsMatrixInvertible( + matrix: *const D2D1_MATRIX_3X2_F, + ) -> BOOL; + pub fn D2D1InvertMatrix( + matrix: *mut D2D1_MATRIX_3X2_F, + ) -> BOOL; + pub fn D2D1ComputeMaximumScaleFactor( + matrix: *const D2D1_MATRIX_3X2_F, + ) -> FLOAT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1_1.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1_1.rs new file mode 100644 index 0000000..8217e30 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1_1.rs @@ -0,0 +1,847 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of d2d1_1.h +use ctypes::c_void; +use shared::basetsd::{UINT32, UINT64}; +use shared::dxgi::{IDXGIDevice, IDXGISurface}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::guiddef::{CLSID, REFCLSID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT}; +use um::d2d1::{ + D2D1_ANTIALIAS_MODE, D2D1_BRUSH_PROPERTIES, D2D1_CAP_STYLE, D2D1_COLOR_F, + D2D1_DASH_STYLE, D2D1_DEBUG_LEVEL, D2D1_EXTEND_MODE, D2D1_GRADIENT_STOP, + D2D1_INTERPOLATION_MODE_DEFINITION_ANISOTROPIC, D2D1_INTERPOLATION_MODE_DEFINITION_CUBIC, + D2D1_INTERPOLATION_MODE_DEFINITION_HIGH_QUALITY_CUBIC, + D2D1_INTERPOLATION_MODE_DEFINITION_LINEAR, + D2D1_INTERPOLATION_MODE_DEFINITION_MULTI_SAMPLE_LINEAR, + D2D1_INTERPOLATION_MODE_DEFINITION_NEAREST_NEIGHBOR, D2D1_LINE_JOIN, D2D1_MATRIX_3X2_F, + D2D1_POINT_2F, D2D1_RECT_F, D2D1_SIZE_U, D2D1_TAG, D2D1_TEXT_ANTIALIAS_MODE, ID2D1Bitmap, + ID2D1BitmapBrush, ID2D1BitmapBrushVtbl, ID2D1BitmapVtbl, ID2D1Brush, ID2D1BrushVtbl, + ID2D1DrawingStateBlock, ID2D1DrawingStateBlockVtbl, ID2D1Factory, ID2D1FactoryVtbl, + ID2D1Geometry, ID2D1GradientStopCollection, ID2D1GradientStopCollectionVtbl, ID2D1Image, + ID2D1ImageVtbl, ID2D1Layer, ID2D1Mesh, ID2D1PathGeometry, ID2D1PathGeometryVtbl, + ID2D1RenderTarget, ID2D1RenderTargetVtbl, ID2D1Resource, ID2D1ResourceVtbl, ID2D1StrokeStyle, + ID2D1StrokeStyleVtbl, +}; +use um::d2d1effectauthor::D2D1_PROPERTY_BINDING; +use um::d2dbasetypes::D2D_SIZE_F; +use um::dcommon::{D2D1_PIXEL_FORMAT, DWRITE_MEASURING_MODE}; +use um::documenttarget::IPrintDocumentPackageTarget; +use um::dwrite::{DWRITE_GLYPH_RUN, DWRITE_GLYPH_RUN_DESCRIPTION, IDWriteRenderingParams}; +use um::objidlbase::IStream; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::wincodec::{IWICBitmapSource, IWICColorContext, IWICImagingFactory}; +use um::winnt::{HRESULT, PCWSTR, PWSTR}; +FN!{stdcall PD2D1_EFFECT_FACTORY( + effectImpl: *mut *mut IUnknown, +) -> HRESULT} +pub use um::d2dbasetypes::D2D_RECT_L as D2D1_RECT_L; +pub use um::d2dbasetypes::D2D_POINT_2L as D2D1_POINT_2L; +ENUM!{enum D2D1_PROPERTY_TYPE { + D2D1_PROPERTY_TYPE_UNKNOWN = 0, + D2D1_PROPERTY_TYPE_STRING = 1, + D2D1_PROPERTY_TYPE_BOOL = 2, + D2D1_PROPERTY_TYPE_UINT32 = 3, + D2D1_PROPERTY_TYPE_INT32 = 4, + D2D1_PROPERTY_TYPE_FLOAT = 5, + D2D1_PROPERTY_TYPE_VECTOR2 = 6, + D2D1_PROPERTY_TYPE_VECTOR3 = 7, + D2D1_PROPERTY_TYPE_VECTOR4 = 8, + D2D1_PROPERTY_TYPE_BLOB = 9, + D2D1_PROPERTY_TYPE_IUNKNOWN = 10, + D2D1_PROPERTY_TYPE_ENUM = 11, + D2D1_PROPERTY_TYPE_ARRAY = 12, + D2D1_PROPERTY_TYPE_CLSID = 13, + D2D1_PROPERTY_TYPE_MATRIX_3X2 = 14, + D2D1_PROPERTY_TYPE_MATRIX_4X3 = 15, + D2D1_PROPERTY_TYPE_MATRIX_4X4 = 16, + D2D1_PROPERTY_TYPE_MATRIX_5X4 = 17, + D2D1_PROPERTY_TYPE_COLOR_CONTEXT = 18, + D2D1_PROPERTY_TYPE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_PROPERTY { + D2D1_PROPERTY_CLSID = 0x80000000, + D2D1_PROPERTY_DISPLAYNAME = 0x80000001, + D2D1_PROPERTY_AUTHOR = 0x80000002, + D2D1_PROPERTY_CATEGORY = 0x80000003, + D2D1_PROPERTY_DESCRIPTION = 0x80000004, + D2D1_PROPERTY_INPUTS = 0x80000005, + D2D1_PROPERTY_CACHED = 0x80000006, + D2D1_PROPERTY_PRECISION = 0x80000007, + D2D1_PROPERTY_MIN_INPUTS = 0x80000008, + D2D1_PROPERTY_MAX_INPUTS = 0x80000009, + D2D1_PROPERTY_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_SUBPROPERTY { + D2D1_SUBPROPERTY_DISPLAYNAME = 0x80000000, + D2D1_SUBPROPERTY_ISREADONLY = 0x80000001, + D2D1_SUBPROPERTY_MIN = 0x80000002, + D2D1_SUBPROPERTY_MAX = 0x80000003, + D2D1_SUBPROPERTY_DEFAULT = 0x80000004, + D2D1_SUBPROPERTY_FIELDS = 0x80000005, + D2D1_SUBPROPERTY_INDEX = 0x80000006, + D2D1_SUBPROPERTY_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BITMAP_OPTIONS { + D2D1_BITMAP_OPTIONS_NONE = 0x00000000, + D2D1_BITMAP_OPTIONS_TARGET = 0x00000001, + D2D1_BITMAP_OPTIONS_CANNOT_DRAW = 0x00000002, + D2D1_BITMAP_OPTIONS_CPU_READ = 0x00000004, + D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE = 0x00000008, + D2D1_BITMAP_OPTIONS_FORCE_DWORD = 0xffffffff, +}} +// DEFINE_ENUM_FLAG_OPERATORS(D2D1_BITMAP_OPTIONS); +ENUM!{enum D2D1_COMPOSITE_MODE { + D2D1_COMPOSITE_MODE_SOURCE_OVER = 0, + D2D1_COMPOSITE_MODE_DESTINATION_OVER = 1, + D2D1_COMPOSITE_MODE_SOURCE_IN = 2, + D2D1_COMPOSITE_MODE_DESTINATION_IN = 3, + D2D1_COMPOSITE_MODE_SOURCE_OUT = 4, + D2D1_COMPOSITE_MODE_DESTINATION_OUT = 5, + D2D1_COMPOSITE_MODE_SOURCE_ATOP = 6, + D2D1_COMPOSITE_MODE_DESTINATION_ATOP = 7, + D2D1_COMPOSITE_MODE_XOR = 8, + D2D1_COMPOSITE_MODE_PLUS = 9, + D2D1_COMPOSITE_MODE_SOURCE_COPY = 10, + D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY = 11, + D2D1_COMPOSITE_MODE_MASK_INVERT = 12, + D2D1_COMPOSITE_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BUFFER_PRECISION { + D2D1_BUFFER_PRECISION_UNKNOWN = 0, + D2D1_BUFFER_PRECISION_8BPC_UNORM = 1, + D2D1_BUFFER_PRECISION_8BPC_UNORM_SRGB = 2, + D2D1_BUFFER_PRECISION_16BPC_UNORM = 3, + D2D1_BUFFER_PRECISION_16BPC_FLOAT = 4, + D2D1_BUFFER_PRECISION_32BPC_FLOAT = 5, + D2D1_BUFFER_PRECISION_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_MAP_OPTIONS { + D2D1_MAP_OPTIONS_NONE = 0, + D2D1_MAP_OPTIONS_READ = 1, + D2D1_MAP_OPTIONS_WRITE = 2, + D2D1_MAP_OPTIONS_DISCARD = 4, + D2D1_MAP_OPTIONS_FORCE_DWORD = 0xffffffff, +}} +//DEFINE_ENUM_FLAG_OPERATORS(D2D1_MAP_OPTIONS); +ENUM!{enum D2D1_INTERPOLATION_MODE { + D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR = D2D1_INTERPOLATION_MODE_DEFINITION_NEAREST_NEIGHBOR, + D2D1_INTERPOLATION_MODE_LINEAR = D2D1_INTERPOLATION_MODE_DEFINITION_LINEAR, + D2D1_INTERPOLATION_MODE_CUBIC = D2D1_INTERPOLATION_MODE_DEFINITION_CUBIC, + D2D1_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR + = D2D1_INTERPOLATION_MODE_DEFINITION_MULTI_SAMPLE_LINEAR, + D2D1_INTERPOLATION_MODE_ANISOTROPIC = D2D1_INTERPOLATION_MODE_DEFINITION_ANISOTROPIC, + D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC + = D2D1_INTERPOLATION_MODE_DEFINITION_HIGH_QUALITY_CUBIC, + D2D1_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_UNIT_MODE { + D2D1_UNIT_MODE_DIPS = 0, + D2D1_UNIT_MODE_PIXELS = 1, + D2D1_UNIT_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_COLOR_SPACE { + D2D1_COLOR_SPACE_CUSTOM = 0, + D2D1_COLOR_SPACE_SRGB = 1, + D2D1_COLOR_SPACE_SCRGB = 2, + D2D1_COLOR_SPACE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DEVICE_CONTEXT_OPTIONS { + D2D1_DEVICE_CONTEXT_OPTIONS_NONE = 0, + D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS = 1, + D2D1_DEVICE_CONTEXT_OPTIONS_FORCE_DWORD = 0xffffffff, +}} +//DEFINE_ENUM_FLAG_OPERATORS(D2D1_DEVICE_CONTEXT_OPTIONS); +ENUM!{enum D2D1_STROKE_TRANSFORM_TYPE { + D2D1_STROKE_TRANSFORM_TYPE_NORMAL = 0, + D2D1_STROKE_TRANSFORM_TYPE_FIXED = 1, + D2D1_STROKE_TRANSFORM_TYPE_HAIRLINE = 2, + D2D1_STROKE_TRANSFORM_TYPE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_PRIMITIVE_BLEND { + D2D1_PRIMITIVE_BLEND_SOURCE_OVER = 0, + D2D1_PRIMITIVE_BLEND_COPY = 1, + D2D1_PRIMITIVE_BLEND_MIN = 2, + D2D1_PRIMITIVE_BLEND_ADD = 3, + D2D1_PRIMITIVE_BLEND_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_THREADING_MODE { + D2D1_THREADING_MODE_SINGLE_THREADED = super::d2d1::D2D1_FACTORY_TYPE_SINGLE_THREADED, + D2D1_THREADING_MODE_MULTI_THREADED = super::d2d1::D2D1_FACTORY_TYPE_MULTI_THREADED, + D2D1_THREADING_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_COLOR_INTERPOLATION_MODE { + D2D1_COLOR_INTERPOLATION_MODE_STRAIGHT = 0, + D2D1_COLOR_INTERPOLATION_MODE_PREMULTIPLIED = 1, + D2D1_COLOR_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff, +}} +pub use um::d2dbasetypes::D2D_VECTOR_2F as D2D1_VECTOR_2F; +pub use um::d2dbasetypes::D2D_VECTOR_3F as D2D1_VECTOR_3F; +pub use um::d2dbasetypes::D2D_VECTOR_4F as D2D1_VECTOR_4F; +STRUCT!{struct D2D1_BITMAP_PROPERTIES1 { + pixelFormat: D2D1_PIXEL_FORMAT, + dpiX: FLOAT, + dpiY: FLOAT, + bitmapOptions: D2D1_BITMAP_OPTIONS, + colorContext: *const ID2D1ColorContext, +}} +STRUCT!{struct D2D1_MAPPED_RECT { + pitch: UINT32, + bits: *const BYTE, +}} +STRUCT!{struct D2D1_RENDERING_CONTROLS { + bufferPrecision: D2D1_BUFFER_PRECISION, + tileSize: D2D1_SIZE_U, +}} +STRUCT!{struct D2D1_EFFECT_INPUT_DESCRIPTION { + effect: *const ID2D1Effect, + inputIndex: UINT32, + inputRectangle: D2D1_RECT_F, +}} +pub use um::d2dbasetypes::D2D_MATRIX_4X3_F as D2D1_MATRIX_4X3_F; +pub use um::d2dbasetypes::D2D_MATRIX_4X4_F as D2D1_MATRIX_4X4_F; +pub use um::d2dbasetypes::D2D_MATRIX_5X4_F as D2D1_MATRIX_5X4_F; +STRUCT!{struct D2D1_POINT_DESCRIPTION { + point: D2D1_POINT_2F, + unitTangentVector: D2D1_POINT_2F, + endSegment: UINT32, + endFigure: UINT32, + lengthToEndSegment: FLOAT, +}} +STRUCT!{struct D2D1_IMAGE_BRUSH_PROPERTIES { + sourceRectangle: D2D1_RECT_F, + extendModeX: D2D1_EXTEND_MODE, + extendModeY: D2D1_EXTEND_MODE, + interpolationMode: D2D1_INTERPOLATION_MODE, +}} +STRUCT!{struct D2D1_BITMAP_BRUSH_PROPERTIES1 { + extendModeX: D2D1_EXTEND_MODE, + extendModeY: D2D1_EXTEND_MODE, + interpolationMode: D2D1_INTERPOLATION_MODE, +}} +STRUCT!{struct D2D1_STROKE_STYLE_PROPERTIES1 { + startCap: D2D1_CAP_STYLE, + endCap: D2D1_CAP_STYLE, + dashCap: D2D1_CAP_STYLE, + lineJoin: D2D1_LINE_JOIN, + miterLimit: FLOAT, + dashStyle: D2D1_DASH_STYLE, + dashOffset: FLOAT, + transformType: D2D1_STROKE_TRANSFORM_TYPE, +}} +ENUM!{enum D2D1_LAYER_OPTIONS1 { + D2D1_LAYER_OPTIONS1_NONE = 0, + D2D1_LAYER_OPTIONS1_INITIALIZE_FROM_BACKGROUND = 1, + D2D1_LAYER_OPTIONS1_IGNORE_ALPHA = 2, + D2D1_LAYER_OPTIONS1_FORCE_DWORD = 0xffffffff, +}} +//DEFINE_ENUM_FLAG_OPERATORS(D2D1_LAYER_OPTIONS1); +STRUCT!{struct D2D1_LAYER_PARAMETERS1 { + contentBounds: D2D1_RECT_F, + geometricMask: *const ID2D1Geometry, + maskAntialiasMode: D2D1_ANTIALIAS_MODE, + maskTransform: D2D1_MATRIX_3X2_F, + opacity: FLOAT, + opacityBrush: *const ID2D1Brush, + layerOptions: D2D1_LAYER_OPTIONS1, +}} +ENUM!{enum D2D1_PRINT_FONT_SUBSET_MODE { + D2D1_PRINT_FONT_SUBSET_MODE_DEFAULT = 0, + D2D1_PRINT_FONT_SUBSET_MODE_EACHPAGE = 1, + D2D1_PRINT_FONT_SUBSET_MODE_NONE = 2, + D2D1_PRINT_FONT_SUBSET_MODE_FORCE_DWORD = 0xffffffff, +}} +STRUCT!{struct D2D1_DRAWING_STATE_DESCRIPTION1 { + antialiasMode: D2D1_ANTIALIAS_MODE, + textAntialiasMode: D2D1_TEXT_ANTIALIAS_MODE, + tag1: D2D1_TAG, + tag2: D2D1_TAG, + transform: D2D1_MATRIX_3X2_F, + primitiveBlend: D2D1_PRIMITIVE_BLEND, + unitMode: D2D1_UNIT_MODE, +}} +STRUCT!{struct D2D1_PRINT_CONTROL_PROPERTIES { + fontSubset: D2D1_PRINT_FONT_SUBSET_MODE, + rasterDPI: FLOAT, + colorSpace: D2D1_COLOR_SPACE, +}} +STRUCT!{struct D2D1_CREATION_PROPERTIES { + threadingMode: D2D1_THREADING_MODE, + debugLevel: D2D1_DEBUG_LEVEL, + options: D2D1_DEVICE_CONTEXT_OPTIONS, +}} +RIDL!{#[uuid(0x82237326, 0x8111, 0x4f7c, 0xbc, 0xf4, 0xb5, 0xc1, 0x17, 0x55, 0x64, 0xfe)] +interface ID2D1GdiMetafileSink(ID2D1GdiMetafileSinkVtbl): IUnknown(IUnknownVtbl) { + fn ProcessRecord( + recordType: DWORD, + recordData: *const c_void, + recordDataSize: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2f543dc3, 0xcfc1, 0x4211, 0x86, 0x4f, 0xcf, 0xd9, 0x1c, 0x6f, 0x33, 0x95)] +interface ID2D1GdiMetafile(ID2D1GdiMetafileVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn Stream( + sink: *const ID2D1GdiMetafileSink, + ) -> HRESULT, + fn GetBounds( + bounds: *mut D2D1_RECT_F, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x54d7898a, 0xa061, 0x40a7, 0xbe, 0xc7, 0xe4, 0x65, 0xbc, 0xba, 0x2c, 0x4f)] +interface ID2D1CommandSink(ID2D1CommandSinkVtbl): IUnknown(IUnknownVtbl) { + fn BeginDraw() -> HRESULT, + fn EndDraw() -> HRESULT, + fn SetAntialiasMode( + antialiasMode: D2D1_ANTIALIAS_MODE, + ) -> HRESULT, + fn SetTags( + tag1: D2D1_TAG, + tag2: D2D1_TAG, + ) -> HRESULT, + fn SetTextAntialiasMode( + textAntialiasMode: D2D1_TEXT_ANTIALIAS_MODE, + ) -> HRESULT, + fn SetTextRenderingParams( + textRenderingParams: *const IDWriteRenderingParams, + ) -> HRESULT, + fn SetTransform( + transform: *const D2D1_MATRIX_3X2_F, + ) -> HRESULT, + fn SetPrimitiveBlend( + primitiveBlend: D2D1_PRIMITIVE_BLEND, + ) -> HRESULT, + fn SetUnitMode( + unitMode: D2D1_UNIT_MODE, + ) -> HRESULT, + fn Clear( + color: *const D2D1_COLOR_F, + ) -> HRESULT, + fn DrawGlyphRun( + baselineOrigin: D2D1_POINT_2F, + glyphRun: *const DWRITE_GLYPH_RUN, + glyphRunDescription: *const DWRITE_GLYPH_RUN_DESCRIPTION, + foregroundBrush: *const ID2D1Brush, + measuringMode: DWRITE_MEASURING_MODE, + ) -> HRESULT, + fn DrawLine( + point0: D2D1_POINT_2F, + point1: D2D1_POINT_2F, + brush: *const ID2D1Brush, + strokeWidth: FLOAT, + strokeStyle: *const ID2D1StrokeStyle, + ) -> HRESULT, + fn DrawGeometry( + geometry: *const ID2D1Geometry, + brush: *const ID2D1Brush, + strokeWidth: FLOAT, + strokeStyle: *const ID2D1StrokeStyle, + ) -> HRESULT, + fn DrawRectangle( + rect: *const D2D1_RECT_F, + brush: *const ID2D1Brush, + strokeWidth: FLOAT, + strokeStyle: *const ID2D1StrokeStyle, + ) -> HRESULT, + fn DrawBitmap( + bitmap: *const ID2D1Bitmap, + destinationRectangle: *const D2D1_RECT_F, + opacity: FLOAT, + interpolationMode: D2D1_INTERPOLATION_MODE, + sourceRectangle: *const D2D1_RECT_F, + perspectiveTransform: *const D2D1_MATRIX_4X4_F, + ) -> HRESULT, + fn DrawImage( + image: *const ID2D1Image, + targetOffset: *const D2D1_POINT_2F, + imageRectangle: *const D2D1_RECT_F, + interpolationMode: D2D1_INTERPOLATION_MODE, + compositeMode: D2D1_COMPOSITE_MODE, + ) -> HRESULT, + fn DrawGdiMetafile( + gdiMetafile: *const ID2D1GdiMetafile, + targetOffset: *const D2D1_POINT_2F, + ) -> HRESULT, + fn FillMesh( + mesh: *const ID2D1Mesh, + brush: *const ID2D1Brush, + ) -> HRESULT, + fn FillOpacityMask( + opacityMask: *const ID2D1Bitmap, + brush: *const ID2D1Brush, + destinationRectangle: *const D2D1_RECT_F, + sourceRectangle: *const D2D1_RECT_F, + ) -> HRESULT, + fn FillGeometry( + geometry: *const ID2D1Geometry, + brush: *const ID2D1Brush, + opacityBrush: *const ID2D1Brush, + ) -> HRESULT, + fn FillRectangle( + rect: *const D2D1_RECT_F, + brush: *const ID2D1Brush, + ) -> HRESULT, + fn PushAxisAlignedClip( + clipRect: *const D2D1_RECT_F, + antialiasMode: D2D1_ANTIALIAS_MODE, + ) -> HRESULT, + fn PushLayer( + layerParameters1: *const D2D1_LAYER_PARAMETERS1, + layer: *const ID2D1Layer, + ) -> HRESULT, + fn PopAxisAlignedClip() -> HRESULT, + fn PopLayer() -> HRESULT, +}} +RIDL!{#[uuid(0xb4f34a19, 0x2383, 0x4d76, 0x94, 0xf6, 0xec, 0x34, 0x36, 0x57, 0xc3, 0xdc)] +interface ID2D1CommandList(ID2D1CommandListVtbl): ID2D1Image(ID2D1ImageVtbl) { + fn Stream( + sink: *const ID2D1CommandSink, + ) -> HRESULT, + fn Close() -> HRESULT, +}} +RIDL!{#[uuid(0x2c1d867d, 0xc290, 0x41c8, 0xae, 0x7e, 0x34, 0xa9, 0x87, 0x02, 0xe9, 0xa5)] +interface ID2D1PrintControl(ID2D1PrintControlVtbl): IUnknown(IUnknownVtbl) { + fn AddPage( + commandList: *const ID2D1CommandList, + pageSize: D2D_SIZE_F, + pagePrintTicketStream: *const IStream, + tag1: *mut D2D1_TAG, + tag2: *mut D2D1_TAG, + ) -> HRESULT, + fn Close() -> HRESULT, +}} +RIDL!{#[uuid(0xfe9e984d, 0x3f95, 0x407c, 0xb5, 0xdb, 0xcb, 0x94, 0xd4, 0xe8, 0xf8, 0x7c)] +interface ID2D1ImageBrush(ID2D1ImageBrushVtbl): ID2D1Brush(ID2D1BrushVtbl) { + fn SetImage( + image: *const ID2D1Image, + ) -> (), + fn SetExtendModeX( + extendModeX: D2D1_EXTEND_MODE, + ) -> (), + fn SetExtendModeY( + extendModeY: D2D1_EXTEND_MODE, + ) -> (), + fn SetInterpolationMode( + interpolationMode: D2D1_INTERPOLATION_MODE, + ) -> (), + fn SetSourceRectangle( + sourceRectangle: *const D2D1_RECT_F, + ) -> (), + fn GetImage( + image: *mut *mut ID2D1Image, + ) -> (), + fn GetExtendModeX() -> D2D1_EXTEND_MODE, + fn GetExtendModeY() -> D2D1_EXTEND_MODE, + fn GetInterpolationMode() -> D2D1_INTERPOLATION_MODE, + fn GetSourceRectangle( + sourceRectangle: *mut D2D1_RECT_F, + ) -> (), +}} +RIDL!{#[uuid(0x41343a53, 0xe41a, 0x49a2, 0x91, 0xcd, 0x21, 0x79, 0x3b, 0xbb, 0x62, 0xe5)] +interface ID2D1BitmapBrush1(ID2D1BitmapBrush1Vtbl): ID2D1BitmapBrush(ID2D1BitmapBrushVtbl) { + fn SetInterpolationMode1( + interpolationMode: D2D1_INTERPOLATION_MODE, + ) -> (), + fn GetInterpolationMode1() -> D2D1_INTERPOLATION_MODE, +}} +RIDL!{#[uuid(0x10a72a66, 0xe91c, 0x43f4, 0x99, 0x3f, 0xdd, 0xf4, 0xb8, 0x2b, 0x0b, 0x4a)] +interface ID2D1StrokeStyle1(ID2D1StrokeStyle1Vtbl): ID2D1StrokeStyle(ID2D1StrokeStyleVtbl) { + fn GetStrokeTransformType() -> D2D1_STROKE_TRANSFORM_TYPE, +}} +RIDL!{#[uuid(0x62baa2d2, 0xab54, 0x41b7, 0xb8, 0x72, 0x78, 0x7e, 0x01, 0x06, 0xa4, 0x21)] +interface ID2D1PathGeometry1(ID2D1PathGeometry1Vtbl): ID2D1PathGeometry(ID2D1PathGeometryVtbl) { + fn ComputePointAndSegmentAtLength( + length: FLOAT, + startSegment: UINT32, + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + pointDescription: *mut D2D1_POINT_DESCRIPTION, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x483473d7, 0xcd46, 0x4f9d, 0x9d, 0x3a, 0x31, 0x12, 0xaa, 0x80, 0x15, 0x9d)] +interface ID2D1Properties(ID2D1PropertiesVtbl): IUnknown(IUnknownVtbl) { + fn GetPropertyCount() -> UINT32, + fn GetPropertyName( + index: UINT32, + name: PWSTR, + nameCount: UINT32, + ) -> HRESULT, + fn GetPropertyNameLength( + index: UINT32, + ) -> UINT32, + fn GetType( + index: UINT32, + ) -> D2D1_PROPERTY_TYPE, + fn GetPropertyIndex( + name: PCWSTR, + ) -> UINT32, + fn SetValueByName( + name: PCWSTR, + prop_type: D2D1_PROPERTY_TYPE, + data: *const BYTE, + dataSize: UINT32, + ) -> HRESULT, + fn SetValue( + index: UINT32, + prop_type: D2D1_PROPERTY_TYPE, + data: *const BYTE, + dataSize: UINT32, + ) -> HRESULT, + fn GetValueByName( + name: PCWSTR, + prop_type: D2D1_PROPERTY_TYPE, + data: *mut BYTE, + dataSize: UINT32, + ) -> HRESULT, + fn GetValue( + index: UINT32, + prop_type: D2D1_PROPERTY_TYPE, + data: *mut BYTE, + dataSize: UINT32, + ) -> HRESULT, + fn GetValueSize( + index: UINT32, + ) -> UINT32, + fn GetSubProperties( + index: UINT32, + subProperties: *mut *mut ID2D1Properties, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x28211a43, 0x7d89, 0x476f, 0x81, 0x81, 0x2d, 0x61, 0x59, 0xb2, 0x20, 0xad)] +interface ID2D1Effect(ID2D1EffectVtbl): ID2D1Properties(ID2D1PropertiesVtbl) { + fn SetInput( + index: UINT32, + input: *const ID2D1Image, + invalidate: BOOL, + ) -> (), + fn SetInputCount( + inputCount: UINT32, + ) -> HRESULT, + fn GetInput( + index: UINT32, + input: *mut *mut ID2D1Image, + ) -> (), + fn GetInputCount() -> UINT32, + fn GetOutput( + outputImage: *mut *mut ID2D1Image, + ) -> (), +}} +RIDL!{#[uuid(0xa898a84c, 0x3873, 0x4588, 0xb0, 0x8b, 0xeb, 0xbf, 0x97, 0x8d, 0xf0, 0x41)] +interface ID2D1Bitmap1(ID2D1Bitmap1Vtbl): ID2D1Bitmap(ID2D1BitmapVtbl) { + fn GetColorContext( + colorContext: *mut *mut ID2D1ColorContext, + ) -> (), + fn GetOptions() -> D2D1_BITMAP_OPTIONS, + fn GetSurface( + dxgiSurface: *mut *mut IDXGISurface, + ) -> HRESULT, + fn Map( + options: D2D1_MAP_OPTIONS, + mappedRect: *mut D2D1_MAPPED_RECT, + ) -> HRESULT, + fn Unmap() -> HRESULT, +}} +RIDL!{#[uuid(0x1c4820bb, 0x5771, 0x4518, 0xa5, 0x81, 0x2f, 0xe4, 0xdd, 0x0e, 0xc6, 0x57)] +interface ID2D1ColorContext(ID2D1ColorContextVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn GetColorSpace() -> D2D1_COLOR_SPACE, + fn GetProfileSize() -> UINT32, + fn GetProfile( + profile: *mut BYTE, + profileSize: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xae1572f4, 0x5dd0, 0x4777, 0x99, 0x8b, 0x92, 0x79, 0x47, 0x2a, 0xe6, 0x3b)] +interface ID2D1GradientStopCollection1(ID2D1GradientStopCollection1Vtbl): + ID2D1GradientStopCollection(ID2D1GradientStopCollectionVtbl) { + fn GetGradientStops1( + gradientStops: *mut D2D1_GRADIENT_STOP, + gradientStopsCount: UINT32, + ) -> (), + fn GetPreInterpolationSpace() -> D2D1_COLOR_SPACE, + fn GetPostInterpolationSpace() -> D2D1_COLOR_SPACE, + fn GetBufferPrecision() -> D2D1_BUFFER_PRECISION, + fn GetColorInterpolationMode() -> D2D1_COLOR_INTERPOLATION_MODE, +}} +RIDL!{#[uuid(0x689f1f85, 0xc72e, 0x4e33, 0x8f, 0x19, 0x85, 0x75, 0x4e, 0xfd, 0x5a, 0xce)] +interface ID2D1DrawingStateBlock1(ID2D1DrawingStateBlock1Vtbl): + ID2D1DrawingStateBlock(ID2D1DrawingStateBlockVtbl) { + fn GetDescription( + stateDescription: *mut D2D1_DRAWING_STATE_DESCRIPTION1, + ) -> (), + fn SetDescription( + stateDescription: *const D2D1_DRAWING_STATE_DESCRIPTION1, + ) -> (), +}} +RIDL!{#[uuid(0xe8f7fe7a, 0x191c, 0x466d, 0xad, 0x95, 0x97, 0x56, 0x78, 0xbd, 0xa9, 0x98)] +interface ID2D1DeviceContext(ID2D1DeviceContextVtbl): ID2D1RenderTarget(ID2D1RenderTargetVtbl) { + fn CreateBitmap( + size: D2D1_SIZE_U, + sourceData: *const c_void, + pitch: UINT32, + bitmapProperties: *const D2D1_BITMAP_PROPERTIES1, + bitmap: *mut *mut ID2D1Bitmap1, + ) -> HRESULT, + fn CreateBitmapFromWicBitmap( + wicBitmapSource: *const IWICBitmapSource, + bitmapProperties: *const D2D1_BITMAP_PROPERTIES1, + bitmap: *mut *mut ID2D1Bitmap1, + ) -> HRESULT, + fn CreateColorContext( + space: D2D1_COLOR_SPACE, + profile: *const BYTE, + profileSize: UINT32, + colorContext: *mut *mut ID2D1ColorContext, + ) -> HRESULT, + fn CreateColorContextFromFilename( + filename: PCWSTR, + colorContext: *mut *mut ID2D1ColorContext, + ) -> HRESULT, + fn CreateColorContextFromWicColorContext( + wicColorContext: *const IWICColorContext, + colorContext: *mut *mut ID2D1ColorContext, + ) -> HRESULT, + fn CreateBitmapFromDxgiSurface( + surface: *const IDXGISurface, + bitmapProperties: *const D2D1_BITMAP_PROPERTIES1, + bitmap: *mut *mut ID2D1Bitmap1, + ) -> HRESULT, + fn CreateEffect( + effectId: REFCLSID, + effect: *mut *mut ID2D1Effect, + ) -> HRESULT, + fn CreateGradientStopCollection( + straightAlphaGradientStops: *const D2D1_GRADIENT_STOP, + straightAlphaGradientStopsCount: UINT32, + preInterpolationSpace: D2D1_COLOR_SPACE, + postInterpolationSpace: D2D1_COLOR_SPACE, + bufferPrecision: D2D1_BUFFER_PRECISION, + extendMode: D2D1_EXTEND_MODE, + colorInterpolationMode: D2D1_COLOR_INTERPOLATION_MODE, + gradientStopCollection1: *mut *mut ID2D1GradientStopCollection1, + ) -> HRESULT, + fn CreateImageBrush( + image: *const ID2D1Image, + imageBrushProperties: *const D2D1_IMAGE_BRUSH_PROPERTIES, + brushProperties: *const D2D1_BRUSH_PROPERTIES, + imageBrush: *mut *mut ID2D1ImageBrush, + ) -> HRESULT, + fn CreateBitmapBrush( + bitmap: *const ID2D1Bitmap, + bitmapBrushProperties: *const D2D1_BITMAP_BRUSH_PROPERTIES1, + brushProperties: *const D2D1_BRUSH_PROPERTIES, + bitmapBrush: *mut *mut ID2D1BitmapBrush1, + ) -> HRESULT, + fn CreateCommandList( + commandList: *mut *mut ID2D1CommandList, + ) -> HRESULT, + fn IsDxgiFormatSupported( + format: DXGI_FORMAT, + ) -> BOOL, + fn IsBufferPrecisionSupported( + bufferPrecision: D2D1_BUFFER_PRECISION, + ) -> BOOL, + fn GetImageLocalBounds( + image: *const ID2D1Image, + localBounds: *mut D2D1_RECT_F, + ) -> HRESULT, + fn GetImageWorldBounds( + image: *const ID2D1Image, + worldBounds: *mut D2D1_RECT_F, + ) -> HRESULT, + fn GetGlyphRunWorldBounds( + baselineOrigin: D2D1_POINT_2F, + glyphRun: *const DWRITE_GLYPH_RUN, + measuringMode: DWRITE_MEASURING_MODE, + bounds: *mut D2D1_RECT_F, + ) -> HRESULT, + fn GetDevice( + device: *mut *mut ID2D1Device, + ) -> (), + fn SetTarget( + image: *const ID2D1Image, + ) -> (), + fn GetTarget( + image: *mut *mut ID2D1Image, + ) -> (), + fn SetRenderingControls( + renderingControls: *const D2D1_RENDERING_CONTROLS, + ) -> (), + fn GetRenderingControls( + renderingControls: *mut D2D1_RENDERING_CONTROLS, + ) -> (), + fn SetPrimitiveBlend( + primitiveBlend: D2D1_PRIMITIVE_BLEND, + ) -> (), + fn GetPrimitiveBlend() -> D2D1_PRIMITIVE_BLEND, + fn SetUnitMode( + unitMode: D2D1_UNIT_MODE, + ) -> (), + fn GetUnitMode() -> D2D1_UNIT_MODE, + fn DrawGlyphRun( + baselineOrigin: D2D1_POINT_2F, + glyphRun: *const DWRITE_GLYPH_RUN, + glyphRunDescription: *const DWRITE_GLYPH_RUN_DESCRIPTION, + foregroundBrush: *const ID2D1Brush, + measuringMode: DWRITE_MEASURING_MODE, + ) -> (), + fn DrawImage( + image: *const ID2D1Image, + targetOffset: *const D2D1_POINT_2F, + imageRectangle: *const D2D1_RECT_F, + interpolationMode: D2D1_INTERPOLATION_MODE, + compositeMode: D2D1_COMPOSITE_MODE, + ) -> (), + fn DrawGdiMetafile( + gdiMetafile: *const ID2D1GdiMetafile, + targetOffset: *const D2D1_POINT_2F, + ) -> (), + fn DrawBitmap( + bitmap: *const ID2D1Bitmap, + destinationRectangle: *const D2D1_RECT_F, + opacity: FLOAT, + interpolationMode: D2D1_INTERPOLATION_MODE, + sourceRectangle: *const D2D1_RECT_F, + perspectiveTransform: *const D2D1_MATRIX_4X4_F, + ) -> (), + fn PushLayer( + layerParameters: *const D2D1_LAYER_PARAMETERS1, + layer: *const ID2D1Layer, + ) -> (), + fn InvalidateEffectInputRectangle( + effect: *const ID2D1Effect, + input: UINT32, + inputRectangle: *const D2D1_RECT_F, + ) -> HRESULT, + fn GetEffectInvalidRectangleCount( + effect: *const ID2D1Effect, + rectangleCount: *mut UINT32, + ) -> HRESULT, + fn GetEffectInvalidRectangles( + effect: *const ID2D1Effect, + rectangles: *mut D2D1_RECT_F, + rectanglesCount: UINT32, + ) -> HRESULT, + fn GetEffectRequiredInputRectangles( + renderEffect: *const ID2D1Effect, + renderImageRectangle: *const D2D1_RECT_F, + inputDescriptions: *const D2D1_EFFECT_INPUT_DESCRIPTION, + requiredInputRects: *mut D2D1_RECT_F, + inputCount: UINT32, + ) -> HRESULT, + fn FillOpacityMask( + opacityMask: *const ID2D1Bitmap, + brush: *const ID2D1Brush, + destinationRectangle: *const D2D1_RECT_F, + sourceRectangle: *const D2D1_RECT_F, + ) -> (), +}} +RIDL!{#[uuid(0x47dd575d, 0xac05, 0x4cdd, 0x80, 0x49, 0x9b, 0x02, 0xcd, 0x16, 0xf4, 0x4c)] +interface ID2D1Device(ID2D1DeviceVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn CreateDeviceContext( + options: D2D1_DEVICE_CONTEXT_OPTIONS, + deviceContext: *mut *mut ID2D1DeviceContext, + ) -> HRESULT, + fn CreatePrintControl( + wicFactory: *const IWICImagingFactory, + documentTarget: *const IPrintDocumentPackageTarget, + printControlProperties: *const D2D1_PRINT_CONTROL_PROPERTIES, + printControl: *mut *mut ID2D1PrintControl, + ) -> HRESULT, + fn SetMaximumTextureMemory( + maximumInBytes: UINT64, + ) -> (), + fn GetMaximumTextureMemory() -> UINT64, + fn ClearResources( + millisecondsSinceUse: UINT32, + ) -> (), +}} +RIDL!{#[uuid(0xbb12d362, 0xdaee, 0x4b9a, 0xaa, 0x1d, 0x14, 0xba, 0x40, 0x1c, 0xfa, 0x1f)] +interface ID2D1Factory1(ID2D1Factory1Vtbl): ID2D1Factory(ID2D1FactoryVtbl) { + fn CreateDevice( + dxgiDevice: *const IDXGIDevice, + d2dDevice: *mut *mut ID2D1Device, + ) -> HRESULT, + fn CreateStrokeStyle( + strokeStyleProperties: *const D2D1_STROKE_STYLE_PROPERTIES1, + dashes: *const FLOAT, + dashesCount: UINT32, + strokeStyle: *mut *mut ID2D1StrokeStyle1, + ) -> HRESULT, + fn CreatePathGeometry( + pathGeometry: *mut *mut ID2D1PathGeometry1, + ) -> HRESULT, + fn CreateDrawingStateBlock( + drawingStateDescription: *const D2D1_DRAWING_STATE_DESCRIPTION1, + textRenderingParams: *const IDWriteRenderingParams, + drawingStateBlock: *mut *mut ID2D1DrawingStateBlock1, + ) -> HRESULT, + fn CreateGdiMetafile( + metafileStream: *const IStream, + metafile: *mut *mut ID2D1GdiMetafile, + ) -> HRESULT, + fn RegisterEffectFromStream( + classId: REFCLSID, + propertyXml: *const IStream, + bindings: *const D2D1_PROPERTY_BINDING, + bindingsCount: UINT32, + effectFactory: PD2D1_EFFECT_FACTORY, + ) -> HRESULT, + fn RegisterEffectFromString( + classId: REFCLSID, + propertyXml: PCWSTR, + bindings: *const D2D1_PROPERTY_BINDING, + bindingsCount: UINT32, + effectFactory: PD2D1_EFFECT_FACTORY, + ) -> HRESULT, + fn UnregisterEffect( + classId: REFCLSID, + ) -> HRESULT, + fn GetRegisteredEffects( + effects: *mut CLSID, + effectsCount: UINT32, + effectsReturned: *mut UINT32, + effectsRegistered: *mut UINT32, + ) -> HRESULT, + fn GetEffectProperties( + effectId: REFCLSID, + properties: *mut *mut ID2D1Properties, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x31e6e7bc, 0xe0ff, 0x4d46, 0x8c, 0x64, 0xa0, 0xa8, 0xc4, 0x1c, 0x15, 0xd3)] +interface ID2D1Multithread(ID2D1MultithreadVtbl): IUnknown(IUnknownVtbl) { + fn GetMultithreadProtected() -> BOOL, + fn Enter() -> (), + fn Leave() -> (), +}} +extern "system" { + pub fn D2D1CreateDevice( + dxgiDevice: *const IDXGIDevice, + creationProperties: *const D2D1_CREATION_PROPERTIES, + d2dDevice: *mut *mut ID2D1Device, + ) -> HRESULT; + pub fn D2D1CreateDeviceContext( + dxgiSurface: *const IDXGISurface, + creationProperties: *const D2D1_CREATION_PROPERTIES, + d2dDeviceContext: *mut *mut ID2D1DeviceContext, + ) -> HRESULT; + pub fn D2D1ConvertColorSpace( + sourceColorSpace: D2D1_COLOR_SPACE, + destinationColorSpace: D2D1_COLOR_SPACE, + color: *const D2D1_COLOR_F, + ) -> D2D1_COLOR_F; + pub fn D2D1SinCos( + angle: FLOAT, + s: *mut FLOAT, + c: *mut FLOAT, + ) -> (); + pub fn D2D1Tan( + angle: FLOAT, + ) -> FLOAT; + pub fn D2D1Vec3Length( + x: FLOAT, + y: FLOAT, + z: FLOAT, + ) -> FLOAT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1_2.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1_2.rs new file mode 100644 index 0000000..31b0513 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1_2.rs @@ -0,0 +1,68 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of d2d1_2.h +use shared::dxgi::IDXGIDevice; +use shared::minwindef::FLOAT; +use um::d2d1::{ID2D1Brush, ID2D1Geometry, ID2D1StrokeStyle}; +use um::d2d1::{ID2D1Resource, ID2D1ResourceVtbl}; +use um::d2d1_1::{D2D1_DEVICE_CONTEXT_OPTIONS, D2D1_PRIMITIVE_BLEND}; +use um::d2d1_1::{ID2D1DeviceContext, ID2D1DeviceContextVtbl}; +use um::d2d1_1::{ID2D1Device, ID2D1DeviceVtbl}; +use um::d2d1_1::{ID2D1Factory1, ID2D1Factory1Vtbl}; +use um::d2d1_1::{ID2D1CommandSink, ID2D1CommandSinkVtbl}; +use um::winnt::HRESULT; +ENUM!{enum D2D1_RENDERING_PRIORITY { + D2D1_RENDERING_PRIORITY_NORMAL = 0, + D2D1_RENDERING_PRIORITY_LOW = 1, + D2D1_RENDERING_PRIORITY_FORCE_DWORD = 0xffffffff, +}} +RIDL!{#[uuid(0xa16907d7, 0xbc02, 0x4801, 0x99, 0xe8, 0x8c, 0xf7, 0xf4, 0x85, 0xf7, 0x74)] +interface ID2D1GeometryRealization(ID2D1GeometryRealizationVtbl): + ID2D1Resource(ID2D1ResourceVtbl) {}} +RIDL!{#[uuid(0xd37f57e4, 0x6908, 0x459f, 0xa1, 0x99, 0xe7, 0x2f, 0x24, 0xf7, 0x99, 0x87)] +interface ID2D1DeviceContext1(ID2D1DeviceContext1Vtbl): + ID2D1DeviceContext(ID2D1DeviceContextVtbl) { + fn CreateFilledGeometryRealization( + geometry: *mut ID2D1Geometry, + flatteningTolerance: FLOAT, + geometryRealization: *mut *mut ID2D1GeometryRealization, + ) -> HRESULT, + fn CreateStrokedGeometryRealization( + geometry: *mut ID2D1Geometry, + flatteningTolerance: FLOAT, + strokeWidth: FLOAT, + strokeStyle: *mut ID2D1StrokeStyle, + geometryRealization: *mut *mut ID2D1GeometryRealization, + ) -> HRESULT, + fn DrawGeometryRealization( + geometryRealization: *mut ID2D1GeometryRealization, + brush: *mut ID2D1Brush, + ) -> (), +}} +RIDL!{#[uuid(0xd21768e1, 0x23a4, 0x4823, 0xa1, 0x4b, 0x7c, 0x3e, 0xba, 0x85, 0xd6, 0x58)] +interface ID2D1Device1(ID2D1Device1Vtbl): ID2D1Device(ID2D1DeviceVtbl) { + fn GetRenderingPriority() -> D2D1_RENDERING_PRIORITY, + fn SetRenderingPriority( + renderingPriority: D2D1_RENDERING_PRIORITY, + ) -> (), + fn CreateDeviceContext( + options: D2D1_DEVICE_CONTEXT_OPTIONS, + deviceContext1: *mut *mut ID2D1DeviceContext1, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x94f81a73, 0x9212, 0x4376, 0x9c, 0x58, 0xb1, 0x6a, 0x3a, 0x0d, 0x39, 0x92)] +interface ID2D1Factory2(ID2D1Factory2Vtbl): ID2D1Factory1(ID2D1Factory1Vtbl) { + fn CreateDevice( + dxgiDevice: *mut IDXGIDevice, + d2dDevice1: *mut *mut ID2D1Device1, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9eb767fd, 0x4269, 0x4467, 0xb8, 0xc2, 0xeb, 0x30, 0xcb, 0x30, 0x57, 0x43)] +interface ID2D1CommandSink1(ID2D1CommandSink1Vtbl): ID2D1CommandSink(ID2D1CommandSinkVtbl) { + fn SetPrimitiveBlend1( + primitiveBlend: D2D1_PRIMITIVE_BLEND, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1_3.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1_3.rs new file mode 100644 index 0000000..64b7bd3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1_3.rs @@ -0,0 +1,698 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of d2d1_3.h +use ctypes::c_void; +use shared::basetsd::{UINT16, UINT32, UINT64}; +use shared::dxgi::{IDXGIDevice, IDXGISurface}; +use shared::dxgitype::DXGI_COLOR_SPACE_TYPE; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT}; +use shared::ntdef::WCHAR; +use shared::winerror::HRESULT; +use um::d2d1::{ + D2D1_BITMAP_INTERPOLATION_MODE, D2D1_COLOR_F, D2D1_DRAW_TEXT_OPTIONS, D2D1_GAMMA_1_0, + D2D1_GAMMA_2_2, D2D1_MATRIX_3X2_F, D2D1_POINT_2F, D2D1_RECT_F, D2D1_RECT_U, D2D1_SIZE_F, + ID2D1Bitmap, ID2D1Brush, ID2D1Image, ID2D1ImageVtbl, ID2D1Resource, ID2D1ResourceVtbl, + ID2D1SimplifiedGeometrySink, +}; +use um::d2d1_1::{ + D2D1_BUFFER_PRECISION, D2D1_DEVICE_CONTEXT_OPTIONS, D2D1_INTERPOLATION_MODE, + D2D1_PRIMITIVE_BLEND, ID2D1ColorContext, ID2D1ColorContextVtbl, ID2D1CommandList, + ID2D1GdiMetafile, ID2D1GdiMetafileSink, ID2D1GdiMetafileSinkVtbl, ID2D1GdiMetafileVtbl, +}; +use um::d2d1_2::{ + ID2D1CommandSink1, ID2D1CommandSink1Vtbl, ID2D1Device1, ID2D1Device1Vtbl, ID2D1DeviceContext1, + ID2D1DeviceContext1Vtbl, ID2D1Factory2, ID2D1Factory2Vtbl, +}; +use um::d2d1effects::D2D1_BLEND_MODE; +use um::d2d1svg::ID2D1SvgDocument; +use um::dcommon::{D2D1_ALPHA_MODE, DWRITE_GLYPH_IMAGE_FORMATS, DWRITE_MEASURING_MODE}; +use um::dwrite::{DWRITE_GLYPH_RUN, IDWriteFontFace, IDWriteTextFormat, IDWriteTextLayout}; +use um::objidlbase::IStream; +use um::wincodec::IWICBitmapSource; +ENUM!{enum D2D1_INK_NIB_SHAPE { + D2D1_INK_NIB_SHAPE_ROUND = 0, + D2D1_INK_NIB_SHAPE_SQUARE = 1, +}} +ENUM!{enum D2D1_ORIENTATION { + D2D1_ORIENTATION_DEFAULT = 1, + D2D1_ORIENTATION_FLIP_HORIZONTAL = 2, + D2D1_ORIENTATION_ROTATE_CLOCKWISE180 = 3, + D2D1_ORIENTATION_ROTATE_CLOCKWISE180_FLIP_HORIZONTAL = 4, + D2D1_ORIENTATION_ROTATE_CLOCKWISE90_FLIP_HORIZONTAL = 5, + D2D1_ORIENTATION_ROTATE_CLOCKWISE270 = 6, + D2D1_ORIENTATION_ROTATE_CLOCKWISE270_FLIP_HORIZONTAL = 7, + D2D1_ORIENTATION_ROTATE_CLOCKWISE90 = 8, +}} +ENUM!{enum D2D1_IMAGE_SOURCE_LOADING_OPTIONS { + D2D1_IMAGE_SOURCE_LOADING_OPTIONS_NONE = 0, + D2D1_IMAGE_SOURCE_LOADING_OPTIONS_RELEASE_SOURCE = 1, + D2D1_IMAGE_SOURCE_LOADING_OPTIONS_CACHE_ON_DEMAND = 2, +}} +ENUM!{enum D2D1_IMAGE_SOURCE_FROM_DXGI_OPTIONS { + D2D1_IMAGE_SOURCE_FROM_DXGI_OPTIONS_NONE = 0, + D2D1_IMAGE_SOURCE_FROM_DXGI_OPTIONS_LOW_QUALITY_PRIMARY_CONVERSION = 1, +}} +ENUM!{enum D2D1_TRANSFORMED_IMAGE_SOURCE_OPTIONS { + D2D1_TRANSFORMED_IMAGE_SOURCE_OPTIONS_NONE = 0, + D2D1_TRANSFORMED_IMAGE_SOURCE_OPTIONS_DISABLE_DPI_SCALE = 1, +}} +STRUCT!{struct D2D1_TRANSFORMED_IMAGE_SOURCE_PROPERTIES { + orientation: D2D1_ORIENTATION, + scaleX: FLOAT, + scaleY: FLOAT, + interpolationMode: D2D1_INTERPOLATION_MODE, + options: D2D1_TRANSFORMED_IMAGE_SOURCE_OPTIONS, +}} +STRUCT!{struct D2D1_INK_POINT { + x: FLOAT, + y: FLOAT, + radius: FLOAT, +}} +STRUCT!{struct D2D1_INK_BEZIER_SEGMENT { + point1: D2D1_INK_POINT, + point2: D2D1_INK_POINT, + point3: D2D1_INK_POINT, +}} +STRUCT!{struct D2D1_INK_STYLE_PROPERTIES { + nibShape: D2D1_INK_NIB_SHAPE, + nibTransform: D2D1_MATRIX_3X2_F, +}} +ENUM!{enum D2D1_PATCH_EDGE_MODE { + D2D1_PATCH_EDGE_MODE_ALIASED = 0, + D2D1_PATCH_EDGE_MODE_ANTIALIASED = 1, + D2D1_PATCH_EDGE_MODE_ALIASED_INFLATED = 2, +}} +STRUCT!{struct D2D1_GRADIENT_MESH_PATCH { + point00: D2D1_POINT_2F, + point01: D2D1_POINT_2F, + point02: D2D1_POINT_2F, + point03: D2D1_POINT_2F, + point10: D2D1_POINT_2F, + point11: D2D1_POINT_2F, + point12: D2D1_POINT_2F, + point13: D2D1_POINT_2F, + point20: D2D1_POINT_2F, + point21: D2D1_POINT_2F, + point22: D2D1_POINT_2F, + point23: D2D1_POINT_2F, + point30: D2D1_POINT_2F, + point31: D2D1_POINT_2F, + point32: D2D1_POINT_2F, + point33: D2D1_POINT_2F, + color00: D2D1_COLOR_F, + color03: D2D1_COLOR_F, + color30: D2D1_COLOR_F, + color33: D2D1_COLOR_F, + topEdgeMode: D2D1_PATCH_EDGE_MODE, + leftEdgeMode: D2D1_PATCH_EDGE_MODE, + bottomEdgeMode: D2D1_PATCH_EDGE_MODE, + rightEdgeMode: D2D1_PATCH_EDGE_MODE, +}} +ENUM!{enum D2D1_SPRITE_OPTIONS { + D2D1_SPRITE_OPTIONS_NONE = 0, + D2D1_SPRITE_OPTIONS_CLAMP_TO_SOURCE_RECTANGLE = 1, +}} +ENUM!{enum D2D1_COLOR_BITMAP_GLYPH_SNAP_OPTION { + D2D1_COLOR_BITMAP_GLYPH_SNAP_OPTION_DEFAULT = 0, + D2D1_COLOR_BITMAP_GLYPH_SNAP_OPTION_DISABLE = 1, +}} +ENUM!{enum D2D1_GAMMA1 { + D2D1_GAMMA1_G22 = D2D1_GAMMA_2_2, + D2D1_GAMMA1_G10 = D2D1_GAMMA_1_0, + D2D1_GAMMA1_G2084 = 2, +}} +STRUCT!{struct D2D1_SIMPLE_COLOR_PROFILE { + redPrimary: D2D1_POINT_2F, + greenPrimary: D2D1_POINT_2F, + bluePrimary: D2D1_POINT_2F, + whitePointXZ: D2D1_POINT_2F, + gamma: D2D1_GAMMA1, +}} +ENUM!{enum D2D1_COLOR_CONTEXT_TYPE { + D2D1_COLOR_CONTEXT_TYPE_ICC = 0, + D2D1_COLOR_CONTEXT_TYPE_SIMPLE = 1, + D2D1_COLOR_CONTEXT_TYPE_DXGI = 2, +}} +DEFINE_GUID!{IID_ID2D1InkStyle, + 0xbae8b344, 0x23fc, 0x4071, 0x8c, 0xb5, 0xd0, 0x5d, 0x6f, 0x07, 0x38, 0x48} +DEFINE_GUID!{IID_ID2D1Ink, + 0xb499923b, 0x7029, 0x478f, 0xa8, 0xb3, 0x43, 0x2c, 0x7c, 0x5f, 0x53, 0x12} +DEFINE_GUID!{IID_ID2D1GradientMesh, + 0xf292e401, 0xc050, 0x4cde, 0x83, 0xd7, 0x04, 0x96, 0x2d, 0x3b, 0x23, 0xc2} +DEFINE_GUID!{IID_ID2D1ImageSource, + 0xc9b664e5, 0x74a1, 0x4378, 0x9a, 0xc2, 0xee, 0xfc, 0x37, 0xa3, 0xf4, 0xd8} +DEFINE_GUID!{IID_ID2D1ImageSourceFromWic, + 0x77395441, 0x1c8f, 0x4555, 0x86, 0x83, 0xf5, 0x0d, 0xab, 0x0f, 0xe7, 0x92} +DEFINE_GUID!{IID_ID2D1TransformedImageSource, + 0x7f1f79e5, 0x2796, 0x416c, 0x8f, 0x55, 0x70, 0x0f, 0x91, 0x14, 0x45, 0xe5} +DEFINE_GUID!{IID_ID2D1LookupTable3D, + 0x53dd9855, 0xa3b0, 0x4d5b, 0x82, 0xe1, 0x26, 0xe2, 0x5c, 0x5e, 0x57, 0x97} +DEFINE_GUID!{IID_ID2D1DeviceContext2, + 0x394ea6a3, 0x0c34, 0x4321, 0x95, 0x0b, 0x6c, 0xa2, 0x0f, 0x0b, 0xe6, 0xc7} +DEFINE_GUID!{IID_ID2D1Device2, + 0xa44472e1, 0x8dfb, 0x4e60, 0x84, 0x92, 0x6e, 0x28, 0x61, 0xc9, 0xca, 0x8b} +DEFINE_GUID!{IID_ID2D1Factory3, + 0x0869759f, 0x4f00, 0x413f, 0xb0, 0x3e, 0x2b, 0xda, 0x45, 0x40, 0x4d, 0x0f} +DEFINE_GUID!{IID_ID2D1CommandSink2, + 0x3bab440e, 0x417e, 0x47df, 0xa2, 0xe2, 0xbc, 0x0b, 0xe6, 0xa0, 0x09, 0x16} +DEFINE_GUID!{IID_ID2D1GdiMetafile1, + 0x2e69f9e8, 0xdd3f, 0x4bf9, 0x95, 0xba, 0xc0, 0x4f, 0x49, 0xd7, 0x88, 0xdf} +DEFINE_GUID!{IID_ID2D1GdiMetafileSink1, + 0xfd0ecb6b, 0x91e6, 0x411e, 0x86, 0x55, 0x39, 0x5e, 0x76, 0x0f, 0x91, 0xb4} +DEFINE_GUID!{IID_ID2D1SpriteBatch, + 0x4dc583bf, 0x3a10, 0x438a, 0x87, 0x22, 0xe9, 0x76, 0x52, 0x24, 0xf1, 0xf1} +DEFINE_GUID!{IID_ID2D1DeviceContext3, + 0x235a7496, 0x8351, 0x414c, 0xbc, 0xd4, 0x66, 0x72, 0xab, 0x2d, 0x8e, 0x00} +DEFINE_GUID!{IID_ID2D1Device3, + 0x852f2087, 0x802c, 0x4037, 0xab, 0x60, 0xff, 0x2e, 0x7e, 0xe6, 0xfc, 0x01} +DEFINE_GUID!{IID_ID2D1Factory4, + 0xbd4ec2d2, 0x0662, 0x4bee, 0xba, 0x8e, 0x6f, 0x29, 0xf0, 0x32, 0xe0, 0x96} +DEFINE_GUID!{IID_ID2D1CommandSink3, + 0x18079135, 0x4cf3, 0x4868, 0xbc, 0x8e, 0x06, 0x06, 0x7e, 0x6d, 0x24, 0x2d} +DEFINE_GUID!{IID_ID2D1SvgGlyphStyle, + 0xaf671749, 0xd241, 0x4db8, 0x8e, 0x41, 0xdc, 0xc2, 0xe5, 0xc1, 0xa4, 0x38} +DEFINE_GUID!{IID_ID2D1DeviceContext4, + 0x8c427831, 0x3d90, 0x4476, 0xb6, 0x47, 0xc4, 0xfa, 0xe3, 0x49, 0xe4, 0xdb} +DEFINE_GUID!{IID_ID2D1Device4, + 0xd7bdb159, 0x5683, 0x4a46, 0xbc, 0x9c, 0x72, 0xdc, 0x72, 0x0b, 0x85, 0x8b} +DEFINE_GUID!{IID_ID2D1Factory5, + 0xc4349994, 0x838e, 0x4b0f, 0x8c, 0xab, 0x44, 0x99, 0x7d, 0x9e, 0xea, 0xcc} +DEFINE_GUID!{IID_ID2D1CommandSink4, + 0xc78a6519, 0x40d6, 0x4218, 0xb2, 0xde, 0xbe, 0xee, 0xb7, 0x44, 0xbb, 0x3e} +DEFINE_GUID!{IID_ID2D1ColorContext1, + 0x1ab42875, 0xc57f, 0x4be9, 0xbd, 0x85, 0x9c, 0xd7, 0x8d, 0x6f, 0x55, 0xee} +DEFINE_GUID!{IID_ID2D1DeviceContext5, + 0x7836d248, 0x68cc, 0x4df6, 0xb9, 0xe8, 0xde, 0x99, 0x1b, 0xf6, 0x2e, 0xb7} +DEFINE_GUID!{IID_ID2D1Device5, + 0xd55ba0a4, 0x6405, 0x4694, 0xae, 0xf5, 0x08, 0xee, 0x1a, 0x43, 0x58, 0xb4} +DEFINE_GUID!{IID_ID2D1Factory6, + 0xf9976f46, 0xf642, 0x44c1, 0x97, 0xca, 0xda, 0x32, 0xea, 0x2a, 0x26, 0x35} +DEFINE_GUID!{IID_ID2D1CommandSink5, + 0x7047dd26, 0xb1e7, 0x44a7, 0x95, 0x9a, 0x83, 0x49, 0xe2, 0x14, 0x4f, 0xa8} +DEFINE_GUID!{IID_ID2D1DeviceContext6, + 0x985f7e37, 0x4ed0, 0x4a19, 0x98, 0xa3, 0x15, 0xb0, 0xed, 0xfd, 0xe3, 0x06} +DEFINE_GUID!{IID_ID2D1Device6, + 0x7bfef914, 0x2d75, 0x4bad, 0xbe, 0x87, 0xe1, 0x8d, 0xdb, 0x07, 0x7b, 0x6d} +DEFINE_GUID!{IID_ID2D1Factory7, + 0xbdc2bdd3, 0xb96c, 0x4de6, 0xbd, 0xf7, 0x99, 0xd4, 0x74, 0x54, 0x54, 0xde} +RIDL!{#[uuid(0xbae8b344, 0x23fc, 0x4071, 0x8c, 0xb5, 0xd0, 0x5d, 0x6f, 0x07, 0x38, 0x48)] +interface ID2D1InkStyle(ID2D1InkStyleVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn SetNibTransform( + transform: *const D2D1_MATRIX_3X2_F, + ) -> (), + fn GetNibTransform( + transform: *mut D2D1_MATRIX_3X2_F, + ) -> (), + fn SetNibShape( + nibShape: D2D1_INK_NIB_SHAPE, + ) -> (), + fn GetNibShape() -> D2D1_INK_NIB_SHAPE, +}} +RIDL!{#[uuid(0xb499923b, 0x7029, 0x478f, 0xa8, 0xb3, 0x43, 0x2c, 0x7c, 0x5f, 0x53, 0x12)] +interface ID2D1Ink(ID2D1InkVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn SetStartPoint( + startPoint: *const D2D1_INK_POINT, + ) -> (), + fn GetStartPoint() -> D2D1_INK_POINT, + fn AddSegments( + segments: *const D2D1_INK_BEZIER_SEGMENT, + segmentsCount: UINT32, + ) -> HRESULT, + fn RemoveSegmentsAtEnd( + segmentsCount: UINT32, + ) -> HRESULT, + fn SetSegments( + startSegment: UINT32, + segments: *const D2D1_INK_BEZIER_SEGMENT, + segmentsCount: UINT32, + ) -> HRESULT, + fn SetSegmentAtEnd( + segment: *const D2D1_INK_BEZIER_SEGMENT, + ) -> HRESULT, + fn GetSegmentCount() -> UINT32, + fn GetSegments( + startSegment: UINT32, + segments: *mut D2D1_INK_BEZIER_SEGMENT, + segmentsCount: UINT32, + ) -> HRESULT, + fn StreamAsGeometry( + inkStyle: *mut ID2D1InkStyle, + worldTransform: *const D2D1_MATRIX_3X2_F, + flatteningTolerance: FLOAT, + geometrySink: *mut ID2D1SimplifiedGeometrySink, + ) -> HRESULT, + fn GetBounds( + inkStyle: *mut ID2D1InkStyle, + worldTransform: *const D2D1_MATRIX_3X2_F, + bounds: *mut D2D1_RECT_F, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf292e401, 0xc050, 0x4cde, 0x83, 0xd7, 0x04, 0x96, 0x2d, 0x3b, 0x23, 0xc2)] +interface ID2D1GradientMesh(ID2D1GradientMeshVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn GetPatchCount() -> UINT32, + fn GetPatches( + startIndex: UINT32, + patches: *mut D2D1_GRADIENT_MESH_PATCH, + patchesCount: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc9b664e5, 0x74a1, 0x4378, 0x9a, 0xc2, 0xee, 0xfc, 0x37, 0xa3, 0xf4, 0xd8)] +interface ID2D1ImageSource(ID2D1ImageSourceVtbl): ID2D1Image(ID2D1ImageVtbl) { + fn OfferResources() -> HRESULT, + fn TryReclaimResources( + resourcesDiscarded: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x77395441, 0x1c8f, 0x4555, 0x86, 0x83, 0xf5, 0x0d, 0xab, 0x0f, 0xe7, 0x92)] +interface ID2D1ImageSourceFromWic(ID2D1ImageSourceFromWicVtbl): + ID2D1ImageSource(ID2D1ImageSourceVtbl) { + fn EnsureCached( + rectangleToFill: *const D2D1_RECT_U, + ) -> HRESULT, + fn TrimCache( + rectangleToPreserve: *const D2D1_RECT_U, + ) -> HRESULT, + fn GetSource( + wicBitmapSource: *mut *mut IWICBitmapSource, + ) -> (), +}} +RIDL!{#[uuid(0x7f1f79e5, 0x2796, 0x416c, 0x8f, 0x55, 0x70, 0x0f, 0x91, 0x14, 0x45, 0xe5)] +interface ID2D1TransformedImageSource(ID2D1TransformedImageSourceVtbl): + ID2D1Image(ID2D1ImageVtbl) { + fn GetSource( + imageSource: *mut *mut ID2D1ImageSource, + ) -> (), + fn GetProperties( + properties: *mut D2D1_TRANSFORMED_IMAGE_SOURCE_PROPERTIES, + ) -> (), +}} +RIDL!{#[uuid(0x53dd9855, 0xa3b0, 0x4d5b, 0x82, 0xe1, 0x26, 0xe2, 0x5c, 0x5e, 0x57, 0x97)] +interface ID2D1LookupTable3D(ID2D1LookupTable3DVtbl): ID2D1Resource(ID2D1ResourceVtbl) {}} +RIDL!{#[uuid(0x394ea6a3, 0x0c34, 0x4321, 0x95, 0x0b, 0x6c, 0xa2, 0x0f, 0x0b, 0xe6, 0xc7)] +interface ID2D1DeviceContext2(ID2D1DeviceContext2Vtbl): + ID2D1DeviceContext1(ID2D1DeviceContext1Vtbl) { + fn CreateInk( + startPoint: *const D2D1_INK_POINT, + ink: *mut *mut ID2D1Ink, + ) -> HRESULT, + fn CreateInkStyle( + inkStyleProperties: *const D2D1_INK_STYLE_PROPERTIES, + inkStyle: *mut *mut ID2D1InkStyle, + ) -> HRESULT, + fn CreateGradientMesh( + patches: *const D2D1_GRADIENT_MESH_PATCH, + patchesCount: UINT32, + gradientMesh: *mut *mut ID2D1GradientMesh, + ) -> HRESULT, + fn CreateImageSourceFromWic( + wicBitmapSource: *mut IWICBitmapSource, + loadingOptions: D2D1_IMAGE_SOURCE_LOADING_OPTIONS, + alphaMode: D2D1_ALPHA_MODE, + imageSource: *mut *mut ID2D1ImageSourceFromWic, + ) -> HRESULT, + fn CreateLookupTable3D( + precision: D2D1_BUFFER_PRECISION, + extents: *const UINT32, + data: *const BYTE, + dataCount: UINT32, + strides: *const UINT32, + lookupTable: *mut *mut ID2D1LookupTable3D, + ) -> HRESULT, + fn CreateImageSourceFromDxgi( + surfaces: *const *mut IDXGISurface, + surfaceCount: UINT32, + colorSpace: DXGI_COLOR_SPACE_TYPE, + options: D2D1_IMAGE_SOURCE_FROM_DXGI_OPTIONS, + imageSource: *mut *mut ID2D1ImageSource, + ) -> HRESULT, + fn GetGradientMeshWorldBounds( + gradientMesh: *mut ID2D1GradientMesh, + pBounds: *mut D2D1_RECT_F, + ) -> HRESULT, + fn DrawInk( + ink: *mut ID2D1Ink, + brush: *mut ID2D1Brush, + inkStyle: *mut ID2D1InkStyle, + ) -> (), + fn DrawGradientMesh( + gradientMesh: *mut ID2D1GradientMesh, + ) -> (), + fn DrawGdiMetafile( + gdiMetafile: *mut ID2D1GdiMetafile, + destinationRectangle: *const D2D1_RECT_F, + sourceRectangle: *const D2D1_RECT_F, + ) -> (), + fn CreateTransformedImageSource( + imageSource: *mut ID2D1ImageSource, + properties: *const D2D1_TRANSFORMED_IMAGE_SOURCE_PROPERTIES, + transformedImageSource: *mut *mut ID2D1TransformedImageSource, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa44472e1, 0x8dfb, 0x4e60, 0x84, 0x92, 0x6e, 0x28, 0x61, 0xc9, 0xca, 0x8b)] +interface ID2D1Device2(ID2D1Device2Vtbl): ID2D1Device1(ID2D1Device1Vtbl) { + fn CreateDeviceContext( + options: D2D1_DEVICE_CONTEXT_OPTIONS, + deviceContext2: *mut *mut ID2D1DeviceContext2, + ) -> HRESULT, + fn FlushDeviceContexts( + bitmap: *mut ID2D1Bitmap, + ) -> (), + fn GetDxgiDevice( + dxgiDevice: *mut *mut IDXGIDevice, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0869759f, 0x4f00, 0x413f, 0xb0, 0x3e, 0x2b, 0xda, 0x45, 0x40, 0x4d, 0x0f)] +interface ID2D1Factory3(ID2D1Factory3Vtbl): ID2D1Factory2(ID2D1Factory2Vtbl) { + fn CreateDevice( + dxgiDevice: *mut IDXGIDevice, + d2dDevice2: *mut *mut ID2D1Device2, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3bab440e, 0x417e, 0x47df, 0xa2, 0xe2, 0xbc, 0x0b, 0xe6, 0xa0, 0x09, 0x16)] +interface ID2D1CommandSink2(ID2D1CommandSink2Vtbl): ID2D1CommandSink1(ID2D1CommandSink1Vtbl) { + fn DrawInk( + ink: *mut ID2D1Ink, + brush: *mut ID2D1Brush, + inkStyle: *mut ID2D1InkStyle, + ) -> (), + fn DrawGradientMesh( + gradientMesh: *mut ID2D1GradientMesh, + ) -> (), + fn DrawGdiMetafile( + gdiMetafile: *mut ID2D1GdiMetafile, + destinationRectangle: *const D2D1_RECT_F, + sourceRectangle: *const D2D1_RECT_F, + ) -> (), +}} +RIDL!{#[uuid(0x2e69f9e8, 0xdd3f, 0x4bf9, 0x95, 0xba, 0xc0, 0x4f, 0x49, 0xd7, 0x88, 0xdf)] +interface ID2D1GdiMetafile1(ID2D1GdiMetafile1Vtbl): ID2D1GdiMetafile(ID2D1GdiMetafileVtbl) { + fn GetDpi( + dpiX: *mut FLOAT, + dpiY: *mut FLOAT, + ) -> HRESULT, + fn GetSourceBounds( + bounds: *mut D2D1_RECT_F, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xfd0ecb6b, 0x91e6, 0x411e, 0x86, 0x55, 0x39, 0x5e, 0x76, 0x0f, 0x91, 0xb4)] +interface ID2D1GdiMetafileSink1(ID2D1GdiMetafileSink1Vtbl): + ID2D1GdiMetafileSink(ID2D1GdiMetafileSinkVtbl) { + fn ProcessRecord( + recordType: DWORD, + recordData: *const c_void, + recordDataSize: DWORD, + flags: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4dc583bf, 0x3a10, 0x438a, 0x87, 0x22, 0xe9, 0x76, 0x52, 0x24, 0xf1, 0xf1)] +interface ID2D1SpriteBatch(ID2D1SpriteBatchVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn AddSprites( + spriteCount: UINT32, + destinationRectangle: *const D2D1_RECT_F, + sourceRectangles: *const D2D1_RECT_U, + colors: *const D2D1_COLOR_F, + transforms: *const D2D1_MATRIX_3X2_F, + destinationRectanglesStride: UINT32, + sourceRectanglesStride: UINT32, + colorsStride: UINT32, + transformsStride: D2D1_MATRIX_3X2_F, + ) -> HRESULT, + fn SetSprites( + startIndex: UINT32, + spriteCount: UINT32, + destinationRectangle: *const D2D1_RECT_F, + sourceRectangles: *const D2D1_RECT_U, + colors: *const D2D1_COLOR_F, + transforms: *const D2D1_MATRIX_3X2_F, + destinationRectanglesStride: UINT32, + sourceRectanglesStride: UINT32, + colorsStride: UINT32, + transformsStride: D2D1_MATRIX_3X2_F, + ) -> HRESULT, + fn GetSprites( + startIndex: UINT32, + spriteCount: UINT32, + destinationRectangle: *mut D2D1_RECT_F, + sourceRectangles: *mut D2D1_RECT_U, + colors: *mut D2D1_COLOR_F, + transforms: *mut D2D1_MATRIX_3X2_F, + ) -> HRESULT, + fn GetSpriteCount() -> UINT32, + fn Clear() -> (), +}} +RIDL!{#[uuid(0x235a7496, 0x8351, 0x414c, 0xbc, 0xd4, 0x66, 0x72, 0xab, 0x2d, 0x8e, 0x00)] +interface ID2D1DeviceContext3(ID2D1DeviceContext3Vtbl): + ID2D1DeviceContext2(ID2D1DeviceContext2Vtbl) { + fn CreateSpriteBatch( + spriteBatch: *mut *mut ID2D1SpriteBatch, + ) -> HRESULT, + fn DrawSpriteBatch( + spriteBatch: *mut ID2D1SpriteBatch, + startIndex: UINT32, + spriteCount: UINT32, + bitmap: *mut ID2D1Bitmap, + interpolationMode: D2D1_BITMAP_INTERPOLATION_MODE, + spriteOptions: D2D1_SPRITE_OPTIONS, + ) -> (), +}} +RIDL!{#[uuid(0x852f2087, 0x802c, 0x4037, 0xab, 0x60, 0xff, 0x2e, 0x7e, 0xe6, 0xfc, 0x01)] +interface ID2D1Device3(ID2D1Device3Vtbl): ID2D1Device2(ID2D1Device2Vtbl) { + fn CreateDeviceContext( + options: D2D1_DEVICE_CONTEXT_OPTIONS, + deviceContext3: *mut *mut ID2D1DeviceContext3, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xbd4ec2d2, 0x0662, 0x4bee, 0xba, 0x8e, 0x6f, 0x29, 0xf0, 0x32, 0xe0, 0x96)] +interface ID2D1Factory4(ID2D1Factory4Vtbl): ID2D1Factory3(ID2D1Factory3Vtbl) { + fn CreateDevice( + dxgiDevice: *mut IDXGIDevice, + d2dDevice3: *mut *mut ID2D1Device3, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x18079135, 0x4cf3, 0x4868, 0xbc, 0x8e, 0x06, 0x06, 0x7e, 0x6d, 0x24, 0x2d)] +interface ID2D1CommandSink3(ID2D1CommandSink3Vtbl): ID2D1CommandSink2(ID2D1CommandSink2Vtbl) { + fn DrawSpriteBatch( + spriteBatch: *mut ID2D1SpriteBatch, + startIndex: UINT32, + spriteCount: UINT32, + bitmap: *mut ID2D1Bitmap, + interpolationMode: D2D1_BITMAP_INTERPOLATION_MODE, + spriteOptions: D2D1_SPRITE_OPTIONS, + ) -> (), +}} +RIDL!{#[uuid(0xaf671749, 0xd241, 0x4db8, 0x8e, 0x41, 0xdc, 0xc2, 0xe5, 0xc1, 0xa4, 0x38)] +interface ID2D1SvgGlyphStyle(ID2D1SvgGlyphStyleVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn SetFill( + brush: *mut ID2D1Brush, + ) -> HRESULT, + fn GetFill( + brush: *mut *mut ID2D1Brush, + ) -> (), + fn SetStroke( + brush: *mut ID2D1Brush, + strokeWidth: FLOAT, + dashes: *const FLOAT, + dashesCount: UINT32, + dashOffset: FLOAT, + ) -> HRESULT, + fn GetStrokeDashesCount() -> UINT32, + fn GetStroke( + brush: *mut *mut ID2D1Brush, + strokeWidth: *mut FLOAT, + dashes: *mut FLOAT, + dashesCount: UINT32, + dashOffset: *mut FLOAT, + ) -> (), +}} +RIDL!{#[uuid(0x8c427831, 0x3d90, 0x4476, 0xb6, 0x47, 0xc4, 0xfa, 0xe3, 0x49, 0xe4, 0xdb)] +interface ID2D1DeviceContext4(ID2D1DeviceContext4Vtbl): + ID2D1DeviceContext3(ID2D1DeviceContext3Vtbl) { + fn CreateSvgGlyphStyle( + svgGlyphStyle: *mut *mut ID2D1SvgGlyphStyle, + ) -> HRESULT, + fn DrawText( + string: *const WCHAR, + stringLength: UINT32, + textFormat: *mut IDWriteTextFormat, + layoutRect: *const D2D1_RECT_F, + defaultFillBrush: *mut ID2D1Brush, + svgGlyphStyle: *mut ID2D1SvgGlyphStyle, + colorPaletteIndex: UINT32, + options: D2D1_DRAW_TEXT_OPTIONS, + measuringMode: DWRITE_MEASURING_MODE, + ) -> (), + fn DrawTextLayout( + origin: D2D1_POINT_2F, + textLayout: *mut IDWriteTextLayout, + defaultFillBrush: *mut ID2D1Brush, + svgGlyphStyle: *mut ID2D1SvgGlyphStyle, + colorPaletteIndex: UINT32, + options: D2D1_DRAW_TEXT_OPTIONS, + ) -> (), + fn DrawColorBitmapGlyphRun( + glyphImageFormat: DWRITE_GLYPH_IMAGE_FORMATS, + baselineOrigin: D2D1_POINT_2F, + glyphRun: *const DWRITE_GLYPH_RUN, + measuringMode: DWRITE_MEASURING_MODE, + bitmapSnapOption: D2D1_COLOR_BITMAP_GLYPH_SNAP_OPTION, + ) -> (), + fn DrawSvgGlyphRun( + baselineOrigin: D2D1_POINT_2F, + glyphRun: *const DWRITE_GLYPH_RUN, + defaultFillBrush: *mut ID2D1Brush, + svgGlyphStyle: *mut ID2D1SvgGlyphStyle, + colorPaletteIndex: UINT32, + measuringMode: DWRITE_MEASURING_MODE, + ) -> (), + fn GetColorBitmapGlyphImage( + glyphImageFormat: DWRITE_GLYPH_IMAGE_FORMATS, + glyphOrigin: D2D1_POINT_2F, + fontFace: *mut IDWriteFontFace, + fontEmSize: FLOAT, + glyphIndex: UINT16, + isSideways: BOOL, + worldTransform: *const D2D1_MATRIX_3X2_F, + dpiX: FLOAT, + dpiY: FLOAT, + glyphTransform: *mut D2D1_MATRIX_3X2_F, + glyphImage: *mut *mut ID2D1Image, + ) -> HRESULT, + fn GetSvgGlyphImage( + glyphImageFormat: DWRITE_GLYPH_IMAGE_FORMATS, + glyphOrigin: D2D1_POINT_2F, + fontFace: *mut IDWriteFontFace, + fontEmSize: FLOAT, + glyphIndex: UINT16, + isSideways: BOOL, + worldTransform: *const D2D1_MATRIX_3X2_F, + defaultFillBrush: *mut ID2D1Brush, + svgGlyphStyle: *mut ID2D1SvgGlyphStyle, + colorPaletteIndex: UINT32, + glyphTransform: *mut D2D1_MATRIX_3X2_F, + glyphImage: *mut *mut ID2D1CommandList, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd7bdb159, 0x5683, 0x4a46, 0xbc, 0x9c, 0x72, 0xdc, 0x72, 0x0b, 0x85, 0x8b)] +interface ID2D1Device4(ID2D1Device4Vtbl): ID2D1Device3(ID2D1Device3Vtbl) { + fn CreateDeviceContext( + options: D2D1_DEVICE_CONTEXT_OPTIONS, + deviceContext4: *mut *mut ID2D1DeviceContext4, + ) -> HRESULT, + fn SetMaximumColorGlyphCacheMemory( + maximumInBytes: UINT64, + ) -> (), + fn GetMaximumColorGlyphCacheMemory() -> UINT64, +}} +RIDL!{#[uuid(0xc4349994, 0x838e, 0x4b0f, 0x8c, 0xab, 0x44, 0x99, 0x7d, 0x9e, 0xea, 0xcc)] +interface ID2D1Factory5(ID2D1Factory5Vtbl): ID2D1Factory4(ID2D1Factory4Vtbl) { + fn CreateDevice( + dxgiDevice: *mut IDXGIDevice, + d2dDevice4: *mut *mut ID2D1Device4, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc78a6519, 0x40d6, 0x4218, 0xb2, 0xde, 0xbe, 0xee, 0xb7, 0x44, 0xbb, 0x3e)] +interface ID2D1CommandSink4(ID2D1CommandSink4Vtbl): ID2D1CommandSink3(ID2D1CommandSink3Vtbl) { + fn SetPrimitiveBlend2( + primitiveBlend: D2D1_PRIMITIVE_BLEND, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1ab42875, 0xc57f, 0x4be9, 0xbd, 0x85, 0x9c, 0xd7, 0x8d, 0x6f, 0x55, 0xee)] +interface ID2D1ColorContext1(ID2D1ColorContext1Vtbl): ID2D1ColorContext(ID2D1ColorContextVtbl) { + fn GetColorContextType() -> D2D1_COLOR_CONTEXT_TYPE, + fn GetDXGIColorSpace() -> DXGI_COLOR_SPACE_TYPE, + fn GetSimpleColorProfile( + simpleProfile: *mut D2D1_SIMPLE_COLOR_PROFILE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7836d248, 0x68cc, 0x4df6, 0xb9, 0xe8, 0xde, 0x99, 0x1b, 0xf6, 0x2e, 0xb7)] +interface ID2D1DeviceContext5(ID2D1DeviceContext5Vtbl): + ID2D1DeviceContext4(ID2D1DeviceContext4Vtbl) { + fn CreateSvgDocument( + inputXmlStream: *mut IStream, + viewportSize: D2D1_SIZE_F, + svgDocument: *mut *mut ID2D1SvgDocument, + ) -> HRESULT, + fn DrawSvgDocument( + svgDocument: *mut ID2D1SvgDocument, + ) -> (), + fn CreateColorContextFromDxgiColorSpace( + colorSpace: DXGI_COLOR_SPACE_TYPE, + colorContext: *mut *mut ID2D1ColorContext1, + ) -> HRESULT, + fn CreateColorContextFromSimpleColorProfile( + simpleProfile: *const D2D1_SIMPLE_COLOR_PROFILE, + colorContext: *mut *mut ID2D1ColorContext1, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd55ba0a4, 0x6405, 0x4694, 0xae, 0xf5, 0x08, 0xee, 0x1a, 0x43, 0x58, 0xb4)] +interface ID2D1Device5(ID2D1Device5Vtbl): ID2D1Device4(ID2D1Device4Vtbl) { + fn CreateDeviceContext( + options: D2D1_DEVICE_CONTEXT_OPTIONS, + deviceContext5: *mut *mut ID2D1DeviceContext5, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf9976f46, 0xf642, 0x44c1, 0x97, 0xca, 0xda, 0x32, 0xea, 0x2a, 0x26, 0x35)] +interface ID2D1Factory6(ID2D1Factory6Vtbl): ID2D1Factory5(ID2D1Factory5Vtbl) { + fn CreateDevice( + dxgiDevice: *mut IDXGIDevice, + d2dDevice5: *mut *mut ID2D1Device5, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7047dd26, 0xb1e7, 0x44a7, 0x95, 0x9a, 0x83, 0x49, 0xe2, 0x14, 0x4f, 0xa8)] +interface ID2D1CommandSink5(ID2D1CommandSink5Vtbl): ID2D1CommandSink4(ID2D1CommandSink4Vtbl) { + fn BlendImage( + image: *mut ID2D1Image, + blendMode: D2D1_BLEND_MODE, + targetOffset: *const D2D1_POINT_2F, + imageRectangle: *const D2D1_RECT_F, + interpolationMode: D2D1_INTERPOLATION_MODE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x985f7e37, 0x4ed0, 0x4a19, 0x98, 0xa3, 0x15, 0xb0, 0xed, 0xfd, 0xe3, 0x06)] +interface ID2D1DeviceContext6(ID2D1DeviceContext6Vtbl): + ID2D1DeviceContext5(ID2D1DeviceContext5Vtbl) { + fn BlendImage( + image: *mut ID2D1Image, + blendMode: D2D1_BLEND_MODE, + targetOffset: *const D2D1_POINT_2F, + imageRectangle: *const D2D1_RECT_F, + interpolationMode: D2D1_INTERPOLATION_MODE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7bfef914, 0x2d75, 0x4bad, 0xbe, 0x87, 0xe1, 0x8d, 0xdb, 0x07, 0x7b, 0x6d)] +interface ID2D1Device6(ID2D1Device6Vtbl): ID2D1Device5(ID2D1Device5Vtbl) { + fn CreateDeviceContext( + options: D2D1_DEVICE_CONTEXT_OPTIONS, + deviceContext6: *mut *mut ID2D1DeviceContext6, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xbdc2bdd3, 0xb96c, 0x4de6, 0xbd, 0xf7, 0x99, 0xd4, 0x74, 0x54, 0x54, 0xde)] +interface ID2D1Factory7(ID2D1Factory7Vtbl): ID2D1Factory6(ID2D1Factory6Vtbl) { + fn CreateDevice( + dxgiDevice: *mut IDXGIDevice, + d2dDevice6: *mut *mut ID2D1Device6, + ) -> HRESULT, +}} +extern "system" { + pub fn D2D1GetGradientMeshInteriorPointsFromCoonsPatch( + pPoint0: *const D2D1_POINT_2F, + pPoint1: *const D2D1_POINT_2F, + pPoint2: *const D2D1_POINT_2F, + pPoint3: *const D2D1_POINT_2F, + pPoint4: *const D2D1_POINT_2F, + pPoint5: *const D2D1_POINT_2F, + pPoint6: *const D2D1_POINT_2F, + pPoint7: *const D2D1_POINT_2F, + pPoint8: *const D2D1_POINT_2F, + pPoint9: *const D2D1_POINT_2F, + pPoint10: *const D2D1_POINT_2F, + pPoint11: *const D2D1_POINT_2F, + pTensorPoint11: *mut D2D1_POINT_2F, + pTensorPoint12: *mut D2D1_POINT_2F, + pTensorPoint21: *mut D2D1_POINT_2F, + pTensorPoint22: *mut D2D1_POINT_2F, + ); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effectauthor.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effectauthor.rs new file mode 100644 index 0000000..c832279 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effectauthor.rs @@ -0,0 +1,516 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_void; +use shared::basetsd::UINT32; +use shared::dxgiformat::DXGI_FORMAT; +use shared::guiddef::{GUID, REFCLSID, REFGUID}; +use shared::minwindef::{BOOL, BYTE, FLOAT}; +use shared::ntdef::{HRESULT, PCSTR, PCWSTR}; +use um::d2d1::D2D1_EXTEND_MODE; +use um::d2d1_1::{ + D2D1_BUFFER_PRECISION, D2D1_COLOR_SPACE, ID2D1Bitmap1, ID2D1ColorContext, ID2D1Effect, +}; +use um::d2dbasetypes::{D2D_POINT_2L, D2D_POINT_2U, D2D_RECT_L}; +use um::d3dcommon::D3D_FEATURE_LEVEL; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::wincodec::IWICColorContext; +FN!{stdcall PD2D1_PROPERTY_SET_FUNCTION( + effect: *const IUnknown, + data: *const BYTE, + dataSize: UINT32, +) -> HRESULT} +FN!{stdcall PD2D1_PROPERTY_GET_FUNCTION( + effect: *const IUnknown, + data: *mut BYTE, + dataSize: UINT32, + actualSize: *mut UINT32, +) -> HRESULT} +ENUM!{enum D2D1_CHANGE_TYPE { + D2D1_CHANGE_TYPE_NONE = 0, + D2D1_CHANGE_TYPE_PROPERTIES = 1, + D2D1_CHANGE_TYPE_CONTEXT = 2, + D2D1_CHANGE_TYPE_GRAPH = 3, +}} +ENUM!{enum D2D1_PIXEL_OPTIONS { + D2D1_PIXEL_OPTIONS_NONE = 0, + D2D1_PIXEL_OPTIONS_TRIVIAL_SAMPLING = 1, +}} +ENUM!{enum D2D1_VERTEX_OPTIONS { + D2D1_VERTEX_OPTIONS_NONE = 0, + D2D1_VERTEX_OPTIONS_DO_NOT_CLEAR = 1, + D2D1_VERTEX_OPTIONS_USE_DEPTH_BUFFER = 2, + D2D1_VERTEX_OPTIONS_ASSUME_NO_OVERLAP = 4, +}} +ENUM!{enum D2D1_VERTEX_USAGE { + D2D1_VERTEX_USAGE_STATIC = 0, + D2D1_VERTEX_USAGE_DYNAMIC = 1, +}} +ENUM!{enum D2D1_BLEND_OPERATION { + D2D1_BLEND_OPERATION_ADD = 1, + D2D1_BLEND_OPERATION_SUBTRACT = 2, + D2D1_BLEND_OPERATION_REV_SUBTRACT = 3, + D2D1_BLEND_OPERATION_MIN = 4, + D2D1_BLEND_OPERATION_MAX = 5, +}} +ENUM!{enum D2D1_BLEND { + D2D1_BLEND_ZERO = 1, + D2D1_BLEND_ONE = 2, + D2D1_BLEND_SRC_COLOR = 3, + D2D1_BLEND_INV_SRC_COLOR = 4, + D2D1_BLEND_SRC_ALPHA = 5, + D2D1_BLEND_INV_SRC_ALPHA = 6, + D2D1_BLEND_DEST_ALPHA = 7, + D2D1_BLEND_INV_DEST_ALPHA = 8, + D2D1_BLEND_DEST_COLOR = 9, + D2D1_BLEND_INV_DEST_COLOR = 10, + D2D1_BLEND_SRC_ALPHA_SAT = 11, + D2D1_BLEND_BLEND_FACTOR = 14, + D2D1_BLEND_INV_BLEND_FACTOR = 15, +}} +ENUM!{enum D2D1_CHANNEL_DEPTH { + D2D1_CHANNEL_DEPTH_DEFAULT = 0, + D2D1_CHANNEL_DEPTH_1 = 1, + D2D1_CHANNEL_DEPTH_4 = 4, +}} +ENUM!{enum D2D1_FILTER { + D2D1_FILTER_MIN_MAG_MIP_POINT = 0x00, + D2D1_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x01, + D2D1_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x04, + D2D1_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x05, + D2D1_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, + D2D1_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, + D2D1_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, + D2D1_FILTER_MIN_MAG_MIP_LINEAR = 0x15, + D2D1_FILTER_ANISOTROPIC = 0x55, +}} +ENUM!{enum D2D1_FEATURE { + D2D1_FEATURE_DOUBLES = 0, + D2D1_FEATURE_D3D10_X_HARDWARE_OPTIONS = 1, +}} +STRUCT!{struct D2D1_PROPERTY_BINDING { + propertyName: PCWSTR, + setFunction: PD2D1_PROPERTY_SET_FUNCTION, + getFunction: PD2D1_PROPERTY_GET_FUNCTION, +}} +STRUCT!{struct D2D1_RESOURCE_TEXTURE_PROPERTIES { + extents: *const UINT32, + dimensions: UINT32, + bufferPrecision: D2D1_BUFFER_PRECISION, + channelDepth: D2D1_CHANNEL_DEPTH, + filter: D2D1_FILTER, + extendModes: *const D2D1_EXTEND_MODE, +}} +STRUCT!{struct D2D1_INPUT_ELEMENT_DESC { + semanticName: PCSTR, + semanticIndex: UINT32, + format: DXGI_FORMAT, + inputSlot: UINT32, + alignedByteOffset: UINT32, +}} +pub const D2D1_APPEND_ALIGNED_ELEMENT: UINT32 = 0xffffffff; +STRUCT!{struct D2D1_VERTEX_BUFFER_PROPERTIES { + inputCount: UINT32, + usage: D2D1_VERTEX_USAGE, + data: *const BYTE, + byteWidth: UINT32, +}} +STRUCT!{struct D2D1_CUSTOM_VERTEX_BUFFER_PROPERTIES { + shaderBufferWithInputSignature: *const BYTE, + shaderBufferSize: UINT32, + inputElements: *const D2D1_INPUT_ELEMENT_DESC, + elementCount: UINT32, + stride: UINT32, +}} +STRUCT!{struct D2D1_VERTEX_RANGE { + startVertex: UINT32, + vertexCount: UINT32, +}} +STRUCT!{struct D2D1_BLEND_DESCRIPTION { + sourceBlend: D2D1_BLEND, + destinationBlend: D2D1_BLEND, + blendOperation: D2D1_BLEND_OPERATION, + sourceBlendAlpha: D2D1_BLEND, + destinationBlendAlpha: D2D1_BLEND, + blendOperationAlpha: D2D1_BLEND_OPERATION, + blendFactor: [FLOAT; 4], +}} +STRUCT!{struct D2D1_INPUT_DESCRIPTION { + filter: D2D1_FILTER, + leveOfDetailCount: UINT32, +}} +STRUCT!{struct D2D1_FEATURE_DATA_DOUBLES { + doublePrecisionFloatShaderOps: BOOL, +}} +STRUCT!{struct D2D1_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS { + computeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x: BOOL, +}} +DEFINE_GUID!{IID_ID2D1VertexBuffer, + 0x9b8b1336, 0x00a5, 0x4668, 0x92, 0xb7, 0xce, 0xd5, 0xd8, 0xbf, 0x9b, 0x7b} +DEFINE_GUID!{IID_ID2D1ResourceTexture, + 0x688d15c3, 0x02b0, 0x438d, 0xb1, 0x3a, 0xd1, 0xb4, 0x4c, 0x32, 0xc3, 0x9a} +DEFINE_GUID!{IID_ID2D1RenderInfo, + 0x519ae1bd, 0xd19a, 0x420d, 0xb8, 0x49, 0x36, 0x4f, 0x59, 0x47, 0x76, 0xb7} +DEFINE_GUID!{IID_ID2D1DrawInfo, + 0x693ce632, 0x7f2f, 0x45de, 0x93, 0xfe, 0x18, 0xd8, 0x8b, 0x37, 0xaa, 0x21} +DEFINE_GUID!{IID_ID2D1ComputeInfo, + 0x5598b14b, 0x9fd7, 0x48b7, 0x9b, 0xdb, 0x8f, 0x09, 0x64, 0xeb, 0x38, 0xbc} +DEFINE_GUID!{IID_ID2D1TransformNode, + 0xb2efe1e7, 0x729f, 0x4102, 0x94, 0x9f, 0x50, 0x5f, 0xa2, 0x1b, 0xf6, 0x66} +DEFINE_GUID!{IID_ID2D1TransformGraph, + 0x13d29038, 0xc3e6, 0x4034, 0x90, 0x81, 0x13, 0xb5, 0x3a, 0x41, 0x79, 0x92} +DEFINE_GUID!{IID_ID2D1Transform, + 0xef1a287d, 0x342a, 0x4f76, 0x8f, 0xdb, 0xda, 0x0d, 0x6e, 0xa9, 0xf9, 0x2b} +DEFINE_GUID!{IID_ID2D1DrawTransform, + 0x36bfdcb6, 0x9739, 0x435d, 0xa3, 0x0d, 0xa6, 0x53, 0xbe, 0xff, 0x6a, 0x6f} +DEFINE_GUID!{IID_ID2D1ComputeTransform, + 0x0d85573c, 0x01e3, 0x4f7d, 0xbf, 0xd9, 0x0d, 0x60, 0x60, 0x8b, 0xf3, 0xc3} +DEFINE_GUID!{IID_ID2D1AnalysisTransform, + 0x0359dc30, 0x95e6, 0x4568, 0x90, 0x55, 0x27, 0x72, 0x0d, 0x13, 0x0e, 0x93} +DEFINE_GUID!{IID_ID2D1SourceTransform, + 0xdb1800dd, 0x0c34, 0x4cf9, 0xbe, 0x90, 0x31, 0xcc, 0x0a, 0x56, 0x53, 0xe1} +DEFINE_GUID!{IID_ID2D1ConcreteTransform, + 0x1a799d8a, 0x69f7, 0x4e4c, 0x9f, 0xed, 0x43, 0x7c, 0xcc, 0x66, 0x84, 0xcc} +DEFINE_GUID!{IID_ID2D1BlendTransform, + 0x63ac0b32, 0xba44, 0x450f, 0x88, 0x06, 0x7f, 0x4c, 0xa1, 0xff, 0x2f, 0x1b} +DEFINE_GUID!{IID_ID2D1BorderTransform, + 0x4998735c, 0x3a19, 0x473c, 0x97, 0x81, 0x65, 0x68, 0x47, 0xe3, 0xa3, 0x47} +DEFINE_GUID!{IID_ID2D1OffsetTransform, + 0x3fe6adea, 0x7643, 0x4f53, 0xbd, 0x14, 0xa0, 0xce, 0x63, 0xf2, 0x40, 0x42} +DEFINE_GUID!{IID_ID2D1BoundsAdjustmentTransform, + 0x90f732e2, 0x5092, 0x4606, 0xa8, 0x19, 0x86, 0x51, 0x97, 0x0b, 0xac, 0xcd} +DEFINE_GUID!{IID_ID2D1EffectImpl, + 0xa248fd3f, 0x3e6c, 0x4e63, 0x9f, 0x03, 0x7f, 0x68, 0xec, 0xc9, 0x1d, 0xb9} +DEFINE_GUID!{IID_ID2D1EffectContext, + 0x3d9f916b, 0x27dc, 0x4ad7, 0xb4, 0xf1, 0x64, 0x94, 0x53, 0x40, 0xf5, 0x63} +RIDL!{#[uuid(0x9b8b1336, 0x00a5, 0x4668, 0x92, 0xb7, 0xce, 0xd5, 0xd8, 0xbf, 0x9b, 0x7b)] +interface ID2D1VertexBuffer(ID2D1VertexBufferVtbl): IUnknown(IUnknownVtbl) { + fn Map( + data: *mut *mut BYTE, + ) -> HRESULT, + fn Unmap() -> HRESULT, +}} +RIDL!{#[uuid(0x688d15c3, 0x02b0, 0x438d, 0xb1, 0x3a, 0xd1, 0xb4, 0x4c, 0x32, 0xc3, 0x9a)] +interface ID2D1ResourceTexture(ID2D1ResourceTextureVtbl): IUnknown(IUnknownVtbl) { + fn Update( + minimumExtents: *const UINT32, + maximumExtents: *const UINT32, + strides: *const UINT32, + dimensions: UINT32, + data: *const BYTE, + dataCount: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x519ae1bd, 0xd19a, 0x420d, 0xb8, 0x49, 0x36, 0x4f, 0x59, 0x47, 0x76, 0xb7)] +interface ID2D1RenderInfo(ID2D1RenderInfoVtbl): IUnknown(IUnknownVtbl) { + fn SetInputDescription( + inputIndex: UINT32, + inputDescription: D2D1_INPUT_DESCRIPTION, + ) -> HRESULT, + fn SetOutputBuffer( + bufferPrecision: D2D1_BUFFER_PRECISION, + channelDepth: D2D1_CHANNEL_DEPTH, + ) -> HRESULT, + fn SetCached( + isCached: BOOL, + ) -> (), + fn SetInstructionCountHint( + instructionCount: UINT32, + ) -> (), +}} +RIDL!{#[uuid(0x693ce632, 0x7f2f, 0x45de, 0x93, 0xfe, 0x18, 0xd8, 0x8b, 0x37, 0xaa, 0x21)] +interface ID2D1DrawInfo(ID2D1DrawInfoVtbl): ID2D1RenderInfo(ID2D1RenderInfoVtbl) { + fn SetPixelShaderConstantBuffer( + buffer: *const BYTE, + bufferCount: UINT32, + ) -> HRESULT, + fn SetResourceTexture( + textureIndex: UINT32, + resourceTexture: *mut ID2D1ResourceTexture, + ) -> HRESULT, + fn SetVertexShaderConstantBuffer( + buffer: *const BYTE, + bufferCount: UINT32, + ) -> HRESULT, + fn SetPixelShader( + shaderId: REFGUID, + pixelOptions: D2D1_PIXEL_OPTIONS, + ) -> HRESULT, + fn SetVertexProcessing( + vertexBuffer: *mut ID2D1VertexBuffer, + vertexOptions: D2D1_VERTEX_OPTIONS, + blendDescription: *const D2D1_BLEND_DESCRIPTION, + vertexRange: *const D2D1_VERTEX_RANGE, + vertexShader: *const GUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5598b14b, 0x9fd7, 0x48b7, 0x9b, 0xdb, 0x8f, 0x09, 0x64, 0xeb, 0x38, 0xbc)] +interface ID2D1ComputeInfo(ID2D1ComputeInfoVtbl): ID2D1RenderInfo(ID2D1RenderInfoVtbl) { + fn SetComputeShaderConstantBuffer( + buffer: *const BYTE, + bufferCount: UINT32, + ) -> HRESULT, + fn SetComputeShader( + shaderId: REFGUID, + ) -> HRESULT, + fn SetResourceTexture( + textureIndex: UINT32, + resourceTexture: *mut ID2D1ResourceTexture, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb2efe1e7, 0x729f, 0x4102, 0x94, 0x9f, 0x50, 0x5f, 0xa2, 0x1b, 0xf6, 0x66)] +interface ID2D1TransformNode(ID2D1TransformNodeVtbl): IUnknown(IUnknownVtbl) { + fn GetInputCount() -> UINT32, +}} +RIDL!{#[uuid(0x13d29038, 0xc3e6, 0x4034, 0x90, 0x81, 0x13, 0xb5, 0x3a, 0x41, 0x79, 0x92)] +interface ID2D1TransformGraph(ID2D1TransformGraphVtbl): IUnknown(IUnknownVtbl) { + fn GetInputCount() -> UINT32, + fn SetSingleTransformNode( + node: *mut ID2D1TransformNode, + ) -> HRESULT, + fn AddNode( + node: *mut ID2D1TransformNode, + ) -> HRESULT, + fn RemoveNode( + node: *mut ID2D1TransformNode, + ) -> HRESULT, + fn SetOutputNode( + node: *mut ID2D1TransformNode, + ) -> HRESULT, + fn ConnectNode( + fromNode: *mut ID2D1TransformNode, + toNode: *mut ID2D1TransformNode, + toNodeInputIndex: UINT32, + ) -> HRESULT, + fn ConnectToEffectInput( + toEffectInputIndex: UINT32, + node: *mut ID2D1TransformNode, + toNodeInputIndex: UINT32, + ) -> HRESULT, + fn Clear() -> (), + fn SetPassthroughGraph( + effectInputIndex: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xef1a287d, 0x342a, 0x4f76, 0x8f, 0xdb, 0xda, 0x0d, 0x6e, 0xa9, 0xf9, 0x2b)] +interface ID2D1Transform(ID2D1TransformVtbl): ID2D1TransformNode(ID2D1TransformNodeVtbl) { + fn MapOutputRectToInputRects( + outputRect: *const D2D_RECT_L, + inputRects: *mut D2D_RECT_L, + inputRectsCount: UINT32, + ) -> HRESULT, + fn MapInputRectsToOutputRect( + inputRects: *const D2D_RECT_L, + inputOpaqueSubRects: *const D2D_RECT_L, + inputRectCount: UINT32, + outputRect: *mut D2D_RECT_L, + outputOpaqueSubRect: *mut D2D_RECT_L, + ) -> HRESULT, + fn MapInvalidRect( + inputIndex: UINT32, + invalidInputRect: D2D_RECT_L, + invalidOutputRect: *mut D2D_RECT_L, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x36bfdcb6, 0x9739, 0x435d, 0xa3, 0x0d, 0xa6, 0x53, 0xbe, 0xff, 0x6a, 0x6f)] +interface ID2D1DrawTransform(ID2D1DrawTransformVtbl): ID2D1Transform(ID2D1TransformVtbl) { + fn SetDrawInfo( + drawInfo: *mut ID2D1DrawInfo, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0d85573c, 0x01e3, 0x4f7d, 0xbf, 0xd9, 0x0d, 0x60, 0x60, 0x8b, 0xf3, 0xc3)] +interface ID2D1ComputeTransform(ID2D1ComputeTransformVtbl): ID2D1Transform(ID2D1TransformVtbl) { + fn SetComputeInfo( + computeInfo: *mut ID2D1ComputeInfo, + ) -> HRESULT, + fn CalculateThreadgroups( + outputRect: *const D2D_RECT_L, + dimensionX: *mut UINT32, + dimensionY: *mut UINT32, + dimensionZ: *mut UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0359dc30, 0x95e6, 0x4568, 0x90, 0x55, 0x27, 0x72, 0x0d, 0x13, 0x0e, 0x93)] +interface ID2D1AnalysisTransform(ID2D1AnalysisTransformVtbl): IUnknown(IUnknownVtbl) { + fn ProcessAnalysisResults( + analysisData: *const BYTE, + analysisDataCount: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdb1800dd, 0x0c34, 0x4cf9, 0xbe, 0x90, 0x31, 0xcc, 0x0a, 0x56, 0x53, 0xe1)] +interface ID2D1SourceTransform(ID2D1SourceTransformVtbl): ID2D1Transform(ID2D1TransformVtbl) { + fn SetRenderInfo( + renderInfo: *mut ID2D1RenderInfo, + ) -> HRESULT, + fn Draw( + target: *mut ID2D1Bitmap1, + drawRect: *mut D2D_RECT_L, + targetOrigin: D2D_POINT_2U, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1a799d8a, 0x69f7, 0x4e4c, 0x9f, 0xed, 0x43, 0x7c, 0xcc, 0x66, 0x84, 0xcc)] +interface ID2D1ConcreteTransform(ID2D1ConcreteTransformVtbl): + ID2D1TransformNode(ID2D1TransformNodeVtbl) { + fn SetOutputBuffer( + bufferPrecision: D2D1_BUFFER_PRECISION, + channelDepth: D2D1_CHANNEL_DEPTH, + ) -> HRESULT, + fn SetCached( + isCached: BOOL, + ) -> (), +}} +RIDL!{#[uuid(0x63ac0b32, 0xba44, 0x450f, 0x88, 0x06, 0x7f, 0x4c, 0xa1, 0xff, 0x2f, 0x1b)] +interface ID2D1BlendTransform(ID2D1BlendTransformVtbl): + ID2D1ConcreteTransform(ID2D1ConcreteTransformVtbl) { + fn SetDescription( + description: *const D2D1_BLEND_DESCRIPTION, + ) -> (), + fn GetDescription( + description: *mut D2D1_BLEND_DESCRIPTION, + ) -> (), +}} +RIDL!{#[uuid(0x4998735c, 0x3a19, 0x473c, 0x97, 0x81, 0x65, 0x68, 0x47, 0xe3, 0xa3, 0x47)] +interface ID2D1BorderTransform(ID2D1BorderTransformVtbl): + ID2D1ConcreteTransform(ID2D1ConcreteTransformVtbl) { + fn SetExtendModeX( + extendMode: D2D1_EXTEND_MODE, + ) -> (), + fn SetExtendModeY( + extendMode: D2D1_EXTEND_MODE, + ) -> (), + fn GetExtendModeX() -> D2D1_EXTEND_MODE, + fn GetExtendModeY() -> D2D1_EXTEND_MODE, +}} +RIDL!{#[uuid(0x3fe6adea, 0x7643, 0x4f53, 0xbd, 0x14, 0xa0, 0xce, 0x63, 0xf2, 0x40, 0x42)] +interface ID2D1OffsetTransform(ID2D1OffsetTransformVtbl): + ID2D1TransformNode(ID2D1TransformNodeVtbl) { + fn SetOffset( + offset: D2D_POINT_2L, + ) -> (), + fn GetOffset() -> D2D_POINT_2L, +}} +RIDL!{#[uuid(0x90f732e2, 0x5092, 0x4606, 0xa8, 0x19, 0x86, 0x51, 0x97, 0x0b, 0xac, 0xcd)] +interface ID2D1BoundsAdjustmentTransform(ID2D1BoundsAdjustmentTransformVtbl): + ID2D1TransformNode(ID2D1TransformNodeVtbl) { + fn SetOutputBounds( + outputBounds: *const D2D_RECT_L, + ) -> (), + fn GetOutputBounds( + outputBounds: *mut D2D_RECT_L, + ) -> (), +}} +RIDL!{#[uuid(0xa248fd3f, 0x3e6c, 0x4e63, 0x9f, 0x03, 0x7f, 0x68, 0xec, 0xc9, 0x1d, 0xb9)] +interface ID2D1EffectImpl(ID2D1EffectImplVtbl): IUnknown(IUnknownVtbl) { + fn Initialize( + effectContext: *mut ID2D1EffectContext, + transformGraph: *mut ID2D1TransformGraph, + ) -> HRESULT, + fn PrepareForRender( + changeType: D2D1_CHANGE_TYPE, + ) -> HRESULT, + fn SetGraph( + transformGraph: *mut ID2D1TransformGraph, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3d9f916b, 0x27dc, 0x4ad7, 0xb4, 0xf1, 0x64, 0x94, 0x53, 0x40, 0xf5, 0x63)] +interface ID2D1EffectContext(ID2D1EffectContextVtbl): IUnknown(IUnknownVtbl) { + fn GetDpi( + dpiX: *mut FLOAT, + dpiY: *mut FLOAT, + ) -> (), + fn CreateEffect( + effectId: REFCLSID, + effect: *mut *mut ID2D1Effect, + ) -> HRESULT, + fn GetMaximumSupportedFeatureLevel( + featureLevels: *const D3D_FEATURE_LEVEL, + featureLevelsCount: UINT32, + maximumSupportedFeatureLevel: *mut D3D_FEATURE_LEVEL, + ) -> HRESULT, + fn CreateTransformNodeFromEffect( + effect: *mut ID2D1Effect, + transformNode: *mut *mut ID2D1TransformNode, + ) -> HRESULT, + fn CreateBlendTransform( + numInputs: UINT32, + blendDescription: D2D1_BLEND_DESCRIPTION, + transform: *mut *mut ID2D1BlendTransform, + ) -> HRESULT, + fn CreateBorderTransform( + extendModeX: D2D1_EXTEND_MODE, + extendModeY: D2D1_EXTEND_MODE, + transform: *mut *mut ID2D1BorderTransform, + ) -> HRESULT, + fn CreateOffsetTransform( + offset: D2D_POINT_2L, + transform: *mut *mut ID2D1OffsetTransform, + ) -> HRESULT, + fn CreateBoundsAdjustmentTransform( + outputRectangle: *mut D2D_RECT_L, + transform: ID2D1BoundsAdjustmentTransform, + ) -> HRESULT, + fn LoadPixelShader( + shaderId: REFGUID, + shaderBuffer: *const BYTE, + shaderBufferCount: UINT32, + ) -> HRESULT, + fn LoadVertexShader( + resourceId: REFGUID, + shaderBuffer: *const BYTE, + shaderBufferCount: UINT32, + ) -> HRESULT, + fn LoadComputeShader( + resourceId: REFGUID, + shaderBuffer: *const BYTE, + shaderBufferCount: UINT32, + ) -> HRESULT, + fn IsShaderLoaded( + shaderId: REFGUID, + ) -> BOOL, + fn CreateResourceTexture( + resourceId: *const GUID, + resourceTextureProperties: *const D2D1_RESOURCE_TEXTURE_PROPERTIES, + data: *const BYTE, + strides: *const UINT32, + dataSize: UINT32, + resourceTexture: *mut *mut ID2D1ResourceTexture, + ) -> HRESULT, + fn FindResourceTexture( + resourceId: *const GUID, + resourceTexture: *mut *mut ID2D1ResourceTexture, + ) -> HRESULT, + fn CreateVertexBuffer( + vertexBufferProperties: *const D2D1_VERTEX_BUFFER_PROPERTIES, + resourceId: *const GUID, + customVertexBufferProperties: *const D2D1_CUSTOM_VERTEX_BUFFER_PROPERTIES, + buffer: *mut *mut ID2D1VertexBuffer, + ) -> HRESULT, + fn FindVertexBuffer( + resourceId: *const GUID, + buffer: *mut *mut ID2D1VertexBuffer, + ) -> HRESULT, + fn CreateColorContext( + space: D2D1_COLOR_SPACE, + profile: *const BYTE, + profileSize: UINT32, + colorContext: *mut *mut ID2D1ColorContext, + ) -> HRESULT, + fn CreateColorContextFromFilename( + filename: PCWSTR, + colorContext: *mut *mut ID2D1ColorContext, + ) -> HRESULT, + fn CreateColorContextFromWicColorContext( + wicColorContext: *mut IWICColorContext, + colorContext: *mut *mut ID2D1ColorContext, + ) -> HRESULT, + fn CheckFeatureSupport( + feature: D2D1_FEATURE, + featureSupportData: *mut c_void, + featureSupportDataSize: UINT32, + ) -> HRESULT, + fn IsBufferPrecisionSupported( + bufferPrecision: D2D1_BUFFER_PRECISION, + ) -> BOOL, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effects.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effects.rs new file mode 100644 index 0000000..c2d1f58 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effects.rs @@ -0,0 +1,617 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of d2d1effects.h +DEFINE_GUID!{CLSID_D2D12DAffineTransform, + 0x6AA97485, 0x6354, 0x4cfc, 0x90, 0x8C, 0xE4, 0xA7, 0x4F, 0x62, 0xC9, 0x6C} +DEFINE_GUID!{CLSID_D2D13DPerspectiveTransform, + 0xC2844D0B, 0x3D86, 0x46e7, 0x85, 0xBA, 0x52, 0x6C, 0x92, 0x40, 0xF3, 0xFB} +DEFINE_GUID!{CLSID_D2D13DTransform, + 0xe8467b04, 0xec61, 0x4b8a, 0xb5, 0xde, 0xd4, 0xd7, 0x3d, 0xeb, 0xea, 0x5a} +DEFINE_GUID!{CLSID_D2D1ArithmeticComposite, + 0xfc151437, 0x049a, 0x4784, 0xa2, 0x4a, 0xf1, 0xc4, 0xda, 0xf2, 0x09, 0x87} +DEFINE_GUID!{CLSID_D2D1Atlas, + 0x913e2be4, 0xfdcf, 0x4fe2, 0xa5, 0xf0, 0x24, 0x54, 0xf1, 0x4f, 0xf4, 0x08} +DEFINE_GUID!{CLSID_D2D1BitmapSource, + 0x5fb6c24d, 0xc6dd, 0x4231, 0x94, 0x4, 0x50, 0xf4, 0xd5, 0xc3, 0x25, 0x2d} +DEFINE_GUID!{CLSID_D2D1Blend, + 0x81c5b77b, 0x13f8, 0x4cdd, 0xad, 0x20, 0xc8, 0x90, 0x54, 0x7a, 0xc6, 0x5d} +DEFINE_GUID!{CLSID_D2D1Border, + 0x2A2D49C0, 0x4ACF, 0x43c7, 0x8C, 0x6A, 0x7C, 0x4A, 0x27, 0x87, 0x4D, 0x27} +DEFINE_GUID!{CLSID_D2D1Brightness, + 0x8cea8d1e, 0x77b0, 0x4986, 0xb3, 0xb9, 0x2f, 0x0c, 0x0e, 0xae, 0x78, 0x87} +DEFINE_GUID!{CLSID_D2D1ColorManagement, + 0x1A28524C, 0xFDD6, 0x4AA4, 0xAE, 0x8F, 0x83, 0x7E, 0xB8, 0x26, 0x7B, 0x37} +DEFINE_GUID!{CLSID_D2D1ColorMatrix, + 0x921F03D6, 0x641C, 0x47DF, 0x85, 0x2D, 0xB4, 0xBB, 0x61, 0x53, 0xAE, 0x11} +DEFINE_GUID!{CLSID_D2D1Composite, + 0x48fc9f51, 0xf6ac, 0x48f1, 0x8b, 0x58, 0x3b, 0x28, 0xac, 0x46, 0xf7, 0x6d} +DEFINE_GUID!{CLSID_D2D1ConvolveMatrix, + 0x407f8c08, 0x5533, 0x4331, 0xa3, 0x41, 0x23, 0xcc, 0x38, 0x77, 0x84, 0x3e} +DEFINE_GUID!{CLSID_D2D1Crop, + 0xE23F7110, 0x0E9A, 0x4324, 0xAF, 0x47, 0x6A, 0x2C, 0x0C, 0x46, 0xF3, 0x5B} +DEFINE_GUID!{CLSID_D2D1DirectionalBlur, + 0x174319a6, 0x58e9, 0x49b2, 0xbb, 0x63, 0xca, 0xf2, 0xc8, 0x11, 0xa3, 0xdb} +DEFINE_GUID!{CLSID_D2D1DiscreteTransfer, + 0x90866fcd, 0x488e, 0x454b, 0xaf, 0x06, 0xe5, 0x04, 0x1b, 0x66, 0xc3, 0x6c} +DEFINE_GUID!{CLSID_D2D1DisplacementMap, + 0xedc48364, 0x417, 0x4111, 0x94, 0x50, 0x43, 0x84, 0x5f, 0xa9, 0xf8, 0x90} +DEFINE_GUID!{CLSID_D2D1DistantDiffuse, + 0x3e7efd62, 0xa32d, 0x46d4, 0xa8, 0x3c, 0x52, 0x78, 0x88, 0x9a, 0xc9, 0x54} +DEFINE_GUID!{CLSID_D2D1DistantSpecular, + 0x428c1ee5, 0x77b8, 0x4450, 0x8a, 0xb5, 0x72, 0x21, 0x9c, 0x21, 0xab, 0xda} +DEFINE_GUID!{CLSID_D2D1DpiCompensation, + 0x6c26c5c7, 0x34e0, 0x46fc, 0x9c, 0xfd, 0xe5, 0x82, 0x37, 0x6, 0xe2, 0x28} +DEFINE_GUID!{CLSID_D2D1Flood, + 0x61c23c20, 0xae69, 0x4d8e, 0x94, 0xcf, 0x50, 0x07, 0x8d, 0xf6, 0x38, 0xf2} +DEFINE_GUID!{CLSID_D2D1GammaTransfer, + 0x409444c4, 0xc419, 0x41a0, 0xb0, 0xc1, 0x8c, 0xd0, 0xc0, 0xa1, 0x8e, 0x42} +DEFINE_GUID!{CLSID_D2D1GaussianBlur, + 0x1feb6d69, 0x2fe6, 0x4ac9, 0x8c, 0x58, 0x1d, 0x7f, 0x93, 0xe7, 0xa6, 0xa5} +DEFINE_GUID!{CLSID_D2D1Scale, + 0x9daf9369, 0x3846, 0x4d0e, 0xa4, 0x4e, 0xc, 0x60, 0x79, 0x34, 0xa5, 0xd7} +DEFINE_GUID!{CLSID_D2D1Histogram, + 0x881db7d0, 0xf7ee, 0x4d4d, 0xa6, 0xd2, 0x46, 0x97, 0xac, 0xc6, 0x6e, 0xe8} +DEFINE_GUID!{CLSID_D2D1HueRotation, + 0x0f4458ec, 0x4b32, 0x491b, 0x9e, 0x85, 0xbd, 0x73, 0xf4, 0x4d, 0x3e, 0xb6} +DEFINE_GUID!{CLSID_D2D1LinearTransfer, + 0xad47c8fd, 0x63ef, 0x4acc, 0x9b, 0x51, 0x67, 0x97, 0x9c, 0x03, 0x6c, 0x06} +DEFINE_GUID!{CLSID_D2D1LuminanceToAlpha, + 0x41251ab7, 0x0beb, 0x46f8, 0x9d, 0xa7, 0x59, 0xe9, 0x3f, 0xcc, 0xe5, 0xde} +DEFINE_GUID!{CLSID_D2D1Morphology, + 0xeae6c40d, 0x626a, 0x4c2d, 0xbf, 0xcb, 0x39, 0x10, 0x01, 0xab, 0xe2, 0x02} +DEFINE_GUID!{CLSID_D2D1OpacityMetadata, + 0x6c53006a, 0x4450, 0x4199, 0xaa, 0x5b, 0xad, 0x16, 0x56, 0xfe, 0xce, 0x5e} +DEFINE_GUID!{CLSID_D2D1PointDiffuse, + 0xb9e303c3, 0xc08c, 0x4f91, 0x8b, 0x7b, 0x38, 0x65, 0x6b, 0xc4, 0x8c, 0x20} +DEFINE_GUID!{CLSID_D2D1PointSpecular, + 0x09c3ca26, 0x3ae2, 0x4f09, 0x9e, 0xbc, 0xed, 0x38, 0x65, 0xd5, 0x3f, 0x22} +DEFINE_GUID!{CLSID_D2D1Premultiply, + 0x06eab419, 0xdeed, 0x4018, 0x80, 0xd2, 0x3e, 0x1d, 0x47, 0x1a, 0xde, 0xb2} +DEFINE_GUID!{CLSID_D2D1Saturation, + 0x5cb2d9cf, 0x327d, 0x459f, 0xa0, 0xce, 0x40, 0xc0, 0xb2, 0x08, 0x6b, 0xf7} +DEFINE_GUID!{CLSID_D2D1Shadow, + 0xC67EA361, 0x1863, 0x4e69, 0x89, 0xDB, 0x69, 0x5D, 0x3E, 0x9A, 0x5B, 0x6B} +DEFINE_GUID!{CLSID_D2D1SpotDiffuse, + 0x818a1105, 0x7932, 0x44f4, 0xaa, 0x86, 0x08, 0xae, 0x7b, 0x2f, 0x2c, 0x93} +DEFINE_GUID!{CLSID_D2D1SpotSpecular, + 0xedae421e, 0x7654, 0x4a37, 0x9d, 0xb8, 0x71, 0xac, 0xc1, 0xbe, 0xb3, 0xc1} +DEFINE_GUID!{CLSID_D2D1TableTransfer, + 0x5bf818c3, 0x5e43, 0x48cb, 0xb6, 0x31, 0x86, 0x83, 0x96, 0xd6, 0xa1, 0xd4} +DEFINE_GUID!{CLSID_D2D1Tile, + 0xB0784138, 0x3B76, 0x4bc5, 0xB1, 0x3B, 0x0F, 0xA2, 0xAD, 0x02, 0x65, 0x9F} +DEFINE_GUID!{CLSID_D2D1Turbulence, + 0xCF2BB6AE, 0x889A, 0x4ad7, 0xBA, 0x29, 0xA2, 0xFD, 0x73, 0x2C, 0x9F, 0xC9} +DEFINE_GUID!{CLSID_D2D1UnPremultiply, + 0xfb9ac489, 0xad8d, 0x41ed, 0x99, 0x99, 0xbb, 0x63, 0x47, 0xd1, 0x10, 0xf7} +ENUM!{enum D2D1_BORDER_MODE { + D2D1_BORDER_MODE_SOFT = 0, + D2D1_BORDER_MODE_HARD = 1, + D2D1_BORDER_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_CHANNEL_SELECTOR { + D2D1_CHANNEL_SELECTOR_R = 0, + D2D1_CHANNEL_SELECTOR_G = 1, + D2D1_CHANNEL_SELECTOR_B = 2, + D2D1_CHANNEL_SELECTOR_A = 3, + D2D1_CHANNEL_SELECTOR_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BITMAPSOURCE_ORIENTATION { + D2D1_BITMAPSOURCE_ORIENTATION_DEFAULT = 1, + D2D1_BITMAPSOURCE_ORIENTATION_FLIP_HORIZONTAL = 2, + D2D1_BITMAPSOURCE_ORIENTATION_ROTATE_CLOCKWISE180 = 3, + D2D1_BITMAPSOURCE_ORIENTATION_ROTATE_CLOCKWISE180_FLIP_HORIZONTAL = 4, + D2D1_BITMAPSOURCE_ORIENTATION_ROTATE_CLOCKWISE270_FLIP_HORIZONTAL = 5, + D2D1_BITMAPSOURCE_ORIENTATION_ROTATE_CLOCKWISE90 = 6, + D2D1_BITMAPSOURCE_ORIENTATION_ROTATE_CLOCKWISE90_FLIP_HORIZONTAL = 7, + D2D1_BITMAPSOURCE_ORIENTATION_ROTATE_CLOCKWISE270 = 8, + D2D1_BITMAPSOURCE_ORIENTATION_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_GAUSSIANBLUR_PROP { + D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION = 0, + D2D1_GAUSSIANBLUR_PROP_OPTIMIZATION = 1, + D2D1_GAUSSIANBLUR_PROP_BORDER_MODE = 2, + D2D1_GAUSSIANBLUR_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_GAUSSIANBLUR_OPTIMIZATION { + D2D1_GAUSSIANBLUR_OPTIMIZATION_SPEED = 0, + D2D1_GAUSSIANBLUR_OPTIMIZATION_BALANCED = 1, + D2D1_GAUSSIANBLUR_OPTIMIZATION_QUALITY = 2, + D2D1_GAUSSIANBLUR_OPTIMIZATION_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DIRECTIONALBLUR_PROP { + D2D1_DIRECTIONALBLUR_PROP_STANDARD_DEVIATION = 0, + D2D1_DIRECTIONALBLUR_PROP_ANGLE = 1, + D2D1_DIRECTIONALBLUR_PROP_OPTIMIZATION = 2, + D2D1_DIRECTIONALBLUR_PROP_BORDER_MODE = 3, + D2D1_DIRECTIONALBLUR_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DIRECTIONALBLUR_OPTIMIZATION { + D2D1_DIRECTIONALBLUR_OPTIMIZATION_SPEED = 0, + D2D1_DIRECTIONALBLUR_OPTIMIZATION_BALANCED = 1, + D2D1_DIRECTIONALBLUR_OPTIMIZATION_QUALITY = 2, + D2D1_DIRECTIONALBLUR_OPTIMIZATION_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_SHADOW_PROP { + D2D1_SHADOW_PROP_BLUR_STANDARD_DEVIATION = 0, + D2D1_SHADOW_PROP_COLOR = 1, + D2D1_SHADOW_PROP_OPTIMIZATION = 2, + D2D1_SHADOW_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_SHADOW_OPTIMIZATION { + D2D1_SHADOW_OPTIMIZATION_SPEED = 0, + D2D1_SHADOW_OPTIMIZATION_BALANCED = 1, + D2D1_SHADOW_OPTIMIZATION_QUALITY = 2, + D2D1_SHADOW_OPTIMIZATION_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BLEND_PROP { + D2D1_BLEND_PROP_MODE = 0, + D2D1_BLEND_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BLEND_MODE { + D2D1_BLEND_MODE_MULTIPLY = 0, + D2D1_BLEND_MODE_SCREEN = 1, + D2D1_BLEND_MODE_DARKEN = 2, + D2D1_BLEND_MODE_LIGHTEN = 3, + D2D1_BLEND_MODE_DISSOLVE = 4, + D2D1_BLEND_MODE_COLOR_BURN = 5, + D2D1_BLEND_MODE_LINEAR_BURN = 6, + D2D1_BLEND_MODE_DARKER_COLOR = 7, + D2D1_BLEND_MODE_LIGHTER_COLOR = 8, + D2D1_BLEND_MODE_COLOR_DODGE = 9, + D2D1_BLEND_MODE_LINEAR_DODGE = 10, + D2D1_BLEND_MODE_OVERLAY = 11, + D2D1_BLEND_MODE_SOFT_LIGHT = 12, + D2D1_BLEND_MODE_HARD_LIGHT = 13, + D2D1_BLEND_MODE_VIVID_LIGHT = 14, + D2D1_BLEND_MODE_LINEAR_LIGHT = 15, + D2D1_BLEND_MODE_PIN_LIGHT = 16, + D2D1_BLEND_MODE_HARD_MIX = 17, + D2D1_BLEND_MODE_DIFFERENCE = 18, + D2D1_BLEND_MODE_EXCLUSION = 19, + D2D1_BLEND_MODE_HUE = 20, + D2D1_BLEND_MODE_SATURATION = 21, + D2D1_BLEND_MODE_COLOR = 22, + D2D1_BLEND_MODE_LUMINOSITY = 23, + D2D1_BLEND_MODE_SUBTRACT = 24, + D2D1_BLEND_MODE_DIVISION = 25, + D2D1_BLEND_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_SATURATION_PROP { + D2D1_SATURATION_PROP_SATURATION = 0, + D2D1_SATURATION_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_HUEROTATION_PROP { + D2D1_HUEROTATION_PROP_ANGLE = 0, + D2D1_HUEROTATION_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_COLORMATRIX_PROP { + D2D1_COLORMATRIX_PROP_COLOR_MATRIX = 0, + D2D1_COLORMATRIX_PROP_ALPHA_MODE = 1, + D2D1_COLORMATRIX_PROP_CLAMP_OUTPUT = 2, + D2D1_COLORMATRIX_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_COLORMATRIX_ALPHA_MODE { + D2D1_COLORMATRIX_ALPHA_MODE_PREMULTIPLIED = 1, + D2D1_COLORMATRIX_ALPHA_MODE_STRAIGHT = 2, + D2D1_COLORMATRIX_ALPHA_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BITMAPSOURCE_PROP { + D2D1_BITMAPSOURCE_PROP_WIC_BITMAP_SOURCE = 0, + D2D1_BITMAPSOURCE_PROP_SCALE = 1, + D2D1_BITMAPSOURCE_PROP_INTERPOLATION_MODE = 2, + D2D1_BITMAPSOURCE_PROP_ENABLE_DPI_CORRECTION = 3, + D2D1_BITMAPSOURCE_PROP_ALPHA_MODE = 4, + D2D1_BITMAPSOURCE_PROP_ORIENTATION = 5, + D2D1_BITMAPSOURCE_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BITMAPSOURCE_INTERPOLATION_MODE { + D2D1_BITMAPSOURCE_INTERPOLATION_MODE_NEAREST_NEIGHBOR = 0, + D2D1_BITMAPSOURCE_INTERPOLATION_MODE_LINEAR = 1, + D2D1_BITMAPSOURCE_INTERPOLATION_MODE_CUBIC = 2, + D2D1_BITMAPSOURCE_INTERPOLATION_MODE_FANT = 6, + D2D1_BITMAPSOURCE_INTERPOLATION_MODE_MIPMAP_LINEAR = 7, + D2D1_BITMAPSOURCE_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BITMAPSOURCE_ALPHA_MODE { + D2D1_BITMAPSOURCE_ALPHA_MODE_PREMULTIPLIED = 1, + D2D1_BITMAPSOURCE_ALPHA_MODE_STRAIGHT = 2, + D2D1_BITMAPSOURCE_ALPHA_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_COMPOSITE_PROP { + D2D1_COMPOSITE_PROP_MODE = 0, + D2D1_COMPOSITE_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_3DTRANSFORM_PROP { + D2D1_3DTRANSFORM_PROP_INTERPOLATION_MODE = 0, + D2D1_3DTRANSFORM_PROP_BORDER_MODE = 1, + D2D1_3DTRANSFORM_PROP_TRANSFORM_MATRIX = 2, + D2D1_3DTRANSFORM_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_3DTRANSFORM_INTERPOLATION_MODE { + D2D1_3DTRANSFORM_INTERPOLATION_MODE_NEAREST_NEIGHBOR = 0, + D2D1_3DTRANSFORM_INTERPOLATION_MODE_LINEAR = 1, + D2D1_3DTRANSFORM_INTERPOLATION_MODE_CUBIC = 2, + D2D1_3DTRANSFORM_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_3DTRANSFORM_INTERPOLATION_MODE_ANISOTROPIC = 4, + D2D1_3DTRANSFORM_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_3DPERSPECTIVETRANSFORM_PROP { + D2D1_3DPERSPECTIVETRANSFORM_PROP_INTERPOLATION_MODE = 0, + D2D1_3DPERSPECTIVETRANSFORM_PROP_BORDER_MODE = 1, + D2D1_3DPERSPECTIVETRANSFORM_PROP_DEPTH = 2, + D2D1_3DPERSPECTIVETRANSFORM_PROP_PERSPECTIVE_ORIGIN = 3, + D2D1_3DPERSPECTIVETRANSFORM_PROP_LOCAL_OFFSET = 4, + D2D1_3DPERSPECTIVETRANSFORM_PROP_GLOBAL_OFFSET = 5, + D2D1_3DPERSPECTIVETRANSFORM_PROP_ROTATION_ORIGIN = 6, + D2D1_3DPERSPECTIVETRANSFORM_PROP_ROTATION = 7, + D2D1_3DPERSPECTIVETRANSFORM_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_3DPERSPECTIVETRANSFORM_INTERPOLATION_MODE { + D2D1_3DPERSPECTIVETRANSFORM_INTERPOLATION_MODE_NEAREST_NEIGHBOR = 0, + D2D1_3DPERSPECTIVETRANSFORM_INTERPOLATION_MODE_LINEAR = 1, + D2D1_3DPERSPECTIVETRANSFORM_INTERPOLATION_MODE_CUBIC = 2, + D2D1_3DPERSPECTIVETRANSFORM_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_3DPERSPECTIVETRANSFORM_INTERPOLATION_MODE_ANISOTROPIC = 4, + D2D1_3DPERSPECTIVETRANSFORM_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_2DAFFINETRANSFORM_PROP { + D2D1_2DAFFINETRANSFORM_PROP_INTERPOLATION_MODE = 0, + D2D1_2DAFFINETRANSFORM_PROP_BORDER_MODE = 1, + D2D1_2DAFFINETRANSFORM_PROP_TRANSFORM_MATRIX = 2, + D2D1_2DAFFINETRANSFORM_PROP_SHARPNESS = 3, + D2D1_2DAFFINETRANSFORM_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE { + D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_NEAREST_NEIGHBOR = 0, + D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_LINEAR = 1, + D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_CUBIC = 2, + D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_ANISOTROPIC = 4, + D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DPICOMPENSATION_PROP { + D2D1_DPICOMPENSATION_PROP_INTERPOLATION_MODE = 0, + D2D1_DPICOMPENSATION_PROP_BORDER_MODE = 1, + D2D1_DPICOMPENSATION_PROP_INPUT_DPI = 2, + D2D1_DPICOMPENSATION_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DPICOMPENSATION_INTERPOLATION_MODE { + D2D1_DPICOMPENSATION_INTERPOLATION_MODE_NEAREST_NEIGHBOR = 0, + D2D1_DPICOMPENSATION_INTERPOLATION_MODE_LINEAR = 1, + D2D1_DPICOMPENSATION_INTERPOLATION_MODE_CUBIC = 2, + D2D1_DPICOMPENSATION_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_DPICOMPENSATION_INTERPOLATION_MODE_ANISOTROPIC = 4, + D2D1_DPICOMPENSATION_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_DPICOMPENSATION_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_SCALE_PROP { + D2D1_SCALE_PROP_SCALE = 0, + D2D1_SCALE_PROP_CENTER_POINT = 1, + D2D1_SCALE_PROP_INTERPOLATION_MODE = 2, + D2D1_SCALE_PROP_BORDER_MODE = 3, + D2D1_SCALE_PROP_SHARPNESS = 4, + D2D1_SCALE_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_SCALE_INTERPOLATION_MODE { + D2D1_SCALE_INTERPOLATION_MODE_NEAREST_NEIGHBOR = 0, + D2D1_SCALE_INTERPOLATION_MODE_LINEAR = 1, + D2D1_SCALE_INTERPOLATION_MODE_CUBIC = 2, + D2D1_SCALE_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_SCALE_INTERPOLATION_MODE_ANISOTROPIC = 4, + D2D1_SCALE_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_SCALE_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_TURBULENCE_PROP { + D2D1_TURBULENCE_PROP_OFFSET = 0, + D2D1_TURBULENCE_PROP_SIZE = 1, + D2D1_TURBULENCE_PROP_BASE_FREQUENCY = 2, + D2D1_TURBULENCE_PROP_NUM_OCTAVES = 3, + D2D1_TURBULENCE_PROP_SEED = 4, + D2D1_TURBULENCE_PROP_NOISE = 5, + D2D1_TURBULENCE_PROP_STITCHABLE = 6, + D2D1_TURBULENCE_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_TURBULENCE_NOISE { + D2D1_TURBULENCE_NOISE_FRACTAL_SUM = 0, + D2D1_TURBULENCE_NOISE_TURBULENCE = 1, + D2D1_TURBULENCE_NOISE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DISPLACEMENTMAP_PROP { + D2D1_DISPLACEMENTMAP_PROP_SCALE = 0, + D2D1_DISPLACEMENTMAP_PROP_X_CHANNEL_SELECT = 1, + D2D1_DISPLACEMENTMAP_PROP_Y_CHANNEL_SELECT = 2, + D2D1_DISPLACEMENTMAP_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_COLORMANAGEMENT_PROP { + D2D1_COLORMANAGEMENT_PROP_SOURCE_COLOR_CONTEXT = 0, + D2D1_COLORMANAGEMENT_PROP_SOURCE_RENDERING_INTENT = 1, + D2D1_COLORMANAGEMENT_PROP_DESTINATION_COLOR_CONTEXT = 2, + D2D1_COLORMANAGEMENT_PROP_DESTINATION_RENDERING_INTENT = 3, + D2D1_COLORMANAGEMENT_PROP_ALPHA_MODE = 4, + D2D1_COLORMANAGEMENT_PROP_QUALITY = 5, + D2D1_COLORMANAGEMENT_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_COLORMANAGEMENT_ALPHA_MODE { + D2D1_COLORMANAGEMENT_ALPHA_MODE_PREMULTIPLIED = 1, + D2D1_COLORMANAGEMENT_ALPHA_MODE_STRAIGHT = 2, + D2D1_COLORMANAGEMENT_ALPHA_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_COLORMANAGEMENT_QUALITY { + D2D1_COLORMANAGEMENT_QUALITY_PROOF = 0, + D2D1_COLORMANAGEMENT_QUALITY_NORMAL = 1, + D2D1_COLORMANAGEMENT_QUALITY_BEST = 2, + D2D1_COLORMANAGEMENT_QUALITY_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_COLORMANAGEMENT_RENDERING_INTENT { + D2D1_COLORMANAGEMENT_RENDERING_INTENT_PERCEPTUAL = 0, + D2D1_COLORMANAGEMENT_RENDERING_INTENT_RELATIVE_COLORIMETRIC = 1, + D2D1_COLORMANAGEMENT_RENDERING_INTENT_SATURATION = 2, + D2D1_COLORMANAGEMENT_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC = 3, + D2D1_COLORMANAGEMENT_RENDERING_INTENT_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_HISTOGRAM_PROP { + D2D1_HISTOGRAM_PROP_NUM_BINS = 0, + D2D1_HISTOGRAM_PROP_CHANNEL_SELECT = 1, + D2D1_HISTOGRAM_PROP_HISTOGRAM_OUTPUT = 2, + D2D1_HISTOGRAM_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_POINTSPECULAR_PROP { + D2D1_POINTSPECULAR_PROP_LIGHT_POSITION = 0, + D2D1_POINTSPECULAR_PROP_SPECULAR_EXPONENT = 1, + D2D1_POINTSPECULAR_PROP_SPECULAR_CONSTANT = 2, + D2D1_POINTSPECULAR_PROP_SURFACE_SCALE = 3, + D2D1_POINTSPECULAR_PROP_COLOR = 4, + D2D1_POINTSPECULAR_PROP_KERNEL_UNIT_LENGTH = 5, + D2D1_POINTSPECULAR_PROP_SCALE_MODE = 6, + D2D1_POINTSPECULAR_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_POINTSPECULAR_SCALE_MODE { + D2D1_POINTSPECULAR_SCALE_MODE_NEAREST_NEIGHBOR = 0, + D2D1_POINTSPECULAR_SCALE_MODE_LINEAR = 1, + D2D1_POINTSPECULAR_SCALE_MODE_CUBIC = 2, + D2D1_POINTSPECULAR_SCALE_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_POINTSPECULAR_SCALE_MODE_ANISOTROPIC = 4, + D2D1_POINTSPECULAR_SCALE_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_POINTSPECULAR_SCALE_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_SPOTSPECULAR_PROP { + D2D1_SPOTSPECULAR_PROP_LIGHT_POSITION = 0, + D2D1_SPOTSPECULAR_PROP_POINTS_AT = 1, + D2D1_SPOTSPECULAR_PROP_FOCUS = 2, + D2D1_SPOTSPECULAR_PROP_LIMITING_CONE_ANGLE = 3, + D2D1_SPOTSPECULAR_PROP_SPECULAR_EXPONENT = 4, + D2D1_SPOTSPECULAR_PROP_SPECULAR_CONSTANT = 5, + D2D1_SPOTSPECULAR_PROP_SURFACE_SCALE = 6, + D2D1_SPOTSPECULAR_PROP_COLOR = 7, + D2D1_SPOTSPECULAR_PROP_KERNEL_UNIT_LENGTH = 8, + D2D1_SPOTSPECULAR_PROP_SCALE_MODE = 9, + D2D1_SPOTSPECULAR_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_SPOTSPECULAR_SCALE_MODE { + D2D1_SPOTSPECULAR_SCALE_MODE_NEAREST_NEIGHBOR = 0, + D2D1_SPOTSPECULAR_SCALE_MODE_LINEAR = 1, + D2D1_SPOTSPECULAR_SCALE_MODE_CUBIC = 2, + D2D1_SPOTSPECULAR_SCALE_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_SPOTSPECULAR_SCALE_MODE_ANISOTROPIC = 4, + D2D1_SPOTSPECULAR_SCALE_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_SPOTSPECULAR_SCALE_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DISTANTSPECULAR_PROP { + D2D1_DISTANTSPECULAR_PROP_AZIMUTH = 0, + D2D1_DISTANTSPECULAR_PROP_ELEVATION = 1, + D2D1_DISTANTSPECULAR_PROP_SPECULAR_EXPONENT = 2, + D2D1_DISTANTSPECULAR_PROP_SPECULAR_CONSTANT = 3, + D2D1_DISTANTSPECULAR_PROP_SURFACE_SCALE = 4, + D2D1_DISTANTSPECULAR_PROP_COLOR = 5, + D2D1_DISTANTSPECULAR_PROP_KERNEL_UNIT_LENGTH = 6, + D2D1_DISTANTSPECULAR_PROP_SCALE_MODE = 7, + D2D1_DISTANTSPECULAR_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DISTANTSPECULAR_SCALE_MODE { + D2D1_DISTANTSPECULAR_SCALE_MODE_NEAREST_NEIGHBOR = 0, + D2D1_DISTANTSPECULAR_SCALE_MODE_LINEAR = 1, + D2D1_DISTANTSPECULAR_SCALE_MODE_CUBIC = 2, + D2D1_DISTANTSPECULAR_SCALE_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_DISTANTSPECULAR_SCALE_MODE_ANISOTROPIC = 4, + D2D1_DISTANTSPECULAR_SCALE_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_DISTANTSPECULAR_SCALE_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_POINTDIFFUSE_PROP { + D2D1_POINTDIFFUSE_PROP_LIGHT_POSITION = 0, + D2D1_POINTDIFFUSE_PROP_DIFFUSE_CONSTANT = 1, + D2D1_POINTDIFFUSE_PROP_SURFACE_SCALE = 2, + D2D1_POINTDIFFUSE_PROP_COLOR = 3, + D2D1_POINTDIFFUSE_PROP_KERNEL_UNIT_LENGTH = 4, + D2D1_POINTDIFFUSE_PROP_SCALE_MODE = 5, + D2D1_POINTDIFFUSE_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_POINTDIFFUSE_SCALE_MODE { + D2D1_POINTDIFFUSE_SCALE_MODE_NEAREST_NEIGHBOR = 0, + D2D1_POINTDIFFUSE_SCALE_MODE_LINEAR = 1, + D2D1_POINTDIFFUSE_SCALE_MODE_CUBIC = 2, + D2D1_POINTDIFFUSE_SCALE_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_POINTDIFFUSE_SCALE_MODE_ANISOTROPIC = 4, + D2D1_POINTDIFFUSE_SCALE_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_POINTDIFFUSE_SCALE_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_SPOTDIFFUSE_PROP { + D2D1_SPOTDIFFUSE_PROP_LIGHT_POSITION = 0, + D2D1_SPOTDIFFUSE_PROP_POINTS_AT = 1, + D2D1_SPOTDIFFUSE_PROP_FOCUS = 2, + D2D1_SPOTDIFFUSE_PROP_LIMITING_CONE_ANGLE = 3, + D2D1_SPOTDIFFUSE_PROP_DIFFUSE_CONSTANT = 4, + D2D1_SPOTDIFFUSE_PROP_SURFACE_SCALE = 5, + D2D1_SPOTDIFFUSE_PROP_COLOR = 6, + D2D1_SPOTDIFFUSE_PROP_KERNEL_UNIT_LENGTH = 7, + D2D1_SPOTDIFFUSE_PROP_SCALE_MODE = 8, + D2D1_SPOTDIFFUSE_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_SPOTDIFFUSE_SCALE_MODE { + D2D1_SPOTDIFFUSE_SCALE_MODE_NEAREST_NEIGHBOR = 0, + D2D1_SPOTDIFFUSE_SCALE_MODE_LINEAR = 1, + D2D1_SPOTDIFFUSE_SCALE_MODE_CUBIC = 2, + D2D1_SPOTDIFFUSE_SCALE_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_SPOTDIFFUSE_SCALE_MODE_ANISOTROPIC = 4, + D2D1_SPOTDIFFUSE_SCALE_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_SPOTDIFFUSE_SCALE_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DISTANTDIFFUSE_PROP { + D2D1_DISTANTDIFFUSE_PROP_AZIMUTH = 0, + D2D1_DISTANTDIFFUSE_PROP_ELEVATION = 1, + D2D1_DISTANTDIFFUSE_PROP_DIFFUSE_CONSTANT = 2, + D2D1_DISTANTDIFFUSE_PROP_SURFACE_SCALE = 3, + D2D1_DISTANTDIFFUSE_PROP_COLOR = 4, + D2D1_DISTANTDIFFUSE_PROP_KERNEL_UNIT_LENGTH = 5, + D2D1_DISTANTDIFFUSE_PROP_SCALE_MODE = 6, + D2D1_DISTANTDIFFUSE_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DISTANTDIFFUSE_SCALE_MODE { + D2D1_DISTANTDIFFUSE_SCALE_MODE_NEAREST_NEIGHBOR = 0, + D2D1_DISTANTDIFFUSE_SCALE_MODE_LINEAR = 1, + D2D1_DISTANTDIFFUSE_SCALE_MODE_CUBIC = 2, + D2D1_DISTANTDIFFUSE_SCALE_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_DISTANTDIFFUSE_SCALE_MODE_ANISOTROPIC = 4, + D2D1_DISTANTDIFFUSE_SCALE_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_DISTANTDIFFUSE_SCALE_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_FLOOD_PROP { + D2D1_FLOOD_PROP_COLOR = 0, + D2D1_FLOOD_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_LINEARTRANSFER_PROP { + D2D1_LINEARTRANSFER_PROP_RED_Y_INTERCEPT = 0, + D2D1_LINEARTRANSFER_PROP_RED_SLOPE = 1, + D2D1_LINEARTRANSFER_PROP_RED_DISABLE = 2, + D2D1_LINEARTRANSFER_PROP_GREEN_Y_INTERCEPT = 3, + D2D1_LINEARTRANSFER_PROP_GREEN_SLOPE = 4, + D2D1_LINEARTRANSFER_PROP_GREEN_DISABLE = 5, + D2D1_LINEARTRANSFER_PROP_BLUE_Y_INTERCEPT = 6, + D2D1_LINEARTRANSFER_PROP_BLUE_SLOPE = 7, + D2D1_LINEARTRANSFER_PROP_BLUE_DISABLE = 8, + D2D1_LINEARTRANSFER_PROP_ALPHA_Y_INTERCEPT = 9, + D2D1_LINEARTRANSFER_PROP_ALPHA_SLOPE = 10, + D2D1_LINEARTRANSFER_PROP_ALPHA_DISABLE = 11, + D2D1_LINEARTRANSFER_PROP_CLAMP_OUTPUT = 12, + D2D1_LINEARTRANSFER_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_GAMMATRANSFER_PROP { + D2D1_GAMMATRANSFER_PROP_RED_AMPLITUDE = 0, + D2D1_GAMMATRANSFER_PROP_RED_EXPONENT = 1, + D2D1_GAMMATRANSFER_PROP_RED_OFFSET = 2, + D2D1_GAMMATRANSFER_PROP_RED_DISABLE = 3, + D2D1_GAMMATRANSFER_PROP_GREEN_AMPLITUDE = 4, + D2D1_GAMMATRANSFER_PROP_GREEN_EXPONENT = 5, + D2D1_GAMMATRANSFER_PROP_GREEN_OFFSET = 6, + D2D1_GAMMATRANSFER_PROP_GREEN_DISABLE = 7, + D2D1_GAMMATRANSFER_PROP_BLUE_AMPLITUDE = 8, + D2D1_GAMMATRANSFER_PROP_BLUE_EXPONENT = 9, + D2D1_GAMMATRANSFER_PROP_BLUE_OFFSET = 10, + D2D1_GAMMATRANSFER_PROP_BLUE_DISABLE = 11, + D2D1_GAMMATRANSFER_PROP_ALPHA_AMPLITUDE = 12, + D2D1_GAMMATRANSFER_PROP_ALPHA_EXPONENT = 13, + D2D1_GAMMATRANSFER_PROP_ALPHA_OFFSET = 14, + D2D1_GAMMATRANSFER_PROP_ALPHA_DISABLE = 15, + D2D1_GAMMATRANSFER_PROP_CLAMP_OUTPUT = 16, + D2D1_GAMMATRANSFER_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_TABLETRANSFER_PROP { + D2D1_TABLETRANSFER_PROP_RED_TABLE = 0, + D2D1_TABLETRANSFER_PROP_RED_DISABLE = 1, + D2D1_TABLETRANSFER_PROP_GREEN_TABLE = 2, + D2D1_TABLETRANSFER_PROP_GREEN_DISABLE = 3, + D2D1_TABLETRANSFER_PROP_BLUE_TABLE = 4, + D2D1_TABLETRANSFER_PROP_BLUE_DISABLE = 5, + D2D1_TABLETRANSFER_PROP_ALPHA_TABLE = 6, + D2D1_TABLETRANSFER_PROP_ALPHA_DISABLE = 7, + D2D1_TABLETRANSFER_PROP_CLAMP_OUTPUT = 8, + D2D1_TABLETRANSFER_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_DISCRETETRANSFER_PROP { + D2D1_DISCRETETRANSFER_PROP_RED_TABLE = 0, + D2D1_DISCRETETRANSFER_PROP_RED_DISABLE = 1, + D2D1_DISCRETETRANSFER_PROP_GREEN_TABLE = 2, + D2D1_DISCRETETRANSFER_PROP_GREEN_DISABLE = 3, + D2D1_DISCRETETRANSFER_PROP_BLUE_TABLE = 4, + D2D1_DISCRETETRANSFER_PROP_BLUE_DISABLE = 5, + D2D1_DISCRETETRANSFER_PROP_ALPHA_TABLE = 6, + D2D1_DISCRETETRANSFER_PROP_ALPHA_DISABLE = 7, + D2D1_DISCRETETRANSFER_PROP_CLAMP_OUTPUT = 8, + D2D1_DISCRETETRANSFER_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_CONVOLVEMATRIX_PROP { + D2D1_CONVOLVEMATRIX_PROP_KERNEL_UNIT_LENGTH = 0, + D2D1_CONVOLVEMATRIX_PROP_SCALE_MODE = 1, + D2D1_CONVOLVEMATRIX_PROP_KERNEL_SIZE_X = 2, + D2D1_CONVOLVEMATRIX_PROP_KERNEL_SIZE_Y = 3, + D2D1_CONVOLVEMATRIX_PROP_KERNEL_MATRIX = 4, + D2D1_CONVOLVEMATRIX_PROP_DIVISOR = 5, + D2D1_CONVOLVEMATRIX_PROP_BIAS = 6, + D2D1_CONVOLVEMATRIX_PROP_KERNEL_OFFSET = 7, + D2D1_CONVOLVEMATRIX_PROP_PRESERVE_ALPHA = 8, + D2D1_CONVOLVEMATRIX_PROP_BORDER_MODE = 9, + D2D1_CONVOLVEMATRIX_PROP_CLAMP_OUTPUT = 10, + D2D1_CONVOLVEMATRIX_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_CONVOLVEMATRIX_SCALE_MODE { + D2D1_CONVOLVEMATRIX_SCALE_MODE_NEAREST_NEIGHBOR = 0, + D2D1_CONVOLVEMATRIX_SCALE_MODE_LINEAR = 1, + D2D1_CONVOLVEMATRIX_SCALE_MODE_CUBIC = 2, + D2D1_CONVOLVEMATRIX_SCALE_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_CONVOLVEMATRIX_SCALE_MODE_ANISOTROPIC = 4, + D2D1_CONVOLVEMATRIX_SCALE_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_CONVOLVEMATRIX_SCALE_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BRIGHTNESS_PROP { + D2D1_BRIGHTNESS_PROP_WHITE_POINT = 0, + D2D1_BRIGHTNESS_PROP_BLACK_POINT = 1, + D2D1_BRIGHTNESS_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_ARITHMETICCOMPOSITE_PROP { + D2D1_ARITHMETICCOMPOSITE_PROP_COEFFICIENTS = 0, + D2D1_ARITHMETICCOMPOSITE_PROP_CLAMP_OUTPUT = 1, + D2D1_ARITHMETICCOMPOSITE_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_CROP_PROP { + D2D1_CROP_PROP_RECT = 0, + D2D1_CROP_PROP_BORDER_MODE = 1, + D2D1_CROP_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BORDER_PROP { + D2D1_BORDER_PROP_EDGE_MODE_X = 0, + D2D1_BORDER_PROP_EDGE_MODE_Y = 1, + D2D1_BORDER_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_BORDER_EDGE_MODE { + D2D1_BORDER_EDGE_MODE_CLAMP = 0, + D2D1_BORDER_EDGE_MODE_WRAP = 1, + D2D1_BORDER_EDGE_MODE_MIRROR = 2, + D2D1_BORDER_EDGE_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_MORPHOLOGY_PROP { + D2D1_MORPHOLOGY_PROP_MODE = 0, + D2D1_MORPHOLOGY_PROP_WIDTH = 1, + D2D1_MORPHOLOGY_PROP_HEIGHT = 2, + D2D1_MORPHOLOGY_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_MORPHOLOGY_MODE { + D2D1_MORPHOLOGY_MODE_ERODE = 0, + D2D1_MORPHOLOGY_MODE_DILATE = 1, + D2D1_MORPHOLOGY_MODE_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_TILE_PROP { + D2D1_TILE_PROP_RECT = 0, + D2D1_TILE_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_ATLAS_PROP { + D2D1_ATLAS_PROP_INPUT_RECT = 0, + D2D1_ATLAS_PROP_INPUT_PADDING_RECT = 1, + D2D1_ATLAS_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_OPACITYMETADATA_PROP { + D2D1_OPACITYMETADATA_PROP_INPUT_OPAQUE_RECT = 0, + D2D1_OPACITYMETADATA_PROP_FORCE_DWORD = 0xffffffff, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effects_1.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effects_1.rs new file mode 100644 index 0000000..ba97f01 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effects_1.rs @@ -0,0 +1,31 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +// Mappings for the contents of d2d1effects_1.h +DEFINE_GUID!{CLSID_D2D1YCbCr, + 0x99503cc1, 0x66c7, 0x45c9, 0xa8, 0x75, 0x8a, 0xd8, 0xa7, 0x91, 0x44, 0x01} +ENUM!{enum D2D1_YCBCR_PROP { + D2D1_YCBCR_PROP_CHROMA_SUBSAMPLING = 0, + D2D1_YCBCR_PROP_TRANSFORM_MATRIX = 1, + D2D1_YCBCR_PROP_INTERPOLATION_MODE = 2, + D2D1_YCBCR_PROP_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_YCBCR_CHROMA_SUBSAMPLING { + D2D1_YCBCR_CHROMA_SUBSAMPLING_AUTO = 0, + D2D1_YCBCR_CHROMA_SUBSAMPLING_420 = 1, + D2D1_YCBCR_CHROMA_SUBSAMPLING_422 = 2, + D2D1_YCBCR_CHROMA_SUBSAMPLING_444 = 3, + D2D1_YCBCR_CHROMA_SUBSAMPLING_440 = 4, + D2D1_YCBCR_CHROMA_SUBSAMPLING_FORCE_DWORD = 0xffffffff, +}} +ENUM!{enum D2D1_YCBCR_INTERPOLATION_MODE { + D2D1_YCBCR_INTERPOLATION_MODE_NEAREST_NEIGHBOR = 0, + D2D1_YCBCR_INTERPOLATION_MODE_LINEAR = 1, + D2D1_YCBCR_INTERPOLATION_MODE_CUBIC = 2, + D2D1_YCBCR_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR = 3, + D2D1_YCBCR_INTERPOLATION_MODE_ANISOTROPIC = 4, + D2D1_YCBCR_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC = 5, + D2D1_YCBCR_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effects_2.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effects_2.rs new file mode 100644 index 0000000..40eea83 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1effects_2.rs @@ -0,0 +1,40 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of d2d1effects_2.h +DEFINE_GUID!{CLSID_D2D1Contrast, + 0xb648a78a, 0x0ed5, 0x4f80, 0xa9, 0x4a, 0x8e, 0x82, 0x5a, 0xca, 0x6b, 0x77} +DEFINE_GUID!{CLSID_D2D1RgbToHue, + 0x23f3e5ec, 0x91e8, 0x4d3d, 0xad, 0x0a, 0xaf, 0xad, 0xc1, 0x00, 0x4a, 0xa1} +DEFINE_GUID!{CLSID_D2D1HueToRgb, + 0x7b78a6bd, 0x0141, 0x4def, 0x8a, 0x52, 0x63, 0x56, 0xee, 0x0c, 0xbd, 0xd5} +DEFINE_GUID!{CLSID_D2D1ChromaKey, + 0x74c01f5b, 0x2a0d, 0x408c, 0x88, 0xe2, 0xc7, 0xa3, 0xc7, 0x19, 0x77, 0x42} +DEFINE_GUID!{CLSID_D2D1Emboss, + 0xb1c5eb2b, 0x0348, 0x43f0, 0x81, 0x07, 0x49, 0x57, 0xca, 0xcb, 0xa2, 0xae} +DEFINE_GUID!{CLSID_D2D1Exposure, + 0xb56c8cfa, 0xf634, 0x41ee, 0xbe, 0xe0, 0xff, 0xa6, 0x17, 0x10, 0x60, 0x04} +DEFINE_GUID!{CLSID_D2D1Grayscale, + 0x36dde0eb, 0x3725, 0x42e0, 0x83, 0x6d, 0x52, 0xfb, 0x20, 0xae, 0xe6, 0x44} +DEFINE_GUID!{CLSID_D2D1Invert, + 0xe0c3784d, 0xcb39, 0x4e84, 0xb6, 0xfd, 0x6b, 0x72, 0xf0, 0x81, 0x02, 0x63} +DEFINE_GUID!{CLSID_D2D1Posterize, + 0x2188945e, 0x33a3, 0x4366, 0xb7, 0xbc, 0x08, 0x6b, 0xd0, 0x2d, 0x08, 0x84} +DEFINE_GUID!{CLSID_D2D1Sepia, + 0x3a1af410, 0x5f1d, 0x4dbe, 0x84, 0xdf, 0x91, 0x5d, 0xa7, 0x9b, 0x71, 0x53} +DEFINE_GUID!{CLSID_D2D1Sharpen, + 0xc9b887cb, 0xc5ff, 0x4dc5, 0x97, 0x79, 0x27, 0x3d, 0xcf, 0x41, 0x7c, 0x7d} +DEFINE_GUID!{CLSID_D2D1Straighten, + 0x4da47b12, 0x79a3, 0x4fb0, 0x82, 0x37, 0xbb, 0xc3, 0xb2, 0xa4, 0xde, 0x08} +DEFINE_GUID!{CLSID_D2D1TemperatureTint, + 0x89176087, 0x8af9, 0x4a08, 0xae, 0xb1, 0x89, 0x5f, 0x38, 0xdb, 0x17, 0x66} +DEFINE_GUID!{CLSID_D2D1Vignette, + 0xc00c40be, 0x5e67, 0x4ca3, 0x95, 0xb4, 0xf4, 0xb0, 0x2c, 0x11, 0x51, 0x35} +DEFINE_GUID!{CLSID_D2D1EdgeDetection, + 0xeff583ca, 0xcb07, 0x4aa9, 0xac, 0x5d, 0x2c, 0xc4, 0x4c, 0x76, 0x46, 0x0f} +DEFINE_GUID!{CLSID_D2D1HighlightsShadows, + 0xcadc8384, 0x323f, 0x4c7e, 0xa3, 0x61, 0x2e, 0x2b, 0x24, 0xdf, 0x6e, 0xe4} +DEFINE_GUID!{CLSID_D2D1LookupTable3D, + 0x349e0eda, 0x0088, 0x4a79, 0x9c, 0xa3, 0xc7, 0xe3, 0x00, 0x20, 0x20, 0x20} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1svg.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1svg.rs new file mode 100644 index 0000000..33e133e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2d1svg.rs @@ -0,0 +1,411 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of d2d1svg.h +use ctypes::c_void; +use shared::basetsd::UINT32; +use shared::guiddef::REFIID; +use shared::minwindef::{BOOL, FLOAT}; +use shared::ntdef::{PCWSTR, PWSTR, WCHAR}; +use shared::winerror::HRESULT; +use um::d2d1::{ + D2D1_CAP_STYLE_FLAT, D2D1_CAP_STYLE_ROUND, D2D1_CAP_STYLE_SQUARE, D2D1_COLOR_F, D2D1_FILL_MODE, + D2D1_LINE_JOIN_BEVEL, D2D1_LINE_JOIN_MITER_OR_BEVEL, D2D1_LINE_JOIN_ROUND, D2D1_POINT_2F, + D2D1_SIZE_F, ID2D1Resource, ID2D1ResourceVtbl +}; +use um::d2d1_1::ID2D1PathGeometry1; +use um::objidlbase::IStream; +ENUM!{enum D2D1_SVG_PAINT_TYPE { + D2D1_SVG_PAINT_TYPE_NONE = 0, + D2D1_SVG_PAINT_TYPE_COLOR = 1, + D2D1_SVG_PAINT_TYPE_CURRENT_COLOR = 2, + D2D1_SVG_PAINT_TYPE_URI = 3, + D2D1_SVG_PAINT_TYPE_URI_NONE = 4, + D2D1_SVG_PAINT_TYPE_URI_COLOR = 5, + D2D1_SVG_PAINT_TYPE_URI_CURRENT_COLOR = 6, +}} +ENUM!{enum D2D1_SVG_LENGTH_UNITS { + D2D1_SVG_LENGTH_UNITS_NUMBER = 0, + D2D1_SVG_LENGTH_UNITS_PERCENTAGE = 1, +}} +ENUM!{enum D2D1_SVG_DISPLAY { + D2D1_SVG_DISPLAY_INLINE = 0, + D2D1_SVG_DISPLAY_NONE = 1, +}} +ENUM!{enum D2D1_SVG_VISIBILITY { + D2D1_SVG_VISIBILITY_VISIBLE = 0, + D2D1_SVG_VISIBILITY_HIDDEN = 1, +}} +ENUM!{enum D2D1_SVG_OVERFLOW { + D2D1_SVG_OVERFLOW_VISIBLE = 0, + D2D1_SVG_OVERFLOW_HIDDEN = 1, +}} +ENUM!{enum D2D1_SVG_LINE_CAP { + D2D1_SVG_LINE_CAP_BUTT = D2D1_CAP_STYLE_FLAT, + D2D1_SVG_LINE_CAP_SQUARE = D2D1_CAP_STYLE_SQUARE, + D2D1_SVG_LINE_CAP_ROUND = D2D1_CAP_STYLE_ROUND, +}} +ENUM!{enum D2D1_SVG_LINE_JOIN { + D2D1_SVG_LINE_JOIN_BEVEL = D2D1_LINE_JOIN_BEVEL, + D2D1_SVG_LINE_JOIN_MITER = D2D1_LINE_JOIN_MITER_OR_BEVEL, + D2D1_SVG_LINE_JOIN_ROUND = D2D1_LINE_JOIN_ROUND, +}} +ENUM!{enum D2D1_SVG_ASPECT_ALIGN { + D2D1_SVG_ASPECT_ALIGN_NONE = 0, + D2D1_SVG_ASPECT_ALIGN_X_MIN_Y_MIN = 1, + D2D1_SVG_ASPECT_ALIGN_X_MID_Y_MIN = 2, + D2D1_SVG_ASPECT_ALIGN_X_MAX_Y_MIN = 3, + D2D1_SVG_ASPECT_ALIGN_X_MIN_Y_MID = 4, + D2D1_SVG_ASPECT_ALIGN_X_MID_Y_MID = 5, + D2D1_SVG_ASPECT_ALIGN_X_MAX_Y_MID = 6, + D2D1_SVG_ASPECT_ALIGN_X_MIN_Y_MAX = 7, + D2D1_SVG_ASPECT_ALIGN_X_MID_Y_MAX = 8, + D2D1_SVG_ASPECT_ALIGN_X_MAX_Y_MAX = 9, +}} +ENUM!{enum D2D1_SVG_ASPECT_SCALING { + D2D1_SVG_ASPECT_SCALING_MEET = 0, + D2D1_SVG_ASPECT_SCALING_SLICE = 1, +}} +ENUM!{enum D2D1_SVG_PATH_COMMAND { + D2D1_SVG_PATH_COMMAND_CLOSE_PATH = 0, + D2D1_SVG_PATH_COMMAND_MOVE_ABSOLUTE = 1, + D2D1_SVG_PATH_COMMAND_MOVE_RELATIVE = 2, + D2D1_SVG_PATH_COMMAND_LINE_ABSOLUTE = 3, + D2D1_SVG_PATH_COMMAND_LINE_RELATIVE = 4, + D2D1_SVG_PATH_COMMAND_CUBIC_ABSOLUTE = 5, + D2D1_SVG_PATH_COMMAND_CUBIC_RELATIVE = 6, + D2D1_SVG_PATH_COMMAND_QUADRADIC_ABSOLUTE = 7, + D2D1_SVG_PATH_COMMAND_QUADRADIC_RELATIVE = 8, + D2D1_SVG_PATH_COMMAND_ARC_ABSOLUTE = 9, + D2D1_SVG_PATH_COMMAND_ARC_RELATIVE = 10, + D2D1_SVG_PATH_COMMAND_HORIZONTAL_ABSOLUTE = 11, + D2D1_SVG_PATH_COMMAND_HORIZONTAL_RELATIVE = 12, + D2D1_SVG_PATH_COMMAND_VERTICAL_ABSOLUTE = 13, + D2D1_SVG_PATH_COMMAND_VERTICAL_RELATIVE = 14, + D2D1_SVG_PATH_COMMAND_CUBIC_SMOOTH_ABSOLUTE = 15, + D2D1_SVG_PATH_COMMAND_CUBIC_SMOOTH_RELATIVE = 16, + D2D1_SVG_PATH_COMMAND_QUADRADIC_SMOOTH_ABSOLUTE = 17, + D2D1_SVG_PATH_COMMAND_QUADRADIC_SMOOTH_RELATIVE = 18, +}} +ENUM!{enum D2D1_SVG_UNIT_TYPE { + D2D1_SVG_UNIT_TYPE_USER_SPACE_ON_USE = 0, + D2D1_SVG_UNIT_TYPE_OBJECT_BOUNDING_BOX = 1, +}} +ENUM!{enum D2D1_SVG_ATTRIBUTE_STRING_TYPE { + D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG = 0, + D2D1_SVG_ATTRIBUTE_STRING_TYPE_ID = 1, +}} +ENUM!{enum D2D1_SVG_ATTRIBUTE_POD_TYPE { + D2D1_SVG_ATTRIBUTE_POD_TYPE_FLOAT = 0, + D2D1_SVG_ATTRIBUTE_POD_TYPE_COLOR = 1, + D2D1_SVG_ATTRIBUTE_POD_TYPE_FILL_MODE = 2, + D2D1_SVG_ATTRIBUTE_POD_TYPE_DISPLAY = 3, + D2D1_SVG_ATTRIBUTE_POD_TYPE_OVERFLOW = 4, + D2D1_SVG_ATTRIBUTE_POD_TYPE_LINE_CAP = 5, + D2D1_SVG_ATTRIBUTE_POD_TYPE_LINE_JOIN = 6, + D2D1_SVG_ATTRIBUTE_POD_TYPE_VISIBILITY = 7, + D2D1_SVG_ATTRIBUTE_POD_TYPE_MATRIX = 8, + D2D1_SVG_ATTRIBUTE_POD_TYPE_UNIT_TYPE = 9, + D2D1_SVG_ATTRIBUTE_POD_TYPE_EXTEND_MODE = 10, + D2D1_SVG_ATTRIBUTE_POD_TYPE_PRESERVE_ASPECT_RATIO = 11, + D2D1_SVG_ATTRIBUTE_POD_TYPE_VIEWBOX = 12, + D2D1_SVG_ATTRIBUTE_POD_TYPE_LENGTH = 13, +}} +STRUCT!{struct D2D1_SVG_LENGTH { + value: FLOAT, + units: D2D1_SVG_LENGTH_UNITS, +}} +STRUCT!{struct D2D1_SVG_PRESERVE_ASPECT_RATIO { + defer: BOOL, + align: D2D1_SVG_ASPECT_ALIGN, + meetOrSlice: D2D1_SVG_ASPECT_SCALING, +}} +STRUCT!{struct D2D1_SVG_VIEWBOX { + x: FLOAT, + y: FLOAT, + width: FLOAT, + height: FLOAT, +}} +DEFINE_GUID!{IID_ID2D1SvgAttribute, + 0xc9cdb0dd, 0xf8c9, 0x4e70, 0xb7, 0xc2, 0x30, 0x1c, 0x80, 0x29, 0x2c, 0x5e} +DEFINE_GUID!{IID_ID2D1SvgPaint, + 0xd59bab0a, 0x68a2, 0x455b, 0xa5, 0xdc, 0x9e, 0xb2, 0x85, 0x4e, 0x24, 0x90} +DEFINE_GUID!{IID_ID2D1SvgStrokeDashArray, + 0xf1c0ca52, 0x92a3, 0x4f00, 0xb4, 0xce, 0xf3, 0x56, 0x91, 0xef, 0xd9, 0xd9} +DEFINE_GUID!{IID_ID2D1SvgPointCollection, + 0x9dbe4c0d, 0x3572, 0x4dd9, 0x98, 0x25, 0x55, 0x30, 0x81, 0x3b, 0xb7, 0x12} +DEFINE_GUID!{IID_ID2D1SvgPathData, + 0xc095e4f4, 0xbb98, 0x43d6, 0x97, 0x45, 0x4d, 0x1b, 0x84, 0xec, 0x98, 0x88} +DEFINE_GUID!{IID_ID2D1SvgElement, + 0xac7b67a6, 0x183e, 0x49c1, 0xa8, 0x23, 0x0e, 0xbe, 0x40, 0xb0, 0xdb, 0x29} +DEFINE_GUID!{IID_ID2D1SvgDocument, + 0x86b88e4d, 0xafa4, 0x4d7b, 0x88, 0xe4, 0x68, 0xa5, 0x1c, 0x4a, 0x0a, 0xec} +RIDL!{#[uuid(0xc9cdb0dd, 0xf8c9, 0x4e70, 0xb7, 0xc2, 0x30, 0x1c, 0x80, 0x29, 0x2c, 0x5e)] +interface ID2D1SvgAttribute(ID2D1SvgAttributeVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn GetElement( + element: *mut *mut ID2D1SvgElement, + ) -> (), + fn Clone( + attribute: *mut *mut ID2D1SvgAttribute, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd59bab0a, 0x68a2, 0x455b, 0xa5, 0xdc, 0x9e, 0xb2, 0x85, 0x4e, 0x24, 0x90)] +interface ID2D1SvgPaint(ID2D1SvgPaintVtbl): ID2D1SvgAttribute(ID2D1SvgAttributeVtbl) { + fn SetPaintType( + paintType: D2D1_SVG_PAINT_TYPE, + ) -> HRESULT, + fn GetPaintType() -> D2D1_SVG_PAINT_TYPE, + fn SetColor( + color: D2D1_COLOR_F, + ) -> HRESULT, + fn GetColor( + color: *mut D2D1_COLOR_F, + ) -> (), + fn SetId( + id: PCWSTR, + ) -> HRESULT, + fn GetId( + id: PWSTR, + idCount: UINT32, + ) -> HRESULT, + fn GetIdLength() -> UINT32, +}} +RIDL!{#[uuid(0xf1c0ca52, 0x92a3, 0x4f00, 0xb4, 0xce, 0xf3, 0x56, 0x91, 0xef, 0xd9, 0xd9)] +interface ID2D1SvgStrokeDashArray(ID2D1SvgStrokeDashArrayVtbl): + ID2D1SvgAttribute(ID2D1SvgAttributeVtbl) { + fn RemoveDashesAtEnd( + dashesCount: UINT32, + ) -> HRESULT, + fn UpdateDashes_1( + dashes: *const D2D1_SVG_LENGTH, + dashesCount: UINT32, + startIndex: UINT32, + ) -> HRESULT, + fn UpdateDashes_2( + dashes: *const FLOAT, + dashesCount: UINT32, + startIndex: UINT32, + ) -> HRESULT, + fn GetDashes_1( + dashes: *mut D2D1_SVG_LENGTH, + dashesCount: UINT32, + startIndex: UINT32, + ) -> HRESULT, + fn GetDashes_2( + dashes: *mut FLOAT, + dashesCount: UINT32, + startIndex: UINT32, + ) -> HRESULT, + fn GetDashesCount() -> UINT32, +}} +RIDL!{#[uuid(0x9dbe4c0d, 0x3572, 0x4dd9, 0x98, 0x25, 0x55, 0x30, 0x81, 0x3b, 0xb7, 0x12)] +interface ID2D1SvgPointCollection(ID2D1SvgPointCollectionVtbl): + ID2D1SvgAttribute(ID2D1SvgAttributeVtbl) { + fn RemovePointsAtEnd( + pointsCount: UINT32, + ) -> HRESULT, + fn UpdatePoints( + points: *const D2D1_POINT_2F, + pointsCount: UINT32, + startIndex: UINT32, + ) -> HRESULT, + fn GetPoints( + points: *mut D2D1_POINT_2F, + pointsCount: UINT32, + startIndex: UINT32, + ) -> HRESULT, + fn GetPointsCount() -> UINT32, +}} +RIDL!{#[uuid(0xc095e4f4, 0xbb98, 0x43d6, 0x97, 0x45, 0x4d, 0x1b, 0x84, 0xec, 0x98, 0x88)] +interface ID2D1SvgPathData(ID2D1SvgPathDataVtbl): ID2D1SvgAttribute(ID2D1SvgAttributeVtbl) { + fn RemoveSegmentDataAtEnd( + dataCount: UINT32, + ) -> HRESULT, + fn UpdateSegmentData( + data: *const FLOAT, + dataCount: UINT32, + startIndex: UINT32, + ) -> HRESULT, + fn GetSegmentData( + data: *mut FLOAT, + dataCount: UINT32, + startIndex: UINT32, + ) -> HRESULT, + fn GetSegmentDataCount() -> UINT32, + fn RemoveCommandsAtEnd( + commandsCount: UINT32, + ) -> HRESULT, + fn UpdateCommands( + commands: *const D2D1_SVG_PATH_COMMAND, + commandsCount: UINT32, + startIndex: UINT32, + ) -> HRESULT, + fn GetCommands( + commands: *mut D2D1_SVG_PATH_COMMAND, + commandsCount: UINT32, + startIndex: UINT32, + ) -> HRESULT, + fn GetCommandsCount() -> UINT32, + fn CreatePathGeometry( + fillMode: D2D1_FILL_MODE, + pathGeometry: *mut *mut ID2D1PathGeometry1, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xac7b67a6, 0x183e, 0x49c1, 0xa8, 0x23, 0x0e, 0xbe, 0x40, 0xb0, 0xdb, 0x29)] +interface ID2D1SvgElement(ID2D1SvgElementVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn GetDocument( + document: *mut *mut ID2D1SvgDocument, + ) -> (), + fn GetTagName( + name: PWSTR, + nameCount: UINT32, + ) -> HRESULT, + fn GetTagNameLength() -> UINT32, + fn IsTextContent() -> BOOL, + fn GetParent( + parent: *mut *mut ID2D1SvgElement, + ) -> (), + fn HasChildren() -> BOOL, + fn GetFirstChild( + child: *mut *mut ID2D1SvgElement, + ) -> (), + fn GetLastChild( + child: *mut *mut ID2D1SvgElement, + ) -> (), + fn GetPreviousChild( + referenceChild: *mut ID2D1SvgElement, + previousChild: *mut *mut ID2D1SvgElement, + ) -> HRESULT, + fn GetNextChild( + referenceChild: *mut ID2D1SvgElement, + nextChild: *mut *mut ID2D1SvgElement, + ) -> HRESULT, + fn InsertChildBefore( + newChild: *mut ID2D1SvgElement, + referenceChild: *mut ID2D1SvgElement, + ) -> HRESULT, + fn AppendChild( + newChild: *mut ID2D1SvgElement, + ) -> HRESULT, + fn ReplaceChild( + newChild: *mut ID2D1SvgElement, + oldChild: *mut ID2D1SvgElement, + ) -> HRESULT, + fn RemoveChild( + oldChild: *mut ID2D1SvgElement, + ) -> HRESULT, + fn IsAttributeSpecified( + name: PCWSTR, inherited: *mut BOOL, + ) -> BOOL, + fn GetSpecifiedAttributeCount() -> UINT32, + fn GetSpecifiedAttributeName( + index: UINT32, + name: PWSTR, + nameCount: UINT32, + inherited: *mut BOOL, + ) -> HRESULT, + fn GetSpecifiedAttributeNameLength( + index: UINT32, + nameLength: *mut UINT32, + inherited: *mut BOOL, + ) -> HRESULT, + fn RemoveAttribute( + name: PCWSTR, + ) -> HRESULT, + fn SetTextValue( + name: *const WCHAR, + nameCount: UINT32, + ) -> HRESULT, + fn GetTextValue( + name: PWSTR, + nameCount: UINT32, + ) -> HRESULT, + fn GetTextValueLength() -> UINT32, + fn SetAttributeValue_1( + name: PCWSTR, + value: *mut ID2D1SvgAttribute, + ) -> HRESULT, + fn SetAttributeValue_2( + name: PCWSTR, + type_: D2D1_SVG_ATTRIBUTE_POD_TYPE, + value: *const c_void, + valueSizeInBytes: UINT32, + ) -> HRESULT, + fn SetAttributeValue_3( + name: PCWSTR, + type_: D2D1_SVG_ATTRIBUTE_STRING_TYPE, + value: PCWSTR, + ) -> HRESULT, + fn GetAttributeValue_1( + name: PCWSTR, + riid: REFIID, + value: *mut *mut c_void, + ) -> HRESULT, + fn GetAttributeValue_2( + name: PCWSTR, + type_: D2D1_SVG_ATTRIBUTE_POD_TYPE, + value: *mut c_void, + valueSizeInBytes: UINT32, + ) -> HRESULT, + fn GetAttributeValue_3( + name: PCWSTR, + type_: D2D1_SVG_ATTRIBUTE_STRING_TYPE, + value: PWSTR, + valueCount: UINT32, + ) -> HRESULT, + fn GetAttributeValueLength( + name: PCWSTR, + type_: D2D1_SVG_ATTRIBUTE_STRING_TYPE, + valueLength: *mut UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x86b88e4d, 0xafa4, 0x4d7b, 0x88, 0xe4, 0x68, 0xa5, 0x1c, 0x4a, 0x0a, 0xec)] +interface ID2D1SvgDocument(ID2D1SvgDocumentVtbl): ID2D1Resource(ID2D1ResourceVtbl) { + fn SetViewportSize( + viewportSize: D2D1_SIZE_F, + ) -> HRESULT, + fn GetViewportSize() -> D2D1_SIZE_F, + fn SetRoot( + root: *mut ID2D1SvgElement, + ) -> HRESULT, + fn GetRoot( + root: *mut *mut ID2D1SvgElement, + ) -> (), + fn FindElementById( + id: PCWSTR, + svgElement: *mut *mut ID2D1SvgElement, + ) -> HRESULT, + fn Serialize( + outputXmlStream: *mut IStream, + subtree: *mut ID2D1SvgElement, + ) -> HRESULT, + fn Deserialize( + inputXmlStream: *mut IStream, + subtree: *mut *mut ID2D1SvgElement, + ) -> HRESULT, + fn CreatePaint( + paintType: D2D1_SVG_PAINT_TYPE, + color: *const D2D1_COLOR_F, + id: PCWSTR, + paint: *mut *mut ID2D1SvgPaint, + ) -> HRESULT, + fn CreateStrokeDashArray( + dashes: *const D2D1_SVG_LENGTH, + dashesCount: UINT32, + strokeDashArray: *mut *mut ID2D1SvgStrokeDashArray, + ) -> HRESULT, + fn CreatePointCollection( + points: *const D2D1_POINT_2F, + pountsCount: UINT32, + pointCollection: *mut ID2D1SvgPointCollection, + ) -> HRESULT, + fn CreatePathData( + segmentData: *const FLOAT, + segmentDataCount: UINT32, + commands: *const D2D1_SVG_PATH_COMMAND, + commandsCount: UINT32, + pathData: *mut *mut ID2D1SvgPathData, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d2dbasetypes.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2dbasetypes.rs new file mode 100644 index 0000000..754a055 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d2dbasetypes.rs @@ -0,0 +1,15 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of d2dbasetypes.h +use shared::d3d9types::D3DCOLORVALUE; +// FIXME: Remove in next major version +pub use um::dcommon::{ + D2D1_MATRIX_3X2_F, D2D1_POINT_2F, D2D1_POINT_2L, D2D1_POINT_2U, D2D1_RECT_F, D2D1_RECT_L, + D2D1_RECT_U, D2D1_SIZE_F, D2D1_SIZE_U, D2D_MATRIX_3X2_F, D2D_MATRIX_4X3_F, D2D_MATRIX_4X4_F, + D2D_MATRIX_5X4_F, D2D_POINT_2F, D2D_POINT_2L, D2D_POINT_2U, D2D_RECT_F, D2D_RECT_L, D2D_RECT_U, + D2D_SIZE_F, D2D_SIZE_U, D2D_VECTOR_2F, D2D_VECTOR_3F, D2D_VECTOR_4F, +}; +pub type D2D_COLOR_F = D3DCOLORVALUE; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d.rs new file mode 100644 index 0000000..e4b0250 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d.rs @@ -0,0 +1,61 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_IDirect3D, + 0x3bba0080, 0x2421, 0x11cf, 0xa3, 0x1a, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56} +DEFINE_GUID!{IID_IDirect3D2, + 0x6aae1ec1, 0x662a, 0x11d0, 0x88, 0x9d, 0x00, 0xaa, 0x00, 0xbb, 0xb7, 0x6a} +DEFINE_GUID!{IID_IDirect3D3, + 0xbb223240, 0xe72b, 0x11d0, 0xa9, 0xb4, 0x00, 0xaa, 0x00, 0xc0, 0x99, 0x3e} +DEFINE_GUID!{IID_IDirect3D7, + 0xf5049e77, 0x4861, 0x11d2, 0xa4, 0x07, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0xa8} +DEFINE_GUID!{IID_IDirect3DRampDevice, + 0xf2086b20, 0x259f, 0x11cf, 0xa3, 0x1a, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56} +DEFINE_GUID!{IID_IDirect3DRGBDevice, + 0xa4665c60, 0x2673, 0x11cf, 0xa3, 0x1a, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56} +DEFINE_GUID!{IID_IDirect3DHALDevice, + 0x84e63de0, 0x46aa, 0x11cf, 0x81, 0x6f, 0x00, 0x00, 0xc0, 0x20, 0x15, 0x6e} +DEFINE_GUID!{IID_IDirect3DMMXDevice, + 0x881949a1, 0xd6f3, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29} +DEFINE_GUID!{IID_IDirect3DRefDevice, + 0x50936643, 0x13e9, 0x11d1, 0x89, 0xaa, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29} +DEFINE_GUID!{IID_IDirect3DNullDevice, + 0x8767df22, 0xbacc, 0x11d1, 0x89, 0x69, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0xa8} +DEFINE_GUID!{IID_IDirect3DTnLHalDevice, + 0xf5049e78, 0x4861, 0x11d2, 0xa4, 0x07, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0xa8} +DEFINE_GUID!{IID_IDirect3DDevice, + 0x64108800, 0x957d, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29} +DEFINE_GUID!{IID_IDirect3DDevice2, + 0x93281501, 0x8cf8, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29} +DEFINE_GUID!{IID_IDirect3DDevice3, + 0xb0ab3b60, 0x33d7, 0x11d1, 0xa9, 0x81, 0x00, 0xc0, 0x4f, 0xd7, 0xb1, 0x74} +DEFINE_GUID!{IID_IDirect3DDevice7, + 0xf5049e79, 0x4861, 0x11d2, 0xa4, 0x07, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0xa8} +DEFINE_GUID!{IID_IDirect3DTexture, + 0x2cdcd9e0, 0x25a0, 0x11cf, 0xa3, 0x1a, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56} +DEFINE_GUID!{IID_IDirect3DTexture2, + 0x93281502, 0x8cf8, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29} +DEFINE_GUID!{IID_IDirect3DLight, + 0x4417c142, 0x33ad, 0x11cf, 0x81, 0x6f, 0x00, 0x00, 0xc0, 0x20, 0x15, 0x6e} +DEFINE_GUID!{IID_IDirect3DMaterial, + 0x4417c144, 0x33ad, 0x11cf, 0x81, 0x6f, 0x00, 0x00, 0xc0, 0x20, 0x15, 0x6e} +DEFINE_GUID!{IID_IDirect3DIndexBuffer8, + 0x0e689c9a, 0x053d, 0x44a0, 0x9d, 0x92, 0xdb, 0x0e, 0x3d, 0x75, 0x0f, 0x86} +DEFINE_GUID!{IID_IDirect3DMaterial2, + 0x93281503, 0x8cf8, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29} +DEFINE_GUID!{IID_IDirect3DMaterial3, + 0xca9c46f4, 0xd3c5, 0x11d1, 0xb7, 0x5a, 0x00, 0x60, 0x08, 0x52, 0xb3, 0x12} +DEFINE_GUID!{IID_IDirect3DExecuteBuffer, + 0x4417c145, 0x33ad, 0x11cf, 0x81, 0x6f, 0x00, 0x00, 0xc0, 0x20, 0x15, 0x6e} +DEFINE_GUID!{IID_IDirect3DViewport, + 0x4417c146, 0x33ad, 0x11cf, 0x81, 0x6f, 0x00, 0x00, 0xc0, 0x20, 0x15, 0x6e} +DEFINE_GUID!{IID_IDirect3DViewport2, + 0x93281500, 0x8cf8, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29} +DEFINE_GUID!{IID_IDirect3DViewport3, + 0xb0ab3b61, 0x33d7, 0x11d1, 0xa9, 0x81, 0x00, 0xc0, 0x4f, 0xd7, 0xb1, 0x74} +DEFINE_GUID!{IID_IDirect3DVertexBuffer, + 0x7a503555, 0x4a83, 0x11d1, 0xa5, 0xdb, 0x00, 0xa0, 0xc9, 0x03, 0x67, 0xf8} +DEFINE_GUID!{IID_IDirect3DVertexBuffer7, + 0xf5049e7d, 0x4861, 0x11d2, 0xa4, 0x07, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0xa8} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10.rs new file mode 100644 index 0000000..887b7a3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10.rs @@ -0,0 +1,57 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use um::d3dcommon::{D3D_PRIMITIVE, D3D_PRIMITIVE_TOPOLOGY, D3D_SRV_DIMENSION}; +pub type D3D10_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY; +pub type D3D10_PRIMITIVE = D3D_PRIMITIVE; +pub type D3D10_SRV_DIMENSION = D3D_SRV_DIMENSION; +DEFINE_GUID!{IID_ID3D10DeviceChild, + 0x9b7e4c00, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10DepthStencilState, + 0x2b4b1cc8, 0xa4ad, 0x41f8, 0x83, 0x22, 0xca, 0x86, 0xfc, 0x3e, 0xc6, 0x75} +DEFINE_GUID!{IID_ID3D10BlendState, + 0xedad8d19, 0x8a35, 0x4d6d, 0x85, 0x66, 0x2e, 0xa2, 0x76, 0xcd, 0xe1, 0x61} +DEFINE_GUID!{IID_ID3D10RasterizerState, + 0xa2a07292, 0x89af, 0x4345, 0xbe, 0x2e, 0xc5, 0x3d, 0x9f, 0xbb, 0x6e, 0x9f} +DEFINE_GUID!{IID_ID3D10Resource, + 0x9b7e4c01, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Buffer, + 0x9b7e4c02, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Texture1D, + 0x9b7e4c03, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Texture2D, + 0x9b7e4c04, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Texture3D, + 0x9b7e4c05, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10View, + 0xc902b03f, 0x60a7, 0x49ba, 0x99, 0x36, 0x2a, 0x3a, 0xb3, 0x7a, 0x7e, 0x33} +DEFINE_GUID!{IID_ID3D10ShaderResourceView, + 0x9b7e4c07, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10RenderTargetView, + 0x9b7e4c08, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10DepthStencilView, + 0x9b7e4c09, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10VertexShader, + 0x9b7e4c0a, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10GeometryShader, + 0x6316be88, 0x54cd, 0x4040, 0xab, 0x44, 0x20, 0x46, 0x1b, 0xc8, 0x1f, 0x68} +DEFINE_GUID!{IID_ID3D10PixelShader, + 0x4968b601, 0x9d00, 0x4cde, 0x83, 0x46, 0x8e, 0x7f, 0x67, 0x58, 0x19, 0xb6} +DEFINE_GUID!{IID_ID3D10InputLayout, + 0x9b7e4c0b, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10SamplerState, + 0x9b7e4c0c, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Asynchronous, + 0x9b7e4c0d, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Query, + 0x9b7e4c0e, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Predicate, + 0x9b7e4c10, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Counter, + 0x9b7e4c11, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Device, + 0x9b7e4c0f, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Multithread, + 0x9b7e4e00, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10_1.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10_1.rs new file mode 100644 index 0000000..3765ce3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10_1.rs @@ -0,0 +1,11 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_ID3D10BlendState1, + 0xedad8d99, 0x8a35, 0x4d6d, 0x85, 0x66, 0x2e, 0xa2, 0x76, 0xcd, 0xe1, 0x61} +DEFINE_GUID!{IID_ID3D10ShaderResourceView1, + 0x9b7e4c87, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10Device1, + 0x9b7e4c8f, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10_1shader.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10_1shader.rs new file mode 100644 index 0000000..69d9583 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10_1shader.rs @@ -0,0 +1,7 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_ID3D10ShaderReflection1, + 0xc3457783, 0xa846, 0x47ce, 0x95, 0x20, 0xce, 0xa6, 0xf6, 0x6e, 0x74, 0x47} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10effect.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10effect.rs new file mode 100644 index 0000000..de93ace --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10effect.rs @@ -0,0 +1,45 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_ID3D10StateBlock, + 0x0803425a, 0x57f5, 0x4dd6, 0x94, 0x65, 0xa8, 0x75, 0x70, 0x83, 0x4a, 0x08} +DEFINE_GUID!{IID_ID3D10EffectType, + 0x4e9e1ddc, 0xcd9d, 0x4772, 0xa8, 0x37, 0x00, 0x18, 0x0b, 0x9b, 0x88, 0xfd} +DEFINE_GUID!{IID_ID3D10EffectVariable, + 0xae897105, 0x00e6, 0x45bf, 0xbb, 0x8e, 0x28, 0x1d, 0xd6, 0xdb, 0x8e, 0x1b} +DEFINE_GUID!{IID_ID3D10EffectScalarVariable, + 0x00e48f7b, 0xd2c8, 0x49e8, 0xa8, 0x6c, 0x02, 0x2d, 0xee, 0x53, 0x43, 0x1f} +DEFINE_GUID!{IID_ID3D10EffectVectorVariable, + 0x62b98c44, 0x1f82, 0x4c67, 0xbc, 0xd0, 0x72, 0xcf, 0x8f, 0x21, 0x7e, 0x81} +DEFINE_GUID!{IID_ID3D10EffectMatrixVariable, + 0x50666c24, 0xb82f, 0x4eed, 0xa1, 0x72, 0x5b, 0x6e, 0x7e, 0x85, 0x22, 0xe0} +DEFINE_GUID!{IID_ID3D10EffectStringVariable, + 0x71417501, 0x8df9, 0x4e0a, 0xa7, 0x8a, 0x25, 0x5f, 0x97, 0x56, 0xba, 0xff} +DEFINE_GUID!{IID_ID3D10EffectShaderResourceVariable, + 0xc0a7157b, 0xd872, 0x4b1d, 0x80, 0x73, 0xef, 0xc2, 0xac, 0xd4, 0xb1, 0xfc} +DEFINE_GUID!{IID_ID3D10EffectRenderTargetViewVariable, + 0x28ca0cc3, 0xc2c9, 0x40bb, 0xb5, 0x7f, 0x67, 0xb7, 0x37, 0x12, 0x2b, 0x17} +DEFINE_GUID!{IID_ID3D10EffectDepthStencilViewVariable, + 0x3e02c918, 0xcc79, 0x4985, 0xb6, 0x22, 0x2d, 0x92, 0xad, 0x70, 0x16, 0x23} +DEFINE_GUID!{IID_ID3D10EffectConstantBuffer, + 0x56648f4d, 0xcc8b, 0x4444, 0xa5, 0xad, 0xb5, 0xa3, 0xd7, 0x6e, 0x91, 0xb3} +DEFINE_GUID!{IID_ID3D10EffectShaderVariable, + 0x80849279, 0xc799, 0x4797, 0x8c, 0x33, 0x04, 0x07, 0xa0, 0x7d, 0x9e, 0x06} +DEFINE_GUID!{IID_ID3D10EffectBlendVariable, + 0x1fcd2294, 0xdf6d, 0x4eae, 0x86, 0xb3, 0x0e, 0x91, 0x60, 0xcf, 0xb0, 0x7b} +DEFINE_GUID!{IID_ID3D10EffectDepthStencilVariable, + 0xaf482368, 0x330a, 0x46a5, 0x9a, 0x5c, 0x01, 0xc7, 0x1a, 0xf2, 0x4c, 0x8d} +DEFINE_GUID!{IID_ID3D10EffectRasterizerVariable, + 0x21af9f0e, 0x4d94, 0x4ea9, 0x97, 0x85, 0x2c, 0xb7, 0x6b, 0x8c, 0x0b, 0x34} +DEFINE_GUID!{IID_ID3D10EffectSamplerVariable, + 0x6530d5c7, 0x07e9, 0x4271, 0xa4, 0x18, 0xe7, 0xce, 0x4b, 0xd1, 0xe4, 0x80} +DEFINE_GUID!{IID_ID3D10EffectPass, + 0x5cfbeb89, 0x1a06, 0x46e0, 0xb2, 0x82, 0xe3, 0xf9, 0xbf, 0xa3, 0x6a, 0x54} +DEFINE_GUID!{IID_ID3D10EffectTechnique, + 0xdb122ce8, 0xd1c9, 0x4292, 0xb2, 0x37, 0x24, 0xed, 0x3d, 0xe8, 0xb1, 0x75} +DEFINE_GUID!{IID_ID3D10Effect, + 0x51b0ca8b, 0xec0b, 0x4519, 0x87, 0x0d, 0x8e, 0xe1, 0xcb, 0x50, 0x17, 0xc7} +DEFINE_GUID!{IID_ID3D10EffectPool, + 0x9537ab04, 0x3250, 0x412e, 0x82, 0x13, 0xfc, 0xd2, 0xf8, 0x67, 0x79, 0x33} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10misc.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10misc.rs new file mode 100644 index 0000000..5303f2e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10misc.rs @@ -0,0 +1,7 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{GUID_DeviceType, + 0xd722fb4d, 0x7a68, 0x437a, 0xb2, 0x0c, 0x58, 0x04, 0xee, 0x24, 0x94, 0xa6} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10sdklayers.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10sdklayers.rs new file mode 100644 index 0000000..d71c483 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10sdklayers.rs @@ -0,0 +1,13 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{DXGI_DEBUG_D3D10, + 0x243b4c52, 0x3606, 0x4d3a, 0x99, 0xd7, 0xa7, 0xe7, 0xb3, 0x3e, 0xd7, 0x06} +DEFINE_GUID!{IID_ID3D10Debug, + 0x9b7e4e01, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10SwitchToRef, + 0x9b7e4e02, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} +DEFINE_GUID!{IID_ID3D10InfoQueue, + 0x1b940b17, 0x2642, 0x4d1f, 0xab, 0x1f, 0xb9, 0x9b, 0xad, 0x0c, 0x39, 0x5f} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10shader.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10shader.rs new file mode 100644 index 0000000..952fd6d --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d10shader.rs @@ -0,0 +1,206 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +use shared::minwindef::{BYTE, LPVOID, UINT}; +use um::d3d10::{D3D10_PRIMITIVE_TOPOLOGY, D3D10_SRV_DIMENSION}; +use um::d3dcommon::{ + D3D_CBUFFER_TYPE, D3D_INCLUDE_TYPE, D3D_NAME, D3D_REGISTER_COMPONENT_TYPE, + D3D_RESOURCE_RETURN_TYPE, D3D_SHADER_CBUFFER_FLAGS, D3D_SHADER_INPUT_FLAGS, + D3D_SHADER_INPUT_TYPE, D3D_SHADER_MACRO, D3D_SHADER_VARIABLE_CLASS, D3D_SHADER_VARIABLE_FLAGS, + D3D_SHADER_VARIABLE_TYPE, ID3DInclude, +}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCSTR}; +pub const D3D10_SHADER_DEBUG: UINT = 1 << 0; +pub const D3D10_SHADER_SKIP_VALIDATION: UINT = 1 << 1; +pub const D3D10_SHADER_SKIP_OPTIMIZATION: UINT = 1 << 2; +pub const D3D10_SHADER_PACK_MATRIX_ROW_MAJOR: UINT = 1 << 3; +pub const D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR: UINT = 1 << 4; +pub const D3D10_SHADER_PARTIAL_PRECISION: UINT = 1 << 5; +pub const D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT: UINT = 1 << 6; +pub const D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT: UINT = 1 << 7; +pub const D3D10_SHADER_NO_PRESHADER: UINT = 1 << 8; +pub const D3D10_SHADER_AVOID_FLOW_CONTROL: UINT = 1 << 9; +pub const D3D10_SHADER_PREFER_FLOW_CONTROL: UINT = 1 << 10; +pub const D3D10_SHADER_ENABLE_STRICTNESS: UINT = 1 << 11; +pub const D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY: UINT = 1 << 12; +pub const D3D10_SHADER_IEEE_STRICTNESS: UINT = 1 << 13; +pub const D3D10_SHADER_WARNINGS_ARE_ERRORS: UINT = 1 << 18; +pub const D3D10_SHADER_RESOURCES_MAY_ALIAS: UINT = 1 << 19; +pub const D3D10_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES: UINT = 1 << 20; +pub const D3D10_ALL_RESOURCES_BOUND: UINT = 1 << 21; +pub const D3D10_SHADER_OPTIMIZATION_LEVEL0: UINT = 1 << 14; +pub const D3D10_SHADER_OPTIMIZATION_LEVEL1: UINT = 0; +pub const D3D10_SHADER_OPTIMIZATION_LEVEL2: UINT = (1 << 14) | (1 << 15); +pub const D3D10_SHADER_OPTIMIZATION_LEVEL3: UINT = 1 << 15; +pub const D3D10_SHADER_FLAGS2_FORCE_ROOT_SIGNATURE_LATEST: UINT = 0; +pub const D3D10_SHADER_FLAGS2_FORCE_ROOT_SIGNATURE_1_0: UINT = 1 << 4; +pub const D3D10_SHADER_FLAGS2_FORCE_ROOT_SIGNATURE_1_1: UINT = 1 << 5; +pub type D3D10_SHADER_MACRO = D3D_SHADER_MACRO; +pub type LPD3D10_SHADER_MACRO = *mut D3D10_SHADER_MACRO; +pub type D3D10_SHADER_VARIABLE_CLASS = D3D_SHADER_VARIABLE_CLASS; +pub type LPD3D10_SHADER_VARIABLE_CLASS = *mut D3D10_SHADER_VARIABLE_CLASS; +pub type D3D10_SHADER_VARIABLE_FLAGS = D3D_SHADER_VARIABLE_FLAGS; +pub type LPD3D10_SHADER_VARIABLE_FLAGS = *mut D3D10_SHADER_VARIABLE_FLAGS; +pub type D3D10_SHADER_VARIABLE_TYPE = D3D_SHADER_VARIABLE_TYPE; +pub type LPD3D10_SHADER_VARIABLE_TYPE = *mut D3D10_SHADER_VARIABLE_TYPE; +pub type D3D10_SHADER_INPUT_FLAGS = D3D_SHADER_INPUT_FLAGS; +pub type LPD3D10_SHADER_INPUT_FLAGS = *mut D3D10_SHADER_INPUT_FLAGS; +pub type D3D10_SHADER_INPUT_TYPE = D3D_SHADER_INPUT_TYPE; +pub type LPD3D10_SHADER_INPUT_TYPE = *mut D3D10_SHADER_INPUT_TYPE; +pub type D3D10_SHADER_CBUFFER_FLAGS = D3D_SHADER_CBUFFER_FLAGS; +pub type LPD3D10_SHADER_CBUFFER_FLAGS = *mut D3D10_SHADER_CBUFFER_FLAGS; +pub type D3D10_CBUFFER_TYPE = D3D_CBUFFER_TYPE; +pub type LPD3D10_CBUFFER_TYPE = *mut D3D10_CBUFFER_TYPE; +pub type D3D10_NAME = D3D_NAME; +pub type D3D10_RESOURCE_RETURN_TYPE = D3D_RESOURCE_RETURN_TYPE; +pub type D3D10_REGISTER_COMPONENT_TYPE = D3D_REGISTER_COMPONENT_TYPE; +pub type D3D10_INCLUDE_TYPE = D3D_INCLUDE_TYPE; +pub type ID3D10Include = ID3DInclude; +pub type LPD3D10INCLUDE = *mut ID3DInclude; +// const IID_ID3D10Include: IID = IID_ID3DInclude; +STRUCT!{struct D3D10_SHADER_DESC { + Version: UINT, + Creator: LPCSTR, + Flags: UINT, + ConstantBuffers: UINT, + BoundResources: UINT, + InputParameters: UINT, + OutputParameters: UINT, + InstructionCount: UINT, + TempRegisterCount: UINT, + TempArrayCount: UINT, + DefCount: UINT, + DclCount: UINT, + TextureNormalInstructions: UINT, + TextureLoadInstructions: UINT, + TextureCompInstructions: UINT, + TextureBiasInstructions: UINT, + TextureGradientInstructions: UINT, + FloatInstructionCount: UINT, + IntInstructionCount: UINT, + UintInstructionCount: UINT, + StaticFlowControlCount: UINT, + DynamicFlowControlCount: UINT, + MacroInstructionCount: UINT, + ArrayInstructionCount: UINT, + CutInstructionCount: UINT, + EmitInstructionCount: UINT, + GSOutputTopology: D3D10_PRIMITIVE_TOPOLOGY, + GSMaxOutputVertexCount: UINT, +}} +STRUCT!{struct D3D10_SHADER_BUFFER_DESC { + Name: LPCSTR, + Type: D3D10_CBUFFER_TYPE, + Variables: UINT, + Size: UINT, + uFlags: UINT, +}} +STRUCT!{struct D3D10_SHADER_VARIABLE_DESC { + Name: LPCSTR, + StartOffset: UINT, + Size: UINT, + uFlags: UINT, + DefaultValue: LPVOID, +}} +STRUCT!{struct D3D10_SHADER_TYPE_DESC { + Class: D3D10_SHADER_VARIABLE_CLASS, + Type: D3D10_SHADER_VARIABLE_TYPE, + Rows: UINT, + Columns: UINT, + Elements: UINT, + Members: UINT, + Offset: UINT, +}} +STRUCT!{struct D3D10_SHADER_INPUT_BIND_DESC { + Name: LPCSTR, + Type: D3D10_SHADER_INPUT_TYPE, + BindPoint: UINT, + BindCount: UINT, + uFlags: UINT, + ReturnType: D3D10_RESOURCE_RETURN_TYPE, + Dimension: D3D10_SRV_DIMENSION, + NumSamples: UINT, +}} +STRUCT!{struct D3D10_SIGNATURE_PARAMETER_DESC { + SemanticName: LPCSTR, + SemanticIndex: UINT, + Register: UINT, + SystemValueType: D3D10_NAME, + ComponentType: D3D10_REGISTER_COMPONENT_TYPE, + Mask: BYTE, + ReadWriteMask: BYTE, +}} +pub type LPD3D10SHADERREFLECTIONTYPE = *mut ID3D10ShaderReflectionType; +DEFINE_GUID!{IID_ID3D10ShaderReflectionType, + 0xc530ad7d, 0x9b16, 0x4395, 0xa9, 0x79, 0xba, 0x2e, 0xcf, 0xf8, 0x3a, 0xdd} +RIDL!{#[uuid(0xc530ad7d, 0x9b16, 0x4395, 0xa9, 0x79, 0xba, 0x2e, 0xcf, 0xf8, 0x3a, 0xdd)] +interface ID3D10ShaderReflectionType(ID3D10ShaderReflectionTypeVtbl) { + fn GetDesc( + pDesc: *mut D3D10_SHADER_TYPE_DESC, + ) -> HRESULT, + fn GetMemberTypeByIndex( + Index: UINT, + ) -> *mut ID3D10ShaderReflectionType, + fn GetMemberTypeByName( + Name: LPCSTR, + ) -> *mut ID3D10ShaderReflectionType, + fn GetMemberTypeName( + Index: UINT, + ) -> LPCSTR, +}} +pub type LPD3D10SHADERREFLECTIONVARIABLE = *mut ID3D10ShaderReflectionVariable; +DEFINE_GUID!{IID_ID3D10ShaderReflectionVariable, + 0x1bf63c95, 0x2650, 0x405d, 0x99, 0xc1, 0x36, 0x36, 0xbd, 0x1d, 0xa0, 0xa1} +RIDL!{#[uuid(0x1bf63c95, 0x2650, 0x405d, 0x99, 0xc1, 0x36, 0x36, 0xbd, 0x1d, 0xa0, 0xa1)] +interface ID3D10ShaderReflectionVariable(ID3D10ShaderReflectionVariableVtbl) { + fn GetDesc( + pDesc: *mut D3D10_SHADER_VARIABLE_DESC, + ) -> HRESULT, + fn GetType() -> *mut ID3D10ShaderReflectionType, +}} +pub type LPD3D10SHADERREFLECTIONCONSTANTBUFFER = *mut ID3D10ShaderReflectionConstantBuffer; +DEFINE_GUID!{IID_ID3D10ShaderReflectionConstantBuffer, + 0x66c66a94, 0xdddd, 0x4b62, 0xa6, 0x6a, 0xf0, 0xda, 0x33, 0xc2, 0xb4, 0xd0} +RIDL!{#[uuid(0x66c66a94, 0xdddd, 0x4b62, 0xa6, 0x6a, 0xf0, 0xda, 0x33, 0xc2, 0xb4, 0xd0)] +interface ID3D10ShaderReflectionConstantBuffer(ID3D10ShaderReflectionConstantBufferVtbl) { + fn GetDesc( + pDesc: *mut D3D10_SHADER_BUFFER_DESC, + ) -> HRESULT, + fn GetVariableByIndex( + Index: UINT, + ) -> *mut ID3D10ShaderReflectionVariable, + fn GetVariableByName( + Name: LPCSTR, + ) -> *mut ID3D10ShaderReflectionVariable, +}} +pub type LPD3D10SHADERREFLECTION = *mut ID3D10ShaderReflection; +DEFINE_GUID!{IID_ID3D10ShaderReflection, + 0xd40e20b6, 0xf8f7, 0x42ad, 0xab, 0x20, 0x4b, 0xaf, 0x8f, 0x15, 0xdf, 0xaa} +RIDL!{#[uuid(0xd40e20b6, 0xf8f7, 0x42ad, 0xab, 0x20, 0x4b, 0xaf, 0x8f, 0x15, 0xdf, 0xaa)] +interface ID3D10ShaderReflection(ID3D10ShaderReflectionVtbl): IUnknown(IUnknownVtbl) { + fn GetDesc( + pDesc: *mut D3D10_SHADER_DESC, + ) -> HRESULT, + fn GetConstantBufferByIndex( + Index: UINT, + ) -> *mut ID3D10ShaderReflectionConstantBuffer, + fn GetConstantBufferByName( + Name: LPCSTR, + ) -> *mut ID3D10ShaderReflectionConstantBuffer, + fn GetResourceBindingDesc( + ResourceIndex: UINT, + pDesc: *mut D3D10_SHADER_INPUT_BIND_DESC, + ) -> HRESULT, + fn GetInputParameterDesc( + ParameterIndex: UINT, + pDesc: *mut D3D10_SIGNATURE_PARAMETER_DESC, + ) -> HRESULT, + fn GetOutputParameterDesc( + ParameterIndex: UINT, + pDesc: *mut D3D10_SIGNATURE_PARAMETER_DESC, + ) -> HRESULT, +}} +// TODO Some functions diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11.rs new file mode 100644 index 0000000..d6e306a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11.rs @@ -0,0 +1,3420 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_float, c_int, c_long, c_void}; +use shared::basetsd::{SIZE_T, UINT64, UINT8}; +use shared::dxgi::{DXGI_SWAP_CHAIN_DESC, IDXGIAdapter, IDXGISwapChain}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::dxgitype::{DXGI_RATIONAL, DXGI_SAMPLE_DESC}; +use shared::guiddef::{GUID, REFGUID, REFIID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, HMODULE, INT, UINT, USHORT}; +use shared::windef::{RECT, SIZE}; +use um::d3dcommon::{ + D3D_DRIVER_TYPE, D3D_FEATURE_LEVEL, D3D_PRIMITIVE, D3D_PRIMITIVE_TOPOLOGY, D3D_SRV_DIMENSION, +}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, LPCSTR, LPSTR, ULONGLONG}; +pub const D3D11_16BIT_INDEX_STRIP_CUT_VALUE: DWORD = 0xffff; +pub const D3D11_32BIT_INDEX_STRIP_CUT_VALUE: DWORD = 0xffffffff; +pub const D3D11_8BIT_INDEX_STRIP_CUT_VALUE: DWORD = 0xff; +pub const D3D11_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT: DWORD = 9; +pub const D3D11_CLIP_OR_CULL_DISTANCE_COUNT: DWORD = 8; +pub const D3D11_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT: DWORD = 2; +pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT: DWORD = 14; +pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS: DWORD = 4; +pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT: DWORD = 15; +pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_PARTIAL_UPDATE_EXTENTS_BYTE_ALIGNMENT: DWORD = 16; +pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT: DWORD = 15; +pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST: DWORD = 1; +pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT: DWORD = 64; +pub const D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT: DWORD = 1; +pub const D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST: DWORD = 1; +pub const D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT: DWORD = 128; +pub const D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST: DWORD = 1; +pub const D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT: DWORD = 128; +pub const D3D11_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_COMMONSHADER_SAMPLER_REGISTER_COUNT: DWORD = 16; +pub const D3D11_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST: DWORD = 1; +pub const D3D11_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT: DWORD = 16; +pub const D3D11_COMMONSHADER_SUBROUTINE_NESTING_LIMIT: DWORD = 32; +pub const D3D11_COMMONSHADER_TEMP_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_COMMONSHADER_TEMP_REGISTER_COUNT: DWORD = 4096; +pub const D3D11_COMMONSHADER_TEMP_REGISTER_READS_PER_INST: DWORD = 3; +pub const D3D11_COMMONSHADER_TEMP_REGISTER_READ_PORTS: DWORD = 3; +pub const D3D11_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX: DWORD = 10; +pub const D3D11_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN: c_long = -10; +pub const D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE: c_long = -8; +pub const D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE: DWORD = 7; +pub const D3D11_CS_4_X_BUCKET00_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 256; +pub const D3D11_CS_4_X_BUCKET00_MAX_NUM_THREADS_PER_GROUP: DWORD = 64; +pub const D3D11_CS_4_X_BUCKET01_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 240; +pub const D3D11_CS_4_X_BUCKET01_MAX_NUM_THREADS_PER_GROUP: DWORD = 68; +pub const D3D11_CS_4_X_BUCKET02_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 224; +pub const D3D11_CS_4_X_BUCKET02_MAX_NUM_THREADS_PER_GROUP: DWORD = 72; +pub const D3D11_CS_4_X_BUCKET03_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 208; +pub const D3D11_CS_4_X_BUCKET03_MAX_NUM_THREADS_PER_GROUP: DWORD = 76; +pub const D3D11_CS_4_X_BUCKET04_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 192; +pub const D3D11_CS_4_X_BUCKET04_MAX_NUM_THREADS_PER_GROUP: DWORD = 84; +pub const D3D11_CS_4_X_BUCKET05_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 176; +pub const D3D11_CS_4_X_BUCKET05_MAX_NUM_THREADS_PER_GROUP: DWORD = 92; +pub const D3D11_CS_4_X_BUCKET06_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 160; +pub const D3D11_CS_4_X_BUCKET06_MAX_NUM_THREADS_PER_GROUP: DWORD = 100; +pub const D3D11_CS_4_X_BUCKET07_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 144; +pub const D3D11_CS_4_X_BUCKET07_MAX_NUM_THREADS_PER_GROUP: DWORD = 112; +pub const D3D11_CS_4_X_BUCKET08_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 128; +pub const D3D11_CS_4_X_BUCKET08_MAX_NUM_THREADS_PER_GROUP: DWORD = 128; +pub const D3D11_CS_4_X_BUCKET09_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 112; +pub const D3D11_CS_4_X_BUCKET09_MAX_NUM_THREADS_PER_GROUP: DWORD = 144; +pub const D3D11_CS_4_X_BUCKET10_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 96; +pub const D3D11_CS_4_X_BUCKET10_MAX_NUM_THREADS_PER_GROUP: DWORD = 168; +pub const D3D11_CS_4_X_BUCKET11_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 80; +pub const D3D11_CS_4_X_BUCKET11_MAX_NUM_THREADS_PER_GROUP: DWORD = 204; +pub const D3D11_CS_4_X_BUCKET12_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 64; +pub const D3D11_CS_4_X_BUCKET12_MAX_NUM_THREADS_PER_GROUP: DWORD = 256; +pub const D3D11_CS_4_X_BUCKET13_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 48; +pub const D3D11_CS_4_X_BUCKET13_MAX_NUM_THREADS_PER_GROUP: DWORD = 340; +pub const D3D11_CS_4_X_BUCKET14_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 32; +pub const D3D11_CS_4_X_BUCKET14_MAX_NUM_THREADS_PER_GROUP: DWORD = 512; +pub const D3D11_CS_4_X_BUCKET15_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: DWORD = 16; +pub const D3D11_CS_4_X_BUCKET15_MAX_NUM_THREADS_PER_GROUP: DWORD = 768; +pub const D3D11_CS_4_X_DISPATCH_MAX_THREAD_GROUPS_IN_Z_DIMENSION: DWORD = 1; +pub const D3D11_CS_4_X_RAW_UAV_BYTE_ALIGNMENT: DWORD = 256; +pub const D3D11_CS_4_X_THREAD_GROUP_MAX_THREADS_PER_GROUP: DWORD = 768; +pub const D3D11_CS_4_X_THREAD_GROUP_MAX_X: DWORD = 768; +pub const D3D11_CS_4_X_THREAD_GROUP_MAX_Y: DWORD = 768; +pub const D3D11_CS_4_X_UAV_REGISTER_COUNT: DWORD = 1; +pub const D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION: DWORD = 65535; +pub const D3D11_CS_TGSM_REGISTER_COUNT: DWORD = 8192; +pub const D3D11_CS_TGSM_REGISTER_READS_PER_INST: DWORD = 1; +pub const D3D11_CS_TGSM_RESOURCE_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_CS_TGSM_RESOURCE_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_CS_THREADGROUPID_REGISTER_COMPONENTS: DWORD = 3; +pub const D3D11_CS_THREADGROUPID_REGISTER_COUNT: DWORD = 1; +pub const D3D11_CS_THREADIDINGROUPFLATTENED_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_CS_THREADIDINGROUPFLATTENED_REGISTER_COUNT: DWORD = 1; +pub const D3D11_CS_THREADIDINGROUP_REGISTER_COMPONENTS: DWORD = 3; +pub const D3D11_CS_THREADIDINGROUP_REGISTER_COUNT: DWORD = 1; +pub const D3D11_CS_THREADID_REGISTER_COMPONENTS: DWORD = 3; +pub const D3D11_CS_THREADID_REGISTER_COUNT: DWORD = 1; +pub const D3D11_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP: DWORD = 1024; +pub const D3D11_CS_THREAD_GROUP_MAX_X: DWORD = 1024; +pub const D3D11_CS_THREAD_GROUP_MAX_Y: DWORD = 1024; +pub const D3D11_CS_THREAD_GROUP_MAX_Z: DWORD = 64; +pub const D3D11_CS_THREAD_GROUP_MIN_X: DWORD = 1; +pub const D3D11_CS_THREAD_GROUP_MIN_Y: DWORD = 1; +pub const D3D11_CS_THREAD_GROUP_MIN_Z: DWORD = 1; +pub const D3D11_CS_THREAD_LOCAL_TEMP_REGISTER_POOL: DWORD = 16384; +pub const D3D11_DEFAULT_BLEND_FACTOR_ALPHA: FLOAT = 1.0; +pub const D3D11_DEFAULT_BLEND_FACTOR_BLUE: FLOAT = 1.0; +pub const D3D11_DEFAULT_BLEND_FACTOR_GREEN: FLOAT = 1.0; +pub const D3D11_DEFAULT_BLEND_FACTOR_RED: FLOAT = 1.0; +pub const D3D11_DEFAULT_BORDER_COLOR_COMPONENT: FLOAT = 0.0; +pub const D3D11_DEFAULT_DEPTH_BIAS: DWORD = 0; +pub const D3D11_DEFAULT_DEPTH_BIAS_CLAMP: FLOAT = 0.0; +pub const D3D11_DEFAULT_MAX_ANISOTROPY: DWORD = 16; +pub const D3D11_DEFAULT_MIP_LOD_BIAS: FLOAT = 0.0; +pub const D3D11_DEFAULT_RENDER_TARGET_ARRAY_INDEX: DWORD = 0; +pub const D3D11_DEFAULT_SAMPLE_MASK: DWORD = 0xffffffff; +pub const D3D11_DEFAULT_SCISSOR_ENDX: DWORD = 0; +pub const D3D11_DEFAULT_SCISSOR_ENDY: DWORD = 0; +pub const D3D11_DEFAULT_SCISSOR_STARTX: DWORD = 0; +pub const D3D11_DEFAULT_SCISSOR_STARTY: DWORD = 0; +pub const D3D11_DEFAULT_SLOPE_SCALED_DEPTH_BIAS: FLOAT = 0.0; +pub const D3D11_DEFAULT_STENCIL_READ_MASK: DWORD = 0xff; +pub const D3D11_DEFAULT_STENCIL_REFERENCE: DWORD = 0; +pub const D3D11_DEFAULT_STENCIL_WRITE_MASK: DWORD = 0xff; +pub const D3D11_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX: DWORD = 0; +pub const D3D11_DEFAULT_VIEWPORT_HEIGHT: DWORD = 0; +pub const D3D11_DEFAULT_VIEWPORT_MAX_DEPTH: FLOAT = 0.0; +pub const D3D11_DEFAULT_VIEWPORT_MIN_DEPTH: FLOAT = 0.0; +pub const D3D11_DEFAULT_VIEWPORT_TOPLEFTX: DWORD = 0; +pub const D3D11_DEFAULT_VIEWPORT_TOPLEFTY: DWORD = 0; +pub const D3D11_DEFAULT_VIEWPORT_WIDTH: DWORD = 0; +pub const D3D11_DS_INPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS: DWORD = 3968; +pub const D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_DS_INPUT_CONTROL_POINT_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_DS_INPUT_CONTROL_POINT_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENTS: DWORD = 3; +pub const D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COUNT: DWORD = 1; +pub const D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_DS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_DS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_DS_INPUT_PRIMITIVE_ID_REGISTER_COUNT: DWORD = 1; +pub const D3D11_DS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_DS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_DS_OUTPUT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_DS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_DS_OUTPUT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_FLOAT16_FUSED_TOLERANCE_IN_ULP: FLOAT = 0.6; +pub const D3D11_FLOAT32_MAX: FLOAT = 3.402823466E+38; +pub const D3D11_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP: FLOAT = 0.6; +pub const D3D11_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR: FLOAT = 2.4; +pub const D3D11_FLOAT_TO_SRGB_EXPONENT_NUMERATOR: FLOAT = 1.0; +pub const D3D11_FLOAT_TO_SRGB_OFFSET: FLOAT = 0.055; +pub const D3D11_FLOAT_TO_SRGB_SCALE_1: FLOAT = 12.92; +pub const D3D11_FLOAT_TO_SRGB_SCALE_2: FLOAT = 1.055; +pub const D3D11_FLOAT_TO_SRGB_THRESHOLD: FLOAT = 0.0031308; +pub const D3D11_FTOI_INSTRUCTION_MAX_INPUT: FLOAT = 2147483647.999; +pub const D3D11_FTOI_INSTRUCTION_MIN_INPUT: FLOAT = -2147483648.999; +pub const D3D11_FTOU_INSTRUCTION_MAX_INPUT: FLOAT = 4294967295.999; +pub const D3D11_FTOU_INSTRUCTION_MIN_INPUT: FLOAT = 0.0; +pub const D3D11_GS_INPUT_INSTANCE_ID_READS_PER_INST: DWORD = 2; +pub const D3D11_GS_INPUT_INSTANCE_ID_READ_PORTS: DWORD = 1; +pub const D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COUNT: DWORD = 1; +pub const D3D11_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_GS_INPUT_PRIM_CONST_REGISTER_COUNT: DWORD = 1; +pub const D3D11_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_GS_INPUT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_GS_INPUT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_GS_INPUT_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_GS_INPUT_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_GS_INPUT_REGISTER_VERTICES: DWORD = 32; +pub const D3D11_GS_MAX_INSTANCE_COUNT: DWORD = 32; +pub const D3D11_GS_MAX_OUTPUT_VERTEX_COUNT_ACROSS_INSTANCES: DWORD = 1024; +pub const D3D11_GS_OUTPUT_ELEMENTS: DWORD = 32; +pub const D3D11_GS_OUTPUT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_GS_OUTPUT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_HS_CONTROL_POINT_PHASE_INPUT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_HS_CONTROL_POINT_PHASE_OUTPUT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_HS_CONTROL_POINT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_HS_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_HS_CONTROL_POINT_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_HS_CONTROL_POINT_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_HS_FORK_PHASE_INSTANCE_COUNT_UPPER_BOUND: DWORD = 0xffffffff; +pub const D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COUNT: DWORD = 1; +pub const D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COUNT: DWORD = 1; +pub const D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COUNT: DWORD = 1; +pub const D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_HS_JOIN_PHASE_INSTANCE_COUNT_UPPER_BOUND: DWORD = 0xffffffff; +pub const D3D11_HS_MAXTESSFACTOR_LOWER_BOUND: FLOAT = 1.0; +pub const D3D11_HS_MAXTESSFACTOR_UPPER_BOUND: FLOAT = 64.0; +pub const D3D11_HS_OUTPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS: DWORD = 3968; +pub const D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COUNT: DWORD = 1; +pub const D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_SCALAR_COMPONENTS: DWORD = 128; +pub const D3D11_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES: DWORD = 0; +pub const D3D11_IA_DEFAULT_PRIMITIVE_TOPOLOGY: DWORD = 0; +pub const D3D11_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES: DWORD = 0; +pub const D3D11_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT: DWORD = 1; +pub const D3D11_IA_INSTANCE_ID_BIT_COUNT: DWORD = 32; +pub const D3D11_IA_INTEGER_ARITHMETIC_BIT_COUNT: DWORD = 32; +pub const D3D11_IA_PATCH_MAX_CONTROL_POINT_COUNT: DWORD = 32; +pub const D3D11_IA_PRIMITIVE_ID_BIT_COUNT: DWORD = 32; +pub const D3D11_IA_VERTEX_ID_BIT_COUNT: DWORD = 32; +pub const D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT: DWORD = 32; +pub const D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS: DWORD = 128; +pub const D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT: DWORD = 32; +pub const D3D11_INTEGER_DIVIDE_BY_ZERO_QUOTIENT: DWORD = 0xffffffff; +pub const D3D11_INTEGER_DIVIDE_BY_ZERO_REMAINDER: DWORD = 0xffffffff; +pub const D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL: DWORD = 0xffffffff; +pub const D3D11_KEEP_UNORDERED_ACCESS_VIEWS: DWORD = 0xffffffff; +pub const D3D11_LINEAR_GAMMA: FLOAT = 1.0; +pub const D3D11_MAJOR_VERSION: DWORD = 11; +pub const D3D11_MAX_BORDER_COLOR_COMPONENT: FLOAT = 1.0; +pub const D3D11_MAX_DEPTH: FLOAT = 1.0; +pub const D3D11_MAX_MAXANISOTROPY: DWORD = 16; +pub const D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT: DWORD = 32; +pub const D3D11_MAX_POSITION_VALUE: FLOAT = 3.402823466E+34; +pub const D3D11_MAX_TEXTURE_DIMENSION_2_TO_EXP: DWORD = 17; +pub const D3D11_MINOR_VERSION: DWORD = 0; +pub const D3D11_MIN_BORDER_COLOR_COMPONENT: FLOAT = 0.0; +pub const D3D11_MIN_DEPTH: FLOAT = 0.0; +pub const D3D11_MIN_MAXANISOTROPY: DWORD = 0; +pub const D3D11_MIP_LOD_BIAS_MAX: FLOAT = 15.99; +pub const D3D11_MIP_LOD_BIAS_MIN: FLOAT = -16.0; +pub const D3D11_MIP_LOD_FRACTIONAL_BIT_COUNT: DWORD = 8; +pub const D3D11_MIP_LOD_RANGE_BIT_COUNT: DWORD = 8; +pub const D3D11_MULTISAMPLE_ANTIALIAS_LINE_WIDTH: FLOAT = 1.4; +pub const D3D11_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT: DWORD = 0; +pub const D3D11_PIXEL_ADDRESS_RANGE_BIT_COUNT: DWORD = 15; +pub const D3D11_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT: DWORD = 16; +pub const D3D11_PS_CS_UAV_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_PS_CS_UAV_REGISTER_COUNT: DWORD = 8; +pub const D3D11_PS_CS_UAV_REGISTER_READS_PER_INST: DWORD = 1; +pub const D3D11_PS_CS_UAV_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_PS_FRONTFACING_DEFAULT_VALUE: DWORD = 0xffffffff; +pub const D3D11_PS_FRONTFACING_FALSE_VALUE: DWORD = 0; +pub const D3D11_PS_FRONTFACING_TRUE_VALUE: DWORD = 0xffffffff; +pub const D3D11_PS_INPUT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_PS_INPUT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_PS_INPUT_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_PS_INPUT_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT: FLOAT = 0.0; +pub const D3D11_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_PS_OUTPUT_DEPTH_REGISTER_COUNT: DWORD = 1; +pub const D3D11_PS_OUTPUT_MASK_REGISTER_COMPONENTS: DWORD = 1; +pub const D3D11_PS_OUTPUT_MASK_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_PS_OUTPUT_MASK_REGISTER_COUNT: DWORD = 1; +pub const D3D11_PS_OUTPUT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_PS_OUTPUT_REGISTER_COUNT: DWORD = 8; +pub const D3D11_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT: FLOAT = 0.5; +pub const D3D11_RAW_UAV_SRV_BYTE_ALIGNMENT: DWORD = 16; +pub const D3D11_REQ_BLEND_OBJECT_COUNT_PER_DEVICE: DWORD = 4096; +pub const D3D11_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP: DWORD = 27; +pub const D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT: DWORD = 4096; +pub const D3D11_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_DEVICE: DWORD = 4096; +pub const D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP: DWORD = 32; +pub const D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP: DWORD = 32; +pub const D3D11_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION: DWORD = 16384; +pub const D3D11_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT: DWORD = 1024; +pub const D3D11_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT: DWORD = 4096; +pub const D3D11_REQ_MAXANISOTROPY: DWORD = 16; +pub const D3D11_REQ_MIP_LEVELS: DWORD = 15; +pub const D3D11_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES: DWORD = 2048; +pub const D3D11_REQ_RASTERIZER_OBJECT_COUNT_PER_DEVICE: DWORD = 4096; +pub const D3D11_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH: DWORD = 16384; +pub const D3D11_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_A_TERM: DWORD = 128; +pub const D3D11_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_B_TERM: FLOAT = 0.25; +pub const D3D11_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_C_TERM: DWORD = 2048; +pub const D3D11_REQ_RESOURCE_VIEW_COUNT_PER_DEVICE_2_TO_EXP: DWORD = 20; +pub const D3D11_REQ_SAMPLER_OBJECT_COUNT_PER_DEVICE: DWORD = 4096; +pub const D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION: DWORD = 2048; +pub const D3D11_REQ_TEXTURE1D_U_DIMENSION: DWORD = 16384; +pub const D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION: DWORD = 2048; +pub const D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION: DWORD = 16384; +pub const D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION: DWORD = 2048; +pub const D3D11_REQ_TEXTURECUBE_DIMENSION: DWORD = 16384; +pub const D3D11_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL: DWORD = 0; +pub const D3D11_SHADER_MAJOR_VERSION: DWORD = 5; +pub const D3D11_SHADER_MAX_INSTANCES: DWORD = 65535; +pub const D3D11_SHADER_MAX_INTERFACES: DWORD = 253; +pub const D3D11_SHADER_MAX_INTERFACE_CALL_SITES: DWORD = 4096; +pub const D3D11_SHADER_MAX_TYPES: DWORD = 65535; +pub const D3D11_SHADER_MINOR_VERSION: DWORD = 0; +pub const D3D11_SHIFT_INSTRUCTION_PAD_VALUE: DWORD = 0; +pub const D3D11_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT: DWORD = 5; +pub const D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT: DWORD = 8; +pub const D3D11_SO_BUFFER_MAX_STRIDE_IN_BYTES: DWORD = 2048; +pub const D3D11_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES: DWORD = 512; +pub const D3D11_SO_BUFFER_SLOT_COUNT: DWORD = 4; +pub const D3D11_SO_DDI_REGISTER_INDEX_DENOTING_GAP: DWORD = 0xffffffff; +pub const D3D11_SO_NO_RASTERIZED_STREAM: DWORD = 0xffffffff; +pub const D3D11_SO_OUTPUT_COMPONENT_COUNT: DWORD = 128; +pub const D3D11_SO_STREAM_COUNT: DWORD = 4; +pub const D3D11_SPEC_DATE_DAY: DWORD = 16; +pub const D3D11_SPEC_DATE_MONTH: DWORD = 0o5; +pub const D3D11_SPEC_DATE_YEAR: DWORD = 2011; +pub const D3D11_SPEC_VERSION: FLOAT = 1.07; +pub const D3D11_SRGB_GAMMA: FLOAT = 2.2; +pub const D3D11_SRGB_TO_FLOAT_DENOMINATOR_1: FLOAT = 12.92; +pub const D3D11_SRGB_TO_FLOAT_DENOMINATOR_2: FLOAT = 1.055; +pub const D3D11_SRGB_TO_FLOAT_EXPONENT: FLOAT = 2.4; +pub const D3D11_SRGB_TO_FLOAT_OFFSET: FLOAT = 0.055; +pub const D3D11_SRGB_TO_FLOAT_THRESHOLD: FLOAT = 0.04045; +pub const D3D11_SRGB_TO_FLOAT_TOLERANCE_IN_ULP: FLOAT = 0.5; +pub const D3D11_STANDARD_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_STANDARD_COMPONENT_BIT_COUNT_DOUBLED: DWORD = 64; +pub const D3D11_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE: DWORD = 4; +pub const D3D11_STANDARD_PIXEL_COMPONENT_COUNT: DWORD = 128; +pub const D3D11_STANDARD_PIXEL_ELEMENT_COUNT: DWORD = 32; +pub const D3D11_STANDARD_VECTOR_SIZE: DWORD = 4; +pub const D3D11_STANDARD_VERTEX_ELEMENT_COUNT: DWORD = 32; +pub const D3D11_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT: DWORD = 64; +pub const D3D11_SUBPIXEL_FRACTIONAL_BIT_COUNT: DWORD = 8; +pub const D3D11_SUBTEXEL_FRACTIONAL_BIT_COUNT: DWORD = 8; +pub const D3D11_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR: DWORD = 64; +pub const D3D11_TESSELLATOR_MAX_ISOLINE_DENSITY_TESSELLATION_FACTOR: DWORD = 64; +pub const D3D11_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR: DWORD = 63; +pub const D3D11_TESSELLATOR_MAX_TESSELLATION_FACTOR: DWORD = 64; +pub const D3D11_TESSELLATOR_MIN_EVEN_TESSELLATION_FACTOR: DWORD = 2; +pub const D3D11_TESSELLATOR_MIN_ISOLINE_DENSITY_TESSELLATION_FACTOR: DWORD = 1; +pub const D3D11_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR: DWORD = 1; +pub const D3D11_TEXEL_ADDRESS_RANGE_BIT_COUNT: DWORD = 16; +pub const D3D11_UNBOUND_MEMORY_ACCESS_RESULT: DWORD = 0; +pub const D3D11_VIEWPORT_AND_SCISSORRECT_MAX_INDEX: DWORD = 15; +pub const D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE: DWORD = 16; +pub const D3D11_VIEWPORT_BOUNDS_MAX: DWORD = 32767; +pub const D3D11_VIEWPORT_BOUNDS_MIN: c_long = -32768; +pub const D3D11_VS_INPUT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_VS_INPUT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_VS_INPUT_REGISTER_READS_PER_INST: DWORD = 2; +pub const D3D11_VS_INPUT_REGISTER_READ_PORTS: DWORD = 1; +pub const D3D11_VS_OUTPUT_REGISTER_COMPONENTS: DWORD = 4; +pub const D3D11_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: DWORD = 32; +pub const D3D11_VS_OUTPUT_REGISTER_COUNT: DWORD = 32; +pub const D3D11_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT: DWORD = 10; +pub const D3D11_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP: DWORD = 25; +pub const D3D11_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP: DWORD = 25; +pub const D3D11_1_UAV_SLOT_COUNT: DWORD = 64; +pub const D3D11_2_TILED_RESOURCE_TILE_SIZE_IN_BYTES: DWORD = 65536; +ENUM!{enum D3D11_INPUT_CLASSIFICATION { + D3D11_INPUT_PER_VERTEX_DATA = 0, + D3D11_INPUT_PER_INSTANCE_DATA = 1, +}} +pub const D3D11_APPEND_ALIGNED_ELEMENT: DWORD = 0xffffffff; +STRUCT!{struct D3D11_INPUT_ELEMENT_DESC { + SemanticName: LPCSTR, + SemanticIndex: UINT, + Format: DXGI_FORMAT, + InputSlot: UINT, + AlignedByteOffset: UINT, + InputSlotClass: D3D11_INPUT_CLASSIFICATION, + InstanceDataStepRate: UINT, +}} +ENUM!{enum D3D11_FILL_MODE { + D3D11_FILL_WIREFRAME = 2, + D3D11_FILL_SOLID = 3, +}} +pub type D3D11_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY; +pub type D3D11_PRIMITIVE = D3D_PRIMITIVE; +ENUM!{enum D3D11_CULL_MODE { + D3D11_CULL_NONE = 1, + D3D11_CULL_FRONT = 2, + D3D11_CULL_BACK = 3, +}} +STRUCT!{struct D3D11_SO_DECLARATION_ENTRY { + Stream: UINT, + SemanticName: LPCSTR, + SemanticIndex: UINT, + StartComponent: BYTE, + ComponentCount: BYTE, + OutputSlot: BYTE, +}} +STRUCT!{struct D3D11_VIEWPORT { + TopLeftX: FLOAT, + TopLeftY: FLOAT, + Width: FLOAT, + Height: FLOAT, + MinDepth: FLOAT, + MaxDepth: FLOAT, +}} +STRUCT!{struct D3D11_DRAW_INSTANCED_INDIRECT_ARGS { + VertexCountPerInstance: UINT, + InstanceCount: UINT, + StartVertexLocation: UINT, + StartInstanceLocation: UINT, +}} +STRUCT!{struct D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS { + IndexCountPerInstance: UINT, + InstanceCount: UINT, + StartIndexLocation: UINT, + BaseVertexLocation: INT, + StartInstanceLocation: UINT, +}} +ENUM!{enum D3D11_RESOURCE_DIMENSION { + D3D11_RESOURCE_DIMENSION_UNKNOWN = 0, + D3D11_RESOURCE_DIMENSION_BUFFER = 1, + D3D11_RESOURCE_DIMENSION_TEXTURE1D = 2, + D3D11_RESOURCE_DIMENSION_TEXTURE2D = 3, + D3D11_RESOURCE_DIMENSION_TEXTURE3D = 4, +}} +pub type D3D11_SRV_DIMENSION = D3D_SRV_DIMENSION; +ENUM!{enum D3D11_DSV_DIMENSION { + D3D11_DSV_DIMENSION_UNKNOWN = 0, + D3D11_DSV_DIMENSION_TEXTURE1D = 1, + D3D11_DSV_DIMENSION_TEXTURE1DARRAY = 2, + D3D11_DSV_DIMENSION_TEXTURE2D = 3, + D3D11_DSV_DIMENSION_TEXTURE2DARRAY = 4, + D3D11_DSV_DIMENSION_TEXTURE2DMS = 5, + D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY = 6, +}} +ENUM!{enum D3D11_RTV_DIMENSION { + D3D11_RTV_DIMENSION_UNKNOWN = 0, + D3D11_RTV_DIMENSION_BUFFER = 1, + D3D11_RTV_DIMENSION_TEXTURE1D = 2, + D3D11_RTV_DIMENSION_TEXTURE1DARRAY = 3, + D3D11_RTV_DIMENSION_TEXTURE2D = 4, + D3D11_RTV_DIMENSION_TEXTURE2DARRAY = 5, + D3D11_RTV_DIMENSION_TEXTURE2DMS = 6, + D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY = 7, + D3D11_RTV_DIMENSION_TEXTURE3D = 8, +}} +ENUM!{enum D3D11_UAV_DIMENSION { + D3D11_UAV_DIMENSION_UNKNOWN = 0, + D3D11_UAV_DIMENSION_BUFFER = 1, + D3D11_UAV_DIMENSION_TEXTURE1D = 2, + D3D11_UAV_DIMENSION_TEXTURE1DARRAY = 3, + D3D11_UAV_DIMENSION_TEXTURE2D = 4, + D3D11_UAV_DIMENSION_TEXTURE2DARRAY = 5, + D3D11_UAV_DIMENSION_TEXTURE3D = 8, +}} +ENUM!{enum D3D11_USAGE { + D3D11_USAGE_DEFAULT = 0, + D3D11_USAGE_IMMUTABLE = 1, + D3D11_USAGE_DYNAMIC = 2, + D3D11_USAGE_STAGING = 3, +}} +ENUM!{enum D3D11_BIND_FLAG { + D3D11_BIND_VERTEX_BUFFER = 0x1, + D3D11_BIND_INDEX_BUFFER = 0x2, + D3D11_BIND_CONSTANT_BUFFER = 0x4, + D3D11_BIND_SHADER_RESOURCE = 0x8, + D3D11_BIND_STREAM_OUTPUT = 0x10, + D3D11_BIND_RENDER_TARGET = 0x20, + D3D11_BIND_DEPTH_STENCIL = 0x40, + D3D11_BIND_UNORDERED_ACCESS = 0x80, + D3D11_BIND_DECODER = 0x200, + D3D11_BIND_VIDEO_ENCODER = 0x400, +}} +ENUM!{enum D3D11_CPU_ACCESS_FLAG { + D3D11_CPU_ACCESS_WRITE = 0x10000, + D3D11_CPU_ACCESS_READ = 0x20000, +}} +ENUM!{enum D3D11_RESOURCE_MISC_FLAG { + D3D11_RESOURCE_MISC_GENERATE_MIPS = 0x1, + D3D11_RESOURCE_MISC_SHARED = 0x2, + D3D11_RESOURCE_MISC_TEXTURECUBE = 0x4, + D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS = 0x10, + D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS = 0x20, + D3D11_RESOURCE_MISC_BUFFER_STRUCTURED = 0x40, + D3D11_RESOURCE_MISC_RESOURCE_CLAMP = 0x80, + D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x100, + D3D11_RESOURCE_MISC_GDI_COMPATIBLE = 0x200, + D3D11_RESOURCE_MISC_SHARED_NTHANDLE = 0x800, + D3D11_RESOURCE_MISC_RESTRICTED_CONTENT = 0x1000, + D3D11_RESOURCE_MISC_RESTRICT_SHARED_RESOURCE = 0x2000, + D3D11_RESOURCE_MISC_RESTRICT_SHARED_RESOURCE_DRIVER = 0x4000, + D3D11_RESOURCE_MISC_GUARDED = 0x8000, + D3D11_RESOURCE_MISC_TILE_POOL = 0x20000, + D3D11_RESOURCE_MISC_TILED = 0x40000, + D3D11_RESOURCE_MISC_HW_PROTECTED = 0x80000, +}} +ENUM!{enum D3D11_MAP { + D3D11_MAP_READ = 1, + D3D11_MAP_WRITE = 2, + D3D11_MAP_READ_WRITE = 3, + D3D11_MAP_WRITE_DISCARD = 4, + D3D11_MAP_WRITE_NO_OVERWRITE = 5, +}} +ENUM!{enum D3D11_MAP_FLAG { + D3D11_MAP_FLAG_DO_NOT_WAIT = 0x100000, +}} +ENUM!{enum D3D11_RAISE_FLAG { + D3D11_RAISE_FLAG_DRIVER_INTERNAL_ERROR = 0x1, +}} +ENUM!{enum D3D11_CLEAR_FLAG { + D3D11_CLEAR_DEPTH = 0x1, + D3D11_CLEAR_STENCIL = 0x2, +}} +pub type D3D11_RECT = RECT; +STRUCT!{struct D3D11_BOX { + left: UINT, + top: UINT, + front: UINT, + right: UINT, + bottom: UINT, + back: UINT, +}} +RIDL!{#[uuid(0x1841e5c8, 0x16b0, 0x489b, 0xbc, 0xc8, 0x44, 0xcf, 0xb0, 0xd5, 0xde, 0xae)] +interface ID3D11DeviceChild(ID3D11DeviceChildVtbl): IUnknown(IUnknownVtbl) { + fn GetDevice( + ppDevice: *mut *mut ID3D11Device, + ) -> (), + fn GetPrivateData( + guid: REFGUID, + pDataSize: *mut UINT, + pData: *mut c_void, + ) -> HRESULT, + fn SetPrivateData( + guid: REFGUID, + DataSize: UINT, + pData: *const c_void, + ) -> HRESULT, + fn SetPrivateDataInterface( + guid: REFGUID, + pData: *const IUnknown, + ) -> HRESULT, +}} +ENUM!{enum D3D11_COMPARISON_FUNC { + D3D11_COMPARISON_NEVER = 1, + D3D11_COMPARISON_LESS = 2, + D3D11_COMPARISON_EQUAL = 3, + D3D11_COMPARISON_LESS_EQUAL = 4, + D3D11_COMPARISON_GREATER = 5, + D3D11_COMPARISON_NOT_EQUAL = 6, + D3D11_COMPARISON_GREATER_EQUAL = 7, + D3D11_COMPARISON_ALWAYS = 8, +}} +ENUM!{enum D3D11_DEPTH_WRITE_MASK { + D3D11_DEPTH_WRITE_MASK_ZERO = 0, + D3D11_DEPTH_WRITE_MASK_ALL = 1, +}} +ENUM!{enum D3D11_STENCIL_OP { + D3D11_STENCIL_OP_KEEP = 1, + D3D11_STENCIL_OP_ZERO = 2, + D3D11_STENCIL_OP_REPLACE = 3, + D3D11_STENCIL_OP_INCR_SAT = 4, + D3D11_STENCIL_OP_DECR_SAT = 5, + D3D11_STENCIL_OP_INVERT = 6, + D3D11_STENCIL_OP_INCR = 7, + D3D11_STENCIL_OP_DECR = 8, +}} +STRUCT!{struct D3D11_DEPTH_STENCILOP_DESC { + StencilFailOp: D3D11_STENCIL_OP, + StencilDepthFailOp: D3D11_STENCIL_OP, + StencilPassOp: D3D11_STENCIL_OP, + StencilFunc: D3D11_COMPARISON_FUNC, +}} +STRUCT!{struct D3D11_DEPTH_STENCIL_DESC { + DepthEnable: BOOL, + DepthWriteMask: D3D11_DEPTH_WRITE_MASK, + DepthFunc: D3D11_COMPARISON_FUNC, + StencilEnable: BOOL, + StencilReadMask: UINT8, + StencilWriteMask: UINT8, + FrontFace: D3D11_DEPTH_STENCILOP_DESC, + BackFace: D3D11_DEPTH_STENCILOP_DESC, +}} +RIDL!{#[uuid(0x03823efb, 0x8d8f, 0x4e1c, 0x9a, 0xa2, 0xf6, 0x4b, 0xb2, 0xcb, 0xfd, 0xf1)] +interface ID3D11DepthStencilState(ID3D11DepthStencilStateVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetDesc( + pDesc: *mut D3D11_DEPTH_STENCIL_DESC, + ) -> (), +}} +ENUM!{enum D3D11_BLEND { + D3D11_BLEND_ZERO = 1, + D3D11_BLEND_ONE = 2, + D3D11_BLEND_SRC_COLOR = 3, + D3D11_BLEND_INV_SRC_COLOR = 4, + D3D11_BLEND_SRC_ALPHA = 5, + D3D11_BLEND_INV_SRC_ALPHA = 6, + D3D11_BLEND_DEST_ALPHA = 7, + D3D11_BLEND_INV_DEST_ALPHA = 8, + D3D11_BLEND_DEST_COLOR = 9, + D3D11_BLEND_INV_DEST_COLOR = 10, + D3D11_BLEND_SRC_ALPHA_SAT = 11, + D3D11_BLEND_BLEND_FACTOR = 14, + D3D11_BLEND_INV_BLEND_FACTOR = 15, + D3D11_BLEND_SRC1_COLOR = 16, + D3D11_BLEND_INV_SRC1_COLOR = 17, + D3D11_BLEND_SRC1_ALPHA = 18, + D3D11_BLEND_INV_SRC1_ALPHA = 19, +}} +ENUM!{enum D3D11_BLEND_OP { + D3D11_BLEND_OP_ADD = 1, + D3D11_BLEND_OP_SUBTRACT = 2, + D3D11_BLEND_OP_REV_SUBTRACT = 3, + D3D11_BLEND_OP_MIN = 4, + D3D11_BLEND_OP_MAX = 5, +}} +ENUM!{enum D3D11_COLOR_WRITE_ENABLE { + D3D11_COLOR_WRITE_ENABLE_RED = 1, + D3D11_COLOR_WRITE_ENABLE_GREEN = 2, + D3D11_COLOR_WRITE_ENABLE_BLUE = 4, + D3D11_COLOR_WRITE_ENABLE_ALPHA = 8, + D3D11_COLOR_WRITE_ENABLE_ALL = D3D11_COLOR_WRITE_ENABLE_RED | D3D11_COLOR_WRITE_ENABLE_GREEN + | D3D11_COLOR_WRITE_ENABLE_BLUE | D3D11_COLOR_WRITE_ENABLE_ALPHA, +}} +STRUCT!{struct D3D11_RENDER_TARGET_BLEND_DESC { + BlendEnable: BOOL, + SrcBlend: D3D11_BLEND, + DestBlend: D3D11_BLEND, + BlendOp: D3D11_BLEND_OP, + SrcBlendAlpha: D3D11_BLEND, + DestBlendAlpha: D3D11_BLEND, + BlendOpAlpha: D3D11_BLEND_OP, + RenderTargetWriteMask: UINT8, +}} +STRUCT!{struct D3D11_BLEND_DESC { + AlphaToCoverageEnable: BOOL, + IndependentBlendEnable: BOOL, + RenderTarget: [D3D11_RENDER_TARGET_BLEND_DESC; 8], +}} +RIDL!{#[uuid(0x75b68faa, 0x347d, 0x4159, 0x8f, 0x45, 0xa0, 0x64, 0x0f, 0x01, 0xcd, 0x9a)] +interface ID3D11BlendState(ID3D11BlendStateVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetDesc( + pDesc: *mut D3D11_BLEND_DESC, + ) -> (), +}} +STRUCT!{struct D3D11_RASTERIZER_DESC { + FillMode: D3D11_FILL_MODE, + CullMode: D3D11_CULL_MODE, + FrontCounterClockwise: BOOL, + DepthBias: INT, + DepthBiasClamp: FLOAT, + SlopeScaledDepthBias: FLOAT, + DepthClipEnable: BOOL, + ScissorEnable: BOOL, + MultisampleEnable: BOOL, + AntialiasedLineEnable: BOOL, +}} +RIDL!{#[uuid(0x9bb4ab81, 0xab1a, 0x4d8f, 0xb5, 0x06, 0xfc, 0x04, 0x20, 0x0b, 0x6e, 0xe7)] +interface ID3D11RasterizerState(ID3D11RasterizerStateVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetDesc( + pDesc: *mut D3D11_RASTERIZER_DESC, + ) -> (), +}} +STRUCT!{struct D3D11_SUBRESOURCE_DATA { + pSysMem: *const c_void, + SysMemPitch: UINT, + SysMemSlicePitch: UINT, +}} +STRUCT!{struct D3D11_MAPPED_SUBRESOURCE { + pData: *mut c_void, + RowPitch: UINT, + DepthPitch: UINT, +}} +RIDL!{#[uuid(0xdc8e63f3, 0xd12b, 0x4952, 0xb4, 0x7b, 0x5e, 0x45, 0x02, 0x6a, 0x86, 0x2d)] +interface ID3D11Resource(ID3D11ResourceVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetType( + pResourceDimension: *mut D3D11_RESOURCE_DIMENSION, + ) -> (), + fn SetEvictionPriority( + EvictionPriority: UINT, + ) -> (), + fn GetEvictionPriority() -> UINT, +}} +STRUCT!{struct D3D11_BUFFER_DESC { + ByteWidth: UINT, + Usage: D3D11_USAGE, + BindFlags: UINT, + CPUAccessFlags: UINT, + MiscFlags: UINT, + StructureByteStride: UINT, +}} +RIDL!{#[uuid(0x48570b85, 0xd1ee, 0x4fcd, 0xa2, 0x50, 0xeb, 0x35, 0x07, 0x22, 0xb0, 0x37)] +interface ID3D11Buffer(ID3D11BufferVtbl): ID3D11Resource(ID3D11ResourceVtbl) { + fn GetDesc( + pDesc: *mut D3D11_BUFFER_DESC, + ) -> (), +}} +STRUCT!{struct D3D11_TEXTURE1D_DESC { + Width: UINT, + MipLevels: UINT, + ArraySize: UINT, + Format: DXGI_FORMAT, + Usage: D3D11_USAGE, + BindFlags: UINT, + CPUAccessFlags: UINT, + MiscFlags: UINT, +}} +RIDL!{#[uuid(0xf8fb5c27, 0xc6b3, 0x4f75, 0xa4, 0xc8, 0x43, 0x9a, 0xf2, 0xef, 0x56, 0x4c)] +interface ID3D11Texture1D(ID3D11Texture1DVtbl): ID3D11Resource(ID3D11ResourceVtbl) { + fn GetDesc( + pDesc: *mut D3D11_TEXTURE1D_DESC, + ) -> (), +}} +STRUCT!{struct D3D11_TEXTURE2D_DESC { + Width: UINT, + Height: UINT, + MipLevels: UINT, + ArraySize: UINT, + Format: DXGI_FORMAT, + SampleDesc: DXGI_SAMPLE_DESC, + Usage: D3D11_USAGE, + BindFlags: UINT, + CPUAccessFlags: UINT, + MiscFlags: UINT, +}} +RIDL!{#[uuid(0x6f15aaf2, 0xd208, 0x4e89, 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c)] +interface ID3D11Texture2D(ID3D11Texture2DVtbl): ID3D11Resource(ID3D11ResourceVtbl) { + fn GetDesc( + pDesc: *mut D3D11_TEXTURE2D_DESC, + ) -> (), +}} +STRUCT!{struct D3D11_TEXTURE3D_DESC { + Width: UINT, + Height: UINT, + Depth: UINT, + MipLevels: UINT, + Format: DXGI_FORMAT, + Usage: D3D11_USAGE, + BindFlags: UINT, + CPUAccessFlags: UINT, + MiscFlags: UINT, +}} +RIDL!{#[uuid(0x037e866e, 0xf56d, 0x4357, 0xa8, 0xaf, 0x9d, 0xab, 0xbe, 0x6e, 0x25, 0x0e)] +interface ID3D11Texture3D(ID3D11Texture3DVtbl): ID3D11Resource(ID3D11ResourceVtbl) { + fn GetDesc( + pDesc: *mut D3D11_TEXTURE3D_DESC, + ) -> (), +}} +ENUM!{enum D3D11_TEXTURECUBE_FACE { + D3D11_TEXTURECUBE_FACE_POSITIVE_X = 0, + D3D11_TEXTURECUBE_FACE_NEGATIVE_X = 1, + D3D11_TEXTURECUBE_FACE_POSITIVE_Y = 2, + D3D11_TEXTURECUBE_FACE_NEGATIVE_Y = 3, + D3D11_TEXTURECUBE_FACE_POSITIVE_Z = 4, + D3D11_TEXTURECUBE_FACE_NEGATIVE_Z = 5, +}} +RIDL!{#[uuid(0x839d1216, 0xbb2e, 0x412b, 0xb7, 0xf4, 0xa9, 0xdb, 0xeb, 0xe0, 0x8e, 0xd1)] +interface ID3D11View(ID3D11ViewVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetResource( + ppResource: *mut *mut ID3D11Resource, + ) -> (), +}} +UNION!{union D3D11_BUFFER_SRV_u1 { + [u32; 1], + FirstElement FirstElement_mut: UINT, + ElementOffset ElementOffset_mut: UINT, +}} +UNION!{union D3D11_BUFFER_SRV_u2 { + [u32; 1], + NumElements NumElements_mut: UINT, + ElementWidth ElementWidth_mut: UINT, +}} +STRUCT!{struct D3D11_BUFFER_SRV { + u1: D3D11_BUFFER_SRV_u1, + u2: D3D11_BUFFER_SRV_u2, +}} +ENUM!{enum D3D11_BUFFEREX_SRV_FLAG { + D3D11_BUFFEREX_SRV_FLAG_RAW = 0x1, +}} +STRUCT!{struct D3D11_BUFFEREX_SRV { + FirstElement: UINT, + NumElements: UINT, + Flags: UINT, +}} +STRUCT!{struct D3D11_TEX1D_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, +}} +STRUCT!{struct D3D11_TEX1D_ARRAY_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D11_TEX2D_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, +}} +STRUCT!{struct D3D11_TEX2D_ARRAY_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D11_TEX3D_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, +}} +STRUCT!{struct D3D11_TEXCUBE_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, +}} +STRUCT!{struct D3D11_TEXCUBE_ARRAY_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, + First2DArrayFace: UINT, + NumCubes: UINT, +}} +STRUCT!{struct D3D11_TEX2DMS_SRV { + UnusedField_NothingToDefine: UINT, +}} +STRUCT!{struct D3D11_TEX2DMS_ARRAY_SRV { + FirstArraySlice: UINT, + ArraySize: UINT, +}} +UNION!{union D3D11_SHADER_RESOURCE_VIEW_DESC_u { + [u32; 4], + Buffer Buffer_mut: D3D11_BUFFER_SRV, + Texture1D Texture1D_mut: D3D11_TEX1D_SRV, + Texture1DArray Texture1DArray_mut: D3D11_TEX1D_ARRAY_SRV, + Texture2D Texture2D_mut: D3D11_TEX2D_SRV, + Texture2DArray Texture2DArray_mut: D3D11_TEX2D_ARRAY_SRV, + Texture2DMS Texture2DMS_mut: D3D11_TEX2DMS_SRV, + Texture2DMSArray Texture2DMSArray_mut: D3D11_TEX2DMS_ARRAY_SRV, + Texture3D Texture3D_mut: D3D11_TEX3D_SRV, + TextureCube TextureCube_mut: D3D11_TEXCUBE_SRV, + TextureCubeArray TextureCubeArray_mut: D3D11_TEXCUBE_ARRAY_SRV, + BufferEx BufferEx_mut: D3D11_BUFFEREX_SRV, +}} +STRUCT!{struct D3D11_SHADER_RESOURCE_VIEW_DESC { + Format: DXGI_FORMAT, + ViewDimension: D3D11_SRV_DIMENSION, + u: D3D11_SHADER_RESOURCE_VIEW_DESC_u, +}} +RIDL!{#[uuid(0xb0e06fe0, 0x8192, 0x4e1a, 0xb1, 0xca, 0x36, 0xd7, 0x41, 0x47, 0x10, 0xb2)] +interface ID3D11ShaderResourceView(ID3D11ShaderResourceViewVtbl): ID3D11View(ID3D11ViewVtbl) { + fn GetDesc( + pDesc: *mut D3D11_SHADER_RESOURCE_VIEW_DESC, + ) -> (), +}} +UNION!{union D3D11_BUFFER_RTV_u1 { + [u32; 1], + FirstElement FirstElement_mut: UINT, + ElementOffset ElementOffset_mut: UINT, +}} +UNION!{union D3D11_BUFFER_RTV_u2 { + [u32; 1], + NumElements NumElements_mut: UINT, + ElementWidth ElementWidth_mut: UINT, +}} +STRUCT!{struct D3D11_BUFFER_RTV { + u1: D3D11_BUFFER_RTV_u1, + u2: D3D11_BUFFER_RTV_u2, +}} +STRUCT!{struct D3D11_TEX1D_RTV { + MipSlice: UINT, +}} +STRUCT!{struct D3D11_TEX1D_ARRAY_RTV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D11_TEX2D_RTV { + MipSlice: UINT, +}} +STRUCT!{struct D3D11_TEX2DMS_RTV { + UnusedField_NothingToDefine: UINT, +}} +STRUCT!{struct D3D11_TEX2D_ARRAY_RTV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D11_TEX2DMS_ARRAY_RTV { + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D11_TEX3D_RTV { + MipSlice: UINT, + FirstWSlice: UINT, + WSize: UINT, +}} +UNION!{union D3D11_RENDER_TARGET_VIEW_DESC_u { + [u32; 3], + Buffer Buffer_mut: D3D11_BUFFER_RTV, + Texture1D Texture1D_mut: D3D11_TEX1D_RTV, + Texture1DArray Texture1DArray_mut: D3D11_TEX1D_ARRAY_RTV, + Texture2D Texture2D_mut: D3D11_TEX2D_RTV, + Texture2DArray Texture2DArray_mut: D3D11_TEX2D_ARRAY_RTV, + Texture2DMS Texture2DMS_mut: D3D11_TEX2DMS_RTV, + Texture2DMSArray Texture2DMSArray_mut: D3D11_TEX2DMS_ARRAY_RTV, + Texture3D Texture3D_mut: D3D11_TEX3D_RTV, +}} +STRUCT!{struct D3D11_RENDER_TARGET_VIEW_DESC { + Format: DXGI_FORMAT, + ViewDimension: D3D11_RTV_DIMENSION, + u: D3D11_RENDER_TARGET_VIEW_DESC_u, +}} +RIDL!{#[uuid(0xdfdba067, 0x0b8d, 0x4865, 0x87, 0x5b, 0xd7, 0xb4, 0x51, 0x6c, 0xc1, 0x64)] +interface ID3D11RenderTargetView(ID3D11RenderTargetViewVtbl): ID3D11View(ID3D11ViewVtbl) { + fn GetDesc( + pDesc: *mut D3D11_RENDER_TARGET_VIEW_DESC, + ) -> (), +}} +STRUCT!{struct D3D11_TEX1D_DSV { + MipSlice: UINT, +}} +STRUCT!{struct D3D11_TEX1D_ARRAY_DSV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D11_TEX2D_DSV { + MipSlice: UINT, +}} +STRUCT!{struct D3D11_TEX2D_ARRAY_DSV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D11_TEX2DMS_DSV { + UnusedField_NothingToDefine: UINT, +}} +STRUCT!{struct D3D11_TEX2DMS_ARRAY_DSV { + FirstArraySlice: UINT, + ArraySize: UINT, +}} +ENUM!{enum D3D11_DSV_FLAG { + D3D11_DSV_READ_ONLY_DEPTH = 0x1, + D3D11_DSV_READ_ONLY_STENCIL = 0x2, +}} +UNION!{union D3D11_DEPTH_STENCIL_VIEW_DESC_u { + [u32; 3], + Texture1D Texture1D_mut: D3D11_TEX1D_DSV, + Texture1DArray Texture1DArray_mut: D3D11_TEX1D_ARRAY_DSV, + Texture2D Texture2D_mut: D3D11_TEX2D_DSV, + Texture2DArray Texture2DArray_mut: D3D11_TEX2D_ARRAY_DSV, + Texture2DMS Texture2DMS_mut: D3D11_TEX2DMS_DSV, + Texture2DMSArray Texture2DMSArray_mut: D3D11_TEX2DMS_ARRAY_DSV, +}} +STRUCT!{struct D3D11_DEPTH_STENCIL_VIEW_DESC { + Format: DXGI_FORMAT, + ViewDimension: D3D11_DSV_DIMENSION, + Flags: UINT, + u: D3D11_DEPTH_STENCIL_VIEW_DESC_u, +}} +RIDL!{#[uuid(0x9fdac92a, 0x1876, 0x48c3, 0xaf, 0xad, 0x25, 0xb9, 0x4f, 0x84, 0xa9, 0xb6)] +interface ID3D11DepthStencilView(ID3D11DepthStencilViewVtbl): ID3D11View(ID3D11ViewVtbl) { + fn GetDesc( + pDesc: *mut D3D11_DEPTH_STENCIL_VIEW_DESC, + ) -> (), +}} +ENUM!{enum D3D11_BUFFER_UAV_FLAG { + D3D11_BUFFER_UAV_FLAG_RAW = 0x1, + D3D11_BUFFER_UAV_FLAG_APPEND = 0x2, + D3D11_BUFFER_UAV_FLAG_COUNTER = 0x4, +}} +STRUCT!{struct D3D11_BUFFER_UAV { + FirstElement: UINT, + NumElements: UINT, + Flags: UINT, +}} +STRUCT!{struct D3D11_TEX1D_UAV { + MipSlice: UINT, +}} +STRUCT!{struct D3D11_TEX1D_ARRAY_UAV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D11_TEX2D_UAV { + MipSlice: UINT, +}} +STRUCT!{struct D3D11_TEX2D_ARRAY_UAV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D11_TEX3D_UAV { + MipSlice: UINT, + FirstWSlice: UINT, + WSize: UINT, +}} +UNION!{union D3D11_UNORDERED_ACCESS_VIEW_DESC_u { + [u32; 3], + Buffer Buffer_mut: D3D11_BUFFER_UAV, + Texture1D Texture1D_mut: D3D11_TEX1D_UAV, + Texture1DArray Texture1DArray_mut: D3D11_TEX1D_ARRAY_UAV, + Texture2D Texture2D_mut: D3D11_TEX2D_UAV, + Texture2DArray Texture2DArray_mut: D3D11_TEX2D_ARRAY_UAV, + Texture3D Texture3D_mut: D3D11_TEX3D_UAV, +}} +STRUCT!{struct D3D11_UNORDERED_ACCESS_VIEW_DESC { + Format: DXGI_FORMAT, + ViewDimension: D3D11_UAV_DIMENSION, + u: D3D11_UNORDERED_ACCESS_VIEW_DESC_u, +}} +RIDL!{#[uuid(0x28acf509, 0x7f5c, 0x48f6, 0x86, 0x11, 0xf3, 0x16, 0x01, 0x0a, 0x63, 0x80)] +interface ID3D11UnorderedAccessView(ID3D11UnorderedAccessViewVtbl): ID3D11View(ID3D11ViewVtbl) { + fn GetDesc( + pDesc: *mut D3D11_UNORDERED_ACCESS_VIEW_DESC, + ) -> (), +}} +RIDL!{#[uuid(0x3b301d64, 0xd678, 0x4289, 0x88, 0x97, 0x22, 0xf8, 0x92, 0x8b, 0x72, 0xf3)] +interface ID3D11VertexShader(ID3D11VertexShaderVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) {}} +RIDL!{#[uuid(0x8e5c6061, 0x628a, 0x4c8e, 0x82, 0x64, 0xbb, 0xe4, 0x5c, 0xb3, 0xd5, 0xdd)] +interface ID3D11HullShader(ID3D11HullShaderVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) {}} +RIDL!{#[uuid(0xf582c508, 0x0f36, 0x490c, 0x99, 0x77, 0x31, 0xee, 0xce, 0x26, 0x8c, 0xfa)] +interface ID3D11DomainShader(ID3D11DomainShaderVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) {}} +RIDL!{#[uuid(0x38325b96, 0xeffb, 0x4022, 0xba, 0x02, 0x2e, 0x79, 0x5b, 0x70, 0x27, 0x5c)] +interface ID3D11GeometryShader(ID3D11GeometryShaderVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) {}} +RIDL!{#[uuid(0xea82e40d, 0x51dc, 0x4f33, 0x93, 0xd4, 0xdb, 0x7c, 0x91, 0x25, 0xae, 0x8c)] +interface ID3D11PixelShader(ID3D11PixelShaderVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) {}} +RIDL!{#[uuid(0x4f5b196e, 0xc2bd, 0x495e, 0xbd, 0x01, 0x1f, 0xde, 0xd3, 0x8e, 0x49, 0x69)] +interface ID3D11ComputeShader(ID3D11ComputeShaderVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) {}} +RIDL!{#[uuid(0xe4819ddc, 0x4cf0, 0x4025, 0xbd, 0x26, 0x5d, 0xe8, 0x2a, 0x3e, 0x07, 0xb7)] +interface ID3D11InputLayout(ID3D11InputLayoutVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) {}} +ENUM!{enum D3D11_FILTER { + D3D11_FILTER_MIN_MAG_MIP_POINT = 0, + D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1, + D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4, + D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x5, + D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, + D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, + D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, + D3D11_FILTER_MIN_MAG_MIP_LINEAR = 0x15, + D3D11_FILTER_ANISOTROPIC = 0x55, + D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x80, + D3D11_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81, + D3D11_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84, + D3D11_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85, + D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90, + D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91, + D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94, + D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, + D3D11_FILTER_COMPARISON_ANISOTROPIC = 0xd5, + D3D11_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 0x100, + D3D11_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x101, + D3D11_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x104, + D3D11_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x105, + D3D11_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x110, + D3D11_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x111, + D3D11_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x114, + D3D11_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR = 0x115, + D3D11_FILTER_MINIMUM_ANISOTROPIC = 0x155, + D3D11_FILTER_MAXIMUM_MIN_MAG_MIP_POINT = 0x180, + D3D11_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x181, + D3D11_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x184, + D3D11_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x185, + D3D11_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x190, + D3D11_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x191, + D3D11_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x194, + D3D11_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR = 0x195, + D3D11_FILTER_MAXIMUM_ANISOTROPIC = 0x1d5, +}} +ENUM!{enum D3D11_FILTER_TYPE { + D3D11_FILTER_TYPE_POINT = 0, + D3D11_FILTER_TYPE_LINEAR = 1, +}} +ENUM!{enum D3D11_FILTER_REDUCTION_TYPE { + D3D11_FILTER_REDUCTION_TYPE_STANDARD = 0, + D3D11_FILTER_REDUCTION_TYPE_COMPARISON = 1, + D3D11_FILTER_REDUCTION_TYPE_MINIMUM = 2, + D3D11_FILTER_REDUCTION_TYPE_MAXIMUM = 3, +}} +pub const D3D11_FILTER_REDUCTION_TYPE_MASK: DWORD = 0x3; +pub const D3D11_FILTER_REDUCTION_TYPE_SHIFT: DWORD = 7; +pub const D3D11_FILTER_TYPE_MASK: DWORD = 0x3; +pub const D3D11_MIN_FILTER_SHIFT: DWORD = 4; +pub const D3D11_MAG_FILTER_SHIFT: DWORD = 2; +pub const D3D11_MIP_FILTER_SHIFT: DWORD = 0; +pub const D3D11_COMPARISON_FILTERING_BIT: DWORD = 0x80; +pub const D3D11_ANISOTROPIC_FILTERING_BIT: DWORD = 0x40; +ENUM!{enum D3D11_TEXTURE_ADDRESS_MODE { + D3D11_TEXTURE_ADDRESS_WRAP = 1, + D3D11_TEXTURE_ADDRESS_MIRROR = 2, + D3D11_TEXTURE_ADDRESS_CLAMP = 3, + D3D11_TEXTURE_ADDRESS_BORDER = 4, + D3D11_TEXTURE_ADDRESS_MIRROR_ONCE = 5, +}} +STRUCT!{struct D3D11_SAMPLER_DESC { + Filter: D3D11_FILTER, + AddressU: D3D11_TEXTURE_ADDRESS_MODE, + AddressV: D3D11_TEXTURE_ADDRESS_MODE, + AddressW: D3D11_TEXTURE_ADDRESS_MODE, + MipLODBias: FLOAT, + MaxAnisotropy: UINT, + ComparisonFunc: D3D11_COMPARISON_FUNC, + BorderColor: [FLOAT; 4], + MinLOD: FLOAT, + MaxLOD: FLOAT, +}} +RIDL!{#[uuid(0xda6fea51, 0x564c, 0x4487, 0x98, 0x10, 0xf0, 0xd0, 0xf9, 0xb4, 0xe3, 0xa5)] +interface ID3D11SamplerState(ID3D11SamplerStateVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetDesc( + pDesc: *mut D3D11_SAMPLER_DESC, + ) -> (), +}} +ENUM!{enum D3D11_FORMAT_SUPPORT { + D3D11_FORMAT_SUPPORT_BUFFER = 0x1, + D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER = 0x2, + D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER = 0x4, + D3D11_FORMAT_SUPPORT_SO_BUFFER = 0x8, + D3D11_FORMAT_SUPPORT_TEXTURE1D = 0x10, + D3D11_FORMAT_SUPPORT_TEXTURE2D = 0x20, + D3D11_FORMAT_SUPPORT_TEXTURE3D = 0x40, + D3D11_FORMAT_SUPPORT_TEXTURECUBE = 0x80, + D3D11_FORMAT_SUPPORT_SHADER_LOAD = 0x100, + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE = 0x200, + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON = 0x400, + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT = 0x800, + D3D11_FORMAT_SUPPORT_MIP = 0x1000, + D3D11_FORMAT_SUPPORT_MIP_AUTOGEN = 0x2000, + D3D11_FORMAT_SUPPORT_RENDER_TARGET = 0x4000, + D3D11_FORMAT_SUPPORT_BLENDABLE = 0x8000, + D3D11_FORMAT_SUPPORT_DEPTH_STENCIL = 0x10000, + D3D11_FORMAT_SUPPORT_CPU_LOCKABLE = 0x20000, + D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE = 0x40000, + D3D11_FORMAT_SUPPORT_DISPLAY = 0x80000, + D3D11_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT = 0x100000, + D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET = 0x200000, + D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD = 0x400000, + D3D11_FORMAT_SUPPORT_SHADER_GATHER = 0x800000, + D3D11_FORMAT_SUPPORT_BACK_BUFFER_CAST = 0x1000000, + D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW = 0x2000000, + D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON = 0x4000000, + D3D11_FORMAT_SUPPORT_DECODER_OUTPUT = 0x8000000, + D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT = 0x10000000, + D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_INPUT = 0x20000000, + D3D11_FORMAT_SUPPORT_VIDEO_ENCODER = 0x40000000, +}} +ENUM!{enum D3D11_FORMAT_SUPPORT2 { + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_ADD = 0x1, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS = 0x2, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE = 0x4, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE = 0x8, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX = 0x10, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX = 0x20, + D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD = 0x40, + D3D11_FORMAT_SUPPORT2_UAV_TYPED_STORE = 0x80, + D3D11_FORMAT_SUPPORT2_OUTPUT_MERGER_LOGIC_OP = 0x100, + D3D11_FORMAT_SUPPORT2_TILED = 0x200, + D3D11_FORMAT_SUPPORT2_SHAREABLE = 0x400, + D3D11_FORMAT_SUPPORT2_MULTIPLANE_OVERLAY = 0x4000, +}} +RIDL!{#[uuid(0x4b35d0cd, 0x1e15, 0x4258, 0x9c, 0x98, 0x1b, 0x13, 0x33, 0xf6, 0xdd, 0x3b)] +interface ID3D11Asynchronous(ID3D11AsynchronousVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetDataSize() -> UINT, +}} +ENUM!{enum D3D11_ASYNC_GETDATA_FLAG { + D3D11_ASYNC_GETDATA_DONOTFLUSH = 0x1, +}} +ENUM!{enum D3D11_QUERY { + D3D11_QUERY_EVENT = 0, + D3D11_QUERY_OCCLUSION = D3D11_QUERY_EVENT + 1u32, + D3D11_QUERY_TIMESTAMP = D3D11_QUERY_OCCLUSION + 1u32, + D3D11_QUERY_TIMESTAMP_DISJOINT = D3D11_QUERY_TIMESTAMP + 1u32, + D3D11_QUERY_PIPELINE_STATISTICS = D3D11_QUERY_TIMESTAMP_DISJOINT + 1u32, + D3D11_QUERY_OCCLUSION_PREDICATE = D3D11_QUERY_PIPELINE_STATISTICS + 1u32, + D3D11_QUERY_SO_STATISTICS = D3D11_QUERY_OCCLUSION_PREDICATE + 1u32, + D3D11_QUERY_SO_OVERFLOW_PREDICATE = D3D11_QUERY_SO_STATISTICS + 1u32, + D3D11_QUERY_SO_STATISTICS_STREAM0 = D3D11_QUERY_SO_OVERFLOW_PREDICATE + 1u32, + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0 = D3D11_QUERY_SO_STATISTICS_STREAM0 + 1u32, + D3D11_QUERY_SO_STATISTICS_STREAM1 = D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0 + 1u32, + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1 = D3D11_QUERY_SO_STATISTICS_STREAM1 + 1u32, + D3D11_QUERY_SO_STATISTICS_STREAM2 = D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1 + 1u32, + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2 = D3D11_QUERY_SO_STATISTICS_STREAM2 + 1u32, + D3D11_QUERY_SO_STATISTICS_STREAM3 = D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2 + 1u32, + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3 = D3D11_QUERY_SO_STATISTICS_STREAM3 + 1u32, +}} +ENUM!{enum D3D11_QUERY_MISC_FLAG { + D3D11_QUERY_MISC_PREDICATEHINT = 0x1, +}} +STRUCT!{struct D3D11_QUERY_DESC { + Query: D3D11_QUERY, + MiscFlags: UINT, +}} +RIDL!{#[uuid(0xd6c00747, 0x87b7, 0x425e, 0xb8, 0x4d, 0x44, 0xd1, 0x08, 0x56, 0x0a, 0xfd)] +interface ID3D11Query(ID3D11QueryVtbl): ID3D11Asynchronous(ID3D11AsynchronousVtbl) { + fn GetDesc( + pDesc: *mut D3D11_QUERY_DESC, + ) -> (), +}} +RIDL!{#[uuid(0x9eb576dd, 0x9f77, 0x4d86, 0x81, 0xaa, 0x8b, 0xab, 0x5f, 0xe4, 0x90, 0xe2)] +interface ID3D11Predicate(ID3D11PredicateVtbl): ID3D11Query(ID3D11QueryVtbl) {}} +STRUCT!{struct D3D11_QUERY_DATA_TIMESTAMP_DISJOINT { + Frequency: UINT64, + Disjoint: BOOL, +}} +STRUCT!{struct D3D11_QUERY_DATA_PIPELINE_STATISTICS { + IAVertices: UINT64, + IAPrimitives: UINT64, + VSInvocations: UINT64, + GSInvocations: UINT64, + GSPrimitives: UINT64, + CInvocations: UINT64, + CPrimitives: UINT64, + PSInvocations: UINT64, + HSInvocations: UINT64, + DSInvocations: UINT64, + CSInvocations: UINT64, +}} +STRUCT!{struct D3D11_QUERY_DATA_SO_STATISTICS { + NumPrimitivesWritten: UINT64, + PrimitivesStorageNeeded: UINT64, +}} +ENUM!{enum D3D11_COUNTER { + D3D11_COUNTER_DEVICE_DEPENDENT_0 = 0x40000000, +}} +ENUM!{enum D3D11_COUNTER_TYPE { + D3D11_COUNTER_TYPE_FLOAT32 = 0, + D3D11_COUNTER_TYPE_UINT16 = D3D11_COUNTER_TYPE_FLOAT32 + 1u32, + D3D11_COUNTER_TYPE_UINT32 = D3D11_COUNTER_TYPE_UINT16 + 1u32, + D3D11_COUNTER_TYPE_UINT64 = D3D11_COUNTER_TYPE_UINT32 + 1u32, +}} +STRUCT!{struct D3D11_COUNTER_DESC { + Counter: D3D11_COUNTER, + MiscFlags: UINT, +}} +STRUCT!{struct D3D11_COUNTER_INFO { + LastDeviceDependentCounter: D3D11_COUNTER, + NumSimultaneousCounters: UINT, + NumDetectableParallelUnits: UINT8, +}} +RIDL!{#[uuid(0x6e8c49fb, 0xa371, 0x4770, 0xb4, 0x40, 0x29, 0x08, 0x60, 0x22, 0xb7, 0x41)] +interface ID3D11Counter(ID3D11CounterVtbl): ID3D11Asynchronous(ID3D11AsynchronousVtbl) { + fn GetDesc( + pDesc: *mut D3D11_COUNTER_DESC, + ) -> (), +}} +ENUM!{enum D3D11_STANDARD_MULTISAMPLE_QUALITY_LEVELS { + D3D11_STANDARD_MULTISAMPLE_PATTERN = 0xffffffff, + D3D11_CENTER_MULTISAMPLE_PATTERN = 0xfffffffe, +}} +ENUM!{enum D3D11_DEVICE_CONTEXT_TYPE { + D3D11_DEVICE_CONTEXT_IMMEDIATE = 0, + D3D11_DEVICE_CONTEXT_DEFERRED = D3D11_DEVICE_CONTEXT_IMMEDIATE + 1u32, +}} +STRUCT!{struct D3D11_CLASS_INSTANCE_DESC { + InstanceId: UINT, + InstanceIndex: UINT, + TypeId: UINT, + ConstantBuffer: UINT, + BaseConstantBufferOffset: UINT, + BaseTexture: UINT, + BaseSampler: UINT, + Created: BOOL, +}} +RIDL!{#[uuid(0xa6cd7faa, 0xb0b7, 0x4a2f, 0x94, 0x36, 0x86, 0x62, 0xa6, 0x57, 0x97, 0xcb)] +interface ID3D11ClassInstance(ID3D11ClassInstanceVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetClassLinkage( + ppLinkage: *mut *mut ID3D11ClassLinkage, + ) -> (), + fn GetDesc( + pDesc: *mut D3D11_CLASS_INSTANCE_DESC, + ) -> (), + fn GetInstanceName( + pInstanceName: LPSTR, + pBufferLength: *mut SIZE_T, + ) -> (), + fn GetTypeName( + pTypeName: LPSTR, + pBufferLength: *mut SIZE_T, + ) -> (), +}} +RIDL!{#[uuid(0xddf57cba, 0x9543, 0x46e4, 0xa1, 0x2b, 0xf2, 0x07, 0xa0, 0xfe, 0x7f, 0xed)] +interface ID3D11ClassLinkage(ID3D11ClassLinkageVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetClassInstance( + GetClassInstance: LPCSTR, + InstanceIndex: UINT, + ppInstance: *mut *mut ID3D11ClassInstance, + ) -> HRESULT, + fn CreateClassInstance( + pClassTypeName: LPCSTR, + ConstantBufferOffset: UINT, + ConstantVectorOffset: UINT, + TextureOffset: UINT, + SamplerOffset: UINT, + ppInstance: *mut *mut ID3D11ClassInstance, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa24bc4d1, 0x769e, 0x43f7, 0x80, 0x13, 0x98, 0xff, 0x56, 0x6c, 0x18, 0xe2)] +interface ID3D11CommandList(ID3D11CommandListVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetContextFlags() -> UINT, +}} +ENUM!{enum D3D11_FEATURE { + D3D11_FEATURE_THREADING = 0, + D3D11_FEATURE_DOUBLES = D3D11_FEATURE_THREADING + 1u32, + D3D11_FEATURE_FORMAT_SUPPORT = D3D11_FEATURE_DOUBLES + 1u32, + D3D11_FEATURE_FORMAT_SUPPORT2 = D3D11_FEATURE_FORMAT_SUPPORT + 1u32, + D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS = D3D11_FEATURE_FORMAT_SUPPORT2 + 1u32, + D3D11_FEATURE_D3D11_OPTIONS = D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS + 1u32, + D3D11_FEATURE_ARCHITECTURE_INFO = D3D11_FEATURE_D3D11_OPTIONS + 1u32, + D3D11_FEATURE_D3D9_OPTIONS = D3D11_FEATURE_ARCHITECTURE_INFO + 1u32, + D3D11_FEATURE_SHADER_MIN_PRECISION_SUPPORT = D3D11_FEATURE_D3D9_OPTIONS + 1u32, + D3D11_FEATURE_D3D9_SHADOW_SUPPORT = D3D11_FEATURE_SHADER_MIN_PRECISION_SUPPORT + 1u32, + D3D11_FEATURE_D3D11_OPTIONS1 = D3D11_FEATURE_D3D9_SHADOW_SUPPORT + 1u32, + D3D11_FEATURE_D3D9_SIMPLE_INSTANCING_SUPPORT = D3D11_FEATURE_D3D11_OPTIONS1 + 1u32, + D3D11_FEATURE_MARKER_SUPPORT = D3D11_FEATURE_D3D9_SIMPLE_INSTANCING_SUPPORT + 1u32, + D3D11_FEATURE_D3D9_OPTIONS1 = D3D11_FEATURE_MARKER_SUPPORT + 1u32, + D3D11_FEATURE_D3D11_OPTIONS2 = D3D11_FEATURE_D3D9_OPTIONS1 + 1u32, + D3D11_FEATURE_D3D11_OPTIONS3 = D3D11_FEATURE_D3D11_OPTIONS2 + 1u32, + D3D11_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT = D3D11_FEATURE_D3D11_OPTIONS3 + 1u32, +}} +STRUCT!{struct D3D11_FEATURE_DATA_THREADING { + DriverConcurrentCreates: BOOL, + DriverCommandLists: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_DOUBLES { + DoublePrecisionFloatShaderOps: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_FORMAT_SUPPORT { + InFormat: DXGI_FORMAT, + OutFormatSupport: UINT, +}} +STRUCT!{struct D3D11_FEATURE_DATA_FORMAT_SUPPORT2 { + InFormat: DXGI_FORMAT, + OutFormatSupport2: UINT, +}} +STRUCT!{struct D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS { + ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_D3D11_OPTIONS { + OutputMergerLogicOp: BOOL, + UAVOnlyRenderingForcedSampleCount: BOOL, + DiscardAPIsSeenByDriver: BOOL, + FlagsForUpdateAndCopySeenByDriver: BOOL, + ClearView: BOOL, + CopyWithOverlap: BOOL, + ConstantBufferPartialUpdate: BOOL, + ConstantBufferOffsetting: BOOL, + MapNoOverwriteOnDynamicConstantBuffer: BOOL, + MapNoOverwriteOnDynamicBufferSRV: BOOL, + MultisampleRTVWithForcedSampleCountOne: BOOL, + SAD4ShaderInstructions: BOOL, + ExtendedDoublesShaderInstructions: BOOL, + ExtendedResourceSharing: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_ARCHITECTURE_INFO { + TileBasedDeferredRenderer: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_D3D9_OPTIONS { + FullNonPow2TextureSupport: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_D3D9_SHADOW_SUPPORT { + SupportsDepthAsTextureWithLessEqualComparisonFilter: BOOL, +}} +ENUM!{enum D3D11_SHADER_MIN_PRECISION_SUPPORT { + D3D11_SHADER_MIN_PRECISION_10_BIT = 0x1, + D3D11_SHADER_MIN_PRECISION_16_BIT = 0x2, +}} +STRUCT!{struct D3D11_FEATURE_DATA_SHADER_MIN_PRECISION_SUPPORT { + PixelShaderMinPrecision: UINT, + AllOtherShaderStagesMinPrecision: UINT, +}} +ENUM!{enum D3D11_TILED_RESOURCES_TIER { + D3D11_TILED_RESOURCES_NOT_SUPPORTED = 0, + D3D11_TILED_RESOURCES_TIER_1 = 1, + D3D11_TILED_RESOURCES_TIER_2 = 2, + D3D11_TILED_RESOURCES_TIER_3 = 3, +}} +STRUCT!{struct D3D11_FEATURE_DATA_D3D11_OPTIONS1 { + TiledResourcesTier: D3D11_TILED_RESOURCES_TIER, + MinMaxFiltering: BOOL, + ClearViewAlsoSupportsDepthOnlyFormats: BOOL, + MapOnDefaultBuffers: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_D3D9_SIMPLE_INSTANCING_SUPPORT { + SimpleInstancingSupported: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_MARKER_SUPPORT { + Profile: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_D3D9_OPTIONS1 { + FullNonPow2TextureSupported: BOOL, + DepthAsTextureWithLessEqualComparisonFilterSupported: BOOL, + SimpleInstancingSupported: BOOL, + TextureCubeFaceRenderTargetWithNonCubeDepthStencilSupported: BOOL, +}} +ENUM!{enum D3D11_CONSERVATIVE_RASTERIZATION_TIER { + D3D11_CONSERVATIVE_RASTERIZATION_NOT_SUPPORTED = 0, + D3D11_CONSERVATIVE_RASTERIZATION_TIER_1 = 1, + D3D11_CONSERVATIVE_RASTERIZATION_TIER_2 = 2, + D3D11_CONSERVATIVE_RASTERIZATION_TIER_3 = 3, +}} +STRUCT!{struct D3D11_FEATURE_DATA_D3D11_OPTIONS2 { + PSSpecifiedStencilRefSupported: BOOL, + TypedUAVLoadAdditionalFormats: BOOL, + ROVsSupported: BOOL, + ConservativeRasterizationTier: D3D11_CONSERVATIVE_RASTERIZATION_TIER, + TiledResourcesTier: D3D11_TILED_RESOURCES_TIER, + MapOnDefaultTextures: BOOL, + StandardSwizzle: BOOL, + UnifiedMemoryArchitecture: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_D3D11_OPTIONS3 { + VPAndRTArrayIndexFromAnyShaderFeedingRasterizer: BOOL, +}} +STRUCT!{struct D3D11_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT { + MaxGPUVirtualAddressBitsPerResource: UINT, + MaxGPUVirtualAddressBitsPerProcess: UINT, +}} +RIDL!{#[uuid(0xc0bfa96c, 0xe089, 0x44fb, 0x8e, 0xaf, 0x26, 0xf8, 0x79, 0x61, 0x90, 0xda)] +interface ID3D11DeviceContext(ID3D11DeviceContextVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn VSSetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + ) -> (), + fn PSSetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *const *mut ID3D11ShaderResourceView, + ) -> (), + fn PSSetShader( + pPixelShader: *mut ID3D11PixelShader, + ppClassInstances: *const *mut ID3D11ClassInstance, + NumClassInstances: UINT, + ) -> (), + fn PSSetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *const *mut ID3D11SamplerState, + ) -> (), + fn VSSetShader( + pVertexShader: *mut ID3D11VertexShader, + ppClassInstances: *const *mut ID3D11ClassInstance, + NumClassInstances: UINT, + ) -> (), + fn DrawIndexed( + IndexCount: UINT, + StartIndexLocation: UINT, + BaseVertexLocation: INT, + ) -> (), + fn Draw( + VertexCount: UINT, + StartVertexLocation: UINT, + ) -> (), + fn Map( + pResource: *mut ID3D11Resource, + Subresource: UINT, + MapType: D3D11_MAP, + MapFlags: UINT, + pMappedResource: *mut D3D11_MAPPED_SUBRESOURCE, + ) -> HRESULT, + fn Unmap( + pResource: *mut ID3D11Resource, + Subresource: UINT, + ) -> (), + fn PSSetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + ) -> (), + fn IASetInputLayout( + pInputLayout: *mut ID3D11InputLayout, + ) -> (), + fn IASetVertexBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppVertexBuffers: *const *mut ID3D11Buffer, + pStrides: *const UINT, + pOffsets: *const UINT, + ) -> (), + fn IASetIndexBuffer( + pIndexBuffer: *mut ID3D11Buffer, + Format: DXGI_FORMAT, + Offset: UINT, + ) -> (), + fn DrawIndexedInstanced( + IndexCountPerInstance: UINT, + InstanceCount: UINT, + StartIndexLocation: UINT, + BaseVertexLocation: INT, + StartInstanceLocation: UINT, + ) -> (), + fn DrawInstanced( + VertexCountPerInstance: UINT, + InstanceCount: UINT, + StartVertexLocation: UINT, + StartInstanceLocation: UINT, + ) -> (), + fn GSSetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + ) -> (), + fn GSSetShader( + pShader: *mut ID3D11GeometryShader, + ppClassInstances: *const *mut ID3D11ClassInstance, + NumClassInstances: UINT, + ) -> (), + fn IASetPrimitiveTopology( + Topology: D3D11_PRIMITIVE_TOPOLOGY, + ) -> (), + fn VSSetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *const *mut ID3D11ShaderResourceView, + ) -> (), + fn VSSetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *const *mut ID3D11SamplerState, + ) -> (), + fn Begin( + pAsync: *mut ID3D11Asynchronous, + ) -> (), + fn End( + pAsync: *mut ID3D11Asynchronous, + ) -> (), + fn GetData( + pAsync: *mut ID3D11Asynchronous, + pData: *mut c_void, + DataSize: UINT, + GetDataFlags: UINT, + ) -> HRESULT, + fn SetPredication( + pPredicate: *mut ID3D11Predicate, + PredicateValue: BOOL, + ) -> (), + fn GSSetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *const *mut ID3D11ShaderResourceView, + ) -> (), + fn GSSetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *const *mut ID3D11SamplerState, + ) -> (), + fn OMSetRenderTargets( + NumViews: UINT, + ppRenderTargetViews: *const *mut ID3D11RenderTargetView, + pDepthStencilView: *mut ID3D11DepthStencilView, + ) -> (), + fn OMSetRenderTargetsAndUnorderedAccessViews( + NumRTVs: UINT, + ppRenderTargetViews: *const *mut ID3D11RenderTargetView, + pDepthStencilView: *mut ID3D11DepthStencilView, + UAVStartSlot: UINT, + NumUAVs: UINT, + ppUnorderedAccessViews: *const *mut ID3D11UnorderedAccessView, + pUAVInitialCounts: *const UINT, + ) -> (), + fn OMSetBlendState( + pBlendState: *mut ID3D11BlendState, + BlendFactor: &[FLOAT; 4], + SampleMask: UINT, + ) -> (), + fn OMSetDepthStencilState( + pDepthStencilState: *mut ID3D11DepthStencilState, + StencilRef: UINT, + ) -> (), + fn SOSetTargets( + NumBuffers: UINT, + ppSOTargets: *const *mut ID3D11Buffer, + pOffsets: *const UINT, + ) -> (), + fn DrawAuto() -> (), + fn DrawIndexedInstancedIndirect( + pBufferForArgs: *mut ID3D11Buffer, + AlignedByteOffsetForArgs: UINT, + ) -> (), + fn DrawInstancedIndirect( + pBufferForArgs: *mut ID3D11Buffer, + AlignedByteOffsetForArgs: UINT, + ) -> (), + fn Dispatch( + ThreadGroupCountX: UINT, + ThreadGroupCountY: UINT, + ThreadGroupCountZ: UINT, + ) -> (), + fn DispatchIndirect( + pBufferForArgs: *mut ID3D11Buffer, + AlignedByteOffsetForArgs: UINT, + ) -> (), + fn RSSetState( + pRasterizerState: *mut ID3D11RasterizerState, + ) -> (), + fn RSSetViewports( + NumViewports: UINT, + pViewports: *const D3D11_VIEWPORT, + ) -> (), + fn RSSetScissorRects( + NumRects: UINT, + pRects: *const D3D11_RECT, + ) -> (), + fn CopySubresourceRegion( + pDstResource: *mut ID3D11Resource, + DstSubresource: UINT, + DstX: UINT, + DstY: UINT, + DstZ: UINT, + pSrcResource: *mut ID3D11Resource, + SrcSubresource: UINT, + pSrcBox: *const D3D11_BOX, + ) -> (), + fn CopyResource( + pDstResource: *mut ID3D11Resource, + pSrcResource: *mut ID3D11Resource, + ) -> (), + fn UpdateSubresource( + pDstResource: *mut ID3D11Resource, + DstSubresource: UINT, + pDstBox: *const D3D11_BOX, + pSrcData: *const c_void, + SrcRowPitch: UINT, + SrcDepthPitch: UINT, + ) -> (), + fn CopyStructureCount( + pDstBuffer: *mut ID3D11Buffer, + DstAlignedByteOffset: UINT, + pSrcView: *mut ID3D11UnorderedAccessView, + ) -> (), + fn ClearRenderTargetView( + pRenderTargetView: *mut ID3D11RenderTargetView, + ColorRGBA: &[FLOAT; 4], + ) -> (), + fn ClearUnorderedAccessViewUint( + pUnorderedAccessView: *mut ID3D11UnorderedAccessView, + Values: &[UINT; 4], + ) -> (), + fn ClearUnorderedAccessViewFloat( + pUnorderedAccessView: *mut ID3D11UnorderedAccessView, + Values: &[FLOAT; 4], + ) -> (), + fn ClearDepthStencilView( + pDepthStencilView: *mut ID3D11DepthStencilView, + ClearFlags: UINT, + Depth: FLOAT, + Stencil: UINT8, + ) -> (), + fn GenerateMips( + pShaderResourceView: *mut ID3D11ShaderResourceView, + ) -> (), + fn SetResourceMinLOD( + pResource: *mut ID3D11Resource, + MinLOD: FLOAT, + ) -> (), + fn GetResourceMinLOD( + pResource: *mut ID3D11Resource, + ) -> FLOAT, + fn ResolveSubresource( + pDstResource: *mut ID3D11Resource, + DstSubresource: UINT, + pSrcResource: *mut ID3D11Resource, + SrcSubresource: UINT, + Format: DXGI_FORMAT, + ) -> (), + fn ExecuteCommandList( + pCommandList: *mut ID3D11CommandList, + RestoreContextState: BOOL, + ) -> (), + fn HSSetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *const *mut ID3D11ShaderResourceView, + ) -> (), + fn HSSetShader( + pHullShader: *mut ID3D11HullShader, + ppClassInstances: *const *mut ID3D11ClassInstance, + NumClassInstances: UINT, + ) -> (), + fn HSSetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *const *mut ID3D11SamplerState, + ) -> (), + fn HSSetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + ) -> (), + fn DSSetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *const *mut ID3D11ShaderResourceView, + ) -> (), + fn DSSetShader( + pDomainShader: *mut ID3D11DomainShader, + ppClassInstances: *const *mut ID3D11ClassInstance, + NumClassInstances: UINT, + ) -> (), + fn DSSetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *const *mut ID3D11SamplerState, + ) -> (), + fn DSSetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + ) -> (), + fn CSSetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *const *mut ID3D11ShaderResourceView, + ) -> (), + fn CSSetUnorderedAccessViews( + StartSlot: UINT, + NumUAVs: UINT, + ppUnorderedAccessViews: *const *mut ID3D11UnorderedAccessView, + pUAVInitialCounts: *const UINT, + ) -> (), + fn CSSetShader( + pComputeShader: *mut ID3D11ComputeShader, + ppClassInstances: *const *mut ID3D11ClassInstance, + NumClassInstances: UINT, + ) -> (), + fn CSSetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *const *mut ID3D11SamplerState, + ) -> (), + fn CSSetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + ) -> (), + fn VSGetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + ) -> (), + fn PSGetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView, + ) -> (), + fn PSGetShader( + ppPixelShader: *mut *mut ID3D11PixelShader, + ppClassInstances: *mut *mut ID3D11ClassInstance, + pNumClassInstances: *mut UINT, + ) -> (), + fn PSGetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *mut *mut ID3D11SamplerState, + ) -> (), + fn VSGetShader( + ppVertexShader: *mut *mut ID3D11VertexShader, + ppClassInstances: *mut *mut ID3D11ClassInstance, + pNumClassInstances: *mut UINT, + ) -> (), + fn PSGetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + ) -> (), + fn IAGetInputLayout( + ppInputLayout: *mut *mut ID3D11InputLayout, + ) -> (), + fn IAGetVertexBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppVertexBuffers: *mut *mut ID3D11Buffer, + pStrides: *mut UINT, + pOffsets: *mut UINT, + ) -> (), + fn IAGetIndexBuffer( + pIndexBuffer: *mut *mut ID3D11Buffer, + Format: *mut DXGI_FORMAT, + Offset: *mut UINT, + ) -> (), + fn GSGetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + ) -> (), + fn GSGetShader( + ppGeometryShader: *mut *mut ID3D11GeometryShader, + ppClassInstances: *mut *mut ID3D11ClassInstance, + pNumClassInstances: *mut UINT, + ) -> (), + fn IAGetPrimitiveTopology( + pTopology: *mut D3D11_PRIMITIVE_TOPOLOGY, + ) -> (), + fn VSGetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView, + ) -> (), + fn VSGetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *mut *mut ID3D11SamplerState, + ) -> (), + fn GetPredication( + ppPredicate: *mut *mut ID3D11Predicate, + pPredicateValue: *mut BOOL, + ) -> (), + fn GSGetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView, + ) -> (), + fn GSGetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *mut *mut ID3D11SamplerState, + ) -> (), + fn OMGetRenderTargets( + NumViews: UINT, + ppRenderTargetViews: *mut *mut ID3D11RenderTargetView, + ppDepthStencilView: *mut *mut ID3D11DepthStencilView, + ) -> (), + fn OMGetRenderTargetsAndUnorderedAccessViews( + NumRTVs: UINT, + ppRenderTargetViews: *mut *mut ID3D11RenderTargetView, + ppDepthStencilView: *mut *mut ID3D11DepthStencilView, + UAVStartSlot: UINT, + ppUnorderedAccessViews: *mut *mut ID3D11UnorderedAccessView, + ) -> (), + fn OMGetBlendState( + ppBlendState: *mut *mut ID3D11BlendState, + BlendFactor: &mut [FLOAT; 4], + pSampleMask: *mut UINT, + ) -> (), + fn OMGetDepthStencilState( + ppDepthStencilState: *mut *mut ID3D11DepthStencilState, + pStencilRef: *mut UINT, + ) -> (), + fn SOGetTargets( + NumBuffers: UINT, + ppSOTargets: *mut *mut ID3D11Buffer, + ) -> (), + fn RSGetState( + ppRasterizerState: *mut *mut ID3D11RasterizerState, + ) -> (), + fn RSGetViewports( + pNumViewports: *mut UINT, + pViewports: *mut D3D11_VIEWPORT, + ) -> (), + fn RSGetScissorRects( + pNumRects: *mut UINT, + pRects: *mut D3D11_RECT, + ) -> (), + fn HSGetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView, + ) -> (), + fn HSGetShader( + ppHullShader: *mut *mut ID3D11HullShader, + ppClassInstances: *mut *mut ID3D11ClassInstance, + pNumClassInstances: *mut UINT, + ) -> (), + fn HSGetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *mut *mut ID3D11SamplerState, + ) -> (), + fn HSGetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + ) -> (), + fn DSGetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView, + ) -> (), + fn DSGetShader( + ppDomainShader: *mut *mut ID3D11DomainShader, + ppClassInstances: *mut *mut ID3D11ClassInstance, + pNumClassInstances: *mut UINT, + ) -> (), + fn DSGetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *mut *mut ID3D11SamplerState, + ) -> (), + fn DSGetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + ) -> (), + fn CSGetShaderResources( + StartSlot: UINT, + NumViews: UINT, + ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView, + ) -> (), + fn CSGetUnorderedAccessViews( + StartSlot: UINT, + NumUAVs: UINT, + ppUnorderedAccessViews: *mut *mut ID3D11UnorderedAccessView, + ) -> (), + fn CSGetShader( + ppComputeShader: *mut *mut ID3D11ComputeShader, + ppClassInstances: *mut *mut ID3D11ClassInstance, + pNumClassInstances: *mut UINT, + ) -> (), + fn CSGetSamplers( + StartSlot: UINT, + NumSamplers: UINT, + ppSamplers: *mut *mut ID3D11SamplerState, + ) -> (), + fn CSGetConstantBuffers( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + ) -> (), + fn ClearState() -> (), + fn Flush() -> (), + fn GetType() -> D3D11_DEVICE_CONTEXT_TYPE, + fn GetContextFlags() -> UINT, + fn FinishCommandList( + RestoreDeferredContextState: BOOL, + ppCommandList: *mut *mut ID3D11CommandList, + ) -> HRESULT, +}} +DEFINE_GUID!{D3D11_DECODER_PROFILE_MPEG2_MOCOMP, + 0xe6a9f44b, 0x61b0, 0x4563, 0x9e, 0xa4, 0x63, 0xd2, 0xa3, 0xc6, 0xfe, 0x66} +DEFINE_GUID!{D3D11_DECODER_PROFILE_MPEG2_IDCT, + 0xbf22ad00, 0x03ea, 0x4690, 0x80, 0x77, 0x47, 0x33, 0x46, 0x20, 0x9b, 0x7e} +DEFINE_GUID!{D3D11_DECODER_PROFILE_MPEG2_VLD, + 0xee27417f, 0x5e28, 0x4e65, 0xbe, 0xea, 0x1d, 0x26, 0xb5, 0x08, 0xad, 0xc9} +DEFINE_GUID!{D3D11_DECODER_PROFILE_MPEG1_VLD, + 0x6f3ec719, 0x3735, 0x42cc, 0x80, 0x63, 0x65, 0xcc, 0x3c, 0xb3, 0x66, 0x16} +DEFINE_GUID!{D3D11_DECODER_PROFILE_MPEG2and1_VLD, + 0x86695f12, 0x340e, 0x4f04, 0x9f, 0xd3, 0x92, 0x53, 0xdd, 0x32, 0x74, 0x60} +DEFINE_GUID!{D3D11_DECODER_PROFILE_H264_MOCOMP_NOFGT, + 0x1b81be64, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_H264_MOCOMP_FGT, + 0x1b81be65, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_H264_IDCT_NOFGT, + 0x1b81be66, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_H264_IDCT_FGT, + 0x1b81be67, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_H264_VLD_NOFGT, + 0x1b81be68, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_H264_VLD_FGT, + 0x1b81be69, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_H264_VLD_WITHFMOASO_NOFGT, + 0xd5f04ff9, 0x3418, 0x45d8, 0x95, 0x61, 0x32, 0xa7, 0x6a, 0xae, 0x2d, 0xdd} +DEFINE_GUID!{D3D11_DECODER_PROFILE_H264_VLD_STEREO_PROGRESSIVE_NOFGT, + 0xd79be8da, 0x0cf1, 0x4c81, 0xb8, 0x2a, 0x69, 0xa4, 0xe2, 0x36, 0xf4, 0x3d} +DEFINE_GUID!{D3D11_DECODER_PROFILE_H264_VLD_STEREO_NOFGT, + 0xf9aaccbb, 0xc2b6, 0x4cfc, 0x87, 0x79, 0x57, 0x07, 0xb1, 0x76, 0x05, 0x52} +DEFINE_GUID!{D3D11_DECODER_PROFILE_H264_VLD_MULTIVIEW_NOFGT, + 0x705b9d82, 0x76cf, 0x49d6, 0xb7, 0xe6, 0xac, 0x88, 0x72, 0xdb, 0x01, 0x3c} +DEFINE_GUID!{D3D11_DECODER_PROFILE_WMV8_POSTPROC, + 0x1b81be80, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_WMV8_MOCOMP, + 0x1b81be81, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_WMV9_POSTPROC, + 0x1b81be90, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_WMV9_MOCOMP, + 0x1b81be91, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_WMV9_IDCT, + 0x1b81be94, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_VC1_POSTPROC, + 0x1b81bea0, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_VC1_MOCOMP, + 0x1b81bea1, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_VC1_IDCT, + 0x1b81bea2, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_VC1_VLD, + 0x1b81bea3, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_VC1_D2010, + 0x1b81bea4, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{D3D11_DECODER_PROFILE_MPEG4PT2_VLD_SIMPLE, + 0xefd64d74, 0xc9e8, 0x41d7, 0xa5, 0xe9, 0xe9, 0xb0, 0xe3, 0x9f, 0xa3, 0x19} +DEFINE_GUID!{D3D11_DECODER_PROFILE_MPEG4PT2_VLD_ADVSIMPLE_NOGMC, + 0xed418a9f, 0x010d, 0x4eda, 0x9a, 0xe3, 0x9a, 0x65, 0x35, 0x8d, 0x8d, 0x2e} +DEFINE_GUID!{D3D11_DECODER_PROFILE_MPEG4PT2_VLD_ADVSIMPLE_GMC, + 0xab998b5b, 0x4258, 0x44a9, 0x9f, 0xeb, 0x94, 0xe5, 0x97, 0xa6, 0xba, 0xae} +DEFINE_GUID!{D3D11_DECODER_PROFILE_HEVC_VLD_MAIN, + 0x5b11d51b, 0x2f4c, 0x4452, 0xbc, 0xc3, 0x09, 0xf2, 0xa1, 0x16, 0x0c, 0xc0} +DEFINE_GUID!{D3D11_DECODER_PROFILE_HEVC_VLD_MAIN10, + 0x107af0e0, 0xef1a, 0x4d19, 0xab, 0xa8, 0x67, 0xa1, 0x63, 0x07, 0x3d, 0x13} +DEFINE_GUID!{D3D11_DECODER_PROFILE_VP9_VLD_PROFILE0, + 0x463707f8, 0xa1d0, 0x4585, 0x87, 0x6d, 0x83, 0xaa, 0x6d, 0x60, 0xb8, 0x9e} +DEFINE_GUID!{D3D11_DECODER_PROFILE_VP8_VLD, + 0x90b899ea, 0x3a62, 0x4705, 0x88, 0xb3, 0x8d, 0xf0, 0x4b, 0x27, 0x44, 0xe7} +STRUCT!{struct D3D11_VIDEO_DECODER_DESC { + Guid: GUID, + SampleWidth: UINT, + SampleHeight: UINT, + OutputFormat: DXGI_FORMAT, +}} +STRUCT!{struct D3D11_VIDEO_DECODER_CONFIG { + guidConfigBitstreamEncryption: GUID, + guidConfigMBcontrolEncryption: GUID, + guidConfigResidDiffEncryption: GUID, + ConfigBitstreamRaw: UINT, + ConfigMBcontrolRasterOrder: UINT, + ConfigResidDiffHost: UINT, + ConfigSpatialResid8: UINT, + ConfigResid8Subtraction: UINT, + ConfigSpatialHost8or9Clipping: UINT, + ConfigSpatialResidInterleaved: UINT, + ConfigIntraResidUnsigned: UINT, + ConfigResidDiffAccelerator: UINT, + ConfigHostInverseScan: UINT, + ConfigSpecificIDCT: UINT, + Config4GroupedCoefs: UINT, + ConfigMinRenderTargetBuffCount: USHORT, + ConfigDecoderSpecific: USHORT, +}} +ENUM!{enum D3D11_VIDEO_DECODER_BUFFER_TYPE { + D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS = 0, + D3D11_VIDEO_DECODER_BUFFER_MACROBLOCK_CONTROL = 1, + D3D11_VIDEO_DECODER_BUFFER_RESIDUAL_DIFFERENCE = 2, + D3D11_VIDEO_DECODER_BUFFER_DEBLOCKING_CONTROL = 3, + D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX = 4, + D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL = 5, + D3D11_VIDEO_DECODER_BUFFER_BITSTREAM = 6, + D3D11_VIDEO_DECODER_BUFFER_MOTION_VECTOR = 7, + D3D11_VIDEO_DECODER_BUFFER_FILM_GRAIN = 8, +}} +STRUCT!{struct D3D11_AES_CTR_IV { + IV: UINT64, + Count: UINT64, +}} +STRUCT!{struct D3D11_ENCRYPTED_BLOCK_INFO { + NumEncryptedBytesAtBeginning: UINT, + NumBytesInSkipPattern: UINT, + NumBytesInEncryptPattern: UINT, +}} +STRUCT!{struct D3D11_VIDEO_DECODER_BUFFER_DESC { + BufferType: D3D11_VIDEO_DECODER_BUFFER_TYPE, + BufferIndex: UINT, + DataOffset: UINT, + DataSize: UINT, + FirstMBaddress: UINT, + NumMBsInBuffer: UINT, + Width: UINT, + Height: UINT, + Stride: UINT, + ReservedBits: UINT, + pIV: *mut c_void, + IVSize: UINT, + PartialEncryption: BOOL, + EncryptedBlockInfo: D3D11_ENCRYPTED_BLOCK_INFO, +}} +STRUCT!{struct D3D11_VIDEO_DECODER_EXTENSION { + Function: UINT, + pPrivateInputData: *mut c_void, + PrivateInputDataSize: UINT, + pPrivateOutputData: *mut c_void, + PrivateOutputDataSize: UINT, + ResourceCount: UINT, + ppResourceList: *mut *mut ID3D11Resource, +}} +RIDL!{#[uuid(0x3c9c5b51, 0x995d, 0x48d1, 0x9b, 0x8d, 0xfa, 0x5c, 0xae, 0xde, 0xd6, 0x5c)] +interface ID3D11VideoDecoder(ID3D11VideoDecoderVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetCreationParameters( + pVideoDesc: *mut D3D11_VIDEO_DECODER_DESC, + pConfig: *mut D3D11_VIDEO_DECODER_CONFIG, + ) -> HRESULT, + fn GetDriverHandle( + pDriverHandle: *mut HANDLE, + ) -> HRESULT, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT { + D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT_INPUT = 0x1, + D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT_OUTPUT = 0x2, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_DEVICE_CAPS { + D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_LINEAR_SPACE = 0x1, + D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_xvYCC = 0x2, + D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_RGB_RANGE_CONVERSION = 0x4, + D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_YCbCr_MATRIX_CONVERSION = 0x8, + D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_NOMINAL_RANGE = 0x10, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_FEATURE_CAPS { + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ALPHA_FILL = 0x1, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_CONSTRICTION = 0x2, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_LUMA_KEY = 0x4, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ALPHA_PALETTE = 0x8, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_LEGACY = 0x10, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_STEREO = 0x20, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ROTATION = 0x40, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ALPHA_STREAM = 0x80, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_PIXEL_ASPECT_RATIO = 0x100, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_MIRROR = 0x200, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_SHADER_USAGE = 0x400, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_FILTER_CAPS { + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_BRIGHTNESS = 0x1, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_CONTRAST = 0x2, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_HUE = 0x4, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_SATURATION = 0x8, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_NOISE_REDUCTION = 0x10, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_EDGE_ENHANCEMENT = 0x20, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_ANAMORPHIC_SCALING = 0x40, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_STEREO_ADJUSTMENT = 0x80, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_FORMAT_CAPS { + D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_RGB_INTERLACED = 0x1, + D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_RGB_PROCAMP = 0x2, + D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_RGB_LUMA_KEY = 0x4, + D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_PALETTE_INTERLACED = 0x8, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS { + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_DENOISE = 0x1, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_DERINGING = 0x2, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_EDGE_ENHANCEMENT = 0x4, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_COLOR_CORRECTION = 0x8, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_FLESH_TONE_MAPPING = 0x10, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_IMAGE_STABILIZATION = 0x20, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_SUPER_RESOLUTION = 0x40, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_ANAMORPHIC_SCALING = 0x80, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_STEREO_CAPS { + D3D11_VIDEO_PROCESSOR_STEREO_CAPS_MONO_OFFSET = 0x1, + D3D11_VIDEO_PROCESSOR_STEREO_CAPS_ROW_INTERLEAVED = 0x2, + D3D11_VIDEO_PROCESSOR_STEREO_CAPS_COLUMN_INTERLEAVED = 0x4, + D3D11_VIDEO_PROCESSOR_STEREO_CAPS_CHECKERBOARD = 0x8, + D3D11_VIDEO_PROCESSOR_STEREO_CAPS_FLIP_MODE = 0x10, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_CAPS { + DeviceCaps: UINT, + FeatureCaps: UINT, + FilterCaps: UINT, + InputFormatCaps: UINT, + AutoStreamCaps: UINT, + StereoCaps: UINT, + RateConversionCapsCount: UINT, + MaxInputStreams: UINT, + MaxStreamStates: UINT, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS { + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BLEND = 0x1, + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BOB = 0x2, + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_ADAPTIVE = 0x4, + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_MOTION_COMPENSATION = 0x8, + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_INVERSE_TELECINE = 0x10, + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_FRAME_RATE_CONVERSION = 0x20, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS { + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_32 = 0x1, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_22 = 0x2, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_2224 = 0x4, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_2332 = 0x8, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_32322 = 0x10, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_55 = 0x20, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_64 = 0x40, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_87 = 0x80, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_222222222223 = 0x100, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_OTHER = 0x80000000, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS { + PastFrames: UINT, + FutureFrames: UINT, + ProcessorCaps: UINT, + ITelecineCaps: UINT, + CustomRateCount: UINT, +}} +ENUM!{enum D3D11_CONTENT_PROTECTION_CAPS { + D3D11_CONTENT_PROTECTION_CAPS_SOFTWARE = 0x1, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE = 0x2, + D3D11_CONTENT_PROTECTION_CAPS_PROTECTION_ALWAYS_ON = 0x4, + D3D11_CONTENT_PROTECTION_CAPS_PARTIAL_DECRYPTION = 0x8, + D3D11_CONTENT_PROTECTION_CAPS_CONTENT_KEY = 0x10, + D3D11_CONTENT_PROTECTION_CAPS_FRESHEN_SESSION_KEY = 0x20, + D3D11_CONTENT_PROTECTION_CAPS_ENCRYPTED_READ_BACK = 0x40, + D3D11_CONTENT_PROTECTION_CAPS_ENCRYPTED_READ_BACK_KEY = 0x80, + D3D11_CONTENT_PROTECTION_CAPS_SEQUENTIAL_CTR_IV = 0x100, + D3D11_CONTENT_PROTECTION_CAPS_ENCRYPT_SLICEDATA_ONLY = 0x200, + D3D11_CONTENT_PROTECTION_CAPS_DECRYPTION_BLT = 0x400, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_PROTECT_UNCOMPRESSED = 0x800, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_PROTECTED_MEMORY_PAGEABLE = 0x1000, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_TEARDOWN = 0x2000, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_DRM_COMMUNICATION = 0x4000, +}} +DEFINE_GUID!{D3D11_CRYPTO_TYPE_AES128_CTR, + 0x9b6bd711, 0x4f74, 0x41c9, 0x9e, 0x7b, 0x0b, 0xe2, 0xd7, 0xd9, 0x3b, 0x4f} +DEFINE_GUID!{D3D11_DECODER_ENCRYPTION_HW_CENC, + 0x89d6ac4f, 0x09f2, 0x4229, 0xb2, 0xcd, 0x37, 0x74, 0x0a, 0x6d, 0xfd, 0x81} +DEFINE_GUID!{D3D11_KEY_EXCHANGE_HW_PROTECTION, + 0xb1170d8a, 0x628d, 0x4da3, 0xad, 0x3b, 0x82, 0xdd, 0xb0, 0x8b, 0x49, 0x70} +STRUCT!{struct D3D11_VIDEO_CONTENT_PROTECTION_CAPS { + Caps: UINT, + KeyExchangeTypeCount: UINT, + BlockAlignmentSize: UINT, + ProtectedMemorySize: ULONGLONG, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_CUSTOM_RATE { + CustomRate: DXGI_RATIONAL, + OutputFrames: UINT, + InputInterlaced: BOOL, + InputFramesOrFields: UINT, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_FILTER { + D3D11_VIDEO_PROCESSOR_FILTER_BRIGHTNESS = 0, + D3D11_VIDEO_PROCESSOR_FILTER_CONTRAST = 1, + D3D11_VIDEO_PROCESSOR_FILTER_HUE = 2, + D3D11_VIDEO_PROCESSOR_FILTER_SATURATION = 3, + D3D11_VIDEO_PROCESSOR_FILTER_NOISE_REDUCTION = 4, + D3D11_VIDEO_PROCESSOR_FILTER_EDGE_ENHANCEMENT = 5, + D3D11_VIDEO_PROCESSOR_FILTER_ANAMORPHIC_SCALING = 6, + D3D11_VIDEO_PROCESSOR_FILTER_STEREO_ADJUSTMENT = 7, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_FILTER_RANGE { + Minimum: c_int, + Maximum: c_int, + Default: c_int, + Multiplier: c_float, +}} +ENUM!{enum D3D11_VIDEO_FRAME_FORMAT { + D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE = 0, + D3D11_VIDEO_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST = 1, + D3D11_VIDEO_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST = 2, +}} +ENUM!{enum D3D11_VIDEO_USAGE { + D3D11_VIDEO_USAGE_PLAYBACK_NORMAL = 0, + D3D11_VIDEO_USAGE_OPTIMAL_SPEED = 1, + D3D11_VIDEO_USAGE_OPTIMAL_QUALITY = 2, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_CONTENT_DESC { + InputFrameFormat: D3D11_VIDEO_FRAME_FORMAT, + InputFrameRate: DXGI_RATIONAL, + InputWidth: UINT, + InputHeight: UINT, + OutputFrameRate: DXGI_RATIONAL, + OutputWidth: UINT, + OutputHeight: UINT, + Usage: D3D11_VIDEO_USAGE, +}} +RIDL!{#[uuid(0x31627037, 0x53ab, 0x4200, 0x90, 0x61, 0x05, 0xfa, 0xa9, 0xab, 0x45, 0xf9)] +interface ID3D11VideoProcessorEnumerator(ID3D11VideoProcessorEnumeratorVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetVideoProcessorContentDesc( + pContentDesc: *mut D3D11_VIDEO_PROCESSOR_CONTENT_DESC, + ) -> HRESULT, + fn CheckVideoProcessorFormat( + Format: DXGI_FORMAT, + pFlags: *mut UINT, + ) -> HRESULT, + fn GetVideoProcessorCaps( + pCaps: *mut D3D11_VIDEO_PROCESSOR_CAPS, + ) -> HRESULT, + fn GetVideoProcessorRateConversionCaps( + TypeIndex: UINT, + pCaps: *mut D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS, + ) -> HRESULT, + fn GetVideoProcessorCustomRate( + TypeIndex: UINT, + CustomRateIndex: UINT, + pRate: *mut D3D11_VIDEO_PROCESSOR_CUSTOM_RATE, + ) -> HRESULT, + fn GetVideoProcessorFilterRange( + Filter: D3D11_VIDEO_PROCESSOR_FILTER, + Range: *mut D3D11_VIDEO_PROCESSOR_FILTER_RANGE, + ) -> HRESULT, +}} +STRUCT!{struct D3D11_VIDEO_COLOR_RGBA { + R: c_float, + G: c_float, + B: c_float, + A: c_float, +}} +STRUCT!{struct D3D11_VIDEO_COLOR_YCbCrA { + Y: c_float, + Cb: c_float, + Cr: c_float, + A: c_float, +}} +UNION!{union D3D11_VIDEO_COLOR { + [f32; 4], + YCbCr YCbCr_mut: D3D11_VIDEO_COLOR_YCbCrA, + RGBA RGBA_mut: D3D11_VIDEO_COLOR_RGBA, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE { + D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_UNDEFINED = 0, + D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_16_235 = 1, + D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_0_255 = 2, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_COLOR_SPACE { + bitfield: UINT, +}} +BITFIELD!{D3D11_VIDEO_PROCESSOR_COLOR_SPACE bitfield: UINT [ + Usage set_Usage[0..1], + RGB_Range set_RGB_Range[1..2], + YCbCr_Matrix set_YCbCr_Matrix[2..3], + YCbCr_xvYCC set_YCbCr_xvYCC[3..4], + Nominal_Range set_Nominal_Range[4..6], +]} +ENUM!{enum D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE { + D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_OPAQUE = 0, + D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_BACKGROUND = 1, + D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_DESTINATION = 2, + D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_SOURCE_STREAM = 3, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_OUTPUT_RATE { + D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_NORMAL = 0, + D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_HALF = 1, + D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_CUSTOM = 2, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_STEREO_FORMAT { + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_MONO = 0, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_HORIZONTAL = 1, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_VERTICAL = 2, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_SEPARATE = 3, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_MONO_OFFSET = 4, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_ROW_INTERLEAVED = 5, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_COLUMN_INTERLEAVED = 6, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_CHECKERBOARD = 7, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE { + D3D11_VIDEO_PROCESSOR_STEREO_FLIP_NONE = 0, + D3D11_VIDEO_PROCESSOR_STEREO_FLIP_FRAME0 = 1, + D3D11_VIDEO_PROCESSOR_STEREO_FLIP_FRAME1 = 2, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_ROTATION { + D3D11_VIDEO_PROCESSOR_ROTATION_IDENTITY = 0, + D3D11_VIDEO_PROCESSOR_ROTATION_90 = 1, + D3D11_VIDEO_PROCESSOR_ROTATION_180 = 2, + D3D11_VIDEO_PROCESSOR_ROTATION_270 = 3, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_STREAM { + Enable: BOOL, + OutputIndex: UINT, + InputFrameOrField: UINT, + PastFrames: UINT, + FutureFrames: UINT, + ppPastSurfaces: *mut *mut ID3D11VideoProcessorInputView, + pInputSurface: *mut ID3D11VideoProcessorInputView, + ppFutureSurfaces: *mut *mut ID3D11VideoProcessorInputView, + ppPastSurfacesRight: *mut *mut ID3D11VideoProcessorInputView, + pInputSurfaceRight: *mut ID3D11VideoProcessorInputView, + ppFutureSurfacesRight: *mut *mut ID3D11VideoProcessorInputView, +}} +RIDL!{#[uuid(0x1d7b0652, 0x185f, 0x41c6, 0x85, 0xce, 0x0c, 0x5b, 0xe3, 0xd4, 0xae, 0x6c)] +interface ID3D11VideoProcessor(ID3D11VideoProcessorVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetContentDesc( + pDesc: *mut D3D11_VIDEO_PROCESSOR_CONTENT_DESC, + ) -> (), + fn GetRateConversionCaps( + pCaps: *mut D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS, + ) -> (), +}} +STRUCT!{struct D3D11_OMAC { + Omac: [BYTE; 16], +}} +ENUM!{enum D3D11_AUTHENTICATED_CHANNEL_TYPE { + D3D11_AUTHENTICATED_CHANNEL_D3D11 = 1, + D3D11_AUTHENTICATED_CHANNEL_DRIVER_SOFTWARE = 2, + D3D11_AUTHENTICATED_CHANNEL_DRIVER_HARDWARE = 3, +}} +RIDL!{#[uuid(0x3015a308, 0xdcbd, 0x47aa, 0xa7, 0x47, 0x19, 0x24, 0x86, 0xd1, 0x4d, 0x4a)] +interface ID3D11AuthenticatedChannel(ID3D11AuthenticatedChannelVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetCertificateSize( + pCertificateSize: *mut UINT, + ) -> HRESULT, + fn GetCertificate( + CertificateSize: UINT, + pCertificate: *mut BYTE, + ) -> HRESULT, + fn GetChannelHandle( + pChannelHandle: *mut HANDLE, + ) -> (), +}} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_PROTECTION, + 0xa84eb584, 0xc495, 0x48aa, 0xb9, 0x4d, 0x8b, 0xd2, 0xd6, 0xfb, 0xce, 0x05} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_CHANNEL_TYPE, + 0xbc1b18a5, 0xb1fb, 0x42ab, 0xbd, 0x94, 0xb5, 0x82, 0x8b, 0x4b, 0xf7, 0xbe} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_DEVICE_HANDLE, + 0xec1c539d, 0x8cff, 0x4e2a, 0xbc, 0xc4, 0xf5, 0x69, 0x2f, 0x99, 0xf4, 0x80} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_CRYPTO_SESSION, + 0x2634499e, 0xd018, 0x4d74, 0xac, 0x17, 0x7f, 0x72, 0x40, 0x59, 0x52, 0x8d} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_RESTRICTED_SHARED_RESOURCE_PROCESS_COUNT, + 0x0db207b3, 0x9450, 0x46a6, 0x82, 0xde, 0x1b, 0x96, 0xd4, 0x4f, 0x9c, 0xf2} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_RESTRICTED_SHARED_RESOURCE_PROCESS, + 0x649bbadb, 0xf0f4, 0x4639, 0xa1, 0x5b, 0x24, 0x39, 0x3f, 0xc3, 0xab, 0xac} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_UNRESTRICTED_PROTECTED_SHARED_RESOURCE_COUNT, + 0x012f0bd6, 0xe662, 0x4474, 0xbe, 0xfd, 0xaa, 0x53, 0xe5, 0x14, 0x3c, 0x6d} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_OUTPUT_ID_COUNT, + 0x2c042b5e, 0x8c07, 0x46d5, 0xaa, 0xbe, 0x8f, 0x75, 0xcb, 0xad, 0x4c, 0x31} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_OUTPUT_ID, + 0x839ddca3, 0x9b4e, 0x41e4, 0xb0, 0x53, 0x89, 0x2b, 0xd2, 0xa1, 0x1e, 0xe7} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_ACCESSIBILITY_ATTRIBUTES, + 0x6214d9d2, 0x432c, 0x4abb, 0x9f, 0xce, 0x21, 0x6e, 0xea, 0x26, 0x9e, 0x3b} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_ENCRYPTION_WHEN_ACCESSIBLE_GUID_COUNT, + 0xb30f7066, 0x203c, 0x4b07, 0x93, 0xfc, 0xce, 0xaa, 0xfd, 0x61, 0x24, 0x1e} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_ENCRYPTION_WHEN_ACCESSIBLE_GUID, + 0xf83a5958, 0xe986, 0x4bda, 0xbe, 0xb0, 0x41, 0x1f, 0x6a, 0x7a, 0x01, 0xb7} +DEFINE_GUID!{D3D11_AUTHENTICATED_QUERY_CURRENT_ENCRYPTION_WHEN_ACCESSIBLE, + 0xec1791c7, 0xdad3, 0x4f15, 0x9e, 0xc3, 0xfa, 0xa9, 0x3d, 0x60, 0xd4, 0xf0} +DEFINE_GUID!{D3D11_AUTHENTICATED_CONFIGURE_INITIALIZE, + 0x06114bdb, 0x3523, 0x470a, 0x8d, 0xca, 0xfb, 0xc2, 0x84, 0x51, 0x54, 0xf0} +DEFINE_GUID!{D3D11_AUTHENTICATED_CONFIGURE_PROTECTION, + 0x50455658, 0x3f47, 0x4362, 0xbf, 0x99, 0xbf, 0xdf, 0xcd, 0xe9, 0xed, 0x29} +DEFINE_GUID!{D3D11_AUTHENTICATED_CONFIGURE_CRYPTO_SESSION, + 0x6346cc54, 0x2cfc, 0x4ad4, 0x82, 0x24, 0xd1, 0x58, 0x37, 0xde, 0x77, 0x00} +DEFINE_GUID!{D3D11_AUTHENTICATED_CONFIGURE_SHARED_RESOURCE, + 0x0772d047, 0x1b40, 0x48e8, 0x9c, 0xa6, 0xb5, 0xf5, 0x10, 0xde, 0x9f, 0x01} +DEFINE_GUID!{D3D11_AUTHENTICATED_CONFIGURE_ENCRYPTION_WHEN_ACCESSIBLE, + 0x41fff286, 0x6ae0, 0x4d43, 0x9d, 0x55, 0xa4, 0x6e, 0x9e, 0xfd, 0x15, 0x8a} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_INPUT { + QueryType: GUID, + hChannel: HANDLE, + SequenceNumber: UINT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_OUTPUT { + omac: D3D11_OMAC, + QueryType: GUID, + hChannel: HANDLE, + SequenceNumber: UINT, + ReturnCode: HRESULT, +}} +//FIXME bitfield +STRUCT!{struct D3D11_AUTHENTICATED_PROTECTION_FLAGS { + u: UINT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_PROTECTION_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + ProtectionFlags: D3D11_AUTHENTICATED_PROTECTION_FLAGS, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_CHANNEL_TYPE_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + ChannelType: D3D11_AUTHENTICATED_CHANNEL_TYPE, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_DEVICE_HANDLE_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + DeviceHandle: HANDLE, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_CRYPTO_SESSION_INPUT { + Input: D3D11_AUTHENTICATED_QUERY_INPUT, + DecoderHandle: HANDLE, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_CRYPTO_SESSION_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + DecoderHandle: HANDLE, + CryptoSessionHandle: HANDLE, + DeviceHandle: HANDLE, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_RESTRICTED_SHARED_RESOURCE_PROCESS_COUNT_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + RestrictedSharedResourceProcessCount: UINT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_RESTRICTED_SHARED_RESOURCE_PROCESS_INPUT { + Input: D3D11_AUTHENTICATED_QUERY_INPUT, + ProcessIndex: UINT, +}} +ENUM!{enum D3D11_AUTHENTICATED_PROCESS_IDENTIFIER_TYPE { + DD3D11_PROCESSIDTYPE_UNKNOWN = 0, + DD3D11_PROCESSIDTYPE_DWM = 1, + DD3D11_PROCESSIDTYPE_HANDLE = 2, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_RESTRICTED_SHARED_RESOURCE_PROCESS_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + ProcessIndex: UINT, + ProcessIdentifier: D3D11_AUTHENTICATED_PROCESS_IDENTIFIER_TYPE, + ProcessHandle: HANDLE, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_UNRESTRICTED_PROTECTED_SHARED_RESOURCE_COUNT_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + UnrestrictedProtectedSharedResourceCount: UINT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_OUTPUT_ID_COUNT_INPUT { + Input: D3D11_AUTHENTICATED_QUERY_INPUT, + DeviceHandle: HANDLE, + CryptoSessionHandle: HANDLE, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_OUTPUT_ID_COUNT_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + DeviceHandle: HANDLE, + CryptoSessionHandle: HANDLE, + OutputIDCount: UINT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_OUTPUT_ID_INPUT { + Input: D3D11_AUTHENTICATED_QUERY_INPUT, + DeviceHandle: HANDLE, + CryptoSessionHandle: HANDLE, + OutputIDIndex: UINT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_OUTPUT_ID_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + DeviceHandle: HANDLE, + CryptoSessionHandle: HANDLE, + OutputIDIndex: UINT, + OutputID: UINT64, +}} +ENUM!{enum D3D11_BUS_TYPE { + D3D11_BUS_TYPE_OTHER = 0, + D3D11_BUS_TYPE_PCI = 0x1, + D3D11_BUS_TYPE_PCIX = 0x2, + D3D11_BUS_TYPE_PCIEXPRESS = 0x3, + D3D11_BUS_TYPE_AGP = 0x4, + D3D11_BUS_IMPL_MODIFIER_INSIDE_OF_CHIPSET = 0x10000, + D3D11_BUS_IMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP = 0x20000, + D3D11_BUS_IMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x30000, + D3D11_BUS_IMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR = 0x40000, + D3D11_BUS_IMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x50000, + D3D11_BUS_IMPL_MODIFIER_NON_STANDARD = 0x80000000, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_ACESSIBILITY_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + BusType: D3D11_BUS_TYPE, + AccessibleInContiguousBlocks: BOOL, + AccessibleInNonContiguousBlocks: BOOL, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_ACCESSIBILITY_ENCRYPTION_GUID_COUNT_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + EncryptionGuidCount: UINT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_ACCESSIBILITY_ENCRYPTION_GUID_INPUT { + Input: D3D11_AUTHENTICATED_QUERY_INPUT, + EncryptionGuidIndex: UINT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_ACCESSIBILITY_ENCRYPTION_GUID_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + EncryptionGuidIndex: UINT, + EncryptionGuid: GUID, +}} +STRUCT!{struct D3D11_AUTHENTICATED_QUERY_CURRENT_ACCESSIBILITY_ENCRYPTION_OUTPUT { + Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, + EncryptionGuid: GUID, +}} +STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_INPUT { + omac: D3D11_OMAC, + ConfigureType: GUID, + hChannel: HANDLE, + SequenceNumber: UINT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_OUTPUT { + omac: D3D11_OMAC, + ConfigureType: GUID, + hChannel: HANDLE, + SequenceNumber: UINT, + ReturnCode: HRESULT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_INITIALIZE_INPUT { + Parameters: D3D11_AUTHENTICATED_CONFIGURE_INPUT, + StartSequenceQuery: UINT, + StartSequenceConfigure: UINT, +}} +STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_PROTECTION_INPUT { + Parameters: D3D11_AUTHENTICATED_CONFIGURE_INPUT, + Protections: D3D11_AUTHENTICATED_PROTECTION_FLAGS, +}} +STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_CRYPTO_SESSION_INPUT { + Parameters: D3D11_AUTHENTICATED_CONFIGURE_INPUT, + DecoderHandle: HANDLE, + CryptoSessionHandle: HANDLE, + DeviceHandle: HANDLE, +}} +STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_SHARED_RESOURCE_INPUT { + Parameters: D3D11_AUTHENTICATED_CONFIGURE_INPUT, + ProcessType: D3D11_AUTHENTICATED_PROCESS_IDENTIFIER_TYPE, + ProcessHandle: HANDLE, + AllowAccess: BOOL, +}} +STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_ACCESSIBLE_ENCRYPTION_INPUT { + Parameters: D3D11_AUTHENTICATED_CONFIGURE_INPUT, + EncryptionGuid: GUID, +}} +DEFINE_GUID!{D3D11_KEY_EXCHANGE_RSAES_OAEP, + 0xc1949895, 0xd72a, 0x4a1d, 0x8e, 0x5d, 0xed, 0x85, 0x7d, 0x17, 0x15, 0x20} +RIDL!{#[uuid(0x9b32f9ad, 0xbdcc, 0x40a6, 0xa3, 0x9d, 0xd5, 0xc8, 0x65, 0x84, 0x57, 0x20)] +interface ID3D11CryptoSession(ID3D11CryptoSessionVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetCryptoType( + pCryptoType: *mut GUID, + ) -> (), + fn GetDecoderProfile( + pDecoderProfile: *mut GUID, + ) -> (), + fn GetCertificateSize( + pCertificateSize: *mut UINT, + ) -> HRESULT, + fn GetCertificate( + CertificateSize: UINT, + pCertificate: *mut BYTE, + ) -> HRESULT, + fn GetCryptoSessionHandle( + pCertificate: *mut HANDLE, + ) -> (), +}} +ENUM!{enum D3D11_VDOV_DIMENSION { + D3D11_VDOV_DIMENSION_UNKNOWN = 0, + D3D11_VDOV_DIMENSION_TEXTURE2D = 1, +}} +STRUCT!{struct D3D11_TEX2D_VDOV { + ArraySlice: UINT, +}} +STRUCT!{struct D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC { + DecodeProfile: GUID, + ViewDimension: D3D11_VDOV_DIMENSION, + Texture2D: D3D11_TEX2D_VDOV, +}} +RIDL!{#[uuid(0xc2931aea, 0x2a85, 0x4f20, 0x86, 0x0f, 0xfb, 0xa1, 0xfd, 0x25, 0x6e, 0x18)] +interface ID3D11VideoDecoderOutputView(ID3D11VideoDecoderOutputViewVtbl): + ID3D11View(ID3D11ViewVtbl) { + fn GetDesc( + pDesc: *mut D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC, + ) -> (), +}} +ENUM!{enum D3D11_VPIV_DIMENSION { + D3D11_VPIV_DIMENSION_UNKNOWN = 0, + D3D11_VPIV_DIMENSION_TEXTURE2D = 1, +}} +STRUCT!{struct D3D11_TEX2D_VPIV { + MipSlice: UINT, + ArraySlice: UINT, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC { + FourCC: UINT, + ViewDimension: D3D11_VPIV_DIMENSION, + Texture2D: D3D11_TEX2D_VPIV, +}} +RIDL!{#[uuid(0x11ec5a5f, 0x51dc, 0x4945, 0xab, 0x34, 0x6e, 0x8c, 0x21, 0x30, 0x0e, 0xa5)] +interface ID3D11VideoProcessorInputView(ID3D11VideoProcessorInputViewVtbl): + ID3D11View(ID3D11ViewVtbl) { + fn GetDesc( + pDesc: *mut D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC, + ) -> (), +}} +ENUM!{enum D3D11_VPOV_DIMENSION { + D3D11_VPOV_DIMENSION_UNKNOWN = 0, + D3D11_VPOV_DIMENSION_TEXTURE2D = 1, + D3D11_VPOV_DIMENSION_TEXTURE2DARRAY = 2, +}} +STRUCT!{struct D3D11_TEX2D_VPOV { + MipSlice: UINT, +}} +STRUCT!{struct D3D11_TEX2D_ARRAY_VPOV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +UNION!{union D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC_u { + [u32; 3], + Texture2D Texture2D_mut: D3D11_TEX2D_VPOV, + Texture2DArray Texture2DArray_mut: D3D11_TEX2D_ARRAY_VPOV, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC { + ViewDimension: D3D11_VPOV_DIMENSION, + u: D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC_u, +}} +RIDL!{#[uuid(0xa048285e, 0x25a9, 0x4527, 0xbd, 0x93, 0xd6, 0x8b, 0x68, 0xc4, 0x42, 0x54)] +interface ID3D11VideoProcessorOutputView(ID3D11VideoProcessorOutputViewVtbl): + ID3D11View(ID3D11ViewVtbl) { + fn GetDesc( + pDesc: *mut D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC, + ) -> (), +}} +RIDL!{#[uuid(0x61f21c45, 0x3c0e, 0x4a74, 0x9c, 0xea, 0x67, 0x10, 0x0d, 0x9a, 0xd5, 0xe4)] +interface ID3D11VideoContext(ID3D11VideoContextVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { + fn GetDecoderBuffer( + pDecoder: *mut ID3D11VideoDecoder, + Type: D3D11_VIDEO_DECODER_BUFFER_TYPE, + pBufferSize: *mut UINT, + ppBuffer: *mut *mut c_void, + ) -> HRESULT, + fn ReleaseDecoderBuffer( + pDecoder: *mut ID3D11VideoDecoder, + Type: D3D11_VIDEO_DECODER_BUFFER_TYPE, + ) -> HRESULT, + fn DecoderBeginFrame( + pDecoder: *mut ID3D11VideoDecoder, + pView: *mut ID3D11VideoDecoderOutputView, + ContentKeySize: UINT, + pContentKey: *const c_void, + ) -> HRESULT, + fn DecoderEndFrame( + pDecoder: *mut ID3D11VideoDecoder, + ) -> HRESULT, + fn SubmitDecoderBuffers( + pDecoder: *mut ID3D11VideoDecoder, + NumBuffers: UINT, + pBufferDesc: *const D3D11_VIDEO_DECODER_BUFFER_DESC, + ) -> HRESULT, + fn DecoderExtension( + pDecoder: *mut ID3D11VideoDecoder, + pExtensionData: *const D3D11_VIDEO_DECODER_EXTENSION, + ) -> HRESULT, + fn VideoProcessorSetOutputTargetRect( + pVideoProcessor: *mut ID3D11VideoProcessor, + Enable: BOOL, + pRect: *const RECT, + ) -> (), + fn VideoProcessorSetOutputBackgroundColor( + pVideoProcessor: *mut ID3D11VideoProcessor, + YCbCr: BOOL, + pRect: *const RECT, + ) -> (), + fn VideoProcessorSetOutputColorSpace( + pVideoProcessor: *mut ID3D11VideoProcessor, + pColorSpace: *const D3D11_VIDEO_PROCESSOR_COLOR_SPACE, + ) -> HRESULT, + fn VideoProcessorSetOutputAlphaFillMode( + pVideoProcessor: *mut ID3D11VideoProcessor, + AlphaFillMode: D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE, + StreamIndex: UINT, + ) -> (), + fn VideoProcessorSetOutputConstriction( + pVideoProcessor: *mut ID3D11VideoProcessor, + Enable: BOOL, + Size: SIZE, + ) -> (), + fn VideoProcessorSetOutputStereoMode( + pVideoProcessor: *mut ID3D11VideoProcessor, + Enable: BOOL, + ) -> (), + fn VideoProcessorSetOutputExtension( + pVideoProcessor: *mut ID3D11VideoProcessor, + pExtensionGuid: *const GUID, + DataSize: UINT, + pData: *mut c_void, + ) -> HRESULT, + fn VideoProcessorGetOutputTargetRect( + pVideoProcessor: *mut ID3D11VideoProcessor, + Enabled: *mut BOOL, + pRect: *mut RECT, + ) -> (), + fn VideoProcessorGetOutputBackgroundColor( + pVideoProcessor: *mut ID3D11VideoProcessor, + pYCbCr: *mut BOOL, + pColor: *mut D3D11_VIDEO_COLOR, + ) -> (), + fn VideoProcessorGetOutputColorSpace( + pVideoProcessor: *mut ID3D11VideoProcessor, + pColorSpace: *mut D3D11_VIDEO_PROCESSOR_COLOR_SPACE, + ) -> (), + fn VideoProcessorGetOutputAlphaFillMode( + pVideoProcessor: *mut ID3D11VideoProcessor, + pAlphaFillMode: *mut D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE, + pStreamIndex: *mut UINT, + ) -> (), + fn VideoProcessorGetOutputConstriction( + pVideoProcessor: *mut ID3D11VideoProcessor, + pEnabled: *mut BOOL, + pSize: *mut SIZE, + ) -> (), + fn VideoProcessorGetOutputStereoMode( + pVideoProcessor: *mut ID3D11VideoProcessor, + pEnabled: *mut BOOL, + ) -> (), + fn VideoProcessorGetOutputExtension( + pVideoProcessor: *mut ID3D11VideoProcessor, + pExtensionGuid: *const GUID, + DataSize: UINT, + pData: *mut c_void, + ) -> HRESULT, + fn VideoProcessorSetStreamFrameFormat( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + FrameFormat: D3D11_VIDEO_FRAME_FORMAT, + ) -> (), + fn VideoProcessorSetStreamColorSpace( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pColorSpace: *const D3D11_VIDEO_PROCESSOR_COLOR_SPACE, + ) -> (), + fn VideoProcessorSetStreamOutputRate( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + OutputRate: D3D11_VIDEO_PROCESSOR_OUTPUT_RATE, + RepeatFrame: BOOL, + pCustomRate: *const DXGI_RATIONAL, + ) -> (), + fn VideoProcessorSetStreamSourceRect( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Enable: BOOL, + pRect: *const RECT, + ) -> (), + fn VideoProcessorSetStreamDestRect( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Enable: BOOL, + pRect: *const RECT, + ) -> (), + fn VideoProcessorSetStreamAlpha( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Enable: BOOL, + Alpha: FLOAT, + ) -> (), + fn VideoProcessorSetStreamPalette( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Count: UINT, + pEntries: *const UINT, + ) -> (), + fn VideoProcessorSetStreamPixelAspectRatio( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Enable: BOOL, + pSourceAspectRatio: *const DXGI_RATIONAL, + pDestinationAspectRatio: *const DXGI_RATIONAL, + ) -> (), + fn VideoProcessorSetStreamLumaKey( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Enable: BOOL, + Lower: FLOAT, + Upper: FLOAT, + ) -> (), + fn VideoProcessorSetStreamStereoFormat( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Enable: BOOL, + Format: D3D11_VIDEO_PROCESSOR_STEREO_FORMAT, + LeftViewFrame0: BOOL, + BaseViewFrame0: BOOL, + FlipMode: D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE, + ) -> (), + fn VideoProcessorSetStreamAutoProcessingMode( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Enable: BOOL, + ) -> (), + fn VideoProcessorSetStreamFilter( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Filter: D3D11_VIDEO_PROCESSOR_FILTER, + Enable: BOOL, + Level: c_int, + ) -> (), + fn VideoProcessorSetStreamExtension( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pExtensionGuid: *const GUID, + DataSize: UINT, + pData: *mut c_void, + ) -> HRESULT, + fn VideoProcessorGetStreamFrameFormat( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pFrameFormat: *mut D3D11_VIDEO_FRAME_FORMAT, + ) -> (), + fn VideoProcessorGetStreamColorSpace( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pColorSpace: *mut D3D11_VIDEO_PROCESSOR_COLOR_SPACE, + ) -> (), + fn VideoProcessorGetStreamOutputRate( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pOutputRate: *mut D3D11_VIDEO_PROCESSOR_OUTPUT_RATE, + pRepeatFrame: *mut BOOL, + pCustomRate: *mut DXGI_RATIONAL, + ) -> (), + fn VideoProcessorGetStreamSourceRect( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pEnabled: *mut BOOL, + pRect: *mut RECT, + ) -> (), + fn VideoProcessorGetStreamDestRect( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pEnabled: *mut BOOL, + pRect: *mut RECT, + ) -> (), + fn VideoProcessorGetStreamAlpha( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pEnabled: *mut BOOL, + pAlpha: *mut FLOAT, + ) -> (), + fn VideoProcessorGetStreamPalette( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Count: UINT, + pEntries: *mut UINT, + ) -> (), + fn VideoProcessorGetStreamPixelAspectRatio( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pEnabled: *mut BOOL, + pSourceAspectRatio: *mut DXGI_RATIONAL, + pDestinationAspectRatio: *mut DXGI_RATIONAL, + ) -> (), + fn VideoProcessorGetStreamLumaKey( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pEnabled: *mut BOOL, + pLower: *mut FLOAT, + pUpper: *mut FLOAT, + ) -> (), + fn VideoProcessorGetStreamStereoFormat( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pEnabled: *mut BOOL, + pFormat: *mut D3D11_VIDEO_PROCESSOR_STEREO_FORMAT, + pLeftViewFrame0: *mut BOOL, + pBaseViewFrame0: *mut BOOL, + pFlipMode: *mut D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE, + MonoOffset: *mut c_int, + ) -> (), + fn VideoProcessorGetStreamAutoProcessingMode( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pEnabled: *mut BOOL, + ) -> (), + fn VideoProcessorGetStreamFilter( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Filter: D3D11_VIDEO_PROCESSOR_FILTER, + pEnabled: *mut BOOL, + pLevel: *mut c_int, + ) -> (), + fn VideoProcessorGetStreamExtension( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pExtensionGuid: *const GUID, + DataSize: UINT, + pData: *mut c_void, + ) -> HRESULT, + fn VideoProcessorBlt( + pVideoProcessor: *mut ID3D11VideoProcessor, + pView: *mut ID3D11VideoProcessorOutputView, + OutputFrame: UINT, + StreamCount: UINT, + pStreams: *const D3D11_VIDEO_PROCESSOR_STREAM, + ) -> HRESULT, + fn NegotiateCryptoSessionKeyExchange( + pCryptoSession: *mut ID3D11CryptoSession, + DataSize: UINT, + pData: *mut c_void, + ) -> HRESULT, + fn EncryptionBlt( + pCryptoSession: *mut ID3D11CryptoSession, + pSrcSurface: *mut ID3D11Texture2D, + pDstSurface: *mut ID3D11Texture2D, + IVSize: UINT, + pIV: *mut c_void, + ) -> HRESULT, + fn DecryptionBlt( + pCryptoSession: *mut ID3D11CryptoSession, + pSrcSurface: *mut ID3D11Texture2D, + pDstSurface: *mut ID3D11Texture2D, + pEncryptedBlockInfo: *mut D3D11_ENCRYPTED_BLOCK_INFO, + ContentKeySize: UINT, + pContentKey: *const c_void, + IVSize: UINT, + pIV: *mut c_void, + ) -> HRESULT, + fn StartSessionKeyRefresh( + pCryptoSession: *mut ID3D11CryptoSession, + RandomNumberSize: UINT, + pRandomNumber: *mut c_void, + ) -> HRESULT, + fn FinishSessionKeyRefresh( + pCryptoSession: *mut ID3D11CryptoSession, + ) -> HRESULT, + fn GetEncryptionBltKey( + pCryptoSession: *mut ID3D11CryptoSession, + KeySize: UINT, + pReadbackKey: *mut c_void, + ) -> HRESULT, + fn NegotiateAuthenticatedChannelKeyExchange( + pChannel: *mut ID3D11AuthenticatedChannel, + DataSize: UINT, + pData: *mut c_void, + ) -> HRESULT, + fn QueryAuthenticatedChannel( + pChannel: *mut ID3D11AuthenticatedChannel, + InputSize: UINT, + pInput: *const c_void, + OutputSize: UINT, + pOutput: *mut c_void, + ) -> HRESULT, + fn ConfigureAuthenticatedChannel( + pChannel: *mut ID3D11AuthenticatedChannel, + InputSize: UINT, + pInput: *const c_void, + pOutput: *mut D3D11_AUTHENTICATED_CONFIGURE_OUTPUT, + ) -> HRESULT, + fn VideoProcessorSetStreamRotation( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Enable: BOOL, + Rotation: D3D11_VIDEO_PROCESSOR_ROTATION, + ) -> HRESULT, + fn VideoProcessorGetStreamRotation( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pEnable: *mut BOOL, + pRotation: *mut D3D11_VIDEO_PROCESSOR_ROTATION, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x10ec4d5b, 0x975a, 0x4689, 0xb9, 0xe4, 0xd0, 0xaa, 0xc3, 0x0f, 0xe3, 0x33)] +interface ID3D11VideoDevice(ID3D11VideoDeviceVtbl): IUnknown(IUnknownVtbl) { + fn CreateVideoDecoder( + pVideoDesc: *const D3D11_VIDEO_DECODER_DESC, + pConfig: *const D3D11_VIDEO_DECODER_CONFIG, + ppDecoder: *mut *mut ID3D11VideoDecoder, + ) -> HRESULT, + fn CreateVideoProcessor( + pEnum: *mut ID3D11VideoProcessorEnumerator, + RateConversionIndex: UINT, + ppVideoProcessor: *mut *mut ID3D11VideoProcessor, + ) -> HRESULT, + fn CreateAuthenticatedChannel( + ChannelType: D3D11_AUTHENTICATED_CHANNEL_TYPE, + ppAuthenticatedChannel: *mut *mut ID3D11AuthenticatedChannel, + ) -> HRESULT, + fn CreateCryptoSession( + pCryptoType: *const GUID, + pDecoderProfile: *const GUID, + pKeyExchangeType: *const GUID, + ppCryptoSession: *mut *mut ID3D11CryptoSession, + ) -> HRESULT, + fn CreateVideoDecoderOutputView( + pResource: *mut ID3D11Resource, + pDesc: *const D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC, + ppVDOVView: *mut *mut ID3D11VideoDecoderOutputView, + ) -> HRESULT, + fn CreateVideoProcessorInputView( + pResource: *mut ID3D11Resource, + pEnum: *mut ID3D11VideoProcessorEnumerator, + pDesc: *const D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC, + ppVPIView: *mut *mut ID3D11VideoProcessorInputView, + ) -> HRESULT, + fn CreateVideoProcessorOutputView( + pResource: *mut ID3D11Resource, + pEnum: *mut ID3D11VideoProcessorEnumerator, + pDesc: *const D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC, + ppVPOView: *mut *mut ID3D11VideoProcessorOutputView, + ) -> HRESULT, + fn CreateVideoProcessorEnumerator( + pDesc: *const D3D11_VIDEO_PROCESSOR_CONTENT_DESC, + ppEnum: *mut *mut ID3D11VideoProcessorEnumerator, + ) -> HRESULT, + fn GetVideoDecoderProfileCount() -> UINT, + fn GetVideoDecoderProfile( + Index: UINT, + pDecoderProfile: *mut GUID, + ) -> HRESULT, + fn CheckVideoDecoderFormat( + pDecoderProfile: *const GUID, + Format: DXGI_FORMAT, + pSupported: *mut BOOL, + ) -> HRESULT, + fn GetVideoDecoderConfigCount( + pDesc: *const D3D11_VIDEO_DECODER_DESC, + pCount: *mut UINT, + ) -> HRESULT, + fn GetVideoDecoderConfig( + pDesc: *const D3D11_VIDEO_DECODER_DESC, + Index: UINT, + pConfig: *mut D3D11_VIDEO_DECODER_CONFIG, + ) -> HRESULT, + fn GetContentProtectionCaps( + pCryptoType: *const GUID, + pDecoderProfile: *const GUID, + pCaps: *mut D3D11_VIDEO_CONTENT_PROTECTION_CAPS, + ) -> HRESULT, + fn CheckCryptoKeyExchange( + pCryptoType: *const GUID, + pDecoderProfile: *const GUID, + Index: UINT, + pKeyExchangeType: *mut GUID, + ) -> HRESULT, + fn SetPrivateData( + guid: REFGUID, + DataSize: UINT, + pData: *const c_void, + ) -> HRESULT, + fn SetPrivateDataInterface( + guid: REFGUID, + pData: *const IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdb6f6ddb, 0xac77, 0x4e88, 0x82, 0x53, 0x81, 0x9d, 0xf9, 0xbb, 0xf1, 0x40)] +interface ID3D11Device(ID3D11DeviceVtbl): IUnknown(IUnknownVtbl) { + fn CreateBuffer( + pDesc: *const D3D11_BUFFER_DESC, + pInitialData: *const D3D11_SUBRESOURCE_DATA, + ppBuffer: *mut *mut ID3D11Buffer, + ) -> HRESULT, + fn CreateTexture1D( + pDesc: *const D3D11_TEXTURE1D_DESC, + pInitialData: *const D3D11_SUBRESOURCE_DATA, + ppTexture1D: *mut *mut ID3D11Texture1D, + ) -> HRESULT, + fn CreateTexture2D( + pDesc: *const D3D11_TEXTURE2D_DESC, + pInitialData: *const D3D11_SUBRESOURCE_DATA, + ppTexture2D: *mut *mut ID3D11Texture2D, + ) -> HRESULT, + fn CreateTexture3D( + pDesc: *const D3D11_TEXTURE3D_DESC, + pInitialData: *const D3D11_SUBRESOURCE_DATA, + ppTexture3D: *mut *mut ID3D11Texture3D, + ) -> HRESULT, + fn CreateShaderResourceView( + pResource: *mut ID3D11Resource, + pDesc: *const D3D11_SHADER_RESOURCE_VIEW_DESC, + ppSRView: *mut *mut ID3D11ShaderResourceView, + ) -> HRESULT, + fn CreateUnorderedAccessView( + pResource: *mut ID3D11Resource, + pDesc: *const D3D11_UNORDERED_ACCESS_VIEW_DESC, + ppUAView: *mut *mut ID3D11UnorderedAccessView, + ) -> HRESULT, + fn CreateRenderTargetView( + pResource: *mut ID3D11Resource, + pDesc: *const D3D11_RENDER_TARGET_VIEW_DESC, + ppRTView: *mut *mut ID3D11RenderTargetView, + ) -> HRESULT, + fn CreateDepthStencilView( + pResource: *mut ID3D11Resource, + pDesc: *const D3D11_DEPTH_STENCIL_VIEW_DESC, + ppDepthStencilView: *mut *mut ID3D11DepthStencilView, + ) -> HRESULT, + fn CreateInputLayout( + pInputElementDescs: *const D3D11_INPUT_ELEMENT_DESC, + NumElements: UINT, + pShaderBytecodeWithInputSignature: *const c_void, + BytecodeLength: SIZE_T, + ppInputLayout: *mut *mut ID3D11InputLayout, + ) -> HRESULT, + fn CreateVertexShader( + pShaderBytecode: *const c_void, + BytecodeLength: SIZE_T, + pClassLinkage: *mut ID3D11ClassLinkage, + ppVertexShader: *mut *mut ID3D11VertexShader, + ) -> HRESULT, + fn CreateGeometryShader( + pShaderBytecode: *const c_void, + BytecodeLength: SIZE_T, + pClassLinkage: *mut ID3D11ClassLinkage, + ppGeometryShader: *mut *mut ID3D11GeometryShader, + ) -> HRESULT, + fn CreateGeometryShaderWithStreamOutput( + pShaderBytecode: *const c_void, + BytecodeLength: SIZE_T, + pSODeclaration: *const D3D11_SO_DECLARATION_ENTRY, + NumEntries: UINT, + pBufferStrides: *const UINT, + NumStrides: UINT, + RasterizedStream: UINT, + pClassLinkage: *mut ID3D11ClassLinkage, + ppGeometryShader: *mut *mut ID3D11GeometryShader, + ) -> HRESULT, + fn CreatePixelShader( + pShaderBytecode: *const c_void, + BytecodeLength: SIZE_T, + pClassLinkage: *mut ID3D11ClassLinkage, + ppPixelShader: *mut *mut ID3D11PixelShader, + ) -> HRESULT, + fn CreateHullShader( + pShaderBytecode: *const c_void, + BytecodeLength: SIZE_T, + pClassLinkage: *mut ID3D11ClassLinkage, + ppHullShader: *mut *mut ID3D11HullShader, + ) -> HRESULT, + fn CreateDomainShader( + pShaderBytecode: *const c_void, + BytecodeLength: SIZE_T, + pClassLinkage: *mut ID3D11ClassLinkage, + ppDomainShader: *mut *mut ID3D11DomainShader, + ) -> HRESULT, + fn CreateComputeShader( + pShaderBytecode: *const c_void, + BytecodeLength: SIZE_T, + pClassLinkage: *mut ID3D11ClassLinkage, + ppComputeShader: *mut *mut ID3D11ComputeShader, + ) -> HRESULT, + fn CreateClassLinkage( + ppLinkage: *mut *mut ID3D11ClassLinkage, + ) -> HRESULT, + fn CreateBlendState( + pBlendStateDesc: *const D3D11_BLEND_DESC, + ppBlendState: *mut *mut ID3D11BlendState, + ) -> HRESULT, + fn CreateDepthStencilState( + pDepthStencilDesc: *const D3D11_DEPTH_STENCIL_DESC, + ppDepthStencilState: *mut *mut ID3D11DepthStencilState, + ) -> HRESULT, + fn CreateRasterizerState( + pRasterizerDesc: *const D3D11_RASTERIZER_DESC, + ppRasterizerState: *mut *mut ID3D11RasterizerState, + ) -> HRESULT, + fn CreateSamplerState( + pSamplerDesc: *const D3D11_SAMPLER_DESC, + ppSamplerState: *mut *mut ID3D11SamplerState, + ) -> HRESULT, + fn CreateQuery( + pQueryDesc: *const D3D11_QUERY_DESC, + ppQuery: *mut *mut ID3D11Query, + ) -> HRESULT, + fn CreatePredicate( + pPredicateDesc: *const D3D11_QUERY_DESC, + ppPredicate: *mut *mut ID3D11Predicate, + ) -> HRESULT, + fn CreateCounter( + pCounterDesc: *const D3D11_COUNTER_DESC, + ppCounter: *mut *mut ID3D11Counter, + ) -> HRESULT, + fn CreateDeferredContext( + ContextFlags: UINT, + ppDeferredContext: *mut *mut ID3D11DeviceContext, + ) -> HRESULT, + fn OpenSharedResource( + hResource: HANDLE, + ReturnedInterface: REFIID, + ppResource: *mut *mut c_void, + ) -> HRESULT, + fn CheckFormatSupport( + Format: DXGI_FORMAT, + pFormatSupport: *mut UINT, + ) -> HRESULT, + fn CheckMultisampleQualityLevels( + Format: DXGI_FORMAT, + SampleCount: UINT, + pNumQualityLevels: *mut UINT, + ) -> HRESULT, + fn CheckCounterInfo( + pCounterInfo: *mut D3D11_COUNTER_INFO, + ) -> (), + fn CheckCounter( + pDesc: *const D3D11_COUNTER_DESC, + pType: *mut D3D11_COUNTER_TYPE, + pActiveCounters: *mut UINT, + szName: LPSTR, + pNameLength: *mut UINT, + szUnits: LPSTR, + pUnitsLength: *mut UINT, + szDescription: LPSTR, + pDescriptionLength: *mut UINT, + ) -> HRESULT, + fn CheckFeatureSupport( + Feature: D3D11_FEATURE, + pFeatureSupportData: *mut c_void, + FeatureSupportDataSize: UINT, + ) -> HRESULT, + fn GetPrivateData( + guid: REFGUID, + pDataSize: *mut UINT, + pData: *mut c_void, + ) -> HRESULT, + fn SetPrivateData( + guid: REFGUID, + DataSize: UINT, + pData: *const c_void, + ) -> HRESULT, + fn SetPrivateDataInterface( + guid: REFGUID, + pData: *const IUnknown, + ) -> HRESULT, + fn GetFeatureLevel() -> D3D_FEATURE_LEVEL, + fn GetCreationFlags() -> UINT, + fn GetDeviceRemovedReason() -> HRESULT, + fn GetImmediateContext( + ppImmediateContext: *mut *mut ID3D11DeviceContext, + ) -> (), + fn SetExceptionMode( + RaiseFlags: UINT, + ) -> HRESULT, + fn GetExceptionMode() -> UINT, +}} +ENUM!{enum D3D11_CREATE_DEVICE_FLAG { + D3D11_CREATE_DEVICE_SINGLETHREADED = 0x1, + D3D11_CREATE_DEVICE_DEBUG = 0x2, + D3D11_CREATE_DEVICE_SWITCH_TO_REF = 0x4, + D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS = 0x8, + D3D11_CREATE_DEVICE_BGRA_SUPPORT = 0x20, + D3D11_CREATE_DEVICE_DEBUGGABLE = 0x40, + D3D11_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY = 0x80, + D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT = 0x100, + D3D11_CREATE_DEVICE_VIDEO_SUPPORT = 0x800, +}} +pub const D3D11_SDK_VERSION: DWORD = 7; +#[inline] +pub fn D3D11CalcSubresource(MipSlice: UINT, ArraySlice: UINT, MipLevels: UINT) -> UINT { + MipSlice + ArraySlice * MipLevels +} +extern "system" { + pub fn D3D11CreateDevice( + pAdapter: *mut IDXGIAdapter, + DriverType: D3D_DRIVER_TYPE, + Software: HMODULE, + Flags: UINT, + pFeatureLevels: *const D3D_FEATURE_LEVEL, + FeatureLevels: UINT, + SDKVersion: UINT, + ppDevice: *mut *mut ID3D11Device, + pFeatureLevel: *mut D3D_FEATURE_LEVEL, + ppImmediateContext: *mut *mut ID3D11DeviceContext, + ) -> HRESULT; + pub fn D3D11CreateDeviceAndSwapChain( + pAdapter: *mut IDXGIAdapter, + DriverType: D3D_DRIVER_TYPE, + Software: HMODULE, + Flags: UINT, + pFeatureLevels: *const D3D_FEATURE_LEVEL, + FeatureLevels: UINT, + SDKVersion: UINT, + pSwapChainDesc: *const DXGI_SWAP_CHAIN_DESC, + ppSwapChain: *mut *mut IDXGISwapChain, + ppDevice: *mut *mut ID3D11Device, + pFeatureLevel: *mut D3D_FEATURE_LEVEL, + ppImmediateContext: *mut *mut ID3D11DeviceContext, + ) -> HRESULT; +} +DEFINE_GUID!{IID_ID3D11DeviceChild, + 0x1841e5c8, 0x16b0, 0x489b, 0xbc, 0xc8, 0x44, 0xcf, 0xb0, 0xd5, 0xde, 0xae} +DEFINE_GUID!{IID_ID3D11DepthStencilState, + 0x03823efb, 0x8d8f, 0x4e1c, 0x9a, 0xa2, 0xf6, 0x4b, 0xb2, 0xcb, 0xfd, 0xf1} +DEFINE_GUID!{IID_ID3D11BlendState, + 0x75b68faa, 0x347d, 0x4159, 0x8f, 0x45, 0xa0, 0x64, 0x0f, 0x01, 0xcd, 0x9a} +DEFINE_GUID!{IID_ID3D11RasterizerState, + 0x9bb4ab81, 0xab1a, 0x4d8f, 0xb5, 0x06, 0xfc, 0x04, 0x20, 0x0b, 0x6e, 0xe7} +DEFINE_GUID!{IID_ID3D11Resource, + 0xdc8e63f3, 0xd12b, 0x4952, 0xb4, 0x7b, 0x5e, 0x45, 0x02, 0x6a, 0x86, 0x2d} +DEFINE_GUID!{IID_ID3D11Buffer, + 0x48570b85, 0xd1ee, 0x4fcd, 0xa2, 0x50, 0xeb, 0x35, 0x07, 0x22, 0xb0, 0x37} +DEFINE_GUID!{IID_ID3D11Texture1D, + 0xf8fb5c27, 0xc6b3, 0x4f75, 0xa4, 0xc8, 0x43, 0x9a, 0xf2, 0xef, 0x56, 0x4c} +DEFINE_GUID!{IID_ID3D11Texture2D, + 0x6f15aaf2, 0xd208, 0x4e89, 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c} +DEFINE_GUID!{IID_ID3D11Texture3D, + 0x037e866e, 0xf56d, 0x4357, 0xa8, 0xaf, 0x9d, 0xab, 0xbe, 0x6e, 0x25, 0x0e} +DEFINE_GUID!{IID_ID3D11View, + 0x839d1216, 0xbb2e, 0x412b, 0xb7, 0xf4, 0xa9, 0xdb, 0xeb, 0xe0, 0x8e, 0xd1} +DEFINE_GUID!{IID_ID3D11ShaderResourceView, + 0xb0e06fe0, 0x8192, 0x4e1a, 0xb1, 0xca, 0x36, 0xd7, 0x41, 0x47, 0x10, 0xb2} +DEFINE_GUID!{IID_ID3D11RenderTargetView, + 0xdfdba067, 0x0b8d, 0x4865, 0x87, 0x5b, 0xd7, 0xb4, 0x51, 0x6c, 0xc1, 0x64} +DEFINE_GUID!{IID_ID3D11DepthStencilView, + 0x9fdac92a, 0x1876, 0x48c3, 0xaf, 0xad, 0x25, 0xb9, 0x4f, 0x84, 0xa9, 0xb6} +DEFINE_GUID!{IID_ID3D11UnorderedAccessView, + 0x28acf509, 0x7f5c, 0x48f6, 0x86, 0x11, 0xf3, 0x16, 0x01, 0x0a, 0x63, 0x80} +DEFINE_GUID!{IID_ID3D11VertexShader, + 0x3b301d64, 0xd678, 0x4289, 0x88, 0x97, 0x22, 0xf8, 0x92, 0x8b, 0x72, 0xf3} +DEFINE_GUID!{IID_ID3D11HullShader, + 0x8e5c6061, 0x628a, 0x4c8e, 0x82, 0x64, 0xbb, 0xe4, 0x5c, 0xb3, 0xd5, 0xdd} +DEFINE_GUID!{IID_ID3D11DomainShader, + 0xf582c508, 0x0f36, 0x490c, 0x99, 0x77, 0x31, 0xee, 0xce, 0x26, 0x8c, 0xfa} +DEFINE_GUID!{IID_ID3D11GeometryShader, + 0x38325b96, 0xeffb, 0x4022, 0xba, 0x02, 0x2e, 0x79, 0x5b, 0x70, 0x27, 0x5c} +DEFINE_GUID!{IID_ID3D11PixelShader, + 0xea82e40d, 0x51dc, 0x4f33, 0x93, 0xd4, 0xdb, 0x7c, 0x91, 0x25, 0xae, 0x8c} +DEFINE_GUID!{IID_ID3D11ComputeShader, + 0x4f5b196e, 0xc2bd, 0x495e, 0xbd, 0x01, 0x1f, 0xde, 0xd3, 0x8e, 0x49, 0x69} +DEFINE_GUID!{IID_ID3D11InputLayout, + 0xe4819ddc, 0x4cf0, 0x4025, 0xbd, 0x26, 0x5d, 0xe8, 0x2a, 0x3e, 0x07, 0xb7} +DEFINE_GUID!{IID_ID3D11SamplerState, + 0xda6fea51, 0x564c, 0x4487, 0x98, 0x10, 0xf0, 0xd0, 0xf9, 0xb4, 0xe3, 0xa5} +DEFINE_GUID!{IID_ID3D11Asynchronous, + 0x4b35d0cd, 0x1e15, 0x4258, 0x9c, 0x98, 0x1b, 0x13, 0x33, 0xf6, 0xdd, 0x3b} +DEFINE_GUID!{IID_ID3D11Query, + 0xd6c00747, 0x87b7, 0x425e, 0xb8, 0x4d, 0x44, 0xd1, 0x08, 0x56, 0x0a, 0xfd} +DEFINE_GUID!{IID_ID3D11Predicate, + 0x9eb576dd, 0x9f77, 0x4d86, 0x81, 0xaa, 0x8b, 0xab, 0x5f, 0xe4, 0x90, 0xe2} +DEFINE_GUID!{IID_ID3D11Counter, + 0x6e8c49fb, 0xa371, 0x4770, 0xb4, 0x40, 0x29, 0x08, 0x60, 0x22, 0xb7, 0x41} +DEFINE_GUID!{IID_ID3D11ClassInstance, + 0xa6cd7faa, 0xb0b7, 0x4a2f, 0x94, 0x36, 0x86, 0x62, 0xa6, 0x57, 0x97, 0xcb} +DEFINE_GUID!{IID_ID3D11ClassLinkage, + 0xddf57cba, 0x9543, 0x46e4, 0xa1, 0x2b, 0xf2, 0x07, 0xa0, 0xfe, 0x7f, 0xed} +DEFINE_GUID!{IID_ID3D11CommandList, + 0xa24bc4d1, 0x769e, 0x43f7, 0x80, 0x13, 0x98, 0xff, 0x56, 0x6c, 0x18, 0xe2} +DEFINE_GUID!{IID_ID3D11DeviceContext, + 0xc0bfa96c, 0xe089, 0x44fb, 0x8e, 0xaf, 0x26, 0xf8, 0x79, 0x61, 0x90, 0xda} +DEFINE_GUID!{IID_ID3D11VideoDecoder, + 0x3c9c5b51, 0x995d, 0x48d1, 0x9b, 0x8d, 0xfa, 0x5c, 0xae, 0xde, 0xd6, 0x5c} +DEFINE_GUID!{IID_ID3D11VideoProcessorEnumerator, + 0x31627037, 0x53ab, 0x4200, 0x90, 0x61, 0x05, 0xfa, 0xa9, 0xab, 0x45, 0xf9} +DEFINE_GUID!{IID_ID3D11VideoProcessor, + 0x1d7b0652, 0x185f, 0x41c6, 0x85, 0xce, 0x0c, 0x5b, 0xe3, 0xd4, 0xae, 0x6c} +DEFINE_GUID!{IID_ID3D11AuthenticatedChannel, + 0x3015a308, 0xdcbd, 0x47aa, 0xa7, 0x47, 0x19, 0x24, 0x86, 0xd1, 0x4d, 0x4a} +DEFINE_GUID!{IID_ID3D11CryptoSession, + 0x9b32f9ad, 0xbdcc, 0x40a6, 0xa3, 0x9d, 0xd5, 0xc8, 0x65, 0x84, 0x57, 0x20} +DEFINE_GUID!{IID_ID3D11VideoDecoderOutputView, + 0xc2931aea, 0x2a85, 0x4f20, 0x86, 0x0f, 0xfb, 0xa1, 0xfd, 0x25, 0x6e, 0x18} +DEFINE_GUID!{IID_ID3D11VideoProcessorInputView, + 0x11ec5a5f, 0x51dc, 0x4945, 0xab, 0x34, 0x6e, 0x8c, 0x21, 0x30, 0x0e, 0xa5} +DEFINE_GUID!{IID_ID3D11VideoProcessorOutputView, + 0xa048285e, 0x25a9, 0x4527, 0xbd, 0x93, 0xd6, 0x8b, 0x68, 0xc4, 0x42, 0x54} +DEFINE_GUID!{IID_ID3D11VideoContext, + 0x61f21c45, 0x3c0e, 0x4a74, 0x9c, 0xea, 0x67, 0x10, 0x0d, 0x9a, 0xd5, 0xe4} +DEFINE_GUID!{IID_ID3D11VideoDevice, + 0x10ec4d5b, 0x975a, 0x4689, 0xb9, 0xe4, 0xd0, 0xaa, 0xc3, 0x0f, 0xe3, 0x33} +DEFINE_GUID!{IID_ID3D11Device, + 0xdb6f6ddb, 0xac77, 0x4e88, 0x82, 0x53, 0x81, 0x9d, 0xf9, 0xbb, 0xf1, 0x40} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_1.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_1.rs new file mode 100644 index 0000000..7b0b46e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_1.rs @@ -0,0 +1,484 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_void; +use shared::basetsd::{UINT64, UINT8}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::dxgitype::{DXGI_COLOR_SPACE_TYPE, DXGI_RATIONAL}; +use shared::guiddef::{GUID, REFIID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, INT, UINT}; +use um::d3d11::{ + D3D11_BLEND, D3D11_BLEND_OP, D3D11_BOX, D3D11_CULL_MODE, D3D11_FILL_MODE, D3D11_RECT, + D3D11_VIDEO_DECODER_BUFFER_TYPE, D3D11_VIDEO_DECODER_CONFIG, D3D11_VIDEO_DECODER_DESC, + ID3D11BlendState, ID3D11BlendStateVtbl, ID3D11Buffer, ID3D11CryptoSession, ID3D11Device, + ID3D11DeviceChild, ID3D11DeviceChildVtbl, ID3D11DeviceContext, ID3D11DeviceContextVtbl, + ID3D11DeviceVtbl, ID3D11RasterizerState, ID3D11RasterizerStateVtbl, ID3D11Resource, + ID3D11VideoContext, ID3D11VideoContextVtbl, ID3D11VideoDecoder, ID3D11VideoDevice, + ID3D11VideoDeviceVtbl, ID3D11VideoProcessor, ID3D11VideoProcessorEnumerator, + ID3D11VideoProcessorEnumeratorVtbl, ID3D11View +}; +use um::d3dcommon::D3D_FEATURE_LEVEL; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, LPCWSTR}; +DEFINE_GUID!{IID_ID3D11BlendState1, + 0xcc86fabe, 0xda55, 0x401d, 0x85, 0xe7, 0xe3, 0xc9, 0xde, 0x28, 0x77, 0xe9} +DEFINE_GUID!{IID_ID3D11RasterizerState1, + 0x1217d7a6, 0x5039, 0x418c, 0xb0, 0x42, 0x9c, 0xbe, 0x25, 0x6a, 0xfd, 0x6e} +DEFINE_GUID!{IID_ID3DDeviceContextState, + 0x5c1e0d8a, 0x7c23, 0x48f9, 0x8c, 0x59, 0xa9, 0x29, 0x58, 0xce, 0xff, 0x11} +DEFINE_GUID!{IID_ID3D11DeviceContext1, + 0xbb2c6faa, 0xb5fb, 0x4082, 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1} +DEFINE_GUID!{IID_ID3D11VideoContext1, + 0xa7f026da, 0xa5f8, 0x4487, 0xa5, 0x64, 0x15, 0xe3, 0x43, 0x57, 0x65, 0x1e} +DEFINE_GUID!{IID_ID3D11VideoDevice1, + 0x29da1d51, 0x1321, 0x4454, 0x80, 0x4b, 0xf5, 0xfc, 0x9f, 0x86, 0x1f, 0x0f} +DEFINE_GUID!{IID_ID3D11VideoProcessorEnumerator1, + 0x465217f2, 0x5568, 0x43cf, 0xb5, 0xb9, 0xf6, 0x1d, 0x54, 0x53, 0x1c, 0xa1} +DEFINE_GUID!{IID_ID3D11Device1, + 0xa04bfb29, 0x08ef, 0x43d6, 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86} +DEFINE_GUID!{IID_ID3DUserDefinedAnnotation, + 0xb2daad8b, 0x03d4, 0x4dbf, 0x95, 0xeb, 0x32, 0xab, 0x4b, 0x63, 0xd0, 0xab} +ENUM!{enum D3D11_COPY_FLAGS { + D3D11_COPY_NO_OVERWRITE = 0x00000001, + D3D11_COPY_DISCARD = 0x00000002, +}} +ENUM!{enum D3D11_LOGIC_OP { + D3D11_LOGIC_OP_CLEAR = 0, + D3D11_LOGIC_OP_SET = 1, + D3D11_LOGIC_OP_COPY = 2, + D3D11_LOGIC_OP_COPY_INVERTED = 3, + D3D11_LOGIC_OP_NOOP = 4, + D3D11_LOGIC_OP_INVERT = 5, + D3D11_LOGIC_OP_AND = 6, + D3D11_LOGIC_OP_NAND = 7, + D3D11_LOGIC_OP_OR = 8, + D3D11_LOGIC_OP_NOR = 9, + D3D11_LOGIC_OP_XOR = 10, + D3D11_LOGIC_OP_EQUIV = 11, + D3D11_LOGIC_OP_AND_REVERSE = 12, + D3D11_LOGIC_OP_AND_INVERTED = 13, + D3D11_LOGIC_OP_OR_REVERSE = 14, + D3D11_LOGIC_OP_OR_INVERTED = 15, +}} +STRUCT!{struct D3D11_RENDER_TARGET_BLEND_DESC1 { + BlendEnable: BOOL, + LogicOpEnable: BOOL, + SrcBlend: D3D11_BLEND, + DestBlend: D3D11_BLEND, + BlendOp: D3D11_BLEND_OP, + SrcBlendAlpha: D3D11_BLEND, + DestBlendAlpha: D3D11_BLEND, + BlendOpAlpha: D3D11_BLEND_OP, + LogicOp: D3D11_LOGIC_OP, + RenderTargetWriteMask: UINT8, +}} +STRUCT!{struct D3D11_BLEND_DESC1 { + AlphaToCoverageEnable: BOOL, + IndependentBlendEnable: BOOL, + RenderTarget: [D3D11_RENDER_TARGET_BLEND_DESC1; 8], +}} +RIDL!{#[uuid(0xcc86fabe, 0xda55, 0x401d, 0x85, 0xe7, 0xe3, 0xc9, 0xde, 0x28, 0x77, 0xe9)] +interface ID3D11BlendState1(ID3D11BlendState1Vtbl): ID3D11BlendState(ID3D11BlendStateVtbl) { + fn GetDesc1( + pDesc: *mut D3D11_BLEND_DESC1, + ) -> (), +}} +STRUCT!{struct D3D11_RASTERIZER_DESC1 { + FillMode: D3D11_FILL_MODE, + CullMode: D3D11_CULL_MODE, + FrontCounterClockwise: BOOL, + DepthBias: INT, + DepthBiasClamp: FLOAT, + SlopeScaledDepthBias: FLOAT, + DepthClipEnable: BOOL, + ScissorEnable: BOOL, + MultisampleEnable: BOOL, + AntialiasedLineEnable: BOOL, + ForcedSampleCount: UINT, +}} +RIDL!{#[uuid(0x1217d7a6, 0x5039, 0x418c, 0xb0, 0x42, 0x9c, 0xbe, 0x25, 0x6a, 0xfd, 0x6e)] +interface ID3D11RasterizerState1(ID3D11RasterizerState1Vtbl): + ID3D11RasterizerState(ID3D11RasterizerStateVtbl) { + fn GetDesc1( + pDesc: *mut D3D11_RASTERIZER_DESC1, + ) -> (), +}} +ENUM!{enum D3D11_1_CREATE_DEVICE_CONTEXT_STATE_FLAG { + D3D11_1_CREATE_DEVICE_CONTEXT_STATE_SINGLETHREADED = 0x1, +}} +RIDL!{#[uuid(0x5c1e0d8a, 0x7c23, 0x48f9, 0x8c, 0x59, 0xa9, 0x29, 0x58, 0xce, 0xff, 0x11)] +interface ID3DDeviceContextState(ID3DDeviceContextStateVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) {}} +RIDL!{#[uuid(0xbb2c6faa, 0xb5fb, 0x4082, 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1)] +interface ID3D11DeviceContext1(ID3D11DeviceContext1Vtbl): + ID3D11DeviceContext(ID3D11DeviceContextVtbl) { + fn CopySubresourceRegion1( + pDstResource: *mut ID3D11Resource, + DstSubresource: UINT, + DstX: UINT, + DstY: UINT, + DstZ: UINT, + pSrcResource: *mut ID3D11Resource, + SrcSubresource: UINT, + pSrcBox: *const D3D11_BOX, + CopyFlags: UINT, + ) -> (), + fn UpdateSubresource1( + pDstResource: *mut ID3D11Resource, + DstSubresource: UINT, + pDstBox: *const D3D11_BOX, + pSrcData: *mut c_void, + SrcRowPitch: UINT, + SrcDepthPitch: UINT, + CopyFlags: UINT, + ) -> (), + fn DiscardResource( + pResource: *mut ID3D11Resource, + ) -> (), + fn DiscardView( + pResource: *mut ID3D11Resource, + ) -> (), + fn VSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn HSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn DSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn GSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn PSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn CSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn VSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn HSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn DSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn GSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn PSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn CSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn SwapDeviceContextState( + pState: *mut ID3DDeviceContextState, + ppPreviousState: *mut *mut ID3DDeviceContextState, + ) -> (), + fn ClearView( + pView: *mut ID3D11View, + Color: [FLOAT; 4], + pRect: *const D3D11_RECT, + NumRects: UINT, + ) -> (), + fn DiscardView1( + pResourceView: *mut ID3D11View, + pRects: *const D3D11_RECT, + NumRects: UINT, + ) -> (), +}} +STRUCT!{struct D3D11_VIDEO_DECODER_SUB_SAMPLE_MAPPING_BLOCK { + ClearSize: UINT, + EncryptedSize: UINT, +}} +STRUCT!{struct D3D11_VIDEO_DECODER_BUFFER_DESC1 { + BufferType: D3D11_VIDEO_DECODER_BUFFER_TYPE, + DataOffset: UINT, + DataSize: UINT, + pIV: *mut c_void, + IVSize: UINT, + pSubSampleMappingBlock: *mut D3D11_VIDEO_DECODER_SUB_SAMPLE_MAPPING_BLOCK, + SubSampleMappingCount: UINT, +}} +STRUCT!{struct D3D11_VIDEO_DECODER_BEGIN_FRAME_CRYPTO_SESSION { + pCryptoSession: *mut ID3D11CryptoSession, + BlobSize: UINT, + pBlob: *mut c_void, + pKeyInfoId: *mut GUID, + PrivateDataSize: UINT, + pPrivateData: *mut c_void, +}} +ENUM!{enum D3D11_VIDEO_DECODER_CAPS { + D3D11_VIDEO_DECODER_CAPS_DOWNSAMPLE = 0x1, + D3D11_VIDEO_DECODER_CAPS_NON_REAL_TIME = 0x02, + D3D11_VIDEO_DECODER_CAPS_DOWNSAMPLE_DYNAMIC = 0x04, + D3D11_VIDEO_DECODER_CAPS_DOWNSAMPLE_REQUIRED = 0x08, + D3D11_VIDEO_DECODER_CAPS_UNSUPPORTED = 0x10, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINTS { + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_MULTIPLANE_OVERLAY_ROTATION = 0x01, + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_MULTIPLANE_OVERLAY_RESIZE = 0x02, + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_MULTIPLANE_OVERLAY_COLOR_SPACE_CONVERSION = 0x04, + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_TRIPLE_BUFFER_OUTPUT = 0x08, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_STREAM_BEHAVIOR_HINT { + Enable: BOOL, + Width: UINT, + Height: UINT, + Format: DXGI_FORMAT, +}} +ENUM!{enum D3D11_CRYPTO_SESSION_STATUS { + D3D11_CRYPTO_SESSION_STATUS_OK = 0, + D3D11_CRYPTO_SESSION_STATUS_KEY_LOST = 1, + D3D11_CRYPTO_SESSION_STATUS_KEY_AND_CONTENT_LOST = 2, +}} +STRUCT!{struct D3D11_KEY_EXCHANGE_HW_PROTECTION_INPUT_DATA { + PrivateDataSize: UINT, + HWProtectionDataSize: UINT, + pbInput: [BYTE; 4], +}} +STRUCT!{struct D3D11_KEY_EXCHANGE_HW_PROTECTION_OUTPUT_DATA { + PrivateDataSize: UINT, + MaxHWProtectionDataSize: UINT, + HWProtectionDataSize: UINT, + TransportTime: UINT64, + ExecutionTime: UINT64, + pbOutput: [BYTE; 4], +}} +STRUCT!{struct D3D11_KEY_EXCHANGE_HW_PROTECTION_DATA { + HWProtectionFunctionID: UINT, + pInputData: *mut D3D11_KEY_EXCHANGE_HW_PROTECTION_INPUT_DATA, + pOutputData: *mut D3D11_KEY_EXCHANGE_HW_PROTECTION_OUTPUT_DATA, + Status: HRESULT, +}} +STRUCT!{struct D3D11_VIDEO_SAMPLE_DESC { + Width: UINT, + Height: UINT, + Format: DXGI_FORMAT, + ColorSpace: DXGI_COLOR_SPACE_TYPE, +}} +RIDL!{#[uuid(0xa7f026da, 0xa5f8, 0x4487, 0xa5, 0x64, 0x15, 0xe3, 0x43, 0x57, 0x65, 0x1e)] +interface ID3D11VideoContext1(ID3D11VideoContext1Vtbl): + ID3D11VideoContext(ID3D11VideoContextVtbl) { + fn SubmitDecoderBuffers1( + pDecoder: *mut ID3D11VideoDecoder, + NumBuffers: UINT, + pBufferDesc: *const D3D11_VIDEO_DECODER_BUFFER_DESC1, + ) -> HRESULT, + fn GetDataForNewHardwareKey( + pCryptoSession: *mut ID3D11CryptoSession, + PrivateInputSize: UINT, + pPrivateInputData: *const c_void, + pPrivateOutputData: *mut UINT64, + ) -> HRESULT, + fn CheckCryptoSessionStatus( + pCryptoSession: *mut ID3D11CryptoSession, + pStatus: *mut D3D11_CRYPTO_SESSION_STATUS, + ) -> HRESULT, + fn DecoderEnableDownsampling( + pDecoder: *mut ID3D11VideoDecoder, + InputColorSpace: DXGI_COLOR_SPACE_TYPE, + pOutputDesc: *const D3D11_VIDEO_SAMPLE_DESC, + ReferenceFrameCount: UINT, + ) -> HRESULT, + fn DecoderUpdateDownsampling( + pDecoder: *mut ID3D11VideoDecoder, + pOutputDesc: *const D3D11_VIDEO_SAMPLE_DESC, + ) -> HRESULT, + fn VideoProcessorSetOutputColorSpace1( + pVideoProcessor: *mut ID3D11VideoProcessor, + ColorSpace: DXGI_COLOR_SPACE_TYPE, + ) -> (), + fn VideoProcessorSetOutputShaderUsage( + pVideoProcessor: *mut ID3D11VideoProcessor, + ShaderUsage: BOOL, + ) -> (), + fn VideoProcessorGetOutputColorSpace1( + pVideoProcessor: *mut ID3D11VideoProcessor, + pColorSpace: *mut DXGI_COLOR_SPACE_TYPE, + ) -> (), + fn VideoProcessorGetOutputShaderUsage( + pVideoProcessor: *mut ID3D11VideoProcessor, + pShaderUsage: *mut BOOL, + ) -> (), + fn VideoProcessorSetStreamColorSpace1( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + ColorSpace: DXGI_COLOR_SPACE_TYPE, + ) -> (), + fn VideoProcessorSetStreamMirror( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Enable: BOOL, + FlipHorizontal: BOOL, + FlipVertical: BOOL, + ) -> (), + fn VideoProcessorGetStreamColorSpace1( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pColorSpace: *mut DXGI_COLOR_SPACE_TYPE, + ) -> (), + fn VideoProcessorGetStreamMirror( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pEnable: *mut BOOL, + pFlipHorizontal: *mut BOOL, + pFlipVertical: *mut BOOL, + ) -> (), + fn VideoProcessorGetBehaviorHints( + pVideoProcessor: *mut ID3D11VideoProcessor, + OutputWidth: UINT, + OutputHeight: UINT, + OutputFormat: DXGI_FORMAT, + StreamCount: UINT, + pStreams: *const D3D11_VIDEO_PROCESSOR_STREAM_BEHAVIOR_HINT, + pBehaviorHints: *mut UINT, + ) -> (), +}} +RIDL!{#[uuid(0x29da1d51, 0x1321, 0x4454, 0x80, 0x4b, 0xf5, 0xfc, 0x9f, 0x86, 0x1f, 0x0f)] +interface ID3D11VideoDevice1(ID3D11VideoDevice1Vtbl): ID3D11VideoDevice(ID3D11VideoDeviceVtbl) { + fn GetCryptoSessionPrivateDataSize( + pCryptoType: *const GUID, + pDecoderProfile: *const GUID, + pKeyExchangeType: *const GUID, + pPrivateInputSize: *mut UINT, + pPrivateOutputSize: *mut UINT, + ) -> HRESULT, + fn GetVideoDecoderCaps( + pDecoderProfile: *const GUID, + SampleWidth: UINT, + SampleHeight: UINT, + pFrameRate: *const DXGI_RATIONAL, + BitRate: UINT, + pCryptoType: *const GUID, + pDecoderCaps: *mut UINT, + ) -> HRESULT, + fn CheckVideoDecoderDownsampling( + pInputDesc: *const D3D11_VIDEO_DECODER_DESC, + InputColorSpace: DXGI_COLOR_SPACE_TYPE, + pInputConfig: *const D3D11_VIDEO_DECODER_CONFIG, + pFrameRate: *const DXGI_RATIONAL, + pOutputDesc: *const D3D11_VIDEO_SAMPLE_DESC, + pSupported: *mut BOOL, + pRealTimeHint: *mut BOOL, + ) -> HRESULT, + fn RecommendVideoDecoderDownsampleParameters( + pInputDesc: *const D3D11_VIDEO_DECODER_DESC, + InputColorSpace: DXGI_COLOR_SPACE_TYPE, + pInputConfig: *const D3D11_VIDEO_DECODER_CONFIG, + pRecommendedOutputDesc: *mut D3D11_VIDEO_SAMPLE_DESC, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x465217f2, 0x5568, 0x43cf, 0xb5, 0xb9, 0xf6, 0x1d, 0x54, 0x53, 0x1c, 0xa1)] +interface ID3D11VideoProcessorEnumerator1(ID3D11VideoProcessorEnumerator1Vtbl): + ID3D11VideoProcessorEnumerator(ID3D11VideoProcessorEnumeratorVtbl) { + fn CheckVideoProcessorFormatConversion( + InputFormat: DXGI_FORMAT, + InputCOlorSpace: DXGI_COLOR_SPACE_TYPE, + OutputFormat: DXGI_FORMAT, + OutputColorSpace: DXGI_COLOR_SPACE_TYPE, + pSupported: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa04bfb29, 0x08ef, 0x43d6, 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86)] +interface ID3D11Device1(ID3D11Device1Vtbl): ID3D11Device(ID3D11DeviceVtbl) { + fn GetImmediateContext1( + ppImmediateContext: *mut *mut ID3D11DeviceContext1, + ) -> (), + fn CreateDeferredContext1( + ContextFlags: UINT, + ppDeferredContext: *mut *mut ID3D11DeviceContext1, + ) -> HRESULT, + fn CreateBlendState( + pBlendStateDesc: *const D3D11_BLEND_DESC1, + ppBlendState: *mut *mut ID3D11BlendState1, + ) -> HRESULT, + fn CreateRasterizerState( + pRasterizerDesc: *const D3D11_RASTERIZER_DESC1, + ppRasterizerState: *mut *mut ID3D11RasterizerState1, + ) -> HRESULT, + fn CreateDeviceContextState( + Flags: UINT, + pFeatureLevels: *const D3D_FEATURE_LEVEL, + FeatureLevels: UINT, + SDKVersion: UINT, + EmulatedInterface: REFIID, + pChosenFeatureLevel: *mut D3D_FEATURE_LEVEL, + ppContextState: *mut *mut ID3DDeviceContextState, + ) -> HRESULT, + fn OpenSharedResource1( + hResource: HANDLE, + returnedInterface: REFIID, + ppResource: *mut *mut c_void, + ) -> HRESULT, + fn OpenSharedResourceByName( + Name: LPCWSTR, + dwDesiredAccess: DWORD, + returnedInterface: REFIID, + ppResource: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb2daad8b, 0x03d4, 0x4dbf, 0x95, 0xeb, 0x32, 0xab, 0x4b, 0x63, 0xd0, 0xab)] +interface ID3DUserDefinedAnnotation(ID3DUserDefinedAnnotationVtbl): IUnknown(IUnknownVtbl) { + fn BeginEvent( + Name: LPCWSTR, + ) -> INT, + fn EndEvent() -> INT, + fn SetMarker( + Name: LPCWSTR, + ) -> (), + fn GetStatus() -> BOOL, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_2.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_2.rs new file mode 100644 index 0000000..28b655a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_2.rs @@ -0,0 +1,146 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_void; +use shared::basetsd::{UINT16, UINT64, UINT8}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::minwindef::{BOOL, INT, UINT}; +use um::d3d11::{ID3D11Buffer, ID3D11DeviceChild, ID3D11Resource}; +use um::d3d11_1::{ + ID3D11Device1, ID3D11Device1Vtbl, ID3D11DeviceContext1, ID3D11DeviceContext1Vtbl, +}; +use um::winnt::{HRESULT, LPCWSTR}; +DEFINE_GUID!{IID_ID3D11DeviceContext2, + 0x420d5b32, 0xb90c, 0x4da4, 0xbe, 0xf0, 0x35, 0x9f, 0x6a, 0x24, 0xa8, 0x3a} +DEFINE_GUID!{IID_ID3D11Device2, + 0x9d06dffa, 0xd1e5, 0x4d07, 0x83, 0xa8, 0x1b, 0xb1, 0x23, 0xf2, 0xf8, 0x41} +STRUCT!{struct D3D11_TILED_RESOURCE_COORDINATE { + X: UINT, + Y: UINT, + Z: UINT, + Subresource: UINT, +}} +STRUCT!{struct D3D11_TILE_REGION_SIZE { + NumTiles: UINT, + bUseBox: BOOL, + Width: UINT, + Height: UINT16, + Depth: UINT16, +}} +ENUM!{enum D3D11_TILE_MAPPING_FLAG { + D3D11_TILE_MAPPING_NO_OVERWRITE = 0x00000001, +}} +ENUM!{enum D3D11_TILE_RANGE_FLAG { + D3D11_TILE_RANGE_NULL = 0x00000001, + D3D11_TILE_RANGE_SKIP = 0x00000002, + D3D11_TILE_RANGE_REUSE_SINGLE_TILE = 0x00000004, +}} +STRUCT!{struct D3D11_SUBRESOURCE_TILING { + WidthInTiles: UINT, + HeightInTiles: UINT16, + DepthInTiles: UINT16, + StartTileIndexInOverallResource: UINT, +}} +STRUCT!{struct D3D11_TILE_SHAPE { + WidthInTexels: UINT, + HeightInTexels: UINT, + DepthInTexels: UINT, +}} +STRUCT!{struct D3D11_PACKED_MIP_DESC { + NumStandardMips: UINT8, + NumPackedMips: UINT8, + NumTilesForPackedMips: UINT, + StartTileIndexInOverallResource: UINT, +}} +ENUM!{enum D3D11_CHECK_MULTISAMPLE_QUALITY_LEVELS_FLAG { + D3D11_CHECK_MULTISAMPLE_QUALITY_LEVELS_TILED_RESOURCE = 0x00000001, +}} +ENUM!{enum D3D11_TILE_COPY_FLAG { + D3D11_TILE_COPY_NO_OVERWRITE = 0x00000001, + D3D11_TILE_COPY_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 0x00000002, + D3D11_TILE_COPY_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER = 0x00000004, +}} +RIDL!{#[uuid(0x420d5b32, 0xb90c, 0x4da4, 0xbe, 0xf0, 0x35, 0x9f, 0x6a, 0x24, 0xa8, 0x3a)] +interface ID3D11DeviceContext2(ID3D11DeviceContext2Vtbl): + ID3D11DeviceContext1(ID3D11DeviceContext1Vtbl) { + fn UpdateTileMappings( + pTiledResource: *mut ID3D11Resource, + NumTiledResourceRegions: UINT, + pTiledResourceRegionStartCoordinates: *const D3D11_TILED_RESOURCE_COORDINATE, + pTiledResourceRegionSizes: *const D3D11_TILE_REGION_SIZE, + pTilePool: *mut ID3D11Buffer, + NumRanges: UINT, + pRangeFlags: *const UINT, + pTilePoolStartOffsets: *const UINT, + pRangeTileCounts: *const UINT, + Flags: UINT, + ) -> HRESULT, + fn CopyTileMappings( + pDestTiledResource: *mut ID3D11Resource, + pDestRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE, + pSourceTiledResource: *mut ID3D11Resource, + pSourceRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE, + pTileRegionSize: *const D3D11_TILE_REGION_SIZE, + Flags: UINT, + ) -> HRESULT, + fn CopyTiles( + pTiledResource: *mut ID3D11Resource, + pTileRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE, + pTileRegionSize: *const D3D11_TILE_REGION_SIZE, + pBuffer: *mut ID3D11Buffer, + BufferStartOffsetInBytes: UINT64, + Flags: UINT, + ) -> (), + fn UpdateTiles( + pDestTiledResource: *mut ID3D11Resource, + pDestTileRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE, + pDestTileRegionSize: *const D3D11_TILE_REGION_SIZE, + pSourceTileData: *const c_void, + Flags: UINT, + ) -> (), + fn ResizeTilePool( + pTilePool: *mut ID3D11Buffer, + NewSizeInBytes: UINT64, + ) -> HRESULT, + fn TiledResourceBarrier( + pTiledResourceOrViewAccessBeforeBarrier: *mut ID3D11DeviceChild, + pTiledResourceOrViewAccessAfterBarrier: *mut ID3D11DeviceChild, + ) -> (), + fn IsAnnotationEnabled() -> BOOL, + fn SetMarkerInt( + pLabel: LPCWSTR, + Data: INT, + ) -> (), + fn BeginEventInt( + pLabel: LPCWSTR, + Data: INT, + ) -> (), + fn EndEvent() -> (), +}} +RIDL!{#[uuid(0x9d06dffa, 0xd1e5, 0x4d07, 0x83, 0xa8, 0x1b, 0xb1, 0x23, 0xf2, 0xf8, 0x41)] +interface ID3D11Device2(ID3D11Device2Vtbl): ID3D11Device1(ID3D11Device1Vtbl) { + fn GetImmediateContext2( + ppImmediateContext: *mut *mut ID3D11DeviceContext2, + ) -> (), + fn CreateDeferredContext2( + ContextFlags: UINT, + ppDeferredContext: *mut *mut ID3D11DeviceContext2, + ) -> HRESULT, + fn GetResourceTiling( + pTiledResource: *mut ID3D11Resource, + pNumTilesForEntireResource: *mut UINT, + pPackedMipDesc: *mut D3D11_PACKED_MIP_DESC, + pStandardTileShapeForNonPackedMips: *mut D3D11_TILE_SHAPE, + pNumSubresourceTilings: *mut UINT, + FirstSubresourceTilingToGet: UINT, + pSubresourceTilingsForNonPackedMips: *mut D3D11_SUBRESOURCE_TILING, + ) -> (), + fn CheckMultisampleQualityLevels1( + Format: DXGI_FORMAT, + SampleCount: UINT, + Flags: UINT, + pNumQualityLevels: *mut UINT, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_3.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_3.rs new file mode 100644 index 0000000..5ae7213 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_3.rs @@ -0,0 +1,23 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_ID3D11Texture2D1, + 0x51218251, 0x1e33, 0x4617, 0x9c, 0xcb, 0x4d, 0x3a, 0x43, 0x67, 0xe7, 0xbb} +DEFINE_GUID!{IID_ID3D11Texture3D1, + 0x0c711683, 0x2853, 0x4846, 0x9b, 0xb0, 0xf3, 0xe6, 0x06, 0x39, 0xe4, 0x6a} +DEFINE_GUID!{IID_ID3D11RasterizerState2, + 0x6fbd02fb, 0x209f, 0x46c4, 0xb0, 0x59, 0x2e, 0xd1, 0x55, 0x86, 0xa6, 0xac} +DEFINE_GUID!{IID_ID3D11ShaderResourceView1, + 0x91308b87, 0x9040, 0x411d, 0x8c, 0x67, 0xc3, 0x92, 0x53, 0xce, 0x38, 0x02} +DEFINE_GUID!{IID_ID3D11RenderTargetView1, + 0xffbe2e23, 0xf011, 0x418a, 0xac, 0x56, 0x5c, 0xee, 0xd7, 0xc5, 0xb9, 0x4b} +DEFINE_GUID!{IID_ID3D11UnorderedAccessView1, + 0x7b3b6153, 0xa886, 0x4544, 0xab, 0x37, 0x65, 0x37, 0xc8, 0x50, 0x04, 0x03} +DEFINE_GUID!{IID_ID3D11Query1, + 0x631b4766, 0x36dc, 0x461d, 0x8d, 0xb6, 0xc4, 0x7e, 0x13, 0xe6, 0x09, 0x16} +DEFINE_GUID!{IID_ID3D11DeviceContext3, + 0xb4e3c01d, 0xe79e, 0x4637, 0x91, 0xb2, 0x51, 0x0e, 0x9f, 0x4c, 0x9b, 0x8f} +DEFINE_GUID!{IID_ID3D11Device3, + 0xa05c8c37, 0xd2c6, 0x4732, 0xb3, 0xa0, 0x9c, 0xe0, 0xb0, 0xdc, 0x9a, 0xe6} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_4.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_4.rs new file mode 100644 index 0000000..5d0da98 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11_4.rs @@ -0,0 +1,7 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_ID3D11Device4, + 0x8992ab71, 0x02e6, 0x4b8d, 0xba, 0x48, 0xb0, 0x56, 0xdc, 0xda, 0x42, 0xc4} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11on12.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11on12.rs new file mode 100644 index 0000000..bf106a3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11on12.rs @@ -0,0 +1,67 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the content of d3d11on12.h +use ctypes::c_void; +use shared::guiddef::IID; +use shared::minwindef::UINT; +use um::d3d11::{ID3D11Device, ID3D11DeviceContext, ID3D11Resource}; +use um::d3d12::D3D12_RESOURCE_STATES; +use um::d3dcommon::D3D_FEATURE_LEVEL; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::HRESULT; +FN!{stdcall PFN_D3D11ON12_CREATE_DEVICE( + *mut IUnknown, + UINT, + *const D3D_FEATURE_LEVEL, + UINT, + *mut *mut IUnknown, + UINT, + UINT, + *mut *mut ID3D11Device, + *mut *mut ID3D11DeviceContext, + *mut D3D_FEATURE_LEVEL, +) -> HRESULT} +extern "system" { + pub fn D3D11On12CreateDevice( + pDevice: *mut IUnknown, + Flags: UINT, + pFeatureLevels: *const D3D_FEATURE_LEVEL, + FeatureLevels: UINT, + ppCommandQueues: *mut *mut IUnknown, + NumQueues: UINT, + NodeMask: UINT, + ppDevice: *mut *mut ID3D11Device, + ppImmediateContext: *mut *mut ID3D11DeviceContext, + pChosenFeatureLevel: *mut D3D_FEATURE_LEVEL, + ) -> HRESULT; +} +STRUCT!{struct D3D11_RESOURCE_FLAGS { + BindFlags: UINT, + MiscFlags: UINT, + CPUAccessFlags: UINT, + StructureByteStride: UINT, +}} +RIDL!{#[uuid(0x85611e73, 0x70a9, 0x490e, 0x96, 0x14, 0xa9, 0xe3, 0x02, 0x77, 0x79, 0x04)] +interface ID3D11On12Device(ID3D11On12DeviceVtbl): IUnknown(IUnknownVtbl) { + fn CreateWrappedResource( + pResource12: *mut IUnknown, + pFlags11: *const D3D11_RESOURCE_FLAGS, + InState: D3D12_RESOURCE_STATES, + OutState: D3D12_RESOURCE_STATES, + riid: *const IID, + ppResource11: *mut *mut c_void, + ) -> HRESULT, + fn ReleaseWrappedResources( + ppResources: *mut *mut ID3D11Resource, + NumResources: UINT, + ) -> (), + fn AcquireWrappedResources( + ppResources: *mut *mut ID3D11Resource, + NumResources: UINT, + ) -> (), +}} +DEFINE_GUID!{IID_ID3D11On12Device, + 0x85611e73, 0x70a9, 0x490e, 0x96, 0x14, 0xa9, 0xe3, 0x02, 0x77, 0x79, 0x04} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11sdklayers.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11sdklayers.rs new file mode 100644 index 0000000..e70b668 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11sdklayers.rs @@ -0,0 +1,2679 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_char; +use shared::basetsd::{SIZE_T, UINT64}; +use shared::dxgi::IDXGISwapChain; +use shared::minwindef::{BOOL, UINT}; +use um::d3d11::ID3D11DeviceContext; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCSTR}; +pub const D3D11_SDK_LAYERS_VERSION: UINT = 0x1; +pub const D3D11_DEBUG_FEATURE_FLUSH_PER_RENDER_OP: UINT = 0x1; +pub const D3D11_DEBUG_FEATURE_FINISH_PER_RENDER_OP: UINT = 0x2; +pub const D3D11_DEBUG_FEATURE_PRESENT_PER_RENDER_OP: UINT = 0x4; +pub const D3D11_DEBUG_FEATURE_ALWAYS_DISCARD_OFFERED_RESOURCE: UINT = 0x8; +pub const D3D11_DEBUG_FEATURE_NEVER_DISCARD_OFFERED_RESOURCE: UINT = 0x10; +pub const D3D11_DEBUG_FEATURE_AVOID_BEHAVIOR_CHANGING_DEBUG_AIDS: UINT = 0x40; +pub const D3D11_DEBUG_FEATURE_DISABLE_TILED_RESOURCE_MAPPING_TRACKING_AND_VALIDATION: UINT = 0x80; +ENUM!{enum D3D11_RLDO_FLAGS { + D3D11_RLDO_SUMMARY = 0x1, + D3D11_RLDO_DETAIL = 0x2, + D3D11_RLDO_IGNORE_INTERNAL = 0x4, +}} +RIDL!{#[uuid(0x79cf2233, 0x7536, 0x4948, 0x9d, 0x36, 0x1e, 0x46, 0x92, 0xdc, 0x57, 0x60)] +interface ID3D11Debug(ID3D11DebugVtbl): IUnknown(IUnknownVtbl) { + fn SetFeatureMask( + Mask: UINT, + ) -> HRESULT, + fn GetFeatureMask() -> UINT, + fn SetPresentPerRenderOpDelay( + Milliseconds: UINT, + ) -> HRESULT, + fn GetPresentPerRenderOpDelay() -> UINT, + fn SetSwapChain( + pSwapChain: *mut IDXGISwapChain, + ) -> HRESULT, + fn GetSwapChain( + ppSwapChain: *mut *mut IDXGISwapChain, + ) -> HRESULT, + fn ValidateContext( + pContext: *const ID3D11DeviceContext, + ) -> HRESULT, + fn ReportLiveDeviceObjects( + Flags: D3D11_RLDO_FLAGS, + ) -> HRESULT, + fn ValidateContextForDispatch( + pContext: *mut ID3D11DeviceContext, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1ef337e3, 0x58e7, 0x4f83, 0xa6, 0x92, 0xdb, 0x22, 0x1f, 0x5e, 0xd4, 0x7e)] +interface ID3D11SwitchToRef(ID3D11SwitchToRefVtbl): IUnknown(IUnknownVtbl) { + fn SetUseRef( + UseRef: BOOL, + ) -> BOOL, + fn GetUseRef() -> BOOL, +}} +ENUM!{enum D3D11_SHADER_TRACKING_RESOURCE_TYPE { + D3D11_SHADER_TRACKING_RESOURCE_TYPE_NONE = 0, + D3D11_SHADER_TRACKING_RESOURCE_TYPE_UAV_DEVICEMEMORY = 1, + D3D11_SHADER_TRACKING_RESOURCE_TYPE_NON_UAV_DEVICEMEMORY = 2, + D3D11_SHADER_TRACKING_RESOURCE_TYPE_ALL_DEVICEMEMORY = 3, + D3D11_SHADER_TRACKING_RESOURCE_TYPE_GROUPSHARED_MEMORY = 4, + D3D11_SHADER_TRACKING_RESOURCE_TYPE_ALL_SHARED_MEMORY = 5, + D3D11_SHADER_TRACKING_RESOURCE_TYPE_GROUPSHARED_NON_UAV = 6, + D3D11_SHADER_TRACKING_RESOURCE_TYPE_ALL = 7, +}} +ENUM!{enum D3D11_SHADER_TRACKING_OPTION { + D3D11_SHADER_TRACKING_OPTION_IGNORE = 0, + D3D11_SHADER_TRACKING_OPTION_TRACK_UNINITIALIZED = 0x1, + D3D11_SHADER_TRACKING_OPTION_TRACK_RAW = 0x2, + D3D11_SHADER_TRACKING_OPTION_TRACK_WAR = 0x4, + D3D11_SHADER_TRACKING_OPTION_TRACK_WAW = 0x8, + D3D11_SHADER_TRACKING_OPTION_ALLOW_SAME = 0x10, + D3D11_SHADER_TRACKING_OPTION_TRACK_ATOMIC_CONSISTENCY = 0x20, + D3D11_SHADER_TRACKING_OPTION_TRACK_RAW_ACROSS_THREADGROUPS = 0x40, + D3D11_SHADER_TRACKING_OPTION_TRACK_WAR_ACROSS_THREADGROUPS = 0x80, + D3D11_SHADER_TRACKING_OPTION_TRACK_WAW_ACROSS_THREADGROUPS = 0x100, + D3D11_SHADER_TRACKING_OPTION_TRACK_ATOMIC_CONSISTENCY_ACROSS_THREADGROUPS = 0x200, + D3D11_SHADER_TRACKING_OPTION_UAV_SPECIFIC_FLAGS + = D3D11_SHADER_TRACKING_OPTION_TRACK_RAW_ACROSS_THREADGROUPS + | D3D11_SHADER_TRACKING_OPTION_TRACK_WAR_ACROSS_THREADGROUPS + | D3D11_SHADER_TRACKING_OPTION_TRACK_WAW_ACROSS_THREADGROUPS + | D3D11_SHADER_TRACKING_OPTION_TRACK_ATOMIC_CONSISTENCY_ACROSS_THREADGROUPS, + D3D11_SHADER_TRACKING_OPTION_ALL_HAZARDS = D3D11_SHADER_TRACKING_OPTION_TRACK_RAW + | D3D11_SHADER_TRACKING_OPTION_TRACK_WAR | D3D11_SHADER_TRACKING_OPTION_TRACK_WAW + | D3D11_SHADER_TRACKING_OPTION_TRACK_ATOMIC_CONSISTENCY + | D3D11_SHADER_TRACKING_OPTION_TRACK_RAW_ACROSS_THREADGROUPS + | D3D11_SHADER_TRACKING_OPTION_TRACK_WAR_ACROSS_THREADGROUPS + | D3D11_SHADER_TRACKING_OPTION_TRACK_WAW_ACROSS_THREADGROUPS + | D3D11_SHADER_TRACKING_OPTION_TRACK_ATOMIC_CONSISTENCY_ACROSS_THREADGROUPS, + D3D11_SHADER_TRACKING_OPTION_ALL_HAZARDS_ALLOWING_SAME + = D3D11_SHADER_TRACKING_OPTION_ALL_HAZARDS | D3D11_SHADER_TRACKING_OPTION_ALLOW_SAME, + D3D11_SHADER_TRACKING_OPTION_ALL_OPTIONS + = D3D11_SHADER_TRACKING_OPTION_ALL_HAZARDS_ALLOWING_SAME + | D3D11_SHADER_TRACKING_OPTION_TRACK_UNINITIALIZED, +}} +RIDL!{#[uuid(0x1911c771, 0x1587, 0x413e, 0xa7, 0xe0, 0xfb, 0x26, 0xc3, 0xde, 0x02, 0x68)] +interface ID3D11TracingDevice(ID3D11TracingDeviceVtbl): IUnknown(IUnknownVtbl) { + fn SetShaderTrackingOptionsByType( + ResourceTypeFlags: UINT, + Options: UINT, + ) -> HRESULT, + fn SetShaderTrackingOptions( + pShader: *const IUnknown, + Options: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x193dacdf, 0x0db2, 0x4c05, 0xa5, 0x5c, 0xef, 0x06, 0xca, 0xc5, 0x6f, 0xd9)] +interface ID3D11RefTrackingOptions(ID3D11RefTrackingOptionsVtbl): IUnknown(IUnknownVtbl) { + fn SetTrackingOptions( + Options: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x03916615, 0xc644, 0x418c, 0x9b, 0xf4, 0x75, 0xdb, 0x5b, 0xe6, 0x3c, 0xa0)] +interface ID3D11RefDefaultTrackingOptions(ID3D11RefDefaultTrackingOptionsVtbl): + IUnknown(IUnknownVtbl) { + fn SetTrackingOptions( + ResourceTypeFlags: UINT, + Options: UINT, + ) -> HRESULT, +}} +DEFINE_GUID!{DXGI_DEBUG_D3D11, + 0x4b99317b, 0xac39, 0x4aa6, 0xbb, 0x0b, 0xba, 0xa0, 0x47, 0x84, 0x79, 0x8f} +pub const D3D11_REGKEY_PATH: &'static str = "Software\\Microsoft\\Direct3D"; +pub const D3D11_MUTE_DEBUG_OUTPUT: &'static str = "MuteDebugOutput"; +pub const D3D11_ENABLE_BREAK_ON_MESSAGE: &'static str = "EnableBreakOnMessage"; +pub const D3D11_INFOQUEUE_STORAGE_FILTER_OVERRIDE: &'static str = "InfoQueueStorageFilterOverride"; +pub const D3D11_MUTE_CATEGORY: &'static str = "Mute_CATEGORY_%s"; +pub const D3D11_MUTE_SEVERITY: &'static str = "Mute_SEVERITY_%s"; +pub const D3D11_MUTE_ID_STRING: &'static str = "Mute_ID_%s"; +pub const D3D11_MUTE_ID_DECIMAL: &'static str = "Mute_ID_%d"; +pub const D3D11_UNMUTE_SEVERITY_INFO: &'static str = "Unmute_SEVERITY_INFO"; +pub const D3D11_BREAKON_CATEGORY: &'static str = "BreakOn_CATEGORY_%s"; +pub const D3D11_BREAKON_SEVERITY: &'static str = "BreakOn_SEVERITY_%s"; +pub const D3D11_BREAKON_ID_STRING: &'static str = "BreakOn_ID_%s"; +pub const D3D11_BREAKON_ID_DECIMAL: &'static str = "BreakOn_ID_%d"; +pub const D3D11_APPSIZE_STRING: &'static str = "Size"; +pub const D3D11_APPNAME_STRING: &'static str = "Name"; +pub const D3D11_FORCE_DEBUGGABLE: &'static str = "ForceDebuggable"; +pub const D3D11_FORCE_SHADER_SKIP_OPTIMIZATION: &'static str = "ForceShaderSkipOptimization"; +ENUM!{enum D3D11_MESSAGE_CATEGORY { + D3D11_MESSAGE_CATEGORY_APPLICATION_DEFINED = 0, + D3D11_MESSAGE_CATEGORY_MISCELLANEOUS = D3D11_MESSAGE_CATEGORY_APPLICATION_DEFINED + 1, + D3D11_MESSAGE_CATEGORY_INITIALIZATION = D3D11_MESSAGE_CATEGORY_MISCELLANEOUS + 1, + D3D11_MESSAGE_CATEGORY_CLEANUP = D3D11_MESSAGE_CATEGORY_INITIALIZATION + 1, + D3D11_MESSAGE_CATEGORY_COMPILATION = D3D11_MESSAGE_CATEGORY_CLEANUP + 1, + D3D11_MESSAGE_CATEGORY_STATE_CREATION = D3D11_MESSAGE_CATEGORY_COMPILATION + 1, + D3D11_MESSAGE_CATEGORY_STATE_SETTING = D3D11_MESSAGE_CATEGORY_STATE_CREATION + 1, + D3D11_MESSAGE_CATEGORY_STATE_GETTING = D3D11_MESSAGE_CATEGORY_STATE_SETTING + 1, + D3D11_MESSAGE_CATEGORY_RESOURCE_MANIPULATION = D3D11_MESSAGE_CATEGORY_STATE_GETTING + 1, + D3D11_MESSAGE_CATEGORY_EXECUTION = D3D11_MESSAGE_CATEGORY_RESOURCE_MANIPULATION + 1, + D3D11_MESSAGE_CATEGORY_SHADER = D3D11_MESSAGE_CATEGORY_EXECUTION + 1, +}} +ENUM!{enum D3D11_MESSAGE_SEVERITY { + D3D11_MESSAGE_SEVERITY_CORRUPTION = 0, + D3D11_MESSAGE_SEVERITY_ERROR = D3D11_MESSAGE_SEVERITY_CORRUPTION + 1, + D3D11_MESSAGE_SEVERITY_WARNING = D3D11_MESSAGE_SEVERITY_ERROR + 1, + D3D11_MESSAGE_SEVERITY_INFO = D3D11_MESSAGE_SEVERITY_WARNING + 1, + D3D11_MESSAGE_SEVERITY_MESSAGE = D3D11_MESSAGE_SEVERITY_INFO + 1, +}} +ENUM!{enum D3D11_MESSAGE_ID { + D3D11_MESSAGE_ID_UNKNOWN = 0, + D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_HAZARD = D3D11_MESSAGE_ID_UNKNOWN + 1, + D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_HAZARD + = D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_HAZARD + 1, + D3D11_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_HAZARD + = D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_HAZARD + 1, + D3D11_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_HAZARD + = D3D11_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_HAZARD + 1, + D3D11_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_HAZARD + = D3D11_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_HAZARD + 1, + D3D11_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_HAZARD + = D3D11_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_HAZARD + 1, + D3D11_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_HAZARD + = D3D11_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_HAZARD + 1, + D3D11_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_HAZARD + = D3D11_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_HAZARD + 1, + D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETS_HAZARD + = D3D11_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_HAZARD + 1, + D3D11_MESSAGE_ID_DEVICE_SOSETTARGETS_HAZARD + = D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETS_HAZARD + 1, + D3D11_MESSAGE_ID_STRING_FROM_APPLICATION = D3D11_MESSAGE_ID_DEVICE_SOSETTARGETS_HAZARD + 1, + D3D11_MESSAGE_ID_CORRUPTED_THIS = D3D11_MESSAGE_ID_STRING_FROM_APPLICATION + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER1 = D3D11_MESSAGE_ID_CORRUPTED_THIS + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER2 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER1 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER3 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER2 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER4 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER3 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER5 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER4 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER6 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER5 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER7 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER6 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER8 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER7 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER9 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER8 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER10 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER9 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER11 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER10 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER12 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER11 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER13 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER12 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER14 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER13 + 1, + D3D11_MESSAGE_ID_CORRUPTED_PARAMETER15 = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER14 + 1, + D3D11_MESSAGE_ID_CORRUPTED_MULTITHREADING = D3D11_MESSAGE_ID_CORRUPTED_PARAMETER15 + 1, + D3D11_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY + = D3D11_MESSAGE_ID_CORRUPTED_MULTITHREADING + 1, + D3D11_MESSAGE_ID_IASETINPUTLAYOUT_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_IASETVERTEXBUFFERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_IASETINPUTLAYOUT_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_IASETINDEXBUFFER_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_IASETVERTEXBUFFERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_VSSETSHADER_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_IASETINDEXBUFFER_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_VSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_VSSETSHADER_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_VSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_VSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_VSSETSAMPLERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_VSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_GSSETSHADER_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_VSSETSAMPLERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_GSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_GSSETSHADER_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_GSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_GSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_GSSETSAMPLERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_GSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_SOSETTARGETS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_GSSETSAMPLERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_PSSETSHADER_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_SOSETTARGETS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_PSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_PSSETSHADER_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_PSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_PSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_PSSETSAMPLERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_PSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_RSSETSTATE_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_PSSETSAMPLERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_OMSETBLENDSTATE_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_RSSETSTATE_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_OMSETDEPTHSTENCILSTATE_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_OMSETBLENDSTATE_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_OMSETRENDERTARGETS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_OMSETDEPTHSTENCILSTATE_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_SETPREDICATION_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_OMSETRENDERTARGETS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_GETPRIVATEDATA_MOREDATA + = D3D11_MESSAGE_ID_SETPREDICATION_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA = D3D11_MESSAGE_ID_GETPRIVATEDATA_MOREDATA + 1, + D3D11_MESSAGE_ID_SETPRIVATEDATA_INVALIDIUNKNOWN + = D3D11_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA + 1, + D3D11_MESSAGE_ID_SETPRIVATEDATA_INVALIDFLAGS + = D3D11_MESSAGE_ID_SETPRIVATEDATA_INVALIDIUNKNOWN + 1, + D3D11_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS + = D3D11_MESSAGE_ID_SETPRIVATEDATA_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY + = D3D11_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDFORMAT + = D3D11_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDSAMPLES + = D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDUSAGE + = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDSAMPLES + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDBINDFLAGS + = D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDUSAGE + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDCPUACCESSFLAGS + = D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDBINDFLAGS + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDMISCFLAGS + = D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDCPUACCESSFLAGS + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDCPUACCESSFLAGS + = D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDMISCFLAGS + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDBINDFLAGS + = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDCPUACCESSFLAGS + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDINITIALDATA + = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDBINDFLAGS + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDDIMENSIONS + = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDINITIALDATA + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDMIPLEVELS + = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDDIMENSIONS + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDMISCFLAGS + = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDMIPLEVELS + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDMISCFLAGS + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_NULLDESC = D3D11_MESSAGE_ID_CREATEBUFFER_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDCONSTANTBUFFERBINDINGS + = D3D11_MESSAGE_ID_CREATEBUFFER_NULLDESC + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_LARGEALLOCATION + = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDCONSTANTBUFFERBINDINGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDFORMAT + = D3D11_MESSAGE_ID_CREATEBUFFER_LARGEALLOCATION + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_UNSUPPORTEDFORMAT + = D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDSAMPLES + = D3D11_MESSAGE_ID_CREATETEXTURE1D_UNSUPPORTEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDUSAGE + = D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDSAMPLES + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDBINDFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDUSAGE + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDCPUACCESSFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDBINDFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDMISCFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDCPUACCESSFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDCPUACCESSFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDMISCFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDBINDFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDCPUACCESSFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDINITIALDATA + = D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDBINDFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDDIMENSIONS + = D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDINITIALDATA + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDMIPLEVELS + = D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDDIMENSIONS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDMISCFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDMIPLEVELS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDMISCFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_NULLDESC + = D3D11_MESSAGE_ID_CREATETEXTURE1D_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_LARGEALLOCATION + = D3D11_MESSAGE_ID_CREATETEXTURE1D_NULLDESC + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDFORMAT + = D3D11_MESSAGE_ID_CREATETEXTURE1D_LARGEALLOCATION + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_UNSUPPORTEDFORMAT + = D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDSAMPLES + = D3D11_MESSAGE_ID_CREATETEXTURE2D_UNSUPPORTEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDUSAGE + = D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDSAMPLES + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDBINDFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDUSAGE + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDCPUACCESSFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDBINDFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDMISCFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDCPUACCESSFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDCPUACCESSFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDMISCFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDBINDFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDCPUACCESSFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDINITIALDATA + = D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDBINDFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDDIMENSIONS + = D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDINITIALDATA + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDMIPLEVELS + = D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDDIMENSIONS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDMISCFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDMIPLEVELS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDMISCFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_NULLDESC + = D3D11_MESSAGE_ID_CREATETEXTURE2D_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_LARGEALLOCATION + = D3D11_MESSAGE_ID_CREATETEXTURE2D_NULLDESC + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDFORMAT + = D3D11_MESSAGE_ID_CREATETEXTURE2D_LARGEALLOCATION + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_UNSUPPORTEDFORMAT + = D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDSAMPLES + = D3D11_MESSAGE_ID_CREATETEXTURE3D_UNSUPPORTEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDUSAGE + = D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDSAMPLES + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDBINDFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDUSAGE + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDCPUACCESSFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDBINDFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDMISCFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDCPUACCESSFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDCPUACCESSFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDMISCFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDBINDFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDCPUACCESSFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDINITIALDATA + = D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDBINDFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDDIMENSIONS + = D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDINITIALDATA + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDMIPLEVELS + = D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDDIMENSIONS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDMISCFLAGS + = D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDMIPLEVELS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDMISCFLAGS + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_NULLDESC + = D3D11_MESSAGE_ID_CREATETEXTURE3D_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATETEXTURE3D_LARGEALLOCATION + = D3D11_MESSAGE_ID_CREATETEXTURE3D_NULLDESC + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT + = D3D11_MESSAGE_ID_CREATETEXTURE3D_LARGEALLOCATION + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_TOOMANYOBJECTS + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_TOOMANYOBJECTS + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_TOOMANYOBJECTS + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_TOOMANYOBJECTS + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_TOOMANYOBJECTS + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_TOOMANYOBJECTS + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_NULLDESC + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT + 1, + D3D11_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_NULLDESC + 1, + D3D11_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE + = D3D11_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE + = D3D11_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY + = D3D11_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDDECL + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_EXPECTEDDECL + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDDECL + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_EXPECTEDDECL + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION = + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT + + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX + 1, + D3D11_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE + 1, + D3D11_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE + = D3D11_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE + = D3D11_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE + 1, + D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE + = D3D11_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE + 1, + D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE + = D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE + 1, + D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP + = D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE + 1, + D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS + = D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP + 1, + D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_TOOMANYOBJECTS + = D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS + 1, + D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_NULLDESC + = D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_TOOMANYOBJECTS + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK + = D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_NULLDESC + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_TOOMANYOBJECTS + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC + 1, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_NULLDESC + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_TOOMANYOBJECTS + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_NULLDESC + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_TOOMANYOBJECTS + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_NULLDESC + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_TOOMANYOBJECTS + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDFILTER + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_NULLDESC + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSU + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDFILTER + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSV + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSU + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSW + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSV + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMIPLODBIAS + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSW + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXANISOTROPY + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMIPLODBIAS + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDCOMPARISONFUNC + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXANISOTROPY + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMINLOD + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDCOMPARISONFUNC + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXLOD + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMINLOD + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_TOOMANYOBJECTS + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXLOD + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_NULLDESC + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_TOOMANYOBJECTS + 1, + D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDQUERY + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_NULLDESC + 1, + D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDMISCFLAGS + = D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDQUERY + 1, + D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_UNEXPECTEDMISCFLAG + = D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDMISCFLAGS + 1, + D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_NULLDESC + = D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_UNEXPECTEDMISCFLAG + 1, + D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNRECOGNIZED + = D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_NULLDESC + 1, + D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNDEFINED + = D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNRECOGNIZED + 1, + D3D11_MESSAGE_ID_IASETVERTEXBUFFERS_INVALIDBUFFER + = D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNDEFINED + 1, + D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_OFFSET_TOO_LARGE + = D3D11_MESSAGE_ID_IASETVERTEXBUFFERS_INVALIDBUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_OFFSET_TOO_LARGE + 1, + D3D11_MESSAGE_ID_IASETINDEXBUFFER_INVALIDBUFFER + = D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_FORMAT_INVALID + = D3D11_MESSAGE_ID_IASETINDEXBUFFER_INVALIDBUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_TOO_LARGE + = D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_FORMAT_INVALID + 1, + D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_UNALIGNED + = D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_TOO_LARGE + 1, + D3D11_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_UNALIGNED + 1, + D3D11_MESSAGE_ID_VSSETCONSTANTBUFFERS_INVALIDBUFFER + = D3D11_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_VSSETCONSTANTBUFFERS_INVALIDBUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_VSSETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_VSSETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_GSSETCONSTANTBUFFERS_INVALIDBUFFER + = D3D11_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_GSSETCONSTANTBUFFERS_INVALIDBUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_GSSETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_SOSETTARGETS_INVALIDBUFFER + = D3D11_MESSAGE_ID_DEVICE_GSSETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_SOSETTARGETS_OFFSET_UNALIGNED + = D3D11_MESSAGE_ID_SOSETTARGETS_INVALIDBUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_SOSETTARGETS_OFFSET_UNALIGNED + 1, + D3D11_MESSAGE_ID_PSSETCONSTANTBUFFERS_INVALIDBUFFER + = D3D11_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_PSSETCONSTANTBUFFERS_INVALIDBUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_PSSETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_INVALIDVIEWPORT + = D3D11_MESSAGE_ID_DEVICE_PSSETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_INVALIDSCISSOR + = D3D11_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_INVALIDVIEWPORT + 1, + D3D11_MESSAGE_ID_CLEARRENDERTARGETVIEW_DENORMFLUSH + = D3D11_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_INVALIDSCISSOR + 1, + D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DENORMFLUSH + = D3D11_MESSAGE_ID_CLEARRENDERTARGETVIEW_DENORMFLUSH + 1, + D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_INVALID + = D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DENORMFLUSH + 1, + D3D11_MESSAGE_ID_DEVICE_IAGETVERTEXBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_INVALID + 1, + D3D11_MESSAGE_ID_DEVICE_VSGETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_IAGETVERTEXBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_VSGETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_VSGETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_VSGETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_VSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_GSGETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_VSGETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_GSGETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_GSGETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_GSGETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_GSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_SOGETTARGETS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_GSGETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_PSGETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_SOGETTARGETS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_PSGETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_PSGETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_PSGETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_PSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_RSGETVIEWPORTS_VIEWPORTS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_PSGETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_RSGETSCISSORRECTS_RECTS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_RSGETVIEWPORTS_VIEWPORTS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_GENERATEMIPS_RESOURCE_INVALID + = D3D11_MESSAGE_ID_DEVICE_RSGETSCISSORRECTS_RECTS_EMPTY + 1, + D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSUBRESOURCE + = D3D11_MESSAGE_ID_DEVICE_GENERATEMIPS_RESOURCE_INVALID + 1, + D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESUBRESOURCE + = D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSUBRESOURCE + 1, + D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCEBOX + = D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESUBRESOURCE + 1, + D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCE + = D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCEBOX + 1, + D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSTATE + = D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCE + 1, + D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESTATE + = D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSTATE + 1, + D3D11_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCE + = D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESTATE + 1, + D3D11_MESSAGE_ID_COPYRESOURCE_INVALIDDESTINATIONSTATE + = D3D11_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCE + 1, + D3D11_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCESTATE + = D3D11_MESSAGE_ID_COPYRESOURCE_INVALIDDESTINATIONSTATE + 1, + D3D11_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSUBRESOURCE + = D3D11_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCESTATE + 1, + D3D11_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONBOX + = D3D11_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSUBRESOURCE + 1, + D3D11_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE + = D3D11_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONBOX + 1, + D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_INVALID + = D3D11_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE + 1, + D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_SUBRESOURCE_INVALID + = D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_INVALID + 1, + D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_INVALID + = D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_SUBRESOURCE_INVALID + 1, + D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_SUBRESOURCE_INVALID + = D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_INVALID + 1, + D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_FORMAT_INVALID + = D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_SUBRESOURCE_INVALID + 1, + D3D11_MESSAGE_ID_BUFFER_MAP_INVALIDMAPTYPE + = D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_FORMAT_INVALID + 1, + D3D11_MESSAGE_ID_BUFFER_MAP_INVALIDFLAGS = D3D11_MESSAGE_ID_BUFFER_MAP_INVALIDMAPTYPE + 1, + D3D11_MESSAGE_ID_BUFFER_MAP_ALREADYMAPPED = D3D11_MESSAGE_ID_BUFFER_MAP_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_BUFFER_MAP_DEVICEREMOVED_RETURN + = D3D11_MESSAGE_ID_BUFFER_MAP_ALREADYMAPPED + 1, + D3D11_MESSAGE_ID_BUFFER_UNMAP_NOTMAPPED = D3D11_MESSAGE_ID_BUFFER_MAP_DEVICEREMOVED_RETURN + 1, + D3D11_MESSAGE_ID_TEXTURE1D_MAP_INVALIDMAPTYPE = D3D11_MESSAGE_ID_BUFFER_UNMAP_NOTMAPPED + 1, + D3D11_MESSAGE_ID_TEXTURE1D_MAP_INVALIDSUBRESOURCE + = D3D11_MESSAGE_ID_TEXTURE1D_MAP_INVALIDMAPTYPE + 1, + D3D11_MESSAGE_ID_TEXTURE1D_MAP_INVALIDFLAGS + = D3D11_MESSAGE_ID_TEXTURE1D_MAP_INVALIDSUBRESOURCE + 1, + D3D11_MESSAGE_ID_TEXTURE1D_MAP_ALREADYMAPPED = D3D11_MESSAGE_ID_TEXTURE1D_MAP_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_TEXTURE1D_MAP_DEVICEREMOVED_RETURN + = D3D11_MESSAGE_ID_TEXTURE1D_MAP_ALREADYMAPPED + 1, + D3D11_MESSAGE_ID_TEXTURE1D_UNMAP_INVALIDSUBRESOURCE + = D3D11_MESSAGE_ID_TEXTURE1D_MAP_DEVICEREMOVED_RETURN + 1, + D3D11_MESSAGE_ID_TEXTURE1D_UNMAP_NOTMAPPED + = D3D11_MESSAGE_ID_TEXTURE1D_UNMAP_INVALIDSUBRESOURCE + 1, + D3D11_MESSAGE_ID_TEXTURE2D_MAP_INVALIDMAPTYPE = D3D11_MESSAGE_ID_TEXTURE1D_UNMAP_NOTMAPPED + 1, + D3D11_MESSAGE_ID_TEXTURE2D_MAP_INVALIDSUBRESOURCE + = D3D11_MESSAGE_ID_TEXTURE2D_MAP_INVALIDMAPTYPE + 1, + D3D11_MESSAGE_ID_TEXTURE2D_MAP_INVALIDFLAGS + = D3D11_MESSAGE_ID_TEXTURE2D_MAP_INVALIDSUBRESOURCE + 1, + D3D11_MESSAGE_ID_TEXTURE2D_MAP_ALREADYMAPPED + = D3D11_MESSAGE_ID_TEXTURE2D_MAP_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_TEXTURE2D_MAP_DEVICEREMOVED_RETURN + = D3D11_MESSAGE_ID_TEXTURE2D_MAP_ALREADYMAPPED + 1, + D3D11_MESSAGE_ID_TEXTURE2D_UNMAP_INVALIDSUBRESOURCE + = D3D11_MESSAGE_ID_TEXTURE2D_MAP_DEVICEREMOVED_RETURN + 1, + D3D11_MESSAGE_ID_TEXTURE2D_UNMAP_NOTMAPPED + = D3D11_MESSAGE_ID_TEXTURE2D_UNMAP_INVALIDSUBRESOURCE + 1, + D3D11_MESSAGE_ID_TEXTURE3D_MAP_INVALIDMAPTYPE = D3D11_MESSAGE_ID_TEXTURE2D_UNMAP_NOTMAPPED + 1, + D3D11_MESSAGE_ID_TEXTURE3D_MAP_INVALIDSUBRESOURCE + = D3D11_MESSAGE_ID_TEXTURE3D_MAP_INVALIDMAPTYPE + 1, + D3D11_MESSAGE_ID_TEXTURE3D_MAP_INVALIDFLAGS + = D3D11_MESSAGE_ID_TEXTURE3D_MAP_INVALIDSUBRESOURCE + 1, + D3D11_MESSAGE_ID_TEXTURE3D_MAP_ALREADYMAPPED = D3D11_MESSAGE_ID_TEXTURE3D_MAP_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_TEXTURE3D_MAP_DEVICEREMOVED_RETURN + = D3D11_MESSAGE_ID_TEXTURE3D_MAP_ALREADYMAPPED + 1, + D3D11_MESSAGE_ID_TEXTURE3D_UNMAP_INVALIDSUBRESOURCE + = D3D11_MESSAGE_ID_TEXTURE3D_MAP_DEVICEREMOVED_RETURN + 1, + D3D11_MESSAGE_ID_TEXTURE3D_UNMAP_NOTMAPPED + = D3D11_MESSAGE_ID_TEXTURE3D_UNMAP_INVALIDSUBRESOURCE + 1, + D3D11_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_DEPRECATED + = D3D11_MESSAGE_ID_TEXTURE3D_UNMAP_NOTMAPPED + 1, + D3D11_MESSAGE_ID_CHECKMULTISAMPLEQUALITYLEVELS_FORMAT_DEPRECATED + = D3D11_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_DEPRECATED + 1, + D3D11_MESSAGE_ID_SETEXCEPTIONMODE_UNRECOGNIZEDFLAGS + = D3D11_MESSAGE_ID_CHECKMULTISAMPLEQUALITYLEVELS_FORMAT_DEPRECATED + 1, + D3D11_MESSAGE_ID_SETEXCEPTIONMODE_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_SETEXCEPTIONMODE_UNRECOGNIZEDFLAGS + 1, + D3D11_MESSAGE_ID_SETEXCEPTIONMODE_DEVICEREMOVED_RETURN + = D3D11_MESSAGE_ID_SETEXCEPTIONMODE_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_REF_SIMULATING_INFINITELY_FAST_HARDWARE + = D3D11_MESSAGE_ID_SETEXCEPTIONMODE_DEVICEREMOVED_RETURN + 1, + D3D11_MESSAGE_ID_REF_THREADING_MODE + = D3D11_MESSAGE_ID_REF_SIMULATING_INFINITELY_FAST_HARDWARE + 1, + D3D11_MESSAGE_ID_REF_UMDRIVER_EXCEPTION = D3D11_MESSAGE_ID_REF_THREADING_MODE + 1, + D3D11_MESSAGE_ID_REF_KMDRIVER_EXCEPTION = D3D11_MESSAGE_ID_REF_UMDRIVER_EXCEPTION + 1, + D3D11_MESSAGE_ID_REF_HARDWARE_EXCEPTION = D3D11_MESSAGE_ID_REF_KMDRIVER_EXCEPTION + 1, + D3D11_MESSAGE_ID_REF_ACCESSING_INDEXABLE_TEMP_OUT_OF_RANGE + = D3D11_MESSAGE_ID_REF_HARDWARE_EXCEPTION + 1, + D3D11_MESSAGE_ID_REF_PROBLEM_PARSING_SHADER + = D3D11_MESSAGE_ID_REF_ACCESSING_INDEXABLE_TEMP_OUT_OF_RANGE + 1, + D3D11_MESSAGE_ID_REF_OUT_OF_MEMORY = D3D11_MESSAGE_ID_REF_PROBLEM_PARSING_SHADER + 1, + D3D11_MESSAGE_ID_REF_INFO = D3D11_MESSAGE_ID_REF_OUT_OF_MEMORY + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEXPOS_OVERFLOW = D3D11_MESSAGE_ID_REF_INFO + 1, + D3D11_MESSAGE_ID_DEVICE_DRAWINDEXED_INDEXPOS_OVERFLOW + = D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEXPOS_OVERFLOW + 1, + D3D11_MESSAGE_ID_DEVICE_DRAWINSTANCED_VERTEXPOS_OVERFLOW + = D3D11_MESSAGE_ID_DEVICE_DRAWINDEXED_INDEXPOS_OVERFLOW + 1, + D3D11_MESSAGE_ID_DEVICE_DRAWINSTANCED_INSTANCEPOS_OVERFLOW + = D3D11_MESSAGE_ID_DEVICE_DRAWINSTANCED_VERTEXPOS_OVERFLOW + 1, + D3D11_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INSTANCEPOS_OVERFLOW + = D3D11_MESSAGE_ID_DEVICE_DRAWINSTANCED_INSTANCEPOS_OVERFLOW + 1, + D3D11_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INDEXPOS_OVERFLOW + = D3D11_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INSTANCEPOS_OVERFLOW + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_SHADER_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INDEXPOS_OVERFLOW + 1, + D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND + = D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_SHADER_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERINDEX + = D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND + 1, + D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_COMPONENTTYPE + = D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERINDEX + 1, + D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERMASK + = D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_COMPONENTTYPE + 1, + D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SYSTEMVALUE + = D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERMASK + 1, + D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS + = D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SYSTEMVALUE + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_INPUTLAYOUT_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_DRAW_INPUTLAYOUT_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_TOO_SMALL + = D3D11_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_TOO_SMALL + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_SHADERRESOURCEVIEW_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_VIEW_DIMENSION_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_DRAW_SHADERRESOURCEVIEW_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL + = D3D11_MESSAGE_ID_DEVICE_DRAW_VIEW_DIMENSION_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL + = D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_FORMAT_INVALID + = D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL + = D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_FORMAT_INVALID + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_GS_INPUT_PRIMITIVE_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_RETURN_TYPE_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_DRAW_GS_INPUT_PRIMITIVE_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_POSITION_NOT_PRESENT + = D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_RETURN_TYPE_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_DRAW_POSITION_NOT_PRESENT + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_BOUND_RESOURCE_MAPPED + = D3D11_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_INVALID_PRIMITIVETOPOLOGY + = D3D11_MESSAGE_ID_DEVICE_DRAW_BOUND_RESOURCE_MAPPED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_OFFSET_UNALIGNED + = D3D11_MESSAGE_ID_DEVICE_DRAW_INVALID_PRIMITIVETOPOLOGY + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_STRIDE_UNALIGNED + = D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_OFFSET_UNALIGNED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_OFFSET_UNALIGNED + = D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_STRIDE_UNALIGNED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_OFFSET_UNALIGNED + = D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_OFFSET_UNALIGNED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_LD_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_OFFSET_UNALIGNED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_LD_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_MULTISAMPLE_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_SO_TARGETS_BOUND_WITHOUT_SOURCE + = D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_MULTISAMPLE_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_SO_STRIDE_LARGER_THAN_BUFFER + = D3D11_MESSAGE_ID_DEVICE_DRAW_SO_TARGETS_BOUND_WITHOUT_SOURCE + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_OM_RENDER_TARGET_DOES_NOT_SUPPORT_BLENDING + = D3D11_MESSAGE_ID_DEVICE_DRAW_SO_STRIDE_LARGER_THAN_BUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_OM_DUAL_SOURCE_BLENDING_CAN_ONLY_HAVE_RENDER_TARGET_0 + = D3D11_MESSAGE_ID_DEVICE_DRAW_OM_RENDER_TARGET_DOES_NOT_SUPPORT_BLENDING + 1, + D3D11_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_AT_FAULT + = D3D11_MESSAGE_ID_DEVICE_DRAW_OM_DUAL_SOURCE_BLENDING_CAN_ONLY_HAVE_RENDER_TARGET_0 + 1, + D3D11_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_POSSIBLY_AT_FAULT + = D3D11_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_AT_FAULT + 1, + D3D11_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT + = D3D11_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_POSSIBLY_AT_FAULT + 1, + D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT + 1, + D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_BADINTERFACE_RETURN + = D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_VIEWPORT_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_BADINTERFACE_RETURN + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TRAILING_DIGIT_IN_SEMANTIC + = D3D11_MESSAGE_ID_DEVICE_DRAW_VIEWPORT_NOT_SET + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_TRAILING_DIGIT_IN_SEMANTIC + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TRAILING_DIGIT_IN_SEMANTIC + 1, + D3D11_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_DENORMFLUSH + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_TRAILING_DIGIT_IN_SEMANTIC + 1, + D3D11_MESSAGE_ID_OMSETRENDERTARGETS_INVALIDVIEW + = D3D11_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_DENORMFLUSH + 1, + D3D11_MESSAGE_ID_DEVICE_SETTEXTFILTERSIZE_INVALIDDIMENSIONS + = D3D11_MESSAGE_ID_OMSETRENDERTARGETS_INVALIDVIEW + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_SETTEXTFILTERSIZE_INVALIDDIMENSIONS + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_MISMATCH + 1, + D3D11_MESSAGE_ID_BLENDSTATE_GETDESC_LEGACY + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH + 1, + D3D11_MESSAGE_ID_SHADERRESOURCEVIEW_GETDESC_LEGACY + = D3D11_MESSAGE_ID_BLENDSTATE_GETDESC_LEGACY + 1, + D3D11_MESSAGE_ID_CREATEQUERY_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_SHADERRESOURCEVIEW_GETDESC_LEGACY + 1, + D3D11_MESSAGE_ID_CREATEPREDICATE_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATEQUERY_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATECOUNTER_OUTOFRANGE_COUNTER + = D3D11_MESSAGE_ID_CREATEPREDICATE_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATECOUNTER_SIMULTANEOUS_ACTIVE_COUNTERS_EXHAUSTED + = D3D11_MESSAGE_ID_CREATECOUNTER_OUTOFRANGE_COUNTER + 1, + D3D11_MESSAGE_ID_CREATECOUNTER_UNSUPPORTED_WELLKNOWN_COUNTER + = D3D11_MESSAGE_ID_CREATECOUNTER_SIMULTANEOUS_ACTIVE_COUNTERS_EXHAUSTED + 1, + D3D11_MESSAGE_ID_CREATECOUNTER_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATECOUNTER_UNSUPPORTED_WELLKNOWN_COUNTER + 1, + D3D11_MESSAGE_ID_CREATECOUNTER_NONEXCLUSIVE_RETURN + = D3D11_MESSAGE_ID_CREATECOUNTER_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATECOUNTER_NULLDESC + = D3D11_MESSAGE_ID_CREATECOUNTER_NONEXCLUSIVE_RETURN + 1, + D3D11_MESSAGE_ID_CHECKCOUNTER_OUTOFRANGE_COUNTER = D3D11_MESSAGE_ID_CREATECOUNTER_NULLDESC + 1, + D3D11_MESSAGE_ID_CHECKCOUNTER_UNSUPPORTED_WELLKNOWN_COUNTER + = D3D11_MESSAGE_ID_CHECKCOUNTER_OUTOFRANGE_COUNTER + 1, + D3D11_MESSAGE_ID_SETPREDICATION_INVALID_PREDICATE_STATE + = D3D11_MESSAGE_ID_CHECKCOUNTER_UNSUPPORTED_WELLKNOWN_COUNTER + 1, + D3D11_MESSAGE_ID_QUERY_BEGIN_UNSUPPORTED + = D3D11_MESSAGE_ID_SETPREDICATION_INVALID_PREDICATE_STATE + 1, + D3D11_MESSAGE_ID_PREDICATE_BEGIN_DURING_PREDICATION + = D3D11_MESSAGE_ID_QUERY_BEGIN_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_QUERY_BEGIN_DUPLICATE + = D3D11_MESSAGE_ID_PREDICATE_BEGIN_DURING_PREDICATION + 1, + D3D11_MESSAGE_ID_QUERY_BEGIN_ABANDONING_PREVIOUS_RESULTS + = D3D11_MESSAGE_ID_QUERY_BEGIN_DUPLICATE + 1, + D3D11_MESSAGE_ID_PREDICATE_END_DURING_PREDICATION + = D3D11_MESSAGE_ID_QUERY_BEGIN_ABANDONING_PREVIOUS_RESULTS + 1, + D3D11_MESSAGE_ID_QUERY_END_ABANDONING_PREVIOUS_RESULTS + = D3D11_MESSAGE_ID_PREDICATE_END_DURING_PREDICATION + 1, + D3D11_MESSAGE_ID_QUERY_END_WITHOUT_BEGIN + = D3D11_MESSAGE_ID_QUERY_END_ABANDONING_PREVIOUS_RESULTS + 1, + D3D11_MESSAGE_ID_QUERY_GETDATA_INVALID_DATASIZE = D3D11_MESSAGE_ID_QUERY_END_WITHOUT_BEGIN + 1, + D3D11_MESSAGE_ID_QUERY_GETDATA_INVALID_FLAGS + = D3D11_MESSAGE_ID_QUERY_GETDATA_INVALID_DATASIZE + 1, + D3D11_MESSAGE_ID_QUERY_GETDATA_INVALID_CALL = D3D11_MESSAGE_ID_QUERY_GETDATA_INVALID_FLAGS + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_PS_OUTPUT_TYPE_MISMATCH + = D3D11_MESSAGE_ID_QUERY_GETDATA_INVALID_CALL + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_GATHER_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_DRAW_PS_OUTPUT_TYPE_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_INVALID_USE_OF_CENTER_MULTISAMPLE_PATTERN + = D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_GATHER_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_STRIDE_TOO_LARGE + = D3D11_MESSAGE_ID_DEVICE_DRAW_INVALID_USE_OF_CENTER_MULTISAMPLE_PATTERN + 1, + D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_INVALIDRANGE + = D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_STRIDE_TOO_LARGE + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_EMPTY_LAYOUT + = D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_INVALIDRANGE + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_SAMPLE_COUNT_MISMATCH + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_EMPTY_LAYOUT + 1, + D3D11_MESSAGE_ID_LIVE_OBJECT_SUMMARY + = D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_SAMPLE_COUNT_MISMATCH + 1, + D3D11_MESSAGE_ID_LIVE_BUFFER = D3D11_MESSAGE_ID_LIVE_OBJECT_SUMMARY + 1, + D3D11_MESSAGE_ID_LIVE_TEXTURE1D = D3D11_MESSAGE_ID_LIVE_BUFFER + 1, + D3D11_MESSAGE_ID_LIVE_TEXTURE2D = D3D11_MESSAGE_ID_LIVE_TEXTURE1D + 1, + D3D11_MESSAGE_ID_LIVE_TEXTURE3D = D3D11_MESSAGE_ID_LIVE_TEXTURE2D + 1, + D3D11_MESSAGE_ID_LIVE_SHADERRESOURCEVIEW = D3D11_MESSAGE_ID_LIVE_TEXTURE3D + 1, + D3D11_MESSAGE_ID_LIVE_RENDERTARGETVIEW = D3D11_MESSAGE_ID_LIVE_SHADERRESOURCEVIEW + 1, + D3D11_MESSAGE_ID_LIVE_DEPTHSTENCILVIEW = D3D11_MESSAGE_ID_LIVE_RENDERTARGETVIEW + 1, + D3D11_MESSAGE_ID_LIVE_VERTEXSHADER = D3D11_MESSAGE_ID_LIVE_DEPTHSTENCILVIEW + 1, + D3D11_MESSAGE_ID_LIVE_GEOMETRYSHADER = D3D11_MESSAGE_ID_LIVE_VERTEXSHADER + 1, + D3D11_MESSAGE_ID_LIVE_PIXELSHADER = D3D11_MESSAGE_ID_LIVE_GEOMETRYSHADER + 1, + D3D11_MESSAGE_ID_LIVE_INPUTLAYOUT = D3D11_MESSAGE_ID_LIVE_PIXELSHADER + 1, + D3D11_MESSAGE_ID_LIVE_SAMPLER = D3D11_MESSAGE_ID_LIVE_INPUTLAYOUT + 1, + D3D11_MESSAGE_ID_LIVE_BLENDSTATE = D3D11_MESSAGE_ID_LIVE_SAMPLER + 1, + D3D11_MESSAGE_ID_LIVE_DEPTHSTENCILSTATE = D3D11_MESSAGE_ID_LIVE_BLENDSTATE + 1, + D3D11_MESSAGE_ID_LIVE_RASTERIZERSTATE = D3D11_MESSAGE_ID_LIVE_DEPTHSTENCILSTATE + 1, + D3D11_MESSAGE_ID_LIVE_QUERY = D3D11_MESSAGE_ID_LIVE_RASTERIZERSTATE + 1, + D3D11_MESSAGE_ID_LIVE_PREDICATE = D3D11_MESSAGE_ID_LIVE_QUERY + 1, + D3D11_MESSAGE_ID_LIVE_COUNTER = D3D11_MESSAGE_ID_LIVE_PREDICATE + 1, + D3D11_MESSAGE_ID_LIVE_DEVICE = D3D11_MESSAGE_ID_LIVE_COUNTER + 1, + D3D11_MESSAGE_ID_LIVE_SWAPCHAIN = D3D11_MESSAGE_ID_LIVE_DEVICE + 1, + D3D11_MESSAGE_ID_D3D10_MESSAGES_END = D3D11_MESSAGE_ID_LIVE_SWAPCHAIN + 1, + D3D11_MESSAGE_ID_D3D10L9_MESSAGES_START = 0x100000, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_STENCIL_NO_TWO_SIDED + = D3D11_MESSAGE_ID_D3D10L9_MESSAGES_START + 1, + D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_DepthBiasClamp_NOT_SUPPORTED + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_STENCIL_NO_TWO_SIDED + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_NO_COMPARISON_SUPPORT + = D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_DepthBiasClamp_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_EXCESSIVE_ANISOTROPY + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_NO_COMPARISON_SUPPORT + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_BORDER_OUT_OF_RANGE + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_EXCESSIVE_ANISOTROPY + 1, + D3D11_MESSAGE_ID_VSSETSAMPLERS_NOT_SUPPORTED + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_BORDER_OUT_OF_RANGE + 1, + D3D11_MESSAGE_ID_VSSETSAMPLERS_TOO_MANY_SAMPLERS + = D3D11_MESSAGE_ID_VSSETSAMPLERS_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_PSSETSAMPLERS_TOO_MANY_SAMPLERS + = D3D11_MESSAGE_ID_VSSETSAMPLERS_TOO_MANY_SAMPLERS + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_NO_ARRAYS + = D3D11_MESSAGE_ID_PSSETSAMPLERS_TOO_MANY_SAMPLERS + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_NO_VB_AND_IB_BIND + = D3D11_MESSAGE_ID_CREATERESOURCE_NO_ARRAYS + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_NO_TEXTURE_1D + = D3D11_MESSAGE_ID_CREATERESOURCE_NO_VB_AND_IB_BIND + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_DIMENSION_OUT_OF_RANGE + = D3D11_MESSAGE_ID_CREATERESOURCE_NO_TEXTURE_1D + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_NOT_BINDABLE_AS_SHADER_RESOURCE + = D3D11_MESSAGE_ID_CREATERESOURCE_DIMENSION_OUT_OF_RANGE + 1, + D3D11_MESSAGE_ID_OMSETRENDERTARGETS_TOO_MANY_RENDER_TARGETS + = D3D11_MESSAGE_ID_CREATERESOURCE_NOT_BINDABLE_AS_SHADER_RESOURCE + 1, + D3D11_MESSAGE_ID_OMSETRENDERTARGETS_NO_DIFFERING_BIT_DEPTHS + = D3D11_MESSAGE_ID_OMSETRENDERTARGETS_TOO_MANY_RENDER_TARGETS + 1, + D3D11_MESSAGE_ID_IASETVERTEXBUFFERS_BAD_BUFFER_INDEX + = D3D11_MESSAGE_ID_OMSETRENDERTARGETS_NO_DIFFERING_BIT_DEPTHS + 1, + D3D11_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_TOO_MANY_VIEWPORTS + = D3D11_MESSAGE_ID_IASETVERTEXBUFFERS_BAD_BUFFER_INDEX + 1, + D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_ADJACENCY_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_TOO_MANY_VIEWPORTS + 1, + D3D11_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_TOO_MANY_SCISSORS + = D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_ADJACENCY_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_COPYRESOURCE_ONLY_TEXTURE_2D_WITHIN_GPU_MEMORY + = D3D11_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_TOO_MANY_SCISSORS + 1, + D3D11_MESSAGE_ID_COPYRESOURCE_NO_TEXTURE_3D_READBACK + = D3D11_MESSAGE_ID_COPYRESOURCE_ONLY_TEXTURE_2D_WITHIN_GPU_MEMORY + 1, + D3D11_MESSAGE_ID_COPYRESOURCE_NO_TEXTURE_ONLY_READBACK + = D3D11_MESSAGE_ID_COPYRESOURCE_NO_TEXTURE_3D_READBACK + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_UNSUPPORTED_FORMAT + = D3D11_MESSAGE_ID_COPYRESOURCE_NO_TEXTURE_ONLY_READBACK + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_ALPHA_TO_COVERAGE + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_UNSUPPORTED_FORMAT + 1, + D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_DepthClipEnable_MUST_BE_TRUE + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_ALPHA_TO_COVERAGE + 1, + D3D11_MESSAGE_ID_DRAWINDEXED_STARTINDEXLOCATION_MUST_BE_POSITIVE + = D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_DepthClipEnable_MUST_BE_TRUE + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_MUST_USE_LOWEST_LOD + = D3D11_MESSAGE_ID_DRAWINDEXED_STARTINDEXLOCATION_MUST_BE_POSITIVE + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_MINLOD_MUST_NOT_BE_FRACTIONAL + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_MUST_USE_LOWEST_LOD + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_MAXLOD_MUST_BE_FLT_MAX + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_MINLOD_MUST_NOT_BE_FRACTIONAL + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_FIRSTARRAYSLICE_MUST_BE_ZERO + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_MAXLOD_MUST_BE_FLT_MAX + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_CUBES_MUST_HAVE_6_SIDES + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_FIRSTARRAYSLICE_MUST_BE_ZERO + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_NOT_BINDABLE_AS_RENDER_TARGET + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_CUBES_MUST_HAVE_6_SIDES + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_NO_DWORD_INDEX_BUFFER + = D3D11_MESSAGE_ID_CREATERESOURCE_NOT_BINDABLE_AS_RENDER_TARGET + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_MSAA_PRECLUDES_SHADER_RESOURCE + = D3D11_MESSAGE_ID_CREATERESOURCE_NO_DWORD_INDEX_BUFFER + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_PRESENTATION_PRECLUDES_SHADER_RESOURCE + = D3D11_MESSAGE_ID_CREATERESOURCE_MSAA_PRECLUDES_SHADER_RESOURCE + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_INDEPENDENT_BLEND_ENABLE + = D3D11_MESSAGE_ID_CREATERESOURCE_PRESENTATION_PRECLUDES_SHADER_RESOURCE + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_INDEPENDENT_WRITE_MASKS + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_INDEPENDENT_BLEND_ENABLE + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_NO_STREAM_OUT + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_INDEPENDENT_WRITE_MASKS + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_ONLY_VB_IB_FOR_BUFFERS + = D3D11_MESSAGE_ID_CREATERESOURCE_NO_STREAM_OUT + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_NO_AUTOGEN_FOR_VOLUMES + = D3D11_MESSAGE_ID_CREATERESOURCE_ONLY_VB_IB_FOR_BUFFERS + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_DXGI_FORMAT_R8G8B8A8_CANNOT_BE_SHARED + = D3D11_MESSAGE_ID_CREATERESOURCE_NO_AUTOGEN_FOR_VOLUMES + 1, + D3D11_MESSAGE_ID_VSSHADERRESOURCES_NOT_SUPPORTED + = D3D11_MESSAGE_ID_CREATERESOURCE_DXGI_FORMAT_R8G8B8A8_CANNOT_BE_SHARED + 1, + D3D11_MESSAGE_ID_GEOMETRY_SHADER_NOT_SUPPORTED + = D3D11_MESSAGE_ID_VSSHADERRESOURCES_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_STREAM_OUT_NOT_SUPPORTED = D3D11_MESSAGE_ID_GEOMETRY_SHADER_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_TEXT_FILTER_NOT_SUPPORTED = D3D11_MESSAGE_ID_STREAM_OUT_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_SEPARATE_ALPHA_BLEND + = D3D11_MESSAGE_ID_TEXT_FILTER_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_MRT_BLEND + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_SEPARATE_ALPHA_BLEND + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_OPERATION_NOT_SUPPORTED + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_MRT_BLEND + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_NO_MIRRORONCE + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_OPERATION_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_DRAWINSTANCED_NOT_SUPPORTED + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_NO_MIRRORONCE + 1, + D3D11_MESSAGE_ID_DRAWINDEXEDINSTANCED_NOT_SUPPORTED_BELOW_9_3 + = D3D11_MESSAGE_ID_DRAWINSTANCED_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_DRAWINDEXED_POINTLIST_UNSUPPORTED + = D3D11_MESSAGE_ID_DRAWINDEXEDINSTANCED_NOT_SUPPORTED_BELOW_9_3 + 1, + D3D11_MESSAGE_ID_SETBLENDSTATE_SAMPLE_MASK_CANNOT_BE_ZERO + = D3D11_MESSAGE_ID_DRAWINDEXED_POINTLIST_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_DIMENSION_EXCEEDS_FEATURE_LEVEL_DEFINITION + = D3D11_MESSAGE_ID_SETBLENDSTATE_SAMPLE_MASK_CANNOT_BE_ZERO + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_ONLY_SINGLE_MIP_LEVEL_DEPTH_STENCIL_SUPPORTED + = D3D11_MESSAGE_ID_CREATERESOURCE_DIMENSION_EXCEEDS_FEATURE_LEVEL_DEFINITION + 1, + D3D11_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_NEGATIVESCISSOR + = D3D11_MESSAGE_ID_CREATERESOURCE_ONLY_SINGLE_MIP_LEVEL_DEPTH_STENCIL_SUPPORTED + 1, + D3D11_MESSAGE_ID_SLOT_ZERO_MUST_BE_D3D10_INPUT_PER_VERTEX_DATA + = D3D11_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_NEGATIVESCISSOR + 1, + D3D11_MESSAGE_ID_CREATERESOURCE_NON_POW_2_MIPMAP + = D3D11_MESSAGE_ID_SLOT_ZERO_MUST_BE_D3D10_INPUT_PER_VERTEX_DATA + 1, + D3D11_MESSAGE_ID_CREATESAMPLERSTATE_BORDER_NOT_SUPPORTED + = D3D11_MESSAGE_ID_CREATERESOURCE_NON_POW_2_MIPMAP + 1, + D3D11_MESSAGE_ID_OMSETRENDERTARGETS_NO_SRGB_MRT + = D3D11_MESSAGE_ID_CREATESAMPLERSTATE_BORDER_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_COPYRESOURCE_NO_3D_MISMATCHED_UPDATES + = D3D11_MESSAGE_ID_OMSETRENDERTARGETS_NO_SRGB_MRT + 1, + D3D11_MESSAGE_ID_D3D10L9_MESSAGES_END + = D3D11_MESSAGE_ID_COPYRESOURCE_NO_3D_MISMATCHED_UPDATES + 1, + D3D11_MESSAGE_ID_D3D11_MESSAGES_START = 0x200000, + D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFLAGS + = D3D11_MESSAGE_ID_D3D11_MESSAGES_START + 1, + D3D11_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDCLASSLINKAGE + = D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDCLASSLINKAGE + = D3D11_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDCLASSLINKAGE + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTREAMS + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDCLASSLINKAGE + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAMTORASTERIZER + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTREAMS + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTREAMS + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAMTORASTERIZER + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCLASSLINKAGE + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTREAMS + 1, + D3D11_MESSAGE_ID_CREATEPIXELSHADER_INVALIDCLASSLINKAGE + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCLASSLINKAGE + 1, + D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_INVALID_COMMANDLISTFLAGS + = D3D11_MESSAGE_ID_CREATEPIXELSHADER_INVALIDCLASSLINKAGE + 1, + D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_SINGLETHREADED + = D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_INVALID_COMMANDLISTFLAGS + 1, + D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_SINGLETHREADED + 1, + D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_INVALID_CALL_RETURN + = D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_INVALID_CALL_RETURN + 1, + D3D11_MESSAGE_ID_FINISHDISPLAYLIST_ONIMMEDIATECONTEXT + = D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_FINISHDISPLAYLIST_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_FINISHDISPLAYLIST_ONIMMEDIATECONTEXT + 1, + D3D11_MESSAGE_ID_FINISHDISPLAYLIST_INVALID_CALL_RETURN + = D3D11_MESSAGE_ID_FINISHDISPLAYLIST_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAM + = D3D11_MESSAGE_ID_FINISHDISPLAYLIST_INVALID_CALL_RETURN + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDENTRIES + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTRIDES + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDENTRIES + 1, + D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTRIDES + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTRIDES + 1, + D3D11_MESSAGE_ID_DEVICE_HSSETSHADERRESOURCES_HAZARD + = D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTRIDES + 1, + D3D11_MESSAGE_ID_DEVICE_HSSETCONSTANTBUFFERS_HAZARD + = D3D11_MESSAGE_ID_DEVICE_HSSETSHADERRESOURCES_HAZARD + 1, + D3D11_MESSAGE_ID_HSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_DEVICE_HSSETCONSTANTBUFFERS_HAZARD + 1, + D3D11_MESSAGE_ID_HSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_HSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDCALL + = D3D11_MESSAGE_ID_HSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CREATEHULLSHADER_OUTOFMEMORY + = D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDCALL + 1, + D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERBYTECODE + = D3D11_MESSAGE_ID_CREATEHULLSHADER_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERTYPE + = D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERBYTECODE + 1, + D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDCLASSLINKAGE + = D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERTYPE + 1, + D3D11_MESSAGE_ID_DEVICE_HSSETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDCLASSLINKAGE + 1, + D3D11_MESSAGE_ID_HSSETCONSTANTBUFFERS_INVALIDBUFFER + = D3D11_MESSAGE_ID_DEVICE_HSSETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_HSSETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_HSSETCONSTANTBUFFERS_INVALIDBUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_HSSETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_HSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_HSGETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_HSSETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_HSGETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_HSGETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_HSGETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_HSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_DSSETSHADERRESOURCES_HAZARD + = D3D11_MESSAGE_ID_DEVICE_HSGETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_DSSETCONSTANTBUFFERS_HAZARD + = D3D11_MESSAGE_ID_DEVICE_DSSETSHADERRESOURCES_HAZARD + 1, + D3D11_MESSAGE_ID_DSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_DEVICE_DSSETCONSTANTBUFFERS_HAZARD + 1, + D3D11_MESSAGE_ID_DSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_DSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCALL + = D3D11_MESSAGE_ID_DSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CREATEDOMAINSHADER_OUTOFMEMORY + = D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCALL + 1, + D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERBYTECODE + = D3D11_MESSAGE_ID_CREATEDOMAINSHADER_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERTYPE + = D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERBYTECODE + 1, + D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCLASSLINKAGE + = D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERTYPE + 1, + D3D11_MESSAGE_ID_DEVICE_DSSETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCLASSLINKAGE + 1, + D3D11_MESSAGE_ID_DSSETCONSTANTBUFFERS_INVALIDBUFFER + = D3D11_MESSAGE_ID_DEVICE_DSSETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_DSSETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_DSSETCONSTANTBUFFERS_INVALIDBUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_DSSETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_DSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_DSGETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_DSSETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_DSGETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_DSGETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_DSGETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_DSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_HS_XOR_DS_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_DSGETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEFERRED_CONTEXT_REMOVAL_PROCESS_AT_FAULT + = D3D11_MESSAGE_ID_DEVICE_DRAW_HS_XOR_DS_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_DRAWINDIRECT_INVALID_ARG_BUFFER + = D3D11_MESSAGE_ID_DEFERRED_CONTEXT_REMOVAL_PROCESS_AT_FAULT + 1, + D3D11_MESSAGE_ID_DEVICE_DRAWINDIRECT_OFFSET_UNALIGNED + = D3D11_MESSAGE_ID_DEVICE_DRAWINDIRECT_INVALID_ARG_BUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_DRAWINDIRECT_OFFSET_OVERFLOW + = D3D11_MESSAGE_ID_DEVICE_DRAWINDIRECT_OFFSET_UNALIGNED + 1, + D3D11_MESSAGE_ID_RESOURCE_MAP_INVALIDMAPTYPE + = D3D11_MESSAGE_ID_DEVICE_DRAWINDIRECT_OFFSET_OVERFLOW + 1, + D3D11_MESSAGE_ID_RESOURCE_MAP_INVALIDSUBRESOURCE + = D3D11_MESSAGE_ID_RESOURCE_MAP_INVALIDMAPTYPE + 1, + D3D11_MESSAGE_ID_RESOURCE_MAP_INVALIDFLAGS + = D3D11_MESSAGE_ID_RESOURCE_MAP_INVALIDSUBRESOURCE + 1, + D3D11_MESSAGE_ID_RESOURCE_MAP_ALREADYMAPPED = D3D11_MESSAGE_ID_RESOURCE_MAP_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_RESOURCE_MAP_DEVICEREMOVED_RETURN + = D3D11_MESSAGE_ID_RESOURCE_MAP_ALREADYMAPPED + 1, + D3D11_MESSAGE_ID_RESOURCE_MAP_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_RESOURCE_MAP_DEVICEREMOVED_RETURN + 1, + D3D11_MESSAGE_ID_RESOURCE_MAP_WITHOUT_INITIAL_DISCARD + = D3D11_MESSAGE_ID_RESOURCE_MAP_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_RESOURCE_UNMAP_INVALIDSUBRESOURCE + = D3D11_MESSAGE_ID_RESOURCE_MAP_WITHOUT_INITIAL_DISCARD + 1, + D3D11_MESSAGE_ID_RESOURCE_UNMAP_NOTMAPPED + = D3D11_MESSAGE_ID_RESOURCE_UNMAP_INVALIDSUBRESOURCE + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_RASTERIZING_CONTROL_POINTS + = D3D11_MESSAGE_ID_RESOURCE_UNMAP_NOTMAPPED + 1, + D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_DRAW_RASTERIZING_CONTROL_POINTS + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_HS_DS_SIGNATURE_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_HULL_SHADER_INPUT_TOPOLOGY_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_DRAW_HS_DS_SIGNATURE_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_HS_DS_CONTROL_POINT_COUNT_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_DRAW_HULL_SHADER_INPUT_TOPOLOGY_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_HS_DS_TESSELLATOR_DOMAIN_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_DRAW_HS_DS_CONTROL_POINT_COUNT_MISMATCH + 1, + D3D11_MESSAGE_ID_CREATE_CONTEXT + = D3D11_MESSAGE_ID_DEVICE_DRAW_HS_DS_TESSELLATOR_DOMAIN_MISMATCH + 1, + D3D11_MESSAGE_ID_LIVE_CONTEXT = D3D11_MESSAGE_ID_CREATE_CONTEXT + 1, + D3D11_MESSAGE_ID_DESTROY_CONTEXT = D3D11_MESSAGE_ID_LIVE_CONTEXT + 1, + D3D11_MESSAGE_ID_CREATE_BUFFER = D3D11_MESSAGE_ID_DESTROY_CONTEXT + 1, + D3D11_MESSAGE_ID_LIVE_BUFFER_WIN7 = D3D11_MESSAGE_ID_CREATE_BUFFER + 1, + D3D11_MESSAGE_ID_DESTROY_BUFFER = D3D11_MESSAGE_ID_LIVE_BUFFER_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_TEXTURE1D = D3D11_MESSAGE_ID_DESTROY_BUFFER + 1, + D3D11_MESSAGE_ID_LIVE_TEXTURE1D_WIN7 = D3D11_MESSAGE_ID_CREATE_TEXTURE1D + 1, + D3D11_MESSAGE_ID_DESTROY_TEXTURE1D = D3D11_MESSAGE_ID_LIVE_TEXTURE1D_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_TEXTURE2D = D3D11_MESSAGE_ID_DESTROY_TEXTURE1D + 1, + D3D11_MESSAGE_ID_LIVE_TEXTURE2D_WIN7 = D3D11_MESSAGE_ID_CREATE_TEXTURE2D + 1, + D3D11_MESSAGE_ID_DESTROY_TEXTURE2D = D3D11_MESSAGE_ID_LIVE_TEXTURE2D_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_TEXTURE3D = D3D11_MESSAGE_ID_DESTROY_TEXTURE2D + 1, + D3D11_MESSAGE_ID_LIVE_TEXTURE3D_WIN7 = D3D11_MESSAGE_ID_CREATE_TEXTURE3D + 1, + D3D11_MESSAGE_ID_DESTROY_TEXTURE3D = D3D11_MESSAGE_ID_LIVE_TEXTURE3D_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_SHADERRESOURCEVIEW = D3D11_MESSAGE_ID_DESTROY_TEXTURE3D + 1, + D3D11_MESSAGE_ID_LIVE_SHADERRESOURCEVIEW_WIN7 = D3D11_MESSAGE_ID_CREATE_SHADERRESOURCEVIEW + 1, + D3D11_MESSAGE_ID_DESTROY_SHADERRESOURCEVIEW + = D3D11_MESSAGE_ID_LIVE_SHADERRESOURCEVIEW_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_RENDERTARGETVIEW = D3D11_MESSAGE_ID_DESTROY_SHADERRESOURCEVIEW + 1, + D3D11_MESSAGE_ID_LIVE_RENDERTARGETVIEW_WIN7 = D3D11_MESSAGE_ID_CREATE_RENDERTARGETVIEW + 1, + D3D11_MESSAGE_ID_DESTROY_RENDERTARGETVIEW = D3D11_MESSAGE_ID_LIVE_RENDERTARGETVIEW_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_DEPTHSTENCILVIEW = D3D11_MESSAGE_ID_DESTROY_RENDERTARGETVIEW + 1, + D3D11_MESSAGE_ID_LIVE_DEPTHSTENCILVIEW_WIN7 = D3D11_MESSAGE_ID_CREATE_DEPTHSTENCILVIEW + 1, + D3D11_MESSAGE_ID_DESTROY_DEPTHSTENCILVIEW = D3D11_MESSAGE_ID_LIVE_DEPTHSTENCILVIEW_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_VERTEXSHADER = D3D11_MESSAGE_ID_DESTROY_DEPTHSTENCILVIEW + 1, + D3D11_MESSAGE_ID_LIVE_VERTEXSHADER_WIN7 = D3D11_MESSAGE_ID_CREATE_VERTEXSHADER + 1, + D3D11_MESSAGE_ID_DESTROY_VERTEXSHADER = D3D11_MESSAGE_ID_LIVE_VERTEXSHADER_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_HULLSHADER = D3D11_MESSAGE_ID_DESTROY_VERTEXSHADER + 1, + D3D11_MESSAGE_ID_LIVE_HULLSHADER = D3D11_MESSAGE_ID_CREATE_HULLSHADER + 1, + D3D11_MESSAGE_ID_DESTROY_HULLSHADER = D3D11_MESSAGE_ID_LIVE_HULLSHADER + 1, + D3D11_MESSAGE_ID_CREATE_DOMAINSHADER = D3D11_MESSAGE_ID_DESTROY_HULLSHADER + 1, + D3D11_MESSAGE_ID_LIVE_DOMAINSHADER = D3D11_MESSAGE_ID_CREATE_DOMAINSHADER + 1, + D3D11_MESSAGE_ID_DESTROY_DOMAINSHADER = D3D11_MESSAGE_ID_LIVE_DOMAINSHADER + 1, + D3D11_MESSAGE_ID_CREATE_GEOMETRYSHADER = D3D11_MESSAGE_ID_DESTROY_DOMAINSHADER + 1, + D3D11_MESSAGE_ID_LIVE_GEOMETRYSHADER_WIN7 = D3D11_MESSAGE_ID_CREATE_GEOMETRYSHADER + 1, + D3D11_MESSAGE_ID_DESTROY_GEOMETRYSHADER = D3D11_MESSAGE_ID_LIVE_GEOMETRYSHADER_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_PIXELSHADER = D3D11_MESSAGE_ID_DESTROY_GEOMETRYSHADER + 1, + D3D11_MESSAGE_ID_LIVE_PIXELSHADER_WIN7 = D3D11_MESSAGE_ID_CREATE_PIXELSHADER + 1, + D3D11_MESSAGE_ID_DESTROY_PIXELSHADER = D3D11_MESSAGE_ID_LIVE_PIXELSHADER_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_INPUTLAYOUT = D3D11_MESSAGE_ID_DESTROY_PIXELSHADER + 1, + D3D11_MESSAGE_ID_LIVE_INPUTLAYOUT_WIN7 = D3D11_MESSAGE_ID_CREATE_INPUTLAYOUT + 1, + D3D11_MESSAGE_ID_DESTROY_INPUTLAYOUT = D3D11_MESSAGE_ID_LIVE_INPUTLAYOUT_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_SAMPLER = D3D11_MESSAGE_ID_DESTROY_INPUTLAYOUT + 1, + D3D11_MESSAGE_ID_LIVE_SAMPLER_WIN7 = D3D11_MESSAGE_ID_CREATE_SAMPLER + 1, + D3D11_MESSAGE_ID_DESTROY_SAMPLER = D3D11_MESSAGE_ID_LIVE_SAMPLER_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_BLENDSTATE = D3D11_MESSAGE_ID_DESTROY_SAMPLER + 1, + D3D11_MESSAGE_ID_LIVE_BLENDSTATE_WIN7 = D3D11_MESSAGE_ID_CREATE_BLENDSTATE + 1, + D3D11_MESSAGE_ID_DESTROY_BLENDSTATE = D3D11_MESSAGE_ID_LIVE_BLENDSTATE_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_DEPTHSTENCILSTATE = D3D11_MESSAGE_ID_DESTROY_BLENDSTATE + 1, + D3D11_MESSAGE_ID_LIVE_DEPTHSTENCILSTATE_WIN7 = D3D11_MESSAGE_ID_CREATE_DEPTHSTENCILSTATE + 1, + D3D11_MESSAGE_ID_DESTROY_DEPTHSTENCILSTATE = D3D11_MESSAGE_ID_LIVE_DEPTHSTENCILSTATE_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_RASTERIZERSTATE = D3D11_MESSAGE_ID_DESTROY_DEPTHSTENCILSTATE + 1, + D3D11_MESSAGE_ID_LIVE_RASTERIZERSTATE_WIN7 = D3D11_MESSAGE_ID_CREATE_RASTERIZERSTATE + 1, + D3D11_MESSAGE_ID_DESTROY_RASTERIZERSTATE = D3D11_MESSAGE_ID_LIVE_RASTERIZERSTATE_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_QUERY = D3D11_MESSAGE_ID_DESTROY_RASTERIZERSTATE + 1, + D3D11_MESSAGE_ID_LIVE_QUERY_WIN7 = D3D11_MESSAGE_ID_CREATE_QUERY + 1, + D3D11_MESSAGE_ID_DESTROY_QUERY = D3D11_MESSAGE_ID_LIVE_QUERY_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_PREDICATE = D3D11_MESSAGE_ID_DESTROY_QUERY + 1, + D3D11_MESSAGE_ID_LIVE_PREDICATE_WIN7 = D3D11_MESSAGE_ID_CREATE_PREDICATE + 1, + D3D11_MESSAGE_ID_DESTROY_PREDICATE = D3D11_MESSAGE_ID_LIVE_PREDICATE_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_COUNTER = D3D11_MESSAGE_ID_DESTROY_PREDICATE + 1, + D3D11_MESSAGE_ID_DESTROY_COUNTER = D3D11_MESSAGE_ID_CREATE_COUNTER + 1, + D3D11_MESSAGE_ID_CREATE_COMMANDLIST = D3D11_MESSAGE_ID_DESTROY_COUNTER + 1, + D3D11_MESSAGE_ID_LIVE_COMMANDLIST = D3D11_MESSAGE_ID_CREATE_COMMANDLIST + 1, + D3D11_MESSAGE_ID_DESTROY_COMMANDLIST = D3D11_MESSAGE_ID_LIVE_COMMANDLIST + 1, + D3D11_MESSAGE_ID_CREATE_CLASSINSTANCE = D3D11_MESSAGE_ID_DESTROY_COMMANDLIST + 1, + D3D11_MESSAGE_ID_LIVE_CLASSINSTANCE = D3D11_MESSAGE_ID_CREATE_CLASSINSTANCE + 1, + D3D11_MESSAGE_ID_DESTROY_CLASSINSTANCE = D3D11_MESSAGE_ID_LIVE_CLASSINSTANCE + 1, + D3D11_MESSAGE_ID_CREATE_CLASSLINKAGE = D3D11_MESSAGE_ID_DESTROY_CLASSINSTANCE + 1, + D3D11_MESSAGE_ID_LIVE_CLASSLINKAGE = D3D11_MESSAGE_ID_CREATE_CLASSLINKAGE + 1, + D3D11_MESSAGE_ID_DESTROY_CLASSLINKAGE = D3D11_MESSAGE_ID_LIVE_CLASSLINKAGE + 1, + D3D11_MESSAGE_ID_LIVE_DEVICE_WIN7 = D3D11_MESSAGE_ID_DESTROY_CLASSLINKAGE + 1, + D3D11_MESSAGE_ID_LIVE_OBJECT_SUMMARY_WIN7 = D3D11_MESSAGE_ID_LIVE_DEVICE_WIN7 + 1, + D3D11_MESSAGE_ID_CREATE_COMPUTESHADER = D3D11_MESSAGE_ID_LIVE_OBJECT_SUMMARY_WIN7 + 1, + D3D11_MESSAGE_ID_LIVE_COMPUTESHADER = D3D11_MESSAGE_ID_CREATE_COMPUTESHADER + 1, + D3D11_MESSAGE_ID_DESTROY_COMPUTESHADER = D3D11_MESSAGE_ID_LIVE_COMPUTESHADER + 1, + D3D11_MESSAGE_ID_CREATE_UNORDEREDACCESSVIEW = D3D11_MESSAGE_ID_DESTROY_COMPUTESHADER + 1, + D3D11_MESSAGE_ID_LIVE_UNORDEREDACCESSVIEW = D3D11_MESSAGE_ID_CREATE_UNORDEREDACCESSVIEW + 1, + D3D11_MESSAGE_ID_DESTROY_UNORDEREDACCESSVIEW = D3D11_MESSAGE_ID_LIVE_UNORDEREDACCESSVIEW + 1, + D3D11_MESSAGE_ID_DEVICE_SETSHADER_INTERFACES_FEATURELEVEL + = D3D11_MESSAGE_ID_DESTROY_UNORDEREDACCESSVIEW + 1, + D3D11_MESSAGE_ID_DEVICE_SETSHADER_INTERFACE_COUNT_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_SETSHADER_INTERFACES_FEATURELEVEL + 1, + D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE + = D3D11_MESSAGE_ID_DEVICE_SETSHADER_INTERFACE_COUNT_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE_INDEX + = D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE + 1, + D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE_TYPE + = D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE_INDEX + 1, + D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE_DATA + = D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE_TYPE + 1, + D3D11_MESSAGE_ID_DEVICE_SETSHADER_UNBOUND_INSTANCE_DATA + = D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE_DATA + 1, + D3D11_MESSAGE_ID_DEVICE_SETSHADER_INSTANCE_DATA_BINDINGS + = D3D11_MESSAGE_ID_DEVICE_SETSHADER_UNBOUND_INSTANCE_DATA + 1, + D3D11_MESSAGE_ID_DEVICE_CREATESHADER_CLASSLINKAGE_FULL + = D3D11_MESSAGE_ID_DEVICE_SETSHADER_INSTANCE_DATA_BINDINGS + 1, + D3D11_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_UNRECOGNIZED_FEATURE + = D3D11_MESSAGE_ID_DEVICE_CREATESHADER_CLASSLINKAGE_FULL + 1, + D3D11_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_MISMATCHED_DATA_SIZE + = D3D11_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_UNRECOGNIZED_FEATURE + 1, + D3D11_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_MISMATCHED_DATA_SIZE + 1, + D3D11_MESSAGE_ID_DEVICE_CSSETSHADERRESOURCES_HAZARD + = D3D11_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_DEVICE_CSSETCONSTANTBUFFERS_HAZARD + = D3D11_MESSAGE_ID_DEVICE_CSSETSHADERRESOURCES_HAZARD + 1, + D3D11_MESSAGE_ID_CSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_DEVICE_CSSETCONSTANTBUFFERS_HAZARD + 1, + D3D11_MESSAGE_ID_CSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_CSSETSHADERRESOURCES_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCALL + = D3D11_MESSAGE_ID_CSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CREATECOMPUTESHADER_OUTOFMEMORY + = D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCALL + 1, + D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDSHADERBYTECODE + = D3D11_MESSAGE_ID_CREATECOMPUTESHADER_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDSHADERTYPE + = D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDSHADERBYTECODE + 1, + D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCLASSLINKAGE + = D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDSHADERTYPE + 1, + D3D11_MESSAGE_ID_DEVICE_CSSETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCLASSLINKAGE + 1, + D3D11_MESSAGE_ID_CSSETCONSTANTBUFFERS_INVALIDBUFFER + = D3D11_MESSAGE_ID_DEVICE_CSSETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_CSSETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_CSSETCONSTANTBUFFERS_INVALIDBUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_CSSETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_CSSETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_CSGETSHADERRESOURCES_VIEWS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_CSSETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_CSGETCONSTANTBUFFERS_BUFFERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_CSGETSHADERRESOURCES_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_CSGETSAMPLERS_SAMPLERS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_CSGETCONSTANTBUFFERS_BUFFERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEFLOATOPSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CSGETSAMPLERS_SAMPLERS_EMPTY + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEFLOATOPSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEFLOATOPSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEFLOATOPSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEFLOATOPSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEFLOATOPSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEFLOATOPSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEFLOATOPSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEFLOATOPSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEFLOATOPSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEFLOATOPSNOTSUPPORTED + + 1, + D3D11_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEFLOATOPSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEFLOATOPSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDSTRUCTURESTRIDE + = D3D11_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEFLOATOPSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFLAGS + = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDSTRUCTURESTRIDE + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDRESOURCE + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDESC + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDRESOURCE + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFORMAT + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDESC + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDIMENSIONS + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_UNRECOGNIZEDFORMAT + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDIMENSIONS + 1, + D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_HAZARD + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_UNRECOGNIZEDFORMAT + 1, + D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_OVERLAPPING_OLD_SLOTS + = D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_HAZARD + 1, + D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_NO_OP + = D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_OVERLAPPING_OLD_SLOTS + + 1, + D3D11_MESSAGE_ID_CSSETUNORDEREDACCESSVIEWS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_NO_OP + 1, + D3D11_MESSAGE_ID_PSSETUNORDEREDACCESSVIEWS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_CSSETUNORDEREDACCESSVIEWS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_PSSETUNORDEREDACCESSVIEWS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_TOOMANYOBJECTS + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_HAZARD + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_TOOMANYOBJECTS + 1, + D3D11_MESSAGE_ID_CLEARUNORDEREDACCESSVIEW_DENORMFLUSH + = D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_HAZARD + 1, + D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSS_VIEWS_EMPTY + = D3D11_MESSAGE_ID_CLEARUNORDEREDACCESSVIEW_DENORMFLUSH + 1, + D3D11_MESSAGE_ID_DEVICE_CSGETUNORDEREDACCESSS_VIEWS_EMPTY + = D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSS_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFLAGS + = D3D11_MESSAGE_ID_DEVICE_CSGETUNORDEREDACCESSS_VIEWS_EMPTY + 1, + D3D11_MESSAGE_ID_CREATESHADERRESESOURCEVIEW_TOOMANYOBJECTS + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_INVALID_ARG_BUFFER + = D3D11_MESSAGE_ID_CREATESHADERRESESOURCEVIEW_TOOMANYOBJECTS + 1, + D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_OFFSET_UNALIGNED + = D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_INVALID_ARG_BUFFER + 1, + D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_OFFSET_OVERFLOW + = D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_OFFSET_UNALIGNED + 1, + D3D11_MESSAGE_ID_DEVICE_SETRESOURCEMINLOD_INVALIDCONTEXT + = D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_OFFSET_OVERFLOW + 1, + D3D11_MESSAGE_ID_DEVICE_SETRESOURCEMINLOD_INVALIDRESOURCE + = D3D11_MESSAGE_ID_DEVICE_SETRESOURCEMINLOD_INVALIDCONTEXT + 1, + D3D11_MESSAGE_ID_DEVICE_SETRESOURCEMINLOD_INVALIDMINLOD + = D3D11_MESSAGE_ID_DEVICE_SETRESOURCEMINLOD_INVALIDRESOURCE + 1, + D3D11_MESSAGE_ID_DEVICE_GETRESOURCEMINLOD_INVALIDCONTEXT + = D3D11_MESSAGE_ID_DEVICE_SETRESOURCEMINLOD_INVALIDMINLOD + 1, + D3D11_MESSAGE_ID_DEVICE_GETRESOURCEMINLOD_INVALIDRESOURCE + = D3D11_MESSAGE_ID_DEVICE_GETRESOURCEMINLOD_INVALIDCONTEXT + 1, + D3D11_MESSAGE_ID_OMSETDEPTHSTENCIL_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_DEVICE_GETRESOURCEMINLOD_INVALIDRESOURCE + 1, + D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DEPTH_READONLY + = D3D11_MESSAGE_ID_OMSETDEPTHSTENCIL_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_STENCIL_READONLY + = D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DEPTH_READONLY + 1, + D3D11_MESSAGE_ID_CHECKFEATURESUPPORT_FORMAT_DEPRECATED + = D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_STENCIL_READONLY + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_RETURN_TYPE_MISMATCH + = D3D11_MESSAGE_ID_CHECKFEATURESUPPORT_FORMAT_DEPRECATED + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_RETURN_TYPE_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_UNORDEREDACCESSVIEW_RENDERTARGETVIEW_OVERLAP + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_DIMENSION_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_DRAW_UNORDEREDACCESSVIEW_RENDERTARGETVIEW_OVERLAP + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_APPEND_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_DIMENSION_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMICS_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_APPEND_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_STRUCTURE_STRIDE_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMICS_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_BUFFER_TYPE_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_STRUCTURE_STRIDE_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_RAW_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_BUFFER_TYPE_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_FORMAT_LD_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_RAW_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_FORMAT_STORE_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_FORMAT_LD_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_ADD_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_FORMAT_STORE_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_BITWISE_OPS_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_ADD_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_CMPSTORE_CMPEXCHANGE_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_BITWISE_OPS_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_EXCHANGE_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_CMPSTORE_CMPEXCHANGE_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_SIGNED_MINMAX_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_EXCHANGE_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_UNSIGNED_MINMAX_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_SIGNED_MINMAX_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_DISPATCH_BOUND_RESOURCE_MAPPED + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_UNSIGNED_MINMAX_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_DISPATCH_THREADGROUPCOUNT_OVERFLOW + = D3D11_MESSAGE_ID_DEVICE_DISPATCH_BOUND_RESOURCE_MAPPED + 1, + D3D11_MESSAGE_ID_DEVICE_DISPATCH_THREADGROUPCOUNT_ZERO + = D3D11_MESSAGE_ID_DEVICE_DISPATCH_THREADGROUPCOUNT_OVERFLOW + 1, + D3D11_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_STRUCTURE_STRIDE_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_DISPATCH_THREADGROUPCOUNT_ZERO + 1, + D3D11_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_BUFFER_TYPE_MISMATCH + = D3D11_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_STRUCTURE_STRIDE_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_RAW_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_BUFFER_TYPE_MISMATCH + 1, + D3D11_MESSAGE_ID_DEVICE_DISPATCH_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_RAW_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_DISPATCH_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDOFFSET + = D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_LARGEOFFSET + = D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDOFFSET + 1, + D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDDESTINATIONSTATE + = D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_LARGEOFFSET + 1, + D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDSOURCESTATE + = D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDDESTINATIONSTATE + 1, + D3D11_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_NOT_SUPPORTED + = D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDSOURCESTATE + 1, + D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_INVALIDVIEW + = D3D11_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_INVALIDOFFSET + = D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_INVALIDVIEW + 1, + D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_TOOMANYVIEWS + = D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_INVALIDOFFSET + 1, + D3D11_MESSAGE_ID_CLEARUNORDEREDACCESSVIEWFLOAT_INVALIDFORMAT + = D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_TOOMANYVIEWS + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_COUNTER_UNSUPPORTED + = D3D11_MESSAGE_ID_CLEARUNORDEREDACCESSVIEWFLOAT_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_REF_WARNING + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_COUNTER_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_PIXEL_SHADER_WITHOUT_RTV_OR_DSV + = D3D11_MESSAGE_ID_REF_WARNING + 1, + D3D11_MESSAGE_ID_SHADER_ABORT + = D3D11_MESSAGE_ID_DEVICE_DRAW_PIXEL_SHADER_WITHOUT_RTV_OR_DSV + 1, + D3D11_MESSAGE_ID_SHADER_MESSAGE = D3D11_MESSAGE_ID_SHADER_ABORT + 1, + D3D11_MESSAGE_ID_SHADER_ERROR = D3D11_MESSAGE_ID_SHADER_MESSAGE + 1, + D3D11_MESSAGE_ID_OFFERRESOURCES_INVALIDRESOURCE = D3D11_MESSAGE_ID_SHADER_ERROR + 1, + D3D11_MESSAGE_ID_HSSETSAMPLERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_OFFERRESOURCES_INVALIDRESOURCE + 1, + D3D11_MESSAGE_ID_DSSETSAMPLERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_HSSETSAMPLERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CSSETSAMPLERS_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_DSSETSAMPLERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_HSSETSHADER_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_CSSETSAMPLERS_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_DSSETSHADER_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_HSSETSHADER_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_CSSETSHADER_UNBINDDELETINGOBJECT + = D3D11_MESSAGE_ID_DSSETSHADER_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_ENQUEUESETEVENT_INVALIDARG_RETURN + = D3D11_MESSAGE_ID_CSSETSHADER_UNBINDDELETINGOBJECT + 1, + D3D11_MESSAGE_ID_ENQUEUESETEVENT_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_ENQUEUESETEVENT_INVALIDARG_RETURN + 1, + D3D11_MESSAGE_ID_ENQUEUESETEVENT_ACCESSDENIED_RETURN + = D3D11_MESSAGE_ID_ENQUEUESETEVENT_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_NUMUAVS_INVALIDRANGE + = D3D11_MESSAGE_ID_ENQUEUESETEVENT_ACCESSDENIED_RETURN + 1, + D3D11_MESSAGE_ID_USE_OF_ZERO_REFCOUNT_OBJECT + = D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_NUMUAVS_INVALIDRANGE + + 1, + D3D11_MESSAGE_ID_D3D11_MESSAGES_END = D3D11_MESSAGE_ID_USE_OF_ZERO_REFCOUNT_OBJECT + 1, + D3D11_MESSAGE_ID_D3D11_1_MESSAGES_START = 0x300000, + D3D11_MESSAGE_ID_CREATE_VIDEODECODER = D3D11_MESSAGE_ID_D3D11_1_MESSAGES_START + 1, + D3D11_MESSAGE_ID_CREATE_VIDEOPROCESSORENUM = D3D11_MESSAGE_ID_CREATE_VIDEODECODER + 1, + D3D11_MESSAGE_ID_CREATE_VIDEOPROCESSOR = D3D11_MESSAGE_ID_CREATE_VIDEOPROCESSORENUM + 1, + D3D11_MESSAGE_ID_CREATE_DECODEROUTPUTVIEW = D3D11_MESSAGE_ID_CREATE_VIDEOPROCESSOR + 1, + D3D11_MESSAGE_ID_CREATE_PROCESSORINPUTVIEW = D3D11_MESSAGE_ID_CREATE_DECODEROUTPUTVIEW + 1, + D3D11_MESSAGE_ID_CREATE_PROCESSOROUTPUTVIEW = D3D11_MESSAGE_ID_CREATE_PROCESSORINPUTVIEW + 1, + D3D11_MESSAGE_ID_CREATE_DEVICECONTEXTSTATE = D3D11_MESSAGE_ID_CREATE_PROCESSOROUTPUTVIEW + 1, + D3D11_MESSAGE_ID_LIVE_VIDEODECODER = D3D11_MESSAGE_ID_CREATE_DEVICECONTEXTSTATE + 1, + D3D11_MESSAGE_ID_LIVE_VIDEOPROCESSORENUM = D3D11_MESSAGE_ID_LIVE_VIDEODECODER + 1, + D3D11_MESSAGE_ID_LIVE_VIDEOPROCESSOR = D3D11_MESSAGE_ID_LIVE_VIDEOPROCESSORENUM + 1, + D3D11_MESSAGE_ID_LIVE_DECODEROUTPUTVIEW = D3D11_MESSAGE_ID_LIVE_VIDEOPROCESSOR + 1, + D3D11_MESSAGE_ID_LIVE_PROCESSORINPUTVIEW = D3D11_MESSAGE_ID_LIVE_DECODEROUTPUTVIEW + 1, + D3D11_MESSAGE_ID_LIVE_PROCESSOROUTPUTVIEW = D3D11_MESSAGE_ID_LIVE_PROCESSORINPUTVIEW + 1, + D3D11_MESSAGE_ID_LIVE_DEVICECONTEXTSTATE = D3D11_MESSAGE_ID_LIVE_PROCESSOROUTPUTVIEW + 1, + D3D11_MESSAGE_ID_DESTROY_VIDEODECODER = D3D11_MESSAGE_ID_LIVE_DEVICECONTEXTSTATE + 1, + D3D11_MESSAGE_ID_DESTROY_VIDEOPROCESSORENUM = D3D11_MESSAGE_ID_DESTROY_VIDEODECODER + 1, + D3D11_MESSAGE_ID_DESTROY_VIDEOPROCESSOR = D3D11_MESSAGE_ID_DESTROY_VIDEOPROCESSORENUM + 1, + D3D11_MESSAGE_ID_DESTROY_DECODEROUTPUTVIEW = D3D11_MESSAGE_ID_DESTROY_VIDEOPROCESSOR + 1, + D3D11_MESSAGE_ID_DESTROY_PROCESSORINPUTVIEW = D3D11_MESSAGE_ID_DESTROY_DECODEROUTPUTVIEW + 1, + D3D11_MESSAGE_ID_DESTROY_PROCESSOROUTPUTVIEW = D3D11_MESSAGE_ID_DESTROY_PROCESSORINPUTVIEW + 1, + D3D11_MESSAGE_ID_DESTROY_DEVICECONTEXTSTATE = D3D11_MESSAGE_ID_DESTROY_PROCESSOROUTPUTVIEW + 1, + D3D11_MESSAGE_ID_CREATEDEVICECONTEXTSTATE_INVALIDFLAGS + = D3D11_MESSAGE_ID_DESTROY_DEVICECONTEXTSTATE + 1, + D3D11_MESSAGE_ID_CREATEDEVICECONTEXTSTATE_INVALIDFEATURELEVEL + = D3D11_MESSAGE_ID_CREATEDEVICECONTEXTSTATE_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_CREATEDEVICECONTEXTSTATE_FEATURELEVELS_NOT_SUPPORTED + = D3D11_MESSAGE_ID_CREATEDEVICECONTEXTSTATE_INVALIDFEATURELEVEL + 1, + D3D11_MESSAGE_ID_CREATEDEVICECONTEXTSTATE_INVALIDREFIID + = D3D11_MESSAGE_ID_CREATEDEVICECONTEXTSTATE_FEATURELEVELS_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_DISCARDVIEW_INVALIDVIEW + = D3D11_MESSAGE_ID_CREATEDEVICECONTEXTSTATE_INVALIDREFIID + 1, + D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION1_INVALIDCOPYFLAGS + = D3D11_MESSAGE_ID_DEVICE_DISCARDVIEW_INVALIDVIEW + 1, + D3D11_MESSAGE_ID_UPDATESUBRESOURCE1_INVALIDCOPYFLAGS + = D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION1_INVALIDCOPYFLAGS + 1, + D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFORCEDSAMPLECOUNT + = D3D11_MESSAGE_ID_UPDATESUBRESOURCE1_INVALIDCOPYFLAGS + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODER_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFORCEDSAMPLECOUNT + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODER_NULLPARAM + = D3D11_MESSAGE_ID_CREATEVIDEODECODER_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODER_INVALIDFORMAT + = D3D11_MESSAGE_ID_CREATEVIDEODECODER_NULLPARAM + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODER_ZEROWIDTHHEIGHT + = D3D11_MESSAGE_ID_CREATEVIDEODECODER_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODER_DRIVER_INVALIDBUFFERSIZE + = D3D11_MESSAGE_ID_CREATEVIDEODECODER_ZEROWIDTHHEIGHT + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODER_DRIVER_INVALIDBUFFERUSAGE + = D3D11_MESSAGE_ID_CREATEVIDEODECODER_DRIVER_INVALIDBUFFERSIZE + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERPROFILECOUNT_OUTOFMEMORY + = D3D11_MESSAGE_ID_CREATEVIDEODECODER_DRIVER_INVALIDBUFFERUSAGE + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERPROFILE_NULLPARAM + = D3D11_MESSAGE_ID_GETVIDEODECODERPROFILECOUNT_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERPROFILE_INVALIDINDEX + = D3D11_MESSAGE_ID_GETVIDEODECODERPROFILE_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERPROFILE_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_GETVIDEODECODERPROFILE_INVALIDINDEX + 1, + D3D11_MESSAGE_ID_CHECKVIDEODECODERFORMAT_NULLPARAM + = D3D11_MESSAGE_ID_GETVIDEODECODERPROFILE_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CHECKVIDEODECODERFORMAT_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CHECKVIDEODECODERFORMAT_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERCONFIGCOUNT_NULLPARAM + = D3D11_MESSAGE_ID_CHECKVIDEODECODERFORMAT_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERCONFIGCOUNT_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_GETVIDEODECODERCONFIGCOUNT_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERCONFIG_NULLPARAM + = D3D11_MESSAGE_ID_GETVIDEODECODERCONFIGCOUNT_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERCONFIG_INVALIDINDEX + = D3D11_MESSAGE_ID_GETVIDEODECODERCONFIG_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERCONFIG_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_GETVIDEODECODERCONFIG_INVALIDINDEX + 1, + D3D11_MESSAGE_ID_GETDECODERCREATIONPARAMS_NULLPARAM + = D3D11_MESSAGE_ID_GETVIDEODECODERCONFIG_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_GETDECODERDRIVERHANDLE_NULLPARAM + = D3D11_MESSAGE_ID_GETDECODERCREATIONPARAMS_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETDECODERBUFFER_NULLPARAM + = D3D11_MESSAGE_ID_GETDECODERDRIVERHANDLE_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETDECODERBUFFER_INVALIDBUFFER + = D3D11_MESSAGE_ID_GETDECODERBUFFER_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETDECODERBUFFER_INVALIDTYPE + = D3D11_MESSAGE_ID_GETDECODERBUFFER_INVALIDBUFFER + 1, + D3D11_MESSAGE_ID_GETDECODERBUFFER_LOCKED = D3D11_MESSAGE_ID_GETDECODERBUFFER_INVALIDTYPE + 1, + D3D11_MESSAGE_ID_RELEASEDECODERBUFFER_NULLPARAM = D3D11_MESSAGE_ID_GETDECODERBUFFER_LOCKED + 1, + D3D11_MESSAGE_ID_RELEASEDECODERBUFFER_INVALIDTYPE + = D3D11_MESSAGE_ID_RELEASEDECODERBUFFER_NULLPARAM + 1, + D3D11_MESSAGE_ID_RELEASEDECODERBUFFER_NOTLOCKED + = D3D11_MESSAGE_ID_RELEASEDECODERBUFFER_INVALIDTYPE + 1, + D3D11_MESSAGE_ID_DECODERBEGINFRAME_NULLPARAM + = D3D11_MESSAGE_ID_RELEASEDECODERBUFFER_NOTLOCKED + 1, + D3D11_MESSAGE_ID_DECODERBEGINFRAME_HAZARD = D3D11_MESSAGE_ID_DECODERBEGINFRAME_NULLPARAM + 1, + D3D11_MESSAGE_ID_DECODERENDFRAME_NULLPARAM = D3D11_MESSAGE_ID_DECODERBEGINFRAME_HAZARD + 1, + D3D11_MESSAGE_ID_SUBMITDECODERBUFFERS_NULLPARAM + = D3D11_MESSAGE_ID_DECODERENDFRAME_NULLPARAM + 1, + D3D11_MESSAGE_ID_SUBMITDECODERBUFFERS_INVALIDTYPE + = D3D11_MESSAGE_ID_SUBMITDECODERBUFFERS_NULLPARAM + 1, + D3D11_MESSAGE_ID_DECODEREXTENSION_NULLPARAM + = D3D11_MESSAGE_ID_SUBMITDECODERBUFFERS_INVALIDTYPE + 1, + D3D11_MESSAGE_ID_DECODEREXTENSION_INVALIDRESOURCE + = D3D11_MESSAGE_ID_DECODEREXTENSION_NULLPARAM + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_DECODEREXTENSION_INVALIDRESOURCE + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_NULLPARAM + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_INVALIDFRAMEFORMAT + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_NULLPARAM + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_INVALIDUSAGE + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_INVALIDFRAMEFORMAT + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_INVALIDINPUTFRAMERATE + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_INVALIDUSAGE + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_INVALIDOUTPUTFRAMERATE + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_INVALIDINPUTFRAMERATE + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_INVALIDWIDTHHEIGHT + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_INVALIDOUTPUTFRAMERATE + 1, + D3D11_MESSAGE_ID_GETVIDEOPROCESSORCONTENTDESC_NULLPARAM + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORENUMERATOR_INVALIDWIDTHHEIGHT + 1, + D3D11_MESSAGE_ID_CHECKVIDEOPROCESSORFORMAT_NULLPARAM + = D3D11_MESSAGE_ID_GETVIDEOPROCESSORCONTENTDESC_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEOPROCESSORCAPS_NULLPARAM + = D3D11_MESSAGE_ID_CHECKVIDEOPROCESSORFORMAT_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEOPROCESSORRATECONVERSIONCAPS_NULLPARAM + = D3D11_MESSAGE_ID_GETVIDEOPROCESSORCAPS_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEOPROCESSORRATECONVERSIONCAPS_INVALIDINDEX + = D3D11_MESSAGE_ID_GETVIDEOPROCESSORRATECONVERSIONCAPS_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEOPROCESSORCUSTOMRATE_NULLPARAM + = D3D11_MESSAGE_ID_GETVIDEOPROCESSORRATECONVERSIONCAPS_INVALIDINDEX + 1, + D3D11_MESSAGE_ID_GETVIDEOPROCESSORCUSTOMRATE_INVALIDINDEX + = D3D11_MESSAGE_ID_GETVIDEOPROCESSORCUSTOMRATE_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEOPROCESSORFILTERRANGE_NULLPARAM + = D3D11_MESSAGE_ID_GETVIDEOPROCESSORCUSTOMRATE_INVALIDINDEX + 1, + D3D11_MESSAGE_ID_GETVIDEOPROCESSORFILTERRANGE_UNSUPPORTED + = D3D11_MESSAGE_ID_GETVIDEOPROCESSORFILTERRANGE_NULLPARAM + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOR_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_GETVIDEOPROCESSORFILTERRANGE_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOR_NULLPARAM + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOR_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTTARGETRECT_NULLPARAM + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOR_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTBACKGROUNDCOLOR_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTTARGETRECT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTBACKGROUNDCOLOR_INVALIDALPHA + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTBACKGROUNDCOLOR_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCOLORSPACE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTBACKGROUNDCOLOR_INVALIDALPHA + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTALPHAFILLMODE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCOLORSPACE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTALPHAFILLMODE_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTALPHAFILLMODE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTALPHAFILLMODE_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTALPHAFILLMODE_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTALPHAFILLMODE_INVALIDFILLMODE + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTALPHAFILLMODE_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCONSTRICTION_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTALPHAFILLMODE_INVALIDFILLMODE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTSTEREOMODE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCONSTRICTION_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTSTEREOMODE_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTSTEREOMODE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTEXTENSION_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTSTEREOMODE_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTTARGETRECT_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTEXTENSION_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTBACKGROUNDCOLOR_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTTARGETRECT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTCOLORSPACE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTBACKGROUNDCOLOR_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTALPHAFILLMODE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTCOLORSPACE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTCONSTRICTION_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTALPHAFILLMODE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCONSTRICTION_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTCONSTRICTION_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCONSTRICTION_INVALIDSIZE + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCONSTRICTION_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTSTEREOMODE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCONSTRICTION_INVALIDSIZE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTEXTENSION_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTSTEREOMODE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFRAMEFORMAT_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTEXTENSION_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFRAMEFORMAT_INVALIDFORMAT + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFRAMEFORMAT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFRAMEFORMAT_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFRAMEFORMAT_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFRAMEFORMAT_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMOUTPUTRATE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMOUTPUTRATE_INVALIDRATE + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMOUTPUTRATE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMOUTPUTRATE_INVALIDFLAG + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMOUTPUTRATE_INVALIDRATE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMOUTPUTRATE_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMOUTPUTRATE_INVALIDFLAG + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSOURCERECT_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMOUTPUTRATE_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSOURCERECT_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSOURCERECT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSOURCERECT_INVALIDRECT + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSOURCERECT_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMDESTRECT_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSOURCERECT_INVALIDRECT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMDESTRECT_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMDESTRECT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMDESTRECT_INVALIDRECT + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMDESTRECT_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMALPHA_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMDESTRECT_INVALIDRECT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMALPHA_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMALPHA_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMALPHA_INVALIDALPHA + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMALPHA_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPALETTE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMALPHA_INVALIDALPHA + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPALETTE_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPALETTE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPALETTE_INVALIDCOUNT + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPALETTE_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPALETTE_INVALIDALPHA + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPALETTE_INVALIDCOUNT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPIXELASPECTRATIO_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPALETTE_INVALIDALPHA + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPIXELASPECTRATIO_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPIXELASPECTRATIO_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPIXELASPECTRATIO_INVALIDRATIO + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPIXELASPECTRATIO_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMLUMAKEY_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPIXELASPECTRATIO_INVALIDRATIO + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMLUMAKEY_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMLUMAKEY_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMLUMAKEY_INVALIDRANGE + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMLUMAKEY_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMLUMAKEY_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMLUMAKEY_INVALIDRANGE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMLUMAKEY_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_FLIPUNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_MONOOFFSETUNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_FLIPUNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_FORMATUNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_MONOOFFSETUNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_INVALIDFORMAT + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_FORMATUNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMAUTOPROCESSINGMODE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMSTEREOFORMAT_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMAUTOPROCESSINGMODE_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMAUTOPROCESSINGMODE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFILTER_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMAUTOPROCESSINGMODE_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFILTER_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFILTER_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFILTER_INVALIDFILTER + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFILTER_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFILTER_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFILTER_INVALIDFILTER + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFILTER_INVALIDLEVEL + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFILTER_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMEXTENSION_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMFILTER_INVALIDLEVEL + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMEXTENSION_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMEXTENSION_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFRAMEFORMAT_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMEXTENSION_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFRAMEFORMAT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMOUTPUTRATE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSOURCERECT_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMOUTPUTRATE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMDESTRECT_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSOURCERECT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMALPHA_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMDESTRECT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPALETTE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMALPHA_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPIXELASPECTRATIO_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPALETTE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMLUMAKEY_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPIXELASPECTRATIO_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSTEREOFORMAT_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMLUMAKEY_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMAUTOPROCESSINGMODE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSTEREOFORMAT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFILTER_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMAUTOPROCESSINGMODE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMEXTENSION_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFILTER_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMEXTENSION_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMEXTENSION_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMEXTENSION_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDSTREAMCOUNT + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_TARGETRECT + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDSTREAMCOUNT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDOUTPUT + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_TARGETRECT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDPASTFRAMES + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDOUTPUT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDFUTUREFRAMES + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDPASTFRAMES + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDSOURCERECT + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDFUTUREFRAMES + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDDESTRECT + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDSOURCERECT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDINPUTRESOURCE + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDDESTRECT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDARRAYSIZE + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDINPUTRESOURCE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDARRAY + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDARRAYSIZE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_RIGHTEXPECTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDARRAY + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_RIGHTNOTEXPECTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_RIGHTEXPECTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_STEREONOTENABLED + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_RIGHTNOTEXPECTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDRIGHTRESOURCE + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_STEREONOTENABLED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_NOSTEREOSTREAMS + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INVALIDRIGHTRESOURCE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INPUTHAZARD + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_NOSTEREOSTREAMS + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_OUTPUTHAZARD + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_INPUTHAZARD + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_VIDEOPROCESSORBLT_OUTPUTHAZARD + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_NULLPARAM + = D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDTYPE + = D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_NULLPARAM + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDBIND + = D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDTYPE + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_UNSUPPORTEDFORMAT + = D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDBIND + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDMIP + = D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_UNSUPPORTEDFORMAT + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_UNSUPPORTEMIP + = D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDMIP + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDARRAYSIZE + = D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_UNSUPPORTEMIP + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDARRAY + = D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDARRAYSIZE + 1, + D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDDIMENSION + = D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDARRAY + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATEVIDEODECODEROUTPUTVIEW_INVALIDDIMENSION + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_NULLPARAM + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDTYPE + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_NULLPARAM + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDBIND + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDTYPE + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDMISC + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDBIND + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDUSAGE + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDMISC + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDFORMAT + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDUSAGE + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDFOURCC + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDMIP + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDFOURCC + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_UNSUPPORTEDMIP + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDMIP + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDARRAYSIZE + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_UNSUPPORTEDMIP + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDARRAY + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDARRAYSIZE + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDDIMENSION + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDARRAY + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDDIMENSION + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_NULLPARAM + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDTYPE + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_NULLPARAM + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDBIND + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDTYPE + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDFORMAT + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDBIND + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDMIP + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDFORMAT + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_UNSUPPORTEDMIP + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDMIP + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_UNSUPPORTEDARRAY + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_UNSUPPORTEDMIP + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDARRAY + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_UNSUPPORTEDARRAY + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDDIMENSION + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDARRAY + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_INVALID_USE_OF_FORCED_SAMPLE_COUNT + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDDIMENSION + 1, + D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDLOGICOPS + = D3D11_MESSAGE_ID_DEVICE_DRAW_INVALID_USE_OF_FORCED_SAMPLE_COUNT + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDARRAYWITHDECODER + = D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDLOGICOPS + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDARRAYWITHDECODER + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDARRAYWITHDECODER + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDARRAYWITHDECODER + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDARRAYWITHDECODER + 1, + D3D11_MESSAGE_ID_DEVICE_LOCKEDOUT_INTERFACE + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDARRAYWITHDECODER + 1, + D3D11_MESSAGE_ID_REF_WARNING_ATOMIC_INCONSISTENT + = D3D11_MESSAGE_ID_DEVICE_LOCKEDOUT_INTERFACE + 1, + D3D11_MESSAGE_ID_REF_WARNING_READING_UNINITIALIZED_RESOURCE + = D3D11_MESSAGE_ID_REF_WARNING_ATOMIC_INCONSISTENT + 1, + D3D11_MESSAGE_ID_REF_WARNING_RAW_HAZARD + = D3D11_MESSAGE_ID_REF_WARNING_READING_UNINITIALIZED_RESOURCE + 1, + D3D11_MESSAGE_ID_REF_WARNING_WAR_HAZARD = D3D11_MESSAGE_ID_REF_WARNING_RAW_HAZARD + 1, + D3D11_MESSAGE_ID_REF_WARNING_WAW_HAZARD = D3D11_MESSAGE_ID_REF_WARNING_WAR_HAZARD + 1, + D3D11_MESSAGE_ID_CREATECRYPTOSESSION_NULLPARAM = D3D11_MESSAGE_ID_REF_WARNING_WAW_HAZARD + 1, + D3D11_MESSAGE_ID_CREATECRYPTOSESSION_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATECRYPTOSESSION_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETCRYPTOTYPE_NULLPARAM + = D3D11_MESSAGE_ID_CREATECRYPTOSESSION_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_GETDECODERPROFILE_NULLPARAM = D3D11_MESSAGE_ID_GETCRYPTOTYPE_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETCRYPTOSESSIONCERTIFICATESIZE_NULLPARAM + = D3D11_MESSAGE_ID_GETDECODERPROFILE_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETCRYPTOSESSIONCERTIFICATE_NULLPARAM + = D3D11_MESSAGE_ID_GETCRYPTOSESSIONCERTIFICATESIZE_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETCRYPTOSESSIONCERTIFICATE_WRONGSIZE + = D3D11_MESSAGE_ID_GETCRYPTOSESSIONCERTIFICATE_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETCRYPTOSESSIONHANDLE_WRONGSIZE + = D3D11_MESSAGE_ID_GETCRYPTOSESSIONCERTIFICATE_WRONGSIZE + 1, + D3D11_MESSAGE_ID_NEGOTIATECRPYTOSESSIONKEYEXCHANGE_NULLPARAM + = D3D11_MESSAGE_ID_GETCRYPTOSESSIONHANDLE_WRONGSIZE + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_UNSUPPORTED + = D3D11_MESSAGE_ID_NEGOTIATECRPYTOSESSIONKEYEXCHANGE_NULLPARAM + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_NULLPARAM = D3D11_MESSAGE_ID_ENCRYPTIONBLT_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_SRC_WRONGDEVICE = D3D11_MESSAGE_ID_ENCRYPTIONBLT_NULLPARAM + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_DST_WRONGDEVICE + = D3D11_MESSAGE_ID_ENCRYPTIONBLT_SRC_WRONGDEVICE + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_FORMAT_MISMATCH + = D3D11_MESSAGE_ID_ENCRYPTIONBLT_DST_WRONGDEVICE + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_SIZE_MISMATCH + = D3D11_MESSAGE_ID_ENCRYPTIONBLT_FORMAT_MISMATCH + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_SRC_MULTISAMPLED + = D3D11_MESSAGE_ID_ENCRYPTIONBLT_SIZE_MISMATCH + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_DST_NOT_STAGING + = D3D11_MESSAGE_ID_ENCRYPTIONBLT_SRC_MULTISAMPLED + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_SRC_MAPPED = D3D11_MESSAGE_ID_ENCRYPTIONBLT_DST_NOT_STAGING + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_DST_MAPPED = D3D11_MESSAGE_ID_ENCRYPTIONBLT_SRC_MAPPED + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_SRC_OFFERED = D3D11_MESSAGE_ID_ENCRYPTIONBLT_DST_MAPPED + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_DST_OFFERED = D3D11_MESSAGE_ID_ENCRYPTIONBLT_SRC_OFFERED + 1, + D3D11_MESSAGE_ID_ENCRYPTIONBLT_SRC_CONTENT_UNDEFINED + = D3D11_MESSAGE_ID_ENCRYPTIONBLT_DST_OFFERED + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_UNSUPPORTED + = D3D11_MESSAGE_ID_ENCRYPTIONBLT_SRC_CONTENT_UNDEFINED + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_NULLPARAM = D3D11_MESSAGE_ID_DECRYPTIONBLT_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_SRC_WRONGDEVICE = D3D11_MESSAGE_ID_DECRYPTIONBLT_NULLPARAM + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_DST_WRONGDEVICE + = D3D11_MESSAGE_ID_DECRYPTIONBLT_SRC_WRONGDEVICE + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_FORMAT_MISMATCH + = D3D11_MESSAGE_ID_DECRYPTIONBLT_DST_WRONGDEVICE + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_SIZE_MISMATCH + = D3D11_MESSAGE_ID_DECRYPTIONBLT_FORMAT_MISMATCH + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_DST_MULTISAMPLED + = D3D11_MESSAGE_ID_DECRYPTIONBLT_SIZE_MISMATCH + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_SRC_NOT_STAGING + = D3D11_MESSAGE_ID_DECRYPTIONBLT_DST_MULTISAMPLED + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_DST_NOT_RENDER_TARGET + = D3D11_MESSAGE_ID_DECRYPTIONBLT_SRC_NOT_STAGING + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_SRC_MAPPED + = D3D11_MESSAGE_ID_DECRYPTIONBLT_DST_NOT_RENDER_TARGET + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_DST_MAPPED = D3D11_MESSAGE_ID_DECRYPTIONBLT_SRC_MAPPED + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_SRC_OFFERED = D3D11_MESSAGE_ID_DECRYPTIONBLT_DST_MAPPED + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_DST_OFFERED = D3D11_MESSAGE_ID_DECRYPTIONBLT_SRC_OFFERED + 1, + D3D11_MESSAGE_ID_DECRYPTIONBLT_SRC_CONTENT_UNDEFINED + = D3D11_MESSAGE_ID_DECRYPTIONBLT_DST_OFFERED + 1, + D3D11_MESSAGE_ID_STARTSESSIONKEYREFRESH_NULLPARAM + = D3D11_MESSAGE_ID_DECRYPTIONBLT_SRC_CONTENT_UNDEFINED + 1, + D3D11_MESSAGE_ID_STARTSESSIONKEYREFRESH_INVALIDSIZE + = D3D11_MESSAGE_ID_STARTSESSIONKEYREFRESH_NULLPARAM + 1, + D3D11_MESSAGE_ID_FINISHSESSIONKEYREFRESH_NULLPARAM + = D3D11_MESSAGE_ID_STARTSESSIONKEYREFRESH_INVALIDSIZE + 1, + D3D11_MESSAGE_ID_GETENCRYPTIONBLTKEY_NULLPARAM + = D3D11_MESSAGE_ID_FINISHSESSIONKEYREFRESH_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETENCRYPTIONBLTKEY_INVALIDSIZE + = D3D11_MESSAGE_ID_GETENCRYPTIONBLTKEY_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETCONTENTPROTECTIONCAPS_NULLPARAM + = D3D11_MESSAGE_ID_GETENCRYPTIONBLTKEY_INVALIDSIZE + 1, + D3D11_MESSAGE_ID_CHECKCRYPTOKEYEXCHANGE_NULLPARAM + = D3D11_MESSAGE_ID_GETCONTENTPROTECTIONCAPS_NULLPARAM + 1, + D3D11_MESSAGE_ID_CHECKCRYPTOKEYEXCHANGE_INVALIDINDEX + = D3D11_MESSAGE_ID_CHECKCRYPTOKEYEXCHANGE_NULLPARAM + 1, + D3D11_MESSAGE_ID_CREATEAUTHENTICATEDCHANNEL_NULLPARAM + = D3D11_MESSAGE_ID_CHECKCRYPTOKEYEXCHANGE_INVALIDINDEX + 1, + D3D11_MESSAGE_ID_CREATEAUTHENTICATEDCHANNEL_UNSUPPORTED + = D3D11_MESSAGE_ID_CREATEAUTHENTICATEDCHANNEL_NULLPARAM + 1, + D3D11_MESSAGE_ID_CREATEAUTHENTICATEDCHANNEL_INVALIDTYPE + = D3D11_MESSAGE_ID_CREATEAUTHENTICATEDCHANNEL_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_CREATEAUTHENTICATEDCHANNEL_OUTOFMEMORY_RETURN + = D3D11_MESSAGE_ID_CREATEAUTHENTICATEDCHANNEL_INVALIDTYPE + 1, + D3D11_MESSAGE_ID_GETAUTHENTICATEDCHANNELCERTIFICATESIZE_INVALIDCHANNEL + = D3D11_MESSAGE_ID_CREATEAUTHENTICATEDCHANNEL_OUTOFMEMORY_RETURN + 1, + D3D11_MESSAGE_ID_GETAUTHENTICATEDCHANNELCERTIFICATESIZE_NULLPARAM + = D3D11_MESSAGE_ID_GETAUTHENTICATEDCHANNELCERTIFICATESIZE_INVALIDCHANNEL + 1, + D3D11_MESSAGE_ID_GETAUTHENTICATEDCHANNELCERTIFICATE_INVALIDCHANNEL + = D3D11_MESSAGE_ID_GETAUTHENTICATEDCHANNELCERTIFICATESIZE_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETAUTHENTICATEDCHANNELCERTIFICATE_NULLPARAM + = D3D11_MESSAGE_ID_GETAUTHENTICATEDCHANNELCERTIFICATE_INVALIDCHANNEL + 1, + D3D11_MESSAGE_ID_GETAUTHENTICATEDCHANNELCERTIFICATE_WRONGSIZE + = D3D11_MESSAGE_ID_GETAUTHENTICATEDCHANNELCERTIFICATE_NULLPARAM + 1, + D3D11_MESSAGE_ID_NEGOTIATEAUTHENTICATEDCHANNELKEYEXCHANGE_INVALIDCHANNEL + = D3D11_MESSAGE_ID_GETAUTHENTICATEDCHANNELCERTIFICATE_WRONGSIZE + 1, + D3D11_MESSAGE_ID_NEGOTIATEAUTHENTICATEDCHANNELKEYEXCHANGE_NULLPARAM + = D3D11_MESSAGE_ID_NEGOTIATEAUTHENTICATEDCHANNELKEYEXCHANGE_INVALIDCHANNEL + 1, + D3D11_MESSAGE_ID_QUERYAUTHENTICATEDCHANNEL_NULLPARAM + = D3D11_MESSAGE_ID_NEGOTIATEAUTHENTICATEDCHANNELKEYEXCHANGE_NULLPARAM + 1, + D3D11_MESSAGE_ID_QUERYAUTHENTICATEDCHANNEL_WRONGCHANNEL + = D3D11_MESSAGE_ID_QUERYAUTHENTICATEDCHANNEL_NULLPARAM + 1, + D3D11_MESSAGE_ID_QUERYAUTHENTICATEDCHANNEL_UNSUPPORTEDQUERY + = D3D11_MESSAGE_ID_QUERYAUTHENTICATEDCHANNEL_WRONGCHANNEL + 1, + D3D11_MESSAGE_ID_QUERYAUTHENTICATEDCHANNEL_WRONGSIZE + = D3D11_MESSAGE_ID_QUERYAUTHENTICATEDCHANNEL_UNSUPPORTEDQUERY + 1, + D3D11_MESSAGE_ID_QUERYAUTHENTICATEDCHANNEL_INVALIDPROCESSINDEX + = D3D11_MESSAGE_ID_QUERYAUTHENTICATEDCHANNEL_WRONGSIZE + 1, + D3D11_MESSAGE_ID_CONFIGUREAUTHENTICATEDCHANNEL_NULLPARAM + = D3D11_MESSAGE_ID_QUERYAUTHENTICATEDCHANNEL_INVALIDPROCESSINDEX + 1, + D3D11_MESSAGE_ID_CONFIGUREAUTHENTICATEDCHANNEL_WRONGCHANNEL + = D3D11_MESSAGE_ID_CONFIGUREAUTHENTICATEDCHANNEL_NULLPARAM + 1, + D3D11_MESSAGE_ID_CONFIGUREAUTHENTICATEDCHANNEL_UNSUPPORTEDCONFIGURE + = D3D11_MESSAGE_ID_CONFIGUREAUTHENTICATEDCHANNEL_WRONGCHANNEL + 1, + D3D11_MESSAGE_ID_CONFIGUREAUTHENTICATEDCHANNEL_WRONGSIZE + = D3D11_MESSAGE_ID_CONFIGUREAUTHENTICATEDCHANNEL_UNSUPPORTEDCONFIGURE + 1, + D3D11_MESSAGE_ID_CONFIGUREAUTHENTICATEDCHANNEL_INVALIDPROCESSIDTYPE + = D3D11_MESSAGE_ID_CONFIGUREAUTHENTICATEDCHANNEL_WRONGSIZE + 1, + D3D11_MESSAGE_ID_VSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + = D3D11_MESSAGE_ID_CONFIGUREAUTHENTICATEDCHANNEL_INVALIDPROCESSIDTYPE + 1, + D3D11_MESSAGE_ID_DSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + = D3D11_MESSAGE_ID_VSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + 1, + D3D11_MESSAGE_ID_HSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + = D3D11_MESSAGE_ID_DSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + 1, + D3D11_MESSAGE_ID_GSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + = D3D11_MESSAGE_ID_HSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + 1, + D3D11_MESSAGE_ID_PSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + = D3D11_MESSAGE_ID_GSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + 1, + D3D11_MESSAGE_ID_CSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + = D3D11_MESSAGE_ID_PSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + 1, + D3D11_MESSAGE_ID_NEGOTIATECRPYTOSESSIONKEYEXCHANGE_INVALIDSIZE + = D3D11_MESSAGE_ID_CSSETCONSTANTBUFFERS_INVALIDBUFFEROFFSETORCOUNT + 1, + D3D11_MESSAGE_ID_NEGOTIATEAUTHENTICATEDCHANNELKEYEXCHANGE_INVALIDSIZE + = D3D11_MESSAGE_ID_NEGOTIATECRPYTOSESSIONKEYEXCHANGE_INVALIDSIZE + 1, + D3D11_MESSAGE_ID_OFFERRESOURCES_INVALIDPRIORITY + = D3D11_MESSAGE_ID_NEGOTIATEAUTHENTICATEDCHANNELKEYEXCHANGE_INVALIDSIZE + 1, + D3D11_MESSAGE_ID_GETCRYPTOSESSIONHANDLE_OUTOFMEMORY + = D3D11_MESSAGE_ID_OFFERRESOURCES_INVALIDPRIORITY + 1, + D3D11_MESSAGE_ID_ACQUIREHANDLEFORCAPTURE_NULLPARAM + = D3D11_MESSAGE_ID_GETCRYPTOSESSIONHANDLE_OUTOFMEMORY + 1, + D3D11_MESSAGE_ID_ACQUIREHANDLEFORCAPTURE_INVALIDTYPE + = D3D11_MESSAGE_ID_ACQUIREHANDLEFORCAPTURE_NULLPARAM + 1, + D3D11_MESSAGE_ID_ACQUIREHANDLEFORCAPTURE_INVALIDBIND + = D3D11_MESSAGE_ID_ACQUIREHANDLEFORCAPTURE_INVALIDTYPE + 1, + D3D11_MESSAGE_ID_ACQUIREHANDLEFORCAPTURE_INVALIDARRAY + = D3D11_MESSAGE_ID_ACQUIREHANDLEFORCAPTURE_INVALIDBIND + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMROTATION_NULLPARAM + = D3D11_MESSAGE_ID_ACQUIREHANDLEFORCAPTURE_INVALIDARRAY + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMROTATION_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMROTATION_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMROTATION_INVALID + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMROTATION_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMROTATION_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMROTATION_INVALID + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMROTATION_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMROTATION_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDVIEW + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMROTATION_NULLPARAM + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEEXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDVIEW + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_SHADEREXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEEXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEEXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_SHADEREXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEHULLSHADER_SHADEREXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEEXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEEXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEHULLSHADER_SHADEREXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_SHADEREXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEEXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEEXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_SHADEREXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_SHADEREXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEEXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEEXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_SHADEREXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_SHADEREXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEEXTENSIONSNOTSUPPORTED + + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEEXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_SHADEREXTENSIONSNOTSUPPORTED + + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_SHADEREXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEEXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEEXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_SHADEREXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_SHADEREXTENSIONSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEEXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_MINPRECISION + = D3D11_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_SHADEREXTENSIONSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMALPHA_UNSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_MINPRECISION + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPIXELASPECTRATIO_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMALPHA_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_UAVSNOTSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMPIXELASPECTRATIO_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEHULLSHADER_UAVSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_UAVSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_UAVSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEHULLSHADER_UAVSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_UAVSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_UAVSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UAVSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_UAVSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_UAVSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UAVSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_UAVSNOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_UAVSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_INVALIDOFFSET + = D3D11_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_UAVSNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_TOOMANYVIEWS + = D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_INVALIDOFFSET + 1, + D3D11_MESSAGE_ID_DEVICE_CLEARVIEW_NOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_TOOMANYVIEWS + 1, + D3D11_MESSAGE_ID_SWAPDEVICECONTEXTSTATE_NOTSUPPORTED + = D3D11_MESSAGE_ID_DEVICE_CLEARVIEW_NOTSUPPORTED + 1, + D3D11_MESSAGE_ID_UPDATESUBRESOURCE_PREFERUPDATESUBRESOURCE1 + = D3D11_MESSAGE_ID_SWAPDEVICECONTEXTSTATE_NOTSUPPORTED + 1, + D3D11_MESSAGE_ID_GETDC_INACCESSIBLE + = D3D11_MESSAGE_ID_UPDATESUBRESOURCE_PREFERUPDATESUBRESOURCE1 + 1, + D3D11_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDRECT = D3D11_MESSAGE_ID_GETDC_INACCESSIBLE + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLE_MASK_IGNORED_ON_FL9 + = D3D11_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDRECT + 1, + D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE1_NOT_SUPPORTED + = D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLE_MASK_IGNORED_ON_FL9 + 1, + D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_BY_NAME_NOT_SUPPORTED + = D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE1_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_ENQUEUESETEVENT_NOT_SUPPORTED + = D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_BY_NAME_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_OFFERRELEASE_NOT_SUPPORTED + = D3D11_MESSAGE_ID_ENQUEUESETEVENT_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_OFFERRESOURCES_INACCESSIBLE = D3D11_MESSAGE_ID_OFFERRELEASE_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDMSAA + = D3D11_MESSAGE_ID_OFFERRESOURCES_INACCESSIBLE + 1, + D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDMSAA + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDMSAA + 1, + D3D11_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDSOURCERECT + = D3D11_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDMSAA + 1, + D3D11_MESSAGE_ID_DEVICE_CLEARVIEW_EMPTYRECT + = D3D11_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDSOURCERECT + 1, + D3D11_MESSAGE_ID_UPDATESUBRESOURCE_EMPTYDESTBOX + = D3D11_MESSAGE_ID_DEVICE_CLEARVIEW_EMPTYRECT + 1, + D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_EMPTYSOURCEBOX + = D3D11_MESSAGE_ID_UPDATESUBRESOURCE_EMPTYDESTBOX + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_OM_RENDER_TARGET_DOES_NOT_SUPPORT_LOGIC_OPS + = D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_EMPTYSOURCEBOX + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_DEPTHSTENCILVIEW_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_DRAW_OM_RENDER_TARGET_DOES_NOT_SUPPORT_LOGIC_OPS + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET + = D3D11_MESSAGE_ID_DEVICE_DRAW_DEPTHSTENCILVIEW_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET_DUE_TO_FLIP_PRESENT + = D3D11_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET + 1, + D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_NOT_SET_DUE_TO_FLIP_PRESENT + = D3D11_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET_DUE_TO_FLIP_PRESENT + 1, + D3D11_MESSAGE_ID_GETDATAFORNEWHARDWAREKEY_NULLPARAM + = D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_NOT_SET_DUE_TO_FLIP_PRESENT + 1, + D3D11_MESSAGE_ID_CHECKCRYPTOSESSIONSTATUS_NULLPARAM + = D3D11_MESSAGE_ID_GETDATAFORNEWHARDWAREKEY_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETCRYPTOSESSIONPRIVATEDATASIZE_NULLPARAM + = D3D11_MESSAGE_ID_CHECKCRYPTOSESSIONSTATUS_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERCAPS_NULLPARAM + = D3D11_MESSAGE_ID_GETCRYPTOSESSIONPRIVATEDATASIZE_NULLPARAM + 1, + D3D11_MESSAGE_ID_GETVIDEODECODERCAPS_ZEROWIDTHHEIGHT + = D3D11_MESSAGE_ID_GETVIDEODECODERCAPS_NULLPARAM + 1, + D3D11_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_NULLPARAM + = D3D11_MESSAGE_ID_GETVIDEODECODERCAPS_ZEROWIDTHHEIGHT + 1, + D3D11_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_INVALIDCOLORSPACE + = D3D11_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_NULLPARAM + 1, + D3D11_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_ZEROWIDTHHEIGHT + = D3D11_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_INVALIDCOLORSPACE + 1, + D3D11_MESSAGE_ID_VIDEODECODERENABLEDOWNSAMPLING_NULLPARAM + = D3D11_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_ZEROWIDTHHEIGHT + 1, + D3D11_MESSAGE_ID_VIDEODECODERENABLEDOWNSAMPLING_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEODECODERENABLEDOWNSAMPLING_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEODECODERUPDATEDOWNSAMPLING_NULLPARAM + = D3D11_MESSAGE_ID_VIDEODECODERENABLEDOWNSAMPLING_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEODECODERUPDATEDOWNSAMPLING_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEODECODERUPDATEDOWNSAMPLING_NULLPARAM + 1, + D3D11_MESSAGE_ID_CHECKVIDEOPROCESSORFORMATCONVERSION_NULLPARAM + = D3D11_MESSAGE_ID_VIDEODECODERUPDATEDOWNSAMPLING_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCOLORSPACE1_NULLPARAM + = D3D11_MESSAGE_ID_CHECKVIDEOPROCESSORFORMATCONVERSION_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTCOLORSPACE1_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCOLORSPACE1_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE1_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTCOLORSPACE1_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE1_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE1_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE1_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_UNSUPPORTED + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE1_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_UNSUPPORTED + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMMIRROR_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE1_NULLPARAM + 1, + D3D11_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMMIRROR_NULLPARAM + 1, + D3D11_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_INVALIDCOLORSPACE + = D3D11_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_NULLPARAM + 1, + D3D11_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_ZEROWIDTHHEIGHT + = D3D11_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_INVALIDCOLORSPACE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTSHADERUSAGE_NULLPARAM + = D3D11_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_ZEROWIDTHHEIGHT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTSHADERUSAGE_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTSHADERUSAGE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTSHADERUSAGE_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSTREAMCOUNT + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_TARGETRECT + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSTREAMCOUNT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSOURCERECT + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_TARGETRECT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDDESTRECT + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSOURCERECT + 1, + D3D11_MESSAGE_ID_GETCRYPTOSESSIONPRIVATEDATASIZE_INVALID_KEY_EXCHANGE_TYPE + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDDESTRECT + 1, + D3D11_MESSAGE_ID_D3D11_1_MESSAGES_END + = D3D11_MESSAGE_ID_GETCRYPTOSESSIONPRIVATEDATASIZE_INVALID_KEY_EXCHANGE_TYPE + 1, + D3D11_MESSAGE_ID_D3D11_2_MESSAGES_START = D3D11_MESSAGE_ID_D3D11_1_MESSAGES_END + 1, + D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDUSAGE = D3D11_MESSAGE_ID_D3D11_2_MESSAGES_START + 1, + D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDUSAGE = D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDUSAGE + 1, + D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDUSAGE + = D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDUSAGE + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_LEVEL9_STEPRATE_NOT_1 + = D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDUSAGE + 1, + D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_LEVEL9_INSTANCING_NOT_SUPPORTED + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_LEVEL9_STEPRATE_NOT_1 + 1, + D3D11_MESSAGE_ID_UPDATETILEMAPPINGS_INVALID_PARAMETER + = D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_LEVEL9_INSTANCING_NOT_SUPPORTED + 1, + D3D11_MESSAGE_ID_COPYTILEMAPPINGS_INVALID_PARAMETER + = D3D11_MESSAGE_ID_UPDATETILEMAPPINGS_INVALID_PARAMETER + 1, + D3D11_MESSAGE_ID_COPYTILES_INVALID_PARAMETER + = D3D11_MESSAGE_ID_COPYTILEMAPPINGS_INVALID_PARAMETER + 1, + D3D11_MESSAGE_ID_UPDATETILES_INVALID_PARAMETER + = D3D11_MESSAGE_ID_COPYTILES_INVALID_PARAMETER + 1, + D3D11_MESSAGE_ID_RESIZETILEPOOL_INVALID_PARAMETER + = D3D11_MESSAGE_ID_UPDATETILES_INVALID_PARAMETER + 1, + D3D11_MESSAGE_ID_TILEDRESOURCEBARRIER_INVALID_PARAMETER + = D3D11_MESSAGE_ID_RESIZETILEPOOL_INVALID_PARAMETER + 1, + D3D11_MESSAGE_ID_NULL_TILE_MAPPING_ACCESS_WARNING + = D3D11_MESSAGE_ID_TILEDRESOURCEBARRIER_INVALID_PARAMETER + 1, + D3D11_MESSAGE_ID_NULL_TILE_MAPPING_ACCESS_ERROR + = D3D11_MESSAGE_ID_NULL_TILE_MAPPING_ACCESS_WARNING + 1, + D3D11_MESSAGE_ID_DIRTY_TILE_MAPPING_ACCESS + = D3D11_MESSAGE_ID_NULL_TILE_MAPPING_ACCESS_ERROR + 1, + D3D11_MESSAGE_ID_DUPLICATE_TILE_MAPPINGS_IN_COVERED_AREA + = D3D11_MESSAGE_ID_DIRTY_TILE_MAPPING_ACCESS + 1, + D3D11_MESSAGE_ID_TILE_MAPPINGS_IN_COVERED_AREA_DUPLICATED_OUTSIDE + = D3D11_MESSAGE_ID_DUPLICATE_TILE_MAPPINGS_IN_COVERED_AREA + 1, + D3D11_MESSAGE_ID_TILE_MAPPINGS_SHARED_BETWEEN_INCOMPATIBLE_RESOURCES + = D3D11_MESSAGE_ID_TILE_MAPPINGS_IN_COVERED_AREA_DUPLICATED_OUTSIDE + 1, + D3D11_MESSAGE_ID_TILE_MAPPINGS_SHARED_BETWEEN_INPUT_AND_OUTPUT + = D3D11_MESSAGE_ID_TILE_MAPPINGS_SHARED_BETWEEN_INCOMPATIBLE_RESOURCES + 1, + D3D11_MESSAGE_ID_CHECKMULTISAMPLEQUALITYLEVELS_INVALIDFLAGS + = D3D11_MESSAGE_ID_TILE_MAPPINGS_SHARED_BETWEEN_INPUT_AND_OUTPUT + 1, + D3D11_MESSAGE_ID_GETRESOURCETILING_NONTILED_RESOURCE + = D3D11_MESSAGE_ID_CHECKMULTISAMPLEQUALITYLEVELS_INVALIDFLAGS + 1, + D3D11_MESSAGE_ID_RESIZETILEPOOL_SHRINK_WITH_MAPPINGS_STILL_DEFINED_PAST_END + = D3D11_MESSAGE_ID_GETRESOURCETILING_NONTILED_RESOURCE + 1, + D3D11_MESSAGE_ID_NEED_TO_CALL_TILEDRESOURCEBARRIER + = D3D11_MESSAGE_ID_RESIZETILEPOOL_SHRINK_WITH_MAPPINGS_STILL_DEFINED_PAST_END + 1, + D3D11_MESSAGE_ID_CREATEDEVICE_INVALIDARGS + = D3D11_MESSAGE_ID_NEED_TO_CALL_TILEDRESOURCEBARRIER + 1, + D3D11_MESSAGE_ID_CREATEDEVICE_WARNING = D3D11_MESSAGE_ID_CREATEDEVICE_INVALIDARGS + 1, + D3D11_MESSAGE_ID_CLEARUNORDEREDACCESSVIEWUINT_HAZARD + = D3D11_MESSAGE_ID_CREATEDEVICE_WARNING + 1, + D3D11_MESSAGE_ID_CLEARUNORDEREDACCESSVIEWFLOAT_HAZARD + = D3D11_MESSAGE_ID_CLEARUNORDEREDACCESSVIEWUINT_HAZARD + 1, + D3D11_MESSAGE_ID_TILED_RESOURCE_TIER_1_BUFFER_TEXTURE_MISMATCH + = D3D11_MESSAGE_ID_CLEARUNORDEREDACCESSVIEWFLOAT_HAZARD + 1, + D3D11_MESSAGE_ID_CREATE_CRYPTOSESSION + = D3D11_MESSAGE_ID_TILED_RESOURCE_TIER_1_BUFFER_TEXTURE_MISMATCH + 1, + D3D11_MESSAGE_ID_CREATE_AUTHENTICATEDCHANNEL = D3D11_MESSAGE_ID_CREATE_CRYPTOSESSION + 1, + D3D11_MESSAGE_ID_LIVE_CRYPTOSESSION = D3D11_MESSAGE_ID_CREATE_AUTHENTICATEDCHANNEL + 1, + D3D11_MESSAGE_ID_LIVE_AUTHENTICATEDCHANNEL = D3D11_MESSAGE_ID_LIVE_CRYPTOSESSION + 1, + D3D11_MESSAGE_ID_DESTROY_CRYPTOSESSION = D3D11_MESSAGE_ID_LIVE_AUTHENTICATEDCHANNEL + 1, + D3D11_MESSAGE_ID_DESTROY_AUTHENTICATEDCHANNEL = D3D11_MESSAGE_ID_DESTROY_CRYPTOSESSION + 1, + D3D11_MESSAGE_ID_D3D11_2_MESSAGES_END = D3D11_MESSAGE_ID_DESTROY_AUTHENTICATEDCHANNEL + 1, + D3D11_MESSAGE_ID_D3D11_3_MESSAGES_START = D3D11_MESSAGE_ID_D3D11_2_MESSAGES_END + 1, + D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALID_CONSERVATIVERASTERMODE + = D3D11_MESSAGE_ID_D3D11_3_MESSAGES_START + 1, + D3D11_MESSAGE_ID_DEVICE_DRAW_INVALID_SYSTEMVALUE + = D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALID_CONSERVATIVERASTERMODE + 1, + D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDCONTEXTTYPE + = D3D11_MESSAGE_ID_DEVICE_DRAW_INVALID_SYSTEMVALUE + 1, + D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_DECODENOTSUPPORTED + = D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDCONTEXTTYPE + 1, + D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_ENCODENOTSUPPORTED + = D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_DECODENOTSUPPORTED + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDPLANEINDEX + = D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_ENCODENOTSUPPORTED + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDVIDEOPLANEINDEX + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDPLANEINDEX + 1, + D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_AMBIGUOUSVIDEOPLANEINDEX + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDVIDEOPLANEINDEX + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDPLANEINDEX + = D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_AMBIGUOUSVIDEOPLANEINDEX + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDVIDEOPLANEINDEX + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDPLANEINDEX + 1, + D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_AMBIGUOUSVIDEOPLANEINDEX + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDVIDEOPLANEINDEX + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDPLANEINDEX + = D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_AMBIGUOUSVIDEOPLANEINDEX + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDVIDEOPLANEINDEX + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDPLANEINDEX + 1, + D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_AMBIGUOUSVIDEOPLANEINDEX + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDVIDEOPLANEINDEX + 1, + D3D11_MESSAGE_ID_JPEGDECODE_INVALIDSCANDATAOFFSET + = D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_AMBIGUOUSVIDEOPLANEINDEX + 1, + D3D11_MESSAGE_ID_JPEGDECODE_NOTSUPPORTED + = D3D11_MESSAGE_ID_JPEGDECODE_INVALIDSCANDATAOFFSET + 1, + D3D11_MESSAGE_ID_JPEGDECODE_DIMENSIONSTOOLARGE = D3D11_MESSAGE_ID_JPEGDECODE_NOTSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGDECODE_INVALIDCOMPONENTS + = D3D11_MESSAGE_ID_JPEGDECODE_DIMENSIONSTOOLARGE + 1, + D3D11_MESSAGE_ID_JPEGDECODE_DESTINATIONNOT2D + = D3D11_MESSAGE_ID_JPEGDECODE_INVALIDCOMPONENTS + 1, + D3D11_MESSAGE_ID_JPEGDECODE_TILEDRESOURCESUNSUPPORTED + = D3D11_MESSAGE_ID_JPEGDECODE_DESTINATIONNOT2D + 1, + D3D11_MESSAGE_ID_JPEGDECODE_GUARDRECTSUNSUPPORTED + = D3D11_MESSAGE_ID_JPEGDECODE_TILEDRESOURCESUNSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGDECODE_FORMATUNSUPPORTED + = D3D11_MESSAGE_ID_JPEGDECODE_GUARDRECTSUNSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGDECODE_INVALIDSUBRESOURCE + = D3D11_MESSAGE_ID_JPEGDECODE_FORMATUNSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGDECODE_INVALIDMIPLEVEL + = D3D11_MESSAGE_ID_JPEGDECODE_INVALIDSUBRESOURCE + 1, + D3D11_MESSAGE_ID_JPEGDECODE_EMPTYDESTBOX = D3D11_MESSAGE_ID_JPEGDECODE_INVALIDMIPLEVEL + 1, + D3D11_MESSAGE_ID_JPEGDECODE_DESTBOXNOT2D = D3D11_MESSAGE_ID_JPEGDECODE_EMPTYDESTBOX + 1, + D3D11_MESSAGE_ID_JPEGDECODE_DESTBOXNOTSUB = D3D11_MESSAGE_ID_JPEGDECODE_DESTBOXNOT2D + 1, + D3D11_MESSAGE_ID_JPEGDECODE_DESTBOXESINTERSECT = D3D11_MESSAGE_ID_JPEGDECODE_DESTBOXNOTSUB + 1, + D3D11_MESSAGE_ID_JPEGDECODE_XSUBSAMPLEMISMATCH + = D3D11_MESSAGE_ID_JPEGDECODE_DESTBOXESINTERSECT + 1, + D3D11_MESSAGE_ID_JPEGDECODE_YSUBSAMPLEMISMATCH + = D3D11_MESSAGE_ID_JPEGDECODE_XSUBSAMPLEMISMATCH + 1, + D3D11_MESSAGE_ID_JPEGDECODE_XSUBSAMPLEODD = D3D11_MESSAGE_ID_JPEGDECODE_YSUBSAMPLEMISMATCH + 1, + D3D11_MESSAGE_ID_JPEGDECODE_YSUBSAMPLEODD = D3D11_MESSAGE_ID_JPEGDECODE_XSUBSAMPLEODD + 1, + D3D11_MESSAGE_ID_JPEGDECODE_OUTPUTDIMENSIONSTOOLARGE + = D3D11_MESSAGE_ID_JPEGDECODE_YSUBSAMPLEODD + 1, + D3D11_MESSAGE_ID_JPEGDECODE_NONPOW2SCALEUNSUPPORTED + = D3D11_MESSAGE_ID_JPEGDECODE_OUTPUTDIMENSIONSTOOLARGE + 1, + D3D11_MESSAGE_ID_JPEGDECODE_FRACTIONALDOWNSCALETOLARGE + = D3D11_MESSAGE_ID_JPEGDECODE_NONPOW2SCALEUNSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGDECODE_CHROMASIZEMISMATCH + = D3D11_MESSAGE_ID_JPEGDECODE_FRACTIONALDOWNSCALETOLARGE + 1, + D3D11_MESSAGE_ID_JPEGDECODE_LUMACHROMASIZEMISMATCH + = D3D11_MESSAGE_ID_JPEGDECODE_CHROMASIZEMISMATCH + 1, + D3D11_MESSAGE_ID_JPEGDECODE_INVALIDNUMDESTINATIONS + = D3D11_MESSAGE_ID_JPEGDECODE_LUMACHROMASIZEMISMATCH + 1, + D3D11_MESSAGE_ID_JPEGDECODE_SUBBOXUNSUPPORTED + = D3D11_MESSAGE_ID_JPEGDECODE_INVALIDNUMDESTINATIONS + 1, + D3D11_MESSAGE_ID_JPEGDECODE_1DESTUNSUPPORTEDFORMAT + = D3D11_MESSAGE_ID_JPEGDECODE_SUBBOXUNSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGDECODE_3DESTUNSUPPORTEDFORMAT + = D3D11_MESSAGE_ID_JPEGDECODE_1DESTUNSUPPORTEDFORMAT + 1, + D3D11_MESSAGE_ID_JPEGDECODE_SCALEUNSUPPORTED + = D3D11_MESSAGE_ID_JPEGDECODE_3DESTUNSUPPORTEDFORMAT + 1, + D3D11_MESSAGE_ID_JPEGDECODE_INVALIDSOURCESIZE + = D3D11_MESSAGE_ID_JPEGDECODE_SCALEUNSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGDECODE_INVALIDCOPYFLAGS + = D3D11_MESSAGE_ID_JPEGDECODE_INVALIDSOURCESIZE + 1, + D3D11_MESSAGE_ID_JPEGDECODE_HAZARD = D3D11_MESSAGE_ID_JPEGDECODE_INVALIDCOPYFLAGS + 1, + D3D11_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDSRCBUFFERUSAGE = D3D11_MESSAGE_ID_JPEGDECODE_HAZARD + 1, + D3D11_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDSRCBUFFERMISCFLAGS + = D3D11_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDSRCBUFFERUSAGE + 1, + D3D11_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDDSTTEXTUREUSAGE + = D3D11_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDSRCBUFFERMISCFLAGS + 1, + D3D11_MESSAGE_ID_JPEGDECODE_BACKBUFFERNOTSUPPORTED + = D3D11_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDDSTTEXTUREUSAGE + 1, + D3D11_MESSAGE_ID_JPEGDECODE_UNSUPPRTEDCOPYFLAGS + = D3D11_MESSAGE_ID_JPEGDECODE_BACKBUFFERNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGENCODE_NOTSUPPORTED = D3D11_MESSAGE_ID_JPEGDECODE_UNSUPPRTEDCOPYFLAGS + 1, + D3D11_MESSAGE_ID_JPEGENCODE_INVALIDSCANDATAOFFSET + = D3D11_MESSAGE_ID_JPEGENCODE_NOTSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGENCODE_INVALIDCOMPONENTS + = D3D11_MESSAGE_ID_JPEGENCODE_INVALIDSCANDATAOFFSET + 1, + D3D11_MESSAGE_ID_JPEGENCODE_SOURCENOT2D = D3D11_MESSAGE_ID_JPEGENCODE_INVALIDCOMPONENTS + 1, + D3D11_MESSAGE_ID_JPEGENCODE_TILEDRESOURCESUNSUPPORTED + = D3D11_MESSAGE_ID_JPEGENCODE_SOURCENOT2D + 1, + D3D11_MESSAGE_ID_JPEGENCODE_GUARDRECTSUNSUPPORTED + = D3D11_MESSAGE_ID_JPEGENCODE_TILEDRESOURCESUNSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGENCODE_XSUBSAMPLEMISMATCH + = D3D11_MESSAGE_ID_JPEGENCODE_GUARDRECTSUNSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGENCODE_YSUBSAMPLEMISMATCH + = D3D11_MESSAGE_ID_JPEGENCODE_XSUBSAMPLEMISMATCH + 1, + D3D11_MESSAGE_ID_JPEGENCODE_FORMATUNSUPPORTED + = D3D11_MESSAGE_ID_JPEGENCODE_YSUBSAMPLEMISMATCH + 1, + D3D11_MESSAGE_ID_JPEGENCODE_INVALIDSUBRESOURCE + = D3D11_MESSAGE_ID_JPEGENCODE_FORMATUNSUPPORTED + 1, + D3D11_MESSAGE_ID_JPEGENCODE_INVALIDMIPLEVEL + = D3D11_MESSAGE_ID_JPEGENCODE_INVALIDSUBRESOURCE + 1, + D3D11_MESSAGE_ID_JPEGENCODE_DIMENSIONSTOOLARGE + = D3D11_MESSAGE_ID_JPEGENCODE_INVALIDMIPLEVEL + 1, + D3D11_MESSAGE_ID_JPEGENCODE_HAZARD = D3D11_MESSAGE_ID_JPEGENCODE_DIMENSIONSTOOLARGE + 1, + D3D11_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDDSTBUFFERUSAGE = D3D11_MESSAGE_ID_JPEGENCODE_HAZARD + 1, + D3D11_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDDSTBUFFERMISCFLAGS + = D3D11_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDDSTBUFFERUSAGE + 1, + D3D11_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDSRCTEXTUREUSAGE + = D3D11_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDDSTBUFFERMISCFLAGS + 1, + D3D11_MESSAGE_ID_JPEGENCODE_BACKBUFFERNOTSUPPORTED + = D3D11_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDSRCTEXTUREUSAGE + 1, + D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_UNSUPPORTEDCONTEXTTTYPEFORQUERY + = D3D11_MESSAGE_ID_JPEGENCODE_BACKBUFFERNOTSUPPORTED + 1, + D3D11_MESSAGE_ID_FLUSH1_INVALIDCONTEXTTYPE + = D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_UNSUPPORTEDCONTEXTTTYPEFORQUERY + 1, + D3D11_MESSAGE_ID_DEVICE_SETHARDWAREPROTECTION_INVALIDCONTEXT + = D3D11_MESSAGE_ID_FLUSH1_INVALIDCONTEXTTYPE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTHDRMETADATA_NULLPARAM + = D3D11_MESSAGE_ID_DEVICE_SETHARDWAREPROTECTION_INVALIDCONTEXT + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTHDRMETADATA_INVALIDSIZE + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTHDRMETADATA_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTHDRMETADATA_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTHDRMETADATA_INVALIDSIZE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTHDRMETADATA_INVALIDSIZE + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTHDRMETADATA_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTHDRMETADATA_INVALIDSIZE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_INVALIDSIZE + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_NULLPARAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_INVALIDSIZE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_NULLPARAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_INVALIDSIZE + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFRAMEFORMAT_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_INVALIDSIZE + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFRAMEFORMAT_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMOUTPUTRATE_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSOURCERECT_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMOUTPUTRATE_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMDESTRECT_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSOURCERECT_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMALPHA_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMDESTRECT_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPALETTE_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMALPHA_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPIXELASPECTRATIO_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPALETTE_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMLUMAKEY_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPIXELASPECTRATIO_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSTEREOFORMAT_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMLUMAKEY_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMAUTOPROCESSINGMODE_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSTEREOFORMAT_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFILTER_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMAUTOPROCESSINGMODE_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMROTATION_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFILTER_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE1_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMROTATION_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMMIRROR_INVALIDSTREAM + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE1_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_CREATE_FENCE + = D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMMIRROR_INVALIDSTREAM + 1, + D3D11_MESSAGE_ID_LIVE_FENCE = D3D11_MESSAGE_ID_CREATE_FENCE + 1, + D3D11_MESSAGE_ID_DESTROY_FENCE = D3D11_MESSAGE_ID_LIVE_FENCE + 1, + D3D11_MESSAGE_ID_D3D11_3_MESSAGES_END = D3D11_MESSAGE_ID_DESTROY_FENCE + 1, +}} +STRUCT!{struct D3D11_MESSAGE { + Category: D3D11_MESSAGE_CATEGORY, + Severity: D3D11_MESSAGE_SEVERITY, + ID: D3D11_MESSAGE_ID, + pDescription: *const c_char, + DescriptionByteLength: SIZE_T, +}} +STRUCT!{struct D3D11_INFO_QUEUE_FILTER_DESC { + NumCategories: UINT, + pCategoryList: *const D3D11_MESSAGE_CATEGORY, + NumSeverities: UINT, + pSeverityList: *const D3D11_MESSAGE_SEVERITY, + NumIDs: UINT, + pIDList: *const D3D11_MESSAGE_ID, +}} +STRUCT!{struct D3D11_INFO_QUEUE_FILTER { + AllowList: D3D11_INFO_QUEUE_FILTER_DESC, + DenyList: D3D11_INFO_QUEUE_FILTER_DESC, +}} +pub const D3D11_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT: UINT64 = 1024; +RIDL!{#[uuid(0x6543dbb6, 0x1b48, 0x42f5, 0xab, 0x82, 0xe9, 0x7e, 0xc7, 0x43, 0x26, 0xf6)] +interface ID3D11InfoQueue(ID3D11InfoQueueVtbl): IUnknown(IUnknownVtbl) { + fn SetMessageCountLimit( + MessageCountLimit: UINT64, + ) -> HRESULT, + fn ClearStoredMessages() -> (), + fn GetMessage( + MessageIndex: UINT64, + pMessage: *mut D3D11_MESSAGE, + pMessageByteLength: *mut SIZE_T, + ) -> HRESULT, + fn GetNumMessagesAllowedByStorageFilter() -> UINT64, + fn GetNumMessagesDeniedByStorageFilter() -> UINT64, + fn GetNumStoredMessages() -> UINT64, + fn GetNumStoredMessagesAllowedByRetrievalFilter() -> UINT64, + fn GetNumMessagesDiscardedByMessageCountLimit() -> UINT64, + fn GetMessageCountLimit() -> UINT64, + fn AddStorageFilterEntries( + pFilter: *const D3D11_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn GetStorageFilter( + pFilter: *mut D3D11_INFO_QUEUE_FILTER, + pFilterByteLength: *mut SIZE_T, + ) -> HRESULT, + fn ClearStorageFilter() -> (), + fn PushEmptyStorageFilter() -> HRESULT, + fn PushCopyOfStorageFilter() -> HRESULT, + fn PushStorageFilter( + pFilter: *const D3D11_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn PopStorageFilter() -> (), + fn GetStorageFilterStackSize() -> UINT, + fn AddRetrievalFilterEntries( + pFilter: *const D3D11_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn GetRetrievalFilter( + pFilter: *mut D3D11_INFO_QUEUE_FILTER, + pFilterByteLength: *mut SIZE_T, + ) -> HRESULT, + fn ClearRetrievalFilter() -> (), + fn PushEmptyRetrievalFilter() -> HRESULT, + fn PushCopyOfRetrievalFilter() -> HRESULT, + fn PushRetrievalFilter( + pFilter: *const D3D11_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn PopRetrievalFilter() -> (), + fn GetRetrievalFilterStackSize() -> UINT, + fn AddMessage( + Category: D3D11_MESSAGE_CATEGORY, + Severity: D3D11_MESSAGE_SEVERITY, + ID: D3D11_MESSAGE_ID, + pDescription: LPCSTR, + ) -> HRESULT, + fn AddApplicationMessage( + Severity: D3D11_MESSAGE_SEVERITY, + pDescription: LPCSTR, + ) -> HRESULT, + fn SetBreakOnCategory( + Category: D3D11_MESSAGE_CATEGORY, + bEnable: BOOL, + ) -> HRESULT, + fn SetBreakOnSeverity( + ID: D3D11_MESSAGE_ID, + bEnable: BOOL, + ) -> HRESULT, + fn SetBreakOnID( + Severity: D3D11_MESSAGE_SEVERITY, + bEnable: BOOL, + ) -> HRESULT, + fn GetBreakOnCategory( + Category: D3D11_MESSAGE_CATEGORY, + ) -> BOOL, + fn GetBreakOnSeverity( + Severity: D3D11_MESSAGE_SEVERITY, + ) -> BOOL, + fn GetBreakOnID( + ID: D3D11_MESSAGE_ID, + ) -> BOOL, + fn SetMuteDebugOutput( + bMute: BOOL, + ) -> (), + fn GetMuteDebugOutput() -> BOOL, +}} +DEFINE_GUID!{IID_ID3D11Debug, + 0x79cf2233, 0x7536, 0x4948, 0x9d, 0x36, 0x1e, 0x46, 0x92, 0xdc, 0x57, 0x60} +DEFINE_GUID!{IID_ID3D11SwitchToRef, + 0x1ef337e3, 0x58e7, 0x4f83, 0xa6, 0x92, 0xdb, 0x22, 0x1f, 0x5e, 0xd4, 0x7e} +DEFINE_GUID!{IID_ID3D11TracingDevice, + 0x1911c771, 0x1587, 0x413e, 0xa7, 0xe0, 0xfb, 0x26, 0xc3, 0xde, 0x02, 0x68} +DEFINE_GUID!{IID_ID3D11RefTrackingOptions, + 0x193dacdf, 0x0db2, 0x4c05, 0xa5, 0x5c, 0xef, 0x06, 0xca, 0xc5, 0x6f, 0xd9} +DEFINE_GUID!{IID_ID3D11RefDefaultTrackingOptions, + 0x03916615, 0xc644, 0x418c, 0x9b, 0xf4, 0x75, 0xdb, 0x5b, 0xe6, 0x3c, 0xa0} +DEFINE_GUID!{IID_ID3D11InfoQueue, + 0x6543dbb6, 0x1b48, 0x42f5, 0xab, 0x82, 0xe9, 0x7e, 0xc7, 0x43, 0x26, 0xf6} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11shader.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11shader.rs new file mode 100644 index 0000000..ebe06b4 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11shader.rs @@ -0,0 +1,477 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_int; +use shared::basetsd::UINT64; +use shared::minwindef::{BOOL, BYTE, INT, LPVOID, UINT}; +use um::d3dcommon::{ + D3D_CBUFFER_TYPE, D3D_FEATURE_LEVEL, D3D_INTERPOLATION_MODE, D3D_MIN_PRECISION, D3D_NAME, + D3D_PARAMETER_FLAGS, D3D_PRIMITIVE, D3D_PRIMITIVE_TOPOLOGY, D3D_REGISTER_COMPONENT_TYPE, + D3D_RESOURCE_RETURN_TYPE, D3D_SHADER_INPUT_TYPE, D3D_SHADER_VARIABLE_CLASS, + D3D_SHADER_VARIABLE_TYPE, D3D_SRV_DIMENSION, D3D_TESSELLATOR_DOMAIN, + D3D_TESSELLATOR_OUTPUT_PRIMITIVE, D3D_TESSELLATOR_PARTITIONING, ID3DBlob, +}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCSTR}; +ENUM!{enum D3D11_SHADER_VERSION_TYPE { + D3D11_SHVER_PIXEL_SHADER = 0, + D3D11_SHVER_VERTEX_SHADER = 1, + D3D11_SHVER_GEOMETRY_SHADER = 2, + D3D11_SHVER_HULL_SHADER = 3, + D3D11_SHVER_DOMAIN_SHADER = 4, + D3D11_SHVER_COMPUTE_SHADER = 5, + D3D11_SHVER_RESERVED0 = 0xFFF0, +}} +pub const D3D_RETURN_PARAMETER_INDEX: c_int = -1; +pub type D3D11_RESOURCE_RETURN_TYPE = D3D_RESOURCE_RETURN_TYPE; +pub type D3D11_CBUFFER_TYPE = D3D_CBUFFER_TYPE; +STRUCT!{struct D3D11_SIGNATURE_PARAMETER_DESC { + SemanticName: LPCSTR, + SemanticIndex: UINT, + Register: UINT, + SystemValueType: D3D_NAME, + ComponentType: D3D_REGISTER_COMPONENT_TYPE, + Mask: BYTE, + ReadWriteMask: BYTE, + Stream: UINT, + MinPrecision: D3D_MIN_PRECISION, +}} +STRUCT!{struct D3D11_SHADER_BUFFER_DESC { + Name: LPCSTR, + Type: D3D_CBUFFER_TYPE, + Variables: UINT, + Size: UINT, + uFlags: UINT, +}} +STRUCT!{struct D3D11_SHADER_VARIABLE_DESC { + Name: LPCSTR, + StartOffset: UINT, + Size: UINT, + uFlags: UINT, + DefaultValue: LPVOID, + StartTexture: UINT, + TextureSize: UINT, + StartSampler: UINT, + SamplerSize: UINT, +}} +STRUCT!{struct D3D11_SHADER_TYPE_DESC { + Class: D3D_SHADER_VARIABLE_CLASS, + Type: D3D_SHADER_VARIABLE_TYPE, + Rows: UINT, + Columns: UINT, + Elements: UINT, + Members: UINT, + Offset: UINT, + Name: LPCSTR, +}} +pub type D3D11_TESSELLATOR_DOMAIN = D3D_TESSELLATOR_DOMAIN; +pub type D3D11_TESSELLATOR_PARTITIONING = D3D_TESSELLATOR_PARTITIONING; +pub type D3D11_TESSELLATOR_OUTPUT_PRIMITIVE = D3D_TESSELLATOR_OUTPUT_PRIMITIVE; +STRUCT!{struct D3D11_SHADER_DESC { + Version: UINT, + Creator: LPCSTR, + Flags: UINT, + ConstantBuffers: UINT, + BoundResources: UINT, + InputParameters: UINT, + OutputParameters: UINT, + InstructionCount: UINT, + TempRegisterCount: UINT, + TempArrayCount: UINT, + DefCount: UINT, + DclCount: UINT, + TextureNormalInstructions: UINT, + TextureLoadInstructions: UINT, + TextureCompInstructions: UINT, + TextureBiasInstructions: UINT, + TextureGradientInstructions: UINT, + FloatInstructionCount: UINT, + IntInstructionCount: UINT, + UintInstructionCount: UINT, + StaticFlowControlCount: UINT, + DynamicFlowControlCount: UINT, + MacroInstructionCount: UINT, + ArrayInstructionCount: UINT, + CutInstructionCount: UINT, + EmitInstructionCount: UINT, + GSOutputTopology: D3D_PRIMITIVE_TOPOLOGY, + GSMaxOutputVertexCount: UINT, + InputPrimitive: D3D_PRIMITIVE, + PatchConstantParameters: UINT, + cGSInstanceCount: UINT, + cControlPoints: UINT, + HSOutputPrimitive: D3D_TESSELLATOR_OUTPUT_PRIMITIVE, + HSPartitioning: D3D_TESSELLATOR_PARTITIONING, + TessellatorDomain: D3D_TESSELLATOR_DOMAIN, + cBarrierInstructions: UINT, + cInterlockedInstructions: UINT, + cTextureStoreInstructions: UINT, +}} +STRUCT!{struct D3D11_SHADER_INPUT_BIND_DESC { + Name: LPCSTR, + Type: D3D_SHADER_INPUT_TYPE, + BindPoint: UINT, + BindCount: UINT, + uFlags: UINT, + ReturnType: D3D_RESOURCE_RETURN_TYPE, + Dimension: D3D_SRV_DIMENSION, + NumSamples: UINT, +}} +pub const D3D_SHADER_REQUIRES_DOUBLES: UINT64 = 0x00000001; +pub const D3D_SHADER_REQUIRES_EARLY_DEPTH_STENCIL: UINT64 = 0x00000002; +pub const D3D_SHADER_REQUIRES_UAVS_AT_EVERY_STAGE: UINT64 = 0x00000004; +pub const D3D_SHADER_REQUIRES_64_UAVS: UINT64 = 0x00000008; +pub const D3D_SHADER_REQUIRES_MINIMUM_PRECISION: UINT64 = 0x00000010; +pub const D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS: UINT64 = 0x00000020; +pub const D3D_SHADER_REQUIRES_11_1_SHADER_EXTENSIONS: UINT64 = 0x00000040; +pub const D3D_SHADER_REQUIRES_LEVEL_9_COMPARISON_FILTERING: UINT64 = 0x00000080; +pub const D3D_SHADER_REQUIRES_TILED_RESOURCES: UINT64 = 0x00000100; +STRUCT!{struct D3D11_LIBRARY_DESC { + Creator: LPCSTR, + Flags: UINT, + FunctionCount: UINT, +}} +STRUCT!{struct D3D11_FUNCTION_DESC { + Version: UINT, + Creator: LPCSTR, + Flags: UINT, + ConstantBuffers: UINT, + BoundResources: UINT, + InstructionCount: UINT, + TempRegisterCount: UINT, + TempArrayCount: UINT, + DefCount: UINT, + DclCount: UINT, + TextureNormalInstructions: UINT, + TextureLoadInstructions: UINT, + TextureCompInstructions: UINT, + TextureBiasInstructions: UINT, + TextureGradientInstructions: UINT, + FloatInstructionCount: UINT, + IntInstructionCount: UINT, + UintInstructionCount: UINT, + StaticFlowControlCount: UINT, + DynamicFlowControlCount: UINT, + MacroInstructionCount: UINT, + ArrayInstructionCount: UINT, + MovInstructionCount: UINT, + MovcInstructionCount: UINT, + ConversionInstructionCount: UINT, + BitwiseInstructionCount: UINT, + MinFeatureLevel: D3D_FEATURE_LEVEL, + RequiredFeatureFlags: UINT64, + Name: LPCSTR, + FunctionParameterCount: INT, + HasReturn: BOOL, + Has10Level9VertexShader: BOOL, + Has10Level9PixelShader: BOOL, +}} +STRUCT!{struct D3D11_PARAMETER_DESC { + Name: LPCSTR, + SemanticName: LPCSTR, + Type: D3D_SHADER_VARIABLE_TYPE, + Class: D3D_SHADER_VARIABLE_CLASS, + Rows: UINT, + Columns: UINT, + InterpolationMode: D3D_INTERPOLATION_MODE, + Flags: D3D_PARAMETER_FLAGS, + FirstInRegister: UINT, + FirstInComponent: UINT, + FirstOutRegister: UINT, + FirstOutComponent: UINT, +}} +DEFINE_GUID!{IID_ID3D11ShaderReflectionType, + 0x6e6ffa6a, 0x9bae, 0x4613, 0xa5, 0x1e, 0x91, 0x65, 0x2d, 0x50, 0x8c, 0x21} +RIDL!{#[uuid(0x6e6ffa6a, 0x9bae, 0x4613, 0xa5, 0x1e, 0x91, 0x65, 0x2d, 0x50, 0x8c, 0x21)] +interface ID3D11ShaderReflectionType(ID3D11ShaderReflectionTypeVtbl) { + fn GetDesc( + pDesc: *mut D3D11_SHADER_TYPE_DESC, + ) -> HRESULT, + fn GetMemberTypeByIndex( + Index: UINT, + ) -> *mut ID3D11ShaderReflectionType, + fn GetMemberTypeByName( + Name: LPCSTR, + ) -> *mut ID3D11ShaderReflectionType, + fn GetMemberTypeName( + Index: UINT, + ) -> LPCSTR, + fn IsEqual( + pType: *mut ID3D11ShaderReflectionType, + ) -> HRESULT, + fn GetSubType() -> *mut ID3D11ShaderReflectionType, + fn GetBaseClass() -> *mut ID3D11ShaderReflectionType, + fn GetNumInterfaces() -> UINT, + fn GetInterfaceByIndex( + uIndex: UINT, + ) -> *mut ID3D11ShaderReflectionType, + fn IsOfType( + pType: *mut ID3D11ShaderReflectionType, + ) -> HRESULT, + fn ImplementsInterface( + pBase: *mut ID3D11ShaderReflectionType, + ) -> HRESULT, +}} +DEFINE_GUID!{IID_ID3D11ShaderReflectionVariable, + 0x51f23923, 0xf3e5, 0x4bd1, 0x91, 0xcb, 0x60, 0x61, 0x77, 0xd8, 0xdb, 0x4c} +RIDL!{#[uuid(0x51f23923, 0xf3e5, 0x4bd1, 0x91, 0xcb, 0x60, 0x61, 0x77, 0xd8, 0xdb, 0x4c)] +interface ID3D11ShaderReflectionVariable(ID3D11ShaderReflectionVariableVtbl) { + fn GetDesc( + pDesc: *mut D3D11_SHADER_VARIABLE_DESC, + ) -> HRESULT, + fn GetType() -> *mut ID3D11ShaderReflectionType, + fn GetBuffer() -> *mut ID3D11ShaderReflectionConstantBuffer, + fn GetInterfaceSlot( + uArrayIndex: UINT, + ) -> UINT, +}} +DEFINE_GUID!{IID_ID3D11ShaderReflectionConstantBuffer, + 0xeb62d63d, 0x93dd, 0x4318, 0x8a, 0xe8, 0xc6, 0xf8, 0x3a, 0xd3, 0x71, 0xb8} +RIDL!{#[uuid(0xeb62d63d, 0x93dd, 0x4318, 0x8a, 0xe8, 0xc6, 0xf8, 0x3a, 0xd3, 0x71, 0xb8)] +interface ID3D11ShaderReflectionConstantBuffer(ID3D11ShaderReflectionConstantBufferVtbl) { + fn GetDesc( + pDesc: *mut D3D11_SHADER_BUFFER_DESC, + ) -> HRESULT, + fn GetVariableByIndex( + Index: UINT, + ) -> *mut ID3D11ShaderReflectionVariable, + fn GetVariableByName( + Name: LPCSTR, + ) -> *mut ID3D11ShaderReflectionVariable, +}} +DEFINE_GUID!{IID_ID3D11ShaderReflection, + 0x8d536ca1, 0x0cca, 0x4956, 0xa8, 0x37, 0x78, 0x69, 0x63, 0x75, 0x55, 0x84} +RIDL!{#[uuid(0x8d536ca1, 0x0cca, 0x4956, 0xa8, 0x37, 0x78, 0x69, 0x63, 0x75, 0x55, 0x84)] +interface ID3D11ShaderReflection(ID3D11ShaderReflectionVtbl): IUnknown(IUnknownVtbl) { + fn GetDesc( + pDesc: *mut D3D11_SHADER_DESC, + ) -> HRESULT, + fn GetConstantBufferByIndex( + Index: UINT, + ) -> *mut ID3D11ShaderReflectionConstantBuffer, + fn GetConstantBufferByName( + Name: LPCSTR, + ) -> *mut ID3D11ShaderReflectionConstantBuffer, + fn GetResourceBindingDesc( + ResourceIndex: UINT, + pDesc: *mut D3D11_SHADER_INPUT_BIND_DESC, + ) -> HRESULT, + fn GetInputParameterDesc( + ParameterIndex: UINT, + pDesc: *mut D3D11_SIGNATURE_PARAMETER_DESC, + ) -> HRESULT, + fn GetOutputParameterDesc( + ParameterIndex: UINT, + pDesc: *mut D3D11_SIGNATURE_PARAMETER_DESC, + ) -> HRESULT, + fn GetPatchConstantParameterDesc( + ParameterIndex: UINT, + pDesc: *mut D3D11_SIGNATURE_PARAMETER_DESC, + ) -> HRESULT, + fn GetVariableByName( + Name: LPCSTR, + ) -> *mut ID3D11ShaderReflectionVariable, + fn GetResourceBindingDescByName( + Name: LPCSTR, + pDesc: *mut D3D11_SHADER_INPUT_BIND_DESC, + ) -> HRESULT, + fn GetMovInstructionCount() -> UINT, + fn GetMovcInstructionCount() -> UINT, + fn GetConversionInstructionCount() -> UINT, + fn GetBitwiseInstructionCount() -> UINT, + fn GetGSInputPrimitive() -> D3D_PRIMITIVE, + fn IsSampleFrequencyShader() -> BOOL, + fn GetNumInterfaceSlots() -> UINT, + fn GetMinFeatureLevel( + pLevel: *mut D3D_FEATURE_LEVEL, + ) -> HRESULT, + fn GetThreadGroupSize( + pSizeX: *mut UINT, + pSizeY: *mut UINT, + pSizeZ: *mut UINT, + ) -> UINT, + fn GetRequiresFlags() -> UINT64, +}} +DEFINE_GUID!{IID_ID3D11LibraryReflection, + 0x54384f1b, 0x5b3e, 0x4bb7, 0xae, 0x01, 0x60, 0xba, 0x30, 0x97, 0xcb, 0xb6} +RIDL!{#[uuid(0x54384f1b, 0x5b3e, 0x4bb7, 0xae, 0x01, 0x60, 0xba, 0x30, 0x97, 0xcb, 0xb6)] +interface ID3D11LibraryReflection(ID3D11LibraryReflectionVtbl): IUnknown(IUnknownVtbl) { + fn GetDesc( + pDesc: *mut D3D11_LIBRARY_DESC, + ) -> HRESULT, + fn GetFunctionByIndex( + FunctionIndex: INT, + ) -> *mut ID3D11FunctionReflection, +}} +DEFINE_GUID!{IID_ID3D11FunctionReflection, + 0x207bcecb, 0xd683, 0x4a06, 0xa8, 0xa3, 0x9b, 0x14, 0x9b, 0x9f, 0x73, 0xa4} +RIDL!{#[uuid(0x207bcecb, 0xd683, 0x4a06, 0xa8, 0xa3, 0x9b, 0x14, 0x9b, 0x9f, 0x73, 0xa4)] +interface ID3D11FunctionReflection(ID3D11FunctionReflectionVtbl) { + fn GetDesc( + pDesc: *mut D3D11_FUNCTION_DESC, + ) -> HRESULT, + fn GetConstantBufferByIndex( + BufferIndex: UINT, + ) -> *mut ID3D11ShaderReflectionConstantBuffer, + fn GetConstantBufferByName( + Name: LPCSTR, + ) -> *mut ID3D11ShaderReflectionConstantBuffer, + fn GetResourceBindingDesc( + ResourceIndex: UINT, + pDesc: *mut D3D11_SHADER_INPUT_BIND_DESC, + ) -> HRESULT, + fn GetVariableByName( + Name: LPCSTR, + ) -> *mut ID3D11ShaderReflectionVariable, + fn GetResourceBindingDescByName( + Name: LPCSTR, + pDesc: *mut D3D11_SHADER_INPUT_BIND_DESC, + ) -> HRESULT, + fn GetFunctionParameter( + ParameterIndex: INT, + ) -> *mut ID3D11FunctionParameterReflection, +}} +DEFINE_GUID!{IID_ID3D11FunctionParameterReflection, + 0x42757488, 0x334f, 0x47fe, 0x98, 0x2e, 0x1a, 0x65, 0xd0, 0x8c, 0xc4, 0x62} +RIDL!{#[uuid(0x42757488, 0x334f, 0x47fe, 0x98, 0x2e, 0x1a, 0x65, 0xd0, 0x8c, 0xc4, 0x62)] +interface ID3D11FunctionParameterReflection(ID3D11FunctionParameterReflectionVtbl) { + fn GetDesc( + pDesc: *mut D3D11_PARAMETER_DESC, + ) -> HRESULT, +}} +DEFINE_GUID!{IID_ID3D11Module, + 0xcac701ee, 0x80fc, 0x4122, 0x82, 0x42, 0x10, 0xb3, 0x9c, 0x8c, 0xec, 0x34} +RIDL!{#[uuid(0xcac701ee, 0x80fc, 0x4122, 0x82, 0x42, 0x10, 0xb3, 0x9c, 0x8c, 0xec, 0x34)] +interface ID3D11Module(ID3D11ModuleVtbl): IUnknown(IUnknownVtbl) { + fn CreateInstance( + pNamespace: LPCSTR, + ppModuleInstance: *mut *mut ID3D11ModuleInstance, + ) -> HRESULT, +}} +DEFINE_GUID!{IID_ID3D11ModuleInstance, + 0x469e07f7, 0x045a, 0x48d5, 0xaa, 0x12, 0x68, 0xa4, 0x78, 0xcd, 0xf7, 0x5d} +RIDL!{#[uuid(0x469e07f7, 0x045a, 0x48d5, 0xaa, 0x12, 0x68, 0xa4, 0x78, 0xcd, 0xf7, 0x5d)] +interface ID3D11ModuleInstance(ID3D11ModuleInstanceVtbl): IUnknown(IUnknownVtbl) { + fn BindConstantBuffer( + uSrcSlot: UINT, + uDstSlot: UINT, + cbDstOffset: UINT, + ) -> HRESULT, + fn BindConstantBufferByName( + pName: LPCSTR, + uDstSlot: UINT, + cbDstOffset: UINT, + ) -> HRESULT, + fn BindResource( + uSrcSlot: UINT, + uDstSlot: UINT, + uCount: UINT, + ) -> HRESULT, + fn BindResourceByName( + pName: LPCSTR, + uDstSlot: UINT, + uCount: UINT, + ) -> HRESULT, + fn BindSampler( + uSrcSlot: UINT, + uDstSlot: UINT, + uCount: UINT, + ) -> HRESULT, + fn BindSamplerByName( + pName: LPCSTR, + uDstSlot: UINT, + uCount: UINT, + ) -> HRESULT, + fn BindUnorderedAccessView( + uSrcSlot: UINT, + uDstSlot: UINT, + uCount: UINT, + ) -> HRESULT, + fn BindUnorderedAccessViewByName( + pName: LPCSTR, + uDstSlot: UINT, + uCount: UINT, + ) -> HRESULT, + fn BindResourceAsUnorderedAccessView( + uSrcSrvSlot: UINT, + uDstUavSlot: UINT, + uCount: UINT, + ) -> HRESULT, + fn BindResourceAsUnorderedAccessViewByName( + pSrvName: LPCSTR, + uDstUavSlot: UINT, + uCount: UINT, + ) -> HRESULT, +}} +DEFINE_GUID!{IID_ID3D11Linker, + 0x59a6cd0e, 0xe10d, 0x4c1f, 0x88, 0xc0, 0x63, 0xab, 0xa1, 0xda, 0xf3, 0x0e} +RIDL!{#[uuid(0x59a6cd0e, 0xe10d, 0x4c1f, 0x88, 0xc0, 0x63, 0xab, 0xa1, 0xda, 0xf3, 0x0e)] +interface ID3D11Linker(ID3D11LinkerVtbl): IUnknown(IUnknownVtbl) { + fn Link( + pEntry: *mut ID3D11ModuleInstance, + pEntryName: LPCSTR, + pTargetName: LPCSTR, + uFlags: UINT, + ppShaderBlob: *mut *mut ID3DBlob, + ppErrorBuffer: *mut *mut ID3DBlob, + ) -> HRESULT, + fn UseLibrary( + pLibraryMI: *mut ID3D11ModuleInstance, + ) -> HRESULT, + fn AddClipPlaneFromCBuffer( + uCBufferSlot: UINT, + uCBufferEntry: UINT, + ) -> HRESULT, +}} +DEFINE_GUID!{IID_ID3D11LinkingNode, + 0xd80dd70c, 0x8d2f, 0x4751, 0x94, 0xa1, 0x03, 0xc7, 0x9b, 0x35, 0x56, 0xdb} +RIDL!{#[uuid(0xd80dd70c, 0x8d2f, 0x4751, 0x94, 0xa1, 0x03, 0xc7, 0x9b, 0x35, 0x56, 0xdb)] +interface ID3D11LinkingNode(ID3D11LinkingNodeVtbl): IUnknown(IUnknownVtbl) {}} +DEFINE_GUID!{IID_ID3D11FunctionLinkingGraph, + 0x54133220, 0x1ce8, 0x43d3, 0x82, 0x36, 0x98, 0x55, 0xc5, 0xce, 0xec, 0xff} +RIDL!{#[uuid(0x54133220, 0x1ce8, 0x43d3, 0x82, 0x36, 0x98, 0x55, 0xc5, 0xce, 0xec, 0xff)] +interface ID3D11FunctionLinkingGraph(ID3D11FunctionLinkingGraphVtbl): IUnknown(IUnknownVtbl) { + fn CreateModuleInstance( + ppModuleInstance: *mut *mut ID3D11ModuleInstance, + ppErrorBuffer: *mut *mut ID3DBlob, + ) -> HRESULT, + fn SetInputSignature( + pInputParameters: *const D3D11_PARAMETER_DESC, + cInputParameters: UINT, + ppInputNode: *mut *mut ID3D11LinkingNode, + ) -> HRESULT, + fn SetOutputSignature( + pOutputParameters: *const D3D11_PARAMETER_DESC, + cOutputParameters: UINT, + ppOutputNode: *mut *mut ID3D11LinkingNode, + ) -> HRESULT, + fn CallFunction( + pModuleInstanceNamespace: LPCSTR, + pModuleWithFunctionPrototype: *mut ID3D11Module, + pFunctionName: LPCSTR, + ppCallNode: *mut *mut ID3D11LinkingNode, + ) -> HRESULT, + fn PassValue( + pSrcNode: *mut ID3D11LinkingNode, + SrcParameterIndex: INT, + pDstNode: *mut ID3D11LinkingNode, + DstParameterIndex: INT, + ) -> HRESULT, + fn PassValueWithSwizzle( + pSrcNode: *mut ID3D11LinkingNode, + SrcParameterIndex: INT, + pSrcSwizzle: LPCSTR, + pDstNode: *mut ID3D11LinkingNode, + DstParameterIndex: INT, + pDstSwizzle: LPCSTR, + ) -> HRESULT, + fn GetLastError( + ppErrorBuffer: *mut *mut ID3DBlob, + ) -> HRESULT, + fn GenerateHlsl( + uFlags: UINT, + ppBuffer: *mut *mut ID3DBlob, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11tokenizedprogramformat.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11tokenizedprogramformat.rs new file mode 100644 index 0000000..e819262 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d11tokenizedprogramformat.rs @@ -0,0 +1,1335 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{DWORD, UINT}; +ENUM!{enum D3D10_SB_TOKENIZED_PROGRAM_TYPE { + D3D10_SB_PIXEL_SHADER = 0, + D3D10_SB_VERTEX_SHADER = 1, + D3D10_SB_GEOMETRY_SHADER = 2, + D3D11_SB_HULL_SHADER = 3, + D3D11_SB_DOMAIN_SHADER = 4, + D3D11_SB_COMPUTE_SHADER = 5, + D3D11_SB_RESERVED0 = 0xFFF0, +}} +pub const D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK: DWORD = 0xffff0000; +pub const D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT: DWORD = 16; +#[inline] +pub fn DECODE_D3D10_SB_TOKENIZED_PROGRAM_TYPE(VerTok: DWORD) -> DWORD { + (((VerTok & D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK) >> D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT) + as D3D10_SB_TOKENIZED_PROGRAM_TYPE) +} +pub const D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK: DWORD = 0x000000f0; +pub const D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT: DWORD = 4; +pub const D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK: DWORD = 0x0000000f; +#[inline] +pub fn DECODE_D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION(VerTok: DWORD) -> DWORD { + ((VerTok & D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK) + >> D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT) +} +#[inline] +pub fn DECODE_D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION(VerTok: DWORD) -> DWORD { + (VerTok & D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK) +} +#[inline] +pub fn ENCODE_D3D10_SB_TOKENIZED_PROGRAM_VERSION_TOKEN( + ProgType: DWORD, + MajorVer: DWORD, + MinorVer: DWORD, +) -> DWORD { + ((ProgType << D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT) & D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK) + | ((MajorVer << D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT) + & D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK) + | (MinorVer & D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK) +} +#[inline] +pub fn DECODE_D3D10_SB_TOKENIZED_PROGRAM_LENGTH(LenTok: DWORD) -> DWORD { + LenTok +} +#[inline] +pub fn ENCODE_D3D10_SB_TOKENIZED_PROGRAM_LENGTH(Length: DWORD) -> DWORD { + Length +} +pub const MAX_D3D10_SB_TOKENIZED_PROGRAM_LENGTH: DWORD = 0xffffffff; +ENUM!{enum D3D10_SB_OPCODE_TYPE { + D3D10_SB_OPCODE_ADD = 0, + D3D10_SB_OPCODE_AND = 1, + D3D10_SB_OPCODE_BREAK = 2, + D3D10_SB_OPCODE_BREAKC = 3, + D3D10_SB_OPCODE_CALL = 4, + D3D10_SB_OPCODE_CALLC = 5, + D3D10_SB_OPCODE_CASE = 6, + D3D10_SB_OPCODE_CONTINUE = 7, + D3D10_SB_OPCODE_CONTINUEC = 8, + D3D10_SB_OPCODE_CUT = 9, + D3D10_SB_OPCODE_DEFAULT = 10, + D3D10_SB_OPCODE_DERIV_RTX = 11, + D3D10_SB_OPCODE_DERIV_RTY = 12, + D3D10_SB_OPCODE_DISCARD = 13, + D3D10_SB_OPCODE_DIV = 14, + D3D10_SB_OPCODE_DP2 = 15, + D3D10_SB_OPCODE_DP3 = 16, + D3D10_SB_OPCODE_DP4 = 17, + D3D10_SB_OPCODE_ELSE = 18, + D3D10_SB_OPCODE_EMIT = 19, + D3D10_SB_OPCODE_EMITTHENCUT = 20, + D3D10_SB_OPCODE_ENDIF = 21, + D3D10_SB_OPCODE_ENDLOOP = 22, + D3D10_SB_OPCODE_ENDSWITCH = 23, + D3D10_SB_OPCODE_EQ = 24, + D3D10_SB_OPCODE_EXP = 25, + D3D10_SB_OPCODE_FRC = 26, + D3D10_SB_OPCODE_FTOI = 27, + D3D10_SB_OPCODE_FTOU = 28, + D3D10_SB_OPCODE_GE = 29, + D3D10_SB_OPCODE_IADD = 30, + D3D10_SB_OPCODE_IF = 31, + D3D10_SB_OPCODE_IEQ = 32, + D3D10_SB_OPCODE_IGE = 33, + D3D10_SB_OPCODE_ILT = 34, + D3D10_SB_OPCODE_IMAD = 35, + D3D10_SB_OPCODE_IMAX = 36, + D3D10_SB_OPCODE_IMIN = 37, + D3D10_SB_OPCODE_IMUL = 38, + D3D10_SB_OPCODE_INE = 39, + D3D10_SB_OPCODE_INEG = 40, + D3D10_SB_OPCODE_ISHL = 41, + D3D10_SB_OPCODE_ISHR = 42, + D3D10_SB_OPCODE_ITOF = 43, + D3D10_SB_OPCODE_LABEL = 44, + D3D10_SB_OPCODE_LD = 45, + D3D10_SB_OPCODE_LD_MS = 46, + D3D10_SB_OPCODE_LOG = 47, + D3D10_SB_OPCODE_LOOP = 48, + D3D10_SB_OPCODE_LT = 49, + D3D10_SB_OPCODE_MAD = 50, + D3D10_SB_OPCODE_MIN = 51, + D3D10_SB_OPCODE_MAX = 52, + D3D10_SB_OPCODE_CUSTOMDATA = 53, + D3D10_SB_OPCODE_MOV = 54, + D3D10_SB_OPCODE_MOVC = 55, + D3D10_SB_OPCODE_MUL = 56, + D3D10_SB_OPCODE_NE = 57, + D3D10_SB_OPCODE_NOP = 58, + D3D10_SB_OPCODE_NOT = 59, + D3D10_SB_OPCODE_OR = 60, + D3D10_SB_OPCODE_RESINFO = 61, + D3D10_SB_OPCODE_RET = 62, + D3D10_SB_OPCODE_RETC = 63, + D3D10_SB_OPCODE_ROUND_NE = 64, + D3D10_SB_OPCODE_ROUND_NI = 65, + D3D10_SB_OPCODE_ROUND_PI = 66, + D3D10_SB_OPCODE_ROUND_Z = 67, + D3D10_SB_OPCODE_RSQ = 68, + D3D10_SB_OPCODE_SAMPLE = 69, + D3D10_SB_OPCODE_SAMPLE_C = 70, + D3D10_SB_OPCODE_SAMPLE_C_LZ = 71, + D3D10_SB_OPCODE_SAMPLE_L = 72, + D3D10_SB_OPCODE_SAMPLE_D = 73, + D3D10_SB_OPCODE_SAMPLE_B = 74, + D3D10_SB_OPCODE_SQRT = 75, + D3D10_SB_OPCODE_SWITCH = 76, + D3D10_SB_OPCODE_SINCOS = 77, + D3D10_SB_OPCODE_UDIV = 78, + D3D10_SB_OPCODE_ULT = 79, + D3D10_SB_OPCODE_UGE = 80, + D3D10_SB_OPCODE_UMUL = 81, + D3D10_SB_OPCODE_UMAD = 82, + D3D10_SB_OPCODE_UMAX = 83, + D3D10_SB_OPCODE_UMIN = 84, + D3D10_SB_OPCODE_USHR = 85, + D3D10_SB_OPCODE_UTOF = 86, + D3D10_SB_OPCODE_XOR = 87, + D3D10_SB_OPCODE_DCL_RESOURCE = 88, + D3D10_SB_OPCODE_DCL_CONSTANT_BUFFER = 89, + D3D10_SB_OPCODE_DCL_SAMPLER = 90, + D3D10_SB_OPCODE_DCL_INDEX_RANGE = 91, + D3D10_SB_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY = 92, + D3D10_SB_OPCODE_DCL_GS_INPUT_PRIMITIVE = 93, + D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT = 94, + D3D10_SB_OPCODE_DCL_INPUT = 95, + D3D10_SB_OPCODE_DCL_INPUT_SGV = 96, + D3D10_SB_OPCODE_DCL_INPUT_SIV = 97, + D3D10_SB_OPCODE_DCL_INPUT_PS = 98, + D3D10_SB_OPCODE_DCL_INPUT_PS_SGV = 99, + D3D10_SB_OPCODE_DCL_INPUT_PS_SIV = 100, + D3D10_SB_OPCODE_DCL_OUTPUT = 101, + D3D10_SB_OPCODE_DCL_OUTPUT_SGV = 102, + D3D10_SB_OPCODE_DCL_OUTPUT_SIV = 103, + D3D10_SB_OPCODE_DCL_TEMPS = 104, + D3D10_SB_OPCODE_DCL_INDEXABLE_TEMP = 105, + D3D10_SB_OPCODE_DCL_GLOBAL_FLAGS = 106, + D3D10_SB_OPCODE_RESERVED0 = 107, + D3D10_1_SB_OPCODE_LOD = 108, + D3D10_1_SB_OPCODE_GATHER4 = 109, + D3D10_1_SB_OPCODE_SAMPLE_POS = 110, + D3D10_1_SB_OPCODE_SAMPLE_INFO = 111, + D3D10_1_SB_OPCODE_RESERVED1 = 112, + D3D11_SB_OPCODE_HS_DECLS = 113, + D3D11_SB_OPCODE_HS_CONTROL_POINT_PHASE = 114, + D3D11_SB_OPCODE_HS_FORK_PHASE = 115, + D3D11_SB_OPCODE_HS_JOIN_PHASE = 116, + D3D11_SB_OPCODE_EMIT_STREAM = 117, + D3D11_SB_OPCODE_CUT_STREAM = 118, + D3D11_SB_OPCODE_EMITTHENCUT_STREAM = 119, + D3D11_SB_OPCODE_INTERFACE_CALL = 120, + D3D11_SB_OPCODE_BUFINFO = 121, + D3D11_SB_OPCODE_DERIV_RTX_COARSE = 122, + D3D11_SB_OPCODE_DERIV_RTX_FINE = 123, + D3D11_SB_OPCODE_DERIV_RTY_COARSE = 124, + D3D11_SB_OPCODE_DERIV_RTY_FINE = 125, + D3D11_SB_OPCODE_GATHER4_C = 126, + D3D11_SB_OPCODE_GATHER4_PO = 127, + D3D11_SB_OPCODE_GATHER4_PO_C = 128, + D3D11_SB_OPCODE_RCP = 129, + D3D11_SB_OPCODE_F32TOF16 = 130, + D3D11_SB_OPCODE_F16TOF32 = 131, + D3D11_SB_OPCODE_UADDC = 132, + D3D11_SB_OPCODE_USUBB = 133, + D3D11_SB_OPCODE_COUNTBITS = 134, + D3D11_SB_OPCODE_FIRSTBIT_HI = 135, + D3D11_SB_OPCODE_FIRSTBIT_LO = 136, + D3D11_SB_OPCODE_FIRSTBIT_SHI = 137, + D3D11_SB_OPCODE_UBFE = 138, + D3D11_SB_OPCODE_IBFE = 139, + D3D11_SB_OPCODE_BFI = 140, + D3D11_SB_OPCODE_BFREV = 141, + D3D11_SB_OPCODE_SWAPC = 142, + D3D11_SB_OPCODE_DCL_STREAM = 143, + D3D11_SB_OPCODE_DCL_FUNCTION_BODY = 144, + D3D11_SB_OPCODE_DCL_FUNCTION_TABLE = 145, + D3D11_SB_OPCODE_DCL_INTERFACE = 146, + D3D11_SB_OPCODE_DCL_INPUT_CONTROL_POINT_COUNT = 147, + D3D11_SB_OPCODE_DCL_OUTPUT_CONTROL_POINT_COUNT = 148, + D3D11_SB_OPCODE_DCL_TESS_DOMAIN = 149, + D3D11_SB_OPCODE_DCL_TESS_PARTITIONING = 150, + D3D11_SB_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE = 151, + D3D11_SB_OPCODE_DCL_HS_MAX_TESSFACTOR = 152, + D3D11_SB_OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT = 153, + D3D11_SB_OPCODE_DCL_HS_JOIN_PHASE_INSTANCE_COUNT = 154, + D3D11_SB_OPCODE_DCL_THREAD_GROUP = 155, + D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_TYPED = 156, + D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW = 157, + D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED = 158, + D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW = 159, + D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED = 160, + D3D11_SB_OPCODE_DCL_RESOURCE_RAW = 161, + D3D11_SB_OPCODE_DCL_RESOURCE_STRUCTURED = 162, + D3D11_SB_OPCODE_LD_UAV_TYPED = 163, + D3D11_SB_OPCODE_STORE_UAV_TYPED = 164, + D3D11_SB_OPCODE_LD_RAW = 165, + D3D11_SB_OPCODE_STORE_RAW = 166, + D3D11_SB_OPCODE_LD_STRUCTURED = 167, + D3D11_SB_OPCODE_STORE_STRUCTURED = 168, + D3D11_SB_OPCODE_ATOMIC_AND = 169, + D3D11_SB_OPCODE_ATOMIC_OR = 170, + D3D11_SB_OPCODE_ATOMIC_XOR = 171, + D3D11_SB_OPCODE_ATOMIC_CMP_STORE = 172, + D3D11_SB_OPCODE_ATOMIC_IADD = 173, + D3D11_SB_OPCODE_ATOMIC_IMAX = 174, + D3D11_SB_OPCODE_ATOMIC_IMIN = 175, + D3D11_SB_OPCODE_ATOMIC_UMAX = 176, + D3D11_SB_OPCODE_ATOMIC_UMIN = 177, + D3D11_SB_OPCODE_IMM_ATOMIC_ALLOC = 178, + D3D11_SB_OPCODE_IMM_ATOMIC_CONSUME = 179, + D3D11_SB_OPCODE_IMM_ATOMIC_IADD = 180, + D3D11_SB_OPCODE_IMM_ATOMIC_AND = 181, + D3D11_SB_OPCODE_IMM_ATOMIC_OR = 182, + D3D11_SB_OPCODE_IMM_ATOMIC_XOR = 183, + D3D11_SB_OPCODE_IMM_ATOMIC_EXCH = 184, + D3D11_SB_OPCODE_IMM_ATOMIC_CMP_EXCH = 185, + D3D11_SB_OPCODE_IMM_ATOMIC_IMAX = 186, + D3D11_SB_OPCODE_IMM_ATOMIC_IMIN = 187, + D3D11_SB_OPCODE_IMM_ATOMIC_UMAX = 188, + D3D11_SB_OPCODE_IMM_ATOMIC_UMIN = 189, + D3D11_SB_OPCODE_SYNC = 190, + D3D11_SB_OPCODE_DADD = 191, + D3D11_SB_OPCODE_DMAX = 192, + D3D11_SB_OPCODE_DMIN = 193, + D3D11_SB_OPCODE_DMUL = 194, + D3D11_SB_OPCODE_DEQ = 195, + D3D11_SB_OPCODE_DGE = 196, + D3D11_SB_OPCODE_DLT = 197, + D3D11_SB_OPCODE_DNE = 198, + D3D11_SB_OPCODE_DMOV = 199, + D3D11_SB_OPCODE_DMOVC = 200, + D3D11_SB_OPCODE_DTOF = 201, + D3D11_SB_OPCODE_FTOD = 202, + D3D11_SB_OPCODE_EVAL_SNAPPED = 203, + D3D11_SB_OPCODE_EVAL_SAMPLE_INDEX = 204, + D3D11_SB_OPCODE_EVAL_CENTROID = 205, + D3D11_SB_OPCODE_DCL_GS_INSTANCE_COUNT = 206, + D3D11_SB_OPCODE_ABORT = 207, + D3D11_SB_OPCODE_DEBUG_BREAK = 208, + D3D11_SB_OPCODE_RESERVED0 = 209, + D3D11_1_SB_OPCODE_DDIV = 210, + D3D11_1_SB_OPCODE_DFMA = 211, + D3D11_1_SB_OPCODE_DRCP = 212, + D3D11_1_SB_OPCODE_MSAD = 213, + D3D11_1_SB_OPCODE_DTOI = 214, + D3D11_1_SB_OPCODE_DTOU = 215, + D3D11_1_SB_OPCODE_ITOD = 216, + D3D11_1_SB_OPCODE_UTOD = 217, + D3D11_1_SB_OPCODE_RESERVED0 = 218, + D3DWDDM1_3_SB_OPCODE_GATHER4_FEEDBACK = 219, + D3DWDDM1_3_SB_OPCODE_GATHER4_C_FEEDBACK = 220, + D3DWDDM1_3_SB_OPCODE_GATHER4_PO_FEEDBACK = 221, + D3DWDDM1_3_SB_OPCODE_GATHER4_PO_C_FEEDBACK = 222, + D3DWDDM1_3_SB_OPCODE_LD_FEEDBACK = 223, + D3DWDDM1_3_SB_OPCODE_LD_MS_FEEDBACK = 224, + D3DWDDM1_3_SB_OPCODE_LD_UAV_TYPED_FEEDBACK = 225, + D3DWDDM1_3_SB_OPCODE_LD_RAW_FEEDBACK = 226, + D3DWDDM1_3_SB_OPCODE_LD_STRUCTURED_FEEDBACK = 227, + D3DWDDM1_3_SB_OPCODE_SAMPLE_L_FEEDBACK = 228, + D3DWDDM1_3_SB_OPCODE_SAMPLE_C_LZ_FEEDBACK = 229, + D3DWDDM1_3_SB_OPCODE_SAMPLE_CLAMP_FEEDBACK = 230, + D3DWDDM1_3_SB_OPCODE_SAMPLE_B_CLAMP_FEEDBACK = 231, + D3DWDDM1_3_SB_OPCODE_SAMPLE_D_CLAMP_FEEDBACK = 232, + D3DWDDM1_3_SB_OPCODE_SAMPLE_C_CLAMP_FEEDBACK = 233, + D3DWDDM1_3_SB_OPCODE_CHECK_ACCESS_FULLY_MAPPED = 234, + D3DWDDM1_3_SB_OPCODE_RESERVED0 = 235, + D3D10_SB_NUM_OPCODES = 236, +}} +pub const D3D10_SB_OPCODE_TYPE_MASK: DWORD = 0x00007ff; +#[inline] +pub fn DECODE_D3D10_SB_OPCODE_TYPE(OpcodeToken0: DWORD) -> D3D10_SB_OPCODE_TYPE { + (OpcodeToken0 & D3D10_SB_OPCODE_TYPE_MASK) as D3D10_SB_OPCODE_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_OPCODE_TYPE(OpcodeName: D3D10_SB_OPCODE_TYPE) -> DWORD { + OpcodeName & D3D10_SB_OPCODE_TYPE_MASK +} +pub const D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_MASK: DWORD = 0x7f000000; +pub const D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_SHIFT: DWORD = 24; +#[inline] +pub fn DECODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(OpcodeToken0: DWORD) -> DWORD { + (OpcodeToken0 & D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_MASK) + >> D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_SHIFT +} +#[inline] +pub fn ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(Length: DWORD) -> DWORD { + (Length << D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_SHIFT) + & D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_MASK +} +pub const MAX_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH: DWORD = 127; +pub const D3D10_SB_INSTRUCTION_SATURATE_MASK: DWORD = 0x00002000; +#[inline] +pub fn DECODE_IS_D3D10_SB_INSTRUCTION_SATURATE_ENABLED(OpcodeToken0: DWORD) -> DWORD { + OpcodeToken0 & D3D10_SB_INSTRUCTION_SATURATE_MASK +} +#[inline] +pub fn ENCODE_D3D10_SB_INSTRUCTION_SATURATE(bSat: DWORD) -> DWORD { + if bSat != 0 { + D3D10_SB_INSTRUCTION_SATURATE_MASK + } else { + 0 + } +} +ENUM!{enum D3D10_SB_INSTRUCTION_TEST_BOOLEAN { + D3D10_SB_INSTRUCTION_TEST_ZERO = 0, + D3D10_SB_INSTRUCTION_TEST_NONZERO = 1, +}} +pub const D3D10_SB_INSTRUCTION_TEST_BOOLEAN_MASK: DWORD = 0x00040000; +pub const D3D10_SB_INSTRUCTION_TEST_BOOLEAN_SHIFT: DWORD = 18; +#[inline] +pub fn DECODE_D3D10_SB_INSTRUCTION_TEST_BOOLEAN( + OpcodeToken0: DWORD, +) -> D3D10_SB_INSTRUCTION_TEST_BOOLEAN { + ((OpcodeToken0 & D3D10_SB_INSTRUCTION_TEST_BOOLEAN_MASK) + >> D3D10_SB_INSTRUCTION_TEST_BOOLEAN_SHIFT) as D3D10_SB_INSTRUCTION_TEST_BOOLEAN +} +#[inline] +pub fn ENCODE_D3D10_SB_INSTRUCTION_TEST_BOOLEAN( + Boolean: D3D10_SB_INSTRUCTION_TEST_BOOLEAN, +) -> DWORD { + (Boolean << D3D10_SB_INSTRUCTION_TEST_BOOLEAN_SHIFT) & D3D10_SB_INSTRUCTION_TEST_BOOLEAN_MASK +} +pub const D3D11_SB_INSTRUCTION_PRECISE_VALUES_MASK: DWORD = 0x00780000; +pub const D3D11_SB_INSTRUCTION_PRECISE_VALUES_SHIFT: DWORD = 19; +#[inline] +pub fn DECODE_D3D11_SB_INSTRUCTION_PRECISE_VALUES(OpcodeToken0: DWORD) -> DWORD { + (OpcodeToken0 & D3D11_SB_INSTRUCTION_PRECISE_VALUES_MASK) + >> D3D11_SB_INSTRUCTION_PRECISE_VALUES_SHIFT +} +#[inline] +pub fn ENCODE_D3D11_SB_INSTRUCTION_PRECISE_VALUES(ComponentMask: DWORD) -> DWORD { + (ComponentMask << D3D11_SB_INSTRUCTION_PRECISE_VALUES_SHIFT) + & D3D11_SB_INSTRUCTION_PRECISE_VALUES_MASK +} +ENUM!{enum D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE { + D3D10_SB_RESINFO_INSTRUCTION_RETURN_FLOAT = 0, + D3D10_SB_RESINFO_INSTRUCTION_RETURN_RCPFLOAT = 1, + D3D10_SB_RESINFO_INSTRUCTION_RETURN_UINT = 2, +}} +pub const D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_MASK: DWORD = 0x00001800; +pub const D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE( + OpcodeToken0: DWORD, +) -> D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE { + ((OpcodeToken0 & D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_MASK) + >> D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_SHIFT) + as D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE( + ReturnType: D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE, +) -> DWORD { + (ReturnType << D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_SHIFT) + & D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_MASK +} +pub const D3D11_SB_SYNC_THREADS_IN_GROUP: DWORD = 0x00000800; +pub const D3D11_SB_SYNC_THREAD_GROUP_SHARED_MEMORY: DWORD = 0x00001000; +pub const D3D11_SB_SYNC_UNORDERED_ACCESS_VIEW_MEMORY_GROUP: DWORD = 0x00002000; +pub const D3D11_SB_SYNC_UNORDERED_ACCESS_VIEW_MEMORY_GLOBAL: DWORD = 0x00004000; +pub const D3D11_SB_SYNC_FLAGS_MASK: DWORD = 0x00007800; +#[inline] +pub fn DECODE_D3D11_SB_SYNC_FLAGS(OperandToken0: DWORD) -> DWORD { + OperandToken0 & D3D11_SB_SYNC_FLAGS_MASK +} +#[inline] +pub fn ENCODE_D3D11_SB_SYNC_FLAGS(Flags: DWORD) -> DWORD { + Flags & D3D11_SB_SYNC_FLAGS_MASK +} +pub const D3D10_SB_OPCODE_EXTENDED_MASK: DWORD = 0x80000000; +pub const D3D10_SB_OPCODE_EXTENDED_SHIFT: DWORD = 31; +#[inline] +pub fn DECODE_IS_D3D10_SB_OPCODE_EXTENDED(OpcodeToken0: DWORD) -> DWORD { + (OpcodeToken0 & D3D10_SB_OPCODE_EXTENDED_MASK) >> D3D10_SB_OPCODE_EXTENDED_SHIFT +} +#[inline] +pub fn ENCODE_D3D10_SB_OPCODE_EXTENDED(bExtended: DWORD) -> DWORD { + if bExtended != 0 { + D3D10_SB_OPCODE_EXTENDED_MASK + } else { + 0 + } +} +ENUM!{enum D3D10_SB_EXTENDED_OPCODE_TYPE { + D3D10_SB_EXTENDED_OPCODE_EMPTY = 0, + D3D10_SB_EXTENDED_OPCODE_SAMPLE_CONTROLS = 1, + D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM = 2, + D3D11_SB_EXTENDED_OPCODE_RESOURCE_RETURN_TYPE = 3, +}} +pub const D3D11_SB_MAX_SIMULTANEOUS_EXTENDED_OPCODES: DWORD = 3; +pub const D3D10_SB_EXTENDED_OPCODE_TYPE_MASK: DWORD = 0x0000003f; +#[inline] +pub fn DECODE_D3D10_SB_EXTENDED_OPCODE_TYPE(OpcodeToken1: DWORD) -> D3D10_SB_EXTENDED_OPCODE_TYPE { + (OpcodeToken1 & D3D10_SB_EXTENDED_OPCODE_TYPE_MASK) as D3D10_SB_EXTENDED_OPCODE_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_EXTENDED_OPCODE_TYPE( + ExtOpcodeType: D3D10_SB_EXTENDED_OPCODE_TYPE, +) -> DWORD { + ExtOpcodeType & D3D10_SB_EXTENDED_OPCODE_TYPE_MASK +} +ENUM!{enum D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD { + D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_U = 0, + D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_V = 1, + D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_W = 2, +}} +pub const D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD_MASK: DWORD = 3; +#[inline] +pub fn D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord: DWORD) -> DWORD { + 9 + 4 * (Coord & D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD_MASK) +} +#[inline] +pub fn D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_MASK(Coord: DWORD) -> DWORD { + 0x0000000f << D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord) +} +#[inline] +pub fn DECODE_IMMEDIATE_D3D10_SB_ADDRESS_OFFSET( + Coord: DWORD, + OpcodeToken1: DWORD, +) -> DWORD { + (OpcodeToken1 & D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_MASK(Coord)) + >> D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord) +} +#[inline] +pub fn ENCODE_IMMEDIATE_D3D10_SB_ADDRESS_OFFSET( + Coord: DWORD, + ImmediateOffset: DWORD, +) -> DWORD { + (ImmediateOffset << D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord)) + & D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_MASK(Coord) +} +pub const D3D11_SB_EXTENDED_RESOURCE_DIMENSION_MASK: DWORD = 0x000007C0; +pub const D3D11_SB_EXTENDED_RESOURCE_DIMENSION_SHIFT: DWORD = 6; +#[inline] +pub fn DECODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION( + OpcodeTokenN: DWORD, +) -> D3D10_SB_RESOURCE_DIMENSION { + ((OpcodeTokenN & D3D11_SB_EXTENDED_RESOURCE_DIMENSION_MASK) + >> D3D11_SB_EXTENDED_RESOURCE_DIMENSION_SHIFT) as D3D10_SB_RESOURCE_DIMENSION +} +#[inline] +pub fn ENCODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION( + ResourceDim: D3D10_SB_RESOURCE_DIMENSION, +) -> DWORD { + (ResourceDim << D3D11_SB_EXTENDED_RESOURCE_DIMENSION_SHIFT) + & D3D11_SB_EXTENDED_RESOURCE_DIMENSION_MASK +} +pub const D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_MASK: DWORD = 0x007FF800; +pub const D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE(OpcodeTokenN: DWORD) -> DWORD { + (OpcodeTokenN & D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_MASK) + >> D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_SHIFT +} +#[inline] +pub fn ENCODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE(Stride: DWORD) -> DWORD { + (Stride << D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_SHIFT) + & D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_MASK +} +pub const D3D10_SB_RESOURCE_RETURN_TYPE_MASK: DWORD = 0x0000000f; +pub const D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS: DWORD = 0x00000004; +pub const D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT: DWORD = 6; +#[inline] +pub fn DECODE_D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE( + OpcodeTokenN: DWORD, + Component: DWORD, +) -> DWORD { + ((OpcodeTokenN >> (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS + + D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT)) + & D3D10_SB_RESOURCE_RETURN_TYPE_MASK) as D3D10_SB_RESOURCE_RETURN_TYPE +} +#[inline] +pub fn ENCODE_D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE( + ReturnType: DWORD, + Component: DWORD, +) -> DWORD { + (ReturnType & D3D10_SB_RESOURCE_RETURN_TYPE_MASK) + << (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS + + D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT) +} +ENUM!{enum D3D10_SB_CUSTOMDATA_CLASS { + D3D10_SB_CUSTOMDATA_COMMENT = 0, + D3D10_SB_CUSTOMDATA_DEBUGINFO = 1, + D3D10_SB_CUSTOMDATA_OPAQUE = 2, + D3D10_SB_CUSTOMDATA_DCL_IMMEDIATE_CONSTANT_BUFFER = 3, + D3D11_SB_CUSTOMDATA_SHADER_MESSAGE = 4, + D3D11_SB_CUSTOMDATA_SHADER_CLIP_PLANE_CONSTANT_MAPPINGS_FOR_DX9 = 5, +}} +pub const D3D10_SB_CUSTOMDATA_CLASS_MASK: DWORD = 0xfffff800; +pub const D3D10_SB_CUSTOMDATA_CLASS_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_CUSTOMDATA_CLASS(CustomDataDescTok: DWORD) -> D3D10_SB_CUSTOMDATA_CLASS { + ((CustomDataDescTok & D3D10_SB_CUSTOMDATA_CLASS_MASK) >> D3D10_SB_CUSTOMDATA_CLASS_SHIFT) + as D3D10_SB_CUSTOMDATA_CLASS +} +#[inline] +pub fn ENCODE_D3D10_SB_CUSTOMDATA_CLASS(CustomDataClass: D3D10_SB_CUSTOMDATA_CLASS) -> DWORD { + ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_CUSTOMDATA) + | ((CustomDataClass << D3D10_SB_CUSTOMDATA_CLASS_SHIFT) & D3D10_SB_CUSTOMDATA_CLASS_MASK) +} +ENUM!{enum D3D10_SB_OPERAND_NUM_COMPONENTS { + D3D10_SB_OPERAND_0_COMPONENT = 0, + D3D10_SB_OPERAND_1_COMPONENT = 1, + D3D10_SB_OPERAND_4_COMPONENT = 2, + D3D10_SB_OPERAND_N_COMPONENT = 3, +}} +pub const D3D10_SB_OPERAND_NUM_COMPONENTS_MASK: DWORD = 0x00000003; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_NUM_COMPONENTS(OperandToken0: DWORD) -> DWORD { + (OperandToken0 & D3D10_SB_OPERAND_NUM_COMPONENTS_MASK) as D3D10_SB_OPERAND_NUM_COMPONENTS +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_NUM_COMPONENTS(NumComp: DWORD) -> DWORD { + NumComp & D3D10_SB_OPERAND_NUM_COMPONENTS_MASK +} +ENUM!{enum D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE { + D3D10_SB_OPERAND_4_COMPONENT_MASK_MODE = 0, + D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MODE = 1, + D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE = 2, +}} +pub const D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK: DWORD = 0x0000000c; +pub const D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT: DWORD = 2; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE( + OperandToken0: DWORD, +) -> D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE { + ((OperandToken0 & D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK) + >> D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT) + as D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE( + SelectionMode: D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE, +) -> DWORD { + (SelectionMode << D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT) + & D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK +} +ENUM!{enum D3D10_SB_4_COMPONENT_NAME { + D3D10_SB_4_COMPONENT_X = 0, + D3D10_SB_4_COMPONENT_Y = 1, + D3D10_SB_4_COMPONENT_Z = 2, + D3D10_SB_4_COMPONENT_W = 3, + D3D10_SB_4_COMPONENT_R = 0, + D3D10_SB_4_COMPONENT_G = 1, + D3D10_SB_4_COMPONENT_B = 2, + D3D10_SB_4_COMPONENT_A = 3, +}} +pub const D3D10_SB_4_COMPONENT_NAME_MASK: DWORD = 3; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK: DWORD = 0x000000f0; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_SHIFT: DWORD = 4; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_X: DWORD = 0x00000010; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_Y: DWORD = 0x00000020; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_Z: DWORD = 0x00000040; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_W: DWORD = 0x00000080; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_R: DWORD = D3D10_SB_OPERAND_4_COMPONENT_MASK_X; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_G: DWORD = D3D10_SB_OPERAND_4_COMPONENT_MASK_Y; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_B: DWORD = D3D10_SB_OPERAND_4_COMPONENT_MASK_Z; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_A: DWORD = D3D10_SB_OPERAND_4_COMPONENT_MASK_W; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_ALL: DWORD = D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_4_COMPONENT_MASK(OperandToken0: DWORD) -> DWORD { + OperandToken0 & D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_4_COMPONENT_MASK(ComponentMask: DWORD) -> DWORD { + ComponentMask & D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_MASK(ComponentName: DWORD) -> DWORD { + (1 << (D3D10_SB_OPERAND_4_COMPONENT_MASK_SHIFT + ComponentName)) + & D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK +} +pub const D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MASK: DWORD = 0x00000ff0; +pub const D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT: DWORD = 4; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(OperandToken0: DWORD) -> DWORD { + OperandToken0 & D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MASK +} +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SOURCE( + OperandToken0: DWORD, + DestComp: DWORD, +) -> D3D10_SB_4_COMPONENT_NAME { + ((OperandToken0 >> (D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT + 2 + * (DestComp & D3D10_SB_4_COMPONENT_NAME_MASK))) + & D3D10_SB_4_COMPONENT_NAME_MASK) as D3D10_SB_4_COMPONENT_NAME +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + XSrc: DWORD, + YSrc: DWORD, + ZSrc: DWORD, + WSrc: DWORD, +) -> DWORD { + ((XSrc & D3D10_SB_4_COMPONENT_NAME_MASK) + | ((YSrc & D3D10_SB_4_COMPONENT_NAME_MASK) << 2) + | ((ZSrc & D3D10_SB_4_COMPONENT_NAME_MASK) << 4) + | ((WSrc & D3D10_SB_4_COMPONENT_NAME_MASK) << 6)) + << D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_NOSWIZZLE() -> DWORD { + ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + D3D10_SB_4_COMPONENT_X, + D3D10_SB_4_COMPONENT_Y, + D3D10_SB_4_COMPONENT_Z, + D3D10_SB_4_COMPONENT_W, + ) +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEX() -> DWORD { + ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + D3D10_SB_4_COMPONENT_X, + D3D10_SB_4_COMPONENT_X, + D3D10_SB_4_COMPONENT_X, + D3D10_SB_4_COMPONENT_X, + ) +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEY() -> DWORD { + ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + D3D10_SB_4_COMPONENT_Y, + D3D10_SB_4_COMPONENT_Y, + D3D10_SB_4_COMPONENT_Y, + D3D10_SB_4_COMPONENT_Y, + ) +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEZ() -> DWORD { + ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + D3D10_SB_4_COMPONENT_Z, + D3D10_SB_4_COMPONENT_Z, + D3D10_SB_4_COMPONENT_Z, + D3D10_SB_4_COMPONENT_Z, + ) +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEW() -> DWORD { + ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + D3D10_SB_4_COMPONENT_W, + D3D10_SB_4_COMPONENT_W, + D3D10_SB_4_COMPONENT_W, + D3D10_SB_4_COMPONENT_W, + ) +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATERED() -> DWORD { + D3D10_SB_OPERAND_4_COMPONENT_REPLICATEX() +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEGREEN() -> DWORD { + D3D10_SB_OPERAND_4_COMPONENT_REPLICATEY() +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEBLUE() -> DWORD { + D3D10_SB_OPERAND_4_COMPONENT_REPLICATEZ() +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEALPHA() -> DWORD { + D3D10_SB_OPERAND_4_COMPONENT_REPLICATEW() +} +pub const D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MASK: DWORD = 0x00000030; +pub const D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT: DWORD = 4; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_4_COMPONENT_SELECT_1( + OperandToken0: DWORD, +) -> D3D10_SB_4_COMPONENT_NAME { + ((OperandToken0 & D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MASK) + >> D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT) as D3D10_SB_4_COMPONENT_NAME +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECT_1( + SelectedComp: D3D10_SB_4_COMPONENT_NAME, +) -> DWORD { + (SelectedComp << D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT) + & D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MASK +} +ENUM!{enum D3D10_SB_OPERAND_TYPE { + D3D10_SB_OPERAND_TYPE_TEMP = 0, + D3D10_SB_OPERAND_TYPE_INPUT = 1, + D3D10_SB_OPERAND_TYPE_OUTPUT = 2, + D3D10_SB_OPERAND_TYPE_INDEXABLE_TEMP = 3, + D3D10_SB_OPERAND_TYPE_IMMEDIATE32 = 4, + D3D10_SB_OPERAND_TYPE_IMMEDIATE64 = 5, + D3D10_SB_OPERAND_TYPE_SAMPLER = 6, + D3D10_SB_OPERAND_TYPE_RESOURCE = 7, + D3D10_SB_OPERAND_TYPE_CONSTANT_BUFFER= 8, + D3D10_SB_OPERAND_TYPE_IMMEDIATE_CONSTANT_BUFFER= 9, + D3D10_SB_OPERAND_TYPE_LABEL = 10, + D3D10_SB_OPERAND_TYPE_INPUT_PRIMITIVEID = 11, + D3D10_SB_OPERAND_TYPE_OUTPUT_DEPTH = 12, + D3D10_SB_OPERAND_TYPE_NULL = 13, + D3D10_SB_OPERAND_TYPE_RASTERIZER = 14, + D3D10_SB_OPERAND_TYPE_OUTPUT_COVERAGE_MASK = 15, + D3D11_SB_OPERAND_TYPE_STREAM = 16, + D3D11_SB_OPERAND_TYPE_FUNCTION_BODY = 17, + D3D11_SB_OPERAND_TYPE_FUNCTION_TABLE = 18, + D3D11_SB_OPERAND_TYPE_INTERFACE = 19, + D3D11_SB_OPERAND_TYPE_FUNCTION_INPUT = 20, + D3D11_SB_OPERAND_TYPE_FUNCTION_OUTPUT = 21, + D3D11_SB_OPERAND_TYPE_OUTPUT_CONTROL_POINT_ID = 22, + D3D11_SB_OPERAND_TYPE_INPUT_FORK_INSTANCE_ID = 23, + D3D11_SB_OPERAND_TYPE_INPUT_JOIN_INSTANCE_ID = 24, + D3D11_SB_OPERAND_TYPE_INPUT_CONTROL_POINT = 25, + D3D11_SB_OPERAND_TYPE_OUTPUT_CONTROL_POINT = 26, + D3D11_SB_OPERAND_TYPE_INPUT_PATCH_CONSTANT = 27, + D3D11_SB_OPERAND_TYPE_INPUT_DOMAIN_POINT = 28, + D3D11_SB_OPERAND_TYPE_THIS_POINTER = 29, + D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW = 30, + D3D11_SB_OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY = 31, + D3D11_SB_OPERAND_TYPE_INPUT_THREAD_ID = 32, + D3D11_SB_OPERAND_TYPE_INPUT_THREAD_GROUP_ID = 33, + D3D11_SB_OPERAND_TYPE_INPUT_THREAD_ID_IN_GROUP = 34, + D3D11_SB_OPERAND_TYPE_INPUT_COVERAGE_MASK = 35, + D3D11_SB_OPERAND_TYPE_INPUT_THREAD_ID_IN_GROUP_FLATTENED = 36, + D3D11_SB_OPERAND_TYPE_INPUT_GS_INSTANCE_ID = 37, + D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_GREATER_EQUAL = 38, + D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_LESS_EQUAL = 39, + D3D11_SB_OPERAND_TYPE_CYCLE_COUNTER = 40, +}} +pub const D3D10_SB_OPERAND_TYPE_MASK: DWORD = 0x000ff000; +pub const D3D10_SB_OPERAND_TYPE_SHIFT: DWORD = 12; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_TYPE(OperandToken0: DWORD) -> D3D10_SB_OPERAND_TYPE { + ((OperandToken0 & D3D10_SB_OPERAND_TYPE_MASK) >> D3D10_SB_OPERAND_TYPE_SHIFT) + as D3D10_SB_OPERAND_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_TYPE(OperandType: D3D10_SB_OPERAND_TYPE) -> DWORD { + (OperandType << D3D10_SB_OPERAND_TYPE_SHIFT) & D3D10_SB_OPERAND_TYPE_MASK +} +ENUM!{enum D3D10_SB_OPERAND_INDEX_DIMENSION { + D3D10_SB_OPERAND_INDEX_0D = 0, + D3D10_SB_OPERAND_INDEX_1D = 1, + D3D10_SB_OPERAND_INDEX_2D = 2, + D3D10_SB_OPERAND_INDEX_3D = 3, +}} +pub const D3D10_SB_OPERAND_INDEX_DIMENSION_MASK: DWORD = 0x00300000; +pub const D3D10_SB_OPERAND_INDEX_DIMENSION_SHIFT: DWORD = 20; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_INDEX_DIMENSION( + OperandToken0: DWORD, +) -> D3D10_SB_OPERAND_INDEX_DIMENSION { + ((OperandToken0 & D3D10_SB_OPERAND_INDEX_DIMENSION_MASK) + >> D3D10_SB_OPERAND_INDEX_DIMENSION_SHIFT) as D3D10_SB_OPERAND_INDEX_DIMENSION +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_INDEX_DIMENSION( + OperandIndexDim: D3D10_SB_OPERAND_INDEX_DIMENSION, +) -> DWORD { + (OperandIndexDim << D3D10_SB_OPERAND_INDEX_DIMENSION_SHIFT) + & D3D10_SB_OPERAND_INDEX_DIMENSION_MASK +} +ENUM!{enum D3D10_SB_OPERAND_INDEX_REPRESENTATION { + D3D10_SB_OPERAND_INDEX_IMMEDIATE32 = 0, + D3D10_SB_OPERAND_INDEX_IMMEDIATE64 = 1, + D3D10_SB_OPERAND_INDEX_RELATIVE = 2, + D3D10_SB_OPERAND_INDEX_IMMEDIATE32_PLUS_RELATIVE = 3, + D3D10_SB_OPERAND_INDEX_IMMEDIATE64_PLUS_RELATIVE = 4, +}} +#[inline] +pub fn D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim: DWORD) -> DWORD { + 22 + 3 * (Dim & 3) +} +#[inline] +pub fn D3D10_SB_OPERAND_INDEX_REPRESENTATION_MASK(Dim: DWORD) -> DWORD { + 0x3 << D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim) +} +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_INDEX_REPRESENTATION( + Dim: DWORD, + OperandToken0: DWORD, +) -> D3D10_SB_OPERAND_INDEX_REPRESENTATION { + ((OperandToken0 & D3D10_SB_OPERAND_INDEX_REPRESENTATION_MASK(Dim)) + >> D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim)) + as D3D10_SB_OPERAND_INDEX_REPRESENTATION +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_INDEX_REPRESENTATION( + Dim: DWORD, + IndexRepresentation: D3D10_SB_OPERAND_INDEX_REPRESENTATION, +) -> DWORD { + (IndexRepresentation << D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim)) + & D3D10_SB_OPERAND_INDEX_REPRESENTATION_MASK(Dim) +} +pub const D3D10_SB_OPERAND_EXTENDED_MASK: DWORD = 0x80000000; +pub const D3D10_SB_OPERAND_EXTENDED_SHIFT: DWORD = 31; +#[inline] +pub fn DECODE_IS_D3D10_SB_OPERAND_EXTENDED(OperandToken0: DWORD) -> DWORD { + (OperandToken0 & D3D10_SB_OPERAND_EXTENDED_MASK) >> D3D10_SB_OPERAND_EXTENDED_SHIFT +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_EXTENDED(bExtended: DWORD) -> DWORD { + if bExtended != 0 { + D3D10_SB_OPERAND_EXTENDED_MASK + } else { + 0 + } +} +ENUM!{enum D3D10_SB_EXTENDED_OPERAND_TYPE { + D3D10_SB_EXTENDED_OPERAND_EMPTY = 0, + D3D10_SB_EXTENDED_OPERAND_MODIFIER = 1, +}} +pub const D3D10_SB_EXTENDED_OPERAND_TYPE_MASK: DWORD = 0x0000003f; +#[inline] +pub fn DECODE_D3D10_SB_EXTENDED_OPERAND_TYPE( + OperandToken1: DWORD, +) -> D3D10_SB_EXTENDED_OPERAND_TYPE { + (OperandToken1 & D3D10_SB_EXTENDED_OPERAND_TYPE_MASK) as D3D10_SB_EXTENDED_OPERAND_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_EXTENDED_OPERAND_TYPE( + ExtOperandType: D3D10_SB_EXTENDED_OPERAND_TYPE, +) -> DWORD { + ExtOperandType & D3D10_SB_EXTENDED_OPERAND_TYPE_MASK +} +ENUM!{enum D3D10_SB_OPERAND_MODIFIER { + D3D10_SB_OPERAND_MODIFIER_NONE = 0, + D3D10_SB_OPERAND_MODIFIER_NEG = 1, + D3D10_SB_OPERAND_MODIFIER_ABS = 2, + D3D10_SB_OPERAND_MODIFIER_ABSNEG = 3, +}} +pub const D3D10_SB_OPERAND_MODIFIER_MASK: DWORD = 0x00003fc0; +pub const D3D10_SB_OPERAND_MODIFIER_SHIFT: DWORD = 6; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_MODIFIER(OperandToken1: DWORD) -> D3D10_SB_OPERAND_MODIFIER { + ((OperandToken1 & D3D10_SB_OPERAND_MODIFIER_MASK) >> D3D10_SB_OPERAND_MODIFIER_SHIFT) + as D3D10_SB_OPERAND_MODIFIER +} +#[inline] +pub fn ENCODE_D3D10_SB_EXTENDED_OPERAND_MODIFIER(SourceMod: D3D10_SB_OPERAND_MODIFIER) -> DWORD { + ((SourceMod << D3D10_SB_OPERAND_MODIFIER_SHIFT) & D3D10_SB_OPERAND_MODIFIER_MASK) + | ENCODE_D3D10_SB_EXTENDED_OPERAND_TYPE(D3D10_SB_EXTENDED_OPERAND_MODIFIER) + | ENCODE_D3D10_SB_OPERAND_DOUBLE_EXTENDED(0) +} +ENUM!{enum D3D11_SB_OPERAND_MIN_PRECISION { + D3D11_SB_OPERAND_MIN_PRECISION_DEFAULT = 0, + D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_16 = 1, + D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_2_8 = 2, + D3D11_SB_OPERAND_MIN_PRECISION_SINT_16 = 4, + D3D11_SB_OPERAND_MIN_PRECISION_UINT_16 = 5, +}} +pub const D3D11_SB_OPERAND_MIN_PRECISION_MASK: DWORD = 0x0001C000; +pub const D3D11_SB_OPERAND_MIN_PRECISION_SHIFT: DWORD = 14; +#[inline] +pub fn DECODE_D3D11_SB_OPERAND_MIN_PRECISION( + OperandToken1: DWORD, +) -> D3D11_SB_OPERAND_MIN_PRECISION { + ((OperandToken1 & D3D11_SB_OPERAND_MIN_PRECISION_MASK) >> D3D11_SB_OPERAND_MIN_PRECISION_SHIFT) + as D3D11_SB_OPERAND_MIN_PRECISION +} +#[inline] +pub fn ENCODE_D3D11_SB_OPERAND_MIN_PRECISION( + MinPrecision: D3D11_SB_OPERAND_MIN_PRECISION, +) -> DWORD { + (MinPrecision << D3D11_SB_OPERAND_MIN_PRECISION_SHIFT) & D3D11_SB_OPERAND_MIN_PRECISION_MASK +} +pub const D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK: DWORD = 0x80000000; +pub const D3D10_SB_OPERAND_DOUBLE_EXTENDED_SHIFT: DWORD = 31; +#[inline] +pub fn DECODE_IS_D3D10_SB_OPERAND_DOUBLE_EXTENDED(OperandToken1: DWORD) -> DWORD { + (OperandToken1 & D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK) + >> D3D10_SB_OPERAND_DOUBLE_EXTENDED_SHIFT +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_DOUBLE_EXTENDED(bExtended: DWORD) -> DWORD { + if bExtended != 0 { + D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK + } else { + 0 + } +} +pub const D3D10_SB_NAME_MASK: DWORD = 0x0000ffff; +#[inline] +pub fn DECODE_D3D10_SB_NAME(NameToken: DWORD) -> D3D10_SB_NAME { + (NameToken & D3D10_SB_NAME_MASK) as D3D10_SB_NAME +} +#[inline] +pub fn ENCODE_D3D10_SB_NAME(Name: D3D10_SB_NAME) -> DWORD { + Name & D3D10_SB_NAME_MASK +} +pub const D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED: DWORD = (1 << 11); +pub const D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS: DWORD = (1 << 12); +pub const D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL: DWORD = (1 << 13); +pub const D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS: DWORD = (1 << 14); +pub const D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION: DWORD = (1 << 15); +pub const D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION: DWORD = (1 << 16); +pub const D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS: DWORD = (1 << 17); +pub const D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS: DWORD = (1 << 18); +pub const D3D10_SB_GLOBAL_FLAGS_MASK: DWORD = 0x00fff800; +#[inline] +pub fn DECODE_D3D10_SB_GLOBAL_FLAGS(OpcodeToken0: DWORD) -> DWORD { + OpcodeToken0 & D3D10_SB_GLOBAL_FLAGS_MASK +} +#[inline] +pub fn ENCODE_D3D10_SB_GLOBAL_FLAGS(Flags: DWORD) -> DWORD { + Flags & D3D10_SB_GLOBAL_FLAGS_MASK +} +pub const D3D10_SB_RESOURCE_DIMENSION_MASK: DWORD = 0x0000F800; +pub const D3D10_SB_RESOURCE_DIMENSION_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_RESOURCE_DIMENSION(OpcodeToken0: DWORD) -> D3D10_SB_RESOURCE_DIMENSION { + ((OpcodeToken0 & D3D10_SB_RESOURCE_DIMENSION_MASK) >> D3D10_SB_RESOURCE_DIMENSION_SHIFT) + as D3D10_SB_RESOURCE_DIMENSION +} +#[inline] +pub fn ENCODE_D3D10_SB_RESOURCE_DIMENSION(ResourceDim: D3D10_SB_RESOURCE_DIMENSION) -> DWORD { + (ResourceDim << D3D10_SB_RESOURCE_DIMENSION_SHIFT) & D3D10_SB_RESOURCE_DIMENSION_MASK +} +pub const D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK: DWORD = 0x07F0000; +pub const D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT: DWORD = 16; +#[inline] +pub fn DECODE_D3D10_SB_RESOURCE_SAMPLE_COUNT(OpcodeToken0: DWORD) -> UINT { + ((OpcodeToken0 & D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK) >> D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT) + as UINT +} +#[inline] +pub fn ENCODE_D3D10_SB_RESOURCE_SAMPLE_COUNT(SampleCount: DWORD) -> DWORD { + (if SampleCount > 127 { 127 } else { SampleCount } << D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT) + & D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK +} +#[inline] +pub fn DECODE_D3D10_SB_RESOURCE_RETURN_TYPE( + ResourceReturnTypeToken: D3D10_SB_RESOURCE_RETURN_TYPE, + Component: DWORD, +) -> D3D10_SB_RESOURCE_RETURN_TYPE { + ((ResourceReturnTypeToken >> (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS)) + & D3D10_SB_RESOURCE_RETURN_TYPE_MASK) as D3D10_SB_RESOURCE_RETURN_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_RESOURCE_RETURN_TYPE( + ReturnType: DWORD, + Component: DWORD, +) -> D3D10_SB_RESOURCE_RETURN_TYPE { + (ReturnType & D3D10_SB_RESOURCE_RETURN_TYPE_MASK) + << (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS) +} +ENUM!{enum D3D10_SB_SAMPLER_MODE { + D3D10_SB_SAMPLER_MODE_DEFAULT = 0, + D3D10_SB_SAMPLER_MODE_COMPARISON = 1, + D3D10_SB_SAMPLER_MODE_MONO = 2, +}} +pub const D3D10_SB_SAMPLER_MODE_MASK: DWORD = 0x00007800; +pub const D3D10_SB_SAMPLER_MODE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_SAMPLER_MODE(OpcodeToken0: DWORD) -> D3D10_SB_SAMPLER_MODE { + ((OpcodeToken0 & D3D10_SB_SAMPLER_MODE_MASK) >> D3D10_SB_SAMPLER_MODE_SHIFT) + as D3D10_SB_SAMPLER_MODE +} +#[inline] +pub fn ENCODE_D3D10_SB_SAMPLER_MODE(SamplerMode: D3D10_SB_SAMPLER_MODE) -> DWORD { + (SamplerMode << D3D10_SB_SAMPLER_MODE_SHIFT) & D3D10_SB_SAMPLER_MODE_MASK +} +pub const D3D10_SB_INPUT_INTERPOLATION_MODE_MASK: DWORD = 0x00007800; +pub const D3D10_SB_INPUT_INTERPOLATION_MODE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_INPUT_INTERPOLATION_MODE( + OpcodeToken0: DWORD, +) -> D3D10_SB_INTERPOLATION_MODE { + ((OpcodeToken0 & D3D10_SB_INPUT_INTERPOLATION_MODE_MASK) + >> D3D10_SB_INPUT_INTERPOLATION_MODE_SHIFT) as D3D10_SB_INTERPOLATION_MODE +} +#[inline] +pub fn ENCODE_D3D10_SB_INPUT_INTERPOLATION_MODE( + InterpolationMode: D3D10_SB_INTERPOLATION_MODE, +) -> DWORD { + (InterpolationMode << D3D10_SB_INPUT_INTERPOLATION_MODE_SHIFT) + & D3D10_SB_INPUT_INTERPOLATION_MODE_MASK +} +ENUM!{enum D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN { + D3D10_SB_CONSTANT_BUFFER_IMMEDIATE_INDEXED = 0, + D3D10_SB_CONSTANT_BUFFER_DYNAMIC_INDEXED = 1, +}} +pub const D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK: DWORD = 0x00000800; +pub const D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN( + OpcodeToken0: DWORD, +) -> D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN { + ((OpcodeToken0 & D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK) + >> D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT) + as D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN +} +#[inline] +pub fn ENCODE_D3D10_SB_D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN( + AccessPattern: D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN, +) -> DWORD { + (AccessPattern << D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT) + & D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK +} +ENUM!{enum D3D11_SB_SHADER_MESSAGE_ID { + D3D11_SB_SHADER_MESSAGE_ID_MESSAGE = 0x00200102, + D3D11_SB_SHADER_MESSAGE_ID_ERROR = 0x00200103, +}} +ENUM!{enum D3D11_SB_SHADER_MESSAGE_FORMAT { + D3D11_SB_SHADER_MESSAGE_FORMAT_ANSI_TEXT = 0, + D3D11_SB_SHADER_MESSAGE_FORMAT_ANSI_PRINTF = 1, +}} +pub const D3D10_SB_GS_INPUT_PRIMITIVE_MASK: DWORD = 0x0001f800; +pub const D3D10_SB_GS_INPUT_PRIMITIVE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_GS_INPUT_PRIMITIVE(OpcodeToken0: DWORD) -> D3D10_SB_PRIMITIVE { + ((OpcodeToken0 & D3D10_SB_GS_INPUT_PRIMITIVE_MASK) >> D3D10_SB_GS_INPUT_PRIMITIVE_SHIFT) + as D3D10_SB_PRIMITIVE +} +#[inline] +pub fn ENCODE_D3D10_SB_GS_INPUT_PRIMITIVE(Prim: D3D10_SB_PRIMITIVE) -> DWORD { + (Prim << D3D10_SB_GS_INPUT_PRIMITIVE_SHIFT) & D3D10_SB_GS_INPUT_PRIMITIVE_MASK +} +pub const D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_MASK: DWORD = 0x0001f800; +pub const D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY( + OpcodeToken0: DWORD, +) -> D3D10_SB_PRIMITIVE_TOPOLOGY { + ((OpcodeToken0 & D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_MASK) + >> D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_SHIFT) as D3D10_SB_PRIMITIVE_TOPOLOGY +} +#[inline] +pub fn ENCODE_D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY( + PrimTopology: D3D10_SB_PRIMITIVE_TOPOLOGY, +) -> DWORD { + (PrimTopology << D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_SHIFT) + & D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_MASK +} +pub const D3D11_SB_INPUT_CONTROL_POINT_COUNT_MASK: DWORD = 0x0001f800; +pub const D3D11_SB_INPUT_CONTROL_POINT_COUNT_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_INPUT_CONTROL_POINT_COUNT(OpcodeToken0: DWORD) -> UINT { + ((OpcodeToken0 & D3D11_SB_INPUT_CONTROL_POINT_COUNT_MASK) + >> D3D11_SB_INPUT_CONTROL_POINT_COUNT_SHIFT) as UINT +} +#[inline] +pub fn ENCODE_D3D11_SB_INPUT_CONTROL_POINT_COUNT(Count: DWORD) -> DWORD { + (Count << D3D11_SB_INPUT_CONTROL_POINT_COUNT_SHIFT) & D3D11_SB_INPUT_CONTROL_POINT_COUNT_MASK +} +pub const D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_MASK: DWORD = 0x0001f800; +pub const D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_OUTPUT_CONTROL_POINT_COUNT(OpcodeToken0: DWORD) -> UINT { + ((OpcodeToken0 & D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_MASK) + >> D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_SHIFT) as UINT +} +#[inline] +pub fn ENCODE_D3D11_SB_OUTPUT_CONTROL_POINT_COUNT(Count: DWORD) -> DWORD { + (Count << D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_SHIFT) & D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_MASK +} +ENUM!{enum D3D11_SB_TESSELLATOR_DOMAIN { + D3D11_SB_TESSELLATOR_DOMAIN_UNDEFINED = 0, + D3D11_SB_TESSELLATOR_DOMAIN_ISOLINE = 1, + D3D11_SB_TESSELLATOR_DOMAIN_TRI = 2, + D3D11_SB_TESSELLATOR_DOMAIN_QUAD = 3, +}} +pub const D3D11_SB_TESS_DOMAIN_MASK: DWORD = 0x00001800; +pub const D3D11_SB_TESS_DOMAIN_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_TESS_DOMAIN(OpcodeToken0: DWORD) -> D3D11_SB_TESSELLATOR_DOMAIN { + ((OpcodeToken0 & D3D11_SB_TESS_DOMAIN_MASK) >> D3D11_SB_TESS_DOMAIN_SHIFT) + as D3D11_SB_TESSELLATOR_DOMAIN +} +#[inline] +pub fn ENCODE_D3D11_SB_TESS_DOMAIN(Domain: D3D11_SB_TESSELLATOR_DOMAIN) -> DWORD { + (Domain << D3D11_SB_TESS_DOMAIN_SHIFT) & D3D11_SB_TESS_DOMAIN_MASK +} +ENUM!{enum D3D11_SB_TESSELLATOR_PARTITIONING { + D3D11_SB_TESSELLATOR_PARTITIONING_UNDEFINED = 0, + D3D11_SB_TESSELLATOR_PARTITIONING_INTEGER = 1, + D3D11_SB_TESSELLATOR_PARTITIONING_POW2 = 2, + D3D11_SB_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3, + D3D11_SB_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4, +}} +pub const D3D11_SB_TESS_PARTITIONING_MASK: DWORD = 0x00003800; +pub const D3D11_SB_TESS_PARTITIONING_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_TESS_PARTITIONING( + OpcodeToken0: DWORD, +) -> D3D11_SB_TESSELLATOR_PARTITIONING { + ((OpcodeToken0 & D3D11_SB_TESS_PARTITIONING_MASK) >> D3D11_SB_TESS_PARTITIONING_SHIFT) + as D3D11_SB_TESSELLATOR_PARTITIONING +} +#[inline] +pub fn ENCODE_D3D11_SB_TESS_PARTITIONING( + Partitioning: D3D11_SB_TESSELLATOR_PARTITIONING, +) -> DWORD { + (Partitioning << D3D11_SB_TESS_PARTITIONING_SHIFT) & D3D11_SB_TESS_PARTITIONING_MASK +} +ENUM!{enum D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE { + D3D11_SB_TESSELLATOR_OUTPUT_UNDEFINED = 0, + D3D11_SB_TESSELLATOR_OUTPUT_POINT = 1, + D3D11_SB_TESSELLATOR_OUTPUT_LINE = 2, + D3D11_SB_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3, + D3D11_SB_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4, +}} +pub const D3D11_SB_TESS_OUTPUT_PRIMITIVE_MASK: DWORD = 0x00003800; +pub const D3D11_SB_TESS_OUTPUT_PRIMITIVE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_TESS_OUTPUT_PRIMITIVE( + OpcodeToken0: DWORD, +) -> D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE { + ((OpcodeToken0 & D3D11_SB_TESS_OUTPUT_PRIMITIVE_MASK) >> D3D11_SB_TESS_OUTPUT_PRIMITIVE_SHIFT) + as D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE +} +#[inline] +pub fn ENCODE_D3D11_SB_TESS_OUTPUT_PRIMITIVE( + OutputPrimitive: D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE, +) -> DWORD { + (OutputPrimitive << D3D11_SB_TESS_OUTPUT_PRIMITIVE_SHIFT) & D3D11_SB_TESS_OUTPUT_PRIMITIVE_MASK +} +ENUM!{enum D3D10_SB_INTERPOLATION_MODE { + D3D10_SB_INTERPOLATION_UNDEFINED = 0, + D3D10_SB_INTERPOLATION_CONSTANT = 1, + D3D10_SB_INTERPOLATION_LINEAR = 2, + D3D10_SB_INTERPOLATION_LINEAR_CENTROID = 3, + D3D10_SB_INTERPOLATION_LINEAR_NOPERSPECTIVE = 4, + D3D10_SB_INTERPOLATION_LINEAR_NOPERSPECTIVE_CENTROID = 5, + D3D10_SB_INTERPOLATION_LINEAR_SAMPLE = 6, + D3D10_SB_INTERPOLATION_LINEAR_NOPERSPECTIVE_SAMPLE = 7, +}} +ENUM!{enum D3D10_SB_PRIMITIVE_TOPOLOGY { + D3D10_SB_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, + D3D10_SB_PRIMITIVE_TOPOLOGY_POINTLIST = 1, + D3D10_SB_PRIMITIVE_TOPOLOGY_LINELIST = 2, + D3D10_SB_PRIMITIVE_TOPOLOGY_LINESTRIP = 3, + D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4, + D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5, + D3D10_SB_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10, + D3D10_SB_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ = 11, + D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ = 12, + D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ = 13, +}} +ENUM!{enum D3D10_SB_PRIMITIVE { + D3D10_SB_PRIMITIVE_UNDEFINED = 0, + D3D10_SB_PRIMITIVE_POINT = 1, + D3D10_SB_PRIMITIVE_LINE = 2, + D3D10_SB_PRIMITIVE_TRIANGLE = 3, + D3D10_SB_PRIMITIVE_LINE_ADJ = 6, + D3D10_SB_PRIMITIVE_TRIANGLE_ADJ = 7, + D3D11_SB_PRIMITIVE_1_CONTROL_POINT_PATCH = 8, + D3D11_SB_PRIMITIVE_2_CONTROL_POINT_PATCH = 9, + D3D11_SB_PRIMITIVE_3_CONTROL_POINT_PATCH = 10, + D3D11_SB_PRIMITIVE_4_CONTROL_POINT_PATCH = 11, + D3D11_SB_PRIMITIVE_5_CONTROL_POINT_PATCH = 12, + D3D11_SB_PRIMITIVE_6_CONTROL_POINT_PATCH = 13, + D3D11_SB_PRIMITIVE_7_CONTROL_POINT_PATCH = 14, + D3D11_SB_PRIMITIVE_8_CONTROL_POINT_PATCH = 15, + D3D11_SB_PRIMITIVE_9_CONTROL_POINT_PATCH = 16, + D3D11_SB_PRIMITIVE_10_CONTROL_POINT_PATCH = 17, + D3D11_SB_PRIMITIVE_11_CONTROL_POINT_PATCH = 18, + D3D11_SB_PRIMITIVE_12_CONTROL_POINT_PATCH = 19, + D3D11_SB_PRIMITIVE_13_CONTROL_POINT_PATCH = 20, + D3D11_SB_PRIMITIVE_14_CONTROL_POINT_PATCH = 21, + D3D11_SB_PRIMITIVE_15_CONTROL_POINT_PATCH = 22, + D3D11_SB_PRIMITIVE_16_CONTROL_POINT_PATCH = 23, + D3D11_SB_PRIMITIVE_17_CONTROL_POINT_PATCH = 24, + D3D11_SB_PRIMITIVE_18_CONTROL_POINT_PATCH = 25, + D3D11_SB_PRIMITIVE_19_CONTROL_POINT_PATCH = 26, + D3D11_SB_PRIMITIVE_20_CONTROL_POINT_PATCH = 27, + D3D11_SB_PRIMITIVE_21_CONTROL_POINT_PATCH = 28, + D3D11_SB_PRIMITIVE_22_CONTROL_POINT_PATCH = 29, + D3D11_SB_PRIMITIVE_23_CONTROL_POINT_PATCH = 30, + D3D11_SB_PRIMITIVE_24_CONTROL_POINT_PATCH = 31, + D3D11_SB_PRIMITIVE_25_CONTROL_POINT_PATCH = 32, + D3D11_SB_PRIMITIVE_26_CONTROL_POINT_PATCH = 33, + D3D11_SB_PRIMITIVE_27_CONTROL_POINT_PATCH = 34, + D3D11_SB_PRIMITIVE_28_CONTROL_POINT_PATCH = 35, + D3D11_SB_PRIMITIVE_29_CONTROL_POINT_PATCH = 36, + D3D11_SB_PRIMITIVE_30_CONTROL_POINT_PATCH = 37, + D3D11_SB_PRIMITIVE_31_CONTROL_POINT_PATCH = 38, + D3D11_SB_PRIMITIVE_32_CONTROL_POINT_PATCH = 39, +}} +ENUM!{enum D3D10_SB_COMPONENT_MASK { + D3D10_SB_COMPONENT_MASK_X = 1, + D3D10_SB_COMPONENT_MASK_Y = 2, + D3D10_SB_COMPONENT_MASK_Z = 4, + D3D10_SB_COMPONENT_MASK_W = 8, + D3D10_SB_COMPONENT_MASK_R = 1, + D3D10_SB_COMPONENT_MASK_G = 2, + D3D10_SB_COMPONENT_MASK_B = 4, + D3D10_SB_COMPONENT_MASK_A = 8, + D3D10_SB_COMPONENT_MASK_ALL = 15, +}} +ENUM!{enum D3D10_SB_NAME { + D3D10_SB_NAME_UNDEFINED = 0, + D3D10_SB_NAME_POSITION = 1, + D3D10_SB_NAME_CLIP_DISTANCE = 2, + D3D10_SB_NAME_CULL_DISTANCE = 3, + D3D10_SB_NAME_RENDER_TARGET_ARRAY_INDEX = 4, + D3D10_SB_NAME_VIEWPORT_ARRAY_INDEX = 5, + D3D10_SB_NAME_VERTEX_ID = 6, + D3D10_SB_NAME_PRIMITIVE_ID = 7, + D3D10_SB_NAME_INSTANCE_ID = 8, + D3D10_SB_NAME_IS_FRONT_FACE = 9, + D3D10_SB_NAME_SAMPLE_INDEX = 10, + D3D11_SB_NAME_FINAL_QUAD_U_EQ_0_EDGE_TESSFACTOR = 11, + D3D11_SB_NAME_FINAL_QUAD_V_EQ_0_EDGE_TESSFACTOR = 12, + D3D11_SB_NAME_FINAL_QUAD_U_EQ_1_EDGE_TESSFACTOR = 13, + D3D11_SB_NAME_FINAL_QUAD_V_EQ_1_EDGE_TESSFACTOR = 14, + D3D11_SB_NAME_FINAL_QUAD_U_INSIDE_TESSFACTOR = 15, + D3D11_SB_NAME_FINAL_QUAD_V_INSIDE_TESSFACTOR = 16, + D3D11_SB_NAME_FINAL_TRI_U_EQ_0_EDGE_TESSFACTOR = 17, + D3D11_SB_NAME_FINAL_TRI_V_EQ_0_EDGE_TESSFACTOR = 18, + D3D11_SB_NAME_FINAL_TRI_W_EQ_0_EDGE_TESSFACTOR = 19, + D3D11_SB_NAME_FINAL_TRI_INSIDE_TESSFACTOR = 20, + D3D11_SB_NAME_FINAL_LINE_DETAIL_TESSFACTOR = 21, + D3D11_SB_NAME_FINAL_LINE_DENSITY_TESSFACTOR = 22, +}} +ENUM!{enum D3D10_SB_RESOURCE_DIMENSION { + D3D10_SB_RESOURCE_DIMENSION_UNKNOWN = 0, + D3D10_SB_RESOURCE_DIMENSION_BUFFER = 1, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE1D = 2, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE2D = 3, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE2DMS = 4, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE3D = 5, + D3D10_SB_RESOURCE_DIMENSION_TEXTURECUBE = 6, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE1DARRAY = 7, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE2DARRAY = 8, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE2DMSARRAY = 9, + D3D10_SB_RESOURCE_DIMENSION_TEXTURECUBEARRAY = 10, + D3D11_SB_RESOURCE_DIMENSION_RAW_BUFFER = 11, + D3D11_SB_RESOURCE_DIMENSION_STRUCTURED_BUFFER = 12, +}} +ENUM!{enum D3D10_SB_RESOURCE_RETURN_TYPE { + D3D10_SB_RETURN_TYPE_UNORM = 1, + D3D10_SB_RETURN_TYPE_SNORM = 2, + D3D10_SB_RETURN_TYPE_SINT = 3, + D3D10_SB_RETURN_TYPE_UINT = 4, + D3D10_SB_RETURN_TYPE_FLOAT = 5, + D3D10_SB_RETURN_TYPE_MIXED = 6, + D3D11_SB_RETURN_TYPE_DOUBLE = 7, + D3D11_SB_RETURN_TYPE_CONTINUED = 8, + D3D11_SB_RETURN_TYPE_UNUSED = 9, +}} +ENUM!{enum D3D10_SB_REGISTER_COMPONENT_TYPE { + D3D10_SB_REGISTER_COMPONENT_UNKNOWN = 0, + D3D10_SB_REGISTER_COMPONENT_UINT32 = 1, + D3D10_SB_REGISTER_COMPONENT_SINT32 = 2, + D3D10_SB_REGISTER_COMPONENT_FLOAT32 = 3, +}} +ENUM!{enum D3D10_SB_INSTRUCTION_RETURN_TYPE { + D3D10_SB_INSTRUCTION_RETURN_FLOAT = 0, + D3D10_SB_INSTRUCTION_RETURN_UINT = 1, +}} +pub const D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK: DWORD = 0x00001800; +pub const D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_INSTRUCTION_RETURN_TYPE( + OpcodeToken0: DWORD, +) -> D3D10_SB_INSTRUCTION_RETURN_TYPE { + ((OpcodeToken0 & D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK) + >> D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT) as D3D10_SB_INSTRUCTION_RETURN_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_INSTRUCTION_RETURN_TYPE( + ReturnType: D3D10_SB_INSTRUCTION_RETURN_TYPE, +) -> DWORD { + (ReturnType << D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT) & D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK +} +pub const D3D11_SB_INTERFACE_INDEXED_BIT_MASK: DWORD = 0x00000800; +pub const D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT: DWORD = 11; +pub const D3D11_SB_INTERFACE_TABLE_LENGTH_MASK: DWORD = 0x0000ffff; +pub const D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT: DWORD = 0; +pub const D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK: DWORD = 0xffff0000; +pub const D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT: DWORD = 16; +#[inline] +pub fn DECODE_D3D11_SB_INTERFACE_INDEXED_BIT(OpcodeToken0: DWORD) -> DWORD { + if (OpcodeToken0 & D3D11_SB_INTERFACE_INDEXED_BIT_MASK) >> D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT + != 0 { 1 } else { 0 } +} +#[inline] +pub fn ENCODE_D3D11_SB_INTERFACE_INDEXED_BIT(IndexedBit: DWORD) -> DWORD { + (IndexedBit << D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT) & D3D11_SB_INTERFACE_INDEXED_BIT_MASK +} +#[inline] +pub fn DECODE_D3D11_SB_INTERFACE_TABLE_LENGTH(OpcodeToken0: DWORD) -> UINT { + ((OpcodeToken0 & D3D11_SB_INTERFACE_TABLE_LENGTH_MASK) + >> D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT) as UINT +} +#[inline] +pub fn ENCODE_D3D11_SB_INTERFACE_TABLE_LENGTH(TableLength: DWORD) -> DWORD { + (TableLength << D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT) & D3D11_SB_INTERFACE_TABLE_LENGTH_MASK +} +#[inline] +pub fn DECODE_D3D11_SB_INTERFACE_ARRAY_LENGTH(OpcodeToken0: DWORD) -> UINT { + ((OpcodeToken0 & D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK) + >> D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT) as UINT +} +#[inline] +pub fn ENCODE_D3D11_SB_INTERFACE_ARRAY_LENGTH(ArrayLength: DWORD) -> DWORD { + (ArrayLength << D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT) & D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK +} +pub const D3D11_SB_GLOBALLY_COHERENT_ACCESS: DWORD = 0x00010000; +pub const D3D11_SB_ACCESS_COHERENCY_MASK: DWORD = 0x00010000; +#[inline] +pub fn DECODE_D3D11_SB_ACCESS_COHERENCY_FLAGS(OperandToken0: DWORD) -> DWORD { + OperandToken0 & D3D11_SB_ACCESS_COHERENCY_MASK +} +#[inline] +pub fn ENCODE_D3D11_SB_ACCESS_COHERENCY_FLAGS(Flags: DWORD) -> DWORD { + Flags & D3D11_SB_ACCESS_COHERENCY_MASK +} +pub const D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER: DWORD = 0x00800000; +pub const D3D11_SB_UAV_FLAGS_MASK: DWORD = 0x00800000; +#[inline] +pub fn DECODE_D3D11_SB_UAV_FLAGS(OperandToken0: DWORD) -> DWORD { + OperandToken0 & D3D11_SB_UAV_FLAGS_MASK +} +#[inline] +pub fn ENCODE_D3D11_SB_UAV_FLAGS(Flags: DWORD) -> DWORD { + Flags & D3D11_SB_UAV_FLAGS_MASK +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d12.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d12.rs new file mode 100644 index 0000000..56048d9 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d12.rs @@ -0,0 +1,2722 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_void; +use shared::basetsd::{INT8, LONG_PTR, SIZE_T, UINT16, UINT64, UINT8}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::dxgitype::DXGI_SAMPLE_DESC; +use shared::guiddef::{IID, REFGUID, REFIID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, INT, LPCVOID, UINT}; +use shared::windef::RECT; +use um::d3dcommon::{D3D_FEATURE_LEVEL, D3D_PRIMITIVE, D3D_PRIMITIVE_TOPOLOGY, ID3DBlob}; +use um::minwinbase::SECURITY_ATTRIBUTES; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, LPCSTR, LPCWSTR, LUID}; +pub const D3D12_16BIT_INDEX_STRIP_CUT_VALUE: UINT = 0xffff; +pub const D3D12_32BIT_INDEX_STRIP_CUT_VALUE: UINT = 0xffffffff; +pub const D3D12_8BIT_INDEX_STRIP_CUT_VALUE: UINT = 0xff; +pub const D3D12_APPEND_ALIGNED_ELEMENT: UINT = 0xffffffff; +pub const D3D12_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT: UINT = 9; +pub const D3D12_CLIP_OR_CULL_DISTANCE_COUNT: UINT = 8; +pub const D3D12_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT: UINT = 2; +pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT: UINT = 14; +pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS: UINT = 4; +pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT: UINT = 15; +pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_PARTIAL_UPDATE_EXTENTS_BYTE_ALIGNMENT: UINT = 16; +pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT: UINT = 15; +pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST: UINT = 1; +pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT: UINT = 64; +pub const D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT: UINT = 1; +pub const D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST: UINT = 1; +pub const D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT: UINT = 128; +pub const D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST: UINT = 1; +pub const D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT: UINT = 128; +pub const D3D12_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_COMMONSHADER_SAMPLER_REGISTER_COUNT: UINT = 16; +pub const D3D12_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST: UINT = 1; +pub const D3D12_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_COMMONSHADER_SAMPLER_SLOT_COUNT: UINT = 16; +pub const D3D12_COMMONSHADER_SUBROUTINE_NESTING_LIMIT: UINT = 32; +pub const D3D12_COMMONSHADER_TEMP_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_COMMONSHADER_TEMP_REGISTER_COUNT: UINT = 4096; +pub const D3D12_COMMONSHADER_TEMP_REGISTER_READS_PER_INST: UINT = 3; +pub const D3D12_COMMONSHADER_TEMP_REGISTER_READ_PORTS: UINT = 3; +pub const D3D12_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX: INT = 10; +pub const D3D12_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN: INT = -10; +pub const D3D12_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE: INT = -8; +pub const D3D12_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE: INT = 7; +pub const D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT: UINT = 256; +pub const D3D12_CS_4_X_BUCKET00_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 256; +pub const D3D12_CS_4_X_BUCKET00_MAX_NUM_THREADS_PER_GROUP: UINT = 64; +pub const D3D12_CS_4_X_BUCKET01_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 240; +pub const D3D12_CS_4_X_BUCKET01_MAX_NUM_THREADS_PER_GROUP: UINT = 68; +pub const D3D12_CS_4_X_BUCKET02_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 224; +pub const D3D12_CS_4_X_BUCKET02_MAX_NUM_THREADS_PER_GROUP: UINT = 72; +pub const D3D12_CS_4_X_BUCKET03_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 208; +pub const D3D12_CS_4_X_BUCKET03_MAX_NUM_THREADS_PER_GROUP: UINT = 76; +pub const D3D12_CS_4_X_BUCKET04_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 192; +pub const D3D12_CS_4_X_BUCKET04_MAX_NUM_THREADS_PER_GROUP: UINT = 84; +pub const D3D12_CS_4_X_BUCKET05_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 176; +pub const D3D12_CS_4_X_BUCKET05_MAX_NUM_THREADS_PER_GROUP: UINT = 92; +pub const D3D12_CS_4_X_BUCKET06_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 160; +pub const D3D12_CS_4_X_BUCKET06_MAX_NUM_THREADS_PER_GROUP: UINT = 100; +pub const D3D12_CS_4_X_BUCKET07_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 144; +pub const D3D12_CS_4_X_BUCKET07_MAX_NUM_THREADS_PER_GROUP: UINT = 112; +pub const D3D12_CS_4_X_BUCKET08_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 128; +pub const D3D12_CS_4_X_BUCKET08_MAX_NUM_THREADS_PER_GROUP: UINT = 128; +pub const D3D12_CS_4_X_BUCKET09_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 112; +pub const D3D12_CS_4_X_BUCKET09_MAX_NUM_THREADS_PER_GROUP: UINT = 144; +pub const D3D12_CS_4_X_BUCKET10_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 96; +pub const D3D12_CS_4_X_BUCKET10_MAX_NUM_THREADS_PER_GROUP: UINT = 168; +pub const D3D12_CS_4_X_BUCKET11_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 80; +pub const D3D12_CS_4_X_BUCKET11_MAX_NUM_THREADS_PER_GROUP: UINT = 204; +pub const D3D12_CS_4_X_BUCKET12_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 64; +pub const D3D12_CS_4_X_BUCKET12_MAX_NUM_THREADS_PER_GROUP: UINT = 256; +pub const D3D12_CS_4_X_BUCKET13_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 48; +pub const D3D12_CS_4_X_BUCKET13_MAX_NUM_THREADS_PER_GROUP: UINT = 340; +pub const D3D12_CS_4_X_BUCKET14_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 32; +pub const D3D12_CS_4_X_BUCKET14_MAX_NUM_THREADS_PER_GROUP: UINT = 512; +pub const D3D12_CS_4_X_BUCKET15_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: UINT = 16; +pub const D3D12_CS_4_X_BUCKET15_MAX_NUM_THREADS_PER_GROUP: UINT = 768; +pub const D3D12_CS_4_X_DISPATCH_MAX_THREAD_GROUPS_IN_Z_DIMENSION: UINT = 1; +pub const D3D12_CS_4_X_RAW_UAV_BYTE_ALIGNMENT: UINT = 256; +pub const D3D12_CS_4_X_THREAD_GROUP_MAX_THREADS_PER_GROUP: UINT = 768; +pub const D3D12_CS_4_X_THREAD_GROUP_MAX_X: UINT = 768; +pub const D3D12_CS_4_X_THREAD_GROUP_MAX_Y: UINT = 768; +pub const D3D12_CS_4_X_UAV_REGISTER_COUNT: UINT = 1; +pub const D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION: UINT = 65535; +pub const D3D12_CS_TGSM_REGISTER_COUNT: UINT = 8192; +pub const D3D12_CS_TGSM_REGISTER_READS_PER_INST: UINT = 1; +pub const D3D12_CS_TGSM_RESOURCE_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_CS_TGSM_RESOURCE_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_CS_THREADGROUPID_REGISTER_COMPONENTS: UINT = 3; +pub const D3D12_CS_THREADGROUPID_REGISTER_COUNT: UINT = 1; +pub const D3D12_CS_THREADIDINGROUPFLATTENED_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_CS_THREADIDINGROUPFLATTENED_REGISTER_COUNT: UINT = 1; +pub const D3D12_CS_THREADIDINGROUP_REGISTER_COMPONENTS: UINT = 3; +pub const D3D12_CS_THREADIDINGROUP_REGISTER_COUNT: UINT = 1; +pub const D3D12_CS_THREADID_REGISTER_COMPONENTS: UINT = 3; +pub const D3D12_CS_THREADID_REGISTER_COUNT: UINT = 1; +pub const D3D12_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP: UINT = 1024; +pub const D3D12_CS_THREAD_GROUP_MAX_X: UINT = 1024; +pub const D3D12_CS_THREAD_GROUP_MAX_Y: UINT = 1024; +pub const D3D12_CS_THREAD_GROUP_MAX_Z: UINT = 64; +pub const D3D12_CS_THREAD_GROUP_MIN_X: UINT = 1; +pub const D3D12_CS_THREAD_GROUP_MIN_Y: UINT = 1; +pub const D3D12_CS_THREAD_GROUP_MIN_Z: UINT = 1; +pub const D3D12_CS_THREAD_LOCAL_TEMP_REGISTER_POOL: UINT = 16384; +pub const D3D12_DEFAULT_BLEND_FACTOR_ALPHA: FLOAT = 1.0; +pub const D3D12_DEFAULT_BLEND_FACTOR_BLUE: FLOAT = 1.0; +pub const D3D12_DEFAULT_BLEND_FACTOR_GREEN: FLOAT = 1.0; +pub const D3D12_DEFAULT_BLEND_FACTOR_RED: FLOAT = 1.0; +pub const D3D12_DEFAULT_BORDER_COLOR_COMPONENT: FLOAT = 0.0; +pub const D3D12_DEFAULT_DEPTH_BIAS: UINT = 0; +pub const D3D12_DEFAULT_DEPTH_BIAS_CLAMP: FLOAT = 0.0; +pub const D3D12_DEFAULT_MAX_ANISOTROPY: UINT = 16; +pub const D3D12_DEFAULT_MIP_LOD_BIAS: FLOAT = 0.0; +pub const D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT: UINT = 4194304; +pub const D3D12_DEFAULT_RENDER_TARGET_ARRAY_INDEX: UINT = 0; +pub const D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT: UINT = 65536; +pub const D3D12_DEFAULT_SAMPLE_MASK: UINT = 0xffffffff; +pub const D3D12_DEFAULT_SCISSOR_ENDX: UINT = 0; +pub const D3D12_DEFAULT_SCISSOR_ENDY: UINT = 0; +pub const D3D12_DEFAULT_SCISSOR_STARTX: UINT = 0; +pub const D3D12_DEFAULT_SCISSOR_STARTY: UINT = 0; +pub const D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS: FLOAT = 0.0; +pub const D3D12_DEFAULT_STENCIL_READ_MASK: UINT = 0xff; +pub const D3D12_DEFAULT_STENCIL_REFERENCE: UINT = 0; +pub const D3D12_DEFAULT_STENCIL_WRITE_MASK: UINT = 0xff; +pub const D3D12_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX: UINT = 0; +pub const D3D12_DEFAULT_VIEWPORT_HEIGHT: UINT = 0; +pub const D3D12_DEFAULT_VIEWPORT_MAX_DEPTH: FLOAT = 0.0; +pub const D3D12_DEFAULT_VIEWPORT_MIN_DEPTH: FLOAT = 0.0; +pub const D3D12_DEFAULT_VIEWPORT_TOPLEFTX: UINT = 0; +pub const D3D12_DEFAULT_VIEWPORT_TOPLEFTY: UINT = 0; +pub const D3D12_DEFAULT_VIEWPORT_WIDTH: UINT = 0; +pub const D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND: UINT = 0xffffffff; +pub const D3D12_DRIVER_RESERVED_REGISTER_SPACE_VALUES_END: UINT = 0xfffffff7; +pub const D3D12_DRIVER_RESERVED_REGISTER_SPACE_VALUES_START: UINT = 0xfffffff0; +pub const D3D12_DS_INPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS: UINT = 3968; +pub const D3D12_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_DS_INPUT_CONTROL_POINT_REGISTER_COUNT: UINT = 32; +pub const D3D12_DS_INPUT_CONTROL_POINT_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_DS_INPUT_CONTROL_POINT_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENTS: UINT = 3; +pub const D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_COUNT: UINT = 1; +pub const D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_COUNT: UINT = 32; +pub const D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_COUNT: UINT = 1; +pub const D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_DS_OUTPUT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_DS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_DS_OUTPUT_REGISTER_COUNT: UINT = 32; +pub const D3D12_FLOAT16_FUSED_TOLERANCE_IN_ULP: FLOAT = 0.6; +pub const D3D12_FLOAT32_MAX: FLOAT = 3.402823466e+38; +pub const D3D12_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP: FLOAT = 0.6; +pub const D3D12_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR: FLOAT = 2.4; +pub const D3D12_FLOAT_TO_SRGB_EXPONENT_NUMERATOR: FLOAT = 1.0; +pub const D3D12_FLOAT_TO_SRGB_OFFSET: FLOAT = 0.055; +pub const D3D12_FLOAT_TO_SRGB_SCALE_1: FLOAT = 12.92; +pub const D3D12_FLOAT_TO_SRGB_SCALE_2: FLOAT = 1.055; +pub const D3D12_FLOAT_TO_SRGB_THRESHOLD: FLOAT = 0.0031308; +pub const D3D12_FTOI_INSTRUCTION_MAX_INPUT: FLOAT = 2147483647.999; +pub const D3D12_FTOI_INSTRUCTION_MIN_INPUT: FLOAT = -2147483648.999; +pub const D3D12_FTOU_INSTRUCTION_MAX_INPUT: FLOAT = 4294967295.999; +pub const D3D12_FTOU_INSTRUCTION_MIN_INPUT: FLOAT = 0.0; +pub const D3D12_GS_INPUT_INSTANCE_ID_READS_PER_INST: UINT = 2; +pub const D3D12_GS_INPUT_INSTANCE_ID_READ_PORTS: UINT = 1; +pub const D3D12_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_GS_INPUT_INSTANCE_ID_REGISTER_COUNT: UINT = 1; +pub const D3D12_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_GS_INPUT_PRIM_CONST_REGISTER_COUNT: UINT = 1; +pub const D3D12_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_GS_INPUT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_GS_INPUT_REGISTER_COUNT: UINT = 32; +pub const D3D12_GS_INPUT_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_GS_INPUT_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_GS_INPUT_REGISTER_VERTICES: UINT = 32; +pub const D3D12_GS_MAX_INSTANCE_COUNT: UINT = 32; +pub const D3D12_GS_MAX_OUTPUT_VERTEX_COUNT_ACROSS_INSTANCES: UINT = 1024; +pub const D3D12_GS_OUTPUT_ELEMENTS: UINT = 32; +pub const D3D12_GS_OUTPUT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_GS_OUTPUT_REGISTER_COUNT: UINT = 32; +pub const D3D12_HS_CONTROL_POINT_PHASE_INPUT_REGISTER_COUNT: UINT = 32; +pub const D3D12_HS_CONTROL_POINT_PHASE_OUTPUT_REGISTER_COUNT: UINT = 32; +pub const D3D12_HS_CONTROL_POINT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_HS_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_HS_CONTROL_POINT_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_HS_CONTROL_POINT_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_HS_FORK_PHASE_INSTANCE_COUNT_UPPER_BOUND: UINT = 0xffffffff; +pub const D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COUNT: UINT = 1; +pub const D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COUNT: UINT = 1; +pub const D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_COUNT: UINT = 1; +pub const D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_HS_JOIN_PHASE_INSTANCE_COUNT_UPPER_BOUND: UINT = 0xffffffff; +pub const D3D12_HS_MAXTESSFACTOR_LOWER_BOUND: FLOAT = 1.0; +pub const D3D12_HS_MAXTESSFACTOR_UPPER_BOUND: FLOAT = 64.0; +pub const D3D12_HS_OUTPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS: UINT = 3968; +pub const D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COUNT: UINT = 1; +pub const D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COUNT: UINT = 32; +pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_SCALAR_COMPONENTS: UINT = 128; +pub const D3D12_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES: UINT = 0; +pub const D3D12_IA_DEFAULT_PRIMITIVE_TOPOLOGY: UINT = 0; +pub const D3D12_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES: UINT = 0; +pub const D3D12_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT: UINT = 1; +pub const D3D12_IA_INSTANCE_ID_BIT_COUNT: UINT = 32; +pub const D3D12_IA_INTEGER_ARITHMETIC_BIT_COUNT: UINT = 32; +pub const D3D12_IA_PATCH_MAX_CONTROL_POINT_COUNT: UINT = 32; +pub const D3D12_IA_PRIMITIVE_ID_BIT_COUNT: UINT = 32; +pub const D3D12_IA_VERTEX_ID_BIT_COUNT: UINT = 32; +pub const D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT: UINT = 32; +pub const D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS: UINT = 128; +pub const D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT: UINT = 32; +pub const D3D12_INTEGER_DIVIDE_BY_ZERO_QUOTIENT: UINT = 0xffffffff; +pub const D3D12_INTEGER_DIVIDE_BY_ZERO_REMAINDER: UINT = 0xffffffff; +pub const D3D12_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL: UINT = 0xffffffff; +pub const D3D12_KEEP_UNORDERED_ACCESS_VIEWS: UINT = 0xffffffff; +pub const D3D12_LINEAR_GAMMA: FLOAT = 1.0; +pub const D3D12_MAJOR_VERSION: UINT = 12; +pub const D3D12_MAX_BORDER_COLOR_COMPONENT: FLOAT = 1.0; +pub const D3D12_MAX_DEPTH: FLOAT = 1.0; +pub const D3D12_MAX_LIVE_STATIC_SAMPLERS: UINT = 2032; +pub const D3D12_MAX_MAXANISOTROPY: UINT = 16; +pub const D3D12_MAX_MULTISAMPLE_SAMPLE_COUNT: UINT = 32; +pub const D3D12_MAX_POSITION_VALUE: FLOAT = 3.402823466e+34; +pub const D3D12_MAX_ROOT_COST: UINT = 64; +pub const D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1: UINT = 1000000; +pub const D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_2: UINT = 1000000; +pub const D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE: UINT = 2048; +pub const D3D12_MAX_TEXTURE_DIMENSION_2_TO_EXP: UINT = 17; +pub const D3D12_MINOR_VERSION: UINT = 0; +pub const D3D12_MIN_BORDER_COLOR_COMPONENT: FLOAT = 0.0; +pub const D3D12_MIN_DEPTH: FLOAT = 0.0; +pub const D3D12_MIN_MAXANISOTROPY: UINT = 0; +pub const D3D12_MIP_LOD_BIAS_MAX: FLOAT = 15.99; +pub const D3D12_MIP_LOD_BIAS_MIN: FLOAT = -16.0; +pub const D3D12_MIP_LOD_FRACTIONAL_BIT_COUNT: UINT = 8; +pub const D3D12_MIP_LOD_RANGE_BIT_COUNT: UINT = 8; +pub const D3D12_MULTISAMPLE_ANTIALIAS_LINE_WIDTH: FLOAT = 1.4; +pub const D3D12_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT: UINT = 0; +pub const D3D12_OS_RESERVED_REGISTER_SPACE_VALUES_END: UINT = 0xffffffff; +pub const D3D12_OS_RESERVED_REGISTER_SPACE_VALUES_START: UINT = 0xfffffff8; +pub const D3D12_PACKED_TILE: UINT = 0xffffffff; +pub const D3D12_PIXEL_ADDRESS_RANGE_BIT_COUNT: UINT = 15; +pub const D3D12_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT: UINT = 16; +pub const D3D12_PS_CS_UAV_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_PS_CS_UAV_REGISTER_COUNT: UINT = 8; +pub const D3D12_PS_CS_UAV_REGISTER_READS_PER_INST: UINT = 1; +pub const D3D12_PS_CS_UAV_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_PS_FRONTFACING_DEFAULT_VALUE: UINT = 0xffffffff; +pub const D3D12_PS_FRONTFACING_FALSE_VALUE: UINT = 0; +pub const D3D12_PS_FRONTFACING_TRUE_VALUE: UINT = 0xffffffff; +pub const D3D12_PS_INPUT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_PS_INPUT_REGISTER_COUNT: UINT = 32; +pub const D3D12_PS_INPUT_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_PS_INPUT_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT: FLOAT = 0.0; +pub const D3D12_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_PS_OUTPUT_DEPTH_REGISTER_COUNT: UINT = 1; +pub const D3D12_PS_OUTPUT_MASK_REGISTER_COMPONENTS: UINT = 1; +pub const D3D12_PS_OUTPUT_MASK_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_PS_OUTPUT_MASK_REGISTER_COUNT: UINT = 1; +pub const D3D12_PS_OUTPUT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_PS_OUTPUT_REGISTER_COUNT: UINT = 8; +pub const D3D12_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT: FLOAT = 0.5; +pub const D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT: UINT = 16; +pub const D3D12_REQ_BLEND_OBJECT_COUNT_PER_DEVICE: UINT = 4096; +pub const D3D12_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP: UINT = 27; +pub const D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT: UINT = 4096; +pub const D3D12_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_DEVICE: UINT = 4096; +pub const D3D12_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP: UINT = 32; +pub const D3D12_REQ_DRAW_VERTEX_COUNT_2_TO_EXP: UINT = 32; +pub const D3D12_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION: UINT = 16384; +pub const D3D12_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT: UINT = 1024; +pub const D3D12_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT: UINT = 4096; +pub const D3D12_REQ_MAXANISOTROPY: UINT = 16; +pub const D3D12_REQ_MIP_LEVELS: UINT = 15; +pub const D3D12_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES: UINT = 2048; +pub const D3D12_REQ_RASTERIZER_OBJECT_COUNT_PER_DEVICE: UINT = 4096; +pub const D3D12_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH: UINT = 16384; +pub const D3D12_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_A_TERM: UINT = 128; +pub const D3D12_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_B_TERM: FLOAT = 0.25; +pub const D3D12_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_C_TERM: UINT = 2048; +pub const D3D12_REQ_RESOURCE_VIEW_COUNT_PER_DEVICE_2_TO_EXP: UINT = 20; +pub const D3D12_REQ_SAMPLER_OBJECT_COUNT_PER_DEVICE: UINT = 4096; +pub const D3D12_REQ_SUBRESOURCES: UINT = 30720; +pub const D3D12_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION: UINT = 2048; +pub const D3D12_REQ_TEXTURE1D_U_DIMENSION: UINT = 16384; +pub const D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION: UINT = 2048; +pub const D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION: UINT = 16384; +pub const D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION: UINT = 2048; +pub const D3D12_REQ_TEXTURECUBE_DIMENSION: UINT = 16384; +pub const D3D12_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL: UINT = 0; +pub const D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES: UINT = 0xffffffff; +pub const D3D12_SHADER_MAJOR_VERSION: UINT = 5; +pub const D3D12_SHADER_MAX_INSTANCES: UINT = 65535; +pub const D3D12_SHADER_MAX_INTERFACES: UINT = 253; +pub const D3D12_SHADER_MAX_INTERFACE_CALL_SITES: UINT = 4096; +pub const D3D12_SHADER_MAX_TYPES: UINT = 65535; +pub const D3D12_SHADER_MINOR_VERSION: UINT = 1; +pub const D3D12_SHIFT_INSTRUCTION_PAD_VALUE: UINT = 0; +pub const D3D12_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT: UINT = 5; +pub const D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT: UINT = 8; +pub const D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT: UINT = 65536; +pub const D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT: UINT = 4096; +pub const D3D12_SO_BUFFER_MAX_STRIDE_IN_BYTES: UINT = 2048; +pub const D3D12_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES: UINT = 512; +pub const D3D12_SO_BUFFER_SLOT_COUNT: UINT = 4; +pub const D3D12_SO_DDI_REGISTER_INDEX_DENOTING_GAP: UINT = 0xffffffff; +pub const D3D12_SO_NO_RASTERIZED_STREAM: UINT = 0xffffffff; +pub const D3D12_SO_OUTPUT_COMPONENT_COUNT: UINT = 128; +pub const D3D12_SO_STREAM_COUNT: UINT = 4; +pub const D3D12_SPEC_DATE_DAY: UINT = 14; +pub const D3D12_SPEC_DATE_MONTH: UINT = 11; +pub const D3D12_SPEC_DATE_YEAR: UINT = 2014; +pub const D3D12_SPEC_VERSION: FLOAT = 1.16; +pub const D3D12_SRGB_GAMMA: FLOAT = 2.2; +pub const D3D12_SRGB_TO_FLOAT_DENOMINATOR_1: FLOAT = 12.92; +pub const D3D12_SRGB_TO_FLOAT_DENOMINATOR_2: FLOAT = 1.055; +pub const D3D12_SRGB_TO_FLOAT_EXPONENT: FLOAT = 2.4; +pub const D3D12_SRGB_TO_FLOAT_OFFSET: FLOAT = 0.055; +pub const D3D12_SRGB_TO_FLOAT_THRESHOLD: FLOAT = 0.04045; +pub const D3D12_SRGB_TO_FLOAT_TOLERANCE_IN_ULP: FLOAT = 0.5; +pub const D3D12_STANDARD_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_STANDARD_COMPONENT_BIT_COUNT_DOUBLED: UINT = 64; +pub const D3D12_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE: UINT = 4; +pub const D3D12_STANDARD_PIXEL_COMPONENT_COUNT: UINT = 128; +pub const D3D12_STANDARD_PIXEL_ELEMENT_COUNT: UINT = 32; +pub const D3D12_STANDARD_VECTOR_SIZE: UINT = 4; +pub const D3D12_STANDARD_VERTEX_ELEMENT_COUNT: UINT = 32; +pub const D3D12_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT: UINT = 64; +pub const D3D12_SUBPIXEL_FRACTIONAL_BIT_COUNT: UINT = 8; +pub const D3D12_SUBTEXEL_FRACTIONAL_BIT_COUNT: UINT = 8; +pub const D3D12_SYSTEM_RESERVED_REGISTER_SPACE_VALUES_END: UINT = 0xffffffff; +pub const D3D12_SYSTEM_RESERVED_REGISTER_SPACE_VALUES_START: UINT = 0xfffffff0; +pub const D3D12_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR: UINT = 64; +pub const D3D12_TESSELLATOR_MAX_ISOLINE_DENSITY_TESSELLATION_FACTOR: UINT = 64; +pub const D3D12_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR: UINT = 63; +pub const D3D12_TESSELLATOR_MAX_TESSELLATION_FACTOR: UINT = 64; +pub const D3D12_TESSELLATOR_MIN_EVEN_TESSELLATION_FACTOR: UINT = 2; +pub const D3D12_TESSELLATOR_MIN_ISOLINE_DENSITY_TESSELLATION_FACTOR: UINT = 1; +pub const D3D12_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR: UINT = 1; +pub const D3D12_TEXEL_ADDRESS_RANGE_BIT_COUNT: UINT = 16; +pub const D3D12_TEXTURE_DATA_PITCH_ALIGNMENT: UINT = 256; +pub const D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT: UINT = 512; +pub const D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES: UINT = 65536; +pub const D3D12_UAV_COUNTER_PLACEMENT_ALIGNMENT: UINT = 4096; +pub const D3D12_UAV_SLOT_COUNT: UINT = 64; +pub const D3D12_UNBOUND_MEMORY_ACCESS_RESULT: UINT = 0; +pub const D3D12_VIEWPORT_AND_SCISSORRECT_MAX_INDEX: UINT = 15; +pub const D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE: UINT = 16; +pub const D3D12_VIEWPORT_BOUNDS_MAX: INT = 32767; +pub const D3D12_VIEWPORT_BOUNDS_MIN: INT = -32768; +pub const D3D12_VS_INPUT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_VS_INPUT_REGISTER_COUNT: UINT = 32; +pub const D3D12_VS_INPUT_REGISTER_READS_PER_INST: UINT = 2; +pub const D3D12_VS_INPUT_REGISTER_READ_PORTS: UINT = 1; +pub const D3D12_VS_OUTPUT_REGISTER_COMPONENTS: UINT = 4; +pub const D3D12_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: UINT = 32; +pub const D3D12_VS_OUTPUT_REGISTER_COUNT: UINT = 32; +pub const D3D12_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT: UINT = 10; +pub const D3D12_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP: UINT = 25; +pub const D3D12_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP: UINT = 25; +pub type D3D12_GPU_VIRTUAL_ADDRESS = UINT64; +ENUM!{enum D3D12_COMMAND_LIST_TYPE { + D3D12_COMMAND_LIST_TYPE_DIRECT = 0, + D3D12_COMMAND_LIST_TYPE_BUNDLE = 1, + D3D12_COMMAND_LIST_TYPE_COMPUTE = 2, + D3D12_COMMAND_LIST_TYPE_COPY = 3, +}} +ENUM!{enum D3D12_COMMAND_QUEUE_FLAGS { + D3D12_COMMAND_QUEUE_FLAG_NONE = 0x0, + D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT = 0x1, +}} +ENUM!{enum D3D12_COMMAND_QUEUE_PRIORITY { + D3D12_COMMAND_QUEUE_PRIORITY_NORMAL = 0, + D3D12_COMMAND_QUEUE_PRIORITY_HIGH = 100, + D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME = 10000, +}} +STRUCT!{struct D3D12_COMMAND_QUEUE_DESC { + Type: D3D12_COMMAND_LIST_TYPE, + Priority: INT, + Flags: D3D12_COMMAND_QUEUE_FLAGS, + NodeMask: UINT, +}} +ENUM!{enum D3D12_PRIMITIVE_TOPOLOGY_TYPE { + D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED = 0, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT = 1, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE = 2, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE = 3, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH = 4, +}} +ENUM!{enum D3D12_INPUT_CLASSIFICATION { + D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA = 0, + D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA = 1, +}} +STRUCT!{struct D3D12_INPUT_ELEMENT_DESC { + SemanticName: LPCSTR, + SemanticIndex: UINT, + Format: DXGI_FORMAT, + InputSlot: UINT, + AlignedByteOffset: UINT, + InputSlotClass: D3D12_INPUT_CLASSIFICATION, + InstanceDataStepRate: UINT, +}} +ENUM!{enum D3D12_FILL_MODE { + D3D12_FILL_MODE_WIREFRAME = 2, + D3D12_FILL_MODE_SOLID = 3, +}} +pub type D3D12_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY; +pub type D3D12_PRIMITIVE = D3D_PRIMITIVE; +ENUM!{enum D3D12_CULL_MODE { + D3D12_CULL_MODE_NONE = 1, + D3D12_CULL_MODE_FRONT = 2, + D3D12_CULL_MODE_BACK = 3, +}} +STRUCT!{struct D3D12_SO_DECLARATION_ENTRY { + Stream: UINT, + SemanticName: LPCSTR, + SemanticIndex: UINT, + StartComponent: BYTE, + ComponentCount: BYTE, + OutputSlot: BYTE, +}} +STRUCT!{struct D3D12_VIEWPORT { + TopLeftX: FLOAT, + TopLeftY: FLOAT, + Width: FLOAT, + Height: FLOAT, + MinDepth: FLOAT, + MaxDepth: FLOAT, +}} +pub type D3D12_RECT = RECT; +STRUCT!{struct D3D12_BOX { + left: UINT, + top: UINT, + front: UINT, + right: UINT, + bottom: UINT, + back: UINT, +}} +ENUM!{enum D3D12_COMPARISON_FUNC { + D3D12_COMPARISON_FUNC_NEVER = 1, + D3D12_COMPARISON_FUNC_LESS = 2, + D3D12_COMPARISON_FUNC_EQUAL = 3, + D3D12_COMPARISON_FUNC_LESS_EQUAL = 4, + D3D12_COMPARISON_FUNC_GREATER = 5, + D3D12_COMPARISON_FUNC_NOT_EQUAL = 6, + D3D12_COMPARISON_FUNC_GREATER_EQUAL = 7, + D3D12_COMPARISON_FUNC_ALWAYS = 8, +}} +ENUM!{enum D3D12_DEPTH_WRITE_MASK { + D3D12_DEPTH_WRITE_MASK_ZERO = 0, + D3D12_DEPTH_WRITE_MASK_ALL = 1, +}} +ENUM!{enum D3D12_STENCIL_OP { + D3D12_STENCIL_OP_KEEP = 1, + D3D12_STENCIL_OP_ZERO = 2, + D3D12_STENCIL_OP_REPLACE = 3, + D3D12_STENCIL_OP_INCR_SAT = 4, + D3D12_STENCIL_OP_DECR_SAT = 5, + D3D12_STENCIL_OP_INVERT = 6, + D3D12_STENCIL_OP_INCR = 7, + D3D12_STENCIL_OP_DECR = 8, +}} +STRUCT!{struct D3D12_DEPTH_STENCILOP_DESC { + StencilFailOp: D3D12_STENCIL_OP, + StencilDepthFailOp: D3D12_STENCIL_OP, + StencilPassOp: D3D12_STENCIL_OP, + StencilFunc: D3D12_COMPARISON_FUNC, +}} +STRUCT!{struct D3D12_DEPTH_STENCIL_DESC { + DepthEnable: BOOL, + DepthWriteMask: D3D12_DEPTH_WRITE_MASK, + DepthFunc: D3D12_COMPARISON_FUNC, + StencilEnable: BOOL, + StencilReadMask: UINT8, + StencilWriteMask: UINT8, + FrontFace: D3D12_DEPTH_STENCILOP_DESC, + BackFace: D3D12_DEPTH_STENCILOP_DESC, +}} +STRUCT!{struct D3D12_DEPTH_STENCIL_DESC1 { + DepthEnable: BOOL, + DepthWriteMask: D3D12_DEPTH_WRITE_MASK, + DepthFunc: D3D12_COMPARISON_FUNC, + StencilEnable: BOOL, + StencilReadMask: UINT8, + StencilWriteMask: UINT8, + FrontFace: D3D12_DEPTH_STENCILOP_DESC, + BackFace: D3D12_DEPTH_STENCILOP_DESC, + DepthBoundsTestEnable: BOOL, +}} +ENUM!{enum D3D12_BLEND { + D3D12_BLEND_ZERO = 1, + D3D12_BLEND_ONE = 2, + D3D12_BLEND_SRC_COLOR = 3, + D3D12_BLEND_INV_SRC_COLOR = 4, + D3D12_BLEND_SRC_ALPHA = 5, + D3D12_BLEND_INV_SRC_ALPHA = 6, + D3D12_BLEND_DEST_ALPHA = 7, + D3D12_BLEND_INV_DEST_ALPHA = 8, + D3D12_BLEND_DEST_COLOR = 9, + D3D12_BLEND_INV_DEST_COLOR = 10, + D3D12_BLEND_SRC_ALPHA_SAT = 11, + D3D12_BLEND_BLEND_FACTOR = 14, + D3D12_BLEND_INV_BLEND_FACTOR = 15, + D3D12_BLEND_SRC1_COLOR = 16, + D3D12_BLEND_INV_SRC1_COLOR = 17, + D3D12_BLEND_SRC1_ALPHA = 18, + D3D12_BLEND_INV_SRC1_ALPHA = 19, +}} +ENUM!{enum D3D12_BLEND_OP { + D3D12_BLEND_OP_ADD = 1, + D3D12_BLEND_OP_SUBTRACT = 2, + D3D12_BLEND_OP_REV_SUBTRACT = 3, + D3D12_BLEND_OP_MIN = 4, + D3D12_BLEND_OP_MAX = 5, +}} +ENUM!{enum D3D12_COLOR_WRITE_ENABLE { + D3D12_COLOR_WRITE_ENABLE_RED = 1, + D3D12_COLOR_WRITE_ENABLE_GREEN = 2, + D3D12_COLOR_WRITE_ENABLE_BLUE = 4, + D3D12_COLOR_WRITE_ENABLE_ALPHA = 8, + D3D12_COLOR_WRITE_ENABLE_ALL = D3D12_COLOR_WRITE_ENABLE_RED | D3D12_COLOR_WRITE_ENABLE_GREEN + | D3D12_COLOR_WRITE_ENABLE_BLUE | D3D12_COLOR_WRITE_ENABLE_ALPHA, +}} +ENUM!{enum D3D12_LOGIC_OP { + D3D12_LOGIC_OP_CLEAR = 0, + D3D12_LOGIC_OP_SET = 1, + D3D12_LOGIC_OP_COPY = 2, + D3D12_LOGIC_OP_COPY_INVERTED = 3, + D3D12_LOGIC_OP_NOOP = 4, + D3D12_LOGIC_OP_INVERT = 5, + D3D12_LOGIC_OP_AND = 6, + D3D12_LOGIC_OP_NAND = 7, + D3D12_LOGIC_OP_OR = 8, + D3D12_LOGIC_OP_NOR = 9, + D3D12_LOGIC_OP_XOR = 10, + D3D12_LOGIC_OP_EQUIV = 11, + D3D12_LOGIC_OP_AND_REVERSE = 12, + D3D12_LOGIC_OP_AND_INVERTED = 13, + D3D12_LOGIC_OP_OR_REVERSE = 14, + D3D12_LOGIC_OP_OR_INVERTED = 15, +}} +STRUCT!{struct D3D12_RENDER_TARGET_BLEND_DESC { + BlendEnable: BOOL, + LogicOpEnable: BOOL, + SrcBlend: D3D12_BLEND, + DestBlend: D3D12_BLEND, + BlendOp: D3D12_BLEND_OP, + SrcBlendAlpha: D3D12_BLEND, + DestBlendAlpha: D3D12_BLEND, + BlendOpAlpha: D3D12_BLEND_OP, + LogicOp: D3D12_LOGIC_OP, + RenderTargetWriteMask: UINT8, +}} +STRUCT!{struct D3D12_BLEND_DESC { + AlphaToCoverageEnable: BOOL, + IndependentBlendEnable: BOOL, + RenderTarget: [D3D12_RENDER_TARGET_BLEND_DESC; 8], +}} +ENUM!{enum D3D12_CONSERVATIVE_RASTERIZATION_MODE { + D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF = 0, + D3D12_CONSERVATIVE_RASTERIZATION_MODE_ON = 1, +}} +STRUCT!{struct D3D12_RASTERIZER_DESC { + FillMode: D3D12_FILL_MODE, + CullMode: D3D12_CULL_MODE, + FrontCounterClockwise: BOOL, + DepthBias: INT, + DepthBiasClamp: FLOAT, + SlopeScaledDepthBias: FLOAT, + DepthClipEnable: BOOL, + MultisampleEnable: BOOL, + AntialiasedLineEnable: BOOL, + ForcedSampleCount: UINT, + ConservativeRaster: D3D12_CONSERVATIVE_RASTERIZATION_MODE, +}} +RIDL!{#[uuid(0xc54a6b66, 0x72df, 0x4ee8, 0x8b, 0xe5, 0xa9, 0x46, 0xa1, 0x42, 0x92, 0x14)] +interface ID3D12RootSignature(ID3D12RootSignatureVtbl): + ID3D12DeviceChild(ID3D12DeviceChildVtbl) {}} +STRUCT!{struct D3D12_SHADER_BYTECODE { + pShaderBytecode: *const c_void, + BytecodeLength: SIZE_T, +}} +STRUCT!{struct D3D12_STREAM_OUTPUT_DESC { + pSODeclaration: *const D3D12_SO_DECLARATION_ENTRY, + NumEntries: UINT, + pBufferStrides: *const UINT, + NumStrides: UINT, + RasterizedStream: UINT, +}} +STRUCT!{struct D3D12_INPUT_LAYOUT_DESC { + pInputElementDescs: *const D3D12_INPUT_ELEMENT_DESC, + NumElements: UINT, +}} +ENUM!{enum D3D12_INDEX_BUFFER_STRIP_CUT_VALUE { + D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED = 0, + D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF = 1, + D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF = 2, +}} +STRUCT!{struct D3D12_CACHED_PIPELINE_STATE { + pCachedBlob: *const c_void, + CachedBlobSizeInBytes: SIZE_T, +}} +ENUM!{enum D3D12_PIPELINE_STATE_FLAGS { + D3D12_PIPELINE_STATE_FLAG_NONE = 0, + D3D12_PIPELINE_STATE_FLAG_TOOL_DEBUG = 0x1, +}} +STRUCT!{struct D3D12_GRAPHICS_PIPELINE_STATE_DESC { + pRootSignature: *mut ID3D12RootSignature, + VS: D3D12_SHADER_BYTECODE, + PS: D3D12_SHADER_BYTECODE, + DS: D3D12_SHADER_BYTECODE, + HS: D3D12_SHADER_BYTECODE, + GS: D3D12_SHADER_BYTECODE, + StreamOutput: D3D12_STREAM_OUTPUT_DESC, + BlendState: D3D12_BLEND_DESC, + SampleMask: UINT, + RasterizerState: D3D12_RASTERIZER_DESC, + DepthStencilState: D3D12_DEPTH_STENCIL_DESC, + InputLayout: D3D12_INPUT_LAYOUT_DESC, + IBStripCutValue: D3D12_INDEX_BUFFER_STRIP_CUT_VALUE, + PrimitiveTopologyType: D3D12_PRIMITIVE_TOPOLOGY_TYPE, + NumRenderTargets: UINT, + RTVFormats: [DXGI_FORMAT; 8], + DSVFormat: DXGI_FORMAT, + SampleDesc: DXGI_SAMPLE_DESC, + NodeMask: UINT, + CachedPSO: D3D12_CACHED_PIPELINE_STATE, + Flags: D3D12_PIPELINE_STATE_FLAGS, +}} +STRUCT!{struct D3D12_COMPUTE_PIPELINE_STATE_DESC { + pRootSignature: *mut ID3D12RootSignature, + CS: D3D12_SHADER_BYTECODE, + NodeMask: UINT, + CachedPSO: D3D12_CACHED_PIPELINE_STATE, + Flags: D3D12_PIPELINE_STATE_FLAGS, +}} +STRUCT!{struct D3D12_RT_FORMAT_ARRAY { + RTFormats: [DXGI_FORMAT; 8], + NumRenderTargets: UINT, +}} +STRUCT!{struct D3D12_PIPELINE_STATE_STREAM_DESC { + SizeInBytes: SIZE_T, + pPipelineStateSubobjectStream: *mut c_void, +}} +ENUM!{enum D3D12_PIPELINE_STATE_SUBOBJECT_TYPE { + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE = 0, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS = 1, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS = 2, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS = 3, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS = 4, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS = 5, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS = 6, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT = 7, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND = 8, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK = 9, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER = 10, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL = 11, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT = 12, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE = 13, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY = 14, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS = 15, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT = 16, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC = 17, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK = 18, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO = 19, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS = 20, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1 = 21, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID = 22, +}} +ENUM!{enum D3D12_FEATURE { + D3D12_FEATURE_D3D12_OPTIONS = 0, + D3D12_FEATURE_ARCHITECTURE = 1, + D3D12_FEATURE_FEATURE_LEVELS = 2, + D3D12_FEATURE_FORMAT_SUPPORT = 3, + D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS = 4, + D3D12_FEATURE_FORMAT_INFO = 5, + D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT = 6, + D3D12_FEATURE_SHADER_MODEL = 7, + D3D12_FEATURE_D3D12_OPTIONS1 = 8, + D3D12_FEATURE_ROOT_SIGNATURE = 12, + D3D12_FEATURE_ARCHITECTURE1 = 16, + D3D12_FEATURE_D3D12_OPTIONS2 = 18, + D3D12_FEATURE_SHADER_CACHE = 19, + D3D12_FEATURE_COMMAND_QUEUE_PRIORITY = 20, +}} +ENUM!{enum D3D12_SHADER_MIN_PRECISION_SUPPORT { + D3D12_SHADER_MIN_PRECISION_SUPPORT_NONE = 0, + D3D12_SHADER_MIN_PRECISION_SUPPORT_10_BIT = 0x1, + D3D12_SHADER_MIN_PRECISION_SUPPORT_16_BIT = 0x2, +}} +ENUM!{enum D3D12_TILED_RESOURCES_TIER { + D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED = 0, + D3D12_TILED_RESOURCES_TIER_1 = 1, + D3D12_TILED_RESOURCES_TIER_2 = 2, + D3D12_TILED_RESOURCES_TIER_3 = 3, +}} +ENUM!{enum D3D12_RESOURCE_BINDING_TIER { + D3D12_RESOURCE_BINDING_TIER_1 = 1, + D3D12_RESOURCE_BINDING_TIER_2 = 2, + D3D12_RESOURCE_BINDING_TIER_3 = 3, +}} +ENUM!{enum D3D12_CONSERVATIVE_RASTERIZATION_TIER { + D3D12_CONSERVATIVE_RASTERIZATION_TIER_NOT_SUPPORTED = 0, + D3D12_CONSERVATIVE_RASTERIZATION_TIER_1 = 1, + D3D12_CONSERVATIVE_RASTERIZATION_TIER_2 = 2, + D3D12_CONSERVATIVE_RASTERIZATION_TIER_3 = 3, +}} +ENUM!{enum D3D12_FORMAT_SUPPORT1 { + D3D12_FORMAT_SUPPORT1_NONE = 0, + D3D12_FORMAT_SUPPORT1_BUFFER = 0x1, + D3D12_FORMAT_SUPPORT1_IA_VERTEX_BUFFER = 0x2, + D3D12_FORMAT_SUPPORT1_IA_INDEX_BUFFER = 0x4, + D3D12_FORMAT_SUPPORT1_SO_BUFFER = 0x8, + D3D12_FORMAT_SUPPORT1_TEXTURE1D = 0x10, + D3D12_FORMAT_SUPPORT1_TEXTURE2D = 0x20, + D3D12_FORMAT_SUPPORT1_TEXTURE3D = 0x40, + D3D12_FORMAT_SUPPORT1_TEXTURECUBE = 0x80, + D3D12_FORMAT_SUPPORT1_SHADER_LOAD = 0x100, + D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE = 0x200, + D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE_COMPARISON = 0x400, + D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE_MONO_TEXT = 0x800, + D3D12_FORMAT_SUPPORT1_MIP = 0x1000, + D3D12_FORMAT_SUPPORT1_RENDER_TARGET = 0x4000, + D3D12_FORMAT_SUPPORT1_BLENDABLE = 0x8000, + D3D12_FORMAT_SUPPORT1_DEPTH_STENCIL = 0x10000, + D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RESOLVE = 0x40000, + D3D12_FORMAT_SUPPORT1_DISPLAY = 0x80000, + D3D12_FORMAT_SUPPORT1_CAST_WITHIN_BIT_LAYOUT = 0x100000, + D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RENDERTARGET = 0x200000, + D3D12_FORMAT_SUPPORT1_MULTISAMPLE_LOAD = 0x400000, + D3D12_FORMAT_SUPPORT1_SHADER_GATHER = 0x800000, + D3D12_FORMAT_SUPPORT1_BACK_BUFFER_CAST = 0x1000000, + D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW = 0x2000000, + D3D12_FORMAT_SUPPORT1_SHADER_GATHER_COMPARISON = 0x4000000, + D3D12_FORMAT_SUPPORT1_DECODER_OUTPUT = 0x8000000, + D3D12_FORMAT_SUPPORT1_VIDEO_PROCESSOR_OUTPUT = 0x10000000, + D3D12_FORMAT_SUPPORT1_VIDEO_PROCESSOR_INPUT = 0x20000000, + D3D12_FORMAT_SUPPORT1_VIDEO_ENCODER = 0x40000000, +}} +ENUM!{enum D3D12_FORMAT_SUPPORT2 { + D3D12_FORMAT_SUPPORT2_NONE = 0, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_ADD = 0x1, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS = 0x2, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE = 0x4, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE = 0x8, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX = 0x10, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX = 0x20, + D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD = 0x40, + D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE = 0x80, + D3D12_FORMAT_SUPPORT2_OUTPUT_MERGER_LOGIC_OP = 0x100, + D3D12_FORMAT_SUPPORT2_TILED = 0x200, + D3D12_FORMAT_SUPPORT2_MULTIPLANE_OVERLAY = 0x4000, +}} +ENUM!{enum D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS { + D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_NONE = 0, + D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_TILED_RESOURCE = 0x1, +}} +ENUM!{enum D3D12_CROSS_NODE_SHARING_TIER { + D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED = 0, + D3D12_CROSS_NODE_SHARING_TIER_1_EMULATED = 1, + D3D12_CROSS_NODE_SHARING_TIER_1 = 2, + D3D12_CROSS_NODE_SHARING_TIER_2 = 3, +}} +ENUM!{enum D3D12_RESOURCE_HEAP_TIER { + D3D12_RESOURCE_HEAP_TIER_1 = 1, + D3D12_RESOURCE_HEAP_TIER_2 = 2, +}} +ENUM!{enum D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER { + D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_NOT_SUPPORTED = 0, + D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_1 = 1, + D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_2 = 2, +}} +STRUCT!{struct D3D12_FEATURE_DATA_D3D12_OPTIONS { + DoublePrecisionFloatShaderOps: BOOL, + OutputMergerLogicOp: BOOL, + MinPrecisionSupport: D3D12_SHADER_MIN_PRECISION_SUPPORT, + TiledResourcesTier: D3D12_TILED_RESOURCES_TIER, + ResourceBindingTier: D3D12_RESOURCE_BINDING_TIER, + PSSpecifiedStencilRefSupported: BOOL, + TypedUAVLoadAdditionalFormats: BOOL, + ROVsSupported: BOOL, + ConservativeRasterizationTier: D3D12_CONSERVATIVE_RASTERIZATION_TIER, + MaxGPUVirtualAddressBitsPerResource: UINT, + StandardSwizzle64KBSupported: BOOL, + CrossNodeSharingTier: D3D12_CROSS_NODE_SHARING_TIER, + CrossAdapterRowMajorTextureSupported: BOOL, + VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation: BOOL, + ResourceHeapTier: D3D12_RESOURCE_HEAP_TIER, +}} +STRUCT!{struct D3D12_FEATURE_DATA_D3D12_OPTIONS1 { + WaveOps: BOOL, + WaveLaneCountMin: UINT, + WaveLaneCountMax: UINT, + TotalLaneCount: UINT, + ExpandedComputeResourceStates: BOOL, + Int64ShaderOps: BOOL, +}} +STRUCT!{struct D3D12_FEATURE_DATA_D3D12_OPTIONS2 { + DepthBoundsTestSupported: BOOL, + ProgrammableSamplePositionsTier: D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER, +}} +ENUM!{enum D3D_ROOT_SIGNATURE_VERSION { + D3D_ROOT_SIGNATURE_VERSION_1 = 0x1, + D3D_ROOT_SIGNATURE_VERSION_1_0 = 0x1, + D3D_ROOT_SIGNATURE_VERSION_1_1 = 0x2, +}} +STRUCT!{struct D3D12_FEATURE_DATA_ROOT_SIGNATURE { + HighestVersion: D3D_ROOT_SIGNATURE_VERSION, +}} +STRUCT!{struct D3D12_FEATURE_DATA_ARCHITECTURE { + NodeIndex: UINT, + TileBasedRenderer: BOOL, + UMA: BOOL, + CacheCoherentUMA: BOOL, +}} +STRUCT!{struct D3D12_FEATURE_DATA_ARCHITECTURE1 { + NodeIndex: UINT, + TileBasedRenderer: BOOL, + UMA: BOOL, + CacheCoherentUMA: BOOL, + IsolatedMMU: BOOL, +}} +STRUCT!{struct D3D12_FEATURE_DATA_FEATURE_LEVELS { + NumFeatureLevels: UINT, + pFeatureLevelsRequested: *const D3D_FEATURE_LEVEL, + MaxSupportedFeatureLevel: D3D_FEATURE_LEVEL, +}} +ENUM!{enum D3D_SHADER_MODEL { + D3D_SHADER_MODEL_5_1 = 0x51, + D3D_SHADER_MODEL_6_0 = 0x60, +}} +STRUCT!{struct D3D12_FEATURE_DATA_SHADER_MODEL { + HighestShaderModel: D3D_SHADER_MODEL, +}} +STRUCT!{struct D3D12_FEATURE_DATA_FORMAT_SUPPORT { + Format: DXGI_FORMAT, + Support1: D3D12_FORMAT_SUPPORT1, + Support2: D3D12_FORMAT_SUPPORT2, +}} +STRUCT!{struct D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS { + Format: DXGI_FORMAT, + SampleCount: UINT, + Flags: D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS, + NumQualityLevels: UINT, +}} +STRUCT!{struct D3D12_FEATURE_DATA_FORMAT_INFO { + Format: DXGI_FORMAT, + PlaneCount: UINT8, +}} +STRUCT!{struct D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT { + MaxGPUVirtualAddressBitsPerResource: UINT, + MaxGPUVirtualAddressBitsPerProcess: UINT, +}} +ENUM!{enum D3D12_SHADER_CACHE_SUPPORT_FLAGS { + D3D12_SHADER_CACHE_SUPPORT_NONE = 0, + D3D12_SHADER_CACHE_SUPPORT_SINGLE_PSO = 0x1, + D3D12_SHADER_CACHE_SUPPORT_LIBRARY = 0x2, + D3D12_SHADER_CACHE_SUPPORT_AUTOMATIC_INPROC_CACHE = 0x4, + D3D12_SHADER_CACHE_SUPPORT_AUTOMATIC_DISK_CACHE = 0x8, +}} +STRUCT!{struct D3D12_FEATURE_DATA_SHADER_CACHE { + SupportFlags: D3D12_SHADER_CACHE_SUPPORT_FLAGS, +}} +STRUCT!{struct D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY { + CommandListType: D3D12_COMMAND_LIST_TYPE, + Priority: UINT, + PriorityForTypeIsSupported: BOOL, +}} +STRUCT!{struct D3D12_RESOURCE_ALLOCATION_INFO { + SizeInBytes: UINT64, + Alignment: UINT64, +}} +ENUM!{enum D3D12_HEAP_TYPE { + D3D12_HEAP_TYPE_DEFAULT = 1, + D3D12_HEAP_TYPE_UPLOAD = 2, + D3D12_HEAP_TYPE_READBACK = 3, + D3D12_HEAP_TYPE_CUSTOM = 4, +}} +ENUM!{enum D3D12_CPU_PAGE_PROPERTY { + D3D12_CPU_PAGE_PROPERTY_UNKNOWN = 0, + D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE = 1, + D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE = 2, + D3D12_CPU_PAGE_PROPERTY_WRITE_BACK = 3, +}} +ENUM!{enum D3D12_MEMORY_POOL { + D3D12_MEMORY_POOL_UNKNOWN = 0, + D3D12_MEMORY_POOL_L0 = 1, + D3D12_MEMORY_POOL_L1 = 2, +}} +STRUCT!{struct D3D12_HEAP_PROPERTIES { + Type: D3D12_HEAP_TYPE, + CPUPageProperty: D3D12_CPU_PAGE_PROPERTY, + MemoryPoolPreference: D3D12_MEMORY_POOL, + CreationNodeMask: UINT, + VisibleNodeMask: UINT, +}} +ENUM!{enum D3D12_HEAP_FLAGS { + D3D12_HEAP_FLAG_NONE = 0, + D3D12_HEAP_FLAG_SHARED = 0x1, + D3D12_HEAP_FLAG_DENY_BUFFERS = 0x4, + D3D12_HEAP_FLAG_ALLOW_DISPLAY = 0x8, + D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER = 0x20, + D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES = 0x40, + D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES = 0x80, + D3D12_HEAP_FLAG_HARDWARE_PROTECTED = 0x100, + D3D12_HEAP_FLAG_ALLOW_WRITE_WATCH = 0x200, + D3D12_HEAP_FLAG_ALLOW_ALL_BUFFERS_AND_TEXTURES = 0, + D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS = 0xc0, + D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES = 0x44, + D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES = 0x84, +}} +STRUCT!{struct D3D12_HEAP_DESC { + SizeInBytes: UINT64, + Properties: D3D12_HEAP_PROPERTIES, + Alignment: UINT64, + Flags: D3D12_HEAP_FLAGS, +}} +ENUM!{enum D3D12_RESOURCE_DIMENSION { + D3D12_RESOURCE_DIMENSION_UNKNOWN = 0, + D3D12_RESOURCE_DIMENSION_BUFFER = 1, + D3D12_RESOURCE_DIMENSION_TEXTURE1D = 2, + D3D12_RESOURCE_DIMENSION_TEXTURE2D = 3, + D3D12_RESOURCE_DIMENSION_TEXTURE3D = 4, +}} +ENUM!{enum D3D12_TEXTURE_LAYOUT { + D3D12_TEXTURE_LAYOUT_UNKNOWN = 0, + D3D12_TEXTURE_LAYOUT_ROW_MAJOR = 1, + D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE = 2, + D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE = 3, +}} +ENUM!{enum D3D12_RESOURCE_FLAGS { + D3D12_RESOURCE_FLAG_NONE = 0, + D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET = 0x1, + D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL = 0x2, + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS = 0x4, + D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE = 0x8, + D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER = 0x10, + D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS = 0x20, +}} +STRUCT!{struct D3D12_RESOURCE_DESC { + Dimension: D3D12_RESOURCE_DIMENSION, + Alignment: UINT64, + Width: UINT64, + Height: UINT, + DepthOrArraySize: UINT16, + MipLevels: UINT16, + Format: DXGI_FORMAT, + SampleDesc: DXGI_SAMPLE_DESC, + Layout: D3D12_TEXTURE_LAYOUT, + Flags: D3D12_RESOURCE_FLAGS, +}} +STRUCT!{struct D3D12_DEPTH_STENCIL_VALUE { + Depth: FLOAT, + Stencil: UINT8, +}} +UNION!{union D3D12_CLEAR_VALUE_u { + [u32; 4], + Color Color_mut: [FLOAT; 4], + DepthStencil DepthStencil_mut: D3D12_DEPTH_STENCIL_VALUE, +}} +STRUCT!{struct D3D12_CLEAR_VALUE { + Format: DXGI_FORMAT, + u: D3D12_CLEAR_VALUE_u, +}} +STRUCT!{struct D3D12_RANGE { + Begin: SIZE_T, + End: SIZE_T, +}} +STRUCT!{struct D3D12_RANGE_UINT64 { + Begin: UINT64, + End: UINT64, +}} +STRUCT!{struct D3D12_SUBRESOURCE_RANGE_UINT64 { + Subresource: UINT, + Range: D3D12_RANGE_UINT64, +}} +STRUCT!{struct D3D12_SUBRESOURCE_INFO { + Offset: UINT64, + RowPitch: UINT, + DepthPitch: UINT, +}} +STRUCT!{struct D3D12_TILED_RESOURCE_COORDINATE { + X: UINT, + Y: UINT, + Z: UINT, + Subresource: UINT, +}} +STRUCT!{struct D3D12_TILE_REGION_SIZE { + NumTiles: UINT, + UseBox: BOOL, + Width: UINT, + Height: UINT16, + Depth: UINT16, +}} +ENUM!{enum D3D12_TILE_RANGE_FLAGS { + D3D12_TILE_RANGE_FLAG_NONE = 0, + D3D12_TILE_RANGE_FLAG_NULL = 1, + D3D12_TILE_RANGE_FLAG_SKIP = 2, + D3D12_TILE_RANGE_FLAG_REUSE_SINGLE_TILE = 4, +}} +STRUCT!{struct D3D12_SUBRESOURCE_TILING { + WidthInTiles: UINT, + HeightInTiles: UINT16, + DepthInTiles: UINT16, + StartTileIndexInOverallResource: UINT, +}} +STRUCT!{struct D3D12_TILE_SHAPE { + WidthInTexels: UINT, + HeightInTexels: UINT, + DepthInTexels: UINT, +}} +STRUCT!{struct D3D12_PACKED_MIP_INFO { + NumStandardMips: UINT8, + NumPackedMips: UINT8, + NumTilesForPackedMips: UINT, + StartTileIndexInOverallResource: UINT, +}} +ENUM!{enum D3D12_TILE_MAPPING_FLAGS { + D3D12_TILE_MAPPING_FLAG_NONE = 0, + D3D12_TILE_MAPPING_FLAG_NO_HAZARD = 0x1, +}} +ENUM!{enum D3D12_TILE_COPY_FLAGS { + D3D12_TILE_COPY_FLAG_NONE = 0, + D3D12_TILE_COPY_FLAG_NO_HAZARD = 0x1, + D3D12_TILE_COPY_FLAG_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 0x2, + D3D12_TILE_COPY_FLAG_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER = 0x4, +}} +ENUM!{enum D3D12_RESOURCE_STATES { + D3D12_RESOURCE_STATE_COMMON = 0, + D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER = 0x1, + D3D12_RESOURCE_STATE_INDEX_BUFFER = 0x2, + D3D12_RESOURCE_STATE_RENDER_TARGET = 0x4, + D3D12_RESOURCE_STATE_UNORDERED_ACCESS = 0x8, + D3D12_RESOURCE_STATE_DEPTH_WRITE = 0x10, + D3D12_RESOURCE_STATE_DEPTH_READ = 0x20, + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE = 0x40, + D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE = 0x80, + D3D12_RESOURCE_STATE_STREAM_OUT = 0x100, + D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT = 0x200, + D3D12_RESOURCE_STATE_COPY_DEST = 0x400, + D3D12_RESOURCE_STATE_COPY_SOURCE = 0x800, + D3D12_RESOURCE_STATE_RESOLVE_DEST = 0x1000, + D3D12_RESOURCE_STATE_RESOLVE_SOURCE = 0x2000, + D3D12_RESOURCE_STATE_GENERIC_READ = 0x1 | 0x2 | 0x40 | 0x80 | 0x200 | 0x800, + D3D12_RESOURCE_STATE_PRESENT = 0, + D3D12_RESOURCE_STATE_PREDICATION = 0x200, +}} +ENUM!{enum D3D12_RESOURCE_BARRIER_TYPE { + D3D12_RESOURCE_BARRIER_TYPE_TRANSITION = 0, + D3D12_RESOURCE_BARRIER_TYPE_ALIASING = 1, + D3D12_RESOURCE_BARRIER_TYPE_UAV = 2, +}} +STRUCT!{struct D3D12_RESOURCE_TRANSITION_BARRIER { + pResource: *mut ID3D12Resource, + Subresource: UINT, + StateBefore: D3D12_RESOURCE_STATES, + StateAfter: D3D12_RESOURCE_STATES, +}} +STRUCT!{struct D3D12_RESOURCE_ALIASING_BARRIER { + pResourceBefore: *mut ID3D12Resource, + pResourceAfter: *mut ID3D12Resource, +}} +STRUCT!{struct D3D12_RESOURCE_UAV_BARRIER { + pResource: *mut ID3D12Resource, +}} +ENUM!{enum D3D12_RESOURCE_BARRIER_FLAGS { + D3D12_RESOURCE_BARRIER_FLAG_NONE = 0x0, + D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY = 0x1, + D3D12_RESOURCE_BARRIER_FLAG_END_ONLY = 0x2, +}} +UNION!{union D3D12_RESOURCE_BARRIER_u { + [u32; 4] [u64; 3], + Transition Transition_mut: D3D12_RESOURCE_TRANSITION_BARRIER, + Aliasing Aliasing_mut: D3D12_RESOURCE_ALIASING_BARRIER, + UAV UAV_mut: D3D12_RESOURCE_UAV_BARRIER, +}} +STRUCT!{struct D3D12_RESOURCE_BARRIER { + Type: D3D12_RESOURCE_BARRIER_TYPE, + Flags: D3D12_RESOURCE_BARRIER_FLAGS, + u: D3D12_RESOURCE_BARRIER_u, +}} +STRUCT!{struct D3D12_SUBRESOURCE_FOOTPRINT { + Format: DXGI_FORMAT, + Width: UINT, + Height: UINT, + Depth: UINT, + RowPitch: UINT, +}} +STRUCT!{struct D3D12_PLACED_SUBRESOURCE_FOOTPRINT { + Offset: UINT64, + Footprint: D3D12_SUBRESOURCE_FOOTPRINT, +}} +ENUM!{enum D3D12_TEXTURE_COPY_TYPE { + D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX = 0, + D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT = 1, +}} +UNION!{union D3D12_TEXTURE_COPY_LOCATION_u { + [u64; 4], + PlacedFootprint PlacedFootprint_mut: D3D12_PLACED_SUBRESOURCE_FOOTPRINT, + SubresourceIndex SubresourceIndex_mut: UINT, +}} +STRUCT!{struct D3D12_TEXTURE_COPY_LOCATION { + pResource: *mut ID3D12Resource, + Type: D3D12_TEXTURE_COPY_TYPE, + u: D3D12_TEXTURE_COPY_LOCATION_u, +}} +ENUM!{enum D3D12_RESOLVE_MODE { + D3D12_RESOLVE_MODE_DECOMPRESS = 0, + D3D12_RESOLVE_MODE_MIN = 1, + D3D12_RESOLVE_MODE_MAX = 2, + D3D12_RESOLVE_MODE_AVERAGE = 3, +}} +STRUCT!{struct D3D12_SAMPLE_POSITION { + X: INT8, + Y: INT8, +}} +ENUM!{enum D3D12_SHADER_COMPONENT_MAPPING { + D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0 = 0, + D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1 = 1, + D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2 = 2, + D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3 = 3, + D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0 = 4, + D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1 = 5, +}} +pub const D3D12_SHADER_COMPONENT_MAPPING_MASK: UINT = 0x7; +pub const D3D12_SHADER_COMPONENT_MAPPING_SHIFT: UINT = 3; +pub const D3D12_SHADER_COMPONENT_MAPPING_ALWAYS_SET_BIT_AVOIDING_ZEROMEM_MISTAKES: UINT = 1 + << (D3D12_SHADER_COMPONENT_MAPPING_SHIFT * 4); +// D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING +// D3D12_DECODE_SHADER_4_COMPONENT_MAPPING +// D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING +ENUM!{enum D3D12_BUFFER_SRV_FLAGS { + D3D12_BUFFER_SRV_FLAG_NONE = 0x0, + D3D12_BUFFER_SRV_FLAG_RAW = 0x1, +}} +STRUCT!{struct D3D12_BUFFER_SRV { + FirstElement: UINT64, + NumElements: UINT, + StructureByteStride: UINT, + Flags: D3D12_BUFFER_SRV_FLAGS, +}} +STRUCT!{struct D3D12_TEX1D_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, + ResourceMinLODClamp: FLOAT, +}} +STRUCT!{struct D3D12_TEX1D_ARRAY_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, + ResourceMinLODClamp: FLOAT, +}} +STRUCT!{struct D3D12_TEX2D_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, + PlaneSlice: UINT, + ResourceMinLODClamp: FLOAT, +}} +STRUCT!{struct D3D12_TEX2D_ARRAY_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, + PlaneSlice: UINT, + ResourceMinLODClamp: FLOAT, +}} +STRUCT!{struct D3D12_TEX3D_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, + ResourceMinLODClamp: FLOAT, +}} +STRUCT!{struct D3D12_TEXCUBE_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, + ResourceMinLODClamp: FLOAT, +}} +STRUCT!{struct D3D12_TEXCUBE_ARRAY_SRV { + MostDetailedMip: UINT, + MipLevels: UINT, + First2DArrayFace: UINT, + NumCubes: UINT, + ResourceMinLODClamp: FLOAT, +}} +STRUCT!{struct D3D12_TEX2DMS_SRV { + UnusedField_NothingToDefine: UINT, +}} +STRUCT!{struct D3D12_TEX2DMS_ARRAY_SRV { + FirstArraySlice: UINT, + ArraySize: UINT, +}} +ENUM!{enum D3D12_SRV_DIMENSION { + D3D12_SRV_DIMENSION_UNKNOWN = 0, + D3D12_SRV_DIMENSION_BUFFER = 1, + D3D12_SRV_DIMENSION_TEXTURE1D = 2, + D3D12_SRV_DIMENSION_TEXTURE1DARRAY = 3, + D3D12_SRV_DIMENSION_TEXTURE2D = 4, + D3D12_SRV_DIMENSION_TEXTURE2DARRAY = 5, + D3D12_SRV_DIMENSION_TEXTURE2DMS = 6, + D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY = 7, + D3D12_SRV_DIMENSION_TEXTURE3D = 8, + D3D12_SRV_DIMENSION_TEXTURECUBE = 9, + D3D12_SRV_DIMENSION_TEXTURECUBEARRAY = 10, +}} +UNION!{union D3D12_SHADER_RESOURCE_VIEW_DESC_u { + [u64; 3], + Buffer Buffer_mut: D3D12_BUFFER_SRV, + Texture1D Texture1D_mut: D3D12_TEX1D_SRV, + Texture1DArray Texture1DArray_mut: D3D12_TEX1D_ARRAY_SRV, + Texture2D Texture2D_mut: D3D12_TEX2D_SRV, + Texture2DArray Texture2DArray_mut: D3D12_TEX2D_ARRAY_SRV, + Texture2DMS Texture2DMS_mut: D3D12_TEX2DMS_SRV, + Texture2DMSArray Texture2DMSArray_mut: D3D12_TEX2DMS_ARRAY_SRV, + Texture3D Texture3D_mut: D3D12_TEX3D_SRV, + TextureCube TextureCube_mut: D3D12_TEXCUBE_SRV, + TextureCubeArray TextureCubeArray_mut: D3D12_TEXCUBE_ARRAY_SRV, +}} +STRUCT!{struct D3D12_SHADER_RESOURCE_VIEW_DESC { + Format: DXGI_FORMAT, + ViewDimension: D3D12_SRV_DIMENSION, + Shader4ComponentMapping: UINT, + u: D3D12_SHADER_RESOURCE_VIEW_DESC_u, +}} +STRUCT!{struct D3D12_CONSTANT_BUFFER_VIEW_DESC { + BufferLocation: D3D12_GPU_VIRTUAL_ADDRESS, + SizeInBytes: UINT, +}} +ENUM!{enum D3D12_FILTER { + D3D12_FILTER_MIN_MAG_MIP_POINT = 0, + D3D12_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1, + D3D12_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4, + D3D12_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x5, + D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, + D3D12_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, + D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, + D3D12_FILTER_MIN_MAG_MIP_LINEAR = 0x15, + D3D12_FILTER_ANISOTROPIC = 0x55, + D3D12_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x80, + D3D12_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81, + D3D12_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84, + D3D12_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85, + D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90, + D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91, + D3D12_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94, + D3D12_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, + D3D12_FILTER_COMPARISON_ANISOTROPIC = 0xd5, + D3D12_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 0x100, + D3D12_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x101, + D3D12_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x104, + D3D12_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x105, + D3D12_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x110, + D3D12_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x111, + D3D12_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x114, + D3D12_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR = 0x115, + D3D12_FILTER_MINIMUM_ANISOTROPIC = 0x155, + D3D12_FILTER_MAXIMUM_MIN_MAG_MIP_POINT = 0x180, + D3D12_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x181, + D3D12_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x184, + D3D12_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x185, + D3D12_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x190, + D3D12_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x191, + D3D12_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x194, + D3D12_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR = 0x195, + D3D12_FILTER_MAXIMUM_ANISOTROPIC = 0x1d5, +}} +ENUM!{enum D3D12_FILTER_TYPE { + D3D12_FILTER_TYPE_POINT = 0, + D3D12_FILTER_TYPE_LINEAR = 1, +}} +ENUM!{enum D3D12_FILTER_REDUCTION_TYPE { + D3D12_FILTER_REDUCTION_TYPE_STANDARD = 0, + D3D12_FILTER_REDUCTION_TYPE_COMPARISON = 1, + D3D12_FILTER_REDUCTION_TYPE_MINIMUM = 2, + D3D12_FILTER_REDUCTION_TYPE_MAXIMUM = 3, +}} +pub const D3D12_FILTER_REDUCTION_TYPE_MASK: UINT = 0x3; +pub const D3D12_FILTER_REDUCTION_TYPE_SHIFT: UINT = 7; +pub const D3D12_FILTER_TYPE_MASK: UINT = 0x3; +pub const D3D12_MIN_FILTER_SHIFT: UINT = 4; +pub const D3D12_MAG_FILTER_SHIFT: UINT = 2; +pub const D3D12_MIP_FILTER_SHIFT: UINT = 0; +pub const D3D12_ANISOTROPIC_FILTERING_BIT: UINT = 0x40; +// D3D12_ENCODE_BASIC_FILTER +// D3D12_ENCODE_ANISOTROPIC_FILTER +// D3D12_DECODE_MIN_FILTER +// D3D12_DECODE_MAG_FILTER +// D3D12_DECODE_MIP_FILTER +// D3D12_DECODE_FILTER_REDUCTION +// D3D12_DECODE_IS_COMPARISON_FILTER +// D3D12_DECODE_IS_ANISOTROPIC_FILTER +ENUM!{enum D3D12_TEXTURE_ADDRESS_MODE { + D3D12_TEXTURE_ADDRESS_MODE_WRAP = 1, + D3D12_TEXTURE_ADDRESS_MODE_MIRROR = 2, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP = 3, + D3D12_TEXTURE_ADDRESS_MODE_BORDER = 4, + D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE = 5, +}} +STRUCT!{struct D3D12_SAMPLER_DESC { + Filter: D3D12_FILTER, + AddressU: D3D12_TEXTURE_ADDRESS_MODE, + AddressV: D3D12_TEXTURE_ADDRESS_MODE, + AddressW: D3D12_TEXTURE_ADDRESS_MODE, + MipLODBias: FLOAT, + MaxAnisotropy: UINT, + ComparisonFunc: D3D12_COMPARISON_FUNC, + BorderColor: [FLOAT; 4], + MinLOD: FLOAT, + MaxLOD: FLOAT, +}} +ENUM!{enum D3D12_BUFFER_UAV_FLAGS { + D3D12_BUFFER_UAV_FLAG_NONE = 0, + D3D12_BUFFER_UAV_FLAG_RAW = 0x1, +}} +STRUCT!{struct D3D12_BUFFER_UAV { + FirstElement: UINT64, + NumElements: UINT, + StructureByteStride: UINT, + CounterOffsetInBytes: UINT64, + Flags: D3D12_BUFFER_UAV_FLAGS, +}} +STRUCT!{struct D3D12_TEX1D_UAV { + MipSlice: UINT, +}} +STRUCT!{struct D3D12_TEX1D_ARRAY_UAV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D12_TEX2D_UAV { + MipSlice: UINT, + PlaneSlice: UINT, +}} +STRUCT!{struct D3D12_TEX2D_ARRAY_UAV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, + PlaneSlice: UINT, +}} +STRUCT!{struct D3D12_TEX3D_UAV { + MipSlice: UINT, + FirstWSlice: UINT, + WSize: UINT, +}} +ENUM!{enum D3D12_UAV_DIMENSION { + D3D12_UAV_DIMENSION_UNKNOWN = 0, + D3D12_UAV_DIMENSION_BUFFER = 1, + D3D12_UAV_DIMENSION_TEXTURE1D = 2, + D3D12_UAV_DIMENSION_TEXTURE1DARRAY = 3, + D3D12_UAV_DIMENSION_TEXTURE2D = 4, + D3D12_UAV_DIMENSION_TEXTURE2DARRAY = 5, + D3D12_UAV_DIMENSION_TEXTURE3D = 8, +}} +UNION!{union D3D12_UNORDERED_ACCESS_VIEW_DESC_u { + [u64; 4], + Buffer Buffer_mut: D3D12_BUFFER_UAV, + Texture1D Texture1D_mut: D3D12_TEX1D_UAV, + Texture1DArray Texture1DArray_mut: D3D12_TEX1D_ARRAY_UAV, + Texture2D Texture2D_mut: D3D12_TEX2D_UAV, + Texture2DArray Texture2DArray_mut: D3D12_TEX2D_ARRAY_UAV, + Texture3D Texture3D_mut: D3D12_TEX3D_UAV, +}} +STRUCT!{struct D3D12_UNORDERED_ACCESS_VIEW_DESC { + Format: DXGI_FORMAT, + ViewDimension: D3D12_UAV_DIMENSION, + u: D3D12_UNORDERED_ACCESS_VIEW_DESC_u, +}} +STRUCT!{struct D3D12_BUFFER_RTV { + FirstElement: UINT64, + NumElements: UINT, +}} +STRUCT!{struct D3D12_TEX1D_RTV { + MipSlice: UINT, +}} +STRUCT!{struct D3D12_TEX1D_ARRAY_RTV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D12_TEX2D_RTV { + MipSlice: UINT, + PlaneSlice: UINT, +}} +STRUCT!{struct D3D12_TEX2DMS_RTV { + UnusedField_NothingToDefine: UINT, +}} +STRUCT!{struct D3D12_TEX2D_ARRAY_RTV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, + PlaneSlice: UINT, +}} +STRUCT!{struct D3D12_TEX2DMS_ARRAY_RTV { + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D12_TEX3D_RTV { + MipSlice: UINT, + FirstWSlice: UINT, + WSize: UINT, +}} +ENUM!{enum D3D12_RTV_DIMENSION { + D3D12_RTV_DIMENSION_UNKNOWN = 0, + D3D12_RTV_DIMENSION_BUFFER = 1, + D3D12_RTV_DIMENSION_TEXTURE1D = 2, + D3D12_RTV_DIMENSION_TEXTURE1DARRAY = 3, + D3D12_RTV_DIMENSION_TEXTURE2D = 4, + D3D12_RTV_DIMENSION_TEXTURE2DARRAY = 5, + D3D12_RTV_DIMENSION_TEXTURE2DMS = 6, + D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY = 7, + D3D12_RTV_DIMENSION_TEXTURE3D = 8, +}} +UNION!{union D3D12_RENDER_TARGET_VIEW_DESC_u { + [u64; 2], + Buffer Buffer_mut: D3D12_BUFFER_RTV, + Texture1D Texture1D_mut: D3D12_TEX1D_RTV, + Texture1DArray Texture1DArray_mut: D3D12_TEX1D_ARRAY_RTV, + Texture2D Texture2D_mut: D3D12_TEX2D_RTV, + Texture2DArray Texture2DArray_mut: D3D12_TEX2D_ARRAY_RTV, + Texture2DMS Texture2DMS_mut: D3D12_TEX2DMS_RTV, + Texture2DMSArray Texture2DMSArray_mut: D3D12_TEX2DMS_ARRAY_RTV, + Texture3D Texture3D_mut: D3D12_TEX3D_RTV, +}} +STRUCT!{struct D3D12_RENDER_TARGET_VIEW_DESC { + Format: DXGI_FORMAT, + ViewDimension: D3D12_RTV_DIMENSION, + u: D3D12_RENDER_TARGET_VIEW_DESC_u, +}} +STRUCT!{struct D3D12_TEX1D_DSV { + MipSlice: UINT, +}} +STRUCT!{struct D3D12_TEX1D_ARRAY_DSV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D12_TEX2D_DSV { + MipSlice: UINT, +}} +STRUCT!{struct D3D12_TEX2D_ARRAY_DSV { + MipSlice: UINT, + FirstArraySlice: UINT, + ArraySize: UINT, +}} +STRUCT!{struct D3D12_TEX2DMS_DSV { + UnusedField_NothingToDefine: UINT, +}} +STRUCT!{struct D3D12_TEX2DMS_ARRAY_DSV { + FirstArraySlice: UINT, + ArraySize: UINT, +}} +ENUM!{enum D3D12_DSV_FLAGS { + D3D12_DSV_FLAG_NONE = 0x0, + D3D12_DSV_FLAG_READ_ONLY_DEPTH = 0x1, + D3D12_DSV_FLAG_READ_ONLY_STENCIL = 0x2, +}} +ENUM!{enum D3D12_DSV_DIMENSION { + D3D12_DSV_DIMENSION_UNKNOWN = 0, + D3D12_DSV_DIMENSION_TEXTURE1D = 1, + D3D12_DSV_DIMENSION_TEXTURE1DARRAY = 2, + D3D12_DSV_DIMENSION_TEXTURE2D = 3, + D3D12_DSV_DIMENSION_TEXTURE2DARRAY = 4, + D3D12_DSV_DIMENSION_TEXTURE2DMS = 5, + D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY = 6, +}} +UNION!{union D3D12_DEPTH_STENCIL_VIEW_DESC_u { + [u32; 3], + Texture1D Texture1D_mut: D3D12_TEX1D_DSV, + Texture1DArray Texture1DArray_mut: D3D12_TEX1D_ARRAY_DSV, + Texture2D Texture2D_mut: D3D12_TEX2D_DSV, + Texture2DArray Texture2DArray_mut: D3D12_TEX2D_ARRAY_DSV, + Texture2DMS Texture2DMS_mut: D3D12_TEX2DMS_DSV, + Texture2DMSArray Texture2DMSArray_mut: D3D12_TEX2DMS_ARRAY_DSV, +}} +STRUCT!{struct D3D12_DEPTH_STENCIL_VIEW_DESC { + Format: DXGI_FORMAT, + ViewDimension: D3D12_DSV_DIMENSION, + Flags: D3D12_DSV_FLAGS, + u: D3D12_DEPTH_STENCIL_VIEW_DESC_u, +}} +ENUM!{enum D3D12_CLEAR_FLAGS { + D3D12_CLEAR_FLAG_DEPTH = 0x1, + D3D12_CLEAR_FLAG_STENCIL = 0x2, +}} +ENUM!{enum D3D12_FENCE_FLAGS { + D3D12_FENCE_FLAG_NONE = 0x0, + D3D12_FENCE_FLAG_SHARED = 0x1, + D3D12_FENCE_FLAG_SHARED_CROSS_ADAPTER = 0x2, +}} +ENUM!{enum D3D12_DESCRIPTOR_HEAP_TYPE { + D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV = 0, + D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER = 1, + D3D12_DESCRIPTOR_HEAP_TYPE_RTV = 2, + D3D12_DESCRIPTOR_HEAP_TYPE_DSV = 3, + D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES = 4, +}} +ENUM!{enum D3D12_DESCRIPTOR_HEAP_FLAGS { + D3D12_DESCRIPTOR_HEAP_FLAG_NONE = 0x0, + D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE = 0x1, +}} +STRUCT!{struct D3D12_DESCRIPTOR_HEAP_DESC { + Type: D3D12_DESCRIPTOR_HEAP_TYPE, + NumDescriptors: UINT, + Flags: D3D12_DESCRIPTOR_HEAP_FLAGS, + NodeMask: UINT, +}} +ENUM!{enum D3D12_DESCRIPTOR_RANGE_TYPE { + D3D12_DESCRIPTOR_RANGE_TYPE_SRV = 0, + D3D12_DESCRIPTOR_RANGE_TYPE_UAV = 1, + D3D12_DESCRIPTOR_RANGE_TYPE_CBV = 2, + D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER = 3, +}} +STRUCT!{struct D3D12_DESCRIPTOR_RANGE { + RangeType: D3D12_DESCRIPTOR_RANGE_TYPE, + NumDescriptors: UINT, + BaseShaderRegister: UINT, + RegisterSpace: UINT, + OffsetInDescriptorsFromTableStart: UINT, +}} +STRUCT!{struct D3D12_ROOT_DESCRIPTOR_TABLE { + NumDescriptorRanges: UINT, + pDescriptorRanges: *const D3D12_DESCRIPTOR_RANGE, +}} +STRUCT!{struct D3D12_ROOT_CONSTANTS { + ShaderRegister: UINT, + RegisterSpace: UINT, + Num32BitValues: UINT, +}} +STRUCT!{struct D3D12_ROOT_DESCRIPTOR { + ShaderRegister: UINT, + RegisterSpace: UINT, +}} +ENUM!{enum D3D12_SHADER_VISIBILITY { + D3D12_SHADER_VISIBILITY_ALL = 0, + D3D12_SHADER_VISIBILITY_VERTEX = 1, + D3D12_SHADER_VISIBILITY_HULL = 2, + D3D12_SHADER_VISIBILITY_DOMAIN = 3, + D3D12_SHADER_VISIBILITY_GEOMETRY = 4, + D3D12_SHADER_VISIBILITY_PIXEL = 5, +}} +ENUM!{enum D3D12_ROOT_PARAMETER_TYPE { + D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE = 0, + D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS = 1, + D3D12_ROOT_PARAMETER_TYPE_CBV = 2, + D3D12_ROOT_PARAMETER_TYPE_SRV = 3, + D3D12_ROOT_PARAMETER_TYPE_UAV = 4, +}} +UNION!{union D3D12_ROOT_PARAMETER_u { + [u32; 3] [u64; 2], + DescriptorTable DescriptorTable_mut: D3D12_ROOT_DESCRIPTOR_TABLE, + Constants Constants_mut: D3D12_ROOT_CONSTANTS, + Descriptor Descriptor_mut: D3D12_ROOT_DESCRIPTOR, +}} +STRUCT!{struct D3D12_ROOT_PARAMETER { + ParameterType: D3D12_ROOT_PARAMETER_TYPE, + u: D3D12_ROOT_PARAMETER_u, + ShaderVisibility: D3D12_SHADER_VISIBILITY, +}} +ENUM!{enum D3D12_ROOT_SIGNATURE_FLAGS { + D3D12_ROOT_SIGNATURE_FLAG_NONE = 0x0, + D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT = 0x1, + D3D12_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS = 0x2, + D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS = 0x4, + D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS = 0x8, + D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS = 0x10, + D3D12_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS = 0x20, + D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT = 0x40, +}} +ENUM!{enum D3D12_STATIC_BORDER_COLOR { + D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK = 0, + D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK = 1, + D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE = 2, +}} +STRUCT!{struct D3D12_STATIC_SAMPLER_DESC { + Filter: D3D12_FILTER, + AddressU: D3D12_TEXTURE_ADDRESS_MODE, + AddressV: D3D12_TEXTURE_ADDRESS_MODE, + AddressW: D3D12_TEXTURE_ADDRESS_MODE, + MipLODBias: FLOAT, + MaxAnisotropy: UINT, + ComparisonFunc: D3D12_COMPARISON_FUNC, + BorderColor: D3D12_STATIC_BORDER_COLOR, + MinLOD: FLOAT, + MaxLOD: FLOAT, + ShaderRegister: UINT, + RegisterSpace: UINT, + ShaderVisibility: D3D12_SHADER_VISIBILITY, +}} +STRUCT!{struct D3D12_ROOT_SIGNATURE_DESC { + NumParameters: UINT, + pParameters: *const D3D12_ROOT_PARAMETER, + NumStaticSamplers: UINT, + pStaticSamplers: *const D3D12_STATIC_SAMPLER_DESC, + Flags: D3D12_ROOT_SIGNATURE_FLAGS, +}} +ENUM!{enum D3D12_DESCRIPTOR_RANGE_FLAGS { + D3D12_DESCRIPTOR_RANGE_FLAG_NONE = 0, + D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE = 0x1, + D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE = 0x2, + D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4, + D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC = 0x8, +}} +STRUCT!{struct D3D12_DESCRIPTOR_RANGE1 { + RangeType: D3D12_DESCRIPTOR_RANGE_TYPE, + NumDescriptors: UINT, + BaseShaderRegister: UINT, + RegisterSpace: UINT, + Flags: D3D12_DESCRIPTOR_RANGE_FLAGS, + OffsetInDescriptorsFromTableStart: UINT, +}} +STRUCT!{struct D3D12_ROOT_DESCRIPTOR_TABLE1 { + NumDescriptorRanges: UINT, + pDescriptorRanges: *const D3D12_DESCRIPTOR_RANGE1, +}} +ENUM!{enum D3D12_ROOT_DESCRIPTOR_FLAGS { + D3D12_ROOT_DESCRIPTOR_FLAG_NONE = 0, + D3D12_ROOT_DESCRIPTOR_FLAG_DATA_VOLATILE = 0x2, + D3D12_ROOT_DESCRIPTOR_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4, + D3D12_ROOT_DESCRIPTOR_FLAG_DATA_STATIC = 0x8, +}} +STRUCT!{struct D3D12_ROOT_DESCRIPTOR1 { + ShaderRegister: UINT, + RegisterSpace: UINT, + Flags: D3D12_ROOT_DESCRIPTOR_FLAGS, +}} +UNION!{union D3D12_ROOT_PARAMETER1_u { + [u32; 3] [u64; 2], + DescriptorTable DescriptorTable_mut: D3D12_ROOT_DESCRIPTOR_TABLE1, + Constants Constants_mut: D3D12_ROOT_CONSTANTS, + Descriptor Descriptor_mut: D3D12_ROOT_DESCRIPTOR1, +}} +STRUCT!{struct D3D12_ROOT_PARAMETER1 { + ParameterType: D3D12_ROOT_PARAMETER_TYPE, + u: D3D12_ROOT_PARAMETER1_u, + ShaderVisibility: D3D12_SHADER_VISIBILITY, +}} +STRUCT!{struct D3D12_ROOT_SIGNATURE_DESC1 { + NumParameters: UINT, + pParameters: *const D3D12_ROOT_PARAMETER1, + NumStaticSamplers: UINT, + pStaticSamplers: *const D3D12_STATIC_SAMPLER_DESC, + Flags: D3D12_ROOT_SIGNATURE_FLAGS, +}} +UNION!{union D3D12_VERSIONED_ROOT_SIGNATURE_DESC_u { + [u32; 5] [u64; 5], + Desc_1_0 Desc_1_0_mut: D3D12_ROOT_SIGNATURE_DESC, + Desc_1_1 Desc_1_1_mut: D3D12_ROOT_SIGNATURE_DESC1, +}} +STRUCT!{struct D3D12_VERSIONED_ROOT_SIGNATURE_DESC { + Version: UINT, + u: D3D12_VERSIONED_ROOT_SIGNATURE_DESC_u, +}} +RIDL!{#[uuid(0x34ab647b, 0x3cc8, 0x46ac, 0x84, 0x1b, 0xc0, 0x96, 0x56, 0x45, 0xc0, 0x46)] +interface ID3D12RootSignatureDeserializer(ID3D12RootSignatureDeserializerVtbl): + IUnknown(IUnknownVtbl) { + fn GetRootSignatureDesc() -> *const D3D12_ROOT_SIGNATURE_DESC, +}} +RIDL!{#[uuid(0x7f91ce67, 0x090c, 0x4bb7, 0xb7, 0x8e, 0xed, 0x8f, 0xf2, 0xe3, 0x1d, 0xa0)] +interface ID3D12VersionedRootSignatureDeserializer(ID3D12VersionedRootSignatureDeserializerVtbl): + IUnknown(IUnknownVtbl) { + fn GetRootSignatureDescAtVersion( + convertToVersion: D3D_ROOT_SIGNATURE_VERSION, + ppDesc: *mut *mut D3D12_VERSIONED_ROOT_SIGNATURE_DESC, + ) -> HRESULT, + fn GetUnconvertedRootSignatureDesc() -> *const D3D12_VERSIONED_ROOT_SIGNATURE_DESC, +}} +FN!{stdcall PFN_D3D12_SERIALIZE_ROOT_SIGNATURE( + pRootSignature: *const D3D12_ROOT_SIGNATURE_DESC, + Version: D3D_ROOT_SIGNATURE_VERSION, + ppBlob: *mut *mut ID3DBlob, + ppErrorBlob: *mut *mut ID3DBlob, +) -> HRESULT} +extern "system" { + pub fn D3D12SerializeRootSignature( + pRootSignature: *const D3D12_ROOT_SIGNATURE_DESC, + Version: D3D_ROOT_SIGNATURE_VERSION, + ppBlob: *mut *mut ID3DBlob, + ppErrorBlob: *mut *mut ID3DBlob, + ) -> HRESULT; +} +FN!{stdcall PFN_D3D12_CREATE_ROOT_SIGNATURE_DESERIALIZER( + pSrcData: LPCVOID, + SrcDataSizeInBytes: SIZE_T, + pRootSignatureDeserializerInterface: REFIID, + ppRootSignatureDeserializer: *mut *mut c_void, +) -> HRESULT} +extern "system" { + pub fn D3D12CreateRootSignatureDeserializer( + pSrcData: LPCVOID, + SrcDataSizeInBytes: SIZE_T, + pRootSignatureDeserializerInterface: REFGUID, + ppRootSignatureDeserializer: *mut *mut c_void, + ) -> HRESULT; +} +FN!{stdcall PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE( + pRootSignature: *const D3D12_VERSIONED_ROOT_SIGNATURE_DESC, + ppBlob: *mut *mut ID3DBlob, + ppErrorBlob: *mut *mut ID3DBlob, +) -> HRESULT} +extern "system" { + pub fn D3D12SerializeVersionedRootSignature( + pRootSignature: *const D3D12_VERSIONED_ROOT_SIGNATURE_DESC, + ppBlob: *mut *mut ID3DBlob, + ppErrorBlob: *mut *mut ID3DBlob, + ) -> HRESULT; +} +FN!{stdcall PFN_D3D12_CREATE_VERSIONED_ROOT_SIGNATURE_DESERIALIZER( + pSrcData: LPCVOID, + SrcDataSizeInBytes: SIZE_T, + pRootSignatureDeserializerInterface: REFIID, + ppRootSignatureDeserializer: *mut *mut c_void, +) -> HRESULT} +extern "system" { + pub fn D3D12CreateVersionedRootSignatureDeserializer( + pSrcData: LPCVOID, + SrcDataSizeInBytes: SIZE_T, + pRootSignatureDeserializerInterface: REFIID, + ppRootSignatureDeserializer: *mut *mut c_void, + ) -> HRESULT; +} +STRUCT!{struct D3D12_CPU_DESCRIPTOR_HANDLE { + ptr: SIZE_T, +}} +STRUCT!{struct D3D12_GPU_DESCRIPTOR_HANDLE { + ptr: UINT64, +}} +STRUCT!{struct D3D12_DISCARD_REGION { + NumRects: UINT, + pRects: *const D3D12_RECT, + FirstSubresource: UINT, + NumSubresources: UINT, +}} +ENUM!{enum D3D12_QUERY_HEAP_TYPE { + D3D12_QUERY_HEAP_TYPE_OCCLUSION = 0, + D3D12_QUERY_HEAP_TYPE_TIMESTAMP = 1, + D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS = 2, + D3D12_QUERY_HEAP_TYPE_SO_STATISTICS = 3, +}} +STRUCT!{struct D3D12_QUERY_HEAP_DESC { + Type: D3D12_QUERY_HEAP_TYPE, + Count: UINT, + NodeMask: UINT, +}} +ENUM!{enum D3D12_QUERY_TYPE { + D3D12_QUERY_TYPE_OCCLUSION = 0, + D3D12_QUERY_TYPE_BINARY_OCCLUSION = 1, + D3D12_QUERY_TYPE_TIMESTAMP = 2, + D3D12_QUERY_TYPE_PIPELINE_STATISTICS = 3, + D3D12_QUERY_TYPE_SO_STATISTICS_STREAM0 = 4, + D3D12_QUERY_TYPE_SO_STATISTICS_STREAM1 = 5, + D3D12_QUERY_TYPE_SO_STATISTICS_STREAM2 = 6, + D3D12_QUERY_TYPE_SO_STATISTICS_STREAM3 = 7, +}} +ENUM!{enum D3D12_PREDICATION_OP { + D3D12_PREDICATION_OP_EQUAL_ZERO = 0, + D3D12_PREDICATION_OP_NOT_EQUAL_ZERO = 1, +}} +STRUCT!{struct D3D12_QUERY_DATA_PIPELINE_STATISTICS { + IAVertices: UINT64, + IAPrimitives: UINT64, + VSInvocations: UINT64, + GSInvocations: UINT64, + GSPrimitives: UINT64, + CInvocations: UINT64, + CPrimitives: UINT64, + PSInvocations: UINT64, + HSInvocations: UINT64, + DSInvocations: UINT64, + CSInvocations: UINT64, +}} +STRUCT!{struct D3D12_QUERY_DATA_SO_STATISTICS { + NumPrimitivesWritten: UINT64, + PrimitivesStorageNeeded: UINT64, +}} +STRUCT!{struct D3D12_STREAM_OUTPUT_BUFFER_VIEW { + BufferLocation: D3D12_GPU_VIRTUAL_ADDRESS, + SizeInBytes: UINT64, + BufferFilledSizeLocation: D3D12_GPU_VIRTUAL_ADDRESS, +}} +STRUCT!{struct D3D12_DRAW_ARGUMENTS { + VertexCountPerInstance: UINT, + InstanceCount: UINT, + StartVertexLocation: UINT, + StartInstanceLocation: UINT, +}} +STRUCT!{struct D3D12_DRAW_INDEXED_ARGUMENTS { + IndexCountPerInstance: UINT, + InstanceCount: UINT, + StartIndexLocation: UINT, + BaseVertexLocation: INT, + StartInstanceLocation: UINT, +}} +STRUCT!{struct D3D12_DISPATCH_ARGUMENTS { + ThreadGroupCountX: UINT, + ThreadGroupCountY: UINT, + ThreadGroupCountZ: UINT, +}} +STRUCT!{struct D3D12_VERTEX_BUFFER_VIEW { + BufferLocation: D3D12_GPU_VIRTUAL_ADDRESS, + SizeInBytes: UINT, + StrideInBytes: UINT, +}} +STRUCT!{struct D3D12_INDEX_BUFFER_VIEW { + BufferLocation: D3D12_GPU_VIRTUAL_ADDRESS, + SizeInBytes: UINT, + Format: DXGI_FORMAT, +}} +ENUM!{enum D3D12_INDIRECT_ARGUMENT_TYPE { + D3D12_INDIRECT_ARGUMENT_TYPE_DRAW = 0, + D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED = 1, + D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH = 2, + D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW = 3, + D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW = 4, + D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT = 5, + D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW = 6, + D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW = 7, + D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW = 8, +}} +STRUCT!{struct D3D12_INDIRECT_ARGUMENT_DESC_VertexBuffer { + Slot: UINT, +}} +STRUCT!{struct D3D12_INDIRECT_ARGUMENT_DESC_Constant { + RootParameterIndex: UINT, + DestOffsetIn32BitValues: UINT, + Num32BitValuesToSet: UINT, +}} +STRUCT!{struct D3D12_INDIRECT_ARGUMENT_DESC_ConstantBufferView { + RootParameterIndex: UINT, +}} +STRUCT!{struct D3D12_INDIRECT_ARGUMENT_DESC_ShaderResourceView { + RootParameterIndex: UINT, +}} +STRUCT!{struct D3D12_INDIRECT_ARGUMENT_DESC_UnorderedAccessView { + RootParameterIndex: UINT, +}} +UNION!{union D3D12_INDIRECT_ARGUMENT_DESC_u { + [u32; 3], + VertexBuffer VertexBuffer_mut: D3D12_INDIRECT_ARGUMENT_DESC_VertexBuffer, + Constant Constant_mut: D3D12_INDIRECT_ARGUMENT_DESC_Constant, + ConstantBufferView ConstantBufferView_mut: D3D12_INDIRECT_ARGUMENT_DESC_ConstantBufferView, + ShaderResourceView ShaderResourceView_mut: D3D12_INDIRECT_ARGUMENT_DESC_ShaderResourceView, + UnorderedAccessView UnorderedAccessView_mut: D3D12_INDIRECT_ARGUMENT_DESC_UnorderedAccessView, +}} +STRUCT!{struct D3D12_INDIRECT_ARGUMENT_DESC { + Type: D3D12_INDIRECT_ARGUMENT_TYPE, + u: D3D12_INDIRECT_ARGUMENT_DESC_u, +}} +STRUCT!{struct D3D12_COMMAND_SIGNATURE_DESC { + ByteStride: UINT, + NumArgumentDescs: UINT, + pArgumentDescs: *const D3D12_INDIRECT_ARGUMENT_DESC, + NodeMask: UINT, +}} +RIDL!{#[uuid(0xc4fec28f, 0x7966, 0x4e95, 0x9f, 0x94, 0xf4, 0x31, 0xcb, 0x56, 0xc3, 0xb8)] +interface ID3D12Object(ID3D12ObjectVtbl): IUnknown(IUnknownVtbl) { + fn GetPrivateData( + guid: REFGUID, + pDataSize: *mut UINT, + pData: *mut c_void, + ) -> HRESULT, + fn SetPrivateData( + guid: REFGUID, + DataSize: UINT, + pData: *const c_void, + ) -> HRESULT, + fn SetPrivateDataInterface( + guid: REFGUID, + pData: *const IUnknown, + ) -> HRESULT, + fn SetName( + Name: LPCWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x905db94b, 0xa00c, 0x4140, 0x9d, 0xf5, 0x2b, 0x64, 0xca, 0x9e, 0xa3, 0x57)] +interface ID3D12DeviceChild(ID3D12DeviceChildVtbl): ID3D12Object(ID3D12ObjectVtbl) { + fn GetDevice( + riid: REFIID, + ppvDevice: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x63ee58fb, 0x1268, 0x4835, 0x86, 0xda, 0xf0, 0x08, 0xce, 0x62, 0xf0, 0xd6)] +interface ID3D12Pageable(ID3D12PageableVtbl): ID3D12DeviceChild(ID3D12DeviceChildVtbl) {}} +RIDL!{#[uuid(0x6b3b2502, 0x6e51, 0x45b3, 0x90, 0xee, 0x98, 0x84, 0x26, 0x5e, 0x8d, 0xf3)] +interface ID3D12Heap(ID3D12HeapVtbl): ID3D12Pageable(ID3D12PageableVtbl) { + #[fixme] fn GetDesc() -> D3D12_HEAP_DESC, +}} +RIDL!{#[uuid(0x696442be, 0xa72e, 0x4059, 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad)] +interface ID3D12Resource(ID3D12ResourceVtbl): ID3D12Pageable(ID3D12PageableVtbl) { + fn Map( + Subresource: UINT, + pReadRange: *const D3D12_RANGE, + ppData: *mut *mut c_void, + ) -> HRESULT, + fn Unmap( + Subresource: UINT, + pWrittenRange: *const D3D12_RANGE, + ) -> (), + #[fixme] fn GetDesc() -> D3D12_RESOURCE_DESC, + fn GetGPUVirtualAddress() -> D3D12_GPU_VIRTUAL_ADDRESS, + fn WriteToSubresource( + DstSubresource: UINT, + pDstBox: *const D3D12_BOX, + pSrcData: *const c_void, + SrcRowPitch: UINT, + SrcDepthPitch: UINT, + ) -> HRESULT, + fn ReadFromSubresource( + pDstData: *mut c_void, + DstRowPitch: UINT, + DstDepthPitch: UINT, + SrcSubresource: UINT, + pSrcBox: *const D3D12_BOX, + ) -> HRESULT, + fn GetHeapProperties( + pHeapProperties: *mut D3D12_HEAP_PROPERTIES, + pHeapFlags: *mut D3D12_HEAP_FLAGS, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6102dee4, 0xaf59, 0x4b09, 0xb9, 0x99, 0xb4, 0x4d, 0x73, 0xf0, 0x9b, 0x24)] +interface ID3D12CommandAllocator(ID3D12CommandAllocatorVtbl): ID3D12Pageable(ID3D12PageableVtbl) { + fn Reset() -> HRESULT, +}} +RIDL!{#[uuid(0x0a753dcf, 0xc4d8, 0x4b91, 0xad, 0xf6, 0xbe, 0x5a, 0x60, 0xd9, 0x5a, 0x76)] +interface ID3D12Fence(ID3D12FenceVtbl): ID3D12Pageable(ID3D12PageableVtbl) { + fn GetCompletedValue() -> UINT64, + fn SetEventOnCompletion( + Value: UINT64, + hEvent: HANDLE, + ) -> HRESULT, + fn Signal( + Value: UINT64, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x765a30f3, 0xf624, 0x4c6f, 0xa8, 0x28, 0xac, 0xe9, 0x48, 0x62, 0x24, 0x45)] +interface ID3D12PipelineState(ID3D12PipelineStateVtbl): ID3D12Pageable(ID3D12PageableVtbl) { + fn GetCachedBlob( + ppBlob: *mut *mut ID3DBlob, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8efb471d, 0x616c, 0x4f49, 0x90, 0xf7, 0x12, 0x7b, 0xb7, 0x63, 0xfa, 0x51)] +interface ID3D12DescriptorHeap(ID3D12DescriptorHeapVtbl): ID3D12Pageable(ID3D12PageableVtbl) { + #[fixme] fn GetDesc() -> D3D12_DESCRIPTOR_HEAP_DESC, + #[fixme] fn GetCPUDescriptorHandleForHeapStart() -> D3D12_CPU_DESCRIPTOR_HANDLE, + #[fixme] fn GetGPUDescriptorHandleForHeapStart() -> D3D12_GPU_DESCRIPTOR_HANDLE, +}} +RIDL!{#[uuid(0x0d9658ae, 0xed45, 0x469e, 0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4)] +interface ID3D12QueryHeap(ID3D12QueryHeapVtbl): ID3D12Pageable(ID3D12PageableVtbl) {}} +RIDL!{#[uuid(0xc36a797c, 0xec80, 0x4f0a, 0x89, 0x85, 0xa7, 0xb2, 0x47, 0x50, 0x82, 0xd1)] +interface ID3D12CommandSignature(ID3D12CommandSignatureVtbl): + ID3D12Pageable(ID3D12PageableVtbl) {}} +RIDL!{#[uuid(0x7116d91c, 0xe7e4, 0x47ce, 0xb8, 0xc6, 0xec, 0x81, 0x68, 0xf4, 0x37, 0xe5)] +interface ID3D12CommandList(ID3D12CommandListVtbl): ID3D12DeviceChild(ID3D12DeviceChildVtbl) { + fn GetType() -> D3D12_COMMAND_LIST_TYPE, +}} +RIDL!{#[uuid(0x5b160d0f, 0xac1b, 0x4185, 0x8b, 0xa8, 0xb3, 0xae, 0x42, 0xa5, 0xa4, 0x55)] +interface ID3D12GraphicsCommandList(ID3D12GraphicsCommandListVtbl): + ID3D12CommandList(ID3D12CommandListVtbl) { + fn Close() -> HRESULT, + fn Reset( + pAllocator: *mut ID3D12CommandAllocator, + pInitialState: *mut ID3D12PipelineState, + ) -> HRESULT, + fn ClearState( + pPipelineState: *mut ID3D12PipelineState, + ) -> (), + fn DrawInstanced( + VertexCountPerInstance: UINT, + InstanceCount: UINT, + StartVertexLocation: UINT, + StartInstanceLocation: UINT, + ) -> (), + fn DrawIndexedInstanced( + IndexCountPerInstance: UINT, + InstanceCount: UINT, + StartIndexLocation: UINT, + BaseVertexLocation: INT, + StartInstanceLocation: UINT, + ) -> (), + fn Dispatch( + ThreadGroupCountX: UINT, + ThreadGroupCountY: UINT, + ThreadGroupCountZ: UINT, + ) -> (), + fn CopyBufferRegion( + pDstBuffer: *mut ID3D12Resource, + DstOffset: UINT64, + pSrcBuffer: *mut ID3D12Resource, + SrcOffset: UINT64, + NumBytes: UINT64, + ) -> (), + fn CopyTextureRegion( + pDst: *const D3D12_TEXTURE_COPY_LOCATION, + DstX: UINT, + DstY: UINT, + DstZ: UINT, + pSrc: *const D3D12_TEXTURE_COPY_LOCATION, + pSrcBox: *const D3D12_BOX, + ) -> (), + fn CopyResource( + pDstResource: *mut ID3D12Resource, + pSrcResource: *mut ID3D12Resource, + ) -> (), + fn CopyTiles( + pTiledResource: *mut ID3D12Resource, + pTileRegionStartCoordinate: *const D3D12_TILED_RESOURCE_COORDINATE, + pTileRegionSize: *const D3D12_TILE_REGION_SIZE, + pBuffer: *mut ID3D12Resource, + BufferStartOffsetInBytes: UINT64, + Flags: D3D12_TILE_COPY_FLAGS, + ) -> (), + fn ResolveSubresource( + pDstResource: *mut ID3D12Resource, + DstSubresource: UINT, + pSrcResource: *mut ID3D12Resource, + SrcSubresource: UINT, + Format: DXGI_FORMAT, + ) -> (), + fn IASetPrimitiveTopology( + PrimitiveTopology: D3D12_PRIMITIVE_TOPOLOGY, + ) -> (), + fn RSSetViewports( + NumViewports: UINT, + pViewports: *const D3D12_VIEWPORT, + ) -> (), + fn RSSetScissorRects( + NumRects: UINT, + pRects: *const D3D12_RECT, + ) -> (), + fn OMSetBlendFactor( + BlendFactor: *const [FLOAT; 4], + ) -> (), + fn OMSetStencilRef( + StencilRef: UINT, + ) -> (), + fn SetPipelineState( + pPipelineState: *mut ID3D12PipelineState, + ) -> (), + fn ResourceBarrier( + NumBarriers: UINT, + pBarriers: *const D3D12_RESOURCE_BARRIER, + ) -> (), + fn ExecuteBundle( + pCommandList: *mut ID3D12GraphicsCommandList, + ) -> (), + fn SetDescriptorHeaps( + NumDescriptorHeaps: UINT, + ppDescriptorHeaps: *mut *mut ID3D12DescriptorHeap, + ) -> (), + fn SetComputeRootSignature( + pRootSignature: *mut ID3D12RootSignature, + ) -> (), + fn SetGraphicsRootSignature( + pRootSignature: *mut ID3D12RootSignature, + ) -> (), + fn SetComputeRootDescriptorTable( + RootParameterIndex: UINT, + BaseDescriptor: D3D12_GPU_DESCRIPTOR_HANDLE, + ) -> (), + fn SetGraphicsRootDescriptorTable( + RootParameterIndex: UINT, + BaseDescriptor: D3D12_GPU_DESCRIPTOR_HANDLE, + ) -> (), + fn SetComputeRoot32BitConstant( + RootParameterIndex: UINT, + SrcData: UINT, + DestOffsetIn32BitValues: UINT, + ) -> (), + fn SetGraphicsRoot32BitConstant( + RootParameterIndex: UINT, + SrcData: UINT, + DestOffsetIn32BitValues: UINT, + ) -> (), + fn SetComputeRoot32BitConstants( + RootParameterIndex: UINT, + Num32BitValuesToSet: UINT, + pSrcData: *const c_void, + DestOffsetIn32BitValues: UINT, + ) -> (), + fn SetGraphicsRoot32BitConstants( + RootParameterIndex: UINT, + Num32BitValuesToSet: UINT, + pSrcData: *const c_void, + DestOffsetIn32BitValues: UINT, + ) -> (), + fn SetComputeRootConstantBufferView( + RootParameterIndex: UINT, + BufferLocation: D3D12_GPU_VIRTUAL_ADDRESS, + ) -> (), + fn SetGraphicsRootConstantBufferView( + RootParameterIndex: UINT, + BufferLocation: D3D12_GPU_VIRTUAL_ADDRESS, + ) -> (), + fn SetComputeRootShaderResourceView( + RootParameterIndex: UINT, + BufferLocation: D3D12_GPU_VIRTUAL_ADDRESS, + ) -> (), + fn SetGraphicsRootShaderResourceView( + RootParameterIndex: UINT, + BufferLocation: D3D12_GPU_VIRTUAL_ADDRESS, + ) -> (), + fn SetComputeRootUnorderedAccessView( + RootParameterIndex: UINT, + BufferLocation: D3D12_GPU_VIRTUAL_ADDRESS, + ) -> (), + fn SetGraphicsRootUnorderedAccessView( + RootParameterIndex: UINT, + BufferLocation: D3D12_GPU_VIRTUAL_ADDRESS, + ) -> (), + fn IASetIndexBuffer( + pView: *const D3D12_INDEX_BUFFER_VIEW, + ) -> (), + fn IASetVertexBuffers( + StartSlot: UINT, + NumViews: UINT, + pViews: *const D3D12_VERTEX_BUFFER_VIEW, + ) -> (), + fn SOSetTargets( + StartSlot: UINT, + NumViews: UINT, + pViews: *const D3D12_STREAM_OUTPUT_BUFFER_VIEW, + ) -> (), + fn OMSetRenderTargets( + NumRenderTargetDescriptors: UINT, + pRenderTargetDescriptors: *const D3D12_CPU_DESCRIPTOR_HANDLE, + RTsSingleHandleToDescriptorRange: BOOL, + pDepthStencilDescriptor: *const D3D12_CPU_DESCRIPTOR_HANDLE, + ) -> (), + fn ClearDepthStencilView( + DepthStencilView: D3D12_CPU_DESCRIPTOR_HANDLE, + ClearFlags: D3D12_CLEAR_FLAGS, + Depth: FLOAT, + Stencil: UINT8, + NumRects: UINT, + pRects: *const D3D12_RECT, + ) -> (), + fn ClearRenderTargetView( + RenderTargetView: D3D12_CPU_DESCRIPTOR_HANDLE, + ColorRGBA: *const [FLOAT; 4], + NumRects: UINT, + pRects: *const D3D12_RECT, + ) -> (), + fn ClearUnorderedAccessViewUint( + ViewGPUHandleInCurrentHeap: D3D12_GPU_DESCRIPTOR_HANDLE, + ViewCPUHandle: D3D12_CPU_DESCRIPTOR_HANDLE, + pResource: *mut ID3D12Resource, + Values: *const [UINT; 4], + NumRects: UINT, + pRects: *const D3D12_RECT, + ) -> (), + fn ClearUnorderedAccessViewFloat( + ViewGPUHandleInCurrentHeap: D3D12_GPU_DESCRIPTOR_HANDLE, + ViewCPUHandle: D3D12_CPU_DESCRIPTOR_HANDLE, + pResource: *mut ID3D12Resource, + Values: *const [FLOAT; 4], + NumRects: UINT, + pRects: *const D3D12_RECT, + ) -> (), + fn DiscardResource( + pResource: *mut ID3D12Resource, + pRegion: *const D3D12_DISCARD_REGION, + ) -> (), + fn BeginQuery( + pQueryHeap: *mut ID3D12QueryHeap, + Type: D3D12_QUERY_TYPE, + Index: UINT, + ) -> (), + fn EndQuery( + pQueryHeap: *mut ID3D12QueryHeap, + Type: D3D12_QUERY_TYPE, + Index: UINT, + ) -> (), + fn ResolveQueryData( + pQueryHeap: *mut ID3D12QueryHeap, + Type: D3D12_QUERY_TYPE, + StartIndex: UINT, + NumQueries: UINT, + pDestinationBuffer: *mut ID3D12Resource, + AlignedDestinationBufferOffset: UINT64, + ) -> (), + fn SetPredication( + pBuffer: *mut ID3D12Resource, + AlignedBufferOffset: UINT64, + Operation: D3D12_PREDICATION_OP, + ) -> (), + fn SetMarker( + Metadata: UINT, + pData: *const c_void, + Size: UINT, + ) -> (), + fn BeginEvent( + Metadata: UINT, + pData: *const c_void, + Size: UINT, + ) -> (), + fn EndEvent() -> (), + fn ExecuteIndirect( + pCommandSignature: *mut ID3D12CommandSignature, + MaxCommandCount: UINT, + pArgumentBuffer: *mut ID3D12Resource, + ArgumentBufferOffset: UINT64, + pCountBuffer: *mut ID3D12Resource, + CountBufferOffset: UINT64, + ) -> (), +}} +RIDL!{#[uuid(0x553103fb, 0x1fe7, 0x4557, 0xbb, 0x38, 0x94, 0x6d, 0x7d, 0x0e, 0x7c, 0xa7)] +interface ID3D12GraphicsCommandList1(ID3D12GraphicsCommandList1Vtbl): + ID3D12GraphicsCommandList(ID3D12GraphicsCommandListVtbl) { + fn AtomicCopyBufferUINT( + pDstBuffer: *mut ID3D12Resource, + DstOffset: UINT64, + pSrcBuffer: *mut ID3D12Resource, + SrcOffset: UINT64, + Dependencies: UINT, + ppDependentResources: *const *mut ID3D12Resource, + pDependentSubresourceRanges: *mut D3D12_SUBRESOURCE_RANGE_UINT64, + ) -> (), + fn AtomicCopyBufferUINT64( + pDstBuffer: *mut ID3D12Resource, + DstOffset: UINT64, + pSrcBuffer: *mut ID3D12Resource, + SrcOffset: UINT64, + Dependencies: UINT, + ppDependentResources: *const *mut ID3D12Resource, + pDependentSubresourceRanges: *mut D3D12_SUBRESOURCE_RANGE_UINT64, + ) -> (), + fn OMSetDepthBounds( + Min: FLOAT, + Max: FLOAT, + ) -> (), + fn SetSamplePositions( + NumSamplesPerPixel: UINT, + NumPixels: UINT, + pSamplePositions: *mut D3D12_SAMPLE_POSITION, + ) -> (), + fn ResolveSubresourceRegion( + pDstResource: *mut ID3D12Resource, + DstSubresource: UINT, + DstX: UINT, + DstY: UINT, + pSrcResource: *mut ID3D12Resource, + SrcSubresource: UINT, + pSrcRect: *mut D3D12_RECT, + Format: DXGI_FORMAT, + ResolveMode: D3D12_RESOLVE_MODE, + ) -> (), +}} +RIDL!{#[uuid(0x0ec870a6, 0x5d7e, 0x4c22, 0x8c, 0xfc, 0x5b, 0xaa, 0xe0, 0x76, 0x16, 0xed)] +interface ID3D12CommandQueue(ID3D12CommandQueueVtbl): ID3D12Pageable(ID3D12PageableVtbl) { + fn UpdateTileMappings( + pResource: *mut ID3D12Resource, + NumResourceRegions: UINT, + pResourceRegionStartCoordinates: *const D3D12_TILED_RESOURCE_COORDINATE, + pResourceRegionSizes: *const D3D12_TILE_REGION_SIZE, + pHeap: *mut ID3D12Heap, + NumRanges: UINT, + pRangeFlags: *const D3D12_TILE_RANGE_FLAGS, + pHeapRangeStartOffsets: *const UINT, + pRangeTileCounts: *const UINT, + Flags: D3D12_TILE_MAPPING_FLAGS, + ) -> (), + fn CopyTileMappings( + pDstResource: *mut ID3D12Resource, + pDstRegionStartCoordinate: *const D3D12_TILED_RESOURCE_COORDINATE, + pSrcResource: *mut ID3D12Resource, + pSrcRegionStartCoordinate: *const D3D12_TILED_RESOURCE_COORDINATE, + pRegionSize: *const D3D12_TILE_REGION_SIZE, + Flags: D3D12_TILE_MAPPING_FLAGS, + ) -> (), + fn ExecuteCommandLists( + NumCommandLists: UINT, + ppCommandLists: *const *mut ID3D12CommandList, + ) -> (), + fn SetMarker( + Metadata: UINT, + pData: *const c_void, + Size: UINT, + ) -> (), + fn BeginEvent( + Metadata: UINT, + pData: *const c_void, + Size: UINT, + ) -> (), + fn EndEvent() -> (), + fn Signal( + pFence: *mut ID3D12Fence, + Value: UINT64, + ) -> HRESULT, + fn Wait( + pFence: *mut ID3D12Fence, + Value: UINT64, + ) -> HRESULT, + fn GetTimestampFrequency( + pFrequency: *mut UINT64, + ) -> HRESULT, + fn GetClockCalibration( + pGpuTimestamp: *mut UINT64, + pCpuTimestamp: *mut UINT64, + ) -> HRESULT, + #[fixme] fn GetDesc() -> D3D12_COMMAND_QUEUE_DESC, +}} +RIDL!{#[uuid(0x189819f1, 0x1db6, 0x4b57, 0xbe, 0x54, 0x18, 0x21, 0x33, 0x9b, 0x85, 0xf7)] +interface ID3D12Device(ID3D12DeviceVtbl): ID3D12Object(ID3D12ObjectVtbl) { + fn GetNodeCount() -> UINT, + fn CreateCommandQueue( + pDesc: *const D3D12_COMMAND_QUEUE_DESC, + riid: REFGUID, + ppCommandQueue: *mut *mut c_void, + ) -> HRESULT, + fn CreateCommandAllocator( + type_: D3D12_COMMAND_LIST_TYPE, + riid: REFGUID, + ppCommandAllocator: *mut *mut c_void, + ) -> HRESULT, + fn CreateGraphicsPipelineState( + pDesc: *const D3D12_GRAPHICS_PIPELINE_STATE_DESC, + riid: REFGUID, + ppPipelineState: *mut *mut c_void, + ) -> HRESULT, + fn CreateComputePipelineState( + pDesc: *const D3D12_COMPUTE_PIPELINE_STATE_DESC, + riid: REFGUID, + ppPipelineState: *mut *mut c_void, + ) -> HRESULT, + fn CreateCommandList( + nodeMask: UINT, + type_: D3D12_COMMAND_LIST_TYPE, + pCommandAllocator: *mut ID3D12CommandAllocator, + pInitialState: *mut ID3D12PipelineState, + riid: REFGUID, + ppCommandList: *mut *mut c_void, + ) -> HRESULT, + fn CheckFeatureSupport( + Feature: D3D12_FEATURE, + pFeatureSupportData: *mut c_void, + FeatureSupportDataSize: UINT, + ) -> HRESULT, + fn CreateDescriptorHeap( + pDescriptorHeapDesc: *const D3D12_DESCRIPTOR_HEAP_DESC, + riid: REFGUID, + ppvHeap: *mut *mut c_void, + ) -> HRESULT, + fn GetDescriptorHandleIncrementSize( + DescriptorHeapType: D3D12_DESCRIPTOR_HEAP_TYPE, + ) -> UINT, + fn CreateRootSignature( + nodeMask: UINT, + pBlobWithRootSignature: *const c_void, + blobLengthInBytes: SIZE_T, + riid: REFGUID, + ppvRootSignature: *mut *mut c_void, + ) -> HRESULT, + fn CreateConstantBufferView( + pDesc: *const D3D12_CONSTANT_BUFFER_VIEW_DESC, + DestDescriptor: D3D12_CPU_DESCRIPTOR_HANDLE, + ) -> (), + fn CreateShaderResourceView( + pResource: *mut ID3D12Resource, + pDesc: *const D3D12_SHADER_RESOURCE_VIEW_DESC, + DestDescriptor: D3D12_CPU_DESCRIPTOR_HANDLE, + ) -> (), + fn CreateUnorderedAccessView( + pResource: *mut ID3D12Resource, + pCounterResource: *mut ID3D12Resource, + pDesc: *const D3D12_UNORDERED_ACCESS_VIEW_DESC, + DestDescriptor: D3D12_CPU_DESCRIPTOR_HANDLE, + ) -> (), + fn CreateRenderTargetView( + pResource: *mut ID3D12Resource, + pDesc: *const D3D12_RENDER_TARGET_VIEW_DESC, + DestDescriptor: D3D12_CPU_DESCRIPTOR_HANDLE, + ) -> (), + fn CreateDepthStencilView( + pResource: *mut ID3D12Resource, + pDesc: *const D3D12_DEPTH_STENCIL_VIEW_DESC, + DestDescriptor: D3D12_CPU_DESCRIPTOR_HANDLE, + ) -> (), + fn CreateSampler( + pDesc: *const D3D12_SAMPLER_DESC, + DestDescriptor: D3D12_CPU_DESCRIPTOR_HANDLE, + ) -> (), + fn CopyDescriptors( + NumDestDescriptorRanges: UINT, + pDestDescriptorRangeStarts: *const D3D12_CPU_DESCRIPTOR_HANDLE, + pDestDescriptorRangeSizes: *const UINT, + NumSrcDescriptorRanges: UINT, + pSrcDescriptorRangeStarts: *const D3D12_CPU_DESCRIPTOR_HANDLE, + pSrcDescriptorRangeSizes: *const UINT, + DescriptorHeapsType: D3D12_DESCRIPTOR_HEAP_TYPE, + ) -> (), + fn CopyDescriptorsSimple( + NumDescriptors: UINT, + DestDescriptorRangeStart: D3D12_CPU_DESCRIPTOR_HANDLE, + SrcDescriptorRangeStart: D3D12_CPU_DESCRIPTOR_HANDLE, + DescriptorHeapsType: D3D12_DESCRIPTOR_HEAP_TYPE, + ) -> (), + #[fixme] fn GetResourceAllocationInfo( + visibleMask: UINT, + numResourceDescs: UINT, + pResourceDescs: *const D3D12_RESOURCE_DESC, + ) -> D3D12_RESOURCE_ALLOCATION_INFO, + #[fixme] fn GetCustomHeapProperties( + nodeMask: UINT, + heapType: D3D12_HEAP_TYPE, + ) -> D3D12_HEAP_PROPERTIES, + fn CreateCommittedResource( + pHeapProperties: *const D3D12_HEAP_PROPERTIES, + HeapFlags: D3D12_HEAP_FLAGS, + pResourceDesc: *const D3D12_RESOURCE_DESC, + InitialResourceState: D3D12_RESOURCE_STATES, + pOptimizedClearValue: *const D3D12_CLEAR_VALUE, + riidResource: REFGUID, + ppvResource: *mut *mut c_void, + ) -> HRESULT, + fn CreateHeap( + pDesc: *const D3D12_HEAP_DESC, + riid: REFGUID, + ppvHeap: *mut *mut c_void, + ) -> HRESULT, + fn CreatePlacedResource( + pHeap: *mut ID3D12Heap, + HeapOffset: UINT64, + pDesc: *const D3D12_RESOURCE_DESC, + InitialState: D3D12_RESOURCE_STATES, + pOptimizedClearValue: *const D3D12_CLEAR_VALUE, + riid: REFGUID, + ppvResource: *mut *mut c_void, + ) -> HRESULT, + fn CreateReservedResource( + pDesc: *const D3D12_RESOURCE_DESC, + InitialState: D3D12_RESOURCE_STATES, + pOptimizedClearValue: *const D3D12_CLEAR_VALUE, + riid: REFGUID, + ppvResource: *mut *mut c_void, + ) -> HRESULT, + fn CreateSharedHandle( + pObject: *mut ID3D12DeviceChild, + pAttributes: *const SECURITY_ATTRIBUTES, + Access: DWORD, + Name: LPCWSTR, + pHandle: *mut HANDLE, + ) -> HRESULT, + fn OpenSharedHandle( + NTHandle: HANDLE, + riid: REFGUID, + ppvObj: *mut *mut c_void, + ) -> HRESULT, + fn OpenSharedHandleByName( + Name: LPCWSTR, + Access: DWORD, + pNTHandle: *mut HANDLE, + ) -> HRESULT, + fn MakeResident( + NumObjects: UINT, + ppObjects: *mut *mut ID3D12Pageable, + ) -> HRESULT, + fn Evict( + NumObjects: UINT, + ppObjects: *mut *mut ID3D12Pageable, + ) -> HRESULT, + fn CreateFence( + InitialValue: UINT64, + Flags: D3D12_FENCE_FLAGS, + riid: REFGUID, + ppFence: *mut *mut c_void, + ) -> HRESULT, + fn GetDeviceRemovedReason() -> HRESULT, + fn GetCopyableFootprints( + pResourceDesc: *const D3D12_RESOURCE_DESC, + FirstSubresource: UINT, + NumSubresources: UINT, + BaseOffset: UINT64, + pLayouts: *mut D3D12_PLACED_SUBRESOURCE_FOOTPRINT, + pNumRows: *mut UINT, + pRowSizeInBytes: *mut UINT64, + pTotalBytes: *mut UINT64, + ) -> (), + fn CreateQueryHeap( + pDesc: *const D3D12_QUERY_HEAP_DESC, + riid: REFGUID, + ppvHeap: *mut *mut c_void, + ) -> HRESULT, + fn SetStablePowerState( + Enable: BOOL, + ) -> HRESULT, + fn CreateCommandSignature( + pDesc: *const D3D12_COMMAND_SIGNATURE_DESC, + pRootSignature: *mut ID3D12RootSignature, + riid: REFGUID, + ppvCommandSignature: *mut *mut c_void, + ) -> HRESULT, + fn GetResourceTiling( + pTiledResource: *mut ID3D12Resource, + pNumTilesForEntireResource: *mut UINT, + pPackedMipDesc: *mut D3D12_PACKED_MIP_INFO, + pStandardTileShapeForNonPackedMips: *mut D3D12_TILE_SHAPE, + pNumSubresourceTilings: *mut UINT, + FirstSubresourceTilingToGet: UINT, + pSubresourceTilingsForNonPackedMips: *mut D3D12_SUBRESOURCE_TILING, + ) -> (), + #[fixme] fn GetAdapterLuid() -> LUID, +}} +RIDL!{#[uuid(0xc64226a8, 0x9201, 0x46af, 0xb4, 0xcc, 0x53, 0xfb, 0x9f, 0xf7, 0x41, 0x4f)] +interface ID3D12PipelineLibrary(ID3D12PipelineLibraryVtbl): + ID3D12DeviceChild(ID3D12DeviceChildVtbl) { + fn StorePipeline( + pName: LPCWSTR, + pPipeline: *mut ID3D12PipelineState, + ) -> HRESULT, + fn LoadGraphicsPipeline( + pName: LPCWSTR, + pDesc: *const D3D12_GRAPHICS_PIPELINE_STATE_DESC, + riid: REFIID, + ppPipelineState: *mut *mut c_void, + ) -> HRESULT, + fn LoadComputePipeline( + pName: LPCWSTR, + pDesc: *const D3D12_COMPUTE_PIPELINE_STATE_DESC, + riid: REFIID, + ppPipelineState: *mut *mut c_void, + ) -> HRESULT, + fn GetSerializedSize() -> SIZE_T, + fn Serialize( + pData: *mut c_void, + DataSizeInBytes: SIZE_T, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x80eabf42, 0x2568, 0x4e5e, 0xbd, 0x82, 0xc3, 0x7f, 0x86, 0x96, 0x1d, 0xc3)] +interface ID3D12PipelineLibrary1(ID3D12PipelineLibrary1Vtbl): + ID3D12PipelineLibrary(ID3D12PipelineLibraryVtbl) { + fn LoadPipeline( + pName: LPCWSTR, + pDesc: *const D3D12_PIPELINE_STATE_STREAM_DESC, + riid: REFIID, + ppPipelineState: *mut *mut c_void, + ) -> HRESULT, +}} +ENUM!{enum D3D12_MULTIPLE_FENCE_WAIT_FLAGS { + D3D12_MULTIPLE_FENCE_WAIT_FLAG_NONE = 0, + D3D12_MULTIPLE_FENCE_WAIT_FLAG_ANY = 0x1, + D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL = 0, +}} +ENUM!{enum D3D12_RESIDENCY_PRIORITY { + D3D12_RESIDENCY_PRIORITY_MINIMUM = 0x28000000, + D3D12_RESIDENCY_PRIORITY_LOW = 0x50000000, + D3D12_RESIDENCY_PRIORITY_NORMAL = 0x78000000, + D3D12_RESIDENCY_PRIORITY_HIGH = 0xa0010000, + D3D12_RESIDENCY_PRIORITY_MAXIMUM = 0xc8000000, +}} +RIDL!{#[uuid(0x77acce80, 0x638e, 0x4e65, 0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e)] +interface ID3D12Device1(ID3D12Device1Vtbl): ID3D12Device(ID3D12DeviceVtbl) { + fn CreatePipelineLibrary( + pLibraryBlob: *const c_void, + BlobLength: SIZE_T, + riid: REFIID, + ppPipelineLibrary: *mut *mut c_void, + ) -> HRESULT, + fn SetEventOnMultipleFenceCompletion( + ppFences: *const *mut ID3D12Fence, + pFenceValues: *const UINT64, + NumFences: UINT, + Flags: D3D12_MULTIPLE_FENCE_WAIT_FLAGS, + hEvent: HANDLE, + ) -> HRESULT, + fn SetResidencyPriority( + NumObjects: UINT, + ppObjects: *const *mut ID3D12Pageable, + pPriorities: *const D3D12_RESIDENCY_PRIORITY, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x30baa41e, 0xb15b, 0x475c, 0xa0, 0xbb, 0x1a, 0xf5, 0xc5, 0xb6, 0x43, 0x28)] +interface ID3D12Device2(ID3D12Device2Vtbl): ID3D12Device1(ID3D12Device1Vtbl) { + fn CreatePipelineState( + pDesc: *const D3D12_PIPELINE_STATE_STREAM_DESC, + riid: REFIID, + ppPipelineState: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7071e1f0, 0xe84b, 0x4b33, 0x97, 0x4f, 0x12, 0xfa, 0x49, 0xde, 0x65, 0xc5)] +interface ID3D12Tools(ID3D12ToolsVtbl): IUnknown(IUnknownVtbl) { + fn EnableShaderInstrumentation( + bEnable: BOOL, + ) -> (), + fn ShaderInstrumentationEnabled() -> BOOL, +}} +STRUCT!{struct D3D12_SUBRESOURCE_DATA { + pData: *const c_void, + RowPitch: LONG_PTR, + SlicePitch: LONG_PTR, +}} +STRUCT!{struct D3D12_MEMCPY_DEST { + pData: *mut c_void, + RowPitch: SIZE_T, + SlicePitch: SIZE_T, +}} +FN!{stdcall PFN_D3D12_CREATE_DEVICE( + *mut IUnknown, + D3D_FEATURE_LEVEL, + REFIID, + *mut *mut c_void, +) -> HRESULT} +extern "system" { + pub fn D3D12CreateDevice( + pAdapter: *mut IUnknown, + MinimumFeatureLevel: D3D_FEATURE_LEVEL, + riid: REFGUID, + ppDevice: *mut *mut c_void, + ) -> HRESULT; +} +FN!{stdcall PFN_D3D12_GET_DEBUG_INTERFACE( + REFIID, + *mut *mut c_void, +) -> HRESULT} +extern "system" { + pub fn D3D12GetDebugInterface( + riid: REFGUID, + ppvDebug: *mut *mut c_void, + ) -> HRESULT; + pub fn D3D12EnableExperimentalFeatures( + NumFeatures: UINT, + pIIDs: *const IID, + pConfigurationStructs: *mut c_void, + pConfigurationStructSizes: *mut UINT, + ) -> HRESULT; +} +DEFINE_GUID!{IID_ID3D12Object, + 0xc4fec28f, 0x7966, 0x4e95, 0x9f, 0x94, 0xf4, 0x31, 0xcb, 0x56, 0xc3, 0xb8} +DEFINE_GUID!{IID_ID3D12DeviceChild, + 0x905db94b, 0xa00c, 0x4140, 0x9d, 0xf5, 0x2b, 0x64, 0xca, 0x9e, 0xa3, 0x57} +DEFINE_GUID!{IID_ID3D12RootSignature, + 0xc54a6b66, 0x72df, 0x4ee8, 0x8b, 0xe5, 0xa9, 0x46, 0xa1, 0x42, 0x92, 0x14} +DEFINE_GUID!{IID_ID3D12RootSignatureDeserializer, + 0x34AB647B, 0x3CC8, 0x46AC, 0x84, 0x1B, 0xC0, 0x96, 0x56, 0x45, 0xC0, 0x46} +DEFINE_GUID!{IID_ID3D12VersionedRootSignatureDeserializer, + 0x7F91CE67, 0x090C, 0x4BB7, 0xB7, 0x8E, 0xED, 0x8F, 0xF2, 0xE3, 0x1D, 0xA0} +DEFINE_GUID!{IID_ID3D12Pageable, + 0x63ee58fb, 0x1268, 0x4835, 0x86, 0xda, 0xf0, 0x08, 0xce, 0x62, 0xf0, 0xd6} +DEFINE_GUID!{IID_ID3D12Heap, + 0x6b3b2502, 0x6e51, 0x45b3, 0x90, 0xee, 0x98, 0x84, 0x26, 0x5e, 0x8d, 0xf3} +DEFINE_GUID!{IID_ID3D12Resource, + 0x696442be, 0xa72e, 0x4059, 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad} +DEFINE_GUID!{IID_ID3D12CommandAllocator, + 0x6102dee4, 0xaf59, 0x4b09, 0xb9, 0x99, 0xb4, 0x4d, 0x73, 0xf0, 0x9b, 0x24} +DEFINE_GUID!{IID_ID3D12Fence, + 0x0a753dcf, 0xc4d8, 0x4b91, 0xad, 0xf6, 0xbe, 0x5a, 0x60, 0xd9, 0x5a, 0x76} +DEFINE_GUID!{IID_ID3D12PipelineState, + 0x765a30f3, 0xf624, 0x4c6f, 0xa8, 0x28, 0xac, 0xe9, 0x48, 0x62, 0x24, 0x45} +DEFINE_GUID!{IID_ID3D12DescriptorHeap, + 0x8efb471d, 0x616c, 0x4f49, 0x90, 0xf7, 0x12, 0x7b, 0xb7, 0x63, 0xfa, 0x51} +DEFINE_GUID!{IID_ID3D12QueryHeap, + 0x0d9658ae, 0xed45, 0x469e, 0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4} +DEFINE_GUID!{IID_ID3D12CommandSignature, + 0xc36a797c, 0xec80, 0x4f0a, 0x89, 0x85, 0xa7, 0xb2, 0x47, 0x50, 0x82, 0xd1} +DEFINE_GUID!{IID_ID3D12CommandList, + 0x7116d91c, 0xe7e4, 0x47ce, 0xb8, 0xc6, 0xec, 0x81, 0x68, 0xf4, 0x37, 0xe5} +DEFINE_GUID!{IID_ID3D12GraphicsCommandList, + 0x5b160d0f, 0xac1b, 0x4185, 0x8b, 0xa8, 0xb3, 0xae, 0x42, 0xa5, 0xa4, 0x55} +DEFINE_GUID!{IID_ID3D12GraphicsCommandList1, + 0x553103fb, 0x1fe7, 0x4557, 0xbb, 0x38, 0x94, 0x6d, 0x7d, 0x0e, 0x7c, 0xa7} +DEFINE_GUID!{IID_ID3D12CommandQueue, + 0x0ec870a6, 0x5d7e, 0x4c22, 0x8c, 0xfc, 0x5b, 0xaa, 0xe0, 0x76, 0x16, 0xed} +DEFINE_GUID!{IID_ID3D12Device, + 0x189819f1, 0x1db6, 0x4b57, 0xbe, 0x54, 0x18, 0x21, 0x33, 0x9b, 0x85, 0xf7} +DEFINE_GUID!{IID_ID3D12PipelineLibrary, + 0xc64226a8, 0x9201, 0x46af, 0xb4, 0xcc, 0x53, 0xfb, 0x9f, 0xf7, 0x41, 0x4f} +DEFINE_GUID!{IID_ID3D12PipelineLibrary1, + 0x80eabf42, 0x2568, 0x4e5e, 0xbd, 0x82, 0xc3, 0x7f, 0x86, 0x96, 0x1d, 0xc3} +DEFINE_GUID!{IID_ID3D12Device1, + 0x77acce80, 0x638e, 0x4e65, 0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e} +DEFINE_GUID!{IID_ID3D12Device2, + 0x30baa41e, 0xb15b, 0x475c, 0xa0, 0xbb, 0x1a, 0xf5, 0xc5, 0xb6, 0x43, 0x28} +DEFINE_GUID!{IID_ID3D12Tools, + 0x7071e1f0, 0xe84b, 0x4b33, 0x97, 0x4f, 0x12, 0xfa, 0x49, 0xde, 0x65, 0xc5} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d12sdklayers.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d12sdklayers.rs new file mode 100644 index 0000000..bb9535c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d12sdklayers.rs @@ -0,0 +1,1364 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_char, c_void}; +use shared::basetsd::{SIZE_T, UINT64}; +use shared::minwindef::{BOOL, FLOAT, UINT}; +use um::d3d12::ID3D12Resource; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCSTR}; +RIDL!{#[uuid(0x344488b7, 0x6846, 0x474b, 0xb9, 0x89, 0xf0, 0x27, 0x44, 0x82, 0x45, 0xe0)] +interface ID3D12Debug(ID3D12DebugVtbl): IUnknown(IUnknownVtbl) { + fn EnableDebugLayer() -> (), +}} +RIDL!{#[uuid(0xaffaa4ca, 0x63fe, 0x4d8e, 0xb8, 0xad, 0x15, 0x90, 0x00, 0xaf, 0x43, 0x04)] +interface ID3D12Debug1(ID3D12Debug1Vtbl): IUnknown(IUnknownVtbl) { + fn EnableDebugLayer() -> (), + fn SetEnableGPUBasedValidation( + Enable: BOOL, + ) -> (), + fn SetEnableSynchronizedCommandQueueValidation( + Enable: BOOL, + ) -> (), +}} +ENUM!{enum D3D12_GPU_BASED_VALIDATION_FLAGS { + D3D12_GPU_BASED_VALIDATION_FLAGS_NONE = 0, + D3D12_GPU_BASED_VALIDATION_FLAGS_DISABLE_STATE_TRACKING = 0x01, +}} +RIDL!{#[uuid(0x93a665c4, 0xa3b2, 0x4e5d, 0xb6, 0x92, 0xa2, 0x6a, 0xe1, 0x4e, 0x33, 0x74)] +interface ID3D12Debug2(ID3D12Debug2Vtbl): IUnknown(IUnknownVtbl) { + fn SetGPUBasedValidationFlags( + Flags: D3D12_GPU_BASED_VALIDATION_FLAGS, + ) -> (), +}} +ENUM!{enum D3D12_RLDO_FLAGS { + D3D12_RLDO_NONE = 0, + D3D12_RLDO_SUMMARY = 0x1, + D3D12_RLDO_DETAIL = 0x2, + D3D12_RLDO_IGNORE_INTERNAL = 0x4, +}} +ENUM!{enum D3D12_DEBUG_DEVICE_PARAMETER_TYPE { + D3D12_DEBUG_DEVICE_PARAMETER_FEATURE_FLAGS = 0, + D3D12_DEBUG_DEVICE_PARAMETER_GPU_BASED_VALIDATION_SETTINGS = 1, + D3D12_DEBUG_DEVICE_PARAMETER_GPU_SLOWDOWN_PERFORMANCE_FACTOR = 2, +}} +ENUM!{enum D3D12_DEBUG_FEATURE { + D3D12_DEBUG_FEATURE_NONE = 0, + D3D12_DEBUG_FEATURE_TREAT_BUNDLE_AS_DRAW = 0x1, + D3D12_DEBUG_FEATURE_TREAT_BUNDLE_AS_DISPATCH = 0x2, + D3D12_DEBUG_FEATURE_DISABLE_VIRTUALIZED_BUNDLES_VALIDATION = 0x04, + D3D12_DEBUG_FEATURE_VALID_MASK = 0x7, +}} +ENUM!{enum D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE { + D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_NONE = 0, + D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_STATE_TRACKING_ONLY = 1, + D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_UNGUARDED_VALIDATION = 2, + D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_GUARDED_VALIDATION = 3, + NUM_D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODES = 4, +}} +ENUM!{enum D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS { + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_NONE = 0, + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_FRONT_LOAD_CREATE_TRACKING_ONLY_SHADERS + = 0x01, + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_FRONT_LOAD_CREATE_UNGUARDED_VALIDATION_SHADERS = 0x02, + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_FRONT_LOAD_CREATE_GUARDED_VALIDATION_SHADERS = 0x04, + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS_VALID_MASK = 0x07, +}} +STRUCT!{struct D3D12_DEBUG_DEVICE_GPU_BASED_VALIDATION_SETTINGS { + MaxMessagesPerCommandList: UINT, + DefaultShaderPatchMode: D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE, + PipelineStateCreateFlags: D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS, +}} +STRUCT!{struct D3D12_DEBUG_DEVICE_GPU_SLOWDOWN_PERFORMANCE_FACTOR { + SlowdownFactor: FLOAT, +}} +RIDL!{#[uuid(0x3febd6dd, 0x4973, 0x4787, 0x81, 0x94, 0xe4, 0x5f, 0x9e, 0x28, 0x92, 0x3e)] +interface ID3D12DebugDevice1(ID3D12DebugDevice1Vtbl): IUnknown(IUnknownVtbl) { + fn SetDebugParameter( + Type: D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE, + pData: *const c_void, + DataSize: UINT, + ) -> HRESULT, + fn GetDebugParameter( + Type: D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE, + pData: *mut c_void, + DataSize: UINT, + ) -> HRESULT, + fn ReportLiveDeviceObjects( + Flags: D3D12_RLDO_FLAGS, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3febd6dd, 0x4973, 0x4787, 0x81, 0x94, 0xe4, 0x5f, 0x9e, 0x28, 0x92, 0x3e)] +interface ID3D12DebugDevice(ID3D12DebugDeviceVtbl): IUnknown(IUnknownVtbl) { + fn SetFeatureMask( + Mask: D3D12_DEBUG_FEATURE, + ) -> HRESULT, + fn GetFeatureMask() -> D3D12_DEBUG_FEATURE, + fn ReportLiveDeviceObjects( + Flags: D3D12_RLDO_FLAGS, + ) -> HRESULT, +}} +DEFINE_GUID!{DXGI_DEBUG_D3D12, + 0xcf59a98c, 0xa950, 0x4326, 0x91, 0xef, 0x9b, 0xba, 0xa1, 0x7b, 0xfd, 0x95} +RIDL!{#[uuid(0x09e0bf36, 0x54ac, 0x484f, 0x88, 0x47, 0x4b, 0xae, 0xea, 0xb6, 0x05, 0x3a)] +interface ID3D12DebugCommandQueue(ID3D12DebugCommandQueueVtbl): IUnknown(IUnknownVtbl) { + fn AssertResourceState( + pResource: *mut ID3D12Resource, + Subresource: UINT, + State: UINT, + ) -> BOOL, +}} +ENUM!{enum D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE { + D3D12_DEBUG_COMMAND_LIST_PARAMETER_GPU_BASED_VALIDATION_SETTINGS = 0, +}} +STRUCT!{struct D3D12_DEBUG_COMMAND_LIST_GPU_BASED_VALIDATION_SETTINGS { + ShaderPatchMode: D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE, +}} +RIDL!{#[uuid(0x102ca951, 0x311b, 0x4b01, 0xb1, 0x1f, 0xec, 0xb8, 0x3e, 0x06, 0x1b, 0x37)] +interface ID3D12DebugCommandList1(ID3D12DebugCommandList1Vtbl): IUnknown(IUnknownVtbl) { + fn AssertResourceState( + pResource: *mut ID3D12Resource, + Subresource: UINT, + State: UINT, + ) -> BOOL, + fn SetDebugParameter( + Type: D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE, + pData: *const c_void, + DataSize: UINT, + ) -> HRESULT, + fn GetDebugParameter( + Type: D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE, + pData: *mut c_void, + DataSize: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x09e0bf36, 0x54ac, 0x484f, 0x88, 0x47, 0x4b, 0xae, 0xea, 0xb6, 0x05, 0x3f)] +interface ID3D12DebugCommandList(ID3D12DebugCommandListVtbl): IUnknown(IUnknownVtbl) { + fn AssertResourceState( + pResource: *mut ID3D12Resource, + Subresource: UINT, + State: UINT, + ) -> BOOL, + fn SetFeatureMask( + Mask: D3D12_DEBUG_FEATURE, + ) -> HRESULT, + fn GetFeatureMask() -> D3D12_DEBUG_FEATURE, +}} +ENUM!{enum D3D12_MESSAGE_CATEGORY { + D3D12_MESSAGE_CATEGORY_APPLICATION_DEFINED = 0, + D3D12_MESSAGE_CATEGORY_MISCELLANEOUS = 1, + D3D12_MESSAGE_CATEGORY_INITIALIZATION = 2, + D3D12_MESSAGE_CATEGORY_CLEANUP = 3, + D3D12_MESSAGE_CATEGORY_COMPILATION = 4, + D3D12_MESSAGE_CATEGORY_STATE_CREATION = 5, + D3D12_MESSAGE_CATEGORY_STATE_SETTING = 6, + D3D12_MESSAGE_CATEGORY_STATE_GETTING = 7, + D3D12_MESSAGE_CATEGORY_RESOURCE_MANIPULATION = 8, + D3D12_MESSAGE_CATEGORY_EXECUTION = 9, + D3D12_MESSAGE_CATEGORY_SHADER = 10, +}} +ENUM!{enum D3D12_MESSAGE_SEVERITY { + D3D12_MESSAGE_SEVERITY_CORRUPTION = 0, + D3D12_MESSAGE_SEVERITY_ERROR = 1, + D3D12_MESSAGE_SEVERITY_WARNING = 2, + D3D12_MESSAGE_SEVERITY_INFO = 3, + D3D12_MESSAGE_SEVERITY_MESSAGE = 4, +}} +ENUM!{enum D3D12_MESSAGE_ID { + D3D12_MESSAGE_ID_UNKNOWN = 0, + D3D12_MESSAGE_ID_STRING_FROM_APPLICATION = 1, + D3D12_MESSAGE_ID_CORRUPTED_THIS = 2, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER1 = 3, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER2 = 4, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER3 = 5, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER4 = 6, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER5 = 7, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER6 = 8, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER7 = 9, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER8 = 10, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER9 = 11, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER10 = 12, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER11 = 13, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER12 = 14, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER13 = 15, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER14 = 16, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER15 = 17, + D3D12_MESSAGE_ID_CORRUPTED_MULTITHREADING = 18, + D3D12_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY = 19, + D3D12_MESSAGE_ID_GETPRIVATEDATA_MOREDATA = 20, + D3D12_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA = 21, + D3D12_MESSAGE_ID_SETPRIVATEDATA_INVALIDIUNKNOWN = 22, + D3D12_MESSAGE_ID_SETPRIVATEDATA_INVALIDFLAGS = 23, + D3D12_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS = 24, + D3D12_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY = 25, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT = 26, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC = 27, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT = 28, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDVIDEOPLANESLICE = 29, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDPLANESLICE = 30, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS = 31, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE = 32, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN = 33, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_OUTOFMEMORY_RETURN = 34, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT = 35, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT = 36, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC = 37, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT = 38, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDVIDEOPLANESLICE = 39, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDPLANESLICE = 40, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS = 41, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE = 42, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDARG_RETURN = 43, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_OUTOFMEMORY_RETURN = 44, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT = 45, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC = 46, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT = 47, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS = 48, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE = 49, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN = 50, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_OUTOFMEMORY_RETURN = 51, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY = 52, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS = 53, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT = 54, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT = 55, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT = 56, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS = 57, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH = 58, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE = 59, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE = 60, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT = 61, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC = 62, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE = 63, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC = 64, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT = 65, + D3D12_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY = 66, + D3D12_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE = 67, + D3D12_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE = 68, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY = 69, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE = 70, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE = 71, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY = 72, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE = 73, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE = 74, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES = 75, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED = 76, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDDECL = 77, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_EXPECTEDDECL = 78, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED = 79, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT = 80, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT = 81, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT = 82, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT + = 83, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION = 84, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT = 85, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE = 86, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC = 87, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH = 88, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS = 89, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX = 90, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE = 91, + D3D12_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY = 92, + D3D12_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE = 93, + D3D12_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE = 94, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE = 95, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE = 96, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP = 97, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS = 98, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_NULLDESC = 99, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK = 100, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC = 101, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP = 102, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP = 103, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP = 104, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC = 105, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP = 106, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP = 107, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP = 108, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC = 109, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_NULLDESC = 110, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND = 111, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND = 112, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP = 113, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA = 114, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA = 115, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA = 116, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK = 117, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_NULLDESC = 118, + D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDFILTER = 119, + D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSU = 120, + D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSV = 121, + D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSW = 122, + D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMIPLODBIAS = 123, + D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXANISOTROPY = 124, + D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDCOMPARISONFUNC = 125, + D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMINLOD = 126, + D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXLOD = 127, + D3D12_MESSAGE_ID_CREATESAMPLERSTATE_NULLDESC = 128, + D3D12_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNRECOGNIZED = 129, + D3D12_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNDEFINED = 130, + D3D12_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_INVALIDVIEWPORT = 131, + D3D12_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_INVALIDSCISSOR = 132, + D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_DENORMFLUSH = 133, + D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DENORMFLUSH = 134, + D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_INVALID = 135, + D3D12_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCE = 136, + D3D12_MESSAGE_ID_COPYRESOURCE_INVALIDDESTINATIONSTATE = 137, + D3D12_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCESTATE = 138, + D3D12_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSUBRESOURCE = 139, + D3D12_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONBOX = 140, + D3D12_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE = 141, + D3D12_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_INVALID = 142, + D3D12_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_SUBRESOURCE_INVALID = 143, + D3D12_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_INVALID = 144, + D3D12_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_SUBRESOURCE_INVALID = 145, + D3D12_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_FORMAT_INVALID = 146, + D3D12_MESSAGE_ID_BUFFER_MAP_INVALIDMAPTYPE = 147, + D3D12_MESSAGE_ID_BUFFER_MAP_INVALIDFLAGS = 148, + D3D12_MESSAGE_ID_BUFFER_MAP_ALREADYMAPPED = 149, + D3D12_MESSAGE_ID_BUFFER_MAP_DEVICEREMOVED_RETURN = 150, + D3D12_MESSAGE_ID_BUFFER_UNMAP_NOTMAPPED = 151, + D3D12_MESSAGE_ID_TEXTURE1D_MAP_INVALIDMAPTYPE = 152, + D3D12_MESSAGE_ID_TEXTURE1D_MAP_INVALIDSUBRESOURCE = 153, + D3D12_MESSAGE_ID_TEXTURE1D_MAP_INVALIDFLAGS = 154, + D3D12_MESSAGE_ID_TEXTURE1D_MAP_ALREADYMAPPED = 155, + D3D12_MESSAGE_ID_TEXTURE1D_MAP_DEVICEREMOVED_RETURN = 156, + D3D12_MESSAGE_ID_TEXTURE1D_UNMAP_INVALIDSUBRESOURCE = 157, + D3D12_MESSAGE_ID_TEXTURE1D_UNMAP_NOTMAPPED = 158, + D3D12_MESSAGE_ID_TEXTURE2D_MAP_INVALIDMAPTYPE = 159, + D3D12_MESSAGE_ID_TEXTURE2D_MAP_INVALIDSUBRESOURCE = 160, + D3D12_MESSAGE_ID_TEXTURE2D_MAP_INVALIDFLAGS = 161, + D3D12_MESSAGE_ID_TEXTURE2D_MAP_ALREADYMAPPED = 162, + D3D12_MESSAGE_ID_TEXTURE2D_MAP_DEVICEREMOVED_RETURN = 163, + D3D12_MESSAGE_ID_TEXTURE2D_UNMAP_INVALIDSUBRESOURCE = 164, + D3D12_MESSAGE_ID_TEXTURE2D_UNMAP_NOTMAPPED = 165, + D3D12_MESSAGE_ID_TEXTURE3D_MAP_INVALIDMAPTYPE = 166, + D3D12_MESSAGE_ID_TEXTURE3D_MAP_INVALIDSUBRESOURCE = 167, + D3D12_MESSAGE_ID_TEXTURE3D_MAP_INVALIDFLAGS = 168, + D3D12_MESSAGE_ID_TEXTURE3D_MAP_ALREADYMAPPED = 169, + D3D12_MESSAGE_ID_TEXTURE3D_MAP_DEVICEREMOVED_RETURN = 170, + D3D12_MESSAGE_ID_TEXTURE3D_UNMAP_INVALIDSUBRESOURCE = 171, + D3D12_MESSAGE_ID_TEXTURE3D_UNMAP_NOTMAPPED = 172, + D3D12_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_DEPRECATED = 173, + D3D12_MESSAGE_ID_CHECKMULTISAMPLEQUALITYLEVELS_FORMAT_DEPRECATED = 174, + D3D12_MESSAGE_ID_SETEXCEPTIONMODE_UNRECOGNIZEDFLAGS = 175, + D3D12_MESSAGE_ID_SETEXCEPTIONMODE_INVALIDARG_RETURN = 176, + D3D12_MESSAGE_ID_SETEXCEPTIONMODE_DEVICEREMOVED_RETURN = 177, + D3D12_MESSAGE_ID_REF_SIMULATING_INFINITELY_FAST_HARDWARE = 178, + D3D12_MESSAGE_ID_REF_THREADING_MODE = 179, + D3D12_MESSAGE_ID_REF_UMDRIVER_EXCEPTION = 180, + D3D12_MESSAGE_ID_REF_KMDRIVER_EXCEPTION = 181, + D3D12_MESSAGE_ID_REF_HARDWARE_EXCEPTION = 182, + D3D12_MESSAGE_ID_REF_ACCESSING_INDEXABLE_TEMP_OUT_OF_RANGE = 183, + D3D12_MESSAGE_ID_REF_PROBLEM_PARSING_SHADER = 184, + D3D12_MESSAGE_ID_REF_OUT_OF_MEMORY = 185, + D3D12_MESSAGE_ID_REF_INFO = 186, + D3D12_MESSAGE_ID_DEVICE_DRAW_VERTEXPOS_OVERFLOW = 187, + D3D12_MESSAGE_ID_DEVICE_DRAWINDEXED_INDEXPOS_OVERFLOW = 188, + D3D12_MESSAGE_ID_DEVICE_DRAWINSTANCED_VERTEXPOS_OVERFLOW = 189, + D3D12_MESSAGE_ID_DEVICE_DRAWINSTANCED_INSTANCEPOS_OVERFLOW = 190, + D3D12_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INSTANCEPOS_OVERFLOW = 191, + D3D12_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INDEXPOS_OVERFLOW = 192, + D3D12_MESSAGE_ID_DEVICE_DRAW_VERTEX_SHADER_NOT_SET = 193, + D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND = 194, + D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERINDEX = 195, + D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_COMPONENTTYPE = 196, + D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERMASK = 197, + D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SYSTEMVALUE = 198, + D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS = 199, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_ROOT_SIGNATURE_NOT_SET = 200, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_ROOT_SIGNATURE_MISMATCH = 201, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_NOT_SET = 202, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INPUTLAYOUT_NOT_SET = 203, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_CONSTANT_BUFFER_NOT_SET = 204, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_CONSTANT_BUFFER_TOO_SMALL = 205, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_SAMPLER_NOT_SET = 206, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_SHADERRESOURCEVIEW_NOT_SET = 207, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VIEW_DIMENSION_MISMATCH = 208, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL = 209, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_TOO_SMALL = 210, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_BUFFER_NOT_SET = 211, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_BUFFER_FORMAT_INVALID = 212, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_BUFFER_TOO_SMALL = 213, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_GS_INPUT_PRIMITIVE_MISMATCH = 214, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RESOURCE_RETURN_TYPE_MISMATCH = 215, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_POSITION_NOT_PRESENT = 216, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_OUTPUT_STREAM_NOT_SET = 217, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_BOUND_RESOURCE_MAPPED = 218, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INVALID_PRIMITIVETOPOLOGY = 219, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_OFFSET_UNALIGNED = 220, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_STRIDE_UNALIGNED = 221, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_OFFSET_UNALIGNED = 222, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_OUTPUT_STREAM_OFFSET_UNALIGNED = 223, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RESOURCE_FORMAT_LD_UNSUPPORTED = 224, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED = 225, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED = 226, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RESOURCE_MULTISAMPLE_UNSUPPORTED = 227, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_SO_TARGETS_BOUND_WITHOUT_SOURCE = 228, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_SO_STRIDE_LARGER_THAN_BUFFER = 229, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_OM_RENDER_TARGET_DOES_NOT_SUPPORT_BLENDING = 230, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_OM_DUAL_SOURCE_BLENDING_CAN_ONLY_HAVE_RENDER_TARGET_0 = 231, + D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_AT_FAULT = 232, + D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_POSSIBLY_AT_FAULT = 233, + D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT = 234, + D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_INVALIDARG_RETURN = 235, + D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_OUTOFMEMORY_RETURN = 236, + D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_BADINTERFACE_RETURN = 237, + D3D12_MESSAGE_ID_DEVICE_DRAW_VIEWPORT_NOT_SET = 238, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TRAILING_DIGIT_IN_SEMANTIC = 239, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_TRAILING_DIGIT_IN_SEMANTIC = 240, + D3D12_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_DENORMFLUSH = 241, + D3D12_MESSAGE_ID_OMSETRENDERTARGETS_INVALIDVIEW = 242, + D3D12_MESSAGE_ID_DEVICE_SETTEXTFILTERSIZE_INVALIDDIMENSIONS = 243, + D3D12_MESSAGE_ID_DEVICE_DRAW_SAMPLER_MISMATCH = 244, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH = 245, + D3D12_MESSAGE_ID_BLENDSTATE_GETDESC_LEGACY = 246, + D3D12_MESSAGE_ID_SHADERRESOURCEVIEW_GETDESC_LEGACY = 247, + D3D12_MESSAGE_ID_DEVICE_DRAW_PS_OUTPUT_TYPE_MISMATCH = 248, + D3D12_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_GATHER_UNSUPPORTED = 249, + D3D12_MESSAGE_ID_DEVICE_DRAW_INVALID_USE_OF_CENTER_MULTISAMPLE_PATTERN = 250, + D3D12_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_STRIDE_TOO_LARGE = 251, + D3D12_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_INVALIDRANGE = 252, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_EMPTY_LAYOUT = 253, + D3D12_MESSAGE_ID_DEVICE_DRAW_RESOURCE_SAMPLE_COUNT_MISMATCH = 254, + D3D12_MESSAGE_ID_LIVE_OBJECT_SUMMARY = 255, + D3D12_MESSAGE_ID_LIVE_BUFFER = 256, + D3D12_MESSAGE_ID_LIVE_TEXTURE1D = 257, + D3D12_MESSAGE_ID_LIVE_TEXTURE2D = 258, + D3D12_MESSAGE_ID_LIVE_TEXTURE3D = 259, + D3D12_MESSAGE_ID_LIVE_SHADERRESOURCEVIEW = 260, + D3D12_MESSAGE_ID_LIVE_RENDERTARGETVIEW = 261, + D3D12_MESSAGE_ID_LIVE_DEPTHSTENCILVIEW = 262, + D3D12_MESSAGE_ID_LIVE_VERTEXSHADER = 263, + D3D12_MESSAGE_ID_LIVE_GEOMETRYSHADER = 264, + D3D12_MESSAGE_ID_LIVE_PIXELSHADER = 265, + D3D12_MESSAGE_ID_LIVE_INPUTLAYOUT = 266, + D3D12_MESSAGE_ID_LIVE_SAMPLER = 267, + D3D12_MESSAGE_ID_LIVE_BLENDSTATE = 268, + D3D12_MESSAGE_ID_LIVE_DEPTHSTENCILSTATE = 269, + D3D12_MESSAGE_ID_LIVE_RASTERIZERSTATE = 270, + D3D12_MESSAGE_ID_LIVE_QUERY = 271, + D3D12_MESSAGE_ID_LIVE_PREDICATE = 272, + D3D12_MESSAGE_ID_LIVE_COUNTER = 273, + D3D12_MESSAGE_ID_LIVE_DEVICE = 274, + D3D12_MESSAGE_ID_LIVE_SWAPCHAIN = 275, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFLAGS = 276, + D3D12_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDCLASSLINKAGE = 277, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDCLASSLINKAGE = 278, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTREAMS = 279, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAMTORASTERIZER = 280, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTREAMS = 281, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCLASSLINKAGE = 282, + D3D12_MESSAGE_ID_CREATEPIXELSHADER_INVALIDCLASSLINKAGE = 283, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAM = 284, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDENTRIES = 285, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTRIDES = 286, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTRIDES = 287, + D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDCALL = 288, + D3D12_MESSAGE_ID_CREATEHULLSHADER_OUTOFMEMORY = 289, + D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERBYTECODE = 290, + D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERTYPE = 291, + D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDCLASSLINKAGE = 292, + D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCALL = 293, + D3D12_MESSAGE_ID_CREATEDOMAINSHADER_OUTOFMEMORY = 294, + D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERBYTECODE = 295, + D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERTYPE = 296, + D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCLASSLINKAGE = 297, + D3D12_MESSAGE_ID_DEVICE_DRAW_HS_XOR_DS_MISMATCH = 298, + D3D12_MESSAGE_ID_DEVICE_DRAWINDIRECT_INVALID_ARG_BUFFER = 299, + D3D12_MESSAGE_ID_DEVICE_DRAWINDIRECT_OFFSET_UNALIGNED = 300, + D3D12_MESSAGE_ID_DEVICE_DRAWINDIRECT_OFFSET_OVERFLOW = 301, + D3D12_MESSAGE_ID_RESOURCE_MAP_INVALIDMAPTYPE = 302, + D3D12_MESSAGE_ID_RESOURCE_MAP_INVALIDSUBRESOURCE = 303, + D3D12_MESSAGE_ID_RESOURCE_MAP_INVALIDFLAGS = 304, + D3D12_MESSAGE_ID_RESOURCE_MAP_ALREADYMAPPED = 305, + D3D12_MESSAGE_ID_RESOURCE_MAP_DEVICEREMOVED_RETURN = 306, + D3D12_MESSAGE_ID_RESOURCE_MAP_OUTOFMEMORY_RETURN = 307, + D3D12_MESSAGE_ID_RESOURCE_MAP_WITHOUT_INITIAL_DISCARD = 308, + D3D12_MESSAGE_ID_RESOURCE_UNMAP_INVALIDSUBRESOURCE = 309, + D3D12_MESSAGE_ID_RESOURCE_UNMAP_NOTMAPPED = 310, + D3D12_MESSAGE_ID_DEVICE_DRAW_RASTERIZING_CONTROL_POINTS = 311, + D3D12_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNSUPPORTED = 312, + D3D12_MESSAGE_ID_DEVICE_DRAW_HS_DS_SIGNATURE_MISMATCH = 313, + D3D12_MESSAGE_ID_DEVICE_DRAW_HULL_SHADER_INPUT_TOPOLOGY_MISMATCH = 314, + D3D12_MESSAGE_ID_DEVICE_DRAW_HS_DS_CONTROL_POINT_COUNT_MISMATCH = 315, + D3D12_MESSAGE_ID_DEVICE_DRAW_HS_DS_TESSELLATOR_DOMAIN_MISMATCH = 316, + D3D12_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_UNRECOGNIZED_FEATURE = 317, + D3D12_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_MISMATCHED_DATA_SIZE = 318, + D3D12_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_INVALIDARG_RETURN = 319, + D3D12_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCALL = 320, + D3D12_MESSAGE_ID_CREATECOMPUTESHADER_OUTOFMEMORY = 321, + D3D12_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDSHADERBYTECODE = 322, + D3D12_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCLASSLINKAGE = 323, + D3D12_MESSAGE_ID_DEVICE_CSSETSHADERRESOURCES_VIEWS_EMPTY = 324, + D3D12_MESSAGE_ID_CSSETCONSTANTBUFFERS_INVALIDBUFFER = 325, + D3D12_MESSAGE_ID_DEVICE_CSSETCONSTANTBUFFERS_BUFFERS_EMPTY = 326, + D3D12_MESSAGE_ID_DEVICE_CSSETSAMPLERS_SAMPLERS_EMPTY = 327, + D3D12_MESSAGE_ID_DEVICE_CSGETSHADERRESOURCES_VIEWS_EMPTY = 328, + D3D12_MESSAGE_ID_DEVICE_CSGETCONSTANTBUFFERS_BUFFERS_EMPTY = 329, + D3D12_MESSAGE_ID_DEVICE_CSGETSAMPLERS_SAMPLERS_EMPTY = 330, + D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 331, + D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 332, + D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 333, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 334, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEFLOATOPSNOTSUPPORTED = 335, + D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 336, + D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEFLOATOPSNOTSUPPORTED = 337, + D3D12_MESSAGE_ID_CREATEBUFFER_INVALIDSTRUCTURESTRIDE = 338, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFLAGS = 339, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDRESOURCE = 340, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDESC = 341, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFORMAT = 342, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDVIDEOPLANESLICE = 343, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDPLANESLICE = 344, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDIMENSIONS = 345, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_UNRECOGNIZEDFORMAT = 346, + D3D12_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_OVERLAPPING_OLD_SLOTS = 347, + D3D12_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_NO_OP = 348, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDARG_RETURN = 349, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_OUTOFMEMORY_RETURN = 350, + D3D12_MESSAGE_ID_CLEARUNORDEREDACCESSVIEW_DENORMFLUSH = 351, + D3D12_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSS_VIEWS_EMPTY = 352, + D3D12_MESSAGE_ID_DEVICE_CSGETUNORDEREDACCESSS_VIEWS_EMPTY = 353, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFLAGS = 354, + D3D12_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_INVALID_ARG_BUFFER = 355, + D3D12_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_OFFSET_UNALIGNED = 356, + D3D12_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_OFFSET_OVERFLOW = 357, + D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DEPTH_READONLY = 358, + D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_STENCIL_READONLY = 359, + D3D12_MESSAGE_ID_CHECKFEATURESUPPORT_FORMAT_DEPRECATED = 360, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_RETURN_TYPE_MISMATCH = 361, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_NOT_SET = 362, + D3D12_MESSAGE_ID_DEVICE_DRAW_UNORDEREDACCESSVIEW_RENDERTARGETVIEW_OVERLAP = 363, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_DIMENSION_MISMATCH = 364, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_APPEND_UNSUPPORTED = 365, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMICS_UNSUPPORTED = 366, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_STRUCTURE_STRIDE_MISMATCH = 367, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_BUFFER_TYPE_MISMATCH = 368, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_RAW_UNSUPPORTED = 369, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_FORMAT_LD_UNSUPPORTED = 370, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_FORMAT_STORE_UNSUPPORTED = 371, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_ADD_UNSUPPORTED = 372, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_BITWISE_OPS_UNSUPPORTED = 373, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_CMPSTORE_CMPEXCHANGE_UNSUPPORTED = 374, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_EXCHANGE_UNSUPPORTED = 375, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_SIGNED_MINMAX_UNSUPPORTED = 376, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_UNSIGNED_MINMAX_UNSUPPORTED = 377, + D3D12_MESSAGE_ID_DEVICE_DISPATCH_BOUND_RESOURCE_MAPPED = 378, + D3D12_MESSAGE_ID_DEVICE_DISPATCH_THREADGROUPCOUNT_OVERFLOW = 379, + D3D12_MESSAGE_ID_DEVICE_DISPATCH_THREADGROUPCOUNT_ZERO = 380, + D3D12_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_STRUCTURE_STRIDE_MISMATCH = 381, + D3D12_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_BUFFER_TYPE_MISMATCH = 382, + D3D12_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_RAW_UNSUPPORTED = 383, + D3D12_MESSAGE_ID_DEVICE_DISPATCH_UNSUPPORTED = 384, + D3D12_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_UNSUPPORTED = 385, + D3D12_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDOFFSET = 386, + D3D12_MESSAGE_ID_COPYSTRUCTURECOUNT_LARGEOFFSET = 387, + D3D12_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDDESTINATIONSTATE = 388, + D3D12_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDSOURCESTATE = 389, + D3D12_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_NOT_SUPPORTED = 390, + D3D12_MESSAGE_ID_CLEARUNORDEREDACCESSVIEWFLOAT_INVALIDFORMAT = 391, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_COUNTER_UNSUPPORTED = 392, + D3D12_MESSAGE_ID_DEVICE_DRAW_PIXEL_SHADER_WITHOUT_RTV_OR_DSV = 393, + D3D12_MESSAGE_ID_SHADER_ABORT = 394, + D3D12_MESSAGE_ID_SHADER_MESSAGE = 395, + D3D12_MESSAGE_ID_SHADER_ERROR = 396, + D3D12_MESSAGE_ID_OFFERRESOURCES_INVALIDRESOURCE = 397, + D3D12_MESSAGE_ID_ENQUEUESETEVENT_INVALIDARG_RETURN = 398, + D3D12_MESSAGE_ID_ENQUEUESETEVENT_OUTOFMEMORY_RETURN = 399, + D3D12_MESSAGE_ID_ENQUEUESETEVENT_ACCESSDENIED_RETURN = 400, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFORCEDSAMPLECOUNT = 401, + D3D12_MESSAGE_ID_DEVICE_DRAW_INVALID_USE_OF_FORCED_SAMPLE_COUNT = 402, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDLOGICOPS = 403, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDARRAYWITHDECODER = 404, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDARRAYWITHDECODER = 405, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDARRAYWITHDECODER = 406, + D3D12_MESSAGE_ID_DEVICE_LOCKEDOUT_INTERFACE = 407, + D3D12_MESSAGE_ID_OFFERRESOURCES_INVALIDPRIORITY = 408, + D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDVIEW = 409, + D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 410, + D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_SHADEREXTENSIONSNOTSUPPORTED = 411, + D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 412, + D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_SHADEREXTENSIONSNOTSUPPORTED = 413, + D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 414, + D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_SHADEREXTENSIONSNOTSUPPORTED = 415, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 416, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_SHADEREXTENSIONSNOTSUPPORTED = 417, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEEXTENSIONSNOTSUPPORTED + = 418, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_SHADEREXTENSIONSNOTSUPPORTED + = 419, + D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 420, + D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_SHADEREXTENSIONSNOTSUPPORTED = 421, + D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 422, + D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_SHADEREXTENSIONSNOTSUPPORTED = 423, + D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_MINPRECISION = 424, + D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_UAVSNOTSUPPORTED = 425, + D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_UAVSNOTSUPPORTED = 426, + D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_UAVSNOTSUPPORTED = 427, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_UAVSNOTSUPPORTED = 428, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UAVSNOTSUPPORTED = 429, + D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_UAVSNOTSUPPORTED = 430, + D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_UAVSNOTSUPPORTED = 431, + D3D12_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_INVALIDOFFSET = 432, + D3D12_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_TOOMANYVIEWS = 433, + D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_NOTSUPPORTED = 434, + D3D12_MESSAGE_ID_SWAPDEVICECONTEXTSTATE_NOTSUPPORTED = 435, + D3D12_MESSAGE_ID_UPDATESUBRESOURCE_PREFERUPDATESUBRESOURCE1 = 436, + D3D12_MESSAGE_ID_GETDC_INACCESSIBLE = 437, + D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDRECT = 438, + D3D12_MESSAGE_ID_DEVICE_DRAW_SAMPLE_MASK_IGNORED_ON_FL9 = 439, + D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE1_NOT_SUPPORTED = 440, + D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_BY_NAME_NOT_SUPPORTED = 441, + D3D12_MESSAGE_ID_ENQUEUESETEVENT_NOT_SUPPORTED = 442, + D3D12_MESSAGE_ID_OFFERRELEASE_NOT_SUPPORTED = 443, + D3D12_MESSAGE_ID_OFFERRESOURCES_INACCESSIBLE = 444, + D3D12_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDMSAA = 445, + D3D12_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDMSAA = 446, + D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDSOURCERECT = 447, + D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_EMPTYRECT = 448, + D3D12_MESSAGE_ID_UPDATESUBRESOURCE_EMPTYDESTBOX = 449, + D3D12_MESSAGE_ID_COPYSUBRESOURCEREGION_EMPTYSOURCEBOX = 450, + D3D12_MESSAGE_ID_DEVICE_DRAW_OM_RENDER_TARGET_DOES_NOT_SUPPORT_LOGIC_OPS = 451, + D3D12_MESSAGE_ID_DEVICE_DRAW_DEPTHSTENCILVIEW_NOT_SET = 452, + D3D12_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET = 453, + D3D12_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET_DUE_TO_FLIP_PRESENT = 454, + D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_NOT_SET_DUE_TO_FLIP_PRESENT = 455, + D3D12_MESSAGE_ID_GETDATAFORNEWHARDWAREKEY_NULLPARAM = 456, + D3D12_MESSAGE_ID_CHECKCRYPTOSESSIONSTATUS_NULLPARAM = 457, + D3D12_MESSAGE_ID_SETEVENTONHARDWARECONTENTPROTECTIONTILT_NULLPARAM = 458, + D3D12_MESSAGE_ID_GETVIDEODECODERCAPS_NULLPARAM = 459, + D3D12_MESSAGE_ID_GETVIDEODECODERCAPS_ZEROWIDTHHEIGHT = 460, + D3D12_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_NULLPARAM = 461, + D3D12_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_INVALIDCOLORSPACE = 462, + D3D12_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_ZEROWIDTHHEIGHT = 463, + D3D12_MESSAGE_ID_VIDEODECODERENABLEDOWNSAMPLING_NULLPARAM = 464, + D3D12_MESSAGE_ID_VIDEODECODERENABLEDOWNSAMPLING_UNSUPPORTED = 465, + D3D12_MESSAGE_ID_VIDEODECODERUPDATEDOWNSAMPLING_NULLPARAM = 466, + D3D12_MESSAGE_ID_VIDEODECODERUPDATEDOWNSAMPLING_UNSUPPORTED = 467, + D3D12_MESSAGE_ID_CHECKVIDEOPROCESSORFORMATCONVERSION_NULLPARAM = 468, + D3D12_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCOLORSPACE1_NULLPARAM = 469, + D3D12_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTCOLORSPACE1_NULLPARAM = 470, + D3D12_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE1_NULLPARAM = 471, + D3D12_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE1_INVALIDSTREAM = 472, + D3D12_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_NULLPARAM = 473, + D3D12_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_INVALIDSTREAM = 474, + D3D12_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_UNSUPPORTED = 475, + D3D12_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE1_NULLPARAM = 476, + D3D12_MESSAGE_ID_VIDEOPROCESSORGETSTREAMMIRROR_NULLPARAM = 477, + D3D12_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_NULLPARAM = 478, + D3D12_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_INVALIDCOLORSPACE = 479, + D3D12_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_ZEROWIDTHHEIGHT = 480, + D3D12_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTSHADERUSAGE_NULLPARAM = 481, + D3D12_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTSHADERUSAGE_NULLPARAM = 482, + D3D12_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_NULLPARAM = 483, + D3D12_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSTREAMCOUNT = 484, + D3D12_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_TARGETRECT = 485, + D3D12_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSOURCERECT = 486, + D3D12_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDDESTRECT = 487, + D3D12_MESSAGE_ID_CREATEBUFFER_INVALIDUSAGE = 488, + D3D12_MESSAGE_ID_CREATETEXTURE1D_INVALIDUSAGE = 489, + D3D12_MESSAGE_ID_CREATETEXTURE2D_INVALIDUSAGE = 490, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_LEVEL9_STEPRATE_NOT_1 = 491, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_LEVEL9_INSTANCING_NOT_SUPPORTED = 492, + D3D12_MESSAGE_ID_UPDATETILEMAPPINGS_INVALID_PARAMETER = 493, + D3D12_MESSAGE_ID_COPYTILEMAPPINGS_INVALID_PARAMETER = 494, + D3D12_MESSAGE_ID_COPYTILES_INVALID_PARAMETER = 495, + D3D12_MESSAGE_ID_NULL_TILE_MAPPING_ACCESS_WARNING = 496, + D3D12_MESSAGE_ID_NULL_TILE_MAPPING_ACCESS_ERROR = 497, + D3D12_MESSAGE_ID_DIRTY_TILE_MAPPING_ACCESS = 498, + D3D12_MESSAGE_ID_DUPLICATE_TILE_MAPPINGS_IN_COVERED_AREA = 499, + D3D12_MESSAGE_ID_TILE_MAPPINGS_IN_COVERED_AREA_DUPLICATED_OUTSIDE = 500, + D3D12_MESSAGE_ID_TILE_MAPPINGS_SHARED_BETWEEN_INCOMPATIBLE_RESOURCES = 501, + D3D12_MESSAGE_ID_TILE_MAPPINGS_SHARED_BETWEEN_INPUT_AND_OUTPUT = 502, + D3D12_MESSAGE_ID_CHECKMULTISAMPLEQUALITYLEVELS_INVALIDFLAGS = 503, + D3D12_MESSAGE_ID_GETRESOURCETILING_NONTILED_RESOURCE = 504, + D3D12_MESSAGE_ID_NEED_TO_CALL_TILEDRESOURCEBARRIER = 505, + D3D12_MESSAGE_ID_CREATEDEVICE_INVALIDARGS = 506, + D3D12_MESSAGE_ID_CREATEDEVICE_WARNING = 507, + D3D12_MESSAGE_ID_TILED_RESOURCE_TIER_1_BUFFER_TEXTURE_MISMATCH = 508, + D3D12_MESSAGE_ID_CREATE_CRYPTOSESSION = 509, + D3D12_MESSAGE_ID_CREATE_AUTHENTICATEDCHANNEL = 510, + D3D12_MESSAGE_ID_LIVE_CRYPTOSESSION = 511, + D3D12_MESSAGE_ID_LIVE_AUTHENTICATEDCHANNEL = 512, + D3D12_MESSAGE_ID_DESTROY_CRYPTOSESSION = 513, + D3D12_MESSAGE_ID_DESTROY_AUTHENTICATEDCHANNEL = 514, + D3D12_MESSAGE_ID_MAP_INVALID_SUBRESOURCE = 515, + D3D12_MESSAGE_ID_MAP_INVALID_TYPE = 516, + D3D12_MESSAGE_ID_MAP_UNSUPPORTED_TYPE = 517, + D3D12_MESSAGE_ID_UNMAP_INVALID_SUBRESOURCE = 518, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_TYPE = 519, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_NULL_POINTER = 520, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_SUBRESOURCE = 521, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_RESERVED_BITS = 522, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISSING_BIND_FLAGS = 523, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISMATCHING_MISC_FLAGS = 524, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_MATCHING_STATES = 525, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_COMBINATION = 526, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH = 527, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_RESOURCE = 528, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_SAMPLE_COUNT = 529, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_FLAGS = 530, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_COMBINED_FLAGS = 531, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_FLAGS_FOR_FORMAT = 532, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_SPLIT_BARRIER = 533, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_UNMATCHED_END = 534, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_UNMATCHED_BEGIN = 535, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_FLAG = 536, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_COMMAND_LIST_TYPE = 537, + D3D12_MESSAGE_ID_INVALID_SUBRESOURCE_STATE = 538, + D3D12_MESSAGE_ID_INEFFICIENT_PRESENT = 539, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_CONTENTION = 540, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_RESET = 541, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_RESET_BUNDLE = 542, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_CANNOT_RESET = 543, + D3D12_MESSAGE_ID_COMMAND_LIST_OPEN = 544, + D3D12_MESSAGE_ID_QUERY_STATE_MISMATCH = 545, + D3D12_MESSAGE_ID_INVALID_BUNDLE_API = 546, + D3D12_MESSAGE_ID_COMMAND_LIST_CLOSED = 547, + D3D12_MESSAGE_ID_COMMAND_LIST_CLOSED_WITH_INVALID_RESOURCE = 548, + D3D12_MESSAGE_ID_WRONG_COMMAND_ALLOCATOR_TYPE = 549, + D3D12_MESSAGE_ID_INVALID_INDIRECT_ARGUMENT_BUFFER = 550, + D3D12_MESSAGE_ID_COMPUTE_AND_GRAPHICS_PIPELINE = 551, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_SYNC = 552, + D3D12_MESSAGE_ID_COMMAND_LIST_SYNC = 553, + D3D12_MESSAGE_ID_SET_DESCRIPTOR_HEAP_INVALID = 554, + D3D12_MESSAGE_ID_CREATE_QUEUE_IMAGE_NOT_SUPPORTED = 555, + D3D12_MESSAGE_ID_CREATE_COMMAND_ALLOCATOR_IMAGE_NOT_SUPPORTED = 556, + D3D12_MESSAGE_ID_CREATE_COMMANDQUEUE = 557, + D3D12_MESSAGE_ID_CREATE_COMMANDALLOCATOR = 558, + D3D12_MESSAGE_ID_CREATE_PIPELINESTATE = 559, + D3D12_MESSAGE_ID_CREATE_COMMANDLIST12 = 560, + D3D12_MESSAGE_ID_CREATE_IMAGECOMMANDLIST = 561, + D3D12_MESSAGE_ID_CREATE_RESOURCE = 562, + D3D12_MESSAGE_ID_CREATE_DESCRIPTORHEAP = 563, + D3D12_MESSAGE_ID_CREATE_ROOTSIGNATURE = 564, + D3D12_MESSAGE_ID_CREATE_LIBRARY = 565, + D3D12_MESSAGE_ID_CREATE_HEAP = 566, + D3D12_MESSAGE_ID_CREATE_MONITOREDFENCE = 567, + D3D12_MESSAGE_ID_CREATE_QUERYHEAP = 568, + D3D12_MESSAGE_ID_CREATE_COMMANDSIGNATURE = 569, + D3D12_MESSAGE_ID_LIVE_COMMANDQUEUE = 570, + D3D12_MESSAGE_ID_LIVE_COMMANDALLOCATOR = 571, + D3D12_MESSAGE_ID_LIVE_PIPELINESTATE = 572, + D3D12_MESSAGE_ID_LIVE_COMMANDLIST12 = 573, + D3D12_MESSAGE_ID_LIVE_IMAGECOMMANDLIST = 574, + D3D12_MESSAGE_ID_LIVE_RESOURCE = 575, + D3D12_MESSAGE_ID_LIVE_DESCRIPTORHEAP = 576, + D3D12_MESSAGE_ID_LIVE_ROOTSIGNATURE = 577, + D3D12_MESSAGE_ID_LIVE_LIBRARY = 578, + D3D12_MESSAGE_ID_LIVE_HEAP = 579, + D3D12_MESSAGE_ID_LIVE_MONITOREDFENCE = 580, + D3D12_MESSAGE_ID_LIVE_QUERYHEAP = 581, + D3D12_MESSAGE_ID_LIVE_COMMANDSIGNATURE = 582, + D3D12_MESSAGE_ID_DESTROY_COMMANDQUEUE = 583, + D3D12_MESSAGE_ID_DESTROY_COMMANDALLOCATOR = 584, + D3D12_MESSAGE_ID_DESTROY_PIPELINESTATE = 585, + D3D12_MESSAGE_ID_DESTROY_COMMANDLIST12 = 586, + D3D12_MESSAGE_ID_DESTROY_IMAGECOMMANDLIST = 587, + D3D12_MESSAGE_ID_DESTROY_RESOURCE = 588, + D3D12_MESSAGE_ID_DESTROY_DESCRIPTORHEAP = 589, + D3D12_MESSAGE_ID_DESTROY_ROOTSIGNATURE = 590, + D3D12_MESSAGE_ID_DESTROY_LIBRARY = 591, + D3D12_MESSAGE_ID_DESTROY_HEAP = 592, + D3D12_MESSAGE_ID_DESTROY_MONITOREDFENCE = 593, + D3D12_MESSAGE_ID_DESTROY_QUERYHEAP = 594, + D3D12_MESSAGE_ID_DESTROY_COMMANDSIGNATURE = 595, + D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDHEAPTYPE = 596, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDDIMENSIONS = 597, + D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDMISCFLAGS = 598, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDMISCFLAGS = 599, + D3D12_MESSAGE_ID_CREATERESOURCE_LARGEALLOCATION = 600, + D3D12_MESSAGE_ID_CREATERESOURCE_SMALLALLOCATION = 601, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDARG_RETURN = 602, + D3D12_MESSAGE_ID_CREATERESOURCE_OUTOFMEMORY_RETURN = 603, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDDESC = 604, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDINITIALSTATE = 605, + D3D12_MESSAGE_ID_RESOURCE_HAS_PENDING_INITIAL_DATA = 606, + D3D12_MESSAGE_ID_POSSIBLY_INVALID_SUBRESOURCE_STATE = 607, + D3D12_MESSAGE_ID_INVALID_USE_OF_NON_RESIDENT_RESOURCE = 608, + D3D12_MESSAGE_ID_POSSIBLE_INVALID_USE_OF_NON_RESIDENT_RESOURCE = 609, + D3D12_MESSAGE_ID_BUNDLE_PIPELINE_STATE_MISMATCH = 610, + D3D12_MESSAGE_ID_PRIMITIVE_TOPOLOGY_MISMATCH_PIPELINE_STATE = 611, + D3D12_MESSAGE_ID_RENDER_TARGET_NUMBER_MISMATCH_PIPELINE_STATE = 612, + D3D12_MESSAGE_ID_RENDER_TARGET_FORMAT_MISMATCH_PIPELINE_STATE = 613, + D3D12_MESSAGE_ID_RENDER_TARGET_SAMPLE_DESC_MISMATCH_PIPELINE_STATE = 614, + D3D12_MESSAGE_ID_DEPTH_STENCIL_FORMAT_MISMATCH_PIPELINE_STATE = 615, + D3D12_MESSAGE_ID_DEPTH_STENCIL_SAMPLE_DESC_MISMATCH_PIPELINE_STATE = 616, + D3D12_MESSAGE_ID_RENDER_TARGET_NUMBER_MISMATCH_BUNDLE_PIPELINE_STATE = 617, + D3D12_MESSAGE_ID_RENDER_TARGET_FORMAT_MISMATCH_BUNDLE_PIPELINE_STATE = 618, + D3D12_MESSAGE_ID_RENDER_TARGET_SAMPLE_DESC_MISMATCH_BUNDLE_PIPELINE_STATE = 619, + D3D12_MESSAGE_ID_DEPTH_STENCIL_FORMAT_MISMATCH_BUNDLE_PIPELINE_STATE = 620, + D3D12_MESSAGE_ID_DEPTH_STENCIL_SAMPLE_DESC_MISMATCH_BUNDLE_PIPELINE_STATE = 621, + D3D12_MESSAGE_ID_CREATESHADER_INVALIDBYTECODE = 622, + D3D12_MESSAGE_ID_CREATEHEAP_NULLDESC = 623, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDSIZE = 624, + D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDHEAPTYPE = 625, + D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDCPUPAGEPROPERTIES = 626, + D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDMEMORYPOOL = 627, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDPROPERTIES = 628, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDALIGNMENT = 629, + D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDMISCFLAGS = 630, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDMISCFLAGS = 631, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDARG_RETURN = 632, + D3D12_MESSAGE_ID_CREATEHEAP_OUTOFMEMORY_RETURN = 633, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_NULLHEAPPROPERTIES = 634, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDHEAPTYPE = 635, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDCPUPAGEPROPERTIES = 636, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDMEMORYPOOL = 637, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALIDHEAPPROPERTIES = 638, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDHEAPMISCFLAGS = 639, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALIDHEAPMISCFLAGS = 640, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALIDARG_RETURN = 641, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_OUTOFMEMORY_RETURN = 642, + D3D12_MESSAGE_ID_GETCUSTOMHEAPPROPERTIES_UNRECOGNIZEDHEAPTYPE = 643, + D3D12_MESSAGE_ID_GETCUSTOMHEAPPROPERTIES_INVALIDHEAPTYPE = 644, + D3D12_MESSAGE_ID_CREATE_DESCRIPTOR_HEAP_INVALID_DESC = 645, + D3D12_MESSAGE_ID_INVALID_DESCRIPTOR_HANDLE = 646, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALID_CONSERVATIVERASTERMODE = 647, + D3D12_MESSAGE_ID_DEVICE_DRAW_INVALID_SYSTEMVALUE = 648, + D3D12_MESSAGE_ID_CREATE_CONSTANT_BUFFER_VIEW_INVALID_RESOURCE = 649, + D3D12_MESSAGE_ID_CREATE_CONSTANT_BUFFER_VIEW_INVALID_DESC = 650, + D3D12_MESSAGE_ID_CREATE_CONSTANT_BUFFER_VIEW_LARGE_OFFSET = 651, + D3D12_MESSAGE_ID_CREATE_UNORDEREDACCESS_VIEW_INVALID_COUNTER_USAGE = 652, + D3D12_MESSAGE_ID_COPY_DESCRIPTORS_INVALID_RANGES = 653, + D3D12_MESSAGE_ID_COPY_DESCRIPTORS_WRITE_ONLY_DESCRIPTOR = 654, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RTV_FORMAT_NOT_UNKNOWN = 655, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_RENDER_TARGET_COUNT = 656, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_VERTEX_SHADER_NOT_SET = 657, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INPUTLAYOUT_NOT_SET = 658, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_HS_DS_SIGNATURE_MISMATCH = 659, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_REGISTERINDEX = 660, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_COMPONENTTYPE = 661, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_REGISTERMASK = 662, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_SYSTEMVALUE = 663, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS = 664, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_MINPRECISION = 665, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND = 666, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_XOR_DS_MISMATCH = 667, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HULL_SHADER_INPUT_TOPOLOGY_MISMATCH = 668, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_DS_CONTROL_POINT_COUNT_MISMATCH = 669, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_DS_TESSELLATOR_DOMAIN_MISMATCH = 670, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_USE_OF_CENTER_MULTISAMPLE_PATTERN = 671, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_USE_OF_FORCED_SAMPLE_COUNT = 672, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_PRIMITIVETOPOLOGY = 673, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_SYSTEMVALUE = 674, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_OM_DUAL_SOURCE_BLENDING_CAN_ONLY_HAVE_RENDER_TARGET_0 + = 675, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_OM_RENDER_TARGET_DOES_NOT_SUPPORT_BLENDING = 676, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_PS_OUTPUT_TYPE_MISMATCH = 677, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_OM_RENDER_TARGET_DOES_NOT_SUPPORT_LOGIC_OPS = 678, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RENDERTARGETVIEW_NOT_SET = 679, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_DEPTHSTENCILVIEW_NOT_SET = 680, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_GS_INPUT_PRIMITIVE_MISMATCH = 681, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_POSITION_NOT_PRESENT = 682, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_MISSING_ROOT_SIGNATURE_FLAGS = 683, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_INDEX_BUFFER_PROPERTIES = 684, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_SAMPLE_DESC = 685, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_ROOT_SIGNATURE_MISMATCH = 686, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_DS_ROOT_SIGNATURE_MISMATCH = 687, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_VS_ROOT_SIGNATURE_MISMATCH = 688, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_GS_ROOT_SIGNATURE_MISMATCH = 689, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_PS_ROOT_SIGNATURE_MISMATCH = 690, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_MISSING_ROOT_SIGNATURE = 691, + D3D12_MESSAGE_ID_EXECUTE_BUNDLE_OPEN_BUNDLE = 692, + D3D12_MESSAGE_ID_EXECUTE_BUNDLE_DESCRIPTOR_HEAP_MISMATCH = 693, + D3D12_MESSAGE_ID_EXECUTE_BUNDLE_TYPE = 694, + D3D12_MESSAGE_ID_DRAW_EMPTY_SCISSOR_RECTANGLE = 695, + D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_BLOB_NOT_FOUND = 696, + D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_DESERIALIZE_FAILED = 697, + D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_INVALID_CONFIGURATION = 698, + D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_NOT_SUPPORTED_ON_DEVICE = 699, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_NULLRESOURCEPROPERTIES = 700, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_NULLHEAP = 701, + D3D12_MESSAGE_ID_GETRESOURCEALLOCATIONINFO_INVALIDRDESCS = 702, + D3D12_MESSAGE_ID_MAKERESIDENT_NULLOBJECTARRAY = 703, + D3D12_MESSAGE_ID_MAKERESIDENT_INVALIDOBJECT = 704, + D3D12_MESSAGE_ID_EVICT_NULLOBJECTARRAY = 705, + D3D12_MESSAGE_ID_EVICT_INVALIDOBJECT = 706, + D3D12_MESSAGE_ID_HEAPS_UNSUPPORTED = 707, + D3D12_MESSAGE_ID_SET_DESCRIPTOR_TABLE_INVALID = 708, + D3D12_MESSAGE_ID_SET_ROOT_CONSTANT_INVALID = 709, + D3D12_MESSAGE_ID_SET_ROOT_CONSTANT_BUFFER_VIEW_INVALID = 710, + D3D12_MESSAGE_ID_SET_ROOT_SHADER_RESOURCE_VIEW_INVALID = 711, + D3D12_MESSAGE_ID_SET_ROOT_UNORDERED_ACCESS_VIEW_INVALID = 712, + D3D12_MESSAGE_ID_SET_VERTEX_BUFFERS_INVALID_DESC = 713, + D3D12_MESSAGE_ID_SET_VERTEX_BUFFERS_LARGE_OFFSET = 714, + D3D12_MESSAGE_ID_SET_INDEX_BUFFER_INVALID_DESC = 715, + D3D12_MESSAGE_ID_SET_INDEX_BUFFER_LARGE_OFFSET = 716, + D3D12_MESSAGE_ID_SET_STREAM_OUTPUT_BUFFERS_INVALID_DESC = 717, + D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDDIMENSIONALITY = 718, + D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDLAYOUT = 719, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDDIMENSIONALITY = 720, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDALIGNMENT = 721, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDMIPLEVELS = 722, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDSAMPLEDESC = 723, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDLAYOUT = 724, + D3D12_MESSAGE_ID_SET_INDEX_BUFFER_INVALID = 725, + D3D12_MESSAGE_ID_SET_VERTEX_BUFFERS_INVALID = 726, + D3D12_MESSAGE_ID_SET_STREAM_OUTPUT_BUFFERS_INVALID = 727, + D3D12_MESSAGE_ID_SET_RENDER_TARGETS_INVALID = 728, + D3D12_MESSAGE_ID_CREATEQUERY_HEAP_INVALID_PARAMETERS = 729, + D3D12_MESSAGE_ID_CREATEQUERY_HEAP_JPEG_NOT_SUPPORTED = 730, + D3D12_MESSAGE_ID_BEGIN_END_QUERY_INVALID_PARAMETERS = 731, + D3D12_MESSAGE_ID_CLOSE_COMMAND_LIST_OPEN_QUERY = 732, + D3D12_MESSAGE_ID_RESOLVE_QUERY_DATA_INVALID_PARAMETERS = 733, + D3D12_MESSAGE_ID_SET_PREDICATION_INVALID_PARAMETERS = 734, + D3D12_MESSAGE_ID_TIMESTAMPS_NOT_SUPPORTED = 735, + D3D12_MESSAGE_ID_UNSTABLE_POWER_STATE = 736, + D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDFORMAT = 737, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDFORMAT = 738, + D3D12_MESSAGE_ID_GETCOPYABLELAYOUT_INVALIDSUBRESOURCERANGE = 739, + D3D12_MESSAGE_ID_GETCOPYABLELAYOUT_INVALIDBASEOFFSET = 740, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_HEAP = 741, + D3D12_MESSAGE_ID_CREATE_SAMPLER_INVALID = 742, + D3D12_MESSAGE_ID_CREATECOMMANDSIGNATURE_INVALID = 743, + D3D12_MESSAGE_ID_EXECUTE_INDIRECT_INVALID_PARAMETERS = 744, + D3D12_MESSAGE_ID_GETGPUVIRTUALADDRESS_INVALID_RESOURCE_DIMENSION = 745, + D3D12_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDCONTEXTTYPE = 746, + D3D12_MESSAGE_ID_CREATEQUERYORPREDICATE_DECODENOTSUPPORTED = 747, + D3D12_MESSAGE_ID_CREATEQUERYORPREDICATE_ENCODENOTSUPPORTED = 748, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDPLANEINDEX = 749, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDVIDEOPLANEINDEX = 750, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_AMBIGUOUSVIDEOPLANEINDEX = 751, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDPLANEINDEX = 752, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDVIDEOPLANEINDEX = 753, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_AMBIGUOUSVIDEOPLANEINDEX = 754, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDPLANEINDEX = 755, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDVIDEOPLANEINDEX = 756, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_AMBIGUOUSVIDEOPLANEINDEX = 757, + D3D12_MESSAGE_ID_JPEGDECODE_INVALIDSCANDATAOFFSET = 758, + D3D12_MESSAGE_ID_JPEGDECODE_NOTSUPPORTED = 759, + D3D12_MESSAGE_ID_JPEGDECODE_DIMENSIONSTOOLARGE = 760, + D3D12_MESSAGE_ID_JPEGDECODE_INVALIDCOMPONENTS = 761, + D3D12_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDCOMPONENTS = 762, + D3D12_MESSAGE_ID_JPEGDECODE_DESTINATIONNOT2D = 763, + D3D12_MESSAGE_ID_JPEGDECODE_TILEDRESOURCESUNSUPPORTED = 764, + D3D12_MESSAGE_ID_JPEGDECODE_GUARDRECTSUNSUPPORTED = 765, + D3D12_MESSAGE_ID_JPEGDECODE_FORMATUNSUPPORTED = 766, + D3D12_MESSAGE_ID_JPEGDECODE_INVALIDSUBRESOURCE = 767, + D3D12_MESSAGE_ID_JPEGDECODE_INVALIDMIPLEVEL = 768, + D3D12_MESSAGE_ID_JPEGDECODE_EMPTYDESTBOX = 769, + D3D12_MESSAGE_ID_JPEGDECODE_DESTBOXNOT2D = 770, + D3D12_MESSAGE_ID_JPEGDECODE_DESTBOXNOTSUB = 771, + D3D12_MESSAGE_ID_JPEGDECODE_DESTBOXESINTERSECT = 772, + D3D12_MESSAGE_ID_JPEGDECODE_XSUBSAMPLEMISMATCH = 773, + D3D12_MESSAGE_ID_JPEGDECODE_YSUBSAMPLEMISMATCH = 774, + D3D12_MESSAGE_ID_JPEGDECODE_XSUBSAMPLEODD = 775, + D3D12_MESSAGE_ID_JPEGDECODE_YSUBSAMPLEODD = 776, + D3D12_MESSAGE_ID_JPEGDECODE_UPSCALEUNSUPPORTED = 777, + D3D12_MESSAGE_ID_JPEGDECODE_TIER4DOWNSCALETOLARGE = 778, + D3D12_MESSAGE_ID_JPEGDECODE_TIER3DOWNSCALEUNSUPPORTED = 779, + D3D12_MESSAGE_ID_JPEGDECODE_CHROMASIZEMISMATCH = 780, + D3D12_MESSAGE_ID_JPEGDECODE_LUMACHROMASIZEMISMATCH = 781, + D3D12_MESSAGE_ID_JPEGDECODE_INVALIDNUMDESTINATIONS = 782, + D3D12_MESSAGE_ID_JPEGDECODE_SUBBOXUNSUPPORTED = 783, + D3D12_MESSAGE_ID_JPEGDECODE_1DESTUNSUPPORTEDFORMAT = 784, + D3D12_MESSAGE_ID_JPEGDECODE_3DESTUNSUPPORTEDFORMAT = 785, + D3D12_MESSAGE_ID_JPEGDECODE_SCALEUNSUPPORTED = 786, + D3D12_MESSAGE_ID_JPEGDECODE_INVALIDSOURCESIZE = 787, + D3D12_MESSAGE_ID_JPEGDECODE_INVALIDCOPYFLAGS = 788, + D3D12_MESSAGE_ID_JPEGDECODE_HAZARD = 789, + D3D12_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDSRCBUFFERUSAGE = 790, + D3D12_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDSRCBUFFERMISCFLAGS = 791, + D3D12_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDDSTTEXTUREUSAGE = 792, + D3D12_MESSAGE_ID_JPEGDECODE_BACKBUFFERNOTSUPPORTED = 793, + D3D12_MESSAGE_ID_JPEGDECODE_UNSUPPRTEDCOPYFLAGS = 794, + D3D12_MESSAGE_ID_JPEGENCODE_NOTSUPPORTED = 795, + D3D12_MESSAGE_ID_JPEGENCODE_INVALIDSCANDATAOFFSET = 796, + D3D12_MESSAGE_ID_JPEGENCODE_INVALIDCOMPONENTS = 797, + D3D12_MESSAGE_ID_JPEGENCODE_SOURCENOT2D = 798, + D3D12_MESSAGE_ID_JPEGENCODE_TILEDRESOURCESUNSUPPORTED = 799, + D3D12_MESSAGE_ID_JPEGENCODE_GUARDRECTSUNSUPPORTED = 800, + D3D12_MESSAGE_ID_JPEGENCODE_XSUBSAMPLEMISMATCH = 801, + D3D12_MESSAGE_ID_JPEGENCODE_YSUBSAMPLEMISMATCH = 802, + D3D12_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDCOMPONENTS = 803, + D3D12_MESSAGE_ID_JPEGENCODE_FORMATUNSUPPORTED = 804, + D3D12_MESSAGE_ID_JPEGENCODE_INVALIDSUBRESOURCE = 805, + D3D12_MESSAGE_ID_JPEGENCODE_INVALIDMIPLEVEL = 806, + D3D12_MESSAGE_ID_JPEGENCODE_DIMENSIONSTOOLARGE = 807, + D3D12_MESSAGE_ID_JPEGENCODE_HAZARD = 808, + D3D12_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDDSTBUFFERUSAGE = 809, + D3D12_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDDSTBUFFERMISCFLAGS = 810, + D3D12_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDSRCTEXTUREUSAGE = 811, + D3D12_MESSAGE_ID_JPEGENCODE_BACKBUFFERNOTSUPPORTED = 812, + D3D12_MESSAGE_ID_CREATEQUERYORPREDICATE_UNSUPPORTEDCONTEXTTTYPEFORQUERY = 813, + D3D12_MESSAGE_ID_FLUSH1_INVALIDCONTEXTTYPE = 814, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDCLEARVALUE = 815, + D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDCLEARVALUEFORMAT = 816, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDCLEARVALUEFORMAT = 817, + D3D12_MESSAGE_ID_CREATERESOURCE_CLEARVALUEDENORMFLUSH = 818, + D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_INVALIDDEPTH = 819, + D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_MISMATCHINGCLEARVALUE = 820, + D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_MISMATCHINGCLEARVALUE = 821, + D3D12_MESSAGE_ID_MAP_INVALIDHEAP = 822, + D3D12_MESSAGE_ID_UNMAP_INVALIDHEAP = 823, + D3D12_MESSAGE_ID_MAP_INVALIDRESOURCE = 824, + D3D12_MESSAGE_ID_UNMAP_INVALIDRESOURCE = 825, + D3D12_MESSAGE_ID_MAP_INVALIDSUBRESOURCE = 826, + D3D12_MESSAGE_ID_UNMAP_INVALIDSUBRESOURCE = 827, + D3D12_MESSAGE_ID_MAP_INVALIDRANGE = 828, + D3D12_MESSAGE_ID_UNMAP_INVALIDRANGE = 829, + D3D12_MESSAGE_ID_MAP_NULLRANGE = 830, + D3D12_MESSAGE_ID_UNMAP_NULLRANGE = 831, + D3D12_MESSAGE_ID_MAP_INVALIDDATAPOINTER = 832, + D3D12_MESSAGE_ID_MAP_INVALIDARG_RETURN = 833, + D3D12_MESSAGE_ID_MAP_OUTOFMEMORY_RETURN = 834, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_BUNDLENOTSUPPORTED = 835, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_COMMANDLISTMISMATCH = 836, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_OPENCOMMANDLIST = 837, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_FAILEDCOMMANDLIST = 838, + D3D12_MESSAGE_ID_COPYBUFFERREGION_NULLDST = 839, + D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALIDDSTRESOURCEDIMENSION = 840, + D3D12_MESSAGE_ID_COPYBUFFERREGION_DSTRANGEOUTOFBOUNDS = 841, + D3D12_MESSAGE_ID_COPYBUFFERREGION_NULLSRC = 842, + D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALIDSRCRESOURCEDIMENSION = 843, + D3D12_MESSAGE_ID_COPYBUFFERREGION_SRCRANGEOUTOFBOUNDS = 844, + D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALIDCOPYFLAGS = 845, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_NULLDST = 846, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDDSTTYPE = 847, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTRESOURCEDIMENSION = 848, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTRESOURCE = 849, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTSUBRESOURCE = 850, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTOFFSET = 851, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDDSTFORMAT = 852, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTFORMAT = 853, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTDIMENSIONS = 854, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTROWPITCH = 855, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTPLACEMENT = 856, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTDSPLACEDFOOTPRINTFORMAT = 857, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_DSTREGIONOUTOFBOUNDS = 858, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_NULLSRC = 859, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDSRCTYPE = 860, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCRESOURCEDIMENSION = 861, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCRESOURCE = 862, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCSUBRESOURCE = 863, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCOFFSET = 864, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDSRCFORMAT = 865, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCFORMAT = 866, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCDIMENSIONS = 867, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCROWPITCH = 868, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCPLACEMENT = 869, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCDSPLACEDFOOTPRINTFORMAT = 870, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_SRCREGIONOUTOFBOUNDS = 871, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTCOORDINATES = 872, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCBOX = 873, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_FORMATMISMATCH = 874, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_EMPTYBOX = 875, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDCOPYFLAGS = 876, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALID_SUBRESOURCE_INDEX = 877, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALID_FORMAT = 878, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_RESOURCE_MISMATCH = 879, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALID_SAMPLE_COUNT = 880, + D3D12_MESSAGE_ID_CREATECOMPUTEPIPELINESTATE_INVALID_SHADER = 881, + D3D12_MESSAGE_ID_CREATECOMPUTEPIPELINESTATE_CS_ROOT_SIGNATURE_MISMATCH = 882, + D3D12_MESSAGE_ID_CREATECOMPUTEPIPELINESTATE_MISSING_ROOT_SIGNATURE = 883, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_INVALIDCACHEDBLOB = 884, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBADAPTERMISMATCH = 885, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBDRIVERVERSIONMISMATCH = 886, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBDESCMISMATCH = 887, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBIGNORED = 888, + D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDHEAP = 889, + D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDRESOURCE = 890, + D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDBOX = 891, + D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDSUBRESOURCE = 892, + D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_EMPTYBOX = 893, + D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDHEAP = 894, + D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDRESOURCE = 895, + D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDBOX = 896, + D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDSUBRESOURCE = 897, + D3D12_MESSAGE_ID_READFROMSUBRESOURCE_EMPTYBOX = 898, + D3D12_MESSAGE_ID_TOO_MANY_NODES_SPECIFIED = 899, + D3D12_MESSAGE_ID_INVALID_NODE_INDEX = 900, + D3D12_MESSAGE_ID_GETHEAPPROPERTIES_INVALIDRESOURCE = 901, + D3D12_MESSAGE_ID_NODE_MASK_MISMATCH = 902, + D3D12_MESSAGE_ID_COMMAND_LIST_OUTOFMEMORY = 903, + D3D12_MESSAGE_ID_COMMAND_LIST_MULTIPLE_SWAPCHAIN_BUFFER_REFERENCES = 904, + D3D12_MESSAGE_ID_COMMAND_LIST_TOO_MANY_SWAPCHAIN_REFERENCES = 905, + D3D12_MESSAGE_ID_COMMAND_QUEUE_TOO_MANY_SWAPCHAIN_REFERENCES = 906, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_WRONGSWAPCHAINBUFFERREFERENCE = 907, + D3D12_MESSAGE_ID_COMMAND_LIST_SETRENDERTARGETS_INVALIDNUMRENDERTARGETS = 908, + D3D12_MESSAGE_ID_CREATE_QUEUE_INVALID_TYPE = 909, + D3D12_MESSAGE_ID_CREATE_QUEUE_INVALID_FLAGS = 910, + D3D12_MESSAGE_ID_CREATESHAREDRESOURCE_INVALIDFLAGS = 911, + D3D12_MESSAGE_ID_CREATESHAREDRESOURCE_INVALIDFORMAT = 912, + D3D12_MESSAGE_ID_CREATESHAREDHEAP_INVALIDFLAGS = 913, + D3D12_MESSAGE_ID_REFLECTSHAREDPROPERTIES_UNRECOGNIZEDPROPERTIES = 914, + D3D12_MESSAGE_ID_REFLECTSHAREDPROPERTIES_INVALIDSIZE = 915, + D3D12_MESSAGE_ID_REFLECTSHAREDPROPERTIES_INVALIDOBJECT = 916, + D3D12_MESSAGE_ID_KEYEDMUTEX_INVALIDOBJECT = 917, + D3D12_MESSAGE_ID_KEYEDMUTEX_INVALIDKEY = 918, + D3D12_MESSAGE_ID_KEYEDMUTEX_WRONGSTATE = 919, + D3D12_MESSAGE_ID_CREATE_QUEUE_INVALID_PRIORITY = 920, + D3D12_MESSAGE_ID_OBJECT_DELETED_WHILE_STILL_IN_USE = 921, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_INVALID_FLAGS = 922, + D3D12_MESSAGE_ID_HEAP_ADDRESS_RANGE_HAS_NO_RESOURCE = 923, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RENDER_TARGET_DELETED = 924, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_ALL_RENDER_TARGETS_HAVE_UNKNOWN_FORMAT = 925, + D3D12_MESSAGE_ID_HEAP_ADDRESS_RANGE_INTERSECTS_MULTIPLE_BUFFERS = 926, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_GPU_WRITTEN_READBACK_RESOURCE_MAPPED = 927, + D3D12_MESSAGE_ID_UNMAP_RANGE_NOT_NEEDED = 928, + D3D12_MESSAGE_ID_UNMAP_RANGE_NOT_EMPTY = 929, + D3D12_MESSAGE_ID_MAP_INVALID_NULLRANGE = 930, + D3D12_MESSAGE_ID_UNMAP_INVALID_NULLRANGE = 931, + D3D12_MESSAGE_ID_NO_GRAPHICS_API_SUPPORT = 932, + D3D12_MESSAGE_ID_NO_COMPUTE_API_SUPPORT = 933, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_RESOURCE_FLAGS_NOT_SUPPORTED = 934, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_ROOT_ARGUMENT_UNINITIALIZED = 935, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_DESCRIPTOR_HEAP_INDEX_OUT_OF_BOUNDS = 936, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_DESCRIPTOR_TABLE_REGISTER_INDEX_OUT_OF_BOUNDS = 937, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_DESCRIPTOR_UNINITIALIZED = 938, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_DESCRIPTOR_TYPE_MISMATCH = 939, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_SRV_RESOURCE_DIMENSION_MISMATCH = 940, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_UAV_RESOURCE_DIMENSION_MISMATCH = 941, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_INCOMPATIBLE_RESOURCE_STATE = 942, + D3D12_MESSAGE_ID_COPYRESOURCE_NULLDST = 943, + D3D12_MESSAGE_ID_COPYRESOURCE_INVALIDDSTRESOURCE = 944, + D3D12_MESSAGE_ID_COPYRESOURCE_NULLSRC = 945, + D3D12_MESSAGE_ID_COPYRESOURCE_INVALIDSRCRESOURCE = 946, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_NULLDST = 947, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALIDDSTRESOURCE = 948, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_NULLSRC = 949, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALIDSRCRESOURCE = 950, + D3D12_MESSAGE_ID_PIPELINE_STATE_TYPE_MISMATCH = 951, + D3D12_MESSAGE_ID_COMMAND_LIST_DISPATCH_ROOT_SIGNATURE_NOT_SET = 952, + D3D12_MESSAGE_ID_COMMAND_LIST_DISPATCH_ROOT_SIGNATURE_MISMATCH = 953, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_ZERO_BARRIERS = 954, + D3D12_MESSAGE_ID_BEGIN_END_EVENT_MISMATCH = 955, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_POSSIBLE_BEFORE_AFTER_MISMATCH = 956, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISMATCHING_BEGIN_END = 957, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_INVALID_RESOURCE = 958, + D3D12_MESSAGE_ID_USE_OF_ZERO_REFCOUNT_OBJECT = 959, + D3D12_MESSAGE_ID_OBJECT_EVICTED_WHILE_STILL_IN_USE = 960, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_ROOT_DESCRIPTOR_ACCESS_OUT_OF_BOUNDS = 961, + D3D12_MESSAGE_ID_CREATEPIPELINELIBRARY_INVALIDLIBRARYBLOB = 962, + D3D12_MESSAGE_ID_CREATEPIPELINELIBRARY_DRIVERVERSIONMISMATCH = 963, + D3D12_MESSAGE_ID_CREATEPIPELINELIBRARY_ADAPTERVERSIONMISMATCH = 964, + D3D12_MESSAGE_ID_CREATEPIPELINELIBRARY_UNSUPPORTED = 965, + D3D12_MESSAGE_ID_CREATE_PIPELINELIBRARY = 966, + D3D12_MESSAGE_ID_LIVE_PIPELINELIBRARY = 967, + D3D12_MESSAGE_ID_DESTROY_PIPELINELIBRARY = 968, + D3D12_MESSAGE_ID_STOREPIPELINE_NONAME = 969, + D3D12_MESSAGE_ID_STOREPIPELINE_DUPLICATENAME = 970, + D3D12_MESSAGE_ID_LOADPIPELINE_NAMENOTFOUND = 971, + D3D12_MESSAGE_ID_LOADPIPELINE_INVALIDDESC = 972, + D3D12_MESSAGE_ID_PIPELINELIBRARY_SERIALIZE_NOTENOUGHMEMORY = 973, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_PS_OUTPUT_RT_OUTPUT_MISMATCH = 974, + D3D12_MESSAGE_ID_SETEVENTONMULTIPLEFENCECOMPLETION_INVALIDFLAGS = 975, + D3D12_MESSAGE_ID_CREATE_QUEUE_VIDEO_NOT_SUPPORTED = 976, + D3D12_MESSAGE_ID_CREATE_COMMAND_ALLOCATOR_VIDEO_NOT_SUPPORTED = 977, + D3D12_MESSAGE_ID_CREATEQUERY_HEAP_VIDEO_DECODE_STATISTICS_NOT_SUPPORTED = 978, + D3D12_MESSAGE_ID_CREATE_VIDEODECODECOMMANDLIST = 979, + D3D12_MESSAGE_ID_CREATE_VIDEODECODER = 980, + D3D12_MESSAGE_ID_CREATE_VIDEODECODESTREAM = 981, + D3D12_MESSAGE_ID_LIVE_VIDEODECODECOMMANDLIST = 982, + D3D12_MESSAGE_ID_LIVE_VIDEODECODER = 983, + D3D12_MESSAGE_ID_LIVE_VIDEODECODESTREAM = 984, + D3D12_MESSAGE_ID_DESTROY_VIDEODECODECOMMANDLIST = 985, + D3D12_MESSAGE_ID_DESTROY_VIDEODECODER = 986, + D3D12_MESSAGE_ID_DESTROY_VIDEODECODESTREAM = 987, + D3D12_MESSAGE_ID_DECODE_FRAME_INVALID_PARAMETERS = 988, + D3D12_MESSAGE_ID_DEPRECATED_API = 989, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISMATCHING_COMMAND_LIST_TYPE = 990, + D3D12_MESSAGE_ID_COMMAND_LIST_DESCRIPTOR_TABLE_NOT_SET = 991, + D3D12_MESSAGE_ID_COMMAND_LIST_ROOT_CONSTANT_BUFFER_VIEW_NOT_SET = 992, + D3D12_MESSAGE_ID_COMMAND_LIST_ROOT_SHADER_RESOURCE_VIEW_NOT_SET = 993, + D3D12_MESSAGE_ID_COMMAND_LIST_ROOT_UNORDERED_ACCESS_VIEW_NOT_SET = 994, + D3D12_MESSAGE_ID_DISCARD_INVALID_SUBRESOURCE_RANGE = 995, + D3D12_MESSAGE_ID_DISCARD_ONE_SUBRESOURCE_FOR_MIPS_WITH_RECTS = 996, + D3D12_MESSAGE_ID_DISCARD_NO_RECTS_FOR_NON_TEXTURE2D = 997, + D3D12_MESSAGE_ID_COPY_ON_SAME_SUBRESOURCE = 998, + D3D12_MESSAGE_ID_SETRESIDENCYPRIORITY_INVALID_PAGEABLE = 999, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_UNSUPPORTED = 1000, + D3D12_MESSAGE_ID_STATIC_DESCRIPTOR_INVALID_DESCRIPTOR_CHANGE = 1001, + D3D12_MESSAGE_ID_DATA_STATIC_DESCRIPTOR_INVALID_DATA_CHANGE = 1002, + D3D12_MESSAGE_ID_DATA_STATIC_WHILE_SET_AT_EXECUTE_DESCRIPTOR_INVALID_DATA_CHANGE = 1003, + D3D12_MESSAGE_ID_EXECUTE_BUNDLE_STATIC_DESCRIPTOR_DATA_STATIC_NOT_SET = 1004, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_RESOURCE_ACCESS_OUT_OF_BOUNDS = 1005, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_SAMPLER_MODE_MISMATCH = 1006, + D3D12_MESSAGE_ID_CREATE_FENCE_INVALID_FLAGS = 1007, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_DUPLICATE_SUBRESOURCE_TRANSITIONS = 1008, + D3D12_MESSAGE_ID_SETRESIDENCYPRIORITY_INVALID_PRIORITY = 1009, + D3D12_MESSAGE_ID_CREATE_PASS = 1010, + D3D12_MESSAGE_ID_DESTROY_PASS = 1011, + D3D12_MESSAGE_ID_LIVE_PASS = 1012, + D3D12_MESSAGE_ID_CREATE_DESCRIPTOR_HEAP_LARGE_NUM_DESCRIPTORS = 1013, + D3D12_MESSAGE_ID_BEGIN_EVENT = 1014, + D3D12_MESSAGE_ID_END_EVENT = 1015, + D3D12_MESSAGE_ID_CREATEDEVICE_DEBUG_LAYER_STARTUP_OPTIONS = 1016, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_DEPTHBOUNDSTEST_UNSUPPORTED = 1017, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_DUPLICATE_SUBOBJECT = 1018, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_UNKNOWN_SUBOBJECT = 1019, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_ZERO_SIZE_STREAM = 1020, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_INVALID_STREAM = 1021, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CANNOT_DEDUCE_TYPE = 1022, + D3D12_MESSAGE_ID_COMMAND_LIST_STATIC_DESCRIPTOR_RESOURCE_DIMENSION_MISMATCH = 1023, + D3D12_MESSAGE_ID_CREATE_COMMAND_QUEUE_INSUFFICIENT_PRIVILEGE_FOR_GLOBAL_REALTIME = 1024, + D3D12_MESSAGE_ID_CREATE_COMMAND_QUEUE_INSUFFICIENT_HARDWARE_SUPPORT_FOR_GLOBAL_REALTIME = 1025, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_ARCHITECTURE = 1026, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_NULL_DST = 1027, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_DST_RESOURCE_DIMENSION = 1028, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_DST_RANGE_OUT_OF_BOUNDS = 1029, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_NULL_SRC = 1030, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_SRC_RESOURCE_DIMENSION = 1031, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_SRC_RANGE_OUT_OF_BOUNDS = 1032, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_OFFSET_ALIGNMENT = 1033, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_NULL_DEPENDENT_RESOURCES = 1034, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_NULL_DEPENDENT_SUBRESOURCE_RANGES = 1035, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_DEPENDENT_RESOURCE = 1036, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_DEPENDENT_SUBRESOURCE_RANGE = 1037, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_DEPENDENT_SUBRESOURCE_OUT_OF_BOUNDS = 1038, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_DEPENDENT_RANGE_OUT_OF_BOUNDS = 1039, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_ZERO_DEPENDENCIES = 1040, + D3D12_MESSAGE_ID_DEVICE_CREATE_SHARED_HANDLE_INVALIDARG = 1041, + D3D12_MESSAGE_ID_DESCRIPTOR_HANDLE_WITH_INVALID_RESOURCE = 1042, + D3D12_MESSAGE_ID_SETDEPTHBOUNDS_INVALIDARGS = 1043, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_RESOURCE_STATE_IMPRECISE = 1044, + D3D12_MESSAGE_ID_COMMAND_LIST_PIPELINE_STATE_NOT_SET = 1045, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_MODEL_MISMATCH = 1046, + D3D12_MESSAGE_ID_OBJECT_ACCESSED_WHILE_STILL_IN_USE = 1047, + D3D12_MESSAGE_ID_PROGRAMMABLE_MSAA_UNSUPPORTED = 1048, + D3D12_MESSAGE_ID_SETSAMPLEPOSITIONS_INVALIDARGS = 1049, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCEREGION_INVALID_RECT = 1050, + D3D12_MESSAGE_ID_CREATE_VIDEODECODECOMMANDQUEUE = 1051, + D3D12_MESSAGE_ID_CREATE_VIDEOPROCESSCOMMANDLIST = 1052, + D3D12_MESSAGE_ID_CREATE_VIDEOPROCESSCOMMANDQUEUE = 1053, + D3D12_MESSAGE_ID_LIVE_VIDEODECODECOMMANDQUEUE = 1054, + D3D12_MESSAGE_ID_LIVE_VIDEOPROCESSCOMMANDLIST = 1055, + D3D12_MESSAGE_ID_LIVE_VIDEOPROCESSCOMMANDQUEUE = 1056, + D3D12_MESSAGE_ID_DESTROY_VIDEODECODECOMMANDQUEUE = 1057, + D3D12_MESSAGE_ID_DESTROY_VIDEOPROCESSCOMMANDLIST = 1058, + D3D12_MESSAGE_ID_DESTROY_VIDEOPROCESSCOMMANDQUEUE = 1059, + D3D12_MESSAGE_ID_CREATE_VIDEOPROCESSOR = 1060, + D3D12_MESSAGE_ID_CREATE_VIDEOPROCESSSTREAM = 1061, + D3D12_MESSAGE_ID_LIVE_VIDEOPROCESSOR = 1062, + D3D12_MESSAGE_ID_LIVE_VIDEOPROCESSSTREAM = 1063, + D3D12_MESSAGE_ID_DESTROY_VIDEOPROCESSOR = 1064, + D3D12_MESSAGE_ID_DESTROY_VIDEOPROCESSSTREAM = 1065, + D3D12_MESSAGE_ID_PROCESS_FRAME_INVALID_PARAMETERS = 1066, + D3D12_MESSAGE_ID_COPY_INVALIDLAYOUT = 1067, + D3D12_MESSAGE_ID_D3D12_MESSAGES_END = 1068, +}} +STRUCT!{struct D3D12_MESSAGE { + Category: D3D12_MESSAGE_CATEGORY, + Severity: D3D12_MESSAGE_SEVERITY, + ID: D3D12_MESSAGE_ID, + pDescription: *const c_char, + DescriptionByteLength: SIZE_T, +}} +STRUCT!{struct D3D12_INFO_QUEUE_FILTER_DESC { + NumCategories: UINT, + pCategoryList: *mut D3D12_MESSAGE_CATEGORY, + NumSeverities: UINT, + pSeverityList: *mut D3D12_MESSAGE_SEVERITY, + NumIDs: UINT, + pIDList: *mut D3D12_MESSAGE_ID, +}} +STRUCT!{struct D3D12_INFO_QUEUE_FILTER { + AllowList: D3D12_INFO_QUEUE_FILTER_DESC, + DenyList: D3D12_INFO_QUEUE_FILTER_DESC, +}} +pub const D3D12_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT: UINT = 1024; +RIDL!{#[uuid(0x0742a90b, 0xc387, 0x483f, 0xb9, 0x46, 0x30, 0xa7, 0xe4, 0xe6, 0x14, 0x58)] +interface ID3D12InfoQueue(ID3D12InfoQueueVtbl): IUnknown(IUnknownVtbl) { + fn SetMessageCountLimit( + MessageCountLimit: UINT64, + ) -> HRESULT, + fn ClearStoredMessages() -> (), + fn GetMessage( + MessageIndex: UINT64, + pMessage: *mut D3D12_MESSAGE, + pMessageByteLength: *mut SIZE_T, + ) -> HRESULT, + fn GetNumMessagesAllowedByStorageFilter() -> UINT64, + fn GetNumMessagesDeniedByStorageFilter() -> UINT64, + fn GetNumStoredMessages() -> UINT64, + fn GetNumStoredMessagesAllowedByRetrievalFilter() -> UINT64, + fn GetNumMessagesDiscardedByMessageCountLimit() -> UINT64, + fn GetMessageCountLimit() -> UINT64, + fn AddStorageFilterEntries( + pFilter: *mut D3D12_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn GetStorageFilter( + pFilter: *mut D3D12_INFO_QUEUE_FILTER, + pFilterByteLength: *mut SIZE_T, + ) -> HRESULT, + fn ClearStorageFilter() -> (), + fn PushEmptyStorageFilter() -> HRESULT, + fn PushCopyOfStorageFilter() -> HRESULT, + fn PushStorageFilter( + pFilter: *mut D3D12_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn PopStorageFilter() -> (), + fn GetStorageFilterStackSize() -> UINT, + fn AddRetrievalFilterEntries( + pFilter: *mut D3D12_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn GetRetrievalFilter( + pFilter: *mut D3D12_INFO_QUEUE_FILTER, + pFilterByteLength: *mut SIZE_T, + ) -> HRESULT, + fn ClearRetrievalFilter() -> (), + fn PushEmptyRetrievalFilter() -> HRESULT, + fn PushCopyOfRetrievalFilter() -> HRESULT, + fn PushRetrievalFilter( + pFilter: *mut D3D12_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn PopRetrievalFilter() -> (), + fn GetRetrievalFilterStackSize() -> UINT, + fn AddMessage( + Category: D3D12_MESSAGE_CATEGORY, + Severity: D3D12_MESSAGE_SEVERITY, + ID: D3D12_MESSAGE_ID, + pDescription: LPCSTR, + ) -> HRESULT, + fn AddApplicationMessage( + Severity: D3D12_MESSAGE_SEVERITY, + pDescription: LPCSTR, + ) -> HRESULT, + fn SetBreakOnCategory( + Category: D3D12_MESSAGE_CATEGORY, + bEnable: BOOL, + ) -> HRESULT, + fn SetBreakOnSeverity( + Severity: D3D12_MESSAGE_SEVERITY, + bEnable: BOOL, + ) -> HRESULT, + fn SetBreakOnID( + ID: D3D12_MESSAGE_ID, + bEnable: BOOL, + ) -> HRESULT, + fn GetBreakOnCategory( + Category: D3D12_MESSAGE_CATEGORY, + ) -> BOOL, + fn GetBreakOnSeverity( + Severity: D3D12_MESSAGE_SEVERITY, + ) -> BOOL, + fn GetBreakOnID( + ID: D3D12_MESSAGE_ID, + ) -> BOOL, + fn SetMuteDebugOutput( + bMute: BOOL, + ) -> (), + fn GetMuteDebugOutput() -> BOOL, +}} +DEFINE_GUID!{IID_ID3D12Debug, + 0x344488b7, 0x6846, 0x474b, 0xb9, 0x89, 0xf0, 0x27, 0x44, 0x82, 0x45, 0xe0} +DEFINE_GUID!{IID_ID3D12Debug1, + 0xaffaa4ca, 0x63fe, 0x4d8e, 0xb8, 0xad, 0x15, 0x90, 0x00, 0xaf, 0x43, 0x04} +DEFINE_GUID!{IID_ID3D12Debug2, + 0x93a665c4, 0xa3b2, 0x4e5d, 0xb6, 0x92, 0xa2, 0x6a, 0xe1, 0x4e, 0x33, 0x74} +DEFINE_GUID!{IID_ID3D12DebugDevice1, + 0xa9b71770, 0xd099, 0x4a65, 0xa6, 0x98, 0x3d, 0xee, 0x10, 0x02, 0x0f, 0x88} +DEFINE_GUID!{IID_ID3D12DebugDevice, + 0x3febd6dd, 0x4973, 0x4787, 0x81, 0x94, 0xe4, 0x5f, 0x9e, 0x28, 0x92, 0x3e} +DEFINE_GUID!{IID_ID3D12DebugCommandQueue, + 0x09e0bf36, 0x54ac, 0x484f, 0x88, 0x47, 0x4b, 0xae, 0xea, 0xb6, 0x05, 0x3a} +DEFINE_GUID!{IID_ID3D12DebugCommandList1, + 0x102ca951, 0x311b, 0x4b01, 0xb1, 0x1f, 0xec, 0xb8, 0x3e, 0x06, 0x1b, 0x37} +DEFINE_GUID!{IID_ID3D12DebugCommandList, + 0x09e0bf36, 0x54ac, 0x484f, 0x88, 0x47, 0x4b, 0xae, 0xea, 0xb6, 0x05, 0x3f} +DEFINE_GUID!{IID_ID3D12InfoQueue, + 0x0742a90b, 0xc387, 0x483f, 0xb9, 0x46, 0x30, 0xa7, 0xe4, 0xe6, 0x14, 0x58} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d12shader.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d12shader.rs new file mode 100644 index 0000000..f07bf83 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3d12shader.rs @@ -0,0 +1,347 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::UINT64; +use shared::minwindef::{BOOL, BYTE, INT, LPVOID, UINT}; +use um::d3dcommon::{ + D3D_CBUFFER_TYPE, D3D_FEATURE_LEVEL, D3D_INTERPOLATION_MODE, D3D_MIN_PRECISION, D3D_NAME, + D3D_PARAMETER_FLAGS, D3D_PRIMITIVE, D3D_PRIMITIVE_TOPOLOGY, D3D_REGISTER_COMPONENT_TYPE, + D3D_RESOURCE_RETURN_TYPE, D3D_SHADER_INPUT_TYPE, D3D_SHADER_VARIABLE_CLASS, + D3D_SHADER_VARIABLE_TYPE, D3D_SRV_DIMENSION, D3D_TESSELLATOR_DOMAIN, + D3D_TESSELLATOR_OUTPUT_PRIMITIVE, D3D_TESSELLATOR_PARTITIONING, +}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCSTR}; +ENUM!{enum D3D12_SHADER_VERSION_TYPE { + D3D12_SHVER_PIXEL_SHADER = 0x0, + D3D12_SHVER_VERTEX_SHADER = 0x1, + D3D12_SHVER_GEOMETRY_SHADER = 0x2, + D3D12_SHVER_HULL_SHADER = 0x3, + D3D12_SHVER_DOMAIN_SHADER = 0x4, + D3D12_SHVER_COMPUTE_SHADER = 0x5, + D3D12_SHVER_RESERVED0 = 0xFFF0, +}} +STRUCT!{struct D3D12_FUNCTION_DESC { + Version: UINT, + Creator: LPCSTR, + Flags: UINT, + ConstantBuffers: UINT, + BoundResources: UINT, + InstructionCount: UINT, + TempRegisterCount: UINT, + TempArrayCount: UINT, + DefCount: UINT, + DclCount: UINT, + TextureNormalInstructions: UINT, + TextureLoadInstructions: UINT, + TextureCompInstructions: UINT, + TextureBiasInstructions: UINT, + TextureGradientInstructions: UINT, + FloatInstructionCount: UINT, + IntInstructionCount: UINT, + UintInstructionCount: UINT, + StaticFlowControlCount: UINT, + DynamicFlowControlCount: UINT, + MacroInstructionCount: UINT, + ArrayInstructionCount: UINT, + MovInstructionCount: UINT, + MovcInstructionCount: UINT, + ConversionInstructionCount: UINT, + BitwiseInstructionCount: UINT, + MinFeatureLevel: D3D_FEATURE_LEVEL, + RequiredFeatureFlags: UINT64, + Name: LPCSTR, + FunctionParameterCount: INT, + HasReturn: BOOL, + Has10Level9VertexShader: BOOL, + Has10Level9PixelShader: BOOL, +}} +STRUCT!{struct D3D12_LIBRARY_DESC { + Creator: LPCSTR, + Flags: UINT, + FunctionCount: UINT, +}} +STRUCT!{struct D3D12_PARAMETER_DESC { + Name: LPCSTR, + SemanticName: LPCSTR, + Type: D3D_SHADER_VARIABLE_TYPE, + Class: D3D_SHADER_VARIABLE_CLASS, + Rows: UINT, + Columns: UINT, + InterpolationMode: D3D_INTERPOLATION_MODE, + Flags: D3D_PARAMETER_FLAGS, + FirstInRegister: UINT, + FirstInComponent: UINT, + FirstOutRegister: UINT, + FirstOutComponent: UINT, +}} +STRUCT!{struct D3D12_SHADER_BUFFER_DESC { + Name: LPCSTR, + Type: D3D_CBUFFER_TYPE, + Variables: UINT, + Size: UINT, + uFlags: UINT, +}} +STRUCT!{struct D3D12_SHADER_DESC { + Version: UINT, + Creator: LPCSTR, + Flags: UINT, + ConstantBuffers: UINT, + BoundResources: UINT, + InputParameters: UINT, + OutputParameters: UINT, + InstructionCount: UINT, + TempRegisterCount: UINT, + TempArrayCount: UINT, + DefCount: UINT, + DclCount: UINT, + TextureNormalInstructions: UINT, + TextureLoadInstructions: UINT, + TextureCompInstructions: UINT, + TextureBiasInstructions: UINT, + TextureGradientInstructions: UINT, + FloatInstructionCount: UINT, + IntInstructionCount: UINT, + UintInstructionCount: UINT, + StaticFlowControlCount: UINT, + DynamicFlowControlCount: UINT, + MacroInstructionCount: UINT, + ArrayInstructionCount: UINT, + CutInstructionCount: UINT, + EmitInstructionCount: UINT, + GSOutputTopology: D3D_PRIMITIVE_TOPOLOGY, + GSMaxOutputVertexCount: UINT, + InputPrimitive: D3D_PRIMITIVE, + PatchConstantParameters: UINT, + cGSInstanceCount: UINT, + cControlPoints: UINT, + HSOutputPrimitive: D3D_TESSELLATOR_OUTPUT_PRIMITIVE, + HSPartitioning: D3D_TESSELLATOR_PARTITIONING, + TessellatorDomain: D3D_TESSELLATOR_DOMAIN, + cBarrierInstructions: UINT, + cInterlockedInstructions: UINT, + cTextureStoreInstructions: UINT, +}} +STRUCT!{struct D3D12_SHADER_INPUT_BIND_DESC { + Name: LPCSTR, + Type: D3D_SHADER_INPUT_TYPE, + BindPoint: UINT, + BindCount: UINT, + uFlags: UINT, + ReturnType: D3D_RESOURCE_RETURN_TYPE, + Dimension: D3D_SRV_DIMENSION, + NumSamples: UINT, + Space: UINT, + uID: UINT, +}} +STRUCT!{struct D3D12_SHADER_TYPE_DESC { + Class: D3D_SHADER_VARIABLE_CLASS, + Type: D3D_SHADER_VARIABLE_TYPE, + Rows: UINT, + Columns: UINT, + Elements: UINT, + Members: UINT, + Offset: UINT, + Name: LPCSTR, +}} +STRUCT!{struct D3D12_SHADER_VARIABLE_DESC { + Name: LPCSTR, + StartOffset: UINT, + Size: UINT, + uFlags: UINT, + DefaultValue: LPVOID, + StartTexture: UINT, + TextureSize: UINT, + StartSampler: UINT, + SamplerSize: UINT, +}} +STRUCT!{struct D3D12_SIGNATURE_PARAMETER_DESC { + SemanticName: LPCSTR, + SemanticIndex: UINT, + Register: UINT, + SystemValueType: D3D_NAME, + ComponentType: D3D_REGISTER_COMPONENT_TYPE, + Mask: BYTE, + ReadWriteMask: BYTE, + Stream: UINT, + MinPrecision: D3D_MIN_PRECISION, +}} +RIDL!{#[uuid(0xec25f42d, 0x7006, 0x4f2b, 0xb3, 0x3e, 0x02, 0xcc, 0x33, 0x75, 0x73, 0x3f)] +interface ID3D12FunctionParameterReflection(ID3D12FunctionParameterReflectionVtbl) { + fn GetDesc( + pDesc: *mut D3D12_PARAMETER_DESC, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1108795c, 0x2772, 0x4ba9, 0xb2, 0xa8, 0xd4, 0x64, 0xdc, 0x7e, 0x27, 0x99)] +interface ID3D12FunctionReflection(ID3D12FunctionReflectionVtbl) { + fn GetDesc( + pDesc: *mut D3D12_FUNCTION_DESC, + ) -> HRESULT, + fn GetConstantBufferByIndex( + BufferIndex: UINT, + ) -> *mut ID3D12ShaderReflectionConstantBuffer, + fn GetConstantBufferByName( + Name: LPCSTR, + ) -> *mut ID3D12ShaderReflectionConstantBuffer, + fn GetResourceBindingDesc( + ResourceIndex: UINT, + pDesc: *mut D3D12_SHADER_INPUT_BIND_DESC, + ) -> HRESULT, + fn GetVariableByName( + Name: LPCSTR, + ) -> *mut ID3D12ShaderReflectionVariable, + fn GetResourceBindingDescByName( + Name: LPCSTR, + pDesc: *mut D3D12_SHADER_INPUT_BIND_DESC, + ) -> HRESULT, + fn GetFunctionParameter( + ParameterIndex: INT, + ) -> *mut ID3D12FunctionParameterReflection, +}} +RIDL!{#[uuid(0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x4)] +interface ID3D12LibraryReflection(ID3D12LibraryReflectionVtbl): IUnknown(IUnknownVtbl) { + fn GetDesc( + pDesc: *mut D3D12_LIBRARY_DESC, + ) -> HRESULT, + fn GetFunctionByIndex( + FunctionIndex: INT, + ) -> *mut ID3D12FunctionReflection, +}} +DEFINE_GUID!{IID_ID3D12ShaderReflectionConstantBuffer, + 0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7} +RIDL!{#[uuid(0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7)] +interface ID3D12ShaderReflectionConstantBuffer(ID3D12ShaderReflectionConstantBufferVtbl) { + fn GetDesc( + pDesc: *mut D3D12_SHADER_BUFFER_DESC, + ) -> HRESULT, + fn GetVariableByIndex( + Index: UINT, + ) -> *mut ID3D12ShaderReflectionVariable, + fn GetVariableByName( + Name: LPCSTR, + ) -> *mut ID3D12ShaderReflectionVariable, +}} +DEFINE_GUID!{IID_ID3D12ShaderReflectionType, + 0xe913c351, 0x783d, 0x48ca, 0xa1, 0xd1, 0x4f, 0x30, 0x62, 0x84, 0xad, 0x56} +RIDL!{#[uuid(0xe913c351, 0x783d, 0x48ca, 0xa1, 0xd1, 0x4f, 0x30, 0x62, 0x84, 0xad, 0x56)] +interface ID3D12ShaderReflectionType(ID3D12ShaderReflectionTypeVtbl) { + fn GetDesc( + pDesc: *mut D3D12_SHADER_TYPE_DESC, + ) -> HRESULT, + fn GetMemberTypeByIndex( + Index: UINT, + ) -> *mut ID3D12ShaderReflectionType, + fn GetMemberTypeByName( + Name: LPCSTR, + ) -> *mut ID3D12ShaderReflectionType, + fn GetMemberTypeName( + Index: UINT, + ) -> LPCSTR, + fn IsEqual( + pType: *mut ID3D12ShaderReflectionType, + ) -> HRESULT, + fn GetSubType() -> *mut ID3D12ShaderReflectionType, + fn GetBaseClass() -> *mut ID3D12ShaderReflectionType, + fn GetNumInterfaces() -> UINT, + fn GetInterfaceByIndex( + uIndex: UINT, + ) -> *mut ID3D12ShaderReflectionType, + fn IsOfType( + pType: *mut ID3D12ShaderReflectionType, + ) -> HRESULT, + fn ImplementsInterface( + pBase: *mut ID3D12ShaderReflectionType, + ) -> HRESULT, +}} +DEFINE_GUID!{IID_ID3D12ShaderReflectionVariable, + 0x8337a8a6, 0xa216, 0x444a, 0xb2, 0xf4, 0x31, 0x47, 0x33, 0xa7, 0x3a, 0xea} +RIDL!{#[uuid(0x8337a8a6, 0xa216, 0x444a, 0xb2, 0xf4, 0x31, 0x47, 0x33, 0xa7, 0x3a, 0xea)] +interface ID3D12ShaderReflectionVariable(ID3D12ShaderReflectionVariableVtbl) { + fn GetDesc( + pDesc: *mut D3D12_SHADER_VARIABLE_DESC, + ) -> HRESULT, + fn GetType() -> *mut ID3D12ShaderReflectionType, + fn GetBuffer() -> *mut ID3D12ShaderReflectionConstantBuffer, + fn GetInterfaceSlot( + uArrayIndex: UINT, + ) -> UINT, +}} +DEFINE_GUID!{IID_ID3D12ShaderReflection, + 0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e} +RIDL!{#[uuid(0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e)] +interface ID3D12ShaderReflection(ID3D12ShaderReflectionVtbl): IUnknown(IUnknownVtbl) { + fn GetDesc( + pDesc: *mut D3D12_SHADER_DESC, + ) -> HRESULT, + fn GetConstantBufferByIndex( + Index: UINT, + ) -> *mut ID3D12ShaderReflectionConstantBuffer, + fn GetConstantBufferByName( + Name: LPCSTR, + ) -> *mut ID3D12ShaderReflectionConstantBuffer, + fn GetResourceBindingDesc( + ResourceIndex: UINT, + pDesc: *mut D3D12_SHADER_INPUT_BIND_DESC, + ) -> HRESULT, + fn GetInputParameterDesc( + ParameterIndex: UINT, + pDesc: *mut D3D12_SIGNATURE_PARAMETER_DESC, + ) -> HRESULT, + fn GetOutputParameterDesc( + ParameterIndex: UINT, + pDesc: *mut D3D12_SIGNATURE_PARAMETER_DESC, + ) -> HRESULT, + fn GetPatchConstantParameterDesc( + ParameterIndex: UINT, + pDesc: *mut D3D12_SIGNATURE_PARAMETER_DESC, + ) -> HRESULT, + fn GetVariableByName( + Name: LPCSTR, + ) -> *mut ID3D12ShaderReflectionVariable, + fn GetResourceBindingDescByName( + Name: LPCSTR, + pDesc: *mut D3D12_SHADER_INPUT_BIND_DESC, + ) -> HRESULT, + fn GetMovInstructionCount() -> UINT, + fn GetMovcInstructionCount() -> UINT, + fn GetConversionInstructionCount() -> UINT, + fn GetBitwiseInstructionCount() -> UINT, + fn GetGSInputPrimitive() -> D3D_PRIMITIVE, + fn IsSampleFrequencyShader() -> BOOL, + fn GetNumInterfaceSlots() -> UINT, + fn GetMinFeatureLevel( + pLevel: *mut D3D_FEATURE_LEVEL, + ) -> HRESULT, + fn GetThreadGroupSize( + pSizeX: *mut UINT, + pSizeY: *mut UINT, + pSizeZ: *mut UINT, + ) -> UINT, + fn GetRequiresFlags() -> UINT64, +}} +DEFINE_GUID!{IID_ID3D12LibraryReflection, + 0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x04} +DEFINE_GUID!{IID_ID3D12FunctionReflection, + 0x1108795c, 0x2772, 0x4ba9, 0xb2, 0xa8, 0xd4, 0x64, 0xdc, 0x7e, 0x27, 0x99} +DEFINE_GUID!{IID_ID3D12FunctionParameterReflection, + 0xec25f42d, 0x7006, 0x4f2b, 0xb3, 0x3e, 0x02, 0xcc, 0x33, 0x75, 0x73, 0x3f} +pub type D3D12_CBUFFER_TYPE = D3D_CBUFFER_TYPE; +pub type D3D12_RESOURCE_RETURN_TYPE = D3D_RESOURCE_RETURN_TYPE; +pub type D3D12_TESSELLATOR_DOMAIN = D3D_TESSELLATOR_DOMAIN; +pub type D3D12_TESSELLATOR_OUTPUT_PRIMITIVE = D3D_TESSELLATOR_OUTPUT_PRIMITIVE; +pub type D3D12_TESSELLATOR_PARTITIONING = D3D_TESSELLATOR_PARTITIONING; +pub type LPD3D12FUNCTIONPARAMETERREFLECTION = *mut ID3D12FunctionParameterReflection; +pub type LPD3D12FUNCTIONREFLECTION = *mut ID3D12FunctionReflection; +pub type LPD3D12LIBRARYREFLECTION = *mut ID3D12LibraryReflection; +pub type LPD3D12SHADERREFLECTION = *mut ID3D12ShaderReflection; +pub type LPD3D12SHADERREFLECTIONCONSTANTBUFFER = *mut ID3D12ShaderReflectionConstantBuffer; +pub type LPD3D12SHADERREFLECTIONTYPE = *mut ID3D12ShaderReflectionType; +pub type LPD3D12SHADERREFLECTIONVARIABLE = *mut ID3D12ShaderReflectionVariable; +pub const D3D_SHADER_REQUIRES_INNER_COVERAGE: UINT64 = 0x00000400; +pub const D3D_SHADER_REQUIRES_ROVS: UINT64 = 0x00001000; +pub const D3D_SHADER_REQUIRES_STENCIL_REF: UINT64 = 0x00000200; +pub const D3D_SHADER_REQUIRES_TYPED_UAV_LOAD_ADDITIONAL_FORMATS: UINT64 = 0x00000800; +pub const D3D_SHADER_REQUIRES_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER: + UINT64 = 0x00002000; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dcommon.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dcommon.rs new file mode 100644 index 0000000..b4f67dd --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dcommon.rs @@ -0,0 +1,744 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of d3dcommon.h +use shared::basetsd::SIZE_T; +use shared::minwindef::{LPCVOID, LPVOID, UINT}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCSTR}; +ENUM!{enum D3D_DRIVER_TYPE { + D3D_DRIVER_TYPE_UNKNOWN, + D3D_DRIVER_TYPE_HARDWARE, + D3D_DRIVER_TYPE_REFERENCE, + D3D_DRIVER_TYPE_NULL, + D3D_DRIVER_TYPE_SOFTWARE, + D3D_DRIVER_TYPE_WARP, +}} +ENUM!{enum D3D_FEATURE_LEVEL { + D3D_FEATURE_LEVEL_9_1 = 0x9100, + D3D_FEATURE_LEVEL_9_2 = 0x9200, + D3D_FEATURE_LEVEL_9_3 = 0x9300, + D3D_FEATURE_LEVEL_10_0 = 0xa000, + D3D_FEATURE_LEVEL_10_1 = 0xa100, + D3D_FEATURE_LEVEL_11_0 = 0xb000, + D3D_FEATURE_LEVEL_11_1 = 0xb100, + D3D_FEATURE_LEVEL_12_0 = 0xc000, + D3D_FEATURE_LEVEL_12_1 = 0xc100, +}} +ENUM!{enum D3D_PRIMITIVE_TOPOLOGY { + D3D_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, + D3D_PRIMITIVE_TOPOLOGY_POINTLIST = 1, + D3D_PRIMITIVE_TOPOLOGY_LINELIST = 2, + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP = 3, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5, + D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10, + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ = 11, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ = 12, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ = 13, + D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST = 33, + D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST = 34, + D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST = 35, + D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST = 36, + D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST = 37, + D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST = 38, + D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST = 39, + D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST = 40, + D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST = 41, + D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST = 42, + D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST = 43, + D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST = 44, + D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST = 45, + D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST = 46, + D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST = 47, + D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST = 48, + D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST = 49, + D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST = 50, + D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST = 51, + D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST = 52, + D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST = 53, + D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST = 54, + D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST = 55, + D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST = 56, + D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST = 57, + D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST = 58, + D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST = 59, + D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST = 60, + D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST = 61, + D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST = 62, + D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST = 63, + D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST = 64, +}} +pub const D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; +pub const D3D10_PRIMITIVE_TOPOLOGY_POINTLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_POINTLIST; +pub const D3D10_PRIMITIVE_TOPOLOGY_LINELIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_LINELIST; +pub const D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; +pub const D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; +pub const D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; +pub const D3D10_PRIMITIVE_TOPOLOGY_LINELIST_ADJ: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; +pub const D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ; +pub const D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ; +pub const D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ; +pub const D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; +pub const D3D11_PRIMITIVE_TOPOLOGY_POINTLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_POINTLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_LINELIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_LINELIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; +pub const D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; +pub const D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; +pub const D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ; +pub const D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ; +pub const D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ; +pub const D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST; +pub const D3D11_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST: D3D_PRIMITIVE_TOPOLOGY = + D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST; +ENUM!{enum D3D_PRIMITIVE { + D3D_PRIMITIVE_UNDEFINED = 0, + D3D_PRIMITIVE_POINT = 1, + D3D_PRIMITIVE_LINE = 2, + D3D_PRIMITIVE_TRIANGLE = 3, + D3D_PRIMITIVE_LINE_ADJ = 6, + D3D_PRIMITIVE_TRIANGLE_ADJ = 7, + D3D_PRIMITIVE_1_CONTROL_POINT_PATCH = 8, + D3D_PRIMITIVE_2_CONTROL_POINT_PATCH = 9, + D3D_PRIMITIVE_3_CONTROL_POINT_PATCH = 10, + D3D_PRIMITIVE_4_CONTROL_POINT_PATCH = 11, + D3D_PRIMITIVE_5_CONTROL_POINT_PATCH = 12, + D3D_PRIMITIVE_6_CONTROL_POINT_PATCH = 13, + D3D_PRIMITIVE_7_CONTROL_POINT_PATCH = 14, + D3D_PRIMITIVE_8_CONTROL_POINT_PATCH = 15, + D3D_PRIMITIVE_9_CONTROL_POINT_PATCH = 16, + D3D_PRIMITIVE_10_CONTROL_POINT_PATCH = 17, + D3D_PRIMITIVE_11_CONTROL_POINT_PATCH = 18, + D3D_PRIMITIVE_12_CONTROL_POINT_PATCH = 19, + D3D_PRIMITIVE_13_CONTROL_POINT_PATCH = 20, + D3D_PRIMITIVE_14_CONTROL_POINT_PATCH = 21, + D3D_PRIMITIVE_15_CONTROL_POINT_PATCH = 22, + D3D_PRIMITIVE_16_CONTROL_POINT_PATCH = 23, + D3D_PRIMITIVE_17_CONTROL_POINT_PATCH = 24, + D3D_PRIMITIVE_18_CONTROL_POINT_PATCH = 25, + D3D_PRIMITIVE_19_CONTROL_POINT_PATCH = 26, + D3D_PRIMITIVE_20_CONTROL_POINT_PATCH = 28, + D3D_PRIMITIVE_21_CONTROL_POINT_PATCH = 29, + D3D_PRIMITIVE_22_CONTROL_POINT_PATCH = 30, + D3D_PRIMITIVE_23_CONTROL_POINT_PATCH = 31, + D3D_PRIMITIVE_24_CONTROL_POINT_PATCH = 32, + D3D_PRIMITIVE_25_CONTROL_POINT_PATCH = 33, + D3D_PRIMITIVE_26_CONTROL_POINT_PATCH = 34, + D3D_PRIMITIVE_27_CONTROL_POINT_PATCH = 35, + D3D_PRIMITIVE_28_CONTROL_POINT_PATCH = 36, + D3D_PRIMITIVE_29_CONTROL_POINT_PATCH = 37, + D3D_PRIMITIVE_30_CONTROL_POINT_PATCH = 38, + D3D_PRIMITIVE_31_CONTROL_POINT_PATCH = 39, + D3D_PRIMITIVE_32_CONTROL_POINT_PATCH = 40, +}} +pub const D3D10_PRIMITIVE_UNDEFINED: D3D_PRIMITIVE = D3D_PRIMITIVE_UNDEFINED; +pub const D3D10_PRIMITIVE_POINT: D3D_PRIMITIVE = D3D_PRIMITIVE_POINT; +pub const D3D10_PRIMITIVE_LINE: D3D_PRIMITIVE = D3D_PRIMITIVE_LINE; +pub const D3D10_PRIMITIVE_TRIANGLE: D3D_PRIMITIVE = D3D_PRIMITIVE_TRIANGLE; +pub const D3D10_PRIMITIVE_LINE_ADJ: D3D_PRIMITIVE = D3D_PRIMITIVE_LINE_ADJ; +pub const D3D10_PRIMITIVE_TRIANGLE_ADJ: D3D_PRIMITIVE = D3D_PRIMITIVE_TRIANGLE_ADJ; +pub const D3D11_PRIMITIVE_UNDEFINED: D3D_PRIMITIVE = D3D_PRIMITIVE_UNDEFINED; +pub const D3D11_PRIMITIVE_POINT: D3D_PRIMITIVE = D3D_PRIMITIVE_POINT; +pub const D3D11_PRIMITIVE_LINE: D3D_PRIMITIVE = D3D_PRIMITIVE_LINE; +pub const D3D11_PRIMITIVE_TRIANGLE: D3D_PRIMITIVE = D3D_PRIMITIVE_TRIANGLE; +pub const D3D11_PRIMITIVE_LINE_ADJ: D3D_PRIMITIVE = D3D_PRIMITIVE_LINE_ADJ; +pub const D3D11_PRIMITIVE_TRIANGLE_ADJ: D3D_PRIMITIVE = D3D_PRIMITIVE_TRIANGLE_ADJ; +pub const D3D11_PRIMITIVE_1_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_1_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_2_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_2_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_3_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_3_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_4_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_4_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_5_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_5_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_6_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_6_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_7_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_7_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_8_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_8_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_9_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_9_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_10_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_10_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_11_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_11_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_12_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_12_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_13_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_13_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_14_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_14_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_15_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_15_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_16_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_16_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_17_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_17_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_18_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_18_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_19_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_19_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_20_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_20_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_21_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_21_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_22_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_22_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_23_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_23_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_24_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_24_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_25_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_25_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_26_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_26_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_27_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_27_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_28_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_28_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_29_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_29_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_30_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_30_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_31_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_31_CONTROL_POINT_PATCH; +pub const D3D11_PRIMITIVE_32_CONTROL_POINT_PATCH: D3D_PRIMITIVE = + D3D_PRIMITIVE_32_CONTROL_POINT_PATCH; +ENUM!{enum D3D_SRV_DIMENSION { + D3D_SRV_DIMENSION_UNKNOWN = 0, + D3D_SRV_DIMENSION_BUFFER = 1, + D3D_SRV_DIMENSION_TEXTURE1D = 2, + D3D_SRV_DIMENSION_TEXTURE1DARRAY = 3, + D3D_SRV_DIMENSION_TEXTURE2D = 4, + D3D_SRV_DIMENSION_TEXTURE2DARRAY = 5, + D3D_SRV_DIMENSION_TEXTURE2DMS = 6, + D3D_SRV_DIMENSION_TEXTURE2DMSARRAY = 7, + D3D_SRV_DIMENSION_TEXTURE3D = 8, + D3D_SRV_DIMENSION_TEXTURECUBE = 9, + D3D_SRV_DIMENSION_TEXTURECUBEARRAY = 10, + D3D_SRV_DIMENSION_BUFFEREX = 11, +}} +pub const D3D10_SRV_DIMENSION_UNKNOWN: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_UNKNOWN; +pub const D3D10_SRV_DIMENSION_BUFFER: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_BUFFER; +pub const D3D10_SRV_DIMENSION_TEXTURE1D: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1D; +pub const D3D10_SRV_DIMENSION_TEXTURE1DARRAY: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1DARRAY; +pub const D3D10_SRV_DIMENSION_TEXTURE2D: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2D; +pub const D3D10_SRV_DIMENSION_TEXTURE2DARRAY: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DARRAY; +pub const D3D10_SRV_DIMENSION_TEXTURE2DMS: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DMS; +pub const D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY: D3D_SRV_DIMENSION = + D3D_SRV_DIMENSION_TEXTURE2DMSARRAY; +pub const D3D10_SRV_DIMENSION_TEXTURE3D: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE3D; +pub const D3D10_SRV_DIMENSION_TEXTURECUBE: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURECUBE; +pub const D3D10_1_SRV_DIMENSION_UNKNOWN: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_UNKNOWN; +pub const D3D10_1_SRV_DIMENSION_BUFFER: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_BUFFER; +pub const D3D10_1_SRV_DIMENSION_TEXTURE1D: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1D; +pub const D3D10_1_SRV_DIMENSION_TEXTURE1DARRAY: D3D_SRV_DIMENSION = + D3D_SRV_DIMENSION_TEXTURE1DARRAY; +pub const D3D10_1_SRV_DIMENSION_TEXTURE2D: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2D; +pub const D3D10_1_SRV_DIMENSION_TEXTURE2DARRAY: D3D_SRV_DIMENSION = + D3D_SRV_DIMENSION_TEXTURE2DARRAY; +pub const D3D10_1_SRV_DIMENSION_TEXTURE2DMS: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DMS; +pub const D3D10_1_SRV_DIMENSION_TEXTURE2DMSARRAY: D3D_SRV_DIMENSION = + D3D_SRV_DIMENSION_TEXTURE2DMSARRAY; +pub const D3D10_1_SRV_DIMENSION_TEXTURE3D: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE3D; +pub const D3D10_1_SRV_DIMENSION_TEXTURECUBE: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURECUBE; +pub const D3D10_1_SRV_DIMENSION_TEXTURECUBEARRAY: D3D_SRV_DIMENSION = + D3D_SRV_DIMENSION_TEXTURECUBEARRAY; +pub const D3D11_SRV_DIMENSION_UNKNOWN: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_UNKNOWN; +pub const D3D11_SRV_DIMENSION_BUFFER: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_BUFFER; +pub const D3D11_SRV_DIMENSION_TEXTURE1D: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1D; +pub const D3D11_SRV_DIMENSION_TEXTURE1DARRAY: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1DARRAY; +pub const D3D11_SRV_DIMENSION_TEXTURE2D: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2D; +pub const D3D11_SRV_DIMENSION_TEXTURE2DARRAY: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DARRAY; +pub const D3D11_SRV_DIMENSION_TEXTURE2DMS: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DMS; +pub const D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY: D3D_SRV_DIMENSION = + D3D_SRV_DIMENSION_TEXTURE2DMSARRAY; +pub const D3D11_SRV_DIMENSION_TEXTURE3D: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE3D; +pub const D3D11_SRV_DIMENSION_TEXTURECUBE: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURECUBE; +pub const D3D11_SRV_DIMENSION_TEXTURECUBEARRAY: D3D_SRV_DIMENSION = + D3D_SRV_DIMENSION_TEXTURECUBEARRAY; +pub const D3D11_SRV_DIMENSION_BUFFEREX: D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_BUFFEREX; +STRUCT!{struct D3D_SHADER_MACRO { + Name: LPCSTR, + Definition: LPCSTR, +}} +pub type LPD3D_SHADER_MACRO = *mut D3D_SHADER_MACRO; +DEFINE_GUID!{IID_ID3D10Blob, + 0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0x0d, 0x98, 0x9c, 0x3a, 0x01, 0x02} +RIDL!{#[uuid(0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2)] +interface ID3D10Blob(ID3D10BlobVtbl): IUnknown(IUnknownVtbl) { + fn GetBufferPointer() -> LPVOID, + fn GetBufferSize() -> SIZE_T, +}} +pub type LPD3D10BLOB = *mut ID3D10Blob; +pub type ID3DBlob = ID3D10Blob; +pub type LPD3DBLOB = *mut ID3DBlob; +ENUM!{enum D3D_INCLUDE_TYPE { + D3D_INCLUDE_LOCAL = 0, + D3D_INCLUDE_SYSTEM, +}} +pub const D3D10_INCLUDE_LOCAL: D3D_INCLUDE_TYPE = D3D_INCLUDE_LOCAL; +pub const D3D10_INCLUDE_SYSTEM: D3D_INCLUDE_TYPE = D3D_INCLUDE_SYSTEM; +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +interface ID3DInclude(ID3DIncludeVtbl) { + fn Open( + IncludeType: D3D_INCLUDE_TYPE, + pFileName: LPCSTR, + pParentData: LPCVOID, + ppData: *mut LPCVOID, + pBytes: *mut UINT, + ) -> HRESULT, + fn Close( + pData: LPCVOID, + ) -> HRESULT, +}} +pub type LPD3DINCLUDE = *mut ID3DInclude; +ENUM!{enum D3D_SHADER_VARIABLE_CLASS { + D3D_SVC_SCALAR = 0, + D3D_SVC_VECTOR, + D3D_SVC_MATRIX_ROWS, + D3D_SVC_MATRIX_COLUMNS, + D3D_SVC_OBJECT, + D3D_SVC_STRUCT, + D3D_SVC_INTERFACE_CLASS, + D3D_SVC_INTERFACE_POINTER, +}} +pub const D3D10_SVC_SCALAR: D3D_SHADER_VARIABLE_CLASS = D3D_SVC_SCALAR; +pub const D3D10_SVC_VECTOR: D3D_SHADER_VARIABLE_CLASS = D3D_SVC_VECTOR; +pub const D3D10_SVC_MATRIX_ROWS: D3D_SHADER_VARIABLE_CLASS = D3D_SVC_MATRIX_ROWS; +pub const D3D10_SVC_MATRIX_COLUMNS: D3D_SHADER_VARIABLE_CLASS = D3D_SVC_MATRIX_COLUMNS; +pub const D3D10_SVC_OBJECT: D3D_SHADER_VARIABLE_CLASS = D3D_SVC_OBJECT; +pub const D3D10_SVC_STRUCT: D3D_SHADER_VARIABLE_CLASS = D3D_SVC_STRUCT; +pub const D3D11_SVC_INTERFACE_CLASS: D3D_SHADER_VARIABLE_CLASS = D3D_SVC_INTERFACE_CLASS; +pub const D3D11_SVC_INTERFACE_POINTER: D3D_SHADER_VARIABLE_CLASS = D3D_SVC_INTERFACE_POINTER; +ENUM!{enum D3D_SHADER_VARIABLE_FLAGS { + D3D_SVF_USERPACKED = 1, + D3D_SVF_USED = 2, + D3D_SVF_INTERFACE_POINTER = 4, + D3D_SVF_INTERFACE_PARAMETER = 8, +}} +pub const D3D10_SVF_USERPACKED: D3D_SHADER_VARIABLE_FLAGS = D3D_SVF_USERPACKED; +pub const D3D10_SVF_USED: D3D_SHADER_VARIABLE_FLAGS = D3D_SVF_USED; +pub const D3D11_SVF_INTERFACE_POINTER: D3D_SHADER_VARIABLE_FLAGS = D3D_SVF_INTERFACE_POINTER; +pub const D3D11_SVF_INTERFACE_PARAMETER: D3D_SHADER_VARIABLE_FLAGS = D3D_SVF_INTERFACE_PARAMETER; +ENUM!{enum D3D_SHADER_VARIABLE_TYPE { + D3D_SVT_VOID = 0, + D3D_SVT_BOOL = 1, + D3D_SVT_INT = 2, + D3D_SVT_FLOAT = 3, + D3D_SVT_STRING = 4, + D3D_SVT_TEXTURE = 5, + D3D_SVT_TEXTURE1D = 6, + D3D_SVT_TEXTURE2D = 7, + D3D_SVT_TEXTURE3D = 8, + D3D_SVT_TEXTURECUBE = 9, + D3D_SVT_SAMPLER = 10, + D3D_SVT_SAMPLER1D = 11, + D3D_SVT_SAMPLER2D = 12, + D3D_SVT_SAMPLER3D = 13, + D3D_SVT_SAMPLERCUBE = 14, + D3D_SVT_PIXELSHADER = 15, + D3D_SVT_VERTEXSHADER = 16, + D3D_SVT_PIXELFRAGMENT = 17, + D3D_SVT_VERTEXFRAGMENT = 18, + D3D_SVT_UINT = 19, + D3D_SVT_UINT8 = 20, + D3D_SVT_GEOMETRYSHADER = 21, + D3D_SVT_RASTERIZER = 22, + D3D_SVT_DEPTHSTENCIL = 23, + D3D_SVT_BLEND = 24, + D3D_SVT_BUFFER = 25, + D3D_SVT_CBUFFER = 26, + D3D_SVT_TBUFFER = 27, + D3D_SVT_TEXTURE1DARRAY = 28, + D3D_SVT_TEXTURE2DARRAY = 29, + D3D_SVT_RENDERTARGETVIEW = 30, + D3D_SVT_DEPTHSTENCILVIEW = 31, + D3D_SVT_TEXTURE2DMS = 32, + D3D_SVT_TEXTURE2DMSARRAY = 33, + D3D_SVT_TEXTURECUBEARRAY = 34, + D3D_SVT_HULLSHADER = 35, + D3D_SVT_DOMAINSHADER = 36, + D3D_SVT_INTERFACE_POINTER = 37, + D3D_SVT_COMPUTESHADER = 38, + D3D_SVT_DOUBLE = 39, + D3D_SVT_RWTEXTURE1D = 40, + D3D_SVT_RWTEXTURE1DARRAY = 41, + D3D_SVT_RWTEXTURE2D = 42, + D3D_SVT_RWTEXTURE2DARRAY = 43, + D3D_SVT_RWTEXTURE3D = 44, + D3D_SVT_RWBUFFER = 45, + D3D_SVT_BYTEADDRESS_BUFFER = 46, + D3D_SVT_RWBYTEADDRESS_BUFFER = 47, + D3D_SVT_STRUCTURED_BUFFER = 48, + D3D_SVT_RWSTRUCTURED_BUFFER = 49, + D3D_SVT_APPEND_STRUCTURED_BUFFER = 50, + D3D_SVT_CONSUME_STRUCTURED_BUFFER = 51, + D3D_SVT_MIN8FLOAT = 52, + D3D_SVT_MIN10FLOAT = 53, + D3D_SVT_MIN16FLOAT = 54, + D3D_SVT_MIN12INT = 55, + D3D_SVT_MIN16INT = 56, + D3D_SVT_MIN16UINT = 57, +}} +pub const D3D10_SVT_VOID: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_VOID; +pub const D3D10_SVT_BOOL: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_BOOL; +pub const D3D10_SVT_INT: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_INT; +pub const D3D10_SVT_FLOAT: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_FLOAT; +pub const D3D10_SVT_STRING: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_STRING; +pub const D3D10_SVT_TEXTURE: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE; +pub const D3D10_SVT_TEXTURE1D: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE1D; +pub const D3D10_SVT_TEXTURE2D: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE2D; +pub const D3D10_SVT_TEXTURE3D: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE3D; +pub const D3D10_SVT_TEXTURECUBE: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURECUBE; +pub const D3D10_SVT_SAMPLER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_SAMPLER; +pub const D3D10_SVT_SAMPLER1D: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_SAMPLER1D; +pub const D3D10_SVT_SAMPLER2D: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_SAMPLER2D; +pub const D3D10_SVT_SAMPLER3D: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_SAMPLER3D; +pub const D3D10_SVT_SAMPLERCUBE: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_SAMPLERCUBE; +pub const D3D10_SVT_PIXELSHADER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_PIXELSHADER; +pub const D3D10_SVT_VERTEXSHADER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_VERTEXSHADER; +pub const D3D10_SVT_PIXELFRAGMENT: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_PIXELFRAGMENT; +pub const D3D10_SVT_VERTEXFRAGMENT: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_VERTEXFRAGMENT; +pub const D3D10_SVT_UINT: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_UINT; +pub const D3D10_SVT_UINT8: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_UINT8; +pub const D3D10_SVT_GEOMETRYSHADER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_GEOMETRYSHADER; +pub const D3D10_SVT_RASTERIZER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RASTERIZER; +pub const D3D10_SVT_DEPTHSTENCIL: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_DEPTHSTENCIL; +pub const D3D10_SVT_BLEND: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_BLEND; +pub const D3D10_SVT_BUFFER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_BUFFER; +pub const D3D10_SVT_CBUFFER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_CBUFFER; +pub const D3D10_SVT_TBUFFER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TBUFFER; +pub const D3D10_SVT_TEXTURE1DARRAY: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE1DARRAY; +pub const D3D10_SVT_TEXTURE2DARRAY: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE2DARRAY; +pub const D3D10_SVT_RENDERTARGETVIEW: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RENDERTARGETVIEW; +pub const D3D10_SVT_DEPTHSTENCILVIEW: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_DEPTHSTENCILVIEW; +pub const D3D10_SVT_TEXTURE2DMS: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE2DMS; +pub const D3D10_SVT_TEXTURE2DMSARRAY: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE2DMSARRAY; +pub const D3D10_SVT_TEXTURECUBEARRAY: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURECUBEARRAY; +pub const D3D11_SVT_HULLSHADER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_HULLSHADER; +pub const D3D11_SVT_DOMAINSHADER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_DOMAINSHADER; +pub const D3D11_SVT_INTERFACE_POINTER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_INTERFACE_POINTER; +pub const D3D11_SVT_COMPUTESHADER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_COMPUTESHADER; +pub const D3D11_SVT_DOUBLE: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_DOUBLE; +pub const D3D11_SVT_RWTEXTURE1D: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWTEXTURE1D; +pub const D3D11_SVT_RWTEXTURE1DARRAY: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWTEXTURE1DARRAY; +pub const D3D11_SVT_RWTEXTURE2D: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWTEXTURE2D; +pub const D3D11_SVT_RWTEXTURE2DARRAY: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWTEXTURE2DARRAY; +pub const D3D11_SVT_RWTEXTURE3D: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWTEXTURE3D; +pub const D3D11_SVT_RWBUFFER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWBUFFER; +pub const D3D11_SVT_BYTEADDRESS_BUFFER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_BYTEADDRESS_BUFFER; +pub const D3D11_SVT_RWBYTEADDRESS_BUFFER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWBYTEADDRESS_BUFFER; +pub const D3D11_SVT_STRUCTURED_BUFFER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_STRUCTURED_BUFFER; +pub const D3D11_SVT_RWSTRUCTURED_BUFFER: D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWSTRUCTURED_BUFFER; +pub const D3D11_SVT_APPEND_STRUCTURED_BUFFER: D3D_SHADER_VARIABLE_TYPE = + D3D_SVT_APPEND_STRUCTURED_BUFFER; +pub const D3D11_SVT_CONSUME_STRUCTURED_BUFFER: D3D_SHADER_VARIABLE_TYPE = + D3D_SVT_CONSUME_STRUCTURED_BUFFER; +ENUM!{enum D3D_SHADER_INPUT_FLAGS { + D3D_SIF_USERPACKED = 0x1, + D3D_SIF_COMPARISON_SAMPLER = 0x2, + D3D_SIF_TEXTURE_COMPONENT_0 = 0x4, + D3D_SIF_TEXTURE_COMPONENT_1 = 0x8, + D3D_SIF_TEXTURE_COMPONENTS = 0xc, + D3D_SIF_UNUSED = 0x10, +}} +pub const D3D10_SIF_USERPACKED: D3D_SHADER_INPUT_FLAGS = D3D_SIF_USERPACKED; +pub const D3D10_SIF_COMPARISON_SAMPLER: D3D_SHADER_INPUT_FLAGS = D3D_SIF_COMPARISON_SAMPLER; +pub const D3D10_SIF_TEXTURE_COMPONENT_0: D3D_SHADER_INPUT_FLAGS = D3D_SIF_TEXTURE_COMPONENT_0; +pub const D3D10_SIF_TEXTURE_COMPONENT_1: D3D_SHADER_INPUT_FLAGS = D3D_SIF_TEXTURE_COMPONENT_1; +pub const D3D10_SIF_TEXTURE_COMPONENTS: D3D_SHADER_INPUT_FLAGS = D3D_SIF_TEXTURE_COMPONENTS; +ENUM!{enum D3D_SHADER_INPUT_TYPE { + D3D_SIT_CBUFFER, + D3D_SIT_TBUFFER, + D3D_SIT_TEXTURE, + D3D_SIT_SAMPLER, + D3D_SIT_UAV_RWTYPED, + D3D_SIT_STRUCTURED, + D3D_SIT_UAV_RWSTRUCTURED, + D3D_SIT_BYTEADDRESS, + D3D_SIT_UAV_RWBYTEADDRESS, + D3D_SIT_UAV_APPEND_STRUCTURED, + D3D_SIT_UAV_CONSUME_STRUCTURED, + D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER, +}} +pub const D3D10_SIT_CBUFFER: D3D_SHADER_INPUT_TYPE = D3D_SIT_CBUFFER; +pub const D3D10_SIT_TBUFFER: D3D_SHADER_INPUT_TYPE = D3D_SIT_TBUFFER; +pub const D3D10_SIT_TEXTURE: D3D_SHADER_INPUT_TYPE = D3D_SIT_TEXTURE; +pub const D3D10_SIT_SAMPLER: D3D_SHADER_INPUT_TYPE = D3D_SIT_SAMPLER; +pub const D3D11_SIT_UAV_RWTYPED: D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_RWTYPED; +pub const D3D11_SIT_STRUCTURED: D3D_SHADER_INPUT_TYPE = D3D_SIT_STRUCTURED; +pub const D3D11_SIT_UAV_RWSTRUCTURED: D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_RWSTRUCTURED; +pub const D3D11_SIT_BYTEADDRESS: D3D_SHADER_INPUT_TYPE = D3D_SIT_BYTEADDRESS; +pub const D3D11_SIT_UAV_RWBYTEADDRESS: D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_RWBYTEADDRESS; +pub const D3D11_SIT_UAV_APPEND_STRUCTURED: D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_APPEND_STRUCTURED; +pub const D3D11_SIT_UAV_CONSUME_STRUCTURED: D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_CONSUME_STRUCTURED; +pub const D3D11_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: D3D_SHADER_INPUT_TYPE = + D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER; +ENUM!{enum D3D_SHADER_CBUFFER_FLAGS { + D3D_CBF_USERPACKED = 1, +}} +pub const D3D10_CBF_USERPACKED: D3D_SHADER_CBUFFER_FLAGS = D3D_CBF_USERPACKED; +ENUM!{enum D3D_CBUFFER_TYPE { + D3D_CT_CBUFFER, + D3D_CT_TBUFFER, + D3D_CT_INTERFACE_POINTERS, + D3D_CT_RESOURCE_BIND_INFO, +}} +pub const D3D10_CT_CBUFFER: D3D_CBUFFER_TYPE = D3D_CT_CBUFFER; +pub const D3D10_CT_TBUFFER: D3D_CBUFFER_TYPE = D3D_CT_TBUFFER; +pub const D3D11_CT_CBUFFER: D3D_CBUFFER_TYPE = D3D_CT_CBUFFER; +pub const D3D11_CT_TBUFFER: D3D_CBUFFER_TYPE = D3D_CT_TBUFFER; +pub const D3D11_CT_INTERFACE_POINTERS: D3D_CBUFFER_TYPE = D3D_CT_INTERFACE_POINTERS; +pub const D3D11_CT_RESOURCE_BIND_INFO: D3D_CBUFFER_TYPE = D3D_CT_RESOURCE_BIND_INFO; +ENUM!{enum D3D_NAME { + D3D_NAME_UNDEFINED = 0, + D3D_NAME_POSITION = 1, + D3D_NAME_CLIP_DISTANCE = 2, + D3D_NAME_CULL_DISTANCE = 3, + D3D_NAME_RENDER_TARGET_ARRAY_INDEX = 4, + D3D_NAME_VIEWPORT_ARRAY_INDEX = 5, + D3D_NAME_VERTEX_ID = 6, + D3D_NAME_PRIMITIVE_ID = 7, + D3D_NAME_INSTANCE_ID = 8, + D3D_NAME_IS_FRONT_FACE = 9, + D3D_NAME_SAMPLE_INDEX = 10, + D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR = 11, + D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR = 12, + D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR = 13, + D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR = 14, + D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR = 15, + D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR = 16, + D3D_NAME_TARGET = 64, + D3D_NAME_DEPTH = 65, + D3D_NAME_COVERAGE = 66, + D3D_NAME_DEPTH_GREATER_EQUAL = 67, + D3D_NAME_DEPTH_LESS_EQUAL = 68, +}} +pub const D3D10_NAME_UNDEFINED: D3D_NAME = D3D_NAME_UNDEFINED; +pub const D3D10_NAME_POSITION: D3D_NAME = D3D_NAME_POSITION; +pub const D3D10_NAME_CLIP_DISTANCE: D3D_NAME = D3D_NAME_CLIP_DISTANCE; +pub const D3D10_NAME_CULL_DISTANCE: D3D_NAME = D3D_NAME_CULL_DISTANCE; +pub const D3D10_NAME_RENDER_TARGET_ARRAY_INDEX: D3D_NAME = D3D_NAME_RENDER_TARGET_ARRAY_INDEX; +pub const D3D10_NAME_VIEWPORT_ARRAY_INDEX: D3D_NAME = D3D_NAME_VIEWPORT_ARRAY_INDEX; +pub const D3D10_NAME_VERTEX_ID: D3D_NAME = D3D_NAME_VERTEX_ID; +pub const D3D10_NAME_PRIMITIVE_ID: D3D_NAME = D3D_NAME_PRIMITIVE_ID; +pub const D3D10_NAME_INSTANCE_ID: D3D_NAME = D3D_NAME_INSTANCE_ID; +pub const D3D10_NAME_IS_FRONT_FACE: D3D_NAME = D3D_NAME_IS_FRONT_FACE; +pub const D3D10_NAME_SAMPLE_INDEX: D3D_NAME = D3D_NAME_SAMPLE_INDEX; +pub const D3D10_NAME_TARGET: D3D_NAME = D3D_NAME_TARGET; +pub const D3D10_NAME_DEPTH: D3D_NAME = D3D_NAME_DEPTH; +pub const D3D10_NAME_COVERAGE: D3D_NAME = D3D_NAME_COVERAGE; +pub const D3D11_NAME_FINAL_QUAD_EDGE_TESSFACTOR: D3D_NAME = D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR; +pub const D3D11_NAME_FINAL_QUAD_INSIDE_TESSFACTOR: D3D_NAME + = D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR; +pub const D3D11_NAME_FINAL_TRI_EDGE_TESSFACTOR: D3D_NAME = D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR; +pub const D3D11_NAME_FINAL_TRI_INSIDE_TESSFACTOR: D3D_NAME = D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR; +pub const D3D11_NAME_FINAL_LINE_DETAIL_TESSFACTOR: D3D_NAME + = D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR; +pub const D3D11_NAME_FINAL_LINE_DENSITY_TESSFACTOR: D3D_NAME + = D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR; +pub const D3D11_NAME_DEPTH_GREATER_EQUAL: D3D_NAME = D3D_NAME_DEPTH_GREATER_EQUAL; +pub const D3D11_NAME_DEPTH_LESS_EQUAL: D3D_NAME = D3D_NAME_DEPTH_LESS_EQUAL; +ENUM!{enum D3D_RESOURCE_RETURN_TYPE { + D3D_RETURN_TYPE_UNORM = 1, + D3D_RETURN_TYPE_SNORM = 2, + D3D_RETURN_TYPE_SINT = 3, + D3D_RETURN_TYPE_UINT = 4, + D3D_RETURN_TYPE_FLOAT = 5, + D3D_RETURN_TYPE_MIXED = 6, + D3D_RETURN_TYPE_DOUBLE = 7, + D3D_RETURN_TYPE_CONTINUED = 8, +}} +pub const D3D10_RETURN_TYPE_UNORM: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_UNORM; +pub const D3D10_RETURN_TYPE_SNORM: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_SNORM; +pub const D3D10_RETURN_TYPE_SINT: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_SINT; +pub const D3D10_RETURN_TYPE_UINT: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_UINT; +pub const D3D10_RETURN_TYPE_FLOAT: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_FLOAT; +pub const D3D10_RETURN_TYPE_MIXED: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_MIXED; +pub const D3D11_RETURN_TYPE_UNORM: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_UNORM; +pub const D3D11_RETURN_TYPE_SNORM: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_SNORM; +pub const D3D11_RETURN_TYPE_SINT: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_SINT; +pub const D3D11_RETURN_TYPE_UINT: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_UINT; +pub const D3D11_RETURN_TYPE_FLOAT: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_FLOAT; +pub const D3D11_RETURN_TYPE_MIXED: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_MIXED; +pub const D3D11_RETURN_TYPE_DOUBLE: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_DOUBLE; +pub const D3D11_RETURN_TYPE_CONTINUED: D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_CONTINUED; +ENUM!{enum D3D_REGISTER_COMPONENT_TYPE { + D3D_REGISTER_COMPONENT_UNKNOWN = 0, + D3D_REGISTER_COMPONENT_UINT32 = 1, + D3D_REGISTER_COMPONENT_SINT32 = 2, + D3D_REGISTER_COMPONENT_FLOAT32 = 3, +}} +pub const D3D10_REGISTER_COMPONENT_UNKNOWN: D3D_REGISTER_COMPONENT_TYPE = + D3D_REGISTER_COMPONENT_UNKNOWN; +pub const D3D10_REGISTER_COMPONENT_UINT32: D3D_REGISTER_COMPONENT_TYPE = + D3D_REGISTER_COMPONENT_UINT32; +pub const D3D10_REGISTER_COMPONENT_SINT32: D3D_REGISTER_COMPONENT_TYPE = + D3D_REGISTER_COMPONENT_SINT32; +pub const D3D10_REGISTER_COMPONENT_FLOAT32: D3D_REGISTER_COMPONENT_TYPE = + D3D_REGISTER_COMPONENT_FLOAT32; +ENUM!{enum D3D_TESSELLATOR_DOMAIN { + D3D_TESSELLATOR_DOMAIN_UNDEFINED, + D3D_TESSELLATOR_DOMAIN_ISOLINE, + D3D_TESSELLATOR_DOMAIN_TRI, + D3D_TESSELLATOR_DOMAIN_QUAD, +}} +pub const D3D11_TESSELLATOR_DOMAIN_UNDEFINED: D3D_TESSELLATOR_DOMAIN = + D3D_TESSELLATOR_DOMAIN_UNDEFINED; +pub const D3D11_TESSELLATOR_DOMAIN_ISOLINE: D3D_TESSELLATOR_DOMAIN = + D3D_TESSELLATOR_DOMAIN_ISOLINE; +pub const D3D11_TESSELLATOR_DOMAIN_TRI: D3D_TESSELLATOR_DOMAIN = D3D_TESSELLATOR_DOMAIN_TRI; +pub const D3D11_TESSELLATOR_DOMAIN_QUAD: D3D_TESSELLATOR_DOMAIN = D3D_TESSELLATOR_DOMAIN_QUAD; +ENUM!{enum D3D_TESSELLATOR_PARTITIONING { + D3D_TESSELLATOR_PARTITIONING_UNDEFINED, + D3D_TESSELLATOR_PARTITIONING_INTEGER, + D3D_TESSELLATOR_PARTITIONING_POW2, + D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD, + D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN, +}} +pub const D3D11_TESSELLATOR_PARTITIONING_UNDEFINED: D3D_TESSELLATOR_PARTITIONING = + D3D_TESSELLATOR_PARTITIONING_UNDEFINED; +pub const D3D11_TESSELLATOR_PARTITIONING_INTEGER: D3D_TESSELLATOR_PARTITIONING = + D3D_TESSELLATOR_PARTITIONING_INTEGER; +pub const D3D11_TESSELLATOR_PARTITIONING_POW2: D3D_TESSELLATOR_PARTITIONING = + D3D_TESSELLATOR_PARTITIONING_POW2; +pub const D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD: D3D_TESSELLATOR_PARTITIONING = + D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD; +pub const D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN: D3D_TESSELLATOR_PARTITIONING = + D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN; +ENUM!{enum D3D_TESSELLATOR_OUTPUT_PRIMITIVE { + D3D_TESSELLATOR_OUTPUT_UNDEFINED, + D3D_TESSELLATOR_OUTPUT_POINT, + D3D_TESSELLATOR_OUTPUT_LINE, + D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW, + D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW, +}} +pub const D3D11_TESSELLATOR_OUTPUT_UNDEFINED: D3D_TESSELLATOR_OUTPUT_PRIMITIVE = + D3D_TESSELLATOR_OUTPUT_UNDEFINED; +pub const D3D11_TESSELLATOR_OUTPUT_POINT: D3D_TESSELLATOR_OUTPUT_PRIMITIVE = + D3D_TESSELLATOR_OUTPUT_POINT; +pub const D3D11_TESSELLATOR_OUTPUT_LINE: D3D_TESSELLATOR_OUTPUT_PRIMITIVE = + D3D_TESSELLATOR_OUTPUT_LINE; +pub const D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CW: D3D_TESSELLATOR_OUTPUT_PRIMITIVE = + D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW; +pub const D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CCW: D3D_TESSELLATOR_OUTPUT_PRIMITIVE = + D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW; +ENUM!{enum D3D_MIN_PRECISION { + D3D_MIN_PRECISION_DEFAULT, + D3D_MIN_PRECISION_FLOAT_16, + D3D_MIN_PRECISION_FLOAT_2_8, + D3D_MIN_PRECISION_RESERVED, + D3D_MIN_PRECISION_SINT_16, + D3D_MIN_PRECISION_UINT_16, + D3D_MIN_PRECISION_ANY_16 = 0xf0, + D3D_MIN_PRECISION_ANY_10 = 0xf1, +}} +ENUM!{enum D3D_INTERPOLATION_MODE { + D3D_INTERPOLATION_UNDEFINED, + D3D_INTERPOLATION_CONSTANT, + D3D_INTERPOLATION_LINEAR, + D3D_INTERPOLATION_LINEAR_CENTROID, + D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE, + D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE_CENTROID, + D3D_INTERPOLATION_LINEAR_SAMPLE, + D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE_SAMPLE, +}} +ENUM!{enum D3D_PARAMETER_FLAGS { + D3D_PF_NONE = 0, + D3D_PF_IN = 0x1, + D3D_PF_OUT = 0x2, +}} +DEFINE_GUID!{WKPDID_D3DDebugObjectName, + 0x429b8c22, 0x9188, 0x4b0c, 0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00} +DEFINE_GUID!{WKPDID_D3DDebugObjectNameW, + 0x4cca5fd8, 0x921f, 0x42c8, 0x85, 0x66, 0x70, 0xca, 0xf2, 0xa9, 0xb7, 0x41} +DEFINE_GUID!{WKPDID_CommentStringW, + 0xd0149dc0, 0x90e8, 0x4ec8, 0x81, 0x44, 0xe9, 0x00, 0xad, 0x26, 0x6b, 0xb2} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dcompiler.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dcompiler.rs new file mode 100644 index 0000000..944ae25 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dcompiler.rs @@ -0,0 +1,274 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_void; +use shared::basetsd::SIZE_T; +use shared::guiddef::REFIID; +use shared::minwindef::{BOOL, DWORD, LPCVOID, LPVOID, UINT}; +use um::d3d11shader::{ID3D11FunctionLinkingGraph, ID3D11Linker, ID3D11Module}; +use um::d3dcommon::{D3D_SHADER_MACRO, ID3DBlob, ID3DInclude}; +use um::winnt::{HRESULT, LPCSTR, LPCWSTR}; +pub const D3DCOMPILER_DLL: &'static str = "d3dcompiler_47.dll"; +pub const D3D_COMPILER_VERSION: DWORD = 47; +extern "system" { + pub fn D3DReadFileToBlob( + pFileName: LPCWSTR, + ppContents: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DWriteBlobToFile( + pBlob: *mut ID3DBlob, + pFileName: LPCWSTR, + bOverwrite: BOOL, + ) -> HRESULT; +} +pub const D3DCOMPILE_DEBUG: DWORD = 1 << 0; +pub const D3DCOMPILE_SKIP_VALIDATION: DWORD = 1 << 1; +pub const D3DCOMPILE_SKIP_OPTIMIZATION: DWORD = 1 << 2; +pub const D3DCOMPILE_PACK_MATRIX_ROW_MAJOR: DWORD = 1 << 3; +pub const D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR: DWORD = 1 << 4; +pub const D3DCOMPILE_PARTIAL_PRECISION: DWORD = 1 << 5; +pub const D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT: DWORD = 1 << 6; +pub const D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT: DWORD = 1 << 7; +pub const D3DCOMPILE_NO_PRESHADER: DWORD = 1 << 8; +pub const D3DCOMPILE_AVOID_FLOW_CONTROL: DWORD = 1 << 9; +pub const D3DCOMPILE_PREFER_FLOW_CONTROL: DWORD = 1 << 10; +pub const D3DCOMPILE_ENABLE_STRICTNESS: DWORD = 1 << 11; +pub const D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY: DWORD = 1 << 12; +pub const D3DCOMPILE_IEEE_STRICTNESS: DWORD = 1 << 13; +pub const D3DCOMPILE_OPTIMIZATION_LEVEL0: DWORD = 1 << 14; +pub const D3DCOMPILE_OPTIMIZATION_LEVEL1: DWORD = 0; +pub const D3DCOMPILE_OPTIMIZATION_LEVEL2: DWORD = (1 << 14) | (1 << 15); +pub const D3DCOMPILE_OPTIMIZATION_LEVEL3: DWORD = 1 << 15; +pub const D3DCOMPILE_RESERVED16: DWORD = 1 << 16; +pub const D3DCOMPILE_RESERVED17: DWORD = 1 << 17; +pub const D3DCOMPILE_WARNINGS_ARE_ERRORS: DWORD = 1 << 18; +pub const D3DCOMPILE_RESOURCES_MAY_ALIAS: DWORD = 1 << 19; +pub const D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES: DWORD = 1 << 20; +pub const D3DCOMPILE_ALL_RESOURCES_BOUND: DWORD = 1 << 21; +pub const D3DCOMPILE_EFFECT_CHILD_EFFECT: DWORD = 1 << 0; +pub const D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS: DWORD = 1 << 1; +pub const D3D_COMPILE_STANDARD_FILE_INCLUDE: *mut ID3DInclude = 1 as *mut ID3DInclude; +extern "system" { + pub fn D3DCompile( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + pSourceName: LPCSTR, + pDefines: *const D3D_SHADER_MACRO, + pInclude: *mut ID3DInclude, + pEntrypoint: LPCSTR, + pTarget: LPCSTR, + Flags1: UINT, + Flags2: UINT, + ppCode: *mut *mut ID3DBlob, + ppErrorMsgs: *mut *mut ID3DBlob, + ) -> HRESULT; +} +pub const D3DCOMPILE_SECDATA_MERGE_UAV_SLOTS: DWORD = 0x00000001; +pub const D3DCOMPILE_SECDATA_PRESERVE_TEMPLATE_SLOTS: DWORD = 0x00000002; +pub const D3DCOMPILE_SECDATA_REQUIRE_TEMPLATE_MATCH: DWORD = 0x00000004; +extern "system" { + pub fn D3DCompile2( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + pSourceName: LPCSTR, + pDefines: *const D3D_SHADER_MACRO, + pInclude: *mut ID3DInclude, + pEntrypoint: LPCSTR, + pTarget: LPCSTR, + Flags1: UINT, + Flags2: UINT, + SecondaryDataFlags: UINT, + pSecondaryData: LPCVOID, + SecondaryDataSize: SIZE_T, + ppCode: *mut *mut ID3DBlob, + ppErrorMsgs: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DCompileFromFile( + pFileName: LPCWSTR, + pDefines: *const D3D_SHADER_MACRO, + pInclude: *mut ID3DInclude, + pEntrypoint: LPCSTR, + pTarget: LPCSTR, + Flags1: UINT, + Flags2: UINT, + ppCode: *mut *mut ID3DBlob, + ppErrorMsgs: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DPreprocess( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + pSourceName: LPCSTR, + pDefines: *const D3D_SHADER_MACRO, + pInclude: *mut ID3DInclude, + ppCodeText: *mut *mut ID3DBlob, + ppErrorMsgs: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DGetDebugInfo( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + ppDebugInfo: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DReflect( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + pInterface: REFIID, + ppReflector: *mut *mut c_void, + ) -> HRESULT; + pub fn D3DReflectLibrary( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + riid: REFIID, + ppReflector: *mut LPVOID, + ) -> HRESULT; +} +pub const D3D_DISASM_ENABLE_COLOR_CODE: DWORD = 0x00000001; +pub const D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS: DWORD = 0x00000002; +pub const D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING: DWORD = 0x00000004; +pub const D3D_DISASM_ENABLE_INSTRUCTION_CYCLE: DWORD = 0x00000008; +pub const D3D_DISASM_DISABLE_DEBUG_INFO: DWORD = 0x00000010; +pub const D3D_DISASM_ENABLE_INSTRUCTION_OFFSET: DWORD = 0x00000020; +pub const D3D_DISASM_INSTRUCTION_ONLY: DWORD = 0x00000040; +pub const D3D_DISASM_PRINT_HEX_LITERALS: DWORD = 0x00000080; +extern "system" { + pub fn D3DDisassemble( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + Flags: UINT, + szComments: LPCSTR, + ppDisassembly: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DDisassembleRegion( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + Flags: UINT, + szComments: LPCSTR, + StartByteOffset: SIZE_T, + NumInsts: SIZE_T, + pFinishByteOffset: *mut SIZE_T, + ppDisassembly: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DCreateLinker( + ppLinker: *mut *mut ID3D11Linker, + ) -> HRESULT; + pub fn D3DLoadModule( + pSrcData: LPCVOID, + cbSrcDataSize: SIZE_T, + ppModule: *mut *mut ID3D11Module, + ) -> HRESULT; + pub fn D3DCreateFunctionLinkingGraph( + uFlags: UINT, + ppFunctionLinkingGraph: *mut *mut ID3D11FunctionLinkingGraph, + ) -> HRESULT; +} +pub const D3D_GET_INST_OFFSETS_INCLUDE_NON_EXECUTABLE: DWORD = 0x00000001; +extern "system" { + pub fn D3DGetTraceInstructionOffsets( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + Flags: UINT, + StartInstIndex: SIZE_T, + NumInsts: SIZE_T, + pOffsets: *mut SIZE_T, + pTotalInsts: *mut SIZE_T, + ) -> HRESULT; + pub fn D3DGetInputSignatureBlob( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + ppSignatureBlob: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DGetOutputSignatureBlob( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + ppSignatureBlob: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DGetInputAndOutputSignatureBlob( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + ppSignatureBlob: *mut *mut ID3DBlob, + ) -> HRESULT; +} +ENUM!{enum D3DCOMPILER_STRIP_FLAGS { + D3DCOMPILER_STRIP_REFLECTION_DATA = 0x00000001, + D3DCOMPILER_STRIP_DEBUG_INFO = 0x00000002, + D3DCOMPILER_STRIP_TEST_BLOBS = 0x00000004, + D3DCOMPILER_STRIP_PRIVATE_DATA = 0x00000008, + D3DCOMPILER_STRIP_ROOT_SIGNATURE = 0x00000010, + D3DCOMPILER_STRIP_FORCE_DWORD = 0x7fffffff, +}} +extern "system" { + pub fn D3DStripShader( + pShaderBytecode: LPCVOID, + BytecodeLength: SIZE_T, + uStripFlags: UINT, + ppStrippedBlob: *mut *mut ID3DBlob, + ) -> HRESULT; +} +ENUM!{enum D3D_BLOB_PART { + D3D_BLOB_INPUT_SIGNATURE_BLOB, + D3D_BLOB_OUTPUT_SIGNATURE_BLOB, + D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB, + D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB, + D3D_BLOB_ALL_SIGNATURE_BLOB, + D3D_BLOB_DEBUG_INFO, + D3D_BLOB_LEGACY_SHADER, + D3D_BLOB_XNA_PREPASS_SHADER, + D3D_BLOB_XNA_SHADER, + D3D_BLOB_PDB, + D3D_BLOB_PRIVATE_DATA, + D3D_BLOB_ROOT_SIGNATURE, + D3D_BLOB_TEST_ALTERNATE_SHADER = 0x8000, + D3D_BLOB_TEST_COMPILE_DETAILS, + D3D_BLOB_TEST_COMPILE_PERF, + D3D_BLOB_TEST_COMPILE_REPORT, +}} +extern "system" { + pub fn D3DGetBlobPart( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + Part: D3D_BLOB_PART, + Flags: UINT, + ppPart: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DSetBlobPart( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + Part: D3D_BLOB_PART, + Flags: UINT, + pPart: LPCVOID, + PartSize: SIZE_T, + ppNewShader: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DCreateBlob( + Size: SIZE_T, + ppBlob: *mut *mut ID3DBlob, + ) -> HRESULT; +} +STRUCT!{struct D3D_SHADER_DATA { + pBytecode: LPCVOID, + BytecodeLength: SIZE_T, +}} +extern "system" { + pub fn D3DCompressShaders( + uNumShaders: UINT, + pShaderData: *mut D3D_SHADER_DATA, + uFlags: UINT, + ppCompressedData: *mut *mut ID3DBlob, + ) -> HRESULT; + pub fn D3DDecompressShaders( + pSrcData: LPCVOID, + SrcDataSize: SIZE_T, + uNumShaders: UINT, + uStartIndex: UINT, + pIndices: *mut UINT, + uFlags: UINT, + ppShaders: *mut *mut ID3DBlob, + pTotalShaders: *mut UINT, + ) -> HRESULT; + // pub fn D3DDisassemble10Effect( + // pEffect: *mut ID3D10Effect, + // Flags: UINT, + // ppDisassembly: *mut *mut ID3DBlob, + // ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dcsx.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dcsx.rs new file mode 100644 index 0000000..c126400 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dcsx.rs @@ -0,0 +1,11 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_ID3DX11Scan, + 0x5089b68f, 0xe71d, 0x4d38, 0xbe, 0x8e, 0xf3, 0x63, 0xb9, 0x5a, 0x94, 0x05} +DEFINE_GUID!{IID_ID3DX11SegmentedScan, + 0xa915128c, 0xd954, 0x4c79, 0xbf, 0xe1, 0x64, 0xdb, 0x92, 0x31, 0x94, 0xd6} +DEFINE_GUID!{IID_ID3DX11FFT, + 0xb3f7a938, 0x4c93, 0x4310, 0xa6, 0x75, 0xb3, 0x0d, 0x6d, 0xe5, 0x05, 0x53} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dx10core.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dx10core.rs new file mode 100644 index 0000000..c5fb449 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dx10core.rs @@ -0,0 +1,11 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_ID3DX10Sprite, + 0xba0b762d, 0x8d28, 0x43ec, 0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x06, 0x14} +DEFINE_GUID!{IID_ID3DX10ThreadPump, + 0xc93fecfa, 0x6967, 0x478a, 0xab, 0xbc, 0x40, 0x2d, 0x90, 0x62, 0x1f, 0xcb} +DEFINE_GUID!{IID_ID3DX10Font, + 0xd79dbb70, 0x5f21, 0x4d36, 0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dx10math.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dx10math.rs new file mode 100644 index 0000000..9c6179f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dx10math.rs @@ -0,0 +1,7 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_ID3DXMatrixStack, + 0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dx10mesh.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dx10mesh.rs new file mode 100644 index 0000000..319df62 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/d3dx10mesh.rs @@ -0,0 +1,19 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_ID3DX10BaseMesh, + 0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30} +DEFINE_GUID!{IID_ID3DX10MeshBuffer, + 0x04b0d117, 0x1041, 0x46b1, 0xaa, 0x8a, 0x39, 0x52, 0x84, 0x8b, 0xa2, 0x2e} +DEFINE_GUID!{IID_ID3DX10Mesh, + 0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95} +DEFINE_GUID!{IID_ID3DX10PMesh, + 0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96} +DEFINE_GUID!{IID_ID3DX10SPMesh, + 0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x02, 0x90, 0xb8, 0x3c, 0xc5} +DEFINE_GUID!{IID_ID3DX10PatchMesh, + 0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39} +DEFINE_GUID!{IID_ID3DX10SkinInfo, + 0x420bd604, 0x1c76, 0x4a34, 0xa4, 0x66, 0xe4, 0x5d, 0x06, 0x58, 0xa3, 0x2c} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/datetimeapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/datetimeapi.rs new file mode 100644 index 0000000..e8102a1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/datetimeapi.rs @@ -0,0 +1,60 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_int; +use shared::minwindef::DWORD; +use um::minwinbase::SYSTEMTIME; +use um::winnt::{LCID, LPCSTR, LPCWSTR, LPSTR, LPWSTR}; +extern "system" { + pub fn GetDateFormatA( + Locale: LCID, + dwFlags: DWORD, + lpDate: *const SYSTEMTIME, + lpFormat: LPCSTR, + lpDateStr: LPSTR, + cchDate: c_int, + ) -> c_int; + pub fn GetDateFormatW( + Locale: LCID, + dwFlags: DWORD, + lpDate: *const SYSTEMTIME, + lpFormat: LPCWSTR, + lpDateStr: LPWSTR, + cchDate: c_int, + ) -> c_int; + pub fn GetTimeFormatA( + Locale: LCID, + dwFlags: DWORD, + lpTime: *const SYSTEMTIME, + lpFormat: LPCSTR, + lpTimeStr: LPSTR, + cchTime: c_int, + ) -> c_int; + pub fn GetTimeFormatW( + Locale: LCID, + dwFlags: DWORD, + lpTime: *const SYSTEMTIME, + lpFormat: LPCWSTR, + lpTimeStr: LPWSTR, + cchTime: c_int, + ) -> c_int; + pub fn GetTimeFormatEx( + lpLocaleName: LPCWSTR, + dwFlags: DWORD, + lpTime: *const SYSTEMTIME, + lpFormat: LPCWSTR, + lpTimeStr: LPWSTR, + cchTime: c_int, + ) -> c_int; + pub fn GetDateFormatEx( + lpLocaleName: LPCWSTR, + dwFlags: DWORD, + lpDate: *const SYSTEMTIME, + lpFormat: LPCWSTR, + lpDateStr: LPWSTR, + cchDate: c_int, + lpCalendar: LPCWSTR, + ) -> c_int; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/davclnt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/davclnt.rs new file mode 100644 index 0000000..9bfc5a3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/davclnt.rs @@ -0,0 +1,104 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! This module defines the DAV specific functions that are exposed to the user +use shared::minwindef::{BOOL, DWORD, LPDWORD, PBYTE, PULONG, ULONG}; +use um::winnt::{HANDLE, LPCWSTR, LPWSTR, PVOID, PWSTR}; +pub type OPAQUE_HANDLE = DWORD; +STRUCT!{struct DAV_CALLBACK_AUTH_BLOB { + pBuffer: PVOID, + ulSize: ULONG, + ulType: ULONG, +}} +pub type PDAV_CALLBACK_AUTH_BLOB = *mut DAV_CALLBACK_AUTH_BLOB; +STRUCT!{struct DAV_CALLBACK_AUTH_UNP { + pszUserName: LPWSTR, + ulUserNameLength: ULONG, + pszPassword: LPWSTR, + ulPasswordLength: ULONG, +}} +pub type PDAV_CALLBACK_AUTH_UNP = *mut DAV_CALLBACK_AUTH_UNP; +STRUCT!{struct DAV_CALLBACK_CRED { + AuthBlob: DAV_CALLBACK_AUTH_BLOB, + UNPBlob: DAV_CALLBACK_AUTH_UNP, + bAuthBlobValid: BOOL, + bSave: BOOL, +}} +pub type PDAV_CALLBACK_CRED = *mut DAV_CALLBACK_CRED; +pub const DAV_AUTHN_SCHEME_BASIC: DWORD = 0x00000001; +pub const DAV_AUTHN_SCHEME_NTLM: DWORD = 0x00000002; +pub const DAV_AUTHN_SCHEME_PASSPORT: DWORD = 0x00000004; +pub const DAV_AUTHN_SCHEME_DIGEST: DWORD = 0x00000008; +pub const DAV_AUTHN_SCHEME_NEGOTIATE: DWORD = 0x00000010; +pub const DAV_AUTHN_SCHEME_CERT: DWORD = 0x00010000; +pub const DAV_AUTHN_SCHEME_FBA: DWORD = 0x00100000; +ENUM!{enum AUTHNEXTSTEP { + DefaultBehavior, + RetryRequest, + CancelRequest, +}} +FN!{stdcall PFNDAVAUTHCALLBACK_FREECRED( + pbuffer: PVOID, +) -> DWORD} +FN!{stdcall PFNDAVAUTHCALLBACK( + lpwzServerName: LPWSTR, + lpwzRemoteName: LPWSTR, + dwAuthScheme: DWORD, + dwFlags: DWORD, + pCallbackCred: PDAV_CALLBACK_CRED, + NextStep: *mut AUTHNEXTSTEP, + pFreeCred: *mut PFNDAVAUTHCALLBACK_FREECRED, +) -> DWORD} +extern "system" { + pub fn DavAddConnection( + ConnectionHandle: *mut HANDLE, + RemoteName: LPCWSTR, + UserName: LPCWSTR, + Password: LPCWSTR, + ClientCert: PBYTE, + CertSize: DWORD, + ) -> DWORD; + pub fn DavDeleteConnection( + ConnectionHandle: HANDLE, + ) -> DWORD; + pub fn DavGetUNCFromHTTPPath( + HttpPath: LPCWSTR, + UncPath: LPWSTR, + lpSize: LPDWORD, + ) -> DWORD; + pub fn DavGetHTTPFromUNCPath( + UncPath: LPCWSTR, + HttpPath: LPWSTR, + lpSize: LPDWORD, + ) -> DWORD; + pub fn DavGetTheLockOwnerOfTheFile( + FileName: LPCWSTR, + LockOwnerName: PWSTR, + LockOwnerNameLengthInBytes: PULONG, + ) -> DWORD; + pub fn DavGetExtendedError( + hFile: HANDLE, + ExtError: *mut DWORD, + ExtErrorString: LPWSTR, + cChSize: *mut DWORD, + ) -> DWORD; + pub fn DavFlushFile( + hFile: HANDLE, + ) -> DWORD; + pub fn DavInvalidateCache( + URLName: LPWSTR, + ) -> DWORD; + pub fn DavCancelConnectionsToServer( + URLName: LPWSTR, + fForce: BOOL, + ) -> DWORD; + pub fn DavRegisterAuthCallback( + CallBack: PFNDAVAUTHCALLBACK, + Version: ULONG, + ) -> OPAQUE_HANDLE; + pub fn DavUnregisterAuthCallback( + hCallback: OPAQUE_HANDLE, + ); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dbghelp.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dbghelp.rs new file mode 100644 index 0000000..4e76728 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dbghelp.rs @@ -0,0 +1,667 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! DbgHelp include file +use shared::basetsd::{DWORD64, PDWORD64, ULONG64}; +use shared::guiddef::GUID; +use shared::minwindef::{ + BOOL, DWORD, HMODULE, LPDWORD, PDWORD, PUCHAR, PULONG, UCHAR, ULONG, USHORT, WORD, +}; +use um::winnt::{ + BOOLEAN, CHAR, HANDLE, LIST_ENTRY, PCSTR, PCWSTR, PIMAGE_NT_HEADERS, PIMAGE_SECTION_HEADER, + PSTR, PVOID, PWSTR, WCHAR, +}; +#[cfg(target_pointer_width = "32")] +use um::winnt::{ + PFPO_DATA, PIMAGE_COFF_SYMBOLS_HEADER, PIMAGE_DEBUG_DIRECTORY, PIMAGE_FUNCTION_ENTRY, + PIMAGE_NT_HEADERS32, +}; +#[cfg(target_pointer_width = "64")] +use um::winnt::PIMAGE_NT_HEADERS64; +use vc::vcruntime::size_t; +#[cfg(target_pointer_width = "64")] +STRUCT!{struct LOADED_IMAGE { + ModuleName: PSTR, + hFile: HANDLE, + MappedAddress: PUCHAR, + FileHeader: PIMAGE_NT_HEADERS64, + LastRvaSection: PIMAGE_SECTION_HEADER, + NumberOfSections: ULONG, + Sections: PIMAGE_SECTION_HEADER, + Characteristics: ULONG, + fSystemImage: BOOLEAN, + fDOSImage: BOOLEAN, + fReadOnly: BOOLEAN, + Version: UCHAR, + Links: LIST_ENTRY, + SizeOfImage: ULONG, +}} +#[cfg(target_pointer_width = "32")] +STRUCT!{struct LOADED_IMAGE { + ModuleName: PSTR, + hFile: HANDLE, + MappedAddress: PUCHAR, + FileHeader: PIMAGE_NT_HEADERS32, + LastRvaSection: PIMAGE_SECTION_HEADER, + NumberOfSections: ULONG, + Sections: PIMAGE_SECTION_HEADER, + Characteristics: ULONG, + fSystemImage: BOOLEAN, + fDOSImage: BOOLEAN, + fReadOnly: BOOLEAN, + Version: UCHAR, + Links: LIST_ENTRY, + SizeOfImage: ULONG, +}} +pub const MAX_SYM_NAME: usize = 2000; +pub const ERROR_IMAGE_NOT_STRIPPED: DWORD = 0x8800; +pub const ERROR_NO_DBG_POINTER: DWORD = 0x8801; +pub const ERROR_NO_PDB_POINTER: DWORD = 0x8802; +FN!{stdcall PFIND_DEBUG_FILE_CALLBACK( + FileHandle: HANDLE, + FileName: PCSTR, + CallerData: PVOID, +) -> BOOL} +FN!{stdcall PFIND_DEBUG_FILE_CALLBACKW( + FileHandle: HANDLE, + FileName: PCWSTR, + CallerData: PVOID, +) -> BOOL} +FN!{stdcall PFINDFILEINPATHCALLBACK( + filename: PCSTR, + context: PVOID, +) -> BOOL} +FN!{stdcall PFINDFILEINPATHCALLBACKW( + filename: PCWSTR, + context: PVOID, +) -> BOOL} +FN!{stdcall PFIND_EXE_FILE_CALLBACK( + FileHandle: HANDLE, + FileName: PCSTR, + CallerData: PVOID, +) -> BOOL} +FN!{stdcall PFIND_EXE_FILE_CALLBACKW( + FileHandle: HANDLE, + FileName: PCWSTR, + CallerData: PVOID, +) -> BOOL} +FN!{stdcall PSYM_ENUMERATESYMBOLS_CALLBACKW( + pSymInfo: PSYMBOL_INFOW, + SymbolSize: ULONG, + CallerData: PVOID, +) -> BOOL} +#[cfg(target_pointer_width = "32")] +STRUCT!{struct IMAGE_DEBUG_INFORMATION { + List: LIST_ENTRY, + ReservedSize: DWORD, + ReservedMappedBase: PVOID, + ReservedMachine: USHORT, + ReservedCharacteristics: USHORT, + ReservedCheckSum: DWORD, + ImageBase: DWORD, + SizeOfImage: DWORD, + ReservedNumberOfSections: DWORD, + ReservedSections: PIMAGE_SECTION_HEADER, + ReservedExportedNamesSize: DWORD, + ReservedExportedNames: PSTR, + ReservedNumberOfFunctionTableEntries: DWORD, + ReservedFunctionTableEntries: PIMAGE_FUNCTION_ENTRY, + ReservedLowestFunctionStartingAddress: DWORD, + ReservedHighestFunctionEndingAddress: DWORD, + ReservedNumberOfFpoTableEntries: DWORD, + ReservedFpoTableEntries: PFPO_DATA, + SizeOfCoffSymbols: DWORD, + CoffSymbols: PIMAGE_COFF_SYMBOLS_HEADER, + ReservedSizeOfCodeViewSymbols: DWORD, + ReservedCodeViewSymbols: PVOID, + ImageFilePath: PSTR, + ImageFileName: PSTR, + ReservedDebugFilePath: PSTR, + ReservedTimeDateStamp: DWORD, + ReservedRomImage: BOOL, + ReservedDebugDirectory: PIMAGE_DEBUG_DIRECTORY, + ReservedNumberOfDebugDirectories: DWORD, + ReservedOriginalFunctionTableBaseAddress: DWORD, + Reserved: [DWORD; 2], +}} +#[cfg(target_pointer_width = "32")] +pub type PIMAGE_DEBUG_INFORMATION = *mut IMAGE_DEBUG_INFORMATION; +FN!{stdcall PENUMDIRTREE_CALLBACK( + FilePath: PCSTR, + CallerData: PVOID, +) -> BOOL} +FN!{stdcall PENUMDIRTREE_CALLBACKW( + FilePath: PCWSTR, + CallerData: PVOID, +) -> BOOL} +pub const UNDNAME_COMPLETE: DWORD = 0x0000; +pub const UNDNAME_NO_LEADING_UNDERSCORES: DWORD = 0x0001; +pub const UNDNAME_NO_MS_KEYWORDS: DWORD = 0x0002; +pub const UNDNAME_NO_FUNCTION_RETURNS: DWORD = 0x0004; +pub const UNDNAME_NO_ALLOCATION_MODEL: DWORD = 0x0008; +pub const UNDNAME_NO_ALLOCATION_LANGUAGE: DWORD = 0x0010; +pub const UNDNAME_NO_MS_THISTYPE: DWORD = 0x0020; +pub const UNDNAME_NO_CV_THISTYPE: DWORD = 0x0040; +pub const UNDNAME_NO_THISTYPE: DWORD = 0x0060; +pub const UNDNAME_NO_ACCESS_SPECIFIERS: DWORD = 0x0080; +pub const UNDNAME_NO_THROW_SIGNATURES: DWORD = 0x0100; +pub const UNDNAME_NO_MEMBER_TYPE: DWORD = 0x0200; +pub const UNDNAME_NO_RETURN_UDT_MODEL: DWORD = 0x0400; +pub const UNDNAME_32_BIT_DECODE: DWORD = 0x0800; +pub const UNDNAME_NAME_ONLY: DWORD = 0x1000; +pub const UNDNAME_NO_ARGUMENTS: DWORD = 0x2000; +pub const UNDNAME_NO_SPECIAL_SYMS: DWORD = 0x4000; +pub const DBHHEADER_DEBUGDIRS: DWORD = 0x1; +pub const DBHHEADER_CVMISC: DWORD = 0x2; +pub const DBHHEADER_PDBGUID: DWORD = 0x3; +STRUCT!{struct MODLOAD_DATA { + ssize: DWORD, + ssig: DWORD, + data: PVOID, + size: DWORD, + flags: DWORD, +}} +pub type PMODLOAD_DATA = *mut MODLOAD_DATA; +STRUCT!{struct MODLOAD_CVMISC { + oCV: DWORD, + cCV: size_t, + oMisc: DWORD, + cMisc: size_t, + dtImage: DWORD, + cImage: DWORD, +}} +pub type PMODLOAD_CVMISC = *mut MODLOAD_CVMISC; +STRUCT!{struct MODLOAD_PDBGUID_PDBAGE { + PdbGuid: GUID, + PdbAge: DWORD, +}} +pub type PMODLOAD_PDBGUID_PDBAGE = *mut MODLOAD_PDBGUID_PDBAGE; +ENUM!{enum ADDRESS_MODE { + AddrMode1616, + AddrMode1632, + AddrModeReal, + AddrModeFlat, +}} +STRUCT!{struct ADDRESS64 { + Offset: DWORD64, + Segment: WORD, + Mode: ADDRESS_MODE, +}} +pub type LPADDRESS64 = *mut ADDRESS64; +#[cfg(target_pointer_width = "64")] +pub type ADDRESS = ADDRESS64; +#[cfg(target_pointer_width = "64")] +pub type LPADDRESS = LPADDRESS64; +#[cfg(target_pointer_width = "32")] +STRUCT!{struct ADDRESS { + Offset: DWORD, + Segment: WORD, + Mode: ADDRESS_MODE, +}} +#[cfg(target_pointer_width = "32")] +pub type LPADDRESS = *mut ADDRESS; +STRUCT!{struct KDHELP64 { + Thread: DWORD64, + ThCallbackStack: DWORD, + ThCallbackBStore: DWORD, + NextCallback: DWORD, + FramePointer: DWORD, + KiCallUserMode: DWORD64, + KeUserCallbackDispatcher: DWORD64, + SystemRangeStart: DWORD64, + KiUserExceptionDispatcher: DWORD64, + StackBase: DWORD64, + StackLimit: DWORD64, + BuildVersion: DWORD, + Reserved0: DWORD, + Reserved1: [DWORD64; 4], +}} +pub type PKDHELP64 = *mut KDHELP64; +#[cfg(target_pointer_width = "64")] +pub type KDHELP = KDHELP64; +#[cfg(target_pointer_width = "64")] +pub type PKDHELP = PKDHELP64; +#[cfg(target_pointer_width = "32")] +STRUCT!{struct KDHELP { + Thread: DWORD, + ThCallbackStack: DWORD, + NextCallback: DWORD, + FramePointer: DWORD, + KiCallUserMode: DWORD, + KeUserCallbackDispatcher: DWORD, + SystemRangeStart: DWORD, + ThCallbackBStore: DWORD, + KiUserExceptionDispatcher: DWORD, + StackBase: DWORD, + StackLimit: DWORD, + Reserved: [DWORD; 5], +}} +#[cfg(target_pointer_width = "32")] +pub type PKDHELP = *mut KDHELP; +STRUCT!{struct STACKFRAME64 { + AddrPC: ADDRESS64, + AddrReturn: ADDRESS64, + AddrFrame: ADDRESS64, + AddrStack: ADDRESS64, + AddrBStore: ADDRESS64, + FuncTableEntry: PVOID, + Params: [DWORD64; 4], + Far: BOOL, + Virtual: BOOL, + Reserved: [DWORD64; 3], + KdHelp: KDHELP64, +}} +pub type LPSTACKFRAME64 = *mut STACKFRAME64; +pub const INLINE_FRAME_CONTEXT_INIT: DWORD = 0; +pub const INLINE_FRAME_CONTEXT_IGNORE: DWORD = 0xFFFFFFFF; +STRUCT!{struct STACKFRAME_EX { + AddrPC: ADDRESS64, + AddrReturn: ADDRESS64, + AddrFrame: ADDRESS64, + AddrStack: ADDRESS64, + AddrBStore: ADDRESS64, + FuncTableEntry: PVOID, + Params: [DWORD64; 4], + Far: BOOL, + Virtual: BOOL, + Reserved: [DWORD64; 3], + KdHelp: KDHELP64, + StackFrameSize: DWORD, + InlineFrameContext: DWORD, +}} +pub type LPSTACKFRAME_EX = *mut STACKFRAME_EX; +#[cfg(target_pointer_width = "64")] +pub type STACKFRAME = STACKFRAME64; +#[cfg(target_pointer_width = "64")] +pub type LPSTACKFRAME = LPSTACKFRAME64; +#[cfg(target_pointer_width = "32")] +STRUCT!{struct STACKFRAME { + AddrPC: ADDRESS, + AddrReturn: ADDRESS, + AddrFrame: ADDRESS, + AddrStack: ADDRESS, + FuncTableEntry: PVOID, + Params: [DWORD; 4], + Far: BOOL, + Virtual: BOOL, + Reserved: [DWORD; 3], + KdHelp: KDHELP, + AddrBStore: ADDRESS, +}} +#[cfg(target_pointer_width = "32")] +pub type LPSTACKFRAME = *mut STACKFRAME; +FN!{stdcall PREAD_PROCESS_MEMORY_ROUTINE64( + hProcess: HANDLE, + qwBaseAddress: DWORD64, + lpBuffer: PVOID, + nSize: DWORD, + lpNumberOfBytesRead: LPDWORD, +) -> BOOL} +FN!{stdcall PFUNCTION_TABLE_ACCESS_ROUTINE64( + ahProcess: HANDLE, + AddrBase: DWORD64, +) -> PVOID} +FN!{stdcall PGET_MODULE_BASE_ROUTINE64( + hProcess: HANDLE, + Address: DWORD64, +) -> DWORD64} +FN!{stdcall PTRANSLATE_ADDRESS_ROUTINE64( + hProcess: HANDLE, + hThread: HANDLE, + lpaddr: LPADDRESS64, +) -> DWORD64} +pub const SYM_STKWALK_DEFAULT: DWORD = 0x00000000; +pub const SYM_STKWALK_FORCE_FRAMEPTR: DWORD = 0x00000001; +#[cfg(target_pointer_width = "64")] +pub type PREAD_PROCESS_MEMORY_ROUTINE = PREAD_PROCESS_MEMORY_ROUTINE64; +#[cfg(target_pointer_width = "64")] +pub type PFUNCTION_TABLE_ACCESS_ROUTINE = PFUNCTION_TABLE_ACCESS_ROUTINE64; +#[cfg(target_pointer_width = "64")] +pub type PGET_MODULE_BASE_ROUTINE = PGET_MODULE_BASE_ROUTINE64; +#[cfg(target_pointer_width = "64")] +pub type PTRANSLATE_ADDRESS_ROUTINE = PTRANSLATE_ADDRESS_ROUTINE64; +#[cfg(target_pointer_width = "32")] +FN!{stdcall PREAD_PROCESS_MEMORY_ROUTINE( + hProcess: HANDLE, + qwBaseAddress: DWORD, + lpBuffer: PVOID, + nSize: DWORD, + lpNumberOfBytesRead: PDWORD, +) -> BOOL} +#[cfg(target_pointer_width = "32")] +FN!{stdcall PFUNCTION_TABLE_ACCESS_ROUTINE( + ahProcess: HANDLE, + AddrBase: DWORD, +) -> PVOID} +#[cfg(target_pointer_width = "32")] +FN!{stdcall PGET_MODULE_BASE_ROUTINE( + hProcess: HANDLE, + Address: DWORD, +) -> DWORD} +#[cfg(target_pointer_width = "32")] +FN!{stdcall PTRANSLATE_ADDRESS_ROUTINE( + hProcess: HANDLE, + hThread: HANDLE, + lpaddr: LPADDRESS, +) -> DWORD} +pub const API_VERSION_NUMBER: USHORT = 12; +STRUCT!{struct API_VERSION { + MajorVersion: USHORT, + MinorVersion: USHORT, + Revision: USHORT, + Reserved: USHORT, +}} +pub type LPAPI_VERSION = *mut API_VERSION; +STRUCT!{struct SYMBOL_INFOW { + SizeOfStruct: ULONG, + TypeIndex: ULONG, + Reserved: [ULONG64; 2], + Index: ULONG, + Size: ULONG, + ModBase: ULONG64, + Flags: ULONG, + Value: ULONG64, + Address: ULONG64, + Register: ULONG, + Scope: ULONG, + Tag: ULONG, + NameLen: ULONG, + MaxNameLen: ULONG, + Name: [WCHAR; 1], +}} +pub type PSYMBOL_INFOW = *mut SYMBOL_INFOW; +STRUCT!{struct IMAGEHLP_SYMBOL64 { + SizeOfStruct: DWORD, + Address: DWORD64, + Size: DWORD, + Flags: DWORD, + MaxNameLength: DWORD, + Name: [CHAR; 1], +}} +pub type PIMAGEHLP_SYMBOL64 = *mut IMAGEHLP_SYMBOL64; +STRUCT!{struct IMAGEHLP_LINEW64 { + SizeOfStruct: DWORD, + Key: PVOID, + LineNumber: DWORD, + FileName: PWSTR, + Address: DWORD64, +}} +pub type PIMAGEHLP_LINEW64 = *mut IMAGEHLP_LINEW64; +extern "system" { + pub fn EnumDirTree( + hProcess: HANDLE, + RootPath: PCSTR, + InputPathName: PCSTR, + OutputPathBuffer: PSTR, + cb: PENUMDIRTREE_CALLBACK, + data: PVOID, + ) -> BOOL; + pub fn EnumDirTreeW( + hProcess: HANDLE, + RootPath: PCWSTR, + InputPathName: PCWSTR, + OutputPathBuffer: PWSTR, + cb: PENUMDIRTREE_CALLBACKW, + data: PVOID, + ) -> BOOL; + pub fn ImagehlpApiVersion() -> LPAPI_VERSION; + pub fn ImagehlpApiVersionEx( + AppVersion: LPAPI_VERSION, + ) -> LPAPI_VERSION; + pub fn MakeSureDirectoryPathExists( + DirPath: PCSTR, + ) -> BOOL; + pub fn SearchTreeForFile( + RootPath: PCSTR, + InputPathName: PCSTR, + OutputPathBuffer: PSTR, + ) -> BOOL; + pub fn SearchTreeForFileW( + RootPath: PCWSTR, + InputPathName: PCWSTR, + OutputPathBuffer: PWSTR, + ) -> BOOL; + pub fn FindDebugInfoFile( + FileName: PCSTR, + SymbolPath: PCSTR, + DebugFilePath: PSTR, + ) -> HANDLE; + pub fn FindDebugInfoFileEx( + FileName: PCSTR, + SymbolPath: PCSTR, + DebugFilePath: PSTR, + Callback: PFIND_DEBUG_FILE_CALLBACK, + CallerData: PVOID, + ) -> HANDLE; + pub fn FindDebugInfoFileExW( + FileName: PCWSTR, + SymbolPath: PCWSTR, + DebugFilePath: PWSTR, + Callback: PFIND_DEBUG_FILE_CALLBACKW, + CallerData: PVOID, + ) -> HANDLE; + pub fn FindExecutableImage( + FileName: PCSTR, + SymbolPath: PCSTR, + ImageFilePath: PSTR, + ) -> HANDLE; + pub fn FindExecutableImageEx( + FileName: PCSTR, + SymbolPath: PCSTR, + ImageFilePath: PSTR, + Callback: PFIND_EXE_FILE_CALLBACK, + CallerData: PVOID, + ) -> HANDLE; + pub fn FindExecutableImageExW( + FileName: PCWSTR, + SymbolPath: PCWSTR, + ImageFilePath: PWSTR, + Callback: PFIND_EXE_FILE_CALLBACKW, + CallerData: PVOID, + ) -> HANDLE; + pub fn StackWalk( + MachineType: DWORD, + hProcess: HANDLE, + hThread: HANDLE, + StackFrame: LPSTACKFRAME, + ContextRecord: PVOID, + ReadMemoryRoutine: PREAD_PROCESS_MEMORY_ROUTINE, + FunctionTableAccessRoutine: PFUNCTION_TABLE_ACCESS_ROUTINE, + GetModuleBaseRoutine: PGET_MODULE_BASE_ROUTINE, + TranslateAddress: PTRANSLATE_ADDRESS_ROUTINE, + ) -> BOOL; + pub fn StackWalkEx( + MachineType: DWORD, + hProcess: HANDLE, + hThread: HANDLE, + StackFrame: LPSTACKFRAME_EX, + ContextRecord: PVOID, + ReadMemoryRoutine: PREAD_PROCESS_MEMORY_ROUTINE64, + FunctionTableAccessRoutine: PFUNCTION_TABLE_ACCESS_ROUTINE64, + GetModuleBaseRoutine: PGET_MODULE_BASE_ROUTINE64, + TranslateAddress: PTRANSLATE_ADDRESS_ROUTINE64, + Flags: DWORD, + ) -> BOOL; + pub fn StackWalk64( + MachineType: DWORD, + hProcess: HANDLE, + hThread: HANDLE, + StackFrame: LPSTACKFRAME64, + ContextRecord: PVOID, + ReadMemoryRoutine: PREAD_PROCESS_MEMORY_ROUTINE64, + FunctionTableAccessRoutine: PFUNCTION_TABLE_ACCESS_ROUTINE64, + GetModuleBaseRoutine: PGET_MODULE_BASE_ROUTINE64, + TranslateAddress: PTRANSLATE_ADDRESS_ROUTINE64, + ) -> BOOL; + pub fn UnDecorateSymbolName( + name: PCSTR, + outputString: PSTR, + maxStringLength: DWORD, + flags: DWORD, + ) -> DWORD; + pub fn UnDecorateSymbolNameW( + name: PCWSTR, + outputString: PWSTR, + maxStringLength: DWORD, + flags: DWORD, + ) -> DWORD; + pub fn GetTimestampForLoadedLibrary( + Module: HMODULE, + ) -> DWORD; + pub fn ImageDirectoryEntryToData( + Base: PVOID, + MappedAsImage: BOOLEAN, + DirectoryEntry: USHORT, + Size: PULONG, + ) -> PVOID; + pub fn ImageDirectoryEntryToDataEx( + Base: PVOID, + MappedAsImage: BOOLEAN, + DirectoryEntry: USHORT, + Size: PULONG, + FoundHeader: *mut PIMAGE_SECTION_HEADER, + ) -> PVOID; + pub fn ImageNtHeader( + Base: PVOID, + ) -> PIMAGE_NT_HEADERS; + pub fn ImageRvaToSection( + NtHeaders: PIMAGE_NT_HEADERS, + Base: PVOID, + Rva: ULONG, + ) -> PIMAGE_SECTION_HEADER; + pub fn ImageRvaToVa( + NtHeaders: PIMAGE_NT_HEADERS, + Base: PVOID, + Rva: ULONG, + LastRvaSection: *mut PIMAGE_SECTION_HEADER, + ) -> PVOID; + pub fn SymCleanup( + hProcess: HANDLE, + ) -> BOOL; + pub fn SymEnumSymbolsW( + hProcess: HANDLE, + BaseOfDll: ULONG64, + Mask: PCWSTR, + EnumSymbolsCallback: PSYM_ENUMERATESYMBOLS_CALLBACKW, + CallerData: PVOID, + ) -> BOOL; + pub fn SymFindDebugInfoFile( + hProcess: HANDLE, + FileName: PCSTR, + DebugFilePath: PSTR, + Callback: PFIND_DEBUG_FILE_CALLBACK, + CallerData: PVOID, + ) -> HANDLE; + pub fn SymFindDebugInfoFileW( + hProcess: HANDLE, + FileName: PCWSTR, + DebugFilePath: PWSTR, + Callback: PFIND_DEBUG_FILE_CALLBACKW, + CallerData: PVOID, + ) -> HANDLE; + pub fn SymFindExecutableImage( + hProcess: HANDLE, + FileName: PCSTR, + ImageFilePath: PSTR, + Callback: PFIND_EXE_FILE_CALLBACK, + CallerData: PVOID, + ) -> HANDLE; + pub fn SymFindExecutableImageW( + hProcess: HANDLE, + FileName: PCWSTR, + ImageFilePath: PWSTR, + Callback: PFIND_EXE_FILE_CALLBACKW, + CallerData: PVOID, + ) -> HANDLE; + pub fn SymFindFileInPath( + hprocess: HANDLE, + SearchPath: PCSTR, + FileName: PCSTR, + id: PVOID, + two: DWORD, + three: DWORD, + flags: DWORD, + FoundFile: PSTR, + callback: PFINDFILEINPATHCALLBACK, + context: PVOID, + ) -> BOOL; + pub fn SymFindFileInPathW( + hprocess: HANDLE, + SearchPath: PCWSTR, + FileName: PCWSTR, + id: PVOID, + two: DWORD, + three: DWORD, + flags: DWORD, + FoundFile: PWSTR, + callback: PFINDFILEINPATHCALLBACKW, + context: PVOID, + ) -> BOOL; + pub fn SymFromAddrW( + hProcess: HANDLE, + Address: DWORD64, + Displacement: PDWORD64, + Symbol: PSYMBOL_INFOW, + ) -> BOOL; + pub fn SymFromNameW( + hProcess: HANDLE, + Name: PCWSTR, + Symbol: PSYMBOL_INFOW, + ) -> BOOL; + pub fn SymFunctionTableAccess64( + hProcess: HANDLE, + AddrBase: DWORD64, + ) -> PVOID; + pub fn SymGetLineFromAddrW64( + hProcess: HANDLE, + dwAddr: DWORD64, + pdwDisplacement: PDWORD, + Line: PIMAGEHLP_LINEW64, + ) -> BOOL; + pub fn SymGetModuleBase64( + hProcess: HANDLE, + AddrBase: DWORD64, + ) -> DWORD64; + pub fn SymGetSymFromAddr64( + hProcess: HANDLE, + Address: DWORD64, + Displacement: PDWORD64, + Symbol: PIMAGEHLP_SYMBOL64, + ) -> BOOL; + pub fn SymInitializeW( + hProcess: HANDLE, + UserSearchPath: PCWSTR, + fInvadeProcess: BOOL, + ) -> BOOL; + pub fn SymLoadModuleExW( + hProcess: HANDLE, + hFile: HANDLE, + ImageName: PCWSTR, + ModuleName: PCWSTR, + BaseOfDll: DWORD64, + SizeOfDll: DWORD, + Data: PMODLOAD_DATA, + Flags: DWORD, + ) -> DWORD64; + pub fn SymUnloadModule( + hProcess: HANDLE, + BaseOfDll: DWORD, + ) -> BOOL; + pub fn SymUnloadModule64( + hProcess: HANDLE, + BaseOfDll: DWORD64, + ) -> BOOL; + #[cfg(target_pointer_width = "32")] + pub fn MapDebugInformation( + FileHandle: HANDLE, + FileName: PCSTR, + SymbolPath: PCSTR, + ImageBase: ULONG, + ) -> PIMAGE_DEBUG_INFORMATION; + #[cfg(target_pointer_width = "32")] + pub fn UnmapDebugInformation( + DebugInfo: PIMAGE_DEBUG_INFORMATION, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dbt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dbt.rs new file mode 100644 index 0000000..e95a58c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dbt.rs @@ -0,0 +1,192 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_char, wchar_t}; +use shared::basetsd::{ULONG32, ULONG64}; +use shared::guiddef::GUID; +use shared::minwindef::{BYTE, DWORD, UINT, WORD, WPARAM}; +use um::winnt::{HANDLE, LONG}; +use um::winuser::HDEVNOTIFY; +pub const WM_DEVICECHANGE: UINT = 0x0219; +pub const BSF_QUERY: DWORD = 0x00000001; +pub const BSF_IGNORECURRENTTASK: DWORD = 0x00000002; +pub const BSF_FLUSHDISK: DWORD = 0x00000004; +pub const BSF_NOHANG: DWORD = 0x00000008; +pub const BSF_POSTMESSAGE: DWORD = 0x00000010; +pub const BSF_FORCEIFHUNG: DWORD = 0x00000020; +pub const BSF_NOTIMEOUTIFNOTHUNG: DWORD = 0x00000040; +pub const BSF_MSGSRV32ISOK: DWORD = 0x80000000; +pub const BSF_MSGSRV32ISOK_BIT: usize = 31; +pub const BSM_ALLCOMPONENTS: DWORD = 0x00000000; +pub const BSM_VXDS: DWORD = 0x00000001; +pub const BSM_NETDRIVER: DWORD = 0x00000002; +pub const BSM_INSTALLABLEDRIVERS: DWORD = 0x00000004; +pub const BSM_APPLICATIONS: DWORD = 0x00000008; +pub const DBT_APPYBEGIN: WPARAM = 0x0000; +pub const DBT_APPYEND: WPARAM = 0x0001; +pub const DBT_DEVNODES_CHANGED: WPARAM = 0x0007; +pub const DBT_QUERYCHANGECONFIG: WPARAM = 0x0017; +pub const DBT_CONFIGCHANGED: WPARAM = 0x0018; +pub const DBT_CONFIGCHANGECANCELED: WPARAM = 0x0019; +pub const DBT_MONITORCHANGE: WPARAM = 0x001B; +pub const DBT_SHELLLOGGEDON: WPARAM = 0x0020; +pub const DBT_CONFIGMGAPI32: WPARAM = 0x0022; +pub const DBT_VXDINITCOMPLETE: WPARAM = 0x0023; +pub const DBT_VOLLOCKQUERYLOCK: WPARAM = 0x8041; +pub const DBT_VOLLOCKLOCKTAKEN: WPARAM = 0x8042; +pub const DBT_VOLLOCKLOCKFAILED: WPARAM = 0x8043; +pub const DBT_VOLLOCKQUERYUNLOCK: WPARAM = 0x8044; +pub const DBT_VOLLOCKLOCKRELEASED: WPARAM = 0x8045; +pub const DBT_VOLLOCKUNLOCKFAILED: WPARAM = 0x8046; +STRUCT!{struct DEV_BROADCAST_HDR { + dbch_size: DWORD, + dbch_devicetype: DWORD, + dbch_reserved: DWORD, +}} +pub type PDEV_BROADCAST_HDR = *mut DEV_BROADCAST_HDR; +STRUCT!{struct VolLockBroadcast { + vlb_dbh: DEV_BROADCAST_HDR, + vlb_owner: DWORD, + vlb_perms: BYTE, + vlb_lockType: BYTE, + vlb_drive: BYTE, + vlb_flags: BYTE, +}} +pub type pVolLockBroadcast = *mut VolLockBroadcast; +pub const LOCKP_ALLOW_WRITES: BYTE = 0x01; +pub const LOCKP_FAIL_WRITES: BYTE = 0x00; +pub const LOCKP_FAIL_MEM_MAPPING: BYTE = 0x02; +pub const LOCKP_ALLOW_MEM_MAPPING: BYTE = 0x00; +pub const LOCKP_USER_MASK: BYTE = 0x03; +pub const LOCKP_LOCK_FOR_FORMAT: BYTE = 0x04; +pub const LOCKF_LOGICAL_LOCK: BYTE = 0x00; +pub const LOCKF_PHYSICAL_LOCK: BYTE = 0x01; +pub const DBT_NO_DISK_SPACE: WPARAM = 0x0047; +pub const DBT_LOW_DISK_SPACE: WPARAM = 0x0048; +pub const DBT_CONFIGMGPRIVATE: WPARAM = 0x7FFF; +pub const DBT_DEVICEARRIVAL: WPARAM = 0x8000; +pub const DBT_DEVICEQUERYREMOVE: WPARAM = 0x8001; +pub const DBT_DEVICEQUERYREMOVEFAILED: WPARAM = 0x8002; +pub const DBT_DEVICEREMOVEPENDING: WPARAM = 0x8003; +pub const DBT_DEVICEREMOVECOMPLETE: WPARAM = 0x8004; +pub const DBT_DEVICETYPESPECIFIC: WPARAM = 0x8005; +pub const DBT_CUSTOMEVENT: WPARAM = 0x8006; +pub const DBT_DEVTYP_OEM: DWORD = 0x00000000; +pub const DBT_DEVTYP_DEVNODE: DWORD = 0x00000001; +pub const DBT_DEVTYP_VOLUME: DWORD = 0x00000002; +pub const DBT_DEVTYP_PORT: DWORD = 0x00000003; +pub const DBT_DEVTYP_NET: DWORD = 0x00000004; +pub const DBT_DEVTYP_DEVICEINTERFACE: DWORD = 0x00000005; +pub const DBT_DEVTYP_HANDLE: DWORD = 0x00000006; +STRUCT!{struct _DEV_BROADCAST_HEADER { + dbcd_size: DWORD, + dbcd_devicetype: DWORD, + dbcd_reserved: DWORD, +}} +STRUCT!{struct DEV_BROADCAST_OEM { + dbco_size: DWORD, + dbco_devicetype: DWORD, + dbco_reserved: DWORD, + dbco_identifier: DWORD, + dbco_suppfunc: DWORD, +}} +pub type PDEV_BROADCAST_OEM = *mut DEV_BROADCAST_OEM; +STRUCT!{struct DEV_BROADCAST_DEVNODE { + dbcd_size: DWORD, + dbcd_devicetype: DWORD, + dbcd_reserved: DWORD, + dbcd_devnode: DWORD, +}} +pub type PDEV_BROADCAST_DEVNODE = *mut DEV_BROADCAST_DEVNODE; +STRUCT!{struct DEV_BROADCAST_VOLUME { + dbcv_size: DWORD, + dbcv_devicetype: DWORD, + dbcv_reserved: DWORD, + dbcv_unitmask: DWORD, + dbcv_flags: WORD, +}} +pub type PDEV_BROADCAST_VOLUME = *mut DEV_BROADCAST_VOLUME; +pub const DBTF_MEDIA: WORD = 0x0001; +pub const DBTF_NET: WORD = 0x0002; +STRUCT!{struct DEV_BROADCAST_PORT_A { + dbcp_size: DWORD, + dbcp_devicetype: DWORD, + dbcp_reserved: DWORD, + dbcp_name: [c_char; 1], +}} +pub type PDEV_BROADCAST_PORT_A = *mut DEV_BROADCAST_PORT_A; +STRUCT!{struct DEV_BROADCAST_PORT_W { + dbcp_size: DWORD, + dbcp_devicetype: DWORD, + dbcp_reserved: DWORD, + dbcp_name: [wchar_t; 1], +}} +pub type PDEV_BROADCAST_PORT_W = *mut DEV_BROADCAST_PORT_W; +STRUCT!{struct DEV_BROADCAST_NET { + dbcn_size: DWORD, + dbcn_devicetype: DWORD, + dbcn_reserved: DWORD, + dbcn_resource: DWORD, + dbcn_flags: DWORD, +}} +pub type PDEV_BROADCAST_NET = *mut DEV_BROADCAST_NET; +STRUCT!{struct DEV_BROADCAST_DEVICEINTERFACE_A { + dbcc_size: DWORD, + dbcc_devicetype: DWORD, + dbcc_reserved: DWORD, + dbcc_classguid: GUID, + dbcc_name: [c_char; 1], +}} +pub type PDEV_BROADCAST_DEVICEINTERFACE_A = *mut DEV_BROADCAST_DEVICEINTERFACE_A; +STRUCT!{struct DEV_BROADCAST_DEVICEINTERFACE_W { + dbcc_size: DWORD, + dbcc_devicetype: DWORD, + dbcc_reserved: DWORD, + dbcc_classguid: GUID, + dbcc_name: [wchar_t; 1], +}} +pub type PDEV_BROADCAST_DEVICEINTERFACE_W = *mut DEV_BROADCAST_DEVICEINTERFACE_W; +STRUCT!{struct DEV_BROADCAST_HANDLE { + dbch_size: DWORD, + dbch_devicetype: DWORD, + dbch_reserved: DWORD, + dbch_handle: HANDLE, + dbch_hdevnotify: HDEVNOTIFY, + dbch_eventguid: GUID, + dbch_nameoffset: LONG, + dbch_data: [BYTE; 1], +}} +pub type PDEV_BROADCAST_HANDLE = *mut DEV_BROADCAST_HANDLE; +STRUCT!{struct DEV_BROADCAST_HANDLE32 { + dbch_size: DWORD, + dbch_devicetype: DWORD, + dbch_reserved: DWORD, + dbch_handle: ULONG32, + dbch_hdevnotify: ULONG32, + dbch_eventguid: GUID, + dbch_nameoffset: LONG, + dbch_data: [BYTE; 1], +}} +pub type PDEV_BROADCAST_HANDLE32 = *mut DEV_BROADCAST_HANDLE32; +STRUCT!{struct DEV_BROADCAST_HANDLE64 { + dbch_size: DWORD, + dbch_devicetype: DWORD, + dbch_reserved: DWORD, + dbch_handle: ULONG64, + dbch_hdevnotify: ULONG64, + dbch_eventguid: GUID, + dbch_nameoffset: LONG, + dbch_data: [BYTE; 1], +}} +pub type PDEV_BROADCAST_HANDLE64 = *mut DEV_BROADCAST_HANDLE64; +pub const DBTF_RESOURCE: DWORD = 0x00000001; +pub const DBTF_XPORT: DWORD = 0x00000002; +pub const DBTF_SLOWNET: DWORD = 0x00000004; +pub const DBT_VPOWERDAPI: WPARAM = 0x8100; +pub const DBT_USERDEFINED: WPARAM = 0xFFFF; +STRUCT!{struct _DEV_BROADCAST_USERDEFINED { + dbud_dbh: DEV_BROADCAST_HDR, + dbud_szName: [c_char; 1], +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dcommon.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dcommon.rs new file mode 100644 index 0000000..e0260cb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dcommon.rs @@ -0,0 +1,114 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dcommon.h +use ctypes::c_void; +use shared::basetsd::UINT32; +use shared::dxgiformat::DXGI_FORMAT; +use shared::minwindef::FLOAT; +use shared::windef::{POINT, RECT}; +ENUM!{enum DWRITE_MEASURING_MODE { + DWRITE_MEASURING_MODE_NATURAL = 0, + DWRITE_MEASURING_MODE_GDI_CLASSIC = 1, + DWRITE_MEASURING_MODE_GDI_NATURAL = 2, +}} +ENUM!{enum DWRITE_GLYPH_IMAGE_FORMATS { + DWRITE_GLYPH_IMAGE_FORMATS_NONE = 0x00000000, + DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE = 0x00000001, + DWRITE_GLYPH_IMAGE_FORMATS_CFF = 0x00000002, + DWRITE_GLYPH_IMAGE_FORMATS_COLR = 0x00000004, + DWRITE_GLYPH_IMAGE_FORMATS_SVG = 0x00000008, + DWRITE_GLYPH_IMAGE_FORMATS_PNG = 0x00000010, + DWRITE_GLYPH_IMAGE_FORMATS_JPEG = 0x00000020, + DWRITE_GLYPH_IMAGE_FORMATS_TIFF = 0x00000040, + DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8 = 0x00000080, +}} +STRUCT!{struct DWRITE_GLYPH_IMAGE_DATA { + imageData: *const c_void, + imageDataSize: UINT32, + uniqueDataId: UINT32, + pixelsPerEm: UINT32, + pixelSize: D2D1_SIZE_U, + horizontalLeftOrigin: D2D1_POINT_2L, + horizontalRightOrigin: D2D1_POINT_2L, + verticalTopOrigin: D2D1_POINT_2L, + verticalBottomOrigin: D2D1_POINT_2L, +}} +ENUM!{enum D2D1_ALPHA_MODE { + D2D1_ALPHA_MODE_UNKNOWN = 0, + D2D1_ALPHA_MODE_PREMULTIPLIED = 1, + D2D1_ALPHA_MODE_STRAIGHT = 2, + D2D1_ALPHA_MODE_IGNORE = 3, +}} +STRUCT!{struct D2D1_PIXEL_FORMAT { + format: DXGI_FORMAT, + alphaMode: D2D1_ALPHA_MODE, +}} +STRUCT!{struct D2D_POINT_2U { + x: UINT32, + y: UINT32, +}} +STRUCT!{struct D2D_POINT_2F { + x: FLOAT, + y: FLOAT, +}} +pub type D2D_POINT_2L = POINT; +STRUCT!{struct D2D_VECTOR_2F { + x: FLOAT, + y: FLOAT, +}} +STRUCT!{struct D2D_VECTOR_3F { + x: FLOAT, + y: FLOAT, + z: FLOAT, +}} +STRUCT!{struct D2D_VECTOR_4F { + x: FLOAT, + y: FLOAT, + z: FLOAT, + w: FLOAT, +}} +STRUCT!{struct D2D_RECT_F { + left: FLOAT, + top: FLOAT, + right: FLOAT, + bottom: FLOAT, +}} +STRUCT!{struct D2D_RECT_U { + left: UINT32, + top: UINT32, + right: UINT32, + bottom: UINT32, +}} +pub type D2D_RECT_L = RECT; +STRUCT!{struct D2D_SIZE_F { + width: FLOAT, + height: FLOAT, +}} +STRUCT!{struct D2D_SIZE_U { + width: UINT32, + height: UINT32, +}} +STRUCT!{struct D2D_MATRIX_3X2_F { + matrix: [[FLOAT; 2]; 3], +}} +STRUCT!{struct D2D_MATRIX_4X3_F { + matrix: [[FLOAT; 3]; 4], +}} +STRUCT!{struct D2D_MATRIX_4X4_F { + matrix: [[FLOAT; 4]; 4], +}} +STRUCT!{struct D2D_MATRIX_5X4_F { + matrix: [[FLOAT; 4]; 5], +}} +pub type D2D1_POINT_2F = D2D_POINT_2F; +pub type D2D1_POINT_2U = D2D_POINT_2U; +pub type D2D1_POINT_2L = D2D_POINT_2L; +pub type D2D1_RECT_F = D2D_RECT_F; +pub type D2D1_RECT_U = D2D_RECT_U; +pub type D2D1_RECT_L = D2D_RECT_L; +pub type D2D1_SIZE_F = D2D_SIZE_F; +pub type D2D1_SIZE_U = D2D_SIZE_U; +pub type D2D1_MATRIX_3X2_F = D2D_MATRIX_3X2_F; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dcomp.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dcomp.rs new file mode 100644 index 0000000..1704865 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dcomp.rs @@ -0,0 +1,1159 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dcomp.h +use ctypes::{c_float, c_int, c_void}; +use shared::d3d9types::D3DMATRIX; +use shared::dcomptypes::{ + DCOMPOSITION_BACKFACE_VISIBILITY, DCOMPOSITION_BITMAP_INTERPOLATION_MODE, + DCOMPOSITION_BORDER_MODE, DCOMPOSITION_COMPOSITE_MODE, DCOMPOSITION_DEPTH_MODE, + DCOMPOSITION_FRAME_STATISTICS, DCOMPOSITION_OPACITY_MODE +}; +use shared::dxgi::IDXGIDevice; +use shared::dxgi1_2::DXGI_ALPHA_MODE; +use shared::dxgiformat::DXGI_FORMAT; +use shared::guiddef::REFIID; +use shared::minwindef::{BOOL, DWORD, UINT}; +use shared::ntdef::{HANDLE, HRESULT}; +use shared::windef::{HWND, POINT, RECT}; +use um::d2d1::{D2D1_COLOR_F, D2D1_MATRIX_3X2_F}; +use um::d2d1_1::{D2D1_COMPOSITE_MODE, D2D1_MATRIX_5X4_F, D2D1_VECTOR_2F, D2D1_VECTOR_4F}; +use um::d2d1effects::{ + D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE, D2D1_BLEND_MODE, D2D1_BORDER_MODE, + D2D1_COLORMATRIX_ALPHA_MODE, D2D1_TURBULENCE_NOISE +}; +use um::d2dbasetypes::{D2D_MATRIX_3X2_F, D2D_MATRIX_4X4_F, D2D_RECT_F}; +use um::d3dcommon::D3D_FEATURE_LEVEL; +use um::dcompanimation::IDCompositionAnimation; +use um::minwinbase::SECURITY_ATTRIBUTES; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +extern "system" { + pub fn DCompositionCreateDevice( + dxgiDevice: *const IDXGIDevice, + iid: REFIID, + dcompositionDevice: *mut *mut c_void, + ) -> HRESULT; + pub fn DCompositionCreateDevice2( + renderingDevice: *const IUnknown, + iid: REFIID, + dcompositionDevice: *mut *mut c_void, + ) -> HRESULT; + pub fn DCompositionCreateDevice3( + renderingDevice: *const IUnknown, + iid: REFIID, + dcompositionDevice: *mut *mut c_void, + ) -> HRESULT; + pub fn DCompositionGetFrameStatistics( + statistics: *const DCOMPOSITION_FRAME_STATISTICS, + minSafeFeaturelLevel: *const D3D_FEATURE_LEVEL, + maxHardwareFeaturelLevel: *const D3D_FEATURE_LEVEL, + ) -> HRESULT; + pub fn DCompositionCreateSurfaceHandle( + desiredAccess: DWORD, + securityAttributes: *const SECURITY_ATTRIBUTES, + surfaceHandle: *mut HANDLE, + ) -> HRESULT; + pub fn DCompositionAttachMouseWheelToHwnd( + visual: *const IDCompositionVisual, + hwnd: HWND, + enable: BOOL, + ) -> HRESULT; + pub fn DCompositionAttachMouseDragToHwnd( + visual: *const IDCompositionVisual, + hwnd: HWND, + enable: BOOL, + ) -> HRESULT; +} +RIDL!{#[uuid(0xc37ea93a, 0xe7aa, 0x450d, 0xb1, 0x6f, 0x97, 0x46, 0xcb, 0x04, 0x07, 0xf3)] +interface IDCompositionDevice(IDCompositionDeviceVtbl): IUnknown(IUnknownVtbl) { + fn Commit() -> HRESULT, + fn WaitForCommitCompletion() -> HRESULT, + fn GetFrameStatistics( + statistics: *mut DCOMPOSITION_FRAME_STATISTICS, + ) -> HRESULT, + fn CreateTargetForHwnd( + hwnd: HWND, + topmost: BOOL, + target: *mut *mut IDCompositionTarget, + ) -> HRESULT, + fn CreateVisual( + visual: *mut *mut IDCompositionVisual, + ) -> HRESULT, + fn CreateSurface( + width: UINT, + height: UINT, + pixelFormat: DXGI_FORMAT, + alphaMode: DXGI_ALPHA_MODE, + surface: *mut *mut IDCompositionSurface, + ) -> HRESULT, + fn CreateVirtualSurface( + initialWidth: UINT, + initialHeight: UINT, + pixelFormat: DXGI_FORMAT, + alphaMode: DXGI_ALPHA_MODE, + virtualSurface: *mut *mut IDCompositionVirtualSurface, + ) -> HRESULT, + fn CreateSurfaceFromHandle( + handle: HANDLE, + mutsurface: *mut *mut IUnknown, + ) -> HRESULT, + fn CreateSurfaceFromHwnd( + hwnd: HWND, + mutsurface: *mut *mut IUnknown, + ) -> HRESULT, + fn CreateTranslateTransform( + translateTransform: *mut *mut IDCompositionTranslateTransform, + ) -> HRESULT, + fn CreateScaleTransform( + scaleTransform: *mut *mut IDCompositionScaleTransform, + ) -> HRESULT, + fn CreateRotateTransform( + rotateTransform: *mut *mut IDCompositionRotateTransform, + ) -> HRESULT, + fn CreateSkewTransform( + skewTransform: *mut *mut IDCompositionSkewTransform, + ) -> HRESULT, + fn CreateMatrixTransform( + matrixTransform: *mut *mut IDCompositionMatrixTransform, + ) -> HRESULT, + fn CreateTransformGroup( + transforms: *const *const IDCompositionTransform, + elements: UINT, + transformGroup: *mut *mut IDCompositionTransform, + ) -> HRESULT, + fn CreateTranslateTransform3D( + translateTransform3D: *mut *mut IDCompositionTranslateTransform3D, + ) -> HRESULT, + fn CreateScaleTransform3D( + scaleTransform3D: *mut *mut IDCompositionScaleTransform3D, + ) -> HRESULT, + fn CreateRotateTransform3D( + rotateTransform3D: *mut *mut IDCompositionRotateTransform3D, + ) -> HRESULT, + fn CreateMatrixTransform3D( + matrixTransform3D: *mut *mut IDCompositionMatrixTransform3D, + ) -> HRESULT, + fn CreateTransform3DGroup( + transforms3D: *const *const IDCompositionTransform3D, + elements: UINT, + transform3DGroup: *mut *mut IDCompositionTransform3D, + ) -> HRESULT, + fn CreateEffectGroup( + effectGroup: *mut *mut IDCompositionEffectGroup, + ) -> HRESULT, + fn CreateRectangleClip( + clip: *mut *mut IDCompositionRectangleClip, + ) -> HRESULT, + fn CreateAnimation( + animation: *mut *mut IDCompositionAnimation, + ) -> HRESULT, + fn CheckDeviceState( + pfValid: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xeacdd04c, 0x117e, 0x4e17, 0x88, 0xf4, 0xd1, 0xb1, 0x2b, 0x0e, 0x3d, 0x89)] +interface IDCompositionTarget(IDCompositionTargetVtbl): IUnknown(IUnknownVtbl) { + fn SetRoot( + visual: *const IDCompositionVisual, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4d93059d, 0x097b, 0x4651, 0x9a, 0x60, 0xf0, 0xf2, 0x51, 0x16, 0xe2, 0xf3)] +interface IDCompositionVisual(IDCompositionVisualVtbl): IUnknown(IUnknownVtbl) { + fn SetOffsetX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetOffsetX_1( + offsetX: c_float, + ) -> HRESULT, + fn SetOffsetY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetOffsetY_1( + offsetY: c_float, + ) -> HRESULT, + fn SetTransform_2( + transform: *const IDCompositionTransform, + ) -> HRESULT, + fn SetTransform_1( + matrix: *const D2D_MATRIX_3X2_F, + ) -> HRESULT, + fn SetTransformParent( + visual: *const IDCompositionVisual, + ) -> HRESULT, + fn SetEffect( + effect: *const IDCompositionEffect, + ) -> HRESULT, + fn SetBitmapInterpolationMode( + interpolationMode: DCOMPOSITION_BITMAP_INTERPOLATION_MODE, + ) -> HRESULT, + fn SetBorderMode( + borderMode: DCOMPOSITION_BORDER_MODE, + ) -> HRESULT, + fn SetClip_2( + clip: *const IDCompositionClip, + ) -> HRESULT, + fn SetClip_1( + rect: *const D2D_RECT_F, + ) -> HRESULT, + fn SetContent( + content: *const IUnknown, + ) -> HRESULT, + fn AddVisual( + visual: *const IDCompositionVisual, + insertAbove: BOOL, + referenceVisual: *const IDCompositionVisual, + ) -> HRESULT, + fn RemoveVisual( + visual: *const IDCompositionVisual, + ) -> HRESULT, + fn RemoveAllVisuals() -> HRESULT, + fn SetCompositeMode( + compositeMode: DCOMPOSITION_COMPOSITE_MODE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xec81b08f, 0xbfcb, 0x4e8d, 0xb1, 0x93, 0xa9, 0x15, 0x58, 0x79, 0x99, 0xe8)] +interface IDCompositionEffect(IDCompositionEffectVtbl): IUnknown(IUnknownVtbl) {}} +RIDL!{#[uuid(0x71185722, 0x246b, 0x41f2, 0xaa, 0xd1, 0x04, 0x43, 0xf7, 0xf4, 0xbf, 0xc2)] +interface IDCompositionTransform3D(IDCompositionTransform3DVtbl): + IDCompositionEffect(IDCompositionEffectVtbl) {}} +RIDL!{#[uuid(0xfd55faa7, 0x37e0, 0x4c20, 0x95, 0xd2, 0x9b, 0xe4, 0x5b, 0xc3, 0x3f, 0x55)] +interface IDCompositionTransform(IDCompositionTransformVtbl): + IDCompositionTransform3D(IDCompositionTransform3DVtbl) {}} +RIDL!{#[uuid(0x06791122, 0xc6f0, 0x417d, 0x83, 0x23, 0x26, 0x9e, 0x98, 0x7f, 0x59, 0x54)] +interface IDCompositionTranslateTransform(IDCompositionTranslateTransformVtbl): + IDCompositionTransform(IDCompositionTransformVtbl) { + fn SetOffsetX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetOffsetX_1( + offsetX: c_float, + ) -> HRESULT, + fn SetOffsetY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetOffsetY_1( + offsetY: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x71fde914, 0x40ef, 0x45ef, 0xbd, 0x51, 0x68, 0xb0, 0x37, 0xc3, 0x39, 0xf9)] +interface IDCompositionScaleTransform(IDCompositionScaleTransformVtbl): + IDCompositionTransform(IDCompositionTransformVtbl) { + fn SetScaleX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetScaleX_1( + scaleX: c_float, + ) -> HRESULT, + fn SetScaleY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetScaleY_1( + scaleY: c_float, + ) -> HRESULT, + fn SetCenterX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterX_1( + centerX: c_float, + ) -> HRESULT, + fn SetCenterY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterY_1( + centerY: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x641ed83c, 0xae96, 0x46c5, 0x90, 0xdc, 0x32, 0x77, 0x4c, 0xc5, 0xc6, 0xd5)] +interface IDCompositionRotateTransform(IDCompositionRotateTransformVtbl): + IDCompositionTransform(IDCompositionTransformVtbl) { + fn SetAngle_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAngle_1( + angle: c_float, + ) -> HRESULT, + fn SetCenterX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterX_1( + centerX: c_float, + ) -> HRESULT, + fn SetCenterY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterY_1( + centerY: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xe57aa735, 0xdcdb, 0x4c72, 0x9c, 0x61, 0x05, 0x91, 0xf5, 0x88, 0x89, 0xee)] +interface IDCompositionSkewTransform(IDCompositionSkewTransformVtbl): + IDCompositionTransform(IDCompositionTransformVtbl) { + fn SetAngleX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAngleX_1( + angleX: c_float, + ) -> HRESULT, + fn SetAngleY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAngleY_1( + angleY: c_float, + ) -> HRESULT, + fn SetCenterX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterX_1( + centerX: c_float, + ) -> HRESULT, + fn SetCenterY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterY_1( + centerY: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x16cdff07, 0xc503, 0x419c, 0x83, 0xf2, 0x09, 0x65, 0xc7, 0xaf, 0x1f, 0xa6)] +interface IDCompositionMatrixTransform(IDCompositionMatrixTransformVtbl): + IDCompositionTransform(IDCompositionTransformVtbl) { + fn SetMatrix( + matrix: *const D2D_MATRIX_3X2_F, + ) -> HRESULT, + fn SetMatrixElement_2( + row: c_int, + column: c_int, + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetMatrixElement_1( + row: c_int, + column: c_int, + value: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa7929a74, 0xe6b2, 0x4bd6, 0x8b, 0x95, 0x40, 0x40, 0x11, 0x9c, 0xa3, 0x4d)] +interface IDCompositionEffectGroup(IDCompositionEffectGroupVtbl): + IDCompositionEffect(IDCompositionEffectVtbl) { + fn SetOpacity_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetOpacity_1( + opacity: c_float, + ) -> HRESULT, + fn SetTransform3D( + transform3D: *const IDCompositionTransform3D, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x91636d4b, 0x9ba1, 0x4532, 0xaa, 0xf7, 0xe3, 0x34, 0x49, 0x94, 0xd7, 0x88)] +interface IDCompositionTranslateTransform3D(IDCompositionTranslateTransform3DVtbl): + IDCompositionTransform3D(IDCompositionTransform3DVtbl) { + fn SetOffsetX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetOffsetX_1( + offsetX: c_float, + ) -> HRESULT, + fn SetOffsetY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetOffsetY_1( + offsetY: c_float, + ) -> HRESULT, + fn SetOffsetZ_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetOffsetZ_1( + offsetZ: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2a9e9ead, 0x364b, 0x4b15, 0xa7, 0xc4, 0xa1, 0x99, 0x7f, 0x78, 0xb3, 0x89)] +interface IDCompositionScaleTransform3D(IDCompositionScaleTransform3DVtbl): + IDCompositionTransform3D(IDCompositionTransform3DVtbl) { + fn SetScaleX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetScaleX_1( + scaleX: c_float, + ) -> HRESULT, + fn SetScaleY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetScaleY_1( + scaleY: c_float, + ) -> HRESULT, + fn SetScaleZ_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetScaleZ_1( + scaleZ: c_float, + ) -> HRESULT, + fn SetCenterX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterX_1( + centerX: c_float, + ) -> HRESULT, + fn SetCenterY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterY_1( + centerY: c_float, + ) -> HRESULT, + fn SetCenterZ_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterZ_1( + centerZ: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd8f5b23f, 0xd429, 0x4a91, 0xb5, 0x5a, 0xd2, 0xf4, 0x5f, 0xd7, 0x5b, 0x18)] +interface IDCompositionRotateTransform3D(IDCompositionRotateTransform3DVtbl): + IDCompositionTransform3D(IDCompositionTransform3DVtbl) { + fn SetAngle_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAngle_1( + angle: c_float, + ) -> HRESULT, + fn SetAxisX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAxisX_1( + axisX: c_float, + ) -> HRESULT, + fn SetAxisY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAxisY_1( + axisY: c_float, + ) -> HRESULT, + fn SetAxisZ_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAxisZ_1( + axisZ: c_float, + ) -> HRESULT, + fn SetCenterX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterX_1( + centerX: c_float, + ) -> HRESULT, + fn SetCenterY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterY_1( + centerY: c_float, + ) -> HRESULT, + fn SetCenterZ_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCenterZ_1( + centerZ: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4b3363f0, 0x643b, 0x41b7, 0xb6, 0xe0, 0xcc, 0xf2, 0x2d, 0x34, 0x46, 0x7c)] +interface IDCompositionMatrixTransform3D(IDCompositionMatrixTransform3DVtbl): + IDCompositionTransform3D(IDCompositionTransform3DVtbl) { + fn SetMatrix( + matrix: *const D3DMATRIX, + ) -> HRESULT, + fn SetMatrixElement_2( + row: c_int, + column: c_int, + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetMatrixElement_1( + row: c_int, + column: c_int, + value: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x64ac3703, 0x9d3f, 0x45ec, 0xa1, 0x09, 0x7c, 0xac, 0x0e, 0x7a, 0x13, 0xa7)] +interface IDCompositionClip(IDCompositionClipVtbl): IUnknown(IUnknownVtbl) {}} +RIDL!{#[uuid(0x9842ad7d, 0xd9cf, 0x4908, 0xae, 0xd7, 0x48, 0xb5, 0x1d, 0xa5, 0xe7, 0xc2)] +interface IDCompositionRectangleClip(IDCompositionRectangleClipVtbl): + IDCompositionClip(IDCompositionClipVtbl) { + fn SetLeft_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetLeft_1( + left: c_float, + ) -> HRESULT, + fn SetTop_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetTop_1( + top: c_float, + ) -> HRESULT, + fn SetRight_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetRight_1( + right: c_float, + ) -> HRESULT, + fn SetBottom_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBottom_1( + bottom: c_float, + ) -> HRESULT, + fn SetTopLeftRadiusX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetTopLeftRadiusX_1( + radius: c_float, + ) -> HRESULT, + fn SetTopLeftRadiusY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetTopLeftRadiusY_1( + radius: c_float, + ) -> HRESULT, + fn SetTopRightRadiusX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetTopRightRadiusX_1( + radius: c_float, + ) -> HRESULT, + fn SetTopRightRadiusY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetTopRightRadiusY_1( + radius: c_float, + ) -> HRESULT, + fn SetBottomLeftRadiusX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBottomLeftRadiusX_1( + radius: c_float, + ) -> HRESULT, + fn SetBottomLeftRadiusY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBottomLeftRadiusY_1( + radius: c_float, + ) -> HRESULT, + fn SetBottomRightRadiusX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBottomRightRadiusX_1( + radius: c_float, + ) -> HRESULT, + fn SetBottomRightRadiusY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBottomRightRadiusY_1( + radius: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xbb8a4953, 0x2c99, 0x4f5a, 0x96, 0xf5, 0x48, 0x19, 0x02, 0x7f, 0xa3, 0xac)] +interface IDCompositionSurface(IDCompositionSurfaceVtbl): IUnknown(IUnknownVtbl) { + fn BeginDraw( + updateRect: *const RECT, + iid: REFIID, + updateObject: *mut *mut c_void, + updateOffset: *mut POINT, + ) -> HRESULT, + fn EndDraw() -> HRESULT, + fn SuspendDraw() -> HRESULT, + fn ResumeDraw() -> HRESULT, + fn Scroll( + scrollRect: *const RECT, + clipRect: *const RECT, + offsetX: c_int, + offsetY: c_int, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xae471c51, 0x5f53, 0x4a24, 0x8d, 0x3e, 0xd0, 0xc3, 0x9c, 0x30, 0xb3, 0xf0)] +interface IDCompositionVirtualSurface(IDCompositionVirtualSurfaceVtbl): + IDCompositionSurface(IDCompositionSurfaceVtbl) { + fn Resize( + width: UINT, + height: UINT, + ) -> HRESULT, + fn Trim( + rectangles: *const RECT, + count: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x75f6468d, 0x1b8e, 0x447c, 0x9b, 0xc6, 0x75, 0xfe, 0xa8, 0x0b, 0x5b, 0x25)] +interface IDCompositionDevice2(IDCompositionDevice2Vtbl): IUnknown(IUnknownVtbl) { + fn Commit() -> HRESULT, + fn WaitForCommitCompletion() -> HRESULT, + fn GetFrameStatistics( + statistics: *mut DCOMPOSITION_FRAME_STATISTICS, + ) -> HRESULT, + fn CreateVisual( + visual: *mut *mut IDCompositionVisual2, + ) -> HRESULT, + fn CreateSurfaceFactory( + renderingDevice: *const IUnknown, + surfaceFactory: *mut *mut IDCompositionSurfaceFactory, + ) -> HRESULT, + fn CreateSurface( + width: UINT, + height: UINT, + pixelFormat: DXGI_FORMAT, + alphaMode: DXGI_ALPHA_MODE, + surface: *mut *mut IDCompositionSurface, + ) -> HRESULT, + fn CreateVirtualSurface( + initialWidth: UINT, + initialHeight: UINT, + pixelFormat: DXGI_FORMAT, + alphaMode: DXGI_ALPHA_MODE, + virtualSurface: *mut *mut IDCompositionVirtualSurface, + ) -> HRESULT, + fn CreateTranslateTransform( + translateTransform: *mut *mut IDCompositionTranslateTransform, + ) -> HRESULT, + fn CreateScaleTransform( + scaleTransform: *mut *mut IDCompositionScaleTransform, + ) -> HRESULT, + fn CreateRotateTransform( + rotateTransform: *mut *mut IDCompositionRotateTransform, + ) -> HRESULT, + fn CreateSkewTransform( + skewTransform: *mut *mut IDCompositionSkewTransform, + ) -> HRESULT, + fn CreateMatrixTransform( + matrixTransform: *mut *mut IDCompositionMatrixTransform, + ) -> HRESULT, + fn CreateTransformGroup( + transforms: *const *const IDCompositionTransform, + elements: UINT, + transformGroup: *mut *mut IDCompositionTransform, + ) -> HRESULT, + fn CreateTranslateTransform3D( + translateTransform3D: *mut *mut IDCompositionTranslateTransform3D, + ) -> HRESULT, + fn CreateScaleTransform3D( + scaleTransform3D: *mut *mut IDCompositionScaleTransform3D, + ) -> HRESULT, + fn CreateRotateTransform3D( + rotateTransform3D: *mut *mut IDCompositionRotateTransform3D, + ) -> HRESULT, + fn CreateMatrixTransform3D( + matrixTransform3D: *mut *mut IDCompositionMatrixTransform3D, + ) -> HRESULT, + fn CreateTransform3DGroup( + transforms3D: *const *const IDCompositionTransform3D, + elements: UINT, + transform3DGroup: *mut *mut IDCompositionTransform3D, + ) -> HRESULT, + fn CreateEffectGroup( + effectGroup: *mut *mut IDCompositionEffectGroup, + ) -> HRESULT, + fn CreateRectangleClip( + clip: *mut *mut IDCompositionRectangleClip, + ) -> HRESULT, + fn CreateAnimation( + animation: *mut *mut IDCompositionAnimation, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5f4633fe, 0x1e08, 0x4cb8, 0x8c, 0x75, 0xce, 0x24, 0x33, 0x3f, 0x56, 0x02)] +interface IDCompositionDesktopDevice(IDCompositionDesktopDeviceVtbl): + IDCompositionDevice2(IDCompositionDevice2Vtbl) { + fn CreateTargetForHwnd( + hwnd: HWND, + topmost: BOOL, + target: *mut *mut IDCompositionTarget, + ) -> HRESULT, + fn CreateSurfaceFromHandle( + handle: HANDLE, + surface: *mut *mut IUnknown, + ) -> HRESULT, + fn CreateSurfaceFromHwnd( + hwnd: HWND, + surface: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa1a3c64a, 0x224f, 0x4a81, 0x97, 0x73, 0x4f, 0x03, 0xa8, 0x9d, 0x3c, 0x6c)] +interface IDCompositionDeviceDebug(IDCompositionDeviceDebugVtbl): IUnknown(IUnknownVtbl) { + fn EnableDebugCounters() -> HRESULT, + fn DisableDebugCounters() -> HRESULT, +}} +RIDL!{#[uuid(0xe334bc12, 0x3937, 0x4e02, 0x85, 0xeb, 0xfc, 0xf4, 0xeb, 0x30, 0xd2, 0xc8)] +interface IDCompositionSurfaceFactory(IDCompositionSurfaceFactoryVtbl): IUnknown(IUnknownVtbl) { + fn CreateSurface( + width: UINT, + height: UINT, + pixelFormat: DXGI_FORMAT, + alphaMode: DXGI_ALPHA_MODE, + surface: *mut *mut IDCompositionSurface, + ) -> HRESULT, + fn CreateVirtualSurface( + initialWidth: UINT, + initialHeight: UINT, + pixelFormat: DXGI_FORMAT, + alphaMode: DXGI_ALPHA_MODE, + virtualSurface: *mut *mut IDCompositionVirtualSurface, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xe8de1639, 0x4331, 0x4b26, 0xbc, 0x5f, 0x6a, 0x32, 0x1d, 0x34, 0x7a, 0x85)] +interface IDCompositionVisual2(IDCompositionVisual2Vtbl): + IDCompositionVisual(IDCompositionVisualVtbl) { + fn SetOpacityMode( + mode: DCOMPOSITION_OPACITY_MODE, + ) -> HRESULT, + fn SetBackFaceVisibility( + visibility: DCOMPOSITION_BACKFACE_VISIBILITY, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xfed2b808, 0x5eb4, 0x43a0, 0xae, 0xa3, 0x35, 0xf6, 0x52, 0x80, 0xf9, 0x1b)] +interface IDCompositionVisualDebug(IDCompositionVisualDebugVtbl): + IDCompositionVisual2(IDCompositionVisual2Vtbl) { + fn EnableHeatMap( + color: *const D2D1_COLOR_F, + ) -> HRESULT, + fn DisableHeatMap() -> HRESULT, + fn EnableRedrawRegions() -> HRESULT, + fn DisableRedrawRegions() -> HRESULT, +}} +RIDL!{#[uuid(0x2775f462, 0xb6c1, 0x4015, 0xb0, 0xbe, 0xb3, 0xe7, 0xd6, 0xa4, 0x97, 0x6d)] +interface IDCompositionVisual3(IDCompositionVisual3Vtbl): + IDCompositionVisualDebug(IDCompositionVisualDebugVtbl) { + fn SetDepthMode( + mode: DCOMPOSITION_DEPTH_MODE, + ) -> HRESULT, + fn SetOffsetZ_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetOffsetZ_1( + offsetZ: c_float, + ) -> HRESULT, + fn SetOpacity_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetOpacity_1( + opacity: c_float, + ) -> HRESULT, + fn SetTransform_2( + transform: *const IDCompositionTransform3D, + ) -> HRESULT, + fn SetTransform_1( + matrix: *const D2D_MATRIX_4X4_F, + ) -> HRESULT, + fn SetVisible( + visible: BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0987cb06, 0xf916, 0x48bf, 0x8d, 0x35, 0xce, 0x76, 0x41, 0x78, 0x1b, 0xd9)] +interface IDCompositionDevice3(IDCompositionDevice3Vtbl): + IDCompositionDevice2(IDCompositionDevice2Vtbl) { + fn CreateGaussianBlurEffect( + gaussianBlurEffect: *mut *mut IDCompositionGaussianBlurEffect, + ) -> HRESULT, + fn CreateBrightnessEffect( + brightnessEffect: *mut *mut IDCompositionBrightnessEffect, + ) -> HRESULT, + fn CreateColorMatrixEffect( + colorMatrixEffect: *mut *mut IDCompositionColorMatrixEffect, + ) -> HRESULT, + fn CreateShadowEffect( + shadowEffect: *mut *mut IDCompositionShadowEffect, + ) -> HRESULT, + fn CreateHueRotationEffect( + hueRotationEffect: *mut *mut IDCompositionHueRotationEffect, + ) -> HRESULT, + fn CreateSaturationEffect( + saturationEffect: *mut *mut IDCompositionSaturationEffect, + ) -> HRESULT, + fn CreateTurbulenceEffect( + turbulenceEffect: *mut *mut IDCompositionTurbulenceEffect, + ) -> HRESULT, + fn CreateLinearTransferEffect( + linearTransferEffect: *mut *mut IDCompositionLinearTransferEffect, + ) -> HRESULT, + fn CreateTableTransferEffect( + tableTransferEffect: *mut *mut IDCompositionTableTransferEffect, + ) -> HRESULT, + fn CreateCompositeEffect( + compositeEffect: *mut *mut IDCompositionCompositeEffect, + ) -> HRESULT, + fn CreateBlendEffect( + blendEffect: *mut *mut IDCompositionBlendEffect, + ) -> HRESULT, + fn CreateArithmeticCompositeEffect( + arithmeticCompositeEffect: *mut *mut IDCompositionArithmeticCompositeEffect, + ) -> HRESULT, + fn CreateAffineTransform2DEffect( + affineTransform2dEffect: *mut *mut IDCompositionAffineTransform2DEffect, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x30c421d5, 0x8cb2, 0x4e9f, 0xb1, 0x33, 0x37, 0xbe, 0x27, 0x0d, 0x4a, 0xc2)] +interface IDCompositionFilterEffect(IDCompositionFilterEffectVtbl): + IDCompositionEffect(IDCompositionEffectVtbl) { + fn SetInput( + index: UINT, + input: *const IUnknown, + flags: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x45d4d0b7, 0x1bd4, 0x454e, 0x88, 0x94, 0x2b, 0xfa, 0x68, 0x44, 0x30, 0x33)] +interface IDCompositionGaussianBlurEffect(IDCompositionGaussianBlurEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetStandardDeviation_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetStandardDeviation_1( + amount: c_float, + ) -> HRESULT, + fn SetBorderMode( + mode: D2D1_BORDER_MODE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6027496e, 0xcb3a, 0x49ab, 0x93, 0x4f, 0xd7, 0x98, 0xda, 0x4f, 0x7d, 0xa6)] +interface IDCompositionBrightnessEffect(IDCompositionBrightnessEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetWhitePoint( + whitePoint: *const D2D1_VECTOR_2F, + ) -> HRESULT, + fn SetBlackPoint( + blackPoint: *const D2D1_VECTOR_2F, + ) -> HRESULT, + fn SetWhitePointX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetWhitePointX_1( + whitePointX: c_float, + ) -> HRESULT, + fn SetWhitePointY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetWhitePointY_1( + whitePointY: c_float, + ) -> HRESULT, + fn SetBlackPointX_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBlackPointX_1( + blackPointX: c_float, + ) -> HRESULT, + fn SetBlackPointY_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBlackPointY_1( + blackPointY: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc1170a22, 0x3ce2, 0x4966, 0x90, 0xd4, 0x55, 0x40, 0x8b, 0xfc, 0x84, 0xc4)] +interface IDCompositionColorMatrixEffect(IDCompositionColorMatrixEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetMatrix( + matrix: *const D2D1_MATRIX_5X4_F, + ) -> HRESULT, + fn SetMatrixElement_2( + row: c_int, + column: c_int, + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetMatrixElement_1( + row: c_int, + column: c_int, + value: c_float, + ) -> HRESULT, + fn SetAlphaMode( + mode: D2D1_COLORMATRIX_ALPHA_MODE, + ) -> HRESULT, + fn SetClampOutput( + clamp: BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4ad18ac0, 0xcfd2, 0x4c2f, 0xbb, 0x62, 0x96, 0xe5, 0x4f, 0xdb, 0x68, 0x79)] +interface IDCompositionShadowEffect(IDCompositionShadowEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetStandardDeviation_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetStandardDeviation_1( + amount: c_float, + ) -> HRESULT, + fn SetColor( + color: *const D2D1_VECTOR_4F, + ) -> HRESULT, + fn SetRed_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetRed_1( + amount: c_float, + ) -> HRESULT, + fn SetGreen_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetGreen_1( + amount: c_float, + ) -> HRESULT, + fn SetBlue_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBlue_1( + amount: c_float, + ) -> HRESULT, + fn SetAlpha_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAlpha_1( + amount: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6db9f920, 0x0770, 0x4781, 0xb0, 0xc6, 0x38, 0x19, 0x12, 0xf9, 0xd1, 0x67)] +interface IDCompositionHueRotationEffect(IDCompositionHueRotationEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + // Changes the angle of rotation + fn SetAngle_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAngle_1( + amountDegrees: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa08debda, 0x3258, 0x4fa4, 0x9f, 0x16, 0x91, 0x74, 0xd3, 0xfe, 0x93, 0xb1)] +interface IDCompositionSaturationEffect(IDCompositionSaturationEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + // Changes the amount of saturation to be applied. + fn SetSaturation_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetSaturation_1( + ratio: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa6a55bda, 0xc09c, 0x49f3, 0x91, 0x93, 0xa4, 0x19, 0x22, 0xc8, 0x97, 0x15)] +interface IDCompositionTurbulenceEffect(IDCompositionTurbulenceEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetOffset( + offset: *const D2D1_VECTOR_2F, + ) -> HRESULT, + fn SetBaseFrequency( + frequency: *const D2D1_VECTOR_2F, + ) -> HRESULT, + fn SetSize( + size: *const D2D1_VECTOR_2F, + ) -> HRESULT, + fn SetNumOctaves( + numOctaves: UINT, + ) -> HRESULT, + fn SetSeed( + seed: UINT, + ) -> HRESULT, + fn SetNoise( + noise: D2D1_TURBULENCE_NOISE, + ) -> HRESULT, + fn SetStitchable( + stitchable: BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4305ee5b, 0xc4a0, 0x4c88, 0x93, 0x85, 0x67, 0x12, 0x4e, 0x01, 0x76, 0x83)] +interface IDCompositionLinearTransferEffect(IDCompositionLinearTransferEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetRedYIntercept_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetRedYIntercept_1( + redYIntercept: c_float, + ) -> HRESULT, + fn SetRedSlope_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetRedSlope_1( + redSlope: c_float, + ) -> HRESULT, + fn SetRedDisable( + redDisable: BOOL, + ) -> HRESULT, + fn SetGreenYIntercept_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetGreenYIntercept_1( + greenYIntercept: c_float, + ) -> HRESULT, + fn SetGreenSlope_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetGreenSlope_1( + greenSlope: c_float, + ) -> HRESULT, + fn SetGreenDisable( + greenDisable: BOOL, + ) -> HRESULT, + fn SetBlueYIntercept_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBlueYIntercept_1( + blueYIntercept: c_float, + ) -> HRESULT, + fn SetBlueSlope_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBlueSlope_1( + blueSlope: c_float, + ) -> HRESULT, + fn SetBlueDisable( + blueDisable: BOOL, + ) -> HRESULT, + fn SetAlphaYIntercept_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAlphaYIntercept_1( + alphaYIntercept: c_float, + ) -> HRESULT, + fn SetAlphaSlope_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAlphaSlope_1( + alphaSlope: c_float, + ) -> HRESULT, + fn SetAlphaDisable( + alphaDisable: BOOL, + ) -> HRESULT, + fn SetClampOutput( + clampOutput: BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9b7e82e2, 0x69c5, 0x4eb4, 0xa5, 0xf5, 0xa7, 0x03, 0x3f, 0x51, 0x32, 0xcd)] +interface IDCompositionTableTransferEffect(IDCompositionTableTransferEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetRedTable( + tableValues: *const c_float, + count: UINT, + ) -> HRESULT, + fn SetGreenTable( + tableValues: *const c_float, + count: UINT, + ) -> HRESULT, + fn SetBlueTable( + tableValues: *const c_float, + count: UINT, + ) -> HRESULT, + fn SetAlphaTable( + tableValues: *const c_float, + count: UINT, + ) -> HRESULT, + fn SetRedDisable( + redDisable: BOOL, + ) -> HRESULT, + fn SetGreenDisable( + greenDisable: BOOL, + ) -> HRESULT, + fn SetBlueDisable( + blueDisable: BOOL, + ) -> HRESULT, + fn SetAlphaDisable( + alphaDisable: BOOL, + ) -> HRESULT, + fn SetClampOutput( + clampOutput: BOOL, + ) -> HRESULT, + fn SetRedTableValue_2( + index: UINT, + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetRedTableValue_1( + index: UINT, + value: c_float, + ) -> HRESULT, + fn SetGreenTableValue_2( + index: UINT, + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetGreenTableValue_1( + index: UINT, + value: c_float, + ) -> HRESULT, + fn SetBlueTableValue_2( + index: UINT, + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetBlueTableValue_1( + index: UINT, + value: c_float, + ) -> HRESULT, + fn SetAlphaTableValue_2( + index: UINT, + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetAlphaTableValue_1( + index: UINT, + value: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x576616c0, 0xa231, 0x494d, 0xa3, 0x8d, 0x00, 0xfd, 0x5e, 0xc4, 0xdb, 0x46)] +interface IDCompositionCompositeEffect(IDCompositionCompositeEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetMode( + mode: D2D1_COMPOSITE_MODE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x33ecdc0a, 0x578a, 0x4a11, 0x9c, 0x14, 0x0c, 0xb9, 0x05, 0x17, 0xf9, 0xc5)] +interface IDCompositionBlendEffect(IDCompositionBlendEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetMode( + mode: D2D1_BLEND_MODE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3b67dfa8, 0xe3dd, 0x4e61, 0xb6, 0x40, 0x46, 0xc2, 0xf3, 0xd7, 0x39, 0xdc)] +interface IDCompositionArithmeticCompositeEffect(IDCompositionArithmeticCompositeEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetCoefficients( + coefficients: *const D2D1_VECTOR_4F, + ) -> HRESULT, + fn SetClampOutput( + clampoutput: BOOL, + ) -> HRESULT, + fn SetCoefficient1_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCoefficient1_1( + Coeffcient1: c_float, + ) -> HRESULT, + fn SetCoefficient2_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCoefficient2_1( + Coefficient2: c_float, + ) -> HRESULT, + fn SetCoefficient3_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCoefficient3_1( + Coefficient3: c_float, + ) -> HRESULT, + fn SetCoefficient4_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetCoefficient4_1( + Coefficient4: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0b74b9e8, 0xcdd6, 0x492f, 0xbb, 0xbc, 0x5e, 0xd3, 0x21, 0x57, 0x02, 0x6d)] +interface IDCompositionAffineTransform2DEffect(IDCompositionAffineTransform2DEffectVtbl): + IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { + fn SetInterpolationMode( + interpolationMode: D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE, + ) -> HRESULT, + fn SetBorderMode( + borderMode: D2D1_BORDER_MODE, + ) -> HRESULT, + fn SetTransformMatrix( + transformMatrix: *const D2D1_MATRIX_3X2_F, + ) -> HRESULT, + fn SetTransformMatrixElement_2( + row: c_int, + column: c_int, + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetTransformMatrixElement_1( + row: c_int, + column: c_int, + value: c_float, + ) -> HRESULT, + fn SetSharpness_2( + animation: *const IDCompositionAnimation, + ) -> HRESULT, + fn SetSharpness_1( + sharpness: c_float, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dcompanimation.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dcompanimation.rs new file mode 100644 index 0000000..ca54c40 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dcompanimation.rs @@ -0,0 +1,38 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of dcompanimation.h +use ctypes::{c_double, c_float}; +use shared::ntdef::{HRESULT, LARGE_INTEGER}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +RIDL!{#[uuid(0xcbfd91d9, 0x51b2, 0x45e4, 0xb3, 0xde, 0xd1, 0x9c, 0xcf, 0xb8, 0x63, 0xc5)] +interface IDCompositionAnimation(IDCompositionAnimationVtbl): IUnknown(IUnknownVtbl) { + fn Reset() -> HRESULT, + fn SetAbsoluteBeginTime( + beginTime: LARGE_INTEGER, + ) -> HRESULT, + fn AddCubic( + beginOffset: c_double, + constantCoefficient: c_float, + linearCoefficient: c_float, + quadraticCoefficient: c_float, + cubicCoefficient: c_float, + )-> HRESULT, + fn AddSinusoidal( + beginOffset: c_double, + bias: c_float, + amplitude: c_float, + frequency: c_float, + phase: c_float, + )-> HRESULT, + fn AddRepeat( + beginOffset: c_double, + durationToRepeat: c_double, + )-> HRESULT, + fn End( + endOffset: c_double, + endValue: c_float, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dde.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dde.rs new file mode 100644 index 0000000..b3ce4a9 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dde.rs @@ -0,0 +1,20 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{PUINT_PTR, UINT_PTR}; +use shared::minwindef::{BOOL, LPARAM, UINT}; +extern "system" { + pub fn PackDDElParam( + msg: UINT, + uiLo: UINT_PTR, + uiHi: UINT_PTR, + ) -> LPARAM; + pub fn UnpackDDElParam( + msg: UINT, + lParam: LPARAM, + puiLo: PUINT_PTR, + puiHi: PUINT_PTR, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ddraw.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ddraw.rs new file mode 100644 index 0000000..fd0d9e8 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ddraw.rs @@ -0,0 +1,37 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{CLSID_DirectDraw, + 0xd7b70ee0, 0x4340, 0x11cf, 0xb0, 0x63, 0x00, 0x20, 0xaf, 0xc2, 0xcd, 0x35} +DEFINE_GUID!{CLSID_DirectDraw7, + 0x3c305196, 0x50db, 0x11d3, 0x9c, 0xfe, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5} +DEFINE_GUID!{CLSID_DirectDrawClipper, + 0x593817a0, 0x7db3, 0x11cf, 0xa2, 0xde, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56} +DEFINE_GUID!{IID_IDirectDraw, + 0x6c14db80, 0xa733, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60} +DEFINE_GUID!{IID_IDirectDraw2, + 0xb3a6f3e0, 0x2b43, 0x11cf, 0xa2, 0xde, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56} +DEFINE_GUID!{IID_IDirectDraw4, + 0x9c59509a, 0x39bd, 0x11d1, 0x8c, 0x4a, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5} +DEFINE_GUID!{IID_IDirectDraw7, + 0x15e65ec0, 0x3b9c, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b} +DEFINE_GUID!{IID_IDirectDrawSurface, + 0x6c14db81, 0xa733, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60} +DEFINE_GUID!{IID_IDirectDrawSurface2, + 0x57805885, 0x6eec, 0x11cf, 0x94, 0x41, 0xa8, 0x23, 0x03, 0xc1, 0x0e, 0x27} +DEFINE_GUID!{IID_IDirectDrawSurface3, + 0xda044e00, 0x69b2, 0x11d0, 0xa1, 0xd5, 0x00, 0xaa, 0x00, 0xb8, 0xdf, 0xbb} +DEFINE_GUID!{IID_IDirectDrawSurface4, + 0x0b2b8630, 0xad35, 0x11d0, 0x8e, 0xa6, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b} +DEFINE_GUID!{IID_IDirectDrawSurface7, + 0x06675a80, 0x3b9b, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b} +DEFINE_GUID!{IID_IDirectDrawPalette, + 0x6c14db84, 0xa733, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60} +DEFINE_GUID!{IID_IDirectDrawClipper, + 0x6c14db85, 0xa733, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60} +DEFINE_GUID!{IID_IDirectDrawColorControl, + 0x4b9f0ee0, 0x0d7e, 0x11d0, 0x9b, 0x06, 0x00, 0xa0, 0xc9, 0x03, 0xa3, 0xb8} +DEFINE_GUID!{IID_IDirectDrawGammaControl, + 0x69c11c3e, 0xb46b, 0x11d1, 0xad, 0x7a, 0x00, 0xc0, 0x4f, 0xc2, 0x9b, 0x4e} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ddrawi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ddrawi.rs new file mode 100644 index 0000000..18e6518 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ddrawi.rs @@ -0,0 +1,13 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{GUID_OptSurfaceKmodeInfo, + 0xe05c8472, 0x51d4, 0x11d1, 0x8c, 0xce, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0xa8} +DEFINE_GUID!{GUID_OptSurfaceUmodeInfo, + 0x9d792804, 0x5fa8, 0x11d1, 0x8c, 0xd0, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0xa8} +DEFINE_GUID!{GUID_UserModeDriverInfo, + 0xf0b0e8e2, 0x5f97, 0x11d1, 0x8c, 0xd0, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0xa8} +DEFINE_GUID!{GUID_UserModeDriverPassword, + 0x97f861b6, 0x60a1, 0x11d1, 0x8c, 0xd0, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0xa8} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ddrawint.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ddrawint.rs new file mode 100644 index 0000000..2f9b743 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ddrawint.rs @@ -0,0 +1,41 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{GUID_MiscellaneousCallbacks, + 0xefd60cc0, 0x49e7, 0x11d0, 0x88, 0x9d, 0x00, 0xaa, 0x00, 0xbb, 0xb7, 0x6a} +DEFINE_GUID!{GUID_Miscellaneous2Callbacks, + 0x406b2f00, 0x3e5a, 0x11d1, 0xb6, 0x40, 0x00, 0xaa, 0x00, 0xa1, 0xf9, 0x6a} +DEFINE_GUID!{GUID_VideoPortCallbacks, + 0xefd60cc1, 0x49e7, 0x11d0, 0x88, 0x9d, 0x00, 0xaa, 0x00, 0xbb, 0xb7, 0x6a} +DEFINE_GUID!{GUID_ColorControlCallbacks, + 0xefd60cc2, 0x49e7, 0x11d0, 0x88, 0x9d, 0x00, 0xaa, 0x00, 0xbb, 0xb7, 0x6a} +DEFINE_GUID!{GUID_MotionCompCallbacks, + 0xb1122b40, 0x5da5, 0x11d1, 0x8f, 0xcf, 0x00, 0xc0, 0x4f, 0xc2, 0x9b, 0x4e} +DEFINE_GUID!{GUID_VideoPortCaps, + 0xefd60cc3, 0x49e7, 0x11d0, 0x88, 0x9d, 0x00, 0xaa, 0x00, 0xbb, 0xb7, 0x6a} +DEFINE_GUID!{GUID_D3DExtendedCaps, + 0x7de41f80, 0x9d93, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29} +DEFINE_GUID!{GUID_D3DCallbacks2, + 0x0ba584e1, 0x70b6, 0x11d0, 0x88, 0x9d, 0x00, 0xaa, 0x00, 0xbb, 0xb7, 0x6a} +DEFINE_GUID!{GUID_D3DCallbacks3, + 0xddf41230, 0xec0a, 0x11d0, 0xa9, 0xb6, 0x00, 0xaa, 0x00, 0xc0, 0x99, 0x3e} +DEFINE_GUID!{GUID_NonLocalVidMemCaps, + 0x86c4fa80, 0x8d84, 0x11d0, 0x94, 0xe8, 0x00, 0xc0, 0x4f, 0xc3, 0x41, 0x37} +DEFINE_GUID!{GUID_KernelCallbacks, + 0x80863800, 0x6b06, 0x11d0, 0x9b, 0x06, 0x00, 0xa0, 0xc9, 0x03, 0xa3, 0xb8} +DEFINE_GUID!{GUID_KernelCaps, + 0xffaa7540, 0x7aa8, 0x11d0, 0x9b, 0x06, 0x00, 0xa0, 0xc9, 0x03, 0xa3, 0xb8} +DEFINE_GUID!{GUID_ZPixelFormats, + 0x93869880, 0x36cf, 0x11d1, 0x9b, 0x1b, 0x00, 0xaa, 0x00, 0xbb, 0xb8, 0xae} +DEFINE_GUID!{GUID_DDMoreCaps, + 0x880baf30, 0xb030, 0x11d0, 0x8e, 0xa7, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b} +DEFINE_GUID!{GUID_D3DParseUnknownCommandCallback, + 0x2e04ffa0, 0x98e4, 0x11d1, 0x8c, 0xe1, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0xa8} +DEFINE_GUID!{GUID_NTCallbacks, + 0x6fe9ecde, 0xdf89, 0x11d1, 0x9d, 0xb0, 0x00, 0x60, 0x08, 0x27, 0x71, 0xba} +DEFINE_GUID!{GUID_DDMoreSurfaceCaps, + 0x3b8a0466, 0xf269, 0x11d1, 0x88, 0x0b, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5} +DEFINE_GUID!{GUID_DDStereoMode, + 0xf828169c, 0xa8e8, 0x11d2, 0xa1, 0xf2, 0x00, 0xa0, 0xc9, 0x83, 0xea, 0xf6} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/debugapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/debugapi.rs new file mode 100644 index 0000000..442b50d --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/debugapi.rs @@ -0,0 +1,41 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, DWORD, PBOOL}; +use um::minwinbase::LPDEBUG_EVENT; +use um::winnt::{HANDLE, LPCSTR, LPCWSTR}; +extern "system" { + pub fn IsDebuggerPresent() -> BOOL; + pub fn DebugBreak(); + pub fn OutputDebugStringA( + lpOutputString: LPCSTR, + ); + pub fn OutputDebugStringW( + lpOutputString: LPCWSTR, + ); + pub fn ContinueDebugEvent( + dwProcessId: DWORD, + dwThreadId: DWORD, + dwContinueStatus: DWORD, + ) -> BOOL; + pub fn WaitForDebugEvent( + lpDebugEvent: LPDEBUG_EVENT, + dwMilliseconds: DWORD, + ) -> BOOL; + pub fn DebugActiveProcess( + dwProcessId: DWORD, + ) -> BOOL; + pub fn DebugActiveProcessStop( + dwProcessId: DWORD, + ) -> BOOL; + pub fn CheckRemoteDebuggerPresent( + hProcess: HANDLE, + pbDebuggerPresent: PBOOL, + ) -> BOOL; + pub fn WaitForDebugEventEx( + lpDebugEvent: LPDEBUG_EVENT, + dwMilliseconds: DWORD, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/devicetopology.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/devicetopology.rs new file mode 100644 index 0000000..6f74ffb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/devicetopology.rs @@ -0,0 +1,462 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! The DeviceTopology API gives clients control over a variety of internal functions of audio +//! adapters that they cannot access through the MMDevice API, WASAPI, or the EndpointVolume API. +use ctypes::{c_float, c_void}; +use shared::guiddef::{GUID, LPCGUID, REFGUID, REFIID}; +use shared::minwindef::{BOOL, DWORD, UCHAR, UINT, ULONG, WORD}; +use shared::windef::COLORREF; +use shared::wtypes::VARTYPE; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LONG, LONGLONG, LPWSTR, WCHAR}; +DEFINE_GUID!{EVENTCONTEXT_VOLUMESLIDER, + 0xe2c2e9de, 0x09b1, 0x4b04, 0x84, 0xe5, 0x07, 0x93, 0x12, 0x25, 0xee, 0x04} +STRUCT!{struct KSDATAFORMAT { + FormatSize: ULONG, + Flags: ULONG, + SampleSize: ULONG, + Reserved: ULONG, + MajorFormat: GUID, + SubFormat: GUID, + Specifier: GUID, +}} +pub type PKSDATAFORMAT = *mut KSDATAFORMAT; +STRUCT!{struct KSIDENTIFIER_s { + Set: GUID, + Id: ULONG, + Flags: ULONG, +}} +UNION!{union KSIDENTIFIER { + [u64; 3], + s s_mut: KSIDENTIFIER_s, + Alignment Alignment_mut: LONGLONG, +}} +pub type KSPROPERTY = KSIDENTIFIER; +pub type PKSPROPERTY = *mut KSIDENTIFIER; +pub type KSMETHOD = KSIDENTIFIER; +pub type PKSMETHOD = *mut KSIDENTIFIER; +pub type KSEVENT = KSIDENTIFIER; +pub type PKSEVENT = *mut KSIDENTIFIER; +ENUM!{enum EPcxConnectionType { + eConnTypeUnknown = 0, + eConnType3Point5mm = 1, + eConnTypeQuarter = 2, + eConnTypeAtapiInternal = 3, + eConnTypeRCA = 4, + eConnTypeOptical = 5, + eConnTypeOtherDigital = 6, + eConnTypeOtherAnalog = 7, + eConnTypeMultichannelAnalogDIN = 8, + eConnTypeXlrProfessional = 9, + eConnTypeRJ11Modem = 10, + eConnTypeCombination = 11, +}} +ENUM!{enum EPcxGeoLocation { + eGeoLocRear = 1, + eGeoLocFront = 2, + eGeoLocLeft = 3, + eGeoLocRight = 4, + eGeoLocTop = 5, + eGeoLocBottom = 6, + eGeoLocRearPanel = 7, + eGeoLocRiser = 8, + eGeoLocInsideMobileLid = 9, + eGeoLocDrivebay = 10, + eGeoLocHDMI = 11, + eGeoLocOutsideMobileLid = 12, + eGeoLocATAPI = 13, + eGeoLocNotApplicable = 14, + eGeoLocReserved6 = 15, +}} +ENUM!{enum EPcxGenLocation { + eGenLocPrimaryBox = 0, + eGenLocInternal = 1, + eGenLocSeparate = 2, + eGenLocOther = 3, +}} +ENUM!{enum EPxcPortConnection { + ePortConnJack = 0, + ePortConnIntegratedDevice = 1, + ePortConnBothIntegratedAndJack = 2, + ePortConnUnknown = 3, +}} +STRUCT!{struct KSJACK_DESCRIPTION { + ChannelMapping: DWORD, + Color: COLORREF, + ConnectionType: EPcxConnectionType, + GeoLocation: EPcxGeoLocation, + GenLocation: EPcxGenLocation, + PortConnection: EPxcPortConnection, + IsConnected: BOOL, +}} +pub type PKSJACK_DESCRIPTION = *mut KSJACK_DESCRIPTION; +STRUCT!{struct LUID { + LowPart: DWORD, + HighPart: LONG, +}} +pub type PLUID = *mut LUID; +ENUM!{enum KSJACK_SINK_CONNECTIONTYPE { + KSJACK_SINK_CONNECTIONTYPE_HDMI = 0, + KSJACK_SINK_CONNECTIONTYPE_DISPLAYPORT = 1, +}} +STRUCT!{struct KSJACK_SINK_INFORMATION { + ConnType: KSJACK_SINK_CONNECTIONTYPE, + ManufacturerId: WORD, + ProductId: WORD, + AudioLatency: WORD, + HDCPCapable: BOOL, + AICapable: BOOL, + SinkDescriptionLength: UCHAR, + SinkDescription: [WCHAR; 32], + PortId: LUID, +}} +STRUCT!{struct KSJACK_DESCRIPTION2 { + DeviceStateInfo: DWORD, + JackCapabilities: DWORD, +}} +pub type PKSJACK_DESCRIPTION2 = *mut KSJACK_DESCRIPTION2; +ENUM!{enum DataFlow { + In = 0, + Out = 1, +}} +ENUM!{enum PartType { + Connector = 0, + Subunit = 1, +}} +ENUM!{enum ConnectorType { + Unknown_Connector = 0, + Physical_Internal = 1, + Physical_External = 2, + Software_IO = 3, + Software_Fixed = 4, + Network = 5, +}} +RIDL!{#[uuid(0x28f54685, 0x06fd, 0x11d2, 0xb2, 0x7a, 0x00, 0xa0, 0xc9, 0x22, 0x31, 0x96)] +interface IKsControl(IKsControlVtbl): IUnknown(IUnknownVtbl) { + fn KsProperty( + Property: PKSPROPERTY, + PropertyLength: ULONG, + PropertyData: *mut c_void, + DataLength: ULONG, + BytesReturned: *mut ULONG, + ) -> HRESULT, + fn KsMethod( + Method: PKSMETHOD, + MethodLength: ULONG, + MethodData: *mut c_void, + DataLength: ULONG, + BytesReturned: *mut ULONG, + ) -> HRESULT, + fn KsEvent( + Event: PKSEVENT, + EventLength: ULONG, + EventData: *mut c_void, + DataLength: ULONG, + BytesReturned: *mut ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc2f8e001, 0xf205, 0x4bc9, 0x99, 0xbc, 0xc1, 0x3b, 0x1e, 0x04, 0x8c, 0xcb)] +interface IPerChannelDbLevel(IPerChannelDbLevelVtbl): IUnknown(IUnknownVtbl) { + fn GetChannelCount( + pcChannels: *mut UINT, + ) -> HRESULT, + fn GetLevelRange( + nChannel: UINT, + pfMinLevelDB: *mut c_float, + pfMaxLevelDB: *mut c_float, + pfStepping: *mut c_float, + ) -> HRESULT, + fn GetLevel( + nChannel: UINT, + pfLevelDB: *mut c_float, + ) -> HRESULT, + fn SetLevel( + nChannel: UINT, + fLevelDB: c_float, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn SetLevelUniform( + fLevelDB: c_float, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn SetLevelAllChannels( + aLevelsDB: *mut c_float, + cChannels: ULONG, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7fb7b48f, 0x531d, 0x44a2, 0xbc, 0xb3, 0x5a, 0xd5, 0xa1, 0x34, 0xb3, 0xdc)] +interface IAudioVolumeLevel(IAudioVolumeLevelVtbl): IPerChannelDbLevel(IPerChannelDbLevelVtbl) {}} +RIDL!{#[uuid(0xbb11c46f, 0xec28, 0x493c, 0xb8, 0x8a, 0x5d, 0xb8, 0x80, 0x62, 0xce, 0x98)] +interface IAudioChannelConfig(IAudioChannelConfigVtbl): IUnknown(IUnknownVtbl) { + fn SetChannelConfig( + dwConfig: DWORD, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn GetChannelConfig( + pdwConfig: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7d8b1437, 0xdd53, 0x4350, 0x9c, 0x1b, 0x1e, 0xe2, 0x89, 0x0b, 0xd9, 0x38)] +interface IAudioLoudness(IAudioLoudnessVtbl): IUnknown(IUnknownVtbl) { + fn GetEnabled( + pbEnabled: *mut BOOL, + ) -> HRESULT, + fn SetEnabled( + bEnable: BOOL, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4f03dc02, 0x5e6e, 0x4653, 0x8f, 0x72, 0xa0, 0x30, 0xc1, 0x23, 0xd5, 0x98)] +interface IAudioInputSelector(IAudioInputSelectorVtbl): IUnknown(IUnknownVtbl) { + fn GetSelection( + pnIdSelected: *mut UINT, + ) -> HRESULT, + fn SetSelection( + nIdSelect: UINT, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xbb515f69, 0x94a7, 0x429e, 0x8b, 0x9c, 0x27, 0x1b, 0x3f, 0x11, 0xa3, 0xab)] +interface IAudioOutputSelector(IAudioOutputSelectorVtbl): IUnknown(IUnknownVtbl) { + fn GetSelection( + pnIdSelected: *mut UINT, + ) -> HRESULT, + fn SetSelection( + nIdSelect: UINT, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdf45aeea, 0xb74a, 0x4b6b, 0xaf, 0xad, 0x23, 0x66, 0xb6, 0xaa, 0x01, 0x2e)] +interface IAudioMute(IAudioMuteVtbl): IUnknown(IUnknownVtbl) { + fn SetMute( + bMuted: BOOL, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn GetMute( + pbMuted: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa2b1a1d9, 0x4db3, 0x425d, 0xa2, 0xb2, 0xbd, 0x33, 0x5c, 0xb3, 0xe2, 0xe5)] +interface IAudioBass(IAudioBassVtbl): IPerChannelDbLevel(IPerChannelDbLevelVtbl) {}} +RIDL!{#[uuid(0x5e54b6d7, 0xb44b, 0x40d9, 0x9a, 0x9e, 0xe6, 0x91, 0xd9, 0xce, 0x6e, 0xdf)] +interface IAudioMidrange(IAudioMidrangeVtbl): IPerChannelDbLevel(IPerChannelDbLevelVtbl) {}} +RIDL!{#[uuid(0x0a717812, 0x694e, 0x4907, 0xb7, 0x4b, 0xba, 0xfa, 0x5c, 0xfd, 0xca, 0x7b)] +interface IAudioTreble(IAudioTrebleVtbl): IPerChannelDbLevel(IPerChannelDbLevelVtbl) {}} +RIDL!{#[uuid(0x85401fd4, 0x6de4, 0x4b9d, 0x98, 0x69, 0x2d, 0x67, 0x53, 0xa8, 0x2f, 0x3c)] +interface IAudioAutoGainControl(IAudioAutoGainControlVtbl): IUnknown(IUnknownVtbl) { + fn GetEnabled( + pbEnabled: *mut BOOL, + ) -> HRESULT, + fn SetEnabled( + bEnable: BOOL, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdd79923c, 0x0599, 0x45e0, 0xb8, 0xb6, 0xc8, 0xdf, 0x7d, 0xb6, 0xe7, 0x96)] +interface IAudioPeakMeter(IAudioPeakMeterVtbl): IUnknown(IUnknownVtbl) { + fn GetChannelCount( + pcChannels: *mut UINT, + ) -> HRESULT, + fn GetLevel( + nChannel: UINT, + pfLevel: *mut c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3b22bcbf, 0x2586, 0x4af0, 0x85, 0x83, 0x20, 0x5d, 0x39, 0x1b, 0x80, 0x7c)] +interface IDeviceSpecificProperty(IDeviceSpecificPropertyVtbl): IUnknown(IUnknownVtbl) { + fn GetType( + pVType: *mut VARTYPE, + ) -> HRESULT, + fn GetValue( + pvValue: *mut c_void, + pcbValue: *mut DWORD, + ) -> HRESULT, + fn SetValue( + pvValue: *mut c_void, + cbValue: DWORD, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn Get4BRange( + plMin: *mut LONG, + plMax: *mut LONG, + plStepping: *mut LONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3cb4a69d, 0xbb6f, 0x4d2b, 0x95, 0xb7, 0x45, 0x2d, 0x2c, 0x15, 0x5d, 0xb5)] +interface IKsFormatSupport(IKsFormatSupportVtbl): IUnknown(IUnknownVtbl) { + fn IsFormatSupported( + pKsFormat: PKSDATAFORMAT, + cbFormat: DWORD, + pbSupported: *mut BOOL, + ) -> HRESULT, + fn GetDevicePreferredFormat( + ppKsFormat: *mut PKSDATAFORMAT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4509f757, 0x2d46, 0x4637, 0x8e, 0x62, 0xce, 0x7d, 0xb9, 0x44, 0xf5, 0x7b)] +interface IKsJackDescription(IKsJackDescriptionVtbl): IUnknown(IUnknownVtbl) { + fn GetJackCount( + pcJacks: *mut UINT, + ) -> HRESULT, + fn GetJackDescription( + nJack: UINT, + pDescription: *mut KSJACK_DESCRIPTION, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x478f3a9b, 0xe0c9, 0x4827, 0x92, 0x28, 0x6f, 0x55, 0x05, 0xff, 0xe7, 0x6a)] +interface IKsJackDescription2(IKsJackDescription2Vtbl): IUnknown(IUnknownVtbl) { + fn GetJackCount( + pcJacks: *mut UINT, + ) -> HRESULT, + fn GetJackDescription2( + nJack: UINT, + pDescription2: *mut KSJACK_DESCRIPTION2, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd9bd72ed, 0x290f, 0x4581, 0x9f, 0xf3, 0x61, 0x02, 0x7a, 0x8f, 0xe5, 0x32)] +interface IKsJackSinkInformation(IKsJackSinkInformationVtbl): IUnknown(IUnknownVtbl) { + fn GetJackSinkInformation( + pJackSinkInformation: *mut KSJACK_SINK_INFORMATION, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc99af463, 0xd629, 0x4ec4, 0x8c, 0x00, 0xe5, 0x4d, 0x68, 0x15, 0x42, 0x48)] +interface IKsJackContainerId(IKsJackContainerIdVtbl): IUnknown(IUnknownVtbl) { + fn GetJackContainerId( + pJackContainerId: *mut GUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6daa848c, 0x5eb0, 0x45cc, 0xae, 0xa5, 0x99, 0x8a, 0x2c, 0xda, 0x1f, 0xfb)] +interface IPartsList(IPartsListVtbl): IUnknown(IUnknownVtbl) { + fn GetCount( + pCount: *mut UINT, + ) -> HRESULT, + fn GetPart( + nIndex: UINT, + ppPart: *mut *mut IPart, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xae2de0e4, 0x5bca, 0x4f2d, 0xaa, 0x46, 0x5d, 0x13, 0xf8, 0xfd, 0xb3, 0xa9)] +interface IPart(IPartVtbl): IUnknown(IUnknownVtbl) { + fn GetName( + ppwstrName: *mut LPWSTR, + ) -> HRESULT, + fn GetLocalId( + pnId: *mut UINT, + ) -> HRESULT, + fn GetGlobalId( + ppwstrGlobalId: *mut LPWSTR, + ) -> HRESULT, + fn GetPartType( + pPartType: *mut PartType, + ) -> HRESULT, + fn GetSubType( + pSubType: *mut GUID, + ) -> HRESULT, + fn GetControlInterfaceCount( + pCount: *mut UINT, + ) -> HRESULT, + fn GetControlInterface( + nIndex: UINT, + ppInterfaceDesc: *mut *mut IControlInterface, + ) -> HRESULT, + fn EnumPartsIncoming( + ppParts: *mut *mut IPartsList, + ) -> HRESULT, + fn EnumPartsOutgoing( + ppParts: *mut *mut IPartsList, + ) -> HRESULT, + fn GetTopologyObject( + ppTopology: *mut *mut IDeviceTopology, + ) -> HRESULT, + fn Activate( + dwClsContext: DWORD, + refiid: REFIID, + ppvObject: *mut *mut c_void, + ) -> HRESULT, + fn RegisterControlChangeCallback( + riid: REFGUID, + pNotify: *mut IControlChangeNotify, + ) -> HRESULT, + fn UnregisterControlChangeCallback( + pNotify: *mut IControlChangeNotify, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9c2c4058, 0x23f5, 0x41de, 0x87, 0x7a, 0xdf, 0x3a, 0xf2, 0x36, 0xa0, 0x9e)] +interface IConnector(IConnectorVtbl): IUnknown(IUnknownVtbl) { + fn GetType( + pType: *mut ConnectorType, + ) -> HRESULT, + fn GetDataFlow( + pFlow: *mut DataFlow, + ) -> HRESULT, + fn ConnectTo( + pConnectTo: *mut IConnector, + ) -> HRESULT, + fn Disconnect() -> HRESULT, + fn IsConnected( + pbConnected: *mut BOOL, + ) -> HRESULT, + fn GetConnectedTo( + ppConTo: *mut *mut IConnector, + ) -> HRESULT, + fn GetConnectorIdConnectedTo( + ppwstrConnectorId: *mut LPWSTR, + ) -> HRESULT, + fn GetDeviceIdConnectedTo( + ppwstrDeviceId: *mut LPWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x82149a85, 0xdba6, 0x4487, 0x86, 0xbb, 0xea, 0x8f, 0x7f, 0xef, 0xcc, 0x71)] +interface ISubunit(ISubunitVtbl): IUnknown(IUnknownVtbl) {}} +RIDL!{#[uuid(0x45d37c3f, 0x5140, 0x444a, 0xae, 0x24, 0x40, 0x07, 0x89, 0xf3, 0xcb, 0xf3)] +interface IControlInterface(IControlInterfaceVtbl): IUnknown(IUnknownVtbl) { + fn GetName( + ppwstrName: *mut LPWSTR, + ) -> HRESULT, + fn GetIID( + pIID: *mut GUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa09513ed, 0xc709, 0x4d21, 0xbd, 0x7b, 0x5f, 0x34, 0xc4, 0x7f, 0x39, 0x47)] +interface IControlChangeNotify(IControlChangeNotifyVtbl): IUnknown(IUnknownVtbl) { + fn OnNotify( + dwSenderProcessId: DWORD, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2a07407e, 0x6497, 0x4a18, 0x97, 0x87, 0x32, 0xf7, 0x9b, 0xd0, 0xd9, 0x8f)] +interface IDeviceTopology(IDeviceTopologyVtbl): IUnknown(IUnknownVtbl) { + fn GetConnectorCount( + pCount: *mut UINT, + ) -> HRESULT, + fn GetConnector( + nIndex: UINT, + ppConnector: *mut *mut IConnector, + ) -> HRESULT, + fn GetSubunitCount( + pCount: *mut UINT, + ) -> HRESULT, + fn GetSubunit( + nIndex: UINT, + ppSubunit: *mut *mut ISubunit, + ) -> HRESULT, + fn GetPartById( + nId: UINT, + ppPart: *mut *mut IPart, + ) -> HRESULT, + fn GetDeviceId( + ppwstrDeviceId: *mut LPWSTR, + ) -> HRESULT, + fn GetSignalPath( + pIPartFrom: *mut IPart, + pIPartTo: *mut IPart, + bRejectMixedPaths: BOOL, + ppParts: *mut *mut IPartsList, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1df639d0, 0x5ec1, 0x47aa, 0x93, 0x79, 0x82, 0x8d, 0xc1, 0xaa, 0x8c, 0x59)] +class DeviceTopology;} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dinput.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dinput.rs new file mode 100644 index 0000000..5b5b1c5 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dinput.rs @@ -0,0 +1,107 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{CLSID_DirectInput, + 0x25e609e0, 0xb259, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{CLSID_DirectInputDevice, + 0x25e609e1, 0xb259, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{CLSID_DirectInput8, + 0x25e609e4, 0xb259, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{CLSID_DirectInputDevice8, + 0x25e609e5, 0xb259, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{IID_IDirectInputA, + 0x89521360, 0xaa8a, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{IID_IDirectInputW, + 0x89521361, 0xaa8a, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{IID_IDirectInput2A, + 0x5944e662, 0xaa8a, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{IID_IDirectInput2W, + 0x5944e663, 0xaa8a, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{IID_IDirectInput7A, + 0x9a4cb684, 0x236d, 0x11d3, 0x8e, 0x9d, 0x00, 0xc0, 0x4f, 0x68, 0x44, 0xae} +DEFINE_GUID!{IID_IDirectInput7W, + 0x9a4cb685, 0x236d, 0x11d3, 0x8e, 0x9d, 0x00, 0xc0, 0x4f, 0x68, 0x44, 0xae} +DEFINE_GUID!{IID_IDirectInput8A, + 0xbf798030, 0x483a, 0x4da2, 0xaa, 0x99, 0x5d, 0x64, 0xed, 0x36, 0x97, 0x00} +DEFINE_GUID!{IID_IDirectInput8W, + 0xbf798031, 0x483a, 0x4da2, 0xaa, 0x99, 0x5d, 0x64, 0xed, 0x36, 0x97, 0x00} +DEFINE_GUID!{IID_IDirectInputDeviceA, + 0x5944e680, 0xc92e, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{IID_IDirectInputDeviceW, + 0x5944e681, 0xc92e, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{IID_IDirectInputDevice2A, + 0x5944e682, 0xc92e, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{IID_IDirectInputDevice2W, + 0x5944e683, 0xc92e, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{IID_IDirectInputDevice7A, + 0x57d7c6bc, 0x2356, 0x11d3, 0x8e, 0x9d, 0x00, 0xc0, 0x4f, 0x68, 0x44, 0xae} +DEFINE_GUID!{IID_IDirectInputDevice7W, + 0x57d7c6bd, 0x2356, 0x11d3, 0x8e, 0x9d, 0x00, 0xc0, 0x4f, 0x68, 0x44, 0xae} +DEFINE_GUID!{IID_IDirectInputDevice8A, + 0x54d41080, 0xdc15, 0x4833, 0xa4, 0x1b, 0x74, 0x8f, 0x73, 0xa3, 0x81, 0x79} +DEFINE_GUID!{IID_IDirectInputDevice8W, + 0x54d41081, 0xdc15, 0x4833, 0xa4, 0x1b, 0x74, 0x8f, 0x73, 0xa3, 0x81, 0x79} +DEFINE_GUID!{IID_IDirectInputEffect, + 0xe7e1f7c0, 0x88d2, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_XAxis, + 0xa36d02e0, 0xc9f3, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_YAxis, + 0xa36d02e1, 0xc9f3, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_ZAxis, + 0xa36d02e2, 0xc9f3, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_RxAxis, + 0xa36d02f4, 0xc9f3, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_RyAxis, + 0xa36d02f5, 0xc9f3, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_RzAxis, + 0xa36d02e3, 0xc9f3, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_Slider, + 0xa36d02e4, 0xc9f3, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_Button, + 0xa36d02f0, 0xc9f3, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_Key, + 0x55728220, 0xd33c, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_POV, + 0xa36d02f2, 0xc9f3, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_Unknown, + 0xa36d02f3, 0xc9f3, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_SysMouse, + 0x6f1d2b60, 0xd5a0, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_SysKeyboard, + 0x6f1d2b61, 0xd5a0, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_Joystick, + 0x6f1d2b70, 0xd5a0, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_SysMouseEm, + 0x6f1d2b80, 0xd5a0, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_SysMouseEm2, + 0x6f1d2b81, 0xd5a0, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_SysKeyboardEm, + 0x6f1d2b82, 0xd5a0, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_SysKeyboardEm2, + 0x6f1d2b83, 0xd5a0, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{GUID_ConstantForce, + 0x13541c20, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_RampForce, + 0x13541c21, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_Square, + 0x13541c22, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_Sine, + 0x13541c23, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_Triangle, + 0x13541c24, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_SawtoothUp, + 0x13541c25, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_SawtoothDown, + 0x13541c26, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_Spring, + 0x13541c27, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_Damper, + 0x13541c28, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_Inertia, + 0x13541c29, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_Friction, + 0x13541c2a, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} +DEFINE_GUID!{GUID_CustomForce, + 0x13541c2b, 0x8e33, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dispex.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dispex.rs new file mode 100644 index 0000000..a846b46 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dispex.rs @@ -0,0 +1,221 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::DWORD_PTR; +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, WORD}; +use shared::winerror::HRESULT; +use shared::wtypes::{BSTR, VARIANT_BOOL, VARTYPE}; +use um::oaidl::{DISPID, DISPID_UNKNOWN, DISPPARAMS, EXCEPINFO, IDispatch, IDispatchVtbl, VARIANT}; +use um::servprov::IServiceProvider; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::LCID; +DEFINE_GUID!{IID_IDispatchEx, + 0xa6ef9860, 0xc720, 0x11d0, 0x93, 0x37, 0x0, 0xa0, 0xc9, 0xd, 0xca, 0xa9} +DEFINE_GUID!{IID_IDispError, + 0xa6ef9861, 0xc720, 0x11d0, 0x93, 0x37, 0x0, 0xa0, 0xc9, 0xd, 0xca, 0xa9} +DEFINE_GUID!{IID_IVariantChangeType, + 0xa6ef9862, 0xc720, 0x11d0, 0x93, 0x37, 0x0, 0xa0, 0xc9, 0xd, 0xca, 0xa9} +DEFINE_GUID!{SID_VariantConversion, + 0x1f101481, 0xbccd, 0x11d0, 0x93, 0x36, 0x0, 0xa0, 0xc9, 0xd, 0xca, 0xa9} +DEFINE_GUID!{SID_GetCaller, + 0x4717cc40, 0xbcb9, 0x11d0, 0x93, 0x36, 0x0, 0xa0, 0xc9, 0xd, 0xca, 0xa9} +DEFINE_GUID!{SID_ProvideRuntimeContext, + 0x74a5040c, 0xdd0c, 0x48f0, 0xac, 0x85, 0x19, 0x4c, 0x32, 0x59, 0x18, 0xa} +DEFINE_GUID!{IID_IProvideRuntimeContext, + 0x10e2414a, 0xec59, 0x49d2, 0xbc, 0x51, 0x5a, 0xdd, 0x2c, 0x36, 0xfe, 0xbc} +DEFINE_GUID!{IID_IObjectIdentity, + 0xca04b7e6, 0xd21, 0x11d1, 0x8c, 0xc5, 0x0, 0xc0, 0x4f, 0xc2, 0xb0, 0x85} +DEFINE_GUID!{IID_ICanHandleException, + 0xc5598e60, 0xb307, 0x11d1, 0xb2, 0x7d, 0x0, 0x60, 0x08, 0xc3, 0xfb, 0xfb} +// pub const SID_GetScriptSite = IID_IActiveScriptSite; +pub const fdexNameCaseSensitive: DWORD = 0x00000001; +pub const fdexNameEnsure: DWORD = 0x00000002; +pub const fdexNameImplicit: DWORD = 0x00000004; +pub const fdexNameCaseInsensitive: DWORD = 0x00000008; +pub const fdexNameInternal: DWORD = 0x00000010; +pub const fdexNameNoDynamicProperties: DWORD = 0x00000020; +pub const fdexPropCanGet: DWORD = 0x00000001; +pub const fdexPropCannotGet: DWORD = 0x00000002; +pub const fdexPropCanPut: DWORD = 0x00000004; +pub const fdexPropCannotPut: DWORD = 0x00000008; +pub const fdexPropCanPutRef: DWORD = 0x00000010; +pub const fdexPropCannotPutRef: DWORD = 0x00000020; +pub const fdexPropNoSideEffects: DWORD = 0x00000040; +pub const fdexPropDynamicType: DWORD = 0x00000080; +pub const fdexPropCanCall: DWORD = 0x00000100; +pub const fdexPropCannotCall: DWORD = 0x00000200; +pub const fdexPropCanConstruct: DWORD = 0x00000400; +pub const fdexPropCannotConstruct: DWORD = 0x00000800; +pub const fdexPropCanSourceEvents: DWORD = 0x00001000; +pub const fdexPropCannotSourceEvents: DWORD = 0x00002000; +pub const grfdexPropCanAll: DWORD = fdexPropCanGet | fdexPropCanPut | fdexPropCanPutRef + | fdexPropCanCall | fdexPropCanConstruct | fdexPropCanSourceEvents; +pub const grfdexPropCannotAll: DWORD = fdexPropCannotGet | fdexPropCannotPut | fdexPropCannotPutRef + | fdexPropCannotCall | fdexPropCannotConstruct | fdexPropCannotSourceEvents; +pub const grfdexPropExtraAll: DWORD = fdexPropNoSideEffects | fdexPropDynamicType; +pub const grfdexPropAll: DWORD = grfdexPropCanAll | grfdexPropCannotAll | grfdexPropExtraAll; +pub const fdexEnumDefault: DWORD = 0x00000001; +pub const fdexEnumAll: DWORD = 0x00000002; +pub const DISPATCH_CONSTRUCT: DWORD = 0x4000; +pub const DISPID_THIS: DISPID = -613; +pub const DISPID_STARTENUM: DISPID = DISPID_UNKNOWN; +// extern RPC_IF_HANDLE __MIDL_itf_dispex_0000_0000_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_dispex_0000_0000_v0_0_s_ifspec; +// EXTERN_C const IID IID_IDispatchEx; +RIDL!{#[uuid(0xa6ef9860, 0xc720, 0x11d0, 0x93, 0x37, 0x00, 0xa0, 0xc9, 0x0d, 0xca, 0xa9)] +interface IDispatchEx(IDispatchExVtbl): IDispatch(IDispatchVtbl) { + fn GetDispID( + bstrName: BSTR, + grfdex: DWORD, + pid: *mut DISPID, + ) -> HRESULT, + fn InvokeEx( + id: DISPID, + lcid: LCID, + wFlags: WORD, + pdp: *mut DISPPARAMS, + pvarRes: *mut VARIANT, + pei: *mut EXCEPINFO, + pspCaller: *mut IServiceProvider, + ) -> HRESULT, + fn DeleteMemberByName( + bstrName: BSTR, + grfdex: DWORD, + ) -> HRESULT, + fn DeleteMemberByDispID( + id: DISPID, + ) -> HRESULT, + fn GetMemberProperties( + id: DISPID, + grfdexFetch: DWORD, + pgrfdex: *mut DWORD, + ) -> HRESULT, + fn GetMemberName( + id: DISPID, + pbstrName: *mut BSTR, + ) -> HRESULT, + fn GetNextDispID( + grfdex: DWORD, + id: DISPID, + pid: *mut DISPID, + ) -> HRESULT, + fn GetNameSpaceParent( + ppunk: *mut *mut IUnknown, + ) -> HRESULT, +}} +// HRESULT STDMETHODCALLTYPE IDispatchEx_RemoteInvokeEx_Proxy( +// IDispatchEx * This, +// DISPID id, +// LCID lcid, +// DWORD dwFlags, +// DISPPARAMS *pdp, +// VARIANT *pvarRes, +// EXCEPINFO *pei, +// IServiceProvider *pspCaller, +// UINT cvarRefArg, +// UINT *rgiRefArg, +// VARIANT *rgvarRefArg); +// void __RPC_STUB IDispatchEx_RemoteInvokeEx_Stub( +// IRpcStubBuffer *This, +// IRpcChannelBuffer *_pRpcChannelBuffer, +// PRPC_MESSAGE _pRpcMessage, +// DWORD *_pdwStubPhase); +// EXTERN_C const IID IID_IDispError; +RIDL!{#[uuid(0xa6ef9861, 0xc720, 0x11d0, 0x93, 0x37, 0x00, 0xa0, 0xc9, 0x0d, 0xca, 0xa9)] +interface IDispError(IDispErrorVtbl): IUnknown(IUnknownVtbl) { + fn QueryErrorInfo( + guidErrorType: GUID, + ppde: *mut *mut IDispError, + ) -> HRESULT, + fn GetNext( + ppde: *mut *mut IDispError, + ) -> HRESULT, + fn GetHresult( + phr: *mut HRESULT, + ) -> HRESULT, + fn GetSource( + pbstrSource: *mut BSTR, + ) -> HRESULT, + fn GetHelpInfo( + pbstrFileName: *mut BSTR, + pdwContext: *mut DWORD, + ) -> HRESULT, + fn GetDescription( + pbstrDescription: *mut BSTR, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IVariantChangeType; +RIDL!{#[uuid(0xa6ef9862, 0xc720, 0x11d0, 0x93, 0x37, 0x00, 0xa0, 0xc9, 0x0d, 0xca, 0xa9)] +interface IVariantChangeType(IVariantChangeTypeVtbl): IUnknown(IUnknownVtbl) { + fn ChangeType( + pvarDst: *mut VARIANT, + pvarSrc: *mut VARIANT, + lcid: LCID, + vtNew: VARTYPE, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IObjectIdentity; +RIDL!{#[uuid(0xca04b7e6, 0x0d21, 0x11d1, 0x8c, 0xc5, 0x00, 0xc0, 0x4f, 0xc2, 0xb0, 0x85)] +interface IObjectIdentity(IObjectIdentityVtbl): IUnknown(IUnknownVtbl) { + fn IsEqualObject( + punk: *mut IUnknown, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ICanHandleException; +RIDL!{#[uuid(0xc5598e60, 0xb307, 0x11d1, 0xb2, 0x7d, 0x00, 0x60, 0x08, 0xc3, 0xfb, 0xfb)] +interface ICanHandleException(ICanHandleExceptionVtbl): IUnknown(IUnknownVtbl) { + fn CanHandleException( + pExcepInfo: *mut EXCEPINFO, + pvar: *mut VARIANT, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IProvideRuntimeContext; +RIDL!{#[uuid(0x10e2414a, 0xec59, 0x49d2, 0xbc, 0x51, 0x5a, 0xdd, 0x2c, 0x36, 0xfe, 0xbc)] +interface IProvideRuntimeContext(IProvideRuntimeContextVtbl): IUnknown(IUnknownVtbl) { + fn GetCurrentSourceContext( + pdwContext: *mut DWORD_PTR, + pfExecutingGlobalCode: *mut VARIANT_BOOL, + ) -> HRESULT, +}} +// extern RPC_IF_HANDLE __MIDL_itf_dispex_0000_0006_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_dispex_0000_0006_v0_0_s_ifspec; +// unsigned long __RPC_USER BSTR_UserSize( __RPC__in unsigned long *, unsigned long, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserMarshal( __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserUnmarshal(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); +// void __RPC_USER BSTR_UserFree( __RPC__in unsigned long *, __RPC__in BSTR * ); +// unsigned long __RPC_USER VARIANT_UserSize( __RPC__in unsigned long *, unsigned long, __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserMarshal( __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserUnmarshal(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out VARIANT * ); +// void __RPC_USER VARIANT_UserFree( __RPC__in unsigned long *, __RPC__in VARIANT * ); +// unsigned long __RPC_USER BSTR_UserSize64( __RPC__in unsigned long *, unsigned long, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserMarshal64( __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserUnmarshal64(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); +// void __RPC_USER BSTR_UserFree64( __RPC__in unsigned long *, __RPC__in BSTR * ); +// unsigned long __RPC_USER VARIANT_UserSize64( __RPC__in unsigned long *, unsigned long, __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserMarshal64( __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserUnmarshal64(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out VARIANT * ); +// void __RPC_USER VARIANT_UserFree64( __RPC__in unsigned long *, __RPC__in VARIANT * ); +// HRESULT STDMETHODCALLTYPE IDispatchEx_InvokeEx_Proxy( +// IDispatchEx * This, +// DISPID id, +// LCID lcid, +// WORD wFlags, +// DISPPARAMS *pdp, +// VARIANT *pvarRes, +// EXCEPINFO *pei, +// IServiceProvider *pspCaller); +// HRESULT STDMETHODCALLTYPE IDispatchEx_InvokeEx_Stub( +// IDispatchEx * This, +// DISPID id, +// LCID lcid, +// DWORD dwFlags, +// DISPPARAMS *pdp, +// VARIANT *pvarRes, +// EXCEPINFO *pei, +// IServiceProvider *pspCaller, +// UINT cvarRefArg, +// UINT *rgiRefArg, +// VARIANT *rgvarRefArg); diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dmksctl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dmksctl.rs new file mode 100644 index 0000000..252ab73 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dmksctl.rs @@ -0,0 +1,11 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_IKsControl, + 0x28f54685, 0x06fd, 0x11d2, 0xb2, 0x7a, 0x00, 0xa0, 0xc9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_MIDI, + 0x1d262760, 0xe957, 0x11cf, 0xa5, 0xd6, 0x28, 0xdb, 0x04, 0xc1, 0x00, 0x00} +DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_DIRECTMUSIC, + 0x1a82f8bc, 0x3f8b, 0x11d2, 0xb7, 0x74, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dmusicc.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dmusicc.rs new file mode 100644 index 0000000..ee87b6f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dmusicc.rs @@ -0,0 +1,71 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{CLSID_DirectMusic, + 0x636b9f10, 0x0c7d, 0x11d1, 0x95, 0xb2, 0x00, 0x20, 0xaf, 0xdc, 0x74, 0x21} +DEFINE_GUID!{CLSID_DirectMusicCollection, + 0x480ff4b0, 0x28b2, 0x11d1, 0xbe, 0xf7, 0x00, 0xc0, 0x4f, 0xbf, 0x8f, 0xef} +DEFINE_GUID!{CLSID_DirectMusicSynth, + 0x58c2b4d0, 0x46e7, 0x11d1, 0x89, 0xac, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29} +DEFINE_GUID!{IID_IDirectMusic, + 0x6536115a, 0x7b2d, 0x11d2, 0xba, 0x18, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} +DEFINE_GUID!{IID_IDirectMusicBuffer, + 0xd2ac2878, 0xb39b, 0x11d1, 0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xb1, 0xbd} +DEFINE_GUID!{IID_IDirectMusicPort, + 0x08f2d8c9, 0x37c2, 0x11d2, 0xb9, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} +DEFINE_GUID!{IID_IDirectMusicThru, + 0xced153e7, 0x3606, 0x11d2, 0xb9, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} +DEFINE_GUID!{IID_IDirectMusicPortDownload, + 0xd2ac287a, 0xb39b, 0x11d1, 0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xb1, 0xbd} +DEFINE_GUID!{IID_IDirectMusicDownload, + 0xd2ac287b, 0xb39b, 0x11d1, 0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xb1, 0xbd} +DEFINE_GUID!{IID_IDirectMusicCollection, + 0xd2ac287c, 0xb39b, 0x11d1, 0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xb1, 0xbd} +DEFINE_GUID!{IID_IDirectMusicInstrument, + 0xd2ac287d, 0xb39b, 0x11d1, 0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xb1, 0xbd} +DEFINE_GUID!{IID_IDirectMusicDownloadedInstrument, + 0xd2ac287e, 0xb39b, 0x11d1, 0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xb1, 0xbd} +DEFINE_GUID!{IID_IDirectMusic2, + 0x6fc2cae1, 0xbc78, 0x11d2, 0xaf, 0xa6, 0x00, 0xaa, 0x00, 0x24, 0xd8, 0xb6} +DEFINE_GUID!{IID_IDirectMusic8, + 0x2d3629f7, 0x813d, 0x4939, 0x85, 0x08, 0xf0, 0x5c, 0x6b, 0x75, 0xfd, 0x97} +DEFINE_GUID!{GUID_DMUS_PROP_GM_Hardware, + 0x178f2f24, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} +DEFINE_GUID!{GUID_DMUS_PROP_GS_Hardware, + 0x178f2f25, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} +DEFINE_GUID!{GUID_DMUS_PROP_XG_Hardware, + 0x178f2f26, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} +DEFINE_GUID!{GUID_DMUS_PROP_XG_Capable, + 0x6496aba1, 0x61b0, 0x11d2, 0xaf, 0xa6, 0x00, 0xaa, 0x00, 0x24, 0xd8, 0xb6} +DEFINE_GUID!{GUID_DMUS_PROP_GS_Capable, + 0x6496aba2, 0x61b0, 0x11d2, 0xaf, 0xa6, 0x00, 0xaa, 0x00, 0x24, 0xd8, 0xb6} +DEFINE_GUID!{GUID_DMUS_PROP_DLS1, + 0x178f2f27, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} +DEFINE_GUID!{GUID_DMUS_PROP_DLS2, + 0xf14599e5, 0x4689, 0x11d2, 0xaf, 0xa6, 0x00, 0xaa, 0x00, 0x24, 0xd8, 0xb6} +DEFINE_GUID!{GUID_DMUS_PROP_INSTRUMENT2, + 0x865fd372, 0x9f67, 0x11d2, 0x87, 0x2a, 0x00, 0x60, 0x08, 0x93, 0xb1, 0xbd} +DEFINE_GUID!{GUID_DMUS_PROP_SynthSink_DSOUND, + 0x0aa97844, 0xc877, 0x11d1, 0x87, 0x0c, 0x00, 0x60, 0x08, 0x93, 0xb1, 0xbd} +DEFINE_GUID!{GUID_DMUS_PROP_SynthSink_WAVE, + 0x0aa97845, 0xc877, 0x11d1, 0x87, 0x0c, 0x00, 0x60, 0x08, 0x93, 0xb1, 0xbd} +DEFINE_GUID!{GUID_DMUS_PROP_SampleMemorySize, + 0x178f2f28, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} +DEFINE_GUID!{GUID_DMUS_PROP_SamplePlaybackRate, + 0x2a91f713, 0xa4bf, 0x11d2, 0xbb, 0xdf, 0x00, 0x60, 0x08, 0x33, 0xdb, 0xd8} +DEFINE_GUID!{GUID_DMUS_PROP_WriteLatency, + 0x268a0fa0, 0x60f2, 0x11d2, 0xaf, 0xa6, 0x00, 0xaa, 0x00, 0x24, 0xd8, 0xb6} +DEFINE_GUID!{GUID_DMUS_PROP_WritePeriod, + 0x268a0fa1, 0x60f2, 0x11d2, 0xaf, 0xa6, 0x00, 0xaa, 0x00, 0x24, 0xd8, 0xb6} +DEFINE_GUID!{GUID_DMUS_PROP_MemorySize, + 0x178f2f28, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} +DEFINE_GUID!{GUID_DMUS_PROP_WavesReverb, + 0x04cb5622, 0x32e5, 0x11d2, 0xaf, 0xa6, 0x00, 0xaa, 0x00, 0x24, 0xd8, 0xb6} +DEFINE_GUID!{GUID_DMUS_PROP_Effects, + 0xcda8d611, 0x684a, 0x11d2, 0x87, 0x1e, 0x00, 0x60, 0x08, 0x93, 0xb1, 0xbd} +DEFINE_GUID!{GUID_DMUS_PROP_LegacyCaps, + 0xcfa7cdc2, 0x00a1, 0x11d2, 0xaa, 0xd5, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} +DEFINE_GUID!{GUID_DMUS_PROP_Volume, + 0xfedfae25, 0xe46e, 0x11d1, 0xaa, 0xce, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/docobj.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/docobj.rs new file mode 100644 index 0000000..e14ddb9 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/docobj.rs @@ -0,0 +1,136 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::wchar_t; +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, ULONG}; +use um::oaidl::VARIANT; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::HRESULT; +ENUM!{enum OLECMDF { + OLECMDF_SUPPORTED = 0x1, + OLECMDF_ENABLED = 0x2, + OLECMDF_LATCHED = 0x4, + OLECMDF_NINCHED = 0x8, + OLECMDF_INVISIBLE = 0x10, + OLECMDF_DEFHIDEONCTXTMENU = 0x20, +}} +STRUCT!{struct OLECMD { + cmdID: ULONG, + cmdf: DWORD, +}} +STRUCT!{struct OLECMDTEXT { + cmdtextf: DWORD, + cwActual: ULONG, + cwBuf: ULONG, + rgwz: [wchar_t; 1], +}} +ENUM!{enum OLECMDEXECOPT { + OLECMDEXECOPT_DODEFAULT = 0, + OLECMDEXECOPT_PROMPTUSER = 1, + OLECMDEXECOPT_DONTPROMPTUSER = 2, + OLECMDEXECOPT_SHOWHELP = 3, +}} +ENUM!{enum OLECMDID { + OLECMDID_OPEN = 1, + OLECMDID_NEW = 2, + OLECMDID_SAVE = 3, + OLECMDID_SAVEAS = 4, + OLECMDID_SAVECOPYAS = 5, + OLECMDID_PRINT = 6, + OLECMDID_PRINTPREVIEW = 7, + OLECMDID_PAGESETUP = 8, + OLECMDID_SPELL = 9, + OLECMDID_PROPERTIES = 10, + OLECMDID_CUT = 11, + OLECMDID_COPY = 12, + OLECMDID_PASTE = 13, + OLECMDID_PASTESPECIAL = 14, + OLECMDID_UNDO = 15, + OLECMDID_REDO = 16, + OLECMDID_SELECTALL = 17, + OLECMDID_CLEARSELECTION = 18, + OLECMDID_ZOOM = 19, + OLECMDID_GETZOOMRANGE = 20, + OLECMDID_UPDATECOMMANDS = 21, + OLECMDID_REFRESH = 22, + OLECMDID_STOP = 23, + OLECMDID_HIDETOOLBARS = 24, + OLECMDID_SETPROGRESSMAX = 25, + OLECMDID_SETPROGRESSPOS = 26, + OLECMDID_SETPROGRESSTEXT = 27, + OLECMDID_SETTITLE = 28, + OLECMDID_SETDOWNLOADSTATE = 29, + OLECMDID_STOPDOWNLOAD = 30, + OLECMDID_ONTOOLBARACTIVATED = 31, + OLECMDID_FIND = 32, + OLECMDID_DELETE = 33, + OLECMDID_HTTPEQUIV = 34, + OLECMDID_HTTPEQUIV_DONE = 35, + OLECMDID_ENABLE_INTERACTION = 36, + OLECMDID_ONUNLOAD = 37, + OLECMDID_PROPERTYBAG2 = 38, + OLECMDID_PREREFRESH = 39, + OLECMDID_SHOWSCRIPTERROR = 40, + OLECMDID_SHOWMESSAGE = 41, + OLECMDID_SHOWFIND = 42, + OLECMDID_SHOWPAGESETUP = 43, + OLECMDID_SHOWPRINT = 44, + OLECMDID_CLOSE = 45, + OLECMDID_ALLOWUILESSSAVEAS = 46, + OLECMDID_DONTDOWNLOADCSS = 47, + OLECMDID_UPDATEPAGESTATUS = 48, + OLECMDID_PRINT2 = 49, + OLECMDID_PRINTPREVIEW2 = 50, + OLECMDID_SETPRINTTEMPLATE = 51, + OLECMDID_GETPRINTTEMPLATE = 52, + OLECMDID_PAGEACTIONBLOCKED = 55, + OLECMDID_PAGEACTIONUIQUERY = 56, + OLECMDID_FOCUSVIEWCONTROLS = 57, + OLECMDID_FOCUSVIEWCONTROLSQUERY = 58, + OLECMDID_SHOWPAGEACTIONMENU = 59, + OLECMDID_ADDTRAVELENTRY = 60, + OLECMDID_UPDATETRAVELENTRY = 61, + OLECMDID_UPDATEBACKFORWARDSTATE = 62, + OLECMDID_OPTICAL_ZOOM = 63, + OLECMDID_OPTICAL_GETZOOMRANGE = 64, + OLECMDID_WINDOWSTATECHANGED = 65, + OLECMDID_ACTIVEXINSTALLSCOPE = 66, + OLECMDID_UPDATETRAVELENTRY_DATARECOVERY = 67, + OLECMDID_SHOWTASKDLG = 68, + OLECMDID_POPSTATEEVENT = 69, + OLECMDID_VIEWPORT_MODE = 70, + OLECMDID_LAYOUT_VIEWPORT_WIDTH = 71, + OLECMDID_VISUAL_VIEWPORT_EXCLUDE_BOTTOM = 72, + OLECMDID_USER_OPTICAL_ZOOM = 73, + OLECMDID_PAGEAVAILABLE = 74, + OLECMDID_GETUSERSCALABLE = 75, + OLECMDID_UPDATE_CARET = 76, + OLECMDID_ENABLE_VISIBILITY = 77, + OLECMDID_MEDIA_PLAYBACK = 78, + OLECMDID_SETFAVICON = 79, + OLECMDID_SET_HOST_FULLSCREENMODE = 80, + OLECMDID_EXITFULLSCREEN = 81, + OLECMDID_SCROLLCOMPLETE = 82, + OLECMDID_ONBEFOREUNLOAD = 83, + OLECMDID_SHOWMESSAGE_BLOCKABLE = 84, + OLECMDID_SHOWTASKDLG_BLOCKABLE = 85, +}} +RIDL!{#[uuid(0xb722bccb, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70)] +interface IOleCommandTarget(IOleCommandTargetVtbl): IUnknown(IUnknownVtbl) { + fn QueryStatus( + pguidCmdGroup: *const GUID, + cCmds: ULONG, + prgCmds: *mut OLECMD, + pCmdText: *mut OLECMDTEXT, + ) -> HRESULT, + fn Exec( + pguidCmdGroup: *const GUID, + nCmdID: DWORD, + nCmdexecopt: DWORD, + pvaIn: *mut VARIANT, + pvaOut: *mut VARIANT, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/documenttarget.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/documenttarget.rs new file mode 100644 index 0000000..b4cc1ae --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/documenttarget.rs @@ -0,0 +1,24 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +// TODO:It is a minimal implementation. +use ctypes::c_void; +use shared::basetsd::UINT32; +use shared::guiddef::{GUID, REFGUID, REFIID}; +use shared::ntdef::HRESULT; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +RIDL!{#[uuid(0x1b8efec4, 0x3019, 0x4c27, 0x96, 0x4e, 0x36, 0x72, 0x02, 0x15, 0x69, 0x06)] +interface IPrintDocumentPackageTarget(IPrintDocumentPackageTargetVtbl): IUnknown(IUnknownVtbl) { + fn GetPackageTargetTypes( + targetCount: *mut UINT32, + targetTypes: *mut *mut GUID, + ) -> HRESULT, + fn GetPackageTarget( + guidTargetType: REFGUID, + riid: REFIID, + ppvTarget: *mut *mut c_void, + ) -> HRESULT, + fn Cancel() -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dpa_dsa.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dpa_dsa.rs new file mode 100644 index 0000000..21a3f4b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dpa_dsa.rs @@ -0,0 +1,283 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_int, c_void}; +use shared::basetsd::INT_PTR; +use shared::minwindef::{BOOL, DWORD, LPARAM, UINT}; +use um::winnt::{HANDLE, HRESULT, LPCWSTR, LPWSTR, PVOID, ULONGLONG}; +pub const DA_LAST: c_int = 0x7FFFFFFF; +pub const DA_ERR: c_int = -1; +FN!{stdcall PFNDAENUMCALLBACK( + p: *mut c_void, + pData: *mut c_void, +) -> c_int} +FN!{stdcall PFNDAENUMCALLBACKCONST( + p: *const c_void, + pData: *mut c_void, +) -> c_int} +FN!{stdcall PFNDACOMPARE( + p1: *mut c_void, + p2: *mut c_void, + lParam: LPARAM, +) -> c_int} +FN!{stdcall PFNDACOMPARECONST( + p1: *const c_void, + p2: *const c_void, + lParam: LPARAM, +) -> c_int} +pub enum DSA {} +pub type HDSA = *mut DSA; +extern "system" { + pub fn DSA_Create( + cbItem: c_int, + cItemGrow: c_int, + ) -> HDSA; + pub fn DSA_Destroy( + hdsa: HDSA, + ) -> BOOL; + pub fn DSA_DestroyCallback( + hdsa: HDSA, + pfnCB: PFNDAENUMCALLBACK, + pData: *mut c_void, + ); + pub fn DSA_DeleteItem( + hdsa: HDSA, + i: c_int, + ) -> BOOL; + pub fn DSA_DeleteAllItems( + hdsa: HDSA, + ) -> BOOL; + pub fn DSA_EnumCallback( + hdsa: HDSA, + pfnCB: PFNDAENUMCALLBACK, + pData: *mut c_void, + ); + pub fn DSA_InsertItem( + hdsa: HDSA, + i: c_int, + pitem: *const c_void, + ) -> c_int; + pub fn DSA_GetItemPtr( + hdsa: HDSA, + i: c_int, + ) -> PVOID; + pub fn DSA_GetItem( + hdsa: HDSA, + i: c_int, + pitem: *mut c_void, + ) -> BOOL; + pub fn DSA_SetItem( + hdsa: HDSA, + i: c_int, + pitem: *const c_void, + ) -> BOOL; +} +#[inline] +pub unsafe fn DSA_GetItemCount(hdsa: HDSA) -> c_int { + *(hdsa as *mut c_int) +} +#[inline] +pub unsafe fn DSA_AppendItem(hdsa: HDSA, pitem: *const c_void) -> c_int { + DSA_InsertItem(hdsa, DA_LAST, pitem) +} +extern "system" { + pub fn DSA_Clone( + hdsa: HDSA, + ) -> HDSA; + pub fn DSA_GetSize( + hdsa: HDSA, + ) -> ULONGLONG; + pub fn DSA_Sort( + pdsa: HDSA, + pfnCompare: PFNDACOMPARE, + lParam: LPARAM, + ) -> BOOL; +} +pub const DSA_APPEND: c_int = DA_LAST; +pub const DSA_ERR: c_int = DA_ERR; +pub type PFNDSAENUMCALLBACK = PFNDAENUMCALLBACK; +pub type PFNDSAENUMCALLBACKCONST = PFNDAENUMCALLBACKCONST; +pub type PFNDSACOMPARE = PFNDACOMPARE; +pub type PFNDSACOMPARECONST = PFNDACOMPARECONST; +pub enum DPA {} +pub type HDPA = *mut DPA; +extern "system" { + pub fn DPA_Create( + cItemGrow: c_int, + ) -> HDPA; + pub fn DPA_CreateEx( + cpGrow: c_int, + hheap: HANDLE, + ) -> HDPA; + pub fn DPA_Clone( + hdpa: HDPA, + hdpaNew: HDPA, + ) -> HDPA; + pub fn DPA_Destroy( + hdpa: HDPA, + ) -> BOOL; + pub fn DPA_DestroyCallback( + hdpa: HDPA, + pfnCB: PFNDAENUMCALLBACK, + pData: *mut c_void, + ); + pub fn DPA_DeletePtr( + hdpa: HDPA, + i: c_int, + ) -> PVOID; + pub fn DPA_DeleteAllPtrs( + hdpa: HDPA, + ) -> BOOL; + pub fn DPA_EnumCallback( + hdpa: HDPA, + pfnCB: PFNDAENUMCALLBACK, + pData: *mut c_void, + ); + pub fn DPA_Grow( + hdpa: HDPA, + cp: c_int, + ) -> BOOL; + pub fn DPA_InsertPtr( + hdpa: HDPA, + i: c_int, + p: *mut c_void, + ) -> c_int; + pub fn DPA_SetPtr( + hdpa: HDPA, + i: c_int, + p: *mut c_void, + ) -> BOOL; + pub fn DPA_GetPtr( + hdpa: HDPA, + i: INT_PTR, + ) -> PVOID; + pub fn DPA_GetPtrIndex( + hdpa: HDPA, + p: *const c_void, + ) -> c_int; +} +#[inline] +pub unsafe fn DPA_GetPtrCount(hdpa: HDPA) -> c_int { + *(hdpa as *mut c_int) +} +#[inline] +pub unsafe fn DPA_SetPtrCount(hdpa: HDPA, cItems: c_int) { + *(hdpa as *mut c_int) = cItems; +} +#[inline] +pub unsafe fn DPA_FastDeleteLastPtr(hdpa: HDPA) -> c_int { + *(hdpa as *mut c_int) -= 1; + *(hdpa as *mut c_int) +} +#[inline] +pub unsafe fn DPA_AppendPtr(hdpa: HDPA, pitem: *mut c_void) -> c_int { + DPA_InsertPtr(hdpa, DA_LAST, pitem) +} +extern "system" { + pub fn DPA_GetSize( + hdpa: HDPA, + ) -> ULONGLONG; + pub fn DPA_Sort( + hdpa: HDPA, + pfnCompare: PFNDACOMPARE, + lParam: LPARAM, + ) -> BOOL; +} +STRUCT!{struct DPASTREAMINFO { + iPos: c_int, + pvItem: *mut c_void, +}} +pub enum IStream {} +FN!{stdcall PFNDPASTREAM( + pinfo: *mut DPASTREAMINFO, + pstream: *mut IStream, + pvInstData: *mut c_void, +) -> HRESULT} +extern "system" { + pub fn DPA_LoadStream( + phdpa: *mut HDPA, + pfn: PFNDPASTREAM, + pstream: *mut IStream, + pvInstData: *mut c_void, + ) -> HRESULT; + pub fn DPA_SaveStream( + hdpa: HDPA, + pfn: PFNDPASTREAM, + pstream: *mut IStream, + pvInstData: *mut c_void, + ) -> HRESULT; +} +pub const DPAM_SORTED: DWORD = 0x00000001; +pub const DPAM_NORMAL: DWORD = 0x00000002; +pub const DPAM_UNION: DWORD = 0x00000004; +pub const DPAM_INTERSECT: DWORD = 0x00000008; +FN!{stdcall PFNDPAMERGE( + uMsg: UINT, + pvDest: *mut c_void, + pvSrc: *mut c_void, + lParam: LPARAM, +) -> *mut c_void} +FN!{stdcall PFNDPAMERGECONST( + uMsg: UINT, + pvDest: *const c_void, + pvSrc: *const c_void, + lParam: LPARAM, +) -> *const c_void} +pub const DPAMM_MERGE: UINT = 1; +pub const DPAMM_DELETE: UINT = 2; +pub const DPAMM_INSERT: UINT = 3; +extern "system" { + pub fn DPA_Merge( + hdpaDest: HDPA, + hdpaSrc: HDPA, + dwFlags: DWORD, + pfnCompare: PFNDACOMPARE, + pfnMerge: PFNDPAMERGE, + lParam: LPARAM, + ) -> BOOL; +} +pub const DPAS_SORTED: UINT = 0x0001; +pub const DPAS_INSERTBEFORE: UINT = 0x0002; +pub const DPAS_INSERTAFTER: UINT = 0x0004; +extern "system" { + pub fn DPA_Search( + hdpa: HDPA, + pFind: *mut c_void, + iStart: c_int, + pfnCompare: PFNDACOMPARE, + lParam: LPARAM, + options: UINT, + ) -> c_int; +} +#[inline] +pub unsafe fn DPA_SortedInsertPtr( + hdpa: HDPA, + pFind: *mut c_void, + iStart: c_int, + pfnCompare: PFNDACOMPARE, + lParam: LPARAM, + options: UINT, + pitem: *mut c_void, +) -> c_int { + DPA_InsertPtr( + hdpa, + DPA_Search( + hdpa, pFind, iStart, pfnCompare, lParam, DPAS_SORTED | options, + ), + pitem, + ) +} +pub const DPA_APPEND: c_int = DA_LAST; +pub const DPA_ERR: c_int = DA_ERR; +pub type PFNDPAENUMCALLBACK = PFNDAENUMCALLBACK; +pub type PFNDPAENUMCALLBACKCONST = PFNDAENUMCALLBACKCONST; +pub type PFNDPACOMPARE = PFNDACOMPARE; +pub type PFNDPACOMPARECONST = PFNDACOMPARECONST; +extern "system" { + pub fn Str_SetPtrW( + ppsz: *mut LPWSTR, + psz: LPCWSTR, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dpapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dpapi.rs new file mode 100644 index 0000000..42f5824 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dpapi.rs @@ -0,0 +1,100 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Data Protection API Prototypes and Definitions +use shared::minwindef::{BOOL, BYTE, DWORD, LPVOID}; +use shared::windef::HWND; +use um::wincrypt::DATA_BLOB; +use um::winnt::{LPCWSTR, LPWSTR, PSID, PVOID}; +pub const szFORCE_KEY_PROTECTION: &'static str = "ForceKeyProtection"; +pub const dwFORCE_KEY_PROTECTION_DISABLED: DWORD = 0x0; +pub const dwFORCE_KEY_PROTECTION_USER_SELECT: DWORD = 0x1; +pub const dwFORCE_KEY_PROTECTION_HIGH: DWORD = 0x2; +STRUCT!{struct CRYPTPROTECT_PROMPTSTRUCT { + cbSize: DWORD, + dwPromptFlags: DWORD, + hwndApp: HWND, + szPrompt: LPCWSTR, +}} +pub type PCRYPTPROTECT_PROMPTSTRUCT = *mut CRYPTPROTECT_PROMPTSTRUCT; +pub const CRYPTPROTECT_PROMPT_ON_UNPROTECT: DWORD = 0x1; +pub const CRYPTPROTECT_PROMPT_ON_PROTECT: DWORD = 0x2; +pub const CRYPTPROTECT_PROMPT_RESERVED: DWORD = 0x04; +pub const CRYPTPROTECT_PROMPT_STRONG: DWORD = 0x08; +pub const CRYPTPROTECT_PROMPT_REQUIRE_STRONG: DWORD = 0x10; +pub const CRYPTPROTECT_UI_FORBIDDEN: DWORD = 0x1; +pub const CRYPTPROTECT_LOCAL_MACHINE: DWORD = 0x4; +pub const CRYPTPROTECT_CRED_SYNC: DWORD = 0x8; +pub const CRYPTPROTECT_AUDIT: DWORD = 0x10; +pub const CRYPTPROTECT_NO_RECOVERY: DWORD = 0x20; +pub const CRYPTPROTECT_VERIFY_PROTECTION: DWORD = 0x40; +pub const CRYPTPROTECT_CRED_REGENERATE: DWORD = 0x80; +pub const CRYPTPROTECT_FIRST_RESERVED_FLAGVAL: DWORD = 0x0FFFFFFF; +pub const CRYPTPROTECT_LAST_RESERVED_FLAGVAL: DWORD = 0xFFFFFFFF; +extern "system" { + pub fn CryptProtectData( + pDataIn: *mut DATA_BLOB, + szDataDescr: LPCWSTR, + pOptionalEntropy: *mut DATA_BLOB, + pvReserved: PVOID, + pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, + dwFlags: DWORD, + pDataOut: *mut DATA_BLOB, + ) -> BOOL; + pub fn CryptUnprotectData( + pDataIn: *mut DATA_BLOB, + ppszDataDescr: *mut LPWSTR, + pOptionalEntropy: *mut DATA_BLOB, + pvReserved: PVOID, + pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, + dwFlags: DWORD, + pDataOut: *mut DATA_BLOB, + ) -> BOOL; + pub fn CryptProtectDataNoUI( + pDataIn: *mut DATA_BLOB, + szDataDescr: LPCWSTR, + pOptionalEntropy: *mut DATA_BLOB, + pvReserved: PVOID, + pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, + dwFlags: DWORD, + pbOptionalPassword: *const BYTE, + cbOptionalPassword: DWORD, + pDataOut: *mut DATA_BLOB, + ) -> BOOL; + pub fn CryptUnprotectDataNoUI( + pDataIn: *mut DATA_BLOB, + ppszDataDescr: *mut LPWSTR, + pOptionalEntropy: *mut DATA_BLOB, + pvReserved: PVOID, + pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, + dwFlags: DWORD, + pbOptionalPassword: *const BYTE, + cbOptionalPassword: DWORD, + pDataOut: *mut DATA_BLOB, + ) -> BOOL; + pub fn CryptUpdateProtectedState( + pOldSid: PSID, + pwszOldPassword: LPCWSTR, + dwFlags: DWORD, + pdwSuccessCount: *mut DWORD, + pdwFailureCount: *mut DWORD, + ) -> BOOL; +} +pub const CRYPTPROTECTMEMORY_BLOCK_SIZE: DWORD = 16; +pub const CRYPTPROTECTMEMORY_SAME_PROCESS: DWORD = 0x00; +pub const CRYPTPROTECTMEMORY_CROSS_PROCESS: DWORD = 0x01; +pub const CRYPTPROTECTMEMORY_SAME_LOGON: DWORD = 0x02; +extern "system" { + pub fn CryptProtectMemory( + pDataIn: LPVOID, + cbDataIn: DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptUnprotectMemory( + pDataIn: LPVOID, + cbDataIn: DWORD, + dwFlags: DWORD, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dsgetdc.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dsgetdc.rs new file mode 100644 index 0000000..860a652 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dsgetdc.rs @@ -0,0 +1,267 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This file contains structures, function prototypes, and definitions for the DsGetDcName API. +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, PULONG, ULONG}; +use shared::ws2def::{LPSOCKET_ADDRESS, PSOCKET_ADDRESS}; +use um::ntsecapi::PLSA_FOREST_TRUST_INFORMATION; +use um::winnt::{HANDLE, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PHANDLE, PSID}; +pub const DS_FORCE_REDISCOVERY: ULONG = 0x00000001; +pub const DS_DIRECTORY_SERVICE_REQUIRED: ULONG = 0x00000010; +pub const DS_DIRECTORY_SERVICE_PREFERRED: ULONG = 0x00000020; +pub const DS_GC_SERVER_REQUIRED: ULONG = 0x00000040; +pub const DS_PDC_REQUIRED: ULONG = 0x00000080; +pub const DS_BACKGROUND_ONLY: ULONG = 0x00000100; +pub const DS_IP_REQUIRED: ULONG = 0x00000200; +pub const DS_KDC_REQUIRED: ULONG = 0x00000400; +pub const DS_TIMESERV_REQUIRED: ULONG = 0x00000800; +pub const DS_WRITABLE_REQUIRED: ULONG = 0x00001000; +pub const DS_GOOD_TIMESERV_PREFERRED: ULONG = 0x00002000; +pub const DS_AVOID_SELF: ULONG = 0x00004000; +pub const DS_ONLY_LDAP_NEEDED: ULONG = 0x00008000; +pub const DS_IS_FLAT_NAME: ULONG = 0x00010000; +pub const DS_IS_DNS_NAME: ULONG = 0x00020000; +pub const DS_TRY_NEXTCLOSEST_SITE: ULONG = 0x00040000; +pub const DS_DIRECTORY_SERVICE_6_REQUIRED: ULONG = 0x00080000; +pub const DS_WEB_SERVICE_REQUIRED: ULONG = 0x00100000; +pub const DS_DIRECTORY_SERVICE_8_REQUIRED: ULONG = 0x00200000; +pub const DS_DIRECTORY_SERVICE_9_REQUIRED: ULONG = 0x00400000; +pub const DS_DIRECTORY_SERVICE_10_REQUIRED: ULONG = 0x00800000; +pub const DS_RETURN_DNS_NAME: ULONG = 0x40000000; +pub const DS_RETURN_FLAT_NAME: ULONG = 0x80000000; +pub const DSGETDC_VALID_FLAGS: ULONG = DS_FORCE_REDISCOVERY | DS_DIRECTORY_SERVICE_REQUIRED + | DS_DIRECTORY_SERVICE_PREFERRED | DS_GC_SERVER_REQUIRED | DS_PDC_REQUIRED | DS_BACKGROUND_ONLY + | DS_IP_REQUIRED | DS_KDC_REQUIRED | DS_TIMESERV_REQUIRED | DS_WRITABLE_REQUIRED + | DS_GOOD_TIMESERV_PREFERRED | DS_AVOID_SELF | DS_ONLY_LDAP_NEEDED | DS_IS_FLAT_NAME + | DS_IS_DNS_NAME | DS_TRY_NEXTCLOSEST_SITE | DS_DIRECTORY_SERVICE_6_REQUIRED + | DS_DIRECTORY_SERVICE_8_REQUIRED | DS_DIRECTORY_SERVICE_9_REQUIRED + | DS_DIRECTORY_SERVICE_10_REQUIRED | DS_WEB_SERVICE_REQUIRED | DS_RETURN_FLAT_NAME + | DS_RETURN_DNS_NAME; +STRUCT!{struct DOMAIN_CONTROLLER_INFOA { + DomainControllerName: LPSTR, + DomainControllerAddress: LPSTR, + DomainControllerAddressType: ULONG, + DomainGuid: GUID, + DomainName: LPSTR, + DnsForestName: LPSTR, + Flags: ULONG, + DcSiteName: LPSTR, + ClientSiteName: LPSTR, +}} +pub type PDOMAIN_CONTROLLER_INFOA = *mut DOMAIN_CONTROLLER_INFOA; +STRUCT!{struct DOMAIN_CONTROLLER_INFOW { + DomainControllerName: LPWSTR, + DomainControllerAddress: LPWSTR, + DomainControllerAddressType: ULONG, + DomainGuid: GUID, + DomainName: LPWSTR, + DnsForestName: LPWSTR, + Flags: ULONG, + DcSiteName: LPWSTR, + ClientSiteName: LPWSTR, +}} +pub type PDOMAIN_CONTROLLER_INFOW = *mut DOMAIN_CONTROLLER_INFOW; +pub const DS_INET_ADDRESS: ULONG = 1; +pub const DS_NETBIOS_ADDRESS: ULONG = 2; +pub const DS_PDC_FLAG: ULONG = 0x00000001; +pub const DS_GC_FLAG: ULONG = 0x00000004; +pub const DS_LDAP_FLAG: ULONG = 0x00000008; +pub const DS_DS_FLAG: ULONG = 0x00000010; +pub const DS_KDC_FLAG: ULONG = 0x00000020; +pub const DS_TIMESERV_FLAG: ULONG = 0x00000040; +pub const DS_CLOSEST_FLAG: ULONG = 0x00000080; +pub const DS_WRITABLE_FLAG: ULONG = 0x00000100; +pub const DS_GOOD_TIMESERV_FLAG: ULONG = 0x00000200; +pub const DS_NDNC_FLAG: ULONG = 0x00000400; +pub const DS_SELECT_SECRET_DOMAIN_6_FLAG: ULONG = 0x00000800; +pub const DS_FULL_SECRET_DOMAIN_6_FLAG: ULONG = 0x00001000; +pub const DS_WS_FLAG: ULONG = 0x00002000; +pub const DS_DS_8_FLAG: ULONG = 0x00004000; +pub const DS_DS_9_FLAG: ULONG = 0x00008000; +pub const DS_DS_10_FLAG: ULONG = 0x00010000; +pub const DS_PING_FLAGS: ULONG = 0x000FFFFF; +pub const DS_DNS_CONTROLLER_FLAG: ULONG = 0x20000000; +pub const DS_DNS_DOMAIN_FLAG: ULONG = 0x40000000; +pub const DS_DNS_FOREST_FLAG: ULONG = 0x80000000; +extern "system" { + pub fn DsGetDcNameA( + ComputerName: LPCSTR, + DomainName: LPCSTR, + DomainGuid: *mut GUID, + SiteName: LPCSTR, + Flags: ULONG, + DomainControllerInfo: *mut PDOMAIN_CONTROLLER_INFOA, + ) -> DWORD; + pub fn DsGetDcNameW( + ComputerName: LPCWSTR, + DomainName: LPCWSTR, + DomainGuid: *mut GUID, + SiteName: LPCWSTR, + Flags: ULONG, + DomainControllerInfo: *mut PDOMAIN_CONTROLLER_INFOW, + ) -> DWORD; + pub fn DsGetSiteNameA( + ComputerName: LPCSTR, + SiteName: *mut LPSTR, + ) -> DWORD; + pub fn DsGetSiteNameW( + ComputerName: LPCWSTR, + SiteName: *mut LPWSTR, + ) -> DWORD; + pub fn DsValidateSubnetNameW( + SubnetName: LPCWSTR, + ) -> DWORD; + pub fn DsValidateSubnetNameA( + SubnetName: LPCSTR, + ) -> DWORD; + pub fn DsAddressToSiteNamesW( + ComputerName: LPCWSTR, + EntryCount: DWORD, + SocketAddresses: PSOCKET_ADDRESS, + SiteNames: *mut *mut LPWSTR, + ) -> DWORD; + pub fn DsAddressToSiteNamesA( + ComputerName: LPCSTR, + EntryCount: DWORD, + SocketAddresses: PSOCKET_ADDRESS, + SiteNames: *mut *mut LPSTR, + ) -> DWORD; + pub fn DsAddressToSiteNamesExW( + ComputerName: LPCWSTR, + EntryCount: DWORD, + SocketAddresses: PSOCKET_ADDRESS, + SiteNames: *mut *mut LPWSTR, + SubnetNames: *mut *mut LPWSTR, + ) -> DWORD; + pub fn DsAddressToSiteNamesExA( + ComputerName: LPCSTR, + EntryCount: DWORD, + SocketAddresses: PSOCKET_ADDRESS, + SiteNames: *mut *mut LPSTR, + SubnetNames: *mut *mut LPSTR, + ) -> DWORD; +} +pub const DS_DOMAIN_IN_FOREST: ULONG = 0x0001; +pub const DS_DOMAIN_DIRECT_OUTBOUND: ULONG = 0x0002; +pub const DS_DOMAIN_TREE_ROOT: ULONG = 0x0004; +pub const DS_DOMAIN_PRIMARY: ULONG = 0x0008; +pub const DS_DOMAIN_NATIVE_MODE: ULONG = 0x0010; +pub const DS_DOMAIN_DIRECT_INBOUND: ULONG = 0x0020; +pub const DS_DOMAIN_VALID_FLAGS: ULONG = DS_DOMAIN_IN_FOREST | DS_DOMAIN_DIRECT_OUTBOUND + | DS_DOMAIN_TREE_ROOT | DS_DOMAIN_PRIMARY | DS_DOMAIN_NATIVE_MODE | DS_DOMAIN_DIRECT_INBOUND; +STRUCT!{struct DS_DOMAIN_TRUSTSW { + NetbiosDomainName: LPWSTR, + DnsDomainName: LPWSTR, + Flags: ULONG, + ParentIndex: ULONG, + TrustType: ULONG, + TrustAttributes: ULONG, + DomainSid: PSID, + DomainGuid: GUID, +}} +pub type PDS_DOMAIN_TRUSTSW = *mut DS_DOMAIN_TRUSTSW; +STRUCT!{struct DS_DOMAIN_TRUSTSA { + NetbiosDomainName: LPSTR, + DnsDomainName: LPSTR, + Flags: ULONG, + ParentIndex: ULONG, + TrustType: ULONG, + TrustAttributes: ULONG, + DomainSid: PSID, + DomainGuid: GUID, +}} +pub type PDS_DOMAIN_TRUSTSA = *mut DS_DOMAIN_TRUSTSA; +extern "system" { + pub fn DsEnumerateDomainTrustsW( + ServerName: LPWSTR, + Flags: ULONG, + Domains: *mut PDS_DOMAIN_TRUSTSW, + DomainCount: PULONG, + ) -> DWORD; + pub fn DsEnumerateDomainTrustsA( + ServerName: LPSTR, + Flags: ULONG, + Domains: *mut PDS_DOMAIN_TRUSTSA, + DomainCount: PULONG, + ) -> DWORD; + pub fn DsGetForestTrustInformationW( + ServerName: LPCWSTR, + TrustedDomainName: LPCWSTR, + Flags: DWORD, + ForestTrustInfo: *mut PLSA_FOREST_TRUST_INFORMATION, + ) -> DWORD; + pub fn DsMergeForestTrustInformationW( + DomainName: LPCWSTR, + NewForestTrustInfo: PLSA_FOREST_TRUST_INFORMATION, + OldForestTrustInfo: PLSA_FOREST_TRUST_INFORMATION, + MergedForestTrustInfo: *mut PLSA_FOREST_TRUST_INFORMATION, + ) -> DWORD; + pub fn DsGetDcSiteCoverageW( + ServerName: LPCWSTR, + EntryCount: PULONG, + SiteNames: *mut *mut LPWSTR, + ) -> DWORD; + pub fn DsGetDcSiteCoverageA( + ServerName: LPCSTR, + EntryCount: PULONG, + SiteNames: *mut *mut LPSTR, + ) -> DWORD; + pub fn DsDeregisterDnsHostRecordsW( + ServerName: LPWSTR, + DnsDomainName: LPWSTR, + DomainGuid: *mut GUID, + DsaGuid: *mut GUID, + DnsHostName: LPWSTR, + ) -> DWORD; + pub fn DsDeregisterDnsHostRecordsA( + ServerName: LPSTR, + DnsDomainName: LPSTR, + DomainGuid: *mut GUID, + DsaGuid: *mut GUID, + DnsHostName: LPSTR, + ) -> DWORD; +} +pub const DS_ONLY_DO_SITE_NAME: ULONG = 0x01; +pub const DS_NOTIFY_AFTER_SITE_RECORDS: ULONG = 0x02; +pub const DS_OPEN_VALID_OPTION_FLAGS: ULONG = DS_ONLY_DO_SITE_NAME + | DS_NOTIFY_AFTER_SITE_RECORDS; +pub const DS_OPEN_VALID_FLAGS: ULONG = DS_FORCE_REDISCOVERY | DS_ONLY_LDAP_NEEDED + | DS_KDC_REQUIRED | DS_PDC_REQUIRED | DS_GC_SERVER_REQUIRED | DS_WRITABLE_REQUIRED; +extern "system" { + pub fn DsGetDcOpenW( + DnsName: LPCWSTR, + OptionFlags: ULONG, + SiteName: LPCWSTR, + DomainGuid: *mut GUID, + DnsForestName: LPCWSTR, + DcFlags: ULONG, + RetGetDcContext: PHANDLE, + ) -> DWORD; + pub fn DsGetDcOpenA( + DnsName: LPCSTR, + OptionFlags: ULONG, + SiteName: LPCSTR, + DomainGuid: *mut GUID, + DnsForestName: LPCSTR, + DcFlags: ULONG, + RetGetDcContext: PHANDLE, + ) -> DWORD; + pub fn DsGetDcNextA( + GetDcContextHandle: HANDLE, + SockAddressCount: PULONG, + SockAddresses: *mut LPSOCKET_ADDRESS, + DnsHostName: *mut LPSTR, + ) -> DWORD; + pub fn DsGetDcNextW( + GetDcContextHandle: HANDLE, + SockAddressCount: PULONG, + SockAddresses: *mut LPSOCKET_ADDRESS, + DnsHostName: *mut LPWSTR, + ) -> DWORD; + pub fn DsGetDcCloseW( + GetDcContextHandle: HANDLE, + ); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dsound.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dsound.rs new file mode 100644 index 0000000..9c23bbf --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dsound.rs @@ -0,0 +1,342 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! DSound procedure declarations, constant definitions and macros +use shared::guiddef::{GUID, LPCGUID, LPGUID}; +use shared::minwindef::{DWORD, LPDWORD, LPLONG, LPVOID}; +use shared::windef::HWND; +use shared::winerror::{E_FAIL, S_OK}; +use um::mmsystem::{LPCWAVEFORMATEX, LPWAVEFORMATEX}; +use um::unknwnbase::{IUnknown, IUnknownVtbl, LPUNKNOWN}; +use um::winnt::{HRESULT, LONG}; +DEFINE_GUID!{CLSID_DirectSound, + 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} +DEFINE_GUID!{CLSID_DirectSound8, + 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b} +DEFINE_GUID!{CLSID_DirectSoundCapture, + 0xb0210780, 0x89cd, 0x11d0, 0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16} +DEFINE_GUID!{CLSID_DirectSoundCapture8, + 0xe4bcac13, 0x7f99, 0x4908, 0x9a, 0x8e, 0x74, 0xe3, 0xbf, 0x24, 0xb6, 0xe1} +DEFINE_GUID!{CLSID_DirectSoundFullDuplex, + 0xfea4300c, 0x7959, 0x4147, 0xb2, 0x6a, 0x23, 0x77, 0xb9, 0xe7, 0xa9, 0x1d} +DEFINE_GUID!{DSDEVID_DefaultPlayback, + 0xdef00000, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03} +DEFINE_GUID!{DSDEVID_DefaultCapture, + 0xdef00001, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03} +DEFINE_GUID!{DSDEVID_DefaultVoicePlayback, + 0xdef00002, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03} +DEFINE_GUID!{DSDEVID_DefaultVoiceCapture, + 0xdef00003, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03} +STRUCT!{struct DSCAPS { + dwSize: DWORD, + dwFlags: DWORD, + dwMinSecondarySampleRate: DWORD, + dwMaxSecondarySampleRate: DWORD, + dwPrimaryBuffers: DWORD, + dwMaxHwMixingAllBuffers: DWORD, + dwMaxHwMixingStaticBuffers: DWORD, + dwMaxHwMixingStreamingBuffers: DWORD, + dwFreeHwMixingAllBuffers: DWORD, + dwFreeHwMixingStaticBuffers: DWORD, + dwFreeHwMixingStreamingBuffers: DWORD, + dwMaxHw3DAllBuffers: DWORD, + dwMaxHw3DStaticBuffers: DWORD, + dwMaxHw3DStreamingBuffers: DWORD, + dwFreeHw3DAllBuffers: DWORD, + dwFreeHw3DStaticBuffers: DWORD, + dwFreeHw3DStreamingBuffers: DWORD, + dwTotalHwMemBytes: DWORD, + dwFreeHwMemBytes: DWORD, + dwMaxContigFreeHwMemBytes: DWORD, + dwUnlockTransferRateHwBuffers: DWORD, + dwPlayCpuOverheadSwBuffers: DWORD, + dwReserved1: DWORD, + dwReserved2: DWORD, +}} +pub type LPDSCAPS = *mut DSCAPS; +STRUCT!{struct DSBCAPS { + dwSize: DWORD, + dwFlags: DWORD, + dwBufferBytes: DWORD, + dwUnlockTransferRate: DWORD, + dwPlayCpuOverhead: DWORD, +}} +pub type LPDSBCAPS = *mut DSBCAPS; +STRUCT!{struct DSBUFFERDESC { + dwSize: DWORD, + dwFlags: DWORD, + dwBufferBytes: DWORD, + dwReserved: DWORD, + lpwfxFormat: LPWAVEFORMATEX, + guid3DAlgorithm: GUID, +}} +pub type LPCDSBUFFERDESC = *const DSBUFFERDESC; +RIDL!{#[uuid(0x279afa85, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60)] +interface IDirectSoundBuffer(IDirectSoundBufferVtbl): IUnknown(IUnknownVtbl) { + fn GetCaps( + pDSBufferCaps: LPDSBCAPS, + ) -> HRESULT, + fn GetCurrentPosition( + pdwCurrentPlayCursor: LPDWORD, + pdwCurrentWriteCursor: LPDWORD, + ) -> HRESULT, + fn GetFormat( + pwfxFormat: LPWAVEFORMATEX, + dwSizeAllocated: DWORD, + pdwSizeWritten: LPDWORD, + ) -> HRESULT, + fn GetVolume( + plVolume: LPLONG, + ) -> HRESULT, + fn GetPan( + plPan: LPLONG, + ) -> HRESULT, + fn GetFrequency( + pdwFrequency: LPDWORD, + ) -> HRESULT, + fn GetStatus( + pdwStatus: LPDWORD, + ) -> HRESULT, + fn Initialize( + pDirectSound: LPDIRECTSOUND, + pcDSBufferDesc: LPCDSBUFFERDESC, + ) -> HRESULT, + fn Lock( + dwOffset: DWORD, + dwBytes: DWORD, + ppvAudioPtr1: *mut LPVOID, + pdwAudioBytes1: LPDWORD, + ppvAudioPtr2: *mut LPVOID, + pdwAudioBytes2: LPDWORD, + dwFlags: DWORD, + ) -> HRESULT, + fn Play( + dwReserved1: DWORD, + dwPriority: DWORD, + dwFlags: DWORD, + ) -> HRESULT, + fn SetCurrentPosition( + dwNewPosition: DWORD, + ) -> HRESULT, + fn SetFormat( + pcfxFormat: LPCWAVEFORMATEX, + ) -> HRESULT, + fn SetVolume( + lVolume: LONG, + ) -> HRESULT, + fn SetPan( + lPan: LONG, + ) -> HRESULT, + fn SetFrequency( + dwFrequency: DWORD, + ) -> HRESULT, + fn Stop() -> HRESULT, + fn Unlock( + pvAudioPtr1: LPVOID, + dwAudioBytes1: DWORD, + pvAudioPtr2: LPVOID, + dwAudioBytes2: DWORD, + ) -> HRESULT, + fn Restore() -> HRESULT, +}} +pub type LPDIRECTSOUNDBUFFER = *mut IDirectSoundBuffer; +DEFINE_GUID!{IID_IReferenceClock, + 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70} +DEFINE_GUID!{IID_IDirectSound, + 0x279afa83, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60} +RIDL!{#[uuid(0x279afa83, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60)] +interface IDirectSound(IDirectSoundVtbl): IUnknown(IUnknownVtbl) { + fn CreateSoundBuffer( + pcDSBufferDesc: LPCDSBUFFERDESC, + ppDSBuffer: *mut LPDIRECTSOUNDBUFFER, + pUnkOuter: LPUNKNOWN, + ) -> HRESULT, + fn GetCaps( + pDSCaps: LPDSCAPS, + ) -> HRESULT, + fn DuplicateSoundBuffer( + pDSBufferOriginal: LPDIRECTSOUNDBUFFER, + ppDSBufferDuplicate: *mut LPDIRECTSOUNDBUFFER, + ) -> HRESULT, + fn SetCooperativeLevel( + hWnd: HWND, + dwLevel: DWORD, + ) -> HRESULT, + fn Compact() -> HRESULT, + fn GetSpeakerConfig( + pdwSpeakerConfig: LPDWORD, + ) -> HRESULT, + fn SetSpeakerConfig( + dwSpeakerConfig: DWORD, + ) -> HRESULT, + fn Initialize( + pcGuidDevice: LPCGUID, + ) -> HRESULT, +}} +pub type LPDIRECTSOUND = *mut IDirectSound; +DEFINE_GUID!{IID_IDirectSound8, + 0xc50a7e93, 0xf395, 0x4834, 0x9e, 0xf6, 0x7f, 0xa9, 0x9d, 0xe5, 0x09, 0x66} +DEFINE_GUID!{IID_IDirectSoundBuffer, + 0x279afa85, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60} +DEFINE_GUID!{IID_IDirectSoundBuffer8, + 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e} +DEFINE_GUID!{GUID_All_Objects, + 0xaa114de5, 0xc262, 0x4169, 0xa1, 0xc8, 0x23, 0xd6, 0x98, 0xcc, 0x73, 0xb5} +DEFINE_GUID!{IID_IDirectSound3DListener, + 0x279afa84, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60} +DEFINE_GUID!{IID_IDirectSound3DBuffer, + 0x279afa86, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60} +DEFINE_GUID!{IID_IDirectSoundCapture, + 0xb0210781, 0x89cd, 0x11d0, 0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16} +DEFINE_GUID!{IID_IDirectSoundCaptureBuffer, + 0xb0210782, 0x89cd, 0x11d0, 0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16} +DEFINE_GUID!{IID_IDirectSoundCaptureBuffer8, + 0x00990df4, 0x0dbb, 0x4872, 0x83, 0x3e, 0x6d, 0x30, 0x3e, 0x80, 0xae, 0xb6} +DEFINE_GUID!{IID_IDirectSoundNotify, + 0xb0210783, 0x89cd, 0x11d0, 0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16} +DEFINE_GUID!{IID_IKsPropertySet, + 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93} +DEFINE_GUID!{IID_IDirectSoundFXGargle, + 0xd616f352, 0xd622, 0x11ce, 0xaa, 0xc5, 0x00, 0x20, 0xaf, 0x0b, 0x99, 0xa3} +DEFINE_GUID!{IID_IDirectSoundFXChorus, + 0x880842e3, 0x145f, 0x43e6, 0xa9, 0x34, 0xa7, 0x18, 0x06, 0xe5, 0x05, 0x47} +DEFINE_GUID!{IID_IDirectSoundFXFlanger, + 0x903e9878, 0x2c92, 0x4072, 0x9b, 0x2c, 0xea, 0x68, 0xf5, 0x39, 0x67, 0x83} +DEFINE_GUID!{IID_IDirectSoundFXEcho, + 0x8bd28edf, 0x50db, 0x4e92, 0xa2, 0xbd, 0x44, 0x54, 0x88, 0xd1, 0xed, 0x42} +DEFINE_GUID!{IID_IDirectSoundFXDistortion, + 0x8ecf4326, 0x455f, 0x4d8b, 0xbd, 0xa9, 0x8d, 0x5d, 0x3e, 0x9e, 0x3e, 0x0b} +DEFINE_GUID!{IID_IDirectSoundFXCompressor, + 0x4bbd1154, 0x62f6, 0x4e2c, 0xa1, 0x5c, 0xd3, 0xb6, 0xc4, 0x17, 0xf7, 0xa0} +DEFINE_GUID!{IID_IDirectSoundFXParamEq, + 0xc03ca9fe, 0xfe90, 0x4204, 0x80, 0x78, 0x82, 0x33, 0x4c, 0xd1, 0x77, 0xda} +DEFINE_GUID!{IID_IDirectSoundFXI3DL2Reverb, + 0x4b166a6a, 0x0d66, 0x43f3, 0x80, 0xe3, 0xee, 0x62, 0x80, 0xde, 0xe1, 0xa4} +DEFINE_GUID!{IID_IDirectSoundFXWavesReverb, + 0x46858c3a, 0x0dc6, 0x45e3, 0xb7, 0x60, 0xd4, 0xee, 0xf1, 0x6c, 0xb3, 0x25} +DEFINE_GUID!{IID_IDirectSoundCaptureFXAec, + 0xad74143d, 0x903d, 0x4ab7, 0x80, 0x66, 0x28, 0xd3, 0x63, 0x03, 0x6d, 0x65} +DEFINE_GUID!{IID_IDirectSoundCaptureFXNoiseSuppress, + 0xed311e41, 0xfbae, 0x4175, 0x96, 0x25, 0xcd, 0x08, 0x54, 0xf6, 0x93, 0xca} +DEFINE_GUID!{IID_IDirectSoundFullDuplex, + 0xedcb4c7a, 0xdaab, 0x4216, 0xa4, 0x2e, 0x6c, 0x50, 0x59, 0x6d, 0xdc, 0x1d} +pub const DS_OK: HRESULT = S_OK; +pub const DSERR_GENERIC: HRESULT = E_FAIL; +pub const DSSCL_NORMAL: DWORD = 0x00000001; +pub const DSSCL_PRIORITY: DWORD = 0x00000002; +pub const DSSCL_EXCLUSIVE: DWORD = 0x00000003; +pub const DSSCL_WRITEPRIMARY: DWORD = 0x00000004; +pub const DSBCAPS_PRIMARYBUFFER: DWORD = 0x00000001; +pub const DSBCAPS_STATIC: DWORD = 0x00000002; +pub const DSBCAPS_LOCHARDWARE: DWORD = 0x00000004; +pub const DSBCAPS_LOCSOFTWARE: DWORD = 0x00000008; +pub const DSBCAPS_CTRL3D: DWORD = 0x00000010; +pub const DSBCAPS_CTRLFREQUENCY: DWORD = 0x00000020; +pub const DSBCAPS_CTRLPAN: DWORD = 0x00000040; +pub const DSBCAPS_CTRLVOLUME: DWORD = 0x00000080; +pub const DSBCAPS_CTRLPOSITIONNOTIFY: DWORD = 0x00000100; +pub const DSBCAPS_CTRLFX: DWORD = 0x00000200; +pub const DSBCAPS_STICKYFOCUS: DWORD = 0x00004000; +pub const DSBCAPS_GLOBALFOCUS: DWORD = 0x00008000; +pub const DSBCAPS_GETCURRENTPOSITION2: DWORD = 0x00010000; +pub const DSBCAPS_MUTE3DATMAXDISTANCE: DWORD = 0x00020000; +pub const DSBCAPS_LOCDEFER: DWORD = 0x00040000; +pub const DSBCAPS_TRUEPLAYPOSITION: DWORD = 0x00080000; +pub const DSBPLAY_LOOPING: DWORD = 0x00000001; +pub const DSBPLAY_LOCHARDWARE: DWORD = 0x00000002; +pub const DSBPLAY_LOCSOFTWARE: DWORD = 0x00000004; +pub const DSBPLAY_TERMINATEBY_TIME: DWORD = 0x00000008; +pub const DSBPLAY_TERMINATEBY_DISTANCE: DWORD = 0x000000010; +pub const DSBPLAY_TERMINATEBY_PRIORITY: DWORD = 0x000000020; +extern "system" { + pub fn DirectSoundCreate( + pcGuidDevice: LPCGUID, + ppDS: *mut LPDIRECTSOUND, + pUnkOuter: LPUNKNOWN, + ) -> HRESULT; + // pub fn DirectSoundEnumerateA( + // pDSEnumCallback: LPDSENUMCALLBACKA, + // pContext: LPVOID, + // ) -> HRESULT; + // pub fn DirectSoundEnumerateW( + // pDSEnumCallback: LPDSENUMCALLBACKW, + // pContext: LPVOID, + // ) -> HRESULT; + // pub fn DirectSoundCaptureCreate( + // pcGuidDevice: LPCGUID, + // ppDSC: *mut LPDIRECTSOUNDCAPTURE, + // pUnkOuter: LPUNKNOWN, + // ) -> HRESULT; + // pub fn DirectSoundCaptureEnumerateA( + // pDSEnumCallback: LPDSENUMCALLBACKA, + // pContext: LPVOID, + // ) -> HRESULT; + // pub fn DirectSoundCaptureEnumerateW( + // pDSEnumCallback: LPDSENUMCALLBACKW, + // pContext: LPVOID, + // ) -> HRESULT; + // pub fn DirectSoundCreate8( + // pcGuidDevice: LPCGUID, + // ppDS8: *mut LPDIRECTSOUND8, + // pUnkOuter: LPUNKNOWN, + // ) -> HRESULT; + // pub fn DirectSoundCaptureCreate8( + // pcGuidDevice: LPCGUID, + // ppDSC8: *mut LPDIRECTSOUNDCAPTURE8, + // pUnkOuter: LPUNKNOWN, + // ) -> HRESULT; + // pub fn DirectSoundFullDuplexCreate( + // pcGuidCaptureDevice: LPCGUID, + // pcGuidRenderDevice: LPCGUID, + // pcDSCBufferDesc: LPCDSCBUFFERDESC, + // pcDSBufferDesc: LPCDSBUFFERDESC, + // hWnd: HWND, + // dwLevel: DWORD, + // ppDSFD: *mut LPDIRECTSOUNDFULLDUPLEX, + // ppDSCBuffer8: *mut LPDIRECTSOUNDCAPTUREBUFFER8, + // ppDSBuffer8: *mut LPDIRECTSOUNDBUFFER8, + // pUnkOuter: LPUNKNOWN, + // ) -> HRESULT; + pub fn GetDeviceID( + pGuidSrc: LPCGUID, + pGuidDest: LPGUID, + ) -> HRESULT; +} +DEFINE_GUID!{DS3DALG_NO_VIRTUALIZATION, + 0xc241333f, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x00, 0xc0, 0x4f, 0xc2, 0x8a, 0xca} +DEFINE_GUID!{DS3DALG_HRTF_FULL, + 0xc2413340, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x00, 0xc0, 0x4f, 0xc2, 0x8a, 0xca} +DEFINE_GUID!{DS3DALG_HRTF_LIGHT, + 0xc2413342, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x00, 0xc0, 0x4f, 0xc2, 0x8a, 0xca} +DEFINE_GUID!{GUID_DSFX_STANDARD_GARGLE, + 0xdafd8210, 0x5711, 0x4b91, 0x9f, 0xe3, 0xf7, 0x5b, 0x7a, 0xe2, 0x79, 0xbf} +DEFINE_GUID!{GUID_DSFX_STANDARD_CHORUS, + 0xefe6629c, 0x81f7, 0x4281, 0xbd, 0x91, 0xc9, 0xd6, 0x04, 0xa9, 0x5a, 0xf6} +DEFINE_GUID!{GUID_DSFX_STANDARD_FLANGER, + 0xefca3d92, 0xdfd8, 0x4672, 0xa6, 0x03, 0x74, 0x20, 0x89, 0x4b, 0xad, 0x98} +DEFINE_GUID!{GUID_DSFX_STANDARD_ECHO, + 0xef3e932c, 0xd40b, 0x4f51, 0x8c, 0xcf, 0x3f, 0x98, 0xf1, 0xb2, 0x9d, 0x5d} +DEFINE_GUID!{GUID_DSFX_STANDARD_DISTORTION, + 0xef114c90, 0xcd1d, 0x484e, 0x96, 0xe5, 0x09, 0xcf, 0xaf, 0x91, 0x2a, 0x21} +DEFINE_GUID!{GUID_DSFX_STANDARD_COMPRESSOR, + 0xef011f79, 0x4000, 0x406d, 0x87, 0xaf, 0xbf, 0xfb, 0x3f, 0xc3, 0x9d, 0x57} +DEFINE_GUID!{GUID_DSFX_STANDARD_PARAMEQ, + 0x120ced89, 0x3bf4, 0x4173, 0xa1, 0x32, 0x3c, 0xb4, 0x06, 0xcf, 0x32, 0x31} +DEFINE_GUID!{GUID_DSFX_STANDARD_I3DL2REVERB, + 0xef985e71, 0xd5c7, 0x42d4, 0xba, 0x4d, 0x2d, 0x07, 0x3e, 0x2e, 0x96, 0xf4} +DEFINE_GUID!{GUID_DSFX_WAVES_REVERB, + 0x87fc0268, 0x9a55, 0x4360, 0x95, 0xaa, 0x00, 0x4a, 0x1d, 0x9d, 0xe2, 0x6c} +DEFINE_GUID!{GUID_DSCFX_CLASS_AEC, + 0xbf963d80, 0xc559, 0x11d0, 0x8a, 0x2b, 0x00, 0xa0, 0xc9, 0x25, 0x5a, 0xc1} +DEFINE_GUID!{GUID_DSCFX_MS_AEC, + 0xcdebb919, 0x379a, 0x488a, 0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40} +DEFINE_GUID!{GUID_DSCFX_SYSTEM_AEC, + 0x1c22c56d, 0x9879, 0x4f5b, 0xa3, 0x89, 0x27, 0x99, 0x6d, 0xdc, 0x28, 0x10} +DEFINE_GUID!{GUID_DSCFX_CLASS_NS, + 0xe07f903f, 0x62fd, 0x4e60, 0x8c, 0xdd, 0xde, 0xa7, 0x23, 0x66, 0x65, 0xb5} +DEFINE_GUID!{GUID_DSCFX_MS_NS, + 0x11c5c73b, 0x66e9, 0x4ba1, 0xa0, 0xba, 0xe8, 0x14, 0xc6, 0xee, 0xd9, 0x2d} +DEFINE_GUID!{GUID_DSCFX_SYSTEM_NS, + 0x5ab0882e, 0x7274, 0x4516, 0x87, 0x7d, 0x4e, 0xee, 0x99, 0xba, 0x4f, 0xd0} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dsrole.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dsrole.rs new file mode 100644 index 0000000..b644d79 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dsrole.rs @@ -0,0 +1,66 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Contains public interfaces to query the network roles of workstations, servers, and DCs +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, PBYTE, ULONG}; +use um::winnt::{LPCWSTR, LPWSTR, PVOID}; +ENUM!{enum DSROLE_MACHINE_ROLE { + DsRole_RoleStandaloneWorkstation, + DsRole_RoleMemberWorkstation, + DsRole_RoleStandaloneServer, + DsRole_RoleMemberServer, + DsRole_RoleBackupDomainController, + DsRole_RolePrimaryDomainController, +}} +ENUM!{enum DSROLE_SERVER_STATE { + DsRoleServerUnknown = 0, + DsRoleServerPrimary, + DsRoleServerBackup, +}} +pub type PDSROLE_SERVER_STATE = *mut DSROLE_SERVER_STATE; +ENUM!{enum DSROLE_PRIMARY_DOMAIN_INFO_LEVEL { + DsRolePrimaryDomainInfoBasic = 1, + DsRoleUpgradeStatus, + DsRoleOperationState, +}} +pub const DSROLE_PRIMARY_DS_RUNNING: ULONG = 0x00000001; +pub const DSROLE_PRIMARY_DS_MIXED_MODE: ULONG = 0x00000002; +pub const DSROLE_UPGRADE_IN_PROGRESS: ULONG = 0x00000004; +pub const DSROLE_PRIMARY_DS_READONLY: ULONG = 0x00000008; +pub const DSROLE_PRIMARY_DOMAIN_GUID_PRESENT: ULONG = 0x01000000; +STRUCT!{struct DSROLE_PRIMARY_DOMAIN_INFO_BASIC { + MachineRole: DSROLE_MACHINE_ROLE, + Flags: ULONG, + DomainNameFlat: LPWSTR, + DomainNameDns: LPWSTR, + DomainForestName: LPWSTR, + DomainGuid: GUID, +}} +pub type PDSROLE_PRIMARY_DOMAIN_INFO_BASIC = *mut DSROLE_PRIMARY_DOMAIN_INFO_BASIC; +STRUCT!{struct DSROLE_UPGRADE_STATUS_INFO { + OperationState: ULONG, + PreviousServerState: DSROLE_SERVER_STATE, +}} +pub type PDSROLE_UPGRADE_STATUS_INFO = *mut DSROLE_UPGRADE_STATUS_INFO; +ENUM!{enum DSROLE_OPERATION_STATE { + DsRoleOperationIdle = 0, + DsRoleOperationActive, + DsRoleOperationNeedReboot, +}} +STRUCT!{struct DSROLE_OPERATION_STATE_INFO { + OperationState: DSROLE_OPERATION_STATE, +}} +pub type PDSROLE_OPERATION_STATE_INFO = *mut DSROLE_OPERATION_STATE_INFO; +extern "system" { + pub fn DsRoleGetPrimaryDomainInformation( + lpServer: LPCWSTR, + InfoLevel: DSROLE_PRIMARY_DOMAIN_INFO_LEVEL, + Buffer: *mut PBYTE, + ) -> DWORD; + pub fn DsRoleFreeMemory( + Buffer: PVOID, + ); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dvp.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dvp.rs new file mode 100644 index 0000000..5760732 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dvp.rs @@ -0,0 +1,25 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_IDDVideoPortContainer, + 0x6c142760, 0xa733, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60} +DEFINE_GUID!{IID_IDirectDrawVideoPort, + 0xb36d93e0, 0x2b43, 0x11cf, 0xa2, 0xde, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56} +DEFINE_GUID!{IID_IDirectDrawVideoPortNotify, + 0xa655fb94, 0x0589, 0x4e57, 0xb3, 0x33, 0x56, 0x7a, 0x89, 0x46, 0x8c, 0x88} +DEFINE_GUID!{DDVPTYPE_E_HREFH_VREFH, + 0x54f39980, 0xda60, 0x11cf, 0x9b, 0x06, 0x00, 0xa0, 0xc9, 0x03, 0xa3, 0xb8} +DEFINE_GUID!{DDVPTYPE_E_HREFH_VREFL, + 0x92783220, 0xda60, 0x11cf, 0x9b, 0x06, 0x00, 0xa0, 0xc9, 0x03, 0xa3, 0xb8} +DEFINE_GUID!{DDVPTYPE_E_HREFL_VREFH, + 0xa07a02e0, 0xda60, 0x11cf, 0x9b, 0x06, 0x00, 0xa0, 0xc9, 0x03, 0xa3, 0xb8} +DEFINE_GUID!{DDVPTYPE_E_HREFL_VREFL, + 0xe09c77e0, 0xda60, 0x11cf, 0x9b, 0x06, 0x00, 0xa0, 0xc9, 0x03, 0xa3, 0xb8} +DEFINE_GUID!{DDVPTYPE_CCIR656, + 0xfca326a0, 0xda60, 0x11cf, 0x9b, 0x06, 0x00, 0xa0, 0xc9, 0x03, 0xa3, 0xb8} +DEFINE_GUID!{DDVPTYPE_BROOKTREE, + 0x1352a560, 0xda61, 0x11cf, 0x9b, 0x06, 0x00, 0xa0, 0xc9, 0x03, 0xa3, 0xb8} +DEFINE_GUID!{DDVPTYPE_PHILIPS, + 0x332cf160, 0xda61, 0x11cf, 0x9b, 0x06, 0x00, 0xa0, 0xc9, 0x03, 0xa3, 0xb8} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dwmapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dwmapi.rs new file mode 100644 index 0000000..475473f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dwmapi.rs @@ -0,0 +1,295 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Procedure declarations, constant definitions, and macros for the NLS component. +use shared::basetsd::UINT32; +use shared::minwindef::{ + BOOL, BYTE, DWORD, HRGN, INT, LPARAM, LPCVOID, LPVOID, LRESULT, UINT, WPARAM +}; +use shared::windef::{HBITMAP, HWND, POINT, PSIZE, RECT}; +use um::uxtheme::MARGINS; +use um::winnt::{HANDLE, HRESULT, ULONGLONG}; +pub const DWM_BB_ENABLE: DWORD = 0x00000001; +pub const DWM_BB_BLURREGION: DWORD = 0x00000002; +pub const DWM_BB_TRANSITIONONMAXIMIZED: DWORD = 0x00000004; +STRUCT!{#[repr(packed)] struct DWM_BLURBEHIND { + dwFlags: DWORD, + fEnable: BOOL, + hRgnBlur: HRGN, + fTransitionOnMaximized: BOOL, +}} +ENUM!{enum DWMWINDOWATTRIBUTE { + DWMWA_NCRENDERING_ENABLED = 1, + DWMWA_NCRENDERING_POLICY = 2, + DWMWA_TRANSITIONS_FORCEDISABLED = 3, + DWMWA_ALLOW_NCPAINT = 4, + DWMWA_CAPTION_BUTTON_BOUNDS = 5, + DWMWA_NONCLIENT_RTL_LAYOUT = 6, + DWMWA_FORCE_ICONIC_REPRESENTATION = 7, + DWMWA_FLIP3D_POLICY = 8, + DWMWA_EXTENDED_FRAME_BOUNDS = 9, + DWMWA_HAS_ICONIC_BITMAP = 10, + DWMWA_DISALLOW_PEEK = 11, + DWMWA_EXCLUDED_FROM_PEEK = 12, + DWMWA_CLOAK = 13, + DWMWA_CLOAKED = 14, + DWMWA_FREEZE_REPRESENTATION = 15, + DWMWA_LAST = 16, +}} +ENUM!{enum DWMNCRENDERINGPOLICY { + DWMNCRP_USEWINDOWSTYLE = 0, + DWMNCRP_DISABLED = 1, + DWMNCRP_ENABLED = 2, + DWMNCRP_LAST = 3, +}} +ENUM!{enum DWMFLIP3DWINDOWPOLICY { + DWMFLIP3D_DEFAULT = 0, + DWMFLIP3D_EXCLUDEBELOW = 1, + DWMFLIP3D_EXCLUDEABOVE = 2, + DWMFLIP3D_LAST = 3, +}} +pub const DWM_CLOAKED_APP: u32 = 0x00000001; +pub const DWM_CLOAKED_SHELL: u32 = 0x00000002; +pub const DWM_CLOAKED_INHERITED: u32 = 0x00000004; +pub type HTHUMBNAIL = HANDLE; +pub type PHTHUMBNAIL = *mut HTHUMBNAIL; +pub const DWM_TNP_RECTDESTINATION: DWORD = 0x00000001; +pub const DWM_TNP_RECTSOURCE: DWORD = 0x00000002; +pub const DWM_TNP_OPACITY: DWORD = 0x00000004; +pub const DWM_TNP_VISIBLE: DWORD = 0x00000008; +pub const DWM_TNP_SOURCECLIENTAREAONLY: DWORD = 0x00000010; +STRUCT!{#[repr(packed)] struct DWM_THUMBNAIL_PROPERTIES { + dwFlags: DWORD, + rcDestination: RECT, + rcSource: RECT, + opacity: BYTE, + fVisible: BOOL, + fSourceClientAreaOnly: BOOL, +}} +pub type PDWM_THUMBNAIL_PROPERTIES = *mut DWM_THUMBNAIL_PROPERTIES; +pub type DWM_FRAME_COUNT = ULONGLONG; +pub type QPC_TIME = ULONGLONG; +STRUCT!{#[repr(packed)] struct UNSIGNED_RATIO { + uiNumerator: UINT32, + uiDenominator: UINT32, +}} +STRUCT!{#[repr(packed)] struct DWM_TIMING_INFO { + cbSize: UINT32, + rateRefresh: UNSIGNED_RATIO, + qpcRefreshPeriod: QPC_TIME, + rateCompose: UNSIGNED_RATIO, + qpcVBlank: QPC_TIME, + cRefresh: DWM_FRAME_COUNT, + cDXRefresh: UINT, + qpcCompose: QPC_TIME, + cFrame: DWM_FRAME_COUNT, + cDXPresent: UINT, + cRefreshFrame: DWM_FRAME_COUNT, + cFrameSubmitted: DWM_FRAME_COUNT, + cDXPresentSubmitted: UINT, + cFrameConfirmed: DWM_FRAME_COUNT, + cDXPresentConfirmed: UINT, + cRefreshConfirmed: DWM_FRAME_COUNT, + cDXRefreshConfirmed: UINT, + cFramesLate: DWM_FRAME_COUNT, + cFramesOutstanding: UINT, + cFrameDisplayed: DWM_FRAME_COUNT, + qpcFrameDisplayed: QPC_TIME, + cRefreshFrameDisplayed: DWM_FRAME_COUNT, + cFrameComplete: DWM_FRAME_COUNT, + qpcFrameComplete: QPC_TIME, + cFramePending: DWM_FRAME_COUNT, + qpcFramePending: QPC_TIME, + cFramesDisplayed: DWM_FRAME_COUNT, + cFramesComplete: DWM_FRAME_COUNT, + cFramesPending: DWM_FRAME_COUNT, + cFramesAvailable: DWM_FRAME_COUNT, + cFramesDropped: DWM_FRAME_COUNT, + cFramesMissed: DWM_FRAME_COUNT, + cRefreshNextDisplayed: DWM_FRAME_COUNT, + cRefreshNextPresented: DWM_FRAME_COUNT, + cRefreshesDisplayed: DWM_FRAME_COUNT, + cRefreshesPresented: DWM_FRAME_COUNT, + cRefreshStarted: DWM_FRAME_COUNT, + cPixelsReceived: ULONGLONG, + cPixelsDrawn: ULONGLONG, + cBuffersEmpty: DWM_FRAME_COUNT, +}} +ENUM!{enum DWM_SOURCE_FRAME_SAMPLING { + DWM_SOURCE_FRAME_SAMPLING_POINT = 0, + DWM_SOURCE_FRAME_SAMPLING_COVERAGE = 1, + DWM_SOURCE_FRAME_SAMPLING_LAST = 2, +}} +// pub const c_DwmMaxQueuedBuffers: UINT = 8; +// pub const c_DwmMaxMonitors: UINT = 16; +// pub const c_DwmMaxAdapters: UINT = 16; +STRUCT!{#[repr(packed)] struct DWM_PRESENT_PARAMETERS { + cbSize: UINT32, + fQueue: BOOL, + cRefreshStart: DWM_FRAME_COUNT, + cBuffer: UINT, + fUseSourceRate: BOOL, + rateSource: UNSIGNED_RATIO, + cRefreshesPerFrame: UINT, + eSampling: DWM_SOURCE_FRAME_SAMPLING, +}} +// pub const DWM_FRAME_DURATION_DEFAULT: i32 = -1; +extern "system" { + pub fn DwmDefWindowProc( + hWnd: HWND, + msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + plResult: *mut LRESULT, + ) -> BOOL; + pub fn DwmEnableBlurBehindWindow( + hWnd: HWND, + pBlurBehind: *const DWM_BLURBEHIND, + ) -> HRESULT; +} +pub const DWM_EC_DISABLECOMPOSITION: UINT = 0; +pub const DWM_EC_ENABLECOMPOSITION: UINT = 1; +extern "system" { + pub fn DwmEnableComposition( + uCompositionAction: UINT, + ) -> HRESULT; + pub fn DwmEnableMMCSS( + fEnableMMCSS: BOOL, + ) -> HRESULT; + pub fn DwmExtendFrameIntoClientArea( + hWnd: HWND, + pMarInset: *const MARGINS, + ) -> HRESULT; + pub fn DwmGetColorizationColor( + pcrColorization: *mut DWORD, + pfOpaqueBlend: *mut BOOL, + ) -> HRESULT; + pub fn DwmGetCompositionTimingInfo( + hWnd: HWND, + pTimingInfo: *mut DWM_TIMING_INFO, + ) -> HRESULT; + pub fn DwmGetWindowAttribute( + hWnd: HWND, + dwAttribute: DWORD, + pvAttribute: LPVOID, + cbAttribute: DWORD, + ) -> HRESULT; + pub fn DwmIsCompositionEnabled( + pfEnabled: *mut BOOL, + ) -> HRESULT; + pub fn DwmModifyPreviousDxFrameDuration( + hwnd: HWND, + cRefreshes: INT, + fRelative: BOOL, + ) -> HRESULT; + pub fn DwmQueryThumbnailSourceSize( + hThumbnail: HTHUMBNAIL, + pSize: PSIZE, + ) -> HRESULT; + pub fn DwmRegisterThumbnail( + hwndDestination: HWND, + hwndSource: HWND, + phThumbnailId: PHTHUMBNAIL, + ) -> HRESULT; + pub fn DwmSetDxFrameDuration( + hwnd: HWND, + cRefreshes: INT, + ) -> HRESULT; + pub fn DwmSetPresentParameters( + hwnd: HWND, + pPresentParams: *mut DWM_PRESENT_PARAMETERS, + ) -> HRESULT; + pub fn DwmSetWindowAttribute( + hWnd: HWND, + dwAttribute: DWORD, + pvAttribute: LPCVOID, + cbAttribute: DWORD, + ) -> HRESULT; + pub fn DwmUnregisterThumbnail( + hThumbnailId: HTHUMBNAIL, + ) -> HRESULT; + pub fn DwmUpdateThumbnailProperties( + hThumbnailId: HTHUMBNAIL, + ptnProperties: *const DWM_THUMBNAIL_PROPERTIES, + ) -> HRESULT; +} +pub const DWM_SIT_DISPLAYFRAME: DWORD = 0x00000001; +extern "system" { + pub fn DwmSetIconicThumbnail( + hwnd: HWND, + hbmp: HBITMAP, + dwSITFlags: DWORD, + ) -> HRESULT; + pub fn DwmSetIconicLivePreviewBitmap( + hwnd: HWND, + hbmp: HBITMAP, + pptClient: *mut POINT, + dwSITFlags: DWORD, + ) -> HRESULT; + pub fn DwmInvalidateIconicBitmaps( + hwnd: HWND, + ) -> HRESULT; + // pub fn DwmAttachMilContent(hwnd: HWND) -> HRESULT; + // pub fn DwmDetachMilContent(hwnd: HWND) -> HRESULT; + pub fn DwmFlush() -> HRESULT; + // pub fn DwmGetGraphicsStreamTransformHint(); + // pub fn DwmGetGraphicsStreamClient(); + pub fn DwmGetTransportAttributes( + pfIsRemoting: *mut BOOL, + pfIsConnected: *mut BOOL, + pDwGeneration: *mut DWORD, + ) -> HRESULT; +} +ENUM!{enum DWMTRANSITION_OWNEDWINDOW_TARGET { + DWMTRANSITION_OWNEDWINDOW_NULL = -1i32 as u32, + DWMTRANSITION_OWNEDWINDOW_REPOSITION = 0, +}} +extern "system" { + pub fn DwmTransitionOwnedWindow( + hwnd: HWND, + target: DWMTRANSITION_OWNEDWINDOW_TARGET, + ) -> HRESULT; +} +ENUM!{enum GESTURE_TYPE { + GT_PEN_TAP = 0, + GT_PEN_DOUBLETAP = 1, + GT_PEN_RIGHTTAP = 2, + GT_PEN_PRESSANDHOLD = 3, + GT_PEN_PRESSANDHOLDABORT = 4, + GT_TOUCH_TAP = 5, + GT_TOUCH_DOUBLETAP = 6, + GT_TOUCH_RIGHTTAP = 7, + GT_TOUCH_PRESSANDHOLD = 8, + GT_TOUCH_PRESSANDHOLDABORT = 9, + GT_TOUCH_PRESSANDTAP = 10, +}} +extern "system" { + pub fn DwmRenderGesture( + gt: GESTURE_TYPE, + cContacts: UINT, + pdwPointerID: *const DWORD, + pPoints: *const POINT, + ) -> HRESULT; + pub fn DwmTetherContact( + dwPointerID: DWORD, + fEnable: BOOL, + ptTether: POINT, + ) -> HRESULT; +} +ENUM!{enum DWM_SHOWCONTACT { + DWMSC_DOWN = 0x00000001, + DWMSC_UP = 0x00000002, + DWMSC_DRAG = 0x00000004, + DWMSC_HOLD = 0x00000008, + DWMSC_PENBARREL = 0x00000010, + DWMSC_NONE = 0x00000000, + DWMSC_ALL = 0xFFFFFFFF, +}} +extern "system" { + pub fn DwmShowContact( + dwPointerID: DWORD, + eShowContact: DWM_SHOWCONTACT, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite.rs new file mode 100644 index 0000000..b21cd6f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite.rs @@ -0,0 +1,1477 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! DirectX Typography Services public API definitions. +use ctypes::c_void; +use shared::basetsd::{INT16, INT32, UINT16, UINT32, UINT64, UINT8}; +use shared::guiddef::REFIID; +use shared::minwindef::{BOOL, BYTE, FILETIME, FLOAT}; +use shared::windef::{COLORREF, HDC, HMONITOR, RECT, SIZE}; +use shared::winerror::SEVERITY_ERROR; +use um::d2d1::ID2D1SimplifiedGeometrySink; +use um::dcommon::DWRITE_MEASURING_MODE; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::wingdi::LOGFONTW; +use um::winnt::{HRESULT, WCHAR}; +ENUM!{enum DWRITE_FONT_FILE_TYPE { + DWRITE_FONT_FILE_TYPE_UNKNOWN, + DWRITE_FONT_FILE_TYPE_CFF, + DWRITE_FONT_FILE_TYPE_TRUETYPE, + DWRITE_FONT_FILE_TYPE_OPENTYPE_COLLECTION, + DWRITE_FONT_FILE_TYPE_TYPE1_PFM, + DWRITE_FONT_FILE_TYPE_TYPE1_PFB, + DWRITE_FONT_FILE_TYPE_VECTOR, + DWRITE_FONT_FILE_TYPE_BITMAP, + DWRITE_FONT_FILE_TYPE_TRUETYPE_COLLECTION = DWRITE_FONT_FILE_TYPE_OPENTYPE_COLLECTION, +}} +ENUM!{enum DWRITE_FONT_FACE_TYPE { + DWRITE_FONT_FACE_TYPE_CFF, + DWRITE_FONT_FACE_TYPE_TRUETYPE, + DWRITE_FONT_FACE_TYPE_OPENTYPE_COLLECTION, + DWRITE_FONT_FACE_TYPE_TYPE1, + DWRITE_FONT_FACE_TYPE_VECTOR, + DWRITE_FONT_FACE_TYPE_BITMAP, + DWRITE_FONT_FACE_TYPE_UNKNOWN, + DWRITE_FONT_FACE_TYPE_RAW_CFF, + DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION = DWRITE_FONT_FACE_TYPE_OPENTYPE_COLLECTION, +}} +ENUM!{enum DWRITE_FONT_SIMULATIONS { + DWRITE_FONT_SIMULATIONS_NONE = 0x0000, + DWRITE_FONT_SIMULATIONS_BOLD = 0x0001, + DWRITE_FONT_SIMULATIONS_OBLIQUE = 0x0002, +}} +ENUM!{enum DWRITE_FONT_WEIGHT { + DWRITE_FONT_WEIGHT_THIN = 100, + DWRITE_FONT_WEIGHT_EXTRA_LIGHT = 200, + DWRITE_FONT_WEIGHT_ULTRA_LIGHT = 200, + DWRITE_FONT_WEIGHT_LIGHT = 300, + DWRITE_FONT_WEIGHT_SEMI_LIGHT = 350, + DWRITE_FONT_WEIGHT_NORMAL = 400, + DWRITE_FONT_WEIGHT_REGULAR = 400, + DWRITE_FONT_WEIGHT_MEDIUM = 500, + DWRITE_FONT_WEIGHT_DEMI_BOLD = 600, + DWRITE_FONT_WEIGHT_SEMI_BOLD = 600, + DWRITE_FONT_WEIGHT_BOLD = 700, + DWRITE_FONT_WEIGHT_EXTRA_BOLD = 800, + DWRITE_FONT_WEIGHT_ULTRA_BOLD = 800, + DWRITE_FONT_WEIGHT_BLACK = 900, + DWRITE_FONT_WEIGHT_HEAVY = 900, + DWRITE_FONT_WEIGHT_EXTRA_BLACK = 950, + DWRITE_FONT_WEIGHT_ULTRA_BLACK = 950, +}} +ENUM!{enum DWRITE_FONT_STRETCH { + DWRITE_FONT_STRETCH_UNDEFINED = 0, + DWRITE_FONT_STRETCH_ULTRA_CONDENSED = 1, + DWRITE_FONT_STRETCH_EXTRA_CONDENSED = 2, + DWRITE_FONT_STRETCH_CONDENSED = 3, + DWRITE_FONT_STRETCH_SEMI_CONDENSED = 4, + DWRITE_FONT_STRETCH_NORMAL = 5, + DWRITE_FONT_STRETCH_MEDIUM = 5, + DWRITE_FONT_STRETCH_SEMI_EXPANDED = 6, + DWRITE_FONT_STRETCH_EXPANDED = 7, + DWRITE_FONT_STRETCH_EXTRA_EXPANDED = 8, + DWRITE_FONT_STRETCH_ULTRA_EXPANDED = 9, +}} +ENUM!{enum DWRITE_FONT_STYLE { + DWRITE_FONT_STYLE_NORMAL, + DWRITE_FONT_STYLE_OBLIQUE, + DWRITE_FONT_STYLE_ITALIC, +}} +ENUM!{enum DWRITE_INFORMATIONAL_STRING_ID { + DWRITE_INFORMATIONAL_STRING_NONE, + DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE, + DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS, + DWRITE_INFORMATIONAL_STRING_TRADEMARK, + DWRITE_INFORMATIONAL_STRING_MANUFACTURER, + DWRITE_INFORMATIONAL_STRING_DESIGNER, + DWRITE_INFORMATIONAL_STRING_DESIGNER_URL, + DWRITE_INFORMATIONAL_STRING_DESCRIPTION, + DWRITE_INFORMATIONAL_STRING_FONT_VENDOR_URL, + DWRITE_INFORMATIONAL_STRING_LICENSE_DESCRIPTION, + DWRITE_INFORMATIONAL_STRING_LICENSE_INFO_URL, + DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, + DWRITE_INFORMATIONAL_STRING_WIN32_SUBFAMILY_NAMES, + DWRITE_INFORMATIONAL_STRING_PREFERRED_FAMILY_NAMES, + DWRITE_INFORMATIONAL_STRING_PREFERRED_SUBFAMILY_NAMES, + DWRITE_INFORMATIONAL_STRING_SAMPLE_TEXT, + DWRITE_INFORMATIONAL_STRING_FULL_NAME, + DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_NAME, + DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_CID_NAME, + DWRITE_INFORMATIONAL_STRING_WWS_FAMILY_NAME, + DWRITE_INFORMATIONAL_STRING_DESIGN_SCRIPT_LANGUAGE_TAG, + DWRITE_INFORMATIONAL_STRING_SUPPORTED_SCRIPT_LANGUAGE_TAG, +}} +STRUCT!{struct DWRITE_FONT_METRICS { + designUnitsPerEm: UINT16, + ascent: UINT16, + descent: UINT16, + lineGap: INT16, + capHeight: UINT16, + xHeight: UINT16, + underlinePosition: INT16, + underlineThickness: UINT16, + strikethroughPosition: INT16, + strikethroughThickness: UINT16, +}} +STRUCT!{struct DWRITE_GLYPH_METRICS { + leftSideBearing: INT32, + advanceWidth: UINT32, + rightSideBearing: INT32, + topSideBearing: INT32, + advanceHeight: UINT32, + bottomSideBearing: INT32, + verticalOriginY: INT32, +}} +STRUCT!{struct DWRITE_GLYPH_OFFSET { + advanceOffset: FLOAT, + ascenderOffset: FLOAT, +}} +ENUM!{enum DWRITE_FACTORY_TYPE { + DWRITE_FACTORY_TYPE_SHARED, + DWRITE_FACTORY_TYPE_ISOLATED, +}} +RIDL!{#[uuid(0x727cad4e, 0xd6af, 0x4c9e, 0x8a, 0x08, 0xd6, 0x95, 0xb1, 0x1c, 0xaa, 0x49)] +interface IDWriteFontFileLoader(IDWriteFontFileLoaderVtbl): IUnknown(IUnknownVtbl) { + fn CreateStreamFromKey( + fontFileReferenceKey: *const c_void, + fontFileReferenceKeySize: UINT32, + fontFileStream: *mut *mut IDWriteFontFileStream, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb2d9f3ec, 0xc9fe, 0x4a11, 0xa2, 0xec, 0xd8, 0x62, 0x08, 0xf7, 0xc0, 0xa2)] +interface IDWriteLocalFontFileLoader(IDWriteLocalFontFileLoaderVtbl): + IDWriteFontFileLoader(IDWriteFontFileLoaderVtbl) { + fn GetFilePathLengthFromKey( + fontFileReferenceKey: *const c_void, + fontFileReferenceKeySize: UINT32, + filePathLength: *mut UINT32, + ) -> HRESULT, + fn GetFilePathFromKey( + fontFileReferenceKey: *const c_void, + fontFileReferenceKeySize: UINT32, + filePath: *mut WCHAR, + filePathSize: UINT32, + ) -> HRESULT, + fn GetLastWriteTimeFromKey( + fontFileReferenceKey: *const c_void, + fontFileReferenceKeySize: UINT32, + lastWriteTime: *mut FILETIME, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6d4865fe, 0x0ab8, 0x4d91, 0x8f, 0x62, 0x5d, 0xd6, 0xbe, 0x34, 0xa3, 0xe0)] +interface IDWriteFontFileStream(IDWriteFontFileStreamVtbl): IUnknown(IUnknownVtbl) { + fn ReadFileFragment( + fragmentStart: *mut *const c_void, + fileOffset: UINT64, + fragmentSize: UINT64, + fragmentContext: *mut *mut c_void, + ) -> HRESULT, + fn ReleaseFileFragment( + fragmentContext: *mut c_void, + ) -> (), + fn GetFileSize( + fileSize: *mut UINT64, + ) -> HRESULT, + fn GetLastWriteTime( + lastWriteTime: *mut UINT64, + ) -> HRESULT, +}} +ENUM!{enum DWRITE_OUTLINE_THRESHOLD { + DWRITE_OUTLINE_THRESHOLD_ANTIALIASED, + DWRITE_OUTLINE_THRESHOLD_ALIASED, +}} +STRUCT!{struct DWRITE_FONT_METRICS1 { + designUnitsPerEm: UINT16, + ascent: UINT16, + descent: UINT16, + lineGap: INT16, + capHeight: UINT16, + xHeight: UINT16, + underlinePosition: INT16, + underlineThickness: UINT16, + strikethroughPosition: INT16, + strikethroughThickness: UINT16, + glyphBoxLeft: INT16, + glyphBoxTop: INT16, + glyphBoxRight: INT16, + glyphBoxBottom: INT16, + subscriptPositionX: INT16, + subscriptPositionY: INT16, + subscriptSizeX: INT16, + subscriptSizeY: INT16, + superscriptPositionX: INT16, + superscriptPositionY: INT16, + superscriptSizeX: INT16, + superscriptSizeY: INT16, + hasTypographicMetrics: BOOL, +}} +STRUCT!{struct DWRITE_UNICODE_RANGE { + first: UINT32, + last: UINT32, +}} +STRUCT!{struct DWRITE_CARET_METRICS { + slopeRise: INT16, + slopeRun: INT16, + offset: INT16, +}} +#[inline] +pub fn DWRITE_MAKE_OPENTYPE_TAG(a: u8, b: u8, c: u8, d: u8) -> u32 { + ((d as u32) << 24) | ((c as u32) << 16) | ((b as u32) << 8) | (a as u32) +} +RIDL!{#[uuid(0x739d886a, 0xcef5, 0x47dc, 0x87, 0x69, 0x1a, 0x8b, 0x41, 0xbe, 0xbb, 0xb0)] +interface IDWriteFontFile(IDWriteFontFileVtbl): IUnknown(IUnknownVtbl) { + fn GetReferenceKey( + fontFileReferenceKey: *mut *const c_void, + fontFileReferenceKeySize: *mut UINT32, + ) -> HRESULT, + fn GetLoader( + fontFileLoader: *mut *mut IDWriteFontFileLoader, + ) -> HRESULT, + fn Analyze( + isSupportedFontType: *mut BOOL, + fontFileType: *mut DWRITE_FONT_FILE_TYPE, + fontFaceType: *mut DWRITE_FONT_FACE_TYPE, + numberOfFaces: *mut UINT32, + ) -> HRESULT, +}} +ENUM!{enum DWRITE_PIXEL_GEOMETRY { + DWRITE_PIXEL_GEOMETRY_FLAT, + DWRITE_PIXEL_GEOMETRY_RGB, + DWRITE_PIXEL_GEOMETRY_BGR, +}} +ENUM!{enum DWRITE_RENDERING_MODE { + DWRITE_RENDERING_MODE_DEFAULT, + DWRITE_RENDERING_MODE_ALIASED, + DWRITE_RENDERING_MODE_GDI_CLASSIC, + DWRITE_RENDERING_MODE_GDI_NATURAL, + DWRITE_RENDERING_MODE_NATURAL, + DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, + DWRITE_RENDERING_MODE_OUTLINE, + DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC = DWRITE_RENDERING_MODE_GDI_CLASSIC, + DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL = DWRITE_RENDERING_MODE_GDI_NATURAL, + DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL = DWRITE_RENDERING_MODE_NATURAL, + DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC = DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, +}} +STRUCT!{struct DWRITE_MATRIX { + m11: FLOAT, + m12: FLOAT, + m21: FLOAT, + m22: FLOAT, + dx: FLOAT, + dy: FLOAT, +}} +RIDL!{#[uuid(0x2f0da53a, 0x2add, 0x47cd, 0x82, 0xee, 0xd9, 0xec, 0x34, 0x68, 0x8e, 0x75)] +interface IDWriteRenderingParams(IDWriteRenderingParamsVtbl): IUnknown(IUnknownVtbl) { + fn GetGamma() -> FLOAT, + fn GetEnhancedContrast() -> FLOAT, + fn GetClearTypeLevel() -> FLOAT, + fn GetPixelGeometry() -> DWRITE_PIXEL_GEOMETRY, + fn GetRenderingMode() -> DWRITE_RENDERING_MODE, +}} +pub type IDWriteGeometrySink = ID2D1SimplifiedGeometrySink; +RIDL!{#[uuid(0x5f49804d, 0x7024, 0x4d43, 0xbf, 0xa9, 0xd2, 0x59, 0x84, 0xf5, 0x38, 0x49)] +interface IDWriteFontFace(IDWriteFontFaceVtbl): IUnknown(IUnknownVtbl) { + fn GetType() -> DWRITE_FONT_FACE_TYPE, + fn GetFiles( + numberOfFiles: *mut UINT32, + fontFiles: *mut *mut IDWriteFontFile, + ) -> HRESULT, + fn GetIndex() -> UINT32, + fn GetSimulations() -> DWRITE_FONT_SIMULATIONS, + fn IsSymbolFont() -> BOOL, + fn GetMetrics( + fontFaceMetrics: *mut DWRITE_FONT_METRICS, + ) -> (), + fn GetGlyphCount() -> UINT16, + fn GetDesignGlyphMetrics( + glyphIndices: *const UINT16, + glyphCount: UINT32, + glyphMetrics: *mut DWRITE_GLYPH_METRICS, + isSideways: BOOL, + ) -> HRESULT, + fn GetGlyphIndices( + codePoints: *const UINT32, + codePointCount: UINT32, + glyphIndices: *mut UINT16, + ) -> HRESULT, + fn TryGetFontTable( + openTypeTableTag: UINT32, + tableData: *mut *const c_void, + tableSize: *mut UINT32, + tableContext: *mut *mut c_void, + exists: *mut BOOL, + ) -> HRESULT, + fn ReleaseFontTable( + tableContext: *mut c_void, + ) -> HRESULT, + fn GetGlyphRunOutline( + emSize: FLOAT, + glyphIndices: *const UINT16, + glyphAdvances: *const FLOAT, + glyphOffsets: *const DWRITE_GLYPH_OFFSET, + glyphCount: UINT32, + isSideways: BOOL, + isRightToLeft: BOOL, + geometrySink: *mut IDWriteGeometrySink, + ) -> HRESULT, + fn GetRecommendedRenderingMode( + emSize: FLOAT, + pixelsPerDip: FLOAT, + measuringMode: DWRITE_MEASURING_MODE, + renderingParams: *mut IDWriteRenderingParams, + renderingMode: *mut DWRITE_RENDERING_MODE, + ) -> HRESULT, + fn GetGdiCompatibleMetrics( + emSize: FLOAT, + pixelsPerDip: FLOAT, + transform: *const DWRITE_MATRIX, + fontFaceMetrics: *mut DWRITE_FONT_METRICS, + ) -> HRESULT, + fn GetGdiCompatibleGlyphMetrics( + enSize: FLOAT, + pixelsPerDip: FLOAT, + transform: *const DWRITE_MATRIX, + useGdiNatrual: BOOL, + glyphIndices: *const UINT16, + glyphCount: UINT32, + glyphMetrics: *mut DWRITE_GLYPH_METRICS, + isSideways: BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa71efdb4, 0x9fdb, 0x4838, 0xad, 0x90, 0xcf, 0xc3, 0xbe, 0x8c, 0x3d, 0xaf)] +interface IDWriteFontFace1(IDWriteFontFace1Vtbl): IDWriteFontFace(IDWriteFontFaceVtbl) { + fn GetMetrics( + fontFaceMetrics: *mut DWRITE_FONT_METRICS1, + ) -> (), + fn GetGdiCompatibleMetrics( + emSize: FLOAT, + pixelsPerDip: FLOAT, + transform: *const DWRITE_MATRIX, + fontFaceMetrics: *mut DWRITE_FONT_METRICS1, + ) -> HRESULT, + fn GetCaretMetrics( + caretMetrics: *mut DWRITE_CARET_METRICS, + ) -> (), + fn GetUnicodeRanges( + maxRangeCount: UINT32, + unicodeRanges: *mut DWRITE_UNICODE_RANGE, + actualRangeCount: *mut UINT32, + ) -> HRESULT, + fn IsMonoSpacedFont() -> BOOL, + fn GetDesignGlyphAdvances( + glyphCount: UINT32, + glyphIndices: *const UINT16, + glyphAdvances: *mut INT32, + isSideways: BOOL, + ) -> HRESULT, + fn GetGdiCompatibleGlyphAdvance( + emSize: FLOAT, + pixelsPerDip: FLOAT, + transform: *const DWRITE_MATRIX, + useGdiNatural: BOOL, + isSideways: BOOL, + glyphCount: UINT32, + glyphIndices: *const UINT16, + glyphAdvances: *mut INT32, + ) -> HRESULT, + fn GetKerningPairAdjustments( + glyphCount: UINT32, + glyphIndices: *const UINT16, + glyphAdvanceAdjustments: *mut INT32, + ) -> HRESULT, + fn HasKerningPairs() -> BOOL, + fn GetRecommendedRenderingMode( + fontEmSize: FLOAT, + dpiX: FLOAT, + dpiY: FLOAT, + transform: *const DWRITE_MATRIX, + isSideways: BOOL, + outlineThreshold: DWRITE_OUTLINE_THRESHOLD, + measuringMode: DWRITE_MEASURING_MODE, + renderingMode: *mut DWRITE_RENDERING_MODE, + ) -> HRESULT, + fn GetVerticalGlyphVariants( + nominalGlyphIndices: *const UINT16, + verticalGlyphIndices: *mut UINT16, + ) -> HRESULT, + fn HasVerticalGlyphVariants() -> BOOL, +}} +RIDL!{#[uuid(0xcca920e4, 0x52f0, 0x492b, 0xbf, 0xa8, 0x29, 0xc7, 0x2e, 0xe0, 0xa4, 0x68)] +interface IDWriteFontCollectionLoader(IDWriteFontCollectionLoaderVtbl): + IUnknown(IUnknownVtbl) { + fn CreateEnumeratorFromKey( + factory: *mut IDWriteFactory, + collectionKey: *const c_void, + collectionKeySize: UINT32, + fontFileEnumerator: *mut *mut IDWriteFontFileEnumerator, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x72755049, 0x5ff7, 0x435d, 0x83, 0x48, 0x4b, 0xe9, 0x7c, 0xfa, 0x6c, 0x7c)] +interface IDWriteFontFileEnumerator(IDWriteFontFileEnumeratorVtbl): IUnknown(IUnknownVtbl) { + fn MoveNext( + hasCurrentFile: *mut BOOL, + ) -> HRESULT, + fn GetCurrentFontFile( + fontFile: *mut *mut IDWriteFontFile, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x08256209, 0x099a, 0x4b34, 0xb8, 0x6d, 0xc2, 0x2b, 0x11, 0x0e, 0x77, 0x71)] +interface IDWriteLocalizedStrings(IDWriteLocalizedStringsVtbl): IUnknown(IUnknownVtbl) { + fn GetCount() -> UINT32, + fn FindLocaleName( + localeName: *const WCHAR, + index: *mut UINT32, + exists: *mut BOOL, + ) -> HRESULT, + fn GetLocaleNameLength( + index: UINT32, + length: *mut UINT32, + ) -> HRESULT, + fn GetLocaleName( + index: UINT32, + localeName: *mut WCHAR, + size: UINT32, + ) -> HRESULT, + fn GetStringLength( + index: UINT32, + length: *mut UINT32, + ) -> HRESULT, + fn GetString( + index: UINT32, + stringBuffer: *mut WCHAR, + size: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa84cee02, 0x3eea, 0x4eee, 0xa8, 0x27, 0x87, 0xc1, 0xa0, 0x2a, 0x0f, 0xcc)] +interface IDWriteFontCollection(IDWriteFontCollectionVtbl): IUnknown(IUnknownVtbl) { + fn GetFontFamilyCount() -> UINT32, + fn GetFontFamily( + index: UINT32, + fontFamily: *mut *mut IDWriteFontFamily, + ) -> HRESULT, + fn FindFamilyName( + familyName: *const WCHAR, + index: *mut UINT32, + exists: *mut BOOL, + ) -> HRESULT, + fn GetFontFromFontFace( + fontFace: *mut IDWriteFontFace, + font: *mut *mut IDWriteFont, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1a0d8438, 0x1d97, 0x4ec1, 0xae, 0xf9, 0xa2, 0xfb, 0x86, 0xed, 0x6a, 0xcb)] +interface IDWriteFontList(IDWriteFontListVtbl): IUnknown(IUnknownVtbl) { + fn GetFontCollection( + fontCollection: *mut *mut IDWriteFontCollection, + ) -> HRESULT, + fn GetFontCount() -> UINT32, + fn GetFont( + index: UINT32, + font: *mut *mut IDWriteFont, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xda20d8ef, 0x812a, 0x4c43, 0x98, 0x02, 0x62, 0xec, 0x4a, 0xbd, 0x7a, 0xdd)] +interface IDWriteFontFamily(IDWriteFontFamilyVtbl): IDWriteFontList(IDWriteFontListVtbl) { + fn GetFamilyNames( + names: *mut *mut IDWriteLocalizedStrings, + ) -> HRESULT, + fn GetFirstMatchingFont( + weight: DWRITE_FONT_WEIGHT, + stretch: DWRITE_FONT_STRETCH, + style: DWRITE_FONT_STYLE, + matchingFont: *mut *mut IDWriteFont, + ) -> HRESULT, + fn GetMatchingFonts( + weight: DWRITE_FONT_WEIGHT, + stretch: DWRITE_FONT_STRETCH, + style: DWRITE_FONT_STYLE, + matchingFonts: *mut *mut IDWriteFontList, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xacd16696, 0x8c14, 0x4f5d, 0x87, 0x7e, 0xfe, 0x3f, 0xc1, 0xd3, 0x27, 0x37)] +interface IDWriteFont(IDWriteFontVtbl): IUnknown(IUnknownVtbl) { + fn GetFontFamily( + fontFamily: *mut *mut IDWriteFontFamily, + ) -> HRESULT, + fn GetWeight() -> DWRITE_FONT_WEIGHT, + fn GetStretch() -> DWRITE_FONT_STRETCH, + fn GetStyle() -> DWRITE_FONT_STYLE, + fn IsSymbolFont() -> BOOL, + fn GetFaceNames( + names: *mut *mut IDWriteLocalizedStrings, + ) -> HRESULT, + fn GetInformationalStrings( + informationalStringId: DWRITE_INFORMATIONAL_STRING_ID, + informationalStrings: *mut *mut IDWriteLocalizedStrings, + exists: *mut BOOL, + ) -> HRESULT, + fn GetSimulations() -> DWRITE_FONT_SIMULATIONS, + fn GetMetrics( + fontMetrics: *mut DWRITE_FONT_METRICS, + ) -> (), + fn HasCharacter( + unicodeValue: UINT32, + exists: *mut BOOL, + ) -> HRESULT, + fn CreateFontFace( + fontFace: *mut *mut IDWriteFontFace, + ) -> HRESULT, +}} +ENUM!{enum DWRITE_READING_DIRECTION { + DWRITE_READING_DIRECTION_LEFT_TO_RIGHT = 0, + DWRITE_READING_DIRECTION_RIGHT_TO_LEFT = 1, + DWRITE_READING_DIRECTION_TOP_TO_BOTTOM = 2, + DWRITE_READING_DIRECTION_BOTTOM_TO_TOP = 3, +}} +ENUM!{enum DWRITE_FLOW_DIRECTION { + DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM = 0, + DWRITE_FLOW_DIRECTION_BOTTOM_TO_TOP = 1, + DWRITE_FLOW_DIRECTION_LEFT_TO_RIGHT = 2, + DWRITE_FLOW_DIRECTION_RIGHT_TO_LEFT = 3, +}} +ENUM!{enum DWRITE_TEXT_ALIGNMENT { + DWRITE_TEXT_ALIGNMENT_LEADING, + DWRITE_TEXT_ALIGNMENT_TRAILING, + DWRITE_TEXT_ALIGNMENT_CENTER, + DWRITE_TEXT_ALIGNMENT_JUSTIFIED, +}} +ENUM!{enum DWRITE_PARAGRAPH_ALIGNMENT { + DWRITE_PARAGRAPH_ALIGNMENT_NEAR, + DWRITE_PARAGRAPH_ALIGNMENT_FAR, + DWRITE_PARAGRAPH_ALIGNMENT_CENTER, +}} +ENUM!{enum DWRITE_WORD_WRAPPING { + DWRITE_WORD_WRAPPING_WRAP = 0, + DWRITE_WORD_WRAPPING_NO_WRAP = 1, + DWRITE_WORD_WRAPPING_EMERGENCY_BREAK = 2, + DWRITE_WORD_WRAPPING_WHOLE_WORD = 3, + DWRITE_WORD_WRAPPING_CHARACTER = 4, +}} +ENUM!{enum DWRITE_LINE_SPACING_METHOD { + DWRITE_LINE_SPACING_METHOD_DEFAULT, + DWRITE_LINE_SPACING_METHOD_UNIFORM, + DWRITE_LINE_SPACING_METHOD_PROPORTIONAL, +}} +ENUM!{enum DWRITE_TRIMMING_GRANULARITY { + DWRITE_TRIMMING_GRANULARITY_NONE, + DWRITE_TRIMMING_GRANULARITY_CHARACTER, + DWRITE_TRIMMING_GRANULARITY_WORD, +}} +ENUM!{enum DWRITE_FONT_FEATURE_TAG { + DWRITE_FONT_FEATURE_TAG_ALTERNATIVE_FRACTIONS = 0x63726661, // 'afrc' + DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS_FROM_CAPITALS = 0x63703263, // 'c2pc' + DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS_FROM_CAPITALS = 0x63733263, // 'c2sc' + DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_ALTERNATES = 0x746c6163, // 'calt' + DWRITE_FONT_FEATURE_TAG_CASE_SENSITIVE_FORMS = 0x65736163, // 'case' + DWRITE_FONT_FEATURE_TAG_GLYPH_COMPOSITION_DECOMPOSITION = 0x706d6363, // 'ccmp' + DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_LIGATURES = 0x67696c63, // 'clig' + DWRITE_FONT_FEATURE_TAG_CAPITAL_SPACING = 0x70737063, // 'cpsp' + DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_SWASH = 0x68777363, // 'cswh' + DWRITE_FONT_FEATURE_TAG_CURSIVE_POSITIONING = 0x73727563, // 'curs' + DWRITE_FONT_FEATURE_TAG_DEFAULT = 0x746c6664, // 'dflt' + DWRITE_FONT_FEATURE_TAG_DISCRETIONARY_LIGATURES = 0x67696c64, // 'dlig' + DWRITE_FONT_FEATURE_TAG_EXPERT_FORMS = 0x74707865, // 'expt' + DWRITE_FONT_FEATURE_TAG_FRACTIONS = 0x63617266, // 'frac' + DWRITE_FONT_FEATURE_TAG_FULL_WIDTH = 0x64697766, // 'fwid' + DWRITE_FONT_FEATURE_TAG_HALF_FORMS = 0x666c6168, // 'half' + DWRITE_FONT_FEATURE_TAG_HALANT_FORMS = 0x6e6c6168, // 'haln' + DWRITE_FONT_FEATURE_TAG_ALTERNATE_HALF_WIDTH = 0x746c6168, // 'halt' + DWRITE_FONT_FEATURE_TAG_HISTORICAL_FORMS = 0x74736968, // 'hist' + DWRITE_FONT_FEATURE_TAG_HORIZONTAL_KANA_ALTERNATES = 0x616e6b68, // 'hkna' + DWRITE_FONT_FEATURE_TAG_HISTORICAL_LIGATURES = 0x67696c68, // 'hlig' + DWRITE_FONT_FEATURE_TAG_HALF_WIDTH = 0x64697768, // 'hwid' + DWRITE_FONT_FEATURE_TAG_HOJO_KANJI_FORMS = 0x6f6a6f68, // 'hojo' + DWRITE_FONT_FEATURE_TAG_JIS04_FORMS = 0x3430706a, // 'jp04' + DWRITE_FONT_FEATURE_TAG_JIS78_FORMS = 0x3837706a, // 'jp78' + DWRITE_FONT_FEATURE_TAG_JIS83_FORMS = 0x3338706a, // 'jp83' + DWRITE_FONT_FEATURE_TAG_JIS90_FORMS = 0x3039706a, // 'jp90' + DWRITE_FONT_FEATURE_TAG_KERNING = 0x6e72656b, // 'kern' + DWRITE_FONT_FEATURE_TAG_STANDARD_LIGATURES = 0x6167696c, // 'liga' + DWRITE_FONT_FEATURE_TAG_LINING_FIGURES = 0x6d756e6c, // 'lnum' + DWRITE_FONT_FEATURE_TAG_LOCALIZED_FORMS = 0x6c636f6c, // 'locl' + DWRITE_FONT_FEATURE_TAG_MARK_POSITIONING = 0x6b72616d, // 'mark' + DWRITE_FONT_FEATURE_TAG_MATHEMATICAL_GREEK = 0x6b72676d, // 'mgrk' + DWRITE_FONT_FEATURE_TAG_MARK_TO_MARK_POSITIONING = 0x6b6d6b6d, // 'mkmk' + DWRITE_FONT_FEATURE_TAG_ALTERNATE_ANNOTATION_FORMS = 0x746c616e, // 'nalt' + DWRITE_FONT_FEATURE_TAG_NLC_KANJI_FORMS = 0x6b636c6e, // 'nlck' + DWRITE_FONT_FEATURE_TAG_OLD_STYLE_FIGURES = 0x6d756e6f, // 'onum' + DWRITE_FONT_FEATURE_TAG_ORDINALS = 0x6e64726f, // 'ordn' + DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_ALTERNATE_WIDTH = 0x746c6170, // 'palt' + DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS = 0x70616370, // 'pcap' + DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_FIGURES = 0x6d756e70, // 'pnum' + DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_WIDTHS = 0x64697770, // 'pwid' + DWRITE_FONT_FEATURE_TAG_QUARTER_WIDTHS = 0x64697771, // 'qwid' + DWRITE_FONT_FEATURE_TAG_REQUIRED_LIGATURES = 0x67696c72, // 'rlig' + DWRITE_FONT_FEATURE_TAG_RUBY_NOTATION_FORMS = 0x79627572, // 'ruby' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_ALTERNATES = 0x746c6173, // 'salt' + DWRITE_FONT_FEATURE_TAG_SCIENTIFIC_INFERIORS = 0x666e6973, // 'sinf' + DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS = 0x70636d73, // 'smcp' + DWRITE_FONT_FEATURE_TAG_SIMPLIFIED_FORMS = 0x6c706d73, // 'smpl' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_1 = 0x31307373, // 'ss01' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_2 = 0x32307373, // 'ss02' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_3 = 0x33307373, // 'ss03' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_4 = 0x34307373, // 'ss04' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_5 = 0x35307373, // 'ss05' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_6 = 0x36307373, // 'ss06' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_7 = 0x37307373, // 'ss07' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_8 = 0x38307373, // 'ss08' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_9 = 0x39307373, // 'ss09' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_10 = 0x30317373, // 'ss10' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_11 = 0x31317373, // 'ss11' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_12 = 0x32317373, // 'ss12' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_13 = 0x33317373, // 'ss13' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_14 = 0x34317373, // 'ss14' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_15 = 0x35317373, // 'ss15' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_16 = 0x36317373, // 'ss16' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_17 = 0x37317373, // 'ss17' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_18 = 0x38317373, // 'ss18' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_19 = 0x39317373, // 'ss19' + DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_20 = 0x30327373, // 'ss20' + DWRITE_FONT_FEATURE_TAG_SUBSCRIPT = 0x73627573, // 'subs' + DWRITE_FONT_FEATURE_TAG_SUPERSCRIPT = 0x73707573, // 'sups' + DWRITE_FONT_FEATURE_TAG_SWASH = 0x68737773, // 'swsh' + DWRITE_FONT_FEATURE_TAG_TITLING = 0x6c746974, // 'titl' + DWRITE_FONT_FEATURE_TAG_TRADITIONAL_NAME_FORMS = 0x6d616e74, // 'tnam' + DWRITE_FONT_FEATURE_TAG_TABULAR_FIGURES = 0x6d756e74, // 'tnum' + DWRITE_FONT_FEATURE_TAG_TRADITIONAL_FORMS = 0x64617274, // 'trad' + DWRITE_FONT_FEATURE_TAG_THIRD_WIDTHS = 0x64697774, // 'twid' + DWRITE_FONT_FEATURE_TAG_UNICASE = 0x63696e75, // 'unic' + DWRITE_FONT_FEATURE_TAG_VERTICAL_WRITING = 0x74726576, // 'vert' + DWRITE_FONT_FEATURE_TAG_VERTICAL_ALTERNATES_AND_ROTATION = 0x32747276, // 'vrt2' + DWRITE_FONT_FEATURE_TAG_SLASHED_ZERO = 0x6f72657a, // 'zero' +}} +STRUCT!{struct DWRITE_TEXT_RANGE { + startPosition: UINT32, + length: UINT32, +}} +STRUCT!{struct DWRITE_FONT_FEATURE { + nameTag: DWRITE_FONT_FEATURE_TAG, + parameter: UINT32, +}} +STRUCT!{struct DWRITE_TYPOGRAPHIC_FEATURES { + features: *mut DWRITE_FONT_FEATURE, + featureCount: UINT32, +}} +STRUCT!{struct DWRITE_TRIMMING { + granularity: DWRITE_TRIMMING_GRANULARITY, + delimiter: UINT32, + delimiterCount: UINT32, +}} +RIDL!{#[uuid(0x9c906818, 0x31d7, 0x4fd3, 0xa1, 0x51, 0x7c, 0x5e, 0x22, 0x5d, 0xb5, 0x5a)] +interface IDWriteTextFormat(IDWriteTextFormatVtbl): IUnknown(IUnknownVtbl) { + fn SetTextAlignment( + textAlignment: DWRITE_TEXT_ALIGNMENT, + ) -> HRESULT, + fn SetParagraphAlignment( + paragraphAlignment: DWRITE_PARAGRAPH_ALIGNMENT, + ) -> HRESULT, + fn SetWordWrapping( + wordWrapping: DWRITE_WORD_WRAPPING, + ) -> HRESULT, + fn SetReadingDirection( + readingDirection: DWRITE_READING_DIRECTION, + ) -> HRESULT, + fn SetFlowDirection( + flowDirection: DWRITE_FLOW_DIRECTION, + ) -> HRESULT, + fn SetIncrementalTabStop( + incrementalTabStop: FLOAT, + ) -> HRESULT, + fn SetTrimming( + trimmingOptions: *const DWRITE_TRIMMING, + trimmingSign: *mut IDWriteInlineObject, + ) -> HRESULT, + fn SetLineSpacing( + lineSpacingMethod: DWRITE_LINE_SPACING_METHOD, + lineSpacing: FLOAT, + baseLine: FLOAT, + ) -> HRESULT, + fn GetTextAlignment() -> DWRITE_TEXT_ALIGNMENT, + fn GetParagraphAlignment() -> DWRITE_PARAGRAPH_ALIGNMENT, + fn GetWordWrapping() -> DWRITE_WORD_WRAPPING, + fn GetReadingDirection() -> DWRITE_READING_DIRECTION, + fn GetFlowDirection() -> DWRITE_FLOW_DIRECTION, + fn GetIncrementalTabStop() -> FLOAT, + fn GetTrimming( + trimmingOptions: *mut DWRITE_TRIMMING, + trimmingSign: *mut *mut IDWriteInlineObject, + ) -> HRESULT, + fn GetLineSpacing( + lineSpacingMethod: *mut DWRITE_LINE_SPACING_METHOD, + lineSpacing: *mut FLOAT, + baseline: *mut FLOAT, + ) -> HRESULT, + fn GetFontCollection( + fontCollection: *mut *mut IDWriteFontCollection, + ) -> HRESULT, + fn GetFontFamilyNameLength() -> UINT32, + fn GetFontFamilyName( + fontFamilyName: *mut WCHAR, + nameSize: UINT32, + ) -> HRESULT, + fn GetFontWeight() -> DWRITE_FONT_WEIGHT, + fn GetFontStyle() -> DWRITE_FONT_STYLE, + fn GetFontStretch() -> DWRITE_FONT_STRETCH, + fn GetFontSize() -> FLOAT, + fn GetLocaleNameLength() -> UINT32, + fn GetLocaleName( + localeName: *mut WCHAR, + nameSize: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x55f1112b, 0x1dc2, 0x4b3c, 0x95, 0x41, 0xf4, 0x68, 0x94, 0xed, 0x85, 0xb6)] +interface IDWriteTypography(IDWriteTypographyVtbl): IUnknown(IUnknownVtbl) { + fn AddFontFeature( + fontFeature: DWRITE_FONT_FEATURE, + ) -> HRESULT, + fn GetFontFeatureCount() -> UINT32, + fn GetFontFeature( + fontFeatureIndex: UINT32, + fontFeature: *mut DWRITE_FONT_FEATURE, + ) -> HRESULT, +}} +ENUM!{enum DWRITE_SCRIPT_SHAPES { + DWRITE_SCRIPT_SHAPES_DEFAULT = 0, + DWRITE_SCRIPT_SHAPES_NO_VISUAL = 1, +}} +STRUCT!{struct DWRITE_SCRIPT_ANALYSIS { + script: UINT16, + shapes: DWRITE_SCRIPT_SHAPES, +}} +ENUM!{enum DWRITE_BREAK_CONDITION { + DWRITE_BREAK_CONDITION_NEUTRAL, + DWRITE_BREAK_CONDITION_CAN_BREAK, + DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, + DWRITE_BREAK_CONDITION_MUST_BREAK, +}} +STRUCT!{struct DWRITE_LINE_BREAKPOINT { + bit_fields: UINT8, +}} +BITFIELD!{DWRITE_LINE_BREAKPOINT bit_fields: UINT8 [ + breakConditionBefore set_breakConditionBefore[0..2], + breakConditionAfter set_breakConditionAfter[2..4], + isWhitespace set_isWhitespace[4..5], + isSoftHyphen set_isSoftHyphen[5..6], + padding set_padding[6..8], +]} +ENUM!{enum DWRITE_NUMBER_SUBSTITUTION_METHOD { + DWRITE_NUMBER_SUBSTITUTION_METHOD_FROM_CULTURE, + DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL, + DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE, + DWRITE_NUMBER_SUBSTITUTION_METHOD_NATIONAL, + DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL, +}} +RIDL!{#[uuid(0x14885cc9, 0xbab0, 0x4f90, 0xb6, 0xed, 0x5c, 0x36, 0x6a, 0x2c, 0xd0, 0x3d)] +interface IDWriteNumberSubstitution(IDWriteNumberSubstitutionVtbl): IUnknown(IUnknownVtbl) {}} +STRUCT!{struct DWRITE_SHAPING_TEXT_PROPERTIES { + bit_fields: UINT16, +}} +BITFIELD!{DWRITE_SHAPING_TEXT_PROPERTIES bit_fields: UINT16 [ + isShapedAlone set_isShapedAlone[0..1], + reserved set_reserved[1..16], +]} +STRUCT!{struct DWRITE_SHAPING_GLYPH_PROPERTIES { + bit_fields: UINT16, +}} +BITFIELD!{DWRITE_SHAPING_GLYPH_PROPERTIES bit_fields: UINT16 [ + justification set_justification[0..4], + isClusterStart set_isClusterStart[4..5], + isDiacritic set_isDiacritic[5..6], + isZeroWidthSpace set_isZeroWidthSpace[6..7], + reserved set_reserved[7..16], +]} +RIDL!{#[uuid(0x688e1a58, 0x5094, 0x47c8, 0xad, 0xc8, 0xfb, 0xce, 0xa6, 0x0a, 0xe9, 0x2b)] +interface IDWriteTextAnalysisSource(IDWriteTextAnalysisSourceVtbl): IUnknown(IUnknownVtbl) { + fn GetTextAtPosition( + textPosition: UINT32, + textString: *mut *const WCHAR, + textLength: *mut UINT32, + ) -> HRESULT, + fn GetTextBeforePosition( + textPosition: UINT32, + textString: *mut *const WCHAR, + textLength: *mut UINT32, + ) -> HRESULT, + fn GetParagraphReadingDirection() -> DWRITE_READING_DIRECTION, + fn GetLocaleName( + textPosition: UINT32, + textLength: *mut UINT32, + localeName: *mut *const WCHAR, + ) -> HRESULT, + fn GetNumberSubstitution( + textPosition: UINT32, + textLength: *mut UINT32, + numberSubstitution: *mut *mut IDWriteNumberSubstitution, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5810cd44, 0x0ca0, 0x4701, 0xb3, 0xfa, 0xbe, 0xc5, 0x18, 0x2a, 0xe4, 0xf6)] +interface IDWriteTextAnalysisSink(IDWriteTextAnalysisSinkVtbl): IUnknown(IUnknownVtbl) { + fn SetScriptAnalysis( + textPosition: UINT32, + textLength: UINT32, + scriptAnalysis: *const DWRITE_SCRIPT_ANALYSIS, + ) -> HRESULT, + fn SetLineBreakpoints( + textPosition: UINT32, + textLength: UINT32, + lineBreakpoints: *const DWRITE_LINE_BREAKPOINT, + ) -> HRESULT, + fn SetBidiLevel( + textPosition: UINT32, + textLength: UINT32, + explicitLevel: UINT8, + resolvedLevel: UINT8, + ) -> HRESULT, + fn SetNumberSubstitution( + textPosition: UINT32, + textLength: UINT32, + numberSubstitution: *mut IDWriteNumberSubstitution, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb7e6163e, 0x7f46, 0x43b4, 0x84, 0xb3, 0xe4, 0xe6, 0x24, 0x9c, 0x36, 0x5d)] +interface IDWriteTextAnalyzer(IDWriteTextAnalyzerVtbl): IUnknown(IUnknownVtbl) { + fn AnalyzeScript( + analysisSource: *mut IDWriteTextAnalysisSource, + textPosition: UINT32, + textLength: UINT32, + analysisSink: *mut IDWriteTextAnalysisSink, + ) -> HRESULT, + fn AnalyzeBidi( + analysisSource: *mut IDWriteTextAnalysisSource, + textPosition: UINT32, + textLength: UINT32, + analysisSink: *mut IDWriteTextAnalysisSink, + ) -> HRESULT, + fn AnalyzeNumberSubstitution( + analysisSource: *mut IDWriteTextAnalysisSource, + textPosition: UINT32, + textLength: UINT32, + analysisSink: *mut IDWriteTextAnalysisSink, + ) -> HRESULT, + fn AnalyzeLineBreakpoints( + analysisSource: *mut IDWriteTextAnalysisSource, + textPosition: UINT32, + textLength: UINT32, + analysisSink: *mut IDWriteTextAnalysisSink, + ) -> HRESULT, + fn GetGlyphs( + textString: *const WCHAR, + textLength: UINT32, + fontFace: *mut IDWriteFontFace, + isSideways: BOOL, + isRightToLeft: BOOL, + scriptAnalysis: *const DWRITE_SCRIPT_ANALYSIS, + localeName: *const WCHAR, + numberSubstitution: *mut IDWriteNumberSubstitution, + features: *mut *const DWRITE_TYPOGRAPHIC_FEATURES, + featureRangeLengths: *const UINT32, + featureRanges: UINT32, + maxGlyphCount: UINT32, + clusterMap: *mut UINT16, + textProps: *mut DWRITE_SHAPING_TEXT_PROPERTIES, + glyphIndices: *mut UINT16, + glyphProps: *mut DWRITE_SHAPING_GLYPH_PROPERTIES, + actualGlyphCount: *mut UINT32, + ) -> HRESULT, + fn GetGlyphPlacements( + textString: *const WCHAR, + clusterMap: *const UINT16, + textProps: *mut DWRITE_SHAPING_TEXT_PROPERTIES, + textLength: UINT32, + glyphIndices: *const UINT16, + glyphProps: *const DWRITE_SHAPING_GLYPH_PROPERTIES, + glyphCount: UINT32, + fontFace: *mut IDWriteFontFace, + fontEmSize: FLOAT, + isSideways: BOOL, + isRightToLeft: BOOL, + scriptAnalysis: *const DWRITE_SCRIPT_ANALYSIS, + localeName: *const WCHAR, + features: *mut *const DWRITE_TYPOGRAPHIC_FEATURES, + featureRangeLengths: *const UINT32, + featureRanges: UINT32, + glyphAdvances: *mut FLOAT, + glyphOffsets: *mut DWRITE_GLYPH_OFFSET, + ) -> HRESULT, + fn GetGdiCompatibleGlyphPlacements( + textString: *const WCHAR, + clusterMap: *const UINT16, + textProps: *mut DWRITE_SHAPING_TEXT_PROPERTIES, + textLength: UINT32, + glyphIndices: *const UINT16, + glyphProps: *const DWRITE_SHAPING_GLYPH_PROPERTIES, + glyphCount: UINT32, + fontFace: *mut IDWriteFontFace, + fontEmSize: FLOAT, + pixelsPerDip: FLOAT, + transform: *const DWRITE_MATRIX, + useGdiNatrual: BOOL, + isSideways: BOOL, + isRightToLeft: BOOL, + scriptAnalysis: *const DWRITE_SCRIPT_ANALYSIS, + localeName: *const WCHAR, + features: *mut *const DWRITE_TYPOGRAPHIC_FEATURES, + featureRangeLengths: *const UINT32, + featureRanges: UINT32, + glyphAdvances: *mut FLOAT, + glyphOffsets: *mut DWRITE_GLYPH_OFFSET, + ) -> HRESULT, +}} +STRUCT!{struct DWRITE_GLYPH_RUN { + fontFace: *mut IDWriteFontFace, + fontEmSize: FLOAT, + glyphCount: UINT32, + glyphIndices: *const UINT16, + glyphAdvances: *const FLOAT, + glyphOffsets: *const DWRITE_GLYPH_OFFSET, + isSideways: BOOL, + bidiLevel: UINT32, +}} +STRUCT!{struct DWRITE_GLYPH_RUN_DESCRIPTION { + localeName: *const WCHAR, + string: *const WCHAR, + stringLength: UINT32, + clusterMap: *const UINT16, + textPosition: UINT32, +}} +STRUCT!{struct DWRITE_UNDERLINE { + width: FLOAT, + thickness: FLOAT, + offset: FLOAT, + runHeight: FLOAT, + readingDirection: DWRITE_READING_DIRECTION, + flowDirection: DWRITE_FLOW_DIRECTION, + localeName: *const WCHAR, + measuringMode: DWRITE_MEASURING_MODE, +}} +STRUCT!{struct DWRITE_STRIKETHROUGH { + width: FLOAT, + thickness: FLOAT, + offset: FLOAT, + readingDirection: DWRITE_READING_DIRECTION, + flowDirection: DWRITE_FLOW_DIRECTION, + localeName: *const WCHAR, + measuringMode: DWRITE_MEASURING_MODE, +}} +STRUCT!{struct DWRITE_LINE_METRICS { + length: UINT32, + trailingWhitespaceLength: UINT32, + newlineLength: UINT32, + height: FLOAT, + baseline: FLOAT, + isTrimmed: BOOL, +}} +STRUCT!{struct DWRITE_CLUSTER_METRICS { + width: FLOAT, + length: UINT16, + bit_fields: UINT16, +}} +BITFIELD!{DWRITE_CLUSTER_METRICS bit_fields: UINT16 [ + canWrapLineAfter set_canWrapLineAfter[0..1], + isWhitespace set_isWhitespace[1..2], + isNewline set_isNewline[2..3], + isSoftHyphen set_isSoftHyphen[3..4], + isRightToLeft set_isRightToLeft[4..5], + padding set_padding[5..16], +]} +STRUCT!{struct DWRITE_TEXT_METRICS { + left: FLOAT, + top: FLOAT, + width: FLOAT, + widthIncludingTrailingWhitespace: FLOAT, + height: FLOAT, + layoutWidth: FLOAT, + layoutHeight: FLOAT, + maxBidiReorderingDepth: UINT32, + lineCount: UINT32, +}} +STRUCT!{struct DWRITE_INLINE_OBJECT_METRICS { + width: FLOAT, + height: FLOAT, + baseline: FLOAT, + supportsSideways: BOOL, +}} +STRUCT!{struct DWRITE_OVERHANG_METRICS { + left: FLOAT, + top: FLOAT, + right: FLOAT, + bottom: FLOAT, +}} +STRUCT!{struct DWRITE_HIT_TEST_METRICS { + textPosition: UINT32, + length: UINT32, + left: FLOAT, + top: FLOAT, + width: FLOAT, + height: FLOAT, + bidiLevel: UINT32, + isText: BOOL, + isTrimmed: BOOL, +}} +RIDL!{#[uuid(0x8339fde3, 0x106f, 0x47ab, 0x83, 0x73, 0x1c, 0x62, 0x95, 0xeb, 0x10, 0xb3)] +interface IDWriteInlineObject(IDWriteInlineObjectVtbl): IUnknown(IUnknownVtbl) { + fn Draw( + clientDrawingContext: *mut c_void, + renderer: *mut IDWriteTextRenderer, + originX: FLOAT, + originY: FLOAT, + isSideways: BOOL, + isRightToLeft: BOOL, + clientDrawingEffect: *mut IUnknown, + ) -> HRESULT, + fn GetMetrics( + metrics: *mut DWRITE_INLINE_OBJECT_METRICS, + ) -> HRESULT, + fn GetOverhangMetrics( + overhangs: *mut DWRITE_OVERHANG_METRICS, + ) -> HRESULT, + fn GetBreakConditions( + breakConditionBefore: *mut DWRITE_BREAK_CONDITION, + breakConditionAfter: *mut DWRITE_BREAK_CONDITION, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xeaf3a2da, 0xecf4, 0x4d24, 0xb6, 0x44, 0xb3, 0x4f, 0x68, 0x42, 0x02, 0x4b)] +interface IDWritePixelSnapping(IDWritePixelSnappingVtbl): IUnknown(IUnknownVtbl) { + fn IsPixelSnappingDisabled( + clientDrawingContext: *mut c_void, + isDisabled: *mut BOOL, + ) -> HRESULT, + fn GetCurrentTransform( + clientDrawingContext: *mut c_void, + transform: *mut DWRITE_MATRIX, + ) -> HRESULT, + fn GetPixelsPerDip( + clientDrawingContext: *mut c_void, + pixelsPerDip: *mut FLOAT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xef8a8135, 0x5cc6, 0x45fe, 0x88, 0x25, 0xc5, 0xa0, 0x72, 0x4e, 0xb8, 0x19)] +interface IDWriteTextRenderer(IDWriteTextRendererVtbl): + IDWritePixelSnapping(IDWritePixelSnappingVtbl) { + fn DrawGlyphRun( + clientDrawingContext: *mut c_void, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + measuringMode: DWRITE_MEASURING_MODE, + glyphRun: *const DWRITE_GLYPH_RUN, + glyphRunDescription: *const DWRITE_GLYPH_RUN_DESCRIPTION, + clientDrawingEffect: *mut IUnknown, + ) -> HRESULT, + fn DrawUnderline( + clientDrawingContext: *mut c_void, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + underline: *const DWRITE_UNDERLINE, + clientDrawingEffect: *mut IUnknown, + ) -> HRESULT, + fn DrawStrikethrough( + clientDrawingContext: *mut c_void, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + strikethrough: *const DWRITE_STRIKETHROUGH, + clientDrawingEffect: *mut IUnknown, + ) -> HRESULT, + fn DrawInlineObject( + clientDrawingContext: *mut c_void, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + inlineObject: *mut IDWriteInlineObject, + isSideways: BOOL, + isRightToLeft: BOOL, + clientDrawingEffect: *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x53737037, 0x6d14, 0x410b, 0x9b, 0xfe, 0x0b, 0x18, 0x2b, 0xb7, 0x09, 0x61)] +interface IDWriteTextLayout(IDWriteTextLayoutVtbl): + IDWriteTextFormat(IDWriteTextFormatVtbl) { + fn SetMaxWidth( + maxWidth: FLOAT, + ) -> HRESULT, + fn SetMaxHeight( + maxHeight: FLOAT, + ) -> HRESULT, + fn SetFontCollection( + fontCollection: *mut IDWriteFontCollection, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetFontFamilyName( + fontFamilyName: *const WCHAR, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetFontWeight( + fontWeight: DWRITE_FONT_WEIGHT, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetFontStyle( + fontStyle: DWRITE_FONT_STYLE, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetFontStretch( + fontStretch: DWRITE_FONT_STRETCH, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetFontSize( + fontSize: FLOAT, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetUnderline( + hasUnderline: BOOL, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetStrikethrough( + hasStrikethrough: BOOL, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetDrawingEffect( + drawingEffect: *mut IUnknown, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetInlineObject( + inlineObject: *mut IDWriteInlineObject, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetTypography( + typography: *mut IDWriteTypography, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetLocaleName( + localeName: *const WCHAR, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetMaxWidth() -> FLOAT, + fn GetMaxHeight() -> FLOAT, + fn GetFontCollection( + currentPosition: UINT32, + fontCollection: *mut *mut IDWriteFontCollection, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetFontFamilyNameLength( + currentPosition: UINT32, + nameLength: *mut UINT32, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetFontFamilyName( + currentPosition: UINT32, + fontFamilyName: *mut WCHAR, + nameSize: UINT32, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetFontWeight( + currentPosition: UINT32, + fontWeight: *mut DWRITE_FONT_WEIGHT, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetFontStyle( + currentPosition: UINT32, + fontStyle: *mut DWRITE_FONT_STYLE, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetFontStretch( + currentPosition: UINT32, + fontStretch: *mut DWRITE_FONT_STRETCH, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetFontSize( + currentPosition: UINT32, + fontSize: *mut FLOAT, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetUnderline( + currentPosition: UINT32, + hasUnderline: *mut BOOL, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetStrikethrough( + currentPosition: UINT32, + hasStrikethrough: *mut BOOL, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetDrawingEffect( + currentPosition: UINT32, + drawingEffect: *mut *mut IUnknown, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetInlineObject( + currentPosition: UINT32, + inlineObject: *mut *mut IDWriteInlineObject, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetTypography( + currentPosition: UINT32, + typography: *mut *mut IDWriteTypography, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetLocaleNameLength( + currentPosition: UINT32, + nameLength: *mut UINT32, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetLocaleName( + currentPosition: UINT32, + localeName: *mut WCHAR, + nameSize: UINT32, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn Draw( + clientDrawingContext: *mut c_void, + renderer: *mut IDWriteTextRenderer, + originX: FLOAT, + originY: FLOAT, + ) -> HRESULT, + fn GetLineMetrics( + lineMetrics: *mut DWRITE_LINE_METRICS, + maxLineCount: UINT32, + actualLineCount: *mut UINT32, + ) -> HRESULT, + fn GetMetrics( + textMetrics: *mut DWRITE_TEXT_METRICS, + ) -> HRESULT, + fn GetOverhangMetrics( + overhangs: *mut DWRITE_OVERHANG_METRICS, + ) -> HRESULT, + fn GetClusterMetrics( + clusterMetrics: *mut DWRITE_CLUSTER_METRICS, + maxClusterCount: UINT32, + actualClusterCount: *mut UINT32, + ) -> HRESULT, + fn DetermineMinWidth( + minWidth: *mut FLOAT, + ) -> HRESULT, + fn HitTestPoint( + pointX: FLOAT, + pointY: FLOAT, + isTrailingHit: *mut BOOL, + isInside: *mut BOOL, + hitTestMetrics: *mut DWRITE_HIT_TEST_METRICS, + ) -> HRESULT, + fn HitTestTextPosition( + textPosition: UINT32, + isTrailingHit: BOOL, + pointX: *mut FLOAT, + pointY: *mut FLOAT, + hitTestMetrics: *mut DWRITE_HIT_TEST_METRICS, + ) -> HRESULT, + fn HitTestTextRange( + textPosition: UINT32, + textLength: UINT32, + originX: FLOAT, + originY: FLOAT, + hitTestMetrics: *mut DWRITE_HIT_TEST_METRICS, + maxHitTestMetricsCount: UINT32, + actualHitTestMetricsCount: *mut UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5e5a32a3, 0x8dff, 0x4773, 0x9f, 0xf6, 0x06, 0x96, 0xea, 0xb7, 0x72, 0x67)] +interface IDWriteBitmapRenderTarget(IDWriteBitmapRenderTargetVtbl): IUnknown(IUnknownVtbl) { + fn DrawGlyphRun( + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + measuringMode: DWRITE_MEASURING_MODE, + glyphRun: *const DWRITE_GLYPH_RUN, + renderingParams: *mut IDWriteRenderingParams, + textColor: COLORREF, + blackBoxRect: *mut RECT, + ) -> HRESULT, + fn GetMemoryDC() -> HDC, + fn GetPixelsPerDip() -> FLOAT, + fn SetPixelsPerDip( + pixelsPerDip: FLOAT, + ) -> HRESULT, + fn GetCurrentTransform( + transform: *mut DWRITE_MATRIX, + ) -> HRESULT, + fn SetCurrentTransform( + transform: *const DWRITE_MATRIX, + ) -> HRESULT, + fn GetSize( + size: *mut SIZE, + ) -> HRESULT, + fn Resize( + width: UINT32, + height: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1edd9491, 0x9853, 0x4299, 0x89, 0x8f, 0x64, 0x32, 0x98, 0x3b, 0x6f, 0x3a)] +interface IDWriteGdiInterop(IDWriteGdiInteropVtbl): IUnknown(IUnknownVtbl) { + fn CreateFontFromLOGFONT( + logFont: *const LOGFONTW, + font: *mut *mut IDWriteFont, + ) -> HRESULT, + fn ConvertFontToLOGFONT( + font: *mut IDWriteFont, + logFont: *mut LOGFONTW, + isSystemFont: *mut BOOL, + ) -> HRESULT, + fn ConvertFontFaceToLOGFONT( + font: *mut IDWriteFontFace, + logFont: *mut LOGFONTW, + ) -> HRESULT, + fn CreateFontFaceFromHdc( + hdc: HDC, + fontFace: *mut *mut IDWriteFontFace, + ) -> HRESULT, + fn CreateBitmapRenderTarget( + hdc: HDC, + width: UINT32, + height: UINT32, + renderTarget: *mut *mut IDWriteBitmapRenderTarget, + ) -> HRESULT, +}} +ENUM!{enum DWRITE_TEXTURE_TYPE { + DWRITE_TEXTURE_ALIASED_1x1 = 0, + DWRITE_TEXTURE_CLEARTYPE_3x1 = 1, +}} +pub const DWRITE_ALPHA_MAX: BYTE = 255; +RIDL!{#[uuid(0x7d97dbf7, 0xe085, 0x42d4, 0x81, 0xe3, 0x6a, 0x88, 0x3b, 0xde, 0xd1, 0x18)] +interface IDWriteGlyphRunAnalysis(IDWriteGlyphRunAnalysisVtbl): IUnknown(IUnknownVtbl) { + fn GetAlphaTextureBounds( + textureType: DWRITE_TEXTURE_TYPE, + textureBounds: *mut RECT, + ) -> HRESULT, + fn CreateAlphaTexture( + textureType: DWRITE_TEXTURE_TYPE, + textureBounds: *const RECT, + alphaValues: *mut BYTE, + bufferSize: UINT32, + ) -> HRESULT, + fn GetAlphaBlendParams( + renderingParams: *mut IDWriteRenderingParams, + blendGamma: *mut FLOAT, + blendEnhancedContrast: *mut FLOAT, + blendClearTypeLevel: *mut FLOAT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb859ee5a, 0xd838, 0x4b5b, 0xa2, 0xe8, 0x1a, 0xdc, 0x7d, 0x93, 0xdb, 0x48)] +interface IDWriteFactory(IDWriteFactoryVtbl): IUnknown(IUnknownVtbl) { + fn GetSystemFontCollection( + fontCollection: *mut *mut IDWriteFontCollection, + checkForUpdates: BOOL, + ) -> HRESULT, + fn CreateCustomFontCollection( + collectionLoader: *mut IDWriteFontCollectionLoader, + collectionKey: *const c_void, + collectionKeySize: UINT32, + fontCollection: *mut *mut IDWriteFontCollection, + ) -> HRESULT, + fn RegisterFontCollectionLoader( + fontCollectionLoader: *mut IDWriteFontCollectionLoader, + ) -> HRESULT, + fn UnregisterFontCollectionLoader( + fontCollectionLoader: *mut IDWriteFontCollectionLoader, + ) -> HRESULT, + fn CreateFontFileReference( + filePath: *const WCHAR, + lastWriteTime: *const FILETIME, + fontFile: *mut *mut IDWriteFontFile, + ) -> HRESULT, + fn CreateCustomFontFileReference( + fontFileReferenceKey: *const c_void, + fontFileReferenceKeySize: UINT32, + fontFileLoader: *mut IDWriteFontFileLoader, + fontFile: *mut *mut IDWriteFontFile, + ) -> HRESULT, + fn CreateFontFace( + fontFaceType: DWRITE_FONT_FACE_TYPE, + numberOfFiles: UINT32, + fontFiles: *const *mut IDWriteFontFile, + faceIndex: UINT32, + fontFaceSimulationFlags: DWRITE_FONT_SIMULATIONS, + fontFace: *mut *mut IDWriteFontFace, + ) -> HRESULT, + fn CreateRenderingParams( + renderingParams: *mut *mut IDWriteRenderingParams, + ) -> HRESULT, + fn CreateMonitorRenderingParams( + monitor: HMONITOR, + renderingParams: *mut *mut IDWriteRenderingParams, + ) -> HRESULT, + fn CreateCustomRenderingParams( + gamma: FLOAT, + enhancedContrast: FLOAT, + clearTypeLevel: FLOAT, + pixelGeometry: DWRITE_PIXEL_GEOMETRY, + renderingMode: DWRITE_RENDERING_MODE, + renderingParams: *mut *mut IDWriteRenderingParams, + ) -> HRESULT, + fn RegisterFontFileLoader( + fontFileLoader: *mut IDWriteFontFileLoader, + ) -> HRESULT, + fn UnregisterFontFileLoader( + fontFileLoader: *mut IDWriteFontFileLoader, + ) -> HRESULT, + fn CreateTextFormat( + fontFamilyName: *const WCHAR, + fontCollection: *mut IDWriteFontCollection, + fontWeight: DWRITE_FONT_WEIGHT, + fontStyle: DWRITE_FONT_STYLE, + fontStretch: DWRITE_FONT_STRETCH, + fontSize: FLOAT, + localeName: *const WCHAR, + textFormat: *mut *mut IDWriteTextFormat, + ) -> HRESULT, + fn CreateTypography( + typography: *mut *mut IDWriteTypography, + ) -> HRESULT, + fn GetGdiInterop( + gdiInterop: *mut *mut IDWriteGdiInterop, + ) -> HRESULT, + fn CreateTextLayout( + string: *const WCHAR, + stringLength: UINT32, + textFormat: *mut IDWriteTextFormat, + maxWidth: FLOAT, + maxHeight: FLOAT, + textLayout: *mut *mut IDWriteTextLayout, + ) -> HRESULT, + fn CreateGdiCompatibleTextLayout( + string: *const WCHAR, + stringLength: UINT32, + textFormat: *mut IDWriteTextFormat, + layoutWidth: FLOAT, + layoutHeight: FLOAT, + pixelsPerDip: FLOAT, + transform: *const DWRITE_MATRIX, + useGdiNatrual: BOOL, + textLayout: *mut *mut IDWriteTextLayout, + ) -> HRESULT, + fn CreateEllipsisTrimmingSign( + textFormat: *mut IDWriteTextFormat, + trimmingSign: *mut *mut IDWriteInlineObject, + ) -> HRESULT, + fn CreateTextAnalyzer( + textAnalyzer: *mut *mut IDWriteTextAnalyzer, + ) -> HRESULT, + fn CreateNumberSubstitution( + substitutionMethod: DWRITE_NUMBER_SUBSTITUTION_METHOD, + localeName: *const WCHAR, + ignoreUserOverride: BOOL, + numberSubstitution: *mut *mut IDWriteNumberSubstitution, + ) -> HRESULT, + fn CreateGlyphRunAnalysis( + glyphRun: *const DWRITE_GLYPH_RUN, + pixelsPerDip: FLOAT, + transform: *const DWRITE_MATRIX, + renderingMode: DWRITE_RENDERING_MODE, + measuringMode: DWRITE_MEASURING_MODE, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + glyphRunAnalysis: *mut *mut IDWriteGlyphRunAnalysis, + ) -> HRESULT, +}} +pub const FACILITY_DWRITE: HRESULT = 0x898; +pub const DWRITE_ERR_BASE: HRESULT = 0x5000; +#[inline] +pub fn MAKE_DWRITE_HR(severity: HRESULT, code: HRESULT) -> HRESULT { + MAKE_HRESULT!(severity, FACILITY_DWRITE, DWRITE_ERR_BASE + code) +} +#[inline] +pub fn MAKE_DWRITE_HR_ERR(code: HRESULT) -> HRESULT { + MAKE_DWRITE_HR(SEVERITY_ERROR, code) +} +extern "system" { + pub fn DWriteCreateFactory( + factoryType: DWRITE_FACTORY_TYPE, iid: REFIID, factory: *mut *mut IUnknown, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite_1.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite_1.rs new file mode 100644 index 0000000..b762bbd --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite_1.rs @@ -0,0 +1,746 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the content of dwrite_1.h +use shared::basetsd::{INT16, INT32, UINT16, UINT32, UINT8}; +use shared::minwindef::{BOOL, FLOAT}; +use um::dcommon::DWRITE_MEASURING_MODE; +use um::dwrite::{ + DWRITE_GLYPH_OFFSET, DWRITE_MATRIX, DWRITE_PIXEL_GEOMETRY, DWRITE_RENDERING_MODE, + DWRITE_SCRIPT_ANALYSIS, DWRITE_SHAPING_GLYPH_PROPERTIES, DWRITE_TEXT_RANGE, + IDWriteBitmapRenderTarget, IDWriteBitmapRenderTargetVtbl, IDWriteFactory, IDWriteFactoryVtbl, + IDWriteFont, IDWriteFontCollection, IDWriteFontFace, IDWriteFontFaceVtbl, IDWriteFontVtbl, + IDWriteRenderingParams, IDWriteRenderingParamsVtbl, IDWriteTextAnalysisSink, + IDWriteTextAnalysisSinkVtbl, IDWriteTextAnalysisSource, IDWriteTextAnalysisSourceVtbl, + IDWriteTextAnalyzer, IDWriteTextAnalyzerVtbl, IDWriteTextLayout, IDWriteTextLayoutVtbl, +}; +use um::winnt::{HRESULT, WCHAR}; +ENUM!{enum DWRITE_PANOSE_FAMILY { + DWRITE_PANOSE_FAMILY_ANY = 0x0, // 0 + DWRITE_PANOSE_FAMILY_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_FAMILY_TEXT_DISPLAY = 0x2, // 2 + DWRITE_PANOSE_FAMILY_SCRIPT = 0x3, // 3 + DWRITE_PANOSE_FAMILY_DECORATIVE = 0x4, // 4 + DWRITE_PANOSE_FAMILY_SYMBOL = 0x5, // 5 + DWRITE_PANOSE_FAMILY_PICTORIAL = 0x5, // 5 +}} +ENUM!{enum DWRITE_PANOSE_SERIF_STYLE { + DWRITE_PANOSE_SERIF_STYLE_ANY = 0x0, // 0 + DWRITE_PANOSE_SERIF_STYLE_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_SERIF_STYLE_COVE = 0x2, // 2 + DWRITE_PANOSE_SERIF_STYLE_OBTUSE_COVE = 0x3, // 3 + DWRITE_PANOSE_SERIF_STYLE_SQUARE_COVE = 0x4, // 4 + DWRITE_PANOSE_SERIF_STYLE_OBTUSE_SQUARE_COVE = 0x5, // 5 + DWRITE_PANOSE_SERIF_STYLE_SQUARE = 0x6, // 6 + DWRITE_PANOSE_SERIF_STYLE_THIN = 0x7, // 7 + DWRITE_PANOSE_SERIF_STYLE_OVAL = 0x8, // 8 + DWRITE_PANOSE_SERIF_STYLE_EXAGGERATED = 0x9, // 9 + DWRITE_PANOSE_SERIF_STYLE_TRIANGLE = 0xA, // 10 + DWRITE_PANOSE_SERIF_STYLE_NORMAL_SANS = 0xB, // 11 + DWRITE_PANOSE_SERIF_STYLE_OBTUSE_SANS = 0xC, // 12 + DWRITE_PANOSE_SERIF_STYLE_PERPENDICULAR_SANS = 0xD, // 13 + DWRITE_PANOSE_SERIF_STYLE_FLARED = 0xE, // 14 + DWRITE_PANOSE_SERIF_STYLE_ROUNDED = 0xF, // 15 + DWRITE_PANOSE_SERIF_STYLE_SCRIPT = 0x10, // 16 + DWRITE_PANOSE_SERIF_STYLE_PERP_SANS = 0xD, // 13 + DWRITE_PANOSE_SERIF_STYLE_BONE = 0x8, // 8 +}} +ENUM!{enum DWRITE_PANOSE_WEIGHT { + DWRITE_PANOSE_WEIGHT_ANY = 0x0, // 0 + DWRITE_PANOSE_WEIGHT_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_WEIGHT_VERY_LIGHT = 0x2, // 2 + DWRITE_PANOSE_WEIGHT_LIGHT = 0x3, // 3 + DWRITE_PANOSE_WEIGHT_THIN = 0x4, // 4 + DWRITE_PANOSE_WEIGHT_BOOK = 0x5, // 5 + DWRITE_PANOSE_WEIGHT_MEDIUM = 0x6, // 6 + DWRITE_PANOSE_WEIGHT_DEMI = 0x7, // 7 + DWRITE_PANOSE_WEIGHT_BOLD = 0x8, // 8 + DWRITE_PANOSE_WEIGHT_HEAVY = 0x9, // 9 + DWRITE_PANOSE_WEIGHT_BLACK = 0xA, // 10 + DWRITE_PANOSE_WEIGHT_EXTRA_BLACK = 0xB, // 11 + DWRITE_PANOSE_WEIGHT_NORD = 0xB, // 11 +}} +ENUM!{enum DWRITE_PANOSE_PROPORTION { + DWRITE_PANOSE_PROPORTION_ANY = 0x0, // 0 + DWRITE_PANOSE_PROPORTION_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_PROPORTION_OLD_STYLE = 0x2, // 2 + DWRITE_PANOSE_PROPORTION_MODERN = 0x3, // 3 + DWRITE_PANOSE_PROPORTION_EVEN_WIDTH = 0x4, // 4 + DWRITE_PANOSE_PROPORTION_EXPANDED = 0x5, // 5 + DWRITE_PANOSE_PROPORTION_CONDENSED = 0x6, // 6 + DWRITE_PANOSE_PROPORTION_VERY_EXPANDED = 0x7, // 7 + DWRITE_PANOSE_PROPORTION_VERY_CONDENSED = 0x8, // 8 + DWRITE_PANOSE_PROPORTION_MONOSPACED = 0x9, // 9 +}} +ENUM!{enum DWRITE_PANOSE_CONTRAST { + DWRITE_PANOSE_CONTRAST_ANY = 0x0, // 0 + DWRITE_PANOSE_CONTRAST_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_CONTRAST_NONE = 0x2, // 2 + DWRITE_PANOSE_CONTRAST_VERY_LOW = 0x3, // 3 + DWRITE_PANOSE_CONTRAST_LOW = 0x4, // 4 + DWRITE_PANOSE_CONTRAST_MEDIUM_LOW = 0x5, // 5 + DWRITE_PANOSE_CONTRAST_MEDIUM = 0x6, // 6 + DWRITE_PANOSE_CONTRAST_MEDIUM_HIGH = 0x7, // 7 + DWRITE_PANOSE_CONTRAST_HIGH = 0x8, // 8 + DWRITE_PANOSE_CONTRAST_VERY_HIGH = 0x9, // 9 + DWRITE_PANOSE_CONTRAST_HORIZONTAL_LOW = 0xA, // 10 + DWRITE_PANOSE_CONTRAST_HORIZONTAL_MEDIUM = 0xB, // 11 + DWRITE_PANOSE_CONTRAST_HORIZONTAL_HIGH = 0xC, // 12 + DWRITE_PANOSE_CONTRAST_BROKEN = 0xD, // 13 +}} +ENUM!{enum DWRITE_PANOSE_STROKE_VARIATION { + DWRITE_PANOSE_STROKE_VARIATION_ANY = 0x0, // 0 + DWRITE_PANOSE_STROKE_VARIATION_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_STROKE_VARIATION_NO_VARIATION = 0x2, // 2 + DWRITE_PANOSE_STROKE_VARIATION_GRADUAL_DIAGONAL = 0x3, // 3 + DWRITE_PANOSE_STROKE_VARIATION_GRADUAL_TRANSITIONAL = 0x4, // 4 + DWRITE_PANOSE_STROKE_VARIATION_GRADUAL_VERTICAL = 0x5, // 5 + DWRITE_PANOSE_STROKE_VARIATION_GRADUAL_HORIZONTAL = 0x6, // 6 + DWRITE_PANOSE_STROKE_VARIATION_RAPID_VERTICAL = 0x7, // 7 + DWRITE_PANOSE_STROKE_VARIATION_RAPID_HORIZONTAL = 0x8, // 8 + DWRITE_PANOSE_STROKE_VARIATION_INSTANT_VERTICAL = 0x9, // 9 + DWRITE_PANOSE_STROKE_VARIATION_INSTANT_HORIZONTAL = 0xA, // 10 +}} +ENUM!{enum DWRITE_PANOSE_ARM_STYLE { + DWRITE_PANOSE_ARM_STYLE_ANY = 0x0, // 0 + DWRITE_PANOSE_ARM_STYLE_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_ARM_STYLE_STRAIGHT_ARMS_HORIZONTAL = 0x2, // 2 + DWRITE_PANOSE_ARM_STYLE_STRAIGHT_ARMS_WEDGE = 0x3, // 3 + DWRITE_PANOSE_ARM_STYLE_STRAIGHT_ARMS_VERTICAL = 0x4, // 4 + DWRITE_PANOSE_ARM_STYLE_STRAIGHT_ARMS_SINGLE_SERIF = 0x5, // 5 + DWRITE_PANOSE_ARM_STYLE_STRAIGHT_ARMS_DOUBLE_SERIF = 0x6, // 6 + DWRITE_PANOSE_ARM_STYLE_NONSTRAIGHT_ARMS_HORIZONTAL = 0x7, // 7 + DWRITE_PANOSE_ARM_STYLE_NONSTRAIGHT_ARMS_WEDGE = 0x8, // 8 + DWRITE_PANOSE_ARM_STYLE_NONSTRAIGHT_ARMS_VERTICAL = 0x9, // 9 + DWRITE_PANOSE_ARM_STYLE_NONSTRAIGHT_ARMS_SINGLE_SERIF = 0xA, // 10 + DWRITE_PANOSE_ARM_STYLE_NONSTRAIGHT_ARMS_DOUBLE_SERIF = 0xB, // 11 + DWRITE_PANOSE_ARM_STYLE_STRAIGHT_ARMS_HORZ = 0x2, // 2 + DWRITE_PANOSE_ARM_STYLE_STRAIGHT_ARMS_VERT = 0x4, // 4 + DWRITE_PANOSE_ARM_STYLE_BENT_ARMS_HORZ = 0x7, // 7 + DWRITE_PANOSE_ARM_STYLE_BENT_ARMS_WEDGE = 0x8, // 8 + DWRITE_PANOSE_ARM_STYLE_BENT_ARMS_VERT = 0x9, // 9 + DWRITE_PANOSE_ARM_STYLE_BENT_ARMS_SINGLE_SERIF = 0xA, // 10 + DWRITE_PANOSE_ARM_STYLE_BENT_ARMS_DOUBLE_SERIF = 0xB, // 11 +}} +ENUM!{enum DWRITE_PANOSE_LETTERFORM { + DWRITE_PANOSE_LETTERFORM_ANY = 0x0, // 0 + DWRITE_PANOSE_LETTERFORM_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_LETTERFORM_NORMAL_CONTACT = 0x2, // 2 + DWRITE_PANOSE_LETTERFORM_NORMAL_WEIGHTED = 0x3, // 3 + DWRITE_PANOSE_LETTERFORM_NORMAL_BOXED = 0x4, // 4 + DWRITE_PANOSE_LETTERFORM_NORMAL_FLATTENED = 0x5, // 5 + DWRITE_PANOSE_LETTERFORM_NORMAL_ROUNDED = 0x6, // 6 + DWRITE_PANOSE_LETTERFORM_NORMAL_OFF_CENTER = 0x7, // 7 + DWRITE_PANOSE_LETTERFORM_NORMAL_SQUARE = 0x8, // 8 + DWRITE_PANOSE_LETTERFORM_OBLIQUE_CONTACT = 0x9, // 9 + DWRITE_PANOSE_LETTERFORM_OBLIQUE_WEIGHTED = 0xA, // 10 + DWRITE_PANOSE_LETTERFORM_OBLIQUE_BOXED = 0xB, // 11 + DWRITE_PANOSE_LETTERFORM_OBLIQUE_FLATTENED = 0xC, // 12 + DWRITE_PANOSE_LETTERFORM_OBLIQUE_ROUNDED = 0xD, // 13 + DWRITE_PANOSE_LETTERFORM_OBLIQUE_OFF_CENTER = 0xE, // 14 + DWRITE_PANOSE_LETTERFORM_OBLIQUE_SQUARE = 0xF, // 15 +}} +ENUM!{enum DWRITE_PANOSE_MIDLINE { + DWRITE_PANOSE_MIDLINE_ANY = 0x0, // 0 + DWRITE_PANOSE_MIDLINE_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_MIDLINE_STANDARD_TRIMMED = 0x2, // 2 + DWRITE_PANOSE_MIDLINE_STANDARD_POINTED = 0x3, // 3 + DWRITE_PANOSE_MIDLINE_STANDARD_SERIFED = 0x4, // 4 + DWRITE_PANOSE_MIDLINE_HIGH_TRIMMED = 0x5, // 5 + DWRITE_PANOSE_MIDLINE_HIGH_POINTED = 0x6, // 6 + DWRITE_PANOSE_MIDLINE_HIGH_SERIFED = 0x7, // 7 + DWRITE_PANOSE_MIDLINE_CONSTANT_TRIMMED = 0x8, // 8 + DWRITE_PANOSE_MIDLINE_CONSTANT_POINTED = 0x9, // 9 + DWRITE_PANOSE_MIDLINE_CONSTANT_SERIFED = 0xA, // 10 + DWRITE_PANOSE_MIDLINE_LOW_TRIMMED = 0xB, // 11 + DWRITE_PANOSE_MIDLINE_LOW_POINTED = 0xC, // 12 + DWRITE_PANOSE_MIDLINE_LOW_SERIFED = 0xD, // 13 +}} +ENUM!{enum DWRITE_PANOSE_XHEIGHT { + DWRITE_PANOSE_XHEIGHT_ANY = 0x0, // 0 + DWRITE_PANOSE_XHEIGHT_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_XHEIGHT_CONSTANT_SMALL = 0x2, // 2 + DWRITE_PANOSE_XHEIGHT_CONSTANT_STANDARD = 0x3, // 3 + DWRITE_PANOSE_XHEIGHT_CONSTANT_LARGE = 0x4, // 4 + DWRITE_PANOSE_XHEIGHT_DUCKING_SMALL = 0x5, // 5 + DWRITE_PANOSE_XHEIGHT_DUCKING_STANDARD = 0x6, // 6 + DWRITE_PANOSE_XHEIGHT_DUCKING_LARGE = 0x7, // 7 + DWRITE_PANOSE_XHEIGHT_CONSTANT_STD = 0x3, // 3 + DWRITE_PANOSE_XHEIGHT_DUCKING_STD = 0x6, // 6 +}} +ENUM!{enum DWRITE_PANOSE_TOOL_KIND { + DWRITE_PANOSE_TOOL_KIND_ANY = 0x0, // 0 + DWRITE_PANOSE_TOOL_KIND_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_TOOL_KIND_FLAT_NIB = 0x2, // 2 + DWRITE_PANOSE_TOOL_KIND_PRESSURE_POINT = 0x3, // 3 + DWRITE_PANOSE_TOOL_KIND_ENGRAVED = 0x4, // 4 + DWRITE_PANOSE_TOOL_KIND_BALL = 0x5, // 5 + DWRITE_PANOSE_TOOL_KIND_BRUSH = 0x6, // 6 + DWRITE_PANOSE_TOOL_KIND_ROUGH = 0x7, // 7 + DWRITE_PANOSE_TOOL_KIND_FELT_PEN_BRUSH_TIP = 0x8, // 8 + DWRITE_PANOSE_TOOL_KIND_WILD_BRUSH = 0x9, // 9 +}} +ENUM!{enum DWRITE_PANOSE_SPACING { + DWRITE_PANOSE_SPACING_ANY = 0x0, // 0 + DWRITE_PANOSE_SPACING_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_SPACING_PROPORTIONAL_SPACED = 0x2, // 2 + DWRITE_PANOSE_SPACING_MONOSPACED = 0x3, // 3 +}} +ENUM!{enum DWRITE_PANOSE_ASPECT_RATIO { + DWRITE_PANOSE_ASPECT_RATIO_ANY = 0x0, // 0 + DWRITE_PANOSE_ASPECT_RATIO_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_ASPECT_RATIO_VERY_CONDENSED = 0x2, // 2 + DWRITE_PANOSE_ASPECT_RATIO_CONDENSED = 0x3, // 3 + DWRITE_PANOSE_ASPECT_RATIO_NORMAL = 0x4, // 4 + DWRITE_PANOSE_ASPECT_RATIO_EXPANDED = 0x5, // 5 + DWRITE_PANOSE_ASPECT_RATIO_VERY_EXPANDED = 0x6, // 6 +}} +ENUM!{enum DWRITE_PANOSE_SCRIPT_TOPOLOGY { + DWRITE_PANOSE_SCRIPT_TOPOLOGY_ANY = 0x0, // 0 + DWRITE_PANOSE_SCRIPT_TOPOLOGY_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_SCRIPT_TOPOLOGY_ROMAN_DISCONNECTED = 0x2, // 2 + DWRITE_PANOSE_SCRIPT_TOPOLOGY_ROMAN_TRAILING = 0x3, // 3 + DWRITE_PANOSE_SCRIPT_TOPOLOGY_ROMAN_CONNECTED = 0x4, // 4 + DWRITE_PANOSE_SCRIPT_TOPOLOGY_CURSIVE_DISCONNECTED = 0x5, // 5 + DWRITE_PANOSE_SCRIPT_TOPOLOGY_CURSIVE_TRAILING = 0x6, // 6 + DWRITE_PANOSE_SCRIPT_TOPOLOGY_CURSIVE_CONNECTED = 0x7, // 7 + DWRITE_PANOSE_SCRIPT_TOPOLOGY_BLACKLETTER_DISCONNECTED = 0x8, // 8 + DWRITE_PANOSE_SCRIPT_TOPOLOGY_BLACKLETTER_TRAILING = 0x9, // 9 + DWRITE_PANOSE_SCRIPT_TOPOLOGY_BLACKLETTER_CONNECTED = 0xA, // 10 +}} +ENUM!{enum DWRITE_PANOSE_SCRIPT_FORM { + DWRITE_PANOSE_SCRIPT_FORM_ANY = 0x0, // 0 + DWRITE_PANOSE_SCRIPT_FORM_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_SCRIPT_FORM_UPRIGHT_NO_WRAPPING = 0x2, // 2 + DWRITE_PANOSE_SCRIPT_FORM_UPRIGHT_SOME_WRAPPING = 0x3, // 3 + DWRITE_PANOSE_SCRIPT_FORM_UPRIGHT_MORE_WRAPPING = 0x4, // 4 + DWRITE_PANOSE_SCRIPT_FORM_UPRIGHT_EXTREME_WRAPPING = 0x5, // 5 + DWRITE_PANOSE_SCRIPT_FORM_OBLIQUE_NO_WRAPPING = 0x6, // 6 + DWRITE_PANOSE_SCRIPT_FORM_OBLIQUE_SOME_WRAPPING = 0x7, // 7 + DWRITE_PANOSE_SCRIPT_FORM_OBLIQUE_MORE_WRAPPING = 0x8, // 8 + DWRITE_PANOSE_SCRIPT_FORM_OBLIQUE_EXTREME_WRAPPING = 0x9, // 9 + DWRITE_PANOSE_SCRIPT_FORM_EXAGGERATED_NO_WRAPPING = 0xA, // 10 + DWRITE_PANOSE_SCRIPT_FORM_EXAGGERATED_SOME_WRAPPING = 0xB, // 11 + DWRITE_PANOSE_SCRIPT_FORM_EXAGGERATED_MORE_WRAPPING = 0xC, // 12 + DWRITE_PANOSE_SCRIPT_FORM_EXAGGERATED_EXTREME_WRAPPING = 0xD, // 13 +}} +ENUM!{enum DWRITE_PANOSE_FINIALS { + DWRITE_PANOSE_FINIALS_ANY = 0x0, // 0 + DWRITE_PANOSE_FINIALS_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_FINIALS_NONE_NO_LOOPS = 0x2, // 2 + DWRITE_PANOSE_FINIALS_NONE_CLOSED_LOOPS = 0x3, // 3 + DWRITE_PANOSE_FINIALS_NONE_OPEN_LOOPS = 0x4, // 4 + DWRITE_PANOSE_FINIALS_SHARP_NO_LOOPS = 0x5, // 5 + DWRITE_PANOSE_FINIALS_SHARP_CLOSED_LOOPS = 0x6, // 6 + DWRITE_PANOSE_FINIALS_SHARP_OPEN_LOOPS = 0x7, // 7 + DWRITE_PANOSE_FINIALS_TAPERED_NO_LOOPS = 0x8, // 8 + DWRITE_PANOSE_FINIALS_TAPERED_CLOSED_LOOPS = 0x9, // 9 + DWRITE_PANOSE_FINIALS_TAPERED_OPEN_LOOPS = 0xA, // 10 + DWRITE_PANOSE_FINIALS_ROUND_NO_LOOPS = 0xB, // 11 + DWRITE_PANOSE_FINIALS_ROUND_CLOSED_LOOPS = 0xC, // 12 + DWRITE_PANOSE_FINIALS_ROUND_OPEN_LOOPS = 0xD, // 13 +}} +ENUM!{enum DWRITE_PANOSE_XASCENT { + DWRITE_PANOSE_XASCENT_ANY = 0x0, // 0 + DWRITE_PANOSE_XASCENT_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_XASCENT_VERY_LOW = 0x2, // 2 + DWRITE_PANOSE_XASCENT_LOW = 0x3, // 3 + DWRITE_PANOSE_XASCENT_MEDIUM = 0x4, // 4 + DWRITE_PANOSE_XASCENT_HIGH = 0x5, // 5 + DWRITE_PANOSE_XASCENT_VERY_HIGH = 0x6, // 6 +}} +ENUM!{enum DWRITE_PANOSE_DECORATIVE_CLASS { + DWRITE_PANOSE_DECORATIVE_CLASS_ANY = 0x0, // 0 + DWRITE_PANOSE_DECORATIVE_CLASS_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_DECORATIVE_CLASS_DERIVATIVE = 0x2, // 2 + DWRITE_PANOSE_DECORATIVE_CLASS_NONSTANDARD_TOPOLOGY = 0x3, // 3 + DWRITE_PANOSE_DECORATIVE_CLASS_NONSTANDARD_ELEMENTS = 0x4, // 4 + DWRITE_PANOSE_DECORATIVE_CLASS_NONSTANDARD_ASPECT = 0x5, // 5 + DWRITE_PANOSE_DECORATIVE_CLASS_INITIALS = 0x6, // 6 + DWRITE_PANOSE_DECORATIVE_CLASS_CARTOON = 0x7, // 7 + DWRITE_PANOSE_DECORATIVE_CLASS_PICTURE_STEMS = 0x8, // 8 + DWRITE_PANOSE_DECORATIVE_CLASS_ORNAMENTED = 0x9, // 9 + DWRITE_PANOSE_DECORATIVE_CLASS_TEXT_AND_BACKGROUND = 0xA, // 10 + DWRITE_PANOSE_DECORATIVE_CLASS_COLLAGE = 0xB, // 11 + DWRITE_PANOSE_DECORATIVE_CLASS_MONTAGE = 0xC, // 12 +}} +ENUM!{enum DWRITE_PANOSE_ASPECT { + DWRITE_PANOSE_ASPECT_ANY = 0x0, // 0 + DWRITE_PANOSE_ASPECT_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_ASPECT_SUPER_CONDENSED = 0x2, // 2 + DWRITE_PANOSE_ASPECT_VERY_CONDENSED = 0x3, // 3 + DWRITE_PANOSE_ASPECT_CONDENSED = 0x4, // 4 + DWRITE_PANOSE_ASPECT_NORMAL = 0x5, // 5 + DWRITE_PANOSE_ASPECT_EXTENDED = 0x6, // 6 + DWRITE_PANOSE_ASPECT_VERY_EXTENDED = 0x7, // 7 + DWRITE_PANOSE_ASPECT_SUPER_EXTENDED = 0x8, // 8 + DWRITE_PANOSE_ASPECT_MONOSPACED = 0x9, // 9 +}} +ENUM!{enum DWRITE_PANOSE_FILL { + DWRITE_PANOSE_FILL_ANY = 0x0, // 0 + DWRITE_PANOSE_FILL_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_FILL_STANDARD_SOLID_FILL = 0x2, // 2 + DWRITE_PANOSE_FILL_NO_FILL = 0x3, // 3 + DWRITE_PANOSE_FILL_PATTERNED_FILL = 0x4, // 4 + DWRITE_PANOSE_FILL_COMPLEX_FILL = 0x5, // 5 + DWRITE_PANOSE_FILL_SHAPED_FILL = 0x6, // 6 + DWRITE_PANOSE_FILL_DRAWN_DISTRESSED = 0x7, // 7 +}} +ENUM!{enum DWRITE_PANOSE_LINING { + DWRITE_PANOSE_LINING_ANY = 0x0, // 0 + DWRITE_PANOSE_LINING_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_LINING_NONE = 0x2, // 2 + DWRITE_PANOSE_LINING_INLINE = 0x3, // 3 + DWRITE_PANOSE_LINING_OUTLINE = 0x4, // 4 + DWRITE_PANOSE_LINING_ENGRAVED = 0x5, // 5 + DWRITE_PANOSE_LINING_SHADOW = 0x6, // 6 + DWRITE_PANOSE_LINING_RELIEF = 0x7, // 7 + DWRITE_PANOSE_LINING_BACKDROP = 0x8, // 8 +}} +ENUM!{enum DWRITE_PANOSE_DECORATIVE_TOPOLOGY { + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_ANY = 0x0, // 0 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_STANDARD = 0x2, // 2 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_SQUARE = 0x3, // 3 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_MULTIPLE_SEGMENT = 0x4, // 4 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_ART_DECO = 0x5, // 5 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_UNEVEN_WEIGHTING = 0x6, // 6 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_DIVERSE_ARMS = 0x7, // 7 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_DIVERSE_FORMS = 0x8, // 8 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_LOMBARDIC_FORMS = 0x9, // 9 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_UPPER_CASE_IN_LOWER_CASE = 0xA, // 10 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_IMPLIED_TOPOLOGY = 0xB, // 11 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_HORSESHOE_E_AND_A = 0xC, // 12 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_CURSIVE = 0xD, // 13 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_BLACKLETTER = 0xE, // 14 + DWRITE_PANOSE_DECORATIVE_TOPOLOGY_SWASH_VARIANCE = 0xF, // 15 +}} +ENUM!{enum DWRITE_PANOSE_CHARACTER_RANGES { + DWRITE_PANOSE_CHARACTER_RANGES_ANY = 0x0, // 0 + DWRITE_PANOSE_CHARACTER_RANGES_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_CHARACTER_RANGES_EXTENDED_COLLECTION = 0x2, // 2 + DWRITE_PANOSE_CHARACTER_RANGES_LITERALS = 0x3, // 3 + DWRITE_PANOSE_CHARACTER_RANGES_NO_LOWER_CASE = 0x4, // 4 + DWRITE_PANOSE_CHARACTER_RANGES_SMALL_CAPS = 0x5, // 5 +}} +ENUM!{enum DWRITE_PANOSE_SYMBOL_KIND { + DWRITE_PANOSE_SYMBOL_KIND_ANY = 0x0, // 0 + DWRITE_PANOSE_SYMBOL_KIND_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_SYMBOL_KIND_MONTAGES = 0x2, // 2 + DWRITE_PANOSE_SYMBOL_KIND_PICTURES = 0x3, // 3 + DWRITE_PANOSE_SYMBOL_KIND_SHAPES = 0x4, // 4 + DWRITE_PANOSE_SYMBOL_KIND_SCIENTIFIC = 0x5, // 5 + DWRITE_PANOSE_SYMBOL_KIND_MUSIC = 0x6, // 6 + DWRITE_PANOSE_SYMBOL_KIND_EXPERT = 0x7, // 7 + DWRITE_PANOSE_SYMBOL_KIND_PATTERNS = 0x8, // 8 + DWRITE_PANOSE_SYMBOL_KIND_BOARDERS = 0x9, // 9 + DWRITE_PANOSE_SYMBOL_KIND_ICONS = 0xA, // 10 + DWRITE_PANOSE_SYMBOL_KIND_LOGOS = 0xB, // 11 + DWRITE_PANOSE_SYMBOL_KIND_INDUSTRY_SPECIFIC = 0xC, // 12 +}} +ENUM!{enum DWRITE_PANOSE_SYMBOL_ASPECT_RATIO { + DWRITE_PANOSE_SYMBOL_ASPECT_RATIO_ANY = 0x0, // 0 + DWRITE_PANOSE_SYMBOL_ASPECT_RATIO_NO_FIT = 0x1, // 1 + DWRITE_PANOSE_SYMBOL_ASPECT_RATIO_NO_WIDTH = 0x2, // 2 + DWRITE_PANOSE_SYMBOL_ASPECT_RATIO_EXCEPTIONALLY_WIDE = 0x3, // 3 + DWRITE_PANOSE_SYMBOL_ASPECT_RATIO_SUPER_WIDE = 0x4, // 4 + DWRITE_PANOSE_SYMBOL_ASPECT_RATIO_VERY_WIDE = 0x5, // 5 + DWRITE_PANOSE_SYMBOL_ASPECT_RATIO_WIDE = 0x6, // 6 + DWRITE_PANOSE_SYMBOL_ASPECT_RATIO_NORMAL = 0x7, // 7 + DWRITE_PANOSE_SYMBOL_ASPECT_RATIO_NARROW = 0x8, // 8 + DWRITE_PANOSE_SYMBOL_ASPECT_RATIO_VERY_NARROW = 0x9, // 9 +}} +ENUM!{enum DWRITE_OUTLINE_THRESHOLD { + DWRITE_OUTLINE_THRESHOLD_ANTIALIASED = 0x0, // 0 + DWRITE_OUTLINE_THRESHOLD_ALIASED = 0x1, // 1 +}} +ENUM!{enum DWRITE_BASELINE { + DWRITE_BASELINE_DEFAULT = 0x0, // 0 + DWRITE_BASELINE_ROMAN = 0x1, // 1 + DWRITE_BASELINE_CENTRAL = 0x2, // 2 + DWRITE_BASELINE_MATH = 0x3, // 3 + DWRITE_BASELINE_HANGING = 0x4, // 4 + DWRITE_BASELINE_IDEOGRAPHIC_BOTTOM = 0x5, // 5 + DWRITE_BASELINE_IDEOGRAPHIC_TOP = 0x6, // 6 + DWRITE_BASELINE_MINIMUM = 0x7, // 7 + DWRITE_BASELINE_MAXIMUM = 0x8, // 8 +}} +ENUM!{enum DWRITE_VERTICAL_GLYPH_ORIENTATION { + DWRITE_VERTICAL_GLYPH_ORIENTATION_DEFAULT = 0x0, // 0 + DWRITE_VERTICAL_GLYPH_ORIENTATION_STACKED = 0x1, // 1 +}} +ENUM!{enum DWRITE_GLYPH_ORIENTATION_ANGLE { + DWRITE_GLYPH_ORIENTATION_ANGLE_0_DEGREES = 0x0, // 0 + DWRITE_GLYPH_ORIENTATION_ANGLE_90_DEGREES = 0x1, // 1 + DWRITE_GLYPH_ORIENTATION_ANGLE_180_DEGREES = 0x2, // 2 + DWRITE_GLYPH_ORIENTATION_ANGLE_270_DEGREES = 0x3, // 3 +}} +STRUCT!{struct DWRITE_FONT_METRICS1 { + designUnitsPerEm: UINT16, + ascent: UINT16, + descent: UINT16, + lineGap: INT16, + capHeight: UINT16, + xHeight: UINT16, + underlinePosition: INT16, + underlineThickness: UINT16, + strikethroughPosition: INT16, + strikethroughThickness: UINT16, + glyphBoxLeft: INT16, + glyphBoxTop: INT16, + glyphBoxRight: INT16, + glyphBoxBottom: INT16, + subscriptPositionX: INT16, + subscriptPositionY: INT16, + subscriptSizeX: INT16, + subscriptSizeY: INT16, + superscriptPositionX: INT16, + superscriptPositionY: INT16, + superscriptSizeX: INT16, + superscriptSizeY: INT16, + hasTypographicMetrics: BOOL, +}} +STRUCT!{struct DWRITE_CARET_METRICS { + slopeRise: INT16, + slopeRun: INT16, + offset: INT16, +}} +STRUCT!{struct DWRITE_PANOSE_text { + familyKind: UINT8, + serifStyle: UINT8, + weight: UINT8, + proportion: UINT8, + contrast: UINT8, + strokeVariation: UINT8, + armStyle: UINT8, + letterform: UINT8, + midline: UINT8, + xHeight: UINT8, +}} +STRUCT!{struct DWRITE_PANOSE_script { + familyKind: UINT8, + toolKind: UINT8, + weight: UINT8, + spacing: UINT8, + aspectRatio: UINT8, + contrast: UINT8, + scriptTopology: UINT8, + scriptForm: UINT8, + finials: UINT8, + xAscent: UINT8, +}} +STRUCT!{struct DWRITE_PANOSE_decorative { + familyKind: UINT8, + decorativeClass: UINT8, + weight: UINT8, + aspect: UINT8, + contrast: UINT8, + serifVariant: UINT8, + fill: UINT8, + lining: UINT8, + decorativeTopology: UINT8, + characterRange: UINT8, +}} +STRUCT!{struct DWRITE_PANOSE_symbol { + familyKind: UINT8, + symbolKind: UINT8, + weight: UINT8, + spacing: UINT8, + aspectRatioAndContrast: UINT8, + aspectRatio94: UINT8, + aspectRatio119: UINT8, + aspectRatio157: UINT8, + aspectRatio163: UINT8, + aspectRatio211: UINT8, +}} +UNION!{union DWRITE_PANOSE { + [u8; 10], + values values_mut: [UINT8; 10], + familyKind familyKind_mut: UINT8, + text text_mut: DWRITE_PANOSE_text, + script script_mut: DWRITE_PANOSE_script, + decorative decorative_mut: DWRITE_PANOSE_decorative, + symbol symbol_mut: DWRITE_PANOSE_symbol, +}} +STRUCT!{struct DWRITE_UNICODE_RANGE { + first: UINT32, + last: UINT32, +}} +STRUCT!{struct DWRITE_SCRIPT_PROPERTIES { + isoScriptCode: UINT32, + isoScriptNumber: UINT32, + clusterLookahead: UINT32, + justificationCharacter: UINT32, + bitfield0: UINT32, +}} +BITFIELD!{DWRITE_SCRIPT_PROPERTIES bitfield0: UINT32 [ + restrictCaretToClusters set_restrictCaretToClusters[0..1], + usesWordDividers set_usesWordDividers[1..2], + isDiscreteWriting set_isDiscreteWriting[2..3], + isBlockWriting set_isBlockWriting[3..4], + isDistributedWithinCluster set_isDistributedWithinCluster[4..5], + isConnectedWriting set_isConnectedWriting[5..6], + isCursiveWriting set_isCursiveWriting[6..7], + reserved set_reserved[7..32], +]} +STRUCT!{struct DWRITE_JUSTIFICATION_OPPORTUNITY { + expansionMinimum: FLOAT, + expansionMaximum: FLOAT, + compressionMaximum: FLOAT, + bitfield0: UINT32, +}} +BITFIELD!{DWRITE_JUSTIFICATION_OPPORTUNITY bitfield0: UINT32 [ + expansionPriority set_expansionPriority[0..8], + compressionPriority set_compressionPriority[8..16], + allowResidualExpansion set_allowResidualExpansion[16..17], + allowResidualCompression set_allowResidualCompression[17..18], + applyToLeadingEdge set_applyToLeadingEdge[18..19], + applyToTrailingEdge set_applyToTrailingEdge[19..20], + reserved set_reserved[20..32], +]} +RIDL!{#[uuid(0x30572f99, 0xdac6, 0x41db, 0xa1, 0x6e, 0x04, 0x86, 0x30, 0x7e, 0x60, 0x6a)] +interface IDWriteFactory1(IDWriteFactory1Vtbl): IDWriteFactory(IDWriteFactoryVtbl) { + fn GetEudcFontCollection( + fontCollection: *mut *mut IDWriteFontCollection, + checkForUpdates: BOOL, + ) -> HRESULT, + fn CreateCustomRenderingParams( + gamma: FLOAT, + enhancedContrast: FLOAT, + enhancedContrastGrayscale: FLOAT, + clearTypeLevel: FLOAT, + pixelGeometry: DWRITE_PIXEL_GEOMETRY, + renderingMode: DWRITE_RENDERING_MODE, + renderingParams: *mut *mut IDWriteRenderingParams1, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa71efdb4, 0x9fdb, 0x4838, 0xad, 0x90, 0xcf, 0xc3, 0xbe, 0x8c, 0x3d, 0xaf)] +interface IDWriteFontFace1(IDWriteFontFace1Vtbl): IDWriteFontFace(IDWriteFontFaceVtbl) { + fn GetMetrics( + fontMetrics: *mut DWRITE_FONT_METRICS1, + ) -> (), + fn GetGdiCompatibleMetrics( + emSize: FLOAT, + pixelsPerDip: FLOAT, + transform: *const DWRITE_MATRIX, + fontMetrics: *mut DWRITE_FONT_METRICS1, + ) -> HRESULT, + fn GetCaretMetrics( + caretMetrics: *mut DWRITE_CARET_METRICS, + ) -> (), + fn GetUnicodeRanges( + maxRangeCount: UINT32, + unicodeRanges: *mut DWRITE_UNICODE_RANGE, + actualRangeCount: *mut UINT32, + ) -> HRESULT, + fn IsMonospacedFont() -> BOOL, + fn GetDesignGlyphAdvances( + glyphCount: UINT32, + glyphIndices: *const UINT16, + glyphAdvances: *mut INT32, + isSideways: BOOL, + ) -> HRESULT, + fn GetGdiCompatibleGlyphAdvances( + emSize: FLOAT, + pixelsPerDip: FLOAT, + transform: *const DWRITE_MATRIX, + useGdiNatural: BOOL, + isSideways: BOOL, + glyphCount: UINT32, + glyphIndices: *const UINT16, + glyphAdvances: *mut INT32, + ) -> HRESULT, + fn GetKerningPairAdjustments( + glyphCount: UINT32, + glyphIndices: *const UINT16, + glyphAdvanceAdjustments: *mut INT32, + ) -> HRESULT, + fn HasKerningPairs() -> BOOL, + fn GetRecommendedRenderingMode( + fontEmSize: FLOAT, + dpiX: FLOAT, + dpiY: FLOAT, + transform: *const DWRITE_MATRIX, + isSideways: BOOL, + outlineThreshold: DWRITE_OUTLINE_THRESHOLD, + measuringMode: DWRITE_MEASURING_MODE, + renderingMode: *mut DWRITE_RENDERING_MODE, + ) -> HRESULT, + fn GetVerticalGlyphVariants( + glyphCount: UINT32, + nominalGlyphIndices: *const UINT16, + verticalGlyphIndices: *mut UINT16, + ) -> HRESULT, + fn HasVerticalGlyphVariants() -> BOOL, +}} +RIDL!{#[uuid(0xacd16696, 0x8c14, 0x4f5d, 0x87, 0x7e, 0xfe, 0x3f, 0xc1, 0xd3, 0x27, 0x38)] +interface IDWriteFont1(IDWriteFont1Vtbl): IDWriteFont(IDWriteFontVtbl) { + fn GetMetrics( + fontMetrics: *mut DWRITE_FONT_METRICS1, + ) -> (), + fn GetPanose( + panose: *mut DWRITE_PANOSE, + ) -> (), + fn GetUnicodeRanges( + maxRangeCount: UINT32, + unicodeRanges: *mut DWRITE_UNICODE_RANGE, + actualRangeCount: *mut UINT32, + ) -> HRESULT, + fn IsMonospacedFont() -> BOOL, +}} +RIDL!{#[uuid(0x94413cf4, 0xa6fc, 0x4248, 0x8b, 0x50, 0x66, 0x74, 0x34, 0x8f, 0xca, 0xd3)] +interface IDWriteRenderingParams1(IDWriteRenderingParams1Vtbl): + IDWriteRenderingParams(IDWriteRenderingParamsVtbl) { + fn GetGrayscaleEnhancedContrast() -> FLOAT, +}} +RIDL!{#[uuid(0x80dad800, 0xe21f, 0x4e83, 0x96, 0xce, 0xbf, 0xcc, 0xe5, 0x00, 0xdb, 0x7c)] +interface IDWriteTextAnalyzer1(IDWriteTextAnalyzer1Vtbl): + IDWriteTextAnalyzer(IDWriteTextAnalyzerVtbl) { + fn ApplyCharacterSpacing( + leadingSpacing: FLOAT, + trailingSpacing: FLOAT, + minimumAdvanceWidth: FLOAT, + textLength: UINT32, + glyphCount: UINT32, + clusterMap: *const UINT16, + glyphAdvances: *const FLOAT, + glyphOffsets: *const DWRITE_GLYPH_OFFSET, + glyphProperties: *const DWRITE_SHAPING_GLYPH_PROPERTIES, + modifiedGlyphAdvances: *mut FLOAT, + modifiedGlyphOffsets: *mut DWRITE_GLYPH_OFFSET, + ) -> HRESULT, + fn GetBaseline( + fontFace: *mut IDWriteFontFace, + baseline: DWRITE_BASELINE, + isVertical: BOOL, + isSimulationAllowed: BOOL, + scriptAnalysis: DWRITE_SCRIPT_ANALYSIS, + localeName: *const WCHAR, + baselineCoordinate: *mut INT32, + exists: *mut BOOL, + ) -> HRESULT, + fn AnalyzeVerticalGlyphOrientation( + analysisSource: *mut IDWriteTextAnalysisSource1, + textPosition: UINT32, + textLength: UINT32, + analysisSink: *mut IDWriteTextAnalysisSink1, + ) -> HRESULT, + fn GetGlyphOrientationTransform( + glyphOrientationAngle: DWRITE_GLYPH_ORIENTATION_ANGLE, + isSideways: BOOL, + transform: *mut DWRITE_MATRIX, + ) -> HRESULT, + fn GetScriptProperties( + scriptAnalysis: DWRITE_SCRIPT_ANALYSIS, + scriptProperties: *mut DWRITE_SCRIPT_PROPERTIES, + ) -> HRESULT, + fn GetTextComplexity( + textString: *const WCHAR, + textLength: UINT32, + fontFace: *mut IDWriteFontFace, + isTextSimple: *mut BOOL, + textLengthRead: *mut UINT32, + glyphIndices: *mut UINT16, + ) -> HRESULT, + fn GetJustificationOpportunities( + fontFace: *mut IDWriteFontFace, + fontEmSize: FLOAT, + scriptAnalysis: DWRITE_SCRIPT_ANALYSIS, + textLength: UINT32, + glyphCount: UINT32, + textString: *const WCHAR, + clusterMap: *const UINT16, + glyphProperties: *const DWRITE_SHAPING_GLYPH_PROPERTIES, + justificationOpportunities: *mut DWRITE_JUSTIFICATION_OPPORTUNITY, + ) -> HRESULT, + fn JustifyGlyphAdvances( + lineWidth: FLOAT, + glyphCount: UINT32, + justificationOpportunities: *const DWRITE_JUSTIFICATION_OPPORTUNITY, + glyphAdvances: *const FLOAT, + glyphOffsets: *const DWRITE_GLYPH_OFFSET, + justifiedGlyphAdvances: *mut FLOAT, + justifiedGlyphOffsets: *mut DWRITE_GLYPH_OFFSET, + ) -> HRESULT, + fn GetJustifiedGlyphs( + fontFace: *mut IDWriteFontFace, + fontEmSize: FLOAT, + scriptAnalysis: DWRITE_SCRIPT_ANALYSIS, + textLength: UINT32, + glyphCount: UINT32, + maxGlyphCount: UINT32, + clusterMap: *const UINT16, + glyphIndices: *const UINT16, + glyphAdvances: *const FLOAT, + justifiedGlyphAdvances: *const FLOAT, + justifiedGlyphOffsets: *const DWRITE_GLYPH_OFFSET, + glyphProperties: *const DWRITE_SHAPING_GLYPH_PROPERTIES, + actualGlyphCount: *mut UINT32, + modifiedClusterMap: *mut UINT16, + modifiedGlyphIndices: *mut UINT16, + modifiedGlyphAdvances: *mut FLOAT, + modifiedGlyphOffsets: *mut DWRITE_GLYPH_OFFSET, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x639cfad8, 0x0fb4, 0x4b21, 0xa5, 0x8a, 0x06, 0x79, 0x20, 0x12, 0x00, 0x09)] +interface IDWriteTextAnalysisSource1(IDWriteTextAnalysisSource1Vtbl): + IDWriteTextAnalysisSource(IDWriteTextAnalysisSourceVtbl) { + fn GetVerticalGlyphOrientation( + textPosition: UINT32, + textLength: *mut UINT32, + glyphOrientation: *mut DWRITE_VERTICAL_GLYPH_ORIENTATION, + bidiLevel: *mut UINT8, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb0d941a0, 0x85e7, 0x4d8b, 0x9f, 0xd3, 0x5c, 0xed, 0x99, 0x34, 0x48, 0x2a)] +interface IDWriteTextAnalysisSink1(IDWriteTextAnalysisSink1Vtbl): + IDWriteTextAnalysisSink(IDWriteTextAnalysisSinkVtbl) { + fn SetGlyphOrientation( + textPosition: UINT32, + textLength: UINT32, + glyphOrientationAngle: DWRITE_GLYPH_ORIENTATION_ANGLE, + adjustedBidiLevel: UINT8, + isSideways: BOOL, + isRightToLeft: BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9064d822, 0x80a7, 0x465c, 0xa9, 0x86, 0xdf, 0x65, 0xf7, 0x8b, 0x8f, 0xeb)] +interface IDWriteTextLayout1(IDWriteTextLayout1Vtbl): + IDWriteTextLayout(IDWriteTextLayoutVtbl) { + fn SetPairKerning( + isPairKerningEnabled: BOOL, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetPairKerning( + currentPosition: UINT32, + isPairKerningEnabled: *mut BOOL, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn SetCharacterSpacing( + leadingSpacing: FLOAT, + trailingSpacing: FLOAT, + minimumAdvanceWidth: FLOAT, + textRange: DWRITE_TEXT_RANGE, + ) -> HRESULT, + fn GetCharacterSpacing( + currentPosition: UINT32, + leadingSpacing: *mut FLOAT, + trailingSpacing: *mut FLOAT, + minimumAdvanceWidth: *mut FLOAT, + textRange: *mut DWRITE_TEXT_RANGE, + ) -> HRESULT, +}} +ENUM!{enum DWRITE_TEXT_ANTIALIAS_MODE { + DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE = 0x0, // 0 + DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE = 0x1, // 1 +}} +RIDL!{#[uuid(0x791e8298, 0x3ef3, 0x4230, 0x98, 0x80, 0xc9, 0xbd, 0xec, 0xc4, 0x20, 0x64)] +interface IDWriteBitmapRenderTarget1(IDWriteBitmapRenderTarget1Vtbl): + IDWriteBitmapRenderTarget(IDWriteBitmapRenderTargetVtbl) { + fn GetTextAntialiasMode() -> DWRITE_TEXT_ANTIALIAS_MODE, + fn SetTextAntialiasMode( + antialiasMode: DWRITE_TEXT_ANTIALIAS_MODE, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite_2.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite_2.rs new file mode 100644 index 0000000..e9810bb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite_2.rs @@ -0,0 +1,293 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the content of dwrite_2.h +use ctypes::{c_void, wchar_t}; +use shared::basetsd::{UINT16, UINT32, UINT8}; +use shared::d3d9types::D3DCOLORVALUE; +use shared::minwindef::{BOOL, FLOAT}; +use um::dcommon::DWRITE_MEASURING_MODE; +use um::dwrite::{ + DWRITE_FONT_FEATURE_TAG, DWRITE_FONT_STRETCH, DWRITE_FONT_STYLE, DWRITE_FONT_WEIGHT, + DWRITE_GLYPH_RUN, DWRITE_GLYPH_RUN_DESCRIPTION, DWRITE_MATRIX, DWRITE_PIXEL_GEOMETRY, + DWRITE_RENDERING_MODE, DWRITE_SCRIPT_ANALYSIS, DWRITE_STRIKETHROUGH, DWRITE_UNDERLINE, + IDWriteFont, IDWriteFontCollection, IDWriteFontFace, IDWriteGlyphRunAnalysis, + IDWriteInlineObject, IDWriteRenderingParams, IDWriteTextAnalysisSource, IDWriteTextFormat, + IDWriteTextFormatVtbl, IDWriteTextRenderer, IDWriteTextRendererVtbl, +}; +use um::dwrite_1::{ + DWRITE_GLYPH_ORIENTATION_ANGLE, DWRITE_OUTLINE_THRESHOLD, DWRITE_TEXT_ANTIALIAS_MODE, + DWRITE_UNICODE_RANGE, DWRITE_VERTICAL_GLYPH_ORIENTATION, IDWriteFactory1, + IDWriteFactory1Vtbl, IDWriteFont1, IDWriteFont1Vtbl, IDWriteFontFace1, IDWriteFontFace1Vtbl, + IDWriteRenderingParams1, IDWriteRenderingParams1Vtbl, IDWriteTextAnalyzer1, + IDWriteTextAnalyzer1Vtbl, IDWriteTextLayout1, IDWriteTextLayout1Vtbl, +}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, WCHAR}; +ENUM!{enum DWRITE_OPTICAL_ALIGNMENT { + DWRITE_OPTICAL_ALIGNMENT_NONE = 0x0, // 0 + DWRITE_OPTICAL_ALIGNMENT_NO_SIDE_BEARINGS = 0x1, // 1 +}} +ENUM!{enum DWRITE_GRID_FIT_MODE { + DWRITE_GRID_FIT_MODE_DEFAULT = 0x0, // 0 + DWRITE_GRID_FIT_MODE_DISABLED = 0x1, // 1 + DWRITE_GRID_FIT_MODE_ENABLED = 0x2, // 2 +}} +STRUCT!{struct DWRITE_TEXT_METRICS1 { + left: FLOAT, + top: FLOAT, + width: FLOAT, + widthIncludingTrailingWhitespace: FLOAT, + height: FLOAT, + layoutWidth: FLOAT, + layoutHeight: FLOAT, + maxBidiReorderingDepth: UINT32, + lineCount: UINT32, + heightIncludingTrailingWhitespace: FLOAT, +}} +RIDL!{#[uuid(0xd3e0e934, 0x22a0, 0x427e, 0xaa, 0xe4, 0x7d, 0x95, 0x74, 0xb5, 0x9d, 0xb1)] +interface IDWriteTextRenderer1(IDWriteTextRenderer1Vtbl): + IDWriteTextRenderer(IDWriteTextRendererVtbl) { + fn DrawGlyphRun( + clientDrawingContext: *mut c_void, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + orientationAngle: DWRITE_GLYPH_ORIENTATION_ANGLE, + measuringMode: DWRITE_MEASURING_MODE, + glyphRun: *const DWRITE_GLYPH_RUN, + glyphRunDescription: *const DWRITE_GLYPH_RUN_DESCRIPTION, + clientDrawingEffect: *mut IUnknown, + ) -> HRESULT, + fn DrawUnderline( + clientDrawingContext: *mut c_void, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + orientationAngle: DWRITE_GLYPH_ORIENTATION_ANGLE, + underline: *const DWRITE_UNDERLINE, + clientDrawingEffect: *mut IUnknown, + ) -> HRESULT, + fn DrawStrikethrough( + clientDrawingContext: *mut c_void, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + orientationAngle: DWRITE_GLYPH_ORIENTATION_ANGLE, + strikethrough: *const DWRITE_STRIKETHROUGH, + clientDrawingEffect: *mut IUnknown, + ) -> HRESULT, + fn DrawInlineObject( + clientDrawingContext: *mut c_void, + originX: FLOAT, + originY: FLOAT, + orientationAngle: DWRITE_GLYPH_ORIENTATION_ANGLE, + inlineObject: *mut IDWriteInlineObject, + isSideways: BOOL, + isRightToLeft: BOOL, + clientDrawingEffect: *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5f174b49, 0x0d8b, 0x4cfb, 0x8b, 0xca, 0xf1, 0xcc, 0xe9, 0xd0, 0x6c, 0x67)] +interface IDWriteTextFormat1(IDWriteTextFormat1Vtbl): + IDWriteTextFormat(IDWriteTextFormatVtbl) { + fn SetVerticalGlyphOrientation( + glyphOrientation: DWRITE_VERTICAL_GLYPH_ORIENTATION, + ) -> HRESULT, + fn GetVerticalGlyphOrientation() -> DWRITE_VERTICAL_GLYPH_ORIENTATION, + fn SetLastLineWrapping( + isLastLineWrappingEnabled: BOOL, + ) -> HRESULT, + fn GetLastLineWrapping() -> BOOL, + fn SetOpticalAlignment( + opticalAlignment: DWRITE_OPTICAL_ALIGNMENT, + ) -> HRESULT, + fn GetOpticalAlignment() -> DWRITE_OPTICAL_ALIGNMENT, + fn SetFontFallback( + fontFallback: *mut IDWriteFontFallback, + ) -> HRESULT, + fn GetFontFallback( + fontFallback: *mut *mut IDWriteFontFallback, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1093c18f, 0x8d5e, 0x43f0, 0xb0, 0x64, 0x09, 0x17, 0x31, 0x1b, 0x52, 0x5e)] +interface IDWriteTextLayout2(IDWriteTextLayout2Vtbl): + IDWriteTextLayout1(IDWriteTextLayout1Vtbl) { + fn GetMetrics( + textMetrics: *mut DWRITE_TEXT_METRICS1, + ) -> HRESULT, + fn SetVerticalGlyphOrientation( + glyphOrientation: DWRITE_VERTICAL_GLYPH_ORIENTATION, + ) -> HRESULT, + fn GetVerticalGlyphOrientation() -> DWRITE_VERTICAL_GLYPH_ORIENTATION, + fn SetLastLineWrapping( + isLastLineWrappingEnabled: BOOL, + ) -> HRESULT, + fn GetLastLineWrapping() -> BOOL, + fn SetOpticalAlignment( + opticalAlignment: DWRITE_OPTICAL_ALIGNMENT, + ) -> HRESULT, + fn GetOpticalAlignment() -> DWRITE_OPTICAL_ALIGNMENT, + fn SetFontFallback( + fontFallback: *mut IDWriteFontFallback, + ) -> HRESULT, + fn GetFontFallback( + fontFallback: *mut *mut IDWriteFontFallback, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x553a9ff3, 0x5693, 0x4df7, 0xb5, 0x2b, 0x74, 0x80, 0x6f, 0x7f, 0x2e, 0xb9)] +interface IDWriteTextAnalyzer2(IDWriteTextAnalyzer2Vtbl): + IDWriteTextAnalyzer1(IDWriteTextAnalyzer1Vtbl) { + fn GetGlyphOrientationTransform( + glyphOrientationAngle: DWRITE_GLYPH_ORIENTATION_ANGLE, + isSideways: BOOL, + originX: FLOAT, + originY: FLOAT, + transform: *mut DWRITE_MATRIX, + ) -> HRESULT, + fn GetTypographicFeatures( + fontFace: *mut IDWriteFontFace, + scriptAnalysis: DWRITE_SCRIPT_ANALYSIS, + localeName: *const WCHAR, + maxTagCount: UINT32, + actualTagCount: *mut UINT32, + tags: *mut DWRITE_FONT_FEATURE_TAG, + ) -> HRESULT, + fn CheckTypographicFeature( + fontFace: *mut IDWriteFontFace, + scriptAnalysis: DWRITE_SCRIPT_ANALYSIS, + localeName: *const WCHAR, + featureTag: DWRITE_FONT_FEATURE_TAG, + glyphCount: UINT32, + glyphIndices: *const UINT16, + featureApplies: *mut UINT8, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xefa008f9, 0xf7a1, 0x48bf, 0xb0, 0x5c, 0xf2, 0x24, 0x71, 0x3c, 0xc0, 0xff)] +interface IDWriteFontFallback(IDWriteFontFallbackVtbl): IUnknown(IUnknownVtbl) { + fn MapCharacters( + analysisSource: *mut IDWriteTextAnalysisSource, + textPosition: UINT32, + textLength: UINT32, + baseFontCollection: *mut IDWriteFontCollection, + baseFamilyName: *mut wchar_t, + baseWeight: DWRITE_FONT_WEIGHT, + baseStyle: DWRITE_FONT_STYLE, + baseStretch: DWRITE_FONT_STRETCH, + mappedLength: *mut UINT32, + mappedFont: *mut *mut IDWriteFont, + scale: *mut FLOAT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xfd882d06, 0x8aba, 0x4fb8, 0xb8, 0x49, 0x8b, 0xe8, 0xb7, 0x3e, 0x14, 0xde)] +interface IDWriteFontFallbackBuilder(IDWriteFontFallbackBuilderVtbl): + IUnknown(IUnknownVtbl) { + fn AddMapping( + ranges: *const DWRITE_UNICODE_RANGE, + rangesCount: UINT32, + targetFamilyNames: *mut *const WCHAR, + targetFamilyNamesCount: UINT32, + fontCollection: *mut IDWriteFontCollection, + localeName: *const WCHAR, + baseFamilyName: *const WCHAR, + scale: FLOAT, + ) -> HRESULT, + fn AddMappings( + fontFallback: *mut IDWriteFontFallback, + ) -> HRESULT, + fn CreateFontFallback( + fontFallback: *mut *mut IDWriteFontFallback, + ) -> HRESULT, +}} +pub type DWRITE_COLOR_F = D3DCOLORVALUE; +RIDL!{#[uuid(0x29748ed6, 0x8c9c, 0x4a6a, 0xbe, 0x0b, 0xd9, 0x12, 0xe8, 0x53, 0x89, 0x44)] +interface IDWriteFont2(IDWriteFont2Vtbl): IDWriteFont1(IDWriteFont1Vtbl) { + fn IsColorFont() -> BOOL, +}} +RIDL!{#[uuid(0xd8b768ff, 0x64bc, 0x4e66, 0x98, 0x2b, 0xec, 0x8e, 0x87, 0xf6, 0x93, 0xf7)] +interface IDWriteFontFace2(IDWriteFontFace2Vtbl): + IDWriteFontFace1(IDWriteFontFace1Vtbl) { + fn IsColorFont() -> BOOL, + fn GetColorPaletteCount() -> UINT32, + fn GetPaletteEntryCount() -> UINT32, + fn GetPaletteEntries( + colorPaletteIndex: UINT32, + firstEntryIndex: UINT32, + entryCount: UINT32, + paletteEntries: *mut DWRITE_COLOR_F, + ) -> HRESULT, + fn GetRecommendedRenderingMode( + fontEmSize: FLOAT, + dpiX: FLOAT, + dpiY: FLOAT, + transform: *const DWRITE_MATRIX, + isSideways: BOOL, + outlineThreshold: DWRITE_OUTLINE_THRESHOLD, + measuringMode: DWRITE_MEASURING_MODE, + renderingParams: *mut IDWriteRenderingParams, + renderingMode: *mut DWRITE_RENDERING_MODE, + gridFitMode: *mut DWRITE_GRID_FIT_MODE, + ) -> HRESULT, +}} +STRUCT!{struct DWRITE_COLOR_GLYPH_RUN { + glyphRun: DWRITE_GLYPH_RUN, + glyphRunDescription: *mut DWRITE_GLYPH_RUN_DESCRIPTION, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + runColor: DWRITE_COLOR_F, + paletteIndex: UINT16, +}} +RIDL!{#[uuid(0xd31fbe17, 0xf157, 0x41a2, 0x8d, 0x24, 0xcb, 0x77, 0x9e, 0x05, 0x60, 0xe8)] +interface IDWriteColorGlyphRunEnumerator(IDWriteColorGlyphRunEnumeratorVtbl): + IUnknown(IUnknownVtbl) { + fn MoveNext( + hasRun: *mut BOOL, + ) -> HRESULT, + fn GetCurrentRun( + colorGlyphRun: *mut *const DWRITE_COLOR_GLYPH_RUN, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf9d711c3, 0x9777, 0x40ae, 0x87, 0xe8, 0x3e, 0x5a, 0xf9, 0xbf, 0x09, 0x48)] +interface IDWriteRenderingParams2(IDWriteRenderingParams2Vtbl): + IDWriteRenderingParams1(IDWriteRenderingParams1Vtbl) { + fn GetGridFitMode() -> DWRITE_GRID_FIT_MODE, +}} +RIDL!{#[uuid(0x0439fc60, 0xca44, 0x4994, 0x8d, 0xee, 0x3a, 0x9a, 0xf7, 0xb7, 0x32, 0xec)] +interface IDWriteFactory2(IDWriteFactory2Vtbl): IDWriteFactory1(IDWriteFactory1Vtbl) { + fn GetSystemFontFallback( + fontFallback: *mut *mut IDWriteFontFallback, + ) -> HRESULT, + fn CreateFontFallbackBuilder( + fontFallbackBuilder: *mut *mut IDWriteFontFallbackBuilder, + ) -> HRESULT, + fn TranslateColorGlyphRun( + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + glyphRun: *const DWRITE_GLYPH_RUN, + glyphRunDescription: *const DWRITE_GLYPH_RUN_DESCRIPTION, + measuringMode: DWRITE_MEASURING_MODE, + worldToDeviceTransform: *const DWRITE_MATRIX, + colorPaletteIndex: UINT32, + colorLayers: *mut *mut IDWriteColorGlyphRunEnumerator, + ) -> HRESULT, + fn CreateCustomRenderingParams( + gamma: FLOAT, + enhancedContrast: FLOAT, + grayscaleEnhancedContrast: FLOAT, + clearTypeLevel: FLOAT, + pixelGeometry: DWRITE_PIXEL_GEOMETRY, + renderingMode: DWRITE_RENDERING_MODE, + gridFitMode: DWRITE_GRID_FIT_MODE, + renderingParams: *mut *mut IDWriteRenderingParams2, + ) -> HRESULT, + fn CreateGlyphRunAnalysis( + glyphRun: *const DWRITE_GLYPH_RUN, + transform: *const DWRITE_MATRIX, + renderingMode: DWRITE_RENDERING_MODE, + measuringMode: DWRITE_MEASURING_MODE, + gridFitMode: DWRITE_GRID_FIT_MODE, + antialiasMode: DWRITE_TEXT_ANTIALIAS_MODE, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + glyphRunAnalysis: *mut *mut IDWriteGlyphRunAnalysis, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite_3.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite_3.rs new file mode 100644 index 0000000..f6645c3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dwrite_3.rs @@ -0,0 +1,578 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the content of dwrite_3.h +use ctypes::c_void; +use shared::basetsd::{UINT16, UINT32, UINT64}; +use shared::minwindef::{BOOL, FILETIME, FLOAT}; +use um::dcommon::{DWRITE_GLYPH_IMAGE_DATA, DWRITE_GLYPH_IMAGE_FORMATS, DWRITE_MEASURING_MODE}; +use um::dwrite::{ + DWRITE_FONT_SIMULATIONS, DWRITE_FONT_STRETCH, DWRITE_FONT_STYLE, DWRITE_FONT_WEIGHT, + DWRITE_GLYPH_RUN, DWRITE_INFORMATIONAL_STRING_ID, DWRITE_LINE_SPACING_METHOD, DWRITE_MATRIX, + DWRITE_PIXEL_GEOMETRY, DWRITE_RENDERING_MODE_ALIASED, DWRITE_RENDERING_MODE_DEFAULT, + DWRITE_RENDERING_MODE_GDI_CLASSIC, DWRITE_RENDERING_MODE_GDI_NATURAL, + DWRITE_RENDERING_MODE_NATURAL, DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, + DWRITE_RENDERING_MODE_OUTLINE, IDWriteFont, IDWriteFontCollection, IDWriteFontCollectionVtbl, + IDWriteFontFace, IDWriteFontFamily, IDWriteFontFamilyVtbl, IDWriteFontFile, IDWriteFontList, + IDWriteFontListVtbl, IDWriteGdiInterop, IDWriteGdiInteropVtbl, IDWriteGlyphRunAnalysis, + IDWriteLocalizedStrings, IDWriteRenderingParams, +}; +use um::dwrite_1::{DWRITE_OUTLINE_THRESHOLD, DWRITE_PANOSE, DWRITE_TEXT_ANTIALIAS_MODE}; +use um::dwrite_2::{ + DWRITE_GRID_FIT_MODE, IDWriteFactory2, IDWriteFactory2Vtbl, IDWriteFont2, IDWriteFont2Vtbl, + IDWriteFontFace2, IDWriteFontFace2Vtbl, IDWriteRenderingParams2, IDWriteRenderingParams2Vtbl, + IDWriteTextFormat1, IDWriteTextFormat1Vtbl, IDWriteTextLayout2, IDWriteTextLayout2Vtbl, +}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::wingdi::{FONTSIGNATURE, LOGFONTW}; +use um::winnt::{HRESULT, WCHAR}; +pub const DWRITE_E_REMOTEFONT: HRESULT = 0x8898500D; +pub const DWRITE_E_DOWNLOADCANCELLED: HRESULT = 0x8898500E; +pub const DWRITE_E_DOWNLOADFAILED: HRESULT = 0x8898500F; +pub const DWRITE_E_TOOMANYDOWNLOADS: HRESULT = 0x88985010; +ENUM!{enum DWRITE_FONT_PROPERTY_ID { + DWRITE_FONT_PROPERTY_ID_NONE, + DWRITE_FONT_PROPERTY_ID_FAMILY_NAME, + DWRITE_FONT_PROPERTY_ID_PREFERRED_FAMILY_NAME, + DWRITE_FONT_PROPERTY_ID_FACE_NAME, + DWRITE_FONT_PROPERTY_ID_FULL_NAME, + DWRITE_FONT_PROPERTY_ID_WIN32_FAMILY_NAME, + DWRITE_FONT_PROPERTY_ID_POSTSCRIPT_NAME, + DWRITE_FONT_PROPERTY_ID_DESIGN_SCRIPT_LANGUAGE_TAG, + DWRITE_FONT_PROPERTY_ID_SUPPORTED_SCRIPT_LANGUAGE_TAG, + DWRITE_FONT_PROPERTY_ID_SEMANTIC_TAG, + DWRITE_FONT_PROPERTY_ID_WEIGHT , + DWRITE_FONT_PROPERTY_ID_STRETCH, + DWRITE_FONT_PROPERTY_ID_STYLE, + DWRITE_FONT_PROPERTY_ID_TOTAL, +}} +STRUCT!{struct DWRITE_FONT_PROPERTY { + propertyId: DWRITE_FONT_PROPERTY_ID, + propertyValue: *const WCHAR, + localeName: *const WCHAR, +}} +ENUM!{enum DWRITE_LOCALITY { + DWRITE_LOCALITY_REMOTE, + DWRITE_LOCALITY_PARTIAL, + DWRITE_LOCALITY_LOCAL, +}} +ENUM!{enum DWRITE_RENDERING_MODE1 { + DWRITE_RENDERING_MODE1_DEFAULT = DWRITE_RENDERING_MODE_DEFAULT, + DWRITE_RENDERING_MODE1_ALIASED = DWRITE_RENDERING_MODE_ALIASED, + DWRITE_RENDERING_MODE1_GDI_CLASSIC = DWRITE_RENDERING_MODE_GDI_CLASSIC, + DWRITE_RENDERING_MODE1_GDI_NATURAL = DWRITE_RENDERING_MODE_GDI_NATURAL, + DWRITE_RENDERING_MODE1_NATURAL = DWRITE_RENDERING_MODE_NATURAL, + DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC = DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, + DWRITE_RENDERING_MODE1_OUTLINE = DWRITE_RENDERING_MODE_OUTLINE, + DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED, +}} +RIDL!{#[uuid(0xb7924baa, 0x391b, 0x412a, 0x8c, 0x5c, 0xe4, 0x4c, 0xc2, 0xd8, 0x67, 0xdc)] +interface IDWriteRenderingParams3(IDWriteRenderingParams3Vtbl): + IDWriteRenderingParams2(IDWriteRenderingParams2Vtbl) { + fn GetRenderingMode1() -> DWRITE_RENDERING_MODE1, +}} +RIDL!{#[uuid(0x9a1b41c3, 0xd3bb, 0x466a, 0x87, 0xfc, 0xfe, 0x67, 0x55, 0x6a, 0x3b, 0x65)] +interface IDWriteFactory3(IDWriteFactory3Vtbl): IDWriteFactory2(IDWriteFactory2Vtbl) { + fn CreateGlyphRunAnalysis( + glyphRun: *const DWRITE_GLYPH_RUN, + transform: *const DWRITE_MATRIX, + renderingMode: DWRITE_RENDERING_MODE1, + measuringMode: DWRITE_MEASURING_MODE, + gridFitMode: DWRITE_GRID_FIT_MODE, + antialiasMode: DWRITE_TEXT_ANTIALIAS_MODE, + baselineOriginX: FLOAT, + baselineOriginY: FLOAT, + glyphRunAnalysis: *mut *mut IDWriteGlyphRunAnalysis, + ) -> HRESULT, + fn CreateCustomRenderingParams( + gamma: FLOAT, + enhancedContrast: FLOAT, + grayscaleEnhancedContrast: FLOAT, + clearTypeLevel: FLOAT, + pixelGeometry: DWRITE_PIXEL_GEOMETRY, + renderingMode: DWRITE_RENDERING_MODE1, + gridFitMode: DWRITE_GRID_FIT_MODE, + renderingParams: *mut *mut IDWriteRenderingParams3, + ) -> HRESULT, + fn CreateFontFaceReference_2( + fontFile: *mut IDWriteFontFile, + faceIndex: UINT32, + fontSimulations: DWRITE_FONT_SIMULATIONS, + fontFaceReference: *mut *mut IDWriteFontFaceReference, + ) -> HRESULT, + fn CreateFontFaceReference_1( + filePath: *const WCHAR, + lastWriteTime: *const FILETIME, + faceIndex: UINT32, + fontSimulations: DWRITE_FONT_SIMULATIONS, + fontFaceReference: *mut *mut IDWriteFontFaceReference, + ) -> HRESULT, + fn GetSystemFontSet( + fontSet: *mut *mut IDWriteFontSet, + ) -> HRESULT, + fn CreateFontSetBuilder( + fontSetBuilder: *mut *mut IDWriteFontSetBuilder, + ) -> HRESULT, + fn CreateFontCollectionFromFontSet( + fontSet: *mut IDWriteFontSet, + fontCollection: *mut *mut IDWriteFontCollection1, + ) -> HRESULT, + fn GetSystemFontCollection( + includeDownloadableFonts: BOOL, + fontCollection: *mut *mut IDWriteFontCollection1, + checkForUpdates: BOOL, + ) -> HRESULT, + fn GetFontDownloadQueue( + fontDownloadQueue: *mut *mut IDWriteFontDownloadQueue, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x53585141, 0xd9f8, 0x4095, 0x83, 0x21, 0xd7, 0x3c, 0xf6, 0xbd, 0x11, 0x6b)] +interface IDWriteFontSet(IDWriteFontSetVtbl): IUnknown(IUnknownVtbl) { + fn GetFontCount() -> UINT32, + fn GetFontFaceReference( + listIndex: UINT32, + fontFaceReference: *mut *mut IDWriteFontFaceReference, + ) -> HRESULT, + fn FindFontFaceReference( + fontFaceReference: *mut IDWriteFontFaceReference, + listIndex: *mut UINT32, + exists: *mut BOOL, + ) -> HRESULT, + fn FindFontFace( + fontFace: *mut IDWriteFontFace, + listIndex: *mut UINT32, + exists: *mut BOOL, + ) -> HRESULT, + fn GetPropertyValues_3( + propertyID: DWRITE_FONT_PROPERTY_ID, + values: *mut *mut IDWriteStringList, + ) -> HRESULT, + fn GetPropertyValues_2( + propertyID: DWRITE_FONT_PROPERTY_ID, + preferredLocaleNames: *const WCHAR, + values: *mut *mut IDWriteStringList, + ) -> HRESULT, + fn GetPropertyValues_1( + listIndex: UINT32, + propertyId: DWRITE_FONT_PROPERTY_ID, + exists: *mut BOOL, + values: *mut *mut IDWriteLocalizedStrings, + ) -> HRESULT, + fn GetPropertyOccurrenceCount( + property: *const DWRITE_FONT_PROPERTY, + propertyOccurrenceCount: *mut UINT32, + ) -> HRESULT, + fn GetMatchingFonts_2( + familyName: *const WCHAR, + fontWeight: DWRITE_FONT_WEIGHT, + fontStretch: DWRITE_FONT_STRETCH, + fontStyle: DWRITE_FONT_STYLE, + filteredSet: *mut *mut IDWriteFontSet, + ) -> HRESULT, + fn GetMatchingFonts_1( + properties: *const DWRITE_FONT_PROPERTY, + propertyCount: UINT32, + filteredSet: *mut *mut IDWriteFontSet, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2f642afe, 0x9c68, 0x4f40, 0xb8, 0xbe, 0x45, 0x74, 0x01, 0xaf, 0xcb, 0x3d)] +interface IDWriteFontSetBuilder(IDWriteFontSetBuilderVtbl): IUnknown(IUnknownVtbl) { + fn AddFontFaceReference_2( + fontFaceReference: *mut IDWriteFontFaceReference, + properties: *const DWRITE_FONT_PROPERTY, + propertyCount: UINT32, + ) -> HRESULT, + fn AddFontFaceReference_1( + fontFaceReference: *mut IDWriteFontFaceReference, + ) -> HRESULT, + fn AddFontSet( + fontSet: *mut IDWriteFontSet, + ) -> HRESULT, + fn CreateFontSet( + fontSet: *mut *mut IDWriteFontSet, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x53585141, 0xd9f8, 0x4095, 0x83, 0x21, 0xd7, 0x3c, 0xf6, 0xbd, 0x11, 0x6c)] +interface IDWriteFontCollection1(IDWriteFontCollection1Vtbl): + IDWriteFontCollection(IDWriteFontCollectionVtbl) { + fn GetFontSet( + fontSet: *mut *mut IDWriteFontSet, + ) -> HRESULT, + fn GetFontFamily( + index: UINT32, + fontFamily: *mut *mut IDWriteFontFamily1, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xda20d8ef, 0x812a, 0x4c43, 0x98, 0x02, 0x62, 0xec, 0x4a, 0xbd, 0x7a, 0xdf)] +interface IDWriteFontFamily1(IDWriteFontFamily1Vtbl): + IDWriteFontFamily(IDWriteFontFamilyVtbl) { + fn GetFontLocality( + listIndex: UINT32, + ) -> DWRITE_LOCALITY, + fn GetFont( + listIndex: UINT32, + font: *mut *mut IDWriteFont3, + ) -> HRESULT, + fn GetFontFaceReference( + listIndex: UINT32, + fontFaceReference: *mut *mut IDWriteFontFaceReference, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xda20d8ef, 0x812a, 0x4c43, 0x98, 0x02, 0x62, 0xec, 0x4a, 0xbd, 0x7a, 0xde)] +interface IDWriteFontList1(IDWriteFontList1Vtbl): IDWriteFontList(IDWriteFontListVtbl) { + fn GetFontLocality( + listIndex: UINT32, + ) -> DWRITE_LOCALITY, + fn GetFont( + listIndex: UINT32, + font: *mut *mut IDWriteFont3, + ) -> HRESULT, + fn GetFontFaceReference( + listIndex: UINT32, + fontFaceReference: *mut *mut IDWriteFontFaceReference, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5e7fa7ca, 0xdde3, 0x424c, 0x89, 0xf0, 0x9f, 0xcd, 0x6f, 0xed, 0x58, 0xcd)] +interface IDWriteFontFaceReference(IDWriteFontFaceReferenceVtbl): + IUnknown(IUnknownVtbl) { + fn CreateFontFace( + fontFace: *mut *mut IDWriteFontFace3, + ) -> HRESULT, + fn CreateFontFaceWithSimulations( + fontFaceSimulationFlags: DWRITE_FONT_SIMULATIONS, + fontFace: *mut *mut IDWriteFontFace3, + ) -> HRESULT, + fn Equals( + fontFaceReference: *mut IDWriteFontFaceReference, + ) -> BOOL, + fn GetFontFaceIndex() -> UINT32, + fn GetSimulations() -> DWRITE_FONT_SIMULATIONS, + fn GetFontFile( + fontFile: *mut *mut IDWriteFontFile, + ) -> HRESULT, + fn GetLocalFileSize() -> UINT64, + fn GetFileSize() -> UINT64, + fn GetFileTime( + lastWriteTime: *mut FILETIME, + ) -> HRESULT, + fn GetLocality() -> DWRITE_LOCALITY, + fn EnqueueFontDownloadRequest() -> HRESULT, + fn EnqueueCharacterDownloadRequest( + characters: *const WCHAR, + characterCount: UINT32, + ) -> HRESULT, + fn EnqueueGlyphDownloadRequest( + glyphIndices: *const UINT16, + glyphCount: UINT32, + ) -> HRESULT, + fn EnqueueFileFragmentDownloadRequest( + fileOffset: UINT64, + fragmentSize: UINT64, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x29748ed6, 0x8c9c, 0x4a6a, 0xbe, 0x0b, 0xd9, 0x12, 0xe8, 0x53, 0x89, 0x44)] +interface IDWriteFont3(IDWriteFont3Vtbl): IDWriteFont2(IDWriteFont2Vtbl) { + fn CreateFontFace( + fontFace: *mut *mut IDWriteFontFace3, + ) -> HRESULT, + fn Equals( + font: *mut IDWriteFont, + ) -> BOOL, + fn GetFontFaceReference( + fontFaceReference: *mut *mut IDWriteFontFaceReference, + ) -> HRESULT, + fn HasCharacter( + unicodeValue: UINT32, + ) -> BOOL, + fn GetLocality() -> DWRITE_LOCALITY, +}} +RIDL!{#[uuid(0xd37d7598, 0x09be, 0x4222, 0xa2, 0x36, 0x20, 0x81, 0x34, 0x1c, 0xc1, 0xf2)] +interface IDWriteFontFace3(IDWriteFontFace3Vtbl): + IDWriteFontFace2(IDWriteFontFace2Vtbl) { + fn GetFontFaceReference( + fontFaceReference: *mut *mut IDWriteFontFaceReference, + ) -> HRESULT, + fn GetPanose( + panose: *mut DWRITE_PANOSE, + ) -> (), + fn GetWeight() -> DWRITE_FONT_WEIGHT, + fn GetStretch() -> DWRITE_FONT_STRETCH, + fn GetStyle() -> DWRITE_FONT_STYLE, + fn GetFamilyNames( + names: *mut *mut IDWriteLocalizedStrings, + ) -> HRESULT, + fn GetFaceNames( + names: *mut *mut IDWriteLocalizedStrings, + ) -> HRESULT, + fn GetInformationalStrings( + informationalStringID: DWRITE_INFORMATIONAL_STRING_ID, + informationalStrings: *mut *mut IDWriteLocalizedStrings, + exists: *mut BOOL, + ) -> HRESULT, + fn HasCharacter( + unicodeValue: UINT32, + ) -> BOOL, + fn GetRecommendedRenderingMode( + fontEmSize: FLOAT, + dpiX: FLOAT, + dpiY: FLOAT, + transform: *const DWRITE_MATRIX, + isSideways: BOOL, + outlineThreshold: DWRITE_OUTLINE_THRESHOLD, + measuringMode: DWRITE_MEASURING_MODE, + renderingParams: *mut IDWriteRenderingParams, + renderingMode: *mut DWRITE_RENDERING_MODE1, + gridFitMode: *mut DWRITE_GRID_FIT_MODE, + ) -> HRESULT, + fn IsCharacterLocal( + unicodeValue: UINT32, + ) -> BOOL, + fn IsGlyphLocal( + glyphId: UINT16, + ) -> BOOL, + fn AreCharactersLocal( + characters: *const WCHAR, + characterCount: UINT32, + enqueueIfNotLocal: BOOL, + isLocal: *mut BOOL, + ) -> HRESULT, + fn AreGlyphsLocal( + glyphIndices: *const UINT16, + glyphCount: UINT32, + enqueueIfNotLocal: BOOL, + isLocal: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xcfee3140, 0x1157, 0x47ca, 0x8b, 0x85, 0x31, 0xbf, 0xcf, 0x3f, 0x2d, 0x0e)] +interface IDWriteStringList(IDWriteStringListVtbl): IUnknown(IUnknownVtbl) { + fn GetCount() -> UINT32, + fn GetLocaleNameLength( + listIndex: UINT32, + length: *mut UINT32, + ) -> HRESULT, + fn GetLocaleName( + listIndex: UINT32, + localeName: *mut WCHAR, + size: UINT32, + ) -> HRESULT, + fn GetStringLength( + listIndex: UINT32, + length: *mut UINT32, + ) -> HRESULT, + fn GetString( + listIndex: UINT32, + stringBuffer: *mut WCHAR, + stringBufferSize: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb06fe5b9, 0x43ec, 0x4393, 0x88, 0x1b, 0xdb, 0xe4, 0xdc, 0x72, 0xfd, 0xa7)] +interface IDWriteFontDownloadListener(IDWriteFontDownloadListenerVtbl): + IUnknown(IUnknownVtbl) { + fn DownloadCompleted( + downloadQueue: *mut IDWriteFontDownloadQueue, + context: *mut IUnknown, + downloadResult: HRESULT, + ) -> (), +}} +RIDL!{#[uuid(0xb71e6052, 0x5aea, 0x4fa3, 0x83, 0x2e, 0xf6, 0x0d, 0x43, 0x1f, 0x7e, 0x91)] +interface IDWriteFontDownloadQueue(IDWriteFontDownloadQueueVtbl): + IUnknown(IUnknownVtbl) { + fn AddListener( + listener: *mut IDWriteFontDownloadListener, + token: *mut UINT32, + ) -> HRESULT, + fn RemoveListener( + token: UINT32, + ) -> HRESULT, + fn IsEmpty() -> BOOL, + fn BeginDownload( + context: *mut IUnknown, + ) -> HRESULT, + fn CancelDownload() -> HRESULT, + fn GetGenerationCount() -> UINT64, +}} +RIDL!{#[uuid(0x4556be70, 0x3abd, 0x4f70, 0x90, 0xbe, 0x42, 0x17, 0x80, 0xa6, 0xf5, 0x15)] +interface IDWriteGdiInterop1(IDWriteGdiInterop1Vtbl): + IDWriteGdiInterop(IDWriteGdiInteropVtbl) { + fn CreateFontFromLOGFONT( + logFont: *const LOGFONTW, + fontCollection: *mut IDWriteFontCollection, + font: *mut *mut IDWriteFont, + ) -> HRESULT, + fn GetFontSignature_2( + fontFace: *mut IDWriteFontFace, + fontSignature: *mut FONTSIGNATURE, + ) -> HRESULT, + fn GetFontSignature_1( + font: *mut IDWriteFont, + fontSignature: *mut FONTSIGNATURE, + ) -> HRESULT, + fn GetMatchingFontsByLOGFONT( + logFont: *const LOGFONTW, + fontSet: *mut IDWriteFontSet, + filteredSet: *mut *mut IDWriteFontSet, + ) -> HRESULT, +}} +STRUCT!{struct DWRITE_LINE_METRICS1 { + length: UINT32, + trailingWhitespaceLength: UINT32, + newlineLength: UINT32, + height: FLOAT, + baseline: FLOAT, + isTrimmed: BOOL, + leadingBefore: FLOAT, + leadingAfter: FLOAT, +}} +ENUM!{enum DWRITE_FONT_LINE_GAP_USAGE { + DWRITE_FONT_LINE_GAP_USAGE_DEFAULT, + DWRITE_FONT_LINE_GAP_USAGE_DISABLED, + DWRITE_FONT_LINE_GAP_USAGE_ENABLED, +}} +STRUCT!{struct DWRITE_LINE_SPACING { + method: DWRITE_LINE_SPACING_METHOD, + height: FLOAT, + baseline: FLOAT, + leadingBefore: FLOAT, + fontLineGapUsage: DWRITE_FONT_LINE_GAP_USAGE, +}} +RIDL!{#[uuid(0xf67e0edd, 0x9e3d, 0x4ecc, 0x8c, 0x32, 0x41, 0x83, 0x25, 0x3d, 0xfe, 0x70)] +interface IDWriteTextFormat2(IDWriteTextFormat2Vtbl): + IDWriteTextFormat1(IDWriteTextFormat1Vtbl) { + fn SetLineSpacing( + lineSpacingOptions: *const DWRITE_LINE_SPACING, + ) -> HRESULT, + fn GetLineSpacing( + lineSpacingOptions: *mut DWRITE_LINE_SPACING, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x07ddcd52, 0x020e, 0x4de8, 0xac, 0x33, 0x6c, 0x95, 0x3d, 0x83, 0xf9, 0x2d)] +interface IDWriteTextLayout3(IDWriteTextLayout3Vtbl): + IDWriteTextLayout2(IDWriteTextLayout2Vtbl) { + fn InvalidateLayout() -> HRESULT, + fn SetLineSpacing( + lineSpacingOptions: *const DWRITE_LINE_SPACING, + ) -> HRESULT, + fn GetLineSpacing( + lineSpacingOptions: *mut DWRITE_LINE_SPACING, + ) -> HRESULT, + fn GetLineMetrics( + lineMetrics: *mut DWRITE_LINE_METRICS1, + maxLineCount: UINT32, + actualLineCount: *mut UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x27f2a904, 0x4eb8, 0x441d, 0x96, 0x78, 0x05, 0x63, 0xf5, 0x3e, 0x3e, 0x2f)] +interface IDWriteFontFace4(IDWriteFontFace4Vtbl): IDWriteFontFace3(IDWriteFontFace3Vtbl) { + fn GetGlyphImageFormats_2( + glyph: UINT16, + ppemFirst: UINT32, + ppemLast: UINT32, + formats: *mut DWRITE_GLYPH_IMAGE_FORMATS, + ) -> HRESULT, + fn GetGlyphImageFormats_1() -> DWRITE_GLYPH_IMAGE_FORMATS, + fn GetGlyphImageData( + glyph: UINT16, + ppem: UINT32, + format: DWRITE_GLYPH_IMAGE_FORMATS, + data: *mut DWRITE_GLYPH_IMAGE_DATA, + context: *mut *mut c_void, + ) -> HRESULT, + fn ReleaseGlyphImageData( + context: *mut c_void, + ) -> (), +}} +ENUM!{enum DWRITE_FONT_AXIS_TAG { + DWRITE_FONT_AXIS_TAG_WEIGHT = 0x74686777, + DWRITE_FONT_AXIS_TAG_WIDTH = 0x68746477, + DWRITE_FONT_AXIS_TAG_SLANT = 0x746e6c73, + DWRITE_FONT_AXIS_TAG_OPTICAL_SIZE = 0x7a73706f, + DWRITE_FONT_AXIS_TAG_ITALIC = 0x6c617469, +}} +STRUCT!{struct DWRITE_FONT_AXIS_VALUE { + axisTag: DWRITE_FONT_AXIS_TAG, + value: FLOAT, +}} +STRUCT!{struct DWRITE_FONT_AXIS_RANGE { + axisTag: DWRITE_FONT_AXIS_TAG, + minValue: FLOAT, + maxValue: FLOAT, +}} +ENUM!{enum DWRITE_FONT_AXIS_ATTRIBUTES { + DWRITE_FONT_AXIS_ATTRIBUTES_NONE, + DWRITE_FONT_AXIS_ATTRIBUTES_VARIABLE, + DWRITE_FONT_AXIS_ATTRIBUTES_HIDDEN, +}} +RIDL!{#[uuid(0x98eff3a5, 0xb667, 0x479a, 0xb1, 0x45, 0xe2, 0xfa, 0x5b, 0x9f, 0xdc, 0x29)] +interface IDWriteFontFace5(IDWriteFontFace5Vtbl): IDWriteFontFace4(IDWriteFontFace4Vtbl) { + fn GetFontAxisValueCount() -> UINT32, + fn GetFontAxisValues( + values: *mut DWRITE_FONT_AXIS_VALUE, + valueCount: UINT32, + ) -> HRESULT, + fn HasVariations() -> BOOL, + fn GetFontResource( + resource: *mut *mut IDWriteFontResource, + ) -> HRESULT, + fn Equals( + fontFace: *mut IDWriteFontFace, + ) -> BOOL, +}} +RIDL!{#[uuid(0xc081fe77, 0x2fd1, 0x41ac, 0xa5, 0xa3, 0x34, 0x98, 0x3c, 0x4b, 0xa6, 0x1a)] +interface IDWriteFontFaceReference1(IDWriteFontFaceReference1Vtbl): + IDWriteFontFaceReference(IDWriteFontFaceReferenceVtbl) { + fn CreateFontFace( + fontFace: *mut *mut IDWriteFontFace5, + ) -> HRESULT, + fn GetFontAxisValueCount() -> UINT32, + fn GetFontAxisValues( + values: *mut DWRITE_FONT_AXIS_VALUE, + numValues: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1f803a76, 0x6871, 0x48e8, 0x98, 0x7f, 0xb9, 0x75, 0x55, 0x1c, 0x50, 0xf2)] +interface IDWriteFontResource(IDWriteFontResourceVtbl): IUnknown(IUnknownVtbl) { + fn GetFontFile( + fontFile: *mut *mut IDWriteFontFile, + ) -> HRESULT, + fn GetFontFaceIndex() -> UINT32, + fn GetFontAxisCount() -> UINT32, + fn GetDefaultFontAxisValues( + values: *const DWRITE_FONT_AXIS_VALUE, + numValues: UINT32, + ) -> HRESULT, + fn GetFontAxisRanges( + ranges: *const DWRITE_FONT_AXIS_RANGE, + numRanges: UINT32, + ) -> HRESULT, + fn GetFontAxisAttributes( + axis: UINT32, + ) -> DWRITE_FONT_AXIS_ATTRIBUTES, + fn GetAxisNames( + axis: UINT32, + names: *mut *mut IDWriteLocalizedStrings, + ) -> HRESULT, + fn GetAxisValueNameCount( + axis: UINT32, + ) -> UINT32, + fn GetAxisValueNames( + axis: UINT32, + axisValue: UINT32, + axisRange: *mut DWRITE_FONT_AXIS_RANGE, + names: *mut *mut IDWriteLocalizedStrings, + ) -> HRESULT, + fn HasVariations() -> BOOL, + fn CreateFontFace( + simulations: DWRITE_FONT_SIMULATIONS, + axisValues: *const DWRITE_FONT_AXIS_VALUE, + numValues: UINT32, + fontFace: *mut *mut IDWriteFontFace5, + ) -> HRESULT, + fn CreateFontFaceReference( + simulations: DWRITE_FONT_SIMULATIONS, + axisValues: *const DWRITE_FONT_AXIS_VALUE, + numValues: UINT32, + reference: *mut *mut IDWriteFontFaceReference1, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dxdiag.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dxdiag.rs new file mode 100644 index 0000000..6f46c7a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dxdiag.rs @@ -0,0 +1,11 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{CLSID_DxDiagProvider, + 0xa65b8071, 0x3bfe, 0x4213, 0x9a, 0x5b, 0x49, 0x1d, 0xa4, 0x46, 0x1c, 0xa7} +DEFINE_GUID!{IID_IDxDiagProvider, + 0x9c6b4cb0, 0x23f8, 0x49cc, 0xa3, 0xed, 0x45, 0xa5, 0x50, 0x00, 0xa6, 0xd2} +DEFINE_GUID!{IID_IDxDiagContainer, + 0x7d0f462f, 0x4064, 0x4862, 0xbc, 0x7f, 0x93, 0x3e, 0x50, 0x58, 0xc1, 0x0f} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dxfile.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dxfile.rs new file mode 100644 index 0000000..67ba32c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dxfile.rs @@ -0,0 +1,23 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{CLSID_CDirectXFile, + 0x4516ec43, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3} +DEFINE_GUID!{IID_IDirectXFile, + 0x3d82ab40, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{IID_IDirectXFileEnumObject, + 0x3d82ab41, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{IID_IDirectXFileSaveObject, + 0x3d82ab42, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{IID_IDirectXFileObject, + 0x3d82ab43, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{IID_IDirectXFileData, + 0x3d82ab44, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{IID_IDirectXFileDataReference, + 0x3d82ab45, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{IID_IDirectXFileBinary, + 0x3d82ab46, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{TID_DXFILEHeader, + 0x3d82ab43, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dxgidebug.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dxgidebug.rs new file mode 100644 index 0000000..3478da3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dxgidebug.rs @@ -0,0 +1,235 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_char, c_int, c_void}; +use shared::basetsd::{SIZE_T, UINT64}; +use shared::guiddef::{GUID, REFIID}; +use shared::minwindef::{BOOL, DWORD, UINT}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCSTR}; +pub const DXGI_DEBUG_BINARY_VERSION: DWORD = 1; +ENUM!{enum DXGI_DEBUG_RLO_FLAGS { + DXGI_DEBUG_RLO_SUMMARY = 0x1, + DXGI_DEBUG_RLO_DETAIL = 0x2, + DXGI_DEBUG_RLO_IGNORE_INTERNAL = 0x4, + DXGI_DEBUG_RLO_ALL = 0x7, +}} +pub type DXGI_DEBUG_ID = GUID; +DEFINE_GUID!{DXGI_DEBUG_ALL, + 0xe48ae283, 0xda80, 0x490b, 0x87, 0xe6, 0x43, 0xe9, 0xa9, 0xcf, 0xda, 0x08} +DEFINE_GUID!{DXGI_DEBUG_DX, + 0x35cdd7fc, 0x13b2, 0x421d, 0xa5, 0xd7, 0x7e, 0x44, 0x51, 0x28, 0x7d, 0x64} +DEFINE_GUID!{DXGI_DEBUG_DXGI, + 0x25cddaa4, 0xb1c6, 0x47e1, 0xac, 0x3e, 0x98, 0x87, 0x5b, 0x5a, 0x2e, 0x2a} +DEFINE_GUID!{DXGI_DEBUG_APP, + 0x06cd6e01, 0x4219, 0x4ebd, 0x87, 0x09, 0x27, 0xed, 0x23, 0x36, 0x0c, 0x62} +ENUM!{enum DXGI_INFO_QUEUE_MESSAGE_CATEGORY { + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_UNKNOWN = 0, + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_MISCELLANEOUS = 1, + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_INITIALIZATION = 2, + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_CLEANUP = 3, + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_COMPILATION = 4, + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_STATE_CREATION = 5, + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_STATE_SETTING = 6, + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_STATE_GETTING = 7, + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_RESOURCE_MANIPULATION = 8, + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_EXECUTION = 9, + DXGI_INFO_QUEUE_MESSAGE_CATEGORY_SHADER = 10, +}} +ENUM!{enum DXGI_INFO_QUEUE_MESSAGE_SEVERITY { + DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION = 0, + DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR = 1, + DXGI_INFO_QUEUE_MESSAGE_SEVERITY_WARNING = 2, + DXGI_INFO_QUEUE_MESSAGE_SEVERITY_INFO = 3, + DXGI_INFO_QUEUE_MESSAGE_SEVERITY_MESSAGE = 4, +}} +pub type DXGI_INFO_QUEUE_MESSAGE_ID = c_int; +STRUCT!{struct DXGI_INFO_QUEUE_MESSAGE { + Producer: DXGI_DEBUG_ID, + Category: DXGI_INFO_QUEUE_MESSAGE_CATEGORY, + Severity: DXGI_INFO_QUEUE_MESSAGE_SEVERITY, + ID: DXGI_INFO_QUEUE_MESSAGE_ID, + pDescription: *const c_char, + DescriptionByteLength: SIZE_T, +}} +STRUCT!{struct DXGI_INFO_QUEUE_FILTER_DESC { + NumCategories: UINT, + pCategoryList: *mut DXGI_INFO_QUEUE_MESSAGE_CATEGORY, + NumSeverities: UINT, + pSeverityList: *mut DXGI_INFO_QUEUE_MESSAGE_SEVERITY, + NumIDs: UINT, + pIDList: *mut DXGI_INFO_QUEUE_MESSAGE_ID, +}} +STRUCT!{struct DXGI_INFO_QUEUE_FILTER { + AllowList: DXGI_INFO_QUEUE_FILTER_DESC, + DenyList: DXGI_INFO_QUEUE_FILTER_DESC, +}} +pub const DXGI_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT: DWORD = 1024; +extern "system" { + pub fn DXGIGetDebugInterface( + riid: REFIID, + ppDebug: *mut *mut c_void, + ) -> HRESULT; +} +RIDL!{#[uuid(0xd67441c7, 0x672a, 0x476f, 0x9e, 0x82, 0xcd, 0x55, 0xb4, 0x49, 0x49, 0xce)] +interface IDXGIInfoQueue(IDXGIInfoQueueVtbl): IUnknown(IUnknownVtbl) { + fn SetMessageCountLimit( + Producer: DXGI_DEBUG_ID, + MessageCountLimit: UINT64, + ) -> HRESULT, + fn ClearStoredMessages( + Producer: DXGI_DEBUG_ID, + ) -> (), + fn GetMessage( + Producer: DXGI_DEBUG_ID, + MessageIndex: UINT64, + pMessage: *mut DXGI_INFO_QUEUE_MESSAGE, + pMessageByteLength: *mut SIZE_T, + ) -> HRESULT, + fn GetNumStoredMessagesAllowedByRetrievalFilters( + Producer: DXGI_DEBUG_ID, + ) -> UINT64, + fn GetNumStoredMessages( + Producer: DXGI_DEBUG_ID, + ) -> UINT64, + fn GetNumMessagesDiscardedByMessageCountLimit( + Producer: DXGI_DEBUG_ID, + ) -> UINT64, + fn GetMessageCountLimit( + Producer: DXGI_DEBUG_ID, + ) -> UINT64, + fn GetNumMessagesAllowedByStorageFilter( + Producer: DXGI_DEBUG_ID, + ) -> UINT64, + fn GetNumMessagesDeniedByStorageFilter( + Producer: DXGI_DEBUG_ID, + ) -> UINT64, + fn AddStorageFilterEntries( + Producer: DXGI_DEBUG_ID, + pFilter: *const DXGI_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn GetStorageFilter( + Producer: DXGI_DEBUG_ID, + pFilter: *mut DXGI_INFO_QUEUE_FILTER, + pFilterByteLength: *mut SIZE_T, + ) -> HRESULT, + fn ClearStorageFilter( + Producer: DXGI_DEBUG_ID, + ) -> (), + fn PushEmptyStorageFilter( + Producer: DXGI_DEBUG_ID, + ) -> HRESULT, + fn PushDenyAllStorageFilter( + Producer: DXGI_DEBUG_ID, + ) -> HRESULT, + fn PushCopyOfStorageFilter( + Producer: DXGI_DEBUG_ID, + ) -> HRESULT, + fn PushStorageFilter( + Producer: DXGI_DEBUG_ID, + pFilter: *const DXGI_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn PopStorageFilter( + Producer: DXGI_DEBUG_ID, + ) -> (), + fn GetStorageFilterStackSize( + Producer: DXGI_DEBUG_ID, + ) -> UINT, + fn AddRetrievalFilterEntries( + Producer: DXGI_DEBUG_ID, + pFilter: *const DXGI_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn GetRetrievalFilter( + Producer: DXGI_DEBUG_ID, + pFilter: *mut DXGI_INFO_QUEUE_FILTER, + pFilterByteLength: *mut SIZE_T, + ) -> HRESULT, + fn ClearRetrievalFilter( + Producer: DXGI_DEBUG_ID, + ) -> (), + fn PushEmptyRetrievalFilter( + Producer: DXGI_DEBUG_ID, + ) -> HRESULT, + fn PushDenyAllRetrievalFilter( + Producer: DXGI_DEBUG_ID, + ) -> HRESULT, + fn PushCopyOfRetrievalFilter( + Producer: DXGI_DEBUG_ID, + ) -> HRESULT, + fn PushRetrievalFilter( + Producer: DXGI_DEBUG_ID, + pFilter: *const DXGI_INFO_QUEUE_FILTER, + ) -> HRESULT, + fn PopRetrievalFilter( + Producer: DXGI_DEBUG_ID, + ) -> (), + fn GetRetrievalFilterStackSize( + Producer: DXGI_DEBUG_ID, + ) -> UINT, + fn AddMessage( + Producer: DXGI_DEBUG_ID, + Category: DXGI_INFO_QUEUE_MESSAGE_CATEGORY, + Severity: DXGI_INFO_QUEUE_MESSAGE_SEVERITY, + ID: DXGI_INFO_QUEUE_MESSAGE_ID, + pDescription: LPCSTR, + ) -> HRESULT, + fn AddApplicationMessage( + Severity: DXGI_INFO_QUEUE_MESSAGE_SEVERITY, + pDescription: LPCSTR, + ) -> HRESULT, + fn SetBreakOnCategory( + Producer: DXGI_DEBUG_ID, + Category: DXGI_INFO_QUEUE_MESSAGE_CATEGORY, + bEnable: BOOL, + ) -> HRESULT, + fn SetBreakOnSeverity( + Producer: DXGI_DEBUG_ID, + Severity: DXGI_INFO_QUEUE_MESSAGE_SEVERITY, + bEnable: BOOL, + ) -> HRESULT, + fn SetBreakOnID( + Producer: DXGI_DEBUG_ID, + ID: DXGI_INFO_QUEUE_MESSAGE_ID, + bEnable: BOOL, + ) -> HRESULT, + fn GetBreakOnCategory( + Producer: DXGI_DEBUG_ID, + Category: DXGI_INFO_QUEUE_MESSAGE_CATEGORY, + ) -> BOOL, + fn GetBreakOnSeverity( + Producer: DXGI_DEBUG_ID, + Severity: DXGI_INFO_QUEUE_MESSAGE_SEVERITY, + ) -> BOOL, + fn GetBreakOnID( + Producer: DXGI_DEBUG_ID, + ID: DXGI_INFO_QUEUE_MESSAGE_ID, + ) -> BOOL, + fn SetMuteDebugOutput( + Producer: DXGI_DEBUG_ID, + bMute: BOOL, + ) -> (), + fn GetMuteDebugOutput( + Producer: DXGI_DEBUG_ID, + ) -> BOOL, +}} +RIDL!{#[uuid(0x119e7452, 0xde9e, 0x40fe, 0x88, 0x06, 0x88, 0xf9, 0x0c, 0x12, 0xb4, 0x41)] +interface IDXGIDebug(IDXGIDebugVtbl): IUnknown(IUnknownVtbl) { + fn ReportLiveObjects( + apiid: GUID, + flags: DXGI_DEBUG_RLO_FLAGS, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x119e7452, 0xde9e, 0x40fe, 0x88, 0x06, 0x88, 0xf9, 0x0c, 0x12, 0xb4, 0x41)] +interface IDXGIDebug1(IDXGIDebug1Vtbl): IDXGIDebug(IDXGIDebugVtbl) { + fn EnableLeakTrackingForThread() -> (), + fn DisableLeakTrackingForThread() -> (), + fn IsLeakTrackingEnabledForThread() -> BOOL, +}} +DEFINE_GUID!{IID_IDXGIInfoQueue, + 0xd67441c7, 0x672a, 0x476f, 0x9e, 0x82, 0xcd, 0x55, 0xb4, 0x49, 0x49, 0xce} +DEFINE_GUID!{IID_IDXGIDebug, + 0x119e7452, 0xde9e, 0x40fe, 0x88, 0x06, 0x88, 0xf9, 0x0c, 0x12, 0xb4, 0x41} +DEFINE_GUID!{IID_IDXGIDebug1, + 0xc5a05f0c, 0x16f2, 0x4adf, 0x9f, 0x4d, 0xa8, 0xc4, 0xd5, 0x8a, 0xc5, 0x50} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dxva2api.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dxva2api.rs new file mode 100644 index 0000000..db07c40 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dxva2api.rs @@ -0,0 +1,706 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_float, c_void}; +use shared::basetsd::UINT64; +use shared::d3d9::{IDirect3DDevice9, IDirect3DSurface9}; +use shared::d3d9types::{D3DFORMAT, D3DPOOL}; +use shared::guiddef::{GUID, REFGUID, REFIID}; +use shared::minwindef::{BOOL, DWORD, FLOAT, HIWORD, LOWORD, UCHAR, UINT, USHORT}; +use shared::windef::{RECT, SIZE}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, LONG, LONGLONG, PVOID, SHORT}; +DEFINE_GUID!{DXVA2_ModeMPEG2_MoComp, + 0xe6a9f44b, 0x61b0, 0x4563, 0x9e, 0xa4, 0x63, 0xd2, 0xa3, 0xc6, 0xfe, 0x66} +DEFINE_GUID!{DXVA2_ModeMPEG2_IDCT, + 0xbf22ad00, 0x03ea, 0x4690, 0x80, 0x77, 0x47, 0x33, 0x46, 0x20, 0x9b, 0x7e} +DEFINE_GUID!{DXVA2_ModeMPEG2_VLD, + 0xee27417f, 0x5e28, 0x4e65, 0xbe, 0xea, 0x1d, 0x26, 0xb5, 0x08, 0xad, 0xc9} +DEFINE_GUID!{DXVA2_ModeMPEG1_VLD, + 0x6f3ec719, 0x3735, 0x42cc, 0x80, 0x63, 0x65, 0xcc, 0x3c, 0xb3, 0x66, 0x16} +DEFINE_GUID!{DXVA2_ModeMPEG2and1_VLD, + 0x86695f12, 0x340e, 0x4f04, 0x9f, 0xd3, 0x92, 0x53, 0xdd, 0x32, 0x74, 0x60} +DEFINE_GUID!{DXVA2_ModeH264_A, + 0x1b81be64, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeH264_B, + 0x1b81be65, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeH264_C, + 0x1b81be66, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeH264_D, + 0x1b81be67, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeH264_E, + 0x1b81be68, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeH264_F, + 0x1b81be69, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeH264_VLD_WithFMOASO_NoFGT, + 0xd5f04ff9, 0x3418, 0x45d8, 0x95, 0x61, 0x32, 0xa7, 0x6a, 0xae, 0x2d, 0xdd} +DEFINE_GUID!{DXVA2_ModeH264_VLD_Stereo_Progressive_NoFGT, + 0xd79be8da, 0x0cf1, 0x4c81, 0xb8, 0x2a, 0x69, 0xa4, 0xe2, 0x36, 0xf4, 0x3d} +DEFINE_GUID!{DXVA2_ModeH264_VLD_Stereo_NoFGT, + 0xf9aaccbb, 0xc2b6, 0x4cfc, 0x87, 0x79, 0x57, 0x07, 0xb1, 0x76, 0x05, 0x52} +DEFINE_GUID!{DXVA2_ModeH264_VLD_Multiview_NoFGT, + 0x705b9d82, 0x76cf, 0x49d6, 0xb7, 0xe6, 0xac, 0x88, 0x72, 0xdb, 0x01, 0x3c} +DEFINE_GUID!{DXVA2_ModeWMV8_A, + 0x1b81be80, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeWMV8_B, + 0x1b81be81, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeWMV9_A, + 0x1b81be90, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeWMV9_B, + 0x1b81be91, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeWMV9_C, + 0x1b81be94, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeVC1_A, + 0x1b81bea0, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeVC1_B, + 0x1b81bea1, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeVC1_C, + 0x1b81bea2, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeVC1_D, + 0x1b81bea3, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_ModeVC1_D2010, + 0x1b81bea4, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_NoEncrypt, + 0x1b81bed0, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} +DEFINE_GUID!{DXVA2_VideoProcProgressiveDevice, + 0x5a54a0c9, 0xc7ec, 0x4bd9, 0x8e, 0xde, 0xf3, 0xc7, 0x5d, 0xc4, 0x39, 0x3b} +DEFINE_GUID!{DXVA2_VideoProcBobDevice, + 0x335aa36e, 0x7884, 0x43a4, 0x9c, 0x91, 0x7f, 0x87, 0xfa, 0xf3, 0xe3, 0x7e} +DEFINE_GUID!{DXVA2_VideoProcSoftwareDevice, + 0x4553d47f, 0xee7e, 0x4e3f, 0x94, 0x75, 0xdb, 0xf1, 0x37, 0x6c, 0x48, 0x10} +DEFINE_GUID!{DXVA2_ModeMPEG4pt2_VLD_Simple, + 0xefd64d74, 0xc9e8, 0x41d7, 0xa5, 0xe9, 0xe9, 0xb0, 0xe3, 0x9f, 0xa3, 0x19} +DEFINE_GUID!{DXVA2_ModeMPEG4pt2_VLD_AdvSimple_NoGMC, + 0xed418a9f, 0x010d, 0x4eda, 0x9a, 0xe3, 0x9a, 0x65, 0x35, 0x8d, 0x8d, 0x2e} +DEFINE_GUID!{DXVA2_ModeMPEG4pt2_VLD_AdvSimple_GMC, + 0xab998b5b, 0x4258, 0x44a9, 0x9f, 0xeb, 0x94, 0xe5, 0x97, 0xa6, 0xba, 0xae} +DEFINE_GUID!{DXVA2_ModeHEVC_VLD_Main, + 0x5b11d51b, 0x2f4c, 0x4452, 0xbc, 0xc3, 0x09, 0xf2, 0xa1, 0x16, 0x0c, 0xc0} +DEFINE_GUID!{DXVA2_ModeHEVC_VLD_Main10, + 0x107af0e0, 0xef1a, 0x4d19, 0xab, 0xa8, 0x67, 0xa1, 0x63, 0x07, 0x3d, 0x13} +DEFINE_GUID!{DXVA2_ModeVP9_VLD_Profile0, + 0x463707f8, 0xa1d0, 0x4585, 0x87, 0x6d, 0x83, 0xaa, 0x6d, 0x60, 0xb8, 0x9e} +DEFINE_GUID!{DXVA2_ModeVP9_VLD_10bit_Profile2, + 0xa4c749ef, 0x6ecf, 0x48aa, 0x84, 0x48, 0x50, 0xa7, 0xa1, 0x16, 0x5f, 0xf7} +DEFINE_GUID!{DXVA2_ModeVP8_VLD, + 0x90b899ea, 0x3a62, 0x4705, 0x88, 0xb3, 0x8d, 0xf0, 0x4b, 0x27, 0x44, 0xe7} +pub const DXVA2_ModeMPEG2_MOCOMP: GUID = DXVA2_ModeMPEG2_MoComp; +pub const DXVA2_ModeWMV8_PostProc: GUID = DXVA2_ModeWMV8_A; +pub const DXVA2_ModeWMV8_MoComp: GUID = DXVA2_ModeWMV8_B; +pub const DXVA2_ModeWMV9_PostProc: GUID = DXVA2_ModeWMV9_A; +pub const DXVA2_ModeWMV9_MoComp: GUID = DXVA2_ModeWMV9_B; +pub const DXVA2_ModeWMV9_IDCT: GUID = DXVA2_ModeWMV9_C; +pub const DXVA2_ModeVC1_PostProc: GUID = DXVA2_ModeVC1_A; +pub const DXVA2_ModeVC1_MoComp: GUID = DXVA2_ModeVC1_B; +pub const DXVA2_ModeVC1_IDCT: GUID = DXVA2_ModeVC1_C; +pub const DXVA2_ModeVC1_VLD: GUID = DXVA2_ModeVC1_D; +pub const DXVA2_ModeH264_MoComp_NoFGT: GUID = DXVA2_ModeH264_A; +pub const DXVA2_ModeH264_MoComp_FGT: GUID = DXVA2_ModeH264_B; +pub const DXVA2_ModeH264_IDCT_NoFGT: GUID = DXVA2_ModeH264_C; +pub const DXVA2_ModeH264_IDCT_FGT: GUID = DXVA2_ModeH264_D; +pub const DXVA2_ModeH264_VLD_NoFGT: GUID = DXVA2_ModeH264_E; +pub const DXVA2_ModeH264_VLD_FGT: GUID = DXVA2_ModeH264_F; +pub const DXVA2_E_NOT_INITIALIZED: HRESULT = 0x80041000; +pub const DXVA2_E_NEW_VIDEO_DEVICE: HRESULT = 0x80041001; +pub const DXVA2_E_VIDEO_DEVICE_LOCKED: HRESULT = 0x80041002; +pub const DXVA2_E_NOT_AVAILABLE: HRESULT = 0x80041003; +DEFINE_GUID!{IID_IDirect3DDeviceManager9, + 0xa0cade0f, 0x06d5, 0x4cf4, 0xa1, 0xc7, 0xf3, 0xcd, 0xd7, 0x25, 0xaa, 0x75} +DEFINE_GUID!{IID_IDirectXVideoAccelerationService, + 0xfc51a550, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02} +DEFINE_GUID!{IID_IDirectXVideoDecoderService, + 0xfc51a551, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02} +DEFINE_GUID!{IID_IDirectXVideoProcessorService, + 0xfc51a552, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02} +DEFINE_GUID!{IID_IDirectXVideoDecoder, + 0xf2b0810a, 0xfd00, 0x43c9, 0x91, 0x8c, 0xdf, 0x94, 0xe2, 0xd8, 0xef, 0x7d} +DEFINE_GUID!{IID_IDirectXVideoProcessor, + 0x8c3a39f0, 0x916e, 0x4690, 0x80, 0x4f, 0x4c, 0x80, 0x01, 0x35, 0x5d, 0x25} +DEFINE_GUID!{IID_IDirectXVideoMemoryConfiguration, + 0xb7f916dd, 0xdb3b, 0x49c1, 0x84, 0xd7, 0xe4, 0x5e, 0xf9, 0x9e, 0xc7, 0x26} +pub const MAX_DEINTERLACE_SURFACES: usize = 32; +pub const MAX_SUBSTREAMS: usize = 15; +STRUCT!{struct DXVA2_ExtendedFormat { + value: UINT, +}} +BITFIELD!{DXVA2_ExtendedFormat value: UINT [ + SampleFormat set_SampleFormat[0..8], + VideoChromaSubsampling set_VideoChromaSubsampling[8..12], + NominalRange set_NominalRange[12..15], + VideoTransferMatrix set_VideoTransferMatrix[15..18], + VideoLighting set_VideoLighting[18..22], + VideoPrimaries set_VideoPrimaries[22..27], + VideoTransferFunction set_VideoTransferFunction[27..32], +]} +ENUM!{enum DXVA2_SampleFormat { + DXVA2_SampleFormatMask = 0xff, + DXVA2_SampleUnknown = 0, + DXVA2_SampleProgressiveFrame = 2, + DXVA2_SampleFieldInterleavedEvenFirst = 3, + DXVA2_SampleFieldInterleavedOddFirst = 4, + DXVA2_SampleFieldSingleEven = 5, + DXVA2_SampleFieldSingleOdd = 6, + DXVA2_SampleSubStream = 7, +}} +ENUM!{enum DXVA2_VideoChromaSubSampling { + DXVA2_VideoChromaSubsamplingMask = 0xf, + DXVA2_VideoChromaSubsampling_Unknown = 0, + DXVA2_VideoChromaSubsampling_ProgressiveChroma = 0x8, + DXVA2_VideoChromaSubsampling_Horizontally_Cosited = 0x4, + DXVA2_VideoChromaSubsampling_Vertically_Cosited = 0x2, + DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes = 0x1, + DXVA2_VideoChromaSubsampling_MPEG2 = DXVA2_VideoChromaSubsampling_Horizontally_Cosited | + DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes, + DXVA2_VideoChromaSubsampling_MPEG1 = + DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes, + DXVA2_VideoChromaSubsampling_DV_PAL = DXVA2_VideoChromaSubsampling_Horizontally_Cosited | + DXVA2_VideoChromaSubsampling_Vertically_Cosited, + DXVA2_VideoChromaSubsampling_Cosited = DXVA2_VideoChromaSubsampling_Horizontally_Cosited | + DXVA2_VideoChromaSubsampling_Vertically_Cosited | + DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes, +}} +ENUM!{enum DXVA2_NominalRange { + DXVA2_NominalRangeMask = 0x7, + DXVA2_NominalRange_Unknown = 0, + DXVA2_NominalRange_Normal = 1, + DXVA2_NominalRange_Wide = 2, + DXVA2_NominalRange_0_255 = 1, + DXVA2_NominalRange_16_235 = 2, + DXVA2_NominalRange_48_208 = 3, +}} +ENUM!{enum DXVA2_VideoTransferMatrix { + DXVA2_VideoTransferMatrixMask = 0x7, + DXVA2_VideoTransferMatrix_Unknown = 0, + DXVA2_VideoTransferMatrix_BT709 = 1, + DXVA2_VideoTransferMatrix_BT601 = 2, + DXVA2_VideoTransferMatrix_SMPTE240M = 3, +}} +ENUM!{enum DXVA2_VideoLighting { + DXVA2_VideoLightingMask = 0xf, + DXVA2_VideoLighting_Unknown = 0, + DXVA2_VideoLighting_bright = 1, + DXVA2_VideoLighting_office = 2, + DXVA2_VideoLighting_dim = 3, + DXVA2_VideoLighting_dark = 4, +}} +ENUM!{enum DXVA2_VideoPrimaries { + DXVA2_VideoPrimariesMask = 0x1f, + DXVA2_VideoPrimaries_Unknown = 0, + DXVA2_VideoPrimaries_reserved = 1, + DXVA2_VideoPrimaries_BT709 = 2, + DXVA2_VideoPrimaries_BT470_2_SysM = 3, + DXVA2_VideoPrimaries_BT470_2_SysBG = 4, + DXVA2_VideoPrimaries_SMPTE170M = 5, + DXVA2_VideoPrimaries_SMPTE240M = 6, + DXVA2_VideoPrimaries_EBU3213 = 7, + DXVA2_VideoPrimaries_SMPTE_C = 8, +}} +ENUM!{enum DXVA2_VideoTransferFunction { + DXVA2_VideoTransFuncMask = 0x1f, + DXVA2_VideoTransFunc_Unknown = 0, + DXVA2_VideoTransFunc_10 = 1, + DXVA2_VideoTransFunc_18 = 2, + DXVA2_VideoTransFunc_20 = 3, + DXVA2_VideoTransFunc_22 = 4, + DXVA2_VideoTransFunc_709 = 5, + DXVA2_VideoTransFunc_240M = 6, + DXVA2_VideoTransFunc_sRGB = 7, + DXVA2_VideoTransFunc_28 = 8, +}} +pub const DXVA2_VideoTransFunc_22_709: DWORD = DXVA2_VideoTransFunc_709; +pub const DXVA2_VideoTransFunc_22_240M: DWORD = DXVA2_VideoTransFunc_240M; +pub const DXVA2_VideoTransFunc_22_8bit_sRGB: DWORD = DXVA2_VideoTransFunc_sRGB; +STRUCT!{struct DXVA2_Frequency { + Numerator: UINT, + Denominator: UINT, +}} +STRUCT!{struct DXVA2_VideoDesc { + SampleWidth: UINT, + SampleHeight: UINT, + SampleFormat: DXVA2_ExtendedFormat, + Format: D3DFORMAT, + InputSampleFreq: DXVA2_Frequency, + OutputFrameFreq: DXVA2_Frequency, + UABProtectionLevel: UINT, + Reserved: UINT, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0003 { + DXVA2_DeinterlaceTech_Unknown = 0, + DXVA2_DeinterlaceTech_BOBLineReplicate = 0x1, + DXVA2_DeinterlaceTech_BOBVerticalStretch = 0x2, + DXVA2_DeinterlaceTech_BOBVerticalStretch4Tap = 0x4, + DXVA2_DeinterlaceTech_MedianFiltering = 0x8, + DXVA2_DeinterlaceTech_EdgeFiltering = 0x10, + DXVA2_DeinterlaceTech_FieldAdaptive = 0x20, + DXVA2_DeinterlaceTech_PixelAdaptive = 0x40, + DXVA2_DeinterlaceTech_MotionVectorSteered = 0x80, + DXVA2_DeinterlaceTech_InverseTelecine = 0x100, + DXVA2_DeinterlaceTech_Mask = 0x1ff, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0004 { + DXVA2_NoiseFilterLumaLevel = 1, + DXVA2_NoiseFilterLumaThreshold = 2, + DXVA2_NoiseFilterLumaRadius = 3, + DXVA2_NoiseFilterChromaLevel = 4, + DXVA2_NoiseFilterChromaThreshold = 5, + DXVA2_NoiseFilterChromaRadius = 6, + DXVA2_DetailFilterLumaLevel = 7, + DXVA2_DetailFilterLumaThreshold = 8, + DXVA2_DetailFilterLumaRadius = 9, + DXVA2_DetailFilterChromaLevel = 10, + DXVA2_DetailFilterChromaThreshold = 11, + DXVA2_DetailFilterChromaRadius = 12, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0005 { + DXVA2_NoiseFilterTech_Unsupported = 0, + DXVA2_NoiseFilterTech_Unknown = 0x1, + DXVA2_NoiseFilterTech_Median = 0x2, + DXVA2_NoiseFilterTech_Temporal = 0x4, + DXVA2_NoiseFilterTech_BlockNoise = 0x8, + DXVA2_NoiseFilterTech_MosquitoNoise = 0x10, + DXVA2_NoiseFilterTech_Mask = 0x1f, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0006 { + DXVA2_DetailFilterTech_Unsupported = 0, + DXVA2_DetailFilterTech_Unknown = 0x1, + DXVA2_DetailFilterTech_Edge = 0x2, + DXVA2_DetailFilterTech_Sharpening = 0x4, + DXVA2_DetailFilterTech_Mask = 0x7, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0007 { + DXVA2_ProcAmp_None = 0, + DXVA2_ProcAmp_Brightness = 0x1, + DXVA2_ProcAmp_Contrast = 0x2, + DXVA2_ProcAmp_Hue = 0x4, + DXVA2_ProcAmp_Saturation = 0x8, + DXVA2_ProcAmp_Mask = 0xf, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0008 { + DXVA2_VideoProcess_None = 0, + DXVA2_VideoProcess_YUV2RGB = 0x1, + DXVA2_VideoProcess_StretchX = 0x2, + DXVA2_VideoProcess_StretchY = 0x4, + DXVA2_VideoProcess_AlphaBlend = 0x8, + DXVA2_VideoProcess_SubRects = 0x10, + DXVA2_VideoProcess_SubStreams = 0x20, + DXVA2_VideoProcess_SubStreamsExtended = 0x40, + DXVA2_VideoProcess_YUV2RGBExtended = 0x80, + DXVA2_VideoProcess_AlphaBlendExtended = 0x100, + DXVA2_VideoProcess_Constriction = 0x200, + DXVA2_VideoProcess_NoiseFilter = 0x400, + DXVA2_VideoProcess_DetailFilter = 0x800, + DXVA2_VideoProcess_PlanarAlpha = 0x1000, + DXVA2_VideoProcess_LinearScaling = 0x2000, + DXVA2_VideoProcess_GammaCompensated = 0x4000, + DXVA2_VideoProcess_MaintainsOriginalFieldData = 0x8000, + DXVA2_VideoProcess_Mask = 0xffff, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0009 { + DXVA2_VPDev_HardwareDevice = 0x1, + DXVA2_VPDev_EmulatedDXVA1 = 0x2, + DXVA2_VPDev_SoftwareDevice = 0x4, + DXVA2_VPDev_Mask = 0x7, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0010 { + DXVA2_SampleData_RFF = 0x1, + DXVA2_SampleData_TFF = 0x2, + DXVA2_SampleData_RFF_TFF_Present = 0x4, + DXVA2_SampleData_Mask = 0xffff, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0011 { + DXVA2_DestData_RFF = 0x1, + DXVA2_DestData_TFF = 0x2, + DXVA2_DestData_RFF_TFF_Present = 0x4, + DXVA2_DestData_Mask = 0xffff, +}} +STRUCT!{struct DXVA2_VideoProcessorCaps { + DeviceCaps: UINT, + InputPool: D3DPOOL, + NumForwardRefSamples: UINT, + NumBackwardRefSamples: UINT, + Reserved: UINT, + DeinterlaceTechnology: UINT, + ProcAmpControlCaps: UINT, + VideoProcessorOperations: UINT, + NoiseFilterTechnology: UINT, + DetailFilterTechnology: UINT, +}} +STRUCT!{struct DXVA2_Fixed32_s { + Fraction: USHORT, + Value: SHORT, +}} +UNION!{union DXVA2_Fixed32 { + [u32; 1], + s s_mut: DXVA2_Fixed32_s, + ll s_ll: LONG, +}} +STRUCT!{struct DXVA2_AYUVSample8 { + Cr: UCHAR, + Cb: UCHAR, + Y: UCHAR, + Alpha: UCHAR, +}} +STRUCT!{struct DXVA2_AYUVSample16 { + Cr: USHORT, + Cb: USHORT, + Y: USHORT, + Alpha: USHORT, +}} +pub type REFERENCE_TIME = LONGLONG; +STRUCT!{struct DXVA2_VideoSample { + Start: REFERENCE_TIME, + End: REFERENCE_TIME, + SampleFormat: DXVA2_ExtendedFormat, + SrcSurface: *mut IDirect3DSurface9, + SrcRect: RECT, + DstRect: RECT, + Pal: [DXVA2_AYUVSample8; 16], + PlanarAlpha: DXVA2_Fixed32, + SampleData: DWORD, +}} +STRUCT!{struct DXVA2_ValueRange { + MinValue: DXVA2_Fixed32, + MaxValue: DXVA2_Fixed32, + DefaultValue: DXVA2_Fixed32, + StepSize: DXVA2_Fixed32, +}} +STRUCT!{struct DXVA2_ProcAmpValues { + Brightness: DXVA2_Fixed32, + Contrast: DXVA2_Fixed32, + Hue: DXVA2_Fixed32, + Saturation: DXVA2_Fixed32, +}} +STRUCT!{struct DXVA2_FilterValues { + Level: DXVA2_Fixed32, + Threshold: DXVA2_Fixed32, + Radius: DXVA2_Fixed32, +}} +STRUCT!{struct DXVA2_VideoProcessBltParams { + TargetFrame: REFERENCE_TIME, + TargetRect: RECT, + ConstrictionSize: SIZE, + StreamingFlags: UINT, + BackgroundColor: DXVA2_AYUVSample16, + DestFormat: DXVA2_ExtendedFormat, + ProcAmpValues: DXVA2_ProcAmpValues, + Alpha: DXVA2_Fixed32, + NoiseFilterLuma: DXVA2_FilterValues, + NoiseFilterChroma: DXVA2_FilterValues, + DetailFilterLuma: DXVA2_FilterValues, + DetailFilterChroma: DXVA2_FilterValues, + DestData: DWORD, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0012 { + DXVA2_PictureParametersBufferType = 0, + DXVA2_MacroBlockControlBufferType = 1, + DXVA2_ResidualDifferenceBufferType = 2, + DXVA2_DeblockingControlBufferType = 3, + DXVA2_InverseQuantizationMatrixBufferType = 4, + DXVA2_SliceControlBufferType = 5, + DXVA2_BitStreamDateBufferType = 6, + DXVA2_MotionVectorBuffer = 7, + DXVA2_FilmGrainBuffer = 8, +}} +ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0013 { + DXVA2_VideoDecoderRenderTarget = 0, + DXVA2_VideoProcessorRenderTarget = 1, + DXVA2_VideoSoftwareRenderTarget = 2, +}} +STRUCT!{struct DXVA2_ConfigPictureDecode { + guidConfigBitstreamEncryption: GUID, + guidConfigMBcontrolEncryption: GUID, + guidConfigResidDiffEncryption: GUID, + ConfigBitstreamRaw: UINT, + ConfigMBcontrolRasterOrder: UINT, + ConfigResidDiffHost: UINT, + ConfigSpatialResid8: UINT, + ConfigResid8Subtraction: UINT, + ConfigSpatialHost8or9Clipping: UINT, + ConfigSpatialResidInterleaved: UINT, + ConfigIntraResidUnsigned: UINT, + ConfigResidDiffAccelerator: UINT, + ConfigHostInverseScan: UINT, + ConfigSpecificIDCT: UINT, + Config4GroupedCoefs: UINT, + ConfigMinRenderTargetBuffCount: USHORT, + ConfigDecoderSpecific: USHORT, +}} +STRUCT!{struct DXVA2_DecodeBufferDesc { + CompressedBufferType: DWORD, + BufferIndex: UINT, + DataOffset: UINT, + DataSize: UINT, + FirstMBaddress: UINT, + NumMBsInBuffer: UINT, + Width: UINT, + Height: UINT, + Stride: UINT, + ReservedBits: UINT, + pvPVPState: PVOID, +}} +STRUCT!{struct DXVA2_AES_CTR_IV { + IV: UINT64, + Count: UINT64, +}} +STRUCT!{struct DXVA2_DecodeExtensionData { + Function: UINT, + pPrivateInputData: PVOID, + PrivateInputDataSize: UINT, + pPrivateOutputData: PVOID, + PrivateOutputDataSize: UINT, +}} +pub const DXVA2_DECODE_GET_DRIVER_HANDLE: UINT = 0x725; +pub const DXVA2_DECODE_SPECIFY_ENCRYPTED_BLOCKS: UINT = 0x724; +STRUCT!{struct DXVA2_DecodeExecuteParams { + NumCompBuffers: UINT, + pCompressedBuffers: *mut DXVA2_DecodeBufferDesc, + pExtensionData: *mut DXVA2_DecodeExtensionData, +}} +RIDL!{#[uuid(0xa0cade0f, 0x06d5, 0x4cf4, 0xa1, 0xc7, 0xf3, 0xcd, 0xd7, 0x25, 0xaa, 0x75)] +interface IDirect3DDeviceManager9(IDirect3DDeviceManager9Vtbl): IUnknown(IUnknownVtbl) { + fn ResetDevice( + pDevice: *mut IDirect3DDevice9, + resetToken: UINT, + ) -> HRESULT, + fn OpenDeviceHandle( + phDevice: *mut HANDLE, + ) -> HRESULT, + fn CloseDeviceHandle( + hDevice: HANDLE, + ) -> HRESULT, + fn TestDevice( + hDevice: HANDLE, + ) -> HRESULT, + fn LockDevice( + hDevice: HANDLE, + ppDevice: *mut *mut IDirect3DDevice9, + fBloc: BOOL, + ) -> HRESULT, + fn UnlockDevice( + hDevice: HANDLE, + fSaveState: BOOL, + ) -> HRESULT, + fn GetVideoService( + hDevice: HANDLE, + riid: REFIID, + ppService: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xfc51a550, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02)] +interface IDirectXVideoAccelerationService(IDirectXVideoAccelerationServiceVtbl): + IUnknown(IUnknownVtbl) { + fn CreateSurface( + Width: UINT, + Height: UINT, + BackBuffers: UINT, + Format: D3DFORMAT, + Pool: D3DPOOL, + Usage: DWORD, + DxvaType: DWORD, + ppSurface: *mut *mut IDirect3DSurface9, + pSharedHandle: *mut HANDLE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xfc51a551, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02)] +interface IDirectXVideoDecoderService(IDirectXVideoDecoderServiceVtbl): + IDirectXVideoAccelerationService(IDirectXVideoAccelerationServiceVtbl) { + fn GetDecoderDeviceGuids( + pCount: *mut UINT, + pGuids: *mut *mut GUID, + ) -> HRESULT, + fn GetDecoderRenderTargets( + Guid: REFGUID, + pCount: *mut UINT, + pFormats: *mut *mut D3DFORMAT, + ) -> HRESULT, + fn GetDecoderConfigurations( + Guid: REFGUID, + pVideoDesc: *const DXVA2_VideoDesc, + pReserved: *mut c_void, + pCount: *mut UINT, + ppConfigs: *mut *mut DXVA2_ConfigPictureDecode, + ) -> HRESULT, + fn CreateVideoDecoder( + Guid: REFGUID, + pVideoDesc: *const DXVA2_VideoDesc, + pConfig: *const DXVA2_ConfigPictureDecode, + ppDecoderRenderTargets: *mut *mut IDirect3DSurface9, + NumRenderTargets: UINT, + ppDecode: *mut *mut IDirectXVideoDecoder, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xfc51a552, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02)] +interface IDirectXVideoProcessorService(IDirectXVideoProcessorServiceVtbl): + IDirectXVideoAccelerationService(IDirectXVideoAccelerationServiceVtbl) { + fn RegisterVideoProcessorSoftwareDevice( + pCallbacks: *mut c_void, + ) -> HRESULT, + fn GetVideoProcessorDeviceGuids( + pVideoDesc: *mut DXVA2_VideoDesc, + pCount: *mut UINT, + pGuids: *mut *mut GUID, + ) -> HRESULT, + fn GetVideoProcessorRenderTargets( + VideoProcDeviceGuid: REFGUID, + pVideoDesc: *const DXVA2_VideoDesc, + pCount: *mut UINT, + pFormats: *mut *mut D3DFORMAT, + ) -> HRESULT, + fn GetVideoProcessorSubStreamFormats( + VideoProcDeviceGuid: REFGUID, + pVideoDesc: *const DXVA2_VideoDesc, + RenderTargetFormat: D3DFORMAT, + pCount: *mut UINT, + pFormats: *mut *mut D3DFORMAT, + ) -> HRESULT, + fn GetVideoProcessorCaps( + VideoProcDeviceGuid: REFGUID, + pVideoDesc: *const DXVA2_VideoDesc, + RenderTargetFormat: D3DFORMAT, + pCaps: *mut DXVA2_VideoProcessorCaps, + ) -> HRESULT, + fn GetProcAmpRange( + VideoProcDeviceGuid: REFGUID, + pVideoDesc: *const DXVA2_VideoDesc, + RenderTargetFormat: D3DFORMAT, + ProcAmpCap: UINT, + pRange: *mut DXVA2_ValueRange, + ) -> HRESULT, + fn GetFilterPropertyRange( + VideoProcDeviceGuid: REFGUID, + pVideoDesc: *const DXVA2_VideoDesc, + RenderTargetFormat: D3DFORMAT, + FilterSetting: UINT, + pRange: *mut DXVA2_ValueRange, + ) -> HRESULT, + fn CreateVideoProcessor( + VideoProcDeviceGuid: REFGUID, + pVideoDesc: *const DXVA2_VideoDesc, + RenderTargetFormat: D3DFORMAT, + MaxNumSubStreams: UINT, + ppVidProcess: *mut *mut IDirectXVideoProcessor, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf2b0810a, 0xfd00, 0x43c9, 0x91, 0x8c, 0xdf, 0x94, 0xe2, 0xd8, 0xef, 0x7d)] +interface IDirectXVideoDecoder(IDirectXVideoDecoderVtbl): IUnknown(IUnknownVtbl) { + fn GetVideoDecoderService( + ppService: *mut *mut IDirectXVideoDecoderService, + ) -> HRESULT, + fn GetCreationParameters( + pDeviceGuid: *mut GUID, + pVideoDesc: *mut DXVA2_VideoDesc, + pConfig: *mut DXVA2_ConfigPictureDecode, + pDecoderRenderTargets: *mut *mut *mut IDirect3DSurface9, + pNumSurfaces: *mut UINT, + ) -> HRESULT, + fn GetBuffer( + BufferType: UINT, + ppBuffer: *mut *mut c_void, + pBufferSize: *mut UINT, + ) -> HRESULT, + fn ReleaseBuffer( + BufferType: UINT, + ) -> HRESULT, + fn BeginFrame( + pRenderTarget: *mut IDirect3DSurface9, + pvPVPData: *mut c_void, + ) -> HRESULT, + fn EndFrame( + pHandleComplete: *mut HANDLE, + ) -> HRESULT, + fn Execute( + pExecuteParams: *const DXVA2_DecodeExecuteParams, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8c3a39f0, 0x916e, 0x4690, 0x80, 0x4f, 0x4c, 0x80, 0x01, 0x35, 0x5d, 0x25)] +interface IDirectXVideoProcessor(IDirectXVideoProcessorVtbl): IUnknown(IUnknownVtbl) { + fn GetVideoProcessorService( + ppService: *mut *mut IDirectXVideoProcessorService, + ) -> HRESULT, + fn GetCreationParameters( + pDeviceGuid: *mut GUID, + pVideoDesc: *mut DXVA2_VideoDesc, + pRenderTargetFormat: *mut D3DFORMAT, + pMaxNumSubStreams: *mut UINT, + ) -> HRESULT, + fn GetVideoProcessorCaps( + pCaps: *mut DXVA2_VideoProcessorCaps, + ) -> HRESULT, + fn GetProcAmpRange( + ProcAmpCap: UINT, + pRange: *mut DXVA2_ValueRange, + ) -> HRESULT, + fn GetFilterPropertyRange( + FilterSetting: UINT, + pRange: *mut DXVA2_ValueRange, + ) -> HRESULT, + fn VideoProcessBlt( + pRenderTarget: *mut IDirect3DSurface9, + pBltParams: *const DXVA2_VideoProcessBltParams, + pSamples: *const DXVA2_VideoSample, + NumSamples: UINT, + pHandleComplete: *mut HANDLE, + ) -> HRESULT, +}} +ENUM!{enum DXVA2_SurfaceType { + DXVA2_SurfaceType_DecoderRenderTarget = 0, + DXVA2_SurfaceType_ProcessorRenderTarget = 1, + DXVA2_SurfaceType_D3DRenderTargetTexture = 2, +}} +RIDL!{#[uuid(0xb7f916dd, 0xdb3b, 0x49c1, 0x84, 0xd7, 0xe4, 0x5e, 0xf9, 0x9e, 0xc7, 0x26)] +interface IDirectXVideoMemoryConfiguration(IDirectXVideoMemoryConfigurationVtbl): + IUnknown(IUnknownVtbl) { + fn GetAvailableSurfaceTypeByIndex( + dwTypeIndex: DWORD, + pdwType: *mut DXVA2_SurfaceType, + ) -> HRESULT, + fn SetSurfaceType( + dwType: DXVA2_SurfaceType, + ) -> HRESULT, +}} +extern "system" { + pub fn DXVA2CreateDirect3DDeviceManager9( + pResetToken: *mut UINT, + ppDeviceManager: *mut *mut IDirect3DDeviceManager9, + ) -> HRESULT; + pub fn DXVA2CreateVideoService( + pDD: *mut IDirect3DDevice9, + riid: REFIID, + ppService: *mut *mut c_void, + ) -> HRESULT; +} +#[inline] +pub fn DXVA2FloatToFixed(_float_: c_float) -> DXVA2_Fixed32 { + unsafe { + let mut _fixed_: DXVA2_Fixed32 = ::core::mem::uninitialized(); + _fixed_.s_mut().Fraction = LOWORD((_float_ * 0x10000 as c_float) as DWORD); + _fixed_.s_mut().Value = HIWORD((_float_ * 0x10000 as c_float) as DWORD) as SHORT; + _fixed_ + } +} +#[inline] +pub fn DXVA2FixedToFloat(_fixed_: DXVA2_Fixed32) -> c_float { + unsafe { + _fixed_.s().Value as FLOAT + _fixed_.s().Fraction as FLOAT / 0x10000 as FLOAT + } +} +#[inline] +pub fn DXVA2_Fixed32TransparentAlpha() -> DXVA2_Fixed32 { + unsafe { + let mut _fixed_: DXVA2_Fixed32 = ::core::mem::uninitialized(); + _fixed_.s_mut().Fraction = 0; + _fixed_.s_mut().Value = 0; + _fixed_ + } +} +#[inline] +pub fn DXVA2_Fixed32OpaqueAlpha() -> DXVA2_Fixed32 { + unsafe { + let mut _fixed_: DXVA2_Fixed32 = ::core::mem::uninitialized(); + _fixed_.s_mut().Fraction = 0; + _fixed_.s_mut().Value = 1; + _fixed_ + } +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/dxvahd.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/dxvahd.rs new file mode 100644 index 0000000..755dfdc --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/dxvahd.rs @@ -0,0 +1,555 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_void; +use shared::d3d9::{IDirect3DDevice9Ex, IDirect3DSurface9}; +use shared::d3d9types::{D3DCOLOR, D3DFORMAT, D3DPOOL}; +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, DWORD, FLOAT, INT, UINT}; +use shared::windef::{RECT, SIZE}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, ULONGLONG}; +DEFINE_GUID!{IID_IDXVAHD_Device, + 0x95f12dfd, 0xd77e, 0x49be, 0x81, 0x5f, 0x57, 0xd5, 0x79, 0x63, 0x4d, 0x6d} +DEFINE_GUID!{IID_IDXVAHD_VideoProcessor, + 0x95f4edf4, 0x6e03, 0x4cd7, 0xbe, 0x1b, 0x30, 0x75, 0xd6, 0x65, 0xaa, 0x52} +ENUM!{enum DXVAHD_FRAME_FORMAT { + DXVAHD_FRAME_FORMAT_PROGRESSIVE = 0, + DXVAHD_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST = 1, + DXVAHD_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST = 2, +}} +ENUM!{enum DXVAHD_DEVICE_USAGE { + DXVAHD_DEVICE_USAGE_PLAYBACK_NORMAL = 0, + DXVAHD_DEVICE_USAGE_OPTIMAL_SPEED = 1, + DXVAHD_DEVICE_USAGE_OPTIMAL_QUALITY = 2, +}} +ENUM!{enum DXVAHD_SURFACE_TYPE { + DXVAHD_SURFACE_TYPE_VIDEO_INPUT = 0, + DXVAHD_SURFACE_TYPE_VIDEO_INPUT_PRIVATE = 1, + DXVAHD_SURFACE_TYPE_VIDEO_OUTPUT = 2, +}} +ENUM!{enum DXVAHD_DEVICE_TYPE { + DXVAHD_DEVICE_TYPE_HARDWARE = 0, + DXVAHD_DEVICE_TYPE_SOFTWARE = 1, + DXVAHD_DEVICE_TYPE_REFERENCE = 2, + DXVAHD_DEVICE_TYPE_OTHER = 3, +}} +ENUM!{enum DXVAHD_DEVICE_CAPS { + DXVAHD_DEVICE_CAPS_LINEAR_SPACE = 0x1, + DXVAHD_DEVICE_CAPS_xvYCC = 0x2, + DXVAHD_DEVICE_CAPS_RGB_RANGE_CONVERSION = 0x4, + DXVAHD_DEVICE_CAPS_YCbCr_MATRIX_CONVERSION = 0x8, +}} +ENUM!{enum DXVAHD_FEATURE_CAPS { + DXVAHD_FEATURE_CAPS_ALPHA_FILL = 0x1, + DXVAHD_FEATURE_CAPS_CONSTRICTION = 0x2, + DXVAHD_FEATURE_CAPS_LUMA_KEY = 0x4, + DXVAHD_FEATURE_CAPS_ALPHA_PALETTE = 0x8, +}} +ENUM!{enum DXVAHD_FILTER_CAPS { + DXVAHD_FILTER_CAPS_BRIGHTNESS = 0x1, + DXVAHD_FILTER_CAPS_CONTRAST = 0x2, + DXVAHD_FILTER_CAPS_HUE = 0x4, + DXVAHD_FILTER_CAPS_SATURATION = 0x8, + DXVAHD_FILTER_CAPS_NOISE_REDUCTION = 0x10, + DXVAHD_FILTER_CAPS_EDGE_ENHANCEMENT = 0x20, + DXVAHD_FILTER_CAPS_ANAMORPHIC_SCALING = 0x40, +}} +ENUM!{enum DXVAHD_INPUT_FORMAT_CAPS { + DXVAHD_INPUT_FORMAT_CAPS_RGB_INTERLACED = 0x1, + DXVAHD_INPUT_FORMAT_CAPS_RGB_PROCAMP = 0x2, + DXVAHD_INPUT_FORMAT_CAPS_RGB_LUMA_KEY = 0x4, + DXVAHD_INPUT_FORMAT_CAPS_PALETTE_INTERLACED = 0x8, +}} +ENUM!{enum DXVAHD_PROCESSOR_CAPS { + DXVAHD_PROCESSOR_CAPS_DEINTERLACE_BLEND = 0x1, + DXVAHD_PROCESSOR_CAPS_DEINTERLACE_BOB = 0x2, + DXVAHD_PROCESSOR_CAPS_DEINTERLACE_ADAPTIVE = 0x4, + DXVAHD_PROCESSOR_CAPS_DEINTERLACE_MOTION_COMPENSATION = 0x8, + DXVAHD_PROCESSOR_CAPS_INVERSE_TELECINE = 0x10, + DXVAHD_PROCESSOR_CAPS_FRAME_RATE_CONVERSION = 0x20, +}} +ENUM!{enum DXVAHD_ITELECINE_CAPS { + DXVAHD_ITELECINE_CAPS_32 = 0x1, + DXVAHD_ITELECINE_CAPS_22 = 0x2, + DXVAHD_ITELECINE_CAPS_2224 = 0x4, + DXVAHD_ITELECINE_CAPS_2332 = 0x8, + DXVAHD_ITELECINE_CAPS_32322 = 0x10, + DXVAHD_ITELECINE_CAPS_55 = 0x20, + DXVAHD_ITELECINE_CAPS_64 = 0x40, + DXVAHD_ITELECINE_CAPS_87 = 0x80, + DXVAHD_ITELECINE_CAPS_222222222223 = 0x100, + DXVAHD_ITELECINE_CAPS_OTHER = 0x80000000, +}} +ENUM!{enum DXVAHD_FILTER { + DXVAHD_FILTER_BRIGHTNESS = 0, + DXVAHD_FILTER_CONTRAST = 1, + DXVAHD_FILTER_HUE = 2, + DXVAHD_FILTER_SATURATION = 3, + DXVAHD_FILTER_NOISE_REDUCTION = 4, + DXVAHD_FILTER_EDGE_ENHANCEMENT = 5, + DXVAHD_FILTER_ANAMORPHIC_SCALING = 6, +}} +ENUM!{enum DXVAHD_BLT_STATE { + DXVAHD_BLT_STATE_TARGET_RECT = 0, + DXVAHD_BLT_STATE_BACKGROUND_COLOR = 1, + DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE = 2, + DXVAHD_BLT_STATE_ALPHA_FILL = 3, + DXVAHD_BLT_STATE_CONSTRICTION = 4, + DXVAHD_BLT_STATE_PRIVATE = 1000, +}} +ENUM!{enum DXVAHD_ALPHA_FILL_MODE { + DXVAHD_ALPHA_FILL_MODE_OPAQUE = 0, + DXVAHD_ALPHA_FILL_MODE_BACKGROUND = 1, + DXVAHD_ALPHA_FILL_MODE_DESTINATION = 2, + DXVAHD_ALPHA_FILL_MODE_SOURCE_STREAM = 3, +}} +ENUM!{enum DXVAHD_STREAM_STATE { + DXVAHD_STREAM_STATE_D3DFORMAT = 0, + DXVAHD_STREAM_STATE_FRAME_FORMAT = 1, + DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE = 2, + DXVAHD_STREAM_STATE_OUTPUT_RATE = 3, + DXVAHD_STREAM_STATE_SOURCE_RECT = 4, + DXVAHD_STREAM_STATE_DESTINATION_RECT = 5, + DXVAHD_STREAM_STATE_ALPHA = 6, + DXVAHD_STREAM_STATE_PALETTE = 7, + DXVAHD_STREAM_STATE_LUMA_KEY = 8, + DXVAHD_STREAM_STATE_ASPECT_RATIO = 9, + DXVAHD_STREAM_STATE_FILTER_BRIGHTNESS = 100, + DXVAHD_STREAM_STATE_FILTER_CONTRAST = 101, + DXVAHD_STREAM_STATE_FILTER_HUE = 102, + DXVAHD_STREAM_STATE_FILTER_SATURATION = 103, + DXVAHD_STREAM_STATE_FILTER_NOISE_REDUCTION = 104, + DXVAHD_STREAM_STATE_FILTER_EDGE_ENHANCEMENT = 105, + DXVAHD_STREAM_STATE_FILTER_ANAMORPHIC_SCALING = 106, + DXVAHD_STREAM_STATE_PRIVATE = 1000, +}} +ENUM!{enum DXVAHD_OUTPUT_RATE { + DXVAHD_OUTPUT_RATE_NORMAL = 0, + DXVAHD_OUTPUT_RATE_HALF = 1, + DXVAHD_OUTPUT_RATE_CUSTOM = 2, +}} +STRUCT!{struct DXVAHD_RATIONAL { + Numerator: UINT, + Denominator: UINT, +}} +STRUCT!{struct DXVAHD_COLOR_RGBA { + R: FLOAT, + G: FLOAT, + B: FLOAT, + A: FLOAT, +}} +STRUCT!{struct DXVAHD_COLOR_YCbCrA { + Y: FLOAT, + Cb: FLOAT, + Cr: FLOAT, + A: FLOAT, +}} +UNION!{union DXVAHD_COLOR { + [u32; 4], + RGB RGB_mut: DXVAHD_COLOR_RGBA, + YCbCr YCbCr_mut: DXVAHD_COLOR_YCbCrA, +}} +STRUCT!{struct DXVAHD_CONTENT_DESC { + InputFrameFormat: DXVAHD_FRAME_FORMAT, + InputFrameRate: DXVAHD_RATIONAL, + InputWidth: UINT, + InputHeight: UINT, + OutputFrameRate: DXVAHD_RATIONAL, + OutputWidth: UINT, + OutputHeight: UINT, +}} +STRUCT!{struct DXVAHD_VPDEVCAPS { + DeviceType: DXVAHD_DEVICE_TYPE, + DeviceCaps: UINT, + FeatureCaps: UINT, + FilterCaps: UINT, + InputFormatCaps: UINT, + InputPool: D3DPOOL, + OutputFormatCount: UINT, + InputFormatCount: UINT, + VideoProcessorCount: UINT, + MaxInputStreams: UINT, + MaxStreamStates: UINT, +}} +STRUCT!{struct DXVAHD_VPCAPS { + VPGuid: GUID, + PastFrames: UINT, + FutureFrames: UINT, + ProcessorCaps: UINT, + ITelecineCaps: UINT, + CustomRateCount: UINT, +}} +STRUCT!{struct DXVAHD_CUSTOM_RATE_DATA { + CustomRate: DXVAHD_RATIONAL, + OutputFrames: UINT, + InputInterlaced: BOOL, + InputFramesOrFields: UINT, +}} +STRUCT!{struct DXVAHD_FILTER_RANGE_DATA { + Minimum: INT, + Maximum: INT, + Default: INT, + Multiplier: FLOAT, +}} +STRUCT!{struct DXVAHD_BLT_STATE_TARGET_RECT_DATA { + Enable: BOOL, + TargetRect: RECT, +}} +STRUCT!{struct DXVAHD_BLT_STATE_BACKGROUND_COLOR_DATA { + YCbCr: BOOL, + BackgroundColor: DXVAHD_COLOR, +}} +STRUCT!{struct DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA { + Value: UINT, +}} +BITFIELD!{DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA Value: UINT [ + Usage set_Usage[0..1], + RGB_Range set_RGB_Range[1..2], + YCbCr_Matrix set_YCbCr_Matrix[2..3], + YCbCr_xvYCC set_YCbCr_xvYCC[3..4], + Reserved set_Reserved[4..32], +]} +STRUCT!{struct DXVAHD_BLT_STATE_ALPHA_FILL_DATA { + Mode: DXVAHD_ALPHA_FILL_MODE, + StreamNumber: UINT, +}} +STRUCT!{struct DXVAHD_BLT_STATE_CONSTRICTION_DATA { + Enable: BOOL, + Size: SIZE, +}} +STRUCT!{struct DXVAHD_BLT_STATE_PRIVATE_DATA { + Guid: GUID, + DataSize: UINT, + pData: *mut c_void, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_D3DFORMAT_DATA { + Format: D3DFORMAT, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_FRAME_FORMAT_DATA { + FrameFormat: DXVAHD_FRAME_FORMAT, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA { + Value: UINT, +}} +BITFIELD!{DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA Value: UINT [ + Type set_Type[0..1], + RGB_Range set_RGB_Range[1..2], + YCbCr_Matrix set_YCbCr_Matrix[2..3], + YCbCr_xvYCC set_YCbCr_xvYCC[3..4], + Reserved set_Reserved[4..32], +]} +STRUCT!{struct DXVAHD_STREAM_STATE_OUTPUT_RATE_DATA { + RepeatFrame: BOOL, + OutputRate: DXVAHD_OUTPUT_RATE, + CustomRate: DXVAHD_RATIONAL, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_SOURCE_RECT_DATA { + Enable: BOOL, + SourceRect: RECT, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_DESTINATION_RECT_DATA { + Enable: BOOL, + DestinationRect: RECT, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_ALPHA_DATA { + Enable: BOOL, + Alpha: FLOAT, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_PALETTE_DATA { + Count: UINT, + pEntries: *mut D3DCOLOR, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_LUMA_KEY_DATA { + Enable: BOOL, + Lower: FLOAT, + Upper: FLOAT, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_ASPECT_RATIO_DATA { + Enable: BOOL, + SourceAspectRatio: DXVAHD_RATIONAL, + DestinationAspectRatio: DXVAHD_RATIONAL, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_FILTER_DATA { + Enable: BOOL, + Level: INT, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_PRIVATE_DATA { + Guid: GUID, + DataSize: UINT, + pData: *mut c_void, +}} +STRUCT!{struct DXVAHD_STREAM_DATA { + Enable: BOOL, + OutputIndex: UINT, + InputFrameOrField: UINT, + PastFrames: UINT, + FutureFrames: UINT, + ppPastSurfaces: *mut *mut IDirect3DSurface9, + pInputSurface: *mut IDirect3DSurface9, + ppFutureSurfaces: *mut *mut IDirect3DSurface9, +}} +STRUCT!{struct DXVAHD_STREAM_STATE_PRIVATE_IVTC_DATA { + Enable: BOOL, + ITelecineFlags: UINT, + Frames: UINT, + InputField: UINT, +}} +RIDL!{#[uuid(0x95f12dfd, 0xd77e, 0x49be, 0x81, 0x5f, 0x57, 0xd5, 0x79, 0x63, 0x4d, 0x6d)] +interface IDXVAHD_Device(IDXVAHD_DeviceVtbl): IUnknown(IUnknownVtbl) { + fn CreateVideoSurface( + Width: UINT, + Height: UINT, + Format: D3DFORMAT, + Pool: D3DPOOL, + Usage: DWORD, + Type: DXVAHD_SURFACE_TYPE, + NumSurfaces: UINT, + ppSurfaces: *mut *mut IDirect3DSurface9, + pSharedHandle: *mut HANDLE, + ) -> HRESULT, + fn GetVideoProcessorDeviceCaps( + pCaps: *mut DXVAHD_VPDEVCAPS, + ) -> HRESULT, + fn GetVideoProcessorOutputFormats( + Count: UINT, + pFormats: *mut D3DFORMAT, + ) -> HRESULT, + fn GetVideoProcessorInputFormats( + Count: UINT, + pFormats: *mut D3DFORMAT, + ) -> HRESULT, + fn GetVideoProcessorCaps( + Count: UINT, + pCaps: *mut DXVAHD_VPCAPS, + ) -> HRESULT, + fn GetVideoProcessorCustomRates( + pVPGuid: *const GUID, + Count: UINT, + pRates: *mut DXVAHD_CUSTOM_RATE_DATA, + ) -> HRESULT, + fn GetVideoProcessorFilterRange( + Filter: DXVAHD_FILTER, + pRange: *mut DXVAHD_FILTER_RANGE_DATA, + ) -> HRESULT, + fn CreateVideoProcessor( + pVPGuid: *const GUID, + ppVideoProcessor: *mut *mut IDXVAHD_VideoProcessor, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x95f4edf4, 0x6e03, 0x4cd7, 0xbe, 0x1b, 0x30, 0x75, 0xd6, 0x65, 0xaa, 0x52)] +interface IDXVAHD_VideoProcessor(IDXVAHD_VideoProcessorVtbl): IUnknown(IUnknownVtbl) { + fn SetVideoProcessBltState( + State: DXVAHD_BLT_STATE, + DataSize: UINT, + pData: *const c_void, + ) -> HRESULT, + fn GetVideoProcessBltState( + State: DXVAHD_BLT_STATE, + DataSize: UINT, + pData: *mut c_void, + ) -> HRESULT, + fn SetVideoProcessStreamState( + StreamNumber: UINT, + State: DXVAHD_STREAM_STATE, + DataSize: UINT, + pData: *const c_void, + ) -> HRESULT, + fn GetVideoProcessStreamState( + StreamNumber: UINT, + State: DXVAHD_STREAM_STATE, + DataSize: UINT, + pData: *mut c_void, + ) -> HRESULT, + fn VideoProcessBltHD( + pOutputSurface: *mut IDirect3DSurface9, + OutputFrame: UINT, + StreamCount: UINT, + pStreams: *const DXVAHD_STREAM_DATA, + ) -> HRESULT, +}} +FN!{stdcall PDXVAHDSW_CreateDevice( + pD3DDevice: *mut IDirect3DDevice9Ex, + phDevice: *mut HANDLE, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_ProposeVideoPrivateFormat( + hDevice: HANDLE, + pFormat: *mut D3DFORMAT, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_GetVideoProcessorDeviceCaps( + hDevice: HANDLE, + pContentDesc: *const DXVAHD_CONTENT_DESC, + Usage: DXVAHD_DEVICE_USAGE, + pCaps: *mut DXVAHD_VPDEVCAPS, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_GetVideoProcessorOutputFormats( + hDevice: HANDLE, + pContentDesc: *const DXVAHD_CONTENT_DESC, + Usage: DXVAHD_DEVICE_USAGE, + Count: UINT, + pFormats: *mut D3DFORMAT, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_GetVideoProcessorInputFormats( + hDevice: HANDLE, + pContentDesc: *const DXVAHD_CONTENT_DESC, + Usage: DXVAHD_DEVICE_USAGE, + Count: UINT, + pFormats: *mut D3DFORMAT, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_GetVideoProcessorCaps( + hDevice: HANDLE, + pContentDesc: *const DXVAHD_CONTENT_DESC, + Usage: DXVAHD_DEVICE_USAGE, + Count: UINT, + pCaps: *mut DXVAHD_VPCAPS, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_GetVideoProcessorCustomRates( + hDevice: HANDLE, + pVPGuid: *const GUID, + Count: UINT, + pRates: *mut DXVAHD_CUSTOM_RATE_DATA, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_GetVideoProcessorFilterRange( + hDevice: HANDLE, + Filter: DXVAHD_FILTER, + pRange: *mut DXVAHD_FILTER_RANGE_DATA, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_DestroyDevice( + hDevice: HANDLE, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_CreateVideoProcessor( + hDevice: HANDLE, + pVPGuid: *const GUID, + phVideoProcessor: *mut HANDLE, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_SetVideoProcessBltState( + hVideoProcessor: HANDLE, + State: DXVAHD_BLT_STATE, + DataSize: UINT, + pData: *const c_void, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_GetVideoProcessBltStatePrivate( + hVideoProcessor: HANDLE, + pData: *mut DXVAHD_BLT_STATE_PRIVATE_DATA, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_SetVideoProcessStreamState( + hVideoProcessor: HANDLE, + StreamNumber: UINT, + State: DXVAHD_STREAM_STATE, + DataSize: UINT, + pData: *const c_void, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_GetVideoProcessStreamStatePrivate( + hVideoProcessor: HANDLE, + StreamNumber: UINT, + pData: *mut DXVAHD_STREAM_STATE_PRIVATE_DATA, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_VideoProcessBltHD( + hVideoProcessor: HANDLE, + pOutputSurface: *mut IDirect3DSurface9, + OutputFrame: UINT, + StreamCount: UINT, + pStreams: *const DXVAHD_STREAM_DATA, +) -> HRESULT} +FN!{stdcall PDXVAHDSW_DestroyVideoProcessor( + hVideoProcessor: HANDLE, +) -> HRESULT} +STRUCT!{struct DXVAHDSW_CALLBACKS { + CreateDevice: PDXVAHDSW_CreateDevice, + ProposeVideoPrivateFormat: PDXVAHDSW_ProposeVideoPrivateFormat, + GetVideoProcessorDeviceCaps: PDXVAHDSW_GetVideoProcessorDeviceCaps, + GetVideoProcessorOutputFormats: PDXVAHDSW_GetVideoProcessorOutputFormats, + GetVideoProcessorInputFormats: PDXVAHDSW_GetVideoProcessorInputFormats, + GetVideoProcessorCaps: PDXVAHDSW_GetVideoProcessorCaps, + GetVideoProcessorCustomRates: PDXVAHDSW_GetVideoProcessorCustomRates, + GetVideoProcessorFilterRange: PDXVAHDSW_GetVideoProcessorFilterRange, + DestroyDevice: PDXVAHDSW_DestroyDevice, + CreateVideoProcessor: PDXVAHDSW_CreateVideoProcessor, + SetVideoProcessBltState: PDXVAHDSW_SetVideoProcessBltState, + GetVideoProcessBltStatePrivate: PDXVAHDSW_GetVideoProcessBltStatePrivate, + SetVideoProcessStreamState: PDXVAHDSW_SetVideoProcessStreamState, + GetVideoProcessStreamStatePrivate: PDXVAHDSW_GetVideoProcessStreamStatePrivate, + VideoProcessBltHD: PDXVAHDSW_VideoProcessBltHD, + DestroyVideoProcessor: PDXVAHDSW_DestroyVideoProcessor, +}} +FN!{stdcall PDXVAHDSW_Plugin( + Size: UINT, + pCallbacks: *mut c_void, +) -> HRESULT} +DEFINE_GUID!{DXVAHDControlGuid, + 0xa0386e75, 0xf70c, 0x464c, 0xa9, 0xce, 0x33, 0xc4, 0x4e, 0x09, 0x16, 0x23} +DEFINE_GUID!{DXVAHDETWGUID_CREATEVIDEOPROCESSOR, + 0x681e3d1e, 0x5674, 0x4fb3, 0xa5, 0x03, 0x2f, 0x20, 0x55, 0xe9, 0x1f, 0x60} +DEFINE_GUID!{DXVAHDETWGUID_VIDEOPROCESSBLTSTATE, + 0x76c94b5a, 0x193f, 0x4692, 0x94, 0x84, 0xa4, 0xd9, 0x99, 0xda, 0x81, 0xa8} +DEFINE_GUID!{DXVAHDETWGUID_VIDEOPROCESSSTREAMSTATE, + 0x262c0b02, 0x209d, 0x47ed, 0x94, 0xd8, 0x82, 0xae, 0x02, 0xb8, 0x4a, 0xa7} +DEFINE_GUID!{DXVAHDETWGUID_VIDEOPROCESSBLTHD, + 0xbef3d435, 0x78c7, 0x4de3, 0x97, 0x07, 0xcd, 0x1b, 0x08, 0x3b, 0x16, 0x0a} +DEFINE_GUID!{DXVAHDETWGUID_VIDEOPROCESSBLTHD_STREAM, + 0x27ae473e, 0xa5fc, 0x4be5, 0xb4, 0xe3, 0xf2, 0x49, 0x94, 0xd3, 0xc4, 0x95} +DEFINE_GUID!{DXVAHDETWGUID_DESTROYVIDEOPROCESSOR, + 0xf943f0a0, 0x3f16, 0x43e0, 0x80, 0x93, 0x10, 0x5a, 0x98, 0x6a, 0xa5, 0xf1} +STRUCT!{struct DXVAHDETW_CREATEVIDEOPROCESSOR { + pObject: ULONGLONG, + pD3D9Ex: ULONGLONG, + VPGuid: GUID, +}} +STRUCT!{struct DXVAHDETW_VIDEOPROCESSBLTSTATE { + pObject: ULONGLONG, + State: DXVAHD_BLT_STATE, + DataSize: UINT, + SetState: BOOL, +}} +STRUCT!{struct DXVAHDETW_VIDEOPROCESSSTREAMSTATE { + pObject: ULONGLONG, + StreamNumber: UINT, + State: DXVAHD_STREAM_STATE, + DataSize: UINT, + SetState: BOOL, +}} +STRUCT!{struct DXVAHDETW_VIDEOPROCESSBLTHD { + pObject: ULONGLONG, + pOutputSurface: ULONGLONG, + TargetRect: RECT, + OutputFormat: D3DFORMAT, + ColorSpace: UINT, + OutputFrame: UINT, + StreamCount: UINT, + Enter: BOOL, +}} +STRUCT!{struct DXVAHDETW_VIDEOPROCESSBLTHD_STREAM { + pObject: ULONGLONG, + pInputSurface: ULONGLONG, + SourceRect: RECT, + DestinationRect: RECT, + InputFormat: D3DFORMAT, + FrameFormat: DXVAHD_FRAME_FORMAT, + ColorSpace: UINT, + StreamNumber: UINT, + OutputIndex: UINT, + InputFrameOrField: UINT, + PastFrames: UINT, + FutureFrames: UINT, +}} +STRUCT!{struct DXVAHDETW_DESTROYVIDEOPROCESSOR { + pObject: ULONGLONG, +}} +extern "system" { + pub fn DXVAHD_CreateDevice( + pD3DDevice: *mut IDirect3DDevice9Ex, + pContentDesc: *const DXVAHD_CONTENT_DESC, + Usage: DXVAHD_DEVICE_USAGE, + pPlugin: PDXVAHDSW_Plugin, + ppDevice: *mut *mut IDXVAHD_Device, + ) -> HRESULT; +} +FN!{stdcall PDXVAHD_CreateDevice( + pD3DDevice: *mut IDirect3DDevice9Ex, + pContentDesc: *const DXVAHD_CONTENT_DESC, + Usage: DXVAHD_DEVICE_USAGE, + pPlugin: PDXVAHDSW_Plugin, + ppDevice: *mut *mut IDXVAHD_Device, +) -> HRESULT} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/enclaveapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/enclaveapi.rs new file mode 100644 index 0000000..b2da8e1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/enclaveapi.rs @@ -0,0 +1,64 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{PSIZE_T, SIZE_T}; +use shared::minwindef::{BOOL, DWORD, LPCVOID, LPDWORD, LPVOID}; +use shared::ntdef::{HANDLE}; +use um::minwinbase::LPENCLAVE_ROUTINE; +use um::winnt::{LPCSTR, LPCWSTR}; +extern "system" { + pub fn IsEnclaveTypeSupported( + flEnclaveType: DWORD, + ) -> BOOL; + pub fn CreateEnclave( + hProcess: HANDLE, + lpAddress: LPVOID, + dwSize: SIZE_T, + dwInitialCommitment: SIZE_T, + flEnclaveType: DWORD, + lpEnclaveInformation: LPCVOID, + dwInfoLength: DWORD, + lpEnclaveError: LPDWORD, + ) -> LPVOID; + pub fn LoadEnclaveData( + hProcess: HANDLE, + lpAddress: LPVOID, + lpBuffer: LPCVOID, + nSize: SIZE_T, + flProtect: DWORD, + lpPageInformation: LPCVOID, + dwInfoLength: DWORD, + lpNumberOfBytesWritten: PSIZE_T, + lpEnclaveError: LPDWORD, + ) -> BOOL; + pub fn InitializeEnclave( + hProcess: HANDLE, + lpAddress: LPVOID, + lpEnclaveInformation: LPCVOID, + dwInfoLength: DWORD, + lpEnclaveError: LPDWORD, + ) -> BOOL; + pub fn LoadEnclaveImageA( + lpEnclaveAddress: LPVOID, + lpImageName: LPCSTR, + ) -> BOOL; + pub fn LoadEnclaveImageW( + lpEnclaveAddress: LPVOID, + lpImageName: LPCWSTR, + ) -> BOOL; + pub fn CallEnclave( + lpRoutine: LPENCLAVE_ROUTINE, + lpParameter: LPVOID, + fWaitForThread: BOOL, + lpReturnValue: *mut LPVOID, + ) -> BOOL; + pub fn TerminateEnclave( + lpAddress: LPVOID, + fWait: BOOL, + ) -> BOOL; + pub fn DeleteEnclave( + lpAddress: LPVOID, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/endpointvolume.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/endpointvolume.rs new file mode 100644 index 0000000..384e47b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/endpointvolume.rs @@ -0,0 +1,123 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_float; +use shared::basetsd::UINT32; +use shared::guiddef::{GUID, LPCGUID}; +use shared::minwindef::{BOOL, DWORD, UINT}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::HRESULT; +STRUCT!{struct AUDIO_VOLUME_NOTIFICATION_DATA { + guidEventContext: GUID, + bMuted: BOOL, + fMasterVolume: c_float, + nChannels: UINT, + afChannelVolumes: [c_float; 1], +}} +pub type PAUDIO_VOLUME_NOTIFICATION_DATA = *mut AUDIO_VOLUME_NOTIFICATION_DATA; +pub const ENDPOINT_HARDWARE_SUPPORT_VOLUME: DWORD = 0x00000001; +pub const ENDPOINT_HARDWARE_SUPPORT_MUTE: DWORD = 0x00000002; +pub const ENDPOINT_HARDWARE_SUPPORT_METER: DWORD = 0x00000004; +RIDL!{#[uuid(0x657804fa, 0xd6ad, 0x4496, 0x8a, 0x60, 0x35, 0x27, 0x52, 0xaf, 0x4f, 0x89)] +interface IAudioEndpointVolumeCallback(IAudioEndpointVolumeCallbackVtbl): IUnknown(IUnknownVtbl) { + fn OnNotify( + pNotify: PAUDIO_VOLUME_NOTIFICATION_DATA, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5cdf2c82, 0x841e, 0x4546, 0x97, 0x22, 0x0c, 0xf7, 0x40, 0x78, 0x22, 0x9a)] +interface IAudioEndpointVolume(IAudioEndpointVolumeVtbl): IUnknown(IUnknownVtbl) { + fn RegisterControlChangeNotify( + pNotify: *mut IAudioEndpointVolumeCallback, + ) -> HRESULT, + fn UnregisterControlChangeNotify( + pNotify: *mut IAudioEndpointVolumeCallback, + ) -> HRESULT, + fn GetChannelCount( + pnChannelCount: *mut UINT, + ) -> HRESULT, + fn SetMasterVolumeLevel( + fLevelDB: c_float, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn SetMasterVolumeLevelScalar( + fLevel: c_float, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn GetMasterVolumeLevel( + pfLevelDB: *mut c_float, + ) -> HRESULT, + fn GetMasterVolumeLevelScalar( + pfLevel: *mut c_float, + ) -> HRESULT, + fn SetChannelVolumeLevel( + nChannel: UINT, + fLevelDB: c_float, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn SetChannelVolumeLevelScalar( + nChannel: UINT, + fLevel: c_float, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn GetChannelVolumeLevel( + nChannel: UINT, + pfLevelDB: *mut c_float, + ) -> HRESULT, + fn GetChannelVolumeLevelScalar( + nChannel: UINT, + pfLevel: *mut c_float, + ) -> HRESULT, + fn SetMute( + bMute: BOOL, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn GetMute( + pbMute: *mut BOOL, + ) -> HRESULT, + fn GetVolumeStepInfo( + pnStep: *mut UINT, + pnStepCount: *mut UINT, + ) -> HRESULT, + fn VolumeStepUp( + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn VolumeStepDown( + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn QueryHardwareSupport( + pdwHardwareSupportMask: *mut DWORD, + ) -> HRESULT, + fn GetVolumeRange( + pflVolumeMindB: *mut c_float, + pflVolumeMaxdB: *mut c_float, + pflVolumeIncrementdB: *mut c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x66e11784, 0xf695, 0x4f28, 0xa5, 0x05, 0xa7, 0x08, 0x00, 0x81, 0xa7, 0x8f)] +interface IAudioEndpointVolumeEx(IAudioEndpointVolumeExVtbl): + IAudioEndpointVolume(IAudioEndpointVolumeVtbl) { + fn GetVolumeRangeChannel( + iChannel: UINT, + pflVolumeMindB: *mut c_float, + pflVolumeMaxdB: *mut c_float, + pflVolumeIncrementdB: *mut c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc02216f6, 0x8c67, 0x4b5b, 0x9d, 0x00, 0xd0, 0x08, 0xe7, 0x3e, 0x00, 0x64)] +interface IAudioMeterInformation(IAudioMeterInformationVtbl): IUnknown(IUnknownVtbl) { + fn GetPeakValue( + pfPeak: *mut c_float, + ) -> HRESULT, + fn GetMeteringChannelCount( + pnChannelCount: *mut UINT, + ) -> HRESULT, + fn GetChannelsPeakValues( + u32ChannelCount: UINT32, + afPeakValues: *mut c_float, + ) -> HRESULT, + fn QueryHardwareSupport( + pdwHardwareSupportMask: *mut DWORD, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/errhandlingapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/errhandlingapi.rs new file mode 100644 index 0000000..66d7618 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/errhandlingapi.rs @@ -0,0 +1,75 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-core-errorhandling-l1 +use shared::basetsd::ULONG_PTR; +use shared::minwindef::{BOOL, DWORD, LPDWORD, UINT, ULONG}; +use um::winnt::{ + EXCEPTION_POINTERS, LONG, LPCSTR, LPCWSTR, PCONTEXT, PEXCEPTION_RECORD, + PVECTORED_EXCEPTION_HANDLER, PVOID, +}; +FN!{stdcall PTOP_LEVEL_EXCEPTION_FILTER( + ExceptionInfo: *mut EXCEPTION_POINTERS, +) -> LONG} +pub type LPTOP_LEVEL_EXCEPTION_FILTER = PTOP_LEVEL_EXCEPTION_FILTER; +extern "system" { + pub fn RaiseException( + dwExceptionCode: DWORD, + dwExceptionFlags: DWORD, + nNumberOfArguments: DWORD, + lpArguments: *const ULONG_PTR, + ); + pub fn UnhandledExceptionFilter( + ExceptionInfo: *mut EXCEPTION_POINTERS, + ) -> LONG; + pub fn SetUnhandledExceptionFilter( + lpTopLevelExceptionFilter: LPTOP_LEVEL_EXCEPTION_FILTER, + ) -> LPTOP_LEVEL_EXCEPTION_FILTER; + pub fn GetLastError() -> DWORD; + pub fn SetLastError( + dwErrCode: DWORD, + ); + pub fn GetErrorMode() -> UINT; + pub fn SetErrorMode( + uMode: UINT, + ) -> UINT; + pub fn AddVectoredExceptionHandler( + First: ULONG, + Handler: PVECTORED_EXCEPTION_HANDLER, + ) -> PVOID; + pub fn RemoveVectoredExceptionHandler( + Handle: PVOID, + ) -> ULONG; + pub fn AddVectoredContinueHandler( + First: ULONG, + Handler: PVECTORED_EXCEPTION_HANDLER, + ) -> PVOID; + pub fn RemoveVectoredContinueHandler( + Handle: PVOID, + ) -> ULONG; +} +// RestoreLastError +extern "system" { + pub fn RaiseFailFastException( + pExceptionRecord: PEXCEPTION_RECORD, + pContextRecord: PCONTEXT, + dwFlags: DWORD, + ); + pub fn FatalAppExitA( + uAction: UINT, + lpMessageText: LPCSTR, + ); + pub fn FatalAppExitW( + uAction: UINT, + lpMessageText: LPCWSTR, + ); + pub fn GetThreadErrorMode() -> DWORD; + pub fn SetThreadErrorMode( + dwNewMode: DWORD, + lpOldMode: LPDWORD, + ) -> BOOL; +} +// What library provides this function? +// TerminateProcessOnMemoryExhaustion diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/evntcons.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/evntcons.rs new file mode 100644 index 0000000..48d4d70 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/evntcons.rs @@ -0,0 +1,229 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::ULONG64; +use shared::evntprov::EVENT_DESCRIPTOR; +use shared::evntrace::ETW_BUFFER_CONTEXT; +use shared::guiddef::{GUID, LPGUID}; +use shared::minwindef::{PUCHAR, PULONG, PUSHORT, UCHAR, ULONG, USHORT}; +use um::winnt::{ + ANYSIZE_ARRAY, BOOLEAN, LARGE_INTEGER, PCSTR, PSECURITY_DESCRIPTOR, PSID, PVOID, ULONGLONG, +}; +pub const EVENT_HEADER_EXT_TYPE_RELATED_ACTIVITYID: USHORT = 0x0001; +pub const EVENT_HEADER_EXT_TYPE_SID: USHORT = 0x0002; +pub const EVENT_HEADER_EXT_TYPE_TS_ID: USHORT = 0x0003; +pub const EVENT_HEADER_EXT_TYPE_INSTANCE_INFO: USHORT = 0x0004; +pub const EVENT_HEADER_EXT_TYPE_STACK_TRACE32: USHORT = 0x0005; +pub const EVENT_HEADER_EXT_TYPE_STACK_TRACE64: USHORT = 0x0006; +pub const EVENT_HEADER_EXT_TYPE_PEBS_INDEX: USHORT = 0x0007; +pub const EVENT_HEADER_EXT_TYPE_PMC_COUNTERS: USHORT = 0x0008; +pub const EVENT_HEADER_EXT_TYPE_PSM_KEY: USHORT = 0x0009; +pub const EVENT_HEADER_EXT_TYPE_EVENT_KEY: USHORT = 0x000A; +pub const EVENT_HEADER_EXT_TYPE_EVENT_SCHEMA_TL: USHORT = 0x000B; +pub const EVENT_HEADER_EXT_TYPE_PROV_TRAITS: USHORT = 0x000C; +pub const EVENT_HEADER_EXT_TYPE_PROCESS_START_KEY: USHORT = 0x000D; +pub const EVENT_HEADER_EXT_TYPE_CONTROL_GUID: USHORT = 0x000E; +pub const EVENT_HEADER_EXT_TYPE_MAX: USHORT = 0x000F; +STRUCT!{struct EVENT_HEADER_EXTENDED_DATA_ITEM_s { + bitfield: USHORT, +}} +BITFIELD!{EVENT_HEADER_EXTENDED_DATA_ITEM_s bitfield: USHORT [ + Linkage set_Linkage[0..1], + Reserved2 set_Reserved2[1..16], +]} +STRUCT!{struct EVENT_HEADER_EXTENDED_DATA_ITEM { + Reserved1: USHORT, + ExtType: USHORT, + s: EVENT_HEADER_EXTENDED_DATA_ITEM_s, + DataSize: USHORT, + DataPtr: ULONGLONG, +}} +pub type PEVENT_HEADER_EXTENDED_DATA_ITEM = *mut EVENT_HEADER_EXTENDED_DATA_ITEM; +STRUCT!{struct EVENT_EXTENDED_ITEM_INSTANCE { + InstanceId: ULONG, + ParentInstanceId: ULONG, + ParentGuid: GUID, +}} +pub type PEVENT_EXTENDED_ITEM_INSTANCE = *mut EVENT_EXTENDED_ITEM_INSTANCE; +STRUCT!{struct EVENT_EXTENDED_ITEM_RELATED_ACTIVITYID { + RelatedActivityId: GUID, +}} +pub type PEVENT_EXTENDED_ITEM_RELATED_ACTIVITYID = *mut EVENT_EXTENDED_ITEM_RELATED_ACTIVITYID; +STRUCT!{struct EVENT_EXTENDED_ITEM_TS_ID { + SessionId: ULONG, +}} +pub type PEVENT_EXTENDED_ITEM_TS_ID = *mut EVENT_EXTENDED_ITEM_TS_ID; +STRUCT!{struct EVENT_EXTENDED_ITEM_STACK_TRACE32 { + MatchId: ULONG64, + Address: [ULONG; ANYSIZE_ARRAY], +}} +pub type PEVENT_EXTENDED_ITEM_STACK_TRACE32 = *mut EVENT_EXTENDED_ITEM_STACK_TRACE32; +STRUCT!{struct EVENT_EXTENDED_ITEM_STACK_TRACE64 { + MatchId: ULONG64, + Address: [ULONG64; ANYSIZE_ARRAY], +}} +pub type PEVENT_EXTENDED_ITEM_STACK_TRACE64 = *mut EVENT_EXTENDED_ITEM_STACK_TRACE64; +STRUCT!{struct EVENT_EXTENDED_ITEM_PEBS_INDEX { + PebsIndex: ULONG64, +}} +pub type PEVENT_EXTENDED_ITEM_PEBS_INDEX = *mut EVENT_EXTENDED_ITEM_PEBS_INDEX; +STRUCT!{struct EVENT_EXTENDED_ITEM_PMC_COUNTERS { + Counter: [ULONG64; ANYSIZE_ARRAY], +}} +pub type PEVENT_EXTENDED_ITEM_PMC_COUNTERS = *mut EVENT_EXTENDED_ITEM_PMC_COUNTERS; +STRUCT!{struct EVENT_EXTENDED_ITEM_PROCESS_START_KEY { + ProcessStartKey: ULONG64, +}} +pub type PEVENT_EXTENDED_ITEM_PROCESS_START_KEY = *mut EVENT_EXTENDED_ITEM_PROCESS_START_KEY; +STRUCT!{struct EVENT_EXTENDED_ITEM_EVENT_KEY { + Key: ULONG64, +}} +pub type PEVENT_EXTENDED_ITEM_EVENT_KEY = *mut EVENT_EXTENDED_ITEM_EVENT_KEY; +pub const EVENT_HEADER_PROPERTY_XML: USHORT = 0x0001; +pub const EVENT_HEADER_PROPERTY_FORWARDED_XML: USHORT = 0x0002; +pub const EVENT_HEADER_PROPERTY_LEGACY_EVENTLOG: USHORT = 0x0004; +pub const EVENT_HEADER_PROPERTY_RELOGGABLE: USHORT = 0x0008; +pub const EVENT_HEADER_FLAG_EXTENDED_INFO: USHORT = 0x0001; +pub const EVENT_HEADER_FLAG_PRIVATE_SESSION: USHORT = 0x0002; +pub const EVENT_HEADER_FLAG_STRING_ONLY: USHORT = 0x0004; +pub const EVENT_HEADER_FLAG_TRACE_MESSAGE: USHORT = 0x0008; +pub const EVENT_HEADER_FLAG_NO_CPUTIME: USHORT = 0x0010; +pub const EVENT_HEADER_FLAG_32_BIT_HEADER: USHORT = 0x0020; +pub const EVENT_HEADER_FLAG_64_BIT_HEADER: USHORT = 0x0040; +pub const EVENT_HEADER_FLAG_CLASSIC_HEADER: USHORT = 0x0100; +pub const EVENT_HEADER_FLAG_PROCESSOR_INDEX: USHORT = 0x0200; +STRUCT!{struct EVENT_HEADER_u_s { + KernelTime: ULONG, + UserTime: ULONG, +}} +UNION!{union EVENT_HEADER_u { + [u64; 1], + s s_mut: EVENT_HEADER_u_s, + ProcessorTime ProcessorTime_mut: ULONG64, +}} +STRUCT!{struct EVENT_HEADER { + Size: USHORT, + HeaderType: USHORT, + Flags: USHORT, + EventProperty: USHORT, + ThreadId: ULONG, + ProcessId: ULONG, + TimeStamp: LARGE_INTEGER, + ProviderId: GUID, + EventDescriptor: EVENT_DESCRIPTOR, + u: EVENT_HEADER_u, + ActivityId: GUID, +}} +pub type PEVENT_HEADER = *mut EVENT_HEADER; +STRUCT!{struct EVENT_RECORD { + EventHeader: EVENT_HEADER, + BufferContext: ETW_BUFFER_CONTEXT, + ExtendedDataCount: USHORT, + UserDataLength: USHORT, + ExtendedData: PEVENT_HEADER_EXTENDED_DATA_ITEM, + UserData: PVOID, + UserContext: PVOID, +}} +pub type PEVENT_RECORD = *mut EVENT_RECORD; +pub type PCEVENT_RECORD = *const EVENT_RECORD; +pub const EVENT_ENABLE_PROPERTY_SID: USHORT = 0x00000001; +pub const EVENT_ENABLE_PROPERTY_TS_ID: USHORT = 0x00000002; +pub const EVENT_ENABLE_PROPERTY_STACK_TRACE: USHORT = 0x00000004; +pub const EVENT_ENABLE_PROPERTY_PSM_KEY: USHORT = 0x00000008; +pub const EVENT_ENABLE_PROPERTY_IGNORE_KEYWORD_0: USHORT = 0x00000010; +pub const EVENT_ENABLE_PROPERTY_PROVIDER_GROUP: USHORT = 0x00000020; +pub const EVENT_ENABLE_PROPERTY_ENABLE_KEYWORD_0: USHORT = 0x00000040; +pub const EVENT_ENABLE_PROPERTY_PROCESS_START_KEY: USHORT = 0x00000080; +pub const EVENT_ENABLE_PROPERTY_EVENT_KEY: USHORT = 0x00000100; +pub const EVENT_ENABLE_PROPERTY_EXCLUDE_INPRIVATE: USHORT = 0x00000200; +pub const PROCESS_TRACE_MODE_REAL_TIME: ULONG = 0x00000100; +pub const PROCESS_TRACE_MODE_RAW_TIMESTAMP: ULONG = 0x00001000; +pub const PROCESS_TRACE_MODE_EVENT_RECORD: ULONG = 0x10000000; +#[inline] +pub unsafe fn GetEventProcessorIndex(EventRecord: PCEVENT_RECORD) -> ULONG { + if (*EventRecord).EventHeader.Flags & EVENT_HEADER_FLAG_PROCESSOR_INDEX != 0 { + *(*EventRecord).BufferContext.u.ProcessorIndex() as ULONG + } else { + (*EventRecord).BufferContext.u.s().ProcessorNumber as ULONG + } +} +ENUM!{enum ETW_PROVIDER_TRAIT_TYPE { + EtwProviderTraitTypeGroup = 1, + EtwProviderTraitDecodeGuid = 2, + EtwProviderTraitTypeMax, +}} +#[inline] +unsafe fn strnlen(s: PCSTR, max_len: isize) -> isize { + let mut len = 0; + while *s.offset(len) != 0 && len < max_len { + len += 1 + } + len +} +// Taken from Rust 1.17.0 sources +#[inline] +unsafe fn read_unaligned<T>(src: *const T) -> T { + use core::{mem, ptr}; + let mut tmp: T = mem::uninitialized(); + ptr::copy_nonoverlapping( + src as *const u8, + &mut tmp as *mut T as *mut u8, + mem::size_of::<T>(), + ); + tmp +} +#[inline] +pub unsafe fn EtwGetTraitFromProviderTraits( + ProviderTraits: PVOID, TraitType: UCHAR, Trait: *mut PVOID, Size: PUSHORT, +) { + use core::ptr::null_mut; + let ByteCount = read_unaligned(ProviderTraits as *mut USHORT) as isize; + let mut Ptr = ProviderTraits as PUCHAR; + let PtrEnd = Ptr.offset(ByteCount); + *Trait = null_mut(); + *Size = 0; + if ByteCount < 3 { + return; + } + Ptr = Ptr.offset(2); + Ptr = Ptr.offset(strnlen(Ptr as PCSTR, (ByteCount - 3) as isize)); + Ptr = Ptr.offset(1); + while Ptr < PtrEnd { + let TraitByteCount = read_unaligned(Ptr as *const USHORT); + if TraitByteCount < 3 { + return; + } + if *Ptr.offset(2) == TraitType && Ptr.offset(TraitByteCount as isize) <= PtrEnd { + *Trait = Ptr.offset(3) as PVOID; + *Size = TraitByteCount - 3; + return; + } + Ptr = Ptr.offset(TraitByteCount as isize); + } +} +ENUM!{enum EVENTSECURITYOPERATION { + EventSecuritySetDACL, + EventSecuritySetSACL, + EventSecurityAddDACL, + EventSecurityAddSACL, + EventSecurityMax, +}} +extern "system" { + pub fn EventAccessControl( + Guid: LPGUID, + Operation: ULONG, + Sid: PSID, + Rights: ULONG, + AllowOrDeny: BOOLEAN, + ) -> ULONG; + pub fn EventAccessQuery( + Guid: LPGUID, + Buffer: PSECURITY_DESCRIPTOR, + BufferSize: PULONG, + ) -> ULONG; + pub fn EventAccessRemove( + Guid: LPGUID, + ) -> ULONG; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/exdisp.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/exdisp.rs new file mode 100644 index 0000000..3d44fd3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/exdisp.rs @@ -0,0 +1,220 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of ExDisp.h +use shared::basetsd::SHANDLE_PTR; +use shared::wtypes::{BSTR, VARIANT_BOOL}; +use um::docobj::{OLECMDEXECOPT, OLECMDF, OLECMDID}; +use um::oaidl::{IDispatch, IDispatchVtbl, VARIANT}; +use um::ocidl::READYSTATE; +use um::winnt::{HRESULT, INT, LONG}; +DEFINE_GUID!{IID_IWebBrowser2, + 0xd30c1661, 0xcdaf, 0x11d0, 0x8a, 0x3e, 0x00, 0xc0, 0x4f, 0xc9, 0xe2, 0x6e} +RIDL!{#[uuid(0xeab22ac1, 0x30c1, 0x11cf, 0xa7, 0xeb, 0x00, 0x00, 0xc0, 0x5b, 0xae, 0x0b)] +interface IWebBrowser(IWebBrowserVtbl): IDispatch(IDispatchVtbl) { + fn GoBack() -> HRESULT, + fn GoForward() -> HRESULT, + fn GoHome() -> HRESULT, + fn GoSearch() -> HRESULT, + fn Navigate( + URL: BSTR, + Flags: *const VARIANT, + TargetFrameName: *const VARIANT, + PostData: *const VARIANT, + Headers: *const VARIANT, + ) -> HRESULT, + fn Refresh() -> HRESULT, + fn Refresh2( + Level: *const VARIANT, + ) -> HRESULT, + fn Stop() -> HRESULT, + fn get_Application( + ppDisp: *mut *mut IDispatch, + ) -> HRESULT, + fn get_Parent( + ppDisp: *mut *mut IDispatch, + ) -> HRESULT, + fn get_Container( + ppDisp: *mut *mut IDispatch, + ) -> HRESULT, + fn get_Document( + ppDisp: *mut *mut IDispatch, + ) -> HRESULT, + fn get_TopLevelContainer( + pBool: *mut VARIANT_BOOL, + ) -> HRESULT, + fn get_Type( + Type: *mut BSTR, + ) -> HRESULT, + fn get_Left( + pl: *mut LONG, + ) -> HRESULT, + fn put_Left( + Left: LONG, + ) -> HRESULT, + fn get_Top( + pl: *mut LONG, + ) -> HRESULT, + fn put_Top( + Top: LONG, + ) -> HRESULT, + fn get_Width( + pl: *mut LONG, + ) -> HRESULT, + fn put_Width( + Width: LONG, + ) -> HRESULT, + fn get_Height( + pl: *mut LONG, + ) -> HRESULT, + fn put_Height( + Height: LONG, + ) -> HRESULT, + fn get_LocationName( + LocationName: *mut BSTR, + ) -> HRESULT, + fn get_LocationURL( + LocationURL: *mut BSTR, + ) -> HRESULT, + fn get_Busy( + pBool: *mut VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0002df05, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IWebBrowserApp(IWebBrowserAppVtbl): IWebBrowser(IWebBrowserVtbl) { + fn Quit() -> HRESULT, + fn ClientToWindow( + pcx: *mut INT, + pcy: *mut INT, + ) -> HRESULT, + fn PutProperty( + Property: BSTR, + vtValue: VARIANT, + ) -> HRESULT, + fn GetProperty( + Property: BSTR, + pvtValue: *mut VARIANT, + ) -> HRESULT, + fn get_Name( + Name: *mut BSTR, + ) -> HRESULT, + fn get_HWND( + pHWND: *mut SHANDLE_PTR, + ) -> HRESULT, + fn get_FullName( + FullName: *mut BSTR, + ) -> HRESULT, + fn get_Path( + Path: *mut BSTR, + ) -> HRESULT, + fn get_Visible( + pBool: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Visible( + Value: VARIANT_BOOL, + ) -> HRESULT, + fn get_StatusBar( + pBool: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_StatusBar( + Value: VARIANT_BOOL, + ) -> HRESULT, + fn get_StatusText( + StatusText: *mut BSTR, + ) -> HRESULT, + fn put_StatusText( + StatusText: BSTR, + ) -> HRESULT, + fn get_ToolBar( + Value: *mut INT, + ) -> HRESULT, + fn put_ToolBar( + Value: INT, + ) -> HRESULT, + fn get_MenuBar( + Value: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_MenuBar( + Value: VARIANT_BOOL, + ) -> HRESULT, + fn get_FullScreen( + pbFullScreen: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_FullScreen( + bFullScreen: VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd30c1661, 0xcdaf, 0x11d0, 0x8a, 0x3e, 0x00, 0xc0, 0x4f, 0xc9, 0xe2, 0x6e)] +interface IWebBrowser2(IWebBrowser2Vtbl): IWebBrowserApp(IWebBrowserAppVtbl) { + fn Navigate2( + URL: *const VARIANT, + Flags: *const VARIANT, + TargetFrameName: *const VARIANT, + PostData: *const VARIANT, + Headers: *const VARIANT, + ) -> HRESULT, + fn QueryStatusWB( + cmdID: OLECMDID, + pcmdf: *mut OLECMDF, + ) -> HRESULT, + fn ExecWB( + cmdID: OLECMDID, + cmdexecopt: OLECMDEXECOPT, + pvaIn: *const VARIANT, + pvaOut: *mut VARIANT, + ) -> HRESULT, + fn ShowBrowserBar( + pvaClsid: *const VARIANT, + pvarShow: *const VARIANT, + pvarSize: *const VARIANT, + ) -> HRESULT, + fn get_ReadyState( + plReadyState: *mut READYSTATE, + ) -> HRESULT, + fn get_Offline( + pbOffline: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Offline( + bOffline: VARIANT_BOOL, + ) -> HRESULT, + fn get_Silent( + pbSilent: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Silent( + bSilent: VARIANT_BOOL, + ) -> HRESULT, + fn get_RegisterAsBrowser( + pbRegister: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_RegisterAsBrowser( + bRegister: VARIANT_BOOL, + ) -> HRESULT, + fn get_RegisterAsDropTarget( + pbRegister: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_RegisterAsDropTarget( + bRegister: VARIANT_BOOL, + ) -> HRESULT, + fn get_TheaterMode( + pbRegister: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_TheaterMode( + bRegister: VARIANT_BOOL, + ) -> HRESULT, + fn get_AddressBar( + Value: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_AddressBar( + Value: VARIANT_BOOL, + ) -> HRESULT, + fn get_Resizable( + Value: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Resizable( + Value: VARIANT_BOOL, + ) -> HRESULT, +}} +DEFINE_GUID!{CLSID_InternetExplorer, + 0x0002df01, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/fibersapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/fibersapi.rs new file mode 100644 index 0000000..c2e3b08 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/fibersapi.rs @@ -0,0 +1,23 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, DWORD}; +use um::winnt::{PFLS_CALLBACK_FUNCTION, PVOID}; +extern "system" { + pub fn FlsAlloc( + lpCallback: PFLS_CALLBACK_FUNCTION, + ) -> DWORD; + pub fn FlsGetValue( + dwFlsIndex: DWORD, + ) -> PVOID; + pub fn FlsSetValue( + dwFlsIndex: DWORD, + lpFlsData: PVOID, + ) -> BOOL; + pub fn FlsFree( + dwFlsIndex: DWORD, + ) -> BOOL; + pub fn IsThreadAFiber() -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/fileapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/fileapi.rs new file mode 100644 index 0000000..ed183a5 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/fileapi.rs @@ -0,0 +1,639 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-core-file-l1 +use shared::minwindef::{ + BOOL, DWORD, FILETIME, LPCVOID, LPDWORD, LPFILETIME, LPVOID, PDWORD, PUCHAR, UCHAR, UINT, + ULONG, WORD, +}; +use um::minwinbase::{ + FILE_INFO_BY_HANDLE_CLASS, FINDEX_INFO_LEVELS, FINDEX_SEARCH_OPS, GET_FILEEX_INFO_LEVELS, + LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE, LPSECURITY_ATTRIBUTES, LPWIN32_FIND_DATAA, + LPWIN32_FIND_DATAW +}; +use um::winnt::{ + BOOLEAN, CCHAR, FILE_ID_128, FILE_SEGMENT_ELEMENT, HANDLE, LARGE_INTEGER, LONG, LONGLONG, + LPCSTR, LPCWSTR, LPSTR, LPWCH, LPWSTR, PLARGE_INTEGER, PLONG, PULARGE_INTEGER, PWSTR, + ULONGLONG, WCHAR, +}; +pub const CREATE_NEW: DWORD = 1; +pub const CREATE_ALWAYS: DWORD = 2; +pub const OPEN_EXISTING: DWORD = 3; +pub const OPEN_ALWAYS: DWORD = 4; +pub const TRUNCATE_EXISTING: DWORD = 5; +pub const INVALID_FILE_SIZE: DWORD = 0xFFFFFFFF; +pub const INVALID_SET_FILE_POINTER: DWORD = 0xFFFFFFFF; +pub const INVALID_FILE_ATTRIBUTES: DWORD = 0xFFFFFFFF; +STRUCT!{struct WIN32_FILE_ATTRIBUTE_DATA { + dwFileAttributes: DWORD, + ftCreationTime: FILETIME, + ftLastAccessTime: FILETIME, + ftLastWriteTime: FILETIME, + nFileSizeHigh: DWORD, + nFileSizeLow: DWORD, +}} +pub type LPWIN32_FILE_ATTRIBUTE_DATA = *mut WIN32_FILE_ATTRIBUTE_DATA; +STRUCT!{struct BY_HANDLE_FILE_INFORMATION { + dwFileAttributes: DWORD, + ftCreationTime: FILETIME, + ftLastAccessTime: FILETIME, + ftLastWriteTime: FILETIME, + dwVolumeSerialNumber: DWORD, + nFileSizeHigh: DWORD, + nFileSizeLow: DWORD, + nNumberOfLinks: DWORD, + nFileIndexHigh: DWORD, + nFileIndexLow: DWORD, +}} +pub type PBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION; +pub type LPBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION; +STRUCT!{struct CREATEFILE2_EXTENDED_PARAMETERS { + dwSize: DWORD, + dwFileAttributes: DWORD, + dwFileFlags: DWORD, + dwSecurityQosFlags: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + hTemplateFile: HANDLE, +}} +pub type PCREATEFILE2_EXTENDED_PARAMETERS = *mut CREATEFILE2_EXTENDED_PARAMETERS; +pub type LPCREATEFILE2_EXTENDED_PARAMETERS = *mut CREATEFILE2_EXTENDED_PARAMETERS; +ENUM!{enum PRIORITY_HINT { + IoPriorityHintVeryLow = 0, + IoPriorityHintLow = 1, + IoPriorityHintNormal = 2, + MaximumIoPriorityHintType = 3, +}} +STRUCT!{struct FILE_BASIC_INFO { + CreationTime: LARGE_INTEGER, + LastAccessTime: LARGE_INTEGER, + LastWriteTime: LARGE_INTEGER, + ChangeTime: LARGE_INTEGER, + FileAttributes: DWORD, +}} +STRUCT!{struct FILE_STANDARD_INFO { + AllocationSize: LARGE_INTEGER, + EndOfFile: LARGE_INTEGER, + NumberOfLinks: DWORD, + DeletePending: BOOLEAN, + Directory: BOOLEAN, +}} +STRUCT!{struct FILE_NAME_INFO { + FileNameLength: DWORD, + FileName: [WCHAR; 1], +}} +STRUCT!{struct FILE_RENAME_INFO { + ReplaceIfExists: BOOL, + RootDirectory: HANDLE, + FileNameLength: DWORD, + FileName: [WCHAR; 1], +}} +STRUCT!{struct FILE_DISPOSITION_INFO { + DeleteFile: BOOLEAN, +}} +STRUCT!{struct FILE_ALLOCATION_INFO { + AllocationSize: LARGE_INTEGER, +}} +STRUCT!{struct FILE_END_OF_FILE_INFO { + EndOfFile: LARGE_INTEGER, +}} +STRUCT!{struct FILE_STREAM_INFO { + NextEntryOffset: DWORD, + StreamNameLength: DWORD, + StreamSize: LARGE_INTEGER, + StreamAllocationSize: LARGE_INTEGER, + StreamName: [WCHAR; 1], +}} +STRUCT!{struct FILE_COMPRESSION_INFO { + CompressedFileSize: LARGE_INTEGER, + CompressionFormat: WORD, + CompressionUnitShift: UCHAR, + ChunkShift: UCHAR, + ClusterShift: UCHAR, + Reserved: [UCHAR; 3], +}} +STRUCT!{struct FILE_ATTRIBUTE_TAG_INFO { + NextEntryOffset: DWORD, + ReparseTag: DWORD, +}} +STRUCT!{struct FILE_ID_BOTH_DIR_INFO { + NextEntryOffset: DWORD, + FileIndex: DWORD, + CreationTime: LARGE_INTEGER, + LastAccessTime: LARGE_INTEGER, + LastWriteTime: LARGE_INTEGER, + ChangeTime: LARGE_INTEGER, + EndOfFile: LARGE_INTEGER, + AllocationSize: LARGE_INTEGER, + FileAttributes: DWORD, + FileNameLength: DWORD, + EaSize: DWORD, + ShortNameLength: CCHAR, + ShortName: [WCHAR; 12], + FileId: LARGE_INTEGER, + FileName: [WCHAR; 1], +}} +STRUCT!{struct FILE_IO_PRIORITY_HINT_INFO { + PriorityHint: PRIORITY_HINT, +}} +STRUCT!{struct FILE_FULL_DIR_INFO { + NextEntryOffset: ULONG, + FileIndex: ULONG, + CreationTime: LARGE_INTEGER, + LastAccessTime: LARGE_INTEGER, + LastWriteTime: LARGE_INTEGER, + ChangeTime: LARGE_INTEGER, + EndOfFile: LARGE_INTEGER, + AllocationSize: LARGE_INTEGER, + FileAttributes: ULONG, + FileNameLength: ULONG, + EaSize: ULONG, + FileName: [WCHAR; 1], +}} +STRUCT!{struct FILE_STORAGE_INFO { + LogicalBytesPerSector: ULONG, + PhysicalBytesPerSectorForAtomicity: ULONG, + PhysicalBytesPerSectorForPerformance: ULONG, + FileSystemEffectivePhysicalBytesPerSectorForAtomicity: ULONG, + Flags: ULONG, + ByteOffsetForSectorAlignment: ULONG, + ByteOffsetForPartitionAlignment: ULONG, +}} +STRUCT!{struct FILE_ALIGNMENT_INFO { + AlignmentRequirement: ULONG, +}} +STRUCT!{struct FILE_ID_INFO { + VolumeSerialNumber: ULONGLONG, + FileId: FILE_ID_128, +}} +extern "system" { + pub fn CompareFileTime( + lpFileTime1: *const FILETIME, + lpFileTime2: *const FILETIME, + ) -> LONG; + pub fn CreateDirectoryA( + lpPathName: LPCSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> BOOL; + pub fn CreateDirectoryW( + lpPathName: LPCWSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> BOOL; + pub fn CreateFileA( + lpFileName: LPCSTR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, + hTemplateFile: HANDLE, + ) -> HANDLE; + pub fn CreateFileW( + lpFileName: LPCWSTR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, + hTemplateFile: HANDLE, + ) -> HANDLE; + pub fn DefineDosDeviceW( + dwFlags: DWORD, + lpDeviceName: LPCWSTR, + lpTargetPath: LPCWSTR, + ) -> BOOL; + pub fn DeleteFileA( + lpFileName: LPCSTR, + ) -> BOOL; + pub fn DeleteFileW( + lpFileName: LPCWSTR, + ) -> BOOL; + pub fn DeleteVolumeMountPointW( + lpszVolumeMountPoint: LPCWSTR, + ) -> BOOL; + pub fn FileTimeToLocalFileTime( + lpFileTime: *const FILETIME, + lpLocalFileTime: LPFILETIME, + ) -> BOOL; + pub fn FindClose( + hFindFile: HANDLE, + ) -> BOOL; + pub fn FindCloseChangeNotification( + hChangeHandle: HANDLE, + ) -> BOOL; + pub fn FindFirstChangeNotificationA( + lpPathName: LPCSTR, + bWatchSubtree: BOOL, + dwNotifyFilter: DWORD, + ) -> HANDLE; + pub fn FindFirstChangeNotificationW( + lpPathName: LPCWSTR, + bWatchSubtree: BOOL, + dwNotifyFilter: DWORD, + ) -> HANDLE; + pub fn FindFirstFileA( + lpFileName: LPCSTR, + lpFindFileData: LPWIN32_FIND_DATAA, + ) -> HANDLE; + pub fn FindFirstFileW( + lpFileName: LPCWSTR, + lpFindFileData: LPWIN32_FIND_DATAW, + ) -> HANDLE; + pub fn FindFirstFileExA( + lpFileName: LPCSTR, + fInfoLevelId: FINDEX_INFO_LEVELS, + lpFindFileData: LPVOID, + fSearchOp: FINDEX_SEARCH_OPS, + lpSearchFilter: LPVOID, + dwAdditionalFlags: DWORD, + ) -> HANDLE; + pub fn FindFirstFileExW( + lpFileName: LPCWSTR, + fInfoLevelId: FINDEX_INFO_LEVELS, + lpFindFileData: LPVOID, + fSearchOp: FINDEX_SEARCH_OPS, + lpSearchFilter: LPVOID, + dwAdditionalFlags: DWORD, + ) -> HANDLE; + pub fn FindFirstVolumeW( + lpszVolumeName: LPWSTR, + cchBufferLength: DWORD, + ) -> HANDLE; + pub fn FindNextChangeNotification( + hChangeHandle: HANDLE, + ) -> BOOL; + pub fn FindNextFileA( + hFindFile: HANDLE, + lpFindFileData: LPWIN32_FIND_DATAA, + ) -> BOOL; + pub fn FindNextFileW( + hFindFile: HANDLE, + lpFindFileData: LPWIN32_FIND_DATAW, + ) -> BOOL; + pub fn FindNextVolumeW( + hFindVolume: HANDLE, + lpszVolumeName: LPWSTR, + cchBufferLength: DWORD, + ) -> BOOL; + pub fn FindVolumeClose( + hFindVolume: HANDLE, + ) -> BOOL; + pub fn FlushFileBuffers( + hFile: HANDLE, + ) -> BOOL; + pub fn GetDiskFreeSpaceA( + lpRootPathName: LPCSTR, + lpSectorsPerCluster: LPDWORD, + lpBytesPerSector: LPDWORD, + lpNumberOfFreeClusters: LPDWORD, + lpTotalNumberOfClusters: LPDWORD, + ) -> BOOL; + pub fn GetDiskFreeSpaceW( + lpRootPathName: LPCWSTR, + lpSectorsPerCluster: LPDWORD, + lpBytesPerSector: LPDWORD, + lpNumberOfFreeClusters: LPDWORD, + lpTotalNumberOfClusters: LPDWORD, + ) -> BOOL; + pub fn GetDiskFreeSpaceExA( + lpDirectoryName: LPCSTR, + lpFreeBytesAvailableToCaller: PULARGE_INTEGER, + lpTotalNumberOfBytes: PULARGE_INTEGER, + lpTotalNumberOfFreeBytes: PULARGE_INTEGER, + ) -> BOOL; + pub fn GetDiskFreeSpaceExW( + lpDirectoryName: LPCWSTR, + lpFreeBytesAvailableToCaller: PULARGE_INTEGER, + lpTotalNumberOfBytes: PULARGE_INTEGER, + lpTotalNumberOfFreeBytes: PULARGE_INTEGER, + ) -> BOOL; + pub fn GetDriveTypeA( + lpRootPathName: LPCSTR, + ) -> UINT; + pub fn GetDriveTypeW( + lpRootPathName: LPCWSTR, + ) -> UINT; + pub fn GetFileAttributesA( + lpFileName: LPCSTR, + ) -> DWORD; + pub fn GetFileAttributesW( + lpFileName: LPCWSTR, + ) -> DWORD; + pub fn GetFileAttributesExA( + lpFileName: LPCSTR, + fInfoLevelId: GET_FILEEX_INFO_LEVELS, + lpFileInformation: LPVOID, + ) -> BOOL; + pub fn GetFileAttributesExW( + lpFileName: LPCWSTR, + fInfoLevelId: GET_FILEEX_INFO_LEVELS, + lpFileInformation: LPVOID, + ) -> BOOL; + pub fn GetFileInformationByHandle( + hFile: HANDLE, + lpFileInformation: LPBY_HANDLE_FILE_INFORMATION, + ) -> BOOL; + pub fn GetFileSize( + hFile: HANDLE, + lpFileSizeHigh: LPDWORD, + ) -> DWORD; + pub fn GetFileSizeEx( + hFile: HANDLE, + lpFileSize: PLARGE_INTEGER, + ) -> BOOL; + pub fn GetFileType( + hFile: HANDLE, + ) -> DWORD; + pub fn GetFinalPathNameByHandleA( + hFile: HANDLE, + lpszFilePath: LPSTR, + cchFilePath: DWORD, + dwFlags: DWORD, + ) -> DWORD; + pub fn GetFinalPathNameByHandleW( + hFile: HANDLE, + lpszFilePath: LPWSTR, + cchFilePath: DWORD, + dwFlags: DWORD, + ) -> DWORD; + pub fn GetFileTime( + hFile: HANDLE, + lpCreationTime: LPFILETIME, + lpLastAccessTime: LPFILETIME, + lpLastWriteTime: LPFILETIME, + ) -> BOOL; + pub fn GetFullPathNameW( + lpFileName: LPCWSTR, + nBufferLength: DWORD, + lpBuffer: LPWSTR, + lpFilePart: *mut LPWSTR, + ) -> DWORD; + pub fn GetFullPathNameA( + lpFileName: LPCSTR, + nBufferLength: DWORD, + lpBuffer: LPSTR, + lpFilePart: *mut LPSTR, + ) -> DWORD; + pub fn GetLogicalDrives() -> DWORD; + pub fn GetLogicalDriveStringsW( + nBufferLength: DWORD, + lpBuffer: LPWSTR, + ) -> DWORD; + pub fn GetLongPathNameA( + lpszShortPath: LPCSTR, + lpszLongPath: LPSTR, + cchBuffer: DWORD, + ) -> DWORD; + pub fn GetLongPathNameW( + lpszShortPath: LPCWSTR, + lpszLongPath: LPWSTR, + cchBuffer: DWORD, + ) -> DWORD; + pub fn GetShortPathNameW( + lpszLongPath: LPCWSTR, + lpszShortPath: LPWSTR, + cchBuffer: DWORD, + ) -> DWORD; + pub fn GetTempFileNameW( + lpPathName: LPCWSTR, + lpPrefixString: LPCWSTR, + uUnique: UINT, + lpTempFileName: LPWSTR, + ) -> UINT; + pub fn GetVolumeInformationByHandleW( + hFile: HANDLE, + lpVolumeNameBuffer: LPWSTR, + nVolumeNameSize: DWORD, + lpVolumeSerialNumber: LPDWORD, + lpMaximumComponentLength: LPDWORD, + lpFileSystemFlags: LPDWORD, + lpFileSystemNameBuffer: LPWSTR, + nFileSystemNameSize: DWORD, + ) -> BOOL; + pub fn GetVolumeInformationW( + lpRootPathName: LPCWSTR, + lpVolumeNameBuffer: LPWSTR, + nVolumeNameSize: DWORD, + lpVolumeSerialNumber: LPDWORD, + lpMaximumComponentLength: LPDWORD, + lpFileSystemFlags: LPDWORD, + lpFileSystemNameBuffer: LPWSTR, + nFileSystemNameSize: DWORD, + ) -> BOOL; + pub fn GetVolumePathNameW( + lpszFileName: LPCWSTR, + lpszVolumePathName: LPWSTR, + cchBufferLength: DWORD, + ) -> BOOL; + pub fn LocalFileTimeToFileTime( + lpLocalFileTime: *const FILETIME, + lpFileTime: LPFILETIME, + ) -> BOOL; + pub fn LockFile( + hFile: HANDLE, + dwFileOffsetLow: DWORD, + dwFileOffsetHigh: DWORD, + nNumberOfBytesToLockLow: DWORD, + nNumberOfBytesToLockHigh: DWORD, + ) -> BOOL; + pub fn LockFileEx( + hFile: HANDLE, + dwFlags: DWORD, + dwReserved: DWORD, + nNumberOfBytesToLockLow: DWORD, + nNumberOfBytesToLockHigh: DWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn QueryDosDeviceW( + lpDeviceName: LPCWSTR, + lpTargetPath: LPWSTR, + ucchMax: DWORD, + ) -> DWORD; + pub fn ReadFile( + hFile: HANDLE, + lpBuffer: LPVOID, + nNumberOfBytesToRead: DWORD, + lpNumberOfBytesRead: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn ReadFileEx( + hFile: HANDLE, + lpBuffer: LPVOID, + nNumberOfBytesToRead: DWORD, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, + ) -> BOOL; + pub fn ReadFileScatter( + hFile: HANDLE, + aSegmentArray: *mut FILE_SEGMENT_ELEMENT, + nNumberOfBytesToRead: DWORD, + lpReserved: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn RemoveDirectoryA( + lpPathName: LPCSTR, + ) -> BOOL; + pub fn RemoveDirectoryW( + lpPathName: LPCWSTR, + ) -> BOOL; + pub fn SetEndOfFile( + hFile: HANDLE, + ) -> BOOL; + pub fn SetFileAttributesA( + lpFileName: LPCSTR, + dwFileAttributes: DWORD, + ) -> BOOL; + pub fn SetFileAttributesW( + lpFileName: LPCWSTR, + dwFileAttributes: DWORD, + ) -> BOOL; + pub fn SetFileInformationByHandle( + hFile: HANDLE, + FileInformationClass: FILE_INFO_BY_HANDLE_CLASS, + lpFileInformation: LPVOID, + dwBufferSize: DWORD, + ) -> BOOL; + pub fn SetFilePointer( + hFile: HANDLE, + lDistanceToMove: LONG, + lpDistanceToMoveHigh: PLONG, + dwMoveMethod: DWORD, + ) -> DWORD; + pub fn SetFilePointerEx( + hFile: HANDLE, + liDistanceToMove: LARGE_INTEGER, + lpNewFilePointer: PLARGE_INTEGER, + dwMoveMethod: DWORD, + ) -> BOOL; + pub fn SetFileTime( + hFile: HANDLE, + lpCreationTime: *const FILETIME, + lpLastAccessTime: *const FILETIME, + lpLastWriteTime: *const FILETIME, + ) -> BOOL; + pub fn SetFileValidData( + hFile: HANDLE, + ValidDataLength: LONGLONG, + ) -> BOOL; + pub fn UnlockFile( + hFile: HANDLE, + dwFileOffsetLow: DWORD, + dwFileOffsetHigh: DWORD, + nNumberOfBytesToUnlockLow: DWORD, + nNumberOfBytesToUnlockHigh: DWORD, + ) -> BOOL; + pub fn UnlockFileEx( + hFile: HANDLE, + dwReserved: DWORD, + nNumberOfBytesToUnlockLow: DWORD, + nNumberOfBytesToUnlockHigh: DWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn WriteFile( + hFile: HANDLE, + lpBuffer: LPCVOID, + nNumberOfBytesToWrite: DWORD, + lpNumberOfBytesWritten: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn WriteFileEx( + hFile: HANDLE, + lpBuffer: LPCVOID, + nNumberOfBytesToWrite: DWORD, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, + ) -> BOOL; + pub fn WriteFileGather( + hFile: HANDLE, + aSegmentArray: *mut FILE_SEGMENT_ELEMENT, + nNumberOfBytesToWrite: DWORD, + lpReserved: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn GetTempPathW( + nBufferLength: DWORD, + lpBuffer: LPWSTR, + ) -> DWORD; + pub fn GetVolumeNameForVolumeMountPointW( + lpszVolumeMountPoint: LPCWSTR, + lpszVolumeName: LPWSTR, + cchBufferLength: DWORD, + ) -> BOOL; + pub fn GetVolumePathNamesForVolumeNameW( + lpszVolumeName: LPCWSTR, + lpszVolumePathNames: LPWCH, + cchBufferLength: DWORD, + lpcchReturnLength: PDWORD, + ) -> BOOL; + pub fn CreateFile2( + lpFileName: LPCWSTR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + dwCreationDisposition: DWORD, + pCreateExParams: LPCREATEFILE2_EXTENDED_PARAMETERS, + ) -> HANDLE; + pub fn SetFileIoOverlappedRange( + FileHandle: HANDLE, + OverlappedRangeStart: PUCHAR, + Length: ULONG, + ) -> BOOL; + pub fn GetCompressedFileSizeA( + lpFileName: LPCSTR, + lpFileSizeHigh: LPDWORD, + ) -> DWORD; + pub fn GetCompressedFileSizeW( + lpFileName: LPCWSTR, + lpFileSizeHigh: LPDWORD, + ) -> DWORD; +} +ENUM!{enum STREAM_INFO_LEVELS { + FindStreamInfoStandard, + FindStreamInfoMaxInfoLevel, +}} +extern "system" { + pub fn FindFirstStreamW( + lpFileName: LPCWSTR, + InfoLevel: STREAM_INFO_LEVELS, + lpFindStreamData: LPVOID, + dwFlags: DWORD, + ) -> HANDLE; + pub fn FindNextStreamW( + hFindStream: HANDLE, + lpFindStreamData: LPVOID, + ) -> BOOL; + pub fn AreFileApisANSI() -> BOOL; + pub fn GetTempPathA( + nBufferLength: DWORD, + lpBuffer: LPSTR, + ) -> DWORD; + pub fn FindFirstFileNameW( + lpFileName: LPCWSTR, + dwFlags: DWORD, + StringLength: LPDWORD, + LinkName: PWSTR, + ) -> HANDLE; + pub fn FindNextFileNameW( + hFindStream: HANDLE, + StringLength: LPDWORD, + LinkName: PWSTR, + ) -> BOOL; + pub fn GetVolumeInformationA( + lpRootPathName: LPCSTR, + lpVolumeNameBuffer: LPSTR, + nVolumeNameSize: DWORD, + lpVolumeSerialNumber: LPDWORD, + lpMaximumComponentLength: LPDWORD, + lpFileSystemFlags: LPDWORD, + lpFileSystemNameBuffer: LPSTR, + nFileSystemNameSize: DWORD, + ) -> BOOL; + pub fn GetTempFileNameA( + lpPathName: LPCSTR, + lpPrefixString: LPCSTR, + uUnique: UINT, + lpTempFileName: LPSTR, + ) -> UINT; + pub fn SetFileApisToOEM(); + pub fn SetFileApisToANSI(); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/functiondiscoverykeys_devpkey.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/functiondiscoverykeys_devpkey.rs new file mode 100644 index 0000000..0455475 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/functiondiscoverykeys_devpkey.rs @@ -0,0 +1,117 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::wtypes::PROPERTYKEY; +//52 +DEFINE_PROPERTYKEY!{PKEY_Device_DeviceDesc, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 2} +DEFINE_PROPERTYKEY!{PKEY_Device_HardwareIds, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 3} +DEFINE_PROPERTYKEY!{PKEY_Device_CompatibleIds, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 4} +DEFINE_PROPERTYKEY!{PKEY_Device_Service, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 6} +DEFINE_PROPERTYKEY!{PKEY_Device_Class, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 9} +DEFINE_PROPERTYKEY!{PKEY_Device_ClassGuid, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 10} +DEFINE_PROPERTYKEY!{PKEY_Device_Driver, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 11} +DEFINE_PROPERTYKEY!{PKEY_Device_ConfigFlags, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 12} +DEFINE_PROPERTYKEY!{PKEY_Device_Manufacturer, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 13} +DEFINE_PROPERTYKEY!{PKEY_Device_FriendlyName, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14} +DEFINE_PROPERTYKEY!{PKEY_Device_LocationInfo, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 15} +DEFINE_PROPERTYKEY!{PKEY_Device_PDOName, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 16} +DEFINE_PROPERTYKEY!{PKEY_Device_Capabilities, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 17} +DEFINE_PROPERTYKEY!{PKEY_Device_UINumber, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 18} +DEFINE_PROPERTYKEY!{PKEY_Device_UpperFilters, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 19} +DEFINE_PROPERTYKEY!{PKEY_Device_LowerFilters, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 20} +DEFINE_PROPERTYKEY!{PKEY_Device_BusTypeGuid, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 21} +DEFINE_PROPERTYKEY!{PKEY_Device_LegacyBusType, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 22} +DEFINE_PROPERTYKEY!{PKEY_Device_BusNumber, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 23} +DEFINE_PROPERTYKEY!{PKEY_Device_EnumeratorName, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 24} +DEFINE_PROPERTYKEY!{PKEY_Device_Security, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 25} +DEFINE_PROPERTYKEY!{PKEY_Device_SecuritySDS, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 26} +DEFINE_PROPERTYKEY!{PKEY_Device_DevType, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 27} +DEFINE_PROPERTYKEY!{PKEY_Device_Exclusive, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 28} +DEFINE_PROPERTYKEY!{PKEY_Device_Characteristics, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 29} +DEFINE_PROPERTYKEY!{PKEY_Device_Address, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 30} +DEFINE_PROPERTYKEY!{PKEY_Device_UINumberDescFormat, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 31} +DEFINE_PROPERTYKEY!{PKEY_Device_PowerData, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 32} +DEFINE_PROPERTYKEY!{PKEY_Device_RemovalPolicy, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 33} +DEFINE_PROPERTYKEY!{PKEY_Device_RemovalPolicyDefault, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 34} +DEFINE_PROPERTYKEY!{PKEY_Device_RemovalPolicyOverride, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 35} +DEFINE_PROPERTYKEY!{PKEY_Device_InstallState, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 36} +DEFINE_PROPERTYKEY!{PKEY_Device_LocationPaths, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 37} +DEFINE_PROPERTYKEY!{PKEY_Device_BaseContainerId, + 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 38} +//137 +DEFINE_PROPERTYKEY!{PKEY_Device_DriverDate, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 2} +DEFINE_PROPERTYKEY!{PKEY_Device_DriverVersion, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 3} +DEFINE_PROPERTYKEY!{PKEY_Device_DriverDesc, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 4} +DEFINE_PROPERTYKEY!{PKEY_Device_DriverInfPath, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 5} +DEFINE_PROPERTYKEY!{PKEY_Device_DriverInfSection, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 6} +DEFINE_PROPERTYKEY!{PKEY_Device_DriverInfSectionExt, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 7} +DEFINE_PROPERTYKEY!{PKEY_Device_MatchingDeviceId, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 8} +DEFINE_PROPERTYKEY!{PKEY_Device_DriverProvider, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 9} +DEFINE_PROPERTYKEY!{PKEY_Device_DriverPropPageProvider, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 10} +DEFINE_PROPERTYKEY!{PKEY_Device_DriverCoInstallers, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 11} +DEFINE_PROPERTYKEY!{PKEY_Device_ResourcePickerTags, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 12} +DEFINE_PROPERTYKEY!{PKEY_Device_ResourcePickerExceptions, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 13} +DEFINE_PROPERTYKEY!{PKEY_Device_DriverRank, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 14} +DEFINE_PROPERTYKEY!{PKEY_Device_DriverLogoLevel, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 15} +DEFINE_PROPERTYKEY!{PKEY_Device_NoConnectSound, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 17} +DEFINE_PROPERTYKEY!{PKEY_Device_GenericDriverInstalled, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 18} +DEFINE_PROPERTYKEY!{PKEY_Device_AdditionalSoftwareRequested, + 0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 19} +//209 +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_FriendlyName, + 0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22, 2} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Enabled, + 0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22, 3} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_ClassGuid, + 0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22, 4} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/gl/gl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/gl/gl.rs new file mode 100644 index 0000000..d7c1b58 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/gl/gl.rs @@ -0,0 +1,52 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_double, c_float, c_int, c_schar, c_short, c_uchar, c_uint, c_ushort, c_void}; +//48 +pub type GLenum = c_uint; +pub type GLboolean = c_uchar; +pub type GLbitfield = c_uint; +pub type GLbyte = c_schar; +pub type GLshort = c_short; +pub type GLint = c_int; +pub type GLsizei = c_int; +pub type GLubyte = c_uchar; +pub type GLushort = c_ushort; +pub type GLuint = c_uint; +pub type GLfloat = c_float; +pub type GLclampf = c_float; +pub type GLdouble = c_double; +pub type GLclampd = c_double; +pub type GLvoid = c_void; +//63 +//68 +//AccumOp +pub const GL_ACCUM: GLenum = 0x0100; +pub const GL_LOAD: GLenum = 0x0101; +pub const GL_RETURN: GLenum = 0x0102; +pub const GL_MULT: GLenum = 0x0103; +pub const GL_ADD: GLenum = 0x0104; +//AlphaFunction +pub const GL_NEVER: GLenum = 0x0200; +pub const GL_LESS: GLenum = 0x0201; +pub const GL_EQUAL: GLenum = 0x0202; +pub const GL_LEQUAL: GLenum = 0x0203; +pub const GL_GREATER: GLenum = 0x0204; +pub const GL_NOTEQUAL: GLenum = 0x0205; +pub const GL_GEQUAL: GLenum = 0x0206; +pub const GL_ALWAYS: GLenum = 0x0207; +// TODO: we're missing about 1500 lines of defines and methods +// until that time, you can use the excellent GL crate +// https://github.com/brendanzab/gl-rs +extern "system" { + pub fn glAccum( + op: GLenum, + value: GLfloat, + ); + pub fn glAlphaFunc( + func: GLenum, + reference: GLclampf, + ); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/gl/mod.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/gl/mod.rs new file mode 100644 index 0000000..6ce6d06 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/gl/mod.rs @@ -0,0 +1,7 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Headers for user mode only +#[cfg(feature = "gl-gl")] pub mod gl; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/handleapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/handleapi.rs new file mode 100644 index 0000000..1d7e43d --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/handleapi.rs @@ -0,0 +1,36 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! handleapi include file +use shared::minwindef::{BOOL, DWORD, LPDWORD, LPHANDLE}; +use um::winnt::HANDLE; +pub const INVALID_HANDLE_VALUE: HANDLE = -1isize as HANDLE; +extern "system" { + pub fn CloseHandle( + hObject: HANDLE, + ) -> BOOL; + pub fn DuplicateHandle( + hSourceProcessHandle: HANDLE, + hSourceHandle: HANDLE, + hTargetProcessHandle: HANDLE, + lpTargetHandle: LPHANDLE, + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwOptions: DWORD, + ) -> BOOL; + pub fn CompareObjectHandles( + hFirstObjectHandle: HANDLE, + hSecondObjectHandle: HANDLE, + ) -> BOOL; + pub fn GetHandleInformation( + hObject: HANDLE, + lpdwFlags: LPDWORD, + ) -> BOOL; + pub fn SetHandleInformation( + hObject: HANDLE, + dwMask: DWORD, + dwFlags: DWORD, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/heapapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/heapapi.rs new file mode 100644 index 0000000..83073b3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/heapapi.rs @@ -0,0 +1,92 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-core-heap-l1 +use shared::basetsd::{PSIZE_T, SIZE_T}; +use shared::minwindef::{BOOL, DWORD, LPCVOID, LPVOID}; +use um::minwinbase::LPPROCESS_HEAP_ENTRY; +use um::winnt::{HANDLE, HEAP_INFORMATION_CLASS, PHANDLE, PVOID}; +STRUCT!{struct HEAP_SUMMARY { + cb: DWORD, + cbAllocated: SIZE_T, + cbCommitted: SIZE_T, + cbReserved: SIZE_T, + cbMaxReserve: SIZE_T, +}} +pub type PHEAP_SUMMARY = *mut HEAP_SUMMARY; +pub type LPHEAP_SUMMARY = PHEAP_SUMMARY; +extern "system" { + pub fn HeapCreate( + flOptions: DWORD, + dwInitialSize: SIZE_T, + dwMaximumSize: SIZE_T, + ) -> HANDLE; + pub fn HeapDestroy( + hHeap: HANDLE, + ) -> BOOL; + pub fn HeapAlloc( + hHeap: HANDLE, + dwFlags: DWORD, + dwBytes: SIZE_T, + ) -> LPVOID; + pub fn HeapReAlloc( + hHeap: HANDLE, + dwFlags: DWORD, + lpMem: LPVOID, + dwBytes: SIZE_T, + ) -> LPVOID; + pub fn HeapFree( + hHeap: HANDLE, + dwFlags: DWORD, + lpMem: LPVOID, + ) -> BOOL; + pub fn HeapSize( + hHeap: HANDLE, + dwFlags: DWORD, + lpMem: LPCVOID, + ) -> SIZE_T; + pub fn GetProcessHeap() -> HANDLE; + pub fn HeapCompact( + hHeap: HANDLE, + dwFlags: DWORD, + ) -> SIZE_T; + pub fn HeapSetInformation( + HeapHandle: HANDLE, + HeapInformationClass: HEAP_INFORMATION_CLASS, + HeapInformation: PVOID, + HeapInformationLength: SIZE_T, + ) -> BOOL; + pub fn HeapValidate( + hHeap: HANDLE, + dwFlags: DWORD, + lpMem: LPCVOID, + ) -> BOOL; + pub fn HeapSummary( + hHeap: HANDLE, + dwFlags: DWORD, + lpSummary: LPHEAP_SUMMARY, + ) -> BOOL; + pub fn GetProcessHeaps( + NumberOfHeaps: DWORD, + ProcessHeaps: PHANDLE, + ) -> DWORD; + pub fn HeapLock( + hHeap: HANDLE, + ) -> BOOL; + pub fn HeapUnlock( + hHeap: HANDLE, + ) -> BOOL; + pub fn HeapWalk( + hHeap: HANDLE, + lpEntry: LPPROCESS_HEAP_ENTRY, + ) -> BOOL; + pub fn HeapQueryInformation( + HeapHandle: HANDLE, + HeapInformationClass: HEAP_INFORMATION_CLASS, + HeapInformation: PVOID, + HeapInformationLength: SIZE_T, + ReturnLength: PSIZE_T, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/highlevelmonitorconfigurationapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/highlevelmonitorconfigurationapi.rs new file mode 100644 index 0000000..f187aeb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/highlevelmonitorconfigurationapi.rs @@ -0,0 +1,171 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{DWORD, LPDWORD}; +use um::physicalmonitorenumerationapi::_BOOL; +use um::winnt::HANDLE; +pub const MC_CAPS_NONE: DWORD = 0x00000000; +pub const MC_CAPS_MONITOR_TECHNOLOGY_TYPE: DWORD = 0x00000001; +pub const MC_CAPS_BRIGHTNESS: DWORD = 0x00000002; +pub const MC_CAPS_CONTRAST: DWORD = 0x00000004; +pub const MC_CAPS_COLOR_TEMPERATURE: DWORD = 0x00000008; +pub const MC_CAPS_RED_GREEN_BLUE_GAIN: DWORD = 0x00000010; +pub const MC_CAPS_RED_GREEN_BLUE_DRIVE: DWORD = 0x00000020; +pub const MC_CAPS_DEGAUSS: DWORD = 0x00000040; +pub const MC_CAPS_DISPLAY_AREA_POSITION: DWORD = 0x00000080; +pub const MC_CAPS_DISPLAY_AREA_SIZE: DWORD = 0x00000100; +pub const MC_CAPS_RESTORE_FACTORY_DEFAULTS: DWORD = 0x00000400; +pub const MC_CAPS_RESTORE_FACTORY_COLOR_DEFAULTS: DWORD = 0x00000800; +pub const MC_RESTORE_FACTORY_DEFAULTS_ENABLES_MONITOR_SETTINGS: DWORD = 0x00001000; +pub const MC_SUPPORTED_COLOR_TEMPERATURE_NONE: DWORD = 0x00000000; +pub const MC_SUPPORTED_COLOR_TEMPERATURE_4000K: DWORD = 0x00000001; +pub const MC_SUPPORTED_COLOR_TEMPERATURE_5000K: DWORD = 0x00000002; +pub const MC_SUPPORTED_COLOR_TEMPERATURE_6500K: DWORD = 0x00000004; +pub const MC_SUPPORTED_COLOR_TEMPERATURE_7500K: DWORD = 0x00000008; +pub const MC_SUPPORTED_COLOR_TEMPERATURE_8200K: DWORD = 0x00000010; +pub const MC_SUPPORTED_COLOR_TEMPERATURE_9300K: DWORD = 0x00000020; +pub const MC_SUPPORTED_COLOR_TEMPERATURE_10000K: DWORD = 0x00000040; +pub const MC_SUPPORTED_COLOR_TEMPERATURE_11500K: DWORD = 0x00000080; +ENUM!{enum MC_DISPLAY_TECHNOLOGY_TYPE { + MC_SHADOW_MASK_CATHODE_RAY_TUBE, + MC_APERTURE_GRILL_CATHODE_RAY_TUBE, + MC_THIN_FILM_TRANSISTOR, + MC_LIQUID_CRYSTAL_ON_SILICON, + MC_PLASMA, + MC_ORGANIC_LIGHT_EMITTING_DIODE, + MC_ELECTROLUMINESCENT, + MC_MICROELECTROMECHANICAL, + MC_FIELD_EMISSION_DEVICE, +}} +pub type LPMC_DISPLAY_TECHNOLOGY_TYPE = *mut MC_DISPLAY_TECHNOLOGY_TYPE; +ENUM!{enum MC_DRIVE_TYPE { + MC_RED_DRIVE, + MC_GREEN_DRIVE, + MC_BLUE_DRIVE, +}} +ENUM!{enum MC_GAIN_TYPE { + MC_RED_GAIN, + MC_GREEN_GAIN, + MC_BLUE_GAIN, +}} +ENUM!{enum MC_POSITION_TYPE { + MC_HORIZONTAL_POSITION, + MC_VERTICAL_POSITION, +}} +ENUM!{enum MC_SIZE_TYPE { + MC_WIDTH, + MC_HEIGHT, +}} +ENUM!{enum MC_COLOR_TEMPERATURE { + MC_COLOR_TEMPERATURE_UNKNOWN, + MC_COLOR_TEMPERATURE_4000K, + MC_COLOR_TEMPERATURE_5000K, + MC_COLOR_TEMPERATURE_6500K, + MC_COLOR_TEMPERATURE_7500K, + MC_COLOR_TEMPERATURE_8200K, + MC_COLOR_TEMPERATURE_9300K, + MC_COLOR_TEMPERATURE_10000K, + MC_COLOR_TEMPERATURE_11500K, +}} +pub type LPMC_COLOR_TEMPERATURE = *mut MC_COLOR_TEMPERATURE; +extern "system" { + pub fn GetMonitorCapabilities( + hMonitor: HANDLE, + pdwMonitorCapabilities: LPDWORD, + pdwSupportedColorTemperature: LPDWORD, + ) -> _BOOL; + pub fn SaveCurrentMonitorSettings( + hMonitor: HANDLE, + ) -> _BOOL; + pub fn GetMonitorTechnologyType( + hMonitor: HANDLE, + pdtyDisplayTechnologyType: LPMC_DISPLAY_TECHNOLOGY_TYPE, + ) -> _BOOL; + pub fn GetMonitorBrightness( + hMonitor: HANDLE, + pdwMinimumBrightness: LPDWORD, + pdwCurrentBrightness: LPDWORD, + pdwMaximumBrightness: LPDWORD, + ) -> _BOOL; + pub fn GetMonitorContrast( + hMonitor: HANDLE, + pdwMinimumContrast: LPDWORD, + pdwCurrentContrast: LPDWORD, + pdwMaximumContrast: LPDWORD, + ) -> _BOOL; + pub fn GetMonitorColorTemperature( + hMonitor: HANDLE, + pctCurrentColorTemperature: LPMC_COLOR_TEMPERATURE, + ) -> _BOOL; + pub fn GetMonitorRedGreenOrBlueDrive( + hMonitor: HANDLE, + dtDriveType: MC_DRIVE_TYPE, + pdwMinimumDrive: LPDWORD, + pdwCurrentDrive: LPDWORD, + pdwMaximumDrive: LPDWORD, + ) -> _BOOL; + pub fn GetMonitorRedGreenOrBlueGain( + hMonitor: HANDLE, + gtGainType: MC_GAIN_TYPE, + pdwMinimumGain: LPDWORD, + pdwCurrentGain: LPDWORD, + pdwMaximumGain: LPDWORD, + ) -> _BOOL; + pub fn SetMonitorBrightness( + hMonitor: HANDLE, + dwNewBrightness: DWORD, + ) -> _BOOL; + pub fn SetMonitorContrast( + hMonitor: HANDLE, + dwNewContrast: DWORD, + ) -> _BOOL; + pub fn SetMonitorColorTemperature( + hMonitor: HANDLE, + ctCurrentColorTemperature: MC_COLOR_TEMPERATURE, + ) -> _BOOL; + pub fn SetMonitorRedGreenOrBlueDrive( + hMonitor: HANDLE, + dtDriveType: MC_DRIVE_TYPE, + dwNewDrive: DWORD, + ) -> _BOOL; + pub fn SetMonitorRedGreenOrBlueGain( + hMonitor: HANDLE, + gtGainType: MC_GAIN_TYPE, + dwNewGain: DWORD, + ) -> _BOOL; + pub fn DegaussMonitor( + hMonitor: HANDLE, + ) -> _BOOL; + pub fn GetMonitorDisplayAreaSize( + hMonitor: HANDLE, + stSizeType: MC_SIZE_TYPE, + pdwMinimumWidthOrHeight: LPDWORD, + pdwCurrentWidthOrHeight: LPDWORD, + pdwMaximumWidthOrHeight: LPDWORD, + ) -> _BOOL; + pub fn GetMonitorDisplayAreaPosition( + hMonitor: HANDLE, + ptPositionType: MC_POSITION_TYPE, + pdwMinimumPosition: LPDWORD, + pdwCurrentPosition: LPDWORD, + pdwMaximumPosition: LPDWORD, + ) -> _BOOL; + pub fn SetMonitorDisplayAreaSize( + hMonitor: HANDLE, + stSizeType: MC_SIZE_TYPE, + dwNewDisplayAreaWidthOrHeight: DWORD, + ) -> _BOOL; + pub fn SetMonitorDisplayAreaPosition( + hMonitor: HANDLE, + ptPositionType: MC_POSITION_TYPE, + dwNewPosition: DWORD, + ) -> _BOOL; + pub fn RestoreMonitorFactoryColorDefaults( + hMonitor: HANDLE, + ) -> _BOOL; + pub fn RestoreMonitorFactoryDefaults( + hMonitor: HANDLE, + ) -> _BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/http.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/http.rs new file mode 100644 index 0000000..38608d1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/http.rs @@ -0,0 +1,1072 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! HTTP API specification +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, PUCHAR, PULONG, UCHAR, ULONG, USHORT}; +use shared::sspi::SECURITY_STATUS; +use shared::ws2def::{PSOCKADDR, SOCKADDR_STORAGE}; +use um::minwinbase::{LPOVERLAPPED, PSECURITY_ATTRIBUTES}; +use um::winnt::{ + ANYSIZE_ARRAY, BOOLEAN, HANDLE, PCHAR, PCSTR, PCWSTR, PHANDLE, PSECURITY_DESCRIPTOR, PVOID, + PWCHAR, PWSTR, ULARGE_INTEGER, ULONGLONG, +}; +pub const HTTP_INITIALIZE_SERVER: ULONG = 0x00000001; +pub const HTTP_INITIALIZE_CONFIG: ULONG = 0x00000002; +pub const HTTP_DEMAND_CBT: ULONG = 0x00000004; +ENUM!{enum HTTP_SERVER_PROPERTY { + HttpServerAuthenticationProperty, + HttpServerLoggingProperty, + HttpServerQosProperty, + HttpServerTimeoutsProperty, + HttpServerQueueLengthProperty, + HttpServerStateProperty, + HttpServer503VerbosityProperty, + HttpServerBindingProperty, + HttpServerExtendedAuthenticationProperty, + HttpServerListenEndpointProperty, + HttpServerChannelBindProperty, + HttpServerProtectionLevelProperty, +}} +pub type PHTTP_SERVER_PROPERTY = *mut HTTP_SERVER_PROPERTY; +STRUCT!{struct HTTP_PROPERTY_FLAGS { + BitFields: ULONG, +}} +BITFIELD!{HTTP_PROPERTY_FLAGS BitFields: ULONG [ + Present set_Present[0..1], +]} +pub type PHTTP_PROPERTY_FLAGS = *mut HTTP_PROPERTY_FLAGS; +ENUM!{enum HTTP_ENABLED_STATE { + HttpEnabledStateActive, + HttpEnabledStateInactive, +}} +pub type PHTTP_ENABLED_STATE = *mut HTTP_ENABLED_STATE; +STRUCT!{struct HTTP_STATE_INFO { + Flags: HTTP_PROPERTY_FLAGS, + State: HTTP_ENABLED_STATE, +}} +pub type PHTTP_STATE_INFO = *mut HTTP_STATE_INFO; +ENUM!{enum HTTP_503_RESPONSE_VERBOSITY { + Http503ResponseVerbosityBasic, + Http503ResponseVerbosityLimited, + Http503ResponseVerbosityFull, +}} +pub type PHTTP_503_RESPONSE_VERBOSITY = *mut HTTP_503_RESPONSE_VERBOSITY; +ENUM!{enum HTTP_QOS_SETTING_TYPE { + HttpQosSettingTypeBandwidth, + HttpQosSettingTypeConnectionLimit, + HttpQosSettingTypeFlowRate, +}} +pub type PHTTP_QOS_SETTING_TYPE = *mut HTTP_QOS_SETTING_TYPE; +STRUCT!{struct HTTP_QOS_SETTING_INFO { + QosType: HTTP_QOS_SETTING_TYPE, + QosSetting: PVOID, +}} +pub type PHTTP_QOS_SETTING_INFO = *mut HTTP_QOS_SETTING_INFO; +STRUCT!{struct HTTP_CONNECTION_LIMIT_INFO { + Flags: HTTP_PROPERTY_FLAGS, + MaxConnections: ULONG, +}} +pub type PHTTP_CONNECTION_LIMIT_INFO = *mut HTTP_CONNECTION_LIMIT_INFO; +STRUCT!{struct HTTP_BANDWIDTH_LIMIT_INFO { + Flags: HTTP_PROPERTY_FLAGS, + MaxBandwidth: ULONG, +}} +pub type PHTTP_BANDWIDTH_LIMIT_INFO = *mut HTTP_BANDWIDTH_LIMIT_INFO; +STRUCT!{struct HTTP_FLOWRATE_INFO { + Flags: HTTP_PROPERTY_FLAGS, + MaxBandwidth: ULONG, + MaxPeakBandwidth: ULONG, + BurstSize: ULONG, +}} +pub type PHTTP_FLOWRATE_INFO = *mut HTTP_FLOWRATE_INFO; +pub const HTTP_MIN_ALLOWED_BANDWIDTH_THROTTLING_RATE: ULONG = 1024; +pub const HTTP_LIMIT_INFINITE: ULONG = !0; +ENUM!{enum HTTP_SERVICE_CONFIG_TIMEOUT_KEY { + IdleConnectionTimeout = 0, + HeaderWaitTimeout, +}} +pub type PHTTP_SERVICE_CONFIG_TIMEOUT_KEY = *mut HTTP_SERVICE_CONFIG_TIMEOUT_KEY; +pub type HTTP_SERVICE_CONFIG_TIMEOUT_PARAM = USHORT; +pub type PHTTP_SERVICE_CONFIG_TIMEOUT_PARAM = *mut USHORT; +STRUCT!{struct HTTP_SERVICE_CONFIG_TIMEOUT_SET { + KeyDesc: HTTP_SERVICE_CONFIG_TIMEOUT_KEY, + ParamDesc: HTTP_SERVICE_CONFIG_TIMEOUT_PARAM, +}} +pub type PHTTP_SERVICE_CONFIG_TIMEOUT_SET = *mut HTTP_SERVICE_CONFIG_TIMEOUT_SET; +STRUCT!{struct HTTP_TIMEOUT_LIMIT_INFO { + Flags: HTTP_PROPERTY_FLAGS, + EntityBody: USHORT, + DrainEntityBody: USHORT, + RequestQueue: USHORT, + IdleConnection: USHORT, + HeaderWait: USHORT, + MinSendRate: ULONG, +}} +pub type PHTTP_TIMEOUT_LIMIT_INFO = *mut HTTP_TIMEOUT_LIMIT_INFO; +STRUCT!{struct HTTP_LISTEN_ENDPOINT_INFO { + Flags: HTTP_PROPERTY_FLAGS, + EnableSharing: BOOLEAN, +}} +pub type PHTTP_LISTEN_ENDPOINT_INFO = *mut HTTP_LISTEN_ENDPOINT_INFO; +STRUCT!{struct HTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS { + DomainNameLength: USHORT, + DomainName: PWSTR, + RealmLength: USHORT, + Realm: PWSTR, +}} +pub type PHTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS = *mut HTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS; +STRUCT!{struct HTTP_SERVER_AUTHENTICATION_BASIC_PARAMS { + RealmLength: USHORT, + Realm: PWSTR, +}} +pub type PHTTP_SERVER_AUTHENTICATION_BASIC_PARAMS = *mut HTTP_SERVER_AUTHENTICATION_BASIC_PARAMS; +pub const HTTP_AUTH_ENABLE_BASIC: ULONG = 0x00000001; +pub const HTTP_AUTH_ENABLE_DIGEST: ULONG = 0x00000002; +pub const HTTP_AUTH_ENABLE_NTLM: ULONG = 0x00000004; +pub const HTTP_AUTH_ENABLE_NEGOTIATE: ULONG = 0x00000008; +pub const HTTP_AUTH_ENABLE_KERBEROS: ULONG = 0x00000010; +pub const HTTP_AUTH_ENABLE_ALL: ULONG = HTTP_AUTH_ENABLE_BASIC | HTTP_AUTH_ENABLE_DIGEST | + HTTP_AUTH_ENABLE_NTLM | HTTP_AUTH_ENABLE_NEGOTIATE | HTTP_AUTH_ENABLE_KERBEROS; +pub const HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING: UCHAR = 0x01; +pub const HTTP_AUTH_EX_FLAG_CAPTURE_CREDENTIAL: UCHAR = 0x02; +STRUCT!{struct HTTP_SERVER_AUTHENTICATION_INFO { + Flags: HTTP_PROPERTY_FLAGS, + AuthSchemes: ULONG, + ReceiveMutualAuth: BOOLEAN, + ReceiveContextHandle: BOOLEAN, + DisableNTLMCredentialCaching: BOOLEAN, + ExFlags: UCHAR, + DigestParams: HTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS, + BasicParams: HTTP_SERVER_AUTHENTICATION_BASIC_PARAMS, +}} +pub type PHTTP_SERVER_AUTHENTICATION_INFO = *mut HTTP_SERVER_AUTHENTICATION_INFO; +ENUM!{enum HTTP_SERVICE_BINDING_TYPE { + HttpServiceBindingTypeNone = 0, + HttpServiceBindingTypeW, + HttpServiceBindingTypeA, +}} +STRUCT!{struct HTTP_SERVICE_BINDING_BASE { + Type: HTTP_SERVICE_BINDING_TYPE, +}} +pub type PHTTP_SERVICE_BINDING_BASE = *mut HTTP_SERVICE_BINDING_BASE; +STRUCT!{struct HTTP_SERVICE_BINDING_A { + Base: HTTP_SERVICE_BINDING_BASE, + Buffer: PCHAR, + BufferSize: ULONG, +}} +pub type PHTTP_SERVICE_BINDING_A = *mut HTTP_SERVICE_BINDING_A; +STRUCT!{struct HTTP_SERVICE_BINDING_W { + Base: HTTP_SERVICE_BINDING_BASE, + Buffer: PWCHAR, + BufferSize: ULONG, +}} +pub type PHTTP_SERVICE_BINDING_W = *mut HTTP_SERVICE_BINDING_W; +ENUM!{enum HTTP_AUTHENTICATION_HARDENING_LEVELS { + HttpAuthenticationHardeningLegacy = 0, + HttpAuthenticationHardeningMedium, + HttpAuthenticationHardeningStrict, +}} +pub const HTTP_CHANNEL_BIND_PROXY: ULONG = 0x1; +pub const HTTP_CHANNEL_BIND_PROXY_COHOSTING: ULONG = 0x20; +pub const HTTP_CHANNEL_BIND_NO_SERVICE_NAME_CHECK: ULONG = 0x2; +pub const HTTP_CHANNEL_BIND_DOTLESS_SERVICE: ULONG = 0x4; +pub const HTTP_CHANNEL_BIND_SECURE_CHANNEL_TOKEN: ULONG = 0x8; +pub const HTTP_CHANNEL_BIND_CLIENT_SERVICE: ULONG = 0x10; +STRUCT!{struct HTTP_CHANNEL_BIND_INFO { + Hardening: HTTP_AUTHENTICATION_HARDENING_LEVELS, + Flags: ULONG, + ServiceNames: *mut PHTTP_SERVICE_BINDING_BASE, + NumberOfServiceNames: ULONG, +}} +pub type PHTTP_CHANNEL_BIND_INFO = *mut HTTP_CHANNEL_BIND_INFO; +STRUCT!{struct HTTP_REQUEST_CHANNEL_BIND_STATUS { + ServiceName: PHTTP_SERVICE_BINDING_BASE, + ChannelToken: PUCHAR, + ChannelTokenSize: ULONG, + Flags: ULONG, +}} +pub type PHTTP_REQUEST_CHANNEL_BIND_STATUS = *mut HTTP_REQUEST_CHANNEL_BIND_STATUS; +pub const HTTP_LOG_FIELD_DATE: ULONG = 0x00000001; +pub const HTTP_LOG_FIELD_TIME: ULONG = 0x00000002; +pub const HTTP_LOG_FIELD_CLIENT_IP: ULONG = 0x00000004; +pub const HTTP_LOG_FIELD_USER_NAME: ULONG = 0x00000008; +pub const HTTP_LOG_FIELD_SITE_NAME: ULONG = 0x00000010; +pub const HTTP_LOG_FIELD_COMPUTER_NAME: ULONG = 0x00000020; +pub const HTTP_LOG_FIELD_SERVER_IP: ULONG = 0x00000040; +pub const HTTP_LOG_FIELD_METHOD: ULONG = 0x00000080; +pub const HTTP_LOG_FIELD_URI_STEM: ULONG = 0x00000100; +pub const HTTP_LOG_FIELD_URI_QUERY: ULONG = 0x00000200; +pub const HTTP_LOG_FIELD_STATUS: ULONG = 0x00000400; +pub const HTTP_LOG_FIELD_WIN32_STATUS: ULONG = 0x00000800; +pub const HTTP_LOG_FIELD_BYTES_SENT: ULONG = 0x00001000; +pub const HTTP_LOG_FIELD_BYTES_RECV: ULONG = 0x00002000; +pub const HTTP_LOG_FIELD_TIME_TAKEN: ULONG = 0x00004000; +pub const HTTP_LOG_FIELD_SERVER_PORT: ULONG = 0x00008000; +pub const HTTP_LOG_FIELD_USER_AGENT: ULONG = 0x00010000; +pub const HTTP_LOG_FIELD_COOKIE: ULONG = 0x00020000; +pub const HTTP_LOG_FIELD_REFERER: ULONG = 0x00040000; +pub const HTTP_LOG_FIELD_VERSION: ULONG = 0x00080000; +pub const HTTP_LOG_FIELD_HOST: ULONG = 0x00100000; +pub const HTTP_LOG_FIELD_SUB_STATUS: ULONG = 0x00200000; +pub const HTTP_LOG_FIELD_CLIENT_PORT: ULONG = 0x00400000; +pub const HTTP_LOG_FIELD_URI: ULONG = 0x00800000; +pub const HTTP_LOG_FIELD_SITE_ID: ULONG = 0x01000000; +pub const HTTP_LOG_FIELD_REASON: ULONG = 0x02000000; +pub const HTTP_LOG_FIELD_QUEUE_NAME: ULONG = 0x04000000; +ENUM!{enum HTTP_LOGGING_TYPE { + HttpLoggingTypeW3C, + HttpLoggingTypeIIS, + HttpLoggingTypeNCSA, + HttpLoggingTypeRaw, +}} +ENUM!{enum HTTP_LOGGING_ROLLOVER_TYPE { + HttpLoggingRolloverSize, + HttpLoggingRolloverDaily, + HttpLoggingRolloverWeekly, + HttpLoggingRolloverMonthly, + HttpLoggingRolloverHourly, +}} +pub const HTTP_MIN_ALLOWED_LOG_FILE_ROLLOVER_SIZE: ULONG = 1 * 1024 * 1024; +pub const HTTP_LOGGING_FLAG_LOCAL_TIME_ROLLOVER: ULONG = 0x00000001; +pub const HTTP_LOGGING_FLAG_USE_UTF8_CONVERSION: ULONG = 0x00000002; +pub const HTTP_LOGGING_FLAG_LOG_ERRORS_ONLY: ULONG = 0x00000004; +pub const HTTP_LOGGING_FLAG_LOG_SUCCESS_ONLY: ULONG = 0x00000008; +STRUCT!{struct HTTP_LOGGING_INFO { + Flags: HTTP_PROPERTY_FLAGS, + LoggingFlags: ULONG, + SoftwareName: PCWSTR, + SoftwareNameLength: USHORT, + DirectoryNameLength: USHORT, + DirectoryName: PCWSTR, + Format: HTTP_LOGGING_TYPE, + Fields: ULONG, + pExtFields: PVOID, + NumOfExtFields: USHORT, + MaxRecordSize: USHORT, + RolloverType: HTTP_LOGGING_ROLLOVER_TYPE, + RolloverSize: ULONG, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, +}} +pub type PHTTP_LOGGING_INFO = *mut HTTP_LOGGING_INFO; +STRUCT!{struct HTTP_BINDING_INFO { + Flags: HTTP_PROPERTY_FLAGS, + RequestQueueHandle: HANDLE, +}} +pub type PHTTP_BINDING_INFO = *mut HTTP_BINDING_INFO; +ENUM!{enum HTTP_PROTECTION_LEVEL_TYPE { + HttpProtectionLevelUnrestricted, + HttpProtectionLevelEdgeRestricted, + HttpProtectionLevelRestricted, +}} +pub type PHTTP_PROTECTION_LEVEL_TYPE = *mut HTTP_PROTECTION_LEVEL_TYPE; +STRUCT!{struct HTTP_PROTECTION_LEVEL_INFO { + Flags: HTTP_PROPERTY_FLAGS, + Level: HTTP_PROTECTION_LEVEL_TYPE, +}} +pub type PHTTP_PROTECTION_LEVEL_INFO = *mut HTTP_PROTECTION_LEVEL_INFO; +pub const HTTP_CREATE_REQUEST_QUEUE_FLAG_OPEN_EXISTING: ULONG = 0x00000001; +pub const HTTP_CREATE_REQUEST_QUEUE_FLAG_CONTROLLER: ULONG = 0x00000002; +pub const HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY: ULONG = 0x00000001; +pub const HTTP_RECEIVE_REQUEST_FLAG_FLUSH_BODY: ULONG = 0x00000002; +pub const HTTP_RECEIVE_REQUEST_ENTITY_BODY_FLAG_FILL_BUFFER: ULONG = 0x00000001; +pub const HTTP_SEND_RESPONSE_FLAG_DISCONNECT: ULONG = 0x00000001; +pub const HTTP_SEND_RESPONSE_FLAG_MORE_DATA: ULONG = 0x00000002; +pub const HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA: ULONG = 0x00000004; +pub const HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING: ULONG = 0x00000008; +pub const HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES: ULONG = 0x00000020; +pub const HTTP_SEND_RESPONSE_FLAG_OPAQUE: ULONG = 0x00000040; +pub const HTTP_FLUSH_RESPONSE_FLAG_RECURSIVE: ULONG = 0x00000001; +pub type HTTP_OPAQUE_ID = ULONGLONG; +pub type PHTTP_OPAQUE_ID = *mut ULONGLONG; +pub type HTTP_REQUEST_ID = HTTP_OPAQUE_ID; +pub type PHTTP_REQUEST_ID = *mut HTTP_OPAQUE_ID; +pub type HTTP_CONNECTION_ID = HTTP_OPAQUE_ID; +pub type PHTTP_CONNECTION_ID = *mut HTTP_OPAQUE_ID; +pub type HTTP_RAW_CONNECTION_ID = HTTP_OPAQUE_ID; +pub type PHTTP_RAW_CONNECTION_ID = *mut HTTP_OPAQUE_ID; +pub type HTTP_URL_GROUP_ID = HTTP_OPAQUE_ID; +pub type PHTTP_URL_GROUP_ID = *mut HTTP_OPAQUE_ID; +pub type HTTP_SERVER_SESSION_ID = HTTP_OPAQUE_ID; +pub type PHTTP_SERVER_SESSION_ID = *mut HTTP_OPAQUE_ID; +pub const HTTP_BYTE_RANGE_TO_EOF: ULONGLONG = !0; +STRUCT!{struct HTTP_BYTE_RANGE { + StartingOffset: ULARGE_INTEGER, + Length: ULARGE_INTEGER, +}} +pub type PHTTP_BYTE_RANGE = *mut HTTP_BYTE_RANGE; +STRUCT!{struct HTTP_VERSION { + MajorVersion: USHORT, + MinorVersion: USHORT, +}} +pub type PHTTP_VERSION = *mut HTTP_VERSION; +pub const HTTP_VERSION_UNKNOWN: HTTP_VERSION = HTTP_VERSION { MajorVersion: 0, MinorVersion: 0 }; +pub const HTTP_VERSION_0_9: HTTP_VERSION = HTTP_VERSION { MajorVersion: 0, MinorVersion: 9 }; +pub const HTTP_VERSION_1_0: HTTP_VERSION = HTTP_VERSION { MajorVersion: 1, MinorVersion: 0 }; +pub const HTTP_VERSION_1_1: HTTP_VERSION = HTTP_VERSION { MajorVersion: 1, MinorVersion: 1 }; +#[inline] +pub fn HTTP_SET_VERSION(mut version: HTTP_VERSION, major: USHORT, minor: USHORT) { + version.MajorVersion = major; + version.MinorVersion = minor; +} +#[inline] +pub fn HTTP_EQUAL_VERSION(version: HTTP_VERSION, major: USHORT, minor: USHORT) -> bool { + version.MajorVersion == major && version.MinorVersion == minor +} +#[inline] +pub fn HTTP_GREATER_VERSION(version: HTTP_VERSION, major: USHORT, minor: USHORT) -> bool { + version.MajorVersion > major || (version.MajorVersion == major && version.MinorVersion > minor) +} +#[inline] +pub fn HTTP_LESS_VERSION(version: HTTP_VERSION, major: USHORT, minor: USHORT) -> bool { + version.MajorVersion < major || (version.MajorVersion == major && version.MinorVersion < minor) +} +#[inline] +pub fn HTTP_NOT_EQUAL_VERSION(version: HTTP_VERSION, major: USHORT, minor: USHORT) -> bool { + !HTTP_EQUAL_VERSION(version, major, minor) +} +#[inline] +pub fn HTTP_GREATER_EQUAL_VERSION(version: HTTP_VERSION, major: USHORT, minor: USHORT) -> bool { + !HTTP_LESS_VERSION(version, major, minor) +} +#[inline] +pub fn HTTP_LESS_EQUAL_VERSION(version: HTTP_VERSION, major: USHORT, minor: USHORT) -> bool { + !HTTP_GREATER_VERSION(version, major, minor) +} +ENUM!{enum HTTP_VERB { + HttpVerbUnparsed, + HttpVerbUnknown, + HttpVerbInvalid, + HttpVerbOPTIONS, + HttpVerbGET, + HttpVerbHEAD, + HttpVerbPOST, + HttpVerbPUT, + HttpVerbDELETE, + HttpVerbTRACE, + HttpVerbCONNECT, + HttpVerbTRACK, + HttpVerbMOVE, + HttpVerbCOPY, + HttpVerbPROPFIND, + HttpVerbPROPPATCH, + HttpVerbMKCOL, + HttpVerbLOCK, + HttpVerbUNLOCK, + HttpVerbSEARCH, + HttpVerbMaximum, +}} +pub type PHTTP_VERB = *mut HTTP_VERB; +ENUM!{enum HTTP_HEADER_ID { + HttpHeaderCacheControl = 0, + HttpHeaderConnection = 1, + HttpHeaderDate = 2, + HttpHeaderKeepAlive = 3, + HttpHeaderPragma = 4, + HttpHeaderTrailer = 5, + HttpHeaderTransferEncoding = 6, + HttpHeaderUpgrade = 7, + HttpHeaderVia = 8, + HttpHeaderWarning = 9, + HttpHeaderAllow = 10, + HttpHeaderContentLength = 11, + HttpHeaderContentType = 12, + HttpHeaderContentEncoding = 13, + HttpHeaderContentLanguage = 14, + HttpHeaderContentLocation = 15, + HttpHeaderContentMd5 = 16, + HttpHeaderContentRange = 17, + HttpHeaderExpires = 18, + HttpHeaderLastModified = 19, + HttpHeaderAccept = 20, + HttpHeaderAcceptCharset = 21, + HttpHeaderAcceptEncoding = 22, + HttpHeaderAcceptLanguage = 23, + HttpHeaderAuthorization = 24, + HttpHeaderCookie = 25, + HttpHeaderExpect = 26, + HttpHeaderFrom = 27, + HttpHeaderHost = 28, + HttpHeaderIfMatch = 29, + HttpHeaderIfModifiedSince = 30, + HttpHeaderIfNoneMatch = 31, + HttpHeaderIfRange = 32, + HttpHeaderIfUnmodifiedSince = 33, + HttpHeaderMaxForwards = 34, + HttpHeaderProxyAuthorization = 35, + HttpHeaderReferer = 36, + HttpHeaderRange = 37, + HttpHeaderTe = 38, + HttpHeaderTranslate = 39, + HttpHeaderUserAgent = 40, + HttpHeaderRequestMaximum = 41, + HttpHeaderAcceptRanges = 20, + HttpHeaderAge = 21, + HttpHeaderEtag = 22, + HttpHeaderLocation = 23, + HttpHeaderProxyAuthenticate = 24, + HttpHeaderRetryAfter = 25, + HttpHeaderServer = 26, + HttpHeaderSetCookie = 27, + HttpHeaderVary = 28, + HttpHeaderWwwAuthenticate = 29, + HttpHeaderResponseMaximum = 30, + HttpHeaderMaximum = 41, +}} +pub type PHTTP_HEADER_ID = *mut HTTP_HEADER_ID; +STRUCT!{struct HTTP_KNOWN_HEADER { + RawValueLength: USHORT, + pRawValue: PCSTR, +}} +pub type PHTTP_KNOWN_HEADER = *mut HTTP_KNOWN_HEADER; +STRUCT!{struct HTTP_UNKNOWN_HEADER { + NameLength: USHORT, + RawValueLength: USHORT, + pName: PCSTR, + pRawValue: PCSTR, +}} +pub type PHTTP_UNKNOWN_HEADER = *mut HTTP_UNKNOWN_HEADER; +ENUM!{enum HTTP_LOG_DATA_TYPE { + HttpLogDataTypeFields = 0, +}} +pub type PHTTP_LOG_DATA_TYPE = *mut HTTP_LOG_DATA_TYPE; +STRUCT!{struct HTTP_LOG_DATA { + Type: HTTP_LOG_DATA_TYPE, +}} +pub type PHTTP_LOG_DATA = *mut HTTP_LOG_DATA; +STRUCT!{struct HTTP_LOG_FIELDS_DATA { + Base: HTTP_LOG_DATA, + UserNameLength: USHORT, + UriStemLength: USHORT, + ClientIpLength: USHORT, + ServerNameLength: USHORT, + ServiceNameLength: USHORT, + ServerIpLength: USHORT, + MethodLength: USHORT, + UriQueryLength: USHORT, + HostLength: USHORT, + UserAgentLength: USHORT, + CookieLength: USHORT, + ReferrerLength: USHORT, + UserName: PWCHAR, + UriStem: PWCHAR, + ClientIp: PCHAR, + ServerName: PCHAR, + ServiceName: PCHAR, + ServerIp: PCHAR, + Method: PCHAR, + UriQuery: PCHAR, + Host: PCHAR, + UserAgent: PCHAR, + Cookie: PCHAR, + Referrer: PCHAR, + ServerPort: USHORT, + ProtocolStatus: USHORT, + Win32Status: ULONG, + MethodNum: HTTP_VERB, + SubStatus: USHORT, +}} +pub type PHTTP_LOG_FIELDS_DATA = *mut HTTP_LOG_FIELDS_DATA; +ENUM!{enum HTTP_DATA_CHUNK_TYPE { + HttpDataChunkFromMemory, + HttpDataChunkFromFileHandle, + HttpDataChunkFromFragmentCache, + HttpDataChunkFromFragmentCacheEx, + HttpDataChunkMaximum, +}} +pub type PHTTP_DATA_CHUNK_TYPE = *mut HTTP_DATA_CHUNK_TYPE; +STRUCT!{struct HTTP_DATA_CHUNK_FromMemory { + pBuffer: PVOID, + BufferLength: ULONG, +}} +STRUCT!{struct HTTP_DATA_CHUNK_FromFileHandle { + ByteRange: HTTP_BYTE_RANGE, + FileHandle: HANDLE, +}} +STRUCT!{struct HTTP_DATA_CHUNK_FromFragmentCache { + FragmentNameLength: USHORT, + pFragmentName: PCWSTR, +}} +STRUCT!{struct HTTP_DATA_CHUNK_FromFragmentCacheEx { + ByteRange: HTTP_BYTE_RANGE, + pFragmentName: PCWSTR, +}} +UNION!{union HTTP_DATA_CHUNK_u { + [u64; 3], + FromMemory FromMemory_mut: HTTP_DATA_CHUNK_FromMemory, + FromFileHandle FromFileHandle_mut: HTTP_DATA_CHUNK_FromFileHandle, + FromFragmentCache FromFragmentCache_mut: HTTP_DATA_CHUNK_FromFragmentCache, + FromFragmentCacheEx FromFragmentCacheEx_mut: HTTP_DATA_CHUNK_FromFragmentCacheEx, +}} +STRUCT!{struct HTTP_DATA_CHUNK { + DataChunkType: HTTP_DATA_CHUNK_TYPE, + u: HTTP_DATA_CHUNK_u, +}} +pub type PHTTP_DATA_CHUNK = *mut HTTP_DATA_CHUNK; +STRUCT!{struct HTTP_REQUEST_HEADERS { + UnknownHeaderCount: USHORT, + pUnknownHeaders: PHTTP_UNKNOWN_HEADER, + TrailerCount: USHORT, + pTrailers: PHTTP_UNKNOWN_HEADER, + KnownHeaders: [HTTP_KNOWN_HEADER; 41], // FIXME HttpHeaderRequestMaximum +}} +pub type PHTTP_REQUEST_HEADERS = *mut HTTP_REQUEST_HEADERS; +STRUCT!{struct HTTP_RESPONSE_HEADERS { + UnknownHeaderCount: USHORT, + pUnknownHeaders: PHTTP_UNKNOWN_HEADER, + TrailerCount: USHORT, + pTrailers: PHTTP_UNKNOWN_HEADER, + KnownHeaders: [HTTP_KNOWN_HEADER; 30], // FIXME HttpHeaderResponseMaximum +}} +pub type PHTTP_RESPONSE_HEADERS = *mut HTTP_RESPONSE_HEADERS; +STRUCT!{struct HTTP_TRANSPORT_ADDRESS { + pRemoteAddress: PSOCKADDR, + pLocalAddress: PSOCKADDR, +}} +pub type PHTTP_TRANSPORT_ADDRESS = *mut HTTP_TRANSPORT_ADDRESS; +STRUCT!{struct HTTP_COOKED_URL { + FullUrlLength: USHORT, + HostLength: USHORT, + AbsPathLength: USHORT, + QueryStringLength: USHORT, + pFullUrl: PCWSTR, + pHost: PCWSTR, + pAbsPath: PCWSTR, + pQueryString: PCWSTR, +}} +pub type PHTTP_COOKED_URL = *mut HTTP_COOKED_URL; +pub type HTTP_URL_CONTEXT = ULONGLONG; +pub const HTTP_URL_FLAG_REMOVE_ALL: ULONG = 0x00000001; +ENUM!{enum HTTP_AUTH_STATUS { + HttpAuthStatusSuccess, + HttpAuthStatusNotAuthenticated, + HttpAuthStatusFailure, +}} +pub type PHTTP_AUTH_STATUS = *mut HTTP_AUTH_STATUS; +ENUM!{enum HTTP_REQUEST_AUTH_TYPE { + HttpRequestAuthTypeNone = 0, + HttpRequestAuthTypeBasic, + HttpRequestAuthTypeDigest, + HttpRequestAuthTypeNTLM, + HttpRequestAuthTypeNegotiate, + HttpRequestAuthTypeKerberos, +}} +pub type PHTTP_REQUEST_AUTH_TYPE = *mut HTTP_REQUEST_AUTH_TYPE; +STRUCT!{struct HTTP_SSL_CLIENT_CERT_INFO { + CertFlags: ULONG, + CertEncodedSize: ULONG, + pCertEncoded: PUCHAR, + Token: HANDLE, + CertDeniedByMapper: BOOLEAN, +}} +pub type PHTTP_SSL_CLIENT_CERT_INFO = *mut HTTP_SSL_CLIENT_CERT_INFO; +pub const HTTP_RECEIVE_SECURE_CHANNEL_TOKEN: ULONG = 0x1; +STRUCT!{struct HTTP_SSL_INFO { + ServerCertKeySize: USHORT, + ConnectionKeySize: USHORT, + ServerCertIssuerSize: ULONG, + ServerCertSubjectSize: ULONG, + pServerCertIssuer: PCSTR, + pServerCertSubject: PCSTR, + pClientCertInfo: PHTTP_SSL_CLIENT_CERT_INFO, + SslClientCertNegotiated: ULONG, +}} +pub type PHTTP_SSL_INFO = *mut HTTP_SSL_INFO; +ENUM!{enum HTTP_REQUEST_INFO_TYPE { + HttpRequestInfoTypeAuth, + HttpRequestInfoTypeChannelBind, +}} +STRUCT!{struct HTTP_REQUEST_INFO { + InfoType: HTTP_REQUEST_INFO_TYPE, + InfoLength: ULONG, + pInfo: PVOID, +}} +pub type PHTTP_REQUEST_INFO = *mut HTTP_REQUEST_INFO; +pub const HTTP_REQUEST_AUTH_FLAG_TOKEN_FOR_CACHED_CRED: ULONG = 0x00000001; +STRUCT!{struct HTTP_REQUEST_AUTH_INFO { + AuthStatus: HTTP_AUTH_STATUS, + SecStatus: SECURITY_STATUS, + Flags: ULONG, + AuthType: HTTP_REQUEST_AUTH_TYPE, + AccessToken: HANDLE, + ContextAttributes: ULONG, + PackedContextLength: ULONG, + PackedContextType: ULONG, + PackedContext: PVOID, + MutualAuthDataLength: ULONG, + pMutualAuthData: PCHAR, + PackageNameLength: USHORT, + pPackageName: PWSTR, +}} +pub type PHTTP_REQUEST_AUTH_INFO = *mut HTTP_REQUEST_AUTH_INFO; +STRUCT!{struct HTTP_REQUEST_V1 { + Flags: ULONG, + ConnectionId: HTTP_CONNECTION_ID, + RequestId: HTTP_REQUEST_ID, + UrlContext: HTTP_URL_CONTEXT, + Version: HTTP_VERSION, + Verb: HTTP_VERB, + UnknownVerbLength: USHORT, + RawUrlLength: USHORT, + pUnknownVerb: PCSTR, + pRawUrl: PCSTR, + CookedUrl: HTTP_COOKED_URL, + Address: HTTP_TRANSPORT_ADDRESS, + Headers: HTTP_REQUEST_HEADERS, + BytesReceived: ULONGLONG, + EntityChunkCount: USHORT, + pEntityChunks: PHTTP_DATA_CHUNK, + RawConnectionId: HTTP_RAW_CONNECTION_ID, + pSslInfo: PHTTP_SSL_INFO, +}} +pub type PHTTP_REQUEST_V1 = *mut HTTP_REQUEST_V1; +STRUCT!{struct HTTP_REQUEST_V2 { + Base: HTTP_REQUEST_V1, + RequestInfoCount: USHORT, + pRequestInfo: PHTTP_REQUEST_INFO, +}} +pub type PHTTP_REQUEST_V2 = *mut HTTP_REQUEST_V2; +pub type HTTP_REQUEST = HTTP_REQUEST_V2; +pub type PHTTP_REQUEST = *mut HTTP_REQUEST; +pub const HTTP_REQUEST_FLAG_MORE_ENTITY_BODY_EXISTS: ULONG = 0x00000001; +pub const HTTP_REQUEST_FLAG_IP_ROUTED: ULONG = 0x00000002; +STRUCT!{struct HTTP_RESPONSE_V1 { + Flags: ULONG, + Version: HTTP_VERSION, + StatusCode: USHORT, + ReasonLength: USHORT, + pReason: PCSTR, + Headers: HTTP_RESPONSE_HEADERS, + EntityChunkCount: USHORT, + pEntityChunks: PHTTP_DATA_CHUNK, +}} +pub type PHTTP_RESPONSE_V1 = *mut HTTP_RESPONSE_V1; +pub const HTTP_RESPONSE_FLAG_MULTIPLE_ENCODINGS_AVAILABLE: ULONG = 0x00000001; +ENUM!{enum HTTP_RESPONSE_INFO_TYPE { + HttpResponseInfoTypeMultipleKnownHeaders, + HttpResponseInfoTypeAuthenticationProperty, + HttpResponseInfoTypeQoSProperty, + HttpResponseInfoTypeChannelBind, +}} +pub type PHTTP_RESPONSE_INFO_TYPE = *mut HTTP_RESPONSE_INFO_TYPE; +STRUCT!{struct HTTP_RESPONSE_INFO { + Type: HTTP_RESPONSE_INFO_TYPE, + Length: ULONG, + pInfo: PVOID, +}} +pub type PHTTP_RESPONSE_INFO = *mut HTTP_RESPONSE_INFO; +pub const HTTP_RESPONSE_INFO_FLAGS_PRESERVE_ORDER: ULONG = 0x00000001; +STRUCT!{struct HTTP_MULTIPLE_KNOWN_HEADERS { + HeaderId: HTTP_HEADER_ID, + Flags: ULONG, + KnownHeaderCount: USHORT, + KnownHeaders: PHTTP_KNOWN_HEADER, +}} +pub type PHTTP_MULTIPLE_KNOWN_HEADERS = *mut HTTP_MULTIPLE_KNOWN_HEADERS; +STRUCT!{struct HTTP_RESPONSE_V2 { + Base: HTTP_RESPONSE_V1, + ResponseInfoCount: USHORT, + pResponseInfo: PHTTP_RESPONSE_INFO, +}} +pub type PHTTP_RESPONSE_V2 = *mut HTTP_RESPONSE_V2; +pub type HTTP_RESPONSE = HTTP_RESPONSE_V2; +pub type PHTTP_RESPONSE = *mut HTTP_RESPONSE; +STRUCT!{struct HTTPAPI_VERSION { + HttpApiMajorVersion: USHORT, + HttpApiMinorVersion: USHORT, +}} +pub type PHTTPAPI_VERSION = *mut HTTPAPI_VERSION; +pub const HTTPAPI_VERSION_2: HTTPAPI_VERSION = HTTPAPI_VERSION { + HttpApiMajorVersion: 2, + HttpApiMinorVersion: 0, +}; +pub const HTTPAPI_VERSION_1: HTTPAPI_VERSION = HTTPAPI_VERSION { + HttpApiMajorVersion: 1, + HttpApiMinorVersion: 0, +}; +#[inline] +pub fn HTTPAPI_EQUAL_VERSION(version: HTTPAPI_VERSION, major: USHORT, minor: USHORT) -> bool { + version.HttpApiMajorVersion == major && version.HttpApiMinorVersion == minor +} +#[inline] +pub fn HTTPAPI_GREATER_VERSION(version: HTTPAPI_VERSION, major: USHORT, minor: USHORT) -> bool { + version.HttpApiMajorVersion > major || + (version.HttpApiMajorVersion == major && version.HttpApiMinorVersion > minor) +} +#[inline] +pub fn HTTPAPI_LESS_VERSION(version: HTTPAPI_VERSION, major: USHORT, minor: USHORT) -> bool { + version.HttpApiMajorVersion < major || + (version.HttpApiMajorVersion == major && version.HttpApiMinorVersion < minor) +} +#[inline] +pub fn HTTPAPI_VERSION_GREATER_OR_EQUAL( + version: HTTPAPI_VERSION, + major: USHORT, + minor: USHORT, +) -> bool { + !HTTPAPI_LESS_VERSION(version, major, minor) +} +ENUM!{enum HTTP_CACHE_POLICY_TYPE { + HttpCachePolicyNocache, + HttpCachePolicyUserInvalidates, + HttpCachePolicyTimeToLive, + HttpCachePolicyMaximum, +}} +pub type PHTTP_CACHE_POLICY_TYPE = *mut HTTP_CACHE_POLICY_TYPE; +STRUCT!{struct HTTP_CACHE_POLICY { + Policy: HTTP_CACHE_POLICY_TYPE, + SecondsToLive: ULONG, +}} +pub type PHTTP_CACHE_POLICY = *mut HTTP_CACHE_POLICY; +ENUM!{enum HTTP_SERVICE_CONFIG_ID { + HttpServiceConfigIPListenList, + HttpServiceConfigSSLCertInfo, + HttpServiceConfigUrlAclInfo, + HttpServiceConfigTimeout, + HttpServiceConfigCache, + HttpServiceConfigSslSniCertInfo, + HttpServiceConfigSslCcsCertInfo, + HttpServiceConfigMax, +}} +pub type PHTTP_SERVICE_CONFIG_ID = *mut HTTP_SERVICE_CONFIG_ID; +ENUM!{enum HTTP_SERVICE_CONFIG_QUERY_TYPE { + HttpServiceConfigQueryExact, + HttpServiceConfigQueryNext, + HttpServiceConfigQueryMax, +}} +pub type PHTTP_SERVICE_CONFIG_QUERY_TYPE = *mut HTTP_SERVICE_CONFIG_QUERY_TYPE; +STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_KEY { + pIpPort: PSOCKADDR, +}} +pub type PHTTP_SERVICE_CONFIG_SSL_KEY = *mut HTTP_SERVICE_CONFIG_SSL_KEY; +STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_SNI_KEY { + IpPort: SOCKADDR_STORAGE, + Host: PWSTR, +}} +pub type PHTTP_SERVICE_CONFIG_SSL_SNI_KEY = *mut HTTP_SERVICE_CONFIG_SSL_SNI_KEY; +STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_CCS_KEY { + LocalAddress: SOCKADDR_STORAGE, +}} +pub type PHTTP_SERVICE_CONFIG_SSL_CCS_KEY = *mut HTTP_SERVICE_CONFIG_SSL_CCS_KEY; +STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_PARAM { + SslHashLength: ULONG, + pSslHash: PVOID, + AppId: GUID, + pSslCertStoreName: PWSTR, + DefaultCertCheckMode: DWORD, + DefaultRevocationFreshnessTime: DWORD, + DefaultRevocationUrlRetrievalTimeout: DWORD, + pDefaultSslCtlIdentifier: PWSTR, + pDefaultSslCtlStoreName: PWSTR, + DefaultFlags: DWORD, +}} +pub type PHTTP_SERVICE_CONFIG_SSL_PARAM = *mut HTTP_SERVICE_CONFIG_SSL_PARAM; +pub const HTTP_SERVICE_CONFIG_SSL_FLAG_USE_DS_MAPPER: DWORD = 0x00000001; +pub const HTTP_SERVICE_CONFIG_SSL_FLAG_NEGOTIATE_CLIENT_CERT: DWORD = 0x00000002; +pub const HTTP_SERVICE_CONFIG_SSL_FLAG_NO_RAW_FILTER: DWORD = 0x00000004; +STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_SET { + KeyDesc: HTTP_SERVICE_CONFIG_SSL_KEY, + ParamDesc: HTTP_SERVICE_CONFIG_SSL_PARAM, +}} +pub type PHTTP_SERVICE_CONFIG_SSL_SET = *mut HTTP_SERVICE_CONFIG_SSL_SET; +STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_SNI_SET { + KeyDesc: HTTP_SERVICE_CONFIG_SSL_SNI_KEY, + ParamDesc: HTTP_SERVICE_CONFIG_SSL_PARAM, +}} +pub type PHTTP_SERVICE_CONFIG_SSL_SNI_SET = *mut HTTP_SERVICE_CONFIG_SSL_SNI_SET; +STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_CCS_SET { + KeyDesc: HTTP_SERVICE_CONFIG_SSL_CCS_KEY, + ParamDesc: HTTP_SERVICE_CONFIG_SSL_PARAM, +}} +pub type PHTTP_SERVICE_CONFIG_SSL_CCS_SET = *mut HTTP_SERVICE_CONFIG_SSL_CCS_SET; +STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_QUERY { + QueryDesc: HTTP_SERVICE_CONFIG_QUERY_TYPE, + KeyDesc: HTTP_SERVICE_CONFIG_SSL_KEY, + dwToken: DWORD, +}} +pub type PHTTP_SERVICE_CONFIG_SSL_QUERY = *mut HTTP_SERVICE_CONFIG_SSL_QUERY; +STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_SNI_QUERY { + QueryDesc: HTTP_SERVICE_CONFIG_QUERY_TYPE, + KeyDesc: HTTP_SERVICE_CONFIG_SSL_SNI_KEY, + dwToken: DWORD, +}} +pub type PHTTP_SERVICE_CONFIG_SSL_SNI_QUERY = *mut HTTP_SERVICE_CONFIG_SSL_SNI_QUERY; +STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_CCS_QUERY { + QueryDesc: HTTP_SERVICE_CONFIG_QUERY_TYPE, + KeyDesc: HTTP_SERVICE_CONFIG_SSL_CCS_KEY, + dwToken: DWORD, +}} +pub type PHTTP_SERVICE_CONFIG_SSL_CCS_QUERY = *mut HTTP_SERVICE_CONFIG_SSL_CCS_QUERY; +STRUCT!{struct HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM { + AddrLength: USHORT, + pAddress: PSOCKADDR, +}} +pub type PHTTP_SERVICE_CONFIG_IP_LISTEN_PARAM = *mut HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM; +STRUCT!{struct HTTP_SERVICE_CONFIG_IP_LISTEN_QUERY { + AddrCount: ULONG, + AddrList: [SOCKADDR_STORAGE; ANYSIZE_ARRAY], +}} +pub type PHTTP_SERVICE_CONFIG_IP_LISTEN_QUERY = *mut HTTP_SERVICE_CONFIG_IP_LISTEN_QUERY; +STRUCT!{struct HTTP_SERVICE_CONFIG_URLACL_KEY { + pUrlPrefix: PWSTR, +}} +pub type PHTTP_SERVICE_CONFIG_URLACL_KEY = *mut HTTP_SERVICE_CONFIG_URLACL_KEY; +STRUCT!{struct HTTP_SERVICE_CONFIG_URLACL_PARAM { + pStringSecurityDescriptor: PWSTR, +}} +pub type PHTTP_SERVICE_CONFIG_URLACL_PARAM = *mut HTTP_SERVICE_CONFIG_URLACL_PARAM; +STRUCT!{struct HTTP_SERVICE_CONFIG_URLACL_SET { + KeyDesc: HTTP_SERVICE_CONFIG_URLACL_KEY, + ParamDesc: HTTP_SERVICE_CONFIG_URLACL_PARAM, +}} +pub type PHTTP_SERVICE_CONFIG_URLACL_SET = *mut HTTP_SERVICE_CONFIG_URLACL_SET; +STRUCT!{struct HTTP_SERVICE_CONFIG_URLACL_QUERY { + QueryDesc: HTTP_SERVICE_CONFIG_QUERY_TYPE, + KeyDesc: HTTP_SERVICE_CONFIG_URLACL_KEY, + dwToken: DWORD, +}} +pub type PHTTP_SERVICE_CONFIG_URLACL_QUERY = *mut HTTP_SERVICE_CONFIG_URLACL_QUERY; +ENUM!{enum HTTP_SERVICE_CONFIG_CACHE_KEY { + MaxCacheResponseSize = 0, + CacheRangeChunkSize, +}} +pub type PHTTP_SERVICE_CONFIG_CACHE_KEY = *mut HTTP_SERVICE_CONFIG_CACHE_KEY; +pub type HTTP_SERVICE_CONFIG_CACHE_PARAM = ULONG; +pub type PHTTP_SERVICE_CONFIG_CACHE_PARAM = *mut ULONG; +STRUCT!{struct HTTP_SERVICE_CONFIG_CACHE_SET { + KeyDesc: HTTP_SERVICE_CONFIG_CACHE_KEY, + ParamDesc: HTTP_SERVICE_CONFIG_CACHE_PARAM, +}} +pub type PHTTP_SERVICE_CONFIG_CACHE_SET = *mut HTTP_SERVICE_CONFIG_CACHE_SET; +extern "system" { + pub fn HttpInitialize( + Version: HTTPAPI_VERSION, + Flags: ULONG, + pReserved: PVOID, + ) -> ULONG; + pub fn HttpTerminate( + Flags: ULONG, + pReserved: PVOID, + ) -> ULONG; + pub fn HttpCreateHttpHandle( + pReqQueueHandle: HANDLE, + Reserved: ULONG, + ) -> ULONG; + pub fn HttpCreateRequestQueue( + Version: HTTPAPI_VERSION, + pName: PCWSTR, + pSecurityAttributes: PSECURITY_ATTRIBUTES, + Flags: ULONG, + pReqQueueHandle: PHANDLE, + ) -> ULONG; + pub fn HttpCloseRequestQueue( + ReqQueueHandle: HANDLE, + ) -> ULONG; + pub fn HttpSetRequestQueueProperty( + Handle: HANDLE, + Property: HTTP_SERVER_PROPERTY, + pPropertyInformation: PVOID, + PropertyInformationLength: ULONG, + Reserved: ULONG, + pReserved: PVOID, + ) -> ULONG; + pub fn HttpQueryRequestQueueProperty( + Handle: HANDLE, + Property: HTTP_SERVER_PROPERTY, + pPropertyInformation: PVOID, + PropertyInformationLength: ULONG, + Reserved: ULONG, + pReturnLength: PULONG, + pReserved: PVOID, + ) -> ULONG; + pub fn HttpShutdownRequestQueue( + ReqQueueHandle: HANDLE, + ) -> ULONG; + pub fn HttpReceiveClientCertificate( + ReqQueueHandle: HANDLE, + ConnectionId: HTTP_CONNECTION_ID, + Flags: ULONG, + pSslClientCertInfo: PHTTP_SSL_CLIENT_CERT_INFO, + SslClientCertInfoSize: ULONG, + pBytesReceived: PULONG, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpCreateServerSession( + Version: HTTPAPI_VERSION, + pServerSessionId: PHTTP_SERVER_SESSION_ID, + Reserved: ULONG, + ) -> ULONG; + pub fn HttpCloseServerSession( + ServerSessionId: HTTP_SERVER_SESSION_ID, + ) -> ULONG; + pub fn HttpQueryServerSessionProperty( + ServerSessionId: HTTP_SERVER_SESSION_ID, + Property: HTTP_SERVER_PROPERTY, + pPropertyInformation: PVOID, + PropertyInformationLength: ULONG, + pReturnLength: PULONG, + ) -> ULONG; + pub fn HttpSetServerSessionProperty( + ServerSessionId: HTTP_SERVER_SESSION_ID, + Property: HTTP_SERVER_PROPERTY, + pPropertyInformation: PVOID, + PropertyInformationLength: ULONG, + ) -> ULONG; + pub fn HttpAddUrl( + ReqQueueHandle: HANDLE, + pFullyQualifiedUrl: PCWSTR, + pReserved: PVOID, + ) -> ULONG; + pub fn HttpRemoveUrl( + ReqQueueHandle: HANDLE, + pFullyQualifiedUrl: PCWSTR, + ) -> ULONG; + pub fn HttpCreateUrlGroup( + ServerSessionId: HTTP_SERVER_SESSION_ID, + pUrlGroupId: PHTTP_URL_GROUP_ID, + Reserved: ULONG, + ) -> ULONG; + pub fn HttpCloseUrlGroup( + UrlGroupId: HTTP_URL_GROUP_ID, + ) -> ULONG; + pub fn HttpAddUrlToUrlGroup( + UrlGroupId: HTTP_URL_GROUP_ID, + pFullyQualifiedUrl: PCWSTR, + UrlContext: HTTP_URL_CONTEXT, + Reserved: ULONG, + ) -> ULONG; + pub fn HttpRemoveUrlFromUrlGroup( + UrlGroupId: HTTP_URL_GROUP_ID, + pFullyQualifiedUrl: PCWSTR, + Flags: ULONG, + ) -> ULONG; + pub fn HttpSetUrlGroupProperty( + UrlGroupId: HTTP_URL_GROUP_ID, + Property: HTTP_SERVER_PROPERTY, + pPropertyInformation: PVOID, + PropertyInformationLength: ULONG, + ) -> ULONG; + pub fn HttpQueryUrlGroupProperty( + UrlGroupId: HTTP_URL_GROUP_ID, + Property: HTTP_SERVER_PROPERTY, + pPropertyInformation: PVOID, + PropertyInformationLength: ULONG, + pReturnLength: PULONG, + ) -> ULONG; + pub fn HttpPrepareUrl( + Reserved: PVOID, + Flags: ULONG, + Url: PCWSTR, + PreparedUrl: *mut PWSTR, + ) -> ULONG; + pub fn HttpReceiveHttpRequest( + ReqQueueHandle: HANDLE, + RequestId: HTTP_REQUEST_ID, + Flags: ULONG, + pRequestBuffer: PHTTP_REQUEST, + RequestBufferLength: ULONG, + pBytesReturned: PULONG, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpReceiveRequestEntityBody( + ReqQueueHandle: HANDLE, + RequestId: HTTP_REQUEST_ID, + Flags: ULONG, + pBuffer: PVOID, + EntityBufferLength: ULONG, + pBytesReturned: PULONG, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpSendHttpResponse( + ReqQueueHandle: HANDLE, + RequestId: HTTP_REQUEST_ID, + Flags: ULONG, + pHttpResponse: PHTTP_RESPONSE, + pCachePolicy: PHTTP_CACHE_POLICY, + pBytesSent: PULONG, + pReserved1: PVOID, + Reserved2: ULONG, + pOverlapped: LPOVERLAPPED, + pLogData: PHTTP_LOG_DATA, + ) -> ULONG; + pub fn HttpSendResponseEntityBody( + ReqQueueHandle: HANDLE, + RequestId: HTTP_REQUEST_ID, + Flags: ULONG, + EntityChunkCount: USHORT, + pEntityChunks: PHTTP_DATA_CHUNK, + pBytesSent: PULONG, + pReserved1: PVOID, + Reserved2: ULONG, + pOverlapped: LPOVERLAPPED, + pLogData: PHTTP_LOG_DATA, + ) -> ULONG; + pub fn HttpWaitForDisconnect( + ReqQueueHandle: HANDLE, + ConnectionId: HTTP_CONNECTION_ID, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpWaitForDisconnectEx( + ReqQueueHandle: HANDLE, + ConnectionId: HTTP_CONNECTION_ID, + Reserved: ULONG, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpCancelHttpRequest( + ReqQueueHandle: HANDLE, + RequestId: HTTP_REQUEST_ID, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpWaitForDemandStart( + ReqQueueHandle: HANDLE, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpFlushResponseCache( + ReqQueueHandle: HANDLE, + pUrlPrefix: PCWSTR, + Flags: ULONG, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpAddFragmentToCache( + ReqQueueHandle: HANDLE, + pUrlPrefix: PCWSTR, + pDataChunk: PHTTP_DATA_CHUNK, + pCachePolicy: PHTTP_CACHE_POLICY, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpReadFragmentFromCache( + ReqQueueHandle: HANDLE, + pUrlPrefix: PCWSTR, + pByteRange: PHTTP_BYTE_RANGE, + pBuffer: PVOID, + BufferLength: ULONG, + pBytesRead: PULONG, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpSetServiceConfiguration( + ServiceHandle: HANDLE, + ConfigId: HTTP_SERVICE_CONFIG_ID, + pConfigInformation: PVOID, + ConfigInformationLength: ULONG, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpDeleteServiceConfiguration( + ServiceHandle: HANDLE, + ConfigId: HTTP_SERVICE_CONFIG_ID, + pConfigInformation: PVOID, + ConfigInformationLength: ULONG, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; + pub fn HttpQueryServiceConfiguration( + ServiceHandle: HANDLE, + ConfigId: HTTP_SERVICE_CONFIG_ID, + pInput: PVOID, + InputLength: ULONG, + pOutput: PVOID, + OutputLength: ULONG, + pReturnLength: PULONG, + pOverlapped: LPOVERLAPPED, + ) -> ULONG; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/imm.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/imm.rs new file mode 100644 index 0000000..ddf4c3f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/imm.rs @@ -0,0 +1,42 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_uint; +use shared::minwindef::{BOOL, DWORD, UINT}; +use shared::windef::{HWND, POINT, RECT}; +pub type LPUINT = *mut c_uint; +STRUCT!{struct COMPOSITIONFORM { + dwStyle: DWORD, + ptCurrentPos: POINT, + rcArea: RECT, +}} +DECLARE_HANDLE!{HIMC, HIMC__} +pub type LPCOMPOSITIONFORM = *mut COMPOSITIONFORM; +extern "system" { + pub fn ImmGetContext( + hwnd: HWND, + ) -> HIMC; + pub fn ImmGetOpenStatus( + himc: HIMC, + ) -> BOOL; + pub fn ImmSetOpenStatus( + himc: HIMC, + fopen: BOOL, + ) -> BOOL; + pub fn ImmSetCompositionWindow( + himc: HIMC, + lpCompForm: LPCOMPOSITIONFORM, + ) -> BOOL; + pub fn ImmReleaseContext( + hwnd: HWND, + himc: HIMC, + ) -> BOOL; +} +pub const CFS_DEFAULT: UINT = 0x0000; +pub const CFS_RECT: UINT = 0x0001; +pub const CFS_POINT: UINT = 0x0002; +pub const CFS_FORCE_POSITION: UINT = 0x0020; +pub const CFS_CANDIDATEPOS: UINT = 0x0040; +pub const CFS_EXCLUDE: UINT = 0x0080; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/interlockedapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/interlockedapi.rs new file mode 100644 index 0000000..17f656d --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/interlockedapi.rs @@ -0,0 +1,31 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{ULONG, USHORT}; +use um::winnt::{PSLIST_ENTRY, PSLIST_HEADER}; +extern "system" { + pub fn InitializeSListHead( + ListHead: PSLIST_HEADER, + ); + pub fn InterlockedPopEntrySList( + ListHead: PSLIST_HEADER, + ) -> PSLIST_ENTRY; + pub fn InterlockedPushEntrySList( + ListHead: PSLIST_HEADER, + ListEntry: PSLIST_ENTRY, + ) -> PSLIST_ENTRY; + pub fn InterlockedPushListSListEx( + ListHead: PSLIST_HEADER, + List: PSLIST_ENTRY, + ListEnd: PSLIST_ENTRY, + Count: ULONG, + ) -> PSLIST_ENTRY; + pub fn InterlockedFlushSList( + ListHead: PSLIST_HEADER, + ) -> PSLIST_ENTRY; + pub fn QueryDepthSList( + ListHead: PSLIST_HEADER, + ) -> USHORT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ioapiset.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ioapiset.rs new file mode 100644 index 0000000..b9b7109 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ioapiset.rs @@ -0,0 +1,71 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{PULONG_PTR, ULONG_PTR}; +use shared::minwindef::{BOOL, DWORD, LPDWORD, LPVOID, PULONG, ULONG}; +use um::minwinbase::{LPOVERLAPPED, LPOVERLAPPED_ENTRY}; +use um::winnt::HANDLE; +extern "system" { + pub fn CreateIoCompletionPort( + FileHandle: HANDLE, + ExistingCompletionPort: HANDLE, + CompletionKey: ULONG_PTR, + NumberOfConcurrentThreads: DWORD, + ) -> HANDLE; + pub fn GetQueuedCompletionStatus( + CompletionPort: HANDLE, + lpNumberOfBytesTransferred: LPDWORD, + lpCompletionKey: PULONG_PTR, + lpOverlapped: *mut LPOVERLAPPED, + dwMilliseconds: DWORD, + ) -> BOOL; + pub fn GetQueuedCompletionStatusEx( + CompletionPort: HANDLE, + lpCompletionPortEntries: LPOVERLAPPED_ENTRY, + ulCount: ULONG, + ulNumEntriesRemoved: PULONG, + dwMilliseconds: DWORD, + fAlertable: BOOL, + ) -> BOOL; + pub fn PostQueuedCompletionStatus( + CompletionPort: HANDLE, + dwNumberOfBytesTransferred: DWORD, + dwCompletionKey: ULONG_PTR, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn DeviceIoControl( + hDevice: HANDLE, + dwIoControlCode: DWORD, + lpInBuffer: LPVOID, + nInBufferSize: DWORD, + lpOutBuffer: LPVOID, + nOutBufferSize: DWORD, + lpBytesReturned: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn GetOverlappedResult( + hFile: HANDLE, + lpOverlapped: LPOVERLAPPED, + lpNumberOfBytesTransferred: LPDWORD, + bWait: BOOL, + ) -> BOOL; + pub fn CancelIoEx( + hFile: HANDLE, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn CancelIo( + hFile: HANDLE, + ) -> BOOL; + pub fn GetOverlappedResultEx( + hFile: HANDLE, + lpOverlapped: LPOVERLAPPED, + lpNumberOfBytesTransferred: LPDWORD, + dwMilliseconds: DWORD, + bAlertable: BOOL, + ) -> BOOL; + pub fn CancelSynchronousIo( + hThread: HANDLE, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/jobapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/jobapi.rs new file mode 100644 index 0000000..cbe45c1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/jobapi.rs @@ -0,0 +1,14 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, PBOOL}; +use um::winnt::HANDLE; +extern "system" { + pub fn IsProcessInJob( + ProcessHandle: HANDLE, + JobHandle: HANDLE, + Result: PBOOL, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/jobapi2.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/jobapi2.rs new file mode 100644 index 0000000..98eb1e9 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/jobapi2.rs @@ -0,0 +1,63 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::LONG64; +use shared::minwindef::{BOOL, DWORD, LPDWORD, LPVOID, UINT, ULONG}; +use shared::ntdef::{HANDLE, LPCWSTR, PCWSTR, VOID}; +use um::minwinbase::LPSECURITY_ATTRIBUTES; +use um::winnt::JOBOBJECTINFOCLASS; +STRUCT!{struct JOBOBJECT_IO_RATE_CONTROL_INFORMATION { + MaxIops: LONG64, + MaxBandwidth: LONG64, + ReservationIops: LONG64, + VolumeName: PCWSTR, + BaseIoSize: ULONG, + ControlFlags: ULONG, +}} +extern "system" { + pub fn CreateJobObjectW( + lpJobAttributes: LPSECURITY_ATTRIBUTES, + lpName: LPCWSTR, + ) -> HANDLE; + pub fn FreeMemoryJobObject( + Buffer: *mut VOID, + ) -> (); + pub fn OpenJobObjectW( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpName: LPCWSTR, + ) -> HANDLE; + pub fn AssignProcessToJobObject( + hJob: HANDLE, + hProcess: HANDLE, + ) -> BOOL; + pub fn TerminateJobObject( + hJob: HANDLE, + uExitCode: UINT, + ) -> BOOL; + pub fn SetInformationJobObject( + hJob: HANDLE, + JobObjectInformationClass: JOBOBJECTINFOCLASS, + lpJobObjectInformation: LPVOID, + cbJovObjectInformationLength: DWORD, + ) -> BOOL; + pub fn SetIoRateControlInformationJobObject( + hJob: HANDLE, + IoRateControlInfo: *mut JOBOBJECT_IO_RATE_CONTROL_INFORMATION, + ) -> DWORD; + pub fn QueryInformationJobObject( + hJob: HANDLE, + JobObjectInformationClass: JOBOBJECTINFOCLASS, + lpJobObjectInformation: LPVOID, + cbJovObjectInformationLength: DWORD, + lpReturnLength: LPDWORD, + ) -> BOOL; + pub fn QueryIoRateControlInformationJobObject( + hJob: HANDLE, + VolumeName: PCWSTR, + InfoBlocks: *mut *mut JOBOBJECT_IO_RATE_CONTROL_INFORMATION, + InfoBlockCount: *mut ULONG, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/knownfolders.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/knownfolders.rs new file mode 100644 index 0000000..a761ce2 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/knownfolders.rs @@ -0,0 +1,287 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{FOLDERID_NetworkFolder, + 0xD20BEEC4, 0x5CA8, 0x4905, 0xAE, 0x3B, 0xBF, 0x25, 0x1E, 0xA0, 0x9B, 0x53} +DEFINE_GUID!{FOLDERID_ComputerFolder, + 0x0AC0837C, 0xBBF8, 0x452A, 0x85, 0x0D, 0x79, 0xD0, 0x8E, 0x66, 0x7C, 0xA7} +DEFINE_GUID!{FOLDERID_InternetFolder, + 0x4D9F7874, 0x4E0C, 0x4904, 0x96, 0x7B, 0x40, 0xB0, 0xD2, 0x0C, 0x3E, 0x4B} +DEFINE_GUID!{FOLDERID_ControlPanelFolder, + 0x82A74AEB, 0xAEB4, 0x465C, 0xA0, 0x14, 0xD0, 0x97, 0xEE, 0x34, 0x6D, 0x63} +DEFINE_GUID!{FOLDERID_PrintersFolder, + 0x76FC4E2D, 0xD6AD, 0x4519, 0xA6, 0x63, 0x37, 0xBD, 0x56, 0x06, 0x81, 0x85} +DEFINE_GUID!{FOLDERID_SyncManagerFolder, + 0x43668BF8, 0xC14E, 0x49B2, 0x97, 0xC9, 0x74, 0x77, 0x84, 0xD7, 0x84, 0xB7} +DEFINE_GUID!{FOLDERID_SyncSetupFolder, + 0x0f214138, 0xb1d3, 0x4a90, 0xbb, 0xa9, 0x27, 0xcb, 0xc0, 0xc5, 0x38, 0x9a} +DEFINE_GUID!{FOLDERID_ConflictFolder, + 0x4bfefb45, 0x347d, 0x4006, 0xa5, 0xbe, 0xac, 0x0c, 0xb0, 0x56, 0x71, 0x92} +DEFINE_GUID!{FOLDERID_SyncResultsFolder, + 0x289a9a43, 0xbe44, 0x4057, 0xa4, 0x1b, 0x58, 0x7a, 0x76, 0xd7, 0xe7, 0xf9} +DEFINE_GUID!{FOLDERID_RecycleBinFolder, + 0xB7534046, 0x3ECB, 0x4C18, 0xBE, 0x4E, 0x64, 0xCD, 0x4C, 0xB7, 0xD6, 0xAC} +DEFINE_GUID!{FOLDERID_ConnectionsFolder, + 0x6F0CD92B, 0x2E97, 0x45D1, 0x88, 0xFF, 0xB0, 0xD1, 0x86, 0xB8, 0xDE, 0xDD} +DEFINE_GUID!{FOLDERID_Fonts, + 0xFD228CB7, 0xAE11, 0x4AE3, 0x86, 0x4C, 0x16, 0xF3, 0x91, 0x0A, 0xB8, 0xFE} +DEFINE_GUID!{FOLDERID_Desktop, + 0xB4BFCC3A, 0xDB2C, 0x424C, 0xB0, 0x29, 0x7F, 0xE9, 0x9A, 0x87, 0xC6, 0x41} +DEFINE_GUID!{FOLDERID_Startup, + 0xB97D20BB, 0xF46A, 0x4C97, 0xBA, 0x10, 0x5E, 0x36, 0x08, 0x43, 0x08, 0x54} +DEFINE_GUID!{FOLDERID_Programs, + 0xA77F5D77, 0x2E2B, 0x44C3, 0xA6, 0xA2, 0xAB, 0xA6, 0x01, 0x05, 0x4A, 0x51} +DEFINE_GUID!{FOLDERID_StartMenu, + 0x625B53C3, 0xAB48, 0x4EC1, 0xBA, 0x1F, 0xA1, 0xEF, 0x41, 0x46, 0xFC, 0x19} +DEFINE_GUID!{FOLDERID_Recent, + 0xAE50C081, 0xEBD2, 0x438A, 0x86, 0x55, 0x8A, 0x09, 0x2E, 0x34, 0x98, 0x7A} +DEFINE_GUID!{FOLDERID_SendTo, + 0x8983036C, 0x27C0, 0x404B, 0x8F, 0x08, 0x10, 0x2D, 0x10, 0xDC, 0xFD, 0x74} +DEFINE_GUID!{FOLDERID_Documents, + 0xFDD39AD0, 0x238F, 0x46AF, 0xAD, 0xB4, 0x6C, 0x85, 0x48, 0x03, 0x69, 0xC7} +DEFINE_GUID!{FOLDERID_Favorites, + 0x1777F761, 0x68AD, 0x4D8A, 0x87, 0xBD, 0x30, 0xB7, 0x59, 0xFA, 0x33, 0xDD} +DEFINE_GUID!{FOLDERID_NetHood, + 0xC5ABBF53, 0xE17F, 0x4121, 0x89, 0x00, 0x86, 0x62, 0x6F, 0xC2, 0xC9, 0x73} +DEFINE_GUID!{FOLDERID_PrintHood, + 0x9274BD8D, 0xCFD1, 0x41C3, 0xB3, 0x5E, 0xB1, 0x3F, 0x55, 0xA7, 0x58, 0xF4} +DEFINE_GUID!{FOLDERID_Templates, + 0xA63293E8, 0x664E, 0x48DB, 0xA0, 0x79, 0xDF, 0x75, 0x9E, 0x05, 0x09, 0xF7} +DEFINE_GUID!{FOLDERID_CommonStartup, + 0x82A5EA35, 0xD9CD, 0x47C5, 0x96, 0x29, 0xE1, 0x5D, 0x2F, 0x71, 0x4E, 0x6E} +DEFINE_GUID!{FOLDERID_CommonPrograms, + 0x0139D44E, 0x6AFE, 0x49F2, 0x86, 0x90, 0x3D, 0xAF, 0xCA, 0xE6, 0xFF, 0xB8} +DEFINE_GUID!{FOLDERID_CommonStartMenu, + 0xA4115719, 0xD62E, 0x491D, 0xAA, 0x7C, 0xE7, 0x4B, 0x8B, 0xE3, 0xB0, 0x67} +DEFINE_GUID!{FOLDERID_PublicDesktop, + 0xC4AA340D, 0xF20F, 0x4863, 0xAF, 0xEF, 0xF8, 0x7E, 0xF2, 0xE6, 0xBA, 0x25} +DEFINE_GUID!{FOLDERID_ProgramData, + 0x62AB5D82, 0xFDC1, 0x4DC3, 0xA9, 0xDD, 0x07, 0x0D, 0x1D, 0x49, 0x5D, 0x97} +DEFINE_GUID!{FOLDERID_CommonTemplates, + 0xB94237E7, 0x57AC, 0x4347, 0x91, 0x51, 0xB0, 0x8C, 0x6C, 0x32, 0xD1, 0xF7} +DEFINE_GUID!{FOLDERID_PublicDocuments, + 0xED4824AF, 0xDCE4, 0x45A8, 0x81, 0xE2, 0xFC, 0x79, 0x65, 0x08, 0x36, 0x34} +DEFINE_GUID!{FOLDERID_RoamingAppData, + 0x3EB685DB, 0x65F9, 0x4CF6, 0xA0, 0x3A, 0xE3, 0xEF, 0x65, 0x72, 0x9F, 0x3D} +DEFINE_GUID!{FOLDERID_LocalAppData, + 0xF1B32785, 0x6FBA, 0x4FCF, 0x9D, 0x55, 0x7B, 0x8E, 0x7F, 0x15, 0x70, 0x91} +DEFINE_GUID!{FOLDERID_LocalAppDataLow, + 0xA520A1A4, 0x1780, 0x4FF6, 0xBD, 0x18, 0x16, 0x73, 0x43, 0xC5, 0xAF, 0x16} +DEFINE_GUID!{FOLDERID_InternetCache, + 0x352481E8, 0x33BE, 0x4251, 0xBA, 0x85, 0x60, 0x07, 0xCA, 0xED, 0xCF, 0x9D} +DEFINE_GUID!{FOLDERID_Cookies, + 0x2B0F765D, 0xC0E9, 0x4171, 0x90, 0x8E, 0x08, 0xA6, 0x11, 0xB8, 0x4F, 0xF6} +DEFINE_GUID!{FOLDERID_History, + 0xD9DC8A3B, 0xB784, 0x432E, 0xA7, 0x81, 0x5A, 0x11, 0x30, 0xA7, 0x59, 0x63} +DEFINE_GUID!{FOLDERID_System, + 0x1AC14E77, 0x02E7, 0x4E5D, 0xB7, 0x44, 0x2E, 0xB1, 0xAE, 0x51, 0x98, 0xB7} +DEFINE_GUID!{FOLDERID_SystemX86, + 0xD65231B0, 0xB2F1, 0x4857, 0xA4, 0xCE, 0xA8, 0xE7, 0xC6, 0xEA, 0x7D, 0x27} +DEFINE_GUID!{FOLDERID_Windows, + 0xF38BF404, 0x1D43, 0x42F2, 0x93, 0x05, 0x67, 0xDE, 0x0B, 0x28, 0xFC, 0x23} +DEFINE_GUID!{FOLDERID_Profile, + 0x5E6C858F, 0x0E22, 0x4760, 0x9A, 0xFE, 0xEA, 0x33, 0x17, 0xB6, 0x71, 0x73} +DEFINE_GUID!{FOLDERID_Pictures, + 0x33E28130, 0x4E1E, 0x4676, 0x83, 0x5A, 0x98, 0x39, 0x5C, 0x3B, 0xC3, 0xBB} +DEFINE_GUID!{FOLDERID_ProgramFilesX86, + 0x7C5A40EF, 0xA0FB, 0x4BFC, 0x87, 0x4A, 0xC0, 0xF2, 0xE0, 0xB9, 0xFA, 0x8E} +DEFINE_GUID!{FOLDERID_ProgramFilesCommonX86, + 0xDE974D24, 0xD9C6, 0x4D3E, 0xBF, 0x91, 0xF4, 0x45, 0x51, 0x20, 0xB9, 0x17} +DEFINE_GUID!{FOLDERID_ProgramFilesX64, + 0x6d809377, 0x6af0, 0x444b, 0x89, 0x57, 0xa3, 0x77, 0x3f, 0x02, 0x20, 0x0e} +DEFINE_GUID!{FOLDERID_ProgramFilesCommonX64, + 0x6365d5a7, 0x0f0d, 0x45e5, 0x87, 0xf6, 0x0d, 0xa5, 0x6b, 0x6a, 0x4f, 0x7d} +DEFINE_GUID!{FOLDERID_ProgramFiles, + 0x905e63b6, 0xc1bf, 0x494e, 0xb2, 0x9c, 0x65, 0xb7, 0x32, 0xd3, 0xd2, 0x1a} +DEFINE_GUID!{FOLDERID_ProgramFilesCommon, + 0xF7F1ED05, 0x9F6D, 0x47A2, 0xAA, 0xAE, 0x29, 0xD3, 0x17, 0xC6, 0xF0, 0x66} +DEFINE_GUID!{FOLDERID_UserProgramFiles, + 0x5cd7aee2, 0x2219, 0x4a67, 0xb8, 0x5d, 0x6c, 0x9c, 0xe1, 0x56, 0x60, 0xcb} +DEFINE_GUID!{FOLDERID_UserProgramFilesCommon, + 0xbcbd3057, 0xca5c, 0x4622, 0xb4, 0x2d, 0xbc, 0x56, 0xdb, 0x0a, 0xe5, 0x16} +DEFINE_GUID!{FOLDERID_AdminTools, + 0x724EF170, 0xA42D, 0x4FEF, 0x9F, 0x26, 0xB6, 0x0E, 0x84, 0x6F, 0xBA, 0x4F} +DEFINE_GUID!{FOLDERID_CommonAdminTools, + 0xD0384E7D, 0xBAC3, 0x4797, 0x8F, 0x14, 0xCB, 0xA2, 0x29, 0xB3, 0x92, 0xB5} +DEFINE_GUID!{FOLDERID_Music, + 0x4BD8D571, 0x6D19, 0x48D3, 0xBE, 0x97, 0x42, 0x22, 0x20, 0x08, 0x0E, 0x43} +DEFINE_GUID!{FOLDERID_Videos, + 0x18989B1D, 0x99B5, 0x455B, 0x84, 0x1C, 0xAB, 0x7C, 0x74, 0xE4, 0xDD, 0xFC} +DEFINE_GUID!{FOLDERID_Ringtones, + 0xC870044B, 0xF49E, 0x4126, 0xA9, 0xC3, 0xB5, 0x2A, 0x1F, 0xF4, 0x11, 0xE8} +DEFINE_GUID!{FOLDERID_PublicPictures, + 0xB6EBFB86, 0x6907, 0x413C, 0x9A, 0xF7, 0x4F, 0xC2, 0xAB, 0xF0, 0x7C, 0xC5} +DEFINE_GUID!{FOLDERID_PublicMusic, + 0x3214FAB5, 0x9757, 0x4298, 0xBB, 0x61, 0x92, 0xA9, 0xDE, 0xAA, 0x44, 0xFF} +DEFINE_GUID!{FOLDERID_PublicVideos, + 0x2400183A, 0x6185, 0x49FB, 0xA2, 0xD8, 0x4A, 0x39, 0x2A, 0x60, 0x2B, 0xA3} +DEFINE_GUID!{FOLDERID_PublicRingtones, + 0xE555AB60, 0x153B, 0x4D17, 0x9F, 0x04, 0xA5, 0xFE, 0x99, 0xFC, 0x15, 0xEC} +DEFINE_GUID!{FOLDERID_ResourceDir, + 0x8AD10C31, 0x2ADB, 0x4296, 0xA8, 0xF7, 0xE4, 0x70, 0x12, 0x32, 0xC9, 0x72} +DEFINE_GUID!{FOLDERID_LocalizedResourcesDir, + 0x2A00375E, 0x224C, 0x49DE, 0xB8, 0xD1, 0x44, 0x0D, 0xF7, 0xEF, 0x3D, 0xDC} +DEFINE_GUID!{FOLDERID_CommonOEMLinks, + 0xC1BAE2D0, 0x10DF, 0x4334, 0xBE, 0xDD, 0x7A, 0xA2, 0x0B, 0x22, 0x7A, 0x9D} +DEFINE_GUID!{FOLDERID_CDBurning, + 0x9E52AB10, 0xF80D, 0x49DF, 0xAC, 0xB8, 0x43, 0x30, 0xF5, 0x68, 0x78, 0x55} +DEFINE_GUID!{FOLDERID_UserProfiles, + 0x0762D272, 0xC50A, 0x4BB0, 0xA3, 0x82, 0x69, 0x7D, 0xCD, 0x72, 0x9B, 0x80} +DEFINE_GUID!{FOLDERID_Playlists, + 0xDE92C1C7, 0x837F, 0x4F69, 0xA3, 0xBB, 0x86, 0xE6, 0x31, 0x20, 0x4A, 0x23} +DEFINE_GUID!{FOLDERID_SamplePlaylists, + 0x15CA69B3, 0x30EE, 0x49C1, 0xAC, 0xE1, 0x6B, 0x5E, 0xC3, 0x72, 0xAF, 0xB5} +DEFINE_GUID!{FOLDERID_SampleMusic, + 0xB250C668, 0xF57D, 0x4EE1, 0xA6, 0x3C, 0x29, 0x0E, 0xE7, 0xD1, 0xAA, 0x1F} +DEFINE_GUID!{FOLDERID_SamplePictures, + 0xC4900540, 0x2379, 0x4C75, 0x84, 0x4B, 0x64, 0xE6, 0xFA, 0xF8, 0x71, 0x6B} +DEFINE_GUID!{FOLDERID_SampleVideos, + 0x859EAD94, 0x2E85, 0x48AD, 0xA7, 0x1A, 0x09, 0x69, 0xCB, 0x56, 0xA6, 0xCD} +DEFINE_GUID!{FOLDERID_PhotoAlbums, + 0x69D2CF90, 0xFC33, 0x4FB7, 0x9A, 0x0C, 0xEB, 0xB0, 0xF0, 0xFC, 0xB4, 0x3C} +DEFINE_GUID!{FOLDERID_Public, + 0xDFDF76A2, 0xC82A, 0x4D63, 0x90, 0x6A, 0x56, 0x44, 0xAC, 0x45, 0x73, 0x85} +DEFINE_GUID!{FOLDERID_ChangeRemovePrograms, + 0xdf7266ac, 0x9274, 0x4867, 0x8d, 0x55, 0x3b, 0xd6, 0x61, 0xde, 0x87, 0x2d} +DEFINE_GUID!{FOLDERID_AppUpdates, + 0xa305ce99, 0xf527, 0x492b, 0x8b, 0x1a, 0x7e, 0x76, 0xfa, 0x98, 0xd6, 0xe4} +DEFINE_GUID!{FOLDERID_AddNewPrograms, + 0xde61d971, 0x5ebc, 0x4f02, 0xa3, 0xa9, 0x6c, 0x82, 0x89, 0x5e, 0x5c, 0x04} +DEFINE_GUID!{FOLDERID_Downloads, + 0x374de290, 0x123f, 0x4565, 0x91, 0x64, 0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b} +DEFINE_GUID!{FOLDERID_PublicDownloads, + 0x3d644c9b, 0x1fb8, 0x4f30, 0x9b, 0x45, 0xf6, 0x70, 0x23, 0x5f, 0x79, 0xc0} +DEFINE_GUID!{FOLDERID_SavedSearches, + 0x7d1d3a04, 0xdebb, 0x4115, 0x95, 0xcf, 0x2f, 0x29, 0xda, 0x29, 0x20, 0xda} +DEFINE_GUID!{FOLDERID_QuickLaunch, + 0x52a4f021, 0x7b75, 0x48a9, 0x9f, 0x6b, 0x4b, 0x87, 0xa2, 0x10, 0xbc, 0x8f} +DEFINE_GUID!{FOLDERID_Contacts, + 0x56784854, 0xc6cb, 0x462b, 0x81, 0x69, 0x88, 0xe3, 0x50, 0xac, 0xb8, 0x82} +DEFINE_GUID!{FOLDERID_SidebarParts, + 0xa75d362e, 0x50fc, 0x4fb7, 0xac, 0x2c, 0xa8, 0xbe, 0xaa, 0x31, 0x44, 0x93} +DEFINE_GUID!{FOLDERID_SidebarDefaultParts, + 0x7b396e54, 0x9ec5, 0x4300, 0xbe, 0x0a, 0x24, 0x82, 0xeb, 0xae, 0x1a, 0x26} +DEFINE_GUID!{FOLDERID_PublicGameTasks, + 0xdebf2536, 0xe1a8, 0x4c59, 0xb6, 0xa2, 0x41, 0x45, 0x86, 0x47, 0x6a, 0xea} +DEFINE_GUID!{FOLDERID_GameTasks, + 0x054fae61, 0x4dd8, 0x4787, 0x80, 0xb6, 0x09, 0x02, 0x20, 0xc4, 0xb7, 0x0} +DEFINE_GUID!{FOLDERID_SavedGames, + 0x4c5c32ff, 0xbb9d, 0x43b0, 0xb5, 0xb4, 0x2d, 0x72, 0xe5, 0x4e, 0xaa, 0xa4} +DEFINE_GUID!{FOLDERID_Games, + 0xcac52c1a, 0xb53d, 0x4edc, 0x92, 0xd7, 0x6b, 0x2e, 0x8a, 0xc1, 0x94, 0x34} +DEFINE_GUID!{FOLDERID_SEARCH_MAPI, + 0x98ec0e18, 0x2098, 0x4d44, 0x86, 0x44, 0x66, 0x97, 0x93, 0x15, 0xa2, 0x81} +DEFINE_GUID!{FOLDERID_SEARCH_CSC, + 0xee32e446, 0x31ca, 0x4aba, 0x81, 0x4f, 0xa5, 0xeb, 0xd2, 0xfd, 0x6d, 0x5e} +DEFINE_GUID!{FOLDERID_Links, + 0xbfb9d5e0, 0xc6a9, 0x404c, 0xb2, 0xb2, 0xae, 0x6d, 0xb6, 0xaf, 0x49, 0x68} +DEFINE_GUID!{FOLDERID_UsersFiles, + 0xf3ce0f7c, 0x4901, 0x4acc, 0x86, 0x48, 0xd5, 0xd4, 0x4b, 0x04, 0xef, 0x8f} +DEFINE_GUID!{FOLDERID_UsersLibraries, + 0xa302545d, 0xdeff, 0x464b, 0xab, 0xe8, 0x61, 0xc8, 0x64, 0x8d, 0x93, 0x9b} +DEFINE_GUID!{FOLDERID_SearchHome, + 0x190337d1, 0xb8ca, 0x4121, 0xa6, 0x39, 0x6d, 0x47, 0x2d, 0x16, 0x97, 0x2a} +DEFINE_GUID!{FOLDERID_OriginalImages, + 0x2C36C0AA, 0x5812, 0x4b87, 0xbf, 0xd0, 0x4c, 0xd0, 0xdf, 0xb1, 0x9b, 0x39} +DEFINE_GUID!{FOLDERID_DocumentsLibrary, + 0x7b0db17d, 0x9cd2, 0x4a93, 0x97, 0x33, 0x46, 0xcc, 0x89, 0x02, 0x2e, 0x7c} +DEFINE_GUID!{FOLDERID_MusicLibrary, + 0x2112ab0a, 0xc86a, 0x4ffe, 0xa3, 0x68, 0x0d, 0xe9, 0x6e, 0x47, 0x01, 0x2e} +DEFINE_GUID!{FOLDERID_PicturesLibrary, + 0xa990ae9f, 0xa03b, 0x4e80, 0x94, 0xbc, 0x99, 0x12, 0xd7, 0x50, 0x41, 0x4} +DEFINE_GUID!{FOLDERID_VideosLibrary, + 0x491e922f, 0x5643, 0x4af4, 0xa7, 0xeb, 0x4e, 0x7a, 0x13, 0x8d, 0x81, 0x74} +DEFINE_GUID!{FOLDERID_RecordedTVLibrary, + 0x1a6fdba2, 0xf42d, 0x4358, 0xa7, 0x98, 0xb7, 0x4d, 0x74, 0x59, 0x26, 0xc5} +DEFINE_GUID!{FOLDERID_HomeGroup, + 0x52528a6b, 0xb9e3, 0x4add, 0xb6, 0x0d, 0x58, 0x8c, 0x2d, 0xba, 0x84, 0x2d} +DEFINE_GUID!{FOLDERID_HomeGroupCurrentUser, + 0x9b74b6a3, 0x0dfd, 0x4f11, 0x9e, 0x78, 0x5f, 0x78, 0x00, 0xf2, 0xe7, 0x72} +DEFINE_GUID!{FOLDERID_DeviceMetadataStore, + 0x5ce4a5e9, 0xe4eb, 0x479d, 0xb8, 0x9f, 0x13, 0x0c, 0x02, 0x88, 0x61, 0x55} +DEFINE_GUID!{FOLDERID_Libraries, + 0x1b3ea5dc, 0xb587, 0x4786, 0xb4, 0xef, 0xbd, 0x1d, 0xc3, 0x32, 0xae, 0xae} +DEFINE_GUID!{FOLDERID_PublicLibraries, + 0x48daf80b, 0xe6cf, 0x4f4e, 0xb8, 0x00, 0x0e, 0x69, 0xd8, 0x4e, 0xe3, 0x84} +DEFINE_GUID!{FOLDERID_UserPinned, + 0x9e3995ab, 0x1f9c, 0x4f13, 0xb8, 0x27, 0x48, 0xb2, 0x4b, 0x6c, 0x71, 0x74} +DEFINE_GUID!{FOLDERID_ImplicitAppShortcuts, + 0xbcb5256f, 0x79f6, 0x4cee, 0xb7, 0x25, 0xdc, 0x34, 0xe4, 0x02, 0xfd, 0x46} +DEFINE_GUID!{FOLDERID_AccountPictures, + 0x008ca0b1, 0x55b4, 0x4c56, 0xb8, 0xa8, 0x4d, 0xe4, 0xb2, 0x99, 0xd3, 0xbe} +DEFINE_GUID!{FOLDERID_PublicUserTiles, + 0x0482af6c, 0x08f1, 0x4c34, 0x8c, 0x90, 0xe1, 0x7e, 0xc9, 0x8b, 0x1e, 0x17} +DEFINE_GUID!{FOLDERID_AppsFolder, + 0x1e87508d, 0x89c2, 0x42f0, 0x8a, 0x7e, 0x64, 0x5a, 0x0f, 0x50, 0xca, 0x58} +DEFINE_GUID!{FOLDERID_StartMenuAllPrograms, + 0xf26305ef, 0x6948, 0x40b9, 0xb2, 0x55, 0x81, 0x45, 0x3d, 0x09, 0xc7, 0x85} +DEFINE_GUID!{FOLDERID_CommonStartMenuPlaces, + 0xa440879f, 0x87a0, 0x4f7d, 0xb7, 0x00, 0x02, 0x07, 0xb9, 0x66, 0x19, 0x4a} +DEFINE_GUID!{FOLDERID_ApplicationShortcuts, + 0xa3918781, 0xe5f2, 0x4890, 0xb3, 0xd9, 0xa7, 0xe5, 0x43, 0x32, 0x32, 0x8c} +DEFINE_GUID!{FOLDERID_RoamingTiles, + 0x00bcfc5a, 0xed94, 0x4e48, 0x96, 0xa1, 0x3f, 0x62, 0x17, 0xf2, 0x19, 0x90} +DEFINE_GUID!{FOLDERID_RoamedTileImages, + 0xaaa8d5a5, 0xf1d6, 0x4259, 0xba, 0xa8, 0x78, 0xe7, 0xef, 0x60, 0x83, 0x5e} +DEFINE_GUID!{FOLDERID_Screenshots, + 0xb7bede81, 0xdf94, 0x4682, 0xa7, 0xd8, 0x57, 0xa5, 0x26, 0x20, 0xb8, 0x6f} +DEFINE_GUID!{FOLDERID_CameraRoll, + 0xab5fb87b, 0x7ce2, 0x4f83, 0x91, 0x5d, 0x55, 0x08, 0x46, 0xc9, 0x53, 0x7b} +DEFINE_GUID!{FOLDERID_SkyDrive, + 0xa52bba46, 0xe9e1, 0x435f, 0xb3, 0xd9, 0x28, 0xda, 0xa6, 0x48, 0xc0, 0xf6} +DEFINE_GUID!{FOLDERID_OneDrive, + 0xa52bba46, 0xe9e1, 0x435f, 0xb3, 0xd9, 0x28, 0xda, 0xa6, 0x48, 0xc0, 0xf6} +DEFINE_GUID!{FOLDERID_SkyDriveDocuments, + 0x24d89e24, 0x2f19, 0x4534, 0x9d, 0xde, 0x6a, 0x66, 0x71, 0xfb, 0xb8, 0xfe} +DEFINE_GUID!{FOLDERID_SkyDrivePictures, + 0x339719b5, 0x8c47, 0x4894, 0x94, 0xc2, 0xd8, 0xf7, 0x7a, 0xdd, 0x44, 0xa6} +DEFINE_GUID!{FOLDERID_SkyDriveMusic, + 0xc3f2459e, 0x80d6, 0x45dc, 0xbf, 0xef, 0x1f, 0x76, 0x9f, 0x2b, 0xe7, 0x30} +DEFINE_GUID!{FOLDERID_SkyDriveCameraRoll, + 0x767e6811, 0x49cb, 0x4273, 0x87, 0xc2, 0x20, 0xf3, 0x55, 0xe1, 0x08, 0x5b} +DEFINE_GUID!{FOLDERID_SearchHistory, + 0x0d4c3db6, 0x03a3, 0x462f, 0xa0, 0xe6, 0x08, 0x92, 0x4c, 0x41, 0xb5, 0xd4} +DEFINE_GUID!{FOLDERID_SearchTemplates, + 0x7e636bfe, 0xdfa9, 0x4d5e, 0xb4, 0x56, 0xd7, 0xb3, 0x98, 0x51, 0xd8, 0xa9} +DEFINE_GUID!{FOLDERID_CameraRollLibrary, + 0x2b20df75, 0x1eda, 0x4039, 0x80, 0x97, 0x38, 0x79, 0x82, 0x27, 0xd5, 0xb7} +DEFINE_GUID!{FOLDERID_SavedPictures, + 0x3b193882, 0xd3ad, 0x4eab, 0x96, 0x5a, 0x69, 0x82, 0x9d, 0x1f, 0xb5, 0x9f} +DEFINE_GUID!{FOLDERID_SavedPicturesLibrary, + 0xe25b5812, 0xbe88, 0x4bd9, 0x94, 0xb0, 0x29, 0x23, 0x34, 0x77, 0xb6, 0xc3} +DEFINE_GUID!{FOLDERID_RetailDemo, + 0x12d4c69e, 0x24ad, 0x4923, 0xbe, 0x19, 0x31, 0x32, 0x1c, 0x43, 0xa7, 0x67} +DEFINE_GUID!{FOLDERID_Device, + 0x1C2AC1DC, 0x4358, 0x4B6C, 0x97, 0x33, 0xAF, 0x21, 0x15, 0x65, 0x76, 0xF0} +DEFINE_GUID!{FOLDERID_DevelopmentFiles, + 0xdbe8e08e, 0x3053, 0x4bbc, 0xb1, 0x83, 0x2a, 0x7b, 0x2b, 0x19, 0x1e, 0x59} +DEFINE_GUID!{FOLDERID_Objects3D, + 0x31c0dd25, 0x9439, 0x4f12, 0xbf, 0x41, 0x7f, 0xf4, 0xed, 0xa3, 0x87, 0x22} +DEFINE_GUID!{FOLDERID_AppCaptures, + 0xedc0fe71, 0x98d8, 0x4f4a, 0xb9, 0x20, 0xc8, 0xdc, 0x13, 0x3c, 0xb1, 0x65} +DEFINE_GUID!{FOLDERID_LocalDocuments, + 0xf42ee2d3, 0x909f, 0x4907, 0x88, 0x71, 0x4c, 0x22, 0xfc, 0x0b, 0xf7, 0x56} +DEFINE_GUID!{FOLDERID_LocalPictures, + 0x0ddd015d, 0xb06c, 0x45d5, 0x8c, 0x4c, 0xf5, 0x97, 0x13, 0x85, 0x46, 0x39} +DEFINE_GUID!{FOLDERID_LocalVideos, + 0x35286a68, 0x3c57, 0x41a1, 0xbb, 0xb1, 0x0e, 0xae, 0x73, 0xd7, 0x6c, 0x95} +DEFINE_GUID!{FOLDERID_LocalMusic, + 0xa0c69a99, 0x21c8, 0x4671, 0x87, 0x03, 0x79, 0x34, 0x16, 0x2f, 0xcf, 0x1d} +DEFINE_GUID!{FOLDERID_LocalDownloads, + 0x7d83ee9b, 0x2244, 0x4e70, 0xb1, 0xf5, 0x53, 0x93, 0x04, 0x2a, 0xf1, 0xe4} +DEFINE_GUID!{FOLDERID_RecordedCalls, + 0x2f8b40c2, 0x83ed, 0x48ee, 0xb3, 0x83, 0xa1, 0xf1, 0x57, 0xec, 0x6f, 0x9a} +DEFINE_GUID!{FOLDERID_AllAppMods, + 0x7ad67899, 0x66af, 0x43ba, 0x91, 0x56, 0x6a, 0xad, 0x42, 0xe6, 0xc5, 0x96} +DEFINE_GUID!{FOLDERID_CurrentAppMods, + 0x3db40b20, 0x2a30, 0x4dbe, 0x91, 0x7e, 0x77, 0x1d, 0xd2, 0x1d, 0xd0, 0x99} +DEFINE_GUID!{FOLDERID_AppDataDesktop, + 0xb2c5e279, 0x7add, 0x439f, 0xb2, 0x8c, 0xc4, 0x1f, 0xe1, 0xbb, 0xf6, 0x72} +DEFINE_GUID!{FOLDERID_AppDataDocuments, + 0x7be16610, 0x1f7f, 0x44ac, 0xbf, 0xf0, 0x83, 0xe1, 0x5f, 0x2f, 0xfc, 0xa1} +DEFINE_GUID!{FOLDERID_AppDataFavorites, + 0x7cfbefbc, 0xde1f, 0x45aa, 0xb8, 0x43, 0xa5, 0x42, 0xac, 0x53, 0x6c, 0xc9} +DEFINE_GUID!{FOLDERID_AppDataProgramData, + 0x559d40a3, 0xa036, 0x40fa, 0xaf, 0x61, 0x84, 0xcb, 0x43, 0x0a, 0x4d, 0x34} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ktmw32.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ktmw32.rs new file mode 100644 index 0000000..c1b8822 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ktmw32.rs @@ -0,0 +1,63 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! FFI bindings to ktmw32. +use shared::guiddef::LPGUID; +use shared::minwindef::{BOOL, DWORD}; +use um::minwinbase::LPSECURITY_ATTRIBUTES; +use um::winnt::{HANDLE, LPWSTR}; +extern "system" { + pub fn CreateTransaction( + lpTransactionAttributes: LPSECURITY_ATTRIBUTES, + UOW: LPGUID, + CreateOptions: DWORD, + IsolationLevel: DWORD, + IsolationFlags: DWORD, + Timeout: DWORD, + Description: LPWSTR, + ) -> HANDLE; + // pub fn OpenTransaction(); + pub fn CommitTransaction( + TransactionHandle: HANDLE, + ) -> BOOL; + // pub fn CommitTransactionAsync(); + pub fn RollbackTransaction( + TransactionHandle: HANDLE, + ) -> BOOL; + // pub fn RollbackTransactionAsync(); + // pub fn GetTransactionId(); + // pub fn GetTransactionInformation(); + // pub fn SetTransactionInformation(); + // pub fn CreateTransactionManager(); + // pub fn OpenTransactionManager(); + // pub fn OpenTransactionManagerById(); + // pub fn RenameTransactionManager(); + // pub fn RollforwardTransactionManager(); + // pub fn RecoverTransactionManager(); + // pub fn GetCurrentClockTransactionManager(); + // pub fn GetTransactionManagerId(); + // pub fn CreateResourceManager(); + // pub fn OpenResourceManager(); + // pub fn RecoverResourceManager(); + // pub fn GetNotificationResourceManager(); + // pub fn GetNotificationResourceManagerAsync(); + // pub fn SetResourceManagerCompletionPort(); + // pub fn CreateEnlistment(); + // pub fn OpenEnlistment(); + // pub fn RecoverEnlistment(); + // pub fn GetEnlistmentRecoveryInformation(); + // pub fn GetEnlistmentId(); + // pub fn SetEnlistmentRecoveryInformation(); + // pub fn PrepareEnlistment(); + // pub fn PrePrepareEnlistment(); + // pub fn CommitEnlistment(); + // pub fn RollbackEnlistment(); + // pub fn PrePrepareComplete(); + // pub fn PrepareComplete(); + // pub fn ReadOnlyEnlistment(); + // pub fn CommitComplete(); + // pub fn RollbackComplete(); + // pub fn SinglePhaseReject(); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/libloaderapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/libloaderapi.rs new file mode 100644 index 0000000..05e3017 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/libloaderapi.rs @@ -0,0 +1,236 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-core-libraryloader-l1 +use ctypes::c_int; +use shared::basetsd::LONG_PTR; +use shared::minwindef::{ + BOOL, DWORD, FARPROC, HGLOBAL, HINSTANCE, HMODULE, HRSRC, LPVOID, UINT, WORD +}; +use um::winnt::{HANDLE, LANGID, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PCWSTR, PVOID}; +pub const GET_MODULE_HANDLE_EX_FLAG_PIN: DWORD = 0x00000001; +pub const GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT: DWORD = 0x00000002; +pub const GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS: DWORD = 0x00000004; +pub const DONT_RESOLVE_DLL_REFERENCES: DWORD = 0x00000001; +pub const LOAD_LIBRARY_AS_DATAFILE: DWORD = 0x00000002; +pub const LOAD_WITH_ALTERED_SEARCH_PATH: DWORD = 0x00000008; +pub const LOAD_IGNORE_CODE_AUTHZ_LEVEL: DWORD = 0x00000010; +pub const LOAD_LIBRARY_AS_IMAGE_RESOURCE: DWORD = 0x00000020; +pub const LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE: DWORD = 0x00000040; +pub const LOAD_LIBRARY_REQUIRE_SIGNED_TARGET: DWORD = 0x00000080; +pub const LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR: DWORD = 0x00000100; +pub const LOAD_LIBRARY_SEARCH_APPLICATION_DIR: DWORD = 0x00000200; +pub const LOAD_LIBRARY_SEARCH_USER_DIRS: DWORD = 0x00000400; +pub const LOAD_LIBRARY_SEARCH_SYSTEM32: DWORD = 0x00000800; +pub const LOAD_LIBRARY_SEARCH_DEFAULT_DIRS: DWORD = 0x00001000; +pub const LOAD_LIBRARY_SAFE_CURRENT_DIRS: DWORD = 0x00002000; +pub const LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER: DWORD = 0x00004000; +pub const LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY: DWORD = 0x00008000; +FN!{stdcall ENUMRESLANGPROCA( + hModule: HMODULE, + lpType: LPCSTR, + lpName: LPCSTR, + wLanguage: WORD, + lParam: LONG_PTR, +) -> BOOL} +FN!{stdcall ENUMRESLANGPROCW( + hModule: HMODULE, + lpType: LPCWSTR, + lpName: LPCWSTR, + wLanguage: WORD, + lParam: LONG_PTR, +) -> BOOL} +FN!{stdcall ENUMRESNAMEPROCA( + hModule: HMODULE, + lpType: LPCSTR, + lpName: LPSTR, + lParam: LONG_PTR, +) -> BOOL} +FN!{stdcall ENUMRESNAMEPROCW( + hModule: HMODULE, + lpType: LPCWSTR, + lpName: LPWSTR, + lParam: LONG_PTR, +) -> BOOL} +FN!{stdcall ENUMRESTYPEPROCA( + hModule: HMODULE, + lpType: LPSTR, + lParam: LONG_PTR, +) -> BOOL} +FN!{stdcall ENUMRESTYPEPROCW( + hModule: HMODULE, + lpType: LPWSTR, + lParam: LONG_PTR, +) -> BOOL} +extern "system" { + pub fn DisableThreadLibraryCalls( + hLibModule: HMODULE, + ) -> BOOL; + pub fn FindResourceExW( + hModule: HMODULE, + lpName: LPCWSTR, + lpType: LPCWSTR, + wLanguage: WORD, + ) -> HRSRC; + pub fn FindStringOrdinal( + dwFindStringOrdinalFlags: DWORD, + lpStringSource: LPCWSTR, + cchSource: c_int, + lpStringValue: LPCWSTR, + cchValue: c_int, + bIgnoreCase: BOOL, + ) -> c_int; + pub fn FreeLibrary( + hLibModule: HMODULE, + ) -> BOOL; + pub fn FreeLibraryAndExitThread( + hLibModule: HMODULE, + dwExitCode: DWORD, + ); + pub fn FreeResource( + hResData: HGLOBAL, + ) -> BOOL; + pub fn GetModuleFileNameA( + hModule: HMODULE, + lpFilename: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetModuleFileNameW( + hModule: HMODULE, + lpFilename: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetModuleHandleA( + lpModuleName: LPCSTR, + ) -> HMODULE; + pub fn GetModuleHandleW( + lpModuleName: LPCWSTR, + ) -> HMODULE; + pub fn GetModuleHandleExA( + dwFlags: DWORD, + lpModuleName: LPCSTR, + phModule: *mut HMODULE, + ) -> BOOL; + pub fn GetModuleHandleExW( + dwFlags: DWORD, + lpModuleName: LPCWSTR, + phModule: *mut HMODULE, + ) -> BOOL; + pub fn GetProcAddress( + hModule: HMODULE, + lpProcName: LPCSTR, + ) -> FARPROC; + pub fn LoadLibraryExA( + lpLibFileName: LPCSTR, + hFile: HANDLE, + dwFlags: DWORD, + ) -> HMODULE; + pub fn LoadLibraryExW( + lpLibFileName: LPCWSTR, + hFile: HANDLE, + dwFlags: DWORD, + ) -> HMODULE; + pub fn LoadResource( + hModule: HMODULE, + hResInfo: HRSRC, + ) -> HGLOBAL; + pub fn LoadStringA( + hInstance: HINSTANCE, + uID: UINT, + lpBuffer: LPSTR, + cchBufferMax: c_int, + ) -> c_int; + pub fn LoadStringW( + hInstance: HINSTANCE, + uID: UINT, + lpBuffer: LPWSTR, + cchBufferMax: c_int, + ) -> c_int; + pub fn LockResource( + hResData: HGLOBAL, + ) -> LPVOID; + pub fn SizeofResource( + hModule: HMODULE, + hResInfo: HRSRC, + ) -> DWORD; +} +pub type DLL_DIRECTORY_COOKIE = PVOID; +pub type PDLL_DIRECTORY_COOKIE = *mut PVOID; +extern "system" { + pub fn AddDllDirectory( + NewDirectory: PCWSTR, + ) -> DLL_DIRECTORY_COOKIE; + pub fn RemoveDllDirectory( + Cookie: DLL_DIRECTORY_COOKIE, + ) -> BOOL; + pub fn SetDefaultDllDirectories( + DirectoryFlags: DWORD, + ) -> BOOL; + pub fn EnumResourceLanguagesExA( + hModule: HMODULE, + lpType: LPCSTR, + lpName: LPCSTR, + lpEnumFunc: ENUMRESLANGPROCA, + lParam: LONG_PTR, + dwFlags: DWORD, + LangId: LANGID, + ) -> BOOL; + pub fn EnumResourceLanguagesExW( + hModule: HMODULE, + lpType: LPCWSTR, + lpName: LPCWSTR, + lpEnumFunc: ENUMRESLANGPROCW, + lParam: LONG_PTR, + dwFlags: DWORD, + LangId: LANGID, + ) -> BOOL; + pub fn EnumResourceNamesExA( + hModule: HMODULE, + lpType: LPCSTR, + lpEnumFunc: ENUMRESNAMEPROCA, + lParam: LONG_PTR, + dwFlags: DWORD, + LangId: LANGID, + ) -> BOOL; + pub fn EnumResourceNamesExW( + hModule: HMODULE, + lpType: LPCWSTR, + lpEnumFunc: ENUMRESNAMEPROCW, + lParam: LONG_PTR, + dwFlags: DWORD, + LangId: LANGID, + ) -> BOOL; + pub fn EnumResourceTypesExA( + hModule: HMODULE, + lpEnumFunc: ENUMRESTYPEPROCA, + lParam: LONG_PTR, + dwFlags: DWORD, + LangId: LANGID, + ) -> BOOL; + pub fn EnumResourceTypesExW( + hModule: HMODULE, + lpEnumFunc: ENUMRESTYPEPROCW, + lParam: LONG_PTR, + dwFlags: DWORD, + LangId: LANGID, + ) -> BOOL; + pub fn FindResourceW( + hModule: HMODULE, + lpName: LPCWSTR, + lpType: LPCWSTR, + ) -> HRSRC; + pub fn LoadLibraryA( + lpFileName: LPCSTR, + ) -> HMODULE; + pub fn LoadLibraryW( + lpFileName: LPCWSTR, + ) -> HMODULE; + pub fn EnumResourceNamesW( + hModule: HMODULE, + lpType: LPCWSTR, + lpEnumFunc: ENUMRESNAMEPROCW, + lParam: LONG_PTR, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmaccess.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmaccess.rs new file mode 100644 index 0000000..3c6c430 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmaccess.rs @@ -0,0 +1,1214 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +// This file contains structures, function prototypes, and definitions +// for the NetUser, NetUserModals, NetGroup, NetAccess, and NetLogon API. +use shared::basetsd::PDWORD_PTR; +use shared::lmcons::{ENCRYPTED_PWLEN, NET_API_STATUS, PARMNUM_BASE_INFOLEVEL, PWLEN}; +use shared::minwindef::{BOOL, BYTE, DWORD, FILETIME, LPBYTE, LPDWORD, LPVOID, PBYTE, ULONG}; +use um::winnt::{BOOLEAN, LONG, LPCWSTR, LPWSTR, PSID, PVOID, PZPWSTR, SID_NAME_USE}; +extern "system" { + pub fn NetUserAdd( + servername: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetUserEnum( + servername: LPCWSTR, + level: DWORD, + filter: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetUserGetInfo( + servername: LPCWSTR, + username: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetUserSetInfo( + servername: LPCWSTR, + username: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetUserDel( + servername: LPCWSTR, + username: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetUserGetGroups( + servername: LPCWSTR, + username: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetUserSetGroups( + servername: LPCWSTR, + username: LPCWSTR, + level: DWORD, + buf: LPBYTE, + num_entries: DWORD, + ) -> NET_API_STATUS; + pub fn NetUserGetLocalGroups( + servername: LPCWSTR, + level: DWORD, + flags: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetUserModalsGet( + servername: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetUserModalsSet( + servername: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetUserChangePassword( + domainname: LPCWSTR, + username: LPCWSTR, + oldpassword: LPCWSTR, + newpassword: LPCWSTR, + ) -> NET_API_STATUS; +} +STRUCT!{struct USER_INFO_0 { + usri0_name: LPWSTR, +}} +pub type PUSER_INFO_0 = *mut USER_INFO_0; +pub type LPUSER_INFO_0 = *mut USER_INFO_0; +STRUCT!{struct USER_INFO_1 { + usri1_name: LPWSTR, + usri1_password: LPWSTR, + usri1_password_age: DWORD, + usri1_priv: DWORD, + usri1_home_dir: LPWSTR, + usri1_comment: LPWSTR, + usri1_flags: DWORD, + usri1_script_path: LPWSTR, +}} +pub type PUSER_INFO_1 = *mut USER_INFO_1; +pub type LPUSER_INFO_1 = *mut USER_INFO_1; +STRUCT!{struct USER_INFO_2 { + usri2_name: LPWSTR, + usri2_password: LPWSTR, + usri2_password_age: DWORD, + usri2_priv: DWORD, + usri2_home_dir: LPWSTR, + usri2_comment: LPWSTR, + usri2_flags: DWORD, + usri2_script_path: LPWSTR, + usri2_auth_flags: DWORD, + usri2_full_name: LPWSTR, + usri2_usr_comment: LPWSTR, + usri2_parms: LPWSTR, + usri2_workstations: LPWSTR, + usri2_last_logon: DWORD, + usri2_last_logoff: DWORD, + usri2_acct_expires: DWORD, + usri2_max_storage: DWORD, + usri2_units_per_week: DWORD, + usri2_logon_hours: PBYTE, + usri2_bad_pw_count: DWORD, + usri2_num_logons: DWORD, + usri2_logon_server: LPWSTR, + usri2_country_code: DWORD, + usri2_code_page: DWORD, +}} +pub type PUSER_INFO_2 = *mut USER_INFO_2; +pub type LPUSER_INFO_2 = *mut USER_INFO_2; +STRUCT!{struct USER_INFO_3 { + usri3_name: LPWSTR, + usri3_password: LPWSTR, + usri3_password_age: DWORD, + usri3_priv: DWORD, + usri3_home_dir: LPWSTR, + usri3_comment: LPWSTR, + usri3_flags: DWORD, + usri3_script_path: LPWSTR, + usri3_auth_flags: DWORD, + usri3_full_name: LPWSTR, + usri3_usr_comment: LPWSTR, + usri3_parms: LPWSTR, + usri3_workstations: LPWSTR, + usri3_last_logon: DWORD, + usri3_last_logoff: DWORD, + usri3_acct_expires: DWORD, + usri3_max_storage: DWORD, + usri3_units_per_week: DWORD, + usri3_logon_hours: PBYTE, + usri3_bad_pw_count: DWORD, + usri3_num_logons: DWORD, + usri3_logon_server: LPWSTR, + usri3_country_code: DWORD, + usri3_code_page: DWORD, + usri3_user_id: DWORD, + usri3_primary_group_id: DWORD, + usri3_profile: LPWSTR, + usri3_home_dir_drive: LPWSTR, + usri3_password_expired: DWORD, +}} +pub type PUSER_INFO_3 = *mut USER_INFO_3; +pub type LPUSER_INFO_3 = *mut USER_INFO_3; +STRUCT!{struct USER_INFO_4 { + usri4_name: LPWSTR, + usri4_password: LPWSTR, + usri4_password_age: DWORD, + usri4_priv: DWORD, + usri4_home_dir: LPWSTR, + usri4_comment: LPWSTR, + usri4_flags: DWORD, + usri4_script_path: LPWSTR, + usri4_auth_flags: DWORD, + usri4_full_name: LPWSTR, + usri4_usr_comment: LPWSTR, + usri4_parms: LPWSTR, + usri4_workstations: LPWSTR, + usri4_last_logon: DWORD, + usri4_last_logoff: DWORD, + usri4_acct_expires: DWORD, + usri4_max_storage: DWORD, + usri4_units_per_week: DWORD, + usri4_logon_hours: PBYTE, + usri4_bad_pw_count: DWORD, + usri4_num_logons: DWORD, + usri4_logon_server: LPWSTR, + usri4_country_code: DWORD, + usri4_code_page: DWORD, + usri4_user_sid: PSID, + usri4_primary_group_id: DWORD, + usri4_profile: LPWSTR, + usri4_home_dir_drive: LPWSTR, + usri4_password_expired: DWORD, +}} +pub type PUSER_INFO_4 = *mut USER_INFO_4; +pub type LPUSER_INFO_4 = *mut USER_INFO_4; +STRUCT!{struct USER_INFO_10 { + usri10_name: LPWSTR, + usri10_comment: LPWSTR, + usri10_usr_comment: LPWSTR, + usri10_full_name: LPWSTR, +}} +pub type PUSER_INFO_10 = *mut USER_INFO_10; +pub type LPUSER_INFO_10 = *mut USER_INFO_10; +STRUCT!{struct USER_INFO_11 { + usri11_name: LPWSTR, + usri11_comment: LPWSTR, + usri11_usr_comment: LPWSTR, + usri11_full_name: LPWSTR, + usri11_priv: DWORD, + usri11_auth_flags: DWORD, + usri11_password_age: DWORD, + usri11_home_dir: LPWSTR, + usri11_parms: LPWSTR, + usri11_last_logon: DWORD, + usri11_last_logoff: DWORD, + usri11_bad_pw_count: DWORD, + usri11_num_logons: DWORD, + usri11_logon_server: LPWSTR, + usri11_country_code: DWORD, + usri11_workstations: LPWSTR, + usri11_max_storage: DWORD, + usri11_units_per_week: DWORD, + usri11_logon_hours: PBYTE, + usri11_code_page: DWORD, +}} +pub type PUSER_INFO_11 = *mut USER_INFO_11; +pub type LPUSER_INFO_11 = *mut USER_INFO_11; +STRUCT!{struct USER_INFO_20 { + usri20_name: LPWSTR, + usri20_full_name: LPWSTR, + usri20_comment: LPWSTR, + usri20_flags: DWORD, + usri20_user_id: DWORD, +}} +pub type PUSER_INFO_20 = *mut USER_INFO_20; +pub type LPUSER_INFO_20 = *mut USER_INFO_20; +STRUCT!{struct USER_INFO_21 { + usri21_password: [BYTE; ENCRYPTED_PWLEN], +}} +pub type PUSER_INFO_21 = *mut USER_INFO_21; +pub type LPUSER_INFO_21 = *mut USER_INFO_21; +STRUCT!{struct USER_INFO_22 { + usri22_name: LPWSTR, + usri22_password: [BYTE; ENCRYPTED_PWLEN], + usri22_password_age: DWORD, + usri22_priv: DWORD, + usri22_home_dir: LPWSTR, + usri22_comment: LPWSTR, + usri22_flags: DWORD, + usri22_script_path: LPWSTR, + usri22_auth_flags: DWORD, + usri22_full_name: LPWSTR, + usri22_usr_comment: LPWSTR, + usri22_parms: LPWSTR, + usri22_workstations: LPWSTR, + usri22_last_logon: DWORD, + usri22_last_logoff: DWORD, + usri22_acct_expires: DWORD, + usri22_max_storage: DWORD, + usri22_units_per_week: DWORD, + usri22_logon_hours: PBYTE, + usri22_bad_pw_count: DWORD, + usri22_num_logons: DWORD, + usri22_logon_server: LPWSTR, + usri22_country_code: DWORD, + usri22_code_page: DWORD, +}} +pub type PUSER_INFO_22 = *mut USER_INFO_22; +pub type LPUSER_INFO_22 = *mut USER_INFO_22; +STRUCT!{struct USER_INFO_23 { + usri23_name: LPWSTR, + usri23_full_name: LPWSTR, + usri23_comment: LPWSTR, + usri23_flags: DWORD, + usri23_user_sid: PSID, +}} +pub type PUSER_INFO_23 = *mut USER_INFO_23; +pub type LPUSER_INFO_23 = *mut USER_INFO_23; +STRUCT!{struct USER_INFO_24 { + usri24_internet_identity: BOOL, + usri24_flags: DWORD, + usri24_internet_provider_name: LPWSTR, + usri24_internet_principal_name: LPWSTR, + usri24_user_sid: PSID, +}} +pub type PUSER_INFO_24 = *mut USER_INFO_24; +pub type LPUSER_INFO_24 = *mut USER_INFO_24; +STRUCT!{struct USER_INFO_1003 { + usri1003_password: LPWSTR, +}} +pub type PUSER_INFO_1003 = *mut USER_INFO_1003; +pub type LPUSER_INFO_1003 = *mut USER_INFO_1003; +STRUCT!{struct USER_INFO_1005 { + usri1005_priv: DWORD, +}} +pub type PUSER_INFO_1005 = *mut USER_INFO_1005; +pub type LPUSER_INFO_1005 = *mut USER_INFO_1005; +STRUCT!{struct USER_INFO_1006 { + usri1006_home_dir: LPWSTR, +}} +pub type PUSER_INFO_1006 = *mut USER_INFO_1006; +pub type LPUSER_INFO_1006 = *mut USER_INFO_1006; +STRUCT!{struct USER_INFO_1007 { + usri1007_comment: LPWSTR, +}} +pub type PUSER_INFO_1007 = *mut USER_INFO_1007; +pub type LPUSER_INFO_1007 = *mut USER_INFO_1007; +STRUCT!{struct USER_INFO_1008 { + usri1008_flags: DWORD, +}} +pub type PUSER_INFO_1008 = *mut USER_INFO_1008; +pub type LPUSER_INFO_1008 = *mut USER_INFO_1008; +STRUCT!{struct USER_INFO_1009 { + usri1009_script_path: LPWSTR, +}} +pub type PUSER_INFO_1009 = *mut USER_INFO_1009; +pub type LPUSER_INFO_1009 = *mut USER_INFO_1009; +STRUCT!{struct USER_INFO_1010 { + usri1010_auth_flags: DWORD, +}} +pub type PUSER_INFO_1010 = *mut USER_INFO_1010; +pub type LPUSER_INFO_1010 = *mut USER_INFO_1010; +STRUCT!{struct USER_INFO_1011 { + usri1011_full_name: LPWSTR, +}} +pub type PUSER_INFO_1011 = *mut USER_INFO_1011; +pub type LPUSER_INFO_1011 = *mut USER_INFO_1011; +STRUCT!{struct USER_INFO_1012 { + usri1012_usr_comment: LPWSTR, +}} +pub type PUSER_INFO_1012 = *mut USER_INFO_1012; +pub type LPUSER_INFO_1012 = *mut USER_INFO_1012; +STRUCT!{struct USER_INFO_1013 { + usri1013_parms: LPWSTR, +}} +pub type PUSER_INFO_1013 = *mut USER_INFO_1013; +pub type LPUSER_INFO_1013 = *mut USER_INFO_1013; +STRUCT!{struct USER_INFO_1014 { + usri1014_workstations: LPWSTR, +}} +pub type PUSER_INFO_1014 = *mut USER_INFO_1014; +pub type LPUSER_INFO_1014 = *mut USER_INFO_1014; +STRUCT!{struct USER_INFO_1017 { + usri1017_acct_expires: DWORD, +}} +pub type PUSER_INFO_1017 = *mut USER_INFO_1017; +pub type LPUSER_INFO_1017 = *mut USER_INFO_1017; +STRUCT!{struct USER_INFO_1018 { + usri1018_max_storage: DWORD, +}} +pub type PUSER_INFO_1018 = *mut USER_INFO_1018; +pub type LPUSER_INFO_1018 = *mut USER_INFO_1018; +STRUCT!{struct USER_INFO_1020 { + usri1020_units_per_week: DWORD, + usri1020_logon_hours: LPBYTE, +}} +pub type PUSER_INFO_1020 = *mut USER_INFO_1020; +pub type LPUSER_INFO_1020 = *mut USER_INFO_1020; +STRUCT!{struct USER_INFO_1023 { + usri1023_logon_server: LPWSTR, +}} +pub type PUSER_INFO_1023 = *mut USER_INFO_1023; +pub type LPUSER_INFO_1023 = *mut USER_INFO_1023; +STRUCT!{struct USER_INFO_1024 { + usri1024_country_code: DWORD, +}} +pub type PUSER_INFO_1024 = *mut USER_INFO_1024; +pub type LPUSER_INFO_1024 = *mut USER_INFO_1024; +STRUCT!{struct USER_INFO_1025 { + usri1025_code_page: DWORD, +}} +pub type PUSER_INFO_1025 = *mut USER_INFO_1025; +pub type LPUSER_INFO_1025 = *mut USER_INFO_1025; +STRUCT!{struct USER_INFO_1051 { + usri1051_primary_group_id: DWORD, +}} +pub type PUSER_INFO_1051 = *mut USER_INFO_1051; +pub type LPUSER_INFO_1051 = *mut USER_INFO_1051; +STRUCT!{struct USER_INFO_1052 { + usri1052_profile: LPWSTR, +}} +pub type PUSER_INFO_1052 = *mut USER_INFO_1052; +pub type LPUSER_INFO_1052 = *mut USER_INFO_1052; +STRUCT!{struct USER_INFO_1053 { + usri1053_home_dir_drive: LPWSTR, +}} +pub type PUSER_INFO_1053 = *mut USER_INFO_1053; +pub type LPUSER_INFO_1053 = *mut USER_INFO_1053; +STRUCT!{struct USER_MODALS_INFO_0 { + usrmod0_min_passwd_len: DWORD, + usrmod0_max_passwd_age: DWORD, + usrmod0_min_passwd_age: DWORD, + usrmod0_force_logoff: DWORD, + usrmod0_password_hist_len: DWORD, +}} +pub type PUSER_MODALS_INFO_0 = *mut USER_MODALS_INFO_0; +pub type LPUSER_MODALS_INFO_0 = *mut USER_MODALS_INFO_0; +STRUCT!{struct USER_MODALS_INFO_1 { + usrmod1_role: DWORD, + usrmod1_primary: LPWSTR, +}} +pub type PUSER_MODALS_INFO_1 = *mut USER_MODALS_INFO_1; +pub type LPUSER_MODALS_INFO_1 = *mut USER_MODALS_INFO_1; +STRUCT!{struct USER_MODALS_INFO_2 { + usrmod2_domain_name: LPWSTR, + usrmod2_domain_id: PSID, +}} +pub type PUSER_MODALS_INFO_2 = *mut USER_MODALS_INFO_2; +pub type LPUSER_MODALS_INFO_2 = *mut USER_MODALS_INFO_2; +STRUCT!{struct USER_MODALS_INFO_3 { + usrmod3_lockout_duration: DWORD, + usrmod3_lockout_observation_window: DWORD, + usrmod3_lockout_threshold: DWORD, +}} +pub type PUSER_MODALS_INFO_3 = *mut USER_MODALS_INFO_3; +pub type LPUSER_MODALS_INFO_3 = *mut USER_MODALS_INFO_3; +STRUCT!{struct USER_MODALS_INFO_1001 { + usrmod1001_min_passwd_len: DWORD, +}} +pub type PUSER_MODALS_INFO_1001 = *mut USER_MODALS_INFO_1001; +pub type LPUSER_MODALS_INFO_1001 = *mut USER_MODALS_INFO_1001; +STRUCT!{struct USER_MODALS_INFO_1002 { + usrmod1002_max_passwd_age: DWORD, +}} +pub type PUSER_MODALS_INFO_1002 = *mut USER_MODALS_INFO_1002; +pub type LPUSER_MODALS_INFO_1002 = *mut USER_MODALS_INFO_1002; +STRUCT!{struct USER_MODALS_INFO_1003 { + usrmod1003_min_passwd_age: DWORD, +}} +pub type PUSER_MODALS_INFO_1003 = *mut USER_MODALS_INFO_1003; +pub type LPUSER_MODALS_INFO_1003 = *mut USER_MODALS_INFO_1003; +STRUCT!{struct USER_MODALS_INFO_1004 { + usrmod1004_force_logoff: DWORD, +}} +pub type PUSER_MODALS_INFO_1004 = *mut USER_MODALS_INFO_1004; +pub type LPUSER_MODALS_INFO_1004 = *mut USER_MODALS_INFO_1004; +STRUCT!{struct USER_MODALS_INFO_1005 { + usrmod1005_password_hist_len: DWORD, +}} +pub type PUSER_MODALS_INFO_1005 = *mut USER_MODALS_INFO_1005; +pub type LPUSER_MODALS_INFO_1005 = *mut USER_MODALS_INFO_1005; +STRUCT!{struct USER_MODALS_INFO_1006 { + usrmod1006_role: DWORD, +}} +pub type PUSER_MODALS_INFO_1006 = *mut USER_MODALS_INFO_1006; +pub type LPUSER_MODALS_INFO_1006 = *mut USER_MODALS_INFO_1006; +STRUCT!{struct USER_MODALS_INFO_1007 { + usrmod1007_primary: LPWSTR, +}} +pub type PUSER_MODALS_INFO_1007 = *mut USER_MODALS_INFO_1007; +pub type LPUSER_MODALS_INFO_1007 = *mut USER_MODALS_INFO_1007; +pub const UF_SCRIPT: DWORD = 0x0001; +pub const UF_ACCOUNTDISABLE: DWORD = 0x0002; +pub const UF_HOMEDIR_REQUIRED: DWORD = 0x0008; +pub const UF_LOCKOUT: DWORD = 0x0010; +pub const UF_PASSWD_NOTREQD: DWORD = 0x0020; +pub const UF_PASSWD_CANT_CHANGE: DWORD = 0x0040; +pub const UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED: DWORD = 0x0080; +pub const UF_TEMP_DUPLICATE_ACCOUNT: DWORD = 0x0100; +pub const UF_NORMAL_ACCOUNT: DWORD = 0x0200; +pub const UF_INTERDOMAIN_TRUST_ACCOUNT: DWORD = 0x0800; +pub const UF_WORKSTATION_TRUST_ACCOUNT: DWORD = 0x1000; +pub const UF_SERVER_TRUST_ACCOUNT: DWORD = 0x2000; +pub const UF_MACHINE_ACCOUNT_MASK: DWORD = UF_INTERDOMAIN_TRUST_ACCOUNT + | UF_WORKSTATION_TRUST_ACCOUNT | UF_SERVER_TRUST_ACCOUNT; +pub const UF_ACCOUNT_TYPE_MASK: DWORD = UF_TEMP_DUPLICATE_ACCOUNT | UF_NORMAL_ACCOUNT + | UF_INTERDOMAIN_TRUST_ACCOUNT | UF_WORKSTATION_TRUST_ACCOUNT | UF_SERVER_TRUST_ACCOUNT; +pub const UF_DONT_EXPIRE_PASSWD: DWORD = 0x10000; +pub const UF_MNS_LOGON_ACCOUNT: DWORD = 0x20000; +pub const UF_SMARTCARD_REQUIRED: DWORD = 0x40000; +pub const UF_TRUSTED_FOR_DELEGATION: DWORD = 0x80000; +pub const UF_NOT_DELEGATED: DWORD = 0x100000; +pub const UF_USE_DES_KEY_ONLY: DWORD = 0x200000; +pub const UF_DONT_REQUIRE_PREAUTH: DWORD = 0x400000; +pub const UF_PASSWORD_EXPIRED: DWORD = 0x800000; +pub const UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION: DWORD = 0x1000000; +pub const UF_NO_AUTH_DATA_REQUIRED: DWORD = 0x2000000; +pub const UF_PARTIAL_SECRETS_ACCOUNT: DWORD = 0x4000000; +pub const UF_USE_AES_KEYS: DWORD = 0x8000000; +pub const UF_SETTABLE_BITS: DWORD = UF_SCRIPT | UF_ACCOUNTDISABLE | UF_LOCKOUT + | UF_HOMEDIR_REQUIRED | UF_PASSWD_NOTREQD | UF_PASSWD_CANT_CHANGE | UF_ACCOUNT_TYPE_MASK + | UF_DONT_EXPIRE_PASSWD | UF_MNS_LOGON_ACCOUNT | UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED + | UF_SMARTCARD_REQUIRED | UF_TRUSTED_FOR_DELEGATION | UF_NOT_DELEGATED | UF_USE_DES_KEY_ONLY + | UF_DONT_REQUIRE_PREAUTH | UF_PASSWORD_EXPIRED | UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION + | UF_NO_AUTH_DATA_REQUIRED | UF_USE_AES_KEYS | UF_PARTIAL_SECRETS_ACCOUNT; +pub const FILTER_TEMP_DUPLICATE_ACCOUNT: DWORD = 0x0001; +pub const FILTER_NORMAL_ACCOUNT: DWORD = 0x0002; +pub const FILTER_INTERDOMAIN_TRUST_ACCOUNT: DWORD = 0x0008; +pub const FILTER_WORKSTATION_TRUST_ACCOUNT: DWORD = 0x0010; +pub const FILTER_SERVER_TRUST_ACCOUNT: DWORD = 0x0020; +pub const LG_INCLUDE_INDIRECT: DWORD = 0x0001; +pub const AF_OP_PRINT: DWORD = 0x1; +pub const AF_OP_COMM: DWORD = 0x2; +pub const AF_OP_SERVER: DWORD = 0x4; +pub const AF_OP_ACCOUNTS: DWORD = 0x8; +pub const AF_SETTABLE_BITS: DWORD = AF_OP_PRINT | AF_OP_COMM | AF_OP_SERVER | AF_OP_ACCOUNTS; +pub const UAS_ROLE_STANDALONE: DWORD = 0; +pub const UAS_ROLE_MEMBER: DWORD = 1; +pub const UAS_ROLE_BACKUP: DWORD = 2; +pub const UAS_ROLE_PRIMARY: DWORD = 3; +pub const USER_NAME_PARMNUM: DWORD = 1; +pub const USER_PASSWORD_PARMNUM: DWORD = 3; +pub const USER_PASSWORD_AGE_PARMNUM: DWORD = 4; +pub const USER_PRIV_PARMNUM: DWORD = 5; +pub const USER_HOME_DIR_PARMNUM: DWORD = 6; +pub const USER_COMMENT_PARMNUM: DWORD = 7; +pub const USER_FLAGS_PARMNUM: DWORD = 8; +pub const USER_SCRIPT_PATH_PARMNUM: DWORD = 9; +pub const USER_AUTH_FLAGS_PARMNUM: DWORD = 10; +pub const USER_FULL_NAME_PARMNUM: DWORD = 11; +pub const USER_USR_COMMENT_PARMNUM: DWORD = 12; +pub const USER_PARMS_PARMNUM: DWORD = 13; +pub const USER_WORKSTATIONS_PARMNUM: DWORD = 14; +pub const USER_LAST_LOGON_PARMNUM: DWORD = 15; +pub const USER_LAST_LOGOFF_PARMNUM: DWORD = 16; +pub const USER_ACCT_EXPIRES_PARMNUM: DWORD = 17; +pub const USER_MAX_STORAGE_PARMNUM: DWORD = 18; +pub const USER_UNITS_PER_WEEK_PARMNUM: DWORD = 19; +pub const USER_LOGON_HOURS_PARMNUM: DWORD = 20; +pub const USER_PAD_PW_COUNT_PARMNUM: DWORD = 21; +pub const USER_NUM_LOGONS_PARMNUM: DWORD = 22; +pub const USER_LOGON_SERVER_PARMNUM: DWORD = 23; +pub const USER_COUNTRY_CODE_PARMNUM: DWORD = 24; +pub const USER_CODE_PAGE_PARMNUM: DWORD = 25; +pub const USER_PRIMARY_GROUP_PARMNUM: DWORD = 51; +pub const USER_PROFILE: DWORD = 52; +pub const USER_PROFILE_PARMNUM: DWORD = 52; +pub const USER_HOME_DIR_DRIVE_PARMNUM: DWORD = 53; +pub const USER_NAME_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_NAME_PARMNUM; +pub const USER_PASSWORD_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_PASSWORD_PARMNUM; +pub const USER_PASSWORD_AGE_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_PASSWORD_AGE_PARMNUM; +pub const USER_PRIV_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_PRIV_PARMNUM; +pub const USER_HOME_DIR_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_HOME_DIR_PARMNUM; +pub const USER_COMMENT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_COMMENT_PARMNUM; +pub const USER_FLAGS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_FLAGS_PARMNUM; +pub const USER_SCRIPT_PATH_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_SCRIPT_PATH_PARMNUM; +pub const USER_AUTH_FLAGS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_AUTH_FLAGS_PARMNUM; +pub const USER_FULL_NAME_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_FULL_NAME_PARMNUM; +pub const USER_USR_COMMENT_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_USR_COMMENT_PARMNUM; +pub const USER_PARMS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_PARMS_PARMNUM; +pub const USER_WORKSTATIONS_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_WORKSTATIONS_PARMNUM; +pub const USER_LAST_LOGON_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_LAST_LOGON_PARMNUM; +pub const USER_LAST_LOGOFF_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_LAST_LOGOFF_PARMNUM; +pub const USER_ACCT_EXPIRES_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_ACCT_EXPIRES_PARMNUM; +pub const USER_MAX_STORAGE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_MAX_STORAGE_PARMNUM; +pub const USER_UNITS_PER_WEEK_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_UNITS_PER_WEEK_PARMNUM; +pub const USER_LOGON_HOURS_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_LOGON_HOURS_PARMNUM; +pub const USER_PAD_PW_COUNT_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_PAD_PW_COUNT_PARMNUM; +pub const USER_NUM_LOGONS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_NUM_LOGONS_PARMNUM; +pub const USER_LOGON_SERVER_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_LOGON_SERVER_PARMNUM; +pub const USER_COUNTRY_CODE_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_COUNTRY_CODE_PARMNUM; +pub const USER_CODE_PAGE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + USER_CODE_PAGE_PARMNUM; +pub const USER_PRIMARY_GROUP_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_PRIMARY_GROUP_PARMNUM; +pub const USER_HOME_DIR_DRIVE_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + USER_HOME_DIR_DRIVE_PARMNUM; +pub const NULL_USERSETINFO_PASSWD: &'static str = " "; +pub const TIMEQ_FOREVER: DWORD = -1i32 as u32; +pub const USER_MAXSTORAGE_UNLIMITED: DWORD = -1i32 as u32; +pub const USER_NO_LOGOFF: DWORD = -1i32 as u32; +pub const UNITS_PER_DAY: DWORD = 24; +pub const UNITS_PER_WEEK: DWORD = UNITS_PER_DAY * 7; +pub const USER_PRIV_MASK: DWORD = 0x3; +pub const USER_PRIV_GUEST: DWORD = 0; +pub const USER_PRIV_USER: DWORD = 1; +pub const USER_PRIV_ADMIN: DWORD = 2; +pub const MAX_PASSWD_LEN: DWORD = PWLEN; +pub const DEF_MIN_PWLEN: DWORD = 6; +pub const DEF_PWUNIQUENESS: DWORD = 5; +pub const DEF_MAX_PWHIST: DWORD = 8; +pub const DEF_MAX_PWAGE: DWORD = TIMEQ_FOREVER; +pub const DEF_MIN_PWAGE: DWORD = 0; +pub const DEF_FORCE_LOGOFF: DWORD = 0xffffffff; +pub const DEF_MAX_BADPW: DWORD = 0; +pub const ONE_DAY: DWORD = 1 * 24 * 3600; +pub const VALIDATED_LOGON: DWORD = 0; +pub const PASSWORD_EXPIRED: DWORD = 2; +pub const NON_VALIDATED_LOGON: DWORD = 3; +pub const VALID_LOGOFF: DWORD = 1; +pub const MODALS_MIN_PASSWD_LEN_PARMNUM: DWORD = 1; +pub const MODALS_MAX_PASSWD_AGE_PARMNUM: DWORD = 2; +pub const MODALS_MIN_PASSWD_AGE_PARMNUM: DWORD = 3; +pub const MODALS_FORCE_LOGOFF_PARMNUM: DWORD = 4; +pub const MODALS_PASSWD_HIST_LEN_PARMNUM: DWORD = 5; +pub const MODALS_ROLE_PARMNUM: DWORD = 6; +pub const MODALS_PRIMARY_PARMNUM: DWORD = 7; +pub const MODALS_DOMAIN_NAME_PARMNUM: DWORD = 8; +pub const MODALS_DOMAIN_ID_PARMNUM: DWORD = 9; +pub const MODALS_LOCKOUT_DURATION_PARMNUM: DWORD = 10; +pub const MODALS_LOCKOUT_OBSERVATION_WINDOW_PARMNUM: DWORD = 11; +pub const MODALS_LOCKOUT_THRESHOLD_PARMNUM: DWORD = 12; +pub const MODALS_MIN_PASSWD_LEN_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + MODALS_MIN_PASSWD_LEN_PARMNUM; +pub const MODALS_MAX_PASSWD_AGE_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + MODALS_MAX_PASSWD_AGE_PARMNUM; +pub const MODALS_MIN_PASSWD_AGE_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + MODALS_MIN_PASSWD_AGE_PARMNUM; +pub const MODALS_FORCE_LOGOFF_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + MODALS_FORCE_LOGOFF_PARMNUM; +pub const MODALS_PASSWD_HIST_LEN_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + MODALS_PASSWD_HIST_LEN_PARMNUM; +pub const MODALS_ROLE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + MODALS_ROLE_PARMNUM; +pub const MODALS_PRIMARY_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + MODALS_PRIMARY_PARMNUM; +pub const MODALS_DOMAIN_NAME_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + MODALS_DOMAIN_NAME_PARMNUM; +pub const MODALS_DOMAIN_ID_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + MODALS_DOMAIN_ID_PARMNUM; +extern "system" { + pub fn NetGroupAdd( + servername: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetGroupAddUser( + servername: LPCWSTR, + GroupName: LPCWSTR, + username: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetGroupEnum( + servername: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resume_handle: PDWORD_PTR, + ) -> NET_API_STATUS; + pub fn NetGroupGetInfo( + servername: LPCWSTR, + groupname: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetGroupSetInfo( + servername: LPCWSTR, + groupname: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetGroupDel( + servername: LPCWSTR, + groupname: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetGroupDelUser( + servername: LPCWSTR, + GroupName: LPCWSTR, + Username: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetGroupGetUsers( + servername: LPCWSTR, + groupname: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + ResumeHandle: PDWORD_PTR, + ) -> NET_API_STATUS; + pub fn NetGroupSetUsers( + servername: LPCWSTR, + groupname: LPCWSTR, + level: DWORD, + buf: LPBYTE, + totalentries: DWORD, + ) -> NET_API_STATUS; +} +STRUCT!{struct GROUP_INFO_0 { + grpi0_name: LPWSTR, +}} +pub type PGROUP_INFO_0 = *mut GROUP_INFO_0; +pub type LPGROUP_INFO_0 = *mut GROUP_INFO_0; +STRUCT!{struct GROUP_INFO_1 { + grpi1_name: LPWSTR, + grpi1_comment: LPWSTR, +}} +pub type PGROUP_INFO_1 = *mut GROUP_INFO_1; +pub type LPGROUP_INFO_1 = *mut GROUP_INFO_1; +STRUCT!{struct GROUP_INFO_2 { + grpi2_name: LPWSTR, + grpi2_comment: LPWSTR, + grpi2_group_id: DWORD, + grpi2_attributes: DWORD, +}} +pub type PGROUP_INFO_2 = *mut GROUP_INFO_2; +STRUCT!{struct GROUP_INFO_3 { + grpi3_name: LPWSTR, + grpi3_comment: LPWSTR, + grpi3_group_sid: PSID, + grpi3_attributes: DWORD, +}} +pub type PGROUP_INFO_3 = *mut GROUP_INFO_3; +STRUCT!{struct GROUP_INFO_1002 { + grpi1002_comment: LPWSTR, +}} +pub type PGROUP_INFO_1002 = *mut GROUP_INFO_1002; +pub type LPGROUP_INFO_1002 = *mut GROUP_INFO_1002; +STRUCT!{struct GROUP_INFO_1005 { + grpi1005_attributes: DWORD, +}} +pub type PGROUP_INFO_1005 = *mut GROUP_INFO_1005; +pub type LPGROUP_INFO_1005 = *mut GROUP_INFO_1005; +STRUCT!{struct GROUP_USERS_INFO_0 { + grui0_name: LPWSTR, +}} +pub type PGROUP_USERS_INFO_0 = *mut GROUP_USERS_INFO_0; +pub type LPGROUP_USERS_INFO_0 = *mut GROUP_USERS_INFO_0; +STRUCT!{struct GROUP_USERS_INFO_1 { + grui1_name: LPWSTR, + grui1_attributes: DWORD, +}} +pub type PGROUP_USERS_INFO_1 = *mut GROUP_USERS_INFO_1; +pub type LPGROUP_USERS_INFO_1 = *mut GROUP_USERS_INFO_1; +pub const GROUPIDMASK: DWORD = 0x8000; +pub const GROUP_SPECIALGRP_USERS: &'static str = "USERS"; +pub const GROUP_SPECIALGRP_ADMINS: &'static str = "ADMINS"; +pub const GROUP_SPECIALGRP_GUESTS: &'static str = "GUESTS"; +pub const GROUP_SPECIALGRP_LOCAL: &'static str = "LOCAL"; +pub const GROUP_ALL_PARMNUM: DWORD = 0; +pub const GROUP_NAME_PARMNUM: DWORD = 1; +pub const GROUP_COMMENT_PARMNUM: DWORD = 2; +pub const GROUP_ATTRIBUTES_PARMNUM: DWORD = 3; +pub const GROUP_ALL_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + GROUP_ALL_PARMNUM; +pub const GROUP_NAME_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + GROUP_NAME_PARMNUM; +pub const GROUP_COMMENT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + GROUP_COMMENT_PARMNUM; +pub const GROUP_ATTRIBUTES_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + GROUP_ATTRIBUTES_PARMNUM; +extern "system" { + pub fn NetLocalGroupAdd( + servername: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetLocalGroupAddMember( + servername: LPCWSTR, + groupname: LPCWSTR, + membersid: PSID, + ) -> NET_API_STATUS; + pub fn NetLocalGroupEnum( + servername: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: PDWORD_PTR, + ) -> NET_API_STATUS; + pub fn NetLocalGroupGetInfo( + servername: LPCWSTR, + groupname: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetLocalGroupSetInfo( + servername: LPCWSTR, + groupname: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetLocalGroupDel( + servername: LPCWSTR, + groupname: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetLocalGroupDelMember( + servername: LPCWSTR, + groupname: LPCWSTR, + membersid: PSID, + ) -> NET_API_STATUS; + pub fn NetLocalGroupGetMembers( + servername: LPCWSTR, + localgroupname: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: PDWORD_PTR, + ) -> NET_API_STATUS; + pub fn NetLocalGroupSetMembers( + servername: LPCWSTR, + groupname: LPCWSTR, + level: DWORD, + buf: LPBYTE, + totalentries: DWORD, + ) -> NET_API_STATUS; + pub fn NetLocalGroupAddMembers( + servername: LPCWSTR, + groupname: LPCWSTR, + level: DWORD, + buf: LPBYTE, + totalentries: DWORD, + ) -> NET_API_STATUS; + pub fn NetLocalGroupDelMembers( + servername: LPCWSTR, + groupname: LPCWSTR, + level: DWORD, + buf: LPBYTE, + totalentries: DWORD, + ) -> NET_API_STATUS; +} +STRUCT!{struct LOCALGROUP_INFO_0 { + lgrpi0_name: LPWSTR, +}} +pub type PLOCALGROUP_INFO_0 = *mut LOCALGROUP_INFO_0; +pub type LPLOCALGROUP_INFO_0 = *mut LOCALGROUP_INFO_0; +STRUCT!{struct LOCALGROUP_INFO_1 { + lgrpi1_name: LPWSTR, + lgrpi1_comment: LPWSTR, +}} +pub type PLOCALGROUP_INFO_1 = *mut LOCALGROUP_INFO_1; +pub type LPLOCALGROUP_INFO_1 = *mut LOCALGROUP_INFO_1; +STRUCT!{struct LOCALGROUP_INFO_1002 { + lgrpi1002_comment: LPWSTR, +}} +pub type PLOCALGROUP_INFO_1002 = *mut LOCALGROUP_INFO_1002; +pub type LPLOCALGROUP_INFO_1002 = *mut LOCALGROUP_INFO_1002; +STRUCT!{struct LOCALGROUP_MEMBERS_INFO_0 { + lgrmi0_sid: PSID, +}} +pub type PLOCALGROUP_MEMBERS_INFO_0 = *mut LOCALGROUP_MEMBERS_INFO_0; +pub type LPLOCALGROUP_MEMBERS_INFO_0 = *mut LOCALGROUP_MEMBERS_INFO_0; +STRUCT!{struct LOCALGROUP_MEMBERS_INFO_1 { + lgrmi1_sid: PSID, + lgrmi1_sidusage: SID_NAME_USE, + lgrmi1_name: LPWSTR, +}} +pub type PLOCALGROUP_MEMBERS_INFO_1 = *mut LOCALGROUP_MEMBERS_INFO_1; +pub type LPLOCALGROUP_MEMBERS_INFO_1 = *mut LOCALGROUP_MEMBERS_INFO_1; +STRUCT!{struct LOCALGROUP_MEMBERS_INFO_2 { + lgrmi2_sid: PSID, + lgrmi2_sidusage: SID_NAME_USE, + lgrmi2_domainandname: LPWSTR, +}} +pub type PLOCALGROUP_MEMBERS_INFO_2 = *mut LOCALGROUP_MEMBERS_INFO_2; +pub type LPLOCALGROUP_MEMBERS_INFO_2 = *mut LOCALGROUP_MEMBERS_INFO_2; +STRUCT!{struct LOCALGROUP_MEMBERS_INFO_3 { + lgrmi3_domainandname: LPWSTR, +}} +pub type PLOCALGROUP_MEMBERS_INFO_3 = *mut LOCALGROUP_MEMBERS_INFO_3; +pub type LPLOCALGROUP_MEMBERS_INFO_3 = *mut LOCALGROUP_MEMBERS_INFO_3; +STRUCT!{struct LOCALGROUP_USERS_INFO_0 { + lgrui0_name: LPWSTR, +}} +pub type PLOCALGROUP_USERS_INFO_0 = *mut LOCALGROUP_USERS_INFO_0; +pub type LPLOCALGROUP_USERS_INFO_0 = *mut LOCALGROUP_USERS_INFO_0; +pub const LOCALGROUP_NAME_PARMNUM: DWORD = 1; +pub const LOCALGROUP_COMMENT_PARMNUM: DWORD = 2; +extern "system" { + pub fn NetQueryDisplayInformation( + ServerName: LPCWSTR, + Level: DWORD, + Index: DWORD, + EntriesRequested: DWORD, + PreferredMaximumLength: DWORD, + ReturnedEntryCount: LPDWORD, + SortedBuffer: *mut PVOID, + ) -> NET_API_STATUS; + pub fn NetGetDisplayInformationIndex( + ServerName: LPCWSTR, + Level: DWORD, + Prefix: LPCWSTR, + Index: LPDWORD, + ) -> NET_API_STATUS; +} +STRUCT!{struct NET_DISPLAY_USER { + usri1_name: LPWSTR, + usri1_comment: LPWSTR, + usri1_flags: DWORD, + usri1_full_name: LPWSTR, + usri1_user_id: DWORD, + usri1_next_index: DWORD, +}} +pub type PNET_DISPLAY_USER = *mut NET_DISPLAY_USER; +STRUCT!{struct NET_DISPLAY_MACHINE { + usri2_name: LPWSTR, + usri2_comment: LPWSTR, + usri2_flags: DWORD, + usri2_user_id: DWORD, + usri2_next_index: DWORD, +}} +pub type PNET_DISPLAY_MACHINE = *mut NET_DISPLAY_MACHINE; +STRUCT!{struct NET_DISPLAY_GROUP { + usri3_name: LPWSTR, + usri3_comment: LPWSTR, + grpi3_group_id: DWORD, + grpi3_attributes: DWORD, + grpi3_next_index: DWORD, +}} +pub type PNET_DISPLAY_GROUP = *mut NET_DISPLAY_GROUP; +extern "system" { + pub fn NetAccessAdd( + servername: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetAccessEnum( + servername: LPCWSTR, + BasePath: LPCWSTR, + Recursive: DWORD, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resume_handle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetAccessGetInfo( + servername: LPCWSTR, + resource: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetAccessSetInfo( + servername: LPCWSTR, + resource: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetAccessDel( + servername: LPCWSTR, + resource: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetAccessGetUserPerms( + servername: LPCWSTR, + UGname: LPCWSTR, + resource: LPCWSTR, + Perms: LPDWORD, + ) -> NET_API_STATUS; +} +STRUCT!{struct ACCESS_INFO_0 { + acc0_resource_name: LPWSTR, +}} +pub type PACCESS_INFO_0 = *mut ACCESS_INFO_0; +pub type LPACCESS_INFO_0 = *mut ACCESS_INFO_0; +STRUCT!{struct ACCESS_INFO_1 { + acc1_resource_name: LPWSTR, + acc1_attr: DWORD, + acc1_count: DWORD, +}} +pub type PACCESS_INFO_1 = *mut ACCESS_INFO_1; +pub type LPACCESS_INFO_1 = *mut ACCESS_INFO_1; +STRUCT!{struct ACCESS_INFO_1002 { + acc1002_attr: DWORD, +}} +pub type PACCESS_INFO_1002 = *mut ACCESS_INFO_1002; +pub type LPACCESS_INFO_1002 = *mut ACCESS_INFO_1002; +STRUCT!{struct ACCESS_LIST { + acl_ugname: LPWSTR, + acl_access: DWORD, +}} +pub type PACCESS_LIST = *mut ACCESS_LIST; +pub type LPACCESS_LIST = *mut ACCESS_LIST; +pub const MAXPERMENTRIES: DWORD = 64; +pub const ACCESS_NONE: DWORD = 0; +pub const ACCESS_ALL: DWORD = ACCESS_READ | ACCESS_WRITE | ACCESS_CREATE | ACCESS_EXEC + | ACCESS_DELETE | ACCESS_ATRIB | ACCESS_PERM; +pub const ACCESS_READ: DWORD = 0x01; +pub const ACCESS_WRITE: DWORD = 0x02; +pub const ACCESS_CREATE: DWORD = 0x04; +pub const ACCESS_EXEC: DWORD = 0x08; +pub const ACCESS_DELETE: DWORD = 0x10; +pub const ACCESS_ATRIB: DWORD = 0x20; +pub const ACCESS_PERM: DWORD = 0x40; +pub const ACCESS_GROUP: DWORD = 0x8000; +pub const ACCESS_AUDIT: DWORD = 0x1; +pub const ACCESS_SUCCESS_OPEN: DWORD = 0x10; +pub const ACCESS_SUCCESS_WRITE: DWORD = 0x20; +pub const ACCESS_SUCCESS_DELETE: DWORD = 0x40; +pub const ACCESS_SUCCESS_ACL: DWORD = 0x80; +pub const ACCESS_SUCCESS_MASK: DWORD = 0xF0; +pub const ACCESS_FAIL_OPEN: DWORD = 0x100; +pub const ACCESS_FAIL_WRITE: DWORD = 0x200; +pub const ACCESS_FAIL_DELETE: DWORD = 0x400; +pub const ACCESS_FAIL_ACL: DWORD = 0x800; +pub const ACCESS_FAIL_MASK: DWORD = 0xF00; +pub const ACCESS_FAIL_SHIFT: DWORD = 4; +pub const ACCESS_RESOURCE_NAME_PARMNUM: DWORD = 1; +pub const ACCESS_ATTR_PARMNUM: DWORD = 2; +pub const ACCESS_COUNT_PARMNUM: DWORD = 3; +pub const ACCESS_ACCESS_LIST_PARMNUM: DWORD = 4; +pub const ACCESS_RESOURCE_NAME_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + ACCESS_RESOURCE_NAME_PARMNUM; +pub const ACCESS_ATTR_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + ACCESS_ATTR_PARMNUM; +pub const ACCESS_COUNT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + ACCESS_COUNT_PARMNUM; +pub const ACCESS_ACCESS_LIST_INFOLEVEL: DWORD = + PARMNUM_BASE_INFOLEVEL + ACCESS_ACCESS_LIST_PARMNUM; +pub const ACCESS_LETTERS: &'static str = "RWCXDAP "; +ENUM!{enum NET_VALIDATE_PASSWORD_TYPE { + NetValidateAuthentication = 1, + NetValidatePasswordChange, + NetValidatePasswordReset, +}} +pub type PNET_VALIDATE_PASSWORD_TYPE = *mut NET_VALIDATE_PASSWORD_TYPE; +STRUCT!{struct NET_VALIDATE_PASSWORD_HASH { + Length: ULONG, + Hash: LPBYTE, +}} +pub type PNET_VALIDATE_PASSWORD_HASH = *mut NET_VALIDATE_PASSWORD_HASH; +pub const NET_VALIDATE_PASSWORD_LAST_SET: ULONG = 0x00000001; +pub const NET_VALIDATE_BAD_PASSWORD_TIME: ULONG = 0x00000002; +pub const NET_VALIDATE_LOCKOUT_TIME: ULONG = 0x00000004; +pub const NET_VALIDATE_BAD_PASSWORD_COUNT: ULONG = 0x00000008; +pub const NET_VALIDATE_PASSWORD_HISTORY_LENGTH: ULONG = 0x00000010; +pub const NET_VALIDATE_PASSWORD_HISTORY: ULONG = 0x00000020; +STRUCT!{struct NET_VALIDATE_PERSISTED_FIELDS { + PresentFields: ULONG, + PasswordLastSet: FILETIME, + BadPasswordTime: FILETIME, + LockoutTime: FILETIME, + BadPasswordCount: ULONG, + PasswordHistoryLength: ULONG, + PasswordHistory: PNET_VALIDATE_PASSWORD_HASH, +}} +pub type PNET_VALIDATE_PERSISTED_FIELDS = *mut NET_VALIDATE_PERSISTED_FIELDS; +STRUCT!{struct NET_VALIDATE_OUTPUT_ARG { + ChangedPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, + ValidationStatus: NET_API_STATUS, +}} +pub type PNET_VALIDATE_OUTPUT_ARG = *mut NET_VALIDATE_OUTPUT_ARG; +STRUCT!{struct NET_VALIDATE_AUTHENTICATION_INPUT_ARG { + InputPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, + PasswordMatched: BOOLEAN, +}} +pub type PNET_VALIDATE_AUTHENTICATION_INPUT_ARG = *mut NET_VALIDATE_AUTHENTICATION_INPUT_ARG; +STRUCT!{struct NET_VALIDATE_PASSWORD_CHANGE_INPUT_ARG { + InputPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, + ClearPassword: LPWSTR, + UserAccountName: LPWSTR, + HashedPassword: NET_VALIDATE_PASSWORD_HASH, + PasswordMatch: BOOLEAN, +}} +pub type PNET_VALIDATE_PASSWORD_CHANGE_INPUT_ARG = *mut NET_VALIDATE_PASSWORD_CHANGE_INPUT_ARG; +STRUCT!{struct NET_VALIDATE_PASSWORD_RESET_INPUT_ARG { + InputPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, + ClearPassword: LPWSTR, + UserAccountName: LPWSTR, + HashedPassword: NET_VALIDATE_PASSWORD_HASH, + PasswordMustChangeAtNextLogon: BOOLEAN, + ClearLockout: BOOLEAN, +}} +pub type PNET_VALIDATE_PASSWORD_RESET_INPUT_ARG = *mut NET_VALIDATE_PASSWORD_RESET_INPUT_ARG; +extern "system" { + pub fn NetValidatePasswordPolicy( + ServerName: LPCWSTR, + Qualifier: LPVOID, + ValidationType: NET_VALIDATE_PASSWORD_TYPE, + InputArg: LPVOID, + OutputArg: *mut LPVOID, + ) -> NET_API_STATUS; + pub fn NetValidatePasswordPolicyFree( + OutputArg: *mut LPVOID, + ) -> NET_API_STATUS; + pub fn NetGetDCName( + servername: LPCWSTR, + domainname: LPCWSTR, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetGetAnyDCName( + servername: LPCWSTR, + domainname: LPCWSTR, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn I_NetLogonControl( + ServerName: LPCWSTR, + FunctionCode: DWORD, + QueryLevel: DWORD, + Buffer: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn I_NetLogonControl2( + ServerName: LPCWSTR, + FunctionCode: DWORD, + QueryLevel: DWORD, + Data: LPBYTE, + Buffer: *mut LPBYTE, + ) -> NET_API_STATUS; +} +pub type NTSTATUS = LONG; +pub type PNTSTATUS = *mut LONG; +extern "system" { + pub fn NetEnumerateTrustedDomains( + ServerName: LPWSTR, + DomainNames: *mut LPWSTR, + ) -> NTSTATUS; +} +pub const NETLOGON_CONTROL_QUERY: DWORD = 1; +pub const NETLOGON_CONTROL_REPLICATE: DWORD = 2; +pub const NETLOGON_CONTROL_SYNCHRONIZE: DWORD = 3; +pub const NETLOGON_CONTROL_PDC_REPLICATE: DWORD = 4; +pub const NETLOGON_CONTROL_REDISCOVER: DWORD = 5; +pub const NETLOGON_CONTROL_TC_QUERY: DWORD = 6; +pub const NETLOGON_CONTROL_TRANSPORT_NOTIFY: DWORD = 7; +pub const NETLOGON_CONTROL_FIND_USER: DWORD = 8; +pub const NETLOGON_CONTROL_CHANGE_PASSWORD: DWORD = 9; +pub const NETLOGON_CONTROL_TC_VERIFY: DWORD = 10; +pub const NETLOGON_CONTROL_FORCE_DNS_REG: DWORD = 11; +pub const NETLOGON_CONTROL_QUERY_DNS_REG: DWORD = 12; +pub const NETLOGON_CONTROL_QUERY_ENC_TYPES: DWORD = 13; +pub const NETLOGON_CONTROL_UNLOAD_NETLOGON_DLL: DWORD = 0xFFFB; +pub const NETLOGON_CONTROL_BACKUP_CHANGE_LOG: DWORD = 0xFFFC; +pub const NETLOGON_CONTROL_TRUNCATE_LOG: DWORD = 0xFFFD; +pub const NETLOGON_CONTROL_SET_DBFLAG: DWORD = 0xFFFE; +pub const NETLOGON_CONTROL_BREAKPOINT: DWORD = 0xFFFF; +STRUCT!{struct NETLOGON_INFO_1 { + netlog1_flags: DWORD, + netlog1_pdc_connection_status: NET_API_STATUS, +}} +pub type PNETLOGON_INFO_1 = *mut NETLOGON_INFO_1; +STRUCT!{struct NETLOGON_INFO_2 { + netlog2_flags: DWORD, + netlog2_pdc_connection_status: NET_API_STATUS, + netlog2_trusted_dc_name: LPWSTR, + netlog2_tc_connection_status: NET_API_STATUS, +}} +pub type PNETLOGON_INFO_2 = *mut NETLOGON_INFO_2; +STRUCT!{struct NETLOGON_INFO_3 { + netlog3_flags: DWORD, + netlog3_logon_attempts: DWORD, + netlog3_reserved1: DWORD, + netlog3_reserved2: DWORD, + netlog3_reserved3: DWORD, + netlog3_reserved4: DWORD, + netlog3_reserved5: DWORD, +}} +pub type PNETLOGON_INFO_3 = *mut NETLOGON_INFO_3; +STRUCT!{struct NETLOGON_INFO_4 { + netlog4_trusted_dc_name: LPWSTR, + netlog4_trusted_domain_name: LPWSTR, +}} +pub type PNETLOGON_INFO_4 = *mut NETLOGON_INFO_4; +pub const NETLOGON_REPLICATION_NEEDED: DWORD = 0x01; +pub const NETLOGON_REPLICATION_IN_PROGRESS: DWORD = 0x02; +pub const NETLOGON_FULL_SYNC_REPLICATION: DWORD = 0x04; +pub const NETLOGON_REDO_NEEDED: DWORD = 0x08; +pub const NETLOGON_HAS_IP: DWORD = 0x10; +pub const NETLOGON_HAS_TIMESERV: DWORD = 0x20; +pub const NETLOGON_DNS_UPDATE_FAILURE: DWORD = 0x40; +pub const NETLOGON_VERIFY_STATUS_RETURNED: DWORD = 0x80; +pub const SERVICE_ACCOUNT_PASSWORD: &'static str = "_SA_{262E99C9-6160-4871-ACEC-4E61736B6F21}"; +pub const SERVICE_ACCOUNT_SECRET_PREFIX: &'static str + = "_SC_{262E99C9-6160-4871-ACEC-4E61736B6F21}_"; +DEFINE_GUID!{ServiceAccountPasswordGUID, + 0x262E99C9, 0x6160, 0x4871, 0xAC, 0xEC, 0x4E, 0x61, 0x73, 0x6B, 0x6F, 0x21} +extern "system" { + pub fn NetAddServiceAccount( + ServerName: LPWSTR, + AccountName: LPWSTR, + Password: LPWSTR, + Flags: DWORD, + ) -> NTSTATUS; +} +pub const SERVICE_ACCOUNT_FLAG_LINK_TO_HOST_ONLY: DWORD = 0x00000001; +pub const SERVICE_ACCOUNT_FLAG_ADD_AGAINST_RODC: DWORD = 0x00000002; +pub const SERVICE_ACCOUNT_FLAG_UNLINK_FROM_HOST_ONLY: DWORD = 0x00000001; +pub const SERVICE_ACCOUNT_FLAG_REMOVE_OFFLINE: DWORD = 0x00000002; +extern "system" { + pub fn NetRemoveServiceAccount( + ServerName: LPWSTR, + AccountName: LPWSTR, + Flags: DWORD, + ) -> NTSTATUS; + pub fn NetEnumerateServiceAccounts( + ServerName: LPWSTR, + Flags: DWORD, + AccountsCount: *mut DWORD, + Accounts: *mut PZPWSTR, + ) -> NTSTATUS; + pub fn NetIsServiceAccount( + ServerName: LPWSTR, + AccountName: LPWSTR, + IsService: *mut BOOL, + ) -> NTSTATUS; + pub fn NetQueryServiceAccount( + ServerName: LPWSTR, + AccountName: LPWSTR, + InfoLevel: DWORD, + Buffer: *mut PBYTE, + ) -> NTSTATUS; +} +ENUM!{enum MSA_INFO_LEVEL { + MsaInfoLevel0 = 0, + MsaInfoLevelMax, +}} +pub type PMSA_INFO_LEVEL = *mut MSA_INFO_LEVEL; +ENUM!{enum MSA_INFO_STATE { + MsaInfoNotExist = 1, + MsaInfoNotService, + MsaInfoCannotInstall, + MsaInfoCanInstall, + MsaInfoInstalled, +}} +pub type PMSA_INFO_STATE = *mut MSA_INFO_STATE; +STRUCT!{struct MSA_INFO_0 { + State: MSA_INFO_STATE, +}} +pub type PMSA_INFO_0 = *mut MSA_INFO_0; +pub type LPMSA_INFO_0 = *mut MSA_INFO_0; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmalert.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmalert.rs new file mode 100644 index 0000000..e406d80 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmalert.rs @@ -0,0 +1,75 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This file contains structures for communication with the Alerter service +use shared::lmcons::{EVLEN, NET_API_STATUS, SNLEN}; +use shared::minwindef::{DWORD, LPVOID}; +use um::winnt::{LPCWSTR, WCHAR}; +extern "system" { + pub fn NetAlertRaise( + AlertType: LPCWSTR, + Buffer: LPVOID, + BufferSize: DWORD, + ) -> NET_API_STATUS; + pub fn NetAlertRaiseEx( + AlertType: LPCWSTR, + VariableInfo: LPVOID, + VariableInfoSize: DWORD, + ServiceName: LPCWSTR, + ) -> NET_API_STATUS; +} +STRUCT!{struct STD_ALERT { + alrt_timestamp: DWORD, + alrt_eventname: [WCHAR; EVLEN + 1], + alrt_servicename: [WCHAR; SNLEN + 1], +}} +pub type PSTD_ALERT = *mut STD_ALERT; +pub type LPSTD_ALERT = *mut STD_ALERT; +STRUCT!{struct ADMIN_OTHER_INFO { + alrtad_errcode: DWORD, + alrtad_numstrings: DWORD, +}} +pub type PADMIN_OTHER_INFO = *mut ADMIN_OTHER_INFO; +pub type LPADMIN_OTHER_INFO = *mut ADMIN_OTHER_INFO; +STRUCT!{struct ERRLOG_OTHER_INFO { + alrter_errcode: DWORD, + alrter_offset: DWORD, +}} +pub type PERRLOG_OTHER_INFO = *mut ERRLOG_OTHER_INFO; +pub type LPERRLOG_OTHER_INFO = *mut ERRLOG_OTHER_INFO; +STRUCT!{struct PRINT_OTHER_INFO { + alrtpr_jobid: DWORD, + alrtpr_status: DWORD, + alrtpr_submitted: DWORD, + alrtpr_size: DWORD, +}} +pub type PPRINT_OTHER_INFO = *mut PRINT_OTHER_INFO; +pub type LPPRINT_OTHER_INFO = *mut PRINT_OTHER_INFO; +STRUCT!{struct USER_OTHER_INFO { + alrtus_errcode: DWORD, + alrtus_numstrings: DWORD, +}} +pub type PUSER_OTHER_INFO = *mut USER_OTHER_INFO; +pub type LPUSER_OTHER_INFO = *mut USER_OTHER_INFO; +pub const ALERTER_MAILSLOT: &'static str = "\\\\.\\MAILSLOT\\Alerter"; +pub const ALERT_PRINT_EVENT: &'static str = "PRINTING"; +pub const ALERT_MESSAGE_EVENT: &'static str = "MESSAGE"; +pub const ALERT_ERRORLOG_EVENT: &'static str = "ERRORLOG"; +pub const ALERT_ADMIN_EVENT: &'static str = "ADMIN"; +pub const ALERT_USER_EVENT: &'static str = "USER"; +pub const PRJOB_QSTATUS: DWORD = 0x3; +pub const PRJOB_DEVSTATUS: DWORD = 0x1fc; +pub const PRJOB_COMPLETE: DWORD = 0x4; +pub const PRJOB_INTERV: DWORD = 0x8; +pub const PRJOB_ERROR: DWORD = 0x10; +pub const PRJOB_DESTOFFLINE: DWORD = 0x20; +pub const PRJOB_DESTPAUSED: DWORD = 0x40; +pub const PRJOB_NOTIFY: DWORD = 0x80; +pub const PRJOB_DESTNOPAPER: DWORD = 0x100; +pub const PRJOB_DELETED: DWORD = 0x8000; +pub const PRJOB_QS_QUEUED: DWORD = 0; +pub const PRJOB_QS_PAUSED: DWORD = 1; +pub const PRJOB_QS_SPOOLING: DWORD = 2; +pub const PRJOB_QS_PRINTING: DWORD = 3; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmapibuf.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmapibuf.rs new file mode 100644 index 0000000..620a131 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmapibuf.rs @@ -0,0 +1,30 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This file contains information about NetApiBuffer APIs +use shared::lmcons::NET_API_STATUS; +use shared::minwindef::{DWORD, LPDWORD, LPVOID}; +extern "system" { + pub fn NetApiBufferAllocate( + ByteCount: DWORD, + Buffer: *mut LPVOID, + ) -> NET_API_STATUS; + pub fn NetApiBufferFree( + Buffer: LPVOID, + ) -> NET_API_STATUS; + pub fn NetApiBufferReallocate( + OldBuffer: LPVOID, + NewByteCount: DWORD, + NewBuffer: *mut LPVOID, + ) -> NET_API_STATUS; + pub fn NetApiBufferSize( + Buffer: LPVOID, + ByteCount: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetapipBufferAllocate( + ByteCount: DWORD, + Buffer: *mut LPVOID, + ) -> NET_API_STATUS; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmat.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmat.rs new file mode 100644 index 0000000..46742eb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmat.rs @@ -0,0 +1,62 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::DWORD_PTR; +use shared::lmcons::NET_API_STATUS; +use shared::minwindef::{DWORD, LPBYTE, LPDWORD, UCHAR}; +use um::winnt::{LPCWSTR, LPWSTR}; +pub const JOB_RUN_PERIODICALLY: UCHAR = 0x01; +pub const JOB_EXEC_ERROR: UCHAR = 0x02; +pub const JOB_RUNS_TODAY: UCHAR = 0x04; +pub const JOB_ADD_CURRENT_DATE: UCHAR = 0x08; +pub const JOB_NONINTERACTIVE: UCHAR = 0x10; +pub const JOB_INPUT_FLAGS: UCHAR = JOB_RUN_PERIODICALLY | JOB_ADD_CURRENT_DATE + | JOB_NONINTERACTIVE; +pub const JOB_OUTPUT_FLAGS: UCHAR = JOB_RUN_PERIODICALLY | JOB_EXEC_ERROR | JOB_RUNS_TODAY + | JOB_NONINTERACTIVE; +STRUCT!{struct AT_INFO { + JobTime: DWORD_PTR, + DaysOfMonth: DWORD, + DaysOfWeek: UCHAR, + Flags: UCHAR, + Command: LPWSTR, +}} +pub type PAT_INFO = *mut AT_INFO; +pub type LPAT_INFO = *mut AT_INFO; +STRUCT!{struct AT_ENUM { + JobId: DWORD, + JobTime: DWORD_PTR, + DaysOfMonth: DWORD, + DaysOfWeek: UCHAR, + Flags: UCHAR, + Command: LPWSTR, +}} +pub type PAT_ENUM = *mut AT_ENUM; +pub type LPAT_ENUM = *mut AT_ENUM; +extern "system" { + pub fn NetScheduleJobAdd( + Servername: LPCWSTR, + Buffer: LPBYTE, + JobId: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetScheduleJobDel( + Servername: LPCWSTR, + MinJobId: DWORD, + MaxJobId: DWORD, + ) -> NET_API_STATUS; + pub fn NetScheduleJobEnum( + Servername: LPCWSTR, + PointerToBuffer: *mut LPBYTE, + PointerToBuffer: DWORD, + EntriesRead: LPDWORD, + TotalEntries: LPDWORD, + ResumeHandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetScheduleJobGetInfo( + Servername: LPCWSTR, + JobId: DWORD, + PointerToBuffer: *mut LPBYTE, + ) -> NET_API_STATUS; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmdfs.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmdfs.rs new file mode 100644 index 0000000..a0be98b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmdfs.rs @@ -0,0 +1,483 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +// This file contains structures, function prototypes, and definitions for the NetDfs API +use shared::guiddef::GUID; +use shared::lmcons::NET_API_STATUS; +use shared::minwindef::{DWORD, LPBYTE, LPDWORD, ULONG, USHORT}; +use um::winnt::{LPWSTR, PSECURITY_DESCRIPTOR, PWSTR, SECURITY_INFORMATION, ULONGLONG, WCHAR}; +pub const DFS_VOLUME_STATES: DWORD = 0xF; +pub const DFS_VOLUME_STATE_OK: DWORD = 1; +pub const DFS_VOLUME_STATE_INCONSISTENT: DWORD = 2; +pub const DFS_VOLUME_STATE_OFFLINE: DWORD = 3; +pub const DFS_VOLUME_STATE_ONLINE: DWORD = 4; +pub const DFS_VOLUME_STATE_RESYNCHRONIZE: DWORD = 0x10; +pub const DFS_VOLUME_STATE_STANDBY: DWORD = 0x20; +pub const DFS_VOLUME_STATE_FORCE_SYNC: DWORD = 0x40; +pub const DFS_VOLUME_FLAVORS: DWORD = 0x0300; +pub const DFS_VOLUME_FLAVOR_UNUSED1: DWORD = 0x0000; +pub const DFS_VOLUME_FLAVOR_STANDALONE: DWORD = 0x0100; +pub const DFS_VOLUME_FLAVOR_AD_BLOB: DWORD = 0x0200; +pub const DFS_STORAGE_FLAVOR_UNUSED2: DWORD = 0x0300; +pub const DFS_STORAGE_STATES: ULONG = 0xF; +pub const DFS_STORAGE_STATE_OFFLINE: ULONG = 1; +pub const DFS_STORAGE_STATE_ONLINE: ULONG = 2; +pub const DFS_STORAGE_STATE_ACTIVE: ULONG = 4; +ENUM!{enum DFS_TARGET_PRIORITY_CLASS { + DfsInvalidPriorityClass = -1i32 as u32, + DfsSiteCostNormalPriorityClass = 0, + DfsGlobalHighPriorityClass, + DfsSiteCostHighPriorityClass, + DfsSiteCostLowPriorityClass, + DfsGlobalLowPriorityClass, +}} +STRUCT!{struct DFS_TARGET_PRIORITY { + TargetPriorityClass: DFS_TARGET_PRIORITY_CLASS, + TargetPriorityRank: USHORT, + Reserved: USHORT, +}} +pub type PDFS_TARGET_PRIORITY = *mut DFS_TARGET_PRIORITY; +STRUCT!{struct DFS_INFO_1 { + EntryPath: LPWSTR, +}} +pub type PDFS_INFO_1 = *mut DFS_INFO_1; +pub type LPDFS_INFO_1 = *mut DFS_INFO_1; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +STRUCT!{struct DFS_INFO_1_32 { + EntryPath: ULONG, +}} +pub type PDFS_INFO_1_32 = *mut DFS_INFO_1_32; +pub type LPDFS_INFO_1_32 = *mut DFS_INFO_1_32; +} +STRUCT!{struct DFS_INFO_2 { + EntryPath: LPWSTR, + Comment: LPWSTR, + State: DWORD, + NumberOfStorages: DWORD, +}} +pub type PDFS_INFO_2 = *mut DFS_INFO_2; +pub type LPDFS_INFO_2 = *mut DFS_INFO_2; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +STRUCT!{struct DFS_INFO_2_32 { + EntryPath: ULONG, + Comment: ULONG, + State: DWORD, + NumberOfStorages: DWORD, +}} +pub type PDFS_INFO_2_32 = *mut DFS_INFO_2_32; +pub type LPDFS_INFO_2_32 = *mut DFS_INFO_2_32; +} +STRUCT!{struct DFS_STORAGE_INFO { + State: ULONG, + ServerName: LPWSTR, + ShareName: LPWSTR, +}} +pub type PDFS_STORAGE_INFO = *mut DFS_STORAGE_INFO; +pub type LPDFS_STORAGE_INFO = *mut DFS_STORAGE_INFO; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +STRUCT!{struct DFS_STORAGE_INFO_0_32 { + State: ULONG, + ServerName: ULONG, + ShareName: ULONG, +}} +pub type PDFS_STORAGE_INFO_0_32 = *mut DFS_STORAGE_INFO_0_32; +pub type LPDFS_STORAGE_INFO_0_32 = *mut DFS_STORAGE_INFO_0_32; +} +STRUCT!{struct DFS_STORAGE_INFO_1 { + State: ULONG, + ServerName: LPWSTR, + ShareName: LPWSTR, + TargetPriority: DFS_TARGET_PRIORITY, +}} +pub type PDFS_STORAGE_INFO_1 = *mut DFS_STORAGE_INFO_1; +pub type LPDFS_STORAGE_INFO_1 = *mut DFS_STORAGE_INFO_1; +STRUCT!{struct DFS_INFO_3 { + EntryPath: LPWSTR, + Comment: LPWSTR, + State: DWORD, + NumberOfStorages: DWORD, + Storage: LPDFS_STORAGE_INFO, +}} +pub type PDFS_INFO_3 = *mut DFS_INFO_3; +pub type LPDFS_INFO_3 = *mut DFS_INFO_3; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +STRUCT!{struct DFS_INFO_3_32 { + EntryPath: ULONG, + Comment: ULONG, + State: DWORD, + NumberOfStorages: DWORD, + Storage: ULONG, +}} +pub type PDFS_INFO_3_32 = *mut DFS_INFO_3_32; +pub type LPDFS_INFO_3_32 = *mut DFS_INFO_3_32; +} +STRUCT!{struct DFS_INFO_4 { + EntryPath: LPWSTR, + Comment: LPWSTR, + State: DWORD, + Timeout: ULONG, + Guid: GUID, + NumberOfStorages: DWORD, + Storage: LPDFS_STORAGE_INFO, +}} +pub type PDFS_INFO_4 = *mut DFS_INFO_4; +pub type LPDFS_INFO_4 = *mut DFS_INFO_4; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +STRUCT!{struct DFS_INFO_4_32 { + EntryPath: ULONG, + Comment: ULONG, + State: DWORD, + Timeout: ULONG, + Guid: GUID, + NumberOfStorages: DWORD, + Storage: ULONG, +}} +pub type PDFS_INFO_4_32 = *mut DFS_INFO_4_32; +pub type LPDFS_INFO_4_32 = *mut DFS_INFO_4_32; +} +STRUCT!{struct DFS_INFO_5 { + EntryPath: LPWSTR, + Comment: LPWSTR, + State: DWORD, + Timeout: ULONG, + Guid: GUID, + PropertyFlags: ULONG, + MetadataSize: ULONG, + NumberOfStorages: DWORD, +}} +pub type PDFS_INFO_5 = *mut DFS_INFO_5; +pub type LPDFS_INFO_5 = *mut DFS_INFO_5; +STRUCT!{struct DFS_INFO_6 { + EntryPath: LPWSTR, + Comment: LPWSTR, + State: DWORD, + Timeout: ULONG, + Guid: GUID, + PropertyFlags: ULONG, + MetadataSize: ULONG, + NumberOfStorages: DWORD, + Storage: LPDFS_STORAGE_INFO, +}} +pub type PDFS_INFO_6 = *mut DFS_INFO_6; +pub type LPDFS_INFO_6 = *mut DFS_INFO_6; +STRUCT!{struct DFS_INFO_7 { + GenerationGuid: GUID, +}} +pub type PDFS_INFO_7 = *mut DFS_INFO_7; +pub type LPDFS_INFO_7 = *mut DFS_INFO_7; +STRUCT!{struct DFS_INFO_8 { + EntryPath: LPWSTR, + Comment: LPWSTR, + State: DWORD, + Timeout: ULONG, + Guid: GUID, + PropertyFlags: ULONG, + MetadataSize: ULONG, + SdLengthReserved: ULONG, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + NumberOfStorages: DWORD, +}} +pub type PDFS_INFO_8 = *mut DFS_INFO_8; +pub type LPDFS_INFO_8 = *mut DFS_INFO_8; +STRUCT!{struct DFS_INFO_9 { + EntryPath: LPWSTR, + Comment: LPWSTR, + State: DWORD, + Timeout: ULONG, + Guid: GUID, + PropertyFlags: ULONG, + MetadataSize: ULONG, + SdLengthReserved: ULONG, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + NumberOfStorages: DWORD, + Storage: LPDFS_STORAGE_INFO, +}} +pub type PDFS_INFO_9 = *mut DFS_INFO_9; +pub type LPDFS_INFO_9 = *mut DFS_INFO_9; +pub const DFS_VALID_PROPERTY_FLAGS: ULONG = DFS_PROPERTY_FLAG_INSITE_REFERRALS + | DFS_PROPERTY_FLAG_ROOT_SCALABILITY | DFS_PROPERTY_FLAG_SITE_COSTING + | DFS_PROPERTY_FLAG_TARGET_FAILBACK | DFS_PROPERTY_FLAG_CLUSTER_ENABLED + | DFS_PROPERTY_FLAG_ABDE; +pub const DFS_PROPERTY_FLAG_INSITE_REFERRALS: ULONG = 0x00000001; +pub const DFS_PROPERTY_FLAG_ROOT_SCALABILITY: ULONG = 0x00000002; +pub const DFS_PROPERTY_FLAG_SITE_COSTING: ULONG = 0x00000004; +pub const DFS_PROPERTY_FLAG_TARGET_FAILBACK: ULONG = 0x00000008; +pub const DFS_PROPERTY_FLAG_CLUSTER_ENABLED: ULONG = 0x00000010; +pub const DFS_PROPERTY_FLAG_ABDE: ULONG = 0x00000020; +STRUCT!{struct DFS_INFO_50 { + NamespaceMajorVersion: ULONG, + NamespaceMinorVersion: ULONG, + NamespaceCapabilities: ULONGLONG, +}} +pub type PDFS_INFO_50 = *mut DFS_INFO_50; +pub type LPDFS_INFO_50 = *mut DFS_INFO_50; +STRUCT!{struct DFS_INFO_100 { + Comment: LPWSTR, +}} +pub type PDFS_INFO_100 = *mut DFS_INFO_100; +pub type LPDFS_INFO_100 = *mut DFS_INFO_100; +STRUCT!{struct DFS_INFO_101 { + State: DWORD, +}} +pub type PDFS_INFO_101 = *mut DFS_INFO_101; +pub type LPDFS_INFO_101 = *mut DFS_INFO_101; +STRUCT!{struct DFS_INFO_102 { + Timeout: ULONG, +}} +pub type PDFS_INFO_102 = *mut DFS_INFO_102; +pub type LPDFS_INFO_102 = *mut DFS_INFO_102; +STRUCT!{struct DFS_INFO_103 { + PropertyFlagMask: ULONG, + PropertyFlags: ULONG, +}} +pub type PDFS_INFO_103 = *mut DFS_INFO_103; +pub type LPDFS_INFO_103 = *mut DFS_INFO_103; +STRUCT!{struct DFS_INFO_104 { + TargetPriority: DFS_TARGET_PRIORITY, +}} +pub type PDFS_INFO_104 = *mut DFS_INFO_104; +pub type LPDFS_INFO_104 = *mut DFS_INFO_104; +STRUCT!{struct DFS_INFO_105 { + Comment: LPWSTR, + State: DWORD, + Timeout: ULONG, + PropertyFlagMask: ULONG, + PropertyFlags: ULONG, +}} +pub type PDFS_INFO_105 = *mut DFS_INFO_105; +pub type LPDFS_INFO_105 = *mut DFS_INFO_105; +STRUCT!{struct DFS_INFO_106 { + State: DWORD, + TargetPriority: DFS_TARGET_PRIORITY, +}} +pub type PDFS_INFO_106 = *mut DFS_INFO_106; +pub type LPDFS_INFO_106 = *mut DFS_INFO_106; +STRUCT!{struct DFS_INFO_107 { + Comment: LPWSTR, + State: DWORD, + Timeout: ULONG, + PropertyFlagMask: ULONG, + PropertyFlags: ULONG, + SdLengthReserved: ULONG, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, +}} +pub type PDFS_INFO_107 = *mut DFS_INFO_107; +pub type LPDFS_INFO_107 = *mut DFS_INFO_107; +STRUCT!{struct DFS_INFO_150 { + SdLengthReserved: ULONG, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, +}} +pub type PDFS_INFO_150 = *mut DFS_INFO_150; +pub type LPDFS_INFO_150 = *mut DFS_INFO_150; +STRUCT!{struct DFS_INFO_200 { + FtDfsName: LPWSTR, +}} +pub type PDFS_INFO_200 = *mut DFS_INFO_200; +pub type LPDFS_INFO_200 = *mut DFS_INFO_200; +STRUCT!{struct DFS_INFO_300 { + Flags: DWORD, + DfsName: LPWSTR, +}} +pub type PDFS_INFO_300 = *mut DFS_INFO_300; +pub type LPDFS_INFO_300 = *mut DFS_INFO_300; +extern "system" { + pub fn NetDfsAdd( + DfsEntryPath: LPWSTR, + ServerName: LPWSTR, + ShareName: LPWSTR, + Comment: LPWSTR, + Flags: DWORD, + ) -> NET_API_STATUS; +} +pub const DFS_ADD_VOLUME: DWORD = 1; +pub const DFS_RESTORE_VOLUME: DWORD = 2; +extern "system" { + pub fn NetDfsAddStdRoot( + ServerName: LPWSTR, + RootShare: LPWSTR, + Comment: LPWSTR, + Flags: DWORD, + ) -> NET_API_STATUS; + pub fn NetDfsRemoveStdRoot( + ServerName: LPWSTR, + RootShare: LPWSTR, + Flags: DWORD, + ) -> NET_API_STATUS; + pub fn NetDfsAddFtRoot( + ServerName: LPWSTR, + RootShare: LPWSTR, + FtDfsName: LPWSTR, + Comment: LPWSTR, + Flags: DWORD, + ) -> NET_API_STATUS; + pub fn NetDfsRemoveFtRoot( + ServerName: LPWSTR, + RootShare: LPWSTR, + FtDfsName: LPWSTR, + Flags: DWORD, + ) -> NET_API_STATUS; + pub fn NetDfsRemoveFtRootForced( + DomainName: LPWSTR, + ServerName: LPWSTR, + RootShare: LPWSTR, + FtDfsName: LPWSTR, + Flags: DWORD, + ) -> NET_API_STATUS; +} +pub const NET_DFS_SETDC_FLAGS: DWORD = 0x00000000; +pub const NET_DFS_SETDC_TIMEOUT: DWORD = 0x00000001; +pub const NET_DFS_SETDC_INITPKT: DWORD = 0x00000002; +STRUCT!{struct DFS_SITENAME_INFO { + SiteFlags: ULONG, + SiteName: LPWSTR, +}} +pub type PDFS_SITENAME_INFO = *mut DFS_SITENAME_INFO; +pub type LPDFS_SITENAME_INFO = *mut DFS_SITENAME_INFO; +pub const DFS_SITE_PRIMARY: ULONG = 0x1; +STRUCT!{struct DFS_SITELIST_INFO { + cSites: ULONG, + Site: [DFS_SITENAME_INFO; 1], +}} +pub type PDFS_SITELIST_INFO = *mut DFS_SITELIST_INFO; +pub type LPDFS_SITELIST_INFO = *mut DFS_SITELIST_INFO; +extern "system" { + pub fn NetDfsRemove( + DfsEntryPath: LPWSTR, + ServerName: LPWSTR, + ShareName: LPWSTR, + ) -> NET_API_STATUS; + pub fn NetDfsEnum( + DfsName: LPWSTR, + Level: DWORD, + PrefMaxLen: DWORD, + Buffer: *mut LPBYTE, + EntriesRead: LPDWORD, + ResumeHandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetDfsGetInfo( + DfsEntryPath: LPWSTR, + ServerName: LPWSTR, + ShareName: LPWSTR, + Level: DWORD, + Buffer: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetDfsSetInfo( + DfsEntryPath: LPWSTR, + ServerName: LPWSTR, + ShareName: LPWSTR, + Level: DWORD, + Buffer: LPBYTE, + ) -> NET_API_STATUS; + pub fn NetDfsGetClientInfo( + DfsEntryPath: LPWSTR, + ServerName: LPWSTR, + ShareName: LPWSTR, + Level: DWORD, + Buffer: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetDfsSetClientInfo( + DfsEntryPath: LPWSTR, + ServerName: LPWSTR, + ShareName: LPWSTR, + Level: DWORD, + Buffer: LPBYTE, + ) -> NET_API_STATUS; + pub fn NetDfsMove( + OldDfsEntryPath: LPWSTR, + NewDfsEntryPath: LPWSTR, + Flags: ULONG, + ) -> NET_API_STATUS; +} +pub const DFS_MOVE_FLAG_REPLACE_IF_EXISTS: ULONG = 0x00000001; +extern "system" { + pub fn NetDfsRename( + Path: LPWSTR, + NewPath: LPWSTR, + ) -> NET_API_STATUS; + pub fn NetDfsAddRootTarget( + pDfsPath: LPWSTR, + pTargetPath: LPWSTR, + MajorVersion: ULONG, + pComment: LPWSTR, + Flags: ULONG, + ) -> NET_API_STATUS; +} +pub const DFS_FORCE_REMOVE: ULONG = 0x80000000; +extern "system" { + pub fn NetDfsRemoveRootTarget( + pDfsPath: LPWSTR, + pTargetPath: LPWSTR, + Flags: DWORD, + ) -> NET_API_STATUS; + pub fn NetDfsGetSecurity( + DfsEntryPath: LPWSTR, + SecurityInformation: SECURITY_INFORMATION, + ppSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + lpcbSecurityDescriptor: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetDfsSetSecurity( + DfsEntryPath: LPWSTR, + SecurityInformation: SECURITY_INFORMATION, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ) -> NET_API_STATUS; + pub fn NetDfsGetStdContainerSecurity( + MachineName: LPWSTR, + SecurityInformation: SECURITY_INFORMATION, + ppSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + lpcbSecurityDescriptor: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetDfsSetStdContainerSecurity( + MachineName: LPWSTR, + SecurityInformation: SECURITY_INFORMATION, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ) -> NET_API_STATUS; + pub fn NetDfsGetFtContainerSecurity( + DomainName: LPWSTR, + SecurityInformation: SECURITY_INFORMATION, + ppSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + lpcbSecurityDescriptor: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetDfsSetFtContainerSecurity( + DomainName: LPWSTR, + SecurityInformation: SECURITY_INFORMATION, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ) -> NET_API_STATUS; +} +ENUM!{enum DFS_NAMESPACE_VERSION_ORIGIN { + DFS_NAMESPACE_VERSION_ORIGIN_COMBINED = 0, + DFS_NAMESPACE_VERSION_ORIGIN_SERVER, + DFS_NAMESPACE_VERSION_ORIGIN_DOMAIN, +}} +pub type PDFS_NAMESPACE_VERSION_ORIGIN = *mut DFS_NAMESPACE_VERSION_ORIGIN; +pub const DFS_NAMESPACE_CAPABILITY_ABDE: ULONGLONG = 0x0000000000000001; +STRUCT!{struct DFS_SUPPORTED_NAMESPACE_VERSION_INFO { + DomainDfsMajorVersion: ULONG, + DomainDfsMinorVersion: ULONG, + DomainDfsCapabilities: ULONGLONG, + StandaloneDfsMajorVersion: ULONG, + StandaloneDfsMinorVersion: ULONG, + StandaloneDfsCapabilities: ULONGLONG, +}} +pub type PDFS_SUPPORTED_NAMESPACE_VERSION_INFO = *mut DFS_SUPPORTED_NAMESPACE_VERSION_INFO; +extern "system" { + pub fn NetDfsGetSupportedNamespaceVersion( + Origin: DFS_NAMESPACE_VERSION_ORIGIN, + pName: PWSTR, + ppVersionInfo: *mut PDFS_SUPPORTED_NAMESPACE_VERSION_INFO, + ) -> NET_API_STATUS; +} +STRUCT!{struct DFS_GET_PKT_ENTRY_STATE_ARG { + DfsEntryPathLen: USHORT, + ServerNameLen: USHORT, + ShareNameLen: USHORT, + Level: ULONG, + Buffer: [WCHAR; 1], +}} +pub type PDFS_GET_PKT_ENTRY_STATE_ARG = *mut DFS_GET_PKT_ENTRY_STATE_ARG; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmerrlog.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmerrlog.rs new file mode 100644 index 0000000..8a07f73 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmerrlog.rs @@ -0,0 +1,268 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{DWORD, LPBYTE}; +use um::winnt::LPWSTR; +STRUCT!{struct ERROR_LOG { + el_len: DWORD, + el_reserved: DWORD, + el_time: DWORD, + el_error: DWORD, + el_name: LPWSTR, + el_text: LPWSTR, + el_data: LPBYTE, + el_data_size: DWORD, + el_nstrings: DWORD, +}} +pub type PERROR_LOG = *mut ERROR_LOG; +pub type LPERROR_LOG = *mut ERROR_LOG; +STRUCT!{struct HLOG { + time: DWORD, + last_flags: DWORD, + offset: DWORD, + rec_offset: DWORD, +}} +pub type PHLOG = *mut HLOG; +pub type LPHLOG = *mut HLOG; +pub const LOGFLAGS_FORWARD: DWORD = 0; +pub const LOGFLAGS_BACKWARD: DWORD = 0x1; +pub const LOGFLAGS_SEEK: DWORD = 0x2; +pub const ERRLOG_BASE: DWORD = 3100; +pub const NELOG_Internal_Error: DWORD = ERRLOG_BASE + 0; +pub const NELOG_Resource_Shortage: DWORD = ERRLOG_BASE + 1; +pub const NELOG_Unable_To_Lock_Segment: DWORD = ERRLOG_BASE + 2; +pub const NELOG_Unable_To_Unlock_Segment: DWORD = ERRLOG_BASE + 3; +pub const NELOG_Uninstall_Service: DWORD = ERRLOG_BASE + 4; +pub const NELOG_Init_Exec_Fail: DWORD = ERRLOG_BASE + 5; +pub const NELOG_Ncb_Error: DWORD = ERRLOG_BASE + 6; +pub const NELOG_Net_Not_Started: DWORD = ERRLOG_BASE + 7; +pub const NELOG_Ioctl_Error: DWORD = ERRLOG_BASE + 8; +pub const NELOG_System_Semaphore: DWORD = ERRLOG_BASE + 9; +pub const NELOG_Init_OpenCreate_Err: DWORD = ERRLOG_BASE + 10; +pub const NELOG_NetBios: DWORD = ERRLOG_BASE + 11; +pub const NELOG_SMB_Illegal: DWORD = ERRLOG_BASE + 12; +pub const NELOG_Service_Fail: DWORD = ERRLOG_BASE + 13; +pub const NELOG_Entries_Lost: DWORD = ERRLOG_BASE + 14; +pub const NELOG_Init_Seg_Overflow: DWORD = ERRLOG_BASE + 20; +pub const NELOG_Srv_No_Mem_Grow: DWORD = ERRLOG_BASE + 21; +pub const NELOG_Access_File_Bad: DWORD = ERRLOG_BASE + 22; +pub const NELOG_Srvnet_Not_Started: DWORD = ERRLOG_BASE + 23; +pub const NELOG_Init_Chardev_Err: DWORD = ERRLOG_BASE + 24; +pub const NELOG_Remote_API: DWORD = ERRLOG_BASE + 25; +pub const NELOG_Ncb_TooManyErr: DWORD = ERRLOG_BASE + 26; +pub const NELOG_Mailslot_err: DWORD = ERRLOG_BASE + 27; +pub const NELOG_ReleaseMem_Alert: DWORD = ERRLOG_BASE + 28; +pub const NELOG_AT_cannot_write: DWORD = ERRLOG_BASE + 29; +pub const NELOG_Cant_Make_Msg_File: DWORD = ERRLOG_BASE + 30; +pub const NELOG_Exec_Netservr_NoMem: DWORD = ERRLOG_BASE + 31; +pub const NELOG_Server_Lock_Failure: DWORD = ERRLOG_BASE + 32; +pub const NELOG_Msg_Shutdown: DWORD = ERRLOG_BASE + 40; +pub const NELOG_Msg_Sem_Shutdown: DWORD = ERRLOG_BASE + 41; +pub const NELOG_Msg_Log_Err: DWORD = ERRLOG_BASE + 50; +pub const NELOG_VIO_POPUP_ERR: DWORD = ERRLOG_BASE + 51; +pub const NELOG_Msg_Unexpected_SMB_Type: DWORD = ERRLOG_BASE + 52; +pub const NELOG_Wksta_Infoseg: DWORD = ERRLOG_BASE + 60; +pub const NELOG_Wksta_Compname: DWORD = ERRLOG_BASE + 61; +pub const NELOG_Wksta_BiosThreadFailure: DWORD = ERRLOG_BASE + 62; +pub const NELOG_Wksta_IniSeg: DWORD = ERRLOG_BASE + 63; +pub const NELOG_Wksta_HostTab_Full: DWORD = ERRLOG_BASE + 64; +pub const NELOG_Wksta_Bad_Mailslot_SMB: DWORD = ERRLOG_BASE + 65; +pub const NELOG_Wksta_UASInit: DWORD = ERRLOG_BASE + 66; +pub const NELOG_Wksta_SSIRelogon: DWORD = ERRLOG_BASE + 67; +pub const NELOG_Build_Name: DWORD = ERRLOG_BASE + 70; +pub const NELOG_Name_Expansion: DWORD = ERRLOG_BASE + 71; +pub const NELOG_Message_Send: DWORD = ERRLOG_BASE + 72; +pub const NELOG_Mail_Slt_Err: DWORD = ERRLOG_BASE + 73; +pub const NELOG_AT_cannot_read: DWORD = ERRLOG_BASE + 74; +pub const NELOG_AT_sched_err: DWORD = ERRLOG_BASE + 75; +pub const NELOG_AT_schedule_file_created: DWORD = ERRLOG_BASE + 76; +pub const NELOG_Srvnet_NB_Open: DWORD = ERRLOG_BASE + 77; +pub const NELOG_AT_Exec_Err: DWORD = ERRLOG_BASE + 78; +pub const NELOG_Lazy_Write_Err: DWORD = ERRLOG_BASE + 80; +pub const NELOG_HotFix: DWORD = ERRLOG_BASE + 81; +pub const NELOG_HardErr_From_Server: DWORD = ERRLOG_BASE + 82; +pub const NELOG_LocalSecFail1: DWORD = ERRLOG_BASE + 83; +pub const NELOG_LocalSecFail2: DWORD = ERRLOG_BASE + 84; +pub const NELOG_LocalSecFail3: DWORD = ERRLOG_BASE + 85; +pub const NELOG_LocalSecGeneralFail: DWORD = ERRLOG_BASE + 86; +pub const NELOG_NetWkSta_Internal_Error: DWORD = ERRLOG_BASE + 90; +pub const NELOG_NetWkSta_No_Resource: DWORD = ERRLOG_BASE + 91; +pub const NELOG_NetWkSta_SMB_Err: DWORD = ERRLOG_BASE + 92; +pub const NELOG_NetWkSta_VC_Err: DWORD = ERRLOG_BASE + 93; +pub const NELOG_NetWkSta_Stuck_VC_Err: DWORD = ERRLOG_BASE + 94; +pub const NELOG_NetWkSta_NCB_Err: DWORD = ERRLOG_BASE + 95; +pub const NELOG_NetWkSta_Write_Behind_Err: DWORD = ERRLOG_BASE + 96; +pub const NELOG_NetWkSta_Reset_Err: DWORD = ERRLOG_BASE + 97; +pub const NELOG_NetWkSta_Too_Many: DWORD = ERRLOG_BASE + 98; +pub const NELOG_Srv_Thread_Failure: DWORD = ERRLOG_BASE + 104; +pub const NELOG_Srv_Close_Failure: DWORD = ERRLOG_BASE + 105; +pub const NELOG_ReplUserCurDir: DWORD = ERRLOG_BASE + 106; +pub const NELOG_ReplCannotMasterDir: DWORD = ERRLOG_BASE + 107; +pub const NELOG_ReplUpdateError: DWORD = ERRLOG_BASE + 108; +pub const NELOG_ReplLostMaster: DWORD = ERRLOG_BASE + 109; +pub const NELOG_NetlogonAuthDCFail: DWORD = ERRLOG_BASE + 110; +pub const NELOG_ReplLogonFailed: DWORD = ERRLOG_BASE + 111; +pub const NELOG_ReplNetErr: DWORD = ERRLOG_BASE + 112; +pub const NELOG_ReplMaxFiles: DWORD = ERRLOG_BASE + 113; +pub const NELOG_ReplMaxTreeDepth: DWORD = ERRLOG_BASE + 114; +pub const NELOG_ReplBadMsg: DWORD = ERRLOG_BASE + 115; +pub const NELOG_ReplSysErr: DWORD = ERRLOG_BASE + 116; +pub const NELOG_ReplUserLoged: DWORD = ERRLOG_BASE + 117; +pub const NELOG_ReplBadImport: DWORD = ERRLOG_BASE + 118; +pub const NELOG_ReplBadExport: DWORD = ERRLOG_BASE + 119; +pub const NELOG_ReplSignalFileErr: DWORD = ERRLOG_BASE + 120; +pub const NELOG_DiskFT: DWORD = ERRLOG_BASE + 121; +pub const NELOG_ReplAccessDenied: DWORD = ERRLOG_BASE + 122; +pub const NELOG_NetlogonFailedPrimary: DWORD = ERRLOG_BASE + 123; +pub const NELOG_NetlogonPasswdSetFailed: DWORD = ERRLOG_BASE + 124; +pub const NELOG_NetlogonTrackingError: DWORD = ERRLOG_BASE + 125; +pub const NELOG_NetlogonSyncError: DWORD = ERRLOG_BASE + 126; +pub const NELOG_NetlogonRequireSignOrSealError: DWORD = ERRLOG_BASE + 127; +pub const NELOG_UPS_PowerOut: DWORD = ERRLOG_BASE + 130; +pub const NELOG_UPS_Shutdown: DWORD = ERRLOG_BASE + 131; +pub const NELOG_UPS_CmdFileError: DWORD = ERRLOG_BASE + 132; +pub const NELOG_UPS_CannotOpenDriver: DWORD = ERRLOG_BASE + 133; +pub const NELOG_UPS_PowerBack: DWORD = ERRLOG_BASE + 134; +pub const NELOG_UPS_CmdFileConfig: DWORD = ERRLOG_BASE + 135; +pub const NELOG_UPS_CmdFileExec: DWORD = ERRLOG_BASE + 136; +pub const NELOG_Missing_Parameter: DWORD = ERRLOG_BASE + 150; +pub const NELOG_Invalid_Config_Line: DWORD = ERRLOG_BASE + 151; +pub const NELOG_Invalid_Config_File: DWORD = ERRLOG_BASE + 152; +pub const NELOG_File_Changed: DWORD = ERRLOG_BASE + 153; +pub const NELOG_Files_Dont_Fit: DWORD = ERRLOG_BASE + 154; +pub const NELOG_Wrong_DLL_Version: DWORD = ERRLOG_BASE + 155; +pub const NELOG_Error_in_DLL: DWORD = ERRLOG_BASE + 156; +pub const NELOG_System_Error: DWORD = ERRLOG_BASE + 157; +pub const NELOG_FT_ErrLog_Too_Large: DWORD = ERRLOG_BASE + 158; +pub const NELOG_FT_Update_In_Progress: DWORD = ERRLOG_BASE + 159; +pub const NELOG_Joined_Domain: DWORD = ERRLOG_BASE + 160; +pub const NELOG_Joined_Workgroup: DWORD = ERRLOG_BASE + 161; +pub const NELOG_OEM_Code: DWORD = ERRLOG_BASE + 199; +pub const ERRLOG2_BASE: DWORD = 5700; +pub const NELOG_NetlogonSSIInitError: DWORD = ERRLOG2_BASE + 0; +pub const NELOG_NetlogonFailedToUpdateTrustList: DWORD = ERRLOG2_BASE + 1; +pub const NELOG_NetlogonFailedToAddRpcInterface: DWORD = ERRLOG2_BASE + 2; +pub const NELOG_NetlogonFailedToReadMailslot: DWORD = ERRLOG2_BASE + 3; +pub const NELOG_NetlogonFailedToRegisterSC: DWORD = ERRLOG2_BASE + 4; +pub const NELOG_NetlogonChangeLogCorrupt: DWORD = ERRLOG2_BASE + 5; +pub const NELOG_NetlogonFailedToCreateShare: DWORD = ERRLOG2_BASE + 6; +pub const NELOG_NetlogonDownLevelLogonFailed: DWORD = ERRLOG2_BASE + 7; +pub const NELOG_NetlogonDownLevelLogoffFailed: DWORD = ERRLOG2_BASE + 8; +pub const NELOG_NetlogonNTLogonFailed: DWORD = ERRLOG2_BASE + 9; +pub const NELOG_NetlogonNTLogoffFailed: DWORD = ERRLOG2_BASE + 10; +pub const NELOG_NetlogonPartialSyncCallSuccess: DWORD = ERRLOG2_BASE + 11; +pub const NELOG_NetlogonPartialSyncCallFailed: DWORD = ERRLOG2_BASE + 12; +pub const NELOG_NetlogonFullSyncCallSuccess: DWORD = ERRLOG2_BASE + 13; +pub const NELOG_NetlogonFullSyncCallFailed: DWORD = ERRLOG2_BASE + 14; +pub const NELOG_NetlogonPartialSyncSuccess: DWORD = ERRLOG2_BASE + 15; +pub const NELOG_NetlogonPartialSyncFailed: DWORD = ERRLOG2_BASE + 16; +pub const NELOG_NetlogonFullSyncSuccess: DWORD = ERRLOG2_BASE + 17; +pub const NELOG_NetlogonFullSyncFailed: DWORD = ERRLOG2_BASE + 18; +pub const NELOG_NetlogonAuthNoDomainController: DWORD = ERRLOG2_BASE + 19; +pub const NELOG_NetlogonAuthNoTrustLsaSecret: DWORD = ERRLOG2_BASE + 20; +pub const NELOG_NetlogonAuthNoTrustSamAccount: DWORD = ERRLOG2_BASE + 21; +pub const NELOG_NetlogonServerAuthFailed: DWORD = ERRLOG2_BASE + 22; +pub const NELOG_NetlogonServerAuthNoTrustSamAccount: DWORD = ERRLOG2_BASE + 23; +pub const NELOG_FailedToRegisterSC: DWORD = ERRLOG2_BASE + 24; +pub const NELOG_FailedToSetServiceStatus: DWORD = ERRLOG2_BASE + 25; +pub const NELOG_FailedToGetComputerName: DWORD = ERRLOG2_BASE + 26; +pub const NELOG_DriverNotLoaded: DWORD = ERRLOG2_BASE + 27; +pub const NELOG_NoTranportLoaded: DWORD = ERRLOG2_BASE + 28; +pub const NELOG_NetlogonFailedDomainDelta: DWORD = ERRLOG2_BASE + 29; +pub const NELOG_NetlogonFailedGlobalGroupDelta: DWORD = ERRLOG2_BASE + 30; +pub const NELOG_NetlogonFailedLocalGroupDelta: DWORD = ERRLOG2_BASE + 31; +pub const NELOG_NetlogonFailedUserDelta: DWORD = ERRLOG2_BASE + 32; +pub const NELOG_NetlogonFailedPolicyDelta: DWORD = ERRLOG2_BASE + 33; +pub const NELOG_NetlogonFailedTrustedDomainDelta: DWORD = ERRLOG2_BASE + 34; +pub const NELOG_NetlogonFailedAccountDelta: DWORD = ERRLOG2_BASE + 35; +pub const NELOG_NetlogonFailedSecretDelta: DWORD = ERRLOG2_BASE + 36; +pub const NELOG_NetlogonSystemError: DWORD = ERRLOG2_BASE + 37; +pub const NELOG_NetlogonDuplicateMachineAccounts: DWORD = ERRLOG2_BASE + 38; +pub const NELOG_NetlogonTooManyGlobalGroups: DWORD = ERRLOG2_BASE + 39; +pub const NELOG_NetlogonBrowserDriver: DWORD = ERRLOG2_BASE + 40; +pub const NELOG_NetlogonAddNameFailure: DWORD = ERRLOG2_BASE + 41; +pub const NELOG_RplMessages: DWORD = ERRLOG2_BASE + 42; +pub const NELOG_RplXnsBoot: DWORD = ERRLOG2_BASE + 43; +pub const NELOG_RplSystem: DWORD = ERRLOG2_BASE + 44; +pub const NELOG_RplWkstaTimeout: DWORD = ERRLOG2_BASE + 45; +pub const NELOG_RplWkstaFileOpen: DWORD = ERRLOG2_BASE + 46; +pub const NELOG_RplWkstaFileRead: DWORD = ERRLOG2_BASE + 47; +pub const NELOG_RplWkstaMemory: DWORD = ERRLOG2_BASE + 48; +pub const NELOG_RplWkstaFileChecksum: DWORD = ERRLOG2_BASE + 49; +pub const NELOG_RplWkstaFileLineCount: DWORD = ERRLOG2_BASE + 50; +pub const NELOG_RplWkstaBbcFile: DWORD = ERRLOG2_BASE + 51; +pub const NELOG_RplWkstaFileSize: DWORD = ERRLOG2_BASE + 52; +pub const NELOG_RplWkstaInternal: DWORD = ERRLOG2_BASE + 53; +pub const NELOG_RplWkstaWrongVersion: DWORD = ERRLOG2_BASE + 54; +pub const NELOG_RplWkstaNetwork: DWORD = ERRLOG2_BASE + 55; +pub const NELOG_RplAdapterResource: DWORD = ERRLOG2_BASE + 56; +pub const NELOG_RplFileCopy: DWORD = ERRLOG2_BASE + 57; +pub const NELOG_RplFileDelete: DWORD = ERRLOG2_BASE + 58; +pub const NELOG_RplFilePerms: DWORD = ERRLOG2_BASE + 59; +pub const NELOG_RplCheckConfigs: DWORD = ERRLOG2_BASE + 60; +pub const NELOG_RplCreateProfiles: DWORD = ERRLOG2_BASE + 61; +pub const NELOG_RplRegistry: DWORD = ERRLOG2_BASE + 62; +pub const NELOG_RplReplaceRPLDISK: DWORD = ERRLOG2_BASE + 63; +pub const NELOG_RplCheckSecurity: DWORD = ERRLOG2_BASE + 64; +pub const NELOG_RplBackupDatabase: DWORD = ERRLOG2_BASE + 65; +pub const NELOG_RplInitDatabase: DWORD = ERRLOG2_BASE + 66; +pub const NELOG_RplRestoreDatabaseFailure: DWORD = ERRLOG2_BASE + 67; +pub const NELOG_RplRestoreDatabaseSuccess: DWORD = ERRLOG2_BASE + 68; +pub const NELOG_RplInitRestoredDatabase: DWORD = ERRLOG2_BASE + 69; +pub const NELOG_NetlogonSessionTypeWrong: DWORD = ERRLOG2_BASE + 70; +pub const NELOG_RplUpgradeDBTo40: DWORD = ERRLOG2_BASE + 71; +pub const NELOG_NetlogonLanmanBdcsNotAllowed: DWORD = ERRLOG2_BASE + 72; +pub const NELOG_NetlogonNoDynamicDns: DWORD = ERRLOG2_BASE + 73; +pub const NELOG_NetlogonDynamicDnsRegisterFailure: DWORD = ERRLOG2_BASE + 74; +pub const NELOG_NetlogonDynamicDnsDeregisterFailure: DWORD = ERRLOG2_BASE + 75; +pub const NELOG_NetlogonFailedFileCreate: DWORD = ERRLOG2_BASE + 76; +pub const NELOG_NetlogonGetSubnetToSite: DWORD = ERRLOG2_BASE + 77; +pub const NELOG_NetlogonNoSiteForClient: DWORD = ERRLOG2_BASE + 78; +pub const NELOG_NetlogonBadSiteName: DWORD = ERRLOG2_BASE + 79; +pub const NELOG_NetlogonBadSubnetName: DWORD = ERRLOG2_BASE + 80; +pub const NELOG_NetlogonDynamicDnsServerFailure: DWORD = ERRLOG2_BASE + 81; +pub const NELOG_NetlogonDynamicDnsFailure: DWORD = ERRLOG2_BASE + 82; +pub const NELOG_NetlogonRpcCallCancelled: DWORD = ERRLOG2_BASE + 83; +pub const NELOG_NetlogonDcSiteCovered: DWORD = ERRLOG2_BASE + 84; +pub const NELOG_NetlogonDcSiteNotCovered: DWORD = ERRLOG2_BASE + 85; +pub const NELOG_NetlogonGcSiteCovered: DWORD = ERRLOG2_BASE + 86; +pub const NELOG_NetlogonGcSiteNotCovered: DWORD = ERRLOG2_BASE + 87; +pub const NELOG_NetlogonFailedSpnUpdate: DWORD = ERRLOG2_BASE + 88; +pub const NELOG_NetlogonFailedDnsHostNameUpdate: DWORD = ERRLOG2_BASE + 89; +pub const NELOG_NetlogonAuthNoUplevelDomainController: DWORD = ERRLOG2_BASE + 90; +pub const NELOG_NetlogonAuthDomainDowngraded: DWORD = ERRLOG2_BASE + 91; +pub const NELOG_NetlogonNdncSiteCovered: DWORD = ERRLOG2_BASE + 92; +pub const NELOG_NetlogonNdncSiteNotCovered: DWORD = ERRLOG2_BASE + 93; +pub const NELOG_NetlogonDcOldSiteCovered: DWORD = ERRLOG2_BASE + 94; +pub const NELOG_NetlogonDcSiteNotCoveredAuto: DWORD = ERRLOG2_BASE + 95; +pub const NELOG_NetlogonGcOldSiteCovered: DWORD = ERRLOG2_BASE + 96; +pub const NELOG_NetlogonGcSiteNotCoveredAuto: DWORD = ERRLOG2_BASE + 97; +pub const NELOG_NetlogonNdncOldSiteCovered: DWORD = ERRLOG2_BASE + 98; +pub const NELOG_NetlogonNdncSiteNotCoveredAuto: DWORD = ERRLOG2_BASE + 99; +pub const NELOG_NetlogonSpnMultipleSamAccountNames: DWORD = ERRLOG2_BASE + 100; +pub const NELOG_NetlogonSpnCrackNamesFailure: DWORD = ERRLOG2_BASE + 101; +pub const NELOG_NetlogonNoAddressToSiteMapping: DWORD = ERRLOG2_BASE + 102; +pub const NELOG_NetlogonInvalidGenericParameterValue: DWORD = ERRLOG2_BASE + 103; +pub const NELOG_NetlogonInvalidDwordParameterValue: DWORD = ERRLOG2_BASE + 104; +pub const NELOG_NetlogonServerAuthFailedNoAccount: DWORD = ERRLOG2_BASE + 105; +pub const NELOG_NetlogonNoDynamicDnsManual: DWORD = ERRLOG2_BASE + 106; +pub const NELOG_NetlogonNoSiteForClients: DWORD = ERRLOG2_BASE + 107; +pub const NELOG_NetlogonDnsDeregAborted: DWORD = ERRLOG2_BASE + 108; +pub const NELOG_NetlogonRpcPortRequestFailure: DWORD = ERRLOG2_BASE + 109; +pub const NELOG_NetlogonPartialSiteMappingForClients: DWORD = ERRLOG2_BASE + 110; +pub const NELOG_NetlogonRemoteDynamicDnsRegisterFailure: DWORD = ERRLOG2_BASE + 111; +pub const NELOG_NetlogonRemoteDynamicDnsDeregisterFailure: DWORD = ERRLOG2_BASE + 112; +pub const NELOG_NetlogonRejectedRemoteDynamicDnsRegister: DWORD = ERRLOG2_BASE + 113; +pub const NELOG_NetlogonRejectedRemoteDynamicDnsDeregister: DWORD = ERRLOG2_BASE + 114; +pub const NELOG_NetlogonRemoteDynamicDnsUpdateRequestFailure: DWORD = ERRLOG2_BASE + 115; +pub const NELOG_NetlogonUserValidationReqInitialTimeOut: DWORD = ERRLOG2_BASE + 116; +pub const NELOG_NetlogonUserValidationReqRecurringTimeOut: DWORD = ERRLOG2_BASE + 117; +pub const NELOG_NetlogonUserValidationReqWaitInitialWarning: DWORD = ERRLOG2_BASE + 118; +pub const NELOG_NetlogonUserValidationReqWaitRecurringWarning: DWORD = ERRLOG2_BASE + 119; +pub const NELOG_NetlogonFailedToAddAuthzRpcInterface: DWORD = ERRLOG2_BASE + 120; +pub const NELOG_NetLogonFailedToInitializeAuthzRm: DWORD = ERRLOG2_BASE + 121; +pub const NELOG_NetLogonFailedToInitializeRPCSD: DWORD = ERRLOG2_BASE + 122; +pub const NELOG_NetlogonMachinePasswdSetSucceeded: DWORD = ERRLOG2_BASE + 123; +pub const NELOG_NetlogonMsaPasswdSetSucceeded: DWORD = ERRLOG2_BASE + 124; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmjoin.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmjoin.rs new file mode 100644 index 0000000..72c72c0 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmjoin.rs @@ -0,0 +1,232 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +// Definitions and prototypes for the Net setup apis +use shared::lmcons::NET_API_STATUS; +use shared::minwindef::{BYTE, DWORD, PBYTE, PDWORD, ULONG}; +use um::wincrypt::PCCERT_CONTEXT; +use um::winnt::{HRESULT, LPCWSTR, LPWSTR, PVOID}; +ENUM!{enum NETSETUP_NAME_TYPE { + NetSetupUnknown = 0, + NetSetupMachine, + NetSetupWorkgroup, + NetSetupDomain, + NetSetupNonExistentDomain, + NetSetupDnsMachine, +}} +pub type PNETSETUP_NAME_TYPE = *mut NETSETUP_NAME_TYPE; +ENUM!{enum DSREG_JOIN_TYPE { + DSREG_UNKNOWN_JOIN = 0, + DSREG_DEVICE_JOIN = 1, + DSREG_WORKPLACE_JOIN = 2, +}} +pub type PDSREG_JOIN_TYPE = *mut DSREG_JOIN_TYPE; +STRUCT!{struct DSREG_USER_INFO { + pszUserEmail: LPWSTR, + pszUserKeyId: LPWSTR, + pszUserKeyName: LPWSTR, +}} +pub type PDSREG_USER_INFO = *mut DSREG_USER_INFO; +STRUCT!{struct DSREG_JOIN_INFO { + joinType: DSREG_JOIN_TYPE, + pJoinCertificate: PCCERT_CONTEXT, + pszDeviceId: LPWSTR, + pszIdpDomain: LPWSTR, + pszTenantId: LPWSTR, + pszJoinUserEmail: LPWSTR, + pszTenantDisplayName: LPWSTR, + pszMdmEnrollmentUrl: LPWSTR, + pszMdmTermsOfUseUrl: LPWSTR, + pszMdmComplianceUrl: LPWSTR, + pszUserSettingSyncUrl: LPWSTR, + pUserInfo: *mut DSREG_USER_INFO, +}} +pub type PDSREG_JOIN_INFO = *mut DSREG_JOIN_INFO; +pub const NETSETUP_JOIN_DOMAIN: DWORD = 0x00000001; +pub const NETSETUP_ACCT_CREATE: DWORD = 0x00000002; +pub const NETSETUP_ACCT_DELETE: DWORD = 0x00000004; +pub const NETSETUP_WIN9X_UPGRADE: DWORD = 0x00000010; +pub const NETSETUP_DOMAIN_JOIN_IF_JOINED: DWORD = 0x00000020; +pub const NETSETUP_JOIN_UNSECURE: DWORD = 0x00000040; +pub const NETSETUP_MACHINE_PWD_PASSED: DWORD = 0x00000080; +pub const NETSETUP_DEFER_SPN_SET: DWORD = 0x00000100; +pub const NETSETUP_JOIN_DC_ACCOUNT: DWORD = 0x00000200; +pub const NETSETUP_JOIN_WITH_NEW_NAME: DWORD = 0x00000400; +pub const NETSETUP_JOIN_READONLY: DWORD = 0x00000800; +pub const NETSETUP_DNS_NAME_CHANGES_ONLY: DWORD = 0x00001000; +pub const NETSETUP_INSTALL_INVOCATION: DWORD = 0x00040000; +pub const NETSETUP_AMBIGUOUS_DC: DWORD = 0x00001000; +pub const NETSETUP_NO_NETLOGON_CACHE: DWORD = 0x00002000; +pub const NETSETUP_DONT_CONTROL_SERVICES: DWORD = 0x00004000; +pub const NETSETUP_SET_MACHINE_NAME: DWORD = 0x00008000; +pub const NETSETUP_FORCE_SPN_SET: DWORD = 0x00010000; +pub const NETSETUP_NO_ACCT_REUSE: DWORD = 0x00020000; +pub const NETSETUP_ALT_SAMACCOUNTNAME: DWORD = 0x00020000; +pub const NETSETUP_IGNORE_UNSUPPORTED_FLAGS: DWORD = 0x10000000; +pub const NETSETUP_VALID_UNJOIN_FLAGS: DWORD = NETSETUP_ACCT_DELETE + | NETSETUP_IGNORE_UNSUPPORTED_FLAGS | NETSETUP_JOIN_DC_ACCOUNT; +pub const NETSETUP_PROCESS_OFFLINE_FLAGS: DWORD = NETSETUP_JOIN_DOMAIN + | NETSETUP_DOMAIN_JOIN_IF_JOINED | NETSETUP_JOIN_WITH_NEW_NAME | NETSETUP_DONT_CONTROL_SERVICES + | NETSETUP_MACHINE_PWD_PASSED; +extern "system" { + pub fn NetJoinDomain( + lpServer: LPCWSTR, + lpDomain: LPCWSTR, + lpMachineAccountOU: LPCWSTR, + lpAccount: LPCWSTR, + lpPassword: LPCWSTR, + fJoinOptions: DWORD, + ) -> NET_API_STATUS; + pub fn NetUnjoinDomain( + lpServer: LPCWSTR, + lpAccount: LPCWSTR, + lpPassword: LPCWSTR, + fUnjoinOptions: DWORD, + ) -> NET_API_STATUS; + pub fn NetRenameMachineInDomain( + lpServer: LPCWSTR, + lpNewMachineName: LPCWSTR, + lpAccount: LPCWSTR, + lpPassword: LPCWSTR, + fRenameOptions: DWORD, + ) -> NET_API_STATUS; + pub fn NetValidateName( + lpServer: LPCWSTR, + lpName: LPCWSTR, + lpAccount: LPCWSTR, + lpPassword: LPCWSTR, + NameType: NETSETUP_NAME_TYPE, + ) -> NET_API_STATUS; + pub fn NetGetJoinableOUs( + lpServer: LPCWSTR, + lpDomain: LPCWSTR, + lpAccount: LPCWSTR, + lpPassword: LPCWSTR, + OUCount: *mut DWORD, + OUs: *mut *mut LPWSTR, + ) -> NET_API_STATUS; +} +pub const NET_IGNORE_UNSUPPORTED_FLAGS: DWORD = 0x01; +extern "system" { + pub fn NetAddAlternateComputerName( + Server: LPCWSTR, + AlternateName: LPCWSTR, + DomainAccount: LPCWSTR, + DomainAccountPassword: LPCWSTR, + Reserved: ULONG, + ) -> NET_API_STATUS; + pub fn NetRemoveAlternateComputerName( + Server: LPCWSTR, + AlternateName: LPCWSTR, + DomainAccount: LPCWSTR, + DomainAccountPassword: LPCWSTR, + Reserved: ULONG, + ) -> NET_API_STATUS; + pub fn NetSetPrimaryComputerName( + Server: LPCWSTR, + PrimaryName: LPCWSTR, + DomainAccount: LPCWSTR, + DomainAccountPassword: LPCWSTR, + Reserved: ULONG, + ) -> NET_API_STATUS; +} +ENUM!{enum NET_COMPUTER_NAME_TYPE { + NetPrimaryComputerName, + NetAlternateComputerNames, + NetAllComputerNames, + NetComputerNameTypeMax, +}} +pub type PNET_COMPUTER_NAME_TYPE = *mut NET_COMPUTER_NAME_TYPE; +extern "system" { + pub fn NetEnumerateComputerNames( + Server: LPCWSTR, + NameType: NET_COMPUTER_NAME_TYPE, + Reserved: ULONG, + EntryCount: PDWORD, + ComputerNames: *mut *mut LPWSTR, + ) -> NET_API_STATUS; +} +pub const NETSETUP_PROVISION_DOWNLEVEL_PRIV_SUPPORT: DWORD = 0x00000001; +pub const NETSETUP_PROVISION_REUSE_ACCOUNT: DWORD = 0x00000002; +pub const NETSETUP_PROVISION_USE_DEFAULT_PASSWORD: DWORD = 0x00000004; +pub const NETSETUP_PROVISION_SKIP_ACCOUNT_SEARCH: DWORD = 0x00000008; +pub const NETSETUP_PROVISION_ROOT_CA_CERTS: DWORD = 0x00000010; +pub const NETSETUP_PROVISION_PERSISTENTSITE: DWORD = 0x00000020; +pub const NETSETUP_PROVISION_ONLINE_CALLER: DWORD = 0x40000000; +pub const NETSETUP_PROVISION_CHECK_PWD_ONLY: DWORD = 0x80000000; +extern "system" { + pub fn NetProvisionComputerAccount( + lpDomain: LPCWSTR, + lpMachineName: LPCWSTR, + lpMachineAccountOU: LPCWSTR, + lpDcName: LPCWSTR, + dwOptions: DWORD, + pProvisionBinData: *mut PBYTE, + pdwProvisionBinDataSize: *mut DWORD, + pProvisionTextData: *mut LPWSTR, + ) -> NET_API_STATUS; + pub fn NetRequestOfflineDomainJoin( + pProvisionBinData: *mut BYTE, + cbProvisionBinDataSize: DWORD, + dwOptions: DWORD, + lpWindowsPath: LPCWSTR, + ) -> NET_API_STATUS; +} +pub const NETSETUP_PROVISIONING_PARAMS_WIN8_VERSION: DWORD = 0x00000001; +pub const NETSETUP_PROVISIONING_PARAMS_CURRENT_VERSION: DWORD = 0x00000002; +STRUCT!{struct NETSETUP_PROVISIONING_PARAMS { + dwVersion: DWORD, + lpDomain: LPCWSTR, + lpHostName: LPCWSTR, + lpMachineAccountOU: LPCWSTR, + lpDcName: LPCWSTR, + dwProvisionOptions: DWORD, + aCertTemplateNames: *mut LPCWSTR, + cCertTemplateNames: DWORD, + aMachinePolicyNames: *mut LPCWSTR, + cMachinePolicyNames: DWORD, + aMachinePolicyPaths: *mut LPCWSTR, + cMachinePolicyPaths: DWORD, + lpNetbiosName: LPWSTR, + lpSiteName: LPWSTR, + lpPrimaryDNSDomain: LPWSTR, +}} +pub type PNETSETUP_PROVISIONING_PARAMS = *mut NETSETUP_PROVISIONING_PARAMS; +extern "system" { + pub fn NetCreateProvisioningPackage( + pProvisioningParams: PNETSETUP_PROVISIONING_PARAMS, + ppPackageBinData: *mut PBYTE, + pdwPackageBinDataSize: *mut DWORD, + ppPackageTextData: *mut LPWSTR, + ) -> NET_API_STATUS; + pub fn NetRequestProvisioningPackageInstall( + pPackageBinData: *mut BYTE, + dwPackageBinDataSize: DWORD, + dwProvisionOptions: DWORD, + lpWindowsPath: LPCWSTR, + pvReserved: PVOID, + ) -> NET_API_STATUS; + pub fn NetGetAadJoinInformation( + pcszTenantId: LPCWSTR, + ppJoinInfo: *mut PDSREG_JOIN_INFO, + ) -> HRESULT; + pub fn NetFreeAadJoinInformation( + pJoinInfo: PDSREG_JOIN_INFO, + ); +} +ENUM!{enum NETSETUP_JOIN_STATUS { + NetSetupUnknownStatus = 0, + NetSetupUnjoined, + NetSetupWorkgroupName, + NetSetupDomainName, +}} +pub type PNETSETUP_JOIN_STATUS = *mut NETSETUP_JOIN_STATUS; +extern "system" { + pub fn NetGetJoinInformation( + lpServer: LPCWSTR, + lpNameBuffer: *mut LPWSTR, + BufferType: PNETSETUP_JOIN_STATUS, + ) -> NET_API_STATUS; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmmsg.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmmsg.rs new file mode 100644 index 0000000..9970fe9 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmmsg.rs @@ -0,0 +1,56 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This file contains structures, function prototypes, and definitions for the NetMessage API +use shared::lmcons::NET_API_STATUS; +use shared::minwindef::{DWORD, LPBYTE, LPDWORD}; +use um::winnt::{LPCWSTR, LPWSTR}; +extern "system" { + pub fn NetMessageNameAdd( + servername: LPCWSTR, + msgname: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetMessageNameEnum( + servername: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetMessageNameGetInfo( + servername: LPCWSTR, + msgname: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetMessageNameDel( + servername: LPCWSTR, + msgname: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetMessageBufferSend( + servername: LPCWSTR, + msgname: LPCWSTR, + fromname: LPCWSTR, + buf: LPBYTE, + buflen: DWORD, + ) -> NET_API_STATUS; +} +STRUCT!{struct MSG_INFO_0 { + msgi0_name: LPWSTR, +}} +pub type PMSG_INFO_0 = *mut MSG_INFO_0; +pub type LPMSG_INFO_0 = *mut MSG_INFO_0; +STRUCT!{struct MSG_INFO_1 { + msgi1_name: LPWSTR, + msgi1_forward_flag: DWORD, + msgi1_forward: LPWSTR, +}} +pub type PMSG_INFO_1 = *mut MSG_INFO_1; +pub type LPMSG_INFO_1 = *mut MSG_INFO_1; +pub const MSGNAME_NOT_FORWARDED: DWORD = 0; +pub const MSGNAME_FORWARDED_TO: DWORD = 0x04; +pub const MSGNAME_FORWARDED_FROM: DWORD = 0x10; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmremutl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmremutl.rs new file mode 100644 index 0000000..2727520 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmremutl.rs @@ -0,0 +1,61 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This file contains structures, function prototypes, and definitions for the NetRemote API +use shared::lmcons::NET_API_STATUS; +use shared::minwindef::{DWORD, LPBYTE, LPDWORD}; +use um::winnt::{CHAR, LONG, LPCWSTR, LPSTR}; +pub type DESC_CHAR = CHAR; +pub type LPDESC = LPSTR; +extern "system" { + pub fn NetRemoteTOD( + UncServerName: LPCWSTR, + BufferPtr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetRemoteComputerSupports( + UncServerName: LPCWSTR, + OptionsWanted: DWORD, + OptionsSupported: LPDWORD, + ) -> NET_API_STATUS; +} +extern "C" { + pub fn RxRemoteApi( + ApiNumber: DWORD, + UncServerName: LPCWSTR, + ParmDescString: LPDESC, + DataDesc16: LPDESC, + DataDesc32: LPDESC, + DataDescSmb: LPDESC, + AuxDesc16: LPDESC, + AuxDesc32: LPDESC, + AuxDescSmb: LPDESC, + Flags: DWORD, + ) -> NET_API_STATUS; +} +STRUCT!{struct TIME_OF_DAY_INFO { + tod_elapsedt: DWORD, + tod_msecs: DWORD, + tod_hours: DWORD, + tod_mins: DWORD, + tod_secs: DWORD, + tod_hunds: DWORD, + tod_timezone: LONG, + tod_tinterval: DWORD, + tod_day: DWORD, + tod_month: DWORD, + tod_year: DWORD, + tod_weekday: DWORD, +}} +pub type PTIME_OF_DAY_INFO = *mut TIME_OF_DAY_INFO; +pub type LPTIME_OF_DAY_INFO = *mut TIME_OF_DAY_INFO; +pub const SUPPORTS_REMOTE_ADMIN_PROTOCOL: DWORD = 0x00000002; +pub const SUPPORTS_RPC: DWORD = 0x00000004; +pub const SUPPORTS_SAM_PROTOCOL: DWORD = 0x00000008; +pub const SUPPORTS_UNICODE: DWORD = 0x00000010; +pub const SUPPORTS_LOCAL: DWORD = 0x00000020; +pub const SUPPORTS_ANY: DWORD = 0xFFFFFFFF; +pub const NO_PERMISSION_REQUIRED: DWORD = 0x00000001; +pub const ALLOCATE_RESPONSE: DWORD = 0x00000002; +pub const USE_SPECIFIC_TRANSPORT: DWORD = 0x80000000; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmrepl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmrepl.rs new file mode 100644 index 0000000..81a665b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmrepl.rs @@ -0,0 +1,200 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This file contains structures, function prototypes, and definitions for the replicator APIs +use shared::lmcons::{NET_API_STATUS, PARMNUM_BASE_INFOLEVEL}; +use shared::minwindef::{DWORD, LPBYTE, LPDWORD}; +use um::winnt::{LPCWSTR, LPWSTR}; +pub const REPL_ROLE_EXPORT: DWORD = 1; +pub const REPL_ROLE_IMPORT: DWORD = 2; +pub const REPL_ROLE_BOTH: DWORD = 3; +pub const REPL_INTERVAL_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + 0; +pub const REPL_PULSE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + 1; +pub const REPL_GUARDTIME_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + 2; +pub const REPL_RANDOM_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + 3; +STRUCT!{struct REPL_INFO_0 { + rp0_role: DWORD, + rp0_exportpath: LPWSTR, + rp0_exportlist: LPWSTR, + rp0_importpath: LPWSTR, + rp0_importlist: LPWSTR, + rp0_logonusername: LPWSTR, + rp0_interval: DWORD, + rp0_pulse: DWORD, + rp0_guardtime: DWORD, + rp0_random: DWORD, +}} +pub type PREPL_INFO_0 = *mut REPL_INFO_0; +pub type LPREPL_INFO_0 = *mut REPL_INFO_0; +STRUCT!{struct REPL_INFO_1000 { + rp1000_interval: DWORD, +}} +pub type PREPL_INFO_1000 = *mut REPL_INFO_1000; +pub type LPREPL_INFO_1000 = *mut REPL_INFO_1000; +STRUCT!{struct REPL_INFO_1001 { + rp1001_pulse: DWORD, +}} +pub type PREPL_INFO_1001 = *mut REPL_INFO_1001; +pub type LPREPL_INFO_1001 = *mut REPL_INFO_1001; +STRUCT!{struct REPL_INFO_1002 { + rp1002_guardtime: DWORD, +}} +pub type PREPL_INFO_1002 = *mut REPL_INFO_1002; +pub type LPREPL_INFO_1002 = *mut REPL_INFO_1002; +STRUCT!{struct REPL_INFO_1003 { + rp1003_random: DWORD, +}} +pub type PREPL_INFO_1003 = *mut REPL_INFO_1003; +pub type LPREPL_INFO_1003 = *mut REPL_INFO_1003; +extern "system" { + pub fn NetReplGetInfo( + servername: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetReplSetInfo( + servername: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; +} +pub const REPL_INTEGRITY_FILE: DWORD = 1; +pub const REPL_INTEGRITY_TREE: DWORD = 2; +pub const REPL_EXTENT_FILE: DWORD = 1; +pub const REPL_EXTENT_TREE: DWORD = 2; +pub const REPL_EXPORT_INTEGRITY_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + 0; +pub const REPL_EXPORT_EXTENT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + 1; +STRUCT!{struct REPL_EDIR_INFO_0 { + rped0_dirname: LPWSTR, +}} +pub type PREPL_EDIR_INFO_0 = *mut REPL_EDIR_INFO_0; +pub type LPREPL_EDIR_INFO_0 = *mut REPL_EDIR_INFO_0; +STRUCT!{struct REPL_EDIR_INFO_1 { + rped1_dirname: LPWSTR, + rped1_integrity: DWORD, + rped1_extent: DWORD, +}} +pub type PREPL_EDIR_INFO_1 = *mut REPL_EDIR_INFO_1; +pub type LPREPL_EDIR_INFO_1 = *mut REPL_EDIR_INFO_1; +STRUCT!{struct REPL_EDIR_INFO_2 { + rped2_dirname: LPWSTR, + rped2_integrity: DWORD, + rped2_extent: DWORD, + rped2_lockcount: DWORD, + rped2_locktime: DWORD, +}} +pub type PREPL_EDIR_INFO_2 = *mut REPL_EDIR_INFO_2; +pub type LPREPL_EDIR_INFO_2 = *mut REPL_EDIR_INFO_2; +STRUCT!{struct REPL_EDIR_INFO_1000 { + rped1000_integrity: DWORD, +}} +pub type PREPL_EDIR_INFO_1000 = *mut REPL_EDIR_INFO_1000; +pub type LPREPL_EDIR_INFO_1000 = *mut REPL_EDIR_INFO_1000; +STRUCT!{struct REPL_EDIR_INFO_1001 { + rped1001_extent: DWORD, +}} +pub type PREPL_EDIR_INFO_1001 = *mut REPL_EDIR_INFO_1001; +pub type LPREPL_EDIR_INFO_1001 = *mut REPL_EDIR_INFO_1001; +extern "system" { + pub fn NetReplExportDirAdd( + servername: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetReplExportDirDel( + servername: LPCWSTR, + dirname: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetReplExportDirEnum( + servername: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetReplExportDirGetInfo( + servername: LPCWSTR, + dirname: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetReplExportDirSetInfo( + servername: LPCWSTR, + dirname: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetReplExportDirLock( + servername: LPCWSTR, + dirname: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetReplExportDirUnlock( + servername: LPCWSTR, + dirname: LPCWSTR, + unlockforce: DWORD, + ) -> NET_API_STATUS; +} +pub const REPL_UNLOCK_NOFORCE: DWORD = 0; +pub const REPL_UNLOCK_FORCE: DWORD = 1; +STRUCT!{struct REPL_IDIR_INFO_0 { + rpid0_dirname: LPWSTR, +}} +pub type PREPL_IDIR_INFO_0 = *mut REPL_IDIR_INFO_0; +pub type LPREPL_IDIR_INFO_0 = *mut REPL_IDIR_INFO_0; +STRUCT!{struct REPL_IDIR_INFO_1 { + rpid1_dirname: LPWSTR, + rpid1_state: DWORD, + rpid1_mastername: LPWSTR, + rpid1_last_update_time: DWORD, + rpid1_lockcount: DWORD, + rpid1_locktime: DWORD, +}} +pub type PREPL_IDIR_INFO_1 = *mut REPL_IDIR_INFO_1; +pub type LPREPL_IDIR_INFO_1 = *mut REPL_IDIR_INFO_1; +extern "system" { + pub fn NetReplImportDirAdd( + servername: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetReplImportDirDel( + servername: LPCWSTR, + dirname: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetReplImportDirEnum( + servername: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetReplImportDirGetInfo( + servername: LPCWSTR, + dirname: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetReplImportDirLock( + servername: LPCWSTR, + dirname: LPCWSTR, + ) -> NET_API_STATUS; + pub fn NetReplImportDirUnlock( + servername: LPCWSTR, + dirname: LPCWSTR, + unlockforce: DWORD, + ) -> NET_API_STATUS; +} +pub const REPL_STATE_OK: DWORD = 0; +pub const REPL_STATE_NO_MASTER: DWORD = 1; +pub const REPL_STATE_NO_SYNC: DWORD = 2; +pub const REPL_STATE_NEVER_REPLICATED: DWORD = 3; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmserver.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmserver.rs new file mode 100644 index 0000000..621c4be --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmserver.rs @@ -0,0 +1,1255 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This file contains information about NetServer APIs +use shared::guiddef::GUID; +use shared::lmcons::{LMCSTR, LMSTR, NET_API_STATUS, PARMNUM_BASE_INFOLEVEL, PATHLEN}; +use shared::minwindef::{BOOL, BYTE, DWORD, LPBYTE, LPDWORD, ULONG}; +use um::winnt::{BOOLEAN, LONG}; +use um::winsvc::SERVICE_STATUS_HANDLE; +extern "system" { + pub fn NetServerEnum( + servername: LMCSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + servertype: DWORD, + domain: LMCSTR, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetServerEnumEx( + servername: LMCSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + servertype: DWORD, + domain: LMCSTR, + FirstNameToReturn: LMCSTR, + ) -> NET_API_STATUS; + pub fn NetServerGetInfo( + servername: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetServerSetInfo( + servername: LMSTR, + level: DWORD, + buf: LPBYTE, + ParmError: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetServerDiskEnum( + servername: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetServerComputerNameAdd( + ServerName: LMSTR, + EmulatedDomainName: LMSTR, + EmulatedServerName: LMSTR, + ) -> NET_API_STATUS; + pub fn NetServerComputerNameDel( + ServerName: LMSTR, + EmulatedServerName: LMSTR, + ) -> NET_API_STATUS; + pub fn NetServerTransportAdd( + servername: LMSTR, + level: DWORD, + bufptr: LPBYTE, + ) -> NET_API_STATUS; + pub fn NetServerTransportAddEx( + servername: LMSTR, + level: DWORD, + bufptr: LPBYTE, + ) -> NET_API_STATUS; + pub fn NetServerTransportDel( + servername: LMSTR, + level: DWORD, + bufptr: LPBYTE, + ) -> NET_API_STATUS; + pub fn NetServerTransportEnum( + servername: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn SetServiceBits( + hServiceStatus: SERVICE_STATUS_HANDLE, + dwServiceBits: DWORD, + bSetBitsOn: BOOL, + bUpdateImmediately: BOOL, + ) -> BOOL; +} +STRUCT!{struct SERVER_INFO_100 { + sv100_platform_id: DWORD, + sv100_name: LMSTR, +}} +pub type PSERVER_INFO_100 = *mut SERVER_INFO_100; +pub type LPSERVER_INFO_100 = *mut SERVER_INFO_100; +STRUCT!{struct SERVER_INFO_101 { + sv101_platform_id: DWORD, + sv101_name: LMSTR, + sv101_version_major: DWORD, + sv101_version_minor: DWORD, + sv101_type: DWORD, + sv101_comment: LMSTR, +}} +pub type PSERVER_INFO_101 = *mut SERVER_INFO_101; +pub type LPSERVER_INFO_101 = *mut SERVER_INFO_101; +STRUCT!{struct SERVER_INFO_102 { + sv102_platform_id: DWORD, + sv102_name: LMSTR, + sv102_version_major: DWORD, + sv102_version_minor: DWORD, + sv102_type: DWORD, + sv102_comment: LMSTR, + sv102_users: DWORD, + sv102_disc: LONG, + sv102_hidden: BOOL, + sv102_announce: DWORD, + sv102_anndelta: DWORD, + sv102_licenses: DWORD, + sv102_userpath: LMSTR, +}} +pub type PSERVER_INFO_102 = *mut SERVER_INFO_102; +pub type LPSERVER_INFO_102 = *mut SERVER_INFO_102; +STRUCT!{struct SERVER_INFO_103 { + sv103_platform_id: DWORD, + sv103_name: LMSTR, + sv103_version_major: DWORD, + sv103_version_minor: DWORD, + sv103_type: DWORD, + sv103_comment: LMSTR, + sv103_users: DWORD, + sv103_disc: LONG, + sv103_hidden: BOOL, + sv103_announce: DWORD, + sv103_anndelta: DWORD, + sv103_licenses: DWORD, + sv103_userpath: LMSTR, + sv103_capabilities: DWORD, +}} +pub type PSERVER_INFO_103 = *mut SERVER_INFO_103; +pub type LPSERVER_INFO_103 = *mut SERVER_INFO_103; +STRUCT!{struct SERVER_INFO_402 { + sv402_ulist_mtime: DWORD, + sv402_glist_mtime: DWORD, + sv402_alist_mtime: DWORD, + sv402_alerts: LMSTR, + sv402_security: DWORD, + sv402_numadmin: DWORD, + sv402_lanmask: DWORD, + sv402_guestacct: LMSTR, + sv402_chdevs: DWORD, + sv402_chdevq: DWORD, + sv402_chdevjobs: DWORD, + sv402_connections: DWORD, + sv402_shares: DWORD, + sv402_openfiles: DWORD, + sv402_sessopens: DWORD, + sv402_sessvcs: DWORD, + sv402_sessreqs: DWORD, + sv402_opensearch: DWORD, + sv402_activelocks: DWORD, + sv402_numreqbuf: DWORD, + sv402_sizreqbuf: DWORD, + sv402_numbigbuf: DWORD, + sv402_numfiletasks: DWORD, + sv402_alertsched: DWORD, + sv402_erroralert: DWORD, + sv402_logonalert: DWORD, + sv402_accessalert: DWORD, + sv402_diskalert: DWORD, + sv402_netioalert: DWORD, + sv402_maxauditsz: DWORD, + sv402_srvheuristics: LMSTR, +}} +pub type PSERVER_INFO_402 = *mut SERVER_INFO_402; +pub type LPSERVER_INFO_402 = *mut SERVER_INFO_402; +STRUCT!{struct SERVER_INFO_403 { + sv403_ulist_mtime: DWORD, + sv403_glist_mtime: DWORD, + sv403_alist_mtime: DWORD, + sv403_alerts: LMSTR, + sv403_security: DWORD, + sv403_numadmin: DWORD, + sv403_lanmask: DWORD, + sv403_guestacct: LMSTR, + sv403_chdevs: DWORD, + sv403_chdevq: DWORD, + sv403_chdevjobs: DWORD, + sv403_connections: DWORD, + sv403_shares: DWORD, + sv403_openfiles: DWORD, + sv403_sessopens: DWORD, + sv403_sessvcs: DWORD, + sv403_sessreqs: DWORD, + sv403_opensearch: DWORD, + sv403_activelocks: DWORD, + sv403_numreqbuf: DWORD, + sv403_sizreqbuf: DWORD, + sv403_numbigbuf: DWORD, + sv403_numfiletasks: DWORD, + sv403_alertsched: DWORD, + sv403_erroralert: DWORD, + sv403_logonalert: DWORD, + sv403_accessalert: DWORD, + sv403_diskalert: DWORD, + sv403_netioalert: DWORD, + sv403_maxauditsz: DWORD, + sv403_srvheuristics: LMSTR, + sv403_auditedevents: DWORD, + sv403_autoprofile: DWORD, + sv403_autopath: LMSTR, +}} +pub type PSERVER_INFO_403 = *mut SERVER_INFO_403; +pub type LPSERVER_INFO_403 = *mut SERVER_INFO_403; +STRUCT!{struct SERVER_INFO_502 { + sv502_sessopens: DWORD, + sv502_sessvcs: DWORD, + sv502_opensearch: DWORD, + sv502_sizreqbuf: DWORD, + sv502_initworkitems: DWORD, + sv502_maxworkitems: DWORD, + sv502_rawworkitems: DWORD, + sv502_irpstacksize: DWORD, + sv502_maxrawbuflen: DWORD, + sv502_sessusers: DWORD, + sv502_sessconns: DWORD, + sv502_maxpagedmemoryusage: DWORD, + sv502_maxnonpagedmemoryusage: DWORD, + sv502_enablesoftcompat: BOOL, + sv502_enableforcedlogoff: BOOL, + sv502_timesource: BOOL, + sv502_acceptdownlevelapis: BOOL, + sv502_lmannounce: BOOL, +}} +pub type PSERVER_INFO_502 = *mut SERVER_INFO_502; +pub type LPSERVER_INFO_502 = *mut SERVER_INFO_502; +STRUCT!{struct SERVER_INFO_503 { + sv503_sessopens : DWORD, + sv503_sessvcs: DWORD, + sv503_opensearch: DWORD, + sv503_sizreqbuf: DWORD, + sv503_initworkitems: DWORD, + sv503_maxworkitems: DWORD, + sv503_rawworkitems: DWORD, + sv503_irpstacksize: DWORD, + sv503_maxrawbuflen: DWORD, + sv503_sessusers: DWORD, + sv503_sessconns: DWORD, + sv503_maxpagedmemoryusage: DWORD, + sv503_maxnonpagedmemoryusage: DWORD, + sv503_enablesoftcompat: BOOL, + sv503_enableforcedlogoff: BOOL, + sv503_timesource: BOOL, + sv503_acceptdownlevelapis: BOOL, + sv503_lmannounce: BOOL, + sv503_domain: LMSTR, + sv503_maxcopyreadlen: DWORD, + sv503_maxcopywritelen: DWORD, + sv503_minkeepsearch: DWORD, + sv503_maxkeepsearch: DWORD, + sv503_minkeepcomplsearch: DWORD, + sv503_maxkeepcomplsearch: DWORD, + sv503_threadcountadd: DWORD, + sv503_numblockthreads: DWORD, + sv503_scavtimeout: DWORD, + sv503_minrcvqueue: DWORD, + sv503_minfreeworkitems: DWORD, + sv503_xactmemsize: DWORD, + sv503_threadpriority: DWORD, + sv503_maxmpxct: DWORD, + sv503_oplockbreakwait: DWORD, + sv503_oplockbreakresponsewait: DWORD, + sv503_enableoplocks: BOOL, + sv503_enableoplockforceclose: BOOL, + sv503_enablefcbopens: BOOL, + sv503_enableraw: BOOL, + sv503_enablesharednetdrives: BOOL, + sv503_minfreeconnections: DWORD, + sv503_maxfreeconnections: DWORD, +}} +pub type PSERVER_INFO_503 = *mut SERVER_INFO_503; +pub type LPSERVER_INFO_503 = *mut SERVER_INFO_503; +STRUCT!{struct SERVER_INFO_599 { + sv599_sessopens: DWORD, + sv599_sessvcs: DWORD, + sv599_opensearch: DWORD, + sv599_sizreqbuf: DWORD, + sv599_initworkitems: DWORD, + sv599_maxworkitems: DWORD, + sv599_rawworkitems: DWORD, + sv599_irpstacksize: DWORD, + sv599_maxrawbuflen: DWORD, + sv599_sessusers: DWORD, + sv599_sessconns: DWORD, + sv599_maxpagedmemoryusage: DWORD, + sv599_maxnonpagedmemoryusage: DWORD, + sv599_enablesoftcompat: BOOL, + sv599_enableforcedlogoff: BOOL, + sv599_timesource: BOOL, + sv599_acceptdownlevelapis: BOOL, + sv599_lmannounce: BOOL, + sv599_domain: LMSTR, + sv599_maxcopyreadlen: DWORD, + sv599_maxcopywritelen: DWORD, + sv599_minkeepsearch: DWORD, + sv599_maxkeepsearch: DWORD, + sv599_minkeepcomplsearch: DWORD, + sv599_maxkeepcomplsearch: DWORD, + sv599_threadcountadd: DWORD, + sv599_numblockthreads: DWORD, + sv599_scavtimeout: DWORD, + sv599_minrcvqueue: DWORD, + sv599_minfreeworkitems: DWORD, + sv599_xactmemsize: DWORD, + sv599_threadpriority: DWORD, + sv599_maxmpxct: DWORD, + sv599_oplockbreakwait: DWORD, + sv599_oplockbreakresponsewait: DWORD, + sv599_enableoplocks: BOOL, + sv599_enableoplockforceclose: BOOL, + sv599_enablefcbopens: BOOL, + sv599_enableraw: BOOL, + sv599_enablesharednetdrives: BOOL, + sv599_minfreeconnections: DWORD, + sv599_maxfreeconnections: DWORD, + sv599_initsesstable: DWORD, + sv599_initconntable: DWORD, + sv599_initfiletable: DWORD, + sv599_initsearchtable: DWORD, + sv599_alertschedule: DWORD, + sv599_errorthreshold: DWORD, + sv599_networkerrorthreshold: DWORD, + sv599_diskspacethreshold: DWORD, + sv599_reserved: DWORD, + sv599_maxlinkdelay: DWORD, + sv599_minlinkthroughput: DWORD, + sv599_linkinfovalidtime: DWORD, + sv599_scavqosinfoupdatetime: DWORD, + sv599_maxworkitemidletime: DWORD, +}} +pub type PSERVER_INFO_599 = *mut SERVER_INFO_599; +pub type LPSERVER_INFO_599 = *mut SERVER_INFO_599; +STRUCT!{struct SERVER_INFO_598 { + sv598_maxrawworkitems: DWORD, + sv598_maxthreadsperqueue: DWORD, + sv598_producttype: DWORD, + sv598_serversize: DWORD, + sv598_connectionlessautodisc: DWORD, + sv598_sharingviolationretries: DWORD, + sv598_sharingviolationdelay: DWORD, + sv598_maxglobalopensearch: DWORD, + sv598_removeduplicatesearches: DWORD, + sv598_lockviolationoffset: DWORD, + sv598_lockviolationdelay: DWORD, + sv598_mdlreadswitchover: DWORD, + sv598_cachedopenlimit: DWORD, + sv598_otherqueueaffinity: DWORD, + sv598_restrictnullsessaccess: BOOL, + sv598_enablewfw311directipx: BOOL, + sv598_queuesamplesecs: DWORD, + sv598_balancecount: DWORD, + sv598_preferredaffinity: DWORD, + sv598_maxfreerfcbs: DWORD, + sv598_maxfreemfcbs: DWORD, + sv598_maxfreelfcbs: DWORD, + sv598_maxfreepagedpoolchunks: DWORD, + sv598_minpagedpoolchunksize: DWORD, + sv598_maxpagedpoolchunksize: DWORD, + sv598_sendsfrompreferredprocessor: BOOL, + sv598_cacheddirectorylimit: DWORD, + sv598_maxcopylength: DWORD, + sv598_enablecompression: BOOL, + sv598_autosharewks: BOOL, + sv598_autoshareserver: BOOL, + sv598_enablesecuritysignature: BOOL, + sv598_requiresecuritysignature: BOOL, + sv598_minclientbuffersize: DWORD, + sv598_serverguid: GUID, + sv598_ConnectionNoSessionsTimeout: DWORD, + sv598_IdleThreadTimeOut: DWORD, + sv598_enableW9xsecuritysignature: BOOL, + sv598_enforcekerberosreauthentication: BOOL, + sv598_disabledos: BOOL, + sv598_lowdiskspaceminimum: DWORD, + sv598_disablestrictnamechecking: BOOL, + sv598_enableauthenticateusersharing: BOOL, +}} +pub type PSERVER_INFO_598 = *mut SERVER_INFO_598; +pub type LPSERVER_INFO_598 = *mut SERVER_INFO_598; +STRUCT!{struct SERVER_INFO_1005 { + sv1005_comment: LMSTR, +}} +pub type PSERVER_INFO_1005 = *mut SERVER_INFO_1005; +pub type LPSERVER_INFO_1005 = *mut SERVER_INFO_1005; +STRUCT!{struct SERVER_INFO_1107 { + sv1107_users: DWORD, +}} +pub type PSERVER_INFO_1107 = *mut SERVER_INFO_1107; +pub type LPSERVER_INFO_1107 = *mut SERVER_INFO_1107; +STRUCT!{struct SERVER_INFO_1010 { + sv1010_disc: LONG, +}} +pub type PSERVER_INFO_1010 = *mut SERVER_INFO_1010; +pub type LPSERVER_INFO_1010 = *mut SERVER_INFO_1010; +STRUCT!{struct SERVER_INFO_1016 { + sv1016_hidden: BOOL, +}} +pub type PSERVER_INFO_1016 = *mut SERVER_INFO_1016; +pub type LPSERVER_INFO_1016 = *mut SERVER_INFO_1016; +STRUCT!{struct SERVER_INFO_1017 { + sv1017_announce: DWORD, +}} +pub type PSERVER_INFO_1017 = *mut SERVER_INFO_1017; +pub type LPSERVER_INFO_1017 = *mut SERVER_INFO_1017; +STRUCT!{struct SERVER_INFO_1018 { + sv1018_anndelta: DWORD, +}} +pub type PSERVER_INFO_1018 = *mut SERVER_INFO_1018; +pub type LPSERVER_INFO_1018 = *mut SERVER_INFO_1018; +STRUCT!{struct SERVER_INFO_1501 { + sv1501_sessopens: DWORD, +}} +pub type PSERVER_INFO_1501 = *mut SERVER_INFO_1501; +pub type LPSERVER_INFO_1501 = *mut SERVER_INFO_1501; +STRUCT!{struct SERVER_INFO_1502 { + sv1502_sessvcs: DWORD, +}} +pub type PSERVER_INFO_1502 = *mut SERVER_INFO_1502; +pub type LPSERVER_INFO_1502 = *mut SERVER_INFO_1502; +STRUCT!{struct SERVER_INFO_1503 { + sv1503_opensearch: DWORD, +}} +pub type PSERVER_INFO_1503 = *mut SERVER_INFO_1503; +pub type LPSERVER_INFO_1503 = *mut SERVER_INFO_1503; +STRUCT!{struct SERVER_INFO_1506 { + sv1506_maxworkitems: DWORD, +}} +pub type PSERVER_INFO_1506 = *mut SERVER_INFO_1506; +pub type LPSERVER_INFO_1506 = *mut SERVER_INFO_1506; +STRUCT!{struct SERVER_INFO_1509 { + sv1509_maxrawbuflen: DWORD, +}} +pub type PSERVER_INFO_1509 = *mut SERVER_INFO_1509; +pub type LPSERVER_INFO_1509 = *mut SERVER_INFO_1509; +STRUCT!{struct SERVER_INFO_1510 { + sv1510_sessusers: DWORD, +}} +pub type PSERVER_INFO_1510 = *mut SERVER_INFO_1510; +pub type LPSERVER_INFO_1510 = *mut SERVER_INFO_1510; +STRUCT!{struct SERVER_INFO_1511 { + sv1511_sessconns: DWORD, +}} +pub type PSERVER_INFO_1511 = *mut SERVER_INFO_1511; +pub type LPSERVER_INFO_1511 = *mut SERVER_INFO_1511; +STRUCT!{struct SERVER_INFO_1512 { + sv1512_maxnonpagedmemoryusage: DWORD, +}} +pub type PSERVER_INFO_1512 = *mut SERVER_INFO_1512; +pub type LPSERVER_INFO_1512 = *mut SERVER_INFO_1512; +STRUCT!{struct SERVER_INFO_1513 { + sv1513_maxpagedmemoryusage: DWORD, +}} +pub type PSERVER_INFO_1513 = *mut SERVER_INFO_1513; +pub type LPSERVER_INFO_1513 = *mut SERVER_INFO_1513; +STRUCT!{struct SERVER_INFO_1514 { + sv1514_enablesoftcompat: BOOL, +}} +pub type PSERVER_INFO_1514 = *mut SERVER_INFO_1514; +pub type LPSERVER_INFO_1514 = *mut SERVER_INFO_1514; +STRUCT!{struct SERVER_INFO_1515 { + sv1515_enableforcedlogoff: BOOL, +}} +pub type PSERVER_INFO_1515 = *mut SERVER_INFO_1515; +pub type LPSERVER_INFO_1515 = *mut SERVER_INFO_1515; +STRUCT!{struct SERVER_INFO_1516 { + sv1516_timesource: BOOL, +}} +pub type PSERVER_INFO_1516 = *mut SERVER_INFO_1516; +pub type LPSERVER_INFO_1516 = *mut SERVER_INFO_1516; +STRUCT!{struct SERVER_INFO_1518 { + sv1518_lmannounce: BOOL, +}} +pub type PSERVER_INFO_1518 = *mut SERVER_INFO_1518; +pub type LPSERVER_INFO_1518 = *mut SERVER_INFO_1518; +STRUCT!{struct SERVER_INFO_1520 { + sv1520_maxcopyreadlen: DWORD, +}} +pub type PSERVER_INFO_1520 = *mut SERVER_INFO_1520; +pub type LPSERVER_INFO_1520 = *mut SERVER_INFO_1520; +STRUCT!{struct SERVER_INFO_1521 { + sv1521_maxcopywritelen: DWORD, +}} +pub type PSERVER_INFO_1521 = *mut SERVER_INFO_1521; +pub type LPSERVER_INFO_1521 = *mut SERVER_INFO_1521; +STRUCT!{struct SERVER_INFO_1522 { + sv1522_minkeepsearch: DWORD, +}} +pub type PSERVER_INFO_1522 = *mut SERVER_INFO_1522; +pub type LPSERVER_INFO_1522 = *mut SERVER_INFO_1522; +STRUCT!{struct SERVER_INFO_1523 { + sv1523_maxkeepsearch: DWORD, +}} +pub type PSERVER_INFO_1523 = *mut SERVER_INFO_1523; +pub type LPSERVER_INFO_1523 = *mut SERVER_INFO_1523; +STRUCT!{struct SERVER_INFO_1524 { + sv1524_minkeepcomplsearch: DWORD, +}} +pub type PSERVER_INFO_1524 = *mut SERVER_INFO_1524; +pub type LPSERVER_INFO_1524 = *mut SERVER_INFO_1524; +STRUCT!{struct SERVER_INFO_1525 { + sv1525_maxkeepcomplsearch: DWORD, +}} +pub type PSERVER_INFO_1525 = *mut SERVER_INFO_1525; +pub type LPSERVER_INFO_1525 = *mut SERVER_INFO_1525; +STRUCT!{struct SERVER_INFO_1528 { + sv1528_scavtimeout: DWORD, +}} +pub type PSERVER_INFO_1528 = *mut SERVER_INFO_1528; +pub type LPSERVER_INFO_1528 = *mut SERVER_INFO_1528; +STRUCT!{struct SERVER_INFO_1529 { + sv1529_minrcvqueue: DWORD, +}} +pub type PSERVER_INFO_1529 = *mut SERVER_INFO_1529; +pub type LPSERVER_INFO_1529 = *mut SERVER_INFO_1529; +STRUCT!{struct SERVER_INFO_1530 { + sv1530_minfreeworkitems: DWORD, +}} +pub type PSERVER_INFO_1530 = *mut SERVER_INFO_1530; +pub type LPSERVER_INFO_1530 = *mut SERVER_INFO_1530; +STRUCT!{struct SERVER_INFO_1533 { + sv1533_maxmpxct: DWORD, +}} +pub type PSERVER_INFO_1533 = *mut SERVER_INFO_1533; +pub type LPSERVER_INFO_1533 = *mut SERVER_INFO_1533; +STRUCT!{struct SERVER_INFO_1534 { + sv1534_oplockbreakwait: DWORD, +}} +pub type PSERVER_INFO_1534 = *mut SERVER_INFO_1534; +pub type LPSERVER_INFO_1534 = *mut SERVER_INFO_1534; +STRUCT!{struct SERVER_INFO_1535 { + sv1535_oplockbreakresponsewait: DWORD, +}} +pub type PSERVER_INFO_1535 = *mut SERVER_INFO_1535; +pub type LPSERVER_INFO_1535 = *mut SERVER_INFO_1535; +STRUCT!{struct SERVER_INFO_1536 { + sv1536_enableoplocks: BOOL, +}} +pub type PSERVER_INFO_1536 = *mut SERVER_INFO_1536; +pub type LPSERVER_INFO_1536 = *mut SERVER_INFO_1536; +STRUCT!{struct SERVER_INFO_1537 { + sv1537_enableoplockforceclose: BOOL, +}} +pub type PSERVER_INFO_1537 = *mut SERVER_INFO_1537; +pub type LPSERVER_INFO_1537 = *mut SERVER_INFO_1537; +STRUCT!{struct SERVER_INFO_1538 { + sv1538_enablefcbopens: BOOL, +}} +pub type PSERVER_INFO_1538 = *mut SERVER_INFO_1538; +pub type LPSERVER_INFO_1538 = *mut SERVER_INFO_1538; +STRUCT!{struct SERVER_INFO_1539 { + sv1539_enableraw: BOOL, +}} +pub type PSERVER_INFO_1539 = *mut SERVER_INFO_1539; +pub type LPSERVER_INFO_1539 = *mut SERVER_INFO_1539; +STRUCT!{struct SERVER_INFO_1540 { + sv1540_enablesharednetdrives: BOOL, +}} +pub type PSERVER_INFO_1540 = *mut SERVER_INFO_1540; +pub type LPSERVER_INFO_1540 = *mut SERVER_INFO_1540; +STRUCT!{struct SERVER_INFO_1541 { + sv1541_minfreeconnections: BOOL, +}} +pub type PSERVER_INFO_1541 = *mut SERVER_INFO_1541; +pub type LPSERVER_INFO_1541 = *mut SERVER_INFO_1541; +STRUCT!{struct SERVER_INFO_1542 { + sv1542_maxfreeconnections: BOOL, +}} +pub type PSERVER_INFO_1542 = *mut SERVER_INFO_1542; +pub type LPSERVER_INFO_1542 = *mut SERVER_INFO_1542; +STRUCT!{struct SERVER_INFO_1543 { + sv1543_initsesstable: DWORD, +}} +pub type PSERVER_INFO_1543 = *mut SERVER_INFO_1543; +pub type LPSERVER_INFO_1543 = *mut SERVER_INFO_1543; +STRUCT!{struct SERVER_INFO_1544 { + sv1544_initconntable: DWORD, +}} +pub type PSERVER_INFO_1544 = *mut SERVER_INFO_1544; +pub type LPSERVER_INFO_1544 = *mut SERVER_INFO_1544; +STRUCT!{struct SERVER_INFO_1545 { + sv1545_initfiletable: DWORD, +}} +pub type PSERVER_INFO_1545 = *mut SERVER_INFO_1545; +pub type LPSERVER_INFO_1545 = *mut SERVER_INFO_1545; +STRUCT!{struct SERVER_INFO_1546 { + sv1546_initsearchtable: DWORD, +}} +pub type PSERVER_INFO_1546 = *mut SERVER_INFO_1546; +pub type LPSERVER_INFO_1546 = *mut SERVER_INFO_1546; +STRUCT!{struct SERVER_INFO_1547 { + sv1547_alertschedule: DWORD, +}} +pub type PSERVER_INFO_1547 = *mut SERVER_INFO_1547; +pub type LPSERVER_INFO_1547 = *mut SERVER_INFO_1547; +STRUCT!{struct SERVER_INFO_1548 { + sv1548_errorthreshold: DWORD, +}} +pub type PSERVER_INFO_1548 = *mut SERVER_INFO_1548; +pub type LPSERVER_INFO_1548 = *mut SERVER_INFO_1548; +STRUCT!{struct SERVER_INFO_1549 { + sv1549_networkerrorthreshold: DWORD, +}} +pub type PSERVER_INFO_1549 = *mut SERVER_INFO_1549; +pub type LPSERVER_INFO_1549 = *mut SERVER_INFO_1549; +STRUCT!{struct SERVER_INFO_1550 { + sv1550_diskspacethreshold: DWORD, +}} +pub type PSERVER_INFO_1550 = *mut SERVER_INFO_1550; +pub type LPSERVER_INFO_1550 = *mut SERVER_INFO_1550; +STRUCT!{struct SERVER_INFO_1552 { + sv1552_maxlinkdelay: DWORD, +}} +pub type PSERVER_INFO_1552 = *mut SERVER_INFO_1552; +pub type LPSERVER_INFO_1552 = *mut SERVER_INFO_1552; +STRUCT!{struct SERVER_INFO_1553 { + sv1553_minlinkthroughput: DWORD, +}} +pub type PSERVER_INFO_1553 = *mut SERVER_INFO_1553; +pub type LPSERVER_INFO_1553 = *mut SERVER_INFO_1553; +STRUCT!{struct SERVER_INFO_1554 { + sv1554_linkinfovalidtime: DWORD, +}} +pub type PSERVER_INFO_1554 = *mut SERVER_INFO_1554; +pub type LPSERVER_INFO_1554 = *mut SERVER_INFO_1554; +STRUCT!{struct SERVER_INFO_1555 { + sv1555_scavqosinfoupdatetime: DWORD, +}} +pub type PSERVER_INFO_1555 = *mut SERVER_INFO_1555; +pub type LPSERVER_INFO_1555 = *mut SERVER_INFO_1555; +STRUCT!{struct SERVER_INFO_1556 { + sv1556_maxworkitemidletime: DWORD, +}} +pub type PSERVER_INFO_1556 = *mut SERVER_INFO_1556; +pub type LPSERVER_INFO_1556 = *mut SERVER_INFO_1556; +STRUCT!{struct SERVER_INFO_1557 { + sv1557_maxrawworkitems: DWORD, +}} +pub type PSERVER_INFO_1557 = *mut SERVER_INFO_1557; +pub type LPSERVER_INFO_1557 = *mut SERVER_INFO_1557; +STRUCT!{struct SERVER_INFO_1560 { + sv1560_producttype: DWORD, +}} +pub type PSERVER_INFO_1560 = *mut SERVER_INFO_1560; +pub type LPSERVER_INFO_1560 = *mut SERVER_INFO_1560; +STRUCT!{struct SERVER_INFO_1561 { + sv1561_serversize: DWORD, +}} +pub type PSERVER_INFO_1561 = *mut SERVER_INFO_1561; +pub type LPSERVER_INFO_1561 = *mut SERVER_INFO_1561; +STRUCT!{struct SERVER_INFO_1562 { + sv1562_connectionlessautodisc: DWORD, +}} +pub type PSERVER_INFO_1562 = *mut SERVER_INFO_1562; +pub type LPSERVER_INFO_1562 = *mut SERVER_INFO_1562; +STRUCT!{struct SERVER_INFO_1563 { + sv1563_sharingviolationretries: DWORD, +}} +pub type PSERVER_INFO_1563 = *mut SERVER_INFO_1563; +pub type LPSERVER_INFO_1563 = *mut SERVER_INFO_1563; +STRUCT!{struct SERVER_INFO_1564 { + sv1564_sharingviolationdelay: DWORD, +}} +pub type PSERVER_INFO_1564 = *mut SERVER_INFO_1564; +pub type LPSERVER_INFO_1564 = *mut SERVER_INFO_1564; +STRUCT!{struct SERVER_INFO_1565 { + sv1565_maxglobalopensearch: DWORD, +}} +pub type PSERVER_INFO_1565 = *mut SERVER_INFO_1565; +pub type LPSERVER_INFO_1565 = *mut SERVER_INFO_1565; +STRUCT!{struct SERVER_INFO_1566 { + sv1566_removeduplicatesearches: BOOL, +}} +pub type PSERVER_INFO_1566 = *mut SERVER_INFO_1566; +pub type LPSERVER_INFO_1566 = *mut SERVER_INFO_1566; +STRUCT!{struct SERVER_INFO_1567 { + sv1567_lockviolationretries: DWORD, +}} +pub type PSERVER_INFO_1567 = *mut SERVER_INFO_1567; +pub type LPSERVER_INFO_1567 = *mut SERVER_INFO_1567; +STRUCT!{struct SERVER_INFO_1568 { + sv1568_lockviolationoffset: DWORD, +}} +pub type PSERVER_INFO_1568 = *mut SERVER_INFO_1568; +pub type LPSERVER_INFO_1568 = *mut SERVER_INFO_1568; +STRUCT!{struct SERVER_INFO_1569 { + sv1569_lockviolationdelay: DWORD, +}} +pub type PSERVER_INFO_1569 = *mut SERVER_INFO_1569; +pub type LPSERVER_INFO_1569 = *mut SERVER_INFO_1569; +STRUCT!{struct SERVER_INFO_1570 { + sv1570_mdlreadswitchover: DWORD, +}} +pub type PSERVER_INFO_1570 = *mut SERVER_INFO_1570; +pub type LPSERVER_INFO_1570 = *mut SERVER_INFO_1570; +STRUCT!{struct SERVER_INFO_1571 { + sv1571_cachedopenlimit: DWORD, +}} +pub type PSERVER_INFO_1571 = *mut SERVER_INFO_1571; +pub type LPSERVER_INFO_1571 = *mut SERVER_INFO_1571; +STRUCT!{struct SERVER_INFO_1572 { + sv1572_criticalthreads: DWORD, +}} +pub type PSERVER_INFO_1572 = *mut SERVER_INFO_1572; +pub type LPSERVER_INFO_1572 = *mut SERVER_INFO_1572; +STRUCT!{struct SERVER_INFO_1573 { + sv1573_restrictnullsessaccess: DWORD, +}} +pub type PSERVER_INFO_1573 = *mut SERVER_INFO_1573; +pub type LPSERVER_INFO_1573 = *mut SERVER_INFO_1573; +STRUCT!{struct SERVER_INFO_1574 { + sv1574_enablewfw311directipx: DWORD, +}} +pub type PSERVER_INFO_1574 = *mut SERVER_INFO_1574; +pub type LPSERVER_INFO_1574 = *mut SERVER_INFO_1574; +STRUCT!{struct SERVER_INFO_1575 { + sv1575_otherqueueaffinity: DWORD, +}} +pub type PSERVER_INFO_1575 = *mut SERVER_INFO_1575; +pub type LPSERVER_INFO_1575 = *mut SERVER_INFO_1575; +STRUCT!{struct SERVER_INFO_1576 { + sv1576_queuesamplesecs: DWORD, +}} +pub type PSERVER_INFO_1576 = *mut SERVER_INFO_1576; +pub type LPSERVER_INFO_1576 = *mut SERVER_INFO_1576; +STRUCT!{struct SERVER_INFO_1577 { + sv1577_balancecount: DWORD, +}} +pub type PSERVER_INFO_1577 = *mut SERVER_INFO_1577; +pub type LPSERVER_INFO_1577 = *mut SERVER_INFO_1577; +STRUCT!{struct SERVER_INFO_1578 { + sv1578_preferredaffinity: DWORD, +}} +pub type PSERVER_INFO_1578 = *mut SERVER_INFO_1578; +pub type LPSERVER_INFO_1578 = *mut SERVER_INFO_1578; +STRUCT!{struct SERVER_INFO_1579 { + sv1579_maxfreerfcbs: DWORD, +}} +pub type PSERVER_INFO_1579 = *mut SERVER_INFO_1579; +pub type LPSERVER_INFO_1579 = *mut SERVER_INFO_1579; +STRUCT!{struct SERVER_INFO_1580 { + sv1580_maxfreemfcbs: DWORD, +}} +pub type PSERVER_INFO_1580 = *mut SERVER_INFO_1580; +pub type LPSERVER_INFO_1580 = *mut SERVER_INFO_1580; +STRUCT!{struct SERVER_INFO_1581 { + sv1581_maxfreemlcbs: DWORD, +}} +pub type PSERVER_INFO_1581 = *mut SERVER_INFO_1581; +pub type LPSERVER_INFO_1581 = *mut SERVER_INFO_1581; +STRUCT!{struct SERVER_INFO_1582 { + sv1582_maxfreepagedpoolchunks: DWORD, +}} +pub type PSERVER_INFO_1582 = *mut SERVER_INFO_1582; +pub type LPSERVER_INFO_1582 = *mut SERVER_INFO_1582; +STRUCT!{struct SERVER_INFO_1583 { + sv1583_minpagedpoolchunksize: DWORD, +}} +pub type PSERVER_INFO_1583 = *mut SERVER_INFO_1583; +pub type LPSERVER_INFO_1583 = *mut SERVER_INFO_1583; +STRUCT!{struct SERVER_INFO_1584 { + sv1584_maxpagedpoolchunksize: DWORD, +}} +pub type PSERVER_INFO_1584 = *mut SERVER_INFO_1584; +pub type LPSERVER_INFO_1584 = *mut SERVER_INFO_1584; +STRUCT!{struct SERVER_INFO_1585 { + sv1585_sendsfrompreferredprocessor: BOOL, +}} +pub type PSERVER_INFO_1585 = *mut SERVER_INFO_1585; +pub type LPSERVER_INFO_1585 = *mut SERVER_INFO_1585; +STRUCT!{struct SERVER_INFO_1586 { + sv1586_maxthreadsperqueue: DWORD, +}} +pub type PSERVER_INFO_1586 = *mut SERVER_INFO_1586; +pub type LPSERVER_INFO_1586 = *mut SERVER_INFO_1586; +STRUCT!{struct SERVER_INFO_1587 { + sv1587_cacheddirectorylimit: DWORD, +}} +pub type PSERVER_INFO_1587 = *mut SERVER_INFO_1587; +pub type LPSERVER_INFO_1587 = *mut SERVER_INFO_1587; +STRUCT!{struct SERVER_INFO_1588 { + sv1588_maxcopylength: DWORD, +}} +pub type PSERVER_INFO_1588 = *mut SERVER_INFO_1588; +pub type LPSERVER_INFO_1588 = *mut SERVER_INFO_1588; +STRUCT!{struct SERVER_INFO_1590 { + sv1590_enablecompression: DWORD, +}} +pub type PSERVER_INFO_1590 = *mut SERVER_INFO_1590; +pub type LPSERVER_INFO_1590 = *mut SERVER_INFO_1590; +STRUCT!{struct SERVER_INFO_1591 { + sv1591_autosharewks: DWORD, +}} +pub type PSERVER_INFO_1591 = *mut SERVER_INFO_1591; +pub type LPSERVER_INFO_1591 = *mut SERVER_INFO_1591; +STRUCT!{struct SERVER_INFO_1592 { + sv1592_autosharewks: DWORD, +}} +pub type PSERVER_INFO_1592 = *mut SERVER_INFO_1592; +pub type LPSERVER_INFO_1592 = *mut SERVER_INFO_1592; +STRUCT!{struct SERVER_INFO_1593 { + sv1593_enablesecuritysignature: DWORD, +}} +pub type PSERVER_INFO_1593 = *mut SERVER_INFO_1593; +pub type LPSERVER_INFO_1593 = *mut SERVER_INFO_1593; +STRUCT!{struct SERVER_INFO_1594 { + sv1594_requiresecuritysignature: DWORD, +}} +pub type PSERVER_INFO_1594 = *mut SERVER_INFO_1594; +pub type LPSERVER_INFO_1594 = *mut SERVER_INFO_1594; +STRUCT!{struct SERVER_INFO_1595 { + sv1595_minclientbuffersize: DWORD, +}} +pub type PSERVER_INFO_1595 = *mut SERVER_INFO_1595; +pub type LPSERVER_INFO_1595 = *mut SERVER_INFO_1595; +STRUCT!{struct SERVER_INFO_1596 { + sv1596_ConnectionNoSessionsTimeout: DWORD, +}} +pub type PSERVER_INFO_1596 = *mut SERVER_INFO_1596; +pub type LPSERVER_INFO_1596 = *mut SERVER_INFO_1596; +STRUCT!{struct SERVER_INFO_1597 { + sv1597_IdleThreadTimeOut: DWORD, +}} +pub type PSERVER_INFO_1597 = *mut SERVER_INFO_1597; +pub type LPSERVER_INFO_1597 = *mut SERVER_INFO_1597; +STRUCT!{struct SERVER_INFO_1598 { + sv1598_enableW9xsecuritysignature: DWORD, +}} +pub type PSERVER_INFO_1598 = *mut SERVER_INFO_1598; +pub type LPSERVER_INFO_1598 = *mut SERVER_INFO_1598; +STRUCT!{struct SERVER_INFO_1599 { + sv1598_enforcekerberosreauthentication: BOOLEAN, +}} +pub type PSERVER_INFO_1599 = *mut SERVER_INFO_1599; +pub type LPSERVER_INFO_1599 = *mut SERVER_INFO_1599; +STRUCT!{struct SERVER_INFO_1600 { + sv1598_disabledos: BOOLEAN, +}} +pub type PSERVER_INFO_1600 = *mut SERVER_INFO_1600; +pub type LPSERVER_INFO_1600 = *mut SERVER_INFO_1600; +STRUCT!{struct SERVER_INFO_1601 { + sv1598_lowdiskspaceminimum: DWORD, +}} +pub type PSERVER_INFO_1601 = *mut SERVER_INFO_1601; +pub type LPSERVER_INFO_1601 = *mut SERVER_INFO_1601; +STRUCT!{struct SERVER_INFO_1602 { + sv_1598_disablestrictnamechecking: BOOL, +}} +pub type PSERVER_INFO_1602 = *mut SERVER_INFO_1602; +pub type LPSERVER_INFO_1602 = *mut SERVER_INFO_1602; +STRUCT!{struct SERVER_TRANSPORT_INFO_0 { + svti0_numberofvcs: DWORD, + svti0_transportname: LMSTR, + svti0_transportaddress: LPBYTE, + svti0_transportaddresslength: DWORD, + svti0_networkaddress: LMSTR, +}} +pub type PSERVER_TRANSPORT_INFO_0 = *mut SERVER_TRANSPORT_INFO_0; +pub type LPSERVER_TRANSPORT_INFO_0 = *mut SERVER_TRANSPORT_INFO_0; +STRUCT!{struct SERVER_TRANSPORT_INFO_1 { + svti1_numberofvcs: DWORD, + svti1_transportname: LMSTR, + svti1_transportaddress: LPBYTE, + svti1_transportaddresslength: DWORD, + svti1_networkaddress: LMSTR, + svti1_domain: LMSTR, +}} +pub type PSERVER_TRANSPORT_INFO_1 = *mut SERVER_TRANSPORT_INFO_1; +pub type LPSERVER_TRANSPORT_INFO_1 = *mut SERVER_TRANSPORT_INFO_1; +STRUCT!{struct SERVER_TRANSPORT_INFO_2 { + svti2_numberofvcs: DWORD, + svti2_transportname: LMSTR, + svti2_transportaddress: LPBYTE, + svti2_transportaddresslength: DWORD, + svti2_networkaddress: LMSTR, + svti2_domain: LMSTR, + svti2_flags: ULONG, +}} +pub type PSERVER_TRANSPORT_INFO_2 = *mut SERVER_TRANSPORT_INFO_2; +pub type LPSERVER_TRANSPORT_INFO_2 = *mut SERVER_TRANSPORT_INFO_2; +STRUCT!{struct SERVER_TRANSPORT_INFO_3 { + svti3_numberofvcs: DWORD, + svti3_transportname: LMSTR, + svti3_transportaddress: LPBYTE, + svti3_transportaddresslength: DWORD, + svti3_networkaddress: LMSTR, + svti3_domain: LMSTR, + svti3_flags: ULONG, + svti3_passwordlength: DWORD, + svti3_password: [BYTE; 256], +}} +pub type PSERVER_TRANSPORT_INFO_3 = *mut SERVER_TRANSPORT_INFO_3; +pub type LPSERVER_TRANSPORT_INFO_3 = *mut SERVER_TRANSPORT_INFO_3; +pub const SV_PLATFORM_ID_OS2: DWORD = 400; +pub const SV_PLATFORM_ID_NT: DWORD = 500; +pub const MAJOR_VERSION_MASK: DWORD = 0x0F; +pub const SV_TYPE_WORKSTATION: DWORD = 0x00000001; +pub const SV_TYPE_SERVER: DWORD = 0x00000002; +pub const SV_TYPE_SQLSERVER: DWORD = 0x00000004; +pub const SV_TYPE_DOMAIN_CTRL: DWORD = 0x00000008; +pub const SV_TYPE_DOMAIN_BAKCTRL: DWORD = 0x00000010; +pub const SV_TYPE_TIME_SOURCE: DWORD = 0x00000020; +pub const SV_TYPE_AFP: DWORD = 0x00000040; +pub const SV_TYPE_NOVELL: DWORD = 0x00000080; +pub const SV_TYPE_DOMAIN_MEMBER: DWORD = 0x00000100; +pub const SV_TYPE_PRINTQ_SERVER: DWORD = 0x00000200; +pub const SV_TYPE_DIALIN_SERVER: DWORD = 0x00000400; +pub const SV_TYPE_XENIX_SERVER: DWORD = 0x00000800; +pub const SV_TYPE_SERVER_UNIX: DWORD = SV_TYPE_XENIX_SERVER; +pub const SV_TYPE_NT: DWORD = 0x00001000; +pub const SV_TYPE_WFW: DWORD = 0x00002000; +pub const SV_TYPE_SERVER_MFPN: DWORD = 0x00004000; +pub const SV_TYPE_SERVER_NT: DWORD = 0x00008000; +pub const SV_TYPE_POTENTIAL_BROWSER: DWORD = 0x00010000; +pub const SV_TYPE_BACKUP_BROWSER: DWORD = 0x00020000; +pub const SV_TYPE_MASTER_BROWSER: DWORD = 0x00040000; +pub const SV_TYPE_DOMAIN_MASTER: DWORD = 0x00080000; +pub const SV_TYPE_SERVER_OSF: DWORD = 0x00100000; +pub const SV_TYPE_SERVER_VMS: DWORD = 0x00200000; +pub const SV_TYPE_WINDOWS: DWORD = 0x00400000; +pub const SV_TYPE_DFS: DWORD = 0x00800000; +pub const SV_TYPE_CLUSTER_NT: DWORD = 0x01000000; +pub const SV_TYPE_TERMINALSERVER: DWORD = 0x02000000; +pub const SV_TYPE_CLUSTER_VS_NT: DWORD = 0x04000000; +pub const SV_TYPE_DCE: DWORD = 0x10000000; +pub const SV_TYPE_ALTERNATE_XPORT: DWORD = 0x20000000; +pub const SV_TYPE_LOCAL_LIST_ONLY: DWORD = 0x40000000; +pub const SV_TYPE_DOMAIN_ENUM: DWORD = 0x80000000; +pub const SV_TYPE_ALL: DWORD = 0xFFFFFFFF; +pub const SV_NODISC: DWORD = -1i32 as u32; +pub const SV_USERSECURITY: DWORD = 1; +pub const SV_SHARESECURITY: DWORD = 0; +pub const SV_HIDDEN: DWORD = 1; +pub const SV_VISIBLE: DWORD = 0; +pub const SV_PLATFORM_ID_PARMNUM: DWORD = 101; +pub const SV_NAME_PARMNUM: DWORD = 102; +pub const SV_VERSION_MAJOR_PARMNUM: DWORD = 103; +pub const SV_VERSION_MINOR_PARMNUM: DWORD = 104; +pub const SV_TYPE_PARMNUM: DWORD = 105; +pub const SV_COMMENT_PARMNUM: DWORD = 5; +pub const SV_USERS_PARMNUM: DWORD = 107; +pub const SV_DISC_PARMNUM: DWORD = 10; +pub const SV_HIDDEN_PARMNUM: DWORD = 16; +pub const SV_ANNOUNCE_PARMNUM: DWORD = 17; +pub const SV_ANNDELTA_PARMNUM: DWORD = 18; +pub const SV_USERPATH_PARMNUM: DWORD = 112; +pub const SV_ULIST_MTIME_PARMNUM: DWORD = 401; +pub const SV_GLIST_MTIME_PARMNUM: DWORD = 402; +pub const SV_ALIST_MTIME_PARMNUM: DWORD = 403; +pub const SV_ALERTS_PARMNUM: DWORD = 11; +pub const SV_SECURITY_PARMNUM: DWORD = 405; +pub const SV_NUMADMIN_PARMNUM: DWORD = 406; +pub const SV_LANMASK_PARMNUM: DWORD = 407; +pub const SV_GUESTACC_PARMNUM: DWORD = 408; +pub const SV_CHDEVQ_PARMNUM: DWORD = 410; +pub const SV_CHDEVJOBS_PARMNUM: DWORD = 411; +pub const SV_CONNECTIONS_PARMNUM: DWORD = 412; +pub const SV_SHARES_PARMNUM: DWORD = 413; +pub const SV_OPENFILES_PARMNUM: DWORD = 414; +pub const SV_SESSREQS_PARMNUM: DWORD = 417; +pub const SV_ACTIVELOCKS_PARMNUM: DWORD = 419; +pub const SV_NUMREQBUF_PARMNUM: DWORD = 420; +pub const SV_NUMBIGBUF_PARMNUM: DWORD = 422; +pub const SV_NUMFILETASKS_PARMNUM: DWORD = 423; +pub const SV_ALERTSCHED_PARMNUM: DWORD = 37; +pub const SV_ERRORALERT_PARMNUM: DWORD = 38; +pub const SV_LOGONALERT_PARMNUM: DWORD = 39; +pub const SV_ACCESSALERT_PARMNUM: DWORD = 40; +pub const SV_DISKALERT_PARMNUM: DWORD = 41; +pub const SV_NETIOALERT_PARMNUM: DWORD = 42; +pub const SV_MAXAUDITSZ_PARMNUM: DWORD = 43; +pub const SV_SRVHEURISTICS_PARMNUM: DWORD = 431; +pub const SV_SESSOPENS_PARMNUM: DWORD = 501; +pub const SV_SESSVCS_PARMNUM: DWORD = 502; +pub const SV_OPENSEARCH_PARMNUM: DWORD = 503; +pub const SV_SIZREQBUF_PARMNUM: DWORD = 504; +pub const SV_INITWORKITEMS_PARMNUM: DWORD = 505; +pub const SV_MAXWORKITEMS_PARMNUM: DWORD = 506; +pub const SV_RAWWORKITEMS_PARMNUM: DWORD = 507; +pub const SV_IRPSTACKSIZE_PARMNUM: DWORD = 508; +pub const SV_MAXRAWBUFLEN_PARMNUM: DWORD = 509; +pub const SV_SESSUSERS_PARMNUM: DWORD = 510; +pub const SV_SESSCONNS_PARMNUM: DWORD = 511; +pub const SV_MAXNONPAGEDMEMORYUSAGE_PARMNUM: DWORD = 512; +pub const SV_MAXPAGEDMEMORYUSAGE_PARMNUM: DWORD = 513; +pub const SV_ENABLESOFTCOMPAT_PARMNUM: DWORD = 514; +pub const SV_ENABLEFORCEDLOGOFF_PARMNUM: DWORD = 515; +pub const SV_TIMESOURCE_PARMNUM: DWORD = 516; +pub const SV_ACCEPTDOWNLEVELAPIS_PARMNUM: DWORD = 517; +pub const SV_LMANNOUNCE_PARMNUM: DWORD = 518; +pub const SV_DOMAIN_PARMNUM: DWORD = 519; +pub const SV_MAXCOPYREADLEN_PARMNUM: DWORD = 520; +pub const SV_MAXCOPYWRITELEN_PARMNUM: DWORD = 521; +pub const SV_MINKEEPSEARCH_PARMNUM: DWORD = 522; +pub const SV_MAXKEEPSEARCH_PARMNUM: DWORD = 523; +pub const SV_MINKEEPCOMPLSEARCH_PARMNUM: DWORD = 524; +pub const SV_MAXKEEPCOMPLSEARCH_PARMNUM: DWORD = 525; +pub const SV_THREADCOUNTADD_PARMNUM: DWORD = 526; +pub const SV_NUMBLOCKTHREADS_PARMNUM: DWORD = 527; +pub const SV_SCAVTIMEOUT_PARMNUM: DWORD = 528; +pub const SV_MINRCVQUEUE_PARMNUM: DWORD = 529; +pub const SV_MINFREEWORKITEMS_PARMNUM: DWORD = 530; +pub const SV_XACTMEMSIZE_PARMNUM: DWORD = 531; +pub const SV_THREADPRIORITY_PARMNUM: DWORD = 532; +pub const SV_MAXMPXCT_PARMNUM: DWORD = 533; +pub const SV_OPLOCKBREAKWAIT_PARMNUM: DWORD = 534; +pub const SV_OPLOCKBREAKRESPONSEWAIT_PARMNUM: DWORD = 535; +pub const SV_ENABLEOPLOCKS_PARMNUM: DWORD = 536; +pub const SV_ENABLEOPLOCKFORCECLOSE_PARMNUM: DWORD = 537; +pub const SV_ENABLEFCBOPENS_PARMNUM: DWORD = 538; +pub const SV_ENABLERAW_PARMNUM: DWORD = 539; +pub const SV_ENABLESHAREDNETDRIVES_PARMNUM: DWORD = 540; +pub const SV_MINFREECONNECTIONS_PARMNUM: DWORD = 541; +pub const SV_MAXFREECONNECTIONS_PARMNUM: DWORD = 542; +pub const SV_INITSESSTABLE_PARMNUM: DWORD = 543; +pub const SV_INITCONNTABLE_PARMNUM: DWORD = 544; +pub const SV_INITFILETABLE_PARMNUM: DWORD = 545; +pub const SV_INITSEARCHTABLE_PARMNUM: DWORD = 546; +pub const SV_ALERTSCHEDULE_PARMNUM: DWORD = 547; +pub const SV_ERRORTHRESHOLD_PARMNUM: DWORD = 548; +pub const SV_NETWORKERRORTHRESHOLD_PARMNUM: DWORD = 549; +pub const SV_DISKSPACETHRESHOLD_PARMNUM: DWORD = 550; +pub const SV_MAXLINKDELAY_PARMNUM: DWORD = 552; +pub const SV_MINLINKTHROUGHPUT_PARMNUM: DWORD = 553; +pub const SV_LINKINFOVALIDTIME_PARMNUM: DWORD = 554; +pub const SV_SCAVQOSINFOUPDATETIME_PARMNUM: DWORD = 555; +pub const SV_MAXWORKITEMIDLETIME_PARMNUM: DWORD = 556; +pub const SV_MAXRAWWORKITEMS_PARMNUM: DWORD = 557; +pub const SV_PRODUCTTYPE_PARMNUM: DWORD = 560; +pub const SV_SERVERSIZE_PARMNUM: DWORD = 561; +pub const SV_CONNECTIONLESSAUTODISC_PARMNUM: DWORD = 562; +pub const SV_SHARINGVIOLATIONRETRIES_PARMNUM: DWORD = 563; +pub const SV_SHARINGVIOLATIONDELAY_PARMNUM: DWORD = 564; +pub const SV_MAXGLOBALOPENSEARCH_PARMNUM: DWORD = 565; +pub const SV_REMOVEDUPLICATESEARCHES_PARMNUM: DWORD = 566; +pub const SV_LOCKVIOLATIONRETRIES_PARMNUM: DWORD = 567; +pub const SV_LOCKVIOLATIONOFFSET_PARMNUM: DWORD = 568; +pub const SV_LOCKVIOLATIONDELAY_PARMNUM: DWORD = 569; +pub const SV_MDLREADSWITCHOVER_PARMNUM: DWORD = 570; +pub const SV_CACHEDOPENLIMIT_PARMNUM: DWORD = 571; +pub const SV_CRITICALTHREADS_PARMNUM: DWORD = 572; +pub const SV_RESTRICTNULLSESSACCESS_PARMNUM: DWORD = 573; +pub const SV_ENABLEWFW311DIRECTIPX_PARMNUM: DWORD = 574; +pub const SV_OTHERQUEUEAFFINITY_PARMNUM: DWORD = 575; +pub const SV_QUEUESAMPLESECS_PARMNUM: DWORD = 576; +pub const SV_BALANCECOUNT_PARMNUM: DWORD = 577; +pub const SV_PREFERREDAFFINITY_PARMNUM: DWORD = 578; +pub const SV_MAXFREERFCBS_PARMNUM: DWORD = 579; +pub const SV_MAXFREEMFCBS_PARMNUM: DWORD = 580; +pub const SV_MAXFREELFCBS_PARMNUM: DWORD = 581; +pub const SV_MAXFREEPAGEDPOOLCHUNKS_PARMNUM: DWORD = 582; +pub const SV_MINPAGEDPOOLCHUNKSIZE_PARMNUM: DWORD = 583; +pub const SV_MAXPAGEDPOOLCHUNKSIZE_PARMNUM: DWORD = 584; +pub const SV_SENDSFROMPREFERREDPROCESSOR_PARMNUM: DWORD = 585; +pub const SV_MAXTHREADSPERQUEUE_PARMNUM: DWORD = 586; +pub const SV_CACHEDDIRECTORYLIMIT_PARMNUM: DWORD = 587; +pub const SV_MAXCOPYLENGTH_PARMNUM: DWORD = 588; +pub const SV_ENABLECOMPRESSION_PARMNUM: DWORD = 590; +pub const SV_AUTOSHAREWKS_PARMNUM: DWORD = 591; +pub const SV_AUTOSHARESERVER_PARMNUM: DWORD = 592; +pub const SV_ENABLESECURITYSIGNATURE_PARMNUM: DWORD = 593; +pub const SV_REQUIRESECURITYSIGNATURE_PARMNUM: DWORD = 594; +pub const SV_MINCLIENTBUFFERSIZE_PARMNUM: DWORD = 595; +pub const SV_CONNECTIONNOSESSIONSTIMEOUT_PARMNUM: DWORD = 596; +pub const SV_IDLETHREADTIMEOUT_PARMNUM: DWORD = 597; +pub const SV_ENABLEW9XSECURITYSIGNATURE_PARMNUM: DWORD = 598; +pub const SV_ENFORCEKERBEROSREAUTHENTICATION_PARMNUM: DWORD = 599; +pub const SV_DISABLEDOS_PARMNUM: DWORD = 600; +pub const SV_LOWDISKSPACEMINIMUM_PARMNUM: DWORD = 601; +pub const SV_DISABLESTRICTNAMECHECKING_PARMNUM: DWORD = 602; +pub const SV_ENABLEAUTHENTICATEUSERSHARING_PARMNUM: DWORD = 603; +pub const SV_COMMENT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_COMMENT_PARMNUM; +pub const SV_USERS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_USERS_PARMNUM; +pub const SV_DISC_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_DISC_PARMNUM; +pub const SV_HIDDEN_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_HIDDEN_PARMNUM; +pub const SV_ANNOUNCE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_ANNOUNCE_PARMNUM; +pub const SV_ANNDELTA_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_ANNDELTA_PARMNUM; +pub const SV_SESSOPENS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_SESSOPENS_PARMNUM; +pub const SV_SESSVCS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_SESSVCS_PARMNUM; +pub const SV_OPENSEARCH_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_OPENSEARCH_PARMNUM; +pub const SV_MAXWORKITEMS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MAXWORKITEMS_PARMNUM; +pub const SV_MAXRAWBUFLEN_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MAXRAWBUFLEN_PARMNUM; +pub const SV_SESSUSERS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_SESSUSERS_PARMNUM; +pub const SV_SESSCONNS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_SESSCONNS_PARMNUM; +pub const SV_MAXNONPAGEDMEMORYUSAGE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXNONPAGEDMEMORYUSAGE_PARMNUM; +pub const SV_MAXPAGEDMEMORYUSAGE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXPAGEDMEMORYUSAGE_PARMNUM; +pub const SV_ENABLESOFTCOMPAT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_ENABLESOFTCOMPAT_PARMNUM; +pub const SV_ENABLEFORCEDLOGOFF_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_ENABLEFORCEDLOGOFF_PARMNUM; +pub const SV_TIMESOURCE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_TIMESOURCE_PARMNUM; +pub const SV_LMANNOUNCE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_LMANNOUNCE_PARMNUM; +pub const SV_MAXCOPYREADLEN_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MAXCOPYREADLEN_PARMNUM; +pub const SV_MAXCOPYWRITELEN_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXCOPYWRITELEN_PARMNUM; +pub const SV_MINKEEPSEARCH_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MINKEEPSEARCH_PARMNUM; +pub const SV_MAXKEEPSEARCH_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MAXKEEPSEARCH_PARMNUM; +pub const SV_MINKEEPCOMPLSEARCH_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MINKEEPCOMPLSEARCH_PARMNUM; +pub const SV_MAXKEEPCOMPLSEARCH_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXKEEPCOMPLSEARCH_PARMNUM; +pub const SV_SCAVTIMEOUT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_SCAVTIMEOUT_PARMNUM; +pub const SV_MINRCVQUEUE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MINRCVQUEUE_PARMNUM; +pub const SV_MINFREEWORKITEMS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MINFREEWORKITEMS_PARMNUM; +pub const SV_MAXMPXCT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MAXMPXCT_PARMNUM; +pub const SV_OPLOCKBREAKWAIT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_OPLOCKBREAKWAIT_PARMNUM; +pub const SV_OPLOCKBREAKRESPONSEWAIT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_OPLOCKBREAKRESPONSEWAIT_PARMNUM; +pub const SV_ENABLEOPLOCKS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_ENABLEOPLOCKS_PARMNUM; +pub const SV_ENABLEOPLOCKFORCECLOSE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_ENABLEOPLOCKFORCECLOSE_PARMNUM; +pub const SV_ENABLEFCBOPENS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_ENABLEFCBOPENS_PARMNUM; +pub const SV_ENABLERAW_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_ENABLERAW_PARMNUM; +pub const SV_ENABLESHAREDNETDRIVES_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_ENABLESHAREDNETDRIVES_PARMNUM; +pub const SV_MINFREECONNECTIONS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MINFREECONNECTIONS_PARMNUM; +pub const SV_MAXFREECONNECTIONS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXFREECONNECTIONS_PARMNUM; +pub const SV_INITSESSTABLE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_INITSESSTABLE_PARMNUM; +pub const SV_INITCONNTABLE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_INITCONNTABLE_PARMNUM; +pub const SV_INITFILETABLE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_INITFILETABLE_PARMNUM; +pub const SV_INITSEARCHTABLE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_INITSEARCHTABLE_PARMNUM; +pub const SV_ALERTSCHEDULE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_ALERTSCHEDULE_PARMNUM; +pub const SV_ERRORTHRESHOLD_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_ERRORTHRESHOLD_PARMNUM; +pub const SV_NETWORKERRORTHRESHOLD_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_NETWORKERRORTHRESHOLD_PARMNUM; +pub const SV_DISKSPACETHRESHOLD_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_DISKSPACETHRESHOLD_PARMNUM; +pub const SV_MAXLINKDELAY_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MAXLINKDELAY_PARMNUM; +pub const SV_MINLINKTHROUGHPUT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MINLINKTHROUGHPUT_PARMNUM; +pub const SV_LINKINFOVALIDTIME_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_LINKINFOVALIDTIME_PARMNUM; +pub const SV_SCAVQOSINFOUPDATETIME_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_SCAVQOSINFOUPDATETIME_PARMNUM; +pub const SV_MAXWORKITEMIDLETIME_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXWORKITEMIDLETIME_PARMNUM; +pub const SV_MAXRAWWORKITEMS_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXRAWWORKITEMS_PARMNUM; +pub const SV_PRODUCTTYPE_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_PRODUCTTYPE_PARMNUM; +pub const SV_SERVERSIZE_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_SERVERSIZE_PARMNUM; +pub const SV_CONNECTIONLESSAUTODISC_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_CONNECTIONLESSAUTODISC_PARMNUM; +pub const SV_SHARINGVIOLATIONRETRIES_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_SHARINGVIOLATIONRETRIES_PARMNUM; +pub const SV_SHARINGVIOLATIONDELAY_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_SHARINGVIOLATIONDELAY_PARMNUM; +pub const SV_MAXGLOBALOPENSEARCH_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXGLOBALOPENSEARCH_PARMNUM; +pub const SV_REMOVEDUPLICATESEARCHES_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_REMOVEDUPLICATESEARCHES_PARMNUM; +pub const SV_LOCKVIOLATIONRETRIES_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_LOCKVIOLATIONRETRIES_PARMNUM; +pub const SV_LOCKVIOLATIONOFFSET_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_LOCKVIOLATIONOFFSET_PARMNUM; +pub const SV_LOCKVIOLATIONDELAY_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_LOCKVIOLATIONDELAY_PARMNUM; +pub const SV_MDLREADSWITCHOVER_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MDLREADSWITCHOVER_PARMNUM; +pub const SV_CACHEDOPENLIMIT_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_CACHEDOPENLIMIT_PARMNUM; +pub const SV_CRITICALTHREADS_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_CRITICALTHREADS_PARMNUM; +pub const SV_RESTRICTNULLSESSACCESS_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_RESTRICTNULLSESSACCESS_PARMNUM; +pub const SV_ENABLEWFW311DIRECTIPX_INFOLOEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_ENABLEWFW311DIRECTIPX_PARMNUM; +pub const SV_OTHERQUEUEAFFINITY_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_OTHERQUEUEAFFINITY_PARMNUM; +pub const SV_QUEUESAMPLESECS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_QUEUESAMPLESECS_PARMNUM; +pub const SV_BALANCECOUNT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_BALANCECOUNT_PARMNUM; +pub const SV_PREFERREDAFFINITY_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_PREFERREDAFFINITY_PARMNUM; +pub const SV_MAXFREERFCBS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MAXFREERFCBS_PARMNUM; +pub const SV_MAXFREEMFCBS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MAXFREEMFCBS_PARMNUM; +pub const SV_MAXFREELFCBS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MAXFREELFCBS_PARMNUM; +pub const SV_MAXFREEPAGEDPOOLCHUNKS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXFREEPAGEDPOOLCHUNKS_PARMNUM; +pub const SV_MINPAGEDPOOLCHUNKSIZE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MINPAGEDPOOLCHUNKSIZE_PARMNUM; +pub const SV_MAXPAGEDPOOLCHUNKSIZE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXPAGEDPOOLCHUNKSIZE_PARMNUM; +pub const SV_SENDSFROMPREFERREDPROCESSOR_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_SENDSFROMPREFERREDPROCESSOR_PARMNUM; +pub const SV_MAXTHREADSPERQUEUE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MAXTHREADSPERQUEUE_PARMNUM; +pub const SV_CACHEDDIRECTORYLIMIT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_CACHEDDIRECTORYLIMIT_PARMNUM; +pub const SV_MAXCOPYLENGTH_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_MAXCOPYLENGTH_PARMNUM; +pub const SV_ENABLECOMPRESSION_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_ENABLECOMPRESSION_PARMNUM; +pub const SV_AUTOSHAREWKS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_AUTOSHAREWKS_PARMNUM; +pub const SV_AUTOSHARESERVER_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_AUTOSHARESERVER_PARMNUM; +pub const SV_ENABLESECURITYSIGNATURE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_ENABLESECURITYSIGNATURE_PARMNUM; +pub const SV_REQUIRESECURITYSIGNATURE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_REQUIRESECURITYSIGNATURE_PARMNUM; +pub const SV_MINCLIENTBUFFERSIZE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_MINCLIENTBUFFERSIZE_PARMNUM; +pub const SV_CONNECTIONNOSESSIONSTIMEOUT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_CONNECTIONNOSESSIONSTIMEOUT_PARMNUM; +pub const SV_IDLETHREADTIMEOUT_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_IDLETHREADTIMEOUT_PARMNUM; +pub const SV_ENABLEW9XSECURITYSIGNATURE_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_ENABLEW9XSECURITYSIGNATURE_PARMNUM; +pub const SV_ENFORCEKERBEROSREAUTHENTICATION_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_ENFORCEKERBEROSREAUTHENTICATION_PARMNUM; +pub const SV_DISABLEDOS_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SV_DISABLEDOS_PARMNUM; +pub const SV_LOWDISKSPACEMINIMUM_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_LOWDISKSPACEMINIMUM_PARMNUM; +pub const SV_DISABLESTRICTNAMECHECKING_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_DISABLESTRICTNAMECHECKING_PARMNUM; +pub const SV_ENABLEAUTHENTICATEUSERSHARING_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + + SV_ENABLEAUTHENTICATEUSERSHARING_PARMNUM; +pub const SVI1_NUM_ELEMENTS: DWORD = 5; +pub const SVI2_NUM_ELEMENTS: DWORD = 40; +pub const SVI3_NUM_ELEMENTS: DWORD = 44; +pub const SV_MAX_CMD_LEN: DWORD = PATHLEN; +pub const SW_AUTOPROF_LOAD_MASK: DWORD = 0x1; +pub const SW_AUTOPROF_SAVE_MASK: DWORD = 0x2; +pub const SV_MAX_SRV_HEUR_LEN: DWORD = 32; +pub const SV_USERS_PER_LICENSE: DWORD = 5; +pub const SVTI2_REMAP_PIPE_NAMES: DWORD = 0x02; +pub const SVTI2_SCOPED_NAME: DWORD = 0x04; +pub const SVTI2_CLUSTER_NAME: DWORD = 0x08; +pub const SVTI2_CLUSTER_DNN_NAME: DWORD = 0x10; +pub const SVTI2_UNICODE_TRANSPORT_ADDRESS: DWORD = 0x20; +pub const SVTI2_RESERVED1: DWORD = 0x1000; +pub const SVTI2_RESERVED2: DWORD = 0x2000; +pub const SVTI2_RESERVED3: DWORD = 0x4000; +pub const SVTI2_VALID_FLAGS: DWORD = SVTI2_REMAP_PIPE_NAMES | SVTI2_SCOPED_NAME + | SVTI2_CLUSTER_NAME | SVTI2_CLUSTER_DNN_NAME | SVTI2_UNICODE_TRANSPORT_ADDRESS; +pub const SRV_SUPPORT_HASH_GENERATION: DWORD = 0x0001; +pub const SRV_HASH_GENERATION_ACTIVE: DWORD = 0x0002; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmshare.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmshare.rs new file mode 100644 index 0000000..3024ac3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmshare.rs @@ -0,0 +1,379 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module defines the API function prototypes and data structures +use shared::basetsd::PDWORD_PTR; +use shared::guiddef::GUID; +use shared::lmcons::{LMSTR, NET_API_STATUS, PARMNUM_BASE_INFOLEVEL}; +use shared::minwindef::{DWORD, LPBYTE, LPDWORD, ULONG}; +use um::winnt::{BOOLEAN, PSECURITY_DESCRIPTOR}; +extern "system" { + pub fn NetShareAdd( + servername: LMSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetShareEnum( + servername: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetShareEnumSticky( + servername: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetShareGetInfo( + servername: LMSTR, + netname: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetShareSetInfo( + servername: LMSTR, + netname: LMSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetShareDel( + servername: LMSTR, + netname: LMSTR, + reserved: DWORD, + ) -> NET_API_STATUS; + pub fn NetShareDelSticky( + servername: LMSTR, + netname: LMSTR, + reserved: DWORD, + ) -> NET_API_STATUS; + pub fn NetShareCheck( + servername: LMSTR, + device: LMSTR, + _type: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetShareDelEx( + servername: LMSTR, + level: DWORD, + buf: LPBYTE, + ) -> NET_API_STATUS; +} +STRUCT!{struct SHARE_INFO_0 { + shi0_netname: LMSTR, +}} +pub type PSHARE_INFO_0 = *mut SHARE_INFO_0; +pub type LPSHARE_INFO_0 = *mut SHARE_INFO_0; +STRUCT!{struct SHARE_INFO_1 { + shi1_netname: LMSTR, + shi1_type: DWORD, + shi1_remark: LMSTR, +}} +pub type PSHARE_INFO_1 = *mut SHARE_INFO_1; +pub type LPSHARE_INFO_1 = *mut SHARE_INFO_1; +STRUCT!{struct SHARE_INFO_2 { + shi2_netname: LMSTR, + shi2_type: DWORD, + shi2_remark: LMSTR, + shi2_permissions: DWORD, + shi2_max_uses: DWORD, + shi2_current_uses: DWORD, + shi2_path: LMSTR, + shi2_passwd: LMSTR, +}} +pub type PSHARE_INFO_2 = *mut SHARE_INFO_2; +pub type LPSHARE_INFO_2 = *mut SHARE_INFO_2; +STRUCT!{struct SHARE_INFO_501 { + shi501_netname: LMSTR, + shi501_type: DWORD, + shi501_remark: LMSTR, + shi501_flags: DWORD, +}} +pub type PSHARE_INFO_501 = *mut SHARE_INFO_501; +pub type LPSHARE_INFO_501 = *mut SHARE_INFO_501; +STRUCT!{struct SHARE_INFO_502 { + shi502_netname: LMSTR, + shi502_type: DWORD, + shi502_remark: LMSTR, + shi502_permissions: DWORD, + shi502_max_uses: DWORD, + shi502_current_uses: DWORD, + shi502_path: LMSTR, + shi502_passwd: LMSTR, + shi502_reserved: DWORD, + shi502_security_descriptor: PSECURITY_DESCRIPTOR, +}} +pub type PSHARE_INFO_502 = *mut SHARE_INFO_502; +pub type LPSHARE_INFO_502 = *mut SHARE_INFO_502; +STRUCT!{struct SHARE_INFO_503 { + shi503_netname: LMSTR, + shi503_type: DWORD, + shi503_remark: LMSTR, + shi503_permissions: DWORD, + shi503_max_uses: DWORD, + shi503_current_uses: DWORD, + shi503_path: LMSTR, + shi503_passwd: LMSTR, + shi503_servername: LMSTR, + shi503_reserved: DWORD, + shi503_security_descriptor: PSECURITY_DESCRIPTOR, +}} +pub type PSHARE_INFO_503 = *mut SHARE_INFO_503; +pub type LPSHARE_INFO_503 = *mut SHARE_INFO_503; +STRUCT!{struct SHARE_INFO_1004 { + shi1004_remark: LMSTR, +}} +pub type PSHARE_INFO_1004 = *mut SHARE_INFO_1004; +pub type LPSHARE_INFO_1004 = *mut SHARE_INFO_1004; +STRUCT!{struct SHARE_INFO_1005 { + shi1005_flags: DWORD, +}} +pub type PSHARE_INFO_1005 = *mut SHARE_INFO_1005; +pub type LPSHARE_INFO_1005 = *mut SHARE_INFO_1005; +STRUCT!{struct SHARE_INFO_1006 { + shi1006_max_uses: DWORD, +}} +pub type PSHARE_INFO_1006 = *mut SHARE_INFO_1006; +pub type LPSHARE_INFO_1006 = *mut SHARE_INFO_1006; +STRUCT!{struct SHARE_INFO_1501 { + shi1501_reserved: DWORD, + shi1501_security_descriptor: PSECURITY_DESCRIPTOR, +}} +pub type PSHARE_INFO_1501 = *mut SHARE_INFO_1501; +pub type LPSHARE_INFO_1501 = *mut SHARE_INFO_1501; +STRUCT!{struct SHARE_INFO_1503 { + shi1503_sharefilter: GUID, +}} +pub type PSHARE_INFO_1503 = *mut SHARE_INFO_1503; +pub type LPSHARE_INFO_1503 = *mut SHARE_INFO_1503; +extern "system" { + pub fn NetServerAliasAdd( + servername: LMSTR, + level: DWORD, + buf: LPBYTE, + ) -> NET_API_STATUS; + pub fn NetServerAliasDel( + servername: LMSTR, + level: DWORD, + buf: LPBYTE, + ) -> NET_API_STATUS; + pub fn NetServerAliasEnum( + servername: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; +} +STRUCT!{struct SERVER_ALIAS_INFO_0 { + srvai0_alias: LMSTR, + srvai0_target: LMSTR, + srvai0_default: BOOLEAN, + srvai0_reserved: ULONG, +}} +pub type PSERVER_ALIAS_INFO_0 = *mut SERVER_ALIAS_INFO_0; +pub type LPSERVER_ALIAS_INFO_0 = *mut SERVER_ALIAS_INFO_0; +pub const SHARE_NETNAME_PARMNUM: DWORD = 1; +pub const SHARE_TYPE_PARMNUM: DWORD = 3; +pub const SHARE_REMARK_PARMNUM: DWORD = 4; +pub const SHARE_PERMISSIONS_PARMNUM: DWORD = 5; +pub const SHARE_MAX_USES_PARMNUM: DWORD = 6; +pub const SHARE_CURRENT_USES_PARMNUM: DWORD = 7; +pub const SHARE_PATH_PARMNUM: DWORD = 8; +pub const SHARE_PASSWD_PARMNUM: DWORD = 9; +pub const SHARE_FILE_SD_PARMNUM: DWORD = 501; +pub const SHARE_SERVER_PARMNUM: DWORD = 503; +pub const SHARE_REMARK_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SHARE_REMARK_PARMNUM; +pub const SHARE_MAX_USES_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SHARE_MAX_USES_PARMNUM; +pub const SHARE_FILE_SD_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SHARE_FILE_SD_PARMNUM; +pub const SHI1_NUM_ELEMENTS: DWORD = 4; +pub const SHI2_NUM_ELEMENTS: DWORD = 10; +pub const STYPE_DISKTREE: DWORD = 0; +pub const STYPE_PRINTQ: DWORD = 1; +pub const STYPE_DEVICE: DWORD = 2; +pub const STYPE_IPC: DWORD = 3; +pub const STYPE_MASK: DWORD = 0x000000FF; +pub const STYPE_RESERVED1: DWORD = 0x01000000; +pub const STYPE_RESERVED2: DWORD = 0x02000000; +pub const STYPE_RESERVED3: DWORD = 0x04000000; +pub const STYPE_RESERVED4: DWORD = 0x08000000; +pub const STYPE_RESERVED_ALL: DWORD = 0x3FFFFF00; +pub const STYPE_TEMPORARY: DWORD = 0x40000000; +pub const STYPE_SPECIAL: DWORD = 0x80000000; +pub const SHI_USES_UNLIMITED: DWORD = -1i32 as u32; +pub const SHI1005_FLAGS_DFS: DWORD = 0x0001; +pub const SHI1005_FLAGS_DFS_ROOT: DWORD = 0x0002; +pub const CSC_MASK_EXT: DWORD = 0x2030; +pub const CSC_MASK: DWORD = 0x0030; +pub const CSC_CACHE_MANUAL_REINT: DWORD = 0x0000; +pub const CSC_CACHE_AUTO_REINT: DWORD = 0x0010; +pub const CSC_CACHE_VDO: DWORD = 0x0020; +pub const CSC_CACHE_NONE: DWORD = 0x0030; +pub const SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS: DWORD = 0x00100; +pub const SHI1005_FLAGS_FORCE_SHARED_DELETE: DWORD = 0x00200; +pub const SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING: DWORD = 0x00400; +pub const SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM: DWORD = 0x00800; +pub const SHI1005_FLAGS_FORCE_LEVELII_OPLOCK: DWORD = 0x01000; +pub const SHI1005_FLAGS_ENABLE_HASH: DWORD = 0x02000; +pub const SHI1005_FLAGS_ENABLE_CA: DWORD = 0x04000; +pub const SHI1005_FLAGS_ENCRYPT_DATA: DWORD = 0x08000; +pub const SHI1005_FLAGS_RESERVED: DWORD = 0x10000; +pub const SHI1005_VALID_FLAGS_SET: DWORD = CSC_MASK | SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS + | SHI1005_FLAGS_FORCE_SHARED_DELETE | SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING + | SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM | SHI1005_FLAGS_FORCE_LEVELII_OPLOCK + | SHI1005_FLAGS_ENABLE_HASH | SHI1005_FLAGS_ENABLE_CA | SHI1005_FLAGS_ENCRYPT_DATA + | SHI1005_FLAGS_RESERVED; +extern "system" { + pub fn NetSessionEnum( + servername: LMSTR, + UncClientName: LMSTR, + username: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetSessionDel( + servername: LMSTR, + UncClientName: LMSTR, + username: LMSTR, + ) -> NET_API_STATUS; + pub fn NetSessionGetInfo( + servername: LMSTR, + UncClientName: LMSTR, + username: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; +} +STRUCT!{struct SESSION_INFO_0 { + sesi0_cname: LMSTR, +}} +pub type PSESSION_INFO_0 = *mut SESSION_INFO_0; +pub type LPSESSION_INFO_0 = *mut SESSION_INFO_0; +STRUCT!{struct SESSION_INFO_1 { + sesi1_cname: LMSTR, + sesi1_username: LMSTR, + sesi1_num_opens: DWORD, + sesi1_time: DWORD, + sesi1_idle_time: DWORD, + sesi1_user_flags: DWORD, +}} +pub type PSESSION_INFO_1 = *mut SESSION_INFO_1; +pub type LPSESSION_INFO_1 = *mut SESSION_INFO_1; +STRUCT!{struct SESSION_INFO_2 { + sesi2_cname: LMSTR, + sesi2_username: LMSTR, + sesi2_num_opens: DWORD, + sesi2_time: DWORD, + sesi2_idle_time: DWORD, + sesi2_user_flags: DWORD, + sesi2_cltype_name: LMSTR, +}} +pub type PSESSION_INFO_2 = *mut SESSION_INFO_2; +pub type LPSESSION_INFO_2 = *mut SESSION_INFO_2; +STRUCT!{struct SESSION_INFO_10 { + sesi10_cname: LMSTR, + sesi10_username: LMSTR, + sesi10_time: DWORD, + sesi10_idle_time: DWORD, +}} +pub type PSESSION_INFO_10 = *mut SESSION_INFO_10; +pub type LPSESSION_INFO_10 = *mut SESSION_INFO_10; +STRUCT!{struct SESSION_INFO_502 { + sesi502_cname: LMSTR, + sesi502_username: LMSTR, + sesi502_num_opens: DWORD, + sesi502_time: DWORD, + sesi502_idle_time: DWORD, + sesi502_user_flags: DWORD, + sesi502_cltype_name: LMSTR, + sesi502_transport: LMSTR, +}} +pub type PSESSION_INFO_502 = *mut SESSION_INFO_502; +pub type LPSESSION_INFO_502 = *mut SESSION_INFO_502; +pub const SESS_GUEST: DWORD = 0x00000001; +pub const SESS_NOENCRYPTION: DWORD = 0x00000002; +pub const SESI1_NUM_ELEMENTS: DWORD = 8; +pub const SESI2_NUM_ELEMENTS: DWORD = 9; +extern "system" { + pub fn NetConnectionEnum( + servername: LMSTR, + qualifier: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resume_handle: LPDWORD, + ) -> NET_API_STATUS; +} +STRUCT!{struct CONNECTION_INFO_0 { + coni0_id: DWORD, +}} +pub type PCONNECTION_INFO_0 = *mut CONNECTION_INFO_0; +pub type LPCONNECTION_INFO_0 = *mut CONNECTION_INFO_0; +STRUCT!{struct CONNECTION_INFO_1 { + coni1_id: DWORD, + coni1_type: DWORD, + coni1_num_opens: DWORD, + coni1_num_users: DWORD, + coni1_time: DWORD, + coni1_username: LMSTR, + coni1_netname: LMSTR, +}} +pub type PCONNECTION_INFO_1 = *mut CONNECTION_INFO_1; +pub type LPCONNECTION_INFO_1 = *mut CONNECTION_INFO_1; +extern "system" { + pub fn NetFileClose( + servername: LMSTR, + fileid: DWORD, + ) -> NET_API_STATUS; + pub fn NetFileEnum( + servername: LMSTR, + basepath: LMSTR, + username: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resume_handle: PDWORD_PTR, + ) -> NET_API_STATUS; + pub fn NetFileGetInfo( + servername: LMSTR, + fileid: DWORD, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; +} +STRUCT!{struct FILE_INFO_2 { + fi2_id: DWORD, +}} +pub type PFILE_INFO_2 = *mut FILE_INFO_2; +pub type LPFILE_INFO_2 = *mut FILE_INFO_2; +STRUCT!{struct FILE_INFO_3 { + fi3_id: DWORD, + fi3_permissions: DWORD, + fi3_num_locks: DWORD, + fi3_pathname: LMSTR, + fi3_username: LMSTR, +}} +pub type PFILE_INFO_3 = *mut FILE_INFO_3; +pub type LPFILE_INFO_3 = *mut FILE_INFO_3; +pub const PERM_FILE_READ: DWORD = 0x1; +pub const PERM_FILE_WRITE: DWORD = 0x2; +pub const PERM_FILE_CREATE: DWORD = 0x4; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmstats.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmstats.rs new file mode 100644 index 0000000..c0bfc37 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmstats.rs @@ -0,0 +1,85 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +use shared::lmcons::NET_API_STATUS; +use shared::minwindef::{DWORD, LPBYTE}; +use um::winnt::{LARGE_INTEGER, LPCWSTR}; +extern "system" { + pub fn NetStatisticsGet( + ServerName: LPCWSTR, + Service: LPCWSTR, + Level: DWORD, + Options: DWORD, + Buffer: *mut LPBYTE, + ) -> NET_API_STATUS; +} +STRUCT!{struct STAT_WORKSTATION_0 { + StatisticsStartTime: LARGE_INTEGER, + BytesReceived: LARGE_INTEGER, + SmbsReceived: LARGE_INTEGER, + PagingReadBytesRequested: LARGE_INTEGER, + NonPagingReadBytesRequested: LARGE_INTEGER, + CacheReadBytesRequested: LARGE_INTEGER, + NetworkReadBytesRequested: LARGE_INTEGER, + BytesTransmitted: LARGE_INTEGER, + SmbsTransmitted: LARGE_INTEGER, + PagingWriteBytesRequested: LARGE_INTEGER, + NonPagingWriteBytesRequested: LARGE_INTEGER, + CacheWriteBytesRequested: LARGE_INTEGER, + NetworkWriteBytesRequested: LARGE_INTEGER, + InitiallyFailedOperations: DWORD, + FailedCompletionOperations: DWORD, + ReadOperations: DWORD, + RandomReadOperations: DWORD, + ReadSmbs: DWORD, + LargeReadSmbs: DWORD, + SmallReadSmbs: DWORD, + WriteOperations: DWORD, + RandomWriteOperations: DWORD, + WriteSmbs: DWORD, + LargeWriteSmbs: DWORD, + SmallWriteSmbs: DWORD, + RawReadsDenied: DWORD, + RawWritesDenied: DWORD, + NetworkErrors: DWORD, + Sessions: DWORD, + FailedSessions: DWORD, + Reconnects: DWORD, + CoreConnects: DWORD, + Lanman20Connects: DWORD, + Lanman21Connects: DWORD, + LanmanNtConnects: DWORD, + ServerDisconnects: DWORD, + HungSessions: DWORD, + UseCount: DWORD, + FailedUseCount: DWORD, + CurrentCommands: DWORD, +}} +pub type PSTAT_WORKSTATION_0 = *mut STAT_WORKSTATION_0; +pub type LPSTAT_WORKSTATION_0 = *mut STAT_WORKSTATION_0; +STRUCT!{struct STAT_SERVER_0 { + sts0_start: DWORD, + sts0_fopens: DWORD, + sts0_devopens: DWORD, + sts0_jobsqueued: DWORD, + sts0_sopens: DWORD, + sts0_stimedout: DWORD, + sts0_serrorout: DWORD, + sts0_pwerrors: DWORD, + sts0_permerrors: DWORD, + sts0_syserrors: DWORD, + sts0_bytessent_low: DWORD, + sts0_bytessent_high: DWORD, + sts0_bytesrcvd_low: DWORD, + sts0_bytesrcvd_high: DWORD, + sts0_avresponse: DWORD, + sts0_reqbufneed: DWORD, + sts0_bigbufneed: DWORD, +}} +pub type PSTAT_SERVER_0 = *mut STAT_SERVER_0; +pub type LPSTAT_SERVER_0 = *mut STAT_SERVER_0; +pub const STATSOPT_CLR: DWORD = 1; +pub const STATS_NO_VALUE: DWORD = -1i32 as u32; +pub const STATS_OVERFLOW: DWORD = -2i32 as u32; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmsvc.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmsvc.rs new file mode 100644 index 0000000..2d9ee5e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmsvc.rs @@ -0,0 +1,180 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! This file contains structures, function prototypes, and definitions for the NetService API +use ctypes::c_long; +use shared::lmcons::NET_API_STATUS; +use shared::minwindef::{DWORD, LPBYTE, LPDWORD}; +use um::winnt::{LPCWSTR, LPWSTR}; +STRUCT!{struct SERVICE_INFO_0 { + svci0_name: LPWSTR, +}} +pub type PSERVICE_INFO_0 = *mut SERVICE_INFO_0; +pub type LPSERVICE_INFO_0 = *mut SERVICE_INFO_0; +STRUCT!{struct SERVICE_INFO_1 { + svci1_name: LPWSTR, + svci1_status: DWORD, + svci1_code: DWORD, + svci1_pid: DWORD, +}} +pub type PSERVICE_INFO_1 = *mut SERVICE_INFO_1; +pub type LPSERVICE_INFO_1 = *mut SERVICE_INFO_1; +STRUCT!{struct SERVICE_INFO_2 { + svci2_name: LPWSTR, + svci2_status: DWORD, + svci2_code: DWORD, + svci2_pid: DWORD, + svci2_text: LPWSTR, + svci2_specific_error: DWORD, + svci2_display_name: LPWSTR, +}} +pub type PSERVICE_INFO_2 = *mut SERVICE_INFO_2; +pub type LPSERVICE_INFO_2 = *mut SERVICE_INFO_2; +extern "system" { + pub fn NetServiceControl( + servername: LPCWSTR, + service: LPCWSTR, + opcode: DWORD, + arg: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetServiceEnum( + servername: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetServiceGetInfo( + servername: LPCWSTR, + service: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetServiceInstall( + servername: LPCWSTR, + service: LPCWSTR, + argc: DWORD, + argv: *mut LPCWSTR, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; +} +pub const SERVICE_INSTALL_STATE: DWORD = 0x03; +pub const SERVICE_UNINSTALLED: DWORD = 0x00; +pub const SERVICE_INSTALL_PENDING: DWORD = 0x01; +pub const SERVICE_UNINSTALL_PENDING: DWORD = 0x02; +pub const SERVICE_INSTALLED: DWORD = 0x03; +pub const SERVICE_PAUSE_STATE: DWORD = 0x0C; +pub const LM20_SERVICE_ACTIVE: DWORD = 0x00; +pub const LM20_SERVICE_CONTINUE_PENDING: DWORD = 0x04; +pub const LM20_SERVICE_PAUSE_PENDING: DWORD = 0x08; +pub const LM20_SERVICE_PAUSED: DWORD = 0x0C; +pub const SERVICE_NOT_UNINSTALLABLE: DWORD = 0x00; +pub const SERVICE_UNINSTALLABLE: DWORD = 0x10; +pub const SERVICE_NOT_PAUSABLE: DWORD = 0x00; +pub const SERVICE_PAUSABLE: DWORD = 0x20; +pub const SERVICE_REDIR_PAUSED: DWORD = 0x700; +pub const SERVICE_REDIR_DISK_PAUSED: DWORD = 0x100; +pub const SERVICE_REDIR_PRINT_PAUSED: DWORD = 0x200; +pub const SERVICE_REDIR_COMM_PAUSED: DWORD = 0x400; +pub const SERVICE_DOS_ENCRYPTION: &'static str = "ENCRYPT"; +pub const SERVICE_CTRL_INTERROGATE: DWORD = 0; +pub const SERVICE_CTRL_PAUSE: DWORD = 1; +pub const SERVICE_CTRL_CONTINUE: DWORD = 2; +pub const SERVICE_CTRL_UNINSTALL: DWORD = 3; +pub const SERVICE_CTRL_REDIR_DISK: DWORD = 0x1; +pub const SERVICE_CTRL_REDIR_PRINT: DWORD = 0x2; +pub const SERVICE_CTRL_REDIR_COMM: DWORD = 0x4; +pub const SERVICE_IP_NO_HINT: DWORD = 0x0; +pub const SERVICE_CCP_NO_HINT: DWORD = 0x0; +pub const SERVICE_IP_QUERY_HINT: DWORD = 0x10000; +pub const SERVICE_CCP_QUERY_HINT: DWORD = 0x10000; +pub const SERVICE_IP_CHKPT_NUM: DWORD = 0x0FF; +pub const SERVICE_CCP_CHKPT_NUM: DWORD = 0x0FF; +pub const SERVICE_IP_WAIT_TIME: DWORD = 0x0FF00; +pub const SERVICE_CCP_WAIT_TIME: DWORD = 0x0FF00; +pub const SERVICE_IP_WAITTIME_SHIFT: DWORD = 8; +pub const SERVICE_NTIP_WAITTIME_SHIFT: DWORD = 12; +pub const UPPER_HINT_MASK: DWORD = 0x0000FF00; +pub const LOWER_HINT_MASK: DWORD = 0x000000FF; +pub const UPPER_GET_HINT_MASK: DWORD = 0x0FF00000; +pub const LOWER_GET_HINT_MASK: DWORD = 0x0000FF00; +pub const SERVICE_NT_MAXTIME: DWORD = 0x0000FFFF; +pub const SERVICE_RESRV_MASK: DWORD = 0x0001FFFF; +pub const SERVICE_MAXTIME: DWORD = 0x000000FF; +pub const SERVICE_BASE: DWORD = 3050; +pub const SERVICE_UIC_NORMAL: DWORD = 0; +pub const SERVICE_UIC_BADPARMVAL: DWORD = SERVICE_BASE + 1; +pub const SERVICE_UIC_MISSPARM: DWORD = SERVICE_BASE + 2; +pub const SERVICE_UIC_UNKPARM: DWORD = SERVICE_BASE + 3; +pub const SERVICE_UIC_RESOURCE: DWORD = SERVICE_BASE + 4; +pub const SERVICE_UIC_CONFIG: DWORD = SERVICE_BASE + 5; +pub const SERVICE_UIC_SYSTEM: DWORD = SERVICE_BASE + 6; +pub const SERVICE_UIC_INTERNAL: DWORD = SERVICE_BASE + 7; +pub const SERVICE_UIC_AMBIGPARM: DWORD = SERVICE_BASE + 8; +pub const SERVICE_UIC_DUPPARM: DWORD = SERVICE_BASE + 9; +pub const SERVICE_UIC_KILL: DWORD = SERVICE_BASE + 10; +pub const SERVICE_UIC_EXEC: DWORD = SERVICE_BASE + 11; +pub const SERVICE_UIC_SUBSERV: DWORD = SERVICE_BASE + 12; +pub const SERVICE_UIC_CONFLPARM: DWORD = SERVICE_BASE + 13; +pub const SERVICE_UIC_FILE: DWORD = SERVICE_BASE + 14; +pub const SERVICE_UIC_M_NULL: DWORD = 0; +pub const SERVICE_UIC_M_MEMORY: DWORD = SERVICE_BASE + 20; +pub const SERVICE_UIC_M_DISK: DWORD = SERVICE_BASE + 21; +pub const SERVICE_UIC_M_THREADS: DWORD = SERVICE_BASE + 22; +pub const SERVICE_UIC_M_PROCESSES: DWORD = SERVICE_BASE + 23; +pub const SERVICE_UIC_M_SECURITY: DWORD = SERVICE_BASE + 24; +pub const SERVICE_UIC_M_LANROOT: DWORD = SERVICE_BASE + 25; +pub const SERVICE_UIC_M_REDIR: DWORD = SERVICE_BASE + 26; +pub const SERVICE_UIC_M_SERVER: DWORD = SERVICE_BASE + 27; +pub const SERVICE_UIC_M_SEC_FILE_ERR: DWORD = SERVICE_BASE + 28; +pub const SERVICE_UIC_M_FILES: DWORD = SERVICE_BASE + 29; +pub const SERVICE_UIC_M_LOGS: DWORD = SERVICE_BASE + 30; +pub const SERVICE_UIC_M_LANGROUP: DWORD = SERVICE_BASE + 31; +pub const SERVICE_UIC_M_MSGNAME: DWORD = SERVICE_BASE + 32; +pub const SERVICE_UIC_M_ANNOUNCE: DWORD = SERVICE_BASE + 33; +pub const SERVICE_UIC_M_UAS: DWORD = SERVICE_BASE + 34; +pub const SERVICE_UIC_M_SERVER_SEC_ERR: DWORD = SERVICE_BASE + 35; +pub const SERVICE_UIC_M_WKSTA: DWORD = SERVICE_BASE + 37; +pub const SERVICE_UIC_M_ERRLOG: DWORD = SERVICE_BASE + 38; +pub const SERVICE_UIC_M_FILE_UW: DWORD = SERVICE_BASE + 39; +pub const SERVICE_UIC_M_ADDPAK: DWORD = SERVICE_BASE + 40; +pub const SERVICE_UIC_M_LAZY: DWORD = SERVICE_BASE + 41; +pub const SERVICE_UIC_M_UAS_MACHINE_ACCT: DWORD = SERVICE_BASE + 42; +pub const SERVICE_UIC_M_UAS_SERVERS_NMEMB: DWORD = SERVICE_BASE + 43; +pub const SERVICE_UIC_M_UAS_SERVERS_NOGRP: DWORD = SERVICE_BASE + 44; +pub const SERVICE_UIC_M_UAS_INVALID_ROLE: DWORD = SERVICE_BASE + 45; +pub const SERVICE_UIC_M_NETLOGON_NO_DC: DWORD = SERVICE_BASE + 46; +pub const SERVICE_UIC_M_NETLOGON_DC_CFLCT: DWORD = SERVICE_BASE + 47; +pub const SERVICE_UIC_M_NETLOGON_AUTH: DWORD = SERVICE_BASE + 48; +pub const SERVICE_UIC_M_UAS_PROLOG: DWORD = SERVICE_BASE + 49; +pub const SERVICE2_BASE: DWORD = 5600; +pub const SERVICE_UIC_M_NETLOGON_MPATH: DWORD = SERVICE2_BASE + 0; +pub const SERVICE_UIC_M_LSA_MACHINE_ACCT: DWORD = SERVICE2_BASE + 1; +pub const SERVICE_UIC_M_DATABASE_ERROR: DWORD = SERVICE2_BASE + 2; +#[inline] +pub fn SERVICE_IP_CODE(tt: DWORD, nn: DWORD) -> c_long { + (SERVICE_IP_QUERY_HINT | (nn | (tt << SERVICE_IP_WAITTIME_SHIFT))) as c_long +} +#[inline] +pub fn SERVICE_CCP_CODE(tt: DWORD, nn: DWORD) -> c_long { + (SERVICE_CCP_QUERY_HINT | (nn | (tt << SERVICE_IP_WAITTIME_SHIFT))) as c_long +} +#[inline] +pub fn SERVICE_UIC_CODE(cc: DWORD, mm: DWORD) -> c_long { + ((cc << 16) | mm) as c_long +} +#[inline] +pub fn SERVICE_NT_CCP_CODE(tt: DWORD, nn: DWORD) -> c_long { + (SERVICE_CCP_QUERY_HINT | nn | ((tt & LOWER_HINT_MASK) << SERVICE_IP_WAITTIME_SHIFT) + | ((tt & UPPER_HINT_MASK) << SERVICE_NTIP_WAITTIME_SHIFT)) as c_long +} +#[inline] +pub fn SERVICE_NT_WAIT_GET(code: DWORD) -> DWORD { + ((code & UPPER_GET_HINT_MASK) >> SERVICE_NTIP_WAITTIME_SHIFT) + | ((code & LOWER_GET_HINT_MASK) >> SERVICE_IP_WAITTIME_SHIFT) +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmuse.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmuse.rs new file mode 100644 index 0000000..6642312 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmuse.rs @@ -0,0 +1,101 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! This file contains structures, function prototypes, and definitions for the NetUse API +use shared::lmcons::{LMSTR, NET_API_STATUS}; +use shared::minwindef::{DWORD, LPBYTE, LPDWORD, PBYTE, ULONG}; +use um::winnt::LPWSTR; +extern "system" { + pub fn NetUseAdd( + servername: LPWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetUseDel( + UncServerName: LMSTR, + UseName: LMSTR, + ForceCond: DWORD, + ) -> NET_API_STATUS; + pub fn NetUseEnum( + UncServerName: LMSTR, + Level: DWORD, + BufPtr: *mut LPBYTE, + PreferedMaximumSize: DWORD, + EntriesRead: LPDWORD, + TotalEntries: LPDWORD, + ResumeHandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetUseGetInfo( + UncServerName: LMSTR, + UseName: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; +} +STRUCT!{struct USE_INFO_0 { + ui0_local: LMSTR, + ui0_remote: LMSTR, +}} +pub type PUSE_INFO_0 = *mut USE_INFO_0; +pub type LPUSE_INFO_0 = *mut USE_INFO_0; +STRUCT!{struct USE_INFO_1 { + ui1_local: LMSTR, + ui1_remote: LMSTR, + ui1_password: LMSTR, + ui1_status: DWORD, + ui1_asg_type: DWORD, + ui1_refcount: DWORD, + ui1_usecount: DWORD, +}} +pub type PUSE_INFO_1 = *mut USE_INFO_1; +pub type LPUSE_INFO_1 = *mut USE_INFO_1; +STRUCT!{struct USE_INFO_2 { + ui2_local: LMSTR, + ui2_remote: LMSTR, + ui2_password: LMSTR, + ui2_status: DWORD, + ui2_asg_type: DWORD, + ui2_refcount: DWORD, + ui2_usecount: DWORD, + ui2_username: LMSTR, + ui2_domainname: LMSTR, +}} +pub type PUSE_INFO_2 = *mut USE_INFO_2; +pub type LPUSE_INFO_2 = *mut USE_INFO_2; +STRUCT!{struct USE_INFO_3 { + ui3_ui2: USE_INFO_2, + ui3_flags: ULONG, +}} +pub type PUSE_INFO_3 = *mut USE_INFO_3; +STRUCT!{struct USE_INFO_4 { + ui4_ui3: USE_INFO_3, + ui4_auth_identity_length: DWORD, + ui4_auth_identity: PBYTE, +}} +pub type PUSE_INFO_4 = *mut USE_INFO_4; +pub type LPUSE_INFO_4 = *mut USE_INFO_4; +pub const USE_LOCAL_PARMNUM: DWORD = 1; +pub const USE_REMOTE_PARMNUM: DWORD = 2; +pub const USE_PASSWORD_PARMNUM: DWORD = 3; +pub const USE_ASGTYPE_PARMNUM: DWORD = 4; +pub const USE_USERNAME_PARMNUM: DWORD = 5; +pub const USE_DOMAINNAME_PARMNUM: DWORD = 6; +pub const USE_OK: DWORD = 0; +pub const USE_PAUSED: DWORD = 1; +pub const USE_SESSLOST: DWORD = 2; +pub const USE_DISCONN: DWORD = 2; +pub const USE_NETERR: DWORD = 3; +pub const USE_CONN: DWORD = 4; +pub const USE_RECONN: DWORD = 5; +pub const USE_WILDCARD: DWORD = -1i32 as u32; +pub const USE_DISKDEV: DWORD = 0; +pub const USE_SPOOLDEV: DWORD = 1; +pub const USE_CHARDEV: DWORD = 2; +pub const USE_IPC: DWORD = 3; +pub const CREATE_NO_CONNECT: ULONG = 0x1; +pub const CREATE_BYPASS_CSC: ULONG = 0x2; +pub const CREATE_CRED_RESET: ULONG = 0x4; +pub const USE_DEFAULT_CREDENTIALS: ULONG = 0x4; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lmwksta.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmwksta.rs new file mode 100644 index 0000000..9b086bf --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lmwksta.rs @@ -0,0 +1,421 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +use shared::lmcons::{LMSTR, NET_API_STATUS}; +use shared::minwindef::{BOOL, DWORD, LPBYTE, LPDWORD}; +use um::winnt::LPCWSTR; +extern "system" { + pub fn NetWkstaGetInfo( + servername: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetWkstaSetInfo( + servername: LMSTR, + level: DWORD, + buffer: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetWkstaUserGetInfo( + reserved: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + ) -> NET_API_STATUS; + pub fn NetWkstaUserSetInfo( + reserved: LMSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetWkstaUserEnum( + servername: LMSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetWkstaTransportAdd( + servername: LPCWSTR, + level: DWORD, + buf: LPBYTE, + parm_err: LPDWORD, + ) -> NET_API_STATUS; + pub fn NetWkstaTransportDel( + servername: LMSTR, + transportname: LMSTR, + ucond: DWORD, + ) -> NET_API_STATUS; + pub fn NetWkstaTransportEnum( + servername: LPCWSTR, + level: DWORD, + bufptr: *mut LPBYTE, + prefmaxlen: DWORD, + entriesread: LPDWORD, + totalentries: LPDWORD, + resumehandle: LPDWORD, + ) -> NET_API_STATUS; +} +STRUCT!{struct WKSTA_INFO_100 { + wki100_platform_id: DWORD, + wki100_computername: LMSTR, + wki100_langroup: LMSTR, + wki100_ver_major: DWORD, + wki100_ver_minor: DWORD, +}} +pub type PWKSTA_INFO_100 = *mut WKSTA_INFO_100; +pub type LPWKSTA_INFO_100 = *mut WKSTA_INFO_100; +STRUCT!{struct WKSTA_INFO_101 { + wki101_platform_id: DWORD, + wki101_computername: LMSTR, + wki101_langroup: LMSTR, + wki101_ver_major: DWORD, + wki101_ver_minor: DWORD, + wki101_lanroot: LMSTR, +}} +pub type PWKSTA_INFO_101 = *mut WKSTA_INFO_101; +pub type LPWKSTA_INFO_101 = *mut WKSTA_INFO_101; +STRUCT!{struct WKSTA_INFO_102 { + wki102_platform_id: DWORD, + wki102_computername: LMSTR, + wki102_langroup: LMSTR, + wki102_ver_major: DWORD, + wki102_ver_minor: DWORD, + wki102_lanroot: LMSTR, + wki102_logged_on_users: DWORD, +}} +pub type PWKSTA_INFO_102 = *mut WKSTA_INFO_102; +pub type LPWKSTA_INFO_102 = *mut WKSTA_INFO_102; +STRUCT!{struct WKSTA_INFO_302 { + wki302_char_wait: DWORD, + wki302_collection_time: DWORD, + wki302_maximum_collection_count: DWORD, + wki302_keep_conn: DWORD, + wki302_keep_search: DWORD, + wki302_max_cmds: DWORD, + wki302_num_work_buf: DWORD, + wki302_siz_work_buf: DWORD, + wki302_max_wrk_cache: DWORD, + wki302_sess_timeout: DWORD, + wki302_siz_error: DWORD, + wki302_num_alerts: DWORD, + wki302_num_services: DWORD, + wki302_errlog_sz: DWORD, + wki302_print_buf_time: DWORD, + wki302_num_char_buf: DWORD, + wki302_siz_char_buf: DWORD, + wki302_wrk_heuristics: LMSTR, + wki302_mailslots: DWORD, + wki302_num_dgram_buf: DWORD, +}} +pub type PWKSTA_INFO_302 = *mut WKSTA_INFO_302; +pub type LPWKSTA_INFO_302 = *mut WKSTA_INFO_302; +STRUCT!{struct WKSTA_INFO_402 { + wki402_char_wait: DWORD, + wki402_collection_time: DWORD, + wki402_maximum_collection_count: DWORD, + wki402_keep_conn: DWORD, + wki402_keep_search: DWORD, + wki402_max_cmds: DWORD, + wki402_num_work_buf: DWORD, + wki402_siz_work_buf: DWORD, + wki402_max_wrk_cache: DWORD, + wki402_sess_timeout: DWORD, + wki402_siz_error: DWORD, + wki402_num_alerts: DWORD, + wki402_num_services: DWORD, + wki402_errlog_sz: DWORD, + wki402_print_buf_time: DWORD, + wki402_num_char_buf: DWORD, + wki402_siz_char_buf: DWORD, + wki402_wrk_heuristics: LMSTR, + wki402_mailslots: DWORD, + wki402_num_dgram_buf: DWORD, + wki402_max_threads: DWORD, +}} +pub type PWKSTA_INFO_402 = *mut WKSTA_INFO_402; +pub type LPWKSTA_INFO_402 = *mut WKSTA_INFO_402; +STRUCT!{struct WKSTA_INFO_502 { + wki502_char_wait: DWORD, + wki502_collection_time: DWORD, + wki502_maximum_collection_count: DWORD, + wki502_keep_conn: DWORD, + wki502_max_cmds: DWORD, + wki502_sess_timeout: DWORD, + wki502_siz_char_buf: DWORD, + wki502_max_threads: DWORD, + wki502_lock_quota: DWORD, + wki502_lock_increment: DWORD, + wki502_lock_maximum: DWORD, + wki502_pipe_increment: DWORD, + wki502_pipe_maximum: DWORD, + wki502_cache_file_timeout: DWORD, + wki502_dormant_file_limit: DWORD, + wki502_read_ahead_throughput: DWORD, + wki502_num_mailslot_buffers: DWORD, + wki502_num_srv_announce_buffers: DWORD, + wki502_max_illegal_datagram_events: DWORD, + wki502_illegal_datagram_event_reset_frequency: DWORD, + wki502_log_election_packets: BOOL, + wki502_use_opportunistic_locking: BOOL, + wki502_use_unlock_behind: BOOL, + wki502_use_close_behind: BOOL, + wki502_buf_named_pipes: BOOL, + wki502_use_lock_read_unlock: BOOL, + wki502_utilize_nt_caching: BOOL, + wki502_use_raw_read: BOOL, + wki502_use_raw_write: BOOL, + wki502_use_write_raw_data: BOOL, + wki502_use_encryption: BOOL, + wki502_buf_files_deny_write: BOOL, + wki502_buf_read_only_files: BOOL, + wki502_force_core_create_mode: BOOL, + wki502_use_512_byte_max_transfer: BOOL, +}} +pub type PWKSTA_INFO_502 = *mut WKSTA_INFO_502; +pub type LPWKSTA_INFO_502 = *mut WKSTA_INFO_502; +STRUCT!{struct WKSTA_INFO_1010 { + wki1010_char_wait: DWORD, +}} +pub type PWKSTA_INFO_1010 = *mut WKSTA_INFO_1010; +pub type LPWKSTA_INFO_1010 = *mut WKSTA_INFO_1010; +STRUCT!{struct WKSTA_INFO_1011 { + wki1011_collection_time: DWORD, +}} +pub type PWKSTA_INFO_1011 = *mut WKSTA_INFO_1011; +pub type LPWKSTA_INFO_1011 = *mut WKSTA_INFO_1011; +STRUCT!{struct WKSTA_INFO_1012 { + wki1012_maximum_collection_count: DWORD, +}} +pub type PWKSTA_INFO_1012 = *mut WKSTA_INFO_1012; +pub type LPWKSTA_INFO_1012 = *mut WKSTA_INFO_1012; +STRUCT!{struct WKSTA_INFO_1027 { + wki1027_errlog_sz: DWORD, +}} +pub type PWKSTA_INFO_1027 = *mut WKSTA_INFO_1027; +pub type LPWKSTA_INFO_1027 = *mut WKSTA_INFO_1027; +STRUCT!{struct WKSTA_INFO_1028 { + wki1028_print_buf_time: DWORD, +}} +pub type PWKSTA_INFO_1028 = *mut WKSTA_INFO_1028; +pub type LPWKSTA_INFO_1028 = *mut WKSTA_INFO_1028; +STRUCT!{struct WKSTA_INFO_1032 { + wki1032_wrk_heuristics: DWORD, +}} +pub type PWKSTA_INFO_1032 = *mut WKSTA_INFO_1032; +pub type LPWKSTA_INFO_1032 = *mut WKSTA_INFO_1032; +STRUCT!{struct WKSTA_INFO_1013 { + wki1013_keep_conn: DWORD, +}} +pub type PWKSTA_INFO_1013 = *mut WKSTA_INFO_1013; +pub type LPWKSTA_INFO_1013 = *mut WKSTA_INFO_1013; +STRUCT!{struct WKSTA_INFO_1018 { + wki1018_sess_timeout: DWORD, +}} +pub type PWKSTA_INFO_1018 = *mut WKSTA_INFO_1018; +pub type LPWKSTA_INFO_1018 = *mut WKSTA_INFO_1018; +STRUCT!{struct WKSTA_INFO_1023 { + wki1023_siz_char_buf: DWORD, +}} +pub type PWKSTA_INFO_1023 = *mut WKSTA_INFO_1023; +pub type LPWKSTA_INFO_1023 = *mut WKSTA_INFO_1023; +STRUCT!{struct WKSTA_INFO_1033 { + wki1033_max_threads: DWORD, +}} +pub type PWKSTA_INFO_1033 = *mut WKSTA_INFO_1033; +pub type LPWKSTA_INFO_1033 = *mut WKSTA_INFO_1033; +STRUCT!{struct WKSTA_INFO_1041 { + wki1041_lock_quota: DWORD, +}} +pub type PWKSTA_INFO_1041 = *mut WKSTA_INFO_1041; +pub type LPWKSTA_INFO_1041 = *mut WKSTA_INFO_1041; +STRUCT!{struct WKSTA_INFO_1042 { + wki1042_lock_increment: DWORD, +}} +pub type PWKSTA_INFO_1042 = *mut WKSTA_INFO_1042; +pub type LPWKSTA_INFO_1042 = *mut WKSTA_INFO_1042; +STRUCT!{struct WKSTA_INFO_1043 { + wki1043_lock_maximum: DWORD, +}} +pub type PWKSTA_INFO_1043 = *mut WKSTA_INFO_1043; +pub type LPWKSTA_INFO_1043 = *mut WKSTA_INFO_1043; +STRUCT!{struct WKSTA_INFO_1044 { + wki1044_pipe_increment: DWORD, +}} +pub type PWKSTA_INFO_1044 = *mut WKSTA_INFO_1044; +pub type LPWKSTA_INFO_1044 = *mut WKSTA_INFO_1044; +STRUCT!{struct WKSTA_INFO_1045 { + wki1045_pipe_maximum: DWORD, +}} +pub type PWKSTA_INFO_1045 = *mut WKSTA_INFO_1045; +pub type LPWKSTA_INFO_1045 = *mut WKSTA_INFO_1045; +STRUCT!{struct WKSTA_INFO_1046 { + wki1046_dormant_file_limit: DWORD, +}} +pub type PWKSTA_INFO_1046 = *mut WKSTA_INFO_1046; +pub type LPWKSTA_INFO_1046 = *mut WKSTA_INFO_1046; +STRUCT!{struct WKSTA_INFO_1047 { + wki1047_cache_file_timeout: DWORD, +}} +pub type PWKSTA_INFO_1047 = *mut WKSTA_INFO_1047; +pub type LPWKSTA_INFO_1047 = *mut WKSTA_INFO_1047; +STRUCT!{struct WKSTA_INFO_1048 { + wki1048_use_opportunistic_locking: BOOL, +}} +pub type PWKSTA_INFO_1048 = *mut WKSTA_INFO_1048; +pub type LPWKSTA_INFO_1048 = *mut WKSTA_INFO_1048; +STRUCT!{struct WKSTA_INFO_1049 { + wki1049_use_unlock_behind: BOOL, +}} +pub type PWKSTA_INFO_1049 = *mut WKSTA_INFO_1049; +pub type LPWKSTA_INFO_1049 = *mut WKSTA_INFO_1049; +STRUCT!{struct WKSTA_INFO_1050 { + wki1050_use_close_behind: BOOL, +}} +pub type PWKSTA_INFO_1050 = *mut WKSTA_INFO_1050; +pub type LPWKSTA_INFO_1050 = *mut WKSTA_INFO_1050; +STRUCT!{struct WKSTA_INFO_1051 { + wki1051_buf_named_pipes: BOOL, +}} +pub type PWKSTA_INFO_1051 = *mut WKSTA_INFO_1051; +pub type LPWKSTA_INFO_1051 = *mut WKSTA_INFO_1051; +STRUCT!{struct WKSTA_INFO_1052 { + wki1052_use_lock_read_unlock: BOOL, +}} +pub type PWKSTA_INFO_1052 = *mut WKSTA_INFO_1052; +pub type LPWKSTA_INFO_1052 = *mut WKSTA_INFO_1052; +STRUCT!{struct WKSTA_INFO_1053 { + wki1053_utilize_nt_caching: BOOL, +}} +pub type PWKSTA_INFO_1053 = *mut WKSTA_INFO_1053; +pub type LPWKSTA_INFO_1053 = *mut WKSTA_INFO_1053; +STRUCT!{struct WKSTA_INFO_1054 { + wki1054_use_raw_read: BOOL, +}} +pub type PWKSTA_INFO_1054 = *mut WKSTA_INFO_1054; +pub type LPWKSTA_INFO_1054 = *mut WKSTA_INFO_1054; +STRUCT!{struct WKSTA_INFO_1055 { + wki1055_use_raw_write: BOOL, +}} +pub type PWKSTA_INFO_1055 = *mut WKSTA_INFO_1055; +pub type LPWKSTA_INFO_1055 = *mut WKSTA_INFO_1055; +STRUCT!{struct WKSTA_INFO_1056 { + wki1056_use_write_raw_data: BOOL, +}} +pub type PWKSTA_INFO_1056 = *mut WKSTA_INFO_1056; +pub type LPWKSTA_INFO_1056 = *mut WKSTA_INFO_1056; +STRUCT!{struct WKSTA_INFO_1057 { + wki1057_use_encryption: BOOL, +}} +pub type PWKSTA_INFO_1057 = *mut WKSTA_INFO_1057; +pub type LPWKSTA_INFO_1057 = *mut WKSTA_INFO_1057; +STRUCT!{struct WKSTA_INFO_1058 { + wki1058_buf_files_deny_write: BOOL, +}} +pub type PWKSTA_INFO_1058 = *mut WKSTA_INFO_1058; +pub type LPWKSTA_INFO_1058 = *mut WKSTA_INFO_1058; +STRUCT!{struct WKSTA_INFO_1059 { + wki1059_buf_read_only_files: BOOL, +}} +pub type PWKSTA_INFO_1059 = *mut WKSTA_INFO_1059; +pub type LPWKSTA_INFO_1059 = *mut WKSTA_INFO_1059; +STRUCT!{struct WKSTA_INFO_1060 { + wki1060_force_core_create_mode: BOOL, +}} +pub type PWKSTA_INFO_1060 = *mut WKSTA_INFO_1060; +pub type LPWKSTA_INFO_1060 = *mut WKSTA_INFO_1060; +STRUCT!{struct WKSTA_INFO_1061 { + wki1061_use_512_byte_max_transfer: BOOL, +}} +pub type PWKSTA_INFO_1061 = *mut WKSTA_INFO_1061; +pub type LPWKSTA_INFO_1061 = *mut WKSTA_INFO_1061; +STRUCT!{struct WKSTA_INFO_1062 { + wki1062_read_ahead_throughput: DWORD, +}} +pub type PWKSTA_INFO_1062 = *mut WKSTA_INFO_1062; +pub type LPWKSTA_INFO_1062 = *mut WKSTA_INFO_1062; +STRUCT!{struct WKSTA_USER_INFO_0 { + wkui0_username: LMSTR, +}} +pub type PWKSTA_USER_INFO_0 = *mut WKSTA_USER_INFO_0; +pub type LPWKSTA_USER_INFO_0 = *mut WKSTA_USER_INFO_0; +STRUCT!{struct WKSTA_USER_INFO_1 { + wkui1_username: LMSTR, + wkui1_logon_domain: LMSTR, + wkui1_oth_domains: LMSTR, + wkui1_logon_server: LMSTR, +}} +pub type PWKSTA_USER_INFO_1 = *mut WKSTA_USER_INFO_1; +pub type LPWKSTA_USER_INFO_1 = *mut WKSTA_USER_INFO_1; +STRUCT!{struct WKSTA_USER_INFO_1101 { + wkui1101_oth_domains: LMSTR, +}} +pub type PWKSTA_USER_INFO_1101 = *mut WKSTA_USER_INFO_1101; +pub type LPWKSTA_USER_INFO_1101 = *mut WKSTA_USER_INFO_1101; +STRUCT!{struct WKSTA_TRANSPORT_INFO_0 { + wkti0_quality_of_service: DWORD, + wkti0_number_of_vcs: DWORD, + wkti0_transport_name: LMSTR, + wkti0_transport_address: LMSTR, + wkti0_wan_ish: BOOL, +}} +pub type PWKSTA_TRANSPORT_INFO_0 = *mut WKSTA_TRANSPORT_INFO_0; +pub type LPWKSTA_TRANSPORT_INFO_0 = *mut WKSTA_TRANSPORT_INFO_0; +pub const WKSTA_PLATFORM_ID_PARMNUM: DWORD = 100; +pub const WKSTA_COMPUTERNAME_PARMNUM: DWORD = 1; +pub const WKSTA_LANGROUP_PARMNUM: DWORD = 2; +pub const WKSTA_VER_MAJOR_PARMNUM: DWORD = 4; +pub const WKSTA_VER_MINOR_PARMNUM: DWORD = 5; +pub const WKSTA_LOGGED_ON_USERS_PARMNUM: DWORD = 6; +pub const WKSTA_LANROOT_PARMNUM: DWORD = 7; +pub const WKSTA_LOGON_DOMAIN_PARMNUM: DWORD = 8; +pub const WKSTA_LOGON_SERVER_PARMNUM: DWORD = 9; +pub const WKSTA_CHARWAIT_PARMNUM: DWORD = 10; +pub const WKSTA_CHARTIME_PARMNUM: DWORD = 11; +pub const WKSTA_CHARCOUNT_PARMNUM: DWORD = 12; +pub const WKSTA_KEEPCONN_PARMNUM: DWORD = 13; +pub const WKSTA_KEEPSEARCH_PARMNUM: DWORD = 14; +pub const WKSTA_MAXCMDS_PARMNUM: DWORD = 15; +pub const WKSTA_NUMWORKBUF_PARMNUM: DWORD = 16; +pub const WKSTA_MAXWRKCACHE_PARMNUM: DWORD = 17; +pub const WKSTA_SESSTIMEOUT_PARMNUM: DWORD = 18; +pub const WKSTA_SIZERROR_PARMNUM: DWORD = 19; +pub const WKSTA_NUMALERTS_PARMNUM: DWORD = 20; +pub const WKSTA_NUMSERVICES_PARMNUM: DWORD = 21; +pub const WKSTA_NUMCHARBUF_PARMNUM: DWORD = 22; +pub const WKSTA_SIZCHARBUF_PARMNUM: DWORD = 23; +pub const WKSTA_ERRLOGSZ_PARMNUM: DWORD = 27; +pub const WKSTA_PRINTBUFTIME_PARMNUM: DWORD = 28; +pub const WKSTA_SIZWORKBUF_PARMNUM: DWORD = 29; +pub const WKSTA_MAILSLOTS_PARMNUM: DWORD = 30; +pub const WKSTA_NUMDGRAMBUF_PARMNUM: DWORD = 31; +pub const WKSTA_WRKHEURISTICS_PARMNUM: DWORD = 32; +pub const WKSTA_MAXTHREADS_PARMNUM: DWORD = 33; +pub const WKSTA_LOCKQUOTA_PARMNUM: DWORD = 41; +pub const WKSTA_LOCKINCREMENT_PARMNUM: DWORD = 42; +pub const WKSTA_LOCKMAXIMUM_PARMNUM: DWORD = 43; +pub const WKSTA_PIPEINCREMENT_PARMNUM: DWORD = 44; +pub const WKSTA_PIPEMAXIMUM_PARMNUM: DWORD = 45; +pub const WKSTA_DORMANTFILELIMIT_PARMNUM: DWORD = 46; +pub const WKSTA_CACHEFILETIMEOUT_PARMNUM: DWORD = 47; +pub const WKSTA_USEOPPORTUNISTICLOCKING_PARMNUM: DWORD = 48; +pub const WKSTA_USEUNLOCKBEHIND_PARMNUM: DWORD = 49; +pub const WKSTA_USECLOSEBEHIND_PARMNUM: DWORD = 50; +pub const WKSTA_BUFFERNAMEDPIPES_PARMNUM: DWORD = 51; +pub const WKSTA_USELOCKANDREADANDUNLOCK_PARMNUM: DWORD = 52; +pub const WKSTA_UTILIZENTCACHING_PARMNUM: DWORD = 53; +pub const WKSTA_USERAWREAD_PARMNUM: DWORD = 54; +pub const WKSTA_USERAWWRITE_PARMNUM: DWORD = 55; +pub const WKSTA_USEWRITERAWWITHDATA_PARMNUM: DWORD = 56; +pub const WKSTA_USEENCRYPTION_PARMNUM: DWORD = 57; +pub const WKSTA_BUFFILESWITHDENYWRITE_PARMNUM: DWORD = 58; +pub const WKSTA_BUFFERREADONLYFILES_PARMNUM: DWORD = 59; +pub const WKSTA_FORCECORECREATEMODE_PARMNUM: DWORD = 60; +pub const WKSTA_USE512BYTESMAXTRANSFER_PARMNUM: DWORD = 61; +pub const WKSTA_READAHEADTHRUPUT_PARMNUM: DWORD = 62; +pub const WKSTA_OTH_DOMAINS_PARMNUM: DWORD = 101; +pub const TRANSPORT_QUALITYOFSERVICE_PARMNUM: DWORD = 201; +pub const TRANSPORT_NAME_PARMNUM: DWORD = 202; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lowlevelmonitorconfigurationapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lowlevelmonitorconfigurationapi.rs new file mode 100644 index 0000000..fe73214 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lowlevelmonitorconfigurationapi.rs @@ -0,0 +1,49 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BYTE, DWORD, LPDWORD}; +use um::physicalmonitorenumerationapi::_BOOL; +use um::winnt::{HANDLE, LPSTR}; +STRUCT!{#[repr(packed)] struct MC_TIMING_REPORT { + dwHorizontalFrequencyInHZ: DWORD, + dwVerticalFrequencyInHZ: DWORD, + bTimingStatusByte: BYTE, +}} +pub type LPMC_TIMING_REPORT = *mut MC_TIMING_REPORT; +ENUM!{enum MC_VCP_CODE_TYPE { + MC_MOMENTARY, + MC_SET_PARAMETER, +}} +pub type LPMC_VCP_CODE_TYPE = *mut MC_VCP_CODE_TYPE; +extern "system" { + pub fn GetVCPFeatureAndVCPFeatureReply( + hMonitor: HANDLE, + bVCPCode: BYTE, + pvct: LPMC_VCP_CODE_TYPE, + pdwCurrentValue: LPDWORD, + pdwMaximumValue: LPDWORD, + ) -> _BOOL; + pub fn SetVCPFeature( + hMonitor: HANDLE, + bVCPCode: BYTE, + dwNewValue: DWORD, + ) -> _BOOL; + pub fn SaveCurrentSettings( + hMonitor: HANDLE, + ) -> _BOOL; + pub fn GetCapabilitiesStringLength( + hMonitor: HANDLE, + pdwCapabilitiesStringLengthInCharacters: LPDWORD, + ) -> _BOOL; + pub fn CapabilitiesRequestAndCapabilitiesReply( + hMonitor: HANDLE, + pszASCIICapabilitiesString: LPSTR, + dwCapabilitiesStringLengthInCharacters: DWORD, + ) -> _BOOL; + pub fn GetTimingReport( + hMonitor: HANDLE, + pmtrMonitorTimingReport: LPMC_TIMING_REPORT, + ) -> _BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/lsalookup.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/lsalookup.rs new file mode 100644 index 0000000..95a6b62 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/lsalookup.rs @@ -0,0 +1,109 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! LSA Policy Lookup API +use shared::guiddef::GUID; +use shared::minwindef::{ULONG, USHORT}; +use shared::ntdef::NTSTATUS; +use um::winnt::{ACCESS_MASK, HANDLE, LONG, PCHAR, PSID, PVOID, PWSTR, SID_NAME_USE}; +STRUCT!{struct LSA_UNICODE_STRING { + Length: USHORT, + MaximumLength: USHORT, + Buffer: PWSTR, +}} +pub type PLSA_UNICODE_STRING = *mut LSA_UNICODE_STRING; +STRUCT!{struct LSA_STRING { + Length: USHORT, + MaximumLength: USHORT, + Buffer: PCHAR, +}} +pub type PLSA_STRING = *mut LSA_STRING; +STRUCT!{struct LSA_OBJECT_ATTRIBUTES { + Length: ULONG, + RootDirectory: HANDLE, + ObjectName: PLSA_UNICODE_STRING, + Attributes: ULONG, + SecurityDescriptor: PVOID, + SecurityQualityOfService: PVOID, +}} +pub type PLSA_OBJECT_ATTRIBUTES = *mut LSA_OBJECT_ATTRIBUTES; +STRUCT!{struct LSA_TRUST_INFORMATION { + Name: LSA_UNICODE_STRING, + Sid: PSID, +}} +pub type PLSA_TRUST_INFORMATION = *mut LSA_TRUST_INFORMATION; +STRUCT!{struct LSA_REFERENCED_DOMAIN_LIST { + Entries: ULONG, + Domains: PLSA_TRUST_INFORMATION, +}} +pub type PLSA_REFERENCED_DOMAIN_LIST = *mut LSA_REFERENCED_DOMAIN_LIST; +STRUCT!{struct LSA_TRANSLATED_SID2 { + Use: SID_NAME_USE, + Sid: PSID, + DomainIndex: LONG, + Flags: ULONG, +}} +pub type PLSA_TRANSLATED_SID2 = *mut LSA_TRANSLATED_SID2; +STRUCT!{struct LSA_TRANSLATED_NAME { + Use: SID_NAME_USE, + Name: LSA_UNICODE_STRING, + DomainIndex: LONG, +}} +pub type PLSA_TRANSLATED_NAME = *mut LSA_TRANSLATED_NAME; +STRUCT!{struct POLICY_ACCOUNT_DOMAIN_INFO { + DomainName: LSA_UNICODE_STRING, + DomainSid: PSID, +}} +pub type PPOLICY_ACCOUNT_DOMAIN_INFO = *mut POLICY_ACCOUNT_DOMAIN_INFO; +STRUCT!{struct POLICY_DNS_DOMAIN_INFO { + Name: LSA_UNICODE_STRING, + DnsDomainName: LSA_UNICODE_STRING, + DnsForestName: LSA_UNICODE_STRING, + DomainGuid: GUID, + Sid: PSID, +}} +pub type PPOLICY_DNS_DOMAIN_INFO = *mut POLICY_DNS_DOMAIN_INFO; +pub const LOOKUP_VIEW_LOCAL_INFORMATION: ACCESS_MASK = 0x00000001; +pub const LOOKUP_TRANSLATE_NAMES: ACCESS_MASK = 0x00000800; +ENUM!{enum LSA_LOOKUP_DOMAIN_INFO_CLASS { + AccountDomainInformation = 5, + DnsDomainInformation = 12, +}} +pub type PLSA_LOOKUP_DOMAIN_INFO_CLASS = *mut LSA_LOOKUP_DOMAIN_INFO_CLASS; +pub type LSA_LOOKUP_HANDLE = PVOID; +pub type PLSA_LOOKUP_HANDLE = *mut PVOID; +extern "C" { + pub fn LsaLookupOpenLocalPolicy( + ObjectAttributes: PLSA_OBJECT_ATTRIBUTES, + AccessMask: ACCESS_MASK, + PolicyHandle: PLSA_LOOKUP_HANDLE, + ) -> NTSTATUS; + pub fn LsaLookupClose( + ObjectHandle: LSA_LOOKUP_HANDLE, + ) -> NTSTATUS; + pub fn LsaLookupTranslateSids( + PolicyHandle: LSA_LOOKUP_HANDLE, + Count: ULONG, + Sids: *mut PSID, + ReferencedDomains: *mut PLSA_REFERENCED_DOMAIN_LIST, + Names: *mut PLSA_TRANSLATED_NAME, + ) -> NTSTATUS; + pub fn LsaLookupTranslateNames( + PolicyHandle: LSA_LOOKUP_HANDLE, + Flags: ULONG, + Count: ULONG, + Names: PLSA_UNICODE_STRING, + ReferencedDomains: *mut PLSA_REFERENCED_DOMAIN_LIST, + Sids: *mut PLSA_TRANSLATED_SID2, + ) -> NTSTATUS; + pub fn LsaLookupGetDomainInfo( + PolicyHandle: LSA_LOOKUP_HANDLE, + DomainInfoClass: LSA_LOOKUP_DOMAIN_INFO_CLASS, + DomainInfo: *mut PVOID, + ) -> NTSTATUS; + pub fn LsaLookupFreeMemory( + Buffer: PVOID, + ) -> NTSTATUS; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/memoryapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/memoryapi.rs new file mode 100644 index 0000000..5bf5bd0 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/memoryapi.rs @@ -0,0 +1,390 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-core-memory-l1-1-0 +use ctypes::c_void; +use shared::basetsd::{PSIZE_T, PULONG_PTR, SIZE_T, ULONG64, ULONG_PTR}; +use shared::minwindef::{ + BOOL, DWORD, LPCVOID, LPDWORD, LPVOID, PBOOL, PDWORD, PULONG, UINT, ULONG, +}; +use um::minwinbase::{LPSECURITY_ATTRIBUTES, PSECURITY_ATTRIBUTES}; +use um::winnt::{ + HANDLE, LPCWSTR, PCWSTR, PMEMORY_BASIC_INFORMATION, PVOID, SECTION_ALL_ACCESS, + SECTION_MAP_EXECUTE_EXPLICIT, SECTION_MAP_READ, SECTION_MAP_WRITE, +}; +pub const FILE_MAP_WRITE: DWORD = SECTION_MAP_WRITE; +pub const FILE_MAP_READ: DWORD = SECTION_MAP_READ; +pub const FILE_MAP_ALL_ACCESS: DWORD = SECTION_ALL_ACCESS; +pub const FILE_MAP_EXECUTE: DWORD = SECTION_MAP_EXECUTE_EXPLICIT; +pub const FILE_MAP_COPY: DWORD = 0x00000001; +pub const FILE_MAP_RESERVE: DWORD = 0x80000000; +pub const FILE_MAP_TARGETS_INVALID: DWORD = 0x40000000; +pub const FILE_MAP_LARGE_PAGES: DWORD = 0x20000000; +extern "system" { + pub fn VirtualAlloc( + lpAddress: LPVOID, + dwSize: SIZE_T, + flAllocationType: DWORD, + flProtect: DWORD, + ) -> LPVOID; + pub fn VirtualProtect( + lpAddress: LPVOID, + dwSize: SIZE_T, + flNewProtect: DWORD, + lpflOldProtect: PDWORD, + ) -> BOOL; + pub fn VirtualFree( + lpAddress: LPVOID, + dwSize: SIZE_T, + dwFreeType: DWORD, + ) -> BOOL; + pub fn VirtualQuery( + lpAddress: LPCVOID, + lpBuffer: PMEMORY_BASIC_INFORMATION, + dwLength: SIZE_T, + ) -> SIZE_T; + pub fn VirtualAllocEx( + hProcess: HANDLE, + lpAddress: LPVOID, + dwSize: SIZE_T, + flAllocationType: DWORD, + flProtect: DWORD, + ) -> LPVOID; + pub fn VirtualFreeEx( + hProcess: HANDLE, + lpAddress: LPVOID, + dwSize: SIZE_T, + dwFreeType: DWORD, + ) -> BOOL; + pub fn VirtualProtectEx( + hProcess: HANDLE, + lpAddress: LPVOID, + dwSize: SIZE_T, + flNewProtect: DWORD, + lpflOldProtect: PDWORD, + ) -> BOOL; + pub fn VirtualQueryEx( + hProcess: HANDLE, + lpAddress: LPCVOID, + lpBuffer: PMEMORY_BASIC_INFORMATION, + dwLength: SIZE_T, + ) -> SIZE_T; + pub fn ReadProcessMemory( + hProcess: HANDLE, + lpBaseAddress: LPCVOID, + lpBuffer: LPVOID, + nSize: SIZE_T, + lpNumberOfBytesRead: *mut SIZE_T, + ) -> BOOL; + pub fn WriteProcessMemory( + hProcess: HANDLE, + lpBaseAddress: LPVOID, + lpBuffer: LPCVOID, + nSize: SIZE_T, + lpNumberOfBytesWritten: *mut SIZE_T, + ) -> BOOL; + pub fn CreateFileMappingW( + hFile: HANDLE, + lpFileMappingAttributes: LPSECURITY_ATTRIBUTES, + flProtect: DWORD, + dwMaximumSizeHigh: DWORD, + dwMaximumSizeLow: DWORD, + lpName: LPCWSTR, + ) -> HANDLE; + pub fn OpenFileMappingW( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpName: LPCWSTR, + ) -> HANDLE; + pub fn MapViewOfFile( + hFileMappingObject: HANDLE, + dwDesiredAccess: DWORD, + dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, + dwNumberOfBytesToMap: SIZE_T, + ) -> LPVOID; + pub fn MapViewOfFileEx( + hFileMappingObject: HANDLE, + dwDesiredAccess: DWORD, + dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, + dwNumberOfBytesToMap: SIZE_T, + lpBaseAddress: LPVOID, + ) -> LPVOID; + pub fn FlushViewOfFile( + lpBaseAddress: LPCVOID, + dwNumberOfBytesToFlush: SIZE_T, + ) -> BOOL; + pub fn UnmapViewOfFile( + lpBaseAddress: LPCVOID, + ) -> BOOL; + pub fn GetLargePageMinimum() -> SIZE_T; + pub fn GetProcessWorkingSetSizeEx( + hProcess: HANDLE, + lpMinimumWorkingSetSize: PSIZE_T, + lpMaximumWorkingSetSize: PSIZE_T, + Flags: PDWORD, + ) -> BOOL; + pub fn SetProcessWorkingSetSizeEx( + hProcess: HANDLE, + dwMinimumWorkingSetSize: SIZE_T, + dwMaximumWorkingSetSize: SIZE_T, + Flags: DWORD, + ) -> BOOL; + pub fn VirtualLock( + lpAddress: LPVOID, + dwSize: SIZE_T, + ) -> BOOL; + pub fn VirtualUnlock( + lpAddress: LPVOID, + dwSize: SIZE_T, + ) -> BOOL; + pub fn GetWriteWatch( + dwFlags: DWORD, + lpBaseAddress: PVOID, + dwRegionSize: SIZE_T, + lpAddresses: *mut PVOID, + lpdwCount: *mut ULONG_PTR, + lpdwGranularity: LPDWORD, + ) -> UINT; + pub fn ResetWriteWatch( + lpBaseAddress: LPVOID, + dwRegionSize: SIZE_T, + ) -> UINT; +} +ENUM!{enum MEMORY_RESOURCE_NOTIFICATION_TYPE { + LowMemoryResourceNotification, + HighMemoryResourceNotification, +}} +extern "system" { + pub fn CreateMemoryResourceNotification( + NotificationType: MEMORY_RESOURCE_NOTIFICATION_TYPE, + ) -> HANDLE; + pub fn QueryMemoryResourceNotification( + ResourceNotificationHandle: HANDLE, + ResourceState: PBOOL, + ) -> BOOL; +} +pub const FILE_CACHE_MAX_HARD_ENABLE: DWORD = 0x00000001; +pub const FILE_CACHE_MAX_HARD_DISABLE: DWORD = 0x00000002; +pub const FILE_CACHE_MIN_HARD_ENABLE: DWORD = 0x00000004; +pub const FILE_CACHE_MIN_HARD_DISABLE: DWORD = 0x00000008; +extern "system" { + pub fn GetSystemFileCacheSize( + lpMinimumFileCacheSize: PSIZE_T, + lpMaximumFileCacheSize: PSIZE_T, + lpFlags: PDWORD, + ) -> BOOL; + pub fn SetSystemFileCacheSize( + MinimumFileCacheSize: SIZE_T, + MaximumFileCacheSize: SIZE_T, + Flags: DWORD, + ) -> BOOL; + pub fn CreateFileMappingNumaW( + hFile: HANDLE, + lpFileMappingAttributes: LPSECURITY_ATTRIBUTES, + flProtect: DWORD, + dwMaximumSizeHigh: DWORD, + dwMaximumSizeLow: DWORD, + lpName: LPCWSTR, + nndPreferred: DWORD, + ) -> HANDLE; +} +STRUCT!{struct WIN32_MEMORY_RANGE_ENTRY { + VirtualAddress: PVOID, + NumberOfBytes: SIZE_T, +}} +pub type PWIN32_MEMORY_RANGE_ENTRY = *mut WIN32_MEMORY_RANGE_ENTRY; +extern "system" { + pub fn PrefetchVirtualMemory( + hProcess: HANDLE, + NumberOfEntries: ULONG_PTR, + VirtualAddresses: PWIN32_MEMORY_RANGE_ENTRY, + Flags: ULONG, + ) -> BOOL; + pub fn CreateFileMappingFromApp( + hFile: HANDLE, + SecurityAttributes: PSECURITY_ATTRIBUTES, + PageProtection: ULONG, + MaximumSize: ULONG64, + Name: PCWSTR, + ) -> HANDLE; + pub fn MapViewOfFileFromApp( + hFileMappingObject: HANDLE, + DesiredAccess: ULONG, + FileOffset: ULONG64, + NumberOfBytesToMap: SIZE_T, + ) -> PVOID; + pub fn UnmapViewOfFileEx( + BaseAddress: PVOID, + UnmapFlags: ULONG, + ) -> BOOL; + pub fn AllocateUserPhysicalPages( + hProcess: HANDLE, + NumberOfPages: PULONG_PTR, + PageArray: PULONG_PTR, + ) -> BOOL; + pub fn FreeUserPhysicalPages( + hProcess: HANDLE, + NumberOfPages: PULONG_PTR, + PageArray: PULONG_PTR, + ) -> BOOL; + pub fn MapUserPhysicalPages( + VirtualAddress: PVOID, + NumberOfPages: ULONG_PTR, + PageArray: PULONG_PTR, + ) -> BOOL; + pub fn AllocateUserPhysicalPagesNuma( + hProcess: HANDLE, + NumberOfPages: PULONG_PTR, + PageArray: PULONG_PTR, + nndPreferred: DWORD, + ) -> BOOL; + pub fn VirtualAllocExNuma( + hProcess: HANDLE, + lpAddress: LPVOID, + dwSize: SIZE_T, + flAllocationType: DWORD, + flProtect: DWORD, + nndPreferred: DWORD, + ) -> LPVOID; +} +pub const MEHC_PATROL_SCRUBBER_PRESENT: ULONG = 0x1; +extern "system" { + pub fn GetMemoryErrorHandlingCapabilities( + Capabilities: PULONG, + ) -> BOOL; +} +FN!{stdcall PBAD_MEMORY_CALLBACK_ROUTINE() -> ()} +extern "system" { + pub fn RegisterBadMemoryNotification( + Callback: PBAD_MEMORY_CALLBACK_ROUTINE, + ) -> PVOID; + pub fn UnregisterBadMemoryNotification( + RegistrationHandle: PVOID, + ) -> BOOL; +} +ENUM!{enum OFFER_PRIORITY { + VmOfferPriorityVeryLow = 1, + VmOfferPriorityLow, + VmOfferPriorityBelowNormal, + VmOfferPriorityNormal, +}} +extern "system" { + pub fn OfferVirtualMemory( + VirtualAddress: PVOID, + Size: SIZE_T, + Priority: OFFER_PRIORITY, + ) -> DWORD; + pub fn ReclaimVirtualMemory( + VirtualAddress: *const c_void, + Size: SIZE_T, + ) -> DWORD; + pub fn DiscardVirtualMemory( + VirtualAddress: PVOID, + Size: SIZE_T, + ) -> DWORD; +// TODO: Needs winnt::PCFG_CALL_TARGET_INFO. +/* pub fn SetProcessValidCallTargets( + hProcess: HANDLE, + VirtualAddress: PVOID, + RegionSize: SIZE_T, + NumberOfOffsets: ULONG, + OffsetInformation: PCFG_CALL_TARGET_INFO, + ) -> BOOL; */ + pub fn VirtualAllocFromApp( + BaseAddress: PVOID, + Size: SIZE_T, + AllocationType: ULONG, + Protection: ULONG, + ) -> PVOID; + pub fn VirtualProtectFromApp( + Address: PVOID, + Size: SIZE_T, + NewProtection: ULONG, + OldProtection: PULONG, + ) -> BOOL; + pub fn OpenFileMappingFromApp( + DesiredAccess: ULONG, + InheritHandle: BOOL, + Name: PCWSTR, + ) -> HANDLE; +} +// TODO: Under WINAPI_PARTITION_APP, define CreateFileMappingW, MapViewOfFile, VirtualAlloc, +// VirtualProtect, and OpenFileMappingW as wrappers around the *FromApp functions. +ENUM!{enum WIN32_MEMORY_INFORMATION_CLASS { + MemoryRegionInfo, +}} +STRUCT!{struct WIN32_MEMORY_REGION_INFORMATION { + AllocationBase: PVOID, + AllocationProtect: ULONG, + u: WIN32_MEMORY_REGION_INFORMATION_u, + RegionSize: SIZE_T, + CommitSize: SIZE_T, +}} +UNION!{union WIN32_MEMORY_REGION_INFORMATION_u { + [u32; 1], + Flags Flags_mut: ULONG, + s s_mut: WIN32_MEMORY_REGION_INFORMATION_u_s, +}} +STRUCT!{struct WIN32_MEMORY_REGION_INFORMATION_u_s { + Bitfield: ULONG, +}} +BITFIELD!{WIN32_MEMORY_REGION_INFORMATION_u_s Bitfield: ULONG [ + Private set_Private[0..1], + MappedDataFile set_MappedDataFile[1..2], + MappedImage set_MappedImage[2..3], + MappedPageFile set_MappedPageFile[3..4], + MappedPhysical set_MappedPhysical[4..5], + DirectMapped set_DirectMapped[5..6], + Reserved set_Reserved[6..32], +]} +// TODO: Need to resolve issue #323 first. +/*extern "system" { + pub fn QueryVirtualMemoryInformation( + Process: HANDLE, + VirtualAddress: *const VOID, + MemoryInformationClass: WIN32_MEMORY_INFORMATION_CLASS, + MemoryInformation: PVOID, + MemoryInformationSize: SIZE_T, + ReturnSize: PSIZE_T, + ) -> BOOL; + pub fn MapViewOfFileNuma2( + FileMappingHandle: HANDLE, + ProcessHandle: HANDLE, + Offset: ULONG64, + BaseAddress: PVOID, + ViewSize: SIZE_T, + AllocationType: ULONG, + PageProtection: ULONG, + PreferredNode: ULONG, + ) -> PVOID; +} +#[inline] +pub unsafe fn MapViewOfFile2( + FileMappingHandle: HANDLE, + ProcessHandle: HANDLE, + Offset: ULONG64, + BaseAddress: PVOID, + ViewSize: SIZE_T, + AllocationType: ULONG, + PageProtection: ULONG, +) -> PVOID { + MapViewOfFileNuma2(FileMappingHandle, + ProcessHandle, + Offset, + BaseAddress, + ViewSize, + AllocationType, + PageProtection, + NUMA_NO_PREFERRED_NODE) +}*/ +extern "system" { + pub fn UnmapViewOfFile2( + ProcessHandle: HANDLE, + BaseAddress: PVOID, + UnmapFlags: ULONG, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/minschannel.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/minschannel.rs new file mode 100644 index 0000000..ba3ca4f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/minschannel.rs @@ -0,0 +1,58 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Public Definitions for MIN SCHANNEL Security Provider +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, DWORD}; +use um::wincrypt::ALG_ID; +use um::winnt::LPWSTR; +pub const SECPKG_ATTR_ISSUER_LIST: DWORD = 0x50; +pub const SECPKG_ATTR_REMOTE_CRED: DWORD = 0x51; +pub const SECPKG_ATTR_LOCAL_CRED: DWORD = 0x52; +pub const SECPKG_ATTR_REMOTE_CERT_CONTEXT: DWORD = 0x53; +pub const SECPKG_ATTR_LOCAL_CERT_CONTEXT: DWORD = 0x54; +pub const SECPKG_ATTR_ROOT_STORE: DWORD = 0x55; +pub const SECPKG_ATTR_SUPPORTED_ALGS: DWORD = 0x56; +pub const SECPKG_ATTR_CIPHER_STRENGTHS: DWORD = 0x57; +pub const SECPKG_ATTR_SUPPORTED_PROTOCOLS: DWORD = 0x58; +pub const SECPKG_ATTR_ISSUER_LIST_EX: DWORD = 0x59; +pub const SECPKG_ATTR_CONNECTION_INFO: DWORD = 0x5a; +pub const SECPKG_ATTR_EAP_KEY_BLOCK: DWORD = 0x5b; +pub const SECPKG_ATTR_MAPPED_CRED_ATTR: DWORD = 0x5c; +pub const SECPKG_ATTR_SESSION_INFO: DWORD = 0x5d; +pub const SECPKG_ATTR_APP_DATA: DWORD = 0x5e; +pub const SECPKG_ATTR_REMOTE_CERTIFICATES: DWORD = 0x5F; +pub const SECPKG_ATTR_CLIENT_CERT_POLICY: DWORD = 0x60; +pub const SECPKG_ATTR_CC_POLICY_RESULT: DWORD = 0x61; +pub const SECPKG_ATTR_USE_NCRYPT: DWORD = 0x62; +pub const SECPKG_ATTR_LOCAL_CERT_INFO: DWORD = 0x63; +pub const SECPKG_ATTR_CIPHER_INFO: DWORD = 0x64; +pub const SECPKG_ATTR_EAP_PRF_INFO: DWORD = 0x65; +pub const SECPKG_ATTR_SUPPORTED_SIGNATURES: DWORD = 0x66; +pub const SECPKG_ATTR_REMOTE_CERT_CHAIN: DWORD = 0x67; +pub const SECPKG_ATTR_UI_INFO: DWORD = 0x68; +pub const SECPKG_ATTR_EARLY_START: DWORD = 0x69; +STRUCT!{struct SecPkgCred_SupportedAlgs { + cSupportedAlgs: DWORD, + palgSupportedAlgs: *mut ALG_ID, +}} +STRUCT!{struct SecPkgCred_CipherStrengths { + dwMinimumCipherStrength: DWORD, + dwMaximumCipherStrength: DWORD, +}} +STRUCT!{struct SecPkgCred_SupportedProtocols { + grbitProtocol: DWORD, +}} +STRUCT!{struct SecPkgCred_ClientCertPolicy { + dwFlags: DWORD, + guidPolicyId: GUID, + dwCertFlags: DWORD, + dwUrlRetrievalTimeout: DWORD, + fCheckRevocationFreshnessTime: BOOL, + dwRevocationFreshnessTime: DWORD, + fOmitUsageCheck: BOOL, + pwszSslCtlStoreName: LPWSTR, + pwszSslCtlIdentifier: LPWSTR, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/minwinbase.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/minwinbase.rs new file mode 100644 index 0000000..b414af1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/minwinbase.rs @@ -0,0 +1,337 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! This module defines the 32-Bit Windows Base APIs +use shared::basetsd::ULONG_PTR; +use shared::minwindef::{BOOL, BYTE, DWORD, FILETIME, HMODULE, LPVOID, MAX_PATH, UINT, ULONG, WORD}; +use shared::ntstatus::{ + STATUS_ACCESS_VIOLATION, STATUS_ARRAY_BOUNDS_EXCEEDED, STATUS_BREAKPOINT, + STATUS_CONTROL_C_EXIT, STATUS_DATATYPE_MISALIGNMENT, STATUS_FLOAT_DENORMAL_OPERAND, + STATUS_FLOAT_DIVIDE_BY_ZERO, STATUS_FLOAT_INEXACT_RESULT, STATUS_FLOAT_INVALID_OPERATION, + STATUS_FLOAT_OVERFLOW, STATUS_FLOAT_STACK_CHECK, STATUS_FLOAT_UNDERFLOW, + STATUS_GUARD_PAGE_VIOLATION, STATUS_ILLEGAL_INSTRUCTION, STATUS_INTEGER_DIVIDE_BY_ZERO, + STATUS_INTEGER_OVERFLOW, STATUS_INVALID_DISPOSITION, STATUS_INVALID_HANDLE, + STATUS_IN_PAGE_ERROR, STATUS_NONCONTINUABLE_EXCEPTION, STATUS_PENDING, + STATUS_POSSIBLE_DEADLOCK, STATUS_PRIVILEGED_INSTRUCTION, STATUS_SINGLE_STEP, + STATUS_STACK_OVERFLOW, +}; +use um::winnt::{ + CHAR, EXCEPTION_RECORD, HANDLE, LPSTR, LPWSTR, PCONTEXT, PRTL_CRITICAL_SECTION, + PRTL_CRITICAL_SECTION_DEBUG, PVOID, RTL_CRITICAL_SECTION, RTL_CRITICAL_SECTION_DEBUG, WCHAR, +}; +//MoveMemory +//CopyMemory +//FillMemory +//ZeroMemory +STRUCT!{struct SECURITY_ATTRIBUTES { + nLength: DWORD, + lpSecurityDescriptor: LPVOID, + bInheritHandle: BOOL, +}} +pub type PSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; +pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; +STRUCT!{struct OVERLAPPED_u_s { + Offset: DWORD, + OffsetHigh: DWORD, +}} +UNION!{union OVERLAPPED_u { + [u32; 2] [u64; 1], + s s_mut: OVERLAPPED_u_s, + Pointer Pointer_mut: PVOID, +}} +STRUCT!{struct OVERLAPPED { + Internal: ULONG_PTR, + InternalHigh: ULONG_PTR, + u: OVERLAPPED_u, + hEvent: HANDLE, +}} +pub type LPOVERLAPPED = *mut OVERLAPPED; +STRUCT!{struct OVERLAPPED_ENTRY { + lpCompletionKey: ULONG_PTR, + lpOverlapped: LPOVERLAPPED, + Internal: ULONG_PTR, + dwNumberOfBytesTransferred: DWORD, +}} +pub type LPOVERLAPPED_ENTRY = *mut OVERLAPPED_ENTRY; +STRUCT!{struct SYSTEMTIME { + wYear: WORD, + wMonth: WORD, + wDayOfWeek: WORD, + wDay: WORD, + wHour: WORD, + wMinute: WORD, + wSecond: WORD, + wMilliseconds: WORD, +}} +pub type PSYSTEMTIME = *mut SYSTEMTIME; +pub type LPSYSTEMTIME = *mut SYSTEMTIME; +STRUCT!{struct WIN32_FIND_DATAA { + dwFileAttributes: DWORD, + ftCreationTime: FILETIME, + ftLastAccessTime: FILETIME, + ftLastWriteTime: FILETIME, + nFileSizeHigh: DWORD, + nFileSizeLow: DWORD, + dwReserved0: DWORD, + dwReserved1: DWORD, + cFileName: [CHAR; MAX_PATH], + cAlternateFileName: [CHAR; 14], +}} +pub type PWIN32_FIND_DATAA = *mut WIN32_FIND_DATAA; +pub type LPWIN32_FIND_DATAA = *mut WIN32_FIND_DATAA; +STRUCT!{struct WIN32_FIND_DATAW { + dwFileAttributes: DWORD, + ftCreationTime: FILETIME, + ftLastAccessTime: FILETIME, + ftLastWriteTime: FILETIME, + nFileSizeHigh: DWORD, + nFileSizeLow: DWORD, + dwReserved0: DWORD, + dwReserved1: DWORD, + cFileName: [WCHAR; MAX_PATH], + cAlternateFileName: [WCHAR; 14], +}} +pub type PWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; +pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; +ENUM!{enum FINDEX_INFO_LEVELS { + FindExInfoStandard, + FindExInfoBasic, + FindExInfoMaxInfoLevel, +}} +pub const FIND_FIRST_EX_CASE_SENSITIVE: DWORD = 0x00000001; +pub const FIND_FIRST_EX_LARGE_FETCH: DWORD = 0x00000002; +ENUM!{enum FINDEX_SEARCH_OPS { + FindExSearchNameMatch, + FindExSearchLimitToDirectories, + FindExSearchLimitToDevices, + FindExSearchMaxSearchOp, +}} +ENUM!{enum GET_FILEEX_INFO_LEVELS { + GetFileExInfoStandard, + GetFileExMaxInfoLevel, +}} +ENUM!{enum FILE_INFO_BY_HANDLE_CLASS { + FileBasicInfo, + FileStandardInfo, + FileNameInfo, + FileRenameInfo, + FileDispositionInfo, + FileAllocationInfo, + FileEndOfFileInfo, + FileStreamInfo, + FileCompressionInfo, + FileAttributeTagInfo, + FileIdBothDirectoryInfo, + FileIdBothDirectoryRestartInfo, + FileIoPriorityHintInfo, + FileRemoteProtocolInfo, + FileFullDirectoryInfo, + FileFullDirectoryRestartInfo, + FileStorageInfo, + FileAlignmentInfo, + FileIdInfo, + FileIdExtdDirectoryInfo, + FileIdExtdDirectoryRestartInfo, + FileDispositionInfoEx, + FileRenameInfoEx, + MaximumFileInfoByHandleClass, +}} +pub type PFILE_INFO_BY_HANDLE_CLASS = *mut FILE_INFO_BY_HANDLE_CLASS; +pub type CRITICAL_SECTION = RTL_CRITICAL_SECTION; +pub type PCRITICAL_SECTION = PRTL_CRITICAL_SECTION; +pub type LPCRITICAL_SECTION = PRTL_CRITICAL_SECTION; +pub type CRITICAL_SECTION_DEBUG = RTL_CRITICAL_SECTION_DEBUG; +pub type PCRITICAL_SECTION_DEBUG = PRTL_CRITICAL_SECTION_DEBUG; +pub type LPCRITICAL_SECTION_DEBUG = PRTL_CRITICAL_SECTION_DEBUG; +FN!{stdcall LPOVERLAPPED_COMPLETION_ROUTINE( + dwErrorCode: DWORD, + dwNumberOfBytesTransfered: DWORD, + lpOverlapped: LPOVERLAPPED, +) -> ()} +pub const LOCKFILE_FAIL_IMMEDIATELY: DWORD = 0x00000001; +pub const LOCKFILE_EXCLUSIVE_LOCK: DWORD = 0x00000002; +STRUCT!{struct PROCESS_HEAP_ENTRY_Block { + hMem: HANDLE, + dwReserved: [DWORD; 3], +}} +STRUCT!{struct PROCESS_HEAP_ENTRY_Region { + dwCommittedSize: DWORD, + dwUnCommittedSize: DWORD, + lpFirstBlock: LPVOID, + lpLastBlock: LPVOID, +}} +UNION!{union PROCESS_HEAP_ENTRY_u { + [u32; 4] [u64; 3], + Block Block_mut: PROCESS_HEAP_ENTRY_Block, + Region Region_mut: PROCESS_HEAP_ENTRY_Region, +}} +STRUCT!{struct PROCESS_HEAP_ENTRY { + lpData: PVOID, + cbData: DWORD, + cbOverhead: BYTE, + iRegionIndex: BYTE, + wFlags: WORD, + u: PROCESS_HEAP_ENTRY_u, +}} +pub type LPPROCESS_HEAP_ENTRY = *mut PROCESS_HEAP_ENTRY; +pub type PPROCESS_HEAP_ENTRY = *mut PROCESS_HEAP_ENTRY; +pub const PROCESS_HEAP_REGION: WORD = 0x0001; +pub const PROCESS_HEAP_UNCOMMITTED_RANGE: WORD = 0x0002; +pub const PROCESS_HEAP_ENTRY_BUSY: WORD = 0x0004; +pub const PROCESS_HEAP_SEG_ALLOC: WORD = 0x0008; +pub const PROCESS_HEAP_ENTRY_MOVEABLE: WORD = 0x0010; +pub const PROCESS_HEAP_ENTRY_DDESHARE: WORD = 0x0020; +STRUCT!{struct REASON_CONTEXT_Detailed { + LocalizedReasonModule: HMODULE, + LocalizedReasonId: ULONG, + ReasonStringCount: ULONG, + ReasonStrings: *mut LPWSTR, +}} +UNION!{union REASON_CONTEXT_Reason { + [u32; 4] [u64; 3], + Detailed Detailed_mut: REASON_CONTEXT_Detailed, + SimpleReasonString SimpleReasonString_mut: LPWSTR, +}} +STRUCT!{struct REASON_CONTEXT { + Version: ULONG, + Flags: DWORD, + Reason: REASON_CONTEXT_Reason, +}} +pub type PREASON_CONTEXT = *mut REASON_CONTEXT; +pub const EXCEPTION_DEBUG_EVENT: DWORD = 1; +pub const CREATE_THREAD_DEBUG_EVENT: DWORD = 2; +pub const CREATE_PROCESS_DEBUG_EVENT: DWORD = 3; +pub const EXIT_THREAD_DEBUG_EVENT: DWORD = 4; +pub const EXIT_PROCESS_DEBUG_EVENT: DWORD = 5; +pub const LOAD_DLL_DEBUG_EVENT: DWORD = 6; +pub const UNLOAD_DLL_DEBUG_EVENT: DWORD = 7; +pub const OUTPUT_DEBUG_STRING_EVENT: DWORD = 8; +pub const RIP_EVENT: DWORD = 9; +FN!{stdcall PTHREAD_START_ROUTINE( + lpThreadParameter: LPVOID, +) -> DWORD} +pub type LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE; +FN!{stdcall PENCLAVE_ROUTINE( + lpThreadParameter: LPVOID, +) -> DWORD} +pub type LPENCLAVE_ROUTINE = PENCLAVE_ROUTINE; +STRUCT!{struct EXCEPTION_DEBUG_INFO { + ExceptionRecord: EXCEPTION_RECORD, + dwFirstChance: DWORD, +}} +pub type LPEXCEPTION_DEBUG_INFO = *mut EXCEPTION_DEBUG_INFO; +STRUCT!{struct CREATE_THREAD_DEBUG_INFO { + hThread: HANDLE, + lpThreadLocalBase: LPVOID, + lpStartAddress: LPTHREAD_START_ROUTINE, +}} +pub type LPCREATE_THREAD_DEBUG_INFO = *mut CREATE_THREAD_DEBUG_INFO; +STRUCT!{struct CREATE_PROCESS_DEBUG_INFO { + hFile: HANDLE, + hProcess: HANDLE, + hThread: HANDLE, + lpBaseOfImage: LPVOID, + dwDebugInfoFileOffset: DWORD, + nDebugInfoSize: DWORD, + lpThreadLocalBase: LPVOID, + lpStartAddress: LPTHREAD_START_ROUTINE, + lpImageName: LPVOID, + fUnicode: WORD, +}} +pub type LPCREATE_PROCESS_DEBUG_INFO = *mut CREATE_PROCESS_DEBUG_INFO; +STRUCT!{struct EXIT_THREAD_DEBUG_INFO { + dwExitCode: DWORD, +}} +pub type LPEXIT_THREAD_DEBUG_INFO = *mut EXIT_THREAD_DEBUG_INFO; +STRUCT!{struct EXIT_PROCESS_DEBUG_INFO { + dwExitCode: DWORD, +}} +pub type LPEXIT_PROCESS_DEBUG_INFO = *mut EXIT_PROCESS_DEBUG_INFO; +STRUCT!{struct LOAD_DLL_DEBUG_INFO { + hFile: HANDLE, + lpBaseOfDll: LPVOID, + dwDebugInfoFileOffset: DWORD, + nDebugInfoSize: DWORD, + lpImageName: LPVOID, + fUnicode: WORD, +}} +pub type LPLOAD_DLL_DEBUG_INFO = *mut LOAD_DLL_DEBUG_INFO; +STRUCT!{struct UNLOAD_DLL_DEBUG_INFO { + lpBaseOfDll: LPVOID, +}} +pub type LPUNLOAD_DLL_DEBUG_INFO = *mut UNLOAD_DLL_DEBUG_INFO; +STRUCT!{struct OUTPUT_DEBUG_STRING_INFO { + lpDebugStringData: LPSTR, + fUnicode: WORD, + nDebugStringLength: WORD, +}} +pub type LPOUTPUT_DEBUG_STRING_INFO = *mut OUTPUT_DEBUG_STRING_INFO; +STRUCT!{struct RIP_INFO { + dwError: DWORD, + dwType: DWORD, +}} +pub type LPRIP_INFO = *mut RIP_INFO; +UNION!{union DEBUG_EVENT_u { + [u32; 21] [u64; 20], + Exception Exception_mut: EXCEPTION_DEBUG_INFO, + CreateThread CreateThread_mut: CREATE_THREAD_DEBUG_INFO, + CreateProcessInfo CreateProcessInfo_mut: CREATE_PROCESS_DEBUG_INFO, + ExitThread ExitThread_mut: EXIT_THREAD_DEBUG_INFO, + ExitProcess ExitProcess_mut: EXIT_PROCESS_DEBUG_INFO, + LoadDll LoadDll_mut: LOAD_DLL_DEBUG_INFO, + UnloadDll UnloadDll_mut: UNLOAD_DLL_DEBUG_INFO, + DebugString DebugString_mut: OUTPUT_DEBUG_STRING_INFO, + RipInfo RipInfo_mut: RIP_INFO, +}} +STRUCT!{struct DEBUG_EVENT { + dwDebugEventCode: DWORD, + dwProcessId: DWORD, + dwThreadId: DWORD, + u: DEBUG_EVENT_u, +}} +pub type LPDEBUG_EVENT = *mut DEBUG_EVENT; +pub type LPCONTEXT = PCONTEXT; +pub const STILL_ACTIVE: DWORD = STATUS_PENDING as u32; +pub const EXCEPTION_ACCESS_VIOLATION: DWORD = STATUS_ACCESS_VIOLATION as u32; +pub const EXCEPTION_DATATYPE_MISALIGNMENT: DWORD = STATUS_DATATYPE_MISALIGNMENT as u32; +pub const EXCEPTION_BREAKPOINT: DWORD = STATUS_BREAKPOINT as u32; +pub const EXCEPTION_SINGLE_STEP: DWORD = STATUS_SINGLE_STEP as u32; +pub const EXCEPTION_ARRAY_BOUNDS_EXCEEDED: DWORD = STATUS_ARRAY_BOUNDS_EXCEEDED as u32; +pub const EXCEPTION_FLT_DENORMAL_OPERAND: DWORD = STATUS_FLOAT_DENORMAL_OPERAND as u32; +pub const EXCEPTION_FLT_DIVIDE_BY_ZERO: DWORD = STATUS_FLOAT_DIVIDE_BY_ZERO as u32; +pub const EXCEPTION_FLT_INEXACT_RESULT: DWORD = STATUS_FLOAT_INEXACT_RESULT as u32; +pub const EXCEPTION_FLT_INVALID_OPERATION: DWORD = STATUS_FLOAT_INVALID_OPERATION as u32; +pub const EXCEPTION_FLT_OVERFLOW: DWORD = STATUS_FLOAT_OVERFLOW as u32; +pub const EXCEPTION_FLT_STACK_CHECK: DWORD = STATUS_FLOAT_STACK_CHECK as u32; +pub const EXCEPTION_FLT_UNDERFLOW: DWORD = STATUS_FLOAT_UNDERFLOW as u32; +pub const EXCEPTION_INT_DIVIDE_BY_ZERO: DWORD = STATUS_INTEGER_DIVIDE_BY_ZERO as u32; +pub const EXCEPTION_INT_OVERFLOW: DWORD = STATUS_INTEGER_OVERFLOW as u32; +pub const EXCEPTION_PRIV_INSTRUCTION: DWORD = STATUS_PRIVILEGED_INSTRUCTION as u32; +pub const EXCEPTION_IN_PAGE_ERROR: DWORD = STATUS_IN_PAGE_ERROR as u32; +pub const EXCEPTION_ILLEGAL_INSTRUCTION: DWORD = STATUS_ILLEGAL_INSTRUCTION as u32; +pub const EXCEPTION_NONCONTINUABLE_EXCEPTION: DWORD = STATUS_NONCONTINUABLE_EXCEPTION as u32; +pub const EXCEPTION_STACK_OVERFLOW: DWORD = STATUS_STACK_OVERFLOW as u32; +pub const EXCEPTION_INVALID_DISPOSITION: DWORD = STATUS_INVALID_DISPOSITION as u32; +pub const EXCEPTION_GUARD_PAGE: DWORD = STATUS_GUARD_PAGE_VIOLATION as u32; +pub const EXCEPTION_INVALID_HANDLE: DWORD = STATUS_INVALID_HANDLE as u32; +pub const EXCEPTION_POSSIBLE_DEADLOCK: DWORD = STATUS_POSSIBLE_DEADLOCK as u32; +pub const CONTROL_C_EXIT: DWORD = STATUS_CONTROL_C_EXIT as u32; +pub const LMEM_FIXED: UINT = 0x0000; +pub const LMEM_MOVEABLE: UINT = 0x0002; +pub const LMEM_NOCOMPACT: UINT = 0x0010; +pub const LMEM_NODISCARD: UINT = 0x0020; +pub const LMEM_ZEROINIT: UINT = 0x0040; +pub const LMEM_MODIFY: UINT = 0x0080; +pub const LMEM_DISCARDABLE: UINT = 0x0F00; +pub const LMEM_VALID_FLAGS: UINT = 0x0F72; +pub const LMEM_INVALID_HANDLE: UINT = 0x8000; +pub const LHND: UINT = LMEM_MOVEABLE | LMEM_ZEROINIT; +pub const LPTR: UINT = LMEM_FIXED | LMEM_ZEROINIT; +pub const NONZEROLHND: UINT = LMEM_MOVEABLE; +pub const NONZEROLPTR: UINT = LMEM_FIXED; +//LocalDiscard +pub const LMEM_DISCARDED: UINT = 0x4000; +pub const LMEM_LOCKCOUNT: UINT = 0x00FF; +pub const NUMA_NO_PREFERRED_NODE: DWORD = -1i32 as u32; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/mmdeviceapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/mmdeviceapi.rs new file mode 100644 index 0000000..9ab810f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/mmdeviceapi.rs @@ -0,0 +1,220 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! this ALWAYS GENERATED file contains the definitions for the interfaces +use ctypes::c_void; +use shared::guiddef::{GUID, REFIID}; +use shared::minwindef::{DWORD, LPARAM, LPVOID, UINT}; +// use shared::winerror::{ERROR_NOT_FOUND, ERROR_UNSUPPORTED_TYPE, HRESULT_FROM_WIN32}; +use shared::wtypes::PROPERTYKEY; +use um::propidl::PROPVARIANT; +use um::propsys::IPropertyStore; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCWSTR, LPWSTR}; +// pub const E_NOTFOUND: HRESULT = HRESULT_FROM_WIN32(ERROR_NOT_FOUND); +// pub const E_UNSUPPORTED_TYPE: HRESULT = HRESULT_FROM_WIN32(ERROR_UNSUPPORTED_TYPE); +pub const DEVICE_STATE_ACTIVE: DWORD = 0x00000001; +pub const DEVICE_STATE_DISABLED: DWORD = 0x00000002; +pub const DEVICE_STATE_NOTPRESENT: DWORD = 0x00000004; +pub const DEVICE_STATE_UNPLUGGED: DWORD = 0x00000008; +pub const DEVICE_STATEMASK_ALL: DWORD = 0x0000000F; +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_FormFactor, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 0} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_ControlPanelPageProvider, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 1} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_Association, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 2} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_PhysicalSpeakers, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 3} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_GUID, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 4} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_Disable_SysFx, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 5} +pub const ENDPOINT_SYSFX_ENABLED: DWORD = 0x00000000; +pub const ENDPOINT_SYSFX_DISABLED: DWORD = 0x00000001; +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_FullRangeSpeakers, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 6} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_Supports_EventDriven_Mode, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 7} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_JackSubType, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 8} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_Default_VolumeInDb, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 9} +DEFINE_PROPERTYKEY!{PKEY_AudioEngine_DeviceFormat, + 0xf19f064d, 0x82c, 0x4e27, 0xbc, 0x73, 0x68, 0x82, 0xa1, 0xbb, 0x8e, 0x4c, 0} +DEFINE_PROPERTYKEY!{PKEY_AudioEngine_OEMFormat, + 0xe4870e26, 0x3cc5, 0x4cd2, 0xba, 0x46, 0xca, 0xa, 0x9a, 0x70, 0xed, 0x4, 3} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpointLogo_IconEffects, + 0xf1ab780d, 0x2010, 0x4ed3, 0xa3, 0xa6, 0x8b, 0x87, 0xf0, 0xf0, 0xc4, 0x76, 0} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpointLogo_IconPath, + 0xf1ab780d, 0x2010, 0x4ed3, 0xa3, 0xa6, 0x8b, 0x87, 0xf0, 0xf0, 0xc4, 0x76, 1} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpointSettings_MenuText, + 0x14242002, 0x0320, 0x4de4, 0x95, 0x55, 0xa7, 0xd8, 0x2b, 0x73, 0xc2, 0x86, 0} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpointSettings_LaunchContract, + 0x14242002, 0x0320, 0x4de4, 0x95, 0x55, 0xa7, 0xd8, 0x2b, 0x73, 0xc2, 0x86, 1} +STRUCT!{struct DIRECTX_AUDIO_ACTIVATION_PARAMS { + cbDirectXAudioActivationParams: DWORD, + guidAudioSession: GUID, + dwAudioStreamFlags: DWORD, +}} +pub type PDIRECTX_AUDIO_ACTIVATION_PARAMS = *mut DIRECTX_AUDIO_ACTIVATION_PARAMS; +ENUM!{enum EDataFlow { + eRender, + eCapture, + eAll, + EDataFlow_enum_count, +}} +ENUM!{enum ERole { + eConsole, + eMultimedia, + eCommunications, + ERole_enum_count, +}} +ENUM!{enum EndpointFormFactor { + RemoteNetworkDevice, + Speakers, + LineLevel, + Headphones, + Microphone, + Headset, + Handset, + UnknownDigitalPassthrough, + SPDIF, + DigitalAudioDisplayDevice, + UnknownFormFactor, + EndpointFormFactor_enum_count, +}} +pub const HDMI: EndpointFormFactor = DigitalAudioDisplayDevice; +DEFINE_GUID!{DEVINTERFACE_AUDIO_RENDER, + 0xe6327cad, 0xdcec, 0x4949, 0xae, 0x8a, 0x99, 0x1e, 0x97, 0x6a, 0x79, 0xd2} +DEFINE_GUID!{DEVINTERFACE_AUDIO_CAPTURE, + 0x2eef81be, 0x33fa, 0x4800, 0x96, 0x70, 0x1c, 0xd4, 0x74, 0x97, 0x2c, 0x3f} +DEFINE_GUID!{DEVINTERFACE_MIDI_OUTPUT, + 0x6dc23320, 0xab33, 0x4ce4, 0x80, 0xd4, 0xbb, 0xb3, 0xeb, 0xbf, 0x28, 0x14} +DEFINE_GUID!{DEVINTERFACE_MIDI_INPUT, + 0x504be32c, 0xccf6, 0x4d2c, 0xb7, 0x3f, 0x6f, 0x8b, 0x37, 0x47, 0xe2, 0x2b} +RIDL!{#[uuid(0x7991eec9, 0x7e89, 0x4d85, 0x83, 0x90, 0x6c, 0x70, 0x3c, 0xec, 0x60, 0xc0)] +interface IMMNotificationClient(IMMNotificationClientVtbl): IUnknown(IUnknownVtbl) { + fn OnDeviceStateChanged( + pwstrDeviceId: LPCWSTR, + dwNewState: DWORD, + ) -> HRESULT, + fn OnDeviceAdded( + pwstrDeviceId: LPCWSTR, + ) -> HRESULT, + fn OnDeviceRemoved( + pwstrDeviceId: LPCWSTR, + ) -> HRESULT, + fn OnDefaultDeviceChanged( + flow: EDataFlow, + role: ERole, + pwstrDefaultDeviceId: LPCWSTR, + ) -> HRESULT, + fn OnPropertyValueChanged( + pwstrDeviceId: LPCWSTR, + key: PROPERTYKEY, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd666063f, 0x1587, 0x4e43, 0x81, 0xf1, 0xb9, 0x48, 0xe8, 0x07, 0x36, 0x3f)] +interface IMMDevice(IMMDeviceVtbl): IUnknown(IUnknownVtbl) { + fn Activate( + iid: REFIID, + dwClsCtx: DWORD, + pActivationParams: *mut PROPVARIANT, + ppInterface: *mut LPVOID, + ) -> HRESULT, + fn OpenPropertyStore( + stgmAccess: DWORD, + ppProperties: *mut *mut IPropertyStore, + ) -> HRESULT, + fn GetId( + ppstrId: *mut LPWSTR, + ) -> HRESULT, + fn GetState( + pdwState: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0bd7a1be, 0x7a1a, 0x44db, 0x83, 0x97, 0xcc, 0x53, 0x92, 0x38, 0x7b, 0x5e)] +interface IMMDeviceCollection(IMMDeviceCollectionVtbl): IUnknown(IUnknownVtbl) { + fn GetCount( + pcDevices: *const UINT, + ) -> HRESULT, + fn Item( + nDevice: UINT, + ppDevice: *mut *mut IMMDevice, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1be09788, 0x6894, 0x4089, 0x85, 0x86, 0x9a, 0x2a, 0x6c, 0x26, 0x5a, 0xc5)] +interface IMMEndpoint(IMMEndpointVtbl): IUnknown(IUnknownVtbl) { + fn GetDataFlow( + pDataFlow: *mut EDataFlow, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa95664d2, 0x9614, 0x4f35, 0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6)] +interface IMMDeviceEnumerator(IMMDeviceEnumeratorVtbl): IUnknown(IUnknownVtbl) { + fn EnumAudioEndpoints( + dataFlow: EDataFlow, + dwStateMask: DWORD, + ppDevices: *mut *mut IMMDeviceCollection, + ) -> HRESULT, + fn GetDefaultAudioEndpoint( + dataFlow: EDataFlow, + role: ERole, + ppEndpoint: *mut *mut IMMDevice, + ) -> HRESULT, + fn GetDevice( + pwstrId: LPCWSTR, + ppDevices: *mut *mut IMMDevice, + ) -> HRESULT, + fn RegisterEndpointNotificationCallback( + pClient: *mut IMMNotificationClient, + ) -> HRESULT, + fn UnregisterEndpointNotificationCallback( + pClient: *mut IMMNotificationClient, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3b0d0ea4, 0xd0a9, 0x4b0e, 0x93, 0x5b, 0x09, 0x51, 0x67, 0x46, 0xfa, 0xc0)] +interface IMMDeviceActivator(IMMDeviceActivatorVtbl): IUnknown(IUnknownVtbl) { + fn Activate( + iid: REFIID, + pDevice: *mut IMMDevice, + pActivationParams: *mut PROPVARIANT, + ppInterface: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x41d949ab, 0x9862, 0x444a, 0x80, 0xf6, 0xc2, 0x61, 0x33, 0x4d, 0xa5, 0xeb)] +interface IActivateAudioInterfaceCompletionHandler(IActivateAudioInterfaceCompletionHandlerVtbl): + IUnknown(IUnknownVtbl) { + fn ActivateCompleted( + activateOperation: *mut IActivateAudioInterfaceAsyncOperation, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x72a22d78, 0xcde4, 0x431d, 0xb8, 0xcc, 0x84, 0x3a, 0x71, 0x19, 0x9b, 0x6d)] +interface IActivateAudioInterfaceAsyncOperation(IActivateAudioInterfaceAsyncOperationVtbl): + IUnknown(IUnknownVtbl) { + fn GetActivateResult( + activateResult: *mut HRESULT, + activatedInterface: *mut *mut IUnknown, + ) -> HRESULT, +}} +extern "system" { + pub fn ActivateAudioInterfaceAsync( + deviceInterfacePath: LPCWSTR, + riid: REFIID, + activationParams: *mut PROPVARIANT, + completionHandler: *mut IActivateAudioInterfaceCompletionHandler, + activationOperation: *mut *mut IActivateAudioInterfaceAsyncOperation, + ) -> HRESULT; +} +STRUCT!{struct AudioExtensionParams { + AddPageParam: LPARAM, + pEndpoint: *mut IMMDevice, + pPnpInterface: *mut IMMDevice, + pPnpDevnode: *mut IMMDevice, +}} +DEFINE_GUID!{CLSID_MMDeviceEnumerator, + 0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E} +RIDL!{#[uuid(0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E)] +class MMDeviceEnumerator;} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/mmeapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/mmeapi.rs new file mode 100644 index 0000000..cc5153b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/mmeapi.rs @@ -0,0 +1,336 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{DWORD_PTR, UINT_PTR}; +use shared::minwindef::{DWORD, LPBYTE, LPDWORD, LPWORD, PDWORD, UINT}; +use um::imm::LPUINT; +use um::mmsystem::{ + HMIDI, HMIDIIN, HMIDIOUT, HMIDISTRM, HWAVEIN, HWAVEOUT, LPCWAVEFORMATEX, LPHMIDIIN, LPHMIDIOUT, + LPHMIDISTRM, LPHWAVEIN, LPHWAVEOUT, LPMIDIHDR, LPMIDIINCAPSW, LPMIDIOUTCAPSW, LPMMTIME, + LPWAVEHDR, LPWAVEINCAPSW, LPWAVEOUTCAPSW, MMRESULT +}; +use um::winnt::{LPWSTR, PVOID}; +extern "system" { + pub fn waveOutGetNumDevs() -> UINT; + // pub fn waveOutGetDevCapsA(); + pub fn waveOutGetDevCapsW( + uDeviceID: UINT_PTR, + pwoc: LPWAVEOUTCAPSW, + cbwoc: UINT, + ) -> MMRESULT; + pub fn waveOutGetVolume( + hwo: HWAVEOUT, + pdwVolume: LPDWORD, + ) -> MMRESULT; + pub fn waveOutSetVolume( + hwo: HWAVEOUT, + dwVolume: DWORD, + ) -> MMRESULT; + // pub fn waveOutGetErrorTextA(); + pub fn waveOutGetErrorTextW( + mmrError: MMRESULT, + pszText: LPWSTR, + cchText: UINT, + ) -> MMRESULT; + pub fn waveOutOpen( + phwo: LPHWAVEOUT, + uDeviceID: UINT, + pwfx: LPCWAVEFORMATEX, + dwCallback: DWORD_PTR, + dwInstance: DWORD_PTR, + fdwOpen: DWORD, + ) -> MMRESULT; + pub fn waveOutClose( + hwo: HWAVEOUT, + ) -> MMRESULT; + pub fn waveOutPrepareHeader( + hwo: HWAVEOUT, + pwh: LPWAVEHDR, + cbwh: UINT, + ) -> MMRESULT; + pub fn waveOutUnprepareHeader( + hwo: HWAVEOUT, + pwh: LPWAVEHDR, + cbwh: UINT, + ) -> MMRESULT; + pub fn waveOutWrite( + hwo: HWAVEOUT, + pwh: LPWAVEHDR, + cbwh: UINT, + ) -> MMRESULT; + pub fn waveOutPause( + hwo: HWAVEOUT, + ) -> MMRESULT; + pub fn waveOutRestart( + hwo: HWAVEOUT, + ) -> MMRESULT; + pub fn waveOutReset( + hwo: HWAVEOUT, + ) -> MMRESULT; + pub fn waveOutBreakLoop( + hwo: HWAVEOUT, + ) -> MMRESULT; + pub fn waveOutGetPosition( + hwo: HWAVEOUT, + pmmt: LPMMTIME, + cbmmt: UINT, + ) -> MMRESULT; + pub fn waveOutGetPitch( + hwo: HWAVEOUT, + pdwPitch: LPDWORD, + ) -> MMRESULT; + pub fn waveOutSetPitch( + hwo: HWAVEOUT, + dwPitch: DWORD, + ) -> MMRESULT; + pub fn waveOutGetPlaybackRate( + hwo: HWAVEOUT, + pdwRate: LPDWORD, + ) -> MMRESULT; + pub fn waveOutSetPlaybackRate( + hwo: HWAVEOUT, + dwRate: DWORD, + ) -> MMRESULT; + // pub fn waveOutGetID(); + pub fn waveOutMessage( + hwo: HWAVEOUT, + uMsg: UINT, + dw1: DWORD_PTR, + dw2: DWORD_PTR, + ) -> MMRESULT; + pub fn waveInGetNumDevs() -> UINT; + // pub fn waveInGetDevCapsA(); + pub fn waveInGetDevCapsW( + uDeviceID: UINT_PTR, + pwic: LPWAVEINCAPSW, + cbwic: UINT, + ) -> MMRESULT; + // pub fn waveInGetErrorTextA(); + pub fn waveInGetErrorTextW( + mmrError: MMRESULT, + pszText: LPWSTR, + cchText: UINT, + ) -> MMRESULT; + pub fn waveInOpen( + phwi: LPHWAVEIN, + uDeviceID: UINT, + pwfx: LPCWAVEFORMATEX, + dwCallback: DWORD_PTR, + dwInstance: DWORD_PTR, + fdwOpen: DWORD, + ) -> MMRESULT; + pub fn waveInClose( + hwi: HWAVEIN, + ) -> MMRESULT; + pub fn waveInPrepareHeader( + hwi: HWAVEIN, + pwh: LPWAVEHDR, + cbwh: UINT, + ) -> MMRESULT; + pub fn waveInUnprepareHeader( + hwi: HWAVEIN, + pwh: LPWAVEHDR, + cbwh: UINT, + ) -> MMRESULT; + pub fn waveInAddBuffer( + hwi: HWAVEIN, + pwh: LPWAVEHDR, + cbwh: UINT, + ) -> MMRESULT; + pub fn waveInStart( + hwi: HWAVEIN, + ) -> MMRESULT; + pub fn waveInStop( + hwi: HWAVEIN, + ) -> MMRESULT; + pub fn waveInReset( + hwi: HWAVEIN, + ) -> MMRESULT; + pub fn waveInGetPosition( + hwi: HWAVEIN, + pmmt: LPMMTIME, + cbmmt: UINT, + ) -> MMRESULT; + // pub fn waveInGetID(); + pub fn waveInMessage( + hwi: HWAVEIN, + uMsg: UINT, + dw1: DWORD_PTR, + dw2: DWORD_PTR, + ) -> MMRESULT; + pub fn midiOutGetNumDevs() -> UINT; + pub fn midiStreamOpen( + lphStream: LPHMIDISTRM, + puDeviceID: LPUINT, + cMidi: DWORD, + dwCallback: DWORD_PTR, + dwInstance: DWORD_PTR, + fdwOpen: DWORD, + ) -> MMRESULT; + pub fn midiStreamClose( + hStream: HMIDISTRM, + ) -> MMRESULT; + pub fn midiStreamProperty( + hm: HMIDISTRM, + lppropdata: LPBYTE, + dwProperty: DWORD, + ) -> MMRESULT; + pub fn midiStreamPosition( + hms: HMIDISTRM, + pmmt: LPMMTIME, + cbmmt: UINT, + ) -> MMRESULT; + pub fn midiStreamOut( + hMidiStream: HMIDISTRM, + lpMidiHdr: LPMIDIHDR, + cbMidiHdr: UINT, + ) -> MMRESULT; + pub fn midiStreamPause( + hms: HMIDISTRM, + ) -> MMRESULT; + pub fn midiStreamRestart( + hms: HMIDISTRM, + ) -> MMRESULT; + pub fn midiStreamStop( + hms: HMIDISTRM, + ) -> MMRESULT; + pub fn midiConnect( + hMidi: HMIDI, + hmo: HMIDIOUT, + pReserved: PVOID, + ) -> MMRESULT; + pub fn midiDisconnect( + hMidi: HMIDI, + hmo: HMIDIOUT, + pReserved: PVOID, + ) -> MMRESULT; + pub fn midiOutGetDevCapsW( + uDeviceID: UINT_PTR, + lpMidiOutCaps: LPMIDIOUTCAPSW, + cbMidiOutCaps: UINT, + ) -> MMRESULT; + pub fn midiOutGetVolume( + hmo: HMIDIOUT, + lpdwVolume: PDWORD, + ) -> MMRESULT; + pub fn midiOutSetVolume( + hmo: HMIDIOUT, + dwVolume: DWORD, + ) -> MMRESULT; + pub fn midiOutGetErrorTextW( + mmrError: MMRESULT, + lpText: LPWSTR, + cchText: UINT, + ) -> MMRESULT; + pub fn midiOutOpen( + lphmo: LPHMIDIOUT, + uDeviceID: UINT, + dwCallback: DWORD_PTR, + dwCallbackInstance: DWORD_PTR, + dwFlags: DWORD, + ) -> MMRESULT; + pub fn midiOutClose( + hmo: HMIDIOUT, + ) -> MMRESULT; + pub fn midiOutPrepareHeader( + hmo: HMIDIOUT, + lpMidiOutHdr: LPMIDIHDR, + cbMidiOutHdr: UINT, + ) -> MMRESULT; + pub fn midiOutUnprepareHeader( + hmo: HMIDIOUT, + lpMidiOutHdr: LPMIDIHDR, + cbMidiOutHdr: UINT, + ) -> MMRESULT; + pub fn midiOutShortMsg( + hmo: HMIDIOUT, + dwMsg: DWORD, + ) -> MMRESULT; + pub fn midiOutLongMsg( + hmo: HMIDIOUT, + lpMidiOutHdr: LPMIDIHDR, + cbMidiOutHdr: UINT, + ) -> MMRESULT; + pub fn midiOutReset( + hmo: HMIDIOUT, + ) -> MMRESULT; + pub fn midiOutCachePatches( + hmo: HMIDIOUT, + wBank: UINT, + lpPatchArray: LPWORD, + wFlags: UINT, + ) -> MMRESULT; + pub fn midiOutCacheDrumPatches( + hmo: HMIDIOUT, + wPatch: UINT, + lpKeyArray: LPWORD, + wFlags: UINT, + ) -> MMRESULT; + pub fn midiOutGetID( + hmo: HMIDIOUT, + puDeviceID: LPUINT, + ) -> MMRESULT; + pub fn midiOutMessage( + deviceID: HMIDIOUT, + msg: UINT, + dw1: DWORD_PTR, + dw2: DWORD_PTR, + ) -> MMRESULT; + pub fn midiInGetNumDevs() -> UINT; + pub fn midiInGetDevCapsW( + uDeviceID: UINT_PTR, + lpMidiInCaps: LPMIDIINCAPSW, + cbMidiInCaps: UINT, + ) -> MMRESULT; + pub fn midiInGetErrorTextW( + wError: MMRESULT, + lpText: LPWSTR, + cchText: UINT, + ) -> MMRESULT; + pub fn midiInOpen( + lphMidiIn: LPHMIDIIN, + uDeviceID: UINT, + dwCallback: DWORD_PTR, + dwCallbackInstance: DWORD_PTR, + dwFlags: DWORD, + ) -> MMRESULT; + pub fn midiInClose( + hMidiIn: HMIDIIN, + ) -> MMRESULT; + pub fn midiInPrepareHeader( + hMidiIn: HMIDIIN, + lpMidiInHdr: LPMIDIHDR, + cbMidiInHdr: UINT, + ) -> MMRESULT; + pub fn midiInUnprepareHeader( + hMidiIn: HMIDIIN, + lpMidiInHdr: LPMIDIHDR, + cbMidiInHdr: UINT, + ) -> MMRESULT; + pub fn midiInAddBuffer( + hMidiIn: HMIDIIN, + lpMidiInHdr: LPMIDIHDR, + cbMidiInHdr: UINT, + ) -> MMRESULT; + pub fn midiInStart( + hMidiIn: HMIDIIN, + ) -> MMRESULT; + pub fn midiInStop( + hMidiIn: HMIDIIN, + ) -> MMRESULT; + pub fn midiInReset( + hMidiIn: HMIDIIN, + ) -> MMRESULT; + pub fn midiInGetID( + hmi: HMIDIIN, + puDeviceID: LPUINT, + ) -> MMRESULT; + pub fn midiInMessage( + deviceID: HMIDIIN, + msg: UINT, + dw1: DWORD_PTR, + dw2: DWORD_PTR, + ) -> MMRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/mmsystem.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/mmsystem.rs new file mode 100644 index 0000000..657ba5f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/mmsystem.rs @@ -0,0 +1,266 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! MM procedure declarations, constant definitions and macros +use shared::basetsd::DWORD_PTR; +use shared::minwindef::{BYTE, DWORD, UINT, WORD}; +use shared::mmreg::WAVEFORMATEX; +use um::winnt::{LPSTR, WCHAR}; +//109 (Win 7 SDK) +pub type MMVERSION = UINT; +pub type MMRESULT = UINT; +STRUCT!{#[repr(packed)] struct MMTIME_smpte { + hour: BYTE, + min: BYTE, + sec: BYTE, + frame: BYTE, + fps: BYTE, + dummy: BYTE, + pad: [BYTE; 2], +}} +STRUCT!{#[repr(packed)] struct MMTIME_midi { + songptrpos: DWORD, +}} +UNION!{#[repr(packed)] union MMTIME_u { + [u32; 2], + ms ms_mut: DWORD, + sample sample_mut: DWORD, + cb cb_mut: DWORD, + ticks ticks_mut: DWORD, + smpte smpte_mut: MMTIME_smpte, + midi midi_mut: MMTIME_midi, +}} +STRUCT!{#[repr(packed)] struct MMTIME { + wType: UINT, + u: MMTIME_u, +}} +pub type PMMTIME = *mut MMTIME; +pub type NPMMTIME = *mut MMTIME; +pub type LPMMTIME = *mut MMTIME; +pub const TIME_MS: UINT = 0x0001; +pub const TIME_SAMPLES: UINT = 0x0002; +pub const TIME_BYTES: UINT = 0x0004; +pub const TIME_SMPTE: UINT = 0x0008; +pub const TIME_MIDI: UINT = 0x0010; +pub const TIME_TICKS: UINT = 0x0020; +pub const MM_JOY1MOVE: UINT = 0x3A0; +pub const MM_JOY2MOVE: UINT = 0x3A1; +pub const MM_JOY1ZMOVE: UINT = 0x3A2; +pub const MM_JOY2ZMOVE: UINT = 0x3A3; +pub const MM_JOY1BUTTONDOWN: UINT = 0x3B5; +pub const MM_JOY2BUTTONDOWN: UINT = 0x3B6; +pub const MM_JOY1BUTTONUP: UINT = 0x3B7; +pub const MM_JOY2BUTTONUP: UINT = 0x3B8; +pub const MM_MCINOTIFY: UINT = 0x3B9; +pub const MM_WOM_OPEN: UINT = 0x3BB; +pub const MM_WOM_CLOSE: UINT = 0x3BC; +pub const MM_WOM_DONE: UINT = 0x3BD; +pub const MM_WIM_OPEN: UINT = 0x3BE; +pub const MM_WIM_CLOSE: UINT = 0x3BF; +pub const MM_WIM_DATA: UINT = 0x3C0; +pub const MM_MIM_OPEN: UINT = 0x3C1; +pub const MM_MIM_CLOSE: UINT = 0x3C2; +pub const MM_MIM_DATA: UINT = 0x3C3; +pub const MM_MIM_LONGDATA: UINT = 0x3C4; +pub const MM_MIM_ERROR: UINT = 0x3C5; +pub const MM_MIM_LONGERROR: UINT = 0x3C6; +pub const MM_MOM_OPEN: UINT = 0x3C7; +pub const MM_MOM_CLOSE: UINT = 0x3C8; +pub const MM_MOM_DONE: UINT = 0x3C9; +pub const MMSYSERR_BASE: MMRESULT = 0; +pub const WAVERR_BASE: MMRESULT = 32; +pub const MIDIERR_BASE: MMRESULT = 64; +pub const TIMERR_BASE: MMRESULT = 96; +pub const JOYERR_BASE: MMRESULT = 160; +pub const MCIERR_BASE: MMRESULT = 256; +pub const MIXERR_BASE: MMRESULT = 1024; +pub const MMSYSERR_NOERROR: MMRESULT = 0; +pub const MMSYSERR_ERROR: MMRESULT = MMSYSERR_BASE + 1; +pub const MMSYSERR_BADDEVICEID: MMRESULT = MMSYSERR_BASE + 2; +pub const MMSYSERR_NOTENABLED: MMRESULT = MMSYSERR_BASE + 3; +pub const MMSYSERR_ALLOCATED: MMRESULT = MMSYSERR_BASE + 4; +pub const MMSYSERR_INVALHANDLE: MMRESULT = MMSYSERR_BASE + 5; +pub const MMSYSERR_NODRIVER: MMRESULT = MMSYSERR_BASE + 6; +pub const MMSYSERR_NOMEM: MMRESULT = MMSYSERR_BASE + 7; +pub const MMSYSERR_NOTSUPPORTED: MMRESULT = MMSYSERR_BASE + 8; +pub const MMSYSERR_BADERRNUM: MMRESULT = MMSYSERR_BASE + 9; +pub const MMSYSERR_INVALFLAG: MMRESULT = MMSYSERR_BASE + 10; +pub const MMSYSERR_INVALPARAM: MMRESULT = MMSYSERR_BASE + 11; +pub const MMSYSERR_HANDLEBUSY: MMRESULT = MMSYSERR_BASE + 12; +pub const MMSYSERR_INVALIDALIAS: MMRESULT = MMSYSERR_BASE + 13; +pub const MMSYSERR_BADDB: MMRESULT = MMSYSERR_BASE + 14; +pub const MMSYSERR_KEYNOTFOUND: MMRESULT = MMSYSERR_BASE + 15; +pub const MMSYSERR_READERROR: MMRESULT = MMSYSERR_BASE + 16; +pub const MMSYSERR_WRITEERROR: MMRESULT = MMSYSERR_BASE + 17; +pub const MMSYSERR_DELETEERROR: MMRESULT = MMSYSERR_BASE + 18; +pub const MMSYSERR_VALNOTFOUND: MMRESULT = MMSYSERR_BASE + 19; +pub const MMSYSERR_NODRIVERCB: MMRESULT = MMSYSERR_BASE + 20; +pub const MMSYSERR_MOREDATA: MMRESULT = MMSYSERR_BASE + 21; +pub const MMSYSERR_LASTERROR: MMRESULT = MMSYSERR_BASE + 21; +pub const MIDIERR_UNPREPARED: MMRESULT = MIDIERR_BASE + 0; +pub const MIDIERR_STILLPLAYING: MMRESULT = MIDIERR_BASE + 1; +pub const MIDIERR_NOMAP: MMRESULT = MIDIERR_BASE + 2; +pub const MIDIERR_NOTREADY: MMRESULT = MIDIERR_BASE + 3; +pub const MIDIERR_NODEVICE: MMRESULT = MIDIERR_BASE + 4; +pub const MIDIERR_INVALIDSETUP: MMRESULT = MIDIERR_BASE + 5; +pub const MIDIERR_BADOPENMODE: MMRESULT = MIDIERR_BASE + 6; +pub const MIDIERR_DONT_CONTINUE: MMRESULT = MIDIERR_BASE + 7; +pub const MIDIERR_LASTERROR: MMRESULT = MIDIERR_BASE + 7; +pub const CALLBACK_TYPEMASK: DWORD = 0x00070000; +pub const CALLBACK_NULL: DWORD = 0x00000000; +pub const CALLBACK_WINDOW: DWORD = 0x00010000; +pub const CALLBACK_TASK: DWORD = 0x00020000; +pub const CALLBACK_FUNCTION: DWORD = 0x00030000; +pub const CALLBACK_THREAD: DWORD = CALLBACK_TASK; +pub const CALLBACK_EVENT: DWORD = 0x00050000; +//497 (Win 7 SDK) +pub const WAVERR_BADFORMAT: MMRESULT = WAVERR_BASE + 0; +pub const WAVERR_STILLPLAYING: MMRESULT = WAVERR_BASE + 1; +pub const WAVERR_UNPREPARED: MMRESULT = WAVERR_BASE + 2; +pub const WAVERR_SYNC: MMRESULT = WAVERR_BASE + 3; +pub const WAVERR_LASTERROR: MMRESULT = WAVERR_BASE + 3; +DECLARE_HANDLE!{HWAVEIN, HWAVEIN__} +DECLARE_HANDLE!{HWAVEOUT, HWAVEOUT__} +pub type LPHWAVEIN = *mut HWAVEIN; +pub type LPHWAVEOUT = *mut HWAVEOUT; +pub const WOM_OPEN: UINT = MM_WOM_OPEN; +pub const WOM_CLOSE: UINT = MM_WOM_CLOSE; +pub const WOM_DONE: UINT = MM_WOM_DONE; +pub const WIM_OPEN: UINT = MM_WIM_OPEN; +pub const WIM_CLOSE: UINT = MM_WIM_CLOSE; +pub const WIM_DATA: UINT = MM_WIM_DATA; +pub const WAVE_MAPPER: UINT = 0xFFFFFFFF; +pub const WAVE_FORMAT_QUERY: DWORD = 0x0001; +pub const WAVE_ALLOWSYNC: DWORD = 0x0002; +pub const WAVE_MAPPED: DWORD = 0x0004; +pub const WAVE_FORMAT_DIRECT: DWORD = 0x0008; +pub const WAVE_FORMAT_DIRECT_QUERY: DWORD = WAVE_FORMAT_QUERY | WAVE_FORMAT_DIRECT; +pub const WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE: DWORD = 0x0010; +STRUCT!{#[repr(packed)] struct WAVEHDR { + lpData: LPSTR, + dwBufferLength: DWORD, + dwBytesRecorded: DWORD, + dwUser: DWORD_PTR, + dwFlags: DWORD, + dwLoops: DWORD, + lpNext: *mut WAVEHDR, + reserved: DWORD_PTR, +}} +pub type PWAVEHDR = *mut WAVEHDR; +pub type NPWAVEHDR = *mut WAVEHDR; +pub type LPWAVEHDR = *mut WAVEHDR; +STRUCT!{#[repr(packed)] struct WAVEOUTCAPSW { + wMid: WORD, + wPid: WORD, + vDriverVersion: MMVERSION, + szPname: [WCHAR; 32], + dwFormats: DWORD, + wChannels: WORD, + wReserved1: WORD, + dwSupport: DWORD, +}} +pub type PWAVEOUTCAPSW = *mut WAVEOUTCAPSW; +pub type NPWAVEOUTCAPSW = *mut WAVEOUTCAPSW; +pub type LPWAVEOUTCAPSW = *mut WAVEOUTCAPSW; +STRUCT!{#[repr(packed)] struct WAVEINCAPSW { + wMid: WORD, + wPid: WORD, + vDriverVersion: MMVERSION, + szPname: [WCHAR; 32], + dwFormats: DWORD, + wChannels: WORD, + wReserved1: WORD, +}} +pub type PWAVEINCAPSW = *mut WAVEINCAPSW; +pub type NPWAVEINCAPSW = *mut WAVEINCAPSW; +pub type LPWAVEINCAPSW = *mut WAVEINCAPSW; +pub const WAVE_INVALIDFORMAT: DWORD = 0x00000000; +pub const WAVE_FORMAT_1M08: DWORD = 0x00000001; +pub const WAVE_FORMAT_1S08: DWORD = 0x00000002; +pub const WAVE_FORMAT_1M16: DWORD = 0x00000004; +pub const WAVE_FORMAT_1S16: DWORD = 0x00000008; +pub const WAVE_FORMAT_2M08: DWORD = 0x00000010; +pub const WAVE_FORMAT_2S08: DWORD = 0x00000020; +pub const WAVE_FORMAT_2M16: DWORD = 0x00000040; +pub const WAVE_FORMAT_2S16: DWORD = 0x00000080; +pub const WAVE_FORMAT_4M08: DWORD = 0x00000100; +pub const WAVE_FORMAT_4S08: DWORD = 0x00000200; +pub const WAVE_FORMAT_4M16: DWORD = 0x00000400; +pub const WAVE_FORMAT_4S16: DWORD = 0x00000800; +pub const WAVE_FORMAT_44M08: DWORD = 0x00000100; +pub const WAVE_FORMAT_44S08: DWORD = 0x00000200; +pub const WAVE_FORMAT_44M16: DWORD = 0x00000400; +pub const WAVE_FORMAT_44S16: DWORD = 0x00000800; +pub const WAVE_FORMAT_48M08: DWORD = 0x00001000; +pub const WAVE_FORMAT_48S08: DWORD = 0x00002000; +pub const WAVE_FORMAT_48M16: DWORD = 0x00004000; +pub const WAVE_FORMAT_48S16: DWORD = 0x00008000; +pub const WAVE_FORMAT_96M08: DWORD = 0x00010000; +pub const WAVE_FORMAT_96S08: DWORD = 0x00020000; +pub const WAVE_FORMAT_96M16: DWORD = 0x00040000; +pub const WAVE_FORMAT_96S16: DWORD = 0x00080000; +//782 (Win 7 SDK) +pub type PWAVEFORMATEX = *mut WAVEFORMATEX; +pub type NPWAVEFORMATEX = *mut WAVEFORMATEX; +pub type LPWAVEFORMATEX = *mut WAVEFORMATEX; +pub type LPCWAVEFORMATEX = *const WAVEFORMATEX; +//2170 (Win 7 SDK) +pub const TIMERR_NOERROR: MMRESULT = 0; +pub const TIMERR_NOCANDO: MMRESULT = TIMERR_BASE + 1; +pub const TIMERR_STRUCT: MMRESULT = TIMERR_BASE + 33; +//2198 (Win 7 SDK) +STRUCT!{#[repr(packed)] struct TIMECAPS { + wPeriodMin: UINT, + wPeriodMax: UINT, +}} +pub type PTIMECAPS = *mut TIMECAPS; +pub type NPTIMECAPS = *mut TIMECAPS; +pub type LPTIMECAPS = *mut TIMECAPS; +STRUCT!{#[repr(packed)] struct MIDIHDR { + lpData: LPSTR, + dwBufferLength: DWORD, + dwBytesRecorded: DWORD, + dwUser: DWORD_PTR, + dwFlags: DWORD, + lpNext: *mut MIDIHDR, + reserved: DWORD_PTR, + dwOffset: DWORD, + dwReserved: [DWORD_PTR; 8], +}} +pub type PMIDIHDR = *mut MIDIHDR; +pub type NPMIDIHDR = *mut MIDIHDR; +pub type LPMIDIHDR = *mut MIDIHDR; +STRUCT!{#[repr(packed)] struct MIDIINCAPSW { + wMid: WORD, + wPid: WORD, + vDriverVersion: MMVERSION, + szPname: [WCHAR; 32], + dwSupport: DWORD, +}} +pub type PMIDIINCAPSW = *mut MIDIINCAPSW; +pub type NPMIDIINCAPSW = *mut MIDIINCAPSW; +pub type LPMIDIINCAPSW = *mut MIDIINCAPSW; +STRUCT!{#[repr(packed)] struct MIDIOUTCAPSW { + wMid: WORD, + wPid: WORD, + vDriverVersion: MMVERSION, + szPname: [WCHAR; 32], + wTechnology: WORD, + wVoices: WORD, + wNotes: WORD, + wChannelMask: WORD, + dwSupport: DWORD, +}} +pub type PMIDIOUTCAPSW = *mut MIDIOUTCAPSW; +pub type NPMIDIOUTCAPSW = *mut MIDIOUTCAPSW; +pub type LPMIDIOUTCAPSW = *mut MIDIOUTCAPSW; +DECLARE_HANDLE!{HMIDIIN, HMIDIIN__} +DECLARE_HANDLE!{HMIDIOUT, HMIDIOUT__} +pub type LPHMIDIIN = *mut HMIDIIN; +pub type LPHMIDIOUT = *mut HMIDIOUT; +DECLARE_HANDLE!{HMIDISTRM, HMIDISTRM__} +DECLARE_HANDLE!{HMIDI, HMIDI__} +pub type LPHMIDISTRM = *mut HMIDISTRM; +pub type LPHMIDI = *mut HMIDI; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/mod.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/mod.rs new file mode 100644 index 0000000..23b5019 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/mod.rs @@ -0,0 +1,287 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Headers for user mode only +pub mod gl; +#[cfg(feature = "accctrl")] pub mod accctrl; +#[cfg(feature = "aclapi")] pub mod aclapi; +#[cfg(feature = "appmgmt")] pub mod appmgmt; +#[cfg(feature = "audioclient")] pub mod audioclient; +#[cfg(feature = "audiosessiontypes")] pub mod audiosessiontypes; +#[cfg(feature = "avrt")] pub mod avrt; +#[cfg(feature = "bits")] pub mod bits; +#[cfg(feature = "bits10_1")] pub mod bits10_1; +#[cfg(feature = "bits1_5")] pub mod bits1_5; +#[cfg(feature = "bits2_0")] pub mod bits2_0; +#[cfg(feature = "bits2_5")] pub mod bits2_5; +#[cfg(feature = "bits3_0")] pub mod bits3_0; +#[cfg(feature = "bits4_0")] pub mod bits4_0; +#[cfg(feature = "bits5_0")] pub mod bits5_0; +#[cfg(feature = "bitscfg")] pub mod bitscfg; +#[cfg(feature = "bitsmsg")] pub mod bitsmsg; +#[cfg(feature = "bluetoothapis")] pub mod bluetoothapis; +#[cfg(feature = "bluetoothleapis")] pub mod bluetoothleapis; +#[cfg(feature = "bthledef")] pub mod bthledef; +#[cfg(feature = "cfgmgr32")] pub mod cfgmgr32; +#[cfg(feature = "cguid")] pub mod cguid; +#[cfg(feature = "combaseapi")] pub mod combaseapi; +#[cfg(feature = "coml2api")] pub mod coml2api; +#[cfg(feature = "commapi")] pub mod commapi; +#[cfg(feature = "commctrl")] pub mod commctrl; +#[cfg(feature = "commdlg")] pub mod commdlg; +#[cfg(feature = "commoncontrols")] pub mod commoncontrols; +#[cfg(feature = "consoleapi")] pub mod consoleapi; +#[cfg(feature = "corsym")] pub mod corsym; +#[cfg(feature = "d2d1")] pub mod d2d1; +#[cfg(feature = "d2d1_1")] pub mod d2d1_1; +#[cfg(feature = "d2d1_2")] pub mod d2d1_2; +#[cfg(feature = "d2d1_3")] pub mod d2d1_3; +#[cfg(feature = "d2d1effectauthor")] pub mod d2d1effectauthor; +#[cfg(feature = "d2d1effects")] pub mod d2d1effects; +#[cfg(feature = "d2d1effects_1")] pub mod d2d1effects_1; +#[cfg(feature = "d2d1effects_2")] pub mod d2d1effects_2; +#[cfg(feature = "d2d1svg")] pub mod d2d1svg; +#[cfg(feature = "d2dbasetypes")] pub mod d2dbasetypes; +#[cfg(feature = "d3d")] pub mod d3d; +#[cfg(feature = "d3d10")] pub mod d3d10; +#[cfg(feature = "d3d10_1")] pub mod d3d10_1; +#[cfg(feature = "d3d10_1shader")] pub mod d3d10_1shader; +#[cfg(feature = "d3d10effect")] pub mod d3d10effect; +#[cfg(feature = "d3d10misc")] pub mod d3d10misc; +#[cfg(feature = "d3d10sdklayers")] pub mod d3d10sdklayers; +#[cfg(feature = "d3d10shader")] pub mod d3d10shader; +#[cfg(feature = "d3d11")] pub mod d3d11; +#[cfg(feature = "d3d11_1")] pub mod d3d11_1; +#[cfg(feature = "d3d11_2")] pub mod d3d11_2; +#[cfg(feature = "d3d11_3")] pub mod d3d11_3; +#[cfg(feature = "d3d11_4")] pub mod d3d11_4; +#[cfg(feature = "d3d11on12")] pub mod d3d11on12; +#[cfg(feature = "d3d11sdklayers")] pub mod d3d11sdklayers; +#[cfg(feature = "d3d11shader")] pub mod d3d11shader; +#[cfg(feature = "d3d11tokenizedprogramformat")] pub mod d3d11tokenizedprogramformat; +#[cfg(feature = "d3d12")] pub mod d3d12; +#[cfg(feature = "d3d12sdklayers")] pub mod d3d12sdklayers; +#[cfg(feature = "d3d12shader")] pub mod d3d12shader; +#[cfg(feature = "d3dcommon")] pub mod d3dcommon; +#[cfg(feature = "d3dcompiler")] pub mod d3dcompiler; +#[cfg(feature = "d3dcsx")] pub mod d3dcsx; +#[cfg(feature = "d3dx10core")] pub mod d3dx10core; +#[cfg(feature = "d3dx10math")] pub mod d3dx10math; +#[cfg(feature = "d3dx10mesh")] pub mod d3dx10mesh; +#[cfg(feature = "datetimeapi")] pub mod datetimeapi; +#[cfg(feature = "davclnt")] pub mod davclnt; +#[cfg(feature = "dbghelp")] pub mod dbghelp; +#[cfg(feature = "dbt")] pub mod dbt; +#[cfg(feature = "dcommon")] pub mod dcommon; +#[cfg(feature = "dcomp")] pub mod dcomp; +#[cfg(feature = "dcompanimation")] pub mod dcompanimation; +#[cfg(feature = "dde")] pub mod dde; +#[cfg(feature = "ddraw")] pub mod ddraw; +#[cfg(feature = "ddrawi")] pub mod ddrawi; +#[cfg(feature = "ddrawint")] pub mod ddrawint; +#[cfg(feature = "debugapi")] pub mod debugapi; +#[cfg(feature = "devicetopology")] pub mod devicetopology; +#[cfg(feature = "dinput")] pub mod dinput; +#[cfg(feature = "dispex")] pub mod dispex; +#[cfg(feature = "dmksctl")] pub mod dmksctl; +#[cfg(feature = "dmusicc")] pub mod dmusicc; +#[cfg(feature = "docobj")] pub mod docobj; +#[cfg(feature = "documenttarget")] pub mod documenttarget; +#[cfg(feature = "dpa_dsa")] pub mod dpa_dsa; +#[cfg(feature = "dpapi")] pub mod dpapi; +#[cfg(feature = "dsgetdc")] pub mod dsgetdc; +#[cfg(feature = "dsound")] pub mod dsound; +#[cfg(feature = "dsrole")] pub mod dsrole; +#[cfg(feature = "dvp")] pub mod dvp; +#[cfg(feature = "dwmapi")] pub mod dwmapi; +#[cfg(feature = "dwrite")] pub mod dwrite; +#[cfg(feature = "dwrite_1")] pub mod dwrite_1; +#[cfg(feature = "dwrite_2")] pub mod dwrite_2; +#[cfg(feature = "dwrite_3")] pub mod dwrite_3; +#[cfg(feature = "dxdiag")] pub mod dxdiag; +#[cfg(feature = "dxfile")] pub mod dxfile; +#[cfg(feature = "dxgidebug")] pub mod dxgidebug; +#[cfg(feature = "dxva2api")] pub mod dxva2api; +#[cfg(feature = "dxvahd")] pub mod dxvahd; +#[cfg(feature = "enclaveapi")] pub mod enclaveapi; +#[cfg(feature = "endpointvolume")] pub mod endpointvolume; +#[cfg(feature = "errhandlingapi")] pub mod errhandlingapi; +#[cfg(feature = "evntcons")] pub mod evntcons; +#[cfg(feature = "exdisp")] pub mod exdisp; +#[cfg(feature = "fibersapi")] pub mod fibersapi; +#[cfg(feature = "fileapi")] pub mod fileapi; +#[cfg(feature = "functiondiscoverykeys_devpkey")] pub mod functiondiscoverykeys_devpkey; +#[cfg(feature = "handleapi")] pub mod handleapi; +#[cfg(feature = "heapapi")] pub mod heapapi; +#[cfg(feature = "highlevelmonitorconfigurationapi")] pub mod highlevelmonitorconfigurationapi; +#[cfg(feature = "http")] pub mod http; +#[cfg(feature = "imm")] pub mod imm; +#[cfg(feature = "interlockedapi")] pub mod interlockedapi; +#[cfg(feature = "ioapiset")] pub mod ioapiset; +#[cfg(feature = "jobapi")] pub mod jobapi; +#[cfg(feature = "jobapi2")] pub mod jobapi2; +#[cfg(feature = "knownfolders")] pub mod knownfolders; +#[cfg(feature = "ktmw32")] pub mod ktmw32; +#[cfg(feature = "libloaderapi")] pub mod libloaderapi; +#[cfg(feature = "lmaccess")] pub mod lmaccess; +#[cfg(feature = "lmalert")] pub mod lmalert; +#[cfg(feature = "lmapibuf")] pub mod lmapibuf; +#[cfg(feature = "lmat")] pub mod lmat; +#[cfg(feature = "lmdfs")] pub mod lmdfs; +#[cfg(feature = "lmerrlog")] pub mod lmerrlog; +#[cfg(feature = "lmjoin")] pub mod lmjoin; +#[cfg(feature = "lmmsg")] pub mod lmmsg; +#[cfg(feature = "lmremutl")] pub mod lmremutl; +#[cfg(feature = "lmrepl")] pub mod lmrepl; +#[cfg(feature = "lmserver")] pub mod lmserver; +#[cfg(feature = "lmshare")] pub mod lmshare; +#[cfg(feature = "lmstats")] pub mod lmstats; +#[cfg(feature = "lmsvc")] pub mod lmsvc; +#[cfg(feature = "lmuse")] pub mod lmuse; +#[cfg(feature = "lmwksta")] pub mod lmwksta; +#[cfg(feature = "lowlevelmonitorconfigurationapi")] pub mod lowlevelmonitorconfigurationapi; +#[cfg(feature = "lsalookup")] pub mod lsalookup; +#[cfg(feature = "memoryapi")] pub mod memoryapi; +#[cfg(feature = "minschannel")] pub mod minschannel; +#[cfg(feature = "minwinbase")] pub mod minwinbase; +#[cfg(feature = "mmdeviceapi")] pub mod mmdeviceapi; +#[cfg(feature = "mmeapi")] pub mod mmeapi; +#[cfg(feature = "mmsystem")] pub mod mmsystem; +#[cfg(feature = "msaatext")] pub mod msaatext; +#[cfg(feature = "mscat")] pub mod mscat; +#[cfg(feature = "mschapp")] pub mod mschapp; +#[cfg(feature = "mssip")] pub mod mssip; +#[cfg(feature = "mswsock")] pub mod mswsock; +#[cfg(feature = "namedpipeapi")] pub mod namedpipeapi; +#[cfg(feature = "namespaceapi")] pub mod namespaceapi; +#[cfg(feature = "nb30")] pub mod nb30; +#[cfg(feature = "ncrypt")] pub mod ncrypt; +#[cfg(feature = "ntlsa")] pub mod ntlsa; +#[cfg(feature = "ntsecapi")] pub mod ntsecapi; +#[cfg(feature = "oaidl")] pub mod oaidl; +#[cfg(feature = "objbase")] pub mod objbase; +#[cfg(feature = "objidl")] pub mod objidl; +#[cfg(feature = "objidlbase")] pub mod objidlbase; +#[cfg(feature = "ocidl")] pub mod ocidl; +#[cfg(feature = "ole2")] pub mod ole2; +#[cfg(feature = "oleauto")] pub mod oleauto; +#[cfg(feature = "olectl")] pub mod olectl; +#[cfg(feature = "oleidl")] pub mod oleidl; +#[cfg(feature = "opmapi")] pub mod opmapi; +#[cfg(feature = "pdh")] pub mod pdh; +#[cfg(feature = "perflib")] pub mod perflib; +#[cfg(feature = "physicalmonitorenumerationapi")] pub mod physicalmonitorenumerationapi; +#[cfg(feature = "playsoundapi")] pub mod playsoundapi; +#[cfg(feature = "portabledevice")] pub mod portabledevice; +#[cfg(feature = "portabledeviceapi")] pub mod portabledeviceapi; +#[cfg(feature = "portabledevicetypes")] pub mod portabledevicetypes; +#[cfg(feature = "powerbase")] pub mod powerbase; +#[cfg(feature = "powersetting")] pub mod powersetting; +#[cfg(feature = "powrprof")] pub mod powrprof; +#[cfg(feature = "processenv")] pub mod processenv; +#[cfg(feature = "processsnapshot")] pub mod processsnapshot; +#[cfg(feature = "processthreadsapi")] pub mod processthreadsapi; +#[cfg(feature = "processtopologyapi")] pub mod processtopologyapi; +#[cfg(feature = "profileapi")] pub mod profileapi; +#[cfg(feature = "propidl")] pub mod propidl; +#[cfg(feature = "propkey")] pub mod propkey; +#[cfg(feature = "propkeydef")] pub mod propkeydef; +#[cfg(feature = "propsys")] pub mod propsys; +#[cfg(feature = "prsht")] pub mod prsht; +#[cfg(feature = "psapi")] pub mod psapi; +#[cfg(feature = "realtimeapiset")] pub mod realtimeapiset; +#[cfg(feature = "reason")] pub mod reason; +#[cfg(feature = "restartmanager")] pub mod restartmanager; +#[cfg(feature = "restrictederrorinfo")] pub mod restrictederrorinfo; +#[cfg(feature = "rmxfguid")] pub mod rmxfguid; +#[cfg(feature = "sapi")] pub mod sapi; +#[cfg(feature = "sapi51")] pub mod sapi51; +#[cfg(feature = "sapi53")] pub mod sapi53; +#[cfg(feature = "sapiddk")] pub mod sapiddk; +#[cfg(feature = "sapiddk51")] pub mod sapiddk51; +#[cfg(feature = "schannel")] pub mod schannel; +#[cfg(feature = "securityappcontainer")] pub mod securityappcontainer; +#[cfg(feature = "securitybaseapi")] pub mod securitybaseapi; +#[cfg(feature = "servprov")] pub mod servprov; +#[cfg(feature = "setupapi")] pub mod setupapi; +#[cfg(feature = "shellapi")] pub mod shellapi; +#[cfg(feature = "shellscalingapi")] pub mod shellscalingapi; +#[cfg(feature = "shlobj")] pub mod shlobj; +#[cfg(feature = "shobjidl")] pub mod shobjidl; +#[cfg(feature = "shobjidl_core")] pub mod shobjidl_core; +#[cfg(feature = "shtypes")] pub mod shtypes; +#[cfg(feature = "spapidef")] pub mod spapidef; +#[cfg(feature = "spellcheck")] pub mod spellcheck; +#[cfg(feature = "sporder")] pub mod sporder; +#[cfg(feature = "sql")] pub mod sql; +#[cfg(feature = "sqlext")] pub mod sqlext; +#[cfg(feature = "sqltypes")] pub mod sqltypes; +#[cfg(feature = "sqlucode")] pub mod sqlucode; +#[cfg(feature = "sspi")] pub mod sspi; +#[cfg(feature = "stringapiset")] pub mod stringapiset; +#[cfg(feature = "strmif")] pub mod strmif; +#[cfg(feature = "subauth")] pub mod subauth; +#[cfg(feature = "synchapi")] pub mod synchapi; +#[cfg(feature = "sysinfoapi")] pub mod sysinfoapi; +#[cfg(feature = "systemtopologyapi")] pub mod systemtopologyapi; +#[cfg(feature = "taskschd")] pub mod taskschd; +#[cfg(feature = "textstor")] pub mod textstor; +#[cfg(feature = "threadpoolapiset")] pub mod threadpoolapiset; +#[cfg(feature = "threadpoollegacyapiset")] pub mod threadpoollegacyapiset; +#[cfg(feature = "timeapi")] pub mod timeapi; +#[cfg(feature = "timezoneapi")] pub mod timezoneapi; +#[cfg(feature = "tlhelp32")] pub mod tlhelp32; +#[cfg(feature = "unknwnbase")] pub mod unknwnbase; +#[cfg(feature = "urlhist")] pub mod urlhist; +#[cfg(feature = "urlmon")] pub mod urlmon; +#[cfg(feature = "userenv")] pub mod userenv; +#[cfg(feature = "usp10")] pub mod usp10; +#[cfg(feature = "utilapiset")] pub mod utilapiset; +#[cfg(feature = "uxtheme")] pub mod uxtheme; +#[cfg(feature = "vsbackup")] pub mod vsbackup; +#[cfg(feature = "vss")] pub mod vss; +#[cfg(feature = "vsserror")] pub mod vsserror; +#[cfg(feature = "vswriter")] pub mod vswriter; +#[cfg(feature = "wbemads")] pub mod wbemads; +#[cfg(feature = "wbemcli")] pub mod wbemcli; +#[cfg(feature = "wbemdisp")] pub mod wbemdisp; +#[cfg(feature = "wbemprov")] pub mod wbemprov; +#[cfg(feature = "wbemtran")] pub mod wbemtran; +#[cfg(feature = "wct")] pub mod wct; +#[cfg(feature = "werapi")] pub mod werapi; +#[cfg(feature = "winbase")] pub mod winbase; +#[cfg(feature = "wincodec")] pub mod wincodec; +#[cfg(feature = "wincodecsdk")] pub mod wincodecsdk; +#[cfg(feature = "wincon")] pub mod wincon; +#[cfg(feature = "wincontypes")] pub mod wincontypes; +#[cfg(feature = "wincred")] pub mod wincred; +#[cfg(feature = "wincrypt")] pub mod wincrypt; +#[cfg(feature = "windowsceip")] pub mod windowsceip; +#[cfg(feature = "winefs")] pub mod winefs; +#[cfg(feature = "winevt")] pub mod winevt; +#[cfg(feature = "wingdi")] pub mod wingdi; +#[cfg(feature = "winhttp")] pub mod winhttp; +#[cfg(feature = "wininet")] pub mod wininet; +#[cfg(feature = "winineti")] pub mod winineti; +#[cfg(feature = "winioctl")] pub mod winioctl; +#[cfg(feature = "winnetwk")] pub mod winnetwk; +#[cfg(feature = "winnls")] pub mod winnls; +#[cfg(feature = "winnt")] pub mod winnt; +#[cfg(feature = "winreg")] pub mod winreg; +#[cfg(feature = "winsafer")] pub mod winsafer; +#[cfg(feature = "winscard")] pub mod winscard; +#[cfg(feature = "winsmcrd")] pub mod winsmcrd; +#[cfg(feature = "winsock2")] pub mod winsock2; +#[cfg(feature = "winspool")] pub mod winspool; +#[cfg(feature = "winsvc")] pub mod winsvc; +#[cfg(feature = "winusb")] pub mod winusb; +#[cfg(feature = "winuser")] pub mod winuser; +#[cfg(feature = "winver")] pub mod winver; +#[cfg(feature = "wow64apiset")] pub mod wow64apiset; +#[cfg(feature = "wpdmtpextensions")] pub mod wpdmtpextensions; +#[cfg(feature = "ws2bth")] pub mod ws2bth; +#[cfg(feature = "ws2spi")] pub mod ws2spi; +#[cfg(feature = "ws2tcpip")] pub mod ws2tcpip; +#[cfg(feature = "xinput")] pub mod xinput; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/msaatext.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/msaatext.rs new file mode 100644 index 0000000..238ca2c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/msaatext.rs @@ -0,0 +1,59 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{IID_ITfMSAAControl, + 0xb5f8fb3b, 0x393f, 0x4f7c, 0x84, 0xcb, 0x50, 0x49, 0x24, 0xc2, 0x70, 0x5a} +DEFINE_GUID!{IID_IInternalDocWrap, + 0xe1aa6466, 0x9db4, 0x40ba, 0xbe, 0x03, 0x77, 0xc3, 0x8e, 0x8e, 0x60, 0xb2} +DEFINE_GUID!{IID_ITextStoreACPEx, + 0xa2de3bc2, 0x3d8e, 0x11d3, 0x81, 0xa9, 0xf7, 0x53, 0xfb, 0xe6, 0x1a, 0x00} +DEFINE_GUID!{IID_ITextStoreAnchorEx, + 0xa2de3bc1, 0x3d8e, 0x11d3, 0x81, 0xa9, 0xf7, 0x53, 0xfb, 0xe6, 0x1a, 0x00} +DEFINE_GUID!{IID_ITextStoreACPSinkEx, + 0x2bdf9464, 0x41e2, 0x43e3, 0x95, 0x0c, 0xa6, 0x86, 0x5b, 0xa2, 0x5c, 0xd4} +DEFINE_GUID!{IID_ITextStoreSinkAnchorEx, + 0x25642426, 0x028d, 0x4474, 0x97, 0x7b, 0x11, 0x1b, 0xb1, 0x14, 0xfe, 0x3e} +DEFINE_GUID!{IID_IAccDictionary, + 0x1dc4cb5f, 0xd737, 0x474d, 0xad, 0xe9, 0x5c, 0xcf, 0xc9, 0xbc, 0x1c, 0xc9} +DEFINE_GUID!{IID_IVersionInfo, + 0x401518ec, 0xdb00, 0x4611, 0x9b, 0x29, 0x2a, 0x0e, 0x4b, 0x9a, 0xfa, 0x85} +DEFINE_GUID!{IID_ICoCreateLocally, + 0x03de00aa, 0xf272, 0x41e3, 0x99, 0xcb, 0x03, 0xc5, 0xe8, 0x11, 0x4e, 0xa0} +DEFINE_GUID!{IID_ICoCreatedLocally, + 0x0a53eb6c, 0x1908, 0x4742, 0x8c, 0xff, 0x2c, 0xee, 0x2e, 0x93, 0xf9, 0x4c} +DEFINE_GUID!{IID_IAccStore, + 0xe2cd4a63, 0x2b72, 0x4d48, 0xb7, 0x39, 0x95, 0xe4, 0x76, 0x51, 0x95, 0xba} +DEFINE_GUID!{IID_IAccServerDocMgr, + 0xad7c73cf, 0x6dd5, 0x4855, 0xab, 0xc2, 0xb0, 0x4b, 0xad, 0x5b, 0x91, 0x53} +DEFINE_GUID!{IID_IAccClientDocMgr, + 0x4c896039, 0x7b6d, 0x49e6, 0xa8, 0xc1, 0x45, 0x11, 0x6a, 0x98, 0x29, 0x2b} +DEFINE_GUID!{IID_IDocWrap, + 0xdcd285fe, 0x0be0, 0x43bd, 0x99, 0xc9, 0xaa, 0xae, 0xc5, 0x13, 0xc5, 0x55} +DEFINE_GUID!{IID_IClonableWrapper, + 0xb33e75ff, 0xe84c, 0x4dca, 0xa2, 0x5c, 0x33, 0xb8, 0xdc, 0x00, 0x33, 0x74} +DEFINE_GUID!{LIBID_MSAATEXTLib, + 0x150e2d7a, 0xdac1, 0x4582, 0x94, 0x7d, 0x2a, 0x8f, 0xd7, 0x8b, 0x82, 0xcd} +DEFINE_GUID!{CLSID_MSAAControl, + 0x08cd963f, 0x7a3e, 0x4f5c, 0x9b, 0xd8, 0xd6, 0x92, 0xbb, 0x04, 0x3c, 0x5b} +DEFINE_GUID!{CLSID_AccStore, + 0x5440837f, 0x4bff, 0x4ae5, 0xa1, 0xb1, 0x77, 0x22, 0xec, 0xc6, 0x33, 0x2a} +DEFINE_GUID!{CLSID_AccDictionary, + 0x6572ee16, 0x5fe5, 0x4331, 0xbb, 0x6d, 0x76, 0xa4, 0x9c, 0x56, 0xe4, 0x23} +DEFINE_GUID!{CLSID_AccServerDocMgr, + 0x6089a37e, 0xeb8a, 0x482d, 0xbd, 0x6f, 0xf9, 0xf4, 0x69, 0x04, 0xd1, 0x6d} +DEFINE_GUID!{CLSID_AccClientDocMgr, + 0xfc48cc30, 0x4f3e, 0x4fa1, 0x80, 0x3b, 0xad, 0x0e, 0x19, 0x6a, 0x83, 0xb1} +DEFINE_GUID!{CLSID_DocWrap, + 0xbf426f7e, 0x7a5e, 0x44d6, 0x83, 0x0c, 0xa3, 0x90, 0xea, 0x94, 0x62, 0xa3} +DEFINE_GUID!{IID_ITextStoreACP, + 0x28888fe3, 0xc2a0, 0x483a, 0xa3, 0xea, 0x8c, 0xb1, 0xce, 0x51, 0xff, 0x3d} +DEFINE_GUID!{IID_ITextStoreAnchor, + 0x9b2077b0, 0x5f18, 0x4dec, 0xbe, 0xe9, 0x3c, 0xc7, 0x22, 0xf5, 0xdf, 0xe0} +DEFINE_GUID!{IID_IAnchor, + 0x0feb7e34, 0x5a60, 0x4356, 0x8e, 0xf7, 0xab, 0xde, 0xc2, 0xff, 0x7c, 0xf8} +DEFINE_GUID!{IID_ITextStoreAnchorSink, + 0xaa80e905, 0x2021, 0x11d2, 0x93, 0xe0, 0x00, 0x60, 0xb0, 0x67, 0xb8, 0x6e} +DEFINE_GUID!{IID_ITextStoreACPSink, + 0x22d44c94, 0xa419, 0x4542, 0xa2, 0x72, 0xae, 0x26, 0x09, 0x3e, 0xce, 0xcf} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/mscat.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/mscat.rs new file mode 100644 index 0000000..fca635f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/mscat.rs @@ -0,0 +1,36 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Microsoft Internet Security Catalog API Prototypes and Definitions +use shared::guiddef::GUID; +use shared::minwindef::DWORD; +use um::mssip::SIP_INDIRECT_DATA; +use um::wincrypt::{CRYPT_ATTR_BLOB, HCRYPTMSG, HCRYPTPROV}; +use um::winnt::{HANDLE, LPWSTR}; +STRUCT!{struct CRYPTCATSTORE { + cbStruct: DWORD, + dwPublicVersion: DWORD, + pwszP7File: LPWSTR, + hProv: HCRYPTPROV, + dwEncodingType: DWORD, + fdwStoreFlags: DWORD, + hReserved: HANDLE, + hAttrs: HANDLE, + hCryptMsg: HCRYPTMSG, + hSorted: HANDLE, +}} +STRUCT!{struct CRYPTCATMEMBER { + cbStruct: DWORD, + pwszReferenceTag: LPWSTR, + pwszFileName: LPWSTR, + gSubjectType: GUID, + fdwMemberFlags: DWORD, + pIndirectData: *mut SIP_INDIRECT_DATA, + dwCertVersion: DWORD, + dwReserved: DWORD, + hReserved: HANDLE, + sEncodedIndirectData: CRYPT_ATTR_BLOB, + sEncodedMemberInfo: CRYPT_ATTR_BLOB, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/mschapp.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/mschapp.rs new file mode 100644 index 0000000..103b54c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/mschapp.rs @@ -0,0 +1,48 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::SIZE_T; +use shared::minwindef::{DWORD, UCHAR}; +use um::winnt::{BOOLEAN, CHAR, PWSTR}; +pub const CYPHER_BLOCK_LENGTH: SIZE_T = 8; +STRUCT!{struct CYPHER_BLOCK { + data: [CHAR; CYPHER_BLOCK_LENGTH], +}} +STRUCT!{struct LM_OWF_PASSWORD { + data: [CYPHER_BLOCK; 2], +}} +pub type PLM_OWF_PASSWORD = *mut LM_OWF_PASSWORD; +pub type NT_OWF_PASSWORD = LM_OWF_PASSWORD; +pub type PNT_OWF_PASSWORD = *mut NT_OWF_PASSWORD; +STRUCT!{struct SAMPR_ENCRYPTED_USER_PASSWORD { + Buffer: [UCHAR; (256 * 2) + 4], +}} +pub type PSAMPR_ENCRYPTED_USER_PASSWORD = *mut SAMPR_ENCRYPTED_USER_PASSWORD; +STRUCT!{struct ENCRYPTED_LM_OWF_PASSWORD { + data: [CYPHER_BLOCK; 2], +}} +pub type PENCRYPTED_LM_OWF_PASSWORD = *mut ENCRYPTED_LM_OWF_PASSWORD; +pub type ENCRYPTED_NT_OWF_PASSWORD = ENCRYPTED_LM_OWF_PASSWORD; +pub type PENCRYPTED_NT_OWF_PASSWORD = *mut ENCRYPTED_NT_OWF_PASSWORD; +extern "system" { + pub fn MSChapSrvChangePassword( + ServerName: PWSTR, + UserName: PWSTR, + LmOldPresent: BOOLEAN, + LmOldOwfPassword: PLM_OWF_PASSWORD, + LmNewOwfPassword: PLM_OWF_PASSWORD, + NtOldOwfPassword: PNT_OWF_PASSWORD, + NtNewOwfPassword: PNT_OWF_PASSWORD, + ) -> DWORD; + pub fn MSChapSrvChangePassword2( + ServerName: PWSTR, + UserName: PWSTR, + NewPasswordEncryptedWithOldNt: PSAMPR_ENCRYPTED_USER_PASSWORD, + OldNtOwfPasswordEncryptedWithNewNt: PENCRYPTED_NT_OWF_PASSWORD, + LmPresent: BOOLEAN, + NewPasswordEncryptedWithOldLm: PSAMPR_ENCRYPTED_USER_PASSWORD, + OldLmOwfPasswordEncryptedWithNewLmOrNt: PENCRYPTED_LM_OWF_PASSWORD, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/mssip.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/mssip.rs new file mode 100644 index 0000000..f8cd6e4 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/mssip.rs @@ -0,0 +1,255 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Microsoft SIP Provider Prototypes and Definitions +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, BYTE, DWORD, LPVOID}; +use um::mscat::{CRYPTCATMEMBER, CRYPTCATSTORE}; +use um::wincrypt::{ + CRYPT_ALGORITHM_IDENTIFIER, CRYPT_ATTRIBUTE_TYPE_VALUE, CRYPT_HASH_BLOB, HCRYPTPROV, +}; +use um::winnt::{HANDLE, LPCWSTR, PWSTR, WCHAR}; +pub type CRYPT_DIGEST_DATA = CRYPT_HASH_BLOB; +pub const MSSIP_FLAGS_PROHIBIT_RESIZE_ON_CREATE: DWORD = 0x00010000; +pub const MSSIP_FLAGS_USE_CATALOG: DWORD = 0x00020000; +pub const MSSIP_FLAGS_MULTI_HASH: DWORD = 0x00040000; +pub const SPC_INC_PE_RESOURCES_FLAG: DWORD = 0x80; +pub const SPC_INC_PE_DEBUG_INFO_FLAG: DWORD = 0x40; +pub const SPC_INC_PE_IMPORT_ADDR_TABLE_FLAG: DWORD = 0x20; +pub const SPC_EXC_PE_PAGE_HASHES_FLAG: DWORD = 0x10; +pub const SPC_INC_PE_PAGE_HASHES_FLAG: DWORD = 0x100; +pub const SPC_DIGEST_GENERATE_FLAG: DWORD = 0x200; +pub const SPC_DIGEST_SIGN_FLAG: DWORD = 0x400; +pub const SPC_RELAXED_PE_MARKER_CHECK: DWORD = 0x800; +pub const SPC_MARKER_CHECK_SKIP_SIP_INDIRECT_DATA_FLAG: DWORD = 0x00000001; +pub const SPC_MARKER_CHECK_CURRENTLY_SUPPORTED_FLAGS: DWORD + = SPC_MARKER_CHECK_SKIP_SIP_INDIRECT_DATA_FLAG; +pub const MSSIP_ADDINFO_NONE: DWORD = 0; +pub const MSSIP_ADDINFO_FLAT: DWORD = 1; +pub const MSSIP_ADDINFO_CATMEMBER: DWORD = 2; +pub const MSSIP_ADDINFO_BLOB: DWORD = 3; +pub const MSSIP_ADDINFO_NONMSSIP: DWORD = 500; +UNION!{union SIP_SUBJECTINFO_u { + [usize; 1], + psFlat psFlat_mut: *mut MS_ADDINFO_FLAT, + psCatMember psCatMember_mut: *mut MS_ADDINFO_CATALOGMEMBER, + psBlob psBlob_mut: *mut MS_ADDINFO_BLOB, +}} +STRUCT!{struct SIP_SUBJECTINFO { + cbSize: DWORD, + pgSubjectType: *mut GUID, + hFile: HANDLE, + pwsFileName: LPCWSTR, + pwsDisplayName: LPCWSTR, + dwReserved1: DWORD, + dwIntVersion: DWORD, + hProv: HCRYPTPROV, + DigestAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + dwFlags: DWORD, + dwEncodingType: DWORD, + dwReserved2: DWORD, + fdwCAPISettings: DWORD, + fdwSecuritySettings: DWORD, + dwIndex: DWORD, + dwUnionChoice: DWORD, + u: SIP_SUBJECTINFO_u, + pClientData: LPVOID, +}} +pub type LPSIP_SUBJECTINFO = *mut SIP_SUBJECTINFO; +STRUCT!{struct MS_ADDINFO_FLAT { + cbStruct: DWORD, + pIndirectData: *mut SIP_INDIRECT_DATA, +}} +pub type PMS_ADDINFO_FLAT = *mut MS_ADDINFO_FLAT; +STRUCT!{struct MS_ADDINFO_CATALOGMEMBER { + cbStruct: DWORD, + pStore: *mut CRYPTCATSTORE, + pMember: *mut CRYPTCATMEMBER, +}} +pub type PMS_ADDINFO_CATALOGMEMBER = *mut MS_ADDINFO_CATALOGMEMBER; +STRUCT!{struct MS_ADDINFO_BLOB { + cbStruct: DWORD, + cbMemObject: DWORD, + pbMemObject: *mut BYTE, + cbMemSignedMsg: DWORD, + pbMemSignedMsg: *mut BYTE, +}} +pub type PMS_ADDINFO_BLOB = *mut MS_ADDINFO_BLOB; +STRUCT!{struct SIP_CAP_SET_V2 { + cbSize: DWORD, + dwVersion: DWORD, + isMultiSign: BOOL, + dwReserved: DWORD, +}} +pub type PSIP_CAP_SET_V2 = *mut SIP_CAP_SET_V2; +UNION!{union SIP_CAP_SET_V3_u { + [u32; 1], + dwFlags dwFlags_mut: DWORD, + dwReserved dwReserved_mut: DWORD, +}} +STRUCT!{struct SIP_CAP_SET_V3 { + cbSize: DWORD, + dwVersion: DWORD, + isMultiSign: BOOL, + u: SIP_CAP_SET_V3_u, +}} +pub type PSIP_CAP_SET_V3 = *mut SIP_CAP_SET_V3; +pub type SIP_CAP_SET = SIP_CAP_SET_V3; +pub type PSIP_CAP_SET = PSIP_CAP_SET_V3; +pub const SIP_CAP_SET_VERSION_2: DWORD = 2; +pub const SIP_CAP_SET_VERSION_3: DWORD = 3; +pub const SIP_CAP_SET_CUR_VER: DWORD = 3; +pub const SIP_CAP_FLAG_SEALING: DWORD = 0x00000001; +STRUCT!{struct SIP_INDIRECT_DATA { + Data: CRYPT_ATTRIBUTE_TYPE_VALUE, + DigestAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + Digest: CRYPT_HASH_BLOB, +}} +pub type PSIP_INDIRECT_DATA = *mut SIP_INDIRECT_DATA; +extern "system" { + pub fn CryptSIPGetSignedDataMsg( + pSubjectInfo: *mut SIP_SUBJECTINFO, + pdwEncodingType: *mut DWORD, + dwIndex: DWORD, + pcbSignedDataMsg: *mut DWORD, + pbSignedDataMsg: *mut BYTE, + ) -> BOOL; +} +FN!{stdcall pCryptSIPGetSignedDataMsg( + pSubjectInfo: *mut SIP_SUBJECTINFO, + pdwEncodingType: *mut DWORD, + dwIndex: DWORD, + pcbSignedDataMsg: *mut DWORD, + pbSignedDataMsg: *mut BYTE, +) -> BOOL} +extern "system" { + pub fn CryptSIPPutSignedDataMsg( + pSubjectInfo: *mut SIP_SUBJECTINFO, + dwEncodingType: DWORD, + pdwIndex: *mut DWORD, + cbSignedDataMsg: DWORD, + pbSignedDataMsg: *mut BYTE, + ) -> BOOL; +} +FN!{stdcall pCryptSIPPutSignedDataMsg( + pSubjectInfo: *mut SIP_SUBJECTINFO, + dwEncodingType: DWORD, + pdwIndex: *mut DWORD, + cbSignedDataMsg: DWORD, + pbSignedDataMsg: *mut BYTE, +) -> BOOL} +extern "system" { + pub fn CryptSIPCreateIndirectData( + pSubjectInfo: *mut SIP_SUBJECTINFO, + pcbIndirectData: *mut DWORD, + pIndirectData: *mut SIP_INDIRECT_DATA, + ) -> BOOL; +} +FN!{stdcall pCryptSIPCreateIndirectData( + pSubjectInfo: *mut SIP_SUBJECTINFO, + pcbIndirectData: *mut DWORD, + pIndirectData: *mut SIP_INDIRECT_DATA, +) -> BOOL} +extern "system" { + pub fn CryptSIPVerifyIndirectData( + pSubjectInfo: *mut SIP_SUBJECTINFO, + pIndirectData: *mut SIP_INDIRECT_DATA, + ) -> BOOL; +} +FN!{stdcall pCryptSIPVerifyIndirectData( + pSubjectInfo: *mut SIP_SUBJECTINFO, + pIndirectData: *mut SIP_INDIRECT_DATA, +) -> BOOL} +extern "system" { + pub fn CryptSIPRemoveSignedDataMsg( + pSubjectInfo: *mut SIP_SUBJECTINFO, + dwIndex: DWORD, + ) -> BOOL; +} +FN!{stdcall pCryptSIPRemoveSignedDataMsg( + pSubjectInfo: *mut SIP_SUBJECTINFO, + dwIndex: DWORD, +) -> BOOL} +STRUCT!{struct SIP_DISPATCH_INFO { + cbSize: DWORD, + hSIP: HANDLE, + pfGet: pCryptSIPGetSignedDataMsg, + pfPut: pCryptSIPPutSignedDataMsg, + pfCreate: pCryptSIPCreateIndirectData, + pfVerify: pCryptSIPVerifyIndirectData, + pfRemove: pCryptSIPRemoveSignedDataMsg, +}} +pub type LPSIP_DISPATCH_INFO = *mut SIP_DISPATCH_INFO; +FN!{stdcall pfnIsFileSupported( + hFile: HANDLE, + pgSubject: *mut GUID, +) -> BOOL} +FN!{stdcall pfnIsFileSupportedName( + pwszFileName: *mut WCHAR, + pgSubject: *mut GUID, +) -> BOOL} +STRUCT!{struct SIP_ADD_NEWPROVIDER { + cbStruct: DWORD, + pgSubject: *mut GUID, + pwszDLLFileName: *mut WCHAR, + pwszMagicNumber: *mut WCHAR, + pwszIsFunctionName: *mut WCHAR, + pwszGetFuncName: *mut WCHAR, + pwszPutFuncName: *mut WCHAR, + pwszCreateFuncName: *mut WCHAR, + pwszVerifyFuncName: *mut WCHAR, + pwszRemoveFuncName: *mut WCHAR, + pwszIsFunctionNameFmt2: *mut WCHAR, + pwszGetCapFuncName: PWSTR, +}} +pub type PSIP_ADD_NEWPROVIDER = *mut SIP_ADD_NEWPROVIDER; +pub const SIP_MAX_MAGIC_NUMBER: DWORD = 4; +extern "system" { + pub fn CryptSIPLoad( + pgSubject: *const GUID, + dwFlags: DWORD, + pSipDispatch: *mut SIP_DISPATCH_INFO, + ) -> BOOL; + pub fn CryptSIPRetrieveSubjectGuid( + FileName: LPCWSTR, + hFileIn: HANDLE, + pgSubject: *mut GUID, + ) -> BOOL; + pub fn CryptSIPRetrieveSubjectGuidForCatalogFile( + FileName: LPCWSTR, + hFileIn: HANDLE, + pgSubject: *mut GUID, + ) -> BOOL; + pub fn CryptSIPAddProvider( + psNewProv: *mut SIP_ADD_NEWPROVIDER, + ) -> BOOL; + pub fn CryptSIPRemoveProvider( + pgProv: *mut GUID, + ) -> BOOL; + pub fn CryptSIPGetCaps( + pSubjInfo: *mut SIP_SUBJECTINFO, + pCaps: *mut SIP_CAP_SET, + ) -> BOOL; +} +FN!{stdcall pCryptSIPGetCaps( + pSubjInfo: *mut SIP_SUBJECTINFO, + pCaps: *mut SIP_CAP_SET, +) -> BOOL} +extern "system" { + pub fn CryptSIPGetSealedDigest( + pSubjectInfo: *mut SIP_SUBJECTINFO, + pSig: *const BYTE, + dwSig: DWORD, + pbDigest: *mut BYTE, + pcbDigest: *mut DWORD, + ) -> BOOL; +} +FN!{stdcall pCryptSIPGetSealedDigest( + pSubjectInfo: *mut SIP_SUBJECTINFO, + pSig: *const BYTE, + dwSig: DWORD, + pbDigest: *mut BYTE, + pcbDigest: *mut DWORD, +) -> BOOL} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/mswsock.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/mswsock.rs new file mode 100644 index 0000000..cbbe191 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/mswsock.rs @@ -0,0 +1,413 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_char, c_int}; +use shared::minwindef::{BOOL, DWORD, INT, LPDWORD, LPINT, LPVOID, ULONG}; +use shared::mswsockdef::{PRIORESULT, PRIO_BUF, RIO_BUFFERID, RIO_CQ, RIO_RQ}; +use shared::ws2def::{IOC_VENDOR, IOC_WS2, LPWSAMSG, SOCKADDR}; +use um::minwinbase::LPOVERLAPPED; +use um::winnt::{CHAR, HANDLE, LARGE_INTEGER, PCHAR, PVOID, WCHAR}; +use um::winsock2::{ + LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE, LPWSAPOLLFD, SOCKET, WSAESETSERVICEOP, + WSAPOLLFD, +}; +pub const SO_CONNDATA: c_int = 0x7000; +pub const SO_CONNOPT: c_int = 0x7001; +pub const SO_DISCDATA: c_int = 0x7002; +pub const SO_DISCOPT: c_int = 0x7003; +pub const SO_CONNDATALEN: c_int = 0x7004; +pub const SO_CONNOPTLEN: c_int = 0x7005; +pub const SO_DISCDATALEN: c_int = 0x7006; +pub const SO_DISCOPTLEN: c_int = 0x7007; +pub const SO_OPENTYPE: c_int = 0x7008; +pub const SO_SYNCHRONOUS_ALERT: DWORD = 0x10; +pub const SO_SYNCHRONOUS_NONALERT: DWORD = 0x20; +pub const SO_MAXDG: c_int = 0x7009; +pub const SO_MAXPATHDG: c_int = 0x700A; +pub const SO_UPDATE_ACCEPT_CONTEXT: c_int = 0x700B; +pub const SO_CONNECT_TIME: c_int = 0x700C; +pub const SO_UPDATE_CONNECT_CONTEXT: c_int = 0x7010; +pub const TCP_BSDURGENT: c_int = 0x7000; +pub const SIO_UDP_CONNRESET: DWORD = _WSAIOW!(IOC_VENDOR, 12); +pub const SIO_SOCKET_CLOSE_NOTIFY: DWORD = _WSAIOW!(IOC_VENDOR, 13); +pub const SIO_UDP_NETRESET: DWORD = _WSAIOW!(IOC_VENDOR, 15); +extern "system" { + pub fn WSARecvEx( + s: SOCKET, + buf: *mut c_char, + len: c_int, + flags: *mut c_int, + ) -> c_int; +} +STRUCT!{struct TRANSMIT_FILE_BUFFERS { + Head: LPVOID, + HeadLength: DWORD, + Tail: LPVOID, + TailLength: DWORD, +}} +pub type PTRANSMIT_FILE_BUFFERS = *mut TRANSMIT_FILE_BUFFERS; +pub type LPTRANSMIT_FILE_BUFFERS = *mut TRANSMIT_FILE_BUFFERS; +pub const TF_DISCONNECT: DWORD = 0x01; +pub const TF_REUSE_SOCKET: DWORD = 0x02; +pub const TF_WRITE_BEHIND: DWORD = 0x04; +pub const TF_USE_DEFAULT_WORKER: DWORD = 0x00; +pub const TF_USE_SYSTEM_THREAD: DWORD = 0x10; +pub const TF_USE_KERNEL_APC: DWORD = 0x20; +extern "system" { + pub fn TransmitFile( + hSocket: SOCKET, + hFile: HANDLE, + nNumberOfBytesToWrite: DWORD, + nNumberOfBytesPerSend: DWORD, + lpOverlapped: LPOVERLAPPED, + lpTransmitBuffers: LPTRANSMIT_FILE_BUFFERS, + dwReserved: DWORD, + ) -> BOOL; + pub fn AcceptEx( + sListenSocket: SOCKET, + sAcceptSocket: SOCKET, + lpOutputBuffer: PVOID, + dwReceiveDataLength: DWORD, + dwLocalAddressLength: DWORD, + dwRemoteAddressLength: DWORD, + lpdwBytesReceived: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn GetAcceptExSockaddrs( + lpOutputBuffer: PVOID, + dwReceiveDataLength: DWORD, + dwLocalAddressLength: DWORD, + dwRemoteAddressLength: DWORD, + LocalSockaddr: *mut *mut SOCKADDR, + LocalSockaddrLength: LPINT, + RemoteSockaddr: *mut *mut SOCKADDR, + RemoteSockaddrLength: LPINT, + ); +} +FN!{stdcall LPFN_TRANSMITFILE( + hSocket: SOCKET, + hFile: HANDLE, + nNumberOfBytesToWrite: DWORD, + nNumberOfBytesPerSend: DWORD, + lpOverlapped: LPOVERLAPPED, + lpTransmitBuffers: LPTRANSMIT_FILE_BUFFERS, + dwReserved: DWORD, +) -> BOOL} +DEFINE_GUID!{WSAID_TRANSMITFILE, + 0xb5367df0, 0xcbac, 0x11cf, 0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92} +FN!{stdcall LPFN_ACCEPTEX( + sListenSocket: SOCKET, + sAcceptSocket: SOCKET, + lpOutputBuffer: PVOID, + dwReceiveDataLength: DWORD, + dwLocalAddressLength: DWORD, + dwRemoteAddressLength: DWORD, + lpdwBytesReceived: LPDWORD, + lpOverlapped: LPOVERLAPPED, +) -> BOOL} +DEFINE_GUID!{WSAID_ACCEPTEX, + 0xb5367df1, 0xcbac, 0x11cf, 0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92} +FN!{stdcall LPFN_GETACCEPTEXSOCKADDRS( + lpOutputBuffer: PVOID, + dwReceiveDataLength: DWORD, + dwLocalAddressLength: DWORD, + dwRemoteAddressLength: DWORD, + LocalSockaddr: *mut *mut SOCKADDR, + LocalSockaddrLength: LPINT, + RemoteSockaddr: *mut *mut SOCKADDR, + RemoteSockaddrLength: LPINT, +) -> ()} +DEFINE_GUID!{WSAID_GETACCEPTEXSOCKADDRS, + 0xb5367df2, 0xcbac, 0x11cf, 0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92} +pub const TP_ELEMENT_MEMORY: ULONG = 1; +pub const TP_ELEMENT_FILE: ULONG = 2; +pub const TP_ELEMENT_EOP: ULONG = 4; +STRUCT!{struct TRANSMIT_PACKETS_ELEMENT_u_s { + nFileOffset: LARGE_INTEGER, + hFile: HANDLE, +}} +UNION!{union TRANSMIT_PACKETS_ELEMENT_u { + [u64; 2], + s s_mut: TRANSMIT_PACKETS_ELEMENT_u_s, + pBuffer pBuffer_mut: PVOID, +}} +STRUCT!{struct TRANSMIT_PACKETS_ELEMENT { + dwElFlags: ULONG, + cLength: ULONG, + u: TRANSMIT_PACKETS_ELEMENT_u, +}} +pub type PTRANSMIT_PACKETS_ELEMENT = *mut TRANSMIT_PACKETS_ELEMENT; +pub type LPTRANSMIT_PACKETS_ELEMENT = *mut TRANSMIT_PACKETS_ELEMENT; +pub const TP_DISCONNECT: DWORD = TF_DISCONNECT; +pub const TP_REUSE_SOCKET: DWORD = TF_REUSE_SOCKET; +pub const TP_USE_DEFAULT_WORKER: DWORD = TF_USE_DEFAULT_WORKER; +pub const TP_USE_SYSTEM_THREAD: DWORD = TF_USE_SYSTEM_THREAD; +pub const TP_USE_KERNEL_APC: DWORD = TF_USE_KERNEL_APC; +FN!{stdcall LPFN_TRANSMITPACKETS( + hSocket: SOCKET, + lpPacketArray: LPTRANSMIT_PACKETS_ELEMENT, + nElementCount: DWORD, + nSendSize: DWORD, + lpOverlapped: LPOVERLAPPED, + dwFlags: DWORD, +) -> BOOL} +DEFINE_GUID!{WSAID_TRANSMITPACKETS, + 0xd9689da0, 0x1f90, 0x11d3, 0x99, 0x71, 0x00, 0xc0, 0x4f, 0x68, 0xc8, 0x76} +FN!{stdcall LPFN_CONNECTEX( + s: SOCKET, + name: *const SOCKADDR, + namelen: c_int, + lpSendBuffer: PVOID, + dwSendDataLength: DWORD, + lpdwBytesSent: LPDWORD, + lpOverlapped: LPOVERLAPPED, +) -> BOOL} +DEFINE_GUID!{WSAID_CONNECTEX, + 0x25a207b9, 0xddf3, 0x4660, 0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e} +FN!{stdcall LPFN_DISCONNECTEX( + s: SOCKET, + lpOverlapped: LPOVERLAPPED, + dwFlags: DWORD, + dwReserved: DWORD, +) -> BOOL} +DEFINE_GUID!{WSAID_DISCONNECTEX, + 0x7fda2e11, 0x8630, 0x436f, 0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57} +pub const DE_REUSE_SOCKET: DWORD = TF_REUSE_SOCKET; +DEFINE_GUID!{NLA_NAMESPACE_GUID, + 0x6642243a, 0x3ba8, 0x4aa6, 0xba, 0xa5, 0x2e, 0xb, 0xd7, 0x1f, 0xdd, 0x83} +DEFINE_GUID!{NLA_SERVICE_CLASS_GUID, + 0x37e515, 0xb5c9, 0x4a43, 0xba, 0xda, 0x8b, 0x48, 0xa8, 0x7a, 0xd2, 0x39} +pub const NLA_ALLUSERS_NETWORK: WSAESETSERVICEOP = 0x00000001; +pub const NLA_FRIENDLY_NAME: WSAESETSERVICEOP = 0x00000002; +ENUM!{enum NLA_BLOB_DATA_TYPE { + NLA_RAW_DATA = 0, + NLA_INTERFACE = 1, + NLA_802_1X_LOCATION = 2, + NLA_CONNECTIVITY = 3, + NLA_ICS = 4, +}} +pub type PNLA_BLOB_DATA_TYPE = *mut NLA_BLOB_DATA_TYPE; +ENUM!{enum NLA_CONNECTIVITY_TYPE { + NLA_NETWORK_AD_HOC = 0, + NLA_NETWORK_MANAGED = 1, + NLA_NETWORK_UNMANAGED = 2, + NLA_NETWORK_UNKNOWN = 3, +}} +pub type PNLA_CONNECTIVITY_TYPE = *mut NLA_CONNECTIVITY_TYPE; +ENUM!{enum NLA_INTERNET { + NLA_INTERNET_UNKNOWN = 0, + NLA_INTERNET_NO = 1, + NLA_INTERNET_YES = 2, +}} +pub type PNLA_INTERNET = *mut NLA_INTERNET; +STRUCT!{struct NLA_BLOB_s { + type_: NLA_BLOB_DATA_TYPE, + dwSize: DWORD, + nextOffset: DWORD, +}} +STRUCT!{struct NLA_BLOB_u_s1 { + dwType: DWORD, + dwSpeed: DWORD, + adapterName: [CHAR; 1], +}} +STRUCT!{struct NLA_BLOB_u_s2 { + information: [CHAR; 1], +}} +STRUCT!{struct NLA_BLOB_u_s3 { + type_: NLA_CONNECTIVITY_TYPE, + internet: NLA_INTERNET, +}} +STRUCT!{struct NLA_BLOB_u_s4_s { + speed: DWORD, + type_: DWORD, + state: DWORD, + machineName: [WCHAR; 256], + sharedAdapterName: [WCHAR; 256], +}} +STRUCT!{struct NLA_BLOB_u_s4 { + remote: NLA_BLOB_u_s4_s, +}} +UNION!{union NLA_BLOB_u { + [u32; 259], + rawData rawData_mut: [CHAR; 1], + interfaceData interfaceData_mut: NLA_BLOB_u_s1, + locationData locationData_mut: NLA_BLOB_u_s2, + connectivity connectivity_mut: NLA_BLOB_u_s3, + ICS ICS_mut: NLA_BLOB_u_s4, +}} +STRUCT!{struct NLA_BLOB { + header: NLA_BLOB_s, + data: NLA_BLOB_u, +}} +pub type PNLA_BLOB = *mut NLA_BLOB; +pub type LPNLA_BLOB = *mut NLA_BLOB; +FN!{stdcall LPFN_WSARECVMSG( + s: SOCKET, + lpMsg: LPWSAMSG, + lpdwNumberOfBytesRecvd: LPDWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, +) -> INT} +DEFINE_GUID!{WSAID_WSARECVMSG, + 0xf689d7c8, 0x6f1f, 0x436b, 0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22} +pub const SIO_BSP_HANDLE: DWORD = _WSAIOR!(IOC_WS2, 27); +pub const SIO_BSP_HANDLE_SELECT: DWORD = _WSAIOR!(IOC_WS2, 28); +pub const SIO_BSP_HANDLE_POLL: DWORD = _WSAIOR!(IOC_WS2, 29); +pub const SIO_BASE_HANDLE: DWORD = _WSAIOR!(IOC_WS2, 34); +pub const SIO_EXT_SELECT: DWORD = _WSAIORW!(IOC_WS2, 30); +pub const SIO_EXT_POLL: DWORD = _WSAIORW!(IOC_WS2, 31); +pub const SIO_EXT_SENDMSG: DWORD = _WSAIORW!(IOC_WS2, 32); +STRUCT!{struct WSAPOLLDATA { + result: c_int, + fds: ULONG, + timeout: INT, + fdArray: *mut WSAPOLLFD, +}} +pub type LPWSAPOLLDATA = *mut WSAPOLLDATA; +STRUCT!{struct WSASENDMSG { + lpMsg: LPWSAMSG, + dwFlags: DWORD, + lpNumberOfBytesSent: LPDWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, +}} +pub type LPWSASENDMSG = *mut WSASENDMSG; +FN!{stdcall LPFN_WSASENDMSG( + s: SOCKET, + lpMsg: LPWSAMSG, + dwFlags: DWORD, + lpNumberOfBytesSent: LPDWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, +) -> INT} +DEFINE_GUID!{WSAID_WSASENDMSG, + 0xa441e712, 0x754f, 0x43ca, 0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d} +FN!{stdcall LPFN_WSAPOLL( + fdarray: LPWSAPOLLFD, + nfds: ULONG, + timeout: INT, +) -> INT} +DEFINE_GUID!{WSAID_WSAPOLL, + 0x18C76F85, 0xDC66, 0x4964, 0x97, 0x2E, 0x23, 0xC2, 0x72, 0x38, 0x31, 0x2B} +FN!{stdcall LPFN_RIORECEIVE( + SocketQueue: RIO_RQ, + pData: PRIO_BUF, + DataBufferCount: ULONG, + Flags: DWORD, + RequestContext: PVOID, +) -> BOOL} +FN!{stdcall LPFN_RIORECEIVEEX( + SocketQueue: RIO_RQ, + pData: PRIO_BUF, + DataBufferCount: ULONG, + pLocalAddress: PRIO_BUF, + pRemoteAddress: PRIO_BUF, + pControlContext: PRIO_BUF, + pFlags: PRIO_BUF, + Flags: DWORD, + RequestContext: PVOID, +) -> c_int} +FN!{stdcall LPFN_RIOSEND( + SocketQueue: RIO_RQ, + pData: PRIO_BUF, + DataBufferCount: ULONG, + Flags: DWORD, + RequestContext: PVOID, +) -> BOOL} +FN!{stdcall LPFN_RIOSENDEX( + SocketQueue: RIO_RQ, + pData: PRIO_BUF, + DataBufferCount: ULONG, + pLocalAddress: PRIO_BUF, + pRemoteAddress: PRIO_BUF, + pControlContext: PRIO_BUF, + pFlags: PRIO_BUF, + Flags: DWORD, + RequestContext: PVOID, +) -> BOOL} +FN!{stdcall LPFN_RIOCLOSECOMPLETIONQUEUE( + CQ: RIO_CQ, +) -> ()} +ENUM!{enum RIO_NOTIFICATION_COMPLETION_TYPE { + RIO_EVENT_COMPLETION = 1, + RIO_IOCP_COMPLETION = 2, +}} +pub type PRIO_NOTIFICATION_COMPLETION_TYPE = *mut RIO_NOTIFICATION_COMPLETION_TYPE; +STRUCT!{struct RIO_NOTIFICATION_COMPLETION_u_s1 { + EventHandle: HANDLE, + NotifyReset: BOOL, +}} +STRUCT!{struct RIO_NOTIFICATION_COMPLETION_u_s2 { + IocpHandle: HANDLE, + CompletionKey: PVOID, + Overlapped: PVOID, +}} +UNION!{union RIO_NOTIFICATION_COMPLETION_u { + [u32; 3] [u64; 3], + Event Event_mut: RIO_NOTIFICATION_COMPLETION_u_s1, + Iocp Iocp_mut: RIO_NOTIFICATION_COMPLETION_u_s2, +}} +STRUCT!{struct RIO_NOTIFICATION_COMPLETION { + Type: RIO_NOTIFICATION_COMPLETION_TYPE, + u: RIO_NOTIFICATION_COMPLETION_u, +}} +pub type PRIO_NOTIFICATION_COMPLETION = *mut RIO_NOTIFICATION_COMPLETION; +FN!{stdcall LPFN_RIOCREATECOMPLETIONQUEUE( + QueueSize: DWORD, + NotificationCompletion: PRIO_NOTIFICATION_COMPLETION, +) -> RIO_CQ} +FN!{stdcall LPFN_RIOCREATEREQUESTQUEUE( + Socket: SOCKET, + MaxOutstandingReceive: ULONG, + MaxReceiveDataBuffers: ULONG, + MaxOutstandingSend: ULONG, + MaxSendDataBuffers: ULONG, + ReceiveCQ: RIO_CQ, + SendCQ: RIO_CQ, + SocketContext: PVOID, +) -> RIO_RQ} +FN!{stdcall LPFN_RIODEQUEUECOMPLETION( + CQ: RIO_CQ, + Array: PRIORESULT, + ArraySize: ULONG, +) -> ULONG} +FN!{stdcall LPFN_RIODEREGISTERBUFFER( + BufferId: RIO_BUFFERID, +) -> ()} +FN!{stdcall LPFN_RIONOTIFY( + CQ: RIO_CQ, +) -> INT} +FN!{stdcall LPFN_RIOREGISTERBUFFER( + DataBuffer: PCHAR, + DataLength: DWORD, +) -> RIO_BUFFERID} +FN!{stdcall LPFN_RIORESIZECOMPLETIONQUEUE( + CQ: RIO_CQ, + QueueSize: DWORD, +) -> BOOL} +FN!{stdcall LPFN_RIORESIZEREQUESTQUEUE( + RQ: RIO_RQ, + MaxOutstandingReceive: DWORD, + MaxOutstandingSend: DWORD, +) -> BOOL} +STRUCT!{struct RIO_EXTENSION_FUNCTION_TABLE { + cbSize: DWORD, + RIOReceive: LPFN_RIORECEIVE, + RIOReceiveEx: LPFN_RIORECEIVEEX, + RIOSend: LPFN_RIOSEND, + RIOSendEx: LPFN_RIOSENDEX, + RIOCloseCompletionQueue: LPFN_RIOCLOSECOMPLETIONQUEUE, + RIOCreateCompletionQueue: LPFN_RIOCREATECOMPLETIONQUEUE, + RIOCreateRequestQueue: LPFN_RIOCREATEREQUESTQUEUE, + RIODequeueCompletion: LPFN_RIODEQUEUECOMPLETION, + RIODeregisterBuffer: LPFN_RIODEREGISTERBUFFER, + RIONotify: LPFN_RIONOTIFY, + RIORegisterBuffer: LPFN_RIOREGISTERBUFFER, + RIOResizeCompletionQueue: LPFN_RIORESIZECOMPLETIONQUEUE, + RIOResizeRequestQueue: LPFN_RIORESIZEREQUESTQUEUE, +}} +pub type PRIO_EXTENSION_FUNCTION_TABLE = *mut RIO_EXTENSION_FUNCTION_TABLE; +DEFINE_GUID!{WSAID_MULTIPLE_RIO, + 0x8509e081, 0x96dd, 0x4005, 0xb1, 0x65, 0x9e, 0x2e, 0xe8, 0xc7, 0x9e, 0x3f} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/namedpipeapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/namedpipeapi.rs new file mode 100644 index 0000000..7c7447f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/namedpipeapi.rs @@ -0,0 +1,93 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, DWORD, LPDWORD, LPVOID, ULONG}; +use um::minwinbase::{LPOVERLAPPED, LPSECURITY_ATTRIBUTES}; +use um::winnt::{HANDLE, LPCWSTR, LPWSTR, PHANDLE}; +extern "system" { + pub fn CreatePipe( + hReadPipe: PHANDLE, + hWritePipe: PHANDLE, + lpPipeAttributes: LPSECURITY_ATTRIBUTES, + nSize: DWORD, + ) -> BOOL; + pub fn ConnectNamedPipe( + hNamedPipe: HANDLE, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn DisconnectNamedPipe( + hNamedPipe: HANDLE, + ) -> BOOL; + pub fn SetNamedPipeHandleState( + hNamedPipe: HANDLE, + lpMode: LPDWORD, + lpMaxCollectionCount: LPDWORD, + lpCollectDataTimeout: LPDWORD, + ) -> BOOL; + pub fn PeekNamedPipe( + hNamedPipe: HANDLE, + lpBuffer: LPVOID, + nBufferSize: DWORD, + lpBytesRead: LPDWORD, + lpTotalBytesAvail: LPDWORD, + lpBytesLeftThisMessage: LPDWORD, + ) -> BOOL; + pub fn TransactNamedPipe( + hNamedPipe: HANDLE, + lpInBuffer: LPVOID, + nInBufferSize: DWORD, + lpOutBuffer: LPVOID, + nOutBufferSize: DWORD, + lpBytesRead: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn CreateNamedPipeW( + lpName: LPCWSTR, + dwOpenMode: DWORD, + dwPipeMode: DWORD, + nMaxInstances: DWORD, + nOutBufferSize: DWORD, + nInBufferSize: DWORD, + nDefaultTimeOut: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> HANDLE; + pub fn WaitNamedPipeW( + lpNamedPipeName: LPCWSTR, + nTimeOut: DWORD, + ) -> BOOL; + pub fn GetNamedPipeClientComputerNameW( + Pipe: HANDLE, + ClientComputerName: LPWSTR, + ClientComputerNameLength: ULONG, + ) -> BOOL; + pub fn ImpersonateNamedPipeClient( + hNamedPipe: HANDLE, + ) -> BOOL; + pub fn GetNamedPipeInfo( + hNamedPipe: HANDLE, + lpFlags: LPDWORD, + lpOutBufferSize: LPDWORD, + lpInBufferSize: LPDWORD, + lpMaxInstances: LPDWORD, + ) -> BOOL; + pub fn GetNamedPipeHandleStateW( + hNamedPipe: HANDLE, + lpState: LPDWORD, + lpCurInstances: LPDWORD, + lpMaxCollectionCount: LPDWORD, + lpCollectDataTimeout: LPDWORD, + lpUserName: LPWSTR, + nMaxUserNameSize: DWORD, + ) -> BOOL; + pub fn CallNamedPipeW( + lpNamedPipeName: LPCWSTR, + lpInBuffer: LPVOID, + nInBufferSize: DWORD, + lpOutBuffer: LPVOID, + nOutBufferSize: DWORD, + lpBytesRead: LPDWORD, + nTimeOut: DWORD, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/namespaceapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/namespaceapi.rs new file mode 100644 index 0000000..cfdb805 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/namespaceapi.rs @@ -0,0 +1,36 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +use shared::minwindef::{BOOL, LPVOID, ULONG}; +use shared::ntdef::{BOOLEAN, HANDLE, LPCWSTR}; +use um::minwinbase::LPSECURITY_ATTRIBUTES; +use um::winnt::PSID; +pub const PRIVATE_NAMESPACE_FLAG_DESTROY: ULONG = 0x00000001; +extern "system" { + pub fn CreatePrivateNamespaceW( + lpPrivateNamespaceAttributes: LPSECURITY_ATTRIBUTES, + lpBoundaryDescriptor: LPVOID, + lpAliasPrefix: LPCWSTR, + ) -> HANDLE; + pub fn OpenPrivateNamespaceW( + lpBoundaryDescriptor: LPVOID, + lpAliasPrefix: LPCWSTR, + ) -> HANDLE; + pub fn ClosePrivateNamespace( + Handle: HANDLE, + Flags: ULONG, + ) -> BOOLEAN; + pub fn CreateBoundaryDescriptorW( + Name: LPCWSTR, + Flags: ULONG, + ) -> HANDLE; + pub fn AddSIDToBoundaryDescriptor( + BoundaryDescriptor: *mut HANDLE, + RequiredSid: PSID, + ) -> BOOL; + pub fn DeleteBoundaryDescriptor( + BoundaryDescriptor: HANDLE, + ) -> (); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/nb30.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/nb30.rs new file mode 100644 index 0000000..100efbd --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/nb30.rs @@ -0,0 +1,214 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module contains the definitions for portable NetBIOS 3.0 support. +use shared::minwindef::{DWORD, PUCHAR, UCHAR, ULONG, USHORT, WORD}; +use um::winnt::HANDLE; +pub const NCBNAMSZ: usize = 16; +pub const MAX_LANA: usize = 254; +FN!{stdcall PFPOST( + *mut NCB, +) -> ()} +#[cfg(target_pointer_width = "64")] +STRUCT!{struct NCB { + ncb_command: UCHAR, + ncb_retcode: UCHAR, + ncb_lsn: UCHAR, + ncb_num: UCHAR, + ncb_buffer: PUCHAR, + ncb_length: WORD, + ncb_callname: [UCHAR; NCBNAMSZ], + ncb_name: [UCHAR; NCBNAMSZ], + ncb_rto: UCHAR, + ncb_sto: UCHAR, + ncb_post: PFPOST, + ncb_lana_num: UCHAR, + ncb_cmd_cplt: UCHAR, + ncb_reserve: [UCHAR; 18], + ncb_event: HANDLE, +}} +#[cfg(target_pointer_width = "32")] +STRUCT!{struct NCB { + ncb_command: UCHAR, + ncb_retcode: UCHAR, + ncb_lsn: UCHAR, + ncb_num: UCHAR, + ncb_buffer: PUCHAR, + ncb_length: WORD, + ncb_callname: [UCHAR; NCBNAMSZ], + ncb_name: [UCHAR; NCBNAMSZ], + ncb_rto: UCHAR, + ncb_sto: UCHAR, + ncb_post: PFPOST, + ncb_lana_num: UCHAR, + ncb_cmd_cplt: UCHAR, + ncb_reserve: [UCHAR; 10], + ncb_event: HANDLE, +}} +pub type PNCB = *mut NCB; +STRUCT!{struct ADAPTER_STATUS { + adapter_address: [UCHAR; 6], + rev_major: UCHAR, + reserved0: UCHAR, + adapter_type: UCHAR, + rev_minor: UCHAR, + duration: WORD, + frmr_recv: WORD, + frmr_xmit: WORD, + iframe_recv_err: WORD, + xmit_aborts: WORD, + xmit_success: DWORD, + recv_success: DWORD, + iframe_xmit_err: WORD, + recv_buff_unavail: WORD, + t1_timeouts: WORD, + ti_timeouts: WORD, + reserved1: DWORD, + free_ncbs: WORD, + max_cfg_ncbs: WORD, + max_ncbs: WORD, + xmit_buf_unavail: WORD, + max_dgram_size: WORD, + pending_sess: WORD, + max_cfg_sess: WORD, + max_sess: WORD, + max_sess_pkt_size: WORD, + name_count: WORD, +}} +pub type PADAPTER_STATUS = *mut ADAPTER_STATUS; +STRUCT!{struct NAME_BUFFER { + name: [UCHAR; NCBNAMSZ], + name_num: UCHAR, + name_flags: UCHAR, +}} +pub type PNAME_BUFFER = *mut NAME_BUFFER; +pub const NAME_FLAGS_MASK: UCHAR = 0x87; +pub const GROUP_NAME: UCHAR = 0x80; +pub const UNIQUE_NAME: UCHAR = 0x00; +pub const REGISTERING: UCHAR = 0x00; +pub const REGISTERED: UCHAR = 0x04; +pub const DEREGISTERED: UCHAR = 0x05; +pub const DUPLICATE: UCHAR = 0x06; +pub const DUPLICATE_DEREG: UCHAR = 0x07; +STRUCT!{struct SESSION_HEADER { + sess_name: UCHAR, + num_sess: UCHAR, + rcv_dg_outstanding: UCHAR, + rcv_any_outstanding: UCHAR, +}} +pub type PSESSION_HEADER = *mut SESSION_HEADER; +STRUCT!{struct SESSION_BUFFER { + lsn: UCHAR, + state: UCHAR, + local_name: [UCHAR; NCBNAMSZ], + remote_name: [UCHAR; NCBNAMSZ], + rcvs_outstanding: UCHAR, + sends_outstanding: UCHAR, +}} +pub type PSESSION_BUFFER = *mut SESSION_BUFFER; +pub const LISTEN_OUTSTANDING: UCHAR = 0x01; +pub const CALL_PENDING: UCHAR = 0x02; +pub const SESSION_ESTABLISHED: UCHAR = 0x03; +pub const HANGUP_PENDING: UCHAR = 0x04; +pub const HANGUP_COMPLETE: UCHAR = 0x05; +pub const SESSION_ABORTED: UCHAR = 0x06; +STRUCT!{struct LANA_ENUM { + length: UCHAR, + lana: [UCHAR; MAX_LANA + 1], +}} +pub type PLANA_ENUM = *mut LANA_ENUM; +STRUCT!{struct FIND_NAME_HEADER { + node_count: WORD, + reserved: UCHAR, + unique_group: UCHAR, +}} +pub type PFIND_NAME_HEADER = *mut FIND_NAME_HEADER; +STRUCT!{struct FIND_NAME_BUFFER { + length: UCHAR, + access_control: UCHAR, + frame_control: UCHAR, + destination_addr: [UCHAR; 6], + source_addr: [UCHAR; 6], + routing_info: [UCHAR; 18], +}} +pub type PFIND_NAME_BUFFER = *mut FIND_NAME_BUFFER; +STRUCT!{struct ACTION_HEADER { + transport_id: ULONG, + action_code: USHORT, + reserved: USHORT, +}} +pub type PACTION_HEADER = *mut ACTION_HEADER; +pub const ALL_TRANSPORTS: ULONG = 0x0000004d; +pub const MS_NBF: ULONG = 0x46424e4d; +pub const NCBCALL: UCHAR = 0x10; +pub const NCBLISTEN: UCHAR = 0x11; +pub const NCBHANGUP: UCHAR = 0x12; +pub const NCBSEND: UCHAR = 0x14; +pub const NCBRECV: UCHAR = 0x15; +pub const NCBRECVANY: UCHAR = 0x16; +pub const NCBCHAINSEND: UCHAR = 0x17; +pub const NCBDGSEND: UCHAR = 0x20; +pub const NCBDGRECV: UCHAR = 0x21; +pub const NCBDGSENDBC: UCHAR = 0x22; +pub const NCBADDNAME: UCHAR = 0x30; +pub const NCBDELNAME: UCHAR = 0x31; +pub const NCBRESET: UCHAR = 0x32; +pub const NCBASTAT: UCHAR = 0x33; +pub const NCBSSTAT: UCHAR = 0x34; +pub const NCBCANCEL: UCHAR = 0x35; +pub const NCBADDGRNAME: UCHAR = 0x36; +pub const NCBENUM: UCHAR = 0x37; +pub const NCBUNLINK: UCHAR = 0x70; +pub const NCBSENDNA: UCHAR = 0x71; +pub const NCBCHAINSENDNA: UCHAR = 0x72; +pub const NCBLANSTALERT: UCHAR = 0x73; +pub const NCBACTION: UCHAR = 0x77; +pub const NCBFINDNAME: UCHAR = 0x78; +pub const NCBTRACE: UCHAR = 0x79; +pub const ASYNCH: UCHAR = 0x80; +pub const NRC_GOODRET: UCHAR = 0x00; +pub const NRC_BUFLEN: UCHAR = 0x01; +pub const NRC_ILLCMD: UCHAR = 0x03; +pub const NRC_CMDTMO: UCHAR = 0x05; +pub const NRC_INCOMP: UCHAR = 0x06; +pub const NRC_BADDR: UCHAR = 0x07; +pub const NRC_SNUMOUT: UCHAR = 0x08; +pub const NRC_NORES: UCHAR = 0x09; +pub const NRC_SCLOSED: UCHAR = 0x0a; +pub const NRC_CMDCAN: UCHAR = 0x0b; +pub const NRC_DUPNAME: UCHAR = 0x0d; +pub const NRC_NAMTFUL: UCHAR = 0x0e; +pub const NRC_ACTSES: UCHAR = 0x0f; +pub const NRC_LOCTFUL: UCHAR = 0x11; +pub const NRC_REMTFUL: UCHAR = 0x12; +pub const NRC_ILLNN: UCHAR = 0x13; +pub const NRC_NOCALL: UCHAR = 0x14; +pub const NRC_NOWILD: UCHAR = 0x15; +pub const NRC_INUSE: UCHAR = 0x16; +pub const NRC_NAMERR: UCHAR = 0x17; +pub const NRC_SABORT: UCHAR = 0x18; +pub const NRC_NAMCONF: UCHAR = 0x19; +pub const NRC_IFBUSY: UCHAR = 0x21; +pub const NRC_TOOMANY: UCHAR = 0x22; +pub const NRC_BRIDGE: UCHAR = 0x23; +pub const NRC_CANOCCR: UCHAR = 0x24; +pub const NRC_CANCEL: UCHAR = 0x26; +pub const NRC_DUPENV: UCHAR = 0x30; +pub const NRC_ENVNOTDEF: UCHAR = 0x34; +pub const NRC_OSRESNOTAV: UCHAR = 0x35; +pub const NRC_MAXAPPS: UCHAR = 0x36; +pub const NRC_NOSAPS: UCHAR = 0x37; +pub const NRC_NORESOURCES: UCHAR = 0x38; +pub const NRC_INVADDRESS: UCHAR = 0x39; +pub const NRC_INVDDID: UCHAR = 0x3B; +pub const NRC_LOCKFAIL: UCHAR = 0x3C; +pub const NRC_OPENERR: UCHAR = 0x3f; +pub const NRC_SYSTEM: UCHAR = 0x40; +pub const NRC_PENDING: UCHAR = 0xff; +extern "system" { + pub fn Netbios( + pncb: PNCB, + ) -> UCHAR; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ncrypt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ncrypt.rs new file mode 100644 index 0000000..5f5431e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ncrypt.rs @@ -0,0 +1,88 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{SIZE_T, ULONG_PTR}; +use shared::bcrypt::{BCRYPT_NO_KEY_VALIDATION, BCryptBufferDesc}; +use shared::minwindef::{DWORD, LPVOID, PBYTE}; +use um::winnt::{LONG, LPCWSTR, VOID}; +pub type SECURITY_STATUS = LONG; +pub type HCRYPTPROV = ULONG_PTR; +pub type HCRYPTKEY = ULONG_PTR; +pub type HCRYPTHASH = ULONG_PTR; +FN!{stdcall PFN_NCRYPT_ALLOC( + cbSize: SIZE_T, +) -> LPVOID} +FN!{stdcall PFN_NCRYPT_FREE( + pv: LPVOID, +) -> VOID} +STRUCT!{struct NCRYPT_ALLOC_PARA { + cbSize: DWORD, + pfnAlloc: PFN_NCRYPT_ALLOC, + pfnFree: PFN_NCRYPT_FREE, +}} +pub type NCryptBufferDesc = BCryptBufferDesc; +pub type NCRYPT_HANDLE = ULONG_PTR; +pub type NCRYPT_PROV_HANDLE = ULONG_PTR; +pub type NCRYPT_KEY_HANDLE = ULONG_PTR; +pub type NCRYPT_HASH_HANDLE = ULONG_PTR; +pub type NCRYPT_SECRET_HANDLE = ULONG_PTR; +pub const NCRYPT_NO_PADDING_FLAG: DWORD = 0x00000001; +pub const NCRYPT_PAD_PKCS1_FLAG: DWORD = 0x00000002; +pub const NCRYPT_PAD_OAEP_FLAG: DWORD = 0x00000004; +pub const NCRYPT_PAD_PSS_FLAG: DWORD = 0x00000008; +pub const NCRYPT_PAD_CIPHER_FLAG: DWORD = 0x00000010; +pub const NCRYPT_ATTESTATION_FLAG: DWORD = 0x00000020; +pub const NCRYPT_SEALING_FLAG: DWORD = 0x00000100; +pub const NCRYPT_REGISTER_NOTIFY_FLAG: DWORD = 0x00000001; +pub const NCRYPT_UNREGISTER_NOTIFY_FLAG: DWORD = 0x00000002; +pub const NCRYPT_NO_KEY_VALIDATION: DWORD = BCRYPT_NO_KEY_VALIDATION; +pub const NCRYPT_MACHINE_KEY_FLAG: DWORD = 0x00000020; +pub const NCRYPT_SILENT_FLAG: DWORD = 0x00000040; +pub const NCRYPT_OVERWRITE_KEY_FLAG: DWORD = 0x00000080; +pub const NCRYPT_WRITE_KEY_TO_LEGACY_STORE_FLAG: DWORD = 0x00000200; +pub const NCRYPT_DO_NOT_FINALIZE_FLAG: DWORD = 0x00000400; +pub const NCRYPT_EXPORT_LEGACY_FLAG: DWORD = 0x00000800; +pub const NCRYPT_IGNORE_DEVICE_STATE_FLAG: DWORD = 0x00001000; +pub const NCRYPT_TREAT_NIST_AS_GENERIC_ECC_FLAG: DWORD = 0x00002000; +pub const NCRYPT_NO_CACHED_PASSWORD: DWORD = 0x00004000; +pub const NCRYPT_PROTECT_TO_LOCAL_SYSTEM: DWORD = 0x00008000; +pub const NCRYPT_PERSIST_ONLY_FLAG: DWORD = 0x40000000; +pub const NCRYPT_PERSIST_FLAG: DWORD = 0x80000000; +pub const NCRYPT_PREFER_VIRTUAL_ISOLATION_FLAG: DWORD = 0x00010000; +pub const NCRYPT_USE_VIRTUAL_ISOLATION_FLAG: DWORD = 0x00020000; +pub const NCRYPT_USE_PER_BOOT_KEY_FLAG: DWORD = 0x00040000; +extern "system" { + pub fn NCryptOpenStorageProvider( + phProvider: *mut NCRYPT_PROV_HANDLE, + pszProviderName: LPCWSTR, + dwFlags: DWORD, + ) -> SECURITY_STATUS; +} +pub const NCRYPT_ALLOW_EXPORT_FLAG: DWORD = 0x00000001; +pub const NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG: DWORD = 0x00000002; +pub const NCRYPT_ALLOW_ARCHIVING_FLAG: DWORD = 0x00000004; +pub const NCRYPT_ALLOW_PLAINTEXT_ARCHIVING_FLAG: DWORD = 0x00000008; +extern "system" { + pub fn NCryptSetProperty( + hObject: NCRYPT_HANDLE, + pszProperty: LPCWSTR, + pbInput: PBYTE, + cbInput: DWORD, + dwFlags: DWORD, + ) -> SECURITY_STATUS; + pub fn NCryptImportKey( + hProvider: NCRYPT_PROV_HANDLE, + hImportKey: NCRYPT_KEY_HANDLE, + pszBlobType: LPCWSTR, + pParameterList: *const NCryptBufferDesc, + phKey: *mut NCRYPT_KEY_HANDLE, + pbData: PBYTE, + cbData: DWORD, + dwFlags: DWORD, + ) -> SECURITY_STATUS; + pub fn NCryptFreeObject( + hObject: NCRYPT_HANDLE, + ) -> SECURITY_STATUS; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ntlsa.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ntlsa.rs new file mode 100644 index 0000000..0e283b1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ntlsa.rs @@ -0,0 +1,1530 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{SIZE_T, ULONG_PTR}; +use shared::guiddef::GUID; +use shared::minwindef::{PUCHAR, PULONG, UCHAR, ULONG, USHORT}; +use shared::ntdef::{NTSTATUS, PNTSTATUS}; +use um::lsalookup::{ + LSA_TRUST_INFORMATION, LSA_UNICODE_STRING, PLSA_OBJECT_ATTRIBUTES, + PLSA_REFERENCED_DOMAIN_LIST, PLSA_STRING, PLSA_TRANSLATED_NAME, PLSA_TRANSLATED_SID2, + PLSA_TRUST_INFORMATION, PLSA_UNICODE_STRING, +}; +use um::ntsecapi::PLSA_HANDLE; +use um::subauth::{PUNICODE_STRING, UNICODE_STRING}; +use um::winnt::{ + ACCESS_MASK, ANYSIZE_ARRAY, BOOLEAN, HANDLE, LARGE_INTEGER, LONG, LUID, PBOOLEAN, + PCLAIMS_BLOB, PHANDLE, PLARGE_INTEGER, PLUID, PPRIVILEGE_SET, PQUOTA_LIMITS, + PSECURITY_DESCRIPTOR, PSHORT, PSID, PTOKEN_GROUPS, PTOKEN_PRIVILEGES, PTOKEN_SOURCE, PVOID, + PWSTR, QUOTA_LIMITS, SECURITY_INFORMATION, SID_NAME_USE, STANDARD_RIGHTS_EXECUTE, + STANDARD_RIGHTS_READ, STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_WRITE, TOKEN_DEFAULT_DACL, + TOKEN_DEVICE_CLAIMS, TOKEN_OWNER, TOKEN_PRIMARY_GROUP, TOKEN_USER, TOKEN_USER_CLAIMS, +}; +pub type LSA_OPERATIONAL_MODE = ULONG; +pub type PLSA_OPERATIONAL_MODE = *mut LSA_OPERATIONAL_MODE; +pub const LSA_MODE_PASSWORD_PROTECTED: ULONG = 0x00000001; +pub const LSA_MODE_INDIVIDUAL_ACCOUNTS: ULONG = 0x00000002; +pub const LSA_MODE_MANDATORY_ACCESS: ULONG = 0x00000004; +pub const LSA_MODE_LOG_FULL: ULONG = 0x00000008; +pub const LSA_MAXIMUM_SID_COUNT: SIZE_T = 0x00000100; +pub const LSA_MAXIMUM_ENUMERATION_LENGTH: SIZE_T = 32000; +pub const LSA_CALL_LICENSE_SERVER: ULONG = 0x80000000; +ENUM!{enum SECURITY_LOGON_TYPE { + UndefinedLogonType = 0, + Interactive = 2, + Network, + Batch, + Service, + Proxy, + Unlock, + NetworkCleartext, + NewCredentials, + RemoteInteractive, + CachedInteractive, + CachedRemoteInteractive, + CachedUnlock, +}} +pub type PSECURITY_LOGON_TYPE = *mut SECURITY_LOGON_TYPE; +pub const SECURITY_ACCESS_INTERACTIVE_LOGON: ULONG = 0x00000001; +pub const SECURITY_ACCESS_NETWORK_LOGON: ULONG = 0x00000002; +pub const SECURITY_ACCESS_BATCH_LOGON: ULONG = 0x00000004; +pub const SECURITY_ACCESS_SERVICE_LOGON: ULONG = 0x00000010; +pub const SECURITY_ACCESS_PROXY_LOGON: ULONG = 0x00000020; +pub const SECURITY_ACCESS_DENY_INTERACTIVE_LOGON: ULONG = 0x00000040; +pub const SECURITY_ACCESS_DENY_NETWORK_LOGON: ULONG = 0x00000080; +pub const SECURITY_ACCESS_DENY_BATCH_LOGON: ULONG = 0x00000100; +pub const SECURITY_ACCESS_DENY_SERVICE_LOGON: ULONG = 0x00000200; +pub const SECURITY_ACCESS_REMOTE_INTERACTIVE_LOGON: ULONG = 0x00000400; +pub const SECURITY_ACCESS_DENY_REMOTE_INTERACTIVE_LOGON: ULONG = 0x00000800; +ENUM!{enum SE_ADT_PARAMETER_TYPE { + SeAdtParmTypeNone = 0, + SeAdtParmTypeString, + SeAdtParmTypeFileSpec, + SeAdtParmTypeUlong, + SeAdtParmTypeSid, + SeAdtParmTypeLogonId, + SeAdtParmTypeNoLogonId, + SeAdtParmTypeAccessMask, + SeAdtParmTypePrivs, + SeAdtParmTypeObjectTypes, + SeAdtParmTypeHexUlong, + SeAdtParmTypePtr, + SeAdtParmTypeTime, + SeAdtParmTypeGuid, + SeAdtParmTypeLuid, + SeAdtParmTypeHexInt64, + SeAdtParmTypeStringList, + SeAdtParmTypeSidList, + SeAdtParmTypeDuration, + SeAdtParmTypeUserAccountControl, + SeAdtParmTypeNoUac, + SeAdtParmTypeMessage, + SeAdtParmTypeDateTime, + SeAdtParmTypeSockAddr, + SeAdtParmTypeSD, + SeAdtParmTypeLogonHours, + SeAdtParmTypeLogonIdNoSid, + SeAdtParmTypeUlongNoConv, + SeAdtParmTypeSockAddrNoPort, + SeAdtParmTypeAccessReason, + SeAdtParmTypeStagingReason, + SeAdtParmTypeResourceAttribute, + SeAdtParmTypeClaims, + SeAdtParmTypeLogonIdAsSid, + SeAdtParmTypeMultiSzString, + SeAdtParmTypeLogonIdEx, +}} +pub type PSE_ADT_PARAMETER_TYPE = *mut SE_ADT_PARAMETER_TYPE; +pub const SE_ADT_OBJECT_ONLY: USHORT = 0x1; +STRUCT!{struct SE_ADT_OBJECT_TYPE { + ObjectType: GUID, + Flags: USHORT, + Level: USHORT, + AccessMask: ACCESS_MASK, +}} +pub type PSE_ADT_OBJECT_TYPE = *mut SE_ADT_OBJECT_TYPE; +STRUCT!{struct SE_ADT_PARAMETER_ARRAY_ENTRY { + Type: SE_ADT_PARAMETER_TYPE, + Length: ULONG, + Data: [ULONG_PTR; 2], + Address: PVOID, +}} +pub type PSE_ADT_PARAMETER_ARRAY_ENTRY = *mut SE_ADT_PARAMETER_ARRAY_ENTRY; +STRUCT!{struct SE_ADT_ACCESS_REASON { + AccessMask: ACCESS_MASK, + AccessReasons: [ULONG; 32], + ObjectTypeIndex: ULONG, + AccessGranted: ULONG, + SecurityDescriptor: PSECURITY_DESCRIPTOR, +}} +pub type PSE_ADT_ACCESS_REASON = *mut SE_ADT_ACCESS_REASON; +STRUCT!{struct SE_ADT_CLAIMS { + Length: ULONG, + Claims: PCLAIMS_BLOB, +}} +pub type PSE_ADT_CLAIMS = *mut SE_ADT_CLAIMS; +pub const SE_MAX_AUDIT_PARAMETERS: SIZE_T = 32; +pub const SE_MAX_GENERIC_AUDIT_PARAMETERS: SIZE_T = 28; +STRUCT!{struct SE_ADT_PARAMETER_ARRAY { + CategoryId: ULONG, + AuditId: ULONG, + ParameterCount: ULONG, + Length: ULONG, + FlatSubCategoryId: USHORT, + Type: USHORT, + Flags: ULONG, + Parameters: [SE_ADT_PARAMETER_ARRAY_ENTRY; SE_MAX_AUDIT_PARAMETERS], +}} +pub type PSE_ADT_PARAMETER_ARRAY = *mut SE_ADT_PARAMETER_ARRAY; +STRUCT!{struct SE_ADT_PARAMETER_ARRAY_EX { + CategoryId: ULONG, + AuditId: ULONG, + Version: ULONG, + ParameterCount: ULONG, + Length: ULONG, + FlatSubCategoryId: USHORT, + Type: USHORT, + Flags: ULONG, + Parameters: [SE_ADT_PARAMETER_ARRAY_ENTRY; SE_MAX_AUDIT_PARAMETERS], +}} +pub type PSE_ADT_PARAMETER_ARRAY_EX = *mut SE_ADT_PARAMETER_ARRAY_EX; +pub const SE_ADT_PARAMETERS_SELF_RELATIVE: ULONG = 0x00000001; +pub const SE_ADT_PARAMETERS_SEND_TO_LSA: ULONG = 0x00000002; +pub const SE_ADT_PARAMETER_EXTENSIBLE_AUDIT: ULONG = 0x00000004; +pub const SE_ADT_PARAMETER_GENERIC_AUDIT: ULONG = 0x00000008; +pub const SE_ADT_PARAMETER_WRITE_SYNCHRONOUS: ULONG = 0x00000010; +#[cfg(target_pointer_width = "32")] +#[inline] +pub fn LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE( + AuditParameters: SE_ADT_PARAMETER_ARRAY, +) -> SIZE_T { + 664 // FIXME: sizeof::<SE_ADT_PARAMETER_ARRAY>() + - (20 // FIXME: sizeof::<SE_ADT_PARAMETER_ARRAY_ENTRY>() + * (SE_MAX_AUDIT_PARAMETERS - AuditParameters.ParameterCount as SIZE_T)) +} +#[cfg(target_pointer_width = "64")] +#[inline] +pub fn LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE( + AuditParameters: SE_ADT_PARAMETER_ARRAY, +) -> SIZE_T { + 1048 // FIXME: sizeof::<SE_ADT_PARAMETER_ARRAY>() + - (32 // FIXME: sizeof::<SE_ADT_PARAMETER_ARRAY_ENTRY>() + * (SE_MAX_AUDIT_PARAMETERS - AuditParameters.ParameterCount as SIZE_T)) +} +STRUCT!{struct LSA_ADT_STRING_LIST_ENTRY { + Flags: ULONG, + String: UNICODE_STRING, +}} +pub type PLSA_ADT_STRING_LIST_ENTRY = *mut LSA_ADT_STRING_LIST_ENTRY; +STRUCT!{struct LSA_ADT_STRING_LIST { + cStrings: ULONG, + String: PLSA_ADT_STRING_LIST_ENTRY, +}} +pub type PLSA_ADT_STRING_LIST = *mut LSA_ADT_STRING_LIST; +STRUCT!{struct LSA_ADT_SID_LIST_ENTRY { + Flags: ULONG, + Sid: PSID, +}} +pub type PLSA_ADT_SID_LIST_ENTRY = *mut LSA_ADT_SID_LIST_ENTRY; +STRUCT!{struct LSA_ADT_SID_LIST { + cSids: ULONG, + Sid: PLSA_ADT_SID_LIST_ENTRY, +}} +pub type PLSA_ADT_SID_LIST = *mut LSA_ADT_SID_LIST; +pub const LSA_ADT_SECURITY_SOURCE_NAME: &'static str = "Microsoft-Windows-Security-Auditing"; +pub const LSA_ADT_LEGACY_SECURITY_SOURCE_NAME: &'static str = "Security"; +pub const SE_ADT_POLICY_AUDIT_EVENT_TYPE_EX_BEGIN: ULONG = 100; +ENUM!{enum POLICY_AUDIT_EVENT_TYPE_EX { + iSystem_SecurityStateChange = SE_ADT_POLICY_AUDIT_EVENT_TYPE_EX_BEGIN, + iSystem_SecuritySubsystemExtension, + iSystem_Integrity, + iSystem_IPSecDriverEvents, + iSystem_Others, + iLogon_Logon, + iLogon_Logoff, + iLogon_AccountLockout, + iLogon_IPSecMainMode, + iLogon_SpecialLogon, + iLogon_IPSecQuickMode, + iLogon_IPSecUsermode, + iLogon_Others, + iLogon_NPS, + iLogon_Claims, + iLogon_Groups, + iObjectAccess_FileSystem, + iObjectAccess_Registry, + iObjectAccess_Kernel, + iObjectAccess_Sam, + iObjectAccess_Other, + iObjectAccess_CertificationAuthority, + iObjectAccess_ApplicationGenerated, + iObjectAccess_HandleBasedAudits, + iObjectAccess_Share, + iObjectAccess_FirewallPacketDrops, + iObjectAccess_FirewallConnection, + iObjectAccess_DetailedFileShare, + iObjectAccess_RemovableStorage, + iObjectAccess_CbacStaging, + iPrivilegeUse_Sensitive, + iPrivilegeUse_NonSensitive, + iPrivilegeUse_Others, + iDetailedTracking_ProcessCreation, + iDetailedTracking_ProcessTermination, + iDetailedTracking_DpapiActivity, + iDetailedTracking_RpcCall, + iDetailedTracking_PnpActivity, + iDetailedTracking_TokenRightAdjusted, + iPolicyChange_AuditPolicy, + iPolicyChange_AuthenticationPolicy, + iPolicyChange_AuthorizationPolicy, + iPolicyChange_MpsscvRulePolicy, + iPolicyChange_WfpIPSecPolicy, + iPolicyChange_Others, + iAccountManagement_UserAccount, + iAccountManagement_ComputerAccount, + iAccountManagement_SecurityGroup, + iAccountManagement_DistributionGroup, + iAccountManagement_ApplicationGroup, + iAccountManagement_Others, + iDSAccess_DSAccess, + iDSAccess_AdAuditChanges, + iDS_Replication, + iDS_DetailedReplication, + iAccountLogon_CredentialValidation, + iAccountLogon_Kerberos, + iAccountLogon_Others, + iAccountLogon_KerbCredentialValidation, + iUnknownSubCategory = 999, +}} +pub type PPOLICY_AUDIT_EVENT_TYPE_EX = *mut POLICY_AUDIT_EVENT_TYPE_EX; +ENUM!{enum POLICY_AUDIT_EVENT_TYPE { + AuditCategorySystem = 0, + AuditCategoryLogon, + AuditCategoryObjectAccess, + AuditCategoryPrivilegeUse, + AuditCategoryDetailedTracking, + AuditCategoryPolicyChange, + AuditCategoryAccountManagement, + AuditCategoryDirectoryServiceAccess, + AuditCategoryAccountLogon, +}} +pub type PPOLICY_AUDIT_EVENT_TYPE = *mut POLICY_AUDIT_EVENT_TYPE; +pub const POLICY_AUDIT_EVENT_UNCHANGED: ULONG = 0x00000000; +pub const POLICY_AUDIT_EVENT_SUCCESS: ULONG = 0x00000001; +pub const POLICY_AUDIT_EVENT_FAILURE: ULONG = 0x00000002; +pub const POLICY_AUDIT_EVENT_NONE: ULONG = 0x00000004; +pub const POLICY_AUDIT_EVENT_MASK: ULONG = POLICY_AUDIT_EVENT_SUCCESS | POLICY_AUDIT_EVENT_FAILURE + | POLICY_AUDIT_EVENT_UNCHANGED | POLICY_AUDIT_EVENT_NONE; +#[inline] +pub fn LSA_SUCCESS(Error: NTSTATUS) -> bool { + (Error as LONG) >= 0 +} +extern "system" { + pub fn LsaRegisterLogonProcess( + LogonProcessName: PLSA_STRING, + LsaHandle: PHANDLE, + SecurityMode: PLSA_OPERATIONAL_MODE, + ) -> NTSTATUS; + pub fn LsaLogonUser( + LsaHandle: HANDLE, + OriginName: PLSA_STRING, + LogonType: SECURITY_LOGON_TYPE, + AuthenticationPackage: ULONG, + AuthenticationInformation: PVOID, + AuthenticationInformationLength: ULONG, + LocalGroups: PTOKEN_GROUPS, + SourceContext: PTOKEN_SOURCE, + ProfileBuffer: *mut PVOID, + ProfileBufferLength: PULONG, + LogonId: PLUID, + Token: PHANDLE, + Quotas: PQUOTA_LIMITS, + SubStatus: PNTSTATUS, + ) -> NTSTATUS; + pub fn LsaLookupAuthenticationPackage( + LsaHandle: HANDLE, + PackageName: PLSA_STRING, + AuthenticationPackage: PULONG, + ) -> NTSTATUS; + pub fn LsaFreeReturnBuffer( + Buffer: PVOID, + ) -> NTSTATUS; + pub fn LsaCallAuthenticationPackage( + LsaHandle: HANDLE, + AuthenticationPackage: ULONG, + ProtocolSubmitBuffer: PVOID, + SubmitBufferLength: ULONG, + ProtocolReturnBuffer: *mut PVOID, + ReturnBufferLength: PULONG, + ProtocolStatus: PNTSTATUS, + ) -> NTSTATUS; + pub fn LsaDeregisterLogonProcess( + LsaHandle: HANDLE, + ) -> NTSTATUS; + pub fn LsaConnectUntrusted( + LsaHandle: PHANDLE, + ) -> NTSTATUS; +} +extern "C" { + pub fn LsaInsertProtectedProcessAddress( + BufferAddress: PVOID, + BufferSize: ULONG, + ) -> NTSTATUS; + pub fn LsaRemoveProtectedProcessAddress( + BufferAddress: PVOID, + BufferSize: ULONG, + ) -> NTSTATUS; +} +FN!{stdcall PFN_LSA_CALL_AUTH_PKG( + LsaHandle: HANDLE, + AuthenticationPackage: ULONG, + ProtocolSubmitBuffer: PVOID, + SubmitBufferLength: ULONG, + ProtocolReturnBuffer: *mut PVOID, + ReturnBufferLength: PULONG, + ProtocolStatus: PNTSTATUS, +) -> NTSTATUS} +FN!{stdcall PFN_LSA_DEREGISTER_PROC( + LsaHandle: HANDLE, +) -> NTSTATUS} +FN!{stdcall PFN_LSA_FREE_BUFFER( + Buffer: PVOID, +) -> NTSTATUS} +FN!{stdcall PFN_LSA_LOGON_USER( + LsaHandle: HANDLE, + OriginName: PLSA_STRING, + LogonType: SECURITY_LOGON_TYPE, + AuthenticationPackage: ULONG, + AuthenticationInformation: PVOID, + AuthenticationInformationLength: ULONG, + LocalGroups: PTOKEN_GROUPS, + SourceContext: PTOKEN_SOURCE, + ProfileBuffer: *mut PVOID, + ProfileBufferLength: PULONG, + LogonId: PLUID, + Token: PHANDLE, + Quotas: PQUOTA_LIMITS, + SubStatus: PNTSTATUS, +) -> NTSTATUS} +FN!{stdcall PFN_LOOKUP_AUTH_PKG( + LsaHandle: HANDLE, + PackageName: PLSA_STRING, + AuthenticationPackage: PULONG, +) -> NTSTATUS} +FN!{stdcall PFN_LSA_REGISTER_PROC( + LogonProcessName: PLSA_STRING, + LsaHandle: PHANDLE, + SecurityMode: PLSA_OPERATIONAL_MODE, +) -> NTSTATUS} +STRUCT!{struct LSA_AUTH_CALLBACKS { + LsaCallAuthPkgFn: PFN_LSA_CALL_AUTH_PKG, + LsaDeregisterProcFn: PFN_LSA_DEREGISTER_PROC, + LsaFreeReturnBufferFn: PFN_LSA_FREE_BUFFER, + LsaLogonUserFn: PFN_LSA_LOGON_USER, + LsaLookupAuthPkgFn: PFN_LOOKUP_AUTH_PKG, + LsaRegisterProcFn: PFN_LSA_REGISTER_PROC, +}} +pub type PLSA_AUTH_CALLBACKS = *mut LSA_AUTH_CALLBACKS; +pub type PCLSA_AUTH_CALLBACKS = *const LSA_AUTH_CALLBACKS; +pub type PLSA_CLIENT_REQUEST = *mut PVOID; +ENUM!{enum LSA_TOKEN_INFORMATION_TYPE { + LsaTokenInformationNull, + LsaTokenInformationV1, + LsaTokenInformationV2, + LsaTokenInformationV3, +}} +pub type PLSA_TOKEN_INFORMATION_TYPE = *mut LSA_TOKEN_INFORMATION_TYPE; +STRUCT!{struct LSA_TOKEN_INFORMATION_NULL { + ExpirationTime: LARGE_INTEGER, + Groups: PTOKEN_GROUPS, +}} +pub type PLSA_TOKEN_INFORMATION_NULL = *mut LSA_TOKEN_INFORMATION_NULL; +STRUCT!{struct LSA_TOKEN_INFORMATION_V1 { + ExpirationTime: LARGE_INTEGER, + User: TOKEN_USER, + Groups: PTOKEN_GROUPS, + PrimaryGroup: TOKEN_PRIMARY_GROUP, + Privileges: PTOKEN_PRIVILEGES, + Owner: TOKEN_OWNER, + DefaultDacl: TOKEN_DEFAULT_DACL, +}} +pub type PLSA_TOKEN_INFORMATION_V1 = *mut LSA_TOKEN_INFORMATION_V1; +pub type LSA_TOKEN_INFORMATION_V2 = LSA_TOKEN_INFORMATION_V1; +pub type PLSA_TOKEN_INFORMATION_V2 = *mut LSA_TOKEN_INFORMATION_V2; +STRUCT!{struct LSA_TOKEN_INFORMATION_V3 { + ExpirationTime: LARGE_INTEGER, + User: TOKEN_USER, + Groups: PTOKEN_GROUPS, + PrimaryGroup: TOKEN_PRIMARY_GROUP, + Privileges: PTOKEN_PRIVILEGES, + Owner: TOKEN_OWNER, + DefaultDacl: TOKEN_DEFAULT_DACL, + UserClaims: TOKEN_USER_CLAIMS, + DeviceClaims: TOKEN_DEVICE_CLAIMS, + DeviceGroups: PTOKEN_GROUPS, +}} +pub type PLSA_TOKEN_INFORMATION_V3 = *mut LSA_TOKEN_INFORMATION_V3; +FN!{stdcall PLSA_CREATE_LOGON_SESSION( + LogonId: PLUID, +) -> NTSTATUS} +FN!{stdcall PLSA_DELETE_LOGON_SESSION( + LogonId: PLUID, +) -> NTSTATUS} +FN!{stdcall PLSA_ADD_CREDENTIAL( + LogonId: PLUID, + AuthenticationPackage: ULONG, + PrimaryKeyValue: PLSA_STRING, + Credentials: PLSA_STRING, +) -> NTSTATUS} +FN!{stdcall PLSA_GET_CREDENTIALS( + LogonId: PLUID, + AuthenticationPackage: ULONG, + QueryContext: PULONG, + RetrieveAllCredentials: BOOLEAN, + PrimaryKeyValue: PLSA_STRING, + PrimaryKeyLength: PULONG, + Credentials: PLSA_STRING, +) -> NTSTATUS} +FN!{stdcall PLSA_DELETE_CREDENTIAL( + LogonId: PLUID, + AuthenticationPackage: ULONG, + PrimaryKeyValue: PLSA_STRING, +) -> NTSTATUS} +FN!{stdcall PLSA_ALLOCATE_LSA_HEAP( + Length: ULONG, +) -> PVOID} +FN!{stdcall PLSA_FREE_LSA_HEAP( + Base: PVOID, +) -> ()} +FN!{stdcall PLSA_ALLOCATE_PRIVATE_HEAP( + Length: SIZE_T, +) -> PVOID} +FN!{stdcall PLSA_FREE_PRIVATE_HEAP( + Base: PVOID, +) -> ()} +FN!{stdcall PLSA_ALLOCATE_CLIENT_BUFFER( + ClientRequest: PLSA_CLIENT_REQUEST, + LengthRequired: ULONG, + ClientBaseAddress: *mut PVOID, +) -> NTSTATUS} +FN!{stdcall PLSA_FREE_CLIENT_BUFFER( + ClientRequest: PLSA_CLIENT_REQUEST, + ClientBaseAddress: PVOID, +) -> NTSTATUS} +FN!{stdcall PLSA_COPY_TO_CLIENT_BUFFER( + ClientRequest: PLSA_CLIENT_REQUEST, + Length: ULONG, + ClientBaseAddress: PVOID, + BufferToCopy: PVOID, +) -> NTSTATUS} +FN!{stdcall PLSA_COPY_FROM_CLIENT_BUFFER( + ClientRequest: PLSA_CLIENT_REQUEST, + Length: ULONG, + BufferToCopy: PVOID, + ClientBaseAddress: PVOID, +) -> NTSTATUS} +STRUCT!{struct LSA_DISPATCH_TABLE { + CreateLogonSession: PLSA_CREATE_LOGON_SESSION, + DeleteLogonSession: PLSA_DELETE_LOGON_SESSION, + AddCredential: PLSA_ADD_CREDENTIAL, + GetCredentials: PLSA_GET_CREDENTIALS, + DeleteCredential: PLSA_DELETE_CREDENTIAL, + AllocateLsaHeap: PLSA_ALLOCATE_LSA_HEAP, + FreeLsaHeap: PLSA_FREE_LSA_HEAP, + AllocateClientBuffer: PLSA_ALLOCATE_CLIENT_BUFFER, + FreeClientBuffer: PLSA_FREE_CLIENT_BUFFER, + CopyToClientBuffer: PLSA_COPY_TO_CLIENT_BUFFER, + CopyFromClientBuffer: PLSA_COPY_FROM_CLIENT_BUFFER, +}} +pub type PLSA_DISPATCH_TABLE = *mut LSA_DISPATCH_TABLE; +pub const LSA_AP_NAME_INITIALIZE_PACKAGE: &'static str = "LsaApInitializePackage"; +pub const LSA_AP_NAME_LOGON_USER: &'static str = "LsaApLogonUser"; +pub const LSA_AP_NAME_LOGON_USER_EX: &'static str = "LsaApLogonUserEx"; +pub const LSA_AP_NAME_CALL_PACKAGE: &'static str = "LsaApCallPackage"; +pub const LSA_AP_NAME_LOGON_TERMINATED: &'static str = "LsaApLogonTerminated"; +pub const LSA_AP_NAME_CALL_PACKAGE_UNTRUSTED: &'static str = "LsaApCallPackageUntrusted"; +pub const LSA_AP_NAME_CALL_PACKAGE_PASSTHROUGH: &'static str = "LsaApCallPackagePassthrough"; +FN!{stdcall PLSA_AP_INITIALIZE_PACKAGE( + AuthenticationPackageId: ULONG, + LsaDispatchTable: PLSA_DISPATCH_TABLE, + Database: PLSA_STRING, + Confidentiality: PLSA_STRING, + AuthenticationPackageName: *mut PLSA_STRING, +) -> NTSTATUS} +FN!{stdcall PLSA_AP_LOGON_USER( + ClientRequest: PLSA_CLIENT_REQUEST, + LogonType: SECURITY_LOGON_TYPE, + AuthenticationInformation: PVOID, + ClientAuthentication: PVOID, + AuthenticationInformationLength: ULONG, + ProfileBuffer: *mut PVOID, + ProfileBufferLength: PULONG, + LogonId: PLUID, + SubStatus: PNTSTATUS, + TokenInformationType: PLSA_TOKEN_INFORMATION_TYPE, + TokenInformation: *mut PVOID, + AccountName: *mut PLSA_UNICODE_STRING, + AuthenticatingAutority: *mut PLSA_UNICODE_STRING, +) -> NTSTATUS} +FN!{stdcall PLSA_AP_LOGON_USER_EX( + ClientRequest: PLSA_CLIENT_REQUEST, + LogonType: SECURITY_LOGON_TYPE, + AuthenticationInformation: PVOID, + ClientAuthentication: PVOID, + AuthenticationInformationLength: ULONG, + ProfileBuffer: *mut PVOID, + ProfileBufferLength: PULONG, + LogonId: PLUID, + SubStatus: PNTSTATUS, + TokenInformationType: PLSA_TOKEN_INFORMATION_TYPE, + TokenInformation: *mut PVOID, + AccountName: *mut PLSA_UNICODE_STRING, + AuthenticatingAutority: *mut PLSA_UNICODE_STRING, + MachineName: *mut PUNICODE_STRING, +) -> NTSTATUS} +FN!{stdcall PLSA_AP_CALL_PACKAGE( + ClientRequest: PLSA_CLIENT_REQUEST, + ProtocolSubmitBuffer: PVOID, + ClientBufferBase: PVOID, + SubmitBufferLength: ULONG, + ProtocolReturnBuffer: *mut PVOID, + ReturnBufferLength: PULONG, + ProtocolStatus: PNTSTATUS, +) -> NTSTATUS} +FN!{stdcall PLSA_AP_CALL_PACKAGE_PASSTHROUGH( + ClientRequest: PLSA_CLIENT_REQUEST, + ProtocolSubmitBuffer: PVOID, + ClientBufferBase: PVOID, + SubmitBufferLength: ULONG, + ProtocolReturnBuffer: *mut PVOID, + ReturnBufferLength: PULONG, + ProtocolStatus: PNTSTATUS, +) -> NTSTATUS} +FN!{stdcall PLSA_AP_LOGON_TERMINATED( + LogonId: PLUID, +) -> ()} +pub const POLICY_VIEW_LOCAL_INFORMATION: ULONG = 0x00000001; +pub const POLICY_VIEW_AUDIT_INFORMATION: ULONG = 0x00000002; +pub const POLICY_GET_PRIVATE_INFORMATION: ULONG = 0x00000004; +pub const POLICY_TRUST_ADMIN: ULONG = 0x00000008; +pub const POLICY_CREATE_ACCOUNT: ULONG = 0x00000010; +pub const POLICY_CREATE_SECRET: ULONG = 0x00000020; +pub const POLICY_CREATE_PRIVILEGE: ULONG = 0x00000040; +pub const POLICY_SET_DEFAULT_QUOTA_LIMITS: ULONG = 0x00000080; +pub const POLICY_SET_AUDIT_REQUIREMENTS: ULONG = 0x00000100; +pub const POLICY_AUDIT_LOG_ADMIN: ULONG = 0x00000200; +pub const POLICY_SERVER_ADMIN: ULONG = 0x00000400; +pub const POLICY_LOOKUP_NAMES: ULONG = 0x00000800; +pub const POLICY_NOTIFICATION: ULONG = 0x00001000; +pub const POLICY_ALL_ACCESS: ULONG = STANDARD_RIGHTS_REQUIRED | POLICY_VIEW_LOCAL_INFORMATION + | POLICY_VIEW_AUDIT_INFORMATION | POLICY_GET_PRIVATE_INFORMATION | POLICY_TRUST_ADMIN + | POLICY_CREATE_ACCOUNT | POLICY_CREATE_SECRET | POLICY_CREATE_PRIVILEGE + | POLICY_SET_DEFAULT_QUOTA_LIMITS | POLICY_SET_AUDIT_REQUIREMENTS | POLICY_AUDIT_LOG_ADMIN + | POLICY_SERVER_ADMIN | POLICY_LOOKUP_NAMES; +pub const POLICY_READ: ULONG = STANDARD_RIGHTS_READ | POLICY_VIEW_AUDIT_INFORMATION + | POLICY_GET_PRIVATE_INFORMATION; +pub const POLICY_WRITE: ULONG = STANDARD_RIGHTS_WRITE | POLICY_TRUST_ADMIN | POLICY_CREATE_ACCOUNT + | POLICY_CREATE_SECRET | POLICY_CREATE_PRIVILEGE | POLICY_SET_DEFAULT_QUOTA_LIMITS + | POLICY_SET_AUDIT_REQUIREMENTS | POLICY_AUDIT_LOG_ADMIN | POLICY_SERVER_ADMIN; +pub const POLICY_EXECUTE: ULONG = STANDARD_RIGHTS_EXECUTE | POLICY_VIEW_LOCAL_INFORMATION + | POLICY_LOOKUP_NAMES; +STRUCT!{struct LSA_TRANSLATED_SID { + Use: SID_NAME_USE, + RelativeId: ULONG, + DomainIndex: LONG, +}} +pub type PLSA_TRANSLATED_SID = *mut LSA_TRANSLATED_SID; +pub type POLICY_SYSTEM_ACCESS_MODE = ULONG; +pub type PPOLICY_SYSTEM_ACCESS_MODE = *mut POLICY_SYSTEM_ACCESS_MODE; +pub const POLICY_MODE_INTERACTIVE: ULONG = SECURITY_ACCESS_INTERACTIVE_LOGON; +pub const POLICY_MODE_NETWORK: ULONG = SECURITY_ACCESS_NETWORK_LOGON; +pub const POLICY_MODE_BATCH: ULONG = SECURITY_ACCESS_BATCH_LOGON; +pub const POLICY_MODE_SERVICE: ULONG = SECURITY_ACCESS_SERVICE_LOGON; +pub const POLICY_MODE_PROXY: ULONG = SECURITY_ACCESS_PROXY_LOGON; +pub const POLICY_MODE_DENY_INTERACTIVE: ULONG = SECURITY_ACCESS_DENY_INTERACTIVE_LOGON; +pub const POLICY_MODE_DENY_NETWORK: ULONG = SECURITY_ACCESS_DENY_NETWORK_LOGON; +pub const POLICY_MODE_DENY_BATCH: ULONG = SECURITY_ACCESS_DENY_BATCH_LOGON; +pub const POLICY_MODE_DENY_SERVICE: ULONG = SECURITY_ACCESS_DENY_SERVICE_LOGON; +pub const POLICY_MODE_REMOTE_INTERACTIVE: ULONG = SECURITY_ACCESS_REMOTE_INTERACTIVE_LOGON; +pub const POLICY_MODE_DENY_REMOTE_INTERACTIVE: ULONG = + SECURITY_ACCESS_DENY_REMOTE_INTERACTIVE_LOGON; +pub const POLICY_MODE_ALL: ULONG = POLICY_MODE_INTERACTIVE | POLICY_MODE_NETWORK + | POLICY_MODE_BATCH | POLICY_MODE_SERVICE | POLICY_MODE_PROXY | POLICY_MODE_DENY_INTERACTIVE + | POLICY_MODE_DENY_NETWORK | SECURITY_ACCESS_DENY_BATCH_LOGON + | SECURITY_ACCESS_DENY_SERVICE_LOGON | POLICY_MODE_REMOTE_INTERACTIVE + | POLICY_MODE_DENY_REMOTE_INTERACTIVE ; +pub const POLICY_MODE_ALL_NT4: ULONG = POLICY_MODE_INTERACTIVE | POLICY_MODE_NETWORK + | POLICY_MODE_BATCH | POLICY_MODE_SERVICE; +ENUM!{enum POLICY_LSA_SERVER_ROLE { + PolicyServerRoleBackup = 2, + PolicyServerRolePrimary, +}} +pub type PPOLICY_LSA_SERVER_ROLE = *mut POLICY_LSA_SERVER_ROLE; +ENUM!{enum POLICY_SERVER_ENABLE_STATE { + PolicyServerEnabled = 2, + PolicyServerDisabled, +}} +pub type PPOLICY_SERVER_ENABLE_STATE = *mut POLICY_SERVER_ENABLE_STATE; +pub type POLICY_AUDIT_EVENT_OPTIONS = ULONG; +pub type PPOLICY_AUDIT_EVENT_OPTIONS = *mut POLICY_AUDIT_EVENT_OPTIONS; +STRUCT!{struct POLICY_PRIVILEGE_DEFINITION { + Name: LSA_UNICODE_STRING, + LocalValue: LUID, +}} +pub type PPOLICY_PRIVILEGE_DEFINITION = *mut POLICY_PRIVILEGE_DEFINITION; +pub const LSA_LOOKUP_ISOLATED_AS_LOCAL: ULONG = 0x80000000; +pub const LSA_LOOKUP_DISALLOW_CONNECTED_ACCOUNT_INTERNET_SID: ULONG = 0x80000000; +pub const LSA_LOOKUP_PREFER_INTERNET_NAMES: ULONG = 0x40000000; +ENUM!{enum POLICY_INFORMATION_CLASS { + PolicyAuditLogInformation = 1, + PolicyAuditEventsInformation, + PolicyPrimaryDomainInformation, + PolicyPdAccountInformation, + PolicyAccountDomainInformation, + PolicyLsaServerRoleInformation, + PolicyReplicaSourceInformation, + PolicyDefaultQuotaInformation, + PolicyModificationInformation, + PolicyAuditFullSetInformation, + PolicyAuditFullQueryInformation, + PolicyDnsDomainInformation, + PolicyDnsDomainInformationInt, + PolicyLocalAccountDomainInformation, + PolicyLastEntry, +}} +pub type PPOLICY_INFORMATION_CLASS = *mut POLICY_INFORMATION_CLASS; +STRUCT!{struct POLICY_AUDIT_LOG_INFO { + AuditLogPercentFull: ULONG, + MaximumLogSize: ULONG, + AuditRetentionPeriod: LARGE_INTEGER, + AuditLogFullShutdownInProgress: BOOLEAN, + TimeToShutdown: LARGE_INTEGER, + NextAuditRecordId: ULONG, +}} +pub type PPOLICY_AUDIT_LOG_INFO = *mut POLICY_AUDIT_LOG_INFO; +STRUCT!{struct POLICY_AUDIT_EVENTS_INFO { + AuditingMode: BOOLEAN, + EventAuditingOptions: PPOLICY_AUDIT_EVENT_OPTIONS, + MaximumAuditEventCount: ULONG, +}} +pub type PPOLICY_AUDIT_EVENTS_INFO = *mut POLICY_AUDIT_EVENTS_INFO; +STRUCT!{struct POLICY_AUDIT_SUBCATEGORIES_INFO { + MaximumSubCategoryCount: ULONG, + EventAuditingOptions: PPOLICY_AUDIT_EVENT_OPTIONS, +}} +pub type PPOLICY_AUDIT_SUBCATEGORIES_INFO = *mut POLICY_AUDIT_SUBCATEGORIES_INFO; +STRUCT!{struct POLICY_AUDIT_CATEGORIES_INFO { + MaximumCategoryCount: ULONG, + SubCategoriesInfo: PPOLICY_AUDIT_SUBCATEGORIES_INFO, +}} +pub type PPOLICY_AUDIT_CATEGORIES_INFO = *mut POLICY_AUDIT_CATEGORIES_INFO; +pub const PER_USER_POLICY_UNCHANGED: UCHAR = 0x00; +pub const PER_USER_AUDIT_SUCCESS_INCLUDE: UCHAR = 0x01; +pub const PER_USER_AUDIT_SUCCESS_EXCLUDE: UCHAR = 0x02; +pub const PER_USER_AUDIT_FAILURE_INCLUDE: UCHAR = 0x04; +pub const PER_USER_AUDIT_FAILURE_EXCLUDE: UCHAR = 0x08; +pub const PER_USER_AUDIT_NONE: UCHAR = 0x10; +pub const VALID_PER_USER_AUDIT_POLICY_FLAG: UCHAR = PER_USER_AUDIT_SUCCESS_INCLUDE + | PER_USER_AUDIT_SUCCESS_EXCLUDE | PER_USER_AUDIT_FAILURE_INCLUDE + | PER_USER_AUDIT_FAILURE_EXCLUDE | PER_USER_AUDIT_NONE; +STRUCT!{struct POLICY_PRIMARY_DOMAIN_INFO { + Name: LSA_UNICODE_STRING, + Sid: PSID, +}} +pub type PPOLICY_PRIMARY_DOMAIN_INFO = *mut POLICY_PRIMARY_DOMAIN_INFO; +STRUCT!{struct POLICY_PD_ACCOUNT_INFO { + Name: LSA_UNICODE_STRING, +}} +pub type PPOLICY_PD_ACCOUNT_INFO = *mut POLICY_PD_ACCOUNT_INFO; +STRUCT!{struct POLICY_LSA_SERVER_ROLE_INFO { + LsaServerRole: POLICY_LSA_SERVER_ROLE, +}} +pub type PPOLICY_LSA_SERVER_ROLE_INFO = *mut POLICY_LSA_SERVER_ROLE_INFO; +STRUCT!{struct POLICY_REPLICA_SOURCE_INFO { + ReplicaSource: LSA_UNICODE_STRING, + ReplicaAccountName: LSA_UNICODE_STRING, +}} +pub type PPOLICY_REPLICA_SOURCE_INFO = *mut POLICY_REPLICA_SOURCE_INFO; +STRUCT!{struct POLICY_DEFAULT_QUOTA_INFO { + QuotaLimits: QUOTA_LIMITS, +}} +pub type PPOLICY_DEFAULT_QUOTA_INFO = *mut POLICY_DEFAULT_QUOTA_INFO; +STRUCT!{struct POLICY_MODIFICATION_INFO { + ModifiedId: LARGE_INTEGER, + DatabaseCreationTime: LARGE_INTEGER, +}} +pub type PPOLICY_MODIFICATION_INFO = *mut POLICY_MODIFICATION_INFO; +STRUCT!{struct POLICY_AUDIT_FULL_SET_INFO { + ShutDownOnFull: BOOLEAN, +}} +pub type PPOLICY_AUDIT_FULL_SET_INFO = *mut POLICY_AUDIT_FULL_SET_INFO; +STRUCT!{struct POLICY_AUDIT_FULL_QUERY_INFO { + ShutDownOnFull: BOOLEAN, + LogIsFull: BOOLEAN, +}} +pub type PPOLICY_AUDIT_FULL_QUERY_INFO = *mut POLICY_AUDIT_FULL_QUERY_INFO; +ENUM!{enum POLICY_DOMAIN_INFORMATION_CLASS { + PolicyDomainEfsInformation = 2, + PolicyDomainKerberosTicketInformation, +}} +pub type PPOLICY_DOMAIN_INFORMATION_CLASS = *mut POLICY_DOMAIN_INFORMATION_CLASS; +pub const POLICY_QOS_SCHANNEL_REQUIRED: ULONG = 0x00000001; +pub const POLICY_QOS_OUTBOUND_INTEGRITY: ULONG = 0x00000002; +pub const POLICY_QOS_OUTBOUND_CONFIDENTIALITY: ULONG = 0x00000004; +pub const POLICY_QOS_INBOUND_INTEGRITY: ULONG = 0x00000008; +pub const POLICY_QOS_INBOUND_CONFIDENTIALITY: ULONG = 0x00000010; +pub const POLICY_QOS_ALLOW_LOCAL_ROOT_CERT_STORE: ULONG = 0x00000020; +pub const POLICY_QOS_RAS_SERVER_ALLOWED: ULONG = 0x00000040; +pub const POLICY_QOS_DHCP_SERVER_ALLOWED: ULONG = 0x00000080; +STRUCT!{struct POLICY_DOMAIN_EFS_INFO { + InfoLength: ULONG, + EfsBlob: PUCHAR, +}} +pub type PPOLICY_DOMAIN_EFS_INFO = *mut POLICY_DOMAIN_EFS_INFO; +pub const POLICY_KERBEROS_VALIDATE_CLIENT: ULONG = 0x00000080; +STRUCT!{struct POLICY_DOMAIN_KERBEROS_TICKET_INFO { + AuthenticationOptions: ULONG, + MaxServiceTicketAge: LARGE_INTEGER, + MaxTicketAge: LARGE_INTEGER, + MaxRenewAge: LARGE_INTEGER, + MaxClockSkew: LARGE_INTEGER, + Reserved: LARGE_INTEGER, +}} +pub type PPOLICY_DOMAIN_KERBEROS_TICKET_INFO = *mut POLICY_DOMAIN_KERBEROS_TICKET_INFO; +ENUM!{enum POLICY_NOTIFICATION_INFORMATION_CLASS { + PolicyNotifyAuditEventsInformation = 1, + PolicyNotifyAccountDomainInformation, + PolicyNotifyServerRoleInformation, + PolicyNotifyDnsDomainInformation, + PolicyNotifyDomainEfsInformation, + PolicyNotifyDomainKerberosTicketInformation, + PolicyNotifyMachineAccountPasswordInformation, + PolicyNotifyGlobalSaclInformation, + PolicyNotifyMax, +}} +pub type PPOLICY_NOTIFICATION_INFORMATION_CLASS = *mut POLICY_NOTIFICATION_INFORMATION_CLASS; +pub const ACCOUNT_VIEW: ULONG = 0x00000001; +pub const ACCOUNT_ADJUST_PRIVILEGES: ULONG = 0x00000002; +pub const ACCOUNT_ADJUST_QUOTAS: ULONG = 0x00000004; +pub const ACCOUNT_ADJUST_SYSTEM_ACCESS: ULONG = 0x00000008; +pub const ACCOUNT_ALL_ACCESS: ULONG = STANDARD_RIGHTS_REQUIRED | ACCOUNT_VIEW + | ACCOUNT_ADJUST_PRIVILEGES | ACCOUNT_ADJUST_QUOTAS | ACCOUNT_ADJUST_SYSTEM_ACCESS; +pub const ACCOUNT_READ: ULONG = STANDARD_RIGHTS_READ | ACCOUNT_VIEW; +pub const ACCOUNT_WRITE: ULONG = STANDARD_RIGHTS_WRITE | ACCOUNT_ADJUST_PRIVILEGES + | ACCOUNT_ADJUST_QUOTAS | ACCOUNT_ADJUST_SYSTEM_ACCESS; +pub const ACCOUNT_EXECUTE: ULONG = STANDARD_RIGHTS_EXECUTE; +DECLARE_HANDLE!{LSA_HANDLE, __LSA_HANDLE} +pub const TRUSTED_QUERY_DOMAIN_NAME: ULONG = 0x00000001; +pub const TRUSTED_QUERY_CONTROLLERS: ULONG = 0x00000002; +pub const TRUSTED_SET_CONTROLLERS: ULONG = 0x00000004; +pub const TRUSTED_QUERY_POSIX: ULONG = 0x00000008; +pub const TRUSTED_SET_POSIX: ULONG = 0x00000010; +pub const TRUSTED_SET_AUTH: ULONG = 0x00000020; +pub const TRUSTED_QUERY_AUTH: ULONG = 0x00000040; +pub const TRUSTED_ALL_ACCESS: ULONG = STANDARD_RIGHTS_REQUIRED | TRUSTED_QUERY_DOMAIN_NAME + | TRUSTED_QUERY_CONTROLLERS | TRUSTED_SET_CONTROLLERS | TRUSTED_QUERY_POSIX | TRUSTED_SET_POSIX + | TRUSTED_SET_AUTH | TRUSTED_QUERY_AUTH; +pub const TRUSTED_READ: ULONG = STANDARD_RIGHTS_READ | TRUSTED_QUERY_DOMAIN_NAME; +pub const TRUSTED_WRITE: ULONG = STANDARD_RIGHTS_WRITE | TRUSTED_SET_CONTROLLERS + | TRUSTED_SET_POSIX | TRUSTED_SET_AUTH; +pub const TRUSTED_EXECUTE: ULONG = STANDARD_RIGHTS_EXECUTE | TRUSTED_QUERY_CONTROLLERS + | TRUSTED_QUERY_POSIX; +ENUM!{enum TRUSTED_INFORMATION_CLASS { + TrustedDomainNameInformation = 1, + TrustedControllersInformation, + TrustedPosixOffsetInformation, + TrustedPasswordInformation, + TrustedDomainInformationBasic, + TrustedDomainInformationEx, + TrustedDomainAuthInformation, + TrustedDomainFullInformation, + TrustedDomainAuthInformationInternal, + TrustedDomainFullInformationInternal, + TrustedDomainInformationEx2Internal, + TrustedDomainFullInformation2Internal, + TrustedDomainSupportedEncryptionTypes, +}} +pub type PTRUSTED_INFORMATION_CLASS = *mut TRUSTED_INFORMATION_CLASS; +STRUCT!{struct TRUSTED_DOMAIN_NAME_INFO { + Name: LSA_UNICODE_STRING, +}} +pub type PTRUSTED_DOMAIN_NAME_INFO = *mut TRUSTED_DOMAIN_NAME_INFO; +STRUCT!{struct TRUSTED_CONTROLLERS_INFO { + Entries: ULONG, + Names: PLSA_UNICODE_STRING, +}} +pub type PTRUSTED_CONTROLLERS_INFO = *mut TRUSTED_CONTROLLERS_INFO; +STRUCT!{struct TRUSTED_POSIX_OFFSET_INFO { + Offset: ULONG, +}} +pub type PTRUSTED_POSIX_OFFSET_INFO = *mut TRUSTED_POSIX_OFFSET_INFO; +STRUCT!{struct TRUSTED_PASSWORD_INFO { + Password: LSA_UNICODE_STRING, + OldPassword: LSA_UNICODE_STRING, +}} +pub type PTRUSTED_PASSWORD_INFO = *mut TRUSTED_PASSWORD_INFO; +pub type TRUSTED_DOMAIN_INFORMATION_BASIC = LSA_TRUST_INFORMATION; +pub type PTRUSTED_DOMAIN_INFORMATION_BASIC = PLSA_TRUST_INFORMATION; +// NOTE: Ignoring Win XP constants +pub const TRUST_DIRECTION_DISABLED: ULONG = 0x00000000; +pub const TRUST_DIRECTION_INBOUND: ULONG = 0x00000001; +pub const TRUST_DIRECTION_OUTBOUND: ULONG = 0x00000002; +pub const TRUST_DIRECTION_BIDIRECTIONAL: ULONG = TRUST_DIRECTION_INBOUND + | TRUST_DIRECTION_OUTBOUND; +pub const TRUST_TYPE_DOWNLEVEL: ULONG = 0x00000001; +pub const TRUST_TYPE_UPLEVEL: ULONG = 0x00000002; +pub const TRUST_TYPE_MIT: ULONG = 0x00000003; +pub const TRUST_ATTRIBUTE_NON_TRANSITIVE: ULONG = 0x00000001; +pub const TRUST_ATTRIBUTE_UPLEVEL_ONLY: ULONG = 0x00000002; +pub const TRUST_ATTRIBUTE_QUARANTINED_DOMAIN: ULONG = 0x00000004; +pub const TRUST_ATTRIBUTE_FOREST_TRANSITIVE: ULONG = 0x00000008; +pub const TRUST_ATTRIBUTE_CROSS_ORGANIZATION: ULONG = 0x00000010; +pub const TRUST_ATTRIBUTE_WITHIN_FOREST: ULONG = 0x00000020; +pub const TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL: ULONG = 0x00000040; +pub const TRUST_ATTRIBUTE_TRUST_USES_RC4_ENCRYPTION: ULONG = 0x00000080; +pub const TRUST_ATTRIBUTE_TRUST_USES_AES_KEYS: ULONG = 0x00000100; +pub const TRUST_ATTRIBUTE_CROSS_ORGANIZATION_NO_TGT_DELEGATION: ULONG = 0x00000200; +pub const TRUST_ATTRIBUTE_PIM_TRUST: ULONG = 0x00000400; +pub const TRUST_ATTRIBUTES_VALID: ULONG = 0xFF03FFFF; +pub const TRUST_ATTRIBUTES_USER: ULONG = 0xFF000000; +STRUCT!{struct TRUSTED_DOMAIN_INFORMATION_EX { + Name: LSA_UNICODE_STRING, + FlatName: LSA_UNICODE_STRING, + Sid: PSID, + TrustDirection: ULONG, + TrustType: ULONG, + TrustAttributes: ULONG, +}} +pub type PTRUSTED_DOMAIN_INFORMATION_EX = *mut TRUSTED_DOMAIN_INFORMATION_EX; +STRUCT!{struct TRUSTED_DOMAIN_INFORMATION_EX2 { + Name: LSA_UNICODE_STRING, + FlatName: LSA_UNICODE_STRING, + Sid: PSID, + TrustDirection: ULONG, + TrustType: ULONG, + TrustAttributes: ULONG, + ForestTrustLength: ULONG, + ForestTrustInfo: PUCHAR, +}} +pub type PTRUSTED_DOMAIN_INFORMATION_EX2 = *mut TRUSTED_DOMAIN_INFORMATION_EX2; +pub const TRUST_AUTH_TYPE_NONE: ULONG = 0; +pub const TRUST_AUTH_TYPE_NT4OWF: ULONG = 1; +pub const TRUST_AUTH_TYPE_CLEAR: ULONG = 2; +pub const TRUST_AUTH_TYPE_VERSION: ULONG = 3; +STRUCT!{struct LSA_AUTH_INFORMATION { + LastUpdateTime: LARGE_INTEGER, + AuthType: ULONG, + AuthInfoLength: ULONG, + AuthInfo: PUCHAR, +}} +pub type PLSA_AUTH_INFORMATION = *mut LSA_AUTH_INFORMATION; +STRUCT!{struct TRUSTED_DOMAIN_AUTH_INFORMATION { + IncomingAuthInfos: ULONG, + IncomingAuthenticationInformation: PLSA_AUTH_INFORMATION, + IncomingPreviousAuthenticationInformation: PLSA_AUTH_INFORMATION, + OutgoingAuthInfos: ULONG, + OutgoingAuthenticationInformation: PLSA_AUTH_INFORMATION, + OutgoingPreviousAuthenticationInformation: PLSA_AUTH_INFORMATION, +}} +pub type PTRUSTED_DOMAIN_AUTH_INFORMATION = *mut TRUSTED_DOMAIN_AUTH_INFORMATION; +STRUCT!{struct TRUSTED_DOMAIN_FULL_INFORMATION { + Information: TRUSTED_DOMAIN_INFORMATION_EX, + PosixOffset: TRUSTED_POSIX_OFFSET_INFO, + AuthInformation: TRUSTED_DOMAIN_AUTH_INFORMATION, +}} +pub type PTRUSTED_DOMAIN_FULL_INFORMATION = *mut TRUSTED_DOMAIN_FULL_INFORMATION; +STRUCT!{struct TRUSTED_DOMAIN_FULL_INFORMATION2 { + Information: TRUSTED_DOMAIN_INFORMATION_EX2, + PosixOffset: TRUSTED_POSIX_OFFSET_INFO, + AuthInformation: TRUSTED_DOMAIN_AUTH_INFORMATION, +}} +pub type PTRUSTED_DOMAIN_FULL_INFORMATION2 = *mut TRUSTED_DOMAIN_FULL_INFORMATION2; +STRUCT!{struct TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES { + SupportedEncryptionTypes: ULONG, +}} +pub type PTRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES = + *mut TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES; +ENUM!{enum LSA_FOREST_TRUST_RECORD_TYPE { + ForestTrustTopLevelName, + ForestTrustTopLevelNameEx, + ForestTrustDomainInfo, + ForestTrustRecordTypeLast = ForestTrustDomainInfo, +}} +pub const LSA_FTRECORD_DISABLED_REASONS: ULONG = 0x0000FFFF; +pub const LSA_TLN_DISABLED_NEW: ULONG = 0x00000001; +pub const LSA_TLN_DISABLED_ADMIN: ULONG = 0x00000002; +pub const LSA_TLN_DISABLED_CONFLICT: ULONG = 0x00000004; +pub const LSA_SID_DISABLED_ADMIN: ULONG = 0x00000001; +pub const LSA_SID_DISABLED_CONFLICT: ULONG = 0x00000002; +pub const LSA_NB_DISABLED_ADMIN: ULONG = 0x00000004; +pub const LSA_NB_DISABLED_CONFLICT: ULONG = 0x00000008; +STRUCT!{struct LSA_FOREST_TRUST_DOMAIN_INFO { + Sid: PSID, + DnsName: LSA_UNICODE_STRING, + NetbiosName: LSA_UNICODE_STRING, +}} +pub type PLSA_FOREST_TRUST_DOMAIN_INFO = *mut LSA_FOREST_TRUST_DOMAIN_INFO; +pub const MAX_FOREST_TRUST_BINARY_DATA_SIZE: SIZE_T = 128 * 1024; +STRUCT!{struct LSA_FOREST_TRUST_BINARY_DATA { + Length: ULONG, + Buffer: PUCHAR, +}} +pub type PLSA_FOREST_TRUST_BINARY_DATA = *mut LSA_FOREST_TRUST_BINARY_DATA; +UNION!{union LSA_FOREST_TRUST_RECORD_FORESTTRUSTDATA { + [u32; 5] [u64; 5], + TopLevelName TopLevelName_mut: LSA_UNICODE_STRING, + DomainInfo DomainInfo_mut: LSA_FOREST_TRUST_DOMAIN_INFO, + Data Data_mut: LSA_FOREST_TRUST_BINARY_DATA, +}} +STRUCT!{struct LSA_FOREST_TRUST_RECORD { + Flags: ULONG, + ForestTrustType: LSA_FOREST_TRUST_RECORD_TYPE, + Time: LARGE_INTEGER, + ForestTrustData: LSA_FOREST_TRUST_RECORD_FORESTTRUSTDATA, +}} +pub type PLSA_FOREST_TRUST_RECORD = *mut LSA_FOREST_TRUST_RECORD; +pub const MAX_RECORDS_IN_FOREST_TRUST_INFO: SIZE_T = 4000; +STRUCT!{struct LSA_FOREST_TRUST_INFORMATION { + RecordCount: ULONG, + Entries: *mut PLSA_FOREST_TRUST_RECORD, +}} +pub type PLSA_FOREST_TRUST_INFORMATION = LSA_FOREST_TRUST_INFORMATION; +ENUM!{enum LSA_FOREST_TRUST_COLLISION_RECORD_TYPE { + CollisionTdo, + CollisionXref, + CollisionOther, +}} +STRUCT!{struct LSA_FOREST_TRUST_COLLISION_RECORD { + Index: ULONG, + Type: LSA_FOREST_TRUST_COLLISION_RECORD_TYPE, + Flags: ULONG, + Name: LSA_UNICODE_STRING, +}} +pub type PLSA_FOREST_TRUST_COLLISION_RECORD = *mut LSA_FOREST_TRUST_COLLISION_RECORD; +STRUCT!{struct LSA_FOREST_TRUST_COLLISION_INFORMATION { + RecordCount: ULONG, + Entries: *mut PLSA_FOREST_TRUST_COLLISION_RECORD, +}} +pub type PLSA_FOREST_TRUST_COLLISION_INFORMATION = *mut LSA_FOREST_TRUST_COLLISION_INFORMATION; +pub const SECRET_SET_VALUE: ULONG = 0x00000001; +pub const SECRET_QUERY_VALUE: ULONG = 0x00000002; +pub const SECRET_ALL_ACCESS: ULONG = STANDARD_RIGHTS_REQUIRED | SECRET_SET_VALUE + | SECRET_QUERY_VALUE; +pub const SECRET_READ: ULONG = STANDARD_RIGHTS_READ | SECRET_QUERY_VALUE; +pub const SECRET_WRITE: ULONG = STANDARD_RIGHTS_WRITE | SECRET_SET_VALUE; +pub const SECRET_EXECUTE: ULONG = STANDARD_RIGHTS_EXECUTE; +pub const LSA_GLOBAL_SECRET_PREFIX: &'static str = "G$"; +pub const LSA_GLOBAL_SECRET_PREFIX_LENGTH: SIZE_T = 2; +pub const LSA_LOCAL_SECRET_PREFIX: &'static str = "L$"; +pub const LSA_LOCAL_SECRET_PREFIX_LENGTH: SIZE_T = 2; +pub const LSA_MACHINE_SECRET_PREFIX: &'static str = "M$"; +pub const LSA_MACHINE_SECRET_PREFIX_LENGTH: SIZE_T = 2; +pub const LSA_SECRET_MAXIMUM_COUNT: SIZE_T = 0x00001000; +pub const LSA_SECRET_MAXIMUM_LENGTH: SIZE_T = 0x00000200; +DECLARE_HANDLE!{LSA_ENUMERATION_HANDLE, __LSA_ENUMERATION_HANDLE} +pub type PLSA_ENUMERATION_HANDLE = *mut LSA_ENUMERATION_HANDLE; +STRUCT!{struct LSA_ENUMERATION_INFORMATION { + Sid: PSID, +}} +pub type PLSA_ENUMERATION_INFORMATION = *mut LSA_ENUMERATION_INFORMATION; +extern "system" { + pub fn LsaFreeMemory( + Buffer: PVOID, + ) -> NTSTATUS; + pub fn LsaClose( + ObjectHandle: LSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaDelete( + ObjectHandle: LSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaQuerySecurityObject( + ObjectHandle: LSA_HANDLE, + SecurityInformation: SECURITY_INFORMATION, + SecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + ) -> NTSTATUS; + pub fn LsaSetSecurityObject( + ObjectHandle: LSA_HANDLE, + SecurityInformation: SECURITY_INFORMATION, + SecurityDescriptor: PSECURITY_DESCRIPTOR, + ) -> NTSTATUS; + pub fn LsaChangePassword( + ServerName: PLSA_UNICODE_STRING, + DomainName: PLSA_UNICODE_STRING, + AccountName: PLSA_UNICODE_STRING, + OldPassword: PLSA_UNICODE_STRING, + NewPassword: PLSA_UNICODE_STRING, + ) -> NTSTATUS; +} +STRUCT!{struct LSA_LAST_INTER_LOGON_INFO { + LastSuccessfulLogon: LARGE_INTEGER, + LastFailedLogon: LARGE_INTEGER, + FailedAttemptCountSinceLastSuccessfulLogon: ULONG, +}} +pub type PLSA_LAST_INTER_LOGON_INFO = *mut LSA_LAST_INTER_LOGON_INFO; +STRUCT!{struct SECURITY_LOGON_SESSION_DATA { + Size: ULONG, + LogonId: LUID, + UserName: LSA_UNICODE_STRING, + LogonDomain: LSA_UNICODE_STRING, + AuthenticationPackage: LSA_UNICODE_STRING, + LogonType: ULONG, + Session: ULONG, + Sid: PSID, + LogonTime: LARGE_INTEGER, + LogonServer: LSA_UNICODE_STRING, + DnsDomainName: LSA_UNICODE_STRING, + Upn: LSA_UNICODE_STRING, + UserFlags: ULONG, + LastLogonInfo: LSA_LAST_INTER_LOGON_INFO, + LogonScript: LSA_UNICODE_STRING, + ProfilePath: LSA_UNICODE_STRING, + HomeDirectory: LSA_UNICODE_STRING, + HomeDirectoryDrive: LSA_UNICODE_STRING, + LogoffTime: LARGE_INTEGER, + KickOffTime: LARGE_INTEGER, + PasswordLastSet: LARGE_INTEGER, + PasswordCanChange: LARGE_INTEGER, + PasswordMustChange: LARGE_INTEGER, +}} +pub type PSECURITY_LOGON_SESSION_DATA = *mut SECURITY_LOGON_SESSION_DATA; +extern "system" { + pub fn LsaEnumerateLogonSessions( + LogonSessionCount: PULONG, + LogonSessionList: *mut PLUID, + ) -> NTSTATUS; + pub fn LsaGetLogonSessionData( + LogonId: PLUID, + ppLogonSessionData: *mut PSECURITY_LOGON_SESSION_DATA, + ) -> NTSTATUS; + pub fn LsaOpenPolicy( + SystemName: PLSA_UNICODE_STRING, + ObjectAttributes: PLSA_OBJECT_ATTRIBUTES, + DesiredAccess: ACCESS_MASK, + PolicyHandle: PLSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaOpenPolicySce( + SystemName: PLSA_UNICODE_STRING, + ObjectAttributes: PLSA_OBJECT_ATTRIBUTES, + DesiredAccess: ACCESS_MASK, + PolicyHandle: PLSA_HANDLE, + ) -> NTSTATUS; +} +pub const MAXIMUM_CAPES_PER_CAP: SIZE_T = 0x7F; +pub const CENTRAL_ACCESS_POLICY_OWNER_RIGHTS_PRESENT_FLAG: ULONG = 0x00000001; +pub const CENTRAL_ACCESS_POLICY_STAGED_OWNER_RIGHTS_PRESENT_FLAG: ULONG = 0x00000100; +#[inline] +pub fn STAGING_FLAG(Effective: ULONG) -> ULONG { + (Effective & 0xF) << 8 +} +pub const CENTRAL_ACCESS_POLICY_STAGED_FLAG: ULONG = 0x00010000; +pub const CENTRAL_ACCESS_POLICY_VALID_FLAG_MASK: ULONG = + CENTRAL_ACCESS_POLICY_OWNER_RIGHTS_PRESENT_FLAG + | CENTRAL_ACCESS_POLICY_STAGED_OWNER_RIGHTS_PRESENT_FLAG | CENTRAL_ACCESS_POLICY_STAGED_FLAG; +pub const LSASETCAPS_RELOAD_FLAG: ULONG = 0x00000001; +pub const LSASETCAPS_VALID_FLAG_MASK: ULONG = LSASETCAPS_RELOAD_FLAG; +STRUCT!{struct CENTRAL_ACCESS_POLICY_ENTRY { + Name: LSA_UNICODE_STRING, + Description: LSA_UNICODE_STRING, + ChangeId: LSA_UNICODE_STRING, + LengthAppliesTo: ULONG, + AppliesTo: PUCHAR, + LengthSD: ULONG, + SD: PSECURITY_DESCRIPTOR, + LengthStagedSD: ULONG, + StagedSD: PSECURITY_DESCRIPTOR, + Flags: ULONG, +}} +pub type PCENTRAL_ACCESS_POLICY_ENTRY = *mut CENTRAL_ACCESS_POLICY_ENTRY; +pub type PCCENTRAL_ACCESS_POLICY_ENTRY = *const CENTRAL_ACCESS_POLICY_ENTRY; +STRUCT!{struct CENTRAL_ACCESS_POLICY { + CAPID: PSID, + Name: LSA_UNICODE_STRING, + Description: LSA_UNICODE_STRING, + ChangeId: LSA_UNICODE_STRING, + Flags: ULONG, + CAPECount: ULONG, + CAPEs: *mut PCENTRAL_ACCESS_POLICY_ENTRY, +}} +pub type PCENTRAL_ACCESS_POLICY = *mut CENTRAL_ACCESS_POLICY; +pub type PCCENTRAL_ACCESS_POLICY = *const CENTRAL_ACCESS_POLICY; +extern "system" { + pub fn LsaSetCAPs( + CAPDNs: PLSA_UNICODE_STRING, + CAPDNCount: ULONG, + Flags: ULONG, + ) -> NTSTATUS; + pub fn LsaGetAppliedCAPIDs( + SystemName: PLSA_UNICODE_STRING, + CAPIDs: *mut *mut PSID, + CAPIDCount: PULONG, + ) -> NTSTATUS; + pub fn LsaQueryCAPs( + CAPIDs: *mut PSID, + CAPIDCount: ULONG, + CAPs: *mut PCENTRAL_ACCESS_POLICY, + CAPCount: PULONG, + ) -> NTSTATUS; + pub fn LsaQueryInformationPolicy( + PolicyHandle: LSA_HANDLE, + InformationClass: POLICY_INFORMATION_CLASS, + Buffer: *mut PVOID, + ) -> NTSTATUS; + pub fn LsaSetInformationPolicy( + PolicyHandle: LSA_HANDLE, + InformationClass: POLICY_INFORMATION_CLASS, + Buffer: PVOID, + ) -> NTSTATUS; + pub fn LsaQueryDomainInformationPolicy( + PolicyHandle: LSA_HANDLE, + InformationClass: POLICY_DOMAIN_INFORMATION_CLASS, + Buffer: *mut PVOID, + ) -> NTSTATUS; + pub fn LsaSetDomainInformationPolicy( + PolicyHandle: LSA_HANDLE, + InformationClass: POLICY_DOMAIN_INFORMATION_CLASS, + Buffer: PVOID, + ) -> NTSTATUS; + pub fn LsaRegisterPolicyChangeNotification( + InformationClass: POLICY_NOTIFICATION_INFORMATION_CLASS, + NotifcationEventHandle: HANDLE, + ) -> NTSTATUS; + pub fn LsaUnregisterPolicyChangeNotification( + InformationClass: POLICY_NOTIFICATION_INFORMATION_CLASS, + NotifcationEventHandle: HANDLE, + ) -> NTSTATUS; + pub fn LsaClearAuditLog( + PolicyHandle: LSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaCreateAccount( + PolicyHandle: LSA_HANDLE, + AccountSid: PSID, + DesiredAccess: ACCESS_MASK, + AccountHandle: PLSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaEnumerateAccounts( + PolicyHandle: LSA_HANDLE, + EnumerationContext: PLSA_ENUMERATION_HANDLE, + Buffer: *mut PVOID, + PreferredMaximumLength: ULONG, + CountReturned: PULONG, + ) -> NTSTATUS; + pub fn LsaCreateTrustedDomain( + PolicyHandle: LSA_HANDLE, + TrustedDomainInformation: PLSA_TRUST_INFORMATION, + DesiredAccess: ACCESS_MASK, + TrustedDomainHandle: PLSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaEnumerateTrustedDomains( + PolicyHandle: LSA_HANDLE, + EnumerationContext: PLSA_ENUMERATION_HANDLE, + Buffer: *mut PVOID, + PreferredMaximumLength: ULONG, + CountReturned: PULONG, + ) -> NTSTATUS; + pub fn LsaEnumeratePrivileges( + PolicyHandle: LSA_HANDLE, + EnumerationContext: PLSA_ENUMERATION_HANDLE, + Buffer: *mut PVOID, + PreferredMaximumLength: ULONG, + CountReturned: PULONG, + ) -> NTSTATUS; + pub fn LsaLookupNames( + PolicyHandle: LSA_HANDLE, + Count: ULONG, + Names: PLSA_UNICODE_STRING, + ReferencedDomains: *mut PLSA_REFERENCED_DOMAIN_LIST, + Sids: *mut PLSA_TRANSLATED_SID, + ) -> NTSTATUS; + pub fn LsaLookupNames2( + PolicyHandle: LSA_HANDLE, + Flags: ULONG, + Count: ULONG, + Names: PLSA_UNICODE_STRING, + ReferencedDomains: *mut PLSA_REFERENCED_DOMAIN_LIST, + Sids: *mut PLSA_TRANSLATED_SID2, + ) -> NTSTATUS; + pub fn LsaLookupSids( + PolicyHandle: LSA_HANDLE, + Count: ULONG, + Sids: *mut PSID, + ReferencedDomains: *mut PLSA_REFERENCED_DOMAIN_LIST, + Names: *mut PLSA_TRANSLATED_NAME, + ) -> NTSTATUS; + pub fn LsaLookupSids2( + PolicyHandle: LSA_HANDLE, + LookupOptions: ULONG, + Count: ULONG, + Sids: *mut PSID, + ReferencedDomains: *mut PLSA_REFERENCED_DOMAIN_LIST, + Names: *mut PLSA_TRANSLATED_NAME, + ) -> NTSTATUS; + pub fn LsaCreateSecret( + PolicyHandle: LSA_HANDLE, + SecretName: PLSA_UNICODE_STRING, + DesiredAccess: ACCESS_MASK, + SecretHandle: PLSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaOpenAccount( + PolicyHandle: LSA_HANDLE, + AccountSid: PSID, + DesiredAccess: ACCESS_MASK, + AccountHandle: PLSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaEnumeratePrivilegesOfAccount( + AccountHandle: LSA_HANDLE, + Privileges: *mut PPRIVILEGE_SET, + ) -> NTSTATUS; + pub fn LsaAddPrivilegesToAccount( + AccountHandle: LSA_HANDLE, + Privileges: PPRIVILEGE_SET, + ) -> NTSTATUS; + pub fn LsaRemovePrivilegesFromAccount( + AccountHandle: LSA_HANDLE, + AllPrivileges: BOOLEAN, + Privileges: PPRIVILEGE_SET, + ) -> NTSTATUS; + pub fn LsaGetQuotasForAccount( + AccountHandle: LSA_HANDLE, + QuotaLimits: PQUOTA_LIMITS, + ) -> NTSTATUS; + pub fn LsaSetQuotasForAccount( + AccountHandle: LSA_HANDLE, + QuotaLimits: PQUOTA_LIMITS, + ) -> NTSTATUS; + pub fn LsaGetSystemAccessAccount( + AccountHandle: LSA_HANDLE, + SystemAccess: PULONG, + ) -> NTSTATUS; + pub fn LsaSetSystemAccessAccount( + AccountHandle: LSA_HANDLE, + SystemAccess: ULONG, + ) -> NTSTATUS; + pub fn LsaOpenTrustedDomain( + PolicyHandle: LSA_HANDLE, + TrustedDomainSid: PSID, + DesiredAccess: ACCESS_MASK, + TrustedDomainHandle: PLSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaQueryInfoTrustedDomain( + TrustedDomainHandle: LSA_HANDLE, + InformationClass: TRUSTED_INFORMATION_CLASS, + Buffer: *mut PVOID, + ) -> NTSTATUS; + pub fn LsaSetInformationTrustedDomain( + TrustedDomainHandle: LSA_HANDLE, + InformationClass: TRUSTED_INFORMATION_CLASS, + Buffer: PVOID, + ) -> NTSTATUS; + pub fn LsaOpenSecret( + PolicyHandle: LSA_HANDLE, + SecretName: PLSA_UNICODE_STRING, + DesiredAccess: ACCESS_MASK, + SecretHandle: PLSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaSetSecret( + SecretHandle: LSA_HANDLE, + CurrentValue: PLSA_UNICODE_STRING, + OldValue: PLSA_UNICODE_STRING, + ) -> NTSTATUS; + pub fn LsaQuerySecret( + SecretHandle: LSA_HANDLE, + CurrentValue: *mut PLSA_UNICODE_STRING, + CurrentValueSetTime: PLARGE_INTEGER, + OldValue: *mut PLSA_UNICODE_STRING, + OldValueSetTime: PLARGE_INTEGER, + ) -> NTSTATUS; + pub fn LsaLookupPrivilegeValue( + PolicyHandle: LSA_HANDLE, + Name: PLSA_UNICODE_STRING, + Value: PLUID, + ) -> NTSTATUS; + pub fn LsaLookupPrivilegeName( + PolicyHandle: LSA_HANDLE, + Value: PLUID, + Name: *mut PLSA_UNICODE_STRING, + ) -> NTSTATUS; + pub fn LsaLookupPrivilegeDisplayName( + PolicyHandle: LSA_HANDLE, + Name: PLSA_UNICODE_STRING, + DisplayName: *mut PLSA_UNICODE_STRING, + LanguageReturned: PSHORT, + ) -> NTSTATUS; +} +extern "C" { + pub fn LsaGetUserName( + UserName: *mut PLSA_UNICODE_STRING, + DomainName: *mut PLSA_UNICODE_STRING, + ) -> NTSTATUS; + pub fn LsaGetRemoteUserName( + SystemName: PLSA_UNICODE_STRING, + UserName: *mut PLSA_UNICODE_STRING, + DomainName: *mut PLSA_UNICODE_STRING, + ) -> NTSTATUS; +} +pub const SE_INTERACTIVE_LOGON_NAME: &'static str = "SeInteractiveLogonRight"; +pub const SE_NETWORK_LOGON_NAME: &'static str = "SeNetworkLogonRight"; +pub const SE_BATCH_LOGON_NAME: &'static str = "SeBatchLogonRight"; +pub const SE_SERVICE_LOGON_NAME: &'static str = "SeServiceLogonRight"; +pub const SE_DENY_INTERACTIVE_LOGON_NAME: &'static str = "SeDenyInteractiveLogonRight"; +pub const SE_DENY_NETWORK_LOGON_NAME: &'static str = "SeDenyNetworkLogonRight"; +pub const SE_DENY_BATCH_LOGON_NAME: &'static str = "SeDenyBatchLogonRight"; +pub const SE_DENY_SERVICE_LOGON_NAME: &'static str = "SeDenyServiceLogonRight"; +pub const SE_REMOTE_INTERACTIVE_LOGON_NAME: &'static str = "SeRemoteInteractiveLogonRight"; +pub const SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME: &'static str = + "SeDenyRemoteInteractiveLogonRight"; +extern "system" { + pub fn LsaEnumerateAccountsWithUserRight( + PolictHandle: LSA_HANDLE, + UserRights: PLSA_UNICODE_STRING, + EnumerationBuffer: *mut PVOID, + CountReturned: PULONG, + ) -> NTSTATUS; + pub fn LsaEnumerateAccountRights( + PolicyHandle: LSA_HANDLE, + AccountSid: PSID, + UserRights: *mut PLSA_UNICODE_STRING, + CountOfRights: PULONG, + ) -> NTSTATUS; + pub fn LsaAddAccountRights( + PolicyHandle: LSA_HANDLE, + AccountSid: PSID, + UserRights: PLSA_UNICODE_STRING, + CountOfRights: ULONG, + ) -> NTSTATUS; + pub fn LsaRemoveAccountRights( + PolicyHandle: LSA_HANDLE, + AccountSid: PSID, + AllRights: BOOLEAN, + UserRights: PLSA_UNICODE_STRING, + CountOfRights: ULONG, + ) -> NTSTATUS; + pub fn LsaOpenTrustedDomainByName( + PolicyHandle: LSA_HANDLE, + TrustedDomainName: PLSA_UNICODE_STRING, + DesiredAccess: ACCESS_MASK, + TrustedDomainHandle: PLSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaQueryTrustedDomainInfo( + PolicyHandle: LSA_HANDLE, + TrustedDomainSid: PSID, + InformationClass: TRUSTED_INFORMATION_CLASS, + Buffer: *mut PVOID, + ) -> NTSTATUS; + pub fn LsaSetTrustedDomainInformation( + PolicyHandle: LSA_HANDLE, + TrustedDomainSid: PSID, + InformationClass: TRUSTED_INFORMATION_CLASS, + Buffer: PVOID, + ) -> NTSTATUS; + pub fn LsaDeleteTrustedDomain( + PolicyHandle: LSA_HANDLE, + TrustedDomainSid: PSID, + ) -> NTSTATUS; + pub fn LsaQueryTrustedDomainInfoByName( + PolicyHandle: LSA_HANDLE, + TrustedDomainName: PLSA_UNICODE_STRING, + InformationClass: TRUSTED_INFORMATION_CLASS, + Buffer: *mut PVOID, + ) -> NTSTATUS; + pub fn LsaSetTrustedDomainInfoByName( + PolicyHandle: LSA_HANDLE, + TrustedDomainName: PLSA_UNICODE_STRING, + InformationClass: TRUSTED_INFORMATION_CLASS, + Buffer: PVOID, + ) -> NTSTATUS; + pub fn LsaEnumerateTrustedDomainsEx( + PolicyHandle: LSA_HANDLE, + EnumerationContext: PLSA_ENUMERATION_HANDLE, + Buffer: *mut PVOID, + PreferredMaximumLength: ULONG, + CountReturned: PULONG, + ) -> NTSTATUS; + pub fn LsaCreateTrustedDomainEx( + PolicyHandle: LSA_HANDLE, + TrustedDomainInformation: PTRUSTED_DOMAIN_INFORMATION_EX, + AuthenticationInformation: PTRUSTED_DOMAIN_AUTH_INFORMATION, + DesiredAccess: ACCESS_MASK, + TrustedDomainHandle: PLSA_HANDLE, + ) -> NTSTATUS; + pub fn LsaQueryForestTrustInformation( + PolicyHandle: LSA_HANDLE, + TrustedDomainName: PLSA_UNICODE_STRING, + ForestTrustInfo: *mut PLSA_FOREST_TRUST_INFORMATION, + ) -> NTSTATUS; + pub fn LsaSetForestTrustInformation( + PolicyHandle: LSA_HANDLE, + TrustedDomainName: PLSA_UNICODE_STRING, + ForestTrustInfo: PLSA_FOREST_TRUST_INFORMATION, + CheckOnly: BOOLEAN, + CollisionInfo: *mut PLSA_FOREST_TRUST_COLLISION_INFORMATION, + ) -> NTSTATUS; + pub fn LsaForestTrustFindMatch( + PolicyHandle: LSA_HANDLE, + Type: ULONG, + Name: PLSA_UNICODE_STRING, + Match: *mut PLSA_UNICODE_STRING, + ) -> NTSTATUS; + pub fn LsaStorePrivateData( + PolicyHandle: LSA_HANDLE, + KeyName: PLSA_UNICODE_STRING, + PrivateData: PLSA_UNICODE_STRING, + ) -> NTSTATUS; + pub fn LsaRetrievePrivateData( + PolicyHandle: LSA_HANDLE, + KeyName: PLSA_UNICODE_STRING, + PrivateData: *mut PLSA_UNICODE_STRING, + ) -> NTSTATUS; + pub fn LsaNtStatusToWinError( + Status: NTSTATUS, + ) -> ULONG; +} +ENUM!{enum NEGOTIATE_MESSAGES { + NegEnumPackagePrefixes = 0, + NegGetCallerName = 1, + NegTransferCredentials = 2, + NegEnumPackageNames = 3, + NegCallPackageMax, +}} +pub const NEGOTIATE_MAX_PREFIX: SIZE_T = 32; +STRUCT!{struct NEGOTIATE_PACKAGE_PREFIX { + PackageId: ULONG_PTR, + PackageDataA: PVOID, + PackageDataW: PVOID, + PrefixLen: ULONG_PTR, + Prefix: [UCHAR; NEGOTIATE_MAX_PREFIX], +}} +pub type PNEGOTIATE_PACKAGE_PREFIX = *mut NEGOTIATE_PACKAGE_PREFIX; +STRUCT!{struct NEGOTIATE_PACKAGE_PREFIXES { + MessageType: ULONG, + PrefixCount: ULONG, + Offset: ULONG, + Pad: ULONG, +}} +pub type PNEGOTIATE_PACKAGE_PREFIXES = *mut NEGOTIATE_PACKAGE_PREFIXES; +STRUCT!{struct NEGOTIATE_CALLER_NAME_REQUEST { + MessageType: ULONG, + LogonId: LUID, +}} +pub type PNEGOTIATE_CALLER_NAME_REQUEST = *mut NEGOTIATE_CALLER_NAME_REQUEST; +STRUCT!{struct NEGOTIATE_CALLER_NAME_RESPONSE { + Messagetype: ULONG, + CallerName: PWSTR, +}} +pub type PNEGOTIATE_CALLER_NAME_RESPONSE = *mut NEGOTIATE_CALLER_NAME_RESPONSE; +STRUCT!{struct NEGOTIATE_PACKAGE_NAMES { + NamesCount: ULONG, + Names: [UNICODE_STRING; ANYSIZE_ARRAY], +}} +pub type PNEGOTIATE_PACKAGE_NAMES = *mut NEGOTIATE_PACKAGE_NAMES; +pub const NEGOTIATE_ALLOW_NTLM: ULONG = 0x10000000; +pub const NEGOTIATE_NEG_NTLM: ULONG = 0x20000000; +STRUCT!{struct NEGOTIATE_PACKAGE_PREFIX_WOW { + PackageId: ULONG, + PackageDataA: ULONG, + PackageDataW: ULONG, + PrefixLen: ULONG, + Prefix: [UCHAR; NEGOTIATE_MAX_PREFIX], +}} +pub type PNEGOTIATE_PACKAGE_PREFIX_WOW = *mut NEGOTIATE_PACKAGE_PREFIX_WOW; +STRUCT!{struct NEGOTIATE_CALLER_NAME_RESPONSE_WOW { + MessageType: ULONG, + CallerName: ULONG, +}} +pub type PNEGOTIATE_CALLER_NAME_RESPONSE_WOW = *mut NEGOTIATE_CALLER_NAME_RESPONSE_WOW; +extern "system" { + pub fn LsaSetPolicyReplicationHandle( + PolicyHandle: PLSA_HANDLE, + ) -> NTSTATUS; +} +pub const MAX_USER_RECORDS: SIZE_T = 1000; +STRUCT!{struct LSA_USER_REGISTRATION_INFO { + Sid: LSA_UNICODE_STRING, + DeviceId: LSA_UNICODE_STRING, + Username: LSA_UNICODE_STRING, + Thumbprint: LSA_UNICODE_STRING, + RegistrationTime: LARGE_INTEGER, +}} +pub type PLSA_USER_REGISTRATION_INFO = *mut LSA_USER_REGISTRATION_INFO; +STRUCT!{struct LSA_REGISTRATION_INFO { + RegisteredCount: ULONG, + UserRegistrationInfo: *mut PLSA_USER_REGISTRATION_INFO, +}} +pub type PLSA_REGISTRATION_INFO = *mut LSA_REGISTRATION_INFO; +extern "system" { + pub fn LsaGetDeviceRegistrationInfo( + RegistrationInfo: *mut PLSA_REGISTRATION_INFO, + ) -> NTSTATUS; +} +ENUM!{enum LSA_CREDENTIAL_KEY_SOURCE_TYPE { + eFromPrecomputed = 1, + eFromClearPassword, + eFromNtOwf, +}} +pub type PLSA_CREDENTIAL_KEY_SOURCE_TYPE = *mut LSA_CREDENTIAL_KEY_SOURCE_TYPE; +extern "C" { + pub fn SeciIsProtectedUser( + ProtectedUser: PBOOLEAN, + ) -> NTSTATUS; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ntsecapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ntsecapi.rs new file mode 100644 index 0000000..cf30ea9 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ntsecapi.rs @@ -0,0 +1,1728 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module defines the Local Security Authority APIs. +use shared::basetsd::{ULONG64, ULONG_PTR}; +use shared::guiddef::GUID; +use shared::minwindef::{PUCHAR, PULONG, UCHAR, ULONG, USHORT}; +use shared::ntdef::NTSTATUS; +use shared::sspi::SecHandle; +use um::lsalookup::{ + LSA_TRUST_INFORMATION, LSA_UNICODE_STRING, PLSA_TRUST_INFORMATION, PLSA_UNICODE_STRING +}; +use um::subauth::{PUNICODE_STRING, STRING, UNICODE_STRING}; +use um::winnt::{ + ACCESS_MASK, ANYSIZE_ARRAY, BOOLEAN, HANDLE, LARGE_INTEGER, LONG, LUID, PACL, PCSTR, PCWSTR, + PSECURITY_DESCRIPTOR, PSID, PSTR, PVOID, PWSTR, QUOTA_LIMITS, SECURITY_INFORMATION, SHORT, SID, + SID_NAME_USE, STANDARD_RIGHTS_EXECUTE, STANDARD_RIGHTS_READ, STANDARD_RIGHTS_REQUIRED, + STANDARD_RIGHTS_WRITE, ULONGLONG +}; +DEFINE_GUID!{Audit_System_SecurityStateChange, + 0x0cce9210, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_System_SecuritySubsystemExtension, + 0x0cce9211, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_System_Integrity, + 0x0cce9212, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_System_IPSecDriverEvents, + 0x0cce9213, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_System_Others, + 0x0cce9214, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_Logon, + 0x0cce9215, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_Logoff, + 0x0cce9216, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_AccountLockout, + 0x0cce9217, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_IPSecMainMode, + 0x0cce9218, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_IPSecQuickMode, + 0x0cce9219, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_IPSecUserMode, + 0x0cce921a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_SpecialLogon, + 0x0cce921b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_Others, + 0x0cce921c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_FileSystem, + 0x0cce921d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Registry, + 0x0cce921e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Kernel, + 0x0cce921f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Sam, + 0x0cce9220, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_CertificationServices, + 0x0cce9221, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_ApplicationGenerated, + 0x0cce9222, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Handle, + 0x0cce9223, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Share, + 0x0cce9224, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_FirewallPacketDrops, + 0x0cce9225, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_FirewallConnection, + 0x0cce9226, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Other, + 0x0cce9227, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PrivilegeUse_Sensitive, + 0x0cce9228, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PrivilegeUse_NonSensitive, + 0x0cce9229, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PrivilegeUse_Others, + 0x0cce922a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DetailedTracking_ProcessCreation, + 0x0cce922b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DetailedTracking_ProcessTermination, + 0x0cce922c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DetailedTracking_DpapiActivity, + 0x0cce922d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DetailedTracking_RpcCall, + 0x0cce922e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_AuditPolicy, + 0x0cce922f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_AuthenticationPolicy, + 0x0cce9230, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_AuthorizationPolicy, + 0x0cce9231, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_MpsscvRulePolicy, + 0x0cce9232, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_WfpIPSecPolicy, + 0x0cce9233, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_Others, + 0x0cce9234, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_UserAccount, + 0x0cce9235, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_ComputerAccount, + 0x0cce9236, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_SecurityGroup, + 0x0cce9237, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_DistributionGroup, + 0x0cce9238, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_ApplicationGroup, + 0x0cce9239, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_Others, + 0x0cce923a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DSAccess_DSAccess, + 0x0cce923b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DsAccess_AdAuditChanges, + 0x0cce923c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Ds_Replication, + 0x0cce923d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Ds_DetailedReplication, + 0x0cce923e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountLogon_CredentialValidation, + 0x0cce923f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountLogon_Kerberos, + 0x0cce9240, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountLogon_Others, + 0x0cce9241, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountLogon_KerbCredentialValidation, + 0x0cce9242, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_NPS, + 0x0cce9243, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_DetailedFileShare, + 0x0cce9244, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_RemovableStorage, + 0x0cce9245, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_CbacStaging, + 0x0cce9246, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_Claims, + 0x0cce9247, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_System, + 0x69979848, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon, + 0x69979849, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess, + 0x6997984a, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PrivilegeUse, + 0x6997984b, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DetailedTracking, + 0x6997984c, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange, + 0x6997984d, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement, + 0x6997984e, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DirectoryServiceAccess, + 0x6997984f, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountLogon, + 0x69979850, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +ENUM!{enum POLICY_AUDIT_EVENT_TYPE { + AuditCategorySystem = 0, + AuditCategoryLogon, + AuditCategoryObjectAccess, + AuditCategoryPrivilegeUse, + AuditCategoryDetailedTracking, + AuditCategoryPolicyChange, + AuditCategoryAccountManagement, + AuditCategoryDirectoryServiceAccess, + AuditCategoryAccountLogon, +}} +pub type PPOLICY_AUDIT_EVENT_TYPE = *mut POLICY_AUDIT_EVENT_TYPE; +pub const POLICY_AUDIT_EVENT_UNCHANGED: POLICY_AUDIT_EVENT_OPTIONS = 0x00000000; +pub const POLICY_AUDIT_EVENT_SUCCESS: POLICY_AUDIT_EVENT_OPTIONS = 0x00000001; +pub const POLICY_AUDIT_EVENT_FAILURE: POLICY_AUDIT_EVENT_OPTIONS = 0x00000002; +pub const POLICY_AUDIT_EVENT_NONE: POLICY_AUDIT_EVENT_OPTIONS = 0x00000004; +pub const POLICY_AUDIT_EVENT_MASK: POLICY_AUDIT_EVENT_OPTIONS = POLICY_AUDIT_EVENT_SUCCESS + | POLICY_AUDIT_EVENT_FAILURE | POLICY_AUDIT_EVENT_UNCHANGED | POLICY_AUDIT_EVENT_NONE; +pub const POLICY_VIEW_LOCAL_INFORMATION: ACCESS_MASK = 0x00000001; +pub const POLICY_VIEW_AUDIT_INFORMATION: ACCESS_MASK = 0x00000002; +pub const POLICY_GET_PRIVATE_INFORMATION: ACCESS_MASK = 0x00000004; +pub const POLICY_TRUST_ADMIN: ACCESS_MASK = 0x00000008; +pub const POLICY_CREATE_ACCOUNT: ACCESS_MASK = 0x00000010; +pub const POLICY_CREATE_SECRET: ACCESS_MASK = 0x00000020; +pub const POLICY_CREATE_PRIVILEGE: ACCESS_MASK = 0x00000040; +pub const POLICY_SET_DEFAULT_QUOTA_LIMITS: ACCESS_MASK = 0x00000080; +pub const POLICY_SET_AUDIT_REQUIREMENTS: ACCESS_MASK = 0x00000100; +pub const POLICY_AUDIT_LOG_ADMIN: ACCESS_MASK = 0x00000200; +pub const POLICY_SERVER_ADMIN: ACCESS_MASK = 0x00000400; +pub const POLICY_LOOKUP_NAMES: ACCESS_MASK = 0x00000800; +pub const POLICY_NOTIFICATION: ACCESS_MASK = 0x00001000; +pub const POLICY_ALL_ACCESS: ACCESS_MASK = STANDARD_RIGHTS_REQUIRED + | POLICY_VIEW_LOCAL_INFORMATION | POLICY_VIEW_AUDIT_INFORMATION + | POLICY_GET_PRIVATE_INFORMATION | POLICY_TRUST_ADMIN | POLICY_CREATE_ACCOUNT + | POLICY_CREATE_SECRET | POLICY_CREATE_PRIVILEGE | POLICY_SET_DEFAULT_QUOTA_LIMITS + | POLICY_SET_AUDIT_REQUIREMENTS | POLICY_AUDIT_LOG_ADMIN | POLICY_SERVER_ADMIN + | POLICY_LOOKUP_NAMES; +pub const POLICY_READ: ACCESS_MASK = STANDARD_RIGHTS_READ | POLICY_VIEW_AUDIT_INFORMATION + | POLICY_GET_PRIVATE_INFORMATION; +pub const POLICY_WRITE: ACCESS_MASK = STANDARD_RIGHTS_WRITE | POLICY_TRUST_ADMIN + | POLICY_CREATE_ACCOUNT | POLICY_CREATE_SECRET | POLICY_CREATE_PRIVILEGE + | POLICY_SET_DEFAULT_QUOTA_LIMITS | POLICY_SET_AUDIT_REQUIREMENTS | POLICY_AUDIT_LOG_ADMIN + | POLICY_SERVER_ADMIN; +pub const POLICY_EXECUTE: ACCESS_MASK = STANDARD_RIGHTS_EXECUTE + | POLICY_VIEW_LOCAL_INFORMATION | POLICY_LOOKUP_NAMES; +STRUCT!{struct LSA_TRANSLATED_SID { + Use: SID_NAME_USE, + RelativeId: ULONG, + DomainIndex: LONG, +}} +pub type PLSA_TRANSLATED_SID = *mut LSA_TRANSLATED_SID; +ENUM!{enum POLICY_LSA_SERVER_ROLE { + PolicyServerRoleBackup = 2, + PolicyServerRolePrimary, +}} +pub type PPOLICY_LSA_SERVER_ROLE = *mut POLICY_LSA_SERVER_ROLE; +pub type POLICY_AUDIT_EVENT_OPTIONS = ULONG; +pub type PPOLICY_AUDIT_EVENT_OPTIONS = *mut ULONG; +ENUM!{enum POLICY_INFORMATION_CLASS { + PolicyAuditLogInformation = 1, + PolicyAuditEventsInformation, + PolicyPrimaryDomainInformation, + PolicyPdAccountInformation, + PolicyAccountDomainInformation, + PolicyLsaServerRoleInformation, + PolicyReplicaSourceInformation, + PolicyDefaultQuotaInformation, + PolicyModificationInformation, + PolicyAuditFullSetInformation, + PolicyAuditFullQueryInformation, + PolicyDnsDomainInformation, + PolicyDnsDomainInformationInt, + PolicyLocalAccountDomainInformation, + PolicyLastEntry, +}} +pub type PPOLICY_INFORMATION_CLASS = *mut POLICY_INFORMATION_CLASS; +STRUCT!{struct POLICY_AUDIT_LOG_INFO { + AuditLogPercentFull: ULONG, + MaximumLogSize: ULONG, + AuditRetentionPeriod: LARGE_INTEGER, + AuditLogFullShutdownInProgress: BOOLEAN, + TimeToShutdown: LARGE_INTEGER, + NextAuditRecordId: ULONG, +}} +pub type PPOLICY_AUDIT_LOG_INFO = *mut POLICY_AUDIT_LOG_INFO; +STRUCT!{struct POLICY_AUDIT_EVENTS_INFO { + AuditingMode: BOOLEAN, + EventAuditingOptions: PPOLICY_AUDIT_EVENT_OPTIONS, + MaximumAuditEventCount: ULONG, +}} +pub type PPOLICY_AUDIT_EVENTS_INFO = *mut POLICY_AUDIT_EVENTS_INFO; +STRUCT!{struct POLICY_AUDIT_SUBCATEGORIES_INFO { + MaximumSubCategoryCount: ULONG, + EventAuditingOptions: PPOLICY_AUDIT_EVENT_OPTIONS, +}} +pub type PPOLICY_AUDIT_SUBCATEGORIES_INFO = *mut POLICY_AUDIT_SUBCATEGORIES_INFO; +STRUCT!{struct POLICY_AUDIT_CATEGORIES_INFO { + MaximumSubCategoryCount: ULONG, + SubCategoriesInfo: PPOLICY_AUDIT_SUBCATEGORIES_INFO, +}} +pub type PPOLICY_AUDIT_CATEGORIES_INFO = *mut POLICY_AUDIT_CATEGORIES_INFO; +pub const PER_USER_POLICY_UNCHANGED: ULONG = 0x00; +pub const PER_USER_AUDIT_SUCCESS_INCLUDE: ULONG = 0x01; +pub const PER_USER_AUDIT_SUCCESS_EXCLUDE: ULONG = 0x02; +pub const PER_USER_AUDIT_FAILURE_INCLUDE: ULONG = 0x04; +pub const PER_USER_AUDIT_FAILURE_EXCLUDE: ULONG = 0x08; +pub const PER_USER_AUDIT_NONE: ULONG = 0x10; +pub const VALID_PER_USER_AUDIT_POLICY_FLAG: ULONG = PER_USER_AUDIT_SUCCESS_INCLUDE + | PER_USER_AUDIT_SUCCESS_EXCLUDE | PER_USER_AUDIT_FAILURE_INCLUDE + | PER_USER_AUDIT_FAILURE_EXCLUDE | PER_USER_AUDIT_NONE; +STRUCT!{struct POLICY_PRIMARY_DOMAIN_INFO { + Name: LSA_UNICODE_STRING, + Sid: PSID, +}} +pub type PPOLICY_PRIMARY_DOMAIN_INFO = *mut POLICY_PRIMARY_DOMAIN_INFO; +STRUCT!{struct POLICY_PD_ACCOUNT_INFO { + Name: LSA_UNICODE_STRING, +}} +pub type PPOLICY_PD_ACCOUNT_INFO = *mut POLICY_PD_ACCOUNT_INFO; +STRUCT!{struct POLICY_LSA_SERVER_ROLE_INFO { + LsaServerRole: POLICY_LSA_SERVER_ROLE, +}} +pub type PPOLICY_LSA_SERVER_ROLE_INFO = *mut POLICY_LSA_SERVER_ROLE_INFO; +STRUCT!{struct POLICY_REPLICA_SOURCE_INFO { + ReplicaSource: LSA_UNICODE_STRING, + ReplicaAccountName: LSA_UNICODE_STRING, +}} +pub type PPOLICY_REPLICA_SOURCE_INFO = *mut POLICY_REPLICA_SOURCE_INFO; +STRUCT!{struct POLICY_DEFAULT_QUOTA_INFO { + QuotaLimits: QUOTA_LIMITS, +}} +pub type PPOLICY_DEFAULT_QUOTA_INFO = *mut POLICY_DEFAULT_QUOTA_INFO; +STRUCT!{struct POLICY_MODIFICATION_INFO { + ModifiedId: LARGE_INTEGER, + DatabaseCreationTime: LARGE_INTEGER, +}} +pub type PPOLICY_MODIFICATION_INFO = *mut POLICY_MODIFICATION_INFO; +STRUCT!{struct POLICY_AUDIT_FULL_SET_INFO { + ShutDownOnFull: BOOLEAN, +}} +pub type PPOLICY_AUDIT_FULL_SET_INFO = *mut POLICY_AUDIT_FULL_SET_INFO; +STRUCT!{struct POLICY_AUDIT_FULL_QUERY_INFO { + ShutDownOnFull: BOOLEAN, + LogIsFull: BOOLEAN, +}} +pub type PPOLICY_AUDIT_FULL_QUERY_INFO = *mut POLICY_AUDIT_FULL_QUERY_INFO; +ENUM!{enum POLICY_DOMAIN_INFORMATION_CLASS { + PolicyDomainEfsInformation = 2, + PolicyDomainKerberosTicketInformation, +}} +pub type PPOLICY_DOMAIN_INFORMATION_CLASS = *mut POLICY_DOMAIN_INFORMATION_CLASS; +STRUCT!{struct POLICY_DOMAIN_EFS_INFO { + InfoLength: ULONG, + EfsBlob: PUCHAR, +}} +pub type PPOLICY_DOMAIN_EFS_INFO = *mut POLICY_DOMAIN_EFS_INFO; +STRUCT!{struct POLICY_DOMAIN_KERBEROS_TICKET_INFO { + AuthenticationOptions: ULONG, + MaxServiceTicketAge: LARGE_INTEGER, + MaxTicketAge: LARGE_INTEGER, + MaxRenewAge: LARGE_INTEGER, + MaxClockSkew: LARGE_INTEGER, + Reserved: LARGE_INTEGER, +}} +pub type PPOLICY_DOMAIN_KERBEROS_TICKET_INFO = *mut POLICY_DOMAIN_KERBEROS_TICKET_INFO; +ENUM!{enum POLICY_NOTIFICATION_INFORMATION_CLASS { + PolicyNotifyAuditEventsInformation = 1, + PolicyNotifyAccountDomainInformation, + PolicyNotifyServerRoleInformation, + PolicyNotifyDnsDomainInformation, + PolicyNotifyDomainEfsInformation, + PolicyNotifyDomainKerberosTicketInformation, + PolicyNotifyMachineAccountPasswordInformation, + PolicyNotifyGlobalSaclInformation, + PolicyNotifyMax, +}} +pub type PPOLICY_NOTIFICATION_INFORMATION_CLASS = *mut POLICY_NOTIFICATION_INFORMATION_CLASS; +pub type LSA_HANDLE = PVOID; +pub type PLSA_HANDLE = *mut PVOID; +ENUM!{enum TRUSTED_INFORMATION_CLASS { + TrustedDomainNameInformation = 1, + TrustedControllersInformation, + TrustedPosixOffsetInformation, + TrustedPasswordInformation, + TrustedDomainInformationBasic, + TrustedDomainInformationEx, + TrustedDomainAuthInformation, + TrustedDomainFullInformation, + TrustedDomainAuthInformationInternal, + TrustedDomainFullInformationInternal, + TrustedDomainInformationEx2Internal, + TrustedDomainFullInformation2Internal, + TrustedDomainSupportedEncryptionTypes, +}} +pub type PTRUSTED_INFORMATION_CLASS = *mut TRUSTED_INFORMATION_CLASS; +STRUCT!{struct TRUSTED_DOMAIN_NAME_INFO { + Name: LSA_UNICODE_STRING, +}} +pub type PTRUSTED_DOMAIN_NAME_INFO = *mut TRUSTED_DOMAIN_NAME_INFO; +STRUCT!{struct TRUSTED_CONTROLLERS_INFO { + Entries: ULONG, + Names: PLSA_UNICODE_STRING, +}} +pub type PTRUSTED_CONTROLLERS_INFO = *mut TRUSTED_CONTROLLERS_INFO; +STRUCT!{struct TRUSTED_POSIX_OFFSET_INFO { + Offset: ULONG, +}} +pub type PTRUSTED_POSIX_OFFSET_INFO = *mut TRUSTED_POSIX_OFFSET_INFO; +STRUCT!{struct TRUSTED_PASSWORD_INFO { + Password: LSA_UNICODE_STRING, + OldPassword: LSA_UNICODE_STRING, +}} +pub type PTRUSTED_PASSWORD_INFO = *mut TRUSTED_PASSWORD_INFO; +pub type TRUSTED_DOMAIN_INFORMATION_BASIC = LSA_TRUST_INFORMATION; +pub type PTRUSTED_DOMAIN_INFORMATION_BASIC = PLSA_TRUST_INFORMATION; +pub const TRUST_DIRECTION_DISABLED: ULONG = 0x00000000; +pub const TRUST_DIRECTION_INBOUND: ULONG = 0x00000001; +pub const TRUST_DIRECTION_OUTBOUND: ULONG = 0x00000002; +pub const TRUST_DIRECTION_BIDIRECTIONAL: ULONG = TRUST_DIRECTION_INBOUND + | TRUST_DIRECTION_OUTBOUND; +pub const TRUST_TYPE_DOWNLEVEL: ULONG = 0x00000001; +pub const TRUST_TYPE_UPLEVEL: ULONG = 0x00000002; +pub const TRUST_TYPE_MIT: ULONG = 0x00000003; +pub const TRUST_ATTRIBUTE_NON_TRANSITIVE: ULONG = 0x00000001; +pub const TRUST_ATTRIBUTE_UPLEVEL_ONLY: ULONG = 0x00000002; +pub const TRUST_ATTRIBUTE_QUARANTINED_DOMAIN: ULONG = 0x00000004; +pub const TRUST_ATTRIBUTE_FOREST_TRANSITIVE: ULONG = 0x00000008; +pub const TRUST_ATTRIBUTE_CROSS_ORGANIZATION: ULONG = 0x00000010; +pub const TRUST_ATTRIBUTE_WITHIN_FOREST: ULONG = 0x00000020; +pub const TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL: ULONG = 0x00000040; +pub const TRUST_ATTRIBUTE_TRUST_USES_RC4_ENCRYPTION: ULONG = 0x00000080; +pub const TRUST_ATTRIBUTE_TRUST_USES_AES_KEYS: ULONG = 0x00000100; +pub const TRUST_ATTRIBUTE_CROSS_ORGANIZATION_NO_TGT_DELEGATION: ULONG = 0x00000200; +pub const TRUST_ATTRIBUTES_VALID: ULONG = 0xFF03FFFF; +pub const TRUST_ATTRIBUTES_USER: ULONG = 0xFF000000; +STRUCT!{struct TRUSTED_DOMAIN_INFORMATION_EX { + Name: LSA_UNICODE_STRING, + FlatName: LSA_UNICODE_STRING, + Sid: PSID, + TrustDirection: ULONG, + TrustType: ULONG, + TrustAttributes: ULONG, +}} +pub type PTRUSTED_DOMAIN_INFORMATION_EX = *mut TRUSTED_DOMAIN_INFORMATION_EX; +STRUCT!{struct TRUSTED_DOMAIN_INFORMATION_EX2 { + Name: LSA_UNICODE_STRING, + FlatName: LSA_UNICODE_STRING, + Sid: PSID, + TrustDirection: ULONG, + TrustType: ULONG, + TrustAttributes: ULONG, + ForestTrustLength: ULONG, + ForestTrustInfo: PUCHAR, +}} +pub type PTRUSTED_DOMAIN_INFORMATION_EX2 = *mut TRUSTED_DOMAIN_INFORMATION_EX2; +pub const TRUST_AUTH_TYPE_NONE: ULONG = 0; +pub const TRUST_AUTH_TYPE_NT4OWF: ULONG = 1; +pub const TRUST_AUTH_TYPE_CLEAR: ULONG = 2; +pub const TRUST_AUTH_TYPE_VERSION: ULONG = 3; +STRUCT!{struct LSA_AUTH_INFORMATION { + LastUpdateTime: LARGE_INTEGER, + AuthType: ULONG, + AuthInfoLength: ULONG, + AuthInfo: PUCHAR, +}} +pub type PLSA_AUTH_INFORMATION = *mut LSA_AUTH_INFORMATION; +STRUCT!{struct TRUSTED_DOMAIN_AUTH_INFORMATION { + IncomingAuthInfos: ULONG, + IncomingAuthenticationInformation: PLSA_AUTH_INFORMATION, + IncomingPreviousAuthenticationInformation: PLSA_AUTH_INFORMATION, + OutgoingAuthInfos: ULONG, + OutgoingAuthenticationInformation: PLSA_AUTH_INFORMATION, + OutgoingPreviousAuthenticationInformation: PLSA_AUTH_INFORMATION, +}} +pub type PTRUSTED_DOMAIN_AUTH_INFORMATION = *mut TRUSTED_DOMAIN_AUTH_INFORMATION; +STRUCT!{struct TRUSTED_DOMAIN_FULL_INFORMATION { + Information: TRUSTED_DOMAIN_INFORMATION_EX, + PosixOffset: TRUSTED_POSIX_OFFSET_INFO, + AuthInformation: TRUSTED_DOMAIN_AUTH_INFORMATION, +}} +pub type PTRUSTED_DOMAIN_FULL_INFORMATION = *mut TRUSTED_DOMAIN_FULL_INFORMATION; +STRUCT!{struct TRUSTED_DOMAIN_FULL_INFORMATION2 { + Information: TRUSTED_DOMAIN_INFORMATION_EX2, + PosixOffset: TRUSTED_POSIX_OFFSET_INFO, + AuthInformation: TRUSTED_DOMAIN_AUTH_INFORMATION, +}} +pub type PTRUSTED_DOMAIN_FULL_INFORMATION2 = *mut TRUSTED_DOMAIN_FULL_INFORMATION2; +STRUCT!{struct TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES { + SupportedEncryptionTypes: ULONG, +}} +pub type PTRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES = + *mut TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES; +ENUM!{enum LSA_FOREST_TRUST_RECORD_TYPE { + ForestTrustTopLevelName, + ForestTrustTopLevelNameEx, + ForestTrustDomainInfo, + ForestTrustRecordTypeLast, // = ForestTrustDomainInfo, +}} +pub const LSA_FTRECORD_DISABLED_REASONS: ULONG = 0x0000FFFF; +pub const LSA_TLN_DISABLED_NEW: ULONG = 0x00000001; +pub const LSA_TLN_DISABLED_ADMIN: ULONG = 0x00000002; +pub const LSA_TLN_DISABLED_CONFLICT: ULONG = 0x00000004; +pub const LSA_SID_DISABLED_ADMIN: ULONG = 0x00000001; +pub const LSA_SID_DISABLED_CONFLICT: ULONG = 0x00000002; +pub const LSA_NB_DISABLED_ADMIN: ULONG = 0x00000004; +pub const LSA_NB_DISABLED_CONFLICT: ULONG = 0x00000008; +STRUCT!{struct LSA_FOREST_TRUST_DOMAIN_INFO { + Sid: PSID, + DnsName: LSA_UNICODE_STRING, + NetbiosName: LSA_UNICODE_STRING, +}} +pub type PLSA_FOREST_TRUST_DOMAIN_INFO = *mut LSA_FOREST_TRUST_DOMAIN_INFO; +pub const MAX_FOREST_TRUST_BINARY_DATA_SIZE: ULONG = 128 * 1024; +STRUCT!{struct LSA_FOREST_TRUST_BINARY_DATA { + Length: ULONG, + Buffer: PUCHAR, +}} +pub type PLSA_FOREST_TRUST_BINARY_DATA = *mut LSA_FOREST_TRUST_BINARY_DATA; +UNION!{union LSA_FOREST_TRUST_RECORD_ForestTrustData { + [usize; 5], + TopLevelName TopLevelName_mut: LSA_UNICODE_STRING, + DomainInfo DomainInfo_mut: LSA_FOREST_TRUST_DOMAIN_INFO, + Data Data_mut: LSA_FOREST_TRUST_BINARY_DATA, +}} +STRUCT!{struct LSA_FOREST_TRUST_RECORD { + Flags: ULONG, + ForestTrustType: LSA_FOREST_TRUST_RECORD_TYPE, + Time: LARGE_INTEGER, + ForestTrustData: LSA_FOREST_TRUST_RECORD_ForestTrustData, +}} +pub type PLSA_FOREST_TRUST_RECORD = *mut LSA_FOREST_TRUST_RECORD; +pub const MAX_RECORDS_IN_FOREST_TRUST_INFO: ULONG = 4000; +STRUCT!{struct LSA_FOREST_TRUST_INFORMATION { + RecordCount: ULONG, + Entries: *mut PLSA_FOREST_TRUST_RECORD, +}} +pub type PLSA_FOREST_TRUST_INFORMATION = *mut LSA_FOREST_TRUST_INFORMATION; +ENUM!{enum LSA_FOREST_TRUST_COLLISION_RECORD_TYPE { + CollisionTdo, + CollisionXref, + CollisionOther, +}} +STRUCT!{struct LSA_FOREST_TRUST_COLLISION_RECORD { + Index: ULONG, + Type: LSA_FOREST_TRUST_COLLISION_RECORD_TYPE, + Flags: ULONG, + Name: LSA_UNICODE_STRING, +}} +pub type PLSA_FOREST_TRUST_COLLISION_RECORD = *mut LSA_FOREST_TRUST_COLLISION_RECORD; +STRUCT!{struct LSA_FOREST_TRUST_COLLISION_INFORMATION { + RecordCount: ULONG, + Entries: *mut PLSA_FOREST_TRUST_COLLISION_RECORD, +}} +pub type PLSA_FOREST_TRUST_COLLISION_INFORMATION = *mut LSA_FOREST_TRUST_COLLISION_INFORMATION; +pub type LSA_ENUMERATION_HANDLE = ULONG; +pub type PLSA_ENUMERATION_HANDLE = *mut ULONG; +STRUCT!{struct LSA_ENUMERATION_INFORMATION { + Sid: PSID, +}} +pub type PLSA_ENUMERATION_INFORMATION = *mut LSA_ENUMERATION_INFORMATION; +STRUCT!{struct LSA_LAST_INTER_LOGON_INFO { + LastSuccessfulLogon: LARGE_INTEGER, + LastFailedLogon: LARGE_INTEGER, + FailedAttemptCountSinceLastSuccessfulLogon: ULONG, +}} +pub type PLSA_LAST_INTER_LOGON_INFO = *mut LSA_LAST_INTER_LOGON_INFO; +STRUCT!{struct SECURITY_LOGON_SESSION_DATA { + Size: ULONG, + LogonId: LUID, + UserName: LSA_UNICODE_STRING, + LogonDomain: LSA_UNICODE_STRING, + AuthenticationPackage: LSA_UNICODE_STRING, + LogonType: ULONG, + Session: ULONG, + Sid: PSID, + LogonTime: LARGE_INTEGER, + LogonServer: LSA_UNICODE_STRING, + DnsDomainName: LSA_UNICODE_STRING, + Upn: LSA_UNICODE_STRING, + UserFlags: ULONG, + LastLogonInfo: LSA_LAST_INTER_LOGON_INFO, + LogonScript: LSA_UNICODE_STRING, + ProfilePath: LSA_UNICODE_STRING, + HomeDirectory: LSA_UNICODE_STRING, + HomeDirectoryDrive: LSA_UNICODE_STRING, + LogoffTime: LARGE_INTEGER, + KickOffTime: LARGE_INTEGER, + PasswordLastSet: LARGE_INTEGER, + PasswordCanChange: LARGE_INTEGER, + PasswordMustChange: LARGE_INTEGER, +}} +pub type PSECURITY_LOGON_SESSION_DATA = *mut SECURITY_LOGON_SESSION_DATA; +pub const CENTRAL_ACCESS_POLICY_OWNER_RIGHTS_PRESENT_FLAG: ULONG = 0x00000001; +pub const CENTRAL_ACCESS_POLICY_STAGED_OWNER_RIGHTS_PRESENT_FLAG: ULONG = 0x00000100; +pub const CENTRAL_ACCESS_POLICY_STAGED_FLAG: ULONG = 0x00010000; +pub const CENTRAL_ACCESS_POLICY_VALID_FLAG_MASK: ULONG = + CENTRAL_ACCESS_POLICY_OWNER_RIGHTS_PRESENT_FLAG + | CENTRAL_ACCESS_POLICY_STAGED_OWNER_RIGHTS_PRESENT_FLAG + | CENTRAL_ACCESS_POLICY_STAGED_FLAG; +pub const LSASETCAPS_RELOAD_FLAG: ULONG = 0x00000001; +pub const LSASETCAPS_VALID_FLAG_MASK: ULONG = LSASETCAPS_RELOAD_FLAG; +STRUCT!{struct CENTRAL_ACCESS_POLICY_ENTRY { + Name: LSA_UNICODE_STRING, + Description: LSA_UNICODE_STRING, + ChangeId: LSA_UNICODE_STRING, + LengthAppliesTo: ULONG, + AppliesTo: PUCHAR, + LengthSD: ULONG, + SD: PSECURITY_DESCRIPTOR, + LengthStagedSD: ULONG, + StagedSD: PSECURITY_DESCRIPTOR, + Flags: ULONG, +}} +pub type PCENTRAL_ACCESS_POLICY_ENTRY = *mut CENTRAL_ACCESS_POLICY_ENTRY; +pub type PCCENTRAL_ACCESS_POLICY_ENTRY = *const CENTRAL_ACCESS_POLICY_ENTRY; +STRUCT!{struct CENTRAL_ACCESS_POLICY { + CAPID: PSID, + Name: LSA_UNICODE_STRING, + Description: LSA_UNICODE_STRING, + ChangeId: LSA_UNICODE_STRING, + Flags: ULONG, + CAPECount: ULONG, + CAPEs: *mut PCENTRAL_ACCESS_POLICY_ENTRY, +}} +pub type PCENTRAL_ACCESS_POLICY = *mut CENTRAL_ACCESS_POLICY; +pub type PCCENTRAL_ACCESS_POLICY = *const CENTRAL_ACCESS_POLICY; +ENUM!{enum NEGOTIATE_MESSAGES { + NegEnumPackagePrefixes = 0, + NegGetCallerName = 1, + NegTransferCredentials = 2, + NegCallPackageMax, +}} +pub const NEGOTIATE_MAX_PREFIX: usize = 32; +STRUCT!{struct NEGOTIATE_PACKAGE_PREFIX { + PackageId: ULONG_PTR, + PackageDataA: PVOID, + PackageDataW: PVOID, + PrefixLen: ULONG_PTR, + Prefix: [UCHAR; NEGOTIATE_MAX_PREFIX], +}} +pub type PNEGOTIATE_PACKAGE_PREFIX = *mut NEGOTIATE_PACKAGE_PREFIX; +STRUCT!{struct NEGOTIATE_PACKAGE_PREFIXES { + MessageType: ULONG, + PrefixCount: ULONG, + Offset: ULONG, + Pad: ULONG, +}} +pub type PNEGOTIATE_PACKAGE_PREFIXES = *mut NEGOTIATE_PACKAGE_PREFIXES; +STRUCT!{struct NEGOTIATE_CALLER_NAME_REQUEST { + MessageType: ULONG, + LogonId: LUID, +}} +pub type PNEGOTIATE_CALLER_NAME_REQUEST = *mut NEGOTIATE_CALLER_NAME_REQUEST; +STRUCT!{struct NEGOTIATE_CALLER_NAME_RESPONSE { + MessageType: ULONG, + CallerName: PWSTR, +}} +pub type PNEGOTIATE_CALLER_NAME_RESPONSE = *mut NEGOTIATE_CALLER_NAME_RESPONSE; +STRUCT!{struct DOMAIN_PASSWORD_INFORMATION { + MinPasswordLength: USHORT, + PasswordHistoryLength: USHORT, + PasswordProperties: ULONG, + MaxPasswordAge: LARGE_INTEGER, + MinPasswordAge: LARGE_INTEGER, +}} +pub type PDOMAIN_PASSWORD_INFORMATION = *mut DOMAIN_PASSWORD_INFORMATION; +pub const DOMAIN_PASSWORD_COMPLEX: ULONG = 0x00000001; +pub const DOMAIN_PASSWORD_NO_ANON_CHANGE: ULONG = 0x00000002; +pub const DOMAIN_PASSWORD_NO_CLEAR_CHANGE: ULONG = 0x00000004; +pub const DOMAIN_LOCKOUT_ADMINS: ULONG = 0x00000008; +pub const DOMAIN_PASSWORD_STORE_CLEARTEXT: ULONG = 0x00000010; +pub const DOMAIN_REFUSE_PASSWORD_CHANGE: ULONG = 0x00000020; +pub const DOMAIN_NO_LM_OWF_CHANGE: ULONG = 0x00000040; +FN!{stdcall PSAM_PASSWORD_NOTIFICATION_ROUTINE( + UserName: PUNICODE_STRING, + RelativeId: ULONG, + NewPassword: PUNICODE_STRING, +) -> NTSTATUS} +FN!{stdcall PSAM_INIT_NOTIFICATION_ROUTINE() -> BOOLEAN} +FN!{stdcall PSAM_PASSWORD_FILTER_ROUTINE( + AccountName: PUNICODE_STRING, + FullName: PUNICODE_STRING, + Password: PUNICODE_STRING, + SetOperation: BOOLEAN, +) -> BOOLEAN} +ENUM!{enum MSV1_0_LOGON_SUBMIT_TYPE { + MsV1_0InteractiveLogon = 2, + MsV1_0Lm20Logon, + MsV1_0NetworkLogon, + MsV1_0SubAuthLogon, + MsV1_0WorkstationUnlockLogon = 7, + MsV1_0S4ULogon = 12, + MsV1_0VirtualLogon = 82, + MsV1_0NoElevationLogon = 83, + MsV1_0LuidLogon = 84, +}} +pub type PMSV1_0_LOGON_SUBMIT_TYPE = *mut MSV1_0_LOGON_SUBMIT_TYPE; +ENUM!{enum MSV1_0_PROFILE_BUFFER_TYPE { + MsV1_0InteractiveProfile = 2, + MsV1_0Lm20LogonProfile, + MsV1_0SmartCardProfile, +}} +pub type PMSV1_0_PROFILE_BUFFER_TYPE = *mut MSV1_0_PROFILE_BUFFER_TYPE; +STRUCT!{struct MSV1_0_INTERACTIVE_LOGON { + MessageType: MSV1_0_LOGON_SUBMIT_TYPE, + LogonDomainName: UNICODE_STRING, + UserName: UNICODE_STRING, + Password: UNICODE_STRING, +}} +pub type PMSV1_0_INTERACTIVE_LOGON = *mut MSV1_0_INTERACTIVE_LOGON; +STRUCT!{struct MSV1_0_INTERACTIVE_PROFILE { + MessageType: MSV1_0_PROFILE_BUFFER_TYPE, + LogonCount: USHORT, + BadPasswordCount: USHORT, + LogonTime: LARGE_INTEGER, + LogoffTime: LARGE_INTEGER, + KickOffTime: LARGE_INTEGER, + PasswordLastSet: LARGE_INTEGER, + PasswordCanChange: LARGE_INTEGER, + PasswordMustChange: LARGE_INTEGER, + LogonScript: UNICODE_STRING, + HomeDirectory: UNICODE_STRING, + FullName: UNICODE_STRING, + ProfilePath: UNICODE_STRING, + HomeDirectoryDrive: UNICODE_STRING, + LogonServer: UNICODE_STRING, + UserFlags: ULONG, +}} +pub type PMSV1_0_INTERACTIVE_PROFILE = *mut MSV1_0_INTERACTIVE_PROFILE; +pub const MSV1_0_CHALLENGE_LENGTH: usize = 8; +pub const MSV1_0_USER_SESSION_KEY_LENGTH: usize = 16; +pub const MSV1_0_LANMAN_SESSION_KEY_LENGTH: usize = 8; +pub const MSV1_0_CLEARTEXT_PASSWORD_ALLOWED: ULONG = 0x02; +pub const MSV1_0_UPDATE_LOGON_STATISTICS: ULONG = 0x04; +pub const MSV1_0_RETURN_USER_PARAMETERS: ULONG = 0x08; +pub const MSV1_0_DONT_TRY_GUEST_ACCOUNT: ULONG = 0x10; +pub const MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT: ULONG = 0x20; +pub const MSV1_0_RETURN_PASSWORD_EXPIRY: ULONG = 0x40; +pub const MSV1_0_USE_CLIENT_CHALLENGE: ULONG = 0x80; +pub const MSV1_0_TRY_GUEST_ACCOUNT_ONLY: ULONG = 0x100; +pub const MSV1_0_RETURN_PROFILE_PATH: ULONG = 0x200; +pub const MSV1_0_TRY_SPECIFIED_DOMAIN_ONLY: ULONG = 0x400; +pub const MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT: ULONG = 0x800; +pub const MSV1_0_DISABLE_PERSONAL_FALLBACK: ULONG = 0x00001000; +pub const MSV1_0_ALLOW_FORCE_GUEST: ULONG = 0x00002000; +pub const MSV1_0_CLEARTEXT_PASSWORD_SUPPLIED: ULONG = 0x00004000; +pub const MSV1_0_USE_DOMAIN_FOR_ROUTING_ONLY: ULONG = 0x00008000; +pub const MSV1_0_SUBAUTHENTICATION_DLL_EX: ULONG = 0x00100000; +pub const MSV1_0_ALLOW_MSVCHAPV2: ULONG = 0x00010000; +pub const MSV1_0_S4U2SELF: ULONG = 0x00020000; +pub const MSV1_0_CHECK_LOGONHOURS_FOR_S4U: ULONG = 0x00040000; +pub const MSV1_0_INTERNET_DOMAIN: ULONG = 0x00080000; +pub const MSV1_0_SUBAUTHENTICATION_DLL: ULONG = 0xFF000000; +pub const MSV1_0_SUBAUTHENTICATION_DLL_SHIFT: ULONG = 24; +pub const MSV1_0_MNS_LOGON: ULONG = 0x01000000; +pub const MSV1_0_SUBAUTHENTICATION_DLL_RAS: ULONG = 2; +pub const MSV1_0_SUBAUTHENTICATION_DLL_IIS: ULONG = 132; +STRUCT!{struct MSV1_0_LM20_LOGON { + MessageType: MSV1_0_LOGON_SUBMIT_TYPE, + LogonDomainName: UNICODE_STRING, + UserName: UNICODE_STRING, + Workstation: UNICODE_STRING, + ChallengeToClient: [UCHAR; MSV1_0_CHALLENGE_LENGTH], + CaseSensitiveChallengeResponse: STRING, + CaseInsensitiveChallengeResponse: STRING, + ParameterControl: ULONG, +}} +pub type PMSV1_0_LM20_LOGON = *mut MSV1_0_LM20_LOGON; +STRUCT!{struct MSV1_0_SUBAUTH_LOGON { + MessageType: MSV1_0_LOGON_SUBMIT_TYPE, + LogonDomainName: UNICODE_STRING, + UserName: UNICODE_STRING, + Workstation: UNICODE_STRING, + ChallengeToClient: [UCHAR; MSV1_0_CHALLENGE_LENGTH], + AuthenticationInfo1: STRING, + AuthenticationInfo2: STRING, + ParameterControl: ULONG, + SubAuthPackageId: ULONG, +}} +pub type PMSV1_0_SUBAUTH_LOGON = *mut MSV1_0_SUBAUTH_LOGON; +STRUCT!{struct MSV1_0_S4U_LOGON { + MessageType: MSV1_0_LOGON_SUBMIT_TYPE, + MSV1_0_LOGON_SUBMIT_TYPE: ULONG, + UserPrincipalName: UNICODE_STRING, + DomainName: UNICODE_STRING, +}} +pub type PMSV1_0_S4U_LOGON = *mut MSV1_0_S4U_LOGON; +pub const LOGON_GUEST: ULONG = 0x01; +pub const LOGON_NOENCRYPTION: ULONG = 0x02; +pub const LOGON_CACHED_ACCOUNT: ULONG = 0x04; +pub const LOGON_USED_LM_PASSWORD: ULONG = 0x08; +pub const LOGON_EXTRA_SIDS: ULONG = 0x20; +pub const LOGON_SUBAUTH_SESSION_KEY: ULONG = 0x40; +pub const LOGON_SERVER_TRUST_ACCOUNT: ULONG = 0x80; +pub const LOGON_NTLMV2_ENABLED: ULONG = 0x100; +pub const LOGON_RESOURCE_GROUPS: ULONG = 0x200; +pub const LOGON_PROFILE_PATH_RETURNED: ULONG = 0x400; +pub const LOGON_NT_V2: ULONG = 0x800; +pub const LOGON_LM_V2: ULONG = 0x1000; +pub const LOGON_NTLM_V2: ULONG = 0x2000; +pub const LOGON_OPTIMIZED: ULONG = 0x4000; +pub const LOGON_WINLOGON: ULONG = 0x8000; +pub const LOGON_PKINIT: ULONG = 0x10000; +pub const LOGON_NO_OPTIMIZED: ULONG = 0x20000; +pub const LOGON_NO_ELEVATION: ULONG = 0x40000; +pub const LOGON_MANAGED_SERVICE: ULONG = 0x80000; +pub const LOGON_GRACE_LOGON: ULONG = 0x01000000; +STRUCT!{struct MSV1_0_LM20_LOGON_PROFILE { + MessageType: MSV1_0_PROFILE_BUFFER_TYPE, + KickOffTime: LARGE_INTEGER, + LogoffTime: LARGE_INTEGER, + UserFlags: ULONG, + UserSessionKey: [UCHAR; MSV1_0_USER_SESSION_KEY_LENGTH], + LogonDomainName: UNICODE_STRING, + LanmanSessionKey: [UCHAR; MSV1_0_LANMAN_SESSION_KEY_LENGTH], + LogonServer: UNICODE_STRING, + UserParameters: UNICODE_STRING, +}} +pub type PMSV1_0_LM20_LOGON_PROFILE = *mut MSV1_0_LM20_LOGON_PROFILE; +pub const MSV1_0_OWF_PASSWORD_LENGTH: usize = 16; +STRUCT!{struct MSV1_0_SUPPLEMENTAL_CREDENTIAL { + Version: ULONG, + Flags: ULONG, + LmPassword: [UCHAR; MSV1_0_OWF_PASSWORD_LENGTH], + NtPassword: [UCHAR; MSV1_0_OWF_PASSWORD_LENGTH], +}} +pub type PMSV1_0_SUPPLEMENTAL_CREDENTIAL = *mut MSV1_0_SUPPLEMENTAL_CREDENTIAL; +pub const MSV1_0_NTLM3_RESPONSE_LENGTH: usize = 16; +pub const MSV1_0_NTLM3_OWF_LENGTH: usize = 16; +STRUCT!{struct MSV1_0_NTLM3_RESPONSE { + Response: [UCHAR; MSV1_0_NTLM3_RESPONSE_LENGTH], + RespType: UCHAR, + HiRespType: UCHAR, + Flags: USHORT, + MsgWord: ULONG, + TimeStamp: ULONGLONG, + ChallengeFromClient: [UCHAR; MSV1_0_CHALLENGE_LENGTH], + AvPairsOff: ULONG, + Buffer: [UCHAR; 1], +}} +pub type PMSV1_0_NTLM3_RESPONSE = *mut MSV1_0_NTLM3_RESPONSE; +ENUM!{enum MSV1_0_AVID { + MsvAvEOL, + MsvAvNbComputerName, + MsvAvNbDomainName, + MsvAvDnsComputerName, + MsvAvDnsDomainName, + MsvAvDnsTreeName, + MsvAvFlags, + MsvAvTimestamp, + MsvAvRestrictions, + MsvAvTargetName, + MsvAvChannelBindings, +}} +STRUCT!{struct MSV1_0_AV_PAIR { + AvId: USHORT, + AvLen: USHORT, +}} +pub type PMSV1_0_AV_PAIR = *mut MSV1_0_AV_PAIR; +ENUM!{enum MSV1_0_PROTOCOL_MESSAGE_TYPE { + MsV1_0Lm20ChallengeRequest = 0, + MsV1_0Lm20GetChallengeResponse, + MsV1_0EnumerateUsers, + MsV1_0GetUserInfo, + MsV1_0ReLogonUsers, + MsV1_0ChangePassword, + MsV1_0ChangeCachedPassword, + MsV1_0GenericPassthrough, + MsV1_0CacheLogon, + MsV1_0SubAuth, + MsV1_0DeriveCredential, + MsV1_0CacheLookup, + MsV1_0SetProcessOption, + MsV1_0ConfigLocalAliases, + MsV1_0ClearCachedCredentials, + MsV1_0LookupToken, + MsV1_0ValidateAuth, + MsV1_0CacheLookupEx, + MsV1_0GetCredentialKey, + MsV1_0SetThreadOption, +}} +pub type PMSV1_0_PROTOCOL_MESSAGE_TYPE = *mut MSV1_0_PROTOCOL_MESSAGE_TYPE; +STRUCT!{struct MSV1_0_CHANGEPASSWORD_REQUEST { + MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, + DomainName: UNICODE_STRING, + AccountName: UNICODE_STRING, + OldPassword: UNICODE_STRING, + NewPassword: UNICODE_STRING, + Impersonating: BOOLEAN, +}} +pub type PMSV1_0_CHANGEPASSWORD_REQUEST = *mut MSV1_0_CHANGEPASSWORD_REQUEST; +STRUCT!{struct MSV1_0_CHANGEPASSWORD_RESPONSE { + MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, + PasswordInfoValid: BOOLEAN, + DomainPasswordInfo: DOMAIN_PASSWORD_INFORMATION, +}} +pub type PMSV1_0_CHANGEPASSWORD_RESPONSE = *mut MSV1_0_CHANGEPASSWORD_RESPONSE; +STRUCT!{struct MSV1_0_PASSTHROUGH_REQUEST { + MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, + DomainName: UNICODE_STRING, + PackageName: UNICODE_STRING, + DataLength: ULONG, + LogonData: PUCHAR, + Pad: ULONG, +}} +pub type PMSV1_0_PASSTHROUGH_REQUEST = *mut MSV1_0_PASSTHROUGH_REQUEST; +STRUCT!{struct MSV1_0_PASSTHROUGH_RESPONSE { + MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, + Pad: ULONG, + DataLength: ULONG, + ValidationData: PUCHAR, +}} +pub type PMSV1_0_PASSTHROUGH_RESPONSE = *mut MSV1_0_PASSTHROUGH_RESPONSE; +STRUCT!{struct MSV1_0_SUBAUTH_REQUEST { + MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, + SubAuthPackageId: ULONG, + SubAuthInfoLength: ULONG, + SubAuthSubmitBuffer: PUCHAR, +}} +pub type PMSV1_0_SUBAUTH_REQUEST = *mut MSV1_0_SUBAUTH_REQUEST; +STRUCT!{struct MSV1_0_SUBAUTH_RESPONSE { + MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, + SubAuthInfoLength: ULONG, + SubAuthReturnBuffer: PUCHAR, +}} +pub type PMSV1_0_SUBAUTH_RESPONSE = *mut MSV1_0_SUBAUTH_RESPONSE; +pub use self::SystemFunction036 as RtlGenRandom; +pub use self::SystemFunction040 as RtlEncryptMemory; +pub use self::SystemFunction041 as RtlDecryptMemory; +extern "system" { + pub fn SystemFunction036( + RandomBuffer: PVOID, + RandomBufferLength: ULONG, + ) -> BOOLEAN; +} +pub const RTL_ENCRYPT_MEMORY_SIZE: ULONG = 8; +pub const RTL_ENCRYPT_OPTION_CROSS_PROCESS: ULONG = 0x01; +pub const RTL_ENCRYPT_OPTION_SAME_LOGON: ULONG = 0x02; +extern "system" { + pub fn SystemFunction040( + Memory: PVOID, + MemorySize: ULONG, + OptionFlags: ULONG, + ) -> NTSTATUS; + pub fn SystemFunction041( + Memory: PVOID, + MemorySize: ULONG, + OptionFlags: ULONG, + ) -> NTSTATUS; +} +pub const KERBEROS_VERSION: ULONG = 5; +pub const KERBEROS_REVISION: ULONG = 6; +pub const KERB_ETYPE_NULL: LONG = 0; +pub const KERB_ETYPE_DES_CBC_CRC: LONG = 1; +pub const KERB_ETYPE_DES_CBC_MD4: LONG = 2; +pub const KERB_ETYPE_DES_CBC_MD5: LONG = 3; +pub const KERB_ETYPE_AES128_CTS_HMAC_SHA1_96: LONG = 17; +pub const KERB_ETYPE_AES256_CTS_HMAC_SHA1_96: LONG = 18; +pub const KERB_ETYPE_RC4_MD4: LONG = -128; +pub const KERB_ETYPE_RC4_PLAIN2: LONG = -129; +pub const KERB_ETYPE_RC4_LM: LONG = -130; +pub const KERB_ETYPE_RC4_SHA: LONG = -131; +pub const KERB_ETYPE_DES_PLAIN: LONG = -132; +pub const KERB_ETYPE_RC4_HMAC_OLD: LONG = -133; +pub const KERB_ETYPE_RC4_PLAIN_OLD: LONG = -134; +pub const KERB_ETYPE_RC4_HMAC_OLD_EXP: LONG = -135; +pub const KERB_ETYPE_RC4_PLAIN_OLD_EXP: LONG = -136; +pub const KERB_ETYPE_RC4_PLAIN: LONG = -140; +pub const KERB_ETYPE_RC4_PLAIN_EXP: LONG = -141; +pub const KERB_ETYPE_AES128_CTS_HMAC_SHA1_96_PLAIN: LONG = -148; +pub const KERB_ETYPE_AES256_CTS_HMAC_SHA1_96_PLAIN: LONG = -149; +pub const KERB_ETYPE_DSA_SHA1_CMS: LONG = 9; +pub const KERB_ETYPE_RSA_MD5_CMS: LONG = 10; +pub const KERB_ETYPE_RSA_SHA1_CMS: LONG = 11; +pub const KERB_ETYPE_RC2_CBC_ENV: LONG = 12; +pub const KERB_ETYPE_RSA_ENV: LONG = 13; +pub const KERB_ETYPE_RSA_ES_OEAP_ENV: LONG = 14; +pub const KERB_ETYPE_DES_EDE3_CBC_ENV: LONG = 15; +pub const KERB_ETYPE_DSA_SIGN: LONG = 8; +pub const KERB_ETYPE_RSA_PRIV: LONG = 9; +pub const KERB_ETYPE_RSA_PUB: LONG = 10; +pub const KERB_ETYPE_RSA_PUB_MD5: LONG = 11; +pub const KERB_ETYPE_RSA_PUB_SHA1: LONG = 12; +pub const KERB_ETYPE_PKCS7_PUB: LONG = 13; +pub const KERB_ETYPE_DES3_CBC_MD5: LONG = 5; +pub const KERB_ETYPE_DES3_CBC_SHA1: LONG = 7; +pub const KERB_ETYPE_DES3_CBC_SHA1_KD: LONG = 16; +pub const KERB_ETYPE_DES_CBC_MD5_NT: LONG = 20; +pub const KERB_ETYPE_RC4_HMAC_NT: LONG = 23; +pub const KERB_ETYPE_RC4_HMAC_NT_EXP: LONG = 24; +pub const KERB_CHECKSUM_NONE: LONG = 0; +pub const KERB_CHECKSUM_CRC32: LONG = 1; +pub const KERB_CHECKSUM_MD4: LONG = 2; +pub const KERB_CHECKSUM_KRB_DES_MAC: LONG = 4; +pub const KERB_CHECKSUM_KRB_DES_MAC_K: LONG = 5; +pub const KERB_CHECKSUM_MD5: LONG = 7; +pub const KERB_CHECKSUM_MD5_DES: LONG = 8; +pub const KERB_CHECKSUM_SHA1_NEW: LONG = 14; +pub const KERB_CHECKSUM_HMAC_SHA1_96_AES128: LONG = 15; +pub const KERB_CHECKSUM_HMAC_SHA1_96_AES256: LONG = 16; +pub const KERB_CHECKSUM_LM: LONG = -130; +pub const KERB_CHECKSUM_SHA1: LONG = -131; +pub const KERB_CHECKSUM_REAL_CRC32: LONG = -132; +pub const KERB_CHECKSUM_DES_MAC: LONG = -133; +pub const KERB_CHECKSUM_DES_MAC_MD5: LONG = -134; +pub const KERB_CHECKSUM_MD25: LONG = -135; +pub const KERB_CHECKSUM_RC4_MD5: LONG = -136; +pub const KERB_CHECKSUM_MD5_HMAC: LONG = -137; +pub const KERB_CHECKSUM_HMAC_MD5: LONG = -138; +pub const KERB_CHECKSUM_HMAC_SHA1_96_AES128_Ki: LONG = -150; +pub const KERB_CHECKSUM_HMAC_SHA1_96_AES256_Ki: LONG = -151; +pub const KERB_TICKET_FLAGS_reserved: ULONG = 0x80000000; +pub const KERB_TICKET_FLAGS_forwardable: ULONG = 0x40000000; +pub const KERB_TICKET_FLAGS_forwarded: ULONG = 0x20000000; +pub const KERB_TICKET_FLAGS_proxiable: ULONG = 0x10000000; +pub const KERB_TICKET_FLAGS_proxy: ULONG = 0x08000000; +pub const KERB_TICKET_FLAGS_may_postdate: ULONG = 0x04000000; +pub const KERB_TICKET_FLAGS_postdated: ULONG = 0x02000000; +pub const KERB_TICKET_FLAGS_invalid: ULONG = 0x01000000; +pub const KERB_TICKET_FLAGS_renewable: ULONG = 0x00800000; +pub const KERB_TICKET_FLAGS_initial: ULONG = 0x00400000; +pub const KERB_TICKET_FLAGS_pre_authent: ULONG = 0x00200000; +pub const KERB_TICKET_FLAGS_hw_authent: ULONG = 0x00100000; +pub const KERB_TICKET_FLAGS_ok_as_delegate: ULONG = 0x00040000; +pub const KERB_TICKET_FLAGS_name_canonicalize: ULONG = 0x00010000; +pub const KERB_TICKET_FLAGS_cname_in_pa_data: ULONG = 0x00040000; +pub const KERB_TICKET_FLAGS_enc_pa_rep: ULONG = 0x00010000; +pub const KERB_TICKET_FLAGS_reserved1: ULONG = 0x00000001; +pub const KRB_NT_UNKNOWN: LONG = 0; +pub const KRB_NT_PRINCIPAL: LONG = 1; +pub const KRB_NT_PRINCIPAL_AND_ID: LONG = -131; +pub const KRB_NT_SRV_INST: LONG = 2; +pub const KRB_NT_SRV_INST_AND_ID: LONG = -132; +pub const KRB_NT_SRV_HST: LONG = 3; +pub const KRB_NT_SRV_XHST: LONG = 4; +pub const KRB_NT_UID: LONG = 5; +pub const KRB_NT_ENTERPRISE_PRINCIPAL: LONG = 10; +pub const KRB_NT_WELLKNOWN: LONG = 11; +pub const KRB_NT_ENT_PRINCIPAL_AND_ID: LONG = -130; +pub const KRB_NT_MS_PRINCIPAL: LONG = -128; +pub const KRB_NT_MS_PRINCIPAL_AND_ID: LONG = -129; +pub const KRB_NT_MS_BRANCH_ID: LONG = -133; +pub const KRB_NT_X500_PRINCIPAL: LONG = 6; +pub const KERB_WRAP_NO_ENCRYPT: ULONG = 0x80000001; +ENUM!{enum KERB_LOGON_SUBMIT_TYPE { + KerbInteractiveLogon = 2, + KerbSmartCardLogon = 6, + KerbWorkstationUnlockLogon = 7, + KerbSmartCardUnlockLogon = 8, + KerbProxyLogon = 9, + KerbTicketLogon = 10, + KerbTicketUnlockLogon = 11, + KerbS4ULogon = 12, + KerbCertificateLogon = 13, + KerbCertificateS4ULogon = 14, + KerbCertificateUnlockLogon = 15, + KerbNoElevationLogon = 83, + KerbLuidLogon = 84, +}} +pub type PKERB_LOGON_SUBMIT_TYPE = *mut KERB_LOGON_SUBMIT_TYPE; +STRUCT!{struct KERB_INTERACTIVE_LOGON { + MessageType: KERB_LOGON_SUBMIT_TYPE, + LogonDomainName: UNICODE_STRING, + UserName: UNICODE_STRING, + Password: UNICODE_STRING, +}} +pub type PKERB_INTERACTIVE_LOGON = *mut KERB_INTERACTIVE_LOGON; +STRUCT!{struct KERB_INTERACTIVE_UNLOCK_LOGON { + Logon: KERB_INTERACTIVE_LOGON, + LogonId: LUID, +}} +pub type PKERB_INTERACTIVE_UNLOCK_LOGON = *mut KERB_INTERACTIVE_UNLOCK_LOGON; +STRUCT!{struct KERB_SMART_CARD_LOGON { + MessageType: KERB_LOGON_SUBMIT_TYPE, + Pin: UNICODE_STRING, + CspDataLength: ULONG, + CspData: PUCHAR, +}} +pub type PKERB_SMART_CARD_LOGON = *mut KERB_SMART_CARD_LOGON; +STRUCT!{struct KERB_SMART_CARD_UNLOCK_LOGON { + Logon: KERB_SMART_CARD_LOGON, + LogonId: LUID, +}} +pub type PKERB_SMART_CARD_UNLOCK_LOGON = *mut KERB_SMART_CARD_UNLOCK_LOGON; +pub const KERB_CERTIFICATE_LOGON_FLAG_CHECK_DUPLICATES: ULONG = 0x1; +pub const KERB_CERTIFICATE_LOGON_FLAG_USE_CERTIFICATE_INFO: ULONG = 0x2; +STRUCT!{struct KERB_CERTIFICATE_LOGON { + MessageType: KERB_LOGON_SUBMIT_TYPE, + DomainName: UNICODE_STRING, + UserName: UNICODE_STRING, + Pin: UNICODE_STRING, + Flags: ULONG, + CspDataLength: ULONG, + CspData: PUCHAR, +}} +pub type PKERB_CERTIFICATE_LOGON = *mut KERB_CERTIFICATE_LOGON; +STRUCT!{struct KERB_CERTIFICATE_UNLOCK_LOGON { + Logon: KERB_CERTIFICATE_LOGON, + LogonId: LUID, +}} +pub type PKERB_CERTIFICATE_UNLOCK_LOGON = *mut KERB_CERTIFICATE_UNLOCK_LOGON; +pub const KERB_CERTIFICATE_S4U_LOGON_FLAG_CHECK_DUPLICATES: ULONG = 0x1; +pub const KERB_CERTIFICATE_S4U_LOGON_FLAG_CHECK_LOGONHOURS: ULONG = 0x2; +pub const KERB_CERTIFICATE_S4U_LOGON_FLAG_FAIL_IF_NT_AUTH_POLICY_REQUIRED: ULONG = 0x4; +pub const KERB_CERTIFICATE_S4U_LOGON_FLAG_IDENTIFY: ULONG = 0x8; +STRUCT!{struct KERB_CERTIFICATE_S4U_LOGON { + MessageType: KERB_LOGON_SUBMIT_TYPE, + Flags: ULONG, + UserPrincipalName: UNICODE_STRING, + DomainName: UNICODE_STRING, + CertificateLength: ULONG, + Certificate: PUCHAR, +}} +pub type PKERB_CERTIFICATE_S4U_LOGON = *mut KERB_CERTIFICATE_S4U_LOGON; +STRUCT!{struct KERB_TICKET_LOGON { + MessageType: KERB_LOGON_SUBMIT_TYPE, + Flags: ULONG, + ServiceTicketLength: ULONG, + TicketGrantingTicketLength: ULONG, + ServiceTicket: PUCHAR, + TicketGrantingTicket: PUCHAR, +}} +pub type PKERB_TICKET_LOGON = *mut KERB_TICKET_LOGON; +STRUCT!{struct KERB_TICKET_UNLOCK_LOGON { + Logon: KERB_TICKET_LOGON, + LogonId: LUID, +}} +pub type PKERB_TICKET_UNLOCK_LOGON = *mut KERB_TICKET_UNLOCK_LOGON; +pub const KERB_S4U_LOGON_FLAG_CHECK_LOGONHOURS: ULONG = 0x2; +pub const KERB_S4U_LOGON_FLAG_IDENTIFY: ULONG = 0x8; +STRUCT!{struct KERB_S4U_LOGON { + MessageType: KERB_LOGON_SUBMIT_TYPE, + Flags: ULONG, + ClientUpn: UNICODE_STRING, + ClientRealm: UNICODE_STRING, +}} +pub type PKERB_S4U_LOGON = *mut KERB_S4U_LOGON; +ENUM!{enum KERB_PROFILE_BUFFER_TYPE { + KerbInteractiveProfile = 2, + KerbSmartCardProfile = 4, + KerbTicketProfile = 6, +}} +pub type PKERB_PROFILE_BUFFER_TYPE = *mut KERB_PROFILE_BUFFER_TYPE; +STRUCT!{struct KERB_INTERACTIVE_PROFILE { + MessageType: KERB_PROFILE_BUFFER_TYPE, + LogonCount: USHORT, + BadPasswordCount: USHORT, + LogonTime: LARGE_INTEGER, + LogoffTime: LARGE_INTEGER, + KickOffTime: LARGE_INTEGER, + PasswordLastSet: LARGE_INTEGER, + PasswordCanChange: LARGE_INTEGER, + PasswordMustChange: LARGE_INTEGER, + LogonScript: UNICODE_STRING, + HomeDirectory: UNICODE_STRING, + FullName: UNICODE_STRING, + ProfilePath: UNICODE_STRING, + HomeDirectoryDrive: UNICODE_STRING, + LogonServer: UNICODE_STRING, + UserFlags: ULONG, +}} +pub type PKERB_INTERACTIVE_PROFILE = *mut KERB_INTERACTIVE_PROFILE; +STRUCT!{struct KERB_SMART_CARD_PROFILE { + Profile: KERB_INTERACTIVE_PROFILE, + CertificateSize: ULONG, + CertificateData: PUCHAR, +}} +pub type PKERB_SMART_CARD_PROFILE = *mut KERB_SMART_CARD_PROFILE; +STRUCT!{struct KERB_CRYPTO_KEY { + KeyType: LONG, + Length: ULONG, + Value: PUCHAR, +}} +pub type PKERB_CRYPTO_KEY = *mut KERB_CRYPTO_KEY; +STRUCT!{struct KERB_CRYPTO_KEY32 { + KeyType: LONG, + Length: ULONG, + Offset: ULONG, +}} +pub type PKERB_CRYPTO_KEY32 = *mut KERB_CRYPTO_KEY32; +STRUCT!{struct KERB_TICKET_PROFILE { + Profile: KERB_INTERACTIVE_PROFILE, + SessionKey: KERB_CRYPTO_KEY, +}} +pub type PKERB_TICKET_PROFILE = *mut KERB_TICKET_PROFILE; +ENUM!{enum KERB_PROTOCOL_MESSAGE_TYPE { + KerbDebugRequestMessage = 0, + KerbQueryTicketCacheMessage, + KerbChangeMachinePasswordMessage, + KerbVerifyPacMessage, + KerbRetrieveTicketMessage, + KerbUpdateAddressesMessage, + KerbPurgeTicketCacheMessage, + KerbChangePasswordMessage, + KerbRetrieveEncodedTicketMessage, + KerbDecryptDataMessage, + KerbAddBindingCacheEntryMessage, + KerbSetPasswordMessage, + KerbSetPasswordExMessage, + KerbVerifyCredentialsMessage, + KerbQueryTicketCacheExMessage, + KerbPurgeTicketCacheExMessage, + KerbRefreshSmartcardCredentialsMessage, + KerbAddExtraCredentialsMessage, + KerbQuerySupplementalCredentialsMessage, + KerbTransferCredentialsMessage, + KerbQueryTicketCacheEx2Message, + KerbSubmitTicketMessage, + KerbAddExtraCredentialsExMessage, + KerbQueryKdcProxyCacheMessage, + KerbPurgeKdcProxyCacheMessage, + KerbQueryTicketCacheEx3Message, + KerbCleanupMachinePkinitCredsMessage, + KerbAddBindingCacheEntryExMessage, + KerbQueryBindingCacheMessage, + KerbPurgeBindingCacheMessage, + KerbPinKdcMessage, + KerbUnpinAllKdcsMessage, + KerbQueryDomainExtendedPoliciesMessage, + KerbQueryS4U2ProxyCacheMessage, +}} +pub type PKERB_PROTOCOL_MESSAGE_TYPE = *mut KERB_PROTOCOL_MESSAGE_TYPE; +STRUCT!{struct KERB_QUERY_TKT_CACHE_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + LogonId: LUID, +}} +pub type PKERB_QUERY_TKT_CACHE_REQUEST = *mut KERB_QUERY_TKT_CACHE_REQUEST; +STRUCT!{struct KERB_TICKET_CACHE_INFO { + ServerName: UNICODE_STRING, + RealmName: UNICODE_STRING, + StartTime: LARGE_INTEGER, + EndTime: LARGE_INTEGER, + RenewTime: LARGE_INTEGER, + EncryptionType: LONG, + TicketFlags: ULONG, +}} +pub type PKERB_TICKET_CACHE_INFO = *mut KERB_TICKET_CACHE_INFO; +STRUCT!{struct KERB_TICKET_CACHE_INFO_EX { + ClientName: UNICODE_STRING, + ClientRealm: UNICODE_STRING, + ServerName: UNICODE_STRING, + ServerRealm: UNICODE_STRING, + StartTime: LARGE_INTEGER, + EndTime: LARGE_INTEGER, + RenewTime: LARGE_INTEGER, + EncryptionType: LONG, + TicketFlags: ULONG, +}} +pub type PKERB_TICKET_CACHE_INFO_EX = *mut KERB_TICKET_CACHE_INFO_EX; +STRUCT!{struct KERB_TICKET_CACHE_INFO_EX2 { + ClientName: UNICODE_STRING, + ClientRealm: UNICODE_STRING, + ServerName: UNICODE_STRING, + ServerRealm: UNICODE_STRING, + StartTime: LARGE_INTEGER, + EndTime: LARGE_INTEGER, + RenewTime: LARGE_INTEGER, + EncryptionType: LONG, + TicketFlags: ULONG, + SessionKeyType: ULONG, + BranchId: ULONG, +}} +pub type PKERB_TICKET_CACHE_INFO_EX2 = *mut KERB_TICKET_CACHE_INFO_EX2; +STRUCT!{struct KERB_TICKET_CACHE_INFO_EX3 { + ClientName: UNICODE_STRING, + ClientRealm: UNICODE_STRING, + ServerName: UNICODE_STRING, + ServerRealm: UNICODE_STRING, + StartTime: LARGE_INTEGER, + EndTime: LARGE_INTEGER, + RenewTime: LARGE_INTEGER, + EncryptionType: LONG, + TicketFlags: ULONG, + SessionKeyType: ULONG, + BranchId: ULONG, + CacheFlags: ULONG, + KdcCalled: UNICODE_STRING, +}} +pub type PKERB_TICKET_CACHE_INFO_EX3 = *mut KERB_TICKET_CACHE_INFO_EX3; +STRUCT!{struct KERB_QUERY_TKT_CACHE_RESPONSE { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + CountOfTickets: ULONG, + Tickets: [KERB_TICKET_CACHE_INFO; ANYSIZE_ARRAY], +}} +pub type PKERB_QUERY_TKT_CACHE_RESPONSE = *mut KERB_QUERY_TKT_CACHE_RESPONSE; +STRUCT!{struct KERB_QUERY_TKT_CACHE_EX_RESPONSE { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + CountOfTickets: ULONG, + Tickets: [KERB_TICKET_CACHE_INFO_EX; ANYSIZE_ARRAY], +}} +pub type PKERB_QUERY_TKT_CACHE_EX_RESPONSE = *mut KERB_QUERY_TKT_CACHE_EX_RESPONSE; +STRUCT!{struct KERB_QUERY_TKT_CACHE_EX2_RESPONSE { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + CountOfTickets: ULONG, + Tickets: [KERB_TICKET_CACHE_INFO_EX2; ANYSIZE_ARRAY], +}} +pub type PKERB_QUERY_TKT_CACHE_EX2_RESPONSE = *mut KERB_QUERY_TKT_CACHE_EX2_RESPONSE; +STRUCT!{struct KERB_QUERY_TKT_CACHE_EX3_RESPONSE { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + CountOfTickets: ULONG, + Tickets: [KERB_TICKET_CACHE_INFO_EX3; ANYSIZE_ARRAY], +}} +pub type PKERB_QUERY_TKT_CACHE_EX3_RESPONSE = *mut KERB_QUERY_TKT_CACHE_EX3_RESPONSE; +pub const KERB_USE_DEFAULT_TICKET_FLAGS: ULONG = 0x0; +pub const KERB_RETRIEVE_TICKET_DEFAULT: ULONG = 0x0; +pub const KERB_RETRIEVE_TICKET_DONT_USE_CACHE: ULONG = 0x1; +pub const KERB_RETRIEVE_TICKET_USE_CACHE_ONLY: ULONG = 0x2; +pub const KERB_RETRIEVE_TICKET_USE_CREDHANDLE: ULONG = 0x4; +pub const KERB_RETRIEVE_TICKET_AS_KERB_CRED: ULONG = 0x8; +pub const KERB_RETRIEVE_TICKET_WITH_SEC_CRED: ULONG = 0x10; +pub const KERB_RETRIEVE_TICKET_CACHE_TICKET: ULONG = 0x20; +pub const KERB_RETRIEVE_TICKET_MAX_LIFETIME: ULONG = 0x40; +STRUCT!{struct KERB_AUTH_DATA { + Type: ULONG, + Length: ULONG, + Data: PUCHAR, +}} +pub type PKERB_AUTH_DATA = *mut KERB_AUTH_DATA; +STRUCT!{struct KERB_NET_ADDRESS { + Family: ULONG, + Length: ULONG, + Address: PUCHAR, +}} +pub type PKERB_NET_ADDRESS = *mut KERB_NET_ADDRESS; +STRUCT!{struct KERB_NET_ADDRESSES { + Number: ULONG, + Addresses: [KERB_NET_ADDRESS; ANYSIZE_ARRAY], +}} +pub type PKERB_NET_ADDRESSES = *mut KERB_NET_ADDRESSES; +STRUCT!{struct KERB_EXTERNAL_NAME { + NameType: SHORT, + NameCount: USHORT, + Names: [UNICODE_STRING; ANYSIZE_ARRAY], +}} +pub type PKERB_EXTERNAL_NAME = *mut KERB_EXTERNAL_NAME; +STRUCT!{struct KERB_EXTERNAL_TICKET { + ServiceName: PKERB_EXTERNAL_NAME, + TargetName: PKERB_EXTERNAL_NAME, + ClientName: PKERB_EXTERNAL_NAME, + DomainName: UNICODE_STRING, + TargetDomainName: UNICODE_STRING, + AltTargetDomainName: UNICODE_STRING, + SessionKey: KERB_CRYPTO_KEY, + TicketFlags: ULONG, + Flags: ULONG, + KeyExpirationTime: LARGE_INTEGER, + StartTime: LARGE_INTEGER, + EndTime: LARGE_INTEGER, + RenewUntil: LARGE_INTEGER, + TimeSkew: LARGE_INTEGER, + EncodedTicketSize: ULONG, + EncodedTicket: PUCHAR, +}} +pub type PKERB_EXTERNAL_TICKET = *mut KERB_EXTERNAL_TICKET; +STRUCT!{struct KERB_RETRIEVE_TKT_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + LogonId: LUID, + TargetName: UNICODE_STRING, + TicketFlags: ULONG, + CacheOptions: ULONG, + EncryptionType: LONG, + CredentialsHandle: SecHandle, +}} +pub type PKERB_RETRIEVE_TKT_REQUEST = *mut KERB_RETRIEVE_TKT_REQUEST; +STRUCT!{struct KERB_RETRIEVE_TKT_RESPONSE { + Ticket: KERB_EXTERNAL_TICKET, +}} +pub type PKERB_RETRIEVE_TKT_RESPONSE = *mut KERB_RETRIEVE_TKT_RESPONSE; +STRUCT!{struct KERB_PURGE_TKT_CACHE_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + LogonId: LUID, + ServerName: UNICODE_STRING, + RealmName: UNICODE_STRING, +}} +pub type PKERB_PURGE_TKT_CACHE_REQUEST = *mut KERB_PURGE_TKT_CACHE_REQUEST; +pub const KERB_PURGE_ALL_TICKETS: ULONG = 1; +STRUCT!{struct KERB_PURGE_TKT_CACHE_EX_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + LogonId: LUID, + Flags: ULONG, + TicketTemplate: KERB_TICKET_CACHE_INFO_EX, +}} +pub type PKERB_PURGE_TKT_CACHE_EX_REQUEST = *mut KERB_PURGE_TKT_CACHE_EX_REQUEST; +STRUCT!{struct KERB_SUBMIT_TKT_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + LogonId: LUID, + Flags: ULONG, + Key: KERB_CRYPTO_KEY32, + KerbCredSize: ULONG, + KerbCredOffset: ULONG, +}} +pub type PKERB_SUBMIT_TKT_REQUEST = *mut KERB_SUBMIT_TKT_REQUEST; +STRUCT!{struct KERB_QUERY_KDC_PROXY_CACHE_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + Flags: ULONG, + LogonId: LUID, +}} +pub type PKERB_QUERY_KDC_PROXY_CACHE_REQUEST = *mut KERB_QUERY_KDC_PROXY_CACHE_REQUEST; +STRUCT!{struct KDC_PROXY_CACHE_ENTRY_DATA { + SinceLastUsed: ULONG64, + DomainName: UNICODE_STRING, + ProxyServerName: UNICODE_STRING, + ProxyServerVdir: UNICODE_STRING, + ProxyServerPort: USHORT, + LogonId: LUID, + CredUserName: UNICODE_STRING, + CredDomainName: UNICODE_STRING, + GlobalCache: BOOLEAN, +}} +pub type PKDC_PROXY_CACHE_ENTRY_DATA = *mut KDC_PROXY_CACHE_ENTRY_DATA; +STRUCT!{struct KERB_QUERY_KDC_PROXY_CACHE_RESPONSE { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + CountOfEntries: ULONG, + Entries: PKDC_PROXY_CACHE_ENTRY_DATA, +}} +pub type PKERB_QUERY_KDC_PROXY_CACHE_RESPONSE = *mut KERB_QUERY_KDC_PROXY_CACHE_RESPONSE; +STRUCT!{struct KERB_PURGE_KDC_PROXY_CACHE_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + Flags: ULONG, + LogonId: LUID, +}} +pub type PKERB_PURGE_KDC_PROXY_CACHE_REQUEST = *mut KERB_PURGE_KDC_PROXY_CACHE_REQUEST; +STRUCT!{struct KERB_PURGE_KDC_PROXY_CACHE_RESPONSE { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + CountOfPurged: ULONG, +}} +pub type PKERB_PURGE_KDC_PROXY_CACHE_RESPONSE = *mut KERB_PURGE_KDC_PROXY_CACHE_RESPONSE; +pub const KERB_S4U2PROXY_CACHE_ENTRY_INFO_FLAG_NEGATIVE: ULONG = 0x1; +STRUCT!{struct KERB_S4U2PROXY_CACHE_ENTRY_INFO { + ServerName: UNICODE_STRING, + Flags: ULONG, + LastStatus: NTSTATUS, + Expiry: LARGE_INTEGER, +}} +pub type PKERB_S4U2PROXY_CACHE_ENTRY_INFO = *mut KERB_S4U2PROXY_CACHE_ENTRY_INFO; +pub const KERB_S4U2PROXY_CRED_FLAG_NEGATIVE: ULONG = 0x1; +STRUCT!{struct KERB_S4U2PROXY_CRED { + UserName: UNICODE_STRING, + DomainName: UNICODE_STRING, + Flags: ULONG, + LastStatus: NTSTATUS, + Expiry: LARGE_INTEGER, + CountOfEntries: ULONG, + Entries: PKERB_S4U2PROXY_CACHE_ENTRY_INFO, +}} +pub type PKERB_S4U2PROXY_CRED = *mut KERB_S4U2PROXY_CRED; +STRUCT!{struct KERB_QUERY_S4U2PROXY_CACHE_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + Flags: ULONG, + LogonId: LUID, +}} +pub type PKERB_QUERY_S4U2PROXY_CACHE_REQUEST = *mut KERB_QUERY_S4U2PROXY_CACHE_REQUEST; +STRUCT!{struct KERB_QUERY_S4U2PROXY_CACHE_RESPONSE { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + CountOfCreds: ULONG, + Creds: PKERB_S4U2PROXY_CRED, +}} +pub type PKERB_QUERY_S4U2PROXY_CACHE_RESPONSE = *mut KERB_QUERY_S4U2PROXY_CACHE_RESPONSE; +STRUCT!{struct KERB_CHANGEPASSWORD_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + DomainName: UNICODE_STRING, + AccountName: UNICODE_STRING, + OldPassword: UNICODE_STRING, + NewPassword: UNICODE_STRING, + Impersonating: BOOLEAN, +}} +pub type PKERB_CHANGEPASSWORD_REQUEST = *mut KERB_CHANGEPASSWORD_REQUEST; +STRUCT!{struct KERB_SETPASSWORD_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + LogonId: LUID, + CredentialsHandle: SecHandle, + Flags: ULONG, + DomainName: UNICODE_STRING, + AccountName: UNICODE_STRING, + Password: UNICODE_STRING, +}} +pub type PKERB_SETPASSWORD_REQUEST = *mut KERB_SETPASSWORD_REQUEST; +STRUCT!{struct KERB_SETPASSWORD_EX_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + LogonId: LUID, + CredentialsHandle: SecHandle, + Flags: ULONG, + AccountRealm: UNICODE_STRING, + AccountName: UNICODE_STRING, + Password: UNICODE_STRING, + ClientRealm: UNICODE_STRING, + ClientName: UNICODE_STRING, + Impersonating: BOOLEAN, + KdcAddress: UNICODE_STRING, + KdcAddressType: ULONG, +}} +pub type PKERB_SETPASSWORD_EX_REQUEST = *mut KERB_SETPASSWORD_EX_REQUEST; +pub const DS_UNKNOWN_ADDRESS_TYPE: ULONG = 0; +pub const KERB_SETPASS_USE_LOGONID: ULONG = 1; +pub const KERB_SETPASS_USE_CREDHANDLE: ULONG = 2; +STRUCT!{struct KERB_DECRYPT_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + LogonId: LUID, + Flags: ULONG, + CryptoType: LONG, + KeyUsage: LONG, + Key: KERB_CRYPTO_KEY, + EncryptedDataSize: ULONG, + InitialVectorSize: ULONG, + InitialVector: PUCHAR, + EncryptedData: PUCHAR, +}} +pub type PKERB_DECRYPT_REQUEST = *mut KERB_DECRYPT_REQUEST; +pub const KERB_DECRYPT_FLAG_DEFAULT_KEY: ULONG = 0x00000001; +STRUCT!{struct KERB_DECRYPT_RESPONSE { + DecryptedData: [UCHAR; ANYSIZE_ARRAY], +}} +pub type PKERB_DECRYPT_RESPONSE = *mut KERB_DECRYPT_RESPONSE; +STRUCT!{struct KERB_ADD_BINDING_CACHE_ENTRY_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + RealmName: UNICODE_STRING, + KdcAddress: UNICODE_STRING, + AddressType: ULONG, +}} +pub type PKERB_ADD_BINDING_CACHE_ENTRY_REQUEST = *mut KERB_ADD_BINDING_CACHE_ENTRY_REQUEST; +STRUCT!{struct KERB_REFRESH_SCCRED_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + CredentialBlob: UNICODE_STRING, + LogonId: LUID, + Flags: ULONG, +}} +pub type PKERB_REFRESH_SCCRED_REQUEST = *mut KERB_REFRESH_SCCRED_REQUEST; +pub const KERB_REFRESH_SCCRED_RELEASE: ULONG = 0x0; +pub const KERB_REFRESH_SCCRED_GETTGT: ULONG = 0x1; +STRUCT!{struct KERB_ADD_CREDENTIALS_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + UserName: UNICODE_STRING, + DomainName: UNICODE_STRING, + Password: UNICODE_STRING, + LogonId: LUID, + Flags: ULONG, +}} +pub type PKERB_ADD_CREDENTIALS_REQUEST = *mut KERB_ADD_CREDENTIALS_REQUEST; +pub const KERB_REQUEST_ADD_CREDENTIAL: ULONG = 1; +pub const KERB_REQUEST_REPLACE_CREDENTIAL: ULONG = 2; +pub const KERB_REQUEST_REMOVE_CREDENTIAL: ULONG = 4; +STRUCT!{struct KERB_ADD_CREDENTIALS_REQUEST_EX { + Credentials: KERB_ADD_CREDENTIALS_REQUEST, + PrincipalNameCount: ULONG, + PrincipalNames: [UNICODE_STRING; ANYSIZE_ARRAY], +}} +pub type PKERB_ADD_CREDENTIALS_REQUEST_EX = *mut KERB_ADD_CREDENTIALS_REQUEST_EX; +STRUCT!{struct KERB_TRANSFER_CRED_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + OriginLogonId: LUID, + DestinationLogonId: LUID, + Flags: ULONG, +}} +pub type PKERB_TRANSFER_CRED_REQUEST = *mut KERB_TRANSFER_CRED_REQUEST; +pub const KERB_TRANSFER_CRED_WITH_TICKETS: ULONG = 0x1; +pub const KERB_TRANSFER_CRED_CLEANUP_CREDENTIALS: ULONG = 0x2; +STRUCT!{struct KERB_CLEANUP_MACHINE_PKINIT_CREDS_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + LogonId: LUID, +}} +pub type PKERB_CLEANUP_MACHINE_PKINIT_CREDS_REQUEST = + *mut KERB_CLEANUP_MACHINE_PKINIT_CREDS_REQUEST; +STRUCT!{struct KERB_BINDING_CACHE_ENTRY_DATA { + DiscoveryTime: ULONG64, + RealmName: UNICODE_STRING, + KdcAddress: UNICODE_STRING, + AddressType: ULONG, + Flags: ULONG, + DcFlags: ULONG, + CacheFlags: ULONG, + KdcName: UNICODE_STRING, +}} +pub type PKERB_BINDING_CACHE_ENTRY_DATA = *mut KERB_BINDING_CACHE_ENTRY_DATA; +STRUCT!{struct KERB_QUERY_BINDING_CACHE_RESPONSE { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + CountOfEntries: ULONG, + Entries: PKERB_BINDING_CACHE_ENTRY_DATA, +}} +pub type PKERB_QUERY_BINDING_CACHE_RESPONSE = *mut KERB_QUERY_BINDING_CACHE_RESPONSE; +STRUCT!{struct KERB_ADD_BINDING_CACHE_ENTRY_EX_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + RealmName: UNICODE_STRING, + KdcAddress: UNICODE_STRING, + AddressType: ULONG, + DcFlags: ULONG, +}} +pub type PKERB_ADD_BINDING_CACHE_ENTRY_EX_REQUEST = *mut KERB_ADD_BINDING_CACHE_ENTRY_EX_REQUEST; +STRUCT!{struct KERB_QUERY_BINDING_CACHE_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, +}} +pub type PKERB_QUERY_BINDING_CACHE_REQUEST = *mut KERB_QUERY_BINDING_CACHE_REQUEST; +STRUCT!{struct KERB_PURGE_BINDING_CACHE_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, +}} +pub type PKERB_PURGE_BINDING_CACHE_REQUEST = *mut KERB_PURGE_BINDING_CACHE_REQUEST; +STRUCT!{struct KERB_QUERY_DOMAIN_EXTENDED_POLICIES_REQUEST { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + Flags: ULONG, + DomainName: UNICODE_STRING, +}} +pub type PKERB_QUERY_DOMAIN_EXTENDED_POLICIES_REQUEST = + *mut KERB_QUERY_DOMAIN_EXTENDED_POLICIES_REQUEST; +STRUCT!{struct KERB_QUERY_DOMAIN_EXTENDED_POLICIES_RESPONSE { + MessageType: KERB_PROTOCOL_MESSAGE_TYPE, + Flags: ULONG, + ExtendedPolicies: ULONG, + DsFlags: ULONG, +}} +pub type PKERB_QUERY_DOMAIN_EXTENDED_POLICIES_RESPONSE = + *mut KERB_QUERY_DOMAIN_EXTENDED_POLICIES_RESPONSE; +ENUM!{enum KERB_CERTIFICATE_INFO_TYPE { + CertHashInfo = 1, +}} +pub type PKERB_CERTIFICATE_INFO_TYPE = *mut KERB_CERTIFICATE_INFO_TYPE; +STRUCT!{struct KERB_CERTIFICATE_HASHINFO { + StoreNameLength: USHORT, + HashLength: USHORT, +}} +pub type PKERB_CERTIFICATE_HASHINFO = *mut KERB_CERTIFICATE_HASHINFO; +STRUCT!{struct KERB_CERTIFICATE_INFO { + CertInfoSize: ULONG, + InfoType: ULONG, +}} +pub type PKERB_CERTIFICATE_INFO = *mut KERB_CERTIFICATE_INFO; +STRUCT!{struct POLICY_AUDIT_SID_ARRAY { + UsersCount: ULONG, + UserSidArray: *mut PSID, +}} +pub type PPOLICY_AUDIT_SID_ARRAY = *mut POLICY_AUDIT_SID_ARRAY; +STRUCT!{struct AUDIT_POLICY_INFORMATION { + AuditSubCategoryGuid: GUID, + AuditingInformation: ULONG, + AuditCategoryGuid: GUID, +}} +pub type PAUDIT_POLICY_INFORMATION = *mut AUDIT_POLICY_INFORMATION; +pub type LPAUDIT_POLICY_INFORMATION = PAUDIT_POLICY_INFORMATION; +pub type PCAUDIT_POLICY_INFORMATION = *const AUDIT_POLICY_INFORMATION; +pub const AUDIT_SET_SYSTEM_POLICY: ULONG = 0x0001; +pub const AUDIT_QUERY_SYSTEM_POLICY: ULONG = 0x0002; +pub const AUDIT_SET_USER_POLICY: ULONG = 0x0004; +pub const AUDIT_QUERY_USER_POLICY: ULONG = 0x0008; +pub const AUDIT_ENUMERATE_USERS: ULONG = 0x0010; +pub const AUDIT_SET_MISC_POLICY: ULONG = 0x0020; +pub const AUDIT_QUERY_MISC_POLICY: ULONG = 0x0040; +pub const AUDIT_GENERIC_ALL: ULONG = STANDARD_RIGHTS_REQUIRED | AUDIT_SET_SYSTEM_POLICY + | AUDIT_QUERY_SYSTEM_POLICY | AUDIT_SET_USER_POLICY | AUDIT_QUERY_USER_POLICY + | AUDIT_ENUMERATE_USERS | AUDIT_SET_MISC_POLICY | AUDIT_QUERY_MISC_POLICY; +pub const AUDIT_GENERIC_READ: ULONG = STANDARD_RIGHTS_READ | AUDIT_QUERY_SYSTEM_POLICY + | AUDIT_QUERY_USER_POLICY | AUDIT_ENUMERATE_USERS | AUDIT_QUERY_MISC_POLICY; +pub const AUDIT_GENERIC_WRITE: ULONG = STANDARD_RIGHTS_WRITE | AUDIT_SET_USER_POLICY + | AUDIT_SET_MISC_POLICY | AUDIT_SET_SYSTEM_POLICY; +pub const AUDIT_GENERIC_EXECUTE: ULONG = STANDARD_RIGHTS_EXECUTE; +extern "system" { + pub fn AuditSetSystemPolicy( + pAuditPolicy: PCAUDIT_POLICY_INFORMATION, + PolicyCount: ULONG, + ) -> BOOLEAN; + pub fn AuditSetPerUserPolicy( + pSid: *const SID, + pAuditPolicy: PCAUDIT_POLICY_INFORMATION, + PolicyCount: ULONG, + ) -> BOOLEAN; + pub fn AuditQuerySystemPolicy( + pSubCategoryGuids: *const GUID, + PolicyCount: ULONG, + ppAuditPolicy: *mut PAUDIT_POLICY_INFORMATION, + ) -> BOOLEAN; + pub fn AuditQueryPerUserPolicy( + pSid: *const SID, + pSubCategoryGuids: *const GUID, + PolicyCount: ULONG, + ppAuditPolicy: *mut PAUDIT_POLICY_INFORMATION, + ) -> BOOLEAN; + pub fn AuditEnumeratePerUserPolicy( + ppAuditSidArray: *mut PPOLICY_AUDIT_SID_ARRAY, + ) -> BOOLEAN; + pub fn AuditComputeEffectivePolicyBySid( + pSid: *const SID, + pSubCategoryGuids: *const GUID, + dwPolicyCount: ULONG, + ppAuditPolicy: *mut PAUDIT_POLICY_INFORMATION, + ) -> BOOLEAN; + pub fn AuditComputeEffectivePolicyByToken( + hTokenHandle: HANDLE, + pSubCategoryGuids: *const GUID, + dwPolicyCount: ULONG, + ppAuditPolicy: *mut PAUDIT_POLICY_INFORMATION, + ) -> BOOLEAN; + pub fn AuditEnumerateCategories( + ppAuditCategoriesArray: *mut *mut GUID, + pdwCountReturned: PULONG, + ) -> BOOLEAN; + pub fn AuditEnumerateSubCategories( + pAuditCategoryGuid: *const GUID, + bRetrieveAllSubCategories: BOOLEAN, + ppAuditSubCategoriesArray: *mut *mut GUID, + pdwCountReturned: PULONG, + ) -> BOOLEAN; + pub fn AuditLookupCategoryNameW( + pAuditCategoryGuid: *const GUID, + ppszCategoryName: *mut PWSTR, + ) -> BOOLEAN; + pub fn AuditLookupCategoryNameA( + pAuditCategoryGuid: *const GUID, + ppszCategoryName: *mut PSTR, + ) -> BOOLEAN; + pub fn AuditLookupSubCategoryNameW( + pAuditSubCategoryGuid: *const GUID, + ppszSubCategoryName: *mut PWSTR, + ) -> BOOLEAN; + pub fn AuditLookupSubCategoryNameA( + pAuditSubCategoryGuid: *const GUID, + ppszSubCategoryName: *mut PSTR, + ) -> BOOLEAN; + pub fn AuditLookupCategoryIdFromCategoryGuid( + pAuditCategoryGuid: *const GUID, + pAuditCategoryId: PPOLICY_AUDIT_EVENT_TYPE, + ) -> BOOLEAN; + pub fn AuditLookupCategoryGuidFromCategoryId( + AuditCategoryId: POLICY_AUDIT_EVENT_TYPE, + pAuditCategoryGuid: *mut GUID, + ) -> BOOLEAN; + pub fn AuditSetSecurity( + SecurityInformation: SECURITY_INFORMATION, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ) -> BOOLEAN; + pub fn AuditQuerySecurity( + SecurityInformation: SECURITY_INFORMATION, + ppSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + ) -> BOOLEAN; + pub fn AuditSetGlobalSaclW( + ObjectTypeName: PCWSTR, + Acl: PACL, + ) -> BOOLEAN; + pub fn AuditSetGlobalSaclA( + ObjectTypeName: PCSTR, + Acl: PACL, + ) -> BOOLEAN; + pub fn AuditQueryGlobalSaclW( + ObjectTypeName: PCWSTR, + Acl: *mut PACL, + ) -> BOOLEAN; + pub fn AuditQueryGlobalSaclA( + ObjectTypeName: PCSTR, + Acl: *mut PACL, + ) -> BOOLEAN; + pub fn AuditFree( + Buffer: PVOID, + ); +} +STRUCT!{struct PKU2U_CERT_BLOB { + CertOffset: ULONG, + CertLength: USHORT, +}} +pub type PPKU2U_CERT_BLOB = *mut PKU2U_CERT_BLOB; +pub const PKU2U_CREDUI_CONTEXT_VERSION: ULONG64 = 0x4154414454524543; +STRUCT!{struct PKU2U_CREDUI_CONTEXT { + Version: ULONG64, + cbHeaderLength: USHORT, + cbStructureLength: ULONG, + CertArrayCount: USHORT, + CertArrayOffset: ULONG, +}} +pub type PPKU2U_CREDUI_CONTEXT = *mut PKU2U_CREDUI_CONTEXT; +ENUM!{enum PKU2U_LOGON_SUBMIT_TYPE { + Pku2uCertificateS4ULogon = 14, +}} +pub type PPKU2U_LOGON_SUBMIT_TYPE = *mut PKU2U_LOGON_SUBMIT_TYPE; +STRUCT!{struct PKU2U_CERTIFICATE_S4U_LOGON { + MessageType: PKU2U_LOGON_SUBMIT_TYPE, + Flags: ULONG, + UserPrincipalName: UNICODE_STRING, + DomainName: UNICODE_STRING, + CertificateLength: ULONG, + Certificate: PUCHAR, +}} +pub type PPKU2U_CERTIFICATE_S4U_LOGON = *mut PKU2U_CERTIFICATE_S4U_LOGON; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/oaidl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/oaidl.rs new file mode 100644 index 0000000..bc1983f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/oaidl.rs @@ -0,0 +1,879 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of OAIdl.h +use shared::basetsd::ULONG_PTR; +use shared::guiddef::{GUID, IID, REFGUID, REFIID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, INT, UINT, ULONG, USHORT, WORD}; +use shared::rpcndr::byte; +use shared::wtypes::{ + BSTR, CY, DATE, DECIMAL, VARIANT_BOOL, VARTYPE, VT_BSTR, VT_DISPATCH, VT_ERROR, + VT_I1, VT_I2, VT_I4, VT_I8, VT_RECORD, VT_RESERVED, VT_UNKNOWN, VT_VARIANT, + wireBSTR +}; +use shared::wtypesbase::{ + BYTE_SIZEDARR, DOUBLE, DWORD_SIZEDARR, HYPER_SIZEDARR, LPCOLESTR, LPOLESTR, SCODE, + WORD_SIZEDARR +}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{CHAR, HRESULT, LCID, LONG, LONGLONG, PVOID, SHORT, ULONGLONG}; +pub type CURRENCY = CY; +STRUCT!{struct SAFEARRAYBOUND { + cElements: ULONG, + lLbound: LONG, +}} +pub type LPSAFEARRAYBOUND = *mut SAFEARRAYBOUND; +pub type wireBRECORD = *mut _wireBRECORD; +pub type wireVARIANT = *mut _wireVARIANT; +STRUCT!{struct SAFEARR_BSTR { + Size: ULONG, + aBstr: *mut wireBSTR, +}} +STRUCT!{struct SAFEARR_UNKNOWN { + Size: ULONG, + apUnknown: *mut *mut IUnknown, +}} +STRUCT!{struct SAFEARR_DISPATCH { + Size: ULONG, + apDispatch: *mut *mut IDispatch, +}} +STRUCT!{struct SAFEARR_VARIANT { + Size: ULONG, + aVariant: *mut wireVARIANT, +}} +STRUCT!{struct SAFEARR_BRECORD { + Size: ULONG, + aRecord: *mut wireBRECORD, +}} +STRUCT!{struct SAFEARR_HAVEIID { + Size: ULONG, + apUnknown: *mut *mut IUnknown, + iid: IID, +}} +ENUM!{enum SF_TYPE { + SF_ERROR = VT_ERROR, + SF_I1 = VT_I1, + SF_I2 = VT_I2, + SF_I4 = VT_I4, + SF_I8 = VT_I8, + SF_BSTR = VT_BSTR, + SF_UNKNOWN = VT_UNKNOWN, + SF_DISPATCH = VT_DISPATCH, + SF_VARIANT = VT_VARIANT, + SF_RECORD = VT_RECORD, + SF_HAVEIID = VT_UNKNOWN | VT_RESERVED, +}} +#[cfg(target_pointer_width = "32")] +UNION!{union __MIDL_IOleAutomationTypes_0001 { + [u32; 6], + BstrStr BstrStr_mut: SAFEARR_BSTR, + UnknownStr UnknownStr_mut: SAFEARR_UNKNOWN, + DispatchStr DispatchStr_mut: SAFEARR_DISPATCH, + VariantStr VariantStr_mut: SAFEARR_VARIANT, + RecordStr RecordStr_mut: SAFEARR_BRECORD, + HaveIidStr HaveIidStr_mut: SAFEARR_HAVEIID, + ByteStr ByteStr_mut: BYTE_SIZEDARR, + WordStr WordStr_mut: WORD_SIZEDARR, + LongStr LongStr_mut: DWORD_SIZEDARR, + HyperStr HyperStr_mut: HYPER_SIZEDARR, +}} +#[cfg(target_pointer_width = "64")] +UNION!{union __MIDL_IOleAutomationTypes_0001 { + [u64; 4], + BstrStr BstrStr_mut: SAFEARR_BSTR, + UnknownStr UnknownStr_mut: SAFEARR_UNKNOWN, + DispatchStr DispatchStr_mut: SAFEARR_DISPATCH, + VariantStr VariantStr_mut: SAFEARR_VARIANT, + RecordStr RecordStr_mut: SAFEARR_BRECORD, + HaveIidStr HaveIidStr_mut: SAFEARR_HAVEIID, + ByteStr ByteStr_mut: BYTE_SIZEDARR, + WordStr WordStr_mut: WORD_SIZEDARR, + LongStr LongStr_mut: DWORD_SIZEDARR, + HyperStr HyperStr_mut: HYPER_SIZEDARR, +}} +STRUCT!{struct SAFEARRAYUNION { + sfType: ULONG, + u: __MIDL_IOleAutomationTypes_0001, +}} +STRUCT!{struct _wireSAFEARRAY { + cDims: USHORT, + fFeatures: USHORT, + cbElements: ULONG, + cLocks: ULONG, + uArrayStructs: SAFEARRAYUNION, + rgsaBound: [SAFEARRAYBOUND; 1], +}} +pub type wireSAFEARRAY = *mut _wireSAFEARRAY; +pub type wirePSAFEARRAY = *mut wireSAFEARRAY; +STRUCT!{struct SAFEARRAY { + cDims: USHORT, + fFeatures: USHORT, + cbElements: ULONG, + cLocks: ULONG, + pvData: PVOID, + rgsabound: [SAFEARRAYBOUND; 1], +}} +pub type LPSAFEARRAY = *mut SAFEARRAY; +pub const FADF_AUTO: DWORD = 0x1; +pub const FADF_STATIC: DWORD = 0x2; +pub const FADF_EMBEDDED: DWORD = 0x4; +pub const FADF_FIXEDSIZE: DWORD = 0x10; +pub const FADF_RECORD: DWORD = 0x20; +pub const FADF_HAVEIID: DWORD = 0x40; +pub const FADF_HAVEVARTYPE: DWORD = 0x80; +pub const FADF_BSTR: DWORD = 0x100; +pub const FADF_UNKNOWN: DWORD = 0x200; +pub const FADF_DISPATCH: DWORD = 0x400; +pub const FADF_VARIANT: DWORD = 0x800; +pub const FADF_RESERVED: DWORD = 0xf008; +STRUCT!{struct __tagBRECORD { + pvRecord: PVOID, + pRecInfo: *mut IRecordInfo, +}} +UNION!{union VARIANT_n3 { + [u64; 1] [u64; 2], + llVal llVal_mut: LONGLONG, + lVal lVal_mut: LONG, + bVal bVal_mut: BYTE, + iVal iVal_mut: SHORT, + fltVal fltVal_mut: FLOAT, + dblVal dblVal_mut: DOUBLE, + boolVal boolVal_mut: VARIANT_BOOL, + scode scode_mut: SCODE, + cyVal cyVal_mut: CY, + date date_mut: DATE, + bstrVal bstrVal_mut: BSTR, + punkVal punkVal_mut: *mut IUnknown, + pdispVal pdispVal_mut: *mut IDispatch, + parray parray_mut: *mut SAFEARRAY, + pbVal pbVal_mut: *mut BYTE, + piVal piVal_mut: *mut SHORT, + plVal plVal_mut: *mut LONG, + pllVal pllVal_mut: *mut LONGLONG, + pfltVal pfltVal_mut: *mut FLOAT, + pdblVal pdblVal_mut: *mut DOUBLE, + pboolVal pboolVal_mut: *mut VARIANT_BOOL, + pscode pscode_mut: *mut SCODE, + pcyVal pcyVal_mut: *mut CY, + pdate pdate_mut: *mut DATE, + pbstrVal pbstrVal_mut: *mut BSTR, + ppunkVal ppunkVal_mut: *mut *mut IUnknown, + ppdispVal ppdispVal_mut: *mut *mut IDispatch, + pparray pparray_mut: *mut *mut SAFEARRAY, + pvarVal pvarVal_mut: *mut VARIANT, + byref byref_mut: PVOID, + cVal cVal_mut: CHAR, + uiVal uiVal_mut: USHORT, + ulVal ulVal_mut: ULONG, + ullVal ullVal_mut: ULONGLONG, + intVal intVal_mut: INT, + uintVal uintVal_mut: UINT, + pdecVal pdecVal_mut: *mut DECIMAL, + pcVal pcVal_mut: *mut CHAR, + puiVal puiVal_mut: *mut USHORT, + pulVal pulVal_mut: *mut ULONG, + pullVal pullVal_mut: *mut ULONGLONG, + pintVal pintVal_mut: *mut INT, + puintVal puintVal_mut: *mut UINT, + n4 n4_mut: __tagBRECORD, +}} +STRUCT!{struct __tagVARIANT { + vt: VARTYPE, + wReserved1: WORD, + wReserved2: WORD, + wReserved3: WORD, + n3: VARIANT_n3, +}} +UNION!{union VARIANT_n1 { + [u64; 2] [u64; 3], + n2 n2_mut: __tagVARIANT, + decVal decVal_mut: DECIMAL, +}} +STRUCT!{struct VARIANT { + n1: VARIANT_n1, +}} +pub type LPVARIANT = *mut VARIANT; +pub type VARIANTARG = VARIANT; +pub type LPVARIANTARG = *mut VARIANT; +pub type REFVARIANT = *const VARIANT; +STRUCT!{struct _wireBRECORD { + fFlags: ULONG, + clSize: ULONG, + pRecInfo: *mut IRecordInfo, + pRecord: *mut byte, +}} +UNION!{union _wireVARIANT_u { + [u64; 2], + llVal llVal_mut: LONGLONG, + lVal lVal_mut: LONG, + bVal bVal_mut: BYTE, + iVal iVal_mut: SHORT, + fltVal fltVal_mut: FLOAT, + dblVal dblVal_mut: DOUBLE, + boolVal boolVal_mut: VARIANT_BOOL, + scode scode_mut: SCODE, + cyVal cyVal_mut: CY, + date date_mut: DATE, + bstrVal bstrVal_mut: wireBSTR, + punkVal punkVal_mut: *mut IUnknown, + pdispVal pdispVal_mut: *mut IDispatch, + parray parray_mut: wirePSAFEARRAY, + brecVal brecVal_mut: wireBRECORD, + pbVal pbVal_mut: *mut BYTE, + piVal piVal_mut: *mut SHORT, + plVal plVal_mut: *mut LONG, + pllVal pllVal_mut: *mut LONGLONG, + pfltVal pfltVal_mut: *mut FLOAT, + pdblVal pdblVal_mut: *mut DOUBLE, + pboolVal pboolVal_mut: *mut VARIANT_BOOL, + pscode pscode_mut: *mut SCODE, + pcyVal pcyVal_mut: *mut CY, + pdate pdate_mut: *mut DATE, + pbstrVal pbstrVal_mut: *mut wireBSTR, + ppunkVal ppunkVal_mut: *mut *mut IUnknown, + ppdispVal ppdispVal_mut: *mut *mut IDispatch, + pparray pparray_mut: *mut wirePSAFEARRAY, + pvarVal pvarVal_mut: *mut wireVARIANT, + cVal cVal_mut: CHAR, + uiVal uiVal_mut: USHORT, + ulVal ulVal_mut: ULONG, + ullVal ullVal_mut: ULONGLONG, + intVal intVal_mut: INT, + uintVal uintVal_mut: UINT, + decVal decVal_mut: DECIMAL, + pdecVal pdecVal_mut: *mut DECIMAL, + pcVal pcVal_mut: *mut CHAR, + puiVal puiVal_mut: *mut USHORT, + pulVal pulVal_mut: *mut ULONG, + pullVal pullVal_mut: *mut ULONGLONG, + pintVal pintVal_mut: *mut INT, + puintVal puintVal_mut: *mut UINT, +}} +STRUCT!{struct _wireVARIANT { + clSize: DWORD, + rpcReserved: DWORD, + vt: USHORT, + wReserved1: USHORT, + wReserved2: USHORT, + wReserved3: USHORT, + u: _wireVARIANT_u, +}} +pub type DISPID = LONG; +pub type MEMBERID = DISPID; +pub type HREFTYPE = DWORD; +ENUM!{enum TYPEKIND { + TKIND_ENUM = 0, + TKIND_RECORD, + TKIND_MODULE, + TKIND_INTERFACE, + TKIND_DISPATCH, + TKIND_COCLASS, + TKIND_ALIAS, + TKIND_UNION, + TKIND_MAX, +}} +UNION!{union TYPEDESC_u { + [usize; 1], + lptdesc lptdesc_mut: *mut TYPEDESC, + lpadesc lpadesc_mut: *mut ARRAYDESC, + hreftype hreftype_mut: HREFTYPE, +}} +STRUCT!{struct TYPEDESC { + u: TYPEDESC_u, + vt: VARTYPE, +}} +STRUCT!{struct ARRAYDESC { + tdescElem: TYPEDESC, + cDims: USHORT, + rgbounds: [SAFEARRAYBOUND; 1], +}} +STRUCT!{struct PARAMDESCEX { + cBytes: ULONG, + varDefaultValue: VARIANTARG, +}} +pub type LPPARAMDESCEX = *mut PARAMDESCEX; +STRUCT!{struct PARAMDESC { + pparamdescex: LPPARAMDESCEX, + wParamFlags: USHORT, +}} +pub type LPPARAMDESC = *mut PARAMDESC; +pub const PARAMFLAG_NONE: DWORD = 0; +pub const PARAMFLAG_FIN: DWORD = 0x1; +pub const PARAMFLAG_FOUT: DWORD = 0x2; +pub const PARAMFLAG_FLCID: DWORD = 0x4; +pub const PARAMFLAG_FRETVAL: DWORD = 0x8; +pub const PARAMFLAG_FOPT: DWORD = 0x10; +pub const PARAMFLAG_FHASDEFAULT: DWORD = 0x20; +pub const PARAMFLAG_FHASCUSTDATA: DWORD = 0x40; +STRUCT!{struct IDLDESC { + dwReserved: ULONG_PTR, + wIDLFlags: USHORT, +}} +pub type LPIDLDESC = *mut IDLDESC; +pub const IDLFLAG_NONE: DWORD = PARAMFLAG_NONE; +pub const IDLFLAG_FIN: DWORD = PARAMFLAG_FIN; +pub const IDLFLAG_FOUT: DWORD = PARAMFLAG_FOUT; +pub const IDLFLAG_FLCID: DWORD = PARAMFLAG_FLCID; +pub const IDLFLAG_FRETVAL: DWORD = PARAMFLAG_FRETVAL; +UNION!{union ELEMDESC_u { + [usize; 2], + idldesc idldesc_mut: IDLDESC, + paramdesc paramdesc_mut: PARAMDESC, +}} +STRUCT!{struct ELEMDESC { + tdesc: TYPEDESC, + u: ELEMDESC_u, +}} +pub type LPELEMDESC = *mut ELEMDESC; +STRUCT!{struct TYPEATTR { + guid: GUID, + lcid: LCID, + dwReserved: DWORD, + memidConstructor: MEMBERID, + memidDestructor: MEMBERID, + lpstrSchema: LPOLESTR, + cbSizeInstance: ULONG, + typekind: TYPEKIND, + cFuncs: WORD, + cVars: WORD, + cImplTypes: WORD, + cbSizeVft: WORD, + cbAlignment: WORD, + wTypeFlags: WORD, + wMajorVerNum: WORD, + wMinorVerNum: WORD, + tdescAlias: TYPEDESC, + idldescType: IDLDESC, +}} +pub type LPTYPEATTR = *mut TYPEATTR; +STRUCT!{struct DISPPARAMS { + rgvarg: *mut VARIANTARG, + rgdispidNamedArgs: *mut DISPID, + cArgs: UINT, + cNamedArgs: UINT, +}} +STRUCT!{struct EXCEPINFO { + wCode: WORD, + wReserved: WORD, + bstrSource: BSTR, + bstrDescription: BSTR, + bstrHelpFile: BSTR, + dwHelpContext: DWORD, + pvReserved: PVOID, + pfnDeferredFillIn: Option<unsafe extern "system" fn( + einfo: *mut EXCEPINFO, + ) -> HRESULT>, + scode: SCODE, +}} +ENUM!{enum CALLCONV { + CC_FASTCALL = 0, + CC_CDECL = 1, + CC_MSCPASCAL, + CC_PASCAL, + CC_MACPASCAL, + CC_STDCALL, + CC_FPFASTCALL, + CC_SYSCALL, + CC_MPWCDECL, + CC_MPWPASCAL, + CC_MAX, +}} +ENUM!{enum FUNCKIND { + FUNC_VIRTUAL = 0, + FUNC_PUREVIRTUAL, + FUNC_NONVIRTUAL, + FUNC_STATIC, + FUNC_DISPATCH, +}} +ENUM!{enum INVOKEKIND { + INVOKE_FUNC = 1, + INVOKE_PROPERTYGET = 2, + INVOKE_PROPERTYPUT = 4, + INVOKE_PROPERTYPUTREF = 8, +}} +STRUCT!{struct FUNCDESC { + memid: MEMBERID, + lprgscode: *mut SCODE, + lprgelemdescParam: *mut ELEMDESC, + funckind: FUNCKIND, + invkind: INVOKEKIND, + callconv: CALLCONV, + cParams: SHORT, + cParamsOpt: SHORT, + oVft: SHORT, + cScodes: SHORT, + elemdescFunc: ELEMDESC, + wFuncFlags: WORD, +}} +pub type LPFUNCDESC = *mut FUNCDESC; +ENUM!{enum VARKIND { + VAR_PERINSTANCE = 0, + VAR_STATIC, + VAR_CONST, + VAR_DISPATCH, +}} +pub const IMPLTYPEFLAG_FDEFAULT: DWORD = 0x1; +pub const IMPLTYPEFLAG_FSOURCE: DWORD = 0x2; +pub const IMPLTYPEFLAG_FRESTRICTED: DWORD = 0x4; +pub const IMPLTYPEFLAG_FDEFAULTVTABLE: DWORD = 0x8; +UNION!{union VARDESC_u { + [usize; 1], + oInst oInst_mut: ULONG, + lpvarValue lpvarValue_mut: *mut VARIANT, +}} +STRUCT!{struct VARDESC { + memid: MEMBERID, + lpstrSchema: LPOLESTR, + u: VARDESC_u, + elemdescVar: ELEMDESC, + wVarFlags: WORD, + varkind: VARKIND, +}} +pub type LPVARDESC = *mut VARDESC; +ENUM!{enum TYPEFLAGS { + TYPEFLAG_FAPPOBJECT = 0x1, + TYPEFLAG_FCANCREATE = 0x2, + TYPEFLAG_FLICENSED = 0x4, + TYPEFLAG_FPREDECLID = 0x8, + TYPEFLAG_FHIDDEN = 0x10, + TYPEFLAG_FCONTROL = 0x20, + TYPEFLAG_FDUAL = 0x40, + TYPEFLAG_FNONEXTENSIBLE = 0x80, + TYPEFLAG_FOLEAUTOMATION = 0x100, + TYPEFLAG_FRESTRICTED = 0x200, + TYPEFLAG_FAGGREGATABLE = 0x400, + TYPEFLAG_FREPLACEABLE = 0x800, + TYPEFLAG_FDISPATCHABLE = 0x1000, + TYPEFLAG_FREVERSEBIND = 0x2000, + TYPEFLAG_FPROXY = 0x4000, +}} +ENUM!{enum FUNCFLAGS { + FUNCFLAG_FRESTRICTED = 0x1, + FUNCFLAG_FSOURCE = 0x2, + FUNCFLAG_FBINDABLE = 0x4, + FUNCFLAG_FREQUESTEDIT = 0x8, + FUNCFLAG_FDISPLAYBIND = 0x10, + FUNCFLAG_FDEFAULTBIND = 0x20, + FUNCFLAG_FHIDDEN = 0x40, + FUNCFLAG_FUSESGETLASTERROR = 0x80, + FUNCFLAG_FDEFAULTCOLLELEM = 0x100, + FUNCFLAG_FUIDEFAULT = 0x200, + FUNCFLAG_FNONBROWSABLE = 0x400, + FUNCFLAG_FREPLACEABLE = 0x800, + FUNCFLAG_FIMMEDIATEBIND = 0x1000, +}} +ENUM!{enum VARFLAGS { + VARFLAG_FREADONLY = 0x1, + VARFLAG_FSOURCE = 0x2, + VARFLAG_FBINDABLE = 0x4, + VARFLAG_FREQUESTEDIT = 0x8, + VARFLAG_FDISPLAYBIND = 0x10, + VARFLAG_FDEFAULTBIND = 0x20, + VARFLAG_FHIDDEN = 0x40, + VARFLAG_FRESTRICTED = 0x80, + VARFLAG_FDEFAULTCOLLELEM = 0x100, + VARFLAG_FUIDEFAULT = 0x200, + VARFLAG_FNONBROWSABLE = 0x400, + VARFLAG_FREPLACEABLE = 0x800, + VARFLAG_FIMMEDIATEBIND = 0x1000, +}} +STRUCT!{struct CLEANLOCALSTORAGE { + pInterface: *mut IUnknown, + pStorage: PVOID, + flags: DWORD, +}} +STRUCT!{struct CUSTDATAITEM { + guid: GUID, + varValue: VARIANTARG, +}} +pub type LPCUSTDATAITEM = *mut CUSTDATAITEM; +STRUCT!{struct CUSTDATA { + cCustData: DWORD, + prgCustData: LPCUSTDATAITEM, +}} +pub type LPCUSTDATA = *mut CUSTDATA; +pub type LPCREATETYPEINFO = *mut ICreateTypeInfo; +RIDL!{#[uuid(0x00020405, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ICreateTypeInfo(ICreateTypeInfoVtbl): IUnknown(IUnknownVtbl) { + fn SetGuid( + guid: REFGUID, + ) -> HRESULT, + fn SetTypeFlags( + uTypeFlags: UINT, + ) -> HRESULT, + fn SetDocString( + pStrDoc: LPOLESTR, + ) -> HRESULT, + fn SetHelpContext( + dwHelpContext: DWORD, + ) -> HRESULT, + fn SetVersion( + wMajorVerNum: WORD, + wMinorVerNum: WORD, + ) -> HRESULT, + fn AddRefTypeInfo( + pTInfo: *mut ITypeInfo, + ) -> HRESULT, + fn AddFuncDesc( + index: UINT, + pFuncDesc: *mut FUNCDESC, + ) -> HRESULT, + fn SetImplTypeFlags( + index: UINT, + implTypeFlags: INT, + ) -> HRESULT, + fn SetAlignment( + cbAlignment: WORD, + ) -> HRESULT, + fn SetSchema( + pStrSchema: LPOLESTR, + ) -> HRESULT, + fn AddVarDesc( + index: UINT, + pVarDesc: *mut VARDESC, + ) -> HRESULT, + fn SetFuncAndParamNames( + index: UINT, + rgszNames: *mut LPOLESTR, + cNames: UINT, + ) -> HRESULT, + fn SetVarName( + index: UINT, + szName: LPOLESTR, + ) -> HRESULT, + fn SetTypeDescAlias( + pTDescAlias: *mut TYPEDESC, + ) -> HRESULT, + fn DefineFuncAsDllEntry( + index: UINT, + szDllName: LPOLESTR, + szProcName: LPOLESTR, + ) -> HRESULT, + fn SetFuncDocString( + index: UINT, + szDocString: LPOLESTR, + ) -> HRESULT, + fn SetVarDocString( + index: UINT, + szDocString: LPOLESTR, + ) -> HRESULT, + fn SetFuncHelpContext( + index: UINT, + dwHelpContext: DWORD, + ) -> HRESULT, + fn SetVarHelpContext( + index: UINT, + dwHelpContext: DWORD, + ) -> HRESULT, + fn SetMops( + index: UINT, + bstrMops: BSTR, + ) -> HRESULT, + fn SetTypeIdldesc( + pIdlDesc: *mut IDLDESC, + ) -> HRESULT, + fn LayOut() -> HRESULT, +}} +// LPCREATETYPEINFO2 +// ICreateTypeInfo2 +// LPCREATETYPELIB +// ICreateTypeLib +// LPCREATETYPELIB2 +// ICreateTypeLib2 +pub type LPDISPATCH = *mut IDispatch; +pub const DISPID_UNKNOWN: INT = -1; +pub const DISPID_VALUE: INT = 0; +pub const DISPID_PROPERTYPUT: INT = -3; +pub const DISPID_NEWENUM: INT = -4; +pub const DISPID_EVALUATE: INT = -5; +pub const DISPID_CONSTRUCTOR: INT = -6; +pub const DISPID_DESTRUCTOR: INT = -7; +pub const DISPID_COLLECT: INT = -8; +RIDL!{#[uuid(0x00020400, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IDispatch(IDispatchVtbl): IUnknown(IUnknownVtbl) { + fn GetTypeInfoCount( + pctinfo: *mut UINT, + ) -> HRESULT, + fn GetTypeInfo( + iTInfo: UINT, + lcid: LCID, + ppTInfo: *mut *mut ITypeInfo, + ) -> HRESULT, + fn GetIDsOfNames( + riid: REFIID, + rgszNames: *mut LPOLESTR, + cNames: UINT, + lcid: LCID, + rgDispId: *mut DISPID, + ) -> HRESULT, + fn Invoke( + dispIdMember: DISPID, + riid: REFIID, + lcid: LCID, + wFlags: WORD, + pDispParams: *mut DISPPARAMS, + pVarResult: *mut VARIANT, + pExcepInfo: *mut EXCEPINFO, + puArgErr: *mut UINT, + ) -> HRESULT, +}} +// IDispatch_RemoteInvoke_Proxy +// IDispatch_RemoteInvoke_Stub +// LPENUMVARIANT +// IEnumVARIANT +// IEnumVARIANT_RemoteNext_Proxy +// IEnumVARIANT_RemoteNext_Stub +RIDL!{#[uuid(0x0000002F, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IRecordInfo(IRecordInfoVtbl): IUnknown(IUnknownVtbl) { + fn RecordInit( + pvNew: PVOID, + ) -> HRESULT, + fn RecordClear( + pvExisting: PVOID, + ) -> HRESULT, + fn RecordCopy( + pvExisting: PVOID, + pvNew: PVOID, + ) -> HRESULT, + fn GetGuid( + pguid: *mut GUID, + ) -> HRESULT, + fn GetName( + pbstrName: *mut BSTR, + ) -> HRESULT, + fn GetSize( + pcbSize: *mut ULONG, + ) -> HRESULT, + fn GetTypeInfo( + ppTypeInfo: *mut *mut ITypeInfo, + ) -> HRESULT, + fn GetField( + pvData: PVOID, + szFieldName: LPCOLESTR, + pvarField: *mut VARIANT, + ) -> HRESULT, + fn GetFieldNoCopy( + pvData: PVOID, + szFieldName: LPCOLESTR, + pvarField: *mut VARIANT, + ppvDataCArray: *mut PVOID, + ) -> HRESULT, + fn PutField( + wFlags: ULONG, + pvData: PVOID, + szFieldName: LPCOLESTR, + pvarField: *mut VARIANT, + ) -> HRESULT, + fn PutFieldNoCopy( + wFlags: ULONG, + pvData: PVOID, + szFieldName: LPCOLESTR, + pvarField: *mut VARIANT, + ) -> HRESULT, + fn GetFieldNames( + pcNames: *mut ULONG, + rgBstrNames: *mut BSTR, + ) -> HRESULT, + fn IsMatchingType( + pRecordInfo: *mut IRecordInfo, + ) -> BOOL, + fn RecordCreate() -> PVOID, + fn RecordCreateCopy( + pvSource: PVOID, + ppvDest: *mut PVOID, + ) -> HRESULT, + fn RecordDestroy( + pvRecord: PVOID, + ) -> HRESULT, +}} +pub type LPTYPECOMP = *mut ITypeComp; +ENUM!{enum DESCKIND { + DESCKIND_NONE = 0, + DESCKIND_FUNCDESC = DESCKIND_NONE + 1, + DESCKIND_VARDESC = DESCKIND_FUNCDESC + 1, + DESCKIND_TYPECOMP = DESCKIND_VARDESC + 1, + DESCKIND_IMPLICITAPPOBJ = DESCKIND_TYPECOMP + 1, + DESCKIND_MAX = DESCKIND_IMPLICITAPPOBJ + 1, +}} +UNION!{union BINDPTR { + [usize; 1], + lpfuncdesc lpfuncdesc_mut: *mut FUNCDESC, + lpvardesc lpvardesc_mut: *mut VARDESC, + lptcomp lptcomp_mut: *mut ITypeComp, +}} +pub type LPBINDPTR = *mut BINDPTR; +RIDL!{#[uuid(0x00020403, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ITypeComp(ITypeCompVtbl): IUnknown(IUnknownVtbl) { + fn Bind( + szName: LPOLESTR, + lHashVal: ULONG, + wFlags: WORD, + ppTInfo: *mut *mut ITypeInfo, + pDescKind: *mut DESCKIND, + pBindPtr: *mut BINDPTR, + ) -> HRESULT, + fn BindType( + szName: LPOLESTR, + lHashVal: ULONG, + ppTInfo: *mut *mut ITypeInfo, + ppTComp: *mut *mut ITypeComp, + ) -> HRESULT, +}} +ENUM!{enum SYSKIND { + SYS_WIN16 = 0, + SYS_WIN32, + SYS_MAC, + SYS_WIN64, +}} +STRUCT!{struct TLIBATTR { + guid: GUID, + lcid: LCID, + syskind: SYSKIND, + wMajorVerNum: WORD, + wMinorVerNum: WORD, + wLibFlags: WORD, +}} +RIDL!{#[uuid(0x00020402, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ITypeLib(ITypeLibVtbl): IUnknown(IUnknownVtbl) { + fn GetTypeInfoCount() -> UINT, + fn GetTypeInfo( + index: UINT, + ppTInfo: *mut *mut ITypeInfo, + ) -> HRESULT, + fn GetTypeInfoType( + index: UINT, + pTKind: *mut TYPEKIND, + ) -> HRESULT, + fn GetTypeInfoOfGuid( + guid: REFGUID, + ppTInfo: *mut *mut ITypeInfo, + ) -> HRESULT, + fn GetLibAttr( + ppTLibAttr: *mut *mut TLIBATTR, + ) -> HRESULT, + fn GetTypeComp( + ppTComp: *mut *mut ITypeComp, + ) -> HRESULT, + fn GetDocumentation( + index: INT, + pbstrName: *mut BSTR, + pBstrDocString: *mut BSTR, + pdwHelpContext: *mut DWORD, + pBstrHelpFile: *mut BSTR, + ) -> HRESULT, + fn IsName( + szNameBuf: LPOLESTR, + lHashVal: ULONG, + pfName: *mut BOOL, + ) -> HRESULT, + fn FindName( + szNameBuf: LPOLESTR, + lHashVal: ULONG, + ppTInfo: *mut *mut ITypeInfo, + rgMemId: *mut MEMBERID, + pcFound: *mut USHORT, + ) -> HRESULT, + fn ReleaseTLibAttr( + pTLibAttr: *const TLIBATTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00020401, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ITypeInfo(ITypeInfoVtbl): IUnknown(IUnknownVtbl) { + fn GetTypeAttr( + ppTypeAttr: *mut *mut TYPEATTR, + ) -> HRESULT, + fn GetTypeComp( + ppTComp: *mut *mut ITypeComp, + ) -> HRESULT, + fn GetFuncDesc( + index: UINT, + ppFunDesc: *mut *mut FUNCDESC, + ) -> HRESULT, + fn GetVarDesc( + index: UINT, + pPVarDesc: *mut *mut VARDESC, + ) -> HRESULT, + fn GetNames( + memid: MEMBERID, + rgBstrNames: *mut BSTR, + cMaxNames: UINT, + pcNames: *mut UINT, + ) -> HRESULT, + fn GetRefTypeOfImplType( + index: UINT, + pRefType: *mut HREFTYPE, + ) -> HRESULT, + fn GetImplTypeFlags( + index: UINT, + pImplTypeFlags: *mut INT, + ) -> HRESULT, + fn GetIDsOfNames( + rgszNames: *mut LPOLESTR, + cNames: UINT, + pMemId: *mut MEMBERID, + ) -> HRESULT, + fn Invoke( + pvInstance: PVOID, + memid: MEMBERID, + wFlags: WORD, + pDispParams: *mut DISPPARAMS, + pVarResult: *mut VARIANT, + pExcepInfo: *mut EXCEPINFO, + puArgErr: *mut UINT, + ) -> HRESULT, + fn GetDocumentation( + memid: MEMBERID, + pBstrName: *mut BSTR, + pBstrDocString: *mut BSTR, + pdwHelpContext: *mut DWORD, + pBstrHelpFile: *mut BSTR, + ) -> HRESULT, + fn GetDllEntry( + memid: MEMBERID, + invKind: INVOKEKIND, + pBstrDllName: *mut BSTR, + pBstrName: *mut BSTR, + pwOrdinal: *mut WORD, + ) -> HRESULT, + fn GetRefTypeInfo( + hRefType: HREFTYPE, + ppTInfo: *mut *mut ITypeInfo, + ) -> HRESULT, + fn AddressOfMember( + memid: MEMBERID, + invKind: INVOKEKIND, + ppv: *mut PVOID, + ) -> HRESULT, + fn CreateInstance( + pUnkOuter: *mut IUnknown, + riid: REFIID, + ppvObj: *mut PVOID, + ) -> HRESULT, + fn GetMops( + memid: MEMBERID, + pBstrMops: *mut BSTR, + ) -> HRESULT, + fn GetContainingTypeLib( + ppTLib: *mut *mut ITypeLib, + pIndex: *mut UINT, + ) -> HRESULT, + fn ReleaseTypeAttr( + pTypeAttr: *mut TYPEATTR, + ) -> (), + fn ReleaseFuncDesc( + pFuncDesc: *mut FUNCDESC, + ) -> (), + fn ReleaseVarDesc( + pVarDesc: *mut VARDESC, + ) -> (), +}} +RIDL!{#[uuid(0x3127ca40, 0x446e, 0x11ce, 0x81, 0x35, 0x00, 0xaa, 0x00, 0x4b, 0xb8, 0x51)] +interface IErrorLog(IErrorLogVtbl): IUnknown(IUnknownVtbl) { + fn AddError( + pszPropName: LPCOLESTR, + pExcepInfo: *const EXCEPINFO, + ) -> HRESULT, +}} +pub type LPERRORLOG = *mut IErrorLog; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/objbase.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/objbase.rs new file mode 100644 index 0000000..7caffac --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/objbase.rs @@ -0,0 +1,64 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Component object model defintions +use shared::minwindef::LPVOID; +use um::combaseapi::COINITBASE_MULTITHREADED; +use um::winnt::HRESULT; +ENUM!{enum COINIT { + COINIT_APARTMENTTHREADED = 0x2, + COINIT_MULTITHREADED = COINITBASE_MULTITHREADED, + COINIT_DISABLE_OLE1DDE = 0x4, + COINIT_SPEED_OVER_MEMORY = 0x8, +}} + // pub fn CoBuildVersion(); +extern "system" { + pub fn CoInitialize( + pvReserved: LPVOID, + ) -> HRESULT; +} + // pub fn CoRegisterMallocSpy(); + // pub fn CoRevokeMallocSpy(); + // pub fn CoRegisterInitializeSpy(); + // pub fn CoRevokeInitializeSpy(); + // pub fn CoGetSystemSecurityPermissions(); + // pub fn CoLoadLibrary(); + // pub fn CoFreeLibrary(); + // pub fn CoFreeAllLibraries(); + // pub fn CoGetInstanceFromFile(); + // pub fn CoGetInstanceFromIStorage(); + // pub fn CoAllowSetForegroundWindow(); + // pub fn DcomChannelSetHResult(); + // pub fn CoIsOle1Class(); + // pub fn CLSIDFromProgIDEx(); + // pub fn CoFileTimeToDosDateTime(); + // pub fn CoDosDateTimeToFileTime(); + // pub fn CoFileTimeNow(); + // pub fn CoRegisterMessageFilter(); + // pub fn CoRegisterChannelHook(); + // pub fn CoTreatAsClass(); + // pub fn CreateDataAdviseHolder(); + // pub fn CreateDataCache(); + // pub fn StgOpenAsyncDocfileOnIFillLockBytes(); + // pub fn StgGetIFillLockBytesOnILockBytes(); + // pub fn StgGetIFillLockBytesOnFile(); + // pub fn StgOpenLayoutDocfile(); + // pub fn CoInstall(); + // pub fn BindMoniker(); + // pub fn CoGetObject(); + // pub fn MkParseDisplayName(); + // pub fn MonikerRelativePathTo(); + // pub fn MonikerCommonPrefixWith(); + // pub fn CreateBindCtx(); + // pub fn CreateGenericComposite(); + // pub fn GetClassFile(); + // pub fn CreateClassMoniker(); + // pub fn CreateFileMoniker(); + // pub fn CreateItemMoniker(); + // pub fn CreateAntiMoniker(); + // pub fn CreatePointerMoniker(); + // pub fn CreateObjrefMoniker(); + // pub fn GetRunningObjectTable(); + // pub fn CreateStdProgressIndicator(); diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/objidl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/objidl.rs new file mode 100644 index 0000000..f3f0b27 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/objidl.rs @@ -0,0 +1,507 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! this ALWAYS GENERATED file contains the definitions for the interfaces +use ctypes::c_void; +use shared::basetsd::UINT64; +use shared::guiddef::{CLSID, IID, REFCLSID, REFIID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FILETIME, HGLOBAL, ULONG, WORD}; +use shared::ntdef::LONG; +use shared::windef::{HBITMAP, HENHMETAFILE}; +use shared::wtypes::{CLIPFORMAT, HMETAFILEPICT}; +use shared::wtypesbase::{LPOLESTR, OLECHAR}; +use um::objidlbase::{IEnumString, IStream, STATSTG}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, ULARGE_INTEGER}; +//8402 +STRUCT!{struct BIND_OPTS { + cbStruct: DWORD, + grfFlags: DWORD, + grfMode: DWORD, + dwTickCountDeadline: DWORD, +}} +pub type LPBIND_OPTS = *mut BIND_OPTS; +//8479 +RIDL!{#[uuid(0x0000000e, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IBindCtx(IBindCtxVtbl): IUnknown(IUnknownVtbl) { + fn RegisterObjectBound( + punk: *mut IUnknown, + ) -> HRESULT, + fn RevokeObjectBound( + punk: *mut IUnknown, + ) -> HRESULT, + fn ReleaseBoundObjects() -> HRESULT, + fn SetBindOptions( + pbindopts: *mut BIND_OPTS, + ) -> HRESULT, + fn GetBindOptions( + pbindopts: *mut BIND_OPTS, + ) -> HRESULT, + fn GetRunningObjectTable( + pprot: *mut *mut IRunningObjectTable, + ) -> HRESULT, + fn RegisterObjectParam( + pszKey: LPOLESTR, + punk: *mut IUnknown, + ) -> HRESULT, + fn GetObjectParam( + pszKey: LPOLESTR, + ppunk: *mut *mut IUnknown, + ) -> HRESULT, + fn EnumObjectParam( + ppenum: *mut *mut IEnumString, + ) -> HRESULT, + fn RevokeObjectParam( + pszKey: LPOLESTR, + ) -> HRESULT, +}} +//8681 +RIDL!{#[uuid(0x00000102, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumMoniker(IEnumMonikerVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut *mut IMoniker, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumMoniker, + ) -> HRESULT, +}} +//8958 +RIDL!{#[uuid(0x00000010, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IRunningObjectTable(IRunningObjectTableVtbl): IUnknown(IUnknownVtbl) { + fn Register( + grfFlags: DWORD, + punkObject: *mut IUnknown, + pmkObjectName: *mut IMoniker, + pdwRegister: *mut DWORD, + ) -> HRESULT, + fn Revoke( + dwRegister: DWORD, + ) -> HRESULT, + fn IsRunning( + pmkObjectName: *mut IMoniker, + ) -> HRESULT, + fn GetObject( + pmkObjectName: *mut IMoniker, + ppunkObject: *mut *mut IUnknown, + ) -> HRESULT, + fn NoteChangeTime( + dwRegister: DWORD, + pfiletime: *mut FILETIME, + ) -> HRESULT, + fn GetTimeOfLastChange( + pmkObjectName: *mut IMoniker, + pfiletime: *mut FILETIME, + ) -> HRESULT, + fn EnumRunning( + ppenumMoniker: *mut *mut IEnumMoniker, + ) -> HRESULT, +}} +//9125 +RIDL!{#[uuid(0x0000010c, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IPersist(IPersistVtbl): IUnknown(IUnknownVtbl) { + fn GetClassID( + pClassID: *mut CLSID, + ) -> HRESULT, +}} +//9207 +RIDL!{#[uuid(0x00000109, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IPersistStream(IPersistStreamVtbl): IPersist(IPersistVtbl) { + fn IsDirty() -> HRESULT, + fn Load( + pStm: *mut IStream, + ) -> HRESULT, + fn Save( + pStm: *mut IStream, + fClearDirty: BOOL, + ) -> HRESULT, + fn GetSizeMax( + pcbSize: *mut ULARGE_INTEGER, + ) -> HRESULT, +}} +//9350 +RIDL!{#[uuid(0x0000000f, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IMoniker(IMonikerVtbl): IPersistStream(IPersistStreamVtbl) { + fn BindToObject( + pbc: *mut IBindCtx, + pmkToLeft: *mut IMoniker, + riidResult: REFIID, + ppvResult: *mut *mut c_void, + ) -> HRESULT, + fn BindToStorage( + pbc: *mut IBindCtx, + pmkToLeft: *mut IMoniker, + riid: REFIID, + ppvObj: *mut *mut c_void, + ) -> HRESULT, + fn Reduce( + pbc: *mut IBindCtx, + dwReduceHowFar: DWORD, + ppmkToLeft: *mut *mut IMoniker, + ppmkReduced: *mut *mut IMoniker, + ) -> HRESULT, + fn ComposeWith( + pmkRight: *mut IMoniker, + fOnlyIfNotGeneric: BOOL, + ppmkComposite: *mut *mut IMoniker, + ) -> HRESULT, + fn Enum( + fForward: BOOL, + ppenumMoniker: *mut *mut IEnumMoniker, + ) -> HRESULT, + fn IsEqual( + pmkOtherMoniker: *mut IMoniker, + ) -> HRESULT, + fn Hash( + pdwHash: *mut DWORD, + ) -> HRESULT, + fn IsRunning( + pbc: *mut IBindCtx, + pmkToLeft: *mut IMoniker, + pmkNewlyRunning: *mut IMoniker, + ) -> HRESULT, + fn GetTimeOfLastChange( + pbc: *mut IBindCtx, + pmkToLeft: *mut IMoniker, + pFileTime: *mut FILETIME, + ) -> HRESULT, + fn Inverse( + ppmk: *mut *mut IMoniker, + ) -> HRESULT, + fn CommonPrefixWith( + pmkOther: *mut IMoniker, + ppmkPrefix: *mut *mut IMoniker, + ) -> HRESULT, + fn RelativePathTo( + pmkOther: *mut IMoniker, + ppmkRelPath: *mut *mut IMoniker, + ) -> HRESULT, + fn GetDisplayName( + pbc: *mut IBindCtx, + pmkToLeft: *mut IMoniker, + ppszDisplayName: *mut LPOLESTR, + ) -> HRESULT, + fn ParseDisplayName( + pbc: *mut IBindCtx, + pmkToLeft: *mut IMoniker, + pszDisplayName: LPOLESTR, + pchEaten: *mut ULONG, + ppmkOut: *mut *mut IMoniker, + ) -> HRESULT, + fn IsSystemMoniker( + pdwMksys: *mut DWORD, + ) -> HRESULT, +}} +ENUM!{enum EOLE_AUTHENTICATION_CAPABILITIES { + EOAC_NONE = 0, + EOAC_MUTUAL_AUTH = 0x1, + EOAC_STATIC_CLOAKING = 0x20, + EOAC_DYNAMIC_CLOAKING = 0x40, + EOAC_ANY_AUTHORITY = 0x80, + EOAC_MAKE_FULLSIC = 0x100, + EOAC_DEFAULT = 0x800, + EOAC_SECURE_REFS = 0x2, + EOAC_ACCESS_CONTROL = 0x4, + EOAC_APPID = 0x8, + EOAC_DYNAMIC = 0x10, + EOAC_REQUIRE_FULLSIC = 0x200, + EOAC_AUTO_IMPERSONATE = 0x400, + EOAC_NO_CUSTOM_MARSHAL = 0x2000, + EOAC_DISABLE_AAA = 0x1000, +}} +STRUCT!{struct SOLE_AUTHENTICATION_SERVICE { + dwAuthnSvc: DWORD, + dwAuthzSvc: DWORD, + pPrincipalName: *mut OLECHAR, + hr: HRESULT, +}} +RIDL!{#[uuid(0x0000000d, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumSTATSTG(IEnumSTATSTGVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut STATSTG, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumSTATSTG, + ) -> HRESULT, +}} +pub type SNB = *const *const OLECHAR; +RIDL!{#[uuid(0x0000000b, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IStorage(IStorageVtbl): IUnknown(IUnknownVtbl) { + fn CreateStream( + pwcsName: *const OLECHAR, + grfMode: DWORD, + reserved1: DWORD, + reserved2: DWORD, + ppstm: *mut *mut IStream, + ) -> HRESULT, + fn OpenStream( + pwcsName: *const OLECHAR, + reserved1: *const c_void, + grfMode: DWORD, + reserved2: DWORD, + ppstm: *mut *mut IStream, + ) -> HRESULT, + fn CreateStorage( + pwcsName: *const OLECHAR, + grfMode: DWORD, + reserved1: DWORD, + reserved2: DWORD, + ppstg: *mut *mut IStorage, + ) -> HRESULT, + fn OpenStorage( + pwcsName: *const OLECHAR, + pstgPriority: IStorage, + grfMode: DWORD, + snbExclude: SNB, + reserved: DWORD, + ppstg: *mut *mut IStorage, + ) -> HRESULT, + fn CopyTo( + ciidExclude: DWORD, + rgiidExclude: *const IID, + snbExclude: SNB, + pstgDest: *const IStorage, + ) -> HRESULT, + fn MoveElementTo( + pwcsName: *const OLECHAR, + pstgDest: *const IStorage, + pwcsNewName: *const OLECHAR, + grfFlags: DWORD, + ) -> HRESULT, + fn Commit( + grfCommitFlags: DWORD, + ) -> HRESULT, + fn Revert() -> HRESULT, + fn EnumElements( + reserved1: DWORD, + reserved2: *const c_void, + reserved3: DWORD, + ppenum: *mut *mut IEnumSTATSTG, + ) -> HRESULT, + fn DestroyElement( + pwcsName: *const OLECHAR, + ) -> HRESULT, + fn RenameElement( + pwcsOldName: *const OLECHAR, + pwcsNewName: *const OLECHAR, + ) -> HRESULT, + fn SetElementTimes( + pwcsName: *const OLECHAR, + pctime: *const FILETIME, + patime: *const FILETIME, + pmtime: *const FILETIME, + ) -> HRESULT, + fn SetClass( + clsid: REFCLSID, + ) -> HRESULT, + fn SetStateBits( + grfStateBits: DWORD, + grfMask: DWORD, + ) -> HRESULT, + fn Stat( + pstatstg: *mut STATSTG, + grfStatFlag: DWORD, + ) -> HRESULT, +}} +STRUCT!{struct DVTARGETDEVICE { + tdSize: DWORD, + tdDriverNameOffset: WORD, + tdDeviceNameOffset: WORD, + tdPortNameOffset: WORD, + tdExtDevmodeOFfset: WORD, + tdData: [BYTE; 1], +}} +STRUCT!{struct FORMATETC { + cfFormat: CLIPFORMAT, + ptd: *const DVTARGETDEVICE, + dwAspect: DWORD, + lindex: LONG, + tymed: DWORD, +}} +RIDL!{#[uuid(0x00000103, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumFORMATETC(IEnumFORMATETCVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut FORMATETC, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumFORMATETC, + ) -> HRESULT, +}} +ENUM!{enum ADVF { + ADVF_NODATA = 1, + ADVF_PRIMEFIRST = 2, + ADVF_ONLYONCE = 4, + ADVF_DATAONSTOP = 64, + ADVFCACHE_NOHANDLER = 8, + ADVFCACHE_FORCEBUILTIN = 16, + ADVFCACHE_ONSAVE = 32, +}} +STRUCT!{struct STATDATA { + formatetc: FORMATETC, + advf: DWORD, + pAdvSInk: *mut IAdviseSink, + dwConnection: DWORD, +}} +RIDL!{#[uuid(0x00000105, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumSTATDATA(IEnumSTATDATAVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut STATDATA, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumSTATDATA, + ) -> HRESULT, +}} +ENUM!{enum TYMED { + TYMED_HGLOBAL = 1, + TYMED_FILE = 2, + TYMED_ISTREAM = 4, + TYMED_ISTORAGE = 8, + TYMED_GDI = 16, + TYMED_MFPICT = 32, + TYMED_ENHMF = 64, + TYMED_NULL = 0, +}} +UNION!{union STGMEDIUM_u { + [u64; 7], //TODO: I guessed to move on + hBitmap hBitmap_mut: HBITMAP, + hMetaFilePict hMetaFilePict_mut: HMETAFILEPICT, + hEnhMetaFile hEnhMetaFile_mut: HENHMETAFILE, + hGlobal hGlobal_mut: HGLOBAL, + lpszFileName lpszFileName_mut: LPOLESTR, + pstm pstm_mut: *mut IStream, + pstg pstg_mut: *mut IStorage, +}} +STRUCT!{struct STGMEDIUM { + tymed: DWORD, + u: *mut STGMEDIUM_u, + pUnkForRelease: *mut IUnknown, +}} +RIDL!{#[uuid(0x0000010f, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IAdviseSink(IAdviseSinkVtbl): IUnknown(IUnknownVtbl) { + fn OnDataChange( + pformatetc: *mut FORMATETC, + pStgmed: *mut STGMEDIUM, + ) -> c_void, + fn OnViewChange( + dwAspect: DWORD, + lindex: LONG, + ) -> c_void, + fn OnRename( + pmk: *mut IMoniker, + ) -> c_void, + fn OnSave() -> c_void, + fn OnClose() -> c_void, +}} +ENUM!{enum DATADIR { + DATADIR_GET = 1, + DATADIR_SET = 2, +}} +pub type LPDATAOBJECT = *mut IDataObject; +RIDL!{#[uuid(0x0000010e, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IDataObject(IDataObjectVtbl): IUnknown(IUnknownVtbl) { + fn GetData( + pformatetcIn: *const FORMATETC, + pmedium: *mut STGMEDIUM, + ) -> HRESULT, + fn GetDataHere( + pformatetc: *const FORMATETC, + pmedium: *mut STGMEDIUM, + ) -> HRESULT, + fn QueryGetData( + pformatetc: *const FORMATETC, + ) -> HRESULT, + fn GetCanonicalFormatEtc( + pformatetcIn: *const FORMATETC, + pformatetcOut: *mut FORMATETC, + ) -> HRESULT, + fn SetData( + pformatetc: *const FORMATETC, + pformatetcOut: *const FORMATETC, + fRelease: BOOL, + ) -> HRESULT, + fn EnumFormatEtc( + dwDirection: DWORD, + ppenumFormatEtc: *mut *mut IEnumFORMATETC, + ) -> HRESULT, + fn DAdvise( + pformatetc: *const FORMATETC, + advf: DWORD, + pAdvSInk: *const IAdviseSink, + pdwConnection: *mut DWORD, + ) -> HRESULT, + fn DUnadvise( + dwConnection: DWORD, + ) -> HRESULT, + fn EnumDAdvise( + ppenumAdvise: *const *const IEnumSTATDATA, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa2f05a09, 0x27a2, 0x42b5, 0xbc, 0x0e, 0xac, 0x16, 0x3e, 0xf4, 0x9d, 0x9b)] +interface IApartmentShutdown(IApartmentShutdownVtbl): IUnknown(IUnknownVtbl) { + fn OnUninitialize( + ui64ApartmentIdentifier: UINT64, + ) -> (), +}} +RIDL!{#[uuid(0x00000003, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IMarshal(IMarshalVtbl): IUnknown(IUnknownVtbl) { + fn GetUnmarshalClass( + riid: REFIID, + pv: *mut c_void, + dwDestContext: DWORD, + pvDestContext: *mut c_void, + mshlflags: DWORD, + pCid: *mut CLSID, + ) -> HRESULT, + fn GetMarshalSizeMax( + riid: REFIID, + pv: *mut c_void, + dwDestContext: DWORD, + pvDestContext: *mut c_void, + mshlflags: DWORD, + pSize: *mut DWORD, + ) -> HRESULT, + fn MarshalInterface( + pStm: *mut IStream, + riid: REFIID, + pv: *mut c_void, + dwDestContext: DWORD, + pvDestContext: *mut c_void, + mshlflags: DWORD, + ) -> HRESULT, + fn UnmarshalInterface( + pStm: *mut IStream, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, + fn ReleaseMarshalData( + pStm: *mut IStream, + ) -> HRESULT, + fn DisconnectObject( + dwReserved: DWORD, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/objidlbase.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/objidlbase.rs new file mode 100644 index 0000000..9984480 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/objidlbase.rs @@ -0,0 +1,952 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_int, c_void}; +use shared::basetsd::{SIZE_T, ULONG_PTR}; +use shared::guiddef::{CLSID, GUID, IID, REFCLSID, REFGUID, REFIID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FILETIME, ULONG}; +use shared::wtypesbase::{COAUTHINFO, DOUBLE, LPOLESTR, OLECHAR}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, LARGE_INTEGER, LONG, LPWSTR, ULARGE_INTEGER}; +STRUCT!{struct COSERVERINFO { + dwReserved1: DWORD, + pwszName: LPWSTR, + pAuthInfo: *mut COAUTHINFO, + dwReserved2: DWORD, +}} +pub type LPMARSHAL = *mut IMarshal; +RIDL!{#[uuid(0x00000003, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IMarshal(IMarshalVtbl): IUnknown(IUnknownVtbl) { + fn GetUnmarshalClass( + riid: REFIID, + pv: *mut c_void, + dwDestContext: DWORD, + pvDestContext: *mut c_void, + mshlflags: DWORD, + pCid: *mut CLSID, + ) -> HRESULT, + fn GetMarshalSizeMax( + riid: REFIID, + pv: *mut c_void, + dwDestContext: DWORD, + pvDestContext: *mut c_void, + mshlflags: DWORD, + pSize: *mut DWORD, + ) -> HRESULT, + fn MarshalInterface( + pStm: *mut IStream, + riid: REFIID, + pv: *mut c_void, + dwDestContext: DWORD, + pvDestContext: *mut c_void, + mshlflags: DWORD, + ) -> HRESULT, + fn UnmarshalInterface( + pStm: *mut IStream, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, + fn ReleaseMarshalData( + pStm: *mut IStream, + ) -> HRESULT, + fn DisconnectObject( + dwReserved: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xecc8691b, 0xc1db, 0x4dc0, 0x85, 0x5e, 0x65, 0xf6, 0xc5, 0x51, 0xaf, 0x49)] +interface INoMarshal(INoMarshalVtbl): IUnknown(IUnknownVtbl) {}} +RIDL!{#[uuid(0x94ea2b94, 0xe9cc, 0x49e0, 0xc0, 0xff, 0xee, 0x64, 0xca, 0x8f, 0x5b, 0x90)] +interface IAgileObject(IAgileObjectVtbl): IUnknown(IUnknownVtbl) {}} +ENUM!{enum ACTIVATIONTYPE { + ACTIVATIONTYPE_UNCATEGORIZED = 0, + ACTIVATIONTYPE_FROM_MONIKER = 0x1, + ACTIVATIONTYPE_FROM_DATA = 0x2, + ACTIVATIONTYPE_FROM_STORAGE = 0x4, + ACTIVATIONTYPE_FROM_STREAM = 0x8, + ACTIVATIONTYPE_FROM_FILE = 0x10, +}} +RIDL!{#[uuid(0x00000017, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IActivationFilter(IActivationFilterVtbl): IUnknown(IUnknownVtbl) { + fn HandleActivation( + dwActivationType: DWORD, + rclsid: REFCLSID, + pReplacementClsId: *mut CLSID, + ) -> HRESULT, +}} +pub type LPMARSHAL2 = *mut IMarshal2; +RIDL!{#[uuid(0x000001cf, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IMarshal2(IMarshal2Vtbl): IMarshal(IMarshalVtbl) {}} +pub type LPMALLOC = *mut IMalloc; +RIDL!{#[uuid(0x00000002, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IMalloc(IMallocVtbl): IUnknown(IUnknownVtbl) { + fn Alloc( + cb: SIZE_T, + ) -> *mut c_void, + fn Realloc( + pv: *mut c_void, + cb: SIZE_T, + ) -> *mut c_void, + fn Free( + pv: *mut c_void, + ) -> (), + fn GetSize( + pv: *mut c_void, + ) -> SIZE_T, + fn DidAlloc( + pv: *mut c_void, + ) -> c_int, + fn HeapMinimize() -> (), +}} +pub type LPSTDMARSHALINFO = IStdMarshalInfo; +RIDL!{#[uuid(0x00000018, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IStdMarshalInfo(IStdMarshalInfoVtbl): IUnknown(IUnknownVtbl) { + fn GetClassForHandler( + dwDestContext: DWORD, + pvDestContext: *mut c_void, + pClsid: *mut CLSID, + ) -> HRESULT, +}} +ENUM!{enum EXTCONN { + EXTCONN_STRONG = 0x1, + EXTCONN_WEAK = 0x2, + EXTCONN_CALLABLE = 0x4, +}} +RIDL!{#[uuid(0x00000019, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IExternalConnection(IExternalConnectionVtbl): IUnknown(IUnknownVtbl) { + fn AddConnection( + extconn: DWORD, + reserved: DWORD, + ) -> DWORD, + fn ReleaseConnection( + extconn: DWORD, + reserved: DWORD, + fLastReleaseCloses: BOOL, + ) -> DWORD, +}} +pub type LPMULTIQI = *mut IMultiQI; +STRUCT!{struct MULTI_QI { + pIID: *const IID, + pItf: *mut IUnknown, + hr: HRESULT, +}} +RIDL!{#[uuid(0x00000020, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IMultiQI(IMultiQIVtbl): IUnknown(IUnknownVtbl) { + fn QueryMultipleInterfaces( + cMQIs: ULONG, + pMQIs: *mut MULTI_QI, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x000e0020, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface AsyncIMultiQI(AsyncIMultiQIVtbl): IUnknown(IUnknownVtbl) { + fn Begin_QueryMultipleInterfaces( + cMQIs: ULONG, + pMQIs: *mut MULTI_QI, + ) -> HRESULT, + fn Finish_QueryMultipleInterfaces( + pMQIs: *mut MULTI_QI, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000021, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IInternalUnknown(IInternalUnknownVtbl): IUnknown(IUnknownVtbl) { + fn QueryInternalInterface( + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000100, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumUnknown(IEnumUnknownVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut *mut IUnknown, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000101, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumString(IEnumStringVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut LPOLESTR, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumString, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0c733a30, 0x2a1c, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d)] +interface ISequentialStream(ISequentialStreamVtbl): IUnknown(IUnknownVtbl) { + fn Read( + pv: *mut c_void, + cb: ULONG, + pcbRead: *mut ULONG, + ) -> HRESULT, + fn Write( + pv: *const c_void, + cb: ULONG, + pcbWritten: *mut ULONG, + ) -> HRESULT, +}} +STRUCT!{struct STATSTG { + pwcsName: LPOLESTR, + type_: DWORD, + cbSize: ULARGE_INTEGER, + mtime: FILETIME, + ctime: FILETIME, + atime: FILETIME, + grfMode: DWORD, + grfLocksSupported: DWORD, + clsid: CLSID, + grfStateBits: DWORD, + reserved: DWORD, +}} +ENUM!{enum STGTY { + STGTY_STORAGE = 1, + STGTY_STREAM = 2, + STGTY_LOCKBYTES = 3, + STGTY_PROPERTY = 4, +}} +ENUM!{enum STREAM_SEEK { + STREAM_SEEK_SET = 0, + STREAM_SEEK_CUR = 1, + STREAM_SEEK_END = 2, +}} +ENUM!{enum LOCKTYPE { + LOCK_WRITE = 1, + LOCK_EXCLUSIVE = 2, + LOCK_ONLYONCE = 4, +}} +pub type LPSTREAM = *mut IStream; +RIDL!{#[uuid(0x0000000c, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IStream(IStreamVtbl): ISequentialStream(ISequentialStreamVtbl) { + fn Seek( + dlibMove: LARGE_INTEGER, + dwOrigin: DWORD, + plibNewPosition: *mut ULARGE_INTEGER, + ) -> HRESULT, + fn SetSize( + libNewSize: ULARGE_INTEGER, + ) -> HRESULT, + fn CopyTo( + pstm: *mut IStream, + cb: ULARGE_INTEGER, + pcbRead: *mut ULARGE_INTEGER, + pcbWritten: *mut ULARGE_INTEGER, + ) -> HRESULT, + fn Commit( + grfCommitFlags: DWORD, + ) -> HRESULT, + fn Revert() -> HRESULT, + fn LockRegion( + libOffset: ULARGE_INTEGER, + cb: ULARGE_INTEGER, + dwLockType: DWORD, + ) -> HRESULT, + fn UnlockRegion( + libOffset: ULARGE_INTEGER, + cb: ULARGE_INTEGER, + dwLockType: DWORD, + ) -> HRESULT, + fn Stat( + pstatstg: *mut STATSTG, + grfStatFlag: DWORD, + ) -> HRESULT, + fn Clone( + ppstm: *mut *mut IStream, + ) -> HRESULT, +}} +pub type RPCOLEDATAREP = ULONG; +STRUCT!{struct RPCOLEMESSAGE { + reserved1: *mut c_void, + dataRepresentation: RPCOLEDATAREP, + Buffer: *mut c_void, + cbBuffer: ULONG, + iMethod: ULONG, + reserved2: [*mut c_void; 5], + rpcFlags: ULONG, +}} +pub type PRPCOLEMESSAGE = *mut RPCOLEMESSAGE; +RIDL!{#[uuid(0xd5f56b60, 0x593b, 0x101a, 0xb5, 0x69, 0x08, 0x00, 0x2b, 0x2d, 0xbf, 0x7a)] +interface IRpcChannelBuffer(IRpcChannelBufferVtbl): IUnknown(IUnknownVtbl) { + fn GetBuffer( + pMessage: *mut RPCOLEMESSAGE, + riid: REFIID, + ) -> HRESULT, + fn SendReceive( + pMessage: *mut RPCOLEMESSAGE, + pStatus: *mut ULONG, + ) -> HRESULT, + fn FreeBuffer( + pMessage: *mut RPCOLEMESSAGE, + ) -> HRESULT, + fn GetDestCtx( + pdwDestContext: *mut DWORD, + ppvDestContext: *mut *mut c_void, + ) -> HRESULT, + fn IsConnected() -> HRESULT, +}} +RIDL!{#[uuid(0x594f31d0, 0x7f19, 0x11d0, 0xb1, 0x94, 0x00, 0xa0, 0xc9, 0x0d, 0xc8, 0xbf)] +interface IRpcChannelBuffer2(IRpcChannelBuffer2Vtbl): IRpcChannelBuffer(IRpcChannelBufferVtbl) { + fn GetProtocolVersion( + pdwVersion: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa5029fb6, 0x3c34, 0x11d1, 0x9c, 0x99, 0x00, 0xc0, 0x4f, 0xb9, 0x98, 0xaa)] +interface IAsyncRpcChannelBuffer(IAsyncRpcChannelBufferVtbl): + IRpcChannelBuffer2(IRpcChannelBuffer2Vtbl) { + fn Send( + pMsg: *mut RPCOLEMESSAGE, + pSync: *mut ISynchronize, + pulStatus: *mut ULONG, + ) -> HRESULT, + fn Receive( + pMsg: *mut RPCOLEMESSAGE, + pulStatus: *mut ULONG, + ) -> HRESULT, + fn GetDestCtxEx( + pMsg: *mut RPCOLEMESSAGE, + pdwDestContext: *mut DWORD, + ppvDestContext: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x25b15600, 0x0115, 0x11d0, 0xbf, 0x0d, 0x00, 0xaa, 0x00, 0xb8, 0xdf, 0xd2)] +interface IRpcChannelBuffer3(IRpcChannelBuffer3Vtbl): IRpcChannelBuffer2(IRpcChannelBuffer2Vtbl) { + fn Send( + pMsg: *mut RPCOLEMESSAGE, + pulStatus: *mut ULONG, + ) -> HRESULT, + fn Receive( + pMsg: *mut RPCOLEMESSAGE, + ulSize: ULONG, + pulStatus: *mut ULONG, + ) -> HRESULT, + fn Cancel( + pMsg: *mut RPCOLEMESSAGE, + ) -> HRESULT, + fn GetCallContext( + pMsg: *mut RPCOLEMESSAGE, + riid: REFIID, + pInterface: *mut *mut c_void, + ) -> HRESULT, + fn GetDestCtxEx( + pMsg: *mut RPCOLEMESSAGE, + pdwDestContext: *mut DWORD, + ppvDestContext: *mut *mut c_void, + ) -> HRESULT, + fn GetState( + pMsg: *mut RPCOLEMESSAGE, + pState: *mut DWORD, + ) -> HRESULT, + fn RegisterAsync( + pMsg: *mut RPCOLEMESSAGE, + pAsyncMgr: *mut IAsyncManager, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x58a08519, 0x24c8, 0x4935, 0xb4, 0x82, 0x3f, 0xd8, 0x23, 0x33, 0x3a, 0x4f)] +interface IRpcSyntaxNegotiate(IRpcSyntaxNegotiateVtbl): IUnknown(IUnknownVtbl) { + fn NegotiateSyntax( + pMsg: *mut RPCOLEMESSAGE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd5f56a34, 0x593b, 0x101a, 0xb5, 0x69, 0x08, 0x00, 0x2b, 0x2d, 0xbf, 0x7a)] +interface IRpcProxyBuffer(IRpcProxyBufferVtbl): IUnknown(IUnknownVtbl) { + fn Connect( + pRpcChannelBuffer: *mut IRpcChannelBuffer, + ) -> HRESULT, + fn Disconnect() -> (), +}} +RIDL!{#[uuid(0xd5f56afc, 0x593b, 0x101a, 0xb5, 0x69, 0x08, 0x00, 0x2b, 0x2d, 0xbf, 0x7a)] +interface IRpcStubBuffer(IRpcStubBufferVtbl): IUnknown(IUnknownVtbl) { + fn Connect( + pUnkServer: *mut IUnknown, + ) -> HRESULT, + fn Disconnect() -> (), + fn Invoke( + _prpcmsg: *mut RPCOLEMESSAGE, + _pRpcChannelBuffer: *mut IRpcChannelBuffer, + ) -> HRESULT, + fn IsIIDSupported( + riid: REFIID, + ) -> *mut IRpcStubBuffer, + fn CountRefs() -> ULONG, + fn DebugServerQueryInterface( + ppv: *mut *mut c_void, + ) -> HRESULT, + fn DebugServerRelease( + pv: *mut c_void, + ) -> (), +}} +RIDL!{#[uuid(0xd5f569d0, 0x593b, 0x101a, 0xb5, 0x69, 0x08, 0x00, 0x2b, 0x2d, 0xbf, 0x7a)] +interface IPSFactoryBuffer(IPSFactoryBufferVtbl): IUnknown(IUnknownVtbl) { + fn CreateProxy( + pUnkOuter: *mut IUnknown, + riid: REFIID, + ppProxy: *mut *mut IRpcProxyBuffer, + ppv: *mut *mut c_void, + ) -> HRESULT, + fn CreateStub( + riid: REFIID, + pUnkServer: *mut *mut IUnknown, + ppStub: *mut *mut IRpcStubBuffer, + ) -> HRESULT, +}} +STRUCT!{struct SChannelHookCallInfo { + iid: IID, + cbSize: DWORD, + uCausality: GUID, + dwServerPid: DWORD, + iMethod: DWORD, + pObject: *mut c_void, +}} +RIDL!{#[uuid(0x1008c4a0, 0x7613, 0x11cf, 0x9a, 0xf1, 0x00, 0x20, 0xaf, 0x6e, 0x72, 0xf4)] +interface IChannelHook(IChannelHookVtbl): IUnknown(IUnknownVtbl) { + fn ClientGetSize( + uExtent: REFGUID, + riid: REFIID, + pDataSize: *mut ULONG, + ) -> (), + fn ClientFillBuffer( + uExtent: REFGUID, + riid: REFIID, + pDataSize: *mut ULONG, + pDataBuffer: *mut c_void, + ) -> (), + fn ClientNotify( + uExtent: REFGUID, + riid: REFIID, + cbDataSize: ULONG, + pDataBuffer: *mut c_void, + lDataRep: DWORD, + hrFault: HRESULT, + ) -> (), + fn ServerNotify( + uExtent: REFGUID, + riid: REFIID, + cbDataSize: ULONG, + pDataBuffer: *mut c_void, + lDataRep: DWORD, + ) -> (), + fn ServerGetSize( + uExtent: REFGUID, + riid: REFIID, + hrFault: HRESULT, + pDataSize: *mut ULONG, + ) -> (), + fn ServerFillBuffer( + uExtent: REFGUID, + riid: REFIID, + pDataSize: *mut ULONG, + pDataBuffer: *mut c_void, + hrFault: HRESULT, + ) -> (), +}} +STRUCT!{struct SOLE_AUTHENTICATION_SERVICE { + dwAuthnSvc: DWORD, + dwAuthzSvc: DWORD, + pPrincipalName: *mut OLECHAR, + hr: HRESULT, +}} +pub type PSOLE_AUTHENTICATION_SERVICE = *mut SOLE_AUTHENTICATION_SERVICE; +ENUM!{enum EOLE_AUTHENTICATION_CAPABILITIES { + EOAC_NONE = 0, + EOAC_MUTUAL_AUTH = 0x1, + EOAC_STATIC_CLOAKING = 0x20, + EOAC_DYNAMIC_CLOAKING = 0x40, + EOAC_ANY_AUTHORITY = 0x80, + EOAC_MAKE_FULLSIC = 0x100, + EOAC_DEFAULT = 0x800, + EOAC_SECURE_REFS = 0x2, + EOAC_ACCESS_CONTROL = 0x4, + EOAC_APPID = 0x8, + EOAC_DYNAMIC = 0x10, + EOAC_REQUIRE_FULLSIC = 0x200, + EOAC_AUTO_IMPERSONATE = 0x400, + EOAC_DISABLE_AAA = 0x1000, + EOAC_NO_CUSTOM_MARSHAL = 0x2000, + EOAC_RESERVED1 = 0x4000, +}} +pub const COLE_DEFAULT_PRINCIPAL: *mut OLECHAR = -1isize as *mut OLECHAR; +pub const COLE_DEFAULT_AUTHINFO: *mut c_void = -1isize as *mut c_void; +STRUCT!{struct SOLE_AUTHENTICATION_INFO { + dwAuthnSvc: DWORD, + dwAuthzSvc: DWORD, + pAuthInfo: *mut c_void, +}} +pub type PSOLE_AUTHENTICATION_INFO = *mut SOLE_AUTHENTICATION_INFO; +STRUCT!{struct SOLE_AUTHENTICATION_LIST { + cAuthInfo: DWORD, + aAuthInfo: *mut SOLE_AUTHENTICATION_INFO, +}} +pub type PSOLE_AUTHENTICATION_LIST = *mut SOLE_AUTHENTICATION_LIST; +RIDL!{#[uuid(0x0000013d, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IClientSecurity(IClientSecurityVtbl): IUnknown(IUnknownVtbl) { + fn QueryBlanket( + pProxy: *mut IUnknown, + pAuthnSvc: *mut DWORD, + pAuthzSvc: *mut DWORD, + pServerPrincName: *mut *mut OLECHAR, + pAuthnLevel: *mut DWORD, + pImpLevel: *mut DWORD, + pAuthInfo: *mut *mut c_void, + pCapabilities: *mut DWORD, + ) -> HRESULT, + fn SetBlanket( + pProxy: *mut IUnknown, + dwAuthnSvc: DWORD, + dwAuthzSvc: DWORD, + pServerPrincName: *mut OLECHAR, + dwAuthnLevel: DWORD, + dwImpLevel: DWORD, + pAuthInfo: *mut c_void, + dwCapabilities: DWORD, + ) -> HRESULT, + fn CopyProxy( + pProxy: *mut IUnknown, + ppCopy: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0000013e, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IServerSecurity(IServerSecurityVtbl): IUnknown(IUnknownVtbl) { + fn QueryBlanket( + pAuthnSvc: *mut DWORD, + pAuthzSvc: *mut DWORD, + pServerPrincName: *mut *mut OLECHAR, + pAuthnLevel: *mut DWORD, + pImpLevel: *mut DWORD, + pPrivs: *mut *mut c_void, + pCapabilities: *mut DWORD, + ) -> HRESULT, + fn ImpersonateClient() -> HRESULT, + fn RevertToSelf() -> HRESULT, + fn IsImpersonating() -> BOOL, +}} +ENUM!{enum RPCOPT_PROPERTIES { + COMBND_RPCTIMEOUT = 0x1, + COMBND_SERVER_LOCALITY = 0x2, + COMBND_RESERVED1 = 0x4, + COMBND_RESERVED2 = 0x5, + COMBND_RESERVED3 = 0x8, + COMBND_RESERVED4 = 0x10, +}} +ENUM!{enum RPCOPT_SERVER_LOCALITY_VALUES { + SERVER_LOCALITY_PROCESS_LOCAL = 0, + SERVER_LOCALITY_MACHINE_LOCAL = 1, + SERVER_LOCALITY_REMOTE = 2, +}} +RIDL!{#[uuid(0x00000144, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IRpcOptions(IRpcOptionsVtbl): IUnknown(IUnknownVtbl) { + fn Set( + pPrx: *mut IUnknown, + dwProperty: RPCOPT_PROPERTIES, + dwValue: ULONG_PTR, + ) -> HRESULT, + fn Query( + pPrx: *mut IUnknown, + dwProperty: RPCOPT_PROPERTIES, + pdwValue: *mut ULONG_PTR, + ) -> HRESULT, +}} +ENUM!{enum GLOBALOPT_PROPERTIES { + COMGLB_EXCEPTION_HANDLING = 1, + COMGLB_APPID = 2, + COMGLB_RPC_THREADPOOL_SETTING = 3, + COMGLB_RO_SETTINGS = 4, + COMGLB_UNMARSHALING_POLICY = 5, + COMGLB_PROPERTIES_RESERVED1 = 6, +}} +ENUM!{enum GLOBALOPT_EH_VALUES { + COMGLB_EXCEPTION_HANDLE = 0, + COMGLB_EXCEPTION_DONOT_HANDLE_FATAL = 1, + COMGLB_EXCEPTION_DONOT_HANDLE = COMGLB_EXCEPTION_DONOT_HANDLE_FATAL, + COMGLB_EXCEPTION_DONOT_HANDLE_ANY = 2, +}} +ENUM!{enum GLOBALOPT_RPCTP_VALUES { + COMGLB_RPC_THREADPOOL_SETTING_DEFAULT_POOL = 0, + COMGLB_RPC_THREADPOOL_SETTING_PRIVATE_POOL = 1, +}} +ENUM!{enum GLOBALOPT_RO_FLAGS { + COMGLB_STA_MODALLOOP_REMOVE_TOUCH_MESSAGES = 0x1, + COMGLB_STA_MODALLOOP_SHARED_QUEUE_REMOVE_INPUT_MESSAGES = 0x2, + COMGLB_STA_MODALLOOP_SHARED_QUEUE_DONOT_REMOVE_INPUT_MESSAGES = 0x4, + COMGLB_FAST_RUNDOWN = 0x8, + COMGLB_RESERVED1 = 0x10, + COMGLB_RESERVED2 = 0x20, + COMGLB_RESERVED3 = 0x40, + COMGLB_STA_MODALLOOP_SHARED_QUEUE_REORDER_POINTER_MESSAGES = 0x80, + COMGLB_RESERVED4 = 0x100, + COMGLB_RESERVED5 = 0x200, + COMGLB_RESERVED6 = 0x400, +}} +ENUM!{enum GLOBALOPT_UNMARSHALING_POLICY_VALUES { + COMGLB_UNMARSHALING_POLICY_NORMAL = 0, + COMGLB_UNMARSHALING_POLICY_STRONG = 1, + COMGLB_UNMARSHALING_POLICY_HYBRID = 2, +}} +RIDL!{#[uuid(0x0000015b, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IGlobalOptions(IGlobalOptionsVtbl): IUnknown(IUnknownVtbl) { + fn Set( + dwProperty: GLOBALOPT_PROPERTIES, + dwValue: ULONG_PTR, + ) -> HRESULT, + fn Query( + dwProperty: GLOBALOPT_PROPERTIES, + pdwValue: *mut ULONG_PTR, + ) -> HRESULT, +}} +pub type LPSURROGATE = *mut ISurrogate; +RIDL!{#[uuid(0x00000022, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ISurrogate(ISurrogateVtbl): IUnknown(IUnknownVtbl) { + fn LoadDllServer( + Clsid: REFCLSID, + ) -> HRESULT, + fn FreeSurrogate() -> HRESULT, +}} +pub type LPGLOBALINTERFACETABLE = *mut IGlobalInterfaceTable; +RIDL!{#[uuid(0x00000146, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IGlobalInterfaceTable(IGlobalInterfaceTableVtbl): IUnknown(IUnknownVtbl) { + fn RegisterInterfaceInGlobal( + pUnk: *mut IUnknown, + riid: REFIID, + pdwCookie: *mut DWORD, + ) -> HRESULT, + fn RevokeInterfaceFromGlobal( + dwCookie: DWORD, + ) -> HRESULT, + fn GetInterfaceFromGlobal( + dwCookie: DWORD, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000030, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ISynchronize(ISynchronizeVtbl): IUnknown(IUnknownVtbl) { + fn Wait( + dwFlags: DWORD, + dwMilliseconds: DWORD, + ) -> HRESULT, + fn Signal() -> HRESULT, + fn Reset() -> HRESULT, +}} +RIDL!{#[uuid(0x00000031, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ISynchronizeHandle(ISynchronizeHandleVtbl): IUnknown(IUnknownVtbl) { + fn GetHandle( + ph: *mut HANDLE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000032, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ISynchronizeEvent(ISynchronizeEventVtbl): ISynchronizeHandle(ISynchronizeHandleVtbl) { + fn SetEventHandle( + ph: *mut HANDLE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000033, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ISynchronizeContainer(ISynchronizeContainerVtbl): IUnknown(IUnknownVtbl) { + fn AddSynchronize( + pSync: *mut ISynchronize, + ) -> HRESULT, + fn WaitMultiple( + dwFlags: DWORD, + dwTimeOut: DWORD, + ppSync: *mut *mut ISynchronize, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000025, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ISynchronizeMutex(ISynchronizeMutexVtbl): ISynchronize(ISynchronizeVtbl) { + fn ReleaseMutex() -> HRESULT, +}} +pub type LPCANCELMETHODCALLS = *mut ICancelMethodCalls; +RIDL!{#[uuid(0x00000029, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface ICancelMethodCalls(ICancelMethodCallsVtbl): IUnknown(IUnknownVtbl) { + fn Cancel( + ulSeconds: ULONG, + ) -> HRESULT, + fn TestCancel() -> HRESULT, +}} +ENUM!{enum DCOM_CALL_STATE { + DCOM_NONE = 0, + DCOM_CALL_COMPLETE = 0x1, + DCOM_CALL_CANCELED = 0x2, +}} +RIDL!{#[uuid(0x0000002a, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IAsyncManager(IAsyncManagerVtbl): IUnknown(IUnknownVtbl) { + fn CompleteCall( + Result: HRESULT, + ) -> HRESULT, + fn GetCallContext( + riid: REFIID, + pInterface: *mut *mut c_void, + ) -> HRESULT, + fn GetState( + pulStateFlags: *mut ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1c733a30, 0x2a1c, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d)] +interface ICallFactory(ICallFactoryVtbl): IUnknown(IUnknownVtbl) { + fn CreateCall( + riid: REFIID, + pCtrlUnk: *mut IUnknown, + riid2: REFIID, + ppv: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000149, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IRpcHelper(IRpcHelperVtbl): IUnknown(IUnknownVtbl) { + fn GetDCOMProtocolVersion( + pComVersion: *mut DWORD, + ) -> HRESULT, + fn GetIIDFromOBJREF( + pObjRef: *mut c_void, + piid: *mut *mut IID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xeb0cb9e8, 0x7996, 0x11d2, 0x87, 0x2e, 0x00, 0x00, 0xf8, 0x08, 0x08, 0x59)] +interface IReleaseMarshalBuffers(IReleaseMarshalBuffersVtbl): IUnknown(IUnknownVtbl) { + fn ReleaseMarshalBuffer( + pMsg: *mut RPCOLEMESSAGE, + dwFlags: DWORD, + pChnl: *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0000002b, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IWaitMultiple(IWaitMultipleVtbl): IUnknown(IUnknownVtbl) { + fn WaitMultiple( + timeout: DWORD, + pSync: *mut *mut ISynchronize, + ) -> HRESULT, + fn AddSynchronize( + pSync: *mut ISynchronize, + ) -> HRESULT, +}} +pub type LPADDRTRACKINGCONTROL = *mut IAddrTrackingControl; +RIDL!{#[uuid(0x00000147, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IAddrTrackingControl(IAddrTrackingControlVtbl): IUnknown(IUnknownVtbl) { + fn EnableCOMDynamicAddrTracking() -> HRESULT, + fn DisableCOMDynamicAddrTracking() -> HRESULT, +}} +pub type LPADDREXCLUSIONCONTROL = *mut IAddrExclusionControl; +RIDL!{#[uuid(0x00000148, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IAddrExclusionControl(IAddrExclusionControlVtbl): IUnknown(IUnknownVtbl) { + fn GetCurrentAddrExclusionList( + riid: REFIID, + ppEnumerator: *mut *mut c_void, + ) -> HRESULT, + fn UpdateAddrExclusionList( + pEnumerator: *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdb2f3aca, 0x2f86, 0x11d1, 0x8e, 0x04, 0x00, 0xc0, 0x4f, 0xb9, 0x98, 0x9a)] +interface IPipeByte(IPipeByteVtbl): IUnknown(IUnknownVtbl) { + fn Pull( + buf: *mut BYTE, + cRequest: ULONG, + pcReturned: *mut ULONG, + ) -> HRESULT, + fn Push( + buf: *mut BYTE, + cSent: ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdb2f3acb, 0x2f86, 0x11d1, 0x8e, 0x04, 0x00, 0xc0, 0x4f, 0xb9, 0x98, 0x9a)] +interface AsyncIPipeByte(AsyncIPipeByteVtbl): IUnknown(IUnknownVtbl) { + fn Begin_Pull( + cRequest: ULONG, + ) -> HRESULT, + fn Finish_Pull( + buf: *mut BYTE, + pcReturned: *mut ULONG, + ) -> HRESULT, + fn Begin_Push( + buf: *mut BYTE, + cSent: ULONG, + ) -> HRESULT, + fn Finish_Push() -> HRESULT, +}} +RIDL!{#[uuid(0xdb2f3acc, 0x2f86, 0x11d1, 0x8e, 0x04, 0x00, 0xc0, 0x4f, 0xb9, 0x98, 0x9a)] +interface IPipeLong(IPipeLongVtbl): IUnknown(IUnknownVtbl) { + fn Pull( + buf: *mut LONG, + cRequest: ULONG, + pcReturned: *mut ULONG, + ) -> HRESULT, + fn Push( + buf: *mut LONG, + cSent: ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdb2f3acd, 0x2f86, 0x11d1, 0x8e, 0x04, 0x00, 0xc0, 0x4f, 0xb9, 0x98, 0x9a)] +interface AsyncIPipeLong(AsyncIPipeLongVtbl): IUnknown(IUnknownVtbl) { + fn Begin_Pull( + cRequest: ULONG, + ) -> HRESULT, + fn Finish_Pull( + buf: *mut LONG, + pcReturned: *mut ULONG, + ) -> HRESULT, + fn Begin_Push( + buf: *mut LONG, + cSent: ULONG, + ) -> HRESULT, + fn Finish_Push() -> HRESULT, +}} +RIDL!{#[uuid(0xdb2f3ace, 0x2f86, 0x11d1, 0x8e, 0x04, 0x00, 0xc0, 0x4f, 0xb9, 0x98, 0x9a)] +interface IPipeDouble(IPipeDoubleVtbl): IUnknown(IUnknownVtbl) { + fn Pull( + buf: *mut DOUBLE, + cRequest: ULONG, + pcReturned: *mut ULONG, + ) -> HRESULT, + fn Push( + buf: *mut DOUBLE, + cSent: ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdb2f3acf, 0x2f86, 0x11d1, 0x8e, 0x04, 0x00, 0xc0, 0x4f, 0xb9, 0x98, 0x9a)] +interface AsyncIPipeDouble(AsyncIPipeDoubleVtbl): IUnknown(IUnknownVtbl) { + fn Begin_Pull( + cRequest: ULONG, + ) -> HRESULT, + fn Finish_Pull( + buf: *mut DOUBLE, + pcReturned: *mut ULONG, + ) -> HRESULT, + fn Begin_Push( + buf: *mut DOUBLE, + cSent: ULONG, + ) -> HRESULT, + fn Finish_Push() -> HRESULT, +}} +pub type CPFLAGS = DWORD; +STRUCT!{struct ContextProperty { + policyId: GUID, + flags: CPFLAGS, + pUnk: *mut IUnknown, +}} +pub type LPENUMCONTEXTPROPS = *mut IEnumContextProps; +RIDL!{#[uuid(0x000001c1, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumContextProps(IEnumContextPropsVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + pContextProperties: *mut ContextProperty, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppEnumContextProps: *mut *mut IEnumContextProps, + ) -> HRESULT, + fn Count( + pcelt: *mut ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x000001c0, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IContext(IContextVtbl): IUnknown(IUnknownVtbl) { + fn SetProperty( + rpolicyId: REFGUID, + flags: CPFLAGS, + pUnk: *mut IUnknown, + ) -> HRESULT, + fn RemoveProperty( + rPolicyId: REFGUID, + ) -> HRESULT, + fn GetProperty( + policyId: REFGUID, + pFlags: *mut CPFLAGS, + ppUnk: *mut *mut IUnknown, + ) -> HRESULT, + fn EnumContextProps( + ppEnumContextProps: *mut *mut IEnumContextProps, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x000001c6, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IObjContext(IObjContextVtbl): IContext(IContextVtbl) { + fn Reserved1() -> (), + fn Reserved2() -> (), + fn Reserved3() -> (), + fn Reserved4() -> (), + fn Reserved5() -> (), + fn Reserved6() -> (), + fn Reserved7() -> (), +}} +ENUM!{enum APTTYPEQUALIFIER { + APTTYPEQUALIFIER_NONE = 0, + APTTYPEQUALIFIER_IMPLICIT_MTA = 1, + APTTYPEQUALIFIER_NA_ON_MTA = 2, + APTTYPEQUALIFIER_NA_ON_STA = 3, + APTTYPEQUALIFIER_NA_ON_IMPLICIT_MTA = 4, + APTTYPEQUALIFIER_NA_ON_MAINSTA = 5, + APTTYPEQUALIFIER_APPLICATION_STA= 6, +}} +ENUM!{enum APTTYPE { + APTTYPE_CURRENT = -1i32 as u32, + APTTYPE_STA = 0, + APTTYPE_MTA = 1, + APTTYPE_NA = 2, + APTTYPE_MAINSTA = 3, +}} +ENUM!{enum THDTYPE { + THDTYPE_BLOCKMESSAGES = 0, + THDTYPE_PROCESSMESSAGES = 1, +}} +pub type APARTMENTID = DWORD; +RIDL!{#[uuid(0x000001ce, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IComThreadingInfo(IComThreadingInfoVtbl): IUnknown(IUnknownVtbl) { + fn GetCurrentApartmentType( + pAptType: *mut APTTYPE, + ) -> HRESULT, + fn GetCurrentThreadType( + pThreadType: *mut THDTYPE, + ) -> HRESULT, + fn GetCurrentLogicalThreadId( + pguidLogicalThreadId: *mut GUID, + ) -> HRESULT, + fn SetCurrentLogicalThreadId( + rguid: REFGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x72380d55, 0x8d2b, 0x43a3, 0x85, 0x13, 0x2b, 0x6e, 0xf3, 0x14, 0x34, 0xe9)] +interface IProcessInitControl(IProcessInitControlVtbl): IUnknown(IUnknownVtbl) { + fn ResetInitializerTimeout( + dwSecondsRemaining: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000040, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IFastRundown(IFastRundownVtbl): IUnknown(IUnknownVtbl) {}} +ENUM!{enum CO_MARSHALING_CONTEXT_ATTRIBUTES { + CO_MARSHALING_SOURCE_IS_APP_CONTAINER = 0, + CO_MARSHALING_CONTEXT_ATTRIBUTE_RESERVED_1 = 0x80000000, + CO_MARSHALING_CONTEXT_ATTRIBUTE_RESERVED_2 = 0x80000001, + CO_MARSHALING_CONTEXT_ATTRIBUTE_RESERVED_3 = 0x80000002, + CO_MARSHALING_CONTEXT_ATTRIBUTE_RESERVED_4 = 0x80000003, + CO_MARSHALING_CONTEXT_ATTRIBUTE_RESERVED_5 = 0x80000004, + CO_MARSHALING_CONTEXT_ATTRIBUTE_RESERVED_6 = 0x80000005, + CO_MARSHALING_CONTEXT_ATTRIBUTE_RESERVED_7 = 0x80000006, + CO_MARSHALING_CONTEXT_ATTRIBUTE_RESERVED_8 = 0x80000007, + CO_MARSHALING_CONTEXT_ATTRIBUTE_RESERVED_9 = 0x80000008, +}} +RIDL!{#[uuid(0xd8f2f5e6, 0x6102, 0x4863, 0x9f, 0x26, 0x38, 0x9a, 0x46, 0x76, 0xef, 0xde)] +interface IMarshalingStream(IMarshalingStreamVtbl): IStream(IStreamVtbl) { + fn GetMarshalingContextAttribute( + attribute: CO_MARSHALING_CONTEXT_ATTRIBUTES, + pAttributeValue: *mut ULONG_PTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc03f6a43, 0x65a4, 0x9818, 0x98, 0x7e, 0xe0, 0xb8, 0x10, 0xd2, 0xa6, 0xf2)] +interface IAgileReference(IAgileReferenceVtbl): IUnknown(IUnknownVtbl) { + fn Resolve( + riid: REFIID, + ppvObjectReference: *mut *mut c_void, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ocidl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ocidl.rs new file mode 100644 index 0000000..07ec0d4 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ocidl.rs @@ -0,0 +1,68 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +// TODO:It is a minimal implementation. +use shared::guiddef::CLSID; +use shared::minwindef::{DWORD, ULONG}; +use shared::ntdef::HRESULT; +use shared::wtypes::{CLIPFORMAT, VARTYPE}; +use shared::wtypesbase::{LPCOLESTR, LPOLESTR}; +use um::oaidl::{IErrorLog, VARIANT}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +ENUM!{enum READYSTATE { + READYSTATE_UNINITIALIZED = 0, + READYSTATE_LOADING = 1, + READYSTATE_LOADED = 2, + READYSTATE_INTERACTIVE = 3, + READYSTATE_COMPLETE = 4, +}} +ENUM!{enum PROPBAG2_TYPE { + PROPBAG2_TYPE_UNDEFINED = 0, + PROPBAG2_TYPE_DATA = 1, + PROPBAG2_TYPE_URL = 2, + PROPBAG2_TYPE_OBJECT = 3, + PROPBAG2_TYPE_STREAM = 4, + PROPBAG2_TYPE_STORAGE = 5, + PROPBAG2_TYPE_MONIKER = 6, +}} +STRUCT!{struct PROPBAG2 { + dwType: DWORD, + vt: VARTYPE, + cfType: CLIPFORMAT, + dwHint: DWORD, + pstrName: LPOLESTR, + clsid: CLSID, +}} +RIDL!{#[uuid(0x22f55882, 0x280b, 0x11d0, 0xa8, 0xa9, 0x00, 0xa0, 0xc9, 0x0c, 0x20, 0x04)] +interface IPropertyBag2(IPropertyBag2Vtbl): IUnknown(IUnknownVtbl) { + fn Read( + cProperties: ULONG, + pPropBag: *const PROPBAG2, + pErrLog: *const IErrorLog, + pvarValue: *mut VARIANT, + phrError: *mut HRESULT, + ) -> HRESULT, + fn Write( + cProperties: ULONG, + pPropBag: *const PROPBAG2, + pvarValue: *const VARIANT, + ) -> HRESULT, + fn CountProperties( + pcProperties: *mut ULONG, + ) -> HRESULT, + fn GetPropertyInfo( + iProperty: ULONG, + cProperties: ULONG, + pPropBag: *mut PROPBAG2, + pcProperties: *mut ULONG, + ) -> HRESULT, + fn LoadObject( + pstrName: LPCOLESTR, + dwHint: DWORD, + pUnkObject: *const IUnknown, + pErrLog: *const IErrorLog, + ) -> HRESULT, +}} +pub type LPPROPERTYBAG2 = *mut IPropertyBag2; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ole2.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ole2.rs new file mode 100644 index 0000000..66c1689 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ole2.rs @@ -0,0 +1,21 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::LPVOID; +use shared::windef::HWND; +use um::oleidl::LPDROPTARGET; +use um::winnt::HRESULT; +extern "system" { + pub fn OleInitialize( + pvReserved: LPVOID, + ) -> HRESULT; + pub fn RegisterDragDrop( + hwnd: HWND, + pDropTarget: LPDROPTARGET, + ) -> HRESULT; + pub fn RevokeDragDrop( + hwnd: HWND, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/oleauto.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/oleauto.rs new file mode 100644 index 0000000..7d4edba --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/oleauto.rs @@ -0,0 +1,836 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of OleAuto.h +use ctypes::{c_double, c_float, c_int, c_uint, c_void}; +use shared::basetsd::{LONG64, ULONG64}; +use shared::minwindef::{BYTE, DWORD, FLOAT, UINT, ULONG, USHORT, WORD}; +use shared::wtypes::{BSTR, DATE, DECIMAL, LPBSTR, LPDECIMAL, VARTYPE}; +use shared::wtypesbase::{DOUBLE, LPCOLESTR, LPOLESTR, OLECHAR}; +use um::minwinbase::LPSYSTEMTIME; +use um::oaidl::{DISPID_UNKNOWN, ITypeLib, SAFEARRAY, VARIANT, VARIANTARG}; +use um::winnt::{CHAR, HRESULT, INT, LCID, LONG, LPCSTR, SHORT}; +extern "system" { + pub fn SysAllocString( + psz: *const OLECHAR, + ) -> BSTR; + pub fn SysReAllocString( + pbstr: *mut BSTR, + psz: *const OLECHAR, + ) -> INT; + pub fn SysAllocStringLen( + strIn: *const OLECHAR, + ui: UINT, + ) -> BSTR; + pub fn SysReAllocStringLen( + pbstr: *mut BSTR, + psz: *const OLECHAR, + len: c_uint, + ) -> INT; + pub fn SysFreeString( + bstrString: BSTR, + ); + pub fn SysStringLen( + pbstr: BSTR, + ) -> UINT; + pub fn SysStringByteLen( + bstr: BSTR, + ) -> UINT; + pub fn SysAllocStringByteLen( + psz: LPCSTR, + len: UINT, + ) -> BSTR; + pub fn DosDateTimeToVariantTime( + wDosDate: USHORT, + wDosTime: USHORT, + pvtime: *mut DOUBLE, + ) -> INT; + pub fn VariantTimeToDosDateTime( + vtime: DOUBLE, + pwDosDate: *mut USHORT, + pwDosTime: *mut USHORT, + ) -> INT; + pub fn SystemTimeToVariantTime( + lpSystemTime: LPSYSTEMTIME, + pvtime: *mut DOUBLE, + ) -> INT; + pub fn VariantTimeToSystemTime( + vtime: DOUBLE, + lpSystemTime: LPSYSTEMTIME, + ) -> INT; + pub fn SafeArrayAccessData( + psa: *mut SAFEARRAY, + ppvData: *mut *mut c_void, + ) -> HRESULT; + pub fn SafeArrayUnaccessData( + psa: *mut SAFEARRAY, + ) -> HRESULT; + pub fn SafeArrayCreateVector( + vt: VARTYPE, + lLbound: LONG, + cElements: ULONG, + ) -> *mut SAFEARRAY; + pub fn SafeArrayGetLBound( + psa: *mut SAFEARRAY, + nDim: UINT, + plLbound: *mut LONG + ) -> HRESULT; + pub fn SafeArrayGetUBound( + psa: *mut SAFEARRAY, + nDim: UINT, + plUbound: *mut LONG + ) -> HRESULT; + pub fn SafeArrayDestroy( + psa: *mut SAFEARRAY + ) -> HRESULT; + pub fn VariantInit( + pvarg: *mut VARIANTARG, + ); + pub fn VariantClear( + pvarg: *mut VARIANTARG, + ) -> HRESULT; + pub fn VariantCopy( + pvargDest: *mut VARIANTARG, + pvargSrc: *const VARIANTARG, + ) -> HRESULT; + pub fn VariantCopyInd( + pvarDest: *mut VARIANT, + pvargSrc: *const VARIANTARG, + ) -> HRESULT; + pub fn VariantChangeType( + pvargDest: *mut VARIANTARG, + pvarSrc: *const VARIANTARG, + wFlags: USHORT, + vt: VARTYPE, + ) -> HRESULT; + pub fn VariantChangeTypeEx( + pvargDest: *mut VARIANTARG, + pvarSrc: *const VARIANTARG, + lcid: LCID, + wFlags: USHORT, + vt: VARTYPE, + ) -> HRESULT; + pub fn VarUI1FromI2( + sIn: SHORT, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromI4( + lIn: LONG, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromI8( + i64In: LONG64, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromR4( + fltIn: FLOAT, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromR8( + dblIn: DOUBLE, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromDate( + dateIn: DATE, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromI1( + cIn: CHAR, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromUI2( + uiIn: USHORT, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromUI4( + ulIn: ULONG, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromUI8( + ui64In: ULONG64, + pbOut: *mut BYTE, + ); + pub fn VarUI1FromDec( + pdecIn: *const DECIMAL, + pbOut: *mut BYTE, + ); + pub fn VarI2FromUI1( + bIn: BYTE, + psOut: *mut SHORT, + ); + pub fn VarI2FromI4( + lIn: LONG, + psOut: *mut SHORT, + ); + pub fn VarI2FromI8( + i64In: LONG64, + psOut: *mut SHORT, + ); + pub fn VarI2FromR4( + fltIn: FLOAT, + psOut: *mut SHORT, + ); + pub fn VarI2FromR8( + dblIn: DOUBLE, + psOut: *mut SHORT, + ); + pub fn VarI2FromDate( + dateIn: DATE, + psOut: *mut SHORT, + ); + pub fn VarI2FromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + psOut: *mut SHORT, + ); + pub fn VarI2FromI1( + cIn: CHAR, + psOut: *mut SHORT, + ); + pub fn VarI2FromUI2( + uiIn: USHORT, + psOut: *mut SHORT, + ); + pub fn VarI2FromUI4( + ulIn: ULONG, + psOut: *mut SHORT, + ); + pub fn VarI2FromUI8( + ui64In: ULONG64, + psOut: *mut SHORT, + ); + pub fn VarI2FromDec( + pdecIn: *const DECIMAL, + psOut: *mut SHORT, + ); + pub fn VarI4FromUI1( + bIn: BYTE, + plOut: *mut LONG, + ); + pub fn VarI4FromI2( + sIn: SHORT, + plOut: *mut LONG, + ); + pub fn VarI4FromI8( + i64In: LONG64, + plOut: *mut LONG, + ); + pub fn VarI4FromR4( + fltIn: FLOAT, + plOut: *mut LONG, + ); + pub fn VarI4FromR8( + dblIn: DOUBLE, + plOut: *mut LONG, + ); + pub fn VarI4FromDate( + dateIn: DATE, + plOut: *mut LONG, + ); + pub fn VarI4FromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + plOut: *mut LONG, + ); + pub fn VarI4FromI1( + cIn: CHAR, + plOut: *mut LONG, + ); + pub fn VarI4FromUI2( + uiIn: USHORT, + plOut: *mut LONG, + ); + pub fn VarI4FromUI4( + ulIn: ULONG, + plOut: *mut LONG, + ); + pub fn VarI4FromUI8( + ui64In: ULONG64, + plOut: *mut LONG, + ); + pub fn VarI4FromDec( + pdecIn: *const DECIMAL, + plOut: *mut LONG, + ); + pub fn VarI8FromUI1( + bIn: BYTE, + pi64Out: *mut LONG64, + ); + pub fn VarI8FromI2( + sIn: SHORT, + pi64Out: *mut LONG64, + ); + pub fn VarI8FromR4( + fltIn: FLOAT, + pi64Out: *mut LONG64, + ); + pub fn VarI8FromR8( + dblIn: DOUBLE, + pi64Out: *mut LONG64, + ); + pub fn VarI8FromDate( + dateIn: DATE, + pi64Out: *mut LONG64, + ); + pub fn VarI8FromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + pi64Out: *mut LONG64, + ); + pub fn VarI8FromI1( + cIn: CHAR, + pi64Out: *mut LONG64, + ); + pub fn VarI8FromUI2( + uiIn: USHORT, + pi64Out: *mut LONG64, + ); + pub fn VarI8FromUI4( + ulIn: ULONG, + pi64Out: *mut LONG64, + ); + pub fn VarI8FromUI8( + ui64In: ULONG64, + pi64Out: *mut LONG64, + ); + pub fn VarI8FromDec( + pdecIn: *const DECIMAL, + pi64Out: *mut LONG64, + ); + pub fn VarR4FromUI1( + bIn: BYTE, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromI2( + sIn: SHORT, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromI4( + lIn: LONG, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromI8( + i64In: LONG64, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromR8( + dblIn: DOUBLE, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromDate( + dateIn: DATE, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromI1( + cIn: CHAR, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromUI2( + uiIn: USHORT, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromUI4( + ulIn: ULONG, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromUI8( + ui64In: ULONG64, + pfltOut: *mut FLOAT, + ); + pub fn VarR4FromDec( + pdecIn: *const DECIMAL, + pfltOut: *mut FLOAT, + ); + pub fn VarR8FromUI1( + bIn: BYTE, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromI2( + sIn: SHORT, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromI4( + lIn: LONG, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromI8( + i64In: LONG64, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromR4( + fltIn: FLOAT, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromDate( + dateIn: DATE, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromI1( + cIn: CHAR, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromUI2( + uiIn: USHORT, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromUI4( + ulIn: ULONG, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromUI8( + ui64In: ULONG64, + pdblOut: *mut DOUBLE, + ); + pub fn VarR8FromDec( + pdecIn: *const DECIMAL, + pdblOut: *mut DOUBLE, + ); + pub fn VarDateFromUI1( + bIn: BYTE, + pdateOut: *mut DATE, + ); + pub fn VarDateFromI2( + sIn: SHORT, + pdateOut: *mut DATE, + ); + pub fn VarDateFromI4( + lIn: LONG, + pdateOut: *mut DATE, + ); + pub fn VarDateFromI8( + i64In: LONG64, + pdateOut: *mut DATE, + ); + pub fn VarDateFromR4( + fltIn: FLOAT, + pdateOut: *mut DATE, + ); + pub fn VarDateFromR8( + dblIn: DOUBLE, + pdateOut: *mut DATE, + ); + pub fn VarDateFromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + pdateOut: *mut DATE, + ); + pub fn VarDateFromI1( + cIn: CHAR, + pdateOut: *mut DATE, + ); + pub fn VarDateFromUI2( + uiIn: USHORT, + pdateOut: *mut DATE, + ); + pub fn VarDateFromUI4( + ulIn: ULONG, + pdateOut: *mut DATE, + ); + pub fn VarDateFromUI8( + ui64In: ULONG64, + pdateOut: *mut DATE, + ); + pub fn VarDateFromDec( + pdecIn: *const DECIMAL, + pdateOut: *mut DATE, + ); + pub fn VarBstrFromUI1( + bVal: BYTE, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromI2( + iVal: SHORT, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromI4( + lIn: LONG, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromI8( + i64In: LONG64, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromR4( + fltIn: FLOAT, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromR8( + dblIn: DOUBLE, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromDate( + dateIn: DATE, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromI1( + cIn: CHAR, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromUI2( + uiIn: USHORT, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromUI4( + ulIn: ULONG, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromUI8( + ui64In: ULONG64, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarBstrFromDec( + pdecIn: *const DECIMAL, + lcid: LCID, + dwFlags: ULONG, + pbstrOut: *mut BSTR, + ); + pub fn VarUI2FromUI1( + bIn: BYTE, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromI2( + uiIn: SHORT, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromI4( + lIn: LONG, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromI8( + i64In: LONG64, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromR4( + fltIn: FLOAT, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromR8( + dblIn: DOUBLE, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromDate( + dateIn: DATE, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromI1( + cIn: CHAR, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromUI4( + ulIn: ULONG, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromUI8( + i64In: ULONG64, + puiOut: *mut USHORT, + ); + pub fn VarUI2FromDec( + pdecIn: *const DECIMAL, + puiOut: *mut USHORT, + ); + pub fn VarUI4FromUI1( + bIn: BYTE, + pulOut: *mut ULONG, + ); + pub fn VarUI4FromI2( + uiIn: SHORT, + pulOut: *mut ULONG, + ); + pub fn VarUI4FromI4( + lIn: LONG, + pulOut: *mut ULONG, + ); + pub fn VarUI4FromI8( + i64In: LONG64, + plOut: *mut ULONG, + ); + pub fn VarUI4FromR4( + fltIn: FLOAT, + pulOut: *mut ULONG, + ); + pub fn VarUI4FromR8( + dblIn: DOUBLE, + pulOut: *mut ULONG, + ); + pub fn VarUI4FromDate( + dateIn: DATE, + pulOut: *mut ULONG, + ); + pub fn VarUI4FromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + pulOut: *mut ULONG, + ); + pub fn VarUI4FromI1( + cIn: CHAR, + pulOut: *mut ULONG, + ); + pub fn VarUI4FromUI2( + uiIn: USHORT, + pulOut: *mut ULONG, + ); + pub fn VarUI4FromUI8( + ui64In: ULONG64, + plOut: *mut ULONG, + ); + pub fn VarUI4FromDec( + pdecIn: *const DECIMAL, + pulOut: *mut ULONG, + ); + pub fn VarUI8FromUI1( + bIn: BYTE, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromI2( + sIn: SHORT, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromI4( + lIn: LONG, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromI8( + ui64In: LONG64, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromR4( + fltIn: FLOAT, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromR8( + dblIn: DOUBLE, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromDate( + dateIn: DATE, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromI1( + cIn: CHAR, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromUI2( + uiIn: USHORT, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromUI4( + ulIn: ULONG, + pi64Out: *mut ULONG64, + ); + pub fn VarUI8FromDec( + pdecIn: *const DECIMAL, + pi64Out: *mut ULONG64, + ); + pub fn VarDecFromUI1( + bIn: BYTE, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromI2( + uiIn: SHORT, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromI4( + lIn: LONG, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromI8( + i64In: LONG64, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromR4( + fltIn: FLOAT, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromR8( + dblIn: DOUBLE, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromDate( + dateIn: DATE, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromStr( + strIn: LPCOLESTR, + lcid: LCID, + dwFlags: ULONG, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromI1( + cIn: CHAR, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromUI2( + uiIn: USHORT, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromUI4( + ulIn: ULONG, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecFromUI8( + ui64In: ULONG64, + pdecOut: *mut DECIMAL, + ); + pub fn VarDecAdd( + pdecLeft: LPDECIMAL, + pdecRight: LPDECIMAL, + pdecResult: LPDECIMAL, + ); + pub fn VarDecDiv( + pdecLeft: LPDECIMAL, + pdecRight: LPDECIMAL, + pdecResult: LPDECIMAL, + ); + pub fn VarDecMul( + pdecLeft: LPDECIMAL, + pdecRight: LPDECIMAL, + pdecResult: LPDECIMAL, + ); + pub fn VarDecSub( + pdecLeft: LPDECIMAL, + pdecRight: LPDECIMAL, + pdecResult: LPDECIMAL, + ); + pub fn VarDecAbs( + pdecIn: LPDECIMAL, + pdecResult: LPDECIMAL, + ); + pub fn VarDecFix( + pdecIn: LPDECIMAL, + pdecResult: LPDECIMAL, + ); + pub fn VarDecInt( + pdecIn: LPDECIMAL, + pdecResult: LPDECIMAL, + ); + pub fn VarDecNeg( + pdecIn: LPDECIMAL, + pdecResult: LPDECIMAL, + ); + pub fn VarDecRound( + pdecIn: LPDECIMAL, + cDecimals: c_int, + pdecResult: LPDECIMAL, + ); + pub fn VarDecCmp( + pdecLeft: LPDECIMAL, + pdecRight: LPDECIMAL, + ); + pub fn VarDecCmpR8( + pdecLeft: LPDECIMAL, + dblRight: c_double, + ); + pub fn VarBstrCat( + bstrLeft: BSTR, + bstrRight: BSTR, + pbstrResult: LPBSTR, + ); + pub fn VarBstrCmp( + bstrLeft: BSTR, + bstrRight: BSTR, + lcid: LCID, + dwFlags: ULONG, + ); + pub fn VarR8Pow( + dblLeft: c_double, + dblRight: c_double, + pdblResult: *mut c_double, + ); + pub fn VarR4CmpR8( + fltLeft: c_float, + dblRight: c_double, + ); + pub fn VarR8Round( + dblIn: c_double, + cDecimals: c_int, + pdblResult: *mut c_double, + ); + pub fn GetAltMonthNames( + lcid: LCID, + prgp: *mut LPOLESTR, + ); +} +pub type DISPID = LONG; +pub type MEMBERID = DISPID; +pub const MEMBERID_NIL: MEMBERID = DISPID_UNKNOWN; +pub const DISPATCH_METHOD: WORD = 0x1; +pub const DISPATCH_PROPERTYGET: WORD = 0x2; +pub const DISPATCH_PROPERTYPUT: WORD = 0x4; +pub const DISPATCH_PROPERTYPUTREF: WORD = 0x8; +ENUM!{enum REGKIND { + REGKIND_DEFAULT = 0, + REGKIND_REGISTER, + REGKIND_NONE, +}} +extern "system" { + pub fn LoadTypeLibEx( + szFile: LPCOLESTR, + regkind: REGKIND, + pptlib: *mut *mut ITypeLib, + ) -> HRESULT; + pub fn RevokeActiveObject( + dwRegister: DWORD, + pvReserved: *mut c_void, + ); + pub fn OaBuildVersion() -> ULONG; + pub fn OaEnablePerUserTLibRegistration(); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/olectl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/olectl.rs new file mode 100644 index 0000000..4a9ccdf --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/olectl.rs @@ -0,0 +1,14 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! OLE Control interfaces +use shared::winerror::{FACILITY_ITF, SEVERITY_ERROR, SEVERITY_SUCCESS}; +use um::winnt::HRESULT; +pub const SELFREG_E_FIRST: HRESULT = MAKE_SCODE!(SEVERITY_ERROR, FACILITY_ITF, 0x0200); +pub const SELFREG_E_LAST: HRESULT = MAKE_SCODE!(SEVERITY_ERROR, FACILITY_ITF, 0x020F); +pub const SELFREG_S_FIRST: HRESULT = MAKE_SCODE!(SEVERITY_SUCCESS, FACILITY_ITF, 0x0200); +pub const SELFREG_S_LAST: HRESULT = MAKE_SCODE!(SEVERITY_SUCCESS, FACILITY_ITF, 0x020F); +pub const SELFREG_E_TYPELIB: HRESULT = SELFREG_E_FIRST + 0; +pub const SELFREG_E_CLASS: HRESULT = SELFREG_E_FIRST + 1; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/oleidl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/oleidl.rs new file mode 100644 index 0000000..39b8c30 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/oleidl.rs @@ -0,0 +1,43 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::DWORD; +use shared::ntdef::HRESULT; +use shared::windef::POINTL; +use um::objidl::IDataObject; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +pub const MK_ALT: DWORD = 20; +pub const DROPEFFECT_NONE: DWORD = 0; +pub const DROPEFFECT_COPY: DWORD = 1; +pub const DROPEFFECT_MOVE: DWORD = 2; +pub const DROPEFFECT_LINK: DWORD = 4; +pub const DROPEFFECT_SCROLL: DWORD = 0x80000000; +pub const DD_DEFSCROLLINSET: DWORD = 11; +pub const DD_DEFSCROLLDELAY: DWORD = 50; +pub const DD_DEFSCROLLINTERVAL: DWORD = 50; +pub const DD_DEFDRAGDELAY: DWORD = 200; +pub const DD_DEFDRAGMINDIST: DWORD = 2; +pub type LPDROPTARGET = *mut IDropTarget; +RIDL!{#[uuid(0x00000122, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IDropTarget(IDropTargetVtbl): IUnknown(IUnknownVtbl) { + fn DragEnter( + pDataObj: *const IDataObject, + grfKeyState: DWORD, + pt: *const POINTL, + pdwEffect: *mut DWORD, + ) -> HRESULT, + fn DragOver( + grfKeyState: DWORD, + pt: *const POINTL, + pdwEffect: *mut DWORD, + ) -> HRESULT, + fn DragLeave() -> HRESULT, + fn Drop( + pDataObj: *const IDataObject, + grfKeyState: DWORD, + pt: *const POINTL, + pdwEffect: *mut DWORD, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/opmapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/opmapi.rs new file mode 100644 index 0000000..a8e5de8 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/opmapi.rs @@ -0,0 +1,362 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::UINT64; +use shared::d3d9::IDirect3DDevice9; +use shared::d3d9types::D3DFORMAT; +use shared::guiddef::GUID; +use shared::minwindef::{BYTE, DWORD, ULONG}; +use shared::windef::HMONITOR; +use um::dxva2api::DXVA2_SampleFormat; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LUID}; +DEFINE_GUID!{OPM_GET_CURRENT_HDCP_SRM_VERSION, + 0x99c5ceff, 0x5f1d, 0x4879, 0x81, 0xc1, 0xc5, 0x24, 0x43, 0xc9, 0x48, 0x2b} +DEFINE_GUID!{OPM_GET_CONNECTED_HDCP_DEVICE_INFORMATION, + 0x0db59d74, 0xa992, 0x492e, 0xa0, 0xbd, 0xc2, 0x3f, 0xda, 0x56, 0x4e, 0x00} +DEFINE_GUID!{OPM_GET_ACP_AND_CGMSA_SIGNALING, + 0x6629a591, 0x3b79, 0x4cf3, 0x92, 0x4a, 0x11, 0xe8, 0xe7, 0x81, 0x16, 0x71} +DEFINE_GUID!{OPM_GET_CONNECTOR_TYPE, + 0x81d0bfd5, 0x6afe, 0x48c2, 0x99, 0xc0, 0x95, 0xa0, 0x8f, 0x97, 0xc5, 0xda} +DEFINE_GUID!{OPM_GET_SUPPORTED_PROTECTION_TYPES, + 0x38f2a801, 0x9a6c, 0x48bb, 0x91, 0x07, 0xb6, 0x69, 0x6e, 0x6f, 0x17, 0x97} +DEFINE_GUID!{OPM_GET_VIRTUAL_PROTECTION_LEVEL, + 0xb2075857, 0x3eda, 0x4d5d, 0x88, 0xdb, 0x74, 0x8f, 0x8c, 0x1a, 0x05, 0x49} +DEFINE_GUID!{OPM_GET_ACTUAL_PROTECTION_LEVEL, + 0x1957210a, 0x7766, 0x452a, 0xb9, 0x9a, 0xd2, 0x7a, 0xed, 0x54, 0xf0, 0x3a} +DEFINE_GUID!{OPM_GET_ACTUAL_OUTPUT_FORMAT, + 0xd7bf1ba3, 0xad13, 0x4f8e, 0xaf, 0x98, 0x0d, 0xcb, 0x3c, 0xa2, 0x04, 0xcc} +DEFINE_GUID!{OPM_GET_ADAPTER_BUS_TYPE, + 0xc6f4d673, 0x6174, 0x4184, 0x8e, 0x35, 0xf6, 0xdb, 0x52, 0x0, 0xbc, 0xba} +DEFINE_GUID!{OPM_GET_OUTPUT_ID, + 0x72cb6df3, 0x244f, 0x40ce, 0xb0, 0x9e, 0x20, 0x50, 0x6a, 0xf6, 0x30, 0x2f} +DEFINE_GUID!{OPM_GET_DVI_CHARACTERISTICS, + 0xa470b3bb, 0x5dd7, 0x4172, 0x83, 0x9c, 0x3d, 0x37, 0x76, 0xe0, 0xeb, 0xf5} +DEFINE_GUID!{OPM_GET_CODEC_INFO, + 0x4f374491, 0x8f5f, 0x4445, 0x9d, 0xba, 0x95, 0x58, 0x8f, 0x6b, 0x58, 0xb4} +DEFINE_GUID!{OPM_GET_OUTPUT_HARDWARE_PROTECTION_SUPPORT, + 0x3b129589, 0x2af8, 0x4ef0, 0x96, 0xa2, 0x70, 0x4a, 0x84, 0x5a, 0x21, 0x8e} +DEFINE_GUID!{OPM_SET_PROTECTION_LEVEL, + 0x9bb9327c, 0x4eb5, 0x4727, 0x9f, 0x00, 0xb4, 0x2b, 0x09, 0x19, 0xc0, 0xda} +DEFINE_GUID!{OPM_SET_ACP_AND_CGMSA_SIGNALING, + 0x09a631a5, 0xd684, 0x4c60, 0x8e, 0x4d, 0xd3, 0xbb, 0x0f, 0x0b, 0xe3, 0xee} +DEFINE_GUID!{OPM_SET_HDCP_SRM, + 0x8b5ef5d1, 0xc30d, 0x44ff, 0x84, 0xa5, 0xea, 0x71, 0xdc, 0xe7, 0x8f, 0x13} +DEFINE_GUID!{OPM_SET_PROTECTION_LEVEL_ACCORDING_TO_CSS_DVD, + 0x39ce333e, 0x4cc0, 0x44ae, 0xbf, 0xcc, 0xda, 0x50, 0xb5, 0xf8, 0x2e, 0x72} +ENUM!{enum __MIDL___MIDL_itf_opmapi_0000_0000_0001 { + OPM_OMAC_SIZE = 16, + OPM_128_BIT_RANDOM_NUMBER_SIZE = 16, + OPM_ENCRYPTED_INITIALIZATION_PARAMETERS_SIZE = 256, + OPM_CONFIGURE_SETTING_DATA_SIZE = 4056, + OPM_GET_INFORMATION_PARAMETERS_SIZE = 4056, + OPM_REQUESTED_INFORMATION_SIZE = 4076, + OPM_HDCP_KEY_SELECTION_VECTOR_SIZE = 5, + OPM_PROTECTION_TYPE_SIZE = 4, + OPM_BUS_TYPE_MASK = 0xffff, + OPM_BUS_IMPLEMENTATION_MODIFIER_MASK = 0x7fff, +}} +ENUM!{enum OPM_VIDEO_OUTPUT_SEMANTICS { + OPM_VOS_COPP_SEMANTICS = 0, + OPM_VOS_OPM_SEMANTICS = 1, + OPM_VOS_OPM_INDIRECT_DISPLAY = 2, +}} +ENUM!{enum __MIDL___MIDL_itf_opmapi_0000_0000_0002 { + OPM_HDCP_FLAG_NONE = 0, + OPM_HDCP_FLAG_REPEATER = 0x1, +}} +ENUM!{enum __MIDL___MIDL_itf_opmapi_0000_0000_0003 { + OPM_STATUS_NORMAL = 0, + OPM_STATUS_LINK_LOST = 0x1, + OPM_STATUS_RENEGOTIATION_REQUIRED = 0x2, + OPM_STATUS_TAMPERING_DETECTED = 0x4, + OPM_STATUS_REVOKED_HDCP_DEVICE_ATTACHED = 0x8, +}} +ENUM!{enum __MIDL___MIDL_itf_opmapi_0000_0000_0004 { + OPM_CONNECTOR_TYPE_OTHER = -1i32 as u32, + OPM_CONNECTOR_TYPE_VGA = 0, + OPM_CONNECTOR_TYPE_SVIDEO = 1, + OPM_CONNECTOR_TYPE_COMPOSITE_VIDEO = 2, + OPM_CONNECTOR_TYPE_COMPONENT_VIDEO = 3, + OPM_CONNECTOR_TYPE_DVI = 4, + OPM_CONNECTOR_TYPE_HDMI = 5, + OPM_CONNECTOR_TYPE_LVDS = 6, + OPM_CONNECTOR_TYPE_D_JPN = 8, + OPM_CONNECTOR_TYPE_SDI = 9, + OPM_CONNECTOR_TYPE_DISPLAYPORT_EXTERNAL = 10, + OPM_CONNECTOR_TYPE_DISPLAYPORT_EMBEDDED = 11, + OPM_CONNECTOR_TYPE_UDI_EXTERNAL = 12, + OPM_CONNECTOR_TYPE_UDI_EMBEDDED = 13, + OPM_CONNECTOR_TYPE_RESERVED = 14, + OPM_CONNECTOR_TYPE_MIRACAST = 15, + OPM_CONNECTOR_TYPE_TRANSPORT_AGNOSTIC_DIGITAL_MODE_A = 16, + OPM_CONNECTOR_TYPE_TRANSPORT_AGNOSTIC_DIGITAL_MODE_B = 17, + OPM_COPP_COMPATIBLE_CONNECTOR_TYPE_INTERNAL = 0x80000000, +}} +ENUM!{enum __MIDL___MIDL_itf_opmapi_0000_0000_0005 { + OPM_DVI_CHARACTERISTIC_1_0 = 1, + OPM_DVI_CHARACTERISTIC_1_1_OR_ABOVE = 2, +}} +ENUM!{enum OPM_OUTPUT_HARDWARE_PROTECTION { + OPM_OUTPUT_HARDWARE_PROTECTION_NOT_SUPPORTED = 0, + OPM_OUTPUT_HARDWARE_PROTECTION_SUPPORTED = 0x1, +}} +ENUM!{enum __MIDL___MIDL_itf_opmapi_0000_0000_0006 { + OPM_BUS_TYPE_OTHER = 0, + OPM_BUS_TYPE_PCI = 0x1, + OPM_BUS_TYPE_PCIX = 0x2, + OPM_BUS_TYPE_PCIEXPRESS = 0x3, + OPM_BUS_TYPE_AGP = 0x4, + OPM_BUS_IMPLEMENTATION_MODIFIER_INSIDE_OF_CHIPSET = 0x10000, + OPM_BUS_IMPLEMENTATION_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP = 0x20000, + OPM_BUS_IMPLEMENTATION_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x30000, + OPM_BUS_IMPLEMENTATION_MODIFIER_DAUGHTER_BOARD_CONNECTOR = 0x40000, + OPM_BUS_IMPLEMENTATION_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x50000, + OPM_BUS_IMPLEMENTATION_MODIFIER_NON_STANDARD = 0x80000000, + OPM_COPP_COMPATIBLE_BUS_TYPE_INTEGRATED = 0x80000000, +}} +ENUM!{enum OPM_DPCP_PROTECTION_LEVEL { + OPM_DPCP_OFF = 0, + OPM_DPCP_ON = 1, + OPM_DPCP_FORCE_ULONG = 0x7fffffff, +}} +ENUM!{enum OPM_HDCP_PROTECTION_LEVEL { + OPM_HDCP_OFF = 0, + OPM_HDCP_ON = 1, + OPM_HDCP_FORCE_ULONG = 0x7fffffff, +}} +ENUM!{enum OPM_TYPE_ENFORCEMENT_HDCP_PROTECTION_LEVEL { + OPM_TYPE_ENFORCEMENT_HDCP_OFF = OPM_HDCP_OFF, + OPM_TYPE_ENFORCEMENT_HDCP_ON_WITH_NO_TYPE_RESTRICTION = OPM_HDCP_ON, + OPM_TYPE_ENFORCEMENT_HDCP_ON_WITH_TYPE1_RESTRICTION = OPM_HDCP_ON + 1, + OPM_TYPE_ENFORCEMENT_HDCP_FORCE_ULONG = 0x7fffffff, +}} +ENUM!{enum __MIDL___MIDL_itf_opmapi_0000_0000_0007 { + OPM_CGMSA_OFF = 0, + OPM_CGMSA_COPY_FREELY = 0x1, + OPM_CGMSA_COPY_NO_MORE = 0x2, + OPM_CGMSA_COPY_ONE_GENERATION = 0x3, + OPM_CGMSA_COPY_NEVER = 0x4, + OPM_CGMSA_REDISTRIBUTION_CONTROL_REQUIRED = 0x8, +}} +ENUM!{enum OPM_ACP_PROTECTION_LEVEL { + OPM_ACP_OFF = 0, + OPM_ACP_LEVEL_ONE = 1, + OPM_ACP_LEVEL_TWO = 2, + OPM_ACP_LEVEL_THREE = 3, + OPM_ACP_FORCE_ULONG = 0x7fffffff, +}} +ENUM!{enum __MIDL___MIDL_itf_opmapi_0000_0000_0008 { + OPM_PROTECTION_TYPE_OTHER = 0x80000000, + OPM_PROTECTION_TYPE_NONE = 0, + OPM_PROTECTION_TYPE_COPP_COMPATIBLE_HDCP = 0x1, + OPM_PROTECTION_TYPE_ACP = 0x2, + OPM_PROTECTION_TYPE_CGMSA = 0x4, + OPM_PROTECTION_TYPE_HDCP = 0x8, + OPM_PROTECTION_TYPE_DPCP = 0x10, + OPM_PROTECTION_TYPE_TYPE_ENFORCEMENT_HDCP = 0x20, +}} +ENUM!{enum __MIDL___MIDL_itf_opmapi_0000_0000_0009 { + OPM_PROTECTION_STANDARD_OTHER = 0x80000000, + OPM_PROTECTION_STANDARD_NONE = 0, + OPM_PROTECTION_STANDARD_IEC61880_525I = 0x1, + OPM_PROTECTION_STANDARD_IEC61880_2_525I = 0x2, + OPM_PROTECTION_STANDARD_IEC62375_625P = 0x4, + OPM_PROTECTION_STANDARD_EIA608B_525 = 0x8, + OPM_PROTECTION_STANDARD_EN300294_625I = 0x10, + OPM_PROTECTION_STANDARD_CEA805A_TYPEA_525P = 0x20, + OPM_PROTECTION_STANDARD_CEA805A_TYPEA_750P = 0x40, + OPM_PROTECTION_STANDARD_CEA805A_TYPEA_1125I = 0x80, + OPM_PROTECTION_STANDARD_CEA805A_TYPEB_525P = 0x100, + OPM_PROTECTION_STANDARD_CEA805A_TYPEB_750P = 0x200, + OPM_PROTECTION_STANDARD_CEA805A_TYPEB_1125I = 0x400, + OPM_PROTECTION_STANDARD_ARIBTRB15_525I = 0x800, + OPM_PROTECTION_STANDARD_ARIBTRB15_525P = 0x1000, + OPM_PROTECTION_STANDARD_ARIBTRB15_750P = 0x2000, + OPM_PROTECTION_STANDARD_ARIBTRB15_1125I = 0x4000, +}} +ENUM!{enum OPM_IMAGE_ASPECT_RATIO_EN300294 { + OPM_ASPECT_RATIO_EN300294_FULL_FORMAT_4_BY_3 = 0, + OPM_ASPECT_RATIO_EN300294_BOX_14_BY_9_CENTER = 1, + OPM_ASPECT_RATIO_EN300294_BOX_14_BY_9_TOP = 2, + OPM_ASPECT_RATIO_EN300294_BOX_16_BY_9_CENTER = 3, + OPM_ASPECT_RATIO_EN300294_BOX_16_BY_9_TOP = 4, + OPM_ASPECT_RATIO_EN300294_BOX_GT_16_BY_9_CENTER = 5, + OPM_ASPECT_RATIO_EN300294_FULL_FORMAT_4_BY_3_PROTECTED_CENTER = 6, + OPM_ASPECT_RATIO_EN300294_FULL_FORMAT_16_BY_9_ANAMORPHIC = 7, + OPM_ASPECT_RATIO_FORCE_ULONG = 0x7fffffff, +}} +STRUCT!{#[repr(packed)] struct OPM_RANDOM_NUMBER { + abRandomNumber: [BYTE; 16], +}} +STRUCT!{#[repr(packed)] struct OPM_OMAC { + abOMAC: [BYTE; 16], +}} +STRUCT!{#[repr(packed)] struct OPM_ENCRYPTED_INITIALIZATION_PARAMETERS { + abEncryptedInitializationParameters: [BYTE; 256], +}} +STRUCT!{#[repr(packed)] struct OPM_GET_INFO_PARAMETERS { + omac: OPM_OMAC, + rnRandomNumber: OPM_RANDOM_NUMBER, + guidInformation: GUID, + ulSequenceNumber: ULONG, + cbParametersSize: ULONG, + abParameters: [BYTE; 4056], +}} +STRUCT!{#[repr(packed)] struct OPM_COPP_COMPATIBLE_GET_INFO_PARAMETERS { + rnRandomNumber: OPM_RANDOM_NUMBER, + guidInformation: GUID, + ulSequenceNumber: ULONG, + cbParametersSize: ULONG, + abParameters: [BYTE; 4056], +}} +STRUCT!{#[repr(packed)] struct OPM_HDCP_KEY_SELECTION_VECTOR { + abKeySelectionVector: [BYTE; 5], +}} +STRUCT!{#[repr(packed)] struct OPM_CONNECTED_HDCP_DEVICE_INFORMATION { + rnRandomNumber: OPM_RANDOM_NUMBER, + ulStatusFlags: ULONG, + ulHDCPFlags: ULONG, + ksvB: OPM_HDCP_KEY_SELECTION_VECTOR, + Reserved: [BYTE; 11], + Reserved2: [BYTE; 16], + Reserved3: [BYTE; 16], +}} +STRUCT!{#[repr(packed)] struct OPM_REQUESTED_INFORMATION { + omac: OPM_OMAC, + cbRequestedInformationSize: ULONG, + abRequestedInformation: [BYTE; 4076], +}} +STRUCT!{#[repr(packed)] struct OPM_STANDARD_INFORMATION { + rnRandomNumber: OPM_RANDOM_NUMBER, + ulStatusFlags: ULONG, + ulInformation: ULONG, + ulReserved: ULONG, + ulReserved2: ULONG, +}} +STRUCT!{#[repr(packed)] struct OPM_ACTUAL_OUTPUT_FORMAT { + rnRandomNumber: OPM_RANDOM_NUMBER, + ulStatusFlags: ULONG, + ulDisplayWidth: ULONG, + ulDisplayHeight: ULONG, + dsfSampleInterleaveFormat: DXVA2_SampleFormat, + d3dFormat: D3DFORMAT, + ulFrequencyNumerator: ULONG, + ulFrequencyDenominator: ULONG, +}} +STRUCT!{#[repr(packed)] struct OPM_ACP_AND_CGMSA_SIGNALING { + rnRandomNumber: OPM_RANDOM_NUMBER, + ulStatusFlags: ULONG, + ulAvailableTVProtectionStandards: ULONG, + ulActiveTVProtectionStandard: ULONG, + ulReserved: ULONG, + ulAspectRatioValidMask1: ULONG, + ulAspectRatioData1: ULONG, + ulAspectRatioValidMask2: ULONG, + ulAspectRatioData2: ULONG, + ulAspectRatioValidMask3: ULONG, + ulAspectRatioData3: ULONG, + ulReserved2: [ULONG; 4], + ulReserved3: [ULONG; 4], +}} +STRUCT!{#[repr(packed)] struct OPM_OUTPUT_ID_DATA { + rnRandomNumber: OPM_RANDOM_NUMBER, + ulStatusFlags: ULONG, + OutputId: UINT64, +}} +STRUCT!{#[repr(packed)] struct OPM_CONFIGURE_PARAMETERS { + omac: OPM_OMAC, + guidSetting: GUID, + ulSequenceNumber: ULONG, + cbParametersSize: ULONG, + abParameters: [BYTE; 4056], +}} +STRUCT!{#[repr(packed)] struct OPM_SET_PROTECTION_LEVEL_PARAMETERS { + ulProtectionType: ULONG, + ulProtectionLevel: ULONG, + Reserved: ULONG, + Reserved2: ULONG, +}} +STRUCT!{#[repr(packed)] struct OPM_SET_ACP_AND_CGMSA_SIGNALING_PARAMETERS { + ulNewTVProtectionStandard: ULONG, + ulAspectRatioChangeMask1: ULONG, + ulAspectRatioData1: ULONG, + ulAspectRatioChangeMask2: ULONG, + ulAspectRatioData2: ULONG, + ulAspectRatioChangeMask3: ULONG, + ulAspectRatioData3: ULONG, + ulReserved: [ULONG; 4], + ulReserved2: [ULONG; 4], + ulReserved3: ULONG, +}} +STRUCT!{#[repr(packed)] struct OPM_SET_HDCP_SRM_PARAMETERS { + ulSRMVersion: ULONG, +}} +STRUCT!{#[repr(packed)] struct OPM_GET_CODEC_INFO_PARAMETERS { + cbVerifier: DWORD, + Verifier: [BYTE; 4052], +}} +STRUCT!{#[repr(packed)] struct OPM_GET_CODEC_INFO_INFORMATION { + rnRandomNumber: OPM_RANDOM_NUMBER, + Merit: DWORD, +}} +DEFINE_GUID!{IID_IOPMVideoOutput, + 0x0a15159d, 0x41c7, 0x4456, 0x93, 0xe1, 0x28, 0x4c, 0xd6, 0x1d, 0x4e, 0x8d} +RIDL!{#[uuid(0x0a15159d, 0x41c7, 0x4456, 0x93, 0xe1, 0x28, 0x4c, 0xd6, 0x1d, 0x4e, 0x8d)] +interface IOPMVideoOutput(IOPMVideoOutputVtbl): IUnknown(IUnknownVtbl) { + fn StartInitialization( + prnRandomNumber: *mut OPM_RANDOM_NUMBER, + ppbCertificate: *mut *mut BYTE, + pulCertificateLength: *mut ULONG, + ) -> HRESULT, + fn FinishInitialization( + pParameters: *const OPM_ENCRYPTED_INITIALIZATION_PARAMETERS, + ) -> HRESULT, + fn GetInformation( + pParameters: *const OPM_GET_INFO_PARAMETERS, + pRequestedInformation: *mut OPM_REQUESTED_INFORMATION, + ) -> HRESULT, + fn COPPCompatibleGetInformation( + pParameters: *const OPM_COPP_COMPATIBLE_GET_INFO_PARAMETERS, + pRequestedInformation: *mut OPM_REQUESTED_INFORMATION, + ) -> HRESULT, + fn Configure( + pParameters: *const OPM_CONFIGURE_PARAMETERS, + ulAdditionalParametersSize: ULONG, + pbAdditionalParameters: *const BYTE, + ) -> HRESULT, +}} +#[inline] +pub fn GetBusType(ulBusTypeAndImplementation: ULONG) -> ULONG { + ulBusTypeAndImplementation & OPM_BUS_TYPE_MASK +} +#[inline] +pub fn GetBusImplementation(ulBusTypeAndImplementation: ULONG) -> ULONG { + (ulBusTypeAndImplementation & OPM_BUS_IMPLEMENTATION_MODIFIER_MASK) >> 16 +} +#[inline] +pub fn IsNonStandardBusImplementation(ulBusTypeAndImplementation: ULONG) -> ULONG { + ulBusTypeAndImplementation & OPM_BUS_IMPLEMENTATION_MODIFIER_NON_STANDARD +} +extern "system" { + pub fn OPMGetVideoOutputsFromHMONITOR( + hMonitor: HMONITOR, + vos: OPM_VIDEO_OUTPUT_SEMANTICS, + pulNumVideoOutputs: *mut ULONG, + pppOPMVideoOutputArray: *mut *mut *mut IOPMVideoOutput, + ) -> HRESULT; + pub fn OPMGetVideoOutputForTarget( + pAdapterLuid: *mut LUID, + VidPnTarget: ULONG, + vos: OPM_VIDEO_OUTPUT_SEMANTICS, + ppOPMVideoOutput: *mut *mut IOPMVideoOutput, + ) -> HRESULT; + pub fn OPMGetVideoOutputsFromIDirect3DDevice9Object( + pDirect3DDevice9: *mut IDirect3DDevice9, + vos: OPM_VIDEO_OUTPUT_SEMANTICS, + pulNumVideoOutputs: *mut ULONG, + pppOPMVideoOutputArray: *mut *mut *mut IOPMVideoOutput, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/pdh.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/pdh.rs new file mode 100644 index 0000000..9ef4ee7 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/pdh.rs @@ -0,0 +1,806 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Common Performance Data Helper definitions +use ctypes::c_double; +use shared::basetsd::DWORD_PTR; +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, DWORD, FILETIME, LPDWORD, UCHAR}; +use shared::windef::HWND; +use um::winnt::{BOOLEAN, HANDLE, LONG, LONGLONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR}; +pub const PDH_FMT_RAW: DWORD = 0x00000010; +pub const PDH_FMT_ANSI: DWORD = 0x00000020; +pub const PDH_FMT_UNICODE: DWORD = 0x00000040; +pub const PDH_FMT_LONG: DWORD = 0x00000100; +pub const PDH_FMT_DOUBLE: DWORD = 0x00000200; +pub const PDH_FMT_LARGE: DWORD = 0x00000400; +pub const PDH_FMT_NOSCALE: DWORD = 0x00001000; +pub const PDH_FMT_1000: DWORD = 0x00002000; +pub const PDH_FMT_NODATA: DWORD = 0x00004000; +pub const PDH_FMT_NOCAP100: DWORD = 0x00008000; +pub const PERF_DETAIL_COSTLY: DWORD = 0x00010000; +pub const PERF_DETAIL_STANDARD: DWORD = 0x0000FFFF; +pub type PDH_STATUS = LONG; +pub type PDH_HQUERY = HANDLE; +pub type HQUERY = PDH_HQUERY; +pub type PDH_HCOUNTER = HANDLE; +pub type HCOUNTER = PDH_HCOUNTER; +pub type PPDH_BROWSE_DLG_CONFIG_A = *mut PDH_BROWSE_DLG_CONFIG_A; +pub type PPDH_BROWSE_DLG_CONFIG_W = *mut PDH_BROWSE_DLG_CONFIG_W; +pub type PDH_HLOG = HANDLE; +pub type PPDH_RAW_LOG_RECORD = *mut PDH_RAW_LOG_RECORD; +pub type PPDH_TIME_INFO = *mut PDH_TIME_INFO; +pub type PPDH_RAW_COUNTER = *mut PDH_RAW_COUNTER; +pub type PPDH_COUNTER_INFO_A = *mut PDH_COUNTER_INFO_A; +pub type PPDH_COUNTER_INFO_W = *mut PDH_COUNTER_INFO_W; +pub type PPDH_STATISTICS = *mut PDH_STATISTICS; +pub type PPDH_FMT_COUNTERVALUE_ITEM_A = *mut PDH_FMT_COUNTERVALUE_ITEM_A; +pub type PPDH_FMT_COUNTERVALUE_ITEM_W = *mut PDH_FMT_COUNTERVALUE_ITEM_W; +pub type PPDH_DATA_ITEM_PATH_ELEMENTS_A = *mut PDH_DATA_ITEM_PATH_ELEMENTS_A; +pub type PPDH_DATA_ITEM_PATH_ELEMENTS_W = *mut PDH_DATA_ITEM_PATH_ELEMENTS_W; +pub type PPDH_FMT_COUNTERVALUE = *mut PDH_FMT_COUNTERVALUE; +FN!{stdcall CounterPathCallBack( + DWORD_PTR, +) -> PDH_STATUS} +pub type PPDH_COUNTER_PATH_ELEMENTS_A = *mut PDH_COUNTER_PATH_ELEMENTS_A; +pub type PPDH_COUNTER_PATH_ELEMENTS_W = *mut PDH_COUNTER_PATH_ELEMENTS_W; +pub type PPDH_BROWSE_DLG_CONFIG_HA = *mut PDH_BROWSE_DLG_CONFIG_HA; +pub type PPDH_BROWSE_DLG_CONFIG_HW = *mut PDH_BROWSE_DLG_CONFIG_HW; +UNION!{union PDH_FMT_COUNTERVALUE_u { + [u64; 1], + longValue longValue_mut: LONG, + doubleValue doubleValue_mut: c_double, + largeValue largeValue_mut: LONGLONG, + AnsiStringValue AnsiStringValue_mut: LPCSTR, + WideStringValue WideStringValue_mut: LPCWSTR, +}} +STRUCT!{struct PDH_FMT_COUNTERVALUE { + CStatus: DWORD, + u: PDH_FMT_COUNTERVALUE_u, +}} +STRUCT!{struct PDH_RAW_LOG_RECORD { + dwStructureSize: DWORD, + dwRecordType: DWORD, + dwItems: DWORD, + RawBytes: UCHAR, +}} +STRUCT!{struct PDH_TIME_INFO { + StartTime: LONGLONG, + EndTime: LONGLONG, + SampleCount: DWORD, +}} +STRUCT!{struct PDH_RAW_COUNTER { + CStatus: DWORD, + TimeStamp: FILETIME, + FirstValue: LONGLONG, + SecondValue: LONGLONG, + MultiCount: DWORD, +}} +STRUCT!{struct PDH_STATISTICS { + dwFormat: DWORD, + count: DWORD, + min: PDH_FMT_COUNTERVALUE, + max: PDH_FMT_COUNTERVALUE, + mean: PDH_FMT_COUNTERVALUE, +}} +STRUCT!{struct PDH_FMT_COUNTERVALUE_ITEM_A { + szName: LPSTR, + FmtValue: PDH_FMT_COUNTERVALUE, +}} +STRUCT!{struct PDH_FMT_COUNTERVALUE_ITEM_W { + szName: LPWSTR, + FmtValue: PDH_FMT_COUNTERVALUE, +}} +STRUCT!{struct PDH_BROWSE_DLG_CONFIG_A { + flags: DWORD, + hWndOwner: HWND, + szDataSource: LPSTR, + szReturnPathBuffer: LPSTR, + cchReturnPathLength: DWORD, + pCallBack: CounterPathCallBack, + dwCallBackArg: DWORD_PTR, + CallBackStatus: PDH_STATUS, + dwDefaultDetailLevel: DWORD, + szDialogBoxCaption: LPSTR, +}} +BITFIELD!{PDH_BROWSE_DLG_CONFIG_A flags: DWORD [ + IncludeInstanceIndex set_IncludeInstanceIndex[0..1], + SingleCounterPerAdd set_SingleCounterPerAdd[1..2], + SingleCounterPerDialog set_SingleCounterPerDialog[2..3], + LocalCountersOnly set_LocalCountersOnly[3..4], + WildCardInstances set_WildCardInstances[4..5], + HideDetailBox set_HideDetailBox[5..6], + InitializePath set_InitializePath[6..7], + DisableMachineSelection set_DisableMachineSelection[7..8], + IncludeCostlyObjects set_IncludeCostlyObjects[8..9], + ShowObjectBrowser set_ShowObjectBrowser[9..10], +]} +STRUCT!{struct PDH_BROWSE_DLG_CONFIG_W { + flags: DWORD, + hWndOwner: HWND, + szDataSource: LPWSTR, + szReturnPathBuffer: LPWSTR, + cchReturnPathLength: DWORD, + pCallBack: CounterPathCallBack, + dwCallBackArg: DWORD_PTR, + CallBackStatus: PDH_STATUS, + dwDefaultDetailLevel: DWORD, + szDialogBoxCaption: LPWSTR, +}} +BITFIELD!{PDH_BROWSE_DLG_CONFIG_W flags: DWORD [ + IncludeInstanceIndex set_IncludeInstanceIndex[0..1], + SingleCounterPerAdd set_SingleCounterPerAdd[1..2], + SingleCounterPerDialog set_SingleCounterPerDialog[2..3], + LocalCountersOnly set_LocalCountersOnly[3..4], + WildCardInstances set_WildCardInstances[4..5], + HideDetailBox set_HideDetailBox[5..6], + InitializePath set_InitializePath[6..7], + DisableMachineSelection set_DisableMachineSelection[7..8], + IncludeCostlyObjects set_IncludeCostlyObjects[8..9], + ShowObjectBrowser set_ShowObjectBrowser[9..10], +]} +STRUCT!{struct PDH_COUNTER_PATH_ELEMENTS_A { + szMachineName: LPSTR, + szObjectName: LPSTR, + szInstanceName: LPSTR, + szParentInstance: LPSTR, + dwInstanceIndex: DWORD, + szCounterName: LPSTR, +}} +STRUCT!{struct PDH_COUNTER_PATH_ELEMENTS_W { + szMachineName: LPWSTR, + szObjectName: LPWSTR, + szInstanceName: LPWSTR, + szParentInstance: LPWSTR, + dwInstanceIndex: DWORD, + szCounterName: LPWSTR, +}} +STRUCT!{struct PDH_DATA_ITEM_PATH_ELEMENTS_A { + szMachineName: LPSTR, + ObjectGUID: GUID, + dwItemId: DWORD, + szInstanceName: LPSTR, +}} +STRUCT!{struct PDH_DATA_ITEM_PATH_ELEMENTS_W { + szMachineName: LPWSTR, + ObjectGUID: GUID, + dwItemId: DWORD, + szInstanceName: LPWSTR, +}} +STRUCT!{struct PDH_COUNTER_INFO_A_u_s { + szMachineName: LPSTR, + szObjectName: LPSTR, + szInstanceName: LPSTR, + szParentInstance: LPSTR, + dwInstanceIndex: DWORD, + szCounterName: LPSTR, +}} +UNION!{union PDH_COUNTER_INFO_A_u { + [u32; 7] [u64; 6], + DataItemPath DataItemPath_mut: PDH_DATA_ITEM_PATH_ELEMENTS_A, + CounterPath CounterPath_mut: PDH_COUNTER_PATH_ELEMENTS_A, + s s_mut: PDH_COUNTER_INFO_A_u_s, +}} +STRUCT!{struct PDH_COUNTER_INFO_A { + dwLength: DWORD, + dwType: DWORD, + CVersion: DWORD, + CStatus: DWORD, + lScale: LONG, + lDefaultScale: LONG, + dwUserData: DWORD_PTR, + dwQueryUserData: DWORD_PTR, + szFullPath: LPSTR, + u: PDH_COUNTER_INFO_A_u, + szExplainText: LPSTR, + DataBuffer: [DWORD; 1], +}} +STRUCT!{struct PDH_COUNTER_INFO_W_u_s { + szMachineName: LPWSTR, + szObjectName: LPWSTR, + szInstanceName: LPWSTR, + szParentInstance: LPWSTR, + dwInstanceIndex: DWORD, + szCounterName: LPWSTR, +}} +UNION!{union PDH_COUNTER_INFO_W_u { + [u32; 7] [u64; 6], + DataItemPath DataItemPath_mut: PDH_DATA_ITEM_PATH_ELEMENTS_W, + CounterPath CounterPath_mut: PDH_COUNTER_PATH_ELEMENTS_W, + s s_mut: PDH_COUNTER_INFO_W_u_s, +}} +STRUCT!{struct PDH_COUNTER_INFO_W { + dwLength: DWORD, + dwType: DWORD, + CVersion: DWORD, + CStatus: DWORD, + lScale: LONG, + lDefaultScale: LONG, + dwUserData: DWORD_PTR, + dwQueryUserData: DWORD_PTR, + szFullPath: LPWSTR, + u: PDH_COUNTER_INFO_W_u, + szExplainText: LPWSTR, + DataBuffer: [DWORD; 1], +}} +STRUCT!{struct PDH_BROWSE_DLG_CONFIG_HA { + flags: DWORD, + hWndOwner: HWND, + hDataSource: PDH_HLOG, + szReturnPathBuffer: LPSTR, + cchReturnPathLength: DWORD, + pCallBack: CounterPathCallBack, + dwCallBackArg: DWORD_PTR, + CallBackStatus: PDH_STATUS, + dwDefaultDetailLevel: DWORD, + szDialogBoxCaption: LPSTR, +}} +BITFIELD!{PDH_BROWSE_DLG_CONFIG_HA flags: DWORD [ + IncludeInstanceIndex set_IncludeInstanceIndex[0..1], + SingleCounterPerAdd set_SingleCounterPerAdd[1..2], + SingleCounterPerDialog set_SingleCounterPerDialog[2..3], + LocalCountersOnly set_LocalCountersOnly[3..4], + WildCardInstances set_WildCardInstances[4..5], + HideDetailBox set_HideDetailBox[5..6], + InitializePath set_InitializePath[6..7], + DisableMachineSelection set_DisableMachineSelection[7..8], + IncludeCostlyObjects set_IncludeCostlyObjects[8..9], + ShowObjectBrowser set_ShowObjectBrowser[9..10], +]} +STRUCT!{struct PDH_BROWSE_DLG_CONFIG_HW { + flags: DWORD, + hWndOwner: HWND, + hDataSource: PDH_HLOG, + szReturnPathBuffer: LPWSTR, + cchReturnPathLength: DWORD, + pCallBack: CounterPathCallBack, + dwCallBackArg: DWORD_PTR, + CallBackStatus: PDH_STATUS, + dwDefaultDetailLevel: DWORD, + szDialogBoxCaption: LPWSTR, +}} +BITFIELD!{PDH_BROWSE_DLG_CONFIG_HW flags: DWORD [ + IncludeInstanceIndex set_IncludeInstanceIndex[0..1], + SingleCounterPerAdd set_SingleCounterPerAdd[1..2], + SingleCounterPerDialog set_SingleCounterPerDialog[2..3], + LocalCountersOnly set_LocalCountersOnly[3..4], + WildCardInstances set_WildCardInstances[4..5], + HideDetailBox set_HideDetailBox[5..6], + InitializePath set_InitializePath[6..7], + DisableMachineSelection set_DisableMachineSelection[7..8], + IncludeCostlyObjects set_IncludeCostlyObjects[8..9], + ShowObjectBrowser set_ShowObjectBrowser[9..10], +]} +extern "system" { + pub fn PdhGetDllVersion( + lpdwVersion: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhOpenQueryW( + szDataSource: LPCWSTR, + dwUserData: DWORD_PTR, + phQuery: *mut PDH_HQUERY, + ) -> PDH_STATUS; + pub fn PdhOpenQueryA( + szDataSource: LPCSTR, + dwUserData: DWORD_PTR, + phQuery: *mut PDH_HQUERY, + ) -> PDH_STATUS; + pub fn PdhAddCounterW( + hQuery: PDH_HQUERY, + szFullCounterPath: LPCWSTR, + dwUserData: DWORD_PTR, + phCounter: *mut PDH_HCOUNTER, + ) -> PDH_STATUS; + pub fn PdhAddCounterA( + hQuery: PDH_HQUERY, + szFullCounterPath: LPCSTR, + dwUserData: DWORD_PTR, + phCounter: *mut PDH_HCOUNTER, + ) -> PDH_STATUS; + pub fn PdhAddEnglishCounterW( + hQuery: PDH_HQUERY, + szFullCounterPath: LPCWSTR, + dwUserData: DWORD_PTR, + phCounter: *mut PDH_HCOUNTER, + ) -> PDH_STATUS; + pub fn PdhAddEnglishCounterA( + hQuery: PDH_HQUERY, + szFullCounterPath: LPCSTR, + dwUserData: DWORD_PTR, + phCounter: *mut PDH_HCOUNTER, + ) -> PDH_STATUS; + pub fn PdhCollectQueryDataWithTime( + hQuery: PDH_HQUERY, + pllTimeStamp: *mut LONGLONG, + ) -> PDH_STATUS; + pub fn PdhValidatePathExW( + hDataSource: PDH_HLOG, + szFullPathBuffer: LPCWSTR, + ) -> PDH_STATUS; + pub fn PdhValidatePathExA( + hDataSource: PDH_HLOG, + szFullPathBuffer: LPCSTR, + ) -> PDH_STATUS; + pub fn PdhRemoveCounter( + hCounter: PDH_HCOUNTER, + ) -> PDH_STATUS; + pub fn PdhCollectQueryData( + hQuery: PDH_HQUERY, + ) -> PDH_STATUS; + pub fn PdhCloseQuery( + hQuery: PDH_HQUERY, + ) -> PDH_STATUS; + pub fn PdhGetFormattedCounterValue( + hCounter: PDH_HCOUNTER, + dwFormat: DWORD, + lpdwType: LPDWORD, + pValue: PPDH_FMT_COUNTERVALUE, + ) -> PDH_STATUS; + pub fn PdhGetFormattedCounterArrayA( + hCounter: PDH_HCOUNTER, + dwFormat: DWORD, + lpdwBufferSize: LPDWORD, + lpdwBufferCount: LPDWORD, + ItemBuffer: PPDH_FMT_COUNTERVALUE_ITEM_A, + ) -> PDH_STATUS; + pub fn PdhGetFormattedCounterArrayW( + hCounter: PDH_HCOUNTER, + dwFormat: DWORD, + lpdwBufferSize: LPDWORD, + lpdwBufferCount: LPDWORD, + ItemBuffer: PPDH_FMT_COUNTERVALUE_ITEM_W, + ) -> PDH_STATUS; + pub fn PdhGetRawCounterValue( + hCounter: PDH_HCOUNTER, + lpdwType: LPDWORD, + pValue: PPDH_RAW_COUNTER, + ) -> PDH_STATUS; + pub fn PdhGetRawCounterArrayA( + hCounter: PDH_HCOUNTER, + dwFormat: DWORD, + lpdwBufferSize: LPDWORD, + lpdwBufferCount: LPDWORD, + ItemBuffer: PPDH_FMT_COUNTERVALUE_ITEM_A, + ) -> PDH_STATUS; + pub fn PdhGetRawCounterArrayW( + hCounter: PDH_HCOUNTER, + dwFormat: DWORD, + lpdwBufferSize: LPDWORD, + lpdwBufferCount: LPDWORD, + ItemBuffer: PPDH_FMT_COUNTERVALUE_ITEM_W, + ) -> PDH_STATUS; + pub fn PdhCalculateCounterFromRawValue( + hCounter: PDH_HCOUNTER, + dwFormat: DWORD, + rawValue1: PPDH_RAW_COUNTER, + rawValue2: PPDH_RAW_COUNTER, + fmtValue: PPDH_FMT_COUNTERVALUE, + ) -> PDH_STATUS; + pub fn PdhComputeCounterStatistics( + hCounter: PDH_HCOUNTER, + dwFormat: DWORD, + dwFirstEntry: DWORD, + dwNumEntries: DWORD, + lpRawValueArray: PPDH_RAW_COUNTER, + data: PPDH_STATISTICS, + ) -> PDH_STATUS; + pub fn PdhGetCounterInfoW( + hCounter: PDH_HCOUNTER, + bRetrieveExplainText: BOOLEAN, + pdwBufferSize: LPDWORD, + lpBuffer: PPDH_COUNTER_INFO_W, + ) -> PDH_STATUS; + pub fn PdhGetCounterInfoA( + hCounter: PDH_HCOUNTER, + bRetrieveExplainText: BOOLEAN, + pdwBufferSize: LPDWORD, + lpBuffer: PPDH_COUNTER_INFO_A, + ) -> PDH_STATUS; + pub fn PdhSetCounterScaleFactor( + hCounter: PDH_HCOUNTER, + lFactor: LONG, + ) -> PDH_STATUS; + pub fn PdhConnectMachineW( + szMachineName: LPCWSTR, + ) -> PDH_STATUS; + pub fn PdhConnectMachineA( + szMachineName: LPCSTR, + ) -> PDH_STATUS; + pub fn PdhEnumMachinesW( + szDataSource: LPCWSTR, + mszMachineNameList: LPWSTR, + pcchBufferLength: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhEnumMachinesA( + szDataSource: LPCSTR, + mszMachineNameList: LPSTR, + pcchBufferLength: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhEnumObjectsW( + szDataSource: LPCWSTR, + szMachineName: LPCWSTR, + mszObjectList: LPWSTR, + pcchBufferLength: LPDWORD, + dwDetailLevel: DWORD, + bRefresh: BOOL, + ) -> PDH_STATUS; + pub fn PdhEnumObjectsA( + szDataSource: LPCSTR, + szMachineName: LPCSTR, + mszObjectList: LPSTR, + pcchBufferLength: LPDWORD, + dwDetailLevel: DWORD, + bRefresh: BOOL, + ) -> PDH_STATUS; + pub fn PdhEnumObjectItemsW( + szDataSource: LPCWSTR, + szMachineName: LPCWSTR, + szObjectName: LPCWSTR, + mszCounterList: LPWSTR, + pcchCounterListLength: LPDWORD, + mszInstanceList: LPWSTR, + pcchInstanceListLength: LPDWORD, + dwDetailLevel: DWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhEnumObjectItemsA( + szDataSource: LPCSTR, + szMachineName: LPCSTR, + szObjectName: LPCSTR, + mszCounterList: LPSTR, + pcchCounterListLength: LPDWORD, + mszInstanceList: LPSTR, + pcchInstanceListLength: LPDWORD, + dwDetailLevel: DWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhMakeCounterPathW( + pCounterPathElements: PPDH_COUNTER_PATH_ELEMENTS_W, + szFullPathBuffer: LPWSTR, + pcchBufferSize: LPDWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhMakeCounterPathA( + pCounterPathElements: PPDH_COUNTER_PATH_ELEMENTS_A, + szFullPathBuffer: LPSTR, + pcchBufferSize: LPDWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhParseCounterPathW( + szFullPathBuffer: LPCWSTR, + pCounterPathElements: *mut PDH_COUNTER_PATH_ELEMENTS_W, + pcchBufferSize: LPDWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhParseCounterPathA( + szFullPathBuffer: LPCSTR, + pCounterPathElements: *mut PDH_COUNTER_PATH_ELEMENTS_A, + pcchBufferSize: LPDWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhParseInstanceNameW( + szInstanceString: LPCWSTR, + szInstanceName: LPWSTR, + pcchInstanceNameLength: LPDWORD, + szParentName: LPWSTR, + pcchParentNameLength: LPDWORD, + lpIndex: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhParseInstanceNameA( + szInstanceString: LPCSTR, + szInstanceName: LPSTR, + pcchInstanceNameLength: LPDWORD, + szParentName: LPSTR, + pcchParentNameLength: LPDWORD, + lpIndex: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhValidatePathW( + szFullCounterPath: LPCWSTR, + ) -> PDH_STATUS; + pub fn PdhValidatePathA( + szFullCounterPath: LPCSTR, + ) -> PDH_STATUS; + pub fn PdhGetDefaultPerfObjectW( + szDataSource: LPCWSTR, + szMachineName: LPCWSTR, + szDefaultObjectName: LPWSTR, + pcchBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhGetDefaultPerfObjectA( + szDataSource: LPCSTR, + szMachineName: LPCSTR, + szDefaultObjectName: LPSTR, + pcchBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhGetDefaultPerfCounterW( + szDataSource: LPCWSTR, + szMachineName: LPCWSTR, + szObjectName: LPCWSTR, + szDefaultCounterName: LPWSTR, + pcchBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhGetDefaultPerfCounterA( + szDataSource: LPCSTR, + szMachineName: LPCSTR, + szObjectName: LPCSTR, + szDefaultCounterName: LPSTR, + pcchBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhBrowseCountersW( + pBrowseDlgData: PPDH_BROWSE_DLG_CONFIG_W, + ) -> PDH_STATUS; + pub fn PdhBrowseCountersA( + pBrowseDlgData: PPDH_BROWSE_DLG_CONFIG_A, + ) -> PDH_STATUS; + pub fn PdhExpandCounterPathW( + szWildCardPath: LPCWSTR, + mszExpandedPathList: LPWSTR, + pcchPathListLength: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhExpandCounterPathA( + szWildCardPath: LPCSTR, + mszExpandedPathList: LPSTR, + pcchPathListLength: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhLookupPerfNameByIndexW( + szMachineName: LPCWSTR, + dwNameIndex: DWORD, + szNameBuffer: LPWSTR, + pcchNameBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhLookupPerfNameByIndexA( + szMachineName: LPCSTR, + dwNameIndex: DWORD, + szNameBuffer: LPSTR, + pcchNameBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhLookupPerfIndexByNameW( + szMachineName: LPCWSTR, + szNameBuffer: LPCWSTR, + pdwIndex: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhLookupPerfIndexByNameA( + szMachineName: LPCSTR, + szNameBuffer: LPCSTR, + pdwIndex: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhExpandWildCardPathW( + szDataSource: LPCWSTR, + szWildCardPath: LPCWSTR, + mszExpandedPathList: LPWSTR, + pcchPathListLength: LPDWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhExpandWildCardPathA( + szDataSource: LPCSTR, + szWildCardPath: LPCSTR, + mszExpandedPathList: LPSTR, + pcchPathListLength: LPDWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhOpenLogW( + szLogFileName: LPCWSTR, + dwAccessFlags: DWORD, + lpdwLogType: LPDWORD, + hQuery: PDH_HQUERY, + dwMaxSize: DWORD, + szUserCaption: LPCWSTR, + phLog: *mut PDH_HLOG, + ) -> PDH_STATUS; + pub fn PdhOpenLogA( + szLogFileName: LPCSTR, + dwAccessFlags: DWORD, + lpdwLogType: LPDWORD, + hQuery: PDH_HQUERY, + dwMaxSize: DWORD, + szUserCaption: LPCSTR, + phLog: *mut PDH_HLOG, + ) -> PDH_STATUS; + pub fn PdhUpdateLogW( + hLog: PDH_HLOG, + szUserString: LPCWSTR, + ) -> PDH_STATUS; + pub fn PdhUpdateLogA( + hLog: PDH_HLOG, + szUserString: LPCSTR, + ) -> PDH_STATUS; + pub fn PdhUpdateLogFileCatalog( + hLog: PDH_HLOG, + ) -> PDH_STATUS; + pub fn PdhGetLogFileSize( + hLog: PDH_HLOG, + llSize: *mut LONGLONG, + ) -> PDH_STATUS; + pub fn PdhCloseLog( + hLog: PDH_HLOG, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhSelectDataSourceW( + hWndOwner: HWND, + dwFlags: DWORD, + szDataSource: LPWSTR, + pcchBufferLength: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhSelectDataSourceA( + hWndOwner: HWND, + dwFlags: DWORD, + szDataSource: LPSTR, + pcchBufferLength: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhIsRealTimeQuery( + hQuery: PDH_HQUERY, + ) -> PDH_STATUS; + pub fn PdhSetQueryTimeRange( + hQuery: PDH_HQUERY, + pInfo: PPDH_TIME_INFO, + ) -> PDH_STATUS; + pub fn PdhGetDataSourceTimeRangeW( + szDataSource: LPCWSTR, + pdwNumEntries: LPDWORD, + pInfo: PPDH_TIME_INFO, + pdwBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhGetDataSourceTimeRangeA( + szDataSource: LPCSTR, + pdwNumEntries: LPDWORD, + pInfo: PPDH_TIME_INFO, + pdwBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhCollectQueryDataEx( + hQuery: PDH_HQUERY, + dwIntervalTime: DWORD, + hNewDataEvent: HANDLE, + ) -> PDH_STATUS; + pub fn PdhFormatFromRawValue( + dwCounterType: DWORD, + dwFormat: DWORD, + pTimeBase: *mut LONGLONG, + rawValue1: PPDH_RAW_COUNTER, + rawValue2: PPDH_RAW_COUNTER, + fmtValue: PPDH_FMT_COUNTERVALUE, + ) -> PDH_STATUS; + pub fn PdhGetCounterTimeBase( + hCounter: PDH_HCOUNTER, + pTimeBase: *mut LONGLONG, + ) -> PDH_STATUS; + pub fn PdhReadRawLogRecord( + hLog: PDH_HLOG, + ftRecord: FILETIME, + pRawLogRecord: PPDH_RAW_LOG_RECORD, + pdwBufferLength: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhSetDefaultRealTimeDataSource( + dwDataSourceId: DWORD, + ) -> PDH_STATUS; + pub fn PdhBindInputDataSourceW( + phDataSource: *mut PDH_HLOG, + szLogFileNameList: LPCWSTR, + ) -> PDH_STATUS; + pub fn PdhBindInputDataSourceA( + phDataSource: *mut PDH_HLOG, + szLogFileNameList: LPCSTR, + ) -> PDH_STATUS; + pub fn PdhOpenQueryH( + hDataSource: PDH_HLOG, + dwUserData: DWORD_PTR, + phQuery: *mut PDH_HQUERY, + ) -> PDH_STATUS; + pub fn PdhEnumMachinesHW( + hDataSource: PDH_HLOG, + mszMachineNameList: LPWSTR, + pcchBufferLength: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhEnumMachinesHA( + hDataSource: PDH_HLOG, + mszMachineNameList: LPSTR, + pcchBufferLength: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhEnumObjectsHW( + hDataSource: PDH_HLOG, + szMachineName: LPCWSTR, + mszObjectList: LPWSTR, + pcchBufferLength: LPDWORD, + dwDetailLevel: DWORD, + bRefresh: BOOL, + ) -> PDH_STATUS; + pub fn PdhEnumObjectsHA( + hDataSource: PDH_HLOG, + szMachineName: LPCSTR, + mszObjectList: LPSTR, + pcchBufferLength: LPDWORD, + dwDetailLevel: DWORD, + bRefresh: BOOL, + ) -> PDH_STATUS; + pub fn PdhEnumObjectItemsHW( + hDataSource: PDH_HLOG, + szMachineName: LPCWSTR, + szObjectName: LPCWSTR, + mszCounterList: LPWSTR, + pcchCounterListLength: LPDWORD, + mszInstanceList: LPWSTR, + pcchInstanceListLength: LPDWORD, + dwDetailLevel: DWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhEnumObjectItemsHA( + hDataSource: PDH_HLOG, + szMachineName: LPCSTR, + szObjectName: LPCSTR, + mszCounterList: LPSTR, + pcchCounterListLength: LPDWORD, + mszInstanceList: LPSTR, + pcchInstanceListLength: LPDWORD, + dwDetailLevel: DWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhExpandWildCardPathHW( + hDataSource: PDH_HLOG, + szWildCardPath: LPCWSTR, + mszExpandedPathList: LPWSTR, + pcchPathListLength: LPDWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhExpandWildCardPathHA( + hDataSource: PDH_HLOG, + szWildCardPath: LPCSTR, + mszExpandedPathList: LPSTR, + pcchPathListLength: LPDWORD, + dwFlags: DWORD, + ) -> PDH_STATUS; + pub fn PdhGetDataSourceTimeRangeH( + hDataSource: PDH_HLOG, + pdwNumEntries: LPDWORD, + pInfo: PPDH_TIME_INFO, + pdwBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhGetDefaultPerfObjectHW( + hDataSource: PDH_HLOG, + szMachineName: LPCWSTR, + szDefaultObjectName: LPWSTR, + pcchBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhGetDefaultPerfObjectHA( + hDataSource: PDH_HLOG, + szMachineName: LPCSTR, + szDefaultObjectName: LPSTR, + pcchBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhGetDefaultPerfCounterHW( + hDataSource: PDH_HLOG, + szMachineName: LPCWSTR, + szObjectName: LPCWSTR, + szDefaultCounterName: LPWSTR, + pcchBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhGetDefaultPerfCounterHA( + hDataSource: PDH_HLOG, + szMachineName: LPCSTR, + szObjectName: LPCSTR, + szDefaultCounterName: LPSTR, + pcchBufferSize: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhBrowseCountersHW( + pBrowseDlgData: PPDH_BROWSE_DLG_CONFIG_HW, + ) -> PDH_STATUS; + pub fn PdhBrowseCountersHA( + pBrowseDlgData: PPDH_BROWSE_DLG_CONFIG_HA, + ) -> PDH_STATUS; + pub fn PdhEnumLogSetNamesW( + szDataSource: LPCWSTR, + mszLogSetNameList: LPWSTR, + pcchBufferLength: LPDWORD, + ) -> PDH_STATUS; + pub fn PdhEnumLogSetNamesA( + szDataSource: LPCSTR, + mszLogSetNameList: LPSTR, + pcchBufferLength: LPDWORD, + ) -> PDH_STATUS; +} +// pub fn PdhVerifySQLDBW() -> PDH_STATUS; +// pub fn PdhVerifySQLDBA() -> PDH_STATUS; +// pub fn PdhCreateSQLTablesW() -> PDH_STATUS; +// pub fn PdhCreateSQLTablesA() -> PDH_STATUS; +//pub fn PdhGetLogSetGUID() -> PDH_STATUS; +// pub fn PdhSetLogSetRunID() -> PDH_STATUS; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/perflib.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/perflib.rs new file mode 100644 index 0000000..aea3bde --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/perflib.rs @@ -0,0 +1,331 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::SIZE_T; +use shared::guiddef::{GUID, LPCGUID, LPGUID}; +use shared::minwindef::{DWORD, LPBYTE, LPDWORD, LPVOID, ULONG}; +use um::minwinbase::SYSTEMTIME; +use um::winnt::{HANDLE, LONG, LONGLONG, LPCWSTR, PCWSTR, PHANDLE, PVOID, ULONGLONG}; +pub const PERF_PROVIDER_USER_MODE: ULONG = 0; +pub const PERF_PROVIDER_KERNEL_MODE: ULONG = 1; +pub const PERF_PROVIDER_DRIVER: ULONG = 2; +pub const PERF_COUNTERSET_FLAG_MULTIPLE: ULONG = 2; +pub const PERF_COUNTERSET_FLAG_AGGREGATE: ULONG = 4; +pub const PERF_COUNTERSET_FLAG_HISTORY: ULONG = 8; +pub const PERF_COUNTERSET_FLAG_INSTANCE: ULONG = 16; +pub const PERF_COUNTERSET_SINGLE_INSTANCE: ULONG = 0; +pub const PERF_COUNTERSET_MULTI_INSTANCES: ULONG = PERF_COUNTERSET_FLAG_MULTIPLE; +pub const PERF_COUNTERSET_SINGLE_AGGREGATE: ULONG = PERF_COUNTERSET_FLAG_AGGREGATE; +pub const PERF_COUNTERSET_MULTI_AGGREGATE: ULONG = PERF_COUNTERSET_FLAG_AGGREGATE + | PERF_COUNTERSET_FLAG_MULTIPLE; +pub const PERF_COUNTERSET_SINGLE_AGGREGATE_HISTORY: ULONG = PERF_COUNTERSET_FLAG_HISTORY + | PERF_COUNTERSET_SINGLE_AGGREGATE; +pub const PERF_COUNTERSET_INSTANCE_AGGREGATE: ULONG = PERF_COUNTERSET_MULTI_AGGREGATE + | PERF_COUNTERSET_FLAG_INSTANCE; +pub const PERF_AGGREGATE_UNDEFINED: ULONG = 0; +pub const PERF_AGGREGATE_TOTAL: ULONG = 1; +pub const PERF_AGGREGATE_AVG: ULONG = 2; +pub const PERF_AGGREGATE_MIN: ULONG = 3; +pub const PERF_AGGREGATE_MAX: ULONG = 4; +pub const PERF_ATTRIB_BY_REFERENCE: ULONGLONG = 0x0000000000000001; +pub const PERF_ATTRIB_NO_DISPLAYABLE: ULONGLONG = 0x0000000000000002; +pub const PERF_ATTRIB_NO_GROUP_SEPARATOR: ULONGLONG = 0x0000000000000004; +pub const PERF_ATTRIB_DISPLAY_AS_REAL: ULONGLONG = 0x0000000000000008; +pub const PERF_ATTRIB_DISPLAY_AS_HEX: ULONGLONG = 0x0000000000000010; +STRUCT!{struct PERF_COUNTERSET_INFO { + CounterSetGuid: GUID, + ProviderGuid: GUID, + NumCounters: ULONG, + InstanceType: ULONG, +}} +pub type PPERF_COUNTERSET_INFO = *mut PERF_COUNTERSET_INFO; +STRUCT!{struct PERF_COUNTER_INFO { + CounterId: ULONG, + Type: ULONG, + Attrib: ULONGLONG, + Size: ULONG, + DetailLevel: ULONG, + Scale: LONG, + Offset: LONG, +}} +pub type PPERF_COUNTER_INFO = *mut PERF_COUNTER_INFO; +STRUCT!{struct PERF_COUNTERSET_INSTANCE { + CounterSetGuid: GUID, + dwSize: ULONG, + InstanceId: ULONG, + InstanceNameOffset: ULONG, + InstanceNameSize: ULONG, +}} +pub type PPERF_COUNTERSET_INSTANCE = *mut PERF_COUNTERSET_INSTANCE; +STRUCT!{struct PERF_COUNTER_IDENTITY { + CounterSetGuid: GUID, + BufferSize: ULONG, + CounterId: ULONG, + InstanceId: ULONG, + MachineOffset: ULONG, + NameOffset: ULONG, + Reserved: ULONG, +}} +pub type PPERF_COUNTER_IDENTITY = *mut PERF_COUNTER_IDENTITY; +pub const PERF_WILDCARD_COUNTER: ULONG = 0xFFFFFFFF; +pub const PERF_WILDCARD_INSTANCE: &'static str = "*"; +pub const PERF_AGGREGATE_INSTANCE: &'static str = "_Total"; +pub const PERF_MAX_INSTANCE_NAME: ULONG = 1024; +pub const PERF_ADD_COUNTER: ULONG = 1; +pub const PERF_REMOVE_COUNTER: ULONG = 2; +pub const PERF_ENUM_INSTANCES: ULONG = 3; +pub const PERF_COLLECT_START: ULONG = 5; +pub const PERF_COLLECT_END: ULONG = 6; +pub const PERF_FILTER: ULONG = 9; +FN!{stdcall PERFLIBREQUEST( + RequestCode: ULONG, + Buffer: PVOID, + BufferSize: ULONG, +) -> ULONG} +FN!{stdcall PERF_MEM_ALLOC( + AllocSize: SIZE_T, + pContext: LPVOID, +) -> LPVOID} +FN!{stdcall PERF_MEM_FREE( + pBuffer: LPVOID, + pContext: LPVOID, +) -> ()} +STRUCT!{struct PERF_PROVIDER_CONTEXT { + ContextSize: DWORD, + Reserved: DWORD, + ControlCallback: PERFLIBREQUEST, + MemAllocRoutine: PERF_MEM_ALLOC, + MemFreeRoutine: PERF_MEM_FREE, + pMemContext: LPVOID, +}} +pub type PPERF_PROVIDER_CONTEXT = *mut PERF_PROVIDER_CONTEXT; +extern "system" { + pub fn PerfStartProviderEx( + ProviderGuid: LPGUID, + ProviderContext: PPERF_PROVIDER_CONTEXT, + Provider: PHANDLE, + ) -> ULONG; + pub fn PerfStartProvider( + ProviderGuid: LPGUID, + ControlCallback: PERFLIBREQUEST, + Provider: PHANDLE, + ) -> ULONG; + pub fn PerfStopProvider( + ProviderHandle: HANDLE, + ) -> ULONG; + pub fn PerfSetCounterSetInfo( + ProviderHandle: HANDLE, + Template: PPERF_COUNTERSET_INFO, + TemplateSize: ULONG, + ) -> ULONG; + pub fn PerfCreateInstance( + ProviderHandle: HANDLE, + CounterSetGuid: LPCGUID, + Name: PCWSTR, + Id: ULONG, + ) -> PPERF_COUNTERSET_INSTANCE; + pub fn PerfDeleteInstance( + Provider: HANDLE, + InstanceBlock: PPERF_COUNTERSET_INSTANCE, + ) -> ULONG; + pub fn PerfQueryInstance( + ProviderHandle: HANDLE, + CounterSetGuid: LPCGUID, + Name: LPCWSTR, + Id: ULONG, + ) -> PPERF_COUNTERSET_INSTANCE; + pub fn PerfSetCounterRefValue( + Provider: HANDLE, + Instance: PPERF_COUNTERSET_INSTANCE, + CounterId: ULONG, + Address: PVOID, + ) -> ULONG; + pub fn PerfSetULongCounterValue( + Provider: HANDLE, + Instance: PPERF_COUNTERSET_INSTANCE, + CounterId: ULONG, + Value: ULONG, + ) -> ULONG; + pub fn PerfSetULongLongCounterValue( + Provider: HANDLE, + Instance: PPERF_COUNTERSET_INSTANCE, + CounterId: ULONG, + Value: ULONGLONG, + ) -> ULONG; + pub fn PerfIncrementULongCounterValue( + Provider: HANDLE, + Instance: PPERF_COUNTERSET_INSTANCE, + CounterId: ULONG, + Value: ULONG, + ) -> ULONG; + pub fn PerfIncrementULongLongCounterValue( + Provider: HANDLE, + Instance: PPERF_COUNTERSET_INSTANCE, + CounterId: ULONG, + Value: ULONGLONG, + ) -> ULONG; + pub fn PerfDecrementULongCounterValue( + Provider: HANDLE, + Instance: PPERF_COUNTERSET_INSTANCE, + CounterId: ULONG, + Value: ULONG, + ) -> ULONG; + pub fn PerfDecrementULongLongCounterValue( + Provider: HANDLE, + Instance: PPERF_COUNTERSET_INSTANCE, + CounterId: ULONG, + Value: ULONGLONG, + ) -> ULONG; +} +STRUCT!{struct PERF_INSTANCE_HEADER { + Size: ULONG, + InstanceId: ULONG, +}} +pub type PPERF_INSTANCE_HEADER = *mut PERF_INSTANCE_HEADER; +ENUM!{enum PerfRegInfoType { + PERF_REG_COUNTERSET_STRUCT = 1, + PERF_REG_COUNTER_STRUCT, + PERF_REG_COUNTERSET_NAME_STRING, + PERF_REG_COUNTERSET_HELP_STRING, + PERF_REG_COUNTER_NAME_STRINGS, + PERF_REG_COUNTER_HELP_STRINGS, + PERF_REG_PROVIDER_NAME, + PERF_REG_PROVIDER_GUID, + PERF_REG_COUNTERSET_ENGLISH_NAME, + PERF_REG_COUNTER_ENGLISH_NAMES, +}} +STRUCT!{struct PERF_COUNTERSET_REG_INFO { + CounterSetGuid: GUID, + CounterSetType: ULONG, + DetailLevel: ULONG, + NumCounters: ULONG, + InstanceType: ULONG, +}} +pub type PPERF_COUNTERSET_REG_INFO = *mut PERF_COUNTERSET_REG_INFO; +STRUCT!{struct PERF_COUNTER_REG_INFO { + CounterId: ULONG, + Type: ULONG, + Attrib: ULONGLONG, + DetailLevel: ULONG, + DefaultScale: LONG, + BaseCounterId: ULONG, + PerfTimeId: ULONG, + PerfFreqId: ULONG, + MultiId: ULONG, + AggregateFinc: ULONG, + Reserved: ULONG, +}} +pub type PPERF_COUNTER_REG_INFO = *mut PERF_COUNTER_REG_INFO; +STRUCT!{struct PERF_STRING_BUFFER_HEADER { + dwSize: DWORD, + dwCounters: DWORD, +}} +pub type PPERF_STRING_BUFFER_HEADER = *mut PERF_STRING_BUFFER_HEADER; +STRUCT!{struct PERF_STRING_COUNTER_HEADER { + dwCounterId: DWORD, + dwOffset: DWORD, +}} +pub type PPERF_STRING_COUNTER_HEADER = *mut PERF_STRING_COUNTER_HEADER; +STRUCT!{struct PERF_COUNTER_IDENTIFIER { + CounterSetGuid: GUID, + Status: ULONG, + Size: ULONG, + CounterId: ULONG, + InstanceId: ULONG, + Index: ULONG, + Reserved: ULONG, +}} +pub type PPERF_COUNTER_IDENTIFIER = *mut PERF_COUNTER_IDENTIFIER; +STRUCT!{struct PERF_DATA_HEADER { + dwTotalSize: ULONG, + dwNumCounters: ULONG, + PerfTimeStamp: LONGLONG, + PerfTime100NSec: LONGLONG, + PrefFreq: LONGLONG, + SystemTime: SYSTEMTIME, +}} +pub type PPERF_DATA_HEADER = *mut PERF_DATA_HEADER; +ENUM!{enum PerfCounterDataType { + PERF_ERROR_RETURN = 0, + PERF_SINGLE_COUNTER = 1, + PERF_MULTIPLE_COUNTERS = 2, + PERF_MULTIPLE_INSTANCES = 4, + PERF_COUNTERSET = 6, +}} +STRUCT!{struct PERF_COUNTER_HEADER { + dwStatus: ULONG, + dwType: PerfCounterDataType, + dwSize: ULONG, + Reserved: ULONG, +}} +pub type PPERF_COUNTER_HEADER = *mut PERF_COUNTER_HEADER; +STRUCT!{struct PERF_MULTI_INSTANCES { + dwTotalSize: ULONG, + dwInstances: ULONG, +}} +pub type PPERF_MULTI_INSTANCES = *mut PERF_MULTI_INSTANCES; +STRUCT!{struct PERF_MULTI_COUNTERS { + dwSize: ULONG, + dwCounters: ULONG, +}} +pub type PPERF_MULTI_COUNTERS = *mut PERF_MULTI_COUNTERS; +STRUCT!{struct PERF_COUNTER_DATA { + dwDataSize: ULONG, + dwSize: ULONG, +}} +pub type PPERF_COUNTER_DATA = *mut PERF_COUNTER_DATA; +extern "system" { + pub fn PerfEnumerateCounterSet( + szMachine: LPCWSTR, + pCounterSetIds: LPGUID, + cCounterSetIds: DWORD, + pcCounterSetIdsActual: LPDWORD, + ) -> ULONG; + pub fn PerfEnumerateCounterSetInstances( + szMachine: LPCWSTR, + pCounterSetIds: LPCGUID, + pInstances: PPERF_INSTANCE_HEADER, + cbInstances: DWORD, + pcbInstancesActual: LPDWORD, + ) -> ULONG; + pub fn PerfQueryCounterSetRegistrationInfo( + szMachine: LPCWSTR, + pCounterSetId: LPCGUID, + requestCode: PerfRegInfoType, + requestLangId: DWORD, + pbRegInfo: LPBYTE, + cbRegInfo: DWORD, + pcbRegInfoActual: LPDWORD, + ) -> ULONG; + pub fn PerfOpenQueryHandle( + szMachine: LPCWSTR, + hQuery: *mut HANDLE, + ) -> ULONG; + pub fn PerfCloseQueryHandle( + hQuery: HANDLE, + ) -> ULONG; + pub fn PerfQueryCounterInfo( + hQuery: HANDLE, + pCounters: PPERF_COUNTER_IDENTIFIER, + cbCounters: DWORD, + pcbCountersActual: LPDWORD, + ) -> ULONG; + pub fn PerfQueryCounterData( + hQuery: HANDLE, + pCounterBlock: PPERF_DATA_HEADER, + cbCounterBlock: DWORD, + pcbCounterBlockActual: LPDWORD, + ) -> ULONG; + pub fn PerfAddCounters( + hQuery: HANDLE, + pCounters: PPERF_COUNTER_IDENTIFIER, + cbCounters: DWORD, + ) -> ULONG; + pub fn PerfDeleteCounters( + hQuery: HANDLE, + pCounters: PPERF_COUNTER_IDENTIFIER, + cbCounters: DWORD, + ) -> ULONG; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/physicalmonitorenumerationapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/physicalmonitorenumerationapi.rs new file mode 100644 index 0000000..b61ff7e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/physicalmonitorenumerationapi.rs @@ -0,0 +1,43 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::d3d9::IDirect3DDevice9; +use shared::minwindef::{BOOL, DWORD, LPDWORD}; +use shared::windef::HMONITOR; +use um::winnt::{HANDLE, HRESULT, WCHAR}; +pub type _BOOL = BOOL; +pub const PHYSICAL_MONITOR_DESCRIPTION_SIZE: usize = 128; +STRUCT!{#[repr(packed)] struct PHYSICAL_MONITOR { + hPhysicalMonitor: HANDLE, + szPhysicalMonitorDescription: [WCHAR; PHYSICAL_MONITOR_DESCRIPTION_SIZE], +}} +pub type LPPHYSICAL_MONITOR = *mut PHYSICAL_MONITOR; +extern "system" { + pub fn GetNumberOfPhysicalMonitorsFromHMONITOR( + hMonitor: HMONITOR, + pdwNumberOfPhysicalMonitor: LPDWORD, + ) -> _BOOL; + pub fn GetNumberOfPhysicalMonitorsFromIDirect3DDevice9( + pDirect3DDevice9: *mut IDirect3DDevice9, + pdwNumberOfPhysicalMonitor: LPDWORD, + ) -> HRESULT; + pub fn GetPhysicalMonitorsFromHMONITOR( + hMonitor: HMONITOR, + dwPhysicalMonitorArraySize: DWORD, + pPhysicalMonitorArray: LPPHYSICAL_MONITOR, + ) -> _BOOL; + pub fn GetPhysicalMonitorsFromIDirect3DDevice9( + pDirect3DDevice9: IDirect3DDevice9, + dwPhysicalMonitorArraySize: DWORD, + pPhysicalMonitorArray: LPPHYSICAL_MONITOR, + ) -> HRESULT; + pub fn DestroyPhysicalMonitor( + hMonitor: HANDLE, + ) -> _BOOL; + pub fn DestroyPhysicalMonitors( + dwPhysicalMonitorArraySize: DWORD, + pPhysicalMonitorArray: LPPHYSICAL_MONITOR, + ) -> _BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/playsoundapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/playsoundapi.rs new file mode 100644 index 0000000..9b0d0d5 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/playsoundapi.rs @@ -0,0 +1,46 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-mm-playsound-l1-1-0 +use shared::minwindef::{BOOL, DWORD, HMODULE, UINT}; +use um::winnt::{LPCSTR, LPCWSTR}; +extern "system" { + pub fn sndPlaySoundA( + pszSound: LPCSTR, + fuSound: UINT, + ) -> BOOL; + pub fn sndPlaySoundW( + pszSound: LPCWSTR, + fuSound: UINT, + ) -> BOOL; +} +pub const SND_SYNC: DWORD = 0x0000; +pub const SND_ASYNC: DWORD = 0x0001; +pub const SND_NODEFAULT: DWORD = 0x0002; +pub const SND_MEMORY: DWORD = 0x0004; +pub const SND_LOOP: DWORD = 0x0008; +pub const SND_NOSTOP: DWORD = 0x0010; +pub const SND_NOWAIT: DWORD = 0x00002000; +pub const SND_ALIAS: DWORD = 0x00010000; +pub const SND_ALIAS_ID: DWORD = 0x00110000; +pub const SND_FILENAME: DWORD = 0x00020000; +pub const SND_RESOURCE: DWORD = 0x00040004; +pub const SND_PURGE: DWORD = 0x0040; +pub const SND_APPLICATION: DWORD = 0x0080; +pub const SND_SENTRY: DWORD = 0x00080000; +pub const SND_RING: DWORD = 0x00100000; +pub const SND_SYSTEM: DWORD = 0x00200000; +extern "system" { + pub fn PlaySoundA( + pszSound: LPCSTR, + hmod: HMODULE, + fdwSound: DWORD, + ) -> BOOL; + pub fn PlaySoundW( + pszSound: LPCWSTR, + hmod: HMODULE, + fdwSound: DWORD, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/portabledevice.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/portabledevice.rs new file mode 100644 index 0000000..68d6348 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/portabledevice.rs @@ -0,0 +1,163 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of PortableDevice.h +use shared::basetsd::ULONG_PTR; +use shared::wtypes::PROPERTYKEY; +DEFINE_GUID!{GUID_DEVINTERFACE_WPD, + 0x6AC27878, 0xA6FA, 0x4155, 0xBA, 0x85, 0xF9, 0x8F, 0x49, 0x1D, 0x4F, 0x33} +DEFINE_GUID!{GUID_DEVINTERFACE_WPD_PRIVATE, + 0xBA0C718F, 0x4DED, 0x49B7, 0xBD, 0xD3, 0xFA, 0xBE, 0x28, 0x66, 0x12, 0x11} +DEFINE_GUID!{GUID_DEVINTERFACE_WPD_SERVICE, + 0x9EF44F80, 0x3D64, 0x4246, 0xA6, 0xAA, 0x20, 0x6F, 0x32, 0x8D, 0x1E, 0xDC} +//51 +pub const WPD_DEVICE_OBJECT_ID: &'static str = "DEVICE"; +pub const WMDRMDEVICEAPP_USE_WPD_DEVICE_PTR: ULONG_PTR = -1isize as ULONG_PTR; +pub const PORTABLE_DEVICE_TYPE: &'static str = "PortableDeviceType"; +pub const PORTABLE_DEVICE_ICON: &'static str = "Icons"; +pub const PORTABLE_DEVICE_NAMESPACE_TIMEOUT: &'static str = "PortableDeviceNameSpaceTimeout"; +pub const PORTABLE_DEVICE_NAMESPACE_EXCLUDE_FROM_SHELL: &'static str + = "PortableDeviceNameSpaceExcludeFromShell"; +pub const PORTABLE_DEVICE_NAMESPACE_THUMBNAIL_CONTENT_TYPES: &'static str + = "PortableDeviceNameSpaceThumbnailContentTypes"; +pub const PORTABLE_DEVICE_IS_MASS_STORAGE: &'static str = "PortableDeviceIsMassStorage"; +pub const PORTABLE_DEVICE_DRM_SCHEME_WMDRM10_PD: &'static str = "WMDRM10-PD"; +pub const PORTABLE_DEVICE_DRM_SCHEME_PDDRM: &'static str = "PDDRM"; +//101 +ENUM!{enum WPD_DEVICE_TYPES { + WPD_DEVICE_TYPE_GENERIC = 0, + WPD_DEVICE_TYPE_CAMERA = 1, + WPD_DEVICE_TYPE_MEDIA_PLAYER = 2, + WPD_DEVICE_TYPE_PHONE = 3, + WPD_DEVICE_TYPE_VIDEO = 4, + WPD_DEVICE_TYPE_PERSONAL_INFORMATION_MANAGER = 5, + WPD_DEVICE_TYPE_AUDIO_RECORDER = 6, +}} +//133 +ENUM!{enum WPD_DEVICE_TRANSPORTS { + WPD_DEVICE_TRANSPORT_UNSPECIFIED = 0, + WPD_DEVICE_TRANSPORT_USB = 1, + WPD_DEVICE_TRANSPORT_IP = 2, + WPD_DEVICE_TRANSPORT_BLUETOOTH = 3, +}} +//175 +ENUM!{enum WPD_POWER_SOURCES { + WPD_POWER_SOURCE_BATTERY = 0, + WPD_POWER_SOURCE_EXTERNAL = 1, +}} +//696 +DEFINE_GUID!{WPD_FUNCTIONAL_OBJECT_PROPERTIES_V1, + 0x8F052D93, 0xABCA, 0x4FC5, 0xA5, 0xAC, 0xB0, 0x1D, 0xF4, 0xDB, 0xE5, 0x98} +DEFINE_PROPERTYKEY!{WPD_FUNCTIONAL_OBJECT_CATEGORY, + 0x8F052D93, 0xABCA, 0x4FC5, 0xA5, 0xAC, 0xB0, 0x1D, 0xF4, 0xDB, 0xE5, 0x98, 2} +//1140 +DEFINE_GUID!{WPD_DEVICE_PROPERTIES_V1, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC} +DEFINE_PROPERTYKEY!{WPD_DEVICE_SYNC_PARTNER, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 2} +DEFINE_PROPERTYKEY!{WPD_DEVICE_FIRMWARE_VERSION, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 3} +DEFINE_PROPERTYKEY!{WPD_DEVICE_POWER_LEVEL, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 4} +DEFINE_PROPERTYKEY!{WPD_DEVICE_POWER_SOURCE, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 5} +DEFINE_PROPERTYKEY!{WPD_DEVICE_PROTOCOL, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 6} +DEFINE_PROPERTYKEY!{WPD_DEVICE_MANUFACTURER, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 7} +DEFINE_PROPERTYKEY!{WPD_DEVICE_MODEL, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 8} +DEFINE_PROPERTYKEY!{WPD_DEVICE_SERIAL_NUMBER, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 9} +DEFINE_PROPERTYKEY!{WPD_DEVICE_SUPPORTS_NON_CONSUMABLE, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 10} +DEFINE_PROPERTYKEY!{WPD_DEVICE_DATETIME, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 11} +DEFINE_PROPERTYKEY!{WPD_DEVICE_FRIENDLY_NAME, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 12} +DEFINE_PROPERTYKEY!{WPD_DEVICE_SUPPORTED_DRM_SCHEMES, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 13} +DEFINE_PROPERTYKEY!{WPD_DEVICE_SUPPORTED_FORMATS_ARE_ORDERED, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 14} +DEFINE_PROPERTYKEY!{WPD_DEVICE_TYPE, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 15} +DEFINE_PROPERTYKEY!{WPD_DEVICE_NETWORK_IDENTIFIER, + 0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC, 16} +DEFINE_GUID!{WPD_DEVICE_PROPERTIES_V2, + 0x463DD662, 0x7FC4, 0x4291, 0x91, 0x1C, 0x7F, 0x4C, 0x9C, 0xCA, 0x97, 0x99} +DEFINE_PROPERTYKEY!{WPD_DEVICE_FUNCTIONAL_UNIQUE_ID, + 0x463DD662, 0x7FC4, 0x4291, 0x91, 0x1C, 0x7F, 0x4C, 0x9C, 0xCA, 0x97, 0x99, 2} +DEFINE_PROPERTYKEY!{WPD_DEVICE_MODEL_UNIQUE_ID, + 0x463DD662, 0x7FC4, 0x4291, 0x91, 0x1C, 0x7F, 0x4C, 0x9C, 0xCA, 0x97, 0x99, 3} +DEFINE_PROPERTYKEY!{WPD_DEVICE_TRANSPORT, + 0x463DD662, 0x7FC4, 0x4291, 0x91, 0x1C, 0x7F, 0x4C, 0x9C, 0xCA, 0x97, 0x99, 4} +DEFINE_PROPERTYKEY!{WPD_DEVICE_USE_DEVICE_STAGE, + 0x463DD662, 0x7FC4, 0x4291, 0x91, 0x1C, 0x7F, 0x4C, 0x9C, 0xCA, 0x97, 0x99, 5} +DEFINE_GUID!{WPD_DEVICE_PROPERTIES_V3, + 0x6C2B878C, 0xC2EC, 0x490D, 0xB4, 0x25, 0xD7, 0xA7, 0x5E, 0x23, 0xE5, 0xED} +DEFINE_PROPERTYKEY!{WPD_DEVICE_EDP_IDENTITY, + 0x6C2B878C, 0xC2EC, 0x490D, 0xB4, 0x25, 0xD7, 0xA7, 0x5E, 0x23, 0xE5, 0xED, 1} +//1488 +DEFINE_PROPERTYKEY!{WPD_PROPERTY_COMMON_COMMAND_CATEGORY, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 1001} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_COMMON_COMMAND_ID, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 1002} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_COMMON_HRESULT, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 1003} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_COMMON_DRIVER_ERROR_CODE, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 1004} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_COMMON_COMMAND_TARGET, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 1006} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_COMMON_PERSISTENT_UNIQUE_IDS, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 1007} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_COMMON_OBJECT_IDS, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 1008} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_COMMON_CLIENT_INFORMATION, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 1009} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_COMMON_CLIENT_INFORMATION_CONTEXT, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 1010} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_COMMON_ACTIVITY_ID, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 1011} +DEFINE_PROPERTYKEY!{WPD_OPTION_VALID_OBJECT_IDS, + 0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A, 5001} +//3440 +DEFINE_PROPERTYKEY!{WPD_OBJECT_ID, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 2} +DEFINE_PROPERTYKEY!{WPD_OBJECT_PARENT_ID, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 3} +DEFINE_PROPERTYKEY!{WPD_OBJECT_NAME, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 4} +DEFINE_PROPERTYKEY!{WPD_OBJECT_PERSISTENT_UNIQUE_ID, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 5} +DEFINE_PROPERTYKEY!{WPD_OBJECT_FORMAT, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 6} +DEFINE_PROPERTYKEY!{WPD_OBJECT_ISHIDDEN, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 9} +DEFINE_PROPERTYKEY!{WPD_OBJECT_ISSYSTEM, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 10} +DEFINE_PROPERTYKEY!{WPD_OBJECT_SIZE, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 11} +DEFINE_PROPERTYKEY!{WPD_OBJECT_ORIGINAL_FILE_NAME, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 12} +DEFINE_PROPERTYKEY!{WPD_OBJECT_NON_CONSUMABLE, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 13} +DEFINE_PROPERTYKEY!{WPD_OBJECT_KEYWORDS, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 15} +DEFINE_PROPERTYKEY!{WPD_OBJECT_SYNC_ID, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 16} +DEFINE_PROPERTYKEY!{WPD_OBJECT_IS_DRM_PROTECTED, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 17} +DEFINE_PROPERTYKEY!{WPD_OBJECT_DATE_CREATED, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 18} +DEFINE_PROPERTYKEY!{WPD_OBJECT_DATE_MODIFIED, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 19} +DEFINE_PROPERTYKEY!{WPD_OBJECT_DATE_AUTHORED, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 20} +DEFINE_PROPERTYKEY!{WPD_OBJECT_BACK_REFERENCES, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 21} +DEFINE_PROPERTYKEY!{WPD_OBJECT_CAN_DELETE, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 26} +DEFINE_PROPERTYKEY!{WPD_OBJECT_LANGUAGE_LOCALE, + 0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C, 27} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/portabledeviceapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/portabledeviceapi.rs new file mode 100644 index 0000000..a694e7e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/portabledeviceapi.rs @@ -0,0 +1,288 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of PortableDeviceApi.h +use shared::guiddef::REFGUID; +use shared::minwindef::{BYTE, DWORD, ULONG}; +use um::objidlbase::IStream; +use um::portabledevicetypes::{ + IPortableDeviceKeyCollection, IPortableDevicePropVariantCollection, IPortableDeviceValues, +}; +use um::propkeydef::REFPROPERTYKEY; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCWSTR, LPWSTR, WCHAR}; +// 328 +RIDL!{#[uuid(0xa1567595, 0x4c2f, 0x4574, 0xa6, 0xfa, 0xec, 0xef, 0x91, 0x7b, 0x9a, 0x40)] +interface IPortableDeviceManager(IPortableDeviceManagerVtbl): IUnknown(IUnknownVtbl) { + fn GetDevices( + pPnPDeviceIDs: *mut LPWSTR, + pcPnPDeviceIDs: *mut DWORD, + ) -> HRESULT, + fn RefreshDeviceList() -> HRESULT, + fn GetDeviceFriendlyName( + pszPnPDeviceID: LPCWSTR, + pDeviceFriendlyName: *mut WCHAR, + pcchDeviceFriendlyName: *mut DWORD, + ) -> HRESULT, + fn GetDeviceDescription( + pszPnPDeviceID: LPCWSTR, + pDeviceDescription: *mut WCHAR, + pcchDeviceDescription: *mut DWORD, + ) -> HRESULT, + fn GetDeviceManufacturer( + pszPnPDeviceID: LPCWSTR, + pDeviceManufacturer: *mut WCHAR, + pcchDeviceManufacturer: *mut DWORD, + ) -> HRESULT, + fn GetDeviceProperty( + pszPnPDeviceID: LPCWSTR, + pszDevicePropertyName: LPCWSTR, + pData: *mut BYTE, + pcbData: *mut DWORD, + pdwType: *mut DWORD, + ) -> HRESULT, + fn GetPrivateDevices( + pPnPDeviceIDs: *mut LPWSTR, + pcPnPDeviceIDs: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x625e2df8, 0x6392, 0x4cf0, 0x9a, 0xd1, 0x3c, 0xfa, 0x5f, 0x17, 0x77, 0x5c)] +interface IPortableDevice(IPortableDeviceVtbl): IUnknown(IUnknownVtbl) { + fn Open( + pszPnPDeviceID: LPCWSTR, + pClientInfo: *mut IPortableDeviceValues, + ) -> HRESULT, + fn SendCommand( + dwFlags: DWORD, + pParameters: *mut IPortableDeviceValues, + ppResults: *mut *mut IPortableDeviceValues, + ) -> HRESULT, + fn Content( + ppContent: *mut *mut IPortableDeviceContent, + ) -> HRESULT, + fn Capabilities( + ppCapabilities: *mut *mut IPortableDeviceCapabilities, + ) -> HRESULT, + fn Cancel() -> HRESULT, + fn Close() -> HRESULT, + fn Advise( + dwFlags: DWORD, + pCallback: *mut IPortableDeviceEventCallback, + pParameters: *mut IPortableDeviceValues, + ppszCookie: *mut LPWSTR, + ) -> HRESULT, + fn Unadvise( + pszCookie: LPCWSTR, + ) -> HRESULT, + fn GetPnPDeviceID( + ppszPnPDeviceID: *mut LPWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6a96ed84, 0x7c73, 0x4480, 0x99, 0x38, 0xbf, 0x5a, 0xf4, 0x77, 0xd4, 0x26)] +interface IPortableDeviceContent(IPortableDeviceContentVtbl): IUnknown(IUnknownVtbl) { + fn EnumObjects( + dwFlags: DWORD, + pszParentObjectID: LPCWSTR, + pFilter: *mut IPortableDeviceValues, + ppEnum: *mut *mut IEnumPortableDeviceObjectIDs, + ) -> HRESULT, + fn Properties( + ppProperties: *mut *mut IPortableDeviceProperties, + ) -> HRESULT, + fn Transfer( + ppResources: *mut *mut IPortableDeviceResources, + ) -> HRESULT, + fn CreateObjectWithPropertiesOnly( + pValues: *mut IPortableDeviceValues, + ppszObjectID: *mut LPWSTR, + ) -> HRESULT, + fn CreateObjectWithPropertiesAndData( + pValues: *mut IPortableDeviceValues, + ppData: *mut *mut IStream, + pdwOptimalWriteBufferSize: *mut DWORD, + ppszCookie: *mut LPWSTR, + ) -> HRESULT, + fn Delete( + dwOptions: DWORD, + pObjectIDs: *mut IPortableDevicePropVariantCollection, + ppResults: *mut *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, + fn GetObjectIDsFromPersistentUniqueIDs( + pPersistentUniqueIDs: *mut IPortableDevicePropVariantCollection, + ppObjectIDs: *mut *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, + fn Cancel() -> HRESULT, + fn Move( + pObjectIDs: *mut IPortableDevicePropVariantCollection, + pszDestinationFolderObjectID: LPCWSTR, + ppResults: *mut *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, + fn Copy( + pObjectIDs: *mut IPortableDevicePropVariantCollection, + pszDestinationFolderObjectID: LPCWSTR, + ppResults: *mut *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9b4add96, 0xf6bf, 0x4034, 0x87, 0x08, 0xec, 0xa7, 0x2b, 0xf1, 0x05, 0x54)] +interface IPortableDeviceContent2(IPortableDeviceContent2Vtbl): + IPortableDeviceContent(IPortableDeviceContentVtbl) { + fn UpdateObjectWithPropertiesAndData( + pszObjectID: LPCWSTR, + pProperties: *mut IPortableDeviceValues, + ppData: *mut *mut IStream, + pdwOptimalWriteBufferSize: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x10ece955, 0xcf41, 0x4728, 0xbf, 0xa0, 0x41, 0xee, 0xdf, 0x1b, 0xbf, 0x19)] +interface IEnumPortableDeviceObjectIDs(IEnumPortableDeviceObjectIDsVtbl): IUnknown(IUnknownVtbl) { + fn Next( + cObjects: ULONG, + pObjIDs: *mut LPWSTR, + pcFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + cObjects: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppEnum: *mut *mut IEnumPortableDeviceObjectIDs, + ) -> HRESULT, + fn Cancel() -> HRESULT, +}} +RIDL!{#[uuid(0x7f6d695c, 0x03df, 0x4439, 0xa8, 0x09, 0x59, 0x26, 0x6b, 0xee, 0xe3, 0xa6)] +interface IPortableDeviceProperties(IPortableDevicePropertiesVtbl): IUnknown(IUnknownVtbl) { + fn GetSupportedProperties( + pszObjectID: LPCWSTR, + ppKeys: *mut *mut IPortableDeviceKeyCollection, + ) -> HRESULT, + fn GetPropertyAttributes( + pszObjectID: LPCWSTR, + Key: REFPROPERTYKEY, + ppAttributes: *mut *mut IPortableDeviceValues, + ) -> HRESULT, + fn GetValues( + pszObjectID: LPCWSTR, + pKeys: *mut IPortableDeviceKeyCollection, + ppValues: *mut *mut IPortableDeviceValues, + ) -> HRESULT, + fn SetValues( + pszObjectID: LPCWSTR, + pValues: *mut IPortableDeviceValues, + ppResults: *mut *mut IPortableDeviceValues, + ) -> HRESULT, + fn Delete( + pszObjectID: LPCWSTR, + pKeys: *mut IPortableDeviceKeyCollection, + ) -> HRESULT, + fn Cancel() -> HRESULT, +}} +RIDL!{#[uuid(0xfd8878ac, 0xd841, 0x4d17, 0x89, 0x1c, 0xe6, 0x82, 0x9c, 0xdb, 0x69, 0x34)] +interface IPortableDeviceResources(IPortableDeviceResourcesVtbl): IUnknown(IUnknownVtbl) { + fn GetSupportedResources( + pszObjectID: LPCWSTR, + ppKeys: *mut *mut IPortableDeviceKeyCollection, + ) -> HRESULT, + fn GetResourceAttributes( + pszObjectID: LPCWSTR, + Key: REFPROPERTYKEY, + ppResourceAttributes: *mut *mut IPortableDeviceValues, + ) -> HRESULT, + fn GetStream( + pszObjectID: LPCWSTR, + Key: REFPROPERTYKEY, + dwMode: DWORD, + pdwOptimalBufferSize: *mut DWORD, + ppStream: *mut *mut IStream, + ) -> HRESULT, + fn Delete( + pszObjectID: LPCWSTR, + pKeys: *mut IPortableDeviceKeyCollection, + ) -> HRESULT, + fn Cancel() -> HRESULT, + fn CreateResource( + pResourceAttributes: *mut IPortableDeviceValues, + ppData: *mut *mut IStream, + pdwOptimalWriteBufferSize: *mut DWORD, + ppszCookie: *mut LPWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2c8c6dbf, 0xe3dc, 0x4061, 0xbe, 0xcc, 0x85, 0x42, 0xe8, 0x10, 0xd1, 0x26)] +interface IPortableDeviceCapabilities(IPortableDeviceCapabilitiesVtbl): IUnknown(IUnknownVtbl) { + fn GetSupportedCommands( + ppCommands: *mut *mut IPortableDeviceKeyCollection, + ) -> HRESULT, + fn GetCommandOptions( + Command: REFPROPERTYKEY, + ppOptions: *mut *mut IPortableDeviceValues, + ) -> HRESULT, + fn GetFunctionalCategories( + ppCategories: *mut *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, + fn GetFunctionalObjects( + Category: REFGUID, + ppObjectIDs: *mut *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, + fn GetSupportedContentTypes( + Category: REFGUID, + ppContentTypes: *mut *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, + fn GetSupportedFormats( + ContentType: REFGUID, + ppFormats: *mut *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, + fn GetSupportedFormatProperties( + Format: REFGUID, + ppKeys: *mut *mut IPortableDeviceKeyCollection, + ) -> HRESULT, + fn GetFixedPropertyAttributes( + Format: REFGUID, + Key: REFPROPERTYKEY, + ppAttributes: *mut *mut IPortableDeviceValues, + ) -> HRESULT, + fn Cancel() -> HRESULT, + fn GetSupportedEvents( + ppEvents: *mut *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, + fn GetEventOptions( + Event: REFGUID, + ppOptions: *mut *mut IPortableDeviceValues, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa8792a31, 0xf385, 0x493c, 0xa8, 0x93, 0x40, 0xf6, 0x4e, 0xb4, 0x5f, 0x6e)] +interface IPortableDeviceEventCallback(IPortableDeviceEventCallbackVtbl): IUnknown(IUnknownVtbl) { + fn OnEvent( + pEventParameters: *mut IPortableDeviceValues, + ) -> HRESULT, +}} +DEFINE_GUID!{LIBID_PortableDeviceApiLib, + 0x1f001332, 0x1a57, 0x4934, 0xbe, 0x31, 0xaf, 0xfc, 0x99, 0xf4, 0xee, 0x0a} +DEFINE_GUID!{CLSID_PortableDevice, + 0x728a21c5, 0x3d9e, 0x48d7, 0x98, 0x10, 0x86, 0x48, 0x48, 0xf0, 0xf4, 0x04} +RIDL!{#[uuid(0x728a21c5, 0x3d9e, 0x48d7, 0x98, 0x10, 0x86, 0x48, 0x48, 0xf0, 0xf4, 0x04)] +class PortableDevice;} +DEFINE_GUID!{CLSID_PortableDeviceManager, + 0x0af10cec, 0x2ecd, 0x4b92, 0x95, 0x81, 0x34, 0xf6, 0xae, 0x06, 0x37, 0xf3} +RIDL!{#[uuid(0x0af10cec, 0x2ecd, 0x4b92, 0x95, 0x81, 0x34, 0xf6, 0xae, 0x06, 0x37, 0xf3)] +class PortableDeviceManager;} +DEFINE_GUID!{CLSID_PortableDeviceService, + 0xef5db4c2, 0x9312, 0x422c, 0x91, 0x52, 0x41, 0x1c, 0xd9, 0xc4, 0xdd, 0x84} +RIDL!{#[uuid(0xef5db4c2, 0x9312, 0x422c, 0x91, 0x52, 0x41, 0x1c, 0xd9, 0xc4, 0xdd, 0x84)] +class PortableDeviceService;} +DEFINE_GUID!{CLSID_PortableDeviceDispatchFactory, + 0x43232233, 0x8338, 0x4658, 0xae, 0x01, 0x0b, 0x4a, 0xe8, 0x30, 0xb6, 0xb0} +RIDL!{#[uuid(0x43232233, 0x8338, 0x4658, 0xae, 0x01, 0x0b, 0x4a, 0xe8, 0x30, 0xb6, 0xb0)] +class PortableDeviceDispatchFactory;} +DEFINE_GUID!{CLSID_PortableDeviceFTM, + 0xf7c0039a, 0x4762, 0x488a, 0xb4, 0xb3, 0x76, 0x0e, 0xf9, 0xa1, 0xba, 0x9b} +RIDL!{#[uuid(0xf7c0039a, 0x4762, 0x488a, 0xb4, 0xb3, 0x76, 0x0e, 0xf9, 0xa1, 0xba, 0x9b)] +class PortableDeviceFTM;} +DEFINE_GUID!{CLSID_PortableDeviceServiceFTM, + 0x1649b154, 0xc794, 0x497a, 0x9b, 0x03, 0xf3, 0xf0, 0x12, 0x13, 0x02, 0xf3} +RIDL!{#[uuid(0x1649b154, 0xc794, 0x497a, 0x9b, 0x03, 0xf3, 0xf0, 0x12, 0x13, 0x02, 0xf3)] +class PortableDeviceServiceFTM;} +DEFINE_GUID!{CLSID_PortableDeviceWebControl, + 0x186dd02c, 0x2dec, 0x41b5, 0xa7, 0xd4, 0xb5, 0x90, 0x56, 0xfa, 0xde, 0x51} +RIDL!{#[uuid(0x186dd02c, 0x2dec, 0x41b5, 0xa7, 0xd4, 0xb5, 0x90, 0x56, 0xfa, 0xde, 0x51)] +class PortableDeviceWebControl;} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/portabledevicetypes.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/portabledevicetypes.rs new file mode 100644 index 0000000..f6c13d3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/portabledevicetypes.rs @@ -0,0 +1,255 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of PortableDeviceTypes.h +use shared::guiddef::{GUID, REFGUID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, ULONG}; +use shared::wtypes::{PROPERTYKEY, VARTYPE}; +use um::propidl::PROPVARIANT; +use um::propkeydef::REFPROPERTYKEY; +use um::propsys::IPropertyStore; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LONG, LONGLONG, LPCWSTR, LPWSTR, ULONGLONG}; +//330 +RIDL!{#[uuid(0x6848f6f2, 0x3155, 0x4f86, 0xb6, 0xf5, 0x26, 0x3e, 0xee, 0xab, 0x31, 0x43)] +interface IPortableDeviceValues(IPortableDeviceValuesVtbl): IUnknown(IUnknownVtbl) { + fn GetCount( + pcelt: *mut DWORD, + ) -> HRESULT, + fn GetAt( + index: DWORD, + pKey: *mut PROPERTYKEY, + pValue: *mut PROPVARIANT, + ) -> HRESULT, + fn SetValue( + key: REFPROPERTYKEY, + pValue: *const PROPVARIANT, + ) -> HRESULT, + fn GetValue( + key: REFPROPERTYKEY, + pValue: *mut PROPVARIANT, + ) -> HRESULT, + fn SetStringValue( + key: REFPROPERTYKEY, + Value: LPCWSTR, + ) -> HRESULT, + fn GetStringValue( + key: REFPROPERTYKEY, + pValue: *mut LPWSTR, + ) -> HRESULT, + fn SetUnsignedIntegerValue( + key: REFPROPERTYKEY, + Value: ULONG, + ) -> HRESULT, + fn GetUnsignedIntegerValue( + key: REFPROPERTYKEY, + pValue: *mut ULONG, + ) -> HRESULT, + fn SetSignedIntegerValue( + key: REFPROPERTYKEY, + Value: LONG, + ) -> HRESULT, + fn GetSignedIntegerValue( + key: REFPROPERTYKEY, + pValue: *mut LONG, + ) -> HRESULT, + fn SetUnsignedLargeIntegerValue( + key: REFPROPERTYKEY, + Value: ULONGLONG, + ) -> HRESULT, + fn GetUnsignedLargeIntegerValue( + key: REFPROPERTYKEY, + pValue: *mut ULONGLONG, + ) -> HRESULT, + fn SetSignedLargeIntegerValue( + key: REFPROPERTYKEY, + Value: LONGLONG, + ) -> HRESULT, + fn GetSignedLargeIntegerValue( + key: REFPROPERTYKEY, + pValue: *mut LONGLONG, + ) -> HRESULT, + fn SetFloatValue( + key: REFPROPERTYKEY, + Value: FLOAT, + ) -> HRESULT, + fn GetFloatValue( + key: REFPROPERTYKEY, + pValue: *mut FLOAT, + ) -> HRESULT, + fn SetErrorValue( + key: REFPROPERTYKEY, + Value: HRESULT, + ) -> HRESULT, + fn GetErrorValue( + key: REFPROPERTYKEY, + pValue: *mut HRESULT, + ) -> HRESULT, + fn SetKeyValue( + key: REFPROPERTYKEY, + Value: REFPROPERTYKEY, + ) -> HRESULT, + fn GetKeyValue( + key: REFPROPERTYKEY, + pValue: *mut PROPERTYKEY, + ) -> HRESULT, + fn SetBoolValue( + key: REFPROPERTYKEY, + Value: BOOL, + ) -> HRESULT, + fn GetBoolValue( + key: REFPROPERTYKEY, + pValue: *mut BOOL, + ) -> HRESULT, + fn SetIUnknownValue( + key: REFPROPERTYKEY, + pValue: *mut IUnknown, + ) -> HRESULT, + fn GetIUnknownValue( + key: REFPROPERTYKEY, + ppValue: *mut *mut IUnknown, + ) -> HRESULT, + fn SetGuidValue( + key: REFPROPERTYKEY, + Value: REFGUID, + ) -> HRESULT, + fn GetGuidValue( + key: REFPROPERTYKEY, + pValue: *mut GUID, + ) -> HRESULT, + fn SetBufferValue( + key: REFPROPERTYKEY, + pValue: *mut BYTE, + cbValue: DWORD, + ) -> HRESULT, + fn GetBufferValue( + key: REFPROPERTYKEY, + ppValue: *mut *mut BYTE, + pcbValue: *mut DWORD, + ) -> HRESULT, + fn SetIPortableDeviceValuesValue( + key: REFPROPERTYKEY, + pValue: *mut IPortableDeviceValues, + ) -> HRESULT, + fn GetIPortableDeviceValuesValue( + key: REFPROPERTYKEY, + ppValue: *mut *mut IPortableDeviceValues, + ) -> HRESULT, + fn SetIPortableDevicePropVariantCollectionValue( + key: REFPROPERTYKEY, + pValue: *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, + fn GetIPortableDevicePropVariantCollectionValue( + key: REFPROPERTYKEY, + ppValue: *mut *mut IPortableDevicePropVariantCollection, + ) -> HRESULT, + fn SetIPortableDeviceKeyCollectionValue( + key: REFPROPERTYKEY, + pValue: *mut IPortableDeviceKeyCollection, + ) -> HRESULT, + fn GetIPortableDeviceKeyCollectionValue( + key: REFPROPERTYKEY, + ppValue: *mut *mut IPortableDeviceKeyCollection, + ) -> HRESULT, + fn SetIPortableDeviceValuesCollectionValue( + key: REFPROPERTYKEY, + pValue: *mut IPortableDeviceValuesCollection, + ) -> HRESULT, + fn GetIPortableDeviceValuesCollectionValue( + key: REFPROPERTYKEY, + ppValue: *mut *mut IPortableDeviceValuesCollection, + ) -> HRESULT, + fn RemoveValue( + key: REFPROPERTYKEY, + ) -> HRESULT, + fn CopyValuesFromPropertyStore( + pStore: *mut IPropertyStore, + ) -> HRESULT, + fn CopyValuesToPropertyStore( + pStore: *mut IPropertyStore, + ) -> HRESULT, + fn Clear() -> HRESULT, +}} +RIDL!{#[uuid(0xdada2357, 0xe0ad, 0x492e, 0x98, 0xdb, 0xdd, 0x61, 0xc5, 0x3b, 0xa3, 0x53)] +interface IPortableDeviceKeyCollection(IPortableDeviceKeyCollectionVtbl): IUnknown(IUnknownVtbl) { + fn GetCount( + pcElems: *mut DWORD, + ) -> HRESULT, + fn GetAt( + dwIndex: DWORD, + pKey: *mut PROPERTYKEY, + ) -> HRESULT, + fn Add( + Key: REFPROPERTYKEY, + ) -> HRESULT, + fn Clear() -> HRESULT, + fn RemoveAt( + dwIndex: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x89b2e422, 0x4f1b, 0x4316, 0xbc, 0xef, 0xa4, 0x4a, 0xfe, 0xa8, 0x3e, 0xb3)] +interface IPortableDevicePropVariantCollection(IPortableDevicePropVariantCollectionVtbl): + IUnknown(IUnknownVtbl) { + fn GetCount( + pcElems: *mut DWORD, + ) -> HRESULT, + fn GetAt( + dwIndex: DWORD, + pValue: *mut PROPVARIANT, + ) -> HRESULT, + fn Add( + pValue: *const PROPVARIANT, + ) -> HRESULT, + fn GetType( + pvt: *mut VARTYPE, + ) -> HRESULT, + fn ChangeType( + vt: VARTYPE, + ) -> HRESULT, + fn Clear() -> HRESULT, + fn RemoveAt( + dwIndex: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6e3f2d79, 0x4e07, 0x48c4, 0x82, 0x08, 0xd8, 0xc2, 0xe5, 0xaf, 0x4a, 0x99)] +interface IPortableDeviceValuesCollection(IPortableDeviceValuesCollectionVtbl): + IUnknown(IUnknownVtbl) { + fn GetCount( + pcElems: *mut DWORD, + ) -> HRESULT, + fn GetAt( + dwIndex: DWORD, + ppValues: *mut *mut IPortableDeviceValues, + ) -> HRESULT, + fn Add( + pValues: *mut IPortableDeviceValues, + ) -> HRESULT, + fn Clear() -> HRESULT, + fn RemoveAt( + dwIndex: DWORD, + ) -> HRESULT, +}} +DEFINE_GUID!{LIBID_PortableDeviceTypesLib, + 0x2B00BA2F, 0xE750, 0x4beb, 0x92, 0x35, 0x97, 0x14, 0x2E, 0xDE, 0x1D, 0x3E} +DEFINE_GUID!{CLSID_WpdSerializer, + 0x0b91a74b, 0xad7c, 0x4a9d, 0xb5, 0x63, 0x29, 0xee, 0xf9, 0x16, 0x71, 0x72} +RIDL!{#[uuid(0x0b91a74b, 0xad7c, 0x4a9d, 0xb5, 0x63, 0x29, 0xee, 0xf9, 0x16, 0x71, 0x72)] +class WpdSerializer;} +DEFINE_GUID!{CLSID_PortableDeviceValues, + 0x0c15d503, 0xd017, 0x47ce, 0x90, 0x16, 0x7b, 0x3f, 0x97, 0x87, 0x21, 0xcc} +RIDL!{#[uuid(0x0c15d503, 0xd017, 0x47ce, 0x90, 0x16, 0x7b, 0x3f, 0x97, 0x87, 0x21, 0xcc)] +class PortableDeviceValues;} +DEFINE_GUID!{CLSID_PortableDeviceKeyCollection, + 0xde2d022d, 0x2480, 0x43be, 0x97, 0xf0, 0xd1, 0xfa, 0x2c, 0xf9, 0x8f, 0x4f} +RIDL!{#[uuid(0xde2d022d, 0x2480, 0x43be, 0x97, 0xf0, 0xd1, 0xfa, 0x2c, 0xf9, 0x8f, 0x4f)] +class PortableDeviceKeyCollection;} +DEFINE_GUID!{CLSID_PortableDevicePropVariantCollection, + 0x08a99e2f, 0x6d6d, 0x4b80, 0xaf, 0x5a, 0xba, 0xf2, 0xbc, 0xbe, 0x4c, 0xb9} +RIDL!{#[uuid(0x08a99e2f, 0x6d6d, 0x4b80, 0xaf, 0x5a, 0xba, 0xf2, 0xbc, 0xbe, 0x4c, 0xb9)] +class PortableDevicePropVariantCollection;} +DEFINE_GUID!{CLSID_PortableDeviceValuesCollection, + 0x3882134d, 0x14cf, 0x4220, 0x9c, 0xb4, 0x43, 0x5f, 0x86, 0xd8, 0x3f, 0x60} +RIDL!{#[uuid(0x3882134d, 0x14cf, 0x4220, 0x9c, 0xb4, 0x43, 0x5f, 0x86, 0xd8, 0x3f, 0x60)] +class PortableDeviceValuesCollection;} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/powerbase.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/powerbase.rs new file mode 100644 index 0000000..f856fdd --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/powerbase.rs @@ -0,0 +1,35 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{DWORD, ULONG}; +use um::winnt::{ + BOOLEAN, HANDLE, LONG, POWER_INFORMATION_LEVEL, POWER_PLATFORM_ROLE, + PSYSTEM_POWER_CAPABILITIES, PVOID, +}; +use um::winuser::{HPOWERNOTIFY, PHPOWERNOTIFY}; +pub type NTSTATUS = LONG; +extern "system" { + pub fn CallNtPowerInformation( + InformationLevel: POWER_INFORMATION_LEVEL, + InputBuffer: PVOID, + InputBufferLength: ULONG, + OutputBuffer: PVOID, + OutputBufferLength: ULONG, + ) -> NTSTATUS; + pub fn GetPwrCapabilities( + lpspc: PSYSTEM_POWER_CAPABILITIES, + ) -> BOOLEAN; + pub fn PowerDeterminePlatformRoleEx( + Version: ULONG, + ) -> POWER_PLATFORM_ROLE; + pub fn PowerRegisterSuspendResumeNotification( + Flags: DWORD, + Recipient: HANDLE, + RegistrationHandle: PHPOWERNOTIFY, + ) -> DWORD; + pub fn PowerUnregisterSuspendResumeNotification( + RegistrationHandle: HPOWERNOTIFY, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/powersetting.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/powersetting.rs new file mode 100644 index 0000000..88b0c6f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/powersetting.rs @@ -0,0 +1,60 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::{GUID, LPCGUID}; +use shared::minwindef::{DWORD, HKEY, LPBYTE, LPDWORD, PUCHAR, PULONG}; +use um::winnt::HANDLE; +use um::winuser::{HPOWERNOTIFY, PHPOWERNOTIFY}; +extern "system" { + pub fn PowerReadACValue( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Type: PULONG, + Buffer: LPBYTE, + BufferSize: LPDWORD, + ) -> DWORD; + pub fn PowerReadDCValue( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Type: PULONG, + Buffer: PUCHAR, + BufferSize: LPDWORD, + ) -> DWORD; + pub fn PowerWriteACValueIndex( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + AcValueIndex: DWORD, + ) -> DWORD; + pub fn PowerWriteDCValueIndex( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + DcValueIndex: DWORD, + ) -> DWORD; + pub fn PowerGetActiveScheme( + UserRootPowerKey: HKEY, + ActivePolicyGuid: *mut *mut GUID, + ) -> DWORD; + pub fn PowerSetActiveScheme( + UserRootPowerKey: HKEY, + SchemeGuid: *const GUID, + ) -> DWORD; + pub fn PowerSettingRegisterNotification( + SettingGuid: LPCGUID, + Flags: DWORD, + Recipient: HANDLE, + RegistrationHandle: PHPOWERNOTIFY, + ) -> DWORD; + pub fn PowerSettingUnregisterNotification( + RegistrationHandle: HPOWERNOTIFY, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/powrprof.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/powrprof.rs new file mode 100644 index 0000000..d2d365f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/powrprof.rs @@ -0,0 +1,550 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Interface for powrprof.dll, the power policy applicator +use shared::guiddef::GUID; +use shared::minwindef::{ + BOOL, DWORD, HKEY, LPARAM, LPDWORD, PBYTE, PUCHAR, PUINT, PULONG, UCHAR, UINT, ULONG, +}; +use um::winnt::{ + BOOLEAN, LPCWSTR, LPWSTR, NUM_DISCHARGE_POLICIES, PADMINISTRATOR_POWER_POLICY, + POWER_ACTION_POLICY, POWER_PLATFORM_ROLE, PROCESSOR_POWER_POLICY, PVOID, SYSTEM_POWER_LEVEL, + SYSTEM_POWER_STATE, +}; +use um::winreg::REGSAM; +STRUCT!{struct GLOBAL_MACHINE_POWER_POLICY { + Revision: ULONG, + LidOpenWakeAc: SYSTEM_POWER_STATE, + LidOpenWakeDc: SYSTEM_POWER_STATE, + BroadcastCapacityResolution: ULONG, +}} +pub type PGLOBAL_MACHINE_POWER_POLICY = *mut GLOBAL_MACHINE_POWER_POLICY; +STRUCT!{struct GLOBAL_USER_POWER_POLICY { + Revision: ULONG, + PowerButtonAc: POWER_ACTION_POLICY, + PowerButtonDc: POWER_ACTION_POLICY, + SleepButtonAc: POWER_ACTION_POLICY, + SleepButtonDc: POWER_ACTION_POLICY, + LidCloseAc: POWER_ACTION_POLICY, + LidCloseDc: POWER_ACTION_POLICY, + DischargePolicy: [SYSTEM_POWER_LEVEL; NUM_DISCHARGE_POLICIES], + GlobalFlags: ULONG, +}} +pub type PGLOBAL_USER_POWER_POLICY = *mut GLOBAL_USER_POWER_POLICY; +STRUCT!{struct GLOBAL_POWER_POLICY { + user: GLOBAL_USER_POWER_POLICY, + mach: GLOBAL_MACHINE_POWER_POLICY, +}} +pub type PGLOBAL_POWER_POLICY = *mut GLOBAL_POWER_POLICY; +STRUCT!{struct MACHINE_POWER_POLICY { + Revision: ULONG, + MinSleepAc: SYSTEM_POWER_STATE, + MinSleepDc: SYSTEM_POWER_STATE, + ReducedLatencySleepAc: SYSTEM_POWER_STATE, + ReducedLatencySleepDc: SYSTEM_POWER_STATE, + DozeTimeoutAc: ULONG, + DozeTimeoutDc: ULONG, + DozeS4TimeoutAc: ULONG, + DozeS4TimeoutDc: ULONG, + MinThrottleAc: UCHAR, + MinThrottleDc: UCHAR, + pad1: [UCHAR; 2], + OverThrottledAc: POWER_ACTION_POLICY, + OverThrottledDc: POWER_ACTION_POLICY, +}} +pub type PMACHINE_POWER_POLICY = *mut MACHINE_POWER_POLICY; +STRUCT!{struct MACHINE_PROCESSOR_POWER_POLICY { + Revision: ULONG, + ProcessorPolicyAc: PROCESSOR_POWER_POLICY, + ProcessorPolicyDc: PROCESSOR_POWER_POLICY, +}} +pub type PMACHINE_PROCESSOR_POWER_POLICY = *mut MACHINE_PROCESSOR_POWER_POLICY; +STRUCT!{struct USER_POWER_POLICY { + Revision: ULONG, + IdleAc: POWER_ACTION_POLICY, + IdleDc: POWER_ACTION_POLICY, + IdleTimeoutAc: ULONG, + IdleTimeoutDc: ULONG, + IdleSensitivityAc: UCHAR, + IdleSensitivityDc: UCHAR, + ThrottlePolicyAc: UCHAR, + ThrottlePolicyDc: UCHAR, + MaxSleepAc: SYSTEM_POWER_STATE, + MaxSleepDc: SYSTEM_POWER_STATE, + Reserved: [ULONG; 2], + VideoTimeoutAc: ULONG, + VideoTimeoutDc: ULONG, + SpindownTimeoutAc: ULONG, + SpindownTimeoutDc: ULONG, + OptimizeForPowerAc: BOOLEAN, + OptimizeForPowerDc: BOOLEAN, + FanThrottleToleranceAc: UCHAR, + FanThrottleToleranceDc: UCHAR, + ForcedThrottleAc: UCHAR, + ForcedThrottleDc: UCHAR, +}} +pub type PUSER_POWER_POLICY = *mut USER_POWER_POLICY; +STRUCT!{struct POWER_POLICY { + user: USER_POWER_POLICY, + mach: MACHINE_POWER_POLICY, +}} +pub type PPOWER_POLICY = *mut POWER_POLICY; +pub const EnableSysTrayBatteryMeter: ULONG = 0x01; +pub const EnableMultiBatteryDisplay: ULONG = 0x02; +pub const EnablePasswordLogon: ULONG = 0x04; +pub const EnableWakeOnRing: ULONG = 0x08; +pub const EnableVideoDimDisplay: ULONG = 0x10; +pub const POWER_ATTRIBUTE_HIDE: ULONG = 0x00000001; +pub const POWER_ATTRIBUTE_SHOW_AOAC: ULONG = 0x00000002; +pub const NEWSCHEME: UINT = -1i32 as u32; +FN!{stdcall PWRSCHEMESENUMPROC_V1( + Index: UINT, + NameSize: DWORD, + Name: LPWSTR, + DescriptionSize: DWORD, + Description: LPWSTR, + Policy: PPOWER_POLICY, + Context: LPARAM, +) -> BOOLEAN} +FN!{stdcall PWRSCHEMESENUMPROC_V2( + Index: UINT, + NameSize: DWORD, + Name: LPWSTR, + DescriptionSize: DWORD, + Description: LPWSTR, + Policy: PPOWER_POLICY, + Context: LPARAM, +) -> BOOLEAN} +pub type PWRSCHEMESENUMPROC = *mut PWRSCHEMESENUMPROC_V2; +extern "system" { + pub fn GetPwrDiskSpindownRange( + puiMax: PUINT, + puiMin: PUINT, + ) -> BOOLEAN; + pub fn EnumPwrSchemes( + lpfn: PWRSCHEMESENUMPROC, + lParam: LPARAM, + ) -> BOOLEAN; + pub fn ReadGlobalPwrPolicy( + pGlobalPowerPolicy: PGLOBAL_POWER_POLICY, + ) -> BOOLEAN; + pub fn ReadPwrScheme( + uiID: UINT, + pPowerPolicy: PPOWER_POLICY, + ) -> BOOLEAN; + pub fn WritePwrScheme( + puiID: PUINT, + lpszSchemeName: LPCWSTR, + lpszDescription: LPCWSTR, + lpScheme: PPOWER_POLICY, + ) -> BOOLEAN; + pub fn WriteGlobalPwrPolicy( + pGlobalPowerPolicy: PGLOBAL_POWER_POLICY, + ) -> BOOLEAN; + pub fn DeletePwrScheme( + uiID: UINT, + ) -> BOOLEAN; + pub fn GetActivePwrScheme( + puiID: PUINT, + ) -> BOOLEAN; + pub fn SetActivePwrScheme( + uiID: UINT, + pGlobalPowerPolicy: PGLOBAL_POWER_POLICY, + pPowerPolicy: PPOWER_POLICY, + ) -> BOOLEAN; + pub fn IsPwrSuspendAllowed() -> BOOLEAN; + pub fn IsPwrHibernateAllowed() -> BOOLEAN; + pub fn IsPwrShutdownAllowed() -> BOOLEAN; + pub fn IsAdminOverrideActive( + papp: PADMINISTRATOR_POWER_POLICY, + ) -> BOOLEAN; + pub fn SetSuspendState( + bHibernate: BOOLEAN, + bForce: BOOLEAN, + bWakeupEventsDisabled: BOOLEAN, + ) -> BOOLEAN; + pub fn GetCurrentPowerPolicies( + pGlobalPowerPolicy: PGLOBAL_POWER_POLICY, + pPowerPolicy: PPOWER_POLICY, + ) -> BOOLEAN; + pub fn CanUserWritePwrScheme() -> BOOLEAN; + pub fn ReadProcessorPwrScheme( + uiID: UINT, + pMachineProcessorPowerPolicy: PMACHINE_PROCESSOR_POWER_POLICY, + ) -> BOOLEAN; + pub fn WriteProcessorPwrScheme( + uiID: UINT, + pMachineProcessorPowerPolicy: PMACHINE_PROCESSOR_POWER_POLICY, + ) -> BOOLEAN; + pub fn ValidatePowerPolicies( + pGlobalPowerPolicy: PGLOBAL_POWER_POLICY, + pPowerPolicy: PPOWER_POLICY, + ) -> BOOLEAN; +} +ENUM!{enum POWER_DATA_ACCESSOR { + ACCESS_AC_POWER_SETTING_INDEX = 0, + ACCESS_DC_POWER_SETTING_INDEX, + ACCESS_FRIENDLY_NAME, + ACCESS_DESCRIPTION, + ACCESS_POSSIBLE_POWER_SETTING, + ACCESS_POSSIBLE_POWER_SETTING_FRIENDLY_NAME, + ACCESS_POSSIBLE_POWER_SETTING_DESCRIPTION, + ACCESS_DEFAULT_AC_POWER_SETTING, + ACCESS_DEFAULT_DC_POWER_SETTING, + ACCESS_POSSIBLE_VALUE_MIN, + ACCESS_POSSIBLE_VALUE_MAX, + ACCESS_POSSIBLE_VALUE_INCREMENT, + ACCESS_POSSIBLE_VALUE_UNITS, + ACCESS_ICON_RESOURCE, + ACCESS_DEFAULT_SECURITY_DESCRIPTOR, + ACCESS_ATTRIBUTES, + ACCESS_SCHEME, + ACCESS_SUBGROUP, + ACCESS_INDIVIDUAL_SETTING, + ACCESS_ACTIVE_SCHEME, + ACCESS_CREATE_SCHEME, + ACCESS_AC_POWER_SETTING_MAX, + ACCESS_DC_POWER_SETTING_MAX, + ACCESS_AC_POWER_SETTING_MIN, + ACCESS_DC_POWER_SETTING_MIN, + ACCESS_PROFILE, + ACCESS_OVERLAY_SCHEME, + ACCESS_ACTIVE_OVERLAY_SCHEME, +}} +pub type PPOWER_DATA_ACCESSOR = *mut POWER_DATA_ACCESSOR; +pub const DEVICE_NOTIFY_CALLBACK: ULONG = 2; +FN!{stdcall DEVICE_NOTIFY_CALLBACK_ROUTINE( + Context: PVOID, + Type: ULONG, + Setting: PVOID, +) -> ULONG} +pub type PDEVICE_NOTIFY_CALLBACK_ROUTINE = *mut DEVICE_NOTIFY_CALLBACK_ROUTINE; +STRUCT!{struct DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS { + Callback: PDEVICE_NOTIFY_CALLBACK_ROUTINE, + Context: PVOID, +}} +pub type PDEVICE_NOTIFY_SUBSCRIBE_PARAMETERS = *mut DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS; +extern "system" { + pub fn PowerIsSettingRangeDefined( + SubKeyGuid: *const GUID, + SettingGuid: *const GUID, + ) -> BOOLEAN; + pub fn PowerSettingAccessCheckEx( + AccessFlags: POWER_DATA_ACCESSOR, + PowerGuid: *const GUID, + AccessType: REGSAM, + ) -> DWORD; + pub fn PowerSettingAccessCheck( + AccessFlags: POWER_DATA_ACCESSOR, + PowerGuid: *const GUID, + ) -> DWORD; + pub fn PowerReadACValueIndex( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + AcValueIndex: LPDWORD, + ) -> DWORD; + pub fn PowerReadDCValueIndex( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + DcValueIndex: LPDWORD, + ) -> DWORD; + pub fn PowerReadFriendlyName( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Buffer: PUCHAR, + BufferSize: LPDWORD, + ) -> DWORD; + pub fn PowerReadDescription( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Buffer: PUCHAR, + BufferSize: LPDWORD, + ) -> DWORD; + pub fn PowerReadPossibleValue( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Type: PULONG, + PossibleSettingIndex: ULONG, + Buffer: PUCHAR, + BufferSize: LPDWORD, + ) -> DWORD; + pub fn PowerReadPossibleFriendlyName( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + PossibleSettingIndex: ULONG, + Buffer: PUCHAR, + BufferSize: LPDWORD, + ) -> DWORD; + pub fn PowerReadPossibleDescription( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + PossibleSettingIndex: ULONG, + Buffer: PUCHAR, + BufferSize: LPDWORD, + ) -> DWORD; + pub fn PowerReadValueMin( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + ValueMinimum: LPDWORD, + ) -> DWORD; + pub fn PowerReadValueMax( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + ValueMaximum: LPDWORD, + ) -> DWORD; + pub fn PowerReadValueIncrement( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + ValueIncrement: LPDWORD, + ) -> DWORD; + pub fn PowerReadValueUnitsSpecifier( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Buffer: *mut UCHAR, + BufferSize: LPDWORD, + ) -> DWORD; + pub fn PowerReadACDefaultIndex( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + AcDefaultIndex: LPDWORD, + ) -> DWORD; + pub fn PowerReadDCDefaultIndex( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + DcDefaultIndex: LPDWORD, + ) -> DWORD; + pub fn PowerReadIconResourceSpecifier( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Buffer: PUCHAR, + BufferSize: LPDWORD, + ) -> DWORD; + pub fn PowerReadSettingAttributes( + SubGroupGuid: *const GUID, + PowerSettingGuid: *const GUID, + ) -> DWORD; + pub fn PowerWriteFriendlyName( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Buffer: *mut UCHAR, + BufferSize: DWORD, + ) -> DWORD; + pub fn PowerWriteDescription( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Buffer: *mut UCHAR, + BufferSize: DWORD, + ) -> DWORD; + pub fn PowerWritePossibleValue( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Type: ULONG, + PossibleSettingIndex: ULONG, + Buffer: *mut UCHAR, + BufferSize: DWORD, + ) -> DWORD; + pub fn PowerWritePossibleFriendlyName( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + PossibleSettingIndex: ULONG, + Buffer: *mut UCHAR, + BufferSize: DWORD, + ) -> DWORD; + pub fn PowerWritePossibleDescription( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + PossibleSettingIndex: ULONG, + Buffer: *mut UCHAR, + BufferSize: DWORD, + ) -> DWORD; + pub fn PowerWriteValueMin( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + ValueMinimum: DWORD, + ) -> DWORD; + pub fn PowerWriteValueMax( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + ValueMaximum: DWORD, + ) -> DWORD; + pub fn PowerWriteValueIncrement( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + ValueIncrement: DWORD, + ) -> DWORD; + pub fn PowerWriteValueUnitsSpecifier( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Buffer: *mut UCHAR, + BufferSize: DWORD, + ) -> DWORD; + pub fn PowerWriteACDefaultIndex( + RootSystemPowerKey: HKEY, + SchemePersonalityGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + DefaultAcIndex: DWORD, + ) -> DWORD; + pub fn PowerWriteDCDefaultIndex( + RootSystemPowerKey: HKEY, + SchemePersonalityGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + DefaultDcIndex: DWORD, + ) -> DWORD; + pub fn PowerWriteIconResourceSpecifier( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + Buffer: *mut UCHAR, + BufferSize: DWORD, + ) -> DWORD; + pub fn PowerWriteSettingAttributes( + SubGroupGuid: *const GUID, + PowerSettingGuid: *const GUID, + Attributes: DWORD, + ) -> DWORD; + pub fn PowerDuplicateScheme( + RootPowerKey: HKEY, + SourceSchemeGuid: *const GUID, + DestinationSchemeGuid: *mut *mut GUID, + ) -> DWORD; + pub fn PowerImportPowerScheme( + RootPowerKey: HKEY, + ImportFileNamePath: LPCWSTR, + DestinationSchemeGuid: *mut *mut GUID, + ) -> DWORD; + pub fn PowerDeleteScheme( + RootPowerKey: HKEY, + SchemeGuid: *mut GUID, + ) -> DWORD; + pub fn PowerRemovePowerSetting( + PowerSettingSubKeyGuid: *const GUID, + PowerSettingGuid: *const GUID, + ) -> DWORD; + pub fn PowerCreateSetting( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + ) -> DWORD; + pub fn PowerCreatePossibleSetting( + RootPowerKey: HKEY, + SubGroupOfPowerSettingsGuid: *const GUID, + PowerSettingGuid: *const GUID, + PossibleSettingIndex: ULONG, + ) -> DWORD; + pub fn PowerEnumerate( + RootPowerKey: HKEY, + SchemeGuid: *const GUID, + SubGroupOfPowerSettingsGuid: *const GUID, + AccessFlags: POWER_DATA_ACCESSOR, + Index: ULONG, + Buffer: *mut UCHAR, + BufferSize: *mut DWORD, + ) -> DWORD; + pub fn PowerOpenUserPowerKey( + phUserPowerKey: *mut HKEY, + Access: REGSAM, + OpenExisting: BOOL, + ) -> DWORD; + pub fn PowerOpenSystemPowerKey( + phSystemPowerKey: *mut HKEY, + Access: REGSAM, + OpenExisting: BOOL, + ) -> DWORD; + pub fn PowerCanRestoreIndividualDefaultPowerScheme( + SchemeGuid: *const GUID, + ) -> DWORD; + pub fn PowerRestoreIndividualDefaultPowerScheme( + SchemeGuid: *const GUID, + ) -> DWORD; + pub fn PowerRestoreDefaultPowerSchemes() -> DWORD; + pub fn PowerReplaceDefaultPowerSchemes() -> DWORD; + pub fn PowerDeterminePlatformRole() -> POWER_PLATFORM_ROLE; +} +pub const DEVICEPOWER_HARDWAREID: ULONG = 0x80000000; +pub const DEVICEPOWER_AND_OPERATION: ULONG = 0x40000000; +pub const DEVICEPOWER_FILTER_DEVICES_PRESENT: ULONG = 0x20000000; +pub const DEVICEPOWER_FILTER_HARDWARE: ULONG = 0x10000000; +pub const DEVICEPOWER_FILTER_WAKEENABLED: ULONG = 0x08000000; +pub const DEVICEPOWER_FILTER_WAKEPROGRAMMABLE: ULONG = 0x04000000; +pub const DEVICEPOWER_FILTER_ON_NAME: ULONG = 0x02000000; +pub const DEVICEPOWER_SET_WAKEENABLED: ULONG = 0x00000001; +pub const DEVICEPOWER_CLEAR_WAKEENABLED: ULONG = 0x00000002; +pub const PDCAP_S0_SUPPORTED: ULONG = 0x00010000; +pub const PDCAP_S1_SUPPORTED: ULONG = 0x00020000; +pub const PDCAP_S2_SUPPORTED: ULONG = 0x00040000; +pub const PDCAP_S3_SUPPORTED: ULONG = 0x00080000; +pub const PDCAP_WAKE_FROM_S0_SUPPORTED: ULONG = 0x00100000; +pub const PDCAP_WAKE_FROM_S1_SUPPORTED: ULONG = 0x00200000; +pub const PDCAP_WAKE_FROM_S2_SUPPORTED: ULONG = 0x00400000; +pub const PDCAP_WAKE_FROM_S3_SUPPORTED: ULONG = 0x00800000; +pub const PDCAP_S4_SUPPORTED: ULONG = 0x01000000; +pub const PDCAP_S5_SUPPORTED: ULONG = 0x02000000; +extern "system" { + pub fn DevicePowerEnumDevices( + QueryIndex: ULONG, + QueryInterpretationFlags: ULONG, + QueryFlags: ULONG, + pReturnBuffer: PBYTE, + pBufferSize: PULONG, + ) -> BOOLEAN; + pub fn DevicePowerSetDeviceState( + DeviceDescription: LPCWSTR, + SetFlags: ULONG, + SetData: PVOID, + ) -> DWORD; + pub fn DevicePowerOpen( + DebugMask: ULONG, + ) -> BOOLEAN; + pub fn DevicePowerClose() -> BOOLEAN; +} +STRUCT!{struct THERMAL_EVENT { + Version: ULONG, + Size: ULONG, + Type: ULONG, + Temperature: ULONG, + TripPointTemperature: ULONG, + Initiator: LPWSTR, +}} +pub type PTHERMAL_EVENT = *mut THERMAL_EVENT; +extern "system" { + pub fn PowerReportThermalEvent( + Event: PTHERMAL_EVENT, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/processenv.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/processenv.rs new file mode 100644 index 0000000..8ecb5e0 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/processenv.rs @@ -0,0 +1,98 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, DWORD}; +use um::winnt::{HANDLE, LPCH, LPCSTR, LPCWSTR, LPSTR, LPWCH, LPWSTR, PHANDLE}; +extern "system" { + pub fn GetEnvironmentStrings() -> LPCH; + pub fn GetEnvironmentStringsW() -> LPWCH; + pub fn SetEnvironmentStringsW( + NewEnvironment: LPWCH, + ) -> BOOL; + pub fn FreeEnvironmentStringsA( + penv: LPCH, + ) -> BOOL; + pub fn FreeEnvironmentStringsW( + penv: LPWCH, + ) -> BOOL; + pub fn GetStdHandle( + nStdHandle: DWORD, + ) -> HANDLE; + pub fn SetStdHandle( + nStdHandle: DWORD, + hHandle: HANDLE, + ) -> BOOL; + pub fn SetStdHandleEx( + nStdHandle: DWORD, + hHandle: HANDLE, + phPrevValue: PHANDLE, + ) -> BOOL; + pub fn GetCommandLineA() -> LPSTR; + pub fn GetCommandLineW() -> LPWSTR; + pub fn GetEnvironmentVariableA( + lpName: LPCSTR, + lpBuffer: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetEnvironmentVariableW( + lpName: LPCWSTR, + lpBuffer: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn SetEnvironmentVariableA( + lpName: LPCSTR, + lpValue: LPCSTR, + ) -> BOOL; + pub fn SetEnvironmentVariableW( + lpName: LPCWSTR, + lpValue: LPCWSTR, + ) -> BOOL; + pub fn ExpandEnvironmentStringsA( + lpSrc: LPCSTR, + lpDst: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn ExpandEnvironmentStringsW( + lpSrc: LPCWSTR, + lpDst: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn SetCurrentDirectoryA( + lpPathName: LPCSTR, + ) -> BOOL; + pub fn SetCurrentDirectoryW( + lpPathName: LPCWSTR, + ) -> BOOL; + pub fn GetCurrentDirectoryA( + nBufferLength: DWORD, + lpBuffer: LPSTR, + ) -> DWORD; + pub fn GetCurrentDirectoryW( + nBufferLength: DWORD, + lpBuffer: LPWSTR, + ) -> DWORD; + pub fn SearchPathW( + lpPath: LPCWSTR, + lpFileName: LPCWSTR, + lpExtension: LPCWSTR, + nBufferLength: DWORD, + lpBuffer: LPWSTR, + lpFilePart: *mut LPWSTR, + ) -> DWORD; + pub fn SearchPathA( + lpPath: LPCSTR, + lpFileName: LPCSTR, + lpExtension: LPCSTR, + nBufferLength: DWORD, + lpBuffer: LPSTR, + lpFilePart: *mut LPSTR, + ) -> DWORD; + pub fn NeedCurrentDirectoryForExePathA( + ExeName: LPCSTR, + ) -> BOOL; + pub fn NeedCurrentDirectoryForExePathW( + ExeName: LPCWSTR, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/processsnapshot.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/processsnapshot.rs new file mode 100644 index 0000000..c49aac6 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/processsnapshot.rs @@ -0,0 +1,120 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Defines the process snapshot API +use ctypes::c_void; +use shared::basetsd::ULONG_PTR; +use shared::minwindef::DWORD; +use um::winnt::HANDLE; +ENUM!{enum PSS_CAPTURE_FLAGS { + PSS_CAPTURE_NONE = 0x00000000, + PSS_CAPTURE_VA_CLONE = 0x00000001, + PSS_CAPTURE_RESERVED_00000002 = 0x00000002, + PSS_CAPTURE_HANDLES = 0x00000004, + PSS_CAPTURE_HANDLE_NAME_INFORMATION = 0x00000008, + PSS_CAPTURE_HANDLE_BASIC_INFORMATION = 0x00000010, + PSS_CAPTURE_HANDLE_TYPE_SPECIFIC_INFORMATION = 0x00000020, + PSS_CAPTURE_HANDLE_TRACE = 0x00000040, + PSS_CAPTURE_THREADS = 0x00000080, + PSS_CAPTURE_THREAD_CONTEXT = 0x00000100, + PSS_CAPTURE_THREAD_CONTEXT_EXTENDED = 0x00000200, + PSS_CAPTURE_RESERVED_00000400 = 0x00000400, + PSS_CAPTURE_VA_SPACE = 0x00000800, + PSS_CAPTURE_VA_SPACE_SECTION_INFORMATION = 0x00001000, + PSS_CREATE_BREAKAWAY_OPTIONAL = 0x04000000, + PSS_CREATE_BREAKAWAY = 0x08000000, + PSS_CREATE_FORCE_BREAKAWAY = 0x10000000, + PSS_CREATE_USE_VM_ALLOCATIONS = 0x20000000, + PSS_CREATE_MEASURE_PERFORMANCE = 0x40000000, + PSS_CREATE_RELEASE_SECTION = 0x80000000, +}} +ENUM!{enum PSS_QUERY_INFORMATION_CLASS { + PSS_QUERY_PROCESS_INFORMATION = 0, + PSS_QUERY_VA_CLONE_INFORMATION = 1, + PSS_QUERY_AUXILIARY_PAGES_INFORMATION = 2, + PSS_QUERY_VA_SPACE_INFORMATION = 3, + PSS_QUERY_HANDLE_INFORMATION = 4, + PSS_QUERY_THREAD_INFORMATION = 5, + PSS_QUERY_HANDLE_TRACE_INFORMATION = 6, + PSS_QUERY_PERFORMANCE_COUNTERS = 7, +}} +ENUM!{enum PSS_WALK_INFORMATION_CLASS { + PSS_WALK_AUXILIARY_PAGES = 0, + PSS_WALK_VA_SPACE = 1, + PSS_WALK_HANDLES = 2, + PSS_WALK_THREADS = 3, +}} +ENUM!{enum PSS_DUPLICATE_FLAGS { + PSS_DUPLICATE_NONE = 0x00, + PSS_DUPLICATE_CLOSE_SOURCE = 0x01, +}} +DECLARE_HANDLE!{HPSS, HPSS__} +DECLARE_HANDLE!{HPSSWALK, HPSSWALK__} +FN!{stdcall pAllocRoutine( + Context: *mut c_void, + Size: DWORD, +) -> *mut c_void} +FN!{stdcall pFreeRoutine( + Context: *mut c_void, + Address: *mut c_void, +) -> ()} +STRUCT!{struct PSS_ALLOCATOR { + Context: *mut c_void, + AllocRoutine: pAllocRoutine, + FreeRoutine: pFreeRoutine, +}} +extern "system" { + pub fn PssCaptureSnapshot( + ProcessHandle: HANDLE, + CaptureFlags: PSS_CAPTURE_FLAGS, + ThreadContextFlags: DWORD, + SnapshotHandle: *mut HPSS, + ) -> DWORD; + pub fn PssDuplicateSnapshot( + SourceProcessHandle: HANDLE, + SnapshotHandle: HPSS, + TargetProcessHandle: HANDLE, + TargetSnapshotHandle: *mut HPSS, + Flags: PSS_DUPLICATE_FLAGS, + ) -> DWORD; + pub fn PssFreeSnapshot( + ProcessHandle: HANDLE, + SnapshotHandle: HPSS, + ) -> DWORD; + pub fn PssQuerySnapshot( + SnapshotHandle: HPSS, + InformationClass: PSS_QUERY_INFORMATION_CLASS, + Buffer: *mut c_void, + BufferLength: DWORD, + ) -> DWORD; + pub fn PssWalkMarkerCreate( + Allocator: *const PSS_ALLOCATOR, + WalkMarkerHandle: *mut HPSSWALK, + ) -> DWORD; + pub fn PssWalkMarkerFree( + WalkMarkerHandle: HPSSWALK, + ) -> DWORD; + pub fn PssWalkMarkerGetPosition( + WalkMarkerHandle: HPSSWALK, + Position: *mut ULONG_PTR, + ) -> DWORD; + // pub fn PssWalkMarkerRewind(); + // pub fn PssWalkMarkerSeek(); + pub fn PssWalkMarkerSeekToBeginning( + WalkMarkerHandle: HPSS, + ) -> DWORD; + pub fn PssWalkMarkerSetPosition( + WalkMarkerHandle: HPSSWALK, + Position: ULONG_PTR, + ) -> DWORD; + // pub fn PssWalkMarkerTell(); + pub fn PssWalkSnapshot( + SnapshotHandle: HPSS, + InformationClass: PSS_WALK_INFORMATION_CLASS, + WalkMarkerHandle: HPSSWALK, + Buffer: *mut c_void, + BufferLength: DWORD, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/processthreadsapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/processthreadsapi.rs new file mode 100644 index 0000000..9629ee8 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/processthreadsapi.rs @@ -0,0 +1,441 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! ApiSet Contract for api-ms-win-core-processthreads-l1 +use ctypes::{c_int, c_void}; +use shared::basetsd::{DWORD_PTR, PSIZE_T, PULONG_PTR, SIZE_T, ULONG_PTR}; +use shared::guiddef::LPCGUID; +use shared::minwindef::{ + BOOL, DWORD, LPBYTE, LPCVOID, LPDWORD, LPFILETIME, LPVOID, PBOOL, PDWORD, PULONG, UINT, WORD +}; +use um::minwinbase::{LPCONTEXT, LPSECURITY_ATTRIBUTES, LPTHREAD_START_ROUTINE}; +use um::winnt::{ + CONTEXT, HANDLE, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PAPCFUNC, PHANDLE, PPROCESSOR_NUMBER, + PROCESS_MITIGATION_POLICY, PVOID +}; +STRUCT!{struct PROCESS_INFORMATION { + hProcess: HANDLE, + hThread: HANDLE, + dwProcessId: DWORD, + dwThreadId: DWORD, +}} +pub type PPROCESS_INFORMATION = *mut PROCESS_INFORMATION; +pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; +STRUCT!{struct STARTUPINFOA { + cb: DWORD, + lpReserved: LPSTR, + lpDesktop: LPSTR, + lpTitle: LPSTR, + dwX: DWORD, + dwY: DWORD, + dwXSize: DWORD, + dwYSize: DWORD, + dwXCountChars: DWORD, + dwYCountChars: DWORD, + dwFillAttribute: DWORD, + dwFlags: DWORD, + wShowWindow: WORD, + cbReserved2: WORD, + lpReserved2: LPBYTE, + hStdInput: HANDLE, + hStdOutput: HANDLE, + hStdError: HANDLE, +}} +pub type LPSTARTUPINFOA = *mut STARTUPINFOA; +STRUCT!{struct STARTUPINFOW { + cb: DWORD, + lpReserved: LPWSTR, + lpDesktop: LPWSTR, + lpTitle: LPWSTR, + dwX: DWORD, + dwY: DWORD, + dwXSize: DWORD, + dwYSize: DWORD, + dwXCountChars: DWORD, + dwYCountChars: DWORD, + dwFillAttribute: DWORD, + dwFlags: DWORD, + wShowWindow: WORD, + cbReserved2: WORD, + lpReserved2: LPBYTE, + hStdInput: HANDLE, + hStdOutput: HANDLE, + hStdError: HANDLE, +}} +pub type LPSTARTUPINFOW = *mut STARTUPINFOW; +extern "system" { + pub fn QueueUserAPC( + pfnAPC: PAPCFUNC, + hThread: HANDLE, + dwData: ULONG_PTR, + ) -> DWORD; + pub fn GetProcessTimes( + hProcess: HANDLE, + lpCreationTime: LPFILETIME, + lpExitTime: LPFILETIME, + lpKernelTime: LPFILETIME, + lpUserTime: LPFILETIME, + ) -> BOOL; + pub fn GetCurrentProcess() -> HANDLE; + pub fn GetCurrentProcessId() -> DWORD; + pub fn ExitProcess( + uExitCode: UINT, + ); + pub fn TerminateProcess( + hProcess: HANDLE, + uExitCode: UINT, + ) -> BOOL; + pub fn GetExitCodeProcess( + hProcess: HANDLE, + lpExitCode: LPDWORD, + ) -> BOOL; + pub fn SwitchToThread() -> BOOL; + pub fn CreateThread( + lpThreadAttributes: LPSECURITY_ATTRIBUTES, + dwStackSize: SIZE_T, + lpStartAddress: LPTHREAD_START_ROUTINE, + lpParameter: LPVOID, + dwCreationFlags: DWORD, + lpThreadId: LPDWORD, + ) -> HANDLE; + pub fn CreateRemoteThread( + hProcess: HANDLE, + lpThreadAttributes: LPSECURITY_ATTRIBUTES, + dwStackSize: SIZE_T, + lpStartAddress: LPTHREAD_START_ROUTINE, + lpParameter: LPVOID, + dwCreationFlags: DWORD, + lpThreadId: LPDWORD, + ) -> HANDLE; + pub fn GetCurrentThread() -> HANDLE; + pub fn GetCurrentThreadId() -> DWORD; + pub fn OpenThread( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwThreadId: DWORD, + ) -> HANDLE; + pub fn SetThreadPriority( + hThread: HANDLE, + nPriority: c_int, + ) -> BOOL; + pub fn SetThreadPriorityBoost( + hThread: HANDLE, + bDisablePriorityBoost: BOOL, + ) -> BOOL; + pub fn GetThreadPriorityBoost( + hThread: HANDLE, + pDisablePriorityBoost: PBOOL, + ) -> BOOL; + pub fn GetThreadPriority( + hThread: HANDLE, + ) -> c_int; + pub fn ExitThread( + dwExitCode: DWORD, + ); + pub fn TerminateThread( + hThread: HANDLE, + dwExitCode: DWORD, + ) -> BOOL; + pub fn GetExitCodeThread( + hThread: HANDLE, + lpExitCode: LPDWORD, + ) -> BOOL; + pub fn SuspendThread( + hThread: HANDLE, + ) -> DWORD; + pub fn ResumeThread( + hThread: HANDLE, + ) -> DWORD; +} +pub const TLS_OUT_OF_INDEXES: DWORD = 0xFFFFFFFF; +extern "system" { + pub fn TlsAlloc() -> DWORD; + pub fn TlsGetValue( + dwTlsIndex: DWORD, + ) -> LPVOID; + pub fn TlsSetValue( + dwTlsIndex: DWORD, + lpTlsValue: LPVOID, + ) -> BOOL; + pub fn TlsFree( + dwTlsIndex: DWORD, + ) -> BOOL; + pub fn CreateProcessA( + lpApplicationName: LPCSTR, + lpCommandLine: LPSTR, + lpProcessAttributes: LPSECURITY_ATTRIBUTES, + lpThreadAttributes: LPSECURITY_ATTRIBUTES, + bInheritHandles: BOOL, + dwCreationFlags: DWORD, + lpEnvironment: LPVOID, + lpCurrentDirectory: LPCSTR, + lpStartupInfo: LPSTARTUPINFOA, + lpProcessInformation: LPPROCESS_INFORMATION, + ) -> BOOL; + pub fn CreateProcessW( + lpApplicationName: LPCWSTR, + lpCommandLine: LPWSTR, + lpProcessAttributes: LPSECURITY_ATTRIBUTES, + lpThreadAttributes: LPSECURITY_ATTRIBUTES, + bInheritHandles: BOOL, + dwCreationFlags: DWORD, + lpEnvironment: LPVOID, + lpCurrentDirectory: LPCWSTR, + lpStartupInfo: LPSTARTUPINFOW, + lpProcessInformation: LPPROCESS_INFORMATION, + ) -> BOOL; + pub fn SetProcessShutdownParameters( + dwLevel: DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn GetProcessVersion( + ProcessId: DWORD, + ) -> DWORD; + pub fn GetStartupInfoW( + lpStartupInfo: LPSTARTUPINFOW, + ); + pub fn CreateProcessAsUserW( + hToken: HANDLE, + lpApplicationName: LPCWSTR, + lpCommandLine: LPWSTR, + lpProcessAttributes: LPSECURITY_ATTRIBUTES, + lpThreadAttributes: LPSECURITY_ATTRIBUTES, + bInheritHandles: BOOL, + dwCreationFlags: DWORD, + lpEnvironment: LPVOID, + lpCurrentDirectory: LPCWSTR, + lpStartupInfo: LPSTARTUPINFOW, + lpProcessInformation: LPPROCESS_INFORMATION, + ) -> BOOL; + // pub fn GetCurrentProcessToken(); + // pub fn GetCurrentThreadToken(); + // pub fn GetCurrentThreadEffectiveToken(); + pub fn SetThreadToken( + Thread: PHANDLE, + Token: HANDLE, + ) -> BOOL; + pub fn OpenProcessToken( + ProcessHandle: HANDLE, + DesiredAccess: DWORD, + TokenHandle: PHANDLE, + ) -> BOOL; + pub fn OpenThreadToken( + ThreadHandle: HANDLE, + DesiredAccess: DWORD, + OpenAsSelf: BOOL, + TokenHandle: PHANDLE, + ) -> BOOL; + pub fn SetPriorityClass( + hProcess: HANDLE, + dwPriorityClass: DWORD, + ) -> BOOL; + pub fn SetThreadStackGuarantee( + StackSizeInBytes: PULONG, + ) -> BOOL; + pub fn GetPriorityClass( + hProcess: HANDLE, + ) -> DWORD; + pub fn ProcessIdToSessionId( + dwProcessId: DWORD, + pSessionId: *mut DWORD, + ) -> BOOL; + pub fn GetProcessId( + Process: HANDLE, + ) -> DWORD; +} +STRUCT!{struct PROC_THREAD_ATTRIBUTE_LIST { + dummy: *mut c_void, +}} +pub type PPROC_THREAD_ATTRIBUTE_LIST = *mut PROC_THREAD_ATTRIBUTE_LIST; +pub type LPPROC_THREAD_ATTRIBUTE_LIST = *mut PROC_THREAD_ATTRIBUTE_LIST; +extern "system" { + pub fn GetThreadId( + Thread: HANDLE, + ) -> DWORD; + pub fn FlushProcessWriteBuffers(); + pub fn GetProcessIdOfThread( + Thread: HANDLE, + ) -> DWORD; + pub fn InitializeProcThreadAttributeList( + lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, + dwAttributeCount: DWORD, + dwFlags: DWORD, + lpSize: PSIZE_T, + ) -> BOOL; + pub fn DeleteProcThreadAttributeList( + lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, + ); + pub fn SetProcessAffinityUpdateMode( + hProcess: HANDLE, + dwFlags: DWORD, + ) -> BOOL; + pub fn QueryProcessAffinityUpdateMode( + hProcess: HANDLE, + lpdwFlags: LPDWORD, + ) -> BOOL; + pub fn UpdateProcThreadAttribute( + lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, + dwFlags: DWORD, + Attribute: DWORD_PTR, + lpValue: PVOID, + cbSize: SIZE_T, + lpPreviousValue: PVOID, + lpReturnSize: PSIZE_T, + ) -> BOOL; + pub fn CreateRemoteThreadEx( + hProcess: HANDLE, + lpThreadAttributes: LPSECURITY_ATTRIBUTES, + dwStackSize: SIZE_T, + lpStartAddress: LPTHREAD_START_ROUTINE, + lpParameter: LPVOID, + dwCreationFlags: DWORD, + lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, + lpThreadId: LPDWORD, + ) -> HANDLE; + pub fn GetCurrentThreadStackLimits( + LowLimit: PULONG_PTR, + HighLimit: PULONG_PTR, + ); + pub fn GetThreadContext( + hThread: HANDLE, + lpContext: LPCONTEXT, + ) -> BOOL; + pub fn SetThreadContext( + hThread: HANDLE, + lpContext: *const CONTEXT, + ) -> BOOL; + pub fn SetProcessMitigationPolicy( + MitigationPolicy: PROCESS_MITIGATION_POLICY, + lpBuffer: PVOID, + dwLength: SIZE_T, + ) -> BOOL; + pub fn GetProcessMitigationPolicy( + hProcess: HANDLE, + MitigationPolicy: PROCESS_MITIGATION_POLICY, + lpBuffer: PVOID, + dwLength: SIZE_T, + ) -> BOOL; + pub fn FlushInstructionCache( + hProcess: HANDLE, + lpBaseAddress: LPCVOID, + dwSize: SIZE_T, + ) -> BOOL; + pub fn GetThreadTimes( + hThread: HANDLE, + lpCreationTime: LPFILETIME, + lpExitTime: LPFILETIME, + lpKernelTime: LPFILETIME, + lpUserTime: LPFILETIME, + ) -> BOOL; + pub fn OpenProcess( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwProcessId: DWORD, + ) -> HANDLE; + pub fn IsProcessorFeaturePresent( + ProcessorFeature: DWORD, + ) -> BOOL; + pub fn GetProcessHandleCount( + hProcess: HANDLE, + pdwHandleCount: PDWORD, + ) -> BOOL; + pub fn GetCurrentProcessorNumber() -> DWORD; + pub fn SetThreadIdealProcessorEx( + hThread: HANDLE, + lpIdealProcessor: PPROCESSOR_NUMBER, + lpPreviousIdealProcessor: PPROCESSOR_NUMBER, + ) -> BOOL; + pub fn GetThreadIdealProcessorEx( + hThread: HANDLE, + lpIdealProcessor: PPROCESSOR_NUMBER, + ) -> BOOL; + pub fn GetCurrentProcessorNumberEx( + ProcNumber: PPROCESSOR_NUMBER, + ); + pub fn GetProcessPriorityBoost( + hProcess: HANDLE, + pDisablePriorityBoost: PBOOL, + ) -> BOOL; + pub fn SetProcessPriorityBoost( + hProcess: HANDLE, + bDisablePriorityBoost: BOOL, + ) -> BOOL; + pub fn GetThreadIOPendingFlag( + hThread: HANDLE, + lpIOIsPending: PBOOL, + ) -> BOOL; + pub fn GetSystemTimes( + lpIdleTime: LPFILETIME, + lpKernelTime: LPFILETIME, + lpUserTime: LPFILETIME, + ) -> BOOL; +} +ENUM!{enum THREAD_INFORMATION_CLASS { + ThreadMemoryPriority, + ThreadAbsoluteCpuPriority, + ThreadInformationClassMax, +}} +// MEMORY_PRIORITY_INFORMATION +extern "system" { + pub fn GetThreadInformation( + hThread: HANDLE, + ThreadInformationClass: THREAD_INFORMATION_CLASS, + ThreadInformation: LPVOID, + ThreadInformationSize: DWORD, + ) -> BOOL; + pub fn SetThreadInformation( + hThread: HANDLE, + ThreadInformationClass: THREAD_INFORMATION_CLASS, + ThreadInformation: LPVOID, + ThreadInformationSize: DWORD, + ) -> BOOL; + pub fn IsProcessCritical( + hProcess: HANDLE, + Critical: PBOOL, + ) -> BOOL; + pub fn SetProtectedPolicy( + PolicyGuid: LPCGUID, + PolicyValue: ULONG_PTR, + OldPolicyValue: PULONG_PTR, + ) -> BOOL; + pub fn QueryProtectedPolicy( + PolicyGuid: LPCGUID, + PolicyValue: PULONG_PTR, + ) -> BOOL; + pub fn SetThreadIdealProcessor( + hThread: HANDLE, + dwIdealProcessor: DWORD, + ) -> DWORD; +} +ENUM!{enum PROCESS_INFORMATION_CLASS { + ProcessMemoryPriority, + ProcessInformationClassMax, +}} +extern "system" { + pub fn SetProcessInformation( + hProcess: HANDLE, + ProcessInformationClass: PROCESS_INFORMATION_CLASS, + ProcessInformation: LPVOID, + ProcessInformationSize: DWORD, + ) -> BOOL; + pub fn GetProcessInformation( + hProcess: HANDLE, + ProcessInformationClass: PROCESS_INFORMATION_CLASS, + ProcessInformation: LPVOID, + ProcessInformationSize: DWORD, + ) -> BOOL; + // pub fn GetSystemCpuSetInformation(); + // pub fn GetProcessDefaultCpuSets(); + // pub fn SetProcessDefaultCpuSets(); + // pub fn GetThreadSelectedCpuSets(); + // pub fn SetThreadSelectedCpuSets(); + // pub fn CreateProcessAsUserA(); + pub fn GetProcessShutdownParameters( + lpdwLevel: LPDWORD, + lpdwFlags: LPDWORD, + ) -> BOOL; + // pub fn SetThreadDescription(); + // pub fn GetThreadDescription(); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/processtopologyapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/processtopologyapi.rs new file mode 100644 index 0000000..694f076 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/processtopologyapi.rs @@ -0,0 +1,23 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, PUSHORT}; +use um::winnt::{GROUP_AFFINITY, HANDLE, PGROUP_AFFINITY}; +extern "system" { + pub fn GetProcessGroupAffinity( + hProcess: HANDLE, + GroupCount: PUSHORT, + GroupArray: PUSHORT, + ) -> BOOL; + pub fn GetThreadGroupAffinity( + hThread: HANDLE, + GroupAffinity: PGROUP_AFFINITY, + ) -> BOOL; + pub fn SetThreadGroupAffinity( + hThread: HANDLE, + GroupAffinity: *const GROUP_AFFINITY, + PreviousGroupAffinity: PGROUP_AFFINITY, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/profileapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/profileapi.rs new file mode 100644 index 0000000..9084575 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/profileapi.rs @@ -0,0 +1,15 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::BOOL; +use um::winnt::LARGE_INTEGER; +extern "system" { + pub fn QueryPerformanceCounter( + lpPerformanceCount: *mut LARGE_INTEGER, + ) -> BOOL; + pub fn QueryPerformanceFrequency( + lpFrequency: *mut LARGE_INTEGER, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/propidl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/propidl.rs new file mode 100644 index 0000000..fd25abb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/propidl.rs @@ -0,0 +1,392 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::{CLSID, FMTID, GUID, REFCLSID, REFFMTID}; +use shared::minwindef::{ + BYTE, DWORD, FILETIME, FLOAT, HIBYTE, HIWORD, INT, LOBYTE, LOWORD, UINT, WORD +}; +use shared::ntdef::{ + BOOLEAN, CHAR, HRESULT, LARGE_INTEGER, LONG, LPSTR, LPWSTR, PVOID, SHORT, + UCHAR, ULARGE_INTEGER, ULONG, USHORT +}; +use shared::wtypes::{ + BSTR, BSTRBLOB, CLIPDATA, CY, DATE, DECIMAL, PROPID, VARIANT_BOOL, VARTYPE +}; +use shared::wtypesbase::{BLOB, DOUBLE, LPOLESTR, SCODE}; +use um::oaidl::{IDispatch, LPSAFEARRAY}; +use um::objidlbase::IStream; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +pub const PROPSETFLAG_DEFAULT: DWORD = 0; +pub const PROPSETFLAG_NONSIMPLE: DWORD = 1; +pub const PROPSETFLAG_ANSI: DWORD = 2; +pub const PROPSETFLAG_UNBUFFERED: DWORD = 4; +pub const PROPSET_BEHAVIOR_CASE_SENSITIVE: DWORD = 1; +STRUCT!{struct VERSIONEDSTREAM { + guidVersion: GUID, + pStream: *mut IStream, +}} +pub type LPVERSIONEDSTREAM = *mut VERSIONEDSTREAM; +macro_rules! TYPEDEF_CA { + ($type_:ty, $name:ident) => { STRUCT!{struct $name { + cElems: $crate::shared::ntdef::ULONG, + pElems: *mut $type_, + }}} +} +TYPEDEF_CA!(CHAR, CAC); +TYPEDEF_CA!(UCHAR, CAUB); +TYPEDEF_CA!(SHORT, CAI); +TYPEDEF_CA!(USHORT, CAUI); +TYPEDEF_CA!(LONG, CAL); +TYPEDEF_CA!(ULONG, CAUL); +TYPEDEF_CA!(FLOAT, CAFLT); +TYPEDEF_CA!(DOUBLE, CADBL); +TYPEDEF_CA!(CY, CACY); +TYPEDEF_CA!(DATE, CADATE); +TYPEDEF_CA!(BSTR, CABSTR); +TYPEDEF_CA!(BSTRBLOB, CABSTRBLOB); +TYPEDEF_CA!(VARIANT_BOOL, CABOOL); +TYPEDEF_CA!(SCODE, CASCODE); +TYPEDEF_CA!(PROPVARIANT, CAPROPVARIANT); +TYPEDEF_CA!(LARGE_INTEGER, CAH); +TYPEDEF_CA!(ULARGE_INTEGER, CAUH); +TYPEDEF_CA!(LPSTR, CALPSTR); +TYPEDEF_CA!(LPWSTR, CALPWSTR); +TYPEDEF_CA!(FILETIME, CAFILETIME); +TYPEDEF_CA!(CLIPDATA, CACLIPDATA); +TYPEDEF_CA!(CLSID, CACLSID); +UNION!{union PROPVARIANT_data { + [u64; 1] [u64; 2], + cVal cVal_mut: CHAR, + bVal bVal_mut: UCHAR, + iVal iVal_mut: SHORT, + uiVal uiVal_mut: USHORT, + lVal lVal_mut: LONG, + ulVal ulVal_mut: ULONG, + intVal intVal_mut: INT, + uintVal uintVal_mut: UINT, + hVal hVal_mut: LARGE_INTEGER, + uhVal uhVal_mut: ULARGE_INTEGER, + fltVal fltVal_mut: FLOAT, + dblVal dblVal_mut: DOUBLE, + boolVal boolVal_mut: VARIANT_BOOL, + scode scode_mut: SCODE, + cyVal cyVal_mut: CY, + date date_mut: DATE, + filetime filetime_mut: FILETIME, + puuid puuid_mut: *mut CLSID, + pclipdata pclipdata_mut: *mut CLIPDATA, + bstrVal bstrVal_mut: BSTR, + bstrblobVal bstrblobVal_mut: BSTRBLOB, + blob blob_mut: BLOB, + pszVal pszVal_mut: LPSTR, + pwszVal pwszVal_mut: LPWSTR, + punkVal punkVal_mut: *mut IUnknown, + pdispVal pdisp_mut: *mut IDispatch, + pStream pStream_mut: *mut IStream, + // pStorage pStorage_mut: *mut IStorage, + pVersionedStream pVersionedStream_mut: LPVERSIONEDSTREAM, + parray parray_mut: LPSAFEARRAY, + cac cac_mut: CAC, + caub caub_mut: CAUB, + cai cai_mut: CAI, + caui caui_mut: CAUI, + cal cal_mut: CAL, + caul caul_mut: CAUL, + cah cah_mut: CAH, + cauh cauh_mut: CAUH, + caflt caflt_mut: CAFLT, + cadbl cadbl_mut: CADBL, + cabool cabool_mut: CABOOL, + cascode cascode_mut: CASCODE, + cacy cacy_mut: CACY, + cadate cadate_mut: CADATE, + cafiletime cafiletime_mut: CAFILETIME, + cauuid cauuid_mut: CACLSID, + caclipdata caclipdata_mut: CACLIPDATA, + cabstr cabstr_mut: CABSTR, + cabstrblob cabstrblob_mut: CABSTRBLOB, + calpstr calpstr_mut: CALPSTR, + calpwstr calpwstr_mut: CALPWSTR, + capropvar capropvar_mut: CAPROPVARIANT, + pcVal pcVal_mut: *mut CHAR, + pbVal pbVal_mut: *mut UCHAR, + piVal piVal_mut: *mut SHORT, + puiVal puiVal_mut: *mut USHORT, + plVal plVal_mut: *mut LONG, + pulVal pulVal_mut: *mut ULONG, + pintVal pintVal_mut: *mut INT, + puintVal puintVal_mut: *mut UINT, + pfltVal pfltVal_mut: *mut FLOAT, + pdblVal pdblVal_mut: *mut DOUBLE, + pboolVal pboolVal_mut: *mut VARIANT_BOOL, + pdecVal pdecVal_mut: *mut DECIMAL, + pscode pscode_mut: *mut SCODE, + pcyVal pcyVal_mut: *mut CY, + pdate pdate_mut: *mut DATE, + ppunkVal ppunkVal_mut: *mut *mut IUnknown, + ppdispVal ppdispVal_mut: *mut *mut IDispatch, + ppStream ppStream_mut: *mut *mut IStream, + // ppStorage ppStorage_mut: *mut *mut IStorage, +}} +// This is actually defined as a union between this struct +// and DECIMAL. I don't this we need to do that. +STRUCT!{struct PROPVARIANT { + vt: VARTYPE, + wReserved1: WORD, + wReserved2: WORD, + wReserved3: WORD, + data: PROPVARIANT_data, +}} +pub type LPPROPVARIANT = *mut PROPVARIANT; +pub type REFPROPVARIANT = *const PROPVARIANT; +pub const PID_DICTIONARY: DWORD = 0; +pub const PID_CODEPAGE: DWORD = 0x1; +pub const PID_FIRST_USABLE: DWORD = 0x2; +pub const PID_FIRST_NAME_DEFAULT: DWORD = 0xfff; +pub const PID_LOCALE: DWORD = 0x80000000; +pub const PID_MODIFY_TIME: DWORD = 0x80000001; +pub const PID_SECURITY: DWORD = 0x80000002; +pub const PID_BEHAVIOR: DWORD = 0x80000003; +pub const PID_ILLEGAL: DWORD = 0xffffffff; +pub const PID_MIN_READONLY: DWORD = 0x80000000; +pub const PID_MAX_READONLY: DWORD = 0xbfffffff; +pub const PRSPEC_INVALID: ULONG = 0xffffffff; +pub const PRSPEC_LPWSTR: ULONG = 0; +pub const PRSPEC_PROPID: ULONG = 1; +UNION!{union PROPSPEC_u { + [u32; 1] [u64; 1], + propid propid_mut: PROPID, + lpwstr lpwstr_mut: LPOLESTR, +}} +STRUCT!{struct PROPSPEC { + ulKind: ULONG, + u: PROPSPEC_u, +}} +STRUCT!{struct STATPROPSTG { + lpwstrName: LPOLESTR, + propid: PROPID, + vt: VARTYPE, +}} +#[inline] +pub fn PROPSETHDR_OSVER_KIND(dwOSVer: DWORD) -> WORD { + HIWORD(dwOSVer) +} +#[inline] +pub fn PROPSETHDR_OSVER_MAJOR(dwOSVer: DWORD) -> BYTE { + LOBYTE(LOWORD(dwOSVer)) +} +#[inline] +pub fn PROPSETHDR_OSVER_MINOR(dwOSVer: DWORD) -> BYTE { + HIBYTE(LOWORD(dwOSVer)) +} +pub const PROPSETHDR_OSVERSION_UNKNOWN: DWORD = 0xFFFFFFFF; +STRUCT!{struct STATPROPSETSTG { + fmtid: FMTID, + clsid: CLSID, + grfFlags: DWORD, + mtime: FILETIME, + ctime: FILETIME, + atime: FILETIME, + dwOSVersion: DWORD, +}} +RIDL!{#[uuid(0x00000138, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IPropertyStorage(IPropertyStorageVtbl): IUnknown(IUnknownVtbl) { + fn ReadMultiple( + cpspec: ULONG, + rgpspec: *const PROPSPEC, + rgpropvar: *mut PROPVARIANT, + ) -> HRESULT, + fn WriteMultiple( + cpspec: ULONG, + rgpspec: *const PROPSPEC, + rgpropvar: *const PROPVARIANT, + ) -> HRESULT, + fn DeleteMultiple( + cpspec: ULONG, + rgpspec: *const PROPSPEC, + ) -> HRESULT, + fn ReadPropertyNames( + cppropid: ULONG, + rgpropid: *const PROPID, + rglpwstrName: *mut LPOLESTR, + ) -> HRESULT, + fn WritePropertyNames( + cppropid: ULONG, + rgpropid: *const PROPID, + rglpwstrName: *const LPOLESTR, + ) -> HRESULT, + fn DeletePropertyNames( + cppropid: ULONG, + rgpropid: *const PROPID, + ) -> HRESULT, + fn Commit( + grfCommitFlags: DWORD, + ) -> HRESULT, + fn Revert() -> HRESULT, + fn Enum( + ppenum: *mut *mut IEnumSTATPROPSTG, + ) -> HRESULT, + fn SetTimes( + pctime: *const FILETIME, + patime: *const FILETIME, + pmtime: *const FILETIME, + ) -> HRESULT, + fn SetClass( + clsid: REFCLSID, + ) -> HRESULT, + fn Stat( + pstatpsstg: *mut STATPROPSETSTG, + ) -> HRESULT, +}} +pub type LPPROPERTYSETSTORAGE = *mut IPropertySetStorage; +RIDL!{#[uuid(0x0000013A, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IPropertySetStorage(IPropertySetStorageVtbl): IUnknown(IUnknownVtbl) { + fn Create( + rfmtid: REFFMTID, + pclsid: *const CLSID, + grfFlags: DWORD, + grfMode: DWORD, + ppprstg: *mut *mut IPropertyStorage, + ) -> HRESULT, + fn Open( + rfmtid: REFFMTID, + grfMode: DWORD, + ppprstg: *mut *mut IPropertyStorage, + ) -> HRESULT, + fn Delete( + rfmtid: REFFMTID, + ) -> HRESULT, + fn Enum( + ppenum: *mut *mut IEnumSTATPROPSTG, + ) -> HRESULT, +}} +pub type LPENUMSTATPROPSTG = *mut IEnumSTATPROPSTG; +RIDL!{#[uuid(0x00000139, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumSTATPROPSTG(IEnumSTATPROPSTGVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut STATPROPSTG, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Revert() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumSTATPROPSTG, + ) -> HRESULT, +}} +pub type LPENUMSTATPROPSETSTG = *mut IEnumSTATPROPSETSTG; +RIDL!{#[uuid(0x0000013B, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumSTATPROPSETSTG(IEnumSTATPROPSETSTGVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut STATPROPSETSTG, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Revert() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumSTATPROPSETSTG, + ) -> HRESULT, +}} +pub type LPPROPERTYSTORAGE = *mut IPropertyStorage; +pub const PIDDI_THUMBNAIL: DWORD = 0x00000002; +pub const PIDSI_TITLE: DWORD = 0x00000002; +pub const PIDSI_SUBJECT: DWORD = 0x00000003; +pub const PIDSI_AUTHOR: DWORD = 0x00000004; +pub const PIDSI_KEYWORDS: DWORD = 0x00000005; +pub const PIDSI_COMMENTS: DWORD = 0x00000006; +pub const PIDSI_TEMPLATE: DWORD = 0x00000007; +pub const PIDSI_LASTAUTHOR: DWORD = 0x00000008; +pub const PIDSI_REVNUMBER: DWORD = 0x00000009; +pub const PIDSI_EDITTIME: DWORD = 0x0000000a; +pub const PIDSI_LASTPRINTED: DWORD = 0x0000000b; +pub const PIDSI_CREATE_DTM: DWORD = 0x0000000c; +pub const PIDSI_LASTSAVE_DTM: DWORD = 0x0000000d; +pub const PIDSI_PAGECOUNT: DWORD = 0x0000000e; +pub const PIDSI_WORDCOUNT: DWORD = 0x0000000f; +pub const PIDSI_CHARCOUNT: DWORD = 0x00000010; +pub const PIDSI_THUMBNAIL: DWORD = 0x00000011; +pub const PIDSI_APPNAME: DWORD = 0x00000012; +pub const PIDSI_DOC_SECURITY: DWORD = 0x00000013; +pub const PIDDSI_CATEGORY: DWORD = 0x00000002; +pub const PIDDSI_PRESFORMAT: DWORD = 0x00000003; +pub const PIDDSI_BYTECOUNT: DWORD = 0x00000004; +pub const PIDDSI_LINECOUNT: DWORD = 0x00000005; +pub const PIDDSI_PARCOUNT: DWORD = 0x00000006; +pub const PIDDSI_SLIDECOUNT: DWORD = 0x00000007; +pub const PIDDSI_NOTECOUNT: DWORD = 0x00000008; +pub const PIDDSI_HIDDENCOUNT: DWORD = 0x00000009; +pub const PIDDSI_MMCLIPCOUNT: DWORD = 0x0000000A; +pub const PIDDSI_SCALE: DWORD = 0x0000000B; +pub const PIDDSI_HEADINGPAIR: DWORD = 0x0000000C; +pub const PIDDSI_DOCPARTS: DWORD = 0x0000000D; +pub const PIDDSI_MANAGER: DWORD = 0x0000000E; +pub const PIDDSI_COMPANY: DWORD = 0x0000000F; +pub const PIDDSI_LINKSDIRTY: DWORD = 0x00000010; +pub const PIDMSI_EDITOR: DWORD = 0x00000002; +pub const PIDMSI_SUPPLIER: DWORD = 0x00000003; +pub const PIDMSI_SOURCE: DWORD = 0x00000004; +pub const PIDMSI_SEQUENCE_NO: DWORD = 0x00000005; +pub const PIDMSI_PROJECT: DWORD = 0x00000006; +pub const PIDMSI_STATUS: DWORD = 0x00000007; +pub const PIDMSI_OWNER: DWORD = 0x00000008; +pub const PIDMSI_RATING: DWORD = 0x00000009; +pub const PIDMSI_PRODUCTION: DWORD = 0x0000000A; +pub const PIDMSI_COPYRIGHT: DWORD = 0x0000000B; +ENUM!{enum PIDMSI_STATUS_VALUE { + PIDMSI_STATUS_NORMAL = 0, + PIDMSI_STATUS_NEW, + PIDMSI_STATUS_PRELIM, + PIDMSI_STATUS_DRAFT, + PIDMSI_STATUS_INPROGRESS, + PIDMSI_STATUS_EDIT, + PIDMSI_STATUS_REVIEW, + PIDMSI_STATUS_PROOF, + PIDMSI_STATUS_FINAL, + PIDMSI_STATUS_OTHER = 0x7fff, +}} +extern "system" { + pub fn PropVariantCopy( + pvarDest: *mut PROPVARIANT, + pvarSrc: *const PROPVARIANT, + ) -> HRESULT; + pub fn PropVariantClear( + pvar: *mut PROPVARIANT, + ) -> HRESULT; + pub fn FreePropVariantArray( + cVariants: ULONG, + rgvars: *mut PROPVARIANT, + ) -> HRESULT; +} +// #[inline] +// pub fn PropVariantInit(pvar: *mut PROPVARIANT) { +// memset(pvar, 0, sizeof(PROPVARIANT)) +// } +STRUCT!{struct SERIALIZEDPROPERTYVALUE { + dwType: DWORD, + rgb: *mut BYTE, +}} +pub type PMemoryAllocator = PVOID; +extern "system" { + pub fn StgConvertVariantToProperty( + pvar: *const PROPVARIANT, + CodePage: USHORT, + pprop: *mut SERIALIZEDPROPERTYVALUE, + pcb: *mut ULONG, + pid: PROPID, + fReserved: BOOLEAN, + pcIndirect: *mut ULONG, + ) -> *mut SERIALIZEDPROPERTYVALUE; + pub fn StgConvertPropertyToVariant( + pprop: *const SERIALIZEDPROPERTYVALUE, + CodePage: USHORT, + pvar: *mut PROPVARIANT, + pma: *mut PMemoryAllocator + ) -> BOOLEAN; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/propkey.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/propkey.rs new file mode 100644 index 0000000..bfa7d09 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/propkey.rs @@ -0,0 +1,2300 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::DWORD; +use shared::ntdef::{DOUBLE, LONG}; +use shared::wtypes::PROPERTYKEY; +DEFINE_PROPERTYKEY!{PKEY_Audio_ChannelCount, + 0x64440490, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 7} +pub const AUDIO_CHANNELCOUNT_MONO: DWORD = 1; +pub const AUDIO_CHANNELCOUNT_STEREO: DWORD = 2; +DEFINE_PROPERTYKEY!{PKEY_Audio_Compression, + 0x64440490, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 10} +DEFINE_PROPERTYKEY!{PKEY_Audio_EncodingBitrate, + 0x64440490, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 4} +DEFINE_PROPERTYKEY!{PKEY_Audio_Format, + 0x64440490, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 2} +DEFINE_PROPERTYKEY!{PKEY_Audio_IsVariableBitRate, + 0xE6822FEE, 0x8C17, 0x4D62, 0x82, 0x3C, 0x8E, 0x9C, 0xFC, 0xBD, 0x1D, 0x5C, 100} +DEFINE_PROPERTYKEY!{PKEY_Audio_PeakValue, + 0x2579E5D0, 0x1116, 0x4084, 0xBD, 0x9A, 0x9B, 0x4F, 0x7C, 0xB4, 0xDF, 0x5E, 100} +DEFINE_PROPERTYKEY!{PKEY_Audio_SampleRate, + 0x64440490, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 5} +DEFINE_PROPERTYKEY!{PKEY_Audio_SampleSize, + 0x64440490, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 6} +DEFINE_PROPERTYKEY!{PKEY_Audio_StreamName, + 0x64440490, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 9} +DEFINE_PROPERTYKEY!{PKEY_Audio_StreamNumber, + 0x64440490, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 8} +DEFINE_PROPERTYKEY!{PKEY_Calendar_Duration, + 0x293CA35A, 0x09AA, 0x4DD2, 0xB1, 0x80, 0x1F, 0xE2, 0x45, 0x72, 0x8A, 0x52, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_IsOnline, + 0xBFEE9149, 0xE3E2, 0x49A7, 0xA8, 0x62, 0xC0, 0x59, 0x88, 0x14, 0x5C, 0xEC, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_IsRecurring, + 0x315B9C8D, 0x80A9, 0x4EF9, 0xAE, 0x16, 0x8E, 0x74, 0x6D, 0xA5, 0x1D, 0x70, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_Location, + 0xF6272D18, 0xCECC, 0x40B1, 0xB2, 0x6A, 0x39, 0x11, 0x71, 0x7A, 0xA7, 0xBD, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_OptionalAttendeeAddresses, + 0xD55BAE5A, 0x3892, 0x417A, 0xA6, 0x49, 0xC6, 0xAC, 0x5A, 0xAA, 0xEA, 0xB3, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_OptionalAttendeeNames, + 0x09429607, 0x582D, 0x437F, 0x84, 0xC3, 0xDE, 0x93, 0xA2, 0xB2, 0x4C, 0x3C, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_OrganizerAddress, + 0x744C8242, 0x4DF5, 0x456C, 0xAB, 0x9E, 0x01, 0x4E, 0xFB, 0x90, 0x21, 0xE3, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_OrganizerName, + 0xAAA660F9, 0x9865, 0x458E, 0xB4, 0x84, 0x01, 0xBC, 0x7F, 0xE3, 0x97, 0x3E, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_ReminderTime, + 0x72FC5BA4, 0x24F9, 0x4011, 0x9F, 0x3F, 0xAD, 0xD2, 0x7A, 0xFA, 0xD8, 0x18, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_RequiredAttendeeAddresses, + 0x0BA7D6C3, 0x568D, 0x4159, 0xAB, 0x91, 0x78, 0x1A, 0x91, 0xFB, 0x71, 0xE5, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_RequiredAttendeeNames, + 0xB33AF30B, 0xF552, 0x4584, 0x93, 0x6C, 0xCB, 0x93, 0xE5, 0xCD, 0xA2, 0x9F, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_Resources, + 0x00F58A38, 0xC54B, 0x4C40, 0x86, 0x96, 0x97, 0x23, 0x59, 0x80, 0xEA, 0xE1, 100} +DEFINE_PROPERTYKEY!{PKEY_Calendar_ResponseStatus, + 0x188C1F91, 0x3C40, 0x4132, 0x9E, 0xC5, 0xD8, 0xB0, 0x3B, 0x72, 0xA8, 0xA2, 100} +pub const CALENDAR_RESPONSESTATUS_NONE: DWORD = 0; +pub const CALENDAR_RESPONSESTATUS_ORGANIZED: DWORD = 1; +pub const CALENDAR_RESPONSESTATUS_TENTATIVE: DWORD = 2; +pub const CALENDAR_RESPONSESTATUS_ACCEPTED: DWORD = 3; +pub const CALENDAR_RESPONSESTATUS_DECLINED: DWORD = 4; +pub const CALENDAR_RESPONSESTATUS_NOTRESPONDED: DWORD = 5; +DEFINE_PROPERTYKEY!{PKEY_Calendar_ShowTimeAs, + 0x5BF396D4, 0x5EB2, 0x466F, 0xBD, 0xE9, 0x2F, 0xB3, 0xF2, 0x36, 0x1D, 0x6E, 100} +pub const CALENDAR_SHOWTIMEAS_FREE: DWORD = 0; +pub const CALENDAR_SHOWTIMEAS_TENTATIVE: DWORD = 1; +pub const CALENDAR_SHOWTIMEAS_BUSY: DWORD = 2; +pub const CALENDAR_SHOWTIMEAS_OOF: DWORD = 3; +DEFINE_PROPERTYKEY!{PKEY_Calendar_ShowTimeAsText, + 0x53DA57CF, 0x62C0, 0x45C4, 0x81, 0xDE, 0x76, 0x10, 0xBC, 0xEF, 0xD7, 0xF5, 100} +DEFINE_PROPERTYKEY!{PKEY_Communication_AccountName, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 9} +DEFINE_PROPERTYKEY!{PKEY_Communication_DateItemExpires, + 0x428040AC, 0xA177, 0x4C8A, 0x97, 0x60, 0xF6, 0xF7, 0x61, 0x22, 0x7F, 0x9A, 100} +DEFINE_PROPERTYKEY!{PKEY_Communication_Direction, + 0x8E531030, 0xB960, 0x4346, 0xAE, 0x0D, 0x66, 0xBC, 0x9A, 0x86, 0xFB, 0x94, 100} +pub const COMMUNICATION_DIRECTION_UNKNOWN: DWORD = 0; +pub const COMMUNICATION_DIRECTION_INCOMING: DWORD = 1; +pub const COMMUNICATION_DIRECTION_OUTGOING: DWORD = 2; +DEFINE_PROPERTYKEY!{PKEY_Communication_FollowupIconIndex, + 0x83A6347E, 0x6FE4, 0x4F40, 0xBA, 0x9C, 0xC4, 0x86, 0x52, 0x40, 0xD1, 0xF4, 100} +DEFINE_PROPERTYKEY!{PKEY_Communication_HeaderItem, + 0xC9C34F84, 0x2241, 0x4401, 0xB6, 0x07, 0xBD, 0x20, 0xED, 0x75, 0xAE, 0x7F, 100} +DEFINE_PROPERTYKEY!{PKEY_Communication_PolicyTag, + 0xEC0B4191, 0xAB0B, 0x4C66, 0x90, 0xB6, 0xC6, 0x63, 0x7C, 0xDE, 0xBB, 0xAB, 100} +DEFINE_PROPERTYKEY!{PKEY_Communication_SecurityFlags, + 0x8619A4B6, 0x9F4D, 0x4429, 0x8C, 0x0F, 0xB9, 0x96, 0xCA, 0x59, 0xE3, 0x35, 100} +DEFINE_PROPERTYKEY!{PKEY_Communication_Suffix, + 0x807B653A, 0x9E91, 0x43EF, 0x8F, 0x97, 0x11, 0xCE, 0x04, 0xEE, 0x20, 0xC5, 100} +DEFINE_PROPERTYKEY!{PKEY_Communication_TaskStatus, + 0xBE1A72C6, 0x9A1D, 0x46B7, 0xAF, 0xE7, 0xAF, 0xAF, 0x8C, 0xEF, 0x49, 0x99, 100} +pub const TASKSTATUS_NOTSTARTED: DWORD = 0; +pub const TASKSTATUS_INPROGRESS: DWORD = 1; +pub const TASKSTATUS_COMPLETE: DWORD = 2; +pub const TASKSTATUS_WAITING: DWORD = 3; +pub const TASKSTATUS_DEFERRED: DWORD = 4; +DEFINE_PROPERTYKEY!{PKEY_Communication_TaskStatusText, + 0xA6744477, 0xC237, 0x475B, 0xA0, 0x75, 0x54, 0xF3, 0x44, 0x98, 0x29, 0x2A, 100} +DEFINE_PROPERTYKEY!{PKEY_Computer_DecoratedFreeSpace, + 0x9B174B35, 0x40FF, 0x11D2, 0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71, 7} +DEFINE_PROPERTYKEY!{PKEY_Contact_AccountPictureDynamicVideo, + 0x0B8BB018, 0x2725, 0x4B44, 0x92, 0xBA, 0x79, 0x33, 0xAE, 0xB2, 0xDD, 0xE7, 2} +DEFINE_PROPERTYKEY!{PKEY_Contact_AccountPictureLarge, + 0x0B8BB018, 0x2725, 0x4B44, 0x92, 0xBA, 0x79, 0x33, 0xAE, 0xB2, 0xDD, 0xE7, 3} +DEFINE_PROPERTYKEY!{PKEY_Contact_AccountPictureSmall, + 0x0B8BB018, 0x2725, 0x4B44, 0x92, 0xBA, 0x79, 0x33, 0xAE, 0xB2, 0xDD, 0xE7, 4} +DEFINE_PROPERTYKEY!{PKEY_Contact_Anniversary, + 0x9AD5BADB, 0xCEA7, 0x4470, 0xA0, 0x3D, 0xB8, 0x4E, 0x51, 0xB9, 0x94, 0x9E, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_AssistantName, + 0xCD102C9C, 0x5540, 0x4A88, 0xA6, 0xF6, 0x64, 0xE4, 0x98, 0x1C, 0x8C, 0xD1, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_AssistantTelephone, + 0x9A93244D, 0xA7AD, 0x4FF8, 0x9B, 0x99, 0x45, 0xEE, 0x4C, 0xC0, 0x9A, 0xF6, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_Birthday, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 47} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress, + 0x730FB6DD, 0xCF7C, 0x426B, 0xA0, 0x3F, 0xBD, 0x16, 0x6C, 0xC9, 0xEE, 0x24, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress1Country, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 119} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress1Locality, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 117} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress1PostalCode, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 120} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress1Region, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 118} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress1Street, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 116} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress2Country, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 124} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress2Locality, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 122} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress2PostalCode, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 125} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress2Region, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 123} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress2Street, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 121} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress3Country, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 129} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress3Locality, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 127} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress3PostalCode, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 130} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress3Region, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 128} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddress3Street, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 126} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddressCity, + 0x402B5934, 0xEC5A, 0x48C3, 0x93, 0xE6, 0x85, 0xE8, 0x6A, 0x2D, 0x93, 0x4E, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddressCountry, + 0xB0B87314, 0xFCF6, 0x4FEB, 0x8D, 0xFF, 0xA5, 0x0D, 0xA6, 0xAF, 0x56, 0x1C, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddressPostalCode, + 0xE1D4A09E, 0xD758, 0x4CD1, 0xB6, 0xEC, 0x34, 0xA8, 0xB5, 0xA7, 0x3F, 0x80, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddressPostOfficeBox, + 0xBC4E71CE, 0x17F9, 0x48D5, 0xBE, 0xE9, 0x02, 0x1D, 0xF0, 0xEA, 0x54, 0x09, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddressState, + 0x446F787F, 0x10C4, 0x41CB, 0xA6, 0xC4, 0x4D, 0x03, 0x43, 0x55, 0x15, 0x97, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessAddressStreet, + 0xDDD1460F, 0xC0BF, 0x4553, 0x8C, 0xE4, 0x10, 0x43, 0x3C, 0x90, 0x8F, 0xB0, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessEmailAddresses, + 0xF271C659, 0x7E5E, 0x471F, 0xBA, 0x25, 0x7F, 0x77, 0xB2, 0x86, 0xF8, 0x36, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessFaxNumber, + 0x91EFF6F3, 0x2E27, 0x42CA, 0x93, 0x3E, 0x7C, 0x99, 0x9F, 0xBE, 0x31, 0x0B, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessHomePage, + 0x56310920, 0x2491, 0x4919, 0x99, 0xCE, 0xEA, 0xDB, 0x06, 0xFA, 0xFD, 0xB2, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_BusinessTelephone, + 0x6A15E5A0, 0x0A1E, 0x4CD7, 0xBB, 0x8C, 0xD2, 0xF1, 0xB0, 0xC9, 0x29, 0xBC, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_CallbackTelephone, + 0xBF53D1C3, 0x49E0, 0x4F7F, 0x85, 0x67, 0x5A, 0x82, 0x1D, 0x8A, 0xC5, 0x42, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_CarTelephone, + 0x8FDC6DEA, 0xB929, 0x412B, 0xBA, 0x90, 0x39, 0x7A, 0x25, 0x74, 0x65, 0xFE, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_Children, + 0xD4729704, 0x8EF1, 0x43EF, 0x90, 0x24, 0x2B, 0xD3, 0x81, 0x18, 0x7F, 0xD5, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_CompanyMainTelephone, + 0x8589E481, 0x6040, 0x473D, 0xB1, 0x71, 0x7F, 0xA8, 0x9C, 0x27, 0x08, 0xED, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_ConnectedServiceDisplayName, + 0x39B77F4F, 0xA104, 0x4863, 0xB3, 0x95, 0x2D, 0xB2, 0xAD, 0x8F, 0x7B, 0xC1, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_ConnectedServiceIdentities, + 0x80F41EB8, 0xAFC4, 0x4208, 0xAA, 0x5F, 0xCC, 0xE2, 0x1A, 0x62, 0x72, 0x81, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_ConnectedServiceName, + 0xB5C84C9E, 0x5927, 0x46B5, 0xA3, 0xCC, 0x93, 0x3C, 0x21, 0xB7, 0x84, 0x69, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_ConnectedServiceSupportedActions, + 0xA19FB7A9, 0x024B, 0x4371, 0xA8, 0xBF, 0x4D, 0x29, 0xC3, 0xE4, 0xE9, 0xC9, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_DataSuppliers, + 0x9660C283, 0xFC3A, 0x4A08, 0xA0, 0x96, 0xEE, 0xD3, 0xAA, 0xC4, 0x6D, 0xA2, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_Department, + 0xFC9F7306, 0xFF8F, 0x4D49, 0x9F, 0xB6, 0x3F, 0xFE, 0x5C, 0x09, 0x51, 0xEC, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_DisplayBusinessPhoneNumbers, + 0x364028DA, 0xD895, 0x41FE, 0xA5, 0x84, 0x30, 0x2B, 0x1B, 0xB7, 0x0A, 0x76, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_DisplayHomePhoneNumbers, + 0x5068BCDF, 0xD697, 0x4D85, 0x8C, 0x53, 0x1F, 0x1C, 0xDA, 0xB0, 0x17, 0x63, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_DisplayMobilePhoneNumbers, + 0x9CB0C358, 0x9D7A, 0x46B1, 0xB4, 0x66, 0xDC, 0xC6, 0xF1, 0xA3, 0xD9, 0x3D, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_DisplayOtherPhoneNumbers, + 0x03089873, 0x8EE8, 0x4191, 0xBD, 0x60, 0xD3, 0x1F, 0x72, 0xB7, 0x90, 0x0B, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_EmailAddress, + 0xF8FA7FA3, 0xD12B, 0x4785, 0x8A, 0x4E, 0x69, 0x1A, 0x94, 0xF7, 0xA3, 0xE7, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_EmailAddress2, + 0x38965063, 0xEDC8, 0x4268, 0x84, 0x91, 0xB7, 0x72, 0x31, 0x72, 0xCF, 0x29, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_EmailAddress3, + 0x644D37B4, 0xE1B3, 0x4BAD, 0xB0, 0x99, 0x7E, 0x7C, 0x04, 0x96, 0x6A, 0xCA, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_EmailAddresses, + 0x84D8F337, 0x981D, 0x44B3, 0x96, 0x15, 0xC7, 0x59, 0x6D, 0xBA, 0x17, 0xE3, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_EmailName, + 0xCC6F4F24, 0x6083, 0x4BD4, 0x87, 0x54, 0x67, 0x4D, 0x0D, 0xE8, 0x7A, 0xB8, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_FileAsName, + 0xF1A24AA7, 0x9CA7, 0x40F6, 0x89, 0xEC, 0x97, 0xDE, 0xF9, 0xFF, 0xE8, 0xDB, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_FirstName, + 0x14977844, 0x6B49, 0x4AAD, 0xA7, 0x14, 0xA4, 0x51, 0x3B, 0xF6, 0x04, 0x60, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_FullName, + 0x635E9051, 0x50A5, 0x4BA2, 0xB9, 0xDB, 0x4E, 0xD0, 0x56, 0xC7, 0x72, 0x96, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_Gender, + 0x3C8CEE58, 0xD4F0, 0x4CF9, 0xB7, 0x56, 0x4E, 0x5D, 0x24, 0x44, 0x7B, 0xCD, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_GenderValue, + 0x3C8CEE58, 0xD4F0, 0x4CF9, 0xB7, 0x56, 0x4E, 0x5D, 0x24, 0x44, 0x7B, 0xCD, 101} +pub const GENDERVALUE_UNSPECIFIED: DWORD = 0; +pub const GENDERVALUE_FEMALE: DWORD = 1; +pub const GENDERVALUE_MALE: DWORD = 2; +DEFINE_PROPERTYKEY!{PKEY_Contact_Hobbies, + 0x5DC2253F, 0x5E11, 0x4ADF, 0x9C, 0xFE, 0x91, 0x0D, 0xD0, 0x1E, 0x3E, 0x70, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress, + 0x98F98354, 0x617A, 0x46B8, 0x85, 0x60, 0x5B, 0x1B, 0x64, 0xBF, 0x1F, 0x89, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress1Country, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 104} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress1Locality, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 102} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress1PostalCode, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 105} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress1Region, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 103} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress1Street, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 101} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress2Country, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 109} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress2Locality, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 107} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress2PostalCode, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 110} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress2Region, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 108} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress2Street, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 106} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress3Country, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 114} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress3Locality, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 112} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress3PostalCode, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 115} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress3Region, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 113} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddress3Street, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 111} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddressCity, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 65} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddressCountry, + 0x08A65AA1, 0xF4C9, 0x43DD, 0x9D, 0xDF, 0xA3, 0x3D, 0x8E, 0x7E, 0xAD, 0x85, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddressPostalCode, + 0x8AFCC170, 0x8A46, 0x4B53, 0x9E, 0xEE, 0x90, 0xBA, 0xE7, 0x15, 0x1E, 0x62, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddressPostOfficeBox, + 0x7B9F6399, 0x0A3F, 0x4B12, 0x89, 0xBD, 0x4A, 0xDC, 0x51, 0xC9, 0x18, 0xAF, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddressState, + 0xC89A23D0, 0x7D6D, 0x4EB8, 0x87, 0xD4, 0x77, 0x6A, 0x82, 0xD4, 0x93, 0xE5, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeAddressStreet, + 0x0ADEF160, 0xDB3F, 0x4308, 0x9A, 0x21, 0x06, 0x23, 0x7B, 0x16, 0xFA, 0x2A, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeEmailAddresses, + 0x56C90E9D, 0x9D46, 0x4963, 0x88, 0x6F, 0x2E, 0x1C, 0xD9, 0xA6, 0x94, 0xEF, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeFaxNumber, + 0x660E04D6, 0x81AB, 0x4977, 0xA0, 0x9F, 0x82, 0x31, 0x31, 0x13, 0xAB, 0x26, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_HomeTelephone, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 20} +DEFINE_PROPERTYKEY!{PKEY_Contact_IMAddress, + 0xD68DBD8A, 0x3374, 0x4B81, 0x99, 0x72, 0x3E, 0xC3, 0x06, 0x82, 0xDB, 0x3D, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_Initials, + 0xF3D8F40D, 0x50CB, 0x44A2, 0x97, 0x18, 0x40, 0xCB, 0x91, 0x19, 0x49, 0x5D, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_JA_CompanyNamePhonetic, + 0x897B3694, 0xFE9E, 0x43E6, 0x80, 0x66, 0x26, 0x0F, 0x59, 0x0C, 0x01, 0x00, 2} +DEFINE_PROPERTYKEY!{PKEY_Contact_JA_FirstNamePhonetic, + 0x897B3694, 0xFE9E, 0x43E6, 0x80, 0x66, 0x26, 0x0F, 0x59, 0x0C, 0x01, 0x00, 3} +DEFINE_PROPERTYKEY!{PKEY_Contact_JA_LastNamePhonetic, + 0x897B3694, 0xFE9E, 0x43E6, 0x80, 0x66, 0x26, 0x0F, 0x59, 0x0C, 0x01, 0x00, 4} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo1CompanyAddress, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 120} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo1CompanyName, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 102} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo1Department, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 106} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo1Manager, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 105} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo1OfficeLocation, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 104} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo1Title, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 103} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo1YomiCompanyName, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 101} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo2CompanyAddress, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 121} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo2CompanyName, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 108} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo2Department, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 113} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo2Manager, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 112} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo2OfficeLocation, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 110} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo2Title, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 109} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo2YomiCompanyName, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 107} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo3CompanyAddress, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 123} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo3CompanyName, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 115} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo3Department, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 119} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo3Manager, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 118} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo3OfficeLocation, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 117} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo3Title, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 116} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobInfo3YomiCompanyName, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 114} +DEFINE_PROPERTYKEY!{PKEY_Contact_JobTitle, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 6} +DEFINE_PROPERTYKEY!{PKEY_Contact_Label, + 0x97B0AD89, 0xDF49, 0x49CC, 0x83, 0x4E, 0x66, 0x09, 0x74, 0xFD, 0x75, 0x5B, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_LastName, + 0x8F367200, 0xC270, 0x457C, 0xB1, 0xD4, 0xE0, 0x7C, 0x5B, 0xCD, 0x90, 0xC7, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_MailingAddress, + 0xC0AC206A, 0x827E, 0x4650, 0x95, 0xAE, 0x77, 0xE2, 0xBB, 0x74, 0xFC, 0xC9, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_MiddleName, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 71} +DEFINE_PROPERTYKEY!{PKEY_Contact_MobileTelephone, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 35} +DEFINE_PROPERTYKEY!{PKEY_Contact_NickName, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 74} +DEFINE_PROPERTYKEY!{PKEY_Contact_OfficeLocation, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 7} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress, + 0x508161FA, 0x313B, 0x43D5, 0x83, 0xA1, 0xC1, 0xAC, 0xCF, 0x68, 0x62, 0x2C, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress1Country, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 134} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress1Locality, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 132} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress1PostalCode, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 135} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress1Region, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 133} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress1Street, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 131} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress2Country, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 139} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress2Locality, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 137} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress2PostalCode, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 140} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress2Region, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 138} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress2Street, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 136} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress3Country, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 144} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress3Locality, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 142} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress3PostalCode, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 145} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress3Region, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 143} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddress3Street, + 0xA7B6F596, 0xD678, 0x4BC1, 0xB0, 0x5F, 0x02, 0x03, 0xD2, 0x7E, 0x8A, 0xA1, 141} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddressCity, + 0x6E682923, 0x7F7B, 0x4F0C, 0xA3, 0x37, 0xCF, 0xCA, 0x29, 0x66, 0x87, 0xBF, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddressCountry, + 0x8F167568, 0x0AAE, 0x4322, 0x8E, 0xD9, 0x60, 0x55, 0xB7, 0xB0, 0xE3, 0x98, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddressPostalCode, + 0x95C656C1, 0x2ABF, 0x4148, 0x9E, 0xD3, 0x9E, 0xC6, 0x02, 0xE3, 0xB7, 0xCD, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddressPostOfficeBox, + 0x8B26EA41, 0x058F, 0x43F6, 0xAE, 0xCC, 0x40, 0x35, 0x68, 0x1C, 0xE9, 0x77, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddressState, + 0x71B377D6, 0xE570, 0x425F, 0xA1, 0x70, 0x80, 0x9F, 0xAE, 0x73, 0xE5, 0x4E, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherAddressStreet, + 0xFF962609, 0xB7D6, 0x4999, 0x86, 0x2D, 0x95, 0x18, 0x0D, 0x52, 0x9A, 0xEA, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_OtherEmailAddresses, + 0x11D6336B, 0x38C4, 0x4EC9, 0x84, 0xD6, 0xEB, 0x38, 0xD0, 0xB1, 0x50, 0xAF, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_PagerTelephone, + 0xD6304E01, 0xF8F5, 0x4F45, 0x8B, 0x15, 0xD0, 0x24, 0xA6, 0x29, 0x67, 0x89, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_PersonalTitle, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 69} +DEFINE_PROPERTYKEY!{PKEY_Contact_PhoneNumbersCanonical, + 0xD042D2A1, 0x927E, 0x40B5, 0xA5, 0x03, 0x6E, 0xDB, 0xD4, 0x2A, 0x51, 0x7E, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_Prefix, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 75} +DEFINE_PROPERTYKEY!{PKEY_Contact_PrimaryAddressCity, + 0xC8EA94F0, 0xA9E3, 0x4969, 0xA9, 0x4B, 0x9C, 0x62, 0xA9, 0x53, 0x24, 0xE0, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_PrimaryAddressCountry, + 0xE53D799D, 0x0F3F, 0x466E, 0xB2, 0xFF, 0x74, 0x63, 0x4A, 0x3C, 0xB7, 0xA4, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_PrimaryAddressPostalCode, + 0x18BBD425, 0xECFD, 0x46EF, 0xB6, 0x12, 0x7B, 0x4A, 0x60, 0x34, 0xED, 0xA0, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_PrimaryAddressPostOfficeBox, + 0xDE5EF3C7, 0x46E1, 0x484E, 0x99, 0x99, 0x62, 0xC5, 0x30, 0x83, 0x94, 0xC1, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_PrimaryAddressState, + 0xF1176DFE, 0x7138, 0x4640, 0x8B, 0x4C, 0xAE, 0x37, 0x5D, 0xC7, 0x0A, 0x6D, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_PrimaryAddressStreet, + 0x63C25B20, 0x96BE, 0x488F, 0x87, 0x88, 0xC0, 0x9C, 0x40, 0x7A, 0xD8, 0x12, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_PrimaryEmailAddress, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 48} +DEFINE_PROPERTYKEY!{PKEY_Contact_PrimaryTelephone, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 25} +DEFINE_PROPERTYKEY!{PKEY_Contact_Profession, + 0x7268AF55, 0x1CE4, 0x4F6E, 0xA4, 0x1F, 0xB6, 0xE4, 0xEF, 0x10, 0xE4, 0xA9, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_SpouseName, + 0x9D2408B6, 0x3167, 0x422B, 0x82, 0xB0, 0xF5, 0x83, 0xB7, 0xA7, 0xCF, 0xE3, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_Suffix, + 0x176DC63C, 0x2688, 0x4E89, 0x81, 0x43, 0xA3, 0x47, 0x80, 0x0F, 0x25, 0xE9, 73} +DEFINE_PROPERTYKEY!{PKEY_Contact_TelexNumber, + 0xC554493C, 0xC1F7, 0x40C1, 0xA7, 0x6C, 0xEF, 0x8C, 0x06, 0x14, 0x00, 0x3E, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_TTYTDDTelephone, + 0xAAF16BAC, 0x2B55, 0x45E6, 0x9F, 0x6D, 0x41, 0x5E, 0xB9, 0x49, 0x10, 0xDF, 100} +DEFINE_PROPERTYKEY!{PKEY_Contact_WebPage, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 18} +DEFINE_PROPERTYKEY!{PKEY_Contact_Webpage2, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 124} +DEFINE_PROPERTYKEY!{PKEY_Contact_Webpage3, + 0x00F63DD8, 0x22BD, 0x4A5D, 0xBA, 0x34, 0x5C, 0xB0, 0xB9, 0xBD, 0xCB, 0x03, 125} +DEFINE_PROPERTYKEY!{PKEY_AcquisitionID, + 0x65A98875, 0x3C80, 0x40AB, 0xAB, 0xBC, 0xEF, 0xDA, 0xF7, 0x7D, 0xBE, 0xE2, 100} +DEFINE_PROPERTYKEY!{PKEY_ApplicationDefinedProperties, + 0xCDBFC167, 0x337E, 0x41D8, 0xAF, 0x7C, 0x8C, 0x09, 0x20, 0x54, 0x29, 0xC7, 100} +DEFINE_PROPERTYKEY!{PKEY_ApplicationName, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 18} +DEFINE_PROPERTYKEY!{PKEY_AppZoneIdentifier, + 0x502CFEAB, 0x47EB, 0x459C, 0xB9, 0x60, 0xE6, 0xD8, 0x72, 0x8F, 0x77, 0x01, 102} +DEFINE_PROPERTYKEY!{PKEY_Author, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 4} +DEFINE_PROPERTYKEY!{PKEY_CachedFileUpdaterContentIdForConflictResolution, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 114} +DEFINE_PROPERTYKEY!{PKEY_CachedFileUpdaterContentIdForStream, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 113} +DEFINE_PROPERTYKEY!{PKEY_Capacity, + 0x9B174B35, 0x40FF, 0x11D2, 0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71, 3} +DEFINE_PROPERTYKEY!{PKEY_Category, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 2} +DEFINE_PROPERTYKEY!{PKEY_Comment, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 6} +DEFINE_PROPERTYKEY!{PKEY_Company, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 15} +DEFINE_PROPERTYKEY!{PKEY_ComputerName, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 5} +DEFINE_PROPERTYKEY!{PKEY_ContainedItems, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 29} +DEFINE_PROPERTYKEY!{PKEY_ContentStatus, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 27} +DEFINE_PROPERTYKEY!{PKEY_ContentType, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 26} +DEFINE_PROPERTYKEY!{PKEY_Copyright, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 11} +DEFINE_PROPERTYKEY!{PKEY_CreatorAppId, + 0xC2EA046E, 0x033C, 0x4E91, 0xBD, 0x5B, 0xD4, 0x94, 0x2F, 0x6B, 0xBE, 0x49, 2} +DEFINE_PROPERTYKEY!{PKEY_CreatorOpenWithUIOptions, + 0xC2EA046E, 0x033C, 0x4E91, 0xBD, 0x5B, 0xD4, 0x94, 0x2F, 0x6B, 0xBE, 0x49, 3} +pub const CREATOROPENWITHUIOPTION_HIDDEN: DWORD = 0; +pub const CREATOROPENWITHUIOPTION_VISIBLE: DWORD = 1; +DEFINE_PROPERTYKEY!{PKEY_DataObjectFormat, + 0x1E81A3F8, 0xA30F, 0x4247, 0xB9, 0xEE, 0x1D, 0x03, 0x68, 0xA9, 0x42, 0x5C, 2} +DEFINE_PROPERTYKEY!{PKEY_DateAccessed, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 16} +DEFINE_PROPERTYKEY!{PKEY_DateAcquired, + 0x2CBAA8F5, 0xD81F, 0x47CA, 0xB1, 0x7A, 0xF8, 0xD8, 0x22, 0x30, 0x01, 0x31, 100} +DEFINE_PROPERTYKEY!{PKEY_DateArchived, + 0x43F8D7B7, 0xA444, 0x4F87, 0x93, 0x83, 0x52, 0x27, 0x1C, 0x9B, 0x91, 0x5C, 100} +DEFINE_PROPERTYKEY!{PKEY_DateCompleted, + 0x72FAB781, 0xACDA, 0x43E5, 0xB1, 0x55, 0xB2, 0x43, 0x4F, 0x85, 0xE6, 0x78, 100} +DEFINE_PROPERTYKEY!{PKEY_DateCreated, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 15} +DEFINE_PROPERTYKEY!{PKEY_DateImported, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 18258} +DEFINE_PROPERTYKEY!{PKEY_DateModified, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 14} +DEFINE_PROPERTYKEY!{PKEY_DefaultSaveLocationDisplay, + 0x5D76B67F, 0x9B3D, 0x44BB, 0xB6, 0xAE, 0x25, 0xDA, 0x4F, 0x63, 0x8A, 0x67, 10} +pub const ISDEFAULTSAVE_NONE: DWORD = 0; +pub const ISDEFAULTSAVE_OWNER: DWORD = 1; +pub const ISDEFAULTSAVE_NONOWNER: DWORD = 2; +pub const ISDEFAULTSAVE_BOTH: DWORD = 3; +DEFINE_PROPERTYKEY!{PKEY_DueDate, + 0x3F8472B5, 0xE0AF, 0x4DB2, 0x80, 0x71, 0xC5, 0x3F, 0xE7, 0x6A, 0xE7, 0xCE, 100} +DEFINE_PROPERTYKEY!{PKEY_EndDate, + 0xC75FAA05, 0x96FD, 0x49E7, 0x9C, 0xB4, 0x9F, 0x60, 0x10, 0x82, 0xD5, 0x53, 100} +DEFINE_PROPERTYKEY!{PKEY_ExpandoProperties, + 0x6FA20DE6, 0xD11C, 0x4D9D, 0xA1, 0x54, 0x64, 0x31, 0x76, 0x28, 0xC1, 0x2D, 100} +DEFINE_PROPERTYKEY!{PKEY_FileAllocationSize, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 18} +DEFINE_PROPERTYKEY!{PKEY_FileAttributes, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 13} +DEFINE_PROPERTYKEY!{PKEY_FileCount, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 12} +DEFINE_PROPERTYKEY!{PKEY_FileDescription, + 0x0CEF7D53, 0xFA64, 0x11D1, 0xA2, 0x03, 0x00, 0x00, 0xF8, 0x1F, 0xED, 0xEE, 3} +DEFINE_PROPERTYKEY!{PKEY_FileExtension, + 0xE4F10A3C, 0x49E6, 0x405D, 0x82, 0x88, 0xA2, 0x3B, 0xD4, 0xEE, 0xAA, 0x6C, 100} +DEFINE_PROPERTYKEY!{PKEY_FileFRN, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 21} +DEFINE_PROPERTYKEY!{PKEY_FileName, + 0x41CF5AE0, 0xF75A, 0x4806, 0xBD, 0x87, 0x59, 0xC7, 0xD9, 0x24, 0x8E, 0xB9, 100} +DEFINE_PROPERTYKEY!{PKEY_FileOfflineAvailabilityStatus, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 100} +pub const FILEOFFLINEAVAILABILITYSTATUS_PROP_NOTAVAILABLEOFFLINE: DWORD = 0; +pub const FILEOFFLINEAVAILABILITYSTATUS_PROP_PARTIALLYAVAILABLEOFFLINE: DWORD = 1; +DEFINE_PROPERTYKEY!{PKEY_FileOwner, + 0x9B174B34, 0x40FF, 0x11D2, 0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71, 4} +DEFINE_PROPERTYKEY!{PKEY_FilePlaceholderStatus, + 0xB2F9B9D6, 0xFEC4, 0x4DD5, 0x94, 0xD7, 0x89, 0x57, 0x48, 0x8C, 0x80, 0x7B, 2} +DEFINE_PROPERTYKEY!{PKEY_FileVersion, + 0x0CEF7D53, 0xFA64, 0x11D1, 0xA2, 0x03, 0x00, 0x00, 0xF8, 0x1F, 0xED, 0xEE, 4} +DEFINE_PROPERTYKEY!{PKEY_FindData, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 0} +DEFINE_PROPERTYKEY!{PKEY_FlagColor, + 0x67DF94DE, 0x0CA7, 0x4D6F, 0xB7, 0x92, 0x05, 0x3A, 0x3E, 0x4F, 0x03, 0xCF, 100} +pub const FLAGCOLOR_PURPLE: DWORD = 1; +pub const FLAGCOLOR_ORANGE: DWORD = 2; +pub const FLAGCOLOR_GREEN: DWORD = 3; +pub const FLAGCOLOR_YELLOW: DWORD = 4; +pub const FLAGCOLOR_BLUE: DWORD = 5; +pub const FLAGCOLOR_RED: DWORD = 6; +DEFINE_PROPERTYKEY!{PKEY_FlagColorText, + 0x45EAE747, 0x8E2A, 0x40AE, 0x8C, 0xBF, 0xCA, 0x52, 0xAB, 0xA6, 0x15, 0x2A, 100} +DEFINE_PROPERTYKEY!{PKEY_FlagStatus, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 12} +pub const FLAGSTATUS_NOTFLAGGED: LONG = 0; +pub const FLAGSTATUS_COMPLETED: LONG = 1; +pub const FLAGSTATUS_FOLLOWUP: LONG = 2; +DEFINE_PROPERTYKEY!{PKEY_FlagStatusText, + 0xDC54FD2E, 0x189D, 0x4871, 0xAA, 0x01, 0x08, 0xC2, 0xF5, 0x7A, 0x4A, 0xBC, 100} +DEFINE_PROPERTYKEY!{PKEY_FolderKind, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 101} +DEFINE_PROPERTYKEY!{PKEY_FolderNameDisplay, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 25} +DEFINE_PROPERTYKEY!{PKEY_FreeSpace, + 0x9B174B35, 0x40FF, 0x11D2, 0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71, 2} +DEFINE_PROPERTYKEY!{PKEY_FullText, + 0x1E3EE840, 0xBC2B, 0x476C, 0x82, 0x37, 0x2A, 0xCD, 0x1A, 0x83, 0x9B, 0x22, 6} +DEFINE_PROPERTYKEY!{PKEY_HighKeywords, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 24} +DEFINE_PROPERTYKEY!{PKEY_Identity, + 0xA26F4AFC, 0x7346, 0x4299, 0xBE, 0x47, 0xEB, 0x1A, 0xE6, 0x13, 0x13, 0x9F, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_Blob, + 0x8C3B93A4, 0xBAED, 0x1A83, 0x9A, 0x32, 0x10, 0x2E, 0xE3, 0x13, 0xF6, 0xEB, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_DisplayName, + 0x7D683FC9, 0xD155, 0x45A8, 0xBB, 0x1F, 0x89, 0xD1, 0x9B, 0xCB, 0x79, 0x2F, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_InternetSid, + 0x6D6D5D49, 0x265D, 0x4688, 0x9F, 0x4E, 0x1F, 0xDD, 0x33, 0xE7, 0xCC, 0x83, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_IsMeIdentity, + 0xA4108708, 0x09DF, 0x4377, 0x9D, 0xFC, 0x6D, 0x99, 0x98, 0x6D, 0x5A, 0x67, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_KeyProviderContext, + 0xA26F4AFC, 0x7346, 0x4299, 0xBE, 0x47, 0xEB, 0x1A, 0xE6, 0x13, 0x13, 0x9F, 17} +DEFINE_PROPERTYKEY!{PKEY_Identity_KeyProviderName, + 0xA26F4AFC, 0x7346, 0x4299, 0xBE, 0x47, 0xEB, 0x1A, 0xE6, 0x13, 0x13, 0x9F, 16} +DEFINE_PROPERTYKEY!{PKEY_Identity_LogonStatusString, + 0xF18DEDF3, 0x337F, 0x42C0, 0x9E, 0x03, 0xCE, 0xE0, 0x87, 0x08, 0xA8, 0xC3, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_PrimaryEmailAddress, + 0xFCC16823, 0xBAED, 0x4F24, 0x9B, 0x32, 0xA0, 0x98, 0x21, 0x17, 0xF7, 0xFA, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_PrimarySid, + 0x2B1B801E, 0xC0C1, 0x4987, 0x9E, 0xC5, 0x72, 0xFA, 0x89, 0x81, 0x47, 0x87, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_ProviderData, + 0xA8A74B92, 0x361B, 0x4E9A, 0xB7, 0x22, 0x7C, 0x4A, 0x73, 0x30, 0xA3, 0x12, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_ProviderID, + 0x74A7DE49, 0xFA11, 0x4D3D, 0xA0, 0x06, 0xDB, 0x7E, 0x08, 0x67, 0x59, 0x16, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_QualifiedUserName, + 0xDA520E51, 0xF4E9, 0x4739, 0xAC, 0x82, 0x02, 0xE0, 0xA9, 0x5C, 0x90, 0x30, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_UniqueID, + 0xE55FC3B0, 0x2B60, 0x4220, 0x91, 0x8E, 0xB2, 0x1E, 0x8B, 0xF1, 0x60, 0x16, 100} +DEFINE_PROPERTYKEY!{PKEY_Identity_UserName, + 0xC4322503, 0x78CA, 0x49C6, 0x9A, 0xCC, 0xA6, 0x8E, 0x2A, 0xFD, 0x7B, 0x6B, 100} +DEFINE_PROPERTYKEY!{PKEY_IdentityProvider_Name, + 0xB96EFF7B, 0x35CA, 0x4A35, 0x86, 0x07, 0x29, 0xE3, 0xA5, 0x4C, 0x46, 0xEA, 100} +DEFINE_PROPERTYKEY!{PKEY_IdentityProvider_Picture, + 0x2425166F, 0x5642, 0x4864, 0x99, 0x2F, 0x98, 0xFD, 0x98, 0xF2, 0x94, 0xC3, 100} +DEFINE_PROPERTYKEY!{PKEY_ImageParsingName, + 0xD7750EE0, 0xC6A4, 0x48EC, 0xB5, 0x3E, 0xB8, 0x7B, 0x52, 0xE6, 0xD0, 0x73, 100} +DEFINE_PROPERTYKEY!{PKEY_Importance, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 11} +pub const IMPORTANCE_LOW_MIN: LONG = 0; +pub const IMPORTANCE_LOW_SET: LONG = 1; +pub const IMPORTANCE_LOW_MAX: LONG = 1; +pub const IMPORTANCE_NORMAL_MIN: LONG = 2; +pub const IMPORTANCE_NORMAL_SET: LONG = 3; +pub const IMPORTANCE_NORMAL_MAX: LONG = 4; +pub const IMPORTANCE_HIGH_MIN: LONG = 5; +pub const IMPORTANCE_HIGH_SET: LONG = 5; +pub const IMPORTANCE_HIGH_MAX: LONG = 5; +DEFINE_PROPERTYKEY!{PKEY_ImportanceText, + 0xA3B29791, 0x7713, 0x4E1D, 0xBB, 0x40, 0x17, 0xDB, 0x85, 0xF0, 0x18, 0x31, 100} +DEFINE_PROPERTYKEY!{PKEY_IsAttachment, + 0xF23F425C, 0x71A1, 0x4FA8, 0x92, 0x2F, 0x67, 0x8E, 0xA4, 0xA6, 0x04, 0x08, 100} +DEFINE_PROPERTYKEY!{PKEY_IsDefaultNonOwnerSaveLocation, + 0x5D76B67F, 0x9B3D, 0x44BB, 0xB6, 0xAE, 0x25, 0xDA, 0x4F, 0x63, 0x8A, 0x67, 5} +DEFINE_PROPERTYKEY!{PKEY_IsDefaultSaveLocation, + 0x5D76B67F, 0x9B3D, 0x44BB, 0xB6, 0xAE, 0x25, 0xDA, 0x4F, 0x63, 0x8A, 0x67, 3} +DEFINE_PROPERTYKEY!{PKEY_IsDeleted, + 0x5CDA5FC8, 0x33EE, 0x4FF3, 0x90, 0x94, 0xAE, 0x7B, 0xD8, 0x86, 0x8C, 0x4D, 100} +DEFINE_PROPERTYKEY!{PKEY_IsEncrypted, + 0x90E5E14E, 0x648B, 0x4826, 0xB2, 0xAA, 0xAC, 0xAF, 0x79, 0x0E, 0x35, 0x13, 10} +DEFINE_PROPERTYKEY!{PKEY_IsFlagged, + 0x5DA84765, 0xE3FF, 0x4278, 0x86, 0xB0, 0xA2, 0x79, 0x67, 0xFB, 0xDD, 0x03, 100} +DEFINE_PROPERTYKEY!{PKEY_IsFlaggedComplete, + 0xA6F360D2, 0x55F9, 0x48DE, 0xB9, 0x09, 0x62, 0x0E, 0x09, 0x0A, 0x64, 0x7C, 100} +DEFINE_PROPERTYKEY!{PKEY_IsIncomplete, + 0x346C8BD1, 0x2E6A, 0x4C45, 0x89, 0xA4, 0x61, 0xB7, 0x8E, 0x8E, 0x70, 0x0F, 100} +DEFINE_PROPERTYKEY!{PKEY_IsLocationSupported, + 0x5D76B67F, 0x9B3D, 0x44BB, 0xB6, 0xAE, 0x25, 0xDA, 0x4F, 0x63, 0x8A, 0x67, 8} +DEFINE_PROPERTYKEY!{PKEY_IsPinnedToNameSpaceTree, + 0x5D76B67F, 0x9B3D, 0x44BB, 0xB6, 0xAE, 0x25, 0xDA, 0x4F, 0x63, 0x8A, 0x67, 2} +DEFINE_PROPERTYKEY!{PKEY_IsRead, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 10} +DEFINE_PROPERTYKEY!{PKEY_IsSearchOnlyItem, + 0x5D76B67F, 0x9B3D, 0x44BB, 0xB6, 0xAE, 0x25, 0xDA, 0x4F, 0x63, 0x8A, 0x67, 4} +DEFINE_PROPERTYKEY!{PKEY_IsSendToTarget, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 33} +DEFINE_PROPERTYKEY!{PKEY_IsShared, + 0xEF884C5B, 0x2BFE, 0x41BB, 0xAA, 0xE5, 0x76, 0xEE, 0xDF, 0x4F, 0x99, 0x02, 100} +DEFINE_PROPERTYKEY!{PKEY_ItemAuthors, + 0xD0A04F0A, 0x462A, 0x48A4, 0xBB, 0x2F, 0x37, 0x06, 0xE8, 0x8D, 0xBD, 0x7D, 100} +DEFINE_PROPERTYKEY!{PKEY_ItemClassType, + 0x048658AD, 0x2DB8, 0x41A4, 0xBB, 0xB6, 0xAC, 0x1E, 0xF1, 0x20, 0x7E, 0xB1, 100} +DEFINE_PROPERTYKEY!{PKEY_ItemDate, + 0xF7DB74B4, 0x4287, 0x4103, 0xAF, 0xBA, 0xF1, 0xB1, 0x3D, 0xCD, 0x75, 0xCF, 100} +DEFINE_PROPERTYKEY!{PKEY_ItemFolderNameDisplay, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 2} +DEFINE_PROPERTYKEY!{PKEY_ItemFolderPathDisplay, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 6} +DEFINE_PROPERTYKEY!{PKEY_ItemFolderPathDisplayNarrow, + 0xDABD30ED, 0x0043, 0x4789, 0xA7, 0xF8, 0xD0, 0x13, 0xA4, 0x73, 0x66, 0x22, 100} +DEFINE_PROPERTYKEY!{PKEY_ItemName, + 0x6B8DA074, 0x3B5C, 0x43BC, 0x88, 0x6F, 0x0A, 0x2C, 0xDC, 0xE0, 0x0B, 0x6F, 100} +DEFINE_PROPERTYKEY!{PKEY_ItemNameDisplay, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 10} +DEFINE_PROPERTYKEY!{PKEY_ItemNameDisplayWithoutExtension, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 24} +DEFINE_PROPERTYKEY!{PKEY_ItemNamePrefix, + 0xD7313FF1, 0xA77A, 0x401C, 0x8C, 0x99, 0x3D, 0xBD, 0xD6, 0x8A, 0xDD, 0x36, 100} +DEFINE_PROPERTYKEY!{PKEY_ItemNameSortOverride, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 23} +DEFINE_PROPERTYKEY!{PKEY_ItemParticipants, + 0xD4D0AA16, 0x9948, 0x41A4, 0xAA, 0x85, 0xD9, 0x7F, 0xF9, 0x64, 0x69, 0x93, 100} +DEFINE_PROPERTYKEY!{PKEY_ItemPathDisplay, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 7} +DEFINE_PROPERTYKEY!{PKEY_ItemPathDisplayNarrow, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 8} +DEFINE_PROPERTYKEY!{PKEY_ItemSubType, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 37} +DEFINE_PROPERTYKEY!{PKEY_ItemType, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 11} +DEFINE_PROPERTYKEY!{PKEY_ItemTypeText, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 4} +DEFINE_PROPERTYKEY!{PKEY_ItemUrl, + 0x49691C90, 0x7E17, 0x101A, 0xA9, 0x1C, 0x08, 0x00, 0x2B, 0x2E, 0xCD, 0xA9, 9} +DEFINE_PROPERTYKEY!{PKEY_Keywords, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 5} +DEFINE_PROPERTYKEY!{PKEY_Kind, + 0x1E3EE840, 0xBC2B, 0x476C, 0x82, 0x37, 0x2A, 0xCD, 0x1A, 0x83, 0x9B, 0x22, 3} +pub const KIND_CALENDAR: &'static str = "calendar"; +pub const KIND_COMMUNICATION: &'static str = "communication"; +pub const KIND_CONTACT: &'static str = "contact"; +pub const KIND_DOCUMENT: &'static str = "document"; +pub const KIND_EMAIL: &'static str = "email"; +pub const KIND_FEED: &'static str = "feed"; +pub const KIND_FOLDER: &'static str = "folder"; +pub const KIND_GAME: &'static str = "game"; +pub const KIND_INSTANTMESSAGE: &'static str = "instantmessage"; +pub const KIND_JOURNAL: &'static str = "journal"; +pub const KIND_LINK: &'static str = "link"; +pub const KIND_MOVIE: &'static str = "movie"; +pub const KIND_MUSIC: &'static str = "music"; +pub const KIND_NOTE: &'static str = "note"; +pub const KIND_PICTURE: &'static str = "picture"; +pub const KIND_PLAYLIST: &'static str = "playlist"; +pub const KIND_PROGRAM: &'static str = "program"; +pub const KIND_RECORDEDTV: &'static str = "recordedtv"; +pub const KIND_SEARCHFOLDER: &'static str = "searchfolder"; +pub const KIND_TASK: &'static str = "task"; +pub const KIND_VIDEO: &'static str = "video"; +pub const KIND_WEBHISTORY: &'static str = "webhistory"; +pub const KIND_UNKNOWN: &'static str = "unknown"; +DEFINE_PROPERTYKEY!{PKEY_KindText, + 0xF04BEF95, 0xC585, 0x4197, 0xA2, 0xB7, 0xDF, 0x46, 0xFD, 0xC9, 0xEE, 0x6D, 100} +DEFINE_PROPERTYKEY!{PKEY_Language, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 28} +DEFINE_PROPERTYKEY!{PKEY_LastSyncError, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 107} +DEFINE_PROPERTYKEY!{PKEY_LastWriterPackageFamilyName, + 0x502CFEAB, 0x47EB, 0x459C, 0xB9, 0x60, 0xE6, 0xD8, 0x72, 0x8F, 0x77, 0x01, 101} +DEFINE_PROPERTYKEY!{PKEY_LowKeywords, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 25} +DEFINE_PROPERTYKEY!{PKEY_MediumKeywords, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 26} +DEFINE_PROPERTYKEY!{PKEY_MileageInformation, + 0xFDF84370, 0x031A, 0x4ADD, 0x9E, 0x91, 0x0D, 0x77, 0x5F, 0x1C, 0x66, 0x05, 100} +DEFINE_PROPERTYKEY!{PKEY_MIMEType, + 0x0B63E350, 0x9CCC, 0x11D0, 0xBC, 0xDB, 0x00, 0x80, 0x5F, 0xCC, 0xCE, 0x04, 5} +DEFINE_PROPERTYKEY!{PKEY_Null, + 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0} +DEFINE_PROPERTYKEY!{PKEY_OfflineAvailability, + 0xA94688B6, 0x7D9F, 0x4570, 0xA6, 0x48, 0xE3, 0xDF, 0xC0, 0xAB, 0x2B, 0x3F, 100} +pub const OFFLINEAVAILABILITY_NOT_AVAILABLE: DWORD = 0; +pub const OFFLINEAVAILABILITY_AVAILABLE: DWORD = 1; +pub const OFFLINEAVAILABILITY_ALWAYS_AVAILABLE: DWORD = 2; +DEFINE_PROPERTYKEY!{PKEY_OfflineStatus, + 0x6D24888F, 0x4718, 0x4BDA, 0xAF, 0xED, 0xEA, 0x0F, 0xB4, 0x38, 0x6C, 0xD8, 100} +pub const OFFLINESTATUS_ONLINE: DWORD = 0; +pub const OFFLINESTATUS_OFFLINE: DWORD = 1; +pub const OFFLINESTATUS_OFFLINE_FORCED: DWORD = 2; +pub const OFFLINESTATUS_OFFLINE_SLOW: DWORD = 3; +pub const OFFLINESTATUS_OFFLINE_ERROR: DWORD = 4; +pub const OFFLINESTATUS_OFFLINE_ITEM_VERSION_CONFLICT: DWORD = 5; +pub const OFFLINESTATUS_OFFLINE_SUSPENDED: DWORD = 6; +DEFINE_PROPERTYKEY!{PKEY_OriginalFileName, + 0x0CEF7D53, 0xFA64, 0x11D1, 0xA2, 0x03, 0x00, 0x00, 0xF8, 0x1F, 0xED, 0xEE, 6} +DEFINE_PROPERTYKEY!{PKEY_OwnerSID, + 0x5D76B67F, 0x9B3D, 0x44BB, 0xB6, 0xAE, 0x25, 0xDA, 0x4F, 0x63, 0x8A, 0x67, 6} +DEFINE_PROPERTYKEY!{PKEY_ParentalRating, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 21} +DEFINE_PROPERTYKEY!{PKEY_ParentalRatingReason, + 0x10984E0A, 0xF9F2, 0x4321, 0xB7, 0xEF, 0xBA, 0xF1, 0x95, 0xAF, 0x43, 0x19, 100} +DEFINE_PROPERTYKEY!{PKEY_ParentalRatingsOrganization, + 0xA7FE0840, 0x1344, 0x46F0, 0x8D, 0x37, 0x52, 0xED, 0x71, 0x2A, 0x4B, 0xF9, 100} +DEFINE_PROPERTYKEY!{PKEY_ParsingBindContext, + 0xDFB9A04D, 0x362F, 0x4CA3, 0xB3, 0x0B, 0x02, 0x54, 0xB1, 0x7B, 0x5B, 0x84, 100} +DEFINE_PROPERTYKEY!{PKEY_ParsingName, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 24} +DEFINE_PROPERTYKEY!{PKEY_ParsingPath, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 30} +DEFINE_PROPERTYKEY!{PKEY_PerceivedType, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 9} +DEFINE_PROPERTYKEY!{PKEY_PercentFull, + 0x9B174B35, 0x40FF, 0x11D2, 0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71, 5} +DEFINE_PROPERTYKEY!{PKEY_Priority, + 0x9C1FCF74, 0x2D97, 0x41BA, 0xB4, 0xAE, 0xCB, 0x2E, 0x36, 0x61, 0xA6, 0xE4, 5} +pub const PRIORITY_PROP_LOW: DWORD = 0; +pub const PRIORITY_PROP_NORMAL: DWORD = 1; +pub const PRIORITY_PROP_HIGH: DWORD = 2; +DEFINE_PROPERTYKEY!{PKEY_PriorityText, + 0xD98BE98B, 0xB86B, 0x4095, 0xBF, 0x52, 0x9D, 0x23, 0xB2, 0xE0, 0xA7, 0x52, 100} +DEFINE_PROPERTYKEY!{PKEY_Project, + 0x39A7F922, 0x477C, 0x48DE, 0x8B, 0xC8, 0xB2, 0x84, 0x41, 0xE3, 0x42, 0xE3, 100} +DEFINE_PROPERTYKEY!{PKEY_ProviderItemID, + 0xF21D9941, 0x81F0, 0x471A, 0xAD, 0xEE, 0x4E, 0x74, 0xB4, 0x92, 0x17, 0xED, 100} +DEFINE_PROPERTYKEY!{PKEY_Rating, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 9} +pub const RATING_ONE_STAR_MIN: DWORD = 1; +pub const RATING_ONE_STAR_SET: DWORD = 1; +pub const RATING_ONE_STAR_MAX: DWORD = 12; +pub const RATING_TWO_STARS_MIN: DWORD = 13; +pub const RATING_TWO_STARS_SET: DWORD = 25; +pub const RATING_TWO_STARS_MAX: DWORD = 37; +pub const RATING_THREE_STARS_MIN: DWORD = 38; +pub const RATING_THREE_STARS_SET: DWORD = 50; +pub const RATING_THREE_STARS_MAX: DWORD = 62; +pub const RATING_FOUR_STARS_MIN: DWORD = 63; +pub const RATING_FOUR_STARS_SET: DWORD = 75; +pub const RATING_FOUR_STARS_MAX: DWORD = 87; +pub const RATING_FIVE_STARS_MIN: DWORD = 88; +pub const RATING_FIVE_STARS_SET: DWORD = 99; +pub const RATING_FIVE_STARS_MAX: DWORD = 99; +DEFINE_PROPERTYKEY!{PKEY_RatingText, + 0x90197CA7, 0xFD8F, 0x4E8C, 0x9D, 0xA3, 0xB5, 0x7E, 0x1E, 0x60, 0x92, 0x95, 100} +DEFINE_PROPERTYKEY!{PKEY_RemoteConflictingFile, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 115} +DEFINE_PROPERTYKEY!{PKEY_Security_AllowedEnterpriseDataProtectionIdentities, + 0x38D43380, 0xD418, 0x4830, 0x84, 0xD5, 0x46, 0x93, 0x5A, 0x81, 0xC5, 0xC6, 32} +DEFINE_PROPERTYKEY!{PKEY_Security_EncryptionOwners, + 0x5F5AFF6A, 0x37E5, 0x4780, 0x97, 0xEA, 0x80, 0xC7, 0x56, 0x5C, 0xF5, 0x35, 34} +DEFINE_PROPERTYKEY!{PKEY_Security_EncryptionOwnersDisplay, + 0xDE621B8F, 0xE125, 0x43A3, 0xA3, 0x2D, 0x56, 0x65, 0x44, 0x6D, 0x63, 0x2A, 25} +DEFINE_PROPERTYKEY!{PKEY_Sensitivity, + 0xF8D3F6AC, 0x4874, 0x42CB, 0xBE, 0x59, 0xAB, 0x45, 0x4B, 0x30, 0x71, 0x6A, 100} +pub const SENSITIVITY_PROP_NORMAL: DWORD = 0; +pub const SENSITIVITY_PROP_PERSONAL: DWORD = 1; +pub const SENSITIVITY_PROP_PRIVATE: DWORD = 2; +pub const SENSITIVITY_PROP_CONFIDENTIAL: DWORD = 3; +DEFINE_PROPERTYKEY!{PKEY_SensitivityText, + 0xD0C7F054, 0x3F72, 0x4725, 0x85, 0x27, 0x12, 0x9A, 0x57, 0x7C, 0xB2, 0x69, 100} +DEFINE_PROPERTYKEY!{PKEY_SFGAOFlags, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 25} +DEFINE_PROPERTYKEY!{PKEY_SharedWith, + 0xEF884C5B, 0x2BFE, 0x41BB, 0xAA, 0xE5, 0x76, 0xEE, 0xDF, 0x4F, 0x99, 0x02, 200} +DEFINE_PROPERTYKEY!{PKEY_ShareUserRating, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 12} +DEFINE_PROPERTYKEY!{PKEY_SharingStatus, + 0xEF884C5B, 0x2BFE, 0x41BB, 0xAA, 0xE5, 0x76, 0xEE, 0xDF, 0x4F, 0x99, 0x02, 300} +pub const SHARINGSTATUS_NOTSHARED: DWORD = 0; +pub const SHARINGSTATUS_SHARED: DWORD = 1; +pub const SHARINGSTATUS_PRIVATE: DWORD = 2; +DEFINE_PROPERTYKEY!{PKEY_Shell_OmitFromView, + 0xDE35258C, 0xC695, 0x4CBC, 0xB9, 0x82, 0x38, 0xB0, 0xAD, 0x24, 0xCE, 0xD0, 2} +DEFINE_PROPERTYKEY!{PKEY_SimpleRating, + 0xA09F084E, 0xAD41, 0x489F, 0x80, 0x76, 0xAA, 0x5B, 0xE3, 0x08, 0x2B, 0xCA, 100} +DEFINE_PROPERTYKEY!{PKEY_Size, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 12} +DEFINE_PROPERTYKEY!{PKEY_SoftwareUsed, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 305} +DEFINE_PROPERTYKEY!{PKEY_SourceItem, + 0x668CDFA5, 0x7A1B, 0x4323, 0xAE, 0x4B, 0xE5, 0x27, 0x39, 0x3A, 0x1D, 0x81, 100} +DEFINE_PROPERTYKEY!{PKEY_SourcePackageFamilyName, + 0xFFAE9DB7, 0x1C8D, 0x43FF, 0x81, 0x8C, 0x84, 0x40, 0x3A, 0xA3, 0x73, 0x2D, 100} +DEFINE_PROPERTYKEY!{PKEY_StartDate, + 0x48FD6EC8, 0x8A12, 0x4CDF, 0xA0, 0x3E, 0x4E, 0xC5, 0xA5, 0x11, 0xED, 0xDE, 100} +DEFINE_PROPERTYKEY!{PKEY_Status, + 0x000214A1, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 9} +DEFINE_PROPERTYKEY!{PKEY_StorageProviderCallerVersionInformation, + 0xB2F9B9D6, 0xFEC4, 0x4DD5, 0x94, 0xD7, 0x89, 0x57, 0x48, 0x8C, 0x80, 0x7B, 7} +DEFINE_PROPERTYKEY!{PKEY_StorageProviderError, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 109} +DEFINE_PROPERTYKEY!{PKEY_StorageProviderFileChecksum, + 0xB2F9B9D6, 0xFEC4, 0x4DD5, 0x94, 0xD7, 0x89, 0x57, 0x48, 0x8C, 0x80, 0x7B, 5} +DEFINE_PROPERTYKEY!{PKEY_StorageProviderFileIdentifier, + 0xB2F9B9D6, 0xFEC4, 0x4DD5, 0x94, 0xD7, 0x89, 0x57, 0x48, 0x8C, 0x80, 0x7B, 3} +DEFINE_PROPERTYKEY!{PKEY_StorageProviderFileRemoteUri, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 112} +DEFINE_PROPERTYKEY!{PKEY_StorageProviderFileVersion, + 0xB2F9B9D6, 0xFEC4, 0x4DD5, 0x94, 0xD7, 0x89, 0x57, 0x48, 0x8C, 0x80, 0x7B, 4} +DEFINE_PROPERTYKEY!{PKEY_StorageProviderFileVersionWaterline, + 0xB2F9B9D6, 0xFEC4, 0x4DD5, 0x94, 0xD7, 0x89, 0x57, 0x48, 0x8C, 0x80, 0x7B, 6} +DEFINE_PROPERTYKEY!{PKEY_StorageProviderId, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 108} +DEFINE_PROPERTYKEY!{PKEY_StorageProviderShareStatuses, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 111} +pub const STORAGE_PROVIDER_SHARE_STATUS_PRIVATE: &'static str = "Private"; +pub const STORAGE_PROVIDER_SHARE_STATUS_SHARED: &'static str = "Shared"; +pub const STORAGE_PROVIDER_SHARE_STATUS_PUBLIC: &'static str = "Public"; +pub const STORAGE_PROVIDER_SHARE_STATUS_GROUP: &'static str = "Group"; +pub const STORAGE_PROVIDER_SHARE_STATUS_OWNER: &'static str = "Owner"; +DEFINE_PROPERTYKEY!{PKEY_StorageProviderSharingStatus, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 117} +pub const STORAGE_PROVIDER_SHARINGSTATUS_NOTSHARED: DWORD = 0; +pub const STORAGE_PROVIDER_SHARINGSTATUS_SHARED: DWORD = 1; +pub const STORAGE_PROVIDER_SHARINGSTATUS_PRIVATE: DWORD = 2; +pub const STORAGE_PROVIDER_SHARINGSTATUS_PUBLIC: DWORD = 3; +pub const STORAGE_PROVIDER_SHARINGSTATUS_SHARED_OWNED: DWORD = 4; +pub const STORAGE_PROVIDER_SHARINGSTATUS_SHARED_COOWNED: DWORD = 5; +pub const STORAGE_PROVIDER_SHARINGSTATUS_PUBLIC_OWNED: DWORD = 6; +pub const STORAGE_PROVIDER_SHARINGSTATUS_PUBLIC_COOWNED: DWORD = 7; +DEFINE_PROPERTYKEY!{PKEY_StorageProviderStatus, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 110} +DEFINE_PROPERTYKEY!{PKEY_Subject, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 3} +DEFINE_PROPERTYKEY!{PKEY_SyncTransferStatus, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 103} +DEFINE_PROPERTYKEY!{PKEY_Thumbnail, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 17} +DEFINE_PROPERTYKEY!{PKEY_ThumbnailCacheId, + 0x446D16B1, 0x8DAD, 0x4870, 0xA7, 0x48, 0x40, 0x2E, 0xA4, 0x3D, 0x78, 0x8C, 100} +DEFINE_PROPERTYKEY!{PKEY_ThumbnailStream, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 27} +DEFINE_PROPERTYKEY!{PKEY_Title, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 2} +DEFINE_PROPERTYKEY!{PKEY_TitleSortOverride, + 0xF0F7984D, 0x222E, 0x4AD2, 0x82, 0xAB, 0x1D, 0xD8, 0xEA, 0x40, 0xE5, 0x7E, 300} +DEFINE_PROPERTYKEY!{PKEY_TotalFileSize, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 14} +DEFINE_PROPERTYKEY!{PKEY_Trademarks, + 0x0CEF7D53, 0xFA64, 0x11D1, 0xA2, 0x03, 0x00, 0x00, 0xF8, 0x1F, 0xED, 0xEE, 9} +DEFINE_PROPERTYKEY!{PKEY_TransferOrder, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 106} +DEFINE_PROPERTYKEY!{PKEY_TransferPosition, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 104} +DEFINE_PROPERTYKEY!{PKEY_TransferSize, + 0xFCEFF153, 0xE839, 0x4CF3, 0xA9, 0xE7, 0xEA, 0x22, 0x83, 0x20, 0x94, 0xB8, 105} +DEFINE_PROPERTYKEY!{PKEY_VolumeId, + 0x446D16B1, 0x8DAD, 0x4870, 0xA7, 0x48, 0x40, 0x2E, 0xA4, 0x3D, 0x78, 0x8C, 104} +DEFINE_PROPERTYKEY!{PKEY_ZoneIdentifier, + 0x502CFEAB, 0x47EB, 0x459C, 0xB9, 0x60, 0xE6, 0xD8, 0x72, 0x8F, 0x77, 0x01, 100} +DEFINE_PROPERTYKEY!{PKEY_Device_PrinterURL, + 0x0B48F35A, 0xBE6E, 0x4F17, 0xB1, 0x08, 0x3C, 0x40, 0x73, 0xD1, 0x66, 0x9A, 15} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Bluetooth_DeviceAddress, + 0x2BD67D8B, 0x8BEB, 0x48D5, 0x87, 0xE0, 0x6C, 0xDA, 0x34, 0x28, 0x04, 0x0A, 1} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Bluetooth_Flags, + 0x2BD67D8B, 0x8BEB, 0x48D5, 0x87, 0xE0, 0x6C, 0xDA, 0x34, 0x28, 0x04, 0x0A, 3} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Bluetooth_LastConnectedTime, + 0x2BD67D8B, 0x8BEB, 0x48D5, 0x87, 0xE0, 0x6C, 0xDA, 0x34, 0x28, 0x04, 0x0A, 11} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Bluetooth_Manufacturer, + 0x2BD67D8B, 0x8BEB, 0x48D5, 0x87, 0xE0, 0x6C, 0xDA, 0x34, 0x28, 0x04, 0x0A, 4} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Bluetooth_ModelNumber, + 0x2BD67D8B, 0x8BEB, 0x48D5, 0x87, 0xE0, 0x6C, 0xDA, 0x34, 0x28, 0x04, 0x0A, 5} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Bluetooth_ProductId, + 0x2BD67D8B, 0x8BEB, 0x48D5, 0x87, 0xE0, 0x6C, 0xDA, 0x34, 0x28, 0x04, 0x0A, 8} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Bluetooth_ProductVersion, + 0x2BD67D8B, 0x8BEB, 0x48D5, 0x87, 0xE0, 0x6C, 0xDA, 0x34, 0x28, 0x04, 0x0A, 9} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Bluetooth_ServiceGuid, + 0x2BD67D8B, 0x8BEB, 0x48D5, 0x87, 0xE0, 0x6C, 0xDA, 0x34, 0x28, 0x04, 0x0A, 2} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Bluetooth_VendorId, + 0x2BD67D8B, 0x8BEB, 0x48D5, 0x87, 0xE0, 0x6C, 0xDA, 0x34, 0x28, 0x04, 0x0A, 7} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Bluetooth_VendorIdSource, + 0x2BD67D8B, 0x8BEB, 0x48D5, 0x87, 0xE0, 0x6C, 0xDA, 0x34, 0x28, 0x04, 0x0A, 6} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Hid_IsReadOnly, + 0xCBF38310, 0x4A17, 0x4310, 0xA1, 0xEB, 0x24, 0x7F, 0x0B, 0x67, 0x59, 0x3B, 4} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Hid_ProductId, + 0xCBF38310, 0x4A17, 0x4310, 0xA1, 0xEB, 0x24, 0x7F, 0x0B, 0x67, 0x59, 0x3B, 6} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Hid_UsageId, + 0xCBF38310, 0x4A17, 0x4310, 0xA1, 0xEB, 0x24, 0x7F, 0x0B, 0x67, 0x59, 0x3B, 3} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Hid_UsagePage, + 0xCBF38310, 0x4A17, 0x4310, 0xA1, 0xEB, 0x24, 0x7F, 0x0B, 0x67, 0x59, 0x3B, 2} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Hid_VendorId, + 0xCBF38310, 0x4A17, 0x4310, 0xA1, 0xEB, 0x24, 0x7F, 0x0B, 0x67, 0x59, 0x3B, 5} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Hid_VersionNumber, + 0xCBF38310, 0x4A17, 0x4310, 0xA1, 0xEB, 0x24, 0x7F, 0x0B, 0x67, 0x59, 0x3B, 7} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_PrinterDriverDirectory, + 0x847C66DE, 0xB8D6, 0x4AF9, 0xAB, 0xC3, 0x6F, 0x4F, 0x92, 0x6B, 0xC0, 0x39, 14} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_PrinterDriverName, + 0xAFC47170, 0x14F5, 0x498C, 0x8F, 0x30, 0xB0, 0xD1, 0x9B, 0xE4, 0x49, 0xC6, 11} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_PrinterEnumerationFlag, + 0xA00742A1, 0xCD8C, 0x4B37, 0x95, 0xAB, 0x70, 0x75, 0x55, 0x87, 0x76, 0x7A, 3} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_PrinterName, + 0x0A7B84EF, 0x0C27, 0x463F, 0x84, 0xEF, 0x06, 0xC5, 0x07, 0x00, 0x01, 0xBE, 10} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_PrinterPortName, + 0xEEC7B761, 0x6F94, 0x41B1, 0x94, 0x9F, 0xC7, 0x29, 0x72, 0x0D, 0xD1, 0x3C, 12} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Proximity_SupportsNfc, + 0xFB3842CD, 0x9E2A, 0x4F83, 0x8F, 0xCC, 0x4B, 0x07, 0x61, 0x13, 0x9A, 0xE9, 2} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Serial_PortName, + 0x4C6BF15C, 0x4C03, 0x4AAC, 0x91, 0xF5, 0x64, 0xC0, 0xF8, 0x52, 0xBC, 0xF4, 4} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Serial_UsbProductId, + 0x4C6BF15C, 0x4C03, 0x4AAC, 0x91, 0xF5, 0x64, 0xC0, 0xF8, 0x52, 0xBC, 0xF4, 3} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_Serial_UsbVendorId, + 0x4C6BF15C, 0x4C03, 0x4AAC, 0x91, 0xF5, 0x64, 0xC0, 0xF8, 0x52, 0xBC, 0xF4, 2} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_WinUsb_DeviceInterfaceClasses, + 0x95E127B5, 0x79CC, 0x4E83, 0x9C, 0x9E, 0x84, 0x22, 0x18, 0x7B, 0x3E, 0x0E, 7} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_WinUsb_UsbClass, + 0x95E127B5, 0x79CC, 0x4E83, 0x9C, 0x9E, 0x84, 0x22, 0x18, 0x7B, 0x3E, 0x0E, 4} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_WinUsb_UsbProductId, + 0x95E127B5, 0x79CC, 0x4E83, 0x9C, 0x9E, 0x84, 0x22, 0x18, 0x7B, 0x3E, 0x0E, 3} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_WinUsb_UsbProtocol, + 0x95E127B5, 0x79CC, 0x4E83, 0x9C, 0x9E, 0x84, 0x22, 0x18, 0x7B, 0x3E, 0x0E, 6} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_WinUsb_UsbSubClass, + 0x95E127B5, 0x79CC, 0x4E83, 0x9C, 0x9E, 0x84, 0x22, 0x18, 0x7B, 0x3E, 0x0E, 5} +DEFINE_PROPERTYKEY!{PKEY_DeviceInterface_WinUsb_UsbVendorId, + 0x95E127B5, 0x79CC, 0x4E83, 0x9C, 0x9E, 0x84, 0x22, 0x18, 0x7B, 0x3E, 0x0E, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_AepId, + 0x3B2CE006, 0x5E61, 0x4FDE, 0xBA, 0xB8, 0x9B, 0x8A, 0xAC, 0x9B, 0x26, 0xDF, 8} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Major, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Minor, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Services_Audio, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 10} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Services_Capturing, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 8} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Services_Information, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 12} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Services_LimitedDiscovery, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Services_Networking, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Services_ObjectXfer, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 9} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Services_Positioning, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Services_Rendering, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 7} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Cod_Services_Telephony, + 0x5FBD34CD, 0x561A, 0x412E, 0xBA, 0x98, 0x47, 0x8A, 0x6B, 0x0F, 0xEF, 0x1D, 11} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Le_AddressType, + 0x995EF0B0, 0x7EB3, 0x4A8B, 0xB9, 0xCE, 0x06, 0x8B, 0xB3, 0xF4, 0xAF, 0x69, 4} +pub const BLUETOOTH_ADDRESS_TYPE_PUBLIC: LONG = 0; +pub const BLUETOOTH_ADDRESS_TYPE_RANDOM: LONG = 1; +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Le_Appearance, + 0x995EF0B0, 0x7EB3, 0x4A8B, 0xB9, 0xCE, 0x06, 0x8B, 0xB3, 0xF4, 0xAF, 0x69, 1} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Le_Appearance_Category, + 0x995EF0B0, 0x7EB3, 0x4A8B, 0xB9, 0xCE, 0x06, 0x8B, 0xB3, 0xF4, 0xAF, 0x69, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Le_Appearance_Subcategory, + 0x995EF0B0, 0x7EB3, 0x4A8B, 0xB9, 0xCE, 0x06, 0x8B, 0xB3, 0xF4, 0xAF, 0x69, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Bluetooth_Le_IsConnectable, + 0x995EF0B0, 0x7EB3, 0x4A8B, 0xB9, 0xCE, 0x06, 0x8B, 0xB3, 0xF4, 0xAF, 0x69, 8} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_CanPair, + 0xE7C3FB29, 0xCAA7, 0x4F47, 0x8C, 0x8B, 0xBE, 0x59, 0xB3, 0x30, 0xD4, 0xC5, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Category, + 0xA35996AB, 0x11CF, 0x4935, 0x8B, 0x61, 0xA6, 0x76, 0x10, 0x81, 0xEC, 0xDF, 17} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_ContainerId, + 0xE7C3FB29, 0xCAA7, 0x4F47, 0x8C, 0x8B, 0xBE, 0x59, 0xB3, 0x30, 0xD4, 0xC5, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_DeviceAddress, + 0xA35996AB, 0x11CF, 0x4935, 0x8B, 0x61, 0xA6, 0x76, 0x10, 0x81, 0xEC, 0xDF, 12} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_IsConnected, + 0xA35996AB, 0x11CF, 0x4935, 0x8B, 0x61, 0xA6, 0x76, 0x10, 0x81, 0xEC, 0xDF, 7} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_IsPaired, + 0xA35996AB, 0x11CF, 0x4935, 0x8B, 0x61, 0xA6, 0x76, 0x10, 0x81, 0xEC, 0xDF, 16} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_IsPresent, + 0xA35996AB, 0x11CF, 0x4935, 0x8B, 0x61, 0xA6, 0x76, 0x10, 0x81, 0xEC, 0xDF, 9} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_Manufacturer, + 0xA35996AB, 0x11CF, 0x4935, 0x8B, 0x61, 0xA6, 0x76, 0x10, 0x81, 0xEC, 0xDF, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_ModelId, + 0xA35996AB, 0x11CF, 0x4935, 0x8B, 0x61, 0xA6, 0x76, 0x10, 0x81, 0xEC, 0xDF, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_ModelName, + 0xA35996AB, 0x11CF, 0x4935, 0x8B, 0x61, 0xA6, 0x76, 0x10, 0x81, 0xEC, 0xDF, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_PointOfService_ConnectionTypes, + 0xD4BF61B3, 0x442E, 0x4ADA, 0x88, 0x2D, 0xFA, 0x7B, 0x70, 0xC8, 0x32, 0xD9, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_ProtocolId, + 0x3B2CE006, 0x5E61, 0x4FDE, 0xBA, 0xB8, 0x9B, 0x8A, 0xAC, 0x9B, 0x26, 0xDF, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_Aep_SignalStrength, + 0xA35996AB, 0x11CF, 0x4935, 0x8B, 0x61, 0xA6, 0x76, 0x10, 0x81, 0xEC, 0xDF, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_CanPair, + 0x0BBA1EDE, 0x7566, 0x4F47, 0x90, 0xEC, 0x25, 0xFC, 0x56, 0x7C, 0xED, 0x2A, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_Categories, + 0x0BBA1EDE, 0x7566, 0x4F47, 0x90, 0xEC, 0x25, 0xFC, 0x56, 0x7C, 0xED, 0x2A, 9} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_Children, + 0x0BBA1EDE, 0x7566, 0x4F47, 0x90, 0xEC, 0x25, 0xFC, 0x56, 0x7C, 0xED, 0x2A, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_ContainerId, + 0x0BBA1EDE, 0x7566, 0x4F47, 0x90, 0xEC, 0x25, 0xFC, 0x56, 0x7C, 0xED, 0x2A, 12} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_DialProtocol_InstalledApplications, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_IsPaired, + 0x0BBA1EDE, 0x7566, 0x4F47, 0x90, 0xEC, 0x25, 0xFC, 0x56, 0x7C, 0xED, 0x2A, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_IsPresent, + 0x0BBA1EDE, 0x7566, 0x4F47, 0x90, 0xEC, 0x25, 0xFC, 0x56, 0x7C, 0xED, 0x2A, 11} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_Manufacturer, + 0x0BBA1EDE, 0x7566, 0x4F47, 0x90, 0xEC, 0x25, 0xFC, 0x56, 0x7C, 0xED, 0x2A, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_ModelIds, + 0x0BBA1EDE, 0x7566, 0x4F47, 0x90, 0xEC, 0x25, 0xFC, 0x56, 0x7C, 0xED, 0x2A, 8} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_ModelName, + 0x0BBA1EDE, 0x7566, 0x4F47, 0x90, 0xEC, 0x25, 0xFC, 0x56, 0x7C, 0xED, 0x2A, 7} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_ProtocolIds, + 0x0BBA1EDE, 0x7566, 0x4F47, 0x90, 0xEC, 0x25, 0xFC, 0x56, 0x7C, 0xED, 0x2A, 13} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportedUriSchemes, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsAudio, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsCapturing, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 11} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsImages, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsInformation, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 14} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsLimitedDiscovery, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 7} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsNetworking, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 9} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsObjectTransfer, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 12} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsPositioning, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 8} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsRendering, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 10} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsTelephony, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 13} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepContainer_SupportsVideo, + 0x6AF55D45, 0x38DB, 0x4495, 0xAC, 0xB0, 0xD4, 0x72, 0x8A, 0x3B, 0x83, 0x14, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_AepId, + 0xC9C141A9, 0x1B4C, 0x4F17, 0xA9, 0xD1, 0xF2, 0x98, 0x53, 0x8C, 0xAD, 0xB8, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_Bluetooth_CacheMode, + 0x9744311E, 0x7951, 0x4B2E, 0xB6, 0xF0, 0xEC, 0xB2, 0x93, 0xCA, 0xC1, 0x19, 5} +pub const BLUETOOTH_CACHE_MODE_CACHED: LONG = 0; +pub const BLUETOOTH_CACHED_MODE_UNCACHED: LONG = 1; +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_Bluetooth_ServiceGuid, + 0xA399AAC7, 0xC265, 0x474E, 0xB0, 0x73, 0xFF, 0xCE, 0x57, 0x72, 0x17, 0x16, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_Bluetooth_TargetDevice, + 0x9744311E, 0x7951, 0x4B2E, 0xB6, 0xF0, 0xEC, 0xB2, 0x93, 0xCA, 0xC1, 0x19, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_ContainerId, + 0x71724756, 0x3E74, 0x4432, 0x9B, 0x59, 0xE7, 0xB2, 0xF6, 0x68, 0xA5, 0x93, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_FriendlyName, + 0x71724756, 0x3E74, 0x4432, 0x9B, 0x59, 0xE7, 0xB2, 0xF6, 0x68, 0xA5, 0x93, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_IoT_ServiceInterfaces, + 0x79D94E82, 0x4D79, 0x45AA, 0x82, 0x1A, 0x74, 0x85, 0x8B, 0x4E, 0x4C, 0xA6, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_ParentAepIsPaired, + 0xC9C141A9, 0x1B4C, 0x4F17, 0xA9, 0xD1, 0xF2, 0x98, 0x53, 0x8C, 0xAD, 0xB8, 7} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_ProtocolId, + 0xC9C141A9, 0x1B4C, 0x4F17, 0xA9, 0xD1, 0xF2, 0x98, 0x53, 0x8C, 0xAD, 0xB8, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_ServiceClassId, + 0x71724756, 0x3E74, 0x4432, 0x9B, 0x59, 0xE7, 0xB2, 0xF6, 0x68, 0xA5, 0x93, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_AepService_ServiceId, + 0xC9C141A9, 0x1B4C, 0x4F17, 0xA9, 0xD1, 0xF2, 0x98, 0x53, 0x8C, 0xAD, 0xB8, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_AppPackageFamilyName, + 0x51236583, 0x0C4A, 0x4FE8, 0xB8, 0x1F, 0x16, 0x6A, 0xEC, 0x13, 0xF5, 0x10, 100} +DEFINE_PROPERTYKEY!{PKEY_Devices_AudioDevice_Microphone_SensitivityInDbfs, + 0x8943B373, 0x388C, 0x4395, 0xB5, 0x57, 0xBC, 0x6D, 0xBA, 0xFF, 0xAF, 0xDB, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_AudioDevice_Microphone_SignalToNoiseRatioInDb, + 0x8943B373, 0x388C, 0x4395, 0xB5, 0x57, 0xBC, 0x6D, 0xBA, 0xFF, 0xAF, 0xDB, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_AudioDevice_RawProcessingSupported, + 0x8943B373, 0x388C, 0x4395, 0xB5, 0x57, 0xBC, 0x6D, 0xBA, 0xFF, 0xAF, 0xDB, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_AudioDevice_SpeechProcessingSupported, + 0xFB1DE864, 0xE06D, 0x47F4, 0x82, 0xA6, 0x8A, 0x0A, 0xEF, 0x44, 0x49, 0x3C, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_BatteryLife, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 10} +DEFINE_PROPERTYKEY!{PKEY_Devices_BatteryPlusCharging, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 22} +DEFINE_PROPERTYKEY!{PKEY_Devices_BatteryPlusChargingText, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 23} +DEFINE_PROPERTYKEY!{PKEY_Devices_Category, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 91} +DEFINE_PROPERTYKEY!{PKEY_Devices_CategoryGroup, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 94} +DEFINE_PROPERTYKEY!{PKEY_Devices_CategoryIds, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 90} +DEFINE_PROPERTYKEY!{PKEY_Devices_CategoryPlural, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 92} +DEFINE_PROPERTYKEY!{PKEY_Devices_ChargingState, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 11} +DEFINE_PROPERTYKEY!{PKEY_Devices_Children, + 0x4340A6C5, 0x93FA, 0x4706, 0x97, 0x2C, 0x7B, 0x64, 0x80, 0x08, 0xA5, 0xA7, 9} +DEFINE_PROPERTYKEY!{PKEY_Devices_ClassGuid, + 0xA45C254E, 0xDF1C, 0x4EFD, 0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0, 10} +DEFINE_PROPERTYKEY!{PKEY_Devices_CompatibleIds, + 0xA45C254E, 0xDF1C, 0x4EFD, 0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_Connected, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 55} +DEFINE_PROPERTYKEY!{PKEY_Devices_ContainerId, + 0x8C7ED206, 0x3F8A, 0x4827, 0xB3, 0xAB, 0xAE, 0x9E, 0x1F, 0xAE, 0xFC, 0x6C, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_DefaultTooltip, + 0x880F70A2, 0x6082, 0x47AC, 0x8A, 0xAB, 0xA7, 0x39, 0xD1, 0xA3, 0x00, 0xC3, 153} +DEFINE_PROPERTYKEY!{PKEY_Devices_DeviceCapabilities, + 0xA45C254E, 0xDF1C, 0x4EFD, 0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0, 17} +DEFINE_PROPERTYKEY!{PKEY_Devices_DeviceCharacteristics, + 0xA45C254E, 0xDF1C, 0x4EFD, 0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0, 29} +DEFINE_PROPERTYKEY!{PKEY_Devices_DeviceDescription1, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 81} +DEFINE_PROPERTYKEY!{PKEY_Devices_DeviceDescription2, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 82} +DEFINE_PROPERTYKEY!{PKEY_Devices_DeviceHasProblem, + 0x540B947E, 0x8B40, 0x45BC, 0xA8, 0xA2, 0x6A, 0x0B, 0x89, 0x4C, 0xBD, 0xA2, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_DeviceInstanceId, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 256} +DEFINE_PROPERTYKEY!{PKEY_Devices_DeviceManufacturer, + 0xA45C254E, 0xDF1C, 0x4EFD, 0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0, 13} +DEFINE_PROPERTYKEY!{PKEY_Devices_DevObjectType, + 0x13673F42, 0xA3D6, 0x49F6, 0xB4, 0xDA, 0xAE, 0x46, 0xE0, 0xC5, 0x23, 0x7C, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_DialProtocol_InstalledApplications, + 0x6845CC72, 0x1B71, 0x48C3, 0xAF, 0x86, 0xB0, 0x91, 0x71, 0xA1, 0x9B, 0x14, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_DiscoveryMethod, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 52} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_Domain, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_FullName, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_HostName, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 7} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_InstanceName, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_NetworkAdapterId, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 11} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_PortNumber, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 12} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_Priority, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 9} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_ServiceName, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_TextAttributes, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_Ttl, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 10} +DEFINE_PROPERTYKEY!{PKEY_Devices_Dnssd_Weight, + 0xBF79C0AB, 0xBB74, 0x4CEE, 0xB0, 0x70, 0x47, 0x0B, 0x5A, 0xE2, 0x02, 0xEA, 8} +DEFINE_PROPERTYKEY!{PKEY_Devices_FriendlyName, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 12288} +DEFINE_PROPERTYKEY!{PKEY_Devices_FunctionPaths, + 0xD08DD4C0, 0x3A9E, 0x462E, 0x82, 0x90, 0x7B, 0x63, 0x6B, 0x25, 0x76, 0xB9, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_GlyphIcon, + 0x51236583, 0x0C4A, 0x4FE8, 0xB8, 0x1F, 0x16, 0x6A, 0xEC, 0x13, 0xF5, 0x10, 123} +DEFINE_PROPERTYKEY!{PKEY_Devices_HardwareIds, + 0xA45C254E, 0xDF1C, 0x4EFD, 0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_Icon, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 57} +DEFINE_PROPERTYKEY!{PKEY_Devices_InLocalMachineContainer, + 0x8C7ED206, 0x3F8A, 0x4827, 0xB3, 0xAB, 0xAE, 0x9E, 0x1F, 0xAE, 0xFC, 0x6C, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_InterfaceClassGuid, + 0x026E516E, 0xB814, 0x414B, 0x83, 0xCD, 0x85, 0x6D, 0x6F, 0xEF, 0x48, 0x22, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_InterfaceEnabled, + 0x026E516E, 0xB814, 0x414B, 0x83, 0xCD, 0x85, 0x6D, 0x6F, 0xEF, 0x48, 0x22, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_InterfacePaths, + 0xD08DD4C0, 0x3A9E, 0x462E, 0x82, 0x90, 0x7B, 0x63, 0x6B, 0x25, 0x76, 0xB9, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_IpAddress, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 12297} +DEFINE_PROPERTYKEY!{PKEY_Devices_IsDefault, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 86} +DEFINE_PROPERTYKEY!{PKEY_Devices_IsNetworkConnected, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 85} +DEFINE_PROPERTYKEY!{PKEY_Devices_IsShared, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 84} +DEFINE_PROPERTYKEY!{PKEY_Devices_IsSoftwareInstalling, + 0x83DA6326, 0x97A6, 0x4088, 0x94, 0x53, 0xA1, 0x92, 0x3F, 0x57, 0x3B, 0x29, 9} +DEFINE_PROPERTYKEY!{PKEY_Devices_LaunchDeviceStageFromExplorer, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 77} +DEFINE_PROPERTYKEY!{PKEY_Devices_LocalMachine, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 70} +DEFINE_PROPERTYKEY!{PKEY_Devices_LocationPaths, + 0xA45C254E, 0xDF1C, 0x4EFD, 0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0, 37} +DEFINE_PROPERTYKEY!{PKEY_Devices_Manufacturer, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 8192} +DEFINE_PROPERTYKEY!{PKEY_Devices_MetadataPath, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 71} +DEFINE_PROPERTYKEY!{PKEY_Devices_MicrophoneArray_Geometry, + 0xA1829EA2, 0x27EB, 0x459E, 0x93, 0x5D, 0xB2, 0xFA, 0xD7, 0xB0, 0x77, 0x62, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_MissedCalls, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_ModelId, + 0x80D81EA6, 0x7473, 0x4B0C, 0x82, 0x16, 0xEF, 0xC1, 0x1A, 0x2C, 0x4C, 0x8B, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_ModelName, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 8194} +DEFINE_PROPERTYKEY!{PKEY_Devices_ModelNumber, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 8195} +DEFINE_PROPERTYKEY!{PKEY_Devices_NetworkedTooltip, + 0x880F70A2, 0x6082, 0x47AC, 0x8A, 0xAB, 0xA7, 0x39, 0xD1, 0xA3, 0x00, 0xC3, 152} +DEFINE_PROPERTYKEY!{PKEY_Devices_NetworkName, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 7} +DEFINE_PROPERTYKEY!{PKEY_Devices_NetworkType, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 8} +DEFINE_PROPERTYKEY!{PKEY_Devices_NewPictures, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_Notification, + 0x06704B0C, 0xE830, 0x4C81, 0x91, 0x78, 0x91, 0xE4, 0xE9, 0x5A, 0x80, 0xA0, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_Notifications_LowBattery, + 0xC4C07F2B, 0x8524, 0x4E66, 0xAE, 0x3A, 0xA6, 0x23, 0x5F, 0x10, 0x3B, 0xEB, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Notifications_MissedCall, + 0x6614EF48, 0x4EFE, 0x4424, 0x9E, 0xDA, 0xC7, 0x9F, 0x40, 0x4E, 0xDF, 0x3E, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Notifications_NewMessage, + 0x2BE9260A, 0x2012, 0x4742, 0xA5, 0x55, 0xF4, 0x1B, 0x63, 0x8B, 0x7D, 0xCB, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Notifications_NewVoicemail, + 0x59569556, 0x0A08, 0x4212, 0x95, 0xB9, 0xFA, 0xE2, 0xAD, 0x64, 0x13, 0xDB, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Notifications_StorageFull, + 0xA0E00EE1, 0xF0C7, 0x4D41, 0xB8, 0xE7, 0x26, 0xA7, 0xBD, 0x8D, 0x38, 0xB0, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Notifications_StorageFullLinkText, + 0xA0E00EE1, 0xF0C7, 0x4D41, 0xB8, 0xE7, 0x26, 0xA7, 0xBD, 0x8D, 0x38, 0xB0, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_NotificationStore, + 0x06704B0C, 0xE830, 0x4C81, 0x91, 0x78, 0x91, 0xE4, 0xE9, 0x5A, 0x80, 0xA0, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_NotWorkingProperly, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 83} +DEFINE_PROPERTYKEY!{PKEY_Devices_Paired, + 0x78C34FC8, 0x104A, 0x4ACA, 0x9E, 0xA4, 0x52, 0x4D, 0x52, 0x99, 0x6E, 0x57, 56} +DEFINE_PROPERTYKEY!{PKEY_Devices_Parent, + 0x4340A6C5, 0x93FA, 0x4706, 0x97, 0x2C, 0x7B, 0x64, 0x80, 0x08, 0xA5, 0xA7, 8} +DEFINE_PROPERTYKEY!{PKEY_Devices_PhysicalDeviceLocation, + 0x540B947E, 0x8B40, 0x45BC, 0xA8, 0xA2, 0x6A, 0x0B, 0x89, 0x4C, 0xBD, 0xA2, 9} +DEFINE_PROPERTYKEY!{PKEY_Devices_PlaybackPositionPercent, + 0x3633DE59, 0x6825, 0x4381, 0xA4, 0x9B, 0x9F, 0x6B, 0xA1, 0x3A, 0x14, 0x71, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_PlaybackState, + 0x3633DE59, 0x6825, 0x4381, 0xA4, 0x9B, 0x9F, 0x6B, 0xA1, 0x3A, 0x14, 0x71, 2} +pub const PLAYBACKSTATE_UNKNOWN: LONG = 0; +pub const PLAYBACKSTATE_STOPPED: LONG = 1; +pub const PLAYBACKSTATE_PLAYING: LONG = 2; +pub const PLAYBACKSTATE_TRANSITIONING: LONG = 3; +pub const PLAYBACKSTATE_PAUSED: LONG = 4; +pub const PLAYBACKSTATE_RECORDINGPAUSED: LONG = 5; +pub const PLAYBACKSTATE_RECORDING: LONG = 6; +pub const PLAYBACKSTATE_NOMEDIA: LONG = 7; +DEFINE_PROPERTYKEY!{PKEY_Devices_PlaybackTitle, + 0x3633DE59, 0x6825, 0x4381, 0xA4, 0x9B, 0x9F, 0x6B, 0xA1, 0x3A, 0x14, 0x71, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_Present, + 0x540B947E, 0x8B40, 0x45BC, 0xA8, 0xA2, 0x6A, 0x0B, 0x89, 0x4C, 0xBD, 0xA2, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_PresentationUrl, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 8198} +DEFINE_PROPERTYKEY!{PKEY_Devices_PrimaryCategory, + 0xD08DD4C0, 0x3A9E, 0x462E, 0x82, 0x90, 0x7B, 0x63, 0x6B, 0x25, 0x76, 0xB9, 10} +DEFINE_PROPERTYKEY!{PKEY_Devices_RemainingDuration, + 0x3633DE59, 0x6825, 0x4381, 0xA4, 0x9B, 0x9F, 0x6B, 0xA1, 0x3A, 0x14, 0x71, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_RestrictedInterface, + 0x026E516E, 0xB814, 0x414B, 0x83, 0xCD, 0x85, 0x6D, 0x6F, 0xEF, 0x48, 0x22, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_Roaming, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 9} +DEFINE_PROPERTYKEY!{PKEY_Devices_SafeRemovalRequired, + 0xAFD97640, 0x86A3, 0x4210, 0xB6, 0x7C, 0x28, 0x9C, 0x41, 0xAA, 0xBE, 0x55, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_ServiceAddress, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 16384} +DEFINE_PROPERTYKEY!{PKEY_Devices_ServiceId, + 0x656A3BB3, 0xECC0, 0x43FD, 0x84, 0x77, 0x4A, 0xE0, 0x40, 0x4A, 0x96, 0xCD, 16385} +DEFINE_PROPERTYKEY!{PKEY_Devices_SharedTooltip, + 0x880F70A2, 0x6082, 0x47AC, 0x8A, 0xAB, 0xA7, 0x39, 0xD1, 0xA3, 0x00, 0xC3, 151} +DEFINE_PROPERTYKEY!{PKEY_Devices_SignalStrength, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_SmartCards_ReaderKind, + 0xD6B5B883, 0x18BD, 0x4B4D, 0xB2, 0xEC, 0x9E, 0x38, 0xAF, 0xFE, 0xDA, 0x82, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Status, + 0xD08DD4C0, 0x3A9E, 0x462E, 0x82, 0x90, 0x7B, 0x63, 0x6B, 0x25, 0x76, 0xB9, 259} +DEFINE_PROPERTYKEY!{PKEY_Devices_Status1, + 0xD08DD4C0, 0x3A9E, 0x462E, 0x82, 0x90, 0x7B, 0x63, 0x6B, 0x25, 0x76, 0xB9, 257} +DEFINE_PROPERTYKEY!{PKEY_Devices_Status2, + 0xD08DD4C0, 0x3A9E, 0x462E, 0x82, 0x90, 0x7B, 0x63, 0x6B, 0x25, 0x76, 0xB9, 258} +DEFINE_PROPERTYKEY!{PKEY_Devices_StorageCapacity, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 12} +DEFINE_PROPERTYKEY!{PKEY_Devices_StorageFreeSpace, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 13} +DEFINE_PROPERTYKEY!{PKEY_Devices_StorageFreeSpacePercent, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 14} +DEFINE_PROPERTYKEY!{PKEY_Devices_TextMessages, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_Voicemail, + 0x49CD1F76, 0x5626, 0x4B17, 0xA4, 0xE8, 0x18, 0xB4, 0xAA, 0x1A, 0x22, 0x13, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiaDeviceType, + 0x6BDD1FC6, 0x810F, 0x11D0, 0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFi_InterfaceGuid, + 0xEF1167EB, 0xCBFC, 0x4341, 0xA5, 0x68, 0xA7, 0xC9, 0x1A, 0x68, 0x98, 0x2C, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_DeviceAddress, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 13} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_GroupId, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_InformationElements, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 12} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_InterfaceAddress, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_InterfaceGuid, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_IsConnected, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_IsLegacyDevice, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 7} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_IsMiracastLcpSupported, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 9} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_IsVisible, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_MiracastVersion, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 8} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_Services, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 10} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirect_SupportedChannelList, + 0x1506935D, 0xE3E7, 0x450F, 0x86, 0x37, 0x82, 0x23, 0x3E, 0xBE, 0x5F, 0x6E, 11} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirectServices_AdvertisementId, + 0x31B37743, 0x7C5E, 0x4005, 0x93, 0xE6, 0xE9, 0x53, 0xF9, 0x2B, 0x82, 0xE9, 5} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirectServices_RequestServiceInformation, + 0x31B37743, 0x7C5E, 0x4005, 0x93, 0xE6, 0xE9, 0x53, 0xF9, 0x2B, 0x82, 0xE9, 7} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirectServices_ServiceAddress, + 0x31B37743, 0x7C5E, 0x4005, 0x93, 0xE6, 0xE9, 0x53, 0xF9, 0x2B, 0x82, 0xE9, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirectServices_ServiceConfigMethods, + 0x31B37743, 0x7C5E, 0x4005, 0x93, 0xE6, 0xE9, 0x53, 0xF9, 0x2B, 0x82, 0xE9, 6} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirectServices_ServiceInformation, + 0x31B37743, 0x7C5E, 0x4005, 0x93, 0xE6, 0xE9, 0x53, 0xF9, 0x2B, 0x82, 0xE9, 4} +DEFINE_PROPERTYKEY!{PKEY_Devices_WiFiDirectServices_ServiceName, + 0x31B37743, 0x7C5E, 0x4005, 0x93, 0xE6, 0xE9, 0x53, 0xF9, 0x2B, 0x82, 0xE9, 3} +DEFINE_PROPERTYKEY!{PKEY_Devices_WinPhone8CameraFlags, + 0xB7B4D61C, 0x5A64, 0x4187, 0xA5, 0x2E, 0xB1, 0x53, 0x9F, 0x35, 0x90, 0x99, 2} +DEFINE_PROPERTYKEY!{PKEY_Devices_Wwan_InterfaceGuid, + 0xFF1167EB, 0xCBFC, 0x4341, 0xA5, 0x68, 0xA7, 0xC9, 0x1A, 0x68, 0x98, 0x2C, 2} +DEFINE_PROPERTYKEY!{PKEY_Storage_Portable, + 0x4D1EBEE8, 0x0803, 0x4774, 0x98, 0x42, 0xB7, 0x7D, 0xB5, 0x02, 0x65, 0xE9, 2} +DEFINE_PROPERTYKEY!{PKEY_Storage_RemovableMedia, + 0x4D1EBEE8, 0x0803, 0x4774, 0x98, 0x42, 0xB7, 0x7D, 0xB5, 0x02, 0x65, 0xE9, 3} +DEFINE_PROPERTYKEY!{PKEY_Storage_SystemCritical, + 0x4D1EBEE8, 0x0803, 0x4774, 0x98, 0x42, 0xB7, 0x7D, 0xB5, 0x02, 0x65, 0xE9, 4} +DEFINE_PROPERTYKEY!{PKEY_Document_ByteCount, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 4} +DEFINE_PROPERTYKEY!{PKEY_Document_CharacterCount, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 16} +DEFINE_PROPERTYKEY!{PKEY_Document_ClientID, + 0x276D7BB0, 0x5B34, 0x4FB0, 0xAA, 0x4B, 0x15, 0x8E, 0xD1, 0x2A, 0x18, 0x09, 100} +DEFINE_PROPERTYKEY!{PKEY_Document_Contributor, + 0xF334115E, 0xDA1B, 0x4509, 0x9B, 0x3D, 0x11, 0x95, 0x04, 0xDC, 0x7A, 0xBB, 100} +DEFINE_PROPERTYKEY!{PKEY_Document_DateCreated, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 12} +DEFINE_PROPERTYKEY!{PKEY_Document_DatePrinted, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 11} +DEFINE_PROPERTYKEY!{PKEY_Document_DateSaved, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 13} +DEFINE_PROPERTYKEY!{PKEY_Document_Division, + 0x1E005EE6, 0xBF27, 0x428B, 0xB0, 0x1C, 0x79, 0x67, 0x6A, 0xCD, 0x28, 0x70, 100} +DEFINE_PROPERTYKEY!{PKEY_Document_DocumentID, + 0xE08805C8, 0xE395, 0x40DF, 0x80, 0xD2, 0x54, 0xF0, 0xD6, 0xC4, 0x31, 0x54, 100} +DEFINE_PROPERTYKEY!{PKEY_Document_HiddenSlideCount, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 9} +DEFINE_PROPERTYKEY!{PKEY_Document_LastAuthor, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 8} +DEFINE_PROPERTYKEY!{PKEY_Document_LineCount, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 5} +DEFINE_PROPERTYKEY!{PKEY_Document_Manager, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 14} +DEFINE_PROPERTYKEY!{PKEY_Document_MultimediaClipCount, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 10} +DEFINE_PROPERTYKEY!{PKEY_Document_NoteCount, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 8} +DEFINE_PROPERTYKEY!{PKEY_Document_PageCount, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 14} +DEFINE_PROPERTYKEY!{PKEY_Document_ParagraphCount, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 6} +DEFINE_PROPERTYKEY!{PKEY_Document_PresentationFormat, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 3} +DEFINE_PROPERTYKEY!{PKEY_Document_RevisionNumber, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 9} +DEFINE_PROPERTYKEY!{PKEY_Document_Security, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 19} +DEFINE_PROPERTYKEY!{PKEY_Document_SlideCount, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 7} +DEFINE_PROPERTYKEY!{PKEY_Document_Template, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 7} +DEFINE_PROPERTYKEY!{PKEY_Document_TotalEditingTime, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 10} +DEFINE_PROPERTYKEY!{PKEY_Document_Version, + 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE, 29} +DEFINE_PROPERTYKEY!{PKEY_Document_WordCount, + 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 15} +DEFINE_PROPERTYKEY!{PKEY_DRM_DatePlayExpires, + 0xAEAC19E4, 0x89AE, 0x4508, 0xB9, 0xB7, 0xBB, 0x86, 0x7A, 0xBE, 0xE2, 0xED, 6} +DEFINE_PROPERTYKEY!{PKEY_DRM_DatePlayStarts, + 0xAEAC19E4, 0x89AE, 0x4508, 0xB9, 0xB7, 0xBB, 0x86, 0x7A, 0xBE, 0xE2, 0xED, 5} +DEFINE_PROPERTYKEY!{PKEY_DRM_Description, + 0xAEAC19E4, 0x89AE, 0x4508, 0xB9, 0xB7, 0xBB, 0x86, 0x7A, 0xBE, 0xE2, 0xED, 3} +DEFINE_PROPERTYKEY!{PKEY_DRM_IsDisabled, + 0xAEAC19E4, 0x89AE, 0x4508, 0xB9, 0xB7, 0xBB, 0x86, 0x7A, 0xBE, 0xE2, 0xED, 7} +DEFINE_PROPERTYKEY!{PKEY_DRM_IsProtected, + 0xAEAC19E4, 0x89AE, 0x4508, 0xB9, 0xB7, 0xBB, 0x86, 0x7A, 0xBE, 0xE2, 0xED, 2} +DEFINE_PROPERTYKEY!{PKEY_DRM_PlayCount, + 0xAEAC19E4, 0x89AE, 0x4508, 0xB9, 0xB7, 0xBB, 0x86, 0x7A, 0xBE, 0xE2, 0xED, 4} +DEFINE_PROPERTYKEY!{PKEY_GPS_Altitude, + 0x827EDB4F, 0x5B73, 0x44A7, 0x89, 0x1D, 0xFD, 0xFF, 0xAB, 0xEA, 0x35, 0xCA, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_AltitudeDenominator, + 0x78342DCB, 0xE358, 0x4145, 0xAE, 0x9A, 0x6B, 0xFE, 0x4E, 0x0F, 0x9F, 0x51, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_AltitudeNumerator, + 0x2DAD1EB7, 0x816D, 0x40D3, 0x9E, 0xC3, 0xC9, 0x77, 0x3B, 0xE2, 0xAA, 0xDE, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_AltitudeRef, + 0x46AC629D, 0x75EA, 0x4515, 0x86, 0x7F, 0x6D, 0xC4, 0x32, 0x1C, 0x58, 0x44, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_AreaInformation, + 0x972E333E, 0xAC7E, 0x49F1, 0x8A, 0xDF, 0xA7, 0x0D, 0x07, 0xA9, 0xBC, 0xAB, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_Date, + 0x3602C812, 0x0F3B, 0x45F0, 0x85, 0xAD, 0x60, 0x34, 0x68, 0xD6, 0x94, 0x23, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestBearing, + 0xC66D4B3C, 0xE888, 0x47CC, 0xB9, 0x9F, 0x9D, 0xCA, 0x3E, 0xE3, 0x4D, 0xEA, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestBearingDenominator, + 0x7ABCF4F8, 0x7C3F, 0x4988, 0xAC, 0x91, 0x8D, 0x2C, 0x2E, 0x97, 0xEC, 0xA5, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestBearingNumerator, + 0xBA3B1DA9, 0x86EE, 0x4B5D, 0xA2, 0xA4, 0xA2, 0x71, 0xA4, 0x29, 0xF0, 0xCF, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestBearingRef, + 0x9AB84393, 0x2A0F, 0x4B75, 0xBB, 0x22, 0x72, 0x79, 0x78, 0x69, 0x77, 0xCB, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestDistance, + 0xA93EAE04, 0x6804, 0x4F24, 0xAC, 0x81, 0x09, 0xB2, 0x66, 0x45, 0x21, 0x18, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestDistanceDenominator, + 0x9BC2C99B, 0xAC71, 0x4127, 0x9D, 0x1C, 0x25, 0x96, 0xD0, 0xD7, 0xDC, 0xB7, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestDistanceNumerator, + 0x2BDA47DA, 0x08C6, 0x4FE1, 0x80, 0xBC, 0xA7, 0x2F, 0xC5, 0x17, 0xC5, 0xD0, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestDistanceRef, + 0xED4DF2D3, 0x8695, 0x450B, 0x85, 0x6F, 0xF5, 0xC1, 0xC5, 0x3A, 0xCB, 0x66, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestLatitude, + 0x9D1D7CC5, 0x5C39, 0x451C, 0x86, 0xB3, 0x92, 0x8E, 0x2D, 0x18, 0xCC, 0x47, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestLatitudeDenominator, + 0x3A372292, 0x7FCA, 0x49A7, 0x99, 0xD5, 0xE4, 0x7B, 0xB2, 0xD4, 0xE7, 0xAB, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestLatitudeNumerator, + 0xECF4B6F6, 0xD5A6, 0x433C, 0xBB, 0x92, 0x40, 0x76, 0x65, 0x0F, 0xC8, 0x90, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestLatitudeRef, + 0xCEA820B9, 0xCE61, 0x4885, 0xA1, 0x28, 0x00, 0x5D, 0x90, 0x87, 0xC1, 0x92, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestLongitude, + 0x47A96261, 0xCB4C, 0x4807, 0x8A, 0xD3, 0x40, 0xB9, 0xD9, 0xDB, 0xC6, 0xBC, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestLongitudeDenominator, + 0x425D69E5, 0x48AD, 0x4900, 0x8D, 0x80, 0x6E, 0xB6, 0xB8, 0xD0, 0xAC, 0x86, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestLongitudeNumerator, + 0xA3250282, 0xFB6D, 0x48D5, 0x9A, 0x89, 0xDB, 0xCA, 0xCE, 0x75, 0xCC, 0xCF, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DestLongitudeRef, + 0x182C1EA6, 0x7C1C, 0x4083, 0xAB, 0x4B, 0xAC, 0x6C, 0x9F, 0x4E, 0xD1, 0x28, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_Differential, + 0xAAF4EE25, 0xBD3B, 0x4DD7, 0xBF, 0xC4, 0x47, 0xF7, 0x7B, 0xB0, 0x0F, 0x6D, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DOP, + 0x0CF8FB02, 0x1837, 0x42F1, 0xA6, 0x97, 0xA7, 0x01, 0x7A, 0xA2, 0x89, 0xB9, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DOPDenominator, + 0xA0BE94C5, 0x50BA, 0x487B, 0xBD, 0x35, 0x06, 0x54, 0xBE, 0x88, 0x81, 0xED, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_DOPNumerator, + 0x47166B16, 0x364F, 0x4AA0, 0x9F, 0x31, 0xE2, 0xAB, 0x3D, 0xF4, 0x49, 0xC3, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_ImgDirection, + 0x16473C91, 0xD017, 0x4ED9, 0xBA, 0x4D, 0xB6, 0xBA, 0xA5, 0x5D, 0xBC, 0xF8, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_ImgDirectionDenominator, + 0x10B24595, 0x41A2, 0x4E20, 0x93, 0xC2, 0x57, 0x61, 0xC1, 0x39, 0x5F, 0x32, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_ImgDirectionNumerator, + 0xDC5877C7, 0x225F, 0x45F7, 0xBA, 0xC7, 0xE8, 0x13, 0x34, 0xB6, 0x13, 0x0A, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_ImgDirectionRef, + 0xA4AAA5B7, 0x1AD0, 0x445F, 0x81, 0x1A, 0x0F, 0x8F, 0x6E, 0x67, 0xF6, 0xB5, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_Latitude, + 0x8727CFFF, 0x4868, 0x4EC6, 0xAD, 0x5B, 0x81, 0xB9, 0x85, 0x21, 0xD1, 0xAB, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_LatitudeDecimal, + 0x0F55CDE2, 0x4F49, 0x450D, 0x92, 0xC1, 0xDC, 0xD1, 0x63, 0x01, 0xB1, 0xB7, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_LatitudeDenominator, + 0x16E634EE, 0x2BFF, 0x497B, 0xBD, 0x8A, 0x43, 0x41, 0xAD, 0x39, 0xEE, 0xB9, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_LatitudeNumerator, + 0x7DDAAAD1, 0xCCC8, 0x41AE, 0xB7, 0x50, 0xB2, 0xCB, 0x80, 0x31, 0xAE, 0xA2, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_LatitudeRef, + 0x029C0252, 0x5B86, 0x46C7, 0xAC, 0xA0, 0x27, 0x69, 0xFF, 0xC8, 0xE3, 0xD4, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_Longitude, + 0xC4C4DBB2, 0xB593, 0x466B, 0xBB, 0xDA, 0xD0, 0x3D, 0x27, 0xD5, 0xE4, 0x3A, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_LongitudeDecimal, + 0x4679C1B5, 0x844D, 0x4590, 0xBA, 0xF5, 0xF3, 0x22, 0x23, 0x1F, 0x1B, 0x81, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_LongitudeDenominator, + 0xBE6E176C, 0x4534, 0x4D2C, 0xAC, 0xE5, 0x31, 0xDE, 0xDA, 0xC1, 0x60, 0x6B, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_LongitudeNumerator, + 0x02B0F689, 0xA914, 0x4E45, 0x82, 0x1D, 0x1D, 0xDA, 0x45, 0x2E, 0xD2, 0xC4, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_LongitudeRef, + 0x33DCF22B, 0x28D5, 0x464C, 0x80, 0x35, 0x1E, 0xE9, 0xEF, 0xD2, 0x52, 0x78, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_MapDatum, + 0x2CA2DAE6, 0xEDDC, 0x407D, 0xBE, 0xF1, 0x77, 0x39, 0x42, 0xAB, 0xFA, 0x95, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_MeasureMode, + 0xA015ED5D, 0xAAEA, 0x4D58, 0x8A, 0x86, 0x3C, 0x58, 0x69, 0x20, 0xEA, 0x0B, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_ProcessingMethod, + 0x59D49E61, 0x840F, 0x4AA9, 0xA9, 0x39, 0xE2, 0x09, 0x9B, 0x7F, 0x63, 0x99, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_Satellites, + 0x467EE575, 0x1F25, 0x4557, 0xAD, 0x4E, 0xB8, 0xB5, 0x8B, 0x0D, 0x9C, 0x15, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_Speed, + 0xDA5D0862, 0x6E76, 0x4E1B, 0xBA, 0xBD, 0x70, 0x02, 0x1B, 0xD2, 0x54, 0x94, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_SpeedDenominator, + 0x7D122D5A, 0xAE5E, 0x4335, 0x88, 0x41, 0xD7, 0x1E, 0x7C, 0xE7, 0x2F, 0x53, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_SpeedNumerator, + 0xACC9CE3D, 0xC213, 0x4942, 0x8B, 0x48, 0x6D, 0x08, 0x20, 0xF2, 0x1C, 0x6D, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_SpeedRef, + 0xECF7F4C9, 0x544F, 0x4D6D, 0x9D, 0x98, 0x8A, 0xD7, 0x9A, 0xDA, 0xF4, 0x53, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_Status, + 0x125491F4, 0x818F, 0x46B2, 0x91, 0xB5, 0xD5, 0x37, 0x75, 0x36, 0x17, 0xB2, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_Track, + 0x76C09943, 0x7C33, 0x49E3, 0x9E, 0x7E, 0xCD, 0xBA, 0x87, 0x2C, 0xFA, 0xDA, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_TrackDenominator, + 0xC8D1920C, 0x01F6, 0x40C0, 0xAC, 0x86, 0x2F, 0x3A, 0x4A, 0xD0, 0x07, 0x70, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_TrackNumerator, + 0x702926F4, 0x44A6, 0x43E1, 0xAE, 0x71, 0x45, 0x62, 0x71, 0x16, 0x89, 0x3B, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_TrackRef, + 0x35DBE6FE, 0x44C3, 0x4400, 0xAA, 0xAE, 0xD2, 0xC7, 0x99, 0xC4, 0x07, 0xE8, 100} +DEFINE_PROPERTYKEY!{PKEY_GPS_VersionID, + 0x22704DA4, 0xC6B2, 0x4A99, 0x8E, 0x56, 0xF1, 0x6D, 0xF8, 0xC9, 0x25, 0x99, 100} +DEFINE_PROPERTYKEY!{PKEY_History_VisitCount, + 0x5CBF2787, 0x48CF, 0x4208, 0xB9, 0x0E, 0xEE, 0x5E, 0x5D, 0x42, 0x02, 0x94, 7} +DEFINE_PROPERTYKEY!{PKEY_Image_BitDepth, + 0x6444048F, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 7} +DEFINE_PROPERTYKEY!{PKEY_Image_ColorSpace, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 40961} +pub const IMAGE_COLORSPACE_SRGB: DWORD = 1; +pub const IMAGE_COLORSPACE_UNCALIBRATED: DWORD = 0xFFFF; +DEFINE_PROPERTYKEY!{PKEY_Image_CompressedBitsPerPixel, + 0x364B6FA9, 0x37AB, 0x482A, 0xBE, 0x2B, 0xAE, 0x02, 0xF6, 0x0D, 0x43, 0x18, 100} +DEFINE_PROPERTYKEY!{PKEY_Image_CompressedBitsPerPixelDenominator, + 0x1F8844E1, 0x24AD, 0x4508, 0x9D, 0xFD, 0x53, 0x26, 0xA4, 0x15, 0xCE, 0x02, 100} +DEFINE_PROPERTYKEY!{PKEY_Image_CompressedBitsPerPixelNumerator, + 0xD21A7148, 0xD32C, 0x4624, 0x89, 0x00, 0x27, 0x72, 0x10, 0xF7, 0x9C, 0x0F, 100} +DEFINE_PROPERTYKEY!{PKEY_Image_Compression, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 259} +pub const IMAGE_COMPRESSION_UNCOMPRESSED: DWORD = 1; +pub const IMAGE_COMPRESSION_CCITT_T3: DWORD = 2; +pub const IMAGE_COMPRESSION_CCITT_T4: DWORD = 3; +pub const IMAGE_COMPRESSION_CCITT_T6: DWORD = 4; +pub const IMAGE_COMPRESSION_LZW: DWORD = 5; +pub const IMAGE_COMPRESSION_JPEG: DWORD = 6; +pub const IMAGE_COMPRESSION_PACKBITS: DWORD = 32773; +DEFINE_PROPERTYKEY!{PKEY_Image_CompressionText, + 0x3F08E66F, 0x2F44, 0x4BB9, 0xA6, 0x82, 0xAC, 0x35, 0xD2, 0x56, 0x23, 0x22, 100} +DEFINE_PROPERTYKEY!{PKEY_Image_Dimensions, + 0x6444048F, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 13} +DEFINE_PROPERTYKEY!{PKEY_Image_HorizontalResolution, + 0x6444048F, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 5} +DEFINE_PROPERTYKEY!{PKEY_Image_HorizontalSize, + 0x6444048F, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 3} +DEFINE_PROPERTYKEY!{PKEY_Image_ImageID, + 0x10DABE05, 0x32AA, 0x4C29, 0xBF, 0x1A, 0x63, 0xE2, 0xD2, 0x20, 0x58, 0x7F, 100} +DEFINE_PROPERTYKEY!{PKEY_Image_ResolutionUnit, + 0x19B51FA6, 0x1F92, 0x4A5C, 0xAB, 0x48, 0x7D, 0xF0, 0xAB, 0xD6, 0x74, 0x44, 100} +DEFINE_PROPERTYKEY!{PKEY_Image_VerticalResolution, + 0x6444048F, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 6} +DEFINE_PROPERTYKEY!{PKEY_Image_VerticalSize, + 0x6444048F, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 4} +DEFINE_PROPERTYKEY!{PKEY_Journal_Contacts, + 0xDEA7C82C, 0x1D89, 0x4A66, 0x94, 0x27, 0xA4, 0xE3, 0xDE, 0xBA, 0xBC, 0xB1, 100} +DEFINE_PROPERTYKEY!{PKEY_Journal_EntryType, + 0x95BEB1FC, 0x326D, 0x4644, 0xB3, 0x96, 0xCD, 0x3E, 0xD9, 0x0E, 0x6D, 0xDF, 100} +DEFINE_PROPERTYKEY!{PKEY_LayoutPattern_ContentViewModeForBrowse, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 500} +pub const LAYOUTPATTERN_CVMFB_ALPHA: &'static str = "alpha"; +pub const LAYOUTPATTERN_CVMFB_BETA: &'static str = "beta"; +pub const LAYOUTPATTERN_CVMFB_GAMMA: &'static str = "gamma"; +pub const LAYOUTPATTERN_CVMFB_DELTA: &'static str = "delta"; +DEFINE_PROPERTYKEY!{PKEY_LayoutPattern_ContentViewModeForSearch, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 501} +pub const LAYOUTPATTERN_CVMFS_ALPHA: &'static str = "alpha"; +pub const LAYOUTPATTERN_CVMFS_BETA: &'static str = "beta"; +pub const LAYOUTPATTERN_CVMFS_GAMMA: &'static str = "gamma"; +pub const LAYOUTPATTERN_CVMFS_DELTA: &'static str = "delta"; +DEFINE_PROPERTYKEY!{PKEY_History_SelectionCount, + 0x1CE0D6BC, 0x536C, 0x4600, 0xB0, 0xDD, 0x7E, 0x0C, 0x66, 0xB3, 0x50, 0xD5, 8} +DEFINE_PROPERTYKEY!{PKEY_History_TargetUrlHostName, + 0x1CE0D6BC, 0x536C, 0x4600, 0xB0, 0xDD, 0x7E, 0x0C, 0x66, 0xB3, 0x50, 0xD5, 9} +DEFINE_PROPERTYKEY!{PKEY_Link_Arguments, + 0x436F2667, 0x14E2, 0x4FEB, 0xB3, 0x0A, 0x14, 0x6C, 0x53, 0xB5, 0xB6, 0x74, 100} +DEFINE_PROPERTYKEY!{PKEY_Link_Comment, + 0xB9B4B3FC, 0x2B51, 0x4A42, 0xB5, 0xD8, 0x32, 0x41, 0x46, 0xAF, 0xCF, 0x25, 5} +DEFINE_PROPERTYKEY!{PKEY_Link_DateVisited, + 0x5CBF2787, 0x48CF, 0x4208, 0xB9, 0x0E, 0xEE, 0x5E, 0x5D, 0x42, 0x02, 0x94, 23} +DEFINE_PROPERTYKEY!{PKEY_Link_Description, + 0x5CBF2787, 0x48CF, 0x4208, 0xB9, 0x0E, 0xEE, 0x5E, 0x5D, 0x42, 0x02, 0x94, 21} +DEFINE_PROPERTYKEY!{PKEY_Link_FeedItemLocalId, + 0x8A2F99F9, 0x3C37, 0x465D, 0xA8, 0xD7, 0x69, 0x77, 0x7A, 0x24, 0x6D, 0x0C, 2} +DEFINE_PROPERTYKEY!{PKEY_Link_Status, + 0xB9B4B3FC, 0x2B51, 0x4A42, 0xB5, 0xD8, 0x32, 0x41, 0x46, 0xAF, 0xCF, 0x25, 3} +pub const LINK_STATUS_RESOLVED: LONG = 1; +pub const LINK_STATUS_BROKEN: LONG = 2; +DEFINE_PROPERTYKEY!{PKEY_Link_TargetExtension, + 0x7A7D76F4, 0xB630, 0x4BD7, 0x95, 0xFF, 0x37, 0xCC, 0x51, 0xA9, 0x75, 0xC9, 2} +DEFINE_PROPERTYKEY!{PKEY_Link_TargetParsingPath, + 0xB9B4B3FC, 0x2B51, 0x4A42, 0xB5, 0xD8, 0x32, 0x41, 0x46, 0xAF, 0xCF, 0x25, 2} +DEFINE_PROPERTYKEY!{PKEY_Link_TargetSFGAOFlags, + 0xB9B4B3FC, 0x2B51, 0x4A42, 0xB5, 0xD8, 0x32, 0x41, 0x46, 0xAF, 0xCF, 0x25, 8} +DEFINE_PROPERTYKEY!{PKEY_Link_TargetUrlHostName, + 0x8A2F99F9, 0x3C37, 0x465D, 0xA8, 0xD7, 0x69, 0x77, 0x7A, 0x24, 0x6D, 0x0C, 5} +DEFINE_PROPERTYKEY!{PKEY_Link_TargetUrlPath, + 0x8A2F99F9, 0x3C37, 0x465D, 0xA8, 0xD7, 0x69, 0x77, 0x7A, 0x24, 0x6D, 0x0C, 6} +DEFINE_PROPERTYKEY!{PKEY_Media_AuthorUrl, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 32} +DEFINE_PROPERTYKEY!{PKEY_Media_AverageLevel, + 0x09EDD5B6, 0xB301, 0x43C5, 0x99, 0x90, 0xD0, 0x03, 0x02, 0xEF, 0xFD, 0x46, 100} +DEFINE_PROPERTYKEY!{PKEY_Media_ClassPrimaryID, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 13} +DEFINE_PROPERTYKEY!{PKEY_Media_ClassSecondaryID, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 14} +DEFINE_PROPERTYKEY!{PKEY_Media_CollectionGroupID, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 24} +DEFINE_PROPERTYKEY!{PKEY_Media_CollectionID, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 25} +DEFINE_PROPERTYKEY!{PKEY_Media_ContentDistributor, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 18} +DEFINE_PROPERTYKEY!{PKEY_Media_ContentID, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 26} +DEFINE_PROPERTYKEY!{PKEY_Media_CreatorApplication, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 27} +DEFINE_PROPERTYKEY!{PKEY_Media_CreatorApplicationVersion, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 28} +DEFINE_PROPERTYKEY!{PKEY_Media_DateEncoded, + 0x2E4B640D, 0x5019, 0x46D8, 0x88, 0x81, 0x55, 0x41, 0x4C, 0xC5, 0xCA, 0xA0, 100} +DEFINE_PROPERTYKEY!{PKEY_Media_DateReleased, + 0xDE41CC29, 0x6971, 0x4290, 0xB4, 0x72, 0xF5, 0x9F, 0x2E, 0x2F, 0x31, 0xE2, 100} +DEFINE_PROPERTYKEY!{PKEY_Media_DlnaProfileID, + 0xCFA31B45, 0x525D, 0x4998, 0xBB, 0x44, 0x3F, 0x7D, 0x81, 0x54, 0x2F, 0xA4, 100} +DEFINE_PROPERTYKEY!{PKEY_Media_Duration, + 0x64440490, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 3} +DEFINE_PROPERTYKEY!{PKEY_Media_DVDID, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 15} +DEFINE_PROPERTYKEY!{PKEY_Media_EncodedBy, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 36} +DEFINE_PROPERTYKEY!{PKEY_Media_EncodingSettings, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 37} +DEFINE_PROPERTYKEY!{PKEY_Media_EpisodeNumber, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 100} +DEFINE_PROPERTYKEY!{PKEY_Media_FrameCount, + 0x6444048F, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 12} +DEFINE_PROPERTYKEY!{PKEY_Media_MCDI, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 16} +DEFINE_PROPERTYKEY!{PKEY_Media_MetadataContentProvider, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 17} +DEFINE_PROPERTYKEY!{PKEY_Media_Producer, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 22} +DEFINE_PROPERTYKEY!{PKEY_Media_PromotionUrl, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 33} +DEFINE_PROPERTYKEY!{PKEY_Media_ProtectionType, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 38} +DEFINE_PROPERTYKEY!{PKEY_Media_ProviderRating, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 39} +DEFINE_PROPERTYKEY!{PKEY_Media_ProviderStyle, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 40} +DEFINE_PROPERTYKEY!{PKEY_Media_Publisher, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 30} +DEFINE_PROPERTYKEY!{PKEY_Media_SeasonNumber, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 101} +DEFINE_PROPERTYKEY!{PKEY_Media_SeriesName, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 42} +DEFINE_PROPERTYKEY!{PKEY_Media_SubscriptionContentId, + 0x9AEBAE7A, 0x9644, 0x487D, 0xA9, 0x2C, 0x65, 0x75, 0x85, 0xED, 0x75, 0x1A, 100} +DEFINE_PROPERTYKEY!{PKEY_Media_SubTitle, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 38} +DEFINE_PROPERTYKEY!{PKEY_Media_ThumbnailLargePath, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 47} +DEFINE_PROPERTYKEY!{PKEY_Media_ThumbnailLargeUri, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 48} +DEFINE_PROPERTYKEY!{PKEY_Media_ThumbnailSmallPath, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 49} +DEFINE_PROPERTYKEY!{PKEY_Media_ThumbnailSmallUri, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 50} +DEFINE_PROPERTYKEY!{PKEY_Media_UniqueFileIdentifier, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 35} +DEFINE_PROPERTYKEY!{PKEY_Media_UserNoAutoInfo, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 41} +DEFINE_PROPERTYKEY!{PKEY_Media_UserWebUrl, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 34} +DEFINE_PROPERTYKEY!{PKEY_Media_Writer, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 23} +DEFINE_PROPERTYKEY!{PKEY_Media_Year, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 5} +DEFINE_PROPERTYKEY!{PKEY_Message_AttachmentContents, + 0x3143BF7C, 0x80A8, 0x4854, 0x88, 0x80, 0xE2, 0xE4, 0x01, 0x89, 0xBD, 0xD0, 100} +DEFINE_PROPERTYKEY!{PKEY_Message_AttachmentNames, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 21} +DEFINE_PROPERTYKEY!{PKEY_Message_BccAddress, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 2} +DEFINE_PROPERTYKEY!{PKEY_Message_BccName, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 3} +DEFINE_PROPERTYKEY!{PKEY_Message_CcAddress, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 4} +DEFINE_PROPERTYKEY!{PKEY_Message_CcName, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 5} +DEFINE_PROPERTYKEY!{PKEY_Message_ConversationID, + 0xDC8F80BD, 0xAF1E, 0x4289, 0x85, 0xB6, 0x3D, 0xFC, 0x1B, 0x49, 0x39, 0x92, 100} +DEFINE_PROPERTYKEY!{PKEY_Message_ConversationIndex, + 0xDC8F80BD, 0xAF1E, 0x4289, 0x85, 0xB6, 0x3D, 0xFC, 0x1B, 0x49, 0x39, 0x92, 101} +DEFINE_PROPERTYKEY!{PKEY_Message_DateReceived, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 20} +DEFINE_PROPERTYKEY!{PKEY_Message_DateSent, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 19} +DEFINE_PROPERTYKEY!{PKEY_Message_Flags, + 0xA82D9EE7, 0xCA67, 0x4312, 0x96, 0x5E, 0x22, 0x6B, 0xCE, 0xA8, 0x50, 0x23, 100} +DEFINE_PROPERTYKEY!{PKEY_Message_FromAddress, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 13} +DEFINE_PROPERTYKEY!{PKEY_Message_FromName, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 14} +DEFINE_PROPERTYKEY!{PKEY_Message_HasAttachments, + 0x9C1FCF74, 0x2D97, 0x41BA, 0xB4, 0xAE, 0xCB, 0x2E, 0x36, 0x61, 0xA6, 0xE4, 8} +DEFINE_PROPERTYKEY!{PKEY_Message_IsFwdOrReply, + 0x9A9BC088, 0x4F6D, 0x469E, 0x99, 0x19, 0xE7, 0x05, 0x41, 0x20, 0x40, 0xF9, 100} +DEFINE_PROPERTYKEY!{PKEY_Message_MessageClass, + 0xCD9ED458, 0x08CE, 0x418F, 0xA7, 0x0E, 0xF9, 0x12, 0xC7, 0xBB, 0x9C, 0x5C, 103} +DEFINE_PROPERTYKEY!{PKEY_Message_Participants, + 0x1A9BA605, 0x8E7C, 0x4D11, 0xAD, 0x7D, 0xA5, 0x0A, 0xDA, 0x18, 0xBA, 0x1B, 2} +DEFINE_PROPERTYKEY!{PKEY_Message_ProofInProgress, + 0x9098F33C, 0x9A7D, 0x48A8, 0x8D, 0xE5, 0x2E, 0x12, 0x27, 0xA6, 0x4E, 0x91, 100} +DEFINE_PROPERTYKEY!{PKEY_Message_SenderAddress, + 0x0BE1C8E7, 0x1981, 0x4676, 0xAE, 0x14, 0xFD, 0xD7, 0x8F, 0x05, 0xA6, 0xE7, 100} +DEFINE_PROPERTYKEY!{PKEY_Message_SenderName, + 0x0DA41CFA, 0xD224, 0x4A18, 0xAE, 0x2F, 0x59, 0x61, 0x58, 0xDB, 0x4B, 0x3A, 100} +DEFINE_PROPERTYKEY!{PKEY_Message_Store, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 15} +DEFINE_PROPERTYKEY!{PKEY_Message_ToAddress, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 16} +DEFINE_PROPERTYKEY!{PKEY_Message_ToDoFlags, + 0x1F856A9F, 0x6900, 0x4ABA, 0x95, 0x05, 0x2D, 0x5F, 0x1B, 0x4D, 0x66, 0xCB, 100} +DEFINE_PROPERTYKEY!{PKEY_Message_ToDoTitle, + 0xBCCC8A3C, 0x8CEF, 0x42E5, 0x9B, 0x1C, 0xC6, 0x90, 0x79, 0x39, 0x8B, 0xC7, 100} +DEFINE_PROPERTYKEY!{PKEY_Message_ToName, + 0xE3E0584C, 0xB788, 0x4A5A, 0xBB, 0x20, 0x7F, 0x5A, 0x44, 0xC9, 0xAC, 0xDD, 17} +DEFINE_PROPERTYKEY!{PKEY_Music_AlbumArtist, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 13} +DEFINE_PROPERTYKEY!{PKEY_Music_AlbumArtistSortOverride, + 0xF1FDB4AF, 0xF78C, 0x466C, 0xBB, 0x05, 0x56, 0xE9, 0x2D, 0xB0, 0xB8, 0xEC, 103} +DEFINE_PROPERTYKEY!{PKEY_Music_AlbumID, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 100} +DEFINE_PROPERTYKEY!{PKEY_Music_AlbumTitle, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 4} +DEFINE_PROPERTYKEY!{PKEY_Music_AlbumTitleSortOverride, + 0x13EB7FFC, 0xEC89, 0x4346, 0xB1, 0x9D, 0xCC, 0xC6, 0xF1, 0x78, 0x42, 0x23, 101} +DEFINE_PROPERTYKEY!{PKEY_Music_Artist, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 2} +DEFINE_PROPERTYKEY!{PKEY_Music_ArtistSortOverride, + 0xDEEB2DB5, 0x0696, 0x4CE0, 0x94, 0xFE, 0xA0, 0x1F, 0x77, 0xA4, 0x5F, 0xB5, 102} +DEFINE_PROPERTYKEY!{PKEY_Music_BeatsPerMinute, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 35} +DEFINE_PROPERTYKEY!{PKEY_Music_Composer, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 19} +DEFINE_PROPERTYKEY!{PKEY_Music_ComposerSortOverride, + 0x00BC20A3, 0xBD48, 0x4085, 0x87, 0x2C, 0xA8, 0x8D, 0x77, 0xF5, 0x09, 0x7E, 105} +DEFINE_PROPERTYKEY!{PKEY_Music_Conductor, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 36} +DEFINE_PROPERTYKEY!{PKEY_Music_ContentGroupDescription, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 33} +DEFINE_PROPERTYKEY!{PKEY_Music_DiscNumber, + 0x6AFE7437, 0x9BCD, 0x49C7, 0x80, 0xFE, 0x4A, 0x5C, 0x65, 0xFA, 0x58, 0x74, 104} +DEFINE_PROPERTYKEY!{PKEY_Music_DisplayArtist, + 0xFD122953, 0xFA93, 0x4EF7, 0x92, 0xC3, 0x04, 0xC9, 0x46, 0xB2, 0xF7, 0xC8, 100} +DEFINE_PROPERTYKEY!{PKEY_Music_Genre, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 11} +DEFINE_PROPERTYKEY!{PKEY_Music_InitialKey, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 34} +DEFINE_PROPERTYKEY!{PKEY_Music_IsCompilation, + 0xC449D5CB, 0x9EA4, 0x4809, 0x82, 0xE8, 0xAF, 0x9D, 0x59, 0xDE, 0xD6, 0xD1, 100} +DEFINE_PROPERTYKEY!{PKEY_Music_Lyrics, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 12} +DEFINE_PROPERTYKEY!{PKEY_Music_Mood, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 39} +DEFINE_PROPERTYKEY!{PKEY_Music_PartOfSet, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 37} +DEFINE_PROPERTYKEY!{PKEY_Music_Period, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 31} +DEFINE_PROPERTYKEY!{PKEY_Music_SynchronizedLyrics, + 0x6B223B6A, 0x162E, 0x4AA9, 0xB3, 0x9F, 0x05, 0xD6, 0x78, 0xFC, 0x6D, 0x77, 100} +DEFINE_PROPERTYKEY!{PKEY_Music_TrackNumber, + 0x56A3372E, 0xCE9C, 0x11D2, 0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6, 7} +DEFINE_PROPERTYKEY!{PKEY_Note_Color, + 0x4776CAFA, 0xBCE4, 0x4CB1, 0xA2, 0x3E, 0x26, 0x5E, 0x76, 0xD8, 0xEB, 0x11, 100} +pub const NOTE_COLOR_BLUE: DWORD = 0; +pub const NOTE_COLOR_GREEN: DWORD = 1; +pub const NOTE_COLOR_PINK: DWORD = 2; +pub const NOTE_COLOR_YELLOW: DWORD = 3; +pub const NOTE_COLOR_WHITE: DWORD = 4; +pub const NOTE_COLOR_LIGHTGREEN: DWORD = 5; +DEFINE_PROPERTYKEY!{PKEY_Note_ColorText, + 0x46B4E8DE, 0xCDB2, 0x440D, 0x88, 0x5C, 0x16, 0x58, 0xEB, 0x65, 0xB9, 0x14, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_Aperture, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 37378} +DEFINE_PROPERTYKEY!{PKEY_Photo_ApertureDenominator, + 0xE1A9A38B, 0x6685, 0x46BD, 0x87, 0x5E, 0x57, 0x0D, 0xC7, 0xAD, 0x73, 0x20, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ApertureNumerator, + 0x0337ECEC, 0x39FB, 0x4581, 0xA0, 0xBD, 0x4C, 0x4C, 0xC5, 0x1E, 0x99, 0x14, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_Brightness, + 0x1A701BF6, 0x478C, 0x4361, 0x83, 0xAB, 0x37, 0x01, 0xBB, 0x05, 0x3C, 0x58, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_BrightnessDenominator, + 0x6EBE6946, 0x2321, 0x440A, 0x90, 0xF0, 0xC0, 0x43, 0xEF, 0xD3, 0x24, 0x76, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_BrightnessNumerator, + 0x9E7D118F, 0xB314, 0x45A0, 0x8C, 0xFB, 0xD6, 0x54, 0xB9, 0x17, 0xC9, 0xE9, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_CameraManufacturer, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 271} +DEFINE_PROPERTYKEY!{PKEY_Photo_CameraModel, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 272} +DEFINE_PROPERTYKEY!{PKEY_Photo_CameraSerialNumber, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 273} +DEFINE_PROPERTYKEY!{PKEY_Photo_Contrast, + 0x2A785BA9, 0x8D23, 0x4DED, 0x82, 0xE6, 0x60, 0xA3, 0x50, 0xC8, 0x6A, 0x10, 100} +pub const PHOTO_CONTRAST_NORMAL: DWORD = 0; +pub const PHOTO_CONTRAST_SOFT: DWORD = 1; +pub const PHOTO_CONTRAST_HARD: DWORD = 2; +DEFINE_PROPERTYKEY!{PKEY_Photo_ContrastText, + 0x59DDE9F2, 0x5253, 0x40EA, 0x9A, 0x8B, 0x47, 0x9E, 0x96, 0xC6, 0x24, 0x9A, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_DateTaken, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 36867} +DEFINE_PROPERTYKEY!{PKEY_Photo_DigitalZoom, + 0xF85BF840, 0xA925, 0x4BC2, 0xB0, 0xC4, 0x8E, 0x36, 0xB5, 0x98, 0x67, 0x9E, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_DigitalZoomDenominator, + 0x745BAF0E, 0xE5C1, 0x4CFB, 0x8A, 0x1B, 0xD0, 0x31, 0xA0, 0xA5, 0x23, 0x93, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_DigitalZoomNumerator, + 0x16CBB924, 0x6500, 0x473B, 0xA5, 0xBE, 0xF1, 0x59, 0x9B, 0xCB, 0xE4, 0x13, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_Event, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 18248} +DEFINE_PROPERTYKEY!{PKEY_Photo_EXIFVersion, + 0xD35F743A, 0xEB2E, 0x47F2, 0xA2, 0x86, 0x84, 0x41, 0x32, 0xCB, 0x14, 0x27, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureBias, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 37380} +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureBiasDenominator, + 0xAB205E50, 0x04B7, 0x461C, 0xA1, 0x8C, 0x2F, 0x23, 0x38, 0x36, 0xE6, 0x27, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureBiasNumerator, + 0x738BF284, 0x1D87, 0x420B, 0x92, 0xCF, 0x58, 0x34, 0xBF, 0x6E, 0xF9, 0xED, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureIndex, + 0x967B5AF8, 0x995A, 0x46ED, 0x9E, 0x11, 0x35, 0xB3, 0xC5, 0xB9, 0x78, 0x2D, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureIndexDenominator, + 0x93112F89, 0xC28B, 0x492F, 0x8A, 0x9D, 0x4B, 0xE2, 0x06, 0x2C, 0xEE, 0x8A, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureIndexNumerator, + 0xCDEDCF30, 0x8919, 0x44DF, 0x8F, 0x4C, 0x4E, 0xB2, 0xFF, 0xDB, 0x8D, 0x89, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureProgram, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 34850} +pub const PHOTO_EXPOSUREPROGRAM_UNKNOWN: DWORD = 0; +pub const PHOTO_EXPOSUREPROGRAM_MANUAL: DWORD = 1; +pub const PHOTO_EXPOSUREPROGRAM_NORMAL: DWORD = 2; +pub const PHOTO_EXPOSUREPROGRAM_APERTURE: DWORD = 3; +pub const PHOTO_EXPOSUREPROGRAM_SHUTTER: DWORD = 4; +pub const PHOTO_EXPOSUREPROGRAM_CREATIVE: DWORD = 5; +pub const PHOTO_EXPOSUREPROGRAM_ACTION: DWORD = 6; +pub const PHOTO_EXPOSUREPROGRAM_PORTRAIT: DWORD = 7; +pub const PHOTO_EXPOSUREPROGRAM_LANDSCAPE: DWORD = 8; +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureProgramText, + 0xFEC690B7, 0x5F30, 0x4646, 0xAE, 0x47, 0x4C, 0xAA, 0xFB, 0xA8, 0x84, 0xA3, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureTime, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 33434} +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureTimeDenominator, + 0x55E98597, 0xAD16, 0x42E0, 0xB6, 0x24, 0x21, 0x59, 0x9A, 0x19, 0x98, 0x38, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ExposureTimeNumerator, + 0x257E44E2, 0x9031, 0x4323, 0xAC, 0x38, 0x85, 0xC5, 0x52, 0x87, 0x1B, 0x2E, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_Flash, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 37385} +pub const PHOTO_FLASH_NONE: LONG = 0; +pub const PHOTO_FLASH_FLASH: LONG = 1; +pub const PHOTO_FLASH_WITHOUTSTROBE: LONG = 5; +pub const PHOTO_FLASH_WITHSTROBE: LONG = 7; +pub const PHOTO_FLASH_FLASH_COMPULSORY: LONG = 9; +pub const PHOTO_FLASH_FLASH_COMPULSORY_NORETURNLIGHT: LONG = 13; +pub const PHOTO_FLASH_FLASH_COMPULSORY_RETURNLIGHT: LONG = 15; +pub const PHOTO_FLASH_NONE_COMPULSORY: LONG = 16; +pub const PHOTO_FLASH_NONE_AUTO: LONG = 24; +pub const PHOTO_FLASH_FLASH_AUTO: LONG = 25; +pub const PHOTO_FLASH_FLASH_AUTO_NORETURNLIGHT: LONG = 29; +pub const PHOTO_FLASH_FLASH_AUTO_RETURNLIGHT: LONG = 31; +pub const PHOTO_FLASH_NOFUNCTION: LONG = 32; +pub const PHOTO_FLASH_FLASH_REDEYE: LONG = 65; +pub const PHOTO_FLASH_FLASH_REDEYE_NORETURNLIGHT: LONG = 69; +pub const PHOTO_FLASH_FLASH_REDEYE_RETURNLIGHT: LONG = 71; +pub const PHOTO_FLASH_FLASH_COMPULSORY_REDEYE: LONG = 73; +pub const PHOTO_FLASH_FLASH_COMPULSORY_REDEYE_NORETURNLIGHT: LONG = 77; +pub const PHOTO_FLASH_FLASH_COMPULSORY_REDEYE_RETURNLIGHT: LONG = 79; +pub const PHOTO_FLASH_FLASH_AUTO_REDEYE: LONG = 89; +pub const PHOTO_FLASH_FLASH_AUTO_REDEYE_NORETURNLIGHT: LONG = 93; +pub const PHOTO_FLASH_FLASH_AUTO_REDEYE_RETURNLIGHT: LONG = 95; +DEFINE_PROPERTYKEY!{PKEY_Photo_FlashEnergy, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 41483} +DEFINE_PROPERTYKEY!{PKEY_Photo_FlashEnergyDenominator, + 0xD7B61C70, 0x6323, 0x49CD, 0xA5, 0xFC, 0xC8, 0x42, 0x77, 0x16, 0x2C, 0x97, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FlashEnergyNumerator, + 0xFCAD3D3D, 0x0858, 0x400F, 0xAA, 0xA3, 0x2F, 0x66, 0xCC, 0xE2, 0xA6, 0xBC, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FlashManufacturer, + 0xAABAF6C9, 0xE0C5, 0x4719, 0x85, 0x85, 0x57, 0xB1, 0x03, 0xE5, 0x84, 0xFE, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FlashModel, + 0xFE83BB35, 0x4D1A, 0x42E2, 0x91, 0x6B, 0x06, 0xF3, 0xE1, 0xAF, 0x71, 0x9E, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FlashText, + 0x6B8B68F6, 0x200B, 0x47EA, 0x8D, 0x25, 0xD8, 0x05, 0x0F, 0x57, 0x33, 0x9F, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FNumber, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 33437} +DEFINE_PROPERTYKEY!{PKEY_Photo_FNumberDenominator, + 0xE92A2496, 0x223B, 0x4463, 0xA4, 0xE3, 0x30, 0xEA, 0xBB, 0xA7, 0x9D, 0x80, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FNumberNumerator, + 0x1B97738A, 0xFDFC, 0x462F, 0x9D, 0x93, 0x19, 0x57, 0xE0, 0x8B, 0xE9, 0x0C, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FocalLength, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 37386} +DEFINE_PROPERTYKEY!{PKEY_Photo_FocalLengthDenominator, + 0x305BC615, 0xDCA1, 0x44A5, 0x9F, 0xD4, 0x10, 0xC0, 0xBA, 0x79, 0x41, 0x2E, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FocalLengthInFilm, + 0xA0E74609, 0xB84D, 0x4F49, 0xB8, 0x60, 0x46, 0x2B, 0xD9, 0x97, 0x1F, 0x98, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FocalLengthNumerator, + 0x776B6B3B, 0x1E3D, 0x4B0C, 0x9A, 0x0E, 0x8F, 0xBA, 0xF2, 0xA8, 0x49, 0x2A, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FocalPlaneXResolution, + 0xCFC08D97, 0xC6F7, 0x4484, 0x89, 0xDD, 0xEB, 0xEF, 0x43, 0x56, 0xFE, 0x76, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FocalPlaneXResolutionDenominator, + 0x0933F3F5, 0x4786, 0x4F46, 0xA8, 0xE8, 0xD6, 0x4D, 0xD3, 0x7F, 0xA5, 0x21, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FocalPlaneXResolutionNumerator, + 0xDCCB10AF, 0xB4E2, 0x4B88, 0x95, 0xF9, 0x03, 0x1B, 0x4D, 0x5A, 0xB4, 0x90, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FocalPlaneYResolution, + 0x4FFFE4D0, 0x914F, 0x4AC4, 0x8D, 0x6F, 0xC9, 0xC6, 0x1D, 0xE1, 0x69, 0xB1, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FocalPlaneYResolutionDenominator, + 0x1D6179A6, 0xA876, 0x4031, 0xB0, 0x13, 0x33, 0x47, 0xB2, 0xB6, 0x4D, 0xC8, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_FocalPlaneYResolutionNumerator, + 0xA2E541C5, 0x4440, 0x4BA8, 0x86, 0x7E, 0x75, 0xCF, 0xC0, 0x68, 0x28, 0xCD, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_GainControl, + 0xFA304789, 0x00C7, 0x4D80, 0x90, 0x4A, 0x1E, 0x4D, 0xCC, 0x72, 0x65, 0xAA, 100} +pub const PHOTO_GAINCONTROL_NONE: DOUBLE = 0.0; +pub const PHOTO_GAINCONTROL_LOWGAINUP: DOUBLE = 1.0; +pub const PHOTO_GAINCONTROL_HIGHGAINUP: DOUBLE = 2.0; +pub const PHOTO_GAINCONTROL_LOWGAINDOWN: DOUBLE = 3.0; +pub const PHOTO_GAINCONTROL_HIGHGAINDOWN: DOUBLE = 4.0; +DEFINE_PROPERTYKEY!{PKEY_Photo_GainControlDenominator, + 0x42864DFD, 0x9DA4, 0x4F77, 0xBD, 0xED, 0x4A, 0xAD, 0x7B, 0x25, 0x67, 0x35, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_GainControlNumerator, + 0x8E8ECF7C, 0xB7B8, 0x4EB8, 0xA6, 0x3F, 0x0E, 0xE7, 0x15, 0xC9, 0x6F, 0x9E, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_GainControlText, + 0xC06238B2, 0x0BF9, 0x4279, 0xA7, 0x23, 0x25, 0x85, 0x67, 0x15, 0xCB, 0x9D, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ISOSpeed, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 34855} +DEFINE_PROPERTYKEY!{PKEY_Photo_LensManufacturer, + 0xE6DDCAF7, 0x29C5, 0x4F0A, 0x9A, 0x68, 0xD1, 0x94, 0x12, 0xEC, 0x70, 0x90, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_LensModel, + 0xE1277516, 0x2B5F, 0x4869, 0x89, 0xB1, 0x2E, 0x58, 0x5B, 0xD3, 0x8B, 0x7A, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_LightSource, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 37384} +pub const PHOTO_LIGHTSOURCE_UNKNOWN: DWORD = 0; +pub const PHOTO_LIGHTSOURCE_DAYLIGHT: DWORD = 1; +pub const PHOTO_LIGHTSOURCE_FLUORESCENT: DWORD = 2; +pub const PHOTO_LIGHTSOURCE_TUNGSTEN: DWORD = 3; +pub const PHOTO_LIGHTSOURCE_STANDARD_A: DWORD = 17; +pub const PHOTO_LIGHTSOURCE_STANDARD_B: DWORD = 18; +pub const PHOTO_LIGHTSOURCE_STANDARD_C: DWORD = 19; +pub const PHOTO_LIGHTSOURCE_D55: DWORD = 20; +pub const PHOTO_LIGHTSOURCE_D65: DWORD = 21; +pub const PHOTO_LIGHTSOURCE_D75: DWORD = 22; +DEFINE_PROPERTYKEY!{PKEY_Photo_MakerNote, + 0xFA303353, 0xB659, 0x4052, 0x85, 0xE9, 0xBC, 0xAC, 0x79, 0x54, 0x9B, 0x84, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_MakerNoteOffset, + 0x813F4124, 0x34E6, 0x4D17, 0xAB, 0x3E, 0x6B, 0x1F, 0x3C, 0x22, 0x47, 0xA1, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_MaxAperture, + 0x08F6D7C2, 0xE3F2, 0x44FC, 0xAF, 0x1E, 0x5A, 0xA5, 0xC8, 0x1A, 0x2D, 0x3E, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_MaxApertureDenominator, + 0xC77724D4, 0x601F, 0x46C5, 0x9B, 0x89, 0xC5, 0x3F, 0x93, 0xBC, 0xEB, 0x77, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_MaxApertureNumerator, + 0xC107E191, 0xA459, 0x44C5, 0x9A, 0xE6, 0xB9, 0x52, 0xAD, 0x4B, 0x90, 0x6D, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_MeteringMode, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 37383} +pub const PHOTO_METERINGMODE_UNKNOWN: DWORD = 0; +pub const PHOTO_METERINGMODE_AVERAGE: DWORD = 1; +pub const PHOTO_METERINGMODE_CENTER: DWORD = 2; +pub const PHOTO_METERINGMODE_SPOT: DWORD = 3; +pub const PHOTO_METERINGMODE_MULTISPOT: DWORD = 4; +pub const PHOTO_METERINGMODE_PATTERN: DWORD = 5; +pub const PHOTO_METERINGMODE_PARTIAL: DWORD = 6; +DEFINE_PROPERTYKEY!{PKEY_Photo_MeteringModeText, + 0xF628FD8C, 0x7BA8, 0x465A, 0xA6, 0x5B, 0xC5, 0xAA, 0x79, 0x26, 0x3A, 0x9E, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_Orientation, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 274} +pub const PHOTO_ORIENTATION_NORMAL: DWORD = 1; +pub const PHOTO_ORIENTATION_FLIPHORIZONTAL: DWORD = 2; +pub const PHOTO_ORIENTATION_ROTATE180: DWORD = 3; +pub const PHOTO_ORIENTATION_FLIPVERTICAL: DWORD = 4; +pub const PHOTO_ORIENTATION_TRANSPOSE: DWORD = 5; +pub const PHOTO_ORIENTATION_ROTATE270: DWORD = 6; +pub const PHOTO_ORIENTATION_TRANSVERSE: DWORD = 7; +pub const PHOTO_ORIENTATION_ROTATE90: DWORD = 8; +DEFINE_PROPERTYKEY!{PKEY_Photo_OrientationText, + 0xA9EA193C, 0xC511, 0x498A, 0xA0, 0x6B, 0x58, 0xE2, 0x77, 0x6D, 0xCC, 0x28, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_PeopleNames, + 0xE8309B6E, 0x084C, 0x49B4, 0xB1, 0xFC, 0x90, 0xA8, 0x03, 0x31, 0xB6, 0x38, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_PhotometricInterpretation, + 0x341796F1, 0x1DF9, 0x4B1C, 0xA5, 0x64, 0x91, 0xBD, 0xEF, 0xA4, 0x38, 0x77, 100} +pub const PHOTO_PHOTOMETRIC_RGB: DWORD = 2; +pub const PHOTO_PHOTOMETRIC_YCBCR: DWORD = 6; +DEFINE_PROPERTYKEY!{PKEY_Photo_PhotometricInterpretationText, + 0x821437D6, 0x9EAB, 0x4765, 0xA5, 0x89, 0x3B, 0x1C, 0xBB, 0xD2, 0x2A, 0x61, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ProgramMode, + 0x6D217F6D, 0x3F6A, 0x4825, 0xB4, 0x70, 0x5F, 0x03, 0xCA, 0x2F, 0xBE, 0x9B, 100} +pub const PHOTO_PROGRAMMODE_NOTDEFINED: DWORD = 0; +pub const PHOTO_PROGRAMMODE_MANUAL: DWORD = 1; +pub const PHOTO_PROGRAMMODE_NORMAL: DWORD = 2; +pub const PHOTO_PROGRAMMODE_APERTURE: DWORD = 3; +pub const PHOTO_PROGRAMMODE_SHUTTER: DWORD = 4; +pub const PHOTO_PROGRAMMODE_CREATIVE: DWORD = 5; +pub const PHOTO_PROGRAMMODE_ACTION: DWORD = 6; +pub const PHOTO_PROGRAMMODE_PORTRAIT: DWORD = 7; +pub const PHOTO_PROGRAMMODE_LANDSCAPE: DWORD = 8; +DEFINE_PROPERTYKEY!{PKEY_Photo_ProgramModeText, + 0x7FE3AA27, 0x2648, 0x42F3, 0x89, 0xB0, 0x45, 0x4E, 0x5C, 0xB1, 0x50, 0xC3, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_RelatedSoundFile, + 0x318A6B45, 0x087F, 0x4DC2, 0xB8, 0xCC, 0x05, 0x35, 0x95, 0x51, 0xFC, 0x9E, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_Saturation, + 0x49237325, 0xA95A, 0x4F67, 0xB2, 0x11, 0x81, 0x6B, 0x2D, 0x45, 0xD2, 0xE0, 100} +pub const PHOTO_SATURATION_NORMAL: DWORD = 0; +pub const PHOTO_SATURATION_LOW: DWORD = 1; +pub const PHOTO_SATURATION_HIGH: DWORD = 2; +DEFINE_PROPERTYKEY!{PKEY_Photo_SaturationText, + 0x61478C08, 0xB600, 0x4A84, 0xBB, 0xE4, 0xE9, 0x9C, 0x45, 0xF0, 0xA0, 0x72, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_Sharpness, + 0xFC6976DB, 0x8349, 0x4970, 0xAE, 0x97, 0xB3, 0xC5, 0x31, 0x6A, 0x08, 0xF0, 100} +pub const PHOTO_SHARPNESS_NORMAL: DWORD = 0; +pub const PHOTO_SHARPNESS_SOFT: DWORD = 1; +pub const PHOTO_SHARPNESS_HARD: DWORD = 2; +DEFINE_PROPERTYKEY!{PKEY_Photo_SharpnessText, + 0x51EC3F47, 0xDD50, 0x421D, 0x87, 0x69, 0x33, 0x4F, 0x50, 0x42, 0x4B, 0x1E, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ShutterSpeed, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 37377} +DEFINE_PROPERTYKEY!{PKEY_Photo_ShutterSpeedDenominator, + 0xE13D8975, 0x81C7, 0x4948, 0xAE, 0x3F, 0x37, 0xCA, 0xE1, 0x1E, 0x8F, 0xF7, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_ShutterSpeedNumerator, + 0x16EA4042, 0xD6F4, 0x4BCA, 0x83, 0x49, 0x7C, 0x78, 0xD3, 0x0F, 0xB3, 0x33, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_SubjectDistance, + 0x14B81DA1, 0x0135, 0x4D31, 0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99, 37382} +DEFINE_PROPERTYKEY!{PKEY_Photo_SubjectDistanceDenominator, + 0x0C840A88, 0xB043, 0x466D, 0x97, 0x66, 0xD4, 0xB2, 0x6D, 0xA3, 0xFA, 0x77, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_SubjectDistanceNumerator, + 0x8AF4961C, 0xF526, 0x43E5, 0xAA, 0x81, 0xDB, 0x76, 0x82, 0x19, 0x17, 0x8D, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_TagViewAggregate, + 0xB812F15D, 0xC2D8, 0x4BBF, 0xBA, 0xCD, 0x79, 0x74, 0x43, 0x46, 0x11, 0x3F, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_TranscodedForSync, + 0x9A8EBB75, 0x6458, 0x4E82, 0xBA, 0xCB, 0x35, 0xC0, 0x09, 0x5B, 0x03, 0xBB, 100} +DEFINE_PROPERTYKEY!{PKEY_Photo_WhiteBalance, + 0xEE3D3D8A, 0x5381, 0x4CFA, 0xB1, 0x3B, 0xAA, 0xF6, 0x6B, 0x5F, 0x4E, 0xC9, 100} +pub const PHOTO_WHITEBALANCE_AUTO: DWORD = 0; +pub const PHOTO_WHITEBALANCE_MANUAL: DWORD = 1; +DEFINE_PROPERTYKEY!{PKEY_Photo_WhiteBalanceText, + 0x6336B95E, 0xC7A7, 0x426D, 0x86, 0xFD, 0x7A, 0xE3, 0xD3, 0x9C, 0x84, 0xB4, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Advanced, + 0x900A403B, 0x097B, 0x4B95, 0x8A, 0xE2, 0x07, 0x1F, 0xDA, 0xEE, 0xB1, 0x18, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Audio, + 0x2804D469, 0x788F, 0x48AA, 0x85, 0x70, 0x71, 0xB9, 0xC1, 0x87, 0xE1, 0x38, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Calendar, + 0x9973D2B5, 0xBFD8, 0x438A, 0xBA, 0x94, 0x53, 0x49, 0xB2, 0x93, 0x18, 0x1A, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Camera, + 0xDE00DE32, 0x547E, 0x4981, 0xAD, 0x4B, 0x54, 0x2F, 0x2E, 0x90, 0x07, 0xD8, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Contact, + 0xDF975FD3, 0x250A, 0x4004, 0x85, 0x8F, 0x34, 0xE2, 0x9A, 0x3E, 0x37, 0xAA, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Content, + 0xD0DAB0BA, 0x368A, 0x4050, 0xA8, 0x82, 0x6C, 0x01, 0x0F, 0xD1, 0x9A, 0x4F, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Description, + 0x8969B275, 0x9475, 0x4E00, 0xA8, 0x87, 0xFF, 0x93, 0xB8, 0xB4, 0x1E, 0x44, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_FileSystem, + 0xE3A7D2C1, 0x80FC, 0x4B40, 0x8F, 0x34, 0x30, 0xEA, 0x11, 0x1B, 0xDC, 0x2E, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_General, + 0xCC301630, 0xB192, 0x4C22, 0xB3, 0x72, 0x9F, 0x4C, 0x6D, 0x33, 0x8E, 0x07, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_GPS, + 0xF3713ADA, 0x90E3, 0x4E11, 0xAA, 0xE5, 0xFD, 0xC1, 0x76, 0x85, 0xB9, 0xBE, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Image, + 0xE3690A87, 0x0FA8, 0x4A2A, 0x9A, 0x9F, 0xFC, 0xE8, 0x82, 0x70, 0x55, 0xAC, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Media, + 0x61872CF7, 0x6B5E, 0x4B4B, 0xAC, 0x2D, 0x59, 0xDA, 0x84, 0x45, 0x92, 0x48, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_MediaAdvanced, + 0x8859A284, 0xDE7E, 0x4642, 0x99, 0xBA, 0xD4, 0x31, 0xD0, 0x44, 0xB1, 0xEC, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Message, + 0x7FD7259D, 0x16B4, 0x4135, 0x9F, 0x97, 0x7C, 0x96, 0xEC, 0xD2, 0xFA, 0x9E, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Music, + 0x68DD6094, 0x7216, 0x40F1, 0xA0, 0x29, 0x43, 0xFE, 0x71, 0x27, 0x04, 0x3F, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Origin, + 0x2598D2FB, 0x5569, 0x4367, 0x95, 0xDF, 0x5C, 0xD3, 0xA1, 0x77, 0xE1, 0xA5, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_PhotoAdvanced, + 0x0CB2BF5A, 0x9EE7, 0x4A86, 0x82, 0x22, 0xF0, 0x1E, 0x07, 0xFD, 0xAD, 0xAF, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_RecordedTV, + 0xE7B33238, 0x6584, 0x4170, 0xA5, 0xC0, 0xAC, 0x25, 0xEF, 0xD9, 0xDA, 0x56, 100} +DEFINE_PROPERTYKEY!{PKEY_PropGroup_Video, + 0xBEBE0920, 0x7671, 0x4C54, 0xA3, 0xEB, 0x49, 0xFD, 0xDF, 0xC1, 0x91, 0xEE, 100} +DEFINE_PROPERTYKEY!{PKEY_InfoTipText, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 17} +DEFINE_PROPERTYKEY!{PKEY_PropList_ConflictPrompt, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 11} +DEFINE_PROPERTYKEY!{PKEY_PropList_ContentViewModeForBrowse, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 13} +DEFINE_PROPERTYKEY!{PKEY_PropList_ContentViewModeForSearch, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 14} +DEFINE_PROPERTYKEY!{PKEY_PropList_ExtendedTileInfo, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 9} +DEFINE_PROPERTYKEY!{PKEY_PropList_FileOperationPrompt, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 10} +DEFINE_PROPERTYKEY!{PKEY_PropList_FullDetails, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 2} +DEFINE_PROPERTYKEY!{PKEY_PropList_InfoTip, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 4} +DEFINE_PROPERTYKEY!{PKEY_PropList_NonPersonal, + 0x49D1091F, 0x082E, 0x493F, 0xB2, 0x3F, 0xD2, 0x30, 0x8A, 0xA9, 0x66, 0x8C, 100} +DEFINE_PROPERTYKEY!{PKEY_PropList_PreviewDetails, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 8} +DEFINE_PROPERTYKEY!{PKEY_PropList_PreviewTitle, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 6} +DEFINE_PROPERTYKEY!{PKEY_PropList_QuickTip, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 5} +DEFINE_PROPERTYKEY!{PKEY_PropList_TileInfo, + 0xC9944A21, 0xA406, 0x48FE, 0x82, 0x25, 0xAE, 0xC7, 0xE2, 0x4C, 0x21, 0x1B, 3} +DEFINE_PROPERTYKEY!{PKEY_PropList_XPDetailsPanel, + 0xF2275480, 0xF782, 0x4291, 0xBD, 0x94, 0xF1, 0x36, 0x93, 0x51, 0x3A, 0xEC, 0} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_ChannelNumber, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 7} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_Credits, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 4} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_DateContentExpires, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 15} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_EpisodeName, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 2} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_IsATSCContent, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 16} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_IsClosedCaptioningAvailable, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 12} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_IsDTVContent, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 17} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_IsHDContent, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 18} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_IsRepeatBroadcast, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 13} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_IsSAP, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 14} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_NetworkAffiliation, + 0x2C53C813, 0xFB63, 0x4E22, 0xA1, 0xAB, 0x0B, 0x33, 0x1C, 0xA1, 0xE2, 0x73, 100} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_OriginalBroadcastDate, + 0x4684FE97, 0x8765, 0x4842, 0x9C, 0x13, 0xF0, 0x06, 0x44, 0x7B, 0x17, 0x8C, 100} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_ProgramDescription, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 3} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_RecordingTime, + 0xA5477F61, 0x7A82, 0x4ECA, 0x9D, 0xDE, 0x98, 0xB6, 0x9B, 0x24, 0x79, 0xB3, 100} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_StationCallSign, + 0x6D748DE2, 0x8D38, 0x4CC3, 0xAC, 0x60, 0xF0, 0x09, 0xB0, 0x57, 0xC5, 0x57, 5} +DEFINE_PROPERTYKEY!{PKEY_RecordedTV_StationName, + 0x1B5439E7, 0xEBA1, 0x4AF8, 0xBD, 0xD7, 0x7A, 0xF1, 0xD4, 0x54, 0x94, 0x93, 100} +DEFINE_PROPERTYKEY!{PKEY_Search_AutoSummary, + 0x560C36C0, 0x503A, 0x11CF, 0xBA, 0xA1, 0x00, 0x00, 0x4C, 0x75, 0x2A, 0x9A, 2} +DEFINE_PROPERTYKEY!{PKEY_Search_ContainerHash, + 0xBCEEE283, 0x35DF, 0x4D53, 0x82, 0x6A, 0xF3, 0x6A, 0x3E, 0xEF, 0xC6, 0xBE, 100} +DEFINE_PROPERTYKEY!{PKEY_Search_Contents, + 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 19} +DEFINE_PROPERTYKEY!{PKEY_Search_EntryID, + 0x49691C90, 0x7E17, 0x101A, 0xA9, 0x1C, 0x08, 0x00, 0x2B, 0x2E, 0xCD, 0xA9, 5} +DEFINE_PROPERTYKEY!{PKEY_Search_ExtendedProperties, + 0x7B03B546, 0xFA4F, 0x4A52, 0xA2, 0xFE, 0x03, 0xD5, 0x31, 0x1E, 0x58, 0x65, 100} +DEFINE_PROPERTYKEY!{PKEY_Search_GatherTime, + 0x0B63E350, 0x9CCC, 0x11D0, 0xBC, 0xDB, 0x00, 0x80, 0x5F, 0xCC, 0xCE, 0x04, 8} +DEFINE_PROPERTYKEY!{PKEY_Search_HitCount, + 0x49691C90, 0x7E17, 0x101A, 0xA9, 0x1C, 0x08, 0x00, 0x2B, 0x2E, 0xCD, 0xA9, 4} +DEFINE_PROPERTYKEY!{PKEY_Search_IsClosedDirectory, + 0x0B63E343, 0x9CCC, 0x11D0, 0xBC, 0xDB, 0x00, 0x80, 0x5F, 0xCC, 0xCE, 0x04, 23} +DEFINE_PROPERTYKEY!{PKEY_Search_IsFullyContained, + 0x0B63E343, 0x9CCC, 0x11D0, 0xBC, 0xDB, 0x00, 0x80, 0x5F, 0xCC, 0xCE, 0x04, 24} +DEFINE_PROPERTYKEY!{PKEY_Search_QueryFocusedSummary, + 0x560C36C0, 0x503A, 0x11CF, 0xBA, 0xA1, 0x00, 0x00, 0x4C, 0x75, 0x2A, 0x9A, 3} +DEFINE_PROPERTYKEY!{PKEY_Search_QueryFocusedSummaryWithFallback, + 0x560C36C0, 0x503A, 0x11CF, 0xBA, 0xA1, 0x00, 0x00, 0x4C, 0x75, 0x2A, 0x9A, 4} +DEFINE_PROPERTYKEY!{PKEY_Search_QueryPropertyHits, + 0x49691C90, 0x7E17, 0x101A, 0xA9, 0x1C, 0x08, 0x00, 0x2B, 0x2E, 0xCD, 0xA9, 21} +DEFINE_PROPERTYKEY!{PKEY_Search_Rank, + 0x49691C90, 0x7E17, 0x101A, 0xA9, 0x1C, 0x08, 0x00, 0x2B, 0x2E, 0xCD, 0xA9, 3} +DEFINE_PROPERTYKEY!{PKEY_Search_Store, + 0xA06992B3, 0x8CAF, 0x4ED7, 0xA5, 0x47, 0xB2, 0x59, 0xE3, 0x2A, 0xC9, 0xFC, 100} +DEFINE_PROPERTYKEY!{PKEY_Search_UrlToIndex, + 0x0B63E343, 0x9CCC, 0x11D0, 0xBC, 0xDB, 0x00, 0x80, 0x5F, 0xCC, 0xCE, 0x04, 2} +DEFINE_PROPERTYKEY!{PKEY_Search_UrlToIndexWithModificationTime, + 0x0B63E343, 0x9CCC, 0x11D0, 0xBC, 0xDB, 0x00, 0x80, 0x5F, 0xCC, 0xCE, 0x04, 12} +DEFINE_PROPERTYKEY!{PKEY_Supplemental_AlbumID, + 0x0C73B141, 0x39D6, 0x4653, 0xA6, 0x83, 0xCA, 0xB2, 0x91, 0xEA, 0xF9, 0x5B, 2} +DEFINE_PROPERTYKEY!{PKEY_Supplemental_ResourceId, + 0x0C73B141, 0x39D6, 0x4653, 0xA6, 0x83, 0xCA, 0xB2, 0x91, 0xEA, 0xF9, 0x5B, 3} +DEFINE_PROPERTYKEY!{PKEY_DescriptionID, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 2} +DEFINE_PROPERTYKEY!{PKEY_InternalName, + 0x0CEF7D53, 0xFA64, 0x11D1, 0xA2, 0x03, 0x00, 0x00, 0xF8, 0x1F, 0xED, 0xEE, 5} +DEFINE_PROPERTYKEY!{PKEY_LibraryLocationsCount, + 0x908696C7, 0x8F87, 0x44F2, 0x80, 0xED, 0xA8, 0xC1, 0xC6, 0x89, 0x45, 0x75, 2} +DEFINE_PROPERTYKEY!{PKEY_Link_TargetSFGAOFlagsStrings, + 0xD6942081, 0xD53B, 0x443D, 0xAD, 0x47, 0x5E, 0x05, 0x9D, 0x9C, 0xD2, 0x7A, 3} +DEFINE_PROPERTYKEY!{PKEY_Link_TargetUrl, + 0x5CBF2787, 0x48CF, 0x4208, 0xB9, 0x0E, 0xEE, 0x5E, 0x5D, 0x42, 0x02, 0x94, 2} +DEFINE_PROPERTYKEY!{PKEY_NamespaceCLSID, + 0x28636AA6, 0x953D, 0x11D2, 0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0, 6} +DEFINE_PROPERTYKEY!{PKEY_Shell_SFGAOFlagsStrings, + 0xD6942081, 0xD53B, 0x443D, 0xAD, 0x47, 0x5E, 0x05, 0x9D, 0x9C, 0xD2, 0x7A, 2} +pub const SFGAOSTR_FILESYS: &'static str = "filesys"; +pub const SFGAOSTR_FILEANC: &'static str = "fileanc"; +pub const SFGAOSTR_STORAGEANC: &'static str = "storageanc"; +pub const SFGAOSTR_STREAM: &'static str = "stream"; +pub const SFGAOSTR_LINK: &'static str = "link"; +pub const SFGAOSTR_HIDDEN: &'static str = "hidden"; +pub const SFGAOSTR_SUPERHIDDEN: &'static str = "superhidden"; +pub const SFGAOSTR_FOLDER: &'static str = "folder"; +pub const SFGAOSTR_NONENUM: &'static str = "nonenum"; +pub const SFGAOSTR_BROWSABLE: &'static str = "browsable"; +pub const SFGAOSTR_SYSTEM: &'static str = "system"; +DEFINE_PROPERTYKEY!{PKEY_StatusBarSelectedItemCount, + 0x26DC287C, 0x6E3D, 0x4BD3, 0xB2, 0xB0, 0x6A, 0x26, 0xBA, 0x2E, 0x34, 0x6D, 3} +DEFINE_PROPERTYKEY!{PKEY_StatusBarViewItemCount, + 0x26DC287C, 0x6E3D, 0x4BD3, 0xB2, 0xB0, 0x6A, 0x26, 0xBA, 0x2E, 0x34, 0x6D, 2} +DEFINE_PROPERTYKEY!{PKEY_AppUserModel_ExcludeFromShowInNewInstall, + 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 8} +DEFINE_PROPERTYKEY!{PKEY_AppUserModel_ID, + 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 5} +DEFINE_PROPERTYKEY!{PKEY_AppUserModel_IsDestListSeparator, + 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 6} +DEFINE_PROPERTYKEY!{PKEY_AppUserModel_IsDualMode, + 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 11} +DEFINE_PROPERTYKEY!{PKEY_AppUserModel_PreventPinning, + 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 9} +DEFINE_PROPERTYKEY!{PKEY_AppUserModel_RelaunchCommand, + 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 2} +DEFINE_PROPERTYKEY!{PKEY_AppUserModel_RelaunchDisplayNameResource, + 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 4} +DEFINE_PROPERTYKEY!{PKEY_AppUserModel_RelaunchIconResource, + 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 3} +DEFINE_PROPERTYKEY!{PKEY_AppUserModel_StartPinOption, + 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 12} +pub const APPUSERMODEL_STARTPINOPTION_DEFAULT: DWORD = 0; +pub const APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL: DWORD = 1; +pub const APPUSERMODEL_STARTPINOPTION_USERPINNED: DWORD = 2; +DEFINE_PROPERTYKEY!{PKEY_AppUserModel_ToastActivatorCLSID, + 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 26} +DEFINE_PROPERTYKEY!{PKEY_EdgeGesture_DisableTouchWhenFullscreen, + 0x32CE38B2, 0x2C9A, 0x41B1, 0x9B, 0xC5, 0xB3, 0x78, 0x43, 0x94, 0xAA, 0x44, 2} +DEFINE_PROPERTYKEY!{PKEY_Software_DateLastUsed, + 0x841E4F90, 0xFF59, 0x4D16, 0x89, 0x47, 0xE8, 0x1B, 0xBF, 0xFA, 0xB3, 0x6D, 16} +DEFINE_PROPERTYKEY!{PKEY_Software_ProductName, + 0x0CEF7D53, 0xFA64, 0x11D1, 0xA2, 0x03, 0x00, 0x00, 0xF8, 0x1F, 0xED, 0xEE, 7} +DEFINE_PROPERTYKEY!{PKEY_Sync_Comments, + 0x7BD5533E, 0xAF15, 0x44DB, 0xB8, 0xC8, 0xBD, 0x66, 0x24, 0xE1, 0xD0, 0x32, 13} +DEFINE_PROPERTYKEY!{PKEY_Sync_ConflictDescription, + 0xCE50C159, 0x2FB8, 0x41FD, 0xBE, 0x68, 0xD3, 0xE0, 0x42, 0xE2, 0x74, 0xBC, 4} +DEFINE_PROPERTYKEY!{PKEY_Sync_ConflictFirstLocation, + 0xCE50C159, 0x2FB8, 0x41FD, 0xBE, 0x68, 0xD3, 0xE0, 0x42, 0xE2, 0x74, 0xBC, 6} +DEFINE_PROPERTYKEY!{PKEY_Sync_ConflictSecondLocation, + 0xCE50C159, 0x2FB8, 0x41FD, 0xBE, 0x68, 0xD3, 0xE0, 0x42, 0xE2, 0x74, 0xBC, 7} +DEFINE_PROPERTYKEY!{PKEY_Sync_HandlerCollectionID, + 0x7BD5533E, 0xAF15, 0x44DB, 0xB8, 0xC8, 0xBD, 0x66, 0x24, 0xE1, 0xD0, 0x32, 2} +DEFINE_PROPERTYKEY!{PKEY_Sync_HandlerID, + 0x7BD5533E, 0xAF15, 0x44DB, 0xB8, 0xC8, 0xBD, 0x66, 0x24, 0xE1, 0xD0, 0x32, 3} +DEFINE_PROPERTYKEY!{PKEY_Sync_HandlerName, + 0xCE50C159, 0x2FB8, 0x41FD, 0xBE, 0x68, 0xD3, 0xE0, 0x42, 0xE2, 0x74, 0xBC, 2} +DEFINE_PROPERTYKEY!{PKEY_Sync_HandlerType, + 0x7BD5533E, 0xAF15, 0x44DB, 0xB8, 0xC8, 0xBD, 0x66, 0x24, 0xE1, 0xD0, 0x32, 8} +pub const SYNC_HANDLERTYPE_OTHER: DWORD = 0; +pub const SYNC_HANDLERTYPE_PROGRAMS: DWORD = 1; +pub const SYNC_HANDLERTYPE_DEVICES: DWORD = 2; +pub const SYNC_HANDLERTYPE_FOLDERS: DWORD = 3; +pub const SYNC_HANDLERTYPE_WEBSERVICES: DWORD = 4; +pub const SYNC_HANDLERTYPE_COMPUTERS: DWORD = 5; +DEFINE_PROPERTYKEY!{PKEY_Sync_HandlerTypeLabel, + 0x7BD5533E, 0xAF15, 0x44DB, 0xB8, 0xC8, 0xBD, 0x66, 0x24, 0xE1, 0xD0, 0x32, 9} +DEFINE_PROPERTYKEY!{PKEY_Sync_ItemID, + 0x7BD5533E, 0xAF15, 0x44DB, 0xB8, 0xC8, 0xBD, 0x66, 0x24, 0xE1, 0xD0, 0x32, 6} +DEFINE_PROPERTYKEY!{PKEY_Sync_ItemName, + 0xCE50C159, 0x2FB8, 0x41FD, 0xBE, 0x68, 0xD3, 0xE0, 0x42, 0xE2, 0x74, 0xBC, 3} +DEFINE_PROPERTYKEY!{PKEY_Sync_ProgressPercentage, + 0x7BD5533E, 0xAF15, 0x44DB, 0xB8, 0xC8, 0xBD, 0x66, 0x24, 0xE1, 0xD0, 0x32, 23} +DEFINE_PROPERTYKEY!{PKEY_Sync_State, + 0x7BD5533E, 0xAF15, 0x44DB, 0xB8, 0xC8, 0xBD, 0x66, 0x24, 0xE1, 0xD0, 0x32, 24} +pub const SYNC_STATE_NOTSETUP: DWORD = 0; +pub const SYNC_STATE_SYNCNOTRUN: DWORD = 1; +pub const SYNC_STATE_IDLE: DWORD = 2; +pub const SYNC_STATE_ERROR: DWORD = 3; +pub const SYNC_STATE_PENDING: DWORD = 4; +pub const SYNC_STATE_SYNCING: DWORD = 5; +DEFINE_PROPERTYKEY!{PKEY_Sync_Status, + 0x7BD5533E, 0xAF15, 0x44DB, 0xB8, 0xC8, 0xBD, 0x66, 0x24, 0xE1, 0xD0, 0x32, 10} +DEFINE_PROPERTYKEY!{PKEY_Task_BillingInformation, + 0xD37D52C6, 0x261C, 0x4303, 0x82, 0xB3, 0x08, 0xB9, 0x26, 0xAC, 0x6F, 0x12, 100} +DEFINE_PROPERTYKEY!{PKEY_Task_CompletionStatus, + 0x084D8A0A, 0xE6D5, 0x40DE, 0xBF, 0x1F, 0xC8, 0x82, 0x0E, 0x7C, 0x87, 0x7C, 100} +DEFINE_PROPERTYKEY!{PKEY_Task_Owner, + 0x08C7CC5F, 0x60F2, 0x4494, 0xAD, 0x75, 0x55, 0xE3, 0xE0, 0xB5, 0xAD, 0xD0, 100} +DEFINE_PROPERTYKEY!{PKEY_Video_Compression, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 10} +DEFINE_PROPERTYKEY!{PKEY_Video_Director, + 0x64440492, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 20} +DEFINE_PROPERTYKEY!{PKEY_Video_EncodingBitrate, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 8} +DEFINE_PROPERTYKEY!{PKEY_Video_FourCC, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 44} +DEFINE_PROPERTYKEY!{PKEY_Video_FrameHeight, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 4} +DEFINE_PROPERTYKEY!{PKEY_Video_FrameRate, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 6} +DEFINE_PROPERTYKEY!{PKEY_Video_FrameWidth, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 3} +DEFINE_PROPERTYKEY!{PKEY_Video_HorizontalAspectRatio, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 42} +DEFINE_PROPERTYKEY!{PKEY_Video_IsSpherical, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 100} +DEFINE_PROPERTYKEY!{PKEY_Video_IsStereo, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 98} +DEFINE_PROPERTYKEY!{PKEY_Video_Orientation, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 99} +DEFINE_PROPERTYKEY!{PKEY_Video_SampleSize, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 9} +DEFINE_PROPERTYKEY!{PKEY_Video_StreamName, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 2} +DEFINE_PROPERTYKEY!{PKEY_Video_StreamNumber, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 11} +DEFINE_PROPERTYKEY!{PKEY_Video_TotalBitrate, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 43} +DEFINE_PROPERTYKEY!{PKEY_Video_TranscodedForSync, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 46} +DEFINE_PROPERTYKEY!{PKEY_Video_VerticalAspectRatio, + 0x64440491, 0x4C8B, 0x11D1, 0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03, 45} +DEFINE_PROPERTYKEY!{PKEY_Volume_FileSystem, + 0x9B174B35, 0x40FF, 0x11D2, 0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71, 4} +DEFINE_PROPERTYKEY!{PKEY_Volume_IsMappedDrive, + 0x149C0B69, 0x2C2D, 0x48FC, 0x80, 0x8F, 0xD3, 0x18, 0xD7, 0x8C, 0x46, 0x36, 2} +DEFINE_PROPERTYKEY!{PKEY_Volume_IsRoot, + 0x9B174B35, 0x40FF, 0x11D2, 0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71, 10} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/propkeydef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/propkeydef.rs new file mode 100644 index 0000000..bc0924c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/propkeydef.rs @@ -0,0 +1,13 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +use shared::guiddef::IsEqualIID; +use shared::wtypes::{PROPERTYKEY, PROPID}; +pub const PID_FIRST_USABLE: PROPID = 2; +pub type REFPROPERTYKEY = *const PROPERTYKEY; +#[inline] +pub fn IsEqualPropertyKey(a: &PROPERTYKEY, b: &PROPERTYKEY) -> bool { + (a.pid == b.pid) && IsEqualIID(&a.fmtid, &b.fmtid) +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/propsys.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/propsys.rs new file mode 100644 index 0000000..9a4f6a0 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/propsys.rs @@ -0,0 +1,46 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::DWORD; +use shared::wtypes::PROPERTYKEY; +use um::propidl::{PROPVARIANT, REFPROPVARIANT}; +use um::propkeydef::REFPROPERTYKEY; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::HRESULT; +pub type IPropertyDescriptionList = IUnknown; // TODO +RIDL!{#[uuid(0x886d8eeb, 0x8cf2, 0x4446, 0x8d, 0x02, 0xcd, 0xba, 0x1d, 0xbd, 0xcf, 0x99)] +interface IPropertyStore(IPropertyStoreVtbl): IUnknown(IUnknownVtbl) { + fn GetCount( + cProps: *mut DWORD, + ) -> HRESULT, + fn GetAt( + iProp: DWORD, + pkey: *mut PROPERTYKEY, + ) -> HRESULT, + fn GetValue( + key: REFPROPERTYKEY, + pv: *mut PROPVARIANT, + ) -> HRESULT, + fn SetValue( + key: REFPROPERTYKEY, + propvar: REFPROPVARIANT, + ) -> HRESULT, + fn Commit() -> HRESULT, +}} +ENUM!{enum GETPROPERTYSTOREFLAGS { + GPS_DEFAULT = 0, + GPS_HANDLERPROPERTIESONLY = 0x1, + GPS_READWRITE = 0x2, + GPS_TEMPORARY = 0x4, + GPS_FASTPROPERTIESONLY = 0x8, + GPS_OPENSLOWITEM = 0x10, + GPS_DELAYCREATION = 0x20, + GPS_BESTEFFORT = 0x40, + GPS_NO_OPLOCK = 0x80, + GPS_PREFERQUERYPROPERTIES = 0x100, + GPS_EXTRINSICPROPERTIES = 0x200, + GPS_EXTRINSICPROPERTIESONLY = 0x400, + GPS_MASK_VALID = 0x7ff, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/prsht.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/prsht.rs new file mode 100644 index 0000000..25cb926 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/prsht.rs @@ -0,0 +1,361 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Interface for the Windows Property Sheet Pages +use ctypes::{c_int, c_short}; +use shared::basetsd::INT_PTR; +use shared::minwindef::{BOOL, DWORD, HINSTANCE, LPARAM, LPVOID, LRESULT, UINT, WPARAM}; +use shared::windef::{HBITMAP, HICON, HPALETTE, HWND}; +use um::winnt::{HANDLE, LPCSTR, LPCWSTR}; +use um::winuser::{DLGPROC, LPCDLGTEMPLATEA, NMHDR, WM_USER}; +pub enum PSP {} +pub type HPROPSHEETPAGE = *mut PSP; +FN!{stdcall LPFNPSPCALLBACKA( + hwnd: HWND, + uMsg: UINT, + ppsp: *mut PROPSHEETPAGEA, +) -> UINT} +FN!{stdcall LPFNPSPCALLBACKW( + hwnd: HWND, + uMsg: UINT, + ppsp: *mut PROPSHEETPAGEW, +) -> UINT} +pub const PSP_DEFAULT: DWORD = 0x00000000; +pub const PSP_DLGINDIRECT: DWORD = 0x00000001; +pub const PSP_USEHICON: DWORD = 0x00000002; +pub const PSP_USEICONID: DWORD = 0x00000004; +pub const PSP_USETITLE: DWORD = 0x00000008; +pub const PSP_RTLREADING: DWORD = 0x00000010; +pub const PSP_HASHELP: DWORD = 0x00000020; +pub const PSP_USEREFPARENT: DWORD = 0x00000040; +pub const PSP_USECALLBACK: DWORD = 0x00000080; +pub const PSP_PREMATURE: DWORD = 0x00000400; +pub const PSP_HIDEHEADER: DWORD = 0x00000800; +pub const PSP_USEHEADERTITLE: DWORD = 0x00001000; +pub const PSP_USEHEADERSUBTITLE: DWORD = 0x00002000; +pub const PSP_USEFUSIONCONTEXT: DWORD = 0x00004000; +pub const PSPCB_ADDREF: UINT = 0; +pub const PSPCB_RELEASE: UINT = 1; +pub const PSPCB_CREATE: UINT = 2; +pub type PROPSHEETPAGE_RESOURCE = LPCDLGTEMPLATEA; +UNION!{union PROPSHEETPAGEA_V1_u1 { + [usize; 1], + pszTemplate pszTemplate_mut: LPCSTR, + pResource pResource_mut: PROPSHEETPAGE_RESOURCE, +}} +UNION!{union PROPSHEETPAGEA_V1_u2 { + [usize; 1], + hIcon hIcon_mut: HICON, + pszIcon pszIcon_mut: LPCSTR, +}} +UNION!{union PROPSHEETPAGEA_V4_u3 { + [usize; 1], + hbmHeader hbmHeader_mut: HBITMAP, + pszbmHeader pszbmHeader_mut: LPCSTR, +}} +STRUCT!{struct PROPSHEETPAGEA_V4 { + dwSize: DWORD, + dwFlags: DWORD, + hInstance: HINSTANCE, + u1: PROPSHEETPAGEA_V1_u1, + u2: PROPSHEETPAGEA_V1_u2, + pszTitle: LPCSTR, + pfnDlgProc: DLGPROC, + lParam: LPARAM, + pfnCallback: LPFNPSPCALLBACKA, + pcRefParent: *mut UINT, + pszHeaderTitle: LPCSTR, + pszHeaderSubTitle: LPCSTR, + hActCtx: HANDLE, + u3: PROPSHEETPAGEA_V4_u3, +}} +pub type LPPROPSHEETPAGEA_V4 = *mut PROPSHEETPAGEA_V4; +pub type LPCPROPSHEETPAGEA_V4 = *const PROPSHEETPAGEA_V4; +UNION!{union PROPSHEETPAGEW_V1_u1 { + [usize; 1], + pszTemplate pszTemplate_mut: LPCWSTR, + pResource pResource_mut: PROPSHEETPAGE_RESOURCE, +}} +UNION!{union PROPSHEETPAGEW_V1_u2 { + [usize; 1], + hIcon hIcon_mut: HICON, + pszIcon pszIcon_mut: LPCWSTR, +}} +UNION!{union PROPSHEETPAGEW_V4_u3 { + [usize; 1], + hbmHeader hbmHeader_mut: HBITMAP, + pszbmHeader pszbmHeader_mut: LPCWSTR, +}} +STRUCT!{struct PROPSHEETPAGEW_V4 { + dwSize: DWORD, + dwFlags: DWORD, + hInstance: HINSTANCE, + u1: PROPSHEETPAGEW_V1_u1, + u2: PROPSHEETPAGEW_V1_u2, + pszTitle: LPCWSTR, + pfnDlgProc: DLGPROC, + lParam: LPARAM, + pfnCallback: LPFNPSPCALLBACKW, + pcRefParent: *mut UINT, + pszHeaderTitle: LPCWSTR, + pszHeaderSubTitle: LPCWSTR, + hActCtx: HANDLE, + u3: PROPSHEETPAGEW_V4_u3, +}} +pub type LPPROPSHEETPAGEW_V4 = *mut PROPSHEETPAGEW_V4; +pub type LPCPROPSHEETPAGEW_V4 = *const PROPSHEETPAGEW_V4; +pub type PROPSHEETPAGEA_LATEST = PROPSHEETPAGEA_V4; +pub type PROPSHEETPAGEW_LATEST = PROPSHEETPAGEW_V4; +pub type LPPROPSHEETPAGEA_LATEST = LPPROPSHEETPAGEA_V4; +pub type LPPROPSHEETPAGEW_LATEST = LPPROPSHEETPAGEW_V4; +pub type LPCPROPSHEETPAGEA_LATEST = LPCPROPSHEETPAGEA_V4; +pub type LPCPROPSHEETPAGEW_LATEST = LPCPROPSHEETPAGEW_V4; +pub type PROPSHEETPAGEA = PROPSHEETPAGEA_V4; +pub type PROPSHEETPAGEW = PROPSHEETPAGEW_V4; +pub type LPPROPSHEETPAGEA = LPPROPSHEETPAGEA_V4; +pub type LPPROPSHEETPAGEW = LPPROPSHEETPAGEW_V4; +pub type LPCPROPSHEETPAGEA = LPCPROPSHEETPAGEA_V4; +pub type LPCPROPSHEETPAGEW = LPCPROPSHEETPAGEW_V4; +pub const PSH_DEFAULT: DWORD = 0x00000000; +pub const PSH_PROPTITLE: DWORD = 0x00000001; +pub const PSH_USEHICON: DWORD = 0x00000002; +pub const PSH_USEICONID: DWORD = 0x00000004; +pub const PSH_PROPSHEETPAGE: DWORD = 0x00000008; +pub const PSH_WIZARDHASFINISH: DWORD = 0x00000010; +pub const PSH_WIZARD: DWORD = 0x00000020; +pub const PSH_USEPSTARTPAGE: DWORD = 0x00000040; +pub const PSH_NOAPPLYNOW: DWORD = 0x00000080; +pub const PSH_USECALLBACK: DWORD = 0x00000100; +pub const PSH_HASHELP: DWORD = 0x00000200; +pub const PSH_MODELESS: DWORD = 0x00000400; +pub const PSH_RTLREADING: DWORD = 0x00000800; +pub const PSH_WIZARDCONTEXTHELP: DWORD = 0x00001000; +pub const PSH_WIZARD97: DWORD = 0x01000000; +pub const PSH_WATERMARK: DWORD = 0x00008000; +pub const PSH_USEHBMWATERMARK: DWORD = 0x00010000; +pub const PSH_USEHPLWATERMARK: DWORD = 0x00020000; +pub const PSH_STRETCHWATERMARK: DWORD = 0x00040000; +pub const PSH_HEADER: DWORD = 0x00080000; +pub const PSH_USEHBMHEADER: DWORD = 0x00100000; +pub const PSH_USEPAGELANG: DWORD = 0x00200000; +pub const PSH_WIZARD_LITE: DWORD = 0x00400000; +pub const PSH_NOCONTEXTHELP: DWORD = 0x02000000; +pub const PSH_AEROWIZARD: DWORD = 0x00004000; +pub const PSH_RESIZABLE: DWORD = 0x04000000; +pub const PSH_HEADERBITMAP: DWORD = 0x08000000; +pub const PSH_NOMARGIN: DWORD = 0x10000000; +FN!{stdcall PFNPROPSHEETCALLBACK( + HWND, + UINT, + LPARAM, +) -> c_int} +UNION!{union PROPSHEETHEADERA_V1_u1 { + [usize; 1], + hIcon hIcon_mut: HICON, + pszIcon pszIcon_mut: LPCSTR, +}} +UNION!{union PROPSHEETHEADERA_V1_u2 { + [usize; 1], + nStartPage nStartPage_mut: UINT, + pStartPage pStartPage_mut: LPCSTR, +}} +UNION!{union PROPSHEETHEADERA_V1_u3 { + [usize; 1], + ppsp ppsp_mut: LPCPROPSHEETPAGEA, + phpage phpage_mut: *mut HPROPSHEETPAGE, +}} +UNION!{union PROPSHEETHEADERA_V2_u4 { + [usize; 1], + hbmWatermark hbmWatermark_mut: HBITMAP, + pszbmWatermark pszbmWatermark_mut: LPCSTR, +}} +UNION!{union PROPSHEETHEADERA_V2_u5 { + [usize; 1], + hbmHeader hbmHeader_mut: HBITMAP, + pszbmHeader pszbmHeader_mut: LPCSTR, +}} +STRUCT!{struct PROPSHEETHEADERA_V2 { + dwSize: DWORD, + dwFlags: DWORD, + hwndParent: HWND, + hInstance: HINSTANCE, + u1: PROPSHEETHEADERA_V1_u1, + pszCaption: LPCSTR, + nPages: UINT, + u2: PROPSHEETHEADERA_V1_u2, + u3: PROPSHEETHEADERA_V1_u3, + pfnCallback: PFNPROPSHEETCALLBACK, + u4: PROPSHEETHEADERA_V2_u4, + hplWatermark: HPALETTE, + u5: PROPSHEETHEADERA_V2_u5, +}} +pub type LPPROPSHEETHEADERA_V2 = *mut PROPSHEETHEADERA_V2; +pub type LPCPROPSHEETHEADERA_V2 = *const PROPSHEETHEADERA_V2; +UNION!{union PROPSHEETHEADERW_V1_u1 { + [usize; 1], + hIcon hIcon_mut: HICON, + pszIcon pszIcon_mut: LPCWSTR, +}} +UNION!{union PROPSHEETHEADERW_V1_u2 { + [usize; 1], + nStartPage nStartPage_mut: UINT, + pStartPage pStartPage_mut: LPCWSTR, +}} +UNION!{union PROPSHEETHEADERW_V1_u3 { + [usize; 1], + ppsp ppsp_mut: LPCPROPSHEETPAGEW, + phpage phpage_mut: *mut HPROPSHEETPAGE, +}} +UNION!{union PROPSHEETHEADERW_V2_u4 { + [usize; 1], + hbmWatermark hbmWatermark_mut: HBITMAP, + pszbmWatermark pszbmWatermark_mut: LPCWSTR, +}} +UNION!{union PROPSHEETHEADERW_V2_u5 { + [usize; 1], + hbmHeader hbmHeader_mut: HBITMAP, + pszbmHeader pszbmHeader_mut: LPCWSTR, +}} +STRUCT!{struct PROPSHEETHEADERW_V2 { + dwSize: DWORD, + dwFlags: DWORD, + hwndParent: HWND, + hInstance: HINSTANCE, + u1: PROPSHEETHEADERW_V1_u1, + pszCaption: LPCWSTR, + nPages: UINT, + u2: PROPSHEETHEADERW_V1_u2, + u3: PROPSHEETHEADERW_V1_u3, + pfnCallback: PFNPROPSHEETCALLBACK, + u4: PROPSHEETHEADERW_V2_u4, + hplWatermark: HPALETTE, + u5: PROPSHEETHEADERW_V2_u5, +}} +pub type LPPROPSHEETHEADERW_V2 = *mut PROPSHEETHEADERW_V2; +pub type LPCPROPSHEETHEADERW_V2 = *const PROPSHEETHEADERW_V2; +pub type PROPSHEETHEADERA = PROPSHEETHEADERA_V2; +pub type PROPSHEETHEADERW = PROPSHEETHEADERW_V2; +pub type LPPROPSHEETHEADERA = LPPROPSHEETHEADERA_V2; +pub type LPPROPSHEETHEADERW = LPPROPSHEETHEADERW_V2; +pub type LPCPROPSHEETHEADERA = LPCPROPSHEETHEADERA_V2; +pub type LPCPROPSHEETHEADERW = LPCPROPSHEETHEADERW_V2; +pub const PSCB_INITIALIZED: UINT = 1; +pub const PSCB_PRECREATE: UINT = 2; +pub const PSCB_BUTTONPRESSED: UINT = 3; +extern "system" { + pub fn CreatePropertySheetPageA( + constPropSheetPagePointer: LPCPROPSHEETPAGEA, + ) -> HPROPSHEETPAGE; + pub fn CreatePropertySheetPageW( + constPropSheetPagePointer: LPCPROPSHEETPAGEW, + ) -> HPROPSHEETPAGE; + pub fn DestroyPropertySheetPage( + hPSPage: HPROPSHEETPAGE, + ) -> BOOL; + pub fn PropertySheetA( + lppsph: LPCPROPSHEETHEADERA, + ) -> INT_PTR; + pub fn PropertySheetW( + lppsph: LPCPROPSHEETHEADERW, + ) -> INT_PTR; +} +FN!{stdcall LPFNADDPROPSHEETPAGE( + HPROPSHEETPAGE, + LPARAM, +) -> BOOL} +FN!{stdcall LPFNADDPROPSHEETPAGES( + LPVOID, + LPFNADDPROPSHEETPAGE, + LPARAM, +) -> BOOL} +STRUCT!{struct PSHNOTIFY { + hdr: NMHDR, + lParam: LPARAM, +}} +pub type LPPSHNOTIFY = *mut PSHNOTIFY; +pub const PSN_FIRST: UINT = -200i32 as u32; +pub const PSN_LAST: UINT = -299i32 as u32; +pub const PSN_SETACTIVE: UINT = PSN_FIRST - 0; +pub const PSN_KILLACTIVE: UINT = PSN_FIRST - 1; +pub const PSN_APPLY: UINT = PSN_FIRST - 2; +pub const PSN_RESET: UINT = PSN_FIRST - 3; +pub const PSN_HELP: UINT = PSN_FIRST - 5; +pub const PSN_WIZBACK: UINT = PSN_FIRST - 6; +pub const PSN_WIZNEXT: UINT = PSN_FIRST - 7; +pub const PSN_WIZFINISH: UINT = PSN_FIRST - 8; +pub const PSN_QUERYCANCEL: UINT = PSN_FIRST - 9; +pub const PSN_GETOBJECT: UINT = PSN_FIRST - 10; +pub const PSN_TRANSLATEACCELERATOR: UINT = PSN_FIRST - 12; +pub const PSN_QUERYINITIALFOCUS: UINT = PSN_FIRST - 13; +pub const PSNRET_NOERROR: LRESULT = 0; +pub const PSNRET_INVALID: LRESULT = 1; +pub const PSNRET_INVALID_NOCHANGEPAGE: LRESULT = 2; +pub const PSNRET_MESSAGEHANDLED: LRESULT = 3; +pub const PSM_SETCURSEL: UINT = WM_USER + 101; +pub const PSM_REMOVEPAGE: UINT = WM_USER + 102; +pub const PSM_ADDPAGE: UINT = WM_USER + 103; +pub const PSM_CHANGED: UINT = WM_USER + 104; +pub const PSM_RESTARTWINDOWS: UINT = WM_USER + 105; +pub const PSM_REBOOTSYSTEM: UINT = WM_USER + 106; +pub const PSM_CANCELTOCLOSE: UINT = WM_USER + 107; +pub const PSM_QUERYSIBLINGS: UINT = WM_USER + 108; +pub const PSM_UNCHANGED: UINT = WM_USER + 109; +pub const PSM_APPLY: UINT = WM_USER + 110; +pub const PSM_SETTITLEA: UINT = WM_USER + 111; +pub const PSM_SETTITLEW: UINT = WM_USER + 120; +pub const PSM_SETWIZBUTTONS: UINT = WM_USER + 112; +pub const PSWIZB_BACK: DWORD = 0x00000001; +pub const PSWIZB_NEXT: DWORD = 0x00000002; +pub const PSWIZB_FINISH: DWORD = 0x00000004; +pub const PSWIZB_DISABLEDFINISH: DWORD = 0x00000008; +pub const PSWIZBF_ELEVATIONREQUIRED: WPARAM = 0x00000001; +pub const PSWIZB_CANCEL: DWORD = 0x00000010; +pub const PSM_PRESSBUTTON: UINT = WM_USER + 113; +pub const PSBTN_BACK: c_int = 0; +pub const PSBTN_NEXT: c_int = 1; +pub const PSBTN_FINISH: c_int = 2; +pub const PSBTN_OK: c_int = 3; +pub const PSBTN_APPLYNOW: c_int = 4; +pub const PSBTN_CANCEL: c_int = 5; +pub const PSBTN_HELP: c_int = 6; +pub const PSBTN_MAX: c_int = 6; +pub const PSM_SETCURSELID: UINT = WM_USER + 114; +pub const PSM_SETFINISHTEXTA: UINT = WM_USER + 115; +pub const PSM_SETFINISHTEXTW: UINT = WM_USER + 121; +pub const PSM_GETTABCONTROL: UINT = WM_USER + 116; +pub const PSM_ISDIALOGMESSAGE: UINT = WM_USER + 117; +pub const PSM_GETCURRENTPAGEHWND: UINT = WM_USER + 118; +pub const PSM_INSERTPAGE: UINT = WM_USER + 119; +pub const PSM_SETHEADERTITLEA: UINT = WM_USER + 125; +pub const PSM_SETHEADERTITLEW: UINT = WM_USER + 126; +pub const PSWIZF_SETCOLOR: UINT = -1i32 as u32; +pub const PSM_SETHEADERSUBTITLEA: UINT = WM_USER + 127; +pub const PSM_SETHEADERSUBTITLEW: UINT = WM_USER + 128; +pub const PSM_HWNDTOINDEX: UINT = WM_USER + 129; +pub const PSM_INDEXTOHWND: UINT = WM_USER + 130; +pub const PSM_PAGETOINDEX: UINT = WM_USER + 131; +pub const PSM_INDEXTOPAGE: UINT = WM_USER + 132; +pub const PSM_IDTOINDEX: UINT = WM_USER + 133; +pub const PSM_INDEXTOID: UINT = WM_USER + 134; +pub const PSM_GETRESULT: UINT = WM_USER + 135; +pub const PSM_RECALCPAGESIZES: UINT = WM_USER + 136; +pub const PSM_SETNEXTTEXTW: UINT = WM_USER + 137; +pub const PSM_SHOWWIZBUTTONS: UINT = WM_USER + 138; +pub const PSM_ENABLEWIZBUTTONS: UINT = WM_USER + 139; +pub const PSM_SETBUTTONTEXTW: UINT = WM_USER + 140; +pub const PSM_SETBUTTONTEXT: UINT = PSM_SETBUTTONTEXTW; +pub const ID_PSRESTARTWINDOWS: INT_PTR = 0x2; +pub const ID_PSREBOOTSYSTEM: INT_PTR = ID_PSRESTARTWINDOWS | 0x1; +pub const WIZ_CXDLG: DWORD = 276; +pub const WIZ_CYDLG: DWORD = 140; +pub const WIZ_CXBMP: DWORD = 80; +pub const WIZ_BODYX: DWORD = 92; +pub const WIZ_BODYCX: DWORD = 184; +pub const PROP_SM_CXDLG: c_short = 212; +pub const PROP_SM_CYDLG: c_short = 188; +pub const PROP_MED_CXDLG: c_short = 227; +pub const PROP_MED_CYDLG: c_short = 215; +pub const PROP_LG_CXDLG: c_short = 252; +pub const PROP_LG_CYDLG: c_short = 218; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/psapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/psapi.rs new file mode 100644 index 0000000..eb1adb8 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/psapi.rs @@ -0,0 +1,422 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! FFI bindings to psapi. +use shared::basetsd::{SIZE_T, ULONG_PTR}; +use shared::minwindef::{BOOL, DWORD, HMODULE, LPDWORD, LPVOID, PDWORD}; +use um::winnt::{HANDLE, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PVOID}; +pub const LIST_MODULES_DEFAULT: DWORD = 0x0; +pub const LIST_MODULES_32BIT: DWORD = 0x01; +pub const LIST_MODULES_64BIT: DWORD = 0x02; +pub const LIST_MODULES_ALL: DWORD = LIST_MODULES_32BIT | LIST_MODULES_64BIT; +extern "system" { + pub fn K32EnumProcesses( + lpidProcess: *mut DWORD, + cb: DWORD, + lpcbNeeded: LPDWORD, + ) -> BOOL; + pub fn K32EnumProcessModules( + hProcess: HANDLE, + lphModule: *mut HMODULE, + cb: DWORD, + lpcbNeeded: LPDWORD, + ) -> BOOL; + pub fn K32EnumProcessModulesEx( + hProcess: HANDLE, + lphModule: *mut HMODULE, + cb: DWORD, + lpcbNeeded: LPDWORD, + dwFilterFlag: DWORD, + ) -> BOOL; + pub fn K32GetModuleBaseNameA( + hProcess: HANDLE, + hModule: HMODULE, + lpBaseName: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32GetModuleBaseNameW( + hProcess: HANDLE, + hModule: HMODULE, + lpBaseName: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32GetModuleFileNameExA( + hProcess: HANDLE, + hModule: HMODULE, + lpFilename: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32GetModuleFileNameExW( + hProcess: HANDLE, + hModule: HMODULE, + lpFilename: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32EmptyWorkingSet( + hProcess: HANDLE, + ) -> BOOL; + pub fn K32QueryWorkingSet( + hProcess: HANDLE, + pv: PVOID, + cb: DWORD, + ) -> BOOL; + pub fn K32QueryWorkingSetEx( + hProcess: HANDLE, + pv: PVOID, + cb: DWORD, + ) -> BOOL; + pub fn K32InitializeProcessForWsWatch( + hProcess: HANDLE, + ) -> BOOL; + pub fn K32GetWsChanges( + hProcess: HANDLE, + lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, + cb: DWORD, + ) -> BOOL; + pub fn K32GetWsChangesEx( + hProcess: HANDLE, + lpWatchInfoEx: PPSAPI_WS_WATCH_INFORMATION_EX, + cb: PDWORD, + ) -> BOOL; + pub fn K32GetMappedFileNameW( + hProcess: HANDLE, + lpv: LPVOID, + lpFilename: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32GetMappedFileNameA( + hProcess: HANDLE, + lpv: LPVOID, + lpFilename: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32EnumDeviceDrivers( + lpImageBase: *mut LPVOID, + cb: DWORD, + lpcbNeeded: LPDWORD, + ) -> BOOL; + pub fn K32GetDeviceDriverBaseNameA( + ImageBase: LPVOID, + lpFilename: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32GetDeviceDriverBaseNameW( + ImageBase: LPVOID, + lpFilename: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32GetDeviceDriverFileNameA( + ImageBase: LPVOID, + lpFilename: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32GetDeviceDriverFileNameW( + ImageBase: LPVOID, + lpFilename: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32GetPerformanceInfo( + pPerformanceInformation: PPERFORMANCE_INFORMATION, + cb: DWORD, + ) -> BOOL; + pub fn K32EnumPageFilesW( + pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, + pContext: LPVOID, + ) -> BOOL; + pub fn K32EnumPageFilesA( + pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, + pContext: LPVOID, + ) -> BOOL; + pub fn K32GetProcessImageFileNameA( + hProcess: HANDLE, + lpImageFileName: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn K32GetProcessImageFileNameW( + hProcess: HANDLE, + lpImageFileName: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn EnumProcesses( + lpidProcess: *mut DWORD, + cb: DWORD, + lpcbNeeded: LPDWORD, + ) -> BOOL; + pub fn K32GetProcessMemoryInfo( + Process: HANDLE, + ppsmemCounters: PPROCESS_MEMORY_COUNTERS, + cb: DWORD, + ) -> BOOL; + pub fn K32GetModuleInformation( + hProcess: HANDLE, + hModule: HMODULE, + lpmodinfo: LPMODULEINFO, + cb: DWORD, + ) -> BOOL; +} +pub type LPMODULEINFO = *mut MODULEINFO; +pub type PPSAPI_WORKING_SET_INFORMATION = *mut PSAPI_WORKING_SET_INFORMATION; +pub type PPSAPI_WORKING_SET_EX_INFORMATION = *mut PSAPI_WORKING_SET_EX_INFORMATION; +pub type PPSAPI_WS_WATCH_INFORMATION = *mut PSAPI_WS_WATCH_INFORMATION; +pub type PPSAPI_WS_WATCH_INFORMATION_EX = *mut PSAPI_WS_WATCH_INFORMATION_EX; +pub type PENUM_PAGE_FILE_INFORMATION = *mut ENUM_PAGE_FILE_INFORMATION; +pub type PPERFORMANCE_INFORMATION = *mut PERFORMANCE_INFORMATION; +pub type PPROCESS_MEMORY_COUNTERS = *mut PROCESS_MEMORY_COUNTERS; +pub type PPROCESS_MEMORY_COUNTERS_EX = *mut PROCESS_MEMORY_COUNTERS_EX; +FN!{stdcall PENUM_PAGE_FILE_CALLBACKA( + pContext: LPVOID, + pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, + lpFilename: LPCSTR, +) -> BOOL} +FN!{stdcall PENUM_PAGE_FILE_CALLBACKW( + pContext: LPVOID, + pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, + lpFilename: LPCWSTR, +) -> BOOL} +STRUCT!{struct MODULEINFO { + lpBaseOfDll: LPVOID, + SizeOfImage: DWORD, + EntryPoint: LPVOID, +}} +STRUCT!{struct ENUM_PAGE_FILE_INFORMATION { + cb: DWORD, + Reserved: DWORD, + TotalSize: SIZE_T, + TotalInUse: SIZE_T, + PeakUsage: SIZE_T, +}} +STRUCT!{struct PERFORMANCE_INFORMATION { + cb: DWORD, + CommitTotal: SIZE_T, + CommitLimit: SIZE_T, + CommitPeak: SIZE_T, + PhysicalTotal: SIZE_T, + PhysicalAvailable: SIZE_T, + SystemCache: SIZE_T, + KernelTotal: SIZE_T, + KernelPaged: SIZE_T, + KernelNonpaged: SIZE_T, + PageSize: SIZE_T, + HandleCount: DWORD, + ProcessCount: DWORD, + ThreadCount: DWORD, +}} +STRUCT!{struct PROCESS_MEMORY_COUNTERS { + cb: DWORD, + PageFaultCount: DWORD, + PeakWorkingSetSize: SIZE_T, + WorkingSetSize: SIZE_T, + QuotaPeakPagedPoolUsage: SIZE_T, + QuotaPagedPoolUsage: SIZE_T, + QuotaPeakNonPagedPoolUsage: SIZE_T, + QuotaNonPagedPoolUsage: SIZE_T, + PagefileUsage: SIZE_T, + PeakPagefileUsage: SIZE_T, +}} +STRUCT!{struct PROCESS_MEMORY_COUNTERS_EX { + cb: DWORD, + PageFaultCount: DWORD, + PeakWorkingSetSize: SIZE_T, + WorkingSetSize: SIZE_T, + QuotaPeakPagedPoolUsage: SIZE_T, + QuotaPagedPoolUsage: SIZE_T, + QuotaPeakNonPagedPoolUsage: SIZE_T, + QuotaNonPagedPoolUsage: SIZE_T, + PagefileUsage: SIZE_T, + PeakPagefileUsage: SIZE_T, + PrivateUsage: SIZE_T, +}} +STRUCT!{struct PSAPI_WORKING_SET_BLOCK { + Flags: ULONG_PTR, +}} +BITFIELD!{PSAPI_WORKING_SET_BLOCK Flags: ULONG_PTR [ + Protection set_Protection[0..5], + ShareCount set_ShareCount[5..8], + Shared set_Shared[8..9], + Reserved set_Reserved[9..12], + VirtualPage set_VirtualPage[12..32], +]} +pub type PPSAPI_WORKING_SET_BLOCK = *mut PSAPI_WORKING_SET_BLOCK; +STRUCT!{struct PSAPI_WORKING_SET_EX_BLOCK { + Flags: ULONG_PTR, +}} +#[cfg(not(target_arch="x86_64"))] +BITFIELD!{PSAPI_WORKING_SET_EX_BLOCK Flags: ULONG_PTR [ + Valid set_Valid[0..1], + ShareCount set_ShareCount[1..4], + Win32Protection set_Win32Protection[4..15], + Shared set_Shared[15..16], + Node set_Node[16..22], + Locked set_Locked[22..23], + LargePage set_LargePage[23..24], + Reserved set_Reserved[24..31], + Bad set_Bad[31..32], +]} +#[cfg(target_arch="x86_64")] +BITFIELD!{PSAPI_WORKING_SET_EX_BLOCK Flags: ULONG_PTR [ + Valid set_Valid[0..1], + ShareCount set_ShareCount[1..4], + Win32Protection set_Win32Protection[4..15], + Shared set_Shared[15..16], + Node set_Node[16..22], + Locked set_Locked[22..23], + LargePage set_LargePage[23..24], + Reserved set_Reserved[24..31], + Bad set_Bad[31..32], + ReservedUlong set_ReservedULong[32..64], +]} +pub type PPSAPI_WORKING_SET_EX_BLOCK = *mut PSAPI_WORKING_SET_EX_BLOCK; +STRUCT!{struct PSAPI_WORKING_SET_INFORMATION { + NumberOfEntries: ULONG_PTR, + WorkingSetInfo: [PSAPI_WORKING_SET_BLOCK; 1], +}} +STRUCT!{struct PSAPI_WORKING_SET_EX_INFORMATION { + VirtualAddress: PVOID, + VirtualAttributes: PSAPI_WORKING_SET_EX_BLOCK, +}} +STRUCT!{struct PSAPI_WS_WATCH_INFORMATION { + FaultingPc: LPVOID, + FaultingVa: LPVOID, +}} +STRUCT!{struct PSAPI_WS_WATCH_INFORMATION_EX { + BasicInfo: PSAPI_WS_WATCH_INFORMATION, + FaultingThreadId: ULONG_PTR, + Flags: ULONG_PTR, +}} +extern "system" { + pub fn EmptyWorkingSet( + hProcess: HANDLE, + ) -> BOOL; + pub fn EnumDeviceDrivers( + lpImageBase: *mut LPVOID, + cb: DWORD, + lpcbNeeded: LPDWORD, + ) -> BOOL; + pub fn EnumPageFilesA( + pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, + pContext: LPVOID, + ) -> BOOL; + pub fn EnumPageFilesW( + pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, + pContext: LPVOID, + ) -> BOOL; + pub fn EnumProcessModules( + hProcess: HANDLE, + lphModule: *mut HMODULE, + cb: DWORD, + lpcbNeeded: LPDWORD, + ) -> BOOL; + pub fn EnumProcessModulesEx( + hProcess: HANDLE, + lphModule: *mut HMODULE, + cb: DWORD, + lpcbNeeded: LPDWORD, + dwFilterFlag: DWORD, + ) -> BOOL; + pub fn GetDeviceDriverBaseNameA( + ImageBase: LPVOID, + lpFilename: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetDeviceDriverBaseNameW( + ImageBase: LPVOID, + lpFilename: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetDeviceDriverFileNameA( + ImageBase: LPVOID, + lpFilename: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetDeviceDriverFileNameW( + ImageBase: LPVOID, + lpFilename: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetMappedFileNameA( + hProcess: HANDLE, + lpv: LPVOID, + lpFilename: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetMappedFileNameW( + hProcess: HANDLE, + lpv: LPVOID, + lpFilename: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetModuleBaseNameA( + hProcess: HANDLE, + hModule: HMODULE, + lpBaseName: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetModuleBaseNameW( + hProcess: HANDLE, + hModule: HMODULE, + lpBaseName: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetModuleFileNameExA( + hProcess: HANDLE, + hModule: HMODULE, + lpFilename: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetModuleFileNameExW( + hProcess: HANDLE, + hModule: HMODULE, + lpFilename: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetModuleInformation( + hProcess: HANDLE, + hModule: HMODULE, + lpmodinfo: LPMODULEINFO, + cb: DWORD, + ) -> BOOL; + pub fn GetPerformanceInfo( + pPerformanceInformation: PPERFORMANCE_INFORMATION, + cb: DWORD, + ) -> BOOL; + pub fn GetProcessImageFileNameA( + hProcess: HANDLE, + lpImageFileName: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetProcessImageFileNameW( + hProcess: HANDLE, + lpImageFileName: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetProcessMemoryInfo( + hProcess: HANDLE, + ppsmemCounters: PPROCESS_MEMORY_COUNTERS, + cb: DWORD, + ) -> BOOL; + pub fn GetWsChanges( + hProcess: HANDLE, + lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, + cb: DWORD, + ) -> BOOL; + pub fn GetWsChangesEx( + hProcess: HANDLE, + lpWatchInfoEx: PPSAPI_WS_WATCH_INFORMATION_EX, + cb: PDWORD, + ) -> BOOL; + pub fn InitializeProcessForWsWatch( + hProcess: HANDLE, + ) -> BOOL; + pub fn QueryWorkingSet( + hProcess: HANDLE, + pv: PVOID, + cb: DWORD, + ) -> BOOL; + pub fn QueryWorkingSetEx( + hProcess: HANDLE, + pv: PVOID, + cb: DWORD, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/realtimeapiset.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/realtimeapiset.rs new file mode 100644 index 0000000..5f63dbe --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/realtimeapiset.rs @@ -0,0 +1,30 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::PULONG64; +use shared::minwindef::{BOOL, PULONG, USHORT}; +use um::winnt::{HANDLE, PULONGLONG}; +extern "system" { + pub fn QueryThreadCycleTime( + ThreadHandle: HANDLE, + CycleTime: PULONG64, + ) -> BOOL; + pub fn QueryProcessCycleTime( + ProcessHandle: HANDLE, + CycleTime: PULONG64, + ) -> BOOL; + pub fn QueryIdleProcessorCycleTime( + BufferLength: PULONG, + ProcessorIdleCycleTime: PULONG64, + ) -> BOOL; + pub fn QueryIdleProcessorCycleTimeEx( + Group: USHORT, + BufferLength: PULONG, + ProcessorIdleCycleTime: PULONG64, + ) -> BOOL; + pub fn QueryUnbiasedInterruptTime( + UnbiasedTime: PULONGLONG, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/reason.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/reason.rs new file mode 100644 index 0000000..609c295 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/reason.rs @@ -0,0 +1,60 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::DWORD; +pub const SHTDN_REASON_FLAG_COMMENT_REQUIRED: DWORD = 0x01000000; +pub const SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED: DWORD = 0x02000000; +pub const SHTDN_REASON_FLAG_CLEAN_UI: DWORD = 0x04000000; +pub const SHTDN_REASON_FLAG_DIRTY_UI: DWORD = 0x08000000; +pub const SHTDN_REASON_FLAG_USER_DEFINED: DWORD = 0x40000000; +pub const SHTDN_REASON_FLAG_PLANNED: DWORD = 0x80000000; +pub const SHTDN_REASON_MAJOR_OTHER: DWORD = 0x00000000; +pub const SHTDN_REASON_MAJOR_NONE: DWORD = 0x00000000; +pub const SHTDN_REASON_MAJOR_HARDWARE: DWORD = 0x00010000; +pub const SHTDN_REASON_MAJOR_OPERATINGSYSTEM: DWORD = 0x00020000; +pub const SHTDN_REASON_MAJOR_SOFTWARE: DWORD = 0x00030000; +pub const SHTDN_REASON_MAJOR_APPLICATION: DWORD = 0x00040000; +pub const SHTDN_REASON_MAJOR_SYSTEM: DWORD = 0x00050000; +pub const SHTDN_REASON_MAJOR_POWER: DWORD = 0x00060000; +pub const SHTDN_REASON_MAJOR_LEGACY_API: DWORD = 0x00070000; +pub const SHTDN_REASON_MINOR_OTHER: DWORD = 0x00000000; +pub const SHTDN_REASON_MINOR_NONE: DWORD = 0x000000ff; +pub const SHTDN_REASON_MINOR_MAINTENANCE: DWORD = 0x00000001; +pub const SHTDN_REASON_MINOR_INSTALLATION: DWORD = 0x00000002; +pub const SHTDN_REASON_MINOR_UPGRADE: DWORD = 0x00000003; +pub const SHTDN_REASON_MINOR_RECONFIG: DWORD = 0x00000004; +pub const SHTDN_REASON_MINOR_HUNG: DWORD = 0x00000005; +pub const SHTDN_REASON_MINOR_UNSTABLE: DWORD = 0x00000006; +pub const SHTDN_REASON_MINOR_DISK: DWORD = 0x00000007; +pub const SHTDN_REASON_MINOR_PROCESSOR: DWORD = 0x00000008; +pub const SHTDN_REASON_MINOR_NETWORKCARD: DWORD = 0x00000009; +pub const SHTDN_REASON_MINOR_POWER_SUPPLY: DWORD = 0x0000000a; +pub const SHTDN_REASON_MINOR_CORDUNPLUGGED: DWORD = 0x0000000b; +pub const SHTDN_REASON_MINOR_ENVIRONMENT: DWORD = 0x0000000c; +pub const SHTDN_REASON_MINOR_HARDWARE_DRIVER: DWORD = 0x0000000d; +pub const SHTDN_REASON_MINOR_OTHERDRIVER: DWORD = 0x0000000e; +pub const SHTDN_REASON_MINOR_BLUESCREEN: DWORD = 0x0000000F; +pub const SHTDN_REASON_MINOR_SERVICEPACK: DWORD = 0x00000010; +pub const SHTDN_REASON_MINOR_HOTFIX: DWORD = 0x00000011; +pub const SHTDN_REASON_MINOR_SECURITYFIX: DWORD = 0x00000012; +pub const SHTDN_REASON_MINOR_SECURITY: DWORD = 0x00000013; +pub const SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY: DWORD = 0x00000014; +pub const SHTDN_REASON_MINOR_WMI: DWORD = 0x00000015; +pub const SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL: DWORD = 0x00000016; +pub const SHTDN_REASON_MINOR_HOTFIX_UNINSTALL: DWORD = 0x00000017; +pub const SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL: DWORD = 0x00000018; +pub const SHTDN_REASON_MINOR_MMC: DWORD = 0x00000019; +pub const SHTDN_REASON_MINOR_SYSTEMRESTORE: DWORD = 0x0000001a; +pub const SHTDN_REASON_MINOR_TERMSRV: DWORD = 0x00000020; +pub const SHTDN_REASON_MINOR_DC_PROMOTION: DWORD = 0x00000021; +pub const SHTDN_REASON_MINOR_DC_DEMOTION: DWORD = 0x00000022; +pub const SHTDN_REASON_UNKNOWN: DWORD = SHTDN_REASON_MINOR_NONE; +pub const SHTDN_REASON_LEGACY_API: DWORD = SHTDN_REASON_MAJOR_LEGACY_API + | SHTDN_REASON_FLAG_PLANNED; +pub const SHTDN_REASON_VALID_BIT_MASK: DWORD = 0xc0ffffff; +pub const PCLEANUI: DWORD = SHTDN_REASON_FLAG_PLANNED | SHTDN_REASON_FLAG_CLEAN_UI; +pub const UCLEANUI: DWORD = SHTDN_REASON_FLAG_CLEAN_UI; +pub const PDIRTYUI: DWORD = SHTDN_REASON_FLAG_PLANNED | SHTDN_REASON_FLAG_DIRTY_UI; +pub const UDIRTYUI: DWORD = SHTDN_REASON_FLAG_DIRTY_UI; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/restartmanager.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/restartmanager.rs new file mode 100644 index 0000000..3f4af64 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/restartmanager.rs @@ -0,0 +1,150 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! RestartManager include file +use shared::minwindef::{BOOL, DWORD, FILETIME, LPDWORD, PBYTE, UINT, ULONG}; +use um::winnt::{LPCWSTR, LPWSTR, WCHAR}; +pub const RM_SESSION_KEY_LEN: usize = 16; // mem::size_of::<GUID>() +pub const CCH_RM_SESSION_KEY: usize = RM_SESSION_KEY_LEN * 2; +pub const CCH_RM_MAX_APP_NAME: usize = 255; +pub const CCH_RM_MAX_SVC_NAME: usize = 63; +pub const RM_INVALID_TS_SESSION: DWORD = -1i32 as u32; +pub const RM_INVALID_PROCESS: DWORD = -1i32 as u32; +ENUM!{enum RM_APP_TYPE { + RmUnknownApp = 0, + RmMainWindow = 1, + RmOtherWindow = 2, + RmService = 3, + RmExplorer = 4, + RmConsole = 5, + RmCritical = 1000, +}} +ENUM!{enum RM_SHUTDOWN_TYPE { + RmForceShutdown = 0x1, + RmShutdownOnlyRegistered = 0x10, +}} +ENUM!{enum RM_APP_STATUS { + RmStatusUnknown = 0x0, + RmStatusRunning = 0x1, + RmStatusStopped = 0x2, + RmStatusStoppedOther = 0x4, + RmStatusRestarted = 0x8, + RmStatusErrorOnStop = 0x10, + RmStatusErrorOnRestart = 0x20, + RmStatusShutdownMasked = 0x40, + RmStatusRestartMasked = 0x80, +}} +ENUM!{enum RM_REBOOT_REASON { + RmRebootReasonNone = 0x0, + RmRebootReasonPermissionDenied = 0x1, + RmRebootReasonSessionMismatch = 0x2, + RmRebootReasonCriticalProcess = 0x4, + RmRebootReasonCriticalService = 0x8, + RmRebootReasonDetectedSelf = 0x10, +}} +STRUCT!{struct RM_UNIQUE_PROCESS { + dwProcessId: DWORD, + ProcessStartTime: FILETIME, +}} +pub type PRM_UNIQUE_PROCESS = *mut RM_UNIQUE_PROCESS; +STRUCT!{struct RM_PROCESS_INFO { + Process: RM_UNIQUE_PROCESS, + strAppName: [WCHAR; CCH_RM_MAX_APP_NAME + 1], + strServiceShortName: [WCHAR; CCH_RM_MAX_SVC_NAME + 1], + ApplicationType: RM_APP_TYPE, + AppStatus: ULONG, + TSSessionId: DWORD, + bRestartable: BOOL, +}} +pub type PRM_PROCESS_INFO = *mut RM_PROCESS_INFO; +ENUM!{enum RM_FILTER_TRIGGER { + RmFilterTriggerInvalid = 0, + RmFilterTriggerFile, + RmFilterTriggerProcess, + RmFilterTriggerService, +}} +ENUM!{enum RM_FILTER_ACTION { + RmInvalidFilterAction = 0, + RmNoRestart = 1, + RmNoShutdown = 2, +}} +UNION!{union RM_FILTER_INFO_u { + [u32; 3] [u64; 2], + strFilename strFilename_mut: LPWSTR, + Process Process_mut: RM_UNIQUE_PROCESS, + strServiceShortName strServiceShortName_mut: LPWSTR, +}} +STRUCT!{struct RM_FILTER_INFO { + FilterAction: RM_FILTER_ACTION, + FilterTrigger: RM_FILTER_TRIGGER, + cbNextOffset: DWORD, + u: RM_FILTER_INFO_u, +}} +pub type PRM_FILTER_INFO = *mut RM_FILTER_INFO; +FN!{cdecl RM_WRITE_STATUS_CALLBACK( + nPercentComplete: u32, +) -> ()} +extern "system" { + pub fn RmStartSession( + pSessionHandle: *mut DWORD, + dwSessionFlags: DWORD, + strSessionKey: *mut WCHAR, + ) -> DWORD; + pub fn RmJoinSession( + pSessionHandle: *mut DWORD, + strSessionKey: *const WCHAR, + ) -> DWORD; + pub fn RmEndSession( + dwSessionHandle: DWORD, + ) -> DWORD; + pub fn RmRegisterResources( + dwSessionHandle: DWORD, + nFiles: UINT, + rgsFileNames: *mut LPCWSTR, + nApplications: UINT, + rgApplications: *mut RM_UNIQUE_PROCESS, + nServices: UINT, + rgsServiceNames: *mut LPCWSTR, + ) -> DWORD; + pub fn RmGetList( + dwSessionHandle: DWORD, + pnProcInfoNeeded: *mut UINT, + pnProcInfo: *mut UINT, + rgAffectedApps: *mut RM_PROCESS_INFO, + lpdwRebootReasons: LPDWORD, + ) -> DWORD; + pub fn RmShutdown( + dwSessionHandle: DWORD, + lActionFlags: ULONG, + fnStatus: RM_WRITE_STATUS_CALLBACK, + ) -> DWORD; + pub fn RmRestart( + dwSessionHandle: DWORD, + dwRestartFlags: DWORD, + fnStatus: RM_WRITE_STATUS_CALLBACK, + ) -> DWORD; + pub fn RmCancelCurrentTask( + dwSessionHandle: DWORD, + ) -> DWORD; + pub fn RmAddFilter( + dwSessionHandle: DWORD, + strModuleName: LPCWSTR, + pProcess: *mut RM_UNIQUE_PROCESS, + strServiceShortName: LPCWSTR, + FilterAction: RM_FILTER_ACTION, + ) -> DWORD; + pub fn RmRemoveFilter( + dwSessionHandle: DWORD, + strModuleName: LPCWSTR, + pProcess: *mut RM_UNIQUE_PROCESS, + strServiceShortName: LPCWSTR, + ) -> DWORD; + pub fn RmGetFilterList( + dwSessionHandle: DWORD, + pbFilterBuf: PBYTE, + cbFilterBuf: DWORD, + cbFilterBufNeeded: LPDWORD, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/restrictederrorinfo.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/restrictederrorinfo.rs new file mode 100644 index 0000000..9c5db98 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/restrictederrorinfo.rs @@ -0,0 +1,20 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::wtypes::BSTR; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::HRESULT; +RIDL!{#[uuid(0x82ba7092, 0x4c88, 0x427d, 0xa7, 0xbc, 0x16, 0xdd, 0x93, 0xfe, 0xb6, 0x7e)] +interface IRestrictedErrorInfo(IRestrictedErrorInfoVtbl): IUnknown(IUnknownVtbl) { + fn GetErrorDetails( + description: *mut BSTR, + error: *mut HRESULT, + restrictedDescription: *mut BSTR, + capabilitySid: *mut BSTR, + ) -> HRESULT, + fn GetReference( + reference: *mut BSTR, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/rmxfguid.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/rmxfguid.rs new file mode 100644 index 0000000..97c3814 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/rmxfguid.rs @@ -0,0 +1,67 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{TID_D3DRMInfo, + 0x2b957100, 0x9e9a, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{TID_D3DRMMesh, + 0x3d82ab44, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{TID_D3DRMVector, + 0x3d82ab5e, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{TID_D3DRMMeshFace, + 0x3d82ab5f, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{TID_D3DRMMaterial, + 0x3d82ab4d, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{TID_D3DRMMaterialArray, + 0x35ff44e1, 0x6c7c, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMFrame, + 0x3d82ab46, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{TID_D3DRMFrameTransformMatrix, + 0xf6f23f41, 0x7686, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMeshMaterialList, + 0xf6f23f42, 0x7686, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMeshTextureCoords, + 0xf6f23f40, 0x7686, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMeshNormals, + 0xf6f23f43, 0x7686, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMCoords2d, + 0xf6f23f44, 0x7686, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMatrix4x4, + 0xf6f23f45, 0x7686, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMAnimation, + 0x3d82ab4f, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{TID_D3DRMAnimationSet, + 0x3d82ab50, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} +DEFINE_GUID!{TID_D3DRMAnimationKey, + 0x10dd46a8, 0x775b, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMFloatKeys, + 0x10dd46a9, 0x775b, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMaterialAmbientColor, + 0x01411840, 0x7786, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMaterialDiffuseColor, + 0x01411841, 0x7786, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMaterialSpecularColor, + 0x01411842, 0x7786, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMaterialEmissiveColor, + 0xd3e16e80, 0x7835, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMaterialPower, + 0x01411843, 0x7786, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMColorRGBA, + 0x35ff44e0, 0x6c7c, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMColorRGB, + 0xd3e16e81, 0x7835, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMGuid, + 0xa42790e0, 0x7810, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMTextureFilename, + 0xa42790e1, 0x7810, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMTextureReference, + 0xa42790e2, 0x7810, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMIndexedColor, + 0x1630b820, 0x7842, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMeshVertexColors, + 0x1630b821, 0x7842, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMMaterialWrap, + 0x4885ae60, 0x78e8, 0x11cf, 0x8f, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xa3} +DEFINE_GUID!{TID_D3DRMBoolean, + 0x537da6a0, 0xca37, 0x11d0, 0x94, 0x1c, 0x00, 0x80, 0xc8, 0x0c, 0xfa, 0x7b} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sapi.rs new file mode 100644 index 0000000..2a2cf37 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sapi.rs @@ -0,0 +1,1388 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! SAPI 5.4 definitions +use shared::guiddef::GUID; +use shared::minwindef::{BYTE, ULONG, WORD}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPWSTR, ULONGLONG}; +pub use um::sapi53::{ + SPDATAKEYLOCATION, + SPDKL_DefaultLocation, + SPDKL_CurrentUser, + SPDKL_LocalMachine, + SPDKL_CurrentConfig, + SPDUI_EngineProperties, + SPDUI_AddRemoveWord, + SPDUI_UserTraining, + SPDUI_MicTraining, + SPDUI_RecoProfileProperties, + SPDUI_AudioProperties, + SPDUI_AudioVolume, + SPDUI_UserEnrollment, + SPDUI_ShareData, + SPDUI_Tutorial, + SPSTREAMFORMAT, + SPSF_Default, + SPSF_NoAssignedFormat, + SPSF_Text, + SPSF_NonStandardFormat, + SPSF_ExtendedAudioFormat, + SPSF_8kHz8BitMono, + SPSF_8kHz8BitStereo, + SPSF_8kHz16BitMono, + SPSF_8kHz16BitStereo, + SPSF_11kHz8BitMono, + SPSF_11kHz8BitStereo, + SPSF_11kHz16BitMono, + SPSF_11kHz16BitStereo, + SPSF_12kHz8BitMono, + SPSF_12kHz8BitStereo, + SPSF_12kHz16BitMono, + SPSF_12kHz16BitStereo, + SPSF_16kHz8BitMono, + SPSF_16kHz8BitStereo, + SPSF_16kHz16BitMono, + SPSF_16kHz16BitStereo, + SPSF_22kHz8BitMono, + SPSF_22kHz8BitStereo, + SPSF_22kHz16BitMono, + SPSF_22kHz16BitStereo, + SPSF_24kHz8BitMono, + SPSF_24kHz8BitStereo, + SPSF_24kHz16BitMono, + SPSF_24kHz16BitStereo, + SPSF_32kHz8BitMono, + SPSF_32kHz8BitStereo, + SPSF_32kHz16BitMono, + SPSF_32kHz16BitStereo, + SPSF_44kHz8BitMono, + SPSF_44kHz8BitStereo, + SPSF_44kHz16BitMono, + SPSF_44kHz16BitStereo, + SPSF_48kHz8BitMono, + SPSF_48kHz8BitStereo, + SPSF_48kHz16BitMono, + SPSF_48kHz16BitStereo, + SPSF_TrueSpeech_8kHz1BitMono, + SPSF_CCITT_ALaw_8kHzMono, + SPSF_CCITT_ALaw_8kHzStereo, + SPSF_CCITT_ALaw_11kHzMono, + SPSF_CCITT_ALaw_11kHzStereo, + SPSF_CCITT_ALaw_22kHzMono, + SPSF_CCITT_ALaw_22kHzStereo, + SPSF_CCITT_ALaw_44kHzMono, + SPSF_CCITT_ALaw_44kHzStereo, + SPSF_CCITT_uLaw_8kHzMono, + SPSF_CCITT_uLaw_8kHzStereo, + SPSF_CCITT_uLaw_11kHzMono, + SPSF_CCITT_uLaw_11kHzStereo, + SPSF_CCITT_uLaw_22kHzMono, + SPSF_CCITT_uLaw_22kHzStereo, + SPSF_CCITT_uLaw_44kHzMono, + SPSF_CCITT_uLaw_44kHzStereo, + SPSF_ADPCM_8kHzMono, + SPSF_ADPCM_8kHzStereo, + SPSF_ADPCM_11kHzMono, + SPSF_ADPCM_11kHzStereo, + SPSF_ADPCM_22kHzMono, + SPSF_ADPCM_22kHzStereo, + SPSF_ADPCM_44kHzMono, + SPSF_ADPCM_44kHzStereo, + SPSF_GSM610_8kHzMono, + SPSF_GSM610_11kHzMono, + SPSF_GSM610_22kHzMono, + SPSF_GSM610_44kHzMono, + SPSF_NUM_FORMATS, + SPDFID_Text, + SPDFID_WaveFormatEx, + SPREG_USER_ROOT, + SPREG_LOCAL_MACHINE_ROOT, + SPCAT_AUDIOOUT, + SPCAT_AUDIOIN, + SPCAT_VOICES, + SPCAT_RECOGNIZERS, + SPCAT_APPLEXICONS, + SPCAT_PHONECONVERTERS, + SPCAT_TEXTNORMALIZERS, + SPCAT_RECOPROFILES, + SPMMSYS_AUDIO_IN_TOKEN_ID, + SPMMSYS_AUDIO_OUT_TOKEN_ID, + SPCURRENT_USER_LEXICON_TOKEN_ID, + SPTOKENVALUE_CLSID, + SPTOKENKEY_FILES, + SPTOKENKEY_UI, + SPTOKENKEY_ATTRIBUTES, + SPTOKENKEY_RETAINEDAUDIO, + SPTOKENKEY_AUDIO_LATENCY_WARNING, + SPTOKENKEY_AUDIO_LATENCY_TRUNCATE, + SPTOKENKEY_AUDIO_LATENCY_UPDATE_INTERVAL, + SPVOICECATEGORY_TTSRATE, + SPPROP_RESOURCE_USAGE, + SPPROP_HIGH_CONFIDENCE_THRESHOLD, + SPPROP_NORMAL_CONFIDENCE_THRESHOLD, + SPPROP_LOW_CONFIDENCE_THRESHOLD, + SPPROP_RESPONSE_SPEED, + SPPROP_COMPLEX_RESPONSE_SPEED, + SPPROP_ADAPTATION_ON, + SPPROP_PERSISTED_BACKGROUND_ADAPTATION, + SPPROP_PERSISTED_LANGUAGE_MODEL_ADAPTATION, + SPPROP_UX_IS_LISTENING, + SPTOPIC_SPELLING, + SPWILDCARD, + SPDICTATION, + SPREG_SAFE_USER_TOKENS, + SPINFDICTATION, + SP_LOW_CONFIDENCE, + SP_NORMAL_CONFIDENCE, + SP_HIGH_CONFIDENCE, + DEFAULT_WEIGHT, + SP_MAX_WORD_LENGTH, + SP_MAX_PRON_LENGTH, + SP_EMULATE_RESULT, + ISpNotifyCallback, + SPNOTIFYCALLBACK, + ISpNotifySource, ISpNotifySourceVtbl, + ISpNotifySink, ISpNotifySinkVtbl, + ISpNotifyTranslator, ISpNotifyTranslatorVtbl, + ISpDataKey, ISpDataKeyVtbl, + ISpRegDataKey, ISpRegDataKeyVtbl, + ISpObjectTokenCategory, ISpObjectTokenCategoryVtbl, + ISpObjectToken, ISpObjectTokenVtbl, + ISpObjectTokenInit, ISpObjectTokenInitVtbl, + IEnumSpObjectTokens, IEnumSpObjectTokensVtbl, + ISpObjectWithToken, ISpObjectWithTokenVtbl, + ISpResourceManager, ISpResourceManagerVtbl, + SPEVENTLPARAMTYPE, + SPET_LPARAM_IS_UNDEFINED, + SPET_LPARAM_IS_TOKEN, + SPET_LPARAM_IS_OBJECT, + SPET_LPARAM_IS_POINTER, + SPET_LPARAM_IS_STRING, + SPEVENTENUM, + SPEI_UNDEFINED, + SPEI_START_INPUT_STREAM, + SPEI_END_INPUT_STREAM, + SPEI_VOICE_CHANGE, + SPEI_TTS_BOOKMARK, + SPEI_WORD_BOUNDARY, + SPEI_PHONEME, + SPEI_SENTENCE_BOUNDARY, + SPEI_VISEME, + SPEI_TTS_AUDIO_LEVEL, + SPEI_TTS_PRIVATE, + SPEI_MIN_TTS, + SPEI_MAX_TTS, + SPEI_END_SR_STREAM, + SPEI_SOUND_START, + SPEI_SOUND_END, + SPEI_PHRASE_START, + SPEI_RECOGNITION, + SPEI_HYPOTHESIS, + SPEI_SR_BOOKMARK, + SPEI_PROPERTY_NUM_CHANGE, + SPEI_PROPERTY_STRING_CHANGE, + SPEI_FALSE_RECOGNITION, + SPEI_INTERFERENCE, + SPEI_REQUEST_UI, + SPEI_RECO_STATE_CHANGE, + SPEI_ADAPTATION, + SPEI_START_SR_STREAM, + SPEI_RECO_OTHER_CONTEXT, + SPEI_SR_AUDIO_LEVEL, + SPEI_SR_RETAINEDAUDIO, + SPEI_SR_PRIVATE, +}; +pub const ACTIVE_CATEGORY_CHANGED: SPEVENTENUM = 53; +pub use um::sapi53::{ + SPEI_RESERVED5, + SPEI_RESERVED6, + SPEI_MIN_SR, + SPEI_MAX_SR, + SPEI_RESERVED1, + SPEI_RESERVED2, + SPEI_RESERVED3, + SPFEI_FLAGCHECK, + SPFEI_ALL_TTS_EVENTS, + SPFEI_ALL_SR_EVENTS, + SPFEI_ALL_EVENTS, + SPFEI, + SPEVENT, + SPSERIALIZEDEVENT, + SPSERIALIZEDEVENT64, + SPEVENTEX, + SPINTERFERENCE, + SPINTERFERENCE_NONE, + SPINTERFERENCE_NOISE, + SPINTERFERENCE_NOSIGNAL, + SPINTERFERENCE_TOOLOUD, + SPINTERFERENCE_TOOQUIET, + SPINTERFERENCE_TOOFAST, + SPINTERFERENCE_TOOSLOW, + SPINTERFERENCE_LATENCY_WARNING, + SPINTERFERENCE_LATENCY_TRUNCATE_BEGIN, + SPINTERFERENCE_LATENCY_TRUNCATE_END, + SPENDSRSTREAMFLAGS, + SPESF_NONE, + SPESF_STREAM_RELEASED, + SPESF_EMULATED, + SPVFEATURE, + SPVFEATURE_STRESSED, + SPVFEATURE_EMPHASIS, + SPVISEMES, + SP_VISEME_0, + SP_VISEME_1, + SP_VISEME_2, + SP_VISEME_3, + SP_VISEME_4, + SP_VISEME_5, + SP_VISEME_6, + SP_VISEME_7, + SP_VISEME_8, + SP_VISEME_9, + SP_VISEME_10, + SP_VISEME_11, + SP_VISEME_12, + SP_VISEME_13, + SP_VISEME_14, + SP_VISEME_15, + SP_VISEME_16, + SP_VISEME_17, + SP_VISEME_18, + SP_VISEME_19, + SP_VISEME_20, + SP_VISEME_21, + SPEVENTSOURCEINFO, + ISpEventSource, ISpEventSourceVtbl, + ISpEventSource2, ISpEventSource2Vtbl, + ISpEventSink, ISpEventSinkVtbl, + ISpStreamFormat, ISpStreamFormatVtbl, + SPFILEMODE, + SPFM_OPEN_READONLY, + SPFM_OPEN_READWRITE, + SPFM_CREATE, + SPFM_CREATE_ALWAYS, + SPFM_NUM_MODES, + ISpStream, ISpStreamVtbl, + ISpStreamFormatConverter, ISpStreamFormatConverterVtbl, + SPAUDIOSTATE, + SPAS_CLOSED, + SPAS_STOP, + SPAS_PAUSE, + SPAS_RUN, + SPAUDIOSTATUS, + SPAUDIOBUFFERINFO, + ISpAudio, ISpAudioVtbl, + ISpMMSysAudio, ISpMMSysAudioVtbl, + ISpTranscript, ISpTranscriptVtbl, + SPDISPLAYATTRIBUTES, + SPAF_ONE_TRAILING_SPACE, + SPAF_TWO_TRAILING_SPACES, + SPAF_CONSUME_LEADING_SPACES, + SPAF_BUFFER_POSITION, + SPAF_ALL, + SPAF_USER_SPECIFIED, + SPPHONEID, + PSPPHONEID, + PCSPPHONEID, + SPPHRASEELEMENT, + SPPHRASERULE, + SPPHRASEPROPERTYUNIONTYPE, + SPPPUT_UNUSED, + SPPPUT_ARRAY_INDEX, + SPPHRASEPROPERTY, + SPPHRASEREPLACEMENT, + SPSEMANTICERRORINFO, + SPSEMANTICFORMAT, + SPPHRASE_50, +// SPPHRASESIZE_500, +}; +pub use um::sapi53::SPPHRASE as SPPHRASE_53; +STRUCT!{struct SPPHRASE { + cbSize: ULONG, + LangID: WORD, + wHomophoneGroupId: WORD, + ullGrammarID: ULONGLONG, + ftStartTime: ULONGLONG, + ullAudioStreamPosition: ULONGLONG, + ulAudioSizeBytes: ULONG, + ulRetainedSizeBytes: ULONG, + ulAudioSizeTime: ULONG, + Rule: SPPHRASERULE, + pProperties: *const SPPHRASEPROPERTY, + pElements: *const SPPHRASEELEMENT, + cReplacements: ULONG, + pReplacements: *const SPPHRASEREPLACEMENT, + SREngineID: GUID, + ulSREnginePrivateDataSize: ULONG, + pSREnginePrivateData: *const BYTE, + pSML: LPWSTR, + pSemanticErrorInfo: *mut SPSEMANTICERRORINFO, + SemanticTagFormat: SPSEMANTICFORMAT, +}} +pub use um::sapi53::{ + SPSERIALIZEDPHRASE, + SPRULE, + SPVALUETYPE, + SPDF_PROPERTY, + SPDF_REPLACEMENT, + SPDF_RULE, + SPDF_DISPLAYTEXT, + SPDF_LEXICALFORM , + SPDF_PRONUNCIATION, + SPDF_AUDIO, + SPDF_ALTERNATES, + SPDF_ALL, + SPBINARYGRAMMAR, + SPPHRASERNG, + SPPR_ALL_ELEMENTS, + SP_GETWHOLEPHRASE, + SPRR_ALL_ELEMENTS, + SPSTATEHANDLE, + SPRECOEVENTFLAGS, + SPREF_AutoPause, + SPREF_Emulated, + SPREF_SMLTimeout, + SPREF_ExtendableParse, + SPREF_ReSent, + SPREF_Hypothesis, + SPREF_FalseRecognition, + SPPARTOFSPEECH, + SPPS_NotOverriden, + SPPS_Unknown, + SPPS_Noun, + SPPS_Verb, + SPPS_Modifier, + SPPS_Function, + SPPS_Interjection, + SPPS_Noncontent, + SPPS_LMA, + SPPS_SuppressWord, + SPLEXICONTYPE, + eLEXTYPE_USER, + eLEXTYPE_APP, + eLEXTYPE_VENDORLEXICON, + eLEXTYPE_LETTERTOSOUND, + eLEXTYPE_MORPHOLOGY, + eLEXTYPE_RESERVED4, + eLEXTYPE_USER_SHORTCUT, + eLEXTYPE_RESERVED6, + eLEXTYPE_RESERVED7, + eLEXTYPE_RESERVED8, + eLEXTYPE_RESERVED9, + eLEXTYPE_RESERVED10, + eLEXTYPE_PRIVATE1, + eLEXTYPE_PRIVATE2, + eLEXTYPE_PRIVATE3, + eLEXTYPE_PRIVATE4, + eLEXTYPE_PRIVATE5, + eLEXTYPE_PRIVATE6, + eLEXTYPE_PRIVATE7, + eLEXTYPE_PRIVATE8, + eLEXTYPE_PRIVATE9, + eLEXTYPE_PRIVATE10, + eLEXTYPE_PRIVATE11, + eLEXTYPE_PRIVATE12, + eLEXTYPE_PRIVATE13, + eLEXTYPE_PRIVATE14, + eLEXTYPE_PRIVATE15, + eLEXTYPE_PRIVATE16, + eLEXTYPE_PRIVATE17, + eLEXTYPE_PRIVATE18, + eLEXTYPE_PRIVATE19, + eLEXTYPE_PRIVATE20, + SPWORDTYPE, + eWORDTYPE_ADDED, + eWORDTYPE_DELETED, + SPPRONUNCIATIONFLAGS, + ePRONFLAG_USED, + SPWORDPRONUNCIATION, + SPWORDPRONUNCIATIONLIST, + SPWORD, + SPWORDLIST, + ISpLexicon, ISpLexiconVtbl, + ISpContainerLexicon, ISpContainerLexiconVtbl, + SPSHORTCUTTYPE, + SPSHT_NotOverriden, + SPSHT_Unknown, + SPSHT_EMAIL, + SPSHT_OTHER, + SPPS_RESERVED1, + SPPS_RESERVED2, + SPPS_RESERVED3, + SPPS_RESERVED4, + SPSHORTCUTPAIR, + SPSHORTCUTPAIRLIST, + ISpShortcut, ISpShortcutVtbl, + ISpPhoneConverter, ISpPhoneConverterVtbl, + ISpPhoneticAlphabetConverter, ISpPhoneticAlphabetConverterVtbl, + ISpPhoneticAlphabetSelection, ISpPhoneticAlphabetSelectionVtbl, + SPVPITCH, + SPVACTIONS, + SPVA_Speak, + SPVA_Silence, + SPVA_Pronounce, + SPVA_Bookmark, + SPVA_SpellOut, + SPVA_Section, + SPVA_ParseUnknownTag, + SPVCONTEXT, + SPVSTATE, + SPRUNSTATE, + SPRS_DONE, + SPRS_IS_SPEAKING, + SPVLIMITS, + SPMIN_VOLUME, + SPMAX_VOLUME, + SPMIN_RATE, + SPMAX_RATE, + SPVPRIORITY, + SPVPRI_NORMAL, + SPVPRI_ALERT, + SPVPRI_OVER, + SPVOICESTATUS, + SPEAKFLAGS, + SPF_DEFAULT, + SPF_ASYNC, + SPF_PURGEBEFORESPEAK, + SPF_IS_FILENAME, + SPF_IS_XML, + SPF_IS_NOT_XML, + SPF_PERSIST_XML, + SPF_NLP_SPEAK_PUNC, + SPF_PARSE_SAPI, + SPF_PARSE_SSML, + SPF_PARSE_AUTODETECT, + SPF_NLP_MASK, + SPF_PARSE_MASK, + SPF_VOICE_MASK, + SPF_UNUSED_FLAGS, + ISpVoice, ISpVoiceVtbl, + ISpPhrase, ISpPhraseVtbl, + ISpPhraseAlt, ISpPhraseAltVtbl, + SPXMLRESULTOPTIONS, + SPXRO_SML, + SPXRO_Alternates_SML, + ISpPhrase2, ISpPhrase2Vtbl, + SPRECORESULTTIMES, + SPSERIALIZEDRESULT, + ISpRecoResult, ISpRecoResultVtbl, + SPCOMMITFLAGS, + SPCF_NONE, + SPCF_ADD_TO_USER_LEXICON, + SPCF_DEFINITE_CORRECTION, + ISpRecoResult2, ISpRecoResult2Vtbl, + ISpXMLRecoResult, ISpXMLRecoResultVtbl, + SPTEXTSELECTIONINFO, + SPWORDPRONOUNCEABLE, + SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE, + SPWP_UNKNOWN_WORD_PRONOUNCEABLE, + SPWP_KNOWN_WORD_PRONOUNCEABLE, + SPGRAMMARSTATE, + SPGS_DISABLED, + SPGS_ENABLED, + SPGS_EXCLUSIVE, + SPCONTEXTSTATE, + SPCS_DISABLED, + SPCS_ENABLED, + SPRULESTATE, + SPRS_INACTIVE, + SPRS_ACTIVE, + SPRS_ACTIVE_WITH_AUTO_PAUSE, + SPWT_LEXICAL_NO_SPECIAL_CHARS, + SPPROPERTYINFO, + SPCFGRULEATTRIBUTES, + SPRAF_TopLevel, + SPRAF_Active, + SPRAF_Export, + SPRAF_Import, + SPRAF_Interpreter, + SPRAF_Dynamic, + SPRAF_Root, + SPRAF_AutoPause, + SPRAF_UserDelimited, + ISpGrammarBuilder, ISpGrammarBuilderVtbl, + SPLOADOPTIONS, + SPLO_STATIC, + SPLO_DYNAMIC, + ISpRecoGrammar, ISpRecoGrammarVtbl, + SPMATCHINGMODE, + AllWords, + Subsequence, + OrderedSubset, + SubsequenceContentRequired, + OrderedSubsetContentRequired, + PHONETICALPHABET, + PA_Ipa, + PA_Ups, + PA_Sapi, + ISpGrammarBuilder2, ISpGrammarBuilder2Vtbl, + SPRP_NORMAL, + ISpRecoGrammar2, ISpRecoGrammar2Vtbl, + ISpeechResourceLoader, ISpeechResourceLoaderVtbl, + SPRECOCONTEXTSTATUS, + SPBOOKMARKOPTIONS, + SPBO_NONE, + SPBO_PAUSE, + SPBO_AHEAD, + SPBO_TIME_UNITS, + SPAUDIOOPTIONS, + SPAO_NONE, + SPAO_RETAIN_AUDIO, + ISpRecoContext, ISpRecoContextVtbl, + SPGRAMMAROPTIONS, + SPGO_SAPI, + SPGO_SRGS, + SPGO_UPS, + SPGO_SRGS_MS_SCRIPT, + SPGO_SRGS_W3C_SCRIPT, + SPGO_SRGS_STG_SCRIPT, + SPGO_SRGS_SCRIPT, + SPGO_FILE, + SPGO_HTTP, + SPGO_RES, + SPGO_OBJECT, + SPGO_DEFAULT, + SPGO_ALL, + SPADAPTATIONSETTINGS, + SPADS_Default, + SPADS_CurrentRecognizer, + SPADS_RecoProfile, + SPADS_Immediate, + SPADS_Reset, + SPADS_HighVolumeDataSource, + SPADAPTATIONRELEVANCE, + SPAR_Unknown, + SPAR_Low, + SPAR_Medium, + SPAR_High, + ISpRecoContext2, ISpRecoContext2Vtbl, + ISpProperties, ISpPropertiesVtbl, + SP_MAX_LANGIDS, + SPRECOGNIZERSTATUS, + SPWAVEFORMATTYPE, + SPWF_INPUT, + SPWF_SRENGINE, + SPSTREAMFORMATTYPE, + SPRECOSTATE, + SPRST_INACTIVE, + SPRST_ACTIVE, + SPRST_ACTIVE_ALWAYS, + SPRST_INACTIVE_WITH_PURGE, + SPRST_NUM_STATES, + ISpRecognizer, ISpRecognizerVtbl, + ISpSerializeState, ISpSerializeStateVtbl, + ISpRecognizer2, ISpRecognizer2Vtbl, +}; +ENUM!{enum SPCATEGORYTYPE { + SPCT_COMMAND, + SPCT_DICTATION, + SPCT_SLEEP, + SPCT_SUB_COMMAND, + SPCT_SUB_DICTATION, +}} +RIDL!{#[uuid(0xda0cd0f9, 0x14a2, 0x4f09, 0x8c, 0x2a, 0x85, 0xcc, 0x48, 0x97, 0x93, 0x45)] +interface ISpRecoCategory(ISpRecoCategoryVtbl): IUnknown(IUnknownVtbl) { + fn GetType( + peCategoryType: *mut SPCATEGORYTYPE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdf1b943c, 0x5838, 0x4aa2, 0x87, 0x06, 0xd7, 0xcd, 0x5b, 0x33, 0x34, 0x99)] +interface ISpRecognizer3(ISpRecognizer3Vtbl): IUnknown(IUnknownVtbl) { + fn GetCategory( + categoryType: SPCATEGORYTYPE, + ppCategory: *mut *mut ISpRecoCategory, + ) -> HRESULT, + fn SetActiveCategory( + pCategory: *mut ISpRecoCategory, + ) -> HRESULT, + fn GetActiveCategory( + ppCategory: *mut *mut ISpRecoCategory, + ) -> HRESULT, +}} +pub use um::sapi53::{ + SPNORMALIZATIONLIST, + ISpEnginePronunciation, ISpEnginePronunciationVtbl, + SPDISPLAYTOKEN, + SPDISPLAYPHRASE, + ISpDisplayAlternates, ISpDisplayAlternatesVtbl, + SpeechLanguageId, + DISPID_SpeechDataKey, + DISPID_SDKSetBinaryValue, + DISPID_SDKGetBinaryValue, + DISPID_SDKSetStringValue, + DISPID_SDKGetStringValue, + DISPID_SDKSetLongValue, + DISPID_SDKGetlongValue, + DISPID_SDKOpenKey, + DISPID_SDKCreateKey, + DISPID_SDKDeleteKey, + DISPID_SDKDeleteValue, + DISPID_SDKEnumKeys, + DISPID_SDKEnumValues, + DISPID_SpeechObjectToken, + DISPID_SOTId, + DISPID_SOTDataKey, + DISPID_SOTCategory, + DISPID_SOTGetDescription, + DISPID_SOTSetId, + DISPID_SOTGetAttribute, + DISPID_SOTCreateInstance, + DISPID_SOTRemove, + DISPID_SOTGetStorageFileName, + DISPID_SOTRemoveStorageFileName, + DISPID_SOTIsUISupported, + DISPID_SOTDisplayUI, + DISPID_SOTMatchesAttributes, + SpeechDataKeyLocation, + SDKLDefaultLocation, + SDKLCurrentUser, + SDKLLocalMachine, + SDKLCurrentConfig, + SpeechTokenContext, + STCInprocServer, + STCInprocHandler , + STCLocalServer, + STCRemoteServer, + STCAll, + SpeechTokenShellFolder, + STSF_AppData, + STSF_LocalAppData, + STSF_CommonAppData, + STSF_FlagCreate, + DISPID_SpeechObjectTokens, + DISPID_SOTsCount, + DISPID_SOTsItem, + DISPID_SOTs_NewEnum, + DISPID_SpeechObjectTokenCategory, + DISPID_SOTCId, + DISPID_SOTCDefault, + DISPID_SOTCSetId, + DISPID_SOTCGetDataKey, + DISPID_SOTCEnumerateTokens, + SpeechAudioFormatType, + SAFTDefault, + SAFTNoAssignedFormat, + SAFTText, + SAFTNonStandardFormat, + SAFTExtendedAudioFormat, + SAFT8kHz8BitMono, + SAFT8kHz8BitStereo, + SAFT8kHz16BitMono, + SAFT8kHz16BitStereo, + SAFT11kHz8BitMono, + SAFT11kHz8BitStereo, + SAFT11kHz16BitMono, + SAFT11kHz16BitStereo, + SAFT12kHz8BitMono, + SAFT12kHz8BitStereo, + SAFT12kHz16BitMono, + SAFT12kHz16BitStereo, + SAFT16kHz8BitMono, + SAFT16kHz8BitStereo, + SAFT16kHz16BitMono, + SAFT16kHz16BitStereo, + SAFT22kHz8BitMono, + SAFT22kHz8BitStereo, + SAFT22kHz16BitMono, + SAFT22kHz16BitStereo, + SAFT24kHz8BitMono, + SAFT24kHz8BitStereo, + SAFT24kHz16BitMono, + SAFT24kHz16BitStereo, + SAFT32kHz8BitMono, + SAFT32kHz8BitStereo, + SAFT32kHz16BitMono, + SAFT32kHz16BitStereo, + SAFT44kHz8BitMono, + SAFT44kHz8BitStereo, + SAFT44kHz16BitMono, + SAFT44kHz16BitStereo, + SAFT48kHz8BitMono, + SAFT48kHz8BitStereo, + SAFT48kHz16BitMono, + SAFT48kHz16BitStereo, + SAFTTrueSpeech_8kHz1BitMono, + SAFTCCITT_ALaw_8kHzMono, + SAFTCCITT_ALaw_8kHzStereo, + SAFTCCITT_ALaw_11kHzMono, + SAFTCCITT_ALaw_11kHzStereo, + SAFTCCITT_ALaw_22kHzMono, + SAFTCCITT_ALaw_22kHzStereo, + SAFTCCITT_ALaw_44kHzMono, + SAFTCCITT_ALaw_44kHzStereo, + SAFTCCITT_uLaw_8kHzMono, + SAFTCCITT_uLaw_8kHzStereo, + SAFTCCITT_uLaw_11kHzMono, + SAFTCCITT_uLaw_11kHzStereo, + SAFTCCITT_uLaw_22kHzMono, + SAFTCCITT_uLaw_22kHzStereo, + SAFTCCITT_uLaw_44kHzMono, + SAFTCCITT_uLaw_44kHzStereo, + SAFTADPCM_8kHzMono, + SAFTADPCM_8kHzStereo, + SAFTADPCM_11kHzMono, + SAFTADPCM_11kHzStereo, + SAFTADPCM_22kHzMono, + SAFTADPCM_22kHzStereo, + SAFTADPCM_44kHzMono, + SAFTADPCM_44kHzStereo, + SAFTGSM610_8kHzMono, + SAFTGSM610_11kHzMono, + SAFTGSM610_22kHzMono, + SAFTGSM610_44kHzMono, + DISPID_SpeechAudioFormat, + DISPID_SAFType, + DISPID_SAFGuid, + DISPID_SAFGetWaveFormatEx, + DISPID_SAFSetWaveFormatEx, + DISPID_SpeechBaseStream, + DISPID_SBSFormat, + DISPID_SBSRead, + DISPID_SBSWrite, + DISPID_SBSSeek, + SpeechStreamSeekPositionType, + SSSPTRelativeToStart, + SSSPTRelativeToCurrentPosition, + SSSPTRelativeToEnd, + DISPID_SpeechAudio, + DISPID_SAStatus, + DISPID_SABufferInfo, + DISPID_SADefaultFormat, + DISPID_SAVolume, + DISPID_SABufferNotifySize, + DISPID_SAEventHandle, + DISPID_SASetState, + SpeechAudioState, + SASClosed, + SASStop, + SASPause, + SASRun, + DISPID_SpeechMMSysAudio, + DISPID_SMSADeviceId, + DISPID_SMSALineId, + DISPID_SMSAMMHandle, + DISPID_SpeechFileStream, + DISPID_SFSOpen, + DISPID_SFSClose, + SpeechStreamFileMode, + SSFMOpenForRead, + SSFMOpenReadWrite, + SSFMCreate, + SSFMCreateForWrite, + DISPID_SpeechCustomStream, + DISPID_SCSBaseStream, + DISPID_SpeechMemoryStream, + DISPID_SMSSetData, + DISPID_SMSGetData, + DISPID_SpeechAudioStatus, + DISPID_SASFreeBufferSpace, + DISPID_SASNonBlockingIO, + DISPID_SASState, + DISPID_SASCurrentSeekPosition, + DISPID_SASCurrentDevicePosition, + DISPID_SpeechAudioBufferInfo, + DISPID_SABIMinNotification, + DISPID_SABIBufferSize, + DISPID_SABIEventBias, + DISPID_SpeechWaveFormatEx, + DISPID_SWFEFormatTag, + DISPID_SWFEChannels, + DISPID_SWFESamplesPerSec, + DISPID_SWFEAvgBytesPerSec, + DISPID_SWFEBlockAlign, + DISPID_SWFEBitsPerSample, + DISPID_SWFEExtraData, + DISPID_SpeechVoice, + DISPID_SVStatus, + DISPID_SVVoice, + DISPID_SVAudioOutput, + DISPID_SVAudioOutputStream, + DISPID_SVRate, + DISPID_SVVolume, + DISPID_SVAllowAudioOuputFormatChangesOnNextSet, + DISPID_SVEventInterests, + DISPID_SVPriority, + DISPID_SVAlertBoundary, + DISPID_SVSyncronousSpeakTimeout, + DISPID_SVSpeak, + DISPID_SVSpeakStream, + DISPID_SVPause, + DISPID_SVResume, + DISPID_SVSkip, + DISPID_SVGetVoices, + DISPID_SVGetAudioOutputs, + DISPID_SVWaitUntilDone, + DISPID_SVSpeakCompleteEvent, + DISPID_SVIsUISupported, + DISPID_SVDisplayUI, + SpeechVoicePriority, + SVPNormal, + SVPAlert, + SVPOver, + SpeechVoiceSpeakFlags, + SVSFDefault, + SVSFlagsAsync, + SVSFPurgeBeforeSpeak, + SVSFIsFilename, + SVSFIsXML, + SVSFIsNotXML, + SVSFPersistXML, + SVSFNLPSpeakPunc, + SVSFParseSapi, + SVSFParseSsml, + SVSFParseAutodetect, + SVSFNLPMask, + SVSFParseMask, + SVSFVoiceMask, + SVSFUnusedFlags, + SpeechVoiceEvents, + SVEStartInputStream, + SVEEndInputStream, + SVEVoiceChange, + SVEBookmark, + SVEWordBoundary, + SVEPhoneme, + SVESentenceBoundary, + SVEViseme, + SVEAudioLevel, + SVEPrivate, + SVEAllEvents, + DISPID_SpeechVoiceStatus, + DISPID_SVSCurrentStreamNumber, + DISPID_SVSLastStreamNumberQueued, + DISPID_SVSLastResult, + DISPID_SVSRunningState, + DISPID_SVSInputWordPosition, + DISPID_SVSInputWordLength, + DISPID_SVSInputSentencePosition, + DISPID_SVSInputSentenceLength, + DISPID_SVSLastBookmark, + DISPID_SVSLastBookmarkId, + DISPID_SVSPhonemeId, + DISPID_SVSVisemeId, + SpeechRunState, + SRSEDone, + SRSEIsSpeaking, + SpeechVisemeType, + SVP_0, + SVP_1, + SVP_2, + SVP_3, + SVP_4, + SVP_5, + SVP_6, + SVP_7, + SVP_8, + SVP_9, + SVP_10, + SVP_11, + SVP_12, + SVP_13, + SVP_14, + SVP_15, + SVP_16, + SVP_17, + SVP_18, + SVP_19, + SVP_20, + SVP_21, + SpeechVisemeFeature, + SVF_None, + SVF_Stressed, + SVF_Emphasis, + DISPID_SpeechVoiceEvent, + DISPID_SVEStreamStart, + DISPID_SVEStreamEnd, + DISPID_SVEVoiceChange, + DISPID_SVEBookmark, + DISPID_SVEWord, + DISPID_SVEPhoneme, + DISPID_SVESentenceBoundary, + DISPID_SVEViseme, + DISPID_SVEAudioLevel, + DISPID_SVEEnginePrivate, + DISPID_SpeechRecognizer, + DISPID_SRRecognizer, + DISPID_SRAllowAudioInputFormatChangesOnNextSet, + DISPID_SRAudioInput, + DISPID_SRAudioInputStream, + DISPID_SRIsShared, + DISPID_SRState, + DISPID_SRStatus, + DISPID_SRProfile, + DISPID_SREmulateRecognition, + DISPID_SRCreateRecoContext, + DISPID_SRGetFormat, + DISPID_SRSetPropertyNumber, + DISPID_SRGetPropertyNumber, + DISPID_SRSetPropertyString, + DISPID_SRGetPropertyString, + DISPID_SRIsUISupported, + DISPID_SRDisplayUI, + DISPID_SRGetRecognizers, + DISPID_SVGetAudioInputs, + DISPID_SVGetProfiles, + SpeechRecognizerState, + SRSInactive, + SRSActive, + SRSActiveAlways, + SRSInactiveWithPurge, + SpeechDisplayAttributes, + SDA_No_Trailing_Space, + SDA_One_Trailing_Space, + SDA_Two_Trailing_Spaces, + SDA_Consume_Leading_Spaces, + SpeechFormatType, + SFTInput, + SFTSREngine, + SpeechEmulationCompareFlags, + SECFIgnoreCase, + SECFIgnoreKanaType, + SECFIgnoreWidth, + SECFNoSpecialChars, + SECFEmulateResult, + SECFDefault, + DISPID_SpeechRecognizerStatus, + DISPID_SRSAudioStatus, + DISPID_SRSCurrentStreamPosition, + DISPID_SRSCurrentStreamNumber, + DISPID_SRSNumberOfActiveRules, + DISPID_SRSClsidEngine, + DISPID_SRSSupportedLanguages, + DISPID_SpeechRecoContext, + DISPID_SRCRecognizer, + DISPID_SRCAudioInInterferenceStatus, + DISPID_SRCRequestedUIType, + DISPID_SRCVoice, + DISPID_SRAllowVoiceFormatMatchingOnNextSet, + DISPID_SRCVoicePurgeEvent, + DISPID_SRCEventInterests, + DISPID_SRCCmdMaxAlternates, + DISPID_SRCState, + DISPID_SRCRetainedAudio, + DISPID_SRCRetainedAudioFormat, + DISPID_SRCPause, + DISPID_SRCResume, + DISPID_SRCCreateGrammar, + DISPID_SRCCreateResultFromMemory, + DISPID_SRCBookmark, + DISPID_SRCSetAdaptationData, + SpeechRetainedAudioOptions, + SRAONone, + SRAORetainAudio, + SpeechBookmarkOptions, + SBONone, + SBOPause, + SpeechInterference, + SINone, + SINoise, + SINoSignal, + SITooLoud, + SITooQuiet, + SITooFast, + SITooSlow, + SpeechRecoEvents, + SREStreamEnd, + SRESoundStart, + SRESoundEnd, + SREPhraseStart, + SRERecognition, + SREHypothesis, + SREBookmark, + SREPropertyNumChange, + SREPropertyStringChange, + SREFalseRecognition, + SREInterference, + SRERequestUI, + SREStateChange, + SREAdaptation, + SREStreamStart, + SRERecoOtherContext, + SREAudioLevel, + SREPrivate, + SREAllEvents, + SpeechRecoContextState, + SRCS_Disabled, + SRCS_Enabled, + DISPIDSPRG, + DISPID_SRGId, + DISPID_SRGRecoContext, + DISPID_SRGState, + DISPID_SRGRules, + DISPID_SRGReset, + DISPID_SRGCommit, + DISPID_SRGCmdLoadFromFile, + DISPID_SRGCmdLoadFromObject, + DISPID_SRGCmdLoadFromResource, + DISPID_SRGCmdLoadFromMemory, + DISPID_SRGCmdLoadFromProprietaryGrammar, + DISPID_SRGCmdSetRuleState, + DISPID_SRGCmdSetRuleIdState, + DISPID_SRGDictationLoad, + DISPID_SRGDictationUnload, + DISPID_SRGDictationSetState, + DISPID_SRGSetWordSequenceData, + DISPID_SRGSetTextSelection, + DISPID_SRGIsPronounceable, + SpeechLoadOption, + SLOStatic, + SLODynamic, + SpeechWordPronounceable, + SWPUnknownWordUnpronounceable, + SWPUnknownWordPronounceable, + SWPKnownWordPronounceable, + SpeechGrammarState, + SGSEnabled, + SGSDisabled, + SGSExclusive, + SpeechRuleState, + SGDSInactive, + SGDSActive, + SGDSActiveWithAutoPause, + SGDSActiveUserDelimited, + SpeechRuleAttributes, + SRATopLevel, + SRADefaultToActive, + SRAExport, + SRAImport, + SRAInterpreter, + SRADynamic, + SRARoot, + SpeechGrammarWordType, + SGDisplay, + SGLexical, + SGPronounciation, + SGLexicalNoSpecialChars, + DISPID_SpeechRecoContextEvents, + DISPID_SRCEStartStream, + DISPID_SRCEEndStream, + DISPID_SRCEBookmark, + DISPID_SRCESoundStart, + DISPID_SRCESoundEnd, + DISPID_SRCEPhraseStart, + DISPID_SRCERecognition, + DISPID_SRCEHypothesis, + DISPID_SRCEPropertyNumberChange, + DISPID_SRCEPropertyStringChange, + DISPID_SRCEFalseRecognition, + DISPID_SRCEInterference, + DISPID_SRCERequestUI, + DISPID_SRCERecognizerStateChange, + DISPID_SRCEAdaptation, + DISPID_SRCERecognitionForOtherContext, + DISPID_SRCEAudioLevel, + DISPID_SRCEEnginePrivate, + SpeechRecognitionType, + SRTStandard, + SRTAutopause, + SRTEmulated, + SRTSMLTimeout, + SRTExtendableParse, + SRTReSent, + DISPID_SpeechGrammarRule, + DISPID_SGRAttributes, + DISPID_SGRInitialState, + DISPID_SGRName, + DISPID_SGRId, + DISPID_SGRClear, + DISPID_SGRAddResource, + DISPID_SGRAddState, + DISPID_SpeechGrammarRules, + DISPID_SGRsCount, + DISPID_SGRsDynamic, + DISPID_SGRsAdd, + DISPID_SGRsCommit, + DISPID_SGRsCommitAndSave, + DISPID_SGRsFindRule, + DISPID_SGRsItem, + DISPID_SGRs_NewEnum, + DISPID_SpeechGrammarRuleState, + DISPID_SGRSRule, + DISPID_SGRSTransitions, + DISPID_SGRSAddWordTransition, + DISPID_SGRSAddRuleTransition, + DISPID_SGRSAddSpecialTransition, + SpeechSpecialTransitionType, + SSTTWildcard, + SSTTDictation, + SSTTTextBuffer, + DISPID_SpeechGrammarRuleStateTransitions, + DISPID_SGRSTsCount, + DISPID_SGRSTsItem, + DISPID_SGRSTs_NewEnum, + DISPID_SpeechGrammarRuleStateTransition, + DISPID_SGRSTType, + DISPID_SGRSTText, + DISPID_SGRSTRule, + DISPID_SGRSTWeight, + DISPID_SGRSTPropertyName, + DISPID_SGRSTPropertyId, + DISPID_SGRSTPropertyValue, + DISPID_SGRSTNextState, + SpeechGrammarRuleStateTransitionType, + SGRSTTEpsilon, + SGRSTTWord, + SGRSTTRule, + SGRSTTDictation, + SGRSTTWildcard, + SGRSTTTextBuffer, + DISPIDSPTSI, + DISPIDSPTSI_ActiveOffset, + DISPIDSPTSI_ActiveLength, + DISPIDSPTSI_SelectionOffset, + DISPIDSPTSI_SelectionLength, + DISPID_SpeechRecoResult, + DISPID_SRRRecoContext, + DISPID_SRRTimes, + DISPID_SRRAudioFormat, + DISPID_SRRPhraseInfo, + DISPID_SRRAlternates, + DISPID_SRRAudio, + DISPID_SRRSpeakAudio, + DISPID_SRRSaveToMemory, + DISPID_SRRDiscardResultInfo, + SpeechDiscardType, + SDTProperty, + SDTReplacement, + SDTRule, + SDTDisplayText, + SDTLexicalForm, + SDTPronunciation, + SDTAudio, + SDTAlternates, + SDTAll, + DISPID_SpeechXMLRecoResult, + DISPID_SRRGetXMLResult, + DISPID_SRRGetXMLErrorInfo, + DISPID_SpeechRecoResult2, + DISPID_SRRSetTextFeedback, + DISPID_SpeechPhraseBuilder, + DISPID_SPPBRestorePhraseFromMemory, + DISPID_SpeechRecoResultTimes, + DISPID_SRRTStreamTime, + DISPID_SRRTLength, + DISPID_SRRTTickCount, + DISPID_SRRTOffsetFromStart, + DISPID_SpeechPhraseAlternate, + DISPID_SPARecoResult, + DISPID_SPAStartElementInResult, + DISPID_SPANumberOfElementsInResult, + DISPID_SPAPhraseInfo, + DISPID_SPACommit, + DISPID_SpeechPhraseAlternates, + DISPID_SPAsCount, + DISPID_SPAsItem, + DISPID_SPAs_NewEnum, + DISPID_SpeechPhraseInfo, + DISPID_SPILanguageId, + DISPID_SPIGrammarId, + DISPID_SPIStartTime, + DISPID_SPIAudioStreamPosition, + DISPID_SPIAudioSizeBytes, + DISPID_SPIRetainedSizeBytes, + DISPID_SPIAudioSizeTime, + DISPID_SPIRule, + DISPID_SPIProperties, + DISPID_SPIElements, + DISPID_SPIReplacements, + DISPID_SPIEngineId, + DISPID_SPIEnginePrivateData, + DISPID_SPISaveToMemory, + DISPID_SPIGetText, + DISPID_SPIGetDisplayAttributes, + DISPID_SpeechPhraseElement, + DISPID_SPEAudioTimeOffset, + DISPID_SPEAudioSizeTime, + DISPID_SPEAudioStreamOffset, + DISPID_SPEAudioSizeBytes, + DISPID_SPERetainedStreamOffset, + DISPID_SPERetainedSizeBytes, + DISPID_SPEDisplayText, + DISPID_SPELexicalForm, + DISPID_SPEPronunciation, + DISPID_SPEDisplayAttributes, + DISPID_SPERequiredConfidence, + DISPID_SPEActualConfidence, + DISPID_SPEEngineConfidence, + SpeechEngineConfidence, + SECLowConfidence, + SECNormalConfidence, + SECHighConfidence, + DISPID_SpeechPhraseElements, + DISPID_SPEsCount, + DISPID_SPEsItem, + DISPID_SPEs_NewEnum, + DISPID_SpeechPhraseReplacement, + DISPID_SPRDisplayAttributes, + DISPID_SPRText, + DISPID_SPRFirstElement, + DISPID_SPRNumberOfElements, + DISPID_SpeechPhraseReplacements, + DISPID_SPRsCount, + DISPID_SPRsItem, + DISPID_SPRs_NewEnum, + DISPID_SpeechPhraseProperty, + DISPID_SPPName, + DISPID_SPPId, + DISPID_SPPValue, + DISPID_SPPFirstElement, + DISPID_SPPNumberOfElements, + DISPID_SPPEngineConfidence, + DISPID_SPPConfidence, + DISPID_SPPParent, + DISPID_SPPChildren, + DISPID_SpeechPhraseProperties, + DISPID_SPPsCount, + DISPID_SPPsItem, + DISPID_SPPs_NewEnum, + DISPID_SpeechPhraseRule, + DISPID_SPRuleName, + DISPID_SPRuleId, + DISPID_SPRuleFirstElement, + DISPID_SPRuleNumberOfElements, + DISPID_SPRuleParent, + DISPID_SPRuleChildren, + DISPID_SPRuleConfidence, + DISPID_SPRuleEngineConfidence, + DISPID_SpeechPhraseRules, + DISPID_SPRulesCount, + DISPID_SPRulesItem, + DISPID_SPRules_NewEnum, + DISPID_SpeechLexicon, + DISPID_SLGenerationId, + DISPID_SLGetWords, + DISPID_SLAddPronunciation, + DISPID_SLAddPronunciationByPhoneIds, + DISPID_SLRemovePronunciation, + DISPID_SLRemovePronunciationByPhoneIds, + DISPID_SLGetPronunciations, + DISPID_SLGetGenerationChange, + SpeechLexiconType, + SLTUser, + SLTApp, + SpeechPartOfSpeech, + SPSNotOverriden, + SPSUnknown, + SPSNoun, + SPSVerb, + SPSModifier, + SPSFunction, + SPSInterjection, + SPSLMA, + SPSSuppressWord, + DISPID_SpeechLexiconWords, + DISPID_SLWsCount, + DISPID_SLWsItem, + DISPID_SLWs_NewEnum, + SpeechWordType, + SWTAdded, + SWTDeleted, + DISPID_SpeechLexiconWord, + DISPID_SLWLangId, + DISPID_SLWType, + DISPID_SLWWord, + DISPID_SLWPronunciations, + DISPID_SpeechLexiconProns, + DISPID_SLPsCount, + DISPID_SLPsItem, + DISPID_SLPs_NewEnum, + DISPID_SpeechLexiconPronunciation, + DISPID_SLPType, + DISPID_SLPLangId, + DISPID_SLPPartOfSpeech, + DISPID_SLPPhoneIds, + DISPID_SLPSymbolic, + DISPID_SpeechPhoneConverter, + DISPID_SPCLangId, + DISPID_SPCPhoneToId, + DISPID_SPCIdToPhone, + LIBID_SpeechLib, + ISpeechDataKey, ISpeechDataKeyVtbl, + ISpeechObjectToken, ISpeechObjectTokenVtbl, + ISpeechObjectTokens, ISpeechObjectTokensVtbl, + ISpeechObjectTokenCategory, ISpeechObjectTokenCategoryVtbl, + ISpeechAudioBufferInfo, ISpeechAudioBufferInfoVtbl, + ISpeechAudioStatus, ISpeechAudioStatusVtbl, + ISpeechAudioFormat, ISpeechAudioFormatVtbl, + ISpeechWaveFormatEx, ISpeechWaveFormatExVtbl, + ISpeechBaseStream, ISpeechBaseStreamVtbl, + ISpeechFileStream, ISpeechFileStreamVtbl, + ISpeechMemoryStream, ISpeechMemoryStreamVtbl, + ISpeechCustomStream, ISpeechCustomStreamVtbl, + ISpeechAudio, ISpeechAudioVtbl, + ISpeechMMSysAudio, ISpeechMMSysAudioVtbl, + ISpeechVoice, ISpeechVoiceVtbl, + ISpeechVoiceStatus, ISpeechVoiceStatusVtbl, + _ISpeechVoiceEvents, _ISpeechVoiceEventsVtbl, + ISpeechRecognizer, ISpeechRecognizerVtbl, + ISpeechRecognizerStatus, ISpeechRecognizerStatusVtbl, + ISpeechRecoContext, ISpeechRecoContextVtbl, + ISpeechRecoGrammar, ISpeechRecoGrammarVtbl, + _ISpeechRecoContextEvents, _ISpeechRecoContextEventsVtbl, + ISpeechGrammarRule, ISpeechGrammarRuleVtbl, + ISpeechGrammarRules, ISpeechGrammarRulesVtbl, + ISpeechGrammarRuleState, ISpeechGrammarRuleStateVtbl, + ISpeechGrammarRuleStateTransition, ISpeechGrammarRuleStateTransitionVtbl, + ISpeechGrammarRuleStateTransitions, ISpeechGrammarRuleStateTransitionsVtbl, + ISpeechTextSelectionInformation, ISpeechTextSelectionInformationVtbl, + ISpeechRecoResult, ISpeechRecoResultVtbl, + ISpeechRecoResult2, ISpeechRecoResult2Vtbl, + ISpeechRecoResultTimes, ISpeechRecoResultTimesVtbl, + ISpeechPhraseAlternate, ISpeechPhraseAlternateVtbl, + ISpeechPhraseAlternates, ISpeechPhraseAlternatesVtbl, + ISpeechPhraseInfo, ISpeechPhraseInfoVtbl, + ISpeechPhraseElement, ISpeechPhraseElementVtbl, + ISpeechPhraseElements, ISpeechPhraseElementsVtbl, + ISpeechPhraseReplacement, ISpeechPhraseReplacementVtbl, + ISpeechPhraseReplacements, ISpeechPhraseReplacementsVtbl, + ISpeechPhraseProperty, ISpeechPhrasePropertyVtbl, + ISpeechPhraseProperties, ISpeechPhrasePropertiesVtbl, + ISpeechPhraseRule, ISpeechPhraseRuleVtbl, + ISpeechPhraseRules, ISpeechPhraseRulesVtbl, + ISpeechLexicon, ISpeechLexiconVtbl, + ISpeechLexiconWords, ISpeechLexiconWordsVtbl, + ISpeechLexiconWord, ISpeechLexiconWordVtbl, + ISpeechLexiconPronunciations, ISpeechLexiconPronunciationsVtbl, + ISpeechLexiconPronunciation, ISpeechLexiconPronunciationVtbl, + Speech_Default_Weight, + Speech_Max_Word_Length, + Speech_Max_Pron_Length, + Speech_StreamPos_Asap, + Speech_StreamPos_RealTime, + SpeechAllElements, + ISpeechXMLRecoResult, ISpeechXMLRecoResultVtbl, + ISpeechRecoResultDispatch, ISpeechRecoResultDispatchVtbl, + ISpeechPhraseInfoBuilder, ISpeechPhraseInfoBuilderVtbl, + ISpeechPhoneConverter, ISpeechPhoneConverterVtbl, + CLSID_SpNotifyTranslator, + CLSID_SpObjectTokenCategory, + CLSID_SpObjectToken, + CLSID_SpResourceManager, + CLSID_SpStreamFormatConverter, + CLSID_SpMMAudioEnum, + CLSID_SpMMAudioIn, + CLSID_SpMMAudioOut, + CLSID_SpStream, + CLSID_SpVoice, + CLSID_SpSharedRecoContext, + CLSID_SpInprocRecognizer, + CLSID_SpSharedRecognizer, + CLSID_SpLexicon, + CLSID_SpUnCompressedLexicon, + CLSID_SpCompressedLexicon, + CLSID_SpShortcut, + CLSID_SpPhoneConverter, + CLSID_SpPhoneticAlphabetConverter, + CLSID_SpNullPhoneConverter, + CLSID_SpTextSelectionInformation, + CLSID_SpPhraseInfoBuilder, + CLSID_SpAudioFormat, + CLSID_SpWaveFormatEx, + CLSID_SpInProcRecoContext, + CLSID_SpCustomStream, + CLSID_SpFileStream, + CLSID_SpMemoryStream, +}; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sapi51.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sapi51.rs new file mode 100644 index 0000000..db1d464 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sapi51.rs @@ -0,0 +1,3726 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! SAPI 5.1 definitions +use ctypes::{c_char, c_float, c_long, c_short, c_ushort, c_void}; +use shared::guiddef::{CLSID, GUID, IID, REFCLSID, REFGUID, REFIID}; +use shared::minwindef::{ + BOOL, BYTE, DWORD, FILETIME, HKEY, HMODULE, LPARAM, UINT, ULONG, USHORT, WORD, WPARAM +}; +use shared::mmreg::WAVEFORMATEX; +use shared::rpcndr::byte; +use shared::windef::HWND; +use shared::wtypes::{BSTR, VARIANT_BOOL}; +use shared::wtypesbase::{ + CLSCTX_INPROC_HANDLER, CLSCTX_INPROC_SERVER, CLSCTX_LOCAL_SERVER, CLSCTX_REMOTE_SERVER +}; +use um::oaidl::{DISPID_NEWENUM, DISPID_VALUE, IDispatch, IDispatchVtbl, VARIANT}; +use um::objidlbase::{IStream, IStreamVtbl, STREAM_SEEK_CUR, STREAM_SEEK_END, STREAM_SEEK_SET}; +use um::servprov::{IServiceProvider, IServiceProviderVtbl}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, LONG, LONGLONG, LPCWSTR, LPWSTR, ULONGLONG, WCHAR}; +ENUM!{enum SPDATAKEYLOCATION { + SPDKL_DefaultLocation = 0, + SPDKL_CurrentUser = 1, + SPDKL_LocalMachine = 2, + SPDKL_CurrentConfig = 5, +}} +pub const SPDUI_EngineProperties: &'static str = "EngineProperties"; +pub const SPDUI_AddRemoveWord: &'static str = "AddRemoveWord"; +pub const SPDUI_UserTraining: &'static str = "UserTraining"; +pub const SPDUI_MicTraining: &'static str = "MicTraining"; +pub const SPDUI_RecoProfileProperties: &'static str = "RecoProfileProperties"; +pub const SPDUI_AudioProperties: &'static str = "AudioProperties"; +pub const SPDUI_AudioVolume: &'static str = "AudioVolume"; +pub const SPDUI_UserEnrollment: &'static str = "UserEnrollment"; +pub const SPDUI_ShareData: &'static str = "ShareData"; +pub const SPDUI_Tutorial: &'static str = "Tutorial"; +ENUM!{enum SPSTREAMFORMAT { + SPSF_Default = -1i32 as u32, + SPSF_NoAssignedFormat = 0, + SPSF_Text = 1, + SPSF_NonStandardFormat = 2, + SPSF_ExtendedAudioFormat = 3, + SPSF_8kHz8BitMono = 4, + SPSF_8kHz8BitStereo = 5, + SPSF_8kHz16BitMono = 6, + SPSF_8kHz16BitStereo = 7, + SPSF_11kHz8BitMono = 8, + SPSF_11kHz8BitStereo = 9, + SPSF_11kHz16BitMono = 10, + SPSF_11kHz16BitStereo = 11, + SPSF_12kHz8BitMono = 12, + SPSF_12kHz8BitStereo = 13, + SPSF_12kHz16BitMono = 14, + SPSF_12kHz16BitStereo = 15, + SPSF_16kHz8BitMono = 16, + SPSF_16kHz8BitStereo = 17, + SPSF_16kHz16BitMono = 18, + SPSF_16kHz16BitStereo = 19, + SPSF_22kHz8BitMono = 20, + SPSF_22kHz8BitStereo = 21, + SPSF_22kHz16BitMono = 22, + SPSF_22kHz16BitStereo = 23, + SPSF_24kHz8BitMono = 24, + SPSF_24kHz8BitStereo = 25, + SPSF_24kHz16BitMono = 26, + SPSF_24kHz16BitStereo = 27, + SPSF_32kHz8BitMono = 28, + SPSF_32kHz8BitStereo = 29, + SPSF_32kHz16BitMono = 30, + SPSF_32kHz16BitStereo = 31, + SPSF_44kHz8BitMono = 32, + SPSF_44kHz8BitStereo = 33, + SPSF_44kHz16BitMono = 34, + SPSF_44kHz16BitStereo = 35, + SPSF_48kHz8BitMono = 36, + SPSF_48kHz8BitStereo = 37, + SPSF_48kHz16BitMono = 38, + SPSF_48kHz16BitStereo = 39, + SPSF_TrueSpeech_8kHz1BitMono = 40, + SPSF_CCITT_ALaw_8kHzMono = 41, + SPSF_CCITT_ALaw_8kHzStereo = 42, + SPSF_CCITT_ALaw_11kHzMono = 43, + SPSF_CCITT_ALaw_11kHzStereo = 44, + SPSF_CCITT_ALaw_22kHzMono = 45, + SPSF_CCITT_ALaw_22kHzStereo = 46, + SPSF_CCITT_ALaw_44kHzMono = 47, + SPSF_CCITT_ALaw_44kHzStereo = 48, + SPSF_CCITT_uLaw_8kHzMono = 49, + SPSF_CCITT_uLaw_8kHzStereo = 50, + SPSF_CCITT_uLaw_11kHzMono = 51, + SPSF_CCITT_uLaw_11kHzStereo = 52, + SPSF_CCITT_uLaw_22kHzMono = 53, + SPSF_CCITT_uLaw_22kHzStereo = 54, + SPSF_CCITT_uLaw_44kHzMono = 55, + SPSF_CCITT_uLaw_44kHzStereo = 56, + SPSF_ADPCM_8kHzMono = 57, + SPSF_ADPCM_8kHzStereo = 58, + SPSF_ADPCM_11kHzMono = 59, + SPSF_ADPCM_11kHzStereo = 60, + SPSF_ADPCM_22kHzMono = 61, + SPSF_ADPCM_22kHzStereo = 62, + SPSF_ADPCM_44kHzMono = 63, + SPSF_ADPCM_44kHzStereo = 64, + SPSF_GSM610_8kHzMono = 65, + SPSF_GSM610_11kHzMono = 66, + SPSF_GSM610_22kHzMono = 67, + SPSF_GSM610_44kHzMono = 68, + SPSF_NUM_FORMATS = 69, +}} +extern { + pub static SPDFID_Text: GUID; + pub static SPDFID_WaveFormatEx: GUID; +} +pub const SPREG_USER_ROOT: &'static str = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech"; +pub const SPREG_LOCAL_MACHINE_ROOT: &'static str + = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech"; +pub const SPCAT_AUDIOOUT: &'static str + = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\AudioOutput"; +pub const SPCAT_AUDIOIN: &'static str + = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\AudioInput"; +pub const SPCAT_VOICES: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Voices"; +pub const SPCAT_RECOGNIZERS: &'static str + = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Recognizers"; +pub const SPCAT_APPLEXICONS: &'static str + = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\AppLexicons"; +pub const SPCAT_PHONECONVERTERS: &'static str + = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\PhoneConverters"; +pub const SPCAT_TEXTNORMALIZERS: &'static str + = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\TextNormalizers"; +pub const SPCAT_RECOPROFILES: &'static str + = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech\\RecoProfiles"; +pub const SPMMSYS_AUDIO_IN_TOKEN_ID: &'static str + = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\AudioInput\\TokenEnums\\MMAudioIn\\"; +pub const SPMMSYS_AUDIO_OUT_TOKEN_ID: &'static str + = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\AudioOutput\\TokenEnums\\MMAudioOut\\"; +pub const SPCURRENT_USER_LEXICON_TOKEN_ID: &'static str + = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech\\CurrentUserLexicon"; +pub const SPCURRENT_USER_SHORTCUT_TOKEN_ID: &'static str + = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech\\CurrentUserShortcut"; +pub const SPTOKENVALUE_CLSID: &'static str = "CLSID"; +pub const SPTOKENKEY_FILES: &'static str = "Files"; +pub const SPTOKENKEY_UI: &'static str = "UI"; +pub const SPTOKENKEY_ATTRIBUTES: &'static str = "Attributes"; +pub const SPVOICECATEGORY_TTSRATE: &'static str = "DefaultTTSRate"; +pub const SPPROP_RESOURCE_USAGE: &'static str = "ResourceUsage"; +pub const SPPROP_HIGH_CONFIDENCE_THRESHOLD: &'static str = "HighConfidenceThreshold"; +pub const SPPROP_NORMAL_CONFIDENCE_THRESHOLD: &'static str = "NormalConfidenceThreshold"; +pub const SPPROP_LOW_CONFIDENCE_THRESHOLD: &'static str = "LowConfidenceThreshold"; +pub const SPPROP_RESPONSE_SPEED: &'static str = "ResponseSpeed"; +pub const SPPROP_COMPLEX_RESPONSE_SPEED: &'static str = "ComplexResponseSpeed"; +pub const SPPROP_ADAPTATION_ON: &'static str = "AdaptationOn"; +pub const SPPROP_PERSISTED_BACKGROUND_ADAPTATION: &'static str = "PersistedBackgroundAdaptation"; +pub const SPPROP_PERSISTED_LANGUAGE_MODEL_ADAPTATION: &'static str + = "PersistedLanguageModelAdaptation"; +pub const SPPROP_UX_IS_LISTENING: &'static str = "UXIsListening"; +pub const SPTOPIC_SPELLING: &'static str = "Spelling"; +pub const SPWILDCARD: &'static str = "..."; +pub const SPDICTATION: &'static str = "*"; +pub const SPINFDICTATION: &'static str = "*+"; +pub const SP_LOW_CONFIDENCE: c_char = -1; +pub const SP_NORMAL_CONFIDENCE: c_char = 0; +pub const SP_HIGH_CONFIDENCE: c_char = 1; +pub const DEFAULT_WEIGHT: c_float = 1.0; +pub const SP_MAX_WORD_LENGTH: ULONG = 128; +pub const SP_MAX_PRON_LENGTH: ULONG = 384; +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +interface ISpNotifyCallback(ISpNotifyCallbackVtbl) { + fn NotifyCallback( + wParam: WPARAM, + lParam: LPARAM, + ) -> HRESULT, +}} +FN!{stdcall SPNOTIFYCALLBACK( + wParam: WPARAM, + lParam: LPARAM, +) -> ()} +RIDL!{#[uuid(0x5eff4aef, 0x8487, 0x11d2, 0x96, 0x1c, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] +interface ISpNotifySource(ISpNotifySourceVtbl): IUnknown(IUnknownVtbl) { + fn SetNotifySink( + pNotifySink: *mut ISpNotifySink, + ) -> HRESULT, + fn SetNotifyWindowMessage( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> HRESULT, + fn SetNotifyCallbackFunction( + pfnCallback: SPNOTIFYCALLBACK, + wParam: WPARAM, + lParam: LPARAM, + ) -> HRESULT, + fn SetNotifyCallbackInterface( + pSpCallback: *mut ISpNotifyCallback, + wParam: WPARAM, + lParam: LPARAM, + ) -> HRESULT, + fn SetNotifyWin32Event() -> HRESULT, + fn WaitForNotifyEvent( + dwMilliseconds: DWORD, + ) -> HRESULT, + fn GetNotifyEventHandle() -> HANDLE, +}} +RIDL!{#[uuid(0x259684dc, 0x37c3, 0x11d2, 0x96, 0x03, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] +interface ISpNotifySink(ISpNotifySinkVtbl): IUnknown(IUnknownVtbl) { + fn Notify() -> HRESULT, +}} +RIDL!{#[uuid(0xaca16614, 0x5d3d, 0x11d2, 0x96, 0x0e, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] +interface ISpNotifyTranslator(ISpNotifyTranslatorVtbl): ISpNotifySink(ISpNotifySinkVtbl) { + fn InitWindowMessage( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> HRESULT, + fn InitCallback( + pfnCallback: SPNOTIFYCALLBACK, + wParam: WPARAM, + lParam: LPARAM, + ) -> HRESULT, + fn InitSpNotifyCallback( + pSpCallback: *mut ISpNotifyCallback, + wParam: WPARAM, + lParam: LPARAM, + ) -> HRESULT, + fn InitWin32Event( + hEvent: HANDLE, + fCloseHandleOnRelease: BOOL, + ) -> HRESULT, + fn Wait( + dwMilliseconds: DWORD, + ) -> HRESULT, + fn GetEventHandle() -> HANDLE, +}} +RIDL!{#[uuid(0x14056581, 0xe16c, 0x11d2, 0xbb, 0x90, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +interface ISpDataKey(ISpDataKeyVtbl): IUnknown(IUnknownVtbl) { + fn SetData( + pszValueName: LPCWSTR, + cbData: ULONG, + pData: *const BYTE, + ) -> HRESULT, + fn GetData( + pszValueName: LPCWSTR, + pcbData: *mut ULONG, + pData: *mut BYTE, + ) -> HRESULT, + fn SetStringValue( + pszValueName: LPCWSTR, + pszValue: LPCWSTR, + ) -> HRESULT, + fn GetStringValue( + pszValueName: LPCWSTR, + ppszValue: *mut LPWSTR, + ) -> HRESULT, + fn SetDWORD( + pszValueName: LPCWSTR, + dwValue: DWORD, + ) -> HRESULT, + fn GetDWORD( + pszValueName: LPCWSTR, + pdwValue: *mut DWORD, + ) -> HRESULT, + fn OpenKey( + pszSubKeyName: LPCWSTR, + ppSubKey: *mut *mut ISpDataKey, + ) -> HRESULT, + fn CreateKey( + pszSubKey: LPCWSTR, + ppSubKey: *mut *mut ISpDataKey, + ) -> HRESULT, + fn DeleteKey( + pszSubKey: LPCWSTR, + ) -> HRESULT, + fn DeleteValue( + pszValueName: LPCWSTR, + ) -> HRESULT, + fn EnumKeys( + Index: ULONG, + ppszSubKeyName: *mut LPWSTR, + ) -> HRESULT, + fn EnumValues( + Index: ULONG, + ppszValueName: *mut LPWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x92a66e2b, 0xc830, 0x4149, 0x83, 0xdf, 0x6f, 0xc2, 0xba, 0x1e, 0x7a, 0x5b)] +interface ISpRegDataKey(ISpRegDataKeyVtbl): ISpDataKey(ISpDataKeyVtbl) { + fn SetKey( + hkey: HKEY, + fReadOnly: BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2d3d3845, 0x39af, 0x4850, 0xbb, 0xf9, 0x40, 0xb4, 0x97, 0x80, 0x01, 0x1d)] +interface ISpObjectTokenCategory(ISpObjectTokenCategoryVtbl): ISpDataKey(ISpDataKeyVtbl) { + fn SetId( + pszCategoryId: LPCWSTR, + fCreateIfNotExist: BOOL, + ) -> HRESULT, + fn GetId( + ppszCoMemCategoryId: *mut LPWSTR, + ) -> HRESULT, + fn GetDataKey( + spdkl: SPDATAKEYLOCATION, + pppDataKey: *mut *mut ISpDataKey, + ) -> HRESULT, + fn EnumTokens( + pzsReqAttribs: LPCWSTR, + pszOptAttribs: LPCWSTR, + ppEnum: *mut *mut IEnumSpObjectTokens, + ) -> HRESULT, + fn SetDefaultTokenId( + pszTokenId: LPCWSTR, + ) -> HRESULT, + fn GetDefaultTokenId( + ppszCoMemTokenId: *mut LPWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x14056589, 0xe16c, 0x11d2, 0xbb, 0x90, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +interface ISpObjectToken(ISpObjectTokenVtbl): ISpDataKey(ISpDataKeyVtbl) { + fn SetId( + pszCategoryId: LPCWSTR, + pszTokenId: LPCWSTR, + fCreateIfNotExist: BOOL, + ) -> HRESULT, + fn GetId( + ppszCoMemTokenId: *mut LPWSTR, + ) -> HRESULT, + fn GetCategory( + ppTokenCategory: *mut *mut ISpObjectTokenCategory, + ) -> HRESULT, + fn CreateInstance( + pUnkOuter: *mut IUnknown, + dwClsContext: DWORD, + riid: REFIID, + ppvObject: *mut *mut c_void, + ) -> HRESULT, + fn GetStorageFileName( + clsidCaller: REFCLSID, + pszValueName: LPCWSTR, + pszFileNameSpecifier: LPCWSTR, + nFolder: ULONG, + ppszFilePath: *mut LPWSTR, + ) -> HRESULT, + fn RemoveStorageFileName( + pszKeyName: LPCWSTR, + fDeleteFile: BOOL, + ) -> HRESULT, + fn Remove( + pclsidCaller: *const CLSID, + ) -> HRESULT, + fn IsUISupported( + pszTypeOfUI: LPCWSTR, + pvExtraData: *mut c_void, + cbExtraData: ULONG, + punkObject: *mut IUnknown, + pfSupported: *mut BOOL, + ) -> HRESULT, + fn DisplayUI( + hwndParent: HWND, + pszTitle: LPCWSTR, + pszTypeOfUI: LPCWSTR, + pvExtraData: *mut c_void, + cbExtraData: ULONG, + punkObject: *mut IUnknown, + ) -> HRESULT, + fn MatchesAttributes( + pszAttributes: LPCWSTR, + pfMatches: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb8aab0cf, 0x346f, 0x49d8, 0x94, 0x99, 0xc8, 0xb0, 0x3f, 0x16, 0x1d, 0x51)] +interface ISpObjectTokenInit(ISpObjectTokenInitVtbl): ISpObjectToken(ISpObjectTokenVtbl) { + fn InitFromDataKey( + pszCategoryId: LPCWSTR, + pszTokenId: LPCWSTR, + pDataKey: *mut ISpDataKey, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x06b64f9e, 0x7fda, 0x11d2, 0xb4, 0xf2, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] +interface IEnumSpObjectTokens(IEnumSpObjectTokensVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + pelt: *mut *mut ISpObjectToken, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppEnum: *mut *mut IEnumSpObjectTokens, + ) -> HRESULT, + fn Item( + Index: ULONG, + ppToken: *mut *mut ISpObjectToken, + ) -> HRESULT, + fn GetCount( + pCount: *mut ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5b559f40, 0xe952, 0x11d2, 0xbb, 0x91, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +interface ISpObjectWithToken(ISpObjectWithTokenVtbl): IUnknown(IUnknownVtbl) { + fn SetObjectToken( + pToken: *mut ISpObjectToken, + ) -> HRESULT, + fn GetObjectToken( + ppToken: *mut *mut ISpObjectToken, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x93384e18, 0x5014, 0x43d5, 0xad, 0xbb, 0xa7, 0x8e, 0x05, 0x59, 0x26, 0xbd)] +interface ISpResourceManager(ISpResourceManagerVtbl): IServiceProvider(IServiceProviderVtbl) { + fn SetObject( + guidServiceId: REFGUID, + pUnkObject: *mut IUnknown, + ) -> HRESULT, + fn GetObject( + guidServiceId: REFGUID, + ObjectCLSID: REFCLSID, + ObjectIID: REFIID, + fReleaseWhenLastExternalRefReleased: BOOL, + ppObject: *mut *mut c_void, + ) -> HRESULT, +}} +ENUM!{enum SPEVENTLPARAMTYPE { + SPET_LPARAM_IS_UNDEFINED = 0, + SPET_LPARAM_IS_TOKEN, + SPET_LPARAM_IS_OBJECT, + SPET_LPARAM_IS_POINTER, + SPET_LPARAM_IS_STRING, +}} +ENUM!{enum SPEVENTENUM { + SPEI_UNDEFINED = 0, + SPEI_START_INPUT_STREAM = 1, + SPEI_END_INPUT_STREAM = 2, + SPEI_VOICE_CHANGE = 3, + SPEI_TTS_BOOKMARK = 4, + SPEI_WORD_BOUNDARY = 5, + SPEI_PHONEME = 6, + SPEI_SENTENCE_BOUNDARY = 7, + SPEI_VISEME = 8, + SPEI_TTS_AUDIO_LEVEL = 9, + SPEI_TTS_PRIVATE = 15, + SPEI_MIN_TTS = 1, + SPEI_MAX_TTS = 15, + SPEI_END_SR_STREAM = 34, + SPEI_SOUND_START = 35, + SPEI_SOUND_END = 36, + SPEI_PHRASE_START = 37, + SPEI_RECOGNITION = 38, + SPEI_HYPOTHESIS = 39, + SPEI_SR_BOOKMARK = 40, + SPEI_PROPERTY_NUM_CHANGE = 41, + SPEI_PROPERTY_STRING_CHANGE = 42, + SPEI_FALSE_RECOGNITION = 43, + SPEI_INTERFERENCE = 44, + SPEI_REQUEST_UI = 45, + SPEI_RECO_STATE_CHANGE = 46, + SPEI_ADAPTATION = 47, + SPEI_START_SR_STREAM = 48, + SPEI_RECO_OTHER_CONTEXT = 49, + SPEI_SR_AUDIO_LEVEL = 50, + SPEI_SR_PRIVATE = 52, + SPEI_MIN_SR = 34, + SPEI_MAX_SR = 52, + SPEI_RESERVED1 = 30, + SPEI_RESERVED2 = 33, + SPEI_RESERVED3 = 63, +}} +pub const SPFEI_FLAGCHECK: ULONGLONG = (1 << SPEI_RESERVED1) | (1 << SPEI_RESERVED2); +pub const SPFEI_ALL_TTS_EVENTS: ULONGLONG = 0x000000000000FFFE | SPFEI_FLAGCHECK; +pub const SPFEI_ALL_SR_EVENTS: ULONGLONG = 0x003FFFFC00000000 | SPFEI_FLAGCHECK; +pub const SPFEI_ALL_EVENTS: ULONGLONG = 0xEFFFFFFFFFFFFFFF; +#[inline] +pub fn SPFEI( + SPEI_ord: SPEVENTENUM, + ) -> ULONGLONG { + (1 << SPEI_ord) | SPFEI_FLAGCHECK +} +STRUCT!{struct SPEVENT { + bitfields: DWORD, + ulStreamNum: ULONG, + ullAudioStreamOffset: ULONGLONG, + wParam: WPARAM, + lParam: LPARAM, +}} +BITFIELD!{SPEVENT bitfields: SPEVENTENUM [ eEventId set_eEventId[0..16], ]} +BITFIELD!{SPEVENT bitfields: SPEVENTLPARAMTYPE [ elParamType set_elParamType[16..32], ]} +STRUCT!{struct SPSERIALIZEDEVENT { + bitfields: DWORD, + ulStreamNum: ULONG, + ullAudioStreamOffset: ULONGLONG, + SerializedwParam: ULONG, + SerializedlParam: LONG, +}} +BITFIELD!{SPSERIALIZEDEVENT bitfields: SPEVENTENUM [ eEventId set_eEventId[0..16], ]} +BITFIELD!{SPSERIALIZEDEVENT bitfields: SPEVENTLPARAMTYPE [ elParamType set_elParamType[16..32], ]} +STRUCT!{struct SPSERIALIZEDEVENT64 { + bitfields: DWORD, + ulStreamNum: ULONG, + ullAudioStreamOffset: ULONGLONG, + SerializedwParam: ULONGLONG, + SerializedlParam: LONGLONG, +}} +BITFIELD!{SPSERIALIZEDEVENT64 bitfields: SPEVENTENUM [ + eEventId set_eEventId[0..16], +]} +BITFIELD!{SPSERIALIZEDEVENT64 bitfields: SPEVENTLPARAMTYPE [ + elParamType set_elParamType[16..32], +]} +ENUM!{enum SPINTERFERENCE { + SPINTERFERENCE_NONE = 0, + SPINTERFERENCE_NOISE, + SPINTERFERENCE_NOSIGNAL, + SPINTERFERENCE_TOOLOUD, + SPINTERFERENCE_TOOQUIET, + SPINTERFERENCE_TOOFAST, + SPINTERFERENCE_TOOSLOW, + SPINTERFERENCE_LATENCY_WARNING, + SPINTERFERENCE_LATENCY_TRUNCATE_BEGIN , + SPINTERFERENCE_LATENCY_TRUNCATE_END, +}} +ENUM!{enum SPENDSRSTREAMFLAGS { + SPESF_NONE = 0, + SPESF_STREAM_RELEASED = 1 << 0, + SPESF_EMULATED = 1 << 1, +}} +ENUM!{enum SPVFEATURE { + SPVFEATURE_STRESSED = 1 << 0, + SPVFEATURE_EMPHASIS = 1 << 1, +}} +ENUM!{enum SPVISEMES { + SP_VISEME_0 = 0, + SP_VISEME_1, + SP_VISEME_2, + SP_VISEME_3, + SP_VISEME_4, + SP_VISEME_5, + SP_VISEME_6, + SP_VISEME_7, + SP_VISEME_8, + SP_VISEME_9, + SP_VISEME_10, + SP_VISEME_11, + SP_VISEME_12, + SP_VISEME_13, + SP_VISEME_14, + SP_VISEME_15, + SP_VISEME_16, + SP_VISEME_17, + SP_VISEME_18, + SP_VISEME_19, + SP_VISEME_20, + SP_VISEME_21, +}} +STRUCT!{struct SPEVENTSOURCEINFO { + ullEventInterest: ULONGLONG, + ullQueuedInterest: ULONGLONG, + ulCount: ULONG, +}} +RIDL!{#[uuid(0xbe7a9cce, 0x5f9e, 0x11d2, 0x96, 0x0f, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] +interface ISpEventSource(ISpEventSourceVtbl): ISpNotifySource(ISpNotifySourceVtbl) { + fn SetInterest( + ullEventInterest: ULONGLONG, + ullQueuedInterest: ULONGLONG, + ) -> HRESULT, + fn GetEvents( + ulCount: ULONG, + pEventArray: *mut SPEVENT, + pulFetched: *mut ULONG, + ) -> HRESULT, + fn GetInfo( + pInfo: *mut SPEVENTSOURCEINFO, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xbe7a9cc9, 0x5f9e, 0x11d2, 0x96, 0x0f, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] +interface ISpEventSink(ISpEventSinkVtbl): IUnknown(IUnknownVtbl) { + fn AddEvents( + pEventArray: *const SPEVENT, + ulCount: ULONG, + ) -> HRESULT, + fn GetEventInterest( + pullEventInterest: *mut ULONGLONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xbed530be, 0x2606, 0x4f4d, 0xa1, 0xc0, 0x54, 0xc5, 0xcd, 0xa5, 0x56, 0x6f)] +interface ISpStreamFormat(ISpStreamFormatVtbl): IStream(IStreamVtbl) { + fn GetFormat( + pguidFormatId: *mut GUID, + ppCoMemWaveFormatEx: *mut *mut WAVEFORMATEX, + ) -> HRESULT, +}} +ENUM!{enum SPFILEMODE { + SPFM_OPEN_READONLY, + SPFM_OPEN_READWRITE, + SPFM_CREATE, + SPFM_CREATE_ALWAYS, + SPFM_NUM_MODES, +}} +RIDL!{#[uuid(0x12e3cca9, 0x7518, 0x44c5, 0xa5, 0xe7, 0xba, 0x5a, 0x79, 0xcb, 0x92, 0x9e)] +interface ISpStream(ISpStreamVtbl): ISpStreamFormat(ISpStreamFormatVtbl) { + fn SetBaseStream( + pStream: *mut IStream, + rguidFormat: REFGUID, + pWaveFormatEx: *const WAVEFORMATEX, + ) -> HRESULT, + fn GetBaseStream( + ppStream: *mut *mut IStream, + ) -> HRESULT, + fn BindToFile( + pszFileName: LPCWSTR, + eMode: SPFILEMODE, + pFormatId: *const GUID, + pWaveFormatEx: *const WAVEFORMATEX, + ullEventInterest: ULONGLONG, + ) -> HRESULT, + fn Close() -> HRESULT, +}} +RIDL!{#[uuid(0x678a932c, 0xea71, 0x4446, 0x9b, 0x41, 0x78, 0xfd, 0xa6, 0x28, 0x0a, 0x29)] +interface ISpStreamFormatConverter(ISpStreamFormatConverterVtbl): + ISpStreamFormat(ISpStreamFormatVtbl) { + fn SetBaseStream( + pStream: *mut ISpStreamFormat, + fSetFormatToBaseStreamFormat: BOOL, + fWriteToBaseStream: BOOL, + ) -> HRESULT, + fn GetBaseStream( + ppStream: *mut *mut ISpStreamFormat, + ) -> HRESULT, + fn SetFormat( + rguidFormatIdOfConvertedStream: REFGUID, + pWaveFormatExOfConvertedStream: *const WAVEFORMATEX, + ) -> HRESULT, + fn ResetSeekPosition() -> HRESULT, + fn ScaleConvertedToBaseOffset( + ullOffsetConvertedStream: ULONGLONG, + pullOffsetBaseStream: *mut ULONGLONG, + ) -> HRESULT, + fn ScaleBaseToConvertedOffset( + ullOffsetBaseStream: ULONGLONG, + pullOffsetConvertedStream: *mut ULONGLONG, + ) -> HRESULT, +}} +ENUM!{enum SPAUDIOSTATE { + SPAS_CLOSED, + SPAS_STOP, + SPAS_PAUSE, + SPAS_RUN, +}} +STRUCT!{struct SPAUDIOSTATUS { + cbFreeBuffSpace: c_long, + cbNonBlockingIO: ULONG, + State: SPAUDIOSTATE, + CurSeekPos: ULONGLONG, + CurDevicePos: ULONGLONG, + dwAudioLevel: DWORD, + dwReserved2: DWORD, +}} +STRUCT!{struct SPAUDIOBUFFERINFO { + ulMsMinNotification: ULONG, + ulMsBufferSize: ULONG, + ulMsEventBias: ULONG, +}} +RIDL!{#[uuid(0xc05c768f, 0xfae8, 0x4ec2, 0x8e, 0x07, 0x33, 0x83, 0x21, 0xc1, 0x24, 0x52)] +interface ISpAudio(ISpAudioVtbl): ISpStreamFormat(ISpStreamFormatVtbl) { + fn SetState( + NewState: SPAUDIOSTATE, + ullReserved: ULONGLONG, + ) -> HRESULT, + fn SetFormat( + rguidFmtId: REFGUID, + pWaveFormatEx: *const WAVEFORMATEX, + ) -> HRESULT, + fn GetStatus( + pStatus: *mut SPAUDIOSTATUS, + ) -> HRESULT, + fn SetBufferInfo( + pBuffInfo: *const SPAUDIOBUFFERINFO, + ) -> HRESULT, + fn GetBufferInfo( + pBuffInfo: *mut SPAUDIOBUFFERINFO, + ) -> HRESULT, + fn GetDefaultFormat( + pFormatId: *mut GUID, + ppCoMemWaveFormatEx: *mut *mut WAVEFORMATEX, + ) -> HRESULT, + fn EventHandle() -> HANDLE, + fn GetVolumeLevel( + pLevel: *mut ULONG, + ) -> HRESULT, + fn SetVolumeLevel( + Level: ULONG, + ) -> HRESULT, + fn GetBufferNotifySize( + pcbSize: *mut ULONG, + ) -> HRESULT, + fn SetBufferNotifySize( + cbSize: ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x15806f6e, 0x1d70, 0x4b48, 0x98, 0xe6, 0x3b, 0x1a, 0x00, 0x75, 0x09, 0xab)] +interface ISpMMSysAudio(ISpMMSysAudioVtbl): ISpAudio(ISpAudioVtbl) { + fn GetDeviceId( + puDeviceId: *mut UINT, + ) -> HRESULT, + fn SetDeviceId( + uDeviceId: UINT, + ) -> HRESULT, + fn GetMMHandle( + pHandle: *mut *mut c_void, + ) -> HRESULT, + fn GetLineId( + puLineId: *mut UINT, + ) -> HRESULT, + fn SetLineId( + uLineId: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x10f63bce, 0x201a, 0x11d3, 0xac, 0x70, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +interface ISpTranscript(ISpTranscriptVtbl): IUnknown(IUnknownVtbl) { + fn GetTranscript( + ppszTranscript: *mut LPWSTR, + ) -> HRESULT, + fn AppendTranscript( + pszTranscript: LPCWSTR, + ) -> HRESULT, +}} +ENUM!{enum SPDISPLAYATTRIBUTES { + SPAF_ONE_TRAILING_SPACE = 0x2, + SPAF_TWO_TRAILING_SPACES = 0x4, + SPAF_CONSUME_LEADING_SPACES = 0x8, + SPAF_ALL = 0xf, +}} +pub type SPPHONEID = WCHAR; +pub type PSPPHONEID = LPWSTR; +pub type PCSPPHONEID = LPCWSTR; +STRUCT!{struct SPPHRASEELEMENT { + ulAudioTimeOffset: ULONG, + ulAudioSizeTime: ULONG, + ulAudioStreamOffset: ULONG, + ulAudioSizeBytes: ULONG, + ulRetainedStreamOffset: ULONG, + ulRetainedSizeBytes: ULONG, + pszDisplayText: LPCWSTR, + pszLexicalForm: LPCWSTR, + pszPronunciation: *const SPPHONEID, + bDisplayAttributes: BYTE, + RequiredConfidence: c_char, + ActualConfidence: c_char, + Reserved: BYTE, + SREngineConfidence: c_float, +}} +STRUCT!{struct SPPHRASERULE { + pszName: LPCWSTR, + ulId: ULONG, + ulFirstElement: ULONG, + ulCountOfElements: ULONG, + pNextSibling: *const SPPHRASERULE, + pFirstChild: *const SPPHRASERULE, + SREngineConfidence: c_float, + Confidence: c_char, +}} +ENUM!{enum SPPHRASEPROPERTYUNIONTYPE { + SPPPUT_UNUSED = 0, + SPPPUT_ARRAY_INDEX, +}} +STRUCT!{struct SPPHRASEPROPERTY_u_s { + bType: byte, + bReserved: byte, + usArrayIndex: c_ushort, +}} +UNION!{union SPPHRASEPROPERTY_u { + [u32; 1], + ulId ulId_mut: ULONG, + s s_mut: SPPHRASEPROPERTY_u_s, +}} +STRUCT!{struct SPPHRASEPROPERTY { + pszName: LPCWSTR, + u: SPPHRASEPROPERTY_u_s, + pszValue: LPCWSTR, + vValue: VARIANT, + ulFirstElement: ULONG, + ulCountOfElements: ULONG, + pNextSibling: *const SPPHRASEPROPERTY, + pFirstChild: *const SPPHRASEPROPERTY, + SREngineConfidence: c_float, + Confidence: c_char, +}} +STRUCT!{struct SPPHRASEREPLACEMENT { + bDisplayAttributes: BYTE, + pszReplacementText: LPCWSTR, + ulFirstElement: ULONG, + ulCountOfElements: ULONG, +}} +STRUCT!{struct SPPHRASE { + cbSize: ULONG, + LangID: WORD, + wHomophoneGroupId: WORD, + ullGrammarID: ULONGLONG, + ftStartTime: ULONGLONG, + ullAudioStreamPosition: ULONGLONG, + ulAudioSizeBytes: ULONG, + ulRetainedSizeBytes: ULONG, + ulAudioSizeTime: ULONG, + Rule: SPPHRASERULE, + pProperties: *const SPPHRASEPROPERTY, + pElements: *const SPPHRASEELEMENT, + cReplacements: ULONG, + pReplacements: *const SPPHRASEREPLACEMENT, + SREngineID: GUID, + ulSREnginePrivateDataSize: ULONG, + pSREnginePrivateData: *const BYTE, +}} +STRUCT!{struct SPSERIALIZEDPHRASE { + ulSerializedSize: ULONG, +}} +ENUM!{enum SPVALUETYPE { + SPDF_PROPERTY = 0x1, + SPDF_REPLACEMENT = 0x2, + SPDF_RULE = 0x4, + SPDF_DISPLAYTEXT = 0x8, + SPDF_LEXICALFORM = 0x10, + SPDF_PRONUNCIATION = 0x20, + SPDF_AUDIO = 0x40, + SPDF_ALTERNATES = 0x80, + SPDF_ALL = 0xff, +}} +STRUCT!{struct SPBINARYGRAMMAR { + ulTotalSerializedSize: ULONG, +}} +ENUM!{enum SPPHRASERNG { + SPPR_ALL_ELEMENTS = -1i32 as u32, +}} +pub const SP_GETWHOLEPHRASE: SPPHRASERNG = SPPR_ALL_ELEMENTS; +pub const SPRR_ALL_ELEMENTS: SPPHRASERNG = SPPR_ALL_ELEMENTS; +DECLARE_HANDLE!{SPSTATEHANDLE, SPSTATEHANDLE__} +ENUM!{enum SPRECOEVENTFLAGS { + SPREF_AutoPause = 1 << 0, + SPREF_Emulated = 1 << 1, +}} +ENUM!{enum SPPARTOFSPEECH { + SPPS_NotOverriden = -1i32 as u32, + SPPS_Unknown = 0, + SPPS_Noun = 0x1000, + SPPS_Verb = 0x2000, + SPPS_Modifier = 0x3000, + SPPS_Function = 0x4000, + SPPS_Interjection = 0x5000, +}} +ENUM!{enum SPLEXICONTYPE { + eLEXTYPE_USER = 1 << 0, + eLEXTYPE_APP = 1 << 1, + eLEXTYPE_VENDORLEXICON = 1 << 2, + eLEXTYPE_LETTERTOSOUND = 1 << 3, + eLEXTYPE_MORPHOLOGY = 1 << 4, + eLEXTYPE_RESERVED4 = 1 << 5, + eLEXTYPE_USER_SHORTCUT = 1 << 6, + eLEXTYPE_RESERVED6 = 1 << 7, + eLEXTYPE_RESERVED7 = 1 << 8, + eLEXTYPE_RESERVED8 = 1 << 9, + eLEXTYPE_RESERVED9 = 1 << 10, + eLEXTYPE_RESERVED10 = 1 << 11, + eLEXTYPE_PRIVATE1 = 1 << 12, + eLEXTYPE_PRIVATE2 = 1 << 13, + eLEXTYPE_PRIVATE3 = 1 << 14, + eLEXTYPE_PRIVATE4 = 1 << 15, + eLEXTYPE_PRIVATE5 = 1 << 16, + eLEXTYPE_PRIVATE6 = 1 << 17, + eLEXTYPE_PRIVATE7 = 1 << 18, + eLEXTYPE_PRIVATE8 = 1 << 19, + eLEXTYPE_PRIVATE9 = 1 << 20, + eLEXTYPE_PRIVATE10 = 1 << 21, + eLEXTYPE_PRIVATE11 = 1 << 22, + eLEXTYPE_PRIVATE12 = 1 << 23, + eLEXTYPE_PRIVATE13 = 1 << 24, + eLEXTYPE_PRIVATE14 = 1 << 25, + eLEXTYPE_PRIVATE15 = 1 << 26, + eLEXTYPE_PRIVATE16 = 1 << 27, + eLEXTYPE_PRIVATE17 = 1 << 28, + eLEXTYPE_PRIVATE18 = 1 << 29, + eLEXTYPE_PRIVATE19 = 1 << 30, + eLEXTYPE_PRIVATE20 = 1 << 31, +}} +ENUM!{enum SPWORDTYPE { + eWORDTYPE_ADDED = 1 << 0, + eWORDTYPE_DELETED = 1 << 1, +}} +STRUCT!{struct SPWORDPRONUNCIATION { + pNextWordPronunciation: *mut SPWORDPRONUNCIATION, + eLexiconType: SPLEXICONTYPE, + LangID: WORD, + wPronunciationFlags: WORD, + ePartOfSpeech: SPPARTOFSPEECH, + szPronunciation: [SPPHONEID; 1], +}} +STRUCT!{struct SPWORDPRONUNCIATIONLIST { + ulSize: ULONG, + pvBuffer: *mut BYTE, + pFirstWordPronunciation: *mut SPWORDPRONUNCIATION, +}} +STRUCT!{struct SPWORD { + pNextWord: *mut SPWORD, + LangID: WORD, + wReserved: WORD, + eWordType: SPWORDTYPE, + pszWord: LPWSTR, + pFirstWordPronunciation: *mut SPWORDPRONUNCIATION, +}} +STRUCT!{struct SPWORDLIST { + ulSize: ULONG, + pvBuffer: *mut BYTE, + pFirstWord: *mut SPWORD, +}} +RIDL!{#[uuid(0xda41a7c2, 0x5383, 0x4db2, 0x91, 0x6b, 0x6c, 0x17, 0x19, 0xe3, 0xdb, 0x58)] +interface ISpLexicon(ISpLexiconVtbl): IUnknown(IUnknownVtbl) { + fn GetPronunciations( + pszWord: LPCWSTR, + LangID: WORD, + dwFlags: DWORD, + pWordPronunciationList: *mut SPWORDPRONUNCIATIONLIST, + ) -> HRESULT, + fn AddPronunciation( + pszWord: LPCWSTR, + LangID: WORD, + ePartOfSpeech: SPPARTOFSPEECH, + pszPronunciation: PCSPPHONEID, + ) -> HRESULT, + fn RemovePronunciation( + pszWord: LPCWSTR, + LangID: WORD, + ePartOfSpeech: SPPARTOFSPEECH, + pszPronunciation: PCSPPHONEID, + ) -> HRESULT, + fn GetGeneration( + pdwGeneration: *mut DWORD, + ) -> HRESULT, + fn GetGenerationChange( + dwFlags: DWORD, + pdwGeneration: *mut DWORD, + pWordList: *mut SPWORDLIST, + ) -> HRESULT, + fn GetWords( + dwFlags: DWORD, + pdwGeneration: *mut DWORD, + pdwCookie: *mut DWORD, + pWordList: *mut SPWORDLIST, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8565572f, 0xc094, 0x41cc, 0xb5, 0x6e, 0x10, 0xbd, 0x9c, 0x3f, 0xf0, 0x44)] +interface ISpContainerLexicon(ISpContainerLexiconVtbl): ISpLexicon(ISpLexiconVtbl) { + fn AddLexicon( + pAddLexicon: *mut ISpLexicon, + dwFlags: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8445c581, 0x0cac, 0x4a38, 0xab, 0xfe, 0x9b, 0x2c, 0xe2, 0x82, 0x64, 0x55)] +interface ISpPhoneConverter(ISpPhoneConverterVtbl): ISpObjectWithToken(ISpObjectWithTokenVtbl) { + fn PhoneToId( + pszPhone: LPCWSTR, + pId: *mut SPPHONEID, + ) -> HRESULT, + fn IdToPhone( + pId: PCSPPHONEID, + pszPhone: *mut WCHAR, + ) -> HRESULT, +}} +STRUCT!{struct SPVPITCH { + MiddleAdj: c_long, + RangeAdj: c_long, +}} +ENUM!{enum SPVACTIONS { + SPVA_Speak = 0, + SPVA_Silence, + SPVA_Pronounce, + SPVA_Bookmark, + SPVA_SpellOut, + SPVA_Section, + SPVA_ParseUnknownTag, +}} +STRUCT!{struct SPVCONTEXT { + pCategory: LPCWSTR, + pBefore: LPCWSTR, + pAfter: LPCWSTR, +}} +STRUCT!{struct SPVSTATE { + eAction: SPVACTIONS, + LangID: WORD, + wReserved: WORD, + EmphAdj: c_long, + RateAdj: c_long, + Volume: ULONG, + PitchAdj: SPVPITCH, + SilenceMSecs: ULONG, + pPhoneIds: *mut SPPHONEID, + ePartOfSpeech: SPPARTOFSPEECH, + Context: SPVCONTEXT, +}} +ENUM!{enum SPRUNSTATE { + SPRS_DONE = 1 << 0, + SPRS_IS_SPEAKING = 1 << 1, +}} +ENUM!{enum SPVLIMITS { + SPMIN_VOLUME = 0, + SPMAX_VOLUME = 100, + SPMIN_RATE = -10i32 as u32, + SPMAX_RATE = 10, +}} +ENUM!{enum SPVPRIORITY { + SPVPRI_NORMAL = 0, + SPVPRI_ALERT = 1 << 0, + SPVPRI_OVER = 1 << 1, +}} +STRUCT!{struct SPVOICESTATUS { + ulCurrentStream: ULONG, + ulLastStreamQueued: ULONG, + hrLastResult: HRESULT, + dwRunningState: DWORD, + ulInputWordPos: ULONG, + ulInputWordLen: ULONG, + ulInputSentPos: ULONG, + ulInputSentLen: ULONG, + lBookmarkId: LONG, + PhonemeId: SPPHONEID, + VisemeId: SPVISEMES, + dwReserved1: DWORD, + dwReserved2: DWORD, +}} +ENUM!{enum SPEAKFLAGS { + SPF_DEFAULT = 0, + SPF_ASYNC = 1 << 0, + SPF_PURGEBEFORESPEAK = 1 << 1, + SPF_IS_FILENAME = 1 << 2, + SPF_IS_XML = 1 << 3, + SPF_IS_NOT_XML = 1 << 4, + SPF_PERSIST_XML = 1 << 5, + SPF_NLP_SPEAK_PUNC = 1 << 6, + SPF_NLP_MASK = SPF_NLP_SPEAK_PUNC, + SPF_VOICE_MASK = SPF_ASYNC | SPF_PURGEBEFORESPEAK + | SPF_IS_FILENAME | SPF_IS_XML | SPF_IS_NOT_XML + | SPF_NLP_MASK | SPF_PERSIST_XML, + SPF_UNUSED_FLAGS = !SPF_VOICE_MASK, +}} +RIDL!{#[uuid(0x6c44df74, 0x72b9, 0x4992, 0xa1, 0xec, 0xef, 0x99, 0x6e, 0x04, 0x22, 0xd4)] +interface ISpVoice(ISpVoiceVtbl): ISpEventSource(ISpEventSourceVtbl) { + fn SetOutput( + pUnkOutput: *mut IUnknown, + fAllowFormatChanges: BOOL, + ) -> HRESULT, + fn GetOutputObjectToken( + ppObjectToken: *mut *mut ISpObjectToken, + ) -> HRESULT, + fn GetOutputStream( + ppStream: *mut *mut ISpStreamFormat, + ) -> HRESULT, + fn Pause() -> HRESULT, + fn Resume() -> HRESULT, + fn SetVoice( + pToken: *mut ISpObjectToken, + ) -> HRESULT, + fn GetVoice( + ppToken: *mut *mut ISpObjectToken, + ) -> HRESULT, + fn Speak( + pwcs: LPCWSTR, + dwFlags: DWORD, + pulStreamNumber: *mut ULONG, + ) -> HRESULT, + fn SpeakStream( + pStream: *mut IStream, + dwFlags: DWORD, + pulStreamNumber: *mut ULONG, + ) -> HRESULT, + fn GetStatus( + pStatus: *mut SPVOICESTATUS, + ppszLastBookmark: *mut LPWSTR, + ) -> HRESULT, + fn Skip( + pItemType: LPCWSTR, + lNumItems: c_long, + pulNumSkipped: *mut ULONG, + ) -> HRESULT, + fn SetPriority( + ePriority: SPVPRIORITY, + ) -> HRESULT, + fn GetPriority( + pePriority: *mut SPVPRIORITY, + ) -> HRESULT, + fn SetAlertBoundary( + eBoundary: SPEVENTENUM, + ) -> HRESULT, + fn GetAlertBoundary( + peBoundary: *mut SPEVENTENUM, + ) -> HRESULT, + fn SetRate( + RateAdjust: c_long, + ) -> HRESULT, + fn GetRate( + pRateAdjust: *mut c_long, + ) -> HRESULT, + fn SetVolume( + usVolume: USHORT, + ) -> HRESULT, + fn GetVolume( + pusVolume: *mut USHORT, + ) -> HRESULT, + fn WaitUntilDone( + msTimeout: ULONG, + ) -> HRESULT, + fn SetSyncSpeakTimeout( + msTimeout: ULONG, + ) -> HRESULT, + fn GetSyncSpeakTimeout( + pmsTimeout: *mut ULONG, + ) -> HRESULT, + fn SpeakCompleteEvent() -> HANDLE, + fn IsUISupported( + pszTypeOfUI: LPCWSTR, + pvExtraData: *mut c_void, + cbExtraData: ULONG, + pfSupported: *mut BOOL, + ) -> HRESULT, + fn DisplayUI( + hwndParent: HWND, + pszTitle: LPCWSTR, + pszTypeOfUI: LPCWSTR, + pvExtraData: *mut c_void, + cbExtraData: ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1a5c0354, 0xb621, 0x4b5a, 0x87, 0x91, 0xd3, 0x06, 0xed, 0x37, 0x9e, 0x53)] +interface ISpPhrase(ISpPhraseVtbl): IUnknown(IUnknownVtbl) { + fn GetPhrase( + ppCoMemPhrase: *mut *mut SPPHRASE, + ) -> HRESULT, + fn GetSerializedPhrase( + ppCoMemPhrase: *mut *mut SPSERIALIZEDPHRASE, + ) -> HRESULT, + fn GetText( + ulStart: ULONG, + ulCount: ULONG, + fUseTextReplacements: BOOL, + ppszCoMemText: *mut LPWSTR, + pbDisplayAttributes: *mut BYTE, + ) -> HRESULT, + fn Discard( + dwValueTypes: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8fcebc98, 0x4e49, 0x4067, 0x9c, 0x6c, 0xd8, 0x6a, 0x0e, 0x09, 0x2e, 0x3d)] +interface ISpPhraseAlt(ISpPhraseAltVtbl): ISpPhrase(ISpPhraseVtbl) { + fn GetAltInfo( + pParent: *mut *mut ISpPhrase, + pulStartElementInParent: *mut ULONG, + pcElementsInParent: *mut ULONG, + pcElementsInAlt: *mut ULONG, + ) -> HRESULT, + fn Commit() -> HRESULT, +}} +STRUCT!{struct SPRECORESULTTIMES { + ftStreamTime: FILETIME, + ullLength: ULONGLONG, + dwTickCount: DWORD, + ullStart: ULONGLONG, +}} +STRUCT!{struct SPSERIALIZEDRESULT { + ulSerializedSize: ULONG, +}} +RIDL!{#[uuid(0x20b053be, 0xe235, 0x43cd, 0x9a, 0x2a, 0x8d, 0x17, 0xa4, 0x8b, 0x78, 0x42)] +interface ISpRecoResult(ISpRecoResultVtbl): ISpPhrase(ISpPhraseVtbl) { + fn GetResultTimes( + pTimes: *mut SPRECORESULTTIMES, + ) -> HRESULT, + fn GetAlternates( + ulStartElement: ULONG, + cElements: ULONG, + ulRequestCount: ULONG, + ppPhrases: *mut *mut ISpPhraseAlt, + pcPhrasesReturned: *mut ULONG, + ) -> HRESULT, + fn GetAudio( + ulStartElement: ULONG, + cElements: ULONG, + ppStream: *mut *mut ISpStreamFormat, + ) -> HRESULT, + fn SpeakAudio( + ulStartElement: ULONG, + cElements: ULONG, + dwFlags: DWORD, + pulStreamNumber: *mut ULONG, + ) -> HRESULT, + fn Serialize( + ppCoMemSerializedResult: *mut *mut SPSERIALIZEDRESULT, + ) -> HRESULT, + fn ScaleAudio( + pAudioFormatId: *const GUID, + pWaveFormatEx: *const WAVEFORMATEX, + ) -> HRESULT, + fn GetRecoContext( + ppRecoContext: *mut *mut ISpRecoContext, + ) -> HRESULT, +}} +STRUCT!{struct SPTEXTSELECTIONINFO { + ulStartActiveOffset: ULONG, + cchActiveChars: ULONG, + ulStartSelection: ULONG, + cchSelection: ULONG, +}} +ENUM!{enum SPWORDPRONOUNCEABLE { + SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE = 0, + SPWP_UNKNOWN_WORD_PRONOUNCEABLE = 1, + SPWP_KNOWN_WORD_PRONOUNCEABLE = 2, +}} +ENUM!{enum SPGRAMMARSTATE { + SPGS_DISABLED = 0, + SPGS_ENABLED = 1, + SPGS_EXCLUSIVE = 3, +}} +ENUM!{enum SPCONTEXTSTATE { + SPCS_DISABLED = 0, + SPCS_ENABLED = 1, +}} +ENUM!{enum SPRULESTATE { + SPRS_INACTIVE = 0, + SPRS_ACTIVE = 1, + SPRS_ACTIVE_WITH_AUTO_PAUSE = 3, +}} +pub const SP_STREAMPOS_ASAP: ULONGLONG = 0; +pub const SP_STREAMPOS_REALTIME: ULONGLONG = -1i64 as u64; +pub const SPRULETRANS_TEXTBUFFER: SPSTATEHANDLE = -1isize as SPSTATEHANDLE; +pub const SPRULETRANS_WILDCARD: SPSTATEHANDLE = -2isize as SPSTATEHANDLE; +pub const SPRULETRANS_DICTATION: SPSTATEHANDLE = -3isize as SPSTATEHANDLE; +ENUM!{enum SPGRAMMARWORDTYPE { + SPWT_DISPLAY, + SPWT_LEXICAL, + SPWT_PRONUNCIATION, + SPWT_LEXICAL_NO_SPECIAL_CHARS, +}} +STRUCT!{struct SPPROPERTYINFO { + pszName: LPCWSTR, + ulId: ULONG, + pszValue: LPCWSTR, + vValue: VARIANT, +}} +ENUM!{enum SPCFGRULEATTRIBUTES { + SPRAF_TopLevel = 1 << 0, + SPRAF_Active = 1 << 1, + SPRAF_Export = 1 << 2, + SPRAF_Import = 1 << 3, + SPRAF_Interpreter = 1 << 4, + SPRAF_Dynamic = 1 << 5, + SPRAF_AutoPause = 1 << 16, +}} +RIDL!{#[uuid(0x8137828f, 0x591a, 0x4a42, 0xbe, 0x58, 0x49, 0xea, 0x7e, 0xba, 0xac, 0x68)] +interface ISpGrammarBuilder(ISpGrammarBuilderVtbl): IUnknown(IUnknownVtbl) { + fn ResetGrammar( + NewLanguage: WORD, + ) -> HRESULT, + fn GetRule( + pszRuleName: LPCWSTR, + dwRuleId: DWORD, + dwAttributes: DWORD, + fCreateIfNotExist: BOOL, + phInitialState: *mut SPSTATEHANDLE, + ) -> HRESULT, + fn ClearRule( + hState: SPSTATEHANDLE, + ) -> HRESULT, + fn CreateNewState( + hState: SPSTATEHANDLE, + phState: *mut SPSTATEHANDLE, + ) -> HRESULT, + fn AddWordTransition( + hFromState: SPSTATEHANDLE, + hToState: SPSTATEHANDLE, + psz: LPCWSTR, + pszSeparators: LPCWSTR, + eWordType: SPGRAMMARWORDTYPE, + Weight: c_float, + pPropInfo: *const SPPROPERTYINFO, + ) -> HRESULT, + fn AddRuleTransition( + hFromState: SPSTATEHANDLE, + hToState: SPSTATEHANDLE, + hRule: SPSTATEHANDLE, + Weight: c_float, + pPropInfo: *const SPPROPERTYINFO, + ) -> HRESULT, + fn AddResource( + hRuleState: SPSTATEHANDLE, + pszResourceName: LPCWSTR, + pszResourceValue: LPCWSTR, + ) -> HRESULT, + fn Commit( + dwReserved: DWORD, + ) -> HRESULT, +}} +ENUM!{enum SPLOADOPTIONS { + SPLO_STATIC = 0, + SPLO_DYNAMIC = 1, +}} +RIDL!{#[uuid(0x2177db29, 0x7f45, 0x47d0, 0x85, 0x54, 0x06, 0x7e, 0x91, 0xc8, 0x05, 0x02)] +interface ISpRecoGrammar(ISpRecoGrammarVtbl): ISpGrammarBuilder(ISpGrammarBuilderVtbl) { + fn GetGrammarId( + pullGrammarId: *mut ULONGLONG, + ) -> HRESULT, + fn GetRecoContext( + ppRecoCtxt: *mut *mut ISpRecoContext, + ) -> HRESULT, + fn LoadCmdFromFile( + pszFileName: LPCWSTR, + Options: SPLOADOPTIONS, + ) -> HRESULT, + fn LoadCmdFromObject( + rcid: REFCLSID, + pszGrammarName: LPCWSTR, + Options: SPLOADOPTIONS, + ) -> HRESULT, + fn LoadCmdFromResource( + hModule: HMODULE, + pszResourceName: LPCWSTR, + pszResourceType: LPCWSTR, + wLanguage: WORD, + Options: SPLOADOPTIONS, + ) -> HRESULT, + fn LoadCmdFromMemory( + pGrammar: *const SPBINARYGRAMMAR, + Options: SPLOADOPTIONS, + ) -> HRESULT, + fn LoadCmdFromProprietaryGrammar( + rguidParam: REFGUID, + pszStringParam: LPCWSTR, + pvDataPrarm: *const c_void, + cbDataSize: ULONG, + Options: SPLOADOPTIONS, + ) -> HRESULT, + fn SetRuleState( + pszName: LPCWSTR, + pReserved: *mut c_void, + NewState: SPRULESTATE, + ) -> HRESULT, + fn SetRuleIdState( + ulRuleId: ULONG, + NewState: SPRULESTATE, + ) -> HRESULT, + fn LoadDictation( + pszTopicName: LPCWSTR, + Options: SPLOADOPTIONS, + ) -> HRESULT, + fn UnloadDictation() -> HRESULT, + fn SetDictationState( + NewState: SPRULESTATE, + ) -> HRESULT, + fn SetWordSequenceData( + pText: *const WCHAR, + cchText: ULONG, + pInfo: *const SPTEXTSELECTIONINFO, + ) -> HRESULT, + fn SetTextSelection( + pInfo: *const SPTEXTSELECTIONINFO, + ) -> HRESULT, + fn IsPronounceable( + pszWord: LPCWSTR, + pWordPronounceable: *mut SPWORDPRONOUNCEABLE, + ) -> HRESULT, + fn SetGrammarState( + eGrammarState: SPGRAMMARSTATE, + ) -> HRESULT, + fn SaveCmd( + pStream: *mut IStream, + ppszCoMemErrorText: *mut LPWSTR, + ) -> HRESULT, + fn GetGrammarState( + peGrammarState: *mut SPGRAMMARSTATE, + ) -> HRESULT, +}} +STRUCT!{struct SPRECOCONTEXTSTATUS { + eInterference: SPINTERFERENCE, + szRequestTypeOfUI: [WCHAR; 255], + dwReserved1: DWORD, + dwReserved2: DWORD, +}} +ENUM!{enum SPBOOKMARKOPTIONS { + SPBO_NONE = 0, + SPBO_PAUSE = 1 << 0, +}} +ENUM!{enum SPAUDIOOPTIONS { + SPAO_NONE = 0, + SPAO_RETAIN_AUDIO = 1 << 0, +}} +RIDL!{#[uuid(0xf740a62f, 0x7c15, 0x489e, 0x82, 0x34, 0x94, 0x0a, 0x33, 0xd9, 0x27, 0x2d)] +interface ISpRecoContext(ISpRecoContextVtbl): ISpEventSource(ISpEventSourceVtbl) { + fn GetRecognizer( + ppRecognizer: *mut *mut ISpRecognizer, + ) -> HRESULT, + fn CreateGrammer( + ullGrammarId: ULONGLONG, + ppGrammar: *mut *mut ISpRecoGrammar, + ) -> HRESULT, + fn GetStatus( + pState: *mut SPRECOCONTEXTSTATUS, + ) -> HRESULT, + fn GetMaxAlternates( + pcAlternates: *mut ULONG, + ) -> HRESULT, + fn SetMaxAlternates( + cAlternates: ULONG, + ) -> HRESULT, + fn SetAudioOptions( + Options: SPAUDIOOPTIONS, + pAudioFormatId: *const GUID, + pWaveFormatEx: *const WAVEFORMATEX, + ) -> HRESULT, + fn GetAudioOptions( + pOptions: *mut SPAUDIOOPTIONS, + pAudioFormatId: *mut GUID, + ppCoMemWFEX: *mut *mut WAVEFORMATEX, + ) -> HRESULT, + fn DeserializeResult( + pSerializedResult: *const SPSERIALIZEDRESULT, + ppResult: *mut *mut ISpRecoResult, + ) -> HRESULT, + fn Bookmark( + Options: SPBOOKMARKOPTIONS, + ullStreamPosition: ULONGLONG, + lparamEvent: LPARAM, + ) -> HRESULT, + fn SetAdaptionData( + pAdaptionData: LPCWSTR, + cch: ULONG, + ) -> HRESULT, + fn Pause( + dwReserved: DWORD, + ) -> HRESULT, + fn Resume( + dwReserved: DWORD, + ) -> HRESULT, + fn SetVoice( + pVoice: *mut ISpVoice, + fAllowFormatChanges: BOOL, + ) -> HRESULT, + fn GetVoice( + ppVoice: *mut *mut ISpVoice, + ) -> HRESULT, + fn SetVoicePurgeEvent( + ullEventIntereset: ULONGLONG, + ) -> HRESULT, + fn GetVoicePurgeEvent( + pullEventIntereset: *mut ULONGLONG, + ) -> HRESULT, + fn SetContextState( + eContextState: SPCONTEXTSTATE, + ) -> HRESULT, + fn GetContextState( + peContextState: *mut SPCONTEXTSTATE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5b4fb971, 0xb115, 0x4de1, 0xad, 0x97, 0xe4, 0x82, 0xe3, 0xbf, 0x6e, 0xe4)] +interface ISpProperties(ISpPropertiesVtbl): IUnknown(IUnknownVtbl) { + fn SetPropertyNum( + pName: LPCWSTR, + lValue: LONG, + ) -> HRESULT, + fn GetPropertyNum( + pName: LPCWSTR, + plValue: *mut LONG, + ) -> HRESULT, + fn SetPropertyString( + pName: LPCWSTR, + pValue: LPCWSTR, + ) -> HRESULT, + fn GetPropertyString( + pName: LPCWSTR, + ppCoMemValue: *mut LPWSTR, + ) -> HRESULT, +}} +pub const SP_MAX_LANGIDS: usize = 20; +STRUCT!{struct SPRECOGNIZERSTATUS { + AudioStatus: SPAUDIOSTATUS, + ullRecognitionStreamPos: ULONGLONG, + ulStreamNumber: ULONG, + ulNumActive: ULONG, + clsidEngine: CLSID, + cLangIDs: ULONG, + aLangID: [WORD; SP_MAX_LANGIDS], + ullRecognitionStreamTime: ULONGLONG, +}} +ENUM!{enum SPWAVEFORMATTYPE { + SPWF_INPUT, + SPWF_SRENGINE, +}} +pub type SPSTREAMFORMATTYPE = SPWAVEFORMATTYPE; +ENUM!{enum SPRECOSTATE { + SPRST_INACTIVE, + SPRST_ACTIVE, + SPRST_ACTIVE_ALWAYS, + SPRST_INACTIVE_WITH_PURGE, + SPRST_NUM_STATES, +}} +RIDL!{#[uuid(0xc2b5f241, 0xdaa0, 0x4507, 0x9e, 0x16, 0x5a, 0x1e, 0xaa, 0x2b, 0x7a, 0x5c)] +interface ISpRecognizer(ISpRecognizerVtbl): ISpProperties(ISpPropertiesVtbl) { + fn SetRecognizer( + pRecognizer: *mut ISpObjectToken, + ) -> HRESULT, + fn GetRecognizer( + ppRecognizer: *mut *mut ISpObjectToken, + ) -> HRESULT, + fn SetInput( + pUnkInput: *mut IUnknown, + fAllowFormatChanges: BOOL, + ) -> HRESULT, + fn GetInputObjectToken( + ppToken: *mut *mut ISpObjectToken, + ) -> HRESULT, + fn GetInputStream( + ppStream: *mut *mut ISpStreamFormat, + ) -> HRESULT, + fn CreateRecoContext( + ppNewCtxt: *mut *mut ISpRecoContext, + ) -> HRESULT, + fn GetRecoProfile( + ppToken: *mut *mut ISpObjectToken, + ) -> HRESULT, + fn SetRecoProfile( + pToken: *mut ISpObjectToken, + ) -> HRESULT, + fn IsSharedInstance() -> HRESULT, + fn GetRecoState( + pState: *mut SPRECOSTATE, + ) -> HRESULT, + fn SetRecoState( + NewState: SPRECOSTATE, + ) -> HRESULT, + fn GetStatus( + pStatus: *mut SPRECOGNIZERSTATUS, + ) -> HRESULT, + fn GetFormat( + WaveFormatType: SPSTREAMFORMATTYPE, + pFormatId: *mut GUID, + ppCoMemWFEX: *mut WAVEFORMATEX, + ) -> HRESULT, + fn IsUISupported( + pszTypeOfUI: LPCWSTR, + pvExtraData: *mut c_void, + cbExtraData: ULONG, + pfSupported: *mut BOOL, + ) -> HRESULT, + fn DisplayUI( + hwndParent: HWND, + pszTitle: LPCWSTR, + pszTypeOfUI: LPCWSTR, + pvExtraData: *mut c_void, + cbExtraData: ULONG, + ) -> HRESULT, + fn EmulateRecognition( + pPhrase: *mut ISpPhrase, + ) -> HRESULT, +}} +pub type SpeechLanguageId = c_long; +ENUM!{enum DISPID_SpeechDataKey { + DISPID_SDKSetBinaryValue = 1, + DISPID_SDKGetBinaryValue, + DISPID_SDKSetStringValue, + DISPID_SDKGetStringValue, + DISPID_SDKSetLongValue, + DISPID_SDKGetlongValue, + DISPID_SDKOpenKey, + DISPID_SDKCreateKey, + DISPID_SDKDeleteKey, + DISPID_SDKDeleteValue, + DISPID_SDKEnumKeys, + DISPID_SDKEnumValues, +}} +ENUM!{enum DISPID_SpeechObjectToken { + DISPID_SOTId = 1, + DISPID_SOTDataKey, + DISPID_SOTCategory, + DISPID_SOTGetDescription, + DISPID_SOTSetId, + DISPID_SOTGetAttribute, + DISPID_SOTCreateInstance, + DISPID_SOTRemove, + DISPID_SOTGetStorageFileName, + DISPID_SOTRemoveStorageFileName, + DISPID_SOTIsUISupported, + DISPID_SOTDisplayUI, + DISPID_SOTMatchesAttributes, +}} +ENUM!{enum SpeechDataKeyLocation { + SDKLDefaultLocation = SPDKL_DefaultLocation, + SDKLCurrentUser = SPDKL_CurrentUser, + SDKLLocalMachine = SPDKL_LocalMachine, + SDKLCurrentConfig = SPDKL_CurrentConfig, +}} +ENUM!{enum SpeechTokenContext { + STCInprocServer = CLSCTX_INPROC_SERVER, + STCInprocHandler = CLSCTX_INPROC_HANDLER, + STCLocalServer = CLSCTX_LOCAL_SERVER, + STCRemoteServer = CLSCTX_REMOTE_SERVER, + STCAll = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER + | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, +}} +ENUM!{enum SpeechTokenShellFolder { + STSF_AppData = 0x1a, + STSF_LocalAppData = 0x1c, + STSF_CommonAppData = 0x23, + STSF_FlagCreate = 0x8000, +}} +ENUM!{enum DISPID_SpeechObjectTokens { + DISPID_SOTsCount = 1, + DISPID_SOTsItem = DISPID_VALUE as u32, + DISPID_SOTs_NewEnum = DISPID_NEWENUM as u32, +}} +ENUM!{enum DISPID_SpeechObjectTokenCategory { + DISPID_SOTCId = 1, + DISPID_SOTCDefault, + DISPID_SOTCSetId, + DISPID_SOTCGetDataKey, + DISPID_SOTCEnumerateTokens, +}} +ENUM!{enum SpeechAudioFormatType { + SAFTDefault = -1i32 as u32, + SAFTNoAssignedFormat = 0, + SAFTText = 1, + SAFTNonStandardFormat = 2, + SAFTExtendedAudioFormat = 3, + SAFT8kHz8BitMono = 4, + SAFT8kHz8BitStereo = 5, + SAFT8kHz16BitMono = 6, + SAFT8kHz16BitStereo = 7, + SAFT11kHz8BitMono = 8, + SAFT11kHz8BitStereo = 9, + SAFT11kHz16BitMono = 10, + SAFT11kHz16BitStereo = 11, + SAFT12kHz8BitMono = 12, + SAFT12kHz8BitStereo = 13, + SAFT12kHz16BitMono = 14, + SAFT12kHz16BitStereo = 15, + SAFT16kHz8BitMono = 16, + SAFT16kHz8BitStereo = 17, + SAFT16kHz16BitMono = 18, + SAFT16kHz16BitStereo = 19, + SAFT22kHz8BitMono = 20, + SAFT22kHz8BitStereo = 21, + SAFT22kHz16BitMono = 22, + SAFT22kHz16BitStereo = 23, + SAFT24kHz8BitMono = 24, + SAFT24kHz8BitStereo = 25, + SAFT24kHz16BitMono = 26, + SAFT24kHz16BitStereo = 27, + SAFT32kHz8BitMono = 28, + SAFT32kHz8BitStereo = 29, + SAFT32kHz16BitMono = 30, + SAFT32kHz16BitStereo = 31, + SAFT44kHz8BitMono = 32, + SAFT44kHz8BitStereo = 33, + SAFT44kHz16BitMono = 34, + SAFT44kHz16BitStereo = 35, + SAFT48kHz8BitMono = 36, + SAFT48kHz8BitStereo = 37, + SAFT48kHz16BitMono = 38, + SAFT48kHz16BitStereo = 39, + SAFTTrueSpeech_8kHz1BitMono = 40, + SAFTCCITT_ALaw_8kHzMono = 41, + SAFTCCITT_ALaw_8kHzStereo = 42, + SAFTCCITT_ALaw_11kHzMono = 43, + SAFTCCITT_ALaw_11kHzStereo = 44, + SAFTCCITT_ALaw_22kHzMono = 45, + SAFTCCITT_ALaw_22kHzStereo = 46, + SAFTCCITT_ALaw_44kHzMono = 47, + SAFTCCITT_ALaw_44kHzStereo = 48, + SAFTCCITT_uLaw_8kHzMono = 49, + SAFTCCITT_uLaw_8kHzStereo = 50, + SAFTCCITT_uLaw_11kHzMono = 51, + SAFTCCITT_uLaw_11kHzStereo = 52, + SAFTCCITT_uLaw_22kHzMono = 53, + SAFTCCITT_uLaw_22kHzStereo = 54, + SAFTCCITT_uLaw_44kHzMono = 55, + SAFTCCITT_uLaw_44kHzStereo = 56, + SAFTADPCM_8kHzMono = 57, + SAFTADPCM_8kHzStereo = 58, + SAFTADPCM_11kHzMono = 59, + SAFTADPCM_11kHzStereo = 60, + SAFTADPCM_22kHzMono = 61, + SAFTADPCM_22kHzStereo = 62, + SAFTADPCM_44kHzMono = 63, + SAFTADPCM_44kHzStereo = 64, + SAFTGSM610_8kHzMono = 65, + SAFTGSM610_11kHzMono = 66, + SAFTGSM610_22kHzMono = 67, + SAFTGSM610_44kHzMono = 68, +}} +ENUM!{enum DISPID_SpeechAudioFormat { + DISPID_SAFType = 1, + DISPID_SAFGuid, + DISPID_SAFGetWaveFormatEx, + DISPID_SAFSetWaveFormatEx, +}} +ENUM!{enum DISPID_SpeechBaseStream { + DISPID_SBSFormat = 1, + DISPID_SBSRead, + DISPID_SBSWrite, + DISPID_SBSSeek, +}} +ENUM!{enum SpeechStreamSeekPositionType { + SSSPTRelativeToStart = STREAM_SEEK_SET, + SSSPTRelativeToCurrentPosition = STREAM_SEEK_CUR, + SSSPTRelativeToEnd = STREAM_SEEK_END, +}} +ENUM!{enum DISPID_SpeechAudio { + DISPID_SAStatus = 200, + DISPID_SABufferInfo, + DISPID_SADefaultFormat, + DISPID_SAVolume, + DISPID_SABufferNotifySize, + DISPID_SAEventHandle, + DISPID_SASetState, +}} +ENUM!{enum SpeechAudioState { + SASClosed = SPAS_CLOSED, + SASStop = SPAS_STOP, + SASPause = SPAS_PAUSE, + SASRun = SPAS_RUN, +}} +ENUM!{enum DISPID_SpeechMMSysAudio { + DISPID_SMSADeviceId = 300, + DISPID_SMSALineId, + DISPID_SMSAMMHandle, +}} +ENUM!{enum DISPID_SpeechFileStream { + DISPID_SFSOpen = 100, + DISPID_SFSClose, +}} +ENUM!{enum SpeechStreamFileMode { + SSFMOpenForRead = SPFM_OPEN_READONLY, + SSFMOpenReadWrite = SPFM_OPEN_READWRITE, + SSFMCreate = SPFM_CREATE, + SSFMCreateForWrite = SPFM_CREATE_ALWAYS, +}} +ENUM!{enum DISPID_SpeechCustomStream { + DISPID_SCSBaseStream = 100, +}} +ENUM!{enum DISPID_SpeechMemoryStream { + DISPID_SMSSetData = 100, + DISPID_SMSGetData, +}} +ENUM!{enum DISPID_SpeechAudioStatus { + DISPID_SASFreeBufferSpace = 1, + DISPID_SASNonBlockingIO, + DISPID_SASState, + DISPID_SASCurrentSeekPosition, + DISPID_SASCurrentDevicePosition, +}} +ENUM!{enum DISPID_SpeechAudioBufferInfo { + DISPID_SABIMinNotification = 1, + DISPID_SABIBufferSize, + DISPID_SABIEventBias, +}} +ENUM!{enum DISPID_SpeechWaveFormatEx { + DISPID_SWFEFormatTag = 1, + DISPID_SWFEChannels, + DISPID_SWFESamplesPerSec, + DISPID_SWFEAvgBytesPerSec, + DISPID_SWFEBlockAlign, + DISPID_SWFEBitsPerSample, + DISPID_SWFEExtraData, +}} +ENUM!{enum DISPID_SpeechVoice { + DISPID_SVStatus = 1, + DISPID_SVVoice, + DISPID_SVAudioOutput, + DISPID_SVAudioOutputStream, + DISPID_SVRate, + DISPID_SVVolume, + DISPID_SVAllowAudioOuputFormatChangesOnNextSet, + DISPID_SVEventInterests, + DISPID_SVPriority, + DISPID_SVAlertBoundary, + DISPID_SVSyncronousSpeakTimeout, + DISPID_SVSpeak, + DISPID_SVSpeakStream, + DISPID_SVPause, + DISPID_SVResume, + DISPID_SVSkip, + DISPID_SVGetVoices, + DISPID_SVGetAudioOutputs, + DISPID_SVWaitUntilDone, + DISPID_SVSpeakCompleteEvent, + DISPID_SVIsUISupported, + DISPID_SVDisplayUI, +}} +ENUM!{enum SpeechVoicePriority { + SVPNormal = SPVPRI_NORMAL, + SVPAlert = SPVPRI_ALERT, + SVPOver = SPVPRI_OVER, +}} +ENUM!{enum SpeechVoiceSpeakFlags { + SVSFDefault = SPF_DEFAULT, + SVSFlagsAsync = SPF_ASYNC, + SVSFPurgeBeforeSpeak = SPF_PURGEBEFORESPEAK, + SVSFIsFilename = SPF_IS_FILENAME, + SVSFIsXML = SPF_IS_XML, + SVSFIsNotXML = SPF_IS_NOT_XML, + SVSFPersistXML = SPF_PERSIST_XML, + SVSFNLPSpeakPunc = SPF_NLP_SPEAK_PUNC, + SVSFNLPMask = SPF_NLP_MASK, + SVSFVoiceMask = SPF_VOICE_MASK as u32, + SVSFUnusedFlags = SPF_UNUSED_FLAGS as u32, +}} +ENUM!{enum SpeechVoiceEvents { + SVEStartInputStream = 1 << 1, + SVEEndInputStream = 1 << 2, + SVEVoiceChange = 1 << 3, + SVEBookmark = 1 << 4, + SVEWordBoundary = 1 << 5, + SVEPhoneme = 1 << 6, + SVESentenceBoundary = 1 << 7, + SVEViseme = 1 << 8, + SVEAudioLevel = 1 << 9, + SVEPrivate = 1 << 15, + SVEAllEvents = 0x83fe, +}} +ENUM!{enum DISPID_SpeechVoiceStatus { + DISPID_SVSCurrentStreamNumber = 1, + DISPID_SVSLastStreamNumberQueued, + DISPID_SVSLastResult, + DISPID_SVSRunningState, + DISPID_SVSInputWordPosition, + DISPID_SVSInputWordLength, + DISPID_SVSInputSentencePosition, + DISPID_SVSInputSentenceLength, + DISPID_SVSLastBookmark, + DISPID_SVSLastBookmarkId, + DISPID_SVSPhonemeId, + DISPID_SVSVisemeId, +}} +ENUM!{enum SpeechRunState { + SRSEDone = SPRS_DONE, + SRSEIsSpeaking = SPRS_IS_SPEAKING, +}} +ENUM!{enum SpeechVisemeType { + SVP_0 = 0, + SVP_1, + SVP_2, + SVP_3, + SVP_4, + SVP_5, + SVP_6, + SVP_7, + SVP_8, + SVP_9, + SVP_10, + SVP_11, + SVP_12, + SVP_13, + SVP_14, + SVP_15, + SVP_16, + SVP_17, + SVP_18, + SVP_19, + SVP_20, + SVP_21, +}} +ENUM!{enum SpeechVisemeFeature { + SVF_None = 0, + SVF_Stressed = SPVFEATURE_STRESSED, + SVF_Emphasis = SPVFEATURE_EMPHASIS, +}} +ENUM!{enum DISPID_SpeechVoiceEvent { + DISPID_SVEStreamStart = 1, + DISPID_SVEStreamEnd, + DISPID_SVEVoiceChange, + DISPID_SVEBookmark, + DISPID_SVEWord, + DISPID_SVEPhoneme, + DISPID_SVESentenceBoundary, + DISPID_SVEViseme, + DISPID_SVEAudioLevel, + DISPID_SVEEnginePrivate, +}} +ENUM!{enum DISPID_SpeechRecognizer { + DISPID_SRRecognizer = 1, + DISPID_SRAllowAudioInputFormatChangesOnNextSet, + DISPID_SRAudioInput, + DISPID_SRAudioInputStream, + DISPID_SRIsShared, + DISPID_SRState, + DISPID_SRStatus, + DISPID_SRProfile, + DISPID_SREmulateRecognition, + DISPID_SRCreateRecoContext, + DISPID_SRGetFormat, + DISPID_SRSetPropertyNumber, + DISPID_SRGetPropertyNumber, + DISPID_SRSetPropertyString, + DISPID_SRGetPropertyString, + DISPID_SRIsUISupported, + DISPID_SRDisplayUI, + DISPID_SRGetRecognizers, + DISPID_SVGetAudioInputs, + DISPID_SVGetProfiles, +}} +ENUM!{enum SpeechRecognizerState { + SRSInactive = SPRST_INACTIVE, + SRSActive = SPRST_ACTIVE, + SRSActiveAlways = SPRST_ACTIVE_ALWAYS, + SRSInactiveWithPurge = SPRST_INACTIVE_WITH_PURGE, +}} +ENUM!{enum SpeechDisplayAttributes { + SDA_No_Trailing_Space = 0, + SDA_One_Trailing_Space = SPAF_ONE_TRAILING_SPACE, + SDA_Two_Trailing_Spaces = SPAF_TWO_TRAILING_SPACES, + SDA_Consume_Leading_Spaces = SPAF_CONSUME_LEADING_SPACES, +}} +ENUM!{enum SpeechFormatType { + SFTInput = SPWF_INPUT, + SFTSREngine = SPWF_SRENGINE, +}} +ENUM!{enum DISPID_SpeechRecognizerStatus { + DISPID_SRSAudioStatus = 1, + DISPID_SRSCurrentStreamPosition, + DISPID_SRSCurrentStreamNumber, + DISPID_SRSNumberOfActiveRules, + DISPID_SRSClsidEngine, + DISPID_SRSSupportedLanguages, +}} +ENUM!{enum DISPID_SpeechRecoContext { + DISPID_SRCRecognizer = 1, + DISPID_SRCAudioInInterferenceStatus, + DISPID_SRCRequestedUIType, + DISPID_SRCVoice, + DISPID_SRAllowVoiceFormatMatchingOnNextSet, + DISPID_SRCVoicePurgeEvent, + DISPID_SRCEventInterests, + DISPID_SRCCmdMaxAlternates, + DISPID_SRCState, + DISPID_SRCRetainedAudio, + DISPID_SRCRetainedAudioFormat, + DISPID_SRCPause, + DISPID_SRCResume, + DISPID_SRCCreateGrammar, + DISPID_SRCCreateResultFromMemory, + DISPID_SRCBookmark, + DISPID_SRCSetAdaptationData, +}} +ENUM!{enum SpeechRetainedAudioOptions { + SRAONone = SPAO_NONE, + SRAORetainAudio = SPAO_RETAIN_AUDIO, +}} +ENUM!{enum SpeechBookmarkOptions { + SBONone = SPBO_NONE, + SBOPause = SPBO_PAUSE, +}} +ENUM!{enum SpeechInterference { + SINone = SPINTERFERENCE_NONE, + SINoise = SPINTERFERENCE_NOISE, + SINoSignal = SPINTERFERENCE_NOSIGNAL, + SITooLoud = SPINTERFERENCE_TOOLOUD, + SITooQuiet = SPINTERFERENCE_TOOQUIET, + SITooFast = SPINTERFERENCE_TOOFAST, + SITooSlow = SPINTERFERENCE_TOOSLOW, +}} +ENUM!{enum SpeechRecoEvents { + SREStreamEnd = 1 << 0, + SRESoundStart = 1 << 1, + SRESoundEnd = 1 << 2, + SREPhraseStart = 1 << 3, + SRERecognition = 1 << 4, + SREHypothesis = 1 << 5, + SREBookmark = 1 << 6, + SREPropertyNumChange = 1 << 7, + SREPropertyStringChange = 1 << 8, + SREFalseRecognition = 1 << 9, + SREInterference = 1 << 10, + SRERequestUI = 1 << 11, + SREStateChange = 1 << 12, + SREAdaptation = 1 << 13, + SREStreamStart = 1 << 14, + SRERecoOtherContext = 1 << 15, + SREAudioLevel = 1 << 16, + SREPrivate = 1 << 18, + SREAllEvents = 0x5ffff, +}} +ENUM!{enum SpeechRecoContextState { + SRCS_Disabled = SPCS_DISABLED, + SRCS_Enabled = SPCS_ENABLED, +}} +ENUM!{enum DISPIDSPRG { + DISPID_SRGId = 1, + DISPID_SRGRecoContext, + DISPID_SRGState, + DISPID_SRGRules, + DISPID_SRGReset, + DISPID_SRGCommit, + DISPID_SRGCmdLoadFromFile, + DISPID_SRGCmdLoadFromObject, + DISPID_SRGCmdLoadFromResource, + DISPID_SRGCmdLoadFromMemory, + DISPID_SRGCmdLoadFromProprietaryGrammar, + DISPID_SRGCmdSetRuleState, + DISPID_SRGCmdSetRuleIdState, + DISPID_SRGDictationLoad, + DISPID_SRGDictationUnload, + DISPID_SRGDictationSetState, + DISPID_SRGSetWordSequenceData, + DISPID_SRGSetTextSelection, + DISPID_SRGIsPronounceable, +}} +ENUM!{enum SpeechLoadOption { + SLOStatic = SPLO_STATIC, + SLODynamic = SPLO_DYNAMIC, +}} +ENUM!{enum SpeechWordPronounceable { + SWPUnknownWordUnpronounceable = SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE, + SWPUnknownWordPronounceable = SPWP_UNKNOWN_WORD_PRONOUNCEABLE, + SWPKnownWordPronounceable = SPWP_KNOWN_WORD_PRONOUNCEABLE, +}} +ENUM!{enum SpeechGrammarState { + SGSEnabled = SPGS_ENABLED, + SGSDisabled = SPGS_DISABLED, + SGSExclusive = SPGS_EXCLUSIVE, +}} +ENUM!{enum SpeechRuleState { + SGDSInactive = SPRS_INACTIVE, + SGDSActive = SPRS_ACTIVE, + SGDSActiveWithAutoPause = SPRS_ACTIVE_WITH_AUTO_PAUSE, +}} +ENUM!{enum SpeechRuleAttributes { + SRATopLevel = SPRAF_TopLevel, + SRADefaultToActive = SPRAF_Active, + SRAExport = SPRAF_Export, + SRAImport = SPRAF_Import, + SRAInterpreter = SPRAF_Interpreter, + SRADynamic = SPRAF_Dynamic, +}} +ENUM!{enum SpeechGrammarWordType { + SGDisplay = SPWT_DISPLAY, + SGLexical = SPWT_LEXICAL, + SGPronounciation = SPWT_PRONUNCIATION, +}} +ENUM!{enum DISPID_SpeechRecoContextEvents { + DISPID_SRCEStartStream = 1, + DISPID_SRCEEndStream, + DISPID_SRCEBookmark, + DISPID_SRCESoundStart, + DISPID_SRCESoundEnd, + DISPID_SRCEPhraseStart, + DISPID_SRCERecognition, + DISPID_SRCEHypothesis, + DISPID_SRCEPropertyNumberChange, + DISPID_SRCEPropertyStringChange, + DISPID_SRCEFalseRecognition, + DISPID_SRCEInterference, + DISPID_SRCERequestUI, + DISPID_SRCERecognizerStateChange, + DISPID_SRCEAdaptation, + DISPID_SRCERecognitionForOtherContext, + DISPID_SRCEAudioLevel, + DISPID_SRCEEnginePrivate, +}} +ENUM!{enum SpeechRecognitionType { + SRTStandard = 0, + SRTAutopause = SPREF_AutoPause, + SRTEmulated = SPREF_Emulated, +}} +ENUM!{enum DISPID_SpeechGrammarRule { + DISPID_SGRAttributes = 1, + DISPID_SGRInitialState, + DISPID_SGRName, + DISPID_SGRId, + DISPID_SGRClear, + DISPID_SGRAddResource, + DISPID_SGRAddState, +}} +ENUM!{enum DISPID_SpeechGrammarRules { + DISPID_SGRsCount = 1, + DISPID_SGRsDynamic, + DISPID_SGRsAdd, + DISPID_SGRsCommit, + DISPID_SGRsCommitAndSave, + DISPID_SGRsFindRule, + DISPID_SGRsItem = DISPID_VALUE as u32, + DISPID_SGRs_NewEnum = DISPID_NEWENUM as u32, +}} +ENUM!{enum DISPID_SpeechGrammarRuleState { + DISPID_SGRSRule = 1, + DISPID_SGRSTransitions, + DISPID_SGRSAddWordTransition, + DISPID_SGRSAddRuleTransition, + DISPID_SGRSAddSpecialTransition, +}} +ENUM!{enum SpeechSpecialTransitionType { + SSTTWildcard = 1, + SSTTDictation, + SSTTTextBuffer, +}} +ENUM!{enum DISPID_SpeechGrammarRuleStateTransitions { + DISPID_SGRSTsCount = 1, + DISPID_SGRSTsItem = DISPID_VALUE as u32, + DISPID_SGRSTs_NewEnum = DISPID_NEWENUM as u32, +}} +ENUM!{enum DISPID_SpeechGrammarRuleStateTransition { + DISPID_SGRSTType = 1, + DISPID_SGRSTText, + DISPID_SGRSTRule, + DISPID_SGRSTWeight, + DISPID_SGRSTPropertyName, + DISPID_SGRSTPropertyId, + DISPID_SGRSTPropertyValue, + DISPID_SGRSTNextState, +}} +ENUM!{enum SpeechGrammarRuleStateTransitionType { + SGRSTTEpsilon = 0, + SGRSTTWord, + SGRSTTRule, + SGRSTTDictation, + SGRSTTWildcard, + SGRSTTTextBuffer, +}} +ENUM!{enum DISPIDSPTSI { + DISPIDSPTSI_ActiveOffset = 1, + DISPIDSPTSI_ActiveLength, + DISPIDSPTSI_SelectionOffset, + DISPIDSPTSI_SelectionLength, +}} +ENUM!{enum DISPID_SpeechRecoResult { + DISPID_SRRRecoContext = 1, + DISPID_SRRTimes, + DISPID_SRRAudioFormat, + DISPID_SRRPhraseInfo, + DISPID_SRRAlternates, + DISPID_SRRAudio, + DISPID_SRRSpeakAudio, + DISPID_SRRSaveToMemory, + DISPID_SRRDiscardResultInfo, +}} +ENUM!{enum SpeechDiscardType { + SDTProperty = SPDF_PROPERTY, + SDTReplacement = SPDF_REPLACEMENT, + SDTRule = SPDF_RULE, + SDTDisplayText = SPDF_DISPLAYTEXT, + SDTLexicalForm = SPDF_LEXICALFORM, + SDTPronunciation = SPDF_PRONUNCIATION, + SDTAudio = SPDF_AUDIO, + SDTAlternates = SPDF_ALTERNATES, + SDTAll = SPDF_ALL, +}} +ENUM!{enum DISPID_SpeechPhraseBuilder { + DISPID_SPPBRestorePhraseFromMemory = 1, +}} +ENUM!{enum DISPID_SpeechRecoResultTimes { + DISPID_SRRTStreamTime = 1, + DISPID_SRRTLength, + DISPID_SRRTTickCount, + DISPID_SRRTOffsetFromStart, +}} +ENUM!{enum DISPID_SpeechPhraseAlternate { + DISPID_SPARecoResult = 1, + DISPID_SPAStartElementInResult, + DISPID_SPANumberOfElementsInResult, + DISPID_SPAPhraseInfo, + DISPID_SPACommit, +}} +ENUM!{enum DISPID_SpeechPhraseAlternates { + DISPID_SPAsCount = 1, + DISPID_SPAsItem = DISPID_VALUE as u32, + DISPID_SPAs_NewEnum = DISPID_NEWENUM as u32, +}} +ENUM!{enum DISPID_SpeechPhraseInfo { + DISPID_SPILanguageId = 1, + DISPID_SPIGrammarId, + DISPID_SPIStartTime, + DISPID_SPIAudioStreamPosition, + DISPID_SPIAudioSizeBytes, + DISPID_SPIRetainedSizeBytes, + DISPID_SPIAudioSizeTime, + DISPID_SPIRule, + DISPID_SPIProperties, + DISPID_SPIElements, + DISPID_SPIReplacements, + DISPID_SPIEngineId, + DISPID_SPIEnginePrivateData, + DISPID_SPISaveToMemory, + DISPID_SPIGetText, + DISPID_SPIGetDisplayAttributes, +}} +ENUM!{enum DISPID_SpeechPhraseElement { + DISPID_SPEAudioTimeOffset = 1, + DISPID_SPEAudioSizeTime, + DISPID_SPEAudioStreamOffset, + DISPID_SPEAudioSizeBytes, + DISPID_SPERetainedStreamOffset, + DISPID_SPERetainedSizeBytes, + DISPID_SPEDisplayText, + DISPID_SPELexicalForm, + DISPID_SPEPronunciation, + DISPID_SPEDisplayAttributes, + DISPID_SPERequiredConfidence, + DISPID_SPEActualConfidence, + DISPID_SPEEngineConfidence, +}} +ENUM!{enum SpeechEngineConfidence { + SECLowConfidence = -1i32 as u32, + SECNormalConfidence = 0, + SECHighConfidence = 1, +}} +ENUM!{enum DISPID_SpeechPhraseElements { + DISPID_SPEsCount = 1, + DISPID_SPEsItem = DISPID_VALUE as u32, + DISPID_SPEs_NewEnum = DISPID_NEWENUM as u32, +}} +ENUM!{enum DISPID_SpeechPhraseReplacement { + DISPID_SPRDisplayAttributes = 1, + DISPID_SPRText, + DISPID_SPRFirstElement, + DISPID_SPRNumberOfElements, +}} +ENUM!{enum DISPID_SpeechPhraseReplacements { + DISPID_SPRsCount = 1, + DISPID_SPRsItem = DISPID_VALUE as u32, + DISPID_SPRs_NewEnum = DISPID_NEWENUM as u32, +}} +ENUM!{enum DISPID_SpeechPhraseProperty { + DISPID_SPPName = 1, + DISPID_SPPId, + DISPID_SPPValue, + DISPID_SPPFirstElement, + DISPID_SPPNumberOfElements, + DISPID_SPPEngineConfidence, + DISPID_SPPConfidence, + DISPID_SPPParent, + DISPID_SPPChildren, +}} +ENUM!{enum DISPID_SpeechPhraseProperties { + DISPID_SPPsCount = 1, + DISPID_SPPsItem = DISPID_VALUE as u32, + DISPID_SPPs_NewEnum = DISPID_NEWENUM as u32, +}} +ENUM!{enum DISPID_SpeechPhraseRule { + DISPID_SPRuleName = 1, + DISPID_SPRuleId, + DISPID_SPRuleFirstElement, + DISPID_SPRuleNumberOfElements, + DISPID_SPRuleParent, + DISPID_SPRuleChildren, + DISPID_SPRuleConfidence, + DISPID_SPRuleEngineConfidence, +}} +ENUM!{enum DISPID_SpeechPhraseRules { + DISPID_SPRulesCount = 1, + DISPID_SPRulesItem = DISPID_VALUE as u32, + DISPID_SPRules_NewEnum = DISPID_NEWENUM as u32, +}} +ENUM!{enum DISPID_SpeechLexicon { + DISPID_SLGenerationId = 1, + DISPID_SLGetWords, + DISPID_SLAddPronunciation, + DISPID_SLAddPronunciationByPhoneIds, + DISPID_SLRemovePronunciation, + DISPID_SLRemovePronunciationByPhoneIds, + DISPID_SLGetPronunciations, + DISPID_SLGetGenerationChange, +}} +ENUM!{enum SpeechLexiconType { + SLTUser = eLEXTYPE_USER, + SLTApp = eLEXTYPE_APP, +}} +ENUM!{enum SpeechPartOfSpeech { + SPSNotOverriden = SPPS_NotOverriden, + SPSUnknown = SPPS_Unknown, + SPSNoun = SPPS_Noun, + SPSVerb = SPPS_Verb, + SPSModifier = SPPS_Modifier, + SPSFunction = SPPS_Function, + SPSInterjection = SPPS_Interjection, +}} +ENUM!{enum DISPID_SpeechLexiconWords { + DISPID_SLWsCount = 1, + DISPID_SLWsItem = DISPID_VALUE as u32, + DISPID_SLWs_NewEnum = DISPID_NEWENUM as u32, +}} +ENUM!{enum SpeechWordType { + SWTAdded = eWORDTYPE_ADDED, + SWTDeleted = eWORDTYPE_DELETED, +}} +ENUM!{enum DISPID_SpeechLexiconWord { + DISPID_SLWLangId = 1, + DISPID_SLWType, + DISPID_SLWWord, + DISPID_SLWPronunciations, +}} +ENUM!{enum DISPID_SpeechLexiconProns { + DISPID_SLPsCount = 1, + DISPID_SLPsItem = DISPID_VALUE as u32, + DISPID_SLPs_NewEnum = DISPID_NEWENUM as u32, +}} +ENUM!{enum DISPID_SpeechLexiconPronunciation { + DISPID_SLPType = 1, + DISPID_SLPLangId, + DISPID_SLPPartOfSpeech, + DISPID_SLPPhoneIds, + DISPID_SLPSymbolic, +}} +ENUM!{enum DISPID_SpeechPhoneConverter { + DISPID_SPCLangId = 1, + DISPID_SPCPhoneToId, + DISPID_SPCIdToPhone, +}} +extern { + pub static LIBID_SpeechLib: IID; +} +RIDL!{#[uuid(0xce17c09b, 0x4efa, 0x44d5, 0xa4, 0xc9, 0x59, 0xd9, 0x58, 0x5a, 0xb0, 0xcd)] +interface ISpeechDataKey(ISpeechDataKeyVtbl): IDispatch(IDispatchVtbl) { + fn SetBinaryValue( + ValueName: BSTR, + Value: VARIANT, + ) -> HRESULT, + fn GetBinaryValue( + ValueName: BSTR, + Value: *mut VARIANT, + ) -> HRESULT, + fn SetStringValue( + ValueName: BSTR, + Value: BSTR, + ) -> HRESULT, + fn GetStringValue( + ValueName: BSTR, + Value: *mut BSTR, + ) -> HRESULT, + fn SetLongValue( + ValueName: BSTR, + Value: c_long, + ) -> HRESULT, + fn GetLongValue( + ValueName: BSTR, + Value: *mut c_long, + ) -> HRESULT, + fn OpenKey( + SubKeyName: BSTR, + SubKey: *mut *mut ISpeechDataKey, + ) -> HRESULT, + fn CreateKey( + SubKeyName: BSTR, + SubKey: *mut *mut ISpeechDataKey, + ) -> HRESULT, + fn DeleteKey( + SubKeyName: BSTR, + ) -> HRESULT, + fn DeleteValue( + ValueName: BSTR, + ) -> HRESULT, + fn EnumKeys( + Index: c_long, + SubKeyName: *mut BSTR, + ) -> HRESULT, + fn EnumValues( + Index: c_long, + ValueName: *mut BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc74a3adc, 0xb727, 0x4500, 0xa8, 0x4a, 0xb5, 0x26, 0x72, 0x1c, 0x8b, 0x8c)] +interface ISpeechObjectToken(ISpeechObjectTokenVtbl): IDispatch(IDispatchVtbl) { + fn get_Id( + ObjectId: *mut BSTR, + ) -> HRESULT, + fn get_DataKey( + DataKey: *mut *mut ISpeechDataKey, + ) -> HRESULT, + fn get_Category( + Category: *mut *mut ISpeechObjectTokenCategory, + ) -> HRESULT, + fn GetDescription( + Locale: c_long, + Description: *mut BSTR, + ) -> HRESULT, + fn SetId( + Id: BSTR, + CategoryId: BSTR, + CreateIfNotExist: VARIANT_BOOL, + ) -> HRESULT, + fn GetAttribute( + AttributeName: BSTR, + AttributeValue: *mut BSTR, + ) -> HRESULT, + fn CreateInstance( + pUnkOuter: *mut IUnknown, + ClsContext: SpeechTokenContext, + Object: *mut *mut IUnknown, + ) -> HRESULT, + fn Remove( + ObjectStorageCLSID: BSTR, + ) -> HRESULT, + fn GetStorageFileName( + ObjectStorageCLSID: BSTR, + KeyName: BSTR, + FileName: BSTR, + Folder: BSTR, + FilePath: *mut BSTR, + ) -> HRESULT, + fn RemoveStorageFileName( + ObjectStorageCLSID: BSTR, + KeyName: BSTR, + DeleteFile: VARIANT_BOOL, + ) -> HRESULT, + fn IsUISupported( + TypeOfUI: BSTR, + ExtraData: *const VARIANT, + Object: *mut IUnknown, + Supported: *mut VARIANT_BOOL, + ) -> HRESULT, + fn DisplayUI( + hWnd: c_long, + Title: BSTR, + TypeOfUI: BSTR, + ExtraData: *const VARIANT, + Object: *mut IUnknown, + ) -> HRESULT, + fn MatchesAttributes( + Attributes: BSTR, + Matches: *mut VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9285b776, 0x2e7b, 0x4bc0, 0xb5, 0x3e, 0x58, 0x0e, 0xb6, 0xfa, 0x96, 0x7f)] +interface ISpeechObjectTokens(ISpeechObjectTokensVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + Count: *mut c_long, + ) -> HRESULT, + fn Item( + Index: c_long, + Token: *mut *mut ISpeechObjectToken, + ) -> HRESULT, + fn get__NewEnum( + ppEnumVARIANT: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xca7eac50, 0x2d01, 0x4145, 0x86, 0xd4, 0x5a, 0xe7, 0xd7, 0x0f, 0x44, 0x69)] +interface ISpeechObjectTokenCategory(ISpeechObjectTokenCategoryVtbl): IDispatch(IDispatchVtbl) { + fn get_Id( + Id: *mut BSTR, + ) -> HRESULT, + fn put_Default( + TokenId: BSTR, + ) -> HRESULT, + fn get_Default( + TokenId: *mut BSTR, + ) -> HRESULT, + fn SetId( + Id: BSTR, + CreateIfNotExist: VARIANT_BOOL, + ) -> HRESULT, + fn GetDataKey( + Location: SpeechDataKeyLocation, + DataKey: *mut *mut ISpeechDataKey, + ) -> HRESULT, + fn EnumerateTokens( + RequiredAttributes: BSTR, + OptionalAttributes: BSTR, + Tokens: *mut *mut ISpeechObjectTokens, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x11b103d8, 0x1142, 0x4edf, 0xa0, 0x93, 0x82, 0xfb, 0x39, 0x15, 0xf8, 0xcc)] +interface ISpeechAudioBufferInfo(ISpeechAudioBufferInfoVtbl): IDispatch(IDispatchVtbl) { + fn get_MinNotification( + MinNotification: *mut c_long, + ) -> HRESULT, + fn put_MinNotification( + MinNotification: c_long, + ) -> HRESULT, + fn get_BufferSize( + BufferSize: *mut c_long, + ) -> HRESULT, + fn put_BufferSize( + BufferSize: c_long, + ) -> HRESULT, + fn get_EventBias( + EventBias: *mut c_long, + ) -> HRESULT, + fn put_EventBias( + EventBias: c_long, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc62d9c91, 0x7458, 0x47f6, 0x86, 0x2d, 0x1e, 0xf8, 0x6f, 0xb0, 0xb2, 0x78)] +interface ISpeechAudioStatus(ISpeechAudioStatusVtbl): IDispatch(IDispatchVtbl) { + fn get_FreeBufferSpace( + FreeBufferSpace: *mut c_long, + ) -> HRESULT, + fn get_NonBlockingIO( + NonBlockingIO: *mut c_long, + ) -> HRESULT, + fn get_State( + State: *mut SpeechAudioState, + ) -> HRESULT, + fn get_CurrentSeekPosition( + CurrentSeekPosition: *mut VARIANT, + ) -> HRESULT, + fn get_CurrentDevicePosition( + CurrentDevicePosition: *mut VARIANT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xe6e9c590, 0x3e18, 0x40e3, 0x82, 0x99, 0x06, 0x1f, 0x98, 0xbd, 0xe7, 0xc7)] +interface ISpeechAudioFormat(ISpeechAudioFormatVtbl): IDispatch(IDispatchVtbl) { + fn get_Type( + AudioFormat: *mut SpeechAudioFormatType, + ) -> HRESULT, + fn put_Type( + AudioFormat: SpeechAudioFormatType, + ) -> HRESULT, + fn get_Guid( + Guid: *mut BSTR, + ) -> HRESULT, + fn put_Guid( + Guid: BSTR, + ) -> HRESULT, + fn GetWaveFormatEx( + SpeechWaveFormatEx: *mut *mut ISpeechWaveFormatEx, + ) -> HRESULT, + fn SetWaveFormatEx( + SpeechWaveFormatEx: *mut ISpeechWaveFormatEx, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7a1ef0d5, 0x1581, 0x4741, 0x88, 0xe4, 0x20, 0x9a, 0x49, 0xf1, 0x1a, 0x10)] +interface ISpeechWaveFormatEx(ISpeechWaveFormatExVtbl): IDispatch(IDispatchVtbl) { + fn get_FormatTag( + FormatTag: *mut c_short, + ) -> HRESULT, + fn put_FormatTag( + FormatTag: c_short, + ) -> HRESULT, + fn get_Channels( + Channels: *mut c_short, + ) -> HRESULT, + fn put_Channels( + Channels: c_short, + ) -> HRESULT, + fn get_SamplesPerSec( + SamplesPerSec: *mut c_long, + ) -> HRESULT, + fn put_SamplesPerSec( + SamplesPerSec: c_long, + ) -> HRESULT, + fn get_AvgBytesPerSec( + AvgBytesPerSec: *mut c_long, + ) -> HRESULT, + fn put_AvgBytesPerSec( + AvgBytesPerSec: c_long, + ) -> HRESULT, + fn get_BlockAlign( + BlockAlign: *mut c_short, + ) -> HRESULT, + fn put_BlockAlign( + BlockAlign: c_short, + ) -> HRESULT, + fn get_BitsPerSample( + BitsPerSample: *mut c_short, + ) -> HRESULT, + fn put_BitsPerSample( + BitsPerSample: c_short, + ) -> HRESULT, + fn get_ExtraData( + ExtraData: *mut VARIANT, + ) -> HRESULT, + fn put_ExtraData( + ExtraData: VARIANT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6450336f, 0x7d49, 0x4ced, 0x80, 0x97, 0x49, 0xd6, 0xde, 0xe3, 0x72, 0x94)] +interface ISpeechBaseStream(ISpeechBaseStreamVtbl): IDispatch(IDispatchVtbl) { + fn get_Format( + AudioFormat: *mut *mut ISpeechAudioFormat, + ) -> HRESULT, + fn putref_Format( + AudioFormat: *mut ISpeechAudioFormat, + ) -> HRESULT, + fn Read( + Buffer: *mut VARIANT, + NumberOfBytes: c_long, + BytesRead: *mut c_long, + ) -> HRESULT, + fn Write( + Buffer: VARIANT, + BytesWritten: *mut c_long, + ) -> HRESULT, + fn Seek( + Position: VARIANT, + Origin: SpeechStreamSeekPositionType, + NewPosition: *mut VARIANT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xaf67f125, 0xab39, 0x4e93, 0xb4, 0xa2, 0xcc, 0x2e, 0x66, 0xe1, 0x82, 0xa7)] +interface ISpeechFileStream(ISpeechFileStreamVtbl): ISpeechBaseStream(ISpeechBaseStreamVtbl) { + fn Open( + FileName: BSTR, + FileMode: SpeechStreamFileMode, + DoEvents: VARIANT_BOOL, + ) -> HRESULT, + fn Close() -> HRESULT, +}} +RIDL!{#[uuid(0xeeb14b68, 0x808b, 0x4abe, 0xa5, 0xea, 0xb5, 0x1d, 0xa7, 0x58, 0x80, 0x08)] +interface ISpeechMemoryStream(ISpeechMemoryStreamVtbl): ISpeechBaseStream(ISpeechBaseStreamVtbl) { + fn SetData( + Data: VARIANT, + ) -> HRESULT, + fn GetData( + pData: *mut VARIANT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1a9e9f4f, 0x104f, 0x4db8, 0xa1, 0x15, 0xef, 0xd7, 0xfd, 0x0c, 0x97, 0xae)] +interface ISpeechCustomStream(ISpeechCustomStreamVtbl): ISpeechBaseStream(ISpeechBaseStreamVtbl) { + fn get_BaseStream( + ppUnkStream: *mut *mut IUnknown, + ) -> HRESULT, + fn putref_BaseStream( + pUnkStream: *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xcff8e175, 0x019e, 0x11d3, 0xa0, 0x8e, 0x00, 0xc0, 0x4f, 0x8e, 0xf9, 0xb5)] +interface ISpeechAudio(ISpeechAudioVtbl): ISpeechBaseStream(ISpeechBaseStreamVtbl) { + fn get_Status( + Status: *mut *mut ISpeechAudioStatus, + ) -> HRESULT, + fn get_BufferInfo( + BufferInfo: *mut *mut ISpeechAudioBufferInfo, + ) -> HRESULT, + fn get_DefaultFormat( + StreamFormat: *mut *mut ISpeechAudioFormat, + ) -> HRESULT, + fn get_Volume( + Volume: *mut c_long, + ) -> HRESULT, + fn put_Volume( + Volume: c_long, + ) -> HRESULT, + fn get_BufferNotifySize( + BufferNotifySize: *mut c_long, + ) -> HRESULT, + fn put_BufferNotifySize( + BufferNotifySize: c_long, + ) -> HRESULT, + fn get_EventHandle( + EventHandle: *mut c_long, + ) -> HRESULT, + fn SetState( + State: SpeechAudioState, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3c76af6d, 0x1fd7, 0x4831, 0x81, 0xd1, 0x3b, 0x71, 0xd5, 0xa1, 0x3c, 0x44)] +interface ISpeechMMSysAudio(ISpeechMMSysAudioVtbl): ISpeechAudio(ISpeechAudioVtbl) { + fn get_DeviceId( + DeviceId: *mut c_long, + ) -> HRESULT, + fn put_DeviceId( + DeviceId: c_long, + ) -> HRESULT, + fn get_LineId( + LineId: *mut c_long, + ) -> HRESULT, + fn put_LineId( + LineId: c_long, + ) -> HRESULT, + fn get_MMHandle( + Handle: *mut c_long, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x269316d8, 0x57bd, 0x11d2, 0x9e, 0xee, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] +interface ISpeechVoice(ISpeechVoiceVtbl): IDispatch(IDispatchVtbl) { + fn get_Status( + Status: *mut *mut ISpeechVoiceStatus, + ) -> HRESULT, + fn get_Voice( + Voice: *mut *mut ISpeechObjectToken, + ) -> HRESULT, + fn putref_Voice( + Voice: *mut ISpeechObjectToken, + ) -> HRESULT, + fn get_AudioOutput( + AudioOutput: *mut *mut ISpeechObjectToken, + ) -> HRESULT, + fn putref_AudioOutput( + AudioOutput: *mut ISpeechObjectToken, + ) -> HRESULT, + fn get_AudioOutputStream( + AudioOutputStream: *mut *mut ISpeechBaseStream, + ) -> HRESULT, + fn putref_AudioOutputStream( + AudioOutputStream: *mut ISpeechBaseStream, + ) -> HRESULT, + fn get_Rate( + Rate: *mut c_long, + ) -> HRESULT, + fn put_Rate( + Rate: c_long, + ) -> HRESULT, + fn get_Volume( + Volume: *mut c_long, + ) -> HRESULT, + fn put_Volume( + Volume: c_long, + ) -> HRESULT, + fn put_AllowAudioOutputFormatChangesOnNextSet( + Allow: VARIANT_BOOL, + ) -> HRESULT, + fn get_AllowAudioOutputFormatChangesOnNextSet( + Allow: *mut VARIANT_BOOL, + ) -> HRESULT, + fn get_EventInterests( + EventInterestFlags: *mut SpeechVoiceEvents, + ) -> HRESULT, + fn put_EventInterests( + EventInterestFlags: SpeechVoiceEvents, + ) -> HRESULT, + fn put_Priority( + Priority: SpeechVoicePriority, + ) -> HRESULT, + fn get_Priority( + Priority: *mut SpeechVoicePriority, + ) -> HRESULT, + fn put_AlertBoundary( + Boundary: SpeechVoiceEvents, + ) -> HRESULT, + fn get_AlertBoundary( + Boundary: *mut SpeechVoiceEvents, + ) -> HRESULT, + fn put_SynchronousSpeakTimeout( + msTimeout: c_long, + ) -> HRESULT, + fn get_SynchronousSpeakTimeout( + msTimeOut: *mut c_long, + ) -> HRESULT, + fn Speak( + Text: BSTR, + Flags: SpeechVoiceSpeakFlags, + StreamNumber: *mut c_long, + ) -> HRESULT, + fn SpeakStream( + Stream: *mut ISpeechBaseStream, + Flags: SpeechVoiceSpeakFlags, + StreamNumber: *mut c_long, + ) -> HRESULT, + fn Pause() -> HRESULT, + fn Resume() -> HRESULT, + fn Skip( + Type: BSTR, + NumItems: c_long, + NumSkipped: c_long, + ) -> HRESULT, + fn GetVoices( + RequiredAttributes: BSTR, + OptionalAttributes: BSTR, + ObjectTokens: *mut *mut ISpeechObjectTokens, + ) -> HRESULT, + fn GetAudioOutputs( + RequiredAttributes: BSTR, + OptionalAttributes: BSTR, + ObjectTokens: *mut *mut ISpeechObjectTokens, + ) -> HRESULT, + fn WaitUntilDone( + msTimeout: c_long, + Done: *mut VARIANT_BOOL, + ) -> HRESULT, + fn SpeakCompleteEvent( + Handle: *mut c_long, + ) -> HRESULT, + fn IsUISupported( + TypeOfUI: BSTR, + ExtraData: *const VARIANT, + Supported: *mut VARIANT_BOOL, + ) -> HRESULT, + fn DisplayUI( + hWndParent: c_long, + Title: BSTR, + TypeOfUI: BSTR, + ExtraData: *const VARIANT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8be47b07, 0x57f6, 0x11d2, 0x9e, 0xee, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] +interface ISpeechVoiceStatus(ISpeechVoiceStatusVtbl): IDispatch(IDispatchVtbl) { + fn get_CurrentStreamNumber( + StreamNumber: *mut c_long, + ) -> HRESULT, + fn get_LastStreamNumberQueued( + StreamNumber: *mut c_long, + ) -> HRESULT, + fn get_LastHResult( + HResult: *mut c_long, + ) -> HRESULT, + fn get_RunningState( + State: *mut SpeechRunState, + ) -> HRESULT, + fn get_InputWordPosition( + Position: *mut c_long, + ) -> HRESULT, + fn get_InputWordLength( + Length: *mut c_long, + ) -> HRESULT, + fn get_InputSentencePosition( + Position: *mut c_long, + ) -> HRESULT, + fn get_InputSentenceLength( + Length: *mut c_long, + ) -> HRESULT, + fn get_LastBookmark( + Bookmark: *mut BSTR, + ) -> HRESULT, + fn get_LastBookmarkId( + BookmarkId: *mut c_long, + ) -> HRESULT, + fn get_PhonemeId( + PhoneId: *mut c_short, + ) -> HRESULT, + fn get_VisemeId( + VisemeId: *mut c_short, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa372acd1, 0x3bef, 0x4bbd, 0x8f, 0xfb, 0xcb, 0x3e, 0x2b, 0x41, 0x6a, 0xf8)] +interface _ISpeechVoiceEvents(_ISpeechVoiceEventsVtbl): IDispatch(IDispatchVtbl) {}} +RIDL!{#[uuid(0x2d5f1c0c, 0xbd75, 0x4b08, 0x94, 0x78, 0x3b, 0x11, 0xfe, 0xa2, 0x58, 0x6c)] +interface ISpeechRecognizer(ISpeechRecognizerVtbl): IDispatch(IDispatchVtbl) { + fn putref_Recognizer( + Recognizer: *mut ISpeechObjectToken, + ) -> HRESULT, + fn get_Recognizer( + Recognizer: *mut *mut ISpeechObjectToken, + ) -> HRESULT, + fn put_AllowAudioInputFormatChangesOnNextSet( + Allow: VARIANT_BOOL, + ) -> HRESULT, + fn get_AllowAudioInputFormatChangesOnNextSet( + Allow: *mut VARIANT_BOOL, + ) -> HRESULT, + fn putref_AudioInput( + AudioInput: *mut ISpeechObjectToken, + ) -> HRESULT, + fn get_AudioInput( + AudioInput: *mut *mut ISpeechObjectToken, + ) -> HRESULT, + fn putref_AudioInputStream( + AudioInputStream: *mut ISpeechBaseStream, + ) -> HRESULT, + fn get_AudioInputStream( + AudioInputStream: *mut *mut ISpeechBaseStream, + ) -> HRESULT, + fn get_IsShared( + Shared: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_State( + State: SpeechRecognizerState, + ) -> HRESULT, + fn get_State( + State: *mut SpeechRecognizerState, + ) -> HRESULT, + fn get_Status( + Status: *mut *mut ISpeechRecognizerStatus, + ) -> HRESULT, + fn putref_Profile( + Profile: *mut ISpeechObjectToken, + ) -> HRESULT, + fn get_Profile( + Profile: *mut *mut ISpeechObjectToken, + ) -> HRESULT, + fn EmulateRecognition( + TextElements: VARIANT, + ElementDisplayAttributes: *mut VARIANT, + LanguageId: c_long, + ) -> HRESULT, + fn CreateRecoContext( + NewContext: *mut *mut ISpeechRecoContext, + ) -> HRESULT, + fn GetFormat( + Type: SpeechFormatType, + Format: *mut *mut ISpeechAudioFormat, + ) -> HRESULT, + fn SetPropertyNumber( + Name: BSTR, + Value: c_long, + Supported: *mut VARIANT_BOOL, + ) -> HRESULT, + fn GetPropertyNumber( + Name: BSTR, + Value: *mut c_long, + Supported: *mut VARIANT_BOOL, + ) -> HRESULT, + fn SetPropertyString( + Name: BSTR, + Value: BSTR, + Supported: *mut VARIANT_BOOL, + ) -> HRESULT, + fn GetPropertyString( + Name: BSTR, + Value: *mut BSTR, + Supported: *mut VARIANT_BOOL, + ) -> HRESULT, + fn IsUISupported( + TypeOfUI: BSTR, + ExtraData: *const VARIANT, + Supported: *mut VARIANT_BOOL, + ) -> HRESULT, + fn DisplayUI( + hWndParent: c_long, + Title: BSTR, + TypeOfUI: BSTR, + ExtraData: *const VARIANT, + ) -> HRESULT, + fn GetRecognizers( + RequiredAttributes: BSTR, + OptionalAttributes: BSTR, + ObjectTokens: *mut *mut ISpeechObjectTokens, + ) -> HRESULT, + fn GetAudioInputs( + RequiredAttributes: BSTR, + OptionalAttributes: BSTR, + ObjectTokens: *mut *mut ISpeechObjectTokens, + ) -> HRESULT, + fn GetProfiles( + RequiredAttributes: BSTR, + OptionalAttributes: BSTR, + ObjectTokens: *mut *mut ISpeechObjectTokens, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xbff9e781, 0x53ec, 0x484e, 0xbb, 0x8a, 0x0e, 0x1b, 0x55, 0x51, 0xe3, 0x5c)] +interface ISpeechRecognizerStatus(ISpeechRecognizerStatusVtbl): IDispatch(IDispatchVtbl) { + fn get_AudioStatus( + AudioStatus: *mut *mut ISpeechAudioStatus, + ) -> HRESULT, + fn get_CurrentStreamPosition( + pCurrentStreamPos: *mut VARIANT, + ) -> HRESULT, + fn get_CurrentStreamNumber( + StreamNumber: *mut c_long, + ) -> HRESULT, + fn get_NumberOfActiveRules( + NumberOfActiveRules: *mut c_long, + ) -> HRESULT, + fn get_ClsidEngine( + ClsidEngine: *mut BSTR, + ) -> HRESULT, + fn get_SupportedLanguages( + SupportedLanguages: *mut VARIANT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x580aa49d, 0x7e1e, 0x4809, 0xb8, 0xe2, 0x57, 0xda, 0x80, 0x61, 0x04, 0xb8)] +interface ISpeechRecoContext(ISpeechRecoContextVtbl): IDispatch(IDispatchVtbl) { + fn get_Recognizer( + Recognizer: *mut *mut ISpeechRecognizer, + ) -> HRESULT, + fn get_AudioInputInterferenceStatus( + Interference: *mut SpeechInterference, + ) -> HRESULT, + fn get_RequestedUIType( + UIType: *mut BSTR, + ) -> HRESULT, + fn putref_Voice( + Voice: *mut ISpeechVoice, + ) -> HRESULT, + fn get_Voice( + Voice: *mut *mut ISpeechVoice, + ) -> HRESULT, + fn put_AllowVoiceFormatMatchingOnNextSet( + Allow: VARIANT_BOOL, + ) -> HRESULT, + fn get_AllowVoiceFormatMatchingOnNextSet( + Allow: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_VoicePurgeEvent( + EventInterest: SpeechRecoEvents, + ) -> HRESULT, + fn get_VoicePurgeEvent( + EventInterest: *mut SpeechRecoEvents, + ) -> HRESULT, + fn put_EventInterests( + EventInterest: SpeechRecoEvents, + ) -> HRESULT, + fn get_EventInterests( + EventInterest: *mut SpeechRecoEvents, + ) -> HRESULT, + fn put_CmdMaxAlternates( + MaxAlternates: c_long, + ) -> HRESULT, + fn get_CmdMaxAlternates( + MaxAlternates: *mut c_long, + ) -> HRESULT, + fn put_State( + State: SpeechRecoContextState, + ) -> HRESULT, + fn get_State( + State: *mut SpeechRecoContextState, + ) -> HRESULT, + fn put_RetainedAudio( + Option: SpeechRetainedAudioOptions, + ) -> HRESULT, + fn get_RetainedAudio( + Option: *mut SpeechRetainedAudioOptions, + ) -> HRESULT, + fn putref_RetainedAudioFormat( + Format: *mut ISpeechAudioFormat, + ) -> HRESULT, + fn get_RetainedAudioFormat( + Format: *mut *mut ISpeechAudioFormat, + ) -> HRESULT, + fn Pause() -> HRESULT, + fn Resume() -> HRESULT, + fn CreateGrammar( + GrammarId: VARIANT, + Grammar: *mut *mut ISpeechRecoGrammar, + ) -> HRESULT, + fn CreateResultFromMemory( + ResultBlock: *mut VARIANT, + Result: *mut *mut ISpeechRecoResult, + ) -> HRESULT, + fn Bookmark( + Options: SpeechBookmarkOptions, + StreamPos: VARIANT, + BookmarkId: VARIANT, + ) -> HRESULT, + fn SetAdaptationData( + AdaptationString: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb6d6f79f, 0x2158, 0x4e50, 0xb5, 0xbc, 0x9a, 0x9c, 0xcd, 0x85, 0x2a, 0x09)] +interface ISpeechRecoGrammar(ISpeechRecoGrammarVtbl): IDispatch(IDispatchVtbl) { + fn get_Id( + Id: *mut VARIANT, + ) -> HRESULT, + fn get_RecoContext( + RecoContext: *mut *mut ISpeechRecoContext, + ) -> HRESULT, + fn put_State( + State: SpeechGrammarState, + ) -> HRESULT, + fn get_State( + State: *mut SpeechGrammarState, + ) -> HRESULT, + fn get_Rules( + Rules: *mut *mut ISpeechGrammarRules, + ) -> HRESULT, + fn Reset( + NewLanguage: SpeechLanguageId, + ) -> HRESULT, + fn CmdLoadFromFile( + FileName: BSTR, + LoadOption: SpeechLoadOption, + ) -> HRESULT, + fn CmdLoadFromObject( + ClassId: BSTR, + GrammarName: BSTR, + LoadOption: SpeechLoadOption, + ) -> HRESULT, + fn CmdLoadFromResource( + hModule: c_long, + ResourceName: VARIANT, + ResourceType: VARIANT, + LanguageId: SpeechLanguageId, + LoadOption: SpeechLoadOption, + ) -> HRESULT, + fn CmdLoadFromMemory( + GrammarData: VARIANT, + LoadOption: SpeechLoadOption, + ) -> HRESULT, + fn CmdLoadFromProprietaryGrammar( + ProprietaryGuid: BSTR, + PriorietaryString: BSTR, + ProprietaryData: VARIANT, + LoadOption: SpeechLoadOption, + ) -> HRESULT, + fn CmdSetRuleState( + Name: BSTR, + State: SpeechRuleState, + ) -> HRESULT, + fn CmdSetRuleIdState( + RuleId: c_long, + State: SpeechRuleState, + ) -> HRESULT, + fn DictationLoad( + TopicName: BSTR, + LoadOption: SpeechLoadOption, + ) -> HRESULT, + fn DictationUnload() -> HRESULT, + fn DictationSetState( + State: SpeechRuleState, + ) -> HRESULT, + fn SetWordSequenceData( + Text: BSTR, + TextLength: c_long, + Info: *mut ISpeechTextSelectionInformation, + ) -> HRESULT, + fn SetTextSelection( + Info: *mut ISpeechTextSelectionInformation, + ) -> HRESULT, + fn IsPronounceable( + Word: BSTR, + WordPronounceable: *mut SpeechWordPronounceable, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7b8fcb42, 0x0e9d, 0x4f00, 0xa0, 0x48, 0x7b, 0x04, 0xd6, 0x17, 0x9d, 0x3d)] +interface _ISpeechRecoContextEvents(_ISpeechRecoContextEventsVtbl): IDispatch(IDispatchVtbl) {}} +RIDL!{#[uuid(0xafe719cf, 0x5dd1, 0x44f2, 0x99, 0x9c, 0x7a, 0x39, 0x9f, 0x1c, 0xfc, 0xcc)] +interface ISpeechGrammarRule(ISpeechGrammarRuleVtbl): IDispatch(IDispatchVtbl) { + fn get_Attributes( + Attributes: *mut SpeechRuleAttributes, + ) -> HRESULT, + fn get_InitialState( + State: *mut *mut ISpeechGrammarRuleState, + ) -> HRESULT, + fn get_Name( + Name: *mut BSTR, + ) -> HRESULT, + fn get_Id( + Id: *mut c_long, + ) -> HRESULT, + fn Clear() -> HRESULT, + fn AddResource( + ResourceName: BSTR, + ResourceValue: BSTR, + ) -> HRESULT, + fn AddState( + State: *mut *mut ISpeechGrammarRuleState, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6ffa3b44, 0xfc2d, 0x40d1, 0x8a, 0xfc, 0x32, 0x91, 0x1c, 0x7f, 0x1a, 0xd1)] +interface ISpeechGrammarRules(ISpeechGrammarRulesVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + Count: *mut c_long, + ) -> HRESULT, + fn FindRule( + RuleNameOrId: VARIANT, + Rule: *mut *mut ISpeechGrammarRule, + ) -> HRESULT, + fn Item( + Index: c_long, + Rule: *mut *mut ISpeechGrammarRule, + ) -> HRESULT, + fn get__NewEnum( + EnumVARIANT: *mut *mut IUnknown, + ) -> HRESULT, + fn get_Dynamic( + Dynamic: *mut VARIANT_BOOL, + ) -> HRESULT, + fn Add( + RuleName: BSTR, + Attributes: SpeechRuleAttributes, + RuleId: c_long, + Rule: *mut *mut ISpeechGrammarRule, + ) -> HRESULT, + fn Commit() -> HRESULT, + fn CommitAndSave( + ErrorText: *mut BSTR, + SaveStream: *mut VARIANT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd4286f2c, 0xee67, 0x45ae, 0xb9, 0x28, 0x28, 0xd6, 0x95, 0x36, 0x2e, 0xda)] +interface ISpeechGrammarRuleState(ISpeechGrammarRuleStateVtbl): IDispatch(IDispatchVtbl) { + fn get_Rule( + Rule: *mut *mut ISpeechGrammarRule, + ) -> HRESULT, + fn get_Transitions( + Transitions: *mut *mut ISpeechGrammarRuleStateTransitions, + ) -> HRESULT, + fn AddWordTransition( + DestState: *mut ISpeechGrammarRuleState, + Words: BSTR, + Separators: BSTR, + Type: SpeechGrammarWordType, + PropertyName: BSTR, + PropertyId: c_long, + PropertyValue: *mut VARIANT, + Weight: c_float, + ) -> HRESULT, + fn AddRuleTransition( + DestinationState: *mut ISpeechGrammarRuleState, + Rule: *mut ISpeechGrammarRule, + PropertyName: BSTR, + PropertyId: c_long, + PropertyValue: *mut VARIANT, + Weight: c_float, + ) -> HRESULT, + fn AddSpecialTransition( + DestinationState: *mut ISpeechGrammarRuleState, + Type: SpeechSpecialTransitionType, + PropertyName: BSTR, + PropertyId: c_long, + PropertyValue: *mut VARIANT, + Weight: c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xcafd1db1, 0x41d1, 0x4a06, 0x98, 0x63, 0xe2, 0xe8, 0x1d, 0xa1, 0x7a, 0x9a)] +interface ISpeechGrammarRuleStateTransition(ISpeechGrammarRuleStateTransitionVtbl): + IDispatch(IDispatchVtbl) { + fn get_Type( + Type: *mut SpeechGrammarRuleStateTransitionType, + ) -> HRESULT, + fn get_Text( + Text: *mut BSTR, + ) -> HRESULT, + fn get_Rule( + Rule: *mut *mut ISpeechGrammarRule, + ) -> HRESULT, + fn get_Weight( + Weight: *mut VARIANT, + ) -> HRESULT, + fn get_PropertyName( + PropertyName: *mut BSTR, + ) -> HRESULT, + fn get_PropertyId( + PropertyId: *mut c_long, + ) -> HRESULT, + fn get_PropertyValue( + PropertyValue: *mut VARIANT, + ) -> HRESULT, + fn get_NextState( + NextState: *mut *mut ISpeechGrammarRuleState, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xeabce657, 0x75bc, 0x44a2, 0xaa, 0x7f, 0xc5, 0x64, 0x76, 0x74, 0x29, 0x63)] +interface ISpeechGrammarRuleStateTransitions(ISpeechGrammarRuleStateTransitionsVtbl): + IDispatch(IDispatchVtbl) { + fn get_Count( + Count: *mut c_long, + ) -> HRESULT, + fn Item( + Index: c_long, + Transition: *mut *mut ISpeechGrammarRuleStateTransition, + ) -> HRESULT, + fn get__NewEnum( + EnumVARIANT: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3b9c7e7a, 0x6eee, 0x4ded, 0x90, 0x92, 0x11, 0x65, 0x72, 0x79, 0xad, 0xbe)] +interface ISpeechTextSelectionInformation(ISpeechTextSelectionInformationVtbl): + IDispatch(IDispatchVtbl) { + fn put_ActiveOffset( + ActiveOffset: c_long, + ) -> HRESULT, + fn get_ActiveOffset( + ActiveOffset: *mut c_long, + ) -> HRESULT, + fn put_ActiveLength( + ActiveLength: c_long, + ) -> HRESULT, + fn get_ActiveLength( + ActiveLength: *mut c_long, + ) -> HRESULT, + fn put_SelectionOffset( + SelectionOffset: c_long, + ) -> HRESULT, + fn get_SelectionOffset( + SelectionOffset: *mut c_long, + ) -> HRESULT, + fn put_SelectionLength( + SelectionLength: c_long, + ) -> HRESULT, + fn get_SelectionLength( + SelectionLength: *mut c_long, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xed2879cf, 0xced9, 0x4ee6, 0xa5, 0x34, 0xde, 0x01, 0x91, 0xd5, 0x46, 0x8d)] +interface ISpeechRecoResult(ISpeechRecoResultVtbl): IDispatch(IDispatchVtbl) { + fn get_RecoContext( + RecoContext: *mut *mut ISpeechRecoContext, + ) -> HRESULT, + fn get_Times( + Times: *mut *mut ISpeechRecoResultTimes, + ) -> HRESULT, + fn putref_AudioFormat( + Format: *mut ISpeechAudioFormat, + ) -> HRESULT, + fn get_AudioFormat( + Format: *mut *mut ISpeechAudioFormat, + ) -> HRESULT, + fn get_PhraseInfo( + PhraseInfo: *mut *mut ISpeechPhraseInfo, + ) -> HRESULT, + fn Alternates( + RequestCount: c_long, + StartElement: c_long, + Elements: c_long, + Alternates: *mut *mut ISpeechPhraseAlternates, + ) -> HRESULT, + fn Audio( + StartElement: c_long, + Elements: c_long, + Stream: *mut *mut ISpeechMemoryStream, + ) -> HRESULT, + fn SpeakAudio( + StartElement: c_long, + Elements: c_long, + Flags: SpeechVoiceSpeakFlags, + StreamNumber: *mut c_long, + ) -> HRESULT, + fn SaveToMemory( + ResultBlock: *mut VARIANT, + ) -> HRESULT, + fn DiscardResultInfo( + ValueTypes: SpeechDiscardType, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x62b3b8fb, 0xf6e7, 0x41be, 0xbd, 0xcb, 0x05, 0x6b, 0x1c, 0x29, 0xef, 0xc0)] +interface ISpeechRecoResultTimes(ISpeechRecoResultTimesVtbl): IDispatch(IDispatchVtbl) { + fn get_StreamTime( + Time: *mut VARIANT, + ) -> HRESULT, + fn get_Length( + Length: *mut VARIANT, + ) -> HRESULT, + fn get_TickCount( + TickCount: *mut c_long, + ) -> HRESULT, + fn get_OffsetFromStart( + OffsetFromStart: *mut VARIANT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x27864a2a, 0x2b9f, 0x4cb8, 0x92, 0xd3, 0x0d, 0x27, 0x22, 0xfd, 0x1e, 0x73)] +interface ISpeechPhraseAlternate(ISpeechPhraseAlternateVtbl): IDispatch(IDispatchVtbl) { + fn get_RecoResult( + RecoResult: *mut *mut ISpeechRecoResult, + ) -> HRESULT, + fn get_StartElementInResult( + StartElement: *mut c_long, + ) -> HRESULT, + fn get_NumberOfElementsInResult( + NumberOfElements: *mut c_long, + ) -> HRESULT, + fn get_PhraseInfo( + PhraseInfo: *mut *mut ISpeechPhraseInfo, + ) -> HRESULT, + fn Commit() -> HRESULT, +}} +RIDL!{#[uuid(0xb238b6d5, 0xf276, 0x4c3d, 0xa6, 0xc1, 0x29, 0x74, 0x80, 0x1c, 0x3c, 0xc2)] +interface ISpeechPhraseAlternates(ISpeechPhraseAlternatesVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + Count: *mut c_long, + ) -> HRESULT, + fn Item( + Index: c_long, + PhraseAlternate: *mut *mut ISpeechPhraseAlternate, + ) -> HRESULT, + fn get__NewEnum( + EnumVARIANT: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x961559cf, 0x4e67, 0x4662, 0x8b, 0xf0, 0xd9, 0x3f, 0x1f, 0xcd, 0x61, 0xb3)] +interface ISpeechPhraseInfo(ISpeechPhraseInfoVtbl): IDispatch(IDispatchVtbl) { + fn get_LanguageId( + LanguageId: *mut c_long, + ) -> HRESULT, + fn get_GrammarId( + GrammarId: *mut VARIANT, + ) -> HRESULT, + fn get_StartTime( + StartTime: *mut VARIANT, + ) -> HRESULT, + fn get_AudioStreamPosition( + AudioStreamPosition: *mut VARIANT, + ) -> HRESULT, + fn get_AudioSizeBytes( + pAudioSizeBytes: *mut c_long, + ) -> HRESULT, + fn get_RetainedSizeBytes( + RetainedSizeBytes: *mut c_long, + ) -> HRESULT, + fn get_AudioSizeTime( + AudioSizeTime: *mut c_long, + ) -> HRESULT, + fn get_Rule( + Rule: *mut *mut ISpeechPhraseRule, + ) -> HRESULT, + fn get_Properties( + Properties: *mut *mut ISpeechPhraseProperties, + ) -> HRESULT, + fn get_Elements( + Elements: *mut *mut ISpeechPhraseElements, + ) -> HRESULT, + fn get_Replacements( + Replacements: *mut *mut ISpeechPhraseReplacements, + ) -> HRESULT, + fn get_EngineId( + EngineIdGuid: *mut BSTR, + ) -> HRESULT, + fn get_EnginePrivateData( + PrivateData: *mut VARIANT, + ) -> HRESULT, + fn SaveToMemory( + PhraseBlock: *mut VARIANT, + ) -> HRESULT, + fn GetText( + StartElement: c_long, + Elements: c_long, + UseReplacements: VARIANT_BOOL, + Text: *mut BSTR, + ) -> HRESULT, + fn GetDisplayAttributes( + StartElement: c_long, + Elements: c_long, + UseReplacements: VARIANT_BOOL, + DisplayAttributes: *mut SpeechDisplayAttributes, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xe6176f96, 0xe373, 0x4801, 0xb2, 0x23, 0x3b, 0x62, 0xc0, 0x68, 0xc0, 0xb4)] +interface ISpeechPhraseElement(ISpeechPhraseElementVtbl): IDispatch(IDispatchVtbl) { + fn get_AudioTimeOffset( + AudioTimeOffset: *mut c_long, + ) -> HRESULT, + fn get_AudioSizeTime( + AudioSizeTime: *mut c_long, + ) -> HRESULT, + fn get_AudioStreamOffset( + AudioStreamOffset: *mut c_long, + ) -> HRESULT, + fn get_AudioSizeBytes( + AudioSizeBytes: *mut c_long, + ) -> HRESULT, + fn get_RetainedStreamOffset( + RetainedStreamOffset: *mut c_long, + ) -> HRESULT, + fn get_RetainedSizeBytes( + RetainedSizeBytes: *mut c_long, + ) -> HRESULT, + fn get_DisplayText( + DisplayText: *mut BSTR, + ) -> HRESULT, + fn get_LexicalForm( + LexicalForm: *mut BSTR, + ) -> HRESULT, + fn get_Pronunciation( + Pronunciation: *mut VARIANT, + ) -> HRESULT, + fn get_DisplayAttributes( + DisplayAttributes: *mut SpeechDisplayAttributes, + ) -> HRESULT, + fn get_RequiredConfidence( + RequiredConfidence: *mut SpeechEngineConfidence, + ) -> HRESULT, + fn get_ActualConfidence( + ActualConfidence: *mut SpeechEngineConfidence, + ) -> HRESULT, + fn get_EngineConfidence( + EngineConfident: *mut c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0626b328, 0x3478, 0x467d, 0xa0, 0xb3, 0xd0, 0x85, 0x3b, 0x93, 0xdd, 0xa3)] +interface ISpeechPhraseElements(ISpeechPhraseElementsVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + Count: *mut c_long, + ) -> HRESULT, + fn Item( + Index: c_long, + Element: *mut *mut ISpeechPhraseElement, + ) -> HRESULT, + fn get__NewEnum( + EnumVARIANT: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2890a410, 0x53a7, 0x4fb5, 0x94, 0xec, 0x06, 0xd4, 0x99, 0x8e, 0x3d, 0x02)] +interface ISpeechPhraseReplacement(ISpeechPhraseReplacementVtbl): IDispatch(IDispatchVtbl) { + fn get_DisplayAttributes( + DisplayAttributes: *mut SpeechDisplayAttributes, + ) -> HRESULT, + fn get_Text( + Text: *mut BSTR, + ) -> HRESULT, + fn get_FirstElement( + FirstElement: *mut c_long, + ) -> HRESULT, + fn get_NumberOfElements( + NumberOfElements: *mut c_long, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x38bc662f, 0x2257, 0x4525, 0x95, 0x9e, 0x20, 0x69, 0xd2, 0x59, 0x6c, 0x05)] +interface ISpeechPhraseReplacements(ISpeechPhraseReplacementsVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + Count: *mut c_long, + ) -> HRESULT, + fn Item( + Index: c_long, + Reps: *mut *mut ISpeechPhraseReplacement, + ) -> HRESULT, + fn get__NewEnum( + EnumVARIANT: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xce563d48, 0x961e, 0x4732, 0xa2, 0xe1, 0x37, 0x8a, 0x42, 0xb4, 0x30, 0xbe)] +interface ISpeechPhraseProperty(ISpeechPhrasePropertyVtbl): IDispatch(IDispatchVtbl) { + fn get_Name( + Name: *mut BSTR, + ) -> HRESULT, + fn get_Id( + Id: *mut c_long, + ) -> HRESULT, + fn get_Value( + Value: *mut VARIANT, + ) -> HRESULT, + fn get_FirstElement( + FirstElement: *mut c_long, + ) -> HRESULT, + fn get_NumberOfElements( + NumberOfElements: *mut c_long, + ) -> HRESULT, + fn get_EngineConfidence( + Confidence: *mut c_float, + ) -> HRESULT, + fn get_Confidence( + Confidence: *mut SpeechEngineConfidence, + ) -> HRESULT, + fn get_Parent( + ParentProperty: *mut *mut ISpeechPhraseProperty, + ) -> HRESULT, + fn get_Children( + Children: *mut *mut ISpeechPhraseProperties, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x08166b47, 0x102e, 0x4b23, 0xa5, 0x99, 0xbd, 0xb9, 0x8d, 0xbf, 0xd1, 0xf4)] +interface ISpeechPhraseProperties(ISpeechPhrasePropertiesVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + Count: *mut c_long, + ) -> HRESULT, + fn Item( + Index: c_long, + Property: *mut *mut ISpeechPhraseProperty, + ) -> HRESULT, + fn get__NewEnum( + EnumVARIANT: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa7bfe112, 0xa4a0, 0x48d9, 0xb6, 0x02, 0xc3, 0x13, 0x84, 0x3f, 0x69, 0x64)] +interface ISpeechPhraseRule(ISpeechPhraseRuleVtbl): IDispatch(IDispatchVtbl) { + fn get_Name( + Name: *mut BSTR, + ) -> HRESULT, + fn get_Id( + Id: *mut c_long, + ) -> HRESULT, + fn get_FirstElement( + FirstElement: *mut c_long, + ) -> HRESULT, + fn get_NumberOfElements( + NumberOfElements: *mut c_long, + ) -> HRESULT, + fn get_Parent( + Parent: *mut *mut ISpeechPhraseRule, + ) -> HRESULT, + fn get_Children( + Children: *mut *mut ISpeechPhraseRules, + ) -> HRESULT, + fn get_Confidence( + ActualConfidence: *mut SpeechEngineConfidence, + ) -> HRESULT, + fn get_EngineConfidence( + Confidence: *mut c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9047d593, 0x01dd, 0x4b72, 0x81, 0xa3, 0xe4, 0xa0, 0xca, 0x69, 0xf4, 0x07)] +interface ISpeechPhraseRules(ISpeechPhraseRulesVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + Count: *mut c_long, + ) -> HRESULT, + fn Item( + Index: c_long, + Rule: *mut *mut ISpeechPhraseRule, + ) -> HRESULT, + fn get__NewEnum( + EnumVARIANT: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3da7627a, 0xc7ae, 0x4b23, 0x87, 0x08, 0x63, 0x8c, 0x50, 0x36, 0x2c, 0x25)] +interface ISpeechLexicon(ISpeechLexiconVtbl): IDispatch(IDispatchVtbl) { + fn get_GenerationId( + GenerationId: *mut c_long, + ) -> HRESULT, + fn GetWords( + Flags: SpeechLexiconType, + GenerationID: *mut c_long, + Words: *mut *mut ISpeechLexiconWords, + ) -> HRESULT, + fn AddPronunciation( + bstrWord: BSTR, + LangId: SpeechLanguageId, + PartOfSpeech: SpeechPartOfSpeech, + bstrPronunciation: BSTR, + ) -> HRESULT, + fn AddPronunciationByPhoneIds( + bstrWord: BSTR, + LangId: SpeechLanguageId, + PartOfSpeech: SpeechPartOfSpeech, + PhoneIds: *mut VARIANT, + ) -> HRESULT, + fn RemovePronunciation( + bstrWord: BSTR, + LangId: SpeechLanguageId, + PartOfSpeech: SpeechPartOfSpeech, + bstrPronunciation: BSTR, + ) -> HRESULT, + fn RemovePronunciationByPhoneIds( + bstrWord: BSTR, + LangId: SpeechLanguageId, + PartOfSpeech: SpeechPartOfSpeech, + PhoneIds: *mut VARIANT, + ) -> HRESULT, + fn GetPronunciations( + bstrWord: BSTR, + LangId: SpeechLanguageId, + TypeFlags: SpeechLexiconType, + ppPronunciations: *mut *mut ISpeechLexiconPronunciations, + ) -> HRESULT, + fn GetGenerationChange( + GenerationID: *mut c_long, + ppWords: *mut *mut ISpeechLexiconWords, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8d199862, 0x415e, 0x47d5, 0xac, 0x4f, 0xfa, 0xa6, 0x08, 0xb4, 0x24, 0xe6)] +interface ISpeechLexiconWords(ISpeechLexiconWordsVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + Count: *mut c_long, + ) -> HRESULT, + fn Item( + Index: c_long, + Word: *mut *mut ISpeechLexiconWord, + ) -> HRESULT, + fn get__NewEnum( + EnumVARIANT: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4e5b933c, 0xc9be, 0x48ed, 0x88, 0x42, 0x1e, 0xe5, 0x1b, 0xb1, 0xd4, 0xff)] +interface ISpeechLexiconWord(ISpeechLexiconWordVtbl): IDispatch(IDispatchVtbl) { + fn get_LangId( + LangId: *mut SpeechLanguageId, + ) -> HRESULT, + fn get_Type( + WordType: *mut SpeechWordType, + ) -> HRESULT, + fn get_Word( + Word: *mut BSTR, + ) -> HRESULT, + fn get_Pronunciations( + Pronunciations: *mut *mut ISpeechLexiconPronunciations, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x72829128, 0x5682, 0x4704, 0xa0, 0xd4, 0x3e, 0x2b, 0xb6, 0xf2, 0xea, 0xd3)] +interface ISpeechLexiconPronunciations(ISpeechLexiconPronunciationsVtbl): + IDispatch(IDispatchVtbl) { + fn get_Count( + Count: *mut c_long, + ) -> HRESULT, + fn Item( + Index: c_long, + Pronunciation: *mut *mut ISpeechLexiconPronunciation, + ) -> HRESULT, + fn get__NewEnum( + EnumVARIANT: *mut *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x95252c5d, 0x9e43, 0x4f4a, 0x98, 0x99, 0x48, 0xee, 0x73, 0x35, 0x2f, 0x9f)] +interface ISpeechLexiconPronunciation(ISpeechLexiconPronunciationVtbl): IDispatch(IDispatchVtbl) { + fn get_Type( + LexiconType: *mut SpeechLexiconType, + ) -> HRESULT, + fn get_LangId( + LangId: *mut SpeechLanguageId, + ) -> HRESULT, + fn get_PartOfSpeech( + PartOfSpeech: *mut SpeechPartOfSpeech, + ) -> HRESULT, + fn get_PhoneIds( + PhoneIds: *mut VARIANT, + ) -> HRESULT, + fn get_Symbolic( + Symbolic: *mut BSTR, + ) -> HRESULT, +}} +pub const Speech_Default_Weight: c_float = DEFAULT_WEIGHT; +pub const Speech_Max_Word_Length: LONG = SP_MAX_WORD_LENGTH as i32; +pub const Speech_Max_Pron_Length: LONG = SP_MAX_PRON_LENGTH as i32; +pub const Speech_StreamPos_Asap: LONG = SP_STREAMPOS_ASAP as i32; +pub const Speech_StreamPos_RealTime: LONG = SP_STREAMPOS_REALTIME as i32; +pub const SpeechAllElements: LONG = SPPR_ALL_ELEMENTS as i32; +RIDL!{#[uuid(0x3b151836, 0xdf3a, 0x4e0a, 0x84, 0x6c, 0xd2, 0xad, 0xc9, 0x33, 0x43, 0x33)] +interface ISpeechPhraseInfoBuilder(ISpeechPhraseInfoBuilderVtbl): IDispatch(IDispatchVtbl) { + fn RestorePhraseFromMemory( + PhraseInMemory: *mut VARIANT, + PhraseInfo: *mut *mut ISpeechPhraseInfo, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc3e4f353, 0x433f, 0x43d6, 0x89, 0xa1, 0x6a, 0x62, 0xa7, 0x05, 0x4c, 0x3d)] +interface ISpeechPhoneConverter(ISpeechPhoneConverterVtbl): IDispatch(IDispatchVtbl) { + fn get_LanguageId( + LanguageId: *mut SpeechLanguageId, + ) -> HRESULT, + fn put_LanguageId( + LanguageId: SpeechLanguageId, + ) -> HRESULT, + fn PhoneToId( + Phonemes: BSTR, + IdArray: *mut VARIANT, + ) -> HRESULT, + fn IdToPhone( + IdArray: VARIANT, + Phonemes: *mut BSTR, + ) -> HRESULT, +}} +extern { + pub static CLSID_SpNotifyTranslator: CLSID; + pub static CLSID_SpObjectTokenCategory: CLSID; + pub static CLSID_SpObjectToken: CLSID; + pub static CLSID_SpResourceManager: CLSID; + pub static CLSID_SpStreamFormatConverter: CLSID; + pub static CLSID_SpMMAudioEnum: CLSID; + pub static CLSID_SpMMAudioIn: CLSID; + pub static CLSID_SpMMAudioOut: CLSID; + pub static CLSID_SpStream: CLSID; + pub static CLSID_SpVoice: CLSID; + pub static CLSID_SpSharedRecoContext: CLSID; + pub static CLSID_SpInprocRecognizer: CLSID; + pub static CLSID_SpSharedRecognizer: CLSID; + pub static CLSID_SpLexicon: CLSID; + pub static CLSID_SpUnCompressedLexicon: CLSID; + pub static CLSID_SpCompressedLexicon: CLSID; + pub static CLSID_SpPhoneConverter: CLSID; + pub static CLSID_SpNullPhoneConverter: CLSID; + pub static CLSID_SpTextSelectionInformation: CLSID; + pub static CLSID_SpPhraseInfoBuilder: CLSID; + pub static CLSID_SpAudioFormat: CLSID; + pub static CLSID_SpWaveFormatEx: CLSID; + pub static CLSID_SpInProcRecoContext: CLSID; + pub static CLSID_SpCustomStream: CLSID; + pub static CLSID_SpFileStream: CLSID; + pub static CLSID_SpMemoryStream: CLSID; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sapi53.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sapi53.rs new file mode 100644 index 0000000..7121191 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sapi53.rs @@ -0,0 +1,1823 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! SAPI 5.3 definitions +use ctypes::{c_float, c_int, c_long}; +use shared::guiddef::{CLSID, GUID}; +use shared::minwindef::{BOOL, BYTE, DWORD, LPARAM, UINT, ULONG, WORD, WPARAM}; +use shared::wtypes::{BSTR, VARIANT_BOOL}; +use um::oaidl::{IDispatch, IDispatchVtbl, VARIANT}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::urlmon::IInternetSecurityManager; +use um::winnt::{HRESULT, LPCWSTR, LPWSTR, ULONGLONG, WCHAR}; +pub use um::sapi51::{ + SPDATAKEYLOCATION, + SPDKL_DefaultLocation, + SPDKL_CurrentUser, + SPDKL_LocalMachine, + SPDKL_CurrentConfig, + SPDUI_EngineProperties, + SPDUI_AddRemoveWord, + SPDUI_UserTraining, + SPDUI_MicTraining, + SPDUI_RecoProfileProperties, + SPDUI_AudioProperties, + SPDUI_AudioVolume, + SPDUI_UserEnrollment, + SPDUI_ShareData, + SPDUI_Tutorial, + SPSTREAMFORMAT, + SPSF_Default, + SPSF_NoAssignedFormat, + SPSF_Text, + SPSF_NonStandardFormat, + SPSF_ExtendedAudioFormat, + SPSF_8kHz8BitMono, + SPSF_8kHz8BitStereo, + SPSF_8kHz16BitMono, + SPSF_8kHz16BitStereo, + SPSF_11kHz8BitMono, + SPSF_11kHz8BitStereo, + SPSF_11kHz16BitMono, + SPSF_11kHz16BitStereo, + SPSF_12kHz8BitMono, + SPSF_12kHz8BitStereo, + SPSF_12kHz16BitMono, + SPSF_12kHz16BitStereo, + SPSF_16kHz8BitMono, + SPSF_16kHz8BitStereo, + SPSF_16kHz16BitMono, + SPSF_16kHz16BitStereo, + SPSF_22kHz8BitMono, + SPSF_22kHz8BitStereo, + SPSF_22kHz16BitMono, + SPSF_22kHz16BitStereo, + SPSF_24kHz8BitMono, + SPSF_24kHz8BitStereo, + SPSF_24kHz16BitMono, + SPSF_24kHz16BitStereo, + SPSF_32kHz8BitMono, + SPSF_32kHz8BitStereo, + SPSF_32kHz16BitMono, + SPSF_32kHz16BitStereo, + SPSF_44kHz8BitMono, + SPSF_44kHz8BitStereo, + SPSF_44kHz16BitMono, + SPSF_44kHz16BitStereo, + SPSF_48kHz8BitMono, + SPSF_48kHz8BitStereo, + SPSF_48kHz16BitMono, + SPSF_48kHz16BitStereo, + SPSF_TrueSpeech_8kHz1BitMono, + SPSF_CCITT_ALaw_8kHzMono, + SPSF_CCITT_ALaw_8kHzStereo, + SPSF_CCITT_ALaw_11kHzMono, + SPSF_CCITT_ALaw_11kHzStereo, + SPSF_CCITT_ALaw_22kHzMono, + SPSF_CCITT_ALaw_22kHzStereo, + SPSF_CCITT_ALaw_44kHzMono, + SPSF_CCITT_ALaw_44kHzStereo, + SPSF_CCITT_uLaw_8kHzMono, + SPSF_CCITT_uLaw_8kHzStereo, + SPSF_CCITT_uLaw_11kHzMono, + SPSF_CCITT_uLaw_11kHzStereo, + SPSF_CCITT_uLaw_22kHzMono, + SPSF_CCITT_uLaw_22kHzStereo, + SPSF_CCITT_uLaw_44kHzMono, + SPSF_CCITT_uLaw_44kHzStereo, + SPSF_ADPCM_8kHzMono, + SPSF_ADPCM_8kHzStereo, + SPSF_ADPCM_11kHzMono, + SPSF_ADPCM_11kHzStereo, + SPSF_ADPCM_22kHzMono, + SPSF_ADPCM_22kHzStereo, + SPSF_ADPCM_44kHzMono, + SPSF_ADPCM_44kHzStereo, + SPSF_GSM610_8kHzMono, + SPSF_GSM610_11kHzMono, + SPSF_GSM610_22kHzMono, + SPSF_GSM610_44kHzMono, + SPSF_NUM_FORMATS, + SPDFID_Text, + SPDFID_WaveFormatEx, + SPREG_USER_ROOT, + SPREG_LOCAL_MACHINE_ROOT, + SPCAT_AUDIOOUT, + SPCAT_AUDIOIN, + SPCAT_VOICES, + SPCAT_RECOGNIZERS, + SPCAT_APPLEXICONS, + SPCAT_PHONECONVERTERS, + SPCAT_TEXTNORMALIZERS, + SPCAT_RECOPROFILES, + SPMMSYS_AUDIO_IN_TOKEN_ID, + SPMMSYS_AUDIO_OUT_TOKEN_ID, + SPCURRENT_USER_LEXICON_TOKEN_ID, + SPTOKENVALUE_CLSID, + SPTOKENKEY_FILES, + SPTOKENKEY_UI, + SPTOKENKEY_ATTRIBUTES +}; +pub const SPTOKENKEY_RETAINEDAUDIO: &'static str = "SecondsPerRetainedAudioEvent"; +pub const SPTOKENKEY_AUDIO_LATENCY_WARNING: &'static str = "LatencyWarningThreshold"; +pub const SPTOKENKEY_AUDIO_LATENCY_TRUNCATE: &'static str = "LatencyTruncateThreshold"; +pub const SPTOKENKEY_AUDIO_LATENCY_UPDATE_INTERVAL: &'static str = "LatencyUpdateInterval"; +pub use um::sapi51::{ + SPVOICECATEGORY_TTSRATE, + SPPROP_RESOURCE_USAGE, + SPPROP_HIGH_CONFIDENCE_THRESHOLD, + SPPROP_NORMAL_CONFIDENCE_THRESHOLD, + SPPROP_LOW_CONFIDENCE_THRESHOLD, + SPPROP_RESPONSE_SPEED, + SPPROP_COMPLEX_RESPONSE_SPEED, + SPPROP_ADAPTATION_ON, + SPPROP_PERSISTED_BACKGROUND_ADAPTATION, + SPPROP_PERSISTED_LANGUAGE_MODEL_ADAPTATION, + SPPROP_UX_IS_LISTENING, + SPTOPIC_SPELLING, + SPWILDCARD, + SPDICTATION +}; +pub const SPREG_SAFE_USER_TOKENS: &'static str + = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\UserTokens"; +pub use um::sapi51::{ + SPINFDICTATION, + SP_LOW_CONFIDENCE, + SP_NORMAL_CONFIDENCE, + SP_HIGH_CONFIDENCE, + DEFAULT_WEIGHT, + SP_MAX_WORD_LENGTH, + SP_MAX_PRON_LENGTH +}; +pub const SP_EMULATE_RESULT: ULONG = 0x40000000; +pub use um::sapi51::{ + ISpNotifyCallback, + SPNOTIFYCALLBACK, + ISpNotifySource, ISpNotifySourceVtbl, + ISpNotifySink, ISpNotifySinkVtbl, + ISpNotifyTranslator, ISpNotifyTranslatorVtbl, + ISpDataKey, ISpDataKeyVtbl, + ISpRegDataKey, ISpRegDataKeyVtbl, + ISpObjectTokenCategory, ISpObjectTokenCategoryVtbl, + ISpObjectToken, ISpObjectTokenVtbl, + ISpObjectTokenInit, ISpObjectTokenInitVtbl, + IEnumSpObjectTokens, IEnumSpObjectTokensVtbl, + ISpObjectWithToken, ISpObjectWithTokenVtbl, + ISpResourceManager, ISpResourceManagerVtbl, + SPEVENTLPARAMTYPE, + SPET_LPARAM_IS_UNDEFINED, + SPET_LPARAM_IS_TOKEN, + SPET_LPARAM_IS_OBJECT, + SPET_LPARAM_IS_POINTER, + SPET_LPARAM_IS_STRING, + SPEVENTENUM, + SPEI_UNDEFINED, + SPEI_START_INPUT_STREAM, + SPEI_END_INPUT_STREAM, + SPEI_VOICE_CHANGE, + SPEI_TTS_BOOKMARK, + SPEI_WORD_BOUNDARY, + SPEI_PHONEME, + SPEI_SENTENCE_BOUNDARY, + SPEI_VISEME, + SPEI_TTS_AUDIO_LEVEL, + SPEI_TTS_PRIVATE, + SPEI_MIN_TTS, + SPEI_MAX_TTS, + SPEI_END_SR_STREAM, + SPEI_SOUND_START, + SPEI_SOUND_END, + SPEI_PHRASE_START, + SPEI_RECOGNITION, + SPEI_HYPOTHESIS, + SPEI_SR_BOOKMARK, + SPEI_PROPERTY_NUM_CHANGE, + SPEI_PROPERTY_STRING_CHANGE, + SPEI_FALSE_RECOGNITION, + SPEI_INTERFERENCE, + SPEI_REQUEST_UI, + SPEI_RECO_STATE_CHANGE, + SPEI_ADAPTATION, + SPEI_START_SR_STREAM, + SPEI_RECO_OTHER_CONTEXT, + SPEI_SR_AUDIO_LEVEL +}; +pub const SPEI_SR_RETAINEDAUDIO: SPEVENTENUM = 51; +pub use um::sapi51::SPEI_SR_PRIVATE; +pub const SPEI_RESERVED4: SPEVENTENUM = 53; +pub const SPEI_RESERVED5: SPEVENTENUM = 54; +pub const SPEI_RESERVED6: SPEVENTENUM = 55; +pub use um::sapi51::SPEI_MIN_SR; +pub const SPEI_MAX_SR: SPEVENTENUM = 55; +pub use um::sapi51::{ + SPEI_RESERVED1, + SPEI_RESERVED2, + SPEI_RESERVED3, + SPFEI_FLAGCHECK, + SPFEI_ALL_TTS_EVENTS, + SPFEI_ALL_SR_EVENTS, + SPFEI_ALL_EVENTS, + SPFEI, + SPEVENT, + SPSERIALIZEDEVENT, + SPSERIALIZEDEVENT64 +}; +STRUCT!{struct SPEVENTEX { + eEventId: WORD, + elParamType: WORD, + ulStreamNum: ULONG, + ullAudioStreamOffset: ULONGLONG, + wParam: WPARAM, + lParam: LPARAM, + ullAudioTimeOffset: ULONGLONG, +}} +pub use um::sapi51::{ + SPINTERFERENCE, + SPINTERFERENCE_NONE, + SPINTERFERENCE_NOISE, + SPINTERFERENCE_NOSIGNAL, + SPINTERFERENCE_TOOLOUD, + SPINTERFERENCE_TOOQUIET, + SPINTERFERENCE_TOOFAST, + SPINTERFERENCE_TOOSLOW, + SPINTERFERENCE_LATENCY_WARNING, + SPINTERFERENCE_LATENCY_TRUNCATE_BEGIN, + SPINTERFERENCE_LATENCY_TRUNCATE_END, + SPENDSRSTREAMFLAGS, + SPESF_NONE, + SPESF_STREAM_RELEASED +}; +pub const SPESF_EMULATED: SPENDSRSTREAMFLAGS = 1 << 1; +pub use um::sapi51::{ + SPVFEATURE, + SPVFEATURE_STRESSED, + SPVFEATURE_EMPHASIS, + SPVISEMES, + SP_VISEME_0, + SP_VISEME_1, + SP_VISEME_2, + SP_VISEME_3, + SP_VISEME_4, + SP_VISEME_5, + SP_VISEME_6, + SP_VISEME_7, + SP_VISEME_8, + SP_VISEME_9, + SP_VISEME_10, + SP_VISEME_11, + SP_VISEME_12, + SP_VISEME_13, + SP_VISEME_14, + SP_VISEME_15, + SP_VISEME_16, + SP_VISEME_17, + SP_VISEME_18, + SP_VISEME_19, + SP_VISEME_20, + SP_VISEME_21, + SPEVENTSOURCEINFO, + ISpEventSource, ISpEventSourceVtbl, +}; +RIDL!{#[uuid(0x2373a435, 0x6a4b, 0x429e, 0xa6, 0xac, 0xd4, 0x23, 0x1a, 0x61, 0x97, 0x5b)] +interface ISpEventSource2(ISpEventSource2Vtbl): ISpEventSource(ISpEventSourceVtbl) { + fn GetEventsEx( + ulCount: ULONG, + pEventArray: *mut SPEVENTEX, + pulFetched: *mut ULONG, + ) -> HRESULT, +}} +pub use um::sapi51::{ + ISpEventSink, ISpEventSinkVtbl, + ISpStreamFormat, ISpStreamFormatVtbl, + SPFILEMODE, + SPFM_OPEN_READONLY, + SPFM_OPEN_READWRITE, + SPFM_CREATE, + SPFM_CREATE_ALWAYS, + SPFM_NUM_MODES, + ISpStream, ISpStreamVtbl, + ISpStreamFormatConverter, ISpStreamFormatConverterVtbl, + SPAUDIOSTATE, + SPAS_CLOSED, + SPAS_STOP, + SPAS_PAUSE, + SPAS_RUN, + SPAUDIOSTATUS, + SPAUDIOBUFFERINFO, + ISpAudio, ISpAudioVtbl, + ISpMMSysAudio, ISpMMSysAudioVtbl, + ISpTranscript, ISpTranscriptVtbl, + SPDISPLAYATTRIBUTES, + SPAF_ONE_TRAILING_SPACE, + SPAF_TWO_TRAILING_SPACES, + SPAF_CONSUME_LEADING_SPACES +}; +pub const SPAF_BUFFER_POSITION: SPDISPLAYATTRIBUTES = 0x10; +pub const SPAF_ALL: SPDISPLAYATTRIBUTES = 0x1f; +pub const SPAF_USER_SPECIFIED: SPDISPLAYATTRIBUTES = 0x80; +pub use um::sapi51::{ + SPPHONEID, + PSPPHONEID, + PCSPPHONEID, + SPPHRASEELEMENT, + SPPHRASERULE, + SPPHRASEPROPERTYUNIONTYPE, + SPPPUT_UNUSED, + SPPPUT_ARRAY_INDEX, + SPPHRASEPROPERTY, + SPPHRASEREPLACEMENT +}; +STRUCT!{struct SPSEMANTICERRORINFO { + ulLineNumber: ULONG, + pszScriptLine: LPWSTR, + pszSource: LPWSTR, + pszDescription: LPWSTR, + hrResultCode: HRESULT, +}} +ENUM!{enum SPSEMANTICFORMAT { + SPSMF_SAPI_PROPERTIES = 0, + SPSMF_SRGS_SEMANTICINTERPRETATION_MS = 1, + SPSMF_SRGS_SAPIPROPERTIES = 2, + SPSMF_UPS = 4, + SPSMF_SRGS_SEMANTICINTERPRETATION_W3C = 8, +}} +pub use um::sapi51::SPPHRASE as SPPHRASE_50; +// TODO: pub const SP_SPPHRASESIZE_500: usize = mem::size_of::<SPPHRASE_50>(); +STRUCT!{struct SPPHRASE { + cbSize: ULONG, + LangID: WORD, + wHomophoneGroupId: WORD, + ullGrammarID: ULONGLONG, + ftStartTime: ULONGLONG, + ullAudioStreamPosition: ULONGLONG, + ulAudioSizeBytes: ULONG, + ulRetainedSizeBytes: ULONG, + ulAudioSizeTime: ULONG, + Rule: SPPHRASERULE, + pProperties: *const SPPHRASEPROPERTY, + pElements: *const SPPHRASEELEMENT, + cReplacements: ULONG, + pReplacements: *const SPPHRASEREPLACEMENT, + SREngineID: GUID, + ulSREnginePrivateDataSize: ULONG, + pSREnginePrivateData: *const BYTE, + pSML: LPWSTR, + pSemanticErrorInfo: *mut SPSEMANTICERRORINFO, +}} +pub use um::sapi51::SPSERIALIZEDPHRASE; +STRUCT!{struct SPRULE { + pszRuleName: LPCWSTR, + ulRuleId: ULONG, + dwAttributes: DWORD, +}} +pub use um::sapi51::{ + SPVALUETYPE, + SPDF_PROPERTY, + SPDF_REPLACEMENT, + SPDF_RULE, + SPDF_DISPLAYTEXT, + SPDF_LEXICALFORM , + SPDF_PRONUNCIATION, + SPDF_AUDIO, + SPDF_ALTERNATES, + SPDF_ALL, + SPBINARYGRAMMAR, + SPPHRASERNG, + SPPR_ALL_ELEMENTS, + SP_GETWHOLEPHRASE, + SPRR_ALL_ELEMENTS, + SPSTATEHANDLE, + SPRECOEVENTFLAGS, + SPREF_AutoPause, + SPREF_Emulated +}; +pub const SPREF_SMLTimeout: SPRECOEVENTFLAGS = 1 << 2; +pub const SPREF_ExtendableParse: SPRECOEVENTFLAGS = 1 << 3; +pub const SPREF_ReSent: SPRECOEVENTFLAGS = 1 << 4; +pub const SPREF_Hypothesis: SPRECOEVENTFLAGS = 1 << 5; +pub const SPREF_FalseRecognition: SPRECOEVENTFLAGS = 1 << 6; +pub use um::sapi51::{ + SPPARTOFSPEECH, + SPPS_NotOverriden, + SPPS_Unknown, + SPPS_Noun, + SPPS_Verb, + SPPS_Modifier, + SPPS_Function, + SPPS_Interjection +}; +pub const SPPS_Noncontent: SPPARTOFSPEECH = 0x6000; +pub const SPPS_LMA: SPPARTOFSPEECH = 0x7000; +pub const SPPS_SuppressWord: SPPARTOFSPEECH = 0xf000; +pub use um::sapi51::{ + SPLEXICONTYPE, + eLEXTYPE_USER, + eLEXTYPE_APP, + eLEXTYPE_VENDORLEXICON, + eLEXTYPE_LETTERTOSOUND, + eLEXTYPE_MORPHOLOGY, + eLEXTYPE_RESERVED4, + eLEXTYPE_USER_SHORTCUT, + eLEXTYPE_RESERVED6, + eLEXTYPE_RESERVED7, + eLEXTYPE_RESERVED8, + eLEXTYPE_RESERVED9, + eLEXTYPE_RESERVED10, + eLEXTYPE_PRIVATE1, + eLEXTYPE_PRIVATE2, + eLEXTYPE_PRIVATE3, + eLEXTYPE_PRIVATE4, + eLEXTYPE_PRIVATE5, + eLEXTYPE_PRIVATE6, + eLEXTYPE_PRIVATE7, + eLEXTYPE_PRIVATE8, + eLEXTYPE_PRIVATE9, + eLEXTYPE_PRIVATE10, + eLEXTYPE_PRIVATE11, + eLEXTYPE_PRIVATE12, + eLEXTYPE_PRIVATE13, + eLEXTYPE_PRIVATE14, + eLEXTYPE_PRIVATE15, + eLEXTYPE_PRIVATE16, + eLEXTYPE_PRIVATE17, + eLEXTYPE_PRIVATE18, + eLEXTYPE_PRIVATE19, + eLEXTYPE_PRIVATE20, + SPWORDTYPE, + eWORDTYPE_ADDED, + eWORDTYPE_DELETED +}; +ENUM!{enum SPPRONUNCIATIONFLAGS { + ePRONFLAG_USED = 1 << 0, +}} +pub use um::sapi51::{ + SPWORDPRONUNCIATION, + SPWORDPRONUNCIATIONLIST, + SPWORD, + SPWORDLIST, + ISpLexicon, ISpLexiconVtbl, + ISpContainerLexicon, ISpContainerLexiconVtbl, +}; +ENUM!{enum SPSHORTCUTTYPE { + SPSHT_NotOverriden = -1i32 as u32, + SPSHT_Unknown = 0, + SPSHT_EMAIL = 0x1000, + SPSHT_OTHER = 0x2000, + SPPS_RESERVED1 = 0x3000, + SPPS_RESERVED2 = 0x4000, + SPPS_RESERVED3 = 0x5000, + SPPS_RESERVED4 = 0xf000, +}} +STRUCT!{struct SPSHORTCUTPAIR { + pNextSHORTCUTPAIR: *mut SPSHORTCUTPAIR, + LangID: WORD, + shType: SPSHORTCUTTYPE, + pszDisplay: LPWSTR, + pszSpoken: LPWSTR, +}} +STRUCT!{struct SPSHORTCUTPAIRLIST { + ulSize: ULONG, + pvBuffer: *mut BYTE, + pFirstShortcutPair: *mut SPSHORTCUTPAIR, +}} +RIDL!{#[uuid(0x3df681e2, 0xea56, 0x11d9, 0x8b, 0xde, 0xf6, 0x6b, 0xad, 0x1e, 0x3f, 0x3a)] +interface ISpShortcut(ISpShortcutVtbl): IUnknown(IUnknownVtbl) { + fn AddShortcut( + pszDisplay: LPCWSTR, + LangID: WORD, + pszSpoken: LPCWSTR, + shType: SPSHORTCUTTYPE, + ) -> HRESULT, + fn RemoveShortcut( + pszDisplay: LPCWSTR, + LangID: WORD, + pszSpoken: LPCWSTR, + shType: SPSHORTCUTTYPE, + ) -> HRESULT, + fn GetShortcuts( + LangId: WORD, + pShortcutpairList: *mut SPSHORTCUTPAIRLIST, + ) -> HRESULT, + fn GetGeneration( + pdwGeneration: *mut DWORD, + ) -> HRESULT, + fn GetWordsFromGenerationChange( + pdwGeneration: *mut DWORD, + pWordList: *mut SPWORDLIST, + ) -> HRESULT, + fn GetWords( + pdwGeneration: *mut DWORD, + pdwCookie: *mut DWORD, + pWordList: *mut SPWORDLIST, + ) -> HRESULT, + fn GetShortcutsForGeneration( + pdwGeneration: *mut DWORD, + pdwCookie: *mut DWORD, + pShortcutpairList: *mut SPSHORTCUTPAIRLIST, + ) -> HRESULT, + fn GetGenerationChange( + pdwGeneration: *mut DWORD, + pShortcutpairList: *mut SPSHORTCUTPAIRLIST, + ) -> HRESULT, +}} +pub use um::sapi51::{ISpPhoneConverter, ISpPhoneConverterVtbl}; +RIDL!{#[uuid(0x133adcd4, 0x19b4, 0x4020, 0x9f, 0xdc, 0x84, 0x2e, 0x78, 0x25, 0x3b, 0x17)] +interface ISpPhoneticAlphabetConverter(ISpPhoneticAlphabetConverterVtbl): IUnknown(IUnknownVtbl) { + fn GetLangId( + pLangID: *mut WORD, + ) -> HRESULT, + fn SetLangId( + LangID: WORD, + ) -> HRESULT, + fn SAPI2UPS( + pszSAPIId: *const SPPHONEID, + pszUPSId: *mut SPPHONEID, + cMaxLength: DWORD, + ) -> HRESULT, + fn UPS2SAPI( + pszUPSId: *const SPPHONEID, + pszSAPIId: *mut SPPHONEID, + cMaxLength: DWORD, + ) -> HRESULT, + fn GetMaxConvertLength( + cSrcLength: DWORD, + bSAPI2UPS: BOOL, + pcMaxDestLength: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb2745efd, 0x42ce, 0x48ca, 0x81, 0xf1, 0xa9, 0x6e, 0x02, 0x53, 0x8a, 0x90)] +interface ISpPhoneticAlphabetSelection(ISpPhoneticAlphabetSelectionVtbl): IUnknown(IUnknownVtbl) { + fn IsAlphabetUPS( + pfIsUPS: *mut BOOL, + ) -> HRESULT, + fn SetAlphabetToUPS( + fForceUPS: BOOL, + ) -> HRESULT, +}} +pub use um::sapi51::{ + SPVPITCH, + SPVACTIONS, + SPVA_Speak, + SPVA_Silence, + SPVA_Pronounce, + SPVA_Bookmark, + SPVA_SpellOut, + SPVA_Section, + SPVA_ParseUnknownTag, + SPVCONTEXT, + SPVSTATE, + SPRUNSTATE, + SPRS_DONE, + SPRS_IS_SPEAKING, + SPVLIMITS, + SPMIN_VOLUME, + SPMAX_VOLUME, + SPMIN_RATE, + SPMAX_RATE, + SPVPRIORITY, + SPVPRI_NORMAL, + SPVPRI_ALERT, + SPVPRI_OVER, + SPVOICESTATUS, + SPEAKFLAGS, + SPF_DEFAULT, + SPF_ASYNC, + SPF_PURGEBEFORESPEAK, + SPF_IS_FILENAME, + SPF_IS_XML, + SPF_IS_NOT_XML, + SPF_PERSIST_XML, + SPF_NLP_SPEAK_PUNC, +}; +pub const SPF_PARSE_SAPI: SPEAKFLAGS = 1 << 7; +pub const SPF_PARSE_SSML: SPEAKFLAGS = 1 << 8; +pub const SPF_PARSE_AUTODETECT: SPEAKFLAGS = 0; +pub use um::sapi51::SPF_NLP_MASK; +pub const SPF_PARSE_MASK: SPEAKFLAGS = SPF_PARSE_SAPI | SPF_PARSE_SSML; +pub const SPF_VOICE_MASK: SPEAKFLAGS = ::um::sapi51::SPF_VOICE_MASK | SPF_PARSE_MASK; +pub const SPF_UNUSED_FLAGS: SPEAKFLAGS = !SPF_VOICE_MASK; +pub use um::sapi51::{ + ISpVoice, ISpVoiceVtbl, + ISpPhrase, ISpPhraseVtbl, + ISpPhraseAlt, ISpPhraseAltVtbl, +}; +ENUM!{enum SPXMLRESULTOPTIONS { + SPXRO_SML = 0, + SPXRO_Alternates_SML = 1, +}} +RIDL!{#[uuid(0xf264da52, 0xe457, 0x4696, 0xb8, 0x56, 0xa7, 0x37, 0xb7, 0x17, 0xaf, 0x79)] +interface ISpPhrase2(ISpPhrase2Vtbl): ISpPhrase(ISpPhraseVtbl) { + fn GetXMLResult( + ppszCoMemXMLResult: *mut LPWSTR, + Options: SPXMLRESULTOPTIONS, + ) -> HRESULT, + fn GetXMLErrorInfo( + pSemanticErrorInfo: *mut SPSEMANTICERRORINFO, + ) -> HRESULT, + fn GetAudio( + ulStartElement: ULONG, + cElements: ULONG, + ppStream: *mut *mut ISpStreamFormat, + ) -> HRESULT, +}} +pub use um::sapi51::{ + SPRECORESULTTIMES, + SPSERIALIZEDRESULT, + ISpRecoResult, ISpRecoResultVtbl, +}; +ENUM!{enum SPCOMMITFLAGS { + SPCF_NONE = 0, + SPCF_ADD_TO_USER_LEXICON = 1 << 0, + SPCF_DEFINITE_CORRECTION = 1 << 1, +}} +RIDL!{#[uuid(0x27cac6c4, 0x88f2, 0x41f2, 0x88, 0x17, 0x0c, 0x95, 0xe5, 0x9f, 0x1e, 0x6e)] +interface ISpRecoResult2(ISpRecoResult2Vtbl): ISpRecoResult(ISpRecoResultVtbl) { + fn CommitAlternate( + pPhraseAlt: *mut ISpPhraseAlt, + ppNewResult: *mut *mut ISpRecoResult, + ) -> HRESULT, + fn CommitText( + ulStartElement: ULONG, + cElements: ULONG, + pszCorrectedData: LPCWSTR, + eCommitFlags: DWORD, + ) -> HRESULT, + fn SetTextFeedback( + pszFeedback: LPCWSTR, + fSuccessful: BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xae39362b, 0x45a8, 0x4074, 0x9b, 0x9e, 0xcc, 0xf4, 0x9a, 0xa2, 0xd0, 0xb6)] +interface ISpXMLRecoResult(ISpXMLRecoResultVtbl): ISpRecoResult(ISpRecoResultVtbl) { + fn GetXMLResult( + ppszCoMemXMLResult: *mut LPWSTR, + Options: SPXMLRESULTOPTIONS, + ) -> HRESULT, + fn GetXMLErrorInfo( + pSemanticErrorInfo: *mut SPSEMANTICERRORINFO, + ) -> HRESULT, +}} +pub use um::sapi51::{ + SPTEXTSELECTIONINFO, + SPWORDPRONOUNCEABLE, + SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE, + SPWP_UNKNOWN_WORD_PRONOUNCEABLE, + SPWP_KNOWN_WORD_PRONOUNCEABLE, + SPGRAMMARSTATE, + SPGS_DISABLED, + SPGS_ENABLED, + SPGS_EXCLUSIVE, + SPCONTEXTSTATE, + SPCS_DISABLED, + SPCS_ENABLED, + SPRULESTATE, + SPRS_INACTIVE, + SPRS_ACTIVE, + SPRS_ACTIVE_WITH_AUTO_PAUSE, +}; +pub const SPRS_ACTIVE_USER_DELIMITED: SPRULESTATE = 4; +pub use um::sapi51::{ + SP_STREAMPOS_ASAP, + SP_STREAMPOS_REALTIME, + SPRULETRANS_TEXTBUFFER, + SPRULETRANS_WILDCARD, + SPRULETRANS_DICTATION, + SPGRAMMARWORDTYPE, + SPWT_DISPLAY, + SPWT_LEXICAL, + SPWT_PRONUNCIATION, +}; +pub const SPWT_LEXICAL_NO_SPECIAL_CHARS: SPGRAMMARWORDTYPE = SPWT_PRONUNCIATION + 1; +pub use um::sapi51::{ + SPPROPERTYINFO, + SPCFGRULEATTRIBUTES, + SPRAF_TopLevel, + SPRAF_Active, + SPRAF_Export, + SPRAF_Import, + SPRAF_Interpreter, + SPRAF_Dynamic, +}; +pub const SPRAF_Root: SPCFGRULEATTRIBUTES = 1 << 6; +pub use um::sapi51::SPRAF_AutoPause; +pub const SPRAF_UserDelimited: SPCFGRULEATTRIBUTES = 1 << 17; +pub use um::sapi51::{ + ISpGrammarBuilder, ISpGrammarBuilderVtbl, + SPLOADOPTIONS, + SPLO_STATIC, + SPLO_DYNAMIC, + ISpRecoGrammar, ISpRecoGrammarVtbl, +}; +ENUM!{enum SPMATCHINGMODE { + AllWords = 0, + Subsequence = 1, + OrderedSubset = 3, + SubsequenceContentRequired = 5, + OrderedSubsetContentRequired = 7, +}} +ENUM!{enum PHONETICALPHABET { + PA_Ipa = 0, + PA_Ups = 1, + PA_Sapi = 2, +}} +RIDL!{#[uuid(0x8ab10026, 0x20cc, 0x4b20, 0x8c, 0x22, 0xa4, 0x9c, 0x9b, 0xa7, 0x8f, 0x60)] +interface ISpGrammarBuilder2(ISpGrammarBuilder2Vtbl): IUnknown(IUnknownVtbl) { + fn AddTextSubset( + hFromState: SPSTATEHANDLE, + hToState: SPSTATEHANDLE, + psz: LPCWSTR, + eMatchMode: SPMATCHINGMODE, + ) -> HRESULT, + fn SetPhoneticAlphabet( + phoneticALphabet: PHONETICALPHABET, + ) -> HRESULT, +}} +pub const SPRP_NORMAL: i32 = 0; // TODO: Unknown purpose and type +RIDL!{#[uuid(0x4b37bc9e, 0x9ed6, 0x44a3, 0x93, 0xd3, 0x18, 0xf0, 0x22, 0xb7, 0x9e, 0xc3)] +interface ISpRecoGrammar2(ISpRecoGrammar2Vtbl): IUnknown(IUnknownVtbl) { + fn GetRules( + ppCoMemRules: *mut *mut SPRULE, + puNumRules: *mut UINT, + ) -> HRESULT, + fn LoadCmdFromFile2( + pszFileName: LPCWSTR, + Options: SPLOADOPTIONS, + pszSharingUri: LPCWSTR, + pszBaseUri: LPCWSTR, + ) -> HRESULT, + fn LoadCmdFromMemory2( + pGrammar: *const SPBINARYGRAMMAR, + Options: SPLOADOPTIONS, + pszSharingUri: LPCWSTR, + pszBaseUri: LPCWSTR, + ) -> HRESULT, + fn SetRulePriority( + pszRuleName: LPCWSTR, + ulRuleId: ULONG, + nRulePriority: c_int, + ) -> HRESULT, + fn SetRuleWeight( + pszRuleName: LPCWSTR, + ulRuleId: ULONG, + flWeight: c_float, + ) -> HRESULT, + fn SetDictationWeight( + flWeight: c_float, + ) -> HRESULT, + fn SetGrammarLoader( + pLoader: *mut ISpeechResourceLoader, + ) -> HRESULT, + fn SetSMLSecurityManager( + pSMLSecurityManager: *mut IInternetSecurityManager, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb9ac5783, 0xfcd0, 0x4b21, 0xb1, 0x19, 0xb4, 0xf8, 0xda, 0x8f, 0xd2, 0xc3)] +interface ISpeechResourceLoader(ISpeechResourceLoaderVtbl): IDispatch(IDispatchVtbl) { + fn LoadResource( + bstrResourceUri: BSTR, + fAlwaysReload: VARIANT_BOOL, + pStream: *mut *mut IUnknown, + pbstrMIMEType: *mut BSTR, + pfModified: *mut VARIANT_BOOL, + pbstrRedirectUrl: *mut BSTR, + ) -> HRESULT, + fn GetLocalCopy( + bstrResourceUri: BSTR, + pbstrLocalPath: *mut BSTR, + pbstrMIMEType: *mut BSTR, + pbstrRedirectUrl: *mut BSTR, + ) -> HRESULT, + fn ReleaseLocalCopy( + pbstrLocalPath: BSTR, + ) -> HRESULT, +}} +pub use um::sapi51::{ + SPRECOCONTEXTSTATUS, + SPBOOKMARKOPTIONS, + SPBO_NONE, + SPBO_PAUSE, +}; +pub const SPBO_AHEAD: SPBOOKMARKOPTIONS = 1 << 1; +pub const SPBO_TIME_UNITS: SPBOOKMARKOPTIONS = 1 << 2; +pub use um::sapi51::{ + SPAUDIOOPTIONS, + SPAO_NONE, + SPAO_RETAIN_AUDIO, + ISpRecoContext, ISpRecoContextVtbl, +}; +ENUM!{enum SPGRAMMAROPTIONS { + SPGO_SAPI = 0x1, + SPGO_SRGS = 0x2, + SPGO_UPS = 0x4, + SPGO_SRGS_MS_SCRIPT = 0x8, + SPGO_SRGS_W3C_SCRIPT = 0x100, + SPGO_SRGS_STG_SCRIPT = 0x200, + SPGO_SRGS_SCRIPT = SPGO_SRGS | SPGO_SRGS_MS_SCRIPT + | SPGO_SRGS_W3C_SCRIPT | SPGO_SRGS_STG_SCRIPT, + SPGO_FILE = 0x10, + SPGO_HTTP = 0x20, + SPGO_RES = 0x40, + SPGO_OBJECT = 0x80, + SPGO_DEFAULT = 0x3fb, + SPGO_ALL = 0x3ff, +}} +ENUM!{enum SPADAPTATIONSETTINGS { + SPADS_Default = 0, + SPADS_CurrentRecognizer = 0x1, + SPADS_RecoProfile = 0x2, + SPADS_Immediate = 0x4, + SPADS_Reset = 0x8, + SPADS_HighVolumeDataSource = 0x10, +}} +ENUM!{enum SPADAPTATIONRELEVANCE { + SPAR_Unknown = 0, + SPAR_Low = 1, + SPAR_Medium = 2, + SPAR_High = 3, +}} +RIDL!{#[uuid(0xbead311c, 0x52ff, 0x437f, 0x94, 0x64, 0x6b, 0x21, 0x05, 0x4c, 0xa7, 0x3d)] +interface ISpRecoContext2(ISpRecoContext2Vtbl): IUnknown(IUnknownVtbl) { + fn SetGrammarOptions( + eGrammarOptions: DWORD, + ) -> HRESULT, + fn GetGrammarOptions( + peGrammarOptions: *mut DWORD, + ) -> HRESULT, + fn SetAdaptationData2( + pAdaptationData: LPCWSTR, + cch: ULONG, + pTopicName: LPCWSTR, + eAdaptationSettings: DWORD, + eRelevance: SPADAPTATIONRELEVANCE, + ) -> HRESULT, +}} +pub use um::sapi51::{ + ISpProperties, ISpPropertiesVtbl, + SP_MAX_LANGIDS, + SPRECOGNIZERSTATUS, + SPWAVEFORMATTYPE, + SPWF_INPUT, + SPWF_SRENGINE, + SPSTREAMFORMATTYPE, + SPRECOSTATE, + SPRST_INACTIVE, + SPRST_ACTIVE, + SPRST_ACTIVE_ALWAYS, + SPRST_INACTIVE_WITH_PURGE, + SPRST_NUM_STATES, + ISpRecognizer, ISpRecognizerVtbl, +}; +RIDL!{#[uuid(0x21b501a0, 0x0ec7, 0x46c9, 0x92, 0xc3, 0xa2, 0xbc, 0x78, 0x4c, 0x54, 0xb9)] +interface ISpSerializeState(ISpSerializeStateVtbl): IUnknown(IUnknownVtbl) { + fn GetSerializedState( + ppbData: *mut *mut BYTE, + pulSize: *mut ULONG, + dwReserved: DWORD, + ) -> HRESULT, + fn SetSerializedState( + pbData: *mut BYTE, + ulSize: ULONG, + dwReserved: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8fc6d974, 0xc81e, 0x4098, 0x93, 0xc5, 0x01, 0x47, 0xf6, 0x1e, 0xd4, 0xd3)] +interface ISpRecognizer2(ISpRecognizer2Vtbl): IUnknown(IUnknownVtbl) { + fn EmulateRecognitionEx( + pPhrase: *mut ISpPhrase, + dwCompareFlags: DWORD, + ) -> HRESULT, + fn SetTrainingState( + fDoingTraining: BOOL, + fAdaptFromTrainingData: BOOL, + ) -> HRESULT, + fn ResetAcousticModelAdaptation() -> HRESULT, +}} +STRUCT!{struct SPNORMALIZATIONLIST { + ulSize: ULONG, + ppszzNormalizedList: *mut *mut WCHAR, +}} +RIDL!{#[uuid(0xc360ce4b, 0x76d1, 0x4214, 0xad, 0x68, 0x52, 0x65, 0x7d, 0x50, 0x83, 0xda)] +interface ISpEnginePronunciation(ISpEnginePronunciationVtbl): IUnknown(IUnknownVtbl) { + fn Normalize( + pszWord: LPCWSTR, + pszLeftContext: LPCWSTR, + pszRightContext: LPCWSTR, + LangID: WORD, + pNormalizationList: *mut SPNORMALIZATIONLIST, + ) -> HRESULT, + fn GetPronunciations( + pszWord: LPCWSTR, + pszLeftContext: LPCWSTR, + pszRightContext: LPCWSTR, + LangID: WORD, + pEnginePronunciationList: *mut SPWORDPRONUNCIATIONLIST, + ) -> HRESULT, +}} +STRUCT!{struct SPDISPLAYTOKEN { + pszLexical: *const WCHAR, + pszDisplay: *const WCHAR, + bDisplayAttributes: BYTE, +}} +STRUCT!{struct SPDISPLAYPHRASE { + ulNumTokens: ULONG, + pTokens: *mut SPDISPLAYTOKEN, +}} +RIDL!{#[uuid(0xc8d7c7e2, 0x0dde, 0x44b7, 0xaf, 0xe3, 0xb0, 0xc9, 0x91, 0xfb, 0xeb, 0x5e)] +interface ISpDisplayAlternates(ISpDisplayAlternatesVtbl): IUnknown(IUnknownVtbl) { + fn GetDisplayAlternates( + pPhrase: *const SPDISPLAYPHRASE, + cRequestCount: ULONG, + ppCoMemPhrases: *mut *mut SPDISPLAYPHRASE, + pcPhrasesReturned: *mut ULONG, + ) -> HRESULT, + fn SetFullStopTrailSpace( + ulTrailSpace: ULONG, + ) -> HRESULT, +}} +pub use um::sapi51::{ + SpeechLanguageId, + DISPID_SpeechDataKey, + DISPID_SDKSetBinaryValue, + DISPID_SDKGetBinaryValue, + DISPID_SDKSetStringValue, + DISPID_SDKGetStringValue, + DISPID_SDKSetLongValue, + DISPID_SDKGetlongValue, + DISPID_SDKOpenKey, + DISPID_SDKCreateKey, + DISPID_SDKDeleteKey, + DISPID_SDKDeleteValue, + DISPID_SDKEnumKeys, + DISPID_SDKEnumValues, + DISPID_SpeechObjectToken, + DISPID_SOTId, + DISPID_SOTDataKey, + DISPID_SOTCategory, + DISPID_SOTGetDescription, + DISPID_SOTSetId, + DISPID_SOTGetAttribute, + DISPID_SOTCreateInstance, + DISPID_SOTRemove, + DISPID_SOTGetStorageFileName, + DISPID_SOTRemoveStorageFileName, + DISPID_SOTIsUISupported, + DISPID_SOTDisplayUI, + DISPID_SOTMatchesAttributes, + SpeechDataKeyLocation, + SDKLDefaultLocation, + SDKLCurrentUser, + SDKLLocalMachine, + SDKLCurrentConfig, + SpeechTokenContext, + STCInprocServer, + STCInprocHandler , + STCLocalServer, + STCRemoteServer, + STCAll, + SpeechTokenShellFolder, + STSF_AppData, + STSF_LocalAppData, + STSF_CommonAppData, + STSF_FlagCreate, + DISPID_SpeechObjectTokens, + DISPID_SOTsCount, + DISPID_SOTsItem, + DISPID_SOTs_NewEnum, + DISPID_SpeechObjectTokenCategory, + DISPID_SOTCId, + DISPID_SOTCDefault, + DISPID_SOTCSetId, + DISPID_SOTCGetDataKey, + DISPID_SOTCEnumerateTokens, + SpeechAudioFormatType, + SAFTDefault, + SAFTNoAssignedFormat, + SAFTText, + SAFTNonStandardFormat, + SAFTExtendedAudioFormat, + SAFT8kHz8BitMono, + SAFT8kHz8BitStereo, + SAFT8kHz16BitMono, + SAFT8kHz16BitStereo, + SAFT11kHz8BitMono, + SAFT11kHz8BitStereo, + SAFT11kHz16BitMono, + SAFT11kHz16BitStereo, + SAFT12kHz8BitMono, + SAFT12kHz8BitStereo, + SAFT12kHz16BitMono, + SAFT12kHz16BitStereo, + SAFT16kHz8BitMono, + SAFT16kHz8BitStereo, + SAFT16kHz16BitMono, + SAFT16kHz16BitStereo, + SAFT22kHz8BitMono, + SAFT22kHz8BitStereo, + SAFT22kHz16BitMono, + SAFT22kHz16BitStereo, + SAFT24kHz8BitMono, + SAFT24kHz8BitStereo, + SAFT24kHz16BitMono, + SAFT24kHz16BitStereo, + SAFT32kHz8BitMono, + SAFT32kHz8BitStereo, + SAFT32kHz16BitMono, + SAFT32kHz16BitStereo, + SAFT44kHz8BitMono, + SAFT44kHz8BitStereo, + SAFT44kHz16BitMono, + SAFT44kHz16BitStereo, + SAFT48kHz8BitMono, + SAFT48kHz8BitStereo, + SAFT48kHz16BitMono, + SAFT48kHz16BitStereo, + SAFTTrueSpeech_8kHz1BitMono, + SAFTCCITT_ALaw_8kHzMono, + SAFTCCITT_ALaw_8kHzStereo, + SAFTCCITT_ALaw_11kHzMono, + SAFTCCITT_ALaw_11kHzStereo, + SAFTCCITT_ALaw_22kHzMono, + SAFTCCITT_ALaw_22kHzStereo, + SAFTCCITT_ALaw_44kHzMono, + SAFTCCITT_ALaw_44kHzStereo, + SAFTCCITT_uLaw_8kHzMono, + SAFTCCITT_uLaw_8kHzStereo, + SAFTCCITT_uLaw_11kHzMono, + SAFTCCITT_uLaw_11kHzStereo, + SAFTCCITT_uLaw_22kHzMono, + SAFTCCITT_uLaw_22kHzStereo, + SAFTCCITT_uLaw_44kHzMono, + SAFTCCITT_uLaw_44kHzStereo, + SAFTADPCM_8kHzMono, + SAFTADPCM_8kHzStereo, + SAFTADPCM_11kHzMono, + SAFTADPCM_11kHzStereo, + SAFTADPCM_22kHzMono, + SAFTADPCM_22kHzStereo, + SAFTADPCM_44kHzMono, + SAFTADPCM_44kHzStereo, + SAFTGSM610_8kHzMono, + SAFTGSM610_11kHzMono, + SAFTGSM610_22kHzMono, + SAFTGSM610_44kHzMono, + DISPID_SpeechAudioFormat, + DISPID_SAFType, + DISPID_SAFGuid, + DISPID_SAFGetWaveFormatEx, + DISPID_SAFSetWaveFormatEx, + DISPID_SpeechBaseStream, + DISPID_SBSFormat, + DISPID_SBSRead, + DISPID_SBSWrite, + DISPID_SBSSeek, + SpeechStreamSeekPositionType, + SSSPTRelativeToStart, + SSSPTRelativeToCurrentPosition, + SSSPTRelativeToEnd, + DISPID_SpeechAudio, + DISPID_SAStatus, + DISPID_SABufferInfo, + DISPID_SADefaultFormat, + DISPID_SAVolume, + DISPID_SABufferNotifySize, + DISPID_SAEventHandle, + DISPID_SASetState, + SpeechAudioState, + SASClosed, + SASStop, + SASPause, + SASRun, + DISPID_SpeechMMSysAudio, + DISPID_SMSADeviceId, + DISPID_SMSALineId, + DISPID_SMSAMMHandle, + DISPID_SpeechFileStream, + DISPID_SFSOpen, + DISPID_SFSClose, + SpeechStreamFileMode, + SSFMOpenForRead, + SSFMOpenReadWrite, + SSFMCreate, + SSFMCreateForWrite, + DISPID_SpeechCustomStream, + DISPID_SCSBaseStream, + DISPID_SpeechMemoryStream, + DISPID_SMSSetData, + DISPID_SMSGetData, + DISPID_SpeechAudioStatus, + DISPID_SASFreeBufferSpace, + DISPID_SASNonBlockingIO, + DISPID_SASState, + DISPID_SASCurrentSeekPosition, + DISPID_SASCurrentDevicePosition, + DISPID_SpeechAudioBufferInfo, + DISPID_SABIMinNotification, + DISPID_SABIBufferSize, + DISPID_SABIEventBias, + DISPID_SpeechWaveFormatEx, + DISPID_SWFEFormatTag, + DISPID_SWFEChannels, + DISPID_SWFESamplesPerSec, + DISPID_SWFEAvgBytesPerSec, + DISPID_SWFEBlockAlign, + DISPID_SWFEBitsPerSample, + DISPID_SWFEExtraData, + DISPID_SpeechVoice, + DISPID_SVStatus, + DISPID_SVVoice, + DISPID_SVAudioOutput, + DISPID_SVAudioOutputStream, + DISPID_SVRate, + DISPID_SVVolume, + DISPID_SVAllowAudioOuputFormatChangesOnNextSet, + DISPID_SVEventInterests, + DISPID_SVPriority, + DISPID_SVAlertBoundary, + DISPID_SVSyncronousSpeakTimeout, + DISPID_SVSpeak, + DISPID_SVSpeakStream, + DISPID_SVPause, + DISPID_SVResume, + DISPID_SVSkip, + DISPID_SVGetVoices, + DISPID_SVGetAudioOutputs, + DISPID_SVWaitUntilDone, + DISPID_SVSpeakCompleteEvent, + DISPID_SVIsUISupported, + DISPID_SVDisplayUI, + SpeechVoicePriority, + SVPNormal, + SVPAlert, + SVPOver, + SpeechVoiceSpeakFlags, + SVSFDefault, + SVSFlagsAsync, + SVSFPurgeBeforeSpeak, + SVSFIsFilename, + SVSFIsXML, + SVSFIsNotXML, + SVSFPersistXML, + SVSFNLPSpeakPunc, +}; +pub const SVSFParseSapi: SpeechVoiceSpeakFlags = SPF_PARSE_SAPI; +pub const SVSFParseSsml: SpeechVoiceSpeakFlags = SPF_PARSE_SSML; +pub const SVSFParseAutodetect: SpeechVoiceSpeakFlags = SPF_PARSE_AUTODETECT; +pub use um::sapi51::SVSFNLPMask; +pub const SVSFParseMask: SpeechVoiceSpeakFlags = SPF_PARSE_MASK as u32; +pub use um::sapi51::{ + SVSFVoiceMask, + SVSFUnusedFlags, + SpeechVoiceEvents, + SVEStartInputStream, + SVEEndInputStream, + SVEVoiceChange, + SVEBookmark, + SVEWordBoundary, + SVEPhoneme, + SVESentenceBoundary, + SVEViseme, + SVEAudioLevel, + SVEPrivate, + SVEAllEvents, + DISPID_SpeechVoiceStatus, + DISPID_SVSCurrentStreamNumber, + DISPID_SVSLastStreamNumberQueued, + DISPID_SVSLastResult, + DISPID_SVSRunningState, + DISPID_SVSInputWordPosition, + DISPID_SVSInputWordLength, + DISPID_SVSInputSentencePosition, + DISPID_SVSInputSentenceLength, + DISPID_SVSLastBookmark, + DISPID_SVSLastBookmarkId, + DISPID_SVSPhonemeId, + DISPID_SVSVisemeId, + SpeechRunState, + SRSEDone, + SRSEIsSpeaking, + SpeechVisemeType, + SVP_0, + SVP_1, + SVP_2, + SVP_3, + SVP_4, + SVP_5, + SVP_6, + SVP_7, + SVP_8, + SVP_9, + SVP_10, + SVP_11, + SVP_12, + SVP_13, + SVP_14, + SVP_15, + SVP_16, + SVP_17, + SVP_18, + SVP_19, + SVP_20, + SVP_21, + SpeechVisemeFeature, + SVF_None, + SVF_Stressed, + SVF_Emphasis, + DISPID_SpeechVoiceEvent, + DISPID_SVEStreamStart, + DISPID_SVEStreamEnd, + DISPID_SVEVoiceChange, + DISPID_SVEBookmark, + DISPID_SVEWord, + DISPID_SVEPhoneme, + DISPID_SVESentenceBoundary, + DISPID_SVEViseme, + DISPID_SVEAudioLevel, + DISPID_SVEEnginePrivate, + DISPID_SpeechRecognizer, + DISPID_SRRecognizer, + DISPID_SRAllowAudioInputFormatChangesOnNextSet, + DISPID_SRAudioInput, + DISPID_SRAudioInputStream, + DISPID_SRIsShared, + DISPID_SRState, + DISPID_SRStatus, + DISPID_SRProfile, + DISPID_SREmulateRecognition, + DISPID_SRCreateRecoContext, + DISPID_SRGetFormat, + DISPID_SRSetPropertyNumber, + DISPID_SRGetPropertyNumber, + DISPID_SRSetPropertyString, + DISPID_SRGetPropertyString, + DISPID_SRIsUISupported, + DISPID_SRDisplayUI, + DISPID_SRGetRecognizers, + DISPID_SVGetAudioInputs, + DISPID_SVGetProfiles, + SpeechRecognizerState, + SRSInactive, + SRSActive, + SRSActiveAlways, + SRSInactiveWithPurge, + SpeechDisplayAttributes, + SDA_No_Trailing_Space, + SDA_One_Trailing_Space, + SDA_Two_Trailing_Spaces, + SDA_Consume_Leading_Spaces, + SpeechFormatType, + SFTInput, + SFTSREngine, +}; +ENUM!{enum SpeechEmulationCompareFlags { + SECFIgnoreCase = 0x1, + SECFIgnoreKanaType = 0x10000, + SECFIgnoreWidth = 0x20000, + SECFNoSpecialChars = 0x20000000, + SECFEmulateResult = 0x40000000, + SECFDefault = SECFIgnoreCase | SECFIgnoreKanaType | SECFIgnoreWidth, +}} +pub use um::sapi51::{ + DISPID_SpeechRecognizerStatus, + DISPID_SRSAudioStatus, + DISPID_SRSCurrentStreamPosition, + DISPID_SRSCurrentStreamNumber, + DISPID_SRSNumberOfActiveRules, + DISPID_SRSClsidEngine, + DISPID_SRSSupportedLanguages, + DISPID_SpeechRecoContext, + DISPID_SRCRecognizer, + DISPID_SRCAudioInInterferenceStatus, + DISPID_SRCRequestedUIType, + DISPID_SRCVoice, + DISPID_SRAllowVoiceFormatMatchingOnNextSet, + DISPID_SRCVoicePurgeEvent, + DISPID_SRCEventInterests, + DISPID_SRCCmdMaxAlternates, + DISPID_SRCState, + DISPID_SRCRetainedAudio, + DISPID_SRCRetainedAudioFormat, + DISPID_SRCPause, + DISPID_SRCResume, + DISPID_SRCCreateGrammar, + DISPID_SRCCreateResultFromMemory, + DISPID_SRCBookmark, + DISPID_SRCSetAdaptationData, + SpeechRetainedAudioOptions, + SRAONone, + SRAORetainAudio, + SpeechBookmarkOptions, + SBONone, + SBOPause, + SpeechInterference, + SINone, + SINoise, + SINoSignal, + SITooLoud, + SITooQuiet, + SITooFast, + SITooSlow, + SpeechRecoEvents, + SREStreamEnd, + SRESoundStart, + SRESoundEnd, + SREPhraseStart, + SRERecognition, + SREHypothesis, + SREBookmark, + SREPropertyNumChange, + SREPropertyStringChange, + SREFalseRecognition, + SREInterference, + SRERequestUI, + SREStateChange, + SREAdaptation, + SREStreamStart, + SRERecoOtherContext, + SREAudioLevel, + SREPrivate, + SREAllEvents, + SpeechRecoContextState, + SRCS_Disabled, + SRCS_Enabled, + DISPIDSPRG, + DISPID_SRGId, + DISPID_SRGRecoContext, + DISPID_SRGState, + DISPID_SRGRules, + DISPID_SRGReset, + DISPID_SRGCommit, + DISPID_SRGCmdLoadFromFile, + DISPID_SRGCmdLoadFromObject, + DISPID_SRGCmdLoadFromResource, + DISPID_SRGCmdLoadFromMemory, + DISPID_SRGCmdLoadFromProprietaryGrammar, + DISPID_SRGCmdSetRuleState, + DISPID_SRGCmdSetRuleIdState, + DISPID_SRGDictationLoad, + DISPID_SRGDictationUnload, + DISPID_SRGDictationSetState, + DISPID_SRGSetWordSequenceData, + DISPID_SRGSetTextSelection, + DISPID_SRGIsPronounceable, + SpeechLoadOption, + SLOStatic, + SLODynamic, + SpeechWordPronounceable, + SWPUnknownWordUnpronounceable, + SWPUnknownWordPronounceable, + SWPKnownWordPronounceable, + SpeechGrammarState, + SGSEnabled, + SGSDisabled, + SGSExclusive, + SpeechRuleState, + SGDSInactive, + SGDSActive, + SGDSActiveWithAutoPause, +}; +pub const SGDSActiveUserDelimited: SpeechRuleState = SPRS_ACTIVE_USER_DELIMITED; +pub use um::sapi51::{ + SpeechRuleAttributes, + SRATopLevel, + SRADefaultToActive, + SRAExport, + SRAImport, + SRAInterpreter, + SRADynamic, +}; +pub const SRARoot: SpeechRuleAttributes = SPRAF_Root; +pub use um::sapi51::{ + SpeechGrammarWordType, + SGDisplay, + SGLexical, + SGPronounciation, +}; +pub const SGLexicalNoSpecialChars: SpeechGrammarWordType = SPWT_LEXICAL_NO_SPECIAL_CHARS; +pub use um::sapi51::{ + DISPID_SpeechRecoContextEvents, + DISPID_SRCEStartStream, + DISPID_SRCEEndStream, + DISPID_SRCEBookmark, + DISPID_SRCESoundStart, + DISPID_SRCESoundEnd, + DISPID_SRCEPhraseStart, + DISPID_SRCERecognition, + DISPID_SRCEHypothesis, + DISPID_SRCEPropertyNumberChange, + DISPID_SRCEPropertyStringChange, + DISPID_SRCEFalseRecognition, + DISPID_SRCEInterference, + DISPID_SRCERequestUI, + DISPID_SRCERecognizerStateChange, + DISPID_SRCEAdaptation, + DISPID_SRCERecognitionForOtherContext, + DISPID_SRCEAudioLevel, + DISPID_SRCEEnginePrivate, + SpeechRecognitionType, + SRTStandard, + SRTAutopause, + SRTEmulated, +}; +pub const SRTSMLTimeout: SpeechRecognitionType = SPREF_SMLTimeout; +pub const SRTExtendableParse: SpeechRecognitionType = SPREF_ExtendableParse; +pub const SRTReSent: SpeechRecognitionType = SPREF_ReSent; +pub use um::sapi51::{ + DISPID_SpeechGrammarRule, + DISPID_SGRAttributes, + DISPID_SGRInitialState, + DISPID_SGRName, + DISPID_SGRId, + DISPID_SGRClear, + DISPID_SGRAddResource, + DISPID_SGRAddState, + DISPID_SpeechGrammarRules, + DISPID_SGRsCount, + DISPID_SGRsDynamic, + DISPID_SGRsAdd, + DISPID_SGRsCommit, + DISPID_SGRsCommitAndSave, + DISPID_SGRsFindRule, + DISPID_SGRsItem, + DISPID_SGRs_NewEnum, + DISPID_SpeechGrammarRuleState, + DISPID_SGRSRule, + DISPID_SGRSTransitions, + DISPID_SGRSAddWordTransition, + DISPID_SGRSAddRuleTransition, + DISPID_SGRSAddSpecialTransition, + SpeechSpecialTransitionType, + SSTTWildcard, + SSTTDictation, + SSTTTextBuffer, + DISPID_SpeechGrammarRuleStateTransitions, + DISPID_SGRSTsCount, + DISPID_SGRSTsItem, + DISPID_SGRSTs_NewEnum, + DISPID_SpeechGrammarRuleStateTransition, + DISPID_SGRSTType, + DISPID_SGRSTText, + DISPID_SGRSTRule, + DISPID_SGRSTWeight, + DISPID_SGRSTPropertyName, + DISPID_SGRSTPropertyId, + DISPID_SGRSTPropertyValue, + DISPID_SGRSTNextState, + SpeechGrammarRuleStateTransitionType, + SGRSTTEpsilon, + SGRSTTWord, + SGRSTTRule, + SGRSTTDictation, + SGRSTTWildcard, + SGRSTTTextBuffer, + DISPIDSPTSI, + DISPIDSPTSI_ActiveOffset, + DISPIDSPTSI_ActiveLength, + DISPIDSPTSI_SelectionOffset, + DISPIDSPTSI_SelectionLength, + DISPID_SpeechRecoResult, + DISPID_SRRRecoContext, + DISPID_SRRTimes, + DISPID_SRRAudioFormat, + DISPID_SRRPhraseInfo, + DISPID_SRRAlternates, + DISPID_SRRAudio, + DISPID_SRRSpeakAudio, + DISPID_SRRSaveToMemory, + DISPID_SRRDiscardResultInfo, + SpeechDiscardType, + SDTProperty, + SDTReplacement, + SDTRule, + SDTDisplayText, + SDTLexicalForm, + SDTPronunciation, + SDTAudio, + SDTAlternates, + SDTAll, +}; +ENUM!{enum DISPID_SpeechXMLRecoResult { + DISPID_SRRGetXMLResult, + DISPID_SRRGetXMLErrorInfo, +}} +ENUM!{enum DISPID_SpeechRecoResult2 { + DISPID_SRRSetTextFeedback, +}} +pub use um::sapi51::{ + DISPID_SpeechPhraseBuilder, + DISPID_SPPBRestorePhraseFromMemory, + DISPID_SpeechRecoResultTimes, + DISPID_SRRTStreamTime, + DISPID_SRRTLength, + DISPID_SRRTTickCount, + DISPID_SRRTOffsetFromStart, + DISPID_SpeechPhraseAlternate, + DISPID_SPARecoResult, + DISPID_SPAStartElementInResult, + DISPID_SPANumberOfElementsInResult, + DISPID_SPAPhraseInfo, + DISPID_SPACommit, + DISPID_SpeechPhraseAlternates, + DISPID_SPAsCount, + DISPID_SPAsItem, + DISPID_SPAs_NewEnum, + DISPID_SpeechPhraseInfo, + DISPID_SPILanguageId, + DISPID_SPIGrammarId, + DISPID_SPIStartTime, + DISPID_SPIAudioStreamPosition, + DISPID_SPIAudioSizeBytes, + DISPID_SPIRetainedSizeBytes, + DISPID_SPIAudioSizeTime, + DISPID_SPIRule, + DISPID_SPIProperties, + DISPID_SPIElements, + DISPID_SPIReplacements, + DISPID_SPIEngineId, + DISPID_SPIEnginePrivateData, + DISPID_SPISaveToMemory, + DISPID_SPIGetText, + DISPID_SPIGetDisplayAttributes, + DISPID_SpeechPhraseElement, + DISPID_SPEAudioTimeOffset, + DISPID_SPEAudioSizeTime, + DISPID_SPEAudioStreamOffset, + DISPID_SPEAudioSizeBytes, + DISPID_SPERetainedStreamOffset, + DISPID_SPERetainedSizeBytes, + DISPID_SPEDisplayText, + DISPID_SPELexicalForm, + DISPID_SPEPronunciation, + DISPID_SPEDisplayAttributes, + DISPID_SPERequiredConfidence, + DISPID_SPEActualConfidence, + DISPID_SPEEngineConfidence, + SpeechEngineConfidence, + SECLowConfidence, + SECNormalConfidence, + SECHighConfidence, + DISPID_SpeechPhraseElements, + DISPID_SPEsCount, + DISPID_SPEsItem, + DISPID_SPEs_NewEnum, + DISPID_SpeechPhraseReplacement, + DISPID_SPRDisplayAttributes, + DISPID_SPRText, + DISPID_SPRFirstElement, + DISPID_SPRNumberOfElements, + DISPID_SpeechPhraseReplacements, + DISPID_SPRsCount, + DISPID_SPRsItem, + DISPID_SPRs_NewEnum, + DISPID_SpeechPhraseProperty, + DISPID_SPPName, + DISPID_SPPId, + DISPID_SPPValue, + DISPID_SPPFirstElement, + DISPID_SPPNumberOfElements, + DISPID_SPPEngineConfidence, + DISPID_SPPConfidence, + DISPID_SPPParent, + DISPID_SPPChildren, + DISPID_SpeechPhraseProperties, + DISPID_SPPsCount, + DISPID_SPPsItem, + DISPID_SPPs_NewEnum, + DISPID_SpeechPhraseRule, + DISPID_SPRuleName, + DISPID_SPRuleId, + DISPID_SPRuleFirstElement, + DISPID_SPRuleNumberOfElements, + DISPID_SPRuleParent, + DISPID_SPRuleChildren, + DISPID_SPRuleConfidence, + DISPID_SPRuleEngineConfidence, + DISPID_SpeechPhraseRules, + DISPID_SPRulesCount, + DISPID_SPRulesItem, + DISPID_SPRules_NewEnum, + DISPID_SpeechLexicon, + DISPID_SLGenerationId, + DISPID_SLGetWords, + DISPID_SLAddPronunciation, + DISPID_SLAddPronunciationByPhoneIds, + DISPID_SLRemovePronunciation, + DISPID_SLRemovePronunciationByPhoneIds, + DISPID_SLGetPronunciations, + DISPID_SLGetGenerationChange, + SpeechLexiconType, + SLTUser, + SLTApp, + SpeechPartOfSpeech, + SPSNotOverriden, + SPSUnknown, + SPSNoun, + SPSVerb, + SPSModifier, + SPSFunction, + SPSInterjection, +}; +pub const SPSLMA: SpeechPartOfSpeech = SPPS_LMA; +pub const SPSSuppressWord: SpeechPartOfSpeech = SPPS_SuppressWord; +pub use um::sapi51::{ + DISPID_SpeechLexiconWords, + DISPID_SLWsCount, + DISPID_SLWsItem, + DISPID_SLWs_NewEnum, + SpeechWordType, + SWTAdded, + SWTDeleted, + DISPID_SpeechLexiconWord, + DISPID_SLWLangId, + DISPID_SLWType, + DISPID_SLWWord, + DISPID_SLWPronunciations, + DISPID_SpeechLexiconProns, + DISPID_SLPsCount, + DISPID_SLPsItem, + DISPID_SLPs_NewEnum, + DISPID_SpeechLexiconPronunciation, + DISPID_SLPType, + DISPID_SLPLangId, + DISPID_SLPPartOfSpeech, + DISPID_SLPPhoneIds, + DISPID_SLPSymbolic, + DISPID_SpeechPhoneConverter, + DISPID_SPCLangId, + DISPID_SPCPhoneToId, + DISPID_SPCIdToPhone, + LIBID_SpeechLib, + ISpeechDataKey, ISpeechDataKeyVtbl, + ISpeechObjectToken, ISpeechObjectTokenVtbl, + ISpeechObjectTokens, ISpeechObjectTokensVtbl, + ISpeechObjectTokenCategory, ISpeechObjectTokenCategoryVtbl, + ISpeechAudioBufferInfo, ISpeechAudioBufferInfoVtbl, + ISpeechAudioStatus, ISpeechAudioStatusVtbl, + ISpeechAudioFormat, ISpeechAudioFormatVtbl, + ISpeechWaveFormatEx, ISpeechWaveFormatExVtbl, + ISpeechBaseStream, ISpeechBaseStreamVtbl, + ISpeechFileStream, ISpeechFileStreamVtbl, + ISpeechMemoryStream, ISpeechMemoryStreamVtbl, + ISpeechCustomStream, ISpeechCustomStreamVtbl, + ISpeechAudio, ISpeechAudioVtbl, + ISpeechMMSysAudio, ISpeechMMSysAudioVtbl, + ISpeechVoice, ISpeechVoiceVtbl, + ISpeechVoiceStatus, ISpeechVoiceStatusVtbl, + _ISpeechVoiceEvents, _ISpeechVoiceEventsVtbl, + ISpeechRecognizer, ISpeechRecognizerVtbl, + ISpeechRecognizerStatus, ISpeechRecognizerStatusVtbl, + ISpeechRecoContext, ISpeechRecoContextVtbl, + ISpeechRecoGrammar, ISpeechRecoGrammarVtbl, + _ISpeechRecoContextEvents, _ISpeechRecoContextEventsVtbl, + ISpeechGrammarRule, ISpeechGrammarRuleVtbl, + ISpeechGrammarRules, ISpeechGrammarRulesVtbl, + ISpeechGrammarRuleState, ISpeechGrammarRuleStateVtbl, + ISpeechGrammarRuleStateTransition, ISpeechGrammarRuleStateTransitionVtbl, + ISpeechGrammarRuleStateTransitions, ISpeechGrammarRuleStateTransitionsVtbl, + ISpeechTextSelectionInformation, ISpeechTextSelectionInformationVtbl, + ISpeechRecoResult, ISpeechRecoResultVtbl, +}; +RIDL!{#[uuid(0x8e0a246d, 0xd3c8, 0x45de, 0x86, 0x57, 0x04, 0x29, 0x0c, 0x45, 0x8c, 0x3c)] +interface ISpeechRecoResult2(ISpeechRecoResult2Vtbl): ISpeechRecoResult(ISpeechRecoResultVtbl) { + fn SetTextFeedback( + Feedback: BSTR, + WasSuccessful: VARIANT_BOOL, + ) -> HRESULT, +}} +pub use um::sapi51::{ + ISpeechRecoResultTimes, ISpeechRecoResultTimesVtbl, + ISpeechPhraseAlternate, ISpeechPhraseAlternateVtbl, + ISpeechPhraseAlternates, ISpeechPhraseAlternatesVtbl, + ISpeechPhraseInfo, ISpeechPhraseInfoVtbl, + ISpeechPhraseElement, ISpeechPhraseElementVtbl, + ISpeechPhraseElements, ISpeechPhraseElementsVtbl, + ISpeechPhraseReplacement, ISpeechPhraseReplacementVtbl, + ISpeechPhraseReplacements, ISpeechPhraseReplacementsVtbl, + ISpeechPhraseProperty, ISpeechPhrasePropertyVtbl, + ISpeechPhraseProperties, ISpeechPhrasePropertiesVtbl, + ISpeechPhraseRule, ISpeechPhraseRuleVtbl, + ISpeechPhraseRules, ISpeechPhraseRulesVtbl, + ISpeechLexicon, ISpeechLexiconVtbl, + ISpeechLexiconWords, ISpeechLexiconWordsVtbl, + ISpeechLexiconWord, ISpeechLexiconWordVtbl, + ISpeechLexiconPronunciations, ISpeechLexiconPronunciationsVtbl, + ISpeechLexiconPronunciation, ISpeechLexiconPronunciationVtbl, + Speech_Default_Weight, + Speech_Max_Word_Length, + Speech_Max_Pron_Length, + Speech_StreamPos_Asap, + Speech_StreamPos_RealTime, + SpeechAllElements, +}; +RIDL!{#[uuid(0xaaec54af, 0x8f85, 0x4924, 0x94, 0x4d, 0xb7, 0x9d, 0x39, 0xd7, 0x2e, 0x19)] +interface ISpeechXMLRecoResult(ISpeechXMLRecoResultVtbl): + ISpeechRecoResult(ISpeechRecoResultVtbl) { + fn GetXMLResult( + Options: SPXMLRESULTOPTIONS, + pResult: *mut BSTR, + ) -> HRESULT, + fn GetXMLErrorInfo( + LineNumber: *mut c_long, + ScriptLine: *mut BSTR, + Source: *mut BSTR, + Description: *mut BSTR, + ResultCode: *mut c_long, + IsError: *mut VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6d60eb64, 0xaced, 0x40a6, 0xbb, 0xf3, 0x4e, 0x55, 0x7f, 0x71, 0xde, 0xe2)] +interface ISpeechRecoResultDispatch(ISpeechRecoResultDispatchVtbl): IDispatch(IDispatchVtbl) { + fn get_RecoContext( + RecoContext: *mut ISpeechRecoContext, + ) -> HRESULT, + fn get_Times( + Times: *mut ISpeechRecoResultTimes, + ) -> HRESULT, + fn putref_AudioFormat( + Format: *mut ISpeechAudioFormat, + ) -> HRESULT, + fn get_AudioFormat( + Format: *mut *mut ISpeechAudioFormat, + ) -> HRESULT, + fn get_PhraseInfo( + PhraseInfo: *mut *mut ISpeechPhraseInfo, + ) -> HRESULT, + fn Alternates( + RequestCount: c_long, + StartElement: c_long, + Elements: c_long, + Alternates: *mut *mut ISpeechPhraseAlternates, + ) -> HRESULT, + fn Audio( + StartElement: c_long, + Elements: c_long, + Stream: *mut *mut ISpeechMemoryStream, + ) -> HRESULT, + fn SpeakAudio( + StartElement: c_long, + Elements: c_long, + Flags: SpeechVoiceSpeakFlags, + StreamNumber: *mut c_long, + ) -> HRESULT, + fn SaveToMemory( + ResultBlock: *mut VARIANT, + ) -> HRESULT, + fn DiscardResultInfo( + ValueTypes: SpeechDiscardType, + ) -> HRESULT, + fn GetXMLResult( + Options: SPXMLRESULTOPTIONS, + pResult: *mut BSTR, + ) -> HRESULT, + fn GetXMLErrorInfo( + LineNumber: *mut c_long, + ScriptLine: *mut BSTR, + Source: *mut BSTR, + Description: *mut BSTR, + ResultCode: *mut HRESULT, + IsError: *mut VARIANT_BOOL, + ) -> HRESULT, + fn SetTextFeedback( + Feedback: BSTR, + WasSuccessful: VARIANT_BOOL, + ) -> HRESULT, +}} +pub use um::sapi51::{ + ISpeechPhraseInfoBuilder, ISpeechPhraseInfoBuilderVtbl, + ISpeechPhoneConverter, ISpeechPhoneConverterVtbl, + CLSID_SpNotifyTranslator, + CLSID_SpObjectTokenCategory, + CLSID_SpObjectToken, + CLSID_SpResourceManager, + CLSID_SpStreamFormatConverter, + CLSID_SpMMAudioEnum, + CLSID_SpMMAudioIn, + CLSID_SpMMAudioOut, + CLSID_SpStream, + CLSID_SpVoice, + CLSID_SpSharedRecoContext, + CLSID_SpInprocRecognizer, + CLSID_SpSharedRecognizer, + CLSID_SpLexicon, + CLSID_SpUnCompressedLexicon, + CLSID_SpCompressedLexicon, +}; +extern { + pub static CLSID_SpShortcut: CLSID; +} +pub use um::sapi51::CLSID_SpPhoneConverter; +extern { + pub static CLSID_SpPhoneticAlphabetConverter: CLSID; +} +pub use um::sapi51::{ + CLSID_SpNullPhoneConverter, + CLSID_SpTextSelectionInformation, + CLSID_SpPhraseInfoBuilder, + CLSID_SpAudioFormat, + CLSID_SpWaveFormatEx, + CLSID_SpInProcRecoContext, + CLSID_SpCustomStream, + CLSID_SpFileStream, + CLSID_SpMemoryStream, +}; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sapiddk.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sapiddk.rs new file mode 100644 index 0000000..8ff59b5 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sapiddk.rs @@ -0,0 +1,238 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_float, c_int, c_void}; +use shared::guiddef::CLSID; +use shared::minwindef::{BOOL, DWORD, ULONG}; +use um::sapi::*; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCWSTR, ULONGLONG, WCHAR}; +pub use um::sapiddk51::{ + SPRECOEXTENSION, + SPALTERNATESCLSID, +}; +pub const SR_LOCALIZED_DESCRIPTION: &'static str = "Description"; +pub use um::sapiddk51::{ + ISpTokenUI, ISpTokenUIVtbl, + ISpObjectTokenEnumBuilder, ISpObjectTokenEnumBuilderVtbl, + SPWORDHANDLE, + SPRULEHANDLE, + SPGRAMMARHANDLE, + SPRECOCONTEXTHANDLE, + SPPHRASERULEHANDLE, + SPPHRASEPROPERTYHANDLE, + SPTRANSITIONID, + ISpErrorLog, ISpErrorLogVtbl, + ISpGrammarCompiler, ISpGrammarCompilerVtbl, + ISpGramCompBackend, ISpGramCompBackendVtbl, + ISpITNProcessor, ISpITNProcessorVtbl, + ISpPhraseBuilder, ISpPhraseBuilderVtbl, + ISpTask, + ISpThreadTask, + ISpThreadControl, ISpThreadControlVtbl, + SPTMTHREADINFO, + ISpTaskManager, ISpTaskManagerVtbl, + SPVSKIPTYPE, + SPVST_SENTENCE, + SPVESACTIONS, + SPVES_CONTINUE, + SPVES_ABORT, + SPVES_SKIP, + SPVES_RATE, + SPVES_VOLUME, + ISpTTSEngineSite, ISpTTSEngineSiteVtbl, + SPVTEXTFRAG, + ISpTTSEngine, ISpTTSEngineVtbl, + SPWORDENTRY, + SPRULEENTRY, + SPTRANSITIONTYPE, + SPTRANSEPSILON, + SPTRANSWORD, + SPTRANSRULE, + SPTRANSTEXTBUF, + SPTRANSWILDCARD, + SPTRANSDICTATION, + SPTRANSITIONENTRY, + SPTRANSITIONPROPERTY, + SPSTATEINFO, + SPPATHENTRY, + ISpCFGInterpreterSite, ISpCFGInterpreterSiteVtbl, + ISpCFGInterpreter, ISpCFGInterpreterVtbl, + SPCFGNOTIFY, + SPCFGN_ADD, + SPCFGN_REMOVE, + SPCFGN_INVALIDATE, + SPCFGN_ACTIVATE, + SPCFGN_DEACTIVATE, + SPRESULTTYPE, + SPRT_CFG, + SPRT_SLM, + SPRT_PROPRIETARY, + SPRT_FALSE_RECOGNITION, +}; +pub const SPRT_TYPE_MASK: SPRESULTTYPE = 3; +pub const SPRT_EMULATED: SPRESULTTYPE = 1 << 3; +pub const SPRT_EXTENDABLE_PARSE: SPRESULTTYPE = 1 << 4; +pub use um::sapiddk51::{ + SPPHRASEALT, + SPRECORESULTINFO, +}; +STRUCT!{struct SPRECORESULTINFOEX { + cbSize: ULONG, + eResultType: SPRESULTTYPE, + fHypothesis: BOOL, + fProprietaryAutoPause: BOOL, + ullStreamPosStart: ULONGLONG, + ullStreamPosEnd: ULONGLONG, + hGrammar: SPGRAMMARHANDLE, + ulSizeEngineData: ULONG, + pvEngineData: *mut c_void, + pPhrase: *mut ISpPhraseBuilder, + aPhraseAlts: *mut SPPHRASEALT, + ulNumAlts: ULONG, + ullStreamTimeStart: ULONGLONG, + ullStreamTimeEnd: ULONGLONG, +}} +pub use um::sapiddk51::{ + SPWORDINFOOPT, + SPWIO_NONE, + SPWIO_WANT_TEXT, + SPRULEINFOOPT, + SPRIO_NONE, + SPPARSEINFO, + ISpSREngineSite, ISpSREngineSiteVtbl, +}; +RIDL!{#[uuid(0x7bc6e012, 0x684a, 0x493e, 0xbd, 0xd4, 0x2b, 0xf5, 0xfb, 0xf4, 0x8c, 0xfe)] +interface ISpSREngineSite2(ISpSREngineSite2Vtbl): ISpSREngineSite(ISpSREngineSiteVtbl) { + fn AddEventEx( + pEvent: *const SPEVENTEX, + hSAPIRecoContext: SPRECOCONTEXTHANDLE, + ) -> HRESULT, + fn UpdateRecoPosEx( + ullCurrentRecoPos: ULONGLONG, + ullCurrentRecoTime: ULONGLONG, + ) -> HRESULT, + fn GetRuleTransition( + ulGrammarID: ULONG, + RuleIndex: ULONG, + pTrans: *mut SPTRANSITIONENTRY, + ) -> HRESULT, + fn RecognitionEx( + pResultInfo: *const SPRECORESULTINFOEX, + ) -> HRESULT, +}} +pub use um::sapiddk51::{ + SPPROPSRC, + SPPROPSRC_RECO_INST, + SPPROPSRC_RECO_CTX, + SPPROPSRC_RECO_GRAMMAR, + ISpSREngine, ISpSREngineVtbl, +}; +RIDL!{#[uuid(0x7ba627d8, 0x33f9, 0x4375, 0x90, 0xc5, 0x99, 0x85, 0xae, 0xe5, 0xed, 0xe5)] +interface ISpSREngine2(ISpSREngine2Vtbl): ISpSREngine(ISpSREngineVtbl) { + fn PrivateCallImmediate( + pvEngineContext: *mut c_void, + pInCallFrame: *const c_void, + ulInCallFrameSize: ULONG, + ppvCoMemResponse: *mut *mut c_void, + pulResponseSize: *mut ULONG, + ) -> HRESULT, + fn SetAdaptationData2( + pvEngineContext: *mut c_void, + pAdaptationData: *const WCHAR, + cch: ULONG, + pTopicName: LPCWSTR, + eSettings: SPADAPTATIONSETTINGS, + eRelevance: SPADAPTATIONRELEVANCE, + ) -> HRESULT, + fn SetGrammarPrefix( + pvEngineGrammar: *mut c_void, + pszPrefix: LPCWSTR, + fIsPrefixRequired: BOOL, + ) -> HRESULT, + fn SetRulePriority( + hRule: SPRULEHANDLE, + pvClientRuleContext: *mut c_void, + nRulePriority: c_int, + ) -> HRESULT, + fn EmulateRecognition( + pPhrase: *mut ISpPhrase, + dwCompareFlags: DWORD, + ) -> HRESULT, + fn SetSLMWeight( + pvEngineGrammar: *mut c_void, + flWeight: c_float, + ) -> HRESULT, + fn SetRuleWeight( + hRule: SPRULEHANDLE, + pvClientRuleContext: *mut c_void, + flWeight: c_float, + ) -> HRESULT, + fn SetTrainingState( + fDoingTraining: BOOL, + fAdaptFromTrainingData: BOOL, + ) -> HRESULT, + fn ResetAcousticModelAdaptation() -> HRESULT, + fn OnLoadCFG( + pvEngineGrammar: *mut c_void, + pvGrammarData: *const SPBINARYGRAMMAR, + ulGrammarID: ULONG, + ) -> HRESULT, + fn OnUnloadCFG( + pvEngineGrammar: *mut c_void, + ulGrammarID: ULONG, + ) -> HRESULT, +}} +pub use um::sapiddk51::SPPHRASEALTREQUEST; +RIDL!{#[uuid(0xfece8294, 0x2be1, 0x408f, 0x8e, 0x68, 0x2d, 0xe3, 0x77, 0x09, 0x2f, 0x0e)] +interface ISpSRAlternates(ISpSRAlternatesVtbl): IUnknown(IUnknownVtbl) { + fn GetAlternates( + pAltRequest: *mut SPPHRASEALTREQUEST, + ppAlts: *mut *mut SPPHRASEALT, + pcAlts: *mut ULONG, + ) -> HRESULT, + fn Commit( + pAltRequest: *mut SPPHRASEALTREQUEST, + pAlt: *mut SPPHRASEALT, + ppvResultExtra: *mut c_void, + pcbResultExtra: *mut ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf338f437, 0xcb33, 0x4020, 0x9c, 0xab, 0xc7, 0x1f, 0xf9, 0xce, 0x12, 0xd3)] +interface ISpSRAlternates2(ISpSRAlternates2Vtbl): ISpSRAlternates(ISpSRAlternatesVtbl) { + fn CommitText( + pAltRequest: *mut SPPHRASEALTREQUEST, + pcszNewText: LPCWSTR, + commitFlags: SPCOMMITFLAGS, + ) -> HRESULT, +}} +pub use um::sapiddk51::{_ISpPrivateEngineCall, _ISpPrivateEngineCallVtbl}; +RIDL!{#[uuid(0xdefd682a, 0xfe0a, 0x42b9, 0xbf, 0xa1, 0x56, 0xd3, 0xd6, 0xce, 0xcf, 0xaf)] +interface ISpPrivateEngineCallEx(ISpPrivateEngineCallExVtbl): IUnknown(IUnknownVtbl) { + fn CallEngineSynchronize( + pInFrame: *const c_void, + ulInFrameSize: ULONG, + ppCoMemOutFrame: *mut *mut c_void, + pulOutFrameSize: *mut ULONG, + ) -> HRESULT, + fn CallEngineImmediate( + pInFrame: *const c_void, + ulInFrameSize: ULONG, + ppCoMemOutFrame: *mut *mut c_void, + pulOutFrameSize: *mut ULONG, + ) -> HRESULT, +}} +pub use um::sapiddk51::{ + LIBID_SpeechDDKLib, + CLSID_SpDataKey, + CLSID_SpObjectTokenEnum, + CLSID_SpPhraseBuilder, + CLSID_SpITNProcessor, + CLSID_SpGrammarCompiler, +}; +extern { + pub static CLSID_SpW3CGrammarCompiler: CLSID; +} +pub use um::sapiddk51::CLSID_SpGramCompBackend; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sapiddk51.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sapiddk51.rs new file mode 100644 index 0000000..0607ceb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sapiddk51.rs @@ -0,0 +1,651 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_char, c_float, c_long, c_void}; +use shared::guiddef::{CLSID, GUID, IID, REFGUID}; +use shared::minwindef::{BOOL, BYTE, DWORD, ULONG, USHORT, WORD}; +use shared::mmreg::WAVEFORMATEX; +use shared::windef::HWND; +use um::oaidl::VARIANT; +use um::objidlbase::IStream; +use um::sapi::*; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, LONG, LPCWSTR, LPWSTR, PVOID, ULONGLONG, WCHAR}; +pub const SPRECOEXTENSION: &'static str = "RecoExtension"; +pub const SPALTERNATESCLSID: &'static str = "AlternatesCLSID"; +RIDL!{#[uuid(0xf8e690f0, 0x39cb, 0x4843, 0xb8, 0xd7, 0xc8, 0x46, 0x96, 0xe1, 0x11, 0x9d)] +interface ISpTokenUI(ISpTokenUIVtbl): IUnknown(IUnknownVtbl) { + fn IsUISupported( + pszTypeOfUI: LPCWSTR, + pvExtraData: *mut c_void, + cbExtraData: ULONG, + punkObject: *mut IUnknown, + pfSupported: *mut BOOL, + ) -> HRESULT, + fn DisplayUI( + hwndParent: HWND, + pszTitle: LPCWSTR, + pszTypeOfUI: LPCWSTR, + pvExtraData: *mut c_void, + cbExtraData: ULONG, + pToken: *mut ISpObjectToken, + punkObject: *mut IUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x06b64f9f, 0x7fda, 0x11d2, 0xb4, 0xf2, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] +interface ISpObjectTokenEnumBuilder(ISpObjectTokenEnumBuilderVtbl): + IEnumSpObjectTokens(IEnumSpObjectTokensVtbl) { + fn SetAttribs( + pszReqAttribs: LPCWSTR, + pszOptAttribs: LPCWSTR, + ) -> HRESULT, + fn AddTokens( + cTokens: ULONG, + pToken: *mut *mut ISpObjectToken, + ) -> HRESULT, + fn AddTokensFromDataKey( + pDataKey: *mut ISpDataKey, + pszSubKey: LPCWSTR, + pszCategoryId: LPCWSTR, + ) -> HRESULT, + fn AddTokensFromTokenEnum( + pTokenEnum: *mut IEnumSpObjectTokens, + ) -> HRESULT, + fn Sort( + pszTokenIdToListFirst: LPCWSTR, + ) -> HRESULT, +}} +DECLARE_HANDLE!{SPWORDHANDLE, SPWORDHANDLE__} +DECLARE_HANDLE!{SPRULEHANDLE, SPRULEHANDLE__} +DECLARE_HANDLE!{SPGRAMMARHANDLE, SPGRAMMARHANDLE__} +DECLARE_HANDLE!{SPRECOCONTEXTHANDLE, SPRECOCONTEXTHANDLE__} +DECLARE_HANDLE!{SPPHRASERULEHANDLE, SPPHRASERULEHANDLE__} +DECLARE_HANDLE!{SPPHRASEPROPERTYHANDLE, SPPHRASEPROPERTYHANDLE__} +DECLARE_HANDLE!{SPTRANSITIONID, SPTRANSITIONID__} +RIDL!{#[uuid(0xf4711347, 0xe608, 0x11d2, 0xa0, 0x86, 0x00, 0xc0, 0x4f, 0x8e, 0xf9, 0xb5)] +interface ISpErrorLog(ISpErrorLogVtbl): IUnknown(IUnknownVtbl) { + fn AddError( + lLineNumber: c_long, + hr: HRESULT, + pszDescription: LPCWSTR, + pszHelpFile: LPCWSTR, + dwHelpContext: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb1e29d58, 0xa675, 0x11d2, 0x83, 0x02, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +interface ISpGrammarCompiler(ISpGrammarCompilerVtbl): IUnknown(IUnknownVtbl) { + fn CompileStream( + pSource: *mut IStream, + pDest: *mut IStream, + pHeader: *mut IStream, + pReserved: *mut IUnknown, + pErrorLog: *mut ISpErrorLog, + dwFlags: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3ddca27c, 0x665c, 0x4786, 0x9f, 0x97, 0x8c, 0x90, 0xc3, 0x48, 0x8b, 0x61)] +interface ISpGramCompBackend(ISpGramCompBackendVtbl): ISpGrammarBuilder(ISpGrammarBuilderVtbl) { + fn SetSaveObjects( + pStream: *mut IStream, + pErrorLog: *mut ISpErrorLog, + ) -> HRESULT, + fn InitFromBinaryGrammar( + pBinaryData: *const SPBINARYGRAMMAR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x12d7360f, 0xa1c9, 0x11d3, 0xbc, 0x90, 0x00, 0xc0, 0x4f, 0x72, 0xdf, 0x9f)] +interface ISpITNProcessor(ISpITNProcessorVtbl): IUnknown(IUnknownVtbl) { + fn LoadITNGrammar( + pszCLSID: LPWSTR, + ) -> HRESULT, + fn ITNPhrase( + pPhrase: *mut ISpPhraseBuilder, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x88a3342a, 0x0bed, 0x4834, 0x92, 0x2b, 0x88, 0xd4, 0x31, 0x73, 0x16, 0x2f)] +interface ISpPhraseBuilder(ISpPhraseBuilderVtbl): ISpPhrase(ISpPhraseVtbl) { + fn InitFromPhrase( + pPhrase: *const SPPHRASE, + ) -> HRESULT, + fn InitFromSerializedPhrase( + pPhrase: *const SPSERIALIZEDPHRASE, + ) -> HRESULT, + fn AddElements( + cElements: ULONG, + pElement: *const SPPHRASEELEMENT, + ) -> HRESULT, + fn AddRules( + hParent: SPPHRASERULEHANDLE, + pRule: *const SPPHRASERULE, + phNewRule: *mut SPPHRASERULEHANDLE, + ) -> HRESULT, + fn AddProperties( + hParent: SPPHRASEPROPERTYHANDLE, + pProperty: *const SPPHRASEPROPERTY, + phNewProperty: *mut SPPHRASEPROPERTYHANDLE, + ) -> HRESULT, + fn AddReplacements( + cReplacements: ULONG, + pReplacements: *const SPPHRASEREPLACEMENT, + ) -> HRESULT, +}} +pub type ISpTask = *mut c_void; +pub type ISpThreadTask = *mut c_void; +RIDL!{#[uuid(0xa6be4d73, 0x4403, 0x4358, 0xb2, 0x2d, 0x03, 0x46, 0xe2, 0x3b, 0x17, 0x64)] +interface ISpThreadControl(ISpThreadControlVtbl): ISpNotifySink(ISpNotifySinkVtbl) { + fn StartThread( + dwFlags: DWORD, + phwnd: *mut HWND, + ) -> HRESULT, + fn WaitForThreadDone( + fForceStop: BOOL, + phrThreadResult: *mut HRESULT, + msTimeOut: ULONG, + ) -> HRESULT, + fn TerminateThread() -> HRESULT, + fn ThreadHandle() -> HANDLE, + fn ThreadId() -> DWORD, + fn NotifyEvent() -> HANDLE, + fn WindowHandle() -> HWND, + fn ThreadCompleteEvent() -> HANDLE, + fn ExitThreadEvent() -> HANDLE, +}} +STRUCT!{struct SPTMTHREADINFO { + lPoolSize: c_long, + lPriority: c_long, + ulConcurrencyLimit: ULONG, + ulMaxQuickAllocThreads: ULONG, +}} +RIDL!{#[uuid(0x2baeef81, 0x2ca3, 0x4331, 0x98, 0xf3, 0x26, 0xec, 0x5a, 0xbe, 0xfb, 0x03)] +interface ISpTaskManager(ISpTaskManagerVtbl): IUnknown(IUnknownVtbl) { + fn SetThreadPoolInfo( + pPoolInfo: *const SPTMTHREADINFO, + ) -> HRESULT, + fn GetThreadPoolInfo( + pPoolInfo: *mut SPTMTHREADINFO, + ) -> HRESULT, + fn QueueTask( + pTask: *mut ISpTask, + pvTaskData: *mut c_void, + hCompEvent: HANDLE, + pdwGroupId: *mut DWORD, + pTaskID: *mut DWORD, + ) -> HRESULT, + fn CreateReoccurringTask( + pTask: *mut ISpTask, + pvTaskData: *mut c_void, + hCompEvent: HANDLE, + ppTaskCtrl: *mut *mut ISpNotifySink, + ) -> HRESULT, + fn CreateThreadControl( + pTask: *mut ISpThreadTask, + pvTaskData: *mut c_void, + nPriority: c_long, + ppTaskCtrl: *mut *mut ISpThreadControl, + ) -> HRESULT, + fn TerminateTask( + dwGroupId: DWORD, + ulWaitPeriod: ULONG, + ) -> HRESULT, +}} +ENUM!{enum SPVSKIPTYPE { + SPVST_SENTENCE = 1 << 0, +}} +ENUM!{enum SPVESACTIONS { + SPVES_CONTINUE = 0, + SPVES_ABORT = 1 << 0, + SPVES_SKIP = 1 << 1, + SPVES_RATE = 1 << 2, + SPVES_VOLUME = 1 << 3, +}} +RIDL!{#[uuid(0x9880499b, 0xcce9, 0x11d2, 0xb5, 0x03, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] +interface ISpTTSEngineSite(ISpTTSEngineSiteVtbl): ISpEventSink(ISpEventSinkVtbl) { + fn GetActions() -> DWORD, + fn Write( + pBuff: *const c_void, + cb: ULONG, + pcbWritten: *mut ULONG, + ) -> HRESULT, + fn GetRate( + pRateAdjust: *mut c_long, + ) -> HRESULT, + fn GetVolume(pusVolume: *mut USHORT, + ) -> HRESULT, + fn GetSkipInfo( + peType: *mut SPVSKIPTYPE, + plNumItems: *mut c_long, + ) -> HRESULT, + fn CompleteSkip( + ulNumSkipped: c_long, + ) -> HRESULT, +}} +STRUCT!{struct SPVTEXTFRAG { + pNext: *mut SPVTEXTFRAG, + State: SPVSTATE, + pTextStart: LPCWSTR, + ulTextLen: ULONG, + ulTextSrcOffset: ULONG, +}} +RIDL!{#[uuid(0xa74d7c8e, 0x4cc5, 0x4f2f, 0xa6, 0xeb, 0x80, 0x4d, 0xee, 0x18, 0x50, 0x0e)] +interface ISpTTSEngine(ISpTTSEngineVtbl): IUnknown(IUnknownVtbl) { + fn Speak( + dwSpeakFlags: DWORD, + rguidFormatId: REFGUID, + pWaveFormatEx: *const WAVEFORMATEX, + pTextFragList: *const SPVTEXTFRAG, + pOutputSite: *mut ISpTTSEngineSite, + ) -> HRESULT, + fn GetOutputFormat( + pTargetFmtId: *const GUID, + pTargetWaveFormatEx: *const WAVEFORMATEX, + pOutputFormatId: *mut GUID, + ppCoMemOutputWaveFormatEx: *mut WAVEFORMATEX, + ) -> HRESULT, +}} +STRUCT!{struct SPWORDENTRY { + hWord: SPWORDHANDLE, + LangID: WORD, + pszDisplayText: *mut WCHAR, + pszLexicalForm: *mut WCHAR, + aPhoneId: *mut SPPHONEID, + pvClientContext: *mut c_void, +}} +STRUCT!{struct SPRULEENTRY { + hRule: SPRULEHANDLE, + hInitialState: SPSTATEHANDLE, + Attributes: DWORD, + pvClientRuleContext: *mut c_void, + pvClientGrammarContext: *mut c_void, +}} +ENUM!{enum SPTRANSITIONTYPE { + SPTRANSEPSILON = 0, + SPTRANSWORD, + SPTRANSRULE, + SPTRANSTEXTBUF, + SPTRANSWILDCARD, + SPTRANSDICTATION, +}} +STRUCT!{struct SPTRANSITIONENTRY_u_s1 { + hRuleInitialState: SPSTATEHANDLE, + hRule: SPRULEHANDLE, + pvClientRuleContext: *mut c_void, +}} +STRUCT!{struct SPTRANSITIONENTRY_u_s2 { + hWord: SPWORDHANDLE, + pvClientWordContext: *mut c_void, +}} +UNION!{union SPTRANSITIONENTRY_u { + [usize; 3], + s1 s1_mut: SPTRANSITIONENTRY_u_s1, + s2 s2_mut: SPTRANSITIONENTRY_u_s2, + pvGrammarCookie pvGrammarCookie_mut: *mut c_void, +}} +STRUCT!{struct SPTRANSITIONENTRY { + ID: SPTRANSITIONID, + hNextState: SPSTATEHANDLE, + Type: BYTE, + RequiredConfidence: c_char, + fHasProperty: DWORD, + Weight: c_float, + u: SPTRANSITIONENTRY_u, +}} +STRUCT!{struct SPTRANSITIONPROPERTY { + pszName: LPCWSTR, + ulId: ULONG, + pszValue: LPCWSTR, + vValue: VARIANT, +}} +STRUCT!{struct SPSTATEINFO { + cAllocatedEntries: ULONG, + pTransitions: *mut SPTRANSITIONENTRY, + cEpsilons: ULONG, + cRules: ULONG, + cWords: ULONG, + cSpecialTransitions: ULONG, +}} +STRUCT!{struct SPPATHENTRY { + hTransition: SPTRANSITIONID, + elem: SPPHRASEELEMENT, +}} +RIDL!{#[uuid(0x6a6ffad8, 0x78b6, 0x473d, 0xb8, 0x44, 0x98, 0x15, 0x2e, 0x4f, 0xb1, 0x6b)] +interface ISpCFGInterpreterSite(ISpCFGInterpreterSiteVtbl): IUnknown(IUnknownVtbl) { + fn AddTextReplacement( + pReplace: *mut SPPHRASEREPLACEMENT, + ) -> HRESULT, + fn AddProperty( + pProperty: *const SPPHRASEPROPERTY, + ) -> HRESULT, + fn GetResourceValue( + pszResourceName: LPCWSTR, + ppCoMemResource: *mut LPWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf3d3f926, 0x11fc, 0x11d3, 0xbb, 0x97, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +interface ISpCFGInterpreter(ISpCFGInterpreterVtbl): IUnknown(IUnknownVtbl) { + fn InitGrammar( + pszGrammarName: LPCWSTR, + pvGrammarData: *mut *const c_void, + ) -> HRESULT, + fn Interpret( + pPhrase: *mut ISpPhraseBuilder, + ulFirstElement: *const ULONG, + ulCountOfElements: *const ULONG, + pSite: *mut ISpCFGInterpreterSite, + ) -> HRESULT, +}} +ENUM!{enum SPCFGNOTIFY { + SPCFGN_ADD, + SPCFGN_REMOVE, + SPCFGN_INVALIDATE, + SPCFGN_ACTIVATE, + SPCFGN_DEACTIVATE, +}} +ENUM!{enum SPRESULTTYPE { + SPRT_CFG = 0, + SPRT_SLM = 1, + SPRT_PROPRIETARY = 2, + SPRT_FALSE_RECOGNITION = 1 << 2, +}} +STRUCT!{struct SPPHRASEALT { + pPhrase: *mut ISpPhraseBuilder, + ulStartElementInParent: ULONG, + cElementsInParent: ULONG, + cElementsInAlternate: ULONG, + pvAltExtra: *mut c_void, + cbAltExtra: ULONG, +}} +STRUCT!{struct SPRECORESULTINFO { + cbSize: ULONG, + eResultType: SPRESULTTYPE, + fHypothesis: BOOL, + fProprietaryAutoPause: BOOL, + ullStreamPosStart: ULONGLONG, + ullStreamPosEnd: ULONGLONG, + hGrammar: SPGRAMMARHANDLE, + ulSizeEngineData: ULONG, + pvEngineData: *mut c_void, + pPhrase: *mut ISpPhraseBuilder, + aPhraseAlts: *mut SPPHRASEALT, + ulNumAlts: ULONG, +}} +ENUM!{enum SPWORDINFOOPT { + SPWIO_NONE = 0, + SPWIO_WANT_TEXT = 1, +}} +ENUM!{enum SPRULEINFOOPT { + SPRIO_NONE = 0, +}} +STRUCT!{struct SPPARSEINFO { + cbSize: ULONG, + hRule: SPRULEHANDLE, + ullAudioStreamPosition: ULONGLONG, + ulAudioSize: ULONG, + cTransitions: ULONG, + pPath: *mut SPPATHENTRY, + SREngineID: GUID, + ulSREnginePrivateDataSize: ULONG, + pSREnginePrivateData: *const BYTE, + fHypothesis: BOOL, +}} +RIDL!{#[uuid(0x3b414aec, 0x720c, 0x4883, 0xb9, 0xef, 0x17, 0x8c, 0xd3, 0x94, 0xfb, 0x3a)] +interface ISpSREngineSite(ISpSREngineSiteVtbl): IUnknown(IUnknownVtbl) { + fn Read( + pv: *mut c_void, + cb: ULONG, + pcbRead: *mut ULONG, + ) -> HRESULT, + fn DataAvailable( + pcb: *mut ULONG, + ) -> HRESULT, + fn SetBufferNotifySize( + cbSize: ULONG, + ) -> HRESULT, + fn ParseFromTransitions( + pParseInfo: *const SPPARSEINFO, + ppNewPhrase: *mut *mut ISpPhraseBuilder, + ) -> HRESULT, + fn Recognition( + pResultInfo: *const SPRECORESULTINFO, + ) -> HRESULT, + fn AddEvent( + pEvent: *const SPEVENT, + hSAPIRecoContext: SPRECOCONTEXTHANDLE, + ) -> HRESULT, + fn Synchronize( + ullProcessedThruPos: ULONGLONG, + ) -> HRESULT, + fn GetWordInfo( + pWordEntry: *mut SPWORDENTRY, + Options: SPWORDINFOOPT, + ) -> HRESULT, + fn SetWordClientContext( + hWord: SPWORDHANDLE, + pvClientContext: *mut c_void, + ) -> HRESULT, + fn GetRuleInfo( + pRuleEntry: *mut SPRULEENTRY, + Options: SPRULEINFOOPT, + ) -> HRESULT, + fn SetRuleClientContext( + hRule: SPRULEHANDLE, + pvClientContext: *mut c_void, + ) -> HRESULT, + fn GetStateInfo( + hState: SPSTATEHANDLE, + pStateInfo: *mut SPSTATEINFO, + ) -> HRESULT, + fn GetResource( + hRule: SPRULEHANDLE, + pszResourceName: LPCWSTR, + ppCoMemResource: *mut LPWSTR, + ) -> HRESULT, + fn GetTransitionProperty( + ID: SPTRANSITIONID, + ppCoMemProperty: *mut *mut SPTRANSITIONPROPERTY, + ) -> HRESULT, + fn IsAlternate( + hRule: SPRULEHANDLE, + hAltRule: SPRULEHANDLE, + ) -> HRESULT, + fn GetMaxAlternates( + hRule: SPRULEHANDLE, + pulNumAlts: *mut ULONG, + ) -> HRESULT, + fn GetContextMaxAlternates( + hContext: SPRECOCONTEXTHANDLE, + pulNumAlts: *mut ULONG, + ) -> HRESULT, + fn UpdateRecoPos( + ullCurrentRecoPos: ULONGLONG, + ) -> HRESULT, +}} +ENUM!{enum SPPROPSRC { + SPPROPSRC_RECO_INST, + SPPROPSRC_RECO_CTX, + SPPROPSRC_RECO_GRAMMAR, +}} +RIDL!{#[uuid(0x2f472991, 0x854b, 0x4465, 0xb6, 0x13, 0xfb, 0xaf, 0xb3, 0xad, 0x8e, 0xd8)] +interface ISpSREngine(ISpSREngineVtbl): IUnknown(IUnknownVtbl) { + fn SetSite( + pSite: *mut ISpSREngineSite, + ) -> HRESULT, + fn GetInputAudioFormat( + pguidSourceFormatId: *const GUID, + pSourceWaveFormatEx: *const WAVEFORMATEX, + pguidDesiredFormatId: *mut GUID, + ppCoMemDesiredWaveFormatEx: *mut WAVEFORMATEX, + ) -> HRESULT, + fn RecognizeStream( + rguidFmtId: REFGUID, + pWaveFormatEx: *const WAVEFORMATEX, + hRequestSync: HANDLE, + hDataAvailable: HANDLE, + hExit: HANDLE, + fNewAudioStream: BOOL, + fRealTimeAudio: BOOL, + pAudioObjectToken: *mut ISpObjectToken, + ) -> HRESULT, + fn SetRecoProfile( + pProfile: *mut ISpObjectToken, + ) -> HRESULT, + fn OnCreateGrammar( + pvEngineRecoContext: *mut c_void, + hSAPIGrammar: SPGRAMMARHANDLE, + ppvEngineGrammarContext: *mut *mut c_void, + ) -> HRESULT, + fn OnDeleteGrammar( + pvEngineGrammar: *mut c_void, + ) -> HRESULT, + fn LoadProprietaryGrammar( + pvEngineGrammar: *mut c_void, + rguidParam: REFGUID, + pszStringParam: LPCWSTR, + pvDataParam: *const c_void, + ulDataSize: ULONG, + Options: SPLOADOPTIONS, + ) -> HRESULT, + fn UnloadProprietaryGrammar( + pvEngineGrammar: *mut c_void, + ) -> HRESULT, + fn SetProprietaryRuleState( + pvEngineGrammar: *mut c_void, + pszName: LPCWSTR, + pReserved: *mut c_void, + NewState: SPRULESTATE, + pcRulesChanged: *mut ULONG, + ) -> HRESULT, + fn SetProprietaryRuleIdState( + pvEngineGrammar: *mut c_void, + dwRuleId: DWORD, + NewState: SPRULESTATE, + ) -> HRESULT, + fn LoadSLM( + pvEngineGrammar: *mut c_void, + pszTopicName: LPCWSTR, + ) -> HRESULT, + fn UnloadSLM( + pvEngineGrammar: *mut c_void, + ) -> HRESULT, + fn SetSLMState( + pvEngineGrammar: *mut c_void, + NewState: SPRULESTATE, + ) -> HRESULT, + fn SetWordSequenceData( + pvEngineGrammar: *mut c_void, + pText: *const WCHAR, + cchText: ULONG, + pInfo: *const SPTEXTSELECTIONINFO, + ) -> HRESULT, + fn SetTextSelection( + pvEngineGrammar: *mut c_void, + pInfo: *const SPTEXTSELECTIONINFO, + ) -> HRESULT, + fn IsPronounceable( + pvEngineGrammar: *mut c_void, + pszWord: LPCWSTR, + pWordPronounceable: *mut SPWORDPRONOUNCEABLE, + ) -> HRESULT, + fn OnCreateRecoContext( + hSAPIRecoContext: SPRECOCONTEXTHANDLE, + ppvEngineContext: *mut *mut c_void, + ) -> HRESULT, + fn OnDeleteRecoContext( + pvEngineContext: *mut c_void, + ) -> HRESULT, + fn OnPrivateCall( + pvEngineContext: *mut c_void, + pCallFrame: PVOID, + ulCallFrameSize: ULONG, + ) -> HRESULT, + fn SetAdaptationData( + pvEngineContext: *mut c_void, + pAdaptationData: *const WCHAR, + cch: ULONG, + ) -> HRESULT, + fn SetPropertyNum( + eSrc: SPPROPSRC, + pvSrcObj: *mut c_void, + pName: *const WCHAR, + lValue: LONG, + ) -> HRESULT, + fn GetPropertyNum( + eSrc: SPPROPSRC, + pvSrcObj: *mut c_void, + pName: *const WCHAR, + lValue: *mut LONG, + ) -> HRESULT, + fn SetPropertyString( + eSrc: SPPROPSRC, + pvSrcObj: *mut c_void, + pName: LPCWSTR, + pValue: LPCWSTR, + ) -> HRESULT, + fn GetPropertyString( + eSrc: SPPROPSRC, + pvSrcObj: *mut c_void, + pName: LPCWSTR, + ppCoMemValue: *mut LPWSTR, + ) -> HRESULT, + fn SetGrammarState( + pvEngineGrammar: *mut c_void, + eGrammarState: SPGRAMMARSTATE, + ) -> HRESULT, + fn WordNotify( + Action: SPCFGNOTIFY, + cWords: ULONG, + pWords: *const SPWORDENTRY, + ) -> HRESULT, + fn RuleNotify( + Action: SPCFGNOTIFY, + cRules: ULONG, + pRules: *const SPRULEENTRY, + ) -> HRESULT, + fn PrivateCallEx( + pvEngineContext: *mut c_void, + pInCallFrame: *const c_void, + ulInCallFrameSize: ULONG, + ppvCoMemResponse: *mut *mut c_void, + pulResponseSize: *mut ULONG, + ) -> HRESULT, + fn SetContextState( + pvEngineContext: *mut c_void, + eContextState: SPCONTEXTSTATE, + ) -> HRESULT, +}} +STRUCT!{struct SPPHRASEALTREQUEST { + ulStartElement: ULONG, + cElements: ULONG, + ulRequestAltCount: ULONG, + pvResultExtra: *mut c_void, + cbResultExtra: ULONG, + pPhrase: *mut ISpPhrase, + pRecoContext: *mut ISpRecoContext, +}} +RIDL!{#[uuid(0x8e7c791e, 0x4467, 0x11d3, 0x97, 0x23, 0x00, 0xc0, 0x4f, 0x72, 0xdb, 0x08)] +interface _ISpPrivateEngineCall(_ISpPrivateEngineCallVtbl): IUnknown(IUnknownVtbl) { + fn CallEngine( + pCallFrame: *mut c_void, + ulCallFrameSize: ULONG, + ) -> HRESULT, + fn CallEngineEx( + pInFrame: *const c_void, + ulInFrameSize: ULONG, + ppCoMemOutFrame: *mut *mut c_void, + pulOutFrameSize: *mut ULONG, + ) -> HRESULT, +}} +extern { + pub static LIBID_SpeechDDKLib: IID; + pub static CLSID_SpDataKey: CLSID; +} +RIDL!{#[uuid(0xd9f6ee60, 0x58c9, 0x458b, 0x88, 0xe1, 0x2f, 0x90, 0x8f, 0xd7, 0xf8, 0x7c)] +class SpDataKey;} +extern { + pub static CLSID_SpObjectTokenEnum: CLSID; + pub static CLSID_SpPhraseBuilder: CLSID; + pub static CLSID_SpITNProcessor: CLSID; + pub static CLSID_SpGrammarCompiler: CLSID; + pub static CLSID_SpGramCompBackend: CLSID; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/schannel.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/schannel.rs new file mode 100644 index 0000000..5ec1ac0 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/schannel.rs @@ -0,0 +1,339 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Public Definitions for SCHANNEL Security Provider +use shared::guiddef::GUID; +use shared::minwindef::{BYTE, DWORD, PBYTE, WORD}; +use shared::windef::HWND; +use um::wincrypt::{ALG_ID, HCERTSTORE, HCRYPTPROV, PCCERT_CONTEXT, PCERT_NAME_BLOB}; +use um::winnt::{HRESULT, LPWSTR, PVOID, WCHAR}; +pub const UNISP_NAME: &'static str = "Microsoft Unified Security Protocol Provider"; +pub const SSL2SP_NAME: &'static str = "Microsoft SSL 2.0"; +pub const SSL3SP_NAME: &'static str = "Microsoft SSL 3.0"; +pub const TLS1SP_NAME: &'static str = "Microsoft TLS 1.0"; +pub const PCT1SP_NAME: &'static str = "Microsoft PCT 1.0"; +pub const SCHANNEL_NAME: &'static str = "Schannel"; +ENUM!{enum eTlsSignatureAlgorithm { + TlsSignatureAlgorithm_Anonymous = 0, + TlsSignatureAlgorithm_Rsa = 1, + TlsSignatureAlgorithm_Dsa = 2, + TlsSignatureAlgorithm_Ecdsa = 3, +}} +ENUM!{enum eTlsHashAlgorithm { + TlsHashAlgorithm_None = 0, + TlsHashAlgorithm_Md5 = 1, + TlsHashAlgorithm_Sha1 = 2, + TlsHashAlgorithm_Sha224 = 3, + TlsHashAlgorithm_Sha256 = 4, + TlsHashAlgorithm_Sha384 = 5, + TlsHashAlgorithm_Sha512 = 6, +}} +pub const UNISP_RPC_ID: DWORD = 14; +STRUCT!{struct SecPkgContext_RemoteCredentialInfo { + cbCertificateChain: DWORD, + pbCertificateChain: PBYTE, + cCertificates: DWORD, + fFlags: DWORD, + dwBits: DWORD, +}} +pub type PSecPkgContext_RemoteCredentialInfo = *mut SecPkgContext_RemoteCredentialInfo; +pub type SecPkgContext_RemoteCredenitalInfo = SecPkgContext_RemoteCredentialInfo; +pub type PSecPkgContext_RemoteCredenitalInfo = *mut SecPkgContext_RemoteCredentialInfo; +pub const RCRED_STATUS_NOCRED: DWORD = 0x00000000; +pub const RCRED_CRED_EXISTS: DWORD = 0x00000001; +pub const RCRED_STATUS_UNKNOWN_ISSUER: DWORD = 0x00000002; +STRUCT!{struct SecPkgContext_LocalCredentialInfo { + cbCertificateChain: DWORD, + pbCertificateChain: PBYTE, + cCertificates: DWORD, + fFlags: DWORD, + dwBits: DWORD, +}} +pub type PSecPkgContext_LocalCredentialInfo = *mut SecPkgContext_LocalCredentialInfo; +pub type SecPkgContext_LocalCredenitalInfo = SecPkgContext_LocalCredentialInfo; +pub type PSecPkgContext_LocalCredenitalInfo = *mut SecPkgContext_LocalCredentialInfo; +pub const LCRED_STATUS_NOCRED: DWORD = 0x00000000; +pub const LCRED_CRED_EXISTS: DWORD = 0x00000001; +pub const LCRED_STATUS_UNKNOWN_ISSUER: DWORD = 0x00000002; +STRUCT!{struct SecPkgContext_ClientCertPolicyResult { + dwPolicyResult: HRESULT, + guidPolicyId: GUID, +}} +pub type PSecPkgContext_ClientCertPolicyResult = *mut SecPkgContext_ClientCertPolicyResult; +STRUCT!{struct SecPkgContext_IssuerListInfoEx { + aIssuers: PCERT_NAME_BLOB, + cIssuers: DWORD, +}} +pub type PSecPkgContext_IssuerListInfoEx = *mut SecPkgContext_IssuerListInfoEx; +STRUCT!{struct SecPkgContext_ConnectionInfo { + dwProtocol: DWORD, + aiCipher: ALG_ID, + dwCipherStrength: DWORD, + aiHash: ALG_ID, + dwHashStrength: DWORD, + aiExch: ALG_ID, + dwExchStrength: DWORD, +}} +pub type PSecPkgContext_ConnectionInfo = *mut SecPkgContext_ConnectionInfo; +pub const SZ_ALG_MAX_SIZE: usize = 64; +pub const SECPKGCONTEXT_CIPHERINFO_V1: DWORD = 1; +STRUCT!{struct SecPkgContext_CipherInfo { + dwVersion: DWORD, + dwProtocol: DWORD, + dwCipherSuite: DWORD, + dwBaseCipherSuite: DWORD, + szCipherSuite: [WCHAR; SZ_ALG_MAX_SIZE], + szCipher: [WCHAR; SZ_ALG_MAX_SIZE], + dwCipherLen: DWORD, + dwCipherBlockLen: DWORD, + szHash: [WCHAR; SZ_ALG_MAX_SIZE], + dwHashLen: DWORD, + szExchange: [WCHAR; SZ_ALG_MAX_SIZE], + dwMinExchangeLen: DWORD, + dwMaxExchangeLen: DWORD, + szCertificate: [WCHAR; SZ_ALG_MAX_SIZE], + dwKeyType: DWORD, +}} +pub type PSecPkgContext_CipherInfo = *mut SecPkgContext_CipherInfo; +STRUCT!{struct SecPkgContext_EapKeyBlock { + rgbKeys: [BYTE; 128], + rgbIVs: [BYTE; 64], +}} +pub type PSecPkgContext_EapKeyBlock = *mut SecPkgContext_EapKeyBlock; +STRUCT!{struct SecPkgContext_MappedCredAttr { + dwAttribute: DWORD, + pvBuffer: PVOID, +}} +pub type PSecPkgContext_MappedCredAttr = *mut SecPkgContext_MappedCredAttr; +pub const SSL_SESSION_RECONNECT: DWORD = 1; +STRUCT!{struct SecPkgContext_SessionInfo { + dwFlags: DWORD, + cbSessionId: DWORD, + rgbSessionId: [BYTE; 32], +}} +pub type PSecPkgContext_SessionInfo = *mut SecPkgContext_SessionInfo; +STRUCT!{struct SecPkgContext_SessionAppData { + dwFlags: DWORD, + cbAppData: DWORD, + pbAppData: PBYTE, +}} +pub type PSecPkgContext_SessionAppData = *mut SecPkgContext_SessionAppData; +STRUCT!{struct SecPkgContext_EapPrfInfo { + dwVersion: DWORD, + cbPrfData: DWORD, + pbPrfData: PBYTE, +}} +pub type PSecPkgContext_EapPrfInfo = *mut SecPkgContext_EapPrfInfo; +STRUCT!{struct SecPkgContext_SupportedSignatures { + cSignatureAndHashAlgorithms: WORD, + pSignatureAndHashAlgorithms: *mut WORD, +}} +pub type PSecPkgContext_SupportedSignatures = *mut SecPkgContext_SupportedSignatures; +STRUCT!{struct SecPkgContext_Certificates { + cCertificates: DWORD, + cbCertificateChain: DWORD, + pbCertificateChain: PBYTE, +}} +pub type PSecPkgContext_Certificates = *mut SecPkgContext_Certificates; +STRUCT!{struct SecPkgContext_CertInfo { + dwVersion: DWORD, + cbSubjectName: DWORD, + pwszSubjectName: LPWSTR, + cbIssuerName: DWORD, + pwszIssuerName: LPWSTR, + dwKeySize: DWORD, +}} +pub type PSecPkgContext_CertInfo = *mut SecPkgContext_CertInfo; +pub const KERN_CONTEXT_CERT_INFO_V1: DWORD = 0x00000000; +STRUCT!{struct SecPkgContext_UiInfo { + hParentWindow: HWND, +}} +pub type PSecPkgContext_UiInfo = *mut SecPkgContext_UiInfo; +STRUCT!{struct SecPkgContext_EarlyStart { + dwEarlyStartFlags: DWORD, +}} +pub type PSecPkgContext_EarlyStart = *mut SecPkgContext_EarlyStart; +pub const ENABLE_TLS_CLIENT_EARLY_START: DWORD = 0x00000001; +pub const SCH_CRED_V1: DWORD = 0x00000001; +pub const SCH_CRED_V2: DWORD = 0x00000002; +pub const SCH_CRED_VERSION: DWORD = 0x00000002; +pub const SCH_CRED_V3: DWORD = 0x00000003; +pub const SCHANNEL_CRED_VERSION: DWORD = 0x00000004; +pub const SCHANNEL_SECRET_TYPE_CAPI: DWORD = 0x00000001; +pub const SCHANNEL_SECRET_PRIVKEY: DWORD = 0x00000002; +pub const SCH_CRED_X509_CERTCHAIN: DWORD = 0x00000001; +pub const SCH_CRED_X509_CAPI: DWORD = 0x00000002; +pub const SCH_CRED_CERT_CONTEXT: DWORD = 0x00000003; +pub enum _HMAPPER {} +STRUCT!{struct SCHANNEL_CRED { + dwVersion: DWORD, + cCreds: DWORD, + paCred: *mut PCCERT_CONTEXT, + hRootStore: HCERTSTORE, + cMappers: DWORD, + aphMappers: *mut *mut _HMAPPER, + cSupportedAlgs: DWORD, + palgSupportedAlgs: *mut ALG_ID, + grbitEnabledProtocols: DWORD, + dwMinimumCipherStrength: DWORD, + dwMaximumCipherStrength: DWORD, + dwSessionLifespan: DWORD, + dwFlags: DWORD, + dwCredFormat: DWORD, +}} +pub type PSCHANNEL_CRED = *mut SCHANNEL_CRED; +pub const SCH_CRED_FORMAT_CERT_CONTEXT: DWORD = 0x00000000; +pub const SCH_CRED_FORMAT_CERT_HASH: DWORD = 0x00000001; +pub const SCH_CRED_FORMAT_CERT_HASH_STORE: DWORD = 0x00000002; +pub const SCH_CRED_MAX_STORE_NAME_SIZE: usize = 128; +pub const SCH_CRED_MAX_SUPPORTED_ALGS: DWORD = 256; +pub const SCH_CRED_MAX_SUPPORTED_CERTS: DWORD = 100; +STRUCT!{struct SCHANNEL_CERT_HASH { + dwLength: DWORD, + dwFlags: DWORD, + hProv: HCRYPTPROV, + ShaHash: [BYTE; 20], +}} +pub type PSCHANNEL_CERT_HASH = *mut SCHANNEL_CERT_HASH; +STRUCT!{struct SCHANNEL_CERT_HASH_STORE { + dwLength: DWORD, + dwFlags: DWORD, + hProv: HCRYPTPROV, + ShaHash: [BYTE; 20], + pwszStoreName: [WCHAR; SCH_CRED_MAX_STORE_NAME_SIZE], +}} +pub type PSCHANNEL_CERT_HASH_STORE = *mut SCHANNEL_CERT_HASH_STORE; +pub const SCH_MACHINE_CERT_HASH: DWORD = 0x00000001; +pub const SCH_CRED_NO_SYSTEM_MAPPER: DWORD = 0x00000002; +pub const SCH_CRED_NO_SERVERNAME_CHECK: DWORD = 0x00000004; +pub const SCH_CRED_MANUAL_CRED_VALIDATION: DWORD = 0x00000008; +pub const SCH_CRED_NO_DEFAULT_CREDS: DWORD = 0x00000010; +pub const SCH_CRED_AUTO_CRED_VALIDATION: DWORD = 0x00000020; +pub const SCH_CRED_USE_DEFAULT_CREDS: DWORD = 0x00000040; +pub const SCH_CRED_DISABLE_RECONNECTS: DWORD = 0x00000080; +pub const SCH_CRED_REVOCATION_CHECK_END_CERT: DWORD = 0x00000100; +pub const SCH_CRED_REVOCATION_CHECK_CHAIN: DWORD = 0x00000200; +pub const SCH_CRED_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT: DWORD = 0x00000400; +pub const SCH_CRED_IGNORE_NO_REVOCATION_CHECK: DWORD = 0x00000800; +pub const SCH_CRED_IGNORE_REVOCATION_OFFLINE: DWORD = 0x00001000; +pub const SCH_CRED_RESTRICTED_ROOTS: DWORD = 0x00002000; +pub const SCH_CRED_REVOCATION_CHECK_CACHE_ONLY: DWORD = 0x00004000; +pub const SCH_CRED_CACHE_ONLY_URL_RETRIEVAL: DWORD = 0x00008000; +pub const SCH_CRED_MEMORY_STORE_CERT: DWORD = 0x00010000; +pub const SCH_CRED_CACHE_ONLY_URL_RETRIEVAL_ON_CREATE: DWORD = 0x00020000; +pub const SCH_SEND_ROOT_CERT: DWORD = 0x00040000; +pub const SCH_CRED_SNI_CREDENTIAL: DWORD = 0x00080000; +pub const SCH_CRED_SNI_ENABLE_OCSP: DWORD = 0x00100000; +pub const SCH_SEND_AUX_RECORD: DWORD = 0x00200000; +pub const SCH_USE_STRONG_CRYPTO: DWORD = 0x00400000; +pub const SCHANNEL_RENEGOTIATE: DWORD = 0; +pub const SCHANNEL_SHUTDOWN: DWORD = 1; +pub const SCHANNEL_ALERT: DWORD = 2; +pub const SCHANNEL_SESSION: DWORD = 3; +STRUCT!{struct SCHANNEL_ALERT_TOKEN { + dwTokenType: DWORD, + dwAlertType: DWORD, + dwAlertNumber: DWORD, +}} +pub const TLS1_ALERT_WARNING: DWORD = 1; +pub const TLS1_ALERT_FATAL: DWORD = 2; +pub const TLS1_ALERT_CLOSE_NOTIFY: DWORD = 0; +pub const TLS1_ALERT_UNEXPECTED_MESSAGE: DWORD = 10; +pub const TLS1_ALERT_BAD_RECORD_MAC: DWORD = 20; +pub const TLS1_ALERT_DECRYPTION_FAILED: DWORD = 21; +pub const TLS1_ALERT_RECORD_OVERFLOW: DWORD = 22; +pub const TLS1_ALERT_DECOMPRESSION_FAIL: DWORD = 30; +pub const TLS1_ALERT_HANDSHAKE_FAILURE: DWORD = 40; +pub const TLS1_ALERT_BAD_CERTIFICATE: DWORD = 42; +pub const TLS1_ALERT_UNSUPPORTED_CERT: DWORD = 43; +pub const TLS1_ALERT_CERTIFICATE_REVOKED: DWORD = 44; +pub const TLS1_ALERT_CERTIFICATE_EXPIRED: DWORD = 45; +pub const TLS1_ALERT_CERTIFICATE_UNKNOWN: DWORD = 46; +pub const TLS1_ALERT_ILLEGAL_PARAMETER: DWORD = 47; +pub const TLS1_ALERT_UNKNOWN_CA: DWORD = 48; +pub const TLS1_ALERT_ACCESS_DENIED: DWORD = 49; +pub const TLS1_ALERT_DECODE_ERROR: DWORD = 50; +pub const TLS1_ALERT_DECRYPT_ERROR: DWORD = 51; +pub const TLS1_ALERT_EXPORT_RESTRICTION: DWORD = 60; +pub const TLS1_ALERT_PROTOCOL_VERSION: DWORD = 70; +pub const TLS1_ALERT_INSUFFIENT_SECURITY: DWORD = 71; +pub const TLS1_ALERT_INTERNAL_ERROR: DWORD = 80; +pub const TLS1_ALERT_USER_CANCELED: DWORD = 90; +pub const TLS1_ALERT_NO_RENEGOTIATION: DWORD = 100; +pub const TLS1_ALERT_UNSUPPORTED_EXT: DWORD = 110; +pub const TLS1_ALERT_NO_APP_PROTOCOL: DWORD = 120; +pub const SSL_SESSION_ENABLE_RECONNECTS: DWORD = 1; +pub const SSL_SESSION_DISABLE_RECONNECTS: DWORD = 2; +STRUCT!{struct SCHANNEL_SESSION_TOKEN { + dwTokenType: DWORD, + dwFlags: DWORD, +}} +STRUCT!{struct SCHANNEL_CLIENT_SIGNATURE { + cbLength: DWORD, + aiHash: ALG_ID, + cbHash: DWORD, + HashValue: [BYTE; 36], + CertThumbprint: [BYTE; 20], +}} +pub type PSCHANNEL_CLIENT_SIGNATURE = *mut SCHANNEL_CLIENT_SIGNATURE; +pub const SP_PROT_PCT1_SERVER: DWORD = 0x00000001; +pub const SP_PROT_PCT1_CLIENT: DWORD = 0x00000002; +pub const SP_PROT_PCT1: DWORD = SP_PROT_PCT1_SERVER | SP_PROT_PCT1_CLIENT; +pub const SP_PROT_SSL2_SERVER: DWORD = 0x00000004; +pub const SP_PROT_SSL2_CLIENT: DWORD = 0x00000008; +pub const SP_PROT_SSL2: DWORD = SP_PROT_SSL2_SERVER | SP_PROT_SSL2_CLIENT; +pub const SP_PROT_SSL3_SERVER: DWORD = 0x00000010; +pub const SP_PROT_SSL3_CLIENT: DWORD = 0x00000020; +pub const SP_PROT_SSL3: DWORD = SP_PROT_SSL3_SERVER | SP_PROT_SSL3_CLIENT; +pub const SP_PROT_TLS1_SERVER: DWORD = 0x00000040; +pub const SP_PROT_TLS1_CLIENT: DWORD = 0x00000080; +pub const SP_PROT_TLS1: DWORD = SP_PROT_TLS1_SERVER | SP_PROT_TLS1_CLIENT; +pub const SP_PROT_SSL3TLS1_CLIENTS: DWORD = SP_PROT_TLS1_CLIENT | SP_PROT_SSL3_CLIENT; +pub const SP_PROT_SSL3TLS1_SERVERS: DWORD = SP_PROT_TLS1_SERVER | SP_PROT_SSL3_SERVER; +pub const SP_PROT_SSL3TLS1: DWORD = SP_PROT_SSL3 | SP_PROT_TLS1; +pub const SP_PROT_UNI_SERVER: DWORD = 0x40000000; +pub const SP_PROT_UNI_CLIENT: DWORD = 0x80000000; +pub const SP_PROT_UNI: DWORD = SP_PROT_UNI_SERVER | SP_PROT_UNI_CLIENT; +pub const SP_PROT_ALL: DWORD = 0xffffffff; +pub const SP_PROT_NONE: DWORD = 0; +pub const SP_PROT_CLIENTS: DWORD = SP_PROT_PCT1_CLIENT | SP_PROT_SSL2_CLIENT + | SP_PROT_SSL3_CLIENT | SP_PROT_UNI_CLIENT | SP_PROT_TLS1_CLIENT; +pub const SP_PROT_SERVERS: DWORD = SP_PROT_PCT1_SERVER | SP_PROT_SSL2_SERVER + | SP_PROT_SSL3_SERVER | SP_PROT_UNI_SERVER | SP_PROT_TLS1_SERVER; +pub const SP_PROT_TLS1_0_SERVER: DWORD = SP_PROT_TLS1_SERVER; +pub const SP_PROT_TLS1_0_CLIENT: DWORD = SP_PROT_TLS1_CLIENT; +pub const SP_PROT_TLS1_0: DWORD = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_0_CLIENT; +pub const SP_PROT_TLS1_1_SERVER: DWORD = 0x00000100; +pub const SP_PROT_TLS1_1_CLIENT: DWORD = 0x00000200; +pub const SP_PROT_TLS1_1: DWORD = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_1_CLIENT; +pub const SP_PROT_TLS1_2_SERVER: DWORD = 0x00000400; +pub const SP_PROT_TLS1_2_CLIENT: DWORD = 0x00000800; +pub const SP_PROT_TLS1_2: DWORD = SP_PROT_TLS1_2_SERVER | SP_PROT_TLS1_2_CLIENT; +pub const SP_PROT_DTLS_SERVER: DWORD = 0x00010000; +pub const SP_PROT_DTLS_CLIENT: DWORD = 0x00020000; +pub const SP_PROT_DTLS: DWORD = SP_PROT_DTLS_SERVER | SP_PROT_DTLS_CLIENT; +pub const SP_PROT_DTLS1_0_SERVER: DWORD = SP_PROT_DTLS_SERVER; +pub const SP_PROT_DTLS1_0_CLIENT: DWORD = SP_PROT_DTLS_CLIENT; +pub const SP_PROT_DTLS1_0: DWORD = SP_PROT_DTLS1_0_SERVER | SP_PROT_DTLS1_0_CLIENT; +pub const SP_PROT_DTLS1_X_SERVER: DWORD = SP_PROT_DTLS1_0_SERVER; +pub const SP_PROT_DTLS1_X_CLIENT: DWORD = SP_PROT_DTLS1_0_CLIENT; +pub const SP_PROT_DTLS1_X: DWORD = SP_PROT_DTLS1_X_SERVER | SP_PROT_DTLS1_X_CLIENT; +pub const SP_PROT_TLS1_1PLUS_SERVER: DWORD = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_2_SERVER; +pub const SP_PROT_TLS1_1PLUS_CLIENT: DWORD = SP_PROT_TLS1_1_CLIENT | SP_PROT_TLS1_2_CLIENT; +pub const SP_PROT_TLS1_1PLUS: DWORD = SP_PROT_TLS1_1PLUS_SERVER | SP_PROT_TLS1_1PLUS_CLIENT; +pub const SP_PROT_TLS1_X_SERVER: DWORD = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_1_SERVER + | SP_PROT_TLS1_2_SERVER; +pub const SP_PROT_TLS1_X_CLIENT: DWORD = SP_PROT_TLS1_0_CLIENT | SP_PROT_TLS1_1_CLIENT + | SP_PROT_TLS1_2_CLIENT; +pub const SP_PROT_TLS1_X: DWORD = SP_PROT_TLS1_X_SERVER | SP_PROT_TLS1_X_CLIENT; +pub const SP_PROT_SSL3TLS1_X_CLIENTS: DWORD = SP_PROT_TLS1_X_CLIENT | SP_PROT_SSL3_CLIENT; +pub const SP_PROT_SSL3TLS1_X_SERVERS: DWORD = SP_PROT_TLS1_X_SERVER | SP_PROT_SSL3_SERVER; +pub const SP_PROT_SSL3TLS1_X: DWORD = SP_PROT_SSL3 | SP_PROT_TLS1_X; +pub const SP_PROT_X_CLIENTS: DWORD = SP_PROT_CLIENTS | SP_PROT_TLS1_X_CLIENT + | SP_PROT_DTLS1_X_CLIENT; +pub const SP_PROT_X_SERVERS: DWORD = SP_PROT_SERVERS | SP_PROT_TLS1_X_SERVER + | SP_PROT_DTLS1_X_SERVER; +pub const SSL_CRACK_CERTIFICATE_NAME: &'static str = "SslCrackCertificate"; +pub const SSL_FREE_CERTIFICATE_NAME: &'static str = "SslFreeCertificate"; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/securityappcontainer.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/securityappcontainer.rs new file mode 100644 index 0000000..02d8629 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/securityappcontainer.rs @@ -0,0 +1,16 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, PULONG, ULONG}; +use um::winnt::{HANDLE, LPWSTR, PSID}; +extern "system" { + pub fn GetAppContainerNamedObjectPath( + Token: HANDLE, + AppContainerSid: PSID, + ObjectPathLength: ULONG, + ObjectPath: LPWSTR, + ReturnLength: PULONG, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/securitybaseapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/securitybaseapi.rs new file mode 100644 index 0000000..81bfd18 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/securitybaseapi.rs @@ -0,0 +1,690 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! FFI bindings to psapi. +use shared::guiddef::GUID; +use shared::minwindef::{ + BOOL, BYTE, DWORD, LPBOOL, LPDWORD, LPVOID, PBOOL, PDWORD, PUCHAR, PULONG, UCHAR, ULONG +}; +use um::minwinbase::LPSECURITY_ATTRIBUTES; +use um::winnt::{ + ACL_INFORMATION_CLASS, AUDIT_EVENT_TYPE, BOOLEAN, HANDLE, LONG, LPCWSTR, LPWSTR, PACL, + PCLAIM_SECURITY_ATTRIBUTES_INFORMATION, PCWSTR, PGENERIC_MAPPING, PHANDLE, PLUID, + PLUID_AND_ATTRIBUTES, POBJECT_TYPE_LIST, PPRIVILEGE_SET, PSECURITY_DESCRIPTOR, + PSECURITY_DESCRIPTOR_CONTROL, PSID, PSID_AND_ATTRIBUTES, PSID_IDENTIFIER_AUTHORITY, + PTOKEN_GROUPS, PTOKEN_PRIVILEGES, PVOID, SECURITY_DESCRIPTOR_CONTROL, + SECURITY_IMPERSONATION_LEVEL, SECURITY_INFORMATION, TOKEN_INFORMATION_CLASS, TOKEN_TYPE, + WELL_KNOWN_SID_TYPE +}; +extern "system" { + pub fn AccessCheck( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ClientToken: HANDLE, + DesiredAccess: DWORD, + GenericMapping: PGENERIC_MAPPING, + PrivilegeSet: PPRIVILEGE_SET, + PrivilegeSetLength: LPDWORD, + GrantedAccess: LPDWORD, + AccessStatus: LPBOOL, + ) -> BOOL; + pub fn AccessCheckAndAuditAlarmW( + SubsystemName: LPCWSTR, + HandleId: LPVOID, + ObjectTypeName: LPWSTR, + ObjectName: LPWSTR, + SecurityDescriptor: PSECURITY_DESCRIPTOR, + DesiredAccess: DWORD, + GenericMapping: PGENERIC_MAPPING, + ObjectCreation: BOOL, + GrantedAccess: LPDWORD, + AccessStatus: LPBOOL, + pfGenerateOnClose: LPBOOL, + ) -> BOOL; + pub fn AccessCheckByType( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + PrincipalSelfSid: PSID, + ClientToken: HANDLE, + DesiredAccess: DWORD, + ObjectTypeList: POBJECT_TYPE_LIST, + ObjectTypeListLength: DWORD, + GenericMapping: PGENERIC_MAPPING, + PrivilegeSet: PPRIVILEGE_SET, + PrivilegeSetLength: LPDWORD, + GrantedAccess: LPDWORD, + AccessStatus: LPBOOL, + ) -> BOOL; + pub fn AccessCheckByTypeResultList( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + PrincipalSelfSid: PSID, + ClientToken: HANDLE, + DesiredAccess: DWORD, + ObjectTypeList: POBJECT_TYPE_LIST, + ObjectTypeListLength: DWORD, + GenericMapping: PGENERIC_MAPPING, + PrivilegeSet: PPRIVILEGE_SET, + PrivilegeSetLength: LPDWORD, + GrantedAccessList: LPDWORD, + AccessStatusList: LPDWORD, + ) -> BOOL; + pub fn AccessCheckByTypeAndAuditAlarmW( + SubsystemName: LPCWSTR, + HandleId: LPVOID, + ObjectTypeName: LPWSTR, + ObjectName: LPCWSTR, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + PrincipalSelfSid: PSID, + DesiredAccess: DWORD, + AuditType: AUDIT_EVENT_TYPE, + Flags: DWORD, + ObjectTypeList: POBJECT_TYPE_LIST, + ObjectTypeListLength: DWORD, + GenericMapping: PGENERIC_MAPPING, + ObjectCreation: BOOL, + GrantedAccess: LPDWORD, + AccessStatus: LPBOOL, + pfGenerateOnClose: LPBOOL, + ) -> BOOL; + pub fn AccessCheckByTypeResultListAndAuditAlarmW( + SubsystemName: LPCWSTR, + HandleId: LPVOID, + ObjectTypeName: LPCWSTR, + ObjectName: LPCWSTR, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + PrincipalSelfSid: PSID, + DesiredAccess: DWORD, + AuditType: AUDIT_EVENT_TYPE, + Flags: DWORD, + ObjectTypeList: POBJECT_TYPE_LIST, + ObjectTypeListLength: DWORD, + GenericMapping: PGENERIC_MAPPING, + ObjectCreation: BOOL, + GrantedAccess: LPDWORD, + AccessStatusList: LPDWORD, + pfGenerateOnClose: LPBOOL, + ) -> BOOL; + pub fn AccessCheckByTypeResultListAndAuditAlarmByHandleW( + SubsystemName: LPCWSTR, + HandleId: LPVOID, + ClientToken: HANDLE, + ObjectTypeName: LPCWSTR, + ObjectName: LPCWSTR, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + PrincipalSelfSid: PSID, + DesiredAccess: DWORD, + AuditType: AUDIT_EVENT_TYPE, + Flags: DWORD, + ObjectTypeList: POBJECT_TYPE_LIST, + ObjectTypeListLength: DWORD, + GenericMapping: PGENERIC_MAPPING, + ObjectCreation: BOOL, + GrantedAccess: LPDWORD, + AccessStatusList: LPDWORD, + pfGenerateOnClose: LPBOOL, + ) -> BOOL; + pub fn AddAccessAllowedAce( + pAcl: PACL, + dwAceRevision: DWORD, + AccessMask: DWORD, + pSid: PSID, + ) -> BOOL; + pub fn AddAccessAllowedAceEx( + pAcl: PACL, + dwAceRevision: DWORD, + AceFlags: DWORD, + AccessMask: DWORD, + pSid: PSID, + ) -> BOOL; + pub fn AddAccessAllowedObjectAce( + pAcl: PACL, + dwAceRevision: DWORD, + AceFlags: DWORD, + AccessMask: DWORD, + ObjectTypeGuid: *mut GUID, + InheritedObjectTypeGuid: *mut GUID, + pSid: PSID, + ) -> BOOL; + pub fn AddAccessDeniedAce( + pAcl: PACL, + dwAceRevision: DWORD, + AccessMask: DWORD, + pSid: PSID, + ) -> BOOL; + pub fn AddAccessDeniedAceEx( + pAcl: PACL, + dwAceRevision: DWORD, + AceFlags: DWORD, + AccessMask: DWORD, + pSid: PSID, + ) -> BOOL; + pub fn AddAccessDeniedObjectAce( + pAcl: PACL, + dwAceRevision: DWORD, + AceFlags: DWORD, + AccessMask: DWORD, + ObjectTypeGuid: *mut GUID, + InheritedObjectTypeGuid: *mut GUID, + pSid: PSID, + ) -> BOOL; + pub fn AddAce( + pAcl: PACL, + dwAceRevision: DWORD, + dwStartingAceIndex: DWORD, + pAceList: LPVOID, + nAceListLength: DWORD, + ) -> BOOL; + pub fn AddAuditAccessAce( + pAcl: PACL, + dwAceRevision: DWORD, + dwAccessMask: DWORD, + pSid: PSID, + bAuditSuccess: BOOL, + bAuditFailure: BOOL, + ) -> BOOL; + pub fn AddAuditAccessAceEx( + pAcl: PACL, + dwAceRevision: DWORD, + AceFlags: DWORD, + dwAccessMask: DWORD, + pSid: PSID, + bAuditSuccess: BOOL, + bAuditFailure: BOOL, + ) -> BOOL; + pub fn AddAuditAccessObjectAce( + pAcl: PACL, + dwAceRevision: DWORD, + AceFlags: DWORD, + AccessMask: DWORD, + ObjectTypeGuid: *mut GUID, + InheritedObjectTypeGuid: *mut GUID, + pSid: PSID, + bAuditSuccess: BOOL, + bAuditFailure: BOOL, + ) -> BOOL; + pub fn AddMandatoryAce( + pAcl: PACL, + dwAceRevision: DWORD, + AceFlags: DWORD, + MandatoryPolicy: DWORD, + pLabelSid: PSID, + ) -> BOOL; + pub fn AddResourceAttributeAce( + pAcl: PACL, + dwAceRevision: DWORD, + AceFlags: DWORD, + AccessMask: DWORD, + pSid: PSID, + pAttributeInfo: PCLAIM_SECURITY_ATTRIBUTES_INFORMATION, + pReturnLength: PDWORD, + ) -> BOOL; + pub fn AddScopedPolicyIDAce( + pAcl: PACL, + dwAceRevision: DWORD, + AceFlags: DWORD, + AccessMask: DWORD, + pSid: PSID, + ) -> BOOL; + pub fn AdjustTokenGroups( + TokenHandle: HANDLE, + ResetToDefault: BOOL, + NewState: PTOKEN_GROUPS, + BufferLength: DWORD, + PreviousState: PTOKEN_GROUPS, + ReturnLength: PDWORD, + ) -> BOOL; + pub fn AdjustTokenPrivileges( + TokenHandle: HANDLE, + DisableAllPrivileges: BOOL, + NewState: PTOKEN_PRIVILEGES, + BufferLength: DWORD, + PreviousState: PTOKEN_PRIVILEGES, + ReturnLength: PDWORD, + ) -> BOOL; + pub fn AllocateAndInitializeSid( + pIdentifierAuthoirity: PSID_IDENTIFIER_AUTHORITY, + nSubAuthorityCount: BYTE, + dwSubAuthority0: DWORD, + dwSubAuthority1: DWORD, + dwSubAuthority2: DWORD, + dwSubAuthority3: DWORD, + dwSubAuthority4: DWORD, + dwSubAuthority5: DWORD, + dwSubAuthority6: DWORD, + dwSubAuthority7: DWORD, + pSid: *mut PSID, + ) -> BOOL; + pub fn AllocateLocallyUniqueId( + Luid: PLUID, + ) -> BOOL; + pub fn AreAllAccessesGranted( + GrantedAccess: DWORD, + DesiredAccess: DWORD, + ) -> BOOL; + pub fn AreAnyAccessesGranted( + GrantedAccess: DWORD, + DesiredAccess: DWORD, + ) -> BOOL; + pub fn CheckTokenMembership( + TokenHandle: HANDLE, + SidToCheck: PSID, + IsMember: PBOOL, + ) -> BOOL; + pub fn CheckTokenCapability( + TokenHandle: HANDLE, + CapabilitySidToCheck: PSID, + HasCapability: PBOOL, + ) -> BOOL; + pub fn GetAppContainerAce( + Acl: PACL, + StartingAceIndex: DWORD, + AppContainerAce: *mut PVOID, + AppContainerAceIndex: *mut DWORD, + ) -> BOOL; + pub fn CheckTokenMembershipEx( + TokenHandle: HANDLE, + SidToCheck: PSID, + Flags: DWORD, + IsMember: PBOOL, + ) -> BOOL; + pub fn ConvertToAutoInheritPrivateObjectSecurity( + ParentDescriptor: PSECURITY_DESCRIPTOR, + CurrentSecurityDescriptor: PSECURITY_DESCRIPTOR, + NewSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + ObjectType: *mut GUID, + IsDirectoryObject: BOOLEAN, + GenericMapping: PGENERIC_MAPPING, + ) -> BOOL; + pub fn CopySid( + nDestinationSidLength: DWORD, + pDestinationSid: PSID, + pSourceSid: PSID, + ) -> BOOL; + pub fn CreatePrivateObjectSecurity( + ParentDescriptor: PSECURITY_DESCRIPTOR, + CreatorDescriptor: PSECURITY_DESCRIPTOR, + NewDescriptor: *mut PSECURITY_DESCRIPTOR, + IsDirectoryObject: BOOL, + Token: HANDLE, + GenericMapping: PGENERIC_MAPPING, + ) -> BOOL; + pub fn CreatePrivateObjectSecurityEx( + ParentDescriptor: PSECURITY_DESCRIPTOR, + CreatorDescriptor: PSECURITY_DESCRIPTOR, + NewSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + ObjectType: *mut GUID, + IsContainerObject: BOOL, + AutoInheritFlags: ULONG, + Token: HANDLE, + GenericMapping: PGENERIC_MAPPING, + ) -> BOOL; + pub fn CreatePrivateObjectSecurityWithMultipleInheritance( + ParentDescriptor: PSECURITY_DESCRIPTOR, + CreatorDescriptor: PSECURITY_DESCRIPTOR, + NewSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + ObjectTypes: *mut *mut GUID, + GuidCount: ULONG, + IsContainerObject: BOOL, + AutoInheritFlags: ULONG, + Token: HANDLE, + GenericMapping: PGENERIC_MAPPING, + ) -> BOOL; + pub fn CreateRestrictedToken( + ExistingTokenHandle: HANDLE, + Flags: DWORD, + DisableSidCount: DWORD, + SidsToDisable: PSID_AND_ATTRIBUTES, + DeletePrivilegeCount: DWORD, + PrivilegesToDelete: PLUID_AND_ATTRIBUTES, + RestrictedSidCount: DWORD, + SidsToRestrict: PSID_AND_ATTRIBUTES, + NewTokenHandle: PHANDLE, + ) -> BOOL; + pub fn CreateWellKnownSid( + WellKnownSidType: WELL_KNOWN_SID_TYPE, + DomainSid: PSID, + pSid: PSID, + cbSid: *mut DWORD, + ) -> BOOL; + pub fn EqualDomainSid( + pSid1: PSID, + pSid2: PSID, + pfEqual: *mut BOOL, + ) -> BOOL; + pub fn DeleteAce( + pAcl: PACL, + dwAceIndex: DWORD, + ) -> BOOL; + pub fn DestroyPrivateObjectSecurity( + ObjectDescriptor: *mut PSECURITY_DESCRIPTOR, + ) -> BOOL; + pub fn DuplicateToken( + ExistingTokenHandle: HANDLE, + ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, + DuplicateTokenHandle: PHANDLE, + ) -> BOOL; + pub fn DuplicateTokenEx( + hExistingToken: HANDLE, + dwDesiredAccess: DWORD, + lpTokenAttributes: LPSECURITY_ATTRIBUTES, + ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, + TokenType: TOKEN_TYPE, + phNewToken: PHANDLE, + ) -> BOOL; + pub fn EqualPrefixSid( + pSid1: PSID, + pSid2: PSID, + ) -> BOOL; + pub fn EqualSid( + pSid1: PSID, + pSid2: PSID, + ) -> BOOL; + pub fn FindFirstFreeAce( + pAcl: PACL, + pAce: *mut LPVOID, + ) -> BOOL; + pub fn FreeSid( + pSid: PSID, + ) -> PVOID; + pub fn GetAce( + pAcl: PACL, + dwAceIndex: DWORD, + pAce: *mut LPVOID, + ) -> BOOL; + pub fn GetAclInformation( + pAcl: PACL, + pAclInformtion: LPVOID, + nAclInformationLength: DWORD, + dwAclInformationClass: ACL_INFORMATION_CLASS, + ) -> BOOL; + pub fn GetFileSecurityW( + lpFileName: LPCWSTR, + RequestedInformation: SECURITY_INFORMATION, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + nLength: DWORD, + lpnLengthNeeded: LPDWORD, + ) -> BOOL; + pub fn GetKernelObjectSecurity( + Handle: HANDLE, + RequestedInformation: SECURITY_INFORMATION, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + nLength: DWORD, + lpnLengthNeeded: LPDWORD, + ) -> BOOL; + pub fn GetLengthSid( + pSid: PSID, + ) -> DWORD; + pub fn GetPrivateObjectSecurity( + ObjectDescriptor: PSECURITY_DESCRIPTOR, + SecurityInformation: SECURITY_INFORMATION, + ResultantDescriptor: PSECURITY_DESCRIPTOR, + DescriptorLength: DWORD, + ReturnLength: PDWORD, + ) -> BOOL; + pub fn GetSecurityDescriptorControl( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + pControl: PSECURITY_DESCRIPTOR_CONTROL, + lpdwRevision: LPDWORD, + ) -> BOOL; + pub fn GetSecurityDescriptorDacl( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + lpbDaclPresent: LPBOOL, + pDacl: *mut PACL, + lpbDaclDefaulted: LPBOOL, + ) -> BOOL; + pub fn GetSecurityDescriptorGroup( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + pGroup: *mut PSID, + lpbGroupDefaulted: LPBOOL, + ) -> BOOL; + pub fn GetSecurityDescriptorLength( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ) -> DWORD; + pub fn GetSecurityDescriptorOwner( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + pOwner: *mut PSID, + lpbOwnerDefaulted: LPBOOL, + ) -> BOOL; + pub fn GetSecurityDescriptorRMControl( + SecurityDescriptor: PSECURITY_DESCRIPTOR, + RMControl: PUCHAR, + ) -> DWORD; + pub fn GetSecurityDescriptorSacl( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + lpbSaclPresent: LPBOOL, + pSacl: *mut PACL, + lpbSaclDefaulted: LPBOOL, + ) -> BOOL; + pub fn GetSidIdentifierAuthority( + pSid: PSID, + ) -> PSID_IDENTIFIER_AUTHORITY; + pub fn GetSidLengthRequired( + nSubAuthorityCount: UCHAR, + ) -> DWORD; + pub fn GetSidSubAuthority( + pSid: PSID, + nSubAuthority: DWORD, + ) -> PDWORD; + pub fn GetSidSubAuthorityCount( + pSid: PSID, + ) -> PUCHAR; + pub fn GetTokenInformation( + TokenHandle: HANDLE, + TokenInformationClass: TOKEN_INFORMATION_CLASS, + TokenInformation: LPVOID, + TokenInformationLength: DWORD, + ReturnLength: PDWORD, + ) -> BOOL; + pub fn GetWindowsAccountDomainSid( + pSid: PSID, + pDomainSid: PSID, + cbDomainSid: *mut DWORD, + ) -> BOOL; + pub fn ImpersonateAnonymousToken( + ThreadHandle: HANDLE, + ) -> BOOL; + pub fn ImpersonateLoggedOnUser( + hToken: HANDLE, + ) -> BOOL; + pub fn ImpersonateSelf( + ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, + ) -> BOOL; + pub fn InitializeAcl( + pAcl: PACL, + nAclLength: DWORD, + dwAclRevision: DWORD, + ) -> BOOL; + pub fn InitializeSecurityDescriptor( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + dwRevision: DWORD, + ) -> BOOL; + pub fn InitializeSid( + Sid: PSID, + pIdentifierAuthority: PSID_IDENTIFIER_AUTHORITY, + nSubAuthorityCount: BYTE, + ) -> BOOL; + pub fn IsTokenRestricted( + TokenHandle: HANDLE, + ) -> BOOL; + pub fn IsValidAcl( + pAcl: PACL, + ) -> BOOL; + pub fn IsValidSecurityDescriptor( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ) -> BOOL; + pub fn IsValidSid( + pSid: PSID, + ) -> BOOL; + pub fn IsWellKnownSid( + pSid: PSID, + WellKnownSidType: WELL_KNOWN_SID_TYPE, + ) -> BOOL; + pub fn MakeAbsoluteSD( + pSelfRelativeSD: PSECURITY_DESCRIPTOR, + pAbsoluteSD: PSECURITY_DESCRIPTOR, + lpdwAbsoluteSDSize: LPDWORD, + pDacl: PACL, + lpdwDaclSize: LPDWORD, + pSacl: PACL, + lpdwSaclSize: LPDWORD, + pOwner: PSID, + lpdwOwnerSize: LPDWORD, + pPrimaryGroup: PSID, + lpdwPrimaryGroupSize: LPDWORD, + ) -> BOOL; + pub fn MakeSelfRelativeSD( + pAbsoluteSD: PSECURITY_DESCRIPTOR, + pSelfRelativeSD: PSECURITY_DESCRIPTOR, + lpdwBufferLength: LPDWORD, + ) -> BOOL; + pub fn MapGenericMask( + AccessMask: PDWORD, + GenericMapping: PGENERIC_MAPPING, + ); + pub fn ObjectCloseAuditAlarmW( + SubsystemName: LPCWSTR, + HandleId: LPVOID, + GenerateOnClose: BOOL, + ) -> BOOL; + pub fn ObjectDeleteAuditAlarmW( + SubsystemName: LPCWSTR, + HandleId: LPVOID, + GenerateOnClose: BOOL, + ) -> BOOL; + pub fn ObjectOpenAuditAlarmW( + SubsystemName: LPCWSTR, + HandleId: LPVOID, + ObjectTypeName: LPWSTR, + ObjectName: LPWSTR, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ClientToken: HANDLE, + DesiredAccess: DWORD, + GrantedAccess: DWORD, + Privileges: PPRIVILEGE_SET, + ObjectCreation: BOOL, + AccessGranted: BOOL, + GenerateOnClose: LPBOOL, + ) -> BOOL; + pub fn ObjectPrivilegeAuditAlarmW( + SubsystemName: LPCWSTR, + HandleId: LPVOID, + ClientToken: HANDLE, + DesiredAccess: DWORD, + Privileges: PPRIVILEGE_SET, + AccessGranted: BOOL, + ) -> BOOL; + pub fn PrivilegeCheck( + ClientToken: HANDLE, + RequiredPrivileges: PPRIVILEGE_SET, + pfResult: LPBOOL, + ) -> BOOL; + pub fn PrivilegedServiceAuditAlarmW( + SubsystemName: LPCWSTR, + ServiceName: LPCWSTR, + ClientToken: HANDLE, + Privileges: PPRIVILEGE_SET, + AccessGranted: BOOL, + ) -> BOOL; + pub fn QuerySecurityAccessMask( + SecurityInformation: SECURITY_INFORMATION, + DesiredAccess: LPDWORD, + ); + pub fn RevertToSelf() -> BOOL; + pub fn SetAclInformation( + pAcl: PACL, + pAclInformation: LPVOID, + nAclInformationLength: DWORD, + dwAclInfomrationClass: ACL_INFORMATION_CLASS, + ) -> BOOL; + pub fn SetFileSecurityW( + lpFileName: LPCWSTR, + SecurityInformation: SECURITY_INFORMATION, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ) -> BOOL; + pub fn SetKernelObjectSecurity( + Handle: HANDLE, + SecurityInformation: SECURITY_INFORMATION, + SecurityDescriptor: PSECURITY_DESCRIPTOR, + ) -> BOOL; + pub fn SetPrivateObjectSecurity( + SecurityInformation: SECURITY_INFORMATION, + ModificationDescriptor: PSECURITY_DESCRIPTOR, + ObjectsSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + GenericMapping: PGENERIC_MAPPING, + Token: HANDLE, + ) -> BOOL; + pub fn SetPrivateObjectSecurityEx( + SecurityInformation: SECURITY_INFORMATION, + ModificationDescriptor: PSECURITY_DESCRIPTOR, + ObjectsSecurityDescriptor: *mut PSECURITY_DESCRIPTOR, + AutoInheritFlags: ULONG, + GenericMapping: PGENERIC_MAPPING, + Token: HANDLE, + ) -> BOOL; + pub fn SetSecurityAccessMask( + SecurityInformation: SECURITY_INFORMATION, + DesiredAccess: LPDWORD, + ); + pub fn SetSecurityDescriptorControl( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ControlBitsOfInterest: SECURITY_DESCRIPTOR_CONTROL, + ControlBitsToSet: SECURITY_DESCRIPTOR_CONTROL, + ) -> BOOL; + pub fn SetSecurityDescriptorDacl( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + bDaclPresent: BOOL, + pDacl: PACL, + bDaclDefaulted: BOOL, + ) -> BOOL; + pub fn SetSecurityDescriptorGroup( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + pGroup: PSID, + bGroupDefaulted: BOOL, + ) -> BOOL; + pub fn SetSecurityDescriptorOwner( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + pOwner: PSID, + bOwnerDefaulted: BOOL, + ) -> BOOL; + pub fn SetSecurityDescriptorRMControl( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + RMControl: PUCHAR, + ) -> DWORD; + pub fn SetSecurityDescriptorSacl( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + bSaclPresent: BOOL, + pSacl: PACL, + bSaclDefaulted: BOOL, + ) -> BOOL; + pub fn SetTokenInformation( + TokenHandle: HANDLE, + TokenInformationClass: TOKEN_INFORMATION_CLASS, + TokenInformation: LPVOID, + TokenInformationLength: DWORD, + ) -> BOOL; + pub fn SetCachedSigningLevel( + SourceFiles: PHANDLE, + SourceFileCount: ULONG, + Flags: ULONG, + TargetFile: HANDLE, + ) -> BOOL; + pub fn GetCachedSigningLevel( + File: HANDLE, + Flags: PULONG, + SigningLevel: PULONG, + Thumbprint: PUCHAR, + ThumbprintSize: PULONG, + ThumbprintAlgorithm: PULONG, + ) -> BOOL; + pub fn CveEventWrite( + CveId: PCWSTR, + AdditionalDetails: PCWSTR, + ) -> LONG; + pub fn DeriveCapabilitySidsFromName( + CapName: LPCWSTR, + CapabilityGroupSids: *mut *mut PSID, + CapabilityGroupSidCount: *mut DWORD, + CapabilitySids: *mut *mut PSID, + CapabilitySidCount: *mut DWORD, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/servprov.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/servprov.rs new file mode 100644 index 0000000..aeb382d --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/servprov.rs @@ -0,0 +1,23 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_void; +use shared::guiddef::{REFGUID, REFIID}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::HRESULT; +pub type LPSERVICEPROVIDER = *mut IServiceProvider; +RIDL!{#[uuid(0x6d5140c1, 0x7436, 0x11ce, 0x80, 0x34, 0x00, 0xaa, 0x00, 0x60, 0x09, 0xfa)] +interface IServiceProvider(IServiceProviderVtbl): IUnknown(IUnknownVtbl) { + fn QueryService( + guidService: REFGUID, + riid: REFIID, + ppvObject: *mut *mut c_void, + ) -> HRESULT, + fn RemoteQueryService( + guidService: REFGUID, + riid: REFIID, + ppvObject: *mut *mut IUnknown, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/setupapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/setupapi.rs new file mode 100644 index 0000000..d716fc5 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/setupapi.rs @@ -0,0 +1,3571 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Public header file for Windows NT Setup and Device Installer services Dll. +use ctypes::c_int; +use shared::basetsd::{DWORD_PTR, UINT_PTR, ULONG_PTR}; +use shared::devpropdef::{DEVPROPKEY, DEVPROPTYPE}; +use shared::guiddef::{GUID, LPGUID}; +use shared::minwindef::{ + BOOL, BYTE, DWORD, FILETIME, HINSTANCE, HKEY, INT, LPARAM, LPCVOID, LPDWORD, MAX_PATH, PBOOL, + PBYTE, PDWORD, PINT, PUINT, UINT, USHORT, WORD, +}; +use shared::windef::{HDC, HICON, HWND, RECT}; +use um::commctrl::HIMAGELIST; +use um::prsht::{HPROPSHEETPAGE, LPPROPSHEETHEADERA, LPPROPSHEETHEADERW}; +use um::spapidef::SP_LOG_TOKEN; +use um::winnt::{ + ANYSIZE_ARRAY, APPLICATION_ERROR_MASK, CHAR, DWORDLONG, ERROR_SEVERITY_ERROR, HANDLE, LONG, + LONGLONG, LPCSTR, LPCWSTR, PCSTR, PCWSTR, PSTR, PVOID, PWSTR, WCHAR, +}; +use um::winreg::REGSAM; +pub const LINE_LEN: usize = 256; +pub const MAX_INF_STRING_LENGTH: usize = 4096; +pub const MAX_INF_SECTION_NAME_LENGTH: usize = 255; +pub const MAX_TITLE_LEN: usize = 60; +pub const MAX_INSTRUCTION_LEN: usize = 256; +pub const MAX_LABEL_LEN: usize = 30; +pub const MAX_SERVICE_NAME_LEN: usize = 256; +pub const MAX_SUBTITLE_LEN: usize = 256; +pub const SP_MAX_MACHINENAME_LENGTH: usize = MAX_PATH + 3; +pub type HINF = PVOID; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct INFCONTEXT { + Inf: PVOID, + CurrentInf: PVOID, + Section: UINT, + Line: UINT, +}} +pub type PINFCONTEXT = *mut INFCONTEXT; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_INF_INFORMATION { + InfStyle: DWORD, + InfCount: DWORD, + VersionData: [BYTE; ANYSIZE_ARRAY], +}} +pub type PSP_INF_INFORMATION = *mut SP_INF_INFORMATION; +UNION!{#[cfg_attr(target_arch = "x86", repr(packed))] union SP_ALTPLATFORM_INFO_V3_u { + [u16; 1], + Reserved Reserved_mut: WORD, + Flags Flags_mut: WORD, +}} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_ALTPLATFORM_INFO_V3 { + cbSize: DWORD, + Platform: DWORD, + MajorVersion: DWORD, + MinorVersion: DWORD, + ProcessorArchitecture: WORD, + u: SP_ALTPLATFORM_INFO_V3_u, + FirstValidatedMajorVersion: DWORD, + FirstValidatedMinorVersion: DWORD, + ProductType: BYTE, + SuiteMask: WORD, + BuildNumber: DWORD, +}} +pub type PSP_ALTPLATFORM_INFO_V3 = *mut SP_ALTPLATFORM_INFO_V3; +UNION!{#[cfg_attr(target_arch = "x86", repr(packed))] union SP_ALTPLATFORM_INFO_V2_u { + [u16; 1], + Reserved Reserved_mut: WORD, + Flags Flags_mut: WORD, +}} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_ALTPLATFORM_INFO_V2 { + cbSize: DWORD, + Platform: DWORD, + MajorVersion: DWORD, + MinorVersion: DWORD, + ProcessorArchitecture: WORD, + u: SP_ALTPLATFORM_INFO_V2_u, + FirstValidatedMajorVersion: DWORD, + FirstValidatedMinorVersion: DWORD, +}} +pub type PSP_ALTPLATFORM_INFO_V2 = *mut SP_ALTPLATFORM_INFO_V2; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_ALTPLATFORM_INFO_V1 { + cbSize: DWORD, + Platform: DWORD, + MajorVersion: DWORD, + MinorVersion: DWORD, + ProcessorArchitecture: WORD, + Reserved: WORD, +}} +pub type PSP_ALTPLATFORM_INFO_V1 = *mut SP_ALTPLATFORM_INFO_V1; +pub type SP_ALTPLATFORM_INFO = SP_ALTPLATFORM_INFO_V2; +pub type PSP_ALTPLATFORM_INFO = PSP_ALTPLATFORM_INFO_V2; +pub const SP_ALTPLATFORM_FLAGS_VERSION_RANGE: WORD = 0x0001; +pub const SP_ALTPLATFORM_FLAGS_SUITE_MASK: WORD = 0x0002; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_ORIGINAL_FILE_INFO_A { + cbSize: DWORD, + OriginalInfName: [CHAR; MAX_PATH], + OriginalCatalogName: [CHAR; MAX_PATH], +}} +pub type PSP_ORIGINAL_FILE_INFO_A = *mut SP_ORIGINAL_FILE_INFO_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_ORIGINAL_FILE_INFO_W { + cbSize: DWORD, + OriginalInfName: [WCHAR; MAX_PATH], + OriginalCatalogName: [WCHAR; MAX_PATH], +}} +pub type PSP_ORIGINAL_FILE_INFO_W = *mut SP_ORIGINAL_FILE_INFO_W; +pub const INF_STYLE_NONE: DWORD = 0x00000000; +pub const INF_STYLE_OLDNT: DWORD = 0x00000001; +pub const INF_STYLE_WIN4: DWORD = 0x00000002; +pub const INF_STYLE_CACHE_ENABLE: DWORD = 0x00000010; +pub const INF_STYLE_CACHE_DISABLE: DWORD = 0x00000020; +pub const INF_STYLE_CACHE_IGNORE: DWORD = 0x00000040; +pub const DIRID_ABSOLUTE: DWORD = -1i32 as u32; +pub const DIRID_ABSOLUTE_16BIT: DWORD = 0xffff; +pub const DIRID_NULL: DWORD = 0; +pub const DIRID_SRCPATH: DWORD = 1; +pub const DIRID_WINDOWS: DWORD = 10; +pub const DIRID_SYSTEM: DWORD = 11; +pub const DIRID_DRIVERS: DWORD = 12; +pub const DIRID_IOSUBSYS: DWORD = DIRID_DRIVERS; +pub const DIRID_DRIVER_STORE: DWORD = 13; +pub const DIRID_INF: DWORD = 17; +pub const DIRID_HELP: DWORD = 18; +pub const DIRID_FONTS: DWORD = 20; +pub const DIRID_VIEWERS: DWORD = 21; +pub const DIRID_COLOR: DWORD = 23; +pub const DIRID_APPS: DWORD = 24; +pub const DIRID_SHARED: DWORD = 25; +pub const DIRID_BOOT: DWORD = 30; +pub const DIRID_SYSTEM16: DWORD = 50; +pub const DIRID_SPOOL: DWORD = 51; +pub const DIRID_SPOOLDRIVERS: DWORD = 52; +pub const DIRID_USERPROFILE: DWORD = 53; +pub const DIRID_LOADER: DWORD = 54; +pub const DIRID_PRINTPROCESSOR: DWORD = 55; +pub const DIRID_DEFAULT: DWORD = DIRID_SYSTEM; +pub const DIRID_COMMON_STARTMENU: DWORD = 16406; +pub const DIRID_COMMON_PROGRAMS: DWORD = 16407; +pub const DIRID_COMMON_STARTUP: DWORD = 16408; +pub const DIRID_COMMON_DESKTOPDIRECTORY: DWORD = 16409; +pub const DIRID_COMMON_FAVORITES: DWORD = 16415; +pub const DIRID_COMMON_APPDATA: DWORD = 16419; +pub const DIRID_PROGRAM_FILES: DWORD = 16422; +pub const DIRID_SYSTEM_X86: DWORD = 16425; +pub const DIRID_PROGRAM_FILES_X86: DWORD = 16426; +pub const DIRID_PROGRAM_FILES_COMMON: DWORD = 16427; +pub const DIRID_PROGRAM_FILES_COMMONX86: DWORD = 16428; +pub const DIRID_COMMON_TEMPLATES: DWORD = 16429; +pub const DIRID_COMMON_DOCUMENTS: DWORD = 16430; +pub const DIRID_USER: DWORD = 0x8000; +FN!{stdcall PSP_FILE_CALLBACK_A( + Context: PVOID, + Notification: UINT, + Param1: UINT_PTR, + Param2: UINT_PTR, +) -> UINT} +FN!{stdcall PSP_FILE_CALLBACK_W( + Context: PVOID, + Notification: UINT, + Param1: UINT_PTR, + Param2: UINT_PTR, +) -> UINT} +pub const SPFILENOTIFY_STARTQUEUE: UINT = 0x00000001; +pub const SPFILENOTIFY_ENDQUEUE: UINT = 0x00000002; +pub const SPFILENOTIFY_STARTSUBQUEUE: UINT = 0x00000003; +pub const SPFILENOTIFY_ENDSUBQUEUE: UINT = 0x00000004; +pub const SPFILENOTIFY_STARTDELETE: UINT = 0x00000005; +pub const SPFILENOTIFY_ENDDELETE: UINT = 0x00000006; +pub const SPFILENOTIFY_DELETEERROR: UINT = 0x00000007; +pub const SPFILENOTIFY_STARTRENAME: UINT = 0x00000008; +pub const SPFILENOTIFY_ENDRENAME: UINT = 0x00000009; +pub const SPFILENOTIFY_RENAMEERROR: UINT = 0x0000000a; +pub const SPFILENOTIFY_STARTCOPY: UINT = 0x0000000b; +pub const SPFILENOTIFY_ENDCOPY: UINT = 0x0000000c; +pub const SPFILENOTIFY_COPYERROR: UINT = 0x0000000d; +pub const SPFILENOTIFY_NEEDMEDIA: UINT = 0x0000000e; +pub const SPFILENOTIFY_QUEUESCAN: UINT = 0x0000000f; +pub const SPFILENOTIFY_CABINETINFO: UINT = 0x00000010; +pub const SPFILENOTIFY_FILEINCABINET: UINT = 0x00000011; +pub const SPFILENOTIFY_NEEDNEWCABINET: UINT = 0x00000012; +pub const SPFILENOTIFY_FILEEXTRACTED: UINT = 0x00000013; +pub const SPFILENOTIFY_FILEOPDELAYED: UINT = 0x00000014; +pub const SPFILENOTIFY_STARTBACKUP: UINT = 0x00000015; +pub const SPFILENOTIFY_BACKUPERROR: UINT = 0x00000016; +pub const SPFILENOTIFY_ENDBACKUP: UINT = 0x00000017; +pub const SPFILENOTIFY_QUEUESCAN_EX: UINT = 0x00000018; +pub const SPFILENOTIFY_STARTREGISTRATION: UINT = 0x00000019; +pub const SPFILENOTIFY_ENDREGISTRATION: UINT = 0x00000020; +pub const SPFILENOTIFY_QUEUESCAN_SIGNERINFO: UINT = 0x00000040; +pub const SPFILENOTIFY_LANGMISMATCH: UINT = 0x00010000; +pub const SPFILENOTIFY_TARGETEXISTS: UINT = 0x00020000; +pub const SPFILENOTIFY_TARGETNEWER: UINT = 0x00040000; +pub const FILEOP_COPY: UINT = 0; +pub const FILEOP_RENAME: UINT = 1; +pub const FILEOP_DELETE: UINT = 2; +pub const FILEOP_BACKUP: UINT = 3; +pub const FILEOP_ABORT: UINT = 0; +pub const FILEOP_DOIT: UINT = 1; +pub const FILEOP_SKIP: UINT = 2; +pub const FILEOP_RETRY: UINT = FILEOP_DOIT; +pub const FILEOP_NEWPATH: UINT = 4; +pub const COPYFLG_WARN_IF_SKIP: UINT = 0x00000001; +pub const COPYFLG_NOSKIP: UINT = 0x00000002; +pub const COPYFLG_NOVERSIONCHECK: UINT = 0x00000004; +pub const COPYFLG_FORCE_FILE_IN_USE: UINT = 0x00000008; +pub const COPYFLG_NO_OVERWRITE: UINT = 0x00000010; +pub const COPYFLG_NO_VERSION_DIALOG: UINT = 0x00000020; +pub const COPYFLG_OVERWRITE_OLDER_ONLY: UINT = 0x00000040; +pub const COPYFLG_PROTECTED_WINDOWS_DRIVER_FILE: UINT = 0x00000100; +pub const COPYFLG_REPLACEONLY: UINT = 0x00000400; +pub const COPYFLG_NODECOMP: UINT = 0x00000800; +pub const COPYFLG_REPLACE_BOOT_FILE: UINT = 0x00001000; +pub const COPYFLG_NOPRUNE: UINT = 0x00002000; +pub const COPYFLG_IN_USE_TRY_RENAME: UINT = 0x00004000; +pub const DELFLG_IN_USE: UINT = 0x00000001; +pub const DELFLG_IN_USE1: UINT = 0x00010000; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct FILEPATHS_A { + Target: PCSTR, + Source: PCSTR, + Win32Error: UINT, + Flags: DWORD, +}} +pub type PFILEPATHS_A = *mut FILEPATHS_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct FILEPATHS_W { + Target: PCWSTR, + Source: PCWSTR, + Win32Error: UINT, + Flags: DWORD, +}} +pub type PFILEPATHS_W = *mut FILEPATHS_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct FILEPATHS_SIGNERINFO_A { + Target: PCSTR, + Source: PCSTR, + Win32Error: UINT, + Flags: DWORD, + DigitalSigner: PCSTR, + Version: PCSTR, + CatalogFile: PCSTR, +}} +pub type PFILEPATHS_SIGNERINFO_A = *mut FILEPATHS_SIGNERINFO_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct FILEPATHS_SIGNERINFO_W { + Target: PCWSTR, + Source: PCWSTR, + Win32Error: UINT, + Flags: DWORD, + DigitalSigner: PCWSTR, + Version: PCWSTR, + CatalogFile: PCWSTR, +}} +pub type PFILEPATHS_SIGNERINFO_W = *mut FILEPATHS_SIGNERINFO_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SOURCE_MEDIA_A { + Reserved: PCSTR, + Tagfile: PCSTR, + Description: PCSTR, + SourcePath: PCSTR, + SourceFile: PCSTR, + Flags: DWORD, +}} +pub type PSOURCE_MEDIA_A = *mut SOURCE_MEDIA_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SOURCE_MEDIA_W { + Reserved: PCWSTR, + Tagfile: PCWSTR, + Description: PCWSTR, + SourcePath: PCWSTR, + SourceFile: PCWSTR, + Flags: DWORD, +}} +pub type PSOURCE_MEDIA_W = *mut SOURCE_MEDIA_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct CABINET_INFO_A { + CabinetPath: PCSTR, + CabinetFile: PCSTR, + DiskName: PCSTR, + SetId: USHORT, + CabinetNumber: USHORT, +}} +pub type PCABINET_INFO_A = *mut CABINET_INFO_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct CABINET_INFO_W { + CabinetPath: PCWSTR, + CabinetFile: PCWSTR, + DiskName: PCWSTR, + SetId: USHORT, + CabinetNumber: USHORT, +}} +pub type PCABINET_INFO_W = *mut CABINET_INFO_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct FILE_IN_CABINET_INFO_A { + NameInCabinet: PCSTR, + FileSize: DWORD, + Win32Error: DWORD, + DosDate: WORD, + DosTime: WORD, + DosAttribs: WORD, + FullTargetName: [CHAR; MAX_PATH], +}} +pub type PFILE_IN_CABINET_INFO_A = *mut FILE_IN_CABINET_INFO_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct FILE_IN_CABINET_INFO_W { + NameInCabinet: PCWSTR, + FileSize: DWORD, + Win32Error: DWORD, + DosDate: WORD, + DosTime: WORD, + DosAttribs: WORD, + FullTargetName: [WCHAR; MAX_PATH], +}} +pub type PFILE_IN_CABINET_INFO_W = *mut FILE_IN_CABINET_INFO_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_REGISTER_CONTROL_STATUSA { + cbSize: DWORD, + FileName: PCSTR, + Win32Error: DWORD, + FailureCode: DWORD, +}} +pub type PSP_REGISTER_CONTROL_STATUSA = *mut SP_REGISTER_CONTROL_STATUSA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_REGISTER_CONTROL_STATUSW { + cbSize: DWORD, + FileName: PCWSTR, + Win32Error: DWORD, + FailureCode: DWORD, +}} +pub type PSP_REGISTER_CONTROL_STATUSW = *mut SP_REGISTER_CONTROL_STATUSW; +pub const SPREG_SUCCESS: DWORD = 0x00000000; +pub const SPREG_LOADLIBRARY: DWORD = 0x00000001; +pub const SPREG_GETPROCADDR: DWORD = 0x00000002; +pub const SPREG_REGSVR: DWORD = 0x00000003; +pub const SPREG_DLLINSTALL: DWORD = 0x00000004; +pub const SPREG_TIMEOUT: DWORD = 0x00000005; +pub const SPREG_UNKNOWN: DWORD = 0xFFFFFFFF; +pub type HSPFILEQ = PVOID; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_FILE_COPY_PARAMS_A { + cbSize: DWORD, + QueueHandle: HSPFILEQ, + SourceRootPath: PCSTR, + SourcePath: PCSTR, + SourceFilename: PCSTR, + SourceDescription: PCSTR, + SourceTagfile: PCSTR, + TargetDirectory: PCSTR, + TargetFilename: PCSTR, + CopyStyle: DWORD, + LayoutInf: HINF, + SecurityDescriptor: PCSTR, +}} +pub type PSP_FILE_COPY_PARAMS_A = *mut SP_FILE_COPY_PARAMS_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_FILE_COPY_PARAMS_W { + cbSize: DWORD, + QueueHandle: HSPFILEQ, + SourceRootPath: PCWSTR, + SourcePath: PCWSTR, + SourceFilename: PCWSTR, + SourceDescription: PCWSTR, + SourceTagfile: PCWSTR, + TargetDirectory: PCWSTR, + TargetFilename: PCWSTR, + CopyStyle: DWORD, + LayoutInf: HINF, + SecurityDescriptor: PCWSTR, +}} +pub type PSP_FILE_COPY_PARAMS_W = *mut SP_FILE_COPY_PARAMS_W; +pub type HDSKSPC = PVOID; +pub type HDEVINFO = PVOID; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DEVINFO_DATA { + cbSize: DWORD, + ClassGuid: GUID, + DevInst: DWORD, + Reserved: ULONG_PTR, +}} +pub type PSP_DEVINFO_DATA = *mut SP_DEVINFO_DATA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DEVICE_INTERFACE_DATA { + cbSize: DWORD, + InterfaceClassGuid: GUID, + Flags: DWORD, + Reserved: ULONG_PTR, +}} +pub type PSP_DEVICE_INTERFACE_DATA = *mut SP_DEVICE_INTERFACE_DATA; +pub const SPINT_ACTIVE: DWORD = 0x00000001; +pub const SPINT_DEFAULT: DWORD = 0x00000002; +pub const SPINT_REMOVED: DWORD = 0x00000004; +pub type SP_INTERFACE_DEVICE_DATA = SP_DEVICE_INTERFACE_DATA; +pub type PSP_INTERFACE_DEVICE_DATA = PSP_DEVICE_INTERFACE_DATA; +pub const SPID_ACTIVE: DWORD = SPINT_ACTIVE; +pub const SPID_DEFAULT: DWORD = SPINT_DEFAULT; +pub const SPID_REMOVED: DWORD = SPINT_REMOVED; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DEVICE_INTERFACE_DETAIL_DATA_A { + cbSize: DWORD, + DevicePath: [CHAR; ANYSIZE_ARRAY], +}} +pub type PSP_DEVICE_INTERFACE_DETAIL_DATA_A = *mut SP_DEVICE_INTERFACE_DETAIL_DATA_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DEVICE_INTERFACE_DETAIL_DATA_W { + cbSize: DWORD, + DevicePath: [WCHAR; ANYSIZE_ARRAY], +}} +pub type PSP_DEVICE_INTERFACE_DETAIL_DATA_W = *mut SP_DEVICE_INTERFACE_DETAIL_DATA_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DEVINFO_LIST_DETAIL_DATA_A { + cbSize: DWORD, + ClassGuid: GUID, + RemoteMachineHandle: HANDLE, + RemoteMachineName: [CHAR; SP_MAX_MACHINENAME_LENGTH], +}} +pub type PSP_DEVINFO_LIST_DETAIL_DATA_A = *mut SP_DEVINFO_LIST_DETAIL_DATA_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DEVINFO_LIST_DETAIL_DATA_W { + cbSize: DWORD, + ClassGuid: GUID, + RemoteMachineHandle: HANDLE, + RemoteMachineName: [WCHAR; SP_MAX_MACHINENAME_LENGTH], +}} +pub type PSP_DEVINFO_LIST_DETAIL_DATA_W = *mut SP_DEVINFO_LIST_DETAIL_DATA_W; +pub const DIF_SELECTDEVICE: DI_FUNCTION = 0x00000001; +pub const DIF_INSTALLDEVICE: DI_FUNCTION = 0x00000002; +pub const DIF_ASSIGNRESOURCES: DI_FUNCTION = 0x00000003; +pub const DIF_PROPERTIES: DI_FUNCTION = 0x00000004; +pub const DIF_REMOVE: DI_FUNCTION = 0x00000005; +pub const DIF_FIRSTTIMESETUP: DI_FUNCTION = 0x00000006; +pub const DIF_FOUNDDEVICE: DI_FUNCTION = 0x00000007; +pub const DIF_SELECTCLASSDRIVERS: DI_FUNCTION = 0x00000008; +pub const DIF_VALIDATECLASSDRIVERS: DI_FUNCTION = 0x00000009; +pub const DIF_INSTALLCLASSDRIVERS: DI_FUNCTION = 0x0000000A; +pub const DIF_CALCDISKSPACE: DI_FUNCTION = 0x0000000B; +pub const DIF_DESTROYPRIVATEDATA: DI_FUNCTION = 0x0000000C; +pub const DIF_VALIDATEDRIVER: DI_FUNCTION = 0x0000000D; +pub const DIF_DETECT: DI_FUNCTION = 0x0000000F; +pub const DIF_INSTALLWIZARD: DI_FUNCTION = 0x00000010; +pub const DIF_DESTROYWIZARDDATA: DI_FUNCTION = 0x00000011; +pub const DIF_PROPERTYCHANGE: DI_FUNCTION = 0x00000012; +pub const DIF_ENABLECLASS: DI_FUNCTION = 0x00000013; +pub const DIF_DETECTVERIFY: DI_FUNCTION = 0x00000014; +pub const DIF_INSTALLDEVICEFILES: DI_FUNCTION = 0x00000015; +pub const DIF_UNREMOVE: DI_FUNCTION = 0x00000016; +pub const DIF_SELECTBESTCOMPATDRV: DI_FUNCTION = 0x00000017; +pub const DIF_ALLOW_INSTALL: DI_FUNCTION = 0x00000018; +pub const DIF_REGISTERDEVICE: DI_FUNCTION = 0x00000019; +pub const DIF_NEWDEVICEWIZARD_PRESELECT: DI_FUNCTION = 0x0000001A; +pub const DIF_NEWDEVICEWIZARD_SELECT: DI_FUNCTION = 0x0000001B; +pub const DIF_NEWDEVICEWIZARD_PREANALYZE: DI_FUNCTION = 0x0000001C; +pub const DIF_NEWDEVICEWIZARD_POSTANALYZE: DI_FUNCTION = 0x0000001D; +pub const DIF_NEWDEVICEWIZARD_FINISHINSTALL: DI_FUNCTION = 0x0000001E; +pub const DIF_UNUSED1: DI_FUNCTION = 0x0000001F; +pub const DIF_INSTALLINTERFACES: DI_FUNCTION = 0x00000020; +pub const DIF_DETECTCANCEL: DI_FUNCTION = 0x00000021; +pub const DIF_REGISTER_COINSTALLERS: DI_FUNCTION = 0x00000022; +pub const DIF_ADDPROPERTYPAGE_ADVANCED: DI_FUNCTION = 0x00000023; +pub const DIF_ADDPROPERTYPAGE_BASIC: DI_FUNCTION = 0x00000024; +pub const DIF_RESERVED1: DI_FUNCTION = 0x00000025; +pub const DIF_TROUBLESHOOTER: DI_FUNCTION = 0x00000026; +pub const DIF_POWERMESSAGEWAKE: DI_FUNCTION = 0x00000027; +pub const DIF_ADDREMOTEPROPERTYPAGE_ADVANCED: DI_FUNCTION = 0x00000028; +pub const DIF_UPDATEDRIVER_UI: DI_FUNCTION = 0x00000029; +pub const DIF_FINISHINSTALL_ACTION: DI_FUNCTION = 0x0000002A; +pub const DIF_RESERVED2: DI_FUNCTION = 0x00000030; +pub const DIF_MOVEDEVICE: DI_FUNCTION = 0x0000000E; +pub type DI_FUNCTION = UINT; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DEVINSTALL_PARAMS_A { + cbSize: DWORD, + Flags: DWORD, + FlagsEx: DWORD, + hwndParent: HWND, + InstallMsgHandler: PSP_FILE_CALLBACK_A, + InstallMsgHandlerContext: PVOID, + FileQueue: HSPFILEQ, + ClassInstallReserved: ULONG_PTR, + Reserved: DWORD, + DriverPath: [CHAR; MAX_PATH], +}} +pub type PSP_DEVINSTALL_PARAMS_A = *mut SP_DEVINSTALL_PARAMS_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DEVINSTALL_PARAMS_W { + cbSize: DWORD, + Flags: DWORD, + FlagsEx: DWORD, + hwndParent: HWND, + InstallMsgHandler: PSP_FILE_CALLBACK_W, + InstallMsgHandlerContext: PVOID, + FileQueue: HSPFILEQ, + ClassInstallReserved: ULONG_PTR, + Reserved: DWORD, + DriverPath: [WCHAR; MAX_PATH], +}} +pub type PSP_DEVINSTALL_PARAMS_W = *mut SP_DEVINSTALL_PARAMS_W; +pub const DI_SHOWOEM: DWORD = 0x00000001; +pub const DI_SHOWCOMPAT: DWORD = 0x00000002; +pub const DI_SHOWCLASS: DWORD = 0x00000004; +pub const DI_SHOWALL: DWORD = 0x00000007; +pub const DI_NOVCP: DWORD = 0x00000008; +pub const DI_DIDCOMPAT: DWORD = 0x00000010; +pub const DI_DIDCLASS: DWORD = 0x00000020; +pub const DI_AUTOASSIGNRES: DWORD = 0x00000040; +pub const DI_NEEDRESTART: DWORD = 0x00000080; +pub const DI_NEEDREBOOT: DWORD = 0x00000100; +pub const DI_NOBROWSE: DWORD = 0x00000200; +pub const DI_MULTMFGS: DWORD = 0x00000400; +pub const DI_DISABLED: DWORD = 0x00000800; +pub const DI_GENERALPAGE_ADDED: DWORD = 0x00001000; +pub const DI_RESOURCEPAGE_ADDED: DWORD = 0x00002000; +pub const DI_PROPERTIES_CHANGE: DWORD = 0x00004000; +pub const DI_INF_IS_SORTED: DWORD = 0x00008000; +pub const DI_ENUMSINGLEINF: DWORD = 0x00010000; +pub const DI_DONOTCALLCONFIGMG: DWORD = 0x00020000; +pub const DI_INSTALLDISABLED: DWORD = 0x00040000; +pub const DI_COMPAT_FROM_CLASS: DWORD = 0x00080000; +pub const DI_CLASSINSTALLPARAMS: DWORD = 0x00100000; +pub const DI_NODI_DEFAULTACTION: DWORD = 0x00200000; +pub const DI_QUIETINSTALL: DWORD = 0x00800000; +pub const DI_NOFILECOPY: DWORD = 0x01000000; +pub const DI_FORCECOPY: DWORD = 0x02000000; +pub const DI_DRIVERPAGE_ADDED: DWORD = 0x04000000; +pub const DI_USECI_SELECTSTRINGS: DWORD = 0x08000000; +pub const DI_OVERRIDE_INFFLAGS: DWORD = 0x10000000; +pub const DI_PROPS_NOCHANGEUSAGE: DWORD = 0x20000000; +pub const DI_NOSELECTICONS: DWORD = 0x40000000; +pub const DI_NOWRITE_IDS: DWORD = 0x80000000; +pub const DI_FLAGSEX_RESERVED2: DWORD = 0x00000001; +pub const DI_FLAGSEX_RESERVED3: DWORD = 0x00000002; +pub const DI_FLAGSEX_CI_FAILED: DWORD = 0x00000004; +pub const DI_FLAGSEX_FINISHINSTALL_ACTION: DWORD = 0x00000008; +pub const DI_FLAGSEX_DIDINFOLIST: DWORD = 0x00000010; +pub const DI_FLAGSEX_DIDCOMPATINFO: DWORD = 0x00000020; +pub const DI_FLAGSEX_FILTERCLASSES: DWORD = 0x00000040; +pub const DI_FLAGSEX_SETFAILEDINSTALL: DWORD = 0x00000080; +pub const DI_FLAGSEX_DEVICECHANGE: DWORD = 0x00000100; +pub const DI_FLAGSEX_ALWAYSWRITEIDS: DWORD = 0x00000200; +pub const DI_FLAGSEX_PROPCHANGE_PENDING: DWORD = 0x00000400; +pub const DI_FLAGSEX_ALLOWEXCLUDEDDRVS: DWORD = 0x00000800; +pub const DI_FLAGSEX_NOUIONQUERYREMOVE: DWORD = 0x00001000; +pub const DI_FLAGSEX_USECLASSFORCOMPAT: DWORD = 0x00002000; +pub const DI_FLAGSEX_RESERVED4: DWORD = 0x00004000; +pub const DI_FLAGSEX_NO_DRVREG_MODIFY: DWORD = 0x00008000; +pub const DI_FLAGSEX_IN_SYSTEM_SETUP: DWORD = 0x00010000; +pub const DI_FLAGSEX_INET_DRIVER: DWORD = 0x00020000; +pub const DI_FLAGSEX_APPENDDRIVERLIST: DWORD = 0x00040000; +pub const DI_FLAGSEX_PREINSTALLBACKUP: DWORD = 0x00080000; +pub const DI_FLAGSEX_BACKUPONREPLACE: DWORD = 0x00100000; +pub const DI_FLAGSEX_DRIVERLIST_FROM_URL: DWORD = 0x00200000; +pub const DI_FLAGSEX_RESERVED1: DWORD = 0x00400000; +pub const DI_FLAGSEX_EXCLUDE_OLD_INET_DRIVERS: DWORD = 0x00800000; +pub const DI_FLAGSEX_POWERPAGE_ADDED: DWORD = 0x01000000; +pub const DI_FLAGSEX_FILTERSIMILARDRIVERS: DWORD = 0x02000000; +pub const DI_FLAGSEX_INSTALLEDDRIVER: DWORD = 0x04000000; +pub const DI_FLAGSEX_NO_CLASSLIST_NODE_MERGE: DWORD = 0x08000000; +pub const DI_FLAGSEX_ALTPLATFORM_DRVSEARCH: DWORD = 0x10000000; +pub const DI_FLAGSEX_RESTART_DEVICE_ONLY: DWORD = 0x20000000; +pub const DI_FLAGSEX_RECURSIVESEARCH: DWORD = 0x40000000; +pub const DI_FLAGSEX_SEARCH_PUBLISHED_INFS: DWORD = 0x80000000; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_CLASSINSTALL_HEADER { + cbSize: DWORD, + InstallFunction: DI_FUNCTION, +}} +pub type PSP_CLASSINSTALL_HEADER = *mut SP_CLASSINSTALL_HEADER; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_ENABLECLASS_PARAMS { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + ClassGuid: GUID, + EnableMessage: DWORD, +}} +pub type PSP_ENABLECLASS_PARAMS = *mut SP_ENABLECLASS_PARAMS; +pub const ENABLECLASS_QUERY: DWORD = 0; +pub const ENABLECLASS_SUCCESS: DWORD = 1; +pub const ENABLECLASS_FAILURE: DWORD = 2; +pub const DICS_ENABLE: DWORD = 0x00000001; +pub const DICS_DISABLE: DWORD = 0x00000002; +pub const DICS_PROPCHANGE: DWORD = 0x00000003; +pub const DICS_START: DWORD = 0x00000004; +pub const DICS_STOP: DWORD = 0x00000005; +pub const DICS_FLAG_GLOBAL: DWORD = 0x00000001; +pub const DICS_FLAG_CONFIGSPECIFIC: DWORD = 0x00000002; +pub const DICS_FLAG_CONFIGGENERAL: DWORD = 0x00000004; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_PROPCHANGE_PARAMS { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + StateChange: DWORD, + Scope: DWORD, + HwProfile: DWORD, +}} +pub type PSP_PROPCHANGE_PARAMS = *mut SP_PROPCHANGE_PARAMS; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_REMOVEDEVICE_PARAMS { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + Scope: DWORD, + HwProfile: DWORD, +}} +pub type PSP_REMOVEDEVICE_PARAMS = *mut SP_REMOVEDEVICE_PARAMS; +pub const DI_REMOVEDEVICE_GLOBAL: DWORD = 0x00000001; +pub const DI_REMOVEDEVICE_CONFIGSPECIFIC: DWORD = 0x00000002; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_UNREMOVEDEVICE_PARAMS { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + Scope: DWORD, + HwProfile: DWORD, +}} +pub type PSP_UNREMOVEDEVICE_PARAMS = *mut SP_UNREMOVEDEVICE_PARAMS; +pub const DI_UNREMOVEDEVICE_CONFIGSPECIFIC: DWORD = 0x00000002; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_SELECTDEVICE_PARAMS_A { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + Title: [CHAR; MAX_TITLE_LEN], + Instructions: [CHAR; MAX_INSTRUCTION_LEN], + ListLabel: [CHAR; MAX_LABEL_LEN], + SubTitle: [CHAR; MAX_SUBTITLE_LEN], + Reserved: [BYTE; 2], +}} +pub type PSP_SELECTDEVICE_PARAMS_A = *mut SP_SELECTDEVICE_PARAMS_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_SELECTDEVICE_PARAMS_W { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + Title: [WCHAR; MAX_TITLE_LEN], + Instructions: [WCHAR; MAX_INSTRUCTION_LEN], + ListLabel: [WCHAR; MAX_LABEL_LEN], + SubTitle: [WCHAR; MAX_SUBTITLE_LEN], +}} +pub type PSP_SELECTDEVICE_PARAMS_W = *mut SP_SELECTDEVICE_PARAMS_W; +FN!{stdcall PDETECT_PROGRESS_NOTIFY( + ProgressNotifyParam: PVOID, + DetectComplete: DWORD, +) -> BOOL} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DETECTDEVICE_PARAMS { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + DetectProgressNotify: PDETECT_PROGRESS_NOTIFY, + ProgressNotifyParam: PVOID, +}} +pub type PSP_DETECTDEVICE_PARAMS = *mut SP_DETECTDEVICE_PARAMS; +pub const MAX_INSTALLWIZARD_DYNAPAGES: usize = 20; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_INSTALLWIZARD_DATA { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + Flags: DWORD, + DynamicPages: [HPROPSHEETPAGE; MAX_INSTALLWIZARD_DYNAPAGES], + NumDynamicPages: DWORD, + DynamicPageFlags: DWORD, + PrivateFlags: DWORD, + PrivateData: LPARAM, + hwndWizardDlg: HWND, +}} +pub type PSP_INSTALLWIZARD_DATA = *mut SP_INSTALLWIZARD_DATA; +pub const NDW_INSTALLFLAG_DIDFACTDEFS: DWORD = 0x00000001; +pub const NDW_INSTALLFLAG_HARDWAREALLREADYIN: DWORD = 0x00000002; +pub const NDW_INSTALLFLAG_NEEDRESTART: DWORD = DI_NEEDRESTART; +pub const NDW_INSTALLFLAG_NEEDREBOOT: DWORD = DI_NEEDREBOOT; +pub const NDW_INSTALLFLAG_NEEDSHUTDOWN: DWORD = 0x00000200; +pub const NDW_INSTALLFLAG_EXPRESSINTRO: DWORD = 0x00000400; +pub const NDW_INSTALLFLAG_SKIPISDEVINSTALLED: DWORD = 0x00000800; +pub const NDW_INSTALLFLAG_NODETECTEDDEVS: DWORD = 0x00001000; +pub const NDW_INSTALLFLAG_INSTALLSPECIFIC: DWORD = 0x00002000; +pub const NDW_INSTALLFLAG_SKIPCLASSLIST: DWORD = 0x00004000; +pub const NDW_INSTALLFLAG_CI_PICKED_OEM: DWORD = 0x00008000; +pub const NDW_INSTALLFLAG_PCMCIAMODE: DWORD = 0x00010000; +pub const NDW_INSTALLFLAG_PCMCIADEVICE: DWORD = 0x00020000; +pub const NDW_INSTALLFLAG_USERCANCEL: DWORD = 0x00040000; +pub const NDW_INSTALLFLAG_KNOWNCLASS: DWORD = 0x00080000; +pub const DYNAWIZ_FLAG_PAGESADDED: DWORD = 0x00000001; +pub const DYNAWIZ_FLAG_ANALYZE_HANDLECONFLICT: DWORD = 0x00000008; +pub const DYNAWIZ_FLAG_INSTALLDET_NEXT: DWORD = 0x00000002; +pub const DYNAWIZ_FLAG_INSTALLDET_PREV: DWORD = 0x00000004; +pub const MIN_IDD_DYNAWIZ_RESOURCE_ID: c_int = 10000; +pub const MAX_IDD_DYNAWIZ_RESOURCE_ID: c_int = 11000; +pub const IDD_DYNAWIZ_FIRSTPAGE: c_int = 10000; +pub const IDD_DYNAWIZ_SELECT_PREVPAGE: c_int = 10001; +pub const IDD_DYNAWIZ_SELECT_NEXTPAGE: c_int = 10002; +pub const IDD_DYNAWIZ_ANALYZE_PREVPAGE: c_int = 10003; +pub const IDD_DYNAWIZ_ANALYZE_NEXTPAGE: c_int = 10004; +pub const IDD_DYNAWIZ_SELECTDEV_PAGE: c_int = 10009; +pub const IDD_DYNAWIZ_ANALYZEDEV_PAGE: c_int = 10010; +pub const IDD_DYNAWIZ_INSTALLDETECTEDDEVS_PAGE: c_int = 10011; +pub const IDD_DYNAWIZ_SELECTCLASS_PAGE: c_int = 10012; +pub const IDD_DYNAWIZ_INSTALLDETECTED_PREVPAGE: c_int = 10006; +pub const IDD_DYNAWIZ_INSTALLDETECTED_NEXTPAGE: c_int = 10007; +pub const IDD_DYNAWIZ_INSTALLDETECTED_NODEVS: c_int = 10008; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_NEWDEVICEWIZARD_DATA { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + Flags: DWORD, + DynamicPages: [HPROPSHEETPAGE; MAX_INSTALLWIZARD_DYNAPAGES], + NumDynamicPages: DWORD, + hwndWizardDlg: HWND, +}} +pub type PSP_NEWDEVICEWIZARD_DATA = *mut SP_NEWDEVICEWIZARD_DATA; +pub type SP_ADDPROPERTYPAGE_DATA = SP_NEWDEVICEWIZARD_DATA; +pub type PSP_ADDPROPERTYPAGE_DATA = PSP_NEWDEVICEWIZARD_DATA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_TROUBLESHOOTER_PARAMS_A { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + ChmFile: [CHAR; MAX_PATH], + HtmlTroubleShooter: [CHAR; MAX_PATH], +}} +pub type PSP_TROUBLESHOOTER_PARAMS_A = *mut SP_TROUBLESHOOTER_PARAMS_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_TROUBLESHOOTER_PARAMS_W { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + ChmFile: [WCHAR; MAX_PATH], + HtmlTroubleShooter: [WCHAR; MAX_PATH], +}} +pub type PSP_TROUBLESHOOTER_PARAMS_W = *mut SP_TROUBLESHOOTER_PARAMS_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_POWERMESSAGEWAKE_PARAMS_A { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + PowerMessageWake: [CHAR; LINE_LEN * 2], +}} +pub type PSP_POWERMESSAGEWAKE_PARAMS_A = *mut SP_POWERMESSAGEWAKE_PARAMS_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_POWERMESSAGEWAKE_PARAMS_W { + ClassInstallHeader: SP_CLASSINSTALL_HEADER, + PowerMessageWake: [WCHAR; LINE_LEN * 2], +}} +pub type PSP_POWERMESSAGEWAKE_PARAMS_W = *mut SP_POWERMESSAGEWAKE_PARAMS_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DRVINFO_DATA_V2_A { + cbSize: DWORD, + DriverType: DWORD, + Reserved: ULONG_PTR, + Description: [CHAR; LINE_LEN], + MfgName: [CHAR; LINE_LEN], + ProviderName: [CHAR; LINE_LEN], + DriverDate: FILETIME, + DriverVersion: DWORDLONG, +}} +pub type PSP_DRVINFO_DATA_V2_A = *mut SP_DRVINFO_DATA_V2_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DRVINFO_DATA_V2_W { + cbSize: DWORD, + DriverType: DWORD, + Reserved: ULONG_PTR, + Description: [WCHAR; LINE_LEN], + MfgName: [WCHAR; LINE_LEN], + ProviderName: [WCHAR; LINE_LEN], + DriverDate: FILETIME, + DriverVersion: DWORDLONG, +}} +pub type PSP_DRVINFO_DATA_V2_W = *mut SP_DRVINFO_DATA_V2_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DRVINFO_DATA_V1_A { + cbSize: DWORD, + DriverType: DWORD, + Reserved: ULONG_PTR, + Description: [CHAR; LINE_LEN], + MfgName: [CHAR; LINE_LEN], + ProviderName: [CHAR; LINE_LEN], +}} +pub type PSP_DRVINFO_DATA_V1_A = *mut SP_DRVINFO_DATA_V1_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DRVINFO_DATA_V1_W { + cbSize: DWORD, + DriverType: DWORD, + Reserved: ULONG_PTR, + Description: [WCHAR; LINE_LEN], + MfgName: [WCHAR; LINE_LEN], + ProviderName: [WCHAR; LINE_LEN], +}} +pub type PSP_DRVINFO_DATA_V1_W = *mut SP_DRVINFO_DATA_V1_W; +pub type SP_DRVINFO_DATA_A = SP_DRVINFO_DATA_V2_A; +pub type PSP_DRVINFO_DATA_A = PSP_DRVINFO_DATA_V2_A; +pub type SP_DRVINFO_DATA_W = SP_DRVINFO_DATA_V2_W; +pub type PSP_DRVINFO_DATA_W = PSP_DRVINFO_DATA_V2_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DRVINFO_DETAIL_DATA_A { + cbSize: DWORD, + InfDate: FILETIME, + CompatIDsOffset: DWORD, + CompatIDsLength: DWORD, + Reserved: ULONG_PTR, + SectionName: [CHAR; LINE_LEN], + InfFileName: [CHAR; MAX_PATH], + DrvDescription: [CHAR; LINE_LEN], + HardwareID: [CHAR; ANYSIZE_ARRAY], +}} +pub type PSP_DRVINFO_DETAIL_DATA_A = *mut SP_DRVINFO_DETAIL_DATA_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DRVINFO_DETAIL_DATA_W { + cbSize: DWORD, + InfDate: FILETIME, + CompatIDsOffset: DWORD, + CompatIDsLength: DWORD, + Reserved: ULONG_PTR, + SectionName: [WCHAR; LINE_LEN], + InfFileName: [WCHAR; MAX_PATH], + DrvDescription: [WCHAR; LINE_LEN], + HardwareID: [WCHAR; ANYSIZE_ARRAY], +}} +pub type PSP_DRVINFO_DETAIL_DATA_W = *mut SP_DRVINFO_DETAIL_DATA_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_DRVINSTALL_PARAMS { + cbSize: DWORD, + Rank: DWORD, + Flags: DWORD, + PrivateData: DWORD_PTR, + Reserved: DWORD, +}} +pub type PSP_DRVINSTALL_PARAMS = *mut SP_DRVINSTALL_PARAMS; +pub const DNF_DUPDESC: DWORD = 0x00000001; +pub const DNF_OLDDRIVER: DWORD = 0x00000002; +pub const DNF_EXCLUDEFROMLIST: DWORD = 0x00000004; +pub const DNF_NODRIVER: DWORD = 0x00000008; +pub const DNF_LEGACYINF: DWORD = 0x00000010; +pub const DNF_CLASS_DRIVER: DWORD = 0x00000020; +pub const DNF_COMPATIBLE_DRIVER: DWORD = 0x00000040; +pub const DNF_INET_DRIVER: DWORD = 0x00000080; +pub const DNF_UNUSED1: DWORD = 0x00000100; +pub const DNF_UNUSED2: DWORD = 0x00000200; +pub const DNF_OLD_INET_DRIVER: DWORD = 0x00000400; +pub const DNF_BAD_DRIVER: DWORD = 0x00000800; +pub const DNF_DUPPROVIDER: DWORD = 0x00001000; +pub const DNF_INF_IS_SIGNED: DWORD = 0x00002000; +pub const DNF_OEM_F6_INF: DWORD = 0x00004000; +pub const DNF_DUPDRIVERVER: DWORD = 0x00008000; +pub const DNF_BASIC_DRIVER: DWORD = 0x00010000; +pub const DNF_AUTHENTICODE_SIGNED: DWORD = 0x00020000; +pub const DNF_INSTALLEDDRIVER: DWORD = 0x00040000; +pub const DNF_ALWAYSEXCLUDEFROMLIST: DWORD = 0x00080000; +pub const DNF_INBOX_DRIVER: DWORD = 0x00100000; +pub const DNF_REQUESTADDITIONALSOFTWARE: DWORD = 0x00200000; +pub const DNF_UNUSED_22: DWORD = 0x00400000; +pub const DNF_UNUSED_23: DWORD = 0x00800000; +pub const DNF_UNUSED_24: DWORD = 0x01000000; +pub const DNF_UNUSED_25: DWORD = 0x02000000; +pub const DNF_UNUSED_26: DWORD = 0x04000000; +pub const DNF_UNUSED_27: DWORD = 0x08000000; +pub const DNF_UNUSED_28: DWORD = 0x10000000; +pub const DNF_UNUSED_29: DWORD = 0x20000000; +pub const DNF_UNUSED_30: DWORD = 0x40000000; +pub const DNF_UNUSED_31: DWORD = 0x80000000; +pub const DRIVER_HARDWAREID_RANK: DWORD = 0x00000FFF; +pub const DRIVER_HARDWAREID_MASK: DWORD = 0x80000FFF; +pub const DRIVER_UNTRUSTED_RANK: DWORD = 0x80000000; +pub const DRIVER_W9X_SUSPECT_RANK: DWORD = 0xC0000000; +FN!{stdcall PSP_DETSIG_CMPPROC( + DeviceInfoSet: HDEVINFO, + NewDeviceData: PSP_DEVINFO_DATA, + ExistingDeviceData: PSP_DEVINFO_DATA, + CompareContext: PVOID, +) -> DWORD} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct COINSTALLER_CONTEXT_DATA { + PostProcessing: BOOL, + InstallResult: DWORD, + PrivateData: PVOID, +}} +pub type PCOINSTALLER_CONTEXT_DATA = *mut COINSTALLER_CONTEXT_DATA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_CLASSIMAGELIST_DATA { + cbSize: DWORD, + ImageList: HIMAGELIST, + Reserved: ULONG_PTR, +}} +pub type PSP_CLASSIMAGELIST_DATA = *mut SP_CLASSIMAGELIST_DATA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_PROPSHEETPAGE_REQUEST { + cbSize: DWORD, + PageRequested: DWORD, + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, +}} +pub type PSP_PROPSHEETPAGE_REQUEST = *mut SP_PROPSHEETPAGE_REQUEST; +pub const SPPSR_SELECT_DEVICE_RESOURCES: DWORD = 1; +pub const SPPSR_ENUM_BASIC_DEVICE_PROPERTIES: DWORD = 2; +pub const SPPSR_ENUM_ADV_DEVICE_PROPERTIES: DWORD = 3; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_BACKUP_QUEUE_PARAMS_V2_A { + cbSize: DWORD, + FullInfPath: [CHAR; MAX_PATH], + FilenameOffset: INT, + ReinstallInstance: [CHAR; MAX_PATH], +}} +pub type PSP_BACKUP_QUEUE_PARAMS_V2_A = *mut SP_BACKUP_QUEUE_PARAMS_V2_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_BACKUP_QUEUE_PARAMS_V2_W { + cbSize: DWORD, + FullInfPath: [WCHAR; MAX_PATH], + FilenameOffset: INT, + ReinstallInstance: [WCHAR; MAX_PATH], +}} +pub type PSP_BACKUP_QUEUE_PARAMS_V2_W = *mut SP_BACKUP_QUEUE_PARAMS_V2_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_BACKUP_QUEUE_PARAMS_V1_A { + cbSize: DWORD, + FullInfPath: [CHAR; MAX_PATH], + FilenameOffset: INT, +}} +pub type PSP_BACKUP_QUEUE_PARAMS_V1_A = *mut SP_BACKUP_QUEUE_PARAMS_V1_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_BACKUP_QUEUE_PARAMS_V1_W { + cbSize: DWORD, + FullInfPath: [WCHAR; MAX_PATH], + FilenameOffset: INT, +}} +pub type PSP_BACKUP_QUEUE_PARAMS_V1_W = *mut SP_BACKUP_QUEUE_PARAMS_V1_W; +pub type SP_BACKUP_QUEUE_PARAMS_A = SP_BACKUP_QUEUE_PARAMS_V2_A; +pub type PSP_BACKUP_QUEUE_PARAMS_A = PSP_BACKUP_QUEUE_PARAMS_V2_A; +pub type SP_BACKUP_QUEUE_PARAMS_W = SP_BACKUP_QUEUE_PARAMS_V2_W; +pub type PSP_BACKUP_QUEUE_PARAMS_W = PSP_BACKUP_QUEUE_PARAMS_V2_W; +pub const ERROR_EXPECTED_SECTION_NAME: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0; +pub const ERROR_BAD_SECTION_NAME_LINE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 1; +pub const ERROR_SECTION_NAME_TOO_LONG: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 2; +pub const ERROR_GENERAL_SYNTAX: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 3; +pub const ERROR_WRONG_INF_STYLE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x100; +pub const ERROR_SECTION_NOT_FOUND: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x101; +pub const ERROR_LINE_NOT_FOUND: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x102; +pub const ERROR_NO_BACKUP: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x103; +pub const ERROR_NO_ASSOCIATED_CLASS: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x200; +pub const ERROR_CLASS_MISMATCH: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x201; +pub const ERROR_DUPLICATE_FOUND: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x202; +pub const ERROR_NO_DRIVER_SELECTED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x203; +pub const ERROR_KEY_DOES_NOT_EXIST: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x204; +pub const ERROR_INVALID_DEVINST_NAME: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x205; +pub const ERROR_INVALID_CLASS: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x206; +pub const ERROR_DEVINST_ALREADY_EXISTS: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x207; +pub const ERROR_DEVINFO_NOT_REGISTERED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x208; +pub const ERROR_INVALID_REG_PROPERTY: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x209; +pub const ERROR_NO_INF: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20A; +pub const ERROR_NO_SUCH_DEVINST: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20B; +pub const ERROR_CANT_LOAD_CLASS_ICON: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x20C; +pub const ERROR_INVALID_CLASS_INSTALLER: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x20D; +pub const ERROR_DI_DO_DEFAULT: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20E; +pub const ERROR_DI_NOFILECOPY: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20F; +pub const ERROR_INVALID_HWPROFILE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x210; +pub const ERROR_NO_DEVICE_SELECTED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x211; +pub const ERROR_DEVINFO_LIST_LOCKED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x212; +pub const ERROR_DEVINFO_DATA_LOCKED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x213; +pub const ERROR_DI_BAD_PATH: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x214; +pub const ERROR_NO_CLASSINSTALL_PARAMS: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x215; +pub const ERROR_FILEQUEUE_LOCKED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x216; +pub const ERROR_BAD_SERVICE_INSTALLSECT: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x217; +pub const ERROR_NO_CLASS_DRIVER_LIST: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x218; +pub const ERROR_NO_ASSOCIATED_SERVICE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x219; +pub const ERROR_NO_DEFAULT_DEVICE_INTERFACE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x21A; +pub const ERROR_DEVICE_INTERFACE_ACTIVE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x21B; +pub const ERROR_DEVICE_INTERFACE_REMOVED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x21C; +pub const ERROR_BAD_INTERFACE_INSTALLSECT: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x21D; +pub const ERROR_NO_SUCH_INTERFACE_CLASS: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x21E; +pub const ERROR_INVALID_REFERENCE_STRING: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x21F; +pub const ERROR_INVALID_MACHINENAME: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x220; +pub const ERROR_REMOTE_COMM_FAILURE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x221; +pub const ERROR_MACHINE_UNAVAILABLE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x222; +pub const ERROR_NO_CONFIGMGR_SERVICES: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x223; +pub const ERROR_INVALID_PROPPAGE_PROVIDER: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x224; +pub const ERROR_NO_SUCH_DEVICE_INTERFACE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x225; +pub const ERROR_DI_POSTPROCESSING_REQUIRED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x226; +pub const ERROR_INVALID_COINSTALLER: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x227; +pub const ERROR_NO_COMPAT_DRIVERS: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x228; +pub const ERROR_NO_DEVICE_ICON: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x229; +pub const ERROR_INVALID_INF_LOGCONFIG: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x22A; +pub const ERROR_DI_DONT_INSTALL: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22B; +pub const ERROR_INVALID_FILTER_DRIVER: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x22C; +pub const ERROR_NON_WINDOWS_NT_DRIVER: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x22D; +pub const ERROR_NON_WINDOWS_DRIVER: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22E; +pub const ERROR_NO_CATALOG_FOR_OEM_INF: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x22F; +pub const ERROR_DEVINSTALL_QUEUE_NONNATIVE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x230; +pub const ERROR_NOT_DISABLEABLE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x231; +pub const ERROR_CANT_REMOVE_DEVINST: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x232; +pub const ERROR_INVALID_TARGET: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x233; +pub const ERROR_DRIVER_NONNATIVE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x234; +pub const ERROR_IN_WOW64: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x235; +pub const ERROR_SET_SYSTEM_RESTORE_POINT: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x236; +pub const ERROR_SCE_DISABLED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x238; +pub const ERROR_UNKNOWN_EXCEPTION: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x239; +pub const ERROR_PNP_REGISTRY_ERROR: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x23A; +pub const ERROR_REMOTE_REQUEST_UNSUPPORTED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x23B; +pub const ERROR_NOT_AN_INSTALLED_OEM_INF: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x23C; +pub const ERROR_INF_IN_USE_BY_DEVICES: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x23D; +pub const ERROR_DI_FUNCTION_OBSOLETE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x23E; +pub const ERROR_NO_AUTHENTICODE_CATALOG: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x23F; +pub const ERROR_AUTHENTICODE_DISALLOWED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x240; +pub const ERROR_AUTHENTICODE_TRUSTED_PUBLISHER: DWORD = APPLICATION_ERROR_MASK + | ERROR_SEVERITY_ERROR | 0x241; +pub const ERROR_AUTHENTICODE_TRUST_NOT_ESTABLISHED: DWORD = APPLICATION_ERROR_MASK + | ERROR_SEVERITY_ERROR | 0x242; +pub const ERROR_AUTHENTICODE_PUBLISHER_NOT_TRUSTED: DWORD = APPLICATION_ERROR_MASK + | ERROR_SEVERITY_ERROR | 0x243; +pub const ERROR_SIGNATURE_OSATTRIBUTE_MISMATCH: DWORD = APPLICATION_ERROR_MASK + | ERROR_SEVERITY_ERROR | 0x244; +pub const ERROR_ONLY_VALIDATE_VIA_AUTHENTICODE: DWORD = APPLICATION_ERROR_MASK + | ERROR_SEVERITY_ERROR | 0x245; +pub const ERROR_DEVICE_INSTALLER_NOT_READY: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x246; +pub const ERROR_DRIVER_STORE_ADD_FAILED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x247; +pub const ERROR_DEVICE_INSTALL_BLOCKED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x248; +pub const ERROR_DRIVER_INSTALL_BLOCKED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x249; +pub const ERROR_WRONG_INF_TYPE: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x24A; +pub const ERROR_FILE_HASH_NOT_IN_CATALOG: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x24B; +pub const ERROR_DRIVER_STORE_DELETE_FAILED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x24C; +pub const ERROR_UNRECOVERABLE_STACK_OVERFLOW: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x300; +pub const EXCEPTION_SPAPI_UNRECOVERABLE_STACK_OVERFLOW: DWORD = ERROR_UNRECOVERABLE_STACK_OVERFLOW; +pub const ERROR_NO_DEFAULT_INTERFACE_DEVICE: DWORD = ERROR_NO_DEFAULT_DEVICE_INTERFACE; +pub const ERROR_INTERFACE_DEVICE_ACTIVE: DWORD = ERROR_DEVICE_INTERFACE_ACTIVE; +pub const ERROR_INTERFACE_DEVICE_REMOVED: DWORD = ERROR_DEVICE_INTERFACE_REMOVED; +pub const ERROR_NO_SUCH_INTERFACE_DEVICE: DWORD = ERROR_NO_SUCH_DEVICE_INTERFACE; +pub const ERROR_NOT_INSTALLED: DWORD = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR + | 0x1000; +extern "system" { + pub fn SetupGetInfInformationA( + InfSpec: LPCVOID, + SearchControl: DWORD, + ReturnBuffer: PSP_INF_INFORMATION, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetInfInformationW( + InfSpec: LPCVOID, + SearchControl: DWORD, + ReturnBuffer: PSP_INF_INFORMATION, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; +} +pub const INFINFO_INF_SPEC_IS_HINF: DWORD = 1; +pub const INFINFO_INF_NAME_IS_ABSOLUTE: DWORD = 2; +pub const INFINFO_DEFAULT_SEARCH: DWORD = 3; +pub const INFINFO_REVERSE_DEFAULT_SEARCH: DWORD = 4; +pub const INFINFO_INF_PATH_LIST_SEARCH: DWORD = 5; +extern "system" { + pub fn SetupQueryInfFileInformationA( + InfInformation: PSP_INF_INFORMATION, + InfIndex: UINT, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupQueryInfFileInformationW( + InfInformation: PSP_INF_INFORMATION, + InfIndex: UINT, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupQueryInfOriginalFileInformationA( + InfInformation: PSP_INF_INFORMATION, + InfIndex: UINT, + AlternatePlatformInfo: PSP_ALTPLATFORM_INFO, + OriginalFileInfo: PSP_ORIGINAL_FILE_INFO_A, + ) -> BOOL; + pub fn SetupQueryInfOriginalFileInformationW( + InfInformation: PSP_INF_INFORMATION, + InfIndex: UINT, + AlternatePlatformInfo: PSP_ALTPLATFORM_INFO, + OriginalFileInfo: PSP_ORIGINAL_FILE_INFO_W, + ) -> BOOL; + pub fn SetupQueryInfVersionInformationA( + InfInformation: PSP_INF_INFORMATION, + InfIndex: UINT, + Key: PCSTR, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupQueryInfVersionInformationW( + InfInformation: PSP_INF_INFORMATION, + InfIndex: UINT, + Key: PCWSTR, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetInfDriverStoreLocationA( + FileName: PCSTR, + AlternatePlatformInfo: PSP_ALTPLATFORM_INFO, + LocaleName: PCSTR, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetInfDriverStoreLocationW( + FileName: PCWSTR, + AlternatePlatformInfo: PSP_ALTPLATFORM_INFO, + LocaleName: PCWSTR, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetInfPublishedNameA( + DriverStoreLocation: PCSTR, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetInfPublishedNameW( + DriverStoreLocation: PCWSTR, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetInfFileListA( + DirectoryPath: PCSTR, + InfStyle: DWORD, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetInfFileListW( + DirectoryPath: PCWSTR, + InfStyle: DWORD, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupOpenInfFileW( + FileName: PCWSTR, + InfClass: PCWSTR, + InfStyle: DWORD, + ErrorLine: PUINT, + ) -> HINF; + pub fn SetupOpenInfFileA( + FileName: PCSTR, + InfClass: PCSTR, + InfStyle: DWORD, + ErrorLine: PUINT, + ) -> HINF; + pub fn SetupOpenMasterInf() -> HINF; + pub fn SetupOpenAppendInfFileW( + FileName: PCWSTR, + InfHandle: HINF, + ErrorLine: PUINT, + ) -> BOOL; + pub fn SetupOpenAppendInfFileA( + FileName: PCSTR, + InfHandle: HINF, + ErrorLine: PUINT, + ) -> BOOL; + pub fn SetupCloseInfFile( + InfHandle: HINF, + ) -> (); + pub fn SetupFindFirstLineA( + InfHandle: HINF, + Section: PCSTR, + Key: PCSTR, + Context: PINFCONTEXT, + ) -> BOOL; + pub fn SetupFindFirstLineW( + InfHandle: HINF, + Section: PCWSTR, + Key: PCWSTR, + Context: PINFCONTEXT, + ) -> BOOL; + pub fn SetupFindNextLine( + ContextIn: PINFCONTEXT, + ContextOut: PINFCONTEXT, + ) -> BOOL; + pub fn SetupFindNextMatchLineA( + ContextIn: PINFCONTEXT, + Key: PCSTR, + ContextOut: PINFCONTEXT, + ) -> BOOL; + pub fn SetupFindNextMatchLineW( + ContextIn: PINFCONTEXT, + Key: PCWSTR, + ContextOut: PINFCONTEXT, + ) -> BOOL; + pub fn SetupGetLineByIndexA( + InfHandle: HINF, + Section: PCSTR, + Index: DWORD, + Context: PINFCONTEXT, + ) -> BOOL; + pub fn SetupGetLineByIndexW( + InfHandle: HINF, + Section: PCWSTR, + Index: DWORD, + Context: PINFCONTEXT, + ) -> BOOL; + pub fn SetupGetLineCountA( + InfHandle: HINF, + Section: PCSTR, + ) -> LONG; + pub fn SetupGetLineCountW( + InfHandle: HINF, + Section: PCWSTR, + ) -> LONG; + pub fn SetupGetLineTextA( + Context: PINFCONTEXT, + InfHandle: HINF, + Section: PCSTR, + Key: PCSTR, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + ReturnBufferSize: PDWORD, + ) -> BOOL; + pub fn SetupGetLineTextW( + Context: PINFCONTEXT, + InfHandle: HINF, + Section: PCWSTR, + Key: PCWSTR, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + ReturnBufferSize: PDWORD, + ) -> BOOL; + pub fn SetupGetFieldCount( + Context: PINFCONTEXT, + ) -> DWORD; + pub fn SetupGetStringFieldA( + Context: PINFCONTEXT, + FieldIndex: DWORD, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetStringFieldW( + Context: PINFCONTEXT, + FieldIndex: DWORD, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetIntField( + Context: PINFCONTEXT, + FieldIndex: DWORD, + IntegerValue: PINT, + ) -> BOOL; + pub fn SetupGetMultiSzFieldA( + Context: PINFCONTEXT, + FieldIndex: DWORD, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: LPDWORD, + ) -> BOOL; + pub fn SetupGetMultiSzFieldW( + Context: PINFCONTEXT, + FieldIndex: DWORD, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: LPDWORD, + ) -> BOOL; + pub fn SetupGetBinaryField( + Context: PINFCONTEXT, + FieldIndex: DWORD, + ReturnBuffer: PBYTE, + ReturnBufferSize: DWORD, + RequiredSize: LPDWORD, + ) -> BOOL; + pub fn SetupGetFileCompressionInfoA( + SourceFileName: PCSTR, + ActualSourceFileName: *mut PSTR, + SourceFileSize: PDWORD, + TargetFileSize: PDWORD, + CompressionType: PUINT, + ) -> DWORD; + pub fn SetupGetFileCompressionInfoW( + SourceFileName: PCWSTR, + ActualSourceFileName: *mut PWSTR, + SourceFileSize: PDWORD, + TargetFileSize: PDWORD, + CompressionType: PUINT, + ) -> DWORD; + pub fn SetupGetFileCompressionInfoExA( + SourceFileName: PCSTR, + ActualSourceFileNameBuffer: PSTR, + ActualSourceFileNameBufferLen: DWORD, + RequiredBufferLen: PDWORD, + SourceFileSize: PDWORD, + TargetFileSize: PDWORD, + CompressionType: PUINT, + ) -> BOOL; + pub fn SetupGetFileCompressionInfoExW( + SourceFileName: PCWSTR, + ActualSourceFileNameBuffer: PWSTR, + ActualSourceFileNameBufferLen: DWORD, + RequiredBufferLen: PDWORD, + SourceFileSize: PDWORD, + TargetFileSize: PDWORD, + CompressionType: PUINT, + ) -> BOOL; +} +pub const FILE_COMPRESSION_NONE: UINT = 0; +pub const FILE_COMPRESSION_WINLZA: UINT = 1; +pub const FILE_COMPRESSION_MSZIP: UINT = 2; +pub const FILE_COMPRESSION_NTCAB: UINT = 3; +extern "system" { + pub fn SetupDecompressOrCopyFileA( + SourceFileName: PCSTR, + TargetFileName: PCSTR, + CompressionType: PUINT, + ) -> DWORD; + pub fn SetupDecompressOrCopyFileW( + SourceFileName: PCWSTR, + TargetFileName: PCWSTR, + CompressionType: PUINT, + ) -> DWORD; + pub fn SetupGetSourceFileLocationA( + InfHandle: HINF, + InfContext: PINFCONTEXT, + FileName: PCSTR, + SourceId: PUINT, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetSourceFileLocationW( + InfHandle: HINF, + InfContext: PINFCONTEXT, + FileName: PCWSTR, + SourceId: PUINT, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetSourceFileSizeA( + InfHandle: HINF, + InfContext: PINFCONTEXT, + FileName: PCSTR, + Section: PCSTR, + FileSize: PDWORD, + RoundingFactor: UINT, + ) -> BOOL; + pub fn SetupGetSourceFileSizeW( + InfHandle: HINF, + InfContext: PINFCONTEXT, + FileName: PCWSTR, + Section: PCWSTR, + FileSize: PDWORD, + RoundingFactor: UINT, + ) -> BOOL; + pub fn SetupGetTargetPathA( + InfHandle: HINF, + InfContext: PINFCONTEXT, + Section: PCSTR, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetTargetPathW( + InfHandle: HINF, + InfContext: PINFCONTEXT, + Section: PCWSTR, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; +} +pub const SRCLIST_TEMPORARY: DWORD = 0x00000001; +pub const SRCLIST_NOBROWSE: DWORD = 0x00000002; +pub const SRCLIST_SYSTEM: DWORD = 0x00000010; +pub const SRCLIST_USER: DWORD = 0x00000020; +pub const SRCLIST_SYSIFADMIN: DWORD = 0x00000040; +pub const SRCLIST_SUBDIRS: DWORD = 0x00000100; +pub const SRCLIST_APPEND: DWORD = 0x00000200; +pub const SRCLIST_NOSTRIPPLATFORM: DWORD = 0x00000400; +extern "system" { + pub fn SetupSetSourceListA( + Flags: DWORD, + SourceList: *mut PCSTR, + SourceCount: UINT, + ) -> BOOL; + pub fn SetupSetSourceListW( + Flags: DWORD, + SourceList: *mut PCWSTR, + SourceCount: UINT, + ) -> BOOL; + pub fn SetupCancelTemporarySourceList() -> BOOL; + pub fn SetupAddToSourceListA( + Flags: DWORD, + Source: PCSTR, + ) -> BOOL; + pub fn SetupAddToSourceListW( + Flags: DWORD, + Source: PCWSTR, + ) -> BOOL; + pub fn SetupRemoveFromSourceListA( + Flags: DWORD, + Source: PCSTR, + ) -> BOOL; + pub fn SetupRemoveFromSourceListW( + Flags: DWORD, + Source: PCWSTR, + ) -> BOOL; + pub fn SetupQuerySourceListA( + Flags: DWORD, + List: *mut *mut PCSTR, + Count: PUINT, + ) -> BOOL; + pub fn SetupQuerySourceListW( + Flags: DWORD, + List: *mut *mut PCWSTR, + Count: PUINT, + ) -> BOOL; + pub fn SetupFreeSourceListA( + List: *mut *mut PCSTR, + Count: UINT, + ) -> BOOL; + pub fn SetupFreeSourceListW( + List: *mut *mut PCWSTR, + Count: UINT, + ) -> BOOL; + pub fn SetupPromptForDiskA( + hwndParent: HWND, + DialogTitle: PCSTR, + DiskName: PCSTR, + PathToSource: PCSTR, + FileSought: PCSTR, + TagFile: PCSTR, + DiskPromptStyle: DWORD, + PathBuffer: PSTR, + PathBufferSize: DWORD, + PathRequiredSize: PDWORD, + ) -> UINT; + pub fn SetupPromptForDiskW( + hwndParent: HWND, + DialogTitle: PCWSTR, + DiskName: PCWSTR, + PathToSource: PCWSTR, + FileSought: PCWSTR, + TagFile: PCWSTR, + DiskPromptStyle: DWORD, + PathBuffer: PWSTR, + PathBufferSize: DWORD, + PathRequiredSize: PDWORD, + ) -> UINT; + pub fn SetupCopyErrorA( + hwndParent: HWND, + DialogTitle: PCSTR, + DiskName: PCSTR, + PathToSource: PCSTR, + SourceFile: PCSTR, + TargetPathFile: PCSTR, + Win32ErrorCode: UINT, + Style: DWORD, + PathBuffer: PSTR, + PathBufferSize: DWORD, + PathRequiredSize: PDWORD, + ) -> UINT; + pub fn SetupCopyErrorW( + hwndParent: HWND, + DialogTitle: PCWSTR, + DiskName: PCWSTR, + PathToSource: PCWSTR, + SourceFile: PCWSTR, + TargetPathFile: PCWSTR, + Win32ErrorCode: UINT, + Style: DWORD, + PathBuffer: PWSTR, + PathBufferSize: DWORD, + PathRequiredSize: PDWORD, + ) -> UINT; + pub fn SetupRenameErrorA( + hwndParent: HWND, + DialogTitle: PCSTR, + SourceFile: PCSTR, + TargetFile: PCSTR, + Win32ErrorCode: UINT, + Style: DWORD, + ) -> UINT; + pub fn SetupRenameErrorW( + hwndParent: HWND, + DialogTitle: PCWSTR, + SourceFile: PCWSTR, + TargetFile: PCWSTR, + Win32ErrorCode: UINT, + Style: DWORD, + ) -> UINT; + pub fn SetupDeleteErrorA( + hwndParent: HWND, + DialogTitle: PCSTR, + File: PCSTR, + Win32ErrorCode: UINT, + Style: DWORD, + ) -> UINT; + pub fn SetupDeleteErrorW( + hwndParent: HWND, + DialogTitle: PCWSTR, + File: PCWSTR, + Win32ErrorCode: UINT, + Style: DWORD, + ) -> UINT; + pub fn SetupBackupErrorA( + hwndParent: HWND, + DialogTitle: PCSTR, + SourceFile: PCSTR, + TargetFile: PCSTR, + Win32ErrorCode: UINT, + Style: DWORD, + ) -> UINT; + pub fn SetupBackupErrorW( + hwndParent: HWND, + DialogTitle: PCWSTR, + SourceFile: PCWSTR, + TargetFile: PCWSTR, + Win32ErrorCode: UINT, + Style: DWORD, + ) -> UINT; +} +pub const IDF_NOBROWSE: DWORD = 0x00000001; +pub const IDF_NOSKIP: DWORD = 0x00000002; +pub const IDF_NODETAILS: DWORD = 0x00000004; +pub const IDF_NOCOMPRESSED: DWORD = 0x00000008; +pub const IDF_CHECKFIRST: DWORD = 0x00000100; +pub const IDF_NOBEEP: DWORD = 0x00000200; +pub const IDF_NOFOREGROUND: DWORD = 0x00000400; +pub const IDF_WARNIFSKIP: DWORD = 0x00000800; +pub const IDF_NOREMOVABLEMEDIAPROMPT: DWORD = 0x00001000; +pub const IDF_USEDISKNAMEASPROMPT: DWORD = 0x00002000; +pub const IDF_OEMDISK: DWORD = 0x80000000; +pub const DPROMPT_SUCCESS: UINT = 0; +pub const DPROMPT_CANCEL: UINT = 1; +pub const DPROMPT_SKIPFILE: UINT = 2; +pub const DPROMPT_BUFFERTOOSMALL: UINT = 3; +pub const DPROMPT_OUTOFMEMORY: UINT = 4; +extern "system" { + pub fn SetupSetDirectoryIdA( + InfHandle: HINF, + Id: DWORD, + Directory: PCSTR, + ) -> BOOL; + pub fn SetupSetDirectoryIdW( + InfHandle: HINF, + Id: DWORD, + Directory: PCWSTR, + ) -> BOOL; + pub fn SetupSetDirectoryIdExA( + InfHandle: HINF, + Id: DWORD, + Directory: PCSTR, + Flags: DWORD, + Reserved1: DWORD, + Reserved2: PVOID, + ) -> BOOL; + pub fn SetupSetDirectoryIdExW( + InfHandle: HINF, + Id: DWORD, + Directory: PCWSTR, + Flags: DWORD, + Reserved1: DWORD, + Reserved2: PVOID, + ) -> BOOL; +} +pub const SETDIRID_NOT_FULL_PATH: DWORD = 0x00000001; +extern "system" { + pub fn SetupGetSourceInfoA( + InfHandle: HINF, + SourceId: UINT, + InfoDesired: UINT, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupGetSourceInfoW( + InfHandle: HINF, + SourceId: UINT, + InfoDesired: UINT, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; +} +pub const SRCINFO_PATH: UINT = 1; +pub const SRCINFO_TAGFILE: UINT = 2; +pub const SRCINFO_DESCRIPTION: UINT = 3; +pub const SRCINFO_FLAGS: UINT = 4; +pub const SRCINFO_TAGFILE2: UINT = 4; +pub const SRC_FLAGS_CABFILE: UINT = 0x0010; +extern "system" { + pub fn SetupInstallFileA( + InfHandle: HINF, + InfContext: PINFCONTEXT, + SourceFile: PCSTR, + SourcePathRoot: PCSTR, + DestinationName: PCSTR, + CopyStyle: DWORD, + CopyMsgHandler: PSP_FILE_CALLBACK_A, + Context: PVOID, + ) -> BOOL; + pub fn SetupInstallFileW( + InfHandle: HINF, + InfContext: PINFCONTEXT, + SourceFile: PCWSTR, + SourcePathRoot: PCWSTR, + DestinationName: PCWSTR, + CopyStyle: DWORD, + CopyMsgHandler: PSP_FILE_CALLBACK_W, + Context: PVOID, + ) -> BOOL; + pub fn SetupInstallFileExA( + InfHandle: HINF, + InfContext: PINFCONTEXT, + SourceFile: PCSTR, + SourcePathRoot: PCSTR, + DestinationName: PCSTR, + CopyStyle: DWORD, + CopyMsgHandler: PSP_FILE_CALLBACK_A, + Context: PVOID, + FileWasInUse: PBOOL, + ) -> BOOL; + pub fn SetupInstallFileExW( + InfHandle: HINF, + InfContext: PINFCONTEXT, + SourceFile: PCWSTR, + SourcePathRoot: PCWSTR, + DestinationName: PCWSTR, + CopyStyle: DWORD, + CopyMsgHandler: PSP_FILE_CALLBACK_W, + Context: PVOID, + FileWasInUse: PBOOL, + ) -> BOOL; +} +pub const SP_COPY_DELETESOURCE: DWORD = 0x0000001; +pub const SP_COPY_REPLACEONLY: DWORD = 0x0000002; +pub const SP_COPY_NEWER: DWORD = 0x0000004; +pub const SP_COPY_NEWER_OR_SAME: DWORD = SP_COPY_NEWER; +pub const SP_COPY_NOOVERWRITE: DWORD = 0x0000008; +pub const SP_COPY_NODECOMP: DWORD = 0x0000010; +pub const SP_COPY_LANGUAGEAWARE: DWORD = 0x0000020; +pub const SP_COPY_SOURCE_ABSOLUTE: DWORD = 0x0000040; +pub const SP_COPY_SOURCEPATH_ABSOLUTE: DWORD = 0x0000080; +pub const SP_COPY_IN_USE_NEEDS_REBOOT: DWORD = 0x0000100; +pub const SP_COPY_FORCE_IN_USE: DWORD = 0x0000200; +pub const SP_COPY_NOSKIP: DWORD = 0x0000400; +pub const SP_FLAG_CABINETCONTINUATION: DWORD = 0x0000800; +pub const SP_COPY_FORCE_NOOVERWRITE: DWORD = 0x0001000; +pub const SP_COPY_FORCE_NEWER: DWORD = 0x0002000; +pub const SP_COPY_WARNIFSKIP: DWORD = 0x0004000; +pub const SP_COPY_NOBROWSE: DWORD = 0x0008000; +pub const SP_COPY_NEWER_ONLY: DWORD = 0x0010000; +pub const SP_COPY_RESERVED: DWORD = 0x0020000; +pub const SP_COPY_OEMINF_CATALOG_ONLY: DWORD = 0x0040000; +pub const SP_COPY_REPLACE_BOOT_FILE: DWORD = 0x0080000; +pub const SP_COPY_NOPRUNE: DWORD = 0x0100000; +pub const SP_COPY_OEM_F6_INF: DWORD = 0x0200000; +pub const SP_COPY_ALREADYDECOMP: DWORD = 0x0400000; +pub const SP_COPY_WINDOWS_SIGNED: DWORD = 0x1000000; +pub const SP_COPY_PNPLOCKED: DWORD = 0x2000000; +pub const SP_COPY_IN_USE_TRY_RENAME: DWORD = 0x4000000; +pub const SP_COPY_INBOX_INF: DWORD = 0x8000000; +pub const SP_COPY_HARDLINK: DWORD = 0x10000000; +pub const SP_BACKUP_BACKUPPASS: DWORD = 0x00000001; +pub const SP_BACKUP_DEMANDPASS: DWORD = 0x00000002; +pub const SP_BACKUP_SPECIAL: DWORD = 0x00000004; +pub const SP_BACKUP_BOOTFILE: DWORD = 0x00000008; +extern "system" { + pub fn SetupOpenFileQueue() -> HSPFILEQ; + pub fn SetupCloseFileQueue( + QueueHandle: HSPFILEQ, + ) -> BOOL; + pub fn SetupSetFileQueueAlternatePlatformA( + QueueHandle: HSPFILEQ, + AlternatePlatformInfo: PSP_ALTPLATFORM_INFO, + AlternateDefaultCatalogFile: PCSTR, + ) -> BOOL; + pub fn SetupSetFileQueueAlternatePlatformW( + QueueHandle: HSPFILEQ, + AlternatePlatformInfo: PSP_ALTPLATFORM_INFO, + AlternateDefaultCatalogFile: PCWSTR, + ) -> BOOL; + pub fn SetupSetPlatformPathOverrideA( + Override: PCSTR, + ) -> BOOL; + pub fn SetupSetPlatformPathOverrideW( + Override: PCWSTR, + ) -> BOOL; + pub fn SetupQueueCopyA( + QueueHandle: HSPFILEQ, + SourceRootPath: PCSTR, + SourcePath: PCSTR, + SourceFilename: PCSTR, + SourceDescription: PCSTR, + SourceTagfile: PCSTR, + TargetDirectory: PCSTR, + TargetFilename: PCSTR, + CopyStyle: DWORD, + ) -> BOOL; + pub fn SetupQueueCopyW( + QueueHandle: HSPFILEQ, + SourceRootPath: PCWSTR, + SourcePath: PCWSTR, + SourceFilename: PCWSTR, + SourceDescription: PCWSTR, + SourceTagfile: PCWSTR, + TargetDirectory: PCWSTR, + TargetFilename: PCWSTR, + CopyStyle: DWORD, + ) -> BOOL; + pub fn SetupQueueCopyIndirectA( + CopyParams: PSP_FILE_COPY_PARAMS_A, + ) -> BOOL; + pub fn SetupQueueCopyIndirectW( + CopyParams: PSP_FILE_COPY_PARAMS_W, + ) -> BOOL; + pub fn SetupQueueDefaultCopyA( + QueueHandle: HSPFILEQ, + InfHandle: HINF, + SourceRootPath: PCSTR, + SourceFilename: PCSTR, + TargetFilename: PCSTR, + CopyStyle: DWORD, + ) -> BOOL; + pub fn SetupQueueDefaultCopyW( + QueueHandle: HSPFILEQ, + InfHandle: HINF, + SourceRootPath: PCWSTR, + SourceFilename: PCWSTR, + TargetFilename: PCWSTR, + CopyStyle: DWORD, + ) -> BOOL; + pub fn SetupQueueCopySectionA( + QueueHandle: HSPFILEQ, + SourceRootPath: PCSTR, + InfHandle: HINF, + ListInfHandle: HINF, + Section: PCSTR, + CopyStyle: DWORD, + ) -> BOOL; + pub fn SetupQueueCopySectionW( + QueueHandle: HSPFILEQ, + SourceRootPath: PCWSTR, + InfHandle: HINF, + ListInfHandle: HINF, + Section: PCWSTR, + CopyStyle: DWORD, + ) -> BOOL; + pub fn SetupQueueDeleteA( + QueueHandle: HSPFILEQ, + PathPart1: PCSTR, + PathPart2: PCSTR, + ) -> BOOL; + pub fn SetupQueueDeleteW( + QueueHandle: HSPFILEQ, + PathPart1: PCWSTR, + PathPart2: PCWSTR, + ) -> BOOL; + pub fn SetupQueueDeleteSectionA( + QueueHandle: HSPFILEQ, + InfHandle: HINF, + ListInfHandle: HINF, + Section: PCSTR, + ) -> BOOL; + pub fn SetupQueueDeleteSectionW( + QueueHandle: HSPFILEQ, + InfHandle: HINF, + ListInfHandle: HINF, + Section: PCWSTR, + ) -> BOOL; + pub fn SetupQueueRenameA( + QueueHandle: HSPFILEQ, + SourcePath: PCSTR, + SourceFilename: PCSTR, + TargetPath: PCSTR, + TargetFilename: PCSTR, + ) -> BOOL; + pub fn SetupQueueRenameW( + QueueHandle: HSPFILEQ, + SourcePath: PCWSTR, + SourceFilename: PCWSTR, + TargetPath: PCWSTR, + TargetFilename: PCWSTR, + ) -> BOOL; + pub fn SetupQueueRenameSectionA( + QueueHandle: HSPFILEQ, + InfHandle: HINF, + ListInfHandle: HINF, + Section: PCSTR, + ) -> BOOL; + pub fn SetupQueueRenameSectionW( + QueueHandle: HSPFILEQ, + InfHandle: HINF, + ListInfHandle: HINF, + Section: PCWSTR, + ) -> BOOL; + pub fn SetupCommitFileQueueA( + Owner: HWND, + QueueHandle: HSPFILEQ, + MsgHandler: PSP_FILE_CALLBACK_A, + Context: PVOID, + ) -> BOOL; + pub fn SetupCommitFileQueueW( + Owner: HWND, + QueueHandle: HSPFILEQ, + MsgHandler: PSP_FILE_CALLBACK_W, + Context: PVOID, + ) -> BOOL; + pub fn SetupScanFileQueueA( + FileQueue: HSPFILEQ, + Flags: DWORD, + Window: HWND, + CallbackRoutine: PSP_FILE_CALLBACK_A, + CallbackContext: PVOID, + Result: PDWORD, + ) -> BOOL; + pub fn SetupScanFileQueueW( + FileQueue: HSPFILEQ, + Flags: DWORD, + Window: HWND, + CallbackRoutine: PSP_FILE_CALLBACK_W, + CallbackContext: PVOID, + Result: PDWORD, + ) -> BOOL; +} +pub const SPQ_SCAN_FILE_PRESENCE: DWORD = 0x00000001; +pub const SPQ_SCAN_FILE_VALIDITY: DWORD = 0x00000002; +pub const SPQ_SCAN_USE_CALLBACK: DWORD = 0x00000004; +pub const SPQ_SCAN_USE_CALLBACKEX: DWORD = 0x00000008; +pub const SPQ_SCAN_INFORM_USER: DWORD = 0x00000010; +pub const SPQ_SCAN_PRUNE_COPY_QUEUE: DWORD = 0x00000020; +pub const SPQ_SCAN_USE_CALLBACK_SIGNERINFO: DWORD = 0x00000040; +pub const SPQ_SCAN_PRUNE_DELREN: DWORD = 0x00000080; +pub const SPQ_SCAN_FILE_PRESENCE_WITHOUT_SOURCE: DWORD = 0x00000100; +pub const SPQ_SCAN_FILE_COMPARISON: DWORD = 0x00000200; +pub const SPQ_SCAN_ACTIVATE_DRP: DWORD = 0x00000400; +pub const SPQ_DELAYED_COPY: DWORD = 0x00000001; +extern "system" { + pub fn SetupGetFileQueueCount( + FileQueue: HSPFILEQ, + SubQueueFileOp: UINT, + NumOperations: PUINT, + ) -> BOOL; + pub fn SetupGetFileQueueFlags( + FileQueue: HSPFILEQ, + Flags: PDWORD, + ) -> BOOL; + pub fn SetupSetFileQueueFlags( + FileQueue: HSPFILEQ, + FlagMask: DWORD, + Flags: DWORD, + ) -> BOOL; +} +pub const SPQ_FLAG_BACKUP_AWARE: DWORD = 0x00000001; +pub const SPQ_FLAG_ABORT_IF_UNSIGNED: DWORD = 0x00000002; +pub const SPQ_FLAG_FILES_MODIFIED: DWORD = 0x00000004; +pub const SPQ_FLAG_DO_SHUFFLEMOVE: DWORD = 0x00000008; +pub const SPQ_FLAG_VALID: DWORD = 0x0000000F; +pub const SPOST_NONE: DWORD = 0; +pub const SPOST_PATH: DWORD = 1; +pub const SPOST_URL: DWORD = 2; +pub const SPOST_MAX: DWORD = 3; +extern "system" { + pub fn SetupCopyOEMInfA( + SourceInfFileName: PCSTR, + OEMSourceMediaLocation: PCSTR, + OEMSourceMediaType: DWORD, + CopyStyle: DWORD, + DestinationInfFileName: PSTR, + DestinationInfFileNameSize: DWORD, + RequiredSize: PDWORD, + DestinationInfFileNameComponent: *mut PSTR, + ) -> BOOL; + pub fn SetupCopyOEMInfW( + SourceInfFileName: PCWSTR, + OEMSourceMediaLocation: PCWSTR, + OEMSourceMediaType: DWORD, + CopyStyle: DWORD, + DestinationInfFileName: PWSTR, + DestinationInfFileNameSize: DWORD, + RequiredSize: PDWORD, + DestinationInfFileNameComponent: *mut PWSTR, + ) -> BOOL; +} +pub const SUOI_FORCEDELETE: DWORD = 0x00000001; +pub const SUOI_INTERNAL1: DWORD = 0x00000002; +extern "system" { + pub fn SetupUninstallOEMInfA( + InfFileName: PCSTR, + Flags: DWORD, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupUninstallOEMInfW( + InfFileName: PCWSTR, + Flags: DWORD, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupUninstallNewlyCopiedInfs( + FileQueue: HSPFILEQ, + Flags: DWORD, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupCreateDiskSpaceListA( + Reserved1: PVOID, + Reserved2: DWORD, + Flags: UINT, + ) -> HDSKSPC; + pub fn SetupCreateDiskSpaceListW( + Reserved1: PVOID, + Reserved2: DWORD, + Flags: UINT, + ) -> HDSKSPC; +} +pub const SPDSL_IGNORE_DISK: UINT = 0x00000001; +pub const SPDSL_DISALLOW_NEGATIVE_ADJUST: UINT = 0x00000002; +extern "system" { + pub fn SetupDuplicateDiskSpaceListA( + DiskSpace: HDSKSPC, + Reserved1: PVOID, + Reserved2: DWORD, + Flags: UINT, + ) -> HDSKSPC; + pub fn SetupDuplicateDiskSpaceListW( + DiskSpace: HDSKSPC, + Reserved1: PVOID, + Reserved2: DWORD, + Flags: UINT, + ) -> HDSKSPC; + pub fn SetupDestroyDiskSpaceList( + DiskSpace: HDSKSPC, + ) -> BOOL; + pub fn SetupQueryDrivesInDiskSpaceListA( + DiskSpace: HDSKSPC, + ReturnBuffer: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupQueryDrivesInDiskSpaceListW( + DiskSpace: HDSKSPC, + ReturnBuffer: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupQuerySpaceRequiredOnDriveA( + DiskSpace: HDSKSPC, + DriveSpec: PCSTR, + SpaceRequired: *mut LONGLONG, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupQuerySpaceRequiredOnDriveW( + DiskSpace: HDSKSPC, + DriveSpec: PCWSTR, + SpaceRequired: *mut LONGLONG, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupAdjustDiskSpaceListA( + DiskSpace: HDSKSPC, + DriveRoot: LPCSTR, + Amount: LONGLONG, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupAdjustDiskSpaceListW( + DiskSpace: HDSKSPC, + DriveRoot: LPCWSTR, + Amount: LONGLONG, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupAddToDiskSpaceListA( + DiskSpace: HDSKSPC, + TargetFilespec: PCSTR, + FileSize: LONGLONG, + Operation: UINT, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupAddToDiskSpaceListW( + DiskSpace: HDSKSPC, + TargetFilespec: PCWSTR, + FileSize: LONGLONG, + Operation: UINT, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupAddSectionToDiskSpaceListA( + DiskSpace: HDSKSPC, + InfHandle: HINF, + ListInfHandle: HINF, + SectionName: PCSTR, + Operation: UINT, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupAddSectionToDiskSpaceListW( + DiskSpace: HDSKSPC, + InfHandle: HINF, + ListInfHandle: HINF, + SectionName: PCWSTR, + Operation: UINT, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupAddInstallSectionToDiskSpaceListA( + DiskSpace: HDSKSPC, + InfHandle: HINF, + LayoutInfHandle: HINF, + SectionName: PCSTR, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupAddInstallSectionToDiskSpaceListW( + DiskSpace: HDSKSPC, + InfHandle: HINF, + LayoutInfHandle: HINF, + SectionName: PCWSTR, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupRemoveFromDiskSpaceListA( + DiskSpace: HDSKSPC, + TargetFilespec: PCSTR, + Operation: UINT, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupRemoveFromDiskSpaceListW( + DiskSpace: HDSKSPC, + TargetFilespec: PCWSTR, + Operation: UINT, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupRemoveSectionFromDiskSpaceListA( + DiskSpace: HDSKSPC, + InfHandle: HINF, + ListInfHandle: HINF, + SectionName: PCSTR, + Operation: UINT, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupRemoveSectionFromDiskSpaceListW( + DiskSpace: HDSKSPC, + InfHandle: HINF, + ListInfHandle: HINF, + SectionName: PCWSTR, + Operation: UINT, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupRemoveInstallSectionFromDiskSpaceListA( + DiskSpace: HDSKSPC, + InfHandle: HINF, + LayoutInfHandle: HINF, + SectionName: PCSTR, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupRemoveInstallSectionFromDiskSpaceListW( + DiskSpace: HDSKSPC, + InfHandle: HINF, + LayoutInfHandle: HINF, + SectionName: PCWSTR, + Reserved1: PVOID, + Reserved2: UINT, + ) -> BOOL; + pub fn SetupIterateCabinetA( + CabinetFile: PCSTR, + Reserved: DWORD, + MsgHandler: PSP_FILE_CALLBACK_A, + Context: PVOID, + ) -> BOOL; + pub fn SetupIterateCabinetW( + CabinetFile: PCWSTR, + Reserved: DWORD, + MsgHandler: PSP_FILE_CALLBACK_W, + Context: PVOID, + ) -> BOOL; + pub fn SetupPromptReboot( + FileQueue: HSPFILEQ, + Owner: HWND, + ScanOnly: BOOL, + ) -> INT; +} +pub const SPFILEQ_FILE_IN_USE: INT = 0x00000001; +pub const SPFILEQ_REBOOT_RECOMMENDED: INT = 0x00000002; +pub const SPFILEQ_REBOOT_IN_PROGRESS: INT = 0x00000004; +extern "system" { + pub fn SetupInitDefaultQueueCallback( + OwnerWindow: HWND, + ) -> PVOID; + pub fn SetupInitDefaultQueueCallbackEx( + OwnerWindow: HWND, + AlternateProgressWindow: HWND, + ProgressMessage: UINT, + Reserved1: DWORD, + Reserved2: PVOID, + ) -> PVOID; + pub fn SetupTermDefaultQueueCallback( + Context: PVOID, + ) -> (); + pub fn SetupDefaultQueueCallbackA( + Context: PVOID, + Notification: UINT, + Param1: UINT_PTR, + Param2: UINT_PTR, + ) -> UINT; + pub fn SetupDefaultQueueCallbackW( + Context: PVOID, + Notification: UINT, + Param1: UINT_PTR, + Param2: UINT_PTR, + ) -> UINT; +} +pub const FLG_ADDREG_DELREG_BIT: DWORD = 0x00008000; +pub const FLG_ADDREG_BINVALUETYPE: DWORD = 0x00000001; +pub const FLG_ADDREG_NOCLOBBER: DWORD = 0x00000002; +pub const FLG_ADDREG_DELVAL: DWORD = 0x00000004; +pub const FLG_ADDREG_APPEND: DWORD = 0x00000008; +pub const FLG_ADDREG_KEYONLY: DWORD = 0x00000010; +pub const FLG_ADDREG_OVERWRITEONLY: DWORD = 0x00000020; +pub const FLG_ADDREG_64BITKEY: DWORD = 0x00001000; +pub const FLG_ADDREG_KEYONLY_COMMON: DWORD = 0x00002000; +pub const FLG_ADDREG_32BITKEY: DWORD = 0x00004000; +pub const FLG_ADDREG_TYPE_MASK: DWORD = 0xFFFF0000 | FLG_ADDREG_BINVALUETYPE; +pub const FLG_ADDREG_TYPE_SZ: DWORD = 0x00000000; +pub const FLG_ADDREG_TYPE_MULTI_SZ: DWORD = 0x00010000; +pub const FLG_ADDREG_TYPE_EXPAND_SZ: DWORD = 0x00020000; +pub const FLG_ADDREG_TYPE_BINARY: DWORD = 0x00000000 | FLG_ADDREG_BINVALUETYPE; +pub const FLG_ADDREG_TYPE_DWORD: DWORD = 0x00010000 | FLG_ADDREG_BINVALUETYPE; +pub const FLG_ADDREG_TYPE_NONE: DWORD = 0x00020000 | FLG_ADDREG_BINVALUETYPE; +pub const FLG_DELREG_VALUE: DWORD = 0x00000000; +pub const FLG_DELREG_TYPE_MASK: DWORD = FLG_ADDREG_TYPE_MASK; +pub const FLG_DELREG_TYPE_SZ: DWORD = FLG_ADDREG_TYPE_SZ; +pub const FLG_DELREG_TYPE_MULTI_SZ: DWORD = FLG_ADDREG_TYPE_MULTI_SZ; +pub const FLG_DELREG_TYPE_EXPAND_SZ: DWORD = FLG_ADDREG_TYPE_EXPAND_SZ; +pub const FLG_DELREG_TYPE_BINARY: DWORD = FLG_ADDREG_TYPE_BINARY; +pub const FLG_DELREG_TYPE_DWORD: DWORD = FLG_ADDREG_TYPE_DWORD; +pub const FLG_DELREG_TYPE_NONE: DWORD = FLG_ADDREG_TYPE_NONE; +pub const FLG_DELREG_64BITKEY: DWORD = FLG_ADDREG_64BITKEY; +pub const FLG_DELREG_KEYONLY_COMMON: DWORD = FLG_ADDREG_KEYONLY_COMMON; +pub const FLG_DELREG_32BITKEY: DWORD = FLG_ADDREG_32BITKEY; +pub const FLG_DELREG_OPERATION_MASK: DWORD = 0x000000FE; +pub const FLG_DELREG_MULTI_SZ_DELSTRING: DWORD = FLG_DELREG_TYPE_MULTI_SZ | FLG_ADDREG_DELREG_BIT + | 0x00000002; +pub const FLG_BITREG_CLEARBITS: DWORD = 0x00000000; +pub const FLG_BITREG_SETBITS: DWORD = 0x00000001; +pub const FLG_BITREG_64BITKEY: DWORD = 0x00001000; +pub const FLG_BITREG_32BITKEY: DWORD = 0x00004000; +pub const FLG_INI2REG_64BITKEY: DWORD = 0x00001000; +pub const FLG_INI2REG_32BITKEY: DWORD = 0x00004000; +pub const FLG_REGSVR_DLLREGISTER: DWORD = 0x00000001; +pub const FLG_REGSVR_DLLINSTALL: DWORD = 0x00000002; +pub const FLG_PROFITEM_CURRENTUSER: DWORD = 0x00000001; +pub const FLG_PROFITEM_DELETE: DWORD = 0x00000002; +pub const FLG_PROFITEM_GROUP: DWORD = 0x00000004; +pub const FLG_PROFITEM_CSIDL: DWORD = 0x00000008; +pub const FLG_ADDPROPERTY_NOCLOBBER: DWORD = 0x00000001; +pub const FLG_ADDPROPERTY_OVERWRITEONLY: DWORD = 0x00000002; +pub const FLG_ADDPROPERTY_APPEND: DWORD = 0x00000004; +pub const FLG_ADDPROPERTY_OR: DWORD = 0x00000008; +pub const FLG_ADDPROPERTY_AND: DWORD = 0x00000010; +pub const FLG_DELPROPERTY_MULTI_SZ_DELSTRING: DWORD = 0x00000001; +extern "system" { + pub fn SetupInstallFromInfSectionA( + Owner: HWND, + InfHandle: HINF, + SectionName: PCSTR, + Flags: UINT, + RelativeKeyRoot: HKEY, + SourceRootPath: PCSTR, + CopyFlags: UINT, + MsgHandler: PSP_FILE_CALLBACK_A, + Context: PVOID, + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupInstallFromInfSectionW( + Owner: HWND, + InfHandle: HINF, + SectionName: PCWSTR, + Flags: UINT, + RelativeKeyRoot: HKEY, + SourceRootPath: PCWSTR, + CopyFlags: UINT, + MsgHandler: PSP_FILE_CALLBACK_W, + Context: PVOID, + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; +} +pub const SPINST_LOGCONFIG: UINT = 0x00000001; +pub const SPINST_INIFILES: UINT = 0x00000002; +pub const SPINST_REGISTRY: UINT = 0x00000004; +pub const SPINST_INI2REG: UINT = 0x00000008; +pub const SPINST_FILES: UINT = 0x00000010; +pub const SPINST_BITREG: UINT = 0x00000020; +pub const SPINST_REGSVR: UINT = 0x00000040; +pub const SPINST_UNREGSVR: UINT = 0x00000080; +pub const SPINST_PROFILEITEMS: UINT = 0x00000100; +pub const SPINST_COPYINF: UINT = 0x00000200; +pub const SPINST_PROPERTIES: UINT = 0x00000400; +pub const SPINST_ALL: UINT = 0x000007ff; +pub const SPINST_SINGLESECTION: UINT = 0x00010000; +pub const SPINST_LOGCONFIG_IS_FORCED: UINT = 0x00020000; +pub const SPINST_LOGCONFIGS_ARE_OVERRIDES: UINT = 0x00040000; +pub const SPINST_REGISTERCALLBACKAWARE: UINT = 0x00080000; +pub const SPINST_DEVICEINSTALL: UINT = 0x00100000; +extern "system" { + pub fn SetupInstallFilesFromInfSectionA( + InfHandle: HINF, + LayoutInfHandle: HINF, + FileQueue: HSPFILEQ, + SectionName: PCSTR, + SourceRootPath: PCSTR, + CopyFlags: UINT, + ) -> BOOL; + pub fn SetupInstallFilesFromInfSectionW( + InfHandle: HINF, + LayoutInfHandle: HINF, + FileQueue: HSPFILEQ, + SectionName: PCWSTR, + SourceRootPath: PCWSTR, + CopyFlags: UINT, + ) -> BOOL; +} +pub const SPSVCINST_TAGTOFRONT: DWORD = 0x00000001; +pub const SPSVCINST_ASSOCSERVICE: DWORD = 0x00000002; +pub const SPSVCINST_DELETEEVENTLOGENTRY: DWORD = 0x00000004; +pub const SPSVCINST_NOCLOBBER_DISPLAYNAME: DWORD = 0x00000008; +pub const SPSVCINST_NOCLOBBER_STARTTYPE: DWORD = 0x00000010; +pub const SPSVCINST_NOCLOBBER_ERRORCONTROL: DWORD = 0x00000020; +pub const SPSVCINST_NOCLOBBER_LOADORDERGROUP: DWORD = 0x00000040; +pub const SPSVCINST_NOCLOBBER_DEPENDENCIES: DWORD = 0x00000080; +pub const SPSVCINST_NOCLOBBER_DESCRIPTION: DWORD = 0x00000100; +pub const SPSVCINST_STOPSERVICE: DWORD = 0x00000200; +pub const SPSVCINST_CLOBBER_SECURITY: DWORD = 0x00000400; +pub const SPSVCINST_STARTSERVICE: DWORD = 0x00000800; +pub const SPSVCINST_NOCLOBBER_REQUIREDPRIVILEGES: DWORD = 0x00001000; +extern "system" { + pub fn SetupInstallServicesFromInfSectionA( + InfHandle: HINF, + SectionName: PCSTR, + Flags: DWORD, + ) -> BOOL; + pub fn SetupInstallServicesFromInfSectionW( + InfHandle: HINF, + SectionName: PCWSTR, + Flags: DWORD, + ) -> BOOL; + pub fn SetupInstallServicesFromInfSectionExA( + InfHandle: HINF, + SectionName: PCSTR, + Flags: DWORD, + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Reserved1: PVOID, + Reserved2: PVOID, + ) -> BOOL; + pub fn SetupInstallServicesFromInfSectionExW( + InfHandle: HINF, + SectionName: PCWSTR, + Flags: DWORD, + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Reserved1: PVOID, + Reserved2: PVOID, + ) -> BOOL; + pub fn InstallHinfSectionA( + Window: HWND, + ModuleHandle: HINSTANCE, + CommandLine: PCSTR, + ShowCommand: INT, + ) -> (); + pub fn InstallHinfSectionW( + Window: HWND, + ModuleHandle: HINSTANCE, + CommandLine: PCWSTR, + ShowCommand: INT, + ) -> (); +} +pub type HSPFILELOG = PVOID; +extern "system" { + pub fn SetupInitializeFileLogA( + LogFileName: PCSTR, + Flags: DWORD, + ) -> HSPFILELOG; + pub fn SetupInitializeFileLogW( + LogFileName: PCWSTR, + Flags: DWORD, + ) -> HSPFILELOG; +} +pub const SPFILELOG_SYSTEMLOG: DWORD = 0x00000001; +pub const SPFILELOG_FORCENEW: DWORD = 0x00000002; +pub const SPFILELOG_QUERYONLY: DWORD = 0x00000004; +extern "system" { + pub fn SetupTerminateFileLog( + FileLogHandle: HSPFILELOG, + ) -> BOOL; + pub fn SetupLogFileA( + FileLogHandle: HSPFILELOG, + LogSectionName: PCSTR, + SourceFilename: PCSTR, + TargetFilename: PCSTR, + Checksum: DWORD, + DiskTagfile: PCSTR, + DiskDescription: PCSTR, + OtherInfo: PCSTR, + Flags: DWORD, + ) -> BOOL; + pub fn SetupLogFileW( + FileLogHandle: HSPFILELOG, + LogSectionName: PCWSTR, + SourceFilename: PCWSTR, + TargetFilename: PCWSTR, + Checksum: DWORD, + DiskTagfile: PCWSTR, + DiskDescription: PCWSTR, + OtherInfo: PCWSTR, + Flags: DWORD, + ) -> BOOL; +} +pub const SPFILELOG_OEMFILE: DWORD = 0x00000001; +extern "system" { + pub fn SetupRemoveFileLogEntryA( + FileLogHandle: HSPFILELOG, + LogSectionName: PCSTR, + TargetFilename: PCSTR, + ) -> BOOL; + pub fn SetupRemoveFileLogEntryW( + FileLogHandle: HSPFILELOG, + LogSectionName: PCWSTR, + TargetFilename: PCWSTR, + ) -> BOOL; +} +ENUM!{enum SetupFileLogInfo { + SetupFileLogSourceFilename, + SetupFileLogChecksum, + SetupFileLogDiskTagfile, + SetupFileLogDiskDescription, + SetupFileLogOtherInfo, + SetupFileLogMax, +}} +extern "system" { + pub fn SetupQueryFileLogA( + FileLogHandle: HSPFILELOG, + LogSectionName: PCSTR, + TargetFilename: PCSTR, + DesiredInfo: SetupFileLogInfo, + DataOut: PSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupQueryFileLogW( + FileLogHandle: HSPFILELOG, + LogSectionName: PCWSTR, + TargetFilename: PCWSTR, + DesiredInfo: SetupFileLogInfo, + DataOut: PWSTR, + ReturnBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; +} +pub type LogSeverity = DWORD; +pub const LogSevInformation: LogSeverity = 0x00000000; +pub const LogSevWarning: LogSeverity = 0x00000001; +pub const LogSevError: LogSeverity = 0x00000002; +pub const LogSevFatalError: LogSeverity = 0x00000003; +pub const LogSevMaximum: LogSeverity = 0x00000004; +extern "system" { + pub fn SetupOpenLog( + Erase: BOOL, + ) -> BOOL; + pub fn SetupLogErrorA( + MessageString: LPCSTR, + Severity: LogSeverity, + ) -> BOOL; + pub fn SetupLogErrorW( + MessageString: LPCWSTR, + Severity: LogSeverity, + ) -> BOOL; + pub fn SetupCloseLog() -> (); + pub fn SetupGetThreadLogToken() -> SP_LOG_TOKEN; + pub fn SetupSetThreadLogToken( + LogToken: SP_LOG_TOKEN, + ) -> (); +} +//pub fn SetupWriteTextLog() -> (); +//pub fn SetupWriteTextLogError() -> (); +extern "system" { + pub fn SetupWriteTextLogInfLine( + LogToken: SP_LOG_TOKEN, + Flags: DWORD, + InfHandle: HINF, + Context: PINFCONTEXT, + ) -> (); + pub fn SetupGetBackupInformationA( + QueueHandle: HSPFILEQ, + BackupParams: PSP_BACKUP_QUEUE_PARAMS_A, + ) -> BOOL; + pub fn SetupGetBackupInformationW( + QueueHandle: HSPFILEQ, + BackupParams: PSP_BACKUP_QUEUE_PARAMS_W, + ) -> BOOL; + pub fn SetupPrepareQueueForRestoreA( + QueueHandle: HSPFILEQ, + BackupPath: PCSTR, + RestoreFlags: DWORD, + ) -> BOOL; + pub fn SetupPrepareQueueForRestoreW( + QueueHandle: HSPFILEQ, + BackupPath: PCWSTR, + RestoreFlags: DWORD, + ) -> BOOL; + pub fn SetupSetNonInteractiveMode( + NonInteractiveFlag: BOOL, + ) -> BOOL; + pub fn SetupGetNonInteractiveMode() -> BOOL; + pub fn SetupDiCreateDeviceInfoList( + ClassGuid: *const GUID, + hwndParent: HWND, + ) -> HDEVINFO; + pub fn SetupDiCreateDeviceInfoListExA( + ClassGuid: *const GUID, + hwndParent: HWND, + MachineName: PCSTR, + Reserved: PVOID, + ) -> HDEVINFO; + pub fn SetupDiCreateDeviceInfoListExW( + ClassGuid: *const GUID, + hwndParent: HWND, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> HDEVINFO; + pub fn SetupDiGetDeviceInfoListClass( + DeviceInfoSet: HDEVINFO, + ClassGuid: LPGUID, + ) -> BOOL; + pub fn SetupDiGetDeviceInfoListDetailA( + DeviceInfoSet: HDEVINFO, + DeviceInfoSetDetailData: PSP_DEVINFO_LIST_DETAIL_DATA_A, + ) -> BOOL; + pub fn SetupDiGetDeviceInfoListDetailW( + DeviceInfoSet: HDEVINFO, + DeviceInfoSetDetailData: PSP_DEVINFO_LIST_DETAIL_DATA_W, + ) -> BOOL; +} +pub const DICD_GENERATE_ID: DWORD = 0x00000001; +pub const DICD_INHERIT_CLASSDRVS: DWORD = 0x00000002; +extern "system" { + pub fn SetupDiCreateDeviceInfoA( + DeviceInfoSet: HDEVINFO, + DeviceName: PCSTR, + ClassGuid: *const GUID, + DeviceDescription: PCSTR, + hwndParent: HWND, + CreationFlags: DWORD, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiCreateDeviceInfoW( + DeviceInfoSet: HDEVINFO, + DeviceName: PCWSTR, + ClassGuid: *const GUID, + DeviceDescription: PCWSTR, + hwndParent: HWND, + CreationFlags: DWORD, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; +} +pub const DIOD_INHERIT_CLASSDRVS: DWORD = 0x00000002; +pub const DIOD_CANCEL_REMOVE: DWORD = 0x00000004; +extern "system" { + pub fn SetupDiOpenDeviceInfoA( + DeviceInfoSet: HDEVINFO, + DeviceInstanceId: PCSTR, + hwndParent: HWND, + OpenFlags: DWORD, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiOpenDeviceInfoW( + DeviceInfoSet: HDEVINFO, + DeviceInstanceId: PCWSTR, + hwndParent: HWND, + OpenFlags: DWORD, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiGetDeviceInstanceIdA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DeviceInstanceId: PSTR, + DeviceInstanceIdSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetDeviceInstanceIdW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DeviceInstanceId: PWSTR, + DeviceInstanceIdSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiDeleteDeviceInfo( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiEnumDeviceInfo( + DeviceInfoSet: HDEVINFO, + MemberIndex: DWORD, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiDestroyDeviceInfoList( + DeviceInfoSet: HDEVINFO, + ) -> BOOL; + pub fn SetupDiEnumDeviceInterfaces( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + InterfaceClassGuid: *const GUID, + MemberIndex: DWORD, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + ) -> BOOL; + pub fn SetupDiCreateDeviceInterfaceA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + InterfaceClassGuid: *const GUID, + ReferenceString: PCSTR, + CreationFlags: DWORD, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + ) -> BOOL; + pub fn SetupDiCreateDeviceInterfaceW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + InterfaceClassGuid: *const GUID, + ReferenceString: PCWSTR, + CreationFlags: DWORD, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + ) -> BOOL; +} +pub const DIODI_NO_ADD: DWORD = 0x00000001; +extern "system" { + pub fn SetupDiOpenDeviceInterfaceA( + DeviceInfoSet: HDEVINFO, + DevicePath: PCSTR, + OpenFlags: DWORD, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + ) -> BOOL; + pub fn SetupDiOpenDeviceInterfaceW( + DeviceInfoSet: HDEVINFO, + DevicePath: PCWSTR, + OpenFlags: DWORD, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + ) -> BOOL; + pub fn SetupDiGetDeviceInterfaceAlias( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + AliasInterfaceClassGuid: *const GUID, + AliasDeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + ) -> BOOL; + pub fn SetupDiDeleteDeviceInterfaceData( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + ) -> BOOL; + pub fn SetupDiRemoveDeviceInterface( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + ) -> BOOL; + pub fn SetupDiGetDeviceInterfaceDetailA( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + DeviceInterfaceDetailData: PSP_DEVICE_INTERFACE_DETAIL_DATA_A, + DeviceInterfaceDetailDataSize: DWORD, + RequiredSize: PDWORD, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiGetDeviceInterfaceDetailW( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + DeviceInterfaceDetailData: PSP_DEVICE_INTERFACE_DETAIL_DATA_W, + DeviceInterfaceDetailDataSize: DWORD, + RequiredSize: PDWORD, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiInstallDeviceInterfaces( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiSetDeviceInterfaceDefault( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Flags: DWORD, + Reserved: PVOID, + ) -> BOOL; +} +pub const SPRDI_FIND_DUPS: DWORD = 0x00000001; +extern "system" { + pub fn SetupDiRegisterDeviceInfo( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Flags: DWORD, + CompareProc: PSP_DETSIG_CMPPROC, + CompareContext: PVOID, + DupDeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; +} +pub const SPDIT_NODRIVER: DWORD = 0x00000000; +pub const SPDIT_CLASSDRIVER: DWORD = 0x00000001; +pub const SPDIT_COMPATDRIVER: DWORD = 0x00000002; +extern "system" { + pub fn SetupDiBuildDriverInfoList( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverType: DWORD, + ) -> BOOL; + pub fn SetupDiCancelDriverInfoSearch( + DeviceInfoSet: HDEVINFO, + ) -> BOOL; + pub fn SetupDiEnumDriverInfoA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverType: DWORD, + MemberIndex: DWORD, + DriverInfoData: PSP_DRVINFO_DATA_A, + ) -> BOOL; + pub fn SetupDiEnumDriverInfoW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverType: DWORD, + MemberIndex: DWORD, + DriverInfoData: PSP_DRVINFO_DATA_W, + ) -> BOOL; + pub fn SetupDiGetSelectedDriverA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverInfoData: PSP_DRVINFO_DATA_A, + ) -> BOOL; + pub fn SetupDiGetSelectedDriverW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverInfoData: PSP_DRVINFO_DATA_W, + ) -> BOOL; + pub fn SetupDiSetSelectedDriverA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverInfoData: PSP_DRVINFO_DATA_A, + ) -> BOOL; + pub fn SetupDiSetSelectedDriverW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverInfoData: PSP_DRVINFO_DATA_W, + ) -> BOOL; + pub fn SetupDiGetDriverInfoDetailA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverInfoData: PSP_DRVINFO_DATA_A, + DriverInfoDetailData: PSP_DRVINFO_DETAIL_DATA_A, + DriverInfoDetailDataSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetDriverInfoDetailW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverInfoData: PSP_DRVINFO_DATA_W, + DriverInfoDetailData: PSP_DRVINFO_DETAIL_DATA_W, + DriverInfoDetailDataSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiDestroyDriverInfoList( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverType: DWORD, + ) -> BOOL; +} +pub const DIGCF_DEFAULT: DWORD = 0x00000001; +pub const DIGCF_PRESENT: DWORD = 0x00000002; +pub const DIGCF_ALLCLASSES: DWORD = 0x00000004; +pub const DIGCF_PROFILE: DWORD = 0x00000008; +pub const DIGCF_DEVICEINTERFACE: DWORD = 0x00000010; +extern "system" { + pub fn SetupDiGetClassDevsA( + ClassGuid: *const GUID, + Enumerator: PCSTR, + hwndParent: HWND, + Flags: DWORD, + ) -> HDEVINFO; + pub fn SetupDiGetClassDevsW( + ClassGuid: *const GUID, + Enumerator: PCWSTR, + hwndParent: HWND, + Flags: DWORD, + ) -> HDEVINFO; + pub fn SetupDiGetClassDevsExA( + ClassGuid: *const GUID, + Enumerator: PCSTR, + hwndParent: HWND, + Flags: DWORD, + DeviceInfoSet: HDEVINFO, + MachineName: PCSTR, + Reserved: PVOID, + ) -> HDEVINFO; + pub fn SetupDiGetClassDevsExW( + ClassGuid: *const GUID, + Enumerator: PCWSTR, + hwndParent: HWND, + Flags: DWORD, + DeviceInfoSet: HDEVINFO, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> HDEVINFO; + pub fn SetupDiGetINFClassA( + InfName: PCSTR, + ClassGuid: LPGUID, + ClassName: PSTR, + ClassNameSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetINFClassW( + InfName: PCWSTR, + ClassGuid: LPGUID, + ClassName: PWSTR, + ClassNameSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; +} +pub const DIBCI_NOINSTALLCLASS: DWORD = 0x00000001; +pub const DIBCI_NODISPLAYCLASS: DWORD = 0x00000002; +extern "system" { + pub fn SetupDiBuildClassInfoList( + Flags: DWORD, + ClassGuidList: LPGUID, + ClassGuidListSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiBuildClassInfoListExA( + Flags: DWORD, + ClassGuidList: LPGUID, + ClassGuidListSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiBuildClassInfoListExW( + Flags: DWORD, + ClassGuidList: LPGUID, + ClassGuidListSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetClassDescriptionA( + ClassGuid: *const GUID, + ClassDescription: PSTR, + ClassDescriptionSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetClassDescriptionW( + ClassGuid: *const GUID, + ClassDescription: PWSTR, + ClassDescriptionSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetClassDescriptionExA( + ClassGuid: *const GUID, + ClassDescription: PSTR, + ClassDescriptionSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetClassDescriptionExW( + ClassGuid: *const GUID, + ClassDescription: PWSTR, + ClassDescriptionSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiCallClassInstaller( + InstallFunction: DI_FUNCTION, + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiSelectDevice( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiSelectBestCompatDrv( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiInstallDevice( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiInstallDriverFiles( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiRegisterCoDeviceInstallers( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiRemoveDevice( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiUnremoveDevice( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiRestartDevices( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiChangeState( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiInstallClassA( + hwndParent: HWND, + InfFileName: PCSTR, + Flags: DWORD, + FileQueue: HSPFILEQ, + ) -> BOOL; + pub fn SetupDiInstallClassW( + hwndParent: HWND, + InfFileName: PCWSTR, + Flags: DWORD, + FileQueue: HSPFILEQ, + ) -> BOOL; + pub fn SetupDiInstallClassExA( + hwndParent: HWND, + InfFileName: PCSTR, + Flags: DWORD, + FileQueue: HSPFILEQ, + InterfaceClassGuid: *const GUID, + Reserved1: PVOID, + Reserved2: PVOID, + ) -> BOOL; + pub fn SetupDiInstallClassExW( + hwndParent: HWND, + InfFileName: PCWSTR, + Flags: DWORD, + FileQueue: HSPFILEQ, + InterfaceClassGuid: *const GUID, + Reserved1: PVOID, + Reserved2: PVOID, + ) -> BOOL; + pub fn SetupDiOpenClassRegKey( + ClassGuid: *const GUID, + samDesired: REGSAM, + ) -> HKEY; +} +pub const DIOCR_INSTALLER: DWORD = 0x00000001; +pub const DIOCR_INTERFACE: DWORD = 0x00000002; +extern "system" { + pub fn SetupDiOpenClassRegKeyExA( + ClassGuid: *const GUID, + samDesired: REGSAM, + Flags: DWORD, + MachineName: PCSTR, + Reserved: PVOID, + ) -> HKEY; + pub fn SetupDiOpenClassRegKeyExW( + ClassGuid: *const GUID, + samDesired: REGSAM, + Flags: DWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> HKEY; + pub fn SetupDiCreateDeviceInterfaceRegKeyA( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + Reserved: DWORD, + samDesired: REGSAM, + InfHandle: HINF, + InfSectionName: PCSTR, + ) -> HKEY; + pub fn SetupDiCreateDeviceInterfaceRegKeyW( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + Reserved: DWORD, + samDesired: REGSAM, + InfHandle: HINF, + InfSectionName: PCWSTR, + ) -> HKEY; + pub fn SetupDiOpenDeviceInterfaceRegKey( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + Reserved: DWORD, + samDesired: REGSAM, + ) -> HKEY; + pub fn SetupDiDeleteDeviceInterfaceRegKey( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + Reserved: DWORD, + ) -> BOOL; +} +pub const DIREG_DEV: DWORD = 0x00000001; +pub const DIREG_DRV: DWORD = 0x00000002; +pub const DIREG_BOTH: DWORD = 0x00000004; +extern "system" { + pub fn SetupDiCreateDevRegKeyA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Scope: DWORD, + HwProfile: DWORD, + KeyType: DWORD, + InfHandle: HINF, + InfSectionName: PCSTR, + ) -> HKEY; + pub fn SetupDiCreateDevRegKeyW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Scope: DWORD, + HwProfile: DWORD, + KeyType: DWORD, + InfHandle: HINF, + InfSectionName: PCWSTR, + ) -> HKEY; + pub fn SetupDiOpenDevRegKey( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Scope: DWORD, + HwProfile: DWORD, + KeyType: DWORD, + samDesired: REGSAM, + ) -> HKEY; + pub fn SetupDiDeleteDevRegKey( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Scope: DWORD, + HwProfile: DWORD, + KeyType: DWORD, + ) -> BOOL; + pub fn SetupDiGetHwProfileList( + HwProfileList: PDWORD, + HwProfileListSize: DWORD, + RequiredSize: PDWORD, + CurrentlyActiveIndex: PDWORD, + ) -> BOOL; + pub fn SetupDiGetHwProfileListExA( + HwProfileList: PDWORD, + HwProfileListSize: DWORD, + RequiredSize: PDWORD, + CurrentlyActiveIndex: PDWORD, + MachineName: PCSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetHwProfileListExW( + HwProfileList: PDWORD, + HwProfileListSize: DWORD, + RequiredSize: PDWORD, + CurrentlyActiveIndex: PDWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetDevicePropertyKeys( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + PropertyKeyArray: *mut DEVPROPKEY, + PropertyKeyCount: DWORD, + RequiredPropertyKeyCount: PDWORD, + Flags: DWORD, + ) -> BOOL; + pub fn SetupDiGetDevicePropertyW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + PropertyKey: *const DEVPROPKEY, + PropertyType: *mut DEVPROPTYPE, + PropertyBuffer: PBYTE, + PropertyBufferSize: DWORD, + RequiredSize: PDWORD, + Flags: DWORD, + ) -> BOOL; + pub fn SetupDiSetDevicePropertyW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + PropertyKey: *const DEVPROPKEY, + PropertyType: DEVPROPTYPE, + PropertyBuffer: *const BYTE, + PropertyBufferSize: DWORD, + Flags: DWORD, + ) -> BOOL; + pub fn SetupDiGetDeviceInterfacePropertyKeys( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + PropertyKeyArray: *mut DEVPROPKEY, + PropertyKeyCount: DWORD, + RequiredPropertyKeyCount: PDWORD, + Flags: DWORD, + ) -> BOOL; + pub fn SetupDiGetDeviceInterfacePropertyW( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + PropertyKey: *const DEVPROPKEY, + PropertyType: *mut DEVPROPTYPE, + PropertyBuffer: PBYTE, + PropertyBufferSize: DWORD, + RequiredSize: PDWORD, + Flags: DWORD, + ) -> BOOL; + pub fn SetupDiSetDeviceInterfacePropertyW( + DeviceInfoSet: HDEVINFO, + DeviceInterfaceData: PSP_DEVICE_INTERFACE_DATA, + PropertyKey: *const DEVPROPKEY, + PropertyType: DEVPROPTYPE, + PropertyBuffer: *const BYTE, + PropertyBufferSize: DWORD, + Flags: DWORD, + ) -> BOOL; +} +pub const DICLASSPROP_INSTALLER: DWORD = 0x00000001; +pub const DICLASSPROP_INTERFACE: DWORD = 0x00000002; +extern "system" { + pub fn SetupDiGetClassPropertyKeys( + ClassGuid: *const GUID, + PropertyKeyArray: *mut DEVPROPKEY, + PropertyKeyCount: DWORD, + RequiredPropertyKeyCount: PDWORD, + Flags: DWORD, + ) -> BOOL; + pub fn SetupDiGetClassPropertyKeysExW( + ClassGuid: *const GUID, + PropertyKeyArray: *mut DEVPROPKEY, + PropertyKeyCount: DWORD, + RequiredPropertyKeyCount: PDWORD, + Flags: DWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetClassPropertyW( + ClassGuid: *const GUID, + PropertyKey: *const DEVPROPKEY, + PropertyType: *mut DEVPROPTYPE, + PropertyBuffer: PBYTE, + PropertyBufferSize: DWORD, + RequiredSize: PDWORD, + Flags: DWORD, + ) -> BOOL; + pub fn SetupDiGetClassPropertyExW( + ClassGuid: *const GUID, + PropertyKey: *const DEVPROPKEY, + PropertyType: *mut DEVPROPTYPE, + PropertyBuffer: PBYTE, + PropertyBufferSize: DWORD, + RequiredSize: PDWORD, + Flags: DWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiSetClassPropertyW( + ClassGuid: *const GUID, + PropertyKey: *const DEVPROPKEY, + PropertyType: DEVPROPTYPE, + PropertyBuffer: *const BYTE, + PropertyBufferSize: DWORD, + Flags: DWORD, + ) -> BOOL; + pub fn SetupDiSetClassPropertyExW( + ClassGuid: *const GUID, + PropertyKey: *const DEVPROPKEY, + PropertyType: DEVPROPTYPE, + PropertyBuffer: *const BYTE, + PropertyBufferSize: DWORD, + Flags: DWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; +} +pub const SPDRP_DEVICEDESC: DWORD = 0x00000000; +pub const SPDRP_HARDWAREID: DWORD = 0x00000001; +pub const SPDRP_COMPATIBLEIDS: DWORD = 0x00000002; +pub const SPDRP_UNUSED0: DWORD = 0x00000003; +pub const SPDRP_SERVICE: DWORD = 0x00000004; +pub const SPDRP_UNUSED1: DWORD = 0x00000005; +pub const SPDRP_UNUSED2: DWORD = 0x00000006; +pub const SPDRP_CLASS: DWORD = 0x00000007; +pub const SPDRP_CLASSGUID: DWORD = 0x00000008; +pub const SPDRP_DRIVER: DWORD = 0x00000009; +pub const SPDRP_CONFIGFLAGS: DWORD = 0x0000000A; +pub const SPDRP_MFG: DWORD = 0x0000000B; +pub const SPDRP_FRIENDLYNAME: DWORD = 0x0000000C; +pub const SPDRP_LOCATION_INFORMATION: DWORD = 0x0000000D; +pub const SPDRP_PHYSICAL_DEVICE_OBJECT_NAME: DWORD = 0x0000000E; +pub const SPDRP_CAPABILITIES: DWORD = 0x0000000F; +pub const SPDRP_UI_NUMBER: DWORD = 0x00000010; +pub const SPDRP_UPPERFILTERS: DWORD = 0x00000011; +pub const SPDRP_LOWERFILTERS: DWORD = 0x00000012; +pub const SPDRP_BUSTYPEGUID: DWORD = 0x00000013; +pub const SPDRP_LEGACYBUSTYPE: DWORD = 0x00000014; +pub const SPDRP_BUSNUMBER: DWORD = 0x00000015; +pub const SPDRP_ENUMERATOR_NAME: DWORD = 0x00000016; +pub const SPDRP_SECURITY: DWORD = 0x00000017; +pub const SPDRP_SECURITY_SDS: DWORD = 0x00000018; +pub const SPDRP_DEVTYPE: DWORD = 0x00000019; +pub const SPDRP_EXCLUSIVE: DWORD = 0x0000001A; +pub const SPDRP_CHARACTERISTICS: DWORD = 0x0000001B; +pub const SPDRP_ADDRESS: DWORD = 0x0000001C; +pub const SPDRP_UI_NUMBER_DESC_FORMAT: DWORD = 0x0000001D; +pub const SPDRP_DEVICE_POWER_DATA: DWORD = 0x0000001E; +pub const SPDRP_REMOVAL_POLICY: DWORD = 0x0000001F; +pub const SPDRP_REMOVAL_POLICY_HW_DEFAULT: DWORD = 0x00000020; +pub const SPDRP_REMOVAL_POLICY_OVERRIDE: DWORD = 0x00000021; +pub const SPDRP_INSTALL_STATE: DWORD = 0x00000022; +pub const SPDRP_LOCATION_PATHS: DWORD = 0x00000023; +pub const SPDRP_BASE_CONTAINERID: DWORD = 0x00000024; +pub const SPDRP_MAXIMUM_PROPERTY: DWORD = 0x00000025; +pub const SPCRP_UPPERFILTERS: DWORD = 0x00000011; +pub const SPCRP_LOWERFILTERS: DWORD = 0x00000012; +pub const SPCRP_SECURITY: DWORD = 0x00000017; +pub const SPCRP_SECURITY_SDS: DWORD = 0x00000018; +pub const SPCRP_DEVTYPE: DWORD = 0x00000019; +pub const SPCRP_EXCLUSIVE: DWORD = 0x0000001A; +pub const SPCRP_CHARACTERISTICS: DWORD = 0x0000001B; +pub const SPCRP_MAXIMUM_PROPERTY: DWORD = 0x0000001C; +extern "system" { + pub fn SetupDiGetDeviceRegistryPropertyA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Property: DWORD, + PropertyRegDataType: PDWORD, + PropertyBuffer: PBYTE, + PropertyBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetDeviceRegistryPropertyW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Property: DWORD, + PropertyRegDataType: PDWORD, + PropertyBuffer: PBYTE, + PropertyBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetClassRegistryPropertyA( + ClassGuid: *const GUID, + Property: DWORD, + PropertyRegDataType: PDWORD, + PropertyBuffer: PBYTE, + PropertyBufferSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetClassRegistryPropertyW( + ClassGuid: *const GUID, + Property: DWORD, + PropertyRegDataType: PDWORD, + PropertyBuffer: PBYTE, + PropertyBufferSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiSetDeviceRegistryPropertyA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Property: DWORD, + PropertyBuffer: *const BYTE, + PropertyBufferSize: DWORD, + ) -> BOOL; + pub fn SetupDiSetDeviceRegistryPropertyW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + Property: DWORD, + PropertyBuffer: *const BYTE, + PropertyBufferSize: DWORD, + ) -> BOOL; + pub fn SetupDiSetClassRegistryPropertyA( + ClassGuid: *const GUID, + Property: DWORD, + PropertyBuffer: *const BYTE, + PropertyBufferSize: DWORD, + MachineName: PCSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiSetClassRegistryPropertyW( + ClassGuid: *const GUID, + Property: DWORD, + PropertyBuffer: *const BYTE, + PropertyBufferSize: DWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetDeviceInstallParamsA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DeviceInstallParams: PSP_DEVINSTALL_PARAMS_A, + ) -> BOOL; + pub fn SetupDiGetDeviceInstallParamsW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DeviceInstallParams: PSP_DEVINSTALL_PARAMS_W, + ) -> BOOL; + pub fn SetupDiGetClassInstallParamsA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ClassInstallParams: PSP_CLASSINSTALL_HEADER, + ClassInstallParamsSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetClassInstallParamsW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ClassInstallParams: PSP_CLASSINSTALL_HEADER, + ClassInstallParamsSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiSetDeviceInstallParamsA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DeviceInstallParams: PSP_DEVINSTALL_PARAMS_A, + ) -> BOOL; + pub fn SetupDiSetDeviceInstallParamsW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DeviceInstallParams: PSP_DEVINSTALL_PARAMS_W, + ) -> BOOL; + pub fn SetupDiSetClassInstallParamsA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ClassInstallParams: PSP_CLASSINSTALL_HEADER, + ClassInstallParamsSize: DWORD, + ) -> BOOL; + pub fn SetupDiSetClassInstallParamsW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ClassInstallParams: PSP_CLASSINSTALL_HEADER, + ClassInstallParamsSize: DWORD, + ) -> BOOL; + pub fn SetupDiGetDriverInstallParamsA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverInfoData: PSP_DRVINFO_DATA_A, + DriverInstallParams: PSP_DRVINSTALL_PARAMS, + ) -> BOOL; + pub fn SetupDiGetDriverInstallParamsW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverInfoData: PSP_DRVINFO_DATA_W, + DriverInstallParams: PSP_DRVINSTALL_PARAMS, + ) -> BOOL; + pub fn SetupDiSetDriverInstallParamsA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverInfoData: PSP_DRVINFO_DATA_A, + DriverInstallParams: PSP_DRVINSTALL_PARAMS, + ) -> BOOL; + pub fn SetupDiSetDriverInstallParamsW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + DriverInfoData: PSP_DRVINFO_DATA_W, + DriverInstallParams: PSP_DRVINSTALL_PARAMS, + ) -> BOOL; + pub fn SetupDiLoadClassIcon( + ClassGuid: *const GUID, + LargeIcon: *mut HICON, + MiniIconIndex: PINT, + ) -> BOOL; + pub fn SetupDiLoadDeviceIcon( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + cxIcon: UINT, + cyIcon: UINT, + Flags: DWORD, + hIcon: *mut HICON, + ) -> BOOL; +} +pub const DMI_MASK: DWORD = 0x00000001; +pub const DMI_BKCOLOR: DWORD = 0x00000002; +pub const DMI_USERECT: DWORD = 0x00000004; +extern "system" { + pub fn SetupDiDrawMiniIcon( + hdc: HDC, + rc: RECT, + MiniIconIndex: INT, + Flags: DWORD, + ) -> INT; + pub fn SetupDiGetClassBitmapIndex( + ClassGuid: *const GUID, + MiniIconIndex: PINT, + ) -> BOOL; + pub fn SetupDiGetClassImageList( + ClassImageListData: PSP_CLASSIMAGELIST_DATA, + ) -> BOOL; + pub fn SetupDiGetClassImageListExA( + ClassImageListData: PSP_CLASSIMAGELIST_DATA, + MachineName: PCSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetClassImageListExW( + ClassImageListData: PSP_CLASSIMAGELIST_DATA, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetClassImageIndex( + ClassImageListData: PSP_CLASSIMAGELIST_DATA, + ClassGuid: *const GUID, + ImageIndex: PINT, + ) -> BOOL; + pub fn SetupDiDestroyClassImageList( + ClassImageListData: PSP_CLASSIMAGELIST_DATA, + ) -> BOOL; +} +pub const DIGCDP_FLAG_BASIC: DWORD = 0x00000001; +pub const DIGCDP_FLAG_ADVANCED: DWORD = 0x00000002; +pub const DIGCDP_FLAG_REMOTE_BASIC: DWORD = 0x00000003; +pub const DIGCDP_FLAG_REMOTE_ADVANCED: DWORD = 0x00000004; +extern "system" { + pub fn SetupDiGetClassDevPropertySheetsA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + PropertySheetHeader: LPPROPSHEETHEADERA, + PropertySheetHeaderPageListSize: DWORD, + RequiredSize: PDWORD, + PropertySheetType: DWORD, + ) -> BOOL; + pub fn SetupDiGetClassDevPropertySheetsW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + PropertySheetHeader: LPPROPSHEETHEADERW, + PropertySheetHeaderPageListSize: DWORD, + RequiredSize: PDWORD, + PropertySheetType: DWORD, + ) -> BOOL; +} +pub const IDI_RESOURCEFIRST: c_int = 159; +pub const IDI_RESOURCE: c_int = 159; +pub const IDI_RESOURCELAST: c_int = 161; +pub const IDI_RESOURCEOVERLAYFIRST: c_int = 161; +pub const IDI_RESOURCEOVERLAYLAST: c_int = 161; +pub const IDI_CONFLICT: c_int = 161; +pub const IDI_CLASSICON_OVERLAYFIRST: c_int = 500; +pub const IDI_CLASSICON_OVERLAYLAST: c_int = 502; +pub const IDI_PROBLEM_OVL: c_int = 500; +pub const IDI_DISABLED_OVL: c_int = 501; +pub const IDI_FORCED_OVL: c_int = 502; +extern "system" { + pub fn SetupDiAskForOEMDisk( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiSelectOEMDrv( + hwndParent: HWND, + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiClassNameFromGuidA( + ClassGuid: *const GUID, + ClassName: PSTR, + ClassNameSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiClassNameFromGuidW( + ClassGuid: *const GUID, + ClassName: PWSTR, + ClassNameSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiClassNameFromGuidExA( + ClassGuid: *const GUID, + ClassName: PSTR, + ClassNameSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiClassNameFromGuidExW( + ClassGuid: *const GUID, + ClassName: PWSTR, + ClassNameSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiClassGuidsFromNameA( + ClassName: PCSTR, + ClassGuidList: LPGUID, + ClassGuidListSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiClassGuidsFromNameW( + ClassName: PCWSTR, + ClassGuidList: LPGUID, + ClassGuidListSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiClassGuidsFromNameExA( + ClassName: PCSTR, + ClassGuidList: LPGUID, + ClassGuidListSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiClassGuidsFromNameExW( + ClassName: PCWSTR, + ClassGuidList: LPGUID, + ClassGuidListSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetHwProfileFriendlyNameA( + HwProfile: DWORD, + FriendlyName: PSTR, + FriendlyNameSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetHwProfileFriendlyNameW( + HwProfile: DWORD, + FriendlyName: PWSTR, + FriendlyNameSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetHwProfileFriendlyNameExA( + HwProfile: DWORD, + FriendlyName: PSTR, + FriendlyNameSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetHwProfileFriendlyNameExW( + HwProfile: DWORD, + FriendlyName: PWSTR, + FriendlyNameSize: DWORD, + RequiredSize: PDWORD, + MachineName: PCWSTR, + Reserved: PVOID, + ) -> BOOL; +} +pub const SPWPT_SELECTDEVICE: DWORD = 0x00000001; +pub const SPWP_USE_DEVINFO_DATA: DWORD = 0x00000001; +extern "system" { + pub fn SetupDiGetWizardPage( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + InstallWizardData: PSP_INSTALLWIZARD_DATA, + PageType: DWORD, + Flags: DWORD, + ) -> HPROPSHEETPAGE; + pub fn SetupDiGetSelectedDevice( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiSetSelectedDevice( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + ) -> BOOL; + pub fn SetupDiGetActualModelsSectionA( + Context: PINFCONTEXT, + AlternatePlatformInfo: PSP_ALTPLATFORM_INFO, + InfSectionWithExt: PSTR, + InfSectionWithExtSize: DWORD, + RequiredSize: PDWORD, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetActualModelsSectionW( + Context: PINFCONTEXT, + AlternatePlatformInfo: PSP_ALTPLATFORM_INFO, + InfSectionWithExt: PWSTR, + InfSectionWithExtSize: DWORD, + RequiredSize: PDWORD, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetActualSectionToInstallA( + InfHandle: HINF, + InfSectionName: PCSTR, + InfSectionWithExt: PSTR, + InfSectionWithExtSize: DWORD, + RequiredSize: PDWORD, + Extension: *mut PSTR, + ) -> BOOL; + pub fn SetupDiGetActualSectionToInstallW( + InfHandle: HINF, + InfSectionName: PCWSTR, + InfSectionWithExt: PWSTR, + InfSectionWithExtSize: DWORD, + RequiredSize: PDWORD, + Extension: *mut PWSTR, + ) -> BOOL; + pub fn SetupDiGetActualSectionToInstallExA( + InfHandle: HINF, + InfSectionName: PCSTR, + AlternatePlatformInfo: PSP_ALTPLATFORM_INFO, + InfSectionWithExt: PSTR, + InfSectionWithExtSize: DWORD, + RequiredSize: PDWORD, + Extension: *mut PSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupDiGetActualSectionToInstallExW( + InfHandle: HINF, + InfSectionName: PCWSTR, + AlternatePlatformInfo: PSP_ALTPLATFORM_INFO, + InfSectionWithExt: PWSTR, + InfSectionWithExtSize: DWORD, + RequiredSize: PDWORD, + Extension: *mut PWSTR, + Reserved: PVOID, + ) -> BOOL; + pub fn SetupEnumInfSectionsA( + InfHandle: HINF, + Index: UINT, + Buffer: PSTR, + Size: UINT, + SizeNeeded: *mut UINT, + ) -> BOOL; + pub fn SetupEnumInfSectionsW( + InfHandle: HINF, + Index: UINT, + Buffer: PWSTR, + Size: UINT, + SizeNeeded: *mut UINT, + ) -> BOOL; +} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_INF_SIGNER_INFO_V1_A { + cbSize: DWORD, + CatalogFile: [CHAR; MAX_PATH], + DigitalSigner: [CHAR; MAX_PATH], + DigitalSignerVersion: [CHAR; MAX_PATH], +}} +pub type PSP_INF_SIGNER_INFO_V1_A = *mut SP_INF_SIGNER_INFO_V1_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_INF_SIGNER_INFO_V1_W { + cbSize: DWORD, + CatalogFile: [WCHAR; MAX_PATH], + DigitalSigner: [WCHAR; MAX_PATH], + DigitalSignerVersion: [WCHAR; MAX_PATH], +}} +pub type PSP_INF_SIGNER_INFO_V1_W = *mut SP_INF_SIGNER_INFO_V1_W; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_INF_SIGNER_INFO_V2_A { + cbSize: DWORD, + CatalogFile: [CHAR; MAX_PATH], + DigitalSigner: [CHAR; MAX_PATH], + DigitalSignerVersion: [CHAR; MAX_PATH], + SignerScore: DWORD, +}} +pub type PSP_INF_SIGNER_INFO_V2_A = *mut SP_INF_SIGNER_INFO_V2_A; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SP_INF_SIGNER_INFO_V2_W { + cbSize: DWORD, + CatalogFile: [WCHAR; MAX_PATH], + DigitalSigner: [WCHAR; MAX_PATH], + DigitalSignerVersion: [WCHAR; MAX_PATH], + SignerScore: DWORD, +}} +pub type PSP_INF_SIGNER_INFO_V2_W = *mut SP_INF_SIGNER_INFO_V2_W; +pub const SIGNERSCORE_UNKNOWN: DWORD = 0xFF000000; +pub const SIGNERSCORE_W9X_SUSPECT: DWORD = 0xC0000000; +pub const SIGNERSCORE_UNSIGNED: DWORD = 0x80000000; +pub const SIGNERSCORE_AUTHENTICODE: DWORD = 0x0F000000; +pub const SIGNERSCORE_WHQL: DWORD = 0x0D000005; +pub const SIGNERSCORE_UNCLASSIFIED: DWORD = 0x0D000004; +pub const SIGNERSCORE_INBOX: DWORD = 0x0D000003; +pub const SIGNERSCORE_LOGO_STANDARD: DWORD = 0x0D000002; +pub const SIGNERSCORE_LOGO_PREMIUM: DWORD = 0x0D000001; +pub const SIGNERSCORE_MASK: DWORD = 0xFF000000; +pub const SIGNERSCORE_SIGNED_MASK: DWORD = 0xF0000000; +pub type SP_INF_SIGNER_INFO_A = SP_INF_SIGNER_INFO_V2_A; +pub type PSP_INF_SIGNER_INFO_A = PSP_INF_SIGNER_INFO_V2_A; +pub type SP_INF_SIGNER_INFO_W = SP_INF_SIGNER_INFO_V2_W; +pub type PSP_INF_SIGNER_INFO_W = PSP_INF_SIGNER_INFO_V2_W; +extern "system" { + pub fn SetupVerifyInfFileA( + InfName: PCSTR, + AltPlatformInfo: PSP_ALTPLATFORM_INFO, + InfSignerInfo: PSP_INF_SIGNER_INFO_A, + ) -> BOOL; + pub fn SetupVerifyInfFileW( + InfName: PCWSTR, + AltPlatformInfo: PSP_ALTPLATFORM_INFO, + InfSignerInfo: PSP_INF_SIGNER_INFO_W, + ) -> BOOL; +} +pub const DICUSTOMDEVPROP_MERGE_MULTISZ: DWORD = 0x00000001; +extern "system" { + pub fn SetupDiGetCustomDevicePropertyA( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + CustomPropertyName: PCSTR, + Flags: DWORD, + PropertyRegDataType: PDWORD, + PropertyBuffer: PBYTE, + PropertyBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; + pub fn SetupDiGetCustomDevicePropertyW( + DeviceInfoSet: HDEVINFO, + DeviceInfoData: PSP_DEVINFO_DATA, + CustomPropertyName: PCWSTR, + Flags: DWORD, + PropertyRegDataType: PDWORD, + PropertyBuffer: PBYTE, + PropertyBufferSize: DWORD, + RequiredSize: PDWORD, + ) -> BOOL; +} +pub const SCWMI_CLOBBER_SECURITY: DWORD = 0x00000001; +extern "system" { + pub fn SetupConfigureWmiFromInfSectionA( + InfHandle: HINF, + SectionName: PCSTR, + Flags: DWORD, + ) -> BOOL; + pub fn SetupConfigureWmiFromInfSectionW( + InfHandle: HINF, + SectionName: PCWSTR, + Flags: DWORD, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/shellapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/shellapi.rs new file mode 100644 index 0000000..2c961c4 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/shellapi.rs @@ -0,0 +1,923 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! SHELL.DLL functions, types, and definitions +use ctypes::{__int64, c_int, c_void}; +use shared::basetsd::{DWORD_PTR, UINT_PTR}; +use shared::guiddef::{GUID, REFIID}; +use shared::minwindef::{ + BOOL, DWORD, FILETIME, HINSTANCE, HKEY, INT, LPARAM, LPVOID, MAX_PATH, UINT, ULONG, WORD, +}; +use shared::windef::{HICON, HWND, POINT, RECT}; +use um::minwinbase::LPSECURITY_ATTRIBUTES; +use um::processthreadsapi::{LPPROCESS_INFORMATION, LPSTARTUPINFOW}; +use um::winnt::{ + CHAR, HANDLE, HRESULT, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PCSTR, PCWSTR, PCZZSTR, PCZZWSTR, PWSTR, + PZZSTR, PZZWSTR, ULARGE_INTEGER, WCHAR, +}; +use um::winuser::WM_USER; +DECLARE_HANDLE!{HDROP, HDROP__} +extern "system" { + pub fn DragQueryFileA( + hDrop: HDROP, + iFile: UINT, + lpszFile: LPSTR, + cch: UINT, + ) -> UINT; + pub fn DragQueryFileW( + hDrop: HDROP, + iFile: UINT, + lpszFile: LPWSTR, + cch: UINT, + ) -> UINT; + pub fn DragQueryPoint( + hDrop: HDROP, + lppt: *mut POINT, + ) -> BOOL; + pub fn DragFinish( + hDrop: HDROP, + ); + pub fn DragAcceptFiles( + hWnd: HWND, + fAccept: BOOL, + ); + pub fn ShellExecuteA( + hwnd: HWND, + lpOperation: LPCSTR, + lpFile: LPCSTR, + lpParameters: LPCSTR, + lpDirectory: LPCSTR, + nShowCmd: c_int, + ) -> HINSTANCE; + pub fn ShellExecuteW( + hwnd: HWND, + lpOperation: LPCWSTR, + lpFile: LPCWSTR, + lpParameters: LPCWSTR, + lpDirectory: LPCWSTR, + nShowCmd: c_int, + ) -> HINSTANCE; + pub fn FindExecutableA( + lpFile: LPCSTR, + lpDirectory: LPCSTR, + lpResult: LPSTR, + ) -> HINSTANCE; + pub fn FindExecutableW( + lpFile: LPCWSTR, + lpDirectory: LPCWSTR, + lpResult: LPWSTR, + ) -> HINSTANCE; + pub fn CommandLineToArgvW( + lpCmdLine: LPCWSTR, + pNumArgs: *mut c_int, + ) -> *mut LPWSTR; + pub fn ShellAboutA( + hWnd: HWND, + szApp: LPCSTR, + szOtherStuff: LPCSTR, + hIcon: HICON, + ) -> INT; + pub fn ShellAboutW( + hWnd: HWND, + szApp: LPCWSTR, + szOtherStuff: LPCWSTR, + hIcon: HICON, + ) -> INT; + pub fn DuplicateIcon( + hInst: HINSTANCE, + hIcon: HICON, + ) -> HICON; + pub fn ExtractAssociatedIconA( + hInst: HINSTANCE, + pszIconPath: LPSTR, + piIcon: *mut WORD, + ) -> HICON; + pub fn ExtractAssociatedIconW( + hInst: HINSTANCE, + pszIconPath: LPWSTR, + piIcon: *mut WORD, + ) -> HICON; + pub fn ExtractAssociatedIconExA( + hInst: HINSTANCE, + pszIconPath: LPSTR, + piIconIndex: *mut WORD, + piIconId: *mut WORD, + ) -> HICON; + pub fn ExtractAssociatedIconExW( + hInst: HINSTANCE, + pszIconPath: LPWSTR, + piIconIndex: *mut WORD, + piIconId: *mut WORD, + ) -> HICON; + pub fn ExtractIconA( + hInst: HINSTANCE, + pszExeFileName: LPCSTR, + nIconIndex: UINT, + ) -> HICON; + pub fn ExtractIconW( + hInst: HINSTANCE, + pszExeFileName: LPCWSTR, + nIconIndex: UINT, + ) -> HICON; +} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct DRAGINFOA { + uSize: UINT, + pt: POINT, + fNC: BOOL, + lpFileList: PZZSTR, + grfKeyState: DWORD, +}} +pub type LPDRAGINFOA = *mut DRAGINFOA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct DRAGINFOW { + uSize: UINT, + pt: POINT, + fNC: BOOL, + lpFileList: PZZWSTR, + grfKeyState: DWORD, +}} +pub type LPDRAGINFOW = *mut DRAGINFOW; +pub const ABM_NEW: DWORD = 0x00000000; +pub const ABM_REMOVE: DWORD = 0x00000001; +pub const ABM_QUERYPOS: DWORD = 0x00000002; +pub const ABM_SETPOS: DWORD = 0x00000003; +pub const ABM_GETSTATE: DWORD = 0x00000004; +pub const ABM_GETTASKBARPOS: DWORD = 0x00000005; +pub const ABM_ACTIVATE: DWORD = 0x00000006; +pub const ABM_GETAUTOHIDEBAR: DWORD = 0x00000007; +pub const ABM_SETAUTOHIDEBAR: DWORD = 0x00000008; +pub const ABM_WINDOWPOSCHANGED: DWORD = 0x0000009; +pub const ABM_SETSTATE: DWORD = 0x0000000a; +pub const ABM_GETAUTOHIDEBAREX: DWORD = 0x0000000b; +pub const ABM_SETAUTOHIDEBAREX: DWORD = 0x0000000c; +pub const ABN_STATECHANGE: DWORD = 0x0000000; +pub const ABN_POSCHANGED: DWORD = 0x0000001; +pub const ABN_FULLSCREENAPP: DWORD = 0x0000002; +pub const ABN_WINDOWARRANGE: DWORD = 0x0000003; +pub const ABS_AUTOHIDE: UINT = 0x0000001; +pub const ABS_ALWAYSONTOP: UINT = 0x0000002; +pub const ABE_LEFT: UINT = 0; +pub const ABE_TOP: UINT = 1; +pub const ABE_RIGHT: UINT = 2; +pub const ABE_BOTTOM: UINT = 3; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct APPBARDATA { + cbSize: DWORD, + hWnd: HWND, + uCallbackMessage: UINT, + uEdge: UINT, + rc: RECT, + lParam: LPARAM, +}} +pub type PAPPBARDATA = *mut APPBARDATA; +extern "system" { + pub fn SHAppBarMessage( + dwMessage: DWORD, + pData: PAPPBARDATA, + ) -> UINT_PTR; + pub fn DoEnvironmentSubstA( + pszSrc: LPSTR, + cchSrc: UINT, + ) -> DWORD; + pub fn DoEnvironmentSubstW( + pszSrc: LPWSTR, + cchSrc: UINT, + ) -> DWORD; + pub fn ExtractIconExA( + lpszFile: LPCSTR, + nIconIndex: c_int, + phiconLarge: *mut HICON, + phiconSmall: *mut HICON, + nIcons: UINT, + ) -> UINT; + pub fn ExtractIconExW( + lpszFile: LPCWSTR, + nIconIndex: c_int, + phiconLarge: *mut HICON, + phiconSmall: *mut HICON, + nIcons: UINT, + ) -> UINT; +} +pub const FO_MOVE: WORD = 0x0001; +pub const FO_COPY: WORD = 0x0002; +pub const FO_DELETE: WORD = 0x0003; +pub const FO_RENAME: WORD = 0x0004; +pub const FOF_MULTIDESTFILES: WORD = 0x0001; +pub const FOF_CONFIRMMOUSE: WORD = 0x0002; +pub const FOF_SILENT: WORD = 0x0004; +pub const FOF_RENAMEONCOLLISION: WORD = 0x0008; +pub const FOF_NOCONFIRMATION: WORD = 0x0010; +pub const FOF_WANTMAPPINGHANDLE: WORD = 0x0020; +pub const FOF_ALLOWUNDO: WORD = 0x0040; +pub const FOF_FILESONLY: WORD = 0x0080; +pub const FOF_SIMPLEPROGRESS: WORD = 0x0100; +pub const FOF_NOCONFIRMMKDIR: WORD = 0x0200; +pub const FOF_NOERRORUI: WORD = 0x0400; +pub const FOF_NOCOPYSECURITYATTRIBS: WORD = 0x0800; +pub const FOF_NORECURSION: WORD = 0x1000; +pub const FOF_NO_CONNECTED_ELEMENTS: WORD = 0x2000; +pub const FOF_WANTNUKEWARNING: WORD = 0x4000; +pub const FOF_NORECURSEREPARSE: WORD = 0x8000; +pub const FOF_NO_UI: WORD = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR; +pub type FILEOP_FLAGS = WORD; +pub const PO_DELETE: WORD = 0x0013; +pub const PO_RENAME: WORD = 0x0014; +pub const PO_PORTCHANGE: WORD = 0x0020; +pub const PO_REN_PORT: WORD = 0x0034; +pub type PRINTEROP_FLAGS = WORD; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHFILEOPSTRUCTA { + hwnd: HWND, + wFunc: UINT, + pFrom: PCZZSTR, + pTo: PCZZSTR, + fFlags: FILEOP_FLAGS, + fAnyOperationsAborted: BOOL, + hNameMappings: LPVOID, + lpszProgressTitle: PCSTR, +}} +pub type LPSHFILEOPSTRUCTA = *mut SHFILEOPSTRUCTA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHFILEOPSTRUCTW { + hwnd: HWND, + wFunc: UINT, + pFrom: PCZZWSTR, + pTo: PCZZWSTR, + fFlags: FILEOP_FLAGS, + fAnyOperationsAborted: BOOL, + hNameMappings: LPVOID, + lpszProgressTitle: PCWSTR, +}} +pub type LPSHFILEOPSTRUCTW = *mut SHFILEOPSTRUCTW; +extern "system" { + pub fn SHFileOperationA( + lpFileOp: LPSHFILEOPSTRUCTA, + ) -> c_int; + pub fn SHFileOperationW( + lpFileOp: LPSHFILEOPSTRUCTW, + ) -> c_int; + pub fn SHFreeNameMappings( + hNameMappings: HANDLE, + ); +} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHNAMEMAPPINGA { + pszOldPath: LPSTR, + pszNewPath: LPSTR, + cchOldPath: c_int, + cchNewPath: c_int, +}} +pub type LPSHNAMEMAPPINGA = *mut SHNAMEMAPPINGA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHNAMEMAPPINGW { + pszOldPath: LPWSTR, + pszNewPath: LPWSTR, + cchOldPath: c_int, + cchNewPath: c_int, +}} +pub type LPSHNAMEMAPPINGW = *mut SHNAMEMAPPINGW; +pub const SE_ERR_FNF: DWORD = 2; +pub const SE_ERR_PNF: DWORD = 3; +pub const SE_ERR_ACCESSDENIED: DWORD = 5; +pub const SE_ERR_OOM: DWORD = 8; +pub const SE_ERR_DLLNOTFOUND: DWORD = 32; +pub const SE_ERR_SHARE: DWORD = 26; +pub const SE_ERR_ASSOCINCOMPLETE: DWORD = 27; +pub const SE_ERR_DDETIMEOUT: DWORD = 28; +pub const SE_ERR_DDEFAIL: DWORD = 29; +pub const SE_ERR_DDEBUSY: DWORD = 30; +pub const SE_ERR_NOASSOC: DWORD = 31; +pub const SEE_MASK_DEFAULT: DWORD = 0x00000000; +pub const SEE_MASK_CLASSNAME: DWORD = 0x00000001; +pub const SEE_MASK_CLASSKEY: DWORD = 0x00000003; +pub const SEE_MASK_IDLIST: DWORD = 0x00000004; +pub const SEE_MASK_INVOKEIDLIST: DWORD = 0x0000000c; +pub const SEE_MASK_ICON: DWORD = 0x00000010; +pub const SEE_MASK_HOTKEY: DWORD = 0x00000020; +pub const SEE_MASK_NOCLOSEPROCESS: DWORD = 0x00000040; +pub const SEE_MASK_CONNECTNETDRV: DWORD = 0x00000080; +pub const SEE_MASK_NOASYNC: DWORD = 0x00000100; +pub const SEE_MASK_FLAG_DDEWAIT: DWORD = SEE_MASK_NOASYNC; +pub const SEE_MASK_DOENVSUBST: DWORD = 0x00000200; +pub const SEE_MASK_FLAG_NO_UI: DWORD = 0x00000400; +pub const SEE_MASK_UNICODE: DWORD = 0x00004000; +pub const SEE_MASK_NO_CONSOLE: DWORD = 0x00008000; +pub const SEE_MASK_ASYNCOK: DWORD = 0x00100000; +pub const SEE_MASK_HMONITOR: DWORD = 0x00200000; +pub const SEE_MASK_NOZONECHECKS: DWORD = 0x00800000; +pub const SEE_MASK_NOQUERYCLASSSTORE: DWORD = 0x01000000; +pub const SEE_MASK_WAITFORINPUTIDLE: DWORD = 0x02000000; +pub const SEE_MASK_FLAG_LOG_USAGE: DWORD = 0x04000000; +pub const SEE_MASK_FLAG_HINST_IS_SITE: DWORD = 0x08000000; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHELLEXECUTEINFOA { + cbSize: DWORD, + fMask: ULONG, + hwnd: HWND, + lpVerb: LPCSTR, + lpFile: LPCSTR, + lpParameters: LPCSTR, + lpDirectory: LPCSTR, + nShow: c_int, + hInstApp: HINSTANCE, + lpIDList: *mut c_void, + lpClass: LPCSTR, + hkeyClass: HKEY, + dwHotKey: DWORD, + hMonitor: HANDLE, + hProcess: HANDLE, +}} +pub type LPSHELLEXECUTEINFOA = *mut SHELLEXECUTEINFOA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHELLEXECUTEINFOW { + cbSize: DWORD, + fMask: ULONG, + hwnd: HWND, + lpVerb: LPCWSTR, + lpFile: LPCWSTR, + lpParameters: LPCWSTR, + lpDirectory: LPCWSTR, + nShow: c_int, + hInstApp: HINSTANCE, + lpIDList: *mut c_void, + lpClass: LPCWSTR, + hkeyClass: HKEY, + dwHotKey: DWORD, + hMonitor: HANDLE, + hProcess: HANDLE, +}} +pub type LPSHELLEXECUTEINFOW = *mut SHELLEXECUTEINFOW; +extern "system" { + pub fn ShellExecuteExA( + pExecInfo: *mut SHELLEXECUTEINFOA, + ) -> BOOL; + pub fn ShellExecuteExW( + pExecInfo: *mut SHELLEXECUTEINFOW, + ) -> BOOL; +} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHCREATEPROCESSINFOW { + cbSize: DWORD, + fMask: ULONG, + hwnd: HWND, + pszFile: LPCWSTR, + pszParameters: LPCWSTR, + pszCurrentDirectory: LPCWSTR, + hUserToken: HANDLE, + lpProcessAttributes: LPSECURITY_ATTRIBUTES, + lpThreadAttributes: LPSECURITY_ATTRIBUTES, + bInheritHandles: BOOL, + dwCreationFlags: DWORD, + lpStartupInfo: LPSTARTUPINFOW, + lpProcessInformation: LPPROCESS_INFORMATION, +}} +pub type PSHCREATEPROCESSINFOW = *mut SHCREATEPROCESSINFOW; +extern "system" { + pub fn SHCreateProcessAsUserW( + pscpi: PSHCREATEPROCESSINFOW, + ) -> BOOL; + pub fn SHEvaluateSystemCommandTemplate( + pszCmdTemplate: PCWSTR, + ppszApplication: *mut PWSTR, + ppszCommandLine: *mut PWSTR, + ppszParameters: *mut PWSTR, + ) -> HRESULT; +} +ENUM!{enum ASSOCCLASS { + ASSOCCLASS_SHELL_KEY = 0, + ASSOCCLASS_PROGID_KEY, + ASSOCCLASS_PROGID_STR, + ASSOCCLASS_CLSID_KEY, + ASSOCCLASS_CLSID_STR, + ASSOCCLASS_APP_KEY, + ASSOCCLASS_APP_STR, + ASSOCCLASS_SYSTEM_STR, + ASSOCCLASS_FOLDER, + ASSOCCLASS_STAR, + ASSOCCLASS_FIXED_PROGID_STR, + ASSOCCLASS_PROTOCOL_STR, +}} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct ASSOCIATIONELEMENT { + ac: ASSOCCLASS, + hkClass: HKEY, + pszClass: PCWSTR, +}} +extern "system" { + pub fn AssocCreateForClasses( + rgClasses: *const ASSOCIATIONELEMENT, + cClasses: ULONG, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT; +} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHQUERYRBINFO { + cbSize: DWORD, + i64Size: __int64, + i64NumItems: __int64, +}} +pub type LPSHQUERYRBINFO = *mut SHQUERYRBINFO; +pub const SHERB_NOCONFIRMATION: DWORD = 0x00000001; +pub const SHERB_NOPROGRESSUI: DWORD = 0x00000002; +pub const SHERB_NOSOUND: DWORD = 0x00000004; +extern "system" { + pub fn SHQueryRecycleBinA( + pszRootPath: LPCSTR, + pSHQueryRBInfo: LPSHQUERYRBINFO, + ) -> HRESULT; + pub fn SHQueryRecycleBinW( + pszRootPath: LPCWSTR, + pSHQueryRBInfo: LPSHQUERYRBINFO, + ) -> HRESULT; + pub fn SHEmptyRecycleBinA( + hwnd: HWND, + pszRootPath: LPCSTR, + dwFlags: DWORD, + ) -> HRESULT; + pub fn SHEmptyRecycleBinW( + hwnd: HWND, + pszRootPath: LPCWSTR, + dwFlags: DWORD, + ) -> HRESULT; +} +ENUM!{enum QUERY_USER_NOTIFICATION_STATE { + QUNS_NOT_PRESENT = 1, + QUNS_BUSY = 2, + QUNS_RUNNING_D3D_FULL_SCREEN = 3, + QUNS_PRESENTATION_MODE = 4, + QUNS_ACCEPTS_NOTIFICATIONS = 5, + QUNS_QUIET_TIME = 6, + QUNS_APP = 7, +}} +extern "system" { + pub fn SHQueryUserNotificationState( + pquns: *mut QUERY_USER_NOTIFICATION_STATE, + ) -> HRESULT; + pub fn SHGetPropertyStoreForWindow( + hwnd: HWND, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT; +} +UNION!{#[cfg_attr(target_arch = "x86", repr(packed))] union NOTIFYICONDATAA_u { + [u32; 1], + uTimeout uTimeout_mut: UINT, + uVersion uVersion_mut: UINT, +}} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct NOTIFYICONDATAA { + cbSize: DWORD, + hWnd: HWND, + uID: UINT, + uFlags: UINT, + uCallbackMessage: UINT, + hIcon: HICON, + szTip: [CHAR; 128], + dwState: DWORD, + dwStateMask: DWORD, + szInfo: [CHAR; 256], + u: NOTIFYICONDATAA_u, + szInfoTitle: [CHAR; 64], + dwInfoFlags: DWORD, + guidItem: GUID, + hBalloonIcon: HICON, +}} +pub type PNOTIFYICONDATAA = *mut NOTIFYICONDATAA; +UNION!{#[cfg_attr(target_arch = "x86", repr(packed))] union NOTIFYICONDATAW_u { + [u32; 1], + uTimeout uTimeout_mut: UINT, + uVersion uVersion_mut: UINT, +}} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct NOTIFYICONDATAW { + cbSize: DWORD, + hWnd: HWND, + uID: UINT, + uFlags: UINT, + uCallbackMessage: UINT, + hIcon: HICON, + szTip: [WCHAR; 128], + dwState: DWORD, + dwStateMask: DWORD, + szInfo: [WCHAR; 256], + u: NOTIFYICONDATAW_u, + szInfoTitle: [WCHAR; 64], + dwInfoFlags: DWORD, + guidItem: GUID, + hBalloonIcon: HICON, +}} +pub type PNOTIFYICONDATAW = *mut NOTIFYICONDATAW; +pub const NIN_SELECT: DWORD = WM_USER + 0; +pub const NINF_KEY: DWORD = 0x1; +pub const NIN_KEYSELECT: DWORD = NIN_SELECT | NINF_KEY; +pub const NIN_BALLOONSHOW: DWORD = WM_USER + 2; +pub const NIN_BALLOONHIDE: DWORD = WM_USER + 3; +pub const NIN_BALLOONTIMEOUT: DWORD = WM_USER + 4; +pub const NIN_BALLOONUSERCLICK: DWORD = WM_USER + 5; +pub const NIN_POPUPOPEN: DWORD = WM_USER + 6; +pub const NIN_POPUPCLOSE: DWORD = WM_USER + 7; +pub const NIM_ADD: DWORD = 0x00000000; +pub const NIM_MODIFY: DWORD = 0x00000001; +pub const NIM_DELETE: DWORD = 0x00000002; +pub const NIM_SETFOCUS: DWORD = 0x00000003; +pub const NIM_SETVERSION: DWORD = 0x00000004; +pub const NOTIFYICON_VERSION: DWORD = 3; +pub const NOTIFYICON_VERSION_4: DWORD = 4; +pub const NIF_MESSAGE: DWORD = 0x00000001; +pub const NIF_ICON: DWORD = 0x00000002; +pub const NIF_TIP: DWORD = 0x00000004; +pub const NIF_STATE: DWORD = 0x00000008; +pub const NIF_INFO: DWORD = 0x00000010; +pub const NIF_GUID: DWORD = 0x00000020; +pub const NIF_REALTIME: DWORD = 0x00000040; +pub const NIF_SHOWTIP: DWORD = 0x00000080; +pub const NIS_HIDDEN: DWORD = 0x00000001; +pub const NIS_SHAREDICON: DWORD = 0x00000002; +pub const NIIF_NONE: DWORD = 0x00000000; +pub const NIIF_INFO: DWORD = 0x00000001; +pub const NIIF_WARNING: DWORD = 0x00000002; +pub const NIIF_ERROR: DWORD = 0x00000003; +pub const NIIF_USER: DWORD = 0x00000004; +pub const NIIF_ICON_MASK: DWORD = 0x0000000F; +pub const NIIF_NOSOUND: DWORD = 0x00000010; +pub const NIIF_LARGE_ICON: DWORD = 0x00000020; +pub const NIIF_RESPECT_QUIET_TIME: DWORD = 0x00000080; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct NOTIFYICONIDENTIFIER { + cbSize: DWORD, + hWnd: HWND, + uID: UINT, + guidItem: GUID, +}} +pub type PNOTIFYICONIDENTIFIER = *mut NOTIFYICONIDENTIFIER; +extern "system" { + pub fn Shell_NotifyIconA( + dwMessage: DWORD, + lpData: PNOTIFYICONDATAA, + ) -> BOOL; + pub fn Shell_NotifyIconW( + dwMessage: DWORD, + lpData: PNOTIFYICONDATAW, + ) -> BOOL; + pub fn Shell_NotifyIconGetRect( + identifier: *const NOTIFYICONIDENTIFIER, + iconLocation: *mut RECT, + ) -> HRESULT; +} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHFILEINFOA { + hIcon: HICON, + iIcon: c_int, + dwAttributes: DWORD, + szDisplayName: [CHAR; MAX_PATH], + szTypeName: [CHAR; 80], +}} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHFILEINFOW { + hIcon: HICON, + iIcon: c_int, + dwAttributes: DWORD, + szDisplayName: [WCHAR; MAX_PATH], + szTypeName: [WCHAR; 80], +}} +pub const SHGFI_ICON: DWORD = 0x000000100; +pub const SHGFI_DISPLAYNAME: DWORD = 0x000000200; +pub const SHGFI_TYPENAME: DWORD = 0x000000400; +pub const SHGFI_ATTRIBUTES: DWORD = 0x000000800; +pub const SHGFI_ICONLOCATION: DWORD = 0x000001000; +pub const SHGFI_EXETYPE: DWORD = 0x000002000; +pub const SHGFI_SYSICONINDEX: DWORD = 0x000004000; +pub const SHGFI_LINKOVERLAY: DWORD = 0x000008000; +pub const SHGFI_SELECTED: DWORD = 0x000010000; +pub const SHGFI_ATTR_SPECIFIED: DWORD = 0x000020000; +pub const SHGFI_LARGEICON: DWORD = 0x000000000; +pub const SHGFI_SMALLICON: DWORD = 0x000000001; +pub const SHGFI_OPENICON: DWORD = 0x000000002; +pub const SHGFI_SHELLICONSIZE: DWORD = 0x000000004; +pub const SHGFI_PIDL: DWORD = 0x000000008; +pub const SHGFI_USEFILEATTRIBUTES: DWORD = 0x000000010; +pub const SHGFI_ADDOVERLAYS: DWORD = 0x000000020; +pub const SHGFI_OVERLAYINDEX: DWORD = 0x000000040; +extern "system" { + pub fn SHGetFileInfoA( + pszPath: LPCSTR, + dwFileAttributes: DWORD, + psfi: *mut SHFILEINFOA, + cbFileInfo: UINT, + uFlags: UINT, + ) -> DWORD_PTR; + pub fn SHGetFileInfoW( + pszPath: LPCWSTR, + dwFileAttributes: DWORD, + psfi: *mut SHFILEINFOW, + cbFileInfo: UINT, + uFlags: UINT, + ) -> DWORD_PTR; +} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHSTOCKICONINFO { + cbSize: DWORD, + hIcon: HICON, + iSysImageIndex: c_int, + iIcon: c_int, + szPath: [WCHAR; MAX_PATH], +}} +pub const SHGSI_ICONLOCATION: DWORD = 0; +pub const SHGSI_ICON: DWORD = SHGFI_ICON; +pub const SHGSI_SYSICONINDEX: DWORD = SHGFI_SYSICONINDEX; +pub const SHGSI_LINKOVERLAY: DWORD = SHGFI_LINKOVERLAY; +pub const SHGSI_SELECTED: DWORD = SHGFI_SELECTED; +pub const SHGSI_LARGEICON: DWORD = SHGFI_LARGEICON; +pub const SHGSI_SMALLICON: DWORD = SHGFI_SMALLICON; +pub const SHGSI_SHELLICONSIZE: DWORD = SHGFI_SHELLICONSIZE; +ENUM!{enum SHSTOCKICONID { + SIID_DOCNOASSOC = 0, + SIID_DOCASSOC = 1, + SIID_APPLICATION = 2, + SIID_FOLDER = 3, + SIID_FOLDEROPEN = 4, + SIID_DRIVE525 = 5, + SIID_DRIVE35 = 6, + SIID_DRIVEREMOVE = 7, + SIID_DRIVEFIXED = 8, + SIID_DRIVENET = 9, + SIID_DRIVENETDISABLED = 10, + SIID_DRIVECD = 11, + SIID_DRIVERAM = 12, + SIID_WORLD = 13, + SIID_SERVER = 15, + SIID_PRINTER = 16, + SIID_MYNETWORK = 17, + SIID_FIND = 22, + SIID_HELP = 23, + SIID_SHARE = 28, + SIID_LINK = 29, + SIID_SLOWFILE = 30, + SIID_RECYCLER = 31, + SIID_RECYCLERFULL = 32, + SIID_MEDIACDAUDIO = 40, + SIID_LOCK = 47, + SIID_AUTOLIST = 49, + SIID_PRINTERNET = 50, + SIID_SERVERSHARE = 51, + SIID_PRINTERFAX = 52, + SIID_PRINTERFAXNET = 53, + SIID_PRINTERFILE = 54, + SIID_STACK = 55, + SIID_MEDIASVCD = 56, + SIID_STUFFEDFOLDER = 57, + SIID_DRIVEUNKNOWN = 58, + SIID_DRIVEDVD = 59, + SIID_MEDIADVD = 60, + SIID_MEDIADVDRAM = 61, + SIID_MEDIADVDRW = 62, + SIID_MEDIADVDR = 63, + SIID_MEDIADVDROM = 64, + SIID_MEDIACDAUDIOPLUS = 65, + SIID_MEDIACDRW = 66, + SIID_MEDIACDR = 67, + SIID_MEDIACDBURN = 68, + SIID_MEDIABLANKCD = 69, + SIID_MEDIACDROM = 70, + SIID_AUDIOFILES = 71, + SIID_IMAGEFILES = 72, + SIID_VIDEOFILES = 73, + SIID_MIXEDFILES = 74, + SIID_FOLDERBACK = 75, + SIID_FOLDERFRONT = 76, + SIID_SHIELD = 77, + SIID_WARNING = 78, + SIID_INFO = 79, + SIID_ERROR = 80, + SIID_KEY = 81, + SIID_SOFTWARE = 82, + SIID_RENAME = 83, + SIID_DELETE = 84, + SIID_MEDIAAUDIODVD = 85, + SIID_MEDIAMOVIEDVD = 86, + SIID_MEDIAENHANCEDCD = 87, + SIID_MEDIAENHANCEDDVD = 88, + SIID_MEDIAHDDVD = 89, + SIID_MEDIABLURAY = 90, + SIID_MEDIAVCD = 91, + SIID_MEDIADVDPLUSR = 92, + SIID_MEDIADVDPLUSRW = 93, + SIID_DESKTOPPC = 94, + SIID_MOBILEPC = 95, + SIID_USERS = 96, + SIID_MEDIASMARTMEDIA = 97, + SIID_MEDIACOMPACTFLASH = 98, + SIID_DEVICECELLPHONE = 99, + SIID_DEVICECAMERA = 100, + SIID_DEVICEVIDEOCAMERA = 101, + SIID_DEVICEAUDIOPLAYER = 102, + SIID_NETWORKCONNECT = 103, + SIID_INTERNET = 104, + SIID_ZIPFILE = 105, + SIID_SETTINGS = 106, + SIID_DRIVEHDDVD = 132, + SIID_DRIVEBD = 133, + SIID_MEDIAHDDVDROM = 134, + SIID_MEDIAHDDVDR = 135, + SIID_MEDIAHDDVDRAM = 136, + SIID_MEDIABDROM = 137, + SIID_MEDIABDR = 138, + SIID_MEDIABDRE = 139, + SIID_CLUSTEREDDRIVE = 140, + SIID_MAX_ICONS = 181, +}} +pub const SIID_INVALID: SHSTOCKICONID = -1i32 as u32; +extern "system" { + pub fn SHGetStockIconInfo( + siid: SHSTOCKICONID, + uFlags: UINT, + psii: *mut SHSTOCKICONINFO, + ) -> HRESULT; + pub fn SHGetDiskFreeSpaceExA( + pszDirectoryName: LPCSTR, + pulFreeBytesAvailableToCaller: *mut ULARGE_INTEGER, + pulTotalNumberOfBytes: *mut ULARGE_INTEGER, + pulTotalNumberOfFreeBytes: *mut ULARGE_INTEGER, + ) -> BOOL; + pub fn SHGetDiskFreeSpaceExW( + pszDirectoryName: LPCWSTR, + pulFreeBytesAvailableToCaller: *mut ULARGE_INTEGER, + pulTotalNumberOfBytes: *mut ULARGE_INTEGER, + pulTotalNumberOfFreeBytes: *mut ULARGE_INTEGER, + ) -> BOOL; + pub fn SHGetNewLinkInfoA( + pszLinkTo: LPCSTR, + pszDir: LPCSTR, + pszName: LPSTR, + pfMustCopy: *mut BOOL, + uFlags: UINT, + ) -> BOOL; + pub fn SHGetNewLinkInfoW( + pszLinkTo: LPCWSTR, + pszDir: LPCWSTR, + pszName: LPWSTR, + pfMustCopy: *mut BOOL, + uFlags: UINT, + ) -> BOOL; +} +pub const SHGNLI_PIDL: DWORD = 0x000000001; +pub const SHGNLI_PREFIXNAME: DWORD = 0x000000002; +pub const SHGNLI_NOUNIQUE: DWORD = 0x000000004; +pub const SHGNLI_NOLNK: DWORD = 0x000000008; +pub const SHGNLI_NOLOCNAME: DWORD = 0x000000010; +pub const SHGNLI_USEURLEXT: DWORD = 0x000000020; +pub const PRINTACTION_OPEN: DWORD = 0; +pub const PRINTACTION_PROPERTIES: DWORD = 1; +pub const PRINTACTION_NETINSTALL: DWORD = 2; +pub const PRINTACTION_NETINSTALLLINK: DWORD = 3; +pub const PRINTACTION_TESTPAGE: DWORD = 4; +pub const PRINTACTION_OPENNETPRN: DWORD = 5; +pub const PRINTACTION_DOCUMENTDEFAULTS: DWORD = 6; +pub const PRINTACTION_SERVERPROPERTIES: DWORD = 7; +extern "system" { + pub fn SHInvokePrinterCommandA( + hwnd: HWND, + uAction: UINT, + lpBuf1: LPCSTR, + lpBuf2: LPCSTR, + fModal: BOOL, + ) -> BOOL; + pub fn SHInvokePrinterCommandW( + hwnd: HWND, + uAction: UINT, + lpBuf1: LPCWSTR, + lpBuf2: LPCWSTR, + fModal: BOOL, + ) -> BOOL; +} +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OPEN_PRINTER_PROPS_INFOA { + dwSize: DWORD, + pszSheetName: LPSTR, + uSheetIndex: UINT, + dwFlags: DWORD, + bModal: BOOL, +}} +pub type POPEN_PRINTER_PROPS_INFOA = *mut OPEN_PRINTER_PROPS_INFOA; +STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OPEN_PRINTER_PROPS_INFOW { + dwSize: DWORD, + pszSheetName: LPWSTR, + uSheetIndex: UINT, + dwFlags: DWORD, + bModal: BOOL, +}} +pub type POPEN_PRINTER_PROPS_INFOW = *mut OPEN_PRINTER_PROPS_INFOW; +pub const PRINT_PROP_FORCE_NAME: DWORD = 0x01; +extern "system" { + pub fn SHLoadNonloadedIconOverlayIdentifiers() -> HRESULT; + pub fn SHIsFileAvailableOffline( + pwszPath: PCWSTR, + pdwStatus: *mut DWORD, + ) -> HRESULT; +} +pub const OFFLINE_STATUS_LOCAL: DWORD = 0x0001; +pub const OFFLINE_STATUS_REMOTE: DWORD = 0x0002; +pub const OFFLINE_STATUS_INCOMPLETE: DWORD = 0x0004; +extern "system" { + pub fn SHSetLocalizedName( + pszPath: PCWSTR, + pszResModule: PCWSTR, + idsRes: c_int, + ) -> HRESULT; + pub fn SHRemoveLocalizedName( + pszPath: PCWSTR, + ) -> HRESULT; + pub fn SHGetLocalizedName( + pszPath: PCWSTR, + pszResModule: PWSTR, + cch: UINT, + pidsRes: *mut c_int, + ) -> HRESULT; +} +extern "C" { + pub fn ShellMessageBoxA( + hAppInst: HINSTANCE, + hWnd: HWND, + lpcText: LPCSTR, + lpcTitle: LPCSTR, + fuStyle: UINT, + ... + ) -> c_int; + pub fn ShellMessageBoxW( + hAppInst: HINSTANCE, + hWnd: HWND, + lpcText: LPCWSTR, + lpcTitle: LPCWSTR, + fuStyle: UINT, + ... + ) -> c_int; +} +extern "system" { + pub fn IsLFNDriveA( + pszPath: LPCSTR, + ) -> BOOL; + pub fn IsLFNDriveW( + pszPath: LPCWSTR, + ) -> BOOL; + pub fn SHEnumerateUnreadMailAccountsA( + hKeyUser: HKEY, + dwIndex: DWORD, + pszMailAddress: LPSTR, + cchMailAddress: c_int, + ) -> HRESULT; + pub fn SHEnumerateUnreadMailAccountsW( + hKeyUser: HKEY, + dwIndex: DWORD, + pszMailAddress: LPWSTR, + cchMailAddress: c_int, + ) -> HRESULT; + pub fn SHGetUnreadMailCountA( + hKeyUser: HKEY, + pszMailAddress: LPCSTR, + pdwCount: *mut DWORD, + pFileTime: *mut FILETIME, + pszShellExecuteCommand: LPSTR, + cchShellExecuteCommand: c_int, + ) -> HRESULT; + pub fn SHGetUnreadMailCountW( + hKeyUser: HKEY, + pszMailAddress: LPCWSTR, + pdwCount: *mut DWORD, + pFileTime: *mut FILETIME, + pszShellExecuteCommand: LPWSTR, + cchShellExecuteCommand: c_int, + ) -> HRESULT; + pub fn SHSetUnreadMailCountA( + pszMailAddress: LPCSTR, + dwCount: DWORD, + pszShellExecuteCommand: LPCSTR, + ) -> HRESULT; + pub fn SHSetUnreadMailCountW( + pszMailAddress: LPCWSTR, + dwCount: DWORD, + pszShellExecuteCommand: LPCWSTR, + ) -> HRESULT; + pub fn SHTestTokenMembership( + hToken: HANDLE, + ulRID: ULONG, + ) -> BOOL; + pub fn SHGetImageList( + iImageList: c_int, + riid: REFIID, + ppvObj: *mut *mut c_void, + ) -> HRESULT; +} +pub const SHIL_LARGE: DWORD = 0; +pub const SHIL_SMALL: DWORD = 1; +pub const SHIL_EXTRALARGE: DWORD = 2; +pub const SHIL_SYSSMALL: DWORD = 3; +pub const SHIL_JUMBO: DWORD = 4; +pub const SHIL_LAST: DWORD = SHIL_JUMBO; +FN!{stdcall PFNCANSHAREFOLDERW( + pszPath: PCWSTR, +) -> HRESULT} +FN!{stdcall PFNSHOWSHAREFOLDERUIW( + hwndParent: HWND, + pszPath: PCWSTR, +) -> HRESULT} +pub const WC_NETADDRESS: &'static str = "msctls_netaddress"; +extern "system" { + pub fn InitNetworkAddressControl() -> BOOL; +} +// STRUCT!{struct NC_ADDRESS { +// pAddrInfo: *mut NET_ADDRESS_INFO, +// PortNumber: USHORT, +// PrefixLength: BYTE, +// }} +// pub type PNC_ADDRESS = *mut NC_ADDRESS; +extern "system" { + pub fn SHGetDriveMedia( + pszDrive: PCWSTR, + pdwMediaContent: *mut DWORD, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/shellscalingapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/shellscalingapi.rs new file mode 100644 index 0000000..4db4ff6 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/shellscalingapi.rs @@ -0,0 +1,44 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::UINT; +use shared::windef::HMONITOR; +use um::winnt::{HANDLE, HRESULT}; +ENUM!{enum PROCESS_DPI_AWARENESS { + PROCESS_DPI_UNAWARE = 0, + PROCESS_SYSTEM_DPI_AWARE = 1, + PROCESS_PER_MONITOR_DPI_AWARE = 2, +}} +ENUM!{enum MONITOR_DPI_TYPE { + MDT_EFFECTIVE_DPI = 0, + MDT_ANGULAR_DPI = 1, + MDT_RAW_DPI = 2, + MDT_DEFAULT = MDT_EFFECTIVE_DPI, +}} +extern "system" { + pub fn SetProcessDpiAwareness( + value: PROCESS_DPI_AWARENESS, + ) -> HRESULT; + pub fn GetProcessDpiAwareness( + hProcess: HANDLE, + value: *mut PROCESS_DPI_AWARENESS, + ) -> HRESULT; + pub fn GetDpiForMonitor( + hmonitor: HMONITOR, + dpiType: MONITOR_DPI_TYPE, + dpiX: *mut UINT, + dpiY: *mut UINT, + ) -> HRESULT; +} +ENUM!{enum SHELL_UI_COMPONENT { + SHELL_UI_COMPONENT_TASKBARS = 0, + SHELL_UI_COMPONENT_NOTIFICATIONAREA = 1, + SHELL_UI_COMPONENT_DESKBAND = 2, +}} +extern "system" { + pub fn GetDpiForShellUIComponent( + component: SHELL_UI_COMPONENT, + ) -> UINT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/shlobj.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/shlobj.rs new file mode 100644 index 0000000..f652c6c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/shlobj.rs @@ -0,0 +1,260 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_int, c_void}; +use shared::guiddef::REFIID; +use shared::minwindef::{BOOL, DWORD, UINT}; +use shared::windef::HWND; +use um::minwinbase::SECURITY_ATTRIBUTES; +use um::shtypes::{PCIDLIST_ABSOLUTE, PCUITEMID_CHILD_ARRAY, PIDLIST_ABSOLUTE, REFKNOWNFOLDERID}; +use um::winnt::{HANDLE, HRESULT, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PCWSTR, PWSTR}; +pub const IDO_SHGIOI_SHARE: c_int = 0x0FFFFFFF; +pub const IDO_SHGIOI_LINK: c_int = 0x0FFFFFFE; +// Yes, these values are supposed to be 9 digits +pub const IDO_SHGIOI_SLOWFILE: c_int = 0x0FFFFFFFD; +pub const IDO_SHGIOI_DEFAULT: c_int = 0x0FFFFFFFC; +extern "system" { + pub fn SHGetIconOverlayIndexA( + pszIconPath: LPCSTR, + iIconIndex: c_int, + ) -> c_int; + pub fn SHGetIconOverlayIndexW( + pszIconPath: LPCWSTR, + iIconIndex: c_int, + ) -> c_int; +} +pub const GPFIDL_DEFAULT: GPFIDL_FLAGS = 0x0000; +pub const GPFIDL_ALTNAME: GPFIDL_FLAGS = 0x0001; +pub const GPFIDL_UNCPRINTER: GPFIDL_FLAGS = 0x0002; +pub type GPFIDL_FLAGS = c_int; +extern "system" { + pub fn SHGetPathFromIDListEx( + pidl: PCIDLIST_ABSOLUTE, + pszPath: PWSTR, + cchPath: DWORD, + uOpts: GPFIDL_FLAGS, + ) -> BOOL; + pub fn SHGetPathFromIDListA( + pidl: PCIDLIST_ABSOLUTE, + pszPath: LPSTR, + ) -> BOOL; + pub fn SHGetPathFromIDListW( + pidl: PCIDLIST_ABSOLUTE, + pszPath: LPWSTR, + ) -> BOOL; + pub fn SHCreateDirectory( + hwnd: HWND, + pszPath: PCWSTR, + ) -> c_int; + pub fn SHCreateDirectoryExA( + hwnd: HWND, + pszPath: LPCSTR, + psa: *const SECURITY_ATTRIBUTES, + ) -> c_int; + pub fn SHCreateDirectoryExW( + hwnd: HWND, + pszPath: LPCWSTR, + psa: *const SECURITY_ATTRIBUTES, + ) -> c_int; +} +pub const OFASI_EDIT: DWORD = 0x0001; +pub const OFASI_OPENDESKTOP: DWORD = 0x0002; +extern "system" { + pub fn SHOpenFolderAndSelectItems( + pidlFolder: PCIDLIST_ABSOLUTE, + cidl: UINT, + apidl: PCUITEMID_CHILD_ARRAY, + dwFlags: DWORD, + ) -> HRESULT; + //pub fn SHCreateShellItem( + // pidlParent: PCIDLIST_ABSOLUTE, + // psfParent: *mut IShellFolder, + // pidl: PCUITEMID_CHILD, + // ppsi: *mut *mut IShellItem, + //) -> HRESULT; +} +pub const CSIDL_DESKTOP: c_int = 0x0000; +pub const CSIDL_INTERNET: c_int = 0x0001; +pub const CSIDL_PROGRAMS: c_int = 0x0002; +pub const CSIDL_CONTROLS: c_int = 0x0003; +pub const CSIDL_PRINTERS: c_int = 0x0004; +pub const CSIDL_PERSONAL: c_int = 0x0005; +pub const CSIDL_FAVORITES: c_int = 0x0006; +pub const CSIDL_STARTUP: c_int = 0x0007; +pub const CSIDL_RECENT: c_int = 0x0008; +pub const CSIDL_SENDTO: c_int = 0x0009; +pub const CSIDL_BITBUCKET: c_int = 0x000a; +pub const CSIDL_STARTMENU: c_int = 0x000b; +pub const CSIDL_MYDOCUMENTS: c_int = CSIDL_PERSONAL; +pub const CSIDL_MYMUSIC: c_int = 0x000d; +pub const CSIDL_MYVIDEO: c_int = 0x000e; +pub const CSIDL_DESKTOPDIRECTORY: c_int = 0x0010; +pub const CSIDL_DRIVES: c_int = 0x0011; +pub const CSIDL_NETWORK: c_int = 0x0012; +pub const CSIDL_NETHOOD: c_int = 0x0013; +pub const CSIDL_FONTS: c_int = 0x0014; +pub const CSIDL_TEMPLATES: c_int = 0x0015; +pub const CSIDL_COMMON_STARTMENU: c_int = 0x0016; +pub const CSIDL_COMMON_PROGRAMS: c_int = 0x0017; +pub const CSIDL_COMMON_STARTUP: c_int = 0x0018; +pub const CSIDL_COMMON_DESKTOPDIRECTORY: c_int = 0x0019; +pub const CSIDL_APPDATA: c_int = 0x001a; +pub const CSIDL_PRINTHOOD: c_int = 0x001b; +pub const CSIDL_LOCAL_APPDATA: c_int = 0x001c; +pub const CSIDL_ALTSTARTUP: c_int = 0x001d; +pub const CSIDL_COMMON_ALTSTARTUP: c_int = 0x001e; +pub const CSIDL_COMMON_FAVORITES: c_int = 0x001f; +pub const CSIDL_INTERNET_CACHE: c_int = 0x0020; +pub const CSIDL_COOKIES: c_int = 0x0021; +pub const CSIDL_HISTORY: c_int = 0x0022; +pub const CSIDL_COMMON_APPDATA: c_int = 0x0023; +pub const CSIDL_WINDOWS: c_int = 0x0024; +pub const CSIDL_SYSTEM: c_int = 0x0025; +pub const CSIDL_PROGRAM_FILES: c_int = 0x0026; +pub const CSIDL_MYPICTURES: c_int = 0x0027; +pub const CSIDL_PROFILE: c_int = 0x0028; +pub const CSIDL_SYSTEMX86: c_int = 0x0029; +pub const CSIDL_PROGRAM_FILESX86: c_int = 0x002a; +pub const CSIDL_PROGRAM_FILES_COMMON: c_int = 0x002b; +pub const CSIDL_PROGRAM_FILES_COMMONX86: c_int = 0x002c; +pub const CSIDL_COMMON_TEMPLATES: c_int = 0x002d; +pub const CSIDL_COMMON_DOCUMENTS: c_int = 0x002e; +pub const CSIDL_COMMON_ADMINTOOLS: c_int = 0x002f; +pub const CSIDL_ADMINTOOLS: c_int = 0x0030; +pub const CSIDL_CONNECTIONS: c_int = 0x0031; +pub const CSIDL_COMMON_MUSIC: c_int = 0x0035; +pub const CSIDL_COMMON_PICTURES: c_int = 0x0036; +pub const CSIDL_COMMON_VIDEO: c_int = 0x0037; +pub const CSIDL_RESOURCES: c_int = 0x0038; +pub const CSIDL_RESOURCES_LOCALIZED: c_int = 0x0039; +pub const CSIDL_COMMON_OEM_LINKS: c_int = 0x003a; +pub const CSIDL_CDBURN_AREA: c_int = 0x003b; +pub const CSIDL_COMPUTERSNEARME: c_int = 0x003d; +pub const CSIDL_FLAG_CREATE: c_int = 0x8000; +pub const CSIDL_FLAG_DONT_VERIFY: c_int = 0x4000; +pub const CSIDL_FLAG_DONT_UNEXPAND: c_int = 0x2000; +pub const CSIDL_FLAG_NO_ALIAS: c_int = 0x1000; +pub const CSIDL_FLAG_PER_USER_INIT: c_int = 0x0800; +pub const CSIDL_FLAG_MASK: c_int = 0xff00; +extern "system" { + pub fn SHGetSpecialFolderLocation( + hwnd: HWND, + csidl: c_int, + ppidl: *mut PIDLIST_ABSOLUTE, + ) -> HRESULT; + pub fn SHCloneSpecialIDList( + hwnd: HWND, + csidl: c_int, + fCreate: BOOL, + ) -> PIDLIST_ABSOLUTE; + pub fn SHGetSpecialFolderPathA( + hwnd: HWND, + pszPath: LPSTR, + csidl: c_int, + fCreate: BOOL, + ) -> BOOL; + pub fn SHGetSpecialFolderPathW( + hwnd: HWND, + pszPath: LPWSTR, + csidl: c_int, + fCreate: BOOL, + ) -> BOOL; + pub fn SHFlushSFCache(); +} +ENUM!{enum SHGFP_TYPE { + SHGFP_TYPE_CURRENT = 0, + SHGFP_TYPE_DEFAULT = 1, +}} +extern "system" { + pub fn SHGetFolderPathA( + hwnd: HWND, + csidl: c_int, + hToken: HANDLE, + dwFlags: DWORD, + pszPath: LPSTR, + ) -> HRESULT; + pub fn SHGetFolderPathW( + hwnd: HWND, + csidl: c_int, + hToken: HANDLE, + dwFlags: DWORD, + pszPath: LPWSTR, + ) -> HRESULT; + pub fn SHGetFolderLocation( + hwnd: HWND, + csidl: c_int, + hToken: HANDLE, + dwFlags: DWORD, + ppidl: *mut PIDLIST_ABSOLUTE, + ) -> HRESULT; + pub fn SHSetFolderPathA( + csidl: c_int, + hToken: HANDLE, + dwFlags: DWORD, + pszPath: LPCSTR, + ) -> HRESULT; + pub fn SHSetFolderPathW( + csidl: c_int, + hToken: HANDLE, + dwFlags: DWORD, + pszPath: LPCWSTR, + ) -> HRESULT; + pub fn SHGetFolderPathAndSubDirA( + hwnd: HWND, + csidl: c_int, + hToken: HANDLE, + dwFlags: DWORD, + pszSubDir: LPCSTR, + pszPath: LPSTR, + ) -> HRESULT; + pub fn SHGetFolderPathAndSubDirW( + hwnd: HWND, + csidl: c_int, + hToken: HANDLE, + dwFlags: DWORD, + pszSubDir: LPCWSTR, + pszPath: LPWSTR, + ) -> HRESULT; +} +ENUM!{enum KNOWN_FOLDER_FLAG { + KF_FLAG_DEFAULT = 0x00000000, + KF_FLAG_NO_APPCONTAINER_REDIRECTION = 0x00010000, + KF_FLAG_CREATE = 0x00008000, + KF_FLAG_DONT_VERIFY = 0x00004000, + KF_FLAG_DONT_UNEXPAND = 0x00002000, + KF_FLAG_NO_ALIAS = 0x00001000, + KF_FLAG_INIT = 0x00000800, + KF_FLAG_DEFAULT_PATH = 0x00000400, + KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200, + KF_FLAG_SIMPLE_IDLIST = 0x00000100, + KF_FLAG_ALIAS_ONLY = 0x80000000, +}} +extern "system" { + pub fn SHGetKnownFolderIDList( + rfid: REFKNOWNFOLDERID, + dwFlags: DWORD, + hToken: HANDLE, + ppidl: *mut PIDLIST_ABSOLUTE, + ) -> HRESULT; + pub fn SHSetKnownFolderPath( + rfid: REFKNOWNFOLDERID, + dwFlags: DWORD, + hToken: HANDLE, + pszPath: PCWSTR, + ) -> HRESULT; + pub fn SHGetKnownFolderPath( + rfid: REFKNOWNFOLDERID, + dwFlags: DWORD, + hToken: HANDLE, + pszPath: *mut PWSTR, + ) -> HRESULT; + pub fn SHGetKnownFolderItem( + rfid: REFKNOWNFOLDERID, + flags: KNOWN_FOLDER_FLAG, + hToken: HANDLE, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/shobjidl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/shobjidl.rs new file mode 100644 index 0000000..7db4412 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/shobjidl.rs @@ -0,0 +1,373 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_void; +use shared::guiddef::{REFGUID, REFIID}; +use shared::minwindef::{BOOL, DWORD, UINT}; +use shared::windef::HWND; +use um::objidl::IBindCtx; +use um::propkeydef::REFPROPERTYKEY; +use um::propsys::{GETPROPERTYSTOREFLAGS, IPropertyDescriptionList, IPropertyStore}; +use um::shobjidl_core::{IModalWindow, IModalWindowVtbl, IShellItem, IShellItemFilter, SFGAOF}; +use um::shtypes::COMDLG_FILTERSPEC; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCWSTR, LPWSTR, WCHAR}; +pub type IFileOperationProgressSink = IUnknown; // TODO +ENUM!{enum SIATTRIBFLAGS { + SIATTRIBFLAGS_AND = 0x1, + SIATTRIBFLAGS_OR = 0x2, + SIATTRIBFLAGS_APPCOMPAT = 0x3, + SIATTRIBFLAGS_MASK = 0x3, + SIATTRIBFLAGS_ALLITEMS = 0x4000, +}} +RIDL!{#[uuid(0xb63ea76d, 0x1f85, 0x456f, 0xa1, 0x9c, 0x48, 0x15, 0x9e, 0xfa, 0x85, 0x8b)] +interface IShellItemArray(IShellItemArrayVtbl): IUnknown(IUnknownVtbl) { + fn BindToHandler( + pbc: *mut IBindCtx, + bhid: REFGUID, + riid: REFIID, + ppvOut: *mut *mut c_void, + ) -> HRESULT, + fn GetPropertyStore( + flags: GETPROPERTYSTOREFLAGS, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, + fn GetPropertyDescriptionList( + keyType: REFPROPERTYKEY, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, + fn GetAttributes( + AttribFlags: SIATTRIBFLAGS, + sfgaoMask: SFGAOF, + psfgaoAttribs: *mut SFGAOF, + ) -> HRESULT, + fn GetCount( + pdwNumItems: *mut DWORD, + ) -> HRESULT, + fn GetItemAt( + dwIndex: DWORD, + ppsi: *mut *mut IShellItem, + ) -> HRESULT, + // TODO: Add IEnumShellItems + //fn EnumItems( + // ppenumShellItems: *mut *mut IEnumShellItems, + //) -> HRESULT, +}} +ENUM!{enum FDE_OVERWRITE_RESPONSE { + FDEOR_DEFAULT = 0, + FDEOR_ACCEPT = 1, + FDEOR_REFUSE = 2, +}} +ENUM!{enum FDE_SHAREVIOLATION_RESPONSE { + FDESVR_DEFAULT = 0, + FDESVR_ACCEPT = 1, + FDESVR_REFUSE = 2, +}} +ENUM!{enum FDAP { + FDAP_BOTTOM = 0, + FDAP_TOP = 1, +}} +RIDL!{#[uuid(0x973510db, 0x7d7f, 0x452b, 0x89, 0x75, 0x74, 0xa8, 0x58, 0x28, 0xd3, 0x54)] +interface IFileDialogEvents(IFileDialogEventsVtbl): IUnknown(IUnknownVtbl) { + fn OnFileOk( + pfd: *mut IFileDialog, + ) -> HRESULT, + fn OnFolderChanging( + pfd: *mut IFileDialog, + psiFolder: *mut IShellItem, + ) -> HRESULT, + fn OnFolderChange( + pfd: *mut IFileDialog, + ) -> HRESULT, + fn OnSelectionChange( + pfd: *mut IFileDialog, + ) -> HRESULT, + fn OnShareViolation( + pfd: *mut IFileDialog, + psi: *mut IShellItem, + pResponse: *mut FDE_SHAREVIOLATION_RESPONSE, + ) -> HRESULT, + fn OnTypeChange( + pfd: *mut IFileDialog, + ) -> HRESULT, + fn OnOverwrite( + pfd: *mut IFileDialog, + psi: *mut IShellItem, + pResponse: *mut FDE_OVERWRITE_RESPONSE, + ) -> HRESULT, +}} +ENUM!{enum FILEOPENDIALOGOPTIONS { + FOS_OVERWRITEPROMPT = 0x2, + FOS_STRICTFILETYPES = 0x4, + FOS_NOCHANGEDIR = 0x8, + FOS_PICKFOLDERS = 0x20, + FOS_FORCEFILESYSTEM = 0x40, + FOS_ALLNONSTORAGEITEMS = 0x80, + FOS_NOVALIDATE = 0x100, + FOS_ALLOWMULTISELECT = 0x200, + FOS_PATHMUSTEXIST = 0x800, + FOS_FILEMUSTEXIST = 0x1000, + FOS_CREATEPROMPT = 0x2000, + FOS_SHAREAWARE = 0x4000, + FOS_NOREADONLYRETURN = 0x8000, + FOS_NOTESTFILECREATE = 0x10000, + FOS_HIDEMRUPLACES = 0x20000, + FOS_HIDEPINNEDPLACES = 0x40000, + FOS_NODEREFERENCELINKS = 0x100000, + FOS_DONTADDTORECENT = 0x2000000, + FOS_FORCESHOWHIDDEN = 0x10000000, + FOS_DEFAULTNOMINIMODE = 0x20000000, + FOS_FORCEPREVIEWPANEON = 0x40000000, + FOS_SUPPORTSTREAMABLEITEMS = 0x80000000, +}} +RIDL!{#[uuid(0x42f85136, 0xdb7e, 0x439c, 0x85, 0xf1, 0xe4, 0x07, 0x5d, 0x13, 0x5f, 0xc8)] +interface IFileDialog(IFileDialogVtbl): IModalWindow(IModalWindowVtbl) { + fn SetFileTypes( + cFileTypes: UINT, + rgFilterSpec: *const COMDLG_FILTERSPEC, + ) -> HRESULT, + fn SetFileTypeIndex( + iFileType: UINT, + ) -> HRESULT, + fn GetFileTypeIndex( + piFileType: *mut UINT, + ) -> HRESULT, + fn Advise( + pfde: *mut IFileDialogEvents, + pdwCookie: *mut DWORD, + ) -> HRESULT, + fn Unadvise( + dwCookie: DWORD, + ) -> HRESULT, + fn SetOptions( + fos: FILEOPENDIALOGOPTIONS, + ) -> HRESULT, + fn GetOptions( + pfos: *mut FILEOPENDIALOGOPTIONS, + ) -> HRESULT, + fn SetDefaultFolder( + psi: *mut IShellItem, + ) -> HRESULT, + fn SetFolder( + psi: *mut IShellItem, + ) -> HRESULT, + fn GetFolder( + ppsi: *mut *mut IShellItem, + ) -> HRESULT, + fn GetCurrentSelection( + ppsi: *mut *mut IShellItem, + ) -> HRESULT, + fn SetFileName( + pszName: LPCWSTR, + ) -> HRESULT, + fn GetFileName( + pszName: *mut LPWSTR, + ) -> HRESULT, + fn SetTitle( + pszTitle: LPCWSTR, + ) -> HRESULT, + fn SetOkButtonLabel( + pszText: LPCWSTR, + ) -> HRESULT, + fn SetFileNameLabel( + pszLabel: LPCWSTR, + ) -> HRESULT, + fn GetResult( + ppsi: *mut *mut IShellItem, + ) -> HRESULT, + fn AddPlace( + psi: *mut IShellItem, + fdap: FDAP, + ) -> HRESULT, + fn SetDefaultExtension( + pszDefaultExtension: LPCWSTR, + ) -> HRESULT, + fn Close( + hr: HRESULT, + ) -> HRESULT, + fn SetClientGuid( + guid: REFGUID, + ) -> HRESULT, + fn ClearClientData() -> HRESULT, + fn SetFilter( + pFilter: *mut IShellItemFilter, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x84bccd23, 0x5fde, 0x4cdb, 0xae, 0xa4, 0xaf, 0x64, 0xb8, 0x3d, 0x78, 0xab)] +interface IFileSaveDialog(IFileSaveDialogVtbl): IFileDialog(IFileDialogVtbl) { + fn SetSaveAsItem( + psi: *mut IShellItem, + ) -> HRESULT, + fn SetProperties( + pStore: *mut IPropertyStore, + ) -> HRESULT, + fn SetCollectedProperties( + pList: *mut IPropertyDescriptionList, + fAppendDefault: BOOL, + ) -> HRESULT, + fn GetProperties( + ppStore: *mut *mut IPropertyStore, + ) -> HRESULT, + fn ApplyProperties( + psi: *mut IShellItem, + pStore: *mut IPropertyStore, + hwnd: HWND, + pSink: *mut IFileOperationProgressSink, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd57c7288, 0xd4ad, 0x4768, 0xbe, 0x02, 0x9d, 0x96, 0x95, 0x32, 0xd9, 0x60)] +interface IFileOpenDialog(IFileOpenDialogVtbl): IFileDialog(IFileDialogVtbl) { + fn GetResults( + ppenum: *mut *mut IShellItemArray, + ) -> HRESULT, + fn GetSelectedItems( + ppsai: *mut *mut IShellItemArray, + ) -> HRESULT, +}} +ENUM!{enum CDCONTROLSTATEF { + CDCS_INACTIVE = 0, + CDCS_ENABLED = 0x1, + CDCS_VISIBLE = 0x2, + CDCS_ENABLEDVISIBLE = 0x3, +}} +RIDL!{#[uuid(0xe6fdd21a, 0x163f, 0x4975, 0x9c, 0x8c, 0xa6, 0x9f, 0x1b, 0xa3, 0x70, 0x34)] +interface IFileDialogCustomize(IFileDialogCustomizeVtbl): IUnknown(IUnknownVtbl) { + fn EnableOpenDropDown( + dwIDCtl: DWORD, + ) -> HRESULT, + fn AddMenu( + dwIDCtl: DWORD, + pszLabel: LPCWSTR, + ) -> HRESULT, + fn AddPushButton( + dwIDCtl: DWORD, + pszLabel: LPCWSTR, + ) -> HRESULT, + fn AddComboBox( + dwIDCtl: DWORD, + ) -> HRESULT, + fn AddRadioButtonList( + dwIDCtl: DWORD, + ) -> HRESULT, + fn AddCheckButton( + dwIDCtl: DWORD, + pszLabel: LPCWSTR, + bChecked: BOOL, + ) -> HRESULT, + fn AddEditBox( + dwIDCtl: DWORD, + pszText: LPCWSTR, + ) -> HRESULT, + fn AddSeparator( + dwIDCtl: DWORD, + ) -> HRESULT, + fn AddText( + dwIDCtl: DWORD, + pszText: LPCWSTR, + ) -> HRESULT, + fn SetControlLabel( + dwIDCtl: DWORD, + pszLabel: LPCWSTR, + ) -> HRESULT, + fn GetControlState( + dwIDCtl: DWORD, + pdwState: *mut CDCONTROLSTATEF, + ) -> HRESULT, + fn SetControlState( + dwIDCtl: DWORD, + dwState: CDCONTROLSTATEF, + ) -> HRESULT, + fn GetEditBoxText( + dwIDCtl: DWORD, + ppszText: *mut *mut WCHAR, + ) -> HRESULT, + fn SetEditBoxText( + dwIDCtl: DWORD, + pszText: LPCWSTR, + ) -> HRESULT, + fn GetCheckButtonState( + dwIDCtl: DWORD, + pbChecked: *mut BOOL, + ) -> HRESULT, + fn SetCheckButtonState( + dwIDCtl: DWORD, + bChecked: BOOL, + ) -> HRESULT, + fn AddControlItem( + dwIDCtl: DWORD, + dwIDItem: DWORD, + pszLabel: LPCWSTR, + ) -> HRESULT, + fn RemoveControlItem( + dwIDCtl: DWORD, + dwIDItem: DWORD, + ) -> HRESULT, + fn RemoveAllControlItems( + dwIDCtl: DWORD, + ) -> HRESULT, + fn GetControlItemState( + dwIDCtl: DWORD, + dwIDItem: DWORD, + pdwState: *mut CDCONTROLSTATEF, + ) -> HRESULT, + fn SetControlItemState( + dwIDCtl: DWORD, + dwIDItem: DWORD, + dwState: CDCONTROLSTATEF, + ) -> HRESULT, + fn GetSelectedControlItem( + dwIDCtl: DWORD, + pdwIDItem: *mut DWORD, + ) -> HRESULT, + fn SetSelectedControlItem( + dwIDCtl: DWORD, + dwIDItem: DWORD, + ) -> HRESULT, + fn StartVisualGroup( + dwIDCtl: DWORD, + pszLabel: LPCWSTR, + ) -> HRESULT, + fn EndVisualGroup() -> HRESULT, + fn MakeProminent( + dwIDCtl: DWORD, + ) -> HRESULT, + fn SetControlItemText( + dwIDCtl: DWORD, + dwIDItem: DWORD, + pszLabel: LPCWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x36116642, 0xd713, 0x4b97, 0x9b, 0x83, 0x74, 0x84, 0xa9, 0xd0, 0x04, 0x33)] +interface IFileDialogControlEvents(IFileDialogControlEventsVtbl): IUnknown(IUnknownVtbl) { + fn OnItemSelected( + pfdc: *mut IFileDialogCustomize, + dwIDCtl: DWORD, + dwIDItem: DWORD, + ) -> HRESULT, + fn OnButtonClicked( + pfdc: *mut IFileDialogCustomize, + dwIDCtl: DWORD, + ) -> HRESULT, + fn OnCheckButtonToggled( + pfdc: *mut IFileDialogCustomize, + dwIDCtl: DWORD, + bChecked: BOOL, + ) -> HRESULT, + fn OnControlActivating( + pfdc: *mut IFileDialogCustomize, + dwIDCtl: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x61744fc7, 0x85b5, 0x4791, 0xa9, 0xb0, 0x27, 0x22, 0x76, 0x30, 0x9b, 0x13)] +interface IFileDialog2(IFileDialog2Vtbl): IFileDialog(IFileDialogVtbl) { + fn SetCancelButtonLabel( + pszLabel: LPCWSTR, + ) -> HRESULT, + fn SetNavigationRoot( + psi: IShellItem, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/shobjidl_core.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/shobjidl_core.rs new file mode 100644 index 0000000..ef17f22 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/shobjidl_core.rs @@ -0,0 +1,306 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_int, c_void}; +use shared::guiddef::{REFGUID, REFIID}; +use shared::minwindef::{BOOL, DWORD, UINT, ULONG, WORD}; +use shared::windef::{HICON, HWND, RECT}; +use um::commctrl::HIMAGELIST; +use um::objidl::IBindCtx; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCWSTR, LPWSTR, ULONGLONG, WCHAR}; +DEFINE_GUID!{CLSID_TaskbarList, + 0x56fdf344, 0xfd6d, 0x11d0, 0x95, 0x8a, 0x00, 0x60, 0x97, 0xc9, 0xa0, 0x90} +DEFINE_GUID!{CLSID_FileOpenDialog, + 0xdc1c5a9c, 0xe88a, 0x4dde, 0xa5, 0xa1, 0x60, 0xf8, 0x2a, 0x20, 0xae, 0xf7} +DEFINE_GUID!{CLSID_FileSaveDialog, + 0xc0b4e2f3, 0xba21, 0x4773, 0x8d, 0xba, 0x33, 0x5e, 0xc9, 0x46, 0xeb, 0x8b} +//4498 +ENUM!{enum SHCONTF { + SHCONTF_CHECKING_FOR_CHILDREN = 0x10, + SHCONTF_FOLDERS = 0x20, + SHCONTF_NONFOLDERS = 0x40, + SHCONTF_INCLUDEHIDDEN = 0x80, + SHCONTF_INIT_ON_FIRST_NEXT = 0x100, + SHCONTF_NETPRINTERSRCH = 0x200, + SHCONTF_SHAREABLE = 0x400, + SHCONTF_STORAGE = 0x800, + SHCONTF_NAVIGATION_ENUM = 0x1000, + SHCONTF_FASTITEMS = 0x2000, + SHCONTF_FLATLIST = 0x4000, + SHCONTF_ENABLE_ASYNC = 0x8000, + SHCONTF_INCLUDESUPERHIDDEN = 0x10000, +}} +pub type SFGAOF = ULONG; +//9466 +ENUM!{enum SIGDN { + SIGDN_NORMALDISPLAY = 0, + SIGDN_PARENTRELATIVEPARSING = 0x80018001, + SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000, + SIGDN_PARENTRELATIVEEDITING = 0x80031001, + SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000, + SIGDN_FILESYSPATH = 0x80058000, + SIGDN_URL = 0x80068000, + SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8007c001, + SIGDN_PARENTRELATIVE = 0x80080001, + SIGDN_PARENTRELATIVEFORUI = 0x80094001, +}} +ENUM!{enum SICHINTF { + SICHINT_DISPLAY = 0, + SICHINT_ALLFIELDS = 0x80000000, + SICHINT_CANONICAL = 0x10000000, + SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL = 0x20000000, +}} +RIDL!{#[uuid(0x43826d1e, 0xe718, 0x42ee, 0xbc, 0x55, 0xa1, 0xe2, 0x61, 0xc3, 0x7b, 0xfe)] +interface IShellItem(IShellItemVtbl): IUnknown(IUnknownVtbl) { + fn BindToHandler( + pbc: *mut IBindCtx, + bhid: REFGUID, + riid: REFIID, + ppv: *mut *mut c_void, + ) -> HRESULT, + fn GetParent( + ppsi: *mut *mut IShellItem, + ) -> HRESULT, + fn GetDisplayName( + sigdnName: SIGDN, + ppszName: *mut LPWSTR, + ) -> HRESULT, + fn GetAttributes( + sfgaoMask: SFGAOF, + psfgaoAttribs: *mut SFGAOF, + ) -> HRESULT, + fn Compare( + psi: *mut IShellItem, + hint: SICHINTF, + piOrder: *mut c_int, + ) -> HRESULT, +}} +//20869 +RIDL!{#[uuid(0xb4db1657, 0x70d7, 0x485e, 0x8e, 0x3e, 0x6f, 0xcb, 0x5a, 0x5c, 0x18, 0x02)] +interface IModalWindow(IModalWindowVtbl): IUnknown(IUnknownVtbl) { + fn Show( + hwndOwner: HWND, + ) -> HRESULT, +}} +//22307 +//27457 +RIDL!{#[uuid(0x2659b475, 0xeeb8, 0x48b7, 0x8f, 0x07, 0xb3, 0x78, 0x81, 0x0f, 0x48, 0xcf)] +interface IShellItemFilter(IShellItemFilterVtbl): IUnknown(IUnknownVtbl) { + fn IncludeItem( + psi: *mut IShellItem, + ) -> HRESULT, + fn GetEnumFlagsForItem( + psi: *mut IShellItem, + pgrfFlags: *mut SHCONTF, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x56fdf342, 0xfd6d, 0x11d0, 0x95, 0x8a, 0x00, 0x60, 0x97, 0xc9, 0xa0, 0x90)] +interface ITaskbarList(ITaskbarListVtbl): IUnknown(IUnknownVtbl) { + fn HrInit() -> HRESULT, + fn AddTab( + hwnd: HWND, + ) -> HRESULT, + fn DeleteTab( + hwnd: HWND, + ) -> HRESULT, + fn ActivateTab( + hwnd: HWND, + ) -> HRESULT, + fn SetActiveAlt( + hwnd: HWND, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x602d4995, 0xb13a, 0x429b, 0xa6, 0x6e, 0x19, 0x35, 0xe4, 0x4f, 0x43, 0x17)] +interface ITaskbarList2(ITaskbarList2Vtbl): ITaskbarList(ITaskbarListVtbl) { + fn MarkFullscreenWindow( + hwnd: HWND, + fFullscreen: BOOL, + ) -> HRESULT, +}} +ENUM!{enum THUMBBUTTONFLAGS { + THBF_ENABLED = 0, + THBF_DISABLED = 0x1, + THBF_DISMISSONCLICK = 0x2, + THBF_NOBACKGROUND = 0x4, + THBF_HIDDEN = 0x8, + THBF_NONINTERACTIVE = 0x10, +}} +ENUM!{enum THUMBBUTTONMASK { + THB_BITMAP = 0x1, + THB_ICON = 0x2, + THB_TOOLTIP = 0x4, + THB_FLAGS = 0x8, +}} +STRUCT!{struct THUMBBUTTON { + dwMask: THUMBBUTTONMASK, + iId: UINT, + iBitmap: UINT, + hIcon: HICON, + szTip: [WCHAR; 260], + dwFlags: THUMBBUTTONFLAGS, +}} +pub type LPTHUMBBUTTON = *mut THUMBBUTTON; +pub const THBN_CLICKED: WORD = 0x1800; +ENUM!{enum TBPFLAG { + TBPF_NOPROGRESS = 0, + TBPF_INDETERMINATE = 0x1, + TBPF_NORMAL = 0x2, + TBPF_ERROR = 0x4, + TBPF_PAUSED = 0x8, +}} +RIDL!{#[uuid(0xea1afb91, 0x9e28, 0x4b86, 0x90, 0xe9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf)] +interface ITaskbarList3(ITaskbarList3Vtbl): ITaskbarList2(ITaskbarList2Vtbl) { + fn SetProgressValue( + hwnd: HWND, + ullCompleted: ULONGLONG, + ullTotal: ULONGLONG, + ) -> HRESULT, + fn SetProgressState( + hwnd: HWND, + tbpFlags: TBPFLAG, + ) -> HRESULT, + fn RegisterTab( + hwndTab: HWND, + hwndMDI: HWND, + ) -> HRESULT, + fn UnregisterTab( + hwndTab: HWND, + ) -> HRESULT, + fn SetTabOrder( + hwndTab: HWND, + hwndInsertBefore: HWND, + ) -> HRESULT, + fn SetTabActive( + hwndTab: HWND, + hwndMDI: HWND, + dwReserved: DWORD, + ) -> HRESULT, + fn ThumbBarAddButtons( + hwnd: HWND, + cButtons: UINT, + pButton: LPTHUMBBUTTON, + ) -> HRESULT, + fn ThumbBarUpdateButtons( + hwnd: HWND, + cButtons: UINT, + pButton: LPTHUMBBUTTON, + ) -> HRESULT, + fn ThumbBarSetImageList( + hwnd: HWND, + himl: HIMAGELIST, + ) -> HRESULT, + fn SetOverlayIcon( + hwnd: HWND, + hIcon: HICON, + pszDescription: LPCWSTR, + ) -> HRESULT, + fn SetThumbnailTooltip( + hwnd: HWND, + pszTip: LPCWSTR, + ) -> HRESULT, + fn SetThumbnailClip( + hwnd: HWND, + prcClip: *mut RECT, + ) -> HRESULT, +}} +ENUM!{enum STPFLAG { + STPF_NONE = 0, + STPF_USEAPPTHUMBNAILALWAYS = 0x1, + STPF_USEAPPTHUMBNAILWHENACTIVE = 0x2, + STPF_USEAPPPEEKALWAYS = 0x4, + STPF_USEAPPPEEKWHENACTIVE = 0x8, +}} +RIDL!{#[uuid(0xc43dc798, 0x95d1, 0x4bea, 0x90, 0x30, 0xbb, 0x99, 0xe2, 0x98, 0x3a, 0x1a)] +interface ITaskbarList4(ITaskbarList4Vtbl): ITaskbarList3(ITaskbarList3Vtbl) { + fn SetTabProperties( + hwndTab: HWND, + stpFlags: STPFLAG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc2cf3110, 0x460e, 0x4fc1, 0xb9, 0xd0, 0x8a, 0x1c, 0x0c, 0x9c, 0xc4, 0xbd)] +class DesktopWallpaper;} +RIDL!{#[uuid(0x00021400, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +class ShellDesktop;} +RIDL!{#[uuid(0xf3364ba0, 0x65b9, 0x11ce, 0xa9, 0xba, 0x00, 0xaa, 0x00, 0x4a, 0xe8, 0x37)] +class ShellFSFolder;} +RIDL!{#[uuid(0x208d2c60, 0x3aea, 0x1069, 0xa2, 0xd7, 0x08, 0x00, 0x2b, 0x30, 0x30, 0x9d)] +class NetworkPlaces;} +RIDL!{#[uuid(0x00021401, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +class ShellLink;} +RIDL!{#[uuid(0x94357b53, 0xca29, 0x4b78, 0x83, 0xae, 0xe8, 0xfe, 0x74, 0x09, 0x13, 0x4f)] +class DriveSizeCategorizer;} +RIDL!{#[uuid(0xb0a8f3cf, 0x4333, 0x4bab, 0x88, 0x73, 0x1c, 0xcb, 0x1c, 0xad, 0xa4, 0x8b)] +class DriveTypeCategorizer;} +RIDL!{#[uuid(0xb5607793, 0x24ac, 0x44c7, 0x82, 0xe2, 0x83, 0x17, 0x26, 0xaa, 0x6c, 0xb7)] +class FreeSpaceCategorizer;} +RIDL!{#[uuid(0x55d7b852, 0xf6d1, 0x42f2, 0xaa, 0x75, 0x87, 0x28, 0xa1, 0xb2, 0xd2, 0x64)] +class SizeCategorizer;} +RIDL!{#[uuid(0xd912f8cf, 0x0396, 0x4915, 0x88, 0x4e, 0xfb, 0x42, 0x5d, 0x32, 0x94, 0x3b)] +class PropertiesUI;} +RIDL!{#[uuid(0x0010890e, 0x8789, 0x413c, 0xad, 0xbc, 0x48, 0xf5, 0xb5, 0x11, 0xb3, 0xaf)] +class UserNotification;} +RIDL!{#[uuid(0x56fdf344, 0xfd6d, 0x11d0, 0x95, 0x8a, 0x00, 0x60, 0x97, 0xc9, 0xa0, 0x90)] +class TaskbarList;} +RIDL!{#[uuid(0x9ac9fbe1, 0xe0a2, 0x4ad6, 0xb4, 0xee, 0xe2, 0x12, 0x01, 0x3e, 0xa9, 0x17)] +class ShellItem;} +RIDL!{#[uuid(0x72eb61e0, 0x8672, 0x4303, 0x91, 0x75, 0xf2, 0xe4, 0xc6, 0x8b, 0x2e, 0x7c)] +class NamespaceWalker;} +RIDL!{#[uuid(0x3ad05575, 0x8857, 0x4850, 0x92, 0x77, 0x11, 0xb8, 0x5b, 0xdb, 0x8e, 0x09)] +class FileOperation;} +RIDL!{#[uuid(0xdc1c5a9c, 0xe88a, 0x4dde, 0xa5, 0xa1, 0x60, 0xf8, 0x2a, 0x20, 0xae, 0xf7)] +class FileOpenDialog;} +RIDL!{#[uuid(0xc0b4e2f3, 0xba21, 0x4773, 0x8d, 0xba, 0x33, 0x5e, 0xc9, 0x46, 0xeb, 0x8b)] +class FileSaveDialog;} +RIDL!{#[uuid(0x4df0c730, 0xdf9d, 0x4ae3, 0x91, 0x53, 0xaa, 0x6b, 0x82, 0xe9, 0x79, 0x5a)] +class KnownFolderManager;} +RIDL!{#[uuid(0x49f371e1, 0x8c5c, 0x4d9c, 0x9a, 0x3b, 0x54, 0xa6, 0x82, 0x7f, 0x51, 0x3c)] +class SharingConfigurationManager;} +RIDL!{#[uuid(0x7007acc7, 0x3202, 0x11d1, 0xaa, 0xd2, 0x00, 0x80, 0x5f, 0xc1, 0x27, 0x0e)] +class NetworkConnections;} +RIDL!{#[uuid(0xd6277990, 0x4c6a, 0x11cf, 0x8d, 0x87, 0x00, 0xaa, 0x00, 0x60, 0xf5, 0xbf)] +class ScheduledTasks;} +RIDL!{#[uuid(0x591209c7, 0x767b, 0x42b2, 0x9f, 0xba, 0x44, 0xee, 0x46, 0x15, 0xf2, 0xc7)] +class ApplicationAssociationRegistration;} +RIDL!{#[uuid(0x14010e02, 0xbbbd, 0x41f0, 0x88, 0xe3, 0xed, 0xa3, 0x71, 0x21, 0x65, 0x84)] +class SearchFolderItemFactory;} +RIDL!{#[uuid(0x06622d85, 0x6856, 0x4460, 0x8d, 0xe1, 0xa8, 0x19, 0x21, 0xb4, 0x1c, 0x4b)] +class OpenControlPanel;} +RIDL!{#[uuid(0x9e56be60, 0xc50f, 0x11cf, 0x9a, 0x2c, 0x00, 0xa0, 0xc9, 0x0a, 0x90, 0xce)] +class MailRecipient;} +RIDL!{#[uuid(0xf02c1a0d, 0xbe21, 0x4350, 0x88, 0xb0, 0x73, 0x67, 0xfc, 0x96, 0xef, 0x3c)] +class NetworkExplorerFolder;} +RIDL!{#[uuid(0x77f10cf0, 0x3db5, 0x4966, 0xb5, 0x20, 0xb7, 0xc5, 0x4f, 0xd3, 0x5e, 0xd6)] +class DestinationList;} +RIDL!{#[uuid(0x86c14003, 0x4d6b, 0x4ef3, 0xa7, 0xb4, 0x05, 0x06, 0x66, 0x3b, 0x2e, 0x68)] +class ApplicationDestinations;} +RIDL!{#[uuid(0x86bec222, 0x30f2, 0x47e0, 0x9f, 0x25, 0x60, 0xd1, 0x1c, 0xd7, 0x5c, 0x28)] +class ApplicationDocumentLists;} +RIDL!{#[uuid(0xde77ba04, 0x3c92, 0x4d11, 0xa1, 0xa5, 0x42, 0x35, 0x2a, 0x53, 0xe0, 0xe3)] +class HomeGroup;} +RIDL!{#[uuid(0xd9b3211d, 0xe57f, 0x4426, 0xaa, 0xef, 0x30, 0xa8, 0x06, 0xad, 0xd3, 0x97)] +class ShellLibrary;} +RIDL!{#[uuid(0x273eb5e7, 0x88b0, 0x4843, 0xbf, 0xef, 0xe2, 0xc8, 0x1d, 0x43, 0xaa, 0xe5)] +class AppStartupLink;} +RIDL!{#[uuid(0x2d3468c1, 0x36a7, 0x43b6, 0xac, 0x24, 0xd3, 0xf0, 0x2f, 0xd9, 0x60, 0x7a)] +class EnumerableObjectCollection;} +RIDL!{#[uuid(0xd5120aa3, 0x46ba, 0x44c5, 0x82, 0x2d, 0xca, 0x80, 0x92, 0xc1, 0xfc, 0x72)] +class FrameworkInputPane;} +RIDL!{#[uuid(0xc63382be, 0x7933, 0x48d0, 0x9a, 0xc8, 0x85, 0xfb, 0x46, 0xbe, 0x2f, 0xdd)] +class DefFolderMenu;} +RIDL!{#[uuid(0x7e5fe3d9, 0x985f, 0x4908, 0x91, 0xf9, 0xee, 0x19, 0xf9, 0xfd, 0x15, 0x14)] +class AppVisibility;} +RIDL!{#[uuid(0x4ed3a719, 0xcea8, 0x4bd9, 0x91, 0x0d, 0xe2, 0x52, 0xf9, 0x97, 0xaf, 0xc2)] +class AppShellVerbHandler;} +RIDL!{#[uuid(0xe44e9428, 0xbdbc, 0x4987, 0xa0, 0x99, 0x40, 0xdc, 0x8f, 0xd2, 0x55, 0xe7)] +class ExecuteUnknown;} +RIDL!{#[uuid(0xb1aec16f, 0x2383, 0x4852, 0xb0, 0xe9, 0x8f, 0x0b, 0x1d, 0xc6, 0x6b, 0x4d)] +class PackageDebugSettings;} +RIDL!{#[uuid(0x6b273fc5, 0x61fd, 0x4918, 0x95, 0xa2, 0xc3, 0xb5, 0xe9, 0xd7, 0xf5, 0x81)] +class SuspensionDependencyManager;} +RIDL!{#[uuid(0x45ba127d, 0x10a8, 0x46ea, 0x8a, 0xb7, 0x56, 0xea, 0x90, 0x78, 0x94, 0x3c)] +class ApplicationActivationManager;} +RIDL!{#[uuid(0x958a6fb5, 0xdcb2, 0x4faf, 0xaa, 0xfd, 0x7f, 0xb0, 0x54, 0xad, 0x1a, 0x3b)] +class ApplicationDesignModeSettings;} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/shtypes.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/shtypes.rs new file mode 100644 index 0000000..470d79e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/shtypes.rs @@ -0,0 +1,44 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! this ALWAYS GENERATED file contains the definitions for the interfaces +use shared::guiddef::GUID; +use shared::minwindef::{BYTE, USHORT}; +use um::winnt::LPCWSTR; +STRUCT!{#[repr(packed)] struct SHITEMID { + cb: USHORT, + abID: [BYTE; 1], +}} +pub type LPSHITEMID = *mut SHITEMID; +pub type LPCSHITEMID = *const SHITEMID; +STRUCT!{#[repr(packed)] struct ITEMIDLIST { + mkid: SHITEMID, +}} +pub type ITEMIDLIST_RELATIVE = ITEMIDLIST; +pub type ITEMID_CHILD = ITEMIDLIST; +pub type ITEMIDLIST_ABSOLUTE = ITEMIDLIST; +pub type LPITEMIDLIST = *mut ITEMIDLIST; +pub type LPCITEMIDLIST = *const ITEMIDLIST; +pub type PIDLIST_ABSOLUTE = *mut ITEMIDLIST_ABSOLUTE; +pub type PCIDLIST_ABSOLUTE = *const ITEMIDLIST_ABSOLUTE; +pub type PCUIDLIST_ABSOLUTE = *const ITEMIDLIST_ABSOLUTE; +pub type PIDLIST_RELATIVE = *mut ITEMIDLIST_RELATIVE; +pub type PCIDLIST_RELATIVE = *const ITEMIDLIST_RELATIVE; +pub type PUIDLIST_RELATIVE = *mut ITEMIDLIST_RELATIVE; +pub type PCUIDLIST_RELATIVE = *const ITEMIDLIST_RELATIVE; +pub type PITEMID_CHILD = *mut ITEMID_CHILD; +pub type PCITEMID_CHILD = *const ITEMID_CHILD; +pub type PUITEMID_CHILD = *mut ITEMID_CHILD; +pub type PCUITEMID_CHILD = *const ITEMID_CHILD; +pub type PCUITEMID_CHILD_ARRAY = *const PCUITEMID_CHILD; +pub type PCUIDLIST_RELATIVE_ARRAY = *const PCUIDLIST_RELATIVE; +pub type PCIDLIST_ABSOLUTE_ARRAY = *const PCIDLIST_ABSOLUTE; +pub type PCUIDLIST_ABSOLUTE_ARRAY = *const PCUIDLIST_ABSOLUTE; +STRUCT!{struct COMDLG_FILTERSPEC { + pszName: LPCWSTR, + pszSpec: LPCWSTR, +}} +pub type KNOWNFOLDERID = GUID; +pub type REFKNOWNFOLDERID = *const KNOWNFOLDERID; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/spapidef.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/spapidef.rs new file mode 100644 index 0000000..259f469 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/spapidef.rs @@ -0,0 +1,53 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Public header file for Windows NT Setup and Device Installer services Dlls +use shared::minwindef::DWORD; +use um::winnt::DWORDLONG; +pub type SP_LOG_TOKEN = DWORDLONG; +pub type PSP_LOG_TOKEN = *mut DWORDLONG; +pub const LOGTOKEN_TYPE_MASK: SP_LOG_TOKEN = 3; +pub const LOGTOKEN_UNSPECIFIED: SP_LOG_TOKEN = 0; +pub const LOGTOKEN_NO_LOG: SP_LOG_TOKEN = 1; +pub const LOGTOKEN_SETUPAPI_APPLOG: SP_LOG_TOKEN = 2; +pub const LOGTOKEN_SETUPAPI_DEVLOG: SP_LOG_TOKEN = 3; +pub const TXTLOG_SETUPAPI_DEVLOG: DWORD = 0x00000001; +pub const TXTLOG_SETUPAPI_CMDLINE: DWORD = 0x00000002; +pub const TXTLOG_SETUPAPI_BITS: DWORD = 0x00000003; +pub const TXTLOG_ERROR: DWORD = 0x1; +pub const TXTLOG_WARNING: DWORD = 0x2; +pub const TXTLOG_SYSTEM_STATE_CHANGE: DWORD = 0x3; +pub const TXTLOG_SUMMARY: DWORD = 0x4; +pub const TXTLOG_DETAILS: DWORD = 0x5; +pub const TXTLOG_VERBOSE: DWORD = 0x6; +pub const TXTLOG_VERY_VERBOSE: DWORD = 0x7; +pub const TXTLOG_RESERVED_FLAGS: DWORD = 0x0000FFF0; +pub const TXTLOG_TIMESTAMP: DWORD = 0x00010000; +pub const TXTLOG_DEPTH_INCR: DWORD = 0x00020000; +pub const TXTLOG_DEPTH_DECR: DWORD = 0x00040000; +pub const TXTLOG_TAB_1: DWORD = 0x00080000; +pub const TXTLOG_FLUSH_FILE: DWORD = 0x00100000; +#[inline] +pub fn TXTLOG_LEVEL(flags: DWORD) -> DWORD { + flags & 0xf +} +pub const TXTLOG_DEVINST: DWORD = 0x00000001; +pub const TXTLOG_INF: DWORD = 0x00000002; +pub const TXTLOG_FILEQ: DWORD = 0x00000004; +pub const TXTLOG_COPYFILES: DWORD = 0x00000008; +pub const TXTLOG_SIGVERIF: DWORD = 0x00000020; +pub const TXTLOG_BACKUP: DWORD = 0x00000080; +pub const TXTLOG_UI: DWORD = 0x00000100; +pub const TXTLOG_UTIL: DWORD = 0x00000200; +pub const TXTLOG_INFDB: DWORD = 0x00000400; +pub const TXTLOG_POLICY: DWORD = 0x00800000; +pub const TXTLOG_NEWDEV: DWORD = 0x01000000; +pub const TXTLOG_UMPNPMGR: DWORD = 0x02000000; +pub const TXTLOG_DRIVER_STORE: DWORD = 0x04000000; +pub const TXTLOG_SETUP: DWORD = 0x08000000; +pub const TXTLOG_CMI: DWORD = 0x10000000; +pub const TXTLOG_DEVMGR: DWORD = 0x20000000; +pub const TXTLOG_INSTALLER: DWORD = 0x40000000; +pub const TXTLOG_VENDOR: DWORD = 0x80000000; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/spellcheck.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/spellcheck.rs new file mode 100644 index 0000000..9254ed5 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/spellcheck.rs @@ -0,0 +1,146 @@ +use shared::minwindef::{BOOL, BYTE, DWORD}; +use shared::ntdef::{LPCWSTR, LPWSTR, ULONG}; +use shared::winerror::HRESULT; +use um::objidlbase::IEnumString; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +ENUM!{enum WORDLIST_TYPE { + WORDLIST_TYPE_IGNORE = 0, + WORDLIST_TYPE_ADD = 1, + WORDLIST_TYPE_EXCLUDE = 2, + WORDLIST_TYPE_AUTOCORRECT = 3, +}} +ENUM!{enum CORRECTIVE_ACTION { + CORRECTIVE_ACTION_NONE = 0, + CORRECTIVE_ACTION_GET_SUGGESTIONS = 1, + CORRECTIVE_ACTION_REPLACE = 2, + CORRECTIVE_ACTION_DELETE = 3, +}} +RIDL!{#[uuid(0xb7c82d61, 0xfbe8, 0x4b47, 0x9b, 0x27, 0x6c, 0x0d, 0x2e, 0x0d, 0xe0, 0xa3)] +interface ISpellingError(ISpellingErrorVtbl): IUnknown(IUnknownVtbl) { + fn get_StartIndex( + value: *mut ULONG, + ) -> HRESULT, + fn get_Length( + value: *mut ULONG, + ) -> HRESULT, + fn get_CorrectiveAction( + value: *mut CORRECTIVE_ACTION, + ) -> HRESULT, + fn get_Replacement( + value: *mut LPWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x803e3bd4, 0x2828, 0x4410, 0x82, 0x90, 0x41, 0x8d, 0x1d, 0x73, 0xc7, 0x62)] +interface IEnumSpellingError(IEnumSpellingErrorVtbl): IUnknown(IUnknownVtbl) { + fn Next( + value: *mut *mut ISpellingError, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x432e5f85, 0x35cf, 0x4606, 0xa8, 0x01, 0x6f, 0x70, 0x27, 0x7e, 0x1d, 0x7a)] +interface IOptionDescription(IOptionDescriptionVtbl): IUnknown(IUnknownVtbl) { + fn Id( + value: *mut LPWSTR, + ) -> HRESULT, + fn Heading( + value: *mut LPWSTR, + ) -> HRESULT, + fn Description( + value: *mut LPWSTR, + ) -> HRESULT, + fn Labels( + value: *mut *mut IEnumString, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0b83a5b0, 0x792f, 0x4eab, 0x97, 0x99, 0xac, 0xf5, 0x2c, 0x5e, 0xd0, 0x8a)] +interface ISpellCheckerChangedEventHandler(ISpellCheckerChangedEventHandlerVtbl): + IUnknown(IUnknownVtbl) { + fn Invoke( + sender: *const ISpellChecker, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb6fd0b71, 0xe2bc, 0x4653, 0x8d, 0x05, 0xf1, 0x97, 0xe4, 0x12, 0x77, 0x0b)] +interface ISpellChecker(ISpellCheckerVtbl): IUnknown(IUnknownVtbl) { + fn get_LanguageTag( + value: *mut LPWSTR, + ) -> HRESULT, + fn Check( + text: LPCWSTR, + value: *mut *mut IEnumSpellingError, + ) -> HRESULT, + fn Suggest( + word: LPCWSTR, + value: *mut *mut IEnumString, + ) -> HRESULT, + fn Add( + word: LPCWSTR, + ) -> HRESULT, + fn Ignore( + word: LPCWSTR, + ) -> HRESULT, + fn AutoCorrect( + from: LPCWSTR, + to: LPCWSTR, + ) -> HRESULT, + fn GetOptionValue( + optionId: LPCWSTR, + value: *mut BYTE, + ) -> HRESULT, + fn Get_OptionIds( + value: *mut *mut IEnumString, + ) -> HRESULT, + fn Get_Id( + value: *mut LPWSTR, + ) -> HRESULT, + fn Get_LocalizedName( + value: *mut LPWSTR, + ) -> HRESULT, + fn add_SpellCheckerChanged( + handler: *const ISpellCheckerChangedEventHandler, + eventCookie: *mut DWORD, + ) -> HRESULT, + fn remove_SpellCheckerChanged( + eventCookie: DWORD, + ) -> HRESULT, + fn GetOptionDescription( + optionId: LPCWSTR, + value: *mut *mut IOptionDescription, + ) -> HRESULT, + fn ComprehensiveCheck( + text: LPCWSTR, + value: *mut *mut IEnumSpellingError, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xe7ed1c71, 0x87f7, 0x4378, 0xa8, 0x40, 0xc9, 0x20, 0x0d, 0xac, 0xee, 0x47)] +interface ISpellChecker2(ISpellChecker2Vtbl): ISpellChecker(ISpellCheckerVtbl) { + fn Remove( + word: LPCWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8e018a9d, 0x2415, 0x4677, 0xbf, 0x08, 0x79, 0x4e, 0xa6, 0x1f, 0x94, 0xbb)] +interface ISpellCheckerFactory(ISpellCheckerFactoryVtbl): IUnknown(IUnknownVtbl) { + fn SupportedLanguages( + value: *mut *mut IEnumString, + ) -> HRESULT, + fn IsSupported( + languageTag: LPCWSTR, + value: *mut BOOL, + ) -> HRESULT, + fn CreateSpellChecker( + languageTag: LPCWSTR, + value: *mut *mut ISpellChecker, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xaa176b85, 0x0e12, 0x4844, 0x8e, 0x1a, 0xee, 0xf1, 0xda, 0x77, 0xf5, 0x86)] +interface IUserDictionariesRegistrar(IUserDictionariesRegistrarVtbl): IUnknown(IUnknownVtbl) { + fn RegisterUserDictionary( + dictionaryPath: LPCWSTR, + languageTag: LPCWSTR, + ) -> HRESULT, + fn UnregisterUserDictionary( + dictionaryPath: LPCWSTR, + languageTag: LPCWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7ab36653, 0x1796, 0x484b, 0xbd, 0xfa, 0xe7, 0x4f, 0x1d, 0xb7, 0xc1, 0xdc)] +class SpellCheckerFactory; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sporder.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sporder.rs new file mode 100644 index 0000000..84630e3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sporder.rs @@ -0,0 +1,41 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! Service Provider Order +use ctypes::c_int; +use shared::guiddef::LPGUID; +use shared::minwindef::{DWORD, LPDWORD}; +extern "system" { + pub fn WSCWriteProviderOrder( + lpwdCatalogEntryId: LPDWORD, + dwNumberOfEntries: DWORD, + ) -> c_int; +} +FN!{stdcall LPWSCWRITEPROVIDERORDER( + lpwdCatalogEntryId: LPDWORD, + dwNumberOfEntries: DWORD, +) -> c_int} +#[cfg(target_pointer_width = "64")] +extern "system" { + pub fn WSCWriteProviderOrder32( + lpwdCatalogEntryId: LPDWORD, + dwNumberOfEntries: DWORD, + ) -> c_int; + pub fn WSCWriteNameSpaceOrder( + lpProviderId: LPGUID, + dwNumberOfEntries: DWORD, + ) -> c_int; +} +FN!{stdcall LPWSCWRITENAMESPACEORDER( + lpProviderId: LPGUID, + dwNumberOfEntries: DWORD, +) -> c_int} +#[cfg(target_pointer_width = "64")] +extern "system" { + pub fn WSCWriteNameSpaceOrder32( + lpProviderId: LPGUID, + dwNumberOfEntries: DWORD, + ) -> c_int; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sql.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sql.rs new file mode 100644 index 0000000..d42a163 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sql.rs @@ -0,0 +1,108 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use um::sqltypes::{ + SQLHANDLE, SQLHDBC, SQLHENV, SQLHSTMT, SQLINTEGER, SQLLEN, SQLPOINTER, SQLRETURN, SQLSMALLINT, + SQLUSMALLINT, +}; +pub const SQL_NULL_DATA: SQLLEN = -1; +pub const SQL_DATA_AT_EXEC: SQLLEN = -2; +pub const SQL_SUCCESS: SQLRETURN = 0; +pub const SQL_SUCCESS_WITH_INFO: SQLRETURN = 1; +pub const SQL_NO_DATA: SQLRETURN = 100; +pub const SQL_PARAM_DATA_AVAILABLE: SQLRETURN = 101; +pub const SQL_ERROR: SQLRETURN = -1; +pub const SQL_INVALID_HANDLE: SQLRETURN = -2; +pub const SQL_STILL_EXECUTING: SQLRETURN = 2; +pub const SQL_NEED_DATA: SQLRETURN = 99; +pub const SQL_NTS: SQLSMALLINT = -3; +pub const SQL_MAX_MESSAGE_LENGTH: usize = 512; +pub const SQL_DATE_LEN: usize = 10; +pub const SQL_TIME_LEN: usize = 8; +pub const SQL_TIMESTAMP_LEN: usize = 19; +pub const SQL_HANDLE_ENV: SQLSMALLINT = 1; +pub const SQL_HANDLE_DBC: SQLSMALLINT = 2; +pub const SQL_HANDLE_STMT: SQLSMALLINT = 3; +pub const SQL_HANDLE_DESC: SQLSMALLINT = 4; +pub const SQL_ATTR_OUTPUT_NTS: SQLINTEGER = 10001; +pub const SQL_ATTR_AUTO_IPD: SQLINTEGER = 10001; +pub const SQL_ATTR_METADATA_ID: SQLINTEGER = 10014; +pub const SQL_ATTR_APP_ROW_DESC: SQLINTEGER = 10010; +pub const SQL_ATTR_APP_PARAM_DESC: SQLINTEGER = 10011; +pub const SQL_ATTR_IMP_ROW_DESC: SQLINTEGER = 10012; +pub const SQL_ATTR_IMP_PARAM_DESC: SQLINTEGER = 10013; +pub const SQL_ATTR_CURSOR_SCROLLABLE: SQLINTEGER = -1; +pub const SQL_ATTR_CURSOR_SENSITIVITY: SQLINTEGER = -2; +pub const SQL_UNKNOWN_TYPE: SQLSMALLINT = 0; +pub const SQL_CHAR: SQLSMALLINT = 1; +pub const SQL_NUMERIC: SQLSMALLINT = 2; +pub const SQL_DECIMAL: SQLSMALLINT = 3; +pub const SQL_INTEGER: SQLSMALLINT = 4; +pub const SQL_SMALLINT: SQLSMALLINT = 5; +pub const SQL_FLOAT: SQLSMALLINT = 6; +pub const SQL_REAL: SQLSMALLINT = 7; +pub const SQL_DOUBLE: SQLSMALLINT = 8; +pub const SQL_DATETIME: SQLSMALLINT = 9; +pub const SQL_VARCHAR: SQLSMALLINT = 12; +pub const SQL_TYPE_DATE: SQLSMALLINT = 91; +pub const SQL_TYPE_TIME: SQLSMALLINT = 92; +pub const SQL_TYPE_TIMESTAMP: SQLSMALLINT = 93; +pub const SQL_NO_NULLS: SQLSMALLINT = 0; +pub const SQL_NULLABLE: SQLSMALLINT = 1; +pub const SQL_NULLABLE_UNKNOWN: SQLSMALLINT = 2; +pub const SQL_CLOSE: SQLUSMALLINT = 0; +pub const SQL_DROP: SQLUSMALLINT = 1; +pub const SQL_UNBIND: SQLUSMALLINT = 2; +pub const SQL_RESET_PARAMS: SQLUSMALLINT = 3; +pub const SQL_NULL_HANDLE: SQLHANDLE = 0 as SQLHANDLE; +extern "system" { + pub fn SQLAllocHandle( + handleType: SQLSMALLINT, + inputHandle: SQLHANDLE, + outputHandle: *mut SQLHANDLE, + ) -> SQLRETURN; + pub fn SQLDisconnect( + connectionHandle: SQLHDBC, + ) -> SQLRETURN; + pub fn SQLFetch( + statementHandle: SQLHSTMT, + ) -> SQLRETURN; + pub fn SQLFreeHandle( + handleType: SQLSMALLINT, + handle: SQLHANDLE, + ) -> SQLRETURN; + pub fn SQLFreeStmt( + statementHandle: SQLHSTMT, + option: SQLUSMALLINT, + ) -> SQLRETURN; + pub fn SQLGetData( + statementHandle: SQLHSTMT, + columnNumber: SQLUSMALLINT, + targetType: SQLSMALLINT, + targetValue: SQLPOINTER, + bufferLength: SQLLEN, + strLen_or_IndPtr: *mut SQLLEN, + ) -> SQLRETURN; + pub fn SQLNumResultCols( + statementHandle: SQLHSTMT, + columnCount: *mut SQLSMALLINT, + ) -> SQLRETURN; + pub fn SQLRowCount( + statementHandle: SQLHSTMT, + rowCount: *mut SQLLEN, + ) -> SQLRETURN; + pub fn SQLSetConnectAttr( + connectionHandle: SQLHDBC, + attribute: SQLINTEGER, + value: SQLPOINTER, + stringLength: SQLINTEGER, + ) -> SQLRETURN; + pub fn SQLSetEnvAttr( + environmentHandle: SQLHENV, + attribute: SQLINTEGER, + value: SQLPOINTER, + stringLength: SQLINTEGER, + ) -> SQLRETURN; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sqlext.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sqlext.rs new file mode 100644 index 0000000..8de50f1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sqlext.rs @@ -0,0 +1,95 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module defines the SQL extension APIs +use um::sql::{ + SQL_CHAR, SQL_DOUBLE, SQL_INTEGER, SQL_NUMERIC, SQL_REAL, SQL_SMALLINT, SQL_TYPE_DATE, + SQL_TYPE_TIME, SQL_TYPE_TIMESTAMP +}; +use um::sqltypes::{SQLINTEGER, SQLSMALLINT, SQLUSMALLINT}; +pub const SQL_ATTR_ODBC_VERSION: SQLINTEGER = 200; +pub const SQL_ATTR_CONNECTION_POOLING: SQLINTEGER = 201; +pub const SQL_ATTR_CP_MATCH: SQLINTEGER = 202; +pub const SQL_OV_ODBC2: SQLINTEGER = 2; +pub const SQL_OV_ODBC3: SQLINTEGER = 3; +pub const SQL_OV_ODBC3_80: SQLINTEGER = 380; +pub const SQL_ACCESS_MODE: SQLINTEGER = 101; +pub const SQL_AUTOCOMMIT: SQLINTEGER = 102; +pub const SQL_LOGIN_TIMEOUT: SQLINTEGER = 103; +pub const SQL_OPT_TRACE: SQLINTEGER = 104; +pub const SQL_OPT_TRACEFILE: SQLINTEGER = 105; +pub const SQL_TRANSLATE_DLL: SQLINTEGER = 106; +pub const SQL_TRANSLATE_OPTION: SQLINTEGER = 107; +pub const SQL_TXN_ISOLATION: SQLINTEGER = 108; +pub const SQL_CURRENT_QUALIFIER: SQLINTEGER = 109; +pub const SQL_ODBC_CURSORS: SQLINTEGER = 110; +pub const SQL_QUIET_MODE: SQLINTEGER = 111; +pub const SQL_PACKET_SIZE: SQLINTEGER = 112; +pub const SQL_ATTR_ACCESS_MODE: SQLINTEGER = SQL_ACCESS_MODE; +pub const SQL_ATTR_AUTOCOMMIT: SQLINTEGER = SQL_AUTOCOMMIT; +pub const SQL_ATTR_CONNECTION_TIMEOUT: SQLINTEGER = 113; +pub const SQL_ATTR_CURRENT_CATALOG: SQLINTEGER = SQL_CURRENT_QUALIFIER; +pub const SQL_ATTR_DISCONNECT_BEHAVIOR: SQLINTEGER = 114; +pub const SQL_ATTR_ENLIST_IN_DTC: SQLINTEGER = 1207; +pub const SQL_ATTR_ENLIST_IN_XA: SQLINTEGER = 1208; +pub const SQL_ATTR_LOGIN_TIMEOUT: SQLINTEGER = SQL_LOGIN_TIMEOUT; +pub const SQL_ATTR_ODBC_CURSORS: SQLINTEGER = SQL_ODBC_CURSORS; +pub const SQL_ATTR_PACKET_SIZE: SQLINTEGER = SQL_PACKET_SIZE; +pub const SQL_ATTR_QUIET_MODE: SQLINTEGER = SQL_QUIET_MODE; +pub const SQL_ATTR_TRACE: SQLINTEGER = SQL_OPT_TRACE; +pub const SQL_ATTR_TRACEFILE: SQLINTEGER = SQL_OPT_TRACEFILE; +pub const SQL_ATTR_TRANSLATE_LIB: SQLINTEGER = SQL_TRANSLATE_DLL; +pub const SQL_ATTR_TRANSLATE_OPTION: SQLINTEGER = SQL_TRANSLATE_OPTION; +pub const SQL_ATTR_TXN_ISOLATION: SQLINTEGER = SQL_TXN_ISOLATION; +pub const SQL_ATTR_CONNECTION_DEAD: SQLINTEGER = 1209; +pub const SQL_IS_POINTER: SQLINTEGER = -4; +pub const SQL_IS_UINTEGER: SQLINTEGER = -5; +pub const SQL_IS_INTEGER: SQLINTEGER = -6; +pub const SQL_IS_USMALLINT: SQLINTEGER = -7; +pub const SQL_IS_SMALLINT: SQLINTEGER = -8; +pub const SQL_DATE: SQLSMALLINT = 9; +pub const SQL_INTERVAL: SQLSMALLINT = 10; +pub const SQL_TIME: SQLSMALLINT = 10; +pub const SQL_TIMESTAMP: SQLSMALLINT = 11; +pub const SQL_LONGVARCHAR: SQLSMALLINT = -1; +pub const SQL_BINARY: SQLSMALLINT = -2; +pub const SQL_VARBINARY: SQLSMALLINT = -3; +pub const SQL_LONGVARBINARY: SQLSMALLINT = -4; +pub const SQL_BIGINT: SQLSMALLINT = -5; +pub const SQL_TINYINT: SQLSMALLINT = -6; +pub const SQL_BIT: SQLSMALLINT = -7; +pub const SQL_GUID: SQLSMALLINT = -11; +pub const SQL_C_CHAR: SQLSMALLINT = SQL_CHAR; +pub const SQL_C_LONG: SQLSMALLINT = SQL_INTEGER; +pub const SQL_C_SHORT: SQLSMALLINT = SQL_SMALLINT; +pub const SQL_C_FLOAT: SQLSMALLINT = SQL_REAL; +pub const SQL_C_DOUBLE: SQLSMALLINT = SQL_DOUBLE; +pub const SQL_C_NUMERIC: SQLSMALLINT = SQL_NUMERIC; +pub const SQL_C_DEFAULT: SQLSMALLINT = 99; +pub const SQL_SIGNED_OFFSET: SQLSMALLINT = -20; +pub const SQL_UNSIGNED_OFFSET: SQLSMALLINT = -22; +pub const SQL_C_DATE: SQLSMALLINT = SQL_DATE; +pub const SQL_C_TIME: SQLSMALLINT = SQL_TIME; +pub const SQL_C_TIMESTAMP: SQLSMALLINT = SQL_TIMESTAMP; +pub const SQL_C_TYPE_DATE: SQLSMALLINT = SQL_TYPE_DATE; +pub const SQL_C_TYPE_TIME: SQLSMALLINT = SQL_TYPE_TIME; +pub const SQL_C_TYPE_TIMESTAMP: SQLSMALLINT = SQL_TYPE_TIMESTAMP; +pub const SQL_C_BINARY: SQLSMALLINT = SQL_BINARY; +pub const SQL_C_BIT: SQLSMALLINT = SQL_BIT; +pub const SQL_C_SBIGINT: SQLSMALLINT = SQL_BIGINT + SQL_SIGNED_OFFSET; +pub const SQL_C_UBIGINT: SQLSMALLINT = SQL_BIGINT + SQL_UNSIGNED_OFFSET; +pub const SQL_C_TINYINT: SQLSMALLINT = SQL_TINYINT; +pub const SQL_C_SLONG: SQLSMALLINT = SQL_C_LONG + SQL_SIGNED_OFFSET; +pub const SQL_C_SSHORT: SQLSMALLINT = SQL_C_SHORT + SQL_SIGNED_OFFSET; +pub const SQL_C_STINYINT: SQLSMALLINT = SQL_TINYINT + SQL_SIGNED_OFFSET; +pub const SQL_C_ULONG: SQLSMALLINT = SQL_C_LONG + SQL_UNSIGNED_OFFSET; +pub const SQL_C_USHORT: SQLSMALLINT = SQL_C_SHORT + SQL_UNSIGNED_OFFSET; +pub const SQL_C_UTINYINT: SQLSMALLINT = SQL_TINYINT + SQL_UNSIGNED_OFFSET; +pub const SQL_C_GUID: SQLSMALLINT = SQL_GUID; +pub const SQL_TYPE_NULL: SQLSMALLINT = 0; +pub const SQL_DRIVER_NOPROMPT: SQLUSMALLINT = 0; +pub const SQL_DRIVER_COMPLETE: SQLUSMALLINT = 1; +pub const SQL_DRIVER_PROMPT: SQLUSMALLINT = 2; +pub const SQL_DRIVER_COMPLETE_REQUIRED: SQLUSMALLINT = 3; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sqltypes.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sqltypes.rs new file mode 100644 index 0000000..401cffb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sqltypes.rs @@ -0,0 +1,142 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module defines the types used in ODBC +use ctypes::*; +#[cfg(target_pointer_width = "64")] +use shared::basetsd::{INT64, UINT64}; +use shared::guiddef::GUID; +use shared::windef::HWND; +pub type SQLCHAR = c_uchar; +pub type SQLSCHAR = c_schar; +pub type SQLDATE = c_uchar; +pub type SQLDECIMAL = c_uchar; +pub type SQLDOUBLE = c_double; +pub type SQLFLOAT = c_double; +pub type SQLINTEGER = c_long; +pub type SQLUINTEGER = c_ulong; +#[cfg(target_pointer_width = "64")] +pub type SQLLEN = INT64; +#[cfg(target_pointer_width = "64")] +pub type SQLULEN = UINT64; +#[cfg(target_pointer_width = "64")] +pub type SQLSETPOSIROW = UINT64; +#[cfg(target_pointer_width = "32")] +pub type SQLLEN = SQLINTEGER; +#[cfg(target_pointer_width = "32")] +pub type SQLULEN = SQLUINTEGER; +#[cfg(target_pointer_width = "32")] +pub type SQLSETPOSIROW = SQLUSMALLINT; +pub type SQLROWCOUNT = SQLULEN; +pub type SQLROWSETSIZE = SQLULEN; +pub type SQLTRANSID = SQLULEN; +pub type SQLROWOFFSET = SQLLEN; +pub type SQLNUMERIC = c_uchar; +pub type SQLPOINTER = *mut c_void; +pub type SQLREAL = c_float; +pub type SQLSMALLINT = c_short; +pub type SQLUSMALLINT = c_ushort; +pub type SQLTIME = c_uchar; +pub type SQLTIMESTAMP = c_uchar; +pub type SQLVARCHAR = c_uchar; +pub type SQLRETURN = SQLSMALLINT; +pub type SQLHANDLE = *mut c_void; +pub type SQLHENV = SQLHANDLE; +pub type SQLHDBC = SQLHANDLE; +pub type SQLHSTMT = SQLHANDLE; +pub type SQLHDESC = SQLHANDLE; +//pub type UCHAR = c_uchar; +pub type SCHAR = c_schar; +//pub type SQLSCHAR = SCHAR; +pub type SDWORD = c_long; +pub type SWORD = c_short; +pub type UDWORD = c_ulong; +//pub type UWORD = c_ushort; +//#[cfg(target_pointer_width = "32")] +//pub type SQLUINTEGER = UDWORD; +pub type SLONG = c_long; +pub type SSHORT = c_short; +//pub type ULONG = c_ulong; +//pub type USHORT = c_ushort; +pub type SDOUBLE = c_double; +pub type LDOUBLE = c_double; +pub type SFLOAT = c_float; +pub type PTR = *mut c_void; +pub type HENV = *mut c_void; +pub type HDBC = *mut c_void; +pub type HSTMT = *mut c_void; +pub type RETCODE = c_short; +pub type SQLHWND = HWND; +STRUCT!{struct DATE_STRUCT { + year: SQLSMALLINT, + month: SQLUSMALLINT, + day: SQLUSMALLINT, +}} +pub type SQL_DATE_STRUCT = DATE_STRUCT; +STRUCT!{struct TIME_STRUCT { + hour: SQLUSMALLINT, + minute: SQLUSMALLINT, + second: SQLUSMALLINT, +}} +pub type SQL_TIME_STRUCT = TIME_STRUCT; +STRUCT!{struct TIMESTAMP_STRUCT { + year: SQLSMALLINT, + month: SQLUSMALLINT, + day: SQLUSMALLINT, + hour: SQLUSMALLINT, + minute: SQLUSMALLINT, + second: SQLUSMALLINT, + fraction: SQLUINTEGER, +}} +pub type SQL_TIMESTAMP_STRUCT = TIMESTAMP_STRUCT; +ENUM!{enum SQLINTERVAL { + SQL_IS_YEAR = 1, + SQL_IS_MONTH = 2, + SQL_IS_DAY = 3, + SQL_IS_HOUR = 4, + SQL_IS_MINUTE = 5, + SQL_IS_SECOND = 6, + SQL_IS_YEAR_TO_MONTH = 7, + SQL_IS_DAY_TO_HOUR = 8, + SQL_IS_DAY_TO_MINUTE = 9, + SQL_IS_DAY_TO_SECOND = 10, + SQL_IS_HOUR_TO_MINUTE = 11, + SQL_IS_HOUR_TO_SECOND = 12, + SQL_IS_MINUTE_TO_SECOND = 13, +}} +STRUCT!{struct SQL_YEAR_MONTH_STRUCT { + year: SQLUINTEGER, + month: SQLUINTEGER, +}} +STRUCT!{struct SQL_DAY_SECOND_STRUCT { + day: SQLUINTEGER, + hour: SQLUINTEGER, + minute: SQLUINTEGER, + second: SQLUINTEGER, + fraction: SQLUINTEGER, +}} +UNION!{union SQL_INTERVAL_STRUCT_intval { + [u32; 5], + year_month year_month_mut: SQL_YEAR_MONTH_STRUCT, + day_second day_second_mut: SQL_DAY_SECOND_STRUCT, +}} +STRUCT!{struct SQL_INTERVAL_STRUCT { + interval_type: SQLINTERVAL, + interval_sign: SQLSMALLINT, + intval: SQL_INTERVAL_STRUCT_intval, +}} +pub type ODBCINT64 = __int64; +pub type SQLBIGINT = ODBCINT64; +pub type SQLUBIGINT = __uint64; +pub const SQL_MAX_NUMERIC_LEN: usize = 16; +STRUCT!{struct SQL_NUMERIC_STRUCT { + precision: SQLCHAR, + scale: SQLSCHAR, + sign: SQLCHAR, + val: [SQLCHAR; SQL_MAX_NUMERIC_LEN], +}} +pub type SQLGUID = GUID; +pub type BOOKMARK = SQLULEN; +pub type SQLWCHAR = wchar_t; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sqlucode.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sqlucode.rs new file mode 100644 index 0000000..b5ed4bf --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sqlucode.rs @@ -0,0 +1,106 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module defines the ODBC Core unicode functions +use um::sqltypes::{ + SQLCHAR, SQLHANDLE, SQLHDBC, SQLHSTMT, SQLHWND, SQLINTEGER, SQLRETURN, SQLSMALLINT, SQLULEN, + SQLUSMALLINT, SQLWCHAR +}; +pub const SQL_WCHAR: SQLSMALLINT = -8; +pub const SQL_WVARCHAR: SQLSMALLINT = -9; +pub const SQL_WLONGVARCHAR: SQLSMALLINT = -10; +pub const SQL_C_WCHAR: SQLSMALLINT = SQL_WCHAR; +extern "system" { + pub fn SQLConnectW( + connectionHandle: SQLHDBC, + serverName: *const SQLWCHAR, + nameLength1: SQLSMALLINT, + userName: *const SQLWCHAR, + nameLength2: SQLSMALLINT, + authentication: *const SQLWCHAR, + nameLength3: SQLSMALLINT, + ) -> SQLRETURN; + pub fn SQLDescribeColW( + statementHandle: SQLHSTMT, + columnNumber: SQLUSMALLINT, + columnName: *mut SQLWCHAR, + bufferLength: SQLSMALLINT, + nameLength: *mut SQLSMALLINT, + dataType: *mut SQLSMALLINT, + columnSize: *mut SQLULEN, + decimalDigits: *mut SQLSMALLINT, + nullable: *mut SQLSMALLINT, + ) -> SQLRETURN; + pub fn SQLExecDirectW( + statementHandle: SQLHSTMT, + statementText: *const SQLWCHAR, + textLength: SQLINTEGER, + ) -> SQLRETURN; + pub fn SQLGetDiagRecW( + handleType: SQLSMALLINT, + handle: SQLHANDLE, + recNumber: SQLSMALLINT, + sqlstate: *mut SQLWCHAR, + nativeError: *mut SQLINTEGER, + messageText: *mut SQLWCHAR, + bufferLength: SQLSMALLINT, + textLength: *mut SQLSMALLINT, + ) -> SQLRETURN; + pub fn SQLDriverConnectW( + hdbc: SQLHDBC, + hwnd: SQLHWND, + szConnStrIn: *const SQLWCHAR, + cchConnStrIn: SQLSMALLINT, + szConnStrOut: *mut SQLWCHAR, + cchConnStrOutMax: SQLSMALLINT, + pcchConnStrOut: *mut SQLSMALLINT, + fDriverCompletion: SQLUSMALLINT, + ) -> SQLRETURN; + pub fn SQLConnectA( + connectionHandle: SQLHDBC, + serverName: *const SQLCHAR, + nameLength1: SQLSMALLINT, + userName: *const SQLCHAR, + nameLength2: SQLSMALLINT, + authentication: *const SQLCHAR, + nameLength3: SQLSMALLINT, + ) -> SQLRETURN; + pub fn SQLDescribeColA( + statementHandle: SQLHSTMT, + columnNumber: SQLUSMALLINT, + columnName: *mut SQLCHAR, + bufferLength: SQLSMALLINT, + nameLength: *mut SQLSMALLINT, + dataType: *mut SQLSMALLINT, + columnSize: *mut SQLULEN, + decimalDigits: *mut SQLSMALLINT, + nullable: *mut SQLSMALLINT, + ) -> SQLRETURN; + pub fn SQLExecDirectA( + statementHandle: SQLHSTMT, + statementText: *const SQLCHAR, + textLength: SQLINTEGER, + ) -> SQLRETURN; + pub fn SQLGetDiagRecA( + handleType: SQLSMALLINT, + handle: SQLHANDLE, + recNumber: SQLSMALLINT, + sqlstate: *mut SQLCHAR, + nativeError: *mut SQLINTEGER, + messageText: *mut SQLCHAR, + bufferLength: SQLSMALLINT, + textLength: *mut SQLSMALLINT, + ) -> SQLRETURN; + pub fn SQLDriverConnectA( + hdbc: SQLHDBC, + hwnd: SQLHWND, + szConnStrIn: *const SQLCHAR, + cchConnStrIn: SQLSMALLINT, + szConnStrOut: *mut SQLCHAR, + cchConnStrOutMax: SQLSMALLINT, + pcchConnStrOut: *mut SQLSMALLINT, + fDriverCompletion: SQLUSMALLINT, + ) -> SQLRETURN; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sspi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sspi.rs new file mode 100644 index 0000000..edc0dbc --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sspi.rs @@ -0,0 +1,7 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Security Support Provider Interface Prototypes and structure definitions +pub use shared::sspi::*; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/stringapiset.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/stringapiset.rs new file mode 100644 index 0000000..61560ed --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/stringapiset.rs @@ -0,0 +1,75 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_int; +use shared::minwindef::{BOOL, DWORD, LPARAM, LPBOOL, LPVOID, LPWORD, UINT}; +use um::winnls::LPNLSVERSIONINFO; +use um::winnt::{LCID, LPCSTR, LPCWCH, LPCWSTR, LPSTR, LPWSTR, PCNZWCH}; +extern "system" { + pub fn CompareStringEx( + lpLocaleName: LPCWSTR, + dwCmpFlags: DWORD, + lpString1: LPCWCH, + cchCount1: c_int, + lpString2: LPCWCH, + cchCount2: c_int, + lpVersionInformation: LPNLSVERSIONINFO, + lpReserved: LPVOID, + lParam: LPARAM, + ) -> c_int; + pub fn CompareStringOrdinal( + lpString1: LPCWCH, + cchCount1: c_int, + lpString2: LPCWCH, + cchCount2: c_int, + bIgnoreCase: BOOL, + ) -> c_int; + pub fn CompareStringW( + Locale: LCID, + dwCmpFlags: DWORD, + lpString1: PCNZWCH, + cchCount1: c_int, + lpString2: PCNZWCH, + cchCount2: c_int, + ) -> c_int; + pub fn FoldStringW( + dwMapFlags: DWORD, + lpSrcStr: LPCWCH, + cchSrc: c_int, + lpDestStr: LPWSTR, + cchDest: c_int, + ) -> c_int; + pub fn GetStringTypeExW( + Locale: LCID, + dwInfoType: DWORD, + lpSrcStr: LPCWCH, + cchSrc: c_int, + lpCharType: LPWORD, + ) -> BOOL; + pub fn GetStringTypeW( + dwInfoType: DWORD, + lpSrcStr: LPCWCH, + cchSrc: c_int, + lpCharType: LPWORD, + ) -> BOOL; + pub fn MultiByteToWideChar( + CodePage: UINT, + dwFlags: DWORD, + lpMultiByteStr: LPCSTR, + cbMultiByte: c_int, + lpWideCharStr: LPWSTR, + cchWideChar: c_int, + ) -> c_int; + pub fn WideCharToMultiByte( + CodePage: UINT, + dwFlags: DWORD, + lpWideCharStr: LPCWSTR, + cchWideChar: c_int, + lpMultiByteStr: LPSTR, + cbMultiByte: c_int, + lpDefaultChar: LPCSTR, + lpUsedDefaultChar: LPBOOL, + ) -> c_int; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/strmif.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/strmif.rs new file mode 100644 index 0000000..db08afd --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/strmif.rs @@ -0,0 +1,7 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use um::winnt::LONGLONG; +pub type REFERENCE_TIME = LONGLONG; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/subauth.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/subauth.rs new file mode 100644 index 0000000..b5d539b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/subauth.rs @@ -0,0 +1,204 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Types and macros for Subauthentication Packages. +use shared::minwindef::{PUCHAR, ULONG, USHORT}; +use um::winnt::{BOOLEAN, CHAR, LARGE_INTEGER, LONG, PCHAR, PVOID, PWSTR}; +STRUCT!{struct UNICODE_STRING { + Length: USHORT, + MaximumLength: USHORT, + Buffer: PWSTR, +}} +pub type PUNICODE_STRING = *mut UNICODE_STRING; +STRUCT!{struct STRING { + Length: USHORT, + MaximumLength: USHORT, + Buffer: PCHAR, +}} +pub type PSTRING = *mut STRING; +STRUCT!{struct OLD_LARGE_INTEGER { + LowPart: ULONG, + HighPart: LONG, +}} +pub type POLD_LARGE_INTEGER = *mut OLD_LARGE_INTEGER; +pub type SAM_HANDLE = PVOID; +pub type PSAM_HANDLE = *mut PVOID; +pub const USER_ACCOUNT_DISABLED: ULONG = 0x00000001; +pub const USER_HOME_DIRECTORY_REQUIRED: ULONG = 0x00000002; +pub const USER_PASSWORD_NOT_REQUIRED: ULONG = 0x00000004; +pub const USER_TEMP_DUPLICATE_ACCOUNT: ULONG = 0x00000008; +pub const USER_NORMAL_ACCOUNT: ULONG = 0x00000010; +pub const USER_MNS_LOGON_ACCOUNT: ULONG = 0x00000020; +pub const USER_INTERDOMAIN_TRUST_ACCOUNT: ULONG = 0x00000040; +pub const USER_WORKSTATION_TRUST_ACCOUNT: ULONG = 0x00000080; +pub const USER_SERVER_TRUST_ACCOUNT: ULONG = 0x00000100; +pub const USER_DONT_EXPIRE_PASSWORD: ULONG = 0x00000200; +pub const USER_ACCOUNT_AUTO_LOCKED: ULONG = 0x00000400; +pub const USER_ENCRYPTED_TEXT_PASSWORD_ALLOWED: ULONG = 0x00000800; +pub const USER_SMARTCARD_REQUIRED: ULONG = 0x00001000; +pub const USER_TRUSTED_FOR_DELEGATION: ULONG = 0x00002000; +pub const USER_NOT_DELEGATED: ULONG = 0x00004000; +pub const USER_USE_DES_KEY_ONLY: ULONG = 0x00008000; +pub const USER_DONT_REQUIRE_PREAUTH: ULONG = 0x00010000; +pub const USER_PASSWORD_EXPIRED: ULONG = 0x00020000; +pub const USER_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION: ULONG = 0x00040000; +pub const USER_NO_AUTH_DATA_REQUIRED: ULONG = 0x00080000; +pub const USER_PARTIAL_SECRETS_ACCOUNT: ULONG = 0x00100000; +pub const USER_USE_AES_KEYS: ULONG = 0x00200000; +pub const NEXT_FREE_ACCOUNT_CONTROL_BIT: ULONG = USER_USE_AES_KEYS << 1; +pub const USER_MACHINE_ACCOUNT_MASK: ULONG = USER_INTERDOMAIN_TRUST_ACCOUNT + | USER_WORKSTATION_TRUST_ACCOUNT | USER_SERVER_TRUST_ACCOUNT; +pub const USER_ACCOUNT_TYPE_MASK: ULONG = USER_TEMP_DUPLICATE_ACCOUNT | USER_NORMAL_ACCOUNT + | USER_MACHINE_ACCOUNT_MASK; +pub const USER_COMPUTED_ACCOUNT_CONTROL_BITS: ULONG = USER_ACCOUNT_AUTO_LOCKED + | USER_PASSWORD_EXPIRED; +pub const SAM_DAYS_PER_WEEK: USHORT = 7; +pub const SAM_HOURS_PER_WEEK: USHORT = 24 * SAM_DAYS_PER_WEEK; +pub const SAM_MINUTES_PER_WEEK: USHORT = 60 * SAM_HOURS_PER_WEEK; +STRUCT!{struct LOGON_HOURS { + UnitsPerWeek: USHORT, + LogonHours: PUCHAR, +}} +pub type PLOGON_HOURS = *mut LOGON_HOURS; +STRUCT!{struct SR_SECURITY_DESCRIPTOR { + Length: ULONG, + SecurityDescriptor: PUCHAR, +}} +pub type PSR_SECURITY_DESCRIPTOR = *mut SR_SECURITY_DESCRIPTOR; +STRUCT!{struct USER_ALL_INFORMATION { + LastLogon: LARGE_INTEGER, + LastLogoff: LARGE_INTEGER, + PasswordLastSet: LARGE_INTEGER, + AccountExpires: LARGE_INTEGER, + PasswordCanChange: LARGE_INTEGER, + PasswordMustChange: LARGE_INTEGER, + UserName: UNICODE_STRING, + FullName: UNICODE_STRING, + HomeDirectory: UNICODE_STRING, + HomeDirectoryDrive: UNICODE_STRING, + ScriptPath: UNICODE_STRING, + ProfilePath: UNICODE_STRING, + AdminComment: UNICODE_STRING, + WorkStations: UNICODE_STRING, + UserComment: UNICODE_STRING, + Parameters: UNICODE_STRING, + LmPassword: UNICODE_STRING, + NtPassword: UNICODE_STRING, + PrivateData: UNICODE_STRING, + SecurityDescriptor: SR_SECURITY_DESCRIPTOR, + UserId: ULONG, + PrimaryGroupId: ULONG, + UserAccountControl: ULONG, + WhichFields: ULONG, + LogonHours: LOGON_HOURS, + BadPasswordCount: USHORT, + LogonCount: USHORT, + CountryCode: USHORT, + CodePage: USHORT, + LmPasswordPresent: BOOLEAN, + NtPasswordPresent: BOOLEAN, + PasswordExpired: BOOLEAN, + PrivateDataSensitive: BOOLEAN, +}} +pub type PUSER_ALL_INFORMATION = *mut USER_ALL_INFORMATION; +pub const USER_ALL_PARAMETERS: ULONG = 0x00200000; +pub const CLEAR_BLOCK_LENGTH: usize = 8; +STRUCT!{struct CLEAR_BLOCK { + data: [CHAR; CLEAR_BLOCK_LENGTH], +}} +pub type PCLEAR_BLOCK = *mut CLEAR_BLOCK; +pub const CYPHER_BLOCK_LENGTH: usize = 8; +STRUCT!{struct CYPHER_BLOCK { + data: [CHAR; CYPHER_BLOCK_LENGTH], +}} +pub type PCYPHER_BLOCK = *mut CYPHER_BLOCK; +STRUCT!{struct LM_OWF_PASSWORD { + data: [CYPHER_BLOCK; 2], +}} +pub type PLM_OWF_PASSWORD = *mut LM_OWF_PASSWORD; +pub type LM_CHALLENGE = CLEAR_BLOCK; +pub type PLM_CHALLENGE = *mut LM_CHALLENGE; +pub type NT_OWF_PASSWORD = LM_OWF_PASSWORD; +pub type PNT_OWF_PASSWORD = *mut NT_OWF_PASSWORD; +pub type NT_CHALLENGE = LM_CHALLENGE; +pub type PNT_CHALLENGE = *mut NT_CHALLENGE; +pub const USER_SESSION_KEY_LENGTH: usize = CYPHER_BLOCK_LENGTH * 2; +STRUCT!{struct USER_SESSION_KEY { + data: [CYPHER_BLOCK; 2], +}} +pub type PUSER_SESSION_KEY = *mut USER_SESSION_KEY; +ENUM!{enum NETLOGON_LOGON_INFO_CLASS { + NetlogonInteractiveInformation = 1, + NetlogonNetworkInformation, + NetlogonServiceInformation, + NetlogonGenericInformation, + NetlogonInteractiveTransitiveInformation, + NetlogonNetworkTransitiveInformation, + NetlogonServiceTransitiveInformation, +}} +STRUCT!{struct NETLOGON_LOGON_IDENTITY_INFO { + LogonDomainName: UNICODE_STRING, + ParameterControl: ULONG, + LogonId: OLD_LARGE_INTEGER, + UserName: UNICODE_STRING, + Workstation: UNICODE_STRING, +}} +pub type PNETLOGON_LOGON_IDENTITY_INFO = *mut NETLOGON_LOGON_IDENTITY_INFO; +STRUCT!{struct NETLOGON_INTERACTIVE_INFO { + Identity: NETLOGON_LOGON_IDENTITY_INFO, + LmOwfPassword: LM_OWF_PASSWORD, + NtOwfPassword: NT_OWF_PASSWORD, +}} +pub type PNETLOGON_INTERACTIVE_INFO = *mut NETLOGON_INTERACTIVE_INFO; +STRUCT!{struct NETLOGON_SERVICE_INFO { + Identity: NETLOGON_LOGON_IDENTITY_INFO, + LmOwfPassword: LM_OWF_PASSWORD, + NtOwfPassword: NT_OWF_PASSWORD, +}} +pub type PNETLOGON_SERVICE_INFO = *mut NETLOGON_SERVICE_INFO; +STRUCT!{struct NETLOGON_NETWORK_INFO { + Identity: NETLOGON_LOGON_IDENTITY_INFO, + LmChallenge: LM_CHALLENGE, + NtChallengeResponse: STRING, + LmChallengeResponse: STRING, +}} +pub type PNETLOGON_NETWORK_INFO = *mut NETLOGON_NETWORK_INFO; +STRUCT!{struct NETLOGON_GENERIC_INFO { + Identity: NETLOGON_LOGON_IDENTITY_INFO, + PackageName: UNICODE_STRING, + DataLength: ULONG, + LogonData: PUCHAR, +}} +pub type PNETLOGON_GENERIC_INFO = *mut NETLOGON_GENERIC_INFO; +pub const MSV1_0_PASSTHRU: ULONG = 0x01; +pub const MSV1_0_GUEST_LOGON: ULONG = 0x02; +STRUCT!{struct MSV1_0_VALIDATION_INFO { + LogoffTime: LARGE_INTEGER, + KickoffTime: LARGE_INTEGER, + LogonServer: UNICODE_STRING, + LogonDomainName: UNICODE_STRING, + SessionKey: USER_SESSION_KEY, + Authoritative: BOOLEAN, + UserFlags: ULONG, + WhichFields: ULONG, + UserId: ULONG, +}} +pub type PMSV1_0_VALIDATION_INFO = *mut MSV1_0_VALIDATION_INFO; +pub const MSV1_0_VALIDATION_LOGOFF_TIME: ULONG = 0x00000001; +pub const MSV1_0_VALIDATION_KICKOFF_TIME: ULONG = 0x00000002; +pub const MSV1_0_VALIDATION_LOGON_SERVER: ULONG = 0x00000004; +pub const MSV1_0_VALIDATION_LOGON_DOMAIN: ULONG = 0x00000008; +pub const MSV1_0_VALIDATION_SESSION_KEY: ULONG = 0x00000010; +pub const MSV1_0_VALIDATION_USER_FLAGS: ULONG = 0x00000020; +pub const MSV1_0_VALIDATION_USER_ID: ULONG = 0x00000040; +pub const MSV1_0_SUBAUTH_ACCOUNT_DISABLED: ULONG = 0x00000001; +pub const MSV1_0_SUBAUTH_PASSWORD: ULONG = 0x00000002; +pub const MSV1_0_SUBAUTH_WORKSTATIONS: ULONG = 0x00000004; +pub const MSV1_0_SUBAUTH_LOGON_HOURS: ULONG = 0x00000008; +pub const MSV1_0_SUBAUTH_ACCOUNT_EXPIRY: ULONG = 0x00000010; +pub const MSV1_0_SUBAUTH_PASSWORD_EXPIRY: ULONG = 0x00000020; +pub const MSV1_0_SUBAUTH_ACCOUNT_TYPE: ULONG = 0x00000040; +pub const MSV1_0_SUBAUTH_LOCKOUT: ULONG = 0x00000080; +// STATUS_* diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/synchapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/synchapi.rs new file mode 100644 index 0000000..205579e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/synchapi.rs @@ -0,0 +1,349 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-core-synch-l1 +use shared::basetsd::SIZE_T; +use shared::minwindef::{BOOL, DWORD, LPLONG, LPVOID, PBOOL, ULONG}; +use um::minwinbase::{ + LPCRITICAL_SECTION, LPSECURITY_ATTRIBUTES, PCRITICAL_SECTION, PREASON_CONTEXT, +}; +use um::winnt::{ + BOOLEAN, HANDLE, LARGE_INTEGER, LONG, LPCSTR, LPCWSTR, PRTL_BARRIER, PRTL_RUN_ONCE, + PVOID, RTL_BARRIER, RTL_CONDITION_VARIABLE, RTL_CONDITION_VARIABLE_INIT, + RTL_RUN_ONCE, RTL_SRWLOCK, RTL_SRWLOCK_INIT, VOID +}; +pub const SRWLOCK_INIT: SRWLOCK = RTL_SRWLOCK_INIT; +pub type SRWLOCK = RTL_SRWLOCK; +pub type PSRWLOCK = *mut RTL_SRWLOCK; +extern "system" { + pub fn InitializeSRWLock( + SRWLock: PSRWLOCK, + ); + pub fn ReleaseSRWLockExclusive( + SRWLock: PSRWLOCK, + ); + pub fn ReleaseSRWLockShared( + SRWLock: PSRWLOCK, + ); + pub fn AcquireSRWLockExclusive( + SRWLock: PSRWLOCK, + ); + pub fn AcquireSRWLockShared( + SRWLock: PSRWLOCK, + ); + pub fn TryAcquireSRWLockExclusive( + SRWLock: PSRWLOCK, + ) -> BOOLEAN; + pub fn TryAcquireSRWLockShared( + SRWLock: PSRWLOCK, + ) -> BOOLEAN; + pub fn InitializeCriticalSection( + lpCriticalSection: LPCRITICAL_SECTION, + ); + pub fn EnterCriticalSection( + lpCriticalSection: LPCRITICAL_SECTION, + ); + pub fn LeaveCriticalSection( + lpCriticalSection: LPCRITICAL_SECTION, + ); + pub fn InitializeCriticalSectionAndSpinCount( + lpCriticalSection: LPCRITICAL_SECTION, + dwSpinCount: DWORD, + ) -> BOOL; + pub fn InitializeCriticalSectionEx( + lpCriticalSection: LPCRITICAL_SECTION, + dwSpinCount: DWORD, + Flags: DWORD, + ) -> BOOL; + pub fn SetCriticalSectionSpinCount( + lpCriticalSection: LPCRITICAL_SECTION, + dwSpinCount: DWORD, + ) -> DWORD; + pub fn TryEnterCriticalSection( + lpCriticalSection: LPCRITICAL_SECTION, + ) -> BOOL; + pub fn DeleteCriticalSection( + lpCriticalSection: LPCRITICAL_SECTION, + ); +} +pub type INIT_ONCE = RTL_RUN_ONCE; +pub type PINIT_ONCE = PRTL_RUN_ONCE; +pub type LPINIT_ONCE = PRTL_RUN_ONCE; +//pub const INIT_ONCE_STATIC_INIT: INIT_ONCE = RTL_RUN_ONCE_INIT; +//pub const INIT_ONCE_CHECK_ONLY: ULONG = RTL_RUN_ONCE_CHECK_ONLY; +//pub const INIT_ONCE_ASYNC: ULONG = RTL_RUN_ONCE_ASYNC; +//pub const INIT_ONCE_INIT_FAILED: ULONG = RTL_RUN_ONCE_INIT_FAILED; +//pub const INIT_ONCE_CTX_RESERVED_BITS: usize = RTL_RUN_ONCE_CTX_RESERVED_BITS; +FN!{stdcall PINIT_ONCE_FN( + InitOnce: PINIT_ONCE, + Parameter: PVOID, + Context: *mut PVOID, +) -> BOOL} +extern "system" { + pub fn InitOnceInitialize( + InitOnce: PINIT_ONCE, + ); + pub fn InitOnceExecuteOnce( + InitOnce: PINIT_ONCE, + InitFn: PINIT_ONCE_FN, + Parameter: PVOID, + Context: *mut LPVOID, + ) -> BOOL; + pub fn InitOnceBeginInitialize( + lpInitOnce: LPINIT_ONCE, + dwFlags: DWORD, + fPending: PBOOL, + lpContext: *mut LPVOID, + ) -> BOOL; + pub fn InitOnceComplete( + lpInitOnce: LPINIT_ONCE, + dwFlags: DWORD, + lpContext: LPVOID, + ) -> BOOL; +} +pub type CONDITION_VARIABLE = RTL_CONDITION_VARIABLE; +pub type PCONDITION_VARIABLE = *mut CONDITION_VARIABLE; +pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = RTL_CONDITION_VARIABLE_INIT; +//pub const CONDITION_VARIABLE_LOCKMODE_SHARED: ULONG = RTL_CONDITION_VARIABLE_LOCKMODE_SHARED; +extern "system" { + pub fn InitializeConditionVariable( + ConditionVariable: PCONDITION_VARIABLE, + ); + pub fn WakeConditionVariable( + ConditionVariable: PCONDITION_VARIABLE, + ); + pub fn WakeAllConditionVariable( + ConditionVariable: PCONDITION_VARIABLE, + ); + pub fn SleepConditionVariableCS( + ConditionVariable: PCONDITION_VARIABLE, + CriticalSection: PCRITICAL_SECTION, + dwMilliseconds: DWORD, + ) -> BOOL; + pub fn SleepConditionVariableSRW( + ConditionVariable: PCONDITION_VARIABLE, + SRWLock: PSRWLOCK, + dwMilliseconds: DWORD, + Flags: ULONG, + ) -> BOOL; + pub fn SetEvent( + hEvent: HANDLE, + ) -> BOOL; + pub fn ResetEvent( + hEvent: HANDLE, + ) -> BOOL; + pub fn ReleaseSemaphore( + hSemaphore: HANDLE, + lReleaseCount: LONG, + lpPreviousCount: LPLONG, + ) -> BOOL; + pub fn ReleaseMutex( + hMutex: HANDLE, + ) -> BOOL; + pub fn WaitForSingleObject( + hHandle: HANDLE, + dwMilliseconds: DWORD, + ) -> DWORD; + pub fn SleepEx( + dwMilliseconds: DWORD, + bAlertable: BOOL, + ) -> DWORD; + pub fn WaitForSingleObjectEx( + hHandle: HANDLE, + dwMilliseconds: DWORD, + bAlertable: BOOL, + ) -> DWORD; + pub fn WaitForMultipleObjectsEx( + nCount: DWORD, + lpHandles: *const HANDLE, + bWaitAll: BOOL, + dwMilliseconds: DWORD, + bAlertable: BOOL, + ) -> DWORD; +} +//pub const MUTEX_MODIFY_STATE: DWORD = MUTANT_QUERY_STATE; +//pub const MUTEX_ALL_ACCESS: DWORD = MUTANT_ALL_ACCESS; +extern "system" { + pub fn CreateMutexA( + lpMutexAttributes: LPSECURITY_ATTRIBUTES, + bInitialOwner: BOOL, + lpName: LPCSTR, + ) -> HANDLE; + pub fn CreateMutexW( + lpMutexAttributes: LPSECURITY_ATTRIBUTES, + bInitialOwner: BOOL, + lpName: LPCWSTR, + ) -> HANDLE; + pub fn OpenMutexW( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpName: LPCWSTR, + ) -> HANDLE; + pub fn CreateEventA( + lpEventAttributes: LPSECURITY_ATTRIBUTES, + bManualReset: BOOL, + bInitialState: BOOL, + lpName: LPCSTR, + ) -> HANDLE; + pub fn CreateEventW( + lpEventAttributes: LPSECURITY_ATTRIBUTES, + bManualReset: BOOL, + bInitialState: BOOL, + lpName: LPCWSTR, + ) -> HANDLE; + pub fn OpenEventA( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpName: LPCSTR, + ) -> HANDLE; + pub fn OpenEventW( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpName: LPCWSTR, + ) -> HANDLE; + pub fn OpenSemaphoreW( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpName: LPCWSTR, + ) -> HANDLE; +} +FN!{stdcall PTIMERAPCROUTINE( + lpArgToCompletionRoutine: LPVOID, + dwTimerLowValue: DWORD, + dwTimerHighValue: DWORD, +) -> ()} +extern "system" { + pub fn OpenWaitableTimerW( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpTimerName: LPCWSTR, + ) -> HANDLE; + pub fn SetWaitableTimerEx( + hTimer: HANDLE, + lpDueTime: *const LARGE_INTEGER, + lPeriod: LONG, + pfnCompletionRoutine: PTIMERAPCROUTINE, + lpArgToCompletionRoutine: LPVOID, + WakeContext: PREASON_CONTEXT, + TolerableDelay: ULONG, + ) -> BOOL; + pub fn SetWaitableTimer( + hTimer: HANDLE, + lpDueTime: *const LARGE_INTEGER, + lPeriod: LONG, + pfnCompletionRoutine: PTIMERAPCROUTINE, + lpArgToCompletionRoutine: LPVOID, + fResume: BOOL, + ) -> BOOL; + pub fn CancelWaitableTimer( + hTimer: HANDLE, + ) -> BOOL; +} +pub const CREATE_MUTEX_INITIAL_OWNER: DWORD = 0x00000001; +extern "system" { + pub fn CreateMutexExA( + lpMutexAttributes: LPSECURITY_ATTRIBUTES, + lpName: LPCSTR, + dwFlags: DWORD, + dwDesiredAccess: DWORD, + ) -> HANDLE; + pub fn CreateMutexExW( + lpMutexAttributes: LPSECURITY_ATTRIBUTES, + lpName: LPCWSTR, + dwFlags: DWORD, + dwDesiredAccess: DWORD, + ) -> HANDLE; +} +pub const CREATE_EVENT_MANUAL_RESET: DWORD = 0x00000001; +pub const CREATE_EVENT_INITIAL_SET: DWORD = 0x00000002; +extern "system" { + pub fn CreateEventExA( + lpEventAttributes: LPSECURITY_ATTRIBUTES, + lpName: LPCSTR, + dwFlags: DWORD, + dwDesiredAccess: DWORD, + ) -> HANDLE; + pub fn CreateEventExW( + lpEventAttributes: LPSECURITY_ATTRIBUTES, + lpName: LPCWSTR, + dwFlags: DWORD, + dwDesiredAccess: DWORD, + ) -> HANDLE; + pub fn CreateSemaphoreExW( + lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, + lInitialCount: LONG, + lMaximumCount: LONG, + lpName: LPCWSTR, + dwFlags: DWORD, + dwDesiredAccess: DWORD, + ) -> HANDLE; +} +pub const CREATE_WAITABLE_TIMER_MANUAL_RESET: DWORD = 0x00000001; +extern "system" { + pub fn CreateWaitableTimerExW( + lpTimerAttributes: LPSECURITY_ATTRIBUTES, + lpTimerName: LPCWSTR, + dwFlags: DWORD, + dwDesiredAccess: DWORD, + ) -> HANDLE; +} +pub type SYNCHRONIZATION_BARRIER = RTL_BARRIER; +pub type PSYNCHRONIZATION_BARRIER = PRTL_BARRIER; +pub type LPSYNCHRONIZATION_BARRIER = PRTL_BARRIER; +pub const SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY: DWORD = 0x01; +pub const SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY: DWORD = 0x02; +pub const SYNCHRONIZATION_BARRIER_FLAGS_NO_DELETE: DWORD = 0x04; +extern "system" { + pub fn EnterSynchronizationBarrier( + lpBarrier: LPSYNCHRONIZATION_BARRIER, + dwFlags: DWORD, + ) -> BOOL; + pub fn InitializeSynchronizationBarrier( + lpBarrier: LPSYNCHRONIZATION_BARRIER, + lTotalThreads: LONG, + lSpinCount: LONG, + ) -> BOOL; + pub fn DeleteSynchronizationBarrier( + lpBarrier: LPSYNCHRONIZATION_BARRIER, + ) -> BOOL; + pub fn Sleep( + dwMilliseconds: DWORD, + ); + pub fn WaitOnAddress( + Address: *mut VOID, + CompareAddress: PVOID, + AddressSize: SIZE_T, + dwMilliseconds: DWORD, + ) -> BOOL; + pub fn WakeByAddressSingle( + Address: PVOID, + ); + pub fn WakeByAddressAll( + Address: PVOID, + ); + pub fn SignalObjectAndWait( + hObjectToSignal: HANDLE, + hObjectToWaitOn: HANDLE, + dwMilliseconds: DWORD, + bAlertable: BOOL, + ) -> DWORD; + pub fn WaitForMultipleObjects( + nCount: DWORD, + lpHandles: *const HANDLE, + bWaitAll: BOOL, + dwMilliseconds: DWORD, + ) -> DWORD; + pub fn CreateSemaphoreW( + lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, + lInitialCount: LONG, + lMaximumCount: LONG, + lpName: LPCWSTR, + ) -> HANDLE; + pub fn CreateWaitableTimerW( + lpTimerAttributes: LPSECURITY_ATTRIBUTES, + bManualReset: BOOL, + lpTimerName: LPCWSTR, + ) -> HANDLE; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/sysinfoapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/sysinfoapi.rs new file mode 100644 index 0000000..03bdb47 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/sysinfoapi.rs @@ -0,0 +1,217 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-core-sysinfo-l1. +use shared::basetsd::DWORD_PTR; +use shared::minwindef::{ + BOOL, BYTE, DWORD, LPDWORD, LPFILETIME, LPVOID, PBOOL, PDWORD, UINT, USHORT, WORD, +}; +use um::minwinbase::{LPSYSTEMTIME, SYSTEMTIME}; +use um::winnt::{ + DWORDLONG, HANDLE, LOGICAL_PROCESSOR_RELATIONSHIP, LPCSTR, LPCWSTR, LPOSVERSIONINFOA, + LPOSVERSIONINFOW, LPSTR, LPWSTR, PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, + PSYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION, PULONGLONG, PVOID, ULONGLONG, +}; +STRUCT!{struct SYSTEM_INFO_u_s { + wProcessorArchitecture: WORD, + wReserved: WORD, +}} +UNION!{union SYSTEM_INFO_u { + [u32; 1], + dwOemId dwOemId_mut: DWORD, + s s_mut: SYSTEM_INFO_u_s, +}} +STRUCT!{struct SYSTEM_INFO { + u: SYSTEM_INFO_u, + dwPageSize: DWORD, + lpMinimumApplicationAddress: LPVOID, + lpMaximumApplicationAddress: LPVOID, + dwActiveProcessorMask: DWORD_PTR, + dwNumberOfProcessors: DWORD, + dwProcessorType: DWORD, + dwAllocationGranularity: DWORD, + wProcessorLevel: WORD, + wProcessorRevision: WORD, +}} +pub type LPSYSTEM_INFO = *mut SYSTEM_INFO; +STRUCT!{struct MEMORYSTATUSEX { + dwLength: DWORD, + dwMemoryLoad: DWORD, + ullTotalPhys: DWORDLONG, + ullAvailPhys: DWORDLONG, + ullTotalPageFile: DWORDLONG, + ullAvailPageFile: DWORDLONG, + ullTotalVirtual: DWORDLONG, + ullAvailVirtual: DWORDLONG, + ullAvailExtendedVirtual: DWORDLONG, +}} +pub type LPMEMORYSTATUSEX = *mut MEMORYSTATUSEX; +extern "system" { + pub fn GlobalMemoryStatusEx( + lpBuffer: LPMEMORYSTATUSEX, + ) -> BOOL; + pub fn GetSystemInfo( + lpSystemInfo: LPSYSTEM_INFO, + ); + pub fn GetSystemTime( + lpSystemTime: LPSYSTEMTIME, + ); + pub fn GetSystemTimeAsFileTime( + lpSystemTimeAsFileTime: LPFILETIME, + ); + pub fn GetLocalTime( + lpSystemTime: LPSYSTEMTIME, + ); + pub fn GetVersion() -> DWORD; + pub fn SetLocalTime( + lpSystemTime: *const SYSTEMTIME, + ) -> BOOL; + pub fn GetTickCount() -> DWORD; + pub fn GetTickCount64() -> ULONGLONG; + pub fn GetSystemTimeAdjustment( + lpTimeAdjustment: PDWORD, + lpTimeIncrement: PDWORD, + lpTimeAdjustmentDisabled: PBOOL, + ) -> BOOL; + pub fn GetSystemDirectoryA( + lpBuffer: LPSTR, + uSize: UINT, + ) -> UINT; + pub fn GetSystemDirectoryW( + lpBuffer: LPWSTR, + uSize: UINT, + ) -> UINT; + pub fn GetWindowsDirectoryA( + lpBuffer: LPSTR, + uSize: UINT, + ) -> UINT; + pub fn GetWindowsDirectoryW( + lpBuffer: LPWSTR, + uSize: UINT, + ) -> UINT; + pub fn GetSystemWindowsDirectoryA( + lpBuffer: LPSTR, + uSize: UINT, + ) -> UINT; + pub fn GetSystemWindowsDirectoryW( + lpBuffer: LPWSTR, + uSize: UINT, + ) -> UINT; +} +ENUM!{enum COMPUTER_NAME_FORMAT { + ComputerNameNetBIOS, + ComputerNameDnsHostname, + ComputerNameDnsDomain, + ComputerNameDnsFullyQualified, + ComputerNamePhysicalNetBIOS, + ComputerNamePhysicalDnsHostname, + ComputerNamePhysicalDnsDomain, + ComputerNamePhysicalDnsFullyQualified, + ComputerNameMax, +}} +extern "system" { + pub fn GetComputerNameExA( + NameType: COMPUTER_NAME_FORMAT, + lpBuffer: LPSTR, + nSize: LPDWORD, + ) -> BOOL; + pub fn GetComputerNameExW( + NameType: COMPUTER_NAME_FORMAT, + lpBuffer: LPWSTR, + nSize: LPDWORD, + ) -> BOOL; + pub fn SetComputerNameExW( + NameType: COMPUTER_NAME_FORMAT, + lpBuffer: LPCWSTR, + ) -> BOOL; + pub fn SetSystemTime( + lpSystemTime: *const SYSTEMTIME, + ) -> BOOL; + pub fn GetVersionExA( + lpVersionInformation: LPOSVERSIONINFOA, + ) -> BOOL; + pub fn GetVersionExW( + lpVersionInformation: LPOSVERSIONINFOW, + ) -> BOOL; + pub fn GetLogicalProcessorInformation( + Buffer: PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, + ReturnedLength: PDWORD, + ) -> BOOL; + pub fn GetLogicalProcessorInformationEx( + RelationshipType: LOGICAL_PROCESSOR_RELATIONSHIP, + Buffer: PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, + ReturnedLength: PDWORD, + ) -> BOOL; + pub fn GetNativeSystemInfo( + lpSystemInfo: LPSYSTEM_INFO, + ); + pub fn GetSystemTimePreciseAsFileTime( + lpSystemTimeAsFileTime: LPFILETIME, + ); + pub fn GetProductInfo( + dwOSMajorVersion: DWORD, + dwOSMinorVersion: DWORD, + dwSpMajorVersion: DWORD, + dwSpMinorVersion: DWORD, + pdwReturnedProductType: PDWORD, + ) -> BOOL; + pub fn VerSetConditionMask( + ConditionMask: ULONGLONG, + TypeMask: DWORD, + Condition: BYTE, + ) -> ULONGLONG; + // pub fn GetOsSafeBootMode(); + pub fn EnumSystemFirmwareTables( + FirmwareTableProviderSignature: DWORD, + pFirmwareTableEnumBuffer: PVOID, + BufferSize: DWORD, + ) -> UINT; + pub fn GetSystemFirmwareTable( + FirmwareTableProviderSignature: DWORD, + FirmwareTableID: DWORD, + pFirmwareTableBuffer: PVOID, + BufferSize: DWORD, + ) -> UINT; + pub fn DnsHostnameToComputerNameExW( + Hostname: LPCWSTR, + ComputerName: LPWSTR, + nSize: LPDWORD, + ) -> BOOL; + pub fn GetPhysicallyInstalledSystemMemory( + TotalMemoryInKilobytes: PULONGLONG, + ) -> BOOL; +} +pub const SCEX2_ALT_NETBIOS_NAME: DWORD = 0x00000001; +extern "system" { + pub fn SetComputerNameEx2W( + NameType: COMPUTER_NAME_FORMAT, + Flags: DWORD, + lpBuffer: LPCWSTR, + ) -> BOOL; + pub fn SetSystemTimeAdjustment( + dwTimeAdjustment: DWORD, + bTimeAdjustmentDisabled: BOOL, + ) -> BOOL; + pub fn InstallELAMCertificateInfo( + ELAMFile: HANDLE, + ) -> BOOL; + pub fn GetProcessorSystemCycleTime( + Group: USHORT, + Buffer: PSYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION, + ReturnedLength: PDWORD, + ) -> BOOL; + // pub fn GetOsManufacturingMode(); + // pub fn GetIntegratedDisplaySize(); + pub fn SetComputerNameA( + lpComputerName: LPCSTR, + ) -> BOOL; + pub fn SetComputerNameW( + lpComputerName: LPCWSTR, + ) -> BOOL; + pub fn SetComputerNameExA( + NameType: COMPUTER_NAME_FORMAT, + lpBuffer: LPCSTR, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/systemtopologyapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/systemtopologyapi.rs new file mode 100644 index 0000000..8591fac --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/systemtopologyapi.rs @@ -0,0 +1,20 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, PULONG, PUSHORT, ULONG, USHORT}; +use um::winnt::PGROUP_AFFINITY; +extern "system" { + pub fn GetNumaHighestNodeNumber( + HighestNodeNumber: PULONG, + ) -> BOOL; + pub fn GetNumaNodeProcessorMaskEx( + Node: USHORT, + ProcessorMask: PGROUP_AFFINITY, + ) -> BOOL; + pub fn GetNumaProximityNodeEx( + ProximityId: ULONG, + NodeNumber: PUSHORT, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/taskschd.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/taskschd.rs new file mode 100644 index 0000000..d73786c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/taskschd.rs @@ -0,0 +1,1233 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_long, c_short}; +use shared::minwindef::{DWORD, INT}; +use shared::wtypes::{BSTR, DATE, VARIANT_BOOL}; +use um::minwinbase::SYSTEMTIME; +use um::oaidl::{IDispatch, IDispatchVtbl, SAFEARRAY, VARIANT}; +use um::unknwnbase::{IUnknown, IUnknownVtbl, LPUNKNOWN}; +use um::winnt::{HRESULT, LONG}; +RIDL!{#[uuid(0x0f87369f, 0xa4e5, 0x4cfc, 0xbd, 0x3e, 0x73, 0xe6, 0x15, 0x45, 0x72, 0xdd)] +class TaskScheduler;} +RIDL!{#[uuid(0xf2a69db7, 0xda2c, 0x4352, 0x90, 0x66, 0x86, 0xfe, 0xe6, 0xda, 0xca, 0xc9)] +class TaskHandlerPS;} +RIDL!{#[uuid(0x9f15266d, 0xd7ba, 0x48f0, 0x93, 0xc1, 0xe6, 0x89, 0x5f, 0x6f, 0xe5, 0xac)] +class TaskHandlerStatusPS;} +RIDL!{#[uuid(0x79184a66, 0x8664, 0x423f, 0x97, 0xf1, 0x63, 0x73, 0x56, 0xa5, 0xd8, 0x12)] +interface ITaskFolderCollection(ITaskFolderCollectionVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + pCount: *mut LONG, + ) -> HRESULT, + fn get_Item( + index: VARIANT, + ppFolder: *mut *mut ITaskFolder, + ) -> HRESULT, + fn get__NewEnum( + ppEnum: *mut LPUNKNOWN, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8cfac062, 0xa080, 0x4c15, 0x9a, 0x88, 0xaa, 0x7c, 0x2a, 0xf8, 0x0d, 0xfc)] +interface ITaskFolder(ITaskFolderVtbl): IDispatch(IDispatchVtbl) { + fn get_Name( + pName: *mut BSTR, + ) -> HRESULT, + fn get_Path( + pPath: *mut BSTR, + ) -> HRESULT, + fn GetFolder( + Path: BSTR, + ppFolder: *mut *mut ITaskFolder, + ) -> HRESULT, + fn GetFolders( + flags: LONG, + ppFolders: *mut *mut ITaskFolderCollection, + ) -> HRESULT, + fn CreateFolder( + subFolderName: BSTR, + sddl: VARIANT, + ppFolder: *mut *mut ITaskFolder, + ) -> HRESULT, + fn DeleteFolder( + subFolderName: BSTR, + flags: LONG, + ) -> HRESULT, + fn GetTask( + Path: BSTR, + ppTask: *mut *mut IRegisteredTask, + ) -> HRESULT, + fn GetTasks( + flags: LONG, + ppTasks: *mut *mut IRegisteredTaskCollection, + ) -> HRESULT, + fn DeleteTask( + Name: BSTR, + flags: LONG, + ) -> HRESULT, + fn RegisterTask( + Path: BSTR, + XmlText: BSTR, + flags: LONG, + UserId: VARIANT, + password: VARIANT, + LogonType: TASK_LOGON_TYPE, + sddl: VARIANT, + ppTask: *mut *mut IRegisteredTask, + ) -> HRESULT, + fn RegisterTaskDefinition( + Path: BSTR, + pDefinition: *const ITaskDefinition, + flags: LONG, + UserId: VARIANT, + password: VARIANT, + LogonType: TASK_LOGON_TYPE, + sddl: VARIANT, + ppTask: *mut *mut IRegisteredTask, + ) -> HRESULT, + fn GetSecurityDescriptor( + securityInformation: LONG, + pSddl: *mut BSTR, + ) -> HRESULT, + fn SetSecurityDescriptor( + sddl: BSTR, + flags: LONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9c86f320, 0xdee3, 0x4dd1, 0xb9, 0x72, 0xa3, 0x03, 0xf2, 0x6b, 0x06, 0x1e)] +interface IRegisteredTask(IRegisteredTaskVtbl): IDispatch(IDispatchVtbl) { + fn get_Name( + pName: *mut BSTR, + ) -> HRESULT, + fn get_Path( + pPath: *mut BSTR, + ) -> HRESULT, + fn get_State( + pState: *mut TASK_STATE, + ) -> HRESULT, + fn get_Enabled( + pEnabled: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Enabled( + pEnabled: VARIANT_BOOL, + ) -> HRESULT, + fn Run( + params: VARIANT, + ppRunningTask: *mut *mut IRunningTask, + ) -> HRESULT, + fn RunEx( + params: VARIANT, + flags: LONG, + sessionID: LONG, + user: BSTR, + ppRunningTask: *mut *mut IRunningTask, + ) -> HRESULT, + fn GetInstances( + flags: LONG, + ppRunningTasks: *mut *mut IRunningTaskCollection, + ) -> HRESULT, + fn get_LastRunTime( + pLastRunTime: *mut DATE, + ) -> HRESULT, + fn get_LastTaskResult( + pLastTaskResult: *mut LONG, + ) -> HRESULT, + fn get_NumberOfMissedRuns( + pNumberOfMissedRuns: *mut LONG, + ) -> HRESULT, + fn get_NextRunTime( + pNextRunTime: *mut DATE, + ) -> HRESULT, + fn get_Definition( + ppDefinition: *mut *mut ITaskDefinition, + ) -> HRESULT, + fn get_Xml( + pXml: *mut BSTR, + ) -> HRESULT, + fn GetSecurityDescriptor( + securityInformation: LONG, + pSddl: *mut BSTR, + ) -> HRESULT, + fn SetSecurityDescriptor( + sddl: BSTR, + flags: LONG, + ) -> HRESULT, + fn Stop( + flags: LONG, + ) -> HRESULT, + fn GetRunTimes( + pstStart: *const SYSTEMTIME, + pstEnd: *const SYSTEMTIME, + pCount: *mut DWORD, + pRunTimes: *mut *mut SYSTEMTIME, + ) -> HRESULT, +}} +ENUM!{enum TASK_STATE { + TASK_STATE_UNKNOWN = 0, + TASK_STATE_DISABLED = 1, + TASK_STATE_QUEUED = 2, + TASK_STATE_READY = 3, + TASK_STATE_RUNNING = 4, +}} +RIDL!{#[uuid(0x653758fb, 0x7b9a, 0x4f1e, 0xa4, 0x71, 0xbe, 0xeb, 0x8e, 0x9b, 0x83, 0x4e)] +interface IRunningTask(IRunningTaskVtbl): IDispatch(IDispatchVtbl) { + fn get_Name( + pName: *mut BSTR, + ) -> HRESULT, + fn get_InstanceGuid( + pGuid: *mut BSTR, + ) -> HRESULT, + fn get_Path( + pPath: *mut BSTR, + ) -> HRESULT, + fn get_State( + pState: *mut TASK_STATE, + ) -> HRESULT, + fn get_CurrentAction( + pName: *mut BSTR, + ) -> HRESULT, + fn Stop() -> HRESULT, + fn Refresh() -> HRESULT, + fn get_EnginePID( + pPID: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6a67614b, 0x6828, 0x4fec, 0xaa, 0x54, 0x6d, 0x52, 0xe8, 0xf1, 0xf2, 0xdb)] +interface IRunningTaskCollection(IRunningTaskCollectionVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + pCount: *mut LONG, + ) -> HRESULT, + fn get_Item( + index: VARIANT, + ppRunningTask: *mut *mut IRunningTask, + ) -> HRESULT, + fn get__NewEnum( + ppEnum: *mut LPUNKNOWN, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf5bc8fc5, 0x536d, 0x4f77, 0xb8, 0x52, 0xfb, 0xc1, 0x35, 0x6f, 0xde, 0xb6)] +interface ITaskDefinition(ITaskDefinitionVtbl): IDispatch(IDispatchVtbl) { + fn get_RegistrationInfo( + ppRegistrationInfo: *mut *mut IRegistrationInfo, + ) -> HRESULT, + fn put_RegistrationInfo( + ppRegistrationInfo: *const IRegistrationInfo, + ) -> HRESULT, + fn get_Triggers( + ppTriggers: *mut *mut ITriggerCollection, + ) -> HRESULT, + fn put_Triggers( + ppTriggers: *const ITriggerCollection, + ) -> HRESULT, + fn get_Settings( + ppSettings: *mut *mut ITaskSettings, + ) -> HRESULT, + fn put_Settings( + ppSettings: *const ITaskSettings, + ) -> HRESULT, + fn get_Data( + pData: *mut BSTR, + ) -> HRESULT, + fn put_Data( + pData: BSTR, + ) -> HRESULT, + fn get_Principal( + ppPrincipal: *mut *mut IPrincipal, + ) -> HRESULT, + fn put_Principal( + ppPrincipal: *const IPrincipal, + ) -> HRESULT, + fn get_Actions( + ppActions: *mut *mut IActionCollection, + ) -> HRESULT, + fn put_Actions( + ppActions: *const IActionCollection, + ) -> HRESULT, + fn get_XmlText( + pXml: *mut BSTR, + ) -> HRESULT, + fn put_XmlText( + pXml: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x416d8b73, 0xcb41, 0x4ea1, 0x80, 0x5c, 0x9b, 0xe9, 0xa5, 0xac, 0x4a, 0x74)] +interface IRegistrationInfo(IRegistrationInfoVtbl): IDispatch(IDispatchVtbl) { + fn get_Description( + pDescription: *mut BSTR, + ) -> HRESULT, + fn put_Description( + pDescription: BSTR, + ) -> HRESULT, + fn get_Author( + pAuthor: *mut BSTR, + ) -> HRESULT, + fn put_Author( + pAuthor: BSTR, + ) -> HRESULT, + fn get_Version( + pVersion: *mut BSTR, + ) -> HRESULT, + fn put_Version( + pVersion: BSTR, + ) -> HRESULT, + fn get_Date( + pDate: *mut BSTR, + ) -> HRESULT, + fn put_Date( + pDate: BSTR, + ) -> HRESULT, + fn get_Documentation( + pDocumentation: *mut BSTR, + ) -> HRESULT, + fn put_Documentation( + pDocumentation: BSTR, + ) -> HRESULT, + fn get_XmlText( + pText: *mut BSTR, + ) -> HRESULT, + fn put_XmlText( + pText: BSTR, + ) -> HRESULT, + fn get_URI( + pUri: *mut BSTR, + ) -> HRESULT, + fn put_URI( + pUri: BSTR, + ) -> HRESULT, + fn get_SecurityDescriptor( + pSddl: *mut VARIANT, + ) -> HRESULT, + fn put_SecurityDescriptor( + pSddl: VARIANT, + ) -> HRESULT, + fn get_Source( + pSource: *mut BSTR, + ) -> HRESULT, + fn put_Source( + pSource: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x85df5081, 0x1b24, 0x4f32, 0x87, 0x8a, 0xd9, 0xd1, 0x4d, 0xf4, 0xcb, 0x77)] +interface ITriggerCollection(ITriggerCollectionVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + pCount: *mut c_long, + ) -> HRESULT, + fn get_Item( + index: c_long, + ppTrigger: *mut *mut ITrigger, + ) -> HRESULT, + fn get__NewEnum( + ppEnum: *mut LPUNKNOWN, + ) -> HRESULT, + fn Create( + Type: TASK_TRIGGER_TYPE2, + ppTrigger: *mut *mut ITrigger, + ) -> HRESULT, + fn Remove( + index: VARIANT, + ) -> HRESULT, + fn Clear() -> HRESULT, +}} +RIDL!{#[uuid(0x09941815, 0xea89, 0x4b5b, 0x89, 0xe0, 0x2a, 0x77, 0x38, 0x01, 0xfa, 0xc3)] +interface ITrigger(ITriggerVtbl): IDispatch(IDispatchVtbl) { + fn get_Type( + pType: *mut TASK_TRIGGER_TYPE2, + ) -> HRESULT, + fn get_Id( + pId: *mut BSTR, + ) -> HRESULT, + fn put_Id( + pId: BSTR, + ) -> HRESULT, + fn get_Repetition( + ppRepeat: *mut *mut IRepetitionPattern, + ) -> HRESULT, + fn put_Repetition( + ppRepeat: *const IRepetitionPattern, + ) -> HRESULT, + fn get_ExecutionTimeLimit( + pTimeLimit: *mut BSTR, + ) -> HRESULT, + fn put_ExecutionTimeLimit( + pTimeLimit: BSTR, + ) -> HRESULT, + fn get_StartBoundary( + pStart: *mut BSTR, + ) -> HRESULT, + fn put_StartBoundary( + pStart: BSTR, + ) -> HRESULT, + fn get_EndBoundary( + pEnd: *mut BSTR, + ) -> HRESULT, + fn put_EndBoundary( + pEnd: BSTR, + ) -> HRESULT, + fn get_Enabled( + pEnabled: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Enabled( + pEnabled: VARIANT_BOOL, + ) -> HRESULT, +}} +ENUM!{enum TASK_TRIGGER_TYPE2 { + TASK_TRIGGER_EVENT = 0, + TASK_TRIGGER_TIME = 1, + TASK_TRIGGER_DAILY = 2, + TASK_TRIGGER_WEEKLY = 3, + TASK_TRIGGER_MONTHLY = 4, + TASK_TRIGGER_MONTHLYDOW = 5, + TASK_TRIGGER_IDLE = 6, + TASK_TRIGGER_REGISTRATION = 7, + TASK_TRIGGER_BOOT = 8, + TASK_TRIGGER_LOGON = 9, + TASK_TRIGGER_SESSION_STATE_CHANGE = 11, + TASK_TRIGGER_CUSTOM_TRIGGER_01 = 12, +}} +RIDL!{#[uuid(0x7fb9acf1, 0x26be, 0x400e, 0x85, 0xb5, 0x29, 0x4b, 0x9c, 0x75, 0xdf, 0xd6)] +interface IRepetitionPattern(IRepetitionPatternVtbl): IDispatch(IDispatchVtbl) { + fn get_Interval( + pInterval: *mut BSTR, + ) -> HRESULT, + fn put_Interval( + pInterval: BSTR, + ) -> HRESULT, + fn get_Duration( + pDuration: *mut BSTR, + ) -> HRESULT, + fn put_Duration( + pDuration: BSTR, + ) -> HRESULT, + fn get_StopAtDurationEnd( + pStop: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_StopAtDurationEnd( + pStop: VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8fd4711d, 0x2d02, 0x4c8c, 0x87, 0xe3, 0xef, 0xf6, 0x99, 0xde, 0x12, 0x7e)] +interface ITaskSettings(ITaskSettingsVtbl): IDispatch(IDispatchVtbl) { + fn get_AllowDemandStart( + pAllowDemandStart: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_AllowDemandStart( + pAllowDemandStart: VARIANT_BOOL, + ) -> HRESULT, + fn get_RestartInterval( + pRestartInterval: *mut BSTR, + ) -> HRESULT, + fn put_RestartInterval( + pRestartInterval: BSTR, + ) -> HRESULT, + fn get_RestartCount( + pRestartCount: *mut INT, + ) -> HRESULT, + fn put_RestartCount( + pRestartCount: INT, + ) -> HRESULT, + fn get_MultipleInstances( + pPolicy: *mut TASK_INSTANCES_POLICY, + ) -> HRESULT, + fn put_MultipleInstances( + pPolicy: TASK_INSTANCES_POLICY, + ) -> HRESULT, + fn get_StopIfGoingOnBatteries( + pStopIfOnBatteries: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_StopIfGoingOnBatteries( + pStopIfOnBatteries: VARIANT_BOOL, + ) -> HRESULT, + fn get_DisallowStartIfOnBatteries( + pDisallowStart: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_DisallowStartIfOnBatteries( + pDisallowStart: VARIANT_BOOL, + ) -> HRESULT, + fn get_AllowHardTerminate( + pAllowHardTerminate: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_AllowHardTerminate( + pAllowHardTerminate: VARIANT_BOOL, + ) -> HRESULT, + fn get_StartWhenAvailable( + pStartWhenAvailable: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_StartWhenAvailable( + pStartWhenAvailable: VARIANT_BOOL, + ) -> HRESULT, + fn get_XmlText( + pText: *mut BSTR, + ) -> HRESULT, + fn put_XmlText( + pText: BSTR, + ) -> HRESULT, + fn get_RunOnlyIfNetworkAvailable( + pRunOnlyIfNetworkAvailable: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_RunOnlyIfNetworkAvailable( + pRunOnlyIfNetworkAvailable: VARIANT_BOOL, + ) -> HRESULT, + fn get_ExecutionTimeLimit( + pExecutionTimeLimit: *mut BSTR, + ) -> HRESULT, + fn put_ExecutionTimeLimit( + pExecutionTimeLimit: BSTR, + ) -> HRESULT, + fn get_Enabled( + pEnabled: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Enabled( + pEnabled: VARIANT_BOOL, + ) -> HRESULT, + fn get_DeleteExpiredTaskAfter( + pExpirationDelay: *mut BSTR, + ) -> HRESULT, + fn put_DeleteExpiredTaskAfter( + pExpirationDelay: BSTR, + ) -> HRESULT, + fn get_Priority( + pPriority: *mut INT, + ) -> HRESULT, + fn put_Priority( + pPriority: INT, + ) -> HRESULT, + fn get_Compatibility( + pCompatLevel: *mut TASK_COMPATIBILITY, + ) -> HRESULT, + fn put_Compatibility( + pCompatLevel: TASK_COMPATIBILITY, + ) -> HRESULT, + fn get_Hidden( + pHidden: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Hidden( + pHidden: VARIANT_BOOL, + ) -> HRESULT, + fn get_IdleSettings( + ppIdleSettings: *mut *mut IIdleSettings, + ) -> HRESULT, + fn put_IdleSettings( + ppIdleSettings: *const IIdleSettings, + ) -> HRESULT, + fn get_RunOnlyIfIdle( + pRunOnlyIfIdle: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_RunOnlyIfIdle( + pRunOnlyIfIdle: VARIANT_BOOL, + ) -> HRESULT, + fn get_WakeToRun( + pWake: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_WakeToRun( + pWake: VARIANT_BOOL, + ) -> HRESULT, + fn get_NetworkSettings( + ppNetworkSettings: *mut *mut INetworkSettings, + ) -> HRESULT, + fn put_NetworkSettings( + ppNetworkSettings: *const INetworkSettings, + ) -> HRESULT, +}} +ENUM!{enum TASK_INSTANCES_POLICY { + TASK_INSTANCES_PARALLEL = 0, + TASK_INSTANCES_QUEUE = 1, + TASK_INSTANCES_IGNORE_NEW = 2, + TASK_INSTANCES_STOP_EXISTING = 3, +}} +ENUM!{enum TASK_COMPATIBILITY { + TASK_COMPATIBILITY_AT = 0, + TASK_COMPATIBILITY_V1 = 1, + TASK_COMPATIBILITY_V2 = 2, + TASK_COMPATIBILITY_V2_1 = 3, + TASK_COMPATIBILITY_V2_2 = 4, + TASK_COMPATIBILITY_V2_3 = 5, + TASK_COMPATIBILITY_V2_4 = 6, +}} +RIDL!{#[uuid(0x84594461, 0x0053, 0x4342, 0xa8, 0xfd, 0x08, 0x8f, 0xab, 0xf1, 0x1f, 0x32)] +interface IIdleSettings(IIdleSettingsVtbl): IDispatch(IDispatchVtbl) { + fn get_IdleDuration( + pDelay: *mut BSTR, + ) -> HRESULT, + fn put_IdleDuration( + pDelay: BSTR, + ) -> HRESULT, + fn get_WaitTimeout( + pTimeout: *mut BSTR, + ) -> HRESULT, + fn put_WaitTimeout( + pTimeout: BSTR, + ) -> HRESULT, + fn get_StopOnIdleEnd( + pStop: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_StopOnIdleEnd( + pStop: VARIANT_BOOL, + ) -> HRESULT, + fn get_RestartOnIdle( + pRestart: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_RestartOnIdle( + pRestart: VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9f7dea84, 0xc30b, 0x4245, 0x80, 0xb6, 0x00, 0xe9, 0xf6, 0x46, 0xf1, 0xb4)] +interface INetworkSettings(INetworkSettingsVtbl): IDispatch(IDispatchVtbl) { + fn get_Name( + pName: *mut BSTR, + ) -> HRESULT, + fn put_Name( + pName: BSTR, + ) -> HRESULT, + fn get_Id( + pId: *mut BSTR, + ) -> HRESULT, + fn put_Id( + pId: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd98d51e5, 0xc9b4, 0x496a, 0xa9, 0xc1, 0x18, 0x98, 0x02, 0x61, 0xcf, 0x0f)] +interface IPrincipal(IPrincipalVtbl): IDispatch(IDispatchVtbl) { + fn get_Id( + pId: *mut BSTR, + ) -> HRESULT, + fn put_Id( + pId: BSTR, + ) -> HRESULT, + fn get_DisplayName( + pName: *mut BSTR, + ) -> HRESULT, + fn put_DisplayName( + pName: BSTR, + ) -> HRESULT, + fn get_UserId( + pUser: *mut BSTR, + ) -> HRESULT, + fn put_UserId( + pUser: BSTR, + ) -> HRESULT, + fn get_LogonType( + pLogon: *mut TASK_LOGON_TYPE, + ) -> HRESULT, + fn put_LogonType( + pLogon: TASK_LOGON_TYPE, + ) -> HRESULT, + fn get_GroupId( + pGroup: *mut BSTR, + ) -> HRESULT, + fn put_GroupId( + pGroup: BSTR, + ) -> HRESULT, + fn get_RunLevel( + pRunLevel: *mut TASK_RUNLEVEL, + ) -> HRESULT, + fn put_RunLevel( + pRunLevel: TASK_RUNLEVEL, + ) -> HRESULT, +}} +ENUM!{enum TASK_LOGON_TYPE { + TASK_LOGON_NONE = 0, + TASK_LOGON_PASSWORD = 1, + TASK_LOGON_S4U = 2, + TASK_LOGON_INTERACTIVE_TOKEN = 3, + TASK_LOGON_GROUP = 4, + TASK_LOGON_SERVICE_ACCOUNT = 5, + TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD = 6, +}} +ENUM!{enum TASK_RUNLEVEL { + TASK_RUNLEVEL_LUA = 0, + TASK_RUNLEVEL_HIGHEST = 1, +}} +RIDL!{#[uuid(0x02820e19, 0x7b98, 0x4ed2, 0xb2, 0xe8, 0xfd, 0xcc, 0xce, 0xff, 0x61, 0x9b)] +interface IActionCollection(IActionCollectionVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + pCount: *mut c_long, + ) -> HRESULT, + fn get_Item( + index: c_long, + ppAction: *mut *mut IAction, + ) -> HRESULT, + fn get__NewEnum( + ppEnum: *mut LPUNKNOWN, + ) -> HRESULT, + fn get_XmlText( + pText: *mut BSTR, + ) -> HRESULT, + fn put_XmlText( + pText: BSTR, + ) -> HRESULT, + fn Create( + Type: TASK_ACTION_TYPE, + ppAction: *mut *mut IAction, + ) -> HRESULT, + fn Remove( + index: VARIANT, + ) -> HRESULT, + fn Clear() -> HRESULT, + fn get_Context( + pContext: *mut BSTR, + ) -> HRESULT, + fn put_Context( + pContext: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xbae54997, 0x48b1, 0x4cbe, 0x99, 0x65, 0xd6, 0xbe, 0x26, 0x3e, 0xbe, 0xa4)] +interface IAction(IActionVtbl): IDispatch(IDispatchVtbl) { + fn get_Id( + pId: *mut BSTR, + ) -> HRESULT, + fn put_Id( + pId: BSTR, + ) -> HRESULT, + fn get_Type( + pType: *mut TASK_ACTION_TYPE, + ) -> HRESULT, +}} +ENUM!{enum TASK_ACTION_TYPE { + TASK_ACTION_EXEC = 0, + TASK_ACTION_COM_HANDLER = 5, + TASK_ACTION_SEND_EMAIL = 6, + TASK_ACTION_SHOW_MESSAGE = 7, +}} +RIDL!{#[uuid(0x86627eb4, 0x42a7, 0x41e4, 0xa4, 0xd9, 0xac, 0x33, 0xa7, 0x2f, 0x2d, 0x52)] +interface IRegisteredTaskCollection(IRegisteredTaskCollectionVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + pCount: *mut LONG, + ) -> HRESULT, + fn get_Item( + index: VARIANT, + ppRegisteredTask: *mut *mut IRegisteredTask, + ) -> HRESULT, + fn get__NewEnum( + ppEnum: *mut LPUNKNOWN, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2faba4c7, 0x4da9, 0x4013, 0x96, 0x97, 0x20, 0xcc, 0x3f, 0xd4, 0x0f, 0x85)] +interface ITaskService(ITaskServiceVtbl): IDispatch(IDispatchVtbl) { + fn GetFolder( + Path: BSTR, + ppFolder: *mut *mut ITaskFolder, + ) -> HRESULT, + fn GetRunningTasks( + flags: LONG, + ppRunningTasks: *mut *mut IRunningTaskCollection, + ) -> HRESULT, + fn NewTask( + flags: DWORD, + ppDefinition: *mut *mut ITaskDefinition, + ) -> HRESULT, + fn Connect( + serverName: VARIANT, + user: VARIANT, + domain: VARIANT, + password: VARIANT, + ) -> HRESULT, + fn get_Connected( + pConnected: *mut VARIANT_BOOL, + ) -> HRESULT, + fn get_TargetServer( + pServer: *mut BSTR, + ) -> HRESULT, + fn get_ConnectedUser( + pUser: *mut BSTR, + ) -> HRESULT, + fn get_ConnectedDomain( + pDomain: *mut BSTR, + ) -> HRESULT, + fn get_HighestVersion( + pVersion: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x839d7762, 0x5121, 0x4009, 0x92, 0x34, 0x4f, 0x0d, 0x19, 0x39, 0x4f, 0x04)] +interface ITaskHandler(ITaskHandlerVtbl): IUnknown(IUnknownVtbl) { + fn Start( + pHandlerServices: LPUNKNOWN, + Data: BSTR, + ) -> HRESULT, + fn Stop( + pRetCode: *mut HRESULT, + ) -> HRESULT, + fn Pause() -> HRESULT, + fn Resume() -> HRESULT, +}} +RIDL!{#[uuid(0xeaec7a8f, 0x27a0, 0x4ddc, 0x86, 0x75, 0x14, 0x72, 0x6a, 0x01, 0xa3, 0x8a)] +interface ITaskHandlerStatus(ITaskHandlerStatusVtbl): IUnknown(IUnknownVtbl) { + fn UpdateStatus( + percentComplete: c_short, + statusMessage: BSTR, + ) -> HRESULT, + fn TaskCompleted( + taskErrCode: HRESULT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3e4c9351, 0xd966, 0x4b8b, 0xbb, 0x87, 0xce, 0xba, 0x68, 0xbb, 0x01, 0x07)] +interface ITaskVariables(ITaskVariablesVtbl): IUnknown(IUnknownVtbl) { + fn GetInput( + pInput: *mut BSTR, + ) -> HRESULT, + fn SetOutput( + input: BSTR, + ) -> HRESULT, + fn GetContext( + pContext: *mut BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x39038068, 0x2b46, 0x4afd, 0x86, 0x62, 0x7b, 0xb6, 0xf8, 0x68, 0xd2, 0x21)] +interface ITaskNamedValuePair(ITaskNamedValuePairVtbl): IDispatch(IDispatchVtbl) { + fn get_Name( + pName: *mut BSTR, + ) -> HRESULT, + fn put_Name( + pName: BSTR, + ) -> HRESULT, + fn get_Value( + pValue: *mut BSTR, + ) -> HRESULT, + fn put_Value( + pValue: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb4ef826b, 0x63c3, 0x46e4, 0xa5, 0x04, 0xef, 0x69, 0xe4, 0xf7, 0xea, 0x4d)] +interface ITaskNamedValueCollection(ITaskNamedValueCollectionVtbl): IDispatch(IDispatchVtbl) { + fn get_Count( + pCount: *mut c_long, + ) -> HRESULT, + fn get_Item( + index: LONG, + ppPair: *mut *mut ITaskNamedValuePair, + ) -> HRESULT, + fn get__NewEnum( + ppEnum: *mut LPUNKNOWN, + ) -> HRESULT, + fn Create( + Name: BSTR, + Value: BSTR, + ppPair: *mut *mut ITaskNamedValuePair, + ) -> HRESULT, + fn Remove( + index: LONG, + ) -> HRESULT, + fn Clear() -> HRESULT, +}} +RIDL!{#[uuid(0xd537d2b0, 0x9fb3, 0x4d34, 0x97, 0x39, 0x1f, 0xf5, 0xce, 0x7b, 0x1e, 0xf3)] +interface IIdleTrigger(IIdleTriggerVtbl): ITrigger(ITriggerVtbl) {}} +RIDL!{#[uuid(0x72dade38, 0xfae4, 0x4b3e, 0xba, 0xf4, 0x5d, 0x00, 0x9a, 0xf0, 0x2b, 0x1c)] +interface ILogonTrigger(ILogonTriggerVtbl): ITrigger(ITriggerVtbl) { + fn get_Delay( + pDelay: *mut BSTR, + ) -> HRESULT, + fn put_Delay( + pDelay: BSTR, + ) -> HRESULT, + fn get_UserId( + pUser: *mut BSTR, + ) -> HRESULT, + fn put_UserId( + pUser: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x754da71b, 0x4385, 0x4475, 0x9d, 0xd9, 0x59, 0x82, 0x94, 0xfa, 0x36, 0x41)] +interface ISessionStateChangeTrigger(ISessionStateChangeTriggerVtbl): ITrigger(ITriggerVtbl) { + fn get_Delay( + pDelay: *mut BSTR, + ) -> HRESULT, + fn put_Delay( + pDelay: BSTR, + ) -> HRESULT, + fn get_UserId( + pUser: *mut BSTR, + ) -> HRESULT, + fn put_UserId( + pUser: BSTR, + ) -> HRESULT, + fn get_StateChange( + pType: *mut TASK_SESSION_STATE_CHANGE_TYPE, + ) -> HRESULT, + fn put_StateChange( + pType: TASK_SESSION_STATE_CHANGE_TYPE, + ) -> HRESULT, +}} +ENUM!{enum TASK_SESSION_STATE_CHANGE_TYPE { + TASK_CONSOLE_CONNECT = 1, + TASK_CONSOLE_DISCONNECT = 2, + TASK_REMOTE_CONNECT = 3, + TASK_REMOTE_DISCONNECT = 4, + TASK_SESSION_LOCK = 7, + TASK_SESSION_UNLOCK = 8, +}} +RIDL!{#[uuid(0xd45b0167, 0x9653, 0x4eef, 0xb9, 0x4f, 0x07, 0x32, 0xca, 0x7a, 0xf2, 0x51)] +interface IEventTrigger(IEventTriggerVtbl): ITrigger(ITriggerVtbl) { + fn get_Subscription( + pQuery: *mut BSTR, + ) -> HRESULT, + fn put_Subscription( + pQuery: BSTR, + ) -> HRESULT, + fn get_Delay( + pDelay: *mut BSTR, + ) -> HRESULT, + fn put_Delay( + pDelay: BSTR, + ) -> HRESULT, + fn get_ValueQueries( + ppNamedXPaths: *mut *mut ITaskNamedValueCollection, + ) -> HRESULT, + fn put_ValueQueries( + ppNamedXPaths: *const ITaskNamedValueCollection, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb45747e0, 0xeba7, 0x4276, 0x9f, 0x29, 0x85, 0xc5, 0xbb, 0x30, 0x00, 0x06)] +interface ITimeTrigger(ITimeTriggerVtbl): ITrigger(ITriggerVtbl) { + fn get_RandomDelay( + pRandomDelay: *mut BSTR, + ) -> HRESULT, + fn put_RandomDelay( + pRandomDelay: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x126c5cd8, 0xb288, 0x41d5, 0x8d, 0xbf, 0xe4, 0x91, 0x44, 0x6a, 0xdc, 0x5c)] +interface IDailyTrigger(IDailyTriggerVtbl): ITrigger(ITriggerVtbl) { + fn get_DaysInterval( + pDays: *mut c_short, + ) -> HRESULT, + fn put_DaysInterval( + pDays: c_short, + ) -> HRESULT, + fn get_RandomDelay( + pRandomDelay: *mut BSTR, + ) -> HRESULT, + fn put_RandomDelay( + pRandomDelay: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5038fc98, 0x82ff, 0x436d, 0x87, 0x28, 0xa5, 0x12, 0xa5, 0x7c, 0x9d, 0xc1)] +interface IWeeklyTrigger(IWeeklyTriggerVtbl): ITrigger(ITriggerVtbl) { + fn get_DaysOfWeek( + pDays: *mut c_short, + ) -> HRESULT, + fn put_DaysOfWeek( + pDays: c_short, + ) -> HRESULT, + fn get_WeeksInterval( + pWeeks: *mut c_short, + ) -> HRESULT, + fn put_WeeksInterval( + pWeeks: c_short, + ) -> HRESULT, + fn get_RandomDelay( + pRandomDelay: *mut BSTR, + ) -> HRESULT, + fn put_RandomDelay( + pRandomDelay: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x97c45ef1, 0x6b02, 0x4a1a, 0x9c, 0x0e, 0x1e, 0xbf, 0xba, 0x15, 0x00, 0xac)] +interface IMonthlyTrigger(IMonthlyTriggerVtbl): ITrigger(ITriggerVtbl) { + fn get_DaysOfMonth( + pDays: *mut c_long, + ) -> HRESULT, + fn put_DaysOfMonth( + pDays: c_long, + ) -> HRESULT, + fn get_MonthsOfYear( + pMonths: *mut c_short, + ) -> HRESULT, + fn put_MonthsOfYear( + pMonths: c_short, + ) -> HRESULT, + fn get_RunOnLastDayOfMonth( + pLastDay: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_RunOnLastDayOfMonth( + pLastDay: VARIANT_BOOL, + ) -> HRESULT, + fn get_RandomDelay( + pRandomDelay: *mut BSTR, + ) -> HRESULT, + fn put_RandomDelay( + pRandomDelay: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x77d025a3, 0x90fa, 0x43aa, 0xb5, 0x2e, 0xcd, 0xa5, 0x49, 0x9b, 0x94, 0x6a)] +interface IMonthlyDOWTrigger(IMonthlyDOWTriggerVtbl): ITrigger(ITriggerVtbl) { + fn get_DaysOfWeek( + pDays: *mut c_short, + ) -> HRESULT, + fn put_DaysOfWeek( + pDays: c_short, + ) -> HRESULT, + fn get_WeeksOfMonth( + pWeeks: *mut c_short, + ) -> HRESULT, + fn put_WeeksOfMonth( + pWeeks: c_short, + ) -> HRESULT, + fn get_MonthsOfYear( + pMonths: *mut c_short, + ) -> HRESULT, + fn put_MonthsOfYear( + pMonths: c_short, + ) -> HRESULT, + fn get_RunOnLastWeekOfMonth( + pLastWeek: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_RunOnLastWeekOfMonth( + pLastWeek: VARIANT_BOOL, + ) -> HRESULT, + fn get_RandomDelay( + pRandomDelay: *mut BSTR, + ) -> HRESULT, + fn put_RandomDelay( + pRandomDelay: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2a9c35da, 0xd357, 0x41f4, 0xbb, 0xc1, 0x20, 0x7a, 0xc1, 0xb1, 0xf3, 0xcb)] +interface IBootTrigger(IBootTriggerVtbl): ITrigger(ITriggerVtbl) { + fn get_Delay( + pDelay: *mut BSTR, + ) -> HRESULT, + fn put_Delay( + pDelay: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4c8fec3a, 0xc218, 0x4e0c, 0xb2, 0x3d, 0x62, 0x90, 0x24, 0xdb, 0x91, 0xa2)] +interface IRegistrationTrigger(IRegistrationTriggerVtbl): ITrigger(ITriggerVtbl) { + fn get_Delay( + pDelay: *mut BSTR, + ) -> HRESULT, + fn put_Delay( + pDelay: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4c3d624d, 0xfd6b, 0x49a3, 0xb9, 0xb7, 0x09, 0xcb, 0x3c, 0xd3, 0xf0, 0x47)] +interface IExecAction(IExecActionVtbl): IAction(IActionVtbl) { + fn get_Path( + pPath: *mut BSTR, + ) -> HRESULT, + fn put_Path( + pPath: BSTR, + ) -> HRESULT, + fn get_Arguments( + pArgument: *mut BSTR, + ) -> HRESULT, + fn put_Arguments( + pArgument: BSTR, + ) -> HRESULT, + fn get_WorkingDirectory( + pWorkingDirectory: *mut BSTR, + ) -> HRESULT, + fn put_WorkingDirectory( + pWorkingDirectory: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf2a82542, 0xbda5, 0x4e6b, 0x91, 0x43, 0xe2, 0xbf, 0x4f, 0x89, 0x87, 0xb6)] +interface IExecAction2(IExecAction2Vtbl): IExecAction(IExecActionVtbl) { + fn get_HideAppWindow( + pHideAppWindow: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_HideAppWindow( + pHideAppWindow: VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x505e9e68, 0xaf89, 0x46b8, 0xa3, 0x0f, 0x56, 0x16, 0x2a, 0x83, 0xd5, 0x37)] +interface IShowMessageAction(IShowMessageActionVtbl): IAction(IActionVtbl) { + fn get_Title( + pTitle: *mut BSTR, + ) -> HRESULT, + fn put_Title( + pTitle: BSTR, + ) -> HRESULT, + fn get_MessageBody( + pMessageBody: *mut BSTR, + ) -> HRESULT, + fn put_MessageBody( + pMessageBody: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6d2fd252, 0x75c5, 0x4f66, 0x90, 0xba, 0x2a, 0x7d, 0x8c, 0xc3, 0x03, 0x9f)] +interface IComHandlerAction(IComHandlerActionVtbl): IAction(IActionVtbl) { + fn get_ClassId( + pClsid: *mut BSTR, + ) -> HRESULT, + fn put_ClassId( + pClsid: BSTR, + ) -> HRESULT, + fn get_Data( + pData: *mut BSTR, + ) -> HRESULT, + fn put_Data( + pData: BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x10f62c64, 0x7e16, 0x4314, 0xa0, 0xc2, 0x0c, 0x36, 0x83, 0xf9, 0x9d, 0x40)] +interface IEmailAction(IEmailActionVtbl): IAction(IActionVtbl) { + fn get_Server( + pServer: *mut BSTR, + ) -> HRESULT, + fn put_Server( + pServer: BSTR, + ) -> HRESULT, + fn get_Subject( + pSubject: *mut BSTR, + ) -> HRESULT, + fn put_Subject( + pSubject: BSTR, + ) -> HRESULT, + fn get_To( + pTo: *mut BSTR, + ) -> HRESULT, + fn put_To( + pTo: BSTR, + ) -> HRESULT, + fn get_Cc( + pCc: *mut BSTR, + ) -> HRESULT, + fn put_Cc( + pCc: BSTR, + ) -> HRESULT, + fn get_Bcc( + pBcc: *mut BSTR, + ) -> HRESULT, + fn put_Bcc( + pBcc: BSTR, + ) -> HRESULT, + fn get_ReplyTo( + pReplyTo: *mut BSTR, + ) -> HRESULT, + fn put_ReplyTo( + pReplyTo: BSTR, + ) -> HRESULT, + fn get_From( + pFrom: *mut BSTR, + ) -> HRESULT, + fn put_From( + pFrom: BSTR, + ) -> HRESULT, + fn get_HeaderFields( + ppHeaderFields: *mut *mut ITaskNamedValueCollection, + ) -> HRESULT, + fn put_HeaderFields( + ppHeaderFields: *const ITaskNamedValueCollection, + ) -> HRESULT, + fn get_Body( + pBody: *mut BSTR, + ) -> HRESULT, + fn put_Body( + pBody: BSTR, + ) -> HRESULT, + fn get_Attachments( + pAttachements: *mut SAFEARRAY, + ) -> HRESULT, + fn put_Attachments( + pAttachements: SAFEARRAY, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x248919ae, 0xe345, 0x4a6d, 0x8a, 0xeb, 0xe0, 0xd3, 0x16, 0x5c, 0x90, 0x4e)] +interface IPrincipal2(IPrincipal2Vtbl): IDispatch(IDispatchVtbl) { + fn get_ProcessTokenSidType( + pProcessTokenSidType: *mut TASK_PROCESSTOKENSID, + ) -> HRESULT, + fn put_ProcessTokenSidType( + pProcessTokenSidType: TASK_PROCESSTOKENSID, + ) -> HRESULT, + fn get_RequiredPrivilegeCount( + pCount: *mut c_long, + ) -> HRESULT, + fn get_RequiredPrivilege( + index: c_long, + pPrivilege: *mut BSTR, + ) -> HRESULT, + fn AddRequiredPrivilege( + privilege: BSTR, + ) -> HRESULT, +}} +ENUM!{enum TASK_PROCESSTOKENSID { + TASK_PROCESSTOKENSID_NONE = 0, + TASK_PROCESSTOKENSID_UNRESTRICTED = 1, + TASK_PROCESSTOKENSID_DEFAULT = 2, +}} +RIDL!{#[uuid(0x2c05c3f0, 0x6eed, 0x4c05, 0xa1, 0x5f, 0xed, 0x7d, 0x7a, 0x98, 0xa3, 0x69)] +interface ITaskSettings2(ITaskSettings2Vtbl): IDispatch(IDispatchVtbl) { + fn get_DisallowStartOnRemoteAppSession( + pDisallowStart: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_DisallowStartOnRemoteAppSession( + pDisallowStart: VARIANT_BOOL, + ) -> HRESULT, + fn get_UseUnifiedSchedulingEngine( + pUseUnifiedEngine: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_UseUnifiedSchedulingEngine( + pUseUnifiedEngine: VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0ad9d0d7, 0x0c7f, 0x4ebb, 0x9a, 0x5f, 0xd1, 0xc6, 0x48, 0xdc, 0xa5, 0x28)] +interface ITaskSettings3(ITaskSettings3Vtbl): ITaskSettings(ITaskSettingsVtbl) { + fn get_DisallowStartOnRemoteAppSession( + pDisallowStart: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_DisallowStartOnRemoteAppSession( + pDisallowStart: VARIANT_BOOL, + ) -> HRESULT, + fn get_UseUnifiedSchedulingEngine( + pUseUnifiedEngine: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_UseUnifiedSchedulingEngine( + pUseUnifiedEngine: VARIANT_BOOL, + ) -> HRESULT, + fn get_MaintenanceSettings( + ppMaintenanceSettings: *mut *mut IMaintenanceSettings, + ) -> HRESULT, + fn put_MaintenanceSettings( + ppMaintenanceSettings: *const IMaintenanceSettings, + ) -> HRESULT, + fn CreateMaintenanceSettings( + ppMaintenanceSettings: *mut *mut IMaintenanceSettings, + ) -> HRESULT, + fn get_Volatile( + pVolatile: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Volatile( + pVolatile: VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa6024fa8, 0x9652, 0x4adb, 0xa6, 0xbf, 0x5c, 0xfc, 0xd8, 0x77, 0xa7, 0xba)] +interface IMaintenanceSettings(IMaintenanceSettingsVtbl): IDispatch(IDispatchVtbl) { + fn put_Period( + target: BSTR, + ) -> HRESULT, + fn get_Period( + target: *mut BSTR, + ) -> HRESULT, + fn put_Deadline( + target: BSTR, + ) -> HRESULT, + fn get_Deadline( + target: *mut BSTR, + ) -> HRESULT, + fn put_Exclusive( + target: VARIANT_BOOL, + ) -> HRESULT, + fn get_Exclusive( + target: *mut VARIANT_BOOL, + ) -> HRESULT, +}} +ENUM!{enum TASK_RUN_FLAGS { + TASK_RUN_NO_FLAGS = 0, + TASK_RUN_AS_SELF = 1, + TASK_RUN_IGNORE_CONSTRAINTS = 2, + TASK_RUN_USE_SESSION_ID = 4, + TASK_RUN_USER_SID = 8, +}} +ENUM!{enum TASK_ENUM_FLAGS { + TASK_ENUM_HIDDEN = 1, +}} +ENUM!{enum TASK_CREATION { + TASK_VALIDATE_ONLY = 1, + TASK_CREATE = 2, + TASK_UPDATE = 4, + TASK_CREATE_OR_UPDATE = 6, + TASK_DISABLE = 8, + TASK_DONT_ADD_PRINCIPAL_ACE = 16, + TASK_IGNORE_REGISTRATION_TRIGGERS = 32, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/textstor.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/textstor.rs new file mode 100644 index 0000000..7e2d602 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/textstor.rs @@ -0,0 +1,11 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +DEFINE_GUID!{GUID_TS_SERVICE_DATAOBJECT, + 0x6086fbb5, 0xe225, 0x46ce, 0xa7, 0x70, 0xc1, 0xbb, 0xd3, 0xe0, 0x5d, 0x7b} +DEFINE_GUID!{GUID_TS_SERVICE_ACCESSIBLE, + 0xf9786200, 0xa5bf, 0x4a0f, 0x8c, 0x24, 0xfb, 0x16, 0xf5, 0xd1, 0xaa, 0xbb} +DEFINE_GUID!{GUID_TS_SERVICE_ACTIVEX, + 0xea937a50, 0xc9a6, 0x4b7d, 0x89, 0x4a, 0x49, 0xd9, 0x9b, 0x78, 0x48, 0x34} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/threadpoolapiset.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/threadpoolapiset.rs new file mode 100644 index 0000000..13a1e7a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/threadpoolapiset.rs @@ -0,0 +1,171 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-core-threadpool-l1. +use shared::basetsd::ULONG_PTR; +use shared::minwindef::{BOOL, DWORD, HMODULE, PFILETIME, ULONG}; +use um::minwinbase::PCRITICAL_SECTION; +use um::winnt::{ + HANDLE, PTP_CALLBACK_ENVIRON, PTP_CALLBACK_INSTANCE, PTP_CLEANUP_GROUP, PTP_IO, PTP_POOL, + PTP_POOL_STACK_INFORMATION, PTP_SIMPLE_CALLBACK, PTP_TIMER, PTP_TIMER_CALLBACK, PTP_WAIT, + PTP_WAIT_CALLBACK, PTP_WORK, PTP_WORK_CALLBACK, PVOID, +}; +FN!{stdcall PTP_WIN32_IO_CALLBACK( + Instance: PTP_CALLBACK_INSTANCE, + Context: PVOID, + Overlapped: PVOID, + IoResult: ULONG, + NumberOfBytesTransferred: ULONG_PTR, + Io: PTP_IO, +) -> ()} +extern "system" { + pub fn CreateThreadpool( + reserved: PVOID, + ) -> PTP_POOL; + pub fn SetThreadpoolThreadMaximum( + ptpp: PTP_POOL, + cthrdMost: DWORD, + ) -> (); + pub fn SetThreadpoolThreadMinimum( + ptpp: PTP_POOL, + cthrdMic: DWORD, + ) -> BOOL; + pub fn SetThreadpoolStackInformation( + ptpp: PTP_POOL, + ptpsi: PTP_POOL_STACK_INFORMATION, + ) -> BOOL; + pub fn QueryThreadpoolStackInformation( + ptpp: PTP_POOL, + ptpsi: PTP_POOL_STACK_INFORMATION, + ) -> BOOL; + pub fn CloseThreadpool( + ptpp: PTP_POOL, + ) -> (); + pub fn CreateThreadpoolCleanupGroup() -> PTP_CLEANUP_GROUP; + pub fn CloseThreadpoolCleanupGroupMembers( + ptpcg: PTP_CLEANUP_GROUP, + fCancelPendingCallbacks: BOOL, + pvCleanupContext: PVOID, + ) -> (); + pub fn CloseThreadpoolCleanupGroup( + ptpcg: PTP_CLEANUP_GROUP, + ) -> (); + pub fn SetEventWhenCallbackReturns( + pci: PTP_CALLBACK_INSTANCE, + evt: HANDLE, + ) -> (); + pub fn ReleaseSemaphoreWhenCallbackReturns( + pci: PTP_CALLBACK_INSTANCE, + sem: HANDLE, + crel: DWORD, + ) -> (); + pub fn ReleaseMutexWhenCallbackReturns( + pci: PTP_CALLBACK_INSTANCE, + mut_: HANDLE, + ) -> (); + pub fn LeaveCriticalSectionWhenCallbackReturns( + pci: PTP_CALLBACK_INSTANCE, + pcs: PCRITICAL_SECTION, + ) -> (); + pub fn FreeLibraryWhenCallbackReturns( + pci: PTP_CALLBACK_INSTANCE, + mod_: HMODULE, + ) -> (); + pub fn CallbackMayRunLong( + pci: PTP_CALLBACK_INSTANCE, + ) -> BOOL; + pub fn DisassociateCurrentThreadFromCallback( + pci: PTP_CALLBACK_INSTANCE, + ) -> (); + pub fn TrySubmitThreadpoolCallback( + pfns: PTP_SIMPLE_CALLBACK, + pv: PVOID, + pcbe: PTP_CALLBACK_ENVIRON, + ) -> BOOL; + pub fn CreateThreadpoolWork( + pfnwk: PTP_WORK_CALLBACK, + pv: PVOID, + pcbe: PTP_CALLBACK_ENVIRON, + ) -> PTP_WORK; + pub fn SubmitThreadpoolWork( + pwk: PTP_WORK, + ) -> (); + pub fn WaitForThreadpoolWorkCallbacks( + pwk: PTP_WORK, + fCancelPendingCallbacks: BOOL, + ) -> (); + pub fn CloseThreadpoolWork( + pwk: PTP_WORK, + ) -> (); + pub fn CreateThreadpoolTimer( + pfnti: PTP_TIMER_CALLBACK, + pv: PVOID, + pcbe: PTP_CALLBACK_ENVIRON, + ) -> PTP_TIMER; + pub fn SetThreadpoolTimer( + pti: PTP_TIMER, + pftDueTime: PFILETIME, + msPeriod: DWORD, + msWindowLength: DWORD, + ) -> (); + pub fn IsThreadpoolTimerSet( + pti: PTP_TIMER, + ) -> BOOL; + pub fn WaitForThreadpoolTimerCallbacks( + pti: PTP_TIMER, + fCancelPendingCallbacks: BOOL, + ) -> (); + pub fn CloseThreadpoolTimer( + pti: PTP_TIMER, + ) -> (); + pub fn CreateThreadpoolWait( + pfnwa: PTP_WAIT_CALLBACK, + pv: PVOID, + pcbe: PTP_CALLBACK_ENVIRON, + ) -> PTP_WAIT; + pub fn SetThreadpoolWait( + pwa: PTP_WAIT, + h: HANDLE, + pftTimeout: PFILETIME, + ) -> (); + pub fn WaitForThreadpoolWaitCallbacks( + pwa: PTP_WAIT, + fCancelPendingCallbacks: BOOL, + ) -> (); + pub fn CloseThreadpoolWait( + pwa: PTP_WAIT, + ) -> (); + pub fn CreateThreadpoolIo( + fl: HANDLE, + pfnio: PTP_WIN32_IO_CALLBACK, + pv: PVOID, + pcbe: PTP_CALLBACK_ENVIRON, + ) -> PTP_IO; + pub fn StartThreadpoolIo( + pio: PTP_IO, + ) -> (); + pub fn CancelThreadpoolIo( + pio: PTP_IO, + ) -> (); + pub fn WaitForThreadpoolIoCallbacks( + pio: PTP_IO, + fCancelPendingCallbacks: BOOL, + ) -> (); + pub fn CloseThreadpoolIo( + pio: PTP_IO, + ) -> (); + pub fn SetThreadpoolTimerEx( + pti: PTP_TIMER, + pftDueTime: PFILETIME, + msPeriod: DWORD, + msWindowLength: DWORD, + ) -> BOOL; + pub fn SetThreadpoolWaitEx( + pwa: PTP_WAIT, + h: HANDLE, + pftTimeout: PFILETIME, + Reserved: PVOID, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/threadpoollegacyapiset.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/threadpoollegacyapiset.rs new file mode 100644 index 0000000..dc306c4 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/threadpoollegacyapiset.rs @@ -0,0 +1,44 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, DWORD, ULONG}; +use um::minwinbase::LPTHREAD_START_ROUTINE; +use um::winnt::{HANDLE, PHANDLE, PVOID, WAITORTIMERCALLBACK}; +extern "system" { + pub fn QueueUserWorkItem( + Function: LPTHREAD_START_ROUTINE, + Context: PVOID, + Flags: ULONG, + ) -> BOOL; + pub fn UnregisterWaitEx( + WaitHandle: HANDLE, + CompletionEvent: HANDLE, + ) -> BOOL; + pub fn CreateTimerQueue() -> HANDLE; + pub fn CreateTimerQueueTimer( + phNewTimer: PHANDLE, + TimerQueue: HANDLE, + Callback: WAITORTIMERCALLBACK, + Parameter: PVOID, + DueTime: DWORD, + Period: DWORD, + Flags: ULONG, + ) -> BOOL; + pub fn ChangeTimerQueueTimer( + TimerQueue: HANDLE, + Timer: HANDLE, + DueTime: ULONG, + Period: ULONG, + ) -> BOOL; + pub fn DeleteTimerQueueTimer( + TimerQueue: HANDLE, + Timer: HANDLE, + CompletionEvent: HANDLE, + ) -> BOOL; + pub fn DeleteTimerQueueEx( + TimerQueue: HANDLE, + CompletionEvent: HANDLE, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/timeapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/timeapi.rs new file mode 100644 index 0000000..dae6470 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/timeapi.rs @@ -0,0 +1,20 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{DWORD, UINT}; +use um::mmsystem::{LPTIMECAPS, MMRESULT}; +extern "system" { + pub fn timeGetTime() -> DWORD; + pub fn timeGetDevCaps( + ptc: LPTIMECAPS, + cbtc: UINT, + ) -> MMRESULT; + pub fn timeBeginPeriod( + uPeriod: UINT, + ) -> MMRESULT; + pub fn timeEndPeriod( + uPeriod: UINT, + ) -> MMRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/timezoneapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/timezoneapi.rs new file mode 100644 index 0000000..b7d99f7 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/timezoneapi.rs @@ -0,0 +1,89 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! ApiSet Contract for api-ms-win-core-timezone-l1 +use shared::minwindef::{BOOL, DWORD, FILETIME, LPDWORD, LPFILETIME, USHORT}; +use um::minwinbase::{LPSYSTEMTIME, SYSTEMTIME}; +use um::winnt::{BOOLEAN, LONG, WCHAR}; +pub const TIME_ZONE_ID_INVALID: DWORD = 0xFFFFFFFF; +STRUCT!{struct TIME_ZONE_INFORMATION { + Bias: LONG, + StandardName: [WCHAR; 32], + StandardDate: SYSTEMTIME, + StandardBias: LONG, + DaylightName: [WCHAR; 32], + DaylightDate: SYSTEMTIME, + DaylightBias: LONG, +}} +pub type PTIME_ZONE_INFORMATION = *mut TIME_ZONE_INFORMATION; +pub type LPTIME_ZONE_INFORMATION = *mut TIME_ZONE_INFORMATION; +STRUCT!{struct DYNAMIC_TIME_ZONE_INFORMATION { + Bias: LONG, + StandardName: [WCHAR; 32], + StandardDate: SYSTEMTIME, + StandardBias: LONG, + DaylightName: [WCHAR; 32], + DaylightDate: SYSTEMTIME, + DaylightBias: LONG, + TimeZoneKeyName: [WCHAR; 128], + DynamicDaylightTimeDisabled: BOOLEAN, +}} +pub type PDYNAMIC_TIME_ZONE_INFORMATION = *mut DYNAMIC_TIME_ZONE_INFORMATION; +extern "system" { + pub fn SystemTimeToTzSpecificLocalTime( + lpTimeZoneInformation: *const TIME_ZONE_INFORMATION, + lpUniversalTime: *const SYSTEMTIME, + lpLocalTime: LPSYSTEMTIME, + ) -> BOOL; + pub fn TzSpecificLocalTimeToSystemTime( + lpTimeZoneInformation: *const TIME_ZONE_INFORMATION, + lpLocalTime: *const SYSTEMTIME, + lpUniversalTime: LPSYSTEMTIME, + ) -> BOOL; + pub fn FileTimeToSystemTime( + lpFileTime: *const FILETIME, + lpSystemTime: LPSYSTEMTIME, + ) -> BOOL; + pub fn SystemTimeToFileTime( + lpSystemTime: *const SYSTEMTIME, + lpFileTime: LPFILETIME, + ) -> BOOL; + pub fn GetTimeZoneInformation( + lpTimeZoneInformation: LPTIME_ZONE_INFORMATION, + ) -> DWORD; + pub fn SetTimeZoneInformation( + lpTimeZoneInformation: *const TIME_ZONE_INFORMATION, + ) -> BOOL; + pub fn SetDynamicTimeZoneInformation( + lpTimeZoneInformation: *const DYNAMIC_TIME_ZONE_INFORMATION, + ) -> BOOL; + pub fn GetDynamicTimeZoneInformation( + pTimeZoneInformation: PDYNAMIC_TIME_ZONE_INFORMATION, + ) -> DWORD; + pub fn GetTimeZoneInformationForYear( + wYear: USHORT, + pdtzi: PDYNAMIC_TIME_ZONE_INFORMATION, + ptzi: LPTIME_ZONE_INFORMATION, + ) -> BOOL; + pub fn EnumDynamicTimeZoneInformation( + dwIndex: DWORD, + lpTimeZoneInformation: PDYNAMIC_TIME_ZONE_INFORMATION, + ) -> DWORD; + pub fn GetDynamicTimeZoneInformationEffectiveYears( + lpTimeZoneInformation: PDYNAMIC_TIME_ZONE_INFORMATION, + FirstYear: LPDWORD, + LastYear: LPDWORD, + ) -> DWORD; + pub fn SystemTimeToTzSpecificLocalTimeEx( + lpTimeZoneInformation: *const DYNAMIC_TIME_ZONE_INFORMATION, + lpUniversalTime: *const SYSTEMTIME, + lpLocalTime: LPSYSTEMTIME, + ) -> BOOL; + pub fn TzSpecificLocalTimeToSystemTimeEx( + lpTimeZoneInformation: *const DYNAMIC_TIME_ZONE_INFORMATION, + lpLocalTime: *const SYSTEMTIME, + lpUniversalTime: LPSYSTEMTIME, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/tlhelp32.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/tlhelp32.rs new file mode 100644 index 0000000..f910b9f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/tlhelp32.rs @@ -0,0 +1,194 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! WIN32 tool help functions, types, and definitions +use shared::basetsd::{SIZE_T, ULONG_PTR}; +use shared::minwindef::{BOOL, BYTE, DWORD, HMODULE, LPCVOID, LPVOID, MAX_PATH}; +use um::winnt::{CHAR, HANDLE, LONG, WCHAR}; +pub const MAX_MODULE_NAME32: usize = 255; +extern "system" { + pub fn CreateToolhelp32Snapshot( + dwFlags: DWORD, + th32ProcessID: DWORD, + ) -> HANDLE; +} +pub const TH32CS_SNAPHEAPLIST: DWORD = 0x00000001; +pub const TH32CS_SNAPPROCESS: DWORD = 0x00000002; +pub const TH32CS_SNAPTHREAD: DWORD = 0x00000004; +pub const TH32CS_SNAPMODULE: DWORD = 0x00000008; +pub const TH32CS_SNAPMODULE32: DWORD = 0x00000010; +pub const TH32CS_SNAPALL: DWORD = + (TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE); +pub const TH32CS_INHERIT: DWORD = 0x80000000; +STRUCT!{struct HEAPLIST32 { + dwSize: SIZE_T, + th32ProcessID: DWORD, + th32HeapID: ULONG_PTR, + dwFlags: DWORD, +}} +pub type PHEAPLIST32 = *mut HEAPLIST32; +pub type LPHEAPLIST32 = *mut HEAPLIST32; +pub const HF32_DEFAULT: DWORD = 1; +pub const HF32_SHARED: DWORD = 2; +extern "system" { + pub fn Heap32ListFirst( + hSnapshot: HANDLE, + lphl: LPHEAPLIST32, + ) -> BOOL; + pub fn Heap32ListNext( + hSnapshot: HANDLE, + lphl: LPHEAPLIST32, + ) -> BOOL; +} +STRUCT!{struct HEAPENTRY32 { + dwSize: SIZE_T, + hHandle: HANDLE, + dwAddress: ULONG_PTR, + dwBlockSize: SIZE_T, + dwFlags: DWORD, + dwLockCount: DWORD, + dwResvd: DWORD, + th32ProcessID: DWORD, + th32HeapID: ULONG_PTR, +}} +pub type PHEAPENTRY32 = *mut HEAPENTRY32; +pub type LPHEAPENTRY32 = *mut HEAPENTRY32; +pub const LF32_FIXED: DWORD = 0x00000001; +pub const LF32_FREE: DWORD = 0x00000002; +pub const LF32_MOVEABLE: DWORD = 0x00000004; +extern "system" { + pub fn Heap32First( + lphe: LPHEAPENTRY32, + th32ProcessID: DWORD, + th32HeapID: ULONG_PTR, + ) -> BOOL; + pub fn Heap32Next( + lphe: LPHEAPENTRY32, + ) -> BOOL; + pub fn Toolhelp32ReadProcessMemory( + th32ProcessID: DWORD, + lpBaseAddress: LPCVOID, + lpBuffer: LPVOID, + cbRead: SIZE_T, + lpNumberOfBytesRead: *mut SIZE_T, + ) -> BOOL; +} +STRUCT!{struct PROCESSENTRY32W { + dwSize: DWORD, + cntUsage: DWORD, + th32ProcessID: DWORD, + th32DefaultHeapID: ULONG_PTR, + th32ModuleID: DWORD, + cntThreads: DWORD, + th32ParentProcessID: DWORD, + pcPriClassBase: LONG, + dwFlags: DWORD, + szExeFile: [WCHAR; MAX_PATH], +}} +pub type PPROCESSENTRY32W = *mut PROCESSENTRY32W; +pub type LPPROCESSENTRY32W = *mut PROCESSENTRY32W; +extern "system" { + pub fn Process32FirstW( + hSnapshot: HANDLE, + lppe: LPPROCESSENTRY32W, + ) -> BOOL; + pub fn Process32NextW( + hSnapshot: HANDLE, + lppe: LPPROCESSENTRY32W, + ) -> BOOL; +} +STRUCT!{struct PROCESSENTRY32 { + dwSize: DWORD, + cntUsage: DWORD, + th32ProcessID: DWORD, + th32DefaultHeapID: ULONG_PTR, + th32ModuleID: DWORD, + cntThreads: DWORD, + th32ParentProcessID: DWORD, + pcPriClassBase: LONG, + dwFlags: DWORD, + szExeFile: [CHAR; MAX_PATH], +}} +pub type PPROCESSENTRY32 = *mut PROCESSENTRY32; +pub type LPPROCESSENTRY32 = *mut PROCESSENTRY32; +extern "system" { + pub fn Process32First( + hSnapshot: HANDLE, + lppe: LPPROCESSENTRY32, + ) -> BOOL; + pub fn Process32Next( + hSnapshot: HANDLE, + lppe: LPPROCESSENTRY32, + ) -> BOOL; +} +STRUCT!{struct THREADENTRY32 { + dwSize: DWORD, + cntUsage: DWORD, + th32ThreadID: DWORD, + th32OwnerProcessID: DWORD, + tpBasePri: LONG, + tpDeltaPri: LONG, + dwFlags: DWORD, +}} +pub type PTHREADENTRY32 = *mut THREADENTRY32; +pub type LPTHREADENTRY32 = *mut THREADENTRY32; +extern "system" { + pub fn Thread32First( + hSnapshot: HANDLE, + lpte: LPTHREADENTRY32, + ) -> BOOL; + pub fn Thread32Next( + hSnapshot: HANDLE, + lpte: LPTHREADENTRY32, + ) -> BOOL; +} +STRUCT!{struct MODULEENTRY32W { + dwSize: DWORD, + th32ModuleID: DWORD, + th32ProcessID: DWORD, + GlblcntUsage: DWORD, + ProccntUsage: DWORD, + modBaseAddr: *mut BYTE, + modBaseSize: DWORD, + hModule: HMODULE, + szModule: [WCHAR; MAX_MODULE_NAME32 + 1], + szExePath: [WCHAR; MAX_PATH], +}} +pub type PMODULEENTRY32W = *mut MODULEENTRY32W; +pub type LPMODULEENTRY32W = *mut MODULEENTRY32W; +extern "system" { + pub fn Module32FirstW( + hSnapshot: HANDLE, + lpme: LPMODULEENTRY32W, + ) -> BOOL; + pub fn Module32NextW( + hSnapshot: HANDLE, + lpme: LPMODULEENTRY32W, + ) -> BOOL; +} +STRUCT!{struct MODULEENTRY32 { + dwSize: DWORD, + th32ModuleID: DWORD, + th32ProcessID: DWORD, + GlblcntUsage: DWORD, + ProccntUsage: DWORD, + modBaseAddr: *mut BYTE, + modBaseSize: DWORD, + hModule: HMODULE, + szModule: [CHAR; MAX_MODULE_NAME32 + 1], + szExePath: [CHAR; MAX_PATH], +}} +pub type PMODULEENTRY32 = *mut MODULEENTRY32; +pub type LPMODULEENTRY32 = *mut MODULEENTRY32; +extern "system" { + pub fn Module32First( + hSnapshot: HANDLE, + lpme: LPMODULEENTRY32, + ) -> BOOL; + pub fn Module32Next( + hSnapshot: HANDLE, + lpme: LPMODULEENTRY32, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/unknwnbase.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/unknwnbase.rs new file mode 100644 index 0000000..4162fc1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/unknwnbase.rs @@ -0,0 +1,43 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_void; +use shared::guiddef::REFIID; +use shared::minwindef::{BOOL, ULONG}; +use um::winnt::HRESULT; +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IUnknown(IUnknownVtbl) { + fn QueryInterface( + riid: REFIID, + ppvObject: *mut *mut c_void, + ) -> HRESULT, + fn AddRef() -> ULONG, + fn Release() -> ULONG, +}} +pub type LPUNKNOWN = *mut IUnknown; +RIDL!{#[uuid(0x000e0000, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface AsyncIUnknown(AsyncIUnknownVtbl): IUnknown(IUnknownVtbl) { + fn Begin_QueryInterface( + riid: REFIID, + ) -> HRESULT, + fn Finish_QueryInterface( + ppvObject: *mut *mut c_void, + ) -> HRESULT, + fn Begin_AddRef() -> HRESULT, + fn Finish_AddRef() -> ULONG, + fn Begin_Release() -> HRESULT, + fn Finish_Release() -> ULONG, +}} +RIDL!{#[uuid(0x00000001, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IClassFactory(IClassFactoryVtbl): IUnknown(IUnknownVtbl) { + fn CreateInstance( + pUnkOuter: *mut IUnknown, + riid: REFIID, + ppvObject: *mut *mut c_void, + ) -> HRESULT, + fn LockServer( + fLock: BOOL, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/urlhist.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/urlhist.rs new file mode 100644 index 0000000..f35e550 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/urlhist.rs @@ -0,0 +1,97 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Url History Interfaces +use ctypes::c_void; +use shared::guiddef::REFIID; +use shared::minwindef::{BOOL, DWORD, FILETIME, ULONG}; +use shared::wtypesbase::LPCOLESTR; +use um::docobj::{IOleCommandTarget, IOleCommandTargetVtbl}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPWSTR}; +pub const STATURL_QUERYFLAG_ISCACHED: DWORD = 0x00010000; +pub const STATURL_QUERYFLAG_NOURL: DWORD = 0x00020000; +pub const STATURL_QUERYFLAG_NOTITLE: DWORD = 0x00040000; +pub const STATURL_QUERYFLAG_TOPLEVEL: DWORD = 0x00080000; +pub const STATURLFLAG_ISCACHED: DWORD = 0x00000001; +pub const STATURLFLAG_ISTOPLEVEL: DWORD = 0x00000002; +ENUM!{enum ADDURL_FLAG { + ADDURL_FIRST = 0, + ADDURL_ADDTOHISTORYANDCACHE = 0, + ADDURL_ADDTOCACHE = 1, + ADDURL_Max = 2147483647, +}} +pub type LPENUMSTATURL = *mut IEnumSTATURL; +STRUCT!{struct STATURL { + cbSize: DWORD, + pwcsUrl: LPWSTR, + pwcsTitle: LPWSTR, + ftLastVisited: FILETIME, + ftLastUpdated: FILETIME, + ftExpires: FILETIME, + dwFlags: DWORD, +}} +pub type LPSTATURL = *mut STATURL; +RIDL!{#[uuid(0x3c374a42, 0xbae4, 0x11cf, 0xbf, 0x7d, 0x00, 0xaa, 0x00, 0x69, 0x46, 0xee)] +interface IEnumSTATURL(IEnumSTATURLVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: LPSTATURL, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumSTATURL, + ) -> HRESULT, + fn SetFilter( + poszFilter: LPCOLESTR, + dwFlags: DWORD, + ) -> HRESULT, +}} +pub type LPURLHISTORYSTG = *mut IUrlHistoryStg; +RIDL!{#[uuid(0x3c374a41, 0xbae4, 0x11cf, 0xbf, 0x7d, 0x00, 0xaa, 0x00, 0x69, 0x46, 0xee)] +interface IUrlHistoryStg(IUrlHistoryStgVtbl): IUnknown(IUnknownVtbl) { + fn AddUrl( + pocsUrl: LPCOLESTR, + ) -> HRESULT, + fn DeleteUrl( + pocsUrl: LPCOLESTR, + dwFlags: DWORD, + ) -> HRESULT, + fn QueryUrl( + pocsUrl: LPCOLESTR, + dwFlags: DWORD, + lpSTATURL: LPSTATURL, + ) -> HRESULT, + fn BindToObject( + pocsUrl: LPCOLESTR, + riid: REFIID, + ppvOut: *mut *mut c_void, + ) -> HRESULT, + fn EnumUrls( + ppEnum: *mut *mut IEnumSTATURL, + ) -> HRESULT, +}} +pub type LPURLHISTORYSTG2 = *mut IUrlHistoryStg2; +RIDL!{#[uuid(0xafa0dc11, 0xc313, 0x11d0, 0x83, 0x1a, 0x00, 0xc0, 0x4f, 0xd5, 0xae, 0x38)] +interface IUrlHistoryStg2(IUrlHistoryStg2Vtbl): IUrlHistoryStg(IUrlHistoryStgVtbl) { + fn AddUrlAndNotify( + pocsUrl: LPCOLESTR, + pocsTitle: LPCOLESTR, + dwFlags: DWORD, + fWriteHistory: BOOL, + poctNotify: *mut IOleCommandTarget, + punkISFolder: *mut IUnknown, + ) -> HRESULT, + fn ClearHistory() -> HRESULT, +}} +pub type LPURLHISTORYNOTIFY = *mut IUrlHistoryNotify; +RIDL!{#[uuid(0xbc40bec1, 0xc493, 0x11d0, 0x83, 0x1b, 0x00, 0xc0, 0x4f, 0xd5, 0xae, 0x38)] +interface IUrlHistoryNotify(IUrlHistoryNotifyVtbl): + IOleCommandTarget(IOleCommandTargetVtbl) {} +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/urlmon.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/urlmon.rs new file mode 100644 index 0000000..bdcbada --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/urlmon.rs @@ -0,0 +1,21 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! URL Moniker interfaces +use shared::minwindef::DWORD; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LPCWSTR}; +RIDL!{#[uuid(0x79eac9ee, 0xbaf9, 0x11ce, 0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b)] +interface IInternetSecurityManager(IInternetSecurityManagerVtbl): IUnknown(IUnknownVtbl) { + fn SetSecuritySite() -> HRESULT, + fn GetSecuritySite() -> HRESULT, + fn MapUrlToZone( + pwszUrl: LPCWSTR, + pdwZone: *mut DWORD, + dwFlags: DWORD, + ) -> HRESULT, + // TODO: the rest +}} +// TODO: the rest diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/userenv.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/userenv.rs new file mode 100644 index 0000000..ea0af96 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/userenv.rs @@ -0,0 +1,159 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Definitions for the user environment API +use shared::minwindef::{BOOL, DWORD, LPDWORD, LPVOID, PHKEY}; +use um::winnt::{ + HANDLE, HRESULT, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PCWSTR, PSID, PSID_AND_ATTRIBUTES, PWSTR +}; +use um::winreg::REGSAM; +extern "system" { + // pub fn LoadUserProfileA( + // hToken: HANDLE, + // lpProfileInfo: LPPROFILEINFOA, + // ) -> BOOL; + // pub fn LoadUserProfileW( + // hToken: HANDLE, + // lpProfileInfo: LPPROFILEINFOW, + // ) -> BOOL; + pub fn UnloadUserProfile( + hToken: HANDLE, + hProfile: HANDLE, + ) -> BOOL; + pub fn GetProfilesDirectoryA( + lpProfileDir: LPSTR, + lpcchSize: LPDWORD, + ) -> BOOL; + pub fn GetProfilesDirectoryW( + lpProfileDir: LPWSTR, + lpcchSize: LPDWORD, + ) -> BOOL; + pub fn GetProfileType( + dwFlags: *mut DWORD, + ) -> BOOL; + pub fn DeleteProfileA( + lpSidString: LPCSTR, + lpProfilePath: LPCSTR, + lpComputerName: LPCSTR, + ) -> BOOL; + pub fn DeleteProfileW( + lpSidString: LPCWSTR, + lpProfilePath: LPCWSTR, + lpComputerName: LPCWSTR, + ) -> BOOL; + pub fn CreateProfile( + pszUserSid: LPCWSTR, + pszUserName: LPCWSTR, + pszProfilePath: LPWSTR, + cchProfilePath: DWORD, + ) -> HRESULT; + pub fn GetDefaultUserProfileDirectoryA( + lpProfileDir: LPSTR, + lpcchSize: LPDWORD, + ) -> BOOL; + pub fn GetDefaultUserProfileDirectoryW( + lpProfileDir: LPWSTR, + lpcchSize: LPDWORD, + ) -> BOOL; + pub fn GetAllUsersProfileDirectoryA( + lpProfileDir: LPSTR, + lpcchSize: LPDWORD, + ) -> BOOL; + pub fn GetAllUsersProfileDirectoryW( + lpProfileDir: LPWSTR, + lpcchSize: LPDWORD, + ) -> BOOL; + pub fn GetUserProfileDirectoryA( + hToken: HANDLE, + lpProfileDir: LPSTR, + lpcchSize: LPDWORD, + ) -> BOOL; + pub fn GetUserProfileDirectoryW( + hToken: HANDLE, + lpProfileDir: LPWSTR, + lpcchSize: LPDWORD, + ) -> BOOL; + pub fn CreateEnvironmentBlock( + lpEnvironment: *mut LPVOID, + hToken: HANDLE, + bInherit: BOOL, + ) -> BOOL; + pub fn DestroyEnvironmentBlock( + lpEnvironment: LPVOID, + ) -> BOOL; + pub fn ExpandEnvironmentStringsForUserA( + hToken: HANDLE, + lpSrc: LPCSTR, + lpDest: LPSTR, + dwSize: DWORD, + ) -> BOOL; + pub fn ExpandEnvironmentStringsForUserW( + hToken: HANDLE, + lpSrc: LPCWSTR, + lpDest: LPWSTR, + dwSize: DWORD, + ) -> BOOL; + pub fn RefreshPolicy( + bMachine: BOOL, + ) -> BOOL; + pub fn RefreshPolicyEx( + bMachine: BOOL, + dwOptions: DWORD, + ) -> BOOL; + pub fn EnterCriticalPolicySection( + bMachine: BOOL, + ) -> HANDLE; + pub fn LeaveCriticalPolicySection( + hSection: HANDLE, + ) -> BOOL; + pub fn RegisterGPNotification( + hEvent: HANDLE, + bMachine: BOOL, + ) -> BOOL; + pub fn UnregisterGPNotification( + hEvent: HANDLE, + ) -> BOOL; + // pub fn GetGPOListA(); + // pub fn GetGPOListW(); + // pub fn FreeGPOListA(); + // pub fn FreeGPOListW(); + // pub fn GetAppliedGPOListA(); + // pub fn GetAppliedGPOListW(); + // pub fn ProcessGroupPolicyCompleted(); + // pub fn ProcessGroupPolicyCompletedEx(); + // pub fn RsopAccessCheckByType(); + // pub fn RsopFileAccessCheck(); + // pub fn RsopSetPolicySettingStatus(); + // pub fn RsopResetPolicySettingStatus(); + // pub fn GenerateGPNotification(); + pub fn CreateAppContainerProfile( + pszAppContainerName: PCWSTR, + pszDisplayName: PCWSTR, + pszDescription: PCWSTR, + pCapabilities: PSID_AND_ATTRIBUTES, + dwCapabilityCount: DWORD, + ppSidAppContainerSid: *mut PSID, + ) -> HRESULT; + pub fn DeleteAppContainerProfile( + pszAppContainerName: PCWSTR, + ) -> HRESULT; + pub fn GetAppContainerRegistryLocation( + desiredAccess: REGSAM, + phAppContainerKey: PHKEY, + ) -> HRESULT; + pub fn GetAppContainerFolderPath( + pszAppContainerSid: PCWSTR, + ppszPath: *mut PWSTR, + ) -> HRESULT; + pub fn DeriveAppContainerSidFromAppContainerName( + pszAppContainerName: PCWSTR, + ppsidAppContainerSid: *mut PSID, + ) -> HRESULT; + pub fn DeriveRestrictedAppContainerSidFromAppContainerSidAndRestrictedName( + psidAppContainerSid: PSID, + pszRestrictedAppContainerName: PCWSTR, + ppsidRestrictedAppContainerSid: *mut PSID, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/usp10.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/usp10.rs new file mode 100644 index 0000000..b2f24be --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/usp10.rs @@ -0,0 +1,560 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Unicode Complex Script processor API declarations +use ctypes::{c_int, c_long, c_void}; +use shared::minwindef::{BOOL, BYTE, DWORD, UINT, ULONG, WORD}; +use shared::ntdef::LCID; +use shared::windef::{HDC, RECT, SIZE}; +use shared::winerror::{FACILITY_ITF, SEVERITY_ERROR}; +use um::wingdi::ABC; +use um::winnt::{HRESULT, LONG, WCHAR}; +pub const SCRIPT_UNDEFINED: WORD = 0; +pub const USP_E_SCRIPT_NOT_IN_FONT: HRESULT = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_ITF, 0x200); +DECLARE_HANDLE!{SCRIPT_CACHE, SCRIPT_CACHE__} +extern "system" { + pub fn ScriptFreeCache( + psc: *mut SCRIPT_CACHE, + ) -> HRESULT; +} +STRUCT!{struct SCRIPT_CONTROL { + bit_fields: DWORD, +}} +BITFIELD!{SCRIPT_CONTROL bit_fields: DWORD [ + uDefaultLanguage set_uDefaultLanguage[0..16], + fContextDigits set_fContextDigits[16..17], + fInvertPreBoundDir set_fInvertPreBoundDir[17..18], + fInvertPostBoundDir set_fInvertPostBoundDir[18..19], + fLinkStringBefore set_fLinkStringBefore[19..20], + fLinkStringAfter set_fLinkStringAfter[20..21], + fNeutralOverride set_fNeutralOverride[21..22], + fNumericOverride set_fNumericOverride[22..23], + fLegacyBidiClass set_fLegacyBidiClass[23..24], + fMergeNeutralItems set_fMergeNeutralItems[24..25], + fReserved set_fReserved[25..32], +]} +STRUCT!{struct SCRIPT_STATE { + bit_fields: WORD, +}} +BITFIELD!{SCRIPT_STATE bit_fields: WORD [ + uBidiLevel set_uBidiLevel[0..5], + fOverrideDirection set_fOverrideDirection[5..6], + fInhibitSymSwap set_fInhibitSymSwap[6..7], + fCharShape set_fCharShape[7..8], + fDigitSubstitute set_fDigitSubstitute[8..9], + fInhibitLigate set_fInhibitLigate[9..10], + fDisplayZWG set_fDisplayZWG[10..11], + fArabicNumContext set_fArabicNumContext[11..12], + fGcpClusters set_fGcpClusters[12..13], + fReserved set_fReserved[13..14], + fEngineReserved set_fEngineReserved[14..16], +]} +STRUCT!{struct SCRIPT_ANALYSIS { + bit_fields: WORD, + s: SCRIPT_STATE, +}} +BITFIELD!{SCRIPT_ANALYSIS bit_fields: WORD [ + eScript set_eScript[0..10], + fRTL set_fRTL[10..11], + fLayoutRTL set_fLayoutRTL[11..12], + fLinkBefore set_fLinkBefore[12..13], + fLinkAfter set_fLinkAfter[13..14], + fLogicalOrder set_fLogicalOrder[14..15], + fNoGlyphIndex set_fNoGlyphIndex[15..16], +]} +STRUCT!{struct SCRIPT_ITEM { + iCharPos: c_int, + a: SCRIPT_ANALYSIS, +}} +extern "system" { + pub fn ScriptItemize( + pwcInChars: *const WCHAR, + cInChars: c_int, + cMaxItems: c_int, + psControl: *const SCRIPT_CONTROL, + psState: *const SCRIPT_STATE, + pItems: *mut SCRIPT_ITEM, + pcItems: *mut c_int, + ) -> HRESULT; + pub fn ScriptLayout( + cRuns: c_int, + pbLevel: *const BYTE, + piVisualToLogical: *mut c_int, + piLogicalToVisual: *mut c_int, + ) -> HRESULT; +} +pub const SCRIPT_JUSTIFY_NONE: WORD = 0; +pub const SCRIPT_JUSTIFY_ARABIC_BLANK: WORD = 1; +pub const SCRIPT_JUSTIFY_CHARACTER: WORD = 2; +pub const SCRIPT_JUSTIFY_RESERVED1: WORD = 3; +pub const SCRIPT_JUSTIFY_BLANK: WORD = 4; +pub const SCRIPT_JUSTIFY_RESERVED2: WORD = 5; +pub const SCRIPT_JUSTIFY_RESERVED3: WORD = 6; +pub const SCRIPT_JUSTIFY_ARABIC_NORMAL: WORD = 7; +pub const SCRIPT_JUSTIFY_ARABIC_KASHIDA: WORD = 8; +pub const SCRIPT_JUSTIFY_ARABIC_ALEF: WORD = 9; +pub const SCRIPT_JUSTIFY_ARABIC_HA: WORD = 10; +pub const SCRIPT_JUSTIFY_ARABIC_RA: WORD = 11; +pub const SCRIPT_JUSTIFY_ARABIC_BA: WORD = 12; +pub const SCRIPT_JUSTIFY_ARABIC_BARA: WORD = 13; +pub const SCRIPT_JUSTIFY_ARABIC_SEEN: WORD = 14; +pub const SCRIPT_JUSTIFY_ARABIC_SEEN_M: WORD = 15; +STRUCT!{struct SCRIPT_VISATTR { + bit_fields: WORD, +}} +BITFIELD!{SCRIPT_VISATTR bit_fields: WORD [ + uJustification set_uJustification[0..4], + fClusterStart set_fClusterStart[4..5], + fDiacritic set_fDiacritic[5..6], + fZeroWidth set_fZeroWidth[6..7], + fReserved set_fReserved[7..8], + fShapeReserved set_fShapeReserved[8..16], +]} +extern "system" { + pub fn ScriptShape( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + pwcChars: *const WCHAR, + cChars: c_int, + cMaxGlyphs: c_int, + psa: *mut SCRIPT_ANALYSIS, + pwOutGlyphs: *mut WORD, + pwLogClust: *mut WORD, + psva: *mut SCRIPT_VISATTR, + pcGlyphs: *mut c_int, + ) -> HRESULT; +} +STRUCT!{struct GOFFSET { + du: LONG, + dv: LONG, +}} +extern "system" { + pub fn ScriptPlace( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + pwGlyphs: *const WORD, + cGlyphs: c_int, + psva: *const SCRIPT_VISATTR, + psa: *mut SCRIPT_ANALYSIS, + piAdvance: *mut c_int, + pGoffset: *mut GOFFSET, + pABC: *mut ABC, + ) -> HRESULT; + pub fn ScriptTextOut( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + x: c_int, + y: c_int, + fuOptions: UINT, + lprc: *const RECT, + psa: *const SCRIPT_ANALYSIS, + pwcReserved: *const WCHAR, + iReserved: c_int, + pwGlyphs: *const WORD, + cGlyphs: c_int, + piAdvance: *const c_int, + piJustify: *const c_int, + pGoffset: *const GOFFSET, + ) -> HRESULT; + pub fn ScriptJustify( + psva: *const SCRIPT_VISATTR, + piAdvance: *const c_int, + cGlyphs: c_int, + iDx: c_int, + iMinKashida: c_int, + piJustify: *mut c_int, + ) -> HRESULT; +} +STRUCT!{struct SCRIPT_LOGATTR { + bit_fields: BYTE, +}} +BITFIELD!{SCRIPT_LOGATTR bit_fields: BYTE [ + fSoftBreak set_fSoftBreak[0..1], + fWhiteSpace set_fWhiteSpace[1..2], + fCharStop set_fCharStop[2..3], + fWordStop set_fWordStop[3..4], + fInvalid set_fInvalid[4..5], + fReserved set_fReserved[5..8], +]} +extern "system" { + pub fn ScriptBreak( + pwcChars: *const WCHAR, + cChars: c_int, + psa: *const SCRIPT_ANALYSIS, + psla: *mut SCRIPT_LOGATTR, + ) -> HRESULT; + pub fn ScriptCPtoX( + iCP: c_int, + fTrailing: BOOL, + cChars: c_int, + cGlyphs: c_int, + pwLogClust: *const WORD, + psva: *const SCRIPT_VISATTR, + piAdvance: *const c_int, + psa: *const SCRIPT_ANALYSIS, + piX: *mut c_int, + ) -> HRESULT; + pub fn ScriptXtoCP( + iX: c_int, + cChars: c_int, + cGlyphs: c_int, + pwLogClust: *const WORD, + psva: *const SCRIPT_VISATTR, + piAdvance: *const c_int, + psa: *const SCRIPT_ANALYSIS, + piCP: *mut c_int, + piTrailing: *mut c_int, + ) -> HRESULT; + pub fn ScriptGetLogicalWidths( + psa: *const SCRIPT_ANALYSIS, + cChars: c_int, + cGlyphs: c_int, + piGlyphWidth: *const c_int, + pwLogClust: *const WORD, + psva: *const SCRIPT_VISATTR, + piDx: *mut c_int, + ) -> HRESULT; + pub fn ScriptApplyLogicalWidth( + piDx: *const c_int, + cChars: c_int, + cGlyphs: c_int, + pwLogClust: *const WORD, + psva: *const SCRIPT_VISATTR, + piAdvance: *const c_int, + psa: *const SCRIPT_ANALYSIS, + pABC: *mut ABC, + piJustify: *mut c_int, + ) -> HRESULT; +} +pub const SGCM_RTL: DWORD = 0x00000001; +extern "system" { + pub fn ScriptGetCMap( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + pwcInChars: *const WCHAR, + cChars: c_int, + dwFlags: DWORD, + pwOutGlyphs: *mut WORD, + ) -> HRESULT; + pub fn ScriptGetGlyphABCWidth( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + wGlyph: WORD, + pABC: *mut ABC, + ) -> HRESULT; +} +STRUCT!{struct SCRIPT_PROPERTIES { + bit_fields1: DWORD, + bit_fields2: DWORD, +}} +BITFIELD!{SCRIPT_PROPERTIES bit_fields1: DWORD [ + langid set_langid[0..16], + fNumeric set_fNumeric[16..17], + fComplex set_fComplex[17..18], + fNeedsWordBreaking set_fNeedsWordBreaking[18..19], + fNeedsCaretInfo set_fNeedsCaretInfo[19..20], + bCharSet set_bCharSet[20..28], + fControl set_fControl[28..29], + fPrivateUseArea set_fPrivateUseArea[29..30], + fNeedsCharacterJustify set_fNeedsCharacterJustify[30..31], + fInvalidGlyph set_fInvalidGlyph[31..32], +]} +BITFIELD!{SCRIPT_PROPERTIES bit_fields2: DWORD [ + fInvalidLogAttr set_fInvalidLogAttr[0..1], + fCDM set_fCDM[1..2], + fAmbiguousCharSet set_fAmbiguousCharSet[2..3], + fClusterSizeVaries set_fClusterSizeVaries[3..4], + fRejectInvalid set_fRejectInvalid[4..5], +]} +extern "system" { + pub fn ScriptGetProperties( + ppSp: *mut *mut *const SCRIPT_PROPERTIES, + piNumScripts: *mut c_int, + ) -> HRESULT; +} +STRUCT!{struct SCRIPT_FONTPROPERTIES { + cBytes: c_int, + wgBlank: WORD, + wgDefault: WORD, + wgInvalid: WORD, + wgKashida: WORD, + iKashidaWidth: c_int, +}} +extern "system" { + pub fn ScriptGetFontProperties( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + sfp: *mut SCRIPT_FONTPROPERTIES, + ) -> HRESULT; + pub fn ScriptCacheGetHeight( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + tmHeight: *mut c_long, + ) -> HRESULT; +} +pub const SSA_PASSWORD: DWORD = 0x00000001; +pub const SSA_TAB: DWORD = 0x00000002; +pub const SSA_CLIP: DWORD = 0x00000004; +pub const SSA_FIT: DWORD = 0x00000008; +pub const SSA_DZWG: DWORD = 0x00000010; +pub const SSA_FALLBACK: DWORD = 0x00000020; +pub const SSA_BREAK: DWORD = 0x00000040; +pub const SSA_GLYPHS: DWORD = 0x00000080; +pub const SSA_RTL: DWORD = 0x00000100; +pub const SSA_GCP: DWORD = 0x00000200; +pub const SSA_HOTKEY: DWORD = 0x00000400; +pub const SSA_METAFILE: DWORD = 0x00000800; +pub const SSA_LINK: DWORD = 0x00001000; +pub const SSA_HIDEHOTKEY: DWORD = 0x00002000; +pub const SSA_HOTKEYONLY: DWORD = 0x00002400; +pub const SSA_FULLMEASURE: DWORD = 0x04000000; +pub const SSA_LPKANSIFALLBACK: DWORD = 0x08000000; +pub const SSA_PIDX: DWORD = 0x10000000; +pub const SSA_LAYOUTRTL: DWORD = 0x20000000; +pub const SSA_DONTGLYPH: DWORD = 0x40000000; +pub const SSA_NOKASHIDA: DWORD = 0x80000000; +STRUCT!{struct SCRIPT_TABDEF { + cTabStops: c_int, + iScale: c_int, + pTabStops: *mut c_int, + iTabOrigin: c_int, +}} +DECLARE_HANDLE!{SCRIPT_STRING_ANALYSIS, SCRIPT_STRING_ANALYSIS__} +extern "system" { + pub fn ScriptStringAnalyse( + hdc: HDC, + pString: *const c_void, + cString: c_int, + cGlyphs: c_int, + iCharset: c_int, + dwFlags: DWORD, + iReqWidth: c_int, + psControl: *mut SCRIPT_CONTROL, + psState: *mut SCRIPT_STATE, + piDx: *const c_int, + pTabdef: *mut SCRIPT_TABDEF, + pbInClass: *const BYTE, + pssa: *mut SCRIPT_STRING_ANALYSIS, + ) -> HRESULT; + pub fn ScriptStringFree( + pssa: *mut SCRIPT_STRING_ANALYSIS, + ) -> HRESULT; + pub fn ScriptString_pSize( + ssa: SCRIPT_STRING_ANALYSIS, + ) -> *const SIZE; + pub fn ScriptString_pcOutChars( + ssa: SCRIPT_STRING_ANALYSIS, + ) -> *const c_int; + pub fn ScriptString_pLogAttr( + ssa: SCRIPT_STRING_ANALYSIS, + ) -> *const SCRIPT_LOGATTR; + pub fn ScriptStringGetOrder( + ssa: SCRIPT_STRING_ANALYSIS, + puOrder: *mut UINT, + ) -> HRESULT; + pub fn ScriptStringCPtoX( + ssa: SCRIPT_STRING_ANALYSIS, + icp: c_int, + fTrailing: BOOL, + pX: *mut c_int, + ) -> HRESULT; + pub fn ScriptStringXtoCP( + ssa: SCRIPT_STRING_ANALYSIS, + iX: c_int, + piCh: *mut c_int, + piTrailing: *mut c_int, + ) -> HRESULT; + pub fn ScriptStringGetLogicalWidths( + ssa: SCRIPT_STRING_ANALYSIS, + dpiDx: *mut c_int, + ) -> HRESULT; + pub fn ScriptStringValidate( + ssa: SCRIPT_STRING_ANALYSIS, + ) -> HRESULT; + pub fn ScriptStringOut( + ssa: SCRIPT_STRING_ANALYSIS, + iX: c_int, + iY: c_int, + uOptions: UINT, + prc: *const RECT, + iMinSel: c_int, + iMaxSel: c_int, + fDisabled: BOOL, + ) -> HRESULT; +} +pub const SIC_COMPLEX: DWORD = 1; +pub const SIC_ASCIIDIGIT: DWORD = 2; +pub const SIC_NEUTRAL: DWORD = 4; +extern "system" { + pub fn ScriptIsComplex( + pwcInChars: *const WCHAR, + cInChars: c_int, + dwFlags: DWORD, + ) -> HRESULT; +} +STRUCT!{struct SCRIPT_DIGITSUBSTITUTE { + bit_fields1: DWORD, + bit_fields2: DWORD, + dwReserved: DWORD, +}} +BITFIELD!{SCRIPT_DIGITSUBSTITUTE bit_fields1: DWORD [ + NationalDigitLanguage set_NationalDigitLanguage[0..16], + TraditionalDigitLanguage set_TraditionalDigitLanguage[16..32], +]} +BITFIELD!{SCRIPT_DIGITSUBSTITUTE bit_fields2: DWORD [ + DigitSubstitute set_DigitSubstitute[0..8], +]} +extern "system" { + pub fn ScriptRecordDigitSubstitution( + Locale: LCID, + psds: *mut SCRIPT_DIGITSUBSTITUTE, + ) -> HRESULT; +} +pub const SCRIPT_DIGITSUBSTITUTE_CONTEXT: BYTE = 0; +pub const SCRIPT_DIGITSUBSTITUTE_NONE: BYTE = 1; +pub const SCRIPT_DIGITSUBSTITUTE_NATIONAL: BYTE = 2; +pub const SCRIPT_DIGITSUBSTITUTE_TRADITIONAL: BYTE = 3; +extern "system" { + pub fn ScriptApplyDigitSubstitution( + psds: *const SCRIPT_DIGITSUBSTITUTE, + psc: *mut SCRIPT_CONTROL, + pss: *mut SCRIPT_STATE, + ) -> HRESULT; +} +pub type OPENTYPE_TAG = ULONG; +pub const SCRIPT_TAG_UNKNOWN: OPENTYPE_TAG = 0x00000000; +STRUCT!{struct OPENTYPE_FEATURE_RECORD { + tagFeature: OPENTYPE_TAG, + lParameter: LONG, +}} +STRUCT!{struct TEXTRANGE_PROPERTIES { + potfRecords: *mut OPENTYPE_FEATURE_RECORD, + cotfRecords: c_int, +}} +STRUCT!{struct SCRIPT_CHARPROP { + bit_fields: WORD, +}} +BITFIELD!{SCRIPT_CHARPROP bit_fields: WORD [ + fCanGlyphAlone set_fCanGlyphAlone[0..1], + reserved set_reserved[1..16], +]} +STRUCT!{struct SCRIPT_GLYPHPROP { + sva: SCRIPT_VISATTR, + reserved: WORD, +}} +extern "system" { + pub fn ScriptShapeOpenType( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + psa: *mut SCRIPT_ANALYSIS, + tagScript: OPENTYPE_TAG, + tagLangSys: OPENTYPE_TAG, + rcRangeChars: *mut c_int, + rpRangeProperties: *mut *mut TEXTRANGE_PROPERTIES, + cRanges: c_int, + pwcChars: *const WCHAR, + cChars: c_int, + cMaxGlyphs: c_int, + pwLogClust: *mut WORD, + pCharProps: *mut SCRIPT_CHARPROP, + pwOutGlyphs: *mut WORD, + pOutGlyphProps: *mut SCRIPT_GLYPHPROP, + pcGlyphs: *mut c_int, + ) -> HRESULT; + pub fn ScriptPlaceOpenType( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + psa: *mut SCRIPT_ANALYSIS, + tagScript: OPENTYPE_TAG, + tagLangSys: OPENTYPE_TAG, + rcRangeChars: *mut c_int, + rpRangeProperties: *mut *mut TEXTRANGE_PROPERTIES, + cRanges: c_int, + pwcChars: *const WCHAR, + pwLogClust: *mut WORD, + pCharProps: *mut SCRIPT_CHARPROP, + cChars: c_int, + pwGlyphs: *const WORD, + pGlyphProps: *const SCRIPT_GLYPHPROP, + cGlyphs: c_int, + piAdvance: *mut c_int, + pGoffset: *mut GOFFSET, + pABC: *mut ABC, + ) -> HRESULT; + pub fn ScriptItemizeOpenType( + pwcInChars: *const WCHAR, + cInChars: c_int, + cMaxItems: c_int, + psControl: *const SCRIPT_CONTROL, + psState: *const SCRIPT_STATE, + pItems: *mut SCRIPT_ITEM, + pScriptTags: *mut OPENTYPE_TAG, + pcItems: *mut c_int, + ) -> HRESULT; + pub fn ScriptGetFontScriptTags( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + psa: *mut SCRIPT_ANALYSIS, + cMaxTags: c_int, + pScriptTags: *mut OPENTYPE_TAG, + pcTags: *mut c_int, + ) -> HRESULT; + pub fn ScriptGetFontLanguageTags( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + psa: *mut SCRIPT_ANALYSIS, + tagScript: OPENTYPE_TAG, + cMaxTags: c_int, + pLangsysTags: *mut OPENTYPE_TAG, + pcTags: *mut c_int, + ) -> HRESULT; + pub fn ScriptGetFontFeatureTags( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + psa: *mut SCRIPT_ANALYSIS, + tagScript: OPENTYPE_TAG, + tagLangSys: OPENTYPE_TAG, + cMaxTags: c_int, + pFeatureTags: *mut OPENTYPE_TAG, + pcTags: *mut c_int, + ) -> HRESULT; + pub fn ScriptGetFontAlternateGlyphs( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + psa: *mut SCRIPT_ANALYSIS, + tagScript: OPENTYPE_TAG, + tagLangSys: OPENTYPE_TAG, + tagFeature: OPENTYPE_TAG, + wGlyphId: WORD, + cMaxAlternates: c_int, + pAlternateGlyphs: *mut WORD, + pcAlternates: *mut c_int, + ) -> HRESULT; + pub fn ScriptSubstituteSingleGlyph( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + psa: *mut SCRIPT_ANALYSIS, + tagScript: OPENTYPE_TAG, + tagLangSys: OPENTYPE_TAG, + tagFeature: OPENTYPE_TAG, + lParameter: LONG, + wGlyphId: WORD, + pwOutGlyphId: *mut WORD, + ) -> HRESULT; + pub fn ScriptPositionSingleGlyph( + hdc: HDC, + psc: *mut SCRIPT_CACHE, + psa: *mut SCRIPT_ANALYSIS, + tagScript: OPENTYPE_TAG, + tagLangSys: OPENTYPE_TAG, + tagFeature: OPENTYPE_TAG, + lParameter: LONG, + wGlyphId: WORD, + iAdvance: c_int, + GOffset: GOFFSET, + piOutAdvance: *mut c_int, + pOutGoffset: *mut GOFFSET, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/utilapiset.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/utilapiset.rs new file mode 100644 index 0000000..0ef86e3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/utilapiset.rs @@ -0,0 +1,25 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, DWORD}; +use shared::ntdef::PVOID; +extern "system" { + pub fn EncodePointer( + Ptr: PVOID, + ) -> PVOID; + pub fn DecodePointer( + Ptr: PVOID, + ) -> PVOID; + pub fn EncodeSystemPointer( + Ptr: PVOID, + ) -> PVOID; + pub fn DecodeSystemPointer( + Ptr: PVOID, + ) -> PVOID; + pub fn Beep( + dwFreq: DWORD, + dwDuration: DWORD, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/uxtheme.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/uxtheme.rs new file mode 100644 index 0000000..0e046a3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/uxtheme.rs @@ -0,0 +1,772 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! theming API +use ctypes::{c_float, c_int, c_void}; +use shared::minwindef::{BOOL, BYTE, DWORD, HINSTANCE, HRGN, LPARAM, UINT, ULONG, WORD}; +use shared::windef::{COLORREF, HBITMAP, HBRUSH, HDC, HWND, LPCRECT, LPRECT, POINT, RECT, SIZE}; +use um::commctrl::HIMAGELIST; +use um::wingdi::{BLENDFUNCTION, LOGFONTW, RGBQUAD, TEXTMETRICW}; +use um::winnt::{HANDLE, HRESULT, LONG, LPCWSTR, LPWSTR, PVOID, VOID}; +pub type HTHEME = HANDLE; +//pub const MAX_THEMECOLOR: u32 = 64; +//pub const MAX_THEMESIZE: u32 = 64; +extern "system" { + pub fn BeginPanningFeedback( + hwnd: HWND, + ) -> BOOL; + pub fn UpdatePanningFeedback( + hwnd: HWND, + lTotalOverpanOffsetX: LONG, + lTotalOverpanOffsetY: LONG, + fInInertia: BOOL, + ) -> BOOL; + pub fn EndPanningFeedback( + hwnd: HWND, + fAnimateBack: BOOL, + ) -> BOOL; +} +ENUM!{enum TA_PROPERTY { + TAP_FLAGS = 0, + TAP_TRANSFORMCOUNT = 1, + TAP_STAGGERDELAY = 2, + TAP_STAGGERDELAYCAP = 3, + TAP_STAGGERDELAYFACTOR = 4, + TAP_ZORDER = 5, +}} +ENUM!{enum TA_PROPERTY_FLAG { + TAPF_NONE = 0x0, + TAPF_HASSTAGGER = 0x1, + TAPF_ISRTLAWARE = 0x2, + TAPF_ALLOWCOLLECTION = 0x4, + TAPF_HASBACKGROUND = 0x8, + TAPF_HASPERSPECTIVE = 0x10, +}} +extern "system" { + pub fn GetThemeAnimationProperty( + hTheme: HTHEME, + iStoryboardId: c_int, + iTargetId: c_int, + eProperty: TA_PROPERTY, + pvProperty: *mut VOID, + cbSize: DWORD, + pcbSizeOut: *mut DWORD, + ) -> HRESULT; +} +ENUM!{enum TA_TRANSFORM_TYPE { + TATT_TRANSLATE_2D = 0, + TATT_SCALE_2D = 1, + TATT_OPACITY = 2, + TATT_CLIP = 3, +}} +ENUM!{enum TA_TRANSFORM_FLAG { + TATF_NONE = 0x0, + TATF_TARGETVALUES_USER = 0x1, + TATF_HASINITIALVALUES = 0x2, + TATF_HASORIGINVALUES = 0x4, +}} +STRUCT!{struct TA_TRANSFORM { + eTransformType: TA_TRANSFORM_TYPE, + dwTimingFunctionId: DWORD, + dwStartTime: DWORD, + dwDurationTime: DWORD, + eFlags: TA_TRANSFORM_FLAG, +}} +pub type PTA_TRANSFORM = *mut TA_TRANSFORM; +STRUCT!{struct TA_TRANSFORM_2D { + header: TA_TRANSFORM, + rX: c_float, + rY: c_float, + rInitialX: c_float, + rInitialY: c_float, + rOriginX: c_float, + rOriginY: c_float, +}} +pub type PTA_TRANSFORM_2D = *mut TA_TRANSFORM_2D; +STRUCT!{struct TA_TRANSFORM_OPACITY { + header: TA_TRANSFORM, + rOpacity: c_float, + rInitialOpacity: c_float, +}} +pub type PTA_TRANSFORM_OPACITY = *mut TA_TRANSFORM_OPACITY; +STRUCT!{struct TA_TRANSFORM_CLIP { + header: TA_TRANSFORM, + rLeft: c_float, + rTop: c_float, + rRight: c_float, + rBottom: c_float, + rInitialLeft: c_float, + rInitialTop: c_float, + rInitialRight: c_float, + rInitialBottom: c_float, +}} +pub type PTA_TRANSFORM_CLIP = *mut TA_TRANSFORM_CLIP; +extern "system" { + pub fn GetThemeAnimationTransform( + hTheme: HTHEME, + iStoryboardId: c_int, + iTargetId: c_int, + dwTransformIndex: DWORD, + pTransform: *mut TA_TRANSFORM, + cbSize: DWORD, + pcbSizeOut: *mut DWORD, + ) -> HRESULT; +} +ENUM!{enum TA_TIMINGFUNCTION_TYPE { + TTFT_UNDEFINED = 0, + TTFT_CUBIC_BEZIER = 1, +}} +STRUCT!{struct TA_TIMINGFUNCTION { + eTimingFunctionType: TA_TIMINGFUNCTION_TYPE, +}} +pub type PTA_TIMINGFUNCTION = *mut TA_TIMINGFUNCTION; +STRUCT!{struct TA_CUBIC_BEZIER { + header: TA_TIMINGFUNCTION, + rX0: c_float, + rY0: c_float, + rX1: c_float, + rY1: c_float, +}} +pub type PTA_CUBIC_BEZIER = *mut TA_CUBIC_BEZIER; +extern "system" { + pub fn GetThemeTimingFunction( + hTheme: HTHEME, + iTimingFunctionId: c_int, + pTimingFunction: *mut TA_TIMINGFUNCTION, + cbSize: DWORD, + pcbSizeOut: *mut DWORD, + ) -> HRESULT; + pub fn OpenThemeData( + hwnd: HWND, + pszClassList: LPCWSTR, + ) -> HTHEME; +} +pub const OTD_FORCE_RECT_SIZING: DWORD = 0x00000001; +pub const OTD_NONCLIENT: DWORD = 0x00000002; +pub const OTD_VALIDBITS: DWORD = OTD_FORCE_RECT_SIZING | OTD_NONCLIENT; +extern "system" { + pub fn OpenThemeDataForDpi( + hwnd: HWND, + pszClassList: LPCWSTR, + dpi: UINT, + ) -> HTHEME; + pub fn OpenThemeDataEx( + hwnd: HWND, + pszClassList: LPCWSTR, + dwFlags: DWORD, + ) -> HTHEME; + pub fn CloseThemeData( + hTheme: HTHEME, + ) -> HRESULT; + pub fn DrawThemeBackground( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pRect: LPCRECT, + pClipRect: LPCRECT, + ) -> HRESULT; +} +pub const DTBG_CLIPRECT: DWORD = 0x00000001; +pub const DTBG_DRAWSOLID: DWORD = 0x00000002; +pub const DTBG_OMITBORDER: DWORD = 0x00000004; +pub const DTBG_OMITCONTENT: DWORD = 0x00000008; +pub const DTBG_COMPUTINGREGION: DWORD = 0x00000010; +pub const DTBG_MIRRORDC: DWORD = 0x00000020; +pub const DTBG_NOMIRROR: DWORD = 0x00000040; +pub const DTBG_VALIDBITS: DWORD = DTBG_CLIPRECT | DTBG_DRAWSOLID | DTBG_OMITBORDER + | DTBG_OMITCONTENT | DTBG_COMPUTINGREGION | DTBG_MIRRORDC | DTBG_NOMIRROR; +STRUCT!{struct DTBGOPTS { + dwSize: DWORD, + dwFlags: DWORD, + rcClip: RECT, +}} +pub type PDTBGOPTS = *mut DTBGOPTS; +extern "system" { + pub fn DrawThemeBackgroundEx( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pRect: LPCRECT, + pOptions: *const DTBGOPTS, + ) -> HRESULT; +} +//pub const DTT_GRAYED: u32 = 0x00000001; +//pub const DTT_FLAGS2VALIDBITS: u32 = DTT_GRAYED; +extern "system" { + pub fn DrawThemeText( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pszText: LPCWSTR, + cchText: c_int, + dwTextFlags: DWORD, + dwTextFlags2: DWORD, + pRect: LPCRECT, + ) -> HRESULT; + pub fn GetThemeBackgroundContentRect( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pBoundingRect: LPCRECT, + pContentRect: LPRECT, + ) -> HRESULT; + pub fn GetThemeBackgroundExtent( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pContentRect: LPCRECT, + pExtentRect: LPRECT, + ) -> HRESULT; + pub fn GetThemeBackgroundRegion( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pRect: LPCRECT, + pRegion: *mut HRGN, + ) -> HRESULT; +} +ENUM!{enum THEMESIZE { + TS_MIN = 0, + TS_TRUE = 1, + TS_DRAW = 2, +}} +extern "system" { + pub fn GetThemePartSize( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + prc: LPCRECT, + eSize: THEMESIZE, + psz: *mut SIZE, + ) -> HRESULT; + pub fn GetThemeTextExtent( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pszText: LPCWSTR, + cchCharCount: c_int, + dwTextFlags: DWORD, + pBoundingRect: LPCRECT, + pExtentRect: LPRECT, + ) -> HRESULT; + pub fn GetThemeTextMetrics( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + ptm: *mut TEXTMETRICW, + ) -> HRESULT; +} +pub const HTTB_BACKGROUNDSEG: DWORD = 0x00000000; +pub const HTTB_FIXEDBORDER: DWORD = 0x00000002; +pub const HTTB_CAPTION: DWORD = 0x00000004; +pub const HTTB_RESIZINGBORDER_LEFT: DWORD = 0x00000010; +pub const HTTB_RESIZINGBORDER_TOP: DWORD = 0x00000020; +pub const HTTB_RESIZINGBORDER_RIGHT: DWORD = 0x00000040; +pub const HTTB_RESIZINGBORDER_BOTTOM: DWORD = 0x00000080; +pub const HTTB_RESIZINGBORDER: DWORD = HTTB_RESIZINGBORDER_LEFT | HTTB_RESIZINGBORDER_TOP + | HTTB_RESIZINGBORDER_RIGHT | HTTB_RESIZINGBORDER_BOTTOM; +pub const HTTB_SIZINGTEMPLATE: DWORD = 0x00000100; +pub const HTTB_SYSTEMSIZINGMARGINS: DWORD = 0x00000200; +extern "system" { + pub fn HitTestThemeBackground( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + dwOptions: DWORD, + pRect: LPCRECT, + hrgn: HRGN, + ptTest: POINT, + pwHitTestCode: *mut WORD, + ) -> HRESULT; + pub fn DrawThemeEdge( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pDestRect: LPCRECT, + uEdge: UINT, + uFlags: UINT, + pContentRect: LPRECT, + ) -> HRESULT; + pub fn DrawThemeIcon( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pRect: LPCRECT, + himl: HIMAGELIST, + iImageIndex: c_int, + ) -> HRESULT; + pub fn IsThemePartDefined( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + ) -> BOOL; + pub fn IsThemeBackgroundPartiallyTransparent( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + ) -> BOOL; + pub fn GetThemeColor( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pColor: *mut COLORREF, + ) -> HRESULT; + pub fn GetThemeMetric( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + piVal: *mut c_int, + ) -> HRESULT; + pub fn GetThemeString( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pszBuff: LPWSTR, + cchMaxBuffChars: c_int, + ) -> HRESULT; + pub fn GetThemeBool( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pfVal: *mut BOOL, + ) -> HRESULT; + pub fn GetThemeInt( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + piVal: *mut c_int, + ) -> HRESULT; + pub fn GetThemeEnumValue( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + piVal: *mut c_int, + ) -> HRESULT; + pub fn GetThemePosition( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pPoint: *mut POINT, + ) -> HRESULT; + pub fn GetThemeFont( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pFont: *mut LOGFONTW, + ) -> HRESULT; + pub fn GetThemeRect( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pRect: LPRECT, + ) -> HRESULT; +} +STRUCT!{struct MARGINS { + cxLeftWidth: c_int, + cxRightWidth: c_int, + cyTopHeight: c_int, + cyBottomHeight: c_int, +}} +pub type PMARGINS = *mut MARGINS; +extern "system" { + pub fn GetThemeMargins( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + prc: LPCRECT, + pMargins: *mut MARGINS, + ) -> HRESULT; +} +pub const MAX_INTLIST_COUNT: usize = 402; +STRUCT!{struct INTLIST { + iValueCount: c_int, + iValues: [c_int; MAX_INTLIST_COUNT], +}} +pub type PINTLIST = *mut INTLIST; +extern "system" { + pub fn GetThemeIntList( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pIntList: *mut INTLIST, + ) -> HRESULT; +} +ENUM!{enum PROPERTYORIGIN { + PO_STATE = 0, + PO_PART = 1, + PO_CLASS = 2, + PO_GLOBAL = 3, + PO_NOTFOUND = 4, +}} +extern "system" { + pub fn GetThemePropertyOrigin( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pOrigin: *mut PROPERTYORIGIN, + ) -> HRESULT; + pub fn SetWindowTheme( + hwnd: HWND, + pszSubAppName: LPCWSTR, + pszSubIdList: LPCWSTR, + ) -> HRESULT; + pub fn GetThemeFilename( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pszThemeFileName: LPWSTR, + cchMaxBuffChars: c_int, + ) -> HRESULT; + pub fn GetThemeSysColor( + hTheme: HTHEME, + iColorId: c_int, + ) -> COLORREF; + pub fn GetThemeSysColorBrush( + hTheme: HTHEME, + iColorId: c_int, + ) -> HBRUSH; + pub fn GetThemeSysBool( + hTheme: HTHEME, + iBoolId: c_int, + ) -> BOOL; + pub fn GetThemeSysSize( + hTheme: HTHEME, + iSizeId: c_int, + ) -> c_int; + pub fn GetThemeSysFont( + hTheme: HTHEME, + iFontId: c_int, + plf: *mut LOGFONTW, + ) -> HRESULT; + pub fn GetThemeSysString( + hTheme: HTHEME, + iStringId: c_int, + pszStringBuff: LPWSTR, + cchMaxStringChars: c_int, + ) -> HRESULT; + pub fn GetThemeSysInt( + hTheme: HTHEME, + iIntId: c_int, + piValue: *mut c_int, + ) -> HRESULT; + pub fn IsThemeActive() -> BOOL; + pub fn IsAppThemed() -> BOOL; + pub fn GetWindowTheme( + hwnd: HWND, + ) -> HTHEME; +} +pub const ETDT_DISABLE: DWORD = 0x00000001; +pub const ETDT_ENABLE: DWORD = 0x00000002; +pub const ETDT_USETABTEXTURE: DWORD = 0x00000004; +pub const ETDT_ENABLETAB: DWORD = ETDT_ENABLE | ETDT_USETABTEXTURE; +pub const ETDT_USEAEROWIZARDTABTEXTURE: DWORD = 0x00000008; +pub const ETDT_ENABLEAEROWIZARDTAB: DWORD = ETDT_ENABLE | ETDT_USEAEROWIZARDTABTEXTURE; +pub const ETDT_VALIDBITS: DWORD = ETDT_DISABLE | ETDT_ENABLE | ETDT_USETABTEXTURE + | ETDT_USEAEROWIZARDTABTEXTURE; +extern "system" { + pub fn EnableThemeDialogTexture( + hwnd: HWND, + dwFlags: DWORD, + ) -> HRESULT; + pub fn IsThemeDialogTextureEnabled( + hwnd: HWND, + ) -> BOOL; +} +pub const STAP_ALLOW_NONCLIENT: DWORD = 1 << 0; +pub const STAP_ALLOW_CONTROLS: DWORD = 1 << 1; +pub const STAP_ALLOW_WEBCONTENT: DWORD = 1 << 2; +pub const STAP_VALIDBITS: DWORD = STAP_ALLOW_NONCLIENT | STAP_ALLOW_CONTROLS + | STAP_ALLOW_WEBCONTENT; +extern "system" { + pub fn GetThemeAppProperties() -> DWORD; + pub fn SetThemeAppProperties( + dwFlags: DWORD, + ); + pub fn GetCurrentThemeName( + pszThemeFileName: LPWSTR, + cchMaxNameChars: c_int, + pszColorBuff: LPWSTR, + cchMaxColorChars: c_int, + pszSizeBuff: LPWSTR, + cchMaxSizeChars: c_int, + ) -> HRESULT; +} +pub const SZ_THDOCPROP_DISPLAYNAME: &'static str = "DisplayName"; +pub const SZ_THDOCPROP_CANONICALNAME: &'static str = "ThemeName"; +pub const SZ_THDOCPROP_TOOLTIP: &'static str = "ToolTip"; +pub const SZ_THDOCPROP_AUTHOR: &'static str = "author"; +extern "system" { + pub fn GetThemeDocumentationProperty( + pszThemeName: LPCWSTR, + pszPropertyName: LPCWSTR, + pszValueBuff: LPWSTR, + cchMaxValChars: c_int, + ) -> HRESULT; + pub fn DrawThemeParentBackground( + hwnd: HWND, + hdc: HDC, + prc: *const RECT, + ) -> HRESULT; + pub fn EnableTheming( + fEnable: BOOL, + ) -> HRESULT; +} +pub const GBF_DIRECT: ULONG = 0x00000001; +pub const GBF_COPY: ULONG = 0x00000002; +pub const GBF_VALIDBITS: ULONG = GBF_DIRECT | GBF_COPY; +pub const DTPB_WINDOWDC: DWORD = 0x00000001; +pub const DTPB_USECTLCOLORSTATIC: DWORD = 0x00000002; +pub const DTPB_USEERASEBKGND: DWORD = 0x00000004; +extern "system" { + pub fn DrawThemeParentBackgroundEx( + hwnd: HWND, + hdc: HDC, + dwFlags: DWORD, + prc: *const RECT, + ) -> HRESULT; +} +ENUM!{enum WINDOWTHEMEATTRIBUTETYPE { + WTA_NONCLIENT = 1, +}} +STRUCT!{struct WTA_OPTIONS { + dwFlags: DWORD, + dwMask: DWORD, +}} +pub type PWTA_OPTIONS = *mut WTA_OPTIONS; +pub const WTNCA_NODRAWCAPTION: DWORD = 0x00000001; +pub const WTNCA_NODRAWICON: DWORD = 0x00000002; +pub const WTNCA_NOSYSMENU: DWORD = 0x00000004; +pub const WTNCA_NOMIRRORHELP: DWORD = 0x00000008; +pub const WTNCA_VALIDBITS: DWORD = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON | WTNCA_NOSYSMENU + | WTNCA_NOMIRRORHELP; +extern "system" { + pub fn SetWindowThemeAttribute( + hwnd: HWND, + eAttribute: WINDOWTHEMEATTRIBUTETYPE, + pvAttribute: PVOID, + cbAttribute: DWORD, + ) -> HRESULT; +} +#[inline] +pub unsafe fn SetWindowThemeNonClientAttributes( + hwnd: HWND, + dwMask: DWORD, + dwAttributes: DWORD, +) -> HRESULT { + use core::mem::{size_of, zeroed}; + let mut wta: WTA_OPTIONS = zeroed(); + wta.dwFlags = dwAttributes; + wta.dwMask = dwMask; + SetWindowThemeAttribute( + hwnd, + WTA_NONCLIENT, + &mut wta as *mut WTA_OPTIONS as *mut c_void, + size_of::<WTA_OPTIONS>() as u32, + ) +} +FN!{stdcall DTT_CALLBACK_PROC( + hdc: HDC, + pszText: LPWSTR, + cchText: c_int, + prc: LPRECT, + dwFlags: UINT, + lParam: LPARAM, +) -> c_int} +pub const DTT_TEXTCOLOR: DWORD = 1 << 0; +pub const DTT_BORDERCOLOR: DWORD = 1 << 1; +pub const DTT_SHADOWCOLOR: DWORD = 1 << 2; +pub const DTT_SHADOWTYPE: DWORD = 1 << 3; +pub const DTT_SHADOWOFFSET: DWORD = 1 << 4; +pub const DTT_BORDERSIZE: DWORD = 1 << 5; +pub const DTT_FONTPROP: DWORD = 1 << 6; +pub const DTT_COLORPROP: DWORD = 1 << 7; +pub const DTT_STATEID: DWORD = 1 << 8; +pub const DTT_CALCRECT: DWORD = 1 << 9; +pub const DTT_APPLYOVERLAY: DWORD = 1 << 10; +pub const DTT_GLOWSIZE: DWORD = 1 << 11; +pub const DTT_CALLBACK: DWORD = 1 << 12; +pub const DTT_COMPOSITED: DWORD = 1 << 13; +pub const DTT_VALIDBITS: DWORD = DTT_TEXTCOLOR | DTT_BORDERCOLOR | DTT_SHADOWCOLOR + | DTT_SHADOWTYPE | DTT_SHADOWOFFSET | DTT_BORDERSIZE | DTT_FONTPROP | DTT_COLORPROP + | DTT_STATEID | DTT_CALCRECT | DTT_APPLYOVERLAY | DTT_GLOWSIZE | DTT_COMPOSITED; +STRUCT!{struct DTTOPTS { + dwSize: DWORD, + dwFlags: DWORD, + crText: COLORREF, + crBorder: COLORREF, + crShadow: COLORREF, + iTextShadowType: c_int, + ptShadowOffset: POINT, + iBorderSize: c_int, + iFontPropId: c_int, + iColorPropId: c_int, + iStateId: c_int, + fApplyOverlay: BOOL, + iGlowSize: c_int, + pfnDrawTextCallback: DTT_CALLBACK_PROC, + lParam: LPARAM, +}} +pub type PDTTOPTS = *mut DTTOPTS; +extern "system" { + pub fn DrawThemeTextEx( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pszText: LPCWSTR, + cchText: c_int, + dwTextFlags: DWORD, + pRect: LPRECT, + pOptions: *const DTTOPTS, + ) -> HRESULT; + pub fn GetThemeBitmap( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + dwFlags: ULONG, + phBitmap: *mut HBITMAP, + ) -> HRESULT; + pub fn GetThemeStream( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + ppvStream: *mut *mut VOID, + pcbStream: *mut DWORD, + hInst: HINSTANCE, + ) -> HRESULT; + pub fn BufferedPaintInit() -> HRESULT; + pub fn BufferedPaintUnInit() -> HRESULT; +} +pub type HPAINTBUFFER = HANDLE; +ENUM!{enum BP_BUFFERFORMAT { + BPBF_COMPATIBLEBITMAP = 0, + BPBF_DIB = 1, + BPBF_TOPDOWNDIB = 2, + BPBF_TOPDOWNMONODIB = 3, +}} +pub const BPBF_COMPOSITED: BP_BUFFERFORMAT = BPBF_TOPDOWNDIB; +ENUM!{enum BP_ANIMATIONSTYLE { + BPAS_NONE = 0, + BPAS_LINEAR = 1, + BPAS_CUBIC = 2, + BPAS_SINE = 3, +}} +STRUCT!{struct BP_ANIMATIONPARAMS { + cbSize: DWORD, + dwFlags: DWORD, + style: BP_ANIMATIONSTYLE, + dwDuration: DWORD, +}} +pub type PBP_ANIMATIONPARAMS = *mut BP_ANIMATIONPARAMS; +pub const BPPF_ERASE: DWORD = 0x0001; +pub const BPPF_NOCLIP: DWORD = 0x0002; +pub const BPPF_NONCLIENT: DWORD = 0x0004; +STRUCT!{struct BP_PAINTPARAMS { + cbSize: DWORD, + dwFlags: DWORD, + prcExclude: *const RECT, + pBlendFunction: *const BLENDFUNCTION, +}} +pub type PBP_PAINTPARAMS = *mut BP_PAINTPARAMS; +extern "system" { + pub fn BeginBufferedPaint( + hdcTarget: HDC, + prcTarget: *const RECT, + dwFormat: BP_BUFFERFORMAT, + pPaintParams: *mut BP_PAINTPARAMS, + phdc: *mut HDC, + ) -> HPAINTBUFFER; + pub fn EndBufferedPaint( + hBufferedPaint: HPAINTBUFFER, + fUpdateTarget: BOOL, + ) -> HRESULT; + pub fn GetBufferedPaintTargetRect( + hBufferedPaint: HPAINTBUFFER, + prc: *mut RECT, + ) -> HRESULT; + pub fn GetBufferedPaintTargetDC( + hBufferedPaint: HPAINTBUFFER, + ) -> HDC; + pub fn GetBufferedPaintDC( + hBufferedPaint: HPAINTBUFFER, + ) -> HDC; + pub fn GetBufferedPaintBits( + hBufferedPaint: HPAINTBUFFER, + ppbBuffer: *mut *mut RGBQUAD, + pcxRow: *mut c_int, + ) -> HRESULT; + pub fn BufferedPaintClear( + hBufferedPaint: HPAINTBUFFER, + prc: *const RECT, + ) -> HRESULT; + pub fn BufferedPaintSetAlpha( + hBufferedPaint: HPAINTBUFFER, + prc: *const RECT, + alpha: BYTE, + ) -> HRESULT; + pub fn BufferedPaintStopAllAnimations( + hwnd: HWND, + ) -> HRESULT; +} +pub type HANIMATIONBUFFER = HANDLE; +extern "system" { + pub fn BeginBufferedAnimation( + hwnd: HWND, + hdcTarget: HDC, + prcTarget: *const RECT, + dwFormat: BP_BUFFERFORMAT, + pPaintParams: *mut BP_PAINTPARAMS, + pAnimationParams: *mut BP_ANIMATIONPARAMS, + phdcFrom: *mut HDC, + phdcTo: *mut HDC, + ) -> HANIMATIONBUFFER; + pub fn EndBufferedAnimation( + hbpAnimation: HANIMATIONBUFFER, + fUpdateTarget: BOOL, + ) -> HRESULT; + pub fn BufferedPaintRenderAnimation( + hwnd: HWND, + hdcTarget: HDC, + ) -> BOOL; + pub fn IsCompositionActive() -> BOOL; + pub fn GetThemeTransitionDuration( + hTheme: HTHEME, + iPartId: c_int, + iStateIdFrom: c_int, + iStateIdTo: c_int, + iPropId: c_int, + pdwDuration: *mut DWORD, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/vsbackup.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/vsbackup.rs new file mode 100644 index 0000000..0a7f260 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/vsbackup.rs @@ -0,0 +1,520 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Declaration of backup interfaces. +use ctypes::c_void; +use shared::guiddef::IID; +use shared::minwindef::{BOOL, BYTE, DWORD, UINT}; +use shared::wtypes::BSTR; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::vss::{ + IVssAsync, IVssEnumObject, VSS_BACKUP_TYPE, VSS_ID, VSS_OBJECT_TYPE, VSS_PWSZ, + VSS_RESTORE_TYPE, VSS_ROLLFORWARD_TYPE, VSS_SNAPSHOT_PROP, VSS_WRITER_STATE +}; +use um::vswriter::{ + IVssWMDependency, IVssWMFiledesc, IVssWriterComponentsVtbl, VSS_COMPONENT_TYPE, + VSS_FILE_RESTORE_STATUS, VSS_RESTOREMETHOD_ENUM, VSS_SOURCE_TYPE, VSS_USAGE_TYPE, + VSS_WRITERRESTORE_ENUM +}; +use um::winnt::{HRESULT, LONG, LPCWSTR}; +DEFINE_GUID!{IID_IVssExamineWriterMetadata, + 0x902fcf7f, 0xb7fd, 0x42f8, 0x81, 0xf1, 0xb2, 0xe4, 0x00, 0xb1, 0xe5, 0xbd} +DEFINE_GUID!{IID_IVssExamineWriterMetadataEx, + 0x0c0e5ec0, 0xca44, 0x472b, 0xb7, 0x02, 0xe6, 0x52, 0xdb, 0x1c, 0x04, 0x51} +DEFINE_GUID!{IID_IVssBackupComponents, + 0x665c1d5f, 0xc218, 0x414d, 0xa0, 0x5d, 0x7f, 0xef, 0x5f, 0x9d, 0x5c, 0x86} +DEFINE_GUID!{IID_IVssBackupComponentsEx, + 0x963f03ad, 0x9e4c, 0x4a34, 0xac, 0x15, 0xe4, 0xb6, 0x17, 0x4e, 0x50, 0x36} +STRUCT!{struct VSS_COMPONENTINFO { + type_: VSS_COMPONENT_TYPE, // type is a keyword in rust + bstrLogicalPath: BSTR, + bstrComponentName: BSTR, + bstrCaption: BSTR, + pbIcon: *mut BYTE, + cbIcon: UINT, + bRestoreMetadata: bool, + bNotifyOnBackupComplete: bool, + bSelectable: bool, + bSelectableForRestore: bool, + dwComponentFlags: DWORD, + cFileCount: UINT, + cDatabases: UINT, + cLogFiles: UINT, + cDependencies: UINT, +}} +pub type PVSSCOMPONENTINFO = *const VSS_COMPONENTINFO; +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +interface IVssWMComponent(IVssWMComponentVtbl): IUnknown(IUnknownVtbl) { + fn GetComponentInfo( + ppInfo: *mut PVSSCOMPONENTINFO, + ) -> HRESULT, + fn FreeComponentInfo( + pInfo: PVSSCOMPONENTINFO, + ) -> HRESULT, + fn GetFile( + iFile: UINT, + ppFiledesc: *mut *mut IVssWMFiledesc, + ) -> HRESULT, + fn GetDatabaseFile( + iDBFile: UINT, + ppFiledesc: *mut *mut IVssWMFiledesc, + ) -> HRESULT, + fn GetDatabaseLogFile( + iDbLogFile: UINT, + ppFiledesc: *mut *mut IVssWMFiledesc, + ) -> HRESULT, + fn GetDependency( + iDependency: UINT, + ppDependency: *mut *mut IVssWMDependency, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x902fcf7f, 0xb7fd, 0x42f8, 0x81, 0xf1, 0xb2, 0xe4, 0x00, 0xb1, 0xe5, 0xbd)] +interface IVssExamineWriterMetadata(IVssExamineWriterMetadataVtbl): IUnknown(IUnknownVtbl) { + fn GetIdentity( + pidInstance: *mut VSS_ID, + pidWriter: *mut VSS_ID, + pbstrWriterName: *mut BSTR, + pUsage: *mut VSS_USAGE_TYPE, + pSource: *mut VSS_SOURCE_TYPE, + ) -> HRESULT, + fn GetFileCounts( + pcIncludeFiles: *mut UINT, + pcExcludeFiles: *mut UINT, + pcComponents: *mut UINT, + ) -> HRESULT, + fn GetIncludeFile( + iFile: UINT, + ppFiledesc: *mut *mut IVssWMFiledesc, + ) -> HRESULT, + fn GetExcludeFile( + iFile: UINT, + ppFiledesc: *mut *mut IVssWMFiledesc, + ) -> HRESULT, + fn GetComponent( + iComponent: UINT, + ppComponent: *mut *mut IVssWMComponent, + ) -> HRESULT, + fn GetRestoreMethod( + pMethod: *mut VSS_RESTOREMETHOD_ENUM, + pbstrService: *mut BSTR, + pbstrUserProcedure: *mut BSTR, + pwriterRestore: *mut VSS_WRITERRESTORE_ENUM, + pbRebootRequired: *mut bool, + pcMappings: *mut UINT, + ) -> HRESULT, + fn GetAlternateLocationMapping( + iMapping: UINT, + ppFiledesc: *mut *mut IVssWMFiledesc, + ) -> HRESULT, + fn GetBackupSchema( + pdwSchemaMask: *mut DWORD, + ) -> HRESULT, + fn GetDocument( + pDoc: *mut c_void, + ) -> HRESULT, //TODO IXMLDOMDocument, + fn SaveAsXML( + pbstrXML: *mut BSTR, + ) -> HRESULT, + fn LoadFromXML( + pbstrXML: *mut BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0c0e5ec0, 0xca44, 0x472b, 0xb7, 0x02, 0xe6, 0x52, 0xdb, 0x1c, 0x04, 0x51)] +interface IVssExamineWriterMetadataEx(IVssExamineWriterMetadataExVtbl): + IVssExamineWriterMetadata(IVssExamineWriterMetadataVtbl) { + fn GetIdentityEx( + pidInstance: *mut VSS_ID, + pidWriter: *mut VSS_ID, + pbstrWriterName: *mut BSTR, + pbstrInstanceName: *mut BSTR, + pUsage: *mut VSS_USAGE_TYPE, + pSource: *mut VSS_SOURCE_TYPE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xce115780, 0xa611, 0x431b, 0xb5, 0x7f, 0xc3, 0x83, 0x03, 0xab, 0x6a, 0xee)] +interface IVssExamineWriterMetadataEx2(IVssExamineWriterMetadataEx2Vtbl): + IVssExamineWriterMetadataEx(IVssExamineWriterMetadataExVtbl) { + fn GetVersion( + pdwMajorVersion: *mut DWORD, + pdwMinorVersion: *mut DWORD, + ) -> HRESULT, + fn GetExcludeFromSnapshotCount( + pcExcludedFromSnapshot: *mut UINT, + ) -> HRESULT, + fn GetExcludeFromSnapshotFile( + iFile: UINT, + ppFiledesc: *mut *mut IVssWMFiledesc, + ) -> HRESULT, +}} +#[repr(C)] +pub struct IVssWriterComponentsExt { + pub lpVtbl: *const IVssWriterComponentsExtVtbl, +} +#[repr(C)] +pub struct IVssWriterComponentsExtVtbl { + pub parent1: IVssWriterComponentsVtbl, + pub parent2: IUnknownVtbl, +} +RIDL!{#[uuid(0x665c1d5f, 0xc218, 0x414d, 0xa0, 0x5d, 0x7f, 0xef, 0x5f, 0x9d, 0x5c, 0x86)] +interface IVssBackupComponents(IVssBackupComponentsVtbl): IUnknown(IUnknownVtbl) { + fn GetWriterComponentsCount( + pcComponents: *mut UINT, + ) -> HRESULT, + fn GetWriterComponents( + iWriter: UINT, + ppWriter: *mut *mut IVssWriterComponentsExt, + ) -> HRESULT, + fn InitializeForBackup( + bstrXML: BSTR, + ) -> HRESULT, + fn SetBackupState( + bSelectComponents: bool, + bBackupBootableSystemState: bool, + backupType: VSS_BACKUP_TYPE, + bPartialFileSupport: bool, + ) -> HRESULT, + fn InitializeForRestore( + bstrXML: BSTR, + ) -> HRESULT, + fn SetRestoreState( + restoreType: VSS_RESTORE_TYPE, + ) -> HRESULT, + fn GatherWriterMetadata( + pAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn GetWriterMetadataCount( + pcWriters: *mut UINT, + ) -> HRESULT, + fn GetWriterMetadata( + iWriter: UINT, + pidInstance: *mut VSS_ID, + ppMetadata: *mut *mut IVssExamineWriterMetadata, + ) -> HRESULT, + fn FreeWriterMetadata() -> HRESULT, + fn AddComponent( + instanceId: VSS_ID, + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + ) -> HRESULT, + fn PrepareForBackup( + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn AbortBackup() -> HRESULT, + fn GatherWriterStatus( + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn GetWriterStatusCount( + pcWriters: *mut UINT, + ) -> HRESULT, + fn FreeWriterStatus() -> HRESULT, + fn GetWriterStatus( + iWriter: UINT, + pidInstance: *mut VSS_ID, + pidWriter: *mut VSS_ID, + pbstrWriter: *mut BSTR, + pnStatus: *mut VSS_WRITER_STATE, + phResultFailure: *mut HRESULT, + ) -> HRESULT, + fn SetBackupSucceeded( + instanceId: VSS_ID, + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + bSucceded: bool, + ) -> HRESULT, + fn SetBackupOptions( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + wszBackupOptions: LPCWSTR, + ) -> HRESULT, + fn SetSelectedForRestore( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + bSelectedForRestore: bool, + ) -> HRESULT, + fn SetRestoreOptions( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + wszRestoreOptions: LPCWSTR, + ) -> HRESULT, + fn SetAdditionalRestores( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + bAdditionalRestores: bool, + ) -> HRESULT, + fn SetPreviousBackupStamp( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + wszPreviousBackupStamp: LPCWSTR, + ) -> HRESULT, + fn SaveAsXML( + pbstrXML: *mut BSTR, + ) -> HRESULT, + fn BackupComplete( + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn AddAlternativeLocationMapping( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + wszPath: LPCWSTR, + wszFilespec: LPCWSTR, + bRecursive: bool, + wszDestination: LPCWSTR, + ) -> HRESULT, + fn AddRestoreSubcomponent( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + wszSubComponentLogicalPath: LPCWSTR, + wszSubComponentName: LPCWSTR, + bRepair: bool, + ) -> HRESULT, + fn SetFileRestoreStatus( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + status: VSS_FILE_RESTORE_STATUS, + ) -> HRESULT, + fn AddNewTarget( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + wszPath: LPCWSTR, + wszFileName: LPCWSTR, + bRecursive: bool, + wszAlternatePath: LPCWSTR, + ) -> HRESULT, + fn SetRangesFilePath( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + iPartialFile: UINT, + wszRangesFile: LPCWSTR, + ) -> HRESULT, + fn PreRestore( + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn PostRestore( + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn SetContext( + lContext: LONG, + ) -> HRESULT, + fn StartSnapshotSet( + pSnapshotSetId: *mut VSS_ID, + ) -> HRESULT, + fn AddToSnapshotSet( + pwszVolumeName: VSS_PWSZ, + ProviderId: VSS_ID, + pidSnapshot: *mut VSS_ID, + ) -> HRESULT, + fn DoSnapshotSet( + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn DeleteSnapshots( + SourceObjectId: VSS_ID, + eSourceObjectType: VSS_OBJECT_TYPE, + bForceDelete: BOOL, + plDeletedSnapshots: *mut LONG, + pNondeletedSnapshotID: *mut VSS_ID, + ) -> HRESULT, + fn ImportSnapshots( + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn BreakSnapshotSet( + SnapshotSetId: VSS_ID, + ) -> HRESULT, + fn GetSnapshotProperties( + SnapshotId: VSS_ID, + pProp: *mut VSS_SNAPSHOT_PROP, + ) -> HRESULT, + fn Query( + QueriedObjectId: VSS_ID, + eQueriedObjectType: VSS_OBJECT_TYPE, + eReturnedObjectsType: VSS_OBJECT_TYPE, + ppEnum: *mut *mut IVssEnumObject, + ) -> HRESULT, + fn IsVolumeSupported( + ProviderId: VSS_ID, + pwszVolumeName: VSS_PWSZ, + pbSupportedByThisProvider: *mut BOOL, + ) -> HRESULT, + fn DisableWriterClasses( + rgWriterClassId: *const VSS_ID, + cClassId: UINT, + ) -> HRESULT, + fn EnableWriterClasses( + rgWriterClassId: *const VSS_ID, + cClassId: UINT, + ) -> HRESULT, + fn DisableWriterInstances( + rgWriterInstanceId: *const VSS_ID, + cInstanceId: UINT, + ) -> HRESULT, + fn ExposeSnapshot( + SnapshotId: VSS_ID, + wszPathFromRoot: VSS_PWSZ, + lAttributes: LONG, + wszExpose: VSS_PWSZ, + pwszExposed: VSS_PWSZ, + ) -> HRESULT, + fn RevertToSnapshot( + SnapshotId: VSS_ID, + bForceDismount: BOOL, + ) -> HRESULT, + fn QueryRevertStatus( + pwszVolume: VSS_PWSZ, + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x963f03ad, 0x9e4c, 0x4a34, 0xac, 0x15, 0xe4, 0xb6, 0x17, 0x4e, 0x50, 0x36)] +interface IVssBackupComponentsEx(IVssBackupComponentsExVtbl): + IVssBackupComponents(IVssBackupComponentsVtbl) { + fn GetWriterMetadataEx( + iWriter: UINT, + pidInstance: *mut VSS_ID, + ppMetadata: *mut *mut IVssExamineWriterMetadataEx, + ) -> HRESULT, + fn SetSelectedForRestoreEx( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + bSelectedForRestore: bool, + instanceId: VSS_ID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xacfe2b3a, 0x22c9, 0x4ef8, 0xbd, 0x03, 0x2f, 0x9c, 0xa2, 0x30, 0x08, 0x4e)] +interface IVssBackupComponentsEx2(IVssBackupComponentsEx2Vtbl): + IVssBackupComponentsEx(IVssBackupComponentsExVtbl) { + fn UnexposeSnapshot( + snapshotId: VSS_ID, + ) -> HRESULT, + fn SetAuthoritativeRestore( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + bAuth: bool, + ) -> HRESULT, + fn SetRollForward( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + rollType: VSS_ROLLFORWARD_TYPE, + wszRollForwardPoint: LPCWSTR, + ) -> HRESULT, + fn SetRestoreName( + writerId: VSS_ID, + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + wszRestoreName: LPCWSTR, + ) -> HRESULT, + fn BreakSnapshotSetEx( + SnapshotSetID: VSS_ID, + dwBreakFlags: DWORD, + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn PreFastRecovery( + SnapshotSetID: VSS_ID, + dwPreFastRecoveryFlags: DWORD, + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn FastRecovery( + SnapshotSetID: VSS_ID, + dwFastRecoveryFlags: DWORD, + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc191bfbc, 0xb602, 0x4675, 0x8b, 0xd1, 0x67, 0xd6, 0x42, 0xf5, 0x29, 0xd5)] +interface IVssBackupComponentsEx3(IVssBackupComponentsEx3Vtbl): + IVssBackupComponentsEx2(IVssBackupComponentsEx2Vtbl) { + fn GetWriterStatusEx( + iWriter: UINT, + pidInstance: *mut VSS_ID, + pidWriter: *mut VSS_ID, + pbstrWriter: *mut BSTR, + pnStatus: *mut VSS_WRITER_STATE, + phrFailureWriter: *mut HRESULT, + phrApplication: *mut HRESULT, + pbstrApplicationMessage: *mut BSTR, + ) -> HRESULT, + fn AddSnapshotToRecoverySet( + snapshotId: VSS_ID, + dwFlags: DWORD, + pwszDestinationVolume: VSS_PWSZ, + ) -> HRESULT, + fn RecoverSet( + dwFlags: DWORD, + ppAsync: *mut *mut IVssAsync, + ) -> HRESULT, + fn GetSessionId( + idSession: *mut VSS_ID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf434c2fd, 0xb553, 0x4961, 0xa9, 0xf9, 0xa8, 0xe9, 0x0b, 0x67, 0x3e, 0x53)] +interface IVssBackupComponentsEx4(IVssBackupComponentsEx4Vtbl): + IVssBackupComponentsEx3(IVssBackupComponentsEx3Vtbl) { + fn GetRootAndLogicalPrefixPaths( + pwszFilePath: VSS_PWSZ, + ppwszRootPath: *mut VSS_PWSZ, + ppwszLogicalPrefix: *mut VSS_PWSZ, + bNormalizeFQDNforRootPath: BOOL, + ) -> HRESULT, +}} +pub const VSS_SW_BOOTABLE_STATE: DWORD = 1; +extern "system" { + #[link_name="CreateVssBackupComponentsInternal"] + pub fn CreateVssBackupComponents( + ppBackup: *mut *mut IVssBackupComponents, + ) -> HRESULT; + #[link_name="CreateVssExamineWriterMetadataInternal"] + pub fn CreateVssExamineWriterMetadata( + bstrXML: BSTR, + ppMetadata: *mut *mut IVssExamineWriterMetadata, + ) -> HRESULT; + #[link_name="IsVolumeSnapshottedInternal"] + pub fn IsVolumeSnapshotted( + pwszVolumeName: VSS_PWSZ, + pbSnapshotsPresent: *mut BOOL, + plSnapshotCapability: *mut LONG, + ) -> HRESULT; + #[link_name="VssFreeSnapshotPropertiesInternal"] + pub fn VssFreeSnapshotProperties( + pProp: *mut VSS_SNAPSHOT_PROP, + ); + #[link_name="GetProviderMgmtInterfaceInternal"] + pub fn GetProviderMgmtInterface( + ProviderId: VSS_ID, + InterfaceId: IID, + ppItf: *mut *mut IUnknown, + ) -> HRESULT; + #[link_name="ShouldBlockRevertInternal"] + pub fn ShouldBlockRevert( + wszVolumeName: LPCWSTR, + pbBlock: *mut bool, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/vss.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/vss.rs new file mode 100644 index 0000000..7038f03 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/vss.rs @@ -0,0 +1,284 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! VSS header file +use shared::guiddef::{CLSID, GUID}; +use shared::minwindef::{DWORD, INT, ULONG}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LONG, LONGLONG, WCHAR}; +ENUM!{enum VSS_OBJECT_TYPE { + VSS_OBJECT_UNKNOWN = 0, + VSS_OBJECT_NONE = 1, + VSS_OBJECT_SNAPSHOT_SET = 2, + VSS_OBJECT_SNAPSHOT = 3, + VSS_OBJECT_PROVIDER = 4, + VSS_OBJECT_TYPE_COUNT = 5, +}} +pub type PVSS_OBJECT_TYPE = *mut VSS_OBJECT_TYPE; +ENUM!{enum VSS_SNAPSHOT_STATE { + VSS_SS_UNKNOWN = 0x00, + VSS_SS_PREPARING = 0x01, + VSS_SS_PROCESSING_PREPARE = 0x02, + VSS_SS_PREPARED = 0x03, + VSS_SS_PROCESSING_PRECOMMIT = 0x04, + VSS_SS_PRECOMMITTED = 0x05, + VSS_SS_PROCESSING_COMMIT = 0x06, + VSS_SS_COMMITTED = 0x07, + VSS_SS_PROCESSING_POSTCOMMIT = 0x08, + VSS_SS_PROCESSING_PREFINALCOMMIT = 0x09, + VSS_SS_PREFINALCOMMITTED = 0x0a, + VSS_SS_PROCESSING_POSTFINALCOMMIT = 0x0b, + VSS_SS_CREATED = 0x0c, + VSS_SS_ABORTED = 0x0d, + VSS_SS_DELETED = 0x0e, + VSS_SS_POSTCOMMITTED = 0x0f, + VSS_SS_COUNT = 0x10, +}} +pub type PVSS_SNAPSHOT_STATE = *mut VSS_SNAPSHOT_STATE; +ENUM!{enum VSS_VOLUME_SNAPSHOT_ATTRIBUTES { + VSS_VOLSNAP_ATTR_PERSISTENT = 0x00000001, + VSS_VOLSNAP_ATTR_NO_AUTORECOVERY = 0x00000002, + VSS_VOLSNAP_ATTR_CLIENT_ACCESSIBLE = 0x00000004, + VSS_VOLSNAP_ATTR_NO_AUTO_RELEASE = 0x00000008, + VSS_VOLSNAP_ATTR_NO_WRITERS = 0x00000010, + VSS_VOLSNAP_ATTR_TRANSPORTABLE = 0x00000020, + VSS_VOLSNAP_ATTR_NOT_SURFACED = 0x00000040, + VSS_VOLSNAP_ATTR_NOT_TRANSACTED = 0x00000080, + VSS_VOLSNAP_ATTR_HARDWARE_ASSISTED = 0x00010000, + VSS_VOLSNAP_ATTR_DIFFERENTIAL = 0x00020000, + VSS_VOLSNAP_ATTR_PLEX = 0x00040000, + VSS_VOLSNAP_ATTR_IMPORTED = 0x00080000, + VSS_VOLSNAP_ATTR_EXPOSED_LOCALLY = 0x00100000, + VSS_VOLSNAP_ATTR_EXPOSED_REMOTELY = 0x00200000, + VSS_VOLSNAP_ATTR_AUTORECOVER = 0x00400000, + VSS_VOLSNAP_ATTR_ROLLBACK_RECOVERY = 0x00800000, + VSS_VOLSNAP_ATTR_DELAYED_POSTSNAPSHOT = 0x01000000, + VSS_VOLSNAP_ATTR_TXF_RECOVERY = 0x02000000, + VSS_VOLSNAP_ATTR_FILE_SHARE = 0x04000000, +}} +pub type PVSS_VOLUME_SNAPSHOT_ATTRIBUTES = *mut VSS_VOLUME_SNAPSHOT_ATTRIBUTES; +ENUM!{enum VSS_SNAPSHOT_CONTEXT { + VSS_CTX_BACKUP = 0, + VSS_CTX_FILE_SHARE_BACKUP = VSS_VOLSNAP_ATTR_NO_WRITERS, + VSS_CTX_NAS_ROLLBACK = VSS_VOLSNAP_ATTR_PERSISTENT + | VSS_VOLSNAP_ATTR_NO_AUTO_RELEASE | VSS_VOLSNAP_ATTR_NO_WRITERS, + VSS_CTX_APP_ROLLBACK = VSS_VOLSNAP_ATTR_PERSISTENT + | VSS_VOLSNAP_ATTR_NO_AUTO_RELEASE, + VSS_CTX_CLIENT_ACCESSIBLE = VSS_VOLSNAP_ATTR_PERSISTENT + | VSS_VOLSNAP_ATTR_CLIENT_ACCESSIBLE | VSS_VOLSNAP_ATTR_NO_AUTO_RELEASE + | VSS_VOLSNAP_ATTR_NO_WRITERS, + VSS_CTX_CLIENT_ACCESSIBLE_WRITERS = VSS_VOLSNAP_ATTR_PERSISTENT + | VSS_VOLSNAP_ATTR_CLIENT_ACCESSIBLE | VSS_VOLSNAP_ATTR_NO_AUTO_RELEASE, + VSS_CTX_ALL = 0xffffffff, +}} +pub type PVSS_SNAPSHOT_CONTEXT = *mut VSS_SNAPSHOT_CONTEXT; +ENUM!{enum VSS_PROVIDER_CAPABILITIES { + VSS_PRV_CAPABILITY_LEGACY = 0x1, + VSS_PRV_CAPABILITY_COMPLIANT = 0x2, + VSS_PRV_CAPABILITY_LUN_REPOINT = 0x4, + VSS_PRV_CAPABILITY_LUN_RESYNC = 0x8, + VSS_PRV_CAPABILITY_OFFLINE_CREATION = 0x10, + VSS_PRV_CAPABILITY_MULTIPLE_IMPORT = 0x20, + VSS_PRV_CAPABILITY_RECYCLING = 0x40, + VSS_PRV_CAPABILITY_PLEX = 0x80, + VSS_PRV_CAPABILITY_DIFFERENTIAL = 0x100, + VSS_PRV_CAPABILITY_CLUSTERED = 0x200, +}} +pub type PVSS_PROVIDER_CAPABILITIES = *mut VSS_PROVIDER_CAPABILITIES; +ENUM!{enum VSS_HARDWARE_OPTIONS { + VSS_BREAKEX_FLAG_MASK_LUNS = 0x1, + VSS_BREAKEX_FLAG_MAKE_READ_WRITE = 0x2, + VSS_BREAKEX_FLAG_REVERT_IDENTITY_ALL = 0x4, + VSS_BREAKEX_FLAG_REVERT_IDENTITY_NONE = 0x8, + VSS_ONLUNSTATECHANGE_NOTIFY_READ_WRITE = 0x100, + VSS_ONLUNSTATECHANGE_NOTIFY_LUN_PRE_RECOVERY = 0x200, + VSS_ONLUNSTATECHANGE_NOTIFY_LUN_POST_RECOVERY = 0x400, + VSS_ONLUNSTATECHANGE_DO_MASK_LUNS = 0x800, +}} +pub type PVSS_HARDWARE_OPTIONS = *mut VSS_HARDWARE_OPTIONS; +ENUM!{enum VSS_RECOVERY_OPTIONS { + VSS_RECOVERY_REVERT_IDENTITY_ALL = 0x00000100, + VSS_RECOVERY_NO_VOLUME_CHECK = 0x00000200, +}} +pub type PVSS_RECOVERY_OPTIONS = *mut VSS_RECOVERY_OPTIONS; +ENUM!{enum VSS_WRITER_STATE { + VSS_WS_UNKNOWN = 0, + VSS_WS_STABLE = 1, + VSS_WS_WAITING_FOR_FREEZE = 2, + VSS_WS_WAITING_FOR_THAW = 3, + VSS_WS_WAITING_FOR_POST_SNAPSHOT = 4, + VSS_WS_WAITING_FOR_BACKUP_COMPLETE = 5, + VSS_WS_FAILED_AT_IDENTIFY = 6, + VSS_WS_FAILED_AT_PREPARE_BACKUP = 7, + VSS_WS_FAILED_AT_PREPARE_SNAPSHOT = 8, + VSS_WS_FAILED_AT_FREEZE = 9, + VSS_WS_FAILED_AT_THAW = 10, + VSS_WS_FAILED_AT_POST_SNAPSHOT = 11, + VSS_WS_FAILED_AT_BACKUP_COMPLETE = 12, + VSS_WS_FAILED_AT_PRE_RESTORE = 13, + VSS_WS_FAILED_AT_POST_RESTORE = 14, + VSS_WS_FAILED_AT_BACKUPSHUTDOWN = 15, + VSS_WS_COUNT = 16, +}} +pub type PVSS_WRITER_STATE = *mut VSS_WRITER_STATE; +ENUM!{enum VSS_BACKUP_TYPE { + VSS_BT_UNDEFINED = 0, + VSS_BT_FULL = 1, + VSS_BT_INCREMENTAL = 2, + VSS_BT_DIFFERENTIAL = 3, + VSS_BT_LOG = 4, + VSS_BT_COPY = 5, + VSS_BT_OTHER = 6, +}} +pub type PVSS_BACKUP_TYPE = *mut VSS_BACKUP_TYPE; +ENUM!{enum VSS_RESTORE_TYPE { + VSS_RTYPE_UNDEFINED = 0, + VSS_RTYPE_BY_COPY = 1, + VSS_RTYPE_IMPORT = 2, + VSS_RTYPE_OTHER = 3, +}} +pub type PVSS_RESTORE_TYPE = *mut VSS_RESTORE_TYPE; +ENUM!{enum VSS_ROLLFORWARD_TYPE { + VSS_RF_UNDEFINED = 0, + VSS_RF_NONE = 1, + VSS_RF_ALL = 2, + VSS_RF_PARTIAL = 3, +}} +pub type PVSS_ROLLFORWARD_TYPE = *mut VSS_ROLLFORWARD_TYPE; +ENUM!{enum VSS_PROVIDER_TYPE { + VSS_PROV_UNKNOWN = 0, + VSS_PROV_SYSTEM = 1, + VSS_PROV_SOFTWARE = 2, + VSS_PROV_HARDWARE = 3, + VSS_PROV_FILESHARE = 4, +}} +pub type PVSS_PROVIDER_TYPE = *mut VSS_PROVIDER_TYPE; +ENUM!{enum VSS_APPLICATION_LEVEL { + VSS_APP_UNKNOWN = 0, + VSS_APP_SYSTEM = 1, + VSS_APP_BACK_END = 2, + VSS_APP_FRONT_END = 3, + VSS_APP_SYSTEM_RM = 4, + VSS_APP_AUTO = -1i32 as u32, +}} +pub type PVSS_APPLICATION_LEVEL = *mut VSS_APPLICATION_LEVEL; +ENUM!{enum _VSS_SNAPSHOT_COMPATIBILITY { + VSS_SC_DISABLE_DEFRAG = 0x1, + VSS_SC_DISABLE_CONTENTINDEX = 0x2, +}} +ENUM!{enum VSS_SNAPSHOT_PROPERTY_ID { + VSS_SPROPID_UNKNOWN = 0, + VSS_SPROPID_SNAPSHOT_ID = 0x1, + VSS_SPROPID_SNAPSHOT_SET_ID = 0x2, + VSS_SPROPID_SNAPSHOTS_COUNT = 0x3, + VSS_SPROPID_SNAPSHOT_DEVICE = 0x4, + VSS_SPROPID_ORIGINAL_VOLUME = 0x5, + VSS_SPROPID_ORIGINATING_MACHINE = 0x6, + VSS_SPROPID_SERVICE_MACHINE = 0x7, + VSS_SPROPID_EXPOSED_NAME = 0x8, + VSS_SPROPID_EXPOSED_PATH = 0x9, + VSS_SPROPID_PROVIDER_ID = 0xa, + VSS_SPROPID_SNAPSHOT_ATTRIBUTES = 0xb, + VSS_SPROPID_CREATION_TIMESTAMP = 0xc, + VSS_SPROPID_STATUS = 0xd, +}} +pub type PVSS_SNAPSHOT_PROPERTY_ID = *mut VSS_SNAPSHOT_PROPERTY_ID; +ENUM!{enum VSS_FILE_SPEC_BACKUP_TYPE { + VSS_FSBT_FULL_BACKUP_REQUIRED = 0x1, + VSS_FSBT_DIFFERENTIAL_BACKUP_REQUIRED = 0x2, + VSS_FSBT_INCREMENTAL_BACKUP_REQUIRED = 0x4, + VSS_FSBT_LOG_BACKUP_REQUIRED = 0x8, + VSS_FSBT_FULL_SNAPSHOT_REQUIRED = 0x100, + VSS_FSBT_DIFFERENTIAL_SNAPSHOT_REQUIRED = 0x200, + VSS_FSBT_INCREMENTAL_SNAPSHOT_REQUIRED = 0x400, + VSS_FSBT_LOG_SNAPSHOT_REQUIRED = 0x800, + VSS_FSBT_CREATED_DURING_BACKUP = 0x10000, + VSS_FSBT_ALL_BACKUP_REQUIRED = 0xf, + VSS_FSBT_ALL_SNAPSHOT_REQUIRED = 0xf00, +}} +pub type PVSS_FILE_SPEC_BACKUP_TYPE = *mut VSS_FILE_SPEC_BACKUP_TYPE; +ENUM!{enum VSS_BACKUP_SCHEMA { + VSS_BS_UNDEFINED = 0, + VSS_BS_DIFFERENTIAL = 0x1, + VSS_BS_INCREMENTAL = 0x2, + VSS_BS_EXCLUSIVE_INCREMENTAL_DIFFERENTIAL = 0x4, + VSS_BS_LOG = 0x8, + VSS_BS_COPY = 0x10, + VSS_BS_TIMESTAMPED = 0x20, + VSS_BS_LAST_MODIFY = 0x40, + VSS_BS_LSN = 0x80, + VSS_BS_WRITER_SUPPORTS_NEW_TARGET = 0x100, + VSS_BS_WRITER_SUPPORTS_RESTORE_WITH_MOVE = 0x200, + VSS_BS_INDEPENDENT_SYSTEM_STATE = 0x400, + VSS_BS_ROLLFORWARD_RESTORE = 0x1000, + VSS_BS_RESTORE_RENAME = 0x2000, + VSS_BS_AUTHORITATIVE_RESTORE = 0x4000, + VSS_BS_WRITER_SUPPORTS_PARALLEL_RESTORES = 0x8000, +}} +pub type PVSS_BACKUP_SCHEMA = *mut VSS_BACKUP_SCHEMA; +pub type VSS_ID = GUID; +pub type VSS_PWSZ = *mut WCHAR; +pub type VSS_TIMESTAMP = LONGLONG; +STRUCT!{struct VSS_SNAPSHOT_PROP { + m_SnapshotId: VSS_ID, + m_SnapshotSetId: VSS_ID, + m_lSnapshotsCount: LONG, + m_pwszSnapshotDeviceObject: VSS_PWSZ, + m_pwszOriginalVolumeName: VSS_PWSZ, + m_pwszOriginatingMachine: VSS_PWSZ, + m_pwszServiceMachine: VSS_PWSZ, + m_pwszExposedName: VSS_PWSZ, + m_pwszExposedPath: VSS_PWSZ, + m_ProviderId: VSS_ID, + m_lSnapshotAttributes: LONG, + m_tsCreationTimestamp: VSS_TIMESTAMP, + m_eStatus: VSS_SNAPSHOT_STATE, +}} +pub type PVSS_SNAPSHOT_PROP = *mut VSS_SNAPSHOT_PROP; +STRUCT!{struct VSS_PROVIDER_PROP { + m_ProviderId: VSS_ID, + m_pwszProviderName: VSS_PWSZ, + m_eProviderType: VSS_PROVIDER_TYPE, + m_pwszProviderVersion: VSS_PWSZ, + m_ProviderVersionId: VSS_ID, + m_ClassId: CLSID, +}} +pub type PVSS_PROVIDER_PROP = *mut VSS_PROVIDER_PROP; +UNION!{union VSS_OBJECT_UNION { + [u64; 12] [u64; 16], + Snap Snap_mut: VSS_SNAPSHOT_PROP, + Prov Prov_mut: VSS_PROVIDER_PROP, +}} +STRUCT!{struct VSS_OBJECT_PROP { + Type: VSS_OBJECT_TYPE, + Obj: VSS_OBJECT_UNION, +}} +pub type PVSS_OBJECT_PROP = *mut VSS_OBJECT_PROP; +RIDL!{#[uuid(0xae1c7110, 0x2f60, 0x11d3, 0x8a, 0x39, 0x00, 0xc0, 0x4f, 0x72, 0xd8, 0xe3)] +interface IVssEnumObject(IVssEnumObjectVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut VSS_OBJECT_PROP, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IVssEnumObject, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x507c37b4, 0xcf5b, 0x4e95, 0xb0, 0xaf, 0x14, 0xeb, 0x97, 0x67, 0x46, 0x7e)] +interface IVssAsync(IVssAsyncVtbl): IUnknown(IUnknownVtbl) { + fn Cancel() -> HRESULT, + fn Wait( + dwMilliseconds: DWORD, + ) -> HRESULT, + fn QueryStatus( + pHrResult: *mut HRESULT, + pReserved: *mut INT, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/vsserror.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/vsserror.rs new file mode 100644 index 0000000..1a29550 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/vsserror.rs @@ -0,0 +1,89 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! VSS Error header file +use um::winnt::HRESULT; +pub const VSS_E_BAD_STATE: HRESULT = 0x80042301; +pub const VSS_E_UNEXPECTED: HRESULT = 0x80042302; +pub const VSS_E_PROVIDER_ALREADY_REGISTERED: HRESULT = 0x80042303; +pub const VSS_E_PROVIDER_NOT_REGISTERED: HRESULT = 0x80042304; +pub const VSS_E_PROVIDER_VETO: HRESULT = 0x80042306; +pub const VSS_E_PROVIDER_IN_USE: HRESULT = 0x80042307; +pub const VSS_E_OBJECT_NOT_FOUND: HRESULT = 0x80042308; +pub const VSS_S_ASYNC_PENDING: HRESULT = 0x00042309; +pub const VSS_S_ASYNC_FINISHED: HRESULT = 0x0004230A; +pub const VSS_S_ASYNC_CANCELLED: HRESULT = 0x0004230B; +pub const VSS_E_VOLUME_NOT_SUPPORTED: HRESULT = 0x8004230C; +pub const VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER: HRESULT = 0x8004230E; +pub const VSS_E_OBJECT_ALREADY_EXISTS: HRESULT = 0x8004230D; +pub const VSS_E_UNEXPECTED_PROVIDER_ERROR: HRESULT = 0x8004230F; +pub const VSS_E_CORRUPT_XML_DOCUMENT: HRESULT = 0x80042310; +pub const VSS_E_INVALID_XML_DOCUMENT: HRESULT = 0x80042311; +pub const VSS_E_MAXIMUM_NUMBER_OF_VOLUMES_REACHED: HRESULT = 0x80042312; +pub const VSS_E_FLUSH_WRITES_TIMEOUT: HRESULT = 0x80042313; +pub const VSS_E_HOLD_WRITES_TIMEOUT: HRESULT = 0x80042314; +pub const VSS_E_UNEXPECTED_WRITER_ERROR: HRESULT = 0x80042315; +pub const VSS_E_SNAPSHOT_SET_IN_PROGRESS: HRESULT = 0x80042316; +pub const VSS_E_MAXIMUM_NUMBER_OF_SNAPSHOTS_REACHED: HRESULT = 0x80042317; +pub const VSS_E_WRITER_INFRASTRUCTURE: HRESULT = 0x80042318; +pub const VSS_E_WRITER_NOT_RESPONDING: HRESULT = 0x80042319; +pub const VSS_E_WRITER_ALREADY_SUBSCRIBED: HRESULT = 0x8004231A; +pub const VSS_E_UNSUPPORTED_CONTEXT: HRESULT = 0x8004231B; +pub const VSS_E_VOLUME_IN_USE: HRESULT = 0x8004231D; +pub const VSS_E_MAXIMUM_DIFFAREA_ASSOCIATIONS_REACHED: HRESULT = 0x8004231E; +pub const VSS_E_INSUFFICIENT_STORAGE: HRESULT = 0x8004231F; +pub const VSS_E_NO_SNAPSHOTS_IMPORTED: HRESULT = 0x80042320; +pub const VSS_S_SOME_SNAPSHOTS_NOT_IMPORTED: HRESULT = 0x00042321; +pub const VSS_E_SOME_SNAPSHOTS_NOT_IMPORTED: HRESULT = 0x80042321; +pub const VSS_E_MAXIMUM_NUMBER_OF_REMOTE_MACHINES_REACHED: HRESULT = 0x80042322; +pub const VSS_E_REMOTE_SERVER_UNAVAILABLE: HRESULT = 0x80042323; +pub const VSS_E_REMOTE_SERVER_UNSUPPORTED: HRESULT = 0x80042324; +pub const VSS_E_REVERT_IN_PROGRESS: HRESULT = 0x80042325; +pub const VSS_E_REVERT_VOLUME_LOST: HRESULT = 0x80042326; +pub const VSS_E_REBOOT_REQUIRED: HRESULT = 0x80042327; +pub const VSS_E_TRANSACTION_FREEZE_TIMEOUT: HRESULT = 0x80042328; +pub const VSS_E_TRANSACTION_THAW_TIMEOUT: HRESULT = 0x80042329; +pub const VSS_E_VOLUME_NOT_LOCAL: HRESULT = 0x8004232D; +pub const VSS_E_CLUSTER_TIMEOUT: HRESULT = 0x8004232E; +pub const VSS_E_WRITERERROR_INCONSISTENTSNAPSHOT: HRESULT = 0x800423F0; +pub const VSS_E_WRITERERROR_OUTOFRESOURCES: HRESULT = 0x800423F1; +pub const VSS_E_WRITERERROR_TIMEOUT: HRESULT = 0x800423F2; +pub const VSS_E_WRITERERROR_RETRYABLE: HRESULT = 0x800423F3; +pub const VSS_E_WRITERERROR_NONRETRYABLE: HRESULT = 0x800423F4; +pub const VSS_E_WRITERERROR_RECOVERY_FAILED: HRESULT = 0x800423F5; +pub const VSS_E_BREAK_REVERT_ID_FAILED: HRESULT = 0x800423F6; +pub const VSS_E_LEGACY_PROVIDER: HRESULT = 0x800423F7; +pub const VSS_E_MISSING_DISK: HRESULT = 0x800423F8; +pub const VSS_E_MISSING_HIDDEN_VOLUME: HRESULT = 0x800423F9; +pub const VSS_E_MISSING_VOLUME: HRESULT = 0x800423FA; +pub const VSS_E_AUTORECOVERY_FAILED: HRESULT = 0x800423FB; +pub const VSS_E_DYNAMIC_DISK_ERROR: HRESULT = 0x800423FC; +pub const VSS_E_NONTRANSPORTABLE_BCD: HRESULT = 0x800423FD; +pub const VSS_E_CANNOT_REVERT_DISKID: HRESULT = 0x800423FE; +pub const VSS_E_RESYNC_IN_PROGRESS: HRESULT = 0x800423FF; +pub const VSS_E_CLUSTER_ERROR: HRESULT = 0x80042400; +pub const VSS_E_UNSELECTED_VOLUME: HRESULT = 0x8004232A; +pub const VSS_E_SNAPSHOT_NOT_IN_SET: HRESULT = 0x8004232B; +pub const VSS_E_NESTED_VOLUME_LIMIT: HRESULT = 0x8004232C; +pub const VSS_E_NOT_SUPPORTED: HRESULT = 0x8004232F; +pub const VSS_E_WRITERERROR_PARTIAL_FAILURE: HRESULT = 0x80042336; +pub const VSS_E_ASRERROR_DISK_ASSIGNMENT_FAILED: HRESULT = 0x80042401; +pub const VSS_E_ASRERROR_DISK_RECREATION_FAILED: HRESULT = 0x80042402; +pub const VSS_E_ASRERROR_NO_ARCPATH: HRESULT = 0x80042403; +pub const VSS_E_ASRERROR_MISSING_DYNDISK: HRESULT = 0x80042404; +pub const VSS_E_ASRERROR_SHARED_CRIDISK: HRESULT = 0x80042405; +pub const VSS_E_ASRERROR_DATADISK_RDISK0: HRESULT = 0x80042406; +pub const VSS_E_ASRERROR_RDISK0_TOOSMALL: HRESULT = 0x80042407; +pub const VSS_E_ASRERROR_CRITICAL_DISKS_TOO_SMALL: HRESULT = 0x80042408; +pub const VSS_E_WRITER_STATUS_NOT_AVAILABLE: HRESULT = 0x80042409; +pub const VSS_E_ASRERROR_DYNAMIC_VHD_NOT_SUPPORTED: HRESULT = 0x8004240A; +pub const VSS_E_CRITICAL_VOLUME_ON_INVALID_DISK: HRESULT = 0x80042411; +pub const VSS_E_ASRERROR_RDISK_FOR_SYSTEM_DISK_NOT_FOUND: HRESULT = 0x80042412; +pub const VSS_E_ASRERROR_NO_PHYSICAL_DISK_AVAILABLE: HRESULT = 0x80042413; +pub const VSS_E_ASRERROR_FIXED_PHYSICAL_DISK_AVAILABLE_AFTER_DISK_EXCLUSION: HRESULT = + 0x80042414; +pub const VSS_E_ASRERROR_CRITICAL_DISK_CANNOT_BE_EXCLUDED: HRESULT = 0x80042415; +pub const VSS_E_ASRERROR_SYSTEM_PARTITION_HIDDEN: HRESULT = 0x80042416; +pub const VSS_E_FSS_TIMEOUT: HRESULT = 0x80042417; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/vswriter.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/vswriter.rs new file mode 100644 index 0000000..43d6000 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/vswriter.rs @@ -0,0 +1,397 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Declaration of Writer +use shared::minwindef::{BOOL, BYTE, DWORD, FILETIME, UINT}; +use shared::wtypes::BSTR; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::vss::{VSS_ID, VSS_ROLLFORWARD_TYPE}; +use um::winnt::{HRESULT, LPCWSTR, VOID}; +ENUM!{enum VSS_USAGE_TYPE { + VSS_UT_UNDEFINED = 0, + VSS_UT_BOOTABLESYSTEMSTATE = 1, + VSS_UT_SYSTEMSERVICE = 2, + VSS_UT_USERDATA = 3, + VSS_UT_OTHER = 4, +}} +ENUM!{enum VSS_SOURCE_TYPE { + VSS_ST_UNDEFINED = 0, + VSS_ST_TRANSACTEDDB = 1, + VSS_ST_NONTRANSACTEDDB = 2, + VSS_ST_OTHER = 3, +}} +ENUM!{enum VSS_RESTOREMETHOD_ENUM { + VSS_RME_UNDEFINED = 0, + VSS_RME_RESTORE_IF_NOT_THERE = 1, + VSS_RME_RESTORE_IF_CAN_REPLACE = 2, + VSS_RME_STOP_RESTORE_START = 3, + VSS_RME_RESTORE_TO_ALTERNATE_LOCATION = 4, + VSS_RME_RESTORE_AT_REBOOT = 5, + VSS_RME_RESTORE_AT_REBOOT_IF_CANNOT_REPLACE = 6, + VSS_RME_CUSTOM = 7, + VSS_RME_RESTORE_STOP_START = 8, +}} +ENUM!{enum VSS_WRITERRESTORE_ENUM { + VSS_WRE_UNDEFINED = 0, + VSS_WRE_NEVER = 1, + VSS_WRE_IF_REPLACE_FAILS = 2, + VSS_WRE_ALWAYS = 3, +}} +ENUM!{enum VSS_COMPONENT_TYPE { + VSS_CT_UNDEFINED = 0, + VSS_CT_DATABASE = 1, + VSS_CT_FILEGROUP = 2, +}} +ENUM!{enum VSS_ALTERNATE_WRITER_STATE { + VSS_AWS_UNDEFINED = 0, + VSS_AWS_NO_ALTERNATE_WRITER = 1, + VSS_AWS_ALTERNATE_WRITER_EXISTS = 2, + VSS_AWS_THIS_IS_ALTERNATE_WRITER = 3, +}} +ENUM!{enum VSS_SUBSCRIBE_MASK { + VSS_SM_POST_SNAPSHOT_FLAG = 0x00000001, + VSS_SM_BACKUP_EVENTS_FLAG = 0x00000002, + VSS_SM_RESTORE_EVENTS_FLAG = 0x00000004, + VSS_SM_IO_THROTTLING_FLAG = 0x00000008, + VSS_SM_ALL_FLAGS = 0xffffffff, +}} +ENUM!{enum VSS_RESTORE_TARGET { + VSS_RT_UNDEFINED = 0, + VSS_RT_ORIGINAL = 1, + VSS_RT_ALTERNATE = 2, + VSS_RT_DIRECTED = 3, + VSS_RT_ORIGINAL_LOCATION = 4, +}} +ENUM!{enum VSS_FILE_RESTORE_STATUS { + VSS_RS_UNDEFINED = 0, + VSS_RS_NONE = 1, + VSS_RS_ALL = 2, + VSS_RS_FAILED = 3, +}} +ENUM!{enum VSS_COMPONENT_FLAGS { + VSS_CF_BACKUP_RECOVERY = 0x00000001, + VSS_CF_APP_ROLLBACK_RECOVERY = 0x00000002, + VSS_CF_NOT_SYSTEM_STATE = 0x00000004, +}} +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +interface IVssWMFiledesc(IVssWMFiledescVtbl): IUnknown(IUnknownVtbl) { + fn GetPath( + pbstrPath: *mut BSTR, + ) -> HRESULT, + fn GetFilespec( + pbstrFilespec: *mut BSTR, + ) -> HRESULT, + fn GetRecursive( + pbRecursive: *mut bool, + ) -> HRESULT, + fn GetAlternateLocation( + pbstrAlternateLocation: *mut BSTR, + ) -> HRESULT, + fn GetBackupTypeMask( + pdwTypeMask: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +interface IVssWMDependency(IVssWMDependencyVtbl): IUnknown(IUnknownVtbl) { + fn GetWriterId( + pWriterId: *mut VSS_ID, + ) -> HRESULT, + fn GetLogicalPath( + pbstrLogicalPath: *mut BSTR, + ) -> HRESULT, + fn GetComponentName( + pbstrComponentName: *mut BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd2c72c96, 0xc121, 0x4518, 0xb6, 0x27, 0xe5, 0xa9, 0x3d, 0x01, 0x0e, 0xad)] +interface IVssComponent(IVssComponentVtbl): IUnknown(IUnknownVtbl) { + fn GetLogicalPath( + pbstrPath: *mut BSTR, + ) -> HRESULT, + fn GetComponentType( + pct: *mut VSS_COMPONENT_TYPE, + ) -> HRESULT, + fn GetComponentName( + pbstrName: *mut BSTR, + ) -> HRESULT, + fn GetBackupSucceeded( + pbSucceeded: *mut bool, + ) -> HRESULT, + fn GetAlternateLocationMappingCount( + pcMappings: *mut UINT, + ) -> HRESULT, + fn GetAlternateLocationMapping( + iMapping: UINT, + ppFiledesc: *mut *mut IVssWMFiledesc, + ) -> HRESULT, + fn SetBackupMetadata( + wszData: LPCWSTR, + ) -> HRESULT, + fn GetBackupMetadata( + pbstrData: *mut BSTR, + ) -> HRESULT, + fn AddPartialFile( + wszPath: LPCWSTR, + wszFilename: LPCWSTR, + wszRanges: LPCWSTR, + wszMetadata: LPCWSTR, + ) -> HRESULT, + fn GetPartialFileCount( + pcPartialFiles: *mut UINT, + ) -> HRESULT, + fn GetPartialFile( + iPartialFile: UINT, + pbstrPath: *mut BSTR, + pbstrFilename: *mut BSTR, + pbstrRange: *mut BSTR, + pbstrMetadata: *mut BSTR, + ) -> HRESULT, + fn IsSelectedForRestore( + pbSelectedForRestore: *mut bool, + ) -> HRESULT, + fn GetAdditionalRestores( + pbAdditionalRestores: *mut bool, + ) -> HRESULT, + fn GetNewTargetCount( + pcNewTarget: *mut UINT, + ) -> HRESULT, + fn GetNewTarget( + iNewTarget: UINT, + ppFiledesc: *mut *mut IVssWMFiledesc, + ) -> HRESULT, + fn AddDirectedTarget( + wszSourcePath: LPCWSTR, + wszSourceFilename: LPCWSTR, + wszSourceRangeList: LPCWSTR, + wszDestinationPath: LPCWSTR, + wszDestinationFilename: LPCWSTR, + wszDestinationRangeList: LPCWSTR, + ) -> HRESULT, + fn GetDirectedTargetCount( + pcDirectedTarget: *mut UINT, + ) -> HRESULT, + fn GetDirectedTarget( + iDirectedTarget: UINT, + pbstrSourcePath: *mut BSTR, + pbstrSourceFileName: *mut BSTR, + pbstrSourceRangeList: *mut BSTR, + pbstrDestinationPath: *mut BSTR, + pbstrDestinationFilename: *mut BSTR, + pbstrDestinationRangeList: *mut BSTR, + ) -> HRESULT, + fn SetRestoreMetadata( + wszRestoreMetadata: LPCWSTR, + ) -> HRESULT, + fn GetRestoreMetadata( + pbstrRestoreMetadata: *mut BSTR, + ) -> HRESULT, + fn SetRestoreTarget( + target: VSS_RESTORE_TARGET, + ) -> HRESULT, + fn GetRestoreTarget( + pTarget: *mut VSS_RESTORE_TARGET, + ) -> HRESULT, + fn SetPreRestoreFailureMsg( + wszPreRestoreFailureMsg: LPCWSTR, + ) -> HRESULT, + fn GetPreRestoreFailureMsg( + pbstrPreRestoreFailureMsg: *mut BSTR, + ) -> HRESULT, + fn SetPostRestoreFailureMsg( + wszPostRestoreFailureMsg: LPCWSTR, + ) -> HRESULT, + fn GetPostRestoreFailureMsg( + pbstrPostRestoreFailureMsg: *mut BSTR, + ) -> HRESULT, + fn SetBackupStamp( + wszBackupStamp: LPCWSTR, + ) -> HRESULT, + fn GetBackupStamp( + pbstrBackupStamp: *mut BSTR, + ) -> HRESULT, + fn GetPreviousBackupStamp( + pbstrBackupStamp: *mut BSTR, + ) -> HRESULT, + fn GetBackupOptions( + pbstrBackupOptions: *mut BSTR, + ) -> HRESULT, + fn GetRestoreOptions( + pbstrRestoreOptions: *mut BSTR, + ) -> HRESULT, + fn GetRestoreSubcomponentCount( + pcRestoreSubcomponent: *mut UINT, + ) -> HRESULT, + fn GetRestoreSubcomponent( + iComponent: UINT, + pbstrLogicalPath: *mut BSTR, + pbstrComponentName: *mut BSTR, + pbRepair: *mut bool, + ) -> HRESULT, + fn GetFileRestoreStatus( + pStatus: *mut VSS_FILE_RESTORE_STATUS, + ) -> HRESULT, + fn AddDifferencedFilesByLastModifyTime( + wszPath: LPCWSTR, + wszFilespec: LPCWSTR, + bRecursive: BOOL, + ftLastModifyTime: FILETIME, + ) -> HRESULT, + fn AddDifferencedFilesByLastModifyLSN( + wszPath: LPCWSTR, + wszFilespec: LPCWSTR, + bRecursive: BOOL, + bstrLsnString: BSTR, + ) -> HRESULT, + fn GetDifferencedFilesCount( + pcDifferencedFiles: *mut UINT, + ) -> HRESULT, + fn GetDifferencedFile( + iDifferencedFile: UINT, + pbstrPath: *mut BSTR, + pbstrFilespec: *mut BSTR, + pbRecursive: *mut BOOL, + pbstrLsnString: *mut BSTR, + pftLastModifyTime: *mut FILETIME, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +interface IVssWriterComponents(IVssWriterComponentsVtbl) { + fn GetComponentCount( + pcComponents: *mut UINT, + ) -> HRESULT, + fn GetWriterInfo( + pidInstance: *mut VSS_ID, + pidWriter: *mut VSS_ID, + ) -> HRESULT, + fn GetComponent( + iComponent: UINT, + ppComponent: *mut *mut IVssComponent, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x156c8b5e, 0xf131, 0x4bd7, 0x9c, 0x97, 0xd1, 0x92, 0x3b, 0xe7, 0xe1, 0xfa)] +interface IVssComponentEx(IVssComponentExVtbl): IVssComponent(IVssComponentVtbl) { + fn SetPrepareForBackupFailureMsg( + wszFailureMsg: LPCWSTR, + ) -> HRESULT, + fn SetPostSnapshotFailureMsg( + wszFailureMsg: LPCWSTR, + ) -> HRESULT, + fn GetPrepareForBackupFailureMsg( + pbstrFailureMsg: *mut BSTR, + ) -> HRESULT, + fn GetPostSnapshotFailureMsg( + pbstrFailureMsg: *mut BSTR, + ) -> HRESULT, + fn GetAuthoritativeRestore( + pbAuth: *mut bool, + ) -> HRESULT, + fn GetRollForward( + pRollType: *mut VSS_ROLLFORWARD_TYPE, + pbstrPoint: *mut BSTR, + ) -> HRESULT, + fn GetRestoreName( + pbstrName: *mut BSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3b5be0f2, 0x07a9, 0x4e4b, 0xbd, 0xd3, 0xcf, 0xdc, 0x8e, 0x2c, 0x0d, 0x2d)] +interface IVssComponentEx2(IVssComponentEx2Vtbl): IVssComponentEx(IVssComponentExVtbl) { + fn SetFailure( + hr: HRESULT, + hrApplication: HRESULT, + wszApplicationMessage: LPCWSTR, + dwReserved: DWORD, + ) -> HRESULT, + fn GetFailure( + phr: *mut HRESULT, + phrApplication: *mut HRESULT, + pbstrApplicationMessage: *mut BSTR, + pdwReserved: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +interface IVssCreateWriterMetadata(IVssCreateWriterMetadataVtbl) { + fn AddIncludeFiles( + wszPath: LPCWSTR, + wszFilespec: LPCWSTR, + bRecursive: bool, + wszAlternateLocation: LPCWSTR, + ) -> HRESULT, + fn AddExcludeFiles( + wszPath: LPCWSTR, + wszFilespec: LPCWSTR, + bRecursive: bool, + ) -> HRESULT, + fn AddComponent( + ct: VSS_COMPONENT_TYPE, + wszLogicalPath: LPCWSTR, + wszComponentName: LPCWSTR, + wszCaption: LPCWSTR, + pbIcon: *const BYTE, + cbIcon: UINT, + bRestoreMetadata: bool, + bNotifyOnBackupComplete: bool, + bSelectableForRestore: bool, + dwComponentFlags: DWORD, + ) -> HRESULT, + fn AddDatabaseFiles( + wszLogicalPath: LPCWSTR, + wszDatabaseName: LPCWSTR, + wszPath: LPCWSTR, + wszFilespec: LPCWSTR, + dwBackupTypeMask: DWORD, + ) -> HRESULT, + fn AddDatabaseLogFiles( + wszLogicalPath: LPCWSTR, + wszDatabaseName: LPCWSTR, + wszPath: LPCWSTR, + wszFilespec: LPCWSTR, + dwBackupTypeMask: DWORD, + ) -> HRESULT, + fn AddFilesToFileGroup( + wszLogicalPath: LPCWSTR, + wszGroupName: LPCWSTR, + wszPath: LPCWSTR, + wszFilespec: LPCWSTR, + bRecursive: bool, + wszAlternateLocation: LPCWSTR, + dwBackupTypeMask: DWORD, + ) -> HRESULT, + fn SetRestoreMethod( + method: VSS_RESTOREMETHOD_ENUM, + wszService: LPCWSTR, + wszUserProcedure: LPCWSTR, + writerRestore: VSS_WRITERRESTORE_ENUM, + bRebootRequired: bool, + ) -> HRESULT, + fn AddAlternateLocationMapping( + wszSourcePath: LPCWSTR, + wszSourceFilespec: LPCWSTR, + bRecursive: bool, + wszDestination: LPCWSTR, + ) -> HRESULT, + fn AddComponentDependency( + wszForLogicalPath: LPCWSTR, + wszForComponentName: LPCWSTR, + onWriterId: VSS_ID, + wszOnLogicalPath: LPCWSTR, + wszOnComponentName: LPCWSTR, + ) -> HRESULT, + fn SetBackupSchema( + dwSchemaMask: DWORD, + ) -> HRESULT, + fn GetDocument( + pDoc: *mut *mut VOID, + ) -> HRESULT, //TODO IXMLDOMDocument, + fn SaveAsXML( + pbstrXML: *mut BSTR, + ) -> HRESULT, +}} +//IVssCreateWriterMetadataEx +//IVssWriterImpl +//IVssCreateExpressWriterMetadata +//IVssExpressWriter +//CVssWriter +//CVssWriterEx +//CVssWriterEx2 diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemads.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemads.rs new file mode 100644 index 0000000..5ba09e6 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemads.rs @@ -0,0 +1,41 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::winerror::HRESULT; +use shared::wtypes::BSTR; +use um::oaidl::{IDispatch, IDispatchVtbl}; +use um::wbemdisp::{ISWbemObject, ISWbemServices}; +// extern RPC_IF_HANDLE __MIDL_itf_wbemads_0000_0000_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemads_0000_0000_v0_0_s_ifspec; +// EXTERN_C const IID LIBID_WMIEXTENSIONLib; +// EXTERN_C const IID IID_IWMIExtension; +DEFINE_GUID!{IID_IWMIExtension, + 0xadc1f06e, 0x5c7e, 0x11d2, 0x8b, 0x74, 0x00, 0x10, 0x4b, 0x2a, 0xfb, 0x41} +RIDL!{#[uuid(0xadc1f06e, 0x5c7e, 0x11d2, 0x8b, 0x74, 0x00, 0x10, 0x4b, 0x2a, 0xfb, 0x41)] +interface IWMIExtension(IWMIExtensionVtbl): IDispatch(IDispatchVtbl) { + fn get_WMIObjectPath( + strWMIObjectPath: *mut BSTR, + ) -> HRESULT, + fn GetWMIObject( + objWMIObject: *mut *mut ISWbemObject, + ) -> HRESULT, + fn GetWMIServices( + objWMIServices: *mut *mut ISWbemServices, + ) -> HRESULT, +}} +DEFINE_GUID!{CLSID_WMIExtension, + 0xf0975afe, 0x5c7f, 0x11d2, 0x8b, 0x74, 0x00, 0x10, 0x4b, 0x2a, 0xfb, 0x41} +// class DECLSPEC_UUID("f0975afe-5c7f-11d2-8b74-00104b2afb41") +// WMIExtension; +// extern RPC_IF_HANDLE __MIDL_itf_wbemads_0000_0002_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemads_0000_0002_v0_0_s_ifspec; +// unsigned long __RPC_USER BSTR_UserSize( __RPC__in unsigned long *, unsigned long , __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserMarshal( __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserUnmarshal(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); +// void __RPC_USER BSTR_UserFree( __RPC__in unsigned long *, __RPC__in BSTR * ); +// unsigned long __RPC_USER BSTR_UserSize64( __RPC__in unsigned long *, unsigned long , __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserMarshal64( __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserUnmarshal64(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); +// void __RPC_USER BSTR_UserFree64( __RPC__in unsigned long *, __RPC__in BSTR * ); diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemcli.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemcli.rs new file mode 100644 index 0000000..9320a80 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemcli.rs @@ -0,0 +1,1174 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{__uint64, c_long, c_uchar}; +use shared::minwindef::{BYTE, DWORD, ULONG}; +use shared::rpcndr::byte; +use shared::winerror::HRESULT; +use shared::wtypes::BSTR; +use um::oaidl::{SAFEARRAY, VARIANT}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{LCID, LONG, LPCWSTR, LPWSTR}; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0000_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0000_v0_0_s_ifspec; +ENUM!{enum WBEM_GENUS_TYPE { + WBEM_GENUS_CLASS = 1, + WBEM_GENUS_INSTANCE = 2, +}} +ENUM!{enum WBEM_CHANGE_FLAG_TYPE { + WBEM_FLAG_CREATE_OR_UPDATE = 0, + WBEM_FLAG_UPDATE_ONLY = 0x1, + WBEM_FLAG_CREATE_ONLY = 0x2, + WBEM_FLAG_UPDATE_COMPATIBLE = 0, + WBEM_FLAG_UPDATE_SAFE_MODE = 0x20, + WBEM_FLAG_UPDATE_FORCE_MODE = 0x40, + WBEM_MASK_UPDATE_MODE = 0x60, + WBEM_FLAG_ADVISORY = 0x10000, +}} +ENUM!{enum WBEM_GENERIC_FLAG_TYPE { + WBEM_FLAG_RETURN_IMMEDIATELY = 0x10, + WBEM_FLAG_RETURN_WBEM_COMPLETE = 0, + WBEM_FLAG_BIDIRECTIONAL = 0, + WBEM_FLAG_FORWARD_ONLY = 0x20, + WBEM_FLAG_NO_ERROR_OBJECT = 0x40, + WBEM_FLAG_RETURN_ERROR_OBJECT = 0, + WBEM_FLAG_SEND_STATUS = 0x80, + WBEM_FLAG_DONT_SEND_STATUS = 0, + WBEM_FLAG_ENSURE_LOCATABLE = 0x100, + WBEM_FLAG_DIRECT_READ = 0x200, + WBEM_FLAG_SEND_ONLY_SELECTED = 0, + WBEM_RETURN_WHEN_COMPLETE = 0, + WBEM_RETURN_IMMEDIATELY = 0x10, + WBEM_MASK_RESERVED_FLAGS = 0x1f000, + WBEM_FLAG_USE_AMENDED_QUALIFIERS = 0x20000, + WBEM_FLAG_STRONG_VALIDATION = 0x100000, +}} +ENUM!{enum WBEM_STATUS_TYPE { + WBEM_STATUS_COMPLETE = 0, + WBEM_STATUS_REQUIREMENTS = 1, + WBEM_STATUS_PROGRESS = 2, + WBEM_STATUS_LOGGING_INFORMATION = 0x100, + WBEM_STATUS_LOGGING_INFORMATION_PROVIDER = 0x200, + WBEM_STATUS_LOGGING_INFORMATION_HOST = 0x400, + WBEM_STATUS_LOGGING_INFORMATION_REPOSITORY = 0x800, + WBEM_STATUS_LOGGING_INFORMATION_ESS = 0x1000, +}} +ENUM!{enum WBEM_TIMEOUT_TYPE { + WBEM_NO_WAIT = 0, + WBEM_INFINITE = 0xffffffff, +}} +ENUM!{enum WBEM_CONDITION_FLAG_TYPE { + WBEM_FLAG_ALWAYS = 0, + WBEM_FLAG_ONLY_IF_TRUE = 0x1, + WBEM_FLAG_ONLY_IF_FALSE = 0x2, + WBEM_FLAG_ONLY_IF_IDENTICAL = 0x3, + WBEM_MASK_PRIMARY_CONDITION = 0x3, + WBEM_FLAG_KEYS_ONLY = 0x4, + WBEM_FLAG_REFS_ONLY = 0x8, + WBEM_FLAG_LOCAL_ONLY = 0x10, + WBEM_FLAG_PROPAGATED_ONLY = 0x20, + WBEM_FLAG_SYSTEM_ONLY = 0x30, + WBEM_FLAG_NONSYSTEM_ONLY = 0x40, + WBEM_MASK_CONDITION_ORIGIN = 0x70, + WBEM_FLAG_CLASS_OVERRIDES_ONLY = 0x100, + WBEM_FLAG_CLASS_LOCAL_AND_OVERRIDES = 0x200, + WBEM_MASK_CLASS_CONDITION = 0x300, +}} +ENUM!{enum WBEM_FLAVOR_TYPE { + WBEM_FLAVOR_DONT_PROPAGATE = 0, + WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE = 0x1, + WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS = 0x2, + WBEM_FLAVOR_MASK_PROPAGATION = 0xf, + WBEM_FLAVOR_OVERRIDABLE = 0, + WBEM_FLAVOR_NOT_OVERRIDABLE = 0x10, + WBEM_FLAVOR_MASK_PERMISSIONS = 0x10, + WBEM_FLAVOR_ORIGIN_LOCAL = 0, + WBEM_FLAVOR_ORIGIN_PROPAGATED = 0x20, + WBEM_FLAVOR_ORIGIN_SYSTEM = 0x40, + WBEM_FLAVOR_MASK_ORIGIN = 0x60, + WBEM_FLAVOR_NOT_AMENDED = 0, + WBEM_FLAVOR_AMENDED = 0x80, + WBEM_FLAVOR_MASK_AMENDED = 0x80, +}} +ENUM!{enum WBEM_QUERY_FLAG_TYPE { + WBEM_FLAG_DEEP = 0, + WBEM_FLAG_SHALLOW = 1, + WBEM_FLAG_PROTOTYPE = 2, +}} +ENUM!{enum WBEM_SECURITY_FLAGS { + WBEM_ENABLE = 1, + WBEM_METHOD_EXECUTE = 2, + WBEM_FULL_WRITE_REP = 4, + WBEM_PARTIAL_WRITE_REP = 8, + WBEM_WRITE_PROVIDER = 0x10, + WBEM_REMOTE_ACCESS = 0x20, + WBEM_RIGHT_SUBSCRIBE = 0x40, + WBEM_RIGHT_PUBLISH = 0x80, +}} +ENUM!{enum WBEM_LIMITATION_FLAG_TYPE { + WBEM_FLAG_EXCLUDE_OBJECT_QUALIFIERS = 0x10, + WBEM_FLAG_EXCLUDE_PROPERTY_QUALIFIERS = 0x20, +}} +ENUM!{enum WBEM_TEXT_FLAG_TYPE { + WBEM_FLAG_NO_FLAVORS = 0x1, +}} +ENUM!{enum WBEM_COMPARISON_FLAG { + WBEM_COMPARISON_INCLUDE_ALL = 0, + WBEM_FLAG_IGNORE_QUALIFIERS = 0x1, + WBEM_FLAG_IGNORE_OBJECT_SOURCE = 0x2, + WBEM_FLAG_IGNORE_DEFAULT_VALUES = 0x4, + WBEM_FLAG_IGNORE_CLASS = 0x8, + WBEM_FLAG_IGNORE_CASE = 0x10, + WBEM_FLAG_IGNORE_FLAVOR = 0x20, +}} +ENUM!{enum WBEM_LOCKING_FLAG_TYPE { + WBEM_FLAG_ALLOW_READ = 0x1, +}} +ENUM!{enum CIMTYPE_ENUMERATION { + CIM_ILLEGAL = 0xfff, + CIM_EMPTY = 0, + CIM_SINT8 = 16, + CIM_UINT8 = 17, + CIM_SINT16 = 2, + CIM_UINT16 = 18, + CIM_SINT32 = 3, + CIM_UINT32 = 19, + CIM_SINT64 = 20, + CIM_UINT64 = 21, + CIM_REAL32 = 4, + CIM_REAL64 = 5, + CIM_BOOLEAN = 11, + CIM_STRING = 8, + CIM_DATETIME = 101, + CIM_REFERENCE = 102, + CIM_CHAR16 = 103, + CIM_OBJECT = 13, + CIM_FLAG_ARRAY = 0x2000, +}} +ENUM!{enum WBEM_BACKUP_RESTORE_FLAGS { + WBEM_FLAG_BACKUP_RESTORE_DEFAULT = 0, + WBEM_FLAG_BACKUP_RESTORE_FORCE_SHUTDOWN = 1, +}} +ENUM!{enum WBEM_REFRESHER_FLAGS { + WBEM_FLAG_REFRESH_AUTO_RECONNECT = 0, + WBEM_FLAG_REFRESH_NO_AUTO_RECONNECT = 1, +}} +ENUM!{enum WBEM_SHUTDOWN_FLAGS { + WBEM_SHUTDOWN_UNLOAD_COMPONENT = 1, + WBEM_SHUTDOWN_WMI = 2, + WBEM_SHUTDOWN_OS = 3, +}} +pub type CIMTYPE = c_long; +ENUM!{enum WBEMSTATUS_FORMAT { + WBEMSTATUS_FORMAT_NEWLINE = 0, + WBEMSTATUS_FORMAT_NO_NEWLINE = 1, +}} +ENUM!{enum WBEM_LIMITS { + WBEM_MAX_IDENTIFIER = 0x1000, + WBEM_MAX_QUERY = 0x4000, + WBEM_MAX_PATH = 0x2000, + WBEM_MAX_OBJECT_NESTING = 64, + WBEM_MAX_USER_PROPERTIES = 1024, +}} +ENUM!{enum WBEMSTATUS { + WBEM_NO_ERROR = 0, + WBEM_S_NO_ERROR = 0, + WBEM_S_SAME = 0, + WBEM_S_FALSE = 1, + WBEM_S_ALREADY_EXISTS = 0x40001, + WBEM_S_RESET_TO_DEFAULT = 0x40002, + WBEM_S_DIFFERENT = 0x40003, + WBEM_S_TIMEDOUT = 0x40004, + WBEM_S_NO_MORE_DATA = 0x40005, + WBEM_S_OPERATION_CANCELLED = 0x40006, + WBEM_S_PENDING = 0x40007, + WBEM_S_DUPLICATE_OBJECTS = 0x40008, + WBEM_S_ACCESS_DENIED = 0x40009, + WBEM_S_PARTIAL_RESULTS = 0x40010, + WBEM_S_SOURCE_NOT_AVAILABLE = 0x40017, + WBEM_E_FAILED = 0x80041001, + WBEM_E_NOT_FOUND = 0x80041002, + WBEM_E_ACCESS_DENIED = 0x80041003, + WBEM_E_PROVIDER_FAILURE = 0x80041004, + WBEM_E_TYPE_MISMATCH = 0x80041005, + WBEM_E_OUT_OF_MEMORY = 0x80041006, + WBEM_E_INVALID_CONTEXT = 0x80041007, + WBEM_E_INVALID_PARAMETER = 0x80041008, + WBEM_E_NOT_AVAILABLE = 0x80041009, + WBEM_E_CRITICAL_ERROR = 0x8004100a, + WBEM_E_INVALID_STREAM = 0x8004100b, + WBEM_E_NOT_SUPPORTED = 0x8004100c, + WBEM_E_INVALID_SUPERCLASS = 0x8004100d, + WBEM_E_INVALID_NAMESPACE = 0x8004100e, + WBEM_E_INVALID_OBJECT = 0x8004100f, + WBEM_E_INVALID_CLASS = 0x80041010, + WBEM_E_PROVIDER_NOT_FOUND = 0x80041011, + WBEM_E_INVALID_PROVIDER_REGISTRATION = 0x80041012, + WBEM_E_PROVIDER_LOAD_FAILURE = 0x80041013, + WBEM_E_INITIALIZATION_FAILURE = 0x80041014, + WBEM_E_TRANSPORT_FAILURE = 0x80041015, + WBEM_E_INVALID_OPERATION = 0x80041016, + WBEM_E_INVALID_QUERY = 0x80041017, + WBEM_E_INVALID_QUERY_TYPE = 0x80041018, + WBEM_E_ALREADY_EXISTS = 0x80041019, + WBEM_E_OVERRIDE_NOT_ALLOWED = 0x8004101a, + WBEM_E_PROPAGATED_QUALIFIER = 0x8004101b, + WBEM_E_PROPAGATED_PROPERTY = 0x8004101c, + WBEM_E_UNEXPECTED = 0x8004101d, + WBEM_E_ILLEGAL_OPERATION = 0x8004101e, + WBEM_E_CANNOT_BE_KEY = 0x8004101f, + WBEM_E_INCOMPLETE_CLASS = 0x80041020, + WBEM_E_INVALID_SYNTAX = 0x80041021, + WBEM_E_NONDECORATED_OBJECT = 0x80041022, + WBEM_E_READ_ONLY = 0x80041023, + WBEM_E_PROVIDER_NOT_CAPABLE = 0x80041024, + WBEM_E_CLASS_HAS_CHILDREN = 0x80041025, + WBEM_E_CLASS_HAS_INSTANCES = 0x80041026, + WBEM_E_QUERY_NOT_IMPLEMENTED = 0x80041027, + WBEM_E_ILLEGAL_NULL = 0x80041028, + WBEM_E_INVALID_QUALIFIER_TYPE = 0x80041029, + WBEM_E_INVALID_PROPERTY_TYPE = 0x8004102a, + WBEM_E_VALUE_OUT_OF_RANGE = 0x8004102b, + WBEM_E_CANNOT_BE_SINGLETON = 0x8004102c, + WBEM_E_INVALID_CIM_TYPE = 0x8004102d, + WBEM_E_INVALID_METHOD = 0x8004102e, + WBEM_E_INVALID_METHOD_PARAMETERS = 0x8004102f, + WBEM_E_SYSTEM_PROPERTY = 0x80041030, + WBEM_E_INVALID_PROPERTY = 0x80041031, + WBEM_E_CALL_CANCELLED = 0x80041032, + WBEM_E_SHUTTING_DOWN = 0x80041033, + WBEM_E_PROPAGATED_METHOD = 0x80041034, + WBEM_E_UNSUPPORTED_PARAMETER = 0x80041035, + WBEM_E_MISSING_PARAMETER_ID = 0x80041036, + WBEM_E_INVALID_PARAMETER_ID = 0x80041037, + WBEM_E_NONCONSECUTIVE_PARAMETER_IDS = 0x80041038, + WBEM_E_PARAMETER_ID_ON_RETVAL = 0x80041039, + WBEM_E_INVALID_OBJECT_PATH = 0x8004103a, + WBEM_E_OUT_OF_DISK_SPACE = 0x8004103b, + WBEM_E_BUFFER_TOO_SMALL = 0x8004103c, + WBEM_E_UNSUPPORTED_PUT_EXTENSION = 0x8004103d, + WBEM_E_UNKNOWN_OBJECT_TYPE = 0x8004103e, + WBEM_E_UNKNOWN_PACKET_TYPE = 0x8004103f, + WBEM_E_MARSHAL_VERSION_MISMATCH = 0x80041040, + WBEM_E_MARSHAL_INVALID_SIGNATURE = 0x80041041, + WBEM_E_INVALID_QUALIFIER = 0x80041042, + WBEM_E_INVALID_DUPLICATE_PARAMETER = 0x80041043, + WBEM_E_TOO_MUCH_DATA = 0x80041044, + WBEM_E_SERVER_TOO_BUSY = 0x80041045, + WBEM_E_INVALID_FLAVOR = 0x80041046, + WBEM_E_CIRCULAR_REFERENCE = 0x80041047, + WBEM_E_UNSUPPORTED_CLASS_UPDATE = 0x80041048, + WBEM_E_CANNOT_CHANGE_KEY_INHERITANCE = 0x80041049, + WBEM_E_CANNOT_CHANGE_INDEX_INHERITANCE = 0x80041050, + WBEM_E_TOO_MANY_PROPERTIES = 0x80041051, + WBEM_E_UPDATE_TYPE_MISMATCH = 0x80041052, + WBEM_E_UPDATE_OVERRIDE_NOT_ALLOWED = 0x80041053, + WBEM_E_UPDATE_PROPAGATED_METHOD = 0x80041054, + WBEM_E_METHOD_NOT_IMPLEMENTED = 0x80041055, + WBEM_E_METHOD_DISABLED = 0x80041056, + WBEM_E_REFRESHER_BUSY = 0x80041057, + WBEM_E_UNPARSABLE_QUERY = 0x80041058, + WBEM_E_NOT_EVENT_CLASS = 0x80041059, + WBEM_E_MISSING_GROUP_WITHIN = 0x8004105a, + WBEM_E_MISSING_AGGREGATION_LIST = 0x8004105b, + WBEM_E_PROPERTY_NOT_AN_OBJECT = 0x8004105c, + WBEM_E_AGGREGATING_BY_OBJECT = 0x8004105d, + WBEM_E_UNINTERPRETABLE_PROVIDER_QUERY = 0x8004105f, + WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING = 0x80041060, + WBEM_E_QUEUE_OVERFLOW = 0x80041061, + WBEM_E_PRIVILEGE_NOT_HELD = 0x80041062, + WBEM_E_INVALID_OPERATOR = 0x80041063, + WBEM_E_LOCAL_CREDENTIALS = 0x80041064, + WBEM_E_CANNOT_BE_ABSTRACT = 0x80041065, + WBEM_E_AMENDED_OBJECT = 0x80041066, + WBEM_E_CLIENT_TOO_SLOW = 0x80041067, + WBEM_E_NULL_SECURITY_DESCRIPTOR = 0x80041068, + WBEM_E_TIMED_OUT = 0x80041069, + WBEM_E_INVALID_ASSOCIATION = 0x8004106a, + WBEM_E_AMBIGUOUS_OPERATION = 0x8004106b, + WBEM_E_QUOTA_VIOLATION = 0x8004106c, + WBEM_E_RESERVED_001 = 0x8004106d, + WBEM_E_RESERVED_002 = 0x8004106e, + WBEM_E_UNSUPPORTED_LOCALE = 0x8004106f, + WBEM_E_HANDLE_OUT_OF_DATE = 0x80041070, + WBEM_E_CONNECTION_FAILED = 0x80041071, + WBEM_E_INVALID_HANDLE_REQUEST = 0x80041072, + WBEM_E_PROPERTY_NAME_TOO_WIDE = 0x80041073, + WBEM_E_CLASS_NAME_TOO_WIDE = 0x80041074, + WBEM_E_METHOD_NAME_TOO_WIDE = 0x80041075, + WBEM_E_QUALIFIER_NAME_TOO_WIDE = 0x80041076, + WBEM_E_RERUN_COMMAND = 0x80041077, + WBEM_E_DATABASE_VER_MISMATCH = 0x80041078, + WBEM_E_VETO_DELETE = 0x80041079, + WBEM_E_VETO_PUT = 0x8004107a, + WBEM_E_INVALID_LOCALE = 0x80041080, + WBEM_E_PROVIDER_SUSPENDED = 0x80041081, + WBEM_E_SYNCHRONIZATION_REQUIRED = 0x80041082, + WBEM_E_NO_SCHEMA = 0x80041083, + WBEM_E_PROVIDER_ALREADY_REGISTERED = 0x80041084, + WBEM_E_PROVIDER_NOT_REGISTERED = 0x80041085, + WBEM_E_FATAL_TRANSPORT_ERROR = 0x80041086, + WBEM_E_ENCRYPTED_CONNECTION_REQUIRED = 0x80041087, + WBEM_E_PROVIDER_TIMED_OUT = 0x80041088, + WBEM_E_NO_KEY = 0x80041089, + WBEM_E_PROVIDER_DISABLED = 0x8004108a, + WBEMESS_E_REGISTRATION_TOO_BROAD = 0x80042001, + WBEMESS_E_REGISTRATION_TOO_PRECISE = 0x80042002, + WBEMESS_E_AUTHZ_NOT_PRIVILEGED = 0x80042003, + WBEMMOF_E_EXPECTED_QUALIFIER_NAME = 0x80044001, + WBEMMOF_E_EXPECTED_SEMI = 0x80044002, + WBEMMOF_E_EXPECTED_OPEN_BRACE = 0x80044003, + WBEMMOF_E_EXPECTED_CLOSE_BRACE = 0x80044004, + WBEMMOF_E_EXPECTED_CLOSE_BRACKET = 0x80044005, + WBEMMOF_E_EXPECTED_CLOSE_PAREN = 0x80044006, + WBEMMOF_E_ILLEGAL_CONSTANT_VALUE = 0x80044007, + WBEMMOF_E_EXPECTED_TYPE_IDENTIFIER = 0x80044008, + WBEMMOF_E_EXPECTED_OPEN_PAREN = 0x80044009, + WBEMMOF_E_UNRECOGNIZED_TOKEN = 0x8004400a, + WBEMMOF_E_UNRECOGNIZED_TYPE = 0x8004400b, + WBEMMOF_E_EXPECTED_PROPERTY_NAME = 0x8004400c, + WBEMMOF_E_TYPEDEF_NOT_SUPPORTED = 0x8004400d, + WBEMMOF_E_UNEXPECTED_ALIAS = 0x8004400e, + WBEMMOF_E_UNEXPECTED_ARRAY_INIT = 0x8004400f, + WBEMMOF_E_INVALID_AMENDMENT_SYNTAX = 0x80044010, + WBEMMOF_E_INVALID_DUPLICATE_AMENDMENT = 0x80044011, + WBEMMOF_E_INVALID_PRAGMA = 0x80044012, + WBEMMOF_E_INVALID_NAMESPACE_SYNTAX = 0x80044013, + WBEMMOF_E_EXPECTED_CLASS_NAME = 0x80044014, + WBEMMOF_E_TYPE_MISMATCH = 0x80044015, + WBEMMOF_E_EXPECTED_ALIAS_NAME = 0x80044016, + WBEMMOF_E_INVALID_CLASS_DECLARATION = 0x80044017, + WBEMMOF_E_INVALID_INSTANCE_DECLARATION = 0x80044018, + WBEMMOF_E_EXPECTED_DOLLAR = 0x80044019, + WBEMMOF_E_CIMTYPE_QUALIFIER = 0x8004401a, + WBEMMOF_E_DUPLICATE_PROPERTY = 0x8004401b, + WBEMMOF_E_INVALID_NAMESPACE_SPECIFICATION = 0x8004401c, + WBEMMOF_E_OUT_OF_RANGE = 0x8004401d, + WBEMMOF_E_INVALID_FILE = 0x8004401e, + WBEMMOF_E_ALIASES_IN_EMBEDDED = 0x8004401f, + WBEMMOF_E_NULL_ARRAY_ELEM = 0x80044020, + WBEMMOF_E_DUPLICATE_QUALIFIER = 0x80044021, + WBEMMOF_E_EXPECTED_FLAVOR_TYPE = 0x80044022, + WBEMMOF_E_INCOMPATIBLE_FLAVOR_TYPES = 0x80044023, + WBEMMOF_E_MULTIPLE_ALIASES = 0x80044024, + WBEMMOF_E_INCOMPATIBLE_FLAVOR_TYPES2 = 0x80044025, + WBEMMOF_E_NO_ARRAYS_RETURNED = 0x80044026, + WBEMMOF_E_MUST_BE_IN_OR_OUT = 0x80044027, + WBEMMOF_E_INVALID_FLAGS_SYNTAX = 0x80044028, + WBEMMOF_E_EXPECTED_BRACE_OR_BAD_TYPE = 0x80044029, + WBEMMOF_E_UNSUPPORTED_CIMV22_QUAL_VALUE = 0x8004402a, + WBEMMOF_E_UNSUPPORTED_CIMV22_DATA_TYPE = 0x8004402b, + WBEMMOF_E_INVALID_DELETEINSTANCE_SYNTAX = 0x8004402c, + WBEMMOF_E_INVALID_QUALIFIER_SYNTAX = 0x8004402d, + WBEMMOF_E_QUALIFIER_USED_OUTSIDE_SCOPE = 0x8004402e, + WBEMMOF_E_ERROR_CREATING_TEMP_FILE = 0x8004402f, + WBEMMOF_E_ERROR_INVALID_INCLUDE_FILE = 0x80044030, + WBEMMOF_E_INVALID_DELETECLASS_SYNTAX = 0x80044031, +}} +// EXTERN_C const IID LIBID_WbemClient_v1; +// EXTERN_C const IID IID_IWbemClassObject; +DEFINE_GUID!{IID_IWbemClassObject, + 0xdc12a681, 0x737f, 0x11cf, 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24} +RIDL!{#[uuid(0xdc12a681, 0x737f, 0x11cf, 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24)] +interface IWbemClassObject(IWbemClassObjectVtbl): IUnknown(IUnknownVtbl) { + fn GetQualifierSet( + ppQualSet: *mut *mut IWbemQualifierSet, + ) -> HRESULT, + fn Get( + wszName: LPCWSTR, + lFlags: c_long, + pVal: *mut VARIANT, + pType: *mut CIMTYPE, + plFlavor: *mut c_long, + ) -> HRESULT, + fn Put( + wszName: LPCWSTR, + lFlags: c_long, + pVal: *mut VARIANT, + Type: CIMTYPE, + ) -> HRESULT, + fn Delete( + wszName: LPCWSTR, + ) -> HRESULT, + fn GetNames( + wszQualifierName: LPCWSTR, + lFlags: c_long, + pQualifierVal: *mut VARIANT, + pNames: *mut *mut SAFEARRAY, + ) -> HRESULT, + fn BeginEnumeration( + lEnumFlags: c_long, + ) -> HRESULT, + fn Next( + lFlags: c_long, + strName: *mut BSTR, + pVal: *mut VARIANT, + pType: *mut CIMTYPE, + plFlavor: *mut c_long, + ) -> HRESULT, + fn EndEnumeration() -> HRESULT, + fn GetPropertyQualifierSet( + wszProperty: LPCWSTR, + ppQualSet: *mut *mut IWbemQualifierSet, + ) -> HRESULT, + fn Clone( + ppCopy: *mut *mut IWbemClassObject, + ) -> HRESULT, + fn GetObjectText( + lFlags: c_long, + pstrObjectText: *mut BSTR, + ) -> HRESULT, + fn SpawnDerivedClass( + lFlags: c_long, + ppNewClass: *mut *mut IWbemClassObject, + ) -> HRESULT, + fn SpawnInstance( + lFlags: c_long, + ppNewInstance: *mut *mut IWbemClassObject, + ) -> HRESULT, + fn CompareTo( + lFlags: c_long, + pCompareTo: *mut IWbemClassObject, + ) -> HRESULT, + fn GetPropertyOrigin( + wszName: LPCWSTR, + pstrClassName: *mut BSTR, + ) -> HRESULT, + fn InheritsFrom( + strAncestor: LPCWSTR, + ) -> HRESULT, + fn GetMethod( + wszName: LPCWSTR, + lFlags: c_long, + ppInSignature: *mut *mut IWbemClassObject, + ppOutSignature: *mut *mut IWbemClassObject, + ) -> HRESULT, + fn PutMethod( + wszName: LPCWSTR, + lFlags: c_long, + pInSignature: *mut IWbemClassObject, + pOutSignature: *mut IWbemClassObject, + ) -> HRESULT, + fn DeleteMethod( + wszName: LPCWSTR, + ) -> HRESULT, + fn BeginMethodEnumeration( + lEnumFlags: c_long, + ) -> HRESULT, + fn NextMethod( + lFlags: c_long, + pstrName: *mut BSTR, + ppInSignature: *mut *mut IWbemClassObject, + ppOutSignature: *mut *mut IWbemClassObject, + ) -> HRESULT, + fn EndMethodEnumeration() -> HRESULT, + fn GetMethodQualifierSet( + wszMethod: LPCWSTR, + ppQualSet: *mut *mut IWbemQualifierSet, + ) -> HRESULT, + fn GetMethodOrigin( + wszMethodName: LPCWSTR, + pstrClassName: *mut BSTR, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemObjectAccess; +DEFINE_GUID!{IID_IWbemObjectAccess, + 0x49353c9a, 0x516b, 0x11d1, 0xae, 0xa6, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0x49353c9a, 0x516b, 0x11d1, 0xae, 0xa6, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IWbemObjectAccess(IWbemObjectAccessVtbl): IWbemClassObject(IWbemClassObjectVtbl) { + fn GetPropertyHandle( + wszPropertyName: LPCWSTR, + pType: *mut CIMTYPE, + plHandle: *mut c_long, + ) -> HRESULT, + fn WritePropertyValue( + lHandle: c_long, + lNumBytes: c_long, + aData: *const byte, + ) -> HRESULT, + fn ReadPropertyValue( + lHandle: c_long, + lBufferSize: c_long, + plNumBytes: *mut c_long, + aData: *mut byte, + ) -> HRESULT, + fn ReadDWORD( + lHandle: c_long, + pdw: *mut DWORD, + ) -> HRESULT, + fn WriteDWORD( + lHandle: c_long, + dw: DWORD, + ) -> HRESULT, + fn ReadQWORD( + lHandle: c_long, + pqw: *mut __uint64, + ) -> HRESULT, + fn WriteQWORD( + lHandle: c_long, + pw: __uint64, + ) -> HRESULT, + fn GetPropertyInfoByHandle( + lHandle: c_long, + pstrName: *mut BSTR, + pType: *mut CIMTYPE, + ) -> HRESULT, + fn Lock( + lFlags: c_long, + ) -> HRESULT, + fn Unlock( + lFlags: c_long, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemQualifierSet; +DEFINE_GUID!{IID_IWbemQualifierSet, + 0xdc12a680, 0x737f, 0x11cf, 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24} +RIDL!{#[uuid(0xdc12a680, 0x737f, 0x11cf, 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24)] +interface IWbemQualifierSet(IWbemQualifierSetVtbl): IUnknown(IUnknownVtbl) { + fn Get( + wszName: LPCWSTR, + lFlags: c_long, + pVal: *mut VARIANT, + plFlavor: *mut c_long, + ) -> HRESULT, + fn Put( + wszName: LPCWSTR, + pVal: *mut VARIANT, + lFlavor: c_long, + ) -> HRESULT, + fn Delete( + wszName: LPCWSTR, + ) -> HRESULT, + fn GetNames( + lFlags: c_long, + pNames: *mut *mut SAFEARRAY, + ) -> HRESULT, + fn BeginEnumeration( + lFlags: c_long, + ) -> HRESULT, + fn Next( + lFlags: c_long, + pstrName: *mut BSTR, + pVal: *mut VARIANT, + plFlavor: *mut c_long, + ) -> HRESULT, + fn EndEnumeration() -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemServices; +DEFINE_GUID!{IID_IWbemServices, + 0x9556dc99, 0x828c, 0x11cf, 0xa3, 0x7e, 0x00, 0xaa, 0x00, 0x32, 0x40, 0xc7} +RIDL!{#[uuid(0x9556dc99, 0x828c, 0x11cf, 0xa3, 0x7e, 0x00, 0xaa, 0x00, 0x32, 0x40, 0xc7)] +interface IWbemServices(IWbemServicesVtbl): IUnknown(IUnknownVtbl) { + fn OpenNamespace( + strNamespace: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppWorkingNamespace: *mut *mut IWbemServices, + ppResult: *mut *mut IWbemCallResult, + ) -> HRESULT, + fn CancelAsyncCall( + pSink: *mut IWbemObjectSink, + ) -> HRESULT, + fn QueryObjectSink( + lFlags: c_long, + ppResponseHandler: *mut *mut IWbemObjectSink, + ) -> HRESULT, + fn GetObject( + strObjectPath: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppObject: *mut *mut IWbemClassObject, + ppCallResult: *mut *mut IWbemCallResult, + ) -> HRESULT, + fn GetObjectAsync( + strObjectPath: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, + fn PutClass( + pObject: *mut IWbemClassObject, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppCallResult: *mut *mut IWbemCallResult, + ) -> HRESULT, + fn PutClassAsync( + pObject: *mut IWbemClassObject, + lFlags: c_long, + pCtx: *mut IWbemContext, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, + fn DeleteClass( + strClass: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppCallResult: *mut *mut IWbemCallResult, + ) -> HRESULT, + fn DeleteClassAsync( + strClass: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, + fn CreateClassEnum( + strSuperclass: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppEnum: *mut *mut IEnumWbemClassObject, + ) -> HRESULT, + fn CreateClassEnumAsync( + strSuperclass: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, + fn PutInstance( + pInst: *mut IWbemClassObject, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppCallResult: *mut *mut IWbemCallResult, + ) -> HRESULT, + fn PutInstanceAsync( + pInst: *mut IWbemClassObject, + lFlags: c_long, + pCtx: *mut IWbemContext, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, + fn DeleteInstance( + strObjectPath: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppCallResult: *mut *mut IWbemCallResult, + ) -> HRESULT, + fn DeleteInstanceAsync( + strObjectPath: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, + fn CreateInstanceEnum( + strFilter: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppEnum: *mut *mut IEnumWbemClassObject, + ) -> HRESULT, + fn CreateInstanceEnumAsync( + strFilter: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, + fn ExecQuery( + strQueryLanguage: BSTR, + strQuery: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppEnum: *mut *mut IEnumWbemClassObject, + ) -> HRESULT, + fn ExecQueryAsync( + strQueryLanguage: BSTR, + strQuery: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, + fn ExecNotificationQuery( + strQueryLanguage: BSTR, + strQuery: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppEnum: *mut *mut IEnumWbemClassObject, + ) -> HRESULT, + fn ExecNotificationQueryAsync( + strQueryLanguage: BSTR, + strQuery: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, + fn ExecMethod( + strObjectPath: BSTR, + strMethodName: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + pInParams: *mut IWbemClassObject, + ppOutParams: *mut *mut IWbemClassObject, + ppCallResult: *mut *mut IWbemCallResult, + ) -> HRESULT, + fn ExecMethodAsync( + strObjectPath: BSTR, + strMethodName: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + pInParams: *mut IWbemClassObject, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemLocator; +DEFINE_GUID!{IID_IWbemLocator, + 0xdc12a687, 0x737f, 0x11cf, 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24} +RIDL!{#[uuid(0xdc12a687, 0x737f, 0x11cf, 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24)] +interface IWbemLocator(IWbemLocatorVtbl): IUnknown(IUnknownVtbl) { + fn ConnectServer( + strNetworkResource: BSTR, + strUser: BSTR, + strPassword: BSTR, + strLocale: BSTR, + lSecurityFlags: c_long, + strAuthority: BSTR, + pCtx: *mut IWbemContext, + ppNamespace: *mut *mut IWbemServices, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemObjectSink; +DEFINE_GUID!{IID_IWbemObjectSink, + 0x7c857801, 0x7381, 0x11cf, 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24} +RIDL!{#[uuid(0x7c857801, 0x7381, 0x11cf, 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24)] +interface IWbemObjectSink(IWbemObjectSinkVtbl): IUnknown(IUnknownVtbl) { + fn Indicate( + lObjectCount: c_long, + apObjArray: *mut *mut IWbemClassObject, + ) -> HRESULT, + fn SetStatus( + lFlags: c_long, + hResult: HRESULT, + strParam: BSTR, + pObjParam: *mut IWbemClassObject, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IEnumWbemClassObject; +DEFINE_GUID!{IID_IEnumWbemClassObject, + 0x027947e1, 0xd731, 0x11ce, 0xa3, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} +RIDL!{#[uuid(0x027947e1, 0xd731, 0x11ce, 0xa3, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01)] +interface IEnumWbemClassObject(IEnumWbemClassObjectVtbl): IUnknown(IUnknownVtbl) { + fn Reset() -> HRESULT, + fn Next( + lTimeout: c_long, + uCount: ULONG, + apObjects: *mut *mut IWbemClassObject, + puReturned: *mut ULONG, + ) -> HRESULT, + fn NextAsync( + uCount: ULONG, + pSink: *mut IWbemObjectSink, + ) -> HRESULT, + fn Clone( + ppEnum: *mut *mut IEnumWbemClassObject, + ) -> HRESULT, + fn Skip( + lTimeout: c_long, + nCount: ULONG, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemCallResult; +DEFINE_GUID!{IID_IWbemCallResult, + 0x44aca675, 0xe8fc, 0x11d0, 0xa0, 0x7c, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0x44aca675, 0xe8fc, 0x11d0, 0xa0, 0x7c, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IWbemCallResult(IWbemCallResultVtbl): IUnknown(IUnknownVtbl) { + fn GetResultObject( + lTimeout: c_long, + ppResultObject: *mut *mut IWbemClassObject, + ) -> HRESULT, + fn GetResultString( + lTimeout: c_long, + pstrResultString: *mut BSTR, + ) -> HRESULT, + fn GetResultServices( + lTimeout: c_long, + ppServices: *mut *mut IWbemServices, + ) -> HRESULT, + fn GetCallStatus( + lTimeout: c_long, + plStatus: *mut c_long, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemContext; +DEFINE_GUID!{IID_IWbemContext, + 0x44aca674, 0xe8fc, 0x11d0, 0xa0, 0x7c, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0x44aca674, 0xe8fc, 0x11d0, 0xa0, 0x7c, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IWbemContext(IWbemContextVtbl): IUnknown(IUnknownVtbl) { + fn Clone( + ppNewCopy: *mut *mut IWbemContext, + ) -> HRESULT, + fn GetNames( + lFlags: c_long, + pNames: *mut *mut SAFEARRAY, + ) -> HRESULT, + fn BeginEnumeration( + lFlags: c_long, + ) -> HRESULT, + fn Next( + lFlags: c_long, + pstrName: *mut BSTR, + pValue: *mut VARIANT, + ) -> HRESULT, + fn EndEnumeration() -> HRESULT, + fn SetValue( + wszName: LPCWSTR, + lFlags: c_long, + pValue: *mut VARIANT, + ) -> HRESULT, + fn GetValue( + wszName: LPCWSTR, + lFlags: c_long, + pValue: *mut VARIANT, + ) -> HRESULT, + fn DeleteValue( + wszName: LPCWSTR, + lFlags: c_long, + ) -> HRESULT, + fn DeleteAll() -> HRESULT, +}} +// EXTERN_C const IID IID_IUnsecuredApartment; +DEFINE_GUID!{IID_IUnsecuredApartment, + 0x1cfaba8c, 0x1523, 0x11d1, 0xad, 0x79, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +RIDL!{#[uuid(0x1cfaba8c, 0x1523, 0x11d1, 0xad, 0x79, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff)] +interface IUnsecuredApartment(IUnsecuredApartmentVtbl): IUnknown(IUnknownVtbl) { + fn CreateObjectStub( + pObject: *mut IUnknown, + ppStub: *mut *mut IUnknown, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemUnsecuredApartment; +DEFINE_GUID!{IID_IWbemUnsecuredApartment, + 0x31739d04, 0x3471, 0x4cf4, 0x9a, 0x7c, 0x57, 0xa4, 0x4a, 0xe7, 0x19, 0x56} +RIDL!{#[uuid(0x31739d04, 0x3471, 0x4cf4, 0x9a, 0x7c, 0x57, 0xa4, 0x4a, 0xe7, 0x19, 0x56)] +interface IWbemUnsecuredApartment(IWbemUnsecuredApartmentVtbl): +IUnsecuredApartment(IUnsecuredApartmentVtbl) { + fn CreateSinkStub( + pSink: *mut IWbemObjectSink, + dwFlags: DWORD, + wszReserved: LPCWSTR, + ppStub: *mut *mut IWbemObjectSink, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemStatusCodeText; +DEFINE_GUID!{IID_IWbemStatusCodeText, + 0xeb87e1bc, 0x3233, 0x11d2, 0xae, 0xc9, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0xeb87e1bc, 0x3233, 0x11d2, 0xae, 0xc9, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IWbemStatusCodeText(IWbemStatusCodeTextVtbl): IUnknown(IUnknownVtbl) { + fn GetErrorCodeText( + hRes: HRESULT, + LocaleId: LCID, + lFlags: c_long, + MessageText: *mut BSTR, + ) -> HRESULT, + fn GetFacilityCodeText( + hRes: HRESULT, + LocaleId: LCID, + lFlags: c_long, + MessageText: *mut BSTR, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemBackupRestore; +DEFINE_GUID!{IID_IWbemBackupRestore, + 0xc49e32c7, 0xbc8b, 0x11d2, 0x85, 0xd4, 0x00, 0x10, 0x5a, 0x1f, 0x83, 0x04} +RIDL!{#[uuid(0xc49e32c7, 0xbc8b, 0x11d2, 0x85, 0xd4, 0x00, 0x10, 0x5a, 0x1f, 0x83, 0x04)] +interface IWbemBackupRestore(IWbemBackupRestoreVtbl): IUnknown(IUnknownVtbl) { + fn Backup( + strBackupToFile: LPCWSTR, + lFlags: c_long, + ) -> HRESULT, + fn Restore( + strRestoreFromFile: LPCWSTR, + lFlags: c_long, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemBackupRestoreEx; +DEFINE_GUID!{IID_IWbemBackupRestoreEx, + 0xa359dec5, 0xe813, 0x4834, 0x8a, 0x2a, 0xba, 0x7f, 0x1d, 0x77, 0x7d, 0x76} +RIDL!{#[uuid(0xa359dec5, 0xe813, 0x4834, 0x8a, 0x2a, 0xba, 0x7f, 0x1d, 0x77, 0x7d, 0x76)] +interface IWbemBackupRestoreEx(IWbemBackupRestoreExVtbl): +IWbemBackupRestore(IWbemBackupRestoreVtbl) { + fn Pause() -> HRESULT, + fn Resume() -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemRefresher; +DEFINE_GUID!{IID_IWbemRefresher, + 0x49353c99, 0x516b, 0x11d1, 0xae, 0xa6, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0x49353c99, 0x516b, 0x11d1, 0xae, 0xa6, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IWbemRefresher(IWbemRefresherVtbl): IUnknown(IUnknownVtbl) { + fn Refresh( + lFlags: c_long, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemHiPerfEnum; +DEFINE_GUID!{IID_IWbemHiPerfEnum, + 0x2705c288, 0x79ae, 0x11d2, 0xb3, 0x48, 0x00, 0x10, 0x5a, 0x1f, 0x81, 0x77} +RIDL!{#[uuid(0x2705c288, 0x79ae, 0x11d2, 0xb3, 0x48, 0x00, 0x10, 0x5a, 0x1f, 0x81, 0x77)] +interface IWbemHiPerfEnum(IWbemHiPerfEnumVtbl): IUnknown(IUnknownVtbl) { + fn AddObjects( + lFlags: c_long, + uNumObjects: ULONG, + apIds: *mut c_long, + apObj: *mut *mut IWbemObjectAccess, + ) -> HRESULT, + fn RemoveObjects( + lFlags: c_long, + uNumObjects: ULONG, + apIds: *mut c_long, + ) -> HRESULT, + fn GetObjects( + lFlags: c_long, + uNumObjects: ULONG, + apObj: *mut *mut IWbemObjectAccess, + puReturned: *mut ULONG, + ) -> HRESULT, + fn RemoveAll( + lFlags: c_long, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemConfigureRefresher; +DEFINE_GUID!{IID_IWbemConfigureRefresher, + 0x49353c92, 0x516b, 0x11d1, 0xae, 0xa6, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0x49353c92, 0x516b, 0x11d1, 0xae, 0xa6, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IWbemConfigureRefresher(IWbemConfigureRefresherVtbl): IUnknown(IUnknownVtbl) { + fn AddObjectByPath( + pNamespace: *mut IWbemServices, + wszPath: LPCWSTR, + lFlags: c_long, + pContext: *mut IWbemContext, + ppRefreshable: *mut *mut IWbemClassObject, + plId: *mut c_long, + ) -> HRESULT, + fn AddObjectByTemplate( + pNamespace: *mut IWbemServices, + pTemplate: *mut IWbemClassObject, + lFlags: c_long, + pContext: *mut IWbemContext, + ppRefreshable: *mut *mut IWbemClassObject, + plId: *mut c_long, + ) -> HRESULT, + fn AddRefresher( + pRefresher: *mut IWbemRefresher, + lFlags: c_long, + plId: *mut c_long, + ) -> HRESULT, + fn Remove( + lId: c_long, + lFlags: c_long, + ) -> HRESULT, + fn AddEnum( + pNamespace: *mut IWbemServices, + wszClassName: LPCWSTR, + lFlags: c_long, + pContext: *mut IWbemContext, + ppEnum: *mut *mut IWbemHiPerfEnum, + plId: *mut c_long, + ) -> HRESULT, +}} +DEFINE_GUID!{CLSID_WbemLocator, + 0x4590f811, 0x1d3a, 0x11d0, 0x89, 0x1f, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24} +RIDL!{#[uuid(0x4590f811, 0x1d3a, 0x11d0, 0x89, 0x1f, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24)] +class WbemLocator;} +DEFINE_GUID!{CLSID_WbemContext, + 0x674B6698, 0xEE92, 0x11d0, 0xAD, 0x71, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF} +// class DECLSPEC_UUID("674B6698-EE92-11d0-AD71-00C04FD8FDFF") +// WbemContext; +DEFINE_GUID!{CLSID_UnsecuredApartment, + 0x49bd2028, 0x1523, 0x11d1, 0xad, 0x79, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +// class DECLSPEC_UUID("49bd2028-1523-11d1-ad79-00c04fd8fdff") +// UnsecuredApartment; +DEFINE_GUID!{CLSID_WbemClassObject, + 0x9A653086, 0x174F, 0x11d2, 0xB5, 0xF9, 0x00, 0x10, 0x4B, 0x70, 0x3E, 0xFD} +// class DECLSPEC_UUID("9A653086-174F-11d2-B5F9-00104B703EFD") +// WbemClassObject; +DEFINE_GUID!{CLSID_MofCompiler, + 0x6daf9757, 0x2e37, 0x11d2, 0xae, 0xc9, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +// class DECLSPEC_UUID("6daf9757-2e37-11d2-aec9-00c04fb68820") +// MofCompiler; +DEFINE_GUID!{CLSID_WbemStatusCodeText, + 0xeb87e1bd, 0x3233, 0x11d2, 0xae, 0xc9, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +// class DECLSPEC_UUID("eb87e1bd-3233-11d2-aec9-00c04fb68820") +// WbemStatusCodeText; +DEFINE_GUID!{CLSID_WbemBackupRestore, + 0xC49E32C6, 0xBC8B, 0x11d2, 0x85, 0xD4, 0x00, 0x10, 0x5A, 0x1F, 0x83, 0x04} +// class DECLSPEC_UUID("C49E32C6-BC8B-11d2-85D4-00105A1F8304") +// WbemBackupRestore; +DEFINE_GUID!{CLSID_WbemRefresher, + 0xc71566f2, 0x561e, 0x11d1, 0xad, 0x87, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +// class DECLSPEC_UUID("c71566f2-561e-11d1-ad87-00c04fd8fdff") +// WbemRefresher; +DEFINE_GUID!{CLSID_WbemObjectTextSrc, + 0x8D1C559D, 0x84F0, 0x4bb3, 0xA7, 0xD5, 0x56, 0xA7, 0x43, 0x5A, 0x9B, 0xA6} +// class DECLSPEC_UUID("8D1C559D-84F0-4bb3-A7D5-56A7435A9BA6") +// WbemObjectTextSrc; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0001_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0001_v0_0_s_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0003_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0003_v0_0_s_ifspec; +// EXTERN_C const IID IID_IWbemObjectSinkEx; +DEFINE_GUID!{IID_IWbemObjectSinkEx, + 0xe7d35cfa, 0x348b, 0x485e, 0xb5, 0x24, 0x25, 0x27, 0x25, 0xd6, 0x97, 0xca} +RIDL!{#[uuid(0xe7d35cfa, 0x348b, 0x485e, 0xb5, 0x24, 0x25, 0x27, 0x25, 0xd6, 0x97, 0xca)] +interface IWbemObjectSinkEx(IWbemObjectSinkExVtbl): IWbemObjectSink(IWbemObjectSinkVtbl) { + fn WriteMessage( + uChannel: ULONG, + strMessage: BSTR, + ) -> HRESULT, + fn WriteError( + pObjError: *mut IWbemClassObject, + puReturned: *mut c_uchar, + ) -> HRESULT, + fn PromptUser( + strMessage: BSTR, + uPromptType: c_uchar, + puReturned: *mut c_uchar, + ) -> HRESULT, + fn WriteProgress( + strActivity: BSTR, + strCurrentOperation: BSTR, + strStatusDescription: BSTR, + uPercentComplete: ULONG, + uSecondsRemaining: ULONG, + ) -> HRESULT, + fn WriteStreamParameter( + strName: BSTR, + vtValue: *mut VARIANT, + ulType: ULONG, + ulFlags: ULONG, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemShutdown; +DEFINE_GUID!{IID_IWbemShutdown, + 0xb7b31df9, 0xd515, 0x11d3, 0xa1, 0x1c, 0x00, 0x10, 0x5a, 0x1f, 0x51, 0x5a} +RIDL!{#[uuid(0xb7b31df9, 0xd515, 0x11d3, 0xa1, 0x1c, 0x00, 0x10, 0x5a, 0x1f, 0x51, 0x5a)] +interface IWbemShutdown(IWbemShutdownVtbl): IUnknown(IUnknownVtbl) { + fn Shutdown( + uReason: LONG, + uMaxMilliseconds: ULONG, + pCtx: *mut IWbemContext, + ) -> HRESULT, +}} +ENUM!{enum WMI_OBJ_TEXT { + WMI_OBJ_TEXT_CIM_DTD_2_0 = 1, + WMI_OBJ_TEXT_WMI_DTD_2_0 = 2, + WMI_OBJ_TEXT_WMI_EXT1 = 3, + WMI_OBJ_TEXT_WMI_EXT2 = 4, + WMI_OBJ_TEXT_WMI_EXT3 = 5, + WMI_OBJ_TEXT_WMI_EXT4 = 6, + WMI_OBJ_TEXT_WMI_EXT5 = 7, + WMI_OBJ_TEXT_WMI_EXT6 = 8, + WMI_OBJ_TEXT_WMI_EXT7 = 9, + WMI_OBJ_TEXT_WMI_EXT8 = 10, + WMI_OBJ_TEXT_WMI_EXT9 = 11, + WMI_OBJ_TEXT_WMI_EXT10 = 12, + WMI_OBJ_TEXT_LAST = 13, +}} +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0011_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0011_v0_0_s_ifspec; +// EXTERN_C const IID IID_IWbemObjectTextSrc; +DEFINE_GUID!{IID_IWbemObjectTextSrc, + 0xbfbf883a, 0xcad7, 0x11d3, 0xa1, 0x1b, 0x00, 0x10, 0x5a, 0x1f, 0x51, 0x5a} +RIDL!{#[uuid(0xbfbf883a, 0xcad7, 0x11d3, 0xa1, 0x1b, 0x00, 0x10, 0x5a, 0x1f, 0x51, 0x5a)] +interface IWbemObjectTextSrc(IWbemObjectTextSrcVtbl): IUnknown(IUnknownVtbl) { + fn GetText( + lFlags: c_long, + pObj: *mut IWbemClassObject, + uObjTextFormat: ULONG, + pCtx: *mut IWbemContext, + strText: *mut BSTR, + ) -> HRESULT, + fn CreateFromText( + lFlags: c_long, + strText: BSTR, + uObjTextFormat: ULONG, + pCtx: *mut IWbemContext, + pNewObj: *mut *mut IWbemClassObject, + ) -> HRESULT, +}} +STRUCT!{struct WBEM_COMPILE_STATUS_INFO { + lPhaseError: c_long, + hRes: HRESULT, + ObjectNum: c_long, + FirstLine: c_long, + LastLine: c_long, + dwOutFlags: DWORD, +}} +ENUM!{enum WBEM_COMPILER_OPTIONS { + WBEM_FLAG_CHECK_ONLY = 0x1, + WBEM_FLAG_AUTORECOVER = 0x2, + WBEM_FLAG_WMI_CHECK = 0x4, + WBEM_FLAG_CONSOLE_PRINT = 0x8, + WBEM_FLAG_DONT_ADD_TO_LIST = 0x10, + WBEM_FLAG_SPLIT_FILES = 0x20, + WBEM_FLAG_STORE_FILE = 0x100, +}} +ENUM!{enum WBEM_CONNECT_OPTIONS { + WBEM_FLAG_CONNECT_REPOSITORY_ONLY = 0x40, + WBEM_FLAG_CONNECT_USE_MAX_WAIT = 0x80, + WBEM_FLAG_CONNECT_PROVIDERS = 0x100, +}} +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0013_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0013_v0_0_s_ifspec; +// EXTERN_C const IID IID_IMofCompiler; +DEFINE_GUID!{IID_IMofCompiler, + 0x6daf974e, 0x2e37, 0x11d2, 0xae, 0xc9, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0x6daf974e, 0x2e37, 0x11d2, 0xae, 0xc9, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IMofCompiler(IMofCompilerVtbl): IUnknown(IUnknownVtbl) { + fn CompileFile( + FileName: LPWSTR, + ServerAndNamespace: LPWSTR, + User: LPWSTR, + Authority: LPWSTR, + Password: LPWSTR, + lOptionFlags: LONG, + lClassFlags: LONG, + lInstanceFlags: LONG, + pInfo: *mut WBEM_COMPILE_STATUS_INFO, + ) -> HRESULT, + fn CompileBuffer( + BuffSize: c_long, + pBuffer: *mut BYTE, + ServerAndNamespace: LPWSTR, + User: LPWSTR, + Authority: LPWSTR, + Password: LPWSTR, + lOptionFlags: LONG, + lClassFlags: LONG, + lInstanceFlags: LONG, + pInfo: *mut WBEM_COMPILE_STATUS_INFO, + ) -> HRESULT, + fn CreateBMOF( + TextFileName: LPWSTR, + BMOFFileName: LPWSTR, + ServerAndNamespace: LPWSTR, + lOptionFlags: LONG, + lClassFlags: LONG, + lInstanceFlags: LONG, + pInfo: *mut WBEM_COMPILE_STATUS_INFO, + ) -> HRESULT, +}} +ENUM!{enum WBEM_UNSECAPP_FLAG_TYPE { + WBEM_FLAG_UNSECAPP_DEFAULT_CHECK_ACCESS = 0, + WBEM_FLAG_UNSECAPP_CHECK_ACCESS = 1, + WBEM_FLAG_UNSECAPP_DONT_CHECK_ACCESS = 2, +}} +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0015_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0015_v0_0_s_ifspec; +ENUM!{enum WBEM_INFORMATION_FLAG_TYPE { + WBEM_FLAG_SHORT_NAME = 0x1, + WBEM_FLAG_LONG_NAME = 0x2, +}} +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0016_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0016_v0_0_s_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0022_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemcli_0000_0022_v0_0_s_ifspec; +// unsigned c_long __RPC_USER BSTR_UserSize( __RPC__in unsigned c_long *, unsigned c_long , __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserMarshal( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserUnmarshal(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); +// void __RPC_USER BSTR_UserFree( __RPC__in unsigned c_long *, __RPC__in BSTR * ); +// unsigned c_long __RPC_USER VARIANT_UserSize( __RPC__in unsigned c_long *, unsigned c_long , __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserMarshal( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserUnmarshal(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out VARIANT * ); +// void __RPC_USER VARIANT_UserFree( __RPC__in unsigned c_long *, __RPC__in VARIANT * ); +// unsigned c_long __RPC_USER BSTR_UserSize64( __RPC__in unsigned c_long *, unsigned c_long , __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserMarshal64( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserUnmarshal64(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); +// void __RPC_USER BSTR_UserFree64( __RPC__in unsigned c_long *, __RPC__in BSTR * ); +// unsigned c_long __RPC_USER VARIANT_UserSize64( __RPC__in unsigned c_long *, unsigned c_long , __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserMarshal64( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserUnmarshal64(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out VARIANT * ); +// void __RPC_USER VARIANT_UserFree64( __RPC__in unsigned c_long *, __RPC__in VARIANT * ); diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemdisp.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemdisp.rs new file mode 100644 index 0000000..8e3ec77 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemdisp.rs @@ -0,0 +1,1344 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_long; +use shared::winerror::HRESULT; +use shared::wtypes::{BSTR, DATE, VARIANT_BOOL}; +use um::oaidl::{DISPID, IDispatch, IDispatchVtbl, VARIANT}; +use um::unknwnbase::IUnknown; +// extern RPC_IF_HANDLE __MIDL_itf_wbemdisp_0000_0000_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemdisp_0000_0000_v0_0_s_ifspec; +ENUM!{enum WbemChangeFlagEnum { + wbemChangeFlagCreateOrUpdate = 0, + wbemChangeFlagUpdateOnly = 0x1, + wbemChangeFlagCreateOnly = 0x2, + wbemChangeFlagUpdateCompatible = 0, + wbemChangeFlagUpdateSafeMode = 0x20, + wbemChangeFlagUpdateForceMode = 0x40, + wbemChangeFlagStrongValidation = 0x80, + wbemChangeFlagAdvisory = 0x10000, +}} +ENUM!{enum WbemFlagEnum { + wbemFlagReturnImmediately = 0x10, + wbemFlagReturnWhenComplete = 0, + wbemFlagBidirectional = 0, + wbemFlagForwardOnly = 0x20, + wbemFlagNoErrorObject = 0x40, + wbemFlagReturnErrorObject = 0, + wbemFlagSendStatus = 0x80, + wbemFlagDontSendStatus = 0, + wbemFlagEnsureLocatable = 0x100, + wbemFlagDirectRead = 0x200, + wbemFlagSendOnlySelected = 0, + wbemFlagUseAmendedQualifiers = 0x20000, + wbemFlagGetDefault = 0, + wbemFlagSpawnInstance = 0x1, + wbemFlagUseCurrentTime = 0x1, +}} +ENUM!{enum WbemQueryFlagEnum { + wbemQueryFlagDeep = 0, + wbemQueryFlagShallow = 1, + wbemQueryFlagPrototype = 2, +}} +ENUM!{enum WbemTextFlagEnum { + wbemTextFlagNoFlavors = 0x1, +}} +ENUM!{enum WbemTimeout { + wbemTimeoutInfinite = 0xffffffff, +}} +ENUM!{enum WbemComparisonFlagEnum { + wbemComparisonFlagIncludeAll = 0, + wbemComparisonFlagIgnoreQualifiers = 0x1, + wbemComparisonFlagIgnoreObjectSource = 0x2, + wbemComparisonFlagIgnoreDefaultValues = 0x4, + wbemComparisonFlagIgnoreClass = 0x8, + wbemComparisonFlagIgnoreCase = 0x10, + wbemComparisonFlagIgnoreFlavor = 0x20, +}} +ENUM!{enum WbemCimtypeEnum { + wbemCimtypeSint8 = 16, + wbemCimtypeUint8 = 17, + wbemCimtypeSint16 = 2, + wbemCimtypeUint16 = 18, + wbemCimtypeSint32 = 3, + wbemCimtypeUint32 = 19, + wbemCimtypeSint64 = 20, + wbemCimtypeUint64 = 21, + wbemCimtypeReal32 = 4, + wbemCimtypeReal64 = 5, + wbemCimtypeBoolean = 11, + wbemCimtypeString = 8, + wbemCimtypeDatetime = 101, + wbemCimtypeReference = 102, + wbemCimtypeChar16 = 103, + wbemCimtypeObject = 13, +}} +ENUM!{enum WbemErrorEnum { + wbemNoErr = 0, + wbemErrFailed = 0x80041001, + wbemErrNotFound = 0x80041002, + wbemErrAccessDenied = 0x80041003, + wbemErrProviderFailure = 0x80041004, + wbemErrTypeMismatch = 0x80041005, + wbemErrOutOfMemory = 0x80041006, + wbemErrInvalidContext = 0x80041007, + wbemErrInvalidParameter = 0x80041008, + wbemErrNotAvailable = 0x80041009, + wbemErrCriticalError = 0x8004100a, + wbemErrInvalidStream = 0x8004100b, + wbemErrNotSupported = 0x8004100c, + wbemErrInvalidSuperclass = 0x8004100d, + wbemErrInvalidNamespace = 0x8004100e, + wbemErrInvalidObject = 0x8004100f, + wbemErrInvalidClass = 0x80041010, + wbemErrProviderNotFound = 0x80041011, + wbemErrInvalidProviderRegistration = 0x80041012, + wbemErrProviderLoadFailure = 0x80041013, + wbemErrInitializationFailure = 0x80041014, + wbemErrTransportFailure = 0x80041015, + wbemErrInvalidOperation = 0x80041016, + wbemErrInvalidQuery = 0x80041017, + wbemErrInvalidQueryType = 0x80041018, + wbemErrAlreadyExists = 0x80041019, + wbemErrOverrideNotAllowed = 0x8004101a, + wbemErrPropagatedQualifier = 0x8004101b, + wbemErrPropagatedProperty = 0x8004101c, + wbemErrUnexpected = 0x8004101d, + wbemErrIllegalOperation = 0x8004101e, + wbemErrCannotBeKey = 0x8004101f, + wbemErrIncompleteClass = 0x80041020, + wbemErrInvalidSyntax = 0x80041021, + wbemErrNondecoratedObject = 0x80041022, + wbemErrReadOnly = 0x80041023, + wbemErrProviderNotCapable = 0x80041024, + wbemErrClassHasChildren = 0x80041025, + wbemErrClassHasInstances = 0x80041026, + wbemErrQueryNotImplemented = 0x80041027, + wbemErrIllegalNull = 0x80041028, + wbemErrInvalidQualifierType = 0x80041029, + wbemErrInvalidPropertyType = 0x8004102a, + wbemErrValueOutOfRange = 0x8004102b, + wbemErrCannotBeSingleton = 0x8004102c, + wbemErrInvalidCimType = 0x8004102d, + wbemErrInvalidMethod = 0x8004102e, + wbemErrInvalidMethodParameters = 0x8004102f, + wbemErrSystemProperty = 0x80041030, + wbemErrInvalidProperty = 0x80041031, + wbemErrCallCancelled = 0x80041032, + wbemErrShuttingDown = 0x80041033, + wbemErrPropagatedMethod = 0x80041034, + wbemErrUnsupportedParameter = 0x80041035, + wbemErrMissingParameter = 0x80041036, + wbemErrInvalidParameterId = 0x80041037, + wbemErrNonConsecutiveParameterIds = 0x80041038, + wbemErrParameterIdOnRetval = 0x80041039, + wbemErrInvalidObjectPath = 0x8004103a, + wbemErrOutOfDiskSpace = 0x8004103b, + wbemErrBufferTooSmall = 0x8004103c, + wbemErrUnsupportedPutExtension = 0x8004103d, + wbemErrUnknownObjectType = 0x8004103e, + wbemErrUnknownPacketType = 0x8004103f, + wbemErrMarshalVersionMismatch = 0x80041040, + wbemErrMarshalInvalidSignature = 0x80041041, + wbemErrInvalidQualifier = 0x80041042, + wbemErrInvalidDuplicateParameter = 0x80041043, + wbemErrTooMuchData = 0x80041044, + wbemErrServerTooBusy = 0x80041045, + wbemErrInvalidFlavor = 0x80041046, + wbemErrCircularReference = 0x80041047, + wbemErrUnsupportedClassUpdate = 0x80041048, + wbemErrCannotChangeKeyInheritance = 0x80041049, + wbemErrCannotChangeIndexInheritance = 0x80041050, + wbemErrTooManyProperties = 0x80041051, + wbemErrUpdateTypeMismatch = 0x80041052, + wbemErrUpdateOverrideNotAllowed = 0x80041053, + wbemErrUpdatePropagatedMethod = 0x80041054, + wbemErrMethodNotImplemented = 0x80041055, + wbemErrMethodDisabled = 0x80041056, + wbemErrRefresherBusy = 0x80041057, + wbemErrUnparsableQuery = 0x80041058, + wbemErrNotEventClass = 0x80041059, + wbemErrMissingGroupWithin = 0x8004105a, + wbemErrMissingAggregationList = 0x8004105b, + wbemErrPropertyNotAnObject = 0x8004105c, + wbemErrAggregatingByObject = 0x8004105d, + wbemErrUninterpretableProviderQuery = 0x8004105f, + wbemErrBackupRestoreWinmgmtRunning = 0x80041060, + wbemErrQueueOverflow = 0x80041061, + wbemErrPrivilegeNotHeld = 0x80041062, + wbemErrInvalidOperator = 0x80041063, + wbemErrLocalCredentials = 0x80041064, + wbemErrCannotBeAbstract = 0x80041065, + wbemErrAmendedObject = 0x80041066, + wbemErrClientTooSlow = 0x80041067, + wbemErrNullSecurityDescriptor = 0x80041068, + wbemErrTimeout = 0x80041069, + wbemErrInvalidAssociation = 0x8004106a, + wbemErrAmbiguousOperation = 0x8004106b, + wbemErrQuotaViolation = 0x8004106c, + wbemErrTransactionConflict = 0x8004106d, + wbemErrForcedRollback = 0x8004106e, + wbemErrUnsupportedLocale = 0x8004106f, + wbemErrHandleOutOfDate = 0x80041070, + wbemErrConnectionFailed = 0x80041071, + wbemErrInvalidHandleRequest = 0x80041072, + wbemErrPropertyNameTooWide = 0x80041073, + wbemErrClassNameTooWide = 0x80041074, + wbemErrMethodNameTooWide = 0x80041075, + wbemErrQualifierNameTooWide = 0x80041076, + wbemErrRerunCommand = 0x80041077, + wbemErrDatabaseVerMismatch = 0x80041078, + wbemErrVetoPut = 0x80041079, + wbemErrVetoDelete = 0x8004107a, + wbemErrInvalidLocale = 0x80041080, + wbemErrProviderSuspended = 0x80041081, + wbemErrSynchronizationRequired = 0x80041082, + wbemErrNoSchema = 0x80041083, + wbemErrProviderAlreadyRegistered = 0x80041084, + wbemErrProviderNotRegistered = 0x80041085, + wbemErrFatalTransportError = 0x80041086, + wbemErrEncryptedConnectionRequired = 0x80041087, + wbemErrRegistrationTooBroad = 0x80042001, + wbemErrRegistrationTooPrecise = 0x80042002, + wbemErrTimedout = 0x80043001, + wbemErrResetToDefault = 0x80043002, +}} +ENUM!{enum WbemAuthenticationLevelEnum { + wbemAuthenticationLevelDefault = 0, + wbemAuthenticationLevelNone = 1, + wbemAuthenticationLevelConnect = 2, + wbemAuthenticationLevelCall = 3, + wbemAuthenticationLevelPkt = 4, + wbemAuthenticationLevelPktIntegrity = 5, + wbemAuthenticationLevelPktPrivacy = 6, +}} +ENUM!{enum WbemImpersonationLevelEnum { + wbemImpersonationLevelAnonymous = 1, + wbemImpersonationLevelIdentify = 2, + wbemImpersonationLevelImpersonate = 3, + wbemImpersonationLevelDelegate = 4, +}} +ENUM!{enum WbemPrivilegeEnum { + wbemPrivilegeCreateToken = 1, + wbemPrivilegePrimaryToken = 2, + wbemPrivilegeLockMemory = 3, + wbemPrivilegeIncreaseQuota = 4, + wbemPrivilegeMachineAccount = 5, + wbemPrivilegeTcb = 6, + wbemPrivilegeSecurity = 7, + wbemPrivilegeTakeOwnership = 8, + wbemPrivilegeLoadDriver = 9, + wbemPrivilegeSystemProfile = 10, + wbemPrivilegeSystemtime = 11, + wbemPrivilegeProfileSingleProcess = 12, + wbemPrivilegeIncreaseBasePriority = 13, + wbemPrivilegeCreatePagefile = 14, + wbemPrivilegeCreatePermanent = 15, + wbemPrivilegeBackup = 16, + wbemPrivilegeRestore = 17, + wbemPrivilegeShutdown = 18, + wbemPrivilegeDebug = 19, + wbemPrivilegeAudit = 20, + wbemPrivilegeSystemEnvironment = 21, + wbemPrivilegeChangeNotify = 22, + wbemPrivilegeRemoteShutdown = 23, + wbemPrivilegeUndock = 24, + wbemPrivilegeSyncAgent = 25, + wbemPrivilegeEnableDelegation = 26, + wbemPrivilegeManageVolume = 27, +}} +ENUM!{enum WbemObjectTextFormatEnum { + wbemObjectTextFormatCIMDTD20 = 1, + wbemObjectTextFormatWMIDTD20 = 2, +}} +ENUM!{enum WbemConnectOptionsEnum { + wbemConnectFlagUseMaxWait = 0x80, +}} +// EXTERN_C const IID LIBID_WbemScripting; +// EXTERN_C const IID IID_ISWbemServices; +DEFINE_GUID!{IID_ISWbemServices, + 0x76a6415c, 0xcb41, 0x11d1, 0x8b, 0x02, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x76a6415c, 0xcb41, 0x11d1, 0x8b, 0x02, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemServices(ISWbemServicesVtbl): IDispatch(IDispatchVtbl) { + fn Get( + strObjectPath: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObject: *mut *mut ISWbemObject, + ) -> HRESULT, + fn GetAsync( + objWbemSink: *mut IDispatch, + strObjectPath: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn Delete( + strObjectPath: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + ) -> HRESULT, + fn DeleteAsync( + objWbemSink: *mut IDispatch, + strObjectPath: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn InstancesOf( + strClass: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectSet: *mut *mut ISWbemObjectSet, + ) -> HRESULT, + fn InstancesOfAsync( + objWbemSink: *mut IDispatch, + strClass: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn SubclassesOf( + strSuperclass: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectSet: *mut *mut ISWbemObjectSet, + ) -> HRESULT, + fn SubclassesOfAsync( + objWbemSink: *mut IDispatch, + strSuperclass: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn ExecQuery( + strQuery: BSTR, + strQueryLanguage: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectSet: *mut *mut ISWbemObjectSet, + ) -> HRESULT, + fn ExecQueryAsync( + objWbemSink: *mut IDispatch, + strQuery: BSTR, + strQueryLanguage: BSTR, + lFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn AssociatorsOf( + strObjectPath: BSTR, + strAssocClass: BSTR, + strResultClass: BSTR, + strResultRole: BSTR, + strRole: BSTR, + bClassesOnly: VARIANT_BOOL, + bSchemaOnly: VARIANT_BOOL, + strRequiredAssocQualifier: BSTR, + strRequiredQualifier: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectSet: *mut *mut ISWbemObjectSet, + ) -> HRESULT, + fn AssociatorsOfAsync( + objWbemSink: *mut IDispatch, + strObjectPath: BSTR, + strAssocClass: BSTR, + strResultClass: BSTR, + strResultRole: BSTR, + strRole: BSTR, + bClassesOnly: VARIANT_BOOL, + bSchemaOnly: VARIANT_BOOL, + strRequiredAssocQualifier: BSTR, + strRequiredQualifier: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn ReferencesTo( + strObjectPath: BSTR, + strResultClass: BSTR, + strRole: BSTR, + bClassesOnly: VARIANT_BOOL, + bSchemaOnly: VARIANT_BOOL, + strRequiredQualifier: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectSet: *mut *mut ISWbemObjectSet, + ) -> HRESULT, + fn ReferencesToAsync( + objWbemSink: *mut IDispatch, + strObjectPath: BSTR, + strResultClass: BSTR, + strRole: BSTR, + bClassesOnly: VARIANT_BOOL, + bSchemaOnly: VARIANT_BOOL, + strRequiredQualifier: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn ExecNotificationQuery( + strQuery: BSTR, + strQueryLanguage: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemEventSource: *mut *mut ISWbemEventSource, + ) -> HRESULT, + fn ExecNotificationQueryAsync( + objWbemSink: *mut IDispatch, + strQuery: BSTR, + strQueryLanguage: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn ExecMethod( + strObjectPath: BSTR, + strMethodName: BSTR, + objWbemInParameters: *mut IDispatch, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemOutParameters: *mut *mut ISWbemObject, + ) -> HRESULT, + fn ExecMethodAsync( + objWbemSink: *mut IDispatch, + strObjectPath: BSTR, + strMethodName: BSTR, + objWbemInParameters: *mut IDispatch, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn get_Security_( + objWbemSecurity: *mut *mut ISWbemSecurity, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemLocator; +DEFINE_GUID!{IID_ISWbemLocator, + 0x76a6415b, 0xcb41, 0x11d1, 0x8b, 0x02, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x76a6415b, 0xcb41, 0x11d1, 0x8b, 0x02, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemLocator(ISWbemLocatorVtbl): IDispatch(IDispatchVtbl) { + fn ConnectServer( + strServer: BSTR, + strNamespace: BSTR, + strUser: BSTR, + strPassword: BSTR, + strLocale: BSTR, + strAuthority: BSTR, + iSecurityFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemServices: *mut *mut ISWbemServices, + ) -> HRESULT, + fn get_Security_( + objWbemSecurity: *mut *mut ISWbemSecurity, + ) -> HRESULT, +}} +pub const WBEMS_DISPID_DERIVATION: DISPID = 23; +// EXTERN_C const IID IID_ISWbemObject; +DEFINE_GUID!{IID_ISWbemObject, + 0x76a6415a, 0xcb41, 0x11d1, 0x8b, 0x02, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x76a6415a, 0xcb41, 0x11d1, 0x8b, 0x02, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemObject(ISWbemObjectVtbl): IDispatch(IDispatchVtbl) { + fn Put_( + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectPath: *mut *mut ISWbemObjectPath, + ) -> HRESULT, + fn PutAsync_( + objWbemSink: *mut IDispatch, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn Delete_( + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + ) -> HRESULT, + fn DeleteAsync_( + objWbemSink: *mut IDispatch, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn Instances_( + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectSet: *mut *mut ISWbemObjectSet, + ) -> HRESULT, + fn InstancesAsync_( + objWbemSink: *mut IDispatch, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn Subclasses_( + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectSet: *mut *mut ISWbemObjectSet, + ) -> HRESULT, + fn SubclassesAsync_( + objWbemSink: *mut IDispatch, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn Associators_( + strAssocClass: BSTR, + strResultClass: BSTR, + strResultRole: BSTR, + strRole: BSTR, + bClassesOnly: VARIANT_BOOL, + bSchemaOnly: VARIANT_BOOL, + strRequiredAssocQualifier: BSTR, + strRequiredQualifier: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectSet: *mut *mut ISWbemObjectSet, + ) -> HRESULT, + fn AssociatorsAsync_( + objWbemSink: *mut IDispatch, + strAssocClass: BSTR, + strResultClass: BSTR, + strResultRole: BSTR, + strRole: BSTR, + bClassesOnly: VARIANT_BOOL, + bSchemaOnly: VARIANT_BOOL, + strRequiredAssocQualifier: BSTR, + strRequiredQualifier: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn References_( + strResultClass: BSTR, + strRole: BSTR, + bClassesOnly: VARIANT_BOOL, + bSchemaOnly: VARIANT_BOOL, + strRequiredQualifier: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectSet: *mut *mut ISWbemObjectSet, + ) -> HRESULT, + fn ReferencesAsync_( + objWbemSink: *mut IDispatch, + strResultClass: BSTR, + strRole: BSTR, + bClassesOnly: VARIANT_BOOL, + bSchemaOnly: VARIANT_BOOL, + strRequiredQualifier: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn ExecMethod_( + strMethodName: BSTR, + objWbemInParameters: *mut IDispatch, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemOutParameters: *mut *mut ISWbemObject, + ) -> HRESULT, + fn ExecMethodAsync_( + objWbemSink: *mut IDispatch, + strMethodName: BSTR, + objWbemInParameters: *mut IDispatch, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, + fn Clone_( + objWbemObject: *mut *mut ISWbemObject, + ) -> HRESULT, + fn GetObjectText_( + iFlags: c_long, + strObjectText: *mut BSTR, + ) -> HRESULT, + fn SpawnDerivedClass_( + iFlags: c_long, + objWbemObject: *mut *mut ISWbemObject, + ) -> HRESULT, + fn SpawnInstance_( + iFlags: c_long, + objWbemObject: *mut *mut ISWbemObject, + ) -> HRESULT, + fn CompareTo_( + objWbemObject: *mut IDispatch, + iFlags: c_long, + bResult: *mut VARIANT_BOOL, + ) -> HRESULT, + fn get_Qualifiers_( + objWbemQualifierSet: *mut *mut ISWbemQualifierSet, + ) -> HRESULT, + fn get_Properties_( + objWbemPropertySet: *mut *mut ISWbemPropertySet, + ) -> HRESULT, + fn get_Methods_( + objWbemMethodSet: *mut *mut ISWbemMethodSet, + ) -> HRESULT, + fn get_Derivation_( + strClassNameArray: *mut VARIANT, + ) -> HRESULT, + fn get_Path_( + objWbemObjectPath: *mut *mut ISWbemObjectPath, + ) -> HRESULT, + fn get_Security_( + objWbemSecurity: *mut *mut ISWbemSecurity, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemObjectSet; +DEFINE_GUID!{IID_ISWbemObjectSet, + 0x76a6415f, 0xcb41, 0x11d1, 0x8b, 0x02, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x76a6415f, 0xcb41, 0x11d1, 0x8b, 0x02, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemObjectSet(ISWbemObjectSetVtbl): IDispatch(IDispatchVtbl) { + fn get__NewEnum( + pUnk: *mut *mut IUnknown, + ) -> HRESULT, + fn Item( + strObjectPath: BSTR, + iFlags: c_long, + objWbemObject: *mut *mut ISWbemObject, + ) -> HRESULT, + fn get_Count( + iCount: *mut c_long, + ) -> HRESULT, + fn get_Security_( + objWbemSecurity: *mut *mut ISWbemSecurity, + ) -> HRESULT, + fn ItemIndex( + lIndex: c_long, + objWbemObject: *mut *mut ISWbemObject, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemNamedValue; +DEFINE_GUID!{IID_ISWbemNamedValue, + 0x76a64164, 0xcb41, 0x11d1, 0x8b, 0x02, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x76a64164, 0xcb41, 0x11d1, 0x8b, 0x02, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemNamedValue(ISWbemNamedValueVtbl): IDispatch(IDispatchVtbl) { + fn get_Value( + varValue: *mut VARIANT, + ) -> HRESULT, + fn put_Value( + varValue: *mut VARIANT, + ) -> HRESULT, + fn get_Name( + strName: *mut BSTR, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemNamedValueSet; +DEFINE_GUID!{IID_ISWbemNamedValueSet, + 0xcf2376ea, 0xce8c, 0x11d1, 0x8b, 0x05, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0xcf2376ea, 0xce8c, 0x11d1, 0x8b, 0x05, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemNamedValueSet(ISWbemNamedValueSetVtbl): IDispatch(IDispatchVtbl) { + fn get__NewEnum( + pUnk: *mut *mut IUnknown, + ) -> HRESULT, + fn Item( + strName: BSTR, + iFlags: c_long, + objWbemNamedValue: *mut *mut ISWbemNamedValue, + ) -> HRESULT, + fn get_Count( + iCount: *mut c_long, + ) -> HRESULT, + fn Add( + strName: BSTR, + varValue: *mut VARIANT, + iFlags: c_long, + objWbemNamedValue: *mut *mut ISWbemNamedValue, + ) -> HRESULT, + fn Remove( + strName: BSTR, + iFlags: c_long, + ) -> HRESULT, + fn Clone( + objWbemNamedValueSet: *mut *mut ISWbemNamedValueSet, + ) -> HRESULT, + fn DeleteAll() -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemQualifier; +DEFINE_GUID!{IID_ISWbemQualifier, + 0x79b05932, 0xd3b7, 0x11d1, 0x8b, 0x06, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x79b05932, 0xd3b7, 0x11d1, 0x8b, 0x06, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemQualifier(ISWbemQualifierVtbl): IDispatch(IDispatchVtbl) { + fn get_Value( + varValue: *mut VARIANT, + ) -> HRESULT, + fn put_Value( + varValue: *mut VARIANT, + ) -> HRESULT, + fn get_Name( + strName: *mut BSTR, + ) -> HRESULT, + fn get_IsLocal( + bIsLocal: *mut VARIANT_BOOL, + ) -> HRESULT, + fn get_PropagatesToSubclass( + bPropagatesToSubclass: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_PropagatesToSubclass( + bPropagatesToSubclass: VARIANT_BOOL, + ) -> HRESULT, + fn get_PropagatesToInstance( + bPropagatesToInstance: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_PropagatesToInstance( + bPropagatesToInstance: VARIANT_BOOL, + ) -> HRESULT, + fn get_IsOverridable( + bIsOverridable: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_IsOverridable( + bIsOverridable: VARIANT_BOOL, + ) -> HRESULT, + fn get_IsAmended( + bIsAmended: *mut VARIANT_BOOL, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemQualifierSet; +DEFINE_GUID!{IID_ISWbemQualifierSet, + 0x9b16ed16, 0xd3df, 0x11d1, 0x8b, 0x08, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x9b16ed16, 0xd3df, 0x11d1, 0x8b, 0x08, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemQualifierSet(ISWbemQualifierSetVtbl): IDispatch(IDispatchVtbl) { + fn get__NewEnum( + pUnk: *mut *mut IUnknown, + ) -> HRESULT, + fn Item( + name: BSTR, + iFlags: c_long, + objWbemQualifier: *mut *mut ISWbemQualifier, + ) -> HRESULT, + fn get_Count( + iCount: *mut c_long, + ) -> HRESULT, + fn Add( + strName: BSTR, + varVal: *mut VARIANT, + bPropagatesToSubclass: VARIANT_BOOL, + bPropagatesToInstance: VARIANT_BOOL, + bIsOverridable: VARIANT_BOOL, + iFlags: c_long, + objWbemQualifier: *mut *mut ISWbemQualifier, + ) -> HRESULT, + fn Remove( + strName: BSTR, + iFlags: c_long, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemProperty; +DEFINE_GUID!{IID_ISWbemProperty, + 0x1a388f98, 0xd4ba, 0x11d1, 0x8b, 0x09, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x1a388f98, 0xd4ba, 0x11d1, 0x8b, 0x09, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemProperty(ISWbemPropertyVtbl): IDispatch(IDispatchVtbl) { + fn get_Value( + varValue: *mut VARIANT, + ) -> HRESULT, + fn put_Value( + varValue: *mut VARIANT, + ) -> HRESULT, + fn get_Name( + strName: *mut BSTR, + ) -> HRESULT, + fn get_IsLocal( + bIsLocal: *mut VARIANT_BOOL, + ) -> HRESULT, + fn get_Origin( + strOrigin: *mut BSTR, + ) -> HRESULT, + fn get_CIMType( + iCimType: *mut WbemCimtypeEnum, + ) -> HRESULT, + fn get_Qualifiers_( + objWbemQualifierSet: *mut *mut ISWbemQualifierSet, + ) -> HRESULT, + fn get_IsArray( + bIsArray: *mut VARIANT_BOOL, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemPropertySet; +DEFINE_GUID!{IID_ISWbemPropertySet, + 0xdea0a7b2, 0xd4ba, 0x11d1, 0x8b, 0x09, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0xdea0a7b2, 0xd4ba, 0x11d1, 0x8b, 0x09, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemPropertySet(ISWbemPropertySetVtbl): IDispatch(IDispatchVtbl) { + fn get__NewEnum( + pUnk: *mut *mut IUnknown, + ) -> HRESULT, + fn Item( + strName: BSTR, + iFlags: c_long, + objWbemProperty: *mut *mut ISWbemProperty, + ) -> HRESULT, + fn get_Count( + iCount: *mut c_long, + ) -> HRESULT, + fn Add( + strName: BSTR, + iCIMType: WbemCimtypeEnum, + bIsArray: VARIANT_BOOL, + iFlags: c_long, + objWbemProperty: *mut *mut ISWbemProperty, + ) -> HRESULT, + fn Remove( + strName: BSTR, + iFlags: c_long, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemMethod; +DEFINE_GUID!{IID_ISWbemMethod, + 0x422e8e90, 0xd955, 0x11d1, 0x8b, 0x09, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x422e8e90, 0xd955, 0x11d1, 0x8b, 0x09, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemMethod(ISWbemMethodVtbl): IDispatch(IDispatchVtbl) { + fn get_Name( + strName: *mut BSTR, + ) -> HRESULT, + fn get_Origin( + strOrigin: *mut BSTR, + ) -> HRESULT, + fn get_InParameters( + objWbemInParameters: *mut *mut ISWbemObject, + ) -> HRESULT, + fn get_OutParameters( + objWbemOutParameters: *mut *mut ISWbemObject, + ) -> HRESULT, + fn get_Qualifiers_( + objWbemQualifierSet: *mut *mut ISWbemQualifierSet, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemMethodSet; +DEFINE_GUID!{IID_ISWbemMethodSet, + 0xc93ba292, 0xd955, 0x11d1, 0x8b, 0x09, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0xc93ba292, 0xd955, 0x11d1, 0x8b, 0x09, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemMethodSet(ISWbemMethodSetVtbl): IDispatch(IDispatchVtbl) { + fn get__NewEnum( + pUnk: *mut *mut IUnknown, + ) -> HRESULT, + fn Item( + strName: BSTR, + iFlags: c_long, + objWbemMethod: *mut *mut ISWbemMethod, + ) -> HRESULT, + fn get_Count( + iCount: *mut c_long, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemEventSource; +DEFINE_GUID!{IID_ISWbemEventSource, + 0x27d54d92, 0x0ebe, 0x11d2, 0x8b, 0x22, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x27d54d92, 0x0ebe, 0x11d2, 0x8b, 0x22, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemEventSource(ISWbemEventSourceVtbl): IDispatch(IDispatchVtbl) { + fn NextEvent( + iTimeoutMs: c_long, + objWbemObject: *mut *mut ISWbemObject, + ) -> HRESULT, + fn get_Security_( + objWbemSecurity: *mut *mut ISWbemSecurity, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemObjectPath; +DEFINE_GUID!{IID_ISWbemObjectPath, + 0x5791bc27, 0xce9c, 0x11d1, 0x97, 0xbf, 0x00, 0x00, 0xf8, 0x1e, 0x84, 0x9c} +RIDL!{#[uuid(0x5791bc27, 0xce9c, 0x11d1, 0x97, 0xbf, 0x00, 0x00, 0xf8, 0x1e, 0x84, 0x9c)] +interface ISWbemObjectPath(ISWbemObjectPathVtbl): IDispatch(IDispatchVtbl) { + fn get_Path( + strPath: *mut BSTR, + ) -> HRESULT, + fn put_Path( + strPath: BSTR, + ) -> HRESULT, + fn get_RelPath( + strRelPath: *mut BSTR, + ) -> HRESULT, + fn put_RelPath( + strRelPath: BSTR, + ) -> HRESULT, + fn get_Server( + strServer: *mut BSTR, + ) -> HRESULT, + fn put_Server( + strServer: BSTR, + ) -> HRESULT, + fn get_Namespace( + strNamespace: *mut BSTR, + ) -> HRESULT, + fn put_Namespace( + strNamespace: BSTR, + ) -> HRESULT, + fn get_ParentNamespace( + strParentNamespace: *mut BSTR, + ) -> HRESULT, + fn get_DisplayName( + strDisplayName: *mut BSTR, + ) -> HRESULT, + fn put_DisplayName( + strDisplayName: BSTR, + ) -> HRESULT, + fn get_Class( + strClass: *mut BSTR, + ) -> HRESULT, + fn put_Class( + strClass: BSTR, + ) -> HRESULT, + fn get_IsClass( + bIsClass: *mut VARIANT_BOOL, + ) -> HRESULT, + fn SetAsClass() -> HRESULT, + fn get_IsSingleton( + bIsSingleton: *mut VARIANT_BOOL, + ) -> HRESULT, + fn SetAsSingleton() -> HRESULT, + fn get_Keys( + objWbemNamedValueSet: *mut *mut ISWbemNamedValueSet, + ) -> HRESULT, + fn get_Security_( + objWbemSecurity: *mut *mut ISWbemSecurity, + ) -> HRESULT, + fn get_Locale( + strLocale: *mut BSTR, + ) -> HRESULT, + fn put_Locale( + strLocale: BSTR, + ) -> HRESULT, + fn get_Authority( + strAuthority: *mut BSTR, + ) -> HRESULT, + fn put_Authority( + strAuthority: BSTR, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemLastError; +DEFINE_GUID!{IID_ISWbemLastError, + 0xd962db84, 0xd4bb, 0x11d1, 0x8b, 0x09, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0xd962db84, 0xd4bb, 0x11d1, 0x8b, 0x09, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemLastError(ISWbemLastErrorVtbl): ISWbemObject(ISWbemObjectVtbl) {}} +// EXTERN_C const IID DIID_ISWbemSinkEvents; +DEFINE_GUID!{IID_ISWbemSinkEvents, + 0x75718ca0, 0xf029, 0x11d1, 0xa1, 0xac, 0x00, 0xc0, 0x4f, 0xb6, 0xc2, 0x23} +RIDL!{#[uuid(0x75718ca0, 0xf029, 0x11d1, 0xa1, 0xac, 0x00, 0xc0, 0x4f, 0xb6, 0xc2, 0x23)] +interface ISWbemSinkEvents(ISWbemSinkEventsVtbl): IDispatch(IDispatchVtbl) {}} +// EXTERN_C const IID IID_ISWbemSink; +DEFINE_GUID!{IID_ISWbemSink, + 0x75718c9f, 0xf029, 0x11d1, 0xa1, 0xac, 0x00, 0xc0, 0x4f, 0xb6, 0xc2, 0x23} +RIDL!{#[uuid(0x75718c9f, 0xf029, 0x11d1, 0xa1, 0xac, 0x00, 0xc0, 0x4f, 0xb6, 0xc2, 0x23)] +interface ISWbemSink(ISWbemSinkVtbl): IDispatch(IDispatchVtbl) { + fn Cancel() -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemSecurity; +DEFINE_GUID!{IID_ISWbemSecurity, + 0xb54d66e6, 0x2287, 0x11d2, 0x8b, 0x33, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0xb54d66e6, 0x2287, 0x11d2, 0x8b, 0x33, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemSecurity(ISWbemSecurityVtbl): IDispatch(IDispatchVtbl) { + fn get_ImpersonationLevel( + iImpersonationLevel: *mut WbemImpersonationLevelEnum, + ) -> HRESULT, + fn put_ImpersonationLevel( + iImpersonationLevel: WbemImpersonationLevelEnum, + ) -> HRESULT, + fn get_AuthenticationLevel( + iAuthenticationLevel: *mut WbemAuthenticationLevelEnum, + ) -> HRESULT, + fn put_AuthenticationLevel( + iAuthenticationLevel: WbemAuthenticationLevelEnum, + ) -> HRESULT, + fn get_Privileges( + objWbemPrivilegeSet: *mut *mut ISWbemPrivilegeSet, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemPrivilege; +DEFINE_GUID!{IID_ISWbemPrivilege, + 0x26ee67bd, 0x5804, 0x11d2, 0x8b, 0x4a, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x26ee67bd, 0x5804, 0x11d2, 0x8b, 0x4a, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemPrivilege(ISWbemPrivilegeVtbl): IDispatch(IDispatchVtbl) { + fn get_IsEnabled( + bIsEnabled: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_IsEnabled( + bIsEnabled: VARIANT_BOOL, + ) -> HRESULT, + fn get_Name( + strDisplayName: *mut BSTR, + ) -> HRESULT, + fn get_DisplayName( + strDisplayName: *mut BSTR, + ) -> HRESULT, + fn get_Identifier( + iPrivilege: *mut WbemPrivilegeEnum, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemPrivilegeSet; +DEFINE_GUID!{IID_ISWbemPrivilegeSet, + 0x26ee67bf, 0x5804, 0x11d2, 0x8b, 0x4a, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6} +RIDL!{#[uuid(0x26ee67bf, 0x5804, 0x11d2, 0x8b, 0x4a, 0x00, 0x60, 0x08, 0x06, 0xd9, 0xb6)] +interface ISWbemPrivilegeSet(ISWbemPrivilegeSetVtbl): IDispatch(IDispatchVtbl) { + fn get__NewEnum( + pUnk: *mut *mut IUnknown, + ) -> HRESULT, + fn Item( + iPrivilege: WbemPrivilegeEnum, + objWbemPrivilege: *mut *mut ISWbemPrivilege, + ) -> HRESULT, + fn get_Count( + iCount: *mut c_long, + ) -> HRESULT, + fn Add( + iPrivilege: WbemPrivilegeEnum, + bIsEnabled: VARIANT_BOOL, + objWbemPrivilege: *mut *mut ISWbemPrivilege, + ) -> HRESULT, + fn Remove( + iPrivilege: WbemPrivilegeEnum, + ) -> HRESULT, + fn DeleteAll() -> HRESULT, + fn AddAsString( + strPrivilege: BSTR, + bIsEnabled: VARIANT_BOOL, + objWbemPrivilege: *mut *mut ISWbemPrivilege, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemServicesEx; +DEFINE_GUID!{IID_ISWbemServicesEx, + 0xd2f68443, 0x85dc, 0x427e, 0x91, 0xd8, 0x36, 0x65, 0x54, 0xcc, 0x75, 0x4c} +RIDL!{#[uuid(0xd2f68443, 0x85dc, 0x427e, 0x91, 0xd8, 0x36, 0x65, 0x54, 0xcc, 0x75, 0x4c)] +interface ISWbemServicesEx(ISWbemServicesExVtbl): ISWbemServices(ISWbemServicesVtbl) { + fn Put( + objWbemObject: *mut ISWbemObjectEx, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemObjectPath: *mut *mut ISWbemObjectPath, + ) -> HRESULT, + fn PutAsync( + objWbemSink: *mut ISWbemSink, + objWbemObject: *mut ISWbemObjectEx, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemAsyncContext: *mut IDispatch, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemObjectEx; +DEFINE_GUID!{IID_ISWbemObjectEx, + 0x269ad56a, 0x8a67, 0x4129, 0xbc, 0x8c, 0x05, 0x06, 0xdc, 0xfe, 0x98, 0x80} +RIDL!{#[uuid(0x269ad56a, 0x8a67, 0x4129, 0xbc, 0x8c, 0x05, 0x06, 0xdc, 0xfe, 0x98, 0x80)] +interface ISWbemObjectEx(ISWbemObjectExVtbl): ISWbemObject(ISWbemObjectVtbl) { + fn Refresh_( + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + ) -> HRESULT, + fn get_SystemProperties_( + objWbemPropertySet: *mut *mut ISWbemPropertySet, + ) -> HRESULT, + fn GetText_( + iObjectTextFormat: WbemObjectTextFormatEnum, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + bsText: *mut BSTR, + ) -> HRESULT, + fn SetFromText_( + bsText: BSTR, + iObjectTextFormat: WbemObjectTextFormatEnum, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemDateTime; +DEFINE_GUID!{IID_ISWbemDateTime, + 0x5e97458a, 0xcf77, 0x11d3, 0xb3, 0x8f, 0x00, 0x10, 0x5a, 0x1f, 0x47, 0x3a} +RIDL!{#[uuid(0x5e97458a, 0xcf77, 0x11d3, 0xb3, 0x8f, 0x00, 0x10, 0x5a, 0x1f, 0x47, 0x3a)] +interface ISWbemDateTime(ISWbemDateTimeVtbl): IDispatch(IDispatchVtbl) { + fn get_Value( + strValue: *mut BSTR, + ) -> HRESULT, + fn put_Value( + strValue: BSTR, + ) -> HRESULT, + fn get_Year( + iYear: *mut c_long, + ) -> HRESULT, + fn put_Year( + iYear: c_long, + ) -> HRESULT, + fn get_YearSpecified( + bYearSpecified: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_YearSpecified( + bYearSpecified: VARIANT_BOOL, + ) -> HRESULT, + fn get_Month( + iMonth: *mut c_long, + ) -> HRESULT, + fn put_Month( + iMonth: c_long, + ) -> HRESULT, + fn get_MonthSpecified( + bMonthSpecified: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_MonthSpecified( + bMonthSpecified: VARIANT_BOOL, + ) -> HRESULT, + fn get_Day( + iDay: *mut c_long, + ) -> HRESULT, + fn put_Day( + iDay: c_long, + ) -> HRESULT, + fn get_DaySpecified( + bDaySpecified: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_DaySpecified( + bDaySpecified: VARIANT_BOOL, + ) -> HRESULT, + fn get_Hours( + iHours: *mut c_long, + ) -> HRESULT, + fn put_Hours( + iHours: c_long, + ) -> HRESULT, + fn get_HoursSpecified( + bHoursSpecified: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_HoursSpecified( + bHoursSpecified: VARIANT_BOOL, + ) -> HRESULT, + fn get_Minutes( + iMinutes: *mut c_long, + ) -> HRESULT, + fn put_Minutes( + iMinutes: c_long, + ) -> HRESULT, + fn get_MinutesSpecified( + bMinutesSpecified: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_MinutesSpecified( + bMinutesSpecified: VARIANT_BOOL, + ) -> HRESULT, + fn get_Seconds( + iSeconds: *mut c_long, + ) -> HRESULT, + fn put_Seconds( + iSeconds: c_long, + ) -> HRESULT, + fn get_SecondsSpecified( + bSecondsSpecified: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_SecondsSpecified( + bSecondsSpecified: VARIANT_BOOL, + ) -> HRESULT, + fn get_Microseconds( + iMicroseconds: *mut c_long, + ) -> HRESULT, + fn put_Microseconds( + iMicroseconds: c_long, + ) -> HRESULT, + fn get_MicrosecondsSpecified( + bMicrosecondsSpecified: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_MicrosecondsSpecified( + bMicrosecondsSpecified: VARIANT_BOOL, + ) -> HRESULT, + fn get_UTC( + iUTC: *mut c_long, + ) -> HRESULT, + fn put_UTC( + iUTC: c_long, + ) -> HRESULT, + fn get_UTCSpecified( + bUTCSpecified: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_UTCSpecified( + bUTCSpecified: VARIANT_BOOL, + ) -> HRESULT, + fn get_IsInterval( + bIsInterval: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_IsInterval( + bIsInterval: VARIANT_BOOL, + ) -> HRESULT, + fn GetVarDate( + bIsLocal: VARIANT_BOOL, + dVarDate: *mut DATE, + ) -> HRESULT, + fn SetVarDate( + dVarDate: DATE, + bIsLocal: VARIANT_BOOL, + ) -> HRESULT, + fn GetFileTime( + bIsLocal: VARIANT_BOOL, + strFileTime: *mut BSTR, + ) -> HRESULT, + fn SetFileTime( + strFileTime: BSTR, + bIsLocal: VARIANT_BOOL, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemRefresher; +DEFINE_GUID!{IID_ISWbemRefresher, + 0x14d8250e, 0xd9c2, 0x11d3, 0xb3, 0x8f, 0x00, 0x10, 0x5a, 0x1f, 0x47, 0x3a} +RIDL!{#[uuid(0x14d8250e, 0xd9c2, 0x11d3, 0xb3, 0x8f, 0x00, 0x10, 0x5a, 0x1f, 0x47, 0x3a)] +interface ISWbemRefresher(ISWbemRefresherVtbl): IDispatch(IDispatchVtbl) { + fn get__NewEnum( + pUnk: *mut *mut IUnknown, + ) -> HRESULT, + fn Item( + iIndex: c_long, + objWbemRefreshableItem: *mut *mut ISWbemRefreshableItem, + ) -> HRESULT, + fn get_Count( + iCount: *mut c_long, + ) -> HRESULT, + fn Add( + objWbemServices: *mut ISWbemServicesEx, + bsInstancePath: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemRefreshableItem: *mut *mut ISWbemRefreshableItem, + ) -> HRESULT, + fn AddEnum( + objWbemServices: *mut ISWbemServicesEx, + bsClassName: BSTR, + iFlags: c_long, + objWbemNamedValueSet: *mut IDispatch, + objWbemRefreshableItem: *mut *mut ISWbemRefreshableItem, + ) -> HRESULT, + fn Remove( + iIndex: c_long, + iFlags: c_long, + ) -> HRESULT, + fn Refresh( + iFlags: c_long, + ) -> HRESULT, + fn get_AutoReconnect( + bCount: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_AutoReconnect( + bCount: VARIANT_BOOL, + ) -> HRESULT, + fn DeleteAll() -> HRESULT, +}} +// EXTERN_C const IID IID_ISWbemRefreshableItem; +DEFINE_GUID!{IID_ISWbemRefreshableItem, + 0x5ad4bf92, 0xdaab, 0x11d3, 0xb3, 0x8f, 0x00, 0x10, 0x5a, 0x1f, 0x47, 0x3a} +RIDL!{#[uuid(0x5ad4bf92, 0xdaab, 0x11d3, 0xb3, 0x8f, 0x00, 0x10, 0x5a, 0x1f, 0x47, 0x3a)] +interface ISWbemRefreshableItem(ISWbemRefreshableItemVtbl): IDispatch(IDispatchVtbl) { + fn get_Index( + iIndex: *mut c_long, + ) -> HRESULT, + fn get_Refresher( + objWbemRefresher: *mut *mut ISWbemRefresher, + ) -> HRESULT, + fn get_IsSet( + bIsSet: *mut VARIANT_BOOL, + ) -> HRESULT, + fn get_Object( + objWbemObject: *mut *mut ISWbemObjectEx, + ) -> HRESULT, + fn get_ObjectSet( + objWbemObjectSet: *mut *mut ISWbemObjectSet, + ) -> HRESULT, + fn Remove( + iFlags: c_long, + ) -> HRESULT, +}} +DEFINE_GUID!{CLSID_SWbemLocator, + 0x76A64158, 0xCB41, 0x11d1, 0x8B, 0x02, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("76A64158-CB41-11d1-8B02-00600806D9B6") +// SWbemLocator; +DEFINE_GUID!{CLSID_SWbemNamedValueSet, + 0x9AED384E, 0xCE8B, 0x11d1, 0x8B, 0x05, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("9AED384E-CE8B-11d1-8B05-00600806D9B6") +// SWbemNamedValueSet; +DEFINE_GUID!{CLSID_SWbemObjectPath, + 0x5791BC26, 0xCE9C, 0x11d1, 0x97, 0xBF, 0x00, 0x00, 0xF8, 0x1E, 0x84, 0x9C} +// class DECLSPEC_UUID("5791BC26-CE9C-11d1-97BF-0000F81E849C") +// SWbemObjectPath; +DEFINE_GUID!{CLSID_SWbemLastError, + 0xC2FEEEAC, 0xCFCD, 0x11d1, 0x8B, 0x05, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("C2FEEEAC-CFCD-11d1-8B05-00600806D9B6") +// SWbemLastError; +DEFINE_GUID!{CLSID_SWbemSink, + 0x75718C9A, 0xF029, 0x11d1, 0xA1, 0xAC, 0x00, 0xC0, 0x4F, 0xB6, 0xC2, 0x23} +// class DECLSPEC_UUID("75718C9A-F029-11d1-A1AC-00C04FB6C223") +// SWbemSink; +DEFINE_GUID!{CLSID_SWbemDateTime, + 0x47DFBE54, 0xCF76, 0x11d3, 0xB3, 0x8F, 0x00, 0x10, 0x5A, 0x1F, 0x47, 0x3A} +// class DECLSPEC_UUID("47DFBE54-CF76-11d3-B38F-00105A1F473A") +// SWbemDateTime; +DEFINE_GUID!{CLSID_SWbemRefresher, + 0xD269BF5C, 0xD9C1, 0x11d3, 0xB3, 0x8F, 0x00, 0x10, 0x5A, 0x1F, 0x47, 0x3A} +// class DECLSPEC_UUID("D269BF5C-D9C1-11d3-B38F-00105A1F473A") +// SWbemRefresher; +DEFINE_GUID!{CLSID_SWbemServices, + 0x04B83D63, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D63-21AE-11d2-8B33-00600806D9B6") +// SWbemServices; +DEFINE_GUID!{CLSID_SWbemServicesEx, + 0x62E522DC, 0x8CF3, 0x40a8, 0x8B, 0x2E, 0x37, 0xD5, 0x95, 0x65, 0x1E, 0x40} +// class DECLSPEC_UUID("62E522DC-8CF3-40a8-8B2E-37D595651E40") +// SWbemServicesEx; +DEFINE_GUID!{CLSID_SWbemObject, + 0x04B83D62, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D62-21AE-11d2-8B33-00600806D9B6") +// SWbemObject; +DEFINE_GUID!{CLSID_SWbemObjectEx, + 0xD6BDAFB2, 0x9435, 0x491f, 0xBB, 0x87, 0x6A, 0xA0, 0xF0, 0xBC, 0x31, 0xA2} +// class DECLSPEC_UUID("D6BDAFB2-9435-491f-BB87-6AA0F0BC31A2") +// SWbemObjectEx; +DEFINE_GUID!{CLSID_SWbemObjectSet, + 0x04B83D61, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D61-21AE-11d2-8B33-00600806D9B6") +// SWbemObjectSet; +DEFINE_GUID!{CLSID_SWbemNamedValue, + 0x04B83D60, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D60-21AE-11d2-8B33-00600806D9B6") +// SWbemNamedValue; +DEFINE_GUID!{CLSID_SWbemQualifier, + 0x04B83D5F, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D5F-21AE-11d2-8B33-00600806D9B6") +// SWbemQualifier; +DEFINE_GUID!{CLSID_SWbemQualifierSet, + 0x04B83D5E, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D5E-21AE-11d2-8B33-00600806D9B6") +// SWbemQualifierSet; +DEFINE_GUID!{CLSID_SWbemProperty, + 0x04B83D5D, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D5D-21AE-11d2-8B33-00600806D9B6") +// SWbemProperty; +DEFINE_GUID!{CLSID_SWbemPropertySet, + 0x04B83D5C, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D5C-21AE-11d2-8B33-00600806D9B6") +// SWbemPropertySet; +DEFINE_GUID!{CLSID_SWbemMethod, + 0x04B83D5B, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D5B-21AE-11d2-8B33-00600806D9B6") +// SWbemMethod; +DEFINE_GUID!{CLSID_SWbemMethodSet, + 0x04B83D5A, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D5A-21AE-11d2-8B33-00600806D9B6") +// SWbemMethodSet; +DEFINE_GUID!{CLSID_SWbemEventSource, + 0x04B83D58, 0x21AE, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("04B83D58-21AE-11d2-8B33-00600806D9B6") +// SWbemEventSource; +DEFINE_GUID!{CLSID_SWbemSecurity, + 0xB54D66E9, 0x2287, 0x11d2, 0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("B54D66E9-2287-11d2-8B33-00600806D9B6") +// SWbemSecurity; +DEFINE_GUID!{CLSID_SWbemPrivilege, + 0x26EE67BC, 0x5804, 0x11d2, 0x8B, 0x4A, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("26EE67BC-5804-11d2-8B4A-00600806D9B6") +// SWbemPrivilege; +DEFINE_GUID!{CLSID_SWbemPrivilegeSet, + 0x26EE67BE, 0x5804, 0x11d2, 0x8B, 0x4A, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6} +// class DECLSPEC_UUID("26EE67BE-5804-11d2-8B4A-00600806D9B6") +// SWbemPrivilegeSet; +DEFINE_GUID!{CLSID_SWbemRefreshableItem, + 0x8C6854BC, 0xDE4B, 0x11d3, 0xB3, 0x90, 0x00, 0x10, 0x5A, 0x1F, 0x47, 0x3A} +// class DECLSPEC_UUID("8C6854BC-DE4B-11d3-B390-00105A1F473A") +// SWbemRefreshableItem; +pub const WBEMS_DISPID_OBJECT_READY: DISPID = 1; +pub const WBEMS_DISPID_COMPLETED: DISPID = 2; +pub const WBEMS_DISPID_PROGRESS: DISPID = 3; +pub const WBEMS_DISPID_OBJECT_PUT: DISPID = 4; +pub const WBEMS_DISPID_CONNECTION_READY: DISPID = 5; +// extern RPC_IF_HANDLE __MIDL_itf_wbemdisp_0000_0018_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemdisp_0000_0018_v0_0_s_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemdisp_0000_0026_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemdisp_0000_0026_v0_0_s_ifspec; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemprov.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemprov.rs new file mode 100644 index 0000000..4ba60ee --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemprov.rs @@ -0,0 +1,302 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_long, c_ulong}; +use shared::minwindef::{BYTE, DWORD}; +use shared::winerror::HRESULT; +use shared::wtypes::BSTR; +use um::oaidl::{VARIANT}; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::wbemcli::{ + IWbemClassObject, IWbemContext, IWbemHiPerfEnum, IWbemObjectAccess, IWbemObjectSink, + IWbemObjectSinkVtbl, IWbemRefresher, IWbemServices +}; +use um::winnt::{LONG, LPCWSTR, LPWSTR, WCHAR}; +pub type WBEM_VARIANT = VARIANT; +pub type WBEM_WSTR = LPWSTR; +pub type WBEM_CWSTR = LPCWSTR; +ENUM!{enum WBEM_PROVIDER_REQUIREMENTS_TYPE { + WBEM_REQUIREMENTS_START_POSTFILTER = 0, + WBEM_REQUIREMENTS_STOP_POSTFILTER = 1, + WBEM_REQUIREMENTS_RECHECK_SUBSCRIPTIONS = 2, +}} +// extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0000_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0000_v0_0_s_ifspec; +// EXTERN_C const IID LIBID_WbemProviders_v1; +// EXTERN_C const IID IID_IWbemPropertyProvider; +DEFINE_GUID!{IID_IWbemPropertyProvider, + 0xce61e841, 0x65bc, 0x11d0, 0xb6, 0xbd, 0x00, 0xaa, 0x00, 0x32, 0x40, 0xc7} +RIDL!{#[uuid(0xce61e841, 0x65bc, 0x11d0, 0xb6, 0xbd, 0x00, 0xaa, 0x00, 0x32, 0x40, 0xc7)] +interface IWbemPropertyProvider(IWbemPropertyProviderVtbl): IUnknown(IUnknownVtbl) { + fn GetProperty( + lFlags: c_long, + strLocale: BSTR, + strClassMapping: BSTR, + strInstMapping: BSTR, + strPropMapping: BSTR, + pvValue: *mut VARIANT, + ) -> HRESULT, + fn PutProperty( + lFlags: c_long, + strLocale: BSTR, + strClassMapping: BSTR, + strInstMapping: BSTR, + strPropMapping: BSTR, + pvValue: *const VARIANT, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemUnboundObjectSink; +DEFINE_GUID!{IID_IWbemUnboundObjectSink, + 0xe246107b, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +RIDL!{#[uuid(0xe246107b, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff)] +interface IWbemUnboundObjectSink(IWbemUnboundObjectSinkVtbl): IUnknown(IUnknownVtbl) { + fn IndicateToConsumer( + pLogicalConsumer: *mut IWbemClassObject, + lNumObjects: c_long, + apObjects: *mut *mut IWbemClassObject, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemEventProvider; +DEFINE_GUID!{IID_IWbemEventProvider, + 0xe245105b, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +RIDL!{#[uuid(0xe245105b, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff)] +interface IWbemEventProvider(IWbemEventProviderVtbl): IUnknown(IUnknownVtbl) { + fn ProvideEvents( + pSink: *mut IWbemObjectSink, + lFlags: c_long, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemEventProviderQuerySink; +DEFINE_GUID!{IID_IWbemEventProviderQuerySink, + 0x580acaf8, 0xfa1c, 0x11d0, 0xad, 0x72, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +RIDL!{#[uuid(0x580acaf8, 0xfa1c, 0x11d0, 0xad, 0x72, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff)] +interface IWbemEventProviderQuerySink(IWbemEventProviderQuerySinkVtbl): IUnknown(IUnknownVtbl) { + fn NewQuery( + dwId: c_ulong, + wszQueryLanguage: WBEM_WSTR, + wszQuery: WBEM_WSTR, + ) -> HRESULT, + fn CancelQuery( + dwId: c_ulong, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemEventProviderSecurity; +DEFINE_GUID!{IID_IWbemEventProviderSecurity, + 0x631f7d96, 0xd993, 0x11d2, 0xb3, 0x39, 0x00, 0x10, 0x5a, 0x1f, 0x4a, 0xaf} +RIDL!{#[uuid(0x631f7d96, 0xd993, 0x11d2, 0xb3, 0x39, 0x00, 0x10, 0x5a, 0x1f, 0x4a, 0xaf)] +interface IWbemEventProviderSecurity(IWbemEventProviderSecurityVtbl): IUnknown(IUnknownVtbl) { + fn AccessCheck( + wszQueryLanguage: WBEM_CWSTR, + wszQuery: WBEM_CWSTR, + lSidLength: c_long, + pSid: *const BYTE, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemEventConsumerProvider; +DEFINE_GUID!{IID_IWbemEventConsumerProvider, + 0xe246107a, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +RIDL!{#[uuid(0xe246107a, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff)] +interface IWbemEventConsumerProvider(IWbemEventConsumerProviderVtbl): IUnknown(IUnknownVtbl) { + fn FindConsumer( + pLogicalConsumer: *mut IWbemClassObject, + ppConsumer: *mut *mut IWbemUnboundObjectSink, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemProviderInitSink; +DEFINE_GUID!{IID_IWbemProviderInitSink, + 0x1be41571, 0x91dd, 0x11d1, 0xae, 0xb2, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0x1be41571, 0x91dd, 0x11d1, 0xae, 0xb2, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IWbemProviderInitSink(IWbemProviderInitSinkVtbl): IUnknown(IUnknownVtbl) { + fn SetStatus( + lStatus: LONG, + lFlags: LONG, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemProviderInit; +DEFINE_GUID!{IID_IWbemProviderInit, + 0x1be41572, 0x91dd, 0x11d1, 0xae, 0xb2, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0x1be41572, 0x91dd, 0x11d1, 0xae, 0xb2, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IWbemProviderInit(IWbemProviderInitVtbl): IUnknown(IUnknownVtbl) { + fn Initialize( + wszUser: LPWSTR, + lFlags: LONG, + wszNamespace: LPWSTR, + wszLocale: LPWSTR, + pNamespace: *mut IWbemServices, + pCtx: *mut IWbemContext, + pInitSink: *mut IWbemProviderInitSink, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemHiPerfProvider; +DEFINE_GUID!{IID_IWbemHiPerfProvider, + 0x49353c93, 0x516b, 0x11d1, 0xae, 0xa6, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0x49353c93, 0x516b, 0x11d1, 0xae, 0xa6, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IWbemHiPerfProvider(IWbemHiPerfProviderVtbl): IUnknown(IUnknownVtbl) { + fn QueryInstances( + pNamespace: *mut IWbemServices, + wszClass: *mut WCHAR, + lFlags: c_long, + pCtx: *mut IWbemContext, + pSink: *mut IWbemObjectSink, + ) -> HRESULT, + fn CreateRefresher( + pNamespace: *mut IWbemServices, + lFlags: c_long, + ppRefresher: *mut *mut IWbemRefresher, + ) -> HRESULT, + fn CreateRefreshableObject( + pNamespace: *mut IWbemServices, + pTemplate: *mut IWbemObjectAccess, + pRefresher: *mut IWbemRefresher, + lFlags: c_long, + pContext: *mut IWbemContext, + ppRefreshable: *mut *mut IWbemObjectAccess, + plId: *mut c_long, + ) -> HRESULT, + fn StopRefreshing( + pRefresher: *mut IWbemRefresher, + lId: c_long, + lFlags: c_long, + ) -> HRESULT, + fn CreateRefreshableEnum( + pNamespace: *mut IWbemServices, + wszClass: LPCWSTR, + pRefresher: *mut IWbemRefresher, + lFlags: c_long, + pContext: *mut IWbemContext, + pHiPerfEnum: *mut IWbemHiPerfEnum, + plId: *mut c_long, + ) -> HRESULT, + fn GetObjects( + pNamespace: *mut IWbemServices, + lNumObjects: c_long, + apObj: *mut *mut IWbemObjectAccess, + lFlags: c_long, + pContext: *mut IWbemContext, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemDecoupledRegistrar; +DEFINE_GUID!{IID_IWbemDecoupledRegistrar, + 0x1005cbcf, 0xe64f, 0x4646, 0xbc, 0xd3, 0x3a, 0x08, 0x9d, 0x8a, 0x84, 0xb4} +RIDL!{#[uuid(0x1005cbcf, 0xe64f, 0x4646, 0xbc, 0xd3, 0x3a, 0x08, 0x9d, 0x8a, 0x84, 0xb4)] +interface IWbemDecoupledRegistrar(IWbemDecoupledRegistrarVtbl): IUnknown(IUnknownVtbl) { + fn Register( + a_Flags: c_long, + a_Context: *mut IWbemContext, + a_User: LPCWSTR, + a_Locale: LPCWSTR, + a_Scope: LPCWSTR, + a_Registration: LPCWSTR, + pIUnknown: *mut IUnknown, + ) -> HRESULT, + fn UnRegister() -> HRESULT, +}} +DEFINE_GUID!{CLSID_WbemAdministrativeLocator, + 0xcb8555cc, 0x9128, 0x11d1, 0xad, 0x9b, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +// class DECLSPEC_UUID("cb8555cc-9128-11d1-ad9b-00c04fd8fdff") +// WbemAdministrativeLocator; +DEFINE_GUID!{CLSID_WbemAuthenticatedLocator, + 0xcd184336, 0x9128, 0x11d1, 0xad, 0x9b, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +// class DECLSPEC_UUID("cd184336-9128-11d1-ad9b-00c04fd8fdff") +// WbemAuthenticatedLocator; +DEFINE_GUID!{CLSID_WbemUnauthenticatedLocator, + 0x443E7B79, 0xDE31, 0x11d2, 0xB3, 0x40, 0x00, 0x10, 0x4B, 0xCC, 0x4B, 0x4A} +// class DECLSPEC_UUID("443E7B79-DE31-11d2-B340-00104BCC4B4A") +// WbemUnauthenticatedLocator; +DEFINE_GUID!{CLSID_WbemDecoupledRegistrar, + 0x4cfc7932, 0x0f9d, 0x4bef, 0x9c, 0x32, 0x8e, 0xa2, 0xa6, 0xb5, 0x6f, 0xcb} +// class DECLSPEC_UUID("4cfc7932-0f9d-4bef-9c32-8ea2a6b56fcb") +// WbemDecoupledRegistrar; +DEFINE_GUID!{CLSID_WbemDecoupledBasicEventProvider, + 0xf5f75737, 0x2843, 0x4f22, 0x93, 0x3d, 0xc7, 0x6a, 0x97, 0xcd, 0xa6, 0x2f} +// class DECLSPEC_UUID("f5f75737-2843-4f22-933d-c76a97cda62f") +// WbemDecoupledBasicEventProvider; +// EXTERN_C const IID IID_IWbemProviderIdentity; +DEFINE_GUID!{IID_IWbemProviderIdentity, + 0x631f7d97, 0xd993, 0x11d2, 0xb3, 0x39, 0x00, 0x10, 0x5a, 0x1f, 0x4a, 0xaf} +RIDL!{#[uuid(0x631f7d97, 0xd993, 0x11d2, 0xb3, 0x39, 0x00, 0x10, 0x5a, 0x1f, 0x4a, 0xaf)] +interface IWbemProviderIdentity(IWbemProviderIdentityVtbl): IUnknown(IUnknownVtbl) { + fn SetRegistrationObject( + lFlags: c_long, + pProvReg: *mut IWbemClassObject, + ) -> HRESULT, +}} +ENUM!{enum WBEM_EXTRA_RETURN_CODES { + WBEM_S_INITIALIZED = 0, + WBEM_S_LIMITED_SERVICE = 0x43001, + WBEM_S_INDIRECTLY_UPDATED = WBEM_S_LIMITED_SERVICE + 1, + WBEM_S_SUBJECT_TO_SDS = WBEM_S_INDIRECTLY_UPDATED + 1, + WBEM_E_RETRY_LATER = 0x80043001, + WBEM_E_RESOURCE_CONTENTION = WBEM_E_RETRY_LATER + 1, +}} +ENUM!{enum WBEM_PROVIDER_FLAGS { + WBEM_FLAG_OWNER_UPDATE = 0x10000, +}} +// extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0008_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0008_v0_0_s_ifspec; +// EXTERN_C const IID IID_IWbemDecoupledBasicEventProvider; +DEFINE_GUID!{IID_IWbemDecoupledBasicEventProvider, + 0x86336d20, 0xca11, 0x4786, 0x9e, 0xf1, 0xbc, 0x8a, 0x94, 0x6b, 0x42, 0xfc} +RIDL!{#[uuid(0x86336d20, 0xca11, 0x4786, 0x9e, 0xf1, 0xbc, 0x8a, 0x94, 0x6b, 0x42, 0xfc)] +interface IWbemDecoupledBasicEventProvider(IWbemDecoupledBasicEventProviderVtbl): + IWbemDecoupledRegistrar(IWbemDecoupledRegistrarVtbl) { + fn GetSink( + a_Flags: c_long, + a_Context: *mut IWbemContext, + a_Sink: *mut *mut IWbemObjectSink, + ) -> HRESULT, + fn GetService( + a_Flags: c_long, + a_Context: *mut IWbemContext, + a_Service: *mut *mut IWbemServices, + ) -> HRESULT, +}} +ENUM!{enum WBEM_BATCH_TYPE { + WBEM_FLAG_BATCH_IF_NEEDED = 0, + WBEM_FLAG_MUST_BATCH = 0x1, + WBEM_FLAG_MUST_NOT_BATCH = 0x2, +}} +// extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0013_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0013_v0_0_s_ifspec; +// EXTERN_C const IID IID_IWbemEventSink; +DEFINE_GUID!{IID_IWbemEventSink, + 0x3ae0080a, 0x7e3a, 0x4366, 0xbf, 0x89, 0x0f, 0xee, 0xdc, 0x93, 0x16, 0x59} +RIDL!{#[uuid(0x3ae0080a, 0x7e3a, 0x4366, 0xbf, 0x89, 0x0f, 0xee, 0xdc, 0x93, 0x16, 0x59)] +interface IWbemEventSink(IWbemEventSinkVtbl): IWbemObjectSink(IWbemObjectSinkVtbl) { + fn SetSinkSecurity( + lSDLength: c_long, + pSD: *mut BYTE, + ) -> HRESULT, + fn IsActive() -> HRESULT, + fn GetRestrictedSink( + lNumQueries: c_long, + awszQueries: *const LPCWSTR, + pCallback: *mut IUnknown, + ppSink: *mut *mut IWbemEventSink, + ) -> HRESULT, + fn SetBatchingParameters( + lFlags: LONG, + dwMaxBufferSize: DWORD, + dwMaxSendLatency: DWORD, + ) -> HRESULT, +}} +// extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0014_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0014_v0_0_s_ifspec; +// unsigned c_long __RPC_USER BSTR_UserSize( __RPC__in unsigned c_long *, unsigned c_long, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserMarshal( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserUnmarshal(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); +// void __RPC_USER BSTR_UserFree( __RPC__in unsigned c_long *, __RPC__in BSTR * ); +// unsigned c_long __RPC_USER VARIANT_UserSize( __RPC__in unsigned c_long *, unsigned c_long, __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserMarshal( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserUnmarshal(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out VARIANT * ); +// void __RPC_USER VARIANT_UserFree( __RPC__in unsigned c_long *, __RPC__in VARIANT * ); +// unsigned c_long __RPC_USER BSTR_UserSize64( __RPC__in unsigned c_long *, unsigned c_long, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserMarshal64( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); +// unsigned char * __RPC_USER BSTR_UserUnmarshal64(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); +// void __RPC_USER BSTR_UserFree64( __RPC__in unsigned c_long *, __RPC__in BSTR * ); +// unsigned c_long __RPC_USER VARIANT_UserSize64( __RPC__in unsigned c_long *, unsigned c_long, __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserMarshal64( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in VARIANT * ); +// unsigned char * __RPC_USER VARIANT_UserUnmarshal64(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out VARIANT * ); +// void __RPC_USER VARIANT_UserFree64( __RPC__in unsigned c_long *, __RPC__in VARIANT * ); diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemtran.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemtran.rs new file mode 100644 index 0000000..6f9d4a6 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wbemtran.rs @@ -0,0 +1,184 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_long, c_void}; +use shared::guiddef::REFIID; +use shared::minwindef::{BYTE, DWORD}; +use shared::winerror::HRESULT; +use shared::wtypes::BSTR; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::wbemcli::{IWbemCallResult, IWbemContext, IWbemObjectSink, IWbemServices}; +use um::winnt::{LPCWSTR, LPWSTR}; +// extern RPC_IF_HANDLE __MIDL_itf_wbemtran_0000_0000_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemtran_0000_0000_v0_0_s_ifspec; +ENUM!{enum WBEM_LOGIN_TYPE { + WBEM_FLAG_INPROC_LOGIN = 0, + WBEM_FLAG_LOCAL_LOGIN = 1, + WBEM_FLAG_REMOTE_LOGIN = 2, + WBEM_AUTHENTICATION_METHOD_MASK = 0xf, + WBEM_FLAG_USE_MULTIPLE_CHALLENGES = 0x10, +}} +pub type WBEM_128BITS = *mut BYTE; +// EXTERN_C const IID LIBID_WbemTransports_v1; +// EXTERN_C const IID IID_IWbemTransport; +DEFINE_GUID!{IID_IWbemTransport, + 0x553fe584, 0x2156, 0x11d0, 0xb6, 0xae, 0x00, 0xaa, 0x00, 0x32, 0x40, 0xc7} +RIDL!{#[uuid(0x553fe584, 0x2156, 0x11d0, 0xb6, 0xae, 0x00, 0xaa, 0x00, 0x32, 0x40, 0xc7)] +interface IWbemTransport(IWbemTransportVtbl): IUnknown(IUnknownVtbl) { + fn Initialize() -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemLevel1Login; +DEFINE_GUID!{IID_IWbemLevel1Login, + 0xf309ad18, 0xd86a, 0x11d0, 0xa0, 0x75, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20} +RIDL!{#[uuid(0xf309ad18, 0xd86a, 0x11d0, 0xa0, 0x75, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)] +interface IWbemLevel1Login(IWbemLevel1LoginVtbl): IUnknown(IUnknownVtbl) { + fn EstablishPosition( + wszLocaleList: LPWSTR, + dwNumLocales: DWORD, + reserved: *mut DWORD, + ) -> HRESULT, + fn RequestChallenge( + wszNetworkResource: LPWSTR, + wszUser: LPWSTR, + Nonce: WBEM_128BITS, + ) -> HRESULT, + fn WBEMLogin( + wszPreferredLocale: LPWSTR, + AccessToken: WBEM_128BITS, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppNamespace: *mut *mut IWbemServices, + ) -> HRESULT, + fn NTLMLogin( + wszNetworkResource: LPWSTR, + wszPreferredLocale: LPWSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + ppNamespace: *mut *mut IWbemServices, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemConnectorLogin; +DEFINE_GUID!{IID_IWbemConnectorLogin, + 0xd8ec9cb1, 0xb135, 0x4f10, 0x8b, 0x1b, 0xc7, 0x18, 0x8b, 0xb0, 0xd1, 0x86} +RIDL!{#[uuid(0xd8ec9cb1, 0xb135, 0x4f10, 0x8b, 0x1b, 0xc7, 0x18, 0x8b, 0xb0, 0xd1, 0x86)] +interface IWbemConnectorLogin(IWbemConnectorLoginVtbl): IUnknown(IUnknownVtbl) { + fn ConnectorLogin( + wszNetworkResource: LPWSTR, + wszPreferredLocale: LPWSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + riid: REFIID, + pInterface: *mut *mut c_void, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemAddressResolution; +DEFINE_GUID!{IID_IWbemAddressResolution, + 0xf7ce2e12, 0x8c90, 0x11d1, 0x9e, 0x7b, 0x00, 0xc0, 0x4f, 0xc3, 0x24, 0xa8} +RIDL!{#[uuid(0xf7ce2e12, 0x8c90, 0x11d1, 0x9e, 0x7b, 0x00, 0xc0, 0x4f, 0xc3, 0x24, 0xa8)] +interface IWbemAddressResolution(IWbemAddressResolutionVtbl): IUnknown(IUnknownVtbl) { + fn Resolve( + wszNamespacePath: LPWSTR, + wszAddressType: LPWSTR, + pdwAddressLength: *mut DWORD, + pabBinaryAddress: *mut *mut BYTE, + ) -> HRESULT, +}} +DEFINE_GUID!{CLSID_WbemLevel1Login, + 0x8BC3F05E, 0xD86B, 0x11d0, 0xA0, 0x75, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20} +// class DECLSPEC_UUID("8BC3F05E-D86B-11d0-A075-00C04FB68820") +// WbemLevel1Login; +DEFINE_GUID!{CLSID_WbemLocalAddrRes, + 0xA1044801, 0x8F7E, 0x11d1, 0x9E, 0x7C, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8} +// class DECLSPEC_UUID("A1044801-8F7E-11d1-9E7C-00C04FC324A8") +// WbemLocalAddrRes; +DEFINE_GUID!{CLSID_WbemUninitializedClassObject, + 0x7a0227f6, 0x7108, 0x11d1, 0xad, 0x90, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +// class DECLSPEC_UUID("7a0227f6-7108-11d1-ad90-00c04fd8fdff") +// WbemUninitializedClassObject; +// EXTERN_C const IID IID_IWbemClientTransport; +DEFINE_GUID!{IID_IWbemClientTransport, + 0xf7ce2e11, 0x8c90, 0x11d1, 0x9e, 0x7b, 0x00, 0xc0, 0x4f, 0xc3, 0x24, 0xa8} +RIDL!{#[uuid(0xf7ce2e11, 0x8c90, 0x11d1, 0x9e, 0x7b, 0x00, 0xc0, 0x4f, 0xc3, 0x24, 0xa8)] +interface IWbemClientTransport(IWbemClientTransportVtbl): IUnknown(IUnknownVtbl) { + fn ConnectServer( + strAddressType: BSTR, + dwBinaryAddressLength: DWORD, + abBinaryAddress: *mut BYTE, + strNetworkResource: BSTR, + strUser: BSTR, + strPassword: BSTR, + strLocale: BSTR, + lSecurityFlags: c_long, + strAuthority: BSTR, + pCtx: *mut IWbemContext, + ppNamespace: *mut *mut IWbemServices, + ) -> HRESULT, +}} +// EXTERN_C const IID IID_IWbemClientConnectionTransport; +DEFINE_GUID!{IID_IWbemClientConnectionTransport, + 0xa889c72a, 0xfcc1, 0x4a9e, 0xaf, 0x61, 0xed, 0x07, 0x13, 0x33, 0xfb, 0x5b} +RIDL!{#[uuid(0xa889c72a, 0xfcc1, 0x4a9e, 0xaf, 0x61, 0xed, 0x07, 0x13, 0x33, 0xfb, 0x5b)] +interface IWbemClientConnectionTransport(IWbemClientConnectionTransportVtbl): + IUnknown(IUnknownVtbl) { + fn Open( + strAddressType: BSTR, + dwBinaryAddressLength: DWORD, + abBinaryAddress: *mut BYTE, + strObject: BSTR, + strUser: BSTR, + strPassword: BSTR, + strLocale: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + riid: REFIID, + pInterface: *mut *mut c_void, + pCallRes: *mut *mut IWbemCallResult, + ) -> HRESULT, + fn OpenAsync( + strAddressType: BSTR, + dwBinaryAddressLength: DWORD, + abBinaryAddress: *mut BYTE, + strObject: BSTR, + strUser: BSTR, + strPassword: BSTR, + strLocale: BSTR, + lFlags: c_long, + pCtx: *mut IWbemContext, + riid: REFIID, + pResponseHandler: *mut IWbemObjectSink, + ) -> HRESULT, + fn Cancel( + lFlags: c_long, + pHandler: *mut IWbemObjectSink, + ) -> HRESULT, +}} +DEFINE_GUID!{CLSID_WbemDCOMTransport, + 0xF7CE2E13, 0x8C90, 0x11d1, 0x9E, 0x7B, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8} +// class DECLSPEC_UUID("F7CE2E13-8C90-11d1-9E7B-00C04FC324A8") +// WbemDCOMTransport; +// EXTERN_C const IID IID_IWbemConstructClassObject; +DEFINE_GUID!{IID_IWbemConstructClassObject, + 0x9ef76194, 0x70d5, 0x11d1, 0xad, 0x90, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff} +RIDL!{#[uuid(0x9ef76194, 0x70d5, 0x11d1, 0xad, 0x90, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff)] +interface IWbemConstructClassObject(IWbemConstructClassObjectVtbl): IUnknown(IUnknownVtbl) { + fn SetInheritanceChain( + lNumAntecedents: c_long, + awszAntecedents: *mut LPWSTR, + ) -> HRESULT, + fn SetPropertyOrigin( + wszPropertyName: LPCWSTR, + lOriginIndex: c_long, + ) -> HRESULT, + fn SetMethodOrigin( + wszMethodName: LPCWSTR, + lOriginIndex: c_long, + ) -> HRESULT, + fn SetServerNamespace( + wszServer: LPCWSTR, + wszNamespace: LPCWSTR, + ) -> HRESULT, +}} +// extern RPC_IF_HANDLE __MIDL_itf_wbemtran_0000_0008_v0_0_c_ifspec; +// extern RPC_IF_HANDLE __MIDL_itf_wbemtran_0000_0008_v0_0_s_ifspec; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wct.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wct.rs new file mode 100644 index 0000000..0c3fae9 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wct.rs @@ -0,0 +1,114 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_int; +use shared::basetsd::{DWORD_PTR, SIZE_T}; +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, DWORD, LPBOOL, LPDWORD, PULONG}; +use um::winnt::{HRESULT, LARGE_INTEGER, WCHAR}; +ENUM!{enum WCT_OBJECT_TYPE { + WctCriticalSectionType = 1, + WctSendMessageType, + WctMutexType, + WctAlpcType, + WctComType, + WctThreadWaitType, + WctProcessWaitType, + WctThreadType, + WctComActivationType, + WctUnknownType, + WctSocketIoType, + WctSmbIoType, + WctMaxType, +}} +ENUM!{enum WCT_OBJECT_STATUS { + WctStatusNoAccess = 1, + WctStatusRunning, + WctStatusBlocked, + WctStatusPidOnly, + WctStatusPidOnlyRpcss, + WctStatusOwned, + WctStatusNotOwned, + WctStatusAbandoned, + WctStatusUnknown, + WctStatusError, + WctStatusMax, +}} +pub const WCT_MAX_NODE_COUNT: SIZE_T = 16; +pub const WCT_OBJNAME_LENGTH: SIZE_T = 128; +STRUCT!{struct WAITCHAIN_NODE_INFO_LOCK_OBJECT { + ObjectName: [WCHAR; WCT_OBJNAME_LENGTH], + Timeout: LARGE_INTEGER, + Alertable: BOOL, +}} +STRUCT!{struct WAITCHAIN_NODE_INFO_THREAD_OBJECT { + ProcessId: DWORD, + ThreadId: DWORD, + WaitTime: DWORD, + ContextSwitches: DWORD, +}} +UNION!{union WAITCHAIN_NODE_INFO_u { + [u64; 34], + LockObject LockObject_mut: WAITCHAIN_NODE_INFO_LOCK_OBJECT, + ThreadObject ThreadObject_mut: WAITCHAIN_NODE_INFO_THREAD_OBJECT, +}} +STRUCT!{struct WAITCHAIN_NODE_INFO { + ObjectType: WCT_OBJECT_TYPE, + ObjectStatus: WCT_OBJECT_STATUS, + u: WAITCHAIN_NODE_INFO_u, +}} +pub type PWAITCHAIN_NODE_INFO = *mut WAITCHAIN_NODE_INFO; +DECLARE_HANDLE!{HWCT, HWCT__} +FN!{cdecl PWAITCHAINCALLBACK( + WctHandle: HWCT, + Context: DWORD_PTR, + CallbackStatus: DWORD, + NodeCount: LPDWORD, + NodeInfoArray: PWAITCHAIN_NODE_INFO, + IsCycle: LPBOOL, +) -> ()} +pub const WCT_ASYNC_OPEN_FLAG: DWORD = 1; +pub const WCTP_OPEN_ALL_FLAGS: DWORD = WCT_ASYNC_OPEN_FLAG; +extern "system" { + pub fn OpenThreadWaitChainSession( + Flags: DWORD, + callback: PWAITCHAINCALLBACK, + ) -> HWCT; + pub fn CloseThreadWaitChainSession( + WctHandle: HWCT, + ); +} +pub const WCT_OUT_OF_PROC_FLAG: DWORD = 0x1; +pub const WCT_OUT_OF_PROC_COM_FLAG: DWORD = 0x2; +pub const WCT_OUT_OF_PROC_CS_FLAG: DWORD = 0x4; +pub const WCT_NETWORK_IO_FLAG: DWORD = 0x8; +pub const WCTP_GETINFO_ALL_FLAGS: DWORD = WCT_OUT_OF_PROC_FLAG | WCT_OUT_OF_PROC_COM_FLAG + | WCT_OUT_OF_PROC_CS_FLAG; +extern "system" { + pub fn GetThreadWaitChain( + WctHandle: HWCT, + Context: DWORD_PTR, + Flags: DWORD, + ThreadId: DWORD, + NodeCount: LPDWORD, + NodeInfoArray: PWAITCHAIN_NODE_INFO, + IsCycle: LPBOOL, + ) -> BOOL; +} +FN!{cdecl PCOGETCALLSTATE( + c_int, + PULONG, +) -> HRESULT} +FN!{cdecl PCOGETACTIVATIONSTATE( + GUID, + DWORD, + *mut DWORD, +) -> HRESULT} +extern "system" { + pub fn RegisterWaitChainCOMCallback( + CallStateCallback: PCOGETCALLSTATE, + ActivationStateCallback: PCOGETACTIVATIONSTATE, + ); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/werapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/werapi.rs new file mode 100644 index 0000000..6eae64e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/werapi.rs @@ -0,0 +1,53 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Function prototypes for Windows Error Reporting (WER) +use shared::minwindef::{BOOL, DWORD, PDWORD}; +use um::winnt::{HANDLE, HRESULT, PCWSTR, PVOID}; +ENUM!{enum WER_REGISTER_FILE_TYPE { + WerRegFileTypeUserDocument = 1, + WerRegFileTypeOther = 2, + WerRegFileTypeMax, +}} +extern "system" { + pub fn WerRegisterFile( + pwzFile: PCWSTR, + regFileType: WER_REGISTER_FILE_TYPE, + dwFlags: DWORD, + ) -> HRESULT; + pub fn WerUnregisterFile( + pwzFilePath: PCWSTR, + ) -> HRESULT; + pub fn WerRegisterMemoryBlock( + pvAddress: PVOID, + dwSize: DWORD, + ) -> HRESULT; + pub fn WerUnregisterMemoryBlock( + pvAddress: PVOID, + ) -> HRESULT; + pub fn WerSetFlags( + dwFlags: DWORD, + ) -> HRESULT; + pub fn WerGetFlags( + hProcess: HANDLE, + pdwFlags: PDWORD, + ) -> HRESULT; + pub fn WerAddExcludedApplication( + pwzExeName: PCWSTR, + bAllUsers: BOOL, + ) -> HRESULT; + pub fn WerRemoveExcludedApplication( + pwzExeName: PCWSTR, + bAllUsers: BOOL, + ) -> HRESULT; + pub fn WerRegisterRuntimeExceptionModule( + pwszOutOfProcessCallbackDll: PCWSTR, + pContext: PVOID, + ) -> HRESULT; + pub fn WerUnregisterRuntimeExceptionModule( + pwszOutOfProcessCallbackDll: PCWSTR, + pContext: PVOID, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winbase.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winbase.rs new file mode 100644 index 0000000..22db22a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winbase.rs @@ -0,0 +1,2825 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module defines the 32-Bit Windows Base APIs +use ctypes::{c_char, c_int, c_long, c_void}; +use shared::basetsd::{ + DWORD64, DWORD_PTR, LONG_PTR, PDWORD64, PDWORD_PTR, PSIZE_T, PULONG_PTR, SIZE_T, UINT_PTR, + ULONG_PTR, +}; +use shared::guiddef::GUID; +use shared::minwindef::{ + ATOM, BOOL, BYTE, DWORD, FARPROC, FILETIME, HFILE, HGLOBAL, HLOCAL, HMODULE, HRSRC, LPBOOL, + LPBYTE, LPCVOID, LPDWORD, LPFILETIME, LPVOID, LPWORD, PBOOL, PDWORD, PUCHAR, PULONG, PUSHORT, + UCHAR, UINT, ULONG, USHORT, WORD, +}; +use shared::windef::HWND; +use um::cfgmgr32::MAX_PROFILE_LEN; +use um::fileapi::STREAM_INFO_LEVELS; +use um::libloaderapi::{ + ENUMRESLANGPROCA, ENUMRESLANGPROCW, ENUMRESNAMEPROCA, ENUMRESTYPEPROCA, ENUMRESTYPEPROCW, +}; +use um::minwinbase::{ + FILE_INFO_BY_HANDLE_CLASS, FINDEX_INFO_LEVELS, FINDEX_SEARCH_OPS, GET_FILEEX_INFO_LEVELS, + LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE, LPSECURITY_ATTRIBUTES, PREASON_CONTEXT, +}; +use um::processthreadsapi::{ + LPPROC_THREAD_ATTRIBUTE_LIST, LPSTARTUPINFOA, STARTUPINFOA, STARTUPINFOW, +}; +use um::winnt::{ + BOOLEAN, CHAR, DWORDLONG, EXECUTION_STATE, FILE_ID_128, HANDLE, HRESULT, INT, LANGID, + LARGE_INTEGER, LATENCY_TIME, LONG, LPCCH, LPCH, LPCSTR, LPCWSTR, LPOSVERSIONINFOEXA, + LPOSVERSIONINFOEXW, LPSTR, LPWSTR, MAXLONG, PBOOLEAN, PCONTEXT, PCWSTR, PFIRMWARE_TYPE, + PHANDLE, PIO_COUNTERS, PJOB_SET_ARRAY, PLUID, POWER_REQUEST_TYPE, PPERFORMANCE_DATA, + PPROCESSOR_NUMBER, PQUOTA_LIMITS, PRTL_UMS_SCHEDULER_ENTRY_POINT, + PSECURE_MEMORY_CACHE_CALLBACK, PSID, PSID_NAME_USE, PULONGLONG, PVOID, PWOW64_CONTEXT, + PWOW64_LDT_ENTRY, PWSTR, RTL_UMS_THREAD_INFO_CLASS, STATUS_ABANDONED_WAIT_0, STATUS_USER_APC, + STATUS_WAIT_0, SecurityAnonymous, SecurityDelegation, SecurityIdentification, + SecurityImpersonation, THREAD_BASE_PRIORITY_IDLE, THREAD_BASE_PRIORITY_LOWRT, + THREAD_BASE_PRIORITY_MAX, THREAD_BASE_PRIORITY_MIN, ULARGE_INTEGER, VOID, WAITORTIMERCALLBACK, + WCHAR, WOW64_CONTEXT, +}; +#[cfg(target_arch = "x86")] +use um::winnt::PLDT_ENTRY; +use vc::vadefs::va_list; +pub const FILE_BEGIN: DWORD = 0; +pub const FILE_CURRENT: DWORD = 1; +pub const FILE_END: DWORD = 2; +pub const WAIT_FAILED: DWORD = 0xFFFFFFFF; +pub const WAIT_OBJECT_0: DWORD = STATUS_WAIT_0 as u32; +pub const WAIT_ABANDONED: DWORD = STATUS_ABANDONED_WAIT_0 as u32; +pub const WAIT_ABANDONED_0: DWORD = STATUS_ABANDONED_WAIT_0 as u32; +pub const WAIT_IO_COMPLETION: DWORD = STATUS_USER_APC as u32; +pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000; +pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000; +pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000; +pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000; +pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000; +pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000; +pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000; +pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x01000000; +pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000; +pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000; +pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000; +pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000; +pub const FILE_FLAG_OPEN_REQUIRING_OPLOCK: DWORD = 0x00040000; +pub const PROGRESS_CONTINUE: DWORD = 0; +pub const PROGRESS_CANCEL: DWORD = 1; +pub const PROGRESS_STOP: DWORD = 2; +pub const PROGRESS_QUIET: DWORD = 3; +pub const CALLBACK_CHUNK_FINISHED: DWORD = 0x00000000; +pub const CALLBACK_STREAM_SWITCH: DWORD = 0x00000001; +pub const COPY_FILE_FAIL_IF_EXISTS: DWORD = 0x00000001; +pub const COPY_FILE_RESTARTABLE: DWORD = 0x00000002; +pub const COPY_FILE_OPEN_SOURCE_FOR_WRITE: DWORD = 0x00000004; +pub const COPY_FILE_ALLOW_DECRYPTED_DESTINATION: DWORD = 0x00000008; +pub const COPY_FILE_COPY_SYMLINK: DWORD = 0x00000800; +pub const COPY_FILE_NO_BUFFERING: DWORD = 0x00001000; +pub const COPY_FILE_REQUEST_SECURITY_PRIVILEGES: DWORD = 0x00002000; +pub const COPY_FILE_RESUME_FROM_PAUSE: DWORD = 0x00004000; +pub const COPY_FILE_NO_OFFLOAD: DWORD = 0x00040000; +pub const COPY_FILE_IGNORE_EDP_BLOCK: DWORD = 0x00400000; +pub const COPY_FILE_IGNORE_SOURCE_ENCRYPTION: DWORD = 0x00800000; +pub const REPLACEFILE_WRITE_THROUGH: DWORD = 0x00000001; +pub const REPLACEFILE_IGNORE_MERGE_ERRORS: DWORD = 0x00000002; +pub const REPLACEFILE_IGNORE_ACL_ERRORS: DWORD = 0x00000004; +pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; +pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; +pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003; +pub const PIPE_CLIENT_END: DWORD = 0x00000000; +pub const PIPE_SERVER_END: DWORD = 0x00000001; +pub const PIPE_WAIT: DWORD = 0x00000000; +pub const PIPE_NOWAIT: DWORD = 0x00000001; +pub const PIPE_READMODE_BYTE: DWORD = 0x00000000; +pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002; +pub const PIPE_TYPE_BYTE: DWORD = 0x00000000; +pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004; +pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000; +pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008; +pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255; +pub const SECURITY_ANONYMOUS: DWORD = SecurityAnonymous << 16; +pub const SECURITY_IDENTIFICATION: DWORD = SecurityIdentification << 16; +pub const SECURITY_IMPERSONATION: DWORD = SecurityImpersonation << 16; +pub const SECURITY_DELEGATION: DWORD = SecurityDelegation << 16; +pub const SECURITY_CONTEXT_TRACKING: DWORD = 0x00040000; +pub const SECURITY_EFFECTIVE_ONLY: DWORD = 0x00080000; +pub const SECURITY_SQOS_PRESENT: DWORD = 0x00100000; +pub const SECURITY_VALID_SQOS_FLAGS: DWORD = 0x001F0000; +FN!{stdcall PFIBER_START_ROUTINE( + lpFiberParameter: LPVOID, +) -> ()} +pub type LPFIBER_START_ROUTINE = PFIBER_START_ROUTINE; +FN!{stdcall PFIBER_CALLOUT_ROUTINE( + lpParameter: LPVOID, +) -> LPVOID} +// FAIL_FAST_* +#[cfg(target_arch = "x86")] +pub type LPLDT_ENTRY = PLDT_ENTRY; +#[cfg(not(target_arch = "x86"))] +pub type LPLDT_ENTRY = LPVOID; // TODO - fix this for 32-bit +//SP_SERIALCOMM +//PST_* +// PCF_* +// SP_* +// BAUD_* +// DATABITS_* +// STOPBITS_* +// PARITY_* +STRUCT!{struct COMMPROP { + wPacketLength: WORD, + wPacketVersion: WORD, + dwServiceMask: DWORD, + dwReserved1: DWORD, + dwMaxTxQueue: DWORD, + dwMaxRxQueue: DWORD, + dwMaxBaud: DWORD, + dwProvSubType: DWORD, + dwProvCapabilities: DWORD, + dwSettableParams: DWORD, + dwSettableBaud: DWORD, + wSettableData: WORD, + wSettableStopParity: WORD, + dwCurrentTxQueue: DWORD, + dwCurrentRxQueue: DWORD, + dwProvSpec1: DWORD, + dwProvSpec2: DWORD, + wcProvChar: [WCHAR; 1], +}} +pub type LPCOMMPROP = *mut COMMPROP; +STRUCT!{struct COMSTAT { + BitFields: DWORD, + cbInQue: DWORD, + cbOutQue: DWORD, +}} +BITFIELD!{COMSTAT BitFields: DWORD [ + fCtsHold set_fCtsHold[0..1], + fDsrHold set_fDsrHold[1..2], + fRlsdHold set_fRlsdHold[2..3], + fXoffHold set_fXoffHold[3..4], + fXoffSent set_fXoffSent[4..5], + fEof set_fEof[5..6], + fTxim set_fTxim[6..7], + fReserved set_fReserved[7..32], +]} +pub type LPCOMSTAT = *mut COMSTAT; +pub const DTR_CONTROL_DISABLE: DWORD = 0x00; +pub const DTR_CONTROL_ENABLE: DWORD = 0x01; +pub const DTR_CONTROL_HANDSHAKE: DWORD = 0x02; +pub const RTS_CONTROL_DISABLE: DWORD = 0x00; +pub const RTS_CONTROL_ENABLE: DWORD = 0x01; +pub const RTS_CONTROL_HANDSHAKE: DWORD = 0x02; +pub const RTS_CONTROL_TOGGLE: DWORD = 0x03; +STRUCT!{struct DCB { + DCBlength: DWORD, + BaudRate: DWORD, + BitFields: DWORD, + wReserved: WORD, + XonLim: WORD, + XoffLim: WORD, + ByteSize: BYTE, + Parity: BYTE, + StopBits: BYTE, + XonChar: c_char, + XoffChar: c_char, + ErrorChar: c_char, + EofChar: c_char, + EvtChar: c_char, + wReserved1: WORD, +}} +BITFIELD!{DCB BitFields: DWORD [ + fBinary set_fBinary[0..1], + fParity set_fParity[1..2], + fOutxCtsFlow set_fOutxCtsFlow[2..3], + fOutxDsrFlow set_fOutxDsrFlow[3..4], + fDtrControl set_fDtrControl[4..6], + fDsrSensitivity set_fDsrSensitivity[6..7], + fTXContinueOnXoff set_fTXContinueOnXoff[7..8], + fOutX set_fOutX[8..9], + fInX set_fInX[9..10], + fErrorChar set_fErrorChar[10..11], + fNull set_fNull[11..12], + fRtsControl set_fRtsControl[12..14], + fAbortOnError set_fAbortOnError[14..15], + fDummy2 set_fDummy2[15..32], +]} +pub type LPDCB = *mut DCB; +STRUCT!{struct COMMTIMEOUTS { + ReadIntervalTimeout: DWORD, + ReadTotalTimeoutMultiplier: DWORD, + ReadTotalTimeoutConstant: DWORD, + WriteTotalTimeoutMultiplier: DWORD, + WriteTotalTimeoutConstant: DWORD, +}} +pub type LPCOMMTIMEOUTS = *mut COMMTIMEOUTS; +STRUCT!{struct COMMCONFIG { + dwSize: DWORD, + wVersion: WORD, + wReserved: WORD, + dcb: DCB, + dwProviderSubType: DWORD, + dwProviderOffset: DWORD, + dwProviderSize: DWORD, + wcProviderData: [WCHAR; 1], +}} +pub type LPCOMMCONFIG = *mut COMMCONFIG; +pub const GMEM_FIXED: UINT = 0x0000; +pub const GMEM_MOVEABLE: UINT = 0x0002; +pub const GMEM_NOCOMPACT: UINT = 0x0010; +pub const GMEM_NODISCARD: UINT = 0x0020; +pub const GMEM_ZEROINIT: UINT = 0x0040; +pub const GMEM_MODIFY: UINT = 0x0080; +pub const GMEM_DISCARDABLE: UINT = 0x0100; +pub const GMEM_NOT_BANKED: UINT = 0x1000; +pub const GMEM_SHARE: UINT = 0x2000; +pub const GMEM_DDESHARE: UINT = 0x2000; +pub const GMEM_NOTIFY: UINT = 0x4000; +pub const GMEM_LOWER: UINT = GMEM_NOT_BANKED; +pub const GMEM_VALID_FLAGS: UINT = 0x7F72; +pub const GMEM_INVALID_HANDLE: UINT = 0x8000; +pub const GHND: UINT = GMEM_MOVEABLE | GMEM_ZEROINIT; +pub const GPTR: UINT = GMEM_FIXED | GMEM_ZEROINIT; +pub const GMEM_DISCARDED: UINT = 0x4000; +pub const GMEM_LOCKCOUNT: UINT = 0x00FF; +STRUCT!{struct MEMORYSTATUS { + dwLength: DWORD, + dwMemoryLoad: DWORD, + dwTotalPhys: SIZE_T, + dwAvailPhys: SIZE_T, + dwTotalPageFile: SIZE_T, + dwAvailPageFile: SIZE_T, + dwTotalVirtual: SIZE_T, + dwAvailVirtual: SIZE_T, +}} +pub type LPMEMORYSTATUS = *mut MEMORYSTATUS; +// NUMA_NO_PREFERRED_NODE +pub const DEBUG_PROCESS: DWORD = 0x00000001; +pub const DEBUG_ONLY_THIS_PROCESS: DWORD = 0x00000002; +pub const CREATE_SUSPENDED: DWORD = 0x00000004; +pub const DETACHED_PROCESS: DWORD = 0x00000008; +pub const CREATE_NEW_CONSOLE: DWORD = 0x00000010; +pub const NORMAL_PRIORITY_CLASS: DWORD = 0x00000020; +pub const IDLE_PRIORITY_CLASS: DWORD = 0x00000040; +pub const HIGH_PRIORITY_CLASS: DWORD = 0x00000080; +pub const REALTIME_PRIORITY_CLASS: DWORD = 0x00000100; +pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200; +pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400; +pub const CREATE_SEPARATE_WOW_VDM: DWORD = 0x00000800; +pub const CREATE_SHARED_WOW_VDM: DWORD = 0x00001000; +pub const CREATE_FORCEDOS: DWORD = 0x00002000; +pub const BELOW_NORMAL_PRIORITY_CLASS: DWORD = 0x00004000; +pub const ABOVE_NORMAL_PRIORITY_CLASS: DWORD = 0x00008000; +pub const INHERIT_PARENT_AFFINITY: DWORD = 0x00010000; +pub const INHERIT_CALLER_PRIORITY: DWORD = 0x00020000; +pub const CREATE_PROTECTED_PROCESS: DWORD = 0x00040000; +pub const EXTENDED_STARTUPINFO_PRESENT: DWORD = 0x00080000; +pub const PROCESS_MODE_BACKGROUND_BEGIN: DWORD = 0x00100000; +pub const PROCESS_MODE_BACKGROUND_END: DWORD = 0x00200000; +pub const CREATE_BREAKAWAY_FROM_JOB: DWORD = 0x01000000; +pub const CREATE_PRESERVE_CODE_AUTHZ_LEVEL: DWORD = 0x02000000; +pub const CREATE_DEFAULT_ERROR_MODE: DWORD = 0x04000000; +pub const CREATE_NO_WINDOW: DWORD = 0x08000000; +pub const PROFILE_USER: DWORD = 0x10000000; +pub const PROFILE_KERNEL: DWORD = 0x20000000; +pub const PROFILE_SERVER: DWORD = 0x40000000; +pub const CREATE_IGNORE_SYSTEM_DEFAULT: DWORD = 0x80000000; +// STACK_SIZE_PARAM_IS_A_RESERVATION +pub const THREAD_PRIORITY_LOWEST: DWORD = THREAD_BASE_PRIORITY_MIN; +pub const THREAD_PRIORITY_BELOW_NORMAL: DWORD = THREAD_PRIORITY_LOWEST + 1; +pub const THREAD_PRIORITY_NORMAL: DWORD = 0; +pub const THREAD_PRIORITY_HIGHEST: DWORD = THREAD_BASE_PRIORITY_MAX; +pub const THREAD_PRIORITY_ABOVE_NORMAL: DWORD = THREAD_PRIORITY_HIGHEST - 1; +pub const THREAD_PRIORITY_ERROR_RETURN: DWORD = MAXLONG as u32; +pub const THREAD_PRIORITY_TIME_CRITICAL: DWORD = THREAD_BASE_PRIORITY_LOWRT; +pub const THREAD_PRIORITY_IDLE: DWORD = THREAD_BASE_PRIORITY_IDLE; +pub const THREAD_MODE_BACKGROUND_BEGIN: DWORD = 0x00010000; +pub const THREAD_MODE_BACKGROUND_END: DWORD = 0x00020000; +pub const VOLUME_NAME_DOS: DWORD = 0x0; +// VOLUME_NAME_* +// FILE_NAME_* +// JIT_DEBUG_* +pub const DRIVE_UNKNOWN: DWORD = 0; +pub const DRIVE_NO_ROOT_DIR: DWORD = 1; +pub const DRIVE_REMOVABLE: DWORD = 2; +pub const DRIVE_FIXED: DWORD = 3; +pub const DRIVE_REMOTE: DWORD = 4; +pub const DRIVE_CDROM: DWORD = 5; +pub const DRIVE_RAMDISK: DWORD = 6; +// pub fn GetFreeSpace(); +pub const FILE_TYPE_UNKNOWN: DWORD = 0x0000; +pub const FILE_TYPE_DISK: DWORD = 0x0001; +pub const FILE_TYPE_CHAR: DWORD = 0x0002; +pub const FILE_TYPE_PIPE: DWORD = 0x0003; +pub const FILE_TYPE_REMOTE: DWORD = 0x8000; +pub const STD_INPUT_HANDLE: DWORD = -10i32 as u32; +pub const STD_OUTPUT_HANDLE: DWORD = -11i32 as u32; +pub const STD_ERROR_HANDLE: DWORD = -12i32 as u32; +pub const NOPARITY: BYTE = 0; +pub const ODDPARITY: BYTE = 1; +pub const EVENPARITY: BYTE = 2; +pub const MARKPARITY: BYTE = 3; +pub const SPACEPARITY: BYTE = 4; +pub const ONESTOPBIT: BYTE = 0; +pub const ONE5STOPBITS: BYTE = 1; +pub const TWOSTOPBITS: BYTE = 2; +pub const IGNORE: DWORD = 0; +pub const INFINITE: DWORD = 0xFFFFFFFF; +pub const CBR_110: DWORD = 110; +pub const CBR_300: DWORD = 300; +pub const CBR_600: DWORD = 600; +pub const CBR_1200: DWORD = 1200; +pub const CBR_2400: DWORD = 2400; +pub const CBR_4800: DWORD = 4800; +pub const CBR_9600: DWORD = 9600; +pub const CBR_14400: DWORD = 14400; +pub const CBR_19200: DWORD = 19200; +pub const CBR_38400: DWORD = 38400; +pub const CBR_56000: DWORD = 56000; +pub const CBR_57600: DWORD = 57600; +pub const CBR_115200: DWORD = 115200; +pub const CBR_128000: DWORD = 128000; +pub const CBR_256000: DWORD = 256000; +// CE_* +// IE_* +// EV_* +pub const SETXOFF: DWORD = 1; +pub const SETXON: DWORD = 2; +pub const SETRTS: DWORD = 3; +pub const CLRRTS: DWORD = 4; +pub const SETDTR: DWORD = 5; +pub const CLRDTR: DWORD = 6; +pub const RESETDEV: DWORD = 7; +pub const SETBREAK: DWORD = 8; +pub const CLRBREAK: DWORD = 9; +pub const PURGE_TXABORT: DWORD = 0x0001; +pub const PURGE_RXABORT: DWORD = 0x0002; +pub const PURGE_TXCLEAR: DWORD = 0x0004; +pub const PURGE_RXCLEAR: DWORD = 0x0008; +pub const MS_CTS_ON: DWORD = 0x0010; +pub const MS_DSR_ON: DWORD = 0x0020; +pub const MS_RING_ON: DWORD = 0x0040; +pub const MS_RLSD_ON: DWORD = 0x0080; +// S_* +// NMPWAIT_* +// FS_* +// OF_* +pub const OFS_MAXPATHNAME: usize = 128; +STRUCT!{struct OFSTRUCT { + cBytes: BYTE, + fFixedDisk: BYTE, + nErrCode: WORD, + Reserved1: WORD, + Reserved2: WORD, + szPathName: [CHAR; OFS_MAXPATHNAME], +}} +pub type POFSTRUCT = *mut OFSTRUCT; +pub type LPOFSTRUCT = *mut OFSTRUCT; +extern "system" { + pub fn GlobalAlloc( + uFlags: UINT, + dwBytes: SIZE_T, + ) -> HGLOBAL; + pub fn GlobalReAlloc( + hMem: HGLOBAL, + dwBytes: SIZE_T, + uFlags: UINT, + ) -> HGLOBAL; + pub fn GlobalSize( + hMem: HGLOBAL, + ) -> SIZE_T; + pub fn GlobalFlags( + hMem: HGLOBAL, + ) -> UINT; + pub fn GlobalLock( + hMem: HGLOBAL, + ) -> LPVOID; + pub fn GlobalHandle( + pMem: LPCVOID, + ) -> HGLOBAL; + pub fn GlobalUnlock( + hMem: HGLOBAL, + ) -> BOOL; + pub fn GlobalFree( + hMem: HGLOBAL, + ) -> HGLOBAL; + pub fn GlobalCompact( + dwMinFree: DWORD, + ) -> SIZE_T; + pub fn GlobalFix( + hMem: HGLOBAL, + ); + pub fn GlobalUnfix( + hMem: HGLOBAL, + ); + pub fn GlobalWire( + hMem: HGLOBAL, + ) -> LPVOID; + pub fn GlobalUnWire( + hMem: HGLOBAL, + ) -> BOOL; + pub fn GlobalMemoryStatus( + lpBuffer: LPMEMORYSTATUS, + ); + pub fn LocalAlloc( + uFlags: UINT, + uBytes: SIZE_T, + ) -> HLOCAL; + pub fn LocalReAlloc( + hMem: HLOCAL, + uBytes: SIZE_T, + uFlags: UINT, + ) -> HLOCAL; + pub fn LocalLock( + hMem: HLOCAL, + ) -> LPVOID; + pub fn LocalHandle( + pMem: LPCVOID, + ) -> HLOCAL; + pub fn LocalUnlock( + hMem: HLOCAL, + ) -> BOOL; + pub fn LocalSize( + hMem: HLOCAL, + ) -> SIZE_T; + pub fn LocalFlags( + hMem: HLOCAL, + ) -> UINT; + pub fn LocalFree( + hMem: HLOCAL, + ) -> HLOCAL; + pub fn LocalShrink( + hMem: HLOCAL, + cbNewSize: UINT, + ) -> SIZE_T; + pub fn LocalCompact( + uMinFree: UINT, + ) -> SIZE_T; +} +// SCS_* +extern "system" { + pub fn GetBinaryTypeA( + lpApplicationName: LPCSTR, + lpBinaryType: LPDWORD, + ) -> BOOL; + pub fn GetBinaryTypeW( + lpApplicationName: LPCWSTR, + lpBinaryType: LPDWORD, + ) -> BOOL; + pub fn GetShortPathNameA( + lpszLongPath: LPCSTR, + lpszShortPath: LPSTR, + cchBuffer: DWORD, + ) -> DWORD; + pub fn GetLongPathNameTransactedA( + lpszShortPath: LPCSTR, + lpszLongPath: LPSTR, + cchBuffer: DWORD, + hTransaction: HANDLE, + ) -> DWORD; + pub fn GetLongPathNameTransactedW( + lpszShortPath: LPCWSTR, + lpszLongPath: LPWSTR, + cchBuffer: DWORD, + hTransaction: HANDLE, + ) -> DWORD; + pub fn GetProcessAffinityMask( + hProcess: HANDLE, + lpProcessAffinityMask: PDWORD_PTR, + lpSystemAffinityMask: PDWORD_PTR, + ) -> BOOL; + pub fn SetProcessAffinityMask( + hProcess: HANDLE, + dwProcessAffinityMask: DWORD, + ) -> BOOL; + pub fn GetProcessIoCounters( + hProcess: HANDLE, + lpIoCounters: PIO_COUNTERS, + ) -> BOOL; + pub fn GetProcessWorkingSetSize( + hProcess: HANDLE, + lpMinimumWorkingSetSize: PSIZE_T, + lpMaximumWorkingSetSize: PSIZE_T, + ) -> BOOL; + pub fn SetProcessWorkingSetSize( + hProcess: HANDLE, + dwMinimumWorkingSetSize: SIZE_T, + dwMaximumWorkingSetSize: SIZE_T, + ) -> BOOL; + pub fn FatalExit( + ExitCode: c_int, + ); + pub fn SetEnvironmentStringsA( + NewEnvironment: LPCH, + ) -> BOOL; + pub fn SwitchToFiber( + lpFiber: LPVOID, + ); + pub fn DeleteFiber( + lpFiber: LPVOID, + ); + pub fn ConvertFiberToThread() -> BOOL; + pub fn CreateFiberEx( + dwStackCommitSize: SIZE_T, + dwStackReserveSize: SIZE_T, + dwFlags: DWORD, + lpStartAddress: LPFIBER_START_ROUTINE, + lpParameter: LPVOID, + ) -> LPVOID; + pub fn ConvertThreadToFiberEx( + lpParameter: LPVOID, + dwFlags: DWORD, + ) -> LPVOID; + pub fn CreateFiber( + dwStackSize: SIZE_T, + lpStartAddress: LPFIBER_START_ROUTINE, + lpParameter: LPVOID, + ) -> LPVOID; + pub fn ConvertThreadToFiber( + lpParameter: LPVOID, + ) -> LPVOID; +} +pub type PUMS_CONTEXT = *mut c_void; +pub type PUMS_COMPLETION_LIST = *mut c_void; +pub type UMS_THREAD_INFO_CLASS = RTL_UMS_THREAD_INFO_CLASS; +pub type PUMS_THREAD_INFO_CLASS = *mut UMS_THREAD_INFO_CLASS; +pub type PUMS_SCHEDULER_ENTRY_POINT = PRTL_UMS_SCHEDULER_ENTRY_POINT; +STRUCT!{struct UMS_SCHEDULER_STARTUP_INFO { + UmsVersion: ULONG, + CompletionList: PUMS_COMPLETION_LIST, + SchedulerProc: PUMS_SCHEDULER_ENTRY_POINT, + SchedulerParam: PVOID, +}} +pub type PUMS_SCHEDULER_STARTUP_INFO = *mut UMS_SCHEDULER_STARTUP_INFO; +STRUCT!{struct UMS_SYSTEM_THREAD_INFORMATION { + UmsVersion: ULONG, + ThreadUmsFlags: ULONG, +}} +BITFIELD!{UMS_SYSTEM_THREAD_INFORMATION ThreadUmsFlags: ULONG [ + IsUmsSchedulerThread set_IsUmsSchedulerThread[0..1], + IsUmsWorkerThread set_IsUmsWorkerThread[1..2], +]} +pub type PUMS_SYSTEM_THREAD_INFORMATION = *mut UMS_SYSTEM_THREAD_INFORMATION; +extern "system" { + #[cfg(target_pointer_width = "64")] + pub fn CreateUmsCompletionList( + UmsCompletionList: *mut PUMS_COMPLETION_LIST, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn DequeueUmsCompletionListItems( + UmsCompletionList: PUMS_COMPLETION_LIST, + WaitTimeOut: DWORD, + UmsThreadList: *mut PUMS_CONTEXT, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn GetUmsCompletionListEvent( + UmsCompletionList: PUMS_COMPLETION_LIST, + UmsCompletionEvent: PHANDLE, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn ExecuteUmsThread( + UmsThread: PUMS_CONTEXT, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn UmsThreadYield( + SchedulerParam: PVOID, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn DeleteUmsCompletionList( + UmsCompletionList: PUMS_COMPLETION_LIST, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn GetCurrentUmsThread() -> PUMS_CONTEXT; + #[cfg(target_pointer_width = "64")] + pub fn GetNextUmsListItem( + UmsContext: PUMS_CONTEXT, + ) -> PUMS_CONTEXT; + #[cfg(target_pointer_width = "64")] + pub fn QueryUmsThreadInformation( + UmsThread: PUMS_CONTEXT, + UmsThreadInfoClass: UMS_THREAD_INFO_CLASS, + UmsThreadInformation: PVOID, + UmsThreadInformationLength: ULONG, + ReturnLength: PULONG, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn SetUmsThreadInformation( + UmsThread: PUMS_CONTEXT, + UmsThreadInfoClass: UMS_THREAD_INFO_CLASS, + UmsThreadInformation: PVOID, + UmsThreadInformationLength: ULONG, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn DeleteUmsThreadContext( + UmsThread: PUMS_CONTEXT, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn CreateUmsThreadContext( + lpUmsThread: *mut PUMS_CONTEXT, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn EnterUmsSchedulingMode( + SchedulerStartupInfo: PUMS_SCHEDULER_STARTUP_INFO, + ) -> BOOL; + #[cfg(target_pointer_width = "64")] + pub fn GetUmsSystemThreadInformation( + ThreadHandle: HANDLE, + SystemThreadInfo: PUMS_SYSTEM_THREAD_INFORMATION, + ) -> BOOL; + pub fn SetThreadAffinityMask( + hThread: HANDLE, + dwThreadAffinityMask: DWORD_PTR, + ) -> DWORD_PTR; + pub fn SetProcessDEPPolicy( + dwFlags: DWORD, + ) -> BOOL; + pub fn GetProcessDEPPolicy( + hProcess: HANDLE, + lpFlags: LPDWORD, + lpPermanent: PBOOL, + ) -> BOOL; + pub fn RequestWakeupLatency( + latency: LATENCY_TIME, + ) -> BOOL; + pub fn IsSystemResumeAutomatic() -> BOOL; + pub fn GetThreadSelectorEntry( + hThread: HANDLE, + dwSelector: DWORD, + lpSelectorEntry: LPLDT_ENTRY, + ) -> BOOL; + pub fn SetThreadExecutionState( + esFlags: EXECUTION_STATE, + ) -> EXECUTION_STATE; + pub fn PowerCreateRequest( + Context: PREASON_CONTEXT, + ) -> HANDLE; + pub fn PowerSetRequest( + PowerRequest: HANDLE, + RequestType: POWER_REQUEST_TYPE, + ) -> BOOL; + pub fn PowerClearRequest( + PowerRequest: HANDLE, + RequestType: POWER_REQUEST_TYPE, + ) -> BOOL; + pub fn RestoreLastError( + dwErrCode: DWORD, + ); +} +pub const FILE_SKIP_COMPLETION_PORT_ON_SUCCESS: UCHAR = 0x1; +pub const FILE_SKIP_SET_EVENT_ON_HANDLE: UCHAR = 0x2; +extern "system" { + pub fn SetFileCompletionNotificationModes( + FileHandle: HANDLE, + Flags: UCHAR, + ) -> BOOL; +} +pub const SEM_FAILCRITICALERRORS: UINT = 0x0001; +pub const SEM_NOGPFAULTERRORBOX: UINT = 0x0002; +pub const SEM_NOALIGNMENTFAULTEXCEPT: UINT = 0x0004; +pub const SEM_NOOPENFILEERRORBOX: UINT = 0x8000; +extern "system" { + pub fn Wow64GetThreadContext( + hThread: HANDLE, + lpContext: PWOW64_CONTEXT, + ) -> BOOL; + pub fn Wow64SetThreadContext( + hThread: HANDLE, + lpContext: *const WOW64_CONTEXT, + ) -> BOOL; + pub fn Wow64GetThreadSelectorEntry( + hThread: HANDLE, + dwSelector: DWORD, + lpSelectorEntry: PWOW64_LDT_ENTRY, + ) -> BOOL; + pub fn Wow64SuspendThread( + hThread: HANDLE, + ) -> DWORD; + pub fn DebugSetProcessKillOnExit( + KillOnExit: BOOL, + ) -> BOOL; + pub fn DebugBreakProcess( + Process: HANDLE, + ) -> BOOL; + pub fn PulseEvent( + hEvent: HANDLE, + ) -> BOOL; + pub fn GlobalDeleteAtom( + nAtom: ATOM, + ) -> ATOM; + pub fn InitAtomTable( + nSize: DWORD, + ) -> BOOL; + pub fn DeleteAtom( + nAtom: ATOM, + ) -> ATOM; + pub fn SetHandleCount( + uNumber: UINT, + ) -> UINT; + pub fn RequestDeviceWakeup( + hDevice: HANDLE, + ) -> BOOL; + pub fn CancelDeviceWakeupRequest( + hDevice: HANDLE, + ) -> BOOL; + pub fn GetDevicePowerState( + hDevice: HANDLE, + pfOn: *mut BOOL, + ) -> BOOL; + pub fn SetMessageWaitingIndicator( + hMsgIndicator: HANDLE, + ulMsgCount: ULONG, + ) -> BOOL; + pub fn SetFileShortNameA( + hFile: HANDLE, + lpShortName: LPCSTR, + ) -> BOOL; + pub fn SetFileShortNameW( + hFile: HANDLE, + lpShortName: LPCWSTR, + ) -> BOOL; +} +pub const HANDLE_FLAG_INHERIT: DWORD = 0x00000001; +pub const HANDLE_FLAG_PROTECT_FROM_CLOSE: DWORD = 0x00000002; +extern "system" { + pub fn LoadModule( + lpModuleName: LPCSTR, + lpParameterBlock: LPVOID, + ) -> DWORD; + pub fn WinExec( + lpCmdLine: LPCSTR, + uCmdShow: UINT, + ) -> UINT; + // ClearCommBreak + // ClearCommError + // SetupComm + // EscapeCommFunction + // GetCommConfig + // GetCommMask + // GetCommProperties + // GetCommModemStatus + // GetCommState + // GetCommTimeouts + // PurgeComm + // SetCommBreak + // SetCommConfig + // SetCommMask + // SetCommState + // SetCommTimeouts + // TransmitCommChar + // WaitCommEvent + pub fn SetTapePosition( + hDevice: HANDLE, + dwPositionMethod: DWORD, + dwPartition: DWORD, + dwOffsetLow: DWORD, + dwOffsetHigh: DWORD, + bImmediate: BOOL, + ) -> DWORD; + pub fn GetTapePosition( + hDevice: HANDLE, + dwPositionType: DWORD, + lpdwPartition: LPDWORD, + lpdwOffsetLow: LPDWORD, + lpdwOffsetHigh: LPDWORD, + ) -> DWORD; + pub fn PrepareTape( + hDevice: HANDLE, + dwOperation: DWORD, + bImmediate: BOOL, + ) -> DWORD; + pub fn EraseTape( + hDevice: HANDLE, + dwEraseType: DWORD, + bImmediate: BOOL, + ) -> DWORD; + pub fn CreateTapePartition( + hDevice: HANDLE, + dwPartitionMethod: DWORD, + dwCount: DWORD, + dwSize: DWORD, + ) -> DWORD; + pub fn WriteTapemark( + hDevice: HANDLE, + dwTapemarkType: DWORD, + dwTapemarkCount: DWORD, + bImmediate: BOOL, + ) -> DWORD; + pub fn GetTapeStatus( + hDevice: HANDLE, + ) -> DWORD; + pub fn GetTapeParameters( + hDevice: HANDLE, + dwOperation: DWORD, + lpdwSize: LPDWORD, + lpTapeInformation: LPVOID, + ) -> DWORD; + pub fn SetTapeParameters( + hDevice: HANDLE, + dwOperation: DWORD, + lpTapeInformation: LPVOID, + ) -> DWORD; + pub fn MulDiv( + nNumber: c_int, + nNumerator: c_int, + nDenominator: c_int, + ) -> c_int; +} +ENUM!{enum DEP_SYSTEM_POLICY_TYPE { + DEPPolicyAlwaysOff = 0, + DEPPolicyAlwaysOn, + DEPPolicyOptIn, + DEPPolicyOptOut, + DEPTotalPolicyCount, +}} +extern "system" { + pub fn GetSystemDEPPolicy() -> DEP_SYSTEM_POLICY_TYPE; + pub fn GetSystemRegistryQuota( + pdwQuotaAllowed: PDWORD, + pdwQuotaUsed: PDWORD, + ) -> BOOL; + pub fn FileTimeToDosDateTime( + lpFileTime: *const FILETIME, + lpFatDate: LPWORD, + lpFatTime: LPWORD, + ) -> BOOL; + pub fn DosDateTimeToFileTime( + wFatDate: WORD, + wFatTime: WORD, + lpFileTime: LPFILETIME, + ) -> BOOL; + pub fn FormatMessageA( + dwFlags: DWORD, + lpSource: LPCVOID, + dwMessageId: DWORD, + dwLanguageId: DWORD, + lpBuffer: LPSTR, + nSize: DWORD, + Arguments: *mut va_list, + ) -> DWORD; + pub fn FormatMessageW( + dwFlags: DWORD, + lpSource: LPCVOID, + dwMessageId: DWORD, + dwLanguageId: DWORD, + lpBuffer: LPWSTR, + nSize: DWORD, + Arguments: *mut va_list, + ) -> DWORD; +} +pub const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200; +pub const FORMAT_MESSAGE_FROM_STRING: DWORD = 0x00000400; +pub const FORMAT_MESSAGE_FROM_HMODULE: DWORD = 0x00000800; +pub const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000; +pub const FORMAT_MESSAGE_ARGUMENT_ARRAY: DWORD = 0x00002000; +pub const FORMAT_MESSAGE_MAX_WIDTH_MASK: DWORD = 0x000000FF; +pub const FORMAT_MESSAGE_ALLOCATE_BUFFER: DWORD = 0x00000100; +extern "system" { + pub fn CreateMailslotA( + lpName: LPCSTR, + nMaxMessageSize: DWORD, + lReadTimeout: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> HANDLE; + pub fn CreateMailslotW( + lpName: LPCWSTR, + nMaxMessageSize: DWORD, + lReadTimeout: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> HANDLE; + pub fn GetMailslotInfo( + hMailslot: HANDLE, + lpMaxMessageSize: LPDWORD, + lpNextSize: LPDWORD, + lpMessageCount: LPDWORD, + lpReadTimeout: LPDWORD, + ) -> BOOL; + pub fn SetMailslotInfo( + hMailslot: HANDLE, + lReadTimeout: DWORD, + ) -> BOOL; + // pub fn EncryptFileA(); + // pub fn EncryptFileW(); + // pub fn DecryptFileA(); + // pub fn DecryptFileW(); + // pub fn FileEncryptionStatusA(); + // pub fn FileEncryptionStatusW(); + // pub fn OpenEncryptedFileRawA(); + // pub fn OpenEncryptedFileRawW(); + // pub fn ReadEncryptedFileRaw(); + // pub fn WriteEncryptedFileRaw(); + // pub fn CloseEncryptedFileRaw(); + pub fn lstrcmpA( + lpString1: LPCSTR, + lpString2: LPCSTR, + ) -> c_int; + pub fn lstrcmpW( + lpString1: LPCWSTR, + lpString2: LPCWSTR, + ) -> c_int; + pub fn lstrcmpiA( + lpString1: LPCSTR, + lpString2: LPCSTR, + ) -> c_int; + pub fn lstrcmpiW( + lpString1: LPCWSTR, + lpString2: LPCWSTR, + ) -> c_int; + pub fn lstrcpynA( + lpString1: LPSTR, + lpString2: LPCSTR, + iMaxLength: c_int, + ) -> LPSTR; + pub fn lstrcpynW( + lpString1: LPWSTR, + lpString2: LPCWSTR, + iMaxLength: c_int, + ) -> LPWSTR; + pub fn lstrcpyA( + lpString1: LPSTR, + lpString2: LPCSTR, + ) -> LPSTR; + pub fn lstrcpyW( + lpString1: LPWSTR, + lpString2: LPCWSTR, + ) -> LPWSTR; + pub fn lstrcatA( + lpString1: LPSTR, + lpString2: LPCSTR, + ) -> LPSTR; + pub fn lstrcatW( + lpString1: LPWSTR, + lpString2: LPCWSTR, + ) -> LPWSTR; + pub fn lstrlenA( + lpString: LPCSTR, + ) -> c_int; + pub fn lstrlenW( + lpString: LPCWSTR, + ) -> c_int; + pub fn OpenFile( + lpFileName: LPCSTR, + lpReOpenBuff: LPOFSTRUCT, + uStyle: UINT, + ) -> HFILE; + pub fn _lopen( + lpPathName: LPCSTR, + iReadWrite: c_int, + ) -> HFILE; + pub fn _lcreat( + lpPathName: LPCSTR, + iAttrubute: c_int, + ) -> HFILE; + pub fn _lread( + hFile: HFILE, + lpBuffer: LPVOID, + uBytes: UINT, + ) -> UINT; + pub fn _lwrite( + hFile: HFILE, + lpBuffer: LPCCH, + uBytes: UINT, + ) -> UINT; + pub fn _hread( + hFile: HFILE, + lpBuffer: LPVOID, + lBytes: c_long, + ) -> c_long; + pub fn _hwrite( + hFile: HFILE, + lpBuffer: LPCCH, + lBytes: c_long, + ) -> c_long; + pub fn _lclose( + hFile: HFILE, + ) -> HFILE; + pub fn _llseek( + hFile: HFILE, + lOffset: LONG, + iOrigin: c_int, + ) -> LONG; + // pub fn IsTextUnicode(); + // pub fn SignalObjectAndWait(); + pub fn BackupRead( + hFile: HANDLE, + lpBuffer: LPBYTE, + nNumberOfBytesToRead: DWORD, + lpNumberOfBytesRead: LPDWORD, + bAbort: BOOL, + bProcessSecurity: BOOL, + lpContext: *mut LPVOID, + ) -> BOOL; + pub fn BackupSeek( + hFile: HANDLE, + dwLowBytesToSeek: DWORD, + dwHighBytesToSeek: DWORD, + lpdwLowByteSeeked: LPDWORD, + lpdwHighByteSeeked: LPDWORD, + lpContext: *mut LPVOID, + ) -> BOOL; + pub fn BackupWrite( + hFile: HANDLE, + lpBuffer: LPBYTE, + nNumberOfBytesToWrite: DWORD, + lpNumberOfBytesWritten: LPDWORD, + bAbort: BOOL, + bProcessSecurity: BOOL, + lpContext: *mut LPVOID, + ) -> BOOL; +} +//2886 +pub const STARTF_USESHOWWINDOW: DWORD = 0x00000001; +pub const STARTF_USESIZE: DWORD = 0x00000002; +pub const STARTF_USEPOSITION: DWORD = 0x00000004; +pub const STARTF_USECOUNTCHARS: DWORD = 0x00000008; +pub const STARTF_USEFILLATTRIBUTE: DWORD = 0x00000010; +pub const STARTF_RUNFULLSCREEN: DWORD = 0x00000020; +pub const STARTF_FORCEONFEEDBACK: DWORD = 0x00000040; +pub const STARTF_FORCEOFFFEEDBACK: DWORD = 0x00000080; +pub const STARTF_USESTDHANDLES: DWORD = 0x00000100; +pub const STARTF_USEHOTKEY: DWORD = 0x00000200; +pub const STARTF_TITLEISLINKNAME: DWORD = 0x00000800; +pub const STARTF_TITLEISAPPID: DWORD = 0x00001000; +pub const STARTF_PREVENTPINNING: DWORD = 0x00002000; +pub const STARTF_UNTRUSTEDSOURCE: DWORD = 0x00008000; +STRUCT!{struct STARTUPINFOEXA { + StartupInfo: STARTUPINFOA, + lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, +}} +pub type LPSTARTUPINFOEXA = *mut STARTUPINFOEXA; +STRUCT!{struct STARTUPINFOEXW { + StartupInfo: STARTUPINFOW, + lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, +}} +pub type LPSTARTUPINFOEXW = *mut STARTUPINFOEXW; +extern "system" { + pub fn OpenMutexA( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpName: LPCSTR, + ) -> HANDLE; + pub fn CreateSemaphoreA( + lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, + lInitialCount: LONG, + lMaximumCount: LONG, + lpName: LPCSTR, + ) -> HANDLE; + pub fn OpenSemaphoreA( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpName: LPCSTR, + ) -> HANDLE; + pub fn CreateWaitableTimerA( + lpTimerAttributes: LPSECURITY_ATTRIBUTES, + bManualReset: BOOL, + lpTimerName: LPCSTR, + ) -> HANDLE; + pub fn OpenWaitableTimerA( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpTimerName: LPCSTR, + ) -> HANDLE; + pub fn CreateSemaphoreExA( + lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, + lInitialCount: LONG, + lMaximumCount: LONG, + lpName: LPCSTR, + dwFlags: DWORD, + dwDesiredAccess: DWORD, + ) -> HANDLE; + pub fn CreateWaitableTimerExA( + lpTimerAttributes: LPSECURITY_ATTRIBUTES, + lpTimerName: LPCSTR, + dwFlags: DWORD, + dwDesiredAccess: DWORD, + ) -> HANDLE; + pub fn CreateFileMappingA( + hFile: HANDLE, + lpAttributes: LPSECURITY_ATTRIBUTES, + flProtect: DWORD, + dwMaximumSizeHigh: DWORD, + dwMaximumSizeLow: DWORD, + lpName: LPCSTR, + ) -> HANDLE; + pub fn CreateFileMappingNumaA( + hFile: HANDLE, + lpFileMappingAttributes: LPSECURITY_ATTRIBUTES, + flProtect: DWORD, + dwMaximumSizeHigh: DWORD, + dwMaximumSizeLow: DWORD, + lpName: LPCSTR, + nndPreferred: DWORD, + ) -> HANDLE; + pub fn OpenFileMappingA( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpName: LPCSTR, + ) -> HANDLE; + pub fn GetLogicalDriveStringsA( + nBufferLength: DWORD, + lpBuffer: LPSTR, + ) -> DWORD; + pub fn LoadPackagedLibrary( + lpwLibFileName: LPCWSTR, + Reserved: DWORD, + ) -> HMODULE; + pub fn QueryFullProcessImageNameA( + hProcess: HANDLE, + dwFlags: DWORD, + lpExeName: LPSTR, + lpdwSize: PDWORD, + ) -> BOOL; + pub fn QueryFullProcessImageNameW( + hProcess: HANDLE, + dwFlags: DWORD, + lpExeName: LPWSTR, + lpdwSize: PDWORD, + ) -> BOOL; +} +//3233 +extern "system" { + pub fn GetStartupInfoA( + lpStartupInfo: LPSTARTUPINFOA, + ); + pub fn GetFirmwareEnvironmentVariableA( + lpName: LPCSTR, + lpGuid: LPCSTR, + pBuffer: PVOID, + nSize: DWORD, + ) -> DWORD; + pub fn GetFirmwareEnvironmentVariableW( + lpName: LPCWSTR, + lpGuid: LPCWSTR, + pBuffer: PVOID, + nSize: DWORD, + ) -> DWORD; + pub fn GetFirmwareEnvironmentVariableExA( + lpName: LPCSTR, + lpGuid: LPCSTR, + pBuffer: PVOID, + nSize: DWORD, + pdwAttribubutes: PDWORD, + ) -> DWORD; + pub fn GetFirmwareEnvironmentVariableExW( + lpName: LPCWSTR, + lpGuid: LPCWSTR, + pBuffer: PVOID, + nSize: DWORD, + pdwAttribubutes: PDWORD, + ) -> DWORD; + pub fn SetFirmwareEnvironmentVariableA( + lpName: LPCSTR, + lpGuid: LPCSTR, + pValue: PVOID, + nSize: DWORD, + ) -> BOOL; + pub fn SetFirmwareEnvironmentVariableW( + lpName: LPCWSTR, + lpGuid: LPCWSTR, + pValue: PVOID, + nSize: DWORD, + ) -> BOOL; + pub fn SetFirmwareEnvironmentVariableExA( + lpName: LPCSTR, + lpGuid: LPCSTR, + pValue: PVOID, + nSize: DWORD, + dwAttributes: DWORD, + ) -> BOOL; + pub fn SetFirmwareEnvironmentVariableExW( + lpName: LPCWSTR, + lpGuid: LPCWSTR, + pValue: PVOID, + nSize: DWORD, + dwAttributes: DWORD, + ) -> BOOL; + pub fn GetFirmwareType( + FirmwareType: PFIRMWARE_TYPE, + ) -> BOOL; + pub fn IsNativeVhdBoot( + NativeVhdBoot: PBOOL, + ) -> BOOL; + pub fn FindResourceA( + hModule: HMODULE, + lpName: LPCSTR, + lpType: LPCSTR, + ) -> HRSRC; + pub fn FindResourceExA( + hModule: HMODULE, + lpName: LPCSTR, + lpType: LPCSTR, + wLanguage: WORD, + ) -> HRSRC; + pub fn EnumResourceTypesA( + hModule: HMODULE, + lpEnumFunc: ENUMRESTYPEPROCA, + lParam: LONG_PTR, + ) -> BOOL; + pub fn EnumResourceTypesW( + hModule: HMODULE, + lpEnumFunc: ENUMRESTYPEPROCW, + lParam: LONG_PTR, + ) -> BOOL; + pub fn EnumResourceNamesA( + hModule: HMODULE, + lpType: LPCSTR, + lpEnumFunc: ENUMRESNAMEPROCA, + lParam: LONG_PTR, + ) -> BOOL; + pub fn EnumResourceLanguagesA( + hModule: HMODULE, + lpType: LPCSTR, + lpName: LPCSTR, + lpEnumFunc: ENUMRESLANGPROCA, + lParam: LONG_PTR, + ) -> BOOL; + pub fn EnumResourceLanguagesW( + hModule: HMODULE, + lpType: LPCWSTR, + lpName: LPCWSTR, + lpEnumFunc: ENUMRESLANGPROCW, + lParam: LONG_PTR, + ) -> BOOL; + pub fn BeginUpdateResourceA( + pFileName: LPCSTR, + bDeleteExistingResources: BOOL, + ) -> HANDLE; + pub fn BeginUpdateResourceW( + pFileName: LPCWSTR, + bDeleteExistingResources: BOOL, + ) -> HANDLE; + pub fn UpdateResourceA( + hUpdate: HANDLE, + lpType: LPCSTR, + lpName: LPCSTR, + wLanguage: WORD, + lpData: LPVOID, + cb: DWORD, + ) -> BOOL; + pub fn UpdateResourceW( + hUpdate: HANDLE, + lpType: LPCWSTR, + lpName: LPCWSTR, + wLanguage: WORD, + lpData: LPVOID, + cb: DWORD, + ) -> BOOL; + pub fn EndUpdateResourceA( + hUpdate: HANDLE, + fDiscard: BOOL, + ) -> BOOL; + pub fn EndUpdateResourceW( + hUpdate: HANDLE, + fDiscard: BOOL, + ) -> BOOL; + pub fn GlobalAddAtomA( + lpString: LPCSTR, + ) -> ATOM; + pub fn GlobalAddAtomW( + lpString: LPCWSTR, + ) -> ATOM; + pub fn GlobalAddAtomExA( + lpString: LPCSTR, + Flags: DWORD, + ) -> ATOM; + pub fn GlobalAddAtomExW( + lpString: LPCWSTR, + Flags: DWORD, + ) -> ATOM; + pub fn GlobalFindAtomA( + lpString: LPCSTR, + ) -> ATOM; + pub fn GlobalFindAtomW( + lpString: LPCWSTR, + ) -> ATOM; + pub fn GlobalGetAtomNameA( + nAtom: ATOM, + lpBuffer: LPSTR, + nSize: c_int, + ) -> UINT; + pub fn GlobalGetAtomNameW( + nAtom: ATOM, + lpBuffer: LPWSTR, + nSize: c_int, + ) -> UINT; + pub fn AddAtomA( + lpString: LPCSTR, + ) -> ATOM; + pub fn AddAtomW( + lpString: LPCWSTR, + ) -> ATOM; + pub fn FindAtomA( + lpString: LPCSTR, + ) -> ATOM; + pub fn FindAtomW( + lpString: LPCWSTR, + ) -> ATOM; + pub fn GetAtomNameA( + nAtom: ATOM, + lpBuffer: LPSTR, + nSize: c_int, + ) -> UINT; + pub fn GetAtomNameW( + nAtom: ATOM, + lpBuffer: LPWSTR, + nSize: c_int, + ) -> UINT; + pub fn GetProfileIntA( + lpAppName: LPCSTR, + lpKeyName: LPCSTR, + nDefault: INT, + ) -> UINT; + pub fn GetProfileIntW( + lpAppName: LPCWSTR, + lpKeyName: LPCWSTR, + nDefault: INT, + ) -> UINT; + pub fn GetProfileStringA( + lpAppName: LPCSTR, + lpKeyName: LPCSTR, + lpDefault: LPCSTR, + lpReturnedString: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetProfileStringW( + lpAppName: LPCWSTR, + lpKeyName: LPCWSTR, + lpDefault: LPCWSTR, + lpReturnedString: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn WriteProfileStringA( + lpAppName: LPCSTR, + lpKeyName: LPCSTR, + lpString: LPCSTR, + ) -> BOOL; + pub fn WriteProfileStringW( + lpAppName: LPCWSTR, + lpKeyName: LPCWSTR, + lpString: LPCWSTR, + ) -> BOOL; + pub fn GetProfileSectionA( + lpAppName: LPCSTR, + lpReturnedString: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetProfileSectionW( + lpAppName: LPCWSTR, + lpReturnedString: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn WriteProfileSectionA( + lpAppName: LPCSTR, + lpString: LPCSTR, + ) -> BOOL; + pub fn WriteProfileSectionW( + lpAppName: LPCWSTR, + lpString: LPCWSTR, + ) -> BOOL; + pub fn GetPrivateProfileIntA( + lpAppName: LPCSTR, + lpKeyName: LPCSTR, + nDefault: INT, + lpFileName: LPCSTR, + ) -> UINT; + pub fn GetPrivateProfileIntW( + lpAppName: LPCWSTR, + lpKeyName: LPCWSTR, + nDefault: INT, + lpFileName: LPCWSTR, + ) -> UINT; + pub fn GetPrivateProfileStringA( + lpAppName: LPCSTR, + lpKeyName: LPCSTR, + lpDefault: LPCSTR, + lpReturnedString: LPSTR, + nSize: DWORD, + lpFileName: LPCSTR, + ) -> DWORD; + pub fn GetPrivateProfileStringW( + lpAppName: LPCWSTR, + lpKeyName: LPCWSTR, + lpDefault: LPCWSTR, + lpReturnedString: LPWSTR, + nSize: DWORD, + lpFileName: LPCWSTR, + ) -> DWORD; + pub fn WritePrivateProfileStringA( + lpAppName: LPCSTR, + lpKeyName: LPCSTR, + lpString: LPCSTR, + lpFileName: LPCSTR, + ) -> BOOL; + pub fn WritePrivateProfileStringW( + lpAppName: LPCWSTR, + lpKeyName: LPCWSTR, + lpString: LPCWSTR, + lpFileName: LPCWSTR, + ) -> BOOL; + pub fn GetPrivateProfileSectionA( + lpAppName: LPCSTR, + lpReturnedString: LPSTR, + nSize: DWORD, + lpFileName: LPCSTR, + ) -> DWORD; + pub fn GetPrivateProfileSectionW( + lpAppName: LPCWSTR, + lpReturnedString: LPWSTR, + nSize: DWORD, + lpFileName: LPCWSTR, + ) -> DWORD; + pub fn WritePrivateProfileSectionA( + lpAppName: LPCSTR, + lpString: LPCSTR, + lpFileName: LPCSTR, + ) -> BOOL; + pub fn WritePrivateProfileSectionW( + lpAppName: LPCWSTR, + lpString: LPCWSTR, + lpFileName: LPCWSTR, + ) -> BOOL; + pub fn GetPrivateProfileSectionNamesA( + lpszReturnBuffer: LPSTR, + nSize: DWORD, + lpFileName: LPCSTR, + ) -> DWORD; + pub fn GetPrivateProfileSectionNamesW( + lpszReturnBuffer: LPWSTR, + nSize: DWORD, + lpFileName: LPCWSTR, + ) -> DWORD; + pub fn GetPrivateProfileStructA( + lpszSection: LPCSTR, + lpszKey: LPCSTR, + lpStruct: LPVOID, + uSizeStruct: UINT, + szFile: LPCSTR, + ) -> BOOL; + pub fn GetPrivateProfileStructW( + lpszSection: LPCWSTR, + lpszKey: LPCWSTR, + lpStruct: LPVOID, + uSizeStruct: UINT, + szFile: LPCWSTR, + ) -> BOOL; + pub fn WritePrivateProfileStructA( + lpszSection: LPCSTR, + lpszKey: LPCSTR, + lpStruct: LPVOID, + uSizeStruct: UINT, + szFile: LPCSTR, + ) -> BOOL; + pub fn WritePrivateProfileStructW( + lpszSection: LPCWSTR, + lpszKey: LPCWSTR, + lpStruct: LPVOID, + uSizeStruct: UINT, + szFile: LPCWSTR, + ) -> BOOL; + pub fn Wow64EnableWow64FsRedirection( + Wow64FsEnableRedirection: BOOLEAN, + ) -> BOOLEAN; + pub fn SetDllDirectoryA( + lpPathName: LPCSTR, + ) -> BOOL; + pub fn SetDllDirectoryW( + lpPathName: LPCWSTR, + ) -> BOOL; + pub fn GetDllDirectoryA( + nBufferLength: DWORD, + lpBuffer: LPSTR, + ) -> DWORD; + pub fn GetDllDirectoryW( + nBufferLength: DWORD, + lpBuffer: LPWSTR, + ) -> DWORD; + pub fn SetSearchPathMode( + Flags: DWORD, + ) -> BOOL; + pub fn CreateDirectoryExA( + lpTemplateDirectory: LPCSTR, + lpNewDirectory: LPCSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> BOOL; + pub fn CreateDirectoryExW( + lpTemplateDirectory: LPCWSTR, + lpNewDirectory: LPCWSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> BOOL; + pub fn CreateDirectoryTransactedA( + lpTemplateDirectory: LPCSTR, + lpNewDirectory: LPCSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + hTransaction: HANDLE, + ) -> BOOL; + pub fn CreateDirectoryTransactedW( + lpTemplateDirectory: LPCWSTR, + lpNewDirectory: LPCWSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + hTransaction: HANDLE, + ) -> BOOL; + pub fn RemoveDirectoryTransactedA( + lpPathName: LPCSTR, + hTransaction: HANDLE, + ) -> BOOL; + pub fn RemoveDirectoryTransactedW( + lpPathName: LPCWSTR, + hTransaction: HANDLE, + ) -> BOOL; + pub fn GetFullPathNameTransactedA( + lpFileName: LPCSTR, + nBufferLength: DWORD, + lpBuffer: LPSTR, + lpFilePart: *mut LPSTR, + hTransaction: HANDLE, + ) -> DWORD; + pub fn GetFullPathNameTransactedW( + lpFileName: LPCWSTR, + nBufferLength: DWORD, + lpBuffer: LPWSTR, + lpFilePart: *mut LPWSTR, + hTransaction: HANDLE, + ); + pub fn DefineDosDeviceA( + dwFlags: DWORD, + lpDeviceName: LPCSTR, + lpTargetPath: LPCSTR, + ) -> BOOL; + pub fn QueryDosDeviceA( + lpDeviceName: LPCSTR, + lpTargetPath: LPSTR, + ucchMax: DWORD, + ) -> DWORD; + pub fn CreateFileTransactedA( + lpFileName: LPCSTR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, + hTemplateFile: HANDLE, + hTransaction: HANDLE, + pusMiniVersion: PUSHORT, + lpExtendedParameter: PVOID, + ) -> HANDLE; + pub fn CreateFileTransactedW( + lpFileName: LPCWSTR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, + hTemplateFile: HANDLE, + hTransaction: HANDLE, + pusMiniVersion: PUSHORT, + lpExtendedParameter: PVOID, + ) -> HANDLE; + pub fn ReOpenFile( + hOriginalFile: HANDLE, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + dwFlags: DWORD, + ) -> HANDLE; + pub fn SetFileAttributesTransactedA( + lpFileName: LPCSTR, + dwFileAttributes: DWORD, + hTransaction: HANDLE, + ) -> BOOL; + pub fn SetFileAttributesTransactedW( + lpFileName: LPCWSTR, + dwFileAttributes: DWORD, + hTransaction: HANDLE, + ) -> BOOL; + pub fn GetFileAttributesTransactedA( + lpFileName: LPCSTR, + fInfoLevelId: GET_FILEEX_INFO_LEVELS, + lpFileInformation: LPVOID, + hTransaction: HANDLE, + ) -> BOOL; + pub fn GetFileAttributesTransactedW( + lpFileName: LPCWSTR, + fInfoLevelId: GET_FILEEX_INFO_LEVELS, + lpFileInformation: LPVOID, + hTransaction: HANDLE, + ) -> BOOL; + pub fn GetCompressedFileSizeTransactedA( + lpFileName: LPCSTR, + lpFileSizeHigh: LPDWORD, + hTransaction: HANDLE, + ) -> DWORD; + pub fn GetCompressedFileSizeTransactedW( + lpFileName: LPCWSTR, + lpFileSizeHigh: LPDWORD, + hTransaction: HANDLE, + ); + pub fn DeleteFileTransactedA( + lpFileName: LPCSTR, + hTransaction: HANDLE, + ) -> BOOL; + pub fn DeleteFileTransactedW( + lpFileName: LPCWSTR, + hTransaction: HANDLE, + ) -> BOOL; + pub fn CheckNameLegalDOS8Dot3A( + lpName: LPCSTR, + lpOemName: LPSTR, + OemNameSize: DWORD, + pbNameContainsSpaces: PBOOL, + pbNameLegal: PBOOL, + ) -> BOOL; + pub fn CheckNameLegalDOS8Dot3W( + lpName: LPCWSTR, + lpOemName: LPSTR, + OemNameSize: DWORD, + pbNameContainsSpaces: PBOOL, + pbNameLegal: PBOOL, + ) -> BOOL; + pub fn FindFirstFileTransactedA( + lpFileName: LPCSTR, + fInfoLevelId: FINDEX_INFO_LEVELS, + lpFindFileData: LPVOID, + fSearchOp: FINDEX_SEARCH_OPS, + lpSearchFilter: LPVOID, + dwAdditionalFlags: DWORD, + hTransaction: HANDLE, + ) -> HANDLE; + pub fn FindFirstFileTransactedW( + lpFileName: LPCWSTR, + fInfoLevelId: FINDEX_INFO_LEVELS, + lpFindFileData: LPVOID, + fSearchOp: FINDEX_SEARCH_OPS, + lpSearchFilter: LPVOID, + dwAdditionalFlags: DWORD, + hTransaction: HANDLE, + ) -> HANDLE; + pub fn CopyFileA( + lpExistingFileName: LPCSTR, + lpNewFileName: LPCSTR, + bFailIfExists: BOOL, + ) -> BOOL; + pub fn CopyFileW( + lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + bFailIfExists: BOOL, + ) -> BOOL; +} +FN!{stdcall LPPROGRESS_ROUTINE( + TotalFileSize: LARGE_INTEGER, + TotalBytesTransferred: LARGE_INTEGER, + StreamSize: LARGE_INTEGER, + StreamBytesTransferred: LARGE_INTEGER, + dwStreamNumber: DWORD, + dwCallbackReason: DWORD, + hSourceFile: HANDLE, + hDestinationFile: HANDLE, + lpData: LPVOID, +) -> DWORD} +extern "system" { + pub fn CopyFileExA( + lpExistingFileName: LPCSTR, + lpNewFileName: LPCSTR, + lpProgressRoutine: LPPROGRESS_ROUTINE, + lpData: LPVOID, + pbCancel: LPBOOL, + dwCopyFlags: DWORD, + ) -> BOOL; + pub fn CopyFileExW( + lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + lpProgressRoutine: LPPROGRESS_ROUTINE, + lpData: LPVOID, + pbCancel: LPBOOL, + dwCopyFlags: DWORD, + ) -> BOOL; + pub fn CopyFileTransactedA( + lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + lpProgressRoutine: LPPROGRESS_ROUTINE, + lpData: LPVOID, + pbCancel: LPBOOL, + dwCopyFlags: DWORD, + hTransaction: HANDLE, + ) -> BOOL; + pub fn CopyFileTransactedW( + lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + lpProgressRoutine: LPPROGRESS_ROUTINE, + lpData: LPVOID, + pbCancel: LPBOOL, + dwCopyFlags: DWORD, + hTransaction: HANDLE, + ) -> BOOL; +} +ENUM!{enum COPYFILE2_MESSAGE_TYPE { + COPYFILE2_CALLBACK_NONE = 0, + COPYFILE2_CALLBACK_CHUNK_STARTED, + COPYFILE2_CALLBACK_CHUNK_FINISHED, + COPYFILE2_CALLBACK_STREAM_STARTED, + COPYFILE2_CALLBACK_STREAM_FINISHED, + COPYFILE2_CALLBACK_POLL_CONTINUE, + COPYFILE2_CALLBACK_ERROR, + COPYFILE2_CALLBACK_MAX, +}} +ENUM!{enum COPYFILE2_MESSAGE_ACTION { + COPYFILE2_PROGRESS_CONTINUE = 0, + COPYFILE2_PROGRESS_CANCEL, + COPYFILE2_PROGRESS_STOP, + COPYFILE2_PROGRESS_QUIET, + COPYFILE2_PROGRESS_PAUSE, +}} +ENUM!{enum COPYFILE2_COPY_PHASE { + COPYFILE2_PHASE_NONE = 0, + COPYFILE2_PHASE_PREPARE_SOURCE, + COPYFILE2_PHASE_PREPARE_DEST, + COPYFILE2_PHASE_READ_SOURCE, + COPYFILE2_PHASE_WRITE_DESTINATION, + COPYFILE2_PHASE_SERVER_COPY, + COPYFILE2_PHASE_NAMEGRAFT_COPY, + COPYFILE2_PHASE_MAX, +}} +STRUCT!{struct COPYFILE2_MESSAGE_ChunkStarted { + dwStreamNumber: DWORD, + dwReserved: DWORD, + hSourceFile: HANDLE, + hDestinationFile: HANDLE, + uliChunkNumber: ULARGE_INTEGER, + uliChunkSize: ULARGE_INTEGER, + uliStreamSize: ULARGE_INTEGER, + uliTotalFileSize: ULARGE_INTEGER, +}} +STRUCT!{struct COPYFILE2_MESSAGE_ChunkFinished { + dwStreamNumber: DWORD, + dwFlags: DWORD, + hSourceFile: HANDLE, + hDestinationFile: HANDLE, + uliChunkNumber: ULARGE_INTEGER, + uliChunkSize: ULARGE_INTEGER, + uliStreamSize: ULARGE_INTEGER, + uliStreamBytesTransferred: ULARGE_INTEGER, + uliTotalFileSize: ULARGE_INTEGER, + uliTotalBytesTransferred: ULARGE_INTEGER, +}} +STRUCT!{struct COPYFILE2_MESSAGE_StreamStarted { + dwStreamNumber: DWORD, + dwReserved: DWORD, + hSourceFile: HANDLE, + hDestinationFile: HANDLE, + uliStreamSize: ULARGE_INTEGER, + uliTotalFileSize: ULARGE_INTEGER, +}} +STRUCT!{struct COPYFILE2_MESSAGE_StreamFinished { + dwStreamNumber: DWORD, + dwReserved: DWORD, + hSourceFile: HANDLE, + hDestinationFile: HANDLE, + uliStreamSize: ULARGE_INTEGER, + uliStreamBytesTransferred: ULARGE_INTEGER, + uliTotalFileSize: ULARGE_INTEGER, + uliTotalBytesTransferred: ULARGE_INTEGER, +}} +STRUCT!{struct COPYFILE2_MESSAGE_PollContinue { + dwReserved: DWORD, +}} +STRUCT!{struct COPYFILE2_MESSAGE_Error { + CopyPhase: COPYFILE2_COPY_PHASE, + dwStreamNumber: DWORD, + hrFailure: HRESULT, + dwReserved: DWORD, + uliChunkNumber: ULARGE_INTEGER, + uliStreamSize: ULARGE_INTEGER, + uliStreamBytesTransferred: ULARGE_INTEGER, + uliTotalFileSize: ULARGE_INTEGER, + uliTotalBytesTransferred: ULARGE_INTEGER, +}} +UNION!{union COPYFILE2_MESSAGE_Info { + [u64; 8] [u64; 9], + ChunkStarted ChunkStarted_mut: COPYFILE2_MESSAGE_ChunkStarted, + ChunkFinished ChunkFinished_mut: COPYFILE2_MESSAGE_ChunkFinished, + StreamStarted StreamStarted_mut: COPYFILE2_MESSAGE_StreamStarted, + StreamFinished StreamFinished_mut: COPYFILE2_MESSAGE_StreamFinished, + PollContinue PollContinue_mut: COPYFILE2_MESSAGE_PollContinue, + Error Error_mut: COPYFILE2_MESSAGE_Error, +}} +STRUCT!{struct COPYFILE2_MESSAGE { + Type: COPYFILE2_MESSAGE_TYPE, + dwPadding: DWORD, + Info: COPYFILE2_MESSAGE_Info, +}} +FN!{stdcall PCOPYFILE2_PROGRESS_ROUTINE( + pMessage: *const COPYFILE2_MESSAGE, + pvCallbackContext: PVOID, +) -> COPYFILE2_MESSAGE_ACTION} +STRUCT!{struct COPYFILE2_EXTENDED_PARAMETERS { + dwSize: DWORD, + dwCopyFlags: DWORD, + pfCancel: *mut BOOL, + pProgressRoutine: PCOPYFILE2_PROGRESS_ROUTINE, + pvCallbackContext: PVOID, +}} +extern "system" { + pub fn CopyFile2( + pwszExistingFileName: PCWSTR, + pwszNewFileName: PCWSTR, + pExtendedParameters: *mut COPYFILE2_EXTENDED_PARAMETERS, + ) -> HRESULT; + pub fn MoveFileA( + lpExistingFileName: LPCSTR, + lpNewFileName: LPCSTR, + ) -> BOOL; + pub fn MoveFileW( + lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + ) -> BOOL; + pub fn MoveFileExA( + lpExistingFileName: LPCSTR, + lpNewFileName: LPCSTR, + dwFlags: DWORD, + ) -> BOOL; + pub fn MoveFileExW( + lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + dwFlags: DWORD, + ) -> BOOL; + pub fn MoveFileWithProgressA( + lpExistingFileName: LPCSTR, + lpNewFileName: LPCSTR, + lpProgressRoutine: LPPROGRESS_ROUTINE, + lpData: LPVOID, + dwFlags: DWORD, + ) -> BOOL; + pub fn MoveFileWithProgressW( + lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + lpProgressRoutine: LPPROGRESS_ROUTINE, + lpData: LPVOID, + dwFlags: DWORD, + ) -> BOOL; + pub fn MoveFileTransactedA( + lpExistingFileName: LPCSTR, + lpNewFileName: LPCSTR, + lpProgressRoutine: LPPROGRESS_ROUTINE, + lpData: LPVOID, + dwFlags: DWORD, + hTransaction: HANDLE, + ) -> BOOL; + pub fn MoveFileTransactedW( + lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + lpProgressRoutine: LPPROGRESS_ROUTINE, + lpData: LPVOID, + dwFlags: DWORD, + hTransaction: HANDLE, + ) -> BOOL; +} +pub const MOVEFILE_REPLACE_EXISTING: DWORD = 0x00000001; +pub const MOVEFILE_COPY_ALLOWED: DWORD = 0x00000002; +pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 0x00000004; +pub const MOVEFILE_WRITE_THROUGH: DWORD = 0x00000008; +pub const MOVEFILE_CREATE_HARDLINK: DWORD = 0x00000010; +pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 0x00000020; +extern "system" { + pub fn ReplaceFileA( + lpReplacedFileName: LPCSTR, + lpReplacementFileName: LPCSTR, + lpBackupFileName: LPCSTR, + dwReplaceFlags: DWORD, + lpExclude: LPVOID, + lpReserved: LPVOID, + ); + pub fn ReplaceFileW( + lpReplacedFileName: LPCWSTR, + lpReplacementFileName: LPCWSTR, + lpBackupFileName: LPCWSTR, + dwReplaceFlags: DWORD, + lpExclude: LPVOID, + lpReserved: LPVOID, + ); + pub fn CreateHardLinkA( + lpFileName: LPCSTR, + lpExistingFileName: LPCSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> BOOL; + pub fn CreateHardLinkW( + lpFileName: LPCWSTR, + lpExistingFileName: LPCWSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> BOOL; + pub fn CreateHardLinkTransactedA( + lpFileName: LPCSTR, + lpExistingFileName: LPCSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + hTransaction: HANDLE, + ) -> BOOL; + pub fn CreateHardLinkTransactedW( + lpFileName: LPCWSTR, + lpExistingFileName: LPCWSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + hTransaction: HANDLE, + ); + pub fn FindFirstStreamTransactedW( + lpFileName: LPCWSTR, + InfoLevel: STREAM_INFO_LEVELS, + lpFindStreamData: LPVOID, + dwFlags: DWORD, + hTransaction: HANDLE, + ) -> HANDLE; + pub fn FindFirstFileNameTransactedW( + lpFileName: LPCWSTR, + dwFlags: DWORD, + StringLength: LPDWORD, + LinkName: PWSTR, + hTransaction: HANDLE, + ) -> HANDLE; + pub fn CreateNamedPipeA( + lpName: LPCSTR, + dwOpenMode: DWORD, + dwPipeMode: DWORD, + nMaxInstances: DWORD, + nOutBufferSize: DWORD, + nInBufferSize: DWORD, + nDefaultTimeOut: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + ) -> HANDLE; + pub fn GetNamedPipeHandleStateA( + hNamedPipe: HANDLE, + lpState: LPDWORD, + lpCurInstances: LPDWORD, + lpMaxCollectionCount: LPDWORD, + lpCollectDataTimeout: LPDWORD, + lpUserName: LPSTR, + nMaxUserNameSize: DWORD, + ) -> BOOL; + pub fn CallNamedPipeA( + lpNamedPipeName: LPCSTR, + lpInBuffer: LPVOID, + nInBufferSize: DWORD, + lpOutBuffer: LPVOID, + nOutBufferSize: DWORD, + lpBytesRead: LPDWORD, + nTimeOut: DWORD, + ) -> BOOL; + pub fn WaitNamedPipeA( + lpNamedPipeName: LPCSTR, + nTimeOut: DWORD, + ) -> BOOL; + pub fn GetNamedPipeClientComputerNameA( + Pipe: HANDLE, + ClientComputerName: LPSTR, + ClientComputerNameLength: ULONG, + ) -> BOOL; + pub fn GetNamedPipeClientProcessId( + Pipe: HANDLE, + ClientProcessId: PULONG, + ) -> BOOL; + pub fn GetNamedPipeClientSessionId( + Pipe: HANDLE, + ClientSessionId: PULONG, + ) -> BOOL; + pub fn GetNamedPipeServerProcessId( + Pipe: HANDLE, + ServerProcessId: PULONG, + ) -> BOOL; + pub fn GetNamedPipeServerSessionId( + Pipe: HANDLE, + ServerSessionId: PULONG, + ) -> BOOL; + pub fn SetVolumeLabelA( + lpRootPathName: LPCSTR, + lpVolumeName: LPCSTR, + ) -> BOOL; + pub fn SetVolumeLabelW( + lpRootPathName: LPCWSTR, + lpVolumeName: LPCWSTR, + ) -> BOOL; + pub fn SetFileBandwidthReservation( + hFile: HANDLE, + nPeriodMilliseconds: DWORD, + nBytesPerPeriod: DWORD, + bDiscardable: BOOL, + lpTransferSize: LPDWORD, + lpNumOutstandingRequests: LPDWORD, + ) -> BOOL; + pub fn GetFileBandwidthReservation( + hFile: HANDLE, + lpPeriodMilliseconds: LPDWORD, + lpBytesPerPeriod: LPDWORD, + pDiscardable: LPBOOL, + lpTransferSize: LPDWORD, + lpNumOutstandingRequests: LPDWORD, + ) -> BOOL; + // pub fn ClearEventLogA(); + // pub fn ClearEventLogW(); + // pub fn BackupEventLogA(); + // pub fn BackupEventLogW(); + // pub fn CloseEventLog(); + pub fn DeregisterEventSource( + hEventLog: HANDLE, + ) -> BOOL; + // pub fn NotifyChangeEventLog(); + // pub fn GetNumberOfEventLogRecords(); + // pub fn GetOldestEventLogRecord(); + // pub fn OpenEventLogA(); + // pub fn OpenEventLogW(); + pub fn RegisterEventSourceA( + lpUNCServerName: LPCSTR, + lpSourceName: LPCSTR, + ) -> HANDLE; + pub fn RegisterEventSourceW( + lpUNCServerName: LPCWSTR, + lpSourceName: LPCWSTR, + ) -> HANDLE; + // pub fn OpenBackupEventLogA(); + // pub fn OpenBackupEventLogW(); + // pub fn ReadEventLogA(); + // pub fn ReadEventLogW(); + pub fn ReportEventA( + hEventLog: HANDLE, + wType: WORD, + wCategory: WORD, + dwEventID: DWORD, + lpUserSid: PSID, + wNumStrings: WORD, + dwDataSize: DWORD, + lpStrings: *mut LPCSTR, + lpRawData: LPVOID, + ) -> BOOL; + pub fn ReportEventW( + hEventLog: HANDLE, + wType: WORD, + wCategory: WORD, + dwEventID: DWORD, + lpUserSid: PSID, + wNumStrings: WORD, + dwDataSize: DWORD, + lpStrings: *mut LPCWSTR, + lpRawData: LPVOID, + ) -> BOOL; + // pub fn GetEventLogInformation(); + // pub fn OperationStart(); + // pub fn OperationEnd(); + // pub fn AccessCheckAndAuditAlarmA(); + // pub fn AccessCheckByTypeAndAuditAlarmA(); + // pub fn AccessCheckByTypeResultListAndAuditAlarmA(); + // pub fn AccessCheckByTypeResultListAndAuditAlarmByHandleA(); + // pub fn ObjectOpenAuditAlarmA(); + // pub fn ObjectPrivilegeAuditAlarmA(); + // pub fn ObjectCloseAuditAlarmA(); + // pub fn ObjectDeleteAuditAlarmA(); + // pub fn PrivilegedServiceAuditAlarmA(); + // pub fn AddConditionalAce(); + // pub fn SetFileSecurityA(); + // pub fn GetFileSecurityA(); + pub fn ReadDirectoryChangesW( + hDirectory: HANDLE, + lpBuffer: LPVOID, + nBufferLength: DWORD, + bWatchSubtree: BOOL, + dwNotifyFilter: DWORD, + lpBytesReturned: LPDWORD, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, + ) -> BOOL; + pub fn MapViewOfFileExNuma( + hFileMappingObject: HANDLE, + dwDesiredAccess: DWORD, + dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, + dwNumberOfBytesToMap: SIZE_T, + lpBaseAddress: LPVOID, + nndPreferred: DWORD, + ) -> LPVOID; + pub fn IsBadReadPtr( + lp: *const VOID, + ucb: UINT_PTR, + ) -> BOOL; + pub fn IsBadWritePtr( + lp: LPVOID, + ucb: UINT_PTR, + ) -> BOOL; + pub fn IsBadHugeReadPtr( + lp: *const VOID, + ucb: UINT_PTR, + ) -> BOOL; + pub fn IsBadHugeWritePtr( + lp: LPVOID, + ucb: UINT_PTR, + ) -> BOOL; + pub fn IsBadCodePtr( + lpfn: FARPROC, + ) -> BOOL; + pub fn IsBadStringPtrA( + lpsz: LPCSTR, + ucchMax: UINT_PTR, + ) -> BOOL; + pub fn IsBadStringPtrW( + lpsz: LPCWSTR, + ucchMax: UINT_PTR, + ) -> BOOL; + pub fn LookupAccountSidA( + lpSystemName: LPCSTR, + Sid: PSID, + Name: LPSTR, + cchName: LPDWORD, + ReferencedDomainName: LPSTR, + cchReferencedDomainName: LPDWORD, + peUse: PSID_NAME_USE, + ) -> BOOL; + pub fn LookupAccountSidW( + lpSystemName: LPCWSTR, + Sid: PSID, + Name: LPWSTR, + cchName: LPDWORD, + ReferencedDomainName: LPWSTR, + cchReferencedDomainName: LPDWORD, + peUse: PSID_NAME_USE, + ) -> BOOL; + pub fn LookupAccountNameA( + lpSystemName: LPCSTR, + lpAccountName: LPCSTR, + Sid: PSID, + cbSid: LPDWORD, + ReferencedDomainName: LPCSTR, + cchReferencedDomainName: LPDWORD, + peUse: PSID_NAME_USE, + ) -> BOOL; + pub fn LookupAccountNameW( + lpSystemName: LPCWSTR, + lpAccountName: LPCWSTR, + Sid: PSID, + cbSid: LPDWORD, + ReferencedDomainName: LPCWSTR, + cchReferencedDomainName: LPDWORD, + peUse: PSID_NAME_USE, + ) -> BOOL; + // pub fn LookupAccountNameLocalA(); + // pub fn LookupAccountNameLocalW(); + // pub fn LookupAccountSidLocalA(); + // pub fn LookupAccountSidLocalW(); + pub fn LookupPrivilegeValueA( + lpSystemName: LPCSTR, + lpName: LPCSTR, + lpLuid: PLUID, + ) -> BOOL; + pub fn LookupPrivilegeValueW( + lpSystemName: LPCWSTR, + lpName: LPCWSTR, + lpLuid: PLUID, + ) -> BOOL; + pub fn LookupPrivilegeNameA( + lpSystemName: LPCSTR, + lpLuid: PLUID, + lpName: LPSTR, + cchName: LPDWORD, + ) -> BOOL; + pub fn LookupPrivilegeNameW( + lpSystemName: LPCWSTR, + lpLuid: PLUID, + lpName: LPWSTR, + cchName: LPDWORD, + ) -> BOOL; + // pub fn LookupPrivilegeDisplayNameA(); + // pub fn LookupPrivilegeDisplayNameW(); + pub fn BuildCommDCBA( + lpDef: LPCSTR, + lpDCB: LPDCB, + ) -> BOOL; + pub fn BuildCommDCBW( + lpDef: LPCWSTR, + lpDCB: LPDCB, + ) -> BOOL; + pub fn BuildCommDCBAndTimeoutsA( + lpDef: LPCSTR, + lpDCB: LPDCB, + lpCommTimeouts: LPCOMMTIMEOUTS, + ) -> BOOL; + pub fn BuildCommDCBAndTimeoutsW( + lpDef: LPCWSTR, + lpDCB: LPDCB, + lpCommTimeouts: LPCOMMTIMEOUTS, + ) -> BOOL; + pub fn CommConfigDialogA( + lpszName: LPCSTR, + hWnd: HWND, + lpCC: LPCOMMCONFIG, + ) -> BOOL; + pub fn CommConfigDialogW( + lpszName: LPCWSTR, + hWnd: HWND, + lpCC: LPCOMMCONFIG, + ) -> BOOL; + pub fn GetDefaultCommConfigA( + lpszName: LPCSTR, + lpCC: LPCOMMCONFIG, + lpdwSize: LPDWORD, + ) -> BOOL; + pub fn GetDefaultCommConfigW( + lpszName: LPCWSTR, + lpCC: LPCOMMCONFIG, + lpdwSize: LPDWORD, + ) -> BOOL; + pub fn SetDefaultCommConfigA( + lpszName: LPCSTR, + lpCC: LPCOMMCONFIG, + dwSize: DWORD, + ) -> BOOL; + pub fn SetDefaultCommConfigW( + lpszName: LPCWSTR, + lpCC: LPCOMMCONFIG, + dwSize: DWORD, + ) -> BOOL; + pub fn GetComputerNameA( + lpBuffer: LPSTR, + nSize: LPDWORD, + ) -> BOOL; + pub fn GetComputerNameW( + lpBuffer: LPWSTR, + nSize: LPDWORD, + ) -> BOOL; + pub fn DnsHostnameToComputerNameA( + Hostname: LPCSTR, + ComputerName: LPCSTR, + nSize: LPDWORD, + ) -> BOOL; + pub fn DnsHostnameToComputerNameW( + Hostname: LPCWSTR, + ComputerName: LPWSTR, + nSize: LPDWORD, + ) -> BOOL; + pub fn GetUserNameA( + lpBuffer: LPSTR, + pcbBuffer: LPDWORD, + ) -> BOOL; + pub fn GetUserNameW( + lpBuffer: LPWSTR, + pcbBuffer: LPDWORD, + ) -> BOOL; +} +pub const LOGON32_LOGON_INTERACTIVE: DWORD = 2; +pub const LOGON32_LOGON_NETWORK: DWORD = 3; +pub const LOGON32_LOGON_BATCH: DWORD = 4; +pub const LOGON32_LOGON_SERVICE: DWORD = 5; +pub const LOGON32_LOGON_UNLOCK: DWORD = 7; +pub const LOGON32_LOGON_NETWORK_CLEARTEXT: DWORD = 8; +pub const LOGON32_LOGON_NEW_CREDENTIALS: DWORD = 9; +pub const LOGON32_PROVIDER_DEFAULT: DWORD = 0; +pub const LOGON32_PROVIDER_WINNT35: DWORD = 1; +pub const LOGON32_PROVIDER_WINNT40: DWORD = 2; +pub const LOGON32_PROVIDER_WINNT50: DWORD = 3; +pub const LOGON32_PROVIDER_VIRTUAL: DWORD = 4; +extern "system" { + pub fn LogonUserA( + lpUsername: LPCSTR, + lpDomain: LPCSTR, + lpPassword: LPCSTR, + dwLogonType: DWORD, + dwLogonProvider: DWORD, + phToken: PHANDLE, + ) -> BOOL; + pub fn LogonUserW( + lpUsername: LPCWSTR, + lpDomain: LPCWSTR, + lpPassword: LPCWSTR, + dwLogonType: DWORD, + dwLogonProvider: DWORD, + phToken: PHANDLE, + ) -> BOOL; + pub fn LogonUserExA( + lpUsername: LPCSTR, + lpDomain: LPCSTR, + lpPassword: LPCSTR, + dwLogonType: DWORD, + dwLogonProvider: DWORD, + phToken: PHANDLE, + ppLogonSid: *mut PSID, + ppProfileBuffer: *mut PVOID, + pdwProfileLength: LPDWORD, + pQuotaLimits: PQUOTA_LIMITS, + ) -> BOOL; + pub fn LogonUserExW( + lpUsername: LPCWSTR, + lpDomain: LPCWSTR, + lpPassword: LPCWSTR, + dwLogonType: DWORD, + dwLogonProvider: DWORD, + phToken: PHANDLE, + ppLogonSid: *mut PSID, + ppProfileBuffer: *mut PVOID, + pdwProfileLength: LPDWORD, + pQuotaLimits: PQUOTA_LIMITS, + ) -> BOOL; + // pub fn CreateProcessWithLogonW(); + // pub fn CreateProcessWithTokenW(); + // pub fn IsTokenUntrusted(); + pub fn RegisterWaitForSingleObject( + phNewWaitObject: PHANDLE, + hObject: HANDLE, + Callback: WAITORTIMERCALLBACK, + Context: PVOID, + dwMilliseconds: ULONG, + dwFlags: ULONG, + ) -> BOOL; + pub fn UnregisterWait( + WaitHandle: HANDLE, + ) -> BOOL; + pub fn BindIoCompletionCallback( + FileHandle: HANDLE, + Function: LPOVERLAPPED_COMPLETION_ROUTINE, + Flags: ULONG, + ) -> BOOL; + pub fn SetTimerQueueTimer( + TimerQueue: HANDLE, + Callback: WAITORTIMERCALLBACK, + Parameter: PVOID, + DueTime: DWORD, + Period: DWORD, + PreferIo: BOOL, + ) -> HANDLE; + pub fn CancelTimerQueueTimer( + TimerQueue: HANDLE, + Timer: HANDLE, + ) -> BOOL; + pub fn DeleteTimerQueue( + TimerQueue: HANDLE, + ) -> BOOL; + // pub fn InitializeThreadpoolEnvironment(); + // pub fn SetThreadpoolCallbackPool(); + // pub fn SetThreadpoolCallbackCleanupGroup(); + // pub fn SetThreadpoolCallbackRunsLong(); + // pub fn SetThreadpoolCallbackLibrary(); + // pub fn SetThreadpoolCallbackPriority(); + // pub fn DestroyThreadpoolEnvironment(); + // pub fn SetThreadpoolCallbackPersistent(); + pub fn CreatePrivateNamespaceA( + lpPrivateNamespaceAttributes: LPSECURITY_ATTRIBUTES, + lpBoundaryDescriptor: LPVOID, + lpAliasPrefix: LPCSTR, + ) -> HANDLE; + pub fn OpenPrivateNamespaceA( + lpBoundaryDescriptor: LPVOID, + lpAliasPrefix: LPCSTR, + ) -> HANDLE; + pub fn CreateBoundaryDescriptorA( + Name: LPCSTR, + Flags: ULONG, + ) -> HANDLE; + pub fn AddIntegrityLabelToBoundaryDescriptor( + BoundaryDescriptor: *mut HANDLE, + IntegrityLabel: PSID, + ) -> BOOL; +} +pub const HW_PROFILE_GUIDLEN: usize = 39; +// MAX_PROFILE_LEN +pub const DOCKINFO_UNDOCKED: DWORD = 0x1; +pub const DOCKINFO_DOCKED: DWORD = 0x2; +pub const DOCKINFO_USER_SUPPLIED: DWORD = 0x4; +pub const DOCKINFO_USER_UNDOCKED: DWORD = DOCKINFO_USER_SUPPLIED | DOCKINFO_UNDOCKED; +pub const DOCKINFO_USER_DOCKED: DWORD = DOCKINFO_USER_SUPPLIED | DOCKINFO_DOCKED; +STRUCT!{struct HW_PROFILE_INFOA { + dwDockInfo: DWORD, + szHwProfileGuid: [CHAR; HW_PROFILE_GUIDLEN], + szHwProfileName: [CHAR; MAX_PROFILE_LEN], +}} +pub type LPHW_PROFILE_INFOA = *mut HW_PROFILE_INFOA; +STRUCT!{struct HW_PROFILE_INFOW { + dwDockInfo: DWORD, + szHwProfileGuid: [WCHAR; HW_PROFILE_GUIDLEN], + szHwProfileName: [WCHAR; MAX_PROFILE_LEN], +}} +pub type LPHW_PROFILE_INFOW = *mut HW_PROFILE_INFOW; +extern "system" { + pub fn GetCurrentHwProfileA( + lpHwProfileInfo: LPHW_PROFILE_INFOA, + ) -> BOOL; + pub fn GetCurrentHwProfileW( + lpHwProfileInfo: LPHW_PROFILE_INFOW, + ) -> BOOL; + pub fn VerifyVersionInfoA( + lpVersionInformation: LPOSVERSIONINFOEXA, + dwTypeMask: DWORD, + dwlConditionMask: DWORDLONG, + ) -> BOOL; + pub fn VerifyVersionInfoW( + lpVersionInformation: LPOSVERSIONINFOEXW, + dwTypeMask: DWORD, + dwlConditionMask: DWORDLONG, + ) -> BOOL; +} +STRUCT!{struct SYSTEM_POWER_STATUS { + ACLineStatus: BYTE, + BatteryFlag: BYTE, + BatteryLifePercent: BYTE, + Reserved1: BYTE, + BatteryLifeTime: DWORD, + BatteryFullLifeTime: DWORD, +}} +pub type LPSYSTEM_POWER_STATUS = *mut SYSTEM_POWER_STATUS; +extern "system" { + pub fn GetSystemPowerStatus( + lpSystemPowerStatus: LPSYSTEM_POWER_STATUS, + ) -> BOOL; + pub fn SetSystemPowerState( + fSuspend: BOOL, + fForce: BOOL, + ) -> BOOL; + pub fn MapUserPhysicalPagesScatter( + VirtualAddresses: *mut PVOID, + NumberOfPages: ULONG_PTR, + PageArray: PULONG_PTR, + ) -> BOOL; + pub fn CreateJobObjectA( + lpJobAttributes: LPSECURITY_ATTRIBUTES, + lpName: LPCSTR, + ) -> HANDLE; + pub fn OpenJobObjectA( + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + lpName: LPCSTR, + ) -> HANDLE; + pub fn CreateJobSet( + NumJob: ULONG, + UserJobSet: PJOB_SET_ARRAY, + Flags: ULONG, + ) -> BOOL; + pub fn FindFirstVolumeA( + lpszVolumeName: LPSTR, + cchBufferLength: DWORD, + ) -> HANDLE; + pub fn FindNextVolumeA( + hFindVolume: HANDLE, + lpszVolumeName: LPSTR, + cchBufferLength: DWORD, + ) -> BOOL; + pub fn FindFirstVolumeMountPointA( + lpszRootPathName: LPCSTR, + lpszVolumeMountPoint: LPSTR, + cchBufferLength: DWORD, + ) -> HANDLE; + pub fn FindFirstVolumeMountPointW( + lpszRootPathName: LPCWSTR, + lpszVolumeMountPoint: LPWSTR, + cchBufferLength: DWORD, + ) -> HANDLE; + pub fn FindNextVolumeMountPointA( + hFindVolumeMountPoint: HANDLE, + lpszVolumeMountPoint: LPSTR, + cchBufferLength: DWORD, + ) -> BOOL; + pub fn FindNextVolumeMountPointW( + hFindVolumeMountPoint: HANDLE, + lpszVolumeMountPoint: LPWSTR, + cchBufferLength: DWORD, + ) -> BOOL; + pub fn FindVolumeMountPointClose( + hFindVolumeMountPoint: HANDLE, + ) -> BOOL; + pub fn SetVolumeMountPointA( + lpszVolumeMountPoint: LPCSTR, + lpszVolumeName: LPCSTR, + ) -> BOOL; + pub fn SetVolumeMountPointW( + lpszVolumeMountPoint: LPCWSTR, + lpszVolumeName: LPCWSTR, + ) -> BOOL; + pub fn DeleteVolumeMountPointA( + lpszVolumeMountPoint: LPCSTR, + ) -> BOOL; + pub fn GetVolumeNameForVolumeMountPointA( + lpszVolumeMountPoint: LPCSTR, + lpszVolumeName: LPSTR, + cchBufferLength: DWORD, + ) -> BOOL; + pub fn GetVolumePathNameA( + lpszFileName: LPCSTR, + lpszVolumePathName: LPSTR, + cchBufferLength: DWORD, + ) -> BOOL; + pub fn GetVolumePathNamesForVolumeNameA( + lpszVolumeName: LPCSTR, + lpszVolumePathNames: LPCH, + cchBufferLength: DWORD, + lpcchReturnLength: PDWORD, + ) -> BOOL; +} +// ACTCTX_FLAG_* +STRUCT!{struct ACTCTXA { + cbSize: ULONG, + dwFlags: DWORD, + lpSource: LPCSTR, + wProcessorArchitecture: USHORT, + wLangId: LANGID, + lpAssemblyDirectory: LPCSTR, + lpResourceName: LPCSTR, + lpApplicationName: LPCSTR, + hModule: HMODULE, +}} +pub type PACTCTXA = *mut ACTCTXA; +STRUCT!{struct ACTCTXW { + cbSize: ULONG, + dwFlags: DWORD, + lpSource: LPCWSTR, + wProcessorArchitecture: USHORT, + wLangId: LANGID, + lpAssemblyDirectory: LPCWSTR, + lpResourceName: LPCWSTR, + lpApplicationName: LPCWSTR, + hModule: HMODULE, +}} +pub type PACTCTXW = *mut ACTCTXW; +pub type PCACTCTXA = *const ACTCTXA; +pub type PCACTCTXW = *const ACTCTXW; +extern "system" { + pub fn CreateActCtxA( + pActCtx: PCACTCTXA, + ) -> HANDLE; + pub fn CreateActCtxW( + pActCtx: PCACTCTXW, + ) -> HANDLE; + pub fn AddRefActCtx( + hActCtx: HANDLE, + ); + pub fn ReleaseActCtx( + hActCtx: HANDLE, + ); + pub fn ZombifyActCtx( + hActCtx: HANDLE, + ) -> BOOL; + pub fn ActivateActCtx( + hActCtx: HANDLE, + lpCookie: *mut ULONG_PTR, + ) -> BOOL; + pub fn DeactivateActCtx( + dwFlags: DWORD, + ulCookie: ULONG_PTR, + ) -> BOOL; + pub fn GetCurrentActCtx( + lphActCtx: *mut HANDLE, + ) -> BOOL; +} +STRUCT!{struct ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA { + lpInformation: PVOID, + lpSectionBase: PVOID, + ulSectionLength: ULONG, + lpSectionGlobalDataBase: PVOID, + ulSectionGlobalDataLength: ULONG, +}} +pub type PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA = + *mut ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA; +pub type PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA = + *const ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA; +STRUCT!{struct ACTCTX_SECTION_KEYED_DATA { + cbSize: ULONG, + ulDataFormatVersion: ULONG, + lpData: PVOID, + ulLength: ULONG, + lpSectionGlobalData: PVOID, + ulSectionGlobalDataLength: ULONG, + lpSectionBase: PVOID, + ulSectionTotalLength: ULONG, + hActCtx: HANDLE, + ulAssemblyRosterIndex: ULONG, + ulFlags: ULONG, + AssemblyMetadata: ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, +}} +pub type PACTCTX_SECTION_KEYED_DATA = *mut ACTCTX_SECTION_KEYED_DATA; +pub type PCACTCTX_SECTION_KEYED_DATA = *const ACTCTX_SECTION_KEYED_DATA; +extern "system" { + pub fn FindActCtxSectionStringA( + dwFlags: DWORD, + lpExtensionGuid: *const GUID, + ulSectionId: ULONG, + lpStringToFind: LPCSTR, + ReturnedData: PACTCTX_SECTION_KEYED_DATA, + ) -> BOOL; + pub fn FindActCtxSectionStringW( + dwFlags: DWORD, + lpExtensionGuid: *const GUID, + ulSectionId: ULONG, + lpStringToFind: LPCWSTR, + ReturnedData: PACTCTX_SECTION_KEYED_DATA, + ) -> BOOL; + pub fn FindActCtxSectionGuid( + dwFlags: DWORD, + lpExtensionGuid: *const GUID, + ulSectionId: ULONG, + lpGuidToFind: *const GUID, + ReturnedData: PACTCTX_SECTION_KEYED_DATA, + ) -> BOOL; + pub fn QueryActCtxW( + dwFlags: DWORD, + hActCtx: HANDLE, + pvSubInstance: PVOID, + ulInfoClass: ULONG, + pvBuffer: PVOID, + cbBuffer: SIZE_T, + pcbWrittenOrRequired: *mut SIZE_T, + ) -> BOOL; + pub fn WTSGetActiveConsoleSessionId() -> DWORD; + // pub fn WTSGetServiceSessionId(); + // pub fn WTSIsServerContainer(); + pub fn GetActiveProcessorGroupCount() -> WORD; + pub fn GetMaximumProcessorGroupCount() -> WORD; + pub fn GetActiveProcessorCount( + GroupNumber: WORD, + ) -> DWORD; + pub fn GetMaximumProcessorCount( + GroupNumber: WORD, + ) -> DWORD; + pub fn GetNumaProcessorNode( + Processor: UCHAR, + NodeNumber: PUCHAR, + ) -> BOOL; + pub fn GetNumaNodeNumberFromHandle( + hFile: HANDLE, + NodeNumber: PUSHORT, + ) -> BOOL; + pub fn GetNumaProcessorNodeEx( + Processor: PPROCESSOR_NUMBER, + NodeNumber: PUSHORT, + ) -> BOOL; + pub fn GetNumaNodeProcessorMask( + Node: UCHAR, + ProcessorMask: PULONGLONG, + ) -> BOOL; + pub fn GetNumaAvailableMemoryNode( + Node: UCHAR, + AvailableBytes: PULONGLONG, + ) -> BOOL; + pub fn GetNumaAvailableMemoryNodeEx( + Node: USHORT, + AvailableBytes: PULONGLONG, + ) -> BOOL; + pub fn GetNumaProximityNode( + ProximityId: ULONG, + NodeNumber: PUCHAR, + ) -> BOOL; +} +FN!{stdcall APPLICATION_RECOVERY_CALLBACK( + pvParameter: PVOID, +) -> DWORD} +// RESTART_* +// RECOVERY_* +extern "system" { + pub fn RegisterApplicationRecoveryCallback( + pRecoveyCallback: APPLICATION_RECOVERY_CALLBACK, + pvParameter: PVOID, + dwPingInterval: DWORD, + dwFlags: DWORD, + ) -> HRESULT; + pub fn UnregisterApplicationRecoveryCallback() -> HRESULT; + pub fn RegisterApplicationRestart( + pwzCommandline: PCWSTR, + dwFlags: DWORD, + ) -> HRESULT; + pub fn UnregisterApplicationRestart() -> HRESULT; + pub fn GetApplicationRecoveryCallback( + hProcess: HANDLE, + pRecoveryCallback: *mut APPLICATION_RECOVERY_CALLBACK, + ppvParameter: *mut PVOID, + pdwPingInterval: PDWORD, + pdwFlags: PDWORD, + ) -> HRESULT; + pub fn GetApplicationRestartSettings( + hProcess: HANDLE, + pwzCommandline: PWSTR, + pcchSize: PDWORD, + pdwFlags: PDWORD, + ) -> HRESULT; + pub fn ApplicationRecoveryInProgress( + pbCancelled: PBOOL, + ) -> HRESULT; + pub fn ApplicationRecoveryFinished( + bSuccess: BOOL, + ); +} +// FILE_BASIC_INFO, etc. +extern "system" { + pub fn GetFileInformationByHandleEx( + hFile: HANDLE, + FileInformationClass: FILE_INFO_BY_HANDLE_CLASS, + lpFileInformation: LPVOID, + dwBufferSize: DWORD, + ) -> BOOL; +} +ENUM!{enum FILE_ID_TYPE { + FileIdType, + ObjectIdType, + ExtendedFileIdType, + MaximumFileIdType, +}} +UNION!{union FILE_ID_DESCRIPTOR_u { + [u64; 2], + FileId FileId_mut: LARGE_INTEGER, + ObjectId ObjectId_mut: GUID, + ExtendedFileId ExtendedFileId_mut: FILE_ID_128, +}} +STRUCT!{struct FILE_ID_DESCRIPTOR { + dwSize: DWORD, + Type: FILE_ID_TYPE, + u: FILE_ID_DESCRIPTOR_u, +}} +pub type LPFILE_ID_DESCRIPTOR = *mut FILE_ID_DESCRIPTOR; +extern "system" { + pub fn OpenFileById( + hVolumeHint: HANDLE, + lpFileId: LPFILE_ID_DESCRIPTOR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + dwFlagsAndAttributes: DWORD, + ) -> HANDLE; + pub fn CreateSymbolicLinkA( + lpSymlinkFileName: LPCSTR, + lpTargetFileName: LPCSTR, + dwFlags: DWORD, + ) -> BOOLEAN; + pub fn CreateSymbolicLinkW( + lpSymlinkFileName: LPCWSTR, + lpTargetFileName: LPCWSTR, + dwFlags: DWORD, + ) -> BOOLEAN; + pub fn QueryActCtxSettingsW( + dwFlags: DWORD, + hActCtx: HANDLE, + settingsNameSpace: PCWSTR, + settingName: PCWSTR, + pvBuffer: PWSTR, + dwBuffer: SIZE_T, + pdwWrittenOrRequired: *mut SIZE_T, + ) -> BOOL; + pub fn CreateSymbolicLinkTransactedA( + lpSymlinkFileName: LPCSTR, + lpTargetFileName: LPCSTR, + dwFlags: DWORD, + hTransaction: HANDLE, + ) -> BOOLEAN; + pub fn CreateSymbolicLinkTransactedW( + lpSymlinkFileName: LPCWSTR, + lpTargetFileName: LPCWSTR, + dwFlags: DWORD, + hTransaction: HANDLE, + ) -> BOOLEAN; + pub fn ReplacePartitionUnit( + TargetPartition: PWSTR, + SparePartition: PWSTR, + Flags: ULONG, + ) -> BOOL; + pub fn AddSecureMemoryCacheCallback( + pfnCallBack: PSECURE_MEMORY_CACHE_CALLBACK, + ) -> BOOL; + pub fn RemoveSecureMemoryCacheCallback( + pfnCallBack: PSECURE_MEMORY_CACHE_CALLBACK, + ) -> BOOL; + pub fn CopyContext( + Destination: PCONTEXT, + ContextFlags: DWORD, + Source: PCONTEXT, + ) -> BOOL; + pub fn InitializeContext( + Buffer: PVOID, + ContextFlags: DWORD, + Context: *mut PCONTEXT, + ContextLength: PDWORD, + ) -> BOOL; + pub fn GetEnabledXStateFeatures() -> DWORD64; + pub fn GetXStateFeaturesMask( + Context: PCONTEXT, + FeatureMask: PDWORD64, + ) -> BOOL; + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + pub fn LocateXStateFeature( + Context: PCONTEXT, + FeatureId: DWORD, + Length: PDWORD, + ) -> PVOID; + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + pub fn SetXStateFeaturesMask( + Context: PCONTEXT, + FeatureMask: DWORD64, + ) -> BOOL; + pub fn EnableThreadProfiling( + ThreadHandle: HANDLE, + Flags: DWORD, + HardwareCounters: DWORD64, + PerformanceDataHandle: *mut HANDLE, + ) -> BOOL; + pub fn DisableThreadProfiling( + PerformanceDataHandle: HANDLE, + ) -> DWORD; + pub fn QueryThreadProfiling( + ThreadHandle: HANDLE, + Enabled: PBOOLEAN, + ) -> DWORD; + pub fn ReadThreadProfilingData( + PerformanceDataHandle: HANDLE, + Flags: DWORD, + PerformanceData: PPERFORMANCE_DATA, + ) -> DWORD; + // intrinsic InterlockedIncrement + // intrinsic InterlockedDecrement + // intrinsic InterlockedExchange + // intrinsic InterlockedExchangeAdd + // intrinsic InterlockedExchangeSubtract + // intrinsic InterlockedCompareExchange + // intrinsic InterlockedAnd + // intrinsic InterlockedOr + // intrinsic InterlockedXor +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wincodec.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincodec.rs new file mode 100644 index 0000000..dbe8a44 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincodec.rs @@ -0,0 +1,1861 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of wincodec.h +use ctypes::c_double; +use shared::basetsd::{UINT32, ULONG_PTR}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::dxgitype::{ + DXGI_JPEG_AC_HUFFMAN_TABLE, DXGI_JPEG_DC_HUFFMAN_TABLE, + DXGI_JPEG_QUANTIZATION_TABLE +}; +use shared::guiddef::{CLSID, GUID, REFCLSID, REFGUID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, INT, LPVOID, UINT, ULONG}; +use shared::ntdef::{LPCWSTR, LPWSTR, PCWSTR, WCHAR}; +use shared::windef::{HBITMAP, HICON, HPALETTE}; +use shared::winerror::{ + E_ABORT, E_ACCESSDENIED, E_FAIL, E_INVALIDARG, E_NOTIMPL, E_OUTOFMEMORY, HRESULT, + SEVERITY_ERROR +}; +use um::d2d1::ID2D1Image; +use um::d2d1_1::ID2D1Device; +use um::dcommon::D2D1_PIXEL_FORMAT; +use um::objidlbase::{IEnumString, IEnumUnknown, IStream, IStreamVtbl}; +use um::ocidl::IPropertyBag2; +use um::propidl::PROPVARIANT; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, ULARGE_INTEGER}; +DEFINE_GUID!{CLSID_WICImagingFactory, + 0xcacaf262, 0x9370, 0x4615, 0xa1, 0x3b, 0x9f, 0x55, 0x39, 0xda, 0x4c, 0xa} +DEFINE_GUID!{CLSID_WICImagingFactory1, + 0xcacaf262, 0x9370, 0x4615, 0xa1, 0x3b, 0x9f, 0x55, 0x39, 0xda, 0x4c, 0xa} +DEFINE_GUID!{CLSID_WICImagingFactory2, + 0x317d06e8, 0x5f24, 0x433d, 0xbd, 0xf7, 0x79, 0xce, 0x68, 0xd8, 0xab, 0xc2} +DEFINE_GUID!{GUID_VendorMicrosoft, + 0xf0e749ca, 0xedef, 0x4589, 0xa7, 0x3a, 0xee, 0xe, 0x62, 0x6a, 0x2a, 0x2b} +DEFINE_GUID!{GUID_VendorMicrosoftBuiltIn, + 0x257a30fd, 0x6b6, 0x462b, 0xae, 0xa4, 0x63, 0xf7, 0xb, 0x86, 0xe5, 0x33} +DEFINE_GUID!{CLSID_WICPngDecoder, + 0x389ea17b, 0x5078, 0x4cde, 0xb6, 0xef, 0x25, 0xc1, 0x51, 0x75, 0xc7, 0x51} +DEFINE_GUID!{CLSID_WICPngDecoder1, + 0x389ea17b, 0x5078, 0x4cde, 0xb6, 0xef, 0x25, 0xc1, 0x51, 0x75, 0xc7, 0x51} +DEFINE_GUID!{CLSID_WICPngDecoder2, + 0xe018945b, 0xaa86, 0x4008, 0x9b, 0xd4, 0x67, 0x77, 0xa1, 0xe4, 0x0c, 0x11} +DEFINE_GUID!{CLSID_WICBmpDecoder, + 0x6b462062, 0x7cbf, 0x400d, 0x9f, 0xdb, 0x81, 0x3d, 0xd1, 0x0f, 0x27, 0x78} +DEFINE_GUID!{CLSID_WICIcoDecoder, + 0xc61bfcdf, 0x2e0f, 0x4aad, 0xa8, 0xd7, 0xe0, 0x6b, 0xaf, 0xeb, 0xcd, 0xfe} +DEFINE_GUID!{CLSID_WICJpegDecoder, + 0x9456a480, 0xe88b, 0x43ea, 0x9e, 0x73, 0x0b, 0x2d, 0x9b, 0x71, 0xb1, 0xca} +DEFINE_GUID!{CLSID_WICGifDecoder, + 0x381dda3c, 0x9ce9, 0x4834, 0xa2, 0x3e, 0x1f, 0x98, 0xf8, 0xfc, 0x52, 0xbe} +DEFINE_GUID!{CLSID_WICTiffDecoder, + 0xb54e85d9, 0xfe23, 0x499f, 0x8b, 0x88, 0x6a, 0xce, 0xa7, 0x13, 0x75, 0x2b} +DEFINE_GUID!{CLSID_WICWmpDecoder, + 0xa26cec36, 0x234c, 0x4950, 0xae, 0x16, 0xe3, 0x4a, 0xac, 0xe7, 0x1d, 0x0d} +DEFINE_GUID!{CLSID_WICDdsDecoder, + 0x9053699f, 0xa341, 0x429d, 0x9e, 0x90, 0xee, 0x43, 0x7c, 0xf8, 0x0c, 0x73} +DEFINE_GUID!{CLSID_WICBmpEncoder, + 0x69be8bb4, 0xd66d, 0x47c8, 0x86, 0x5a, 0xed, 0x15, 0x89, 0x43, 0x37, 0x82} +DEFINE_GUID!{CLSID_WICPngEncoder, + 0x27949969, 0x876a, 0x41d7, 0x94, 0x47, 0x56, 0x8f, 0x6a, 0x35, 0xa4, 0xdc} +DEFINE_GUID!{CLSID_WICJpegEncoder, + 0x1a34f5c1, 0x4a5a, 0x46dc, 0xb6, 0x44, 0x1f, 0x45, 0x67, 0xe7, 0xa6, 0x76} +DEFINE_GUID!{CLSID_WICGifEncoder, + 0x114f5598, 0x0b22, 0x40a0, 0x86, 0xa1, 0xc8, 0x3e, 0xa4, 0x95, 0xad, 0xbd} +DEFINE_GUID!{CLSID_WICTiffEncoder, + 0x0131be10, 0x2001, 0x4c5f, 0xa9, 0xb0, 0xcc, 0x88, 0xfa, 0xb6, 0x4c, 0xe8} +DEFINE_GUID!{CLSID_WICWmpEncoder, + 0xac4ce3cb, 0xe1c1, 0x44cd, 0x82, 0x15, 0x5a, 0x16, 0x65, 0x50, 0x9e, 0xc2} +DEFINE_GUID!{CLSID_WICDdsEncoder, + 0xa61dde94, 0x66ce, 0x4ac1, 0x88, 0x1b, 0x71, 0x68, 0x05, 0x88, 0x89, 0x5e} +DEFINE_GUID!{CLSID_WICAdngDecoder, + 0x981d9411, 0x909e, 0x42a7, 0x8f, 0x5d, 0xa7, 0x47, 0xff, 0x05, 0x2e, 0xdb} +DEFINE_GUID!{CLSID_WICJpegQualcommPhoneEncoder, + 0x68ed5c62, 0xf534, 0x4979, 0xb2, 0xb3, 0x68, 0x6a, 0x12, 0xb2, 0xb3, 0x4c} +DEFINE_GUID!{GUID_ContainerFormatBmp, + 0x0af1d87e, 0xfcfe, 0x4188, 0xbd, 0xeb, 0xa7, 0x90, 0x64, 0x71, 0xcb, 0xe3} +DEFINE_GUID!{GUID_ContainerFormatPng, + 0x1b7cfaf4, 0x713f, 0x473c, 0xbb, 0xcd, 0x61, 0x37, 0x42, 0x5f, 0xae, 0xaf} +DEFINE_GUID!{GUID_ContainerFormatIco, + 0xa3a860c4, 0x338f, 0x4c17, 0x91, 0x9a, 0xfb, 0xa4, 0xb5, 0x62, 0x8f, 0x21} +DEFINE_GUID!{GUID_ContainerFormatJpeg, + 0x19e4a5aa, 0x5662, 0x4fc5, 0xa0, 0xc0, 0x17, 0x58, 0x02, 0x8e, 0x10, 0x57} +DEFINE_GUID!{GUID_ContainerFormatTiff, + 0x163bcc30, 0xe2e9, 0x4f0b, 0x96, 0x1d, 0xa3, 0xe9, 0xfd, 0xb7, 0x88, 0xa3} +DEFINE_GUID!{GUID_ContainerFormatGif, + 0x1f8a5601, 0x7d4d, 0x4cbd, 0x9c, 0x82, 0x1b, 0xc8, 0xd4, 0xee, 0xb9, 0xa5} +DEFINE_GUID!{GUID_ContainerFormatWmp, + 0x57a37caa, 0x367a, 0x4540, 0x91, 0x6b, 0xf1, 0x83, 0xc5, 0x09, 0x3a, 0x4b} +DEFINE_GUID!{GUID_ContainerFormatDds, + 0x9967cb95, 0x2e85, 0x4ac8, 0x8c, 0xa2, 0x83, 0xd7, 0xcc, 0xd4, 0x25, 0xc9} +DEFINE_GUID!{GUID_ContainerFormatAdng, + 0xf3ff6d0d, 0x38c0, 0x41c4, 0xb1, 0xfe, 0x1f, 0x38, 0x24, 0xf1, 0x7b, 0x84} +DEFINE_GUID!{CLSID_WICImagingCategories, + 0xfae3d380, 0xfea4, 0x4623, 0x8c, 0x75, 0xc6, 0xb6, 0x11, 0x10, 0xb6, 0x81} +DEFINE_GUID!{CATID_WICBitmapDecoders, + 0x7ed96837, 0x96f0, 0x4812, 0xb2, 0x11, 0xf1, 0x3c, 0x24, 0x11, 0x7e, 0xd3} +DEFINE_GUID!{CATID_WICBitmapEncoders, + 0xac757296, 0x3522, 0x4e11, 0x98, 0x62, 0xc1, 0x7b, 0xe5, 0xa1, 0x76, 0x7e} +DEFINE_GUID!{CATID_WICPixelFormats, + 0x2b46e70f, 0xcda7, 0x473e, 0x89, 0xf6, 0xdc, 0x96, 0x30, 0xa2, 0x39, 0x0b} +DEFINE_GUID!{CATID_WICFormatConverters, + 0x7835eae8, 0xbf14, 0x49d1, 0x93, 0xce, 0x53, 0x3a, 0x40, 0x7b, 0x22, 0x48} +DEFINE_GUID!{CATID_WICMetadataReader, + 0x05af94d8, 0x7174, 0x4cd2, 0xbe, 0x4a, 0x41, 0x24, 0xb8, 0x0e, 0xe4, 0xb8} +DEFINE_GUID!{CATID_WICMetadataWriter, + 0xabe3b9a4, 0x257d, 0x4b97, 0xbd, 0x1a, 0x29, 0x4a, 0xf4, 0x96, 0x22, 0x2e} +DEFINE_GUID!{CLSID_WICDefaultFormatConverter, + 0x1a3f11dc, 0xb514, 0x4b17, 0x8c, 0x5f, 0x21, 0x54, 0x51, 0x38, 0x52, 0xf1} +DEFINE_GUID!{CLSID_WICFormatConverterHighColor, + 0xac75d454, 0x9f37, 0x48f8, 0xb9, 0x72, 0x4e, 0x19, 0xbc, 0x85, 0x60, 0x11} +DEFINE_GUID!{CLSID_WICFormatConverterNChannel, + 0xc17cabb2, 0xd4a3, 0x47d7, 0xa5, 0x57, 0x33, 0x9b, 0x2e, 0xfb, 0xd4, 0xf1} +DEFINE_GUID!{CLSID_WICFormatConverterWMPhoto, + 0x9cb5172b, 0xd600, 0x46ba, 0xab, 0x77, 0x77, 0xbb, 0x7e, 0x3a, 0x00, 0xd9} +DEFINE_GUID!{CLSID_WICPlanarFormatConverter, + 0x184132b8, 0x32f8, 0x4784, 0x91, 0x31, 0xdd, 0x72, 0x24, 0xb2, 0x34, 0x38} +pub type WICColor = UINT32; +STRUCT!{struct WICRect { + X: INT, + Y: INT, + Width: INT, + Height: INT, +}} +pub type WICInProcPointer = *mut BYTE; +ENUM!{enum WICColorContextType { + WICColorContextUninitialized = 0x00000000, + WICColorContextProfile = 0x00000001, + WICColorContextExifColorSpace = 0x00000002, +}} +pub const CODEC_FORCE_DWORD: DWORD = 0x7FFFFFFF; +pub const WIC_JPEG_MAX_COMPONENT_COUNT: UINT = 4; +pub const WIC_JPEG_MAX_TABLE_INDEX: UINT = 3; +pub const WIC_JPEG_SAMPLE_FACTORS_ONE: DWORD = 0x00000011; +pub const WIC_JPEG_SAMPLE_FACTORS_THREE_420: DWORD = 0x00111122; +pub const WIC_JPEG_SAMPLE_FACTORS_THREE_422: DWORD = 0x00111121; +pub const WIC_JPEG_SAMPLE_FACTORS_THREE_440: DWORD = 0x00111112; +pub const WIC_JPEG_SAMPLE_FACTORS_THREE_444: DWORD = 0x00111111; +pub const WIC_JPEG_QUANTIZATION_BASELINE_ONE: DWORD = 0x00000000; +pub const WIC_JPEG_QUANTIZATION_BASELINE_THREE: DWORD = 0x00010100; +pub const WIC_JPEG_HUFFMAN_BASELINE_ONE: DWORD = 0x00000000; +pub const WIC_JPEG_HUFFMAN_BASELINE_THREE: DWORD = 0x00111100; +pub type REFWICPixelFormatGUID = REFGUID; +pub type WICPixelFormatGUID = GUID; +DEFINE_GUID!{GUID_WICPixelFormatDontCare, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x00} +DEFINE_GUID!{GUID_WICPixelFormat1bppIndexed, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x01} +DEFINE_GUID!{GUID_WICPixelFormat2bppIndexed, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x02} +DEFINE_GUID!{GUID_WICPixelFormat4bppIndexed, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x03} +DEFINE_GUID!{GUID_WICPixelFormat8bppIndexed, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x04} +DEFINE_GUID!{GUID_WICPixelFormatBlackWhite, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x05} +DEFINE_GUID!{GUID_WICPixelFormat2bppGray, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x06} +DEFINE_GUID!{GUID_WICPixelFormat4bppGray, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x07} +DEFINE_GUID!{GUID_WICPixelFormat8bppGray, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x08} +DEFINE_GUID!{GUID_WICPixelFormat8bppAlpha, + 0xe6cd0116, 0xeeba, 0x4161, 0xaa, 0x85, 0x27, 0xdd, 0x9f, 0xb3, 0xa8, 0x95} +DEFINE_GUID!{GUID_WICPixelFormat16bppBGR555, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x09} +DEFINE_GUID!{GUID_WICPixelFormat16bppBGR565, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0a} +DEFINE_GUID!{GUID_WICPixelFormat16bppBGRA5551, + 0x05ec7c2b, 0xf1e6, 0x4961, 0xad, 0x46, 0xe1, 0xcc, 0x81, 0x0a, 0x87, 0xd2} +DEFINE_GUID!{GUID_WICPixelFormat16bppGray, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0b} +DEFINE_GUID!{GUID_WICPixelFormat24bppBGR, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0c} +DEFINE_GUID!{GUID_WICPixelFormat24bppRGB, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0d} +DEFINE_GUID!{GUID_WICPixelFormat32bppBGR, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0e} +DEFINE_GUID!{GUID_WICPixelFormat32bppBGRA, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0f} +DEFINE_GUID!{GUID_WICPixelFormat32bppPBGRA, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x10} +DEFINE_GUID!{GUID_WICPixelFormat32bppGrayFloat, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x11} +DEFINE_GUID!{GUID_WICPixelFormat32bppRGB, + 0xd98c6b95, 0x3efe, 0x47d6, 0xbb, 0x25, 0xeb, 0x17, 0x48, 0xab, 0x0c, 0xf1} +DEFINE_GUID!{GUID_WICPixelFormat32bppRGBA, + 0xf5c7ad2d, 0x6a8d, 0x43dd, 0xa7, 0xa8, 0xa2, 0x99, 0x35, 0x26, 0x1a, 0xe9} +DEFINE_GUID!{GUID_WICPixelFormat32bppPRGBA, + 0x3cc4a650, 0xa527, 0x4d37, 0xa9, 0x16, 0x31, 0x42, 0xc7, 0xeb, 0xed, 0xba} +DEFINE_GUID!{GUID_WICPixelFormat48bppRGB, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x15} +DEFINE_GUID!{GUID_WICPixelFormat48bppBGR, + 0xe605a384, 0xb468, 0x46ce, 0xbb, 0x2e, 0x36, 0xf1, 0x80, 0xe6, 0x43, 0x13} +DEFINE_GUID!{GUID_WICPixelFormat64bppRGB, + 0xa1182111, 0x186d, 0x4d42, 0xbc, 0x6a, 0x9c, 0x83, 0x03, 0xa8, 0xdf, 0xf9} +DEFINE_GUID!{GUID_WICPixelFormat64bppRGBA, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x16} +DEFINE_GUID!{GUID_WICPixelFormat64bppBGRA, + 0x1562ff7c, 0xd352, 0x46f9, 0x97, 0x9e, 0x42, 0x97, 0x6b, 0x79, 0x22, 0x46} +DEFINE_GUID!{GUID_WICPixelFormat64bppPRGBA, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x17} +DEFINE_GUID!{GUID_WICPixelFormat64bppPBGRA, + 0x8c518e8e, 0xa4ec, 0x468b, 0xae, 0x70, 0xc9, 0xa3, 0x5a, 0x9c, 0x55, 0x30} +DEFINE_GUID!{GUID_WICPixelFormat16bppGrayFixedPoint, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x13} +DEFINE_GUID!{GUID_WICPixelFormat32bppBGR101010, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x14} +DEFINE_GUID!{GUID_WICPixelFormat48bppRGBFixedPoint, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x12} +DEFINE_GUID!{GUID_WICPixelFormat48bppBGRFixedPoint, + 0x49ca140e, 0xcab6, 0x493b, 0x9d, 0xdf, 0x60, 0x18, 0x7c, 0x37, 0x53, 0x2a} +DEFINE_GUID!{GUID_WICPixelFormat96bppRGBFixedPoint, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x18} +DEFINE_GUID!{GUID_WICPixelFormat96bppRGBFloat, + 0xe3fed78f, 0xe8db, 0x4acf, 0x84, 0xc1, 0xe9, 0x7f, 0x61, 0x36, 0xb3, 0x27} +DEFINE_GUID!{GUID_WICPixelFormat128bppRGBAFloat, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x19} +DEFINE_GUID!{GUID_WICPixelFormat128bppPRGBAFloat, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1a} +DEFINE_GUID!{GUID_WICPixelFormat128bppRGBFloat, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1b} +DEFINE_GUID!{GUID_WICPixelFormat32bppCMYK, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1c} +DEFINE_GUID!{GUID_WICPixelFormat64bppRGBAFixedPoint, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1d} +DEFINE_GUID!{GUID_WICPixelFormat64bppBGRAFixedPoint, + 0x356de33c, 0x54d2, 0x4a23, 0xbb, 0x4, 0x9b, 0x7b, 0xf9, 0xb1, 0xd4, 0x2d} +DEFINE_GUID!{GUID_WICPixelFormat64bppRGBFixedPoint, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x40} +DEFINE_GUID!{GUID_WICPixelFormat128bppRGBAFixedPoint, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1e} +DEFINE_GUID!{GUID_WICPixelFormat128bppRGBFixedPoint, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x41} +DEFINE_GUID!{GUID_WICPixelFormat64bppRGBAHalf, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3a} +DEFINE_GUID!{GUID_WICPixelFormat64bppPRGBAHalf, + 0x58ad26c2, 0xc623, 0x4d9d, 0xb3, 0x20, 0x38, 0x7e, 0x49, 0xf8, 0xc4, 0x42} +DEFINE_GUID!{GUID_WICPixelFormat64bppRGBHalf, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x42} +DEFINE_GUID!{GUID_WICPixelFormat48bppRGBHalf, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3b} +DEFINE_GUID!{GUID_WICPixelFormat32bppRGBE, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3d} +DEFINE_GUID!{GUID_WICPixelFormat16bppGrayHalf, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3e} +DEFINE_GUID!{GUID_WICPixelFormat32bppGrayFixedPoint, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3f} +DEFINE_GUID!{GUID_WICPixelFormat32bppRGBA1010102, + 0x25238D72, 0xFCF9, 0x4522, 0xb5, 0x14, 0x55, 0x78, 0xe5, 0xad, 0x55, 0xe0} +DEFINE_GUID!{GUID_WICPixelFormat32bppRGBA1010102XR, + 0x00DE6B9A, 0xC101, 0x434b, 0xb5, 0x02, 0xd0, 0x16, 0x5e, 0xe1, 0x12, 0x2c} +DEFINE_GUID!{GUID_WICPixelFormat64bppCMYK, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1f} +DEFINE_GUID!{GUID_WICPixelFormat24bpp3Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x20} +DEFINE_GUID!{GUID_WICPixelFormat32bpp4Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x21} +DEFINE_GUID!{GUID_WICPixelFormat40bpp5Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x22} +DEFINE_GUID!{GUID_WICPixelFormat48bpp6Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x23} +DEFINE_GUID!{GUID_WICPixelFormat56bpp7Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x24} +DEFINE_GUID!{GUID_WICPixelFormat64bpp8Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x25} +DEFINE_GUID!{GUID_WICPixelFormat48bpp3Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x26} +DEFINE_GUID!{GUID_WICPixelFormat64bpp4Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x27} +DEFINE_GUID!{GUID_WICPixelFormat80bpp5Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x28} +DEFINE_GUID!{GUID_WICPixelFormat96bpp6Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x29} +DEFINE_GUID!{GUID_WICPixelFormat112bpp7Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2a} +DEFINE_GUID!{GUID_WICPixelFormat128bpp8Channels, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2b} +DEFINE_GUID!{GUID_WICPixelFormat40bppCMYKAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2c} +DEFINE_GUID!{GUID_WICPixelFormat80bppCMYKAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2d} +DEFINE_GUID!{GUID_WICPixelFormat32bpp3ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2e} +DEFINE_GUID!{GUID_WICPixelFormat40bpp4ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2f} +DEFINE_GUID!{GUID_WICPixelFormat48bpp5ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x30} +DEFINE_GUID!{GUID_WICPixelFormat56bpp6ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x31} +DEFINE_GUID!{GUID_WICPixelFormat64bpp7ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x32} +DEFINE_GUID!{GUID_WICPixelFormat72bpp8ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x33} +DEFINE_GUID!{GUID_WICPixelFormat64bpp3ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x34} +DEFINE_GUID!{GUID_WICPixelFormat80bpp4ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x35} +DEFINE_GUID!{GUID_WICPixelFormat96bpp5ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x36} +DEFINE_GUID!{GUID_WICPixelFormat112bpp6ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x37} +DEFINE_GUID!{GUID_WICPixelFormat128bpp7ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x38} +DEFINE_GUID!{GUID_WICPixelFormat144bpp8ChannelsAlpha, + 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x39} +DEFINE_GUID!{GUID_WICPixelFormat8bppY, + 0x91B4DB54, 0x2DF9, 0x42F0, 0xB4, 0x49, 0x29, 0x09, 0xBB, 0x3D, 0xF8, 0x8E} +DEFINE_GUID!{GUID_WICPixelFormat8bppCb, + 0x1339F224, 0x6BFE, 0x4C3E, 0x93, 0x02, 0xE4, 0xF3, 0xA6, 0xD0, 0xCA, 0x2A} +DEFINE_GUID!{GUID_WICPixelFormat8bppCr, + 0xB8145053, 0x2116, 0x49F0, 0x88, 0x35, 0xED, 0x84, 0x4B, 0x20, 0x5C, 0x51} +DEFINE_GUID!{GUID_WICPixelFormat16bppCbCr, + 0xFF95BA6E, 0x11E0, 0x4263, 0xBB, 0x45, 0x01, 0x72, 0x1F, 0x34, 0x60, 0xA4} +DEFINE_GUID!{GUID_WICPixelFormat16bppYQuantizedDctCoefficients, + 0xA355F433, 0x48E8, 0x4A42, 0x84, 0xD8, 0xE2, 0xAA, 0x26, 0xCA, 0x80, 0xA4} +DEFINE_GUID!{GUID_WICPixelFormat16bppCbQuantizedDctCoefficients, + 0xD2C4FF61, 0x56A5, 0x49C2, 0x8B, 0x5C, 0x4C, 0x19, 0x25, 0x96, 0x48, 0x37} +DEFINE_GUID!{GUID_WICPixelFormat16bppCrQuantizedDctCoefficients, + 0x2FE354F0, 0x1680, 0x42D8, 0x92, 0x31, 0xE7, 0x3C, 0x05, 0x65, 0xBF, 0xC1} +ENUM!{enum WICBitmapCreateCacheOption { + WICBitmapNoCache = 0x00000000, + WICBitmapCacheOnDemand = 0x00000001, + WICBitmapCacheOnLoad = 0x00000002, + WICBITMAPCREATECACHEOPTION_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICDecodeOptions { + WICDecodeMetadataCacheOnDemand = 0x00000000, + WICDecodeMetadataCacheOnLoad = 0x00000001, + WICMETADATACACHEOPTION_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICBitmapEncoderCacheOption { + WICBitmapEncoderCacheInMemory = 0x00000000, + WICBitmapEncoderCacheTempFile = 0x00000001, + WICBitmapEncoderNoCache = 0x00000002, + WICBITMAPENCODERCACHEOPTION_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICComponentType { + WICDecoder = 0x00000001, + WICEncoder = 0x00000002, + WICPixelFormatConverter = 0x00000004, + WICMetadataReader = 0x00000008, + WICMetadataWriter = 0x00000010, + WICPixelFormat = 0x00000020, + WICAllComponents = 0x0000003F, + WICCOMPONENTTYPE_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICComponentEnumerateOptions { + WICComponentEnumerateDefault = 0x00000000, + WICComponentEnumerateRefresh = 0x00000001, + WICComponentEnumerateDisabled = 0x80000000, + WICComponentEnumerateUnsigned = 0x40000000, + WICComponentEnumerateBuiltInOnly = 0x20000000, + WICCOMPONENTENUMERATEOPTIONS_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +STRUCT!{struct WICBitmapPattern { + Position: ULARGE_INTEGER, + Length: ULONG, + Pattern: *mut BYTE, + Mask: *mut BYTE, + EndOfStream: BOOL, +}} +ENUM!{enum WICBitmapInterpolationMode { + WICBitmapInterpolationModeNearestNeighbor = 0x00000000, + WICBitmapInterpolationModeLinear = 0x00000001, + WICBitmapInterpolationModeCubic = 0x00000002, + WICBitmapInterpolationModeFant = 0x00000003, + WICBitmapInterpolationModeHighQualityCubic = 0x00000004, + WICBITMAPINTERPOLATIONMODE_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICBitmapPaletteType { + WICBitmapPaletteTypeCustom = 0x00000000, + WICBitmapPaletteTypeMedianCut = 0x00000001, + WICBitmapPaletteTypeFixedBW = 0x00000002, + WICBitmapPaletteTypeFixedHalftone8 = 0x00000003, + WICBitmapPaletteTypeFixedHalftone27 = 0x00000004, + WICBitmapPaletteTypeFixedHalftone64 = 0x00000005, + WICBitmapPaletteTypeFixedHalftone125 = 0x00000006, + WICBitmapPaletteTypeFixedHalftone216 = 0x00000007, + WICBitmapPaletteTypeFixedWebPalette = WICBitmapPaletteTypeFixedHalftone216, + WICBitmapPaletteTypeFixedHalftone252 = 0x00000008, + WICBitmapPaletteTypeFixedHalftone256 = 0x00000009, + WICBitmapPaletteTypeFixedGray4 = 0x0000000A, + WICBitmapPaletteTypeFixedGray16 = 0x0000000B, + WICBitmapPaletteTypeFixedGray256 = 0x0000000C, + WICBITMAPPALETTETYPE_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICBitmapDitherType { + WICBitmapDitherTypeNone = 0x00000000, + WICBitmapDitherTypeSolid = 0x00000000, + WICBitmapDitherTypeOrdered4x4 = 0x00000001, + WICBitmapDitherTypeOrdered8x8 = 0x00000002, + WICBitmapDitherTypeOrdered16x16 = 0x00000003, + WICBitmapDitherTypeSpiral4x4 = 0x00000004, + WICBitmapDitherTypeSpiral8x8 = 0x00000005, + WICBitmapDitherTypeDualSpiral4x4 = 0x00000006, + WICBitmapDitherTypeDualSpiral8x8 = 0x00000007, + WICBitmapDitherTypeErrorDiffusion = 0x00000008, + WICBITMAPDITHERTYPE_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICBitmapAlphaChannelOption { + WICBitmapUseAlpha = 0x00000000, + WICBitmapUsePremultipliedAlpha = 0x00000001, + WICBitmapIgnoreAlpha = 0x00000002, + WICBITMAPALPHACHANNELOPTIONS_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICBitmapTransformOptions { + WICBitmapTransformRotate0 = 0x00000000, + WICBitmapTransformRotate90 = 0x00000001, + WICBitmapTransformRotate180 = 0x00000002, + WICBitmapTransformRotate270 = 0x00000003, + WICBitmapTransformFlipHorizontal = 0x00000008, + WICBitmapTransformFlipVertical = 0x00000010, + WICBITMAPTRANSFORMOPTIONS_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICBitmapLockFlags { + WICBitmapLockRead = 0x00000001, + WICBitmapLockWrite = 0x00000002, + WICBITMAPLOCKFLAGS_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICBitmapDecoderCapabilities { + WICBitmapDecoderCapabilitySameEncoder = 0x00000001, + WICBitmapDecoderCapabilityCanDecodeAllImages = 0x00000002, + WICBitmapDecoderCapabilityCanDecodeSomeImages = 0x00000004, + WICBitmapDecoderCapabilityCanEnumerateMetadata = 0x00000008, + WICBitmapDecoderCapabilityCanDecodeThumbnail = 0x00000010, + WICBITMAPDECODERCAPABILITIES_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICProgressOperation { + WICProgressOperationCopyPixels = 0x00000001, + WICProgressOperationWritePixels = 0x00000002, + WICProgressOperationAll = 0x0000FFFF, + WICPROGRESSOPERATION_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICProgressNotification { + WICProgressNotificationBegin = 0x00010000, + WICProgressNotificationEnd = 0x00020000, + WICProgressNotificationFrequent = 0x00040000, + WICProgressNotificationAll = 0xFFFF0000, + WICPROGRESSNOTIFICATION_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICComponentSigning { + WICComponentSigned = 0x00000001, + WICComponentUnsigned = 0x00000002, + WICComponentSafe = 0x00000004, + WICComponentDisabled = 0x80000000, + WICCOMPONENTSIGNING_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICGifLogicalScreenDescriptorProperties { + WICGifLogicalScreenSignature = 0x00000001, + WICGifLogicalScreenDescriptorWidth = 0x00000002, + WICGifLogicalScreenDescriptorHeight = 0x00000003, + WICGifLogicalScreenDescriptorGlobalColorTableFlag = 0x00000004, + WICGifLogicalScreenDescriptorColorResolution = 0x00000005, + WICGifLogicalScreenDescriptorSortFlag = 0x00000006, + WICGifLogicalScreenDescriptorGlobalColorTableSize = 0x00000007, + WICGifLogicalScreenDescriptorBackgroundColorIndex = 0x00000008, + WICGifLogicalScreenDescriptorPixelAspectRatio = 0x00000009, + WICGifLogicalScreenDescriptorProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICGifImageDescriptorProperties { + WICGifImageDescriptorLeft = 0x00000001, + WICGifImageDescriptorTop = 0x00000002, + WICGifImageDescriptorWidth = 0x00000003, + WICGifImageDescriptorHeight = 0x00000004, + WICGifImageDescriptorLocalColorTableFlag = 0x00000005, + WICGifImageDescriptorInterlaceFlag = 0x00000006, + WICGifImageDescriptorSortFlag = 0x00000007, + WICGifImageDescriptorLocalColorTableSize = 0x00000008, + WICGifImageDescriptorProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICGifGraphicControlExtensionProperties { + WICGifGraphicControlExtensionDisposal = 0x00000001, + WICGifGraphicControlExtensionUserInputFlag = 0x00000002, + WICGifGraphicControlExtensionTransparencyFlag = 0x00000003, + WICGifGraphicControlExtensionDelay = 0x00000004, + WICGifGraphicControlExtensionTransparentColorIndex = 0x00000005, + WICGifGraphicControlExtensionProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICGifApplicationExtensionProperties { + WICGifApplicationExtensionApplication = 0x00000001, + WICGifApplicationExtensionData = 0x00000002, + WICGifApplicationExtensionProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICGifCommentExtensionProperties { + WICGifCommentExtensionText = 0x00000001, + WICGifCommentExtensionProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICJpegCommentProperties { + WICJpegCommentText = 0x00000001, + WICJpegCommentProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICJpegLuminanceProperties { + WICJpegLuminanceTable = 0x00000001, + WICJpegLuminanceProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICJpegChrominanceProperties { + WICJpegChrominanceTable = 0x00000001, + WICJpegChrominanceProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WIC8BIMIptcProperties { + WIC8BIMIptcPString = 0x00000000, + WIC8BIMIptcEmbeddedIPTC = 0x00000001, + WIC8BIMIptcProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WIC8BIMResolutionInfoProperties { + WIC8BIMResolutionInfoPString = 0x00000001, + WIC8BIMResolutionInfoHResolution = 0x00000002, + WIC8BIMResolutionInfoHResolutionUnit = 0x00000003, + WIC8BIMResolutionInfoWidthUnit = 0x00000004, + WIC8BIMResolutionInfoVResolution = 0x00000005, + WIC8BIMResolutionInfoVResolutionUnit = 0x00000006, + WIC8BIMResolutionInfoHeightUnit = 0x00000007, + WIC8BIMResolutionInfoProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WIC8BIMIptcDigestProperties { + WIC8BIMIptcDigestPString = 0x00000001, + WIC8BIMIptcDigestIptcDigest = 0x00000002, + WIC8BIMIptcDigestProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPngGamaProperties { + WICPngGamaGamma = 0x00000001, + WICPngGamaProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPngBkgdProperties { + WICPngBkgdBackgroundColor = 0x00000001, + WICPngBkgdProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPngItxtProperties { + WICPngItxtKeyword = 0x00000001, + WICPngItxtCompressionFlag = 0x00000002, + WICPngItxtLanguageTag = 0x00000003, + WICPngItxtTranslatedKeyword = 0x00000004, + WICPngItxtText = 0x00000005, + WICPngItxtProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPngChrmProperties { + WICPngChrmWhitePointX = 0x00000001, + WICPngChrmWhitePointY = 0x00000002, + WICPngChrmRedX = 0x00000003, + WICPngChrmRedY = 0x00000004, + WICPngChrmGreenX = 0x00000005, + WICPngChrmGreenY = 0x00000006, + WICPngChrmBlueX = 0x00000007, + WICPngChrmBlueY = 0x0000008, + WICPngChrmProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPngHistProperties { + WICPngHistFrequencies = 0x00000001, + WICPngHistProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPngIccpProperties { + WICPngIccpProfileName = 0x00000001, + WICPngIccpProfileData = 0x00000002, + WICPngIccpProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPngSrgbProperties { + WICPngSrgbRenderingIntent = 0x00000001, + WICPngSrgbProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPngTimeProperties { + WICPngTimeYear = 0x00000001, + WICPngTimeMonth = 0x00000002, + WICPngTimeDay = 0x00000003, + WICPngTimeHour = 0x00000004, + WICPngTimeMinute = 0x00000005, + WICPngTimeSecond = 0x00000006, + WICPngTimeProperties_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICSectionAccessLevel { + WICSectionAccessLevelRead = 0x00000001, + WICSectionAccessLevelReadWrite = 0x00000003, + WICSectionAccessLevel_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPixelFormatNumericRepresentation { + WICPixelFormatNumericRepresentationUnspecified = 0x00000000, + WICPixelFormatNumericRepresentationIndexed = 0x00000001, + WICPixelFormatNumericRepresentationUnsignedInteger = 0x00000002, + WICPixelFormatNumericRepresentationSignedInteger = 0x00000003, + WICPixelFormatNumericRepresentationFixed = 0x00000004, + WICPixelFormatNumericRepresentationFloat = 0x00000005, + WICPixelFormatNumericRepresentation_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPlanarOptions { + WICPlanarOptionsDefault = 0x00000000, + WICPlanarOptionsPreserveSubsampling = 0x00000001, + WICPLANAROPTIONS_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICJpegIndexingOptions { + WICJpegIndexingOptionsGenerateOnDemand = 0x00000000, + WICJpegIndexingOptionsGenerateOnLoad = 0x00000001, + WICJpegIndexingOptions_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICJpegTransferMatrix { + WICJpegTransferMatrixIdentity = 0x00000000, + WICJpegTransferMatrixBT601 = 0x00000001, + WICJpegTransferMatrix_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICJpegScanType { + WICJpegScanTypeInterleaved = 0x00000000, + WICJpegScanTypePlanarComponents = 0x00000001, + WICJpegScanTypeProgressive = 0x00000002, + WICJpegScanType_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +STRUCT!{struct WICImageParameters { + PixelFormat: D2D1_PIXEL_FORMAT, + DpiX: FLOAT, + DpiY: FLOAT, + Top: FLOAT, + Left: FLOAT, + PixelWidth: UINT32, + PixelHeight: UINT32, +}} +STRUCT!{struct WICBitmapPlaneDescription { + Format: WICPixelFormatGUID, + Width: UINT, + Height: UINT, +}} +STRUCT!{struct WICBitmapPlane { + Format: WICPixelFormatGUID, + pbBuffer: *mut BYTE, + cbStride: UINT, + cbBufferSize: UINT, +}} +STRUCT!{struct WICJpegFrameHeader { + Width: UINT, + Height: UINT, + TransferMatrix: WICJpegTransferMatrix, + ScanType: WICJpegScanType, + cComponents: UINT, + ComponentIdentifiers: DWORD, + SampleFactors: DWORD, + QuantizationTableIndices: DWORD, +}} +STRUCT!{struct WICJpegScanHeader { + cComponents: UINT, + RestartInterval: UINT, + ComponentSelectors: DWORD, + HuffmanTableIndices: DWORD, + StartSpectralSelection: BYTE, + EndSpectralSelection: BYTE, + SuccessiveApproximationHigh: BYTE, + SuccessiveApproximationLow: BYTE, +}} +RIDL!{#[uuid(0x00000040, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +interface IWICPalette(IWICPaletteVtbl): IUnknown(IUnknownVtbl) { + fn InitializePredefined( + ePaletteType: WICBitmapPaletteType, + fAddTransparentColor: BOOL, + ) -> HRESULT, + fn InitializeCustom( + pColors: *const WICColor, + cCount: UINT, + ) -> HRESULT, + fn InitializeFromBitmap( + pISurface: *const IWICBitmapSource, + cCount: UINT, + fAddTransparentColor: BOOL, + ) -> HRESULT, + fn InitializeFromPalette( + pIPalette: *const IWICPalette, + ) -> HRESULT, + fn GetType( + pePaletteType: *mut WICBitmapPaletteType, + ) -> HRESULT, + fn GetColorCount( + pcCount: *mut UINT, + ) -> HRESULT, + fn GetColors( + cCount: UINT, + pColors: *mut WICColor, + pcActualColors: *mut UINT, + ) -> HRESULT, + fn IsBlackWhite( + pfIsBlackWhite: *mut BOOL, + ) -> HRESULT, + fn IsGrayscale( + pfIsGrayscale: *mut BOOL, + ) -> HRESULT, + fn HasAlpha( + pfHasAlpha: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000120, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +interface IWICBitmapSource(IWICBitmapSourceVtbl): IUnknown(IUnknownVtbl) { + fn GetSize( + puiWidth: *mut UINT, + puiHeight: *mut UINT, + ) -> HRESULT, + fn GetPixelFormat( + pPixelFormat: *mut WICPixelFormatGUID, + ) -> HRESULT, + fn GetResolution( + pDpiX: *mut c_double, + pDpiY: *mut c_double, + ) -> HRESULT, + fn CopyPalette( + pIPalette: *mut IWICPalette, + ) -> HRESULT, + fn CopyPixels( + prc: *const WICRect, + cbStride: UINT, + cbBufferSize: UINT, + pbBuffer: *mut BYTE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000301, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +interface IWICFormatConverter(IWICFormatConverterVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { + fn Initialize( + pISource: *const IWICBitmapSource, + dstFormat: REFWICPixelFormatGUID, + dither: WICBitmapDitherType, + pIPalette: *const IWICPalette, + alphaThresholdPercent: c_double, + paletteTranslate: WICBitmapPaletteType, + ) -> HRESULT, + fn CanConvert( + srcPixelFormat: REFWICPixelFormatGUID, + dstPixelFormat: REFWICPixelFormatGUID, + pfCanConvert: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xbebee9cb, 0x83b0, 0x4dcc, 0x81, 0x32, 0xb0, 0xaa, 0xa5, 0x5e, 0xac, 0x96)] +interface IWICPlanarFormatConverter(IWICPlanarFormatConverterVtbl): + IWICBitmapSource(IWICBitmapSourceVtbl) { + fn Initialize( + ppPlanes: *const *const IWICBitmapSource, + cPlanes: UINT, + dstFormat: REFWICPixelFormatGUID, + dither: WICBitmapDitherType, + pIPalette: *const IWICPalette, + alphaThresholdPercent: c_double, + paletteTranslate: WICBitmapPaletteType, + ) -> HRESULT, + fn CanConvert( + pSrcPixelFormats: *const WICPixelFormatGUID, + cSrcPlanes: UINT, + dstPixelFormat: REFWICPixelFormatGUID, + pfCanConvert: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000302, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +interface IWICBitmapScaler(IWICBitmapScalerVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { + fn Initialize( + pISource: *const IWICBitmapSource, + uiWidth: UINT, + uiHeight: UINT, + mode: WICBitmapInterpolationMode, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xe4fbcf03, 0x223d, 0x4e81, 0x93, 0x33, 0xd6, 0x35, 0x55, 0x6d, 0xd1, 0xb5)] +interface IWICBitmapClipper(IWICBitmapClipperVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { + fn Initialize( + pISource: *const IWICBitmapSource, + prc: *const WICRect, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5009834f, 0x2d6a, 0x41ce, 0x9e, 0x1b, 0x17, 0xc5, 0xaf, 0xf7, 0xa7, 0x82)] +interface IWICBitmapFlipRotator(IWICBitmapFlipRotatorVtbl): + IWICBitmapSource(IWICBitmapSourceVtbl) { + fn Initialize( + pISource: *const IWICBitmapSource, + options: WICBitmapTransformOptions, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000123, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +interface IWICBitmapLock(IWICBitmapLockVtbl): IUnknown(IUnknownVtbl) { + fn GetSize( + puiWidth: *mut UINT, + puiHeight: *mut UINT, + ) -> HRESULT, + fn GetStride( + pcbStride: *mut UINT, + ) -> HRESULT, + fn GetDataPointer( + pcbBufferSize: *mut UINT, + ppbData: *mut WICInProcPointer, + ) -> HRESULT, + fn GetPixelFormat( + pPixelFormat: *mut WICPixelFormatGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000121, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +interface IWICBitmap(IWICBitmapVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { + fn Lock( + prcLock: *const WICRect, + flags: DWORD, + ppILock: *mut *mut IWICBitmapLock, + ) -> HRESULT, + fn SetPalette( + pIPalette: *const IWICPalette, + ) -> HRESULT, + fn SetResolution( + dpiX: c_double, + dpiY: c_double, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3c613a02, 0x34b2, 0x44ea, 0x9a, 0x7c, 0x45, 0xae, 0xa9, 0xc6, 0xfd, 0x6d)] +interface IWICColorContext(IWICColorContextVtbl): IUnknown(IUnknownVtbl) { + fn InitializeFromFilename( + wzFilename: LPCWSTR, + ) -> HRESULT, + fn InitializeFromMemory( + pbBuffer: *const BYTE, + cbBufferSize: UINT, + ) -> HRESULT, + fn InitializeFromExifColorSpace( + value: UINT, + ) -> HRESULT, + fn GetType( + pType: *mut WICColorContextType, + ) -> HRESULT, + fn GetProfileBytes( + cbBuffer: UINT, + pbBuffer: *mut BYTE, + pcbActual: *mut UINT, + ) -> HRESULT, + fn GetExifColorSpace( + pValue: *mut UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb66f034f, 0xd0e2, 0x40ab, 0xb4, 0x36, 0x6d, 0xe3, 0x9e, 0x32, 0x1a, 0x94)] +interface IWICColorTransform(IWICColorTransformVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { + fn Initialize( + pIBitmapSource: *const IWICBitmapSource, + pIContextSource: *const IWICColorContext, + pIContextDest: *const IWICColorContext, + pixelFmtDest: REFWICPixelFormatGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb84e2c09, 0x78c9, 0x4ac4, 0x8b, 0xd3, 0x52, 0x4a, 0xe1, 0x66, 0x3a, 0x2f)] +interface IWICFastMetadataEncoder(IWICFastMetadataEncoderVtbl): IUnknown(IUnknownVtbl) { + fn Commit() -> HRESULT, + fn GetMetadataQueryWriter( + ppIMetadataQueryWriter: *mut *mut IWICMetadataQueryWriter, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x135ff860, 0x22b7, 0x4ddf, 0xb0, 0xf6, 0x21, 0x8f, 0x4f, 0x29, 0x9a, 0x43)] +interface IWICStream(IWICStreamVtbl): IStream(IStreamVtbl) { + fn InitializeFromIStream( + pIStream: *const IStream, + ) -> HRESULT, + fn InitializeFromFilename( + wzFileName: LPCWSTR, + dwDesiredAccess: DWORD, + ) -> HRESULT, + fn InitializeFromMemory( + pbBuffer: WICInProcPointer, + cbBufferSize: DWORD, + ) -> HRESULT, + fn InitializeFromIStreamRegion( + pIStream: *const IStream, + ulOffset: ULARGE_INTEGER, + ulMaxSize: ULARGE_INTEGER, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdc2bb46d, 0x3f07, 0x481e, 0x86, 0x25, 0x22, 0x0c, 0x4a, 0xed, 0xbb, 0x33)] +interface IWICEnumMetadataItem(IWICEnumMetadataItemVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgeltSchema: *mut PROPVARIANT, + rgeltId: *mut PROPVARIANT, + rgeltValue: *mut PROPVARIANT, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppIEnumMetadataItem: *mut *mut IWICEnumMetadataItem, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x30989668, 0xe1c9, 0x4597, 0xb3, 0x95, 0x45, 0x8e, 0xed, 0xb8, 0x08, 0xdf)] +interface IWICMetadataQueryReader(IWICMetadataQueryReaderVtbl): IUnknown(IUnknownVtbl) { + fn GetContainerFormat( + pguidContainerFormat: *mut GUID, + ) -> HRESULT, + fn GetLocation( + cchMaxLength: UINT, + wzNamespace: *mut WCHAR, + pcchActualLength: *mut UINT, + ) -> HRESULT, + fn GetMetadataByName( + wzName: LPCWSTR, + pvarValue: *mut PROPVARIANT, + ) -> HRESULT, + fn GetEnumerator( + ppIEnumString: *mut *mut IEnumString, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa721791a, 0x0def, 0x4d06, 0xbd, 0x91, 0x21, 0x18, 0xbf, 0x1d, 0xb1, 0x0b)] +interface IWICMetadataQueryWriter(IWICMetadataQueryWriterVtbl): + IWICMetadataQueryReader(IWICMetadataQueryReaderVtbl) { + fn SetMetadataByName( + wzName: LPCWSTR, + pvarValue: *const PROPVARIANT, + ) -> HRESULT, + fn RemoveMetadataByName( + wzName: LPCWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000103, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +interface IWICBitmapEncoder(IWICBitmapEncoderVtbl): IUnknown(IUnknownVtbl) { + fn Initialize( + pIStream: *const IStream, + cacheOption: WICBitmapEncoderCacheOption, + ) -> HRESULT, + fn GetContainerFormat( + pguidContainerFormat: *mut GUID, + ) -> HRESULT, + fn GetEncoderInfo( + ppIEncoderInfo: *mut *mut IWICBitmapEncoderInfo, + ) -> HRESULT, + fn SetColorContexts( + cCount: UINT, + ppIColorContext: *const *const IWICColorContext, + ) -> HRESULT, + fn SetPalette( + pIPalette: *const IWICPalette, + ) -> HRESULT, + fn SetThumbnail( + pIThumbnail: *const IWICBitmapSource, + ) -> HRESULT, + fn SetPreview( + pIPreview: *const IWICBitmapSource, + ) -> HRESULT, + fn CreateNewFrame( + ppIFrameEncode: *mut *mut IWICBitmapFrameEncode, + ppIEncoderOptions: *mut *mut IPropertyBag2, + ) -> HRESULT, + fn Commit() -> HRESULT, + fn GetMetadataQueryWriter( + ppIMetadataQueryWriter: *mut *mut IWICMetadataQueryWriter, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x00000105, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +interface IWICBitmapFrameEncode(IWICBitmapFrameEncodeVtbl): IUnknown(IUnknownVtbl) { + fn Initialize( + pIEncoderOptions: *const IPropertyBag2, + ) -> HRESULT, + fn SetSize( + uiWidth: UINT, + uiHeight: UINT, + ) -> HRESULT, + fn SetResolution( + dpiX: c_double, + dpiY: c_double, + ) -> HRESULT, + fn SetPixelFormat( + pPixelFormat: *mut WICPixelFormatGUID, + ) -> HRESULT, + fn SetColorContexts( + cCount: UINT, + ppIColorContext: *const *const IWICColorContext, + ) -> HRESULT, + fn SetPalette( + pIPalette: *const IWICPalette, + ) -> HRESULT, + fn SetThumbnail( + pIThumbnail: *const IWICBitmapSource, + ) -> HRESULT, + fn WritePixels( + lineCount: UINT, + cbStride: UINT, + cbBufferSize: UINT, + pbPixels: *const BYTE, + ) -> HRESULT, + fn WriteSource( + pIBitmapSource: *const IWICBitmapSource, + prc: *const WICRect, + ) -> HRESULT, + fn Commit() -> HRESULT, + fn GetMetadataQueryWriter( + ppIMetadataQueryWriter: *mut *mut IWICMetadataQueryWriter, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf928b7b8, 0x2221, 0x40c1, 0xb7, 0x2e, 0x7e, 0x82, 0xf1, 0x97, 0x4d, 0x1a)] +interface IWICPlanarBitmapFrameEncode(IWICPlanarBitmapFrameEncodeVtbl): IUnknown(IUnknownVtbl) { + fn WritePixels( + lineCount: UINT, + pPlanes: *const WICBitmapPlane, + cPlanes: UINT, + ) -> HRESULT, + fn WriteSource( + ppPlanes: *const *const IWICBitmapSource, + cPlanes: UINT, + prcSource: *const WICRect, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x04c75bf8, 0x3ce1, 0x473b, 0xac, 0xc5, 0x3c, 0xc4, 0xf5, 0xe9, 0x49, 0x99)] +interface IWICImageEncoder(IWICImageEncoderVtbl): IUnknown(IUnknownVtbl) { + fn WriteFrame( + pImage: *const ID2D1Image, + pFrameEncode: *const IWICBitmapFrameEncode, + pImageParameters: *const WICImageParameters, + ) -> HRESULT, + fn WriteFrameThumbnail( + pImage: *const ID2D1Image, + pFrameEncode: *const IWICBitmapFrameEncode, + pImageParameters: *const WICImageParameters, + ) -> HRESULT, + fn WriteThumbnail( + pImage: *const ID2D1Image, + pEncoder: *const IWICBitmapEncoder, + pImageParameters: *const WICImageParameters, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9edde9e7, 0x8dee, 0x47ea, 0x99, 0xdf, 0xe6, 0xfa, 0xf2, 0xed, 0x44, 0xbf)] +interface IWICBitmapDecoder(IWICBitmapDecoderVtbl): IUnknown(IUnknownVtbl) { + fn QueryCapability( + pIStream: *const IStream, + pdwCapability: *mut DWORD, + ) -> HRESULT, + fn Initialize( + pIStream: *const IStream, + cacheOptions: WICDecodeOptions, + ) -> HRESULT, + fn GetContainerFormat( + pguidContainerFormat: *mut GUID, + ) -> HRESULT, + fn GetDecoderInfo( + ppIDecoderInfo: *mut *mut IWICBitmapDecoderInfo, + ) -> HRESULT, + fn CopyPalette( + pIPalette: *const IWICPalette, + ) -> HRESULT, + fn GetMetadataQueryReader( + ppIMetadataQueryReader: *mut *mut IWICMetadataQueryReader, + ) -> HRESULT, + fn GetPreview( + ppIBitmapSource: *mut *mut IWICBitmapSource, + ) -> HRESULT, + fn GetColorContexts( + cCount: UINT, + ppIColorContexts: *mut *mut IWICColorContext, + pcActualCount: *mut UINT, + ) -> HRESULT, + fn GetThumbnail( + ppIThumbnail: *mut *mut IWICBitmapSource, + ) -> HRESULT, + fn GetFrameCount( + pCount: *mut UINT, + ) -> HRESULT, + fn GetFrame( + index: UINT, + ppIBitmapFrame: *mut *mut IWICBitmapFrameDecode, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3b16811b, 0x6a43, 0x4ec9, 0xb7, 0x13, 0x3d, 0x5a, 0x0c, 0x13, 0xb9, 0x40)] +interface IWICBitmapSourceTransform(IWICBitmapSourceTransformVtbl): IUnknown(IUnknownVtbl) { + fn CopyPixels( + prc: *const WICRect, + uiWidth: UINT, + uiHeight: UINT, + pguidDstFormat: *const WICPixelFormatGUID, + dstTransform: WICBitmapTransformOptions, + nStride: UINT, + cbBufferSize: UINT, + pbBuffer: *mut BYTE, + ) -> HRESULT, + fn GetClosestSize( + puiWidth: *mut UINT, + puiHeight: *mut UINT, + ) -> HRESULT, + fn GetClosestPixelFormat( + pguidDstFormat: *mut WICPixelFormatGUID, + ) -> HRESULT, + fn DoesSupportTransform( + dstTransform: WICBitmapTransformOptions, + pfIsSupported: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3aff9cce, 0xbe95, 0x4303, 0xb9, 0x27, 0xe7, 0xd1, 0x6f, 0xf4, 0xa6, 0x13)] +interface IWICPlanarBitmapSourceTransform(IWICPlanarBitmapSourceTransformVtbl): + IUnknown(IUnknownVtbl) { + fn DoesSupportTransform( + puiWidth: *mut UINT, + puiHeight: *mut UINT, + dstTransform: WICBitmapTransformOptions, + dstPlanarOptions: WICPlanarOptions, + pguidDstFormats: *const WICPixelFormatGUID, + pPlaneDescriptions: *mut WICBitmapPlaneDescription, + cPlanes: UINT, + pfIsSupported: *mut BOOL, + ) -> HRESULT, + fn CopyPixels( + prcSource: *const WICRect, + uiWidth: UINT, + uiHeight: UINT, + dstTransform: WICBitmapTransformOptions, + dstPlanarOptions: WICPlanarOptions, + pDstPlanes: *const WICBitmapPlane, + cPlanes: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3b16811b, 0x6a43, 0x4ec9, 0xa8, 0x13, 0x3d, 0x93, 0x0c, 0x13, 0xb9, 0x40)] +interface IWICBitmapFrameDecode(IWICBitmapFrameDecodeVtbl): + IWICBitmapSource(IWICBitmapSourceVtbl) { + fn GetMetadataQueryReader( + ppIMetadataQueryReader: *mut *mut IWICMetadataQueryReader, + ) -> HRESULT, + fn GetColorContexts( + cCount: UINT, + ppIColorContexts: *mut *mut IWICColorContext, + pcActualCount: *mut UINT, + ) -> HRESULT, + fn GetThumbnail( + ppIThumbnail: *mut *mut IWICBitmapSource, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdaac296f, 0x7aa5, 0x4dbf, 0x8d, 0x15, 0x22, 0x5c, 0x59, 0x76, 0xf8, 0x91)] +interface IWICProgressiveLevelControl(IWICProgressiveLevelControlVtbl): IUnknown(IUnknownVtbl) { + fn GetLevelCount( + pcLevels: *mut UINT, + ) -> HRESULT, + fn GetCurrentLevel( + pnLevel: *mut UINT, + ) -> HRESULT, + fn SetCurrentLevel( + nLevel: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4776f9cd, 0x9517, 0x45fa, 0xbf, 0x24, 0xe8, 0x9c, 0x5e, 0xc5, 0xc6, 0x0c)] +interface IWICProgressCallback(IWICProgressCallbackVtbl): IUnknown(IUnknownVtbl) { + fn Notify( + uFrameNum: ULONG, + operation: WICProgressOperation, + dblProgress: c_double, + ) -> HRESULT, +}} +FN!{stdcall PFNProgressNotification( + pvData: LPVOID, + uFrameNum: ULONG, + operation: WICProgressOperation, + dblProgress: c_double, +) -> HRESULT} +RIDL!{#[uuid(0x64c1024e, 0xc3cf, 0x4462, 0x80, 0x78, 0x88, 0xc2, 0xb1, 0x1c, 0x46, 0xd9)] +interface IWICBitmapCodecProgressNotification(IWICBitmapCodecProgressNotificationVtbl): + IUnknown(IUnknownVtbl) { + fn RegisterProgressNotification( + pfnProgressNotification: PFNProgressNotification, + pvData: LPVOID, + dwProgressFlags: DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x23bc3f0a, 0x698b, 0x4357, 0x88, 0x6b, 0xf2, 0x4d, 0x50, 0x67, 0x13, 0x34)] +interface IWICComponentInfo(IWICComponentInfoVtbl): IUnknown(IUnknownVtbl) { + fn GetComponentType( + pType: *mut WICComponentType, + ) -> HRESULT, + fn GetCLSID( + pclsid: *mut CLSID, + ) -> HRESULT, + fn GetSigningStatus( + pStatus: *mut DWORD, + ) -> HRESULT, + fn GetAuthor( + cchAuthor: UINT, + wzAuthor: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, + fn GetVendorGUID( + pguidVendor: *mut GUID, + ) -> HRESULT, + fn GetVersion( + cchVersion: UINT, + wzVersion: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, + fn GetSpecVersion( + cchSpecVersion: UINT, + wzSpecVersion: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, + fn GetFriendlyName( + cchFriendlyName: UINT, + wzFriendlyName: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9f34fb65, 0x13f4, 0x4f15, 0xbc, 0x57, 0x37, 0x26, 0xb5, 0xe5, 0x3d, 0x9f)] +interface IWICFormatConverterInfo(IWICFormatConverterInfoVtbl): + IWICComponentInfo(IWICComponentInfoVtbl) { + fn GetPixelFormats( + cFormats: UINT, + pPixelFormatGUIDs: *mut WICPixelFormatGUID, + pcActual: *mut UINT, + ) -> HRESULT, + fn CreateInstance( + ppIConverter: *mut *mut IWICFormatConverter, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xe87a44c4, 0xb76e, 0x4c47, 0x8b, 0x09, 0x29, 0x8e, 0xb1, 0x2a, 0x27, 0x14)] +interface IWICBitmapCodecInfo(IWICBitmapCodecInfoVtbl): IWICComponentInfo(IWICComponentInfoVtbl) { + fn GetContainerFormat( + pguidContainerFormat: *mut GUID, + ) -> HRESULT, + fn GetPixelFormats( + cFormats: UINT, + pguidPixelFormats: *mut GUID, + pcActual: *mut UINT, + ) -> HRESULT, + fn GetColorManagementVersion( + cchColorManagementVersion: UINT, + wzColorManagementVersion: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, + fn GetDeviceManufacturer( + cchDeviceManufacturer: UINT, + wzDeviceManufacturer: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, + fn GetDeviceModels( + cchDeviceModels: UINT, + wzDeviceModels: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, + fn GetMimeTypes( + cchMimeTypes: UINT, + wzMimeTypes: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, + fn GetFileExtensions( + cchFileExtensions: UINT, + wzFileExtensions: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, + fn DoesSupportAnimation( + pfSupportAnimation: *mut BOOL, + ) -> HRESULT, + fn DoesSupportChromakey( + pfSupportChromakey: *mut BOOL, + ) -> HRESULT, + fn DoesSupportLossless( + pfSupportLossless: *mut BOOL, + ) -> HRESULT, + fn DoesSupportMultiframe( + pfSupportMultiframe: *mut BOOL, + ) -> HRESULT, + fn MatchesMimeType( + wzMimeType: LPCWSTR, + pfMatches: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x94c9b4ee, 0xa09f, 0x4f92, 0x8a, 0x1e, 0x4a, 0x9b, 0xce, 0x7e, 0x76, 0xfb)] +interface IWICBitmapEncoderInfo(IWICBitmapEncoderInfoVtbl): + IWICBitmapCodecInfo(IWICBitmapCodecInfoVtbl) { + fn CreateInstance( + ppIBitmapEncoder: *mut *mut IWICBitmapEncoder, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd8cd007f, 0xd08f, 0x4191, 0x9b, 0xfc, 0x23, 0x6e, 0xa7, 0xf0, 0xe4, 0xb5)] +interface IWICBitmapDecoderInfo(IWICBitmapDecoderInfoVtbl): + IWICBitmapCodecInfo(IWICBitmapCodecInfoVtbl) { + fn GetPatterns( + cbSizePatterns: UINT, + pPatterns: *mut WICBitmapPattern, + pcPatterns: *mut UINT, + pcbPatternsActual: *mut UINT, + ) -> HRESULT, + fn MatchesPattern( + pIStream: *const IStream, + pfMatches: *mut BOOL, + ) -> HRESULT, + fn CreateInstance( + ppIBitmapDecoder: *mut *mut IWICBitmapDecoder, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xe8eda601, 0x3d48, 0x431a, 0xab, 0x44, 0x69, 0x05, 0x9b, 0xe8, 0x8b, 0xbe)] +interface IWICPixelFormatInfo(IWICPixelFormatInfoVtbl): IWICComponentInfo(IWICComponentInfoVtbl) { + fn GetFormatGUID( + pFormat: *mut GUID, + ) -> HRESULT, + fn GetColorContext( + ppIColorContext: *mut *mut IWICColorContext, + ) -> HRESULT, + fn GetBitsPerPixel( + puiBitsPerPixel: *mut UINT, + ) -> HRESULT, + fn GetChannelCount( + puiChannelCount: *mut UINT, + ) -> HRESULT, + fn GetChannelMask( + uiChannelIndex: UINT, + cbMaskBuffer: UINT, + pbMaskBuffer: *mut BYTE, + pcbActual: *mut UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa9db33a2, 0xaf5f, 0x43c7, 0xb6, 0x79, 0x74, 0xf5, 0x98, 0x4b, 0x5a, 0xa4)] +interface IWICPixelFormatInfo2(IWICPixelFormatInfo2Vtbl): + IWICPixelFormatInfo(IWICPixelFormatInfoVtbl) { + fn SupportsTransparency( + pfSupportsTransparency: *mut BOOL, + ) -> HRESULT, + fn GetNumericRepresentation( + pNumericRepresentation: *mut WICPixelFormatNumericRepresentation, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xec5ec8a9, 0xc395, 0x4314, 0x9c, 0x77, 0x54, 0xd7, 0xa9, 0x35, 0xff, 0x70)] +interface IWICImagingFactory(IWICImagingFactoryVtbl): IUnknown(IUnknownVtbl) { + fn CreateDecoderFromFilename( + wzFilename: LPCWSTR, + pguidVendor: *const GUID, + dwDesiredAccess: DWORD, + metadataOptions: WICDecodeOptions, + ppIDecoder: *mut *mut IWICBitmapDecoder, + ) -> HRESULT, + fn CreateDecoderFromStream( + pIStream: *const IStream, + pguidVendor: *const GUID, + metadataOptions: WICDecodeOptions, + ppIDecoder: *mut *mut IWICBitmapDecoder, + ) -> HRESULT, + fn CreateDecoderFromFileHandle( + hFile: ULONG_PTR, + pguidVendor: *const GUID, + metadataOptions: WICDecodeOptions, + ppIDecoder: *mut *mut IWICBitmapDecoder, + ) -> HRESULT, + fn CreateComponentInfo( + clsidComponent: REFCLSID, + ppIInfo: *mut *mut IWICComponentInfo, + ) -> HRESULT, + fn CreateDecoder( + guidContainerFormat: REFGUID, + pguidVendor: *const GUID, + ppIDecoder: *mut *mut IWICBitmapDecoder, + ) -> HRESULT, + fn CreateEncoder( + guidContainerFormat: REFGUID, + pguidVendor: *const GUID, + ppIEncoder: *mut *mut IWICBitmapEncoder, + ) -> HRESULT, + fn CreatePalette( + ppIPalette: *mut *mut IWICPalette, + ) -> HRESULT, + fn CreateFormatConverter( + ppIFormatConverter: *mut *mut IWICFormatConverter, + ) -> HRESULT, + fn CreateBitmapScaler( + ppIBitmapScaler: *mut *mut IWICBitmapScaler, + ) -> HRESULT, + fn CreateBitmapClipper( + ppIBitmapClipper: *mut *mut IWICBitmapClipper, + ) -> HRESULT, + fn CreateBitmapFlipRotator( + ppIBitmapFlipRotator: *mut *mut IWICBitmapFlipRotator, + ) -> HRESULT, + fn CreateStream( + ppIWICStream: *mut *mut IWICStream, + ) -> HRESULT, + fn CreateColorContext( + ppIWICColorContext: *mut *mut IWICColorContext, + ) -> HRESULT, + fn CreateColorTransformer( + ppIWICColorTransform: *mut *mut IWICColorTransform, + ) -> HRESULT, + fn CreateBitmap( + uiWidth: UINT, + uiHeight: UINT, + pixelFormat: REFWICPixelFormatGUID, + option: WICBitmapCreateCacheOption, + ppIBitmap: *mut *mut IWICBitmap, + ) -> HRESULT, + fn CreateBitmapFromSource( + pIBitmapSource: *const IWICBitmapSource, + option: WICBitmapCreateCacheOption, + ppIBitmap: *mut *mut IWICBitmap, + ) -> HRESULT, + fn CreateBitmapFromSourceRect( + pIBitmapSource: *const IWICBitmapSource, + x: UINT, + y: UINT, + width: UINT, + height: UINT, + ppIBitmap: *mut *mut IWICBitmap, + ) -> HRESULT, + fn CreateBitmapFromMemory( + uiWidth: UINT, + uiHeight: UINT, + pixelFormat: REFWICPixelFormatGUID, + cbStride: UINT, + cbBufferSize: UINT, + pbBuffer: *const BYTE, + ppIBitmap: *mut *mut IWICBitmap, + ) -> HRESULT, + fn CreateBitmapFromHBITMAP( + hBitmap: HBITMAP, + hPalette: HPALETTE, + options: WICBitmapAlphaChannelOption, + ppIBitmap: *mut *mut IWICBitmap, + ) -> HRESULT, + fn CreateBitmapFromHICON( + hIcon: HICON, + ppIBitmap: *mut *mut IWICBitmap, + ) -> HRESULT, + fn CreateComponentEnumerator( + componentTypes: DWORD, + options: DWORD, + ppIEnumUnknown: *mut *mut IEnumUnknown, + ) -> HRESULT, + fn CreateFastMetadataEncoderFromDecoder( + pIDecoder: *const IWICBitmapDecoder, + ppIFastEncoder: *mut *mut IWICFastMetadataEncoder, + ) -> HRESULT, + fn CreateFastMetadataEncoderFromFrameDecode( + pIFrameDecoder: *const IWICBitmapFrameDecode, + ppIFastEncoder: *mut *mut IWICFastMetadataEncoder, + ) -> HRESULT, + fn CreateQueryWriter( + guidMetadataFormat: REFGUID, + pguidVendor: *const GUID, + ppIQueryWriter: *mut *mut IWICMetadataQueryWriter, + ) -> HRESULT, + fn CreateQueryWriterFromReader( + pIQueryReader: *const IWICMetadataQueryReader, + pguidVendor: *const GUID, + ppIQueryWriter: *mut *mut IWICMetadataQueryWriter, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7b816b45, 0x1996, 0x4476, 0xb1, 0x32, 0xde, 0x9e, 0x24, 0x7c, 0x8a, 0xf0)] +interface IWICImagingFactory2(IWICImagingFactory2Vtbl): + IWICImagingFactory(IWICImagingFactoryVtbl) { + fn CreateImageEncoder( + pD2DDevice: *const ID2D1Device, + ppWICImageEncoder: *mut *mut IWICImageEncoder, + ) -> HRESULT, +}} +extern "system" { + pub fn WICConvertBitmapSource( + dstFormat: REFWICPixelFormatGUID, + pISrc: *const IWICBitmapSource, + ppIDst: *mut *mut IWICBitmapSource, + ) -> HRESULT; + pub fn WICCreateBitmapFromSection( + width: UINT, + height: UINT, + pixelFormat: REFWICPixelFormatGUID, + hSection: HANDLE, + stride: UINT, + offset: UINT, + ppIBitmap: *mut *mut IWICBitmap, + ) -> HRESULT; + pub fn WICCreateBitmapFromSectionEx( + width: UINT, + height: UINT, + pixelFormat: REFWICPixelFormatGUID, + hSection: HANDLE, + stride: UINT, + offset: UINT, + desiredAccessLevel: WICSectionAccessLevel, + ppIBitmap: *mut *mut IWICBitmap, + ) -> HRESULT; + pub fn WICMapGuidToShortName( + guid: REFGUID, + cchName: UINT, + wzName: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT; + pub fn WICMapShortNameToGuid( + wzName: PCWSTR, + pguid: *mut GUID, + ) -> HRESULT; + pub fn WICMapSchemaToName( + guidMetadataFormat: REFGUID, + pwzSchema: LPWSTR, + cchName: UINT, + wzName: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT; +} +pub const FACILITY_WINCODEC_ERR: HRESULT = 0x898; +pub const WINCODEC_ERR_BASE: HRESULT = 0x2000; +/// intsafe.h, 0x216 = 534 = ERROR_ARITHMETIC_OVERFLOW +pub const INTSAFE_E_ARITHMETIC_OVERFLOW: HRESULT = 0x80070216; +#[inline] +pub fn MAKE_WINCODECHR(severity: HRESULT, code: HRESULT) -> HRESULT { + MAKE_HRESULT!(severity, FACILITY_WINCODEC_ERR, WINCODEC_ERR_BASE + code) +} +#[inline] +pub fn MAKE_WINCODECHR_ERR(code: HRESULT) -> HRESULT { + MAKE_WINCODECHR(SEVERITY_ERROR, code) +} +pub const WINCODEC_ERR_GENERIC_ERROR: HRESULT = E_FAIL; +pub const WINCODEC_ERR_INVALIDPARAMETER: HRESULT = E_INVALIDARG; +pub const WINCODEC_ERR_OUTOFMEMORY: HRESULT = E_OUTOFMEMORY; +pub const WINCODEC_ERR_NOTIMPLEMENTED: HRESULT = E_NOTIMPL; +pub const WINCODEC_ERR_ABORTED: HRESULT = E_ABORT; +pub const WINCODEC_ERR_ACCESSDENIED: HRESULT = E_ACCESSDENIED; +pub const WINCODEC_ERR_VALUEOVERFLOW: HRESULT = INTSAFE_E_ARITHMETIC_OVERFLOW; +ENUM!{enum WICTiffCompressionOption { + WICTiffCompressionDontCare = 0x00000000, + WICTiffCompressionNone = 0x00000001, + WICTiffCompressionCCITT3 = 0x00000002, + WICTiffCompressionCCITT4 = 0x00000003, + WICTiffCompressionLZW = 0x00000004, + WICTiffCompressionRLE = 0x00000005, + WICTiffCompressionZIP = 0x00000006, + WICTiffCompressionLZWHDifferencing = 0x00000007, + WICTIFFCOMPRESSIONOPTION_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICJpegYCrCbSubsamplingOption { + WICJpegYCrCbSubsamplingDefault = 0x00000000, + WICJpegYCrCbSubsampling420 = 0x00000001, + WICJpegYCrCbSubsampling422 = 0x00000002, + WICJpegYCrCbSubsampling444 = 0x00000003, + WICJpegYCrCbSubsampling440 = 0x00000004, + WICJPEGYCRCBSUBSAMPLING_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICPngFilterOption { + WICPngFilterUnspecified = 0x00000000, + WICPngFilterNone = 0x00000001, + WICPngFilterSub = 0x00000002, + WICPngFilterUp = 0x00000003, + WICPngFilterAverage = 0x00000004, + WICPngFilterPaeth = 0x00000005, + WICPngFilterAdaptive = 0x00000006, + WICPNGFILTEROPTION_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICNamedWhitePoint { + WICWhitePointDefault = 0x00000001, + WICWhitePointDaylight = 0x00000002, + WICWhitePointCloudy = 0x00000004, + WICWhitePointShade = 0x00000008, + WICWhitePointTungsten = 0x00000010, + WICWhitePointFluorescent = 0x00000020, + WICWhitePointFlash = 0x00000040, + WICWhitePointUnderwater = 0x00000080, + WICWhitePointCustom = 0x00000100, + WICWhitePointAutoWhiteBalance = 0x00000200, + WICWhitePointAsShot = WICWhitePointDefault, + WICNAMEDWHITEPOINT_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICRawCapabilities { + WICRawCapabilityNotSupported = 0x00000000, + WICRawCapabilityGetSupported = 0x00000001, + WICRawCapabilityFullySupported = 0x00000002, + WICRAWCAPABILITIES_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICRawRotationCapabilities { + WICRawRotationCapabilityNotSupported = 0x00000000, + WICRawRotationCapabilityGetSupported = 0x00000001, + WICRawRotationCapabilityNinetyDegreesSupported = 0x00000002, + WICRawRotationCapabilityFullySupported = 0x00000003, + WICRAWROTATIONCAPABILITIES_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +STRUCT!{struct WICRawCapabilitiesInfo { + cbSize: UINT, + CodecMajorVersion: UINT, + CodecMinorVersion: UINT, + ExposureCompensationSupport: WICRawCapabilities, + ContrastSupport: WICRawCapabilities, + RGBWhitePointSupport: WICRawCapabilities, + NamedWhitePointSupport: WICRawCapabilities, + NamedWhitePointSupportMask: UINT, + KelvinWhitePointSupport: WICRawCapabilities, + GammaSupport: WICRawCapabilities, + TintSupport: WICRawCapabilities, + SaturationSupport: WICRawCapabilities, + SharpnessSupport: WICRawCapabilities, + NoiseReductionSupport: WICRawCapabilities, + DestinationColorProfileSupport: WICRawCapabilities, + ToneCurveSupport: WICRawCapabilities, + RotationSupport: WICRawRotationCapabilities, + RenderModeSupport: WICRawCapabilities, +}} +ENUM!{enum WICRawParameterSet { + WICAsShotParameterSet = 0x00000001, + WICUserAdjustedParameterSet = 0x00000002, + WICAutoAdjustedParameterSet = 0x00000003, + WICRAWPARAMETERSET_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICRawRenderMode { + WICRawRenderModeDraft = 0x00000001, + WICRawRenderModeNormal = 0x00000002, + WICRawRenderModeBestQuality = 0x00000003, + WICRAWRENDERMODE_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +STRUCT!{struct WICRawToneCurvePoint { + Input: c_double, + Output: c_double, +}} +STRUCT!{struct WICRawToneCurve { + cPoints: UINT, + aPoints: [WICRawToneCurvePoint; 1], +}} +pub const WICRawChangeNotification_ExposureCompensation: UINT = 0x00000001; +pub const WICRawChangeNotification_NamedWhitePoint: UINT = 0x00000002; +pub const WICRawChangeNotification_KelvinWhitePoint: UINT = 0x00000004; +pub const WICRawChangeNotification_RGBWhitePoint: UINT = 0x00000008; +pub const WICRawChangeNotification_Contrast: UINT = 0x00000010; +pub const WICRawChangeNotification_Gamma: UINT = 0x00000020; +pub const WICRawChangeNotification_Sharpness: UINT = 0x00000040; +pub const WICRawChangeNotification_Saturation: UINT = 0x00000080; +pub const WICRawChangeNotification_Tint: UINT = 0x00000100; +pub const WICRawChangeNotification_NoiseReduction: UINT = 0x00000200; +pub const WICRawChangeNotification_DestinationColorContext: UINT = 0x00000400; +pub const WICRawChangeNotification_ToneCurve: UINT = 0x00000800; +pub const WICRawChangeNotification_Rotation: UINT = 0x00001000; +pub const WICRawChangeNotification_RenderMode: UINT = 0x00002000; +RIDL!{#[uuid(0x95c75a6e, 0x3e8c, 0x4ec2, 0x85, 0xa8, 0xae, 0xbc, 0xc5, 0x51, 0xe5, 0x9b)] +interface IWICDevelopRawNotificationCallback(IWICDevelopRawNotificationCallbackVtbl): + IUnknown(IUnknownVtbl) { + fn Notify( + NotificationMask: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xfbec5e44, 0xf7be, 0x4b65, 0xb7, 0xf8, 0xc0, 0xc8, 0x1f, 0xef, 0x02, 0x6d)] +interface IWICDevelopRaw(IWICDevelopRawVtbl): IWICBitmapFrameDecode(IWICBitmapFrameDecodeVtbl) { + fn QueryRawCapabilitiesInfo( + pInfo: *mut WICRawCapabilitiesInfo, + ) -> HRESULT, + fn LoadParameterSet( + ParameterSet: WICRawParameterSet, + ) -> HRESULT, + fn GetCurrentParameterSet( + ppCurrentParameterSet: *mut *mut IPropertyBag2, + ) -> HRESULT, + fn SetExposureCompensation( + ev: c_double, + ) -> HRESULT, + fn GetExposureCompensation( + pEV: *mut c_double, + ) -> HRESULT, + fn SetWhitePointRGB( + Red: UINT, + Green: UINT, + Blue: UINT, + ) -> HRESULT, + fn GetWhitePointRGB( + pRed: *mut UINT, + pGreen: *mut UINT, + pBlue: *mut UINT, + ) -> HRESULT, + fn SetNamedWhitePoint( + WhitePoint: WICNamedWhitePoint, + ) -> HRESULT, + fn GetNamedWhitePoint( + pWhitePoint: *mut WICNamedWhitePoint, + ) -> HRESULT, + fn SetWhitePointKelvin( + WhitePointKelvin: UINT, + ) -> HRESULT, + fn GetWhitePointKelvin( + pWhitePointKelvin: *mut UINT, + ) -> HRESULT, + fn GetKelvinRangeInfo( + pMinKelvinTemp: *mut UINT, + pMaxKelvinTemp: *mut UINT, + pKelvinTempStepValue: *mut UINT, + ) -> HRESULT, + fn SetContrast( + Contrast: c_double, + ) -> HRESULT, + fn GetContrast( + pContrast: *mut c_double, + ) -> HRESULT, + fn SetGamma( + Gamma: c_double, + ) -> HRESULT, + fn GetGamma( + pGamma: *mut c_double, + ) -> HRESULT, + fn SetSharpness( + Sharpness: c_double, + ) -> HRESULT, + fn GetSharpness( + pSharpness: *mut c_double, + ) -> HRESULT, + fn SetSaturation( + Saturation: c_double, + ) -> HRESULT, + fn GetSaturation( + pSaturation: *mut c_double, + ) -> HRESULT, + fn SetTint( + Tint: c_double, + ) -> HRESULT, + fn GetTint( + pTint: *mut c_double, + ) -> HRESULT, + fn SetNoiseReduction( + NoiseReduction: c_double, + ) -> HRESULT, + fn GetNoiseReduction( + pNoiseReduction: *mut c_double, + ) -> HRESULT, + fn SetDestinationColorContext( + pColorContext: *const IWICColorContext, + ) -> HRESULT, + fn SetToneCurve( + cbToneCurveSize: UINT, + pToneCurve: *const WICRawToneCurve, + ) -> HRESULT, + fn GetToneCurve( + cbToneCurveBufferSize: UINT, + pToneCurve: *mut WICRawToneCurve, + pcbActualToneCurveBufferSize: *mut UINT, + ) -> HRESULT, + fn SetRotation( + Rotation: c_double, + ) -> HRESULT, + fn GetRotation( + pRotation: *mut c_double, + ) -> HRESULT, + fn SetRenderMode( + RenderMode: WICRawRenderMode, + ) -> HRESULT, + fn GetRenderMode( + pRenderMode: *mut WICRawRenderMode, + ) -> HRESULT, + fn SetNotificationCallback( + pCallback: *const IWICDevelopRawNotificationCallback, + ) -> HRESULT, +}} +ENUM!{enum WICDdsDimension { + WICDdsTexture1D = 0x00000000, + WICDdsTexture2D = 0x00000001, + WICDdsTexture3D = 0x00000002, + WICDdsTextureCube = 0x00000003, + WICDDSTEXTURE_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +ENUM!{enum WICDdsAlphaMode { + WICDdsAlphaModeUnknown = 0x00000000, + WICDdsAlphaModeStraight = 0x00000001, + WICDdsAlphaModePremultiplied = 0x00000002, + WICDdsAlphaModeOpaque = 0x00000003, + WICDdsAlphaModeCustom = 0x00000004, + WICDDSALPHAMODE_FORCE_DWORD = CODEC_FORCE_DWORD, +}} +STRUCT!{struct WICDdsParameters { + Width: UINT, + Height: UINT, + Depth: UINT, + MipLevels: UINT, + ArraySize: UINT, + DxgiFormat: DXGI_FORMAT, + Dimension: WICDdsDimension, + AlphaMode: WICDdsAlphaMode, +}} +RIDL!{#[uuid(0x409cd537, 0x8532, 0x40cb, 0x97, 0x74, 0xe2, 0xfe, 0xb2, 0xdf, 0x4e, 0x9c)] +interface IWICDdsDecoder(IWICDdsDecoderVtbl): IUnknown(IUnknownVtbl) { + fn GetParameters( + pParameters: *mut WICDdsParameters, + ) -> HRESULT, + fn GetFrame( + arrayIndex: UINT, + mipLevel: UINT, + sliceIndex: UINT, + ppIBitmapFrame: *mut *mut IWICBitmapFrameDecode, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x5cacdb4c, 0x407e, 0x41b3, 0xb9, 0x36, 0xd0, 0xf0, 0x10, 0xcd, 0x67, 0x32)] +interface IWICDdsEncoder(IWICDdsEncoderVtbl): IUnknown(IUnknownVtbl) { + fn SetParameters( + pParameters: *const WICDdsParameters, + ) -> HRESULT, + fn GetParameters( + pParameters: *mut WICDdsParameters, + ) -> HRESULT, + fn CreateNewFrame( + ppIFrameEncode: *mut *mut IWICBitmapFrameEncode, + pArrayIndex: *mut UINT, + pMipLevel: *mut UINT, + pSliceIndex: *mut UINT, + ) -> HRESULT, +}} +STRUCT!{struct WICDdsFormatInfo { + DxgiFormat: DXGI_FORMAT, + BytesPerBlock: UINT, + BlockWidth: UINT, + BlockHeight: UINT, +}} +RIDL!{#[uuid(0x3d4c0c61, 0x18a4, 0x41e4, 0xbd, 0x80, 0x48, 0x1a, 0x4f, 0xc9, 0xf4, 0x64)] +interface IWICDdsFrameDecode(IWICDdsFrameDecodeVtbl): IUnknown(IUnknownVtbl) { + fn GetSizeInBlocks( + pWidthInBlocks: *mut UINT, + pHeightInBlocks: *mut UINT, + ) -> HRESULT, + fn GetFormatInfo( + pFormatInfo: *mut WICDdsFormatInfo, + ) -> HRESULT, + fn CopyBlocks( + prcBoundsInBlocks: *const WICRect, + cbStride: UINT, + cbBufferSize: UINT, + pbBuffer: *mut BYTE, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x8939f66e, 0xc46a, 0x4c21, 0xa9, 0xd1, 0x98, 0xb3, 0x27, 0xce, 0x16, 0x79)] +interface IWICJpegFrameDecode(IWICJpegFrameDecodeVtbl): IUnknown(IUnknownVtbl) { + fn DoesSupportIndexing( + pfIndexingSupported: *mut BOOL, + ) -> HRESULT, + fn SetIndexing( + options: WICJpegIndexingOptions, + horizontalIntervalSize: UINT, + ) -> HRESULT, + fn ClearIndexing() -> HRESULT, + fn GetAcHuffmanTable( + scanIndex: UINT, + tableIndex: UINT, + pAcHuffmanTable: *mut DXGI_JPEG_AC_HUFFMAN_TABLE, + ) -> HRESULT, + fn GetDcHuffmanTable( + scanIndex: UINT, + tableIndex: UINT, + pDcHuffmanTable: *mut DXGI_JPEG_DC_HUFFMAN_TABLE, + ) -> HRESULT, + fn GetQuantizationTable( + scanIndex: UINT, + tableIndex: UINT, + pQuantizationTable: *mut DXGI_JPEG_QUANTIZATION_TABLE, + ) -> HRESULT, + fn GetFrameHeader( + pFrameHeader: *mut WICJpegFrameHeader, + ) -> HRESULT, + fn GetScanHeader( + scanIndex: UINT, + pScanHeader: *mut WICJpegScanHeader, + ) -> HRESULT, + fn CopyScan( + scanIndex: UINT, + scanOffset: UINT, + cbScanData: UINT, + pbScanData: *mut BYTE, + pcbScanDataActual: *mut UINT, + ) -> HRESULT, + fn CopyMinimalStream( + streamOffset: UINT, + cbStreamData: UINT, + pbStreamData: *mut BYTE, + pcbStreamDataActual: *mut UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2f0c601f, 0xd2c6, 0x468c, 0xab, 0xfa, 0x49, 0x49, 0x5d, 0x98, 0x3e, 0xd1)] +interface IWICJpegFrameEncode(IWICJpegFrameEncodeVtbl): IUnknown(IUnknownVtbl) { + fn GetAcHuffmanTable( + scanIndex: UINT, + tableIndex: UINT, + pAcHuffmanTable: *mut DXGI_JPEG_AC_HUFFMAN_TABLE, + ) -> HRESULT, + fn GetDcHuffmanTable( + scanIndex: UINT, + tableIndex: UINT, + pDcHuffmanTable: *mut DXGI_JPEG_DC_HUFFMAN_TABLE, + ) -> HRESULT, + fn GetQuantizationTable( + scanIndex: UINT, + tableIndex: UINT, + pQuantizationTable: *mut DXGI_JPEG_QUANTIZATION_TABLE, + ) -> HRESULT, + fn WriteScan( + cbScanData: UINT, + pbScanData: *const BYTE, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wincodecsdk.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincodecsdk.rs new file mode 100644 index 0000000..f71bf72 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincodecsdk.rs @@ -0,0 +1,564 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_uchar, c_ulong}; +use shared::guiddef::{GUID, REFGUID}; +use shared::minwindef::{BOOL, BYTE, DWORD, UINT, ULONG}; +use shared::wtypes::{BSTR, CLIPFORMAT}; +use um::oaidl::LPSAFEARRAY; +use um::objidl::{IPersistStream, IPersistStreamVtbl}; +use um::objidlbase::{IEnumUnknown, IStream}; +use um::ocidl::{IPropertyBag2, PROPBAG2}; +use um::propidl::PROPVARIANT; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::wincodec::{ + IWICComponentInfo, IWICComponentInfoVtbl, IWICEnumMetadataItem, IWICImagingFactory, + IWICImagingFactoryVtbl, IWICMetadataQueryReader, IWICMetadataQueryWriter, +}; +use um::winnt::{HRESULT, ULARGE_INTEGER, WCHAR}; +DEFINE_GUID!{GUID_MetadataFormatUnknown, + 0xa45e592f, 0x9078, 0x4a7c, 0xad, 0xb5, 0x4e, 0xdc, 0x4f, 0xd6, 0x1b, 0x1f} +DEFINE_GUID!{GUID_MetadataFormatIfd, + 0x537396c6, 0x2d8a, 0x4bb6, 0x9b, 0xf8, 0x2f, 0x0a, 0x8e, 0x2a, 0x3a, 0xdf} +DEFINE_GUID!{GUID_MetadataFormatSubIfd, + 0x58a2e128, 0x2db9, 0x4e57, 0xbb, 0x14, 0x51, 0x77, 0x89, 0x1e, 0xd3, 0x31} +DEFINE_GUID!{GUID_MetadataFormatExif, + 0x1c3c4f9d, 0xb84a, 0x467d, 0x94, 0x93, 0x36, 0xcf, 0xbd, 0x59, 0xea, 0x57} +DEFINE_GUID!{GUID_MetadataFormatGps, + 0x7134ab8a, 0x9351, 0x44ad, 0xaf, 0x62, 0x44, 0x8d, 0xb6, 0xb5, 0x02, 0xec} +DEFINE_GUID!{GUID_MetadataFormatInterop, + 0xed686f8e, 0x681f, 0x4c8b, 0xbd, 0x41, 0xa8, 0xad, 0xdb, 0xf6, 0xb3, 0xfc} +DEFINE_GUID!{GUID_MetadataFormatApp0, + 0x79007028, 0x268d, 0x45d6, 0xa3, 0xc2, 0x35, 0x4e, 0x6a, 0x50, 0x4b, 0xc9} +DEFINE_GUID!{GUID_MetadataFormatApp1, + 0x8fd3dfc3, 0xf951, 0x492b, 0x81, 0x7f, 0x69, 0xc2, 0xe6, 0xd9, 0xa5, 0xb0} +DEFINE_GUID!{GUID_MetadataFormatApp13, + 0x326556a2, 0xf502, 0x4354, 0x9c, 0xc0, 0x8e, 0x3f, 0x48, 0xea, 0xf6, 0xb5} +DEFINE_GUID!{GUID_MetadataFormatIPTC, + 0x4fab0914, 0xe129, 0x4087, 0xa1, 0xd1, 0xbc, 0x81, 0x2d, 0x45, 0xa7, 0xb5} +DEFINE_GUID!{GUID_MetadataFormatIRB, + 0x16100d66, 0x8570, 0x4bb9, 0xb9, 0x2d, 0xfd, 0xa4, 0xb2, 0x3e, 0xce, 0x67} +DEFINE_GUID!{GUID_MetadataFormat8BIMIPTC, + 0x0010568c, 0x0852, 0x4e6a, 0xb1, 0x91, 0x5c, 0x33, 0xac, 0x5b, 0x04, 0x30} +DEFINE_GUID!{GUID_MetadataFormat8BIMResolutionInfo, + 0x739f305d, 0x81db, 0x43cb, 0xac, 0x5e, 0x55, 0x01, 0x3e, 0xf9, 0xf0, 0x03} +DEFINE_GUID!{GUID_MetadataFormat8BIMIPTCDigest, + 0x1ca32285, 0x9ccd, 0x4786, 0x8b, 0xd8, 0x79, 0x53, 0x9d, 0xb6, 0xa0, 0x06} +DEFINE_GUID!{GUID_MetadataFormatXMP, + 0xbb5acc38, 0xf216, 0x4cec, 0xa6, 0xc5, 0x5f, 0x6e, 0x73, 0x97, 0x63, 0xa9} +DEFINE_GUID!{GUID_MetadataFormatThumbnail, + 0x243dcee9, 0x8703, 0x40ee, 0x8e, 0xf0, 0x22, 0xa6, 0x00, 0xb8, 0x05, 0x8c} +DEFINE_GUID!{GUID_MetadataFormatChunktEXt, + 0x568d8936, 0xc0a9, 0x4923, 0x90, 0x5d, 0xdf, 0x2b, 0x38, 0x23, 0x8f, 0xbc} +DEFINE_GUID!{GUID_MetadataFormatXMPStruct, + 0x22383cf1, 0xed17, 0x4e2e, 0xaf, 0x17, 0xd8, 0x5b, 0x8f, 0x6b, 0x30, 0xd0} +DEFINE_GUID!{GUID_MetadataFormatXMPBag, + 0x833cca5f, 0xdcb7, 0x4516, 0x80, 0x6f, 0x65, 0x96, 0xab, 0x26, 0xdc, 0xe4} +DEFINE_GUID!{GUID_MetadataFormatXMPSeq, + 0x63e8df02, 0xeb6c, 0x456c, 0xa2, 0x24, 0xb2, 0x5e, 0x79, 0x4f, 0xd6, 0x48} +DEFINE_GUID!{GUID_MetadataFormatXMPAlt, + 0x7b08a675, 0x91aa, 0x481b, 0xa7, 0x98, 0x4d, 0xa9, 0x49, 0x08, 0x61, 0x3b} +DEFINE_GUID!{GUID_MetadataFormatLSD, + 0xe256031e, 0x6299, 0x4929, 0xb9, 0x8d, 0x5a, 0xc8, 0x84, 0xaf, 0xba, 0x92} +DEFINE_GUID!{GUID_MetadataFormatIMD, + 0xbd2bb086, 0x4d52, 0x48dd, 0x96, 0x77, 0xdb, 0x48, 0x3e, 0x85, 0xae, 0x8f} +DEFINE_GUID!{GUID_MetadataFormatGCE, + 0x2a25cad8, 0xdeeb, 0x4c69, 0xa7, 0x88, 0x0e, 0xc2, 0x26, 0x6d, 0xca, 0xfd} +DEFINE_GUID!{GUID_MetadataFormatAPE, + 0x2e043dc2, 0xc967, 0x4e05, 0x87, 0x5e, 0x61, 0x8b, 0xf6, 0x7e, 0x85, 0xc3} +DEFINE_GUID!{GUID_MetadataFormatJpegChrominance, + 0xf73d0dcf, 0xcec6, 0x4f85, 0x9b, 0x0e, 0x1c, 0x39, 0x56, 0xb1, 0xbe, 0xf7} +DEFINE_GUID!{GUID_MetadataFormatJpegLuminance, + 0x86908007, 0xedfc, 0x4860, 0x8d, 0x4b, 0x4e, 0xe6, 0xe8, 0x3e, 0x60, 0x58} +DEFINE_GUID!{GUID_MetadataFormatJpegComment, + 0x220e5f33, 0xafd3, 0x474e, 0x9d, 0x31, 0x7d, 0x4f, 0xe7, 0x30, 0xf5, 0x57} +DEFINE_GUID!{GUID_MetadataFormatGifComment, + 0xc4b6e0e0, 0xcfb4, 0x4ad3, 0xab, 0x33, 0x9a, 0xad, 0x23, 0x55, 0xa3, 0x4a} +DEFINE_GUID!{GUID_MetadataFormatChunkgAMA, + 0xf00935a5, 0x1d5d, 0x4cd1, 0x81, 0xb2, 0x93, 0x24, 0xd7, 0xec, 0xa7, 0x81} +DEFINE_GUID!{GUID_MetadataFormatChunkbKGD, + 0xe14d3571, 0x6b47, 0x4dea, 0xb6, 0x0a, 0x87, 0xce, 0x0a, 0x78, 0xdf, 0xb7} +DEFINE_GUID!{GUID_MetadataFormatChunkiTXt, + 0xc2bec729, 0x0b68, 0x4b77, 0xaa, 0x0e, 0x62, 0x95, 0xa6, 0xac, 0x18, 0x14} +DEFINE_GUID!{GUID_MetadataFormatChunkcHRM, + 0x9db3655b, 0x2842, 0x44b3, 0x80, 0x67, 0x12, 0xe9, 0xb3, 0x75, 0x55, 0x6a} +DEFINE_GUID!{GUID_MetadataFormatChunkhIST, + 0xc59a82da, 0xdb74, 0x48a4, 0xbd, 0x6a, 0xb6, 0x9c, 0x49, 0x31, 0xef, 0x95} +DEFINE_GUID!{GUID_MetadataFormatChunkiCCP, + 0xeb4349ab, 0xb685, 0x450f, 0x91, 0xb5, 0xe8, 0x02, 0xe8, 0x92, 0x53, 0x6c} +DEFINE_GUID!{GUID_MetadataFormatChunksRGB, + 0xc115fd36, 0xcc6f, 0x4e3f, 0x83, 0x63, 0x52, 0x4b, 0x87, 0xc6, 0xb0, 0xd9} +DEFINE_GUID!{GUID_MetadataFormatChunktIME, + 0x6b00ae2d, 0xe24b, 0x460a, 0x98, 0xb6, 0x87, 0x8b, 0xd0, 0x30, 0x72, 0xfd} +DEFINE_GUID!{GUID_MetadataFormatDds, + 0x4a064603, 0x8c33, 0x4e60, 0x9c, 0x29, 0x13, 0x62, 0x31, 0x70, 0x2d, 0x08} +DEFINE_GUID!{CLSID_WICUnknownMetadataReader, + 0x699745c2, 0x5066, 0x4b82, 0xa8, 0xe3, 0xd4, 0x04, 0x78, 0xdb, 0xec, 0x8c} +DEFINE_GUID!{CLSID_WICUnknownMetadataWriter, + 0xa09cca86, 0x27ba, 0x4f39, 0x90, 0x53, 0x12, 0x1f, 0xa4, 0xdc, 0x08, 0xfc} +DEFINE_GUID!{CLSID_WICApp0MetadataWriter, + 0xf3c633a2, 0x46c8, 0x498e, 0x8f, 0xbb, 0xcc, 0x6f, 0x72, 0x1b, 0xbc, 0xde} +DEFINE_GUID!{CLSID_WICApp0MetadataReader, + 0x43324b33, 0xa78f, 0x480f, 0x91, 0x11, 0x96, 0x38, 0xaa, 0xcc, 0xc8, 0x32} +DEFINE_GUID!{CLSID_WICApp1MetadataWriter, + 0xee366069, 0x1832, 0x420f, 0xb3, 0x81, 0x04, 0x79, 0xad, 0x06, 0x6f, 0x19} +DEFINE_GUID!{CLSID_WICApp1MetadataReader, + 0xdde33513, 0x774e, 0x4bcd, 0xae, 0x79, 0x02, 0xf4, 0xad, 0xfe, 0x62, 0xfc} +DEFINE_GUID!{CLSID_WICApp13MetadataWriter, + 0x7b19a919, 0xa9d6, 0x49e5, 0xbd, 0x45, 0x02, 0xc3, 0x4e, 0x4e, 0x4c, 0xd5} +DEFINE_GUID!{CLSID_WICApp13MetadataReader, + 0xaa7e3c50, 0x864c, 0x4604, 0xbc, 0x04, 0x8b, 0x0b, 0x76, 0xe6, 0x37, 0xf6} +DEFINE_GUID!{CLSID_WICIfdMetadataReader, + 0x8f914656, 0x9d0a, 0x4eb2, 0x90, 0x19, 0x0b, 0xf9, 0x6d, 0x8a, 0x9e, 0xe6} +DEFINE_GUID!{CLSID_WICIfdMetadataWriter, + 0xb1ebfc28, 0xc9bd, 0x47a2, 0x8d, 0x33, 0xb9, 0x48, 0x76, 0x97, 0x77, 0xa7} +DEFINE_GUID!{CLSID_WICSubIfdMetadataReader, + 0x50d42f09, 0xecd1, 0x4b41, 0xb6, 0x5d, 0xda, 0x1f, 0xda, 0xa7, 0x56, 0x63} +DEFINE_GUID!{CLSID_WICSubIfdMetadataWriter, + 0x8ade5386, 0x8e9b, 0x4f4c, 0xac, 0xf2, 0xf0, 0x00, 0x87, 0x06, 0xb2, 0x38} +DEFINE_GUID!{CLSID_WICExifMetadataReader, + 0xd9403860, 0x297f, 0x4a49, 0xbf, 0x9b, 0x77, 0x89, 0x81, 0x50, 0xa4, 0x42} +DEFINE_GUID!{CLSID_WICExifMetadataWriter, + 0xc9a14cda, 0xc339, 0x460b, 0x90, 0x78, 0xd4, 0xde, 0xbc, 0xfa, 0xbe, 0x91} +DEFINE_GUID!{CLSID_WICGpsMetadataReader, + 0x3697790b, 0x223b, 0x484e, 0x99, 0x25, 0xc4, 0x86, 0x92, 0x18, 0xf1, 0x7a} +DEFINE_GUID!{CLSID_WICGpsMetadataWriter, + 0xcb8c13e4, 0x62b5, 0x4c96, 0xa4, 0x8b, 0x6b, 0xa6, 0xac, 0xe3, 0x9c, 0x76} +DEFINE_GUID!{CLSID_WICInteropMetadataReader, + 0xb5c8b898, 0x0074, 0x459f, 0xb7, 0x00, 0x86, 0x0d, 0x46, 0x51, 0xea, 0x14} +DEFINE_GUID!{CLSID_WICInteropMetadataWriter, + 0x122ec645, 0xcd7e, 0x44d8, 0xb1, 0x86, 0x2c, 0x8c, 0x20, 0xc3, 0xb5, 0x0f} +DEFINE_GUID!{CLSID_WICThumbnailMetadataReader, + 0xfb012959, 0xf4f6, 0x44d7, 0x9d, 0x09, 0xda, 0xa0, 0x87, 0xa9, 0xdb, 0x57} +DEFINE_GUID!{CLSID_WICThumbnailMetadataWriter, + 0xd049b20c, 0x5dd0, 0x44fe, 0xb0, 0xb3, 0x8f, 0x92, 0xc8, 0xe6, 0xd0, 0x80} +DEFINE_GUID!{CLSID_WICIPTCMetadataReader, + 0x03012959, 0xf4f6, 0x44d7, 0x9d, 0x09, 0xda, 0xa0, 0x87, 0xa9, 0xdb, 0x57} +DEFINE_GUID!{CLSID_WICIPTCMetadataWriter, + 0x1249b20c, 0x5dd0, 0x44fe, 0xb0, 0xb3, 0x8f, 0x92, 0xc8, 0xe6, 0xd0, 0x80} +DEFINE_GUID!{CLSID_WICIRBMetadataReader, + 0xd4dcd3d7, 0xb4c2, 0x47d9, 0xa6, 0xbf, 0xb8, 0x9b, 0xa3, 0x96, 0xa4, 0xa3} +DEFINE_GUID!{CLSID_WICIRBMetadataWriter, + 0x5c5c1935, 0x0235, 0x4434, 0x80, 0xbc, 0x25, 0x1b, 0xc1, 0xec, 0x39, 0xc6} +DEFINE_GUID!{CLSID_WIC8BIMIPTCMetadataReader, + 0x0010668c, 0x0801, 0x4da6, 0xa4, 0xa4, 0x82, 0x65, 0x22, 0xb6, 0xd2, 0x8f} +DEFINE_GUID!{CLSID_WIC8BIMIPTCMetadataWriter, + 0x00108226, 0xee41, 0x44a2, 0x9e, 0x9c, 0x4b, 0xe4, 0xd5, 0xb1, 0xd2, 0xcd} +DEFINE_GUID!{CLSID_WIC8BIMResolutionInfoMetadataReader, + 0x5805137a, 0xe348, 0x4f7c, 0xb3, 0xcc, 0x6d, 0xb9, 0x96, 0x5a, 0x05, 0x99} +DEFINE_GUID!{CLSID_WIC8BIMResolutionInfoMetadataWriter, + 0x4ff2fe0e, 0xe74a, 0x4b71, 0x98, 0xc4, 0xab, 0x7d, 0xc1, 0x67, 0x07, 0xba} +DEFINE_GUID!{CLSID_WIC8BIMIPTCDigestMetadataReader, + 0x02805f1e, 0xd5aa, 0x415b, 0x82, 0xc5, 0x61, 0xc0, 0x33, 0xa9, 0x88, 0xa6} +DEFINE_GUID!{CLSID_WIC8BIMIPTCDigestMetadataWriter, + 0x2db5e62b, 0x0d67, 0x495f, 0x8f, 0x9d, 0xc2, 0xf0, 0x18, 0x86, 0x47, 0xac} +DEFINE_GUID!{CLSID_WICPngTextMetadataReader, + 0x4b59afcc, 0xb8c3, 0x408a, 0xb6, 0x70, 0x89, 0xe5, 0xfa, 0xb6, 0xfd, 0xa7} +DEFINE_GUID!{CLSID_WICPngTextMetadataWriter, + 0xb5ebafb9, 0x253e, 0x4a72, 0xa7, 0x44, 0x07, 0x62, 0xd2, 0x68, 0x56, 0x83} +DEFINE_GUID!{CLSID_WICXMPMetadataReader, + 0x72b624df, 0xae11, 0x4948, 0xa6, 0x5c, 0x35, 0x1e, 0xb0, 0x82, 0x94, 0x19} +DEFINE_GUID!{CLSID_WICXMPMetadataWriter, + 0x1765e14e, 0x1bd4, 0x462e, 0xb6, 0xb1, 0x59, 0x0b, 0xf1, 0x26, 0x2a, 0xc6} +DEFINE_GUID!{CLSID_WICXMPStructMetadataReader, + 0x01b90d9a, 0x8209, 0x47f7, 0x9c, 0x52, 0xe1, 0x24, 0x4b, 0xf5, 0x0c, 0xed} +DEFINE_GUID!{CLSID_WICXMPStructMetadataWriter, + 0x22c21f93, 0x7ddb, 0x411c, 0x9b, 0x17, 0xc5, 0xb7, 0xbd, 0x06, 0x4a, 0xbc} +DEFINE_GUID!{CLSID_WICXMPBagMetadataReader, + 0xe7e79a30, 0x4f2c, 0x4fab, 0x8d, 0x00, 0x39, 0x4f, 0x2d, 0x6b, 0xbe, 0xbe} +DEFINE_GUID!{CLSID_WICXMPBagMetadataWriter, + 0xed822c8c, 0xd6be, 0x4301, 0xa6, 0x31, 0x0e, 0x14, 0x16, 0xba, 0xd2, 0x8f} +DEFINE_GUID!{CLSID_WICXMPSeqMetadataReader, + 0x7f12e753, 0xfc71, 0x43d7, 0xa5, 0x1d, 0x92, 0xf3, 0x59, 0x77, 0xab, 0xb5} +DEFINE_GUID!{CLSID_WICXMPSeqMetadataWriter, + 0x6d68d1de, 0xd432, 0x4b0f, 0x92, 0x3a, 0x09, 0x11, 0x83, 0xa9, 0xbd, 0xa7} +DEFINE_GUID!{CLSID_WICXMPAltMetadataReader, + 0xaa94dcc2, 0xb8b0, 0x4898, 0xb8, 0x35, 0x00, 0x0a, 0xab, 0xd7, 0x43, 0x93} +DEFINE_GUID!{CLSID_WICXMPAltMetadataWriter, + 0x076c2a6c, 0xf78f, 0x4c46, 0xa7, 0x23, 0x35, 0x83, 0xe7, 0x08, 0x76, 0xea} +DEFINE_GUID!{CLSID_WICLSDMetadataReader, + 0x41070793, 0x59e4, 0x479a, 0xa1, 0xf7, 0x95, 0x4a, 0xdc, 0x2e, 0xf5, 0xfc} +DEFINE_GUID!{CLSID_WICLSDMetadataWriter, + 0x73c037e7, 0xe5d9, 0x4954, 0x87, 0x6a, 0x6d, 0xa8, 0x1d, 0x6e, 0x57, 0x68} +DEFINE_GUID!{CLSID_WICGCEMetadataReader, + 0xb92e345d, 0xf52d, 0x41f3, 0xb5, 0x62, 0x08, 0x1b, 0xc7, 0x72, 0xe3, 0xb9} +DEFINE_GUID!{CLSID_WICGCEMetadataWriter, + 0xaf95dc76, 0x16b2, 0x47f4, 0xb3, 0xea, 0x3c, 0x31, 0x79, 0x66, 0x93, 0xe7} +DEFINE_GUID!{CLSID_WICIMDMetadataReader, + 0x7447a267, 0x0015, 0x42c8, 0xa8, 0xf1, 0xfb, 0x3b, 0x94, 0xc6, 0x83, 0x61} +DEFINE_GUID!{CLSID_WICIMDMetadataWriter, + 0x8c89071f, 0x452e, 0x4e95, 0x96, 0x82, 0x9d, 0x10, 0x24, 0x62, 0x71, 0x72} +DEFINE_GUID!{CLSID_WICAPEMetadataReader, + 0x1767b93a, 0xb021, 0x44ea, 0x92, 0x0f, 0x86, 0x3c, 0x11, 0xf4, 0xf7, 0x68} +DEFINE_GUID!{CLSID_WICAPEMetadataWriter, + 0xbd6edfca, 0x2890, 0x482f, 0xb2, 0x33, 0x8d, 0x73, 0x39, 0xa1, 0xcf, 0x8d} +DEFINE_GUID!{CLSID_WICJpegChrominanceMetadataReader, + 0x50b1904b, 0xf28f, 0x4574, 0x93, 0xf4, 0x0b, 0xad, 0xe8, 0x2c, 0x69, 0xe9} +DEFINE_GUID!{CLSID_WICJpegChrominanceMetadataWriter, + 0x3ff566f0, 0x6e6b, 0x49d4, 0x96, 0xe6, 0xb7, 0x88, 0x86, 0x69, 0x2c, 0x62} +DEFINE_GUID!{CLSID_WICJpegLuminanceMetadataReader, + 0x356f2f88, 0x05a6, 0x4728, 0xb9, 0xa4, 0x1b, 0xfb, 0xce, 0x04, 0xd8, 0x38} +DEFINE_GUID!{CLSID_WICJpegLuminanceMetadataWriter, + 0x1d583abc, 0x8a0e, 0x4657, 0x99, 0x82, 0xa3, 0x80, 0xca, 0x58, 0xfb, 0x4b} +DEFINE_GUID!{CLSID_WICJpegCommentMetadataReader, + 0x9f66347c, 0x60c4, 0x4c4d, 0xab, 0x58, 0xd2, 0x35, 0x86, 0x85, 0xf6, 0x07} +DEFINE_GUID!{CLSID_WICJpegCommentMetadataWriter, + 0xe573236f, 0x55b1, 0x4eda, 0x81, 0xea, 0x9f, 0x65, 0xdb, 0x02, 0x90, 0xd3} +DEFINE_GUID!{CLSID_WICGifCommentMetadataReader, + 0x32557d3b, 0x69dc, 0x4f95, 0x83, 0x6e, 0xf5, 0x97, 0x2b, 0x2f, 0x61, 0x59} +DEFINE_GUID!{CLSID_WICGifCommentMetadataWriter, + 0xa02797fc, 0xc4ae, 0x418c, 0xaf, 0x95, 0xe6, 0x37, 0xc7, 0xea, 0xd2, 0xa1} +DEFINE_GUID!{CLSID_WICPngGamaMetadataReader, + 0x3692ca39, 0xe082, 0x4350, 0x9e, 0x1f, 0x37, 0x04, 0xcb, 0x08, 0x3c, 0xd5} +DEFINE_GUID!{CLSID_WICPngGamaMetadataWriter, + 0xff036d13, 0x5d4b, 0x46dd, 0xb1, 0x0f, 0x10, 0x66, 0x93, 0xd9, 0xfe, 0x4f} +DEFINE_GUID!{CLSID_WICPngBkgdMetadataReader, + 0x0ce7a4a6, 0x03e8, 0x4a60, 0x9d, 0x15, 0x28, 0x2e, 0xf3, 0x2e, 0xe7, 0xda} +DEFINE_GUID!{CLSID_WICPngBkgdMetadataWriter, + 0x68e3f2fd, 0x31ae, 0x4441, 0xbb, 0x6a, 0xfd, 0x70, 0x47, 0x52, 0x5f, 0x90} +DEFINE_GUID!{CLSID_WICPngItxtMetadataReader, + 0xaabfb2fa, 0x3e1e, 0x4a8f, 0x89, 0x77, 0x55, 0x56, 0xfb, 0x94, 0xea, 0x23} +DEFINE_GUID!{CLSID_WICPngItxtMetadataWriter, + 0x31879719, 0xe751, 0x4df8, 0x98, 0x1d, 0x68, 0xdf, 0xf6, 0x77, 0x04, 0xed} +DEFINE_GUID!{CLSID_WICPngChrmMetadataReader, + 0xf90b5f36, 0x367b, 0x402a, 0x9d, 0xd1, 0xbc, 0x0f, 0xd5, 0x9d, 0x8f, 0x62} +DEFINE_GUID!{CLSID_WICPngChrmMetadataWriter, + 0xe23ce3eb, 0x5608, 0x4e83, 0xbc, 0xef, 0x27, 0xb1, 0x98, 0x7e, 0x51, 0xd7} +DEFINE_GUID!{CLSID_WICPngHistMetadataReader, + 0x877a0bb7, 0xa313, 0x4491, 0x87, 0xb5, 0x2e, 0x6d, 0x05, 0x94, 0xf5, 0x20} +DEFINE_GUID!{CLSID_WICPngHistMetadataWriter, + 0x8a03e749, 0x672e, 0x446e, 0xbf, 0x1f, 0x2c, 0x11, 0xd2, 0x33, 0xb6, 0xff} +DEFINE_GUID!{CLSID_WICPngIccpMetadataReader, + 0xf5d3e63b, 0xcb0f, 0x4628, 0xa4, 0x78, 0x6d, 0x82, 0x44, 0xbe, 0x36, 0xb1} +DEFINE_GUID!{CLSID_WICPngIccpMetadataWriter, + 0x16671e5f, 0x0ce6, 0x4cc4, 0x97, 0x68, 0xe8, 0x9f, 0xe5, 0x01, 0x8a, 0xde} +DEFINE_GUID!{CLSID_WICPngSrgbMetadataReader, + 0xfb40360c, 0x547e, 0x4956, 0xa3, 0xb9, 0xd4, 0x41, 0x88, 0x59, 0xba, 0x66} +DEFINE_GUID!{CLSID_WICPngSrgbMetadataWriter, + 0xa6ee35c6, 0x87ec, 0x47df, 0x9f, 0x22, 0x1d, 0x5a, 0xad, 0x84, 0x0c, 0x82} +DEFINE_GUID!{CLSID_WICPngTimeMetadataReader, + 0xd94edf02, 0xefe5, 0x4f0d, 0x85, 0xc8, 0xf5, 0xa6, 0x8b, 0x30, 0x00, 0xb1} +DEFINE_GUID!{CLSID_WICPngTimeMetadataWriter, + 0x1ab78400, 0xb5a3, 0x4d91, 0x8a, 0xce, 0x33, 0xfc, 0xd1, 0x49, 0x9b, 0xe6} +DEFINE_GUID!{CLSID_WICDdsMetadataReader, + 0x276c88ca, 0x7533, 0x4a86, 0xb6, 0x76, 0x66, 0xb3, 0x60, 0x80, 0xd4, 0x84} +DEFINE_GUID!{CLSID_WICDdsMetadataWriter, + 0xfd688bbd, 0x31ed, 0x4db7, 0xa7, 0x23, 0x93, 0x49, 0x27, 0xd3, 0x83, 0x67} +ENUM!{enum WICMetadataCreationOptions { + WICMetadataCreationDefault = 0, + WICMetadataCreationAllowUnknown = WICMetadataCreationDefault, + WICMetadataCreationFailUnknown = 0x10000, + WICMetadataCreationMask = 0xffff0000, +}} +ENUM!{enum WICPersistOptions { + WICPersistOptionDefault = 0, + WICPersistOptionLittleEndian = 0, + WICPersistOptionBigEndian = 0x1, + WICPersistOptionStrictFormat = 0x2, + WICPersistOptionNoCacheStream = 0x4, + WICPersistOptionPreferUTF8 = 0x8, + WICPersistOptionMask = 0xffff, +}} +RIDL!{#[uuid(0xfeaa2a8d, 0xb3f3, 0x43e4, 0xb2, 0x5c, 0xd1, 0xde, 0x99, 0x0a, 0x1a, 0xe1)] +interface IWICMetadataBlockReader(IWICMetadataBlockReaderVtbl): IUnknown(IUnknownVtbl) { + fn GetContainerFormat( + pguidContainerFormat: *mut GUID, + ) -> HRESULT, + fn GetCount( + pcCount: *mut UINT, + ) -> HRESULT, + fn GetReaderByIndex( + ppIMetadataReader: *mut *mut IWICMetadataReader, + ) -> HRESULT, + fn GetEnumerator( + ppIEnumMetadata: *mut IEnumUnknown, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x08fb9676, 0xb444, 0x41e8, 0x8d, 0xbe, 0x6a, 0x53, 0xa5, 0x42, 0xbf, 0xf1)] +interface IWICMetadataBlockWriter(IWICMetadataBlockWriterVtbl): + IWICMetadataBlockReader(IWICMetadataBlockReaderVtbl) { + fn InitializeFromBlockReader( + pIMDBlockReader: *mut IWICMetadataBlockReader, + ) -> HRESULT, + fn GetWriterByIndex( + ppIMetadataWriter: *mut *mut IWICMetadataWriter, + ) -> HRESULT, + fn AddWriter( + pIMetadataWriter: *mut IWICMetadataWriter, + ) -> HRESULT, + fn SetWriterByIndex( + pIMetadataWriter: *mut IWICMetadataWriter, + ) -> HRESULT, + fn RemoveWriterByIndex( + nIndex: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9204fe99, 0xd8fc, 0x4fd5, 0xa0, 0x01, 0x95, 0x36, 0xb0, 0x67, 0xa8, 0x99)] +interface IWICMetadataReader(IWICMetadataReaderVtbl): IUnknown(IUnknownVtbl) { + fn GetMetadataFormat( + pguidMetadataFormat: *mut GUID, + ) -> HRESULT, + fn GetMetadataHandlerInfo( + ppIHandler: *mut *mut IWICMetadataHandlerInfo, + ) -> HRESULT, + fn GetCount( + pcCount: *mut UINT, + ) -> HRESULT, + fn GetValueByIndex( + nIndex: UINT, + pvarSchema: *mut PROPVARIANT, + pvarId: *mut PROPVARIANT, + pvarValue: *mut PROPVARIANT, + ) -> HRESULT, + fn GetValue( + pvarSchema: *const PROPVARIANT, + pvarId: *const PROPVARIANT, + pvarValue: *mut PROPVARIANT, + ) -> HRESULT, + fn GetEnumerator( + ppIEnumMetadata: *mut *mut IWICEnumMetadataItem, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xf7836e16, 0x3be0, 0x470b, 0x86, 0xbb, 0x16, 0x0d, 0x0a, 0xec, 0xd7, 0xde)] +interface IWICMetadataWriter(IWICMetadataWriterVtbl): IWICMetadataReader(IWICMetadataReaderVtbl) { + fn SetValue( + pvarSchema: *const PROPVARIANT, + pvarId: *const PROPVARIANT, + pvarValue: *const PROPVARIANT, + ) -> HRESULT, + fn SetValueByIndex( + nIndex: UINT, + pvarSchema: *const PROPVARIANT, + pvarId: *const PROPVARIANT, + pvarValue: *const PROPVARIANT, + ) -> HRESULT, + fn RemoveValue( + pvarSchema: *const PROPVARIANT, + pvarId: *const PROPVARIANT, + ) -> HRESULT, + fn RemoveValueByIndex( + nIndex: UINT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x449494bc, 0xb468, 0x4927, 0x96, 0xd7, 0xba, 0x90, 0xd3, 0x1a, 0xb5, 0x05)] +interface IWICStreamProvider(IWICStreamProviderVtbl): IUnknown(IUnknownVtbl) { + fn GetStream( + ppIStream: *mut *mut IStream, + ) -> HRESULT, + fn GetPersistOptions( + pdwPersistOptions: *mut DWORD, + ) -> HRESULT, + fn GetPreferredVendorGUID( + pguidPreferredVendor: *mut GUID, + ) -> HRESULT, + fn RefreshStream() -> HRESULT, +}} +RIDL!{#[uuid(0x00675040, 0x6908, 0x45f8, 0x86, 0xa3, 0x49, 0xc7, 0xdf, 0xd6, 0xd9, 0xad)] +interface IWICPersistStream(IWICPersistStreamVtbl): IPersistStream(IPersistStreamVtbl) { + fn LoadEx( + pIStream: *mut IStream, + pguidPreferredVendor: *const GUID, + dwPersistOptions: DWORD, + ) -> HRESULT, + fn SaveEx( + pIStream: *mut IStream, + dwPersistOptions: DWORD, + fClearDirty: BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xaba958bf, 0xc672, 0x44d1, 0x8d, 0x61, 0xce, 0x6d, 0xf2, 0xe6, 0x82, 0xc2)] +interface IWICMetadataHandlerInfo(IWICMetadataHandlerInfoVtbl): + IWICComponentInfo(IWICComponentInfoVtbl) { + fn GetMetadataFormat( + pguidMetadataFormat: *mut GUID, + ) -> HRESULT, + fn GetContainerFormats( + cContainerFormats: UINT, + pguidContainerFormats: *mut GUID, + pcchActual: *mut UINT, + ) -> HRESULT, + fn GetDeviceManufacturer( + cchDeviceManufacturer: UINT, + wzDeviceManufacturer: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, + fn GetDeviceModels( + cchDeviceModels: UINT, + wzDeviceModels: *mut WCHAR, + pcchActual: *mut UINT, + ) -> HRESULT, + fn DoesRequireFullStream( + pfRequiresFullStream: *mut BOOL, + ) -> HRESULT, + fn DoesSupportPadding( + pfSupportsPadding: *mut BOOL, + ) -> HRESULT, + fn DoesRequireFixedSize( + pfFixedSize: *mut BOOL, + ) -> HRESULT, +}} +STRUCT!{struct WICMetadataPattern { + Position: ULARGE_INTEGER, + Length: ULONG, + Pattern: *mut BYTE, + Mask: *mut BYTE, + DataOffset: ULARGE_INTEGER, +}} +RIDL!{#[uuid(0xeebf1f5b, 0x07c1, 0x4447, 0xa3, 0xab, 0x22, 0xac, 0xaf, 0x78, 0xa8, 0x04)] +interface IWICMetadataReaderInfo(IWICMetadataReaderInfoVtbl): + IWICMetadataHandlerInfo(IWICMetadataHandlerInfoVtbl) { + fn GetPatterns( + guidContainerFormat: REFGUID, + cbSize: UINT, + pPattern: *mut WICMetadataPattern, + pcCount: *mut UINT, + pcbActual: *mut UINT, + ) -> HRESULT, + fn MatchesPattern( + guidContainerFormat: REFGUID, + pIStream: *mut IStream, + pfMatches: *mut BOOL, + ) -> HRESULT, + fn CreateInstance( + ppIReader: *mut *mut IWICMetadataReader, + ) -> HRESULT, +}} +STRUCT!{struct WICMetadataHeader { + Position: ULARGE_INTEGER, + Length: ULONG, + Header: *mut BYTE, + DataOffset: ULARGE_INTEGER, +}} +RIDL!{#[uuid(0xb22e3fba, 0x3925, 0x4323, 0xb5, 0xc1, 0x9e, 0xbf, 0xc4, 0x30, 0xf2, 0x36)] +interface IWICMetadataWriterInfo(IWICMetadataWriterInfoVtbl): + IWICMetadataHandlerInfo(IWICMetadataHandlerInfoVtbl) { + fn GetHeader( + guidContainerFormat: REFGUID, + cbSize: UINT, + pHeader: *mut WICMetadataHeader, + pcbActual: *mut UINT, + ) -> HRESULT, + fn CreateInstance( + ppIWriter: *mut *mut IWICMetadataWriter, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x412d0c3a, 0x9650, 0x44fa, 0xaf, 0x5b, 0xdd, 0x2a, 0x06, 0xc8, 0xe8, 0xfb)] +interface IWICComponentFactory(IWICComponentFactoryVtbl): + IWICImagingFactory(IWICImagingFactoryVtbl) { + fn CreateMetadataReader( + guidMetadataFormat: REFGUID, + pguidVendor: *const GUID, + dwOptions: DWORD, + pIStream: *mut IStream, + ppIReader: *mut *mut IWICMetadataReader, + ) -> HRESULT, + fn CreateMetadataReaderFromContainer( + guidContainerFormat: REFGUID, + pguidVendor: *const GUID, + dwOptions: DWORD, + pIStream: *mut IStream, + ppIReader: *mut *mut IWICMetadataReader, + ) -> HRESULT, + fn CreateMetadataWriter( + guidMetadataFormat: REFGUID, + pguidVendor: *const GUID, + dwMetadataOptions: DWORD, + ppIWriter: *mut *mut IWICMetadataWriter, + ) -> HRESULT, + fn CreateMetadataWriterFromReader( + pIReader: *mut IWICMetadataReader, + pguidVendor: *const GUID, + ppIWriter: *mut *mut IWICMetadataWriter, + ) -> HRESULT, + fn CreateQueryReaderFromBlockReader( + pIBlockReader: *mut IWICMetadataBlockReader, + ppIQueryReader: *mut *mut IWICMetadataQueryReader, + ) -> HRESULT, + fn CreateQueryWriterFromBlockWriter( + pIBlockWriter: *mut IWICMetadataBlockWriter, + ppIQueryWriter: *mut *mut IWICMetadataQueryWriter, + ) -> HRESULT, + fn CreateEncoderPropertyBag( + ppropOptions: *mut PROPBAG2, + cCount: UINT, + ppIPropertyBag: *mut *mut IPropertyBag2, + ) -> HRESULT, +}} +extern "system" { + pub fn WICMatchMetadataContent( + guidContainerFormat: REFGUID, + pguidVendor: *const GUID, + pIStream: *mut IStream, + pguidMetadataFormat: *mut GUID, + ) -> HRESULT; + pub fn WICSerializeMetadataContent( + guidContainerFormat: REFGUID, + pIWriter: *mut IWICMetadataWriter, + dwPersistOptions: DWORD, + pIStream: *mut IStream, + ) -> HRESULT; + pub fn WICGetMetadataContentSize( + guidContainerFormat: REFGUID, + pIWriter: *mut IWICMetadataWriter, + pcbSize: *mut ULARGE_INTEGER, + ) -> HRESULT; + pub fn BSTR_UserSize( + pFlags: *mut c_ulong, + Offset: c_ulong, + pBstr: *mut BSTR, + ) -> c_ulong; + pub fn BSTR_UserMarshal( + pFlags: *mut c_ulong, + pBuffer: *mut c_uchar, + pBstr: *mut BSTR, + ) -> *mut c_uchar; + pub fn BSTR_UserUnmarshal( + pFlags: *mut c_ulong, + pBuffer: *mut c_uchar, + pBstr: *mut BSTR, + ) -> *mut c_uchar; + pub fn BSTR_UserFree( + pFlags: *mut c_ulong, + pBstr: *mut BSTR, + ); + pub fn CLIPFORMAT_UserSize( + pFlags: *mut c_ulong, + Offset: c_ulong, + pCF: *mut CLIPFORMAT, + ) -> c_ulong; + pub fn CLIPFORMAT_UserMarshal( + pFlags: *mut c_ulong, + pBuffer: *mut c_uchar, + pCF: *mut CLIPFORMAT, + ) -> *mut c_uchar; + pub fn CLIPFORMAT_UserUnmarshal( + pFlags: *mut c_ulong, + pBuffer: *mut c_uchar, + pCF: *mut CLIPFORMAT, + ) -> *mut c_uchar; + pub fn CLIPFORMAT_UserFree( + pFlags: *mut c_ulong, + pCF: *mut CLIPFORMAT, + ); + pub fn LPSAFEARRAY_UserSize( + pFlags: *mut c_ulong, + Offset: c_ulong, + phBmp: *mut LPSAFEARRAY, + ) -> c_ulong; + pub fn LPSAFEARRAY_UserMarshal( + pFlags: *mut c_ulong, + pBuffer: *mut c_uchar, + pBstr: *mut LPSAFEARRAY, + ) -> *mut c_uchar; + pub fn LPSAFEARRAY_UserUnmarshal( + pFlags: *mut c_ulong, + pBuffer: *mut c_uchar, + pBstr: *mut LPSAFEARRAY, + ) -> *mut c_uchar; + pub fn LPSAFEARRAY_UserFree( + pFlags: *mut c_ulong, + pBstr: *mut LPSAFEARRAY, + ); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wincon.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincon.rs new file mode 100644 index 0000000..9eb3a22 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincon.rs @@ -0,0 +1,459 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module contains the public data structures, data types, and procedures exported by the NT +//! console subsystem. +use ctypes::c_void; +use shared::minwindef::{BOOL, DWORD, LPDWORD, LPVOID, LPWORD, UINT, ULONG, WORD}; +use shared::windef::{COLORREF, HWND}; +use um::minwinbase::SECURITY_ATTRIBUTES; +use um::wingdi::LF_FACESIZE; +use um::winnt::{CHAR, HANDLE, LPCSTR, LPCWSTR, LPSTR, LPWSTR, WCHAR}; +// Many definitions in wincontypes used to be defined in this file, so reexport them to avoid +// breakage. For clarity they are imported in the order they are defined in that file rather +// than winapi's usual alphabetical ordering, with some newlines and indentation to match their +// grouping in the file. +pub use um::wincontypes::{ + COORD, PCOORD, + SMALL_RECT, PSMALL_RECT, + KEY_EVENT_RECORD_uChar, KEY_EVENT_RECORD, PKEY_EVENT_RECORD, + RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED, RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED, SHIFT_PRESSED, + NUMLOCK_ON, SCROLLLOCK_ON, CAPSLOCK_ON, ENHANCED_KEY, NLS_DBCSCHAR, NLS_ALPHANUMERIC, + NLS_KATAKANA, NLS_HIRAGANA, NLS_ROMAN, NLS_IME_CONVERSION, NLS_IME_DISABLE, + MOUSE_EVENT_RECORD, PMOUSE_EVENT_RECORD, + FROM_LEFT_1ST_BUTTON_PRESSED, RIGHTMOST_BUTTON_PRESSED, FROM_LEFT_2ND_BUTTON_PRESSED, + FROM_LEFT_3RD_BUTTON_PRESSED, FROM_LEFT_4TH_BUTTON_PRESSED, MOUSE_MOVED, DOUBLE_CLICK, + MOUSE_WHEELED, MOUSE_HWHEELED, + WINDOW_BUFFER_SIZE_RECORD, PWINDOW_BUFFER_SIZE_RECORD, + MENU_EVENT_RECORD, PMENU_EVENT_RECORD, + FOCUS_EVENT_RECORD, PFOCUS_EVENT_RECORD, + INPUT_RECORD_Event, INPUT_RECORD, PINPUT_RECORD, + KEY_EVENT, MOUSE_EVENT, WINDOW_BUFFER_SIZE_EVENT, MENU_EVENT, FOCUS_EVENT, + CHAR_INFO_Char, CHAR_INFO, PCHAR_INFO, + CONSOLE_FONT_INFO, PCONSOLE_FONT_INFO +}; +pub const FOREGROUND_BLUE: WORD = 0x0001; +pub const FOREGROUND_GREEN: WORD = 0x0002; +pub const FOREGROUND_RED: WORD = 0x0004; +pub const FOREGROUND_INTENSITY: WORD = 0x0008; +pub const BACKGROUND_BLUE: WORD = 0x0010; +pub const BACKGROUND_GREEN: WORD = 0x0020; +pub const BACKGROUND_RED: WORD = 0x0040; +pub const BACKGROUND_INTENSITY: WORD = 0x0080; +pub const COMMON_LVB_LEADING_BYTE: WORD = 0x0100; +pub const COMMON_LVB_TRAILING_BYTE: WORD = 0x0200; +pub const COMMON_LVB_GRID_HORIZONTAL: WORD = 0x0400; +pub const COMMON_LVB_GRID_LVERTICAL: WORD = 0x0800; +pub const COMMON_LVB_GRID_RVERTICAL: WORD = 0x1000; +pub const COMMON_LVB_REVERSE_VIDEO: WORD = 0x4000; +pub const COMMON_LVB_UNDERSCORE: WORD = 0x8000; +pub const COMMON_LVB_SBCSDBCS: WORD = 0x0300; +STRUCT!{struct CONSOLE_SCREEN_BUFFER_INFO { + dwSize: COORD, + dwCursorPosition: COORD, + wAttributes: WORD, + srWindow: SMALL_RECT, + dwMaximumWindowSize: COORD, +}} +pub type PCONSOLE_SCREEN_BUFFER_INFO = *mut CONSOLE_SCREEN_BUFFER_INFO; +STRUCT!{struct CONSOLE_SCREEN_BUFFER_INFOEX { + cbSize: ULONG, + dwSize: COORD, + dwCursorPosition: COORD, + wAttributes: WORD, + srWindow: SMALL_RECT, + dwMaximumWindowSize: COORD, + wPopupAttributes: WORD, + bFullscreenSupported: BOOL, + ColorTable: [COLORREF; 16], +}} +pub type PCONSOLE_SCREEN_BUFFER_INFOEX = *mut CONSOLE_SCREEN_BUFFER_INFOEX; +STRUCT!{struct CONSOLE_CURSOR_INFO { + dwSize: DWORD, + bVisible: BOOL, +}} +pub type PCONSOLE_CURSOR_INFO = *mut CONSOLE_CURSOR_INFO; +STRUCT!{struct CONSOLE_FONT_INFOEX { + cbSize: ULONG, + nFont: DWORD, + dwFontSize: COORD, + FontFamily: UINT, + FontWeight: UINT, + FaceName: [WCHAR; LF_FACESIZE], +}} +pub type PCONSOLE_FONT_INFOEX = *mut CONSOLE_FONT_INFOEX; +pub const HISTORY_NO_DUP_FLAG: DWORD = 0x1; +STRUCT!{struct CONSOLE_HISTORY_INFO { + cbSize: UINT, + HistoryBufferSize: UINT, + NumberOfHistoryBuffers: UINT, + dwFlags: DWORD, +}} +pub type PCONSOLE_HISTORY_INFO = *mut CONSOLE_HISTORY_INFO; +STRUCT!{struct CONSOLE_SELECTION_INFO { + dwFlags: DWORD, + dwSelectionAnchor: COORD, + srSelection: SMALL_RECT, +}} +pub type PCONSOLE_SELECTION_INFO = *mut CONSOLE_SELECTION_INFO; +pub const CONSOLE_NO_SELECTION: DWORD = 0x0000; +pub const CONSOLE_SELECTION_IN_PROGRESS: DWORD = 0x0001; +pub const CONSOLE_SELECTION_NOT_EMPTY: DWORD = 0x0002; +pub const CONSOLE_MOUSE_SELECTION: DWORD = 0x0004; +pub const CONSOLE_MOUSE_DOWN: DWORD = 0x0008; +FN!{stdcall PHANDLER_ROUTINE( + CtrlType: DWORD, +) -> BOOL} +pub const CTRL_C_EVENT: DWORD = 0; +pub const CTRL_BREAK_EVENT: DWORD = 1; +pub const CTRL_CLOSE_EVENT: DWORD = 2; +pub const CTRL_LOGOFF_EVENT: DWORD = 5; +pub const CTRL_SHUTDOWN_EVENT: DWORD = 6; +pub const ENABLE_PROCESSED_INPUT: DWORD = 0x0001; +pub const ENABLE_LINE_INPUT: DWORD = 0x0002; +pub const ENABLE_ECHO_INPUT: DWORD = 0x0004; +pub const ENABLE_WINDOW_INPUT: DWORD = 0x0008; +pub const ENABLE_MOUSE_INPUT: DWORD = 0x0010; +pub const ENABLE_INSERT_MODE: DWORD = 0x0020; +pub const ENABLE_QUICK_EDIT_MODE: DWORD = 0x0040; +pub const ENABLE_EXTENDED_FLAGS: DWORD = 0x0080; +pub const ENABLE_AUTO_POSITION: DWORD = 0x0100; +pub const ENABLE_VIRTUAL_TERMINAL_INPUT: DWORD = 0x0200; +pub const ENABLE_PROCESSED_OUTPUT: DWORD = 0x0001; +pub const ENABLE_WRAP_AT_EOL_OUTPUT: DWORD = 0x0002; +pub const ENABLE_VIRTUAL_TERMINAL_PROCESSING: DWORD = 0x0004; +pub const DISABLE_NEWLINE_AUTO_RETURN: DWORD = 0x0008; +pub const ENABLE_LVB_GRID_WORLDWIDE: DWORD = 0x0010; +extern "system" { + pub fn PeekConsoleInputW( + hConsoleInput: HANDLE, + lpBuffer: PINPUT_RECORD, + nLength: DWORD, + lpNumberOfEventsRead: LPDWORD, + ) -> BOOL; + pub fn WriteConsoleInputA( + hConsoleInput: HANDLE, + lpBuffer: *const INPUT_RECORD, + nLength: DWORD, + lpNumberOfEventsWritten: LPDWORD, + ) -> BOOL; + pub fn WriteConsoleInputW( + hConsoleInput: HANDLE, + lpBuffer: *const INPUT_RECORD, + nLength: DWORD, + lpNumberOfEventsWritten: LPDWORD, + ) -> BOOL; + pub fn ReadConsoleOutputA( + hConsoleOutput: HANDLE, + lpBuffer: PCHAR_INFO, + dwBufferSize: COORD, + dwBufferCoord: COORD, + lpReadRegion: PSMALL_RECT, + ) -> BOOL; + pub fn ReadConsoleOutputW( + hConsoleOutput: HANDLE, + lpBuffer: PCHAR_INFO, + dwBufferSize: COORD, + dwBufferCoord: COORD, + lpReadRegion: PSMALL_RECT, + ) -> BOOL; + pub fn WriteConsoleOutputA( + hConsoleOutput: HANDLE, + lpBuffer: *const CHAR_INFO, + dwBufferSize: COORD, + dwBufferCoord: COORD, + lpWriteRegion: PSMALL_RECT, + ) -> BOOL; + pub fn WriteConsoleOutputW( + hConsoleOutput: HANDLE, + lpBuffer: *const CHAR_INFO, + dwBufferSize: COORD, + dwBufferCoord: COORD, + lpWriteRegion: PSMALL_RECT, + ) -> BOOL; + pub fn ReadConsoleOutputCharacterA( + hConsoleOutput: HANDLE, + lpCharacter: LPSTR, + nLength: DWORD, + dwReadCoord: COORD, + lpNumberOfCharsRead: LPDWORD, + ) -> BOOL; + pub fn ReadConsoleOutputCharacterW( + hConsoleOutput: HANDLE, + lpCharacter: LPWSTR, + nLength: DWORD, + dwReadCoord: COORD, + lpNumberOfCharsRead: LPDWORD, + ) -> BOOL; + pub fn ReadConsoleOutputAttribute( + hConsoleOutput: HANDLE, + lpAttribute: LPWORD, + nLength: DWORD, + dwReadCoord: COORD, + lpNumberOfAttrsRead: LPDWORD, + ) -> BOOL; + pub fn WriteConsoleOutputCharacterA( + hConsoleOutput: HANDLE, + lpCharacter: LPCSTR, + nLength: DWORD, + dwWriteCoord: COORD, + lpNumberOfCharsWritten: LPDWORD, + ) -> BOOL; + pub fn WriteConsoleOutputCharacterW( + hConsoleOutput: HANDLE, + lpCharacter: LPCWSTR, + nLength: DWORD, + dwWriteCoord: COORD, + lpNumberOfCharsWritten: LPDWORD, + ) -> BOOL; + pub fn WriteConsoleOutputAttribute( + hConsoleOutput: HANDLE, + lpAttribute: *const WORD, + nLength: DWORD, + dwWriteCoord: COORD, + lpNumberOfAttrsWritten: LPDWORD, + ) -> BOOL; + pub fn FillConsoleOutputCharacterA( + hConsoleOutput: HANDLE, + cCharacter: CHAR, + nLength: DWORD, + dwWriteCoord: COORD, + lpNumberOfCharsWritten: LPDWORD, + ) -> BOOL; + pub fn FillConsoleOutputCharacterW( + hConsoleOutput: HANDLE, + cCharacter: WCHAR, + nLength: DWORD, + dwWriteCoord: COORD, + lpNumberOfCharsWritten: LPDWORD, + ) -> BOOL; + pub fn FillConsoleOutputAttribute( + hConsoleOutput: HANDLE, + wAttribute: WORD, + nLength: DWORD, + dwWriteCoord: COORD, + lpNumberOfAttrsWritten: LPDWORD, + ) -> BOOL; +} +pub const CONSOLE_REAL_OUTPUT_HANDLE: *mut c_void = -2isize as *mut c_void; +pub const CONSOLE_REAL_INPUT_HANDLE: *mut c_void = -3isize as *mut c_void; +extern "system" { + pub fn GetConsoleScreenBufferInfo( + hConsoleOutput: HANDLE, + lpConsoleScreenBufferInfo: PCONSOLE_SCREEN_BUFFER_INFO, + ) -> BOOL; + pub fn GetConsoleScreenBufferInfoEx( + hConsoleOutput: HANDLE, + lpConsoleScreenBufferInfoEx: PCONSOLE_SCREEN_BUFFER_INFOEX, + ) -> BOOL; + pub fn SetConsoleScreenBufferInfoEx( + hConsoleOutput: HANDLE, + lpConsoleScreenBufferInfoEx: PCONSOLE_SCREEN_BUFFER_INFOEX, + ) -> BOOL; + pub fn GetLargestConsoleWindowSize( + hConsoleOutput: HANDLE, + ) -> COORD; + pub fn GetConsoleCursorInfo( + hConsoleOutput: HANDLE, + lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO, + ) -> BOOL; + pub fn GetCurrentConsoleFont( + hConsoleOutput: HANDLE, + bMaximumWindow: BOOL, + lpConsoleCurrentFont: PCONSOLE_FONT_INFO, + ) -> BOOL; + pub fn GetCurrentConsoleFontEx( + hConsoleOutput: HANDLE, + bMaximumWindow: BOOL, + lpConsoleCurrentFontEx: PCONSOLE_FONT_INFOEX, + ) -> BOOL; + pub fn SetCurrentConsoleFontEx( + hConsoleOutput: HANDLE, + bMaximumWindow: BOOL, + lpConsoleCurrentFontEx: PCONSOLE_FONT_INFOEX, + ) -> BOOL; + pub fn GetConsoleHistoryInfo( + lpConsoleHistoryInfo: PCONSOLE_HISTORY_INFO, + ) -> BOOL; + pub fn SetConsoleHistoryInfo( + lpConsoleHistoryInfo: PCONSOLE_HISTORY_INFO, + ) -> BOOL; + pub fn GetConsoleFontSize( + hConsoleOutput: HANDLE, + nFont: DWORD, + ) -> COORD; + pub fn GetConsoleSelectionInfo( + lpConsoleSelectionInfo: PCONSOLE_SELECTION_INFO, + ) -> BOOL; + pub fn GetNumberOfConsoleMouseButtons( + lpNumberOfMouseButtons: LPDWORD, + ) -> BOOL; + pub fn SetConsoleActiveScreenBuffer( + hConsoleOutput: HANDLE, + ) -> BOOL; + pub fn FlushConsoleInputBuffer( + hConsoleInput: HANDLE, + ) -> BOOL; + pub fn SetConsoleScreenBufferSize( + hConsoleOutput: HANDLE, + dwSize: COORD, + ) -> BOOL; + pub fn SetConsoleCursorPosition( + hConsoleOutput: HANDLE, + dwCursorPosition: COORD, + ) -> BOOL; + pub fn SetConsoleCursorInfo( + hConsoleOutput: HANDLE, + lpConsoleCursorInfo: *const CONSOLE_CURSOR_INFO, + ) -> BOOL; + pub fn ScrollConsoleScreenBufferA( + hConsoleOutput: HANDLE, + lpScrollRectangle: *const SMALL_RECT, + lpClipRectangle: *const SMALL_RECT, + dwDestinationOrigin: COORD, + lpFill: *const CHAR_INFO, + ) -> BOOL; + pub fn ScrollConsoleScreenBufferW( + hConsoleOutput: HANDLE, + lpScrollRectangle: *const SMALL_RECT, + lpClipRectangle: *const SMALL_RECT, + dwDestinationOrigin: COORD, + lpFill: *const CHAR_INFO, + ) -> BOOL; + pub fn SetConsoleWindowInfo( + hConsoleOutput: HANDLE, + bAbsolute: BOOL, + lpConsoleWindow: *const SMALL_RECT, + ) -> BOOL; + pub fn SetConsoleTextAttribute( + hConsoleOutput: HANDLE, + wAttributes: WORD, + ) -> BOOL; + pub fn GenerateConsoleCtrlEvent( + dwCtrlEvent: DWORD, + dwProcessGroupId: DWORD, + ) -> BOOL; + pub fn FreeConsole() -> BOOL; + pub fn AttachConsole( + dwProcessId: DWORD, + ) -> BOOL; +} +pub const ATTACH_PARENT_PROCESS: DWORD = 0xFFFFFFFF; +extern "system" { + pub fn GetConsoleTitleA( + lpConsoleTitle: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetConsoleTitleW( + lpConsoleTitle: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetConsoleOriginalTitleA( + lpConsoleTitle: LPSTR, + nSize: DWORD, + ) -> DWORD; + pub fn GetConsoleOriginalTitleW( + lpConsoleTitle: LPWSTR, + nSize: DWORD, + ) -> DWORD; + pub fn SetConsoleTitleA( + lpConsoleTitle: LPCSTR, + ) -> BOOL; + pub fn SetConsoleTitleW( + lpConsoleTitle: LPCWSTR, + ) -> BOOL; +} +STRUCT!{struct CONSOLE_READCONSOLE_CONTROL { + nLength: ULONG, + nInitialChars: ULONG, + dwCtrlWakeupMask: ULONG, + dwControlKeyState: ULONG, +}} +pub type PCONSOLE_READCONSOLE_CONTROL = *mut CONSOLE_READCONSOLE_CONTROL; +pub const CONSOLE_TEXTMODE_BUFFER: DWORD = 1; +extern "system" { + pub fn CreateConsoleScreenBuffer( + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: *const SECURITY_ATTRIBUTES, + dwFlags: DWORD, + lpScreenBufferData: LPVOID, + ) -> HANDLE; + pub fn SetConsoleCP( + wCodePageID: UINT, + ) -> BOOL; + pub fn SetConsoleOutputCP( + wCodePageID: UINT, + ) -> BOOL; +} +pub const CONSOLE_FULLSCREEN: DWORD = 1; +pub const CONSOLE_FULLSCREEN_HARDWARE: DWORD = 2; +extern "system" { + pub fn GetConsoleDisplayMode( + lpModeFlags: LPDWORD, + ) -> BOOL; +} +pub const CONSOLE_FULLSCREEN_MODE: DWORD = 1; +pub const CONSOLE_WINDOWED_MODE: DWORD = 2; +extern "system" { + pub fn SetConsoleDisplayMode( + hConsoleOutput: HANDLE, + dwFlags: DWORD, + lpNewScreenBufferDimensions: PCOORD, + ) -> BOOL; + pub fn GetConsoleWindow() -> HWND; + pub fn GetConsoleProcessList( + lpdwProcessList: LPDWORD, + dwProcessCount: DWORD, + ) -> DWORD; + pub fn AddConsoleAliasA( + Source: LPSTR, + Target: LPSTR, + ExeName: LPSTR, + ) -> BOOL; + pub fn AddConsoleAliasW( + Source: LPWSTR, + Target: LPWSTR, + ExeName: LPWSTR, + ) -> BOOL; + pub fn GetConsoleAliasA( + Source: LPSTR, + TargetBuffer: LPSTR, + TargetBufferLength: DWORD, + ExeName: LPSTR, + ) -> DWORD; + pub fn GetConsoleAliasW( + Source: LPWSTR, + TargetBuffer: LPWSTR, + TargetBufferLength: DWORD, + ExeName: LPWSTR, + ) -> DWORD; + pub fn GetConsoleAliasesLengthA( + ExeName: LPSTR, + ) -> DWORD; + pub fn GetConsoleAliasesLengthW( + ExeName: LPWSTR, + ) -> DWORD; + pub fn GetConsoleAliasExesLengthA() -> DWORD; + pub fn GetConsoleAliasExesLengthW() -> DWORD; + pub fn GetConsoleAliasesA( + AliasBuffer: LPSTR, + AliasBufferLength: DWORD, + ExeName: LPSTR, + ) -> DWORD; + pub fn GetConsoleAliasesW( + AliasBuffer: LPWSTR, + AliasBufferLength: DWORD, + ExeName: LPWSTR, + ) -> DWORD; + pub fn GetConsoleAliasExesA( + ExeNameBuffer: LPSTR, + ExeNameBufferLength: DWORD, + ) -> DWORD; + pub fn GetConsoleAliasExesW( + ExeNameBuffer: LPWSTR, + ExeNameBufferLength: DWORD, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wincontypes.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincontypes.rs new file mode 100644 index 0000000..ab37d02 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincontypes.rs @@ -0,0 +1,114 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module contains the public data structures, data types, and procedures exported by the NT +//! console subsystem. +use ctypes::c_void; +use shared::minwindef::{BOOL, DWORD, UINT, WORD}; +use um::winnt::{CHAR, SHORT, WCHAR}; +STRUCT!{struct COORD { + X: SHORT, + Y: SHORT, +}} +pub type PCOORD = *mut COORD; +STRUCT!{struct SMALL_RECT { + Left: SHORT, + Top: SHORT, + Right: SHORT, + Bottom: SHORT, +}} +pub type PSMALL_RECT = *mut SMALL_RECT; +UNION!{union KEY_EVENT_RECORD_uChar { + [u16; 1], + UnicodeChar UnicodeChar_mut: WCHAR, + AsciiChar AsciiChar_mut: CHAR, +}} +STRUCT!{struct KEY_EVENT_RECORD { + bKeyDown: BOOL, + wRepeatCount: WORD, + wVirtualKeyCode: WORD, + wVirtualScanCode: WORD, + uChar: KEY_EVENT_RECORD_uChar, + dwControlKeyState: DWORD, +}} +pub type PKEY_EVENT_RECORD = *mut KEY_EVENT_RECORD; +pub const RIGHT_ALT_PRESSED: DWORD = 0x0001; +pub const LEFT_ALT_PRESSED: DWORD = 0x0002; +pub const RIGHT_CTRL_PRESSED: DWORD = 0x0004; +pub const LEFT_CTRL_PRESSED: DWORD = 0x0008; +pub const SHIFT_PRESSED: DWORD = 0x0010; +pub const NUMLOCK_ON: DWORD = 0x0020; +pub const SCROLLLOCK_ON: DWORD = 0x0040; +pub const CAPSLOCK_ON: DWORD = 0x0080; +pub const ENHANCED_KEY: DWORD = 0x0100; +pub const NLS_DBCSCHAR: DWORD = 0x00010000; +pub const NLS_ALPHANUMERIC: DWORD = 0x00000000; +pub const NLS_KATAKANA: DWORD = 0x00020000; +pub const NLS_HIRAGANA: DWORD = 0x00040000; +pub const NLS_ROMAN: DWORD = 0x00400000; +pub const NLS_IME_CONVERSION: DWORD = 0x00800000; +pub const NLS_IME_DISABLE: DWORD = 0x20000000; +STRUCT!{struct MOUSE_EVENT_RECORD { + dwMousePosition: COORD, + dwButtonState: DWORD, + dwControlKeyState: DWORD, + dwEventFlags: DWORD, +}} +pub type PMOUSE_EVENT_RECORD = *mut MOUSE_EVENT_RECORD; +pub const FROM_LEFT_1ST_BUTTON_PRESSED: DWORD = 0x0001; +pub const RIGHTMOST_BUTTON_PRESSED: DWORD = 0x0002; +pub const FROM_LEFT_2ND_BUTTON_PRESSED: DWORD = 0x0004; +pub const FROM_LEFT_3RD_BUTTON_PRESSED: DWORD = 0x0008; +pub const FROM_LEFT_4TH_BUTTON_PRESSED: DWORD = 0x0010; +pub const MOUSE_MOVED: DWORD = 0x0001; +pub const DOUBLE_CLICK: DWORD = 0x0002; +pub const MOUSE_WHEELED: DWORD = 0x0004; +pub const MOUSE_HWHEELED: DWORD = 0x0008; +STRUCT!{struct WINDOW_BUFFER_SIZE_RECORD { + dwSize: COORD, +}} +pub type PWINDOW_BUFFER_SIZE_RECORD = *mut WINDOW_BUFFER_SIZE_RECORD; +STRUCT!{struct MENU_EVENT_RECORD { + dwCommandId: UINT, +}} +pub type PMENU_EVENT_RECORD = *mut MENU_EVENT_RECORD; +STRUCT!{struct FOCUS_EVENT_RECORD { + bSetFocus: BOOL, +}} +pub type PFOCUS_EVENT_RECORD = *mut FOCUS_EVENT_RECORD; +UNION!{union INPUT_RECORD_Event { + [u32; 4], + KeyEvent KeyEvent_mut: KEY_EVENT_RECORD, + MouseEvent MouseEvent_mut: MOUSE_EVENT_RECORD, + WindowBufferSizeEvent WindowBufferSizeEvent_mut: WINDOW_BUFFER_SIZE_RECORD, + MenuEvent MenuEvent_mut: MENU_EVENT_RECORD, + FocusEvent FocusEvent_mut: FOCUS_EVENT_RECORD, +}} +STRUCT!{struct INPUT_RECORD { + EventType: WORD, + Event: INPUT_RECORD_Event, +}} +pub type PINPUT_RECORD = *mut INPUT_RECORD; +pub const KEY_EVENT: WORD = 0x0001; +pub const MOUSE_EVENT: WORD = 0x0002; +pub const WINDOW_BUFFER_SIZE_EVENT: WORD = 0x0004; +pub const MENU_EVENT: WORD = 0x0008; +pub const FOCUS_EVENT: WORD = 0x0010; +UNION!{union CHAR_INFO_Char { + [u16; 1], + UnicodeChar UnicodeChar_mut: WCHAR, + AsciiChar AsciiChar_mut: CHAR, +}} +STRUCT!{struct CHAR_INFO { + Char: CHAR_INFO_Char, + Attributes: WORD, +}} +pub type PCHAR_INFO = *mut CHAR_INFO; +STRUCT!{struct CONSOLE_FONT_INFO { + nFont: DWORD, + dwFontSize: COORD, +}} +pub type PCONSOLE_FONT_INFO = *mut CONSOLE_FONT_INFO; +pub type HPCON = *mut c_void; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wincred.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincred.rs new file mode 100644 index 0000000..660837e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincred.rs @@ -0,0 +1,532 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Authentication API Prototypes and Definitions +use shared::minwindef::{ + BOOL, DWORD, FILETIME, LPBYTE, LPCVOID, LPDWORD, LPVOID, PBOOL, PBYTE, UCHAR, ULONG +}; +use shared::windef::{HBITMAP, HWND}; +use um::sspi::PCtxtHandle; +use um::winnt::{CHAR, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PCSTR, PCWSTR, PSTR, PVOID, PWSTR, WCHAR}; +// STATUS_* +pub const NERR_BASE: DWORD = 2100; +pub const NERR_PasswordExpired: DWORD = NERR_BASE + 142; +pub const CRED_MAX_STRING_LENGTH: DWORD = 256; +pub const CRED_MAX_USERNAME_LENGTH: DWORD = 256 + 1 + 256; +pub const CRED_MAX_GENERIC_TARGET_NAME_LENGTH: DWORD = 32767; +pub const CRED_MAX_DOMAIN_TARGET_NAME_LENGTH: DWORD = 256 + 1 + 80; +pub const CRED_MAX_TARGETNAME_NAMESPACE_LENGTH: DWORD = 256; +pub const CRED_MAX_TARGETNAME_ATTRIBUTE_LENGTH: DWORD = 256; +pub const CRED_MAX_VALUE_SIZE: DWORD = 256; +pub const CRED_MAX_ATTRIBUTES: DWORD = 64; +STRUCT!{struct CREDENTIAL_ATTRIBUTEA { + Keyword: LPSTR, + Flags: DWORD, + ValueSize: DWORD, + Value: LPBYTE, +}} +pub type PCREDENTIAL_ATTRIBUTEA = *mut CREDENTIAL_ATTRIBUTEA; +STRUCT!{struct CREDENTIAL_ATTRIBUTEW { + Keyword: LPWSTR, + Flags: DWORD, + ValueSize: DWORD, + Value: LPBYTE, +}} +pub type PCREDENTIAL_ATTRIBUTEW = *mut CREDENTIAL_ATTRIBUTEW; +pub const CRED_LOGON_TYPES_MASK: DWORD = 0xF000; +pub const CRED_FLAGS_PASSWORD_FOR_CERT: DWORD = 0x0001; +pub const CRED_FLAGS_PROMPT_NOW: DWORD = 0x0002; +pub const CRED_FLAGS_USERNAME_TARGET: DWORD = 0x0004; +pub const CRED_FLAGS_OWF_CRED_BLOB: DWORD = 0x0008; +pub const CRED_FLAGS_REQUIRE_CONFIRMATION: DWORD = 0x0010; +pub const CRED_FLAGS_WILDCARD_MATCH: DWORD = 0x0020; +pub const CRED_FLAGS_VALID_FLAGS: DWORD = 0xF03F; +pub const CRED_FLAGS_VALID_INPUT_FLAGS: DWORD = 0xF01F; +pub const CRED_TYPE_GENERIC: DWORD = 1; +pub const CRED_TYPE_DOMAIN_PASSWORD: DWORD = 2; +pub const CRED_TYPE_DOMAIN_CERTIFICATE: DWORD = 3; +pub const CRED_TYPE_DOMAIN_VISIBLE_PASSWORD: DWORD = 4; +pub const CRED_TYPE_GENERIC_CERTIFICATE: DWORD = 5; +pub const CRED_TYPE_DOMAIN_EXTENDED: DWORD = 6; +pub const CRED_TYPE_MAXIMUM: DWORD = 7; +pub const CRED_TYPE_MAXIMUM_EX: DWORD = CRED_TYPE_MAXIMUM + 1000; +pub const CRED_MAX_CREDENTIAL_BLOB_SIZE: DWORD = 5 * 512; +pub const CRED_PERSIST_NONE: DWORD = 0; +pub const CRED_PERSIST_SESSION: DWORD = 1; +pub const CRED_PERSIST_LOCAL_MACHINE: DWORD = 2; +pub const CRED_PERSIST_ENTERPRISE: DWORD = 3; +STRUCT!{struct CREDENTIALA { + Flags: DWORD, + Type: DWORD, + TargetName: LPSTR, + Comment: LPSTR, + LastWritten: FILETIME, + CredentialBlobSize: DWORD, + CredentialBlob: LPBYTE, + Persist: DWORD, + AttributeCount: DWORD, + Attributes: PCREDENTIAL_ATTRIBUTEA, + TargetAlias: LPSTR, + UserName: LPSTR, +}} +pub type PCREDENTIALA = *mut CREDENTIALA; +STRUCT!{struct CREDENTIALW { + Flags: DWORD, + Type: DWORD, + TargetName: LPWSTR, + Comment: LPWSTR, + LastWritten: FILETIME, + CredentialBlobSize: DWORD, + CredentialBlob: LPBYTE, + Persist: DWORD, + AttributeCount: DWORD, + Attributes: PCREDENTIAL_ATTRIBUTEW, + TargetAlias: LPWSTR, + UserName: LPWSTR, +}} +pub type PCREDENTIALW = *mut CREDENTIALW; +pub const CRED_TI_SERVER_FORMAT_UNKNOWN: ULONG = 0x0001; +pub const CRED_TI_DOMAIN_FORMAT_UNKNOWN: ULONG = 0x0002; +pub const CRED_TI_ONLY_PASSWORD_REQUIRED: ULONG = 0x0004; +pub const CRED_TI_USERNAME_TARGET: ULONG = 0x0008; +pub const CRED_TI_CREATE_EXPLICIT_CRED: ULONG = 0x0010; +pub const CRED_TI_WORKGROUP_MEMBER: ULONG = 0x0020; +pub const CRED_TI_VALID_FLAGS: ULONG = 0xF07F; +STRUCT!{struct CREDENTIAL_TARGET_INFORMATIONA { + TargetName: LPSTR, + NetbiosServerName: LPSTR, + DnsServerName: LPSTR, + NetbiosDomainName: LPSTR, + DnsDomainName: LPSTR, + DnsTreeName: LPSTR, + PackageName: LPSTR, + Flags: ULONG, + CredTypeCount: DWORD, + CredTypes: LPDWORD, +}} +pub type PCREDENTIAL_TARGET_INFORMATIONA = *mut CREDENTIAL_TARGET_INFORMATIONA; +STRUCT!{struct CREDENTIAL_TARGET_INFORMATIONW { + TargetName: LPWSTR, + NetbiosServerName: LPWSTR, + DnsServerName: LPWSTR, + NetbiosDomainName: LPWSTR, + DnsDomainName: LPWSTR, + DnsTreeName: LPWSTR, + PackageName: LPWSTR, + Flags: ULONG, + CredTypeCount: DWORD, + CredTypes: LPDWORD, +}} +pub type PCREDENTIAL_TARGET_INFORMATIONW = *mut CREDENTIAL_TARGET_INFORMATIONW; +pub const CERT_HASH_LENGTH: usize = 20; +STRUCT!{struct CERT_CREDENTIAL_INFO { + cbSize: ULONG, + rgbHashOfCert: [UCHAR; CERT_HASH_LENGTH], +}} +pub type PCERT_CREDENTIAL_INFO = *mut CERT_CREDENTIAL_INFO; +STRUCT!{struct USERNAME_TARGET_CREDENTIAL_INFO { + UserName: LPWSTR, +}} +pub type PUSERNAME_TARGET_CREDENTIAL_INFO = *mut USERNAME_TARGET_CREDENTIAL_INFO; +STRUCT!{struct BINARY_BLOB_CREDENTIAL_INFO { + cbBlob: ULONG, + pbBlob: LPBYTE, +}} +pub type PBINARY_BLOB_CREDENTIAL_INFO = *mut BINARY_BLOB_CREDENTIAL_INFO; +ENUM!{enum CRED_MARSHAL_TYPE { + CertCredential = 1, + UsernameTargetCredential, + BinaryBlobCredential, + UsernameForPackedCredentials, +}} +pub type PCRED_MARSHAL_TYPE = *mut CRED_MARSHAL_TYPE; +ENUM!{enum CRED_PROTECTION_TYPE { + CredUnprotected, + CredUserProtection, + CredTrustedProtection, +}} +pub type PCRED_PROTECTION_TYPE = *mut CRED_PROTECTION_TYPE; +pub const CRED_PACK_PROTECTED_CREDENTIALS: DWORD = 0x1; +pub const CRED_PACK_WOW_BUFFER: DWORD = 0x2; +pub const CRED_PACK_GENERIC_CREDENTIALS: DWORD = 0x4; +pub const CRED_PACK_ID_PROVIDER_CREDENTIALS: DWORD = 0x8; +STRUCT!{struct CREDUI_INFOA { + cbSize: DWORD, + hwndParent: HWND, + pszMessageText: PCSTR, + pszCaptionText: PCSTR, + hbmBanner: HBITMAP, +}} +pub type PCREDUI_INFOA = *mut CREDUI_INFOA; +STRUCT!{struct CREDUI_INFOW { + cbSize: DWORD, + hwndParent: HWND, + pszMessageText: PCWSTR, + pszCaptionText: PCWSTR, + hbmBanner: HBITMAP, +}} +pub type PCREDUI_INFOW = *mut CREDUI_INFOW; +pub const CREDUI_MAX_MESSAGE_LENGTH: DWORD = 1024; +pub const CREDUI_MAX_CAPTION_LENGTH: DWORD = 128; +pub const CREDUI_MAX_GENERIC_TARGET_LENGTH: DWORD = CRED_MAX_GENERIC_TARGET_NAME_LENGTH; +pub const CREDUI_MAX_DOMAIN_TARGET_LENGTH: DWORD = CRED_MAX_DOMAIN_TARGET_NAME_LENGTH; +pub const CREDUI_MAX_USERNAME_LENGTH: DWORD = CRED_MAX_USERNAME_LENGTH; +pub const CREDUI_MAX_PASSWORD_LENGTH: DWORD = 512 / 2; +pub const CREDUI_FLAGS_INCORRECT_PASSWORD: DWORD = 0x00001; +pub const CREDUI_FLAGS_DO_NOT_PERSIST: DWORD = 0x00002; +pub const CREDUI_FLAGS_REQUEST_ADMINISTRATOR: DWORD = 0x00004; +pub const CREDUI_FLAGS_EXCLUDE_CERTIFICATES: DWORD = 0x00008; +pub const CREDUI_FLAGS_REQUIRE_CERTIFICATE: DWORD = 0x00010; +pub const CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX: DWORD = 0x00040; +pub const CREDUI_FLAGS_ALWAYS_SHOW_UI: DWORD = 0x00080; +pub const CREDUI_FLAGS_REQUIRE_SMARTCARD: DWORD = 0x00100; +pub const CREDUI_FLAGS_PASSWORD_ONLY_OK: DWORD = 0x00200; +pub const CREDUI_FLAGS_VALIDATE_USERNAME: DWORD = 0x00400; +pub const CREDUI_FLAGS_COMPLETE_USERNAME: DWORD = 0x00800; +pub const CREDUI_FLAGS_PERSIST: DWORD = 0x01000; +pub const CREDUI_FLAGS_SERVER_CREDENTIAL: DWORD = 0x04000; +pub const CREDUI_FLAGS_EXPECT_CONFIRMATION: DWORD = 0x20000; +pub const CREDUI_FLAGS_GENERIC_CREDENTIALS: DWORD = 0x40000; +pub const CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS: DWORD = 0x80000; +pub const CREDUI_FLAGS_KEEP_USERNAME: DWORD = 0x100000; +pub const CREDUI_FLAGS_PROMPT_VALID: DWORD = CREDUI_FLAGS_INCORRECT_PASSWORD + | CREDUI_FLAGS_DO_NOT_PERSIST | CREDUI_FLAGS_REQUEST_ADMINISTRATOR + | CREDUI_FLAGS_EXCLUDE_CERTIFICATES | CREDUI_FLAGS_REQUIRE_CERTIFICATE + | CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX | CREDUI_FLAGS_ALWAYS_SHOW_UI + | CREDUI_FLAGS_REQUIRE_SMARTCARD | CREDUI_FLAGS_PASSWORD_ONLY_OK + | CREDUI_FLAGS_VALIDATE_USERNAME | CREDUI_FLAGS_COMPLETE_USERNAME | CREDUI_FLAGS_PERSIST + | CREDUI_FLAGS_SERVER_CREDENTIAL | CREDUI_FLAGS_EXPECT_CONFIRMATION + | CREDUI_FLAGS_GENERIC_CREDENTIALS | CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS + | CREDUI_FLAGS_KEEP_USERNAME; +pub const CREDUIWIN_GENERIC: DWORD = 0x00000001; +pub const CREDUIWIN_CHECKBOX: DWORD = 0x00000002; +pub const CREDUIWIN_AUTHPACKAGE_ONLY: DWORD = 0x00000010; +pub const CREDUIWIN_IN_CRED_ONLY: DWORD = 0x00000020; +pub const CREDUIWIN_ENUMERATE_ADMINS: DWORD = 0x00000100; +pub const CREDUIWIN_ENUMERATE_CURRENT_USER: DWORD = 0x00000200; +pub const CREDUIWIN_SECURE_PROMPT: DWORD = 0x00001000; +pub const CREDUIWIN_PREPROMPTING: DWORD = 0x00002000; +pub const CREDUIWIN_PACK_32_WOW: DWORD = 0x10000000; +pub const CREDUIWIN_VALID_FLAGS: DWORD = CREDUIWIN_GENERIC | CREDUIWIN_CHECKBOX + | CREDUIWIN_AUTHPACKAGE_ONLY | CREDUIWIN_IN_CRED_ONLY | CREDUIWIN_ENUMERATE_ADMINS + | CREDUIWIN_ENUMERATE_CURRENT_USER | CREDUIWIN_SECURE_PROMPT | CREDUIWIN_PREPROMPTING + | CREDUIWIN_PACK_32_WOW; +pub const CRED_PRESERVE_CREDENTIAL_BLOB: DWORD = 0x1; +extern "system" { + pub fn CredWriteW( + Credential: PCREDENTIALW, + Flags: DWORD, + ) -> BOOL; + pub fn CredWriteA( + Credential: PCREDENTIALA, + Flags: DWORD, + ) -> BOOL; + pub fn CredReadW( + TargetName: LPCWSTR, + Type: DWORD, + Flags: DWORD, + Credential: *mut PCREDENTIALW, + ) -> BOOL; + pub fn CredReadA( + TargetName: LPCSTR, + Type: DWORD, + Flags: DWORD, + Credential: *mut PCREDENTIALA, + ) -> BOOL; +} +pub const CRED_ENUMERATE_ALL_CREDENTIALS: DWORD = 0x1; +extern "system" { + pub fn CredEnumerateW( + Filter: LPCWSTR, + Flags: DWORD, + Count: *mut DWORD, + Credential: *mut *mut PCREDENTIALW, + ) -> BOOL; + pub fn CredEnumerateA( + Filter: LPCSTR, + Flags: DWORD, + Count: *mut DWORD, + Credential: *mut *mut PCREDENTIALA, + ) -> BOOL; + pub fn CredWriteDomainCredentialsW( + TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW, + Credential: PCREDENTIALW, + Flags: DWORD, + ) -> BOOL; + pub fn CredWriteDomainCredentialsA( + TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA, + Credential: PCREDENTIALA, + Flags: DWORD, + ) -> BOOL; +} +pub const CRED_CACHE_TARGET_INFORMATION: DWORD = 0x1; +extern "system" { + pub fn CredReadDomainCredentialsW( + TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW, + Flags: DWORD, + Count: *mut DWORD, + Credential: *mut *mut PCREDENTIALW, + ) -> BOOL; + pub fn CredReadDomainCredentialsA( + TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA, + Flags: DWORD, + Count: *mut DWORD, + Credential: *mut *mut PCREDENTIALA, + ) -> BOOL; + pub fn CredDeleteW( + TargetName: LPCWSTR, + Type: DWORD, + Flags: DWORD, + ) -> BOOL; + pub fn CredDeleteA( + TargetName: LPCSTR, + Type: DWORD, + Flags: DWORD, + ) -> BOOL; + pub fn CredRenameW( + OldTargetName: LPCWSTR, + NewTargetName: LPCWSTR, + Type: DWORD, + Flags: DWORD, + ) -> BOOL; + pub fn CredRenameA( + OldTargetName: LPCSTR, + NewTargetName: LPCSTR, + Type: DWORD, + Flags: DWORD, + ) -> BOOL; +} +pub const CRED_ALLOW_NAME_RESOLUTION: DWORD = 0x1; +extern "system" { + pub fn CredGetTargetInfoW( + TargetName: LPCWSTR, + Flags: DWORD, + TargetInfo: *mut PCREDENTIAL_TARGET_INFORMATIONW, + ) -> BOOL; + pub fn CredGetTargetInfoA( + TargetName: LPCSTR, + Flags: DWORD, + TargetInfo: *mut PCREDENTIAL_TARGET_INFORMATIONA, + ) -> BOOL; + pub fn CredMarshalCredentialW( + CredType: CRED_MARSHAL_TYPE, + Credential: PVOID, + MarhaledCredential: *mut LPWSTR, + ) -> BOOL; + pub fn CredMarshalCredentialA( + CredType: CRED_MARSHAL_TYPE, + Credential: PVOID, + MarhaledCredential: *mut LPSTR, + ) -> BOOL; + pub fn CredUnmarshalCredentialW( + MarshaledCredential: LPCWSTR, + CredType: PCRED_MARSHAL_TYPE, + Credential: *mut PVOID, + ) -> BOOL; + pub fn CredUnmarshalCredentialA( + MarshaledCredential: LPCSTR, + CredType: PCRED_MARSHAL_TYPE, + Credential: *mut PVOID, + ) -> BOOL; + pub fn CredIsMarshaledCredentialW( + MarshaledCredential: LPCWSTR, + ) -> BOOL; + pub fn CredIsMarshaledCredentialA( + MarshaledCredential: LPCSTR, + ) -> BOOL; + pub fn CredUnPackAuthenticationBufferW( + dwFlags: DWORD, + pAuthBuffer: PVOID, + cbAuthBuffer: DWORD, + pszUserName: LPWSTR, + pcchlMaxUserName: *mut DWORD, + pszDomainName: LPWSTR, + pcchMaxDomainName: *mut DWORD, + pszPassword: LPWSTR, + pcchMaxPassword: *mut DWORD, + ) -> BOOL; + pub fn CredUnPackAuthenticationBufferA( + dwFlags: DWORD, + pAuthBuffer: PVOID, + cbAuthBuffer: DWORD, + pszUserName: LPSTR, + pcchlMaxUserName: *mut DWORD, + pszDomainName: LPSTR, + pcchMaxDomainName: *mut DWORD, + pszPassword: LPSTR, + pcchMaxPassword: *mut DWORD, + ) -> BOOL; + pub fn CredPackAuthenticationBufferW( + dwFlags: DWORD, + pszUserName: LPWSTR, + pszPassword: LPWSTR, + pPackedCredentials: PBYTE, + pcbPackedCredentials: *mut DWORD, + ) -> BOOL; + pub fn CredPackAuthenticationBufferA( + dwFlags: DWORD, + pszUserName: LPSTR, + pszPassword: LPSTR, + pPackedCredentials: PBYTE, + pcbPackedCredentials: *mut DWORD, + ) -> BOOL; + pub fn CredProtectW( + fAsSelf: BOOL, + pszCredentials: LPWSTR, + cchCredentials: DWORD, + pszProtectedCredentials: LPWSTR, + pcchMaxChars: *mut DWORD, + ProtectionType: *mut CRED_PROTECTION_TYPE, + ) -> BOOL; + pub fn CredProtectA( + fAsSelf: BOOL, + pszCredentials: LPSTR, + cchCredentials: DWORD, + pszProtectedCredentials: LPSTR, + pcchMaxChars: *mut DWORD, + ProtectionType: *mut CRED_PROTECTION_TYPE, + ) -> BOOL; + pub fn CredUnprotectW( + fAsSelf: BOOL, + pszProtectedCredentials: LPWSTR, + cchCredentials: DWORD, + pszCredentials: LPWSTR, + pcchMaxChars: *mut DWORD, + ) -> BOOL; + pub fn CredUnprotectA( + fAsSelf: BOOL, + pszProtectedCredentials: LPSTR, + cchCredentials: DWORD, + pszCredentials: LPSTR, + pcchMaxChars: *mut DWORD, + ) -> BOOL; + pub fn CredIsProtectedW( + pszProtectedCredentials: LPWSTR, + pProtectionType: *mut CRED_PROTECTION_TYPE, + ) -> BOOL; + pub fn CredIsProtectedA( + pszProtectedCredentials: LPSTR, + pProtectionType: *mut CRED_PROTECTION_TYPE, + ) -> BOOL; + pub fn CredFindBestCredentialW( + TargetName: LPCWSTR, + Type: DWORD, + Flags: DWORD, + Credential: *mut PCREDENTIALW, + ) -> BOOL; + pub fn CredFindBestCredentialA( + TargetName: LPCSTR, + Type: DWORD, + Flags: DWORD, + Credential: *mut PCREDENTIALA, + ) -> BOOL; + pub fn CredGetSessionTypes( + MaximumPersistCount: DWORD, + MaximumPersist: LPDWORD, + ) -> BOOL; + pub fn CredFree( + Buffer: PVOID, + ); + pub fn CredUIPromptForCredentialsW( + pUiInfo: PCREDUI_INFOW, + pszTargetName: PCWSTR, + pContext: PCtxtHandle, + dwAuthError: DWORD, + pszUserName: PWSTR, + ulUserNameBufferSize: ULONG, + pszPassword: PWSTR, + ulPasswordBufferSize: ULONG, + save: *mut BOOL, + dwFlags: DWORD, + ) -> DWORD; + pub fn CredUIPromptForCredentialsA( + pUiInfo: PCREDUI_INFOA, + pszTargetName: PCSTR, + pContext: PCtxtHandle, + dwAuthError: DWORD, + pszUserName: PSTR, + ulUserNameBufferSize: ULONG, + pszPassword: PSTR, + ulPasswordBufferSize: ULONG, + save: *mut BOOL, + dwFlags: DWORD, + ) -> DWORD; + pub fn CredUIPromptForWindowsCredentialsW( + pUiInfo: PCREDUI_INFOW, + dwAuthError: DWORD, + pulAuthPackage: *mut ULONG, + pvInAuthBuffer: LPCVOID, + ulInAuthBufferSize: ULONG, + ppvOutAuthBuffer: *mut LPVOID, + pulOutAuthBufferSize: *mut ULONG, + pfSave: *mut BOOL, + dwFlags: DWORD, + ) -> DWORD; + pub fn CredUIPromptForWindowsCredentialsA( + pUiInfo: PCREDUI_INFOA, + dwAuthError: DWORD, + pulAuthPackage: *mut ULONG, + pvInAuthBuffer: LPCVOID, + ulInAuthBufferSize: ULONG, + ppvOutAuthBuffer: *mut LPVOID, + pulOutAuthBufferSize: *mut ULONG, + pfSave: *mut BOOL, + dwFlags: DWORD, + ) -> DWORD; + pub fn CredUIParseUserNameW( + userName: PCWSTR, + user: *mut WCHAR, + userBufferSize: ULONG, + domain: *mut WCHAR, + domainBufferSize: ULONG, + ) -> DWORD; + pub fn CredUIParseUserNameA( + userName: PCSTR, + user: *mut CHAR, + userBufferSize: ULONG, + domain: *mut CHAR, + domainBufferSize: ULONG, + ) -> DWORD; + pub fn CredUICmdLinePromptForCredentialsW( + pszTargetName: PCWSTR, + pContext: PCtxtHandle, + dwAuthError: DWORD, + UserName: PWSTR, + ulUserBufferSize: ULONG, + pszPassword: PWSTR, + ulPasswordBufferSize: ULONG, + pfSave: PBOOL, + dwFlags: DWORD, + ) -> DWORD; + pub fn CredUICmdLinePromptForCredentialsA( + pszTargetName: PCSTR, + pContext: PCtxtHandle, + dwAuthError: DWORD, + UserName: PSTR, + ulUserBufferSize: ULONG, + pszPassword: PSTR, + ulPasswordBufferSize: ULONG, + pfSave: PBOOL, + dwFlags: DWORD, + ) -> DWORD; + pub fn CredUIConfirmCredentialsW( + pszTargetName: PCWSTR, + bConfirm: BOOL, + ) -> DWORD; + pub fn CredUIConfirmCredentialsA( + pszTargetName: PCSTR, + bConfirm: BOOL, + ) -> DWORD; + pub fn CredUIStoreSSOCredW( + pszRealm: PCWSTR, + pszUsername: PCWSTR, + pszPassword: PCWSTR, + bPersist: BOOL, + ) -> DWORD; + pub fn CredUIReadSSOCredW( + pszRealm: PCWSTR, + ppszUsername: *mut PWSTR, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wincrypt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincrypt.rs new file mode 100644 index 0000000..abc2a99 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wincrypt.rs @@ -0,0 +1,7365 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Cryptographic API Prototypes and Definitions +use ctypes::{c_int, c_uchar, c_uint, c_void}; +use shared::basetsd::ULONG_PTR; +use shared::bcrypt::BCRYPT_KEY_HANDLE; +use shared::guiddef::{GUID, LPCGUID}; +use shared::minwindef::{ + BOOL, BYTE, DWORD, FALSE, FILETIME, HKEY, HMODULE, LPFILETIME, LPVOID, PBYTE, PDWORD, + PFILETIME, TRUE, ULONG, WORD, +}; +use um::minwinbase::PSYSTEMTIME; +use um::ncrypt::NCRYPT_KEY_HANDLE; +use um::winnt::{ + CHAR, HANDLE, HRESULT, LONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PCWSTR, PVOID, PWSTR, WCHAR, +}; +use vc::vcruntime::size_t; +//108 +#[inline] +pub fn GET_ALG_CLASS(x: ALG_ID) -> ALG_ID { + x & (7 << 13) +} +#[inline] +pub fn GET_ALG_TYPE(x: ALG_ID) -> ALG_ID { + x & (15 << 9) +} +#[inline] +pub fn GET_ALG_SID(x: ALG_ID) -> ALG_ID { + x & 511 +} +pub const ALG_CLASS_ANY: ALG_ID = 0; +pub const ALG_CLASS_SIGNATURE: ALG_ID = 1 << 13; +pub const ALG_CLASS_MSG_ENCRYPT: ALG_ID = 2 << 13; +pub const ALG_CLASS_DATA_ENCRYPT: ALG_ID = 3 << 13; +pub const ALG_CLASS_HASH: ALG_ID = 4 << 13; +pub const ALG_CLASS_KEY_EXCHANGE: ALG_ID = 5 << 13; +pub const ALG_CLASS_ALL: ALG_ID = 7 << 13; +pub const ALG_TYPE_ANY: ALG_ID = 0; +pub const ALG_TYPE_DSS: ALG_ID = 1 << 9; +pub const ALG_TYPE_RSA: ALG_ID = 2 << 9; +pub const ALG_TYPE_BLOCK: ALG_ID = 3 << 9; +pub const ALG_TYPE_STREAM: ALG_ID = 4 << 9; +pub const ALG_TYPE_DH: ALG_ID = 5 << 9; +pub const ALG_TYPE_SECURECHANNEL: ALG_ID = 6 << 9; +pub const ALG_TYPE_ECDH: ALG_ID = 7 << 9; +pub const ALG_TYPE_THIRDPARTY: ALG_ID = 8 << 9; +pub const ALG_SID_ANY: ALG_ID = 0; +pub const ALG_SID_THIRDPARTY_ANY: ALG_ID = 0; +pub const ALG_SID_RSA_ANY: ALG_ID = 0; +pub const ALG_SID_RSA_PKCS: ALG_ID = 1; +pub const ALG_SID_RSA_MSATWORK: ALG_ID = 2; +pub const ALG_SID_RSA_ENTRUST: ALG_ID = 3; +pub const ALG_SID_RSA_PGP: ALG_ID = 4; +pub const ALG_SID_DSS_ANY: ALG_ID = 0; +pub const ALG_SID_DSS_PKCS: ALG_ID = 1; +pub const ALG_SID_DSS_DMS: ALG_ID = 2; +pub const ALG_SID_ECDSA: ALG_ID = 3; +pub const ALG_SID_DES: ALG_ID = 1; +pub const ALG_SID_3DES: ALG_ID = 3; +pub const ALG_SID_DESX: ALG_ID = 4; +pub const ALG_SID_IDEA: ALG_ID = 5; +pub const ALG_SID_CAST: ALG_ID = 6; +pub const ALG_SID_SAFERSK64: ALG_ID = 7; +pub const ALG_SID_SAFERSK128: ALG_ID = 8; +pub const ALG_SID_3DES_112: ALG_ID = 9; +pub const ALG_SID_CYLINK_MEK: ALG_ID = 12; +pub const ALG_SID_RC5: ALG_ID = 13; +pub const ALG_SID_AES_128: ALG_ID = 14; +pub const ALG_SID_AES_192: ALG_ID = 15; +pub const ALG_SID_AES_256: ALG_ID = 16; +pub const ALG_SID_AES: ALG_ID = 17; +pub const ALG_SID_SKIPJACK: ALG_ID = 10; +pub const ALG_SID_TEK: ALG_ID = 11; +pub const CRYPT_MODE_CBCI: ALG_ID = 6; +pub const CRYPT_MODE_CFBP: ALG_ID = 7; +pub const CRYPT_MODE_OFBP: ALG_ID = 8; +pub const CRYPT_MODE_CBCOFM: ALG_ID = 9; +pub const CRYPT_MODE_CBCOFMI: ALG_ID = 10; +pub const ALG_SID_RC2: ALG_ID = 2; +pub const ALG_SID_RC4: ALG_ID = 1; +pub const ALG_SID_SEAL: ALG_ID = 2; +pub const ALG_SID_DH_SANDF: ALG_ID = 1; +pub const ALG_SID_DH_EPHEM: ALG_ID = 2; +pub const ALG_SID_AGREED_KEY_ANY: ALG_ID = 3; +pub const ALG_SID_KEA: ALG_ID = 4; +pub const ALG_SID_ECDH: ALG_ID = 5; +pub const ALG_SID_ECDH_EPHEM: ALG_ID = 6; +pub const ALG_SID_MD2: ALG_ID = 1; +pub const ALG_SID_MD4: ALG_ID = 2; +pub const ALG_SID_MD5: ALG_ID = 3; +pub const ALG_SID_SHA: ALG_ID = 4; +pub const ALG_SID_SHA1: ALG_ID = 4; +pub const ALG_SID_MAC: ALG_ID = 5; +pub const ALG_SID_RIPEMD: ALG_ID = 6; +pub const ALG_SID_RIPEMD160: ALG_ID = 7; +pub const ALG_SID_SSL3SHAMD5: ALG_ID = 8; +pub const ALG_SID_HMAC: ALG_ID = 9; +pub const ALG_SID_TLS1PRF: ALG_ID = 10; +pub const ALG_SID_HASH_REPLACE_OWF: ALG_ID = 11; +pub const ALG_SID_SHA_256: ALG_ID = 12; +pub const ALG_SID_SHA_384: ALG_ID = 13; +pub const ALG_SID_SHA_512: ALG_ID = 14; +pub const ALG_SID_SSL3_MASTER: ALG_ID = 1; +pub const ALG_SID_SCHANNEL_MASTER_HASH: ALG_ID = 2; +pub const ALG_SID_SCHANNEL_MAC_KEY: ALG_ID = 3; +pub const ALG_SID_PCT1_MASTER: ALG_ID = 4; +pub const ALG_SID_SSL2_MASTER: ALG_ID = 5; +pub const ALG_SID_TLS1_MASTER: ALG_ID = 6; +pub const ALG_SID_SCHANNEL_ENC_KEY: ALG_ID = 7; +pub const ALG_SID_ECMQV: ALG_ID = 1; +pub const ALG_SID_EXAMPLE: ALG_ID = 80; +pub type ALG_ID = c_uint; +pub const CALG_MD2: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD2; +pub const CALG_MD4: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD4; +pub const CALG_MD5: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD5; +pub const CALG_SHA: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA; +pub const CALG_SHA1: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA1; +pub const CALG_MAC: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MAC; +pub const CALG_RSA_SIGN: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_RSA | ALG_SID_RSA_ANY; +pub const CALG_DSS_SIGN: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_DSS_ANY; +pub const CALG_NO_SIGN: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | ALG_SID_ANY; +pub const CALG_RSA_KEYX: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_RSA | ALG_SID_RSA_ANY; +pub const CALG_DES: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DES; +pub const CALG_3DES_112: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_3DES_112; +pub const CALG_3DES: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_3DES; +pub const CALG_DESX: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DESX; +pub const CALG_RC2: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC2; +pub const CALG_RC4: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_RC4; +pub const CALG_SEAL: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_SEAL; +pub const CALG_DH_SF: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_DH_SANDF; +pub const CALG_DH_EPHEM: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_DH_EPHEM; +pub const CALG_AGREEDKEY_ANY: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH + | ALG_SID_AGREED_KEY_ANY; +pub const CALG_KEA_KEYX: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_KEA; +pub const CALG_HUGHES_MD5: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_MD5; +pub const CALG_SKIPJACK: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_SKIPJACK; +pub const CALG_TEK: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_TEK; +pub const CALG_CYLINK_MEK: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_CYLINK_MEK; +pub const CALG_SSL3_SHAMD5: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SSL3SHAMD5; +pub const CALG_SSL3_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_SSL3_MASTER; +pub const CALG_SCHANNEL_MASTER_HASH: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_SCHANNEL_MASTER_HASH; +pub const CALG_SCHANNEL_MAC_KEY: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_SCHANNEL_MAC_KEY; +pub const CALG_SCHANNEL_ENC_KEY: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_SCHANNEL_ENC_KEY; +pub const CALG_PCT1_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_PCT1_MASTER; +pub const CALG_SSL2_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_SSL2_MASTER; +pub const CALG_TLS1_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL + | ALG_SID_TLS1_MASTER; +pub const CALG_RC5: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC5; +pub const CALG_HMAC: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HMAC; +pub const CALG_TLS1PRF: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_TLS1PRF; +pub const CALG_HASH_REPLACE_OWF: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HASH_REPLACE_OWF; +pub const CALG_AES_128: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_128; +pub const CALG_AES_192: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_192; +pub const CALG_AES_256: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_256; +pub const CALG_AES: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES; +pub const CALG_SHA_256: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256; +pub const CALG_SHA_384: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384; +pub const CALG_SHA_512: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512; +pub const CALG_ECDH: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_ECDH; +pub const CALG_ECDH_EPHEM: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ECDH | ALG_SID_ECDH_EPHEM; +pub const CALG_ECMQV: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_ECMQV; +pub const CALG_ECDSA: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_ECDSA; +pub const CALG_NULLCIPHER: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_ANY | 0; +pub const CALG_THIRDPARTY_KEY_EXCHANGE: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_THIRDPARTY + | ALG_SID_THIRDPARTY_ANY; +pub const CALG_THIRDPARTY_SIGNATURE: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_THIRDPARTY + | ALG_SID_THIRDPARTY_ANY; +pub const CALG_THIRDPARTY_CIPHER: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_THIRDPARTY + | ALG_SID_THIRDPARTY_ANY; +pub const CALG_THIRDPARTY_HASH: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_THIRDPARTY + | ALG_SID_THIRDPARTY_ANY; +pub type HCRYPTPROV = ULONG_PTR; +pub type HCRYPTKEY = ULONG_PTR; +pub type HCRYPTHASH = ULONG_PTR; +pub const CRYPT_VERIFYCONTEXT: DWORD = 0xF0000000; +pub const CRYPT_NEWKEYSET: DWORD = 0x00000008; +pub const CRYPT_DELETEKEYSET: DWORD = 0x00000010; +pub const CRYPT_MACHINE_KEYSET: DWORD = 0x00000020; +pub const CRYPT_SILENT: DWORD = 0x00000040; +pub const CRYPT_DEFAULT_CONTAINER_OPTIONAL: DWORD = 0x00000080; +pub const CRYPT_EXPORTABLE: DWORD = 0x00000001; +pub const CRYPT_USER_PROTECTED: DWORD = 0x00000002; +pub const CRYPT_CREATE_SALT: DWORD = 0x00000004; +pub const CRYPT_UPDATE_KEY: DWORD = 0x00000008; +pub const CRYPT_NO_SALT: DWORD = 0x00000010; +pub const CRYPT_PREGEN: DWORD = 0x00000040; +pub const CRYPT_RECIPIENT: DWORD = 0x00000010; +pub const CRYPT_INITIATOR: DWORD = 0x00000040; +pub const CRYPT_ONLINE: DWORD = 0x00000080; +pub const CRYPT_SF: DWORD = 0x00000100; +pub const CRYPT_CREATE_IV: DWORD = 0x00000200; +pub const CRYPT_KEK: DWORD = 0x00000400; +pub const CRYPT_DATA_KEY: DWORD = 0x00000800; +pub const CRYPT_VOLATILE: DWORD = 0x00001000; +pub const CRYPT_SGCKEY: DWORD = 0x00002000; +pub const CRYPT_USER_PROTECTED_STRONG: DWORD = 0x00100000; +pub const CRYPT_ARCHIVABLE: DWORD = 0x00004000; +pub const CRYPT_FORCE_KEY_PROTECTION_HIGH: DWORD = 0x00008000; +pub const RSA1024BIT_KEY: DWORD = 0x04000000; +pub const CRYPT_SERVER: DWORD = 0x00000400; +pub const KEY_LENGTH_MASK: DWORD = 0xFFFF0000; +pub const CRYPT_Y_ONLY: DWORD = 0x00000001; +pub const CRYPT_SSL2_FALLBACK: DWORD = 0x00000002; +pub const CRYPT_DESTROYKEY: DWORD = 0x00000004; +pub const CRYPT_OAEP: DWORD = 0x00000040; +pub const CRYPT_BLOB_VER3: DWORD = 0x00000080; +pub const CRYPT_IPSEC_HMAC_KEY: DWORD = 0x00000100; +pub const CRYPT_DECRYPT_RSA_NO_PADDING_CHECK: DWORD = 0x00000020; +pub const CRYPT_SECRETDIGEST: DWORD = 0x00000001; +pub const CRYPT_OWF_REPL_LM_HASH: DWORD = 0x00000001; +pub const CRYPT_LITTLE_ENDIAN: DWORD = 0x00000001; +pub const CRYPT_NOHASHOID: DWORD = 0x00000001; +pub const CRYPT_TYPE2_FORMAT: DWORD = 0x00000002; +pub const CRYPT_X931_FORMAT: DWORD = 0x00000004; +pub const CRYPT_MACHINE_DEFAULT: DWORD = 0x00000001; +pub const CRYPT_USER_DEFAULT: DWORD = 0x00000002; +pub const CRYPT_DELETE_DEFAULT: DWORD = 0x00000004; +pub const SIMPLEBLOB: DWORD = 0x1; +pub const PUBLICKEYBLOB: DWORD = 0x6; +pub const PRIVATEKEYBLOB: DWORD = 0x7; +pub const PLAINTEXTKEYBLOB: DWORD = 0x8; +pub const OPAQUEKEYBLOB: DWORD = 0x9; +pub const PUBLICKEYBLOBEX: DWORD = 0xA; +pub const SYMMETRICWRAPKEYBLOB: DWORD = 0xB; +pub const KEYSTATEBLOB: DWORD = 0xC; +pub const AT_KEYEXCHANGE: DWORD = 1; +pub const AT_SIGNATURE: DWORD = 2; +pub const CRYPT_USERDATA: DWORD = 1; +pub const KP_IV: DWORD = 1; +pub const KP_SALT: DWORD = 2; +pub const KP_PADDING: DWORD = 3; +pub const KP_MODE: DWORD = 4; +pub const KP_MODE_BITS: DWORD = 5; +pub const KP_PERMISSIONS: DWORD = 6; +pub const KP_ALGID: DWORD = 7; +pub const KP_BLOCKLEN: DWORD = 8; +pub const KP_KEYLEN: DWORD = 9; +pub const KP_SALT_EX: DWORD = 10; +pub const KP_P: DWORD = 11; +pub const KP_G: DWORD = 12; +pub const KP_Q: DWORD = 13; +pub const KP_X: DWORD = 14; +pub const KP_Y: DWORD = 15; +pub const KP_RA: DWORD = 16; +pub const KP_RB: DWORD = 17; +pub const KP_INFO: DWORD = 18; +pub const KP_EFFECTIVE_KEYLEN: DWORD = 19; +pub const KP_SCHANNEL_ALG: DWORD = 20; +pub const KP_CLIENT_RANDOM: DWORD = 21; +pub const KP_SERVER_RANDOM: DWORD = 22; +pub const KP_RP: DWORD = 23; +pub const KP_PRECOMP_MD5: DWORD = 24; +pub const KP_PRECOMP_SHA: DWORD = 25; +pub const KP_CERTIFICATE: DWORD = 26; +pub const KP_CLEAR_KEY: DWORD = 27; +pub const KP_PUB_EX_LEN: DWORD = 28; +pub const KP_PUB_EX_VAL: DWORD = 29; +pub const KP_KEYVAL: DWORD = 30; +pub const KP_ADMIN_PIN: DWORD = 31; +pub const KP_KEYEXCHANGE_PIN: DWORD = 32; +pub const KP_SIGNATURE_PIN: DWORD = 33; +pub const KP_PREHASH: DWORD = 34; +pub const KP_ROUNDS: DWORD = 35; +pub const KP_OAEP_PARAMS: DWORD = 36; +pub const KP_CMS_KEY_INFO: DWORD = 37; +pub const KP_CMS_DH_KEY_INFO: DWORD = 38; +pub const KP_PUB_PARAMS: DWORD = 39; +pub const KP_VERIFY_PARAMS: DWORD = 40; +pub const KP_HIGHEST_VERSION: DWORD = 41; +pub const KP_GET_USE_COUNT: DWORD = 42; +pub const KP_PIN_ID: DWORD = 43; +pub const KP_PIN_INFO: DWORD = 44; +pub const PKCS5_PADDING: DWORD = 1; +pub const RANDOM_PADDING: DWORD = 2; +pub const ZERO_PADDING: DWORD = 3; +pub const CRYPT_MODE_CBC: DWORD = 1; +pub const CRYPT_MODE_ECB: DWORD = 2; +pub const CRYPT_MODE_OFB: DWORD = 3; +pub const CRYPT_MODE_CFB: DWORD = 4; +pub const CRYPT_MODE_CTS: DWORD = 5; +pub const CRYPT_ENCRYPT: DWORD = 0x0001; +pub const CRYPT_DECRYPT: DWORD = 0x0002; +pub const CRYPT_EXPORT: DWORD = 0x0004; +pub const CRYPT_READ: DWORD = 0x0008; +pub const CRYPT_WRITE: DWORD = 0x0010; +pub const CRYPT_MAC: DWORD = 0x0020; +pub const CRYPT_EXPORT_KEY: DWORD = 0x0040; +pub const CRYPT_IMPORT_KEY: DWORD = 0x0080; +pub const CRYPT_ARCHIVE: DWORD = 0x0100; +pub const HP_ALGID: DWORD = 0x0001; +pub const HP_HASHVAL: DWORD = 0x0002; +pub const HP_HASHSIZE: DWORD = 0x0004; +pub const HP_HMAC_INFO: DWORD = 0x0005; +pub const HP_TLS1PRF_LABEL: DWORD = 0x0006; +pub const HP_TLS1PRF_SEED: DWORD = 0x0007; +pub const CRYPT_FAILED: BOOL = FALSE; +pub const CRYPT_SUCCEED: BOOL = TRUE; +#[inline] +pub fn RCRYPT_SUCCEEDED(rt: BOOL) -> bool { + rt == CRYPT_SUCCEED +} +#[inline] +pub fn RCRYPT_FAILED(rt: BOOL) -> bool { + rt == CRYPT_FAILED +} +pub const PP_ENUMALGS: DWORD = 1; +pub const PP_ENUMCONTAINERS: DWORD = 2; +pub const PP_IMPTYPE: DWORD = 3; +pub const PP_NAME: DWORD = 4; +pub const PP_VERSION: DWORD = 5; +pub const PP_CONTAINER: DWORD = 6; +pub const PP_CHANGE_PASSWORD: DWORD = 7; +pub const PP_KEYSET_SEC_DESCR: DWORD = 8; +pub const PP_CERTCHAIN: DWORD = 9; +pub const PP_KEY_TYPE_SUBTYPE: DWORD = 10; +pub const PP_PROVTYPE: DWORD = 16; +pub const PP_KEYSTORAGE: DWORD = 17; +pub const PP_APPLI_CERT: DWORD = 18; +pub const PP_SYM_KEYSIZE: DWORD = 19; +pub const PP_SESSION_KEYSIZE: DWORD = 20; +pub const PP_UI_PROMPT: DWORD = 21; +pub const PP_ENUMALGS_EX: DWORD = 22; +pub const PP_ENUMMANDROOTS: DWORD = 25; +pub const PP_ENUMELECTROOTS: DWORD = 26; +pub const PP_KEYSET_TYPE: DWORD = 27; +pub const PP_ADMIN_PIN: DWORD = 31; +pub const PP_KEYEXCHANGE_PIN: DWORD = 32; +pub const PP_SIGNATURE_PIN: DWORD = 33; +pub const PP_SIG_KEYSIZE_INC: DWORD = 34; +pub const PP_KEYX_KEYSIZE_INC: DWORD = 35; +pub const PP_UNIQUE_CONTAINER: DWORD = 36; +pub const PP_SGC_INFO: DWORD = 37; +pub const PP_USE_HARDWARE_RNG: DWORD = 38; +pub const PP_KEYSPEC: DWORD = 39; +pub const PP_ENUMEX_SIGNING_PROT: DWORD = 40; +pub const PP_CRYPT_COUNT_KEY_USE: DWORD = 41; +pub const PP_USER_CERTSTORE: DWORD = 42; +pub const PP_SMARTCARD_READER: DWORD = 43; +pub const PP_SMARTCARD_GUID: DWORD = 45; +pub const PP_ROOT_CERTSTORE: DWORD = 46; +pub const PP_SMARTCARD_READER_ICON: DWORD = 47; +pub const CRYPT_FIRST: DWORD = 1; +pub const CRYPT_NEXT: DWORD = 2; +pub const CRYPT_SGC_ENUM: DWORD = 4; +pub const CRYPT_IMPL_HARDWARE: DWORD = 1; +pub const CRYPT_IMPL_SOFTWARE: DWORD = 2; +pub const CRYPT_IMPL_MIXED: DWORD = 3; +pub const CRYPT_IMPL_UNKNOWN: DWORD = 4; +pub const CRYPT_IMPL_REMOVABLE: DWORD = 8; +pub const CRYPT_SEC_DESCR: DWORD = 0x00000001; +pub const CRYPT_PSTORE: DWORD = 0x00000002; +pub const CRYPT_UI_PROMPT: DWORD = 0x00000004; +pub const CRYPT_FLAG_PCT1: DWORD = 0x0001; +pub const CRYPT_FLAG_SSL2: DWORD = 0x0002; +pub const CRYPT_FLAG_SSL3: DWORD = 0x0004; +pub const CRYPT_FLAG_TLS1: DWORD = 0x0008; +pub const CRYPT_FLAG_IPSEC: DWORD = 0x0010; +pub const CRYPT_FLAG_SIGNING: DWORD = 0x0020; +pub const CRYPT_SGC: DWORD = 0x0001; +pub const CRYPT_FASTSGC: DWORD = 0x0002; +pub const PP_CLIENT_HWND: DWORD = 1; +pub const PP_CONTEXT_INFO: DWORD = 11; +pub const PP_KEYEXCHANGE_KEYSIZE: DWORD = 12; +pub const PP_SIGNATURE_KEYSIZE: DWORD = 13; +pub const PP_KEYEXCHANGE_ALG: DWORD = 14; +pub const PP_SIGNATURE_ALG: DWORD = 15; +pub const PP_DELETEKEY: DWORD = 24; +pub const PP_PIN_PROMPT_STRING: DWORD = 44; +pub const PP_SECURE_KEYEXCHANGE_PIN: DWORD = 47; +pub const PP_SECURE_SIGNATURE_PIN: DWORD = 48; +pub const PROV_RSA_FULL: DWORD = 1; +pub const PROV_RSA_SIG: DWORD = 2; +pub const PROV_DSS: DWORD = 3; +pub const PROV_FORTEZZA: DWORD = 4; +pub const PROV_MS_EXCHANGE: DWORD = 5; +pub const PROV_SSL: DWORD = 6; +pub const PROV_RSA_SCHANNEL: DWORD = 12; +pub const PROV_DSS_DH: DWORD = 13; +pub const PROV_EC_ECDSA_SIG: DWORD = 14; +pub const PROV_EC_ECNRA_SIG: DWORD = 15; +pub const PROV_EC_ECDSA_FULL: DWORD = 16; +pub const PROV_EC_ECNRA_FULL: DWORD = 17; +pub const PROV_DH_SCHANNEL: DWORD = 18; +pub const PROV_SPYRUS_LYNKS: DWORD = 20; +pub const PROV_RNG: DWORD = 21; +pub const PROV_INTEL_SEC: DWORD = 22; +pub const PROV_REPLACE_OWF: DWORD = 23; +pub const PROV_RSA_AES: DWORD = 24; +pub const MS_DEF_PROV: &'static str = "Microsoft Base Cryptographic Provider v1.0"; +pub const MS_ENHANCED_PROV: &'static str = "Microsoft Enhanced Cryptographic Provider v1.0"; +pub const MS_STRONG_PROV: &'static str = "Microsoft Strong Cryptographic Provider"; +pub const MS_DEF_RSA_SIG_PROV: &'static str = "Microsoft RSA Signature Cryptographic Provider"; +pub const MS_DEF_RSA_SCHANNEL_PROV: &'static str = "Microsoft RSA SChannel Cryptographic Provider"; +pub const MS_DEF_DSS_PROV: &'static str = "Microsoft Base DSS Cryptographic Provider"; +pub const MS_DEF_DSS_DH_PROV: &'static str + = "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider"; +pub const MS_ENH_DSS_DH_PROV: &'static str + = "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider"; +pub const MS_DEF_DH_SCHANNEL_PROV: &'static str = "Microsoft DH SChannel Cryptographic Provider"; +pub const MS_SCARD_PROV: &'static str = "Microsoft Base Smart Card Crypto Provider"; +pub const MS_ENH_RSA_AES_PROV: &'static str + = "Microsoft Enhanced RSA and AES Cryptographic Provider"; +pub const MS_ENH_RSA_AES_PROV_XP: &'static str + = "Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)"; +pub const MAXUIDLEN: usize = 64; +pub const EXPO_OFFLOAD_REG_VALUE: &'static str = "ExpoOffload"; +pub const EXPO_OFFLOAD_FUNC_NAME: &'static str = "OffloadModExpo"; +pub const szKEY_CRYPTOAPI_PRIVATE_KEY_OPTIONS: &'static str + = "Software\\Policies\\Microsoft\\Cryptography"; +pub const szKEY_CACHE_ENABLED: &'static str = "CachePrivateKeys"; +pub const szKEY_CACHE_SECONDS: &'static str = "PrivateKeyLifetimeSeconds"; +pub const szPRIV_KEY_CACHE_MAX_ITEMS: &'static str = "PrivKeyCacheMaxItems"; +pub const cPRIV_KEY_CACHE_MAX_ITEMS_DEFAULT: DWORD = 20; +pub const szPRIV_KEY_CACHE_PURGE_INTERVAL_SECONDS: &'static str + = "PrivKeyCachePurgeIntervalSeconds"; +pub const cPRIV_KEY_CACHE_PURGE_INTERVAL_SECONDS_DEFAULT: DWORD = 86400; +pub const CUR_BLOB_VERSION: DWORD = 2; +STRUCT!{struct CMS_KEY_INFO { + dwVersion: DWORD, + Algid: ALG_ID, + pbOID: *mut BYTE, + cbOID: DWORD, +}} +pub type PCMS_KEY_INFO = *mut CMS_KEY_INFO; +STRUCT!{struct HMAC_INFO { + HashAlgid: ALG_ID, + pbInnerString: *mut BYTE, + cbInnerString: DWORD, + pbOuterString: *mut BYTE, + cbOuterString: DWORD, +}} +pub type PHMAC_INFO = *mut HMAC_INFO; +STRUCT!{struct SCHANNEL_ALG { + dwUse: DWORD, + Algid: ALG_ID, + cBits: DWORD, + dwFlags: DWORD, + dwReserved: DWORD, +}} +pub type PSCHANNEL_ALG = *mut SCHANNEL_ALG; +pub const SCHANNEL_MAC_KEY: DWORD = 0x00000000; +pub const SCHANNEL_ENC_KEY: DWORD = 0x00000001; +pub const INTERNATIONAL_USAGE: DWORD = 0x00000001; +STRUCT!{struct PROV_ENUMALGS { + aiAlgid: ALG_ID, + dwBitLen: DWORD, + dwNameLen: DWORD, + szName: [CHAR; 20], +}} +STRUCT!{struct PROV_ENUMALGS_EX { + aiAlgid: ALG_ID, + dwDefaultLen: DWORD, + dwMinLen: DWORD, + dwMaxLen: DWORD, + dwProtocols: DWORD, + dwNameLen: DWORD, + szName: [CHAR; 20], + dwLongNameLen: DWORD, + szLongName: [CHAR; 40], +}} +STRUCT!{struct BLOBHEADER { + bType: BYTE, + bVersion: BYTE, + reserved: WORD, + aiKeyAlg: ALG_ID, +}} +pub type PUBLICKEYSTRUC = BLOBHEADER; +STRUCT!{struct RSAPUBKEY { + magic: DWORD, + bitlen: DWORD, + pubexp: DWORD, +}} +STRUCT!{struct DHPUBKEY { + magic: DWORD, + bitlen: DWORD, +}} +pub type DSSPUBKEY = DHPUBKEY; +pub type KEAPUBKEY = DHPUBKEY; +pub type TEKPUBKEY = DHPUBKEY; +STRUCT!{struct DSSSEED { + counter: DWORD, + seed: [BYTE; 20], +}} +STRUCT!{struct DHPUBKEY_VER3 { + magic: DWORD, + bitlenP: DWORD, + bitlenQ: DWORD, + bitlenJ: DWORD, + DSSSeed: DSSSEED, +}} +pub type DSSPUBKEY_VER3 = DHPUBKEY_VER3; +STRUCT!{struct DHPRIVKEY_VER3 { + magic: DWORD, + bitlenP: DWORD, + bitlenQ: DWORD, + bitlenJ: DWORD, + bitlenX: DWORD, + DSSSeed: DSSSEED, +}} +pub type DSSPRIVKEY_VER3 = DHPRIVKEY_VER3; +STRUCT!{struct KEY_TYPE_SUBTYPE { + dwKeySpec: DWORD, + Type: GUID, + Subtype: GUID, +}} +pub type PKEY_TYPE_SUBTYPE = *mut KEY_TYPE_SUBTYPE; +STRUCT!{struct CERT_FORTEZZA_DATA_PROP { + SerialNumber: [c_uchar; 8], + CertIndex: c_int, + CertLabel: [c_uchar; 36], +}} +STRUCT!{struct CRYPT_RC4_KEY_STATE { + Key: [c_uchar; 16], + SBox: [c_uchar; 256], + i: c_uchar, + j: c_uchar, +}} +pub type PCRYPT_RC4_KEY_STATE = *mut CRYPT_RC4_KEY_STATE; +STRUCT!{struct CRYPT_DES_KEY_STATE { + Key: [c_uchar; 8], + IV: [c_uchar; 8], + Feedback: [c_uchar; 8], +}} +pub type PCRYPT_DES_KEY_STATE = *mut CRYPT_DES_KEY_STATE; +STRUCT!{struct CRYPT_3DES_KEY_STATE { + Key: [c_uchar; 24], + IV: [c_uchar; 8], + Feedback: [c_uchar; 8], +}} +pub type PCRYPT_3DES_KEY_STATE = *mut CRYPT_3DES_KEY_STATE; +STRUCT!{struct CRYPT_AES_128_KEY_STATE { + Key: [c_uchar; 16], + IV: [c_uchar; 16], + EncryptionState: [[c_uchar; 16]; 11], + DecryptionState: [[c_uchar; 16]; 11], + Feedback: [c_uchar; 16], +}} +pub type PCRYPT_AES_128_KEY_STATE = *mut CRYPT_AES_128_KEY_STATE; +STRUCT!{struct CRYPT_AES_256_KEY_STATE { + Key: [c_uchar; 32], + IV: [c_uchar; 16], + EncryptionState: [[c_uchar; 16]; 15], + DecryptionState: [[c_uchar; 16]; 15], + Feedback: [c_uchar; 16], +}} +pub type PCRYPT_AES_256_KEY_STATE = *mut CRYPT_AES_256_KEY_STATE; +STRUCT!{struct CRYPTOAPI_BLOB { + cbData: DWORD, + pbData: *mut BYTE, +}} +pub type CRYPT_INTEGER_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_INTEGER_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_UINT_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_UINT_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_OBJID_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_OBJID_BLOB = *mut CRYPTOAPI_BLOB; +pub type CERT_NAME_BLOB = CRYPTOAPI_BLOB; +pub type PCERT_NAME_BLOB = *mut CRYPTOAPI_BLOB; +pub type CERT_RDN_VALUE_BLOB = CRYPTOAPI_BLOB; +pub type PCERT_RDN_VALUE_BLOB = *mut CRYPTOAPI_BLOB; +pub type CERT_BLOB = CRYPTOAPI_BLOB; +pub type PCERT_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRL_BLOB = CRYPTOAPI_BLOB; +pub type PCRL_BLOB = *mut CRYPTOAPI_BLOB; +pub type DATA_BLOB = CRYPTOAPI_BLOB; +pub type PDATA_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_DATA_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_DATA_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_HASH_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_HASH_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_DIGEST_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_DIGEST_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_DER_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_DER_BLOB = *mut CRYPTOAPI_BLOB; +pub type CRYPT_ATTR_BLOB = CRYPTOAPI_BLOB; +pub type PCRYPT_ATTR_BLOB = *mut CRYPTOAPI_BLOB; +STRUCT!{struct CMS_DH_KEY_INFO { + dwVersion: DWORD, + Algid: ALG_ID, + pszContentEncObjId: LPSTR, + PubInfo: CRYPT_DATA_BLOB, + pReserved: *mut c_void, +}} +pub type PCMS_DH_KEY_INFO = *mut CMS_DH_KEY_INFO; +extern "system" { + pub fn CryptAcquireContextA( + phProv: *mut HCRYPTPROV, + szContainer: LPCSTR, + szProvider: LPCSTR, + dwProvType: DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptAcquireContextW( + phProv: *mut HCRYPTPROV, + szContainer: LPCWSTR, + szProvider: LPCWSTR, + dwProvType: DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptReleaseContext( + hProv: HCRYPTPROV, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptGenKey( + hProv: HCRYPTPROV, + Algid: ALG_ID, + dwFlags: DWORD, + phKey: *mut HCRYPTKEY, + ) -> BOOL; + pub fn CryptDeriveKey( + hProv: HCRYPTPROV, + Algid: ALG_ID, + hBaseData: HCRYPTHASH, + dwFlags: DWORD, + phKey: *mut HCRYPTKEY, + ) -> BOOL; + pub fn CryptDestroyKey( + hKey: HCRYPTKEY, + ) -> BOOL; + pub fn CryptSetKeyParam( + hKey: HCRYPTKEY, + dwParam: DWORD, + pbData: *const BYTE, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptGetKeyParam( + hKey: HCRYPTKEY, + dwParam: DWORD, + pbData: *mut BYTE, + pdwDataLen: *mut DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptSetHashParam( + hHash: HCRYPTHASH, + dwParam: DWORD, + pbData: *const BYTE, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptGetHashParam( + hHash: HCRYPTHASH, + dwParam: DWORD, + pbData: *mut BYTE, + pdwDataLen: *mut DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptSetProvParam( + hProv: HCRYPTPROV, + dwParam: DWORD, + pbData: *const BYTE, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptGetProvParam( + hProv: HCRYPTPROV, + dwParam: DWORD, + pbData: *mut BYTE, + pdwDataLen: *mut DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptGenRandom( + hProv: HCRYPTPROV, + dwLen: DWORD, + pbBuffer: *mut BYTE, + ) -> BOOL; + pub fn CryptGetUserKey( + hProv: HCRYPTPROV, + dwKeySpec: DWORD, + phUserKey: *mut HCRYPTKEY, + ) -> BOOL; + pub fn CryptExportKey( + hKey: HCRYPTKEY, + hExpKey: HCRYPTKEY, + dwBlobType: DWORD, + dwFlags: DWORD, + pbData: *mut BYTE, + pdwDataLen: *mut DWORD, + ) -> BOOL; + pub fn CryptImportKey( + hProv: HCRYPTPROV, + pbData: *const BYTE, + dwDataLen: DWORD, + hPubKey: HCRYPTKEY, + dwFlags: DWORD, + phKey: *mut HCRYPTKEY, + ) -> BOOL; + pub fn CryptEncrypt( + hKey: HCRYPTKEY, + hHash: HCRYPTHASH, + Final: BOOL, + dwFlags: DWORD, + pbData: *mut BYTE, + pdwDataLen: *mut DWORD, + dwBufLen: DWORD, + ) -> BOOL; + pub fn CryptDecrypt( + hKey: HCRYPTKEY, + hHash: HCRYPTHASH, + Final: BOOL, + dwFlags: DWORD, + pbData: *mut BYTE, + pdwDataLen: *mut DWORD, + ) -> BOOL; + pub fn CryptCreateHash( + hProv: HCRYPTPROV, + Algid: ALG_ID, + hKey: HCRYPTKEY, + dwFlags: DWORD, + phHash: *mut HCRYPTHASH, + ) -> BOOL; + pub fn CryptHashData( + hHash: HCRYPTHASH, + pbData: *const BYTE, + dwDataLen: DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptHashSessionKey( + hHash: HCRYPTHASH, + hKey: HCRYPTKEY, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptDestroyHash( + hHash: HCRYPTHASH, + ) -> BOOL; + pub fn CryptSignHashA( + hHash: HCRYPTHASH, + dwKeySpec: DWORD, + szDescription: LPCSTR, + dwFlags: DWORD, + pbSignature: *mut BYTE, + pdwSigLen: *mut DWORD, + ) -> BOOL; + pub fn CryptSignHashW( + hHash: HCRYPTHASH, + dwKeySpec: DWORD, + szDescription: LPCWSTR, + dwFlags: DWORD, + pbSignature: *mut BYTE, + pdwSigLen: *mut DWORD, + ) -> BOOL; + pub fn CryptVerifySignatureA( + hHash: HCRYPTHASH, + pbSignature: *const BYTE, + dwSigLen: DWORD, + hPubKey: HCRYPTKEY, + szDescription: LPCSTR, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptVerifySignatureW( + hHash: HCRYPTHASH, + pbSignature: *const BYTE, + dwSigLen: DWORD, + hPubKey: HCRYPTKEY, + szDescription: LPCWSTR, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptSetProviderA( + pszProvName: LPCSTR, + dwProvType: DWORD, + ) -> BOOL; + pub fn CryptSetProviderW( + pszProvName: LPCWSTR, + dwProvType: DWORD, + ) -> BOOL; + pub fn CryptSetProviderExA( + pszProvName: LPCSTR, + dwProvType: DWORD, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptSetProviderExW( + pszProvName: LPCWSTR, + dwProvType: DWORD, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptGetDefaultProviderA( + dwProvType: DWORD, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + pszProvName: LPSTR, + pcbProvName: *mut DWORD, + ) -> BOOL; + pub fn CryptGetDefaultProviderW( + dwProvType: DWORD, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + pszProvName: LPWSTR, + pcbProvName: *mut DWORD, + ) -> BOOL; + pub fn CryptEnumProviderTypesA( + dwIndex: DWORD, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + pdwProvType: *mut DWORD, + szTypeName: LPSTR, + pcbTypeName: *mut DWORD, + ) -> BOOL; + pub fn CryptEnumProviderTypesW( + dwIndex: DWORD, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + pdwProvType: *mut DWORD, + szTypeName: LPWSTR, + pcbTypeName: *mut DWORD, + ) -> BOOL; + pub fn CryptEnumProvidersA( + dwIndex: DWORD, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + pdwProvType: *mut DWORD, + szProvName: LPSTR, + pcbProvName: *mut DWORD, + ) -> BOOL; + pub fn CryptEnumProvidersW( + dwIndex: DWORD, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + pdwProvType: *mut DWORD, + szProvName: LPWSTR, + pcbProvName: *mut DWORD, + ) -> BOOL; + pub fn CryptContextAddRef( + hProv: HCRYPTPROV, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptDuplicateKey( + hKey: HCRYPTKEY, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + phKey: *mut HCRYPTKEY, + ) -> BOOL; + pub fn CryptDuplicateHash( + hHash: HCRYPTHASH, + pdwReserved: *mut DWORD, + dwFlags: DWORD, + phHash: *mut HCRYPTHASH, + ) -> BOOL; +} +extern "C" { + pub fn GetEncSChannel( + pData: *mut *mut BYTE, + dwDecSize: *mut DWORD, + ) -> BOOL; +} +pub type HCRYPTPROV_OR_NCRYPT_KEY_HANDLE = ULONG_PTR; +pub type HCRYPTPROV_LEGACY = ULONG_PTR; +STRUCT!{struct CRYPT_BIT_BLOB { + cbData: DWORD, + pbData: *mut BYTE, + cUnusedBits: DWORD, +}} +pub type PCRYPT_BIT_BLOB = *mut CRYPT_BIT_BLOB; +STRUCT!{struct CRYPT_ALGORITHM_IDENTIFIER { + pszObjId: LPSTR, + Parameters: CRYPT_OBJID_BLOB, +}} +pub type PCRYPT_ALGORITHM_IDENTIFIER = *mut CRYPT_ALGORITHM_IDENTIFIER; +pub const szOID_RSA: &'static str = "1.2.840.113549"; +pub const szOID_PKCS: &'static str = "1.2.840.113549.1"; +pub const szOID_RSA_HASH: &'static str = "1.2.840.113549.2"; +pub const szOID_RSA_ENCRYPT: &'static str = "1.2.840.113549.3"; +pub const szOID_PKCS_1: &'static str = "1.2.840.113549.1.1"; +pub const szOID_PKCS_2: &'static str = "1.2.840.113549.1.2"; +pub const szOID_PKCS_3: &'static str = "1.2.840.113549.1.3"; +pub const szOID_PKCS_4: &'static str = "1.2.840.113549.1.4"; +pub const szOID_PKCS_5: &'static str = "1.2.840.113549.1.5"; +pub const szOID_PKCS_6: &'static str = "1.2.840.113549.1.6"; +pub const szOID_PKCS_7: &'static str = "1.2.840.113549.1.7"; +pub const szOID_PKCS_8: &'static str = "1.2.840.113549.1.8"; +pub const szOID_PKCS_9: &'static str = "1.2.840.113549.1.9"; +pub const szOID_PKCS_10: &'static str = "1.2.840.113549.1.10"; +pub const szOID_PKCS_12: &'static str = "1.2.840.113549.1.12"; +pub const szOID_RSA_RSA: &'static str = "1.2.840.113549.1.1.1"; +pub const szOID_RSA_MD2RSA: &'static str = "1.2.840.113549.1.1.2"; +pub const szOID_RSA_MD4RSA: &'static str = "1.2.840.113549.1.1.3"; +pub const szOID_RSA_MD5RSA: &'static str = "1.2.840.113549.1.1.4"; +pub const szOID_RSA_SHA1RSA: &'static str = "1.2.840.113549.1.1.5"; +pub const szOID_RSA_SETOAEP_RSA: &'static str = "1.2.840.113549.1.1.6"; +pub const szOID_RSAES_OAEP: &'static str = "1.2.840.113549.1.1.7"; +pub const szOID_RSA_MGF1: &'static str = "1.2.840.113549.1.1.8"; +pub const szOID_RSA_PSPECIFIED: &'static str = "1.2.840.113549.1.1.9"; +pub const szOID_RSA_SSA_PSS: &'static str = "1.2.840.113549.1.1.10"; +pub const szOID_RSA_SHA256RSA: &'static str = "1.2.840.113549.1.1.11"; +pub const szOID_RSA_SHA384RSA: &'static str = "1.2.840.113549.1.1.12"; +pub const szOID_RSA_SHA512RSA: &'static str = "1.2.840.113549.1.1.13"; +pub const szOID_RSA_DH: &'static str = "1.2.840.113549.1.3.1"; +pub const szOID_RSA_data: &'static str = "1.2.840.113549.1.7.1"; +pub const szOID_RSA_signedData: &'static str = "1.2.840.113549.1.7.2"; +pub const szOID_RSA_envelopedData: &'static str = "1.2.840.113549.1.7.3"; +pub const szOID_RSA_signEnvData: &'static str = "1.2.840.113549.1.7.4"; +pub const szOID_RSA_digestedData: &'static str = "1.2.840.113549.1.7.5"; +pub const szOID_RSA_hashedData: &'static str = "1.2.840.113549.1.7.5"; +pub const szOID_RSA_encryptedData: &'static str = "1.2.840.113549.1.7.6"; +pub const szOID_RSA_emailAddr: &'static str = "1.2.840.113549.1.9.1"; +pub const szOID_RSA_unstructName: &'static str = "1.2.840.113549.1.9.2"; +pub const szOID_RSA_contentType: &'static str = "1.2.840.113549.1.9.3"; +pub const szOID_RSA_messageDigest: &'static str = "1.2.840.113549.1.9.4"; +pub const szOID_RSA_signingTime: &'static str = "1.2.840.113549.1.9.5"; +pub const szOID_RSA_counterSign: &'static str = "1.2.840.113549.1.9.6"; +pub const szOID_RSA_challengePwd: &'static str = "1.2.840.113549.1.9.7"; +pub const szOID_RSA_unstructAddr: &'static str = "1.2.840.113549.1.9.8"; +pub const szOID_RSA_extCertAttrs: &'static str = "1.2.840.113549.1.9.9"; +pub const szOID_RSA_certExtensions: &'static str = "1.2.840.113549.1.9.14"; +pub const szOID_RSA_SMIMECapabilities: &'static str = "1.2.840.113549.1.9.15"; +pub const szOID_RSA_preferSignedData: &'static str = "1.2.840.113549.1.9.15.1"; +pub const szOID_TIMESTAMP_TOKEN: &'static str = "1.2.840.113549.1.9.16.1.4"; +pub const szOID_RFC3161_counterSign: &'static str = "1.3.6.1.4.1.311.3.3.1"; +pub const szOID_RSA_SMIMEalg: &'static str = "1.2.840.113549.1.9.16.3"; +pub const szOID_RSA_SMIMEalgESDH: &'static str = "1.2.840.113549.1.9.16.3.5"; +pub const szOID_RSA_SMIMEalgCMS3DESwrap: &'static str = "1.2.840.113549.1.9.16.3.6"; +pub const szOID_RSA_SMIMEalgCMSRC2wrap: &'static str = "1.2.840.113549.1.9.16.3.7"; +pub const szOID_RSA_MD2: &'static str = "1.2.840.113549.2.2"; +pub const szOID_RSA_MD4: &'static str = "1.2.840.113549.2.4"; +pub const szOID_RSA_MD5: &'static str = "1.2.840.113549.2.5"; +pub const szOID_RSA_RC2CBC: &'static str = "1.2.840.113549.3.2"; +pub const szOID_RSA_RC4: &'static str = "1.2.840.113549.3.4"; +pub const szOID_RSA_DES_EDE3_CBC: &'static str = "1.2.840.113549.3.7"; +pub const szOID_RSA_RC5_CBCPad: &'static str = "1.2.840.113549.3.9"; +pub const szOID_ANSI_X942: &'static str = "1.2.840.10046"; +pub const szOID_ANSI_X942_DH: &'static str = "1.2.840.10046.2.1"; +pub const szOID_X957: &'static str = "1.2.840.10040"; +pub const szOID_X957_DSA: &'static str = "1.2.840.10040.4.1"; +pub const szOID_X957_SHA1DSA: &'static str = "1.2.840.10040.4.3"; +pub const szOID_ECC_PUBLIC_KEY: &'static str = "1.2.840.10045.2.1"; +pub const szOID_ECC_CURVE_P256: &'static str = "1.2.840.10045.3.1.7"; +pub const szOID_ECC_CURVE_P384: &'static str = "1.3.132.0.34"; +pub const szOID_ECC_CURVE_P521: &'static str = "1.3.132.0.35"; +pub const szOID_ECC_CURVE_BRAINPOOLP160R1: &'static str = "1.3.36.3.3.2.8.1.1.1"; +pub const szOID_ECC_CURVE_BRAINPOOLP160T1: &'static str = "1.3.36.3.3.2.8.1.1.2"; +pub const szOID_ECC_CURVE_BRAINPOOLP192R1: &'static str = "1.3.36.3.3.2.8.1.1.3"; +pub const szOID_ECC_CURVE_BRAINPOOLP192T1: &'static str = "1.3.36.3.3.2.8.1.1.4"; +pub const szOID_ECC_CURVE_BRAINPOOLP224R1: &'static str = "1.3.36.3.3.2.8.1.1.5"; +pub const szOID_ECC_CURVE_BRAINPOOLP224T1: &'static str = "1.3.36.3.3.2.8.1.1.6"; +pub const szOID_ECC_CURVE_BRAINPOOLP256R1: &'static str = "1.3.36.3.3.2.8.1.1.7"; +pub const szOID_ECC_CURVE_BRAINPOOLP256T1: &'static str = "1.3.36.3.3.2.8.1.1.8"; +pub const szOID_ECC_CURVE_BRAINPOOLP320R1: &'static str = "1.3.36.3.3.2.8.1.1.9"; +pub const szOID_ECC_CURVE_BRAINPOOLP320T1: &'static str = "1.3.36.3.3.2.8.1.1.10"; +pub const szOID_ECC_CURVE_BRAINPOOLP384R1: &'static str = "1.3.36.3.3.2.8.1.1.11"; +pub const szOID_ECC_CURVE_BRAINPOOLP384T1: &'static str = "1.3.36.3.3.2.8.1.1.12"; +pub const szOID_ECC_CURVE_BRAINPOOLP512R1: &'static str = "1.3.36.3.3.2.8.1.1.13"; +pub const szOID_ECC_CURVE_BRAINPOOLP512T1: &'static str = "1.3.36.3.3.2.8.1.1.14"; +pub const szOID_ECC_CURVE_EC192WAPI: &'static str = "1.2.156.11235.1.1.2.1"; +pub const szOID_CN_ECDSA_SHA256: &'static str = "1.2.156.11235.1.1.1"; +pub const szOID_ECC_CURVE_NISTP192: &'static str = "1.2.840.10045.3.1.1"; +pub const szOID_ECC_CURVE_NISTP224: &'static str = "1.3.132.0.33"; +pub const szOID_ECC_CURVE_NISTP256: &'static str = szOID_ECC_CURVE_P256; +pub const szOID_ECC_CURVE_NISTP384: &'static str = szOID_ECC_CURVE_P384; +pub const szOID_ECC_CURVE_NISTP521: &'static str = szOID_ECC_CURVE_P521; +pub const szOID_ECC_CURVE_SECP160K1: &'static str = "1.3.132.0.9"; +pub const szOID_ECC_CURVE_SECP160R1: &'static str = "1.3.132.0.8"; +pub const szOID_ECC_CURVE_SECP160R2: &'static str = "1.3.132.0.30"; +pub const szOID_ECC_CURVE_SECP192K1: &'static str = "1.3.132.0.31"; +pub const szOID_ECC_CURVE_SECP192R1: &'static str = szOID_ECC_CURVE_NISTP192; +pub const szOID_ECC_CURVE_SECP224K1: &'static str = "1.3.132.0.32"; +pub const szOID_ECC_CURVE_SECP224R1: &'static str = szOID_ECC_CURVE_NISTP224; +pub const szOID_ECC_CURVE_SECP256K1: &'static str = "1.3.132.0.10"; +pub const szOID_ECC_CURVE_SECP256R1: &'static str = szOID_ECC_CURVE_P256; +pub const szOID_ECC_CURVE_SECP384R1: &'static str = szOID_ECC_CURVE_P384; +pub const szOID_ECC_CURVE_SECP521R1: &'static str = szOID_ECC_CURVE_P521; +pub const szOID_ECC_CURVE_WTLS7: &'static str = szOID_ECC_CURVE_SECP160R2; +pub const szOID_ECC_CURVE_WTLS9: &'static str = "2.23.43.1.4.9"; +pub const szOID_ECC_CURVE_WTLS12: &'static str = szOID_ECC_CURVE_NISTP224; +pub const szOID_ECC_CURVE_X962P192V1: &'static str = "1.2.840.10045.3.1.1"; +pub const szOID_ECC_CURVE_X962P192V2: &'static str = "1.2.840.10045.3.1.2"; +pub const szOID_ECC_CURVE_X962P192V3: &'static str = "1.2.840.10045.3.1.3"; +pub const szOID_ECC_CURVE_X962P239V1: &'static str = "1.2.840.10045.3.1.4"; +pub const szOID_ECC_CURVE_X962P239V2: &'static str = "1.2.840.10045.3.1.5"; +pub const szOID_ECC_CURVE_X962P239V3: &'static str = "1.2.840.10045.3.1.6"; +pub const szOID_ECC_CURVE_X962P256V1: &'static str = szOID_ECC_CURVE_P256; +pub const szOID_ECDSA_SHA1: &'static str = "1.2.840.10045.4.1"; +pub const szOID_ECDSA_SPECIFIED: &'static str = "1.2.840.10045.4.3"; +pub const szOID_ECDSA_SHA256: &'static str = "1.2.840.10045.4.3.2"; +pub const szOID_ECDSA_SHA384: &'static str = "1.2.840.10045.4.3.3"; +pub const szOID_ECDSA_SHA512: &'static str = "1.2.840.10045.4.3.4"; +pub const szOID_NIST_AES128_CBC: &'static str = "2.16.840.1.101.3.4.1.2"; +pub const szOID_NIST_AES192_CBC: &'static str = "2.16.840.1.101.3.4.1.22"; +pub const szOID_NIST_AES256_CBC: &'static str = "2.16.840.1.101.3.4.1.42"; +pub const szOID_NIST_AES128_WRAP: &'static str = "2.16.840.1.101.3.4.1.5"; +pub const szOID_NIST_AES192_WRAP: &'static str = "2.16.840.1.101.3.4.1.25"; +pub const szOID_NIST_AES256_WRAP: &'static str = "2.16.840.1.101.3.4.1.45"; +pub const szOID_DH_SINGLE_PASS_STDDH_SHA1_KDF: &'static str = "1.3.133.16.840.63.0.2"; +pub const szOID_DH_SINGLE_PASS_STDDH_SHA256_KDF: &'static str = "1.3.132.1.11.1"; +pub const szOID_DH_SINGLE_PASS_STDDH_SHA384_KDF: &'static str = "1.3.132.1.11.2"; +pub const szOID_DS: &'static str = "2.5"; +pub const szOID_DSALG: &'static str = "2.5.8"; +pub const szOID_DSALG_CRPT: &'static str = "2.5.8.1"; +pub const szOID_DSALG_HASH: &'static str = "2.5.8.2"; +pub const szOID_DSALG_SIGN: &'static str = "2.5.8.3"; +pub const szOID_DSALG_RSA: &'static str = "2.5.8.1.1"; +pub const szOID_OIW: &'static str = "1.3.14"; +pub const szOID_OIWSEC: &'static str = "1.3.14.3.2"; +pub const szOID_OIWSEC_md4RSA: &'static str = "1.3.14.3.2.2"; +pub const szOID_OIWSEC_md5RSA: &'static str = "1.3.14.3.2.3"; +pub const szOID_OIWSEC_md4RSA2: &'static str = "1.3.14.3.2.4"; +pub const szOID_OIWSEC_desECB: &'static str = "1.3.14.3.2.6"; +pub const szOID_OIWSEC_desCBC: &'static str = "1.3.14.3.2.7"; +pub const szOID_OIWSEC_desOFB: &'static str = "1.3.14.3.2.8"; +pub const szOID_OIWSEC_desCFB: &'static str = "1.3.14.3.2.9"; +pub const szOID_OIWSEC_desMAC: &'static str = "1.3.14.3.2.10"; +pub const szOID_OIWSEC_rsaSign: &'static str = "1.3.14.3.2.11"; +pub const szOID_OIWSEC_dsa: &'static str = "1.3.14.3.2.12"; +pub const szOID_OIWSEC_shaDSA: &'static str = "1.3.14.3.2.13"; +pub const szOID_OIWSEC_mdc2RSA: &'static str = "1.3.14.3.2.14"; +pub const szOID_OIWSEC_shaRSA: &'static str = "1.3.14.3.2.15"; +pub const szOID_OIWSEC_dhCommMod: &'static str = "1.3.14.3.2.16"; +pub const szOID_OIWSEC_desEDE: &'static str = "1.3.14.3.2.17"; +pub const szOID_OIWSEC_sha: &'static str = "1.3.14.3.2.18"; +pub const szOID_OIWSEC_mdc2: &'static str = "1.3.14.3.2.19"; +pub const szOID_OIWSEC_dsaComm: &'static str = "1.3.14.3.2.20"; +pub const szOID_OIWSEC_dsaCommSHA: &'static str = "1.3.14.3.2.21"; +pub const szOID_OIWSEC_rsaXchg: &'static str = "1.3.14.3.2.22"; +pub const szOID_OIWSEC_keyHashSeal: &'static str = "1.3.14.3.2.23"; +pub const szOID_OIWSEC_md2RSASign: &'static str = "1.3.14.3.2.24"; +pub const szOID_OIWSEC_md5RSASign: &'static str = "1.3.14.3.2.25"; +pub const szOID_OIWSEC_sha1: &'static str = "1.3.14.3.2.26"; +pub const szOID_OIWSEC_dsaSHA1: &'static str = "1.3.14.3.2.27"; +pub const szOID_OIWSEC_dsaCommSHA1: &'static str = "1.3.14.3.2.28"; +pub const szOID_OIWSEC_sha1RSASign: &'static str = "1.3.14.3.2.29"; +pub const szOID_OIWDIR: &'static str = "1.3.14.7.2"; +pub const szOID_OIWDIR_CRPT: &'static str = "1.3.14.7.2.1"; +pub const szOID_OIWDIR_HASH: &'static str = "1.3.14.7.2.2"; +pub const szOID_OIWDIR_SIGN: &'static str = "1.3.14.7.2.3"; +pub const szOID_OIWDIR_md2: &'static str = "1.3.14.7.2.2.1"; +pub const szOID_OIWDIR_md2RSA: &'static str = "1.3.14.7.2.3.1"; +pub const szOID_INFOSEC: &'static str = "2.16.840.1.101.2.1"; +pub const szOID_INFOSEC_sdnsSignature: &'static str = "2.16.840.1.101.2.1.1.1"; +pub const szOID_INFOSEC_mosaicSignature: &'static str = "2.16.840.1.101.2.1.1.2"; +pub const szOID_INFOSEC_sdnsConfidentiality: &'static str = "2.16.840.1.101.2.1.1.3"; +pub const szOID_INFOSEC_mosaicConfidentiality: &'static str = "2.16.840.1.101.2.1.1.4"; +pub const szOID_INFOSEC_sdnsIntegrity: &'static str = "2.16.840.1.101.2.1.1.5"; +pub const szOID_INFOSEC_mosaicIntegrity: &'static str = "2.16.840.1.101.2.1.1.6"; +pub const szOID_INFOSEC_sdnsTokenProtection: &'static str = "2.16.840.1.101.2.1.1.7"; +pub const szOID_INFOSEC_mosaicTokenProtection: &'static str = "2.16.840.1.101.2.1.1.8"; +pub const szOID_INFOSEC_sdnsKeyManagement: &'static str = "2.16.840.1.101.2.1.1.9"; +pub const szOID_INFOSEC_mosaicKeyManagement: &'static str = "2.16.840.1.101.2.1.1.10"; +pub const szOID_INFOSEC_sdnsKMandSig: &'static str = "2.16.840.1.101.2.1.1.11"; +pub const szOID_INFOSEC_mosaicKMandSig: &'static str = "2.16.840.1.101.2.1.1.12"; +pub const szOID_INFOSEC_SuiteASignature: &'static str = "2.16.840.1.101.2.1.1.13"; +pub const szOID_INFOSEC_SuiteAConfidentiality: &'static str = "2.16.840.1.101.2.1.1.14"; +pub const szOID_INFOSEC_SuiteAIntegrity: &'static str = "2.16.840.1.101.2.1.1.15"; +pub const szOID_INFOSEC_SuiteATokenProtection: &'static str = "2.16.840.1.101.2.1.1.16"; +pub const szOID_INFOSEC_SuiteAKeyManagement: &'static str = "2.16.840.1.101.2.1.1.17"; +pub const szOID_INFOSEC_SuiteAKMandSig: &'static str = "2.16.840.1.101.2.1.1.18"; +pub const szOID_INFOSEC_mosaicUpdatedSig: &'static str = "2.16.840.1.101.2.1.1.19"; +pub const szOID_INFOSEC_mosaicKMandUpdSig: &'static str = "2.16.840.1.101.2.1.1.20"; +pub const szOID_INFOSEC_mosaicUpdatedInteg: &'static str = "2.16.840.1.101.2.1.1.21"; +pub const szOID_NIST_sha256: &'static str = "2.16.840.1.101.3.4.2.1"; +pub const szOID_NIST_sha384: &'static str = "2.16.840.1.101.3.4.2.2"; +pub const szOID_NIST_sha512: &'static str = "2.16.840.1.101.3.4.2.3"; +STRUCT!{struct CRYPT_OBJID_TABLE { + dwAlgId: DWORD, + pszObjId: LPCSTR, +}} +pub type PCRYPT_OBJID_TABLE = *mut CRYPT_OBJID_TABLE; +STRUCT!{struct CRYPT_HASH_INFO { + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + Hash: CRYPT_HASH_BLOB, +}} +pub type PCRYPT_HASH_INFO = *mut CRYPT_HASH_INFO; +STRUCT!{struct CERT_EXTENSION { + pszObjId: LPSTR, + fCritical: BOOL, + Value: CRYPT_OBJID_BLOB, +}} +pub type PCERT_EXTENSION = *mut CERT_EXTENSION; +pub type PCCERT_EXTENSION = *const CERT_EXTENSION; +STRUCT!{struct CRYPT_ATTRIBUTE_TYPE_VALUE { + pszObjId: LPSTR, + Value: CRYPT_OBJID_BLOB, +}} +pub type PCRYPT_ATTRIBUTE_TYPE_VALUE = *mut CRYPT_ATTRIBUTE_TYPE_VALUE; +STRUCT!{struct CRYPT_ATTRIBUTE { + pszObjId: LPSTR, + cValue: DWORD, + rgValue: PCRYPT_ATTR_BLOB, +}} +pub type PCRYPT_ATTRIBUTE = *mut CRYPT_ATTRIBUTE; +STRUCT!{struct CRYPT_ATTRIBUTES { + cAttr: DWORD, + rgAttr: PCRYPT_ATTRIBUTE, +}} +pub type PCRYPT_ATTRIBUTES = *mut CRYPT_ATTRIBUTES; +STRUCT!{struct CERT_RDN_ATTR { + pszObjId: LPSTR, + dwValueType: DWORD, + Value: CERT_RDN_VALUE_BLOB, +}} +pub type PCERT_RDN_ATTR = *mut CERT_RDN_ATTR; +pub const szOID_COMMON_NAME: &'static str = "2.5.4.3"; +pub const szOID_SUR_NAME: &'static str = "2.5.4.4"; +pub const szOID_DEVICE_SERIAL_NUMBER: &'static str = "2.5.4.5"; +pub const szOID_COUNTRY_NAME: &'static str = "2.5.4.6"; +pub const szOID_LOCALITY_NAME: &'static str = "2.5.4.7"; +pub const szOID_STATE_OR_PROVINCE_NAME: &'static str = "2.5.4.8"; +pub const szOID_STREET_ADDRESS: &'static str = "2.5.4.9"; +pub const szOID_ORGANIZATION_NAME: &'static str = "2.5.4.10"; +pub const szOID_ORGANIZATIONAL_UNIT_NAME: &'static str = "2.5.4.11"; +pub const szOID_TITLE: &'static str = "2.5.4.12"; +pub const szOID_DESCRIPTION: &'static str = "2.5.4.13"; +pub const szOID_SEARCH_GUIDE: &'static str = "2.5.4.14"; +pub const szOID_BUSINESS_CATEGORY: &'static str = "2.5.4.15"; +pub const szOID_POSTAL_ADDRESS: &'static str = "2.5.4.16"; +pub const szOID_POSTAL_CODE: &'static str = "2.5.4.17"; +pub const szOID_POST_OFFICE_BOX: &'static str = "2.5.4.18"; +pub const szOID_PHYSICAL_DELIVERY_OFFICE_NAME: &'static str = "2.5.4.19"; +pub const szOID_TELEPHONE_NUMBER: &'static str = "2.5.4.20"; +pub const szOID_TELEX_NUMBER: &'static str = "2.5.4.21"; +pub const szOID_TELETEXT_TERMINAL_IDENTIFIER: &'static str = "2.5.4.22"; +pub const szOID_FACSIMILE_TELEPHONE_NUMBER: &'static str = "2.5.4.23"; +pub const szOID_X21_ADDRESS: &'static str = "2.5.4.24"; +pub const szOID_INTERNATIONAL_ISDN_NUMBER: &'static str = "2.5.4.25"; +pub const szOID_REGISTERED_ADDRESS: &'static str = "2.5.4.26"; +pub const szOID_DESTINATION_INDICATOR: &'static str = "2.5.4.27"; +pub const szOID_PREFERRED_DELIVERY_METHOD: &'static str = "2.5.4.28"; +pub const szOID_PRESENTATION_ADDRESS: &'static str = "2.5.4.29"; +pub const szOID_SUPPORTED_APPLICATION_CONTEXT: &'static str = "2.5.4.30"; +pub const szOID_MEMBER: &'static str = "2.5.4.31"; +pub const szOID_OWNER: &'static str = "2.5.4.32"; +pub const szOID_ROLE_OCCUPANT: &'static str = "2.5.4.33"; +pub const szOID_SEE_ALSO: &'static str = "2.5.4.34"; +pub const szOID_USER_PASSWORD: &'static str = "2.5.4.35"; +pub const szOID_USER_CERTIFICATE: &'static str = "2.5.4.36"; +pub const szOID_CA_CERTIFICATE: &'static str = "2.5.4.37"; +pub const szOID_AUTHORITY_REVOCATION_LIST: &'static str = "2.5.4.38"; +pub const szOID_CERTIFICATE_REVOCATION_LIST: &'static str = "2.5.4.39"; +pub const szOID_CROSS_CERTIFICATE_PAIR: &'static str = "2.5.4.40"; +pub const szOID_GIVEN_NAME: &'static str = "2.5.4.42"; +pub const szOID_INITIALS: &'static str = "2.5.4.43"; +pub const szOID_DN_QUALIFIER: &'static str = "2.5.4.46"; +pub const szOID_DOMAIN_COMPONENT: &'static str = "0.9.2342.19200300.100.1.25"; +pub const szOID_PKCS_12_FRIENDLY_NAME_ATTR: &'static str = "1.2.840.113549.1.9.20"; +pub const szOID_PKCS_12_LOCAL_KEY_ID: &'static str = "1.2.840.113549.1.9.21"; +pub const szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR: &'static str = "1.3.6.1.4.1.311.17.1"; +pub const szOID_LOCAL_MACHINE_KEYSET: &'static str = "1.3.6.1.4.1.311.17.2"; +pub const szOID_PKCS_12_EXTENDED_ATTRIBUTES: &'static str = "1.3.6.1.4.1.311.17.3"; +pub const szOID_PKCS_12_PROTECTED_PASSWORD_SECRET_BAG_TYPE_ID: &'static str + = "1.3.6.1.4.1.311.17.4"; +pub const szOID_KEYID_RDN: &'static str = "1.3.6.1.4.1.311.10.7.1"; +pub const szOID_EV_RDN_LOCALE: &'static str = "1.3.6.1.4.1.311.60.2.1.1"; +pub const szOID_EV_RDN_STATE_OR_PROVINCE: &'static str = "1.3.6.1.4.1.311.60.2.1.2"; +pub const szOID_EV_RDN_COUNTRY: &'static str = "1.3.6.1.4.1.311.60.2.1.3"; +pub const CERT_RDN_ANY_TYPE: DWORD = 0; +pub const CERT_RDN_ENCODED_BLOB: DWORD = 1; +pub const CERT_RDN_OCTET_STRING: DWORD = 2; +pub const CERT_RDN_NUMERIC_STRING: DWORD = 3; +pub const CERT_RDN_PRINTABLE_STRING: DWORD = 4; +pub const CERT_RDN_TELETEX_STRING: DWORD = 5; +pub const CERT_RDN_T61_STRING: DWORD = 5; +pub const CERT_RDN_VIDEOTEX_STRING: DWORD = 6; +pub const CERT_RDN_IA5_STRING: DWORD = 7; +pub const CERT_RDN_GRAPHIC_STRING: DWORD = 8; +pub const CERT_RDN_VISIBLE_STRING: DWORD = 9; +pub const CERT_RDN_ISO646_STRING: DWORD = 9; +pub const CERT_RDN_GENERAL_STRING: DWORD = 10; +pub const CERT_RDN_UNIVERSAL_STRING: DWORD = 11; +pub const CERT_RDN_INT4_STRING: DWORD = 11; +pub const CERT_RDN_BMP_STRING: DWORD = 12; +pub const CERT_RDN_UNICODE_STRING: DWORD = 12; +pub const CERT_RDN_UTF8_STRING: DWORD = 13; +pub const CERT_RDN_TYPE_MASK: DWORD = 0x000000FF; +pub const CERT_RDN_FLAGS_MASK: DWORD = 0xFF000000; +pub const CERT_RDN_ENABLE_T61_UNICODE_FLAG: DWORD = 0x80000000; +pub const CERT_RDN_ENABLE_UTF8_UNICODE_FLAG: DWORD = 0x20000000; +pub const CERT_RDN_FORCE_UTF8_UNICODE_FLAG: DWORD = 0x10000000; +pub const CERT_RDN_DISABLE_CHECK_TYPE_FLAG: DWORD = 0x40000000; +pub const CERT_RDN_DISABLE_IE4_UTF8_FLAG: DWORD = 0x01000000; +pub const CERT_RDN_ENABLE_PUNYCODE_FLAG: DWORD = 0x02000000; +#[inline] +pub fn IS_CERT_RDN_CHAR_STRING(X: DWORD) -> bool { + (X & CERT_RDN_TYPE_MASK) >= CERT_RDN_NUMERIC_STRING +} +STRUCT!{struct CERT_RDN { + cRDNAttr: DWORD, + rgRDNAttr: PCERT_RDN_ATTR, +}} +pub type PCERT_RDN = *mut CERT_RDN; +STRUCT!{struct CERT_NAME_INFO { + cRDN: DWORD, + rgRDN: PCERT_RDN, +}} +pub type PCERT_NAME_INFO = *mut CERT_NAME_INFO; +STRUCT!{struct CERT_NAME_VALUE { + dwValueType: DWORD, + Value: CERT_RDN_VALUE_BLOB, +}} +pub type PCERT_NAME_VALUE = *mut CERT_NAME_VALUE; +STRUCT!{struct CERT_PUBLIC_KEY_INFO { + Algorithm: CRYPT_ALGORITHM_IDENTIFIER, + PublicKey: CRYPT_BIT_BLOB, +}} +pub type PCERT_PUBLIC_KEY_INFO = *mut CERT_PUBLIC_KEY_INFO; +pub const CERT_RSA_PUBLIC_KEY_OBJID: &'static str = szOID_RSA_RSA; +pub const CERT_DEFAULT_OID_PUBLIC_KEY_SIGN: &'static str = szOID_RSA_RSA; +pub const CERT_DEFAULT_OID_PUBLIC_KEY_XCHG: &'static str = szOID_RSA_RSA; +STRUCT!{struct CRYPT_ECC_PRIVATE_KEY_INFO { + dwVersion: DWORD, + PrivateKey: CRYPT_DER_BLOB, + szCurveOid: LPSTR, + PublicKey: CRYPT_BIT_BLOB, +}} +pub type PCRYPT_ECC_PRIVATE_KEY_INFO = *mut CRYPT_ECC_PRIVATE_KEY_INFO; +pub const CRYPT_ECC_PRIVATE_KEY_INFO_v1: DWORD = 1; +STRUCT!{struct CRYPT_PRIVATE_KEY_INFO { + Version: DWORD, + Algorithm: CRYPT_ALGORITHM_IDENTIFIER, + PrivateKey: CRYPT_DER_BLOB, + pAttributes: PCRYPT_ATTRIBUTES, +}} +pub type PCRYPT_PRIVATE_KEY_INFO = *mut CRYPT_PRIVATE_KEY_INFO; +STRUCT!{struct CRYPT_ENCRYPTED_PRIVATE_KEY_INFO { + EncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + EncryptedPrivateKey: CRYPT_DATA_BLOB, +}} +pub type PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO = *mut CRYPT_ENCRYPTED_PRIVATE_KEY_INFO; +FN!{stdcall PCRYPT_DECRYPT_PRIVATE_KEY_FUNC( + Algorithm: CRYPT_ALGORITHM_IDENTIFIER, + EncryptedPrivateKey: CRYPT_DATA_BLOB, + pbClearTextKey: *mut BYTE, + pcbClearTextKey: *mut DWORD, + pVoidDecryptFunc: LPVOID, +) -> BOOL} +FN!{stdcall PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC( + Algorithm: *mut CRYPT_ALGORITHM_IDENTIFIER, + pClearTextPrivateKey: *mut CRYPT_DATA_BLOB, + pbEncryptedKey: *mut BYTE, + pcbEncryptedKey: *mut DWORD, + pVoidEncryptFunc: LPVOID, +) -> BOOL} +FN!{stdcall PCRYPT_RESOLVE_HCRYPTPROV_FUNC( + pPrivateKeyInfo: *mut CRYPT_PRIVATE_KEY_INFO, + phCryptProv: *mut HCRYPTPROV, + pVoidResolveFunc: LPVOID, +) -> BOOL} +STRUCT!{struct CRYPT_PKCS8_IMPORT_PARAMS { + PrivateKey: CRYPT_DIGEST_BLOB, + pResolvehCryptProvFunc: PCRYPT_RESOLVE_HCRYPTPROV_FUNC, + pVoidResolveFunc: LPVOID, + pDecryptPrivateKeyFunc: PCRYPT_DECRYPT_PRIVATE_KEY_FUNC, + pVoidDecryptFunc: LPVOID, +}} +pub type PCRYPT_PKCS8_IMPORT_PARAMS = *mut CRYPT_PKCS8_IMPORT_PARAMS; +pub type CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS = CRYPT_PKCS8_IMPORT_PARAMS; +pub type PPCRYPT_PRIVATE_KEY_BLOB_AND_PARAMS = *mut CRYPT_PKCS8_IMPORT_PARAMS; +STRUCT!{struct CRYPT_PKCS8_EXPORT_PARAMS { + hCryptProv: HCRYPTPROV, + dwKeySpec: DWORD, + pszPrivateKeyObjId: LPSTR, + pEncryptPrivateKeyFunc: PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC, + pVoidEncryptFunc: LPVOID, +}} +pub type PCRYPT_PKCS8_EXPORT_PARAMS = *mut CRYPT_PKCS8_EXPORT_PARAMS; +STRUCT!{struct CERT_INFO { + dwVersion: DWORD, + SerialNumber: CRYPT_INTEGER_BLOB, + SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + Issuer: CERT_NAME_BLOB, + NotBefore: FILETIME, + NotAfter: FILETIME, + Subject: CERT_NAME_BLOB, + SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO, + IssuerUniqueId: CRYPT_BIT_BLOB, + SubjectUniqueId: CRYPT_BIT_BLOB, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type PCERT_INFO = *mut CERT_INFO; +pub const CERT_V1: DWORD = 0; +pub const CERT_V2: DWORD = 1; +pub const CERT_V3: DWORD = 2; +pub const CERT_INFO_VERSION_FLAG: DWORD = 1; +pub const CERT_INFO_SERIAL_NUMBER_FLAG: DWORD = 2; +pub const CERT_INFO_SIGNATURE_ALGORITHM_FLAG: DWORD = 3; +pub const CERT_INFO_ISSUER_FLAG: DWORD = 4; +pub const CERT_INFO_NOT_BEFORE_FLAG: DWORD = 5; +pub const CERT_INFO_NOT_AFTER_FLAG: DWORD = 6; +pub const CERT_INFO_SUBJECT_FLAG: DWORD = 7; +pub const CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG: DWORD = 8; +pub const CERT_INFO_ISSUER_UNIQUE_ID_FLAG: DWORD = 9; +pub const CERT_INFO_SUBJECT_UNIQUE_ID_FLAG: DWORD = 10; +pub const CERT_INFO_EXTENSION_FLAG: DWORD = 11; +STRUCT!{struct CRL_ENTRY { + SerialNumber: CRYPT_INTEGER_BLOB, + RevocationDate: FILETIME, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type PCRL_ENTRY = *mut CRL_ENTRY; +STRUCT!{struct CRL_INFO { + dwVersion: DWORD, + SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + Issuer: CERT_NAME_BLOB, + ThisUpdate: FILETIME, + NextUpdate: FILETIME, + cCRLEntry: DWORD, + rgCRLEntry: PCRL_ENTRY, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type PCRL_INFO = *mut CRL_INFO; +pub const CRL_V1: DWORD = 0; +pub const CRL_V2: DWORD = 1; +pub const CERT_BUNDLE_CERTIFICATE: DWORD = 0; +pub const CERT_BUNDLE_CRL: DWORD = 1; +STRUCT!{struct CERT_OR_CRL_BLOB { + dwChoice: DWORD, + cbEncoded: DWORD, + pbEncoded: *mut BYTE, +}} +pub type PCERT_OR_CRL_BLOB = *mut CERT_OR_CRL_BLOB; +STRUCT!{struct CERT_OR_CRL_BUNDLE { + cItem: DWORD, + rgItem: PCERT_OR_CRL_BLOB, +}} +pub type PCERT_OR_CRL_BUNDLE = *mut CERT_OR_CRL_BUNDLE; +STRUCT!{struct CERT_REQUEST_INFO { + dwVersion: DWORD, + Subject: CERT_NAME_BLOB, + SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO, + cAttribute: DWORD, + rgAttribute: PCRYPT_ATTRIBUTE, +}} +pub type PCERT_REQUEST_INFO = *mut CERT_REQUEST_INFO; +pub const CERT_REQUEST_V1: DWORD = 0; +STRUCT!{struct CERT_KEYGEN_REQUEST_INFO { + dwVersion: DWORD, + SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO, + pwszChallengeString: LPWSTR, +}} +pub type PCERT_KEYGEN_REQUEST_INFO = *mut CERT_KEYGEN_REQUEST_INFO; +pub const CERT_KEYGEN_REQUEST_V1: DWORD = 0; +STRUCT!{struct CERT_SIGNED_CONTENT_INFO { + ToBeSigned: CRYPT_DER_BLOB, + SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + Signature: CRYPT_BIT_BLOB, +}} +pub type PCERT_SIGNED_CONTENT_INFO = *mut CERT_SIGNED_CONTENT_INFO; +STRUCT!{struct CTL_USAGE { + cUsageIdentifier: DWORD, + rgpszUsageIdentifier: *mut LPSTR, +}} +pub type PCTL_USAGE = *mut CTL_USAGE; +pub type CERT_ENHKEY_USAGE = CTL_USAGE; +pub type PCERT_ENHKEY_USAGE = *mut CERT_ENHKEY_USAGE; +pub type PCCTL_USAGE = *const CTL_USAGE; +pub type PCCERT_ENHKEY_USAGE = *const CERT_ENHKEY_USAGE; +STRUCT!{struct CTL_ENTRY { + SubjectIdentifier: CRYPT_DATA_BLOB, + cAttribute: DWORD, + rgAttribute: PCRYPT_ATTRIBUTE, +}} +pub type PCTL_ENTRY = *mut CTL_ENTRY; +STRUCT!{struct CTL_INFO { + dwVersion: DWORD, + SubjectUsage: CTL_USAGE, + ListIdentifier: CRYPT_DATA_BLOB, + SequenceNumber: CRYPT_INTEGER_BLOB, + ThisUpdate: FILETIME, + NextUpdate: FILETIME, + SubjectAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + cCTLEntry: DWORD, + rgCTLEntry: PCTL_ENTRY, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type PCTL_INFO = *mut CTL_INFO; +pub const CTL_V1: DWORD = 0; +STRUCT!{struct CRYPT_TIME_STAMP_REQUEST_INFO { + pszTimeStampAlgorithm: LPSTR, + pszContentType: LPSTR, + Content: CRYPT_OBJID_BLOB, + cAttribute: DWORD, + rgAttribute: PCRYPT_ATTRIBUTE, +}} +pub type PCRYPT_TIME_STAMP_REQUEST_INFO = *mut CRYPT_TIME_STAMP_REQUEST_INFO; +STRUCT!{struct CRYPT_ENROLLMENT_NAME_VALUE_PAIR { + pwszName: LPWSTR, + pwszValue: LPWSTR, +}} +pub type PCRYPT_ENROLLMENT_NAME_VALUE_PAIR = *mut CRYPT_ENROLLMENT_NAME_VALUE_PAIR; +STRUCT!{struct CRYPT_CSP_PROVIDER { + dwKeySpec: DWORD, + pwszProviderName: LPWSTR, + Signature: CRYPT_BIT_BLOB, +}} +pub type PCRYPT_CSP_PROVIDER = *mut CRYPT_CSP_PROVIDER; +pub const CERT_ENCODING_TYPE_MASK: DWORD = 0x0000FFFF; +pub const CMSG_ENCODING_TYPE_MASK: DWORD = 0xFFFF0000; +#[inline] +pub fn GET_CERT_ENCODING_TYPE(X: DWORD) -> DWORD { + X & CERT_ENCODING_TYPE_MASK +} +#[inline] +pub fn GET_CMSG_ENCODING_TYPE(X: DWORD) -> DWORD { + X & CMSG_ENCODING_TYPE_MASK +} +pub const CRYPT_ASN_ENCODING: DWORD = 0x00000001; +pub const CRYPT_NDR_ENCODING: DWORD = 0x00000002; +pub const X509_ASN_ENCODING: DWORD = 0x00000001; +pub const X509_NDR_ENCODING: DWORD = 0x00000002; +pub const PKCS_7_ASN_ENCODING: DWORD = 0x00010000; +pub const PKCS_7_NDR_ENCODING: DWORD = 0x00020000; +extern "system" { + pub fn CryptFormatObject( + dwCertEncodingType: DWORD, + dwFormatType: DWORD, + dwFormatStrType: DWORD, + pFormatStruct: *mut c_void, + lpszStructType: LPCSTR, + pbEncoded: *const BYTE, + cbEncoded: DWORD, + pbFormat: *mut c_void, + pcbFormat: *mut DWORD, + ) -> BOOL; +} +pub const CRYPT_FORMAT_STR_MULTI_LINE: DWORD = 0x0001; +pub const CRYPT_FORMAT_STR_NO_HEX: DWORD = 0x0010; +pub const CRYPT_FORMAT_SIMPLE: DWORD = 0x0001; +pub const CRYPT_FORMAT_X509: DWORD = 0x0002; +pub const CRYPT_FORMAT_OID: DWORD = 0x0004; +pub const CRYPT_FORMAT_RDN_SEMICOLON: DWORD = 0x0100; +pub const CRYPT_FORMAT_RDN_CRLF: DWORD = 0x0200; +pub const CRYPT_FORMAT_RDN_UNQUOTE: DWORD = 0x0400; +pub const CRYPT_FORMAT_RDN_REVERSE: DWORD = 0x0800; +pub const CRYPT_FORMAT_COMMA: DWORD = 0x1000; +pub const CRYPT_FORMAT_SEMICOLON: DWORD = CRYPT_FORMAT_RDN_SEMICOLON; +pub const CRYPT_FORMAT_CRLF: DWORD = CRYPT_FORMAT_RDN_CRLF; +FN!{stdcall PFN_CRYPT_ALLOC( + cbSize: size_t, +) -> LPVOID} +FN!{stdcall PFN_CRYPT_FREE( + pv: LPVOID, +) -> ()} +STRUCT!{struct CRYPT_ENCODE_PARA { + cbSize: DWORD, + pfnAlloc: PFN_CRYPT_ALLOC, + pfnFree: PFN_CRYPT_FREE, +}} +pub type PCRYPT_ENCODE_PARA = *mut CRYPT_ENCODE_PARA; +extern "system" { + pub fn CryptEncodeObjectEx( + dwCertEncodingType: DWORD, + lpszStructType: LPCSTR, + pvStructInfo: *const c_void, + dwFlags: DWORD, + pEncodePara: PCRYPT_ENCODE_PARA, + pvEncoded: *mut c_void, + pcbEncoded: *mut DWORD, + ) -> BOOL; + pub fn CryptEncodeObject( + dwCertEncodingType: DWORD, + lpszStructType: LPCSTR, + pvStructInfo: *const c_void, + pbEncoded: *mut BYTE, + pcbEncoded: *mut DWORD, + ) -> BOOL; +} +pub const CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG: DWORD = 0x8; +pub const CRYPT_ENCODE_ALLOC_FLAG: DWORD = 0x8000; +pub const CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG: DWORD + = CERT_RDN_ENABLE_T61_UNICODE_FLAG; +pub const CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG: DWORD + = CERT_RDN_ENABLE_UTF8_UNICODE_FLAG; +pub const CRYPT_UNICODE_NAME_ENCODE_FORCE_UTF8_UNICODE_FLAG: DWORD + = CERT_RDN_FORCE_UTF8_UNICODE_FLAG; +pub const CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG: DWORD + = CERT_RDN_DISABLE_CHECK_TYPE_FLAG; +pub const CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG: DWORD = 0x10000; +pub const CRYPT_ENCODE_ENABLE_PUNYCODE_FLAG: DWORD = 0x20000; +pub const CRYPT_ENCODE_ENABLE_UTF8PERCENT_FLAG: DWORD = 0x40000; +pub const CRYPT_ENCODE_ENABLE_IA5CONVERSION_FLAG: DWORD = CRYPT_ENCODE_ENABLE_PUNYCODE_FLAG + | CRYPT_ENCODE_ENABLE_UTF8PERCENT_FLAG; +STRUCT!{struct CRYPT_DECODE_PARA { + cbSize: DWORD, + pfnAlloc: PFN_CRYPT_ALLOC, + pfnFree: PFN_CRYPT_FREE, +}} +pub type PCRYPT_DECODE_PARA = *mut CRYPT_DECODE_PARA; +extern "system" { + pub fn CryptDecodeObjectEx( + dwCertEncodingType: DWORD, + lpszStructType: LPCSTR, + pbEncoded: *const BYTE, + cbEncoded: DWORD, + dwFlags: DWORD, + pDecodePara: PCRYPT_DECODE_PARA, + pvStructInfo: *mut c_void, + pcbStructInfo: *mut DWORD, + ) -> BOOL; + pub fn CryptDecodeObject( + dwCertEncodingType: DWORD, + lpszStructType: LPCSTR, + pbEncoded: *const BYTE, + cbEncoded: DWORD, + dwFlags: DWORD, + pvStructInfo: *mut c_void, + pcbStructInfo: *mut DWORD, + ) -> BOOL; +} +pub const CRYPT_DECODE_NOCOPY_FLAG: DWORD = 0x1; +pub const CRYPT_DECODE_TO_BE_SIGNED_FLAG: DWORD = 0x2; +pub const CRYPT_DECODE_SHARE_OID_STRING_FLAG: DWORD = 0x4; +pub const CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG: DWORD = 0x8; +pub const CRYPT_DECODE_ALLOC_FLAG: DWORD = 0x8000; +pub const CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG: DWORD + = CERT_RDN_DISABLE_IE4_UTF8_FLAG; +pub const CRYPT_DECODE_ENABLE_PUNYCODE_FLAG: DWORD = 0x02000000; +pub const CRYPT_DECODE_ENABLE_UTF8PERCENT_FLAG: DWORD = 0x04000000; +pub const CRYPT_DECODE_ENABLE_IA5CONVERSION_FLAG: DWORD = CRYPT_DECODE_ENABLE_PUNYCODE_FLAG + | CRYPT_DECODE_ENABLE_UTF8PERCENT_FLAG; +pub const CRYPT_ENCODE_DECODE_NONE: LPCSTR = 0 as LPCSTR; +pub const X509_CERT: LPCSTR = 1 as LPCSTR; +pub const X509_CERT_TO_BE_SIGNED: LPCSTR = 2 as LPCSTR; +pub const X509_CERT_CRL_TO_BE_SIGNED: LPCSTR = 3 as LPCSTR; +pub const X509_CERT_REQUEST_TO_BE_SIGNED: LPCSTR = 4 as LPCSTR; +pub const X509_EXTENSIONS: LPCSTR = 5 as LPCSTR; +pub const X509_NAME_VALUE: LPCSTR = 6 as LPCSTR; +pub const X509_NAME: LPCSTR = 7 as LPCSTR; +pub const X509_PUBLIC_KEY_INFO: LPCSTR = 8 as LPCSTR; +pub const X509_AUTHORITY_KEY_ID: LPCSTR = 9 as LPCSTR; +pub const X509_KEY_ATTRIBUTES: LPCSTR = 10 as LPCSTR; +pub const X509_KEY_USAGE_RESTRICTION: LPCSTR = 11 as LPCSTR; +pub const X509_ALTERNATE_NAME: LPCSTR = 12 as LPCSTR; +pub const X509_BASIC_CONSTRAINTS: LPCSTR = 13 as LPCSTR; +pub const X509_KEY_USAGE: LPCSTR = 14 as LPCSTR; +pub const X509_BASIC_CONSTRAINTS2: LPCSTR = 15 as LPCSTR; +pub const X509_CERT_POLICIES: LPCSTR = 16 as LPCSTR; +pub const PKCS_UTC_TIME: LPCSTR = 17 as LPCSTR; +pub const PKCS_TIME_REQUEST: LPCSTR = 18 as LPCSTR; +pub const RSA_CSP_PUBLICKEYBLOB: LPCSTR = 19 as LPCSTR; +pub const X509_UNICODE_NAME: LPCSTR = 20 as LPCSTR; +pub const X509_KEYGEN_REQUEST_TO_BE_SIGNED: LPCSTR = 21 as LPCSTR; +pub const PKCS_ATTRIBUTE: LPCSTR = 22 as LPCSTR; +pub const PKCS_CONTENT_INFO_SEQUENCE_OF_ANY: LPCSTR = 23 as LPCSTR; +pub const X509_UNICODE_NAME_VALUE: LPCSTR = 24 as LPCSTR; +pub const X509_ANY_STRING: LPCSTR = X509_NAME_VALUE; +pub const X509_UNICODE_ANY_STRING: LPCSTR = X509_UNICODE_NAME_VALUE; +pub const X509_OCTET_STRING: LPCSTR = 25 as LPCSTR; +pub const X509_BITS: LPCSTR = 26 as LPCSTR; +pub const X509_INTEGER: LPCSTR = 27 as LPCSTR; +pub const X509_MULTI_BYTE_INTEGER: LPCSTR = 28 as LPCSTR; +pub const X509_ENUMERATED: LPCSTR = 29 as LPCSTR; +pub const X509_CHOICE_OF_TIME: LPCSTR = 30 as LPCSTR; +pub const X509_AUTHORITY_KEY_ID2: LPCSTR = 31 as LPCSTR; +pub const X509_AUTHORITY_INFO_ACCESS: LPCSTR = 32 as LPCSTR; +pub const X509_SUBJECT_INFO_ACCESS: LPCSTR = X509_AUTHORITY_INFO_ACCESS; +pub const X509_CRL_REASON_CODE: LPCSTR = X509_ENUMERATED; +pub const PKCS_CONTENT_INFO: LPCSTR = 33 as LPCSTR; +pub const X509_SEQUENCE_OF_ANY: LPCSTR = 34 as LPCSTR; +pub const X509_CRL_DIST_POINTS: LPCSTR = 35 as LPCSTR; +pub const X509_ENHANCED_KEY_USAGE: LPCSTR = 36 as LPCSTR; +pub const PKCS_CTL: LPCSTR = 37 as LPCSTR; +pub const X509_MULTI_BYTE_UINT: LPCSTR = 38 as LPCSTR; +pub const X509_DSS_PUBLICKEY: LPCSTR = X509_MULTI_BYTE_UINT; +pub const X509_DSS_PARAMETERS: LPCSTR = 39 as LPCSTR; +pub const X509_DSS_SIGNATURE: LPCSTR = 40 as LPCSTR; +pub const PKCS_RC2_CBC_PARAMETERS: LPCSTR = 41 as LPCSTR; +pub const PKCS_SMIME_CAPABILITIES: LPCSTR = 42 as LPCSTR; +pub const X509_QC_STATEMENTS_EXT: LPCSTR = 42 as LPCSTR; +pub const PKCS_RSA_PRIVATE_KEY: LPCSTR = 43 as LPCSTR; +pub const PKCS_PRIVATE_KEY_INFO: LPCSTR = 44 as LPCSTR; +pub const PKCS_ENCRYPTED_PRIVATE_KEY_INFO: LPCSTR = 45 as LPCSTR; +pub const X509_PKIX_POLICY_QUALIFIER_USERNOTICE: LPCSTR = 46 as LPCSTR; +pub const X509_DH_PUBLICKEY: LPCSTR = X509_MULTI_BYTE_UINT; +pub const X509_DH_PARAMETERS: LPCSTR = 47 as LPCSTR; +pub const PKCS_ATTRIBUTES: LPCSTR = 48 as LPCSTR; +pub const PKCS_SORTED_CTL: LPCSTR = 49 as LPCSTR; +pub const X509_ECC_SIGNATURE: LPCSTR = 47 as LPCSTR; +pub const X942_DH_PARAMETERS: LPCSTR = 50 as LPCSTR; +pub const X509_BITS_WITHOUT_TRAILING_ZEROES: LPCSTR = 51 as LPCSTR; +pub const X942_OTHER_INFO: LPCSTR = 52 as LPCSTR; +pub const X509_CERT_PAIR: LPCSTR = 53 as LPCSTR; +pub const X509_ISSUING_DIST_POINT: LPCSTR = 54 as LPCSTR; +pub const X509_NAME_CONSTRAINTS: LPCSTR = 55 as LPCSTR; +pub const X509_POLICY_MAPPINGS: LPCSTR = 56 as LPCSTR; +pub const X509_POLICY_CONSTRAINTS: LPCSTR = 57 as LPCSTR; +pub const X509_CROSS_CERT_DIST_POINTS: LPCSTR = 58 as LPCSTR; +pub const CMC_DATA: LPCSTR = 59 as LPCSTR; +pub const CMC_RESPONSE: LPCSTR = 60 as LPCSTR; +pub const CMC_STATUS: LPCSTR = 61 as LPCSTR; +pub const CMC_ADD_EXTENSIONS: LPCSTR = 62 as LPCSTR; +pub const CMC_ADD_ATTRIBUTES: LPCSTR = 63 as LPCSTR; +pub const X509_CERTIFICATE_TEMPLATE: LPCSTR = 64 as LPCSTR; +pub const OCSP_SIGNED_REQUEST: LPCSTR = 65 as LPCSTR; +pub const OCSP_REQUEST: LPCSTR = 66 as LPCSTR; +pub const OCSP_RESPONSE: LPCSTR = 67 as LPCSTR; +pub const OCSP_BASIC_SIGNED_RESPONSE: LPCSTR = 68 as LPCSTR; +pub const OCSP_BASIC_RESPONSE: LPCSTR = 69 as LPCSTR; +pub const X509_LOGOTYPE_EXT: LPCSTR = 70 as LPCSTR; +pub const X509_BIOMETRIC_EXT: LPCSTR = 71 as LPCSTR; +pub const CNG_RSA_PUBLIC_KEY_BLOB: LPCSTR = 72 as LPCSTR; +pub const X509_OBJECT_IDENTIFIER: LPCSTR = 73 as LPCSTR; +pub const X509_ALGORITHM_IDENTIFIER: LPCSTR = 74 as LPCSTR; +pub const PKCS_RSA_SSA_PSS_PARAMETERS: LPCSTR = 75 as LPCSTR; +pub const PKCS_RSAES_OAEP_PARAMETERS: LPCSTR = 76 as LPCSTR; +pub const ECC_CMS_SHARED_INFO: LPCSTR = 77 as LPCSTR; +pub const TIMESTAMP_REQUEST: LPCSTR = 78 as LPCSTR; +pub const TIMESTAMP_RESPONSE: LPCSTR = 79 as LPCSTR; +pub const TIMESTAMP_INFO: LPCSTR = 80 as LPCSTR; +pub const X509_CERT_BUNDLE: LPCSTR = 81 as LPCSTR; +pub const X509_ECC_PRIVATE_KEY: LPCSTR = 82 as LPCSTR; +pub const CNG_RSA_PRIVATE_KEY_BLOB: LPCSTR = 83 as LPCSTR; +pub const X509_SUBJECT_DIR_ATTRS: LPCSTR = 84 as LPCSTR; +pub const X509_ECC_PARAMETERS: LPCSTR = 85 as LPCSTR; +pub const PKCS7_SIGNER_INFO: LPCSTR = 500 as LPCSTR; +pub const CMS_SIGNER_INFO: LPCSTR = 501 as LPCSTR; +pub const szOID_AUTHORITY_KEY_IDENTIFIER: &'static str = "2.5.29.1"; +pub const szOID_KEY_ATTRIBUTES: &'static str = "2.5.29.2"; +pub const szOID_CERT_POLICIES_95: &'static str = "2.5.29.3"; +pub const szOID_KEY_USAGE_RESTRICTION: &'static str = "2.5.29.4"; +pub const szOID_SUBJECT_ALT_NAME: &'static str = "2.5.29.7"; +pub const szOID_ISSUER_ALT_NAME: &'static str = "2.5.29.8"; +pub const szOID_BASIC_CONSTRAINTS: &'static str = "2.5.29.10"; +pub const szOID_KEY_USAGE: &'static str = "2.5.29.15"; +pub const szOID_PRIVATEKEY_USAGE_PERIOD: &'static str = "2.5.29.16"; +pub const szOID_BASIC_CONSTRAINTS2: &'static str = "2.5.29.19"; +pub const szOID_CERT_POLICIES: &'static str = "2.5.29.32"; +pub const szOID_ANY_CERT_POLICY: &'static str = "2.5.29.32.0"; +pub const szOID_INHIBIT_ANY_POLICY: &'static str = "2.5.29.54"; +pub const szOID_AUTHORITY_KEY_IDENTIFIER2: &'static str = "2.5.29.35"; +pub const szOID_SUBJECT_KEY_IDENTIFIER: &'static str = "2.5.29.14"; +pub const szOID_SUBJECT_ALT_NAME2: &'static str = "2.5.29.17"; +pub const szOID_ISSUER_ALT_NAME2: &'static str = "2.5.29.18"; +pub const szOID_CRL_REASON_CODE: &'static str = "2.5.29.21"; +pub const szOID_REASON_CODE_HOLD: &'static str = "2.5.29.23"; +pub const szOID_CRL_DIST_POINTS: &'static str = "2.5.29.31"; +pub const szOID_ENHANCED_KEY_USAGE: &'static str = "2.5.29.37"; +pub const szOID_ANY_ENHANCED_KEY_USAGE: &'static str = "2.5.29.37.0"; +pub const szOID_CRL_NUMBER: &'static str = "2.5.29.20"; +pub const szOID_DELTA_CRL_INDICATOR: &'static str = "2.5.29.27"; +pub const szOID_ISSUING_DIST_POINT: &'static str = "2.5.29.28"; +pub const szOID_FRESHEST_CRL: &'static str = "2.5.29.46"; +pub const szOID_NAME_CONSTRAINTS: &'static str = "2.5.29.30"; +pub const szOID_POLICY_MAPPINGS: &'static str = "2.5.29.33"; +pub const szOID_LEGACY_POLICY_MAPPINGS: &'static str = "2.5.29.5"; +pub const szOID_POLICY_CONSTRAINTS: &'static str = "2.5.29.36"; +pub const szOID_RENEWAL_CERTIFICATE: &'static str = "1.3.6.1.4.1.311.13.1"; +pub const szOID_ENROLLMENT_NAME_VALUE_PAIR: &'static str = "1.3.6.1.4.1.311.13.2.1"; +pub const szOID_ENROLLMENT_CSP_PROVIDER: &'static str = "1.3.6.1.4.1.311.13.2.2"; +pub const szOID_OS_VERSION: &'static str = "1.3.6.1.4.1.311.13.2.3"; +pub const szOID_ENROLLMENT_AGENT: &'static str = "1.3.6.1.4.1.311.20.2.1"; +pub const szOID_PKIX: &'static str = "1.3.6.1.5.5.7"; +pub const szOID_PKIX_PE: &'static str = "1.3.6.1.5.5.7.1"; +pub const szOID_AUTHORITY_INFO_ACCESS: &'static str = "1.3.6.1.5.5.7.1.1"; +pub const szOID_SUBJECT_INFO_ACCESS: &'static str = "1.3.6.1.5.5.7.1.11"; +pub const szOID_BIOMETRIC_EXT: &'static str = "1.3.6.1.5.5.7.1.2"; +pub const szOID_QC_STATEMENTS_EXT: &'static str = "1.3.6.1.5.5.7.1.3"; +pub const szOID_LOGOTYPE_EXT: &'static str = "1.3.6.1.5.5.7.1.12"; +pub const szOID_TLS_FEATURES_EXT: &'static str = "1.3.6.1.5.5.7.1.24"; +pub const szOID_CERT_EXTENSIONS: &'static str = "1.3.6.1.4.1.311.2.1.14"; +pub const szOID_NEXT_UPDATE_LOCATION: &'static str = "1.3.6.1.4.1.311.10.2"; +pub const szOID_REMOVE_CERTIFICATE: &'static str = "1.3.6.1.4.1.311.10.8.1"; +pub const szOID_CROSS_CERT_DIST_POINTS: &'static str = "1.3.6.1.4.1.311.10.9.1"; +pub const szOID_CTL: &'static str = "1.3.6.1.4.1.311.10.1"; +pub const szOID_SORTED_CTL: &'static str = "1.3.6.1.4.1.311.10.1.1"; +pub const szOID_SERIALIZED: &'static str = "1.3.6.1.4.1.311.10.3.3.1"; +pub const szOID_NT_PRINCIPAL_NAME: &'static str = "1.3.6.1.4.1.311.20.2.3"; +pub const szOID_INTERNATIONALIZED_EMAIL_ADDRESS: &'static str = "1.3.6.1.4.1.311.20.2.4"; +pub const szOID_PRODUCT_UPDATE: &'static str = "1.3.6.1.4.1.311.31.1"; +pub const szOID_ANY_APPLICATION_POLICY: &'static str = "1.3.6.1.4.1.311.10.12.1"; +pub const szOID_AUTO_ENROLL_CTL_USAGE: &'static str = "1.3.6.1.4.1.311.20.1"; +pub const szOID_ENROLL_CERTTYPE_EXTENSION: &'static str = "1.3.6.1.4.1.311.20.2"; +pub const szOID_CERT_MANIFOLD: &'static str = "1.3.6.1.4.1.311.20.3"; +pub const szOID_CERTSRV_CA_VERSION: &'static str = "1.3.6.1.4.1.311.21.1"; +pub const szOID_CERTSRV_PREVIOUS_CERT_HASH: &'static str = "1.3.6.1.4.1.311.21.2"; +pub const szOID_CRL_VIRTUAL_BASE: &'static str = "1.3.6.1.4.1.311.21.3"; +pub const szOID_CRL_NEXT_PUBLISH: &'static str = "1.3.6.1.4.1.311.21.4"; +pub const szOID_KP_CA_EXCHANGE: &'static str = "1.3.6.1.4.1.311.21.5"; +pub const szOID_KP_PRIVACY_CA: &'static str = "1.3.6.1.4.1.311.21.36"; +pub const szOID_KP_KEY_RECOVERY_AGENT: &'static str = "1.3.6.1.4.1.311.21.6"; +pub const szOID_CERTIFICATE_TEMPLATE: &'static str = "1.3.6.1.4.1.311.21.7"; +pub const szOID_ENTERPRISE_OID_ROOT: &'static str = "1.3.6.1.4.1.311.21.8"; +pub const szOID_RDN_DUMMY_SIGNER: &'static str = "1.3.6.1.4.1.311.21.9"; +pub const szOID_APPLICATION_CERT_POLICIES: &'static str = "1.3.6.1.4.1.311.21.10"; +pub const szOID_APPLICATION_POLICY_MAPPINGS: &'static str = "1.3.6.1.4.1.311.21.11"; +pub const szOID_APPLICATION_POLICY_CONSTRAINTS: &'static str = "1.3.6.1.4.1.311.21.12"; +pub const szOID_ARCHIVED_KEY_ATTR: &'static str = "1.3.6.1.4.1.311.21.13"; +pub const szOID_CRL_SELF_CDP: &'static str = "1.3.6.1.4.1.311.21.14"; +pub const szOID_REQUIRE_CERT_CHAIN_POLICY: &'static str = "1.3.6.1.4.1.311.21.15"; +pub const szOID_ARCHIVED_KEY_CERT_HASH: &'static str = "1.3.6.1.4.1.311.21.16"; +pub const szOID_ISSUED_CERT_HASH: &'static str = "1.3.6.1.4.1.311.21.17"; +pub const szOID_DS_EMAIL_REPLICATION: &'static str = "1.3.6.1.4.1.311.21.19"; +pub const szOID_REQUEST_CLIENT_INFO: &'static str = "1.3.6.1.4.1.311.21.20"; +pub const szOID_ENCRYPTED_KEY_HASH: &'static str = "1.3.6.1.4.1.311.21.21"; +pub const szOID_CERTSRV_CROSSCA_VERSION: &'static str = "1.3.6.1.4.1.311.21.22"; +pub const szOID_NTDS_REPLICATION: &'static str = "1.3.6.1.4.1.311.25.1"; +pub const szOID_SUBJECT_DIR_ATTRS: &'static str = "2.5.29.9"; +pub const szOID_PKIX_KP: &'static str = "1.3.6.1.5.5.7.3"; +pub const szOID_PKIX_KP_SERVER_AUTH: &'static str = "1.3.6.1.5.5.7.3.1"; +pub const szOID_PKIX_KP_CLIENT_AUTH: &'static str = "1.3.6.1.5.5.7.3.2"; +pub const szOID_PKIX_KP_CODE_SIGNING: &'static str = "1.3.6.1.5.5.7.3.3"; +pub const szOID_PKIX_KP_EMAIL_PROTECTION: &'static str = "1.3.6.1.5.5.7.3.4"; +pub const szOID_PKIX_KP_IPSEC_END_SYSTEM: &'static str = "1.3.6.1.5.5.7.3.5"; +pub const szOID_PKIX_KP_IPSEC_TUNNEL: &'static str = "1.3.6.1.5.5.7.3.6"; +pub const szOID_PKIX_KP_IPSEC_USER: &'static str = "1.3.6.1.5.5.7.3.7"; +pub const szOID_PKIX_KP_TIMESTAMP_SIGNING: &'static str = "1.3.6.1.5.5.7.3.8"; +pub const szOID_PKIX_KP_OCSP_SIGNING: &'static str = "1.3.6.1.5.5.7.3.9"; +pub const szOID_PKIX_OCSP_NOCHECK: &'static str = "1.3.6.1.5.5.7.48.1.5"; +pub const szOID_PKIX_OCSP_NONCE: &'static str = "1.3.6.1.5.5.7.48.1.2"; +pub const szOID_IPSEC_KP_IKE_INTERMEDIATE: &'static str = "1.3.6.1.5.5.8.2.2"; +pub const szOID_PKINIT_KP_KDC: &'static str = "1.3.6.1.5.2.3.5"; +pub const szOID_KP_CTL_USAGE_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.1"; +pub const szOID_KP_TIME_STAMP_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.2"; +pub const szOID_SERVER_GATED_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.3"; +pub const szOID_SGC_NETSCAPE: &'static str = "2.16.840.1.113730.4.1"; +pub const szOID_KP_EFS: &'static str = "1.3.6.1.4.1.311.10.3.4"; +pub const szOID_EFS_RECOVERY: &'static str = "1.3.6.1.4.1.311.10.3.4.1"; +pub const szOID_WHQL_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.5"; +pub const szOID_ATTEST_WHQL_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.5.1"; +pub const szOID_NT5_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.6"; +pub const szOID_OEM_WHQL_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.7"; +pub const szOID_EMBEDDED_NT_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.8"; +pub const szOID_ROOT_LIST_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.9"; +pub const szOID_KP_QUALIFIED_SUBORDINATION: &'static str = "1.3.6.1.4.1.311.10.3.10"; +pub const szOID_KP_KEY_RECOVERY: &'static str = "1.3.6.1.4.1.311.10.3.11"; +pub const szOID_KP_DOCUMENT_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.12"; +pub const szOID_KP_LIFETIME_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.13"; +pub const szOID_KP_MOBILE_DEVICE_SOFTWARE: &'static str = "1.3.6.1.4.1.311.10.3.14"; +pub const szOID_KP_SMART_DISPLAY: &'static str = "1.3.6.1.4.1.311.10.3.15"; +pub const szOID_KP_CSP_SIGNATURE: &'static str = "1.3.6.1.4.1.311.10.3.16"; +pub const szOID_KP_FLIGHT_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.27"; +pub const szOID_PLATFORM_MANIFEST_BINARY_ID: &'static str = "1.3.6.1.4.1.311.10.3.28"; +pub const szOID_DRM: &'static str = "1.3.6.1.4.1.311.10.5.1"; +pub const szOID_DRM_INDIVIDUALIZATION: &'static str = "1.3.6.1.4.1.311.10.5.2"; +pub const szOID_LICENSES: &'static str = "1.3.6.1.4.1.311.10.6.1"; +pub const szOID_LICENSE_SERVER: &'static str = "1.3.6.1.4.1.311.10.6.2"; +pub const szOID_KP_SMARTCARD_LOGON: &'static str = "1.3.6.1.4.1.311.20.2.2"; +pub const szOID_KP_KERNEL_MODE_CODE_SIGNING: &'static str = "1.3.6.1.4.1.311.61.1.1"; +pub const szOID_KP_KERNEL_MODE_TRUSTED_BOOT_SIGNING: &'static str = "1.3.6.1.4.1.311.61.4.1"; +pub const szOID_REVOKED_LIST_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.19"; +pub const szOID_WINDOWS_KITS_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.20"; +pub const szOID_WINDOWS_RT_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.21"; +pub const szOID_PROTECTED_PROCESS_LIGHT_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.22"; +pub const szOID_WINDOWS_TCB_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.23"; +pub const szOID_PROTECTED_PROCESS_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.24"; +pub const szOID_WINDOWS_THIRD_PARTY_COMPONENT_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.25"; +pub const szOID_WINDOWS_SOFTWARE_EXTENSION_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.26"; +pub const szOID_DISALLOWED_LIST: &'static str = "1.3.6.1.4.1.311.10.3.30"; +pub const szOID_PIN_RULES_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.31"; +pub const szOID_PIN_RULES_CTL: &'static str = "1.3.6.1.4.1.311.10.3.32"; +pub const szOID_PIN_RULES_EXT: &'static str = "1.3.6.1.4.1.311.10.3.33"; +pub const szOID_PIN_RULES_DOMAIN_NAME: &'static str = "1.3.6.1.4.1.311.10.3.34"; +pub const szOID_PIN_RULES_LOG_END_DATE_EXT: &'static str = "1.3.6.1.4.1.311.10.3.35"; +pub const szOID_IUM_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.37"; +pub const szOID_EV_WHQL_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.39"; +pub const szOID_SYNC_ROOT_CTL_EXT: &'static str = "1.3.6.1.4.1.311.10.3.50"; +pub const szOID_HPKP_DOMAIN_NAME_CTL: &'static str = "1.3.6.1.4.1.311.10.3.60"; +pub const szOID_HPKP_HEADER_VALUE_CTL: &'static str = "1.3.6.1.4.1.311.10.3.61"; +pub const szOID_KP_KERNEL_MODE_HAL_EXTENSION_SIGNING: &'static str = "1.3.6.1.4.1.311.61.5.1"; +pub const szOID_WINDOWS_STORE_SIGNER: &'static str = "1.3.6.1.4.1.311.76.3.1"; +pub const szOID_DYNAMIC_CODE_GEN_SIGNER: &'static str = "1.3.6.1.4.1.311.76.5.1"; +pub const szOID_MICROSOFT_PUBLISHER_SIGNER: &'static str = "1.3.6.1.4.1.311.76.8.1"; +pub const szOID_YESNO_TRUST_ATTR: &'static str = "1.3.6.1.4.1.311.10.4.1"; +pub const szOID_SITE_PIN_RULES_INDEX_ATTR: &'static str = "1.3.6.1.4.1.311.10.4.2"; +pub const szOID_SITE_PIN_RULES_FLAGS_ATTR: &'static str = "1.3.6.1.4.1.311.10.4.3"; +pub const szOID_PKIX_POLICY_QUALIFIER_CPS: &'static str = "1.3.6.1.5.5.7.2.1"; +pub const szOID_PKIX_POLICY_QUALIFIER_USERNOTICE: &'static str = "1.3.6.1.5.5.7.2.2"; +pub const szOID_ROOT_PROGRAM_FLAGS: &'static str = "1.3.6.1.4.1.311.60.1.1"; +pub const CERT_ROOT_PROGRAM_FLAG_ORG: DWORD = 0x80; +pub const CERT_ROOT_PROGRAM_FLAG_LSC: DWORD = 0x40; +pub const CERT_ROOT_PROGRAM_FLAG_SUBJECT_LOGO: DWORD = 0x20; +pub const CERT_ROOT_PROGRAM_FLAG_OU: DWORD = 0x10; +pub const CERT_ROOT_PROGRAM_FLAG_ADDRESS: DWORD = 0x08; +pub const szOID_CERT_POLICIES_95_QUALIFIER1: &'static str = "2.16.840.1.113733.1.7.1.1"; +pub const szOID_RDN_TPM_MANUFACTURER: &'static str = "2.23.133.2.1"; +pub const szOID_RDN_TPM_MODEL: &'static str = "2.23.133.2.2"; +pub const szOID_RDN_TPM_VERSION: &'static str = "2.23.133.2.3"; +pub const szOID_RDN_TCG_PLATFORM_MANUFACTURER: &'static str = "2.23.133.2.4"; +pub const szOID_RDN_TCG_PLATFORM_MODEL: &'static str = "2.23.133.2.5"; +pub const szOID_RDN_TCG_PLATFORM_VERSION: &'static str = "2.23.133.2.6"; +pub const szOID_ENROLL_EK_INFO: &'static str = "1.3.6.1.4.1.311.21.23"; +pub const szOID_ENROLL_AIK_INFO: &'static str = "1.3.6.1.4.1.311.21.39"; +pub const szOID_ENROLL_ATTESTATION_STATEMENT: &'static str = "1.3.6.1.4.1.311.21.24"; +pub const szOID_ENROLL_KSP_NAME: &'static str = "1.3.6.1.4.1.311.21.25"; +pub const szOID_ENROLL_EKPUB_CHALLENGE: &'static str = "1.3.6.1.4.1.311.21.26"; +pub const szOID_ENROLL_CAXCHGCERT_HASH: &'static str = "1.3.6.1.4.1.311.21.27"; +pub const szOID_ENROLL_ATTESTATION_CHALLENGE: &'static str = "1.3.6.1.4.1.311.21.28"; +pub const szOID_ENROLL_ENCRYPTION_ALGORITHM: &'static str = "1.3.6.1.4.1.311.21.29"; +pub const szOID_KP_TPM_EK_CERTIFICATE: &'static str = "2.23.133.8.1"; +pub const szOID_KP_TPM_PLATFORM_CERTIFICATE: &'static str = "2.23.133.8.2"; +pub const szOID_KP_TPM_AIK_CERTIFICATE: &'static str = "2.23.133.8.3"; +pub const szOID_ENROLL_EKVERIFYKEY: &'static str = "1.3.6.1.4.1.311.21.30"; +pub const szOID_ENROLL_EKVERIFYCERT: &'static str = "1.3.6.1.4.1.311.21.31"; +pub const szOID_ENROLL_EKVERIFYCREDS: &'static str = "1.3.6.1.4.1.311.21.32"; +pub const szOID_ENROLL_SCEP_ERROR: &'static str = "1.3.6.1.4.1.311.21.33"; +pub const szOID_ENROLL_SCEP_SERVER_STATE: &'static str = "1.3.6.1.4.1.311.21.34"; +pub const szOID_ENROLL_SCEP_CHALLENGE_ANSWER: &'static str = "1.3.6.1.4.1.311.21.35"; +pub const szOID_ENROLL_SCEP_CLIENT_REQUEST: &'static str = "1.3.6.1.4.1.311.21.37"; +pub const szOID_ENROLL_SCEP_SERVER_MESSAGE: &'static str = "1.3.6.1.4.1.311.21.38"; +pub const szOID_ENROLL_SCEP_SERVER_SECRET: &'static str = "1.3.6.1.4.1.311.21.40"; +pub const szOID_ENROLL_KEY_AFFINITY: &'static str = "1.3.6.1.4.1.311.21.41"; +pub const szOID_ENROLL_SCEP_SIGNER_HASH: &'static str = "1.3.6.1.4.1.311.21.42"; +pub const szOID_ENROLL_EK_CA_KEYID: &'static str = "1.3.6.1.4.1.311.21.43"; +pub const szOID_ATTR_SUPPORTED_ALGORITHMS: &'static str = "2.5.4.52"; +pub const szOID_ATTR_TPM_SPECIFICATION: &'static str = "2.23.133.2.16"; +pub const szOID_ATTR_PLATFORM_SPECIFICATION: &'static str = "2.23.133.2.17"; +pub const szOID_ATTR_TPM_SECURITY_ASSERTIONS: &'static str = "2.23.133.2.18"; +STRUCT!{struct CERT_EXTENSIONS { + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type PCERT_EXTENSIONS = *mut CERT_EXTENSIONS; +pub const CERT_UNICODE_RDN_ERR_INDEX_MASK: DWORD = 0x3FF; +pub const CERT_UNICODE_RDN_ERR_INDEX_SHIFT: DWORD = 22; +pub const CERT_UNICODE_ATTR_ERR_INDEX_MASK: DWORD = 0x003F; +pub const CERT_UNICODE_ATTR_ERR_INDEX_SHIFT: DWORD = 16; +pub const CERT_UNICODE_VALUE_ERR_INDEX_MASK: DWORD = 0x0000FFFF; +pub const CERT_UNICODE_VALUE_ERR_INDEX_SHIFT: DWORD = 0; +#[inline] +pub fn GET_CERT_UNICODE_RDN_ERR_INDEX(X: DWORD) -> DWORD { + (X >> CERT_UNICODE_RDN_ERR_INDEX_SHIFT) & CERT_UNICODE_RDN_ERR_INDEX_MASK +} +#[inline] +pub fn GET_CERT_UNICODE_ATTR_ERR_INDEX(X: DWORD) -> DWORD { + (X >> CERT_UNICODE_ATTR_ERR_INDEX_SHIFT) & CERT_UNICODE_ATTR_ERR_INDEX_MASK +} +#[inline] +pub fn GET_CERT_UNICODE_VALUE_ERR_INDEX(X: DWORD) -> DWORD { + X & CERT_UNICODE_VALUE_ERR_INDEX_MASK +} +STRUCT!{struct CERT_AUTHORITY_KEY_ID_INFO { + KeyId: CRYPT_DATA_BLOB, + CertIssuer: CERT_NAME_BLOB, + CertSerialNumber: CRYPT_INTEGER_BLOB, +}} +pub type PCERT_AUTHORITY_KEY_ID_INFO = *mut CERT_AUTHORITY_KEY_ID_INFO; +STRUCT!{struct CERT_PRIVATE_KEY_VALIDITY { + NotBefore: FILETIME, + NotAfter: FILETIME, +}} +pub type PCERT_PRIVATE_KEY_VALIDITY = *mut CERT_PRIVATE_KEY_VALIDITY; +STRUCT!{struct CERT_KEY_ATTRIBUTES_INFO { + KeyId: CRYPT_DATA_BLOB, + IntendedKeyUsage: CRYPT_BIT_BLOB, + pPrivateKeyUsagePeriod: PCERT_PRIVATE_KEY_VALIDITY, +}} +pub type PCERT_KEY_ATTRIBUTES_INFO = *mut CERT_KEY_ATTRIBUTES_INFO; +pub const CERT_DIGITAL_SIGNATURE_KEY_USAGE: DWORD = 0x80; +pub const CERT_NON_REPUDIATION_KEY_USAGE: DWORD = 0x40; +pub const CERT_KEY_ENCIPHERMENT_KEY_USAGE: DWORD = 0x20; +pub const CERT_DATA_ENCIPHERMENT_KEY_USAGE: DWORD = 0x10; +pub const CERT_KEY_AGREEMENT_KEY_USAGE: DWORD = 0x08; +pub const CERT_KEY_CERT_SIGN_KEY_USAGE: DWORD = 0x04; +pub const CERT_OFFLINE_CRL_SIGN_KEY_USAGE: DWORD = 0x02; +pub const CERT_CRL_SIGN_KEY_USAGE: DWORD = 0x02; +pub const CERT_ENCIPHER_ONLY_KEY_USAGE: DWORD = 0x01; +pub const CERT_DECIPHER_ONLY_KEY_USAGE: DWORD = 0x80; +STRUCT!{struct CERT_POLICY_ID { + cCertPolicyElementId: DWORD, + rgpszCertPolicyElementId: *mut LPSTR, +}} +pub type PCERT_POLICY_ID = *mut CERT_POLICY_ID; +STRUCT!{struct CERT_KEY_USAGE_RESTRICTION_INFO { + cCertPolicyId: DWORD, + rgCertPolicyId: PCERT_POLICY_ID, + RestrictedKeyUsage: CRYPT_BIT_BLOB, +}} +pub type PCERT_KEY_USAGE_RESTRICTION_INFO = *mut CERT_KEY_USAGE_RESTRICTION_INFO; +STRUCT!{struct CERT_OTHER_NAME { + pszObjId: LPSTR, + Value: CRYPT_OBJID_BLOB, +}} +pub type PCERT_OTHER_NAME = *mut CERT_OTHER_NAME; +UNION!{union CERT_ALT_NAME_ENTRY_u { + [usize; 2], + pOtherName pOtherName_mut: PCERT_OTHER_NAME, + pwszRfc822Name pwszRfc822Name_mut: LPWSTR, + pwszDNSName pwszDNSName_mut: LPWSTR, + DirectoryName DirectoryName_mut: CERT_NAME_BLOB, + pwszURL pwszURL_mut: LPWSTR, + IPAddress IPAddress_mut: CRYPT_DATA_BLOB, + pszRegisteredID pszRegisteredID_mut: LPSTR, +}} +STRUCT!{struct CERT_ALT_NAME_ENTRY { + dwAltNameChoice: DWORD, + u: CERT_ALT_NAME_ENTRY_u, +}} +pub type PCERT_ALT_NAME_ENTRY = *mut CERT_ALT_NAME_ENTRY; +pub const CERT_ALT_NAME_OTHER_NAME: DWORD = 1; +pub const CERT_ALT_NAME_RFC822_NAME: DWORD = 2; +pub const CERT_ALT_NAME_DNS_NAME: DWORD = 3; +pub const CERT_ALT_NAME_X400_ADDRESS: DWORD = 4; +pub const CERT_ALT_NAME_DIRECTORY_NAME: DWORD = 5; +pub const CERT_ALT_NAME_EDI_PARTY_NAME: DWORD = 6; +pub const CERT_ALT_NAME_URL: DWORD = 7; +pub const CERT_ALT_NAME_IP_ADDRESS: DWORD = 8; +pub const CERT_ALT_NAME_REGISTERED_ID: DWORD = 9; +STRUCT!{struct CERT_ALT_NAME_INFO { + cAltEntry: DWORD, + rgAltEntry: PCERT_ALT_NAME_ENTRY, +}} +pub type PCERT_ALT_NAME_INFO = *mut CERT_ALT_NAME_INFO; +pub const CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK: DWORD = 0xFF; +pub const CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT: DWORD = 16; +pub const CERT_ALT_NAME_VALUE_ERR_INDEX_MASK: DWORD = 0x0000FFFF; +pub const CERT_ALT_NAME_VALUE_ERR_INDEX_SHIFT: DWORD = 0; +#[inline] +pub fn GET_CERT_ALT_NAME_ENTRY_ERR_INDEX(X: DWORD) -> DWORD { + (X >> CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT) & CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK +} +#[inline] +pub fn GET_CERT_ALT_NAME_VALUE_ERR_INDEX(X: DWORD) -> DWORD { + X & CERT_ALT_NAME_VALUE_ERR_INDEX_MASK +} +STRUCT!{struct CERT_BASIC_CONSTRAINTS_INFO { + SubjectType: CRYPT_BIT_BLOB, + fPathLenConstraint: BOOL, + dwPathLenConstraint: DWORD, + cSubtreesConstraint: DWORD, + rgSubtreesConstraint: *mut CERT_NAME_BLOB, +}} +pub type PCERT_BASIC_CONSTRAINTS_INFO = *mut CERT_BASIC_CONSTRAINTS_INFO; +pub const CERT_CA_SUBJECT_FLAG: DWORD = 0x80; +pub const CERT_END_ENTITY_SUBJECT_FLAG: DWORD = 0x40; +STRUCT!{struct CERT_BASIC_CONSTRAINTS2_INFO { + fCA: BOOL, + fPathLenConstraint: BOOL, + dwPathLenConstraint: DWORD, +}} +pub type PCERT_BASIC_CONSTRAINTS2_INFO = *mut CERT_BASIC_CONSTRAINTS2_INFO; +STRUCT!{struct CERT_POLICY_QUALIFIER_INFO { + pszPolicyQualifierId: LPSTR, + Qualifier: CRYPT_OBJID_BLOB, +}} +pub type PCERT_POLICY_QUALIFIER_INFO = *mut CERT_POLICY_QUALIFIER_INFO; +STRUCT!{struct CERT_POLICY_INFO { + pszPolicyIdentifier: LPSTR, + cPolicyQualifier: DWORD, + rgPolicyQualifier: *mut CERT_POLICY_QUALIFIER_INFO, +}} +pub type PCERT_POLICY_INFO = *mut CERT_POLICY_INFO; +STRUCT!{struct CERT_POLICIES_INFO { + cPolicyInfo: DWORD, + rgPolicyInfo: *mut CERT_POLICY_INFO, +}} +pub type PCERT_POLICIES_INFO = *mut CERT_POLICIES_INFO; +STRUCT!{struct CERT_POLICY_QUALIFIER_NOTICE_REFERENCE { + pszOrganization: LPSTR, + cNoticeNumbers: DWORD, + rgNoticeNumbers: *mut c_int, +}} +pub type PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE = *mut CERT_POLICY_QUALIFIER_NOTICE_REFERENCE; +STRUCT!{struct CERT_POLICY_QUALIFIER_USER_NOTICE { + pNoticeReference: *mut CERT_POLICY_QUALIFIER_NOTICE_REFERENCE, + pszDisplayText: LPWSTR, +}} +pub type PCERT_POLICY_QUALIFIER_USER_NOTICE = *mut CERT_POLICY_QUALIFIER_USER_NOTICE; +STRUCT!{struct CPS_URLS { + pszURL: LPWSTR, + pAlgorithm: *mut CRYPT_ALGORITHM_IDENTIFIER, + pDigest: *mut CRYPT_DATA_BLOB, +}} +pub type PCPS_URLS = *mut CPS_URLS; +STRUCT!{struct CERT_POLICY95_QUALIFIER1 { + pszPracticesReference: LPWSTR, + pszNoticeIdentifier: LPSTR, + pszNSINoticeIdentifier: LPSTR, + cCPSURLs: DWORD, + rgCPSURLs: *mut CPS_URLS, +}} +pub type PCERT_POLICY95_QUALIFIER1 = *mut CERT_POLICY95_QUALIFIER1; +STRUCT!{struct CERT_POLICY_MAPPING { + pszIssuerDomainPolicy: LPSTR, + pszSubjectDomainPolicy: LPSTR, +}} +pub type PCERT_POLICY_MAPPING = *mut CERT_POLICY_MAPPING; +STRUCT!{struct CERT_POLICY_MAPPINGS_INFO { + cPolicyMapping: DWORD, + rgPolicyMapping: PCERT_POLICY_MAPPING, +}} +pub type PCERT_POLICY_MAPPINGS_INFO = *mut CERT_POLICY_MAPPINGS_INFO; +STRUCT!{struct CERT_POLICY_CONSTRAINTS_INFO { + fRequireExplicitPolicy: BOOL, + dwRequireExplicitPolicySkipCerts: DWORD, + fInhibitPolicyMapping: BOOL, + dwInhibitPolicyMappingSkipCerts: DWORD, +}} +pub type PCERT_POLICY_CONSTRAINTS_INFO = *mut CERT_POLICY_CONSTRAINTS_INFO; +STRUCT!{struct CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY { + pszObjId: LPSTR, + cValue: DWORD, + rgValue: PCRYPT_DER_BLOB, +}} +pub type PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY = *mut CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY; +STRUCT!{struct CRYPT_CONTENT_INFO { + pszObjId: LPSTR, + Content: CRYPT_DER_BLOB, +}} +pub type PCRYPT_CONTENT_INFO = *mut CRYPT_CONTENT_INFO; +STRUCT!{struct CRYPT_SEQUENCE_OF_ANY { + cValue: DWORD, + rgValue: PCRYPT_DER_BLOB, +}} +pub type PCRYPT_SEQUENCE_OF_ANY = *mut CRYPT_SEQUENCE_OF_ANY; +STRUCT!{struct CERT_AUTHORITY_KEY_ID2_INFO { + KeyId: CRYPT_DATA_BLOB, + AuthorityCertIssuer: CERT_ALT_NAME_INFO, + AuthorityCertSerialNumber: CRYPT_INTEGER_BLOB, +}} +pub type PCERT_AUTHORITY_KEY_ID2_INFO = *mut CERT_AUTHORITY_KEY_ID2_INFO; +STRUCT!{struct CERT_ACCESS_DESCRIPTION { + pszAccessMethod: LPSTR, + AccessLocation: CERT_ALT_NAME_ENTRY, +}} +pub type PCERT_ACCESS_DESCRIPTION = *mut CERT_ACCESS_DESCRIPTION; +STRUCT!{struct CERT_AUTHORITY_INFO_ACCESS { + cAccDescr: DWORD, + rgAccDescr: PCERT_ACCESS_DESCRIPTION, +}} +pub type PCERT_AUTHORITY_INFO_ACCESS = *mut CERT_AUTHORITY_INFO_ACCESS; +pub type CERT_SUBJECT_INFO_ACCESS = CERT_AUTHORITY_INFO_ACCESS; +pub type PCERT_SUBJECT_INFO_ACCESS = *mut CERT_AUTHORITY_INFO_ACCESS; +pub const szOID_PKIX_ACC_DESCR: &'static str = "1.3.6.1.5.5.7.48"; +pub const szOID_PKIX_OCSP: &'static str = "1.3.6.1.5.5.7.48.1"; +pub const szOID_PKIX_CA_ISSUERS: &'static str = "1.3.6.1.5.5.7.48.2"; +pub const szOID_PKIX_TIME_STAMPING: &'static str = "1.3.6.1.5.5.7.48.3"; +pub const szOID_PKIX_CA_REPOSITORY: &'static str = "1.3.6.1.5.5.7.48.5"; +pub const CRL_REASON_UNSPECIFIED: DWORD = 0; +pub const CRL_REASON_KEY_COMPROMISE: DWORD = 1; +pub const CRL_REASON_CA_COMPROMISE: DWORD = 2; +pub const CRL_REASON_AFFILIATION_CHANGED: DWORD = 3; +pub const CRL_REASON_SUPERSEDED: DWORD = 4; +pub const CRL_REASON_CESSATION_OF_OPERATION: DWORD = 5; +pub const CRL_REASON_CERTIFICATE_HOLD: DWORD = 6; +pub const CRL_REASON_REMOVE_FROM_CRL: DWORD = 8; +pub const CRL_REASON_PRIVILEGE_WITHDRAWN: DWORD = 9; +pub const CRL_REASON_AA_COMPROMISE: DWORD = 10; +UNION!{union CRL_DIST_POINT_NAME_u { + [usize; 2], + FullName FullName_mut: CERT_ALT_NAME_INFO, +}} +STRUCT!{struct CRL_DIST_POINT_NAME { + dwDistPointNameChoice: DWORD, + u: CRL_DIST_POINT_NAME_u, +}} +pub type PCRL_DIST_POINT_NAME = *mut CRL_DIST_POINT_NAME; +pub const CRL_DIST_POINT_NO_NAME: DWORD = 0; +pub const CRL_DIST_POINT_FULL_NAME: DWORD = 1; +pub const CRL_DIST_POINT_ISSUER_RDN_NAME: DWORD = 2; +STRUCT!{struct CRL_DIST_POINT { + DistPointName: CRL_DIST_POINT_NAME, + ReasonFlags: CRYPT_BIT_BLOB, + CRLIssuer: CERT_ALT_NAME_INFO, +}} +pub type PCRL_DIST_POINT = *mut CRL_DIST_POINT; +pub const CRL_REASON_UNUSED_FLAG: DWORD = 0x80; +pub const CRL_REASON_KEY_COMPROMISE_FLAG: DWORD = 0x40; +pub const CRL_REASON_CA_COMPROMISE_FLAG: DWORD = 0x20; +pub const CRL_REASON_AFFILIATION_CHANGED_FLAG: DWORD = 0x10; +pub const CRL_REASON_SUPERSEDED_FLAG: DWORD = 0x08; +pub const CRL_REASON_CESSATION_OF_OPERATION_FLAG: DWORD = 0x04; +pub const CRL_REASON_CERTIFICATE_HOLD_FLAG: DWORD = 0x02; +pub const CRL_REASON_PRIVILEGE_WITHDRAWN_FLAG: DWORD = 0x01; +pub const CRL_REASON_AA_COMPROMISE_FLAG: DWORD = 0x80; +STRUCT!{struct CRL_DIST_POINTS_INFO { + cDistPoint: DWORD, + rgDistPoint: PCRL_DIST_POINT, +}} +pub type PCRL_DIST_POINTS_INFO = *mut CRL_DIST_POINTS_INFO; +pub const CRL_DIST_POINT_ERR_INDEX_MASK: DWORD = 0x7F; +pub const CRL_DIST_POINT_ERR_INDEX_SHIFT: DWORD = 24; +#[inline] +pub fn GET_CRL_DIST_POINT_ERR_INDEX(X: DWORD) -> DWORD { + (X >> CRL_DIST_POINT_ERR_INDEX_SHIFT) & CRL_DIST_POINT_ERR_INDEX_MASK +} +pub const CRL_DIST_POINT_ERR_CRL_ISSUER_BIT: DWORD = 0x80000000; +#[inline] +pub fn IS_CRL_DIST_POINT_ERR_CRL_ISSUER(X: DWORD) -> bool { + 0 != (X & CRL_DIST_POINT_ERR_CRL_ISSUER_BIT) +} +STRUCT!{struct CROSS_CERT_DIST_POINTS_INFO { + dwSyncDeltaTime: DWORD, + cDistPoint: DWORD, + rgDistPoint: PCERT_ALT_NAME_INFO, +}} +pub type PCROSS_CERT_DIST_POINTS_INFO = *mut CROSS_CERT_DIST_POINTS_INFO; +pub const CROSS_CERT_DIST_POINT_ERR_INDEX_MASK: DWORD = 0xFF; +pub const CROSS_CERT_DIST_POINT_ERR_INDEX_SHIFT: DWORD = 24; +#[inline] +pub fn GET_CROSS_CERT_DIST_POINT_ERR_INDEX(X: DWORD) -> DWORD { + (X >> CROSS_CERT_DIST_POINT_ERR_INDEX_SHIFT) & CROSS_CERT_DIST_POINT_ERR_INDEX_MASK +} +STRUCT!{struct CERT_PAIR { + Forward: CERT_BLOB, + Reverse: CERT_BLOB, +}} +pub type PCERT_PAIR = *mut CERT_PAIR; +STRUCT!{struct CRL_ISSUING_DIST_POINT { + DistPointName: CRL_DIST_POINT_NAME, + fOnlyContainsUserCerts: BOOL, + fOnlyContainsCACerts: BOOL, + OnlySomeReasonFlags: CRYPT_BIT_BLOB, + fIndirectCRL: BOOL, +}} +pub type PCRL_ISSUING_DIST_POINT = *mut CRL_ISSUING_DIST_POINT; +STRUCT!{struct CERT_GENERAL_SUBTREE { + Base: CERT_ALT_NAME_ENTRY, + dwMinimum: DWORD, + fMaximum: BOOL, + dwMaximum: DWORD, +}} +pub type PCERT_GENERAL_SUBTREE = *mut CERT_GENERAL_SUBTREE; +STRUCT!{struct CERT_NAME_CONSTRAINTS_INFO { + cPermittedSubtree: DWORD, + rgPermittedSubtree: PCERT_GENERAL_SUBTREE, + cExcludedSubtree: DWORD, + rgExcludedSubtree: PCERT_GENERAL_SUBTREE, +}} +pub type PCERT_NAME_CONSTRAINTS_INFO = *mut CERT_NAME_CONSTRAINTS_INFO; +pub const CERT_EXCLUDED_SUBTREE_BIT: DWORD = 0x80000000; +#[inline] +pub fn IS_CERT_EXCLUDED_SUBTREE(X: DWORD) -> bool { + 0 != (X & CERT_EXCLUDED_SUBTREE_BIT) +} +pub const SORTED_CTL_EXT_FLAGS_OFFSET: c_int = 0 * 4; +pub const SORTED_CTL_EXT_COUNT_OFFSET: c_int = 1 * 4; +pub const SORTED_CTL_EXT_MAX_COLLISION_OFFSET: c_int = 2 * 4; +pub const SORTED_CTL_EXT_HASH_BUCKET_OFFSET: c_int = 3 * 4; +pub const SORTED_CTL_EXT_HASHED_SUBJECT_IDENTIFIER_FLAG: DWORD = 0x1; +STRUCT!{struct CERT_DSS_PARAMETERS { + p: CRYPT_UINT_BLOB, + q: CRYPT_UINT_BLOB, + g: CRYPT_UINT_BLOB, +}} +pub type PCERT_DSS_PARAMETERS = *mut CERT_DSS_PARAMETERS; +pub const CERT_DSS_R_LEN: usize = 20; +pub const CERT_DSS_S_LEN: usize = 20; +pub const CERT_DSS_SIGNATURE_LEN: usize = CERT_DSS_R_LEN + CERT_DSS_S_LEN; +pub const CERT_MAX_ASN_ENCODED_DSS_SIGNATURE_LEN: usize = 2 + 2 * (2 + 20 + 1); +STRUCT!{struct CERT_DH_PARAMETERS { + p: CRYPT_UINT_BLOB, + g: CRYPT_UINT_BLOB, +}} +pub type PCERT_DH_PARAMETERS = *mut CERT_DH_PARAMETERS; +STRUCT!{struct CERT_ECC_SIGNATURE { + r: CRYPT_UINT_BLOB, + s: CRYPT_UINT_BLOB, +}} +pub type PCERT_ECC_SIGNATURE = *mut CERT_ECC_SIGNATURE; +STRUCT!{struct CERT_X942_DH_VALIDATION_PARAMS { + seed: CRYPT_BIT_BLOB, + pgenCounter: DWORD, +}} +pub type PCERT_X942_DH_VALIDATION_PARAMS = *mut CERT_X942_DH_VALIDATION_PARAMS; +STRUCT!{struct CERT_X942_DH_PARAMETERS { + p: CRYPT_UINT_BLOB, + g: CRYPT_UINT_BLOB, + q: CRYPT_UINT_BLOB, + j: CRYPT_UINT_BLOB, + pValidationParams: PCERT_X942_DH_VALIDATION_PARAMS, +}} +pub type PCERT_X942_DH_PARAMETERS = *mut CERT_X942_DH_PARAMETERS; +pub const CRYPT_X942_COUNTER_BYTE_LENGTH: usize = 4; +pub const CRYPT_X942_KEY_LENGTH_BYTE_LENGTH: usize = 4; +pub const CRYPT_X942_PUB_INFO_BYTE_LENGTH: usize = 512 / 8; +STRUCT!{struct CRYPT_X942_OTHER_INFO { + pszContentEncryptionObjId: LPSTR, + rgbCounter: [BYTE; CRYPT_X942_COUNTER_BYTE_LENGTH], + rgbKeyLength: [BYTE; CRYPT_X942_KEY_LENGTH_BYTE_LENGTH], + PubInfo: CRYPT_DATA_BLOB, +}} +pub type PCRYPT_X942_OTHER_INFO = *mut CRYPT_X942_OTHER_INFO; +pub const CRYPT_ECC_CMS_SHARED_INFO_SUPPPUBINFO_BYTE_LENGTH: usize = 4; +STRUCT!{struct CRYPT_ECC_CMS_SHARED_INFO { + Algorithm: CRYPT_ALGORITHM_IDENTIFIER, + EntityUInfo: CRYPT_DATA_BLOB, + rgbSuppPubInfo: [BYTE; CRYPT_ECC_CMS_SHARED_INFO_SUPPPUBINFO_BYTE_LENGTH], +}} +pub type PCRYPT_ECC_CMS_SHARED_INFO = *mut CRYPT_ECC_CMS_SHARED_INFO; +STRUCT!{struct CRYPT_RC2_CBC_PARAMETERS { + dwVersion: DWORD, + fIV: BOOL, + rgbIV: [BYTE; 8], +}} +pub type PCRYPT_RC2_CBC_PARAMETERS = *mut CRYPT_RC2_CBC_PARAMETERS; +pub const CRYPT_RC2_40BIT_VERSION: DWORD = 160; +pub const CRYPT_RC2_56BIT_VERSION: DWORD = 52; +pub const CRYPT_RC2_64BIT_VERSION: DWORD = 120; +pub const CRYPT_RC2_128BIT_VERSION: DWORD = 58; +STRUCT!{struct CRYPT_SMIME_CAPABILITY { + pszObjId: LPSTR, + Parameters: CRYPT_OBJID_BLOB, +}} +pub type PCRYPT_SMIME_CAPABILITY = *mut CRYPT_SMIME_CAPABILITY; +STRUCT!{struct CRYPT_SMIME_CAPABILITIES { + cCapability: DWORD, + rgCapability: PCRYPT_SMIME_CAPABILITY, +}} +pub type PCRYPT_SMIME_CAPABILITIES = *mut CRYPT_SMIME_CAPABILITIES; +STRUCT!{struct CERT_QC_STATEMENT { + pszStatementId: LPSTR, + StatementInfo: CRYPT_OBJID_BLOB, +}} +pub type PCERT_QC_STATEMENT = *mut CERT_QC_STATEMENT; +STRUCT!{struct CERT_QC_STATEMENTS_EXT_INFO { + cStatement: DWORD, + rgStatement: PCERT_QC_STATEMENT, +}} +pub type PCERT_QC_STATEMENTS_EXT_INFO = *mut CERT_QC_STATEMENTS_EXT_INFO; +pub const szOID_QC_EU_COMPLIANCE: &'static str = "0.4.0.1862.1.1"; +pub const szOID_QC_SSCD: &'static str = "0.4.0.1862.1.4"; +STRUCT!{struct CRYPT_MASK_GEN_ALGORITHM { + pszObjId: LPSTR, + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, +}} +pub type PCRYPT_MASK_GEN_ALGORITHM = *mut CRYPT_MASK_GEN_ALGORITHM; +STRUCT!{struct CRYPT_RSA_SSA_PSS_PARAMETERS { + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + MaskGenAlgorithm: CRYPT_MASK_GEN_ALGORITHM, + dwSaltLength: DWORD, + dwTrailerField: DWORD, +}} +pub type PCRYPT_RSA_SSA_PSS_PARAMETERS = *mut CRYPT_RSA_SSA_PSS_PARAMETERS; +pub const PKCS_RSA_SSA_PSS_TRAILER_FIELD_BC: DWORD = 1; +STRUCT!{struct CRYPT_PSOURCE_ALGORITHM { + pszObjId: LPSTR, + EncodingParameters: CRYPT_DATA_BLOB, +}} +pub type PCRYPT_PSOURCE_ALGORITHM = *mut CRYPT_PSOURCE_ALGORITHM; +STRUCT!{struct CRYPT_RSAES_OAEP_PARAMETERS { + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + MaskGenAlgorithm: CRYPT_MASK_GEN_ALGORITHM, + PSourceAlgorithm: CRYPT_PSOURCE_ALGORITHM, +}} +pub type PCRYPT_RSAES_OAEP_PARAMETERS = *mut CRYPT_RSAES_OAEP_PARAMETERS; +pub const szOID_VERISIGN_PRIVATE_6_9: &'static str = "2.16.840.1.113733.1.6.9"; +pub const szOID_VERISIGN_ONSITE_JURISDICTION_HASH: &'static str = "2.16.840.1.113733.1.6.11"; +pub const szOID_VERISIGN_BITSTRING_6_13: &'static str = "2.16.840.1.113733.1.6.13"; +pub const szOID_VERISIGN_ISS_STRONG_CRYPTO: &'static str = "2.16.840.1.113733.1.8.1"; +pub const szOIDVerisign_MessageType: &'static str = "2.16.840.1.113733.1.9.2"; +pub const szOIDVerisign_PkiStatus: &'static str = "2.16.840.1.113733.1.9.3"; +pub const szOIDVerisign_FailInfo: &'static str = "2.16.840.1.113733.1.9.4"; +pub const szOIDVerisign_SenderNonce: &'static str = "2.16.840.1.113733.1.9.5"; +pub const szOIDVerisign_RecipientNonce: &'static str = "2.16.840.1.113733.1.9.6"; +pub const szOIDVerisign_TransactionID: &'static str = "2.16.840.1.113733.1.9.7"; +pub const szOID_NETSCAPE: &'static str = "2.16.840.1.113730"; +pub const szOID_NETSCAPE_CERT_EXTENSION: &'static str = "2.16.840.1.113730.1"; +pub const szOID_NETSCAPE_CERT_TYPE: &'static str = "2.16.840.1.113730.1.1"; +pub const szOID_NETSCAPE_BASE_URL: &'static str = "2.16.840.1.113730.1.2"; +pub const szOID_NETSCAPE_REVOCATION_URL: &'static str = "2.16.840.1.113730.1.3"; +pub const szOID_NETSCAPE_CA_REVOCATION_URL: &'static str = "2.16.840.1.113730.1.4"; +pub const szOID_NETSCAPE_CERT_RENEWAL_URL: &'static str = "2.16.840.1.113730.1.7"; +pub const szOID_NETSCAPE_CA_POLICY_URL: &'static str = "2.16.840.1.113730.1.8"; +pub const szOID_NETSCAPE_SSL_SERVER_NAME: &'static str = "2.16.840.1.113730.1.12"; +pub const szOID_NETSCAPE_COMMENT: &'static str = "2.16.840.1.113730.1.13"; +pub const szOID_NETSCAPE_DATA_TYPE: &'static str = "2.16.840.1.113730.2"; +pub const szOID_NETSCAPE_CERT_SEQUENCE: &'static str = "2.16.840.1.113730.2.5"; +pub const NETSCAPE_SSL_CLIENT_AUTH_CERT_TYPE: DWORD = 0x80; +pub const NETSCAPE_SSL_SERVER_AUTH_CERT_TYPE: DWORD = 0x40; +pub const NETSCAPE_SMIME_CERT_TYPE: DWORD = 0x20; +pub const NETSCAPE_SIGN_CERT_TYPE: DWORD = 0x10; +pub const NETSCAPE_SSL_CA_CERT_TYPE: DWORD = 0x04; +pub const NETSCAPE_SMIME_CA_CERT_TYPE: DWORD = 0x02; +pub const NETSCAPE_SIGN_CA_CERT_TYPE: DWORD = 0x01; +pub const szOID_CT_PKI_DATA: &'static str = "1.3.6.1.5.5.7.12.2"; +pub const szOID_CT_PKI_RESPONSE: &'static str = "1.3.6.1.5.5.7.12.3"; +pub const szOID_PKIX_NO_SIGNATURE: &'static str = "1.3.6.1.5.5.7.6.2"; +pub const szOID_CMC: &'static str = "1.3.6.1.5.5.7.7"; +pub const szOID_CMC_STATUS_INFO: &'static str = "1.3.6.1.5.5.7.7.1"; +pub const szOID_CMC_IDENTIFICATION: &'static str = "1.3.6.1.5.5.7.7.2"; +pub const szOID_CMC_IDENTITY_PROOF: &'static str = "1.3.6.1.5.5.7.7.3"; +pub const szOID_CMC_DATA_RETURN: &'static str = "1.3.6.1.5.5.7.7.4"; +pub const szOID_CMC_TRANSACTION_ID: &'static str = "1.3.6.1.5.5.7.7.5"; +pub const szOID_CMC_SENDER_NONCE: &'static str = "1.3.6.1.5.5.7.7.6"; +pub const szOID_CMC_RECIPIENT_NONCE: &'static str = "1.3.6.1.5.5.7.7.7"; +pub const szOID_CMC_ADD_EXTENSIONS: &'static str = "1.3.6.1.5.5.7.7.8"; +pub const szOID_CMC_ENCRYPTED_POP: &'static str = "1.3.6.1.5.5.7.7.9"; +pub const szOID_CMC_DECRYPTED_POP: &'static str = "1.3.6.1.5.5.7.7.10"; +pub const szOID_CMC_LRA_POP_WITNESS: &'static str = "1.3.6.1.5.5.7.7.11"; +pub const szOID_CMC_GET_CERT: &'static str = "1.3.6.1.5.5.7.7.15"; +pub const szOID_CMC_GET_CRL: &'static str = "1.3.6.1.5.5.7.7.16"; +pub const szOID_CMC_REVOKE_REQUEST: &'static str = "1.3.6.1.5.5.7.7.17"; +pub const szOID_CMC_REG_INFO: &'static str = "1.3.6.1.5.5.7.7.18"; +pub const szOID_CMC_RESPONSE_INFO: &'static str = "1.3.6.1.5.5.7.7.19"; +pub const szOID_CMC_QUERY_PENDING: &'static str = "1.3.6.1.5.5.7.7.21"; +pub const szOID_CMC_ID_POP_LINK_RANDOM: &'static str = "1.3.6.1.5.5.7.7.22"; +pub const szOID_CMC_ID_POP_LINK_WITNESS: &'static str = "1.3.6.1.5.5.7.7.23"; +pub const szOID_CMC_ID_CONFIRM_CERT_ACCEPTANCE: &'static str = "1.3.6.1.5.5.7.7.24"; +pub const szOID_CMC_ADD_ATTRIBUTES: &'static str = "1.3.6.1.4.1.311.10.10.1"; +STRUCT!{struct CMC_TAGGED_ATTRIBUTE { + dwBodyPartID: DWORD, + Attribute: CRYPT_ATTRIBUTE, +}} +pub type PCMC_TAGGED_ATTRIBUTE = *mut CMC_TAGGED_ATTRIBUTE; +STRUCT!{struct CMC_TAGGED_CERT_REQUEST { + dwBodyPartID: DWORD, + SignedCertRequest: CRYPT_DER_BLOB, +}} +pub type PCMC_TAGGED_CERT_REQUEST = *mut CMC_TAGGED_CERT_REQUEST; +UNION!{union CMC_TAGGED_REQUEST_u { + [usize; 1], + pTaggedCertRequest pTaggedCertRequest_mut: PCMC_TAGGED_CERT_REQUEST, +}} +STRUCT!{struct CMC_TAGGED_REQUEST { + dwTaggedRequestChoice: DWORD, + u: CMC_TAGGED_REQUEST_u, +}} +pub type PCMC_TAGGED_REQUEST = *mut CMC_TAGGED_REQUEST; +STRUCT!{struct CMC_TAGGED_CONTENT_INFO { + dwBodyPartID: DWORD, + EncodedContentInfo: CRYPT_DER_BLOB, +}} +pub type PCMC_TAGGED_CONTENT_INFO = *mut CMC_TAGGED_CONTENT_INFO; +STRUCT!{struct CMC_TAGGED_OTHER_MSG { + dwBodyPartID: DWORD, + pszObjId: LPSTR, + Value: CRYPT_OBJID_BLOB, +}} +pub type PCMC_TAGGED_OTHER_MSG = *mut CMC_TAGGED_OTHER_MSG; +STRUCT!{struct CMC_DATA_INFO { + cTaggedAttribute: DWORD, + rgTaggedAttribute: PCMC_TAGGED_ATTRIBUTE, + cTaggedRequest: DWORD, + rgTaggedRequest: PCMC_TAGGED_REQUEST, + cTaggedContentInfo: DWORD, + rgTaggedContentInfo: PCMC_TAGGED_CONTENT_INFO, + cTaggedOtherMsg: DWORD, + rgTaggedOtherMsg: PCMC_TAGGED_OTHER_MSG, +}} +pub type PCMC_DATA_INFO = *mut CMC_DATA_INFO; +STRUCT!{struct CMC_RESPONSE_INFO { + cTaggedAttribute: DWORD, + rgTaggedAttribute: PCMC_TAGGED_ATTRIBUTE, + cTaggedContentInfo: DWORD, + rgTaggedContentInfo: PCMC_TAGGED_CONTENT_INFO, + cTaggedOtherMsg: DWORD, + rgTaggedOtherMsg: PCMC_TAGGED_OTHER_MSG, +}} +pub type PCMC_RESPONSE_INFO = *mut CMC_RESPONSE_INFO; +STRUCT!{struct CMC_PEND_INFO { + PendToken: CRYPT_DATA_BLOB, + PendTime: FILETIME, +}} +pub type PCMC_PEND_INFO = *mut CMC_PEND_INFO; +UNION!{union CMC_STATUS_INFO_u { + [usize; 1], + dwFailInfo dwFailInfo_mut: DWORD, + pPendInfo pPendInfo_mut: PCMC_PEND_INFO, +}} +STRUCT!{struct CMC_STATUS_INFO { + dwStatus: DWORD, + cBodyList: DWORD, + rgdwBodyList: *mut DWORD, + pwszStatusString: LPWSTR, + dwOtherInfoChoice: DWORD, + u: CMC_STATUS_INFO_u, +}} +pub type PCMC_STATUS_INFO = *mut CMC_STATUS_INFO; +pub const CMC_OTHER_INFO_NO_CHOICE: DWORD = 0; +pub const CMC_OTHER_INFO_FAIL_CHOICE: DWORD = 1; +pub const CMC_OTHER_INFO_PEND_CHOICE: DWORD = 2; +pub const CMC_STATUS_SUCCESS: DWORD = 0; +pub const CMC_STATUS_FAILED: DWORD = 2; +pub const CMC_STATUS_PENDING: DWORD = 3; +pub const CMC_STATUS_NO_SUPPORT: DWORD = 4; +pub const CMC_STATUS_CONFIRM_REQUIRED: DWORD = 5; +pub const CMC_FAIL_BAD_ALG: DWORD = 0; +pub const CMC_FAIL_BAD_MESSAGE_CHECK: DWORD = 1; +pub const CMC_FAIL_BAD_REQUEST: DWORD = 2; +pub const CMC_FAIL_BAD_TIME: DWORD = 3; +pub const CMC_FAIL_BAD_CERT_ID: DWORD = 4; +pub const CMC_FAIL_UNSUPORTED_EXT: DWORD = 5; +pub const CMC_FAIL_MUST_ARCHIVE_KEYS: DWORD = 6; +pub const CMC_FAIL_BAD_IDENTITY: DWORD = 7; +pub const CMC_FAIL_POP_REQUIRED: DWORD = 8; +pub const CMC_FAIL_POP_FAILED: DWORD = 9; +pub const CMC_FAIL_NO_KEY_REUSE: DWORD = 10; +pub const CMC_FAIL_INTERNAL_CA_ERROR: DWORD = 11; +pub const CMC_FAIL_TRY_LATER: DWORD = 12; +STRUCT!{struct CMC_ADD_EXTENSIONS_INFO { + dwCmcDataReference: DWORD, + cCertReference: DWORD, + rgdwCertReference: *mut DWORD, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type PCMC_ADD_EXTENSIONS_INFO = *mut CMC_ADD_EXTENSIONS_INFO; +STRUCT!{struct CMC_ADD_ATTRIBUTES_INFO { + dwCmcDataReference: DWORD, + cCertReference: DWORD, + rgdwCertReference: *mut DWORD, + cAttribute: DWORD, + rgAttribute: PCRYPT_ATTRIBUTE, +}} +pub type PCMC_ADD_ATTRIBUTES_INFO = *mut CMC_ADD_ATTRIBUTES_INFO; +STRUCT!{struct CERT_TEMPLATE_EXT { + pszObjId: LPSTR, + dwMajorVersion: DWORD, + fMinorVersion: BOOL, + dwMinorVersion: DWORD, +}} +pub type PCERT_TEMPLATE_EXT = *mut CERT_TEMPLATE_EXT; +STRUCT!{struct CERT_HASHED_URL { + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + Hash: CRYPT_HASH_BLOB, + pwszUrl: LPWSTR, +}} +pub type PCERT_HASHED_URL = *mut CERT_HASHED_URL; +STRUCT!{struct CERT_LOGOTYPE_DETAILS { + pwszMimeType: LPWSTR, + cHashedUrl: DWORD, + rgHashedUrl: PCERT_HASHED_URL, +}} +pub type PCERT_LOGOTYPE_DETAILS = *mut CERT_LOGOTYPE_DETAILS; +STRUCT!{struct CERT_LOGOTYPE_REFERENCE { + cHashedUrl: DWORD, + rgHashedUrl: PCERT_HASHED_URL, +}} +pub type PCERT_LOGOTYPE_REFERENCE = *mut CERT_LOGOTYPE_REFERENCE; +UNION!{union CERT_LOGOTYPE_IMAGE_INFO_u { + [u32; 1], + dwNumBits dwNumBits_mut: DWORD, + dwTableSize dwTableSize_mut: DWORD, +}} +STRUCT!{struct CERT_LOGOTYPE_IMAGE_INFO { + dwLogotypeImageInfoChoice: DWORD, + dwFileSize: DWORD, + dwXSize: DWORD, + dwYSize: DWORD, + dwLogotypeImageResolutionChoice: DWORD, + u: CERT_LOGOTYPE_IMAGE_INFO_u, + pwszLanguage: LPWSTR, +}} +pub type PCERT_LOGOTYPE_IMAGE_INFO = *mut CERT_LOGOTYPE_IMAGE_INFO; +pub const CERT_LOGOTYPE_GRAY_SCALE_IMAGE_INFO_CHOICE: DWORD = 1; +pub const CERT_LOGOTYPE_COLOR_IMAGE_INFO_CHOICE: DWORD = 2; +pub const CERT_LOGOTYPE_NO_IMAGE_RESOLUTION_CHOICE: DWORD = 0; +pub const CERT_LOGOTYPE_BITS_IMAGE_RESOLUTION_CHOICE: DWORD = 1; +pub const CERT_LOGOTYPE_TABLE_SIZE_IMAGE_RESOLUTION_CHOICE: DWORD = 2; +STRUCT!{struct CERT_LOGOTYPE_IMAGE { + LogotypeDetails: CERT_LOGOTYPE_DETAILS, + pLogotypeImageInfo: PCERT_LOGOTYPE_IMAGE_INFO, +}} +pub type PCERT_LOGOTYPE_IMAGE = *mut CERT_LOGOTYPE_IMAGE; +STRUCT!{struct CERT_LOGOTYPE_AUDIO_INFO { + dwFileSize: DWORD, + dwPlayTime: DWORD, + dwChannels: DWORD, + dwSampleRate: DWORD, + pwszLanguage: LPWSTR, +}} +pub type PCERT_LOGOTYPE_AUDIO_INFO = *mut CERT_LOGOTYPE_AUDIO_INFO; +STRUCT!{struct CERT_LOGOTYPE_AUDIO { + LogotypeDetails: CERT_LOGOTYPE_DETAILS, + pLogotypeAudioInfo: PCERT_LOGOTYPE_AUDIO_INFO, +}} +pub type PCERT_LOGOTYPE_AUDIO = *mut CERT_LOGOTYPE_AUDIO; +STRUCT!{struct CERT_LOGOTYPE_DATA { + cLogotypeImage: DWORD, + rgLogotypeImage: PCERT_LOGOTYPE_IMAGE, + cLogotypeAudio: DWORD, + rgLogotypeAudio: PCERT_LOGOTYPE_AUDIO, +}} +pub type PCERT_LOGOTYPE_DATA = *mut CERT_LOGOTYPE_DATA; +UNION!{union CERT_LOGOTYPE_INFO_u { + [usize; 1], + pLogotypeDirectInfo pLogotypeDirectInfo_mut: PCERT_LOGOTYPE_DATA, + pLogotypeIndirectInfo pLogotypeIndirectInfo__mut: PCERT_LOGOTYPE_REFERENCE, +}} +STRUCT!{struct CERT_LOGOTYPE_INFO { + dwLogotypeInfoChoice: DWORD, + u: CERT_LOGOTYPE_INFO_u, +}} +pub type PCERT_LOGOTYPE_INFO = *mut CERT_LOGOTYPE_INFO; +pub const CERT_LOGOTYPE_DIRECT_INFO_CHOICE: DWORD = 1; +pub const CERT_LOGOTYPE_INDIRECT_INFO_CHOICE: DWORD = 2; +STRUCT!{struct CERT_OTHER_LOGOTYPE_INFO { + pszObjId: LPSTR, + LogotypeInfo: CERT_LOGOTYPE_INFO, +}} +pub type PCERT_OTHER_LOGOTYPE_INFO = *mut CERT_OTHER_LOGOTYPE_INFO; +pub const szOID_LOYALTY_OTHER_LOGOTYPE: &'static str = "1.3.6.1.5.5.7.20.1"; +pub const szOID_BACKGROUND_OTHER_LOGOTYPE: &'static str = "1.3.6.1.5.5.7.20.2"; +STRUCT!{struct CERT_LOGOTYPE_EXT_INFO { + cCommunityLogo: DWORD, + rgCommunityLogo: PCERT_LOGOTYPE_INFO, + pIssuerLogo: PCERT_LOGOTYPE_INFO, + pSubjectLogo: PCERT_LOGOTYPE_INFO, + cOtherLogo: DWORD, + rgOtherLogo: PCERT_OTHER_LOGOTYPE_INFO, +}} +pub type PCERT_LOGOTYPE_EXT_INFO = *mut CERT_LOGOTYPE_EXT_INFO; +UNION!{union CERT_BIOMETRIC_DATA_u { + [usize; 1], + dwPredefined dwPredefined_mut: DWORD, + pszObjId pszObjId_mut: LPSTR, +}} +STRUCT!{struct CERT_BIOMETRIC_DATA { + dwTypeOfBiometricDataChoice: DWORD, + u: CERT_BIOMETRIC_DATA_u, + HashedUrl: CERT_HASHED_URL, +}} +pub type PCERT_BIOMETRIC_DATA = *mut CERT_BIOMETRIC_DATA; +pub const CERT_BIOMETRIC_PREDEFINED_DATA_CHOICE: DWORD = 1; +pub const CERT_BIOMETRIC_OID_DATA_CHOICE: DWORD = 2; +pub const CERT_BIOMETRIC_PICTURE_TYPE: DWORD = 0; +pub const CERT_BIOMETRIC_SIGNATURE_TYPE: DWORD = 1; +STRUCT!{struct CERT_BIOMETRIC_EXT_INFO { + cBiometricData: DWORD, + rgBiometricData: PCERT_BIOMETRIC_DATA, +}} +pub type PCERT_BIOMETRIC_EXT_INFO = *mut CERT_BIOMETRIC_EXT_INFO; +STRUCT!{struct OCSP_SIGNATURE_INFO { + SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + Signature: CRYPT_BIT_BLOB, + cCertEncoded: DWORD, + rgCertEncoded: PCERT_BLOB, +}} +pub type POCSP_SIGNATURE_INFO = *mut OCSP_SIGNATURE_INFO; +STRUCT!{struct OCSP_SIGNED_REQUEST_INFO { + ToBeSigned: CRYPT_DER_BLOB, + pOptionalSignatureInfo: POCSP_SIGNATURE_INFO, +}} +pub type POCSP_SIGNED_REQUEST_INFO = *mut OCSP_SIGNED_REQUEST_INFO; +STRUCT!{struct OCSP_CERT_ID { + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + IssuerNameHash: CRYPT_HASH_BLOB, + IssuerKeyHash: CRYPT_HASH_BLOB, + SerialNumber: CRYPT_INTEGER_BLOB, +}} +pub type POCSP_CERT_ID = *mut OCSP_CERT_ID; +STRUCT!{struct OCSP_REQUEST_ENTRY { + CertId: OCSP_CERT_ID, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type POCSP_REQUEST_ENTRY = *mut OCSP_REQUEST_ENTRY; +STRUCT!{struct OCSP_REQUEST_INFO { + dwVersion: DWORD, + pRequestorName: PCERT_ALT_NAME_ENTRY, + cRequestEntry: DWORD, + rgRequestEntry: POCSP_REQUEST_ENTRY, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type POCSP_REQUEST_INFO = *mut OCSP_REQUEST_INFO; +pub const OCSP_REQUEST_V1: DWORD = 0; +STRUCT!{struct OCSP_RESPONSE_INFO { + dwStatus: DWORD, + pszObjId: LPSTR, + Value: CRYPT_OBJID_BLOB, +}} +pub type POCSP_RESPONSE_INFO = *mut OCSP_RESPONSE_INFO; +pub const OCSP_SUCCESSFUL_RESPONSE: DWORD = 0; +pub const OCSP_MALFORMED_REQUEST_RESPONSE: DWORD = 1; +pub const OCSP_INTERNAL_ERROR_RESPONSE: DWORD = 2; +pub const OCSP_TRY_LATER_RESPONSE: DWORD = 3; +pub const OCSP_SIG_REQUIRED_RESPONSE: DWORD = 5; +pub const OCSP_UNAUTHORIZED_RESPONSE: DWORD = 6; +pub const szOID_PKIX_OCSP_BASIC_SIGNED_RESPONSE: &'static str = "1.3.6.1.5.5.7.48.1.1"; +STRUCT!{struct OCSP_BASIC_SIGNED_RESPONSE_INFO { + ToBeSigned: CRYPT_DER_BLOB, + SignatureInfo: OCSP_SIGNATURE_INFO, +}} +pub type POCSP_BASIC_SIGNED_RESPONSE_INFO = *mut OCSP_BASIC_SIGNED_RESPONSE_INFO; +STRUCT!{struct OCSP_BASIC_REVOKED_INFO { + RevocationDate: FILETIME, + dwCrlReasonCode: DWORD, +}} +pub type POCSP_BASIC_REVOKED_INFO = *mut OCSP_BASIC_REVOKED_INFO; +UNION!{union OCSP_BASIC_RESPONSE_ENTRY_u { + [usize; 1], + pRevokedInfo pRevokedInfo_mut: POCSP_BASIC_REVOKED_INFO, +}} +STRUCT!{struct OCSP_BASIC_RESPONSE_ENTRY { + CertId: OCSP_CERT_ID, + dwCertStatus: DWORD, + u: OCSP_BASIC_RESPONSE_ENTRY_u, + ThisUpdate: FILETIME, + NextUpdate: FILETIME, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type POCSP_BASIC_RESPONSE_ENTRY = *mut OCSP_BASIC_RESPONSE_ENTRY; +pub const OCSP_BASIC_GOOD_CERT_STATUS: DWORD = 0; +pub const OCSP_BASIC_REVOKED_CERT_STATUS: DWORD = 1; +pub const OCSP_BASIC_UNKNOWN_CERT_STATUS: DWORD = 2; +UNION!{union OCSP_BASIC_RESPONSE_INFO_u { + [usize; 2], + ByNameResponderId ByNameResponderId_mut: CERT_NAME_BLOB, + ByKeyResponderId ByKeyResponderId_mut: CRYPT_HASH_BLOB, +}} +STRUCT!{struct OCSP_BASIC_RESPONSE_INFO { + dwVersion: DWORD, + dwResponderIdChoice: DWORD, + u: OCSP_BASIC_RESPONSE_INFO_u, + ProducedAt: FILETIME, + cResponseEntry: DWORD, + rgResponseEntry: POCSP_BASIC_RESPONSE_ENTRY, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type POCSP_BASIC_RESPONSE_INFO = *mut OCSP_BASIC_RESPONSE_INFO; +pub const OCSP_BASIC_RESPONSE_V1: DWORD = 0; +pub const OCSP_BASIC_BY_NAME_RESPONDER_ID: DWORD = 1; +pub const OCSP_BASIC_BY_KEY_RESPONDER_ID: DWORD = 2; +STRUCT!{struct CERT_SUPPORTED_ALGORITHM_INFO { + Algorithm: CRYPT_ALGORITHM_IDENTIFIER, + IntendedKeyUsage: CRYPT_BIT_BLOB, + IntendedCertPolicies: CERT_POLICIES_INFO, +}} +pub type PCERT_SUPPORTED_ALGORITHM_INFO = *mut CERT_SUPPORTED_ALGORITHM_INFO; +STRUCT!{struct CERT_TPM_SPECIFICATION_INFO { + pwszFamily: LPWSTR, + dwLevel: DWORD, + dwRevision: DWORD, +}} +pub type PCERT_TPM_SPECIFICATION_INFO = *mut CERT_TPM_SPECIFICATION_INFO; +pub type HCRYPTOIDFUNCSET = *mut c_void; +pub type HCRYPTOIDFUNCADDR = *mut c_void; +pub const CRYPT_OID_ENCODE_OBJECT_FUNC: &'static str = "CryptDllEncodeObject"; +pub const CRYPT_OID_DECODE_OBJECT_FUNC: &'static str = "CryptDllDecodeObject"; +pub const CRYPT_OID_ENCODE_OBJECT_EX_FUNC: &'static str = "CryptDllEncodeObjectEx"; +pub const CRYPT_OID_DECODE_OBJECT_EX_FUNC: &'static str = "CryptDllDecodeObjectEx"; +pub const CRYPT_OID_CREATE_COM_OBJECT_FUNC: &'static str = "CryptDllCreateCOMObject"; +pub const CRYPT_OID_VERIFY_REVOCATION_FUNC: &'static str = "CertDllVerifyRevocation"; +pub const CRYPT_OID_VERIFY_CTL_USAGE_FUNC: &'static str = "CertDllVerifyCTLUsage"; +pub const CRYPT_OID_FORMAT_OBJECT_FUNC: &'static str = "CryptDllFormatObject"; +pub const CRYPT_OID_FIND_OID_INFO_FUNC: &'static str = "CryptDllFindOIDInfo"; +pub const CRYPT_OID_FIND_LOCALIZED_NAME_FUNC: &'static str = "CryptDllFindLocalizedName"; +pub const CRYPT_OID_REGPATH: &'static str = "Software\\Microsoft\\Cryptography\\OID"; +pub const CRYPT_OID_REG_ENCODING_TYPE_PREFIX: &'static str = "EncodingType "; +pub const CRYPT_OID_REG_DLL_VALUE_NAME: &'static str = "Dll"; +pub const CRYPT_OID_REG_FUNC_NAME_VALUE_NAME: &'static str = "FuncName"; +pub const CRYPT_OID_REG_FLAGS_VALUE_NAME: &'static str = "CryptFlags"; +pub const CRYPT_DEFAULT_OID: &'static str = "DEFAULT"; +STRUCT!{struct CRYPT_OID_FUNC_ENTRY { + pszOID: LPCSTR, + pvFuncAddr: *mut c_void, +}} +pub type PCRYPT_OID_FUNC_ENTRY = *mut CRYPT_OID_FUNC_ENTRY; +pub const CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG: DWORD = 1; +extern "system" { + pub fn CryptInstallOIDFunctionAddress( + hModule: HMODULE, + dwEncodingType: DWORD, + pszFuncName: LPCSTR, + cFuncEntry: DWORD, + rgFuncEntry: *const CRYPT_OID_FUNC_ENTRY, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptInitOIDFunctionSet( + pszFuncName: LPCSTR, + dwFlags: DWORD, + ) -> HCRYPTOIDFUNCSET; + pub fn CryptGetOIDFunctionAddress( + hFuncSet: HCRYPTOIDFUNCSET, + dwEncodingType: DWORD, + pszOID: LPCSTR, + dwFlags: DWORD, + ppvFuncAddr: *mut *mut c_void, + phFuncAddr: *mut HCRYPTOIDFUNCADDR, + ) -> BOOL; +} +pub const CRYPT_GET_INSTALLED_OID_FUNC_FLAG: DWORD = 0x1; +extern "system" { + pub fn CryptGetDefaultOIDDllList( + hFuncSet: HCRYPTOIDFUNCSET, + dwEncodingType: DWORD, + pwszDllList: *mut WCHAR, + pcchDllList: *mut DWORD, + ) -> BOOL; + pub fn CryptGetDefaultOIDFunctionAddress( + hFuncSet: HCRYPTOIDFUNCSET, + dwEncodingType: DWORD, + pwszDll: LPCWSTR, + dwFlags: DWORD, + ppvFuncAddr: *mut *mut c_void, + phFuncAddr: *mut HCRYPTOIDFUNCADDR, + ) -> BOOL; + pub fn CryptFreeOIDFunctionAddress( + hFuncAddr: HCRYPTOIDFUNCADDR, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptRegisterOIDFunction( + dwEncodingType: DWORD, + pszFuncName: LPCSTR, + pszOID: LPCSTR, + pwszDll: LPCWSTR, + pszOverrideFuncName: LPCSTR, + ) -> BOOL; + pub fn CryptUnregisterOIDFunction( + dwEncodingType: DWORD, + pszFuncName: LPCSTR, + pszOID: LPCSTR, + ) -> BOOL; + pub fn CryptRegisterDefaultOIDFunction( + dwEncodingType: DWORD, + pszFuncName: LPCSTR, + dwIndex: DWORD, + pwszDll: LPCWSTR, + ) -> BOOL; +} +pub const CRYPT_REGISTER_FIRST_INDEX: DWORD = 0; +pub const CRYPT_REGISTER_LAST_INDEX: DWORD = 0xFFFFFFFF; +extern "system" { + pub fn CryptUnregisterDefaultOIDFunction( + dwEncodingType: DWORD, + pszFuncName: LPCSTR, + pwszDll: LPCWSTR, + ) -> BOOL; + pub fn CryptSetOIDFunctionValue( + dwEncodingType: DWORD, + pszFuncName: LPCSTR, + pszOID: LPCSTR, + pwszValueName: LPCWSTR, + dwValueType: DWORD, + pbValueData: *const BYTE, + cbValueData: DWORD, + ) -> BOOL; + pub fn CryptGetOIDFunctionValue( + dwEncodingType: DWORD, + pszFuncName: LPCSTR, + pszOID: LPCSTR, + pwszValueName: LPCWSTR, + pdwValueType: *mut DWORD, + pbValueData: *mut BYTE, + pcbValueData: *mut DWORD, + ) -> BOOL; +} +FN!{stdcall PFN_CRYPT_ENUM_OID_FUNC( + dwEncodingType: DWORD, + pszFuncName: LPCSTR, + pszOID: LPCSTR, + cValue: DWORD, + rgdwValueType: *const DWORD, + rgpwszValueName: *const LPCWSTR, + rgpbValueData: *const *const BYTE, + rgcbValueData: *const DWORD, + pvArg: *mut c_void, +) -> BOOL} +extern "system" { + pub fn CryptEnumOIDFunction( + dwEncodingType: DWORD, + pszFuncName: LPCSTR, + pszOID: LPCSTR, + dwFlags: DWORD, + pvArg: *mut c_void, + pfnEnumOIDFunc: PFN_CRYPT_ENUM_OID_FUNC, + ) -> BOOL; +} +pub const CRYPT_MATCH_ANY_ENCODING_TYPE: DWORD = 0xFFFFFFFF; +pub const CALG_OID_INFO_CNG_ONLY: ALG_ID = 0xFFFFFFFF; +pub const CALG_OID_INFO_PARAMETERS: ALG_ID = 0xFFFFFFFE; +#[inline] +pub fn IS_SPECIAL_OID_INFO_ALGID(Algid: ALG_ID) -> bool { + Algid >= CALG_OID_INFO_PARAMETERS +} +pub const CRYPT_OID_INFO_HASH_PARAMETERS_ALGORITHM: &'static str = "CryptOIDInfoHashParameters"; +pub const CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM: &'static str = "CryptOIDInfoECCParameters"; +pub const CRYPT_OID_INFO_MGF1_PARAMETERS_ALGORITHM: &'static str = "CryptOIDInfoMgf1Parameters"; +pub const CRYPT_OID_INFO_NO_SIGN_ALGORITHM: &'static str = "CryptOIDInfoNoSign"; +pub const CRYPT_OID_INFO_OAEP_PARAMETERS_ALGORITHM: &'static str = "CryptOIDInfoOAEPParameters"; +pub const CRYPT_OID_INFO_ECC_WRAP_PARAMETERS_ALGORITHM: &'static str + = "CryptOIDInfoECCWrapParameters"; +pub const CRYPT_OID_INFO_NO_PARAMETERS_ALGORITHM: &'static str = "CryptOIDInfoNoParameters"; +UNION!{union CRYPT_OID_INFO_u { + [u32; 1], + dwValue dwValue_mut: DWORD, + Algid Algid_mut: ALG_ID, + dwLength dwLength_mut: DWORD, +}} +STRUCT!{struct CRYPT_OID_INFO { + cbSize: DWORD, + oszOID: LPCSTR, + pwszName: LPCWSTR, + dwGroupId: DWORD, + u: CRYPT_OID_INFO_u, + ExtraInfo: CRYPT_DATA_BLOB, + pwszCNGAlgid: LPCWSTR, + pwszCNGExtraAlgid: LPCWSTR, +}} +pub type PCRYPT_OID_INFO = *mut CRYPT_OID_INFO; +pub type PCCRYPT_OID_INFO = *const CRYPT_OID_INFO; +pub const CRYPT_HASH_ALG_OID_GROUP_ID: DWORD = 1; +pub const CRYPT_ENCRYPT_ALG_OID_GROUP_ID: DWORD = 2; +pub const CRYPT_PUBKEY_ALG_OID_GROUP_ID: DWORD = 3; +pub const CRYPT_SIGN_ALG_OID_GROUP_ID: DWORD = 4; +pub const CRYPT_RDN_ATTR_OID_GROUP_ID: DWORD = 5; +pub const CRYPT_EXT_OR_ATTR_OID_GROUP_ID: DWORD = 6; +pub const CRYPT_ENHKEY_USAGE_OID_GROUP_ID: DWORD = 7; +pub const CRYPT_POLICY_OID_GROUP_ID: DWORD = 8; +pub const CRYPT_TEMPLATE_OID_GROUP_ID: DWORD = 9; +pub const CRYPT_KDF_OID_GROUP_ID: DWORD = 10; +pub const CRYPT_LAST_OID_GROUP_ID: DWORD = 10; +pub const CRYPT_FIRST_ALG_OID_GROUP_ID: DWORD = CRYPT_HASH_ALG_OID_GROUP_ID; +pub const CRYPT_LAST_ALG_OID_GROUP_ID: DWORD = CRYPT_SIGN_ALG_OID_GROUP_ID; +pub const CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG: DWORD = 0x00000001; +pub const CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG: DWORD = 0x00000002; +pub const CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG: DWORD = 0x00000004; +pub const CRYPT_OID_PUBKEY_SIGN_ONLY_FLAG: DWORD = 0x80000000; +pub const CRYPT_OID_PUBKEY_ENCRYPT_ONLY_FLAG: DWORD = 0x40000000; +pub const CRYPT_OID_USE_CURVE_NAME_FOR_ENCODE_FLAG: DWORD = 0x20000000; +pub const CRYPT_OID_USE_CURVE_PARAMETERS_FOR_ENCODE_FLAG: DWORD = 0x10000000; +extern "system" { + pub fn CryptFindOIDInfo( + dwKeyType: DWORD, + pvKey: *mut c_void, + dwGroupId: DWORD, + ) -> PCCRYPT_OID_INFO; +} +pub const CRYPT_OID_INFO_OID_KEY: DWORD = 1; +pub const CRYPT_OID_INFO_NAME_KEY: DWORD = 2; +pub const CRYPT_OID_INFO_ALGID_KEY: DWORD = 3; +pub const CRYPT_OID_INFO_SIGN_KEY: DWORD = 4; +pub const CRYPT_OID_INFO_CNG_ALGID_KEY: DWORD = 5; +pub const CRYPT_OID_INFO_CNG_SIGN_KEY: DWORD = 6; +pub const CRYPT_OID_INFO_OID_KEY_FLAGS_MASK: DWORD = 0xFFFF0000; +pub const CRYPT_OID_INFO_PUBKEY_SIGN_KEY_FLAG: DWORD = 0x80000000; +pub const CRYPT_OID_INFO_PUBKEY_ENCRYPT_KEY_FLAG: DWORD = 0x40000000; +pub const CRYPT_OID_DISABLE_SEARCH_DS_FLAG: DWORD = 0x80000000; +pub const CRYPT_OID_PREFER_CNG_ALGID_FLAG: DWORD = 0x40000000; +pub const CRYPT_OID_INFO_OID_GROUP_BIT_LEN_MASK: DWORD = 0x0FFF0000; +pub const CRYPT_OID_INFO_OID_GROUP_BIT_LEN_SHIFT: DWORD = 16; +extern "system" { + pub fn CryptRegisterOIDInfo( + pInfo: PCCRYPT_OID_INFO, + dwFlags: DWORD, + ) -> BOOL; + pub fn CryptUnregisterOIDInfo( + pInfo: PCCRYPT_OID_INFO, + ) -> BOOL; +} +FN!{stdcall PFN_CRYPT_ENUM_OID_INFO( + pInfo: PCCRYPT_OID_INFO, + pvArg: *mut c_void, +) -> BOOL} +extern "system" { + pub fn CryptEnumOIDInfo( + dwGroupId: DWORD, + dwFlags: DWORD, + pvArg: *mut c_void, + pfnEnumOIDInfo: PFN_CRYPT_ENUM_OID_INFO, + ) -> BOOL; + pub fn CryptFindLocalizedName( + pwszCryptName: LPCWSTR, + ) -> LPCWSTR; +} +pub const CRYPT_LOCALIZED_NAME_ENCODING_TYPE: DWORD = 0; +pub const CRYPT_LOCALIZED_NAME_OID: &'static str = "LocalizedNames"; +STRUCT!{struct CERT_STRONG_SIGN_SERIALIZED_INFO { + dwFlags: DWORD, + pwszCNGSignHashAlgids: LPWSTR, + pwszCNGPubKeyMinBitLengths: LPWSTR, +}} +pub type PCERT_STRONG_SIGN_SERIALIZED_INFO = *mut CERT_STRONG_SIGN_SERIALIZED_INFO; +pub const CERT_STRONG_SIGN_ECDSA_ALGORITHM: &'static str = "ECDSA"; +UNION!{union CERT_STRONG_SIGN_PARA_u { + [usize; 1], + pvInfo pvInfo_mut: *mut c_void, + pSerializedInfo pSerializedInfo_mut: PCERT_STRONG_SIGN_SERIALIZED_INFO, + pszOID pszOID_mut: LPSTR, +}} +STRUCT!{struct CERT_STRONG_SIGN_PARA { + cbSize: DWORD, + dwInfoChoice: DWORD, + u: CERT_STRONG_SIGN_PARA_u, +}} +pub type PCERT_STRONG_SIGN_PARA = *mut CERT_STRONG_SIGN_PARA; +pub type PCCERT_STRONG_SIGN_PARA = *const CERT_STRONG_SIGN_PARA; +pub const CERT_STRONG_SIGN_SERIALIZED_INFO_CHOICE: DWORD = 1; +pub const CERT_STRONG_SIGN_OID_INFO_CHOICE: DWORD = 2; +pub const CERT_STRONG_SIGN_ENABLE_CRL_CHECK: DWORD = 0x1; +pub const CERT_STRONG_SIGN_ENABLE_OCSP_CHECK: DWORD = 0x2; +pub const szOID_CERT_STRONG_SIGN_OS_PREFIX: &'static str = "1.3.6.1.4.1.311.72.1."; +pub const szOID_CERT_STRONG_SIGN_OS_1: &'static str = "1.3.6.1.4.1.311.72.1.1"; +pub const szOID_CERT_STRONG_SIGN_OS_CURRENT: &'static str = szOID_CERT_STRONG_SIGN_OS_1; +pub const szOID_CERT_STRONG_KEY_OS_PREFIX: &'static str = "1.3.6.1.4.1.311.72.2."; +pub const szOID_CERT_STRONG_KEY_OS_1: &'static str = "1.3.6.1.4.1.311.72.2.1"; +pub const szOID_CERT_STRONG_KEY_OS_CURRENT: &'static str = szOID_CERT_STRONG_KEY_OS_1; +pub type HCRYPTMSG = *mut c_void; +pub const szOID_PKCS_7_DATA: &'static str = "1.2.840.113549.1.7.1"; +pub const szOID_PKCS_7_SIGNED: &'static str = "1.2.840.113549.1.7.2"; +pub const szOID_PKCS_7_ENVELOPED: &'static str = "1.2.840.113549.1.7.3"; +pub const szOID_PKCS_7_SIGNEDANDENVELOPED: &'static str = "1.2.840.113549.1.7.4"; +pub const szOID_PKCS_7_DIGESTED: &'static str = "1.2.840.113549.1.7.5"; +pub const szOID_PKCS_7_ENCRYPTED: &'static str = "1.2.840.113549.1.7.6"; +pub const szOID_PKCS_9_CONTENT_TYPE: &'static str = "1.2.840.113549.1.9.3"; +pub const szOID_PKCS_9_MESSAGE_DIGEST: &'static str = "1.2.840.113549.1.9.4"; +pub const CMSG_DATA: DWORD = 1; +pub const CMSG_SIGNED: DWORD = 2; +pub const CMSG_ENVELOPED: DWORD = 3; +pub const CMSG_SIGNED_AND_ENVELOPED: DWORD = 4; +pub const CMSG_HASHED: DWORD = 5; +pub const CMSG_ENCRYPTED: DWORD = 6; +pub const CMSG_ALL_FLAGS: DWORD = !0; +pub const CMSG_DATA_FLAG: DWORD = 1 << CMSG_DATA; +pub const CMSG_SIGNED_FLAG: DWORD = 1 << CMSG_SIGNED; +pub const CMSG_ENVELOPED_FLAG: DWORD = 1 << CMSG_ENVELOPED; +pub const CMSG_SIGNED_AND_ENVELOPED_FLAG: DWORD = 1 << CMSG_SIGNED_AND_ENVELOPED; +pub const CMSG_HASHED_FLAG: DWORD = 1 << CMSG_HASHED; +pub const CMSG_ENCRYPTED_FLAG: DWORD = 1 << CMSG_ENCRYPTED; +STRUCT!{struct CERT_ISSUER_SERIAL_NUMBER { + Issuer: CERT_NAME_BLOB, + SerialNumber: CRYPT_INTEGER_BLOB, +}} +pub type PCERT_ISSUER_SERIAL_NUMBER = *mut CERT_ISSUER_SERIAL_NUMBER; +UNION!{union CERT_ID_u { + [usize; 4], + IssuerSerialNumber IssuerSerialNumber_mut: CERT_ISSUER_SERIAL_NUMBER, + KeyId KeyId_mut: CRYPT_HASH_BLOB, + HashId HashId_mut: CRYPT_HASH_BLOB, +}} +STRUCT!{struct CERT_ID { + dwIdChoice: DWORD, + u: CERT_ID_u, +}} +pub type PCERT_ID = *mut CERT_ID; +pub const CERT_ID_ISSUER_SERIAL_NUMBER: DWORD = 1; +pub const CERT_ID_KEY_IDENTIFIER: DWORD = 2; +pub const CERT_ID_SHA1_HASH: DWORD = 3; +UNION!{union CMSG_SIGNER_ENCODE_INFO_u { + [usize; 1], + hCryptProv hCryptProv_mut: HCRYPTPROV, + hNCryptKey hNCryptKey_mut: NCRYPT_KEY_HANDLE, + hBCryptKey hBCryptKey_mut: BCRYPT_KEY_HANDLE, +}} +STRUCT!{struct CMSG_SIGNER_ENCODE_INFO { + cbSize: DWORD, + pCertInfo: PCERT_INFO, + u: CMSG_SIGNER_ENCODE_INFO_u, + dwKeySpec: DWORD, + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvHashAuxInfo: *mut c_void, + cAuthAttr: DWORD, + rgAuthAttr: PCRYPT_ATTRIBUTE, + cUnauthAttr: DWORD, + rgUnauthAttr: PCRYPT_ATTRIBUTE, + SignerId: CERT_ID, + HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvHashEncryptionAuxInfo: *mut c_void, +}} +pub type PCMSG_SIGNER_ENCODE_INFO = *mut CMSG_SIGNER_ENCODE_INFO; +STRUCT!{struct CMSG_SIGNED_ENCODE_INFO { + cbSize: DWORD, + cSigners: DWORD, + rgSigners: PCMSG_SIGNER_ENCODE_INFO, + cCertEncoded: DWORD, + rgCertEncoded: PCERT_BLOB, + cCrlEncoded: DWORD, + rgCrlEncoded: PCRL_BLOB, + cAttrCertEncoded: DWORD, + rgAttrCertEncoded: PCERT_BLOB, +}} +pub type PCMSG_SIGNED_ENCODE_INFO = *mut CMSG_SIGNED_ENCODE_INFO; +pub type PCMSG_RECIPIENT_ENCODE_INFO = *mut CMSG_RECIPIENT_ENCODE_INFO; +STRUCT!{struct CMSG_ENVELOPED_ENCODE_INFO { + cbSize: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvEncryptionAuxInfo: *mut c_void, + cRecipients: DWORD, + rgpRecipients: *mut PCERT_INFO, + rgCmsRecipients: PCMSG_RECIPIENT_ENCODE_INFO, + cCertEncoded: DWORD, + rgCertEncoded: PCERT_BLOB, + cCrlEncoded: DWORD, + rgCrlEncoded: PCRL_BLOB, + cAttrCertEncoded: DWORD, + rgAttrCertEncoded: PCERT_BLOB, + cUnprotectedAttr: DWORD, + rgUnprotectedAttr: PCRYPT_ATTRIBUTE, +}} +pub type PCMSG_ENVELOPED_ENCODE_INFO = *mut CMSG_ENVELOPED_ENCODE_INFO; +STRUCT!{struct CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO { + cbSize: DWORD, + KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvKeyEncryptionAuxInfo: *mut c_void, + hCryptProv: HCRYPTPROV_LEGACY, + RecipientPublicKey: CRYPT_BIT_BLOB, + RecipientId: CERT_ID, +}} +pub type PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO = *mut CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO; +STRUCT!{struct CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO { + cbSize: DWORD, + RecipientPublicKey: CRYPT_BIT_BLOB, + RecipientId: CERT_ID, + Date: FILETIME, + pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE, +}} +pub type PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO = *mut CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO; +UNION!{union CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO_u { + [usize; 1], + pEphemeralAlgorithm pEphemeralAlgorithm_mut: PCRYPT_ALGORITHM_IDENTIFIER, + pSenderId pSenderId_mut: PCERT_ID, +}} +STRUCT!{struct CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO { + cbSize: DWORD, + KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvKeyEncryptionAuxInfo: *mut c_void, + KeyWrapAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvKeyWrapAuxInfo: *mut c_void, + hCryptProv: HCRYPTPROV_LEGACY, + dwKeySpec: DWORD, + dwKeyChoice: DWORD, + u: CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO_u, + UserKeyingMaterial: CRYPT_DATA_BLOB, + cRecipientEncryptedKeys: DWORD, + rgpRecipientEncryptedKeys: *mut PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO, +}} +pub type PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO = *mut CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO; +pub const CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE: DWORD = 1; +pub const CMSG_KEY_AGREE_STATIC_KEY_CHOICE: DWORD = 2; +UNION!{union CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO_u { + [usize; 1], + hKeyEncryptionKey hKeyEncryptionKey_mut: HCRYPTKEY, + pvKeyEncryptionKey pvKeyEncryptionKey_mut: *mut c_void, +}} +STRUCT!{struct CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO { + cbSize: DWORD, + KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvKeyEncryptionAuxInfo: *mut c_void, + hCryptProv: HCRYPTPROV, + dwKeyChoice: DWORD, + u: CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO_u, + KeyId: CRYPT_DATA_BLOB, + Date: FILETIME, + pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE, +}} +pub type PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO = *mut CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO; +pub const CMSG_MAIL_LIST_HANDLE_KEY_CHOICE: DWORD = 1; +UNION!{union CMSG_RECIPIENT_ENCODE_INFO_u { + [usize; 1], + pKeyTrans pKeyTrans_mut: PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO, + pKeyAgree pKeyAgree_mut: PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO, + pMailList pMailList_mut: PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO, +}} +STRUCT!{struct CMSG_RECIPIENT_ENCODE_INFO { + dwRecipientChoice: DWORD, + u: CMSG_RECIPIENT_ENCODE_INFO_u, +}} +pub const CMSG_KEY_TRANS_RECIPIENT: DWORD = 1; +pub const CMSG_KEY_AGREE_RECIPIENT: DWORD = 2; +pub const CMSG_MAIL_LIST_RECIPIENT: DWORD = 3; +STRUCT!{struct CMSG_RC2_AUX_INFO { + cbSize: DWORD, + dwBitLen: DWORD, +}} +pub type PCMSG_RC2_AUX_INFO = *mut CMSG_RC2_AUX_INFO; +STRUCT!{struct CMSG_SP3_COMPATIBLE_AUX_INFO { + cbSize: DWORD, + dwFlags: DWORD, +}} +pub type PCMSG_SP3_COMPATIBLE_AUX_INFO = *mut CMSG_SP3_COMPATIBLE_AUX_INFO; +pub const CMSG_SP3_COMPATIBLE_ENCRYPT_FLAG: DWORD = 0x80000000; +STRUCT!{struct CMSG_RC4_AUX_INFO { + cbSize: DWORD, + dwBitLen: DWORD, +}} +pub type PCMSG_RC4_AUX_INFO = *mut CMSG_RC4_AUX_INFO; +pub const CMSG_RC4_NO_SALT_FLAG: DWORD = 0x40000000; +STRUCT!{struct CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO { + cbSize: DWORD, + SignedInfo: CMSG_SIGNED_ENCODE_INFO, + EnvelopedInfo: CMSG_ENVELOPED_ENCODE_INFO, +}} +pub type PCMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO = *mut CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO; +STRUCT!{struct CMSG_HASHED_ENCODE_INFO { + cbSize: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvHashAuxInfo: *mut c_void, +}} +pub type PCMSG_HASHED_ENCODE_INFO = *mut CMSG_HASHED_ENCODE_INFO; +STRUCT!{struct CMSG_ENCRYPTED_ENCODE_INFO { + cbSize: DWORD, + ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvEncryptionAuxInfo: *mut c_void, +}} +pub type PCMSG_ENCRYPTED_ENCODE_INFO = *mut CMSG_ENCRYPTED_ENCODE_INFO; +FN!{stdcall PFN_CMSG_STREAM_OUTPUT( + pvArg: *const c_void, + pbData: *mut BYTE, + cbData: DWORD, + fFinal: BOOL, +) -> BOOL} +pub const CMSG_INDEFINITE_LENGTH: DWORD = 0xFFFFFFFF; +STRUCT!{struct CMSG_STREAM_INFO { + cbContent: DWORD, + pfnStreamOutput: PFN_CMSG_STREAM_OUTPUT, + pvArg: *mut c_void, +}} +pub type PCMSG_STREAM_INFO = *mut CMSG_STREAM_INFO; +pub const CMSG_BARE_CONTENT_FLAG: DWORD = 0x00000001; +pub const CMSG_LENGTH_ONLY_FLAG: DWORD = 0x00000002; +pub const CMSG_DETACHED_FLAG: DWORD = 0x00000004; +pub const CMSG_AUTHENTICATED_ATTRIBUTES_FLAG: DWORD = 0x00000008; +pub const CMSG_CONTENTS_OCTETS_FLAG: DWORD = 0x00000010; +pub const CMSG_MAX_LENGTH_FLAG: DWORD = 0x00000020; +pub const CMSG_CMS_ENCAPSULATED_CONTENT_FLAG: DWORD = 0x00000040; +pub const CMSG_SIGNED_DATA_NO_SIGN_FLAG: DWORD = 0x00000080; +pub const CMSG_CRYPT_RELEASE_CONTEXT_FLAG: DWORD = 0x00008000; +extern "system" { + pub fn CryptMsgOpenToEncode( + dwMsgEncodingType: DWORD, + dwFlags: DWORD, + dwMsgType: DWORD, + pvMsgEncodeInfo: *mut c_void, + pszInnerContentObjID: LPSTR, + pStreamInfo: PCMSG_STREAM_INFO, + ) -> HCRYPTMSG; + pub fn CryptMsgCalculateEncodedLength( + dwMsgEncodingType: DWORD, + dwFlags: DWORD, + dwMsgType: DWORD, + pvMsgEncodeInfo: *const c_void, + pszInnerContentObjID: LPSTR, + cbData: DWORD, + ) -> DWORD; + pub fn CryptMsgOpenToDecode( + dwMsgEncodingType: DWORD, + dwFlags: DWORD, + dwMsgType: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + pRecipientInfo: PCERT_INFO, + pStreamInfo: PCMSG_STREAM_INFO, + ) -> HCRYPTMSG; + pub fn CryptMsgDuplicate( + hCryptMsg: HCRYPTMSG, + ) -> HCRYPTMSG; + pub fn CryptMsgClose( + hCryptMsg: HCRYPTMSG, + ) -> BOOL; + pub fn CryptMsgUpdate( + hCryptMsg: HCRYPTMSG, + pbData: *const BYTE, + cbData: DWORD, + fFinal: BOOL, + ) -> BOOL; + pub fn CryptMsgGetParam( + hCryptMsg: HCRYPTMSG, + dwParamType: DWORD, + dwIndex: DWORD, + pvData: *mut c_void, + pcbData: *mut DWORD, + ) -> BOOL; +} +pub const CMSG_TYPE_PARAM: DWORD = 1; +pub const CMSG_CONTENT_PARAM: DWORD = 2; +pub const CMSG_BARE_CONTENT_PARAM: DWORD = 3; +pub const CMSG_INNER_CONTENT_TYPE_PARAM: DWORD = 4; +pub const CMSG_SIGNER_COUNT_PARAM: DWORD = 5; +pub const CMSG_SIGNER_INFO_PARAM: DWORD = 6; +pub const CMSG_SIGNER_CERT_INFO_PARAM: DWORD = 7; +pub const CMSG_SIGNER_HASH_ALGORITHM_PARAM: DWORD = 8; +pub const CMSG_SIGNER_AUTH_ATTR_PARAM: DWORD = 9; +pub const CMSG_SIGNER_UNAUTH_ATTR_PARAM: DWORD = 10; +pub const CMSG_CERT_COUNT_PARAM: DWORD = 11; +pub const CMSG_CERT_PARAM: DWORD = 12; +pub const CMSG_CRL_COUNT_PARAM: DWORD = 13; +pub const CMSG_CRL_PARAM: DWORD = 14; +pub const CMSG_ENVELOPE_ALGORITHM_PARAM: DWORD = 15; +pub const CMSG_RECIPIENT_COUNT_PARAM: DWORD = 17; +pub const CMSG_RECIPIENT_INDEX_PARAM: DWORD = 18; +pub const CMSG_RECIPIENT_INFO_PARAM: DWORD = 19; +pub const CMSG_HASH_ALGORITHM_PARAM: DWORD = 20; +pub const CMSG_HASH_DATA_PARAM: DWORD = 21; +pub const CMSG_COMPUTED_HASH_PARAM: DWORD = 22; +pub const CMSG_ENCRYPT_PARAM: DWORD = 26; +pub const CMSG_ENCRYPTED_DIGEST: DWORD = 27; +pub const CMSG_ENCODED_SIGNER: DWORD = 28; +pub const CMSG_ENCODED_MESSAGE: DWORD = 29; +pub const CMSG_VERSION_PARAM: DWORD = 30; +pub const CMSG_ATTR_CERT_COUNT_PARAM: DWORD = 31; +pub const CMSG_ATTR_CERT_PARAM: DWORD = 32; +pub const CMSG_CMS_RECIPIENT_COUNT_PARAM: DWORD = 33; +pub const CMSG_CMS_RECIPIENT_INDEX_PARAM: DWORD = 34; +pub const CMSG_CMS_RECIPIENT_ENCRYPTED_KEY_INDEX_PARAM: DWORD = 35; +pub const CMSG_CMS_RECIPIENT_INFO_PARAM: DWORD = 36; +pub const CMSG_UNPROTECTED_ATTR_PARAM: DWORD = 37; +pub const CMSG_SIGNER_CERT_ID_PARAM: DWORD = 38; +pub const CMSG_CMS_SIGNER_INFO_PARAM: DWORD = 39; +STRUCT!{struct CMSG_SIGNER_INFO { + dwVersion: DWORD, + Issuer: CERT_NAME_BLOB, + SerialNumber: CRYPT_INTEGER_BLOB, + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + EncryptedHash: CRYPT_DATA_BLOB, + AuthAttrs: CRYPT_ATTRIBUTES, + UnauthAttrs: CRYPT_ATTRIBUTES, +}} +pub type PCMSG_SIGNER_INFO = *mut CMSG_SIGNER_INFO; +STRUCT!{struct CMSG_CMS_SIGNER_INFO { + dwVersion: DWORD, + SignerId: CERT_ID, + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + EncryptedHash: CRYPT_DATA_BLOB, + AuthAttrs: CRYPT_ATTRIBUTES, + UnauthAttrs: CRYPT_ATTRIBUTES, +}} +pub type PCMSG_CMS_SIGNER_INFO = *mut CMSG_CMS_SIGNER_INFO; +pub type CMSG_ATTR = CRYPT_ATTRIBUTES; +pub type PCMSG_ATTR = *mut CRYPT_ATTRIBUTES; +pub const CMSG_SIGNED_DATA_V1: DWORD = 1; +pub const CMSG_SIGNED_DATA_V3: DWORD = 3; +pub const CMSG_SIGNED_DATA_PKCS_1_5_VERSION: DWORD = CMSG_SIGNED_DATA_V1; +pub const CMSG_SIGNED_DATA_CMS_VERSION: DWORD = CMSG_SIGNED_DATA_V3; +pub const CMSG_SIGNER_INFO_V1: DWORD = 1; +pub const CMSG_SIGNER_INFO_V3: DWORD = 3; +pub const CMSG_SIGNER_INFO_PKCS_1_5_VERSION: DWORD = CMSG_SIGNER_INFO_V1; +pub const CMSG_SIGNER_INFO_CMS_VERSION: DWORD = CMSG_SIGNER_INFO_V3; +pub const CMSG_HASHED_DATA_V0: DWORD = 0; +pub const CMSG_HASHED_DATA_V2: DWORD = 2; +pub const CMSG_HASHED_DATA_PKCS_1_5_VERSION: DWORD = CMSG_HASHED_DATA_V0; +pub const CMSG_HASHED_DATA_CMS_VERSION: DWORD = CMSG_HASHED_DATA_V2; +pub const CMSG_ENVELOPED_DATA_V0: DWORD = 0; +pub const CMSG_ENVELOPED_DATA_V2: DWORD = 2; +pub const CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION: DWORD = CMSG_ENVELOPED_DATA_V0; +pub const CMSG_ENVELOPED_DATA_CMS_VERSION: DWORD = CMSG_ENVELOPED_DATA_V2; +STRUCT!{struct CMSG_KEY_TRANS_RECIPIENT_INFO { + dwVersion: DWORD, + RecipientId: CERT_ID, + KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + EncryptedKey: CRYPT_DATA_BLOB, +}} +pub type PCMSG_KEY_TRANS_RECIPIENT_INFO = *mut CMSG_KEY_TRANS_RECIPIENT_INFO; +STRUCT!{struct CMSG_RECIPIENT_ENCRYPTED_KEY_INFO { + RecipientId: CERT_ID, + EncryptedKey: CRYPT_DATA_BLOB, + Date: FILETIME, + pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE, +}} +pub type PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO = *mut CMSG_RECIPIENT_ENCRYPTED_KEY_INFO; +UNION!{union CMSG_KEY_AGREE_RECIPIENT_INFO_u { + [usize; 6], + OriginatorCertId OriginatorCertId_mut: CERT_ID, + OriginatorPublicKeyInfo OriginatorPublicKeyInfo_mut: CERT_PUBLIC_KEY_INFO, +}} +STRUCT!{struct CMSG_KEY_AGREE_RECIPIENT_INFO { + dwVersion: DWORD, + dwOriginatorChoice: DWORD, + u: CMSG_KEY_AGREE_RECIPIENT_INFO_u, + UserKeyingMaterial: CRYPT_DATA_BLOB, + KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + cRecipientEncryptedKeys: DWORD, + rgpRecipientEncryptedKeys: *mut PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO, +}} +pub type PCMSG_KEY_AGREE_RECIPIENT_INFO = *mut CMSG_KEY_AGREE_RECIPIENT_INFO; +pub const CMSG_KEY_AGREE_ORIGINATOR_CERT: DWORD = 1; +pub const CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY: DWORD = 2; +STRUCT!{struct CMSG_MAIL_LIST_RECIPIENT_INFO { + dwVersion: DWORD, + KeyId: CRYPT_DATA_BLOB, + KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + EncryptedKey: CRYPT_DATA_BLOB, + Date: FILETIME, + pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE, +}} +pub type PCMSG_MAIL_LIST_RECIPIENT_INFO = *mut CMSG_MAIL_LIST_RECIPIENT_INFO; +UNION!{union CMSG_CMS_RECIPIENT_INFO_u { + [usize; 1], + pKeyTrans pKeyTrans_mut: PCMSG_KEY_TRANS_RECIPIENT_INFO, + pKeyAgree pKeyAgree_mut: PCMSG_KEY_AGREE_RECIPIENT_INFO, + pMailList pMailList_mut: PCMSG_MAIL_LIST_RECIPIENT_INFO, +}} +STRUCT!{struct CMSG_CMS_RECIPIENT_INFO { + dwRecipientChoice: DWORD, + u: CMSG_CMS_RECIPIENT_INFO_u, +}} +pub type PCMSG_CMS_RECIPIENT_INFO = *mut CMSG_CMS_RECIPIENT_INFO; +pub const CMSG_ENVELOPED_RECIPIENT_V0: DWORD = 0; +pub const CMSG_ENVELOPED_RECIPIENT_V2: DWORD = 2; +pub const CMSG_ENVELOPED_RECIPIENT_V3: DWORD = 3; +pub const CMSG_ENVELOPED_RECIPIENT_V4: DWORD = 4; +pub const CMSG_KEY_TRANS_PKCS_1_5_VERSION: DWORD = CMSG_ENVELOPED_RECIPIENT_V0; +pub const CMSG_KEY_TRANS_CMS_VERSION: DWORD = CMSG_ENVELOPED_RECIPIENT_V2; +pub const CMSG_KEY_AGREE_VERSION: DWORD = CMSG_ENVELOPED_RECIPIENT_V3; +pub const CMSG_MAIL_LIST_VERSION: DWORD = CMSG_ENVELOPED_RECIPIENT_V4; +extern "system" { + pub fn CryptMsgControl( + hCryptMsg: HCRYPTMSG, + dwFlags: DWORD, + dwCtrlType: DWORD, + pvCtrlPara: *const c_void, + ) -> BOOL; +} +pub const CMSG_CTRL_VERIFY_SIGNATURE: DWORD = 1; +pub const CMSG_CTRL_DECRYPT: DWORD = 2; +pub const CMSG_CTRL_VERIFY_HASH: DWORD = 5; +pub const CMSG_CTRL_ADD_SIGNER: DWORD = 6; +pub const CMSG_CTRL_DEL_SIGNER: DWORD = 7; +pub const CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR: DWORD = 8; +pub const CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR: DWORD = 9; +pub const CMSG_CTRL_ADD_CERT: DWORD = 10; +pub const CMSG_CTRL_DEL_CERT: DWORD = 11; +pub const CMSG_CTRL_ADD_CRL: DWORD = 12; +pub const CMSG_CTRL_DEL_CRL: DWORD = 13; +pub const CMSG_CTRL_ADD_ATTR_CERT: DWORD = 14; +pub const CMSG_CTRL_DEL_ATTR_CERT: DWORD = 15; +pub const CMSG_CTRL_KEY_TRANS_DECRYPT: DWORD = 16; +pub const CMSG_CTRL_KEY_AGREE_DECRYPT: DWORD = 17; +pub const CMSG_CTRL_MAIL_LIST_DECRYPT: DWORD = 18; +pub const CMSG_CTRL_VERIFY_SIGNATURE_EX: DWORD = 19; +pub const CMSG_CTRL_ADD_CMS_SIGNER_INFO: DWORD = 20; +pub const CMSG_CTRL_ENABLE_STRONG_SIGNATURE: DWORD = 21; +STRUCT!{struct CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA { + cbSize: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + dwSignerIndex: DWORD, + dwSignerType: DWORD, + pvSigner: *mut c_void, +}} +pub type PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA = *mut CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA; +pub const CMSG_VERIFY_SIGNER_PUBKEY: DWORD = 1; +pub const CMSG_VERIFY_SIGNER_CERT: DWORD = 2; +pub const CMSG_VERIFY_SIGNER_CHAIN: DWORD = 3; +pub const CMSG_VERIFY_SIGNER_NULL: DWORD = 4; +UNION!{union CMSG_CTRL_DECRYPT_PARA_u { + [usize; 1], + hCryptProv hCryptProv_mut: HCRYPTPROV, + hNCryptKey hNCryptKey_mut: NCRYPT_KEY_HANDLE, +}} +STRUCT!{struct CMSG_CTRL_DECRYPT_PARA { + cbSize: DWORD, + u: CMSG_CTRL_DECRYPT_PARA_u, + dwKeySpec: DWORD, + dwRecipientIndex: DWORD, +}} +pub type PCMSG_CTRL_DECRYPT_PARA = *mut CMSG_CTRL_DECRYPT_PARA; +UNION!{union CMSG_CTRL_KEY_TRANS_DECRYPT_PARA_u { + [usize; 1], + hCryptProv hCryptProv_mut: HCRYPTPROV, + hNCryptKey hNCryptKey_mut: NCRYPT_KEY_HANDLE, +}} +STRUCT!{struct CMSG_CTRL_KEY_TRANS_DECRYPT_PARA { + cbSize: DWORD, + u: CMSG_CTRL_KEY_TRANS_DECRYPT_PARA_u, + dwKeySpec: DWORD, + pKeyTrans: PCMSG_KEY_TRANS_RECIPIENT_INFO, + dwRecipientIndex: DWORD, +}} +pub type PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA = *mut CMSG_CTRL_KEY_TRANS_DECRYPT_PARA; +UNION!{union CMSG_CTRL_KEY_AGREE_DECRYPT_PARA_u { + [usize; 1], + hCryptProv hCryptProv_mut: HCRYPTPROV, + hNCryptKey hNCryptKey_mut: NCRYPT_KEY_HANDLE, +}} +STRUCT!{struct CMSG_CTRL_KEY_AGREE_DECRYPT_PARA { + cbSize: DWORD, + u: CMSG_CTRL_KEY_AGREE_DECRYPT_PARA_u, + dwKeySpec: DWORD, + pKeyAgree: PCMSG_KEY_AGREE_RECIPIENT_INFO, + dwRecipientIndex: DWORD, + dwRecipientEncryptedKeyIndex: DWORD, + OriginatorPublicKey: CRYPT_BIT_BLOB, +}} +pub type PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA = *mut CMSG_CTRL_KEY_AGREE_DECRYPT_PARA; +UNION!{union CMSG_CTRL_MAIL_LIST_DECRYPT_PARA_u { + [usize; 1], + hKeyEncryptionKey hKeyEncryptionKey_mut: HCRYPTKEY, + pvKeyEncryptionKey pvKeyEncryptionKey_mut: *mut c_void, +}} +STRUCT!{struct CMSG_CTRL_MAIL_LIST_DECRYPT_PARA { + cbSize: DWORD, + hCryptProv: HCRYPTPROV, + pMailList: PCMSG_MAIL_LIST_RECIPIENT_INFO, + dwRecipientIndex: DWORD, + dwKeyChoice: DWORD, + u: CMSG_CTRL_MAIL_LIST_DECRYPT_PARA_u, +}} +pub type PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA = *mut CMSG_CTRL_MAIL_LIST_DECRYPT_PARA; +STRUCT!{struct CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA { + cbSize: DWORD, + dwSignerIndex: DWORD, + blob: CRYPT_DATA_BLOB, +}} +pub type PCMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA = *mut CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA; +STRUCT!{struct CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA { + cbSize: DWORD, + dwSignerIndex: DWORD, + dwUnauthAttrIndex: DWORD, +}} +pub type PCMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA = *mut CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA; +extern "system" { + pub fn CryptMsgVerifyCountersignatureEncoded( + hCryptProv: HCRYPTPROV_LEGACY, + dwEncodingType: DWORD, + pbSignerInfo: PBYTE, + cbSignerInfo: DWORD, + pbSignerInfoCountersignature: PBYTE, + cbSignerInfoCountersignature: DWORD, + pciCountersigner: PCERT_INFO, + ) -> BOOL; + pub fn CryptMsgVerifyCountersignatureEncodedEx( + hCryptProv: HCRYPTPROV_LEGACY, + dwEncodingType: DWORD, + pbSignerInfo: PBYTE, + cbSignerInfo: DWORD, + pbSignerInfoCountersignature: PBYTE, + cbSignerInfoCountersignature: DWORD, + dwSignerType: DWORD, + pvSigner: *mut c_void, + dwFlags: DWORD, + pvExtra: *mut c_void, + ) -> BOOL; +} +pub const CMSG_VERIFY_COUNTER_SIGN_ENABLE_STRONG_FLAG: DWORD = 0x00000001; +extern "system" { + pub fn CryptMsgCountersign( + hCryptMsg: HCRYPTMSG, + dwIndex: DWORD, + cCountersigners: DWORD, + rgCountersigners: PCMSG_SIGNER_ENCODE_INFO, + ) -> BOOL; + pub fn CryptMsgCountersignEncoded( + dwEncodingType: DWORD, + pbSignerInfo: PBYTE, + cbSignerInfo: DWORD, + cCountersigners: DWORD, + rgCountersigners: PCMSG_SIGNER_ENCODE_INFO, + pbCountersignature: PBYTE, + pcbCountersignature: PDWORD, + ) -> BOOL; +} +FN!{stdcall PFN_CMSG_ALLOC( + cb: size_t, +) -> ()} +FN!{stdcall PFN_CMSG_FREE( + pv: *mut c_void, +) -> ()} +pub const CMSG_OID_GEN_ENCRYPT_KEY_FUNC: &'static str = "CryptMsgDllGenEncryptKey"; +FN!{stdcall PFN_CMSG_GEN_ENCRYPT_KEY( + phCryptProv: *mut HCRYPTPROV, + paiEncrypt: PCRYPT_ALGORITHM_IDENTIFIER, + pvEncryptAuxInfo: PVOID, + pPublicKeyInfo: PCERT_PUBLIC_KEY_INFO, + pfnAlloc: PFN_CMSG_ALLOC, + phEncryptKey: *mut HCRYPTKEY, + ppbEncryptParameters: *mut PBYTE, + pcbEncryptParameters: PDWORD, +) -> BOOL} +pub const CMSG_OID_EXPORT_ENCRYPT_KEY_FUNC: &'static str = "CryptMsgDllExportEncryptKey"; +FN!{stdcall PFN_CMSG_EXPORT_ENCRYPT_KEY( + hCryptProv: HCRYPTPROV, + hEncryptKey: HCRYPTKEY, + pPublicKeyInfo: PCERT_PUBLIC_KEY_INFO, + pbData: PBYTE, + pcbData: PDWORD, +) -> BOOL} +pub const CMSG_OID_IMPORT_ENCRYPT_KEY_FUNC: &'static str = "CryptMsgDllImportEncryptKey"; +FN!{stdcall PFN_CMSG_IMPORT_ENCRYPT_KEY( + hCryptProv: HCRYPTPROV, + dwKeySpec: DWORD, + paiEncrypt: PCRYPT_ALGORITHM_IDENTIFIER, + paiPubKey: PCRYPT_ALGORITHM_IDENTIFIER, + pbEncodedKey: PBYTE, + cbEncodedKey: DWORD, + phEncryptKey: *mut HCRYPTKEY, +) -> BOOL} +pub const CMSG_DEFAULT_INSTALLABLE_FUNC_OID: LPCSTR = 1 as LPCSTR; +UNION!{union CMSG_CONTENT_ENCRYPT_INFO_u { + [usize; 1], + hContentEncryptKey hContentEncryptKey_mut: HCRYPTKEY, + hCNGContentEncryptKey hCNGContentEncryptKey_mut: BCRYPT_KEY_HANDLE, +}} +STRUCT!{struct CMSG_CONTENT_ENCRYPT_INFO { + cbSize: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvEncryptionAuxInfo: *mut c_void, + cRecipients: DWORD, + rgCmsRecipients: PCMSG_RECIPIENT_ENCODE_INFO, + pfnAlloc: PFN_CMSG_ALLOC, + pfnFree: PFN_CMSG_FREE, + dwEncryptFlags: DWORD, + u: CMSG_CONTENT_ENCRYPT_INFO_u, + dwFlags: DWORD, + fCNG: BOOL, + pbCNGContentEncryptKeyObject: *mut BYTE, + pbContentEncryptKey: *mut BYTE, + cbContentEncryptKey: DWORD, +}} +pub type PCMSG_CONTENT_ENCRYPT_INFO = *mut CMSG_CONTENT_ENCRYPT_INFO; +pub const CMSG_CONTENT_ENCRYPT_PAD_ENCODED_LEN_FLAG: DWORD = 0x00000001; +pub const CMSG_CONTENT_ENCRYPT_FREE_PARA_FLAG: DWORD = 0x00000001; +pub const CMSG_CONTENT_ENCRYPT_FREE_OBJID_FLAG: DWORD = 0x00000002; +pub const CMSG_CONTENT_ENCRYPT_RELEASE_CONTEXT_FLAG: DWORD = 0x00008000; +pub const CMSG_OID_GEN_CONTENT_ENCRYPT_KEY_FUNC: &'static str = "CryptMsgDllGenContentEncryptKey"; +pub const CMSG_OID_CAPI1_GEN_CONTENT_ENCRYPT_KEY_FUNC: &'static str + = CMSG_OID_GEN_CONTENT_ENCRYPT_KEY_FUNC; +FN!{stdcall PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY( + pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO, + dwFlags: DWORD, + pvReserved: *mut c_void, +) -> BOOL} +pub const CMSG_OID_CNG_GEN_CONTENT_ENCRYPT_KEY_FUNC: &'static str + = "CryptMsgDllCNGGenContentEncryptKey"; +STRUCT!{struct CMSG_KEY_TRANS_ENCRYPT_INFO { + cbSize: DWORD, + dwRecipientIndex: DWORD, + KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + EncryptedKey: CRYPT_DATA_BLOB, + dwFlags: DWORD, +}} +pub type PCMSG_KEY_TRANS_ENCRYPT_INFO = *mut CMSG_KEY_TRANS_ENCRYPT_INFO; +pub const CMSG_KEY_TRANS_ENCRYPT_FREE_PARA_FLAG: DWORD = 0x00000001; +pub const CMSG_KEY_TRANS_ENCRYPT_FREE_OBJID_FLAG: DWORD = 0x00000002; +pub const CMSG_OID_EXPORT_KEY_TRANS_FUNC: &'static str = "CryptMsgDllExportKeyTrans"; +pub const CMSG_OID_CAPI1_EXPORT_KEY_TRANS_FUNC: &'static str = CMSG_OID_EXPORT_KEY_TRANS_FUNC; +FN!{stdcall PFN_CMSG_EXPORT_KEY_TRANS( + pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO, + pKeyTransEncodeInfo: PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO, + pKeyTransEncryptInfo: PCMSG_KEY_TRANS_ENCRYPT_INFO, + dwFlags: DWORD, + pvReserved: *mut c_void, +) -> BOOL} +pub const CMSG_OID_CNG_EXPORT_KEY_TRANS_FUNC: &'static str = "CryptMsgDllCNGExportKeyTrans"; +STRUCT!{struct CMSG_KEY_AGREE_KEY_ENCRYPT_INFO { + cbSize: DWORD, + EncryptedKey: CRYPT_DATA_BLOB, +}} +pub type PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO = *mut CMSG_KEY_AGREE_KEY_ENCRYPT_INFO; +UNION!{union CMSG_KEY_AGREE_ENCRYPT_INFO_u { + [usize; 6], + OriginatorCertId OriginatorCertId_mut: CERT_ID, + OriginatorPublicKeyInfo OriginatorPublicKeyInfo_mut: CERT_PUBLIC_KEY_INFO, +}} +STRUCT!{struct CMSG_KEY_AGREE_ENCRYPT_INFO { + cbSize: DWORD, + dwRecipientIndex: DWORD, + KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + UserKeyingMaterial: CRYPT_DATA_BLOB, + dwOriginatorChoice: DWORD, + u: CMSG_KEY_AGREE_ENCRYPT_INFO_u, + cKeyAgreeKeyEncryptInfo: DWORD, + rgpKeyAgreeKeyEncryptInfo: *mut PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO, + dwFlags: DWORD, +}} +pub type PCMSG_KEY_AGREE_ENCRYPT_INFO = *mut CMSG_KEY_AGREE_ENCRYPT_INFO; +pub const CMSG_KEY_AGREE_ENCRYPT_FREE_PARA_FLAG: DWORD = 0x00000001; +pub const CMSG_KEY_AGREE_ENCRYPT_FREE_MATERIAL_FLAG: DWORD = 0x00000002; +pub const CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_ALG_FLAG: DWORD = 0x00000004; +pub const CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_PARA_FLAG: DWORD = 0x00000008; +pub const CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_BITS_FLAG: DWORD = 0x00000010; +pub const CMSG_KEY_AGREE_ENCRYPT_FREE_OBJID_FLAG: DWORD = 0x00000020; +pub const CMSG_OID_EXPORT_KEY_AGREE_FUNC: &'static str = "CryptMsgDllExportKeyAgree"; +pub const CMSG_OID_CAPI1_EXPORT_KEY_AGREE_FUNC: &'static str = CMSG_OID_EXPORT_KEY_AGREE_FUNC; +FN!{stdcall PFN_CMSG_EXPORT_KEY_AGREE( + pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO, + pKeyAgreeEncodeInfo: PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO, + pKeyAgreeEncryptInfo: PCMSG_KEY_AGREE_ENCRYPT_INFO, + dwFlags: DWORD, + pvReserved: *mut c_void, +) -> BOOL} +pub const CMSG_OID_CNG_EXPORT_KEY_AGREE_FUNC: &'static str = "CryptMsgDllCNGExportKeyAgree"; +STRUCT!{struct CMSG_MAIL_LIST_ENCRYPT_INFO { + cbSize: DWORD, + dwRecipientIndex: DWORD, + KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + EncryptedKey: CRYPT_DATA_BLOB, + dwFlags: DWORD, +}} +pub type PCMSG_MAIL_LIST_ENCRYPT_INFO = *mut CMSG_MAIL_LIST_ENCRYPT_INFO; +pub const CMSG_MAIL_LIST_ENCRYPT_FREE_PARA_FLAG: DWORD = 0x00000001; +pub const CMSG_MAIL_LIST_ENCRYPT_FREE_OBJID_FLAG: DWORD = 0x00000002; +pub const CMSG_OID_EXPORT_MAIL_LIST_FUNC: &'static str = "CryptMsgDllExportMailList"; +pub const CMSG_OID_CAPI1_EXPORT_MAIL_LIST_FUNC: &'static str = CMSG_OID_EXPORT_MAIL_LIST_FUNC; +FN!{stdcall PFN_CMSG_EXPORT_MAIL_LIST( + pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO, + pMailListEncodeInfo: PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO, + pMailListEncryptInfo: PCMSG_MAIL_LIST_ENCRYPT_INFO, + dwFlags: DWORD, + pvReserved: *mut c_void, +) -> BOOL} +pub const CMSG_OID_IMPORT_KEY_TRANS_FUNC: &'static str = "CryptMsgDllImportKeyTrans"; +pub const CMSG_OID_CAPI1_IMPORT_KEY_TRANS_FUNC: &'static str = CMSG_OID_IMPORT_KEY_TRANS_FUNC; +FN!{stdcall PFN_CMSG_IMPORT_KEY_TRANS( + pContentEncryptionAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER, + pKeyTransDecryptPara: PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA, + dwFlags: DWORD, + pvReserved: *mut c_void, + phContentEncryptKey: *mut HCRYPTKEY, +) -> BOOL} +pub const CMSG_OID_IMPORT_KEY_AGREE_FUNC: &'static str = "CryptMsgDllImportKeyAgree"; +pub const CMSG_OID_CAPI1_IMPORT_KEY_AGREE_FUNC: &'static str = CMSG_OID_IMPORT_KEY_AGREE_FUNC; +FN!{stdcall PFN_CMSG_IMPORT_KEY_AGREE( + pContentEncryptionAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER, + pKeyAgreeDecryptPara: PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA, + dwFlags: DWORD, + pvReserved: *mut c_void, + phContentEncryptKey: *mut HCRYPTKEY, +) -> BOOL} +pub const CMSG_OID_IMPORT_MAIL_LIST_FUNC: &'static str = "CryptMsgDllImportMailList"; +pub const CMSG_OID_CAPI1_IMPORT_MAIL_LIST_FUNC: &'static str = CMSG_OID_IMPORT_MAIL_LIST_FUNC; +FN!{stdcall PFN_CMSG_IMPORT_MAIL_LIST( + pContentEncryptionAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER, + pMailListDecryptPara: PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA, + dwFlags: DWORD, + pvReserved: *mut c_void, + phContentEncryptKey: *mut HCRYPTKEY, +) -> BOOL} +STRUCT!{struct CMSG_CNG_CONTENT_DECRYPT_INFO { + cbSize: DWORD, + ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pfnAlloc: PFN_CMSG_ALLOC, + pfnFree: PFN_CMSG_FREE, + hNCryptKey: NCRYPT_KEY_HANDLE, + pbContentEncryptKey: *mut BYTE, + cbContentEncryptKey: DWORD, + hCNGContentEncryptKey: BCRYPT_KEY_HANDLE, + pbCNGContentEncryptKeyObject: *mut BYTE, +}} +pub type PCMSG_CNG_CONTENT_DECRYPT_INFO = *mut CMSG_CNG_CONTENT_DECRYPT_INFO; +pub const CMSG_OID_CNG_IMPORT_KEY_TRANS_FUNC: &'static str = "CryptMsgDllCNGImportKeyTrans"; +FN!{stdcall PFN_CMSG_CNG_IMPORT_KEY_TRANS( + pCNGContentDecryptInfo: PCMSG_CNG_CONTENT_DECRYPT_INFO, + pKeyTransDecryptPara: PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA, + dwFlags: DWORD, + pvReserved: *mut c_void, +) -> BOOL} +pub const CMSG_OID_CNG_IMPORT_KEY_AGREE_FUNC: &'static str = "CryptMsgDllCNGImportKeyAgree"; +FN!{stdcall PFN_CMSG_CNG_IMPORT_KEY_AGREE( + pCNGContentDecryptInfo: PCMSG_CNG_CONTENT_DECRYPT_INFO, + pKeyAgreeDecryptPara: PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA, + dwFlags: DWORD, + pvReserved: *mut c_void, +) -> BOOL} +pub const CMSG_OID_CNG_IMPORT_CONTENT_ENCRYPT_KEY_FUNC: &'static str + = "CryptMsgDllCNGImportContentEncryptKey"; +FN!{stdcall PFN_CMSG_CNG_IMPORT_CONTENT_ENCRYPT_KEY( + pCNGContentDecryptInfo: PCMSG_CNG_CONTENT_DECRYPT_INFO, + dwFlags: DWORD, + pvReserved: *mut c_void, +) -> BOOL} +pub type HCERTSTORE = *mut c_void; +STRUCT!{struct CERT_CONTEXT { + dwCertEncodingType: DWORD, + pbCertEncoded: *mut BYTE, + cbCertEncoded: DWORD, + pCertInfo: PCERT_INFO, + hCertStore: HCERTSTORE, +}} +pub type PCERT_CONTEXT = *mut CERT_CONTEXT; +pub type PCCERT_CONTEXT = *const CERT_CONTEXT; +STRUCT!{struct CRL_CONTEXT { + dwCertEncodingType: DWORD, + pbCrlEncoded: *mut BYTE, + cbCrlEncoded: DWORD, + pCrlInfo: PCRL_INFO, + hCertStore: HCERTSTORE, +}} +pub type PCRL_CONTEXT = *mut CRL_CONTEXT; +pub type PCCRL_CONTEXT = *const CRL_CONTEXT; +STRUCT!{struct CTL_CONTEXT { + dwMsgAndCertEncodingType: DWORD, + pbCtlEncoded: *mut BYTE, + cbCtlEncoded: DWORD, + pCtlInfo: PCTL_INFO, + hCertStore: HCERTSTORE, + hCryptMsg: HCRYPTMSG, + pbCtlContent: *mut BYTE, + cbCtlContent: DWORD, +}} +pub type PCTL_CONTEXT = *mut CTL_CONTEXT; +pub type PCCTL_CONTEXT = *const CTL_CONTEXT; +pub const CERT_KEY_PROV_HANDLE_PROP_ID: DWORD = 1; +pub const CERT_KEY_PROV_INFO_PROP_ID: DWORD = 2; +pub const CERT_SHA1_HASH_PROP_ID: DWORD = 3; +pub const CERT_MD5_HASH_PROP_ID: DWORD = 4; +pub const CERT_HASH_PROP_ID: DWORD = CERT_SHA1_HASH_PROP_ID; +pub const CERT_KEY_CONTEXT_PROP_ID: DWORD = 5; +pub const CERT_KEY_SPEC_PROP_ID: DWORD = 6; +pub const CERT_IE30_RESERVED_PROP_ID: DWORD = 7; +pub const CERT_PUBKEY_HASH_RESERVED_PROP_ID: DWORD = 8; +pub const CERT_ENHKEY_USAGE_PROP_ID: DWORD = 9; +pub const CERT_CTL_USAGE_PROP_ID: DWORD = CERT_ENHKEY_USAGE_PROP_ID; +pub const CERT_NEXT_UPDATE_LOCATION_PROP_ID: DWORD = 10; +pub const CERT_FRIENDLY_NAME_PROP_ID: DWORD = 11; +pub const CERT_PVK_FILE_PROP_ID: DWORD = 12; +pub const CERT_DESCRIPTION_PROP_ID: DWORD = 13; +pub const CERT_ACCESS_STATE_PROP_ID: DWORD = 14; +pub const CERT_SIGNATURE_HASH_PROP_ID: DWORD = 15; +pub const CERT_SMART_CARD_DATA_PROP_ID: DWORD = 16; +pub const CERT_EFS_PROP_ID: DWORD = 17; +pub const CERT_FORTEZZA_DATA_PROP_ID: DWORD = 18; +pub const CERT_ARCHIVED_PROP_ID: DWORD = 19; +pub const CERT_KEY_IDENTIFIER_PROP_ID: DWORD = 20; +pub const CERT_AUTO_ENROLL_PROP_ID: DWORD = 21; +pub const CERT_PUBKEY_ALG_PARA_PROP_ID: DWORD = 22; +pub const CERT_CROSS_CERT_DIST_POINTS_PROP_ID: DWORD = 23; +pub const CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID: DWORD = 24; +pub const CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID: DWORD = 25; +pub const CERT_ENROLLMENT_PROP_ID: DWORD = 26; +pub const CERT_DATE_STAMP_PROP_ID: DWORD = 27; +pub const CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID: DWORD = 28; +pub const CERT_SUBJECT_NAME_MD5_HASH_PROP_ID: DWORD = 29; +pub const CERT_EXTENDED_ERROR_INFO_PROP_ID: DWORD = 30; +pub const CERT_RENEWAL_PROP_ID: DWORD = 64; +pub const CERT_ARCHIVED_KEY_HASH_PROP_ID: DWORD = 65; +pub const CERT_AUTO_ENROLL_RETRY_PROP_ID: DWORD = 66; +pub const CERT_AIA_URL_RETRIEVED_PROP_ID: DWORD = 67; +pub const CERT_AUTHORITY_INFO_ACCESS_PROP_ID: DWORD = 68; +pub const CERT_BACKED_UP_PROP_ID: DWORD = 69; +pub const CERT_OCSP_RESPONSE_PROP_ID: DWORD = 70; +pub const CERT_REQUEST_ORIGINATOR_PROP_ID: DWORD = 71; +pub const CERT_SOURCE_LOCATION_PROP_ID: DWORD = 72; +pub const CERT_SOURCE_URL_PROP_ID: DWORD = 73; +pub const CERT_NEW_KEY_PROP_ID: DWORD = 74; +pub const CERT_OCSP_CACHE_PREFIX_PROP_ID: DWORD = 75; +pub const CERT_SMART_CARD_ROOT_INFO_PROP_ID: DWORD = 76; +pub const CERT_NO_AUTO_EXPIRE_CHECK_PROP_ID: DWORD = 77; +pub const CERT_NCRYPT_KEY_HANDLE_PROP_ID: DWORD = 78; +pub const CERT_HCRYPTPROV_OR_NCRYPT_KEY_HANDLE_PROP_ID: DWORD = 79; +pub const CERT_SUBJECT_INFO_ACCESS_PROP_ID: DWORD = 80; +pub const CERT_CA_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID: DWORD = 81; +pub const CERT_CA_DISABLE_CRL_PROP_ID: DWORD = 82; +pub const CERT_ROOT_PROGRAM_CERT_POLICIES_PROP_ID: DWORD = 83; +pub const CERT_ROOT_PROGRAM_NAME_CONSTRAINTS_PROP_ID: DWORD = 84; +pub const CERT_SUBJECT_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID: DWORD = 85; +pub const CERT_SUBJECT_DISABLE_CRL_PROP_ID: DWORD = 86; +pub const CERT_CEP_PROP_ID: DWORD = 87; +pub const CERT_SIGN_HASH_CNG_ALG_PROP_ID: DWORD = 89; +pub const CERT_SCARD_PIN_ID_PROP_ID: DWORD = 90; +pub const CERT_SCARD_PIN_INFO_PROP_ID: DWORD = 91; +pub const CERT_SUBJECT_PUB_KEY_BIT_LENGTH_PROP_ID: DWORD = 92; +pub const CERT_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID: DWORD = 93; +pub const CERT_ISSUER_PUB_KEY_BIT_LENGTH_PROP_ID: DWORD = 94; +pub const CERT_ISSUER_CHAIN_SIGN_HASH_CNG_ALG_PROP_ID: DWORD = 95; +pub const CERT_ISSUER_CHAIN_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID: DWORD = 96; +pub const CERT_NO_EXPIRE_NOTIFICATION_PROP_ID: DWORD = 97; +pub const CERT_AUTH_ROOT_SHA256_HASH_PROP_ID: DWORD = 98; +pub const CERT_NCRYPT_KEY_HANDLE_TRANSFER_PROP_ID: DWORD = 99; +pub const CERT_HCRYPTPROV_TRANSFER_PROP_ID: DWORD = 100; +pub const CERT_SMART_CARD_READER_PROP_ID: DWORD = 101; +pub const CERT_SEND_AS_TRUSTED_ISSUER_PROP_ID: DWORD = 102; +pub const CERT_KEY_REPAIR_ATTEMPTED_PROP_ID: DWORD = 103; +pub const CERT_DISALLOWED_FILETIME_PROP_ID: DWORD = 104; +pub const CERT_ROOT_PROGRAM_CHAIN_POLICIES_PROP_ID: DWORD = 105; +pub const CERT_SMART_CARD_READER_NON_REMOVABLE_PROP_ID: DWORD = 106; +pub const CERT_SHA256_HASH_PROP_ID: DWORD = 107; +pub const CERT_SCEP_SERVER_CERTS_PROP_ID: DWORD = 108; +pub const CERT_SCEP_RA_SIGNATURE_CERT_PROP_ID: DWORD = 109; +pub const CERT_SCEP_RA_ENCRYPTION_CERT_PROP_ID: DWORD = 110; +pub const CERT_SCEP_CA_CERT_PROP_ID: DWORD = 111; +pub const CERT_SCEP_SIGNER_CERT_PROP_ID: DWORD = 112; +pub const CERT_SCEP_NONCE_PROP_ID: DWORD = 113; +pub const CERT_SCEP_ENCRYPT_HASH_CNG_ALG_PROP_ID: DWORD = 114; +pub const CERT_SCEP_FLAGS_PROP_ID: DWORD = 115; +pub const CERT_SCEP_GUID_PROP_ID: DWORD = 116; +pub const CERT_SERIALIZABLE_KEY_CONTEXT_PROP_ID: DWORD = 117; +pub const CERT_ISOLATED_KEY_PROP_ID: DWORD = 118; +pub const CERT_SERIAL_CHAIN_PROP_ID: DWORD = 119; +pub const CERT_KEY_CLASSIFICATION_PROP_ID: DWORD = 120; +pub const CERT_OCSP_MUST_STAPLE_PROP_ID: DWORD = 121; +pub const CERT_DISALLOWED_ENHKEY_USAGE_PROP_ID: DWORD = 122; +pub const CERT_NONCOMPLIANT_ROOT_URL_PROP_ID: DWORD = 123; +pub const CERT_PIN_SHA256_HASH_PROP_ID: DWORD = 124; +pub const CERT_CLR_DELETE_KEY_PROP_ID: DWORD = 125; +pub const CERT_NOT_BEFORE_FILETIME_PROP_ID: DWORD = 126; +pub const CERT_NOT_BEFORE_ENHKEY_USAGE_PROP_ID: DWORD = 127; +pub const CERT_FIRST_RESERVED_PROP_ID: DWORD = 128; +pub const CERT_LAST_RESERVED_PROP_ID: DWORD = 0x00007FFF; +pub const CERT_FIRST_USER_PROP_ID: DWORD = 0x00008000; +pub const CERT_LAST_USER_PROP_ID: DWORD = 0x0000FFFF; +ENUM!{enum CertKeyType { + KeyTypeOther = 0, + KeyTypeVirtualSmartCard = 1, + KeyTypePhysicalSmartCard = 2, + KeyTypePassport = 3, + KeyTypePassportRemote = 4, + KeyTypePassportSmartCard = 5, + KeyTypeHardware = 6, + KeyTypeSoftware = 7, + KeyTypeSelfSigned = 8, +}} +#[inline] +pub fn IS_CERT_HASH_PROP_ID(X: DWORD) -> bool { + CERT_SHA1_HASH_PROP_ID == X || CERT_MD5_HASH_PROP_ID == X || CERT_SHA256_HASH_PROP_ID == X + || CERT_SIGNATURE_HASH_PROP_ID == X +} +#[inline] +pub fn IS_PUBKEY_HASH_PROP_ID(X: DWORD) -> bool { + CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID == X || CERT_PIN_SHA256_HASH_PROP_ID == X + || CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID == X +} +#[inline] +pub fn IS_CHAIN_HASH_PROP_ID(X: DWORD) -> bool { + CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID == X || CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID == X + || CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID == X || CERT_SUBJECT_NAME_MD5_HASH_PROP_ID == X +} +#[inline] +pub fn IS_STRONG_SIGN_PROP_ID(X: DWORD) -> bool { + CERT_SIGN_HASH_CNG_ALG_PROP_ID == X || CERT_SUBJECT_PUB_KEY_BIT_LENGTH_PROP_ID == X + || CERT_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID == X +} +pub const szOID_CERT_PROP_ID_PREFIX: &'static str = "1.3.6.1.4.1.311.10.11."; +pub const szOID_CERT_KEY_IDENTIFIER_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.20"; +pub const szOID_CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID: &'static str + = "1.3.6.1.4.1.311.10.11.28"; +pub const szOID_CERT_SUBJECT_NAME_MD5_HASH_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.29"; +pub const szOID_CERT_MD5_HASH_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.4"; +pub const szOID_CERT_SIGNATURE_HASH_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.15"; +pub const szOID_DISALLOWED_HASH: &'static str = szOID_CERT_SIGNATURE_HASH_PROP_ID; +pub const szOID_CERT_DISALLOWED_FILETIME_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.104"; +pub const CERT_ACCESS_STATE_WRITE_PERSIST_FLAG: DWORD = 0x1; +pub const CERT_ACCESS_STATE_SYSTEM_STORE_FLAG: DWORD = 0x2; +pub const CERT_ACCESS_STATE_LM_SYSTEM_STORE_FLAG: DWORD = 0x4; +pub const CERT_ACCESS_STATE_GP_SYSTEM_STORE_FLAG: DWORD = 0x8; +pub const CERT_ACCESS_STATE_SHARED_USER_FLAG: DWORD = 0x10; +pub const szOID_ROOT_PROGRAM_AUTO_UPDATE_CA_REVOCATION: &'static str = "1.3.6.1.4.1.311.60.3.1"; +pub const szOID_ROOT_PROGRAM_AUTO_UPDATE_END_REVOCATION: &'static str = "1.3.6.1.4.1.311.60.3.2"; +pub const szOID_ROOT_PROGRAM_NO_OCSP_FAILOVER_TO_CRL: &'static str = "1.3.6.1.4.1.311.60.3.3"; +STRUCT!{struct CRYPT_KEY_PROV_PARAM { + dwParam: DWORD, + pbData: *mut BYTE, + cbData: DWORD, + dwFlags: DWORD, +}} +pub type PCRYPT_KEY_PROV_PARAM = *mut CRYPT_KEY_PROV_PARAM; +STRUCT!{struct CRYPT_KEY_PROV_INFO { + pwszContainerName: LPWSTR, + pwszProvName: LPWSTR, + dwProvType: DWORD, + dwFlags: DWORD, + cProvParam: DWORD, + rgProvParam: PCRYPT_KEY_PROV_PARAM, + dwKeySpec: DWORD, +}} +pub type PCRYPT_KEY_PROV_INFO = *mut CRYPT_KEY_PROV_INFO; +pub const CERT_SET_KEY_PROV_HANDLE_PROP_ID: DWORD = 0x00000001; +pub const CERT_SET_KEY_CONTEXT_PROP_ID: DWORD = 0x00000001; +pub const CERT_NCRYPT_KEY_SPEC: DWORD = 0xFFFFFFFF; +UNION!{union CERT_KEY_CONTEXT_u { + [usize; 1], + hCryptProv hCryptProv_mut: HCRYPTPROV, + hNCryptKey hNCryptKey_mut: NCRYPT_KEY_HANDLE, +}} +STRUCT!{struct CERT_KEY_CONTEXT { + cbSize: DWORD, + u: CERT_KEY_CONTEXT_u, + dwKeySpec: DWORD, +}} +pub type PCERT_KEY_CONTEXT = *mut CERT_KEY_CONTEXT; +STRUCT!{struct ROOT_INFO_LUID { + LowPart: DWORD, + HighPart: LONG, +}} +pub type PROOT_INFO_LUID = *mut ROOT_INFO_LUID; +STRUCT!{struct CRYPT_SMART_CARD_ROOT_INFO { + rgbCardID: [BYTE; 16], + luid: ROOT_INFO_LUID, +}} +pub type PCRYPT_SMART_CARD_ROOT_INFO = *mut CRYPT_SMART_CARD_ROOT_INFO; +pub const CERT_STORE_PROV_MSG: LPCSTR = 1 as LPCSTR; +pub const CERT_STORE_PROV_MEMORY: LPCSTR = 2 as LPCSTR; +pub const CERT_STORE_PROV_FILE: LPCSTR = 3 as LPCSTR; +pub const CERT_STORE_PROV_REG: LPCSTR = 4 as LPCSTR; +pub const CERT_STORE_PROV_PKCS7: LPCSTR = 5 as LPCSTR; +pub const CERT_STORE_PROV_SERIALIZED: LPCSTR = 6 as LPCSTR; +pub const CERT_STORE_PROV_FILENAME_A: LPCSTR = 7 as LPCSTR; +pub const CERT_STORE_PROV_FILENAME_W: LPCSTR = 8 as LPCSTR; +pub const CERT_STORE_PROV_FILENAME: LPCSTR = CERT_STORE_PROV_FILENAME_W; +pub const CERT_STORE_PROV_SYSTEM_A: LPCSTR = 9 as LPCSTR; +pub const CERT_STORE_PROV_SYSTEM_W: LPCSTR = 10 as LPCSTR; +pub const CERT_STORE_PROV_SYSTEM: LPCSTR = CERT_STORE_PROV_SYSTEM_W; +pub const CERT_STORE_PROV_COLLECTION: LPCSTR = 11 as LPCSTR; +pub const CERT_STORE_PROV_SYSTEM_REGISTRY_A: LPCSTR = 12 as LPCSTR; +pub const CERT_STORE_PROV_SYSTEM_REGISTRY_W: LPCSTR = 13 as LPCSTR; +pub const CERT_STORE_PROV_SYSTEM_REGISTRY: LPCSTR = CERT_STORE_PROV_SYSTEM_REGISTRY_W; +pub const CERT_STORE_PROV_PHYSICAL_W: LPCSTR = 14 as LPCSTR; +pub const CERT_STORE_PROV_PHYSICAL: LPCSTR = CERT_STORE_PROV_PHYSICAL_W; +pub const CERT_STORE_PROV_SMART_CARD_W: LPCSTR = 15 as LPCSTR; +pub const CERT_STORE_PROV_SMART_CARD: LPCSTR = CERT_STORE_PROV_SMART_CARD_W; +pub const CERT_STORE_PROV_LDAP_W: LPCSTR = 16 as LPCSTR; +pub const CERT_STORE_PROV_LDAP: LPCSTR = CERT_STORE_PROV_LDAP_W; +pub const CERT_STORE_PROV_PKCS12: LPCSTR = 17 as LPCSTR; +pub const sz_CERT_STORE_PROV_MEMORY: &'static str = "Memory"; +pub const sz_CERT_STORE_PROV_FILENAME_W: &'static str = "File"; +pub const sz_CERT_STORE_PROV_FILENAME: &'static str = sz_CERT_STORE_PROV_FILENAME_W; +pub const sz_CERT_STORE_PROV_SYSTEM_W: &'static str = "System"; +pub const sz_CERT_STORE_PROV_SYSTEM: &'static str = sz_CERT_STORE_PROV_SYSTEM_W; +pub const sz_CERT_STORE_PROV_PKCS7: &'static str = "PKCS7"; +pub const sz_CERT_STORE_PROV_PKCS12: &'static str = "PKCS12"; +pub const sz_CERT_STORE_PROV_SERIALIZED: &'static str = "Serialized"; +pub const sz_CERT_STORE_PROV_COLLECTION: &'static str = "Collection"; +pub const sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W: &'static str = "SystemRegistry"; +pub const sz_CERT_STORE_PROV_SYSTEM_REGISTRY: &'static str = sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W; +pub const sz_CERT_STORE_PROV_PHYSICAL_W: &'static str = "Physical"; +pub const sz_CERT_STORE_PROV_PHYSICAL: &'static str = sz_CERT_STORE_PROV_PHYSICAL_W; +pub const sz_CERT_STORE_PROV_SMART_CARD_W: &'static str = "SmartCard"; +pub const sz_CERT_STORE_PROV_SMART_CARD: &'static str = sz_CERT_STORE_PROV_SMART_CARD_W; +pub const sz_CERT_STORE_PROV_LDAP_W: &'static str = "Ldap"; +pub const sz_CERT_STORE_PROV_LDAP: &'static str = sz_CERT_STORE_PROV_LDAP_W; +pub const CERT_STORE_SIGNATURE_FLAG: DWORD = 0x00000001; +pub const CERT_STORE_TIME_VALIDITY_FLAG: DWORD = 0x00000002; +pub const CERT_STORE_REVOCATION_FLAG: DWORD = 0x00000004; +pub const CERT_STORE_NO_CRL_FLAG: DWORD = 0x00010000; +pub const CERT_STORE_NO_ISSUER_FLAG: DWORD = 0x00020000; +pub const CERT_STORE_BASE_CRL_FLAG: DWORD = 0x00000100; +pub const CERT_STORE_DELTA_CRL_FLAG: DWORD = 0x00000200; +pub const CERT_STORE_NO_CRYPT_RELEASE_FLAG: DWORD = 0x00000001; +pub const CERT_STORE_SET_LOCALIZED_NAME_FLAG: DWORD = 0x00000002; +pub const CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG: DWORD = 0x00000004; +pub const CERT_STORE_DELETE_FLAG: DWORD = 0x00000010; +pub const CERT_STORE_SHARE_STORE_FLAG: DWORD = 0x00000040; +pub const CERT_STORE_SHARE_CONTEXT_FLAG: DWORD = 0x00000080; +pub const CERT_STORE_MANIFOLD_FLAG: DWORD = 0x00000100; +pub const CERT_STORE_ENUM_ARCHIVED_FLAG: DWORD = 0x00000200; +pub const CERT_STORE_UPDATE_KEYID_FLAG: DWORD = 0x00000400; +pub const CERT_STORE_BACKUP_RESTORE_FLAG: DWORD = 0x00000800; +pub const CERT_STORE_READONLY_FLAG: DWORD = 0x00008000; +pub const CERT_STORE_OPEN_EXISTING_FLAG: DWORD = 0x00004000; +pub const CERT_STORE_CREATE_NEW_FLAG: DWORD = 0x00002000; +pub const CERT_STORE_MAXIMUM_ALLOWED_FLAG: DWORD = 0x00001000; +pub const CERT_SYSTEM_STORE_MASK: DWORD = 0xFFFF0000; +pub const CERT_SYSTEM_STORE_RELOCATE_FLAG: DWORD = 0x80000000; +UNION!{union CERT_SYSTEM_STORE_RELOCATE_PARA_u1 { + [usize; 1], + hKeyBase hKeyBase_mut: HKEY, + pvBase pvBase_mut: *mut c_void, +}} +UNION!{union CERT_SYSTEM_STORE_RELOCATE_PARA_u2 { + [usize; 1], + pvSystemStore pvSystemStore__mut: *mut c_void, + pszSystemStore pszSystemStore_mut: LPCSTR, + pwszSystemStore pwszSystemStore_mut: LPCWSTR, +}} +STRUCT!{struct CERT_SYSTEM_STORE_RELOCATE_PARA { + u1: CERT_SYSTEM_STORE_RELOCATE_PARA_u1, + u2: CERT_SYSTEM_STORE_RELOCATE_PARA_u2, +}} +pub type PCERT_SYSTEM_STORE_RELOCATE_PARA = *mut CERT_SYSTEM_STORE_RELOCATE_PARA; +pub const CERT_SYSTEM_STORE_UNPROTECTED_FLAG: DWORD = 0x40000000; +pub const CERT_SYSTEM_STORE_LOCATION_MASK: DWORD = 0x00FF0000; +pub const CERT_SYSTEM_STORE_LOCATION_SHIFT: DWORD = 16; +pub const CERT_SYSTEM_STORE_CURRENT_USER_ID: DWORD = 1; +pub const CERT_SYSTEM_STORE_LOCAL_MACHINE_ID: DWORD = 2; +pub const CERT_SYSTEM_STORE_CURRENT_SERVICE_ID: DWORD = 4; +pub const CERT_SYSTEM_STORE_SERVICES_ID: DWORD = 5; +pub const CERT_SYSTEM_STORE_USERS_ID: DWORD = 6; +pub const CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID: DWORD = 7; +pub const CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID: DWORD = 8; +pub const CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID: DWORD = 9; +pub const CERT_SYSTEM_STORE_CURRENT_USER: DWORD = CERT_SYSTEM_STORE_CURRENT_USER_ID + << CERT_SYSTEM_STORE_LOCATION_SHIFT; +pub const CERT_SYSTEM_STORE_LOCAL_MACHINE: DWORD = CERT_SYSTEM_STORE_LOCAL_MACHINE_ID + << CERT_SYSTEM_STORE_LOCATION_SHIFT; +pub const CERT_SYSTEM_STORE_CURRENT_SERVICE: DWORD = CERT_SYSTEM_STORE_CURRENT_SERVICE_ID + << CERT_SYSTEM_STORE_LOCATION_SHIFT; +pub const CERT_SYSTEM_STORE_SERVICES: DWORD = CERT_SYSTEM_STORE_SERVICES_ID + << CERT_SYSTEM_STORE_LOCATION_SHIFT; +pub const CERT_SYSTEM_STORE_USERS: DWORD = CERT_SYSTEM_STORE_USERS_ID + << CERT_SYSTEM_STORE_LOCATION_SHIFT; +pub const CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY: DWORD + = CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; +pub const CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY: DWORD + = CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; +pub const CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE: DWORD + = CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; +pub const CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH: &'static str + = "Software\\Policies\\Microsoft\\SystemCertificates"; +pub const CERT_EFSBLOB_REGPATH: &'static str + = "Software\\Policies\\Microsoft\\SystemCertificates\\EFS"; +pub const CERT_EFSBLOB_VALUE_NAME: &'static str = "EFSBlob"; +pub const CERT_PROT_ROOT_FLAGS_REGPATH: &'static str + = "Software\\Policies\\Microsoft\\SystemCertificates\\Root\\ProtectedRoots"; +pub const CERT_PROT_ROOT_FLAGS_VALUE_NAME: &'static str = "Flags"; +pub const CERT_PROT_ROOT_DISABLE_CURRENT_USER_FLAG: DWORD = 0x1; +pub const CERT_PROT_ROOT_INHIBIT_ADD_AT_INIT_FLAG: DWORD = 0x2; +pub const CERT_PROT_ROOT_INHIBIT_PURGE_LM_FLAG: DWORD = 0x4; +pub const CERT_PROT_ROOT_DISABLE_LM_AUTH_FLAG: DWORD = 0x8; +pub const CERT_PROT_ROOT_ONLY_LM_GPT_FLAG: DWORD = 0x8; +pub const CERT_PROT_ROOT_DISABLE_NT_AUTH_REQUIRED_FLAG: DWORD = 0x10; +pub const CERT_PROT_ROOT_DISABLE_NOT_DEFINED_NAME_CONSTRAINT_FLAG: DWORD = 0x20; +pub const CERT_PROT_ROOT_DISABLE_PEER_TRUST: DWORD = 0x10000; +pub const CERT_PROT_ROOT_PEER_USAGES_VALUE_NAME: &'static str = "PeerUsages"; +pub const CERT_PROT_ROOT_PEER_USAGES_VALUE_NAME_A: &'static str = "PeerUsages"; +pub const CERT_PROT_ROOT_PEER_USAGES_DEFAULT_A: &'static str + = "1.3.6.1.5.5.7.3.2\01.3.6.1.5.5.7.3.4\01.3.6.1.4.1.311.10.3.4\0"; +pub const CERT_TRUST_PUB_SAFER_GROUP_POLICY_REGPATH: &'static str + = "Software\\Policies\\Microsoft\\SystemCertificates\\TrustedPublisher\\Safer"; +pub const CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH: &'static str + = "Software\\Microsoft\\SystemCertificates"; +pub const CERT_TRUST_PUB_SAFER_LOCAL_MACHINE_REGPATH: &'static str + = "Software\\Microsoft\\SystemCertificates\\TrustedPublisher\\Safer"; +pub const CERT_TRUST_PUB_AUTHENTICODE_FLAGS_VALUE_NAME: &'static str = "AuthenticodeFlags"; +pub const CERT_TRUST_PUB_ALLOW_TRUST_MASK: DWORD = 0x00000003; +pub const CERT_TRUST_PUB_ALLOW_END_USER_TRUST: DWORD = 0x00000000; +pub const CERT_TRUST_PUB_ALLOW_MACHINE_ADMIN_TRUST: DWORD = 0x00000001; +pub const CERT_TRUST_PUB_ALLOW_ENTERPRISE_ADMIN_TRUST: DWORD = 0x00000002; +pub const CERT_TRUST_PUB_CHECK_PUBLISHER_REV_FLAG: DWORD = 0x00000100; +pub const CERT_TRUST_PUB_CHECK_TIMESTAMP_REV_FLAG: DWORD = 0x00000200; +pub const CERT_OCM_SUBCOMPONENTS_LOCAL_MACHINE_REGPATH: &'static str + = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\OC Manager\\Subcomponents"; +pub const CERT_OCM_SUBCOMPONENTS_ROOT_AUTO_UPDATE_VALUE_NAME: &'static str = "RootAutoUpdate"; +pub const CERT_DISABLE_ROOT_AUTO_UPDATE_REGPATH: &'static str + = "Software\\Policies\\Microsoft\\SystemCertificates\\AuthRoot"; +pub const CERT_DISABLE_ROOT_AUTO_UPDATE_VALUE_NAME: &'static str = "DisableRootAutoUpdate"; +pub const CERT_ENABLE_DISALLOWED_CERT_AUTO_UPDATE_VALUE_NAME: &'static str + = "EnableDisallowedCertAutoUpdate"; +pub const CERT_DISABLE_PIN_RULES_AUTO_UPDATE_VALUE_NAME: &'static str + = "DisablePinRulesAutoUpdate"; +pub const CERT_AUTO_UPDATE_LOCAL_MACHINE_REGPATH: &'static str + = "Software\\Microsoft\\SystemCertificates\\AuthRoot\\AutoUpdate"; +pub const CERT_AUTO_UPDATE_ROOT_DIR_URL_VALUE_NAME: &'static str = "RootDirUrl"; +pub const CERT_AUTO_UPDATE_SYNC_FROM_DIR_URL_VALUE_NAME: &'static str = "SyncFromDirUrl"; +pub const CERT_AUTH_ROOT_AUTO_UPDATE_LOCAL_MACHINE_REGPATH: &'static str + = CERT_AUTO_UPDATE_LOCAL_MACHINE_REGPATH; +pub const CERT_AUTH_ROOT_AUTO_UPDATE_ROOT_DIR_URL_VALUE_NAME: &'static str + = CERT_AUTO_UPDATE_ROOT_DIR_URL_VALUE_NAME; +pub const CERT_AUTH_ROOT_AUTO_UPDATE_SYNC_DELTA_TIME_VALUE_NAME: &'static str = "SyncDeltaTime"; +pub const CERT_AUTH_ROOT_AUTO_UPDATE_FLAGS_VALUE_NAME: &'static str = "Flags"; +pub const CERT_AUTH_ROOT_AUTO_UPDATE_DISABLE_UNTRUSTED_ROOT_LOGGING_FLAG: DWORD = 0x1; +pub const CERT_AUTH_ROOT_AUTO_UPDATE_DISABLE_PARTIAL_CHAIN_LOGGING_FLAG: DWORD = 0x2; +pub const CERT_AUTO_UPDATE_DISABLE_RANDOM_QUERY_STRING_FLAG: DWORD = 0x4; +pub const CERT_AUTH_ROOT_AUTO_UPDATE_LAST_SYNC_TIME_VALUE_NAME: &'static str = "LastSyncTime"; +pub const CERT_AUTH_ROOT_AUTO_UPDATE_ENCODED_CTL_VALUE_NAME: &'static str = "EncodedCt"; +pub const CERT_AUTH_ROOT_CTL_FILENAME: &'static str = "authroot.st"; +pub const CERT_AUTH_ROOT_CTL_FILENAME_A: &'static str = "authroot.st"; +pub const CERT_AUTH_ROOT_CAB_FILENAME: &'static str = "authrootstl.cab"; +pub const CERT_AUTH_ROOT_SEQ_FILENAME: &'static str = "authrootseq.txt"; +pub const CERT_AUTH_ROOT_CERT_EXT: &'static str = ".crt"; +pub const CERT_DISALLOWED_CERT_AUTO_UPDATE_SYNC_DELTA_TIME_VALUE_NAME: &'static str + = "DisallowedCertSyncDeltaTime"; +pub const CERT_DISALLOWED_CERT_AUTO_UPDATE_LAST_SYNC_TIME_VALUE_NAME: &'static str + = "DisallowedCertLastSyncTime"; +pub const CERT_DISALLOWED_CERT_AUTO_UPDATE_ENCODED_CTL_VALUE_NAME: &'static str + = "DisallowedCertEncodedCt"; +pub const CERT_DISALLOWED_CERT_CTL_FILENAME: &'static str = "disallowedcert.st"; +pub const CERT_DISALLOWED_CERT_CTL_FILENAME_A: &'static str = "disallowedcert.st"; +pub const CERT_DISALLOWED_CERT_CAB_FILENAME: &'static str = "disallowedcertstl.cab"; +pub const CERT_DISALLOWED_CERT_AUTO_UPDATE_LIST_IDENTIFIER: &'static str + = "DisallowedCert_AutoUpdate_1"; +pub const CERT_PIN_RULES_AUTO_UPDATE_SYNC_DELTA_TIME_VALUE_NAME: &'static str + = "PinRulesSyncDeltaTime"; +pub const CERT_PIN_RULES_AUTO_UPDATE_LAST_SYNC_TIME_VALUE_NAME: &'static str + = "PinRulesLastSyncTime"; +pub const CERT_PIN_RULES_AUTO_UPDATE_ENCODED_CTL_VALUE_NAME: &'static str = "PinRulesEncodedCt"; +pub const CERT_PIN_RULES_CTL_FILENAME: &'static str = "pinrules.st"; +pub const CERT_PIN_RULES_CTL_FILENAME_A: &'static str = "pinrules.st"; +pub const CERT_PIN_RULES_CAB_FILENAME: &'static str = "pinrulesstl.cab"; +pub const CERT_PIN_RULES_AUTO_UPDATE_LIST_IDENTIFIER: &'static str = "PinRules_AutoUpdate_1"; +pub const CERT_REGISTRY_STORE_REMOTE_FLAG: DWORD = 0x10000; +pub const CERT_REGISTRY_STORE_SERIALIZED_FLAG: DWORD = 0x20000; +pub const CERT_REGISTRY_STORE_CLIENT_GPT_FLAG: DWORD = 0x80000000; +pub const CERT_REGISTRY_STORE_LM_GPT_FLAG: DWORD = 0x01000000; +STRUCT!{struct CERT_REGISTRY_STORE_CLIENT_GPT_PARA { + hKeyBase: HKEY, + pwszRegPath: LPWSTR, +}} +pub type PCERT_REGISTRY_STORE_CLIENT_GPT_PARA = *mut CERT_REGISTRY_STORE_CLIENT_GPT_PARA; +pub const CERT_REGISTRY_STORE_ROAMING_FLAG: DWORD = 0x40000; +STRUCT!{struct CERT_REGISTRY_STORE_ROAMING_PARA { + hKeyBase: HKEY, + pwszStoreDirectory: LPWSTR, +}} +pub type PCERT_REGISTRY_STORE_ROAMING_PARA = *mut CERT_REGISTRY_STORE_ROAMING_PARA; +pub const CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG: DWORD = 0x80000; +pub const CERT_REGISTRY_STORE_EXTERNAL_FLAG: DWORD = 0x100000; +pub const CERT_IE_DIRTY_FLAGS_REGPATH: &'static str + = "Software\\Microsoft\\Cryptography\\IEDirtyFlags"; +pub const CERT_FILE_STORE_COMMIT_ENABLE_FLAG: DWORD = 0x10000; +pub const CERT_LDAP_STORE_SIGN_FLAG: DWORD = 0x10000; +pub const CERT_LDAP_STORE_AREC_EXCLUSIVE_FLAG: DWORD = 0x20000; +pub const CERT_LDAP_STORE_OPENED_FLAG: DWORD = 0x40000; +STRUCT!{struct CERT_LDAP_STORE_OPENED_PARA { + pvLdapSessionHandle: *mut c_void, + pwszLdapUrl: LPCWSTR, +}} +pub type PCERT_LDAP_STORE_OPENED_PARA = *mut CERT_LDAP_STORE_OPENED_PARA; +pub const CERT_LDAP_STORE_UNBIND_FLAG: DWORD = 0x80000; +extern "system" { + pub fn CertOpenStore( + lpszStoreProvider: LPCSTR, + dwEncodingType: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + dwFlags: DWORD, + pvPara: *const c_void, + ) -> HCERTSTORE; +} +pub type HCERTSTOREPROV = *mut c_void; +pub const CRYPT_OID_OPEN_STORE_PROV_FUNC: &'static str = "CertDllOpenStoreProv"; +STRUCT!{struct CERT_STORE_PROV_INFO { + cbSize: DWORD, + cStoreProvFunc: DWORD, + rgpvStoreProvFunc: *mut *mut c_void, + hStoreProv: HCERTSTOREPROV, + dwStoreProvFlags: DWORD, + hStoreProvFuncAddr2: HCRYPTOIDFUNCADDR, +}} +pub type PCERT_STORE_PROV_INFO = *mut CERT_STORE_PROV_INFO; +FN!{stdcall PFN_CERT_DLL_OPEN_STORE_PROV_FUNC( + lpszStoreProvider: LPCSTR, + dwEncodingType: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + dwFlags: DWORD, + pvPara: *const c_void, + hCertStore: HCERTSTORE, + pStoreProvInfo: PCERT_STORE_PROV_INFO, +) -> BOOL} +pub const CERT_STORE_PROV_EXTERNAL_FLAG: DWORD = 0x1; +pub const CERT_STORE_PROV_DELETED_FLAG: DWORD = 0x2; +pub const CERT_STORE_PROV_NO_PERSIST_FLAG: DWORD = 0x4; +pub const CERT_STORE_PROV_SYSTEM_STORE_FLAG: DWORD = 0x8; +pub const CERT_STORE_PROV_LM_SYSTEM_STORE_FLAG: DWORD = 0x10; +pub const CERT_STORE_PROV_GP_SYSTEM_STORE_FLAG: DWORD = 0x20; +pub const CERT_STORE_PROV_SHARED_USER_FLAG: DWORD = 0x40; +pub const CERT_STORE_PROV_CLOSE_FUNC: DWORD = 0; +pub const CERT_STORE_PROV_READ_CERT_FUNC: DWORD = 1; +pub const CERT_STORE_PROV_WRITE_CERT_FUNC: DWORD = 2; +pub const CERT_STORE_PROV_DELETE_CERT_FUNC: DWORD = 3; +pub const CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC: DWORD = 4; +pub const CERT_STORE_PROV_READ_CRL_FUNC: DWORD = 5; +pub const CERT_STORE_PROV_WRITE_CRL_FUNC: DWORD = 6; +pub const CERT_STORE_PROV_DELETE_CRL_FUNC: DWORD = 7; +pub const CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC: DWORD = 8; +pub const CERT_STORE_PROV_READ_CTL_FUNC: DWORD = 9; +pub const CERT_STORE_PROV_WRITE_CTL_FUNC: DWORD = 10; +pub const CERT_STORE_PROV_DELETE_CTL_FUNC: DWORD = 11; +pub const CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC: DWORD = 12; +pub const CERT_STORE_PROV_CONTROL_FUNC: DWORD = 13; +pub const CERT_STORE_PROV_FIND_CERT_FUNC: DWORD = 14; +pub const CERT_STORE_PROV_FREE_FIND_CERT_FUNC: DWORD = 15; +pub const CERT_STORE_PROV_GET_CERT_PROPERTY_FUNC: DWORD = 16; +pub const CERT_STORE_PROV_FIND_CRL_FUNC: DWORD = 17; +pub const CERT_STORE_PROV_FREE_FIND_CRL_FUNC: DWORD = 18; +pub const CERT_STORE_PROV_GET_CRL_PROPERTY_FUNC: DWORD = 19; +pub const CERT_STORE_PROV_FIND_CTL_FUNC: DWORD = 20; +pub const CERT_STORE_PROV_FREE_FIND_CTL_FUNC: DWORD = 21; +pub const CERT_STORE_PROV_GET_CTL_PROPERTY_FUNC: DWORD = 22; +FN!{stdcall PFN_CERT_STORE_PROV_CLOSE( + hStoreProv: HCERTSTOREPROV, + dwFlags: DWORD, +) -> ()} +FN!{stdcall PFN_CERT_STORE_PROV_READ_CERT( + hStoreProv: HCERTSTOREPROV, + pStoreCertContext: PCCERT_CONTEXT, + dwFlags: DWORD, + ppProvCertContext: *mut PCCERT_CONTEXT, +) -> BOOL} +pub const CERT_STORE_PROV_WRITE_ADD_FLAG: DWORD = 0x1; +FN!{stdcall PFN_CERT_STORE_PROV_WRITE_CERT( + hStoreProv: HCERTSTOREPROV, + pCertContext: PCCERT_CONTEXT, + dwFlags: DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_DELETE_CERT( + hStoreProv: HCERTSTOREPROV, + pCertContext: PCCERT_CONTEXT, + dwFlags: DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_SET_CERT_PROPERTY( + hStoreProv: HCERTSTOREPROV, + pCertContext: PCCERT_CONTEXT, + dwPropId: DWORD, + dwFlags: DWORD, + pvData: *const c_void, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_READ_CRL( + hStoreProv: HCERTSTOREPROV, + pStoreCrlContext: PCCRL_CONTEXT, + dwFlags: DWORD, + ppProvCrlContext: *mut PCCRL_CONTEXT, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_WRITE_CRL( + hStoreProv: HCERTSTOREPROV, + pCrlContext: PCCRL_CONTEXT, + dwFlags: DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_DELETE_CRL( + hStoreProv: HCERTSTOREPROV, + pCrlContext: PCCRL_CONTEXT, + dwFlags: DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_SET_CRL_PROPERTY( + hStoreProv: HCERTSTOREPROV, + pCrlContext: PCCRL_CONTEXT, + dwPropId: DWORD, + dwFlags: DWORD, + pvData: *const c_void, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_READ_CTL( + hStoreProv: HCERTSTOREPROV, + pStoreCtlContext: PCCTL_CONTEXT, + dwFlags: DWORD, + ppProvCtlContext: *mut PCCTL_CONTEXT, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_WRITE_CTL( + hStoreProv: HCERTSTOREPROV, + pCtlContext: PCCTL_CONTEXT, + dwFlags: DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_DELETE_CTL( + hStoreProv: HCERTSTOREPROV, + pCtlContext: PCCTL_CONTEXT, + dwFlags: DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_SET_CTL_PROPERTY( + hStoreProv: HCERTSTOREPROV, + pCtlContext: PCCTL_CONTEXT, + dwPropId: DWORD, + dwFlags: DWORD, + pvData: *const c_void, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_CONTROL( + hStoreProv: HCERTSTOREPROV, + dwFlags: DWORD, + dwCtrlType: DWORD, + pvCtrlPara: *const c_void, +) -> BOOL} +STRUCT!{struct CERT_STORE_PROV_FIND_INFO { + cbSize: DWORD, + dwMsgAndCertEncodingType: DWORD, + dwFindFlags: DWORD, + dwFindType: DWORD, + pvFindPara: *const c_void, +}} +pub type PCERT_STORE_PROV_FIND_INFO = *mut CERT_STORE_PROV_FIND_INFO; +pub type CCERT_STORE_PROV_FIND_INFO = CERT_STORE_PROV_FIND_INFO; +pub type PCCERT_STORE_PROV_FIND_INFO = *const CERT_STORE_PROV_FIND_INFO; +FN!{stdcall PFN_CERT_STORE_PROV_FIND_CERT( + hStoreProv: HCERTSTOREPROV, + pFindInfo: PCCERT_STORE_PROV_FIND_INFO, + pPrevCertContext: PCCERT_CONTEXT, + dwFlags: DWORD, + ppvStoreProvFindInfo: *mut *mut c_void, + ppProvCertContext: *mut PCCERT_CONTEXT, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_FREE_FIND_CERT( + hStoreProv: HCERTSTOREPROV, + pCertContext: PCCERT_CONTEXT, + pvStoreProvFindInfo: *mut c_void, + dwFlags: DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_GET_CERT_PROPERTY( + hStoreProv: HCERTSTOREPROV, + pCertContext: PCCERT_CONTEXT, + dwPropId: DWORD, + dwFlags: DWORD, + pvData: *mut c_void, + pcbData: *mut DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_FIND_CRL( + hStoreProv: HCERTSTOREPROV, + pFindInfo: PCCERT_STORE_PROV_FIND_INFO, + pPrevCrlContext: PCCRL_CONTEXT, + dwFlags: DWORD, + ppvStoreProvFindInfo: *mut *mut c_void, + ppProvCrlContext: *mut PCCRL_CONTEXT, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_FREE_FIND_CRL( + hStoreProv: HCERTSTOREPROV, + pCrlContext: PCCRL_CONTEXT, + pvStoreProvFindInfo: *mut c_void, + dwFlags: DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_GET_CRL_PROPERTY( + hStoreProv: HCERTSTOREPROV, + pCrlContext: PCCRL_CONTEXT, + dwPropId: DWORD, + dwFlags: DWORD, + pvData: *mut c_void, + pcbData: *mut DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_FIND_CTL( + hStoreProv: HCERTSTOREPROV, + pFindInfo: PCCERT_STORE_PROV_FIND_INFO, + pPrevCtlContext: PCCTL_CONTEXT, + dwFlags: DWORD, + ppvStoreProvFindInfo: *mut *mut c_void, + ppProvCtlContext: *mut PCCTL_CONTEXT, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_FREE_FIND_CTL( + hStoreProv: HCERTSTOREPROV, + pCtlContext: PCCTL_CONTEXT, + pvStoreProvFindInfo: *mut c_void, + dwFlags: DWORD, +) -> BOOL} +FN!{stdcall PFN_CERT_STORE_PROV_GET_CTL_PROPERTY( + hStoreProv: HCERTSTOREPROV, + pCtlContext: PCCTL_CONTEXT, + dwPropId: DWORD, + dwFlags: DWORD, + pvData: *mut c_void, + pcbData: *mut DWORD, +) -> BOOL} +extern "system" { + pub fn CertDuplicateStore( + hCertStore: HCERTSTORE, + ) -> HCERTSTORE; +} +pub const CERT_STORE_SAVE_AS_STORE: DWORD = 1; +pub const CERT_STORE_SAVE_AS_PKCS7: DWORD = 2; +pub const CERT_STORE_SAVE_AS_PKCS12: DWORD = 3; +pub const CERT_STORE_SAVE_TO_FILE: DWORD = 1; +pub const CERT_STORE_SAVE_TO_MEMORY: DWORD = 2; +pub const CERT_STORE_SAVE_TO_FILENAME_A: DWORD = 3; +pub const CERT_STORE_SAVE_TO_FILENAME_W: DWORD = 4; +pub const CERT_STORE_SAVE_TO_FILENAME: DWORD = CERT_STORE_SAVE_TO_FILENAME_W; +extern "system" { + pub fn CertSaveStore( + hCertStore: HCERTSTORE, + dwEncodingType: DWORD, + dwSaveAs: DWORD, + dwSaveTo: DWORD, + pvSaveToPara: *mut c_void, + dwFlags: DWORD, + ) -> BOOL; +} +pub const CERT_CLOSE_STORE_FORCE_FLAG: DWORD = 0x00000001; +pub const CERT_CLOSE_STORE_CHECK_FLAG: DWORD = 0x00000002; +extern "system" { + pub fn CertCloseStore( + hCertStore: HCERTSTORE, + dwFlags: DWORD, + ) -> BOOL; + pub fn CertGetSubjectCertificateFromStore( + hCertStore: HCERTSTORE, + dwCertEncodingType: DWORD, + pCertId: PCERT_INFO, + ) -> PCCERT_CONTEXT; + pub fn CertEnumCertificatesInStore( + hCertStore: HCERTSTORE, + pPrevCertContext: PCCERT_CONTEXT, + ) -> PCCERT_CONTEXT; + pub fn CertFindCertificateInStore( + hCertStore: HCERTSTORE, + dwCertEncodingType: DWORD, + dwFindFlags: DWORD, + dwFindType: DWORD, + pvFindPara: *const c_void, + pPrevCertContext: PCCERT_CONTEXT, + ) -> PCCERT_CONTEXT; +} +pub const CERT_COMPARE_MASK: DWORD = 0xFFFF; +pub const CERT_COMPARE_SHIFT: DWORD = 16; +pub const CERT_COMPARE_ANY: DWORD = 0; +pub const CERT_COMPARE_SHA1_HASH: DWORD = 1; +pub const CERT_COMPARE_NAME: DWORD = 2; +pub const CERT_COMPARE_ATTR: DWORD = 3; +pub const CERT_COMPARE_MD5_HASH: DWORD = 4; +pub const CERT_COMPARE_PROPERTY: DWORD = 5; +pub const CERT_COMPARE_PUBLIC_KEY: DWORD = 6; +pub const CERT_COMPARE_HASH: DWORD = CERT_COMPARE_SHA1_HASH; +pub const CERT_COMPARE_NAME_STR_A: DWORD = 7; +pub const CERT_COMPARE_NAME_STR_W: DWORD = 8; +pub const CERT_COMPARE_KEY_SPEC: DWORD = 9; +pub const CERT_COMPARE_ENHKEY_USAGE: DWORD = 10; +pub const CERT_COMPARE_CTL_USAGE: DWORD = CERT_COMPARE_ENHKEY_USAGE; +pub const CERT_COMPARE_SUBJECT_CERT: DWORD = 11; +pub const CERT_COMPARE_ISSUER_OF: DWORD = 12; +pub const CERT_COMPARE_EXISTING: DWORD = 13; +pub const CERT_COMPARE_SIGNATURE_HASH: DWORD = 14; +pub const CERT_COMPARE_KEY_IDENTIFIER: DWORD = 15; +pub const CERT_COMPARE_CERT_ID: DWORD = 16; +pub const CERT_COMPARE_CROSS_CERT_DIST_POINTS: DWORD = 17; +pub const CERT_COMPARE_PUBKEY_MD5_HASH: DWORD = 18; +pub const CERT_COMPARE_SUBJECT_INFO_ACCESS: DWORD = 19; +pub const CERT_COMPARE_HASH_STR: DWORD = 20; +pub const CERT_COMPARE_HAS_PRIVATE_KEY: DWORD = 21; +pub const CERT_FIND_ANY: DWORD = CERT_COMPARE_ANY << CERT_COMPARE_SHIFT; +pub const CERT_FIND_SHA1_HASH: DWORD = CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT; +pub const CERT_FIND_MD5_HASH: DWORD = CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT; +pub const CERT_FIND_SIGNATURE_HASH: DWORD = CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT; +pub const CERT_FIND_KEY_IDENTIFIER: DWORD = CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT; +pub const CERT_FIND_HASH: DWORD = CERT_FIND_SHA1_HASH; +pub const CERT_FIND_PROPERTY: DWORD = CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT; +pub const CERT_FIND_PUBLIC_KEY: DWORD = CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT; +pub const CERT_FIND_SUBJECT_NAME: DWORD = (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT) + | CERT_INFO_SUBJECT_FLAG; +pub const CERT_FIND_SUBJECT_ATTR: DWORD = (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT) + | CERT_INFO_SUBJECT_FLAG; +pub const CERT_FIND_ISSUER_NAME: DWORD = (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT) + | CERT_INFO_ISSUER_FLAG; +pub const CERT_FIND_ISSUER_ATTR: DWORD = (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT) + | CERT_INFO_ISSUER_FLAG; +pub const CERT_FIND_SUBJECT_STR_A: DWORD = (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT) + | CERT_INFO_SUBJECT_FLAG; +pub const CERT_FIND_SUBJECT_STR_W: DWORD = (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT) + | CERT_INFO_SUBJECT_FLAG; +pub const CERT_FIND_SUBJECT_STR: DWORD = CERT_FIND_SUBJECT_STR_W; +pub const CERT_FIND_ISSUER_STR_A: DWORD = (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT) + | CERT_INFO_ISSUER_FLAG; +pub const CERT_FIND_ISSUER_STR_W: DWORD = (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT) + | CERT_INFO_ISSUER_FLAG; +pub const CERT_FIND_ISSUER_STR: DWORD = CERT_FIND_ISSUER_STR_W; +pub const CERT_FIND_KEY_SPEC: DWORD = CERT_COMPARE_KEY_SPEC << CERT_COMPARE_SHIFT; +pub const CERT_FIND_ENHKEY_USAGE: DWORD = CERT_COMPARE_ENHKEY_USAGE << CERT_COMPARE_SHIFT; +pub const CERT_FIND_CTL_USAGE: DWORD = CERT_FIND_ENHKEY_USAGE; +pub const CERT_FIND_SUBJECT_CERT: DWORD = CERT_COMPARE_SUBJECT_CERT << CERT_COMPARE_SHIFT; +pub const CERT_FIND_ISSUER_OF: DWORD = CERT_COMPARE_ISSUER_OF << CERT_COMPARE_SHIFT; +pub const CERT_FIND_EXISTING: DWORD = CERT_COMPARE_EXISTING << CERT_COMPARE_SHIFT; +pub const CERT_FIND_CERT_ID: DWORD = CERT_COMPARE_CERT_ID << CERT_COMPARE_SHIFT; +pub const CERT_FIND_CROSS_CERT_DIST_POINTS: DWORD = CERT_COMPARE_CROSS_CERT_DIST_POINTS + << CERT_COMPARE_SHIFT; +pub const CERT_FIND_PUBKEY_MD5_HASH: DWORD = CERT_COMPARE_PUBKEY_MD5_HASH << CERT_COMPARE_SHIFT; +pub const CERT_FIND_SUBJECT_INFO_ACCESS: DWORD = CERT_COMPARE_SUBJECT_INFO_ACCESS + << CERT_COMPARE_SHIFT; +pub const CERT_FIND_HASH_STR: DWORD = CERT_COMPARE_HASH_STR << CERT_COMPARE_SHIFT; +pub const CERT_FIND_HAS_PRIVATE_KEY: DWORD = CERT_COMPARE_HAS_PRIVATE_KEY << CERT_COMPARE_SHIFT; +pub const CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG: DWORD = 0x1; +pub const CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG: DWORD = 0x2; +pub const CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG: DWORD = 0x4; +pub const CERT_FIND_NO_ENHKEY_USAGE_FLAG: DWORD = 0x8; +pub const CERT_FIND_OR_ENHKEY_USAGE_FLAG: DWORD = 0x10; +pub const CERT_FIND_VALID_ENHKEY_USAGE_FLAG: DWORD = 0x20; +pub const CERT_FIND_OPTIONAL_CTL_USAGE_FLAG: DWORD = CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG; +pub const CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG: DWORD = CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG; +pub const CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG: DWORD = CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG; +pub const CERT_FIND_NO_CTL_USAGE_FLAG: DWORD = CERT_FIND_NO_ENHKEY_USAGE_FLAG; +pub const CERT_FIND_OR_CTL_USAGE_FLAG: DWORD = CERT_FIND_OR_ENHKEY_USAGE_FLAG; +pub const CERT_FIND_VALID_CTL_USAGE_FLAG: DWORD = CERT_FIND_VALID_ENHKEY_USAGE_FLAG; +extern "system" { + pub fn CertGetIssuerCertificateFromStore( + hCertStore: HCERTSTORE, + pSubjectContext: PCCERT_CONTEXT, + pPrevIssuerContext: PCCERT_CONTEXT, + pdwFlags: *mut DWORD, + ) -> PCCERT_CONTEXT; + pub fn CertVerifySubjectCertificateContext( + pSubject: PCCERT_CONTEXT, + pIssuer: PCCERT_CONTEXT, + pdwFlags: *mut DWORD, + ) -> BOOL; + pub fn CertDuplicateCertificateContext( + pCertContext: PCCERT_CONTEXT, + ) -> PCCERT_CONTEXT; + pub fn CertCreateCertificateContext( + dwCertEncodingType: DWORD, + pbCertEncoded: *const BYTE, + cbCertEncoded: DWORD, + ) -> PCCERT_CONTEXT; + pub fn CertFreeCertificateContext( + pCertContext: PCCERT_CONTEXT, + ) -> BOOL; + pub fn CertSetCertificateContextProperty( + pCertContext: PCCERT_CONTEXT, + dwPropId: DWORD, + dwFlags: DWORD, + pvData: *const c_void, + ) -> BOOL; +} +pub const CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG: DWORD = 0x80000000; +pub const CERT_SET_PROPERTY_INHIBIT_PERSIST_FLAG: DWORD = 0x40000000; +extern "system" { + pub fn CertGetCertificateContextProperty( + pCertContext: PCCERT_CONTEXT, + dwPropId: DWORD, + pvData: *mut c_void, + pcbData: *mut DWORD, + ) -> BOOL; + pub fn CertEnumCertificateContextProperties( + pCertContext: PCCERT_CONTEXT, + dwPropId: DWORD, + ) -> DWORD; + pub fn CertCreateCTLEntryFromCertificateContextProperties( + pCertContext: PCCERT_CONTEXT, + cOptAttr: DWORD, + rgOptAttr: PCRYPT_ATTRIBUTE, + dwFlags: DWORD, + pvReserved: *mut c_void, + pCtlEntry: PCTL_ENTRY, + pcbCtlEntry: *mut DWORD, + ) -> BOOL; + pub fn CertSetCertificateContextPropertiesFromCTLEntry( + pCertContext: PCCERT_CONTEXT, + pCtlEntry: PCTL_ENTRY, + dwFlags: DWORD, + ) -> BOOL; + pub fn CertGetCRLFromStore( + hCertStore: HCERTSTORE, + pIssuerContext: PCCERT_CONTEXT, + pPrevCrlContext: PCCRL_CONTEXT, + pdwFlags: *mut DWORD, + ) -> PCCRL_CONTEXT; + pub fn CertEnumCRLsInStore( + hCertStore: HCERTSTORE, + pPrevCrlContext: PCCRL_CONTEXT, + ) -> PCCRL_CONTEXT; + pub fn CertFindCRLInStore( + hCertStore: HCERTSTORE, + dwCertEncodingType: DWORD, + dwFindFlags: DWORD, + dwFindType: DWORD, + pvFindPara: *const c_void, + pPrevCrlContext: PCCRL_CONTEXT, + ) -> PCCRL_CONTEXT; +} +pub const CRL_FIND_ANY: DWORD = 0; +pub const CRL_FIND_ISSUED_BY: DWORD = 1; +pub const CRL_FIND_EXISTING: DWORD = 2; +pub const CRL_FIND_ISSUED_FOR: DWORD = 3; +pub const CRL_FIND_ISSUED_BY_AKI_FLAG: DWORD = 0x1; +pub const CRL_FIND_ISSUED_BY_SIGNATURE_FLAG: DWORD = 0x2; +pub const CRL_FIND_ISSUED_BY_DELTA_FLAG: DWORD = 0x4; +pub const CRL_FIND_ISSUED_BY_BASE_FLAG: DWORD = 0x8; +STRUCT!{struct CRL_FIND_ISSUED_FOR_PARA { + pSubjectCert: PCCERT_CONTEXT, + pIssuerCert: PCCERT_CONTEXT, +}} +pub type PCRL_FIND_ISSUED_FOR_PARA = *mut CRL_FIND_ISSUED_FOR_PARA; +pub const CRL_FIND_ISSUED_FOR_SET_STRONG_PROPERTIES_FLAG: DWORD = 0x10; +extern "system" { + pub fn CertDuplicateCRLContext( + pCrlContext: PCCRL_CONTEXT, + ) -> PCCRL_CONTEXT; + pub fn CertCreateCRLContext( + dwCertEncodingType: DWORD, + pbCrlEncoded: *const BYTE, + cbCrlEncoded: DWORD, + ) -> PCCRL_CONTEXT; + pub fn CertFreeCRLContext( + pCrlContext: PCCRL_CONTEXT, + ) -> BOOL; + pub fn CertSetCRLContextProperty( + pCrlContext: PCCRL_CONTEXT, + dwPropId: DWORD, + dwFlags: DWORD, + pvData: *const c_void, + ) -> BOOL; + pub fn CertGetCRLContextProperty( + pCrlContext: PCCRL_CONTEXT, + dwPropId: DWORD, + pvData: *mut c_void, + pcbData: *mut DWORD, + ) -> BOOL; + pub fn CertEnumCRLContextProperties( + pCrlContext: PCCRL_CONTEXT, + dwPropId: DWORD, + ) -> DWORD; + pub fn CertFindCertificateInCRL( + pCert: PCCERT_CONTEXT, + pCrlContext: PCCRL_CONTEXT, + dwFlags: DWORD, + pvReserved: *mut c_void, + ppCrlEntry: *mut PCRL_ENTRY, + ) -> BOOL; + pub fn CertIsValidCRLForCertificate( + pCert: PCCERT_CONTEXT, + pCrl: PCCRL_CONTEXT, + dwFlags: DWORD, + pvReserved: *mut c_void, + ) -> BOOL; +} +pub const CERT_STORE_ADD_NEW: DWORD = 1; +pub const CERT_STORE_ADD_USE_EXISTING: DWORD = 2; +pub const CERT_STORE_ADD_REPLACE_EXISTING: DWORD = 3; +pub const CERT_STORE_ADD_ALWAYS: DWORD = 4; +pub const CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES: DWORD = 5; +pub const CERT_STORE_ADD_NEWER: DWORD = 6; +pub const CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES: DWORD = 7; +extern "system" { + pub fn CertAddEncodedCertificateToStore( + hCertStore: HCERTSTORE, + dwCertEncodingType: DWORD, + pbCertEncoded: *const BYTE, + cbCertEncoded: DWORD, + dwAddDisposition: DWORD, + ppCertContext: *mut PCCERT_CONTEXT, + ) -> BOOL; + pub fn CertAddCertificateContextToStore( + hCertStore: HCERTSTORE, + pCertContext: PCCERT_CONTEXT, + dwAddDisposition: DWORD, + ppStoreContext: *mut PCCERT_CONTEXT, + ) -> BOOL; +} +pub const CERT_STORE_CERTIFICATE_CONTEXT: DWORD = 1; +pub const CERT_STORE_CRL_CONTEXT: DWORD = 2; +pub const CERT_STORE_CTL_CONTEXT: DWORD = 3; +pub const CERT_STORE_ALL_CONTEXT_FLAG: DWORD = !0; +pub const CERT_STORE_CERTIFICATE_CONTEXT_FLAG: DWORD = 1 << CERT_STORE_CERTIFICATE_CONTEXT; +pub const CERT_STORE_CRL_CONTEXT_FLAG: DWORD = 1 << CERT_STORE_CRL_CONTEXT; +pub const CERT_STORE_CTL_CONTEXT_FLAG: DWORD = 1 << CERT_STORE_CTL_CONTEXT; +extern "system" { + pub fn CertAddSerializedElementToStore( + hCertStore: HCERTSTORE, + pbElement: *const BYTE, + cbElement: DWORD, + dwAddDisposition: DWORD, + dwFlags: DWORD, + dwContextTypeFlags: DWORD, + pdwContextType: *mut DWORD, + ppvContext: *mut *const c_void, + ) -> BOOL; + pub fn CertDeleteCertificateFromStore( + pCertContext: PCCERT_CONTEXT, + ) -> BOOL; + pub fn CertAddEncodedCRLToStore( + hCertStore: HCERTSTORE, + dwCertEncodingType: DWORD, + pbCrlEncoded: *const BYTE, + cbCrlEncoded: DWORD, + dwAddDisposition: DWORD, + ppCrlContext: *mut PCCRL_CONTEXT, + ) -> BOOL; + pub fn CertAddCRLContextToStore( + hCertStore: HCERTSTORE, + pCrlContext: PCCRL_CONTEXT, + dwAddDisposition: DWORD, + ppStoreContext: *mut PCCRL_CONTEXT, + ) -> BOOL; + pub fn CertDeleteCRLFromStore( + pCrlContext: PCCRL_CONTEXT, + ) -> BOOL; + pub fn CertSerializeCertificateStoreElement( + pCertContext: PCCERT_CONTEXT, + dwFlags: DWORD, + pbElement: *mut BYTE, + pcbElement: *mut DWORD, + ) -> BOOL; + pub fn CertSerializeCRLStoreElement( + pCrlContext: PCCRL_CONTEXT, + dwFlags: DWORD, + pbElement: *mut BYTE, + pcbElement: *mut DWORD, + ) -> BOOL; + pub fn CertDuplicateCTLContext( + pCtlContext: PCCTL_CONTEXT, + ) -> PCCTL_CONTEXT; + pub fn CertCreateCTLContext( + dwMsgAndCertEncodingType: DWORD, + pbCtlEncoded: *const BYTE, + cbCtlEncoded: DWORD, + ) -> PCCTL_CONTEXT; + pub fn CertFreeCTLContext( + pCtlContext: PCCTL_CONTEXT, + ) -> BOOL; + pub fn CertSetCTLContextProperty( + pCtlContext: PCCTL_CONTEXT, + dwPropId: DWORD, + dwFlags: DWORD, + pvData: *const c_void, + ) -> BOOL; + pub fn CertGetCTLContextProperty( + pCtlContext: PCCTL_CONTEXT, + dwPropId: DWORD, + pvData: *mut c_void, + pcbData: *mut DWORD, + ) -> BOOL; + pub fn CertEnumCTLContextProperties( + pCtlContext: PCCTL_CONTEXT, + dwPropId: DWORD, + ) -> DWORD; + pub fn CertEnumCTLsInStore( + hCertStore: HCERTSTORE, + pPrevCtlContext: PCCTL_CONTEXT, + ) -> PCCTL_CONTEXT; + pub fn CertFindSubjectInCTL( + dwEncodingType: DWORD, + dwSubjectType: DWORD, + pvSubject: *mut c_void, + pCtlContext: PCCTL_CONTEXT, + dwFlags: DWORD, + ) -> PCTL_ENTRY; +} +pub const CTL_ANY_SUBJECT_TYPE: DWORD = 1; +pub const CTL_CERT_SUBJECT_TYPE: DWORD = 2; +STRUCT!{struct CTL_ANY_SUBJECT_INFO { + SubjectAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + SubjectIdentifier: CRYPT_DATA_BLOB, +}} +pub type PCTL_ANY_SUBJECT_INFO = *mut CTL_ANY_SUBJECT_INFO; +extern "system" { + pub fn CertFindCTLInStore( + hCertStore: HCERTSTORE, + dwMsgAndCertEncodingType: DWORD, + dwFindFlags: DWORD, + dwFindType: DWORD, + pvFindPara: *const c_void, + pPrevCtlContext: PCCTL_CONTEXT, + ) -> PCCTL_CONTEXT; +} +pub const CTL_FIND_ANY: DWORD = 0; +pub const CTL_FIND_SHA1_HASH: DWORD = 1; +pub const CTL_FIND_MD5_HASH: DWORD = 2; +pub const CTL_FIND_USAGE: DWORD = 3; +pub const CTL_FIND_SUBJECT: DWORD = 4; +pub const CTL_FIND_EXISTING: DWORD = 5; +STRUCT!{struct CTL_FIND_USAGE_PARA { + cbSize: DWORD, + SubjectUsage: CTL_USAGE, + ListIdentifier: CRYPT_DATA_BLOB, + pSigner: PCERT_INFO, +}} +pub type PCTL_FIND_USAGE_PARA = *mut CTL_FIND_USAGE_PARA; +pub const CTL_FIND_NO_LIST_ID_CBDATA: DWORD = 0xFFFFFFFF; +pub const CTL_FIND_NO_SIGNER_PTR: PCERT_INFO = -1isize as PCERT_INFO; +pub const CTL_FIND_SAME_USAGE_FLAG: DWORD = 0x1; +STRUCT!{struct CTL_FIND_SUBJECT_PARA { + cbSize: DWORD, + pUsagePara: PCTL_FIND_USAGE_PARA, + dwSubjectType: DWORD, + pvSubject: *mut c_void, +}} +pub type PCTL_FIND_SUBJECT_PARA = *mut CTL_FIND_SUBJECT_PARA; +extern "system" { + pub fn CertAddEncodedCTLToStore( + hCertStore: HCERTSTORE, + dwMsgAndCertEncodingType: DWORD, + pbCtlEncoded: *const BYTE, + cbCtlEncoded: DWORD, + dwAddDisposition: DWORD, + ppCtlContext: *mut PCCTL_CONTEXT, + ) -> BOOL; + pub fn CertAddCTLContextToStore( + hCertStore: HCERTSTORE, + pCtlContext: PCCTL_CONTEXT, + dwAddDisposition: DWORD, + ppStoreContext: *mut PCCTL_CONTEXT, + ) -> BOOL; + pub fn CertSerializeCTLStoreElement( + pCtlContext: PCCTL_CONTEXT, + dwFlags: DWORD, + pbElement: *mut BYTE, + pcbElement: *mut DWORD, + ) -> BOOL; + pub fn CertDeleteCTLFromStore( + pCtlContext: PCCTL_CONTEXT, + ) -> BOOL; + pub fn CertAddCertificateLinkToStore( + hCertStore: HCERTSTORE, + pCertContext: PCCERT_CONTEXT, + dwAddDisposition: DWORD, + ppStoreContext: *mut PCCERT_CONTEXT, + ) -> BOOL; + pub fn CertAddCRLLinkToStore( + hCertStore: HCERTSTORE, + pCrlContext: PCCRL_CONTEXT, + dwAddDisposition: DWORD, + ppStoreContext: *mut PCCRL_CONTEXT, + ) -> BOOL; + pub fn CertAddCTLLinkToStore( + hCertStore: HCERTSTORE, + pCtlContext: PCCTL_CONTEXT, + dwAddDisposition: DWORD, + ppStoreContext: *mut PCCTL_CONTEXT, + ) -> BOOL; + pub fn CertAddStoreToCollection( + hCollectionStore: HCERTSTORE, + hSiblingStore: HCERTSTORE, + dwUpdateFlags: DWORD, + dwPriority: DWORD, + ) -> BOOL; + pub fn CertRemoveStoreFromCollection( + hCollectionStore: HCERTSTORE, + hSiblingStore: HCERTSTORE, + ); + pub fn CertControlStore( + hCertStore: HCERTSTORE, + dwFlags: DWORD, + dwCtrlType: DWORD, + pvCtrlPara: *const c_void, + ) -> BOOL; +} +pub const CERT_STORE_CTRL_RESYNC: DWORD = 1; +pub const CERT_STORE_CTRL_NOTIFY_CHANGE: DWORD = 2; +pub const CERT_STORE_CTRL_COMMIT: DWORD = 3; +pub const CERT_STORE_CTRL_AUTO_RESYNC: DWORD = 4; +pub const CERT_STORE_CTRL_CANCEL_NOTIFY: DWORD = 5; +pub const CERT_STORE_CTRL_INHIBIT_DUPLICATE_HANDLE_FLAG: DWORD = 0x1; +pub const CERT_STORE_CTRL_COMMIT_FORCE_FLAG: DWORD = 0x1; +pub const CERT_STORE_CTRL_COMMIT_CLEAR_FLAG: DWORD = 0x2; +pub const CERT_STORE_LOCALIZED_NAME_PROP_ID: DWORD = 0x1000; +extern "system" { + pub fn CertSetStoreProperty( + hCertStore: HCERTSTORE, + dwPropId: DWORD, + dwFlags: DWORD, + pvData: *const c_void, + ) -> BOOL; + pub fn CertGetStoreProperty( + hCertStore: HCERTSTORE, + dwPropId: DWORD, + pvData: *mut c_void, + pcbData: *mut DWORD, + ) -> BOOL; +} +FN!{stdcall PFN_CERT_CREATE_CONTEXT_SORT_FUNC( + cbTotalEncoded: DWORD, + cbRemainEncoded: DWORD, + cEntry: DWORD, + pvSort: *mut c_void, +) -> BOOL} +STRUCT!{struct CERT_CREATE_CONTEXT_PARA { + cbSize: DWORD, + pfnFree: PFN_CRYPT_FREE, + pvFree: *mut c_void, + pfnSort: PFN_CERT_CREATE_CONTEXT_SORT_FUNC, + pvSort: *mut c_void, +}} +pub type PCERT_CREATE_CONTEXT_PARA = *mut CERT_CREATE_CONTEXT_PARA; +extern "system" { + pub fn CertCreateContext( + dwContextType: DWORD, + dwEncodingType: DWORD, + pbEncoded: *const BYTE, + cbEncoded: DWORD, + dwFlags: DWORD, + pCreatePara: PCERT_CREATE_CONTEXT_PARA, + ) -> *const c_void; +} +pub const CERT_CREATE_CONTEXT_NOCOPY_FLAG: DWORD = 0x1; +pub const CERT_CREATE_CONTEXT_SORTED_FLAG: DWORD = 0x2; +pub const CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG: DWORD = 0x4; +pub const CERT_CREATE_CONTEXT_NO_ENTRY_FLAG: DWORD = 0x8; +STRUCT!{struct CERT_SYSTEM_STORE_INFO { + cbSize: DWORD, +}} +pub type PCERT_SYSTEM_STORE_INFO = *mut CERT_SYSTEM_STORE_INFO; +STRUCT!{struct CERT_PHYSICAL_STORE_INFO { + cbSize: DWORD, + pszOpenStoreProvider: LPSTR, + dwOpenEncodingType: DWORD, + dwOpenFlags: DWORD, + OpenParameters: CRYPT_DATA_BLOB, + dwFlags: DWORD, + dwPriority: DWORD, +}} +pub type PCERT_PHYSICAL_STORE_INFO = *mut CERT_PHYSICAL_STORE_INFO; +pub const CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG: DWORD = 0x1; +pub const CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG: DWORD = 0x2; +pub const CERT_PHYSICAL_STORE_REMOTE_OPEN_DISABLE_FLAG: DWORD = 0x4; +pub const CERT_PHYSICAL_STORE_INSERT_COMPUTER_NAME_ENABLE_FLAG: DWORD = 0x8; +extern "system" { + pub fn CertRegisterSystemStore( + pvSystemStore: *const c_void, + dwFlags: DWORD, + pStoreInfo: PCERT_SYSTEM_STORE_INFO, + pvReserved: *mut c_void, + ) -> BOOL; + pub fn CertRegisterPhysicalStore( + pvSystemStore: *const c_void, + dwFlags: DWORD, + pwszStoreName: LPCWSTR, + pStoreInfo: PCERT_PHYSICAL_STORE_INFO, + pvReserved: *mut c_void, + ) -> BOOL; + pub fn CertUnregisterSystemStore( + pvSystemStore: *const c_void, + dwFlags: DWORD, + ) -> BOOL; + pub fn CertUnregisterPhysicalStore( + pvSystemStore: *const c_void, + dwFlags: DWORD, + pwszStoreName: LPCWSTR, + ) -> BOOL; +} +FN!{stdcall PFN_CERT_ENUM_SYSTEM_STORE_LOCATION( + pwszStoreLocation: LPCWSTR, + dwFlags: DWORD, + pvReserved: *mut c_void, + pvArg: *mut c_void, +) -> BOOL} +FN!{stdcall PFN_CERT_ENUM_SYSTEM_STORE( + pvSystemStore: *const c_void, + dwFlags: DWORD, + pStoreInfo: PCERT_SYSTEM_STORE_INFO, + pvReserved: *mut c_void, + pvArg: *mut c_void, +) -> BOOL} +FN!{stdcall PFN_CERT_ENUM_PHYSICAL_STORE( + pvSystemStore: *const c_void, + dwFlags: DWORD, + pwszStoreName: LPCWSTR, + pStoreInfo: PCERT_PHYSICAL_STORE_INFO, + pvReserved: *mut c_void, + pvArg: *mut c_void, +) -> BOOL} +pub const CERT_PHYSICAL_STORE_PREDEFINED_ENUM_FLAG: DWORD = 0x1; +pub const CERT_PHYSICAL_STORE_DEFAULT_NAME: &'static str = ".Default"; +pub const CERT_PHYSICAL_STORE_GROUP_POLICY_NAME: &'static str = ".GroupPolicy"; +pub const CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME: &'static str = ".LocalMachine"; +pub const CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME: &'static str = ".UserCertificate"; +pub const CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME: &'static str + = ".LocalMachineGroupPolicy"; +pub const CERT_PHYSICAL_STORE_ENTERPRISE_NAME: &'static str = ".Enterprise"; +pub const CERT_PHYSICAL_STORE_AUTH_ROOT_NAME: &'static str = ".AuthRoot"; +pub const CERT_PHYSICAL_STORE_SMART_CARD_NAME: &'static str = ".SmartCard"; +extern "system" { + pub fn CertEnumSystemStoreLocation( + dwFlags: DWORD, + pvArg: *mut c_void, + pfnEnum: PFN_CERT_ENUM_SYSTEM_STORE_LOCATION, + ) -> BOOL; + pub fn CertEnumSystemStore( + dwFlags: DWORD, + pvSystemStoreLocationPara: *mut c_void, + pvArg: *mut c_void, + pfnEnum: PFN_CERT_ENUM_SYSTEM_STORE, + ) -> BOOL; + pub fn CertEnumPhysicalStore( + pvSystemStore: *const c_void, + dwFlags: DWORD, + pvArg: *mut c_void, + pfnEnum: PFN_CERT_ENUM_PHYSICAL_STORE, + ) -> BOOL; +} +pub const CRYPT_OID_OPEN_SYSTEM_STORE_PROV_FUNC: &'static str = "CertDllOpenSystemStoreProv"; +pub const CRYPT_OID_REGISTER_SYSTEM_STORE_FUNC: &'static str = "CertDllRegisterSystemStore"; +pub const CRYPT_OID_UNREGISTER_SYSTEM_STORE_FUNC: &'static str = "CertDllUnregisterSystemStore"; +pub const CRYPT_OID_ENUM_SYSTEM_STORE_FUNC: &'static str = "CertDllEnumSystemStore"; +pub const CRYPT_OID_REGISTER_PHYSICAL_STORE_FUNC: &'static str = "CertDllRegisterPhysicalStore"; +pub const CRYPT_OID_UNREGISTER_PHYSICAL_STORE_FUNC: &'static str + = "CertDllUnregisterPhysicalStore"; +pub const CRYPT_OID_ENUM_PHYSICAL_STORE_FUNC: &'static str = "CertDllEnumPhysicalStore"; +pub const CRYPT_OID_SYSTEM_STORE_LOCATION_VALUE_NAME: &'static str = "SystemStoreLocation"; +extern "system" { + pub fn CertGetEnhancedKeyUsage( + pCertContext: PCCERT_CONTEXT, + dwFlags: DWORD, + pUsage: PCERT_ENHKEY_USAGE, + pcbUsage: *mut DWORD, + ) -> BOOL; + pub fn CertSetEnhancedKeyUsage( + pCertContext: PCCERT_CONTEXT, + pUsage: PCERT_ENHKEY_USAGE, + ) -> BOOL; + pub fn CertAddEnhancedKeyUsageIdentifier( + pCertContext: PCCERT_CONTEXT, + pszUsageIdentifier: LPCSTR, + ) -> BOOL; + pub fn CertRemoveEnhancedKeyUsageIdentifier( + pCertContext: PCCERT_CONTEXT, + pszUsageIdentifier: LPCSTR, + ) -> BOOL; + pub fn CertGetValidUsages( + cCerts: DWORD, + rghCerts: *mut PCCERT_CONTEXT, + cNumOIDs: *mut c_int, + rghOIDs: *mut LPSTR, + pcbOIDs: *mut DWORD, + ) -> BOOL; + pub fn CryptMsgGetAndVerifySigner( + hCryptMsg: HCRYPTMSG, + cSignerStore: DWORD, + rghSignerStore: *mut HCERTSTORE, + dwFlags: DWORD, + ppSigner: *mut PCCERT_CONTEXT, + pdwSignerIndex: *mut DWORD, + ) -> BOOL; +} +pub const CMSG_TRUSTED_SIGNER_FLAG: DWORD = 0x1; +pub const CMSG_SIGNER_ONLY_FLAG: DWORD = 0x2; +pub const CMSG_USE_SIGNER_INDEX_FLAG: DWORD = 0x4; +extern "system" { + pub fn CryptMsgSignCTL( + dwMsgEncodingType: DWORD, + pbCtlContent: *mut BYTE, + cbCtlContent: DWORD, + pSignInfo: PCMSG_SIGNED_ENCODE_INFO, + dwFlags: DWORD, + pbEncoded: *mut BYTE, + pcbEncoded: *mut DWORD, + ) -> BOOL; + pub fn CryptMsgEncodeAndSignCTL( + dwMsgEncodingType: DWORD, + pCtlInfo: PCTL_INFO, + pSignInfo: PCMSG_SIGNED_ENCODE_INFO, + dwFlags: DWORD, + pbEncoded: *mut BYTE, + pcbEncoded: *mut DWORD, + ) -> BOOL; +} +pub const CMSG_ENCODE_SORTED_CTL_FLAG: DWORD = 0x1; +pub const CMSG_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG: DWORD = 0x2; +extern "system" { + pub fn CertFindSubjectInSortedCTL( + pSubjectIdentifier: PCRYPT_DATA_BLOB, + pCtlContext: PCCTL_CONTEXT, + dwFlags: DWORD, + pvReserved: *mut c_void, + pEncodedAttributes: PCRYPT_DER_BLOB, + ) -> BOOL; + pub fn CertEnumSubjectInSortedCTL( + pCtlContext: PCCTL_CONTEXT, + ppvNextSubject: *mut *mut c_void, + pSubjectIdentifier: PCRYPT_DER_BLOB, + pEncodedAttributes: PCRYPT_DER_BLOB, + ) -> BOOL; +} +STRUCT!{struct CTL_VERIFY_USAGE_PARA { + cbSize: DWORD, + ListIdentifier: CRYPT_DATA_BLOB, + cCtlStore: DWORD, + rghCtlStore: *mut HCERTSTORE, + cSignerStore: DWORD, + rghSignerStore: *mut HCERTSTORE, +}} +pub type PCTL_VERIFY_USAGE_PARA = *mut CTL_VERIFY_USAGE_PARA; +STRUCT!{struct CTL_VERIFY_USAGE_STATUS { + cbSize: DWORD, + dwError: DWORD, + dwFlags: DWORD, + ppCtl: *mut PCCTL_CONTEXT, + dwCtlEntryIndex: DWORD, + ppSigner: *mut PCCERT_CONTEXT, + dwSignerIndex: DWORD, +}} +pub type PCTL_VERIFY_USAGE_STATUS = *mut CTL_VERIFY_USAGE_STATUS; +pub const CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG: DWORD = 0x1; +pub const CERT_VERIFY_TRUSTED_SIGNERS_FLAG: DWORD = 0x2; +pub const CERT_VERIFY_NO_TIME_CHECK_FLAG: DWORD = 0x4; +pub const CERT_VERIFY_ALLOW_MORE_USAGE_FLAG: DWORD = 0x8; +pub const CERT_VERIFY_UPDATED_CTL_FLAG: DWORD = 0x1; +extern "system" { + pub fn CertVerifyCTLUsage( + dwEncodingType: DWORD, + dwSubjectType: DWORD, + pvSubject: *mut c_void, + pSubjectUsage: PCTL_USAGE, + dwFlags: DWORD, + pVerifyUsagePara: PCTL_VERIFY_USAGE_PARA, + pVerifyUsageStatus: PCTL_VERIFY_USAGE_STATUS, + ) -> BOOL; +} +STRUCT!{struct CERT_REVOCATION_CRL_INFO { + cbSize: DWORD, + pBaseCrlContext: PCCRL_CONTEXT, + pDeltaCrlContext: PCCRL_CONTEXT, + pCrlEntry: PCRL_ENTRY, + fDeltaCrlEntry: BOOL, +}} +pub type PCERT_REVOCATION_CRL_INFO = *mut CERT_REVOCATION_CRL_INFO; +pub type PCERT_REVOCATION_CHAIN_PARA = *mut CERT_REVOCATION_CHAIN_PARA; +STRUCT!{struct CERT_REVOCATION_PARA { + cbSize: DWORD, + pIssuerCert: PCCERT_CONTEXT, + cCertStore: DWORD, + rgCertStore: *mut HCERTSTORE, + hCrlStore: HCERTSTORE, + pftTimeToUse: LPFILETIME, + dwUrlRetrievalTimeout: DWORD, + fCheckFreshnessTime: BOOL, + dwFreshnessTime: DWORD, + pftCurrentTime: LPFILETIME, + pCrlInfo: PCERT_REVOCATION_CRL_INFO, + pftCacheResync: LPFILETIME, + pChainPara: PCERT_REVOCATION_CHAIN_PARA, +}} +pub type PCERT_REVOCATION_PARA = *mut CERT_REVOCATION_PARA; +STRUCT!{struct CERT_REVOCATION_STATUS { + cbSize: DWORD, + dwIndex: DWORD, + dwError: DWORD, + dwReason: DWORD, + fHasFreshnessTime: BOOL, + dwFreshnessTime: DWORD, +}} +pub type PCERT_REVOCATION_STATUS = *mut CERT_REVOCATION_STATUS; +extern "system" { + pub fn CertVerifyRevocation( + dwEncodingType: DWORD, + dwRevType: DWORD, + cContext: DWORD, + rgpvContext: *mut PVOID, + dwFlags: DWORD, + pRevPara: PCERT_REVOCATION_PARA, + pRevStatus: PCERT_REVOCATION_STATUS, + ) -> BOOL; +} +pub const CERT_CONTEXT_REVOCATION_TYPE: DWORD = 1; +pub const CERT_VERIFY_REV_CHAIN_FLAG: DWORD = 0x00000001; +pub const CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION: DWORD = 0x00000002; +pub const CERT_VERIFY_REV_ACCUMULATIVE_TIMEOUT_FLAG: DWORD = 0x00000004; +pub const CERT_VERIFY_REV_SERVER_OCSP_FLAG: DWORD = 0x00000008; +pub const CERT_VERIFY_REV_NO_OCSP_FAILOVER_TO_CRL_FLAG: DWORD = 0x00000010; +extern "system" { + pub fn CertCompareIntegerBlob( + pInt1: PCRYPT_INTEGER_BLOB, + pInt2: PCRYPT_INTEGER_BLOB, + ) -> BOOL; + pub fn CertCompareCertificate( + dwCertEncodingType: DWORD, + pCertId1: PCERT_INFO, + pCertId2: PCERT_INFO, + ) -> BOOL; + pub fn CertCompareCertificateName( + dwCertEncodingType: DWORD, + pCertName1: PCERT_NAME_BLOB, + pCertName2: PCERT_NAME_BLOB, + ) -> BOOL; + pub fn CertIsRDNAttrsInCertificateName( + dwCertEncodingType: DWORD, + dwFlags: DWORD, + pCertName: PCERT_NAME_BLOB, + pRDN: PCERT_RDN, + ) -> BOOL; + pub fn CertComparePublicKeyInfo( + dwCertEncodingType: DWORD, + pPublicKey1: PCERT_PUBLIC_KEY_INFO, + pPublicKey2: PCERT_PUBLIC_KEY_INFO, + ) -> BOOL; + pub fn CertGetPublicKeyLength( + dwCertEncodingType: DWORD, + pPublicKey: PCERT_PUBLIC_KEY_INFO, + ) -> DWORD; + pub fn CryptVerifyCertificateSignature( + hCryptProv: HCRYPTPROV_LEGACY, + dwCertEncodingType: DWORD, + pbEncoded: *const BYTE, + cbEncoded: DWORD, + pPublicKey: PCERT_PUBLIC_KEY_INFO, + ) -> BOOL; + pub fn CryptVerifyCertificateSignatureEx( + hCryptProv: HCRYPTPROV_LEGACY, + dwCertEncodingType: DWORD, + dwSubjectType: DWORD, + pvSubject: *mut c_void, + dwIssuerType: DWORD, + pvIssuer: *mut c_void, + dwFlags: DWORD, + pvExtra: *mut c_void, + ) -> BOOL; +} +pub const CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB: DWORD = 1; +pub const CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT: DWORD = 2; +pub const CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL: DWORD = 3; +pub const CRYPT_VERIFY_CERT_SIGN_SUBJECT_OCSP_BASIC_SIGNED_RESPONSE: DWORD = 4; +pub const CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY: DWORD = 1; +pub const CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT: DWORD = 2; +pub const CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN: DWORD = 3; +pub const CRYPT_VERIFY_CERT_SIGN_ISSUER_NULL: DWORD = 4; +pub const CRYPT_VERIFY_CERT_SIGN_DISABLE_MD2_MD4_FLAG: DWORD = 0x00000001; +pub const CRYPT_VERIFY_CERT_SIGN_SET_STRONG_PROPERTIES_FLAG: DWORD = 0x00000002; +pub const CRYPT_VERIFY_CERT_SIGN_RETURN_STRONG_PROPERTIES_FLAG: DWORD = 0x00000004; +STRUCT!{struct CRYPT_VERIFY_CERT_SIGN_STRONG_PROPERTIES_INFO { + CertSignHashCNGAlgPropData: CRYPT_DATA_BLOB, + CertIssuerPubKeyBitLengthPropData: CRYPT_DATA_BLOB, +}} +pub type PCRYPT_VERIFY_CERT_SIGN_STRONG_PROPERTIES_INFO + = *mut CRYPT_VERIFY_CERT_SIGN_STRONG_PROPERTIES_INFO; +STRUCT!{struct CRYPT_VERIFY_CERT_SIGN_WEAK_HASH_INFO { + cCNGHashAlgid: DWORD, + rgpwszCNGHashAlgid: *mut PCWSTR, + dwWeakIndex: DWORD, +}} +pub type PCRYPT_VERIFY_CERT_SIGN_WEAK_HASH_INFO = *mut CRYPT_VERIFY_CERT_SIGN_WEAK_HASH_INFO; +extern "system" { + pub fn CertIsStrongHashToSign( + pStrongSignPara: PCCERT_STRONG_SIGN_PARA, + pwszCNGHashAlgid: LPCWSTR, + pSigningCert: PCCERT_CONTEXT, + ) -> BOOL; + pub fn CryptHashToBeSigned( + hCryptProv: HCRYPTPROV_LEGACY, + dwCertEncodingType: DWORD, + pbEncoded: *const BYTE, + cbEncoded: DWORD, + pbComputedHash: *mut BYTE, + pcbComputedHash: *mut DWORD, + ) -> BOOL; + pub fn CryptHashCertificate( + hCryptProv: HCRYPTPROV_LEGACY, + Algid: ALG_ID, + dwFlags: DWORD, + pbEncoded: *const BYTE, + cbEncoded: DWORD, + pbComputedHash: *mut BYTE, + pcbComputedHash: *mut DWORD, + ) -> BOOL; + pub fn CryptHashCertificate2( + pwszCNGHashAlgid: LPCWSTR, + dwFlags: DWORD, + pvReserved: *mut c_void, + pbEncoded: *const BYTE, + cbEncoded: DWORD, + pbComputedHash: *mut BYTE, + pcbComputedHash: *mut DWORD, + ) -> BOOL; + pub fn CryptSignCertificate( + hCryptProvOrNCryptKey: HCRYPTPROV_OR_NCRYPT_KEY_HANDLE, + dwKeySpec: DWORD, + dwCertEncodingType: DWORD, + pbEncodedToBeSigned: *const BYTE, + cbEncodedToBeSigned: DWORD, + pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER, + pvHashAuxInfo: *const c_void, + pbSignature: *mut BYTE, + pcbSignature: *mut DWORD, + ) -> BOOL; + pub fn CryptSignAndEncodeCertificate( + hCryptProvOrNCryptKey: HCRYPTPROV_OR_NCRYPT_KEY_HANDLE, + dwKeySpec: DWORD, + dwCertEncodingType: DWORD, + lpszStructType: LPCSTR, + pvStructInfo: *const c_void, + pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER, + pvHashAuxInfo: *const c_void, + pbEncoded: *mut BYTE, + pcbEncoded: *mut DWORD, + ) -> BOOL; +} +pub const CRYPT_OID_EXTRACT_ENCODED_SIGNATURE_PARAMETERS_FUNC: &'static str + = "CryptDllExtractEncodedSignatureParameters"; +FN!{stdcall PFN_CRYPT_EXTRACT_ENCODED_SIGNATURE_PARAMETERS_FUNC( + dwCertEncodingType: DWORD, + pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER, + ppvDecodedSignPara: *mut *mut c_void, + ppwszCNGHashAlgid: LPWSTR, +) -> BOOL} +pub const CRYPT_OID_SIGN_AND_ENCODE_HASH_FUNC: &'static str = "CryptDllSignAndEncodeHash"; +FN!{stdcall PFN_CRYPT_SIGN_AND_ENCODE_HASH_FUNC( + hKey: NCRYPT_KEY_HANDLE, + dwCertEncodingType: DWORD, + pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER, + pvDecodedSignPara: *mut c_void, + pwszCNGPubKeyAlgid: LPCWSTR, + pwszCNGHashAlgid: LPCWSTR, + pbComputedHash: *mut BYTE, + cbComputedHash: DWORD, + pbSignature: *mut BYTE, + pcbSignature: *mut DWORD, +) -> BOOL} +pub const CRYPT_OID_VERIFY_ENCODED_SIGNATURE_FUNC: &'static str = "CryptDllVerifyEncodedSignature"; +FN!{stdcall PFN_CRYPT_VERIFY_ENCODED_SIGNATURE_FUNC( + dwCertEncodingType: DWORD, + pPubKeyInfo: PCERT_PUBLIC_KEY_INFO, + pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER, + pvDecodedSignPara: *mut c_void, + pwszCNGPubKeyAlgid: LPCWSTR, + pwszCNGHashAlgid: LPCWSTR, + pbComputedHash: *mut BYTE, + cbComputedHash: DWORD, + pbSignature: *mut BYTE, + cbSignature: DWORD, +) -> BOOL} +extern "system" { + pub fn CertVerifyTimeValidity( + pTimeToVerify: LPFILETIME, + pCertInfo: PCERT_INFO, + ) -> LONG; + pub fn CertVerifyCRLTimeValidity( + pTimeToVerify: LPFILETIME, + pCrlInfo: PCRL_INFO, + ) -> LONG; + pub fn CertVerifyValidityNesting( + pSubjectInfo: PCERT_INFO, + pIssuerInfo: PCERT_INFO, + ) -> BOOL; + pub fn CertVerifyCRLRevocation( + dwCertEncodingType: DWORD, + pCertId: PCERT_INFO, + cCrlInfo: DWORD, + rgpCrlInfo: *mut PCRL_INFO, + ) -> BOOL; + pub fn CertAlgIdToOID( + dwAlgId: DWORD, + ) -> LPCSTR; + pub fn CertOIDToAlgId( + pszObjId: LPCSTR, + ) -> DWORD; + pub fn CertFindExtension( + pszObjId: LPCSTR, + cExtensions: DWORD, + rgExtensions: *mut CERT_EXTENSION, + ) -> PCERT_EXTENSION; + pub fn CertFindAttribute( + pszObjId: LPCSTR, + cAttr: DWORD, + rgAttr: *mut CRYPT_ATTRIBUTE, + ) -> PCRYPT_ATTRIBUTE; + pub fn CertFindRDNAttr( + pszObjId: LPCSTR, + pName: PCERT_NAME_INFO, + ) -> PCERT_RDN_ATTR; + pub fn CertGetIntendedKeyUsage( + dwCertEncodingType: DWORD, + pCertInfo: PCERT_INFO, + pbKeyUsage: *mut BYTE, + cbKeyUsage: DWORD, + ) -> BOOL; +} +pub type HCRYPTDEFAULTCONTEXT = *mut c_void; +extern "system" { + pub fn CryptInstallDefaultContext( + hCryptProv: HCRYPTPROV, + dwDefaultType: DWORD, + pvDefaultPara: *const c_void, + dwFlags: DWORD, + pvReserved: *mut c_void, + phDefaultContext: *mut HCRYPTDEFAULTCONTEXT, + ) -> BOOL; +} +pub const CRYPT_DEFAULT_CONTEXT_AUTO_RELEASE_FLAG: DWORD = 0x00000001; +pub const CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG: DWORD = 0x00000002; +pub const CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID: DWORD = 1; +pub const CRYPT_DEFAULT_CONTEXT_MULTI_CERT_SIGN_OID: DWORD = 2; +STRUCT!{struct CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA { + cOID: DWORD, + rgpszOID: *mut LPSTR, +}} +pub type PCRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA = *mut CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA; +extern "system" { + pub fn CryptUninstallDefaultContext( + hDefaultContext: HCRYPTDEFAULTCONTEXT, + dwFlags: DWORD, + pvReserved: *mut c_void, + ) -> BOOL; + pub fn CryptExportPublicKeyInfo( + hCryptProvOrNCryptKey: HCRYPTPROV_OR_NCRYPT_KEY_HANDLE, + dwKeySpec: DWORD, + dwCertEncodingType: DWORD, + pInfo: PCERT_PUBLIC_KEY_INFO, + pcbInfo: *mut DWORD, + ) -> BOOL; + pub fn CryptExportPublicKeyInfoEx( + hCryptProvOrNCryptKey: HCRYPTPROV_OR_NCRYPT_KEY_HANDLE, + dwKeySpec: DWORD, + dwCertEncodingType: DWORD, + pszPublicKeyObjId: LPSTR, + dwFlags: DWORD, + pvAuxInfo: *mut c_void, + pInfo: PCERT_PUBLIC_KEY_INFO, + pcbInfo: *mut DWORD, + ) -> BOOL; +} +pub const CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC: &'static str = "CryptDllExportPublicKeyInfoEx"; +pub const CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_EX2_FUNC: &'static str + = "CryptDllExportPublicKeyInfoEx2"; +FN!{stdcall PFN_CRYPT_EXPORT_PUBLIC_KEY_INFO_EX2_FUNC( + hNCryptKey: NCRYPT_KEY_HANDLE, + dwCertEncodingType: DWORD, + pszPublicKeyObjId: LPSTR, + dwFlags: DWORD, + pvAuxInfo: *mut c_void, + pInfo: PCERT_PUBLIC_KEY_INFO, + pcbInfo: *mut DWORD, +) -> BOOL} +extern "system" { + pub fn CryptExportPublicKeyInfoFromBCryptKeyHandle( + hBCryptKey: BCRYPT_KEY_HANDLE, + dwCertEncodingType: DWORD, + pszPublicKeyObjId: LPSTR, + dwFlags: DWORD, + pvAuxInfo: *mut c_void, + pInfo: PCERT_PUBLIC_KEY_INFO, + pcbInfo: *mut DWORD, + ) -> BOOL; +} +pub const CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FROM_BCRYPT_HANDLE_FUNC: &'static str + = "CryptDllExportPublicKeyInfoFromBCryptKeyHandle"; +FN!{stdcall PFN_CRYPT_EXPORT_PUBLIC_KEY_INFO_FROM_BCRYPT_HANDLE_FUNC( + hBCryptKey: BCRYPT_KEY_HANDLE, + dwCertEncodingType: DWORD, + pszPublicKeyObjId: LPSTR, + dwFlags: DWORD, + pvAuxInfo: *mut c_void, + pInfo: PCERT_PUBLIC_KEY_INFO, + pcbInfo: *mut DWORD, +) -> BOOL} +extern "system" { + pub fn CryptImportPublicKeyInfo( + hCryptProv: HCRYPTPROV, + dwCertEncodingType: DWORD, + pInfo: PCERT_PUBLIC_KEY_INFO, + phKey: *mut HCRYPTKEY, + ) -> BOOL; +} +pub const CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC: &'static str = "CryptDllImportPublicKeyInfoEx"; +extern "system" { + pub fn CryptImportPublicKeyInfoEx( + hCryptProv: HCRYPTPROV, + dwCertEncodingType: DWORD, + pInfo: PCERT_PUBLIC_KEY_INFO, + aiKeyAlg: ALG_ID, + dwFlags: DWORD, + pvAuxInfo: *mut c_void, + phKey: *mut HCRYPTKEY, + ) -> BOOL; + pub fn CryptImportPublicKeyInfoEx2( + dwCertEncodingType: DWORD, + pInfo: PCERT_PUBLIC_KEY_INFO, + dwFlags: DWORD, + pvAuxInfo: *mut c_void, + phKey: *mut BCRYPT_KEY_HANDLE, + ) -> BOOL; +} +pub const CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_EX2_FUNC: &'static str + = "CryptDllImportPublicKeyInfoEx2"; +FN!{stdcall PFN_IMPORT_PUBLIC_KEY_INFO_EX2_FUNC( + dwCertEncodingType: DWORD, + pInfo: PCERT_PUBLIC_KEY_INFO, + dwFlags: DWORD, + pvAuxInfo: *mut c_void, + phKey: *mut BCRYPT_KEY_HANDLE, +) -> BOOL} +extern "system" { + pub fn CryptAcquireCertificatePrivateKey( + pCert: PCCERT_CONTEXT, + dwFlags: DWORD, + pvParameters: *mut c_void, + phCryptProvOrNCryptKey: *mut HCRYPTPROV_OR_NCRYPT_KEY_HANDLE, + pdwKeySpec: *mut DWORD, + pfCallerFreeProvOrNCryptKey: *mut BOOL, + ) -> BOOL; +} +pub const CRYPT_ACQUIRE_CACHE_FLAG: DWORD = 0x00000001; +pub const CRYPT_ACQUIRE_USE_PROV_INFO_FLAG: DWORD = 0x00000002; +pub const CRYPT_ACQUIRE_COMPARE_KEY_FLAG: DWORD = 0x00000004; +pub const CRYPT_ACQUIRE_NO_HEALING: DWORD = 0x00000008; +pub const CRYPT_ACQUIRE_SILENT_FLAG: DWORD = 0x00000040; +pub const CRYPT_ACQUIRE_WINDOW_HANDLE_FLAG: DWORD = 0x00000080; +pub const CRYPT_ACQUIRE_NCRYPT_KEY_FLAGS_MASK: DWORD = 0x00070000; +pub const CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG: DWORD = 0x00010000; +pub const CRYPT_ACQUIRE_PREFER_NCRYPT_KEY_FLAG: DWORD = 0x00020000; +pub const CRYPT_ACQUIRE_ONLY_NCRYPT_KEY_FLAG: DWORD = 0x00040000; +extern "system" { + pub fn CryptFindCertificateKeyProvInfo( + pCert: PCCERT_CONTEXT, + dwFlags: DWORD, + pvReserved: *mut c_void, + ) -> BOOL; +} +pub const CRYPT_FIND_USER_KEYSET_FLAG: DWORD = 0x00000001; +pub const CRYPT_FIND_MACHINE_KEYSET_FLAG: DWORD = 0x00000002; +pub const CRYPT_FIND_SILENT_KEYSET_FLAG: DWORD = 0x00000040; +FN!{stdcall PFN_IMPORT_PRIV_KEY_FUNC( + hCryptProv: HCRYPTPROV, + pPrivateKeyInfo: *mut CRYPT_PRIVATE_KEY_INFO, + dwFlags: DWORD, + pvAuxInfo: *mut c_void, +) -> BOOL} +pub const CRYPT_OID_IMPORT_PRIVATE_KEY_INFO_FUNC: &'static str = "CryptDllImportPrivateKeyInfoEx"; +extern "system" { + pub fn CryptImportPKCS8( + sPrivateKeyAndParams: CRYPT_PKCS8_IMPORT_PARAMS, + dwFlags: DWORD, + phCryptProv: *mut HCRYPTPROV, + pvAuxInfo: *mut c_void, + ) -> BOOL; +} +FN!{stdcall PFN_EXPORT_PRIV_KEY_FUNC( + hCryptProv: HCRYPTPROV, + dwKeySpec: DWORD, + pszPrivateKeyObjId: LPSTR, + dwFlags: DWORD, + pvAuxInfo: *mut c_void, + pPrivateKeyInfo: *mut CRYPT_PRIVATE_KEY_INFO, + pcbPrivateKeyInfo: *mut DWORD, +) -> BOOL} +pub const CRYPT_OID_EXPORT_PRIVATE_KEY_INFO_FUNC: &'static str = "CryptDllExportPrivateKeyInfoEx"; +pub const CRYPT_DELETE_KEYSET: DWORD = CRYPT_DELETEKEYSET; +extern "system" { + pub fn CryptExportPKCS8( + hCryptProv: HCRYPTPROV, + dwKeySpec: DWORD, + pszPrivateKeyObjId: LPSTR, + dwFlags: DWORD, + pvAuxInfo: *mut c_void, + pbPrivateKeyBlob: *mut BYTE, + pcbPrivateKeyBlob: *mut DWORD, + ) -> BOOL; + pub fn CryptExportPKCS8Ex( + psExportParams: CRYPT_PKCS8_EXPORT_PARAMS, + dwKeySpec: DWORD, + pvAuxInfo: *mut c_void, + pbPrivateKeyBlob: *mut BYTE, + pcbPrivateKeyBlob: *mut DWORD, + ) -> BOOL; + pub fn CryptHashPublicKeyInfo( + hCryptProv: HCRYPTPROV_LEGACY, + Algid: ALG_ID, + dwFlags: DWORD, + dwCertEncodingType: DWORD, + pInfo: PCERT_PUBLIC_KEY_INFO, + pbComputedHash: *mut BYTE, + pcbComputedHash: *mut DWORD, + ) -> BOOL; + pub fn CertRDNValueToStrA( + dwValueType: DWORD, + pValue: PCERT_RDN_VALUE_BLOB, + psz: LPSTR, + csz: DWORD, + ) -> DWORD; + pub fn CertRDNValueToStrW( + dwValueType: DWORD, + pValue: PCERT_RDN_VALUE_BLOB, + psz: LPWSTR, + csz: DWORD, + ) -> DWORD; + pub fn CertNameToStrA( + dwCertEncodingType: DWORD, + pName: PCERT_NAME_BLOB, + dwStrType: DWORD, + psz: LPSTR, + csz: DWORD, + ) -> DWORD; + pub fn CertNameToStrW( + dwCertEncodingType: DWORD, + pName: PCERT_NAME_BLOB, + dwStrType: DWORD, + psz: LPWSTR, + csz: DWORD, + ) -> DWORD; +} +pub const CERT_SIMPLE_NAME_STR: DWORD = 1; +pub const CERT_OID_NAME_STR: DWORD = 2; +pub const CERT_X500_NAME_STR: DWORD = 3; +pub const CERT_XML_NAME_STR: DWORD = 4; +pub const CERT_NAME_STR_SEMICOLON_FLAG: DWORD = 0x40000000; +pub const CERT_NAME_STR_NO_PLUS_FLAG: DWORD = 0x20000000; +pub const CERT_NAME_STR_NO_QUOTING_FLAG: DWORD = 0x10000000; +pub const CERT_NAME_STR_CRLF_FLAG: DWORD = 0x08000000; +pub const CERT_NAME_STR_COMMA_FLAG: DWORD = 0x04000000; +pub const CERT_NAME_STR_REVERSE_FLAG: DWORD = 0x02000000; +pub const CERT_NAME_STR_FORWARD_FLAG: DWORD = 0x01000000; +pub const CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG: DWORD = 0x00010000; +pub const CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG: DWORD = 0x00020000; +pub const CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG: DWORD = 0x00040000; +pub const CERT_NAME_STR_FORCE_UTF8_DIR_STR_FLAG: DWORD = 0x00080000; +pub const CERT_NAME_STR_DISABLE_UTF8_DIR_STR_FLAG: DWORD = 0x00100000; +pub const CERT_NAME_STR_ENABLE_PUNYCODE_FLAG: DWORD = 0x00200000; +extern "system" { + pub fn CertStrToNameA( + dwCertEncodingType: DWORD, + pszX500: LPCSTR, + dwStrType: DWORD, + pvReserved: *mut c_void, + pbEncoded: *mut BYTE, + pcbEncoded: *mut DWORD, + ppszError: *mut LPCSTR, + ) -> BOOL; + pub fn CertStrToNameW( + dwCertEncodingType: DWORD, + pszX500: LPCWSTR, + dwStrType: DWORD, + pvReserved: *mut c_void, + pbEncoded: *mut BYTE, + pcbEncoded: *mut DWORD, + ppszError: *mut LPCWSTR, + ) -> BOOL; + pub fn CertGetNameStringA( + pCertContext: PCCERT_CONTEXT, + dwType: DWORD, + dwFlags: DWORD, + pvTypePara: *mut c_void, + pszNameString: LPSTR, + cchNameString: DWORD, + ) -> DWORD; + pub fn CertGetNameStringW( + pCertContext: PCCERT_CONTEXT, + dwType: DWORD, + dwFlags: DWORD, + pvTypePara: *mut c_void, + pszNameString: LPWSTR, + cchNameString: DWORD, + ) -> DWORD; +} +pub const CERT_NAME_EMAIL_TYPE: DWORD = 1; +pub const CERT_NAME_RDN_TYPE: DWORD = 2; +pub const CERT_NAME_ATTR_TYPE: DWORD = 3; +pub const CERT_NAME_SIMPLE_DISPLAY_TYPE: DWORD = 4; +pub const CERT_NAME_FRIENDLY_DISPLAY_TYPE: DWORD = 5; +pub const CERT_NAME_DNS_TYPE: DWORD = 6; +pub const CERT_NAME_URL_TYPE: DWORD = 7; +pub const CERT_NAME_UPN_TYPE: DWORD = 8; +pub const CERT_NAME_ISSUER_FLAG: DWORD = 0x1; +pub const CERT_NAME_DISABLE_IE4_UTF8_FLAG: DWORD = 0x00010000; +pub const CERT_NAME_SEARCH_ALL_NAMES_FLAG: DWORD = 0x2; +FN!{stdcall PFN_CRYPT_GET_SIGNER_CERTIFICATE( + pvGetArg: *mut c_void, + dwCertEncodingType: DWORD, + pSignerId: PCERT_INFO, + hMsgCertStore: HCERTSTORE, +) -> PCCERT_CONTEXT} +STRUCT!{struct CRYPT_SIGN_MESSAGE_PARA { + cbSize: DWORD, + dwMsgEncodingType: DWORD, + pSigningCert: PCCERT_CONTEXT, + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvHashAuxInfo: *mut c_void, + cMsgCert: DWORD, + rgpMsgCert: *mut PCCERT_CONTEXT, + cMsgCrl: DWORD, + rgpMsgCrl: *mut PCCRL_CONTEXT, + cAuthAttr: DWORD, + rgAuthAttr: PCRYPT_ATTRIBUTE, + cUnauthAttr: DWORD, + rgUnauthAttr: PCRYPT_ATTRIBUTE, + dwFlags: DWORD, + dwInnerContentType: DWORD, + HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvHashEncryptionAuxInfo: *mut c_void, +}} +pub type PCRYPT_SIGN_MESSAGE_PARA = *mut CRYPT_SIGN_MESSAGE_PARA; +pub const CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG: DWORD = 0x00000001; +pub const CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG: DWORD = 0x00000002; +pub const CRYPT_MESSAGE_KEYID_SIGNER_FLAG: DWORD = 0x00000004; +pub const CRYPT_MESSAGE_SILENT_KEYSET_FLAG: DWORD = 0x00000040; +STRUCT!{struct CRYPT_VERIFY_MESSAGE_PARA { + cbSize: DWORD, + dwMsgAndCertEncodingType: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + pfnGetSignerCertificate: PFN_CRYPT_GET_SIGNER_CERTIFICATE, + pvGetArg: *mut c_void, + pStrongSignPara: PCCERT_STRONG_SIGN_PARA, +}} +pub type PCRYPT_VERIFY_MESSAGE_PARA = *mut CRYPT_VERIFY_MESSAGE_PARA; +STRUCT!{struct CRYPT_ENCRYPT_MESSAGE_PARA { + cbSize: DWORD, + dwMsgEncodingType: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvEncryptionAuxInfo: *mut c_void, + dwFlags: DWORD, + dwInnerContentType: DWORD, +}} +pub type PCRYPT_ENCRYPT_MESSAGE_PARA = *mut CRYPT_DECRYPT_MESSAGE_PARA; +pub const CRYPT_MESSAGE_KEYID_RECIPIENT_FLAG: DWORD = 0x4; +STRUCT!{struct CRYPT_DECRYPT_MESSAGE_PARA { + cbSize: DWORD, + dwMsgAndCertEncodingType: DWORD, + cCertStore: DWORD, + rghCertStore: *mut HCERTSTORE, + dwFlags: DWORD, +}} +pub type PCRYPT_DECRYPT_MESSAGE_PARA = *mut CRYPT_DECRYPT_MESSAGE_PARA; +STRUCT!{struct CRYPT_HASH_MESSAGE_PARA { + cbSize: DWORD, + dwMsgEncodingType: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvHashAuxInfo: *mut c_void, +}} +pub type PCRYPT_HASH_MESSAGE_PARA = *mut CRYPT_HASH_MESSAGE_PARA; +UNION!{union CRYPT_KEY_SIGN_MESSAGE_PARA_u { + [usize; 1], + hCryptProv hCryptProv_mut: HCRYPTPROV, + hNCryptKey hNCryptKey_mut: NCRYPT_KEY_HANDLE, +}} +STRUCT!{struct CRYPT_KEY_SIGN_MESSAGE_PARA { + cbSize: DWORD, + dwMsgAndCertEncodingType: DWORD, + u: CRYPT_KEY_SIGN_MESSAGE_PARA_u, + dwKeySpec: DWORD, + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + pvHashAuxInfo: *mut c_void, + PubKeyAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, +}} +pub type PCRYPT_KEY_SIGN_MESSAGE_PARA = *mut CRYPT_KEY_SIGN_MESSAGE_PARA; +STRUCT!{struct CRYPT_KEY_VERIFY_MESSAGE_PARA { + cbSize: DWORD, + dwMsgEncodingType: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, +}} +pub type PCRYPT_KEY_VERIFY_MESSAGE_PARA = *mut CRYPT_KEY_VERIFY_MESSAGE_PARA; +extern "system" { + pub fn CryptSignMessage( + pSignPara: PCRYPT_SIGN_MESSAGE_PARA, + fDetachedSignature: BOOL, + cToBeSigned: DWORD, + rgpbToBeSigned: *mut *const BYTE, + rgcbToBeSigned: *mut DWORD, + pbSignedBlob: *mut BYTE, + pcbSignedBlob: *mut DWORD, + ) -> BOOL; + pub fn CryptVerifyMessageSignature( + pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA, + dwSignerIndex: DWORD, + pbSignedBlob: *const BYTE, + cbSignedBlob: DWORD, + pbDecoded: *mut BYTE, + pcbDecoded: *mut DWORD, + ppSignerCert: *mut PCCERT_CONTEXT, + ) -> BOOL; + pub fn CryptGetMessageSignerCount( + dwMsgEncodingType: DWORD, + pbSignedBlob: *const BYTE, + cbSignedBlob: DWORD, + ) -> LONG; + pub fn CryptGetMessageCertificates( + dwMsgAndCertEncodingType: DWORD, + hCryptProv: HCRYPTPROV_LEGACY, + dwFlags: DWORD, + pbSignedBlob: *const BYTE, + cbSignedBlob: DWORD, + ) -> HCERTSTORE; + pub fn CryptVerifyDetachedMessageSignature( + pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA, + dwSignerIndex: DWORD, + pbDetachedSignBlob: *const BYTE, + cbDetachedSignBlob: DWORD, + cToBeSigned: DWORD, + rgpbToBeSigned: *mut *const BYTE, + rgcbToBeSigned: *mut DWORD, + ppSignerCert: *mut PCCERT_CONTEXT, + ) -> BOOL; + pub fn CryptEncryptMessage( + pEncryptPara: PCRYPT_ENCRYPT_MESSAGE_PARA, + cRecipientCert: DWORD, + rgpRecipientCert: *mut PCCERT_CONTEXT, + pbToBeEncrypted: *const BYTE, + cbToBeEncrypted: DWORD, + pbEncryptedBlob: *mut BYTE, + pcbEncryptedBlob: *mut DWORD, + ) -> BOOL; + pub fn CryptDecryptMessage( + pDecryptPara: PCRYPT_DECRYPT_MESSAGE_PARA, + pbEncryptedBlob: *const BYTE, + cbEncryptedBlob: DWORD, + pbDecrypted: *mut BYTE, + pcbDecrypted: *mut DWORD, + ppXchgCert: *mut PCCERT_CONTEXT, + ) -> BOOL; + pub fn CryptSignAndEncryptMessage( + pSignPara: PCRYPT_SIGN_MESSAGE_PARA, + pEncryptPara: PCRYPT_ENCRYPT_MESSAGE_PARA, + cRecipientCert: DWORD, + rgpRecipientCert: *mut PCCERT_CONTEXT, + pbToBeSignedAndEncrypted: *const BYTE, + cbToBeSignedAndEncrypted: DWORD, + pbSignedAndEncryptedBlob: *mut BYTE, + pcbSignedAndEncryptedBlob: *mut DWORD, + ) -> BOOL; + pub fn CryptDecryptAndVerifyMessageSignature( + pDecryptPara: PCRYPT_DECRYPT_MESSAGE_PARA, + pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA, + dwSignerIndex: DWORD, + pbEncryptedBlob: *const BYTE, + cbEncryptedBlob: DWORD, + pbDecrypted: *mut BYTE, + pcbDecrypted: *mut DWORD, + ppXchgCert: *mut PCCERT_CONTEXT, + ppSignerCert: *mut PCCERT_CONTEXT, + ) -> BOOL; + pub fn CryptDecodeMessage( + dwMsgTypeFlags: DWORD, + pDecryptPara: PCRYPT_DECRYPT_MESSAGE_PARA, + pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA, + dwSignerIndex: DWORD, + pbEncodedBlob: *const BYTE, + cbEncodedBlob: DWORD, + dwPrevInnerContentType: DWORD, + pdwMsgType: *mut DWORD, + pdwInnerContentType: *mut DWORD, + pbDecoded: *mut BYTE, + pcbDecoded: *mut DWORD, + ppXchgCert: *mut PCCERT_CONTEXT, + ppSignerCert: *mut PCCERT_CONTEXT, + ) -> BOOL; + pub fn CryptHashMessage( + pHashPara: PCRYPT_HASH_MESSAGE_PARA, + fDetachedHash: BOOL, + cToBeHashed: DWORD, + rgpbToBeHashed: *mut *const BYTE, + rgcbToBeHashed: *mut DWORD, + pbHashedBlob: *mut BYTE, + pcbHashedBlob: *mut DWORD, + pbComputedHash: *mut BYTE, + pcbComputedHash: *mut DWORD, + ) -> BOOL; + pub fn CryptVerifyMessageHash( + pHashPara: PCRYPT_HASH_MESSAGE_PARA, + pbHashedBlob: *mut BYTE, + cbHashedBlob: DWORD, + pbToBeHashed: *mut BYTE, + pcbToBeHashed: *mut DWORD, + pbComputedHash: *mut BYTE, + pcbComputedHash: *mut DWORD, + ) -> BOOL; + pub fn CryptVerifyDetachedMessageHash( + pHashPara: PCRYPT_HASH_MESSAGE_PARA, + pbDetachedHashBlob: *mut BYTE, + cbDetachedHashBlob: DWORD, + cToBeHashed: DWORD, + rgpbToBeHashed: *mut *const BYTE, + rgcbToBeHashed: *mut DWORD, + pbComputedHash: *mut BYTE, + pcbComputedHash: *mut DWORD, + ) -> BOOL; + pub fn CryptSignMessageWithKey( + pSignPara: PCRYPT_KEY_SIGN_MESSAGE_PARA, + pbToBeSigned: *const BYTE, + cbToBeSigned: DWORD, + pbSignedBlob: *mut BYTE, + pcbSignedBlob: *mut DWORD, + ) -> BOOL; + pub fn CryptVerifyMessageSignatureWithKey( + pVerifyPara: PCRYPT_KEY_VERIFY_MESSAGE_PARA, + pPublicKeyInfo: PCERT_PUBLIC_KEY_INFO, + pbSignedBlob: *const BYTE, + cbSignedBlob: DWORD, + pbDecoded: *mut BYTE, + pcbDecoded: *mut DWORD, + ) -> BOOL; + pub fn CertOpenSystemStoreA( + hProv: HCRYPTPROV_LEGACY, + szSubsystemProtocol: LPCSTR, + ) -> HCERTSTORE; + pub fn CertOpenSystemStoreW( + hProv: HCRYPTPROV_LEGACY, + szSubsystemProtocol: LPCWSTR, + ) -> HCERTSTORE; + pub fn CertAddEncodedCertificateToSystemStoreA( + szCertStoreName: LPCSTR, + pbCertEncoded: *const BYTE, + cbCertEncoded: DWORD, + ) -> BOOL; + pub fn CertAddEncodedCertificateToSystemStoreW( + szCertStoreName: LPCWSTR, + pbCertEncoded: *const BYTE, + cbCertEncoded: DWORD, + ) -> BOOL; +} +STRUCT!{struct CERT_CHAIN { + cCerts: DWORD, + certs: PCERT_BLOB, + keyLocatorInfo: CRYPT_KEY_PROV_INFO, +}} +pub type PCERT_CHAIN = *mut CERT_CHAIN; +extern "system" { + pub fn FindCertsByIssuer( + pCertChains: PCERT_CHAIN, + pcbCertChains: *mut DWORD, + pcCertChains: *mut DWORD, + pbEncodedIssuerName: *mut BYTE, + cbEncodedIssuerName: DWORD, + pwszPurpose: LPCWSTR, + dwKeySpec: DWORD, + ) -> HRESULT; + pub fn CryptQueryObject( + dwObjectType: DWORD, + pvObject: *const c_void, + dwExpectedContentTypeFlags: DWORD, + dwExpectedFormatTypeFlags: DWORD, + dwFlags: DWORD, + pdwMsgAndCertEncodingType: *mut DWORD, + pdwContentType: *mut DWORD, + pdwFormatType: *mut DWORD, + phCertStore: *mut HCERTSTORE, + phMsg: *mut HCRYPTMSG, + ppvContext: *mut *const c_void, + ) -> BOOL; +} +pub const CERT_QUERY_OBJECT_FILE: DWORD = 0x00000001; +pub const CERT_QUERY_OBJECT_BLOB: DWORD = 0x00000002; +pub const CERT_QUERY_CONTENT_CERT: DWORD = 1; +pub const CERT_QUERY_CONTENT_CTL: DWORD = 2; +pub const CERT_QUERY_CONTENT_CRL: DWORD = 3; +pub const CERT_QUERY_CONTENT_SERIALIZED_STORE: DWORD = 4; +pub const CERT_QUERY_CONTENT_SERIALIZED_CERT: DWORD = 5; +pub const CERT_QUERY_CONTENT_SERIALIZED_CTL: DWORD = 6; +pub const CERT_QUERY_CONTENT_SERIALIZED_CRL: DWORD = 7; +pub const CERT_QUERY_CONTENT_PKCS7_SIGNED: DWORD = 8; +pub const CERT_QUERY_CONTENT_PKCS7_UNSIGNED: DWORD = 9; +pub const CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED: DWORD = 10; +pub const CERT_QUERY_CONTENT_PKCS10: DWORD = 11; +pub const CERT_QUERY_CONTENT_PFX: DWORD = 12; +pub const CERT_QUERY_CONTENT_CERT_PAIR: DWORD = 13; +pub const CERT_QUERY_CONTENT_PFX_AND_LOAD: DWORD = 14; +pub const CERT_QUERY_CONTENT_FLAG_CERT: DWORD = 1 << CERT_QUERY_CONTENT_CERT; +pub const CERT_QUERY_CONTENT_FLAG_CTL: DWORD = 1 << CERT_QUERY_CONTENT_CTL; +pub const CERT_QUERY_CONTENT_FLAG_CRL: DWORD = 1 << CERT_QUERY_CONTENT_CRL; +pub const CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE: DWORD + = 1<< CERT_QUERY_CONTENT_SERIALIZED_STORE; +pub const CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT: DWORD = 1 << CERT_QUERY_CONTENT_SERIALIZED_CERT; +pub const CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL: DWORD = 1 << CERT_QUERY_CONTENT_SERIALIZED_CTL; +pub const CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL: DWORD = 1 << CERT_QUERY_CONTENT_SERIALIZED_CRL; +pub const CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED: DWORD = 1 << CERT_QUERY_CONTENT_PKCS7_SIGNED; +pub const CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED: DWORD = 1 << CERT_QUERY_CONTENT_PKCS7_UNSIGNED; +pub const CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED: DWORD + = 1 << CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED; +pub const CERT_QUERY_CONTENT_FLAG_PKCS10: DWORD = 1 << CERT_QUERY_CONTENT_PKCS10; +pub const CERT_QUERY_CONTENT_FLAG_PFX: DWORD = 1 << CERT_QUERY_CONTENT_PFX; +pub const CERT_QUERY_CONTENT_FLAG_CERT_PAIR: DWORD = 1 << CERT_QUERY_CONTENT_CERT_PAIR; +pub const CERT_QUERY_CONTENT_FLAG_PFX_AND_LOAD: DWORD = 1 << CERT_QUERY_CONTENT_PFX_AND_LOAD; +pub const CERT_QUERY_CONTENT_FLAG_ALL: DWORD = CERT_QUERY_CONTENT_FLAG_CERT + | CERT_QUERY_CONTENT_FLAG_CTL | CERT_QUERY_CONTENT_FLAG_CRL + | CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT + | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL + | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED + | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED | CERT_QUERY_CONTENT_FLAG_PKCS10 + | CERT_QUERY_CONTENT_FLAG_PFX | CERT_QUERY_CONTENT_FLAG_CERT_PAIR; +pub const CERT_QUERY_CONTENT_FLAG_ALL_ISSUER_CERT: DWORD = CERT_QUERY_CONTENT_FLAG_CERT + | CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT + | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED; +pub const CERT_QUERY_FORMAT_BINARY: DWORD = 1; +pub const CERT_QUERY_FORMAT_BASE64_ENCODED: DWORD = 2; +pub const CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED: DWORD = 3; +pub const CERT_QUERY_FORMAT_FLAG_BINARY: DWORD = 1 << CERT_QUERY_FORMAT_BINARY; +pub const CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED: DWORD = 1 << CERT_QUERY_FORMAT_BASE64_ENCODED; +pub const CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED: DWORD + = 1 << CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED; +pub const CERT_QUERY_FORMAT_FLAG_ALL: DWORD = CERT_QUERY_FORMAT_FLAG_BINARY + | CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED | CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED; +extern "system" { + pub fn CryptMemAlloc( + cbSize: ULONG, + ) -> LPVOID; + pub fn CryptMemRealloc( + pv: LPVOID, + cbSize: ULONG, + ) -> LPVOID; + pub fn CryptMemFree( + pv: LPVOID, + ); +} +pub type HCRYPTASYNC = HANDLE; +pub type PHCRYPTASYNC = *mut HANDLE; +FN!{stdcall PFN_CRYPT_ASYNC_PARAM_FREE_FUNC( + pszParamOid: LPSTR, + pvParam: LPVOID, +) -> ()} +extern "system" { + pub fn CryptCreateAsyncHandle( + dwFlags: DWORD, + phAsync: PHCRYPTASYNC, + ) -> BOOL; + pub fn CryptSetAsyncParam( + hAsync: HCRYPTASYNC, + pszParamOid: LPSTR, + pvParam: LPVOID, + pfnFree: PFN_CRYPT_ASYNC_PARAM_FREE_FUNC, + ) -> BOOL; + pub fn CryptGetAsyncParam( + hAsync: HCRYPTASYNC, + pszParamOid: LPSTR, + ppvParam: *mut LPVOID, + ppfnFree: *mut PFN_CRYPT_ASYNC_PARAM_FREE_FUNC, + ) -> BOOL; + pub fn CryptCloseAsyncHandle( + hAsync: HCRYPTASYNC, + ) -> BOOL; +} +STRUCT!{struct CRYPT_BLOB_ARRAY { + cBlob: DWORD, + rgBlob: PCRYPT_DATA_BLOB, +}} +pub type PCRYPT_BLOB_ARRAY = *mut CRYPT_BLOB_ARRAY; +STRUCT!{struct CRYPT_CREDENTIALS { + cbSize: DWORD, + pszCredentialsOid: LPCSTR, + pvCredentials: LPVOID, +}} +pub type PCRYPT_CREDENTIALS = *mut CRYPT_CREDENTIALS; +pub const CREDENTIAL_OID_PASSWORD_CREDENTIALS_A: LPCSTR = 1 as LPCSTR; +pub const CREDENTIAL_OID_PASSWORD_CREDENTIALS_W: LPCSTR = 2 as LPCSTR; +STRUCT!{struct CRYPT_PASSWORD_CREDENTIALSA { + cbSize: DWORD, + pszUsername: LPSTR, + pszPassword: LPSTR, +}} +pub type PCRYPT_PASSWORD_CREDENTIALSA = *mut CRYPT_PASSWORD_CREDENTIALSA; +STRUCT!{struct CRYPT_PASSWORD_CREDENTIALSW { + cbSize: DWORD, + pszUsername: LPWSTR, + pszPassword: LPWSTR, +}} +pub type PCRYPT_PASSWORD_CREDENTIALSW = *mut CRYPT_PASSWORD_CREDENTIALSW; +pub const SCHEME_OID_RETRIEVE_ENCODED_OBJECT_FUNC: &'static str = "SchemeDllRetrieveEncodedObject"; +pub const SCHEME_OID_RETRIEVE_ENCODED_OBJECTW_FUNC: &'static str + = "SchemeDllRetrieveEncodedObjectW"; +FN!{stdcall PFN_FREE_ENCODED_OBJECT_FUNC( + pszObjectOid: LPCSTR, + pObject: PCRYPT_BLOB_ARRAY, + pvFreeContext: LPVOID, +) -> ()} +pub const CONTEXT_OID_CREATE_OBJECT_CONTEXT_FUNC: &'static str = "ContextDllCreateObjectContext"; +pub const CONTEXT_OID_CERTIFICATE: LPCSTR = 1 as LPCSTR; +pub const CONTEXT_OID_CRL: LPCSTR = 2 as LPCSTR; +pub const CONTEXT_OID_CTL: LPCSTR = 3 as LPCSTR; +pub const CONTEXT_OID_PKCS7: LPCSTR = 4 as LPCSTR; +pub const CONTEXT_OID_CAPI2_ANY: LPCSTR = 5 as LPCSTR; +pub const CONTEXT_OID_OCSP_RESP: LPCSTR = 6 as LPCSTR; +pub const CRYPT_RETRIEVE_MULTIPLE_OBJECTS: DWORD = 0x00000001; +pub const CRYPT_CACHE_ONLY_RETRIEVAL: DWORD = 0x00000002; +pub const CRYPT_WIRE_ONLY_RETRIEVAL: DWORD = 0x00000004; +pub const CRYPT_DONT_CACHE_RESULT: DWORD = 0x00000008; +pub const CRYPT_ASYNC_RETRIEVAL: DWORD = 0x00000010; +pub const CRYPT_STICKY_CACHE_RETRIEVAL: DWORD = 0x00001000; +pub const CRYPT_LDAP_SCOPE_BASE_ONLY_RETRIEVAL: DWORD = 0x00002000; +pub const CRYPT_OFFLINE_CHECK_RETRIEVAL: DWORD = 0x00004000; +pub const CRYPT_LDAP_INSERT_ENTRY_ATTRIBUTE: DWORD = 0x00008000; +pub const CRYPT_LDAP_SIGN_RETRIEVAL: DWORD = 0x00010000; +pub const CRYPT_NO_AUTH_RETRIEVAL: DWORD = 0x00020000; +pub const CRYPT_LDAP_AREC_EXCLUSIVE_RETRIEVAL: DWORD = 0x00040000; +pub const CRYPT_AIA_RETRIEVAL: DWORD = 0x00080000; +pub const CRYPT_HTTP_POST_RETRIEVAL: DWORD = 0x00100000; +pub const CRYPT_PROXY_CACHE_RETRIEVAL: DWORD = 0x00200000; +pub const CRYPT_NOT_MODIFIED_RETRIEVAL: DWORD = 0x00400000; +pub const CRYPT_ENABLE_SSL_REVOCATION_RETRIEVAL: DWORD = 0x00800000; +pub const CRYPT_RANDOM_QUERY_STRING_RETRIEVAL: DWORD = 0x04000000; +pub const CRYPT_ENABLE_FILE_RETRIEVAL: DWORD = 0x08000000; +pub const CRYPT_CREATE_NEW_FLUSH_ENTRY: DWORD = 0x10000000; +pub const CRYPT_VERIFY_CONTEXT_SIGNATURE: DWORD = 0x00000020; +pub const CRYPT_VERIFY_DATA_HASH: DWORD = 0x00000040; +pub const CRYPT_KEEP_TIME_VALID: DWORD = 0x00000080; +pub const CRYPT_DONT_VERIFY_SIGNATURE: DWORD = 0x00000100; +pub const CRYPT_DONT_CHECK_TIME_VALIDITY: DWORD = 0x00000200; +pub const CRYPT_CHECK_FRESHNESS_TIME_VALIDITY: DWORD = 0x00000400; +pub const CRYPT_ACCUMULATIVE_TIMEOUT: DWORD = 0x00000800; +pub const CRYPT_OCSP_ONLY_RETRIEVAL: DWORD = 0x01000000; +pub const CRYPT_NO_OCSP_FAILOVER_TO_CRL_RETRIEVAL: DWORD = 0x02000000; +STRUCT!{struct CRYPTNET_URL_CACHE_PRE_FETCH_INFO { + cbSize: DWORD, + dwObjectType: DWORD, + dwError: DWORD, + dwReserved: DWORD, + ThisUpdateTime: FILETIME, + NextUpdateTime: FILETIME, + PublishTime: FILETIME, +}} +pub type PCRYPTNET_URL_CACHE_PRE_FETCH_INFO = *mut CRYPTNET_URL_CACHE_PRE_FETCH_INFO; +pub const CRYPTNET_URL_CACHE_PRE_FETCH_NONE: DWORD = 0; +pub const CRYPTNET_URL_CACHE_PRE_FETCH_BLOB: DWORD = 1; +pub const CRYPTNET_URL_CACHE_PRE_FETCH_CRL: DWORD = 2; +pub const CRYPTNET_URL_CACHE_PRE_FETCH_OCSP: DWORD = 3; +pub const CRYPTNET_URL_CACHE_PRE_FETCH_AUTOROOT_CAB: DWORD = 5; +pub const CRYPTNET_URL_CACHE_PRE_FETCH_DISALLOWED_CERT_CAB: DWORD = 6; +pub const CRYPTNET_URL_CACHE_PRE_FETCH_PIN_RULES_CAB: DWORD = 7; +STRUCT!{struct CRYPTNET_URL_CACHE_FLUSH_INFO { + cbSize: DWORD, + dwExemptSeconds: DWORD, + ExpireTime: FILETIME, +}} +pub type PCRYPTNET_URL_CACHE_FLUSH_INFO = *mut CRYPTNET_URL_CACHE_FLUSH_INFO; +pub const CRYPTNET_URL_CACHE_DEFAULT_FLUSH: DWORD = 0; +pub const CRYPTNET_URL_CACHE_DISABLE_FLUSH: DWORD = 0xFFFFFFFF; +STRUCT!{struct CRYPTNET_URL_CACHE_RESPONSE_INFO { + cbSize: DWORD, + wResponseType: WORD, + wResponseFlags: WORD, + LastModifiedTime: FILETIME, + dwMaxAge: DWORD, + pwszETag: LPCWSTR, + dwProxyId: DWORD, +}} +pub type PCRYPTNET_URL_CACHE_RESPONSE_INFO = *mut CRYPTNET_URL_CACHE_RESPONSE_INFO; +pub const CRYPTNET_URL_CACHE_RESPONSE_NONE: WORD = 0; +pub const CRYPTNET_URL_CACHE_RESPONSE_HTTP: WORD = 1; +pub const CRYPTNET_URL_CACHE_RESPONSE_VALIDATED: WORD = 0x8000; +STRUCT!{struct CRYPT_RETRIEVE_AUX_INFO { + cbSize: DWORD, + pLastSyncTime: *mut FILETIME, + dwMaxUrlRetrievalByteCount: DWORD, + pPreFetchInfo: PCRYPTNET_URL_CACHE_PRE_FETCH_INFO, + pFlushInfo: PCRYPTNET_URL_CACHE_FLUSH_INFO, + ppResponseInfo: *mut PCRYPTNET_URL_CACHE_RESPONSE_INFO, + pwszCacheFileNamePrefix: LPWSTR, + pftCacheResync: LPFILETIME, + fProxyCacheRetrieval: BOOL, + dwHttpStatusCode: DWORD, + ppwszErrorResponseHeaders: *mut LPWSTR, + ppErrorContentBlob: *mut PCRYPT_DATA_BLOB, +}} +pub type PCRYPT_RETRIEVE_AUX_INFO = *mut CRYPT_RETRIEVE_AUX_INFO; +pub const CRYPT_RETRIEVE_MAX_ERROR_CONTENT_LENGTH: DWORD = 0x1000; +extern "system" { + pub fn CryptRetrieveObjectByUrlA( + pszUrl: LPCSTR, + pszObjectOid: LPCSTR, + dwRetrievalFlags: DWORD, + dwTimeout: DWORD, + ppvObject: *mut LPVOID, + hAsyncRetrieve: HCRYPTASYNC, + pCredentials: PCRYPT_CREDENTIALS, + pvVerify: LPVOID, + pAuxInfo: PCRYPT_RETRIEVE_AUX_INFO, + ) -> BOOL; + pub fn CryptRetrieveObjectByUrlW( + pszUrl: LPCWSTR, + pszObjectOid: LPCSTR, + dwRetrievalFlags: DWORD, + dwTimeout: DWORD, + ppvObject: *mut LPVOID, + hAsyncRetrieve: HCRYPTASYNC, + pCredentials: PCRYPT_CREDENTIALS, + pvVerify: LPVOID, + pAuxInfo: PCRYPT_RETRIEVE_AUX_INFO, + ) -> BOOL; +} +FN!{stdcall PFN_CRYPT_CANCEL_RETRIEVAL( + dwFlags: DWORD, + pvArg: *mut c_void, +) -> BOOL} +extern "system" { + pub fn CryptInstallCancelRetrieval( + pfnCancel: PFN_CRYPT_CANCEL_RETRIEVAL, + pvArg: *const c_void, + dwFlags: DWORD, + pvReserved: *mut c_void, + ) -> BOOL; + pub fn CryptUninstallCancelRetrieval( + dwFlags: DWORD, + pvReserved: *mut c_void, + ) -> BOOL; + pub fn CryptCancelAsyncRetrieval( + hAsyncRetrieval: HCRYPTASYNC, + ) -> BOOL; +} +pub const CRYPT_PARAM_ASYNC_RETRIEVAL_COMPLETION: LPCSTR = 1 as LPCSTR; +FN!{stdcall PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC( + pvCompletion: LPVOID, + dwCompletionCode: DWORD, + pszUrl: LPCSTR, + pszObjectOid: LPSTR, + pvObject: LPVOID, +) -> ()} +STRUCT!{struct CRYPT_ASYNC_RETRIEVAL_COMPLETION { + pfnCompletion: PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC, + pvCompletion: LPVOID, +}} +pub type PCRYPT_ASYNC_RETRIEVAL_COMPLETION = *mut CRYPT_ASYNC_RETRIEVAL_COMPLETION; +pub const CRYPT_PARAM_CANCEL_ASYNC_RETRIEVAL: LPCSTR = 2 as LPCSTR; +FN!{stdcall PFN_CANCEL_ASYNC_RETRIEVAL_FUNC( + hAsyncRetrieve: HCRYPTASYNC, +) -> BOOL} +pub const CRYPT_GET_URL_FROM_PROPERTY: DWORD = 0x00000001; +pub const CRYPT_GET_URL_FROM_EXTENSION: DWORD = 0x00000002; +pub const CRYPT_GET_URL_FROM_UNAUTH_ATTRIBUTE: DWORD = 0x00000004; +pub const CRYPT_GET_URL_FROM_AUTH_ATTRIBUTE: DWORD = 0x00000008; +STRUCT!{struct CRYPT_URL_ARRAY { + cUrl: DWORD, + rgwszUrl: *mut LPWSTR, +}} +pub type PCRYPT_URL_ARRAY = *mut CRYPT_URL_ARRAY; +STRUCT!{struct CRYPT_URL_INFO { + cbSize: DWORD, + dwSyncDeltaTime: DWORD, + cGroup: DWORD, + rgcGroupEntry: *mut DWORD, +}} +pub type PCRYPT_URL_INFO = *mut CRYPT_URL_INFO; +extern "system" { + pub fn CryptGetObjectUrl( + pszUrlOid: LPCSTR, + pvPara: LPVOID, + dwFlags: DWORD, + pUrlArray: PCRYPT_URL_ARRAY, + pcbUrlArray: *mut DWORD, + pUrlInfo: PCRYPT_URL_INFO, + pcbUrlInfo: *mut DWORD, + pvReserved: LPVOID, + ) -> BOOL; +} +pub const URL_OID_GET_OBJECT_URL_FUNC: &'static str = "UrlDllGetObjectUrl"; +pub const URL_OID_CERTIFICATE_ISSUER: LPCSTR = 1 as LPCSTR; +pub const URL_OID_CERTIFICATE_CRL_DIST_POINT: LPCSTR = 2 as LPCSTR; +pub const URL_OID_CTL_ISSUER: LPCSTR = 3 as LPCSTR; +pub const URL_OID_CTL_NEXT_UPDATE: LPCSTR = 4 as LPCSTR; +pub const URL_OID_CRL_ISSUER: LPCSTR = 5 as LPCSTR; +pub const URL_OID_CERTIFICATE_FRESHEST_CRL: LPCSTR = 6 as LPCSTR; +pub const URL_OID_CRL_FRESHEST_CRL: LPCSTR = 7 as LPCSTR; +pub const URL_OID_CROSS_CERT_DIST_POINT: LPCSTR = 8 as LPCSTR; +pub const URL_OID_CERTIFICATE_OCSP: LPCSTR = 9 as LPCSTR; +pub const URL_OID_CERTIFICATE_OCSP_AND_CRL_DIST_POINT: LPCSTR = 10 as LPCSTR; +pub const URL_OID_CERTIFICATE_CRL_DIST_POINT_AND_OCSP: LPCSTR = 11 as LPCSTR; +pub const URL_OID_CROSS_CERT_SUBJECT_INFO_ACCESS: LPCSTR = 12 as LPCSTR; +pub const URL_OID_CERTIFICATE_ONLY_OCSP: LPCSTR = 13 as LPCSTR; +STRUCT!{struct CERT_CRL_CONTEXT_PAIR { + pCertContext: PCCERT_CONTEXT, + pCrlContext: PCCRL_CONTEXT, +}} +pub type PCERT_CRL_CONTEXT_PAIR = *mut CERT_CRL_CONTEXT_PAIR; +pub type PCCERT_CRL_CONTEXT_PAIR = *const CERT_CRL_CONTEXT_PAIR; +STRUCT!{struct CRYPT_GET_TIME_VALID_OBJECT_EXTRA_INFO { + cbSize: DWORD, + iDeltaCrlIndicator: c_int, + pftCacheResync: LPFILETIME, + pLastSyncTime: LPFILETIME, + pMaxAgeTime: LPFILETIME, + pChainPara: PCERT_REVOCATION_CHAIN_PARA, + pDeltaCrlIndicator: PCRYPT_INTEGER_BLOB, +}} +pub type PCRYPT_GET_TIME_VALID_OBJECT_EXTRA_INFO = *mut CRYPT_GET_TIME_VALID_OBJECT_EXTRA_INFO; +extern "system" { + pub fn CryptGetTimeValidObject( + pszTimeValidOid: LPCSTR, + pvPara: LPVOID, + pIssuer: PCCERT_CONTEXT, + pftValidFor: LPFILETIME, + dwFlags: DWORD, + dwTimeout: DWORD, + ppvObject: *mut LPVOID, + pCredentials: PCRYPT_CREDENTIALS, + pExtraInfo: PCRYPT_GET_TIME_VALID_OBJECT_EXTRA_INFO, + ) -> BOOL; +} +pub const TIME_VALID_OID_GET_OBJECT_FUNC: &'static str = "TimeValidDllGetObject"; +pub const TIME_VALID_OID_GET_CTL: LPCSTR = 1 as LPCSTR; +pub const TIME_VALID_OID_GET_CRL: LPCSTR = 2 as LPCSTR; +pub const TIME_VALID_OID_GET_CRL_FROM_CERT: LPCSTR = 3 as LPCSTR; +pub const TIME_VALID_OID_GET_FRESHEST_CRL_FROM_CERT: LPCSTR = 4 as LPCSTR; +pub const TIME_VALID_OID_GET_FRESHEST_CRL_FROM_CRL: LPCSTR = 5 as LPCSTR; +extern "system" { + pub fn CryptFlushTimeValidObject( + pszFlushTimeValidOid: LPCSTR, + pvPara: LPVOID, + pIssuer: PCCERT_CONTEXT, + dwFlags: DWORD, + pvReserved: LPVOID, + ) -> BOOL; +} +pub const TIME_VALID_OID_FLUSH_OBJECT_FUNC: &'static str = "TimeValidDllFlushObject"; +pub const TIME_VALID_OID_FLUSH_CTL: LPCSTR = 1 as LPCSTR; +pub const TIME_VALID_OID_FLUSH_CRL: LPCSTR = 2 as LPCSTR; +pub const TIME_VALID_OID_FLUSH_CRL_FROM_CERT: LPCSTR = 3 as LPCSTR; +pub const TIME_VALID_OID_FLUSH_FRESHEST_CRL_FROM_CERT: LPCSTR = 4 as LPCSTR; +pub const TIME_VALID_OID_FLUSH_FRESHEST_CRL_FROM_CRL: LPCSTR = 5 as LPCSTR; +extern "system" { + pub fn CertCreateSelfSignCertificate( + hCryptProvOrNCryptKey: HCRYPTPROV_OR_NCRYPT_KEY_HANDLE, + pSubjectIssuerBlob: PCERT_NAME_BLOB, + dwFlags: DWORD, + pKeyProvInfo: PCRYPT_KEY_PROV_INFO, + pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER, + pStartTime: PSYSTEMTIME, + pEndTime: PSYSTEMTIME, + pExtensions: PCERT_EXTENSIONS, + ) -> PCCERT_CONTEXT; +} +pub const CERT_CREATE_SELFSIGN_NO_SIGN: DWORD = 1; +pub const CERT_CREATE_SELFSIGN_NO_KEY_INFO: DWORD = 2; +extern "system" { + pub fn CryptGetKeyIdentifierProperty( + pKeyIdentifier: *const CRYPT_HASH_BLOB, + dwPropId: DWORD, + dwFlags: DWORD, + pwszComputerName: LPCWSTR, + pvReserved: *mut c_void, + pvData: *mut c_void, + pcbData: *mut DWORD, + ) -> BOOL; +} +pub const CRYPT_KEYID_MACHINE_FLAG: DWORD = 0x00000020; +pub const CRYPT_KEYID_ALLOC_FLAG: DWORD = 0x00008000; +extern "system" { + pub fn CryptSetKeyIdentifierProperty( + pKeyIdentifier: *const CRYPT_HASH_BLOB, + dwPropId: DWORD, + dwFlags: DWORD, + pwszComputerName: LPCWSTR, + pvReserved: *mut c_void, + pvData: *const c_void, + ) -> BOOL; +} +pub const CRYPT_KEYID_DELETE_FLAG: DWORD = 0x00000010; +pub const CRYPT_KEYID_SET_NEW_FLAG: DWORD = 0x00002000; +FN!{stdcall PFN_CRYPT_ENUM_KEYID_PROP( + pKeyIdentifier: *const CRYPT_HASH_BLOB, + dwFlags: DWORD, + pvReserved: *mut c_void, + pvArg: *mut c_void, + cProp: DWORD, + rgdwPropId: *mut DWORD, + rgpvData: *mut *mut c_void, + rgcbData: *mut DWORD, +) -> BOOL} +extern "system" { + pub fn CryptEnumKeyIdentifierProperties( + pKeyIdentifier: *const CRYPT_HASH_BLOB, + dwPropId: DWORD, + dwFlags: DWORD, + pwszComputerName: LPCWSTR, + pvReserved: *mut c_void, + pvArg: *mut c_void, + pfnEnum: PFN_CRYPT_ENUM_KEYID_PROP, + ) -> BOOL; + pub fn CryptCreateKeyIdentifierFromCSP( + dwCertEncodingType: DWORD, + pszPubKeyOID: LPCSTR, + pPubKeyStruc: *const PUBLICKEYSTRUC, + cbPubKeyStruc: DWORD, + dwFlags: DWORD, + pvReserved: *mut c_void, + pbHash: *mut BYTE, + pcbHash: *mut DWORD, + ) -> BOOL; +} +pub const CERT_CHAIN_CONFIG_REGPATH: &'static str + = "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CertDllCreateCertificateChainEngine\\Config"; +pub const CERT_CHAIN_MAX_URL_RETRIEVAL_BYTE_COUNT_VALUE_NAME: &'static str + = "MaxUrlRetrievalByteCount"; +pub const CERT_CHAIN_MAX_URL_RETRIEVAL_BYTE_COUNT_DEFAULT: DWORD = 100 * 1024 * 1024; +pub const CERT_CHAIN_CACHE_RESYNC_FILETIME_VALUE_NAME: &'static str = "ChainCacheResyncFiletime"; +pub const CERT_CHAIN_DISABLE_MANDATORY_BASIC_CONSTRAINTS_VALUE_NAME: &'static str + = "DisableMandatoryBasicConstraints"; +pub const CERT_CHAIN_DISABLE_CA_NAME_CONSTRAINTS_VALUE_NAME: &'static str + = "DisableCANameConstraints"; +pub const CERT_CHAIN_DISABLE_UNSUPPORTED_CRITICAL_EXTENSIONS_VALUE_NAME: &'static str + = "DisableUnsupportedCriticalExtensions"; +pub const CERT_CHAIN_MAX_AIA_URL_COUNT_IN_CERT_VALUE_NAME: &'static str = "MaxAIAUrlCountInCert"; +pub const CERT_CHAIN_MAX_AIA_URL_COUNT_IN_CERT_DEFAULT: DWORD = 5; +pub const CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_COUNT_PER_CHAIN_VALUE_NAME: &'static str + = "MaxAIAUrlRetrievalCountPerChain"; +pub const CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_COUNT_PER_CHAIN_DEFAULT: DWORD = 3; +pub const CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_BYTE_COUNT_VALUE_NAME: &'static str + = "MaxAIAUrlRetrievalByteCount"; +pub const CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_BYTE_COUNT_DEFAULT: DWORD = 100000; +pub const CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_CERT_COUNT_VALUE_NAME: &'static str + = "MaxAIAUrlRetrievalCertCount"; +pub const CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_CERT_COUNT_DEFAULT: DWORD = 10; +pub const CERT_CHAIN_OCSP_VALIDITY_SECONDS_VALUE_NAME: &'static str + = "OcspValiditySeconds"; +pub const CERT_CHAIN_OCSP_VALIDITY_SECONDS_DEFAULT: DWORD = 12 * 60 * 60; +pub const CERT_CHAIN_DISABLE_SERIAL_CHAIN_VALUE_NAME: &'static str = "DisableSerialChain"; +pub const CERT_CHAIN_SERIAL_CHAIN_LOG_FILE_NAME_VALUE_NAME: &'static str + = "SerialChainLogFileName"; +pub const CERT_CHAIN_DISABLE_SYNC_WITH_SSL_TIME_VALUE_NAME: &'static str + = "DisableSyncWithSslTime"; +pub const CERT_CHAIN_MAX_SSL_TIME_UPDATED_EVENT_COUNT_VALUE_NAME: &'static str + = "MaxSslTimeUpdatedEventCount"; +pub const CERT_CHAIN_MAX_SSL_TIME_UPDATED_EVENT_COUNT_DEFAULT: DWORD = 5; +pub const CERT_CHAIN_MAX_SSL_TIME_UPDATED_EVENT_COUNT_DISABLE: DWORD = 0xFFFFFFFF; +pub const CERT_CHAIN_SSL_HANDSHAKE_LOG_FILE_NAME_VALUE_NAME: &'static str + = "SslHandshakeLogFileName"; +pub const CERT_CHAIN_ENABLE_WEAK_SIGNATURE_FLAGS_VALUE_NAME: &'static str + = "EnableWeakSignatureFlags"; +pub const CERT_CHAIN_ENABLE_MD2_MD4_FLAG: DWORD = 0x00000001; +pub const CERT_CHAIN_ENABLE_WEAK_RSA_ROOT_FLAG: DWORD = 0x00000002; +pub const CERT_CHAIN_ENABLE_WEAK_LOGGING_FLAG: DWORD = 0x00000004; +pub const CERT_CHAIN_ENABLE_ONLY_WEAK_LOGGING_FLAG: DWORD = 0x00000008; +pub const CERT_CHAIN_MIN_RSA_PUB_KEY_BIT_LENGTH_VALUE_NAME: &'static str = "MinRsaPubKeyBitLength"; +pub const CERT_CHAIN_MIN_RSA_PUB_KEY_BIT_LENGTH_DEFAULT: DWORD = 1023; +pub const CERT_CHAIN_MIN_RSA_PUB_KEY_BIT_LENGTH_DISABLE: DWORD = 0xFFFFFFFF; +pub const CERT_CHAIN_WEAK_RSA_PUB_KEY_TIME_VALUE_NAME: &'static str = "WeakRsaPubKeyTime"; +pub const CERT_CHAIN_WEAK_RSA_PUB_KEY_TIME_DEFAULT: u64 = 0x01CA8A755C6E0000; +pub const CERT_CHAIN_WEAK_SIGNATURE_LOG_DIR_VALUE_NAME: &'static str = "WeakSignatureLogDir"; +pub const CERT_CHAIN_DEFAULT_CONFIG_SUBDIR: &'static str = "Default"; +pub const CERT_CHAIN_WEAK_PREFIX_NAME: &'static str = "Weak"; +pub const CERT_CHAIN_WEAK_THIRD_PARTY_CONFIG_NAME: &'static str = "ThirdParty"; +pub const CERT_CHAIN_WEAK_ALL_CONFIG_NAME: &'static str = "Al"; +pub const CERT_CHAIN_WEAK_FLAGS_NAME: &'static str = "Flags"; +pub const CERT_CHAIN_WEAK_HYGIENE_NAME: &'static str = "Hygiene"; +pub const CERT_CHAIN_WEAK_AFTER_TIME_NAME: &'static str = "AfterTime"; +pub const CERT_CHAIN_WEAK_FILE_HASH_AFTER_TIME_NAME: &'static str = "FileHashAfterTime"; +pub const CERT_CHAIN_WEAK_TIMESTAMP_HASH_AFTER_TIME_NAME: &'static str = "TimestampHashAfterTime"; +pub const CERT_CHAIN_WEAK_MIN_BIT_LENGTH_NAME: &'static str = "MinBitLength"; +pub const CERT_CHAIN_WEAK_SHA256_ALLOW_NAME: &'static str = "Sha256Allow"; +pub const CERT_CHAIN_MIN_PUB_KEY_BIT_LENGTH_DISABLE: DWORD = 0xFFFFFFFF; +pub const CERT_CHAIN_ENABLE_WEAK_SETTINGS_FLAG: DWORD = 0x80000000; +pub const CERT_CHAIN_DISABLE_ALL_EKU_WEAK_FLAG: DWORD = 0x00010000; +pub const CERT_CHAIN_ENABLE_ALL_EKU_HYGIENE_FLAG: DWORD = 0x00020000; +pub const CERT_CHAIN_DISABLE_OPT_IN_SERVER_AUTH_WEAK_FLAG: DWORD = 0x00040000; +pub const CERT_CHAIN_DISABLE_SERVER_AUTH_WEAK_FLAG: DWORD = 0x00100000; +pub const CERT_CHAIN_ENABLE_SERVER_AUTH_HYGIENE_FLAG: DWORD = 0x00200000; +pub const CERT_CHAIN_DISABLE_CODE_SIGNING_WEAK_FLAG: DWORD = 0x00400000; +pub const CERT_CHAIN_DISABLE_MOTW_CODE_SIGNING_WEAK_FLAG: DWORD = 0x00800000; +pub const CERT_CHAIN_ENABLE_CODE_SIGNING_HYGIENE_FLAG: DWORD = 0x01000000; +pub const CERT_CHAIN_ENABLE_MOTW_CODE_SIGNING_HYGIENE_FLAG: DWORD = 0x02000000; +pub const CERT_CHAIN_DISABLE_TIMESTAMP_WEAK_FLAG: DWORD = 0x04000000; +pub const CERT_CHAIN_DISABLE_MOTW_TIMESTAMP_WEAK_FLAG: DWORD = 0x08000000; +pub const CERT_CHAIN_ENABLE_TIMESTAMP_HYGIENE_FLAG: DWORD = 0x10000000; +pub const CERT_CHAIN_ENABLE_MOTW_TIMESTAMP_HYGIENE_FLAG: DWORD = 0x20000000; +pub const CERT_CHAIN_MOTW_IGNORE_AFTER_TIME_WEAK_FLAG: DWORD = 0x40000000; +pub const CERT_CHAIN_DISABLE_FILE_HASH_WEAK_FLAG: DWORD = 0x00001000; +pub const CERT_CHAIN_DISABLE_MOTW_FILE_HASH_WEAK_FLAG: DWORD = 0x00002000; +pub const CERT_CHAIN_DISABLE_TIMESTAMP_HASH_WEAK_FLAG: DWORD = 0x00004000; +pub const CERT_CHAIN_DISABLE_MOTW_TIMESTAMP_HASH_WEAK_FLAG: DWORD = 0x00008000; +pub const CERT_CHAIN_DISABLE_WEAK_FLAGS: DWORD = CERT_CHAIN_DISABLE_ALL_EKU_WEAK_FLAG + | CERT_CHAIN_DISABLE_SERVER_AUTH_WEAK_FLAG | CERT_CHAIN_DISABLE_OPT_IN_SERVER_AUTH_WEAK_FLAG + | CERT_CHAIN_DISABLE_CODE_SIGNING_WEAK_FLAG | CERT_CHAIN_DISABLE_MOTW_CODE_SIGNING_WEAK_FLAG + | CERT_CHAIN_DISABLE_TIMESTAMP_WEAK_FLAG | CERT_CHAIN_DISABLE_MOTW_TIMESTAMP_WEAK_FLAG; +pub const CERT_CHAIN_DISABLE_FILE_HASH_WEAK_FLAGS: DWORD = CERT_CHAIN_DISABLE_FILE_HASH_WEAK_FLAG + | CERT_CHAIN_DISABLE_MOTW_FILE_HASH_WEAK_FLAG; +pub const CERT_CHAIN_DISABLE_TIMESTAMP_HASH_WEAK_FLAGS: DWORD + = CERT_CHAIN_DISABLE_TIMESTAMP_HASH_WEAK_FLAG + | CERT_CHAIN_DISABLE_MOTW_TIMESTAMP_HASH_WEAK_FLAG; +pub const CERT_CHAIN_ENABLE_HYGIENE_FLAGS: DWORD = CERT_CHAIN_ENABLE_ALL_EKU_HYGIENE_FLAG + | CERT_CHAIN_ENABLE_SERVER_AUTH_HYGIENE_FLAG | CERT_CHAIN_ENABLE_CODE_SIGNING_HYGIENE_FLAG + | CERT_CHAIN_ENABLE_MOTW_CODE_SIGNING_HYGIENE_FLAG | CERT_CHAIN_ENABLE_TIMESTAMP_HYGIENE_FLAG + | CERT_CHAIN_ENABLE_MOTW_TIMESTAMP_HYGIENE_FLAG; +pub const CERT_CHAIN_MOTW_WEAK_FLAGS: DWORD = CERT_CHAIN_DISABLE_MOTW_CODE_SIGNING_WEAK_FLAG + | CERT_CHAIN_DISABLE_MOTW_TIMESTAMP_WEAK_FLAG + | CERT_CHAIN_ENABLE_MOTW_CODE_SIGNING_HYGIENE_FLAG + | CERT_CHAIN_ENABLE_MOTW_TIMESTAMP_HYGIENE_FLAG | CERT_CHAIN_MOTW_IGNORE_AFTER_TIME_WEAK_FLAG; +pub const CERT_CHAIN_OPT_IN_WEAK_FLAGS: DWORD = CERT_CHAIN_DISABLE_OPT_IN_SERVER_AUTH_WEAK_FLAG; +pub const CERT_CHAIN_AUTO_CURRENT_USER: DWORD = 1; +pub const CERT_CHAIN_AUTO_LOCAL_MACHINE: DWORD = 2; +pub const CERT_CHAIN_AUTO_IMPERSONATED: DWORD = 3; +pub const CERT_CHAIN_AUTO_PROCESS_INFO: DWORD = 4; +pub const CERT_CHAIN_AUTO_PINRULE_INFO: DWORD = 5; +pub const CERT_CHAIN_AUTO_NETWORK_INFO: DWORD = 6; +pub const CERT_CHAIN_AUTO_SERIAL_LOCAL_MACHINE: DWORD = 7; +pub const CERT_CHAIN_AUTO_HPKP_RULE_INFO: DWORD = 8; +pub const CERT_CHAIN_AUTO_FLAGS_VALUE_NAME: &'static str = "AutoFlags"; +pub const CERT_CHAIN_AUTO_FLUSH_DISABLE_FLAG: DWORD = 0x00000001; +pub const CERT_CHAIN_AUTO_LOG_CREATE_FLAG: DWORD = 0x00000002; +pub const CERT_CHAIN_AUTO_LOG_FREE_FLAG: DWORD = 0x00000004; +pub const CERT_CHAIN_AUTO_LOG_FLUSH_FLAG: DWORD = 0x00000008; +pub const CERT_CHAIN_AUTO_LOG_FLAGS: DWORD = CERT_CHAIN_AUTO_LOG_CREATE_FLAG + | CERT_CHAIN_AUTO_LOG_FREE_FLAG | CERT_CHAIN_AUTO_LOG_FLUSH_FLAG; +pub const CERT_CHAIN_AUTO_FLUSH_FIRST_DELTA_SECONDS_VALUE_NAME: &'static str + = "AutoFlushFirstDeltaSeconds"; +pub const CERT_CHAIN_AUTO_FLUSH_FIRST_DELTA_SECONDS_DEFAULT: DWORD = 5 * 60; +pub const CERT_CHAIN_AUTO_FLUSH_NEXT_DELTA_SECONDS_VALUE_NAME: &'static str + = "AutoFlushNextDeltaSeconds"; +pub const CERT_CHAIN_AUTO_FLUSH_NEXT_DELTA_SECONDS_DEFAULT: DWORD = 30 * 60; +pub const CERT_CHAIN_AUTO_LOG_FILE_NAME_VALUE_NAME: &'static str = "AutoLogFileName"; +pub const CERT_CHAIN_DISABLE_AUTO_FLUSH_PROCESS_NAME_LIST_VALUE_NAME: &'static str + = "DisableAutoFlushProcessNameList"; +pub const CERT_SRV_OCSP_RESP_MIN_VALIDITY_SECONDS_VALUE_NAME: &'static str + = "SrvOcspRespMinValiditySeconds"; +pub const CERT_SRV_OCSP_RESP_MIN_VALIDITY_SECONDS_DEFAULT: DWORD = 10 * 60; +pub const CERT_SRV_OCSP_RESP_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_VALUE_NAME: &'static str + = "SrvOcspRespUrlRetrievalTimeoutMilliseconds"; +pub const CERT_SRV_OCSP_RESP_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_DEFAULT: DWORD = 15 * 1000; +pub const CERT_SRV_OCSP_RESP_MAX_BEFORE_NEXT_UPDATE_SECONDS_VALUE_NAME: &'static str + = "SrvOcspRespMaxBeforeNextUpdateSeconds"; +pub const CERT_SRV_OCSP_RESP_MAX_BEFORE_NEXT_UPDATE_SECONDS_DEFAULT: DWORD = 4 * 60 * 60; +pub const CERT_SRV_OCSP_RESP_MIN_BEFORE_NEXT_UPDATE_SECONDS_VALUE_NAME: &'static str + = "SrvOcspRespMinBeforeNextUpdateSeconds"; +pub const CERT_SRV_OCSP_RESP_MIN_BEFORE_NEXT_UPDATE_SECONDS_DEFAULT: DWORD = 2 * 60; +pub const CERT_SRV_OCSP_RESP_MIN_AFTER_NEXT_UPDATE_SECONDS_VALUE_NAME: &'static str + = "SrvOcspRespMinAfterNextUpdateSeconds"; +pub const CERT_SRV_OCSP_RESP_MIN_AFTER_NEXT_UPDATE_SECONDS_DEFAULT: DWORD = 1 * 60; +pub const CERT_SRV_OCSP_RESP_MIN_SYNC_CERT_FILE_SECONDS_VALUE_NAME: &'static str + = "SrvOcspRespMinSyncCertFileSeconds"; +pub const CERT_SRV_OCSP_RESP_MIN_SYNC_CERT_FILE_SECONDS_DEFAULT: DWORD = 5; +pub const CERT_SRV_OCSP_RESP_MAX_SYNC_CERT_FILE_SECONDS_VALUE_NAME: &'static str + = "SrvOcspRespMaxSyncCertFileSeconds"; +pub const CERT_SRV_OCSP_RESP_MAX_SYNC_CERT_FILE_SECONDS_DEFAULT: DWORD = 1 * 60 * 60; +pub const CRYPTNET_MAX_CACHED_OCSP_PER_CRL_COUNT_VALUE_NAME: &'static str + = "CryptnetMaxCachedOcspPerCrlCount"; +pub const CRYPTNET_MAX_CACHED_OCSP_PER_CRL_COUNT_DEFAULT: DWORD = 500; +pub const CRYPTNET_OCSP_AFTER_CRL_DISABLE: DWORD = 0xFFFFFFFF; +pub const CRYPTNET_URL_CACHE_DEFAULT_FLUSH_EXEMPT_SECONDS_VALUE_NAME: &'static str + = "CryptnetDefaultFlushExemptSeconds"; +pub const CRYPTNET_URL_CACHE_DEFAULT_FLUSH_EXEMPT_SECONDS_DEFAULT: DWORD = 28 * 24 * 60 * 60; +pub const CRYPTNET_PRE_FETCH_MIN_MAX_AGE_SECONDS_VALUE_NAME: &'static str + = "CryptnetPreFetchMinMaxAgeSeconds"; +pub const CRYPTNET_PRE_FETCH_MIN_MAX_AGE_SECONDS_DEFAULT: DWORD = 1 * 60 * 60; +pub const CRYPTNET_PRE_FETCH_MAX_MAX_AGE_SECONDS_VALUE_NAME: &'static str + = "CryptnetPreFetchMaxMaxAgeSeconds"; +pub const CRYPTNET_PRE_FETCH_MAX_MAX_AGE_SECONDS_DEFAULT: DWORD = 14 * 24 * 60 * 60; +pub const CRYPTNET_PRE_FETCH_MIN_OCSP_VALIDITY_PERIOD_SECONDS_VALUE_NAME: &'static str + = "CryptnetPreFetchMinOcspValidityPeriodSeconds"; +pub const CRYPTNET_PRE_FETCH_MIN_OCSP_VALIDITY_PERIOD_SECONDS_DEFAULT: DWORD = 14 * 24 * 60 * 60; +pub const CRYPTNET_PRE_FETCH_AFTER_PUBLISH_PRE_FETCH_DIVISOR_VALUE_NAME: &'static str + = "CryptnetPreFetchAfterPublishPreFetchDivisor"; +pub const CRYPTNET_PRE_FETCH_AFTER_PUBLISH_PRE_FETCH_DIVISOR_DEFAULT: DWORD = 10; +pub const CRYPTNET_PRE_FETCH_BEFORE_NEXT_UPDATE_PRE_FETCH_DIVISOR_VALUE_NAME: &'static str + = "CryptnetPreFetchBeforeNextUpdatePreFetchDivisor"; +pub const CRYPTNET_PRE_FETCH_BEFORE_NEXT_UPDATE_PRE_FETCH_DIVISOR_DEFAULT: DWORD = 20; +pub const CRYPTNET_PRE_FETCH_MIN_BEFORE_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_VALUE_NAME: + &'static str = "CryptnetPreFetchMinBeforeNextUpdatePreFetchSeconds"; +pub const CRYPTNET_PRE_FETCH_MIN_BEFORE_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_DEFAULT: DWORD + = 1 * 60 * 60; +pub const CRYPTNET_PRE_FETCH_VALIDITY_PERIOD_AFTER_NEXT_UPDATE_PRE_FETCH_DIVISOR_VALUE_NAME: + &'static str = "CryptnetPreFetchValidityPeriodAfterNextUpdatePreFetchDivisor"; +pub const CRYPTNET_PRE_FETCH_VALIDITY_PERIOD_AFTER_NEXT_UPDATE_PRE_FETCH_DIVISOR_DEFAULT: DWORD + = 10; +pub const CRYPTNET_PRE_FETCH_MAX_AFTER_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_VALUE_NAME: + &'static str = "CryptnetPreFetchMaxAfterNextUpdatePreFetchPeriodSeconds"; +pub const CRYPTNET_PRE_FETCH_MAX_AFTER_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_DEFAULT: DWORD + = 4 * 60 * 60; +pub const CRYPTNET_PRE_FETCH_MIN_AFTER_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_VALUE_NAME: + &'static str = "CryptnetPreFetchMinAfterNextUpdatePreFetchPeriodSeconds"; +pub const CRYPTNET_PRE_FETCH_MIN_AFTER_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_DEFAULT: DWORD + = 30 * 60; +pub const CRYPTNET_PRE_FETCH_AFTER_CURRENT_TIME_PRE_FETCH_PERIOD_SECONDS_VALUE_NAME: &'static str + = "CryptnetPreFetchAfterCurrentTimePreFetchPeriodSeconds"; +pub const CRYPTNET_PRE_FETCH_AFTER_CURRENT_TIME_PRE_FETCH_PERIOD_SECONDS_DEFAULT: DWORD + = 30 * 60; +pub const CRYPTNET_PRE_FETCH_TRIGGER_PERIOD_SECONDS_VALUE_NAME: &'static str + = "CryptnetPreFetchTriggerPeriodSeconds"; +pub const CRYPTNET_PRE_FETCH_TRIGGER_PERIOD_SECONDS_DEFAULT: DWORD = 10 * 60; +pub const CRYPTNET_PRE_FETCH_TRIGGER_DISABLE: DWORD = 0xFFFFFFFF; +pub const CRYPTNET_PRE_FETCH_SCAN_AFTER_TRIGGER_DELAY_SECONDS_VALUE_NAME: &'static str + = "CryptnetPreFetchScanAfterTriggerDelaySeconds"; +pub const CRYPTNET_PRE_FETCH_SCAN_AFTER_TRIGGER_DELAY_SECONDS_DEFAULT: DWORD = 60; +pub const CRYPTNET_PRE_FETCH_RETRIEVAL_TIMEOUT_SECONDS_VALUE_NAME: &'static str + = "CryptnetPreFetchRetrievalTimeoutSeconds"; +pub const CRYPTNET_PRE_FETCH_RETRIEVAL_TIMEOUT_SECONDS_DEFAULT: DWORD = 5 * 60; +pub const CRYPTNET_CRL_PRE_FETCH_CONFIG_REGPATH: &'static str + = "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CertDllCreateCertificateChainEngine\\Config\\CrlPreFetch"; +pub const CRYPTNET_CRL_PRE_FETCH_PROCESS_NAME_LIST_VALUE_NAME: &'static str = "ProcessNameList"; +pub const CRYPTNET_CRL_PRE_FETCH_URL_LIST_VALUE_NAME: &'static str = "PreFetchUrlList"; +pub const CRYPTNET_CRL_PRE_FETCH_DISABLE_INFORMATION_EVENTS_VALUE_NAME: &'static str + = "DisableInformationEvents"; +pub const CRYPTNET_CRL_PRE_FETCH_LOG_FILE_NAME_VALUE_NAME: &'static str = "LogFileName"; +pub const CRYPTNET_CRL_PRE_FETCH_TIMEOUT_SECONDS_VALUE_NAME: &'static str = "TimeoutSeconds"; +pub const CRYPTNET_CRL_PRE_FETCH_TIMEOUT_SECONDS_DEFAULT: DWORD = 5 * 60; +pub const CRYPTNET_CRL_PRE_FETCH_MAX_AGE_SECONDS_VALUE_NAME: &'static str = "MaxAgeSeconds"; +pub const CRYPTNET_CRL_PRE_FETCH_MAX_AGE_SECONDS_DEFAULT: DWORD = 2 * 60 * 60; +pub const CRYPTNET_CRL_PRE_FETCH_MAX_AGE_SECONDS_MIN: DWORD = 5 * 60; +pub const CRYPTNET_CRL_PRE_FETCH_PUBLISH_BEFORE_NEXT_UPDATE_SECONDS_VALUE_NAME: &'static str + = "PublishBeforeNextUpdateSeconds"; +pub const CRYPTNET_CRL_PRE_FETCH_PUBLISH_BEFORE_NEXT_UPDATE_SECONDS_DEFAULT: DWORD = 1 * 60 * 60; +pub const CRYPTNET_CRL_PRE_FETCH_PUBLISH_RANDOM_INTERVAL_SECONDS_VALUE_NAME: &'static str + = "PublishRandomIntervalSeconds"; +pub const CRYPTNET_CRL_PRE_FETCH_PUBLISH_RANDOM_INTERVAL_SECONDS_DEFAULT: DWORD = 5 * 60; +pub const CRYPTNET_CRL_PRE_FETCH_MIN_BEFORE_NEXT_UPDATE_SECONDS_VALUE_NAME: &'static str + = "MinBeforeNextUpdateSeconds"; +pub const CRYPTNET_CRL_PRE_FETCH_MIN_BEFORE_NEXT_UPDATE_SECONDS_DEFAULT: DWORD = 5 * 60; +pub const CRYPTNET_CRL_PRE_FETCH_MIN_AFTER_NEXT_UPDATE_SECONDS_VALUE_NAME: &'static str + = "MinAfterNextUpdateSeconds"; +pub const CRYPTNET_CRL_PRE_FETCH_MIN_AFTER_NEXT_UPDATE_SECONDS_DEFAULT: DWORD = 5 * 60; +pub const CERT_GROUP_POLICY_CHAIN_CONFIG_REGPATH: &'static str + = "Software\\Policies\\Microsoft\\SystemCertificates\\ChainEngine\\Config"; +pub const CERT_CHAIN_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_VALUE_NAME: &'static str + = "ChainUrlRetrievalTimeoutMilliseconds"; +pub const CERT_CHAIN_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_DEFAULT: DWORD = 15 * 1000; +pub const CERT_CHAIN_REV_ACCUMULATIVE_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_VALUE_NAME: &'static str + = "ChainRevAccumulativeUrlRetrievalTimeoutMilliseconds"; +pub const CERT_CHAIN_REV_ACCUMULATIVE_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_DEFAULT: DWORD + = 20 * 1000; +pub const CERT_RETR_BEHAVIOR_INET_AUTH_VALUE_NAME: &'static str = "EnableInetUnknownAuth"; +pub const CERT_RETR_BEHAVIOR_INET_STATUS_VALUE_NAME: &'static str = "EnableInetLocal"; +pub const CERT_RETR_BEHAVIOR_FILE_VALUE_NAME: &'static str = "AllowFileUrlScheme"; +pub const CERT_RETR_BEHAVIOR_LDAP_VALUE_NAME: &'static str = "DisableLDAPSignAndEncrypt"; +pub const CRYPTNET_CACHED_OCSP_SWITCH_TO_CRL_COUNT_VALUE_NAME: &'static str + = "CryptnetCachedOcspSwitchToCrlCount"; +pub const CRYPTNET_CACHED_OCSP_SWITCH_TO_CRL_COUNT_DEFAULT: DWORD = 50; +pub const CRYPTNET_CRL_BEFORE_OCSP_ENABLE: DWORD = 0xFFFFFFFF; +pub const CERT_CHAIN_DISABLE_AIA_URL_RETRIEVAL_VALUE_NAME: &'static str = "DisableAIAUrlRetrieval"; +pub const CERT_CHAIN_OPTIONS_VALUE_NAME: &'static str = "Options"; +pub const CERT_CHAIN_OPTION_DISABLE_AIA_URL_RETRIEVAL: DWORD = 0x2; +pub const CERT_CHAIN_OPTION_ENABLE_SIA_URL_RETRIEVAL: DWORD = 0x4; +pub const CERT_CHAIN_CROSS_CERT_DOWNLOAD_INTERVAL_HOURS_VALUE_NAME: &'static str + = "CrossCertDownloadIntervalHours"; +pub const CERT_CHAIN_CROSS_CERT_DOWNLOAD_INTERVAL_HOURS_DEFAULT: DWORD = 24 * 7; +pub const CERT_CHAIN_CRL_VALIDITY_EXT_PERIOD_HOURS_VALUE_NAME: &'static str + = "CRLValidityExtensionPeriod"; +pub const CERT_CHAIN_CRL_VALIDITY_EXT_PERIOD_HOURS_DEFAULT: DWORD = 12; +pub type HCERTCHAINENGINE = HANDLE; +pub const HCCE_CURRENT_USER: HCERTCHAINENGINE = 0 as HCERTCHAINENGINE; +pub const HCCE_LOCAL_MACHINE: HCERTCHAINENGINE = 0x1 as HCERTCHAINENGINE; +pub const HCCE_SERIAL_LOCAL_MACHINE: HCERTCHAINENGINE = 0x2 as HCERTCHAINENGINE; +pub const CERT_CHAIN_CACHE_END_CERT: DWORD = 0x00000001; +pub const CERT_CHAIN_THREAD_STORE_SYNC: DWORD = 0x00000002; +pub const CERT_CHAIN_CACHE_ONLY_URL_RETRIEVAL: DWORD = 0x00000004; +pub const CERT_CHAIN_USE_LOCAL_MACHINE_STORE: DWORD = 0x00000008; +pub const CERT_CHAIN_ENABLE_CACHE_AUTO_UPDATE: DWORD = 0x00000010; +pub const CERT_CHAIN_ENABLE_SHARE_STORE: DWORD = 0x00000020; +STRUCT!{struct CERT_CHAIN_ENGINE_CONFIG { + cbSize: DWORD, + hRestrictedRoot: HCERTSTORE, + hRestrictedTrust: HCERTSTORE, + hRestrictedOther: HCERTSTORE, + cAdditionalStore: DWORD, + rghAdditionalStore: *mut HCERTSTORE, + dwFlags: DWORD, + dwUrlRetrievalTimeout: DWORD, + MaximumCachedCertificates: DWORD, + CycleDetectionModulus: DWORD, + hExclusiveRoot: HCERTSTORE, + hExclusiveTrustedPeople: HCERTSTORE, + dwExclusiveFlags: DWORD, +}} +pub type PCERT_CHAIN_ENGINE_CONFIG = *mut CERT_CHAIN_ENGINE_CONFIG; +extern "system" { + pub fn CertCreateCertificateChainEngine( + pConfig: PCERT_CHAIN_ENGINE_CONFIG, + phChainEngine: *mut HCERTCHAINENGINE, + ) -> BOOL; + pub fn CertFreeCertificateChainEngine( + hChainEngine: HCERTCHAINENGINE, + ); + pub fn CertResyncCertificateChainEngine( + hChainEngine: HCERTCHAINENGINE, + ) -> BOOL; +} +STRUCT!{struct CERT_TRUST_STATUS { + dwErrorStatus: DWORD, + dwInfoStatus: DWORD, +}} +pub type PCERT_TRUST_STATUS = *mut CERT_TRUST_STATUS; +pub const CERT_TRUST_NO_ERROR: DWORD = 0x00000000; +pub const CERT_TRUST_IS_NOT_TIME_VALID: DWORD = 0x00000001; +pub const CERT_TRUST_IS_NOT_TIME_NESTED: DWORD = 0x00000002; +pub const CERT_TRUST_IS_REVOKED: DWORD = 0x00000004; +pub const CERT_TRUST_IS_NOT_SIGNATURE_VALID: DWORD = 0x00000008; +pub const CERT_TRUST_IS_NOT_VALID_FOR_USAGE: DWORD = 0x00000010; +pub const CERT_TRUST_IS_UNTRUSTED_ROOT: DWORD = 0x00000020; +pub const CERT_TRUST_REVOCATION_STATUS_UNKNOWN: DWORD = 0x00000040; +pub const CERT_TRUST_IS_CYCLIC: DWORD = 0x00000080; +pub const CERT_TRUST_INVALID_EXTENSION: DWORD = 0x00000100; +pub const CERT_TRUST_INVALID_POLICY_CONSTRAINTS: DWORD = 0x00000200; +pub const CERT_TRUST_INVALID_BASIC_CONSTRAINTS: DWORD = 0x00000400; +pub const CERT_TRUST_INVALID_NAME_CONSTRAINTS: DWORD = 0x00000800; +pub const CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT: DWORD = 0x00001000; +pub const CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT: DWORD = 0x00002000; +pub const CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT: DWORD = 0x00004000; +pub const CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT: DWORD = 0x00008000; +pub const CERT_TRUST_IS_OFFLINE_REVOCATION: DWORD = 0x01000000; +pub const CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY: DWORD = 0x02000000; +pub const CERT_TRUST_IS_PARTIAL_CHAIN: DWORD = 0x00010000; +pub const CERT_TRUST_CTL_IS_NOT_TIME_VALID: DWORD = 0x00020000; +pub const CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID: DWORD = 0x00040000; +pub const CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE: DWORD = 0x00080000; +pub const CERT_TRUST_HAS_EXACT_MATCH_ISSUER: DWORD = 0x00000001; +pub const CERT_TRUST_HAS_KEY_MATCH_ISSUER: DWORD = 0x00000002; +pub const CERT_TRUST_HAS_NAME_MATCH_ISSUER: DWORD = 0x00000004; +pub const CERT_TRUST_IS_SELF_SIGNED: DWORD = 0x00000008; +pub const CERT_TRUST_AUTO_UPDATE_CA_REVOCATION: DWORD = 0x00000010; +pub const CERT_TRUST_AUTO_UPDATE_END_REVOCATION: DWORD = 0x00000020; +pub const CERT_TRUST_NO_OCSP_FAILOVER_TO_CRL: DWORD = 0x00000040; +pub const CERT_TRUST_IS_KEY_ROLLOVER: DWORD = 0x00000080; +pub const CERT_TRUST_SSL_HANDSHAKE_OCSP: DWORD = 0x00040000; +pub const CERT_TRUST_SSL_TIME_VALID_OCSP: DWORD = 0x00080000; +pub const CERT_TRUST_SSL_RECONNECT_OCSP: DWORD = 0x00100000; +pub const CERT_TRUST_HAS_PREFERRED_ISSUER: DWORD = 0x00000100; +pub const CERT_TRUST_HAS_ISSUANCE_CHAIN_POLICY: DWORD = 0x00000200; +pub const CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS: DWORD = 0x00000400; +pub const CERT_TRUST_IS_PEER_TRUSTED: DWORD = 0x00000800; +pub const CERT_TRUST_HAS_CRL_VALIDITY_EXTENDED: DWORD = 0x00001000; +pub const CERT_TRUST_IS_FROM_EXCLUSIVE_TRUST_STORE: DWORD = 0x00002000; +pub const CERT_TRUST_IS_CA_TRUSTED: DWORD = 0x00004000; +pub const CERT_TRUST_HAS_AUTO_UPDATE_WEAK_SIGNATURE: DWORD = 0x00008000; +pub const CERT_TRUST_HAS_ALLOW_WEAK_SIGNATURE: DWORD = 0x00020000; +pub const CERT_TRUST_IS_COMPLEX_CHAIN: DWORD = 0x00010000; +pub const CERT_TRUST_SSL_TIME_VALID: DWORD = 0x01000000; +pub const CERT_TRUST_NO_TIME_CHECK: DWORD = 0x02000000; +STRUCT!{struct CERT_REVOCATION_INFO { + cbSize: DWORD, + dwRevocationResult: DWORD, + pszRevocationOid: LPCSTR, + pvOidSpecificInfo: LPVOID, + fHasFreshnessTime: BOOL, + dwFreshnessTime: DWORD, + pCrlInfo: PCERT_REVOCATION_CRL_INFO, +}} +pub type PCERT_REVOCATION_INFO = *mut CERT_REVOCATION_INFO; +STRUCT!{struct CERT_TRUST_LIST_INFO { + cbSize: DWORD, + pCtlEntry: PCTL_ENTRY, + pCtlContext: PCCTL_CONTEXT, +}} +pub type PCERT_TRUST_LIST_INFO = *mut CERT_TRUST_LIST_INFO; +STRUCT!{struct CERT_CHAIN_ELEMENT { + cbSize: DWORD, + pCertContext: PCCERT_CONTEXT, + TrustStatus: CERT_TRUST_STATUS, + pRevocationInfo: PCERT_REVOCATION_INFO, + pIssuanceUsage: PCERT_ENHKEY_USAGE, + pApplicationUsage: PCERT_ENHKEY_USAGE, + pwszExtendedErrorInfo: LPWSTR, +}} +pub type PCERT_CHAIN_ELEMENT = *mut CERT_CHAIN_ELEMENT; +pub type PCCERT_CHAIN_ELEMENT = *const CERT_CHAIN_ELEMENT; +STRUCT!{struct CERT_SIMPLE_CHAIN { + cbSize: DWORD, + TrustStatus: CERT_TRUST_STATUS, + cElement: DWORD, + rgpElement: *mut PCERT_CHAIN_ELEMENT, + pTrustListInfo: PCERT_TRUST_LIST_INFO, + fHasRevocationFreshnessTime: BOOL, + dwRevocationFreshnessTime: DWORD, +}} +pub type PCERT_SIMPLE_CHAIN = *mut CERT_SIMPLE_CHAIN; +pub type PCCERT_SIMPLE_CHAIN = *const CERT_SIMPLE_CHAIN; +pub type PCERT_CHAIN_CONTEXT = *mut CERT_CHAIN_CONTEXT; +pub type PCCERT_CHAIN_CONTEXT = *const CERT_CHAIN_CONTEXT; +STRUCT!{struct CERT_CHAIN_CONTEXT { + cbSize: DWORD, + TrustStatus: CERT_TRUST_STATUS, + cChain: DWORD, + rgpChain: *mut PCERT_SIMPLE_CHAIN, + cLowerQualityChainContext: DWORD, + rgpLowerQualityChainContext: *mut PCCERT_CHAIN_CONTEXT, + fHasRevocationFreshnessTime: BOOL, + dwRevocationFreshnessTime: DWORD, + dwCreateFlags: DWORD, + ChainId: GUID, +}} +pub const USAGE_MATCH_TYPE_AND: DWORD = 0x00000000; +pub const USAGE_MATCH_TYPE_OR: DWORD = 0x00000001; +STRUCT!{struct CERT_USAGE_MATCH { + dwType: DWORD, + Usage: CERT_ENHKEY_USAGE, +}} +pub type PCERT_USAGE_MATCH = *mut CERT_USAGE_MATCH; +STRUCT!{struct CTL_USAGE_MATCH { + dwType: DWORD, + Usage: CTL_USAGE, +}} +pub type PCTL_USAGE_MATCH = *mut CTL_USAGE_MATCH; +STRUCT!{struct CERT_CHAIN_PARA { + cbSize: DWORD, + RequestedUsage: CERT_USAGE_MATCH, + RequestedIssuancePolicy: CERT_USAGE_MATCH, + dwUrlRetrievalTimeout: DWORD, + fCheckRevocationFreshnessTime: BOOL, + dwRevocationFreshnessTime: DWORD, + pftCacheResync: LPFILETIME, + pStrongSignPara: PCCERT_STRONG_SIGN_PARA, + dwStrongSignFlags: DWORD, +}} +pub type PCERT_CHAIN_PARA = *mut CERT_CHAIN_PARA; +pub const CERT_CHAIN_STRONG_SIGN_DISABLE_END_CHECK_FLAG: DWORD = 0x00000001; +pub const CERT_CHAIN_REVOCATION_CHECK_END_CERT: DWORD = 0x10000000; +pub const CERT_CHAIN_REVOCATION_CHECK_CHAIN: DWORD = 0x20000000; +pub const CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT: DWORD = 0x40000000; +pub const CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY: DWORD = 0x80000000; +pub const CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT: DWORD = 0x08000000; +pub const CERT_CHAIN_REVOCATION_CHECK_OCSP_CERT: DWORD = 0x04000000; +pub const CERT_CHAIN_DISABLE_PASS1_QUALITY_FILTERING: DWORD = 0x00000040; +pub const CERT_CHAIN_RETURN_LOWER_QUALITY_CONTEXTS: DWORD = 0x00000080; +pub const CERT_CHAIN_DISABLE_AUTH_ROOT_AUTO_UPDATE: DWORD = 0x00000100; +pub const CERT_CHAIN_TIMESTAMP_TIME: DWORD = 0x00000200; +pub const CERT_CHAIN_ENABLE_PEER_TRUST: DWORD = 0x00000400; +pub const CERT_CHAIN_DISABLE_MY_PEER_TRUST: DWORD = 0x00000800; +pub const CERT_CHAIN_DISABLE_MD2_MD4: DWORD = 0x00001000; +pub const CERT_CHAIN_DISABLE_AIA: DWORD = 0x00002000; +pub const CERT_CHAIN_HAS_MOTW: DWORD = 0x00004000; +pub const CERT_CHAIN_ONLY_ADDITIONAL_AND_AUTH_ROOT: DWORD = 0x00008000; +pub const CERT_CHAIN_OPT_IN_WEAK_SIGNATURE: DWORD = 0x00010000; +extern "system" { + pub fn CertGetCertificateChain( + hChainEngine: HCERTCHAINENGINE, + pCertContext: PCCERT_CONTEXT, + pTime: LPFILETIME, + hAdditionalStore: HCERTSTORE, + pChainPara: PCERT_CHAIN_PARA, + dwFlags: DWORD, + pvReserved: LPVOID, + ppChainContext: *mut PCCERT_CHAIN_CONTEXT, + ) -> BOOL; + pub fn CertFreeCertificateChain( + pChainContext: PCCERT_CHAIN_CONTEXT, + ); + pub fn CertDuplicateCertificateChain( + pChainContext: PCCERT_CHAIN_CONTEXT, + ) -> PCCERT_CHAIN_CONTEXT; +} +STRUCT!{struct CERT_REVOCATION_CHAIN_PARA { + cbSize: DWORD, + hChainEngine: HCERTCHAINENGINE, + hAdditionalStore: HCERTSTORE, + dwChainFlags: DWORD, + dwUrlRetrievalTimeout: DWORD, + pftCurrentTime: LPFILETIME, + pftCacheResync: LPFILETIME, + cbMaxUrlRetrievalByteCount: DWORD, +}} +pub const REVOCATION_OID_CRL_REVOCATION: LPCSTR = 1 as LPCSTR; +STRUCT!{struct CRL_REVOCATION_INFO { + pCrlEntry: PCRL_ENTRY, + pCrlContext: PCCRL_CONTEXT, + pCrlIssuerChain: PCCERT_CHAIN_CONTEXT, +}} +pub type PCRL_REVOCATION_INFO = *mut CRL_REVOCATION_INFO; +extern "system" { + pub fn CertFindChainInStore( + hCertStore: HCERTSTORE, + dwCertEncodingType: DWORD, + dwFindFlags: DWORD, + dwFindType: DWORD, + pvFindPara: *const c_void, + pPrevChainContext: PCCERT_CHAIN_CONTEXT, + ) -> PCCERT_CHAIN_CONTEXT; +} +pub const CERT_CHAIN_FIND_BY_ISSUER: DWORD = 1; +FN!{stdcall PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK( + pCert: PCCERT_CONTEXT, + pvFindArg: *mut c_void, +) -> BOOL} +STRUCT!{struct CERT_CHAIN_FIND_ISSUER_PARA { + cbSize: DWORD, + pszUsageIdentifier: LPCSTR, + dwKeySpec: DWORD, + dwAcquirePrivateKeyFlags: DWORD, + cIssuer: DWORD, + rgIssuer: *mut CERT_NAME_BLOB, + pfnFindCallback: PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK, + pvFindArg: *mut c_void, + pdwIssuerChainIndex: *mut DWORD, + pdwIssuerElementIndex: *mut DWORD, +}} +pub type PCERT_CHAIN_FIND_ISSUER_PARA = *mut CERT_CHAIN_FIND_ISSUER_PARA; +pub type CERT_CHAIN_FIND_BY_ISSUER_PARA = CERT_CHAIN_FIND_ISSUER_PARA; +pub type PCERT_CHAIN_FIND_BY_ISSUER_PARA = *mut CERT_CHAIN_FIND_ISSUER_PARA; +pub const CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG: DWORD = 0x0001; +pub const CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG: DWORD = 0x0002; +pub const CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG: DWORD = 0x0004; +pub const CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG: DWORD = 0x0008; +pub const CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG: DWORD = 0x4000; +pub const CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG: DWORD = 0x8000; +STRUCT!{struct CERT_CHAIN_POLICY_PARA { + cbSize: DWORD, + dwFlags: DWORD, + pvExtraPolicyPara: *mut c_void, +}} +pub type PCERT_CHAIN_POLICY_PARA = *mut CERT_CHAIN_POLICY_PARA; +STRUCT!{struct CERT_CHAIN_POLICY_STATUS { + cbSize: DWORD, + dwError: DWORD, + lChainIndex: LONG, + lElementIndex: LONG, + pvExtraPolicyStatus: *mut c_void, +}} +pub type PCERT_CHAIN_POLICY_STATUS = *mut CERT_CHAIN_POLICY_STATUS; +pub const CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG: DWORD = 0x00000001; +pub const CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG: DWORD = 0x00000002; +pub const CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG: DWORD = 0x00000004; +pub const CERT_CHAIN_POLICY_IGNORE_INVALID_BASIC_CONSTRAINTS_FLAG: DWORD = 0x00000008; +pub const CERT_CHAIN_POLICY_IGNORE_ALL_NOT_TIME_VALID_FLAGS: DWORD + = CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG + | CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG + | CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG; +pub const CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG: DWORD = 0x00000010; +pub const CERT_CHAIN_POLICY_IGNORE_WRONG_USAGE_FLAG: DWORD = 0x00000020; +pub const CERT_CHAIN_POLICY_IGNORE_INVALID_NAME_FLAG: DWORD = 0x00000040; +pub const CERT_CHAIN_POLICY_IGNORE_INVALID_POLICY_FLAG: DWORD = 0x00000080; +pub const CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG: DWORD = 0x00000100; +pub const CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG: DWORD = 0x00000200; +pub const CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG: DWORD = 0x00000400; +pub const CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG: DWORD = 0x00000800; +pub const CERT_CHAIN_POLICY_IGNORE_ALL_REV_UNKNOWN_FLAGS: DWORD + = CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG + | CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG + | CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG + | CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG; +pub const CERT_CHAIN_POLICY_ALLOW_TESTROOT_FLAG: DWORD = 0x00008000; +pub const CERT_CHAIN_POLICY_TRUST_TESTROOT_FLAG: DWORD = 0x00004000; +pub const CERT_CHAIN_POLICY_IGNORE_NOT_SUPPORTED_CRITICAL_EXT_FLAG: DWORD = 0x00002000; +pub const CERT_CHAIN_POLICY_IGNORE_PEER_TRUST_FLAG: DWORD = 0x00001000; +pub const CERT_CHAIN_POLICY_IGNORE_WEAK_SIGNATURE_FLAG: DWORD = 0x08000000; +extern "system" { + pub fn CertVerifyCertificateChainPolicy( + pszPolicyOID: LPCSTR, + pChainContext: PCCERT_CHAIN_CONTEXT, + pPolicyPara: PCERT_CHAIN_POLICY_PARA, + pPolicyStatus: PCERT_CHAIN_POLICY_STATUS, + ) -> BOOL; +} +pub const CRYPT_OID_VERIFY_CERTIFICATE_CHAIN_POLICY_FUNC: &'static str + = "CertDllVerifyCertificateChainPolicy"; +pub const CERT_CHAIN_POLICY_BASE: LPCSTR = 1 as LPCSTR; +pub const CERT_CHAIN_POLICY_AUTHENTICODE: LPCSTR = 2 as LPCSTR; +pub const CERT_CHAIN_POLICY_AUTHENTICODE_TS: LPCSTR = 3 as LPCSTR; +pub const CERT_CHAIN_POLICY_SSL: LPCSTR = 4 as LPCSTR; +pub const CERT_CHAIN_POLICY_BASIC_CONSTRAINTS: LPCSTR = 5 as LPCSTR; +pub const CERT_CHAIN_POLICY_NT_AUTH: LPCSTR = 6 as LPCSTR; +pub const CERT_CHAIN_POLICY_MICROSOFT_ROOT: LPCSTR = 7 as LPCSTR; +pub const CERT_CHAIN_POLICY_EV: LPCSTR = 8 as LPCSTR; +pub const CERT_CHAIN_POLICY_SSL_F12: LPCSTR = 9 as LPCSTR; +pub const CERT_CHAIN_POLICY_SSL_HPKP_HEADER: LPCSTR = 10 as LPCSTR; +pub const CERT_CHAIN_POLICY_THIRD_PARTY_ROOT: LPCSTR = 11 as LPCSTR; +pub const CERT_CHAIN_POLICY_SSL_KEY_PIN: LPCSTR = 12 as LPCSTR; +STRUCT!{struct AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA { + cbSize: DWORD, + dwRegPolicySettings: DWORD, + pSignerInfo: PCMSG_SIGNER_INFO, +}} +pub type PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA + = *mut AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA; +STRUCT!{struct AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS { + cbSize: DWORD, + fCommercial: BOOL, +}} +pub type PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS + = *mut AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS; +STRUCT!{struct AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA { + cbSize: DWORD, + dwRegPolicySettings: DWORD, + fCommercial: BOOL, +}} +pub type PAUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA + = *mut AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA; +UNION!{union HTTPSPolicyCallbackData_u { + [u32; 1], + cbStruct cbStruct_mut: DWORD, + cbSize cbSize_mut: DWORD, +}} +STRUCT!{struct HTTPSPolicyCallbackData { + u: HTTPSPolicyCallbackData_u, + dwAuthType: DWORD, + fdwChecks: DWORD, + pwszServerName: *mut WCHAR, +}} +pub type PHTTPSPolicyCallbackData = *mut HTTPSPolicyCallbackData; +pub type SSL_EXTRA_CERT_CHAIN_POLICY_PARA = HTTPSPolicyCallbackData; +pub type PSSL_EXTRA_CERT_CHAIN_POLICY_PARA = *mut HTTPSPolicyCallbackData; +pub const AUTHTYPE_CLIENT: DWORD = 1; +pub const AUTHTYPE_SERVER: DWORD = 2; +pub const BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_CA_FLAG: DWORD = 0x80000000; +pub const BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_END_ENTITY_FLAG: DWORD = 0x40000000; +pub const MICROSOFT_ROOT_CERT_CHAIN_POLICY_ENABLE_TEST_ROOT_FLAG: DWORD = 0x00010000; +pub const MICROSOFT_ROOT_CERT_CHAIN_POLICY_CHECK_APPLICATION_ROOT_FLAG: DWORD = 0x00020000; +pub const MICROSOFT_ROOT_CERT_CHAIN_POLICY_DISABLE_FLIGHT_ROOT_FLAG: DWORD = 0x00040000; +STRUCT!{struct EV_EXTRA_CERT_CHAIN_POLICY_PARA { + cbSize: DWORD, + dwRootProgramQualifierFlags: DWORD, +}} +pub type PEV_EXTRA_CERT_CHAIN_POLICY_PARA = *mut EV_EXTRA_CERT_CHAIN_POLICY_PARA; +STRUCT!{struct EV_EXTRA_CERT_CHAIN_POLICY_STATUS { + cbSize: DWORD, + dwQualifiers: DWORD, + dwIssuanceUsageIndex: DWORD, +}} +pub type PEV_EXTRA_CERT_CHAIN_POLICY_STATUS = *mut EV_EXTRA_CERT_CHAIN_POLICY_STATUS; +pub const SSL_F12_ERROR_TEXT_LENGTH: usize = 256; +STRUCT!{struct SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS { + cbSize: DWORD, + dwErrorLevel: DWORD, + dwErrorCategory: DWORD, + dwReserved: DWORD, + wszErrorText: [WCHAR; SSL_F12_ERROR_TEXT_LENGTH], +}} +pub type PSSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS = *mut SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS; +pub const CERT_CHAIN_POLICY_SSL_F12_SUCCESS_LEVEL: DWORD = 0; +pub const CERT_CHAIN_POLICY_SSL_F12_WARNING_LEVEL: DWORD = 1; +pub const CERT_CHAIN_POLICY_SSL_F12_ERROR_LEVEL: DWORD = 2; +pub const CERT_CHAIN_POLICY_SSL_F12_NONE_CATEGORY: DWORD = 0; +pub const CERT_CHAIN_POLICY_SSL_F12_WEAK_CRYPTO_CATEGORY: DWORD = 1; +pub const CERT_CHAIN_POLICY_SSL_F12_ROOT_PROGRAM_CATEGORY: DWORD = 2; +pub const SSL_HPKP_PKP_HEADER_INDEX: usize = 0; +pub const SSL_HPKP_PKP_RO_HEADER_INDEX: usize = 1; +pub const SSL_HPKP_HEADER_COUNT: usize = 2; +STRUCT!{struct SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA { + cbSize: DWORD, + dwReserved: DWORD, + pwszServerName: LPWSTR, + rgpszHpkpValue: [LPSTR; SSL_HPKP_HEADER_COUNT], +}} +pub type PSSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA + = *mut SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA; +STRUCT!{struct SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA { + cbSize: DWORD, + dwReserved: DWORD, + pwszServerName: PCWSTR, +}} +pub type PSSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA = *mut SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA; +pub const SSL_KEY_PIN_ERROR_TEXT_LENGTH: usize = 512; +STRUCT!{struct SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS { + cbSize: DWORD, + lError: LONG, + wszErrorText: [WCHAR; SSL_KEY_PIN_ERROR_TEXT_LENGTH], +}} +pub type PSSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS + = *mut SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS; +pub const CERT_CHAIN_POLICY_SSL_KEY_PIN_MISMATCH_ERROR: LONG = -2; +pub const CERT_CHAIN_POLICY_SSL_KEY_PIN_MITM_ERROR: LONG = -1; +pub const CERT_CHAIN_POLICY_SSL_KEY_PIN_SUCCESS: LONG = 0; +pub const CERT_CHAIN_POLICY_SSL_KEY_PIN_MITM_WARNING: LONG = 1; +pub const CERT_CHAIN_POLICY_SSL_KEY_PIN_MISMATCH_WARNING: LONG = 2; +extern "system" { + pub fn CryptStringToBinaryA( + pszString: LPCSTR, + cchString: DWORD, + dwFlags: DWORD, + pbBinary: *mut BYTE, + pcbBinary: *mut DWORD, + pdwSkip: *mut DWORD, + pdwFlags: *mut DWORD, + ) -> BOOL; + pub fn CryptStringToBinaryW( + pszString: LPCWSTR, + cchString: DWORD, + dwFlags: DWORD, + pbBinary: *mut BYTE, + pcbBinary: *mut DWORD, + pdwSkip: *mut DWORD, + pdwFlags: *mut DWORD, + ) -> BOOL; + pub fn CryptBinaryToStringA( + pbBinary: *const BYTE, + cbBinary: DWORD, + dwFlags: DWORD, + pszString: LPSTR, + pcchString: *mut DWORD, + ) -> BOOL; + pub fn CryptBinaryToStringW( + pbBinary: *const BYTE, + cbBinary: DWORD, + dwFlags: DWORD, + pszString: LPWSTR, + pcchString: *mut DWORD, + ) -> BOOL; +} +pub const CRYPT_STRING_BASE64HEADER: DWORD = 0x00000000; +pub const CRYPT_STRING_BASE64: DWORD = 0x00000001; +pub const CRYPT_STRING_BINARY: DWORD = 0x00000002; +pub const CRYPT_STRING_BASE64REQUESTHEADER: DWORD = 0x00000003; +pub const CRYPT_STRING_HEX: DWORD = 0x00000004; +pub const CRYPT_STRING_HEXASCII: DWORD = 0x00000005; +pub const CRYPT_STRING_BASE64_ANY: DWORD = 0x00000006; +pub const CRYPT_STRING_ANY: DWORD = 0x00000007; +pub const CRYPT_STRING_HEX_ANY: DWORD = 0x00000008; +pub const CRYPT_STRING_BASE64X509CRLHEADER: DWORD = 0x00000009; +pub const CRYPT_STRING_HEXADDR: DWORD = 0x0000000a; +pub const CRYPT_STRING_HEXASCIIADDR: DWORD = 0x0000000b; +pub const CRYPT_STRING_HEXRAW: DWORD = 0x0000000c; +pub const CRYPT_STRING_BASE64URI: DWORD = 0x0000000d; +pub const CRYPT_STRING_ENCODEMASK: DWORD = 0x000000ff; +pub const CRYPT_STRING_RESERVED100: DWORD = 0x00000100; +pub const CRYPT_STRING_RESERVED200: DWORD = 0x00000200; +pub const CRYPT_STRING_PERCENTESCAPE: DWORD = 0x08000000; +pub const CRYPT_STRING_HASHDATA: DWORD = 0x10000000; +pub const CRYPT_STRING_STRICT: DWORD = 0x20000000; +pub const CRYPT_STRING_NOCRLF: DWORD = 0x40000000; +pub const CRYPT_STRING_NOCR: DWORD = 0x80000000; +pub const szOID_PKCS_12_PbeIds: &'static str = "1.2.840.113549.1.12.1"; +pub const szOID_PKCS_12_pbeWithSHA1And128BitRC4: &'static str = "1.2.840.113549.1.12.1.1"; +pub const szOID_PKCS_12_pbeWithSHA1And40BitRC4: &'static str = "1.2.840.113549.1.12.1.2"; +pub const szOID_PKCS_12_pbeWithSHA1And3KeyTripleDES: &'static str = "1.2.840.113549.1.12.1.3"; +pub const szOID_PKCS_12_pbeWithSHA1And2KeyTripleDES: &'static str = "1.2.840.113549.1.12.1.4"; +pub const szOID_PKCS_12_pbeWithSHA1And128BitRC2: &'static str = "1.2.840.113549.1.12.1.5"; +pub const szOID_PKCS_12_pbeWithSHA1And40BitRC2: &'static str = "1.2.840.113549.1.12.1.6"; +STRUCT!{struct CRYPT_PKCS12_PBE_PARAMS { + iIterations: c_int, + cbSalt: ULONG, +}} +extern "system" { + pub fn PFXImportCertStore( + pPFX: *mut CRYPT_DATA_BLOB, + szPassword: LPCWSTR, + dwFlags: DWORD, + ) -> HCERTSTORE; +} +pub const PKCS12_IMPORT_SILENT: DWORD = 0x00000040; +pub const CRYPT_USER_KEYSET: DWORD = 0x00001000; +pub const PKCS12_PREFER_CNG_KSP: DWORD = 0x00000100; +pub const PKCS12_ALWAYS_CNG_KSP: DWORD = 0x00000200; +pub const PKCS12_ONLY_CERTIFICATES: DWORD = 0x00000400; +pub const PKCS12_ONLY_NOT_ENCRYPTED_CERTIFICATES: DWORD = 0x00000800; +pub const PKCS12_ALLOW_OVERWRITE_KEY: DWORD = 0x00004000; +pub const PKCS12_NO_PERSIST_KEY: DWORD = 0x00008000; +pub const PKCS12_IMPORT_RESERVED_MASK: DWORD = 0xffff0000; +pub const PKCS12_OBJECT_LOCATOR_ALL_IMPORT_FLAGS: DWORD = PKCS12_ALWAYS_CNG_KSP + | PKCS12_NO_PERSIST_KEY | PKCS12_IMPORT_SILENT | PKCS12_INCLUDE_EXTENDED_PROPERTIES; +pub const PKCS12_ONLY_CERTIFICATES_PROVIDER_TYPE: DWORD = 0; +pub const PKCS12_ONLY_CERTIFICATES_PROVIDER_NAME: &'static str = "PfxProvider"; +pub const PKCS12_ONLY_CERTIFICATES_CONTAINER_NAME: &'static str = "PfxContainer"; +extern "system" { + pub fn PFXIsPFXBlob( + pPFX: *mut CRYPT_DATA_BLOB, + ) -> BOOL; + pub fn PFXVerifyPassword( + pPFX: *mut CRYPT_DATA_BLOB, + szPassword: LPCWSTR, + dwFlags: DWORD, + ) -> BOOL; + pub fn PFXExportCertStoreEx( + hStore: HCERTSTORE, + pPFX: *mut CRYPT_DATA_BLOB, + szPassword: LPCWSTR, + pvPara: *mut c_void, + dwFlags: DWORD, + ) -> BOOL; +} +pub const REPORT_NO_PRIVATE_KEY: DWORD = 0x0001; +pub const REPORT_NOT_ABLE_TO_EXPORT_PRIVATE_KEY: DWORD = 0x0002; +pub const EXPORT_PRIVATE_KEYS: DWORD = 0x0004; +pub const PKCS12_INCLUDE_EXTENDED_PROPERTIES: DWORD = 0x0010; +pub const PKCS12_PROTECT_TO_DOMAIN_SIDS: DWORD = 0x0020; +pub const PKCS12_EXPORT_SILENT: DWORD = 0x0040; +pub const PKCS12_DISABLE_ENCRYPT_CERTIFICATES: DWORD = 0x0100; +pub const PKCS12_ENCRYPT_CERTIFICATES: DWORD = 0x0200; +pub const PKCS12_EXPORT_ECC_CURVE_PARAMETERS: DWORD = 0x1000; +pub const PKCS12_EXPORT_ECC_CURVE_OID: DWORD = 0x2000; +pub const PKCS12_EXPORT_RESERVED_MASK: DWORD = 0xffff0000; +pub const PKCS12_CONFIG_REGPATH: &'static str + = "Software\\Microsoft\\Windows\\CurrentVersion\\PFX"; +pub const PKCS12_ENCRYPT_CERTIFICATES_VALUE_NAME: &'static str = "EncryptCertificates"; +extern "system" { + pub fn PFXExportCertStore( + hStore: HCERTSTORE, + pPFX: *mut CRYPT_DATA_BLOB, + szPassword: LPCWSTR, + dwFlags: DWORD, + ) -> BOOL; +} +pub type HCERT_SERVER_OCSP_RESPONSE = *mut c_void; +pub type PCERT_SERVER_OCSP_RESPONSE_CONTEXT = *mut CERT_SERVER_OCSP_RESPONSE_CONTEXT; +pub type PCCERT_SERVER_OCSP_RESPONSE_CONTEXT = *const CERT_SERVER_OCSP_RESPONSE_CONTEXT; +STRUCT!{struct CERT_SERVER_OCSP_RESPONSE_CONTEXT { + cbSize: DWORD, + pbEncodedOcspResponse: *mut BYTE, + cbEncodedOcspResponse: DWORD, +}} +FN!{stdcall PFN_CERT_SERVER_OCSP_RESPONSE_UPDATE_CALLBACK( + pChainContext: PCCERT_CHAIN_CONTEXT, + pServerOcspResponseContext: PCCERT_SERVER_OCSP_RESPONSE_CONTEXT, + pNewCrlContext: PCCRL_CONTEXT, + pPrevCrlContext: PCCRL_CONTEXT, + pvArg: PVOID, + dwWriteOcspFileError: DWORD, +) -> ()} +STRUCT!{struct CERT_SERVER_OCSP_RESPONSE_OPEN_PARA { + cbSize: DWORD, + dwFlags: DWORD, + pcbUsedSize: *mut DWORD, + pwszOcspDirectory: PWSTR, + pfnUpdateCallback: PFN_CERT_SERVER_OCSP_RESPONSE_UPDATE_CALLBACK, + pvUpdateCallbackArg: PVOID, +}} +pub type PCERT_SERVER_OCSP_RESPONSE_OPEN_PARA = *mut CERT_SERVER_OCSP_RESPONSE_OPEN_PARA; +pub const CERT_SERVER_OCSP_RESPONSE_OPEN_PARA_READ_FLAG: DWORD = 0x00000001; +pub const CERT_SERVER_OCSP_RESPONSE_OPEN_PARA_WRITE_FLAG: DWORD = 0x00000002; +extern "system" { + pub fn CertOpenServerOcspResponse( + pChainContext: PCCERT_CHAIN_CONTEXT, + dwFlags: DWORD, + pvReserved: LPVOID, + ) -> HCERT_SERVER_OCSP_RESPONSE; +} +pub const CERT_SERVER_OCSP_RESPONSE_ASYNC_FLAG: DWORD = 0x00000001; +extern "system" { + pub fn CertAddRefServerOcspResponse( + hServerOcspResponse: HCERT_SERVER_OCSP_RESPONSE, + ); + pub fn CertCloseServerOcspResponse( + hServerOcspResponse: HCERT_SERVER_OCSP_RESPONSE, + dwFlags: DWORD, + ); + pub fn CertGetServerOcspResponseContext( + hServerOcspResponse: HCERT_SERVER_OCSP_RESPONSE, + dwFlags: DWORD, + pvReserved: LPVOID, + ) -> PCCERT_SERVER_OCSP_RESPONSE_CONTEXT; + pub fn CertAddRefServerOcspResponseContext( + pServerOcspResponseContext: PCCERT_SERVER_OCSP_RESPONSE_CONTEXT, + ); + pub fn CertFreeServerOcspResponseContext( + pServerOcspResponseContext: PCCERT_SERVER_OCSP_RESPONSE_CONTEXT, + ); + pub fn CertRetrieveLogoOrBiometricInfo( + pCertContext: PCCERT_CONTEXT, + lpszLogoOrBiometricType: LPCSTR, + dwRetrievalFlags: DWORD, + dwTimeout: DWORD, + dwFlags: DWORD, + pvReserved: *mut c_void, + ppbData: *mut *mut BYTE, + pcbData: *mut DWORD, + ppwszMimeType: *mut LPWSTR, + ) -> BOOL; +} +pub const CERT_RETRIEVE_ISSUER_LOGO: LPCSTR = 1 as LPCSTR; +pub const CERT_RETRIEVE_SUBJECT_LOGO: LPCSTR = 2 as LPCSTR; +pub const CERT_RETRIEVE_COMMUNITY_LOGO: LPCSTR = 3 as LPCSTR; +pub const CERT_RETRIEVE_BIOMETRIC_PREDEFINED_BASE_TYPE: LPCSTR = 1000 as LPCSTR; +pub const CERT_RETRIEVE_BIOMETRIC_PICTURE_TYPE: LPCSTR + = (1000 + CERT_BIOMETRIC_PICTURE_TYPE) as LPCSTR; +pub const CERT_RETRIEVE_BIOMETRIC_SIGNATURE_TYPE: LPCSTR + = (1000 + CERT_BIOMETRIC_SIGNATURE_TYPE) as LPCSTR; +STRUCT!{struct CERT_SELECT_CHAIN_PARA { + hChainEngine: HCERTCHAINENGINE, + pTime: PFILETIME, + hAdditionalStore: HCERTSTORE, + pChainPara: PCERT_CHAIN_PARA, + dwFlags: DWORD, +}} +pub type PCERT_SELECT_CHAIN_PARA = *mut CERT_SELECT_CHAIN_PARA; +pub type PCCERT_SELECT_CHAIN_PARA = *const CERT_SELECT_CHAIN_PARA; +pub const CERT_SELECT_MAX_PARA: DWORD = 500; +STRUCT!{struct CERT_SELECT_CRITERIA { + dwType: DWORD, + cPara: DWORD, + ppPara: *mut *mut c_void, +}} +pub type PCERT_SELECT_CRITERIA = *mut CERT_SELECT_CRITERIA; +pub type PCCERT_SELECT_CRITERIA = *const CERT_SELECT_CRITERIA; +pub const CERT_SELECT_BY_ENHKEY_USAGE: DWORD = 1; +pub const CERT_SELECT_BY_KEY_USAGE: DWORD = 2; +pub const CERT_SELECT_BY_POLICY_OID: DWORD = 3; +pub const CERT_SELECT_BY_PROV_NAME: DWORD = 4; +pub const CERT_SELECT_BY_EXTENSION: DWORD = 5; +pub const CERT_SELECT_BY_SUBJECT_HOST_NAME: DWORD = 6; +pub const CERT_SELECT_BY_ISSUER_ATTR: DWORD = 7; +pub const CERT_SELECT_BY_SUBJECT_ATTR: DWORD = 8; +pub const CERT_SELECT_BY_ISSUER_NAME: DWORD = 9; +pub const CERT_SELECT_BY_PUBLIC_KEY: DWORD = 10; +pub const CERT_SELECT_BY_TLS_SIGNATURES: DWORD = 11; +pub const CERT_SELECT_BY_ISSUER_DISPLAYNAME: DWORD = 12; +pub const CERT_SELECT_BY_FRIENDLYNAME: DWORD = 13; +pub const CERT_SELECT_BY_THUMBPRINT: DWORD = 14; +pub const CERT_SELECT_LAST: DWORD = CERT_SELECT_BY_TLS_SIGNATURES; +pub const CERT_SELECT_MAX: DWORD = CERT_SELECT_LAST * 3; +pub const CERT_SELECT_ALLOW_EXPIRED: DWORD = 0x00000001; +pub const CERT_SELECT_TRUSTED_ROOT: DWORD = 0x00000002; +pub const CERT_SELECT_DISALLOW_SELFSIGNED: DWORD = 0x00000004; +pub const CERT_SELECT_HAS_PRIVATE_KEY: DWORD = 0x00000008; +pub const CERT_SELECT_HAS_KEY_FOR_SIGNATURE: DWORD = 0x00000010; +pub const CERT_SELECT_HAS_KEY_FOR_KEY_EXCHANGE: DWORD = 0x00000020; +pub const CERT_SELECT_HARDWARE_ONLY: DWORD = 0x00000040; +pub const CERT_SELECT_ALLOW_DUPLICATES: DWORD = 0x00000080; +pub const CERT_SELECT_IGNORE_AUTOSELECT: DWORD = 0x00000100; +extern "system" { + pub fn CertSelectCertificateChains( + pSelectionContext: LPCGUID, + dwFlags: DWORD, + pChainParameters: PCCERT_SELECT_CHAIN_PARA, + cCriteria: DWORD, + rgpCriteria: PCCERT_SELECT_CRITERIA, + hStore: HCERTSTORE, + pcSelection: PDWORD, + pprgpSelection: *mut *mut PCCERT_CHAIN_CONTEXT, + ) -> BOOL; + pub fn CertFreeCertificateChainList( + prgpSelection: *mut PCCERT_CHAIN_CONTEXT, + ); +} +pub const TIMESTAMP_VERSION: DWORD = 1; +STRUCT!{struct CRYPT_TIMESTAMP_REQUEST { + dwVersion: DWORD, + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + HashedMessage: CRYPT_DER_BLOB, + pszTSAPolicyId: LPSTR, + Nonce: CRYPT_INTEGER_BLOB, + fCertReq: BOOL, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type PCRYPT_TIMESTAMP_REQUEST = *mut CRYPT_TIMESTAMP_REQUEST; +STRUCT!{struct CRYPT_TIMESTAMP_RESPONSE { + dwStatus: DWORD, + cFreeText: DWORD, + rgFreeText: *mut LPWSTR, + FailureInfo: CRYPT_BIT_BLOB, + ContentInfo: CRYPT_DER_BLOB, +}} +pub type PCRYPT_TIMESTAMP_RESPONSE = *mut CRYPT_TIMESTAMP_RESPONSE; +pub const TIMESTAMP_STATUS_GRANTED: DWORD = 0; +pub const TIMESTAMP_STATUS_GRANTED_WITH_MODS: DWORD = 1; +pub const TIMESTAMP_STATUS_REJECTED: DWORD = 2; +pub const TIMESTAMP_STATUS_WAITING: DWORD = 3; +pub const TIMESTAMP_STATUS_REVOCATION_WARNING: DWORD = 4; +pub const TIMESTAMP_STATUS_REVOKED: DWORD = 5; +pub const TIMESTAMP_FAILURE_BAD_ALG: DWORD = 0; +pub const TIMESTAMP_FAILURE_BAD_REQUEST: DWORD = 2; +pub const TIMESTAMP_FAILURE_BAD_FORMAT: DWORD = 5; +pub const TIMESTAMP_FAILURE_TIME_NOT_AVAILABLE: DWORD = 14; +pub const TIMESTAMP_FAILURE_POLICY_NOT_SUPPORTED: DWORD = 15; +pub const TIMESTAMP_FAILURE_EXTENSION_NOT_SUPPORTED: DWORD = 16; +pub const TIMESTAMP_FAILURE_INFO_NOT_AVAILABLE: DWORD = 17; +pub const TIMESTAMP_FAILURE_SYSTEM_FAILURE: DWORD = 25; +STRUCT!{struct CRYPT_TIMESTAMP_ACCURACY { + dwSeconds: DWORD, + dwMillis: DWORD, + dwMicros: DWORD, +}} +pub type PCRYPT_TIMESTAMP_ACCURACY = *mut CRYPT_TIMESTAMP_ACCURACY; +STRUCT!{struct CRYPT_TIMESTAMP_INFO { + dwVersion: DWORD, + pszTSAPolicyId: LPSTR, + HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, + HashedMessage: CRYPT_DER_BLOB, + SerialNumber: CRYPT_INTEGER_BLOB, + ftTime: FILETIME, + pvAccuracy: PCRYPT_TIMESTAMP_ACCURACY, + fOrdering: BOOL, + Nonce: CRYPT_DER_BLOB, + Tsa: CRYPT_DER_BLOB, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type PCRYPT_TIMESTAMP_INFO = *mut CRYPT_TIMESTAMP_INFO; +STRUCT!{struct CRYPT_TIMESTAMP_CONTEXT { + cbEncoded: DWORD, + pbEncoded: *mut BYTE, + pTimeStamp: PCRYPT_TIMESTAMP_INFO, +}} +pub type PCRYPT_TIMESTAMP_CONTEXT = *mut CRYPT_TIMESTAMP_CONTEXT; +STRUCT!{struct CRYPT_TIMESTAMP_PARA { + pszTSAPolicyId: LPCSTR, + fRequestCerts: BOOL, + Nonce: CRYPT_INTEGER_BLOB, + cExtension: DWORD, + rgExtension: PCERT_EXTENSION, +}} +pub type PCRYPT_TIMESTAMP_PARA = *mut CRYPT_TIMESTAMP_PARA; +extern "system" { + pub fn CryptRetrieveTimeStamp( + wszUrl: LPCWSTR, + dwRetrievalFlags: DWORD, + dwTimeout: DWORD, + pszHashId: LPCSTR, + pPara: *const CRYPT_TIMESTAMP_PARA, + pbData: *const BYTE, + cbData: DWORD, + ppTsContext: *mut PCRYPT_TIMESTAMP_CONTEXT, + ppTsSigner: *mut PCCERT_CONTEXT, + phStore: *mut HCERTSTORE, + ) -> BOOL; +} +pub const TIMESTAMP_DONT_HASH_DATA: DWORD = 0x00000001; +pub const TIMESTAMP_VERIFY_CONTEXT_SIGNATURE: DWORD = 0x00000020; +pub const TIMESTAMP_NO_AUTH_RETRIEVAL: DWORD = 0x00020000; +extern "system" { + pub fn CryptVerifyTimeStampSignature( + pbTSContentInfo: *const BYTE, + cbTSContentInfo: DWORD, + pbData: *const BYTE, + cbData: DWORD, + hAdditionalStore: HCERTSTORE, + ppTsContext: *mut PCRYPT_TIMESTAMP_CONTEXT, + ppTsSigner: *mut PCCERT_CONTEXT, + phStore: *mut HCERTSTORE, + ) -> BOOL; +} +pub const CRYPT_OBJECT_LOCATOR_SPN_NAME_TYPE: DWORD = 1; +pub const CRYPT_OBJECT_LOCATOR_LAST_RESERVED_NAME_TYPE: DWORD = 32; +pub const CRYPT_OBJECT_LOCATOR_FIRST_RESERVED_USER_NAME_TYPE: DWORD = 33; +pub const CRYPT_OBJECT_LOCATOR_LAST_RESERVED_USER_NAME_TYPE: DWORD = 0x0000FFFF; +pub const SSL_OBJECT_LOCATOR_PFX_FUNC: &'static str = "SslObjectLocatorInitializePfx"; +pub const SSL_OBJECT_LOCATOR_ISSUER_LIST_FUNC: &'static str + = "SslObjectLocatorInitializeIssuerList"; +pub const SSL_OBJECT_LOCATOR_CERT_VALIDATION_CONFIG_FUNC: &'static str + = "SslObjectLocatorInitializeCertValidationConfig"; +pub const CRYPT_OBJECT_LOCATOR_RELEASE_SYSTEM_SHUTDOWN: DWORD = 1; +pub const CRYPT_OBJECT_LOCATOR_RELEASE_SERVICE_STOP: DWORD = 2; +pub const CRYPT_OBJECT_LOCATOR_RELEASE_PROCESS_EXIT: DWORD = 3; +pub const CRYPT_OBJECT_LOCATOR_RELEASE_DLL_UNLOAD: DWORD = 4; +FN!{stdcall PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FLUSH( + pContext: LPVOID, + rgIdentifierOrNameList: *mut PCERT_NAME_BLOB, + dwIdentifierOrNameListCount: DWORD, +) -> BOOL} +FN!{stdcall PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_GET( + pPluginContext: LPVOID, + pIdentifier: PCRYPT_DATA_BLOB, + dwNameType: DWORD, + pNameBlob: PCERT_NAME_BLOB, + ppbContent: *mut PBYTE, + pcbContent: *mut DWORD, + ppwszPassword: *mut PCWSTR, + ppIdentifier: *mut PCRYPT_DATA_BLOB, +) -> BOOL} +FN!{stdcall PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_RELEASE( + dwReason: DWORD, + pPluginContext: LPVOID, +) -> ()} +FN!{stdcall PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE_PASSWORD( + pPluginContext: LPVOID, + pwszPassword: PCWSTR, +) -> ()} +FN!{stdcall PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE( + pPluginContext: LPVOID, + pbData: PBYTE, +) -> ()} +FN!{stdcall PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE_IDENTIFIER( + pPluginContext: LPVOID, + pIdentifier: PCRYPT_DATA_BLOB, +) -> ()} +STRUCT!{struct CRYPT_OBJECT_LOCATOR_PROVIDER_TABLE { + cbSize: DWORD, + pfnGet: PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_GET, + pfnRelease: PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_RELEASE, + pfnFreePassword: PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE_PASSWORD, + pfnFree: PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE, + pfnFreeIdentifier: PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE_IDENTIFIER, +}} +pub type PCRYPT_OBJECT_LOCATOR_PROVIDER_TABLE = *mut CRYPT_OBJECT_LOCATOR_PROVIDER_TABLE; +FN!{stdcall PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_INITIALIZE( + pfnFlush: PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FLUSH, + pContext: LPVOID, + pdwExpectedObjectCount: *mut DWORD, + ppFuncTable: *mut PCRYPT_OBJECT_LOCATOR_PROVIDER_TABLE, + ppPluginContext: *mut *mut c_void, +) -> BOOL} +extern "system" { + pub fn CertIsWeakHash( + dwHashUseType: DWORD, + pwszCNGHashAlgid: LPCWSTR, + dwChainFlags: DWORD, + pSignerChainContext: PCCERT_CHAIN_CONTEXT, + pTimeStamp: LPFILETIME, + pwszFileName: LPCWSTR, + ) -> BOOL; +} +FN!{stdcall PFN_CERT_IS_WEAK_HASH( + dwHashUseType: DWORD, + pwszCNGHashAlgid: LPCWSTR, + dwChainFlags: DWORD, + pSignerChainContext: PCCERT_CHAIN_CONTEXT, + pTimeStamp: LPFILETIME, + pwszFileName: LPCWSTR, +) -> BOOL} +pub const CERT_FILE_HASH_USE_TYPE: DWORD = 1; +pub const CERT_TIMESTAMP_HASH_USE_TYPE: DWORD = 2; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/windowsceip.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/windowsceip.rs new file mode 100644 index 0000000..87a59d3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/windowsceip.rs @@ -0,0 +1,9 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::BOOL; +extern "system" { + pub fn CeipIsOptedIn() -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winefs.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winefs.rs new file mode 100644 index 0000000..f476643 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winefs.rs @@ -0,0 +1,178 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::SIZE_T; +use shared::minwindef::{BOOL, DWORD, LPVOID, PBYTE, PDWORD, ULONG}; +use um::minwinbase::SECURITY_ATTRIBUTES; +use um::wincrypt::ALG_ID; +use um::winnt::{LPCWSTR, LPWSTR, SID}; +pub const WINEFS_SETUSERKEY_SET_CAPABILITIES: DWORD = 0x00000001; +STRUCT!{struct EFS_CERTIFICATE_BLOB { + dwCertEncodingType: DWORD, + cbData: DWORD, + pbData: PBYTE, +}} +pub type PEFS_CERTIFICATE_BLOB = *mut EFS_CERTIFICATE_BLOB; +STRUCT!{struct EFS_HASH_BLOB { + cbData: DWORD, + pbData: PBYTE, +}} +pub type PEFS_HASH_BLOB = *mut EFS_HASH_BLOB; +STRUCT!{struct EFS_RPC_BLOB { + cbData: DWORD, + pbData: PBYTE, +}} +pub type PEFS_RPC_BLOB = *mut EFS_RPC_BLOB; +STRUCT!{struct EFS_PIN_BLOB { + cbPadding: DWORD, + cbData: DWORD, + pbData: PBYTE, +}} +pub type PEFS_PIN_BLOB = *mut EFS_PIN_BLOB; +STRUCT!{struct EFS_KEY_INFO { + dwVersion: DWORD, + Entropy: ULONG, + Algorithm: ALG_ID, + KeyLength: ULONG, +}} +pub type PEFS_KEY_INFO = *mut EFS_KEY_INFO; +STRUCT!{struct EFS_COMPATIBILITY_INFO { + EfsVersion: DWORD, +}} +pub type PEFS_COMPATIBILITY_INFO = *mut EFS_COMPATIBILITY_INFO; +pub const EFS_COMPATIBILITY_VERSION_NCRYPT_PROTECTOR: DWORD = 5; +pub const EFS_COMPATIBILITY_VERSION_PFILE_PROTECTOR: DWORD = 6; +#[inline] +pub fn EFS_IS_DESCRIPTOR_VERSION(v: DWORD) -> bool { + v == EFS_COMPATIBILITY_VERSION_NCRYPT_PROTECTOR + || v == EFS_COMPATIBILITY_VERSION_PFILE_PROTECTOR +} +pub const EFS_SUBVER_UNKNOWN: DWORD = 0; +pub const EFS_EFS_SUBVER_EFS_CERT: DWORD = 1; +pub const EFS_PFILE_SUBVER_RMS: DWORD = 2; +pub const EFS_PFILE_SUBVER_APPX: DWORD = 3; +STRUCT!{struct EFS_VERSION_INFO { + EfsVersion: DWORD, + SubVersion: DWORD, +}} +pub type PEFS_VERSION_INFO = *mut EFS_VERSION_INFO; +#[inline] +pub fn EFS_IS_APPX_VERSION(v: DWORD, subV: DWORD) -> bool { + v == EFS_COMPATIBILITY_VERSION_PFILE_PROTECTOR && subV == EFS_PFILE_SUBVER_APPX +} +STRUCT!{struct EFS_DECRYPTION_STATUS_INFO { + dwDecryptionError: DWORD, + dwHashOffset: DWORD, + cbHash: DWORD, +}} +pub type PEFS_DECRYPTION_STATUS_INFO = *mut EFS_DECRYPTION_STATUS_INFO; +STRUCT!{struct EFS_ENCRYPTION_STATUS_INFO { + bHasCurrentKey: BOOL, + dwEncryptionError: DWORD, +}} +pub type PEFS_ENCRYPTION_STATUS_INFO = *mut EFS_ENCRYPTION_STATUS_INFO; +STRUCT!{struct ENCRYPTION_CERTIFICATE { + cbTotalLength: DWORD, + pUserSid: *mut SID, + pCertBlob: PEFS_CERTIFICATE_BLOB, +}} +pub type PENCRYPTION_CERTIFICATE = *mut ENCRYPTION_CERTIFICATE; +pub const MAX_SID_SIZE: SIZE_T = 256; +STRUCT!{struct ENCRYPTION_CERTIFICATE_HASH { + cbTotalLength: DWORD, + pUserSid: *mut SID, + pHash: PEFS_HASH_BLOB, + lpDisplayInformation: LPWSTR, +}} +pub type PENCRYPTION_CERTIFICATE_HASH = *mut ENCRYPTION_CERTIFICATE_HASH; +STRUCT!{struct ENCRYPTION_CERTIFICATE_HASH_LIST { + nCert_Hash: DWORD, + pUsers: *mut PENCRYPTION_CERTIFICATE_HASH, +}} +pub type PENCRYPTION_CERTIFICATE_HASH_LIST = *mut ENCRYPTION_CERTIFICATE_HASH_LIST; +STRUCT!{struct ENCRYPTION_CERTIFICATE_LIST { + nUsers: DWORD, + pUsers: *mut PENCRYPTION_CERTIFICATE, +}} +pub type PENCRYPTION_CERTIFICATE_LIST = *mut ENCRYPTION_CERTIFICATE_LIST; +pub const EFS_METADATA_ADD_USER: DWORD = 0x00000001; +pub const EFS_METADATA_REMOVE_USER: DWORD = 0x00000002; +pub const EFS_METADATA_REPLACE_USER: DWORD = 0x00000004; +pub const EFS_METADATA_GENERAL_OP: DWORD = 0x00000008; +STRUCT!{struct ENCRYPTED_FILE_METADATA_SIGNATURE { + dwEfsAccessType: DWORD, + pCertificatesAdded: PENCRYPTION_CERTIFICATE_HASH_LIST, + pEncryptionCertificate: PENCRYPTION_CERTIFICATE, + pEfsStreamSignature: PEFS_RPC_BLOB, +}} +pub type PENCRYPTED_FILE_METADATA_SIGNATURE = *mut ENCRYPTED_FILE_METADATA_SIGNATURE; +STRUCT!{struct ENCRYPTION_PROTECTOR { + cbTotalLength: DWORD, + pUserSid: *mut SID, + lpProtectorDescriptor: LPWSTR, +}} +pub type PENCRYPTION_PROTECTOR = *mut ENCRYPTION_PROTECTOR; +STRUCT!{struct ENCRYPTION_PROTECTOR_LIST { + nProtectors: DWORD, + pProtectors: *mut PENCRYPTION_PROTECTOR, +}} +pub type PENCRYPTION_PROTECTOR_LIST = *mut ENCRYPTION_PROTECTOR_LIST; +extern "system" { + pub fn QueryUsersOnEncryptedFile( + lpFileName: LPCWSTR, + pUsers: *mut PENCRYPTION_CERTIFICATE_HASH_LIST, + ) -> DWORD; + pub fn QueryRecoveryAgentsOnEncryptedFile( + lpFileName: LPCWSTR, + pRecoveryAgents: *mut PENCRYPTION_CERTIFICATE_HASH_LIST, + ) -> DWORD; + pub fn RemoveUsersFromEncryptedFile( + lpFileName: LPCWSTR, + pHashes: PENCRYPTION_CERTIFICATE_HASH_LIST, + ) -> DWORD; + pub fn AddUsersToEncryptedFile( + lpFileName: LPCWSTR, + pEncryptionCertificate: PENCRYPTION_CERTIFICATE_LIST, + ) -> DWORD; + pub fn SetUserFileEncryptionKey( + pEncryptionCertificate: PENCRYPTION_CERTIFICATE, + ) -> DWORD; + pub fn SetUserFileEncryptionKeyEx( + pEncryptionCertificate: PENCRYPTION_CERTIFICATE, + dwCapabilities: DWORD, + dwFlags: DWORD, + pvReserved: LPVOID, + ) -> DWORD; + pub fn FreeEncryptionCertificateHashList( + pUsers: PENCRYPTION_CERTIFICATE_HASH_LIST, + ); + pub fn EncryptionDisable( + DirPath: LPCWSTR, + Disable: BOOL, + ) -> BOOL; + pub fn DuplicateEncryptionInfoFile( + SrcFileName: LPCWSTR, + DstFileName: LPCWSTR, + dwCreationDistribution: DWORD, + dwAttributes: DWORD, + lpSecurityAttributes: *const SECURITY_ATTRIBUTES, + ) -> DWORD; + pub fn GetEncryptedFileMetadata( + lpFileName: LPCWSTR, + pcbMetadata: PDWORD, + ppbMetadata: *mut PBYTE, + ) -> DWORD; + pub fn SetEncryptedFileMetadata( + lpFileName: LPCWSTR, + pbOldMetadata: PBYTE, + pbNewMetadata: PBYTE, + pOwnerHash: PENCRYPTION_CERTIFICATE_HASH, + dwOperation: DWORD, + pCertificatesAdded: PENCRYPTION_CERTIFICATE_HASH_LIST, + ) -> DWORD; + pub fn FreeEncryptedFileMetadata( + pbMetadata: PBYTE, + ); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winevt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winevt.rs new file mode 100644 index 0000000..dce3d27 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winevt.rs @@ -0,0 +1,543 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Windows Events API +use ctypes::{c_double, c_float}; +use shared::basetsd::{INT16, INT32, INT64, INT8, UINT16, UINT32, UINT64, UINT8}; +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, DWORD, FILETIME, PBYTE, PDWORD}; +use um::minwinbase::SYSTEMTIME; +use um::winnt::{HANDLE, LCID, LONGLONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PSID, PVOID, ULONGLONG}; +use vc::vcruntime::size_t; +pub type EVT_HANDLE = HANDLE; +pub type PEVT_HANDLE = *mut HANDLE; +ENUM!{enum EVT_VARIANT_TYPE { + EvtVarTypeNull = 0, + EvtVarTypeString = 1, + EvtVarTypeAnsiString = 2, + EvtVarTypeSByte = 3, + EvtVarTypeByte = 4, + EvtVarTypeInt16 = 5, + EvtVarTypeUInt16 = 6, + EvtVarTypeInt32 = 7, + EvtVarTypeUInt32 = 8, + EvtVarTypeInt64 = 9, + EvtVarTypeUInt64 = 10, + EvtVarTypeSingle = 11, + EvtVarTypeDouble = 12, + EvtVarTypeBoolean = 13, + EvtVarTypeBinary = 14, + EvtVarTypeGuid = 15, + EvtVarTypeSizeT = 16, + EvtVarTypeFileTime = 17, + EvtVarTypeSysTime = 18, + EvtVarTypeSid = 19, + EvtVarTypeHexInt32 = 20, + EvtVarTypeHexInt64 = 21, + EvtVarTypeEvtHandle = 32, + EvtVarTypeEvtXml = 35, +}} +pub const EVT_VARIANT_TYPE_MASK: DWORD = 0x7f; +pub const EVT_VARIANT_TYPE_ARRAY: DWORD = 128; +UNION!{union EVT_VARIANT_u { + [u64; 1], + BooleanVal BooleanVal_mut: BOOL, + SByteVal SByteVal_mut: INT8, + Int16Val Int16Val_mut: INT16, + Int32Val Int32Val_mut: INT32, + Int64Val Int64Val_mut: INT64, + ByteVal ByteVal_mut: UINT8, + UInt16Val UInt16Val_mut: UINT16, + UInt32Val UInt32Val_mut: UINT32, + UInt64Val UInt64Val_mut: UINT64, + SingleVal SingleVal_mut: c_float, + DoubleVal DoubleVal_mut: c_double, + FileTimeVal FileTimeVal_mut: ULONGLONG, + SysTimeVal SysTimeVal_mut: *mut SYSTEMTIME, + GuidVal GuidVal_mut: *mut GUID, + StringVal StringVal_mut: LPCWSTR, + AnsiStringVal AnsiStringVal_mut: LPCSTR, + BinaryVal BinaryVal_mut: PBYTE, + SidVal SidVal_mut: PSID, + SizeTVal SizeTVal_mut: size_t, + BooleanArr BooleanArr_mut: *mut BOOL, + SByteArr SByteArr_mut: *mut INT8, + Int16Arr Int16Arr_mut: *mut INT16, + Int32Arr Int32Arr_mut: *mut INT32, + Int64Arr Int64Arr_mut: *mut INT64, + ByteArr ByteArr_mut: *mut UINT8, + UInt16Arr UInt16Arr_mut: *mut UINT16, + UInt32Arr UInt32Arr_mut: *mut UINT32, + UInt64Arr UInt64Arr_mut: *mut UINT64, + SingleArr SingleArr_mut: *mut c_float, + DoubleArr DoubleArr_mut: *mut c_double, + FileTimeArr FileTimeArr_mut: *mut FILETIME, + SysTimeArr SysTimeArr_mut: *mut SYSTEMTIME, + GuidArr GuidArr_mut: *mut GUID, + StringArr StringArr_mut: *mut LPWSTR, + AnsiStringArr AnsiStringArr_mut: *mut LPSTR, + SidArr SidArr_mut: *mut PSID, + SizeTArr SizeTArr_mut: *mut size_t, + EvtHandleVal EvtHandleVal_mut: EVT_HANDLE, + XmlVal XmlVal_mut: LPCWSTR, + XmlValArr XmlValArr_mut: *mut LPCWSTR, +}} +STRUCT!{struct EVT_VARIANT { + u: EVT_VARIANT_u, + Count: DWORD, + Type: DWORD, +}} +pub type PEVT_VARIANT = *mut EVT_VARIANT; +ENUM!{enum EVT_LOGIN_CLASS { + EvtRpcLogin = 1, +}} +ENUM!{enum EVT_RPC_LOGIN_FLAGS { + EvtRpcLoginAuthDefault = 0, + EvtRpcLoginAuthNegotiate, + EvtRpcLoginAuthKerberos, + EvtRpcLoginAuthNTLM, +}} +STRUCT!{struct EVT_RPC_LOGIN { + Server: LPWSTR, + User: LPWSTR, + Domain: LPWSTR, + Password: LPWSTR, + Flags: DWORD, +}} +extern "system" { + pub fn EvtOpenSession( + LoginClass: EVT_LOGIN_CLASS, + Login: PVOID, + Timeout: DWORD, + Flags: DWORD, + ) -> EVT_HANDLE; + pub fn EvtClose( + Object: EVT_HANDLE, + ) -> BOOL; + pub fn EvtCancel( + Object: EVT_HANDLE, + ) -> BOOL; + pub fn EvtGetExtendedStatus( + BufferSize: DWORD, + Buffer: LPWSTR, + BufferUsed: PDWORD, + ) -> DWORD; +} +ENUM!{enum EVT_QUERY_FLAGS { + EvtQueryChannelPath = 0x1, + EvtQueryFilePath = 0x2, + EvtQueryForwardDirection = 0x100, + EvtQueryReverseDirection = 0x200, + EvtQueryTolerateQueryErrors = 0x1000, +}} +ENUM!{enum EVT_SEEK_FLAGS { + EvtSeekRelativeToFirst = 1, + EvtSeekRelativeToLast = 2, + EvtSeekRelativeToCurrent = 3, + EvtSeekRelativeToBookmark = 4, + EvtSeekOriginMask = 7, + EvtSeekStrict = 0x10000, +}} +extern "system" { + pub fn EvtQuery( + Session: EVT_HANDLE, + Path: LPCWSTR, + Query: LPCWSTR, + Flags: DWORD, + ) -> EVT_HANDLE; + pub fn EvtNext( + ResultSet: EVT_HANDLE, + EventsSize: DWORD, + Events: PEVT_HANDLE, + Timeout: DWORD, + Flags: DWORD, + Returned: PDWORD, + ) -> BOOL; + pub fn EvtSeek( + ResultSet: EVT_HANDLE, + Position: LONGLONG, + Bookmark: EVT_HANDLE, + Timeout: DWORD, + Flags: DWORD, + ) -> BOOL; +} +ENUM!{enum EVT_SUBSCRIBE_FLAGS { + EvtSubscribeToFutureEvents = 1, + EvtSubscribeStartAtOldestRecord = 2, + EvtSubscribeStartAfterBookmark = 3, + EvtSubscribeOriginMask = 3, + EvtSubscribeTolerateQueryErrors = 0x1000, + EvtSubscribeStrict = 0x10000, +}} +ENUM!{enum EVT_SUBSCRIBE_NOTIFY_ACTION { + EvtSubscribeActionError = 0, + EvtSubscribeActionDeliver, +}} +FN!{stdcall EVT_SUBSCRIBE_CALLBACK( + Action: EVT_SUBSCRIBE_NOTIFY_ACTION, + UserContext: PVOID, + Event: EVT_HANDLE, +) -> DWORD} +extern "system" { + pub fn EvtSubscribe( + Session: EVT_HANDLE, + SignalEvent: HANDLE, + ChannelPath: LPCWSTR, + Query: LPCWSTR, + Bookmark: EVT_HANDLE, + Context: PVOID, + Callback: EVT_SUBSCRIBE_CALLBACK, + Flags: DWORD, + ) -> EVT_HANDLE; +} +ENUM!{enum EVT_SYSTEM_PROPERTY_ID { + EvtSystemProviderName = 0, + EvtSystemProviderGuid, + EvtSystemEventID, + EvtSystemQualifiers, + EvtSystemLevel, + EvtSystemTask, + EvtSystemOpcode, + EvtSystemKeywords, + EvtSystemTimeCreated, + EvtSystemEventRecordId, + EvtSystemActivityID, + EvtSystemRelatedActivityID, + EvtSystemProcessID, + EvtSystemThreadID, + EvtSystemChannel, + EvtSystemComputer, + EvtSystemUserID, + EvtSystemVersion, + EvtSystemPropertyIdEND, +}} +ENUM!{enum EVT_RENDER_CONTEXT_FLAGS { + EvtRenderContextValues = 0, + EvtRenderContextSystem, + EvtRenderContextUser, +}} +ENUM!{enum EVT_RENDER_FLAGS { + EvtRenderEventValues = 0, + EvtRenderEventXml, + EvtRenderBookmark, +}} +extern "system" { + pub fn EvtCreateRenderContext( + ValuePathsCount: DWORD, + ValuePaths: *mut LPCWSTR, + Flags: DWORD, + ) -> EVT_HANDLE; + pub fn EvtRender( + Context: EVT_HANDLE, + Fragment: EVT_HANDLE, + Flags: DWORD, + BufferSize: DWORD, + Buffer: PVOID, + BufferUsed: PDWORD, + PropertyCount: PDWORD, + ) -> BOOL; +} +ENUM!{enum EVT_FORMAT_MESSAGE_FLAGS { + EvtFormatMessageEvent = 1, + EvtFormatMessageLevel, + EvtFormatMessageTask, + EvtFormatMessageOpcode, + EvtFormatMessageKeyword, + EvtFormatMessageChannel, + EvtFormatMessageProvider, + EvtFormatMessageId, + EvtFormatMessageXml, +}} +extern "system" { + pub fn EvtFormatMessage( + PublisherMetadata: EVT_HANDLE, + Event: EVT_HANDLE, + MessageId: DWORD, + ValueCount: DWORD, + Values: PEVT_VARIANT, + Flags: DWORD, + BufferSize: DWORD, + Buffer: LPWSTR, + BufferUsed: PDWORD, + ) -> BOOL; +} +ENUM!{enum EVT_OPEN_LOG_FLAGS { + EvtOpenChannelPath = 0x1, + EvtOpenFilePath = 0x2, +}} +ENUM!{enum EVT_LOG_PROPERTY_ID { + EvtLogCreationTime = 0, + EvtLogLastAccessTime, + EvtLogLastWriteTime, + EvtLogFileSize, + EvtLogAttributes, + EvtLogNumberOfLogRecords, + EvtLogOldestRecordNumber, + EvtLogFull, +}} +extern "system" { + pub fn EvtOpenLog( + Session: EVT_HANDLE, + Path: LPCWSTR, + Flags: DWORD, + ) -> EVT_HANDLE; + pub fn EvtGetLogInfo( + Log: EVT_HANDLE, + PropertyId: EVT_LOG_PROPERTY_ID, + PropertyValueBufferSize: DWORD, + PropertyValueBuffer: PEVT_VARIANT, + PropertyValueBufferUsed: PDWORD, + ) -> BOOL; + pub fn EvtClearLog( + Session: EVT_HANDLE, + ChannelPath: LPCWSTR, + TargetFilePath: LPCWSTR, + Flags: DWORD, + ) -> BOOL; +} +ENUM!{enum EVT_EXPORTLOG_FLAGS { + EvtExportLogChannelPath = 0x1, + EvtExportLogFilePath = 0x2, + EvtExportLogTolerateQueryErrors = 0x1000, + EvtExportLogOverwrite = 0x2000, +}} +extern "system" { + pub fn EvtExportLog( + Session: EVT_HANDLE, + Path: LPCWSTR, + Query: LPCWSTR, + TargetFilePath: LPCWSTR, + Flags: DWORD, + ) -> BOOL; + pub fn EvtArchiveExportedLog( + Session: EVT_HANDLE, + LogFilePath: LPCWSTR, + Locale: LCID, + Flags: DWORD, + ) -> BOOL; +} +ENUM!{enum EVT_CHANNEL_CONFIG_PROPERTY_ID { + EvtChannelConfigEnabled = 0, + EvtChannelConfigIsolation, + EvtChannelConfigType, + EvtChannelConfigOwningPublisher, + EvtChannelConfigClassicEventlog, + EvtChannelConfigAccess, + EvtChannelLoggingConfigRetention, + EvtChannelLoggingConfigAutoBackup, + EvtChannelLoggingConfigMaxSize, + EvtChannelLoggingConfigLogFilePath, + EvtChannelPublishingConfigLevel, + EvtChannelPublishingConfigKeywords, + EvtChannelPublishingConfigControlGuid, + EvtChannelPublishingConfigBufferSize, + EvtChannelPublishingConfigMinBuffers, + EvtChannelPublishingConfigMaxBuffers, + EvtChannelPublishingConfigLatency, + EvtChannelPublishingConfigClockType, + EvtChannelPublishingConfigSidType, + EvtChannelPublisherList, + EvtChannelPublishingConfigFileMax, + EvtChannelConfigPropertyIdEND, +}} +ENUM!{enum EVT_CHANNEL_TYPE { + EvtChannelTypeAdmin = 0, + EvtChannelTypeOperational, + EvtChannelTypeAnalytic, + EvtChannelTypeDebug, +}} +ENUM!{enum EVT_CHANNEL_ISOLATION_TYPE { + EvtChannelIsolationTypeApplication = 0, + EvtChannelIsolationTypeSystem, + EvtChannelIsolationTypeCustom, +}} +ENUM!{enum EVT_CHANNEL_CLOCK_TYPE { + EvtChannelClockTypeSystemTime = 0, + EvtChannelClockTypeQPC, +}} +ENUM!{enum EVT_CHANNEL_SID_TYPE { + EvtChannelSidTypeNone = 0, + EvtChannelSidTypePublishing, +}} +extern "system" { + pub fn EvtOpenChannelEnum( + Session: EVT_HANDLE, + Flags: DWORD, + ) -> EVT_HANDLE; + pub fn EvtNextChannelPath( + ChannelEnum: EVT_HANDLE, + ChannelPathBufferSize: DWORD, + ChannelPathBuffer: LPWSTR, + ChannelPathBufferUsed: PDWORD, + ) -> BOOL; + pub fn EvtOpenChannelConfig( + Session: EVT_HANDLE, + ChannelPath: LPCWSTR, + Flags: DWORD, + ) -> EVT_HANDLE; + pub fn EvtSaveChannelConfig( + ChannelConfig: EVT_HANDLE, + Flags: DWORD, + ) -> BOOL; + pub fn EvtSetChannelConfigProperty( + ChannelConfig: EVT_HANDLE, + PropertyId: EVT_CHANNEL_CONFIG_PROPERTY_ID, + Flags: DWORD, + PropertyValue: PEVT_VARIANT, + ) -> BOOL; + pub fn EvtGetChannelConfigProperty( + ChannelConfig: EVT_HANDLE, + PropertyId: EVT_CHANNEL_CONFIG_PROPERTY_ID, + Flags: DWORD, + PropertyValueBufferSize: DWORD, + PropertyValueBuffer: PEVT_VARIANT, + PropertyValueBufferUsed: PDWORD, + ) -> BOOL; +} +ENUM!{enum EVT_CHANNEL_REFERENCE_FLAGS { + EvtChannelReferenceImported = 0x1, +}} +ENUM!{enum EVT_PUBLISHER_METADATA_PROPERTY_ID { + EvtPublisherMetadataPublisherGuid = 0, + EvtPublisherMetadataResourceFilePath, + EvtPublisherMetadataParameterFilePath, + EvtPublisherMetadataMessageFilePath, + EvtPublisherMetadataHelpLink, + EvtPublisherMetadataPublisherMessageID, + EvtPublisherMetadataChannelReferences, + EvtPublisherMetadataChannelReferencePath, + EvtPublisherMetadataChannelReferenceIndex, + EvtPublisherMetadataChannelReferenceID, + EvtPublisherMetadataChannelReferenceFlags, + EvtPublisherMetadataChannelReferenceMessageID, + EvtPublisherMetadataLevels, + EvtPublisherMetadataLevelName, + EvtPublisherMetadataLevelValue, + EvtPublisherMetadataLevelMessageID, + EvtPublisherMetadataTasks, + EvtPublisherMetadataTaskName, + EvtPublisherMetadataTaskEventGuid, + EvtPublisherMetadataTaskValue, + EvtPublisherMetadataTaskMessageID, + EvtPublisherMetadataOpcodes, + EvtPublisherMetadataOpcodeName, + EvtPublisherMetadataOpcodeValue, + EvtPublisherMetadataOpcodeMessageID, + EvtPublisherMetadataKeywords, + EvtPublisherMetadataKeywordName, + EvtPublisherMetadataKeywordValue, + EvtPublisherMetadataKeywordMessageID, + EvtPublisherMetadataPropertyIdEND, +}} +extern "system" { + pub fn EvtOpenPublisherEnum( + Session: EVT_HANDLE, + Flags: DWORD, + ) -> EVT_HANDLE; + pub fn EvtNextPublisherId( + PublisherEnum: EVT_HANDLE, + PublisherIdBufferSize: DWORD, + PublisherIdBuffer: LPWSTR, + PublisherIdBufferUsed: PDWORD, + ) -> BOOL; + pub fn EvtOpenPublisherMetadata( + Session: EVT_HANDLE, + PublisherId: LPCWSTR, + LogFilePath: LPCWSTR, + Locale: LCID, + Flags: DWORD, + ) -> EVT_HANDLE; + pub fn EvtGetPublisherMetadataProperty( + PublisherMetadata: EVT_HANDLE, + PropertyId: EVT_PUBLISHER_METADATA_PROPERTY_ID, + Flags: DWORD, + PublisherMetadataPropertyBufferSize: DWORD, + PublisherMetadataPropertyBuffer: PEVT_VARIANT, + PublisherMetadataPropertyBufferUsed: PDWORD, + ) -> BOOL; +} +ENUM!{enum EVT_EVENT_METADATA_PROPERTY_ID { + EventMetadataEventID, + EventMetadataEventVersion, + EventMetadataEventChannel, + EventMetadataEventLevel, + EventMetadataEventOpcode, + EventMetadataEventTask, + EventMetadataEventKeyword, + EventMetadataEventMessageID, + EventMetadataEventTemplate, + EvtEventMetadataPropertyIdEND, +}} +extern "system" { + pub fn EvtOpenEventMetadataEnum( + PublisherMetadata: EVT_HANDLE, + Flags: DWORD, + ) -> EVT_HANDLE; + pub fn EvtNextEventMetadata( + EventMetadataEnum: EVT_HANDLE, + Flags: DWORD, + ) -> EVT_HANDLE; + pub fn EvtGetEventMetadataProperty( + EventMetadata: EVT_HANDLE, + PropertyId: EVT_EVENT_METADATA_PROPERTY_ID, + Flags: DWORD, + EventMetadataPropertyBufferSize: DWORD, + EventMetadataPropertyBuffer: PEVT_VARIANT, + EventMetadataPropertyBufferUsed: PDWORD, + ) -> BOOL; +} +pub type EVT_OBJECT_ARRAY_PROPERTY_HANDLE = HANDLE; +extern "system" { + pub fn EvtGetObjectArraySize( + ObjectArray: EVT_OBJECT_ARRAY_PROPERTY_HANDLE, + ObjectArraySize: PDWORD, + ) -> BOOL; + pub fn EvtGetObjectArrayProperty( + ObjectArray: EVT_OBJECT_ARRAY_PROPERTY_HANDLE, + PropertyId: DWORD, + ArrayIndex: DWORD, + Flags: DWORD, + PropertyValueBufferSize: DWORD, + PropertyValueBuffer: PEVT_VARIANT, + PropertyValueBufferUsed: PDWORD, + ) -> BOOL; +} +ENUM!{enum EVT_QUERY_PROPERTY_ID { + EvtQueryNames, + EvtQueryStatuses, + EvtQueryPropertyIdEND, +}} +ENUM!{enum EVT_EVENT_PROPERTY_ID { + EvtEventQueryIDs = 0, + EvtEventPath, + EvtEventPropertyIdEND, +}} +extern "system" { + pub fn EvtGetQueryInfo( + QueryOrSubscription: EVT_HANDLE, + PropertyId: EVT_QUERY_PROPERTY_ID, + PropertyValueBufferSize: DWORD, + PropertyValueBuffer: PEVT_VARIANT, + PropertyValueBufferUsed: PDWORD, + ) -> BOOL; + pub fn EvtCreateBookmark( + BookmarkXml: LPCWSTR, + ) -> EVT_HANDLE; + pub fn EvtUpdateBookmark( + Bookmark: EVT_HANDLE, + Event: EVT_HANDLE, + ) -> BOOL; + pub fn EvtGetEventInfo( + Event: EVT_HANDLE, + PropertyId: EVT_EVENT_PROPERTY_ID, + PropertyValueBufferSize: DWORD, + PropertyValueBuffer: PEVT_VARIANT, + PropertyValueBufferUsed: PDWORD, + ) -> BOOL; +} +pub const EVT_READ_ACCESS: DWORD = 0x1; +pub const EVT_WRITE_ACCESS: DWORD = 0x2; +pub const EVT_CLEAR_ACCESS: DWORD = 0x4; +pub const EVT_ALL_ACCESS: DWORD = 0x7; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wingdi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wingdi.rs new file mode 100644 index 0000000..4404bee --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wingdi.rs @@ -0,0 +1,5591 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! GDI procedure declarations, constant definitions and macros +use ctypes::{c_char, c_int, c_long, c_short, c_ushort, c_void}; +use shared::basetsd::{UINT16, UINT32, UINT64, ULONG_PTR}; +use shared::minwindef::{ + BOOL, BYTE, DWORD, FLOAT, HGLOBAL, HMETAFILE, HMODULE, HRGN, INT, LOBYTE, LPARAM, LPBYTE, + LPDWORD, LPINT, LPVOID, LPWORD, MAX_PATH, PFLOAT, PROC, UINT, ULONG, USHORT, WORD, +}; +use shared::windef::{ + COLORREF, HBITMAP, HBRUSH, HCOLORSPACE, HDC, HENHMETAFILE, HFONT, HGDIOBJ, HGLRC, HPALETTE, + HPEN, HWND, LPPOINT, LPRECT, LPSIZE, POINT, POINTL, POINTS, RECT, RECTL, SIZEL, +}; +use um::winnt::{ + CHAR, HANDLE, LONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, LUID, PSTR, PVOID, SHORT, VOID, WCHAR, +}; +pub const R2_BLACK: c_int = 1; +pub const R2_NOTMERGEPEN: c_int = 2; +pub const R2_MASKNOTPEN: c_int = 3; +pub const R2_NOTCOPYPEN: c_int = 4; +pub const R2_MASKPENNOT: c_int = 5; +pub const R2_NOT: c_int = 6; +pub const R2_XORPEN: c_int = 7; +pub const R2_NOTMASKPEN: c_int = 8; +pub const R2_MASKPEN: c_int = 9; +pub const R2_NOTXORPEN: c_int = 10; +pub const R2_NOP: c_int = 11; +pub const R2_MERGENOTPEN: c_int = 12; +pub const R2_COPYPEN: c_int = 13; +pub const R2_MERGEPENNOT: c_int = 14; +pub const R2_MERGEPEN: c_int = 15; +pub const R2_WHITE: c_int = 16; +pub const R2_LAST: c_int = 16; +pub const SRCCOPY: DWORD = 0x00CC0020; +pub const SRCPAINT: DWORD = 0x00EE0086; +pub const SRCAND: DWORD = 0x008800C6; +pub const SRCINVERT: DWORD = 0x00660046; +pub const SRCERASE: DWORD = 0x00440328; +pub const NOTSRCCOPY: DWORD = 0x00330008; +pub const NOTSRCERASE: DWORD = 0x001100A6; +pub const MERGECOPY: DWORD = 0x00C000CA; +pub const MERGEPAINT: DWORD = 0x00BB0226; +pub const PATCOPY: DWORD = 0x00F00021; +pub const PATPAINT: DWORD = 0x00FB0A09; +pub const PATINVERT: DWORD = 0x005A0049; +pub const DSTINVERT: DWORD = 0x00550009; +pub const BLACKNESS: DWORD = 0x00000042; +pub const WHITENESS: DWORD = 0x00FF0062; +pub const NOMIRRORBITMAP: DWORD = 0x80000000; +pub const CAPTUREBLT: DWORD = 0x40000000; +#[inline] +pub fn MAKEROP4(fore: DWORD, back: DWORD) -> DWORD { + ((back << 8) & 0xFF000000) | fore +} +pub const GDI_ERROR: ULONG = 0xFFFFFFFF; +pub const HGDI_ERROR: HANDLE = -1isize as HANDLE; +pub const ERROR: c_int = 0; +pub const NULLREGION: c_int = 1; +pub const SIMPLEREGION: c_int = 2; +pub const COMPLEXREGION: c_int = 3; +pub const RGN_ERROR: c_int = ERROR; +pub const RGN_AND: c_int = 1; +pub const RGN_OR: c_int = 2; +pub const RGN_XOR: c_int = 3; +pub const RGN_DIFF: c_int = 4; +pub const RGN_COPY: c_int = 5; +pub const RGN_MIN: c_int = RGN_AND; +pub const RGN_MAX: c_int = RGN_COPY; +pub const BLACKONWHITE: c_int = 1; +pub const WHITEONBLACK: c_int = 2; +pub const COLORONCOLOR: c_int = 3; +pub const HALFTONE: c_int = 4; +pub const MAXSTRETCHBLTMODE: c_int = 4; +pub const STRETCH_ANDSCANS: c_int = BLACKONWHITE; +pub const STRETCH_ORSCANS: c_int = WHITEONBLACK; +pub const STRETCH_DELETESCANS: c_int = COLORONCOLOR; +pub const STRETCH_HALFTONE: c_int = HALFTONE; +pub const ALTERNATE: c_int = 1; +pub const WINDING: c_int = 2; +pub const POLYFILL_LAST: c_int = 2; +pub const LAYOUT_RTL: DWORD = 0x00000001; +pub const LAYOUT_BTT: DWORD = 0x00000002; +pub const LAYOUT_VBH: DWORD = 0x00000004; +pub const LAYOUT_ORIENTATIONMASK: DWORD = (LAYOUT_RTL | LAYOUT_BTT | LAYOUT_VBH); +pub const LAYOUT_BITMAPORIENTATIONPRESERVED: DWORD = 0x00000008; +pub const TA_NOUPDATECP: UINT = 0; +pub const TA_UPDATECP: UINT = 1; +pub const TA_LEFT: UINT = 0; +pub const TA_RIGHT: UINT = 2; +pub const TA_CENTER: UINT = 6; +pub const TA_TOP: UINT = 0; +pub const TA_BOTTOM: UINT = 8; +pub const TA_BASELINE: UINT = 24; +pub const TA_RTLREADING: UINT = 256; +pub const TA_MASK: UINT = TA_BASELINE + TA_CENTER + TA_UPDATECP + TA_RTLREADING; +pub const VTA_BASELINE: UINT = TA_BASELINE; +pub const VTA_LEFT: UINT = TA_BOTTOM; +pub const VTA_RIGHT: UINT = TA_TOP; +pub const VTA_CENTER: UINT = TA_CENTER; +pub const VTA_BOTTOM: UINT = TA_RIGHT; +pub const VTA_TOP: UINT = TA_LEFT; +pub const ETO_OPAQUE: UINT = 0x0002; +pub const ETO_CLIPPED: UINT = 0x0004; +pub const ETO_GLYPH_INDEX: UINT = 0x0010; +pub const ETO_RTLREADING: UINT = 0x0080; +pub const ETO_NUMERICSLOCAL: UINT = 0x0400; +pub const ETO_NUMERICSLATIN: UINT = 0x0800; +pub const ETO_IGNORELANGUAGE: UINT = 0x1000; +pub const ETO_PDY: UINT = 0x2000; +pub const ETO_REVERSE_INDEX_MAP: UINT = 0x10000; +pub const ASPECT_FILTERING: UINT = 0x0001; +pub const DCB_RESET: UINT = 0x0001; +pub const DCB_ACCUMULATE: UINT = 0x0002; +pub const DCB_DIRTY: UINT = DCB_ACCUMULATE; +pub const DCB_SET: UINT = (DCB_RESET | DCB_ACCUMULATE); +pub const DCB_ENABLE: UINT = 0x0004; +pub const DCB_DISABLE: UINT = 0x0008; +pub const META_SETBKCOLOR: WORD = 0x0201; +pub const META_SETBKMODE: WORD = 0x0102; +pub const META_SETMAPMODE: WORD = 0x0103; +pub const META_SETROP2: WORD = 0x0104; +pub const META_SETRELABS: WORD = 0x0105; +pub const META_SETPOLYFILLMODE: WORD = 0x0106; +pub const META_SETSTRETCHBLTMODE: WORD = 0x0107; +pub const META_SETTEXTCHAREXTRA: WORD = 0x0108; +pub const META_SETTEXTCOLOR: WORD = 0x0209; +pub const META_SETTEXTJUSTIFICATION: WORD = 0x020A; +pub const META_SETWINDOWORG: WORD = 0x020B; +pub const META_SETWINDOWEXT: WORD = 0x020C; +pub const META_SETVIEWPORTORG: WORD = 0x020D; +pub const META_SETVIEWPORTEXT: WORD = 0x020E; +pub const META_OFFSETWINDOWORG: WORD = 0x020F; +pub const META_SCALEWINDOWEXT: WORD = 0x0410; +pub const META_OFFSETVIEWPORTORG: WORD = 0x0211; +pub const META_SCALEVIEWPORTEXT: WORD = 0x0412; +pub const META_LINETO: WORD = 0x0213; +pub const META_MOVETO: WORD = 0x0214; +pub const META_EXCLUDECLIPRECT: WORD = 0x0415; +pub const META_INTERSECTCLIPRECT: WORD = 0x0416; +pub const META_ARC: WORD = 0x0817; +pub const META_ELLIPSE: WORD = 0x0418; +pub const META_FLOODFILL: WORD = 0x0419; +pub const META_PIE: WORD = 0x081A; +pub const META_RECTANGLE: WORD = 0x041B; +pub const META_ROUNDRECT: WORD = 0x061C; +pub const META_PATBLT: WORD = 0x061D; +pub const META_SAVEDC: WORD = 0x001E; +pub const META_SETPIXEL: WORD = 0x041F; +pub const META_OFFSETCLIPRGN: WORD = 0x0220; +pub const META_TEXTOUT: WORD = 0x0521; +pub const META_BITBLT: WORD = 0x0922; +pub const META_STRETCHBLT: WORD = 0x0B23; +pub const META_POLYGON: WORD = 0x0324; +pub const META_POLYLINE: WORD = 0x0325; +pub const META_ESCAPE: WORD = 0x0626; +pub const META_RESTOREDC: WORD = 0x0127; +pub const META_FILLREGION: WORD = 0x0228; +pub const META_FRAMEREGION: WORD = 0x0429; +pub const META_INVERTREGION: WORD = 0x012A; +pub const META_PAINTREGION: WORD = 0x012B; +pub const META_SELECTCLIPREGION: WORD = 0x012C; +pub const META_SELECTOBJECT: WORD = 0x012D; +pub const META_SETTEXTALIGN: WORD = 0x012E; +pub const META_CHORD: WORD = 0x0830; +pub const META_SETMAPPERFLAGS: WORD = 0x0231; +pub const META_EXTTEXTOUT: WORD = 0x0a32; +pub const META_SETDIBTODEV: WORD = 0x0d33; +pub const META_SELECTPALETTE: WORD = 0x0234; +pub const META_REALIZEPALETTE: WORD = 0x0035; +pub const META_ANIMATEPALETTE: WORD = 0x0436; +pub const META_SETPALENTRIES: WORD = 0x0037; +pub const META_POLYPOLYGON: WORD = 0x0538; +pub const META_RESIZEPALETTE: WORD = 0x0139; +pub const META_DIBBITBLT: WORD = 0x0940; +pub const META_DIBSTRETCHBLT: WORD = 0x0b41; +pub const META_DIBCREATEPATTERNBRUSH: WORD = 0x0142; +pub const META_STRETCHDIB: WORD = 0x0f43; +pub const META_EXTFLOODFILL: WORD = 0x0548; +pub const META_SETLAYOUT: WORD = 0x0149; +pub const META_DELETEOBJECT: WORD = 0x01f0; +pub const META_CREATEPALETTE: WORD = 0x00f7; +pub const META_CREATEPATTERNBRUSH: WORD = 0x01F9; +pub const META_CREATEPENINDIRECT: WORD = 0x02FA; +pub const META_CREATEFONTINDIRECT: WORD = 0x02FB; +pub const META_CREATEBRUSHINDIRECT: WORD = 0x02FC; +pub const META_CREATEREGION: WORD = 0x06FF; +STRUCT!{struct DRAWPATRECT { + ptPosition: POINT, + ptSize: POINT, + wStyle: WORD, + wPattern: WORD, +}} +pub type PDRAWPATRECT = *mut DRAWPATRECT; +pub const NEWFRAME: c_int = 1; +pub const ABORTDOC: c_int = 2; +pub const NEXTBAND: c_int = 3; +pub const SETCOLORTABLE: c_int = 4; +pub const GETCOLORTABLE: c_int = 5; +pub const FLUSHOUTPUT: c_int = 6; +pub const DRAFTMODE: c_int = 7; +pub const QUERYESCSUPPORT: c_int = 8; +pub const SETABORTPROC: c_int = 9; +pub const STARTDOC: c_int = 10; +pub const ENDDOC: c_int = 11; +pub const GETPHYSPAGESIZE: c_int = 12; +pub const GETPRINTINGOFFSET: c_int = 13; +pub const GETSCALINGFACTOR: c_int = 14; +pub const MFCOMMENT: c_int = 15; +pub const GETPENWIDTH: c_int = 16; +pub const SETCOPYCOUNT: c_int = 17; +pub const SELECTPAPERSOURCE: c_int = 18; +pub const DEVICEDATA: c_int = 19; +pub const PASSTHROUGH: c_int = 19; +pub const GETTECHNOLGY: c_int = 20; +pub const GETTECHNOLOGY: c_int = 20; +pub const SETLINECAP: c_int = 21; +pub const SETLINEJOIN: c_int = 22; +pub const SETMITERLIMIT: c_int = 23; +pub const BANDINFO: c_int = 24; +pub const DRAWPATTERNRECT: c_int = 25; +pub const GETVECTORPENSIZE: c_int = 26; +pub const GETVECTORBRUSHSIZE: c_int = 27; +pub const ENABLEDUPLEX: c_int = 28; +pub const GETSETPAPERBINS: c_int = 29; +pub const GETSETPRINTORIENT: c_int = 30; +pub const ENUMPAPERBINS: c_int = 31; +pub const SETDIBSCALING: c_int = 32; +pub const EPSPRINTING: c_int = 33; +pub const ENUMPAPERMETRICS: c_int = 34; +pub const GETSETPAPERMETRICS: c_int = 35; +pub const POSTSCRIPT_DATA: c_int = 37; +pub const POSTSCRIPT_IGNORE: c_int = 38; +pub const MOUSETRAILS: c_int = 39; +pub const GETDEVICEUNITS: c_int = 42; +pub const GETEXTENDEDTEXTMETRICS: c_int = 256; +pub const GETEXTENTTABLE: c_int = 257; +pub const GETPAIRKERNTABLE: c_int = 258; +pub const GETTRACKKERNTABLE: c_int = 259; +pub const EXTTEXTOUT: c_int = 512; +pub const GETFACENAME: c_int = 513; +pub const DOWNLOADFACE: c_int = 514; +pub const ENABLERELATIVEWIDTHS: c_int = 768; +pub const ENABLEPAIRKERNING: c_int = 769; +pub const SETKERNTRACK: c_int = 770; +pub const SETALLJUSTVALUES: c_int = 771; +pub const SETCHARSET: c_int = 772; +pub const STRETCHBLT: c_int = 2048; +pub const METAFILE_DRIVER: c_int = 2049; +pub const GETSETSCREENPARAMS: c_int = 3072; +pub const QUERYDIBSUPPORT: c_int = 3073; +pub const BEGIN_PATH: c_int = 4096; +pub const CLIP_TO_PATH: c_int = 4097; +pub const END_PATH: c_int = 4098; +pub const EXT_DEVICE_CAPS: c_int = 4099; +pub const RESTORE_CTM: c_int = 4100; +pub const SAVE_CTM: c_int = 4101; +pub const SET_ARC_DIRECTION: c_int = 4102; +pub const SET_BACKGROUND_COLOR: c_int = 4103; +pub const SET_POLY_MODE: c_int = 4104; +pub const SET_SCREEN_ANGLE: c_int = 4105; +pub const SET_SPREAD: c_int = 4106; +pub const TRANSFORM_CTM: c_int = 4107; +pub const SET_CLIP_BOX: c_int = 4108; +pub const SET_BOUNDS: c_int = 4109; +pub const SET_MIRROR_MODE: c_int = 4110; +pub const OPENCHANNEL: c_int = 4110; +pub const DOWNLOADHEADER: c_int = 4111; +pub const CLOSECHANNEL: c_int = 4112; +pub const POSTSCRIPT_PASSTHROUGH: c_int = 4115; +pub const ENCAPSULATED_POSTSCRIPT: c_int = 4116; +pub const POSTSCRIPT_IDENTIFY: c_int = 4117; +pub const POSTSCRIPT_INJECTION: c_int = 4118; +pub const CHECKJPEGFORMAT: c_int = 4119; +pub const CHECKPNGFORMAT: c_int = 4120; +pub const GET_PS_FEATURESETTING: c_int = 4121; +pub const GDIPLUS_TS_QUERYVER: c_int = 4122; +pub const GDIPLUS_TS_RECORD: c_int = 4123; +pub const MILCORE_TS_QUERYVER_RESULT_FALSE: c_int = 0x0; +pub const MILCORE_TS_QUERYVER_RESULT_TRUE: c_int = 0x7FFFFFFF; +pub const SPCLPASSTHROUGH2: c_int = 4568; +pub const PSIDENT_GDICENTRIC: c_int = 0; +pub const PSIDENT_PSCENTRIC: c_int = 1; +STRUCT!{struct PSINJECTDATA { + DataBytes: DWORD, + InjectionPoint: WORD, + PageNumber: WORD, +}} +pub type PPSINJECTDATA = *mut PSINJECTDATA; +pub const PSINJECT_BEGINSTREAM: WORD = 1; +pub const PSINJECT_PSADOBE: WORD = 2; +pub const PSINJECT_PAGESATEND: WORD = 3; +pub const PSINJECT_PAGES: WORD = 4; +pub const PSINJECT_DOCNEEDEDRES: WORD = 5; +pub const PSINJECT_DOCSUPPLIEDRES: WORD = 6; +pub const PSINJECT_PAGEORDER: WORD = 7; +pub const PSINJECT_ORIENTATION: WORD = 8; +pub const PSINJECT_BOUNDINGBOX: WORD = 9; +pub const PSINJECT_DOCUMENTPROCESSCOLORS: WORD = 10; +pub const PSINJECT_COMMENTS: WORD = 11; +pub const PSINJECT_BEGINDEFAULTS: WORD = 12; +pub const PSINJECT_ENDDEFAULTS: WORD = 13; +pub const PSINJECT_BEGINPROLOG: WORD = 14; +pub const PSINJECT_ENDPROLOG: WORD = 15; +pub const PSINJECT_BEGINSETUP: WORD = 16; +pub const PSINJECT_ENDSETUP: WORD = 17; +pub const PSINJECT_TRAILER: WORD = 18; +pub const PSINJECT_EOF: WORD = 19; +pub const PSINJECT_ENDSTREAM: WORD = 20; +pub const PSINJECT_DOCUMENTPROCESSCOLORSATEND: WORD = 21; +pub const PSINJECT_PAGENUMBER: WORD = 100; +pub const PSINJECT_BEGINPAGESETUP: WORD = 101; +pub const PSINJECT_ENDPAGESETUP: WORD = 102; +pub const PSINJECT_PAGETRAILER: WORD = 103; +pub const PSINJECT_PLATECOLOR: WORD = 104; +pub const PSINJECT_SHOWPAGE: WORD = 105; +pub const PSINJECT_PAGEBBOX: WORD = 106; +pub const PSINJECT_ENDPAGECOMMENTS: WORD = 107; +pub const PSINJECT_VMSAVE: WORD = 200; +pub const PSINJECT_VMRESTORE: WORD = 201; +pub const PSINJECT_DLFONT: DWORD = 0xdddddddd; +pub const FEATURESETTING_NUP: WORD = 0; +pub const FEATURESETTING_OUTPUT: WORD = 1; +pub const FEATURESETTING_PSLEVEL: WORD = 2; +pub const FEATURESETTING_CUSTPAPER: WORD = 3; +pub const FEATURESETTING_MIRROR: WORD = 4; +pub const FEATURESETTING_NEGATIVE: WORD = 5; +pub const FEATURESETTING_PROTOCOL: WORD = 6; +pub const FEATURESETTING_PRIVATE_BEGIN: WORD = 0x1000; +pub const FEATURESETTING_PRIVATE_END: WORD = 0x1FFF; +STRUCT!{struct PSFEATURE_OUTPUT { + bPageIndependent: BOOL, + bSetPageDevice: BOOL, +}} +pub type PPSFEATURE_OUTPUT = *mut PSFEATURE_OUTPUT; +STRUCT!{struct PSFEATURE_CUSTPAPER { + lOrientation: LONG, + lWidth: LONG, + lHeight: LONG, + lWidthOffset: LONG, + lHeightOffset: LONG, +}} +pub type PPSFEATURE_CUSTPAPER = *mut PSFEATURE_CUSTPAPER; +pub const PSPROTOCOL_ASCII: c_int = 0; +pub const PSPROTOCOL_BCP: c_int = 1; +pub const PSPROTOCOL_TBCP: c_int = 2; +pub const PSPROTOCOL_BINARY: c_int = 3; +pub const QDI_SETDIBITS: c_int = 1; +pub const QDI_GETDIBITS: c_int = 2; +pub const QDI_DIBTOSCREEN: c_int = 4; +pub const QDI_STRETCHDIB: c_int = 8; +pub const SP_NOTREPORTED: c_int = 0x4000; +pub const SP_ERROR: c_int = -1; +pub const SP_APPABORT: c_int = -2; +pub const SP_USERABORT: c_int = -3; +pub const SP_OUTOFDISK: c_int = -4; +pub const SP_OUTOFMEMORY: c_int = -5; +pub const PR_JOBSTATUS: c_int = 0x0000; +pub const OBJ_PEN: UINT = 1; +pub const OBJ_BRUSH: UINT = 2; +pub const OBJ_DC: UINT = 3; +pub const OBJ_METADC: UINT = 4; +pub const OBJ_PAL: UINT = 5; +pub const OBJ_FONT: UINT = 6; +pub const OBJ_BITMAP: UINT = 7; +pub const OBJ_REGION: UINT = 8; +pub const OBJ_METAFILE: UINT = 9; +pub const OBJ_MEMDC: UINT = 10; +pub const OBJ_EXTPEN: UINT = 11; +pub const OBJ_ENHMETADC: UINT = 12; +pub const OBJ_ENHMETAFILE: UINT = 13; +pub const OBJ_COLORSPACE: UINT = 14; +pub const GDI_OBJ_LAST: UINT = OBJ_COLORSPACE; +pub const MWT_IDENTITY: c_int = 1; +pub const MWT_LEFTMULTIPLY: c_int = 2; +pub const MWT_RIGHTMULTIPLY: c_int = 3; +pub const MWT_MIN: c_int = MWT_IDENTITY; +pub const MWT_MAX: c_int = MWT_RIGHTMULTIPLY; +STRUCT!{struct XFORM { + eM11: FLOAT, + eM12: FLOAT, + eM21: FLOAT, + eM22: FLOAT, + eDx: FLOAT, + eDy: FLOAT, +}} +pub type PXFORM = *mut XFORM; +pub type LPXFORM = *mut XFORM; +STRUCT!{struct BITMAP { + bmType: LONG, + bmWidth: LONG, + bmHeight: LONG, + bmWidthBytes: LONG, + bmPlanes: WORD, + bmBitsPixel: WORD, + bmBits: LPVOID, +}} +pub type PBITMAP = *mut BITMAP; +pub type NPBITMAP = *mut BITMAP; +pub type LPBITMAP = *mut BITMAP; +STRUCT!{#[debug] struct RGBTRIPLE { + rgbtBlue: BYTE, + rgbtGreen: BYTE, + rgbtRed: BYTE, +}} +pub type PRGBTRIPLE = *mut RGBTRIPLE; +pub type NPRGBTRIPLE = *mut RGBTRIPLE; +pub type LPRGBTRIPLE = *mut RGBTRIPLE; +STRUCT!{#[debug] struct RGBQUAD { + rgbBlue: BYTE, + rgbGreen: BYTE, + rgbRed: BYTE, + rgbReserved: BYTE, +}} +pub type LPRGBQUAD = *mut RGBQUAD; +pub const CS_ENABLE: DWORD = 0x00000001; +pub const CS_DISABLE: DWORD = 0x00000002; +pub const CS_DELETE_TRANSFORM: DWORD = 0x00000003; +pub const LCS_SIGNATURE: DWORD = 0x5053_4F43; // 'PSOC' +pub const LCS_sRGB: LCSCSTYPE = 0x7352_4742; // 'sRGB' +pub const LCS_WINDOWS_COLOR_SPACE: LCSCSTYPE = 0x5769_6E20; // 'Win ' +pub type LCSCSTYPE = LONG; +pub const LCS_CALIBRATED_RGB: LCSCSTYPE = 0x00000000; +pub type LCSGAMUTMATCH = LONG; +pub const LCS_GM_BUSINESS: LCSGAMUTMATCH = 0x00000001; +pub const LCS_GM_GRAPHICS: LCSGAMUTMATCH = 0x00000002; +pub const LCS_GM_IMAGES: LCSGAMUTMATCH = 0x00000004; +pub const LCS_GM_ABS_COLORIMETRIC: LCSGAMUTMATCH = 0x00000008; +pub const CM_OUT_OF_GAMUT: BYTE = 255; +pub const CM_IN_GAMUT: BYTE = 0; +pub const ICM_ADDPROFILE: UINT = 1; +pub const ICM_DELETEPROFILE: UINT = 2; +pub const ICM_QUERYPROFILE: UINT = 3; +pub const ICM_SETDEFAULTPROFILE: UINT = 4; +pub const ICM_REGISTERICMATCHER: UINT = 5; +pub const ICM_UNREGISTERICMATCHER: UINT = 6; +pub const ICM_QUERYMATCH: UINT = 7; +#[inline] +pub fn GetKValue(cmyk: COLORREF) -> BYTE { + cmyk as BYTE +} +#[inline] +pub fn GetYValue(cmyk: COLORREF) -> BYTE { + (cmyk >> 8) as BYTE +} +#[inline] +pub fn GetMValue(cmyk: COLORREF) -> BYTE { + (cmyk >> 16) as BYTE +} +#[inline] +pub fn GetCValue(cmyk: COLORREF) -> BYTE { + (cmyk >> 24) as BYTE +} +#[inline] +pub fn CMYK(c: BYTE, m: BYTE, y: BYTE, k: BYTE) -> COLORREF { + (k as COLORREF) | ((y as COLORREF) << 8) | ((m as COLORREF) << 16) | ((c as COLORREF) << 24) +} +pub type FXPT16DOT16 = c_long; +pub type LPFXPT16DOT16 = *mut c_long; +pub type FXPT2DOT30 = c_long; +pub type LPFXPT2DOT30 = *mut c_long; +STRUCT!{#[debug] struct CIEXYZ { + ciexyzX: FXPT2DOT30, + ciexyzY: FXPT2DOT30, + ciexyzZ: FXPT2DOT30, +}} +pub type LPCIEXYZ = *mut CIEXYZ; +STRUCT!{#[debug] struct CIEXYZTRIPLE { + ciexyzRed: CIEXYZ, + ciexyzGreen: CIEXYZ, + ciexyzBlue: CIEXYZ, +}} +pub type LPCIEXYZTRIPLE = *mut CIEXYZTRIPLE; +STRUCT!{struct LOGCOLORSPACEA { + lcsSignature: DWORD, + lcsVersion: DWORD, + lcsSize: DWORD, + lcsCSType: LCSCSTYPE, + lcsIntent: LCSGAMUTMATCH, + lcsEndpoints: CIEXYZTRIPLE, + lcsGammaRed: DWORD, + lcsGammaGreen: DWORD, + lcsGammaBlue: DWORD, + lcsFilename: [CHAR; MAX_PATH], +}} +pub type LPLOGCOLORSPACEA = *mut LOGCOLORSPACEA; +STRUCT!{struct LOGCOLORSPACEW { + lcsSignature: DWORD, + lcsVersion: DWORD, + lcsSize: DWORD, + lcsCSType: LCSCSTYPE, + lcsIntent: LCSGAMUTMATCH, + lcsEndpoints: CIEXYZTRIPLE, + lcsGammaRed: DWORD, + lcsGammaGreen: DWORD, + lcsGammaBlue: DWORD, + lcsFilename: [WCHAR; MAX_PATH], +}} +pub type LPLOGCOLORSPACEW = *mut LOGCOLORSPACEW; +STRUCT!{#[debug] struct BITMAPCOREHEADER { + bcSize: DWORD, + bcWidth: WORD, + bcHeight: WORD, + bcPlanes: WORD, + bcBitCount: WORD, +}} +pub type LPBITMAPCOREHEADER = *mut BITMAPCOREHEADER; +pub type PBITMAPCOREHEADER = *mut BITMAPCOREHEADER; +STRUCT!{#[debug] struct BITMAPINFOHEADER { + biSize: DWORD, + biWidth: LONG, + biHeight: LONG, + biPlanes: WORD, + biBitCount: WORD, + biCompression: DWORD, + biSizeImage: DWORD, + biXPelsPerMeter: LONG, + biYPelsPerMeter: LONG, + biClrUsed: DWORD, + biClrImportant: DWORD, +}} +pub type LPBITMAPINFOHEADER = *mut BITMAPINFOHEADER; +pub type PBITMAPINFOHEADER = *mut BITMAPINFOHEADER; +STRUCT!{#[debug] struct BITMAPV4HEADER { + bV4Size: DWORD, + bV4Width: LONG, + bV4Height: LONG, + bV4Planes: WORD, + bV4BitCount: WORD, + bV4V4Compression: DWORD, + bV4SizeImage: DWORD, + bV4XPelsPerMeter: LONG, + bV4YPelsPerMeter: LONG, + bV4ClrUsed: DWORD, + bV4ClrImportant: DWORD, + bV4RedMask: DWORD, + bV4GreenMask: DWORD, + bV4BlueMask: DWORD, + bV4AlphaMask: DWORD, + bV4CSType: DWORD, + bV4Endpoints: CIEXYZTRIPLE, + bV4GammaRed: DWORD, + bV4GammaGreen: DWORD, + bV4GammaBlue: DWORD, +}} +pub type LPBITMAPV4HEADER = *mut BITMAPV4HEADER; +pub type PBITMAPV4HEADER = *mut BITMAPV4HEADER; +STRUCT!{#[debug] struct BITMAPV5HEADER { + bV5Size: DWORD, + bV5Width: LONG, + bV5Height: LONG, + bV5Planes: WORD, + bV5BitCount: WORD, + bV5Compression: DWORD, + bV5SizeImage: DWORD, + bV5XPelsPerMeter: LONG, + bV5YPelsPerMeter: LONG, + bV5ClrUsed: DWORD, + bV5ClrImportant: DWORD, + bV5RedMask: DWORD, + bV5GreenMask: DWORD, + bV5BlueMask: DWORD, + bV5AlphaMask: DWORD, + bV5CSType: DWORD, + bV5Endpoints: CIEXYZTRIPLE, + bV5GammaRed: DWORD, + bV5GammaGreen: DWORD, + bV5GammaBlue: DWORD, + bV5Intent: DWORD, + bV5ProfileData: DWORD, + bV5ProfileSize: DWORD, + bV5Reserved: DWORD, +}} +pub type LPBITMAPV5HEADER = *mut BITMAPV5HEADER; +pub type PBITMAPV5HEADER = *mut BITMAPV5HEADER; +pub const PROFILE_LINKED: LONG = 0x4C49_4E4B; // 'LINK' +pub const PROFILE_EMBEDDED: LONG = 0x4D42_4544; // 'MBED' +pub const BI_RGB: DWORD = 0; +pub const BI_RLE8: DWORD = 1; +pub const BI_RLE4: DWORD = 2; +pub const BI_BITFIELDS: DWORD = 3; +pub const BI_JPEG: DWORD = 4; +pub const BI_PNG: DWORD = 5; +STRUCT!{#[debug] struct BITMAPINFO { + bmiHeader: BITMAPINFOHEADER, + bmiColors: [RGBQUAD; 1], +}} +pub type LPBITMAPINFO = *mut BITMAPINFO; +pub type PBITMAPINFO = *mut BITMAPINFO; +STRUCT!{#[debug] struct BITMAPCOREINFO { + bmciHeader: BITMAPCOREHEADER, + bmciColors: [RGBTRIPLE; 1], +}} +pub type LPBITMAPCOREINFO = *mut BITMAPCOREINFO; +pub type PBITMAPCOREINFO = *mut BITMAPCOREINFO; +STRUCT!{#[debug] #[repr(packed)] struct BITMAPFILEHEADER { + bfType: WORD, + bfSize: DWORD, + bfReserved1: WORD, + bfReserved2: WORD, + bfOffBits: DWORD, +}} +pub type LPBITMAPFILEHEADER = *mut BITMAPFILEHEADER; +pub type PBITMAPFILEHEADER = *mut BITMAPFILEHEADER; +#[inline] +pub fn MAKEPOINTS(l: DWORD) -> POINTS { + unsafe { ::core::mem::transmute::<DWORD, POINTS>(l) } +} +STRUCT!{#[debug] struct FONTSIGNATURE { + fsUsb: [DWORD; 4], + fsCsb: [DWORD; 2], +}} +pub type LPFONTSIGNATURE = *mut FONTSIGNATURE; +pub type PFONTSIGNATURE = *mut FONTSIGNATURE; +STRUCT!{#[debug] struct CHARSETINFO { + ciCharset: UINT, + ciACP: UINT, + fs: FONTSIGNATURE, +}} +pub type PCHARSETINFO = *mut CHARSETINFO; +pub type NPCHARSETINFO = *mut CHARSETINFO; +pub type LPCHARSETINFO = *mut CHARSETINFO; +pub const TCI_SRCCHARSET: c_int = 1; +pub const TCI_SRCCODEPAGE: c_int = 2; +pub const TCI_SRCFONTSIG: c_int = 3; +pub const TCI_SRCLOCALE: c_int = 0x1000; +STRUCT!{#[debug] struct LOCALESIGNATURE { + lsUsb: [DWORD; 4], + lsCsbDefault: [DWORD; 2], + lsCsbSupported: [DWORD; 2], +}} +pub type PLOCALESIGNATURE = *mut LOCALESIGNATURE; +pub type LPLOCALESIGNATURE = *mut LOCALESIGNATURE; +STRUCT!{struct HANDLETABLE { + objectHandle: [HGDIOBJ; 1], +}} +pub type LPHANDLETABLE = *mut HANDLETABLE; +pub type PHANDLETABLE = *mut HANDLETABLE; +STRUCT!{struct METARECORD { + rdSize: DWORD, + rdFunction: WORD, + rdParm: [WORD; 1], +}} +pub type PMETARECORD = *mut METARECORD; +pub type LPMETARECORD = *mut METARECORD; +STRUCT!{struct METAFILEPICT { + mm: LONG, + xExt: LONG, + yExt: LONG, + hMF: HMETAFILE, +}} +pub type LPMETAFILEPICT = *mut METAFILEPICT; +STRUCT!{struct METAHEADER { + mtType: WORD, + mtHeaderSize: WORD, + mtVersion: WORD, + mtSize: DWORD, + mtNoObjects: WORD, + mtMaxRecord: DWORD, + mtNoParameters: WORD, +}} +pub type PMETAHEADER = *mut METAHEADER; +pub type LPMETAHEADER = *mut METAHEADER; +STRUCT!{struct ENHMETARECORD { + iType: DWORD, + nSize: DWORD, + dParm: [DWORD; 1], +}} +pub type PENHMETARECORD = *mut ENHMETARECORD; +pub type LPENHMETARECORD = *mut ENHMETARECORD; +STRUCT!{struct ENHMETAHEADER { + iType: DWORD, + nSize: DWORD, + rclBounds: RECTL, + rclFrame: RECTL, + dSignature: DWORD, + nVersion: DWORD, + nBytes: DWORD, + nRecords: DWORD, + nHandles: WORD, + sReserved: WORD, + nDescription: DWORD, + offDescription: DWORD, + nPalEntries: DWORD, + szlDevice: SIZEL, + szlMillimeters: SIZEL, + cbPixelFormat: DWORD, + offPixelFormat: DWORD, + bOpenGL: DWORD, + szlMicrometers: SIZEL, +}} +pub type PENHMETAHEADER = *mut ENHMETAHEADER; +pub type LPENHMETAHEADER = *mut ENHMETAHEADER; +pub const TMPF_FIXED_PITCH: BYTE = 0x01; +pub const TMPF_VECTOR: BYTE = 0x02; +pub const TMPF_DEVICE: BYTE = 0x08; +pub const TMPF_TRUETYPE: BYTE = 0x04; +// BCHAR +STRUCT!{struct TEXTMETRICA { + tmHeight: LONG, + tmAscent: LONG, + tmDescent: LONG, + tmInternalLeading: LONG, + tmExternalLeading: LONG, + tmAveCharWidth: LONG, + tmMaxCharWidth: LONG, + tmWeight: LONG, + tmOverhang: LONG, + tmDigitizedAspectX: LONG, + tmDigitizedAspectY: LONG, + tmFirstChar: BYTE, + tmLastChar: BYTE, + tmDefaultChar: BYTE, + tmBreakChar: BYTE, + tmItalic: BYTE, + tmUnderlined: BYTE, + tmStruckOut: BYTE, + tmPitchAndFamily: BYTE, + tmCharSet: BYTE, +}} +pub type PTEXTMETRICA = *mut TEXTMETRICA; +pub type NPTEXTMETRICA = *mut TEXTMETRICA; +pub type LPTEXTMETRICA = *mut TEXTMETRICA; +STRUCT!{struct TEXTMETRICW { + tmHeight: LONG, + tmAscent: LONG, + tmDescent: LONG, + tmInternalLeading: LONG, + tmExternalLeading: LONG, + tmAveCharWidth: LONG, + tmMaxCharWidth: LONG, + tmWeight: LONG, + tmOverhang: LONG, + tmDigitizedAspectX: LONG, + tmDigitizedAspectY: LONG, + tmFirstChar: WCHAR, + tmLastChar: WCHAR, + tmDefaultChar: WCHAR, + tmBreakChar: WCHAR, + tmItalic: BYTE, + tmUnderlined: BYTE, + tmStruckOut: BYTE, + tmPitchAndFamily: BYTE, + tmCharSet: BYTE, +}} +pub type PTEXTMETRICW = *mut TEXTMETRICW; +pub type NPTEXTMETRICW = *mut TEXTMETRICW; +pub type LPTEXTMETRICW = *mut TEXTMETRICW; +pub const NTM_REGULAR: DWORD = 0x00000040; +pub const NTM_BOLD: DWORD = 0x00000020; +pub const NTM_ITALIC: DWORD = 0x00000001; +pub const NTM_NONNEGATIVE_AC: DWORD = 0x00010000; +pub const NTM_PS_OPENTYPE: DWORD = 0x00020000; +pub const NTM_TT_OPENTYPE: DWORD = 0x00040000; +pub const NTM_MULTIPLEMASTER: DWORD = 0x00080000; +pub const NTM_TYPE1: DWORD = 0x00100000; +pub const NTM_DSIG: DWORD = 0x00200000; +STRUCT!{struct NEWTEXTMETRICA { + tmHeight: LONG, + tmAscent: LONG, + tmDescent: LONG, + tmInternalLeading: LONG, + tmExternalLeading: LONG, + tmAveCharWidth: LONG, + tmMaxCharWidth: LONG, + tmWeight: LONG, + tmOverhang: LONG, + tmDigitizedAspectX: LONG, + tmDigitizedAspectY: LONG, + tmFirstChar: BYTE, + tmLastChar: BYTE, + tmDefaultChar: BYTE, + tmBreakChar: BYTE, + tmItalic: BYTE, + tmUnderlined: BYTE, + tmStruckOut: BYTE, + tmPitchAndFamily: BYTE, + tmCharSet: BYTE, + ntmFlags: DWORD, + ntmSizeEM: UINT, + ntmCellHeight: UINT, + ntmAvgWidth: UINT, +}} +pub type PNEWTEXTMETRICA = *mut NEWTEXTMETRICA; +pub type NPNEWTEXTMETRICA = *mut NEWTEXTMETRICA; +pub type LPNEWTEXTMETRICA = *mut NEWTEXTMETRICA; +STRUCT!{struct NEWTEXTMETRICW { + tmHeight: LONG, + tmAscent: LONG, + tmDescent: LONG, + tmInternalLeading: LONG, + tmExternalLeading: LONG, + tmAveCharWidth: LONG, + tmMaxCharWidth: LONG, + tmWeight: LONG, + tmOverhang: LONG, + tmDigitizedAspectX: LONG, + tmDigitizedAspectY: LONG, + tmFirstChar: WCHAR, + tmLastChar: WCHAR, + tmDefaultChar: WCHAR, + tmBreakChar: WCHAR, + tmItalic: BYTE, + tmUnderlined: BYTE, + tmStruckOut: BYTE, + tmPitchAndFamily: BYTE, + tmCharSet: BYTE, + ntmFlags: DWORD, + ntmSizeEM: UINT, + ntmCellHeight: UINT, + ntmAvgWidth: UINT, +}} +pub type PNEWTEXTMETRICW = *mut NEWTEXTMETRICW; +pub type NPNEWTEXTMETRICW = *mut NEWTEXTMETRICW; +pub type LPNEWTEXTMETRICW = *mut NEWTEXTMETRICW; +STRUCT!{struct NEWTEXTMETRICEXA { + ntmTm: NEWTEXTMETRICA, + ntmFontSig: FONTSIGNATURE, +}} +STRUCT!{struct NEWTEXTMETRICEXW { + ntmTm: NEWTEXTMETRICW, + ntmFontSig: FONTSIGNATURE, +}} +STRUCT!{struct PELARRAY { + paXCount: LONG, + paYCount: LONG, + paXExt: LONG, + paYExt: LONG, + paRGBs: BYTE, +}} +pub type PPELARRAY = *mut PELARRAY; +pub type NPPELARRAY = *mut PELARRAY; +pub type LPPELARRAY = *mut PELARRAY; +STRUCT!{struct LOGBRUSH { + lbStyle: UINT, + lbColor: COLORREF, + lbHatch: ULONG_PTR, +}} +pub type PLOGBRUSH = *mut LOGBRUSH; +pub type NPLOGBRUSH = *mut LOGBRUSH; +pub type LPLOGBRUSH = *mut LOGBRUSH; +STRUCT!{struct LOGBRUSH32 { + lbStyle: UINT, + lbColor: COLORREF, + lbHatch: ULONG, +}} +pub type PLOGBRUSH32 = *mut LOGBRUSH32; +pub type NPLOGBRUSH32 = *mut LOGBRUSH32; +pub type LPLOGBRUSH32 = *mut LOGBRUSH32; +pub type PATTERN = LOGBRUSH; +pub type PPATTERN = *mut PATTERN; +pub type NPPATTERN = *mut PATTERN; +pub type LPPATTERN = *mut PATTERN; +STRUCT!{struct LOGPEN { + lopnStyle: UINT, + lopnWidth: POINT, + lopnColor: COLORREF, +}} +pub type PLOGPEN = *mut LOGPEN; +pub type NPLOGPEN = *mut LOGPEN; +pub type LPLOGPEN = *mut LOGPEN; +STRUCT!{struct EXTLOGPEN { + elpPenStyle: DWORD, + elpWidth: DWORD, + elpBrushStyle: UINT, + elpColor: COLORREF, + elpHatch: ULONG_PTR, + elpNumEntries: DWORD, + elpStyleEntry: [DWORD; 1], +}} +pub type PEXTLOGPEN = *mut EXTLOGPEN; +pub type NPEXTLOGPEN = *mut EXTLOGPEN; +pub type LPEXTLOGPEN = *mut EXTLOGPEN; +STRUCT!{struct EXTLOGPEN32 { + elpPenStyle: DWORD, + elpWidth: DWORD, + elpBrushStyle: UINT, + elpColor: COLORREF, + elpHatch: ULONG, + elpNumEntries: DWORD, + elpStyleEntry: [DWORD; 1], +}} +pub type PEXTLOGPEN32 = *mut EXTLOGPEN32; +pub type NPEXTLOGPEN32 = *mut EXTLOGPEN32; +pub type LPEXTLOGPEN32 = *mut EXTLOGPEN32; +STRUCT!{struct PALETTEENTRY { + peRed: BYTE, + peGreen: BYTE, + peBlue: BYTE, + peFlags: BYTE, +}} +pub type PPALETTEENTRY = *mut PALETTEENTRY; +pub type LPPALETTEENTRY = *mut PALETTEENTRY; +STRUCT!{struct LOGPALETTE { + palVersion: WORD, + palNumEntries: WORD, + palPalEntry: [PALETTEENTRY; 1], +}} +pub type PLOGPALETTE = *mut LOGPALETTE; +pub type NPLOGPALETTE = *mut LOGPALETTE; +pub type LPLOGPALETTE = *mut LOGPALETTE; +pub const LF_FACESIZE: usize = 32; +STRUCT!{struct LOGFONTA { + lfHeight: LONG, + lfWidth: LONG, + lfEscapement: LONG, + lfOrientation: LONG, + lfWeight: LONG, + lfItalic: BYTE, + lfUnderline: BYTE, + lfStrikeOut: BYTE, + lfCharSet: BYTE, + lfOutPrecision: BYTE, + lfClipPrecision: BYTE, + lfQuality: BYTE, + lfPitchAndFamily: BYTE, + lfFaceName: [CHAR; LF_FACESIZE], +}} +pub type PLOGFONTA = *mut LOGFONTA; +pub type NPLOGFONTA = *mut LOGFONTA; +pub type LPLOGFONTA = *mut LOGFONTA; +STRUCT!{struct LOGFONTW { + lfHeight: LONG, + lfWidth: LONG, + lfEscapement: LONG, + lfOrientation: LONG, + lfWeight: LONG, + lfItalic: BYTE, + lfUnderline: BYTE, + lfStrikeOut: BYTE, + lfCharSet: BYTE, + lfOutPrecision: BYTE, + lfClipPrecision: BYTE, + lfQuality: BYTE, + lfPitchAndFamily: BYTE, + lfFaceName: [WCHAR; LF_FACESIZE], +}} +pub type PLOGFONTW = *mut LOGFONTW; +pub type NPLOGFONTW = *mut LOGFONTW; +pub type LPLOGFONTW = *mut LOGFONTW; +pub const LF_FULLFACESIZE: usize = 64; +STRUCT!{struct ENUMLOGFONTA { + elfLogFont: LOGFONTA, + elfFullName: [BYTE; LF_FULLFACESIZE], + elfStyle: [BYTE; LF_FACESIZE], +}} +pub type LPENUMLOGFONTA = *mut ENUMLOGFONTA; +STRUCT!{struct ENUMLOGFONTW { + elfLogFont: LOGFONTW, + elfFullName: [WCHAR; LF_FULLFACESIZE], + elfStyle: [WCHAR; LF_FACESIZE], +}} +pub type LPENUMLOGFONTW = *mut ENUMLOGFONTW; +STRUCT!{struct ENUMLOGFONTEXA { + elfLogFont: LOGFONTA, + elfFullName: [BYTE; LF_FULLFACESIZE], + elfStyle: [BYTE; LF_FACESIZE], + elfScript: [BYTE; LF_FACESIZE], +}} +pub type LPENUMLOGFONTEXA = *mut ENUMLOGFONTEXA; +STRUCT!{struct ENUMLOGFONTEXW { + elfLogFont: LOGFONTW, + elfFullName: [WCHAR; LF_FULLFACESIZE], + elfStyle: [WCHAR; LF_FACESIZE], + elfScript: [WCHAR; LF_FACESIZE], +}} +pub type LPENUMLOGFONTEXW = *mut ENUMLOGFONTEXW; +pub const OUT_DEFAULT_PRECIS: DWORD = 0; +pub const OUT_STRING_PRECIS: DWORD = 1; +pub const OUT_CHARACTER_PRECIS: DWORD = 2; +pub const OUT_STROKE_PRECIS: DWORD = 3; +pub const OUT_TT_PRECIS: DWORD = 4; +pub const OUT_DEVICE_PRECIS: DWORD = 5; +pub const OUT_RASTER_PRECIS: DWORD = 6; +pub const OUT_TT_ONLY_PRECIS: DWORD = 7; +pub const OUT_OUTLINE_PRECIS: DWORD = 8; +pub const OUT_SCREEN_OUTLINE_PRECIS: DWORD = 9; +pub const OUT_PS_ONLY_PRECIS: DWORD = 10; +pub const CLIP_DEFAULT_PRECIS: DWORD = 0; +pub const CLIP_CHARACTER_PRECIS: DWORD = 1; +pub const CLIP_STROKE_PRECIS: DWORD = 2; +pub const CLIP_MASK: DWORD = 0xf; +pub const CLIP_LH_ANGLES: DWORD = 1 << 4; +pub const CLIP_TT_ALWAYS: DWORD = 2 << 4; +pub const CLIP_DFA_DISABLE: DWORD = 4 << 4; +pub const CLIP_EMBEDDED: DWORD = 8 << 4; +pub const DEFAULT_QUALITY: DWORD = 0; +pub const DRAFT_QUALITY: DWORD = 1; +pub const PROOF_QUALITY: DWORD = 2; +pub const NONANTIALIASED_QUALITY: DWORD = 3; +pub const ANTIALIASED_QUALITY: DWORD = 4; +pub const CLEARTYPE_QUALITY: DWORD = 5; +pub const CLEARTYPE_NATURAL_QUALITY: DWORD = 6; +pub const DEFAULT_PITCH: DWORD = 0; +pub const FIXED_PITCH: DWORD = 1; +pub const VARIABLE_PITCH: DWORD = 2; +pub const MONO_FONT: DWORD = 8; +pub const ANSI_CHARSET: DWORD = 0; +pub const DEFAULT_CHARSET: DWORD = 1; +pub const SYMBOL_CHARSET: DWORD = 2; +pub const SHIFTJIS_CHARSET: DWORD = 128; +pub const HANGEUL_CHARSET: DWORD = 129; +pub const HANGUL_CHARSET: DWORD = 129; +pub const GB2312_CHARSET: DWORD = 134; +pub const CHINESEBIG5_CHARSET: DWORD = 136; +pub const OEM_CHARSET: DWORD = 255; +pub const JOHAB_CHARSET: DWORD = 130; +pub const HEBREW_CHARSET: DWORD = 177; +pub const ARABIC_CHARSET: DWORD = 178; +pub const GREEK_CHARSET: DWORD = 161; +pub const TURKISH_CHARSET: DWORD = 162; +pub const VIETNAMESE_CHARSET: DWORD = 163; +pub const THAI_CHARSET: DWORD = 222; +pub const EASTEUROPE_CHARSET: DWORD = 238; +pub const RUSSIAN_CHARSET: DWORD = 204; +pub const MAC_CHARSET: DWORD = 77; +pub const BALTIC_CHARSET: DWORD = 186; +pub const FS_LATIN1: DWORD = 0x00000001; +pub const FS_LATIN2: DWORD = 0x00000002; +pub const FS_CYRILLIC: DWORD = 0x00000004; +pub const FS_GREEK: DWORD = 0x00000008; +pub const FS_TURKISH: DWORD = 0x00000010; +pub const FS_HEBREW: DWORD = 0x00000020; +pub const FS_ARABIC: DWORD = 0x00000040; +pub const FS_BALTIC: DWORD = 0x00000080; +pub const FS_VIETNAMESE: DWORD = 0x00000100; +pub const FS_THAI: DWORD = 0x00010000; +pub const FS_JISJAPAN: DWORD = 0x00020000; +pub const FS_CHINESESIMP: DWORD = 0x00040000; +pub const FS_WANSUNG: DWORD = 0x00080000; +pub const FS_CHINESETRAD: DWORD = 0x00100000; +pub const FS_JOHAB: DWORD = 0x00200000; +pub const FS_SYMBOL: DWORD = 0x80000000; +pub const FF_DONTCARE: DWORD = 0 << 4; +pub const FF_ROMAN: DWORD = 1 << 4; +pub const FF_SWISS: DWORD = 2 << 4; +pub const FF_MODERN: DWORD = 3 << 4; +pub const FF_SCRIPT: DWORD = 4 << 4; +pub const FF_DECORATIVE: DWORD = 5 << 4; +pub const FW_DONTCARE: c_int = 0; +pub const FW_THIN: c_int = 100; +pub const FW_EXTRALIGHT: c_int = 200; +pub const FW_LIGHT: c_int = 300; +pub const FW_NORMAL: c_int = 400; +pub const FW_MEDIUM: c_int = 500; +pub const FW_SEMIBOLD: c_int = 600; +pub const FW_BOLD: c_int = 700; +pub const FW_EXTRABOLD: c_int = 800; +pub const FW_HEAVY: c_int = 900; +pub const FW_ULTRALIGHT: c_int = FW_EXTRALIGHT; +pub const FW_REGULAR: c_int = FW_NORMAL; +pub const FW_DEMIBOLD: c_int = FW_SEMIBOLD; +pub const FW_ULTRABOLD: c_int = FW_EXTRABOLD; +pub const FW_BLACK: c_int = FW_HEAVY; +pub const PANOSE_COUNT: DWORD = 10; +pub const PAN_FAMILYTYPE_INDEX: DWORD = 0; +pub const PAN_SERIFSTYLE_INDEX: DWORD = 1; +pub const PAN_WEIGHT_INDEX: DWORD = 2; +pub const PAN_PROPORTION_INDEX: DWORD = 3; +pub const PAN_CONTRAST_INDEX: DWORD = 4; +pub const PAN_STROKEVARIATION_INDEX: DWORD = 5; +pub const PAN_ARMSTYLE_INDEX: DWORD = 6; +pub const PAN_LETTERFORM_INDEX: DWORD = 7; +pub const PAN_MIDLINE_INDEX: DWORD = 8; +pub const PAN_XHEIGHT_INDEX: DWORD = 9; +pub const PAN_CULTURE_LATIN: DWORD = 0; +STRUCT!{struct PANOSE { + bFamilyType: BYTE, + bSerifStyle: BYTE, + bWeight: BYTE, + bProportion: BYTE, + bContrast: BYTE, + bStrokeVariation: BYTE, + bArmStyle: BYTE, + bLetterform: BYTE, + bMidline: BYTE, + bXHeight: BYTE, +}} +pub type LPPANOSE = *mut PANOSE; +pub const PAN_ANY: BYTE = 0; +pub const PAN_NO_FIT: BYTE = 1; +pub const PAN_FAMILY_TEXT_DISPLAY: BYTE = 2; +pub const PAN_FAMILY_SCRIPT: BYTE = 3; +pub const PAN_FAMILY_DECORATIVE: BYTE = 4; +pub const PAN_FAMILY_PICTORIAL: BYTE = 5; +pub const PAN_SERIF_COVE: BYTE = 2; +pub const PAN_SERIF_OBTUSE_COVE: BYTE = 3; +pub const PAN_SERIF_SQUARE_COVE: BYTE = 4; +pub const PAN_SERIF_OBTUSE_SQUARE_COVE: BYTE = 5; +pub const PAN_SERIF_SQUARE: BYTE = 6; +pub const PAN_SERIF_THIN: BYTE = 7; +pub const PAN_SERIF_BONE: BYTE = 8; +pub const PAN_SERIF_EXAGGERATED: BYTE = 9; +pub const PAN_SERIF_TRIANGLE: BYTE = 10; +pub const PAN_SERIF_NORMAL_SANS: BYTE = 11; +pub const PAN_SERIF_OBTUSE_SANS: BYTE = 12; +pub const PAN_SERIF_PERP_SANS: BYTE = 13; +pub const PAN_SERIF_FLARED: BYTE = 14; +pub const PAN_SERIF_ROUNDED: BYTE = 15; +pub const PAN_WEIGHT_VERY_LIGHT: BYTE = 2; +pub const PAN_WEIGHT_LIGHT: BYTE = 3; +pub const PAN_WEIGHT_THIN: BYTE = 4; +pub const PAN_WEIGHT_BOOK: BYTE = 5; +pub const PAN_WEIGHT_MEDIUM: BYTE = 6; +pub const PAN_WEIGHT_DEMI: BYTE = 7; +pub const PAN_WEIGHT_BOLD: BYTE = 8; +pub const PAN_WEIGHT_HEAVY: BYTE = 9; +pub const PAN_WEIGHT_BLACK: BYTE = 10; +pub const PAN_WEIGHT_NORD: BYTE = 11; +pub const PAN_PROP_OLD_STYLE: BYTE = 2; +pub const PAN_PROP_MODERN: BYTE = 3; +pub const PAN_PROP_EVEN_WIDTH: BYTE = 4; +pub const PAN_PROP_EXPANDED: BYTE = 5; +pub const PAN_PROP_CONDENSED: BYTE = 6; +pub const PAN_PROP_VERY_EXPANDED: BYTE = 7; +pub const PAN_PROP_VERY_CONDENSED: BYTE = 8; +pub const PAN_PROP_MONOSPACED: BYTE = 9; +pub const PAN_CONTRAST_NONE: BYTE = 2; +pub const PAN_CONTRAST_VERY_LOW: BYTE = 3; +pub const PAN_CONTRAST_LOW: BYTE = 4; +pub const PAN_CONTRAST_MEDIUM_LOW: BYTE = 5; +pub const PAN_CONTRAST_MEDIUM: BYTE = 6; +pub const PAN_CONTRAST_MEDIUM_HIGH: BYTE = 7; +pub const PAN_CONTRAST_HIGH: BYTE = 8; +pub const PAN_CONTRAST_VERY_HIGH: BYTE = 9; +pub const PAN_STROKE_GRADUAL_DIAG: BYTE = 2; +pub const PAN_STROKE_GRADUAL_TRAN: BYTE = 3; +pub const PAN_STROKE_GRADUAL_VERT: BYTE = 4; +pub const PAN_STROKE_GRADUAL_HORZ: BYTE = 5; +pub const PAN_STROKE_RAPID_VERT: BYTE = 6; +pub const PAN_STROKE_RAPID_HORZ: BYTE = 7; +pub const PAN_STROKE_INSTANT_VERT: BYTE = 8; +pub const PAN_STRAIGHT_ARMS_HORZ: BYTE = 2; +pub const PAN_STRAIGHT_ARMS_WEDGE: BYTE = 3; +pub const PAN_STRAIGHT_ARMS_VERT: BYTE = 4; +pub const PAN_STRAIGHT_ARMS_SINGLE_SERIF: BYTE = 5; +pub const PAN_STRAIGHT_ARMS_DOUBLE_SERIF: BYTE = 6; +pub const PAN_BENT_ARMS_HORZ: BYTE = 7; +pub const PAN_BENT_ARMS_WEDGE: BYTE = 8; +pub const PAN_BENT_ARMS_VERT: BYTE = 9; +pub const PAN_BENT_ARMS_SINGLE_SERIF: BYTE = 10; +pub const PAN_BENT_ARMS_DOUBLE_SERIF: BYTE = 11; +pub const PAN_LETT_NORMAL_CONTACT: BYTE = 2; +pub const PAN_LETT_NORMAL_WEIGHTED: BYTE = 3; +pub const PAN_LETT_NORMAL_BOXED: BYTE = 4; +pub const PAN_LETT_NORMAL_FLATTENED: BYTE = 5; +pub const PAN_LETT_NORMAL_ROUNDED: BYTE = 6; +pub const PAN_LETT_NORMAL_OFF_CENTER: BYTE = 7; +pub const PAN_LETT_NORMAL_SQUARE: BYTE = 8; +pub const PAN_LETT_OBLIQUE_CONTACT: BYTE = 9; +pub const PAN_LETT_OBLIQUE_WEIGHTED: BYTE = 10; +pub const PAN_LETT_OBLIQUE_BOXED: BYTE = 11; +pub const PAN_LETT_OBLIQUE_FLATTENED: BYTE = 12; +pub const PAN_LETT_OBLIQUE_ROUNDED: BYTE = 13; +pub const PAN_LETT_OBLIQUE_OFF_CENTER: BYTE = 14; +pub const PAN_LETT_OBLIQUE_SQUARE: BYTE = 15; +pub const PAN_MIDLINE_STANDARD_TRIMMED: BYTE = 2; +pub const PAN_MIDLINE_STANDARD_POINTED: BYTE = 3; +pub const PAN_MIDLINE_STANDARD_SERIFED: BYTE = 4; +pub const PAN_MIDLINE_HIGH_TRIMMED: BYTE = 5; +pub const PAN_MIDLINE_HIGH_POINTED: BYTE = 6; +pub const PAN_MIDLINE_HIGH_SERIFED: BYTE = 7; +pub const PAN_MIDLINE_CONSTANT_TRIMMED: BYTE = 8; +pub const PAN_MIDLINE_CONSTANT_POINTED: BYTE = 9; +pub const PAN_MIDLINE_CONSTANT_SERIFED: BYTE = 10; +pub const PAN_MIDLINE_LOW_TRIMMED: BYTE = 11; +pub const PAN_MIDLINE_LOW_POINTED: BYTE = 12; +pub const PAN_MIDLINE_LOW_SERIFED: BYTE = 13; +pub const PAN_XHEIGHT_CONSTANT_SMALL: BYTE = 2; +pub const PAN_XHEIGHT_CONSTANT_STD: BYTE = 3; +pub const PAN_XHEIGHT_CONSTANT_LARGE: BYTE = 4; +pub const PAN_XHEIGHT_DUCKING_SMALL: BYTE = 5; +pub const PAN_XHEIGHT_DUCKING_STD: BYTE = 6; +pub const PAN_XHEIGHT_DUCKING_LARGE: BYTE = 7; +pub const ELF_VENDOR_SIZE: usize = 4; +STRUCT!{struct EXTLOGFONTA { + elfLogFont: LOGFONTA, + elfFullName: [BYTE; LF_FULLFACESIZE], + elfStyle: [BYTE; LF_FACESIZE], + elfVersion: DWORD, + elfStyleSize: DWORD, + elfMatch: DWORD, + elfReserved: DWORD, + elfVendorId: [BYTE; ELF_VENDOR_SIZE], + elfCulture: DWORD, + elfPanose: PANOSE, +}} +pub type PEXTLOGFONTA = *mut EXTLOGFONTA; +pub type NPEXTLOGFONTA = *mut EXTLOGFONTA; +pub type LPEXTLOGFONTA = *mut EXTLOGFONTA; +STRUCT!{struct EXTLOGFONTW { + elfLogFont: LOGFONTW, + elfFullNam: [WCHAR; LF_FULLFACESIZE], + elfStyle: [WCHAR; LF_FACESIZE], + elfVersion: DWORD, + elfStyleSize: DWORD, + elfMatch: DWORD, + elfReserved: DWORD, + elfVendorId: [BYTE; ELF_VENDOR_SIZE], + elfCulture: DWORD, + elfPanose: PANOSE, +}} +pub type PEXTLOGFONTW = *mut EXTLOGFONTW; +pub type NPEXTLOGFONTW = *mut EXTLOGFONTW; +pub type LPEXTLOGFONTW = *mut EXTLOGFONTW; +pub const ELF_VERSION: DWORD = 0; +pub const ELF_CULTURE_LATIN: DWORD = 0; +pub const RASTER_FONTTYPE: DWORD = 0x0001; +pub const DEVICE_FONTTYPE: DWORD = 0x0002; +pub const TRUETYPE_FONTTYPE: DWORD = 0x0004; +#[inline] +pub fn RGB(r: BYTE, g: BYTE, b: BYTE) -> COLORREF { + r as COLORREF | ((g as COLORREF) << 8) | ((b as COLORREF) << 16) +} +#[inline] +pub fn PALETTERGB(r: BYTE, g: BYTE, b: BYTE) -> COLORREF { + 0x02000000 | RGB(r, g, b) +} +#[inline] +pub fn PALETTEINDEX(i: WORD) -> COLORREF { + 0x01000000 | i as DWORD +} +pub const PC_RESERVED: DWORD = 0x01; +pub const PC_EXPLICIT: DWORD = 0x02; +pub const PC_NOCOLLAPSE: DWORD = 0x04; +#[inline] +pub fn GetRValue(rgb: COLORREF) -> BYTE { + LOBYTE(rgb as WORD) +} +#[inline] +pub fn GetGValue(rgb: COLORREF) -> BYTE { + LOBYTE((rgb as WORD) >> 8) +} +#[inline] +pub fn GetBValue(rgb: COLORREF) -> BYTE { + LOBYTE((rgb >> 16) as WORD) +} +pub const TRANSPARENT: DWORD = 1; +pub const OPAQUE: DWORD = 2; +pub const BKMODE_LAST: DWORD = 2; +pub const GM_COMPATIBLE: DWORD = 1; +pub const GM_ADVANCED: DWORD = 2; +pub const GM_LAST: DWORD = 2; +pub const PT_CLOSEFIGURE: DWORD = 0x01; +pub const PT_LINETO: DWORD = 0x02; +pub const PT_BEZIERTO: DWORD = 0x04; +pub const PT_MOVETO: DWORD = 0x06; +pub const MM_TEXT: DWORD = 1; +pub const MM_LOMETRIC: DWORD = 2; +pub const MM_HIMETRIC: DWORD = 3; +pub const MM_LOENGLISH: DWORD = 4; +pub const MM_HIENGLISH: DWORD = 5; +pub const MM_TWIPS: DWORD = 6; +pub const MM_ISOTROPIC: DWORD = 7; +pub const MM_ANISOTROPIC: DWORD = 8; +pub const MM_MIN: DWORD = MM_TEXT; +pub const MM_MAX: DWORD = MM_ANISOTROPIC; +pub const MM_MAX_FIXEDSCALE: DWORD = MM_TWIPS; +pub const ABSOLUTE: DWORD = 1; +pub const RELATIVE: DWORD = 2; +pub const WHITE_BRUSH: DWORD = 0; +pub const LTGRAY_BRUSH: DWORD = 1; +pub const GRAY_BRUSH: DWORD = 2; +pub const DKGRAY_BRUSH: DWORD = 3; +pub const BLACK_BRUSH: DWORD = 4; +pub const NULL_BRUSH: DWORD = 5; +pub const HOLLOW_BRUSH: DWORD = NULL_BRUSH; +pub const WHITE_PEN: DWORD = 6; +pub const BLACK_PEN: DWORD = 7; +pub const NULL_PEN: DWORD = 8; +pub const OEM_FIXED_FONT: DWORD = 10; +pub const ANSI_FIXED_FONT: DWORD = 11; +pub const ANSI_VAR_FONT: DWORD = 12; +pub const SYSTEM_FONT: DWORD = 13; +pub const DEVICE_DEFAULT_FONT: DWORD = 14; +pub const DEFAULT_PALETTE: DWORD = 15; +pub const SYSTEM_FIXED_FONT: DWORD = 16; +pub const DEFAULT_GUI_FONT: DWORD = 17; +pub const DC_BRUSH: DWORD = 18; +pub const DC_PEN: DWORD = 19; +pub const STOCK_LAST: DWORD = 19; +pub const CLR_INVALID: COLORREF = 0xFFFFFFFF; +pub const BS_SOLID: DWORD = 0; +pub const BS_NULL: DWORD = 1; +pub const BS_HOLLOW: DWORD = BS_NULL; +pub const BS_HATCHED: DWORD = 2; +pub const BS_PATTERN: DWORD = 3; +pub const BS_INDEXED: DWORD = 4; +pub const BS_DIBPATTERN: DWORD = 5; +pub const BS_DIBPATTERNPT: DWORD = 6; +pub const BS_PATTERN8X8: DWORD = 7; +pub const BS_DIBPATTERN8X8: DWORD = 8; +pub const BS_MONOPATTERN: DWORD = 9; +pub const HS_HORIZONTAL: DWORD = 0; +pub const HS_VERTICAL: DWORD = 1; +pub const HS_FDIAGONAL: DWORD = 2; +pub const HS_BDIAGONAL: DWORD = 3; +pub const HS_CROSS: DWORD = 4; +pub const HS_DIAGCROSS: DWORD = 5; +pub const HS_API_MAX: DWORD = 12; +pub const PS_SOLID: DWORD = 0; +pub const PS_DASH: DWORD = 1; +pub const PS_DOT: DWORD = 2; +pub const PS_DASHDOT: DWORD = 3; +pub const PS_DASHDOTDOT: DWORD = 4; +pub const PS_NULL: DWORD = 5; +pub const PS_INSIDEFRAME: DWORD = 6; +pub const PS_USERSTYLE: DWORD = 7; +pub const PS_ALTERNATE: DWORD = 8; +pub const PS_STYLE_MASK: DWORD = 0x0000000F; +pub const PS_ENDCAP_ROUND: DWORD = 0x00000000; +pub const PS_ENDCAP_SQUARE: DWORD = 0x00000100; +pub const PS_ENDCAP_FLAT: DWORD = 0x00000200; +pub const PS_ENDCAP_MASK: DWORD = 0x00000F00; +pub const PS_JOIN_ROUND: DWORD = 0x00000000; +pub const PS_JOIN_BEVEL: DWORD = 0x00001000; +pub const PS_JOIN_MITER: DWORD = 0x00002000; +pub const PS_JOIN_MASK: DWORD = 0x0000F000; +pub const PS_COSMETIC: DWORD = 0x00000000; +pub const PS_GEOMETRIC: DWORD = 0x00010000; +pub const PS_TYPE_MASK: DWORD = 0x000F0000; +pub const AD_COUNTERCLOCKWISE: DWORD = 1; +pub const AD_CLOCKWISE: DWORD = 2; +pub const DRIVERVERSION: c_int = 0; +pub const TECHNOLOGY: c_int = 2; +pub const HORZSIZE: c_int = 4; +pub const VERTSIZE: c_int = 6; +pub const HORZRES: c_int = 8; +pub const VERTRES: c_int = 10; +pub const BITSPIXEL: c_int = 12; +pub const PLANES: c_int = 14; +pub const NUMBRUSHES: c_int = 16; +pub const NUMPENS: c_int = 18; +pub const NUMMARKERS: c_int = 20; +pub const NUMFONTS: c_int = 22; +pub const NUMCOLORS: c_int = 24; +pub const PDEVICESIZE: c_int = 26; +pub const CURVECAPS: c_int = 28; +pub const LINECAPS: c_int = 30; +pub const POLYGONALCAPS: c_int = 32; +pub const TEXTCAPS: c_int = 34; +pub const CLIPCAPS: c_int = 36; +pub const RASTERCAPS: c_int = 38; +pub const ASPECTX: c_int = 40; +pub const ASPECTY: c_int = 42; +pub const ASPECTXY: c_int = 44; +pub const LOGPIXELSX: c_int = 88; +pub const LOGPIXELSY: c_int = 90; +pub const SIZEPALETTE: c_int = 104; +pub const NUMRESERVED: c_int = 106; +pub const COLORRES: c_int = 108; +pub const PHYSICALWIDTH: c_int = 110; +pub const PHYSICALHEIGHT: c_int = 111; +pub const PHYSICALOFFSETX: c_int = 112; +pub const PHYSICALOFFSETY: c_int = 113; +pub const SCALINGFACTORX: c_int = 114; +pub const SCALINGFACTORY: c_int = 115; +pub const VREFRESH: c_int = 116; +pub const DESKTOPVERTRES: c_int = 117; +pub const DESKTOPHORZRES: c_int = 118; +pub const BLTALIGNMENT: c_int = 119; +pub const SHADEBLENDCAPS: c_int = 120; +pub const COLORMGMTCAPS: c_int = 121; +pub const DT_PLOTTER: DWORD = 0; +pub const DT_RASDISPLAY: DWORD = 1; +pub const DT_RASPRINTER: DWORD = 2; +pub const DT_RASCAMERA: DWORD = 3; +pub const DT_CHARSTREAM: DWORD = 4; +pub const DT_METAFILE: DWORD = 5; +pub const DT_DISPFILE: DWORD = 6; +pub const CC_NONE: DWORD = 0; +pub const CC_CIRCLES: DWORD = 1; +pub const CC_PIE: DWORD = 2; +pub const CC_CHORD: DWORD = 4; +pub const CC_ELLIPSES: DWORD = 8; +pub const CC_WIDE: DWORD = 16; +pub const CC_STYLED: DWORD = 32; +pub const CC_WIDESTYLED: DWORD = 64; +pub const CC_INTERIORS: DWORD = 128; +pub const CC_ROUNDRECT: DWORD = 256; +pub const LC_NONE: DWORD = 0; +pub const LC_POLYLINE: DWORD = 2; +pub const LC_MARKER: DWORD = 4; +pub const LC_POLYMARKER: DWORD = 8; +pub const LC_WIDE: DWORD = 16; +pub const LC_STYLED: DWORD = 32; +pub const LC_WIDESTYLED: DWORD = 64; +pub const LC_INTERIORS: DWORD = 128; +pub const PC_NONE: DWORD = 0; +pub const PC_POLYGON: DWORD = 1; +pub const PC_RECTANGLE: DWORD = 2; +pub const PC_WINDPOLYGON: DWORD = 4; +pub const PC_TRAPEZOID: DWORD = 4; +pub const PC_SCANLINE: DWORD = 8; +pub const PC_WIDE: DWORD = 16; +pub const PC_STYLED: DWORD = 32; +pub const PC_WIDESTYLED: DWORD = 64; +pub const PC_INTERIORS: DWORD = 128; +pub const PC_POLYPOLYGON: DWORD = 256; +pub const PC_PATHS: DWORD = 512; +pub const CP_NONE: DWORD = 0; +pub const CP_RECTANGLE: DWORD = 1; +pub const CP_REGION: DWORD = 2; +pub const TC_OP_CHARACTER: DWORD = 0x00000001; +pub const TC_OP_STROKE: DWORD = 0x00000002; +pub const TC_CP_STROKE: DWORD = 0x00000004; +pub const TC_CR_90: DWORD = 0x00000008; +pub const TC_CR_ANY: DWORD = 0x00000010; +pub const TC_SF_X_YINDEP: DWORD = 0x00000020; +pub const TC_SA_DOUBLE: DWORD = 0x00000040; +pub const TC_SA_INTEGER: DWORD = 0x00000080; +pub const TC_SA_CONTIN: DWORD = 0x00000100; +pub const TC_EA_DOUBLE: DWORD = 0x00000200; +pub const TC_IA_ABLE: DWORD = 0x00000400; +pub const TC_UA_ABLE: DWORD = 0x00000800; +pub const TC_SO_ABLE: DWORD = 0x00001000; +pub const TC_RA_ABLE: DWORD = 0x00002000; +pub const TC_VA_ABLE: DWORD = 0x00004000; +pub const TC_RESERVED: DWORD = 0x00008000; +pub const TC_SCROLLBLT: DWORD = 0x00010000; +pub const RC_BITBLT: DWORD = 1; +pub const RC_BANDING: DWORD = 2; +pub const RC_SCALING: DWORD = 4; +pub const RC_BITMAP64: DWORD = 8; +pub const RC_GDI20_OUTPUT: DWORD = 0x0010; +pub const RC_GDI20_STATE: DWORD = 0x0020; +pub const RC_SAVEBITMAP: DWORD = 0x0040; +pub const RC_DI_BITMAP: DWORD = 0x0080; +pub const RC_PALETTE: DWORD = 0x0100; +pub const RC_DIBTODEV: DWORD = 0x0200; +pub const RC_BIGFONT: DWORD = 0x0400; +pub const RC_STRETCHBLT: DWORD = 0x0800; +pub const RC_FLOODFILL: DWORD = 0x1000; +pub const RC_STRETCHDIB: DWORD = 0x2000; +pub const RC_OP_DX_OUTPUT: DWORD = 0x4000; +pub const RC_DEVBITS: DWORD = 0x8000; +pub const SB_NONE: DWORD = 0x00000000; +pub const SB_CONST_ALPHA: DWORD = 0x00000001; +pub const SB_PIXEL_ALPHA: DWORD = 0x00000002; +pub const SB_PREMULT_ALPHA: DWORD = 0x00000004; +pub const SB_GRAD_RECT: DWORD = 0x00000010; +pub const SB_GRAD_TRI: DWORD = 0x00000020; +pub const CM_NONE: DWORD = 0x00000000; +pub const CM_DEVICE_ICM: DWORD = 0x00000001; +pub const CM_GAMMA_RAMP: DWORD = 0x00000002; +pub const CM_CMYK_COLOR: DWORD = 0x00000004; +pub const DIB_RGB_COLORS: DWORD = 0; +pub const DIB_PAL_COLORS: DWORD = 1; +pub const SYSPAL_ERROR: DWORD = 0; +pub const SYSPAL_STATIC: DWORD = 1; +pub const SYSPAL_NOSTATIC: DWORD = 2; +pub const SYSPAL_NOSTATIC256: DWORD = 3; +pub const CBM_INIT: DWORD = 0x04; +pub const FLOODFILLBORDER: DWORD = 0; +pub const FLOODFILLSURFACE: DWORD = 1; +pub const CCHDEVICENAME: usize = 32; +pub const CCHFORMNAME: usize = 32; +STRUCT!{struct DEVMODE_u1_s1 { + dmOrientation: c_short, + dmPaperSize: c_short, + dmPaperLength: c_short, + dmPaperWidth: c_short, + dmScale: c_short, + dmCopies: c_short, + dmDefaultSource: c_short, + dmPrintQuality: c_short, +}} +STRUCT!{struct DEVMODE_u1_s2 { + dmPosition: POINTL, + dmDisplayOrientation: DWORD, + dmDisplayFixedOutput: DWORD, +}} +UNION!{union DEVMODE_u1 { + [u32; 4], + s1 s1_mut: DEVMODE_u1_s1, + s2 s2_mut: DEVMODE_u1_s2, +}} +UNION!{union DEVMODE_u2 { + [u32; 1], + dmDisplayFlags dmDisplayFlags_mut: DWORD, + dmNup dmNup_mut: DWORD, +}} +STRUCT!{struct DEVMODEA { + dmDeviceName: [CHAR; CCHDEVICENAME], + dmSpecVersion: WORD, + dmDriverVersion: WORD, + dmSize: WORD, + dmDriverExtra: WORD, + dmFields: DWORD, + u1: DEVMODE_u1, + dmColor: c_short, + dmDuplex: c_short, + dmYResolution: c_short, + dmTTOption: c_short, + dmCollate: c_short, + dmFormName: [CHAR; CCHFORMNAME], + dmLogPixels: WORD, + dmBitsPerPel: DWORD, + dmPelsWidth: DWORD, + dmPelsHeight: DWORD, + u2: DEVMODE_u2, + dmDisplayFrequency: DWORD, + dmICMMethod: DWORD, + dmICMIntent: DWORD, + dmMediaType: DWORD, + dmDitherType: DWORD, + dmReserved1: DWORD, + dmReserved2: DWORD, + dmPanningWidth: DWORD, + dmPanningHeight: DWORD, +}} +pub type PDEVMODEA = *mut DEVMODEA; +pub type NPDEVMODEA = *mut DEVMODEA; +pub type LPDEVMODEA = *mut DEVMODEA; +STRUCT!{struct DEVMODEW { + dmDeviceName: [WCHAR; CCHDEVICENAME], + dmSpecVersion: WORD, + dmDriverVersion: WORD, + dmSize: WORD, + dmDriverExtra: WORD, + dmFields: DWORD, + u1: DEVMODE_u1, + dmColor: c_short, + dmDuplex: c_short, + dmYResolution: c_short, + dmTTOption: c_short, + dmCollate: c_short, + dmFormName: [WCHAR; CCHFORMNAME], + dmLogPixels: WORD, + dmBitsPerPel: DWORD, + dmPelsWidth: DWORD, + dmPelsHeight: DWORD, + u2: DEVMODE_u2, + dmDisplayFrequency: DWORD, + dmICMMethod: DWORD, + dmICMIntent: DWORD, + dmMediaType: DWORD, + dmDitherType: DWORD, + dmReserved1: DWORD, + dmReserved2: DWORD, + dmPanningWidth: DWORD, + dmPanningHeight: DWORD, +}} +pub type PDEVMODEW = *mut DEVMODEW; +pub type NPDEVMODEW = *mut DEVMODEW; +pub type LPDEVMODEW = *mut DEVMODEW; +pub const DM_SPECVERSION: DWORD = 0x0401; +pub const DM_ORIENTATION: DWORD = 0x00000001; +pub const DM_PAPERSIZE: DWORD = 0x00000002; +pub const DM_PAPERLENGTH: DWORD = 0x00000004; +pub const DM_PAPERWIDTH: DWORD = 0x00000008; +pub const DM_SCALE: DWORD = 0x00000010; +pub const DM_POSITION: DWORD = 0x00000020; +pub const DM_NUP: DWORD = 0x00000040; +pub const DM_DISPLAYORIENTATION: DWORD = 0x00000080; +pub const DM_COPIES: DWORD = 0x00000100; +pub const DM_DEFAULTSOURCE: DWORD = 0x00000200; +pub const DM_PRINTQUALITY: DWORD = 0x00000400; +pub const DM_COLOR: DWORD = 0x00000800; +pub const DM_DUPLEX: DWORD = 0x00001000; +pub const DM_YRESOLUTION: DWORD = 0x00002000; +pub const DM_TTOPTION: DWORD = 0x00004000; +pub const DM_COLLATE: DWORD = 0x00008000; +pub const DM_FORMNAME: DWORD = 0x00010000; +pub const DM_LOGPIXELS: DWORD = 0x00020000; +pub const DM_BITSPERPEL: DWORD = 0x00040000; +pub const DM_PELSWIDTH: DWORD = 0x00080000; +pub const DM_PELSHEIGHT: DWORD = 0x00100000; +pub const DM_DISPLAYFLAGS: DWORD = 0x00200000; +pub const DM_DISPLAYFREQUENCY: DWORD = 0x00400000; +pub const DM_ICMMETHOD: DWORD = 0x00800000; +pub const DM_ICMINTENT: DWORD = 0x01000000; +pub const DM_MEDIATYPE: DWORD = 0x02000000; +pub const DM_DITHERTYPE: DWORD = 0x04000000; +pub const DM_PANNINGWIDTH: DWORD = 0x08000000; +pub const DM_PANNINGHEIGHT: DWORD = 0x10000000; +pub const DM_DISPLAYFIXEDOUTPUT: DWORD = 0x20000000; +pub const DMORIENT_PORTRAIT: DWORD = 1; +pub const DMORIENT_LANDSCAPE: DWORD = 2; +pub const DMPAPER_FIRST: DWORD = DMPAPER_LETTER; +pub const DMPAPER_LETTER: DWORD = 1; +pub const DMPAPER_LETTERSMALL: DWORD = 2; +pub const DMPAPER_TABLOID: DWORD = 3; +pub const DMPAPER_LEDGER: DWORD = 4; +pub const DMPAPER_LEGAL: DWORD = 5; +pub const DMPAPER_STATEMENT: DWORD = 6; +pub const DMPAPER_EXECUTIVE: DWORD = 7; +pub const DMPAPER_A3: DWORD = 8; +pub const DMPAPER_A4: DWORD = 9; +pub const DMPAPER_A4SMALL: DWORD = 10; +pub const DMPAPER_A5: DWORD = 11; +pub const DMPAPER_B4: DWORD = 12; +pub const DMPAPER_B5: DWORD = 13; +pub const DMPAPER_FOLIO: DWORD = 14; +pub const DMPAPER_QUARTO: DWORD = 15; +pub const DMPAPER_10X14: DWORD = 16; +pub const DMPAPER_11X17: DWORD = 17; +pub const DMPAPER_NOTE: DWORD = 18; +pub const DMPAPER_ENV_9: DWORD = 19; +pub const DMPAPER_ENV_10: DWORD = 20; +pub const DMPAPER_ENV_11: DWORD = 21; +pub const DMPAPER_ENV_12: DWORD = 22; +pub const DMPAPER_ENV_14: DWORD = 23; +pub const DMPAPER_CSHEET: DWORD = 24; +pub const DMPAPER_DSHEET: DWORD = 25; +pub const DMPAPER_ESHEET: DWORD = 26; +pub const DMPAPER_ENV_DL: DWORD = 27; +pub const DMPAPER_ENV_C5: DWORD = 28; +pub const DMPAPER_ENV_C3: DWORD = 29; +pub const DMPAPER_ENV_C4: DWORD = 30; +pub const DMPAPER_ENV_C6: DWORD = 31; +pub const DMPAPER_ENV_C65: DWORD = 32; +pub const DMPAPER_ENV_B4: DWORD = 33; +pub const DMPAPER_ENV_B5: DWORD = 34; +pub const DMPAPER_ENV_B6: DWORD = 35; +pub const DMPAPER_ENV_ITALY: DWORD = 36; +pub const DMPAPER_ENV_MONARCH: DWORD = 37; +pub const DMPAPER_ENV_PERSONAL: DWORD = 38; +pub const DMPAPER_FANFOLD_US: DWORD = 39; +pub const DMPAPER_FANFOLD_STD_GERMAN: DWORD = 40; +pub const DMPAPER_FANFOLD_LGL_GERMAN: DWORD = 41; +pub const DMPAPER_ISO_B4: DWORD = 42; +pub const DMPAPER_JAPANESE_POSTCARD: DWORD = 43; +pub const DMPAPER_9X11: DWORD = 44; +pub const DMPAPER_10X11: DWORD = 45; +pub const DMPAPER_15X11: DWORD = 46; +pub const DMPAPER_ENV_INVITE: DWORD = 47; +pub const DMPAPER_RESERVED_48: DWORD = 48; +pub const DMPAPER_RESERVED_49: DWORD = 49; +pub const DMPAPER_LETTER_EXTRA: DWORD = 50; +pub const DMPAPER_LEGAL_EXTRA: DWORD = 51; +pub const DMPAPER_TABLOID_EXTRA: DWORD = 52; +pub const DMPAPER_A4_EXTRA: DWORD = 53; +pub const DMPAPER_LETTER_TRANSVERSE: DWORD = 54; +pub const DMPAPER_A4_TRANSVERSE: DWORD = 55; +pub const DMPAPER_LETTER_EXTRA_TRANSVERSE: DWORD = 56; +pub const DMPAPER_A_PLUS: DWORD = 57; +pub const DMPAPER_B_PLUS: DWORD = 58; +pub const DMPAPER_LETTER_PLUS: DWORD = 59; +pub const DMPAPER_A4_PLUS: DWORD = 60; +pub const DMPAPER_A5_TRANSVERSE: DWORD = 61; +pub const DMPAPER_B5_TRANSVERSE: DWORD = 62; +pub const DMPAPER_A3_EXTRA: DWORD = 63; +pub const DMPAPER_A5_EXTRA: DWORD = 64; +pub const DMPAPER_B5_EXTRA: DWORD = 65; +pub const DMPAPER_A2: DWORD = 66; +pub const DMPAPER_A3_TRANSVERSE: DWORD = 67; +pub const DMPAPER_A3_EXTRA_TRANSVERSE: DWORD = 68; +pub const DMPAPER_DBL_JAPANESE_POSTCARD: DWORD = 69; +pub const DMPAPER_A6: DWORD = 70; +pub const DMPAPER_JENV_KAKU2: DWORD = 71; +pub const DMPAPER_JENV_KAKU3: DWORD = 72; +pub const DMPAPER_JENV_CHOU3: DWORD = 73; +pub const DMPAPER_JENV_CHOU4: DWORD = 74; +pub const DMPAPER_LETTER_ROTATED: DWORD = 75; +pub const DMPAPER_A3_ROTATED: DWORD = 76; +pub const DMPAPER_A4_ROTATED: DWORD = 77; +pub const DMPAPER_A5_ROTATED: DWORD = 78; +pub const DMPAPER_B4_JIS_ROTATED: DWORD = 79; +pub const DMPAPER_B5_JIS_ROTATED: DWORD = 80; +pub const DMPAPER_JAPANESE_POSTCARD_ROTATED: DWORD = 81; +pub const DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED: DWORD = 82; +pub const DMPAPER_A6_ROTATED: DWORD = 83; +pub const DMPAPER_JENV_KAKU2_ROTATED: DWORD = 84; +pub const DMPAPER_JENV_KAKU3_ROTATED: DWORD = 85; +pub const DMPAPER_JENV_CHOU3_ROTATED: DWORD = 86; +pub const DMPAPER_JENV_CHOU4_ROTATED: DWORD = 87; +pub const DMPAPER_B6_JIS: DWORD = 88; +pub const DMPAPER_B6_JIS_ROTATED: DWORD = 89; +pub const DMPAPER_12X11: DWORD = 90; +pub const DMPAPER_JENV_YOU4: DWORD = 91; +pub const DMPAPER_JENV_YOU4_ROTATED: DWORD = 92; +pub const DMPAPER_P16K: DWORD = 93; +pub const DMPAPER_P32K: DWORD = 94; +pub const DMPAPER_P32KBIG: DWORD = 95; +pub const DMPAPER_PENV_1: DWORD = 96; +pub const DMPAPER_PENV_2: DWORD = 97; +pub const DMPAPER_PENV_3: DWORD = 98; +pub const DMPAPER_PENV_4: DWORD = 99; +pub const DMPAPER_PENV_5: DWORD = 100; +pub const DMPAPER_PENV_6: DWORD = 101; +pub const DMPAPER_PENV_7: DWORD = 102; +pub const DMPAPER_PENV_8: DWORD = 103; +pub const DMPAPER_PENV_9: DWORD = 104; +pub const DMPAPER_PENV_10: DWORD = 105; +pub const DMPAPER_P16K_ROTATED: DWORD = 106; +pub const DMPAPER_P32K_ROTATED: DWORD = 107; +pub const DMPAPER_P32KBIG_ROTATED: DWORD = 108; +pub const DMPAPER_PENV_1_ROTATED: DWORD = 109; +pub const DMPAPER_PENV_2_ROTATED: DWORD = 110; +pub const DMPAPER_PENV_3_ROTATED: DWORD = 111; +pub const DMPAPER_PENV_4_ROTATED: DWORD = 112; +pub const DMPAPER_PENV_5_ROTATED: DWORD = 113; +pub const DMPAPER_PENV_6_ROTATED: DWORD = 114; +pub const DMPAPER_PENV_7_ROTATED: DWORD = 115; +pub const DMPAPER_PENV_8_ROTATED: DWORD = 116; +pub const DMPAPER_PENV_9_ROTATED: DWORD = 117; +pub const DMPAPER_PENV_10_ROTATED: DWORD = 118; +pub const DMPAPER_LAST: DWORD = DMPAPER_PENV_10_ROTATED; +pub const DMPAPER_USER: DWORD = 256; +pub const DMBIN_FIRST: DWORD = DMBIN_UPPER; +pub const DMBIN_UPPER: DWORD = 1; +pub const DMBIN_ONLYONE: DWORD = 1; +pub const DMBIN_LOWER: DWORD = 2; +pub const DMBIN_MIDDLE: DWORD = 3; +pub const DMBIN_MANUAL: DWORD = 4; +pub const DMBIN_ENVELOPE: DWORD = 5; +pub const DMBIN_ENVMANUAL: DWORD = 6; +pub const DMBIN_AUTO: DWORD = 7; +pub const DMBIN_TRACTOR: DWORD = 8; +pub const DMBIN_SMALLFMT: DWORD = 9; +pub const DMBIN_LARGEFMT: DWORD = 10; +pub const DMBIN_LARGECAPACITY: DWORD = 11; +pub const DMBIN_CASSETTE: DWORD = 14; +pub const DMBIN_FORMSOURCE: DWORD = 15; +pub const DMBIN_LAST: DWORD = DMBIN_FORMSOURCE; +pub const DMBIN_USER: DWORD = 256; +pub const DMRES_DRAFT: c_int = -1; +pub const DMRES_LOW: c_int = -2; +pub const DMRES_MEDIUM: c_int = -3; +pub const DMRES_HIGH: c_int = -4; +pub const DMCOLOR_MONOCHROME: DWORD = 1; +pub const DMCOLOR_COLOR: DWORD = 2; +pub const DMDUP_SIMPLEX: DWORD = 1; +pub const DMDUP_VERTICAL: DWORD = 2; +pub const DMDUP_HORIZONTAL: DWORD = 3; +pub const DMTT_BITMAP: DWORD = 1; +pub const DMTT_DOWNLOAD: DWORD = 2; +pub const DMTT_SUBDEV: DWORD = 3; +pub const DMTT_DOWNLOAD_OUTLINE: DWORD = 4; +pub const DMCOLLATE_FALSE: DWORD = 0; +pub const DMCOLLATE_TRUE: DWORD = 1; +pub const DMDO_DEFAULT: DWORD = 0; +pub const DMDO_90: DWORD = 1; +pub const DMDO_180: DWORD = 2; +pub const DMDO_270: DWORD = 3; +pub const DMDFO_DEFAULT: DWORD = 0; +pub const DMDFO_STRETCH: DWORD = 1; +pub const DMDFO_CENTER: DWORD = 2; +pub const DM_INTERLACED: DWORD = 0x00000002; +pub const DMDISPLAYFLAGS_TEXTMODE: DWORD = 0x00000004; +pub const DMNUP_SYSTEM: DWORD = 1; +pub const DMNUP_ONEUP: DWORD = 2; +pub const DMICMMETHOD_NONE: DWORD = 1; +pub const DMICMMETHOD_SYSTEM: DWORD = 2; +pub const DMICMMETHOD_DRIVER: DWORD = 3; +pub const DMICMMETHOD_DEVICE: DWORD = 4; +pub const DMICMMETHOD_USER: DWORD = 256; +pub const DMICM_SATURATE: DWORD = 1; +pub const DMICM_CONTRAST: DWORD = 2; +pub const DMICM_COLORIMETRIC: DWORD = 3; +pub const DMICM_ABS_COLORIMETRIC: DWORD = 4; +pub const DMICM_USER: DWORD = 256; +pub const DMMEDIA_STANDARD: DWORD = 1; +pub const DMMEDIA_TRANSPARENCY: DWORD = 2; +pub const DMMEDIA_GLOSSY: DWORD = 3; +pub const DMMEDIA_USER: DWORD = 256; +pub const DMDITHER_NONE: DWORD = 1; +pub const DMDITHER_COARSE: DWORD = 2; +pub const DMDITHER_FINE: DWORD = 3; +pub const DMDITHER_LINEART: DWORD = 4; +pub const DMDITHER_ERRORDIFFUSION: DWORD = 5; +pub const DMDITHER_RESERVED6: DWORD = 6; +pub const DMDITHER_RESERVED7: DWORD = 7; +pub const DMDITHER_RESERVED8: DWORD = 8; +pub const DMDITHER_RESERVED9: DWORD = 9; +pub const DMDITHER_GRAYSCALE: DWORD = 10; +pub const DMDITHER_USER: DWORD = 256; +STRUCT!{struct DISPLAY_DEVICEA { + cb: DWORD, + DeviceName: [CHAR; 32], + DeviceString: [CHAR; 128], + StateFlags: DWORD, + DeviceID: [CHAR; 128], + DeviceKey: [CHAR; 128], +}} +pub type PDISPLAY_DEVICEA = *mut DISPLAY_DEVICEA; +pub type LPDISPLAY_DEVICEA = *mut DISPLAY_DEVICEA; +STRUCT!{struct DISPLAY_DEVICEW { + cb: DWORD, + DeviceName: [WCHAR; 32], + DeviceString: [WCHAR; 128], + StateFlags: DWORD, + DeviceID: [WCHAR; 128], + DeviceKey: [WCHAR; 128], +}} +pub type PDISPLAY_DEVICEW = *mut DISPLAY_DEVICEW; +pub type LPDISPLAY_DEVICEW = *mut DISPLAY_DEVICEW; +pub const DISPLAY_DEVICE_ATTACHED_TO_DESKTOP: DWORD = 0x00000001; +pub const DISPLAY_DEVICE_MULTI_DRIVER: DWORD = 0x00000002; +pub const DISPLAY_DEVICE_PRIMARY_DEVICE: DWORD = 0x00000004; +pub const DISPLAY_DEVICE_MIRRORING_DRIVER: DWORD = 0x00000008; +pub const DISPLAY_DEVICE_VGA_COMPATIBLE: DWORD = 0x00000010; +pub const DISPLAY_DEVICE_REMOVABLE: DWORD = 0x00000020; +pub const DISPLAY_DEVICE_ACC_DRIVER: DWORD = 0x00000040; +pub const DISPLAY_DEVICE_MODESPRUNED: DWORD = 0x08000000; +pub const DISPLAY_DEVICE_RDPUDD: DWORD = 0x01000000; +pub const DISPLAY_DEVICE_REMOTE: DWORD = 0x04000000; +pub const DISPLAY_DEVICE_DISCONNECT: DWORD = 0x02000000; +pub const DISPLAY_DEVICE_TS_COMPATIBLE: DWORD = 0x00200000; +pub const DISPLAY_DEVICE_UNSAFE_MODES_ON: DWORD = 0x00080000; +pub const DISPLAY_DEVICE_ACTIVE: DWORD = 0x00000001; +pub const DISPLAY_DEVICE_ATTACHED: DWORD = 0x00000002; +pub const DISPLAYCONFIG_MAXPATH: usize = 1024; +STRUCT!{struct DISPLAYCONFIG_RATIONAL { + Numerator: UINT32, + Denominator: UINT32, +}} +ENUM!{enum DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY { + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER = -1i32 as u32, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HD15 = 0, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SVIDEO = 1, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPOSITE_VIDEO = 2, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPONENT_VIDEO = 3, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DVI = 4, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HDMI = 5, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_LVDS = 6, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_D_JPN = 8, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDI = 9, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EXTERNAL = 10, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED = 11, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EXTERNAL = 12, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED = 13, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDTVDONGLE = 14, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_MIRACAST = 15, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INDIRECT_WIRED = 16, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL = 0x80000000, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_FORCE_UINT32 = 0xFFFFFFFF, +}} +ENUM!{enum DISPLAYCONFIG_SCANLINE_ORDERING { + DISPLAYCONFIG_SCANLINE_ORDERING_UNSPECIFIED = 0, + DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE = 1, + DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED = 2, + DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_UPPERFIELDFIRST = + DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED, + DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_LOWERFIELDFIRST = 3, + DISPLAYCONFIG_SCANLINE_ORDERING_FORCE_UINT32 = 0xFFFFFFFF, +}} +STRUCT!{struct DISPLAYCONFIG_2DREGION { + cx: UINT32, + cy: UINT32, +}} +STRUCT!{struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_AdditionalSignalInfo { + bitfield: UINT32, +}} +BITFIELD!{DISPLAYCONFIG_VIDEO_SIGNAL_INFO_AdditionalSignalInfo bitfield: UINT32 [ + videoStandard set_videoStandard[0..16], + vSyncFreqDivider set_vSyncFreqDivider[16..22], +]} +UNION!{union DISPLAYCONFIG_VIDEO_SIGNAL_INFO_u { + [u32; 1], + AdditionalSignalInfo AdditionalSignalInfo_mut: + DISPLAYCONFIG_VIDEO_SIGNAL_INFO_AdditionalSignalInfo, + videoStandard videoStandard_mut: UINT32, +}} +STRUCT!{struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO { + pixelRate: UINT64, + hSyncFreq: DISPLAYCONFIG_RATIONAL, + vSyncFreq: DISPLAYCONFIG_RATIONAL, + activeSize: DISPLAYCONFIG_2DREGION, + totalSize: DISPLAYCONFIG_2DREGION, + u: DISPLAYCONFIG_VIDEO_SIGNAL_INFO_u, + scanLineOrdering: DISPLAYCONFIG_SCANLINE_ORDERING, +}} +ENUM!{enum DISPLAYCONFIG_SCALING { + DISPLAYCONFIG_SCALING_IDENTITY = 1, + DISPLAYCONFIG_SCALING_CENTERED = 2, + DISPLAYCONFIG_SCALING_STRETCHED = 3, + DISPLAYCONFIG_SCALING_ASPECTRATIOCENTEREDMAX = 4, + DISPLAYCONFIG_SCALING_CUSTOM = 5, + DISPLAYCONFIG_SCALING_PREFERRED = 128, + DISPLAYCONFIG_SCALING_FORCE_UINT32 = 0xFFFFFFFF, +}} +ENUM!{enum DISPLAYCONFIG_ROTATION { + DISPLAYCONFIG_ROTATION_IDENTITY = 1, + DISPLAYCONFIG_ROTATION_ROTATE90 = 2, + DISPLAYCONFIG_ROTATION_ROTATE180 = 3, + DISPLAYCONFIG_ROTATION_ROTATE270 = 4, + DISPLAYCONFIG_ROTATION_FORCE_UINT32 = 0xFFFFFFFF, +}} +ENUM!{enum DISPLAYCONFIG_MODE_INFO_TYPE { + DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE = 1, + DISPLAYCONFIG_MODE_INFO_TYPE_TARGET = 2, + DISPLAYCONFIG_MODE_INFO_TYPE_DESKTOP_IMAGE = 3, + DISPLAYCONFIG_MODE_INFO_TYPE_FORCE_UINT32 = 0xFFFFFFFF, +}} +ENUM!{enum DISPLAYCONFIG_PIXELFORMAT { + DISPLAYCONFIG_PIXELFORMAT_8BPP = 1, + DISPLAYCONFIG_PIXELFORMAT_16BPP = 2, + DISPLAYCONFIG_PIXELFORMAT_24BPP = 3, + DISPLAYCONFIG_PIXELFORMAT_32BPP = 4, + DISPLAYCONFIG_PIXELFORMAT_NONGDI = 5, + DISPLAYCONFIG_PIXELFORMAT_FORCE_UINT32 = 0xffffffff, +}} +STRUCT!{struct DISPLAYCONFIG_SOURCE_MODE { + width: UINT32, + height: UINT32, + pixelFormat: DISPLAYCONFIG_PIXELFORMAT, + position: POINTL, +}} +STRUCT!{struct DISPLAYCONFIG_TARGET_MODE { + targetVideoSignalInfo: DISPLAYCONFIG_VIDEO_SIGNAL_INFO, +}} +STRUCT!{struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO { + PathSourceSize: POINTL, + DesktopImageRegion: RECTL, + DesktopImageClip: RECTL, +}} +UNION!{union DISPLAYCONFIG_MODE_INFO_u { + [u64; 6], + targetMode targetMode_mut: DISPLAYCONFIG_TARGET_MODE, + sourceMode sourceMode_mut: DISPLAYCONFIG_SOURCE_MODE, + desktopImageInfo desktopImageInfo_mut: DISPLAYCONFIG_DESKTOP_IMAGE_INFO, +}} +STRUCT!{struct DISPLAYCONFIG_MODE_INFO { + infoType: DISPLAYCONFIG_MODE_INFO_TYPE, + id: UINT32, + adapterId: LUID, + u: DISPLAYCONFIG_MODE_INFO_u, +}} +pub const DISPLAYCONFIG_PATH_MODE_IDX_INVALID: DWORD = 0xffffffff; +pub const DISPLAYCONFIG_PATH_TARGET_MODE_IDX_INVALID: DWORD = 0xffff; +pub const DISPLAYCONFIG_PATH_DESKTOP_IMAGE_IDX_INVALID: DWORD = 0xffff; +pub const DISPLAYCONFIG_PATH_SOURCE_MODE_IDX_INVALID: DWORD = 0xffff; +pub const DISPLAYCONFIG_PATH_CLONE_GROUP_INVALID: DWORD = 0xffff; +STRUCT!{struct DISPLAYCONFIG_PATH_SOURCE_INFO { + adapterId: LUID, + id: UINT32, + modeInfoIdx: UINT32, + statusFlags: UINT32, +}} +BITFIELD!{DISPLAYCONFIG_PATH_SOURCE_INFO modeInfoIdx: UINT32 [ + cloneGroupId set_cloneGroupId[0..16], + sourceModeInfoIdx set_sourceModeInfoIdx[16..32], +]} +pub const DISPLAYCONFIG_SOURCE_IN_USE: DWORD = 0x00000001; +STRUCT!{struct DISPLAYCONFIG_PATH_TARGET_INFO { + adapterId: LUID, + id: UINT32, + modeInfoIdx: UINT32, + outputTechnology: DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY, + rotation: DISPLAYCONFIG_ROTATION, + scaling: DISPLAYCONFIG_SCALING, + refreshRate: DISPLAYCONFIG_RATIONAL, + scanLineOrdering: DISPLAYCONFIG_SCANLINE_ORDERING, + targetAvailable: BOOL, + statusFlags: UINT32, +}} +BITFIELD!{DISPLAYCONFIG_PATH_TARGET_INFO modeInfoIdx: UINT32 [ + desktopModeInfoIdx set_desktopModeInfoIdx[0..16], + targetModeInfoIdx set_targetModeInfoIdx[16..32], +]} +pub const DISPLAYCONFIG_TARGET_IN_USE: DWORD = 0x00000001; +pub const DISPLAYCONFIG_TARGET_FORCIBLE: DWORD = 0x00000002; +pub const DISPLAYCONFIG_TARGET_FORCED_AVAILABILITY_BOOT: DWORD = 0x00000004; +pub const DISPLAYCONFIG_TARGET_FORCED_AVAILABILITY_PATH: DWORD = 0x00000008; +pub const DISPLAYCONFIG_TARGET_FORCED_AVAILABILITY_SYSTEM: DWORD = 0x00000010; +pub const DISPLAYCONFIG_TARGET_IS_HMD: DWORD = 0x00000020; +STRUCT!{struct DISPLAYCONFIG_PATH_INFO { + sourceInfo: DISPLAYCONFIG_PATH_SOURCE_INFO, + targetInfo: DISPLAYCONFIG_PATH_TARGET_INFO, + flags: UINT32, +}} +pub const DISPLAYCONFIG_PATH_ACTIVE: DWORD = 0x00000001; +pub const DISPLAYCONFIG_PATH_PREFERRED_UNSCALED: DWORD = 0x00000004; +pub const DISPLAYCONFIG_PATH_SUPPORT_VIRTUAL_MODE: DWORD = 0x00000008; +pub const DISPLAYCONFIG_PATH_VALID_FLAGS: DWORD = 0x0000000D; +ENUM!{enum DISPLAYCONFIG_TOPOLOGY_ID { + DISPLAYCONFIG_TOPOLOGY_INTERNAL = 0x00000001, + DISPLAYCONFIG_TOPOLOGY_CLONE = 0x00000002, + DISPLAYCONFIG_TOPOLOGY_EXTEND = 0x00000004, + DISPLAYCONFIG_TOPOLOGY_EXTERNAL = 0x00000008, + DISPLAYCONFIG_TOPOLOGY_FORCE_UINT32 = 0xFFFFFFFF, +}} +ENUM!{enum DISPLAYCONFIG_DEVICE_INFO_TYPE { + DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME = 1, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 2, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE = 3, + DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME = 4, + DISPLAYCONFIG_DEVICE_INFO_SET_TARGET_PERSISTENCE = 5, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_BASE_TYPE = 6, + DISPLAYCONFIG_DEVICE_INFO_GET_SUPPORT_VIRTUAL_RESOLUTION = 7, + DISPLAYCONFIG_DEVICE_INFO_SET_SUPPORT_VIRTUAL_RESOLUTION = 8, + DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO = 9, + DISPLAYCONFIG_DEVICE_INFO_SET_ADVANCED_COLOR_STATE = 10, + DISPLAYCONFIG_DEVICE_INFO_FORCE_UINT32 = 0xFFFFFFFF, +}} +STRUCT!{struct DISPLAYCONFIG_DEVICE_INFO_HEADER { + _type: DISPLAYCONFIG_DEVICE_INFO_TYPE, + size: UINT32, + adapterId: LUID, + id: UINT32, +}} +STRUCT!{struct DISPLAYCONFIG_SOURCE_DEVICE_NAME { + header: DISPLAYCONFIG_DEVICE_INFO_HEADER, + viewGdiDeviceName: [WCHAR; CCHDEVICENAME], +}} +STRUCT!{struct DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS { + value: UINT32, +}} +BITFIELD!{DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS value: UINT32 [ + friendlyNameFromEdid set_friendlyNameFromEdid[0..1], + friendlyNameForced set_friendlyNameForced[1..2], + edidIdsValid set_edidIdsValid[2..3], +]} +STRUCT!{struct DISPLAYCONFIG_TARGET_DEVICE_NAME { + header: DISPLAYCONFIG_DEVICE_INFO_HEADER, + flags: DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS, + outputTechnology: DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY, + edidManufactureId: UINT16, + edidProductCodeId: UINT16, + connectorInstance: UINT32, + monitorFriendlyDeviceName: [WCHAR; 64], + monitorDevicePath: [WCHAR; 128], +}} +STRUCT!{struct DISPLAYCONFIG_TARGET_PREFERRED_MODE { + header: DISPLAYCONFIG_DEVICE_INFO_HEADER, + width: UINT32, + height: UINT32, + targetMode: DISPLAYCONFIG_TARGET_MODE, +}} +STRUCT!{struct DISPLAYCONFIG_ADAPTER_NAME { + header: DISPLAYCONFIG_DEVICE_INFO_HEADER, + adapterDevicePath: [WCHAR; 128], +}} +STRUCT!{struct DISPLAYCONFIG_TARGET_BASE_TYPE { + header: DISPLAYCONFIG_DEVICE_INFO_HEADER, + baseOutputTechnology: DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY, +}} +STRUCT!{struct DISPLAYCONFIG_SET_TARGET_PERSISTENCE { + header: DISPLAYCONFIG_DEVICE_INFO_HEADER, + value: UINT32, +}} +BITFIELD!{DISPLAYCONFIG_SET_TARGET_PERSISTENCE value: UINT32 [ + bootPersistenceOn set_bootPersistenceOn[0..1], +]} +STRUCT!{struct DISPLAYCONFIG_SUPPORT_VIRTUAL_RESOLUTION { + header: DISPLAYCONFIG_DEVICE_INFO_HEADER, + value: UINT32, +}} +BITFIELD!{DISPLAYCONFIG_SUPPORT_VIRTUAL_RESOLUTION value: UINT32 [ + disableMonitorVirtualResolution set_disableMonitorVirtualResolution[0..1], +]} +ENUM!{enum DISPLAYCONFIG_COLOR_ENCODING { + DISPLAYCONFIG_COLOR_ENCODING_RGB = 0, + DISPLAYCONFIG_COLOR_ENCODING_YCBCR444 = 1, + DISPLAYCONFIG_COLOR_ENCODING_YCBCR422 = 2, + DISPLAYCONFIG_COLOR_ENCODING_YCBCR420 = 3, + DISPLAYCONFIG_COLOR_ENCODING_INTENSITY = 4, + DISPLAYCONFIG_COLOR_ENCODING_FORCE_UINT32 = 0xFFFFFFFF, +}} +STRUCT!{struct DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO { + header: DISPLAYCONFIG_DEVICE_INFO_HEADER, + value: UINT32, + colorEncoding: DISPLAYCONFIG_COLOR_ENCODING, + bitsPerColorChannel: UINT32, +}} +BITFIELD!{DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO value: UINT32 [ + advancedColorSupported set_advancedColorSupported[0..1], + advancedColorEnabled set_advancedColorEnabled[1..2], + reserved set_reserved[2..32], +]} +STRUCT!{struct DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE { + header: DISPLAYCONFIG_DEVICE_INFO_HEADER, + value: UINT32, +}} +BITFIELD!{DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE value: UINT32 [ + enableAdvancedColor set_enableAdvancedColor[0..1], + reserved set_reserved[1..32], +]} +pub const QDC_ALL_PATHS: DWORD = 0x00000001; +pub const QDC_ONLY_ACTIVE_PATHS: DWORD = 0x00000002; +pub const QDC_DATABASE_CURRENT: DWORD = 0x00000004; +pub const QDC_VIRTUAL_MODE_AWARE: DWORD = 0x00000010; +pub const QDC_INCLUDE_HMD: DWORD = 0x00000020; +pub const SDC_TOPOLOGY_INTERNAL: DWORD = 0x00000001; +pub const SDC_TOPOLOGY_CLONE: DWORD = 0x00000002; +pub const SDC_TOPOLOGY_EXTEND: DWORD = 0x00000004; +pub const SDC_TOPOLOGY_EXTERNAL: DWORD = 0x00000008; +pub const SDC_TOPOLOGY_SUPPLIED: DWORD = 0x00000010; +pub const SDC_USE_DATABASE_CURRENT: DWORD = SDC_TOPOLOGY_INTERNAL | SDC_TOPOLOGY_CLONE + | SDC_TOPOLOGY_EXTEND | SDC_TOPOLOGY_EXTERNAL; +pub const SDC_USE_SUPPLIED_DISPLAY_CONFIG: DWORD = 0x00000020; +pub const SDC_VALIDATE: DWORD = 0x00000040; +pub const SDC_APPLY: DWORD = 0x00000080; +pub const SDC_NO_OPTIMIZATION: DWORD = 0x00000100; +pub const SDC_SAVE_TO_DATABASE: DWORD = 0x00000200; +pub const SDC_ALLOW_CHANGES: DWORD = 0x00000400; +pub const SDC_PATH_PERSIST_IF_REQUIRED: DWORD = 0x00000800; +pub const SDC_FORCE_MODE_ENUMERATION: DWORD = 0x00001000; +pub const SDC_ALLOW_PATH_ORDER_CHANGES: DWORD = 0x00002000; +pub const SDC_VIRTUAL_MODE_AWARE: DWORD = 0x00008000; +pub const RDH_RECTANGLES: DWORD = 1; +STRUCT!{struct RGNDATAHEADER { + dwSize: DWORD, + iType: DWORD, + nCount: DWORD, + nRgnSize: DWORD, + rcBound: RECT, +}} +pub type PRGNDATAHEADER = *mut RGNDATAHEADER; +STRUCT!{struct RGNDATA { + rdh: RGNDATAHEADER, + Buffer: [c_char; 1], +}} +pub type PRGNDATA = *mut RGNDATA; +pub type NPRGNDATA = *mut RGNDATA; +pub type LPRGNDATA = *mut RGNDATA; +pub const SYSRGN: INT = 4; +STRUCT!{struct ABC { + abcA: c_int, + abcB: UINT, + abcC: c_int, +}} +pub type PABC = *mut ABC; +pub type NPABC = *mut ABC; +pub type LPABC = *mut ABC; +STRUCT!{struct ABCFLOAT { + abcfA: FLOAT, + abcfB: FLOAT, + abcfC: FLOAT, +}} +pub type PABCFLOAT = *mut ABCFLOAT; +pub type NPABCFLOAT = *mut ABCFLOAT; +pub type LPABCFLOAT = *mut ABCFLOAT; +STRUCT!{struct OUTLINETEXTMETRICA { + otmSize: UINT, + otmTextMetrics: TEXTMETRICA, + otmFiller: BYTE, + otmPanoseNumber: PANOSE, + otmfsSelection: UINT, + otmfsType: UINT, + otmsCharSlopeRise: c_int, + otmsCharSlopeRun: c_int, + otmItalicAngle: c_int, + otmEMSquare: UINT, + otmAscent: c_int, + otmDescent: c_int, + otmLineGap: UINT, + otmsCapEmHeight: UINT, + otmsXHeight: UINT, + otmrcFontBox: RECT, + otmMacAscent: c_int, + otmMacDescent: c_int, + otmMacLineGap: UINT, + otmusMinimumPPEM: UINT, + otmptSubscriptSize: POINT, + otmptSubscriptOffset: POINT, + otmptSuperscriptSize: POINT, + otmptSuperscriptOffset: POINT, + otmsStrikeoutSize: UINT, + otmsStrikeoutPosition: c_int, + otmsUnderscoreSize: c_int, + otmsUnderscorePosition: c_int, + otmpFamilyName: PSTR, + otmpFaceName: PSTR, + otmpStyleName: PSTR, + otmpFullName: PSTR, +}} +pub type POUTLINETEXTMETRICA = *mut OUTLINETEXTMETRICA; +pub type NPOUTLINETEXTMETRICA = *mut OUTLINETEXTMETRICA; +pub type LPOUTLINETEXTMETRICA = *mut OUTLINETEXTMETRICA; +STRUCT!{struct OUTLINETEXTMETRICW { + otmSize: UINT, + otmTextMetrics: TEXTMETRICW, + otmFiller: BYTE, + otmPanoseNumber: PANOSE, + otmfsSelection: UINT, + otmfsType: UINT, + otmsCharSlopeRise: c_int, + otmsCharSlopeRun: c_int, + otmItalicAngle: c_int, + otmEMSquare: UINT, + otmAscent: c_int, + otmDescent: c_int, + otmLineGap: UINT, + otmsCapEmHeight: UINT, + otmsXHeight: UINT, + otmrcFontBox: RECT, + otmMacAscent: c_int, + otmMacDescent: c_int, + otmMacLineGap: UINT, + otmusMinimumPPEM: UINT, + otmptSubscriptSize: POINT, + otmptSubscriptOffset: POINT, + otmptSuperscriptSize: POINT, + otmptSuperscriptOffset: POINT, + otmsStrikeoutSize: UINT, + otmsStrikeoutPosition: c_int, + otmsUnderscoreSize: c_int, + otmsUnderscorePosition: c_int, + otmpFamilyName: PSTR, + otmpFaceName: PSTR, + otmpStyleName: PSTR, + otmpFullName: PSTR, +}} +pub type POUTLINETEXTMETRICW = *mut OUTLINETEXTMETRICW; +pub type NPOUTLINETEXTMETRICW = *mut OUTLINETEXTMETRICW; +pub type LPOUTLINETEXTMETRICW = *mut OUTLINETEXTMETRICW; +STRUCT!{struct POLYTEXTA { + x: c_int, + y: c_int, + n: UINT, + lpstr: LPCSTR, + uiFlags: UINT, + rcl: RECT, + pdx: *mut c_int, +}} +pub type PPOLYTEXTA = *mut POLYTEXTA; +pub type NPPOLYTEXTA = *mut POLYTEXTA; +pub type LPPOLYTEXTA = *mut POLYTEXTA; +STRUCT!{struct POLYTEXTW { + x: c_int, + y: c_int, + n: UINT, + lpstr: LPCWSTR, + uiFlags: UINT, + rcl: RECT, + pdx: *mut c_int, +}} +pub type PPOLYTEXTW = *mut POLYTEXTW; +pub type NPPOLYTEXTW = *mut POLYTEXTW; +pub type LPPOLYTEXTW = *mut POLYTEXTW; +STRUCT!{struct FIXED { + fract: WORD, + value: c_short, +}} +STRUCT!{struct MAT2 { + eM11: FIXED, + eM12: FIXED, + eM21: FIXED, + eM22: FIXED, +}} +pub type LPMAT2 = *mut MAT2; +STRUCT!{struct GLYPHMETRICS { + gmBlackBoxX: UINT, + gmBlackBoxY: UINT, + gmptGlyphOrigin: POINT, + gmCellIncX: c_short, + gmCellIncY: c_short, +}} +pub type LPGLYPHMETRICS = *mut GLYPHMETRICS; +pub const GGO_METRICS: DWORD = 0; +pub const GGO_BITMAP: DWORD = 1; +pub const GGO_NATIVE: DWORD = 2; +pub const GGO_BEZIER: DWORD = 3; +pub const GGO_GRAY2_BITMAP: DWORD = 4; +pub const GGO_GRAY4_BITMAP: DWORD = 5; +pub const GGO_GRAY8_BITMAP: DWORD = 6; +pub const GGO_GLYPH_INDEX: DWORD = 0x0080; +pub const GGO_UNHINTED: DWORD = 0x0100; +pub const TT_POLYGON_TYPE: DWORD = 24; +pub const TT_PRIM_LINE: DWORD = 1; +pub const TT_PRIM_QSPLINE: DWORD = 2; +pub const TT_PRIM_CSPLINE: DWORD = 3; +STRUCT!{struct POINTFX { + x: FIXED, + y: FIXED, +}} +pub type LPPOINTFX = *mut POINTFX; +STRUCT!{struct TTPOLYCURVE { + wType: WORD, + cpfx: WORD, + apfx: [POINTFX; 1], +}} +pub type LPTTPOLYCURVE = *mut TTPOLYCURVE; +STRUCT!{struct TTPOLYGONHEADER { + cb: DWORD, + dwType: DWORD, + pfxStart: POINTFX, +}} +pub type LPTTPOLYGONHEADER = *mut TTPOLYGONHEADER; +pub const GCP_DBCS: DWORD = 0x0001; +pub const GCP_REORDER: DWORD = 0x0002; +pub const GCP_USEKERNING: DWORD = 0x0008; +pub const GCP_GLYPHSHAPE: DWORD = 0x0010; +pub const GCP_LIGATE: DWORD = 0x0020; +pub const GCP_DIACRITIC: DWORD = 0x0100; +pub const GCP_KASHIDA: DWORD = 0x0400; +pub const GCP_ERROR: DWORD = 0x8000; +pub const FLI_MASK: DWORD = 0x103B; +pub const GCP_JUSTIFY: DWORD = 0x00010000; +pub const FLI_GLYPHS: DWORD = 0x00040000; +pub const GCP_CLASSIN: DWORD = 0x00080000; +pub const GCP_MAXEXTENT: DWORD = 0x00100000; +pub const GCP_JUSTIFYIN: DWORD = 0x00200000; +pub const GCP_DISPLAYZWG: DWORD = 0x00400000; +pub const GCP_SYMSWAPOFF: DWORD = 0x00800000; +pub const GCP_NUMERICOVERRIDE: DWORD = 0x01000000; +pub const GCP_NEUTRALOVERRIDE: DWORD = 0x02000000; +pub const GCP_NUMERICSLATIN: DWORD = 0x04000000; +pub const GCP_NUMERICSLOCAL: DWORD = 0x08000000; +pub const GCPCLASS_LATIN: DWORD = 1; +pub const GCPCLASS_HEBREW: DWORD = 2; +pub const GCPCLASS_ARABIC: DWORD = 2; +pub const GCPCLASS_NEUTRAL: DWORD = 3; +pub const GCPCLASS_LOCALNUMBER: DWORD = 4; +pub const GCPCLASS_LATINNUMBER: DWORD = 5; +pub const GCPCLASS_LATINNUMERICTERMINATOR: DWORD = 6; +pub const GCPCLASS_LATINNUMERICSEPARATOR: DWORD = 7; +pub const GCPCLASS_NUMERICSEPARATOR: DWORD = 8; +pub const GCPCLASS_PREBOUNDLTR: DWORD = 0x80; +pub const GCPCLASS_PREBOUNDRTL: DWORD = 0x40; +pub const GCPCLASS_POSTBOUNDLTR: DWORD = 0x20; +pub const GCPCLASS_POSTBOUNDRTL: DWORD = 0x10; +pub const GCPGLYPH_LINKBEFORE: DWORD = 0x8000; +pub const GCPGLYPH_LINKAFTER: DWORD = 0x4000; +STRUCT!{struct GCP_RESULTSA { + lStructSize: DWORD, + lpOutString: LPSTR, + lpOrder: *mut UINT, + lpDx: *mut c_int, + lpCaretPos: *mut c_int, + lpClass: LPSTR, + lpGlyphs: LPWSTR, + nGlyphs: UINT, + nMaxFit: c_int, +}} +pub type LPGCP_RESULTSA = *mut GCP_RESULTSA; +STRUCT!{struct GCP_RESULTSW { + lStructSize: DWORD, + lpOutString: LPWSTR, + lpOrder: *mut UINT, + lpDx: *mut c_int, + lpCaretPos: *mut c_int, + lpClass: LPSTR, + lpGlyphs: LPWSTR, + nGlyphs: UINT, + nMaxFit: c_int, +}} +pub type LPGCP_RESULTSW = *mut GCP_RESULTSW; +STRUCT!{struct RASTERIZER_STATUS { + nSize: c_short, + wFlags: c_short, + nLanguageID: c_short, +}} +pub type LPRASTERIZER_STATUS = *mut RASTERIZER_STATUS; +pub const TT_AVAILABLE: DWORD = 0x0001; +pub const TT_ENABLED: DWORD = 0x0002; +STRUCT!{struct PIXELFORMATDESCRIPTOR { + nSize: WORD, + nVersion: WORD, + dwFlags: DWORD, + iPixelType: BYTE, + cColorBits: BYTE, + cRedBits: BYTE, + cRedShift: BYTE, + cGreenBits: BYTE, + cGreenShift: BYTE, + cBlueBits: BYTE, + cBlueShift: BYTE, + cAlphaBits: BYTE, + cAlphaShift: BYTE, + cAccumBits: BYTE, + cAccumRedBits: BYTE, + cAccumGreenBits: BYTE, + cAccumBlueBits: BYTE, + cAccumAlphaBits: BYTE, + cDepthBits: BYTE, + cStencilBits: BYTE, + cAuxBuffers: BYTE, + iLayerType: BYTE, + bReserved: BYTE, + dwLayerMask: DWORD, + dwVisibleMask: DWORD, + dwDamageMask: DWORD, +}} +pub type PPIXELFORMATDESCRIPTOR = *mut PIXELFORMATDESCRIPTOR; +pub type LPPIXELFORMATDESCRIPTOR = *mut PIXELFORMATDESCRIPTOR; +pub const PFD_TYPE_RGBA: BYTE = 0; +pub const PFD_TYPE_COLORINDEX: BYTE = 1; +pub const PFD_MAIN_PLANE: BYTE = 0; +pub const PFD_OVERLAY_PLANE: BYTE = 1; +pub const PFD_UNDERLAY_PLANE: BYTE = -1i8 as u8; +pub const PFD_DOUBLEBUFFER: DWORD = 0x00000001; +pub const PFD_STEREO: DWORD = 0x00000002; +pub const PFD_DRAW_TO_WINDOW: DWORD = 0x00000004; +pub const PFD_DRAW_TO_BITMAP: DWORD = 0x00000008; +pub const PFD_SUPPORT_GDI: DWORD = 0x00000010; +pub const PFD_SUPPORT_OPENGL: DWORD = 0x00000020; +pub const PFD_GENERIC_FORMAT: DWORD = 0x00000040; +pub const PFD_NEED_PALETTE: DWORD = 0x00000080; +pub const PFD_NEED_SYSTEM_PALETTE: DWORD = 0x00000100; +pub const PFD_SWAP_EXCHANGE: DWORD = 0x00000200; +pub const PFD_SWAP_COPY: DWORD = 0x00000400; +pub const PFD_SWAP_LAYER_BUFFERS: DWORD = 0x00000800; +pub const PFD_GENERIC_ACCELERATED: DWORD = 0x00001000; +pub const PFD_SUPPORT_DIRECTDRAW: DWORD = 0x00002000; +pub const PFD_DIRECT3D_ACCELERATED: DWORD = 0x00004000; +pub const PFD_SUPPORT_COMPOSITION: DWORD = 0x00008000; +pub const PFD_DEPTH_DONTCARE: DWORD = 0x20000000; +pub const PFD_DOUBLEBUFFER_DONTCARE: DWORD = 0x40000000; +pub const PFD_STEREO_DONTCARE: DWORD = 0x80000000; +FN!{stdcall OLDFONTENUMPROCA( + *const LOGFONTA, + *const TEXTMETRICA, + DWORD, + LPARAM, +) -> c_int} +FN!{stdcall OLDFONTENUMPROCW( + *const LOGFONTW, + *const TEXTMETRICW, + DWORD, + LPARAM, +) -> c_int} +pub type FONTENUMPROCA = OLDFONTENUMPROCA; +pub type FONTENUMPROCW = OLDFONTENUMPROCW; +FN!{stdcall GOBJENUMPROC( + LPVOID, + LPARAM, +) -> c_int} +FN!{stdcall LINEDDAPROC( + c_int, + c_int, + LPARAM, +) -> ()} +extern "system" { + pub fn AddFontResourceA( + _: LPCSTR, + ) -> c_int; + pub fn AddFontResourceW( + _: LPCWSTR, + ) -> c_int; + pub fn AnimatePalette( + hPal: HPALETTE, + iStartIndex: UINT, + cEntries: UINT, + ppe: *const PALETTEENTRY, + ) -> BOOL; + pub fn Arc( + hdc: HDC, + x1: c_int, + y1: c_int, + x2: c_int, + y2: c_int, + x3: c_int, + y3: c_int, + x4: c_int, + y4: c_int, + ) -> BOOL; + pub fn BitBlt( + hdc: HDC, + x: c_int, + y: c_int, + cx: c_int, + cy: c_int, + hdcSrc: HDC, + x1: c_int, + y1: c_int, + rop: DWORD, + ) -> BOOL; + pub fn CancelDC( + hdc: HDC, + ) -> BOOL; + pub fn Chord( + hdc: HDC, + x1: c_int, + y1: c_int, + x2: c_int, + y2: c_int, + x3: c_int, + y3: c_int, + x4: c_int, + y4: c_int, + ) -> BOOL; + pub fn ChoosePixelFormat( + hdc: HDC, + ppfd: *const PIXELFORMATDESCRIPTOR, + ) -> c_int; + pub fn CloseMetaFile( + hdc: HDC, + ) -> HMETAFILE; + pub fn CombineRgn( + hrgnDst: HRGN, + hrgnSrc1: HRGN, + hrgnSrc2: HRGN, + iMode: c_int, + ) -> c_int; + pub fn CopyMetaFileA( + _: HMETAFILE, + _: LPCSTR, + ) -> HMETAFILE; + pub fn CopyMetaFileW( + _: HMETAFILE, + _: LPCWSTR, + ) -> HMETAFILE; + pub fn CreateBitmap( + nWidth: c_int, + nHeight: c_int, + nPlanes: UINT, + nBitCount: UINT, + lpBits: *const c_void, + ) -> HBITMAP; + pub fn CreateBitmapIndirect( + pbm: *const BITMAP, + ) -> HBITMAP; + pub fn CreateBrushIndirect( + plbrush: *const LOGBRUSH, + ) -> HBRUSH; + pub fn CreateCompatibleBitmap( + hdc: HDC, + cx: c_int, + cy: c_int, + ) -> HBITMAP; + pub fn CreateDiscardableBitmap( + hdc: HDC, + cx: c_int, + cy: c_int, + ) -> HBITMAP; + pub fn CreateCompatibleDC( + hdc: HDC, + ) -> HDC; + pub fn CreateDCA( + pwszDriver: LPCSTR, + pwszDevice: LPCSTR, + pszPort: LPCSTR, + pdm: *const DEVMODEA, + ) -> HDC; + pub fn CreateDCW( + pwszDriver: LPCWSTR, + pwszDevice: LPCWSTR, + pszPort: LPCWSTR, + pdm: *const DEVMODEW, + ) -> HDC; + pub fn CreateDIBitmap( + hdc: HDC, + pbmih: *const BITMAPINFOHEADER, + flInit: DWORD, + pjBits: *const c_void, + pbmi: *const BITMAPINFO, + iUsage: UINT, + ) -> HBITMAP; + pub fn CreateDIBPatternBrush( + h: HGLOBAL, + iUsage: UINT, + ) -> HBRUSH; + pub fn CreateDIBPatternBrushPt( + lpPackedDIB: *const c_void, + iUsage: UINT, + ) -> HBRUSH; + pub fn CreateEllipticRgn( + x1: c_int, + y1: c_int, + x2: c_int, + y2: c_int, + ) -> HRGN; + pub fn CreateEllipticRgnIndirect( + lprect: *const RECT, + ) -> HRGN; + pub fn CreateFontIndirectA( + lplf: *const LOGFONTA, + ) -> HFONT; + pub fn CreateFontIndirectW( + lplf: *const LOGFONTW, + ) -> HFONT; + pub fn CreateFontA( + cHeight: c_int, + cWidth: c_int, + cEscapement: c_int, + cOrientation: c_int, + cWeight: c_int, + bItalic: DWORD, + bUnderline: DWORD, + bStrikeOut: DWORD, + iCharSet: DWORD, + iOutPrecision: DWORD, + iClipPrecision: DWORD, + iQuality: DWORD, + iPitchAndFamily: DWORD, + pszFaceName: LPCSTR, + ) -> HFONT; + pub fn CreateFontW( + cHeight: c_int, + cWidth: c_int, + cEscapement: c_int, + cOrientation: c_int, + cWeight: c_int, + bItalic: DWORD, + bUnderline: DWORD, + bStrikeOut: DWORD, + iCharSet: DWORD, + iOutPrecision: DWORD, + iClipPrecision: DWORD, + iQuality: DWORD, + iPitchAndFamily: DWORD, + pszFaceName: LPCWSTR, + ) -> HFONT; + pub fn CreateHatchBrush( + iHatch: c_int, + color: COLORREF, + ) -> HBRUSH; + pub fn CreateICA( + pszDriver: LPCSTR, + pszDevice: LPCSTR, + pszPort: LPCSTR, + pdm: *const DEVMODEA, + ) -> HDC; + pub fn CreateICW( + pszDriver: LPCWSTR, + pszDevice: LPCWSTR, + pszPort: LPCWSTR, + pdm: *const DEVMODEW, + ) -> HDC; + pub fn CreateMetaFileA( + pszFile: LPCSTR, + ) -> HDC; + pub fn CreateMetaFileW( + pszFile: LPCWSTR, + ) -> HDC; + pub fn CreatePalette( + plpal: *const LOGPALETTE, + ) -> HPALETTE; + pub fn CreatePen( + iStyle: c_int, + cWidth: c_int, + color: COLORREF, + ) -> HPEN; + pub fn CreatePenIndirect( + plpen: *const LOGPEN, + ) -> HPEN; + pub fn CreatePolyPolygonRgn( + pptl: *const POINT, + pc: *const INT, + cPoly: c_int, + iMode: c_int, + ) -> HRGN; + pub fn CreatePatternBrush( + hbm: HBITMAP, + ) -> HBRUSH; + pub fn CreateRectRgn( + x1: c_int, + y1: c_int, + x2: c_int, + y2: c_int, + ) -> HRGN; + pub fn CreateRectRgnIndirect( + lprect: *const RECT, + ) -> HRGN; + pub fn CreateRoundRectRgn( + x1: c_int, + y1: c_int, + x2: c_int, + y2: c_int, + w: c_int, + h: c_int, + ) -> HRGN; + pub fn CreateScalableFontResourceA( + fdwHidden: DWORD, + lpszFont: LPCSTR, + lpszFile: LPCSTR, + lpszPath: LPCSTR, + ) -> BOOL; + pub fn CreateScalableFontResourceW( + fdwHidden: DWORD, + lpszFont: LPCWSTR, + lpszFile: LPCWSTR, + lpszPath: LPCWSTR, + ) -> BOOL; + pub fn CreateSolidBrush( + color: COLORREF, + ) -> HBRUSH; + pub fn DeleteDC( + hdc: HDC, + ) -> BOOL; + pub fn DeleteMetaFile( + hmf: HMETAFILE, + ) -> BOOL; + pub fn DeleteObject( + ho: HGDIOBJ, + ) -> BOOL; + pub fn DescribePixelFormat( + hdc: HDC, + iPixelFormat: c_int, + nBytes: UINT, + ppfd: LPPIXELFORMATDESCRIPTOR, + ) -> c_int; +} +FN!{stdcall LPFNDEVMODE( + HWND, + HMODULE, + LPDEVMODEA, + LPSTR, + LPSTR, + LPDEVMODEA, + LPSTR, + UINT, +) -> UINT} +FN!{stdcall LPFNDEVCAPS( + LPSTR, + LPSTR, + UINT, + LPSTR, + LPDEVMODEA, +) -> DWORD} +pub const DM_UPDATE: DWORD = 1; +pub const DM_COPY: DWORD = 2; +pub const DM_PROMPT: DWORD = 4; +pub const DM_MODIFY: DWORD = 8; +pub const DM_IN_BUFFER: DWORD = DM_MODIFY; +pub const DM_IN_PROMPT: DWORD = DM_PROMPT; +pub const DM_OUT_BUFFER: DWORD = DM_COPY; +pub const DM_OUT_DEFAULT: DWORD = DM_UPDATE; +pub const DC_FIELDS: WORD = 1; +pub const DC_PAPERS: WORD = 2; +pub const DC_PAPERSIZE: WORD = 3; +pub const DC_MINEXTENT: WORD = 4; +pub const DC_MAXEXTENT: WORD = 5; +pub const DC_BINS: WORD = 6; +pub const DC_DUPLEX: WORD = 7; +pub const DC_SIZE: WORD = 8; +pub const DC_EXTRA: WORD = 9; +pub const DC_VERSION: WORD = 10; +pub const DC_DRIVER: WORD = 11; +pub const DC_BINNAMES: WORD = 12; +pub const DC_ENUMRESOLUTIONS: WORD = 13; +pub const DC_FILEDEPENDENCIES: WORD = 14; +pub const DC_TRUETYPE: WORD = 15; +pub const DC_PAPERNAMES: WORD = 16; +pub const DC_ORIENTATION: WORD = 17; +pub const DC_COPIES: WORD = 18; +pub const DC_BINADJUST: WORD = 19; +pub const DC_EMF_COMPLIANT: WORD = 20; +pub const DC_DATATYPE_PRODUCED: WORD = 21; +pub const DC_COLLATE: WORD = 22; +pub const DC_MANUFACTURER: WORD = 23; +pub const DC_MODEL: WORD = 24; +pub const DC_PERSONALITY: WORD = 25; +pub const DC_PRINTRATE: WORD = 26; +pub const DC_PRINTRATEUNIT: WORD = 27; +pub const PRINTRATEUNIT_PPM: WORD = 1; +pub const PRINTRATEUNIT_CPS: WORD = 2; +pub const PRINTRATEUNIT_LPM: WORD = 3; +pub const PRINTRATEUNIT_IPM: WORD = 4; +pub const DC_PRINTERMEM: WORD = 28; +pub const DC_MEDIAREADY: WORD = 29; +pub const DC_STAPLE: WORD = 30; +pub const DC_PRINTRATEPPM: WORD = 31; +pub const DC_COLORDEVICE: WORD = 32; +pub const DC_NUP: WORD = 33; +pub const DC_MEDIATYPENAMES: WORD = 34; +pub const DC_MEDIATYPES: WORD = 35; +pub const DCTT_BITMAP: DWORD = 0x0000001; +pub const DCTT_DOWNLOAD: DWORD = 0x0000002; +pub const DCTT_SUBDEV: DWORD = 0x0000004; +pub const DCTT_DOWNLOAD_OUTLINE: DWORD = 0x0000008; +pub const DCBA_FACEUPNONE: DWORD = 0x0000; +pub const DCBA_FACEUPCENTER: DWORD = 0x0001; +pub const DCBA_FACEUPLEFT: DWORD = 0x0002; +pub const DCBA_FACEUPRIGHT: DWORD = 0x0003; +pub const DCBA_FACEDOWNNONE: DWORD = 0x0100; +pub const DCBA_FACEDOWNCENTER: DWORD = 0x0101; +pub const DCBA_FACEDOWNLEFT: DWORD = 0x0102; +pub const DCBA_FACEDOWNRIGHT: DWORD = 0x0103; +extern "system" { + pub fn DeviceCapabilitiesA( + pDevice: LPCSTR, + pPort: LPCSTR, + fwCapability: WORD, + pOutput: LPSTR, + pDevMode: *const DEVMODEA, + ) -> c_int; + pub fn DeviceCapabilitiesW( + pDevice: LPCWSTR, + pPort: LPCWSTR, + fwCapability: WORD, + pOutput: LPWSTR, + pDevMode: *const DEVMODEW, + ) -> c_int; + pub fn DrawEscape( + hdc: HDC, + iEscape: c_int, + cjIn: c_int, + lpIn: LPCSTR, + ) -> c_int; + pub fn Ellipse( + hdc: HDC, + left: c_int, + top: c_int, + right: c_int, + bottom: c_int, + ) -> BOOL; + pub fn EnumFontFamiliesExA( + hdc: HDC, + lpLogfont: LPLOGFONTA, + lpProc: FONTENUMPROCA, + lParam: LPARAM, + dwFlags: DWORD, + ) -> c_int; + pub fn EnumFontFamiliesExW( + hdc: HDC, + lpLogfont: LPLOGFONTW, + lpProc: FONTENUMPROCW, + lParam: LPARAM, + dwFlags: DWORD, + ) -> c_int; + pub fn EnumFontFamiliesA( + hdc: HDC, + lpLogfont: LPCSTR, + lpProc: FONTENUMPROCA, + lParam: LPARAM, + ) -> c_int; + pub fn EnumFontFamiliesW( + hdc: HDC, + lpLogfont: LPCWSTR, + lpProc: FONTENUMPROCW, + lParam: LPARAM, + ) -> c_int; + pub fn EnumFontsA( + hdc: HDC, + lpLogfont: LPCSTR, + lpProc: FONTENUMPROCA, + lParam: LPARAM, + ) -> c_int; + pub fn EnumFontsW( + hdc: HDC, + lpLogfont: LPCWSTR, + lpProc: FONTENUMPROCW, + lParam: LPARAM, + ) -> c_int; + pub fn EnumObjects( + hdc: HDC, + nType: c_int, + lpFunc: GOBJENUMPROC, + lParam: LPARAM, + ) -> c_int; + pub fn EqualRgn( + hrgn1: HRGN, + hrgn2: HRGN, + ) -> BOOL; + pub fn Escape( + hdc: HDC, + iEscape: c_int, + cjIn: c_int, + pvIn: LPCSTR, + pvOut: LPVOID, + ) -> c_int; + pub fn ExtEscape( + hdc: HDC, + iEscape: c_int, + cjInput: c_int, + lpInData: LPCSTR, + cjOutput: c_int, + lpOutData: LPSTR, + ) -> c_int; + pub fn ExcludeClipRect( + hdc: HDC, + left: c_int, + top: c_int, + right: c_int, + bottom: c_int, + ) -> c_int; + pub fn ExtCreateRegion( + lpx: *const XFORM, + nCount: DWORD, + lpData: *const RGNDATA, + ) -> HRGN; + pub fn ExtFloodFill( + hdc: HDC, + x: c_int, + y: c_int, + color: COLORREF, + utype: UINT, + ) -> BOOL; + pub fn FillRgn( + hdc: HDC, + hrgn: HRGN, + hbr: HBRUSH, + ) -> BOOL; + pub fn FloodFill( + hdc: HDC, + x: c_int, + y: c_int, + color: COLORREF, + ) -> BOOL; + pub fn FrameRgn( + hdc: HDC, + hrgn: HRGN, + hbr: HBRUSH, + w: c_int, + h: c_int, + ) -> BOOL; + pub fn GetROP2( + hdc: HDC, + ) -> c_int; + pub fn GetAspectRatioFilterEx( + hdc: HDC, + lpsize: LPSIZE, + ) -> BOOL; + pub fn GetBkColor( + hdc: HDC, + ) -> COLORREF; + pub fn GetDCBrushColor( + hdc: HDC, + ) -> COLORREF; + pub fn GetDCPenColor( + hdc: HDC, + ) -> COLORREF; + pub fn GetBkMode( + hdc: HDC, + ) -> c_int; + pub fn GetBitmapBits( + hbit: HBITMAP, + cb: LONG, + lpvBits: LPVOID, + ) -> LONG; + pub fn GetBitmapDimensionEx( + hbit: HBITMAP, + lpsize: LPSIZE, + ) -> BOOL; + pub fn GetBoundsRect( + hdc: HDC, + lprect: LPRECT, + flags: UINT, + ) -> UINT; + pub fn GetBrushOrgEx( + hdc: HDC, + lppt: LPPOINT, + ) -> BOOL; + pub fn GetCharWidthA( + hdc: HDC, + iFirst: UINT, + iLast: UINT, + lpBuffer: LPINT, + ) -> BOOL; + pub fn GetCharWidthW( + hdc: HDC, + iFirst: UINT, + iLast: UINT, + lpBuffer: LPINT, + ) -> BOOL; + pub fn GetCharWidth32A( + hdc: HDC, + iFirst: UINT, + iLast: UINT, + lpBuffer: LPINT, + ) -> BOOL; + pub fn GetCharWidth32W( + hdc: HDC, + iFirst: UINT, + iLast: UINT, + lpBuffer: LPINT, + ) -> BOOL; + pub fn GetCharWidthFloatA( + hdc: HDC, + iFirst: UINT, + iLast: UINT, + lpBuffer: PFLOAT, + ) -> BOOL; + pub fn GetCharWidthFloatW( + hdc: HDC, + iFirst: UINT, + iLast: UINT, + lpBuffer: PFLOAT, + ) -> BOOL; + pub fn GetCharABCWidthsA( + hdc: HDC, + wFirst: UINT, + wLast: UINT, + lpABC: LPABC, + ) -> BOOL; + pub fn GetCharABCWidthsW( + hdc: HDC, + wFirst: UINT, + wLast: UINT, + lpABC: LPABC, + ) -> BOOL; + pub fn GetCharABCWidthsFloatA( + hdc: HDC, + iFirst: UINT, + iLast: UINT, + lpABC: LPABCFLOAT, + ) -> BOOL; + pub fn GetCharABCWidthsFloatW( + hdc: HDC, + iFirst: UINT, + iLast: UINT, + lpABC: LPABCFLOAT, + ) -> BOOL; + pub fn GetClipBox( + hdc: HDC, + lprect: LPRECT, + ) -> c_int; + pub fn GetClipRgn( + hdc: HDC, + hrgn: HRGN, + ) -> c_int; + pub fn GetMetaRgn( + hdc: HDC, + hrgn: HRGN, + ) -> c_int; + pub fn GetCurrentObject( + hdc: HDC, + tp: UINT, + ) -> HGDIOBJ; + pub fn GetCurrentPositionEx( + hdc: HDC, + lppt: LPPOINT, + ) -> BOOL; + pub fn GetDeviceCaps( + hdc: HDC, + nIndex: c_int, + ) -> c_int; + pub fn GetDIBits( + hdc: HDC, + hbm: HBITMAP, + start: UINT, + cLines: UINT, + lpvBits: LPVOID, + lpbmi: LPBITMAPINFO, + usage: UINT, + ) -> c_int; + pub fn GetFontData( + hdc: HDC, + dwTable: DWORD, + dwOffset: DWORD, + pvBuffer: PVOID, + cjBuffer: DWORD, + ) -> DWORD; + pub fn GetGlyphOutlineA( + hdc: HDC, + uChar: UINT, + fuFormat: UINT, + lpgm: LPGLYPHMETRICS, + cjBuffer: DWORD, + pvBuffer: LPVOID, + lpmat2: *const MAT2, + ) -> DWORD; + pub fn GetGlyphOutlineW( + hdc: HDC, + uChar: UINT, + fuFormat: UINT, + lpgm: LPGLYPHMETRICS, + cjBuffer: DWORD, + pvBuffer: LPVOID, + lpmat2: *const MAT2, + ) -> DWORD; + pub fn GetGraphicsMode( + hdc: HDC, + ) -> c_int; + pub fn GetMapMode( + hdc: HDC, + ) -> c_int; + pub fn GetMetaFileBitsEx( + hMF: HMETAFILE, + cbBuffer: UINT, + lpData: LPVOID, + ) -> UINT; + pub fn GetMetaFileA( + lpName: LPCSTR, + ) -> HMETAFILE; + pub fn GetMetaFileW( + lpName: LPCWSTR, + ) -> HMETAFILE; + pub fn GetNearestColor( + hdc: HDC, + color: COLORREF, + ) -> COLORREF; + pub fn GetNearestPaletteIndex( + h: HPALETTE, + color: COLORREF, + ) -> UINT; + pub fn GetObjectType( + h: HGDIOBJ, + ) -> DWORD; + pub fn GetOutlineTextMetricsA( + hdc: HDC, + cjCopy: UINT, + potm: LPOUTLINETEXTMETRICA, + ) -> UINT; + pub fn GetOutlineTextMetricsW( + hdc: HDC, + cjCopy: UINT, + potm: LPOUTLINETEXTMETRICW, + ) -> UINT; + pub fn GetPaletteEntries( + hpal: HPALETTE, + iStart: UINT, + cEntries: UINT, + pPalEntries: LPPALETTEENTRY, + ) -> UINT; + pub fn GetPixel( + hdc: HDC, + x: c_int, + y: c_int, + ) -> COLORREF; + pub fn GetPixelFormat( + hdc: HDC, + ) -> c_int; + pub fn GetPolyFillMode( + hdc: HDC, + ) -> c_int; + pub fn GetRasterizerCaps( + lpraststat: LPRASTERIZER_STATUS, + cjBytes: UINT, + ) -> BOOL; + pub fn GetRandomRgn ( + hdc: HDC, + hrgn: HRGN, + i: INT, + ) -> c_int; + pub fn GetRegionData( + hrgn: HRGN, + nCount: DWORD, + lpRgnData: LPRGNDATA, + ) -> DWORD; + pub fn GetRgnBox( + hrgn: HRGN, + lprc: LPRECT, + ) -> c_int; + pub fn GetStockObject( + i: c_int, + ) -> HGDIOBJ; + pub fn GetStretchBltMode( + hdc: HDC, + ) -> c_int; + pub fn GetSystemPaletteEntries( + hdc: HDC, + iStart: UINT, + cEntries: UINT, + pPalEntries: LPPALETTEENTRY, + ) -> UINT; + pub fn GetSystemPaletteUse( + hdc: HDC, + ) -> UINT; + pub fn GetTextCharacterExtra( + hdc: HDC, + ) -> c_int; + pub fn GetTextAlign( + hdc: HDC, + ) -> UINT; + pub fn GetTextColor( + hdc: HDC, + ) -> COLORREF; + pub fn GetTextExtentPointA( + hdc: HDC, + lpString: LPCSTR, + c: c_int, + lpsz: LPSIZE, + ) -> BOOL; + pub fn GetTextExtentPointW( + hdc: HDC, + lpString: LPCWSTR, + c: c_int, + lpsz: LPSIZE, + ) -> BOOL; + pub fn GetTextExtentPoint32A( + hdc: HDC, + lpString: LPCSTR, + c: c_int, + psizl: LPSIZE, + ) -> BOOL; + pub fn GetTextExtentPoint32W( + hdc: HDC, + lpString: LPCWSTR, + c: c_int, + psizl: LPSIZE, + ) -> BOOL; + pub fn GetTextExtentExPointA( + hdc: HDC, + lpszString: LPCSTR, + cchString: c_int, + nMaxExtent: c_int, + lpnFit: LPINT, + lpnDx: LPINT, + lpSize: LPSIZE, + ) -> BOOL; + pub fn GetTextExtentExPointW( + hdc: HDC, + lpszString: LPCWSTR, + cchString: c_int, + nMaxExtent: c_int, + lpnFit: LPINT, + lpnDx: LPINT, + lpSize: LPSIZE, + ) -> BOOL; + pub fn GetTextCharset( + hdc: HDC, + ) -> c_int; + pub fn GetTextCharsetInfo( + hdc: HDC, + lpSig: LPFONTSIGNATURE, + dwFlags: DWORD, + ) -> c_int; + pub fn TranslateCharsetInfo( + lpSrc: *const DWORD, + lpCs: LPCHARSETINFO, + dwFlags: DWORD, + ) -> BOOL; + pub fn GetFontLanguageInfo( + hdc: HDC, + ) -> DWORD; + pub fn GetCharacterPlacementA( + hdc: HDC, + lpString: LPCSTR, + nCount: c_int, + nMexExtent: c_int, + lpResults: LPGCP_RESULTSA, + dwFlags: DWORD, + ) -> DWORD; + pub fn GetCharacterPlacementW( + hdc: HDC, + lpString: LPCWSTR, + nCount: c_int, + nMexExtent: c_int, + lpResults: LPGCP_RESULTSW, + dwFlags: DWORD, + ) -> DWORD; +} +STRUCT!{struct WCRANGE { + wcLow: WCHAR, + cGlyphs: USHORT, +}} +pub type PWCRANGE = *mut WCRANGE; +pub type LPWCRANGE = *mut WCRANGE; +STRUCT!{struct GLYPHSET { + cbThis: DWORD, + flAccel: DWORD, + cGlyphsSupported: DWORD, + cRanges: DWORD, + ranges: [WCRANGE;1], +}} +pub type PGLYPHSET = *mut GLYPHSET; +pub type LPGLYPHSET = *mut GLYPHSET; +pub const GS_8BIT_INDICES: DWORD = 0x00000001; +pub const GGI_MARK_NONEXISTING_GLYPHS: DWORD = 0x0001; +extern "system" { + pub fn GetFontUnicodeRanges( + hdc: HDC, + lpgs: LPGLYPHSET, + ) -> DWORD; + pub fn GetGlyphIndicesA( + hdc: HDC, + lpstr: LPCSTR, + c: c_int, + pgi: LPWORD, + fl: DWORD, + ) -> DWORD; + pub fn GetGlyphIndicesW( + hdc: HDC, + lpstr: LPCWSTR, + c: c_int, + pgi: LPWORD, + fl: DWORD, + ) -> DWORD; + pub fn GetTextExtentPointI( + hdc: HDC, + pgiIn: LPWORD, + cgi: c_int, + psize: LPSIZE, + ) -> BOOL; + pub fn GetTextExtentExPointI( + hdc: HDC, + lpwszString: LPWORD, + cwchString: c_int, + nMaxExtent: c_int, + lpnFit: LPINT, + lpnDx: LPINT, + lpSize: LPSIZE, + ) -> BOOL; + pub fn GetCharWidthI( + hdc: HDC, + giFirst: UINT, + cgi: UINT, + pgi: LPWORD, + piWidths: LPINT, + ) -> BOOL; + pub fn GetCharABCWidthsI( + hdc: HDC, + giFirst: UINT, + cgi: UINT, + pgi: LPWORD, + pabc: LPABC, + ) -> BOOL; +} +pub const STAMP_DESIGNVECTOR: DWORD = 0x8000000 + 0x64 + (0x76 << 8); +pub const STAMP_AXESLIST: DWORD = 0x8000000 + 0x61 + (0x6c << 8); +pub const STAMP_TRUETYPE_VARIATION: DWORD = 0x8000000 + 0x74 + (0x76 << 8); +pub const MM_MAX_NUMAXES: usize = 16; +STRUCT!{struct DESIGNVECTOR { + dvReserved: DWORD, + dvNumAxes: DWORD, + dvValues: [LONG; MM_MAX_NUMAXES], +}} +pub type PDESIGNVECTOR = *mut DESIGNVECTOR; +pub type LPDESIGNVECTOR = *mut DESIGNVECTOR; +extern "system" { + pub fn AddFontResourceExA( + lpszFilename: LPCSTR, + fl: DWORD, + pdv: PVOID, + ) -> c_int; + pub fn AddFontResourceExW( + lpszFilename: LPCWSTR, + fl: DWORD, + pdv: PVOID, + ) -> c_int; + pub fn RemoveFontResourceExA( + name: LPCSTR, + fl: DWORD, + pdv: PVOID, + ) -> BOOL; + pub fn RemoveFontResourceExW( + name: LPCWSTR, + fl: DWORD, + pdv: PVOID, + ) -> BOOL; + pub fn AddFontMemResourceEx( + pbFont: PVOID, + cbSize: DWORD, + pdv: PVOID, + pcFonts: *mut DWORD, + ) -> HANDLE; + pub fn RemoveFontMemResourceEx( + h: HANDLE, + ) -> BOOL; +} +pub const FR_PRIVATE: DWORD = 0x10; +pub const FR_NOT_ENUM: DWORD = 0x20; +pub const MM_MAX_AXES_NAMELEN: usize = 16; +STRUCT!{struct AXISINFOA { + axMinValue: LONG, + axMaxValue: LONG, + axAxisName: [BYTE; MM_MAX_AXES_NAMELEN], +}} +pub type PAXISINFOA = *mut AXISINFOA; +pub type LPAXISINFOA = *mut AXISINFOA; +STRUCT!{struct AXISINFOW { + axMinValue: LONG, + axMaxValue: LONG, + axAxisName: [WCHAR; MM_MAX_AXES_NAMELEN], +}} +pub type PAXISINFOW = *mut AXISINFOW; +pub type LPAXISINFOW = *mut AXISINFOW; +STRUCT!{struct AXESLISTA { + axlReserved: DWORD, + axlNumAxes: DWORD, + axlAxisInfo: [AXISINFOA; MM_MAX_AXES_NAMELEN], +}} +pub type PAXESLISTA = *mut AXESLISTA; +pub type LPAXESLISTA = *mut AXESLISTA; +STRUCT!{struct AXESLISTW { + axlReserved: DWORD, + axlNumAxes: DWORD, + axlAxisInfo: [AXISINFOW; MM_MAX_AXES_NAMELEN], +}} +pub type PAXESLISTW = *mut AXESLISTW; +pub type LPAXESLISTW = *mut AXESLISTW; +STRUCT!{struct ENUMLOGFONTEXDVA { + elfEnumLogfontEx: ENUMLOGFONTEXA, + elfDesignVector: DESIGNVECTOR, +}} +pub type PENUMLOGFONTEXDVA = *mut ENUMLOGFONTEXDVA; +pub type LPENUMLOGFONTEXDVA = *mut ENUMLOGFONTEXDVA; +STRUCT!{struct ENUMLOGFONTEXDVW { + elfEnumLogfontEx: ENUMLOGFONTEXW, + elfDesignVector: DESIGNVECTOR, +}} +pub type PENUMLOGFONTEXDVW = *mut ENUMLOGFONTEXDVW; +pub type LPENUMLOGFONTEXDVW = *mut ENUMLOGFONTEXDVW; +extern "system" { + pub fn CreateFontIndirectExA( + penumlfex: *const ENUMLOGFONTEXDVA, + ) -> HFONT; + pub fn CreateFontIndirectExW( + penumlfex: *const ENUMLOGFONTEXDVW, + ) -> HFONT; +} +STRUCT!{struct ENUMTEXTMETRICA { + etmNewTextMetricEx: NEWTEXTMETRICEXA, + etmAxesList: AXESLISTA, +}} +pub type PENUMTEXTMETRICA = *mut ENUMTEXTMETRICA; +pub type LPENUMTEXTMETRICA = *mut ENUMTEXTMETRICA; +STRUCT!{struct ENUMTEXTMETRICW { + etmNewTextMetricEx: NEWTEXTMETRICEXW, + etmAxesList: AXESLISTW, +}} +pub type PENUMTEXTMETRICW = *mut ENUMTEXTMETRICW; +pub type LPENUMTEXTMETRICW = *mut ENUMTEXTMETRICW; +extern "system" { + pub fn GetViewportExtEx( + hdc: HDC, + lpsize: LPSIZE, + ) -> BOOL; + pub fn GetViewportOrgEx( + hdc: HDC, + lppoint: LPPOINT, + ) -> BOOL; + pub fn GetWindowExtEx( + hdc: HDC, + lpsize: LPSIZE, + ) -> BOOL; + pub fn GetWindowOrgEx( + hdc: HDC, + lppoint: LPPOINT, + ) -> BOOL; + pub fn IntersectClipRect( + hdc: HDC, + left: c_int, + top: c_int, + right: c_int, + bottom: c_int, + ) -> c_int; + pub fn InvertRgn( + hdc: HDC, + hrgn: HRGN, + ) -> BOOL; + pub fn LineDDA( + nXStart: c_int, + nYStart: c_int, + nXEnd: c_int, + nYEnd: c_int, + lpLineFunc: LINEDDAPROC, + lpData: LPARAM, + ) -> BOOL; + pub fn LineTo( + hdc: HDC, + nXEnd: c_int, + nYEnd: c_int, + ) -> BOOL; + pub fn MaskBlt( + hdcDest: HDC, + xDest: c_int, + yDest: c_int, + width: c_int, + height: c_int, + hdcSrc: HDC, + xSrc: c_int, + ySrc: c_int, + hbmMask: HBITMAP, + xMask: c_int, + yMask: c_int, + rop: DWORD, + ) -> BOOL; + pub fn PlgBlt( + hdcDest: HDC, + lpPoint: *const POINT, + hdcSrc: HDC, + xSrc: c_int, + ySrc: c_int, + width: c_int, + height: c_int, + hbmMask: HBITMAP, + xMask: c_int, + yMask: c_int, + ) -> BOOL; + pub fn OffsetClipRgn( + hdc: HDC, + x: c_int, + y: c_int, + ) -> c_int; + pub fn OffsetRgn( + hrgn: HRGN, + x: c_int, + y: c_int, + ) -> c_int; + pub fn PatBlt( + hdc: HDC, + nXLeft: c_int, + nYLeft: c_int, + nWidth: c_int, + nHeight: c_int, + dwRop: DWORD, + ) -> BOOL; + pub fn Pie( + hdc: HDC, + nLeftRect: c_int, + nTopRect: c_int, + nRightRect: c_int, + nBottomRect: c_int, + nXRadial1: c_int, + nYRadial1: c_int, + nXRadial2: c_int, + nYRadial2: c_int, + ) -> BOOL; + pub fn PlayMetaFile( + hdc: HDC, + hmf: HMETAFILE, + ) -> BOOL; + pub fn PaintRgn( + hdc: HDC, + hrgn: HRGN, + ) -> BOOL; + pub fn PolyPolygon( + hdc: HDC, + lpPoints: *const POINT, + lpPolyCounts: *const INT, + cCount: DWORD, + ) -> BOOL; + pub fn PtInRegion( + hrgn: HRGN, + x: c_int, + y: c_int, + ) -> BOOL; + pub fn PtVisible( + hdc: HDC, + x: c_int, + y: c_int, + ) -> BOOL; + pub fn RectInRegion( + hrgn: HRGN, + lprect: *const RECT, + ) -> BOOL; + pub fn RectVisible( + hdc: HDC, + lprect: *const RECT, + ) -> BOOL; + pub fn Rectangle( + hdc: HDC, + left: c_int, + top: c_int, + right: c_int, + bottom: c_int, + ) -> BOOL; + pub fn RestoreDC( + hdc: HDC, + nSavedDC: c_int, + ) -> BOOL; + pub fn ResetDCA( + hdc: HDC, + lpdm: *const DEVMODEA, + ) -> HDC; + pub fn ResetDCW( + hdc: HDC, + lpdm: *const DEVMODEW, + ) -> HDC; + pub fn RealizePalette( + hdc: HDC, + ) -> UINT; + pub fn RemoveFontResourceA( + lpFileName: LPCSTR, + ) -> BOOL; + pub fn RemoveFontResourceW( + lpFileName: LPCWSTR, + ) -> BOOL; + pub fn RoundRect( + hdc: HDC, + nLeftRect: c_int, + nTopRect: c_int, + nRightRect: c_int, + nBottomRect: c_int, + nWidth: c_int, + nHeight: c_int, + ) -> BOOL; + pub fn ResizePalette( + hpal: HPALETTE, + n: UINT, + ) -> BOOL; + pub fn SaveDC( + hdc: HDC, + ) -> c_int; + pub fn SelectClipRgn( + hdc: HDC, + hrgn: HRGN, + ) -> c_int; + pub fn ExtSelectClipRgn( + hdc: HDC, + hrgn: HRGN, + mode: c_int, + ) -> c_int; + pub fn SetMetaRgn( + hdc: HDC, + ) -> c_int; + pub fn SelectObject( + hdc: HDC, + h: HGDIOBJ, + ) -> HGDIOBJ; + pub fn SelectPalette( + hdc: HDC, + hPal: HPALETTE, + bForceBkgd: BOOL, + ) -> HPALETTE; + pub fn SetBkColor( + hdc: HDC, + color: COLORREF, + ) -> COLORREF; + pub fn SetDCBrushColor( + hdc: HDC, + color: COLORREF, + ) -> COLORREF; + pub fn SetDCPenColor( + hdc: HDC, + color: COLORREF, + ) -> COLORREF; + pub fn SetBkMode( + hdc: HDC, + mode: c_int, + ) -> c_int; + pub fn SetBitmapBits( + hbm: HBITMAP, + cb: DWORD, + pvBits: *const VOID, + ) -> LONG; + pub fn SetBoundsRect( + hdc: HDC, + lprect: *const RECT, + flags: UINT, + ) -> UINT; + pub fn SetDIBits( + hdc: HDC, + hbm: HBITMAP, + start: UINT, + cLines: UINT, + lpBits: *const VOID, + lpbmi: *const BITMAPINFO, + ColorUse: UINT, + ) -> c_int; + pub fn SetDIBitsToDevice( + hdc: HDC, + xDest: c_int, + yDest: c_int, + w: DWORD, + h: DWORD, + xSrc: c_int, + ySrc: c_int, + StartScan: UINT, + cLines: UINT, + lpvBits: *const VOID, + lpbmi: *const BITMAPINFO, + ColorUse: UINT, + ) -> c_int; + pub fn SetMapperFlags( + hdc: HDC, + flags: DWORD, + ) -> DWORD; + pub fn SetGraphicsMode( + hdc: HDC, + iMode: c_int, + ) -> c_int; + pub fn SetMapMode( + hdc: HDC, + mode: c_int, + ) -> c_int; + pub fn SetLayout( + hdc: HDC, + l: DWORD, + ) -> DWORD; + pub fn GetLayout( + hdc: HDC, + ) -> DWORD; + pub fn SetMetaFileBitsEx( + cbBuffer: UINT, + lpData: *const BYTE, + ) -> HMETAFILE; + pub fn SetPaletteEntries( + hpal: HPALETTE, + iStart: UINT, + cEntries: UINT, + pPalEntries: *const PALETTEENTRY, + ) -> UINT; + pub fn SetPixel( + hdc: HDC, + x: c_int, + y: c_int, + color: COLORREF, + ) -> COLORREF; + pub fn SetPixelV( + hdc: HDC, + x: c_int, + y: c_int, + color: COLORREF, + ) -> BOOL; + pub fn SetPixelFormat( + hdc: HDC, + iPixelFormat: c_int, + ppfd: *const PIXELFORMATDESCRIPTOR, + ) -> BOOL; + pub fn SetPolyFillMode( + hdc: HDC, + iPolyFillMode: c_int, + ) -> c_int; + pub fn StretchBlt( + hdcDest: HDC, + xDest: c_int, + yDest: c_int, + wDest: c_int, + hDest: c_int, + hdcSrc: HDC, + xSrc: c_int, + ySrc: c_int, + wSrc: c_int, + hSrc: c_int, + rop: DWORD, + ) -> BOOL; + pub fn SetRectRgn( + hrgn: HRGN, + left: c_int, + top: c_int, + right: c_int, + bottom: c_int, + ) -> BOOL; + pub fn StretchDIBits( + hdc: HDC, + XDest: c_int, + YDest: c_int, + nDestWidth: c_int, + nDestHeight: c_int, + XSrc: c_int, + YSrc: c_int, + nSrcWidth: c_int, + nSrcHeight: c_int, + lpBits: *const VOID, + lpBitsInfo: *const BITMAPINFO, + iUsage: UINT, + dwRop: DWORD, + ) -> c_int; + pub fn SetROP2( + hdc: HDC, + rop2: c_int, + ) -> c_int; + pub fn SetStretchBltMode( + hdc: HDC, + mode: c_int, + ) -> c_int; + pub fn SetSystemPaletteUse( + hdc: HDC, + uuse: UINT, + ) -> UINT; + pub fn SetTextCharacterExtra( + hdc: HDC, + extra: c_int, + ) -> c_int; + pub fn SetTextColor( + hdc: HDC, + color: COLORREF, + ) -> COLORREF; + pub fn SetTextAlign( + hdc: HDC, + align: UINT, + ) -> UINT; + pub fn SetTextJustification( + hdc: HDC, + extra: c_int, + count: c_int, + ) -> BOOL; + pub fn UpdateColors( + hdc: HDC, + ) -> BOOL; +} +pub type COLOR16 = c_ushort; +STRUCT!{struct TRIVERTEX { + x: LONG, + y: LONG, + Red: COLOR16, + Green: COLOR16, + Blue: COLOR16, + Alpha: COLOR16, +}} +pub type PTRIVERTEX = *mut TRIVERTEX; +pub type LPTRIVERTEX = *mut TRIVERTEX; +STRUCT!{struct GRADIENT_RECT { + UpperLeft: ULONG, + LowerRight: ULONG, +}} +pub type PGRADIENT_RECT = *mut GRADIENT_RECT; +pub type LPGRADIENT_RECT = *mut GRADIENT_RECT; +STRUCT!{struct BLENDFUNCTION { + BlendOp: BYTE, + BlendFlags: BYTE, + SourceConstantAlpha: BYTE, + AlphaFormat: BYTE, +}} +pub type PBLENDFUNCTION = *mut BLENDFUNCTION; +pub const AC_SRC_OVER: BYTE = 0x00; +pub const AC_SRC_ALPHA: BYTE = 0x01; +extern "system" { + pub fn AlphaBlend( + hdcDest: HDC, + xoriginDest: c_int, + yoriginDest: c_int, + wDest: c_int, + hDest: c_int, + hdcSrc: HDC, + xoriginSrc: c_int, + yoriginSrc: c_int, + wSrc: c_int, + hSrc: c_int, + ftn: BLENDFUNCTION, + ) -> BOOL; + pub fn TransparentBlt( + hdcDest: HDC, + xoriginDest: c_int, + yoriginDest: c_int, + wDest: c_int, + hDest: c_int, + hdcSrc: HDC, + xoriginSrc: c_int, + yoriginSrc: c_int, + wSrc: c_int, + hSrc: c_int, + crTransparent: UINT, + ) -> BOOL; +} +pub const GRADIENT_FILL_RECT_H: ULONG = 0x00000000; +pub const GRADIENT_FILL_RECT_V: ULONG = 0x00000001; +pub const GRADIENT_FILL_TRIANGLE: ULONG = 0x00000002; +pub const GRADIENT_FILL_OP_FLAG: ULONG = 0x000000ff; +extern "system" { + pub fn GradientFill( + hdc: HDC, + pVertex: PTRIVERTEX, + nVertex: ULONG, + pMesh: PVOID, + nMesh: ULONG, + ulMode: ULONG, + ) -> BOOL; + pub fn GdiAlphaBlend( + hdcDest: HDC, + xoriginDest: c_int, + yoriginDest: c_int, + wDest: c_int, + hDest: c_int, + hdcSrc: HDC, + xoriginSrc: c_int, + yoriginSrc: c_int, + wSrc: c_int, + hSrc: c_int, + ftn: BLENDFUNCTION, + ) -> BOOL; + pub fn GdiTransparentBlt( + hdcDest: HDC, + xoriginDest: c_int, + yoriginDest: c_int, + wDest: c_int, + hDest: c_int, + hdcSrc: HDC, + xoriginSrc: c_int, + yoriginSrc: c_int, + wSrc: c_int, + hSrc: c_int, + crTransparent: UINT, + ) -> BOOL; + pub fn GdiGradientFill( + hdc: HDC, + pVertex: PTRIVERTEX, + nVertex: ULONG, + pMesh: PVOID, + nCount: ULONG, + ulMode: ULONG, + ) -> BOOL; + pub fn PlayMetaFileRecord( + hdc: HDC, + lpHandleTable: LPHANDLETABLE, + lpMR: LPMETARECORD, + noObjs: UINT, + ) -> BOOL; +} +FN!{stdcall MFENUMPROC( + hdc: HDC, + lpht: *mut HANDLETABLE, + lpMR: *mut METARECORD, + nObj: c_int, + param: LPARAM, +) -> c_int} +extern "system" { + pub fn EnumMetaFile( + hdc: HDC, + hmf: HMETAFILE, + mproc: MFENUMPROC, + param: LPARAM, + ) -> BOOL; +} +FN!{stdcall ENHMFENUMPROC( + hdc: HDC, + lpht: *mut HANDLETABLE, + lpmr: *const ENHMETARECORD, + nHandles: c_int, + data: LPARAM, +) -> c_int} +extern "system" { + pub fn CloseEnhMetaFile( + hdc: HDC, + ) -> HENHMETAFILE; + pub fn CopyEnhMetaFileA( + hemfSrc: HENHMETAFILE, + lpszFile: LPCSTR, + ) -> HENHMETAFILE; + pub fn CopyEnhMetaFileW( + hemfSrc: HENHMETAFILE, + lpszFile: LPCWSTR, + ) -> HENHMETAFILE; + pub fn CreateEnhMetaFileA( + hdcRef: HDC, + lpFilename: LPCSTR, + lpRect: *const RECT, + lpDescription: LPCSTR, + ) -> HDC; + pub fn CreateEnhMetaFileW( + hdcRef: HDC, + lpFilename: LPCWSTR, + lpRect: *const RECT, + lpDescription: LPCWSTR, + ) -> HDC; + pub fn DeleteEnhMetaFile( + hmf: HENHMETAFILE, + ) -> BOOL; + pub fn EnumEnhMetaFile( + hdc: HDC, + hmf: HENHMETAFILE, + lpProc: ENHMFENUMPROC, + param: LPVOID, + lpRect: *const RECT, + ) -> BOOL; + pub fn GetEnhMetaFileA( + lpName: LPCSTR, + ) -> HENHMETAFILE; + pub fn GetEnhMetaFileW( + lpName: LPCWSTR, + ) -> HENHMETAFILE; + pub fn GetEnhMetaFileBits( + hEMF: HENHMETAFILE, + nSize: UINT, + lpData: LPBYTE, + ) -> UINT; + pub fn GetEnhMetaFileDescriptionA( + hemf: HENHMETAFILE, + cchBuffer: UINT, + lpDescription: LPSTR, + ) -> UINT; + pub fn GetEnhMetaFileDescriptionW( + hemf: HENHMETAFILE, + cchBuffer: UINT, + lpDescription: LPWSTR, + ) -> UINT; + pub fn GetEnhMetaFileHeader( + hemf: HENHMETAFILE, + nSize: UINT, + lpEnhMetaHeader: LPENHMETAHEADER, + ) -> UINT; + pub fn GetEnhMetaFilePaletteEntries( + hemf: HENHMETAFILE, + nNumEntries: UINT, + lpPaletteEntries: LPPALETTEENTRY, + ) -> UINT; + pub fn GetEnhMetaFilePixelFormat( + hemf: HENHMETAFILE, + cbBuffer: UINT, + ppfd: *mut PIXELFORMATDESCRIPTOR, + ) -> UINT; + pub fn GetWinMetaFileBits( + hemf: HENHMETAFILE, + cbData16: UINT, + pData16: LPBYTE, + iMapMode: INT, + hdcRef: HDC, + ) -> UINT; + pub fn PlayEnhMetaFile( + hdc: HDC, + hmf: HENHMETAFILE, + lprect: *const RECT, + ) -> BOOL; + pub fn PlayEnhMetaFileRecord( + hdc: HDC, + pht: LPHANDLETABLE, + pmr: *const ENHMETARECORD, + cht: UINT, + ) -> BOOL; + pub fn SetEnhMetaFileBits( + nSize: UINT, + pb: *const BYTE, + ) -> HENHMETAFILE; + pub fn SetWinMetaFileBits( + nSize: UINT, + lpMeta16Data: *const BYTE, + hdcRef: HDC, + lpMFP: *const METAFILEPICT, + ) -> HENHMETAFILE; + pub fn GdiComment( + hdc: HDC, + nSize: UINT, + lpData: *const BYTE, + ) -> BOOL; + pub fn GetTextMetricsA( + hdc: HDC, + lptm: LPTEXTMETRICA, + ) -> BOOL; + pub fn GetTextMetricsW( + hdc: HDC, + lptm: *mut TEXTMETRICW, + ) -> BOOL; +} +STRUCT!{struct DIBSECTION { + dsBm: BITMAP, + dsBmih: BITMAPINFOHEADER, + dsBitfields: [DWORD; 3], + dshSection: HANDLE, + dsOffset: DWORD, +}} +pub type PDIBSECTION = *mut DIBSECTION; +pub type LPDIBSECTION = *mut DIBSECTION; +extern "system" { + pub fn AngleArc( + hdc: HDC, + X: c_int, + Y: c_int, + dwRadius: DWORD, + eStartAngle: FLOAT, + eSweepAngle: FLOAT, + ) -> BOOL; + pub fn PolyPolyline( + hdc: HDC, + lppt: *const POINT, + lpdwPolyPoints: *const DWORD, + cCount: DWORD, + ) -> BOOL; + pub fn GetWorldTransform( + hdc: HDC, + lpxf: LPXFORM, + ) -> BOOL; + pub fn SetWorldTransform( + hdc: HDC, + lpxf: *const XFORM, + ) -> BOOL; + pub fn ModifyWorldTransform( + hdc: HDC, + lpxf: *const XFORM, + mode: DWORD, + ) -> BOOL; + pub fn CombineTransform( + lpxformResult: LPXFORM, + lpxform1: *const XFORM, + lpxform2: *const XFORM, + ) -> BOOL; +} +#[inline] +pub fn GDI_WIDTHBYTES(bits: DWORD) -> DWORD { + ((bits + 31) & !31) / 8 +} +#[inline] +pub fn GDI_DIBWIDTHBYTES(bi: &BITMAPINFOHEADER) -> DWORD { + GDI_WIDTHBYTES((bi.biWidth as DWORD) * (bi.biBitCount as DWORD)) +} +#[inline] +pub fn GDI__DIBSIZE(bi: &BITMAPINFOHEADER) -> DWORD { + GDI_DIBWIDTHBYTES(bi) * bi.biHeight as DWORD +} +#[inline] +pub fn GDI_DIBSIZE(bi: &BITMAPINFOHEADER) -> DWORD { + if bi.biHeight < 0 { + GDI__DIBSIZE(bi) * -1i32 as u32 + } else { + GDI__DIBSIZE(bi) + } +} +extern "system" { + pub fn CreateDIBSection( + hdc: HDC, + lpbmi: *const BITMAPINFO, + usage: UINT, + ppvBits: *mut *mut c_void, + hSection: HANDLE, + offset: DWORD, + ) -> HBITMAP; + pub fn GetDIBColorTable( + hdc: HDC, + iStart: UINT, + cEntries: UINT, + prgbq: *mut RGBQUAD, + ) -> UINT; + pub fn SetDIBColorTable( + hdc: HDC, + iStart: UINT, + cEntries: UINT, + prgbq: *const RGBQUAD, + ) -> UINT; +} +pub const CA_NEGATIVE: WORD = 0x0001; +pub const CA_LOG_FILTER: WORD = 0x0002; +pub const ILLUMINANT_DEVICE_DEFAULT: WORD = 0; +pub const ILLUMINANT_A: WORD = 1; +pub const ILLUMINANT_B: WORD = 2; +pub const ILLUMINANT_C: WORD = 3; +pub const ILLUMINANT_D50: WORD = 4; +pub const ILLUMINANT_D55: WORD = 5; +pub const ILLUMINANT_D65: WORD = 6; +pub const ILLUMINANT_D75: WORD = 7; +pub const ILLUMINANT_F2: WORD = 8; +pub const ILLUMINANT_MAX_INDEX: WORD = ILLUMINANT_F2; +pub const ILLUMINANT_TUNGSTEN: WORD = ILLUMINANT_A; +pub const ILLUMINANT_DAYLIGHT: WORD = ILLUMINANT_C; +pub const ILLUMINANT_FLUORESCENT: WORD = ILLUMINANT_F2; +pub const ILLUMINANT_NTSC: WORD = ILLUMINANT_C; +pub const RGB_GAMMA_MIN: WORD = 0o2500; // FIXME It is octal in the headers but are the headers actually right? +pub const RGB_GAMMA_MAX: WORD = 65000; +pub const REFERENCE_WHITE_MIN: WORD = 6000; +pub const REFERENCE_WHITE_MAX: WORD = 10000; +pub const REFERENCE_BLACK_MIN: WORD = 0; +pub const REFERENCE_BLACK_MAX: WORD = 4000; +pub const COLOR_ADJ_MIN: SHORT = -100; +pub const COLOR_ADJ_MAX: SHORT = 100; +STRUCT!{struct COLORADJUSTMENT { + caSize: WORD, + caFlags: WORD, + caIlluminantIndex: WORD, + caRedGamma: WORD, + caGreenGamma: WORD, + caBlueGamma: WORD, + caReferenceBlack: WORD, + caReferenceWhite: WORD, + caContrast: SHORT, + caBrightness: SHORT, + caColorfulness: SHORT, + caRedGreenTint: SHORT, +}} +pub type PCOLORADJUSTMENT = *mut COLORADJUSTMENT; +pub type LPCOLORADJUSTMENT = *mut COLORADJUSTMENT; +extern "system" { + pub fn SetColorAdjustment( + hdc: HDC, + lpca: *const COLORADJUSTMENT, + ) -> BOOL; + pub fn GetColorAdjustment( + hdc: HDC, + lpca: LPCOLORADJUSTMENT, + ) -> BOOL; + pub fn CreateHalftonePalette( + hdc: HDC, + ) -> HPALETTE; +} +FN!{stdcall ABORTPROC( + HDC, + c_int, +) -> BOOL} +STRUCT!{struct DOCINFOA { + cbSize: c_int, + lpszDocName: LPCSTR, + lpszOutput: LPCSTR, + lpszDatatype: LPCSTR, + fwType: DWORD, +}} +pub type LPDOCINFOA = *mut DOCINFOA; +STRUCT!{struct DOCINFOW { + cbSize: c_int, + lpszDocName: LPCWSTR, + lpszOutput: LPCWSTR, + lpszDatatype: LPCWSTR, + fwType: DWORD, +}} +pub type LPDOCINFOW = *mut DOCINFOW; +pub const DI_APPBANDING: DWORD = 0x00000001; +pub const DI_ROPS_READ_DESTINATION: DWORD = 0x00000002; +extern "system" { + pub fn StartDocA( + hdc: HDC, + lpdi: *const DOCINFOA, + ) -> c_int; + pub fn StartDocW( + hdc: HDC, + lpdi: *const DOCINFOW, + ) -> c_int; + pub fn EndDoc( + hdc: HDC, + ) -> c_int; + pub fn StartPage( + hdc: HDC, + ) -> c_int; + pub fn EndPage( + hdc: HDC, + ) -> c_int; + pub fn AbortDoc( + hdc: HDC, + ) -> c_int; + pub fn SetAbortProc( + hdc: HDC, + aproc: ABORTPROC, + ) -> c_int; + pub fn AbortPath( + hdc: HDC, + ) -> BOOL; + pub fn ArcTo( + hdc: HDC, + nLeftRect: c_int, + nTopRect: c_int, + nRightRect: c_int, + nBottomRect: c_int, + nXRadial1: c_int, + nYRadial1: c_int, + nXRadial2: c_int, + nYRadial2: c_int, + ) -> BOOL; + pub fn BeginPath( + hdc: HDC, + ) -> BOOL; + pub fn CloseFigure( + hdc: HDC, + ) -> BOOL; + pub fn EndPath( + hdc: HDC, + ) -> BOOL; + pub fn FillPath( + hdc: HDC, + ) -> BOOL; + pub fn FlattenPath( + hdc: HDC, + ) -> BOOL; + pub fn GetPath( + hdc: HDC, + apt: LPPOINT, + aj: LPBYTE, + cpt: c_int, + ) -> c_int; + pub fn PathToRegion( + hdc: HDC, + ) -> HRGN; + pub fn PolyDraw( + hdc: HDC, + lppt: *const POINT, + lpbTypes: *const BYTE, + cCount: c_int, + ) -> BOOL; + pub fn SelectClipPath( + hdc: HDC, + mode: c_int, + ) -> BOOL; + pub fn SetArcDirection( + hdc: HDC, + ArcDirection: c_int, + ) -> c_int; + pub fn SetMiterLimit( + hdc: HDC, + limit: FLOAT, + old: PFLOAT, + ) -> BOOL; + pub fn StrokeAndFillPath( + hdc: HDC, + ) -> BOOL; + pub fn StrokePath( + hdc: HDC, + ) -> BOOL; + pub fn WidenPath( + hdc: HDC, + ) -> BOOL; + pub fn ExtCreatePen( + iPenStyle: DWORD, + cWidth: DWORD, + plbrush: *const LOGBRUSH, + cStyle: DWORD, + pstyle: *const DWORD, + ) -> HPEN; + pub fn GetMiterLimit( + hdc: HDC, + plimit: PFLOAT, + ) -> BOOL; + pub fn GetArcDirection( + hdc: HDC, + ) -> c_int; + pub fn GetObjectA( + h: HANDLE, + c: c_int, + pv: LPVOID, + ) -> c_int; + pub fn GetObjectW( + h: HANDLE, + c: c_int, + pv: LPVOID, + ) -> c_int; + pub fn MoveToEx( + hdc: HDC, + X: c_int, + Y: c_int, + lpPoint:LPPOINT, + ) -> BOOL; + pub fn TextOutA( + hdc: HDC, + x: c_int, + y: c_int, + lpString: LPCSTR, + c: c_int, + ) -> BOOL; + pub fn TextOutW( + hdc: HDC, + x: c_int, + y: c_int, + lpString: LPCWSTR, + c: c_int, + ) -> BOOL; + pub fn ExtTextOutA( + hdc: HDC, + x: c_int, + y: c_int, + options: UINT, + lprect: *const RECT, + lpString: LPCSTR, + c: UINT, + lpDx: *const INT, + ) -> BOOL; + pub fn ExtTextOutW( + hdc: HDC, + x: c_int, + y: c_int, + options: UINT, + lprect: *const RECT, + lpString: LPCWSTR, + c: UINT, + lpDx: *const INT, + ) -> BOOL; + pub fn PolyTextOutA( + hdc: HDC, + ppt: *const POLYTEXTA, + nstrings: c_int, + ) -> BOOL; + pub fn PolyTextOutW( + hdc: HDC, + ppt: *const POLYTEXTW, + nstrings: c_int, + ) -> BOOL; + pub fn CreatePolygonRgn( + lppt: *const POINT, + cPoints: c_int, + fnPolyFillMode: c_int, + ) -> HRGN; + pub fn DPtoLP( + hdc: HDC, + lppt: *mut POINT, + c: c_int, + ) -> BOOL; + pub fn LPtoDP( + hdc: HDC, + lppt: LPPOINT, + c: c_int, + ) -> BOOL; + pub fn Polygon( + hdc: HDC, + lpPoints: *const POINT, + nCount: c_int, + ) -> BOOL; + pub fn Polyline( + hdc: HDC, + lppt: *const POINT, + cCount: c_int, + ) -> BOOL; + pub fn PolyBezier( + hdc: HDC, + lppt: *const POINT, + cPoints: DWORD, + ) -> BOOL; + pub fn PolyBezierTo( + hdc: HDC, + lppt: *const POINT, + cPoints: DWORD, + ) -> BOOL; + pub fn PolylineTo( + hdc: HDC, + lppt: *const POINT, + cCount: DWORD, + ) -> BOOL; + pub fn SetViewportExtEx( + hdc: HDC, + x: c_int, + y: c_int, + lpsz: LPSIZE, + ) -> BOOL; + pub fn SetViewportOrgEx( + hdc: HDC, + x: c_int, + y: c_int, + lppt: *mut POINT, + ) -> BOOL; + pub fn SetWindowExtEx( + hdc: HDC, + x: c_int, + y: c_int, + lppt: LPSIZE, + ) -> BOOL; + pub fn SetWindowOrgEx( + hdc: HDC, + x: c_int, + y: c_int, + lppt: LPPOINT, + ) -> BOOL; + pub fn OffsetViewportOrgEx( + hdc: HDC, + x: c_int, + y: c_int, + lppt: LPPOINT, + ) -> BOOL; + pub fn OffsetWindowOrgEx( + hdc: HDC, + x: c_int, + y: c_int, + lppt: LPPOINT, + ) -> BOOL; + pub fn ScaleViewportExtEx( + hdc: HDC,xn: c_int, + dx: c_int, + yn: c_int, + yd: c_int, + lpsz: LPSIZE, + ) -> BOOL; + pub fn ScaleWindowExtEx( + hdc: HDC, + xn: c_int, + xd: c_int, + yn: c_int, + yd: c_int, + lpsz: LPSIZE, + ) -> BOOL; + pub fn SetBitmapDimensionEx( + hbm: HBITMAP, + w: c_int, + h: c_int, + lpsz: LPSIZE, + ) -> BOOL; + pub fn SetBrushOrgEx( + hdc: HDC, + x: c_int, + y: c_int, + lppt: LPPOINT, + ) -> BOOL; + pub fn GetTextFaceA( + hdc: HDC, + c: c_int, + lpName: LPSTR, + ) -> c_int; + pub fn GetTextFaceW( + hdc: HDC, + c: c_int, + lpName: LPWSTR, + ) -> c_int; +} +STRUCT!{struct KERNINGPAIR { + wFirst: WORD, + wSecond: WORD, + iKernAmount: c_int, +}} +pub type LPKERNINGPAIR = *mut KERNINGPAIR; +extern "system" { + pub fn GetKerningPairsA( + hdc: HDC, + nPairs: DWORD, + lpKernPair: LPKERNINGPAIR, + ) -> DWORD; + pub fn GetKerningPairsW( + hdc: HDC, + nPairs: DWORD, + lpKernPair: LPKERNINGPAIR, + ) -> DWORD; + pub fn GetDCOrgEx( + hdc: HDC, + lppt: LPPOINT, + ) -> BOOL; + pub fn FixBrushOrgEx( + hdc: HDC, + x: c_int, + y: c_int, + ptl: LPPOINT, + ) -> BOOL; + pub fn UnrealizeObject( + h: HGDIOBJ, + ) -> BOOL; + pub fn GdiFlush() -> BOOL; + pub fn GdiSetBatchLimit( + dw: DWORD, + ) -> DWORD; + pub fn GdiGetBatchLimit() -> DWORD; +} +pub const ICM_OFF: c_int = 1; +pub const ICM_ON: c_int = 2; +pub const ICM_QUERY: c_int = 3; +pub const ICM_DONE_OUTSIDEDC: c_int = 4; +FN!{stdcall ICMENUMPROCA( + LPSTR, + LPARAM, +) -> c_int} +FN!{stdcall ICMENUMPROCW( + LPWSTR, + LPARAM, +) -> c_int} +extern "system" { + pub fn SetICMMode( + hdc: HDC, + mode: c_int, + ) -> c_int; + pub fn CheckColorsInGamut( + hDC: HDC, + lpRGBTriples: LPVOID, + lpBuffer: LPVOID, + nCount: UINT, + ) -> BOOL; + pub fn GetColorSpace( + hdc: HDC, + ) -> HCOLORSPACE; + pub fn GetLogColorSpaceA( + hColorSpace: HCOLORSPACE, + lpBuffer: LPLOGCOLORSPACEA, + nSize: DWORD, + ) -> BOOL; + pub fn GetLogColorSpaceW( + hColorSpace: HCOLORSPACE, + lpBuffer: LPLOGCOLORSPACEW, + nSize: DWORD, + ) -> BOOL; + pub fn CreateColorSpaceA( + lpLogColorSpace: LPLOGCOLORSPACEA, + ) -> HCOLORSPACE; + pub fn CreateColorSpaceW( + lpLogColorSpace: LPLOGCOLORSPACEW, + ) -> HCOLORSPACE; + pub fn SetColorSpace( + hdc: HDC, + hcs: HCOLORSPACE, + ) -> HCOLORSPACE; + pub fn DeleteColorSpace( + hcs: HCOLORSPACE, + ) -> BOOL; + pub fn GetICMProfileA( + hdc: HDC, + pBufSize: LPDWORD, + pszFilename: LPSTR, + ) -> BOOL; + pub fn GetICMProfileW( + hdc: HDC, + pBufSize: LPDWORD, + pszFilename: LPWSTR, + ) -> BOOL; + pub fn SetICMProfileA( + hdc: HDC, + lpFileName: LPSTR, + ) -> BOOL; + pub fn SetICMProfileW( + hdc: HDC, + lpFileName: LPWSTR, + ) -> BOOL; + pub fn GetDeviceGammaRamp( + hdc: HDC, + lpRamp: LPVOID, + ) -> BOOL; + pub fn SetDeviceGammaRamp( + hdc: HDC, + lpRamp: LPVOID, + ) -> BOOL; + pub fn ColorMatchToTarget( + hDC: HDC, + hdcTarget: HDC, + uiAction: UINT, + ) -> BOOL; + pub fn EnumICMProfilesA( + hdc: HDC, + iproc: ICMENUMPROCA, + param: LPARAM, + ) -> c_int; + pub fn EnumICMProfilesW( + hdc: HDC, + iproc: ICMENUMPROCW, + param: LPARAM, + ) -> c_int; + pub fn UpdateICMRegKeyA( + reserved: DWORD, + lpszCMID: LPSTR, + lpszFileName: LPSTR, + command: UINT, + ) -> BOOL; + pub fn UpdateICMRegKeyW( + reserved: DWORD, + lpszCMID: LPWSTR, + lpszFileName: LPWSTR, + command: UINT, + ) -> BOOL; + pub fn ColorCorrectPalette( + hDC: HDC, + hPalette: HPALETTE, + dwFirstEntry: DWORD, + dwNumOfEntries: DWORD, + ) -> BOOL; +} +pub const ENHMETA_SIGNATURE: DWORD = 0x464D4520; +pub const ENHMETA_STOCK_OBJECT: DWORD = 0x80000000; +pub const EMR_HEADER: DWORD = 1; +pub const EMR_POLYBEZIER: DWORD = 2; +pub const EMR_POLYGON: DWORD = 3; +pub const EMR_POLYLINE: DWORD = 4; +pub const EMR_POLYBEZIERTO: DWORD = 5; +pub const EMR_POLYLINETO: DWORD = 6; +pub const EMR_POLYPOLYLINE: DWORD = 7; +pub const EMR_POLYPOLYGON: DWORD = 8; +pub const EMR_SETWINDOWEXTEX: DWORD = 9; +pub const EMR_SETWINDOWORGEX: DWORD = 10; +pub const EMR_SETVIEWPORTEXTEX: DWORD = 11; +pub const EMR_SETVIEWPORTORGEX: DWORD = 12; +pub const EMR_SETBRUSHORGEX: DWORD = 13; +pub const EMR_EOF: DWORD = 14; +pub const EMR_SETPIXELV: DWORD = 15; +pub const EMR_SETMAPPERFLAGS: DWORD = 16; +pub const EMR_SETMAPMODE: DWORD = 17; +pub const EMR_SETBKMODE: DWORD = 18; +pub const EMR_SETPOLYFILLMODE: DWORD = 19; +pub const EMR_SETROP2: DWORD = 20; +pub const EMR_SETSTRETCHBLTMODE: DWORD = 21; +pub const EMR_SETTEXTALIGN: DWORD = 22; +pub const EMR_SETCOLORADJUSTMENT: DWORD = 23; +pub const EMR_SETTEXTCOLOR: DWORD = 24; +pub const EMR_SETBKCOLOR: DWORD = 25; +pub const EMR_OFFSETCLIPRGN: DWORD = 26; +pub const EMR_MOVETOEX: DWORD = 27; +pub const EMR_SETMETARGN: DWORD = 28; +pub const EMR_EXCLUDECLIPRECT: DWORD = 29; +pub const EMR_INTERSECTCLIPRECT: DWORD = 30; +pub const EMR_SCALEVIEWPORTEXTEX: DWORD = 31; +pub const EMR_SCALEWINDOWEXTEX: DWORD = 32; +pub const EMR_SAVEDC: DWORD = 33; +pub const EMR_RESTOREDC: DWORD = 34; +pub const EMR_SETWORLDTRANSFORM: DWORD = 35; +pub const EMR_MODIFYWORLDTRANSFORM: DWORD = 36; +pub const EMR_SELECTOBJECT: DWORD = 37; +pub const EMR_CREATEPEN: DWORD = 38; +pub const EMR_CREATEBRUSHINDIRECT: DWORD = 39; +pub const EMR_DELETEOBJECT: DWORD = 40; +pub const EMR_ANGLEARC: DWORD = 41; +pub const EMR_ELLIPSE: DWORD = 42; +pub const EMR_RECTANGLE: DWORD = 43; +pub const EMR_ROUNDRECT: DWORD = 44; +pub const EMR_ARC: DWORD = 45; +pub const EMR_CHORD: DWORD = 46; +pub const EMR_PIE: DWORD = 47; +pub const EMR_SELECTPALETTE: DWORD = 48; +pub const EMR_CREATEPALETTE: DWORD = 49; +pub const EMR_SETPALETTEENTRIES: DWORD = 50; +pub const EMR_RESIZEPALETTE: DWORD = 51; +pub const EMR_REALIZEPALETTE: DWORD = 52; +pub const EMR_EXTFLOODFILL: DWORD = 53; +pub const EMR_LINETO: DWORD = 54; +pub const EMR_ARCTO: DWORD = 55; +pub const EMR_POLYDRAW: DWORD = 56; +pub const EMR_SETARCDIRECTION: DWORD = 57; +pub const EMR_SETMITERLIMIT: DWORD = 58; +pub const EMR_BEGINPATH: DWORD = 59; +pub const EMR_ENDPATH: DWORD = 60; +pub const EMR_CLOSEFIGURE: DWORD = 61; +pub const EMR_FILLPATH: DWORD = 62; +pub const EMR_STROKEANDFILLPATH: DWORD = 63; +pub const EMR_STROKEPATH: DWORD = 64; +pub const EMR_FLATTENPATH: DWORD = 65; +pub const EMR_WIDENPATH: DWORD = 66; +pub const EMR_SELECTCLIPPATH: DWORD = 67; +pub const EMR_ABORTPATH: DWORD = 68; +pub const EMR_GDICOMMENT: DWORD = 70; +pub const EMR_FILLRGN: DWORD = 71; +pub const EMR_FRAMERGN: DWORD = 72; +pub const EMR_INVERTRGN: DWORD = 73; +pub const EMR_PAINTRGN: DWORD = 74; +pub const EMR_EXTSELECTCLIPRGN: DWORD = 75; +pub const EMR_BITBLT: DWORD = 76; +pub const EMR_STRETCHBLT: DWORD = 77; +pub const EMR_MASKBLT: DWORD = 78; +pub const EMR_PLGBLT: DWORD = 79; +pub const EMR_SETDIBITSTODEVICE: DWORD = 80; +pub const EMR_STRETCHDIBITS: DWORD = 81; +pub const EMR_EXTCREATEFONTINDIRECTW: DWORD = 82; +pub const EMR_EXTTEXTOUTA: DWORD = 83; +pub const EMR_EXTTEXTOUTW: DWORD = 84; +pub const EMR_POLYBEZIER16: DWORD = 85; +pub const EMR_POLYGON16: DWORD = 86; +pub const EMR_POLYLINE16: DWORD = 87; +pub const EMR_POLYBEZIERTO16: DWORD = 88; +pub const EMR_POLYLINETO16: DWORD = 89; +pub const EMR_POLYPOLYLINE16: DWORD = 90; +pub const EMR_POLYPOLYGON16: DWORD = 91; +pub const EMR_POLYDRAW16: DWORD = 92; +pub const EMR_CREATEMONOBRUSH: DWORD = 93; +pub const EMR_CREATEDIBPATTERNBRUSHPT: DWORD = 94; +pub const EMR_EXTCREATEPEN: DWORD = 95; +pub const EMR_POLYTEXTOUTA: DWORD = 96; +pub const EMR_POLYTEXTOUTW: DWORD = 97; +pub const EMR_SETICMMODE: DWORD = 98; +pub const EMR_CREATECOLORSPACE: DWORD = 99; +pub const EMR_SETCOLORSPACE: DWORD = 100; +pub const EMR_DELETECOLORSPACE: DWORD = 101; +pub const EMR_GLSRECORD: DWORD = 102; +pub const EMR_GLSBOUNDEDRECORD: DWORD = 103; +pub const EMR_PIXELFORMAT: DWORD = 104; +pub const EMR_RESERVED_105: DWORD = 105; +pub const EMR_RESERVED_106: DWORD = 106; +pub const EMR_RESERVED_107: DWORD = 107; +pub const EMR_RESERVED_108: DWORD = 108; +pub const EMR_RESERVED_109: DWORD = 109; +pub const EMR_RESERVED_110: DWORD = 110; +pub const EMR_COLORCORRECTPALETTE: DWORD = 111; +pub const EMR_SETICMPROFILEA: DWORD = 112; +pub const EMR_SETICMPROFILEW: DWORD = 113; +pub const EMR_ALPHABLEND: DWORD = 114; +pub const EMR_SETLAYOUT: DWORD = 115; +pub const EMR_TRANSPARENTBLT: DWORD = 116; +pub const EMR_RESERVED_117: DWORD = 117; +pub const EMR_GRADIENTFILL: DWORD = 118; +pub const EMR_RESERVED_119: DWORD = 119; +pub const EMR_RESERVED_120: DWORD = 120; +pub const EMR_COLORMATCHTOTARGETW: DWORD = 121; +pub const EMR_CREATECOLORSPACEW: DWORD = 122; +pub const EMR_MIN: DWORD = 1; +pub const EMR_MAX: DWORD = 122; +STRUCT!{struct EMR { + iType: DWORD, + nSize: DWORD, +}} +pub type PEMR = *mut EMR; +STRUCT!{struct EMRTEXT { + ptlReference: POINTL, + nChars: DWORD, + offString: DWORD, + fOptions: DWORD, + rcl: RECTL, + offDx: DWORD, +}} +pub type PEMRTEXT = *mut EMRTEXT; +STRUCT!{struct EMRABORTPATH { + emr: EMR, +}} +pub type PEMRABORTPATH = *mut EMRABORTPATH; +pub type EMRBEGINPATH = EMRABORTPATH; +pub type PEMRBEGINPATH = *mut EMRABORTPATH; +pub type EMRENDPATH = EMRABORTPATH; +pub type PEMRENDPATH = *mut EMRABORTPATH; +pub type EMRCLOSEFIGURE = EMRABORTPATH; +pub type PEMRCLOSEFIGURE = *mut EMRABORTPATH; +pub type EMRFLATTENPATH = EMRABORTPATH; +pub type PEMRFLATTENPATH = *mut EMRABORTPATH; +pub type EMRWIDENPATH = EMRABORTPATH; +pub type PEMRWIDENPATH = *mut EMRABORTPATH; +pub type EMRSETMETARGN = EMRABORTPATH; +pub type PEMRSETMETARGN = *mut EMRABORTPATH; +pub type EMRSAVEDC = EMRABORTPATH; +pub type PEMRSAVEDC = *mut EMRABORTPATH; +pub type EMRREALIZEPALETTE = EMRABORTPATH; +pub type PEMRREALIZEPALETTE = *mut EMRABORTPATH; +STRUCT!{struct EMRSELECTCLIPPATH { + emr: EMR, + iMode: DWORD, +}} +pub type PEMRSELECTCLIPPATH = *mut EMRSELECTCLIPPATH; +pub type EMRSETBKMODE = EMRSELECTCLIPPATH; +pub type PEMRSETBKMODE = *mut EMRSELECTCLIPPATH; +pub type EMRSETMAPMODE = EMRSELECTCLIPPATH; +pub type PEMRSETMAPMODE = *mut EMRSELECTCLIPPATH; +pub type EMRSETLAYOUT = EMRSELECTCLIPPATH; +pub type PEMRSETLAYOUT = *mut EMRSELECTCLIPPATH; +pub type EMRSETPOLYFILLMODE = EMRSELECTCLIPPATH; +pub type PEMRSETPOLYFILLMODE = *mut EMRSELECTCLIPPATH; +pub type EMRSETROP2 = EMRSELECTCLIPPATH; +pub type PEMRSETROP2 = *mut EMRSELECTCLIPPATH; +pub type EMRSETSTRETCHBLTMODE = EMRSELECTCLIPPATH; +pub type PEMRSETSTRETCHBLTMODE = *mut EMRSELECTCLIPPATH; +pub type EMRSETICMMODE = EMRSELECTCLIPPATH; +pub type PEMRSETICMMODE = *mut EMRSELECTCLIPPATH; +pub type EMRSETTEXTALIGN = EMRSELECTCLIPPATH; +pub type PEMRSETTEXTALIGN = *mut EMRSELECTCLIPPATH; +STRUCT!{struct EMRSETMITERLIMIT { + emr: EMR, + eMiterLimit: FLOAT, +}} +pub type PEMRSETMITERLIMIT = *mut EMRSETMITERLIMIT; +STRUCT!{struct EMRRESTOREDC { + emr: EMR, + iRelative: LONG, +}} +pub type PEMRRESTOREDC = *mut EMRRESTOREDC; +STRUCT!{struct EMRSETARCDIRECTION { + emr: EMR, + iArcDirection: DWORD, +}} +pub type PEMRSETARCDIRECTION = *mut EMRSETARCDIRECTION; +STRUCT!{struct EMRSETMAPPERFLAGS { + emr: EMR, + dwFlags: DWORD, +}} +pub type PEMRSETMAPPERFLAGS = *mut EMRSETMAPPERFLAGS; +STRUCT!{struct EMRSETBKCOLOR { + emr: EMR, + crColor: COLORREF, +}} +pub type PEMRSETBKCOLOR = *mut EMRSETBKCOLOR; +pub type EMRSETTEXTCOLOR = EMRSETBKCOLOR; +pub type PEMRSETTEXTCOLOR = *mut EMRSETBKCOLOR; +STRUCT!{struct EMRSELECTOBJECT { + emr: EMR, + ihObject: DWORD, +}} +pub type PEMRSELECTOBJECT = *mut EMRSELECTOBJECT; +pub type EMRDELETEOBJECT = EMRSELECTOBJECT; +pub type PEMRDELETEOBJECT = *mut EMRSELECTOBJECT; +STRUCT!{struct EMRSELECTPALETTE { + emr: EMR, + ihPal: DWORD, +}} +pub type PEMRSELECTPALETTE = *mut EMRSELECTPALETTE; +STRUCT!{struct EMRRESIZEPALETTE { + emr: EMR, + ihPal: DWORD, + cEntries: DWORD, +}} +pub type PEMRRESIZEPALETTE = *mut EMRRESIZEPALETTE; +STRUCT!{struct EMRSETPALETTEENTRIES { + emr: EMR, + ihPal: DWORD, + iStart: DWORD, + cEntries: DWORD, + aPalEntries: [PALETTEENTRY; 1], +}} +pub type PEMRSETPALETTEENTRIES = *mut EMRSETPALETTEENTRIES; +STRUCT!{struct EMRSETCOLORADJUSTMENT { + emr: EMR, + ColorAdjustment: COLORADJUSTMENT, +}} +pub type PEMRSETCOLORADJUSTMENT = *mut EMRSETCOLORADJUSTMENT; +STRUCT!{struct EMRGDICOMMENT { + emr: EMR, + cbData: DWORD, + Data: [BYTE; 1], +}} +pub type PEMRGDICOMMENT = *mut EMRGDICOMMENT; +STRUCT!{struct EMREOF { + emr: EMR, + nPalEntries: DWORD, + offPalEntries: DWORD, + nSizeLast: DWORD, +}} +pub type PEMREOF = *mut EMREOF; +STRUCT!{struct EMRLINETO { + emr: EMR, + ptl: POINTL, +}} +pub type PEMRLINETO = *mut EMRLINETO; +pub type EMRMOVETOEX = EMRLINETO; +pub type PEMRMOVETOEX = *mut EMRLINETO; +STRUCT!{struct EMROFFSETCLIPRGN { + emr: EMR, + ptlOffset: POINTL, +}} +pub type PEMROFFSETCLIPRGN = *mut EMROFFSETCLIPRGN; +STRUCT!{struct EMRFILLPATH { + emr: EMR, + rclBounds: RECTL, +}} +pub type PEMRFILLPATH = *mut EMRFILLPATH; +pub type EMRSTROKEANDFILLPATH = EMRFILLPATH; +pub type PEMRSTROKEANDFILLPATH = *mut EMRFILLPATH; +pub type EMRSTROKEPATH = EMRFILLPATH; +pub type PEMRSTROKEPATH = *mut EMRFILLPATH; +STRUCT!{struct EMREXCLUDECLIPRECT { + emr: EMR, + rclClip: RECTL, +}} +pub type PEMREXCLUDECLIPRECT = *mut EMREXCLUDECLIPRECT; +pub type EMRINTERSECTCLIPRECT = EMREXCLUDECLIPRECT; +pub type PEMRINTERSECTCLIPRECT = *mut EMREXCLUDECLIPRECT; +STRUCT!{struct EMRSETVIEWPORTORGEX { + emr: EMR, + ptlOrigin: POINTL, +}} +pub type PEMRSETVIEWPORTORGEX = *mut EMRSETVIEWPORTORGEX; +pub type EMRSETWINDOWORGEX = EMRSETVIEWPORTORGEX; +pub type PEMRSETWINDOWORGEX = *mut EMRSETVIEWPORTORGEX; +pub type EMRSETBRUSHORGEX = EMRSETVIEWPORTORGEX; +pub type PEMRSETBRUSHORGEX = *mut EMRSETVIEWPORTORGEX; +STRUCT!{struct EMRSETVIEWPORTEXTEX { + emr: EMR, + szlExtent: SIZEL, +}} +pub type PEMRSETVIEWPORTEXTEX = *mut EMRSETVIEWPORTEXTEX; +pub type EMRSETWINDOWEXTEX = EMRSETVIEWPORTEXTEX; +pub type PEMRSETWINDOWEXTEX = *mut EMRSETVIEWPORTEXTEX; +STRUCT!{struct EMRSCALEVIEWPORTEXTEX { + emr: EMR, + xNum: LONG, + xDenom: LONG, + yNum: LONG, + yDenom: LONG, +}} +pub type PEMRSCALEVIEWPORTEXTEX = *mut EMRSCALEVIEWPORTEXTEX; +pub type EMRSCALEWINDOWEXTEX = EMRSCALEVIEWPORTEXTEX; +pub type PEMRSCALEWINDOWEXTEX = *mut EMRSCALEVIEWPORTEXTEX; +STRUCT!{struct EMRSETWORLDTRANSFORM { + emr: EMR, + xform: XFORM, +}} +pub type PEMRSETWORLDTRANSFORM = *mut EMRSETWORLDTRANSFORM; +STRUCT!{struct EMRMODIFYWORLDTRANSFORM { + emr: EMR, + xform: XFORM, + iMode: DWORD, +}} +pub type PEMRMODIFYWORLDTRANSFORM = *mut EMRMODIFYWORLDTRANSFORM; +STRUCT!{struct EMRSETPIXELV { + emr: EMR, + ptlPixel: POINTL, + crColor: COLORREF, +}} +pub type PEMRSETPIXELV = *mut EMRSETPIXELV; +STRUCT!{struct EMREXTFLOODFILL { + emr: EMR, + ptlStart: POINTL, + crColor: COLORREF, + iMode: DWORD, +}} +pub type PEMREXTFLOODFILL = *mut EMREXTFLOODFILL; +STRUCT!{struct EMRELLIPSE { + emr: EMR, + rclBox: RECTL, +}} +pub type PEMRELLIPSE = *mut EMRELLIPSE; +pub type EMRRECTANGLE = EMRELLIPSE; +pub type PEMRRECTANGLE = *mut EMRELLIPSE; +STRUCT!{struct EMRROUNDRECT { + emr: EMR, + rclBox: RECTL, + szlCorner: SIZEL, +}} +pub type PEMRROUNDRECT = *mut EMRROUNDRECT; +STRUCT!{struct EMRARC { + emr: EMR, + rclBox: RECTL, + ptlStart: POINTL, + ptlEnd: POINTL, +}} +pub type PEMRARC = *mut EMRARC; +pub type EMRARCTO = EMRARC; +pub type PEMRARCTO = *mut EMRARC; +pub type EMRCHORD = EMRARC; +pub type PEMRCHORD = *mut EMRARC; +pub type EMRPIE = EMRARC; +pub type PEMRPIE = *mut EMRARC; +STRUCT!{struct EMRANGLEARC { + emr: EMR, + ptlCenter: POINTL, + nRadius: DWORD, + eStartAngle: FLOAT, + eSweepAngle: FLOAT, +}} +pub type PEMRANGLEARC = *mut EMRANGLEARC; +STRUCT!{struct EMRPOLYLINE { + emr: EMR, + rclBounds: RECTL, + cptl: DWORD, + aptl: [POINTL; 1], +}} +pub type PEMRPOLYLINE = *mut EMRPOLYLINE; +pub type EMRPOLYBEZIER = EMRPOLYLINE; +pub type PEMRPOLYBEZIER = *mut EMRPOLYLINE; +pub type EMRPOLYGON = EMRPOLYLINE; +pub type PEMRPOLYGON = *mut EMRPOLYLINE; +pub type EMRPOLYBEZIERTO = EMRPOLYLINE; +pub type PEMRPOLYBEZIERTO = *mut EMRPOLYLINE; +pub type EMRPOLYLINETO = EMRPOLYLINE; +pub type PEMRPOLYLINETO = *mut EMRPOLYLINE; +STRUCT!{struct EMRPOLYLINE16 { + emr: EMR, + rclBounds: RECTL, + cpts: DWORD, + apts: [POINTS; 1], +}} +pub type PEMRPOLYLINE16 = *mut EMRPOLYLINE16; +pub type EMRPOLYBEZIER16 = EMRPOLYLINE16; +pub type PEMRPOLYBEZIER16 = *mut EMRPOLYLINE16; +pub type EMRPOLYGON16 = EMRPOLYLINE16; +pub type PEMRPOLYGON16 = *mut EMRPOLYLINE16; +pub type EMRPOLYBEZIERTO16 = EMRPOLYLINE16; +pub type PEMRPOLYBEZIERTO16 = *mut EMRPOLYLINE16; +pub type EMRPOLYLINETO16 = EMRPOLYLINE16; +pub type PEMRPOLYLINETO16 = *mut EMRPOLYLINE16; +STRUCT!{struct EMRPOLYDRAW { + emr: EMR, + rclBounds: RECTL, + cptl: DWORD, + aptl: [POINTL; 1], + abTypes: [BYTE; 1], +}} +pub type PEMRPOLYDRAW = *mut EMRPOLYDRAW; +STRUCT!{struct EMRPOLYDRAW16 { + emr: EMR, + rclBounds: RECTL, + cpts: DWORD, + apts: [POINTS; 1], + abTypes: [BYTE; 1], +}} +pub type PEMRPOLYDRAW16 = *mut EMRPOLYDRAW16; +STRUCT!{struct EMRPOLYPOLYLINE { + emr: EMR, + rclBounds: RECTL, + nPolys: DWORD, + cptl: DWORD, + aPolyCounts: [DWORD; 1], + aptl: [POINTL; 1], +}} +pub type PEMRPOLYPOLYLINE = *mut EMRPOLYPOLYLINE; +pub type EMRPOLYPOLYGON = EMRPOLYPOLYLINE; +pub type PEMRPOLYPOLYGON = *mut EMRPOLYPOLYLINE; +STRUCT!{struct EMRPOLYPOLYLINE16 { + emr: EMR, + rclBounds: RECTL, + nPolys: DWORD, + cpts: DWORD, + aPolyCounts: [DWORD; 1], + apts: [POINTS; 1], +}} +pub type PEMRPOLYPOLYLINE16 = *mut EMRPOLYPOLYLINE16; +pub type EMRPOLYPOLYGON16 = EMRPOLYPOLYLINE16; +pub type PEMRPOLYPOLYGON16 = *mut EMRPOLYPOLYLINE16; +STRUCT!{struct EMRINVERTRGN { + emr: EMR, + rclBounds: RECTL, + cbRgnData: DWORD, + RgnData: [BYTE; 1], +}} +pub type PEMRINVERTRGN = *mut EMRINVERTRGN; +pub type EMRPAINTRGN = EMRINVERTRGN; +pub type PEMRPAINTRGN = *mut EMRINVERTRGN; +STRUCT!{struct EMRFILLRGN { + emr: EMR, + rclBounds: RECTL, + cbRgnData: DWORD, + ihBrush: DWORD, + RgnData: [BYTE; 1], +}} +pub type PEMRFILLRGN = *mut EMRFILLRGN; +STRUCT!{struct EMRFRAMERGN { + emr: EMR, + rclBounds: RECTL, + cbRgnData: DWORD, + ihBrush: DWORD, + szlStroke: SIZEL, + RgnData: [BYTE; 1], +}} +pub type PEMRFRAMERGN = *mut EMRFRAMERGN; +STRUCT!{struct EMREXTSELECTCLIPRGN { + emr: EMR, + cbRgnData: DWORD, + iMode: DWORD, + RgnData: [BYTE; 1], +}} +pub type PEMREXTSELECTCLIPRGN = *mut EMREXTSELECTCLIPRGN; +STRUCT!{struct EMREXTTEXTOUTA { + emr: EMR, + rclBounds: RECTL, + iGraphicsMode: DWORD, + exScale: FLOAT, + eyScale: FLOAT, + emrtext: EMRTEXT, +}} +pub type PEMREXTTEXTOUTA = *mut EMREXTTEXTOUTA; +pub type EMREXTTEXTOUTW = EMREXTTEXTOUTA; +pub type PEMREXTTEXTOUTW = *mut EMREXTTEXTOUTA; +STRUCT!{struct EMRPOLYTEXTOUTA { + emr: EMR, + rclBounds: RECTL, + iGraphicsMode: DWORD, + exScale: FLOAT, + eyScale: FLOAT, + cStrings: LONG, + aemrtext: [EMRTEXT; 1], +}} +pub type PEMRPOLYTEXTOUTA = *mut EMRPOLYTEXTOUTA; +pub type EMRPOLYTEXTOUTW = EMRPOLYTEXTOUTA; +pub type PEMRPOLYTEXTOUTW = *mut EMRPOLYTEXTOUTA; +STRUCT!{struct EMRBITBLT { + emr: EMR, + rclBounds: RECTL, + xDest: LONG, + yDest: LONG, + cxDest: LONG, + cyDest: LONG, + dwRop: DWORD, + xSrc: LONG, + ySrc: LONG, + xformSrc: XFORM, + crBkColorSrc: COLORREF, + iUsageSrc: DWORD, + offBmiSrc: DWORD, + cbBmiSrc: DWORD, + offBitsSrc: DWORD, + cbBitsSrc: DWORD, +}} +pub type PEMRBITBLT = *mut EMRBITBLT; +STRUCT!{struct EMRSTRETCHBLT { + emr: EMR, + rclBounds: RECTL, + xDest: LONG, + yDest: LONG, + cxDest: LONG, + cyDest: LONG, + dwRop: DWORD, + xSrc: LONG, + ySrc: LONG, + xformSrc: XFORM, + crBkColorSrc: COLORREF, + iUsageSrc: DWORD, + offBmiSrc: DWORD, + cbBmiSrc: DWORD, + offBitsSrc: DWORD, + cbBitsSrc: DWORD, + cxSrc: LONG, + cySrc: LONG, +}} +pub type PEMRSTRETCHBLT = *mut EMRSTRETCHBLT; +STRUCT!{struct EMRMASKBLT { + emr: EMR, + rclBounds: RECTL, + xDest: LONG, + yDest: LONG, + cxDest: LONG, + cyDest: LONG, + dwRop: DWORD, + xSrc: LONG, + ySrc: LONG, + xformSrc: XFORM, + crBkColorSrc: COLORREF, + iUsageSrc: DWORD, + offBmiSrc: DWORD, + cbBmiSrc: DWORD, + offBitsSrc: DWORD, + cbBitsSrc: DWORD, + xMask: LONG, + yMask: LONG, + iUsageMask: DWORD, + offBmiMask: DWORD, + cbBmiMask: DWORD, + offBitsMask: DWORD, + cbBitsMask: DWORD, +}} +pub type PEMRMASKBLT = *mut EMRMASKBLT; +STRUCT!{struct EMRPLGBLT { + emr: EMR, + rclBounds: RECTL, + aptlDest: [POINTL; 3], + xSrc: LONG, + ySrc: LONG, + cxSrc: LONG, + cySrc: LONG, + xformSrc: XFORM, + crBkColorSrc: COLORREF, + iUsageSrc: DWORD, + offBmiSrc: DWORD, + cbBmiSrc: DWORD, + offBitsSrc: DWORD, + cbBitsSrc: DWORD, + xMask: LONG, + yMask: LONG, + iUsageMask: DWORD, + offBmiMask: DWORD, + cbBmiMask: DWORD, + offBitsMask: DWORD, + cbBitsMask: DWORD, +}} +pub type PEMRPLGBLT = *mut EMRPLGBLT; +STRUCT!{struct EMRSETDIBITSTODEVICE { + emr: EMR, + rclBounds: RECTL, + xDest: LONG, + yDest: LONG, + xSrc: LONG, + ySrc: LONG, + cxSrc: LONG, + cySrc: LONG, + offBmiSrc: DWORD, + cbBmiSrc: DWORD, + offBitsSrc: DWORD, + cbBitsSrc: DWORD, + iUsageSrc: DWORD, + iStartScan: DWORD, + cScans: DWORD, +}} +pub type PEMRSETDIBITSTODEVICE = *mut EMRSETDIBITSTODEVICE; +STRUCT!{struct EMRSTRETCHDIBITS { + emr: EMR, + rclBounds: RECTL, + xDest: LONG, + yDest: LONG, + xSrc: LONG, + ySrc: LONG, + cxSrc: LONG, + cySrc: LONG, + offBmiSrc: DWORD, + cbBmiSrc: DWORD, + offBitsSrc: DWORD, + cbBitsSrc: DWORD, + iUsageSrc: DWORD, + dwRop: DWORD, + cxDest: LONG, + cyDest: LONG, +}} +pub type PEMRSTRETCHDIBITS = *mut EMRSTRETCHDIBITS; +STRUCT!{struct EMREXTCREATEFONTINDIRECTW { + emr: EMR, + ihFont: DWORD, + elfw: EXTLOGFONTW, +}} +pub type PEMREXTCREATEFONTINDIRECTW = *mut EMREXTCREATEFONTINDIRECTW; +STRUCT!{struct EMRCREATEPALETTE { + emr: EMR, + ihPal: DWORD, + lgpl: LOGPALETTE, +}} +pub type PEMRCREATEPALETTE = *mut EMRCREATEPALETTE; +STRUCT!{struct EMRCREATEPEN { + emr: EMR, + ihPen: DWORD, + lopn: LOGPEN, +}} +pub type PEMRCREATEPEN = *mut EMRCREATEPEN; +STRUCT!{struct EMREXTCREATEPEN { + emr: EMR, + ihPen: DWORD, + offBmi: DWORD, + cbBmi: DWORD, + offBits: DWORD, + cbBits: DWORD, + elp: EXTLOGPEN32, +}} +pub type PEMREXTCREATEPEN = *mut EMREXTCREATEPEN; +STRUCT!{struct EMRCREATEBRUSHINDIRECT { + emr: EMR, + ihBrush: DWORD, + lb: LOGBRUSH32, +}} +pub type PEMRCREATEBRUSHINDIRECT = *mut EMRCREATEBRUSHINDIRECT; +STRUCT!{struct EMRCREATEMONOBRUSH { + emr: EMR, + ihBrush: DWORD, + iUsage: DWORD, + offBmi: DWORD, + cbBmi: DWORD, + offBits: DWORD, + cbBits: DWORD, +}} +pub type PEMRCREATEMONOBRUSH = *mut EMRCREATEMONOBRUSH; +STRUCT!{struct EMRCREATEDIBPATTERNBRUSHPT { + emr: EMR, + ihBrush: DWORD, + iUsage: DWORD, + offBmi: DWORD, + cbBmi: DWORD, + offBits: DWORD, + cbBits: DWORD, +}} +pub type PEMRCREATEDIBPATTERNBRUSHPT = *mut EMRCREATEDIBPATTERNBRUSHPT; +STRUCT!{struct EMRFORMAT { + dSignature: DWORD, + nVersion: DWORD, + cbData: DWORD, + offData: DWORD, +}} +pub type PEMRFORMAT = *mut EMRFORMAT; +STRUCT!{struct EMRGLSRECORD { + emr: EMR, + cbData: DWORD, + Data: [BYTE; 1], +}} +pub type PEMRGLSRECORD = *mut EMRGLSRECORD; +STRUCT!{struct EMRGLSBOUNDEDRECORD { + emr: EMR, + rclBounds: RECTL, + cbData: DWORD, + Data: [BYTE; 1], +}} +pub type PEMRGLSBOUNDEDRECORD = *mut EMRGLSBOUNDEDRECORD; +STRUCT!{struct EMRPIXELFORMAT { + emr: EMR, + pfd: PIXELFORMATDESCRIPTOR, +}} +pub type PEMRPIXELFORMAT = *mut EMRPIXELFORMAT; +STRUCT!{struct EMRCREATECOLORSPACE { + emr: EMR, + ihCS: DWORD, + lcs: LOGCOLORSPACEA, +}} +pub type PEMRCREATECOLORSPACE = *mut EMRCREATECOLORSPACE; +STRUCT!{struct EMRSETCOLORSPACE { + emr: EMR, + ihCS: DWORD, +}} +pub type PEMRSETCOLORSPACE = *mut EMRSETCOLORSPACE; +pub type EMRSELECTCOLORSPACE = EMRSETCOLORSPACE; +pub type PEMRSELECTCOLORSPACE = *mut EMRSETCOLORSPACE; +pub type EMRDELETECOLORSPACE = EMRSETCOLORSPACE; +pub type PEMRDELETECOLORSPACE = *mut EMRSETCOLORSPACE; +STRUCT!{struct EMREXTESCAPE { + emr: EMR, + iEscape: INT, + cbEscData: INT, + EscData: [BYTE; 1], +}} +pub type PEMREXTESCAPE = *mut EMREXTESCAPE; +pub type EMRDRAWESCAPE = EMREXTESCAPE; +pub type PEMRDRAWESCAPE = *mut EMREXTESCAPE; +STRUCT!{struct EMRNAMEDESCAPE { + emr: EMR, + iEscape: INT, + cbDriver: INT, + cbEscData: INT, + EscData: [BYTE; 1], +}} +pub type PEMRNAMEDESCAPE = *mut EMRNAMEDESCAPE; +pub const SETICMPROFILE_EMBEDED: DWORD = 0x00000001; +STRUCT!{struct EMRSETICMPROFILE { + emr: EMR, + dwFlags: DWORD, + cbName: DWORD, + cbData: DWORD, + Data: [BYTE; 1], +}} +pub type PEMRSETICMPROFILE = *mut EMRSETICMPROFILE; +pub type EMRSETICMPROFILEA = EMRSETICMPROFILE; +pub type PEMRSETICMPROFILEA = *mut EMRSETICMPROFILE; +pub type EMRSETICMPROFILEW = EMRSETICMPROFILE; +pub type PEMRSETICMPROFILEW = *mut EMRSETICMPROFILE; +pub const CREATECOLORSPACE_EMBEDED: DWORD = 0x00000001; +STRUCT!{struct EMRCREATECOLORSPACEW { + emr: EMR, + ihCS: DWORD, + lcs: LOGCOLORSPACEW, + dwFlags: DWORD, + cbData: DWORD, + Data: [BYTE; 1], +}} +pub type PEMRCREATECOLORSPACEW = *mut EMRCREATECOLORSPACEW; +pub const COLORMATCHTOTARGET_EMBEDED: DWORD = 0x00000001; +STRUCT!{struct EMRCOLORMATCHTOTARGET { + emr: EMR, + dwAction: DWORD, + dwFlags: DWORD, + cbName: DWORD, + cbData: DWORD, + Data: [BYTE; 1], +}} +pub type PEMRCOLORMATCHTOTARGET = *mut EMRCOLORMATCHTOTARGET; +STRUCT!{struct EMRCOLORCORRECTPALETTE { + emr: EMR, + ihPalette: DWORD, + nFirstEntry: DWORD, + nPalEntries: DWORD, + nReserved: DWORD, +}} +pub type PEMRCOLORCORRECTPALETTE = *mut EMRCOLORCORRECTPALETTE; +STRUCT!{struct EMRALPHABLEND { + emr: EMR, + rclBounds: RECTL, + xDest: LONG, + yDest: LONG, + cxDest: LONG, + cyDest: LONG, + dwRop: DWORD, + xSrc: LONG, + ySrc: LONG, + xformSrc: XFORM, + crBkColorSrc: COLORREF, + iUsageSrc: DWORD, + offBmiSrc: DWORD, + cbBmiSrc: DWORD, + offBitsSrc: DWORD, + cbBitsSrc: DWORD, + cxSrc: LONG, + cySrc: LONG, +}} +pub type PEMRALPHABLEND = *mut EMRALPHABLEND; +STRUCT!{struct EMRGRADIENTFILL { + emr: EMR, + rclBounds: RECTL, + nVer: DWORD, + nTri: DWORD, + ulMode: ULONG, + Ver: [TRIVERTEX; 1], +}} +pub type PEMRGRADIENTFILL = *mut EMRGRADIENTFILL; +STRUCT!{struct EMRTRANSPARENTBLT { + emr: EMR, + rclBounds: RECTL, + xDest: LONG, + yDest: LONG, + cxDest: LONG, + cyDest: LONG, + dwRop: DWORD, + xSrc: LONG, + ySrc: LONG, + xformSrc: XFORM, + crBkColorSrc: COLORREF, + iUsageSrc: DWORD, + offBmiSrc: DWORD, + cbBmiSrc: DWORD, + offBitsSrc: DWORD, + cbBitsSrc: DWORD, + cxSrc: LONG, + cySrc: LONG, +}} +pub type PEMRTRANSPARENTBLT = *mut EMRTRANSPARENTBLT; +pub const GDICOMMENT_IDENTIFIER: DWORD = 0x43494447; +pub const GDICOMMENT_WINDOWS_METAFILE: DWORD = 0x80000001; +pub const GDICOMMENT_BEGINGROUP: DWORD = 0x00000002; +pub const GDICOMMENT_ENDGROUP: DWORD = 0x00000003; +pub const GDICOMMENT_MULTIFORMATS: DWORD = 0x40000004; +pub const EPS_SIGNATURE: DWORD = 0x46535045; +pub const GDICOMMENT_UNICODE_STRING: DWORD = 0x00000040; +pub const GDICOMMENT_UNICODE_END: DWORD = 0x00000080; +extern "system" { + pub fn wglCopyContext( + hglrcSrc: HGLRC, + hglrcDst: HGLRC, + mask: UINT, + ) -> BOOL; + pub fn wglCreateContext( + hdc: HDC, + ) -> HGLRC; + pub fn wglCreateLayerContext( + hdc: HDC, + iLayerPlane: c_int, + ) -> HGLRC; + pub fn wglDeleteContext( + hglrc: HGLRC, + ) -> BOOL; + pub fn wglGetCurrentContext() -> HGLRC; + pub fn wglGetCurrentDC() -> HDC; + pub fn wglGetProcAddress( + lpszProc: LPCSTR, + ) -> PROC; + pub fn wglMakeCurrent( + hdc: HDC, + hglrc: HGLRC, + ) -> BOOL; + pub fn wglShareLists( + hglrc1: HGLRC, + hglrc2: HGLRC, + ) -> BOOL; + pub fn wglUseFontBitmapsA( + hdc: HDC, + first: DWORD, + count: DWORD, + listBase: DWORD, + ) -> BOOL; + pub fn wglUseFontBitmapsW( + hdc: HDC, + first: DWORD, + count: DWORD, + listBase: DWORD, + ) -> BOOL; + pub fn SwapBuffers( + hdc: HDC, + ) -> BOOL; +} +STRUCT!{struct POINTFLOAT { + x: FLOAT, + y: FLOAT, +}} +pub type PPOINTFLOAT = *mut POINTFLOAT; +STRUCT!{struct GLYPHMETRICSFLOAT { + gmfBlackBoxX: FLOAT, + gmfBlackBoxY: FLOAT, + gmfptGlyphOrigin: POINTFLOAT, + gmfCellIncX: FLOAT, + gmfCellIncY: FLOAT, +}} +pub type PGLYPHMETRICSFLOAT = *mut GLYPHMETRICSFLOAT; +pub type LPGLYPHMETRICSFLOAT = *mut GLYPHMETRICSFLOAT; +pub const WGL_FONT_LINES: DWORD = 0; +pub const WGL_FONT_POLYGONS: DWORD = 1; +extern "system" { + pub fn wglUseFontOutlinesA( + hdc: HDC, + first: DWORD, + count: DWORD, + listBase: DWORD, + deviation: FLOAT, + extrusion: FLOAT, + format: c_int, + lpgmf: LPGLYPHMETRICSFLOAT, + ) -> BOOL; + pub fn wglUseFontOutlinesW( + hdc: HDC, + first: DWORD, + count: DWORD, + listBase: DWORD, + deviation: FLOAT, + extrusion: FLOAT, + format: c_int, + lpgmf: LPGLYPHMETRICSFLOAT, + ) -> BOOL; +} +STRUCT!{struct LAYERPLANEDESCRIPTOR { + nSize: WORD, + nVersion: WORD, + dwFlags: DWORD, + iPixelType: BYTE, + cColorBits: BYTE, + cRedBits: BYTE, + cRedShift: BYTE, + cGreenBits: BYTE, + cGreenShift: BYTE, + cBlueBits: BYTE, + cBlueShift: BYTE, + cAlphaBits: BYTE, + cAlphaShift: BYTE, + cAccumBits: BYTE, + cAccumRedBits: BYTE, + cAccumGreenBits: BYTE, + cAccumBlueBits: BYTE, + cAccumAlphaBits: BYTE, + cDepthBits: BYTE, + cStencilBits: BYTE, + cAuxBuffers: BYTE, + iLayerPlane: BYTE, + bReserved: BYTE, + crTransparent: COLORREF, +}} +pub type PLAYERPLANEDESCRIPTOR = *mut LAYERPLANEDESCRIPTOR; +pub type LPLAYERPLANEDESCRIPTOR = *mut LAYERPLANEDESCRIPTOR; +pub const LPD_DOUBLEBUFFER: DWORD = 0x00000001; +pub const LPD_STEREO: DWORD = 0x00000002; +pub const LPD_SUPPORT_GDI: DWORD = 0x00000010; +pub const LPD_SUPPORT_OPENGL: DWORD = 0x00000020; +pub const LPD_SHARE_DEPTH: DWORD = 0x00000040; +pub const LPD_SHARE_STENCIL: DWORD = 0x00000080; +pub const LPD_SHARE_ACCUM: DWORD = 0x00000100; +pub const LPD_SWAP_EXCHANGE: DWORD = 0x00000200; +pub const LPD_SWAP_COPY: DWORD = 0x00000400; +pub const LPD_TRANSPARENT: DWORD = 0x00001000; +pub const LPD_TYPE_RGBA: BYTE = 0; +pub const LPD_TYPE_COLORINDEX: BYTE = 1; +pub const WGL_SWAP_MAIN_PLANE: UINT = 0x00000001; +pub const WGL_SWAP_OVERLAY1: UINT = 0x00000002; +pub const WGL_SWAP_OVERLAY2: UINT = 0x00000004; +pub const WGL_SWAP_OVERLAY3: UINT = 0x00000008; +pub const WGL_SWAP_OVERLAY4: UINT = 0x00000010; +pub const WGL_SWAP_OVERLAY5: UINT = 0x00000020; +pub const WGL_SWAP_OVERLAY6: UINT = 0x00000040; +pub const WGL_SWAP_OVERLAY7: UINT = 0x00000080; +pub const WGL_SWAP_OVERLAY8: UINT = 0x00000100; +pub const WGL_SWAP_OVERLAY9: UINT = 0x00000200; +pub const WGL_SWAP_OVERLAY10: UINT = 0x00000400; +pub const WGL_SWAP_OVERLAY11: UINT = 0x00000800; +pub const WGL_SWAP_OVERLAY12: UINT = 0x00001000; +pub const WGL_SWAP_OVERLAY13: UINT = 0x00002000; +pub const WGL_SWAP_OVERLAY14: UINT = 0x00004000; +pub const WGL_SWAP_OVERLAY15: UINT = 0x00008000; +pub const WGL_SWAP_UNDERLAY1: UINT = 0x00010000; +pub const WGL_SWAP_UNDERLAY2: UINT = 0x00020000; +pub const WGL_SWAP_UNDERLAY3: UINT = 0x00040000; +pub const WGL_SWAP_UNDERLAY4: UINT = 0x00080000; +pub const WGL_SWAP_UNDERLAY5: UINT = 0x00100000; +pub const WGL_SWAP_UNDERLAY6: UINT = 0x00200000; +pub const WGL_SWAP_UNDERLAY7: UINT = 0x00400000; +pub const WGL_SWAP_UNDERLAY8: UINT = 0x00800000; +pub const WGL_SWAP_UNDERLAY9: UINT = 0x01000000; +pub const WGL_SWAP_UNDERLAY10: UINT = 0x02000000; +pub const WGL_SWAP_UNDERLAY11: UINT = 0x04000000; +pub const WGL_SWAP_UNDERLAY12: UINT = 0x08000000; +pub const WGL_SWAP_UNDERLAY13: UINT = 0x10000000; +pub const WGL_SWAP_UNDERLAY14: UINT = 0x20000000; +pub const WGL_SWAP_UNDERLAY15: UINT = 0x40000000; +extern "system" { + pub fn wglDescribeLayerPlane( + hdc: HDC, + iPixelFormat: c_int, + iLayerPlane: c_int, + nBytes: UINT, + plpd: LPLAYERPLANEDESCRIPTOR, + ) -> BOOL; + pub fn wglSetLayerPaletteEntries( + hdc: HDC, + iLayerPlane: c_int, + iStart: c_int, + cEntries: c_int, + pcr: *const COLORREF, + ) -> c_int; + pub fn wglGetLayerPaletteEntries( + hdc: HDC, + iLayerPlane: c_int, + iStart: c_int, + cEntries: c_int, + pcr: *const COLORREF, + ) -> c_int; + pub fn wglRealizeLayerPalette( + hdc: HDC, + iLayerPlane: c_int, + bRealize: BOOL, + ) -> BOOL; + pub fn wglSwapLayerBuffers( + hdc: HDC, + fuPlanes: UINT, + ) -> BOOL; +} +STRUCT!{struct WGLSWAP { + hdc: HDC, + uiFlags: UINT, +}} +pub type PWGLSWAP = *mut WGLSWAP; +pub type LPWGLSWAP = *mut WGLSWAP; +pub const WGL_SWAPMULTIPLE_MAX: usize = 16; +extern "system" { + pub fn wglSwapMultipleBuffers( + n: UINT, + ps: *const WGLSWAP, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winhttp.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winhttp.rs new file mode 100644 index 0000000..f39c78f --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winhttp.rs @@ -0,0 +1,658 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Windows HTTP Services API constant definitions and macros +use ctypes::c_int; +use shared::basetsd::DWORD_PTR; +use shared::minwindef::{BOOL, DWORD, LPCVOID, LPDWORD, LPVOID, USHORT, WORD}; +use um::minwinbase::SYSTEMTIME; +use um::winnt::{LPCWSTR, LPWSTR, PCWSTR, PVOID, PWSTR}; +pub type HINTERNET = LPVOID; +pub type LPHINTERNET = *mut HINTERNET; +pub type INTERNET_PORT = WORD; +pub type LPINTERNET_PORT = *mut INTERNET_PORT; +pub const INTERNET_DEFAULT_PORT: INTERNET_PORT = 0; +pub const INTERNET_DEFAULT_HTTP_PORT: INTERNET_PORT = 80; +pub const INTERNET_DEFAULT_HTTPS_PORT: INTERNET_PORT = 443; +pub const WINHTTP_FLAG_ASYNC: DWORD = 0x10000000; +pub const WINHTTP_FLAG_SECURE: DWORD = 0x00800000; +pub const WINHTTP_FLAG_ESCAPE_PERCENT: DWORD = 0x00000004; +pub const WINHTTP_FLAG_NULL_CODEPAGE: DWORD = 0x00000008; +pub const WINHTTP_FLAG_BYPASS_PROXY_CACHE: DWORD = 0x00000100; +pub const WINHTTP_FLAG_REFRESH: DWORD = WINHTTP_FLAG_BYPASS_PROXY_CACHE; +pub const WINHTTP_FLAG_ESCAPE_DISABLE: DWORD = 0x00000040; +pub const WINHTTP_FLAG_ESCAPE_DISABLE_QUERY: DWORD = 0x00000080; +STRUCT!{struct WINHTTP_ASYNC_RESULT { + dwResult: DWORD_PTR, + dwError: DWORD, +}} +pub type LPWINHTTP_ASYNC_RESULT = *mut WINHTTP_ASYNC_RESULT; +pub type INTERNET_SCHEME = c_int; +pub type LPINTERNET_SCHEME = *mut c_int; +pub const INTERNET_SCHEME_HTTP: INTERNET_SCHEME = 1; +pub const INTERNET_SCHEME_HTTPS: INTERNET_SCHEME = 2; +pub const INTERNET_SCHEME_FTP: INTERNET_SCHEME = 3; +pub const INTERNET_SCHEME_SOCKS: INTERNET_SCHEME = 4; +STRUCT!{struct URL_COMPONENTS { + dwStructSize: DWORD, + lpszScheme: LPWSTR, + dwSchemeLength: DWORD, + nScheme: INTERNET_SCHEME, + lpszHostName: LPWSTR, + dwHostNameLength: DWORD, + nPort: INTERNET_PORT, + lpszUserName: LPWSTR, + dwUserNameLength: DWORD, + lpszPassword: LPWSTR, + dwPasswordLength: DWORD, + lpszUrlPath: LPWSTR, + dwUrlPathLength: DWORD, + lpszExtraInfo: LPWSTR, + dwExtraInfoLength: DWORD, +}} +pub type LPURL_COMPONENTS = *mut URL_COMPONENTS; +pub type URL_COMPONENTSW = URL_COMPONENTS; +pub type LPURL_COMPONENTSW = LPURL_COMPONENTS; +STRUCT!{struct WINHTTP_PROXY_INFO { + dwAccessType: DWORD, + lpszProxy: LPWSTR, + lpszProxyBypass: LPWSTR, +}} +pub type LPWINHTTP_PROXY_INFO = *mut WINHTTP_PROXY_INFO; +pub type WINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO; +pub type LPWINHTTP_PROXY_INFOW = LPWINHTTP_PROXY_INFO; +STRUCT!{struct WINHTTP_AUTOPROXY_OPTIONS { + dwFlags: DWORD, + dwAutoDetectFlags: DWORD, + lpszAutoConfigUrl: LPCWSTR, + lpvReserved: LPVOID, + dwReserved: DWORD, + fAutoLogonIfChallenged: BOOL, +}} +pub const WINHTTP_AUTOPROXY_AUTO_DETECT: DWORD = 0x00000001; +pub const WINHTTP_AUTOPROXY_CONFIG_URL: DWORD = 0x00000002; +pub const WINHTTP_AUTOPROXY_HOST_KEEPCASE: DWORD = 0x00000004; +pub const WINHTTP_AUTOPROXY_HOST_LOWERCASE: DWORD = 0x00000008; +pub const WINHTTP_AUTOPROXY_RUN_INPROCESS: DWORD = 0x00010000; +pub const WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY: DWORD = 0x00020000; +pub const WINHTTP_AUTOPROXY_NO_DIRECTACCESS: DWORD = 0x00040000; +pub const WINHTTP_AUTOPROXY_NO_CACHE_CLIENT: DWORD = 0x00080000; +pub const WINHTTP_AUTOPROXY_NO_CACHE_SVC: DWORD = 0x00100000; +pub const WINHTTP_AUTOPROXY_SORT_RESULTS: DWORD = 0x00400000; +pub const WINHTTP_AUTO_DETECT_TYPE_DHCP: DWORD = 0x00000001; +pub const WINHTTP_AUTO_DETECT_TYPE_DNS_A: DWORD = 0x00000002; +STRUCT!{struct WINHTTP_PROXY_RESULT_ENTRY { + fProxy: BOOL, + fBypass: BOOL, + ProxyScheme: INTERNET_SCHEME, + pwszProxy: PWSTR, + ProxyPort: INTERNET_PORT, +}} +STRUCT!{struct WINHTTP_PROXY_RESULT { + cEntries: DWORD, + pEntries: *mut WINHTTP_PROXY_RESULT_ENTRY, +}} +pub const WINHTTP_FIRST_OPTION: DWORD = WINHTTP_OPTION_CALLBACK; +pub const WINHTTP_OPTION_CALLBACK: DWORD = 1; +pub const WINHTTP_OPTION_RESOLVE_TIMEOUT: DWORD = 2; +pub const WINHTTP_OPTION_CONNECT_TIMEOUT: DWORD = 3; +pub const WINHTTP_OPTION_CONNECT_RETRIES: DWORD = 4; +pub const WINHTTP_OPTION_SEND_TIMEOUT: DWORD = 5; +pub const WINHTTP_OPTION_RECEIVE_TIMEOUT: DWORD = 6; +pub const WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT: DWORD = 7; +pub const WINHTTP_OPTION_HANDLE_TYPE: DWORD = 9; +pub const WINHTTP_OPTION_READ_BUFFER_SIZE: DWORD = 12; +pub const WINHTTP_OPTION_WRITE_BUFFER_SIZE: DWORD = 13; +pub const WINHTTP_OPTION_PARENT_HANDLE: DWORD = 21; +pub const WINHTTP_OPTION_EXTENDED_ERROR: DWORD = 24; +pub const WINHTTP_OPTION_SECURITY_FLAGS: DWORD = 31; +pub const WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT: DWORD = 32; +pub const WINHTTP_OPTION_URL: DWORD = 34; +pub const WINHTTP_OPTION_SECURITY_KEY_BITNESS: DWORD = 36; +pub const WINHTTP_OPTION_PROXY: DWORD = 38; +pub const WINHTTP_OPTION_PROXY_RESULT_ENTRY: DWORD = 39; +pub const WINHTTP_OPTION_USER_AGENT: DWORD = 41; +pub const WINHTTP_OPTION_CONTEXT_VALUE: DWORD = 45; +pub const WINHTTP_OPTION_CLIENT_CERT_CONTEXT: DWORD = 47; +pub const WINHTTP_OPTION_REQUEST_PRIORITY: DWORD = 58; +pub const WINHTTP_OPTION_HTTP_VERSION: DWORD = 59; +pub const WINHTTP_OPTION_DISABLE_FEATURE: DWORD = 63; +pub const WINHTTP_OPTION_CODEPAGE: DWORD = 68; +pub const WINHTTP_OPTION_MAX_CONNS_PER_SERVER: DWORD = 73; +pub const WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER: DWORD = 74; +pub const WINHTTP_OPTION_AUTOLOGON_POLICY: DWORD = 77; +pub const WINHTTP_OPTION_SERVER_CERT_CONTEXT: DWORD = 78; +pub const WINHTTP_OPTION_ENABLE_FEATURE: DWORD = 79; +pub const WINHTTP_OPTION_WORKER_THREAD_COUNT: DWORD = 80; +pub const WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT: DWORD = 81; +pub const WINHTTP_OPTION_PASSPORT_COBRANDING_URL: DWORD = 82; +pub const WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH: DWORD = 83; +pub const WINHTTP_OPTION_SECURE_PROTOCOLS: DWORD = 84; +pub const WINHTTP_OPTION_ENABLETRACING: DWORD = 85; +pub const WINHTTP_OPTION_PASSPORT_SIGN_OUT: DWORD = 86; +pub const WINHTTP_OPTION_PASSPORT_RETURN_URL: DWORD = 87; +pub const WINHTTP_OPTION_REDIRECT_POLICY: DWORD = 88; +pub const WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS: DWORD = 89; +pub const WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE: DWORD = 90; +pub const WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE: DWORD = 91; +pub const WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE: DWORD = 92; +pub const WINHTTP_OPTION_CONNECTION_INFO: DWORD = 93; +pub const WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST: DWORD = 94; +pub const WINHTTP_OPTION_SPN: DWORD = 96; +pub const WINHTTP_OPTION_GLOBAL_PROXY_CREDS: DWORD = 97; +pub const WINHTTP_OPTION_GLOBAL_SERVER_CREDS: DWORD = 98; +pub const WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT: DWORD = 99; +pub const WINHTTP_OPTION_REJECT_USERPWD_IN_URL: DWORD = 100; +pub const WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS: DWORD = 101; +pub const WINHTTP_OPTION_RECEIVE_PROXY_CONNECT_RESPONSE: DWORD = 103; +pub const WINHTTP_OPTION_IS_PROXY_CONNECT_RESPONSE: DWORD = 104; +pub const WINHTTP_OPTION_SERVER_SPN_USED: DWORD = 106; +pub const WINHTTP_OPTION_PROXY_SPN_USED: DWORD = 107; +pub const WINHTTP_OPTION_SERVER_CBT: DWORD = 108; +pub const WINHTTP_OPTION_UNSAFE_HEADER_PARSING: DWORD = 110; +pub const WINHTTP_OPTION_ASSURED_NON_BLOCKING_CALLBACKS: DWORD = 111; +pub const WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET: DWORD = 114; +pub const WINHTTP_OPTION_WEB_SOCKET_CLOSE_TIMEOUT: DWORD = 115; +pub const WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL: DWORD = 116; +pub const WINHTTP_OPTION_DECOMPRESSION: DWORD = 118; +pub const WINHTTP_OPTION_WEB_SOCKET_RECEIVE_BUFFER_SIZE: DWORD = 122; +pub const WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE: DWORD = 123; +pub const WINHTTP_LAST_OPTION: DWORD = WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE; +pub const WINHTTP_OPTION_USERNAME: DWORD = 0x1000; +pub const WINHTTP_OPTION_PASSWORD: DWORD = 0x1001; +pub const WINHTTP_OPTION_PROXY_USERNAME: DWORD = 0x1002; +pub const WINHTTP_OPTION_PROXY_PASSWORD: DWORD = 0x1003; +//569 +FN!{stdcall WINHTTP_STATUS_CALLBACK( + hInternet: HINTERNET, + dwContext: DWORD_PTR, + dwInternetStatus: DWORD, + lpvStatusInformation: LPVOID, + dwStatusInformationLength: DWORD, +) -> ()} +pub type LPWINHTTP_STATUS_CALLBACK = *mut WINHTTP_STATUS_CALLBACK; +pub const WINHTTP_CALLBACK_STATUS_RESOLVING_NAME: DWORD = 0x00000001; +pub const WINHTTP_CALLBACK_STATUS_NAME_RESOLVED: DWORD = 0x00000002; +pub const WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER: DWORD = 0x00000004; +pub const WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER: DWORD = 0x00000008; +pub const WINHTTP_CALLBACK_STATUS_SENDING_REQUEST: DWORD = 0x00000010; +pub const WINHTTP_CALLBACK_STATUS_REQUEST_SENT: DWORD = 0x00000020; +pub const WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE: DWORD = 0x00000040; +pub const WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED: DWORD = 0x00000080; +pub const WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION: DWORD = 0x00000100; +pub const WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED: DWORD = 0x00000200; +pub const WINHTTP_CALLBACK_STATUS_HANDLE_CREATED: DWORD = 0x00000400; +pub const WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING: DWORD = 0x00000800; +pub const WINHTTP_CALLBACK_STATUS_DETECTING_PROXY: DWORD = 0x00001000; +pub const WINHTTP_CALLBACK_STATUS_REDIRECT: DWORD = 0x00004000; +pub const WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE: DWORD = 0x00008000; +pub const WINHTTP_CALLBACK_STATUS_SECURE_FAILURE: DWORD = 0x00010000; +pub const WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE: DWORD = 0x00020000; +pub const WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE: DWORD = 0x00040000; +pub const WINHTTP_CALLBACK_STATUS_READ_COMPLETE: DWORD = 0x00080000; +pub const WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE: DWORD = 0x00100000; +pub const WINHTTP_CALLBACK_STATUS_REQUEST_ERROR: DWORD = 0x00200000; +pub const WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE: DWORD = 0x00400000; +pub const WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE: DWORD = 0x01000000; +pub const WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE: DWORD = 0x02000000; +pub const WINHTTP_CALLBACK_STATUS_SHUTDOWN_COMPLETE: DWORD = 0x04000000; +pub const WINHTTP_CALLBACK_FLAG_RESOLVE_NAME: DWORD = WINHTTP_CALLBACK_STATUS_RESOLVING_NAME + | WINHTTP_CALLBACK_STATUS_NAME_RESOLVED; +pub const WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER: DWORD = + WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER | WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER; +pub const WINHTTP_CALLBACK_FLAG_SEND_REQUEST: DWORD = + WINHTTP_CALLBACK_STATUS_SENDING_REQUEST | WINHTTP_CALLBACK_STATUS_REQUEST_SENT; +pub const WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE: DWORD = + WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE | WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED; +pub const WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION: DWORD = + WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION | WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED; +pub const WINHTTP_CALLBACK_FLAG_HANDLES: DWORD = + WINHTTP_CALLBACK_STATUS_HANDLE_CREATED | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING; +pub const WINHTTP_CALLBACK_FLAG_DETECTING_PROXY: DWORD = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY; +pub const WINHTTP_CALLBACK_FLAG_REDIRECT: DWORD = WINHTTP_CALLBACK_STATUS_REDIRECT; +pub const WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE: DWORD = + WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE; +pub const WINHTTP_CALLBACK_FLAG_SECURE_FAILURE: DWORD = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE; +pub const WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE: DWORD = + WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE; +pub const WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE: DWORD = + WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE; +pub const WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE: DWORD = WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE; +pub const WINHTTP_CALLBACK_FLAG_READ_COMPLETE: DWORD = WINHTTP_CALLBACK_STATUS_READ_COMPLETE; +pub const WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE: DWORD = WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE; +pub const WINHTTP_CALLBACK_FLAG_REQUEST_ERROR: DWORD = WINHTTP_CALLBACK_STATUS_REQUEST_ERROR; +pub const WINHTTP_CALLBACK_FLAG_GETPROXYFORURL_COMPLETE: DWORD = + WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE; +pub const WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS: DWORD = + WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE | WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE + | WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE | WINHTTP_CALLBACK_STATUS_READ_COMPLETE + | WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE | WINHTTP_CALLBACK_STATUS_REQUEST_ERROR + | WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE; +pub const WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS: DWORD = 0xffffffff; +pub const WINHTTP_QUERY_MIME_VERSION: DWORD = 0; +pub const WINHTTP_QUERY_CONTENT_TYPE: DWORD = 1; +pub const WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING: DWORD = 2; +pub const WINHTTP_QUERY_CONTENT_ID: DWORD = 3; +pub const WINHTTP_QUERY_CONTENT_DESCRIPTION: DWORD = 4; +pub const WINHTTP_QUERY_CONTENT_LENGTH: DWORD = 5; +pub const WINHTTP_QUERY_CONTENT_LANGUAGE: DWORD = 6; +pub const WINHTTP_QUERY_ALLOW: DWORD = 7; +pub const WINHTTP_QUERY_PUBLIC: DWORD = 8; +pub const WINHTTP_QUERY_DATE: DWORD = 9; +pub const WINHTTP_QUERY_EXPIRES: DWORD = 10; +pub const WINHTTP_QUERY_LAST_MODIFIED: DWORD = 11; +pub const WINHTTP_QUERY_MESSAGE_ID: DWORD = 12; +pub const WINHTTP_QUERY_URI: DWORD = 13; +pub const WINHTTP_QUERY_DERIVED_FROM: DWORD = 14; +pub const WINHTTP_QUERY_COST: DWORD = 15; +pub const WINHTTP_QUERY_LINK: DWORD = 16; +pub const WINHTTP_QUERY_PRAGMA: DWORD = 17; +pub const WINHTTP_QUERY_VERSION: DWORD = 18; +pub const WINHTTP_QUERY_STATUS_CODE: DWORD = 19; +pub const WINHTTP_QUERY_STATUS_TEXT: DWORD = 20; +pub const WINHTTP_QUERY_RAW_HEADERS: DWORD = 21; +pub const WINHTTP_QUERY_RAW_HEADERS_CRLF: DWORD = 22; +pub const WINHTTP_QUERY_CONNECTION: DWORD = 23; +pub const WINHTTP_QUERY_ACCEPT: DWORD = 24; +pub const WINHTTP_QUERY_ACCEPT_CHARSET: DWORD = 25; +pub const WINHTTP_QUERY_ACCEPT_ENCODING: DWORD = 26; +pub const WINHTTP_QUERY_ACCEPT_LANGUAGE: DWORD = 27; +pub const WINHTTP_QUERY_AUTHORIZATION: DWORD = 28; +pub const WINHTTP_QUERY_CONTENT_ENCODING: DWORD = 29; +pub const WINHTTP_QUERY_FORWARDED: DWORD = 30; +pub const WINHTTP_QUERY_FROM: DWORD = 31; +pub const WINHTTP_QUERY_IF_MODIFIED_SINCE: DWORD = 32; +pub const WINHTTP_QUERY_LOCATION: DWORD = 33; +pub const WINHTTP_QUERY_ORIG_URI: DWORD = 34; +pub const WINHTTP_QUERY_REFERER: DWORD = 35; +pub const WINHTTP_QUERY_RETRY_AFTER: DWORD = 36; +pub const WINHTTP_QUERY_SERVER: DWORD = 37; +pub const WINHTTP_QUERY_TITLE: DWORD = 38; +pub const WINHTTP_QUERY_USER_AGENT: DWORD = 39; +pub const WINHTTP_QUERY_WWW_AUTHENTICATE: DWORD = 40; +pub const WINHTTP_QUERY_PROXY_AUTHENTICATE: DWORD = 41; +pub const WINHTTP_QUERY_ACCEPT_RANGES: DWORD = 42; +pub const WINHTTP_QUERY_SET_COOKIE: DWORD = 43; +pub const WINHTTP_QUERY_COOKIE: DWORD = 44; +pub const WINHTTP_QUERY_REQUEST_METHOD: DWORD = 45; +pub const WINHTTP_QUERY_REFRESH: DWORD = 46; +pub const WINHTTP_QUERY_CONTENT_DISPOSITION: DWORD = 47; +pub const WINHTTP_QUERY_AGE: DWORD = 48; +pub const WINHTTP_QUERY_CACHE_CONTROL: DWORD = 49; +pub const WINHTTP_QUERY_CONTENT_BASE: DWORD = 50; +pub const WINHTTP_QUERY_CONTENT_LOCATION: DWORD = 51; +pub const WINHTTP_QUERY_CONTENT_MD5: DWORD = 52; +pub const WINHTTP_QUERY_CONTENT_RANGE: DWORD = 53; +pub const WINHTTP_QUERY_ETAG: DWORD = 54; +pub const WINHTTP_QUERY_HOST: DWORD = 55; +pub const WINHTTP_QUERY_IF_MATCH: DWORD = 56; +pub const WINHTTP_QUERY_IF_NONE_MATCH: DWORD = 57; +pub const WINHTTP_QUERY_IF_RANGE: DWORD = 58; +pub const WINHTTP_QUERY_IF_UNMODIFIED_SINCE: DWORD = 59; +pub const WINHTTP_QUERY_MAX_FORWARDS: DWORD = 60; +pub const WINHTTP_QUERY_PROXY_AUTHORIZATION: DWORD = 61; +pub const WINHTTP_QUERY_RANGE: DWORD = 62; +pub const WINHTTP_QUERY_TRANSFER_ENCODING: DWORD = 63; +pub const WINHTTP_QUERY_UPGRADE: DWORD = 64; +pub const WINHTTP_QUERY_VARY: DWORD = 65; +pub const WINHTTP_QUERY_VIA: DWORD = 66; +pub const WINHTTP_QUERY_WARNING: DWORD = 67; +pub const WINHTTP_QUERY_EXPECT: DWORD = 68; +pub const WINHTTP_QUERY_PROXY_CONNECTION: DWORD = 69; +pub const WINHTTP_QUERY_UNLESS_MODIFIED_SINCE: DWORD = 70; +pub const WINHTTP_QUERY_PROXY_SUPPORT: DWORD = 75; +pub const WINHTTP_QUERY_AUTHENTICATION_INFO: DWORD = 76; +pub const WINHTTP_QUERY_PASSPORT_URLS: DWORD = 77; +pub const WINHTTP_QUERY_PASSPORT_CONFIG: DWORD = 78; +pub const WINHTTP_QUERY_MAX: DWORD = 78; +pub const WINHTTP_QUERY_CUSTOM: DWORD = 65535; +pub const WINHTTP_QUERY_FLAG_REQUEST_HEADERS: DWORD = 0x80000000; +pub const WINHTTP_QUERY_FLAG_SYSTEMTIME: DWORD = 0x40000000; +pub const WINHTTP_QUERY_FLAG_NUMBER: DWORD = 0x20000000; +pub const HTTP_STATUS_CONTINUE: DWORD = 100; +pub const HTTP_STATUS_SWITCH_PROTOCOLS: DWORD = 101; +pub const HTTP_STATUS_OK: DWORD = 200; +pub const HTTP_STATUS_CREATED: DWORD = 201; +pub const HTTP_STATUS_ACCEPTED: DWORD = 202; +pub const HTTP_STATUS_PARTIAL: DWORD = 203; +pub const HTTP_STATUS_NO_CONTENT: DWORD = 204; +pub const HTTP_STATUS_RESET_CONTENT: DWORD = 205; +pub const HTTP_STATUS_PARTIAL_CONTENT: DWORD = 206; +pub const HTTP_STATUS_WEBDAV_MULTI_STATUS: DWORD = 207; +pub const HTTP_STATUS_AMBIGUOUS: DWORD = 300; +pub const HTTP_STATUS_MOVED: DWORD = 301; +pub const HTTP_STATUS_REDIRECT: DWORD = 302; +pub const HTTP_STATUS_REDIRECT_METHOD: DWORD = 303; +pub const HTTP_STATUS_NOT_MODIFIED: DWORD = 304; +pub const HTTP_STATUS_USE_PROXY: DWORD = 305; +pub const HTTP_STATUS_REDIRECT_KEEP_VERB: DWORD = 307; +pub const HTTP_STATUS_BAD_REQUEST: DWORD = 400; +pub const HTTP_STATUS_DENIED: DWORD = 401; +pub const HTTP_STATUS_PAYMENT_REQ: DWORD = 402; +pub const HTTP_STATUS_FORBIDDEN: DWORD = 403; +pub const HTTP_STATUS_NOT_FOUND: DWORD = 404; +pub const HTTP_STATUS_BAD_METHOD: DWORD = 405; +pub const HTTP_STATUS_NONE_ACCEPTABLE: DWORD = 406; +pub const HTTP_STATUS_PROXY_AUTH_REQ: DWORD = 407; +pub const HTTP_STATUS_REQUEST_TIMEOUT: DWORD = 408; +pub const HTTP_STATUS_CONFLICT: DWORD = 409; +pub const HTTP_STATUS_GONE: DWORD = 410; +pub const HTTP_STATUS_LENGTH_REQUIRED: DWORD = 411; +pub const HTTP_STATUS_PRECOND_FAILED: DWORD = 412; +pub const HTTP_STATUS_REQUEST_TOO_LARGE: DWORD = 413; +pub const HTTP_STATUS_URI_TOO_LONG: DWORD = 414; +pub const HTTP_STATUS_UNSUPPORTED_MEDIA: DWORD = 415; +pub const HTTP_STATUS_RETRY_WITH: DWORD = 449; +pub const HTTP_STATUS_SERVER_ERROR: DWORD = 500; +pub const HTTP_STATUS_NOT_SUPPORTED: DWORD = 501; +pub const HTTP_STATUS_BAD_GATEWAY: DWORD = 502; +pub const HTTP_STATUS_SERVICE_UNAVAIL: DWORD = 503; +pub const HTTP_STATUS_GATEWAY_TIMEOUT: DWORD = 504; +pub const HTTP_STATUS_VERSION_NOT_SUP: DWORD = 505; +pub const HTTP_STATUS_FIRST: DWORD = HTTP_STATUS_CONTINUE; +pub const HTTP_STATUS_LAST: DWORD = HTTP_STATUS_VERSION_NOT_SUP; +pub const WINHTTP_ACCESS_TYPE_DEFAULT_PROXY: DWORD = 0; +pub const WINHTTP_ACCESS_TYPE_NO_PROXY: DWORD = 1; +pub const WINHTTP_ACCESS_TYPE_NAMED_PROXY: DWORD = 3; +pub const WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY: DWORD = 4; +STRUCT!{struct WINHTTP_CURRENT_USER_IE_PROXY_CONFIG { + fAutoDetect: BOOL, + lpszAutoConfigUrl: LPWSTR, + lpszProxy: LPWSTR, + lpszProxyBypass: LPWSTR, +}} +pub const WINHTTP_ERROR_BASE: DWORD = 12000; +pub const ERROR_WINHTTP_OUT_OF_HANDLES: DWORD = WINHTTP_ERROR_BASE + 1; +pub const ERROR_WINHTTP_TIMEOUT: DWORD = WINHTTP_ERROR_BASE + 2; +pub const ERROR_WINHTTP_INTERNAL_ERROR: DWORD = WINHTTP_ERROR_BASE + 4; +pub const ERROR_WINHTTP_INVALID_URL: DWORD = WINHTTP_ERROR_BASE + 5; +pub const ERROR_WINHTTP_UNRECOGNIZED_SCHEME: DWORD = WINHTTP_ERROR_BASE + 6; +pub const ERROR_WINHTTP_NAME_NOT_RESOLVED: DWORD = WINHTTP_ERROR_BASE + 7; +pub const ERROR_WINHTTP_INVALID_OPTION: DWORD = WINHTTP_ERROR_BASE + 9; +pub const ERROR_WINHTTP_OPTION_NOT_SETTABLE: DWORD = WINHTTP_ERROR_BASE + 11; +pub const ERROR_WINHTTP_SHUTDOWN: DWORD = WINHTTP_ERROR_BASE + 12; +pub const ERROR_WINHTTP_LOGIN_FAILURE: DWORD = WINHTTP_ERROR_BASE + 15; +pub const ERROR_WINHTTP_OPERATION_CANCELLED: DWORD = WINHTTP_ERROR_BASE + 17; +pub const ERROR_WINHTTP_INCORRECT_HANDLE_TYPE: DWORD = WINHTTP_ERROR_BASE + 18; +pub const ERROR_WINHTTP_INCORRECT_HANDLE_STATE: DWORD = WINHTTP_ERROR_BASE + 19; +pub const ERROR_WINHTTP_CANNOT_CONNECT: DWORD = WINHTTP_ERROR_BASE + 29; +pub const ERROR_WINHTTP_CONNECTION_ERROR: DWORD = WINHTTP_ERROR_BASE + 30; +pub const ERROR_WINHTTP_RESEND_REQUEST: DWORD = WINHTTP_ERROR_BASE + 32; +pub const ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED: DWORD = WINHTTP_ERROR_BASE + 44; +pub const ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN: DWORD = WINHTTP_ERROR_BASE + 100; +pub const ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND: DWORD = WINHTTP_ERROR_BASE + 101; +pub const ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND: DWORD = WINHTTP_ERROR_BASE + 102; +pub const ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN: DWORD = WINHTTP_ERROR_BASE + 103; +pub const ERROR_WINHTTP_HEADER_NOT_FOUND: DWORD = WINHTTP_ERROR_BASE + 150; +pub const ERROR_WINHTTP_INVALID_SERVER_RESPONSE: DWORD = WINHTTP_ERROR_BASE + 152; +pub const ERROR_WINHTTP_INVALID_HEADER: DWORD = WINHTTP_ERROR_BASE + 153; +pub const ERROR_WINHTTP_INVALID_QUERY_REQUEST: DWORD = WINHTTP_ERROR_BASE + 154; +pub const ERROR_WINHTTP_HEADER_ALREADY_EXISTS: DWORD = WINHTTP_ERROR_BASE + 155; +pub const ERROR_WINHTTP_REDIRECT_FAILED: DWORD = WINHTTP_ERROR_BASE + 156; +pub const ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR: DWORD = WINHTTP_ERROR_BASE + 178; +pub const ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT: DWORD = WINHTTP_ERROR_BASE + 166; +pub const ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT: DWORD = WINHTTP_ERROR_BASE + 167; +pub const ERROR_WINHTTP_UNHANDLED_SCRIPT_TYPE: DWORD = WINHTTP_ERROR_BASE + 176; +pub const ERROR_WINHTTP_SCRIPT_EXECUTION_ERROR: DWORD = WINHTTP_ERROR_BASE + 177; +pub const ERROR_WINHTTP_NOT_INITIALIZED: DWORD = WINHTTP_ERROR_BASE + 172; +pub const ERROR_WINHTTP_SECURE_FAILURE: DWORD = WINHTTP_ERROR_BASE + 175; +pub const ERROR_WINHTTP_SECURE_CERT_DATE_INVALID: DWORD = WINHTTP_ERROR_BASE + 37; +pub const ERROR_WINHTTP_SECURE_CERT_CN_INVALID: DWORD = WINHTTP_ERROR_BASE + 38; +pub const ERROR_WINHTTP_SECURE_INVALID_CA: DWORD = WINHTTP_ERROR_BASE + 45; +pub const ERROR_WINHTTP_SECURE_CERT_REV_FAILED: DWORD = WINHTTP_ERROR_BASE + 57; +pub const ERROR_WINHTTP_SECURE_CHANNEL_ERROR: DWORD = WINHTTP_ERROR_BASE + 157; +pub const ERROR_WINHTTP_SECURE_INVALID_CERT: DWORD = WINHTTP_ERROR_BASE + 169; +pub const ERROR_WINHTTP_SECURE_CERT_REVOKED: DWORD = WINHTTP_ERROR_BASE + 170; +pub const ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE: DWORD = WINHTTP_ERROR_BASE + 179; +pub const ERROR_WINHTTP_AUTODETECTION_FAILED: DWORD = WINHTTP_ERROR_BASE + 180; +pub const ERROR_WINHTTP_HEADER_COUNT_EXCEEDED: DWORD = WINHTTP_ERROR_BASE + 181; +pub const ERROR_WINHTTP_HEADER_SIZE_OVERFLOW: DWORD = WINHTTP_ERROR_BASE + 182; +pub const ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW: DWORD = WINHTTP_ERROR_BASE + 183; +pub const ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW: DWORD = WINHTTP_ERROR_BASE + 184; +pub const ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY: DWORD = WINHTTP_ERROR_BASE + 185; +pub const ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY: DWORD = WINHTTP_ERROR_BASE + 186; +pub const WINHTTP_ERROR_LAST: DWORD = WINHTTP_ERROR_BASE + 186; +pub const WINHTTP_RESET_STATE: DWORD = 0x00000001; +pub const WINHTTP_RESET_SWPAD_CURRENT_NETWORK: DWORD = 0x00000002; +pub const WINHTTP_RESET_SWPAD_ALL: DWORD = 0x00000004; +pub const WINHTTP_RESET_SCRIPT_CACHE: DWORD = 0x00000008; +pub const WINHTTP_RESET_ALL: DWORD = 0x0000FFFF; +pub const WINHTTP_RESET_NOTIFY_NETWORK_CHANGED: DWORD = 0x00010000; +pub const WINHTTP_RESET_OUT_OF_PROC: DWORD = 0x00020000; +extern "system" { + pub fn WinHttpSetStatusCallback( + hInternet: HINTERNET, + lpfnInternetCallback: WINHTTP_STATUS_CALLBACK, + dwNotificationFlags: DWORD, + dwReserved: DWORD_PTR, + ) -> WINHTTP_STATUS_CALLBACK; + pub fn WinHttpTimeFromSystemTime( + pst: *const SYSTEMTIME, + pwszTime: LPWSTR, + ) -> BOOL; + pub fn WinHttpTimeToSystemTime( + pwszTime: LPCWSTR, + pst: *mut SYSTEMTIME, + ) -> BOOL; + pub fn WinHttpCrackUrl( + pwszUrl: LPCWSTR, + dwUrlLength: DWORD, + dwFlags: DWORD, + lpUrlComponents: LPURL_COMPONENTS, + ) -> BOOL; + pub fn WinHttpCreateUrl( + lpUrlComponents: LPURL_COMPONENTS, + dwFlags: DWORD, + pwszUrl: LPWSTR, + pdwUrlLength: LPDWORD, + ) -> BOOL; + pub fn WinHttpCheckPlatform() -> BOOL; + pub fn WinHttpGetDefaultProxyConfiguration( + pProxyInfo: *mut WINHTTP_PROXY_INFO, + ) -> BOOL; + pub fn WinHttpSetDefaultProxyConfiguration( + pProxyInfo: *mut WINHTTP_PROXY_INFO, + ) -> BOOL; + pub fn WinHttpOpen( + pszAgentW: LPCWSTR, + dwAccessType: DWORD, + pszProxyW: LPCWSTR, + pszProxyBypassW: LPCWSTR, + dwFlags: DWORD, + ) -> HINTERNET; + pub fn WinHttpCloseHandle( + hInternet: HINTERNET, + ) -> BOOL; + pub fn WinHttpConnect( + hSession: HINTERNET, + pswzServerName: LPCWSTR, + nServerPort: INTERNET_PORT, + dwReserved: DWORD, + ) -> HINTERNET; + pub fn WinHttpReadData( + hRequest: HINTERNET, + lpBuffer: LPVOID, + dwNumberOfBytesToRead: DWORD, + lpdwNumberOfBytesRead: LPDWORD, + ) -> BOOL; + pub fn WinHttpWriteData( + hRequest: HINTERNET, + lpBuffer: LPCVOID, + dwNumberOfBytesToWrite: DWORD, + lpdwNumberOfBytesWritten: LPDWORD, + ) -> BOOL; + pub fn WinHttpQueryDataAvailable( + hRequest: HINTERNET, + lpdwNumberOfBytesAvailable: LPDWORD, + ) -> BOOL; + pub fn WinHttpQueryOption( + hInternet: HINTERNET, + dwOption: DWORD, + lpBuffer: LPVOID, + lpdwBufferLength: LPDWORD, + ) -> BOOL; + pub fn WinHttpSetOption( + hInternet: HINTERNET, + dwOption: DWORD, + lpBuffer: LPVOID, + dwBufferLength: DWORD, + ) -> BOOL; + pub fn WinHttpSetTimeouts( + hInternet: HINTERNET, + nResolveTimeout: c_int, + nConnectTimeout: c_int, + nSendTimeout: c_int, + nReceiveTimeout: c_int, + ) -> BOOL; + pub fn WinHttpOpenRequest( + hConnect: HINTERNET, + pwszVerb: LPCWSTR, + pwszObjectName: LPCWSTR, + pwszVersion: LPCWSTR, + pwszReferrer: LPCWSTR, + ppwszAcceptTypes: *mut LPCWSTR, + dwFlags: DWORD, + ) -> HINTERNET; + pub fn WinHttpAddRequestHeaders( + hRequest: HINTERNET, + lpszHeaders: LPCWSTR, + dwHeadersLength: DWORD, + dwModifiers: DWORD, + ) -> BOOL; + pub fn WinHttpSendRequest( + hRequest: HINTERNET, + lpszHeaders: LPCWSTR, + dwHeadersLength: DWORD, + lpOptional: LPVOID, + dwOptionalLength: DWORD, + dwTotalLength: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn WinHttpSetCredentials( + hRequest: HINTERNET, + AuthTargets: DWORD, + AuthScheme: DWORD, + pwszUserName: LPCWSTR, + pwszPassword: LPCWSTR, + pAuthParams: LPVOID, + ) -> BOOL; + pub fn WinHttpQueryAuthSchemes( + hRequest: HINTERNET, + lpdwSupportedSchemes: LPDWORD, + lpdwFirstScheme: LPDWORD, + pdwAuthTarget: LPDWORD, + ) -> BOOL; + pub fn WinHttpReceiveResponse( + hRequest: HINTERNET, + lpReserved: LPVOID, + ) -> BOOL; + pub fn WinHttpQueryHeaders( + hRequest: HINTERNET, + dwInfoLevel: DWORD, + pwszName: LPCWSTR, + lpBuffer: LPVOID, + lpdwBufferLength: LPDWORD, + lpdwIndex: LPDWORD, + ) -> BOOL; + pub fn WinHttpDetectAutoProxyConfigUrl( + dwAutoDetectFlags: DWORD, + ppwstrAutoConfigUrl: *mut LPWSTR, + ) -> BOOL; + pub fn WinHttpGetProxyForUrl( + hSession: HINTERNET, + lpcwszUrl: LPCWSTR, + pAutoProxyOptions: *mut WINHTTP_AUTOPROXY_OPTIONS, + pProxyInfo: *mut WINHTTP_PROXY_INFO, + ) -> BOOL; + pub fn WinHttpCreateProxyResolver( + hSession: HINTERNET, + phResolver: *mut HINTERNET, + ) -> DWORD; + pub fn WinHttpGetProxyForUrlEx( + hResolver: HINTERNET, + pcwszUrl: PCWSTR, + pAutoProxyOptions: *mut WINHTTP_AUTOPROXY_OPTIONS, + pContext: DWORD_PTR, + ) -> DWORD; + pub fn WinHttpGetProxyResult( + hResolver: HINTERNET, + pProxyResult: *mut WINHTTP_PROXY_RESULT, + ) -> DWORD; + pub fn WinHttpFreeProxyResult( + pProxyResult: *mut WINHTTP_PROXY_RESULT, + ); + pub fn WinHttpResetAutoProxy( + hSession: HINTERNET, + dwFlags: DWORD, + ) -> DWORD; + pub fn WinHttpGetIEProxyConfigForCurrentUser( + pProxyConfig: *mut WINHTTP_CURRENT_USER_IE_PROXY_CONFIG, + ) -> BOOL; +} +ENUM!{enum WINHTTP_WEB_SOCKET_OPERATION { + WINHTTP_WEB_SOCKET_SEND_OPERATION = 0, + WINHTTP_WEB_SOCKET_RECEIVE_OPERATION = 1, + WINHTTP_WEB_SOCKET_CLOSE_OPERATION = 2, + WINHTTP_WEB_SOCKET_SHUTDOWN_OPERATION = 3, +}} +ENUM!{enum WINHTTP_WEB_SOCKET_BUFFER_TYPE { + WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE = 0, + WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE = 1, + WINHTTP_WEB_SOCKET_UTF8_MESSAGE_BUFFER_TYPE = 2, + WINHTTP_WEB_SOCKET_UTF8_FRAGMENT_BUFFER_TYPE = 3, + WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE = 4, +}} +ENUM!{enum WINHTTP_WEB_SOCKET_CLOSE_STATUS { + WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS = 1000, + WINHTTP_WEB_SOCKET_ENDPOINT_TERMINATED_CLOSE_STATUS = 1001, + WINHTTP_WEB_SOCKET_PROTOCOL_ERROR_CLOSE_STATUS = 1002, + WINHTTP_WEB_SOCKET_INVALID_DATA_TYPE_CLOSE_STATUS = 1003, + WINHTTP_WEB_SOCKET_EMPTY_CLOSE_STATUS = 1005, + WINHTTP_WEB_SOCKET_ABORTED_CLOSE_STATUS = 1006, + WINHTTP_WEB_SOCKET_INVALID_PAYLOAD_CLOSE_STATUS = 1007, + WINHTTP_WEB_SOCKET_POLICY_VIOLATION_CLOSE_STATUS = 1008, + WINHTTP_WEB_SOCKET_MESSAGE_TOO_BIG_CLOSE_STATUS = 1009, + WINHTTP_WEB_SOCKET_UNSUPPORTED_EXTENSIONS_CLOSE_STATUS = 1010, + WINHTTP_WEB_SOCKET_SERVER_ERROR_CLOSE_STATUS = 1011, + WINHTTP_WEB_SOCKET_SECURE_HANDSHAKE_ERROR_CLOSE_STATUS = 1015, +}} +extern "system" { + pub fn WinHttpWebSocketCompleteUpgrade( + hRequest: HINTERNET, + pContext: DWORD_PTR, + ) -> HINTERNET; + pub fn WinHttpWebSocketSend( + hWebSocket: HINTERNET, + eBufferType: WINHTTP_WEB_SOCKET_BUFFER_TYPE, + pvBuffer: PVOID, + dwBufferLength: DWORD, + ) -> DWORD; + pub fn WinHttpWebSocketReceive( + hWebSocket: HINTERNET, + pvBuffer: PVOID, + dwBufferLength: DWORD, + pdwBytesRead: *mut DWORD, + peBufferType: *mut WINHTTP_WEB_SOCKET_BUFFER_TYPE, + ) -> DWORD; + pub fn WinHttpWebSocketShutdown( + hWebSocket: HINTERNET, + usStatus: USHORT, + pvReason: PVOID, + dwReasonLength: DWORD, + ) -> DWORD; + pub fn WinHttpWebSocketClose( + hWebSocket: HINTERNET, + usStatus: USHORT, + pvReason: PVOID, + dwReasonLength: DWORD, + ) -> DWORD; + pub fn WinHttpWebSocketQueryCloseStatus( + hWebSocket: HINTERNET, + pusStatus: *mut USHORT, + pvReason: PVOID, + dwReasonLength: DWORD, + pdwReasonLengthConsumed: *mut DWORD, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wininet.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wininet.rs new file mode 100644 index 0000000..9a83d6a --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wininet.rs @@ -0,0 +1,2364 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Windows Internet Services API procedure declarations, types and constants. +use ctypes::c_int; +use shared::basetsd::DWORD_PTR; +use shared::minwindef::{ + BOOL, DWORD, FALSE, FILETIME, INT, LPBYTE, + LPCVOID, LPDWORD, LPVOID, PBYTE, PDWORD, TRUE, WORD, +}; +use shared::ntdef::{LONG, LONGLONG, PLONG}; +use shared::windef::HWND; +use um::minwinbase::{LPWIN32_FIND_DATAA, LPWIN32_FIND_DATAW, SYSTEMTIME}; +use um::winineti::INTERNET_FLAG_BGUPDATE; +use um::winnt::{ + CHAR, DWORDLONG, HANDLE, LPCSTR, LPCWSTR, + LPSTR, LPWSTR, PCWSTR, PSTR, PWSTR, WCHAR, +}; +pub type HINTERNET = LPVOID; +pub type LPHINTERNET = *mut HINTERNET; +pub type INTERNET_PORT = WORD; +pub type LPINTERNET_PORT = *mut INTERNET_PORT; +pub const INTERNET_INVALID_PORT_NUMBER: DWORD = 0; +pub const INTERNET_DEFAULT_FTP_PORT: DWORD = 21; +pub const INTERNET_DEFAULT_GOPHER_PORT: DWORD = 70; +pub const INTERNET_DEFAULT_HTTP_PORT: DWORD = 80; +pub const INTERNET_DEFAULT_HTTPS_PORT: DWORD = 443; +pub const INTERNET_DEFAULT_SOCKS_PORT: DWORD = 1080; +pub const INTERNET_MAX_HOST_NAME_LENGTH: usize = 256; +pub const INTERNET_MAX_USER_NAME_LENGTH: usize = 128; +pub const INTERNET_MAX_PASSWORD_LENGTH: usize = 128; +pub const INTERNET_MAX_PORT_NUMBER_LENGTH: usize = 5; +pub const INTERNET_MAX_PORT_NUMBER_VALUE: DWORD = 65535; +pub const INTERNET_MAX_PATH_LENGTH: usize = 2048; +pub const INTERNET_MAX_SCHEME_LENGTH: usize = 32; +pub const INTERNET_MAX_URL_LENGTH: usize = INTERNET_MAX_SCHEME_LENGTH + 3 + + INTERNET_MAX_PATH_LENGTH; +pub const INTERNET_KEEP_ALIVE_UNKNOWN: DWORD = -1i32 as u32; +pub const INTERNET_KEEP_ALIVE_ENABLED: DWORD = 1; +pub const INTERNET_KEEP_ALIVE_DISABLED: DWORD = 0; +pub const INTERNET_REQFLAG_FROM_CACHE: DWORD = 0x00000001; +pub const INTERNET_REQFLAG_ASYNC: DWORD = 0x00000002; +pub const INTERNET_REQFLAG_VIA_PROXY: DWORD = 0x00000004; +pub const INTERNET_REQFLAG_NO_HEADERS: DWORD = 0x00000008; +pub const INTERNET_REQFLAG_PASSIVE: DWORD = 0x00000010; +pub const INTERNET_REQFLAG_CACHE_WRITE_DISABLED: DWORD = 0x00000040; +pub const INTERNET_REQFLAG_NET_TIMEOUT: DWORD = 0x00000080; +pub const INTERNET_FLAG_IDN_DIRECT: DWORD = 0x00000001; +pub const INTERNET_FLAG_IDN_PROXY: DWORD = 0x00000002; +pub const INTERNET_FLAG_RELOAD: DWORD = 0x80000000; +pub const INTERNET_FLAG_RAW_DATA: DWORD = 0x40000000; +pub const INTERNET_FLAG_EXISTING_CONNECT: DWORD = 0x20000000; +pub const INTERNET_FLAG_ASYNC: DWORD = 0x10000000; +pub const INTERNET_FLAG_PASSIVE: DWORD = 0x08000000; +pub const INTERNET_FLAG_NO_CACHE_WRITE: DWORD = 0x04000000; +pub const INTERNET_FLAG_DONT_CACHE: DWORD = INTERNET_FLAG_NO_CACHE_WRITE; +pub const INTERNET_FLAG_MAKE_PERSISTENT: DWORD = 0x02000000; +pub const INTERNET_FLAG_FROM_CACHE: DWORD = 0x01000000; +pub const INTERNET_FLAG_OFFLINE: DWORD = INTERNET_FLAG_FROM_CACHE; +pub const INTERNET_FLAG_SECURE: DWORD = 0x00800000; +pub const INTERNET_FLAG_KEEP_CONNECTION: DWORD = 0x00400000; +pub const INTERNET_FLAG_NO_AUTO_REDIRECT: DWORD = 0x00200000; +pub const INTERNET_FLAG_READ_PREFETCH: DWORD = 0x00100000; +pub const INTERNET_FLAG_NO_COOKIES: DWORD = 0x00080000; +pub const INTERNET_FLAG_NO_AUTH: DWORD = 0x00040000; +pub const INTERNET_FLAG_RESTRICTED_ZONE: DWORD = 0x00020000; +pub const INTERNET_FLAG_CACHE_IF_NET_FAIL: DWORD = 0x00010000; +pub const INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP: DWORD = 0x00008000; +pub const INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS: DWORD = 0x00004000; +pub const INTERNET_FLAG_IGNORE_CERT_DATE_INVALID: DWORD = 0x00002000; +pub const INTERNET_FLAG_IGNORE_CERT_CN_INVALID: DWORD = 0x00001000; +pub const INTERNET_FLAG_RESYNCHRONIZE: DWORD = 0x00000800; +pub const INTERNET_FLAG_HYPERLINK: DWORD = 0x00000400; +pub const INTERNET_FLAG_NO_UI: DWORD = 0x00000200; +pub const INTERNET_FLAG_PRAGMA_NOCACHE: DWORD = 0x00000100; +pub const INTERNET_FLAG_CACHE_ASYNC: DWORD = 0x00000080; +pub const INTERNET_FLAG_FORMS_SUBMIT: DWORD = 0x00000040; +pub const INTERNET_FLAG_FWD_BACK: DWORD = 0x00000020; +pub const INTERNET_FLAG_NEED_FILE: DWORD = 0x00000010; +pub const INTERNET_FLAG_MUST_CACHE_REQUEST: DWORD = INTERNET_FLAG_NEED_FILE; +pub const INTERNET_FLAG_TRANSFER_ASCII: DWORD = FTP_TRANSFER_TYPE_ASCII; +pub const INTERNET_FLAG_TRANSFER_BINARY: DWORD = FTP_TRANSFER_TYPE_BINARY; +pub const SECURITY_INTERNET_MASK: DWORD = INTERNET_FLAG_IGNORE_CERT_CN_INVALID + | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS + | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP; +pub const SECURITY_IGNORE_ERROR_MASK: DWORD = INTERNET_FLAG_IGNORE_CERT_CN_INVALID + | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | SECURITY_FLAG_IGNORE_UNKNOWN_CA + | SECURITY_FLAG_IGNORE_REVOCATION; +pub const INTERNET_FLAGS_MASK: DWORD = INTERNET_FLAG_RELOAD | INTERNET_FLAG_RAW_DATA + | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_ASYNC | INTERNET_FLAG_PASSIVE + | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_MAKE_PERSISTENT | INTERNET_FLAG_FROM_CACHE + | INTERNET_FLAG_SECURE | INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_AUTO_REDIRECT + | INTERNET_FLAG_READ_PREFETCH | INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_AUTH + | INTERNET_FLAG_CACHE_IF_NET_FAIL | SECURITY_INTERNET_MASK | INTERNET_FLAG_RESYNCHRONIZE + | INTERNET_FLAG_HYPERLINK | INTERNET_FLAG_NO_UI | INTERNET_FLAG_PRAGMA_NOCACHE + | INTERNET_FLAG_CACHE_ASYNC | INTERNET_FLAG_FORMS_SUBMIT | INTERNET_FLAG_NEED_FILE + | INTERNET_FLAG_RESTRICTED_ZONE | INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_TRANSFER_ASCII + | INTERNET_FLAG_FWD_BACK | INTERNET_FLAG_BGUPDATE; +pub const INTERNET_ERROR_MASK_INSERT_CDROM: DWORD = 0x1; +pub const INTERNET_ERROR_MASK_COMBINED_SEC_CERT: DWORD = 0x2; +pub const INTERNET_ERROR_MASK_NEED_MSN_SSPI_PKG: DWORD = 0x4; +pub const INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY: DWORD = 0x8; +pub const INTERNET_OPTIONS_MASK: DWORD = !INTERNET_FLAGS_MASK; +pub const WININET_API_FLAG_ASYNC: DWORD = 0x00000001; +pub const WININET_API_FLAG_SYNC: DWORD = 0x00000004; +pub const WININET_API_FLAG_USE_CONTEXT: DWORD = 0x00000008; +pub const INTERNET_NO_CALLBACK: DWORD = 0; +ENUM!{enum INTERNET_SCHEME { + INTERNET_SCHEME_PARTIAL = -2i32 as u32, + INTERNET_SCHEME_UNKNOWN = -1i32 as u32, + INTERNET_SCHEME_DEFAULT = 0, + INTERNET_SCHEME_FTP, + INTERNET_SCHEME_GOPHER, + INTERNET_SCHEME_HTTP, + INTERNET_SCHEME_HTTPS, + INTERNET_SCHEME_FILE, + INTERNET_SCHEME_NEWS, + INTERNET_SCHEME_MAILTO, + INTERNET_SCHEME_SOCKS, + INTERNET_SCHEME_JAVASCRIPT, + INTERNET_SCHEME_VBSCRIPT, + INTERNET_SCHEME_RES, + INTERNET_SCHEME_FIRST = INTERNET_SCHEME_FTP, + INTERNET_SCHEME_LAST = INTERNET_SCHEME_RES, +}} +pub type LPINTERNET_SCHEME = *mut INTERNET_SCHEME; +STRUCT!{struct INTERNET_ASYNC_RESULT { + dwResult: DWORD_PTR, + dwError: DWORD, +}} +pub type LPINTERNET_ASYNC_RESULT = *mut INTERNET_ASYNC_RESULT; +STRUCT!{struct INTERNET_DIAGNOSTIC_SOCKET_INFO { + Socket: DWORD_PTR, + SourcePort: DWORD, + DestPort: DWORD, + Flags: DWORD, +}} +pub type LPINTERNET_DIAGNOSTIC_SOCKET_INFO = *mut INTERNET_DIAGNOSTIC_SOCKET_INFO; +pub const IDSI_FLAG_KEEP_ALIVE: DWORD = 0x00000001; +pub const IDSI_FLAG_SECURE: DWORD = 0x00000002; +pub const IDSI_FLAG_PROXY: DWORD = 0x00000004; +pub const IDSI_FLAG_TUNNEL: DWORD = 0x00000008; +STRUCT!{struct INTERNET_PROXY_INFO { + dwAccessType: DWORD, + lpszProxy: LPCWSTR, + lpszProxyBypass: LPCWSTR, +}} +pub type LPINTERNET_PROXY_INFO = *mut INTERNET_PROXY_INFO; +UNION!{union INTERNET_PER_CONN_OPTIONA_Value { + [u32; 2] [u64; 1], + dwValue dwValue_mut: DWORD, + pszValue pszValue_mut: LPSTR, + ftValue ftValue_mut: FILETIME, +}} +STRUCT!{struct INTERNET_PER_CONN_OPTIONA { + dwOption: DWORD, + Value: INTERNET_PER_CONN_OPTIONA_Value, +}} +pub type LPINTERNET_PER_CONN_OPTIONA = *mut INTERNET_PER_CONN_OPTIONA; +UNION!{union INTERNET_PER_CONN_OPTIONW_Value { + [u32; 2] [u64; 1], + dwValue dwValue_mut: DWORD, + pszValue pszValue_mut: LPWSTR, + ftValue ftValue_mut: FILETIME, +}} +STRUCT!{struct INTERNET_PER_CONN_OPTIONW { + dwOption: DWORD, + Value: INTERNET_PER_CONN_OPTIONW_Value, +}} +pub type LPINTERNET_PER_CONN_OPTIONW = *mut INTERNET_PER_CONN_OPTIONW; +STRUCT!{struct INTERNET_PER_CONN_OPTION_LISTA { + dwSize: DWORD, + pszConnection: LPSTR, + dwOptionCount: DWORD, + dwOptionError: DWORD, + pOptions: LPINTERNET_PER_CONN_OPTIONA, +}} +pub type LPINTERNET_PER_CONN_OPTION_LISTA = *mut INTERNET_PER_CONN_OPTION_LISTA; +STRUCT!{struct INTERNET_PER_CONN_OPTION_LISTW { + dwSize: DWORD, + pszConnection: LPWSTR, + dwOptionCount: DWORD, + dwOptionError: DWORD, + pOptions: LPINTERNET_PER_CONN_OPTIONW, +}} +pub type LPINTERNET_PER_CONN_OPTION_LISTW = *mut INTERNET_PER_CONN_OPTION_LISTW; +pub const INTERNET_PER_CONN_FLAGS: DWORD = 1; +pub const INTERNET_PER_CONN_PROXY_SERVER: DWORD = 2; +pub const INTERNET_PER_CONN_PROXY_BYPASS: DWORD = 3; +pub const INTERNET_PER_CONN_AUTOCONFIG_URL: DWORD = 4; +pub const INTERNET_PER_CONN_AUTODISCOVERY_FLAGS: DWORD = 5; +pub const INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL: DWORD = 6; +pub const INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS: DWORD = 7; +pub const INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME: DWORD = 8; +pub const INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL: DWORD = 9; +pub const INTERNET_PER_CONN_FLAGS_UI: DWORD = 10; +pub const PROXY_TYPE_DIRECT: DWORD = 0x00000001; +pub const PROXY_TYPE_PROXY: DWORD = 0x00000002; +pub const PROXY_TYPE_AUTO_PROXY_URL: DWORD = 0x00000004; +pub const PROXY_TYPE_AUTO_DETECT: DWORD = 0x00000008; +pub const AUTO_PROXY_FLAG_USER_SET: DWORD = 0x00000001; +pub const AUTO_PROXY_FLAG_ALWAYS_DETECT: DWORD = 0x00000002; +pub const AUTO_PROXY_FLAG_DETECTION_RUN: DWORD = 0x00000004; +pub const AUTO_PROXY_FLAG_MIGRATED: DWORD = 0x00000008; +pub const AUTO_PROXY_FLAG_DONT_CACHE_PROXY_RESULT: DWORD = 0x00000010; +pub const AUTO_PROXY_FLAG_CACHE_INIT_RUN: DWORD = 0x00000020; +pub const AUTO_PROXY_FLAG_DETECTION_SUSPECT: DWORD = 0x00000040; +STRUCT!{struct INTERNET_VERSION_INFO { + dwMajorVersion: DWORD, + dwMinorVersion: DWORD, +}} +pub type LPINTERNET_VERSION_INFO = *mut INTERNET_VERSION_INFO; +STRUCT!{struct HTTP_VERSION_INFO { + dwMajorVersion: DWORD, + dwMinorVersion: DWORD, +}} +pub type LPHTTP_VERSION_INFO = *mut HTTP_VERSION_INFO; +STRUCT!{struct INTERNET_CONNECTED_INFO { + dwConnectedState: DWORD, + dwFlags: DWORD, +}} +pub type LPINTERNET_CONNECTED_INFO = *mut INTERNET_CONNECTED_INFO; +pub const ISO_FORCE_DISCONNECTED: DWORD = 0x00000001; +STRUCT!{struct URL_COMPONENTSA { + dwStructSize: DWORD, + lpszScheme: LPSTR, + dwSchemeLength: DWORD, + nScheme: INTERNET_SCHEME, + lpszHostName: LPSTR, + dwHostNameLength: DWORD, + nPort: INTERNET_PORT, + lpszUserName: LPSTR, + dwUserNameLength: DWORD, + lpszPassword: LPSTR, + dwPasswordLength: DWORD, + lpszUrlPath: LPSTR, + dwUrlPathLength: DWORD, + lpszExtraInfo: LPSTR, + dwExtraInfoLength: DWORD, +}} +pub type LPURL_COMPONENTSA = *mut URL_COMPONENTSA; +STRUCT!{struct URL_COMPONENTSW { + dwStructSize: DWORD, + lpszScheme: LPWSTR, + dwSchemeLength: DWORD, + nScheme: INTERNET_SCHEME, + lpszHostName: LPWSTR, + dwHostNameLength: DWORD, + nPort: INTERNET_PORT, + lpszUserName: LPWSTR, + dwUserNameLength: DWORD, + lpszPassword: LPWSTR, + dwPasswordLength: DWORD, + lpszUrlPath: LPWSTR, + dwUrlPathLength: DWORD, + lpszExtraInfo: LPWSTR, + dwExtraInfoLength: DWORD, +}} +pub type LPURL_COMPONENTSW = *mut URL_COMPONENTSW; +STRUCT!{struct INTERNET_CERTIFICATE_INFO { + ftExpiry: FILETIME, + ftStart: FILETIME, + lpszSubjectInfo: LPWSTR, + lpszIssuerInfo: LPWSTR, + lpszProtocolName: LPWSTR, + lpszSignatureAlgName: LPWSTR, + lpszEncryptionAlgName: LPWSTR, + dwKeySize: DWORD, +}} +pub type LPINTERNET_CERTIFICATE_INFO = *mut INTERNET_CERTIFICATE_INFO; +STRUCT!{struct INTERNET_BUFFERSA { + dwStructSize: DWORD, + Next: *mut INTERNET_BUFFERSA, + lpcszHeader: LPCSTR, + dwHeadersLength: DWORD, + dwHeadersTotal: DWORD, + lpvBuffer: LPVOID, + dwBufferLength: DWORD, + dwBufferTotal: DWORD, + dwOffsetLow: DWORD, + dwOffsetHigh: DWORD, +}} +pub type LPINTERNET_BUFFERSA = *mut INTERNET_BUFFERSA; +STRUCT!{struct INTERNET_BUFFERSW { + dwStructSize: DWORD, + Next: *mut INTERNET_BUFFERSW, + lpcszHeader: LPCWSTR, + dwHeadersLength: DWORD, + dwHeadersTotal: DWORD, + lpvBuffer: LPVOID, + dwBufferLength: DWORD, + dwBufferTotal: DWORD, + dwOffsetLow: DWORD, + dwOffsetHigh: DWORD, +}} +pub type LPINTERNET_BUFFERSW = *mut INTERNET_BUFFERSW; +pub const INTERNET_RFC1123_FORMAT: DWORD = 0; +pub const INTERNET_RFC1123_BUFSIZE: DWORD = 30; +pub const ICU_ESCAPE: DWORD = 0x80000000; +pub const ICU_USERNAME: DWORD = 0x40000000; +pub const ICU_NO_ENCODE: DWORD = 0x20000000; +pub const ICU_DECODE: DWORD = 0x10000000; +pub const ICU_NO_META: DWORD = 0x08000000; +pub const ICU_ENCODE_SPACES_ONLY: DWORD = 0x04000000; +pub const ICU_BROWSER_MODE: DWORD = 0x02000000; +pub const ICU_ENCODE_PERCENT: DWORD = 0x00001000; +pub const INTERNET_OPEN_TYPE_PRECONFIG: DWORD = 0; +pub const INTERNET_OPEN_TYPE_DIRECT: DWORD = 1; +pub const INTERNET_OPEN_TYPE_PROXY: DWORD = 3; +pub const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY: DWORD = 4; +pub const PRE_CONFIG_INTERNET_ACCESS: DWORD = INTERNET_OPEN_TYPE_PRECONFIG; +pub const LOCAL_INTERNET_ACCESS: DWORD = INTERNET_OPEN_TYPE_DIRECT; +pub const CERN_PROXY_INTERNET_ACCESS: DWORD = INTERNET_OPEN_TYPE_PROXY; +pub const INTERNET_SERVICE_FTP: DWORD = 1; +pub const INTERNET_SERVICE_GOPHER: DWORD = 2; +pub const INTERNET_SERVICE_HTTP: DWORD = 3; +pub const IRF_ASYNC: DWORD = WININET_API_FLAG_ASYNC; +pub const IRF_SYNC: DWORD = WININET_API_FLAG_SYNC; +pub const IRF_USE_CONTEXT: DWORD = WININET_API_FLAG_USE_CONTEXT; +pub const IRF_NO_WAIT: DWORD = 0x00000008; +pub const ISO_GLOBAL: DWORD = 0x00000001; +pub const ISO_REGISTRY: DWORD = 0x00000002; +pub const ISO_VALID_FLAGS: DWORD = ISO_GLOBAL | ISO_REGISTRY; +pub const INTERNET_OPTION_CALLBACK: DWORD = 1; +pub const INTERNET_OPTION_CONNECT_TIMEOUT: DWORD = 2; +pub const INTERNET_OPTION_CONNECT_RETRIES: DWORD = 3; +pub const INTERNET_OPTION_CONNECT_BACKOFF: DWORD = 4; +pub const INTERNET_OPTION_SEND_TIMEOUT: DWORD = 5; +pub const INTERNET_OPTION_CONTROL_SEND_TIMEOUT: DWORD = INTERNET_OPTION_SEND_TIMEOUT; +pub const INTERNET_OPTION_RECEIVE_TIMEOUT: DWORD = 6; +pub const INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT: DWORD = INTERNET_OPTION_RECEIVE_TIMEOUT; +pub const INTERNET_OPTION_DATA_SEND_TIMEOUT: DWORD = 7; +pub const INTERNET_OPTION_DATA_RECEIVE_TIMEOUT: DWORD = 8; +pub const INTERNET_OPTION_HANDLE_TYPE: DWORD = 9; +pub const INTERNET_OPTION_LISTEN_TIMEOUT: DWORD = 11; +pub const INTERNET_OPTION_READ_BUFFER_SIZE: DWORD = 12; +pub const INTERNET_OPTION_WRITE_BUFFER_SIZE: DWORD = 13; +pub const INTERNET_OPTION_ASYNC_ID: DWORD = 15; +pub const INTERNET_OPTION_ASYNC_PRIORITY: DWORD = 16; +pub const INTERNET_OPTION_PARENT_HANDLE: DWORD = 21; +pub const INTERNET_OPTION_KEEP_CONNECTION: DWORD = 22; +pub const INTERNET_OPTION_REQUEST_FLAGS: DWORD = 23; +pub const INTERNET_OPTION_EXTENDED_ERROR: DWORD = 24; +pub const INTERNET_OPTION_OFFLINE_MODE: DWORD = 26; +pub const INTERNET_OPTION_CACHE_STREAM_HANDLE: DWORD = 27; +pub const INTERNET_OPTION_USERNAME: DWORD = 28; +pub const INTERNET_OPTION_PASSWORD: DWORD = 29; +pub const INTERNET_OPTION_ASYNC: DWORD = 30; +pub const INTERNET_OPTION_SECURITY_FLAGS: DWORD = 31; +pub const INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT: DWORD = 32; +pub const INTERNET_OPTION_DATAFILE_NAME: DWORD = 33; +pub const INTERNET_OPTION_URL: DWORD = 34; +pub const INTERNET_OPTION_SECURITY_CERTIFICATE: DWORD = 35; +pub const INTERNET_OPTION_SECURITY_KEY_BITNESS: DWORD = 36; +pub const INTERNET_OPTION_REFRESH: DWORD = 37; +pub const INTERNET_OPTION_PROXY: DWORD = 38; +pub const INTERNET_OPTION_SETTINGS_CHANGED: DWORD = 39; +pub const INTERNET_OPTION_VERSION: DWORD = 40; +pub const INTERNET_OPTION_USER_AGENT: DWORD = 41; +pub const INTERNET_OPTION_END_BROWSER_SESSION: DWORD = 42; +pub const INTERNET_OPTION_PROXY_USERNAME: DWORD = 43; +pub const INTERNET_OPTION_PROXY_PASSWORD: DWORD = 44; +pub const INTERNET_OPTION_CONTEXT_VALUE: DWORD = 45; +pub const INTERNET_OPTION_CONNECT_LIMIT: DWORD = 46; +pub const INTERNET_OPTION_SECURITY_SELECT_CLIENT_CERT: DWORD = 47; +pub const INTERNET_OPTION_POLICY: DWORD = 48; +pub const INTERNET_OPTION_DISCONNECTED_TIMEOUT: DWORD = 49; +pub const INTERNET_OPTION_CONNECTED_STATE: DWORD = 50; +pub const INTERNET_OPTION_IDLE_STATE: DWORD = 51; +pub const INTERNET_OPTION_OFFLINE_SEMANTICS: DWORD = 52; +pub const INTERNET_OPTION_SECONDARY_CACHE_KEY: DWORD = 53; +pub const INTERNET_OPTION_CALLBACK_FILTER: DWORD = 54; +pub const INTERNET_OPTION_CONNECT_TIME: DWORD = 55; +pub const INTERNET_OPTION_SEND_THROUGHPUT: DWORD = 56; +pub const INTERNET_OPTION_RECEIVE_THROUGHPUT: DWORD = 57; +pub const INTERNET_OPTION_REQUEST_PRIORITY: DWORD = 58; +pub const INTERNET_OPTION_HTTP_VERSION: DWORD = 59; +pub const INTERNET_OPTION_RESET_URLCACHE_SESSION: DWORD = 60; +pub const INTERNET_OPTION_ERROR_MASK: DWORD = 62; +pub const INTERNET_OPTION_FROM_CACHE_TIMEOUT: DWORD = 63; +pub const INTERNET_OPTION_BYPASS_EDITED_ENTRY: DWORD = 64; +pub const INTERNET_OPTION_HTTP_DECODING: DWORD = 65; +pub const INTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO: DWORD = 67; +pub const INTERNET_OPTION_CODEPAGE: DWORD = 68; +pub const INTERNET_OPTION_CACHE_TIMESTAMPS: DWORD = 69; +pub const INTERNET_OPTION_DISABLE_AUTODIAL: DWORD = 70; +pub const INTERNET_OPTION_MAX_CONNS_PER_SERVER: DWORD = 73; +pub const INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER: DWORD = 74; +pub const INTERNET_OPTION_PER_CONNECTION_OPTION: DWORD = 75; +pub const INTERNET_OPTION_DIGEST_AUTH_UNLOAD: DWORD = 76; +pub const INTERNET_OPTION_IGNORE_OFFLINE: DWORD = 77; +pub const INTERNET_OPTION_IDENTITY: DWORD = 78; +pub const INTERNET_OPTION_REMOVE_IDENTITY: DWORD = 79; +pub const INTERNET_OPTION_ALTER_IDENTITY: DWORD = 80; +pub const INTERNET_OPTION_SUPPRESS_BEHAVIOR: DWORD = 81; +pub const INTERNET_OPTION_AUTODIAL_MODE: DWORD = 82; +pub const INTERNET_OPTION_AUTODIAL_CONNECTION: DWORD = 83; +pub const INTERNET_OPTION_CLIENT_CERT_CONTEXT: DWORD = 84; +pub const INTERNET_OPTION_AUTH_FLAGS: DWORD = 85; +pub const INTERNET_OPTION_COOKIES_3RD_PARTY: DWORD = 86; +pub const INTERNET_OPTION_DISABLE_PASSPORT_AUTH: DWORD = 87; +pub const INTERNET_OPTION_SEND_UTF8_SERVERNAME_TO_PROXY: DWORD = 88; +pub const INTERNET_OPTION_EXEMPT_CONNECTION_LIMIT: DWORD = 89; +pub const INTERNET_OPTION_ENABLE_PASSPORT_AUTH: DWORD = 90; +pub const INTERNET_OPTION_HIBERNATE_INACTIVE_WORKER_THREADS: DWORD = 91; +pub const INTERNET_OPTION_ACTIVATE_WORKER_THREADS: DWORD = 92; +pub const INTERNET_OPTION_RESTORE_WORKER_THREAD_DEFAULTS: DWORD = 93; +pub const INTERNET_OPTION_SOCKET_SEND_BUFFER_LENGTH: DWORD = 94; +pub const INTERNET_OPTION_PROXY_SETTINGS_CHANGED: DWORD = 95; +pub const INTERNET_OPTION_DATAFILE_EXT: DWORD = 96; +pub const INTERNET_OPTION_CODEPAGE_PATH: DWORD = 100; +pub const INTERNET_OPTION_CODEPAGE_EXTRA: DWORD = 101; +pub const INTERNET_OPTION_IDN: DWORD = 102; +pub const INTERNET_OPTION_MAX_CONNS_PER_PROXY: DWORD = 103; +pub const INTERNET_OPTION_SUPPRESS_SERVER_AUTH: DWORD = 104; +pub const INTERNET_OPTION_SERVER_CERT_CHAIN_CONTEXT: DWORD = 105; +pub const INTERNET_OPTION_ENABLE_REDIRECT_CACHE_READ: DWORD = 122; +pub const INTERNET_OPTION_ENCODE_EXTRA: DWORD = 155; +pub const INTERNET_FIRST_OPTION: DWORD = INTERNET_OPTION_CALLBACK; +pub const INTERNET_LAST_OPTION: DWORD = INTERNET_OPTION_ENCODE_EXTRA; +pub const INTERNET_PRIORITY_FOREGROUND: DWORD = 1000; +pub const INTERNET_HANDLE_TYPE_INTERNET: DWORD = 1; +pub const INTERNET_HANDLE_TYPE_CONNECT_FTP: DWORD = 2; +pub const INTERNET_HANDLE_TYPE_CONNECT_GOPHER: DWORD = 3; +pub const INTERNET_HANDLE_TYPE_CONNECT_HTTP: DWORD = 4; +pub const INTERNET_HANDLE_TYPE_FTP_FIND: DWORD = 5; +pub const INTERNET_HANDLE_TYPE_FTP_FIND_HTML: DWORD = 6; +pub const INTERNET_HANDLE_TYPE_FTP_FILE: DWORD = 7; +pub const INTERNET_HANDLE_TYPE_FTP_FILE_HTML: DWORD = 8; +pub const INTERNET_HANDLE_TYPE_GOPHER_FIND: DWORD = 9; +pub const INTERNET_HANDLE_TYPE_GOPHER_FIND_HTML: DWORD = 10; +pub const INTERNET_HANDLE_TYPE_GOPHER_FILE: DWORD = 11; +pub const INTERNET_HANDLE_TYPE_GOPHER_FILE_HTML: DWORD = 12; +pub const INTERNET_HANDLE_TYPE_HTTP_REQUEST: DWORD = 13; +pub const INTERNET_HANDLE_TYPE_FILE_REQUEST: DWORD = 14; +pub const AUTH_FLAG_DISABLE_NEGOTIATE: DWORD = 0x00000001; +pub const AUTH_FLAG_ENABLE_NEGOTIATE: DWORD = 0x00000002; +pub const AUTH_FLAG_DISABLE_BASIC_CLEARCHANNEL: DWORD = 0x00000004; +pub const AUTH_FLAG_DISABLE_SERVER_AUTH: DWORD = 0x00000008; +pub const SECURITY_FLAG_SECURE: DWORD = 0x00000001; +pub const SECURITY_FLAG_STRENGTH_WEAK: DWORD = 0x10000000; +pub const SECURITY_FLAG_STRENGTH_MEDIUM: DWORD = 0x40000000; +pub const SECURITY_FLAG_STRENGTH_STRONG: DWORD = 0x20000000; +pub const SECURITY_FLAG_UNKNOWNBIT: DWORD = 0x80000000; +pub const SECURITY_FLAG_FORTEZZA: DWORD = 0x08000000; +pub const SECURITY_FLAG_NORMALBITNESS: DWORD = SECURITY_FLAG_STRENGTH_WEAK; +pub const SECURITY_FLAG_SSL: DWORD = 0x00000002; +pub const SECURITY_FLAG_SSL3: DWORD = 0x00000004; +pub const SECURITY_FLAG_PCT: DWORD = 0x00000008; +pub const SECURITY_FLAG_PCT4: DWORD = 0x00000010; +pub const SECURITY_FLAG_IETFSSL4: DWORD = 0x00000020; +pub const SECURITY_FLAG_40BIT: DWORD = SECURITY_FLAG_STRENGTH_WEAK; +pub const SECURITY_FLAG_128BIT: DWORD = SECURITY_FLAG_STRENGTH_STRONG; +pub const SECURITY_FLAG_56BIT: DWORD = SECURITY_FLAG_STRENGTH_MEDIUM; +pub const SECURITY_FLAG_IGNORE_REVOCATION: DWORD = 0x00000080; +pub const SECURITY_FLAG_IGNORE_UNKNOWN_CA: DWORD = 0x00000100; +pub const SECURITY_FLAG_IGNORE_WRONG_USAGE: DWORD = 0x00000200; +pub const SECURITY_FLAG_IGNORE_CERT_CN_INVALID: DWORD = INTERNET_FLAG_IGNORE_CERT_CN_INVALID; +pub const SECURITY_FLAG_IGNORE_CERT_DATE_INVALID: DWORD = INTERNET_FLAG_IGNORE_CERT_DATE_INVALID; +pub const SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTPS: DWORD = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS; +pub const SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTP: DWORD = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP; +pub const SECURITY_SET_MASK: DWORD = SECURITY_FLAG_IGNORE_REVOCATION + | SECURITY_FLAG_IGNORE_UNKNOWN_CA | SECURITY_FLAG_IGNORE_CERT_CN_INVALID + | SECURITY_FLAG_IGNORE_CERT_DATE_INVALID | SECURITY_FLAG_IGNORE_WRONG_USAGE; +pub const AUTODIAL_MODE_NEVER: DWORD = 1; +pub const AUTODIAL_MODE_ALWAYS: DWORD = 2; +pub const AUTODIAL_MODE_NO_NETWORK_PRESENT: DWORD = 4; +FN!{stdcall INTERNET_STATUS_CALLBACK( + HINTERNET, + DWORD_PTR, + DWORD, + LPVOID, + DWORD, +) -> ()} +pub type LPINTERNET_STATUS_CALLBACK = *mut INTERNET_STATUS_CALLBACK; +pub const INTERNET_STATUS_RESOLVING_NAME: DWORD = 10; +pub const INTERNET_STATUS_NAME_RESOLVED: DWORD = 11; +pub const INTERNET_STATUS_CONNECTING_TO_SERVER: DWORD = 20; +pub const INTERNET_STATUS_CONNECTED_TO_SERVER: DWORD = 21; +pub const INTERNET_STATUS_SENDING_REQUEST: DWORD = 30; +pub const INTERNET_STATUS_REQUEST_SENT: DWORD = 31; +pub const INTERNET_STATUS_RECEIVING_RESPONSE: DWORD = 40; +pub const INTERNET_STATUS_RESPONSE_RECEIVED: DWORD = 41; +pub const INTERNET_STATUS_CTL_RESPONSE_RECEIVED: DWORD = 42; +pub const INTERNET_STATUS_PREFETCH: DWORD = 43; +pub const INTERNET_STATUS_CLOSING_CONNECTION: DWORD = 50; +pub const INTERNET_STATUS_CONNECTION_CLOSED: DWORD = 51; +pub const INTERNET_STATUS_HANDLE_CREATED: DWORD = 60; +pub const INTERNET_STATUS_HANDLE_CLOSING: DWORD = 70; +pub const INTERNET_STATUS_DETECTING_PROXY: DWORD = 80; +pub const INTERNET_STATUS_REQUEST_COMPLETE: DWORD = 100; +pub const INTERNET_STATUS_REDIRECT: DWORD = 110; +pub const INTERNET_STATUS_INTERMEDIATE_RESPONSE: DWORD = 120; +pub const INTERNET_STATUS_USER_INPUT_REQUIRED: DWORD = 140; +pub const INTERNET_STATUS_STATE_CHANGE: DWORD = 200; +pub const INTERNET_STATUS_COOKIE_SENT: DWORD = 320; +pub const INTERNET_STATUS_COOKIE_RECEIVED: DWORD = 321; +pub const INTERNET_STATUS_PRIVACY_IMPACTED: DWORD = 324; +pub const INTERNET_STATUS_P3P_HEADER: DWORD = 325; +pub const INTERNET_STATUS_P3P_POLICYREF: DWORD = 326; +pub const INTERNET_STATUS_COOKIE_HISTORY: DWORD = 327; +pub const INTERNET_STATE_CONNECTED: DWORD = 0x00000001; +pub const INTERNET_STATE_DISCONNECTED: DWORD = 0x00000002; +pub const INTERNET_STATE_DISCONNECTED_BY_USER: DWORD = 0x00000010; +pub const INTERNET_STATE_IDLE: DWORD = 0x00000100; +pub const INTERNET_STATE_BUSY: DWORD = 0x00000200; +ENUM!{enum InternetCookieState { + COOKIE_STATE_UNKNOWN = 0x0, + COOKIE_STATE_ACCEPT = 0x1, + COOKIE_STATE_PROMPT = 0x2, + COOKIE_STATE_LEASH = 0x3, + COOKIE_STATE_DOWNGRADE = 0x4, + COOKIE_STATE_REJECT = 0x5, + COOKIE_STATE_MAX = COOKIE_STATE_REJECT, +}} +STRUCT!{struct IncomingCookieState { + cSession: c_int, + cPersistent: c_int, + cAccepted: c_int, + cLeashed: c_int, + cDowngraded: c_int, + cBlocked: c_int, + pszLocation: LPCSTR, +}} +STRUCT!{struct OutgoingCookieState { + cSent: c_int, + cSuppressed: c_int, + pszLocation: LPCSTR, +}} +STRUCT!{struct InternetCookieHistory { + fAccepted: BOOL, + fLeashed: BOOL, + fDowngraded: BOOL, + fRejected: BOOL, +}} +STRUCT!{struct CookieDecision { + dwCookieState: DWORD, + fAllowSession: BOOL, +}} +pub const INTERNET_INVALID_STATUS_CALLBACK: usize = -1isize as usize; +pub const FTP_TRANSFER_TYPE_UNKNOWN: DWORD = 0x00000000; +pub const FTP_TRANSFER_TYPE_ASCII: DWORD = 0x00000001; +pub const FTP_TRANSFER_TYPE_BINARY: DWORD = 0x00000002; +pub const FTP_TRANSFER_TYPE_MASK: DWORD = FTP_TRANSFER_TYPE_ASCII | FTP_TRANSFER_TYPE_BINARY; +pub const MAX_GOPHER_DISPLAY_TEXT: usize = 128; +pub const MAX_GOPHER_SELECTOR_TEXT: usize = 256; +pub const MAX_GOPHER_HOST_NAME: usize = INTERNET_MAX_HOST_NAME_LENGTH; +pub const MAX_GOPHER_LOCATOR_LENGTH: usize = 1 + MAX_GOPHER_DISPLAY_TEXT + 1 + + MAX_GOPHER_SELECTOR_TEXT + 1 + MAX_GOPHER_HOST_NAME + 1 + INTERNET_MAX_PORT_NUMBER_LENGTH + + 1 + 1 + 2; +STRUCT!{struct GOPHER_FIND_DATAA { + DisplayString: [CHAR; MAX_GOPHER_DISPLAY_TEXT+ 1], + GopherType: DWORD, + SizeLow: DWORD, + SizeHigh: DWORD, + LastModificationTime: FILETIME, + Locator: [CHAR; MAX_GOPHER_LOCATOR_LENGTH + 1], +}} +pub type LPGOPHER_FIND_DATAA = *mut GOPHER_FIND_DATAA; +STRUCT!{struct GOPHER_FIND_DATAW { + DisplayString: [WCHAR; MAX_GOPHER_DISPLAY_TEXT+ 1], + GopherType: DWORD, + SizeLow: DWORD, + SizeHigh: DWORD, + LastModificationTime: FILETIME, + Locator: [WCHAR; MAX_GOPHER_LOCATOR_LENGTH + 1], +}} +pub type LPGOPHER_FIND_DATAW = *mut GOPHER_FIND_DATAW; +pub const GOPHER_TYPE_TEXT_FILE: DWORD = 0x00000001; +pub const GOPHER_TYPE_DIRECTORY: DWORD = 0x00000002; +pub const GOPHER_TYPE_CSO: DWORD = 0x00000004; +pub const GOPHER_TYPE_ERROR: DWORD = 0x00000008; +pub const GOPHER_TYPE_MAC_BINHEX: DWORD = 0x00000010; +pub const GOPHER_TYPE_DOS_ARCHIVE: DWORD = 0x00000020; +pub const GOPHER_TYPE_UNIX_UUENCODED: DWORD = 0x00000040; +pub const GOPHER_TYPE_INDEX_SERVER: DWORD = 0x00000080; +pub const GOPHER_TYPE_TELNET: DWORD = 0x00000100; +pub const GOPHER_TYPE_BINARY: DWORD = 0x00000200; +pub const GOPHER_TYPE_REDUNDANT: DWORD = 0x00000400; +pub const GOPHER_TYPE_TN3270: DWORD = 0x00000800; +pub const GOPHER_TYPE_GIF: DWORD = 0x00001000; +pub const GOPHER_TYPE_IMAGE: DWORD = 0x00002000; +pub const GOPHER_TYPE_BITMAP: DWORD = 0x00004000; +pub const GOPHER_TYPE_MOVIE: DWORD = 0x00008000; +pub const GOPHER_TYPE_SOUND: DWORD = 0x00010000; +pub const GOPHER_TYPE_HTML: DWORD = 0x00020000; +pub const GOPHER_TYPE_PDF: DWORD = 0x00040000; +pub const GOPHER_TYPE_CALENDAR: DWORD = 0x00080000; +pub const GOPHER_TYPE_INLINE: DWORD = 0x00100000; +pub const GOPHER_TYPE_UNKNOWN: DWORD = 0x20000000; +pub const GOPHER_TYPE_ASK: DWORD = 0x40000000; +pub const GOPHER_TYPE_GOPHER_PLUS: DWORD = 0x80000000; +#[inline] +pub fn IS_GOPHER_FILE(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_FILE_MASK) != 0 { TRUE } else { FALSE } +} +#[inline] +pub fn IS_GOPHER_DIRECTORY(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_DIRECTORY) != 0 { TRUE } else { FALSE } +} +#[inline] +pub fn IS_GOPHER_PHONE_SERVER(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_CSO) != 0 { TRUE } else { FALSE } +} +#[inline] +pub fn IS_GOPHER_ERROR(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_ERROR) != 0 { TRUE } else { FALSE } +} +#[inline] +pub fn IS_GOPHER_INDEX_SERVER(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_INDEX_SERVER) != 0 { TRUE } else { FALSE } +} +#[inline] +pub fn IS_GOPHER_TELNET_SESSION(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_TELNET) != 0 { TRUE } else { FALSE } +} +#[inline] +pub fn IS_GOPHER_BACKUP_SERVER(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_REDUNDANT) != 0 { TRUE } else { FALSE } +} +#[inline] +pub fn IS_GOPHER_TN3270_SESSION(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_TN3270) != 0 { TRUE } else { FALSE } +} +#[inline] +pub fn IS_GOPHER_ASK(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_ASK) != 0 { TRUE } else { FALSE } +} +#[inline] +pub fn IS_GOPHER_PLUS(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_GOPHER_PLUS) != 0 { TRUE } else { FALSE } +} +#[inline] +pub fn IS_GOPHER_TYPE_KNOWN(type_: DWORD) -> BOOL { + if (type_ & GOPHER_TYPE_UNKNOWN) != 0 { FALSE } else { TRUE } +} +pub const GOPHER_TYPE_FILE_MASK: DWORD = GOPHER_TYPE_TEXT_FILE | GOPHER_TYPE_MAC_BINHEX + | GOPHER_TYPE_DOS_ARCHIVE | GOPHER_TYPE_UNIX_UUENCODED | GOPHER_TYPE_BINARY | GOPHER_TYPE_GIF + | GOPHER_TYPE_IMAGE | GOPHER_TYPE_BITMAP | GOPHER_TYPE_MOVIE | GOPHER_TYPE_SOUND + | GOPHER_TYPE_HTML | GOPHER_TYPE_PDF | GOPHER_TYPE_CALENDAR | GOPHER_TYPE_INLINE; +STRUCT!{struct GOPHER_ADMIN_ATTRIBUTE_TYPE { + Comment: LPCWSTR, + EmailAddress: LPCWSTR, +}} +pub type LPGOPHER_ADMIN_ATTRIBUTE_TYPE = *mut GOPHER_ADMIN_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_MOD_DATE_ATTRIBUTE_TYPE { + DateAndTime: FILETIME, +}} +pub type LPGOPHER_MOD_DATE_ATTRIBUTE_TYPE = *mut GOPHER_MOD_DATE_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_TTL_ATTRIBUTE_TYPE { + Ttl: DWORD, +}} +pub type LPGOPHER_TTL_ATTRIBUTE_TYPE = *mut GOPHER_TTL_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_SCORE_ATTRIBUTE_TYPE { + Score: INT, +}} +pub type LPGOPHER_SCORE_ATTRIBUTE_TYPE = *mut GOPHER_SCORE_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_SCORE_RANGE_ATTRIBUTE_TYPE { + LowerBound: INT, + UpperBound: INT, +}} +pub type LPGOPHER_SCORE_RANGE_ATTRIBUTE_TYPE = *mut GOPHER_SCORE_RANGE_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_SITE_ATTRIBUTE_TYPE { + Site: LPCWSTR, +}} +pub type LPGOPHER_SITE_ATTRIBUTE_TYPE = *mut GOPHER_SITE_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_ORGANIZATION_ATTRIBUTE_TYPE { + Organization: LPCWSTR, +}} +pub type LPGOPHER_ORGANIZATION_ATTRIBUTE_TYPE = *mut GOPHER_ORGANIZATION_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_LOCATION_ATTRIBUTE_TYPE { + Location: LPCWSTR, +}} +pub type LPGOPHER_LOCATION_ATTRIBUTE_TYPE = *mut GOPHER_LOCATION_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE { + DegreesNorth: INT, + MinutesNorth: INT, + SecondsNorth: INT, + DegreesEast: INT, + MinutesEast: INT, + SecondsEast: INT, +}} +pub type LPGOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE = + *mut GOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_TIMEZONE_ATTRIBUTE_TYPE { + Zone: INT, +}} +pub type LPGOPHER_TIMEZONE_ATTRIBUTE_TYPE = *mut GOPHER_TIMEZONE_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_PROVIDER_ATTRIBUTE_TYPE { + Provider: LPCWSTR, +}} +pub type LPGOPHER_PROVIDER_ATTRIBUTE_TYPE = *mut GOPHER_PROVIDER_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_VERSION_ATTRIBUTE_TYPE { + Version: LPCWSTR, +}} +pub type LPGOPHER_VERSION_ATTRIBUTE_TYPE = *mut GOPHER_VERSION_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_ABSTRACT_ATTRIBUTE_TYPE { + ShortAbstract: LPCWSTR, + AbstractFile: LPCWSTR, +}} +pub type LPGOPHER_ABSTRACT_ATTRIBUTE_TYPE = *mut GOPHER_ABSTRACT_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_VIEW_ATTRIBUTE_TYPE { + ContentType: LPCWSTR, + Language: LPCWSTR, + Size: DWORD, +}} +pub type LPGOPHER_VIEW_ATTRIBUTE_TYPE = *mut GOPHER_VIEW_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_VERONICA_ATTRIBUTE_TYPE { + TreeWalk: BOOL, +}} +pub type LPGOPHER_VERONICA_ATTRIBUTE_TYPE = *mut GOPHER_VERONICA_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_ASK_ATTRIBUTE_TYPE { + QuestionType: LPCWSTR, + QuestionText: LPCWSTR, +}} +pub type LPGOPHER_ASK_ATTRIBUTE_TYPE = *mut GOPHER_ASK_ATTRIBUTE_TYPE; +STRUCT!{struct GOPHER_UNKNOWN_ATTRIBUTE_TYPE { + Text: LPCWSTR, +}} +pub type LPGOPHER_UNKNOWN_ATTRIBUTE_TYPE = *mut GOPHER_UNKNOWN_ATTRIBUTE_TYPE; +UNION!{union GOPHER_ATTRIBUTE_TYPE_AttributeType { + [u32; 6] [u64; 3], + Admin Admin_mut: GOPHER_ADMIN_ATTRIBUTE_TYPE, + ModDate ModDate_mut: GOPHER_MOD_DATE_ATTRIBUTE_TYPE, + Ttl Ttl_mut: GOPHER_TTL_ATTRIBUTE_TYPE, + Score Score_mut: GOPHER_SCORE_ATTRIBUTE_TYPE, + ScoreRange ScoreRange_mut: GOPHER_SCORE_RANGE_ATTRIBUTE_TYPE, + Site Site_mut: GOPHER_SITE_ATTRIBUTE_TYPE, + Organization Organization_mut: GOPHER_ORGANIZATION_ATTRIBUTE_TYPE, + Location Location_mut: GOPHER_LOCATION_ATTRIBUTE_TYPE, + GeographicalLocation GeographicalLocation_mut: GOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE, + TimeZone TimeZone_mut: GOPHER_TIMEZONE_ATTRIBUTE_TYPE, + Provider Provider_mut: GOPHER_PROVIDER_ATTRIBUTE_TYPE, + Version Version_mut: GOPHER_VERSION_ATTRIBUTE_TYPE, + Abstract Abstract_mut: GOPHER_ABSTRACT_ATTRIBUTE_TYPE, + View View_mut: GOPHER_VIEW_ATTRIBUTE_TYPE, + Veronica Veronica_mut: GOPHER_VERONICA_ATTRIBUTE_TYPE, + Ask Ask_mut: GOPHER_ASK_ATTRIBUTE_TYPE, + Unknown Unknown_mut: GOPHER_UNKNOWN_ATTRIBUTE_TYPE, +}} +STRUCT!{struct GOPHER_ATTRIBUTE_TYPE { + CategoryId: DWORD, + AttributeId: DWORD, + AttributeType: GOPHER_ATTRIBUTE_TYPE_AttributeType, +}} +pub type LPGOPHER_ATTRIBUTE_TYPE = *mut GOPHER_ATTRIBUTE_TYPE; +pub const MAX_GOPHER_CATEGORY_NAME: DWORD = 128; +pub const MAX_GOPHER_ATTRIBUTE_NAME: DWORD = 128; +pub const MIN_GOPHER_ATTRIBUTE_LENGTH: DWORD = 256; +pub const GOPHER_INFO_CATEGORY: &'static str = " + INFO"; +pub const GOPHER_ADMIN_CATEGORY: &'static str = " + ADMIN"; +pub const GOPHER_VIEWS_CATEGORY: &'static str = " + VIEWS"; +pub const GOPHER_ABSTRACT_CATEGORY: &'static str = " + ABSTRACT"; +pub const GOPHER_VERONICA_CATEGORY: &'static str = " + VERONICA"; +pub const GOPHER_ADMIN_ATTRIBUTE: &'static str = "Admin"; +pub const GOPHER_MOD_DATE_ATTRIBUTE: &'static str = "Mod-Date"; +pub const GOPHER_TTL_ATTRIBUTE: &'static str = "TTL"; +pub const GOPHER_SCORE_ATTRIBUTE: &'static str = "Score"; +pub const GOPHER_RANGE_ATTRIBUTE: &'static str = "Score-range"; +pub const GOPHER_SITE_ATTRIBUTE: &'static str = "Site"; +pub const GOPHER_ORG_ATTRIBUTE: &'static str = "Org"; +pub const GOPHER_LOCATION_ATTRIBUTE: &'static str = "Loc"; +pub const GOPHER_GEOG_ATTRIBUTE: &'static str = "Geog"; +pub const GOPHER_TIMEZONE_ATTRIBUTE: &'static str = "TZ"; +pub const GOPHER_PROVIDER_ATTRIBUTE: &'static str = "Provider"; +pub const GOPHER_VERSION_ATTRIBUTE: &'static str = "Version"; +pub const GOPHER_ABSTRACT_ATTRIBUTE: &'static str = "Abstract"; +pub const GOPHER_VIEW_ATTRIBUTE: &'static str = "View"; +pub const GOPHER_TREEWALK_ATTRIBUTE: &'static str = "treewalk"; +pub const GOPHER_ATTRIBUTE_ID_BASE: DWORD = 0xabcccc00; +pub const GOPHER_CATEGORY_ID_ALL: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 1; +pub const GOPHER_CATEGORY_ID_INFO: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 2; +pub const GOPHER_CATEGORY_ID_ADMIN: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 3; +pub const GOPHER_CATEGORY_ID_VIEWS: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 4; +pub const GOPHER_CATEGORY_ID_ABSTRACT: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 5; +pub const GOPHER_CATEGORY_ID_VERONICA: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 6; +pub const GOPHER_CATEGORY_ID_ASK: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 7; +pub const GOPHER_CATEGORY_ID_UNKNOWN: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 8; +pub const GOPHER_ATTRIBUTE_ID_ALL: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 9; +pub const GOPHER_ATTRIBUTE_ID_ADMIN: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 10; +pub const GOPHER_ATTRIBUTE_ID_MOD_DATE: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 11; +pub const GOPHER_ATTRIBUTE_ID_TTL: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 12; +pub const GOPHER_ATTRIBUTE_ID_SCORE: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 13; +pub const GOPHER_ATTRIBUTE_ID_RANGE: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 14; +pub const GOPHER_ATTRIBUTE_ID_SITE: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 15; +pub const GOPHER_ATTRIBUTE_ID_ORG: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 16; +pub const GOPHER_ATTRIBUTE_ID_LOCATION: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 17; +pub const GOPHER_ATTRIBUTE_ID_GEOG: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 18; +pub const GOPHER_ATTRIBUTE_ID_TIMEZONE: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 19; +pub const GOPHER_ATTRIBUTE_ID_PROVIDER: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 20; +pub const GOPHER_ATTRIBUTE_ID_VERSION: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 21; +pub const GOPHER_ATTRIBUTE_ID_ABSTRACT: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 22; +pub const GOPHER_ATTRIBUTE_ID_VIEW: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 23; +pub const GOPHER_ATTRIBUTE_ID_TREEWALK: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 24; +pub const GOPHER_ATTRIBUTE_ID_UNKNOWN: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 25; +FN!{stdcall GOPHER_ATTRIBUTE_ENUMERATOR( + LPGOPHER_ATTRIBUTE_TYPE, + DWORD, +) -> BOOL} +pub const HTTP_MAJOR_VERSION: DWORD = 1; +pub const HTTP_MINOR_VERSION: DWORD = 0; +pub const HTTP_VERSION: &'static str = "HTTP/1.0"; +pub const HTTP_QUERY_MIME_VERSION: DWORD = 0; +pub const HTTP_QUERY_CONTENT_TYPE: DWORD = 1; +pub const HTTP_QUERY_CONTENT_TRANSFER_ENCODING: DWORD = 2; +pub const HTTP_QUERY_CONTENT_ID: DWORD = 3; +pub const HTTP_QUERY_CONTENT_DESCRIPTION: DWORD = 4; +pub const HTTP_QUERY_CONTENT_LENGTH: DWORD = 5; +pub const HTTP_QUERY_CONTENT_LANGUAGE: DWORD = 6; +pub const HTTP_QUERY_ALLOW: DWORD = 7; +pub const HTTP_QUERY_PUBLIC: DWORD = 8; +pub const HTTP_QUERY_DATE: DWORD = 9; +pub const HTTP_QUERY_EXPIRES: DWORD = 10; +pub const HTTP_QUERY_LAST_MODIFIED: DWORD = 11; +pub const HTTP_QUERY_MESSAGE_ID: DWORD = 12; +pub const HTTP_QUERY_URI: DWORD = 13; +pub const HTTP_QUERY_DERIVED_FROM: DWORD = 14; +pub const HTTP_QUERY_COST: DWORD = 15; +pub const HTTP_QUERY_LINK: DWORD = 16; +pub const HTTP_QUERY_PRAGMA: DWORD = 17; +pub const HTTP_QUERY_VERSION: DWORD = 18; +pub const HTTP_QUERY_STATUS_CODE: DWORD = 19; +pub const HTTP_QUERY_STATUS_TEXT: DWORD = 20; +pub const HTTP_QUERY_RAW_HEADERS: DWORD = 21; +pub const HTTP_QUERY_RAW_HEADERS_CRLF: DWORD = 22; +pub const HTTP_QUERY_CONNECTION: DWORD = 23; +pub const HTTP_QUERY_ACCEPT: DWORD = 24; +pub const HTTP_QUERY_ACCEPT_CHARSET: DWORD = 25; +pub const HTTP_QUERY_ACCEPT_ENCODING: DWORD = 26; +pub const HTTP_QUERY_ACCEPT_LANGUAGE: DWORD = 27; +pub const HTTP_QUERY_AUTHORIZATION: DWORD = 28; +pub const HTTP_QUERY_CONTENT_ENCODING: DWORD = 29; +pub const HTTP_QUERY_FORWARDED: DWORD = 30; +pub const HTTP_QUERY_FROM: DWORD = 31; +pub const HTTP_QUERY_IF_MODIFIED_SINCE: DWORD = 32; +pub const HTTP_QUERY_LOCATION: DWORD = 33; +pub const HTTP_QUERY_ORIG_URI: DWORD = 34; +pub const HTTP_QUERY_REFERER: DWORD = 35; +pub const HTTP_QUERY_RETRY_AFTER: DWORD = 36; +pub const HTTP_QUERY_SERVER: DWORD = 37; +pub const HTTP_QUERY_TITLE: DWORD = 38; +pub const HTTP_QUERY_USER_AGENT: DWORD = 39; +pub const HTTP_QUERY_WWW_AUTHENTICATE: DWORD = 40; +pub const HTTP_QUERY_PROXY_AUTHENTICATE: DWORD = 41; +pub const HTTP_QUERY_ACCEPT_RANGES: DWORD = 42; +pub const HTTP_QUERY_SET_COOKIE: DWORD = 43; +pub const HTTP_QUERY_COOKIE: DWORD = 44; +pub const HTTP_QUERY_REQUEST_METHOD: DWORD = 45; +pub const HTTP_QUERY_REFRESH: DWORD = 46; +pub const HTTP_QUERY_CONTENT_DISPOSITION: DWORD = 47; +pub const HTTP_QUERY_AGE: DWORD = 48; +pub const HTTP_QUERY_CACHE_CONTROL: DWORD = 49; +pub const HTTP_QUERY_CONTENT_BASE: DWORD = 50; +pub const HTTP_QUERY_CONTENT_LOCATION: DWORD = 51; +pub const HTTP_QUERY_CONTENT_MD5: DWORD = 52; +pub const HTTP_QUERY_CONTENT_RANGE: DWORD = 53; +pub const HTTP_QUERY_ETAG: DWORD = 54; +pub const HTTP_QUERY_HOST: DWORD = 55; +pub const HTTP_QUERY_IF_MATCH: DWORD = 56; +pub const HTTP_QUERY_IF_NONE_MATCH: DWORD = 57; +pub const HTTP_QUERY_IF_RANGE: DWORD = 58; +pub const HTTP_QUERY_IF_UNMODIFIED_SINCE: DWORD = 59; +pub const HTTP_QUERY_MAX_FORWARDS: DWORD = 60; +pub const HTTP_QUERY_PROXY_AUTHORIZATION: DWORD = 61; +pub const HTTP_QUERY_RANGE: DWORD = 62; +pub const HTTP_QUERY_TRANSFER_ENCODING: DWORD = 63; +pub const HTTP_QUERY_UPGRADE: DWORD = 64; +pub const HTTP_QUERY_VARY: DWORD = 65; +pub const HTTP_QUERY_VIA: DWORD = 66; +pub const HTTP_QUERY_WARNING: DWORD = 67; +pub const HTTP_QUERY_EXPECT: DWORD = 68; +pub const HTTP_QUERY_PROXY_CONNECTION: DWORD = 69; +pub const HTTP_QUERY_UNLESS_MODIFIED_SINCE: DWORD = 70; +pub const HTTP_QUERY_ECHO_REQUEST: DWORD = 71; +pub const HTTP_QUERY_ECHO_REPLY: DWORD = 72; +pub const HTTP_QUERY_ECHO_HEADERS: DWORD = 73; +pub const HTTP_QUERY_ECHO_HEADERS_CRLF: DWORD = 74; +pub const HTTP_QUERY_PROXY_SUPPORT: DWORD = 75; +pub const HTTP_QUERY_AUTHENTICATION_INFO: DWORD = 76; +pub const HTTP_QUERY_PASSPORT_URLS: DWORD = 77; +pub const HTTP_QUERY_PASSPORT_CONFIG: DWORD = 78; +pub const HTTP_QUERY_X_CONTENT_TYPE_OPTIONS: DWORD = 79; +pub const HTTP_QUERY_P3P: DWORD = 80; +pub const HTTP_QUERY_X_P2P_PEERDIST: DWORD = 81; +pub const HTTP_QUERY_TRANSLATE: DWORD = 82; +pub const HTTP_QUERY_X_UA_COMPATIBLE: DWORD = 83; +pub const HTTP_QUERY_DEFAULT_STYLE: DWORD = 84; +pub const HTTP_QUERY_X_FRAME_OPTIONS: DWORD = 85; +pub const HTTP_QUERY_X_XSS_PROTECTION: DWORD = 86; +pub const HTTP_QUERY_SET_COOKIE2: DWORD = 87; +pub const HTTP_QUERY_DO_NOT_TRACK: DWORD = 88; +pub const HTTP_QUERY_KEEP_ALIVE: DWORD = 89; +pub const HTTP_QUERY_MAX: DWORD = 89; +pub const HTTP_QUERY_CUSTOM: DWORD = 65535; +pub const HTTP_QUERY_FLAG_REQUEST_HEADERS: DWORD = 0x80000000; +pub const HTTP_QUERY_FLAG_SYSTEMTIME: DWORD = 0x40000000; +pub const HTTP_QUERY_FLAG_NUMBER: DWORD = 0x20000000; +pub const HTTP_QUERY_FLAG_COALESCE: DWORD = 0x10000000; +pub const HTTP_QUERY_FLAG_NUMBER64: DWORD = 0x08000000; +pub const HTTP_QUERY_MODIFIER_FLAGS_MASK: DWORD = HTTP_QUERY_FLAG_REQUEST_HEADERS + | HTTP_QUERY_FLAG_SYSTEMTIME | HTTP_QUERY_FLAG_NUMBER | HTTP_QUERY_FLAG_COALESCE + | HTTP_QUERY_FLAG_NUMBER64; +pub const HTTP_QUERY_HEADER_MASK: DWORD = !HTTP_QUERY_MODIFIER_FLAGS_MASK; +pub const HTTP_STATUS_CONTINUE: DWORD = 100; +pub const HTTP_STATUS_SWITCH_PROTOCOLS: DWORD = 101; +pub const HTTP_STATUS_OK: DWORD = 200; +pub const HTTP_STATUS_CREATED: DWORD = 201; +pub const HTTP_STATUS_ACCEPTED: DWORD = 202; +pub const HTTP_STATUS_PARTIAL: DWORD = 203; +pub const HTTP_STATUS_NO_CONTENT: DWORD = 204; +pub const HTTP_STATUS_RESET_CONTENT: DWORD = 205; +pub const HTTP_STATUS_PARTIAL_CONTENT: DWORD = 206; +pub const HTTP_STATUS_AMBIGUOUS: DWORD = 300; +pub const HTTP_STATUS_MOVED: DWORD = 301; +pub const HTTP_STATUS_REDIRECT: DWORD = 302; +pub const HTTP_STATUS_REDIRECT_METHOD: DWORD = 303; +pub const HTTP_STATUS_NOT_MODIFIED: DWORD = 304; +pub const HTTP_STATUS_USE_PROXY: DWORD = 305; +pub const HTTP_STATUS_REDIRECT_KEEP_VERB: DWORD = 307; +pub const HTTP_STATUS_BAD_REQUEST: DWORD = 400; +pub const HTTP_STATUS_DENIED: DWORD = 401; +pub const HTTP_STATUS_PAYMENT_REQ: DWORD = 402; +pub const HTTP_STATUS_FORBIDDEN: DWORD = 403; +pub const HTTP_STATUS_NOT_FOUND: DWORD = 404; +pub const HTTP_STATUS_BAD_METHOD: DWORD = 405; +pub const HTTP_STATUS_NONE_ACCEPTABLE: DWORD = 406; +pub const HTTP_STATUS_PROXY_AUTH_REQ: DWORD = 407; +pub const HTTP_STATUS_REQUEST_TIMEOUT: DWORD = 408; +pub const HTTP_STATUS_CONFLICT: DWORD = 409; +pub const HTTP_STATUS_GONE: DWORD = 410; +pub const HTTP_STATUS_LENGTH_REQUIRED: DWORD = 411; +pub const HTTP_STATUS_PRECOND_FAILED: DWORD = 412; +pub const HTTP_STATUS_REQUEST_TOO_LARGE: DWORD = 413; +pub const HTTP_STATUS_URI_TOO_LONG: DWORD = 414; +pub const HTTP_STATUS_UNSUPPORTED_MEDIA: DWORD = 415; +pub const HTTP_STATUS_RETRY_WITH: DWORD = 449; +pub const HTTP_STATUS_SERVER_ERROR: DWORD = 500; +pub const HTTP_STATUS_NOT_SUPPORTED: DWORD = 501; +pub const HTTP_STATUS_BAD_GATEWAY: DWORD = 502; +pub const HTTP_STATUS_SERVICE_UNAVAIL: DWORD = 503; +pub const HTTP_STATUS_GATEWAY_TIMEOUT: DWORD = 504; +pub const HTTP_STATUS_VERSION_NOT_SUP: DWORD = 505; +pub const HTTP_STATUS_FIRST: DWORD = HTTP_STATUS_CONTINUE; +pub const HTTP_STATUS_LAST: DWORD = HTTP_STATUS_VERSION_NOT_SUP; +pub const HTTP_ADDREQ_INDEX_MASK: DWORD = 0x0000FFFF; +pub const HTTP_ADDREQ_FLAGS_MASK: DWORD = 0xFFFF0000; +pub const HTTP_ADDREQ_FLAG_ADD_IF_NEW: DWORD = 0x10000000; +pub const HTTP_ADDREQ_FLAG_ADD: DWORD = 0x20000000; +pub const HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA: DWORD = 0x40000000; +pub const HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON: DWORD = 0x01000000; +pub const HTTP_ADDREQ_FLAG_COALESCE: DWORD = HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA; +pub const HTTP_ADDREQ_FLAG_REPLACE: DWORD = 0x80000000; +pub const HSR_ASYNC: DWORD = WININET_API_FLAG_ASYNC; +pub const HSR_SYNC: DWORD = WININET_API_FLAG_SYNC; +pub const HSR_USE_CONTEXT: DWORD = WININET_API_FLAG_USE_CONTEXT; +pub const HSR_INITIATE: DWORD = 0x00000008; +pub const HSR_DOWNLOAD: DWORD = 0x00000010; +pub const HSR_CHUNKED: DWORD = 0x00000020; +STRUCT!{struct INTERNET_COOKIE2 { + pwszName: PWSTR, + pwszValue: PWSTR, + pwszDomain: PWSTR, + pwszPath: PWSTR, + dwFlags: DWORD, + ftExpires: FILETIME, + fExpiresSet: BOOL, +}} +pub const INTERNET_COOKIE_IS_SECURE: DWORD = 0x01; +pub const INTERNET_COOKIE_IS_SESSION: DWORD = 0x02; +pub const INTERNET_COOKIE_THIRD_PARTY: DWORD = 0x10; +pub const INTERNET_COOKIE_PROMPT_REQUIRED: DWORD = 0x20; +pub const INTERNET_COOKIE_EVALUATE_P3P: DWORD = 0x40; +pub const INTERNET_COOKIE_APPLY_P3P: DWORD = 0x80; +pub const INTERNET_COOKIE_P3P_ENABLED: DWORD = 0x100; +pub const INTERNET_COOKIE_IS_RESTRICTED: DWORD = 0x200; +pub const INTERNET_COOKIE_IE6: DWORD = 0x400; +pub const INTERNET_COOKIE_IS_LEGACY: DWORD = 0x800; +pub const INTERNET_COOKIE_NON_SCRIPT: DWORD = 0x00001000; +pub const INTERNET_COOKIE_HTTPONLY: DWORD = 0x00002000; +pub const FLAG_ICC_FORCE_CONNECTION: DWORD = 0x00000001; +pub const FLAGS_ERROR_UI_FILTER_FOR_ERRORS: DWORD = 0x01; +pub const FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS: DWORD = 0x02; +pub const FLAGS_ERROR_UI_FLAGS_GENERATE_DATA: DWORD = 0x04; +pub const FLAGS_ERROR_UI_FLAGS_NO_UI: DWORD = 0x08; +pub const FLAGS_ERROR_UI_SERIALIZE_DIALOGS: DWORD = 0x10; +FN!{stdcall PFN_AUTH_NOTIFY( + DWORD_PTR, + DWORD, + LPVOID, +) -> DWORD} +STRUCT!{struct INTERNET_AUTH_NOTIFY_DATA { + cbStruct: DWORD, + dwOptions: DWORD, + pfnNotify: PFN_AUTH_NOTIFY, + dwContext: DWORD_PTR, +}} +pub const INTERNET_ERROR_BASE: DWORD = 12000; +pub const ERROR_INTERNET_OUT_OF_HANDLES: DWORD = INTERNET_ERROR_BASE + 1; +pub const ERROR_INTERNET_TIMEOUT: DWORD = INTERNET_ERROR_BASE + 2; +pub const ERROR_INTERNET_EXTENDED_ERROR: DWORD = INTERNET_ERROR_BASE + 3; +pub const ERROR_INTERNET_INTERNAL_ERROR: DWORD = INTERNET_ERROR_BASE + 4; +pub const ERROR_INTERNET_INVALID_URL: DWORD = INTERNET_ERROR_BASE + 5; +pub const ERROR_INTERNET_UNRECOGNIZED_SCHEME: DWORD = INTERNET_ERROR_BASE + 6; +pub const ERROR_INTERNET_NAME_NOT_RESOLVED: DWORD = INTERNET_ERROR_BASE + 7; +pub const ERROR_INTERNET_PROTOCOL_NOT_FOUND: DWORD = INTERNET_ERROR_BASE + 8; +pub const ERROR_INTERNET_INVALID_OPTION: DWORD = INTERNET_ERROR_BASE + 9; +pub const ERROR_INTERNET_BAD_OPTION_LENGTH: DWORD = INTERNET_ERROR_BASE + 10; +pub const ERROR_INTERNET_OPTION_NOT_SETTABLE: DWORD = INTERNET_ERROR_BASE + 11; +pub const ERROR_INTERNET_SHUTDOWN: DWORD = INTERNET_ERROR_BASE + 12; +pub const ERROR_INTERNET_INCORRECT_USER_NAME: DWORD = INTERNET_ERROR_BASE + 13; +pub const ERROR_INTERNET_INCORRECT_PASSWORD: DWORD = INTERNET_ERROR_BASE + 14; +pub const ERROR_INTERNET_LOGIN_FAILURE: DWORD = INTERNET_ERROR_BASE + 15; +pub const ERROR_INTERNET_INVALID_OPERATION: DWORD = INTERNET_ERROR_BASE + 16; +pub const ERROR_INTERNET_OPERATION_CANCELLED: DWORD = INTERNET_ERROR_BASE + 17; +pub const ERROR_INTERNET_INCORRECT_HANDLE_TYPE: DWORD = INTERNET_ERROR_BASE + 18; +pub const ERROR_INTERNET_INCORRECT_HANDLE_STATE: DWORD = INTERNET_ERROR_BASE + 19; +pub const ERROR_INTERNET_NOT_PROXY_REQUEST: DWORD = INTERNET_ERROR_BASE + 20; +pub const ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND: DWORD = INTERNET_ERROR_BASE + 21; +pub const ERROR_INTERNET_BAD_REGISTRY_PARAMETER: DWORD = INTERNET_ERROR_BASE + 22; +pub const ERROR_INTERNET_NO_DIRECT_ACCESS: DWORD = INTERNET_ERROR_BASE + 23; +pub const ERROR_INTERNET_NO_CONTEXT: DWORD = INTERNET_ERROR_BASE + 24; +pub const ERROR_INTERNET_NO_CALLBACK: DWORD = INTERNET_ERROR_BASE + 25; +pub const ERROR_INTERNET_REQUEST_PENDING: DWORD = INTERNET_ERROR_BASE + 26; +pub const ERROR_INTERNET_INCORRECT_FORMAT: DWORD = INTERNET_ERROR_BASE + 27; +pub const ERROR_INTERNET_ITEM_NOT_FOUND: DWORD = INTERNET_ERROR_BASE + 28; +pub const ERROR_INTERNET_CANNOT_CONNECT: DWORD = INTERNET_ERROR_BASE + 29; +pub const ERROR_INTERNET_CONNECTION_ABORTED: DWORD = INTERNET_ERROR_BASE + 30; +pub const ERROR_INTERNET_CONNECTION_RESET: DWORD = INTERNET_ERROR_BASE + 31; +pub const ERROR_INTERNET_FORCE_RETRY: DWORD = INTERNET_ERROR_BASE + 32; +pub const ERROR_INTERNET_INVALID_PROXY_REQUEST: DWORD = INTERNET_ERROR_BASE + 33; +pub const ERROR_INTERNET_NEED_UI: DWORD = INTERNET_ERROR_BASE + 34; +pub const ERROR_INTERNET_HANDLE_EXISTS: DWORD = INTERNET_ERROR_BASE + 36; +pub const ERROR_INTERNET_SEC_CERT_DATE_INVALID: DWORD = INTERNET_ERROR_BASE + 37; +pub const ERROR_INTERNET_SEC_CERT_CN_INVALID: DWORD = INTERNET_ERROR_BASE + 38; +pub const ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR: DWORD = INTERNET_ERROR_BASE + 39; +pub const ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR: DWORD = INTERNET_ERROR_BASE + 40; +pub const ERROR_INTERNET_MIXED_SECURITY: DWORD = INTERNET_ERROR_BASE + 41; +pub const ERROR_INTERNET_CHG_POST_IS_NON_SECURE: DWORD = INTERNET_ERROR_BASE + 42; +pub const ERROR_INTERNET_POST_IS_NON_SECURE: DWORD = INTERNET_ERROR_BASE + 43; +pub const ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED: DWORD = INTERNET_ERROR_BASE + 44; +pub const ERROR_INTERNET_INVALID_CA: DWORD = INTERNET_ERROR_BASE + 45; +pub const ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP: DWORD = INTERNET_ERROR_BASE + 46; +pub const ERROR_INTERNET_ASYNC_THREAD_FAILED: DWORD = INTERNET_ERROR_BASE + 47; +pub const ERROR_INTERNET_REDIRECT_SCHEME_CHANGE: DWORD = INTERNET_ERROR_BASE + 48; +pub const ERROR_INTERNET_DIALOG_PENDING: DWORD = INTERNET_ERROR_BASE + 49; +pub const ERROR_INTERNET_RETRY_DIALOG: DWORD = INTERNET_ERROR_BASE + 50; +pub const ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR: DWORD = INTERNET_ERROR_BASE + 52; +pub const ERROR_INTERNET_INSERT_CDROM: DWORD = INTERNET_ERROR_BASE + 53; +pub const ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED: DWORD = INTERNET_ERROR_BASE + 54; +pub const ERROR_INTERNET_SEC_CERT_ERRORS: DWORD = INTERNET_ERROR_BASE + 55; +pub const ERROR_INTERNET_SEC_CERT_NO_REV: DWORD = INTERNET_ERROR_BASE + 56; +pub const ERROR_INTERNET_SEC_CERT_REV_FAILED: DWORD = INTERNET_ERROR_BASE + 57; +pub const ERROR_FTP_TRANSFER_IN_PROGRESS: DWORD = INTERNET_ERROR_BASE + 110; +pub const ERROR_FTP_DROPPED: DWORD = INTERNET_ERROR_BASE + 111; +pub const ERROR_FTP_NO_PASSIVE_MODE: DWORD = INTERNET_ERROR_BASE + 112; +pub const ERROR_GOPHER_PROTOCOL_ERROR: DWORD = INTERNET_ERROR_BASE + 130; +pub const ERROR_GOPHER_NOT_FILE: DWORD = INTERNET_ERROR_BASE + 131; +pub const ERROR_GOPHER_DATA_ERROR: DWORD = INTERNET_ERROR_BASE + 132; +pub const ERROR_GOPHER_END_OF_DATA: DWORD = INTERNET_ERROR_BASE + 133; +pub const ERROR_GOPHER_INVALID_LOCATOR: DWORD = INTERNET_ERROR_BASE + 134; +pub const ERROR_GOPHER_INCORRECT_LOCATOR_TYPE: DWORD = INTERNET_ERROR_BASE + 135; +pub const ERROR_GOPHER_NOT_GOPHER_PLUS: DWORD = INTERNET_ERROR_BASE + 136; +pub const ERROR_GOPHER_ATTRIBUTE_NOT_FOUND: DWORD = INTERNET_ERROR_BASE + 137; +pub const ERROR_GOPHER_UNKNOWN_LOCATOR: DWORD = INTERNET_ERROR_BASE + 138; +pub const ERROR_HTTP_HEADER_NOT_FOUND: DWORD = INTERNET_ERROR_BASE + 150; +pub const ERROR_HTTP_DOWNLEVEL_SERVER: DWORD = INTERNET_ERROR_BASE + 151; +pub const ERROR_HTTP_INVALID_SERVER_RESPONSE: DWORD = INTERNET_ERROR_BASE + 152; +pub const ERROR_HTTP_INVALID_HEADER: DWORD = INTERNET_ERROR_BASE + 153; +pub const ERROR_HTTP_INVALID_QUERY_REQUEST: DWORD = INTERNET_ERROR_BASE + 154; +pub const ERROR_HTTP_HEADER_ALREADY_EXISTS: DWORD = INTERNET_ERROR_BASE + 155; +pub const ERROR_HTTP_REDIRECT_FAILED: DWORD = INTERNET_ERROR_BASE + 156; +pub const ERROR_HTTP_NOT_REDIRECTED: DWORD = INTERNET_ERROR_BASE + 160; +pub const ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION: DWORD = INTERNET_ERROR_BASE + 161; +pub const ERROR_HTTP_COOKIE_DECLINED: DWORD = INTERNET_ERROR_BASE + 162; +pub const ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION: DWORD = INTERNET_ERROR_BASE + 168; +pub const ERROR_INTERNET_SECURITY_CHANNEL_ERROR: DWORD = INTERNET_ERROR_BASE + 157; +pub const ERROR_INTERNET_UNABLE_TO_CACHE_FILE: DWORD = INTERNET_ERROR_BASE + 158; +pub const ERROR_INTERNET_TCPIP_NOT_INSTALLED: DWORD = INTERNET_ERROR_BASE + 159; +pub const ERROR_INTERNET_DISCONNECTED: DWORD = INTERNET_ERROR_BASE + 163; +pub const ERROR_INTERNET_SERVER_UNREACHABLE: DWORD = INTERNET_ERROR_BASE + 164; +pub const ERROR_INTERNET_PROXY_SERVER_UNREACHABLE: DWORD = INTERNET_ERROR_BASE + 165; +pub const ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT: DWORD = INTERNET_ERROR_BASE + 166; +pub const ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT: DWORD = INTERNET_ERROR_BASE + 167; +pub const ERROR_INTERNET_SEC_INVALID_CERT: DWORD = INTERNET_ERROR_BASE + 169; +pub const ERROR_INTERNET_SEC_CERT_REVOKED: DWORD = INTERNET_ERROR_BASE + 170; +pub const ERROR_INTERNET_FAILED_DUETOSECURITYCHECK: DWORD = INTERNET_ERROR_BASE + 171; +pub const ERROR_INTERNET_NOT_INITIALIZED: DWORD = INTERNET_ERROR_BASE + 172; +pub const ERROR_INTERNET_NEED_MSN_SSPI_PKG: DWORD = INTERNET_ERROR_BASE + 173; +pub const ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY: DWORD = INTERNET_ERROR_BASE + 174; +pub const ERROR_INTERNET_DECODING_FAILED: DWORD = INTERNET_ERROR_BASE + 175; +pub const INTERNET_ERROR_LAST: DWORD = ERROR_INTERNET_DECODING_FAILED; +pub const NORMAL_CACHE_ENTRY: DWORD = 0x00000001; +pub const STICKY_CACHE_ENTRY: DWORD = 0x00000004; +pub const EDITED_CACHE_ENTRY: DWORD = 0x00000008; +pub const TRACK_OFFLINE_CACHE_ENTRY: DWORD = 0x00000010; +pub const TRACK_ONLINE_CACHE_ENTRY: DWORD = 0x00000020; +pub const SPARSE_CACHE_ENTRY: DWORD = 0x00010000; +pub const COOKIE_CACHE_ENTRY: DWORD = 0x00100000; +pub const URLHISTORY_CACHE_ENTRY: DWORD = 0x00200000; +pub const URLCACHE_FIND_DEFAULT_FILTER: DWORD = NORMAL_CACHE_ENTRY | COOKIE_CACHE_ENTRY + | URLHISTORY_CACHE_ENTRY | TRACK_OFFLINE_CACHE_ENTRY | TRACK_ONLINE_CACHE_ENTRY + | STICKY_CACHE_ENTRY; +UNION!{union INTERNET_CACHE_ENTRY_INFOA_u { + [u32; 1], + dwReserved dwReserved_mut: DWORD, + dwExemptDelta dwExemptDelta_mut: DWORD, +}} +STRUCT!{struct INTERNET_CACHE_ENTRY_INFOA { + dwStructSize: DWORD, + lpszSourceUrlName: LPSTR, + lpszLocalFileName: LPSTR, + CacheEntryType: DWORD, + dwUseCount: DWORD, + dwHitRate: DWORD, + dwSizeLow: DWORD, + dwSizeHigh: DWORD, + LastModifiedTime: FILETIME, + ExpireTime: FILETIME, + LastAccessTime: FILETIME, + LastSyncTime: FILETIME, + lpHeaderInfo: LPSTR, + dwHeaderInfoSize: DWORD, + lpszFileExtension: LPSTR, + u: INTERNET_CACHE_ENTRY_INFOA_u, +}} +pub type LPINTERNET_CACHE_ENTRY_INFOA = *mut INTERNET_CACHE_ENTRY_INFOA; +UNION!{union INTERNET_CACHE_ENTRY_INFOW_u { + [u32; 1], + dwReserved dwReserved_mut: DWORD, + dwExemptDelta dwExemptDelta_mut: DWORD, +}} +STRUCT!{struct INTERNET_CACHE_ENTRY_INFOW { + dwStructSize: DWORD, + lpszSourceUrlName: LPWSTR, + lpszLocalFileName: LPWSTR, + CacheEntryType: DWORD, + dwUseCount: DWORD, + dwHitRate: DWORD, + dwSizeLow: DWORD, + dwSizeHigh: DWORD, + LastModifiedTime: FILETIME, + ExpireTime: FILETIME, + LastAccessTime: FILETIME, + LastSyncTime: FILETIME, + lpHeaderInfo: LPWSTR, + dwHeaderInfoSize: DWORD, + lpszFileExtension: LPWSTR, + u: INTERNET_CACHE_ENTRY_INFOW_u, +}} +pub type LPINTERNET_CACHE_ENTRY_INFOW = *mut INTERNET_CACHE_ENTRY_INFOW; +STRUCT!{struct INTERNET_CACHE_TIMESTAMPS { + ftExpires: FILETIME, + ftLastModified: FILETIME, +}} +pub type LPINTERNET_CACHE_TIMESTAMPS = *mut INTERNET_CACHE_TIMESTAMPS; +pub type GROUPID = LONGLONG; +pub const CACHEGROUP_ATTRIBUTE_GET_ALL: DWORD = 0xffffffff; +pub const CACHEGROUP_ATTRIBUTE_BASIC: DWORD = 0x00000001; +pub const CACHEGROUP_ATTRIBUTE_FLAG: DWORD = 0x00000002; +pub const CACHEGROUP_ATTRIBUTE_TYPE: DWORD = 0x00000004; +pub const CACHEGROUP_ATTRIBUTE_QUOTA: DWORD = 0x00000008; +pub const CACHEGROUP_ATTRIBUTE_GROUPNAME: DWORD = 0x00000010; +pub const CACHEGROUP_ATTRIBUTE_STORAGE: DWORD = 0x00000020; +pub const CACHEGROUP_FLAG_NONPURGEABLE: DWORD = 0x00000001; +pub const CACHEGROUP_FLAG_GIDONLY: DWORD = 0x00000004; +pub const CACHEGROUP_FLAG_FLUSHURL_ONDELETE: DWORD = 0x00000002; +pub const CACHEGROUP_SEARCH_ALL: DWORD = 0x00000000; +pub const CACHEGROUP_SEARCH_BYURL: DWORD = 0x00000001; +pub const CACHEGROUP_TYPE_INVALID: DWORD = 0x00000001; +pub const CACHEGROUP_READWRITE_MASK: DWORD = CACHEGROUP_ATTRIBUTE_TYPE + | CACHEGROUP_ATTRIBUTE_QUOTA | CACHEGROUP_ATTRIBUTE_GROUPNAME | CACHEGROUP_ATTRIBUTE_STORAGE; +pub const GROUPNAME_MAX_LENGTH: usize = 120; +pub const GROUP_OWNER_STORAGE_SIZE: usize = 4; +STRUCT!{struct INTERNET_CACHE_GROUP_INFOA { + dwGroupSize: DWORD, + dwGroupFlags: DWORD, + dwGroupType: DWORD, + dwDiskUsage: DWORD, + dwDiskQuota: DWORD, + dwOwnerStorage: [DWORD; GROUP_OWNER_STORAGE_SIZE], + szGroupName: [CHAR; GROUPNAME_MAX_LENGTH], +}} +pub type LPINTERNET_CACHE_GROUP_INFOA = *mut INTERNET_CACHE_GROUP_INFOA; +STRUCT!{struct INTERNET_CACHE_GROUP_INFOW { + dwGroupSize: DWORD, + dwGroupFlags: DWORD, + dwGroupType: DWORD, + dwDiskUsage: DWORD, + dwDiskQuota: DWORD, + dwOwnerStorage: [DWORD; GROUP_OWNER_STORAGE_SIZE], + szGroupName: [WCHAR; GROUPNAME_MAX_LENGTH], +}} +pub type LPINTERNET_CACHE_GROUP_INFOW = *mut INTERNET_CACHE_GROUP_INFOW; +pub const CACHE_ENTRY_ATTRIBUTE_FC: DWORD = 0x00000004; +pub const CACHE_ENTRY_HITRATE_FC: DWORD = 0x00000010; +pub const CACHE_ENTRY_MODTIME_FC: DWORD = 0x00000040; +pub const CACHE_ENTRY_EXPTIME_FC: DWORD = 0x00000080; +pub const CACHE_ENTRY_ACCTIME_FC: DWORD = 0x00000100; +pub const CACHE_ENTRY_SYNCTIME_FC: DWORD = 0x00000200; +pub const CACHE_ENTRY_HEADERINFO_FC: DWORD = 0x00000400; +pub const CACHE_ENTRY_EXEMPT_DELTA_FC: DWORD = 0x00000800; +pub const INTERNET_CACHE_GROUP_ADD: DWORD = 0; +pub const INTERNET_CACHE_GROUP_REMOVE: DWORD = 1; +pub const INTERNET_DIAL_FORCE_PROMPT: DWORD = 0x2000; +pub const INTERNET_DIAL_SHOW_OFFLINE: DWORD = 0x4000; +pub const INTERNET_DIAL_UNATTENDED: DWORD = 0x8000; +pub const INTERENT_GOONLINE_REFRESH: DWORD = 0x00000001; +pub const INTERENT_GOONLINE_NOPROMPT: DWORD = 0x00000002; +pub const INTERENT_GOONLINE_MASK: DWORD = 0x00000003; +pub const INTERNET_AUTODIAL_FORCE_ONLINE: DWORD = 1; +pub const INTERNET_AUTODIAL_FORCE_UNATTENDED: DWORD = 2; +pub const INTERNET_AUTODIAL_FAILIFSECURITYCHECK: DWORD = 4; +pub const INTERNET_AUTODIAL_OVERRIDE_NET_PRESENT: DWORD = 8; +pub const INTERNET_AUTODIAL_FLAGS_MASK: DWORD = INTERNET_AUTODIAL_FORCE_ONLINE + | INTERNET_AUTODIAL_FORCE_UNATTENDED | INTERNET_AUTODIAL_FAILIFSECURITYCHECK + | INTERNET_AUTODIAL_OVERRIDE_NET_PRESENT; +pub const PROXY_AUTO_DETECT_TYPE_DHCP: DWORD = 1; +pub const PROXY_AUTO_DETECT_TYPE_DNS_A: DWORD = 2; +STRUCT!{struct AutoProxyHelperVtbl { + IsResolvable: Option<unsafe extern "system" fn( + lpszHost: LPSTR, + ) -> BOOL>, + GetIPAddress: Option<unsafe extern "system" fn( + lpszIPAddress: LPSTR, + lpdwIPAddressSize: LPDWORD, + ) -> DWORD>, + ResolveHostName: Option<unsafe extern "system" fn( + lpszHostName: LPSTR, + lpszIPAddress: LPSTR, + lpdwIPAddressSize: LPDWORD, + ) -> DWORD>, + IsInNet: Option<unsafe extern "system" fn( + lpszIPAddress: LPSTR, + lpszDest: LPSTR, + lpszMask: LPSTR, + ) -> BOOL>, + IsResolvableEx: Option<unsafe extern "system" fn( + lpszHost: LPSTR, + ) -> BOOL>, + GetIPAddressEx: Option<unsafe extern "system" fn( + lpszIPAddress: LPSTR, + lpdwIPAddressSize: LPDWORD, + ) -> DWORD>, + ResolveHostNameEx: Option<unsafe extern "system" fn( + lpszHostName: LPSTR, + lpszIPAddress: LPSTR, + lpdwIPAddressSize: LPDWORD, + ) -> DWORD>, + IsInNetEx: Option<unsafe extern "system" fn( + lpszIPAddress: LPSTR, + lpszIPPrefix: LPSTR, + ) -> BOOL>, + SortIpList: Option<unsafe extern "system" fn( + lpszIPAddressList: LPSTR, + lpszIPSortedList: LPSTR, + lpdwIPSortedListSize: LPDWORD, + ) -> DWORD>, +}} +STRUCT!{struct AUTO_PROXY_SCRIPT_BUFFER { + dwStructSize: DWORD, + lpszScriptBuffer: LPSTR, + dwScriptBufferSize: DWORD, +}} +pub type LPAUTO_PROXY_SCRIPT_BUFFER = *mut AUTO_PROXY_SCRIPT_BUFFER; +STRUCT!{struct AutoProxyHelperFunctions { + lpVtbl: *const AutoProxyHelperVtbl, +}} +FN!{stdcall pfnInternetInitializeAutoProxyDll( + DWORD, + LPSTR, + LPSTR, + *mut AutoProxyHelperFunctions, + LPAUTO_PROXY_SCRIPT_BUFFER, +) -> BOOL} +FN!{stdcall pfnInternetDeInitializeAutoProxyDll( + LPSTR, + DWORD, +) -> BOOL} +FN!{stdcall pfnInternetGetProxyInfo( + LPCSTR, + DWORD, + LPSTR, + DWORD, + *mut LPSTR, + LPDWORD, +) -> BOOL} +ENUM!{enum WPAD_CACHE_DELETE { + WPAD_CACHE_DELETE_CURRENT = 0x0, + WPAD_CACHE_DELETE_ALL = 0x1, +}} +pub const INTERNET_CONNECTION_MODEM: DWORD = 0x01; +pub const INTERNET_CONNECTION_LAN: DWORD = 0x02; +pub const INTERNET_CONNECTION_PROXY: DWORD = 0x04; +pub const INTERNET_CONNECTION_MODEM_BUSY: DWORD = 0x08; +pub const INTERNET_RAS_INSTALLED: DWORD = 0x10; +pub const INTERNET_CONNECTION_OFFLINE: DWORD = 0x20; +pub const INTERNET_CONNECTION_CONFIGURED: DWORD = 0x40; +FN!{stdcall PFN_DIAL_HANDLER( + HWND, + LPCSTR, + DWORD, + LPDWORD, +) -> DWORD} +pub const INTERNET_CUSTOMDIAL_CONNECT: DWORD = 0; +pub const INTERNET_CUSTOMDIAL_UNATTENDED: DWORD = 1; +pub const INTERNET_CUSTOMDIAL_DISCONNECT: DWORD = 2; +pub const INTERNET_CUSTOMDIAL_SHOWOFFLINE: DWORD = 4; +pub const INTERNET_CUSTOMDIAL_SAFE_FOR_UNATTENDED: DWORD = 1; +pub const INTERNET_CUSTOMDIAL_WILL_SUPPLY_STATE: DWORD = 2; +pub const INTERNET_CUSTOMDIAL_CAN_HANGUP: DWORD = 4; +pub const INTERNET_DIALSTATE_DISCONNECTED: DWORD = 1; +pub const INTERNET_IDENTITY_FLAG_PRIVATE_CACHE: DWORD = 0x01; +pub const INTERNET_IDENTITY_FLAG_SHARED_CACHE: DWORD = 0x02; +pub const INTERNET_IDENTITY_FLAG_CLEAR_DATA: DWORD = 0x04; +pub const INTERNET_IDENTITY_FLAG_CLEAR_COOKIES: DWORD = 0x08; +pub const INTERNET_IDENTITY_FLAG_CLEAR_HISTORY: DWORD = 0x10; +pub const INTERNET_IDENTITY_FLAG_CLEAR_CONTENT: DWORD = 0x20; +pub const INTERNET_SUPPRESS_RESET_ALL: DWORD = 0x00; +pub const INTERNET_SUPPRESS_COOKIE_POLICY: DWORD = 0x01; +pub const INTERNET_SUPPRESS_COOKIE_POLICY_RESET: DWORD = 0x02; +pub const PRIVACY_TEMPLATE_NO_COOKIES: DWORD = 0; +pub const PRIVACY_TEMPLATE_HIGH: DWORD = 1; +pub const PRIVACY_TEMPLATE_MEDIUM_HIGH: DWORD = 2; +pub const PRIVACY_TEMPLATE_MEDIUM: DWORD = 3; +pub const PRIVACY_TEMPLATE_MEDIUM_LOW: DWORD = 4; +pub const PRIVACY_TEMPLATE_LOW: DWORD = 5; +pub const PRIVACY_TEMPLATE_CUSTOM: DWORD = 100; +pub const PRIVACY_TEMPLATE_ADVANCED: DWORD = 101; +pub const PRIVACY_TEMPLATE_MAX: DWORD = PRIVACY_TEMPLATE_LOW; +pub const PRIVACY_TYPE_FIRST_PARTY: DWORD = 0; +pub const PRIVACY_TYPE_THIRD_PARTY: DWORD = 1; +extern "system" { + pub fn CommitUrlCacheEntryA( + lpszUrlName: LPCSTR, + lpszLocalFileName: LPCSTR, + ExpireTime: FILETIME, + LastModifiedTime: FILETIME, + CacheEntryType: DWORD, + lpHeaderInfo: LPBYTE, + cchHeaderInfo: DWORD, + lpszFileExtension: LPCSTR, + lpszOriginalUrl: LPCSTR, + ) -> BOOL; + pub fn CommitUrlCacheEntryW( + lpszUrlName: LPCWSTR, + lpszLocalFileName: LPCWSTR, + ExpireTime: FILETIME, + LastModifiedTime: FILETIME, + CacheEntryType: DWORD, + lpszHeaderInfo: LPWSTR, + cchHeaderInfo: DWORD, + lpszFileExtension: LPCWSTR, + lpszOriginalUrl: LPCWSTR, + ) -> BOOL; + pub fn CreateMD5SSOHash ( + pszChallengeInfo: PWSTR, + pwszRealm: PWSTR, + pwszTarget: PWSTR, + pbHexHash: PBYTE, + ) -> BOOL; + pub fn CreateUrlCacheEntryA( + lpszUrlName: LPCSTR, + dwExpectedFileSize: DWORD, + lpszFileExtension: LPCSTR, + lpszFileName: LPSTR, + dwReserved: DWORD, + ) -> BOOL; + pub fn CreateUrlCacheEntryW( + lpszUrlName: LPCWSTR, + dwExpectedFileSize: DWORD, + lpszFileExtension: LPCWSTR, + lpszFileName: LPWSTR, + dwReserved: DWORD, + ) -> BOOL; + pub fn CreateUrlCacheGroup( + dwFlags: DWORD, + lpReserved: LPVOID, + ) -> GROUPID; + pub fn DeleteUrlCacheEntryA( + lpszUrlName: LPCSTR, + ) -> BOOL; + pub fn DeleteUrlCacheEntryW( + lpszUrlName: LPCWSTR, + ) -> BOOL; + pub fn DeleteUrlCacheGroup( + GroupId: GROUPID, + dwFlags: DWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn DeleteWpadCacheForNetworks( + arg0: WPAD_CACHE_DELETE, + ) -> BOOL; + pub fn DetectAutoProxyUrl( + pszAutoProxyUrl: PSTR, + cchAutoProxyUrl: DWORD, + dwDetectFlags: DWORD, + ) -> BOOL; + pub fn FindCloseUrlCache( + hEnumHandle: HANDLE, + ) -> BOOL; + pub fn FindFirstUrlCacheEntryA( + lpszUrlSearchPattern: LPCSTR, + lpFirstCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOA, + lpcbCacheEntryInfo: LPDWORD, + ) -> HANDLE; + pub fn FindFirstUrlCacheEntryExA( + lpszUrlSearchPattern: LPCSTR, + dwFlags: DWORD, + dwFilter: DWORD, + GroupId: GROUPID, + lpFirstCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOA, + lpcbCacheEntryInfo: LPDWORD, + lpGroupAttributes: LPVOID, + lpcbGroupAttributes: LPDWORD, + lpReserved: LPVOID, + ) -> HANDLE; + pub fn FindFirstUrlCacheEntryExW( + lpszUrlSearchPattern: LPCWSTR, + dwFlags: DWORD, + dwFilter: DWORD, + GroupId: GROUPID, + lpFirstCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOW, + lpcbCacheEntryInfo: LPDWORD, + lpGroupAttributes: LPVOID, + lpcbGroupAttributes: LPDWORD, + lpReserved: LPVOID, + ) -> HANDLE; + pub fn FindFirstUrlCacheEntryW( + lpszUrlSearchPattern: LPCWSTR, + lpFirstCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOW, + lpcbCacheEntryInfo: LPDWORD, + ) -> HANDLE; + pub fn FindFirstUrlCacheGroup( + dwFlags: DWORD, + dwFilter: DWORD, + lpSearchCondition: LPVOID, + dwSearchCondition: DWORD, + lpGroupId: *mut GROUPID, + lpReserved: LPVOID, + ) -> HANDLE; + pub fn FindNextUrlCacheEntryA( + hEnumHandle: HANDLE, + lpNextCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOA, + lpcbCacheEntryInfo: LPDWORD, + ) -> BOOL; + pub fn FindNextUrlCacheEntryExA( + hEnumHandle: HANDLE, + lpNextCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOA, + lpcbCacheEntryInfo: LPDWORD, + lpGroupAttributes: LPVOID, + lpcbGroupAttributes: LPDWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn FindNextUrlCacheEntryExW( + hEnumHandle: HANDLE, + lpNextCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOW, + lpcbCacheEntryInfo: LPDWORD, + lpGroupAttributes: LPVOID, + lpcbGroupAttributes: LPDWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn FindNextUrlCacheEntryW( + hEnumHandle: HANDLE, + lpNextCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOW, + lpcbCacheEntryInfo: LPDWORD, + ) -> BOOL; + pub fn FindNextUrlCacheGroup( + hFind: HANDLE, + lpGroupId: *mut GROUPID, + lpReserved: LPVOID, + ) -> BOOL; + pub fn FtpCommandA( + hConnect: HINTERNET, + fExpectResponse: BOOL, + dwFlags: DWORD, + lpszCommand: LPCSTR, + dwContext: DWORD_PTR, + phFtpCommand: *mut HINTERNET, + ) -> BOOL; + pub fn FtpCommandW( + hConnect: HINTERNET, + fExpectResponse: BOOL, + dwFlags: DWORD, + lpszCommand: LPCWSTR, + dwContext: DWORD_PTR, + phFtpCommand: *mut HINTERNET, + ) -> BOOL; + pub fn FtpCreateDirectoryA( + hConnect: HINTERNET, + lpszDirectory: LPCSTR, + ) -> BOOL; + pub fn FtpCreateDirectoryW( + hConnect: HINTERNET, + lpszDirectory: LPCWSTR, + ) -> BOOL; + pub fn FtpDeleteFileA( + hConnect: HINTERNET, + lpszFileName: LPCSTR, + ) -> BOOL; + pub fn FtpDeleteFileW( + hConnect: HINTERNET, + lpszFileName: LPCWSTR, + ) -> BOOL; + pub fn FtpFindFirstFileA( + hConnect: HINTERNET, + lpszSearchFile: LPCSTR, + lpFindFileData: LPWIN32_FIND_DATAA, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn FtpFindFirstFileW( + hConnect: HINTERNET, + lpszSearchFile: LPCWSTR, + lpFindFileData: LPWIN32_FIND_DATAW, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn FtpGetCurrentDirectoryA( + hConnect: HINTERNET, + lpszCurrentDirectory: LPSTR, + lpdwCurrentDirectory: LPDWORD, + ) -> BOOL; + pub fn FtpGetCurrentDirectoryW( + hConnect: HINTERNET, + lpszCurrentDirectory: LPWSTR, + lpdwCurrentDirectory: LPDWORD, + ) -> BOOL; + pub fn FtpGetFileA( + hConnect: HINTERNET, + lpszRemoteFile: LPCSTR, + lpszNewFile: LPCSTR, + fFailIfExists: BOOL, + dwFlagsAndAttributes: DWORD, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn FtpGetFileEx( + hFtpSession: HINTERNET, + lpszRemoteFile: LPCSTR, + lpszNewFile: LPCWSTR, + fFailIfExists: BOOL, + dwFlagsAndAttributes: DWORD, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn FtpGetFileSize( + hFile: HINTERNET, + lpdwFileSizeHigh: LPDWORD, + ) -> DWORD; + pub fn FtpGetFileW( + hConnect: HINTERNET, + lpszRemoteFile: LPCWSTR, + lpszNewFile: LPCWSTR, + fFailIfExists: BOOL, + dwFlagsAndAttributes: DWORD, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn FtpOpenFileA( + hConnect: HINTERNET, + lpszFileName: LPCSTR, + dwAccess: DWORD, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn FtpOpenFileW( + hConnect: HINTERNET, + lpszFileName: LPCWSTR, + dwAccess: DWORD, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn FtpPutFileA( + hConnect: HINTERNET, + lpszLocalFile: LPCSTR, + lpszNewRemoteFile: LPCSTR, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn FtpPutFileEx( + hFtpSession: HINTERNET, + lpszLocalFile: LPCWSTR, + lpszNewRemoteFile: LPCSTR, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn FtpPutFileW( + hConnect: HINTERNET, + lpszLocalFile: LPCWSTR, + lpszNewRemoteFile: LPCWSTR, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn FtpRemoveDirectoryA( + hConnect: HINTERNET, + lpszDirectory: LPCSTR, + ) -> BOOL; + pub fn FtpRemoveDirectoryW( + hConnect: HINTERNET, + lpszDirectory: LPCWSTR, + ) -> BOOL; + pub fn FtpRenameFileA( + hConnect: HINTERNET, + lpszExisting: LPCSTR, + lpszNew: LPCSTR, + ) -> BOOL; + pub fn FtpRenameFileW( + hConnect: HINTERNET, + lpszExisting: LPCWSTR, + lpszNew: LPCWSTR, + ) -> BOOL; + pub fn FtpSetCurrentDirectoryA( + hConnect: HINTERNET, + lpszDirectory: LPCSTR, + ) -> BOOL; + pub fn FtpSetCurrentDirectoryW( + hConnect: HINTERNET, + lpszDirectory: LPCWSTR, + ) -> BOOL; + pub fn GetUrlCacheEntryInfoA( + lpszUrlName: LPCSTR, + lpCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOA, + lpcbCacheEntryInfo: LPDWORD, + ) -> BOOL; + pub fn GetUrlCacheEntryInfoExA( + lpszUrl: LPCSTR, + lpCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOA, + lpcbCacheEntryInfo: LPDWORD, + lpszRedirectUrl: LPSTR, + lpcbRedirectUrl: LPDWORD, + lpReserved: LPVOID, + dwFlags: DWORD, + ) -> BOOL; + pub fn GetUrlCacheEntryInfoExW( + lpszUrl: LPCWSTR, + lpCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOW, + lpcbCacheEntryInfo: LPDWORD, + lpszRedirectUrl: LPWSTR, + lpcbRedirectUrl: LPDWORD, + lpReserved: LPVOID, + dwFlags: DWORD, + ) -> BOOL; + pub fn GetUrlCacheEntryInfoW( + lpszUrlName: LPCWSTR, + lpCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOW, + lpcbCacheEntryInfo: LPDWORD, + ) -> BOOL; + pub fn GetUrlCacheGroupAttributeA( + gid: GROUPID, + dwFlags: DWORD, + dwAttributes: DWORD, + lpGroupInfo: LPINTERNET_CACHE_GROUP_INFOA, + lpcbGroupInfo: LPDWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn GetUrlCacheGroupAttributeW( + gid: GROUPID, + dwFlags: DWORD, + dwAttributes: DWORD, + lpGroupInfo: LPINTERNET_CACHE_GROUP_INFOW, + lpcbGroupInfo: LPDWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn GopherCreateLocatorA( + lpszHost: LPCSTR, + nServerPort: INTERNET_PORT, + lpszDisplayString: LPCSTR, + lpszSelectorString: LPCSTR, + dwGopherType: DWORD, + lpszLocator: LPSTR, + lpdwBufferLength: LPDWORD, + ) -> BOOL; + pub fn GopherCreateLocatorW( + lpszHost: LPCWSTR, + nServerPort: INTERNET_PORT, + lpszDisplayString: LPCWSTR, + lpszSelectorString: LPCWSTR, + dwGopherType: DWORD, + lpszLocator: LPWSTR, + lpdwBufferLength: LPDWORD, + ) -> BOOL; + pub fn GopherFindFirstFileA( + hConnect: HINTERNET, + lpszLocator: LPCSTR, + lpszSearchString: LPCSTR, + lpFindData: LPGOPHER_FIND_DATAA, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn GopherFindFirstFileW( + hConnect: HINTERNET, + lpszLocator: LPCWSTR, + lpszSearchString: LPCWSTR, + lpFindData: LPGOPHER_FIND_DATAW, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn GopherGetAttributeA( + hConnect: HINTERNET, + lpszLocator: LPCSTR, + lpszAttributeName: LPCSTR, + lpBuffer: LPBYTE, + dwBufferLength: DWORD, + lpdwCharactersReturned: LPDWORD, + lpfnEnumerator: GOPHER_ATTRIBUTE_ENUMERATOR, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn GopherGetAttributeW( + hConnect: HINTERNET, + lpszLocator: LPCWSTR, + lpszAttributeName: LPCWSTR, + lpBuffer: LPBYTE, + dwBufferLength: DWORD, + lpdwCharactersReturned: LPDWORD, + lpfnEnumerator: GOPHER_ATTRIBUTE_ENUMERATOR, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn GopherGetLocatorTypeA( + lpszLocator: LPCSTR, + lpdwGopherType: LPDWORD, + ) -> BOOL; + pub fn GopherGetLocatorTypeW( + lpszLocator: LPCWSTR, + lpdwGopherType: LPDWORD, + ) -> BOOL; + pub fn GopherOpenFileA( + hConnect: HINTERNET, + lpszLocator: LPCSTR, + lpszView: LPCSTR, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn GopherOpenFileW( + hConnect: HINTERNET, + lpszLocator: LPCWSTR, + lpszView: LPCWSTR, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn HttpAddRequestHeadersA( + hRequest: HINTERNET, + lpszHeaders: LPCSTR, + dwHeadersLength: DWORD, + dwModifiers: DWORD, + ) -> BOOL; + pub fn HttpAddRequestHeadersW( + hRequest: HINTERNET, + lpszHeaders: LPCWSTR, + dwHeadersLength: DWORD, + dwModifiers: DWORD, + ) -> BOOL; + pub fn HttpEndRequestA( + hRequest: HINTERNET, + lpBuffersOut: LPINTERNET_BUFFERSA, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn HttpEndRequestW( + hRequest: HINTERNET, + lpBuffersOut: LPINTERNET_BUFFERSW, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn HttpOpenRequestA( + hConnect: HINTERNET, + lpszVerb: LPCSTR, + lpszObjectName: LPCSTR, + lpszVersion: LPCSTR, + lpszReferrer: LPCSTR, + lplpszAcceptTypes: *mut LPCSTR, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn HttpOpenRequestW( + hConnect: HINTERNET, + lpszVerb: LPCWSTR, + lpszObjectName: LPCWSTR, + lpszVersion: LPCWSTR, + lpszReferrer: LPCWSTR, + lplpszAcceptTypes: *mut LPCWSTR, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn HttpQueryInfoA( + hRequest: HINTERNET, + dwInfoLevel: DWORD, + lpBuffer: LPVOID, + lpdwBufferLength: LPDWORD, + lpdwIndex: LPDWORD, + ) -> BOOL; + pub fn HttpQueryInfoW( + hRequest: HINTERNET, + dwInfoLevel: DWORD, + lpBuffer: LPVOID, + lpdwBufferLength: LPDWORD, + lpdwIndex: LPDWORD, + ) -> BOOL; + pub fn HttpSendRequestA( + hRequest: HINTERNET, + lpszHeaders: LPCSTR, + dwHeadersLength: DWORD, + lpOptional: LPVOID, + dwOptionalLength: DWORD, + ) -> BOOL; + pub fn HttpSendRequestExA( + hRequest: HINTERNET, + lpBuffersIn: LPINTERNET_BUFFERSA, + lpBuffersOut: LPINTERNET_BUFFERSA, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn HttpSendRequestExW( + hRequest: HINTERNET, + lpBuffersIn: LPINTERNET_BUFFERSW, + lpBuffersOut: LPINTERNET_BUFFERSW, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn HttpSendRequestW( + hRequest: HINTERNET, + lpszHeaders: LPCWSTR, + dwHeadersLength: DWORD, + lpOptional: LPVOID, + dwOptionalLength: DWORD, + ) -> BOOL; + pub fn InternetAttemptConnect( + dwReserved: DWORD, + ) -> DWORD; + pub fn InternetAutodial( + dwFlags: DWORD, + hwndParent: HWND, + ) -> BOOL; + pub fn InternetAutodialHangup( + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetCanonicalizeUrlA( + lpszUrl: LPCSTR, + lpszBuffer: LPSTR, + lpdwBufferLength: LPDWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn InternetCanonicalizeUrlW( + lpszUrl: LPCWSTR, + lpszBuffer: LPWSTR, + lpdwBufferLength: LPDWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn InternetCheckConnectionA( + lpszUrl: LPCSTR, + dwFlags: DWORD, + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetCheckConnectionW( + lpszUrl: LPCWSTR, + dwFlags: DWORD, + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetClearAllPerSiteCookieDecisions() -> BOOL; + pub fn InternetCloseHandle( + hInternet: HINTERNET, + ) -> BOOL; + pub fn InternetCombineUrlA( + lpszBaseUrl: LPCSTR, + lpszRelativeUrl: LPCSTR, + lpszBuffer: LPSTR, + lpdwBufferLength: LPDWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn InternetCombineUrlW( + lpszBaseUrl: LPCWSTR, + lpszRelativeUrl: LPCWSTR, + lpszBuffer: LPWSTR, + lpdwBufferLength: LPDWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn InternetConfirmZoneCrossingA( + hWnd: HWND, + szUrlPrev: LPSTR, + szUrlNew: LPSTR, + bPost: BOOL, + ) -> DWORD; + pub fn InternetConfirmZoneCrossingW( + hWnd: HWND, + szUrlPrev: LPWSTR, + szUrlNew: LPWSTR, + bPost: BOOL, + ) -> DWORD; + pub fn InternetConnectA( + hInternet: HINTERNET, + lpszServerName: LPCSTR, + nServerPort: INTERNET_PORT, + lpszUserName: LPCSTR, + lpszPassword: LPCSTR, + dwService: DWORD, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn InternetConnectW( + hInternet: HINTERNET, + lpszServerName: LPCWSTR, + nServerPort: INTERNET_PORT, + lpszUserName: LPCWSTR, + lpszPassword: LPCWSTR, + dwService: DWORD, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn InternetCrackUrlA( + lpszUrl: LPCSTR, + dwUrlLength: DWORD, + dwFlags: DWORD, + lpUrlComponents: LPURL_COMPONENTSA, + ) -> BOOL; + pub fn InternetCrackUrlW( + lpszUrl: LPCWSTR, + dwUrlLength: DWORD, + dwFlags: DWORD, + lpUrlComponents: LPURL_COMPONENTSW, + ) -> BOOL; + pub fn InternetCreateUrlA( + lpUrlComponents: LPURL_COMPONENTSA, + dwFlags: DWORD, + lpszUrl: LPSTR, + lpdwUrlLength: LPDWORD, + ) -> BOOL; + pub fn InternetCreateUrlW( + lpUrlComponents: LPURL_COMPONENTSW, + dwFlags: DWORD, + lpszUrl: LPWSTR, + lpdwUrlLength: LPDWORD, + ) -> BOOL; + pub fn InternetDialA( + hwndParent: HWND, + lpszConnectoid: LPSTR, + dwFlags: DWORD, + lpdwConnection: *mut DWORD_PTR, + dwReserved: DWORD, + ) -> DWORD; + pub fn InternetDialW( + hwndParent: HWND, + lpszConnectoid: LPWSTR, + dwFlags: DWORD, + lpdwConnection: *mut DWORD_PTR, + dwReserved: DWORD, + ) -> DWORD; + pub fn InternetEnumPerSiteCookieDecisionA( + pszSiteName: LPSTR, + pcSiteNameSize: *mut u32, + pdwDecision: *mut u32, + dwIndex: u32, + ) -> BOOL; + pub fn InternetEnumPerSiteCookieDecisionW( + pszSiteName: LPWSTR, + pcSiteNameSize: *mut u32, + pdwDecision: *mut u32, + dwIndex: u32, + ) -> BOOL; + pub fn InternetErrorDlg( + hWnd: HWND, + hRequest: HINTERNET, + dwError: DWORD, + dwFlags: DWORD, + lppvData: *mut LPVOID, + ) -> DWORD; + pub fn InternetFindNextFileA( + hFind: HINTERNET, + lpvFindData: LPVOID, + ) -> BOOL; + pub fn InternetFindNextFileW( + hFind: HINTERNET, + lpvFindData: LPVOID, + ) -> BOOL; + pub fn InternetFreeCookies( + pCookies: *mut INTERNET_COOKIE2, + dwCookieCount: DWORD, + ) -> (); + pub fn InternetGetConnectedState( + lpdwFlags: LPDWORD, + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetGetConnectedStateExA( + lpdwFlags: LPDWORD, + lpszConnectionName: LPSTR, + cchNameLen: DWORD, + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetGetConnectedStateExW( + lpdwFlags: LPDWORD, + lpszConnectionName: LPWSTR, + cchNameLen: DWORD, + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetGetCookieA( + lpszUrl: LPCSTR, + lpszCookieName: LPCSTR, + lpszCookieData: LPSTR, + lpdwSize: LPDWORD, + ) -> BOOL; + pub fn InternetGetCookieEx2( + pcwszUrl: PCWSTR, + pcwszCookieName: PCWSTR, + dwFlags: DWORD, + ppCookies: *mut *mut INTERNET_COOKIE2, + pdwCookieCount: PDWORD, + ) -> DWORD; + pub fn InternetGetCookieExA( + lpszUrl: LPCSTR, + lpszCookieName: LPCSTR, + lpszCookieData: LPSTR, + lpdwSize: LPDWORD, + dwFlags: DWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn InternetGetCookieExW( + lpszUrl: LPCWSTR, + lpszCookieName: LPCWSTR, + lpszCookieData: LPWSTR, + lpdwSize: LPDWORD, + dwFlags: DWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn InternetGetCookieW( + lpszUrl: LPCWSTR, + lpszCookieName: LPCWSTR, + lpszCookieData: LPWSTR, + lpdwSize: LPDWORD, + ) -> BOOL; + pub fn InternetGetLastResponseInfoA( + lpdwError: LPDWORD, + lpszBuffer: LPSTR, + lpdwBufferLength: LPDWORD, + ) -> BOOL; + pub fn InternetGetLastResponseInfoW( + lpdwError: LPDWORD, + lpszBuffer: LPWSTR, + lpdwBufferLength: LPDWORD, + ) -> BOOL; + pub fn InternetGetPerSiteCookieDecisionA( + pchHostName: LPCSTR, + pResult: *mut u32, + ) -> BOOL; + pub fn InternetGetPerSiteCookieDecisionW( + pchHostName: LPCWSTR, + pResult: *mut u32, + ) -> BOOL; + pub fn InternetGoOnlineA( + lpszURL: LPCSTR, + hwndParent: HWND, + dwFlags: DWORD, + ) -> BOOL; + pub fn InternetGoOnlineW( + lpszURL: LPCWSTR, + hwndParent: HWND, + dwFlags: DWORD, + ) -> BOOL; + pub fn InternetHangUp( + dwConnection: DWORD_PTR, + dwReserved: DWORD, + ) -> DWORD; + pub fn InternetInitializeAutoProxyDll( + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetLockRequestFile( + hInternet: HINTERNET, + lphLockRequestInfo: *mut HANDLE, + ) -> BOOL; + pub fn InternetOpenA( + lpszAgent: LPCSTR, + dwAccessType: DWORD, + lpszProxy: LPCSTR, + lpszProxyBypass: LPCSTR, + dwFlags: DWORD, + ) -> HINTERNET; + pub fn InternetOpenUrlA( + hInternet: HINTERNET, + lpszUrl: LPCSTR, + lpszHeaders: LPCSTR, + dwHeadersLength: DWORD, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn InternetOpenUrlW( + hInternet: HINTERNET, + lpszUrl: LPCWSTR, + lpszHeaders: LPCWSTR, + dwHeadersLength: DWORD, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> HINTERNET; + pub fn InternetOpenW( + lpszAgent: LPCWSTR, + dwAccessType: DWORD, + lpszProxy: LPCWSTR, + lpszProxyBypass: LPCWSTR, + dwFlags: DWORD, + ) -> HINTERNET; + pub fn InternetQueryDataAvailable( + hFile: HINTERNET, + lpdwNumberOfBytesAvailable: LPDWORD, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn InternetQueryOptionA( + hInternet: HINTERNET, + dwOption: DWORD, + lpBuffer: LPVOID, + lpdwBufferLength: LPDWORD, + ) -> BOOL; + pub fn InternetQueryOptionW( + hInternet: HINTERNET, + dwOption: DWORD, + lpBuffer: LPVOID, + lpdwBufferLength: LPDWORD, + ) -> BOOL; + pub fn InternetReadFile( + hFile: HINTERNET, + lpBuffer: LPVOID, + dwNumberOfBytesToRead: DWORD, + lpdwNumberOfBytesRead: LPDWORD, + ) -> BOOL; + pub fn InternetReadFileExA( + hFile: HINTERNET, + lpBuffersOut: LPINTERNET_BUFFERSA, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn InternetReadFileExW( + hFile: HINTERNET, + lpBuffersOut: LPINTERNET_BUFFERSW, + dwFlags: DWORD, + dwContext: DWORD_PTR, + ) -> BOOL; + pub fn InternetSetCookieA( + lpszUrl: LPCSTR, + lpszCookieName: LPCSTR, + lpszCookieData: LPCSTR, + ) -> BOOL; + pub fn InternetSetCookieEx2( + pcwszUrl: PCWSTR, + pCookie: *const INTERNET_COOKIE2, + pcwszP3PPolicy: PCWSTR, + dwFlags: DWORD, + pdwCookieState: PDWORD, + ) -> DWORD; + pub fn InternetSetCookieExA( + lpszUrl: LPCSTR, + lpszCookieName: LPCSTR, + lpszCookieData: LPCSTR, + dwFlags: DWORD, + dwReserved: DWORD_PTR, + ) -> DWORD; + pub fn InternetSetCookieExW( + lpszUrl: LPCWSTR, + lpszCookieName: LPCWSTR, + lpszCookieData: LPCWSTR, + dwFlags: DWORD, + dwReserved: DWORD_PTR, + ) -> DWORD; + pub fn InternetSetCookieW( + lpszUrl: LPCWSTR, + lpszCookieName: LPCWSTR, + lpszCookieData: LPCWSTR, + ) -> BOOL; + pub fn InternetSetDialStateA( + lpszConnectoid: LPCSTR, + dwState: DWORD, + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetSetDialStateW( + lpszConnectoid: LPCWSTR, + dwState: DWORD, + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetSetFilePointer( + hFile: HINTERNET, + lDistanceToMove: LONG, + lpDistanceToMoveHigh: PLONG, + dwMoveMethod: DWORD, + dwContext: DWORD_PTR, + ) -> DWORD; + pub fn InternetSetOptionA( + hInternet: HINTERNET, + dwOption: DWORD, + lpBuffer: LPVOID, + dwBufferLength: DWORD, + ) -> BOOL; + pub fn InternetSetOptionExA( + hInternet: HINTERNET, + dwOption: DWORD, + lpBuffer: LPVOID, + dwBufferLength: DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn InternetSetOptionExW( + hInternet: HINTERNET, + dwOption: DWORD, + lpBuffer: LPVOID, + dwBufferLength: DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn InternetSetOptionW( + hInternet: HINTERNET, + dwOption: DWORD, + lpBuffer: LPVOID, + dwBufferLength: DWORD, + ) -> BOOL; + pub fn InternetSetPerSiteCookieDecisionA( + pchHostName: LPCSTR, + dwDecision: DWORD, + ) -> BOOL; + pub fn InternetSetPerSiteCookieDecisionW( + pchHostName: LPCWSTR, + dwDecision: DWORD, + ) -> BOOL; + pub fn InternetSetStatusCallbackA( + hInternet: HINTERNET, + lpfnInternetCallback: INTERNET_STATUS_CALLBACK, + ) -> INTERNET_STATUS_CALLBACK; + pub fn InternetSetStatusCallbackW( + hInternet: HINTERNET, + lpfnInternetCallback: INTERNET_STATUS_CALLBACK, + ) -> INTERNET_STATUS_CALLBACK; + pub fn InternetTimeFromSystemTimeA( + pst: *const SYSTEMTIME, + dwRFC: DWORD, + lpszTime: LPSTR, + cbTime: DWORD, + ) -> BOOL; + pub fn InternetTimeFromSystemTimeW( + pst: *const SYSTEMTIME, + dwRFC: DWORD, + lpszTime: LPWSTR, + cbTime: DWORD, + ) -> BOOL; + pub fn InternetTimeToSystemTimeA( + lpszTime: LPCSTR, + pst: *mut SYSTEMTIME, + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetTimeToSystemTimeW( + lpszTime: LPCWSTR, + pst: *mut SYSTEMTIME, + dwReserved: DWORD, + ) -> BOOL; + pub fn InternetUnlockRequestFile( + hLockRequestInfo: HANDLE, + ) -> BOOL; + pub fn InternetWriteFile( + hFile: HINTERNET, + lpBuffer: LPCVOID, + dwNumberOfBytesToWrite: DWORD, + lpdwNumberOfBytesWritten: LPDWORD, + ) -> BOOL; + pub fn PrivacyGetZonePreferenceW( + dwZone: DWORD, + dwType: DWORD, + pdwTemplate: LPDWORD, + pszBuffer: LPWSTR, + pdwBufferLength: LPDWORD, + ) -> DWORD; + pub fn PrivacySetZonePreferenceW( + dwZone: DWORD, + dwType: DWORD, + dwTemplate: DWORD, + pszPreference: LPCWSTR, + ) -> DWORD; + pub fn ReadUrlCacheEntryStream( + hUrlCacheStream: HANDLE, + dwLocation: DWORD, + lpBuffer: LPVOID, + lpdwLen: LPDWORD, + Reserved: DWORD, + ) -> BOOL; + pub fn ReadUrlCacheEntryStreamEx( + hUrlCacheStream: HANDLE, + qwLocation: DWORDLONG, + lpBuffer: LPVOID, + lpdwLen: LPDWORD, + ) -> BOOL; + pub fn ResumeSuspendedDownload( + hRequest: HINTERNET, + dwResultCode: DWORD, + ) -> BOOL; + pub fn RetrieveUrlCacheEntryFileA( + lpszUrlName: LPCSTR, + lpCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOA, + lpcbCacheEntryInfo: LPDWORD, + dwReserved: DWORD, + ) -> BOOL; + pub fn RetrieveUrlCacheEntryFileW( + lpszUrlName: LPCWSTR, + lpCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOW, + lpcbCacheEntryInfo: LPDWORD, + dwReserved: DWORD, + ) -> BOOL; + pub fn RetrieveUrlCacheEntryStreamA( + lpszUrlName: LPCSTR, + lpCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOA, + lpcbCacheEntryInfo: LPDWORD, + fRandomRead: BOOL, + dwReserved: DWORD, + ) -> HANDLE; + pub fn RetrieveUrlCacheEntryStreamW( + lpszUrlName: LPCWSTR, + lpCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOW, + lpcbCacheEntryInfo: LPDWORD, + fRandomRead: BOOL, + dwReserved: DWORD, + ) -> HANDLE; + pub fn SetUrlCacheEntryGroupA( + lpszUrlName: LPCSTR, + dwFlags: DWORD, + GroupId: GROUPID, + pbGroupAttributes: LPBYTE, + cbGroupAttributes: DWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn SetUrlCacheEntryGroupW( + lpszUrlName: LPCWSTR, + dwFlags: DWORD, + GroupId: GROUPID, + pbGroupAttributes: LPBYTE, + cbGroupAttributes: DWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn SetUrlCacheEntryInfoA( + lpszUrlName: LPCSTR, + lpCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOA, + dwFieldControl: DWORD, + ) -> BOOL; + pub fn SetUrlCacheEntryInfoW( + lpszUrlName: LPCWSTR, + lpCacheEntryInfo: LPINTERNET_CACHE_ENTRY_INFOW, + dwFieldControl: DWORD, + ) -> BOOL; + pub fn SetUrlCacheGroupAttributeA( + gid: GROUPID, + dwFlags: DWORD, + dwAttributes: DWORD, + lpGroupInfo: LPINTERNET_CACHE_GROUP_INFOA, + lpReserved: LPVOID, + ) -> BOOL; + pub fn SetUrlCacheGroupAttributeW( + gid: GROUPID, + dwFlags: DWORD, + dwAttributes: DWORD, + lpGroupInfo: LPINTERNET_CACHE_GROUP_INFOW, + lpReserved: LPVOID, + ) -> BOOL; + pub fn UnlockUrlCacheEntryFileA( + lpszUrlName: LPCSTR, + dwReserved: DWORD, + ) -> BOOL; + pub fn UnlockUrlCacheEntryFileW( + lpszUrlName: LPCWSTR, + dwReserved: DWORD, + ) -> BOOL; + pub fn UnlockUrlCacheEntryStream( + hUrlCacheStream: HANDLE, + Reserved: DWORD, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winineti.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winineti.rs new file mode 100644 index 0000000..c0076c0 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winineti.rs @@ -0,0 +1,142 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Windows Internet Services API procedure declarations, types and constants. +// Currently, this only contains `INTERNET_FLAG_BGUPDATE`, which is needed to correctly define +// `wininet::INTERNET_FLAGS_MASK`. +use shared::minwindef::DWORD; +pub const INTERNET_FLAG_BGUPDATE: DWORD = 0x00000008; +// Functions from wininet.dll that *should* be in this header. +// pub fn AppCacheCheckManifest(); +// pub fn AppCacheCloseHandle(); +// pub fn AppCacheCreateAndCommitFile(); +// pub fn AppCacheDeleteGroup(); +// pub fn AppCacheDeleteIEGroup(); +// pub fn AppCacheDuplicateHandle(); +// pub fn AppCacheFinalize(); +// pub fn AppCacheFreeDownloadList(); +// pub fn AppCacheFreeGroupList(); +// pub fn AppCacheFreeIESpace(); +// pub fn AppCacheFreeSpace(); +// pub fn AppCacheGetDownloadList(); +// pub fn AppCacheGetFallbackUrl(); +// pub fn AppCacheGetGroupList(); +// pub fn AppCacheGetIEGroupList(); +// pub fn AppCacheGetInfo(); +// pub fn AppCacheGetManifestUrl(); +// pub fn AppCacheLookup(); +// pub fn CommitUrlCacheEntryBinaryBlob(); +// pub fn CreateCacheServerRpcBinding(); +// pub fn CreateUrlCacheContainerA(); +// pub fn CreateUrlCacheContainerW(); +// pub fn CreateUrlCacheEntryExW(); +// pub fn DeleteIE3Cache(); +// pub fn DeleteUrlCacheContainerA(); +// pub fn DeleteUrlCacheContainerW(); +// pub fn DoConnectoidsExist(); +// pub fn ExportCookieFileA(); +// pub fn ExportCookieFileW(); +// pub fn FindFirstUrlCacheContainerA(); +// pub fn FindFirstUrlCacheContainerW(); +// pub fn FindNextUrlCacheContainerA(); +// pub fn FindNextUrlCacheContainerW(); +// pub fn FindP3PPolicySymbol(); +// pub fn ForceNexusLookupExW(); +// pub fn FreeP3PObject(); +// pub fn FreeUrlCacheSpaceA(); +// pub fn FreeUrlCacheSpaceW(); +// pub fn GetCacheServerConnection(); +// pub fn GetDiskInfoA(); +// pub fn GetP3PPolicy(); +// pub fn GetP3PRequestStatus(); +// pub fn GetUrlCacheConfigInfoA(); +// pub fn GetUrlCacheConfigInfoW(); +// pub fn GetUrlCacheEntryBinaryBlob(); +// pub fn GetUrlCacheHeaderData(); +// pub fn HttpCheckDavComplianceA(); +// pub fn HttpCheckDavComplianceW(); +// pub fn HttpCloseDependencyHandle(); +// pub fn HttpDuplicateDependencyHandle(); +// pub fn HttpGetServerCredentials(); +// pub fn HttpGetTunnelSocket(); +// pub fn HttpIsHostHstsEnabled(); +// pub fn HttpOpenDependencyHandle(); +// pub fn HttpPushClose(); +// pub fn HttpPushEnable(); +// pub fn HttpPushWait(); +// pub fn HttpWebSocketClose(); +// pub fn HttpWebSocketCompleteUpgrade(); +// pub fn HttpWebSocketQueryCloseStatus(); +// pub fn HttpWebSocketReceive(); +// pub fn HttpWebSocketSend(); +// pub fn HttpWebSocketShutdown(); +// pub fn ImportCookieFileA(); +// pub fn ImportCookieFileW(); +// pub fn IncrementUrlCacheHeaderData(); +// pub fn InternalInternetGetCookie(); +// pub fn InternetAlgIdToStringA(); +// pub fn InternetAlgIdToStringW(); +// pub fn InternetAutodialCallback(); +// pub fn InternetAutoProxyGetProxyForUrl(); +// pub fn InternetAutoProxyOnSendRequestComplete(); +// pub fn InternetFortezzaCommand(); +// pub fn InternetFreeProxyInfoList(); +// pub fn InternetGetCertByURLA(); +// pub fn InternetGetProxyForUrl(); +// pub fn InternetGetSecurityInfoByURLA(); +// pub fn InternetGetSecurityInfoByURLW(); +// pub fn InternetQueryFortezzaStatus(); +// pub fn InternetSecurityProtocolToStringA(); +// pub fn InternetSecurityProtocolToStringW(); +// pub fn InternetShowSecurityInfoByURLA(); +// pub fn InternetShowSecurityInfoByURLW(); +// pub fn InternetWriteFileExA(); +// pub fn InternetWriteFileExW(); +// pub fn IsDialUpConnection(); +// pub fn IsDomainLegalCookieDomainA(); +// pub fn IsDomainLegalCookieDomainW(); +// pub fn IsHostInProxyBypassList(); +// pub fn IsLanConnection(); +// pub fn IsProfilesEnabled(); +// pub fn IsUrlCacheEntryExpiredA(); +// pub fn IsUrlCacheEntryExpiredW(); +// pub fn LoadUrlCacheContent(); +// pub fn MapResourceToPolicy(); +// pub fn ParseX509EncodedCertificateForListBoxEntry(); +// pub fn PerformOperationOverUrlCacheA(); +// pub fn ReadGuidsForConnectedNetworks(); +// pub fn RegisterForNetworkChangeNotification(); +// pub fn RegisterUrlCacheNotification(); +// pub fn RunOnceUrlCache(); +// pub fn SetGlobalJetParameters(); +// pub fn SetUrlCacheConfigInfoA(); +// pub fn SetUrlCacheConfigInfoW(); +// pub fn SetUrlCacheHeaderData(); +// pub fn ShowCertificate(); +// pub fn ShowClientAuthCerts(); +// pub fn ShowSecurityInfo(); +// pub fn ShowX509EncodedCertificate(); +// pub fn UnRegisterNetworkChangeNotification(); +// pub fn UpdateUrlCacheContentPath(); +// pub fn UrlCacheCheckEntriesExist(); +// pub fn UrlCacheCloseEntryHandle(); +// pub fn UrlCacheContainerSetEntryMaximumAge(); +// pub fn UrlCacheCreateContainer(); +// pub fn UrlCacheFindFirstEntry(); +// pub fn UrlCacheFindNextEntry(); +// pub fn UrlCacheFreeEntryInfo(); +// pub fn UrlCacheFreeGlobalSpace(); +// pub fn UrlCacheGetContentPaths(); +// pub fn UrlCacheGetEntryInfo(); +// pub fn UrlCacheGetGlobalCacheSize(); +// pub fn UrlCacheGetGlobalLimit(); +// pub fn UrlCacheReadEntryStream(); +// pub fn UrlCacheReloadSettings(); +// pub fn UrlCacheRetrieveEntryFile(); +// pub fn UrlCacheRetrieveEntryStream(); +// pub fn UrlCacheServer(); +// pub fn UrlCacheSetGlobalLimit(); +// pub fn UrlCacheUpdateEntryExtraData(); +// pub fn UrlZonesDetach(); diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winioctl.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winioctl.rs new file mode 100644 index 0000000..f01b998 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winioctl.rs @@ -0,0 +1,1091 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module defines the 32-Bit Windows Device I/O control codes. +use shared::basetsd::DWORD64; +use shared::devpropdef::DEVPROPKEY; +use shared::guiddef::GUID; +use shared::minwindef::{BYTE, DWORD, WORD}; +use um::winnt::{ + ANYSIZE_ARRAY, BOOLEAN, FILE_READ_DATA, FILE_WRITE_DATA, HANDLE, LARGE_INTEGER, WCHAR, +}; +DEFINE_GUID!{GUID_DEVINTERFACE_DISK, + 0x53f56307, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{GUID_DEVINTERFACE_CDROM, + 0x53f56308, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{GUID_DEVINTERFACE_PARTITION, + 0x53f5630a, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{GUID_DEVINTERFACE_TAPE, + 0x53f5630b, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{GUID_DEVINTERFACE_WRITEONCEDISK, + 0x53f5630c, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{GUID_DEVINTERFACE_VOLUME, + 0x53f5630d, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{GUID_DEVINTERFACE_MEDIUMCHANGER, + 0x53f56310, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{GUID_DEVINTERFACE_FLOPPY, + 0x53f56311, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{GUID_DEVINTERFACE_CDCHANGER, + 0x53f56312, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{GUID_DEVINTERFACE_STORAGEPORT, + 0x2accfe60, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{GUID_DEVINTERFACE_VMLUN, + 0x6f416619, 0x9f29, 0x42a5, 0xb2, 0x0b, 0x37, 0xe2, 0x19, 0xca, 0x02, 0xb0} +DEFINE_GUID!{GUID_DEVINTERFACE_SES, + 0x1790c9ec, 0x47d5, 0x4df3, 0xb5, 0xaf, 0x9a, 0xdf, 0x3c, 0xf2, 0x3e, 0x48} +DEFINE_GUID!{WDI_STORAGE_PREDICT_FAILURE_DPS_GUID, + 0xe9f2d03a, 0x747c, 0x41c2, 0xbb, 0x9a, 0x02, 0xc6, 0x2b, 0x6d, 0x5f, 0xcb} +DEFINE_GUID!{GUID_DEVINTERFACE_SERVICE_VOLUME, + 0x6ead3d82, 0x25ec, 0x46bc, 0xb7, 0xfd, 0xc1, 0xf0, 0xdf, 0x8f, 0x50, 0x37} +DEFINE_GUID!{GUID_DEVINTERFACE_HIDDEN_VOLUME, + 0x7f108a28, 0x9833, 0x4b3b, 0xb7, 0x80, 0x2c, 0x6b, 0x5f, 0xa5, 0xc0, 0x62} +DEFINE_GUID!{GUID_DEVINTERFACE_UNIFIED_ACCESS_RPMB, + 0x27447c21, 0xbcc3, 0x4d07, 0xa0, 0x5b, 0xa3, 0x39, 0x5b, 0xb4, 0xee, 0xe7} +DEFINE_GUID!{GUID_DEVINTERFACE_SCM_PHYSICAL_DEVICE, + 0x4283609d, 0x4dc2, 0x43be, 0xbb, 0xb4, 0x4f, 0x15, 0xdf, 0xce, 0x2c, 0x61} +DEFINE_GUID!{GUID_SCM_PD_HEALTH_NOTIFICATION, + 0x9da2d386, 0x72f5, 0x4ee3, 0x81, 0x55, 0xec, 0xa0, 0x67, 0x8e, 0x3b, 0x06} +DEFINE_GUID!{GUID_SCM_PD_PASSTHROUGH_INVDIMM, + 0x4309AC30, 0x0D11, 0x11E4, 0x91, 0x91, 0x08, 0x00, 0x20, 0x0C, 0x9A, 0x66} +DEFINE_GUID!{GUID_DEVINTERFACE_COMPORT, + 0x86E0D1E0, 0x8089, 0x11D0, 0x9C, 0xE4, 0x08, 0x00, 0x3E, 0x30, 0x1F, 0x73} +DEFINE_GUID!{GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR, + 0x4D36E978, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18} +//146 +DEFINE_DEVPROPKEY!{DEVPKEY_Storage_Portable, + 0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 2} +DEFINE_DEVPROPKEY!{DEVPKEY_Storage_Removable_Media, + 0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 3} +DEFINE_DEVPROPKEY!{DEVPKEY_Storage_System_Critical, + 0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 4} +//177 +pub type DEVICE_TYPE = DWORD; +pub const FILE_DEVICE_BEEP: DEVICE_TYPE = 0x00000001; +pub const FILE_DEVICE_CD_ROM: DEVICE_TYPE = 0x00000002; +pub const FILE_DEVICE_CD_ROM_FILE_SYSTEM: DEVICE_TYPE = 0x00000003; +pub const FILE_DEVICE_CONTROLLER: DEVICE_TYPE = 0x00000004; +pub const FILE_DEVICE_DATALINK: DEVICE_TYPE = 0x00000005; +pub const FILE_DEVICE_DFS: DEVICE_TYPE = 0x00000006; +pub const FILE_DEVICE_DISK: DEVICE_TYPE = 0x00000007; +pub const FILE_DEVICE_DISK_FILE_SYSTEM: DEVICE_TYPE = 0x00000008; +pub const FILE_DEVICE_FILE_SYSTEM: DEVICE_TYPE = 0x00000009; +pub const FILE_DEVICE_INPORT_PORT: DEVICE_TYPE = 0x0000000a; +pub const FILE_DEVICE_KEYBOARD: DEVICE_TYPE = 0x0000000b; +pub const FILE_DEVICE_MAILSLOT: DEVICE_TYPE = 0x0000000c; +pub const FILE_DEVICE_MIDI_IN: DEVICE_TYPE = 0x0000000d; +pub const FILE_DEVICE_MIDI_OUT: DEVICE_TYPE = 0x0000000e; +pub const FILE_DEVICE_MOUSE: DEVICE_TYPE = 0x0000000f; +pub const FILE_DEVICE_MULTI_UNC_PROVIDER: DEVICE_TYPE = 0x00000010; +pub const FILE_DEVICE_NAMED_PIPE: DEVICE_TYPE = 0x00000011; +pub const FILE_DEVICE_NETWORK: DEVICE_TYPE = 0x00000012; +pub const FILE_DEVICE_NETWORK_BROWSER: DEVICE_TYPE = 0x00000013; +pub const FILE_DEVICE_NETWORK_FILE_SYSTEM: DEVICE_TYPE = 0x00000014; +pub const FILE_DEVICE_NULL: DEVICE_TYPE = 0x00000015; +pub const FILE_DEVICE_PARALLEL_PORT: DEVICE_TYPE = 0x00000016; +pub const FILE_DEVICE_PHYSICAL_NETCARD: DEVICE_TYPE = 0x00000017; +pub const FILE_DEVICE_PRINTER: DEVICE_TYPE = 0x00000018; +pub const FILE_DEVICE_SCANNER: DEVICE_TYPE = 0x00000019; +pub const FILE_DEVICE_SERIAL_MOUSE_PORT: DEVICE_TYPE = 0x0000001a; +pub const FILE_DEVICE_SERIAL_PORT: DEVICE_TYPE = 0x0000001b; +pub const FILE_DEVICE_SCREEN: DEVICE_TYPE = 0x0000001c; +pub const FILE_DEVICE_SOUND: DEVICE_TYPE = 0x0000001d; +pub const FILE_DEVICE_STREAMS: DEVICE_TYPE = 0x0000001e; +pub const FILE_DEVICE_TAPE: DEVICE_TYPE = 0x0000001f; +pub const FILE_DEVICE_TAPE_FILE_SYSTEM: DEVICE_TYPE = 0x00000020; +pub const FILE_DEVICE_TRANSPORT: DEVICE_TYPE = 0x00000021; +pub const FILE_DEVICE_UNKNOWN: DEVICE_TYPE = 0x00000022; +pub const FILE_DEVICE_VIDEO: DEVICE_TYPE = 0x00000023; +pub const FILE_DEVICE_VIRTUAL_DISK: DEVICE_TYPE = 0x00000024; +pub const FILE_DEVICE_WAVE_IN: DEVICE_TYPE = 0x00000025; +pub const FILE_DEVICE_WAVE_OUT: DEVICE_TYPE = 0x00000026; +pub const FILE_DEVICE_8042_PORT: DEVICE_TYPE = 0x00000027; +pub const FILE_DEVICE_NETWORK_REDIRECTOR: DEVICE_TYPE = 0x00000028; +pub const FILE_DEVICE_BATTERY: DEVICE_TYPE = 0x00000029; +pub const FILE_DEVICE_BUS_EXTENDER: DEVICE_TYPE = 0x0000002a; +pub const FILE_DEVICE_MODEM: DEVICE_TYPE = 0x0000002b; +pub const FILE_DEVICE_VDM: DEVICE_TYPE = 0x0000002c; +pub const FILE_DEVICE_MASS_STORAGE: DEVICE_TYPE = 0x0000002d; +pub const FILE_DEVICE_SMB: DEVICE_TYPE = 0x0000002e; +pub const FILE_DEVICE_KS: DEVICE_TYPE = 0x0000002f; +pub const FILE_DEVICE_CHANGER: DEVICE_TYPE = 0x00000030; +pub const FILE_DEVICE_SMARTCARD: DEVICE_TYPE = 0x00000031; +pub const FILE_DEVICE_ACPI: DEVICE_TYPE = 0x00000032; +pub const FILE_DEVICE_DVD: DEVICE_TYPE = 0x00000033; +pub const FILE_DEVICE_FULLSCREEN_VIDEO: DEVICE_TYPE = 0x00000034; +pub const FILE_DEVICE_DFS_FILE_SYSTEM: DEVICE_TYPE = 0x00000035; +pub const FILE_DEVICE_DFS_VOLUME: DEVICE_TYPE = 0x00000036; +pub const FILE_DEVICE_SERENUM: DEVICE_TYPE = 0x00000037; +pub const FILE_DEVICE_TERMSRV: DEVICE_TYPE = 0x00000038; +pub const FILE_DEVICE_KSEC: DEVICE_TYPE = 0x00000039; +pub const FILE_DEVICE_FIPS: DEVICE_TYPE = 0x0000003A; +pub const FILE_DEVICE_INFINIBAND: DEVICE_TYPE = 0x0000003B; +pub const FILE_DEVICE_VMBUS: DEVICE_TYPE = 0x0000003E; +pub const FILE_DEVICE_CRYPT_PROVIDER: DEVICE_TYPE = 0x0000003F; +pub const FILE_DEVICE_WPD: DEVICE_TYPE = 0x00000040; +pub const FILE_DEVICE_BLUETOOTH: DEVICE_TYPE = 0x00000041; +pub const FILE_DEVICE_MT_COMPOSITE: DEVICE_TYPE = 0x00000042; +pub const FILE_DEVICE_MT_TRANSPORT: DEVICE_TYPE = 0x00000043; +pub const FILE_DEVICE_BIOMETRIC: DEVICE_TYPE = 0x00000044; +pub const FILE_DEVICE_PMI: DEVICE_TYPE = 0x00000045; +pub const FILE_DEVICE_EHSTOR: DEVICE_TYPE = 0x00000046; +pub const FILE_DEVICE_DEVAPI: DEVICE_TYPE = 0x00000047; +pub const FILE_DEVICE_GPIO: DEVICE_TYPE = 0x00000048; +pub const FILE_DEVICE_USBEX: DEVICE_TYPE = 0x00000049; +pub const FILE_DEVICE_CONSOLE: DEVICE_TYPE = 0x00000050; +pub const FILE_DEVICE_NFP: DEVICE_TYPE = 0x00000051; +pub const FILE_DEVICE_SYSENV: DEVICE_TYPE = 0x00000052; +pub const FILE_DEVICE_VIRTUAL_BLOCK: DEVICE_TYPE = 0x00000053; +pub const FILE_DEVICE_POINT_OF_SERVICE: DEVICE_TYPE = 0x00000054; +pub const FILE_DEVICE_STORAGE_REPLICATION: DEVICE_TYPE = 0x00000055; +pub const FILE_DEVICE_TRUST_ENV: DEVICE_TYPE = 0x00000056; +pub const FILE_DEVICE_UCM: DEVICE_TYPE = 0x00000057; +pub const FILE_DEVICE_UCMTCPCI: DEVICE_TYPE = 0x00000058; +#[inline] +pub fn CTL_CODE( + DeviceType: DWORD, + Function: DWORD, + Method: DWORD, + Access: DWORD, +) -> DWORD { + (DeviceType << 16) | (Access << 14) | (Function << 2) | Method +} +//288 +pub const METHOD_BUFFERED: DWORD = 0; +pub const METHOD_IN_DIRECT: DWORD = 1; +pub const METHOD_OUT_DIRECT: DWORD = 2; +pub const METHOD_NEITHER: DWORD = 3; +//317 +pub const FILE_ANY_ACCESS: DWORD = 0; +pub const FILE_SPECIAL_ACCESS: DWORD = FILE_ANY_ACCESS; +pub const FILE_READ_ACCESS: DWORD = 0x0001; +pub const FILE_WRITE_ACCESS: DWORD = 0x0002; +//347 +pub const IOCTL_STORAGE_BASE: DWORD = FILE_DEVICE_MASS_STORAGE; +pub const IOCTL_STORAGE_CHECK_VERIFY: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0200, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_CHECK_VERIFY2: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0200, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_MEDIA_REMOVAL: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0201, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_EJECT_MEDIA: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0202, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_LOAD_MEDIA: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0203, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_LOAD_MEDIA2: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0203, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_RESERVE: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const IOCTL_STORAGE_RELEASE: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const IOCTL_STORAGE_FIND_NEW_DEVICES: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0206, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_EJECTION_CONTROL: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0250, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_MCN_CONTROL: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0251, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_GET_MEDIA_TYPES: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0300, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_GET_MEDIA_TYPES_EX: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0301, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0304, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_GET_HOTPLUG_INFO: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0305, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_SET_HOTPLUG_INFO: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0306, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_RESET_BUS: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const IOCTL_STORAGE_RESET_DEVICE: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0401, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_BREAK_RESERVATION: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0405, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_PERSISTENT_RESERVE_IN: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0406, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_PERSISTENT_RESERVE_OUT: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0407, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_GET_DEVICE_NUMBER: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0420, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_PREDICT_FAILURE: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0440, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_FAILURE_PREDICTION_CONFIG: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0441, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_READ_CAPACITY: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0450, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_GET_DEVICE_TELEMETRY: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0470, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_DEVICE_TELEMETRY_NOTIFY: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0471, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_DEVICE_TELEMETRY_QUERY_CAPS: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, + 0x0472, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_GET_DEVICE_TELEMETRY_RAW: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0473, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_QUERY_PROPERTY: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0500, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0501, + METHOD_BUFFERED, FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_GET_LB_PROVISIONING_MAP_RESOURCES: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, + 0x0502, METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_GET_BC_PROPERTIES: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0600, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_STORAGE_ALLOCATE_BC_STREAM: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0601, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_FREE_BC_STREAM: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0602, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_CHECK_PRIORITY_HINT_SUPPORT: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, + 0x0620, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_START_DATA_INTEGRITY_CHECK: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0621, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_STOP_DATA_INTEGRITY_CHECK: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0622, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const OBSOLETE_IOCTL_STORAGE_RESET_BUS: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0400, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const OBSOLETE_IOCTL_STORAGE_RESET_DEVICE: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0401, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_STORAGE_ENABLE_IDLE_POWER: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0720, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_GET_IDLE_POWERUP_REASON: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0721, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_POWER_ACTIVE: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0722, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_POWER_IDLE: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0723, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_STORAGE_EVENT_NOTIFICATION: DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0724, + METHOD_BUFFERED, FILE_ANY_ACCESS); +//565 +STRUCT!{struct STORAGE_DEVICE_NUMBER { + DeviceType: DEVICE_TYPE, + DeviceNumber: DWORD, + PartitionNumber: DWORD, +}} +pub type PSTORAGE_DEVICE_NUMBER = *mut STORAGE_DEVICE_NUMBER; +STRUCT!{struct STORAGE_DEVICE_NUMBERS { + NumberOfDevices: DWORD, + Devices: [STORAGE_DEVICE_NUMBER; ANYSIZE_ARRAY], +}} +pub type PSTORAGE_DEVICE_NUMBERS = *mut STORAGE_DEVICE_NUMBERS; +//1040 +ENUM!{enum STORAGE_QUERY_TYPE { + PropertyStandardQuery = 0, + PropertyExistsQuery, + PropertyMaskQuery, + PropertyQueryMaxDefined, +}} +pub type PSTORAGE_QUERY_TYPE = *mut STORAGE_QUERY_TYPE; +ENUM!{enum STORAGE_PROPERTY_ID { + StorageDeviceProperty = 0, + StorageAdapterProperty, + StorageDeviceIdProperty, + StorageDeviceUniqueIdProperty, + StorageDeviceWriteCacheProperty, + StorageMiniportProperty, + StorageAccessAlignmentProperty, + StorageDeviceSeekPenaltyProperty, + StorageDeviceTrimProperty, + StorageDeviceWriteAggregationProperty, + StorageDeviceDeviceTelemetryProperty, + StorageDeviceLBProvisioningProperty, + StorageDevicePowerProperty, + StorageDeviceCopyOffloadProperty, + StorageDeviceResiliencyProperty, + StorageDeviceMediumProductType, + StorageAdapterCryptoProperty, + StorageDeviceIoCapabilityProperty = 48, + StorageAdapterProtocolSpecificProperty, + StorageDeviceProtocolSpecificProperty, + StorageAdapterTemperatureProperty, + StorageDeviceTemperatureProperty, + StorageAdapterPhysicalTopologyProperty, + StorageDevicePhysicalTopologyProperty, + StorageDeviceAttributesProperty, + StorageDeviceManagementStatus, + StorageAdapterSerialNumberProperty, + StorageDeviceLocationProperty, + StorageDeviceNumaProperty, + StorageDeviceZonedDeviceProperty, + StorageDeviceUnsafeShutdownCount, +}} +pub type PSTORAGE_PROPERTY_ID = *mut STORAGE_PROPERTY_ID; +STRUCT!{struct STORAGE_PROPERTY_QUERY { + PropertyId: STORAGE_PROPERTY_ID, + QueryType: STORAGE_QUERY_TYPE, + AdditionalParameters: [BYTE; 1], +}} +pub type PSTORAGE_PROPERTY_QUERY = *mut STORAGE_PROPERTY_QUERY; +//1574 +STRUCT!{struct DEVICE_TRIM_DESCRIPTOR { + Version: DWORD, + Size: DWORD, + TrimEnabled: BOOLEAN, +}} +pub type PDEVICE_TRIM_DESCRIPTOR = *mut DEVICE_TRIM_DESCRIPTOR; +//7540 +pub const IOCTL_DISK_BASE: DWORD = FILE_DEVICE_DISK; +pub const IOCTL_DISK_GET_DRIVE_GEOMETRY: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0000, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_DISK_GET_PARTITION_INFO: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0001, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_DISK_SET_PARTITION_INFO: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0002, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_GET_DRIVE_LAYOUT: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0003, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_DISK_SET_DRIVE_LAYOUT: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0004, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_VERIFY: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_DISK_FORMAT_TRACKS: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, + FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_REASSIGN_BLOCKS: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, + FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_PERFORMANCE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_DISK_IS_WRITABLE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_DISK_LOGGING: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_DISK_FORMAT_TRACKS_EX: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000b, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_HISTOGRAM_STRUCTURE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000c, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_DISK_HISTOGRAM_DATA: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_DISK_HISTOGRAM_RESET: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_DISK_REQUEST_STRUCTURE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000f, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_DISK_REQUEST_DATA: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_DISK_PERFORMANCE_OFF: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0018, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_DISK_CONTROLLER_NUMBER: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0011, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const SMART_GET_VERSION: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const SMART_SEND_DRIVE_COMMAND: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, + FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const SMART_RCV_DRIVE_DATA: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, + FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_GET_PARTITION_INFO_EX: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0012, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_DISK_SET_PARTITION_INFO_EX: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0013, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_GET_DRIVE_LAYOUT_EX: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0014, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_DISK_SET_DRIVE_LAYOUT_EX: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0015, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_CREATE_DISK: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0016, METHOD_BUFFERED, + FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_GET_LENGTH_INFO: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const IOCTL_DISK_GET_DRIVE_GEOMETRY_EX: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0028, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_DISK_REASSIGN_BLOCKS_EX: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0029, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_UPDATE_DRIVE_SIZE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0032, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_GROW_PARTITION: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0034, METHOD_BUFFERED, + FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_GET_CACHE_INFORMATION: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0035, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_DISK_SET_CACHE_INFORMATION: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0036, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_GET_WRITE_CACHE_STATE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0037, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const OBSOLETE_DISK_GET_WRITE_CACHE_STATE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0037, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_DISK_DELETE_DRIVE_LAYOUT: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0040, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_UPDATE_PROPERTIES: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0050, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_DISK_FORMAT_DRIVE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x00f3, METHOD_BUFFERED, + FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_SENSE_DEVICE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x00f8, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_DISK_CHECK_VERIFY: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const IOCTL_DISK_MEDIA_REMOVAL: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const IOCTL_DISK_EJECT_MEDIA: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const IOCTL_DISK_LOAD_MEDIA: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const IOCTL_DISK_RESERVE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const IOCTL_DISK_RELEASE: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const IOCTL_DISK_FIND_NEW_DEVICES: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0206, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_DISK_GET_MEDIA_TYPES: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_DISK_GET_DISK_ATTRIBUTES: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x003c, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_DISK_SET_DISK_ATTRIBUTES: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x003d, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_DISK_RESET_SNAPSHOT_INFO: DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0084, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +//7810 +ENUM!{enum MEDIA_TYPE { + Unknown, + F5_1Pt2_512, + F3_1Pt44_512, + F3_2Pt88_512, + F3_20Pt8_512, + F3_720_512, + F5_360_512, + F5_320_512, + F5_320_1024, + F5_180_512, + F5_160_512, + RemovableMedia, + FixedMedia, + F3_120M_512, + F3_640_512, + F5_640_512, + F5_720_512, + F3_1Pt2_512, + F3_1Pt23_1024, + F5_1Pt23_1024, + F3_128Mb_512, + F3_230Mb_512, + F8_256_128, + F3_200Mb_512, + F3_240M_512, + F3_32M_512, +}} +pub type PMEDIA_TYPE = *mut MEDIA_TYPE; +//7884 +STRUCT!{struct DISK_GEOMETRY { + Cylinders: LARGE_INTEGER, + MediaType: MEDIA_TYPE, + TracksPerCylinder: DWORD, + SectorsPerTrack: DWORD, + BytesPerSector: DWORD, +}} +pub type PDISK_GEOMETRY = *mut DISK_GEOMETRY; +DEFINE_GUID!{WMI_DISK_GEOMETRY_GUID, + 0x25007f51, 0x57c2, 0x11d1, 0xa5, 0x28, 0x00, 0xa0, 0xc9, 0x06, 0x29, 0x10} +STRUCT!{struct PARTITION_INFORMATION { + StartingOffset: LARGE_INTEGER, + PartitionLength: LARGE_INTEGER, + HiddenSectors: DWORD, + PartitionNumber: DWORD, + PartitionType: BYTE, + BootIndicator: BOOLEAN, + RecognizedPartition: BOOLEAN, + RewritePartition: BOOLEAN, +}} +pub type PPARTITION_INFORMATION = *mut PARTITION_INFORMATION; +STRUCT!{struct SET_PARTITION_INFORMATION { + PartitionType: BYTE, +}} +pub type PSET_PARTITION_INFORMATION = *mut SET_PARTITION_INFORMATION; +STRUCT!{struct DRIVE_LAYOUT_INFORMATION { + PartitionCount: DWORD, + Signature: DWORD, + PartitionEntry: [PARTITION_INFORMATION; 1], +}} +pub type PDRIVE_LAYOUT_INFORMATION = *mut DRIVE_LAYOUT_INFORMATION; +STRUCT!{struct VERIFY_INFORMATION { + StartingOffset: LARGE_INTEGER, + Length: DWORD, +}} +pub type PVERIFY_INFORMATION = *mut VERIFY_INFORMATION; +STRUCT!{struct REASSIGN_BLOCKS { + Reserved: WORD, + Count: WORD, + BlockNumber: [DWORD; 1], +}} +pub type PREASSIGN_BLOCKS = *mut REASSIGN_BLOCKS; +STRUCT!{#[repr(packed)] struct REASSIGN_BLOCKS_EX { + Reserved: WORD, + Count: WORD, + BlockNumber: [LARGE_INTEGER; 1], +}} +pub type PREASSIGN_BLOCKS_EX = *mut REASSIGN_BLOCKS_EX; +ENUM!{enum PARTITION_STYLE { + PARTITION_STYLE_MBR, + PARTITION_STYLE_GPT, + PARTITION_STYLE_RAW, +}} +STRUCT!{struct PARTITION_INFORMATION_GPT { + PartitionType: GUID, + PartitionId: GUID, + Attributes: DWORD64, + Name: [WCHAR; 36], +}} +pub type PPARTITION_INFORMATION_GPT = *mut PARTITION_INFORMATION_GPT; +//8059 +STRUCT!{struct PARTITION_INFORMATION_MBR { + PartitionType: BYTE, + BootIndicator: BOOLEAN, + RecognizedPartition: BOOLEAN, + HiddenSectors: DWORD, + PartitionId: GUID, +}} +pub type PPARTITION_INFORMATION_MBR = *mut PARTITION_INFORMATION_MBR; +pub type SET_PARTITION_INFORMATION_MBR = SET_PARTITION_INFORMATION; +pub type SET_PARTITION_INFORMATION_GPT = PARTITION_INFORMATION_GPT; +STRUCT!{struct SET_PARTITION_INFORMATION_EX { + PartitionStyle: PARTITION_STYLE, + u: SET_PARTITION_INFORMATION_EX_u, +}} +UNION!{union SET_PARTITION_INFORMATION_EX_u { + [u64; 14], + Mbr Mbr_mut: SET_PARTITION_INFORMATION_MBR, + Gpt Gpt_mut: SET_PARTITION_INFORMATION_GPT, +}} +STRUCT!{struct CREATE_DISK_GPT { + DiskId: GUID, + MaxPartitionCount: DWORD, +}} +pub type PCREATE_DISK_GPT = *mut CREATE_DISK_GPT; +STRUCT!{struct CREATE_DISK_MBR { + Signature: DWORD, +}} +pub type PCREATE_DISK_MBR = *mut CREATE_DISK_MBR; +STRUCT!{struct CREATE_DISK { + PartitionStyle: PARTITION_STYLE, + u: CREATE_DISK_u, +}} +pub type PCREATE_DISK = *mut CREATE_DISK; +UNION!{union CREATE_DISK_u { + [u32; 5], + Mbr Mbr_mut: CREATE_DISK_MBR, + Gpt Gpt_mut: CREATE_DISK_GPT, +}} +STRUCT!{struct GET_LENGTH_INFORMATION { + Length: LARGE_INTEGER, +}} +pub type PGET_LENGTH_INFORMATION = *mut GET_LENGTH_INFORMATION; +STRUCT!{struct PARTITION_INFORMATION_EX { + PartitionStyle: PARTITION_STYLE, + StartingOffset: LARGE_INTEGER, + PartitionLength: LARGE_INTEGER, + PartitionNumber: DWORD, + RewritePartition: BOOLEAN, + u: PARTITION_INFORMATION_EX_u, +}} +pub type PPARTITION_INFORMATION_EX = *mut PARTITION_INFORMATION_EX; +UNION!{union PARTITION_INFORMATION_EX_u { + [u64; 14], + Mbr Mbr_mut: PARTITION_INFORMATION_MBR, + Gpt Gpt_mut: PARTITION_INFORMATION_GPT, +}} +STRUCT!{struct DRIVE_LAYOUT_INFORMATION_GPT { + DiskId: GUID, + StartingUsableOffset: LARGE_INTEGER, + UsableLength: LARGE_INTEGER, + MaxPartitionCount: DWORD, +}} +pub type PDRIVE_LAYOUT_INFORMATION_GPT = *mut DRIVE_LAYOUT_INFORMATION_GPT; +STRUCT!{struct DRIVE_LAYOUT_INFORMATION_MBR { + Signature: DWORD, + CheckSum: DWORD, +}} +pub type PDRIVE_LAYOUT_INFORMATION_MBR = *mut DRIVE_LAYOUT_INFORMATION_MBR; +STRUCT!{struct DRIVE_LAYOUT_INFORMATION_EX { + PartitionStyle: DWORD, + PartitionCount: DWORD, + u: DRIVE_LAYOUT_INFORMATION_EX_u, + PartitionEntry: [PARTITION_INFORMATION_EX; 1], +}} +pub type PDRIVE_LAYOUT_INFORMATION_EX = *mut DRIVE_LAYOUT_INFORMATION_EX; +UNION! {union DRIVE_LAYOUT_INFORMATION_EX_u { + [u64; 5], + Mbr Mbr_mut: DRIVE_LAYOUT_INFORMATION_MBR, + Gpt Gpt_mut: DRIVE_LAYOUT_INFORMATION_GPT, +}} +//8350 +STRUCT!{struct DISK_GEOMETRY_EX { + Geometry: DISK_GEOMETRY, + DiskSize: LARGE_INTEGER, + Data: [BYTE; 1], +}} +//8933 +pub const IOCTL_CHANGER_BASE: DWORD = FILE_DEVICE_CHANGER; +pub const IOCTL_CHANGER_GET_PARAMETERS: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0000, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_CHANGER_GET_STATUS: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0001, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_CHANGER_GET_PRODUCT_DATA: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0002, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_CHANGER_SET_ACCESS: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0004, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_CHANGER_GET_ELEMENT_STATUS: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0005, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0006, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_CHANGER_SET_POSITION: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0007, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_CHANGER_EXCHANGE_MEDIUM: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0008, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_CHANGER_MOVE_MEDIUM: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0009, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_CHANGER_REINITIALIZE_TRANSPORT: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x000A, + METHOD_BUFFERED, FILE_READ_ACCESS); +pub const IOCTL_CHANGER_QUERY_VOLUME_TAGS: DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x000B, + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_SERIAL_LSRMST_INSERT: DWORD = CTL_CODE!(FILE_DEVICE_SERIAL_PORT, 31, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SERENUM_EXPOSE_HARDWARE: DWORD = CTL_CODE!(FILE_DEVICE_SERENUM, 128, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SERENUM_REMOVE_HARDWARE: DWORD = CTL_CODE!(FILE_DEVICE_SERENUM, 129, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SERENUM_PORT_DESC: DWORD = CTL_CODE!(FILE_DEVICE_SERENUM, 130, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SERENUM_GET_PORT_NAME: DWORD = CTL_CODE!(FILE_DEVICE_SERENUM, 131, + METHOD_BUFFERED, FILE_ANY_ACCESS); +//9717 +pub const FSCTL_REQUEST_OPLOCK_LEVEL_1: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 0, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_REQUEST_OPLOCK_LEVEL_2: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 1, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_REQUEST_BATCH_OPLOCK: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 2, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_OPLOCK_BREAK_ACKNOWLEDGE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 3, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_OPBATCH_ACK_CLOSE_PENDING: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 4, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_OPLOCK_BREAK_NOTIFY: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 5, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_LOCK_VOLUME: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_UNLOCK_VOLUME: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_DISMOUNT_VOLUME: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_IS_VOLUME_MOUNTED: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 10, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_IS_PATHNAME_VALID: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 11, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_MARK_VOLUME_DIRTY: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 12, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_RETRIEVAL_POINTERS: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 14, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_GET_COMPRESSION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_SET_COMPRESSION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, + FILE_READ_DATA | FILE_WRITE_DATA); +pub const FSCTL_SET_BOOTLOADER_ACCESSED: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 19, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_MARK_AS_SYSTEM_HIVE: DWORD = FSCTL_SET_BOOTLOADER_ACCESSED; +pub const FSCTL_OPLOCK_BREAK_ACK_NO_2: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 20, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_INVALIDATE_VOLUMES: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 21, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_FAT_BPB: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_REQUEST_FILTER_OPLOCK: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 23, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_FILESYSTEM_GET_STATISTICS: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 24, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_NTFS_VOLUME_DATA: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 25, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_NTFS_FILE_RECORD: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 26, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_VOLUME_BITMAP: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER, + FILE_ANY_ACCESS); +pub const FSCTL_GET_RETRIEVAL_POINTERS: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 28, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_MOVE_FILE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, + FILE_SPECIAL_ACCESS); +pub const FSCTL_IS_VOLUME_DIRTY: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_ALLOW_EXTENDED_DASD_IO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 32, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_FIND_FILES_BY_SID: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, + FILE_ANY_ACCESS); +pub const FSCTL_SET_OBJECT_ID: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, + FILE_SPECIAL_ACCESS); +pub const FSCTL_GET_OBJECT_ID: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_DELETE_OBJECT_ID: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, + FILE_SPECIAL_ACCESS); +pub const FSCTL_SET_REPARSE_POINT: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 41, + METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_GET_REPARSE_POINT: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 42, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DELETE_REPARSE_POINT: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 43, + METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_ENUM_USN_DATA: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 44, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_SECURITY_ID_CHECK: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER, + FILE_READ_DATA); +pub const FSCTL_READ_USN_JOURNAL: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, + FILE_ANY_ACCESS); +pub const FSCTL_SET_OBJECT_ID_EXTENDED: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 47, + METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_CREATE_OR_GET_OBJECT_ID: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 48, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_SPARSE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, + FILE_SPECIAL_ACCESS); +pub const FSCTL_SET_ZERO_DATA: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, + FILE_WRITE_DATA); +pub const FSCTL_QUERY_ALLOCATED_RANGES: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 51, + METHOD_NEITHER, FILE_READ_DATA); +pub const FSCTL_ENABLE_UPGRADE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 52, METHOD_BUFFERED, + FILE_WRITE_DATA); +pub const FSCTL_SET_ENCRYPTION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER, + FILE_ANY_ACCESS); +pub const FSCTL_ENCRYPTION_FSCTL_IO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 54, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_WRITE_RAW_ENCRYPTED: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 55, + METHOD_NEITHER, FILE_SPECIAL_ACCESS); +pub const FSCTL_READ_RAW_ENCRYPTED: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 56, + METHOD_NEITHER, FILE_SPECIAL_ACCESS); +pub const FSCTL_CREATE_USN_JOURNAL: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 57, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_READ_FILE_USN_DATA: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 58, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_WRITE_USN_CLOSE_RECORD: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 59, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_EXTEND_VOLUME: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_QUERY_USN_JOURNAL: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 61, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DELETE_USN_JOURNAL: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 62, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_MARK_HANDLE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_SIS_COPYFILE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_SIS_LINK_FILES: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, + FILE_READ_DATA | FILE_WRITE_DATA); +pub const FSCTL_RECALL_FILE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, + FILE_ANY_ACCESS); +pub const FSCTL_READ_FROM_PLEX: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, + FILE_READ_DATA); +pub const FSCTL_FILE_PREFETCH: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, + FILE_SPECIAL_ACCESS); +pub const FSCTL_MAKE_MEDIA_COMPATIBLE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 76, + METHOD_BUFFERED, FILE_WRITE_DATA); +pub const FSCTL_SET_DEFECT_MANAGEMENT: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 77, + METHOD_BUFFERED, FILE_WRITE_DATA); +pub const FSCTL_QUERY_SPARING_INFO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 78, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_ON_DISK_VOLUME_INFO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 79, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_VOLUME_COMPRESSION_STATE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 80, + METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_TXFS_MODIFY_RM: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 81, METHOD_BUFFERED, + FILE_WRITE_DATA); +pub const FSCTL_TXFS_QUERY_RM_INFORMATION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 82, + METHOD_BUFFERED, FILE_READ_DATA); +pub const FSCTL_TXFS_ROLLFORWARD_REDO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 84, + METHOD_BUFFERED, FILE_WRITE_DATA); +pub const FSCTL_TXFS_ROLLFORWARD_UNDO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 85, + METHOD_BUFFERED, FILE_WRITE_DATA); +pub const FSCTL_TXFS_START_RM: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 86, METHOD_BUFFERED, + FILE_WRITE_DATA); +pub const FSCTL_TXFS_SHUTDOWN_RM: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 87, METHOD_BUFFERED, + FILE_WRITE_DATA); +pub const FSCTL_TXFS_READ_BACKUP_INFORMATION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 88, + METHOD_BUFFERED, FILE_READ_DATA); +pub const FSCTL_TXFS_WRITE_BACKUP_INFORMATION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 89, + METHOD_BUFFERED, FILE_WRITE_DATA); +pub const FSCTL_TXFS_CREATE_SECONDARY_RM: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 90, + METHOD_BUFFERED, FILE_WRITE_DATA); +pub const FSCTL_TXFS_GET_METADATA_INFO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 91, + METHOD_BUFFERED, FILE_READ_DATA); +pub const FSCTL_TXFS_GET_TRANSACTED_VERSION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 92, + METHOD_BUFFERED, FILE_READ_DATA); +pub const FSCTL_TXFS_SAVEPOINT_INFORMATION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 94, + METHOD_BUFFERED, FILE_WRITE_DATA); +pub const FSCTL_TXFS_CREATE_MINIVERSION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 95, + METHOD_BUFFERED, FILE_WRITE_DATA); +pub const FSCTL_TXFS_TRANSACTION_ACTIVE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 99, + METHOD_BUFFERED, FILE_READ_DATA); +pub const FSCTL_SET_ZERO_ON_DEALLOCATION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 101, + METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_SET_REPAIR: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 102, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_GET_REPAIR: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 103, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_WAIT_FOR_REPAIR: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 104, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_INITIATE_REPAIR: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 106, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_CSC_INTERNAL: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 107, METHOD_NEITHER, + FILE_ANY_ACCESS); +pub const FSCTL_SHRINK_VOLUME: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 108, METHOD_BUFFERED, + FILE_SPECIAL_ACCESS); +pub const FSCTL_SET_SHORT_NAME_BEHAVIOR: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 109, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DFSR_SET_GHOST_HANDLE_STATE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 110, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_TXFS_LIST_TRANSACTION_LOCKED_FILES: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, + 120, METHOD_BUFFERED, FILE_READ_DATA); +pub const FSCTL_TXFS_LIST_TRANSACTIONS: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 121, + METHOD_BUFFERED, FILE_READ_DATA); +pub const FSCTL_QUERY_PAGEFILE_ENCRYPTION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 122, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_RESET_VOLUME_ALLOCATION_HINTS: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 123, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_DEPENDENT_VOLUME: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 124, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SD_GLOBAL_CHANGE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 125, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_TXFS_READ_BACKUP_INFORMATION2: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 126, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_LOOKUP_STREAM_FROM_CLUSTER: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 127, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_TXFS_WRITE_BACKUP_INFORMATION2: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 128, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_FILE_TYPE_NOTIFICATION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 129, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_FILE_LEVEL_TRIM: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 130, METHOD_BUFFERED, + FILE_WRITE_DATA); +pub const FSCTL_GET_BOOT_AREA_INFO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 140, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_RETRIEVAL_POINTER_BASE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 141, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_PERSISTENT_VOLUME_STATE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 142, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_PERSISTENT_VOLUME_STATE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 143, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_REQUEST_OPLOCK: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 144, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_CSV_TUNNEL_REQUEST: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 145, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_IS_CSV_FILE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 146, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_QUERY_FILE_SYSTEM_RECOGNITION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 147, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_GET_VOLUME_PATH_NAME: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 148, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_GET_VOLUME_NAME_FOR_VOLUME_MOUNT_POINT: DWORD = CTL_CODE!( + FILE_DEVICE_FILE_SYSTEM, 149, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_GET_VOLUME_PATH_NAMES_FOR_VOLUME_NAME: DWORD = CTL_CODE!( + FILE_DEVICE_FILE_SYSTEM, 150, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_IS_FILE_ON_CSV_VOLUME: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 151, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CORRUPTION_HANDLING: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 152, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_OFFLOAD_READ: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 153, METHOD_BUFFERED, + FILE_READ_ACCESS); +pub const FSCTL_OFFLOAD_WRITE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 154, METHOD_BUFFERED, + FILE_WRITE_ACCESS); +pub const FSCTL_CSV_INTERNAL: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 155, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_SET_PURGE_FAILURE_MODE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 156, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_FILE_LAYOUT: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 157, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_IS_VOLUME_OWNED_BYCSVFS: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 158, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_GET_INTEGRITY_INFORMATION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 159, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_INTEGRITY_INFORMATION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 160, + METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA); +pub const FSCTL_QUERY_FILE_REGIONS: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 161, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DEDUP_FILE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 165, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_DEDUP_QUERY_FILE_HASHES: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 166, + METHOD_NEITHER, FILE_READ_DATA); +pub const FSCTL_DEDUP_QUERY_RANGE_STATE: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 167, + METHOD_NEITHER, FILE_READ_DATA); +pub const FSCTL_DEDUP_QUERY_REPARSE_INFO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 168, + METHOD_NEITHER, FILE_ANY_ACCESS); +pub const FSCTL_RKF_INTERNAL: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 171, METHOD_NEITHER, + FILE_ANY_ACCESS); +pub const FSCTL_SCRUB_DATA: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 172, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_REPAIR_COPIES: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 173, METHOD_BUFFERED, + FILE_READ_DATA | FILE_WRITE_DATA); +pub const FSCTL_DISABLE_LOCAL_BUFFERING: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 174, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_MGMT_LOCK: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 175, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_CSV_QUERY_DOWN_LEVEL_FILE_SYSTEM_CHARACTERISTICS: DWORD = CTL_CODE!( + FILE_DEVICE_FILE_SYSTEM, 176, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_ADVANCE_FILE_ID: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 177, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_CSV_SYNC_TUNNEL_REQUEST: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 178, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_QUERY_VETO_FILE_DIRECT_IO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 179, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_WRITE_USN_REASON: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 180, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_CONTROL: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 181, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const FSCTL_GET_REFS_VOLUME_DATA: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 182, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_CSV_H_BREAKING_SYNC_TUNNEL_REQUEST: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, + 185, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_STORAGE_CLASSES: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 187, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_REGION_INFO: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 188, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_USN_TRACK_MODIFIED_RANGES: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 189, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, + 192, METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SVHDX_SYNC_TUNNEL_REQUEST: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 193, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SVHDX_SET_INITIATOR_INFORMATION: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 194, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_SET_EXTERNAL_BACKING: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 195, + METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_GET_EXTERNAL_BACKING: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 196, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_DELETE_EXTERNAL_BACKING: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 197, + METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +pub const FSCTL_ENUM_EXTERNAL_BACKING: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 198, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const FSCTL_ENUM_OVERLAY: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 199, METHOD_NEITHER, + FILE_ANY_ACCESS); +pub const FSCTL_ADD_OVERLAY: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 204, METHOD_BUFFERED, + FILE_WRITE_DATA); +pub const FSCTL_REMOVE_OVERLAY: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 205, METHOD_BUFFERED, + FILE_WRITE_DATA); +pub const FSCTL_UPDATE_OVERLAY: DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 206, METHOD_BUFFERED, + FILE_WRITE_DATA); +// FILE_DEVICE_AVIO is defined nowhere +//pub const IOCTL_AVIO_ALLOCATE_STREAM: DWORD = CTL_CODE!(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, +// FILE_SPECIAL_ACCESS); +//pub const IOCTL_AVIO_FREE_STREAM: DWORD = CTL_CODE!(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, +// FILE_SPECIAL_ACCESS); +//pub const IOCTL_AVIO_MODIFY_STREAM: DWORD = CTL_CODE!(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, +// FILE_SPECIAL_ACCESS); +STRUCT!{struct PATHNAME_BUFFER { + PathNameLength: DWORD, + Name: [WCHAR; 1], +}} +pub type PPATHNAME_BUFFER = *mut PATHNAME_BUFFER; +STRUCT!{struct FSCTL_QUERY_FAT_BPB_BUFFER { + First0x24BytesOfBootSector: [BYTE; 0x24], +}} +pub type PFSCTL_QUERY_FAT_BPB_BUFFER = *mut FSCTL_QUERY_FAT_BPB_BUFFER; +STRUCT!{struct NTFS_VOLUME_DATA_BUFFER { + VolumeSerialNumber: LARGE_INTEGER, + NumberSectors: LARGE_INTEGER, + TotalClusters: LARGE_INTEGER, + FreeClusters: LARGE_INTEGER, + TotalReserved: LARGE_INTEGER, + BytesPerSector: DWORD, + BytesPerCluster: DWORD, + BytesPerFileRecordSegment: DWORD, + ClustersPerFileRecordSegment: DWORD, + MftValidDataLength: LARGE_INTEGER, + MftStartLcn: LARGE_INTEGER, + Mft2StartLcn: LARGE_INTEGER, + MftZoneStart: LARGE_INTEGER, + MftZoneEnd: LARGE_INTEGER, +}} +pub type PNTFS_VOLUME_DATA_BUFFER = *mut NTFS_VOLUME_DATA_BUFFER; +STRUCT!{struct NTFS_EXTENDED_VOLUME_DATA { + ByteCount: DWORD, + MajorVersion: WORD, + MinorVersion: WORD, + BytesPerPhysicalSector: DWORD, + LfsMajorVersion: WORD, + LfsMinorVersion: WORD, + MaxDeviceTrimExtentCount: DWORD, + MaxDeviceTrimByteCount: DWORD, + MaxVolumeTrimExtentCount: DWORD, + MaxVolumeTrimByteCount: DWORD, +}} +pub type PNTFS_EXTENDED_VOLUME_DATA = *mut NTFS_EXTENDED_VOLUME_DATA; +STRUCT!{struct REFS_VOLUME_DATA_BUFFER { + ByteCount: DWORD, + MajorVersion: DWORD, + MinorVersion: DWORD, + BytesPerPhysicalSector: DWORD, + VolumeSerialNumber: LARGE_INTEGER, + NumberSectors: LARGE_INTEGER, + TotalClusters: LARGE_INTEGER, + FreeClusters: LARGE_INTEGER, + TotalReserved: LARGE_INTEGER, + BytesPerSector: DWORD, + BytesPerCluster: DWORD, + MaximumSizeOfResidentFile: LARGE_INTEGER, + Reserved: [LARGE_INTEGER; 10], +}} +pub type PREFS_VOLUME_DATA_BUFFER = *mut REFS_VOLUME_DATA_BUFFER; +STRUCT!{struct STARTING_LCN_INPUT_BUFFER { + StartingLcn: LARGE_INTEGER, +}} +pub type PSTARTING_LCN_INPUT_BUFFER = *mut STARTING_LCN_INPUT_BUFFER; +STRUCT!{struct VOLUME_BITMAP_BUFFER { + StartingLcn: LARGE_INTEGER, + BitmapSize: LARGE_INTEGER, + Buffer: [BYTE; 1], +}} +pub type PVOLUME_BITMAP_BUFFER = *mut VOLUME_BITMAP_BUFFER; +STRUCT!{struct STARTING_VCN_INPUT_BUFFER { + StartingVcn: LARGE_INTEGER, +}} +pub type PSTARTING_VCN_INPUT_BUFFER = *mut STARTING_VCN_INPUT_BUFFER; +STRUCT!{struct RETRIEVAL_POINTERS_BUFFER_INTERNAL { + NextVcn: LARGE_INTEGER, + Lcn: LARGE_INTEGER, +}} +STRUCT!{struct RETRIEVAL_POINTERS_BUFFER { + ExtentCount: DWORD, + StartingVcn: LARGE_INTEGER, + Extents: [RETRIEVAL_POINTERS_BUFFER_INTERNAL; 1], +}} +pub type PRETRIEVAL_POINTERS_BUFFER = *mut RETRIEVAL_POINTERS_BUFFER; +STRUCT!{struct NTFS_FILE_RECORD_INPUT_BUFFER { + FileReferenceNumber: LARGE_INTEGER, +}} +pub type PNTFS_FILE_RECORD_INPUT_BUFFER = *mut NTFS_FILE_RECORD_INPUT_BUFFER; +STRUCT!{struct NTFS_FILE_RECORD_OUTPUT_BUFFER { + FileReferenceNumber: LARGE_INTEGER, + FileRecordLength: DWORD, + FileRecordBuffer: [BYTE; 1], +}} +pub type PNTFS_FILE_RECORD_OUTPUT_BUFFER = *mut NTFS_FILE_RECORD_OUTPUT_BUFFER; +STRUCT!{struct MOVE_FILE_DATA { + FileHandle: HANDLE, + StartingVcn: LARGE_INTEGER, + StartingLcn: LARGE_INTEGER, + ClusterCount: DWORD, +}} +pub type PMOVE_FILE_DATA = *mut MOVE_FILE_DATA; +STRUCT!{struct MOVE_FILE_RECORD_DATA { + FileHandle: HANDLE, + SourceFileRecord: LARGE_INTEGER, + TargetFileRecord: LARGE_INTEGER, +}} +pub type PMOVE_FILE_RECORD_DATA = *mut MOVE_FILE_RECORD_DATA; +//15468 +pub const IOCTL_VOLUME_BASE: DWORD = 0x00000056; +pub const IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS: DWORD = CTL_CODE!(IOCTL_VOLUME_BASE, 0, + METHOD_BUFFERED, FILE_ANY_ACCESS); +STRUCT!{struct DISK_EXTENT { + DiskNumber: DWORD, + StartingOffset: LARGE_INTEGER, + ExtentLength: LARGE_INTEGER, +}} +pub type PDISK_EXTENT = *mut DISK_EXTENT; +STRUCT!{struct VOLUME_DISK_EXTENTS { + NumberOfDiskExtents: DWORD, + Extents: [DISK_EXTENT; ANYSIZE_ARRAY], +}} +pub type PVOLUME_DISK_EXTENTS = *mut VOLUME_DISK_EXTENTS; +pub const IOCTL_VOLUME_ONLINE: DWORD = CTL_CODE!(IOCTL_VOLUME_BASE, 2, METHOD_BUFFERED, + FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_VOLUME_OFFLINE: DWORD = CTL_CODE!(IOCTL_VOLUME_BASE, 3, METHOD_BUFFERED, + FILE_READ_ACCESS | FILE_WRITE_ACCESS); +pub const IOCTL_VOLUME_IS_CLUSTERED: DWORD = CTL_CODE!(IOCTL_VOLUME_BASE, 12, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_VOLUME_GET_GPT_ATTRIBUTES: DWORD = CTL_CODE!(IOCTL_VOLUME_BASE, 14, + METHOD_BUFFERED, FILE_ANY_ACCESS); +STRUCT!{struct DISK_PERFORMANCE { + BytesRead: LARGE_INTEGER, + BytesWritten: LARGE_INTEGER, + ReadTime: LARGE_INTEGER, + WriteTime: LARGE_INTEGER, + IdleTime: LARGE_INTEGER, + ReadCount: DWORD, + WriteCount: DWORD, + QueueDepth: DWORD, + SplitCount: DWORD, + QueryTime: LARGE_INTEGER, + StorageDeviceNumber: DWORD, + StorageManagerName: [WCHAR; 8], +}} +pub type PDISK_PERFORMANCE = *mut DISK_PERFORMANCE; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winnetwk.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winnetwk.rs new file mode 100644 index 0000000..5680da1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winnetwk.rs @@ -0,0 +1,446 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Standard WINNET Header File for WIN32 +use shared::basetsd::ULONG_PTR; +use shared::minwindef::{BOOL, DWORD, LPDWORD, LPHANDLE, LPVOID, WORD}; +use shared::windef::HWND; +use shared::winerror::{ + ERROR_ACCESS_DENIED, ERROR_ALREADY_ASSIGNED, ERROR_ALREADY_INITIALIZED, ERROR_BAD_DEVICE, + ERROR_BAD_DEV_TYPE, ERROR_BAD_NET_NAME, ERROR_BAD_PROFILE, ERROR_BAD_PROVIDER, + ERROR_BAD_USERNAME, ERROR_BUSY, ERROR_CANCELLED, ERROR_CANNOT_OPEN_PROFILE, + ERROR_CONNECTED_OTHER_PASSWORD, ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT, + ERROR_CONNECTION_UNAVAIL, ERROR_DEVICE_ALREADY_REMEMBERED, ERROR_DEVICE_IN_USE, + ERROR_EXTENDED_ERROR, ERROR_GEN_FAILURE, ERROR_INVALID_ADDRESS, ERROR_INVALID_HANDLE, + ERROR_INVALID_LEVEL, ERROR_INVALID_PARAMETER, ERROR_INVALID_PASSWORD, ERROR_MORE_DATA, + ERROR_NOT_AUTHENTICATED, ERROR_NOT_CONNECTED, ERROR_NOT_CONTAINER, ERROR_NOT_ENOUGH_MEMORY, + ERROR_NOT_LOGGED_ON, ERROR_NOT_SUPPORTED, ERROR_NO_LOGON_SERVERS, ERROR_NO_MORE_DEVICES, + ERROR_NO_MORE_ITEMS, ERROR_NO_NETWORK, ERROR_NO_NET_OR_BAD_PATH, ERROR_OPEN_FILES, ERROR_RETRY, + ERROR_UNEXP_NET_ERR, NO_ERROR +}; +use um::winnt::{HANDLE, LPCSTR, LPCWSTR, LPSTR, LPWSTR}; +pub const RESOURCE_CONNECTED: DWORD = 0x00000001; +pub const RESOURCE_GLOBALNET: DWORD = 0x00000002; +pub const RESOURCE_REMEMBERED: DWORD = 0x00000003; +pub const RESOURCE_RECENT: DWORD = 0x00000004; +pub const RESOURCE_CONTEXT: DWORD = 0x00000005; +pub const RESOURCETYPE_ANY: DWORD = 0x00000000; +pub const RESOURCETYPE_DISK: DWORD = 0x00000001; +pub const RESOURCETYPE_PRINT: DWORD = 0x00000002; +pub const RESOURCETYPE_RESERVED: DWORD = 0x00000008; +pub const RESOURCETYPE_UNKNOWN: DWORD = 0xFFFFFFFF; +pub const RESOURCEUSAGE_CONNECTABLE: DWORD = 0x00000001; +pub const RESOURCEUSAGE_CONTAINER: DWORD = 0x00000002; +pub const RESOURCEUSAGE_NOLOCALDEVICE: DWORD = 0x00000004; +pub const RESOURCEUSAGE_SIBLING: DWORD = 0x00000008; +pub const RESOURCEUSAGE_ATTACHED: DWORD = 0x00000010; +pub const RESOURCEUSAGE_ALL: DWORD = RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER + | RESOURCEUSAGE_ATTACHED; +pub const RESOURCEUSAGE_RESERVED: DWORD = 0x80000000; +pub const RESOURCEDISPLAYTYPE_GENERIC: DWORD = 0x00000000; +pub const RESOURCEDISPLAYTYPE_DOMAIN: DWORD = 0x00000001; +pub const RESOURCEDISPLAYTYPE_SERVER: DWORD = 0x00000002; +pub const RESOURCEDISPLAYTYPE_SHARE: DWORD = 0x00000003; +pub const RESOURCEDISPLAYTYPE_FILE: DWORD = 0x00000004; +pub const RESOURCEDISPLAYTYPE_GROUP: DWORD = 0x00000005; +pub const RESOURCEDISPLAYTYPE_NETWORK: DWORD = 0x00000006; +pub const RESOURCEDISPLAYTYPE_ROOT: DWORD = 0x00000007; +pub const RESOURCEDISPLAYTYPE_SHAREADMIN: DWORD = 0x00000008; +pub const RESOURCEDISPLAYTYPE_DIRECTORY: DWORD = 0x00000009; +pub const RESOURCEDISPLAYTYPE_TREE: DWORD = 0x0000000A; +pub const RESOURCEDISPLAYTYPE_NDSCONTAINER: DWORD = 0x0000000B; +STRUCT!{struct NETRESOURCEA { + dwScope: DWORD, + dwType: DWORD, + dwDisplayType: DWORD, + dwUsage: DWORD, + lpLocalName: LPSTR, + lpRemoteName: LPSTR, + lpComment: LPSTR, + lpProvider: LPSTR, +}} +pub type LPNETRESOURCEA = *mut NETRESOURCEA; +STRUCT!{struct NETRESOURCEW { + dwScope: DWORD, + dwType: DWORD, + dwDisplayType: DWORD, + dwUsage: DWORD, + lpLocalName: LPWSTR, + lpRemoteName: LPWSTR, + lpComment: LPWSTR, + lpProvider: LPWSTR, +}} +pub type LPNETRESOURCEW = *mut NETRESOURCEW; +pub const NETPROPERTY_PERSISTENT: DWORD = 1; +pub const CONNECT_UPDATE_PROFILE: DWORD = 0x00000001; +pub const CONNECT_UPDATE_RECENT: DWORD = 0x00000002; +pub const CONNECT_TEMPORARY: DWORD = 0x00000004; +pub const CONNECT_INTERACTIVE: DWORD = 0x00000008; +pub const CONNECT_PROMPT: DWORD = 0x00000010; +pub const CONNECT_NEED_DRIVE: DWORD = 0x00000020; +pub const CONNECT_REFCOUNT: DWORD = 0x00000040; +pub const CONNECT_REDIRECT: DWORD = 0x00000080; +pub const CONNECT_LOCALDRIVE: DWORD = 0x00000100; +pub const CONNECT_CURRENT_MEDIA: DWORD = 0x00000200; +pub const CONNECT_DEFERRED: DWORD = 0x00000400; +pub const CONNECT_RESERVED: DWORD = 0xFF000000; +pub const CONNECT_COMMANDLINE: DWORD = 0x00000800; +pub const CONNECT_CMD_SAVECRED: DWORD = 0x00001000; +pub const CONNECT_CRED_RESET: DWORD = 0x00002000; +extern "system" { + pub fn WNetAddConnection2A( + lpNetResource: LPNETRESOURCEA, + lpPassword: LPCSTR, + lpUsername: LPCSTR, + dwFlags: DWORD, + ) -> DWORD; + pub fn WNetAddConnection2W( + lpNetResource: LPNETRESOURCEW, + lpPassword: LPCWSTR, + lpUsername: LPCWSTR, + dwFlags: DWORD, + ) -> DWORD; + pub fn WNetAddConnection3A( + hwndOwner: HWND, + lpNetResource: LPNETRESOURCEA, + lpPassword: LPCSTR, + lpUsername: LPCSTR, + dwFlags: DWORD, + ) -> DWORD; + pub fn WNetAddConnection3W( + hwndOwner: HWND, + lpNetResource: LPNETRESOURCEW, + lpPassword: LPCWSTR, + lpUsername: LPCWSTR, + dwFlags: DWORD, + ) -> DWORD; + pub fn WNetCancelConnectionA( + lpName: LPCSTR, + fForce: BOOL, + ) -> DWORD; + pub fn WNetCancelConnectionW( + lpName: LPCWSTR, + fForce: BOOL, + ) -> DWORD; + pub fn WNetCancelConnection2A( + lpName: LPCSTR, + dwFlags: DWORD, + fForce: BOOL, + ) -> DWORD; + pub fn WNetCancelConnection2W( + lpName: LPCWSTR, + dwFlags: DWORD, + fForce: BOOL, + ) -> DWORD; + pub fn WNetGetConnectionA( + lpLocalName: LPCSTR, + lpRemoteName: LPSTR, + lpnLength: LPDWORD, + ) -> DWORD; + pub fn WNetGetConnectionW( + lpLocalName: LPCWSTR, + lpRemoteName: LPWSTR, + lpnLength: LPDWORD, + ) -> DWORD; + pub fn WNetUseConnectionA( + hwndOwner: HWND, + lpNetResource: LPNETRESOURCEA, + lpPassword: LPCSTR, + lpUserId: LPCSTR, + dwFlags: DWORD, + lpAccessName: LPSTR, + lpBufferSize: LPDWORD, + lpResult: LPDWORD, + ) -> DWORD; + pub fn WNetUseConnectionW( + hwndOwner: HWND, + lpNetResource: LPNETRESOURCEW, + lpPassword: LPCWSTR, + lpUserId: LPCWSTR, + dwFlags: DWORD, + lpAccessName: LPWSTR, + lpBufferSize: LPDWORD, + lpResult: LPDWORD, + ) -> DWORD; + pub fn WNetConnectionDialog( + hwnd: HWND, + dwType: DWORD, + ) -> DWORD; + pub fn WNetDisconnectDialog( + hwnd: HWND, + dwType: DWORD, + ) -> DWORD; +} +STRUCT!{struct CONNECTDLGSTRUCTA { + cbStructure: DWORD, + hwndOwner: HWND, + lpConnRes: LPNETRESOURCEA, + dwFlags: DWORD, + dwDevNum: DWORD, +}} +pub type LPCONNECTDLGSTRUCTA = *mut CONNECTDLGSTRUCTA; +STRUCT!{struct CONNECTDLGSTRUCTW { + cbStructure: DWORD, + hwndOwner: HWND, + lpConnRes: LPNETRESOURCEW, + dwFlags: DWORD, + dwDevNum: DWORD, +}} +pub type LPCONNECTDLGSTRUCTW = *mut CONNECTDLGSTRUCTW; +pub const CONNDLG_RO_PATH: DWORD = 0x00000001; +pub const CONNDLG_CONN_POINT: DWORD = 0x00000002; +pub const CONNDLG_USE_MRU: DWORD = 0x00000004; +pub const CONNDLG_HIDE_BOX: DWORD = 0x00000008; +pub const CONNDLG_PERSIST: DWORD = 0x00000010; +pub const CONNDLG_NOT_PERSIST: DWORD = 0x00000020; +extern "system" { + pub fn WNetConnectionDialog1A( + lpConnDlgStruct: LPCONNECTDLGSTRUCTA, + ) -> DWORD; + pub fn WNetConnectionDialog1W( + lpConnDlgStruct: LPCONNECTDLGSTRUCTW, + ) -> DWORD; +} +STRUCT!{struct DISCDLGSTRUCTA { + cbStructure: DWORD, + hwndOwner: HWND, + lpLocalName: LPSTR, + lpRemoteName: LPSTR, + dwFlags: DWORD, +}} +pub type LPDISCDLGSTRUCTA = *mut DISCDLGSTRUCTA; +STRUCT!{struct DISCDLGSTRUCTW { + cbStructure: DWORD, + hwndOwner: HWND, + lpLocalName: LPWSTR, + lpRemoteName: LPWSTR, + dwFlags: DWORD, +}} +pub type LPDISCDLGSTRUCTW = *mut DISCDLGSTRUCTW; +pub const DISC_UPDATE_PROFILE: DWORD = 0x00000001; +pub const DISC_NO_FORCE: DWORD = 0x00000040; +extern "system" { + pub fn WNetDisconnectDialog1A( + lpConnDlgStruct: LPDISCDLGSTRUCTA, + ) -> DWORD; + pub fn WNetDisconnectDialog1W( + lpConnDlgStruct: LPDISCDLGSTRUCTW, + ) -> DWORD; + pub fn WNetOpenEnumA( + dwScope: DWORD, + dwType: DWORD, + dwUsage: DWORD, + lpNetResource: LPNETRESOURCEA, + lphEnum: LPHANDLE, + ) -> DWORD; + pub fn WNetOpenEnumW( + dwScope: DWORD, + dwType: DWORD, + dwUsage: DWORD, + lpNetResource: LPNETRESOURCEW, + lphEnum: LPHANDLE, + ) -> DWORD; + pub fn WNetEnumResourceA( + hEnum: HANDLE, + lpcCount: LPDWORD, + lpBuffer: LPVOID, + lpBufferSize: LPDWORD, + ) -> DWORD; + pub fn WNetEnumResourceW( + hEnum: HANDLE, + lpcCount: LPDWORD, + lpBuffer: LPVOID, + lpBufferSize: LPDWORD, + ) -> DWORD; + pub fn WNetCloseEnum( + hEnum: HANDLE, + ) -> DWORD; + pub fn WNetGetResourceParentA( + lpNetResource: LPNETRESOURCEA, + lpBuffer: LPVOID, + lpcbBuffer: LPDWORD, + ) -> DWORD; + pub fn WNetGetResourceParentW( + lpNetResource: LPNETRESOURCEW, + lpBuffer: LPVOID, + lpcbBuffer: LPDWORD, + ) -> DWORD; + pub fn WNetGetResourceInformationA( + lpNetResource: LPNETRESOURCEA, + lpBuffer: LPVOID, + lpcbBuffer: LPDWORD, + lplpSystem: *mut LPSTR, + ) -> DWORD; + pub fn WNetGetResourceInformationW( + lpNetResource: LPNETRESOURCEW, + lpBuffer: LPVOID, + lpcbBuffer: LPDWORD, + lplpSystem: *mut LPWSTR, + ) -> DWORD; +} +pub const UNIVERSAL_NAME_INFO_LEVEL: DWORD = 0x00000001; +pub const REMOTE_NAME_INFO_LEVEL: DWORD = 0x00000002; +STRUCT!{struct UNIVERSAL_NAME_INFOA { + lpUniversalName: LPSTR, +}} +pub type LPUNIVERSAL_NAME_INFOA = *mut UNIVERSAL_NAME_INFOA; +STRUCT!{struct UNIVERSAL_NAME_INFOW { + lpUniversalName: LPWSTR, +}} +pub type LPUNIVERSAL_NAME_INFOW = *mut UNIVERSAL_NAME_INFOW; +STRUCT!{struct REMOTE_NAME_INFOA { + lpUniversalName: LPSTR, + lpConnectionName: LPSTR, + lpRemainingPath: LPSTR, +}} +pub type LPREMOTE_NAME_INFOA = *mut REMOTE_NAME_INFOA; +STRUCT!{struct REMOTE_NAME_INFOW { + lpUniversalName: LPWSTR, + lpConnectionName: LPWSTR, + lpRemainingPath: LPWSTR, +}} +pub type LPREMOTE_NAME_INFOW = *mut REMOTE_NAME_INFOW; +extern "system" { + pub fn WNetGetUniversalNameA( + lpLocalPath: LPCSTR, + dwInfoLevel: DWORD, + lpBuffer: LPVOID, + lpBufferSize: LPDWORD, + ) -> DWORD; + pub fn WNetGetUniversalNameW( + lpLocalPath: LPCWSTR, + dwInfoLevel: DWORD, + lpBuffer: LPVOID, + lpBufferSize: LPDWORD, + ) -> DWORD; + pub fn WNetGetUserA( + lpName: LPCSTR, + lpUserName: LPSTR, + lpnLength: LPDWORD, + ) -> DWORD; + pub fn WNetGetUserW( + lpName: LPCWSTR, + lpUserName: LPWSTR, + lpnLength: LPDWORD, + ) -> DWORD; +} +pub const WNFMT_MULTILINE: DWORD = 0x01; +pub const WNFMT_ABBREVIATED: DWORD = 0x02; +pub const WNFMT_INENUM: DWORD = 0x10; +pub const WNFMT_CONNECTION: DWORD = 0x20; +extern "system" { + pub fn WNetGetProviderNameA( + dwNetType: DWORD, + lpProviderName: LPSTR, + lpBufferSize: LPDWORD, + ) -> DWORD; + pub fn WNetGetProviderNameW( + dwNetType: DWORD, + lpProviderName: LPWSTR, + lpBufferSize: LPDWORD, + ) -> DWORD; +} +STRUCT!{struct NETINFOSTRUCT { + cbStructure: DWORD, + dwProviderVersion: DWORD, + dwStatus: DWORD, + dwCharacteristics: DWORD, + dwHandle: ULONG_PTR, + wNetType: WORD, + dwPrinters: DWORD, + dwDrives: DWORD, +}} +pub type LPNETINFOSTRUCT = *mut NETINFOSTRUCT; +pub const NETINFO_DLL16: DWORD = 0x00000001; +pub const NETINFO_DISKRED: DWORD = 0x00000004; +pub const NETINFO_PRINTERRED: DWORD = 0x00000008; +extern "system" { + pub fn WNetGetNetworkInformationA( + lpProvider: LPCSTR, + lpNetInfoStruct: LPNETINFOSTRUCT, + ) -> DWORD; + pub fn WNetGetNetworkInformationW( + lpProvider: LPCWSTR, + lpNetInfoStruct: LPNETINFOSTRUCT, + ) -> DWORD; + pub fn WNetGetLastErrorA( + lpError: LPDWORD, + lpErrorBuf: LPSTR, + nErrorBufSize: DWORD, + lpNameBuf: LPSTR, + nNameBufSize: DWORD, + ) -> DWORD; + pub fn WNetGetLastErrorW( + lpError: LPDWORD, + lpErrorBuf: LPWSTR, + nErrorBufSize: DWORD, + lpNameBuf: LPWSTR, + nNameBufSize: DWORD, + ) -> DWORD; +} +pub const WN_SUCCESS: DWORD = NO_ERROR; +pub const WN_NO_ERROR: DWORD = NO_ERROR; +pub const WN_NOT_SUPPORTED: DWORD = ERROR_NOT_SUPPORTED; +pub const WN_CANCEL: DWORD = ERROR_CANCELLED; +pub const WN_RETRY: DWORD = ERROR_RETRY; +pub const WN_NET_ERROR: DWORD = ERROR_UNEXP_NET_ERR; +pub const WN_MORE_DATA: DWORD = ERROR_MORE_DATA; +pub const WN_BAD_POINTER: DWORD = ERROR_INVALID_ADDRESS; +pub const WN_BAD_VALUE: DWORD = ERROR_INVALID_PARAMETER; +pub const WN_BAD_USER: DWORD = ERROR_BAD_USERNAME; +pub const WN_BAD_PASSWORD: DWORD = ERROR_INVALID_PASSWORD; +pub const WN_ACCESS_DENIED: DWORD = ERROR_ACCESS_DENIED; +pub const WN_FUNCTION_BUSY: DWORD = ERROR_BUSY; +pub const WN_WINDOWS_ERROR: DWORD = ERROR_UNEXP_NET_ERR; +pub const WN_OUT_OF_MEMORY: DWORD = ERROR_NOT_ENOUGH_MEMORY; +pub const WN_NO_NETWORK: DWORD = ERROR_NO_NETWORK; +pub const WN_EXTENDED_ERROR: DWORD = ERROR_EXTENDED_ERROR; +pub const WN_BAD_LEVEL: DWORD = ERROR_INVALID_LEVEL; +pub const WN_BAD_HANDLE: DWORD = ERROR_INVALID_HANDLE; +pub const WN_NOT_INITIALIZING: DWORD = ERROR_ALREADY_INITIALIZED; +pub const WN_NO_MORE_DEVICES: DWORD = ERROR_NO_MORE_DEVICES; +pub const WN_NOT_CONNECTED: DWORD = ERROR_NOT_CONNECTED; +pub const WN_OPEN_FILES: DWORD = ERROR_OPEN_FILES; +pub const WN_DEVICE_IN_USE: DWORD = ERROR_DEVICE_IN_USE; +pub const WN_BAD_NETNAME: DWORD = ERROR_BAD_NET_NAME; +pub const WN_BAD_LOCALNAME: DWORD = ERROR_BAD_DEVICE; +pub const WN_ALREADY_CONNECTED: DWORD = ERROR_ALREADY_ASSIGNED; +pub const WN_DEVICE_ERROR: DWORD = ERROR_GEN_FAILURE; +pub const WN_CONNECTION_CLOSED: DWORD = ERROR_CONNECTION_UNAVAIL; +pub const WN_NO_NET_OR_BAD_PATH: DWORD = ERROR_NO_NET_OR_BAD_PATH; +pub const WN_BAD_PROVIDER: DWORD = ERROR_BAD_PROVIDER; +pub const WN_CANNOT_OPEN_PROFILE: DWORD = ERROR_CANNOT_OPEN_PROFILE; +pub const WN_BAD_PROFILE: DWORD = ERROR_BAD_PROFILE; +pub const WN_BAD_DEV_TYPE: DWORD = ERROR_BAD_DEV_TYPE; +pub const WN_DEVICE_ALREADY_REMEMBERED: DWORD = ERROR_DEVICE_ALREADY_REMEMBERED; +pub const WN_CONNECTED_OTHER_PASSWORD: DWORD = ERROR_CONNECTED_OTHER_PASSWORD; +pub const WN_CONNECTED_OTHER_PASSWORD_DEFAULT: DWORD = ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT; +pub const WN_NO_MORE_ENTRIES: DWORD = ERROR_NO_MORE_ITEMS; +pub const WN_NOT_CONTAINER: DWORD = ERROR_NOT_CONTAINER; +pub const WN_NOT_AUTHENTICATED: DWORD = ERROR_NOT_AUTHENTICATED; +pub const WN_NOT_LOGGED_ON: DWORD = ERROR_NOT_LOGGED_ON; +pub const WN_NOT_VALIDATED: DWORD = ERROR_NO_LOGON_SERVERS; +STRUCT!{struct NETCONNECTINFOSTRUCT { + cbStructure: DWORD, + dwFlags: DWORD, + dwSpeed: DWORD, + dwDelay: DWORD, + dwOptDataSize: DWORD, +}} +pub type LPNETCONNECTINFOSTRUCT = *mut NETCONNECTINFOSTRUCT; +pub const WNCON_FORNETCARD: DWORD = 0x00000001; +pub const WNCON_NOTROUTED: DWORD = 0x00000002; +pub const WNCON_SLOWLINK: DWORD = 0x00000004; +pub const WNCON_DYNAMIC: DWORD = 0x00000008; +extern "system" { + pub fn MultinetGetConnectionPerformanceA( + lpNetResource: LPNETRESOURCEA, + lpNetConnectInfoStruct: LPNETCONNECTINFOSTRUCT, + ) -> DWORD; + pub fn MultinetGetConnectionPerformanceW( + lpNetResource: LPNETRESOURCEW, + lpNetConnectInfoStruct: LPNETCONNECTINFOSTRUCT, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winnls.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winnls.rs new file mode 100644 index 0000000..fd68a23 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winnls.rs @@ -0,0 +1,817 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Procedure declarations, constant definitions, and macros for the NLS component. +use ctypes::c_int; +use shared::basetsd::LONG_PTR; +use shared::guiddef::GUID; +use shared::minwindef::{ + BOOL, BYTE, DWORD, INT, LPARAM, LPDWORD, LPINT, LPVOID, LPWORD, MAX_PATH, PDWORD, PULONG, + UINT, +}; +use um::minwinbase::SYSTEMTIME; +use um::winnt::{ + CHAR, LANGID, LCID, LONG, LPCSTR, LPCWCH, LPCWSTR, LPSTR, LPWSTR, PCNZCH, PCNZWCH, PCWSTR, + PCZZWSTR, PULONGLONG, PWSTR, PZZWSTR, ULONGLONG, WCHAR, +}; +pub const MAX_LEADBYTES: usize = 12; +pub const MAX_DEFAULTCHAR: usize = 2; +pub const MB_PRECOMPOSED: DWORD = 0x00000001; +pub const MB_COMPOSITE: DWORD = 0x00000002; +pub const MB_USEGLYPHCHARS: DWORD = 0x00000004; +pub const MB_ERR_INVALID_CHARS: DWORD = 0x00000008; +pub const WC_COMPOSITECHECK: DWORD = 0x00000200; +pub const WC_DISCARDNS: DWORD = 0x00000010; +pub const WC_SEPCHARS: DWORD = 0x00000020; +pub const WC_DEFAULTCHAR: DWORD = 0x00000040; +pub const WC_ERR_INVALID_CHARS: DWORD = 0x00000080; +pub const WC_NO_BEST_FIT_CHARS: DWORD = 0x00000400; +pub const CP_ACP: DWORD = 0; +pub const CP_OEMCP: DWORD = 1; +pub const CP_MACCP: DWORD = 2; +pub const CP_THREAD_ACP: DWORD = 3; +pub const CP_SYMBOL: DWORD = 42; +pub const CP_UTF7: DWORD = 65000; +pub const CP_UTF8: DWORD = 65001; +pub type LGRPID = DWORD; +pub type LCTYPE = DWORD; +pub type CALTYPE = DWORD; +pub type CALID = DWORD; +STRUCT!{struct CPINFO { + MaxCharSize: UINT, + DefaultChar: [BYTE; MAX_DEFAULTCHAR], + LeadByte: [BYTE; MAX_LEADBYTES], +}} +pub type LPCPINFO = *mut CPINFO; +STRUCT!{struct CPINFOEXA { + MaxCharSize: UINT, + DefaultChar: [BYTE; MAX_DEFAULTCHAR], + LeadByte: [BYTE; MAX_LEADBYTES], + UnicodeDefaultChar: WCHAR, + CodePage: UINT, + CodePageName: [CHAR; MAX_PATH], +}} +pub type LPCPINFOEXA = *mut CPINFOEXA; +STRUCT!{struct CPINFOEXW { + MaxCharSize: UINT, + DefaultChar: [BYTE; MAX_DEFAULTCHAR], + LeadByte: [BYTE; MAX_LEADBYTES], + UnicodeDefaultChar: WCHAR, + CodePage: UINT, + CodePageName: [WCHAR; MAX_PATH], +}} +pub type LPCPINFOEXW = *mut CPINFOEXW; +STRUCT!{struct NUMBERFMTA { + NumDigits: UINT, + LeadingZero: UINT, + Grouping: UINT, + lpDecimalSep: LPSTR, + lpThousandSep: LPSTR, + NegativeOrder: UINT, +}} +pub type LPNUMBERFMTA = *mut NUMBERFMTA; +STRUCT!{struct NUMBERFMTW { + NumDigits: UINT, + LeadingZero: UINT, + Grouping: UINT, + lpDecimalSep: LPWSTR, + lpThousandSep: LPWSTR, + NegativeOrder: UINT, +}} +pub type LPNUMBERFMTW = *mut NUMBERFMTW; +STRUCT!{struct CURRENCYFMTA { + NumDigits: UINT, + LeadingZero: UINT, + Grouping: UINT, + lpDecimalSep: LPSTR, + lpThousandSep: LPSTR, + NegativeOrder: UINT, + PositiveOrder: UINT, + lpCurrencySymbol: LPSTR, +}} +pub type LPCURRENCYFMTA = *mut CURRENCYFMTA; +STRUCT!{struct CURRENCYFMTW { + NumDigits: UINT, + LeadingZero: UINT, + Grouping: UINT, + lpDecimalSep: LPWSTR, + lpThousandSep: LPWSTR, + NegativeOrder: UINT, + PositiveOrder: UINT, + lpCurrencySymbol: LPWSTR, +}} +pub type LPCURRENCYFMTW = *mut CURRENCYFMTW; +pub type NLS_FUNCTION = DWORD; +STRUCT!{struct NLSVERSIONINFO { + dwNLSVersionInfoSize: DWORD, + dwNLSVersion: DWORD, + dwDefinedVersion: DWORD, + dwEffectiveId: DWORD, + guidCustomVersion: GUID, +}} +pub type LPNLSVERSIONINFO = *mut NLSVERSIONINFO; +STRUCT!{struct NLSVERSIONINFOEX { + dwNLSVersionInfoSize: DWORD, + dwNLSVersion: DWORD, + dwDefinedVersion: DWORD, + dwEffectiveId: DWORD, + guidCustomVersion: GUID, +}} +pub type LPNLSVERSIONINFOEX = *mut NLSVERSIONINFOEX; +pub type GEOID = LONG; +pub type GEOTYPE = DWORD; +pub type GEOCLASS = DWORD; +ENUM!{enum NORM_FORM { + NormalizationOther = 0, + NormalizationC = 0x1, + NormalizationD = 0x2, + NormalizationKC = 0x5, + NormalizationKD = 0x6, +}} +FN!{stdcall LANGUAGEGROUP_ENUMPROCA( + LGRPID, + LPSTR, + LPSTR, + DWORD, + LONG_PTR, +) -> BOOL} +FN!{stdcall LANGGROUPLOCALE_ENUMPROCA( + LGRPID, + LCID, + LPSTR, + LONG_PTR, +) -> BOOL} +FN!{stdcall UILANGUAGE_ENUMPROCA( + LPSTR, + LONG_PTR, +) -> BOOL} +FN!{stdcall CODEPAGE_ENUMPROCA( + LPSTR, +) -> BOOL} +FN!{stdcall DATEFMT_ENUMPROCA( + LPSTR, +) -> BOOL} +FN!{stdcall DATEFMT_ENUMPROCEXA( + LPSTR, + CALID, +) -> BOOL} +FN!{stdcall TIMEFMT_ENUMPROCA( + LPSTR, +) -> BOOL} +FN!{stdcall CALINFO_ENUMPROCA( + LPSTR, +) -> BOOL} +FN!{stdcall CALINFO_ENUMPROCEXA( + LPSTR, + CALID, +) -> BOOL} +FN!{stdcall LOCALE_ENUMPROCA( + LPSTR, +) -> BOOL} +FN!{stdcall LOCALE_ENUMPROCW( + LPWSTR, +) -> BOOL} +FN!{stdcall LANGUAGEGROUP_ENUMPROCW( + LGRPID, + LPWSTR, + LPWSTR, + DWORD, + LONG_PTR, +) -> BOOL} +FN!{stdcall LANGGROUPLOCALE_ENUMPROCW( + LGRPID, + LCID, + LPWSTR, + LONG_PTR, +) -> BOOL} +FN!{stdcall UILANGUAGE_ENUMPROCW( + LPWSTR, + LONG_PTR, +) -> BOOL} +FN!{stdcall CODEPAGE_ENUMPROCW( + LPWSTR, +) -> BOOL} +FN!{stdcall DATEFMT_ENUMPROCW( + LPWSTR, +) -> BOOL} +FN!{stdcall DATEFMT_ENUMPROCEXW( + LPWSTR, + CALID, +) -> BOOL} +FN!{stdcall TIMEFMT_ENUMPROCW( + LPWSTR, +) -> BOOL} +FN!{stdcall CALINFO_ENUMPROCW( + LPWSTR, +) -> BOOL} +FN!{stdcall CALINFO_ENUMPROCEXW( + LPWSTR, + CALID, +) -> BOOL} +FN!{stdcall GEO_ENUMPROC( + GEOID, +) -> BOOL} +STRUCT!{struct FILEMUIINFO { + dwSize: DWORD, + dwVersion: DWORD, + dwFileType: DWORD, + pChecksum: [BYTE; 16], + pServiceChecksum: [BYTE; 16], + dwLanguageNameOffset: DWORD, + dwTypeIDMainSize: DWORD, + dwTypeIDMainOffset: DWORD, + dwTypeNameMainOffset: DWORD, + dwTypeIDMUISize: DWORD, + dwTypeIDMUIOffset: DWORD, + dwTypeNameMUIOffset: DWORD, + abBuffer: [BYTE; 8], +}} +pub type PFILEMUIINFO = *mut FILEMUIINFO; +FN!{stdcall CALINFO_ENUMPROCEXEX( + LPWSTR, + CALID, + LPWSTR, + LPARAM, +) -> BOOL} +FN!{stdcall DATEFMT_ENUMPROCEXEX( + LPWSTR, + CALID, + LPARAM, +) -> BOOL} +FN!{stdcall TIMEFMT_ENUMPROCEX( + LPWSTR, + LPARAM, +) -> BOOL} +FN!{stdcall LOCALE_ENUMPROCEX( + LPWSTR, + DWORD, + LPARAM, +) -> BOOL} +extern "system" { + pub fn CompareStringA( + Locale: LCID, + dwCmpFlags: DWORD, + lpString1: PCNZCH, + cchCount1: c_int, + lpString2: PCNZCH, + cchCount2: c_int, + ) -> c_int; + pub fn CompareStringEx( + lpLocaleName: LPCWSTR, + dwCmpFlags: DWORD, + lpString1: LPCWCH, + cchCount1: c_int, + lpString2: LPCWCH, + cchCount2: c_int, + lpVersionInformation: LPNLSVERSIONINFO, + lpReserved: LPVOID, + lParam: LPARAM, + ) -> c_int; + pub fn CompareStringW( + Locale: LCID, + dwCmpFlags: DWORD, + lpString1: PCNZWCH, + cchCount1: c_int, + lpString2: PCNZWCH, + cchCount2: c_int, + ) -> c_int; + pub fn ConvertDefaultLocale(Locale: LCID) -> LCID; + pub fn EnumCalendarInfoA( + lpCalInfoEnumProc: CALINFO_ENUMPROCA, + Locale: LCID, + Calendar: CALID, + CalType: CALTYPE, + ) -> BOOL; + pub fn EnumCalendarInfoExA( + lpCalInfoEnumProcEx: CALINFO_ENUMPROCEXA, + Locale: LCID, + Calendar: CALID, + CalType: CALTYPE, + ) -> BOOL; + pub fn EnumCalendarInfoExEx( + pCalInfoEnumProcExEx: CALINFO_ENUMPROCEXEX, + lpLocaleName: LPCWSTR, + Calendar: CALID, + lpReserved: LPCWSTR, + CalType: CALTYPE, + lParam: LPARAM, + ) -> BOOL; + pub fn EnumCalendarInfoExW( + lpCalInfoEnumProcEx: CALINFO_ENUMPROCEXW, + Locale: LCID, + Calendar: CALID, + CalType: CALTYPE, + ) -> BOOL; + pub fn EnumCalendarInfoW( + lpCalInfoEnumProc: CALINFO_ENUMPROCW, + Locale: LCID, + Calendar: CALID, + CalType: CALTYPE, + ) -> BOOL; + pub fn EnumDateFormatsA( + lpDateFmtEnumProc: DATEFMT_ENUMPROCA, + Locale: LCID, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumDateFormatsExA( + lpDateFmtEnumProcEx: DATEFMT_ENUMPROCEXA, + Locale: LCID, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumDateFormatsExEx( + lpDateFmtEnumProcExEx: DATEFMT_ENUMPROCEXEX, + lpLocaleName: LPCWSTR, + dwFlags: DWORD, + lParam: LPARAM, + ) -> BOOL; + pub fn EnumDateFormatsExW( + lpDateFmtEnumProcEx: DATEFMT_ENUMPROCEXW, + Locale: LCID, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumDateFormatsW( + lpDateFmtEnumProc: DATEFMT_ENUMPROCW, + Locale: LCID, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumLanguageGroupLocalesA( + lpLangGroupLocaleEnumProc: LANGGROUPLOCALE_ENUMPROCA, + LanguageGroup: LGRPID, + dwFlags: DWORD, + lParam: LONG_PTR, + ) -> BOOL; + pub fn EnumLanguageGroupLocalesW( + lpLangGroupLocaleEnumProc: LANGGROUPLOCALE_ENUMPROCW, + LanguageGroup: LGRPID, + dwFlags: DWORD, + lParam: LONG_PTR, + ) -> BOOL; + pub fn EnumSystemCodePagesA( + lpCodePageEnumProc: CODEPAGE_ENUMPROCA, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumSystemCodePagesW( + lpCodePageEnumProc: CODEPAGE_ENUMPROCW, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumSystemGeoID( + GeoClass: GEOCLASS, + ParentGeoId: GEOID, + lpGeoEnumProc: GEO_ENUMPROC, + ) -> BOOL; + pub fn EnumSystemLanguageGroupsA( + lpLanguageGroupEnumProc: LANGUAGEGROUP_ENUMPROCA, + dwFlags: DWORD, + lParam: LONG_PTR, + ) -> BOOL; + pub fn EnumSystemLanguageGroupsW( + lpLanguageGroupEnumProc: LANGUAGEGROUP_ENUMPROCW, + dwFlags: DWORD, + lParam: LONG_PTR, + ) -> BOOL; + pub fn EnumSystemLocalesA( + lpLocaleEnumProc: LOCALE_ENUMPROCA, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumSystemLocalesEx( + lpLocaleEnumProcEx: LOCALE_ENUMPROCEX, + dwFlags: DWORD, + lParam: LPARAM, + lpReserved: LPVOID, + ) -> BOOL; + pub fn EnumSystemLocalesW( + lpLocaleEnumProc: LOCALE_ENUMPROCW, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumTimeFormatsA( + lpTimeFmtEnumProc: TIMEFMT_ENUMPROCA, + Locale: LCID, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumTimeFormatsEx( + lpTimeFmtEnumProcEx: TIMEFMT_ENUMPROCEX, + lpLocaleName: LPCWSTR, + dwFlags: DWORD, + lParam: LPARAM, + ) -> BOOL; + pub fn EnumTimeFormatsW( + lpTimeFmtEnumProc: TIMEFMT_ENUMPROCW, + Locale: LCID, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumUILanguagesA( + lpUILanguageEnumProc: UILANGUAGE_ENUMPROCA, + dwFlags: DWORD, + lParam: LONG_PTR, + ) -> BOOL; + pub fn EnumUILanguagesW( + lpUILanguageEnumProc: UILANGUAGE_ENUMPROCW, + dwFlags: DWORD, + lParam: LONG_PTR, + ) -> BOOL; + pub fn FindNLSString( + Locale: LCID, + dwFindNLSStringFlags: DWORD, + lpStringSource: LPCWSTR, + cchSource: c_int, + lpStringValue: LPCWSTR, + cchValue: c_int, + pcchFound: LPINT, + ) -> c_int; + pub fn FindNLSStringEx( + lpLocaleName: LPCWSTR, + dwFindNLSStringFlags: DWORD, + lpStringSource: LPCWSTR, + cchSource: c_int, + lpStringValue: LPCWSTR, + cchValue: c_int, + pcchFound: LPINT, + lpVersionInformation: LPNLSVERSIONINFO, + lpReserved: LPVOID, + sortHandle: LPARAM, + ) -> c_int; + pub fn FoldStringA( + dwMapFlags: DWORD, + lpSrcStr: LPCSTR, + cchSrc: c_int, + lpDestStr: LPSTR, + cchDest: c_int, + ) -> c_int; + pub fn GetACP() -> UINT; + pub fn GetCPInfo( + CodePage: UINT, + lpCPInfo: LPCPINFO, + ) -> BOOL; + pub fn GetCPInfoExA( + CodePage: UINT, + dwFlags: DWORD, + lpCPInfoEx: LPCPINFOEXA, + ) -> BOOL; + pub fn GetCPInfoExW( + CodePage: UINT, + dwFlags: DWORD, + lpCPInfoEx: LPCPINFOEXW, + ) -> BOOL; + pub fn GetCalendarInfoA( + Locale: LCID, + Calendar: CALID, + CalType: CALTYPE, + lpCalData: LPSTR, + cchData: c_int, + lpValue: LPDWORD, + ) -> c_int; + pub fn GetCalendarInfoEx( + lpLocaleName: LPCWSTR, + Calendar: CALID, + lpReserved: LPCWSTR, + CalType: CALTYPE, + lpCalData: LPWSTR, + cchData: c_int, + lpValue: LPDWORD, + ) -> c_int; + pub fn GetCalendarInfoW( + Locale: LCID, + Calendar: CALID, + CalType: CALTYPE, + lpCalData: LPWSTR, + cchData: c_int, + lpValue: LPDWORD, + ) -> c_int; + pub fn GetCurrencyFormatA( + Locale: LCID, + dwFlags: DWORD, + lpValue: LPCSTR, + lpFormat: *const CURRENCYFMTA, + lpCurrencyStr: LPSTR, + cchCurrency: c_int, + ) -> c_int; + pub fn GetCurrencyFormatEx( + lpLocaleName: LPCWSTR, + dwFlags: DWORD, + lpValue: LPCWSTR, + lpFormat: *const CURRENCYFMTW, + lpCurrencyStr: LPWSTR, + cchCurrency: c_int, + ) -> c_int; + pub fn GetCurrencyFormatW( + Locale: LCID, + dwFlags: DWORD, + lpValue: LPCWSTR, + lpFormat: *const CURRENCYFMTW, + lpCurrencyStr: LPWSTR, + cchCurrency: c_int, + ) -> c_int; + pub fn GetDurationFormat( + Locale: LCID, + dwFlags: DWORD, + lpDuration: *const SYSTEMTIME, + ullDuration: ULONGLONG, + lpFormat: LPCWSTR, + lpDurationStr: LPWSTR, + cchDuration: c_int, + ) -> c_int; + pub fn GetDurationFormatEx( + lpLocaleName: LPCWSTR, + dwFlags: DWORD, + lpDuration: *const SYSTEMTIME, + ullDuration: ULONGLONG, + lpFormat: LPCWSTR, + lpDurationStr: LPWSTR, + cchDuration: c_int, + ) -> c_int; + pub fn GetFileMUIInfo( + dwFlags: DWORD, + pcwszFilePath: PCWSTR, + pFileMUIInfo: PFILEMUIINFO, + pcbFileMUIInfo: *mut DWORD, + ) -> BOOL; + pub fn GetFileMUIPath( + dwFlags: DWORD, + pcwszFilePath: PCWSTR, + pwszLanguage: PWSTR, + pcchLanguage: PULONG, + pwszFileMUIPath: PWSTR, + pcchFileMUIPath: PULONG, + pululEnumerator: PULONGLONG, + ) -> BOOL; + pub fn GetGeoInfoA( + Location: GEOID, + GeoType: GEOTYPE, + lpGeoData: LPSTR, + cchData: c_int, + LangId: LANGID, + ) -> c_int; + pub fn GetGeoInfoW( + Location: GEOID, + GeoType: GEOTYPE, + lpGeoData: LPWSTR, + cchData: c_int, + LangId: LANGID, + ) -> c_int; + pub fn GetLocaleInfoA( + Locale: LCID, + LCType: LCTYPE, + lpLCData: LPSTR, + cchData: c_int, + ) -> c_int; + pub fn GetLocaleInfoEx( + lpLocaleName: LPCWSTR, + LCType: LCTYPE, + lpLCData: LPWSTR, + cchData: c_int, + ) -> c_int; + pub fn GetLocaleInfoW( + Locale: LCID, + LCType: LCTYPE, + lpLCData: LPWSTR, + cchData: c_int, + ) -> c_int; + pub fn GetNLSVersion( + Function: NLS_FUNCTION, + Locale: LCID, + lpVersionInformation: LPNLSVERSIONINFO, + ) -> BOOL; + pub fn GetNLSVersionEx( + function: NLS_FUNCTION, + lpLocaleName: LPCWSTR, + lpVersionInformation: LPNLSVERSIONINFOEX, + ) -> BOOL; + pub fn GetNumberFormatA( + Locale: LCID, + dwFlags: DWORD, + lpValue: LPCSTR, + lpFormat: *const NUMBERFMTA, + lpNumberStr: LPSTR, + cchNumber: c_int, + ) -> c_int; + pub fn GetNumberFormatEx( + lpLocaleName: LPCWSTR, + dwFlags: DWORD, + lpValue: LPCWSTR, + lpFormat: *const NUMBERFMTW, + lpNumberStr: LPWSTR, + cchNumber: c_int, + ) -> c_int; + pub fn GetNumberFormatW( + Locale: LCID, + dwFlags: DWORD, + lpValue: LPCWSTR, + lpFormat: *const NUMBERFMTW, + lpNumberStr: LPWSTR, + cchNumber: c_int, + ) -> c_int; + pub fn GetOEMCP() -> UINT; + pub fn GetProcessPreferredUILanguages( + dwFlags: DWORD, + pulNumLanguages: PULONG, + pwszLanguagesBuffer: PZZWSTR, + pcchLanguagesBuffer: PULONG, + ) -> BOOL; + pub fn GetStringScripts( + dwFlags: DWORD, + lpString: LPCWSTR, + cchString: c_int, + lpScripts: LPWSTR, + cchScripts: c_int, + ) -> c_int; + pub fn GetStringTypeA( + Locale: LCID, + dwInfoType: DWORD, + lpSrcStr: LPCSTR, + cchSrc: c_int, + lpCharType: LPWORD, + ) -> BOOL; + pub fn GetStringTypeExA( + Locale: LCID, + dwInfoType: DWORD, + lpSrcStr: LPCSTR, + cchSrc: c_int, + lpCharType: LPWORD, + ) -> BOOL; + pub fn GetStringTypeW( + dwInfoType: DWORD, + lpSrcStr: LPCWCH, + cchSrc: c_int, + lpCharType: LPWORD, + ) -> BOOL; + pub fn GetSystemDefaultLCID() -> LCID; + pub fn GetSystemDefaultLangID() -> LANGID; + pub fn GetSystemDefaultLocaleName( + lpLocaleName: LPWSTR, + cchLocaleName: c_int, + ) -> c_int; + pub fn GetSystemDefaultUILanguage() -> LANGID; + pub fn GetSystemPreferredUILanguages( + dwFlags: DWORD, + pulNumLanguages: PULONG, + pwszLanguagesBuffer: PZZWSTR, + pcchLanguagesBuffer: PULONG, + ) -> BOOL; + pub fn GetThreadLocale() -> LCID; + pub fn GetThreadPreferredUILanguages( + dwFlags: DWORD, + pulNumLanguages: PULONG, + pwszLanguagesBuffer: PZZWSTR, + pcchLanguagesBuffer: PULONG, + ) -> BOOL; + pub fn GetThreadUILanguage() -> LANGID; + pub fn GetUILanguageInfo( + dwFlags: DWORD, + pwmszLanguage: PCZZWSTR, + pwszFallbackLanguages: PZZWSTR, + pcchFallbackLanguages: PDWORD, + pAttributes: PDWORD, + ) -> BOOL; + pub fn GetUserDefaultLCID() -> LCID; + pub fn GetUserDefaultLangID() -> LANGID; + pub fn GetUserDefaultLocaleName( + lpLocaleName: LPWSTR, + cchLocaleName: c_int, + ) -> c_int; + pub fn GetUserDefaultUILanguage() -> LANGID; + pub fn GetUserGeoID(GeoClass: GEOCLASS) -> GEOID; + pub fn GetUserPreferredUILanguages( + dwFlags: DWORD, + pulNumLanguages: PULONG, + pwszLanguagesBuffer: PZZWSTR, + pcchLanguagesBuffer: PULONG, + ) -> BOOL; + pub fn IsDBCSLeadByte( + TestChar: BYTE, + ) -> BOOL; + pub fn IsDBCSLeadByteEx( + CodePage: UINT, + TestChar: BYTE, + ) -> BOOL; + pub fn IsNLSDefinedString( + Function: NLS_FUNCTION, + dwFlags: DWORD, + lpVersionInformation: LPNLSVERSIONINFO, + lpString: LPCWSTR, + cchStr: INT, + ) -> BOOL; + pub fn IsNormalizedString( + NormForm: NORM_FORM, + lpString: LPCWSTR, + cwLength: c_int, + ) -> BOOL; + pub fn IsValidCodePage( + CodePage: UINT, + ) -> BOOL; + pub fn IsValidLanguageGroup( + LanguageGroup: LGRPID, + dwFlags: DWORD, + ) -> BOOL; + pub fn IsValidLocale( + Locale: LCID, + dwFlags: DWORD, + ) -> BOOL; + pub fn IsValidLocaleName( + lpLocaleName: LPCWSTR, + ) -> BOOL; + pub fn IsValidNLSVersion( + function: NLS_FUNCTION, + lpLocaleName: LPCWSTR, + lpVersionInformation: LPNLSVERSIONINFOEX, + ) -> BOOL; + pub fn LCIDToLocaleName( + Locale: LCID, + lpName: LPWSTR, + cchName: c_int, + dwFlags: DWORD, + ) -> c_int; + pub fn LCMapStringA( + Locale: LCID, + dwMapFlags: DWORD, + lpSrcStr: LPCSTR, + cchSrc: c_int, + lpDestStr: LPSTR, + cchDest: c_int, + ) -> c_int; + pub fn LCMapStringEx( + lpLocaleName: LPCWSTR, + dwMapFlags: DWORD, + lpSrcStr: LPCWSTR, + cchSrc: c_int, + lpDestStr: LPWSTR, + cchDest: c_int, + lpVersionInformation: LPNLSVERSIONINFO, + lpReserved: LPVOID, + sortHandle: LPARAM, + ) -> c_int; + pub fn LCMapStringW( + Locale: LCID, + dwMapFlags: DWORD, + lpSrcStr: LPCWSTR, + cchSrc: c_int, + lpDestStr: LPWSTR, + cchDest: c_int, + ) -> c_int; + pub fn LocaleNameToLCID( + lpName: LPCWSTR, + dwFlags: DWORD, + ) -> LCID; + pub fn NormalizeString( + NormForm: NORM_FORM, + lpSrcString: LPCWSTR, + cwSrcLength: c_int, + lpDstString: LPWSTR, + cwDstLength: c_int, + ) -> c_int; + pub fn NotifyUILanguageChange( + dwFlags: DWORD, + pcwstrNewLanguage: PCWSTR, + pcwstrPreviousLanguage: PCWSTR, + dwReserved: DWORD, + pdwStatusRtrn: PDWORD, + ) -> BOOL; + pub fn ResolveLocaleName( + lpNameToResolve: LPCWSTR, + lpLocaleName: LPWSTR, + cchLocaleName: c_int, + ) -> c_int; + pub fn SetCalendarInfoA( + Locale: LCID, + Calendar: CALID, + CalType: CALTYPE, + lpCalData: LPCSTR, + ) -> BOOL; + pub fn SetCalendarInfoW( + Locale: LCID, + Calendar: CALID, + CalType: CALTYPE, + lpCalData: LPCWSTR, + ) -> BOOL; + pub fn SetLocaleInfoA( + Locale: LCID, + LCType: LCTYPE, + lpLCData: LPCSTR, + ) -> BOOL; + pub fn SetLocaleInfoW( + Locale: LCID, + LCType: LCTYPE, + lpLCData: LPCWSTR, + ) -> BOOL; + pub fn SetProcessPreferredUILanguages( + dwFlags: DWORD, + pwszLanguagesBuffer: PCZZWSTR, + pulNumLanguages: PULONG, + ) -> BOOL; + pub fn SetThreadLocale(Locale: LCID) -> BOOL; + pub fn SetThreadPreferredUILanguages( + dwFlags: DWORD, + pwszLanguagesBuffer: PCZZWSTR, + pulNumLanguages: PULONG, + ) -> BOOL; + pub fn SetThreadUILanguage(LangId: LANGID) -> LANGID; + pub fn SetUserGeoID(GeoId: GEOID) -> BOOL; + pub fn VerifyScripts( + dwFlags: DWORD, + lpLocaleScripts: LPCWSTR, + cchLocaleScripts: c_int, + lpTestScripts: LPCWSTR, + cchTestScripts: c_int, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winnt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winnt.rs new file mode 100644 index 0000000..eb518c4 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winnt.rs @@ -0,0 +1,8664 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This module defines the 32-Bit Windows types and constants that are defined by NT, but exposed +//! through the Win32 API. +use ctypes::{__int64, __uint64, c_char, c_int, c_long, c_short, c_uint, c_ulong, c_void, wchar_t}; +use shared::basetsd::{ + DWORD64, KAFFINITY, LONG64, LONG_PTR, PDWORD64, PLONG64, SIZE_T, ULONG64, ULONG_PTR, +}; +use shared::guiddef::{CLSID, GUID}; +use shared::ktmtypes::UOW; +use shared::minwindef::{BYTE, DWORD, FALSE, PDWORD, TRUE, ULONG, USHORT, WORD}; +#[cfg(target_arch = "aarch64")] +use shared::minwindef::PBYTE; +use vc::excpt::EXCEPTION_DISPOSITION; +use vc::vcruntime::size_t; +pub const ANYSIZE_ARRAY: usize = 1; +#[cfg(target_pointer_width = "32")] +IFDEF!{ +pub const MAX_NATURAL_ALIGNMENT: usize = 4; +pub const MEMORY_ALLOCATION_ALIGNMENT: usize = 8; +} +#[cfg(target_pointer_width = "64")] +IFDEF!{ +pub const MAX_NATURAL_ALIGNMENT: usize = 8; +pub const MEMORY_ALLOCATION_ALIGNMENT: usize = 16; +} +pub const SYSTEM_CACHE_ALIGNMENT_SIZE: usize = 64; +pub type PVOID = *mut c_void; +pub type PVOID64 = u64; // This is a 64-bit pointer, even when in 32-bit +pub type VOID = c_void; +pub type CHAR = c_char; +pub type SHORT = c_short; +pub type LONG = c_long; +pub type INT = c_int; +pub type WCHAR = wchar_t; +pub type PWCHAR = *mut WCHAR; +pub type LPWCH = *mut WCHAR; +pub type PWCH = *mut WCHAR; +pub type LPCWCH = *const WCHAR; +pub type PCWCH = *const WCHAR; +pub type NWPSTR = *mut WCHAR; +pub type LPWSTR = *mut WCHAR; +pub type PWSTR = *mut WCHAR; +pub type PZPWSTR = *mut PWSTR; +pub type PCZPWSTR = *const PWSTR; +pub type LPUWSTR = *mut WCHAR; // Unaligned pointer +pub type PUWSTR = *mut WCHAR; // Unaligned pointer +pub type LPCWSTR = *const WCHAR; +pub type PCWSTR = *const WCHAR; +pub type PZPCWSTR = *mut PCWSTR; +pub type PCZPCWSTR = *const PCWSTR; +pub type LPCUWSTR = *const WCHAR; // Unaligned pointer +pub type PCUWSTR = *const WCHAR; // Unaligned pointer +pub type PZZWSTR = *mut WCHAR; +pub type PCZZWSTR = *const WCHAR; +pub type PUZZWSTR = *mut WCHAR; // Unaligned pointer +pub type PCUZZWSTR = *const WCHAR; // Unaligned pointer +pub type PNZWCH = *mut WCHAR; +pub type PCNZWCH = *const WCHAR; +pub type PUNZWCH = *mut WCHAR; // Unaligned pointer +pub type PCUNZWCH = *const WCHAR; // Unaligned pointer +pub type LPCWCHAR = *const WCHAR; +pub type PCWCHAR = *const WCHAR; +pub type LPCUWCHAR = *const WCHAR; // Unaligned pointer +pub type PCUWCHAR = *const WCHAR; // Unaligned pointer +pub type UCSCHAR = c_ulong; +pub const UCSCHAR_INVALID_CHARACTER: UCSCHAR = 0xffffffff; +pub const MIN_UCSCHAR: UCSCHAR = 0; +pub const MAX_UCSCHAR: UCSCHAR = 0x0010FFFF; +pub type PUCSCHAR = *mut UCSCHAR; +pub type PCUCSCHAR = *const UCSCHAR; +pub type PUCSSTR = *mut UCSCHAR; +pub type PUUCSSTR = *mut UCSCHAR; // Unaligned pointer +pub type PCUCSSTR = *const UCSCHAR; +pub type PCUUCSSTR = *const UCSCHAR; // Unaligned pointer +pub type PUUCSCHAR = *mut UCSCHAR; // Unaligned pointer +pub type PCUUCSCHAR = *const UCSCHAR; // Unaligned pointer +pub type PCHAR = *mut CHAR; +pub type LPCH = *mut CHAR; +pub type PCH = *mut CHAR; +pub type LPCCH = *const CHAR; +pub type PCCH = *const CHAR; +pub type NPSTR = *mut CHAR; +pub type LPSTR = *mut CHAR; +pub type PSTR = *mut CHAR; +pub type PZPSTR = *mut PSTR; +pub type PCZPSTR = *const PSTR; +pub type LPCSTR = *const CHAR; +pub type PCSTR = *const CHAR; +pub type PZPCSTR = *mut PCSTR; +pub type PCZPCSTR = *const PCSTR; +pub type PZZSTR = *mut CHAR; +pub type PCZZSTR = *const CHAR; +pub type PNZCH = *mut CHAR; +pub type PCNZCH = *const CHAR; +// Skipping TCHAR things +pub type PSHORT = *mut SHORT; +pub type PLONG = *mut LONG; +pub const ALL_PROCESSOR_GROUPS: WORD = 0xffff; +STRUCT!{struct PROCESSOR_NUMBER { + Group: WORD, + Number: BYTE, + Reserved: BYTE, +}} +pub type PPROCESSOR_NUMBER = *mut PROCESSOR_NUMBER; +STRUCT!{struct GROUP_AFFINITY { + Mask: KAFFINITY, + Group: WORD, + Reserved: [WORD; 3], +}} +pub type PGROUP_AFFINITY = *mut GROUP_AFFINITY; +#[cfg(target_pointer_width = "32")] +pub const MAXIMUM_PROC_PER_GROUP: BYTE = 32; +#[cfg(target_pointer_width = "64")] +pub const MAXIMUM_PROC_PER_GROUP: BYTE = 64; +pub const MAXIMUM_PROCESSORS: BYTE = MAXIMUM_PROC_PER_GROUP; +pub type HANDLE = *mut c_void; +pub type PHANDLE = *mut HANDLE; +pub type FCHAR = BYTE; +pub type FSHORT = WORD; +pub type FLONG = DWORD; +pub type HRESULT = c_long; +pub type CCHAR = c_char; +pub type LCID = DWORD; +pub type PLCID = PDWORD; +pub type LANGID = WORD; +ENUM!{enum COMPARTMENT_ID { + UNSPECIFIED_COMPARTMENT_ID = 0, + DEFAULT_COMPARTMENT_ID, +}} +pub type PCOMPARTMENT_ID = *mut COMPARTMENT_ID; +pub const APPLICATION_ERROR_MASK: DWORD = 0x20000000; +pub const ERROR_SEVERITY_SUCCESS: DWORD = 0x00000000; +pub const ERROR_SEVERITY_INFORMATIONAL: DWORD = 0x40000000; +pub const ERROR_SEVERITY_WARNING: DWORD = 0x80000000; +pub const ERROR_SEVERITY_ERROR: DWORD = 0xC0000000; +STRUCT!{struct FLOAT128 { + LowPart: __int64, + HighPart: __int64, +}} +pub type PFLOAT128 = *mut FLOAT128; +pub type LONGLONG = __int64; +pub type ULONGLONG = __uint64; +pub const MAXLONGLONG: LONGLONG = 0x7fffffffffffffff; +pub type PLONGLONG = *mut LONGLONG; +pub type PULONGLONG = *mut ULONGLONG; +pub type USN = LONGLONG; +STRUCT!{struct LARGE_INTEGER_u { + LowPart: DWORD, + HighPart: LONG, +}} +UNION!{union LARGE_INTEGER { + [u64; 1], + QuadPart QuadPart_mut: LONGLONG, + u u_mut: LARGE_INTEGER_u, +}} +pub type PLARGE_INTEGER = *mut LARGE_INTEGER; +STRUCT!{struct ULARGE_INTEGER_u { + LowPart: DWORD, + HighPart: LONG, +}} +UNION!{union ULARGE_INTEGER { + [u64; 1], + QuadPart QuadPart_mut: ULONGLONG, + u u_mut: ULARGE_INTEGER_u, +}} +pub type PULARGE_INTEGER = *mut ULARGE_INTEGER; +pub type RTL_REFERENCE_COUNT = LONG_PTR; +pub type PRTL_REFERENCE_COUNT = *mut LONG_PTR; +pub type RTL_REFERENCE_COUNT32 = LONG; +pub type PRTL_REFERENCE_COUNT32 = *mut LONG; +pub use shared::ntdef::LUID; +pub type PLUID = *mut LUID; +pub type DWORDLONG = ULONGLONG; +pub type PDWORDLONG = *mut DWORDLONG; +pub const ANSI_NULL: CHAR = 0; +pub const UNICODE_NULL: WCHAR = 0; +pub const UNICODE_STRING_MAX_BYTES: WORD = 65534; +pub const UNICODE_STRING_MAX_CHARS: WORD = 32767; +pub type BOOLEAN = BYTE; +pub type PBOOLEAN = *mut BOOLEAN; +STRUCT!{struct LIST_ENTRY { + Flink: *mut LIST_ENTRY, + Blink: *mut LIST_ENTRY, +}} +pub type PLIST_ENTRY = *mut LIST_ENTRY; +pub type PRLIST_ENTRY = *mut LIST_ENTRY; // Restricted pointer +STRUCT!{struct SINGLE_LIST_ENTRY { + Next: *mut SINGLE_LIST_ENTRY, +}} +pub type PSINGLE_LIST_ENTRY = *mut SINGLE_LIST_ENTRY; +STRUCT!{struct LIST_ENTRY32 { + Flink: DWORD, + Blink: DWORD, +}} +pub type PLIST_ENTRY32 = *mut LIST_ENTRY32; +STRUCT!{struct LIST_ENTRY64 { + Flink: ULONGLONG, + Blink: ULONGLONG, +}} +pub type PLIST_ENTRY64 = *mut LIST_ENTRY64; +STRUCT!{struct OBJECTID { + Lineage: GUID, + Uniquifier: DWORD, +}} +pub const MINCHAR: CHAR = 0x80; +pub const MAXCHAR: CHAR = 0x7f; +pub const MINSHORT: SHORT = 0x8000; +pub const MAXSHORT: SHORT = 0x7fff; +pub const MINLONG: LONG = 0x80000000; +pub const MAXLONG: LONG = 0x7fffffff; +pub const MAXBYTE: BYTE = 0xff; +pub const MAXWORD: WORD = 0xffff; +pub const MAXDWORD: DWORD = 0xffffffff; +FN!{stdcall PEXCEPTION_ROUTINE( + ExceptionRecord: *mut EXCEPTION_RECORD, + EstablisherFrame: PVOID, + ContextRecord: *mut CONTEXT, + DispatcherContext: PVOID, +) -> EXCEPTION_DISPOSITION} +pub const VER_SERVER_NT: DWORD = 0x80000000; +pub const VER_WORKSTATION_NT: DWORD = 0x40000000; +pub const VER_SUITE_SMALLBUSINESS: DWORD = 0x00000001; +pub const VER_SUITE_ENTERPRISE: DWORD = 0x00000002; +pub const VER_SUITE_BACKOFFICE: DWORD = 0x00000004; +pub const VER_SUITE_COMMUNICATIONS: DWORD = 0x00000008; +pub const VER_SUITE_TERMINAL: DWORD = 0x00000010; +pub const VER_SUITE_SMALLBUSINESS_RESTRICTED: DWORD = 0x00000020; +pub const VER_SUITE_EMBEDDEDNT: DWORD = 0x00000040; +pub const VER_SUITE_DATACENTER: DWORD = 0x00000080; +pub const VER_SUITE_SINGLEUSERTS: DWORD = 0x00000100; +pub const VER_SUITE_PERSONAL: DWORD = 0x00000200; +pub const VER_SUITE_BLADE: DWORD = 0x00000400; +pub const VER_SUITE_EMBEDDED_RESTRICTED: DWORD = 0x00000800; +pub const VER_SUITE_SECURITY_APPLIANCE: DWORD = 0x00001000; +pub const VER_SUITE_STORAGE_SERVER: DWORD = 0x00002000; +pub const VER_SUITE_COMPUTE_SERVER: DWORD = 0x00004000; +pub const VER_SUITE_WH_SERVER: DWORD = 0x00008000; +pub const PRODUCT_UNDEFINED: DWORD = 0x00000000; +pub const PRODUCT_ULTIMATE: DWORD = 0x00000001; +pub const PRODUCT_HOME_BASIC: DWORD = 0x00000002; +pub const PRODUCT_HOME_PREMIUM: DWORD = 0x00000003; +pub const PRODUCT_ENTERPRISE: DWORD = 0x00000004; +pub const PRODUCT_HOME_BASIC_N: DWORD = 0x00000005; +pub const PRODUCT_BUSINESS: DWORD = 0x00000006; +pub const PRODUCT_STANDARD_SERVER: DWORD = 0x00000007; +pub const PRODUCT_DATACENTER_SERVER: DWORD = 0x00000008; +pub const PRODUCT_SMALLBUSINESS_SERVER: DWORD = 0x00000009; +pub const PRODUCT_ENTERPRISE_SERVER: DWORD = 0x0000000A; +pub const PRODUCT_STARTER: DWORD = 0x0000000B; +pub const PRODUCT_DATACENTER_SERVER_CORE: DWORD = 0x0000000C; +pub const PRODUCT_STANDARD_SERVER_CORE: DWORD = 0x0000000D; +pub const PRODUCT_ENTERPRISE_SERVER_CORE: DWORD = 0x0000000E; +pub const PRODUCT_ENTERPRISE_SERVER_IA64: DWORD = 0x0000000F; +pub const PRODUCT_BUSINESS_N: DWORD = 0x00000010; +pub const PRODUCT_WEB_SERVER: DWORD = 0x00000011; +pub const PRODUCT_CLUSTER_SERVER: DWORD = 0x00000012; +pub const PRODUCT_HOME_SERVER: DWORD = 0x00000013; +pub const PRODUCT_STORAGE_EXPRESS_SERVER: DWORD = 0x00000014; +pub const PRODUCT_STORAGE_STANDARD_SERVER: DWORD = 0x00000015; +pub const PRODUCT_STORAGE_WORKGROUP_SERVER: DWORD = 0x00000016; +pub const PRODUCT_STORAGE_ENTERPRISE_SERVER: DWORD = 0x00000017; +pub const PRODUCT_SERVER_FOR_SMALLBUSINESS: DWORD = 0x00000018; +pub const PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: DWORD = 0x00000019; +pub const PRODUCT_HOME_PREMIUM_N: DWORD = 0x0000001A; +pub const PRODUCT_ENTERPRISE_N: DWORD = 0x0000001B; +pub const PRODUCT_ULTIMATE_N: DWORD = 0x0000001C; +pub const PRODUCT_WEB_SERVER_CORE: DWORD = 0x0000001D; +pub const PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT: DWORD = 0x0000001E; +pub const PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY: DWORD = 0x0000001F; +pub const PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING: DWORD = 0x00000020; +pub const PRODUCT_SERVER_FOUNDATION: DWORD = 0x00000021; +pub const PRODUCT_HOME_PREMIUM_SERVER: DWORD = 0x00000022; +pub const PRODUCT_SERVER_FOR_SMALLBUSINESS_V: DWORD = 0x00000023; +pub const PRODUCT_STANDARD_SERVER_V: DWORD = 0x00000024; +pub const PRODUCT_DATACENTER_SERVER_V: DWORD = 0x00000025; +pub const PRODUCT_ENTERPRISE_SERVER_V: DWORD = 0x00000026; +pub const PRODUCT_DATACENTER_SERVER_CORE_V: DWORD = 0x00000027; +pub const PRODUCT_STANDARD_SERVER_CORE_V: DWORD = 0x00000028; +pub const PRODUCT_ENTERPRISE_SERVER_CORE_V: DWORD = 0x00000029; +pub const PRODUCT_HYPERV: DWORD = 0x0000002A; +pub const PRODUCT_STORAGE_EXPRESS_SERVER_CORE: DWORD = 0x0000002B; +pub const PRODUCT_STORAGE_STANDARD_SERVER_CORE: DWORD = 0x0000002C; +pub const PRODUCT_STORAGE_WORKGROUP_SERVER_CORE: DWORD = 0x0000002D; +pub const PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE: DWORD = 0x0000002E; +pub const PRODUCT_STARTER_N: DWORD = 0x0000002F; +pub const PRODUCT_PROFESSIONAL: DWORD = 0x00000030; +pub const PRODUCT_PROFESSIONAL_N: DWORD = 0x00000031; +pub const PRODUCT_SB_SOLUTION_SERVER: DWORD = 0x00000032; +pub const PRODUCT_SERVER_FOR_SB_SOLUTIONS: DWORD = 0x00000033; +pub const PRODUCT_STANDARD_SERVER_SOLUTIONS: DWORD = 0x00000034; +pub const PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE: DWORD = 0x00000035; +pub const PRODUCT_SB_SOLUTION_SERVER_EM: DWORD = 0x00000036; +pub const PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM: DWORD = 0x00000037; +pub const PRODUCT_SOLUTION_EMBEDDEDSERVER: DWORD = 0x00000038; +pub const PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE: DWORD = 0x00000039; +pub const PRODUCT_PROFESSIONAL_EMBEDDED: DWORD = 0x0000003A; +pub const PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT: DWORD = 0x0000003B; +pub const PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL: DWORD = 0x0000003C; +pub const PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC: DWORD = 0x0000003D; +pub const PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC: DWORD = 0x0000003E; +pub const PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE: DWORD = 0x0000003F; +pub const PRODUCT_CLUSTER_SERVER_V: DWORD = 0x00000040; +pub const PRODUCT_EMBEDDED: DWORD = 0x00000041; +pub const PRODUCT_STARTER_E: DWORD = 0x00000042; +pub const PRODUCT_HOME_BASIC_E: DWORD = 0x00000043; +pub const PRODUCT_HOME_PREMIUM_E: DWORD = 0x00000044; +pub const PRODUCT_PROFESSIONAL_E: DWORD = 0x00000045; +pub const PRODUCT_ENTERPRISE_E: DWORD = 0x00000046; +pub const PRODUCT_ULTIMATE_E: DWORD = 0x00000047; +pub const PRODUCT_ENTERPRISE_EVALUATION: DWORD = 0x00000048; +pub const PRODUCT_MULTIPOINT_STANDARD_SERVER: DWORD = 0x0000004C; +pub const PRODUCT_MULTIPOINT_PREMIUM_SERVER: DWORD = 0x0000004D; +pub const PRODUCT_STANDARD_EVALUATION_SERVER: DWORD = 0x0000004F; +pub const PRODUCT_DATACENTER_EVALUATION_SERVER: DWORD = 0x00000050; +pub const PRODUCT_ENTERPRISE_N_EVALUATION: DWORD = 0x00000054; +pub const PRODUCT_EMBEDDED_AUTOMOTIVE: DWORD = 0x00000055; +pub const PRODUCT_EMBEDDED_INDUSTRY_A: DWORD = 0x00000056; +pub const PRODUCT_THINPC: DWORD = 0x00000057; +pub const PRODUCT_EMBEDDED_A: DWORD = 0x00000058; +pub const PRODUCT_EMBEDDED_INDUSTRY: DWORD = 0x00000059; +pub const PRODUCT_EMBEDDED_E: DWORD = 0x0000005A; +pub const PRODUCT_EMBEDDED_INDUSTRY_E: DWORD = 0x0000005B; +pub const PRODUCT_EMBEDDED_INDUSTRY_A_E: DWORD = 0x0000005C; +pub const PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER: DWORD = 0x0000005F; +pub const PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER: DWORD = 0x00000060; +pub const PRODUCT_CORE_ARM: DWORD = 0x00000061; +pub const PRODUCT_CORE_N: DWORD = 0x00000062; +pub const PRODUCT_CORE_COUNTRYSPECIFIC: DWORD = 0x00000063; +pub const PRODUCT_CORE_SINGLELANGUAGE: DWORD = 0x00000064; +pub const PRODUCT_CORE: DWORD = 0x00000065; +pub const PRODUCT_PROFESSIONAL_WMC: DWORD = 0x00000067; +pub const PRODUCT_MOBILE_CORE: DWORD = 0x00000068; +pub const PRODUCT_EMBEDDED_INDUSTRY_EVAL: DWORD = 0x00000069; +pub const PRODUCT_EMBEDDED_INDUSTRY_E_EVAL: DWORD = 0x0000006A; +pub const PRODUCT_EMBEDDED_EVAL: DWORD = 0x0000006B; +pub const PRODUCT_EMBEDDED_E_EVAL: DWORD = 0x0000006C; +pub const PRODUCT_NANO_SERVER: DWORD = 0x0000006D; +pub const PRODUCT_CLOUD_STORAGE_SERVER: DWORD = 0x0000006E; +pub const PRODUCT_CORE_CONNECTED: DWORD = 0x0000006F; +pub const PRODUCT_PROFESSIONAL_STUDENT: DWORD = 0x00000070; +pub const PRODUCT_CORE_CONNECTED_N: DWORD = 0x00000071; +pub const PRODUCT_PROFESSIONAL_STUDENT_N: DWORD = 0x00000072; +pub const PRODUCT_CORE_CONNECTED_SINGLELANGUAGE: DWORD = 0x00000073; +pub const PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC: DWORD = 0x00000074; +pub const PRODUCT_CONNECTED_CAR: DWORD = 0x00000075; +pub const PRODUCT_INDUSTRY_HANDHELD: DWORD = 0x00000076; +pub const PRODUCT_PPI_PRO: DWORD = 0x00000077; +pub const PRODUCT_ARM64_SERVER: DWORD = 0x00000078; +pub const PRODUCT_EDUCATION: DWORD = 0x00000079; +pub const PRODUCT_EDUCATION_N: DWORD = 0x0000007A; +pub const PRODUCT_IOTUAP: DWORD = 0x0000007B; +pub const PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER: DWORD = 0x0000007C; +pub const PRODUCT_ENTERPRISE_S: DWORD = 0x0000007D; +pub const PRODUCT_ENTERPRISE_S_N: DWORD = 0x0000007E; +pub const PRODUCT_PROFESSIONAL_S: DWORD = 0x0000007F; +pub const PRODUCT_PROFESSIONAL_S_N: DWORD = 0x00000080; +pub const PRODUCT_ENTERPRISE_S_EVALUATION: DWORD = 0x00000081; +pub const PRODUCT_ENTERPRISE_S_N_EVALUATION: DWORD = 0x00000082; +pub const PRODUCT_HOLOGRAPHIC: DWORD = 0x00000087; +pub const PRODUCT_PRO_SINGLE_LANGUAGE: DWORD = 0x0000008A; +pub const PRODUCT_PRO_CHINA: DWORD = 0x0000008B; +pub const PRODUCT_ENTERPRISE_SUBSCRIPTION: DWORD = 0x0000008C; +pub const PRODUCT_ENTERPRISE_SUBSCRIPTION_N: DWORD = 0x0000008D; +pub const PRODUCT_DATACENTER_NANO_SERVER: DWORD = 0x0000008F; +pub const PRODUCT_STANDARD_NANO_SERVER: DWORD = 0x00000090; +pub const PRODUCT_DATACENTER_A_SERVER_CORE: DWORD = 0x00000091; +pub const PRODUCT_STANDARD_A_SERVER_CORE: DWORD = 0x00000092; +pub const PRODUCT_DATACENTER_WS_SERVER_CORE: DWORD = 0x00000093; +pub const PRODUCT_STANDARD_WS_SERVER_CORE: DWORD = 0x00000094; +pub const PRODUCT_UTILITY_VM: DWORD = 0x00000095; +pub const PRODUCT_DATACENTER_EVALUATION_SERVER_CORE: DWORD = 0x0000009F; +pub const PRODUCT_STANDARD_EVALUATION_SERVER_CORE: DWORD = 0x000000A0; +pub const PRODUCT_PRO_WORKSTATION: DWORD = 0x000000A1; +pub const PRODUCT_PRO_WORKSTATION_N: DWORD = 0x000000A2; +pub const PRODUCT_PRO_FOR_EDUCATION: DWORD = 0x000000A4; +pub const PRODUCT_PRO_FOR_EDUCATION_N: DWORD = 0x000000A5; +pub const PRODUCT_AZURE_SERVER_CORE: DWORD = 0x000000A8; +pub const PRODUCT_AZURE_NANO_SERVER: DWORD = 0x000000A9; +pub const PRODUCT_ENTERPRISEG: DWORD = 0x000000AB; +pub const PRODUCT_ENTERPRISEGN: DWORD = 0x000000AC; +pub const PRODUCT_CLOUD: DWORD = 0x000000B2; +pub const PRODUCT_CLOUDN: DWORD = 0x000000B3; +pub const PRODUCT_UNLICENSED: DWORD = 0xABCDABCD; +pub const LANG_NEUTRAL: WORD = 0x00; +pub const LANG_INVARIANT: WORD = 0x7f; +pub const LANG_AFRIKAANS: WORD = 0x36; +pub const LANG_ALBANIAN: WORD = 0x1c; +pub const LANG_ALSATIAN: WORD = 0x84; +pub const LANG_AMHARIC: WORD = 0x5e; +pub const LANG_ARABIC: WORD = 0x01; +pub const LANG_ARMENIAN: WORD = 0x2b; +pub const LANG_ASSAMESE: WORD = 0x4d; +pub const LANG_AZERI: WORD = 0x2c; +pub const LANG_AZERBAIJANI: WORD = 0x2c; +pub const LANG_BANGLA: WORD = 0x45; +pub const LANG_BASHKIR: WORD = 0x6d; +pub const LANG_BASQUE: WORD = 0x2d; +pub const LANG_BELARUSIAN: WORD = 0x23; +pub const LANG_BENGALI: WORD = 0x45; +pub const LANG_BRETON: WORD = 0x7e; +pub const LANG_BOSNIAN: WORD = 0x1a; +pub const LANG_BOSNIAN_NEUTRAL: WORD = 0x781a; +pub const LANG_BULGARIAN: WORD = 0x02; +pub const LANG_CATALAN: WORD = 0x03; +pub const LANG_CENTRAL_KURDISH: WORD = 0x92; +pub const LANG_CHEROKEE: WORD = 0x5c; +pub const LANG_CHINESE: WORD = 0x04; +pub const LANG_CHINESE_SIMPLIFIED: WORD = 0x04; +pub const LANG_CHINESE_TRADITIONAL: WORD = 0x7c04; +pub const LANG_CORSICAN: WORD = 0x83; +pub const LANG_CROATIAN: WORD = 0x1a; +pub const LANG_CZECH: WORD = 0x05; +pub const LANG_DANISH: WORD = 0x06; +pub const LANG_DARI: WORD = 0x8c; +pub const LANG_DIVEHI: WORD = 0x65; +pub const LANG_DUTCH: WORD = 0x13; +pub const LANG_ENGLISH: WORD = 0x09; +pub const LANG_ESTONIAN: WORD = 0x25; +pub const LANG_FAEROESE: WORD = 0x38; +pub const LANG_FARSI: WORD = 0x29; +pub const LANG_FILIPINO: WORD = 0x64; +pub const LANG_FINNISH: WORD = 0x0b; +pub const LANG_FRENCH: WORD = 0x0c; +pub const LANG_FRISIAN: WORD = 0x62; +pub const LANG_FULAH: WORD = 0x67; +pub const LANG_GALICIAN: WORD = 0x56; +pub const LANG_GEORGIAN: WORD = 0x37; +pub const LANG_GERMAN: WORD = 0x07; +pub const LANG_GREEK: WORD = 0x08; +pub const LANG_GREENLANDIC: WORD = 0x6f; +pub const LANG_GUJARATI: WORD = 0x47; +pub const LANG_HAUSA: WORD = 0x68; +pub const LANG_HAWAIIAN: WORD = 0x75; +pub const LANG_HEBREW: WORD = 0x0d; +pub const LANG_HINDI: WORD = 0x39; +pub const LANG_HUNGARIAN: WORD = 0x0e; +pub const LANG_ICELANDIC: WORD = 0x0f; +pub const LANG_IGBO: WORD = 0x70; +pub const LANG_INDONESIAN: WORD = 0x21; +pub const LANG_INUKTITUT: WORD = 0x5d; +pub const LANG_IRISH: WORD = 0x3c; +pub const LANG_ITALIAN: WORD = 0x10; +pub const LANG_JAPANESE: WORD = 0x11; +pub const LANG_KANNADA: WORD = 0x4b; +pub const LANG_KASHMIRI: WORD = 0x60; +pub const LANG_KAZAK: WORD = 0x3f; +pub const LANG_KHMER: WORD = 0x53; +pub const LANG_KICHE: WORD = 0x86; +pub const LANG_KINYARWANDA: WORD = 0x87; +pub const LANG_KONKANI: WORD = 0x57; +pub const LANG_KOREAN: WORD = 0x12; +pub const LANG_KYRGYZ: WORD = 0x40; +pub const LANG_LAO: WORD = 0x54; +pub const LANG_LATVIAN: WORD = 0x26; +pub const LANG_LITHUANIAN: WORD = 0x27; +pub const LANG_LOWER_SORBIAN: WORD = 0x2e; +pub const LANG_LUXEMBOURGISH: WORD = 0x6e; +pub const LANG_MACEDONIAN: WORD = 0x2f; +pub const LANG_MALAY: WORD = 0x3e; +pub const LANG_MALAYALAM: WORD = 0x4c; +pub const LANG_MALTESE: WORD = 0x3a; +pub const LANG_MANIPURI: WORD = 0x58; +pub const LANG_MAORI: WORD = 0x81; +pub const LANG_MAPUDUNGUN: WORD = 0x7a; +pub const LANG_MARATHI: WORD = 0x4e; +pub const LANG_MOHAWK: WORD = 0x7c; +pub const LANG_MONGOLIAN: WORD = 0x50; +pub const LANG_NEPALI: WORD = 0x61; +pub const LANG_NORWEGIAN: WORD = 0x14; +pub const LANG_OCCITAN: WORD = 0x82; +pub const LANG_ODIA: WORD = 0x48; +pub const LANG_ORIYA: WORD = 0x48; +pub const LANG_PASHTO: WORD = 0x63; +pub const LANG_PERSIAN: WORD = 0x29; +pub const LANG_POLISH: WORD = 0x15; +pub const LANG_PORTUGUESE: WORD = 0x16; +pub const LANG_PULAR: WORD = 0x67; +pub const LANG_PUNJABI: WORD = 0x46; +pub const LANG_QUECHUA: WORD = 0x6b; +pub const LANG_ROMANIAN: WORD = 0x18; +pub const LANG_ROMANSH: WORD = 0x17; +pub const LANG_RUSSIAN: WORD = 0x19; +pub const LANG_SAKHA: WORD = 0x85; +pub const LANG_SAMI: WORD = 0x3b; +pub const LANG_SANSKRIT: WORD = 0x4f; +pub const LANG_SCOTTISH_GAELIC: WORD = 0x91; +pub const LANG_SERBIAN: WORD = 0x1a; +pub const LANG_SERBIAN_NEUTRAL: WORD = 0x7c1a; +pub const LANG_SINDHI: WORD = 0x59; +pub const LANG_SINHALESE: WORD = 0x5b; +pub const LANG_SLOVAK: WORD = 0x1b; +pub const LANG_SLOVENIAN: WORD = 0x24; +pub const LANG_SOTHO: WORD = 0x6c; +pub const LANG_SPANISH: WORD = 0x0a; +pub const LANG_SWAHILI: WORD = 0x41; +pub const LANG_SWEDISH: WORD = 0x1d; +pub const LANG_SYRIAC: WORD = 0x5a; +pub const LANG_TAJIK: WORD = 0x28; +pub const LANG_TAMAZIGHT: WORD = 0x5f; +pub const LANG_TAMIL: WORD = 0x49; +pub const LANG_TATAR: WORD = 0x44; +pub const LANG_TELUGU: WORD = 0x4a; +pub const LANG_THAI: WORD = 0x1e; +pub const LANG_TIBETAN: WORD = 0x51; +pub const LANG_TIGRIGNA: WORD = 0x73; +pub const LANG_TIGRINYA: WORD = 0x73; +pub const LANG_TSWANA: WORD = 0x32; +pub const LANG_TURKISH: WORD = 0x1f; +pub const LANG_TURKMEN: WORD = 0x42; +pub const LANG_UIGHUR: WORD = 0x80; +pub const LANG_UKRAINIAN: WORD = 0x22; +pub const LANG_UPPER_SORBIAN: WORD = 0x2e; +pub const LANG_URDU: WORD = 0x20; +pub const LANG_UZBEK: WORD = 0x43; +pub const LANG_VALENCIAN: WORD = 0x03; +pub const LANG_VIETNAMESE: WORD = 0x2a; +pub const LANG_WELSH: WORD = 0x52; +pub const LANG_WOLOF: WORD = 0x88; +pub const LANG_XHOSA: WORD = 0x34; +pub const LANG_YAKUT: WORD = 0x85; +pub const LANG_YI: WORD = 0x78; +pub const LANG_YORUBA: WORD = 0x6a; +pub const LANG_ZULU: WORD = 0x35; +pub const SUBLANG_NEUTRAL: WORD = 0x00; +pub const SUBLANG_DEFAULT: WORD = 0x01; +pub const SUBLANG_SYS_DEFAULT: WORD = 0x02; +pub const SUBLANG_CUSTOM_DEFAULT: WORD = 0x03; +pub const SUBLANG_CUSTOM_UNSPECIFIED: WORD = 0x04; +pub const SUBLANG_UI_CUSTOM_DEFAULT: WORD = 0x05; +pub const SUBLANG_AFRIKAANS_SOUTH_AFRICA: WORD = 0x01; +pub const SUBLANG_ALBANIAN_ALBANIA: WORD = 0x01; +pub const SUBLANG_ALSATIAN_FRANCE: WORD = 0x01; +pub const SUBLANG_AMHARIC_ETHIOPIA: WORD = 0x01; +pub const SUBLANG_ARABIC_SAUDI_ARABIA: WORD = 0x01; +pub const SUBLANG_ARABIC_IRAQ: WORD = 0x02; +pub const SUBLANG_ARABIC_EGYPT: WORD = 0x03; +pub const SUBLANG_ARABIC_LIBYA: WORD = 0x04; +pub const SUBLANG_ARABIC_ALGERIA: WORD = 0x05; +pub const SUBLANG_ARABIC_MOROCCO: WORD = 0x06; +pub const SUBLANG_ARABIC_TUNISIA: WORD = 0x07; +pub const SUBLANG_ARABIC_OMAN: WORD = 0x08; +pub const SUBLANG_ARABIC_YEMEN: WORD = 0x09; +pub const SUBLANG_ARABIC_SYRIA: WORD = 0x0a; +pub const SUBLANG_ARABIC_JORDAN: WORD = 0x0b; +pub const SUBLANG_ARABIC_LEBANON: WORD = 0x0c; +pub const SUBLANG_ARABIC_KUWAIT: WORD = 0x0d; +pub const SUBLANG_ARABIC_UAE: WORD = 0x0e; +pub const SUBLANG_ARABIC_BAHRAIN: WORD = 0x0f; +pub const SUBLANG_ARABIC_QATAR: WORD = 0x10; +pub const SUBLANG_ARMENIAN_ARMENIA: WORD = 0x01; +pub const SUBLANG_ASSAMESE_INDIA: WORD = 0x01; +pub const SUBLANG_AZERI_LATIN: WORD = 0x01; +pub const SUBLANG_AZERI_CYRILLIC: WORD = 0x02; +pub const SUBLANG_AZERBAIJANI_AZERBAIJAN_LATIN: WORD = 0x01; +pub const SUBLANG_AZERBAIJANI_AZERBAIJAN_CYRILLIC: WORD = 0x02; +pub const SUBLANG_BANGLA_INDIA: WORD = 0x01; +pub const SUBLANG_BANGLA_BANGLADESH: WORD = 0x02; +pub const SUBLANG_BASHKIR_RUSSIA: WORD = 0x01; +pub const SUBLANG_BASQUE_BASQUE: WORD = 0x01; +pub const SUBLANG_BELARUSIAN_BELARUS: WORD = 0x01; +pub const SUBLANG_BENGALI_INDIA: WORD = 0x01; +pub const SUBLANG_BENGALI_BANGLADESH: WORD = 0x02; +pub const SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN: WORD = 0x05; +pub const SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC: WORD = 0x08; +pub const SUBLANG_BRETON_FRANCE: WORD = 0x01; +pub const SUBLANG_BULGARIAN_BULGARIA: WORD = 0x01; +pub const SUBLANG_CATALAN_CATALAN: WORD = 0x01; +pub const SUBLANG_CENTRAL_KURDISH_IRAQ: WORD = 0x01; +pub const SUBLANG_CHEROKEE_CHEROKEE: WORD = 0x01; +pub const SUBLANG_CHINESE_TRADITIONAL: WORD = 0x01; +pub const SUBLANG_CHINESE_SIMPLIFIED: WORD = 0x02; +pub const SUBLANG_CHINESE_HONGKONG: WORD = 0x03; +pub const SUBLANG_CHINESE_SINGAPORE: WORD = 0x04; +pub const SUBLANG_CHINESE_MACAU: WORD = 0x05; +pub const SUBLANG_CORSICAN_FRANCE: WORD = 0x01; +pub const SUBLANG_CZECH_CZECH_REPUBLIC: WORD = 0x01; +pub const SUBLANG_CROATIAN_CROATIA: WORD = 0x01; +pub const SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN: WORD = 0x04; +pub const SUBLANG_DANISH_DENMARK: WORD = 0x01; +pub const SUBLANG_DARI_AFGHANISTAN: WORD = 0x01; +pub const SUBLANG_DIVEHI_MALDIVES: WORD = 0x01; +pub const SUBLANG_DUTCH: WORD = 0x01; +pub const SUBLANG_DUTCH_BELGIAN: WORD = 0x02; +pub const SUBLANG_ENGLISH_US: WORD = 0x01; +pub const SUBLANG_ENGLISH_UK: WORD = 0x02; +pub const SUBLANG_ENGLISH_AUS: WORD = 0x03; +pub const SUBLANG_ENGLISH_CAN: WORD = 0x04; +pub const SUBLANG_ENGLISH_NZ: WORD = 0x05; +pub const SUBLANG_ENGLISH_EIRE: WORD = 0x06; +pub const SUBLANG_ENGLISH_SOUTH_AFRICA: WORD = 0x07; +pub const SUBLANG_ENGLISH_JAMAICA: WORD = 0x08; +pub const SUBLANG_ENGLISH_CARIBBEAN: WORD = 0x09; +pub const SUBLANG_ENGLISH_BELIZE: WORD = 0x0a; +pub const SUBLANG_ENGLISH_TRINIDAD: WORD = 0x0b; +pub const SUBLANG_ENGLISH_ZIMBABWE: WORD = 0x0c; +pub const SUBLANG_ENGLISH_PHILIPPINES: WORD = 0x0d; +pub const SUBLANG_ENGLISH_INDIA: WORD = 0x10; +pub const SUBLANG_ENGLISH_MALAYSIA: WORD = 0x11; +pub const SUBLANG_ENGLISH_SINGAPORE: WORD = 0x12; +pub const SUBLANG_ESTONIAN_ESTONIA: WORD = 0x01; +pub const SUBLANG_FAEROESE_FAROE_ISLANDS: WORD = 0x01; +pub const SUBLANG_FILIPINO_PHILIPPINES: WORD = 0x01; +pub const SUBLANG_FINNISH_FINLAND: WORD = 0x01; +pub const SUBLANG_FRENCH: WORD = 0x01; +pub const SUBLANG_FRENCH_BELGIAN: WORD = 0x02; +pub const SUBLANG_FRENCH_CANADIAN: WORD = 0x03; +pub const SUBLANG_FRENCH_SWISS: WORD = 0x04; +pub const SUBLANG_FRENCH_LUXEMBOURG: WORD = 0x05; +pub const SUBLANG_FRENCH_MONACO: WORD = 0x06; +pub const SUBLANG_FRISIAN_NETHERLANDS: WORD = 0x01; +pub const SUBLANG_FULAH_SENEGAL: WORD = 0x02; +pub const SUBLANG_GALICIAN_GALICIAN: WORD = 0x01; +pub const SUBLANG_GEORGIAN_GEORGIA: WORD = 0x01; +pub const SUBLANG_GERMAN: WORD = 0x01; +pub const SUBLANG_GERMAN_SWISS: WORD = 0x02; +pub const SUBLANG_GERMAN_AUSTRIAN: WORD = 0x03; +pub const SUBLANG_GERMAN_LUXEMBOURG: WORD = 0x04; +pub const SUBLANG_GERMAN_LIECHTENSTEIN: WORD = 0x05; +pub const SUBLANG_GREEK_GREECE: WORD = 0x01; +pub const SUBLANG_GREENLANDIC_GREENLAND: WORD = 0x01; +pub const SUBLANG_GUJARATI_INDIA: WORD = 0x01; +pub const SUBLANG_HAUSA_NIGERIA_LATIN: WORD = 0x01; +pub const SUBLANG_HAWAIIAN_US: WORD = 0x01; +pub const SUBLANG_HEBREW_ISRAEL: WORD = 0x01; +pub const SUBLANG_HINDI_INDIA: WORD = 0x01; +pub const SUBLANG_HUNGARIAN_HUNGARY: WORD = 0x01; +pub const SUBLANG_ICELANDIC_ICELAND: WORD = 0x01; +pub const SUBLANG_IGBO_NIGERIA: WORD = 0x01; +pub const SUBLANG_INDONESIAN_INDONESIA: WORD = 0x01; +pub const SUBLANG_INUKTITUT_CANADA: WORD = 0x01; +pub const SUBLANG_INUKTITUT_CANADA_LATIN: WORD = 0x02; +pub const SUBLANG_IRISH_IRELAND: WORD = 0x02; +pub const SUBLANG_ITALIAN: WORD = 0x01; +pub const SUBLANG_ITALIAN_SWISS: WORD = 0x02; +pub const SUBLANG_JAPANESE_JAPAN: WORD = 0x01; +pub const SUBLANG_KANNADA_INDIA: WORD = 0x01; +pub const SUBLANG_KASHMIRI_SASIA: WORD = 0x02; +pub const SUBLANG_KASHMIRI_INDIA: WORD = 0x02; +pub const SUBLANG_KAZAK_KAZAKHSTAN: WORD = 0x01; +pub const SUBLANG_KHMER_CAMBODIA: WORD = 0x01; +pub const SUBLANG_KICHE_GUATEMALA: WORD = 0x01; +pub const SUBLANG_KINYARWANDA_RWANDA: WORD = 0x01; +pub const SUBLANG_KONKANI_INDIA: WORD = 0x01; +pub const SUBLANG_KOREAN: WORD = 0x01; +pub const SUBLANG_KYRGYZ_KYRGYZSTAN: WORD = 0x01; +pub const SUBLANG_LAO_LAO: WORD = 0x01; +pub const SUBLANG_LATVIAN_LATVIA: WORD = 0x01; +pub const SUBLANG_LITHUANIAN: WORD = 0x01; +pub const SUBLANG_LOWER_SORBIAN_GERMANY: WORD = 0x02; +pub const SUBLANG_LUXEMBOURGISH_LUXEMBOURG: WORD = 0x01; +pub const SUBLANG_MACEDONIAN_MACEDONIA: WORD = 0x01; +pub const SUBLANG_MALAY_MALAYSIA: WORD = 0x01; +pub const SUBLANG_MALAY_BRUNEI_DARUSSALAM: WORD = 0x02; +pub const SUBLANG_MALAYALAM_INDIA: WORD = 0x01; +pub const SUBLANG_MALTESE_MALTA: WORD = 0x01; +pub const SUBLANG_MAORI_NEW_ZEALAND: WORD = 0x01; +pub const SUBLANG_MAPUDUNGUN_CHILE: WORD = 0x01; +pub const SUBLANG_MARATHI_INDIA: WORD = 0x01; +pub const SUBLANG_MOHAWK_MOHAWK: WORD = 0x01; +pub const SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA: WORD = 0x01; +pub const SUBLANG_MONGOLIAN_PRC: WORD = 0x02; +pub const SUBLANG_NEPALI_INDIA: WORD = 0x02; +pub const SUBLANG_NEPALI_NEPAL: WORD = 0x01; +pub const SUBLANG_NORWEGIAN_BOKMAL: WORD = 0x01; +pub const SUBLANG_NORWEGIAN_NYNORSK: WORD = 0x02; +pub const SUBLANG_OCCITAN_FRANCE: WORD = 0x01; +pub const SUBLANG_ODIA_INDIA: WORD = 0x01; +pub const SUBLANG_ORIYA_INDIA: WORD = 0x01; +pub const SUBLANG_PASHTO_AFGHANISTAN: WORD = 0x01; +pub const SUBLANG_PERSIAN_IRAN: WORD = 0x01; +pub const SUBLANG_POLISH_POLAND: WORD = 0x01; +pub const SUBLANG_PORTUGUESE: WORD = 0x02; +pub const SUBLANG_PORTUGUESE_BRAZILIAN: WORD = 0x01; +pub const SUBLANG_PULAR_SENEGAL: WORD = 0x02; +pub const SUBLANG_PUNJABI_INDIA: WORD = 0x01; +pub const SUBLANG_PUNJABI_PAKISTAN: WORD = 0x02; +pub const SUBLANG_QUECHUA_BOLIVIA: WORD = 0x01; +pub const SUBLANG_QUECHUA_ECUADOR: WORD = 0x02; +pub const SUBLANG_QUECHUA_PERU: WORD = 0x03; +pub const SUBLANG_ROMANIAN_ROMANIA: WORD = 0x01; +pub const SUBLANG_ROMANSH_SWITZERLAND: WORD = 0x01; +pub const SUBLANG_RUSSIAN_RUSSIA: WORD = 0x01; +pub const SUBLANG_SAKHA_RUSSIA: WORD = 0x01; +pub const SUBLANG_SAMI_NORTHERN_NORWAY: WORD = 0x01; +pub const SUBLANG_SAMI_NORTHERN_SWEDEN: WORD = 0x02; +pub const SUBLANG_SAMI_NORTHERN_FINLAND: WORD = 0x03; +pub const SUBLANG_SAMI_LULE_NORWAY: WORD = 0x04; +pub const SUBLANG_SAMI_LULE_SWEDEN: WORD = 0x05; +pub const SUBLANG_SAMI_SOUTHERN_NORWAY: WORD = 0x06; +pub const SUBLANG_SAMI_SOUTHERN_SWEDEN: WORD = 0x07; +pub const SUBLANG_SAMI_SKOLT_FINLAND: WORD = 0x08; +pub const SUBLANG_SAMI_INARI_FINLAND: WORD = 0x09; +pub const SUBLANG_SANSKRIT_INDIA: WORD = 0x01; +pub const SUBLANG_SCOTTISH_GAELIC: WORD = 0x01; +pub const SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN: WORD = 0x06; +pub const SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC: WORD = 0x07; +pub const SUBLANG_SERBIAN_MONTENEGRO_LATIN: WORD = 0x0b; +pub const SUBLANG_SERBIAN_MONTENEGRO_CYRILLIC: WORD = 0x0c; +pub const SUBLANG_SERBIAN_SERBIA_LATIN: WORD = 0x09; +pub const SUBLANG_SERBIAN_SERBIA_CYRILLIC: WORD = 0x0a; +pub const SUBLANG_SERBIAN_CROATIA: WORD = 0x01; +pub const SUBLANG_SERBIAN_LATIN: WORD = 0x02; +pub const SUBLANG_SERBIAN_CYRILLIC: WORD = 0x03; +pub const SUBLANG_SINDHI_INDIA: WORD = 0x01; +pub const SUBLANG_SINDHI_PAKISTAN: WORD = 0x02; +pub const SUBLANG_SINDHI_AFGHANISTAN: WORD = 0x02; +pub const SUBLANG_SINHALESE_SRI_LANKA: WORD = 0x01; +pub const SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA: WORD = 0x01; +pub const SUBLANG_SLOVAK_SLOVAKIA: WORD = 0x01; +pub const SUBLANG_SLOVENIAN_SLOVENIA: WORD = 0x01; +pub const SUBLANG_SPANISH: WORD = 0x01; +pub const SUBLANG_SPANISH_MEXICAN: WORD = 0x02; +pub const SUBLANG_SPANISH_MODERN: WORD = 0x03; +pub const SUBLANG_SPANISH_GUATEMALA: WORD = 0x04; +pub const SUBLANG_SPANISH_COSTA_RICA: WORD = 0x05; +pub const SUBLANG_SPANISH_PANAMA: WORD = 0x06; +pub const SUBLANG_SPANISH_DOMINICAN_REPUBLIC: WORD = 0x07; +pub const SUBLANG_SPANISH_VENEZUELA: WORD = 0x08; +pub const SUBLANG_SPANISH_COLOMBIA: WORD = 0x09; +pub const SUBLANG_SPANISH_PERU: WORD = 0x0a; +pub const SUBLANG_SPANISH_ARGENTINA: WORD = 0x0b; +pub const SUBLANG_SPANISH_ECUADOR: WORD = 0x0c; +pub const SUBLANG_SPANISH_CHILE: WORD = 0x0d; +pub const SUBLANG_SPANISH_URUGUAY: WORD = 0x0e; +pub const SUBLANG_SPANISH_PARAGUAY: WORD = 0x0f; +pub const SUBLANG_SPANISH_BOLIVIA: WORD = 0x10; +pub const SUBLANG_SPANISH_EL_SALVADOR: WORD = 0x11; +pub const SUBLANG_SPANISH_HONDURAS: WORD = 0x12; +pub const SUBLANG_SPANISH_NICARAGUA: WORD = 0x13; +pub const SUBLANG_SPANISH_PUERTO_RICO: WORD = 0x14; +pub const SUBLANG_SPANISH_US: WORD = 0x15; +pub const SUBLANG_SWAHILI_KENYA: WORD = 0x01; +pub const SUBLANG_SWEDISH: WORD = 0x01; +pub const SUBLANG_SWEDISH_FINLAND: WORD = 0x02; +pub const SUBLANG_SYRIAC_SYRIA: WORD = 0x01; +pub const SUBLANG_TAJIK_TAJIKISTAN: WORD = 0x01; +pub const SUBLANG_TAMAZIGHT_ALGERIA_LATIN: WORD = 0x02; +pub const SUBLANG_TAMAZIGHT_MOROCCO_TIFINAGH: WORD = 0x04; +pub const SUBLANG_TAMIL_INDIA: WORD = 0x01; +pub const SUBLANG_TAMIL_SRI_LANKA: WORD = 0x02; +pub const SUBLANG_TATAR_RUSSIA: WORD = 0x01; +pub const SUBLANG_TELUGU_INDIA: WORD = 0x01; +pub const SUBLANG_THAI_THAILAND: WORD = 0x01; +pub const SUBLANG_TIBETAN_PRC: WORD = 0x01; +pub const SUBLANG_TIGRIGNA_ERITREA: WORD = 0x02; +pub const SUBLANG_TIGRINYA_ERITREA: WORD = 0x02; +pub const SUBLANG_TIGRINYA_ETHIOPIA: WORD = 0x01; +pub const SUBLANG_TSWANA_BOTSWANA: WORD = 0x02; +pub const SUBLANG_TSWANA_SOUTH_AFRICA: WORD = 0x01; +pub const SUBLANG_TURKISH_TURKEY: WORD = 0x01; +pub const SUBLANG_TURKMEN_TURKMENISTAN: WORD = 0x01; +pub const SUBLANG_UIGHUR_PRC: WORD = 0x01; +pub const SUBLANG_UKRAINIAN_UKRAINE: WORD = 0x01; +pub const SUBLANG_UPPER_SORBIAN_GERMANY: WORD = 0x01; +pub const SUBLANG_URDU_PAKISTAN: WORD = 0x01; +pub const SUBLANG_URDU_INDIA: WORD = 0x02; +pub const SUBLANG_UZBEK_LATIN: WORD = 0x01; +pub const SUBLANG_UZBEK_CYRILLIC: WORD = 0x02; +pub const SUBLANG_VALENCIAN_VALENCIA: WORD = 0x02; +pub const SUBLANG_VIETNAMESE_VIETNAM: WORD = 0x01; +pub const SUBLANG_WELSH_UNITED_KINGDOM: WORD = 0x01; +pub const SUBLANG_WOLOF_SENEGAL: WORD = 0x01; +pub const SUBLANG_XHOSA_SOUTH_AFRICA: WORD = 0x01; +pub const SUBLANG_YAKUT_RUSSIA: WORD = 0x01; +pub const SUBLANG_YI_PRC: WORD = 0x01; +pub const SUBLANG_YORUBA_NIGERIA: WORD = 0x01; +pub const SUBLANG_ZULU_SOUTH_AFRICA: WORD = 0x01; +pub const SORT_DEFAULT: WORD = 0x0; +pub const SORT_INVARIANT_MATH: WORD = 0x1; +pub const SORT_JAPANESE_XJIS: WORD = 0x0; +pub const SORT_JAPANESE_UNICODE: WORD = 0x1; +pub const SORT_JAPANESE_RADICALSTROKE: WORD = 0x4; +pub const SORT_CHINESE_BIG5: WORD = 0x0; +pub const SORT_CHINESE_PRCP: WORD = 0x0; +pub const SORT_CHINESE_UNICODE: WORD = 0x1; +pub const SORT_CHINESE_PRC: WORD = 0x2; +pub const SORT_CHINESE_BOPOMOFO: WORD = 0x3; +pub const SORT_CHINESE_RADICALSTROKE: WORD = 0x4; +pub const SORT_KOREAN_KSC: WORD = 0x0; +pub const SORT_KOREAN_UNICODE: WORD = 0x1; +pub const SORT_GERMAN_PHONE_BOOK: WORD = 0x1; +pub const SORT_HUNGARIAN_DEFAULT: WORD = 0x0; +pub const SORT_HUNGARIAN_TECHNICAL: WORD = 0x1; +pub const SORT_GEORGIAN_TRADITIONAL: WORD = 0x0; +pub const SORT_GEORGIAN_MODERN: WORD = 0x1; +macro_rules! MAKELANGID { ($p:expr, $s:expr) => (($s << 10) | $p) } +#[inline] +pub fn MAKELANGID(p: WORD, s: WORD) -> LANGID { + (s << 10) | p +} +#[inline] +pub fn PRIMARYLANGID(lgid: LANGID) -> WORD { + lgid & 0x3ff +} +#[inline] +pub fn SUBLANGID(lgid: LANGID) -> WORD { + lgid >> 10 +} +pub const NLS_VALID_LOCALE_MASK: DWORD = 0x000fffff; +macro_rules! MAKELCID { + ($lgid:expr, $srtid:expr) => ((($srtid as DWORD) << 16) | ($lgid as DWORD)) +} +#[inline] +pub fn MAKELCID(lgid: LANGID, srtid: WORD) -> LCID { + ((srtid as DWORD) << 16) | (lgid as DWORD) +} +#[inline] +pub fn MAKESORTLCID(lgid: LANGID, srtid: WORD, ver: WORD) -> LCID { + MAKELCID(lgid, srtid) | ((ver as DWORD) << 20) +} +#[inline] +pub fn LANGIDFROMLCID(lcid: LCID) -> LANGID { + lcid as LANGID +} +#[inline] +pub fn SORTIDFROMLCID(lcid: LCID) -> WORD { + ((lcid >> 16) & 0xf) as WORD +} +#[inline] +pub fn SORTVERSIONFROMLCID(lcid: LCID) -> WORD { + ((lcid >> 16) & 0xf) as WORD +} +pub const LOCALE_NAME_MAX_LENGTH: usize = 85; +pub const LANG_SYSTEM_DEFAULT: LANGID = MAKELANGID!(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT); +pub const LANG_USER_DEFAULT: LANGID = MAKELANGID!(LANG_NEUTRAL, SUBLANG_DEFAULT); +pub const LOCALE_SYSTEM_DEFAULT: LCID = MAKELCID!(LANG_SYSTEM_DEFAULT, SORT_DEFAULT); +pub const LOCALE_USER_DEFAULT: LCID = MAKELCID!(LANG_USER_DEFAULT, SORT_DEFAULT); +pub const LOCALE_CUSTOM_DEFAULT: LCID + = MAKELCID!(MAKELANGID!(LANG_NEUTRAL, SUBLANG_CUSTOM_DEFAULT), SORT_DEFAULT); +pub const LOCALE_CUSTOM_UNSPECIFIED: LCID + = MAKELCID!(MAKELANGID!(LANG_NEUTRAL, SUBLANG_CUSTOM_UNSPECIFIED), SORT_DEFAULT); +pub const LOCALE_CUSTOM_UI_DEFAULT: LCID + = MAKELCID!(MAKELANGID!(LANG_NEUTRAL, SUBLANG_UI_CUSTOM_DEFAULT), SORT_DEFAULT); +pub const LOCALE_NEUTRAL: LCID + = MAKELCID!(MAKELANGID!(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT); +pub const LOCALE_INVARIANT: LCID + = MAKELCID!(MAKELANGID!(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT); +pub const LOCALE_TRANSIENT_KEYBOARD1: LCID = 0x2000; +pub const LOCALE_TRANSIENT_KEYBOARD2: LCID = 0x2400; +pub const LOCALE_TRANSIENT_KEYBOARD3: LCID = 0x2800; +pub const LOCALE_TRANSIENT_KEYBOARD4: LCID = 0x2c00; +pub const LOCALE_UNASSIGNED_LCID: LCID = LOCALE_CUSTOM_UNSPECIFIED; +pub const STATUS_WAIT_0: DWORD = 0x00000000; +pub const STATUS_ABANDONED_WAIT_0: DWORD = 0x00000080; +pub const STATUS_USER_APC: DWORD = 0x000000C0; +pub const STATUS_TIMEOUT: DWORD = 0x00000102; +pub const STATUS_PENDING: DWORD = 0x00000103; +pub const DBG_EXCEPTION_HANDLED: DWORD = 0x00010001; +pub const DBG_CONTINUE: DWORD = 0x00010002; +pub const STATUS_SEGMENT_NOTIFICATION: DWORD = 0x40000005; +pub const STATUS_FATAL_APP_EXIT: DWORD = 0x40000015; +pub const DBG_REPLY_LATER: DWORD = 0x40010001; +pub const DBG_TERMINATE_THREAD: DWORD = 0x40010003; +pub const DBG_TERMINATE_PROCESS: DWORD = 0x40010004; +pub const DBG_CONTROL_C: DWORD = 0x40010005; +pub const DBG_PRINTEXCEPTION_C: DWORD = 0x40010006; +pub const DBG_RIPEXCEPTION: DWORD = 0x40010007; +pub const DBG_CONTROL_BREAK: DWORD = 0x40010008; +pub const DBG_COMMAND_EXCEPTION: DWORD = 0x40010009; +pub const DBG_PRINTEXCEPTION_WIDE_C: DWORD = 0x4001000A; +pub const STATUS_GUARD_PAGE_VIOLATION: DWORD = 0x80000001; +pub const STATUS_DATATYPE_MISALIGNMENT: DWORD = 0x80000002; +pub const STATUS_BREAKPOINT: DWORD = 0x80000003; +pub const STATUS_SINGLE_STEP: DWORD = 0x80000004; +pub const STATUS_LONGJUMP: DWORD = 0x80000026; +pub const STATUS_UNWIND_CONSOLIDATE: DWORD = 0x80000029; +pub const DBG_EXCEPTION_NOT_HANDLED: DWORD = 0x80010001; +pub const STATUS_ACCESS_VIOLATION: DWORD = 0xC0000005; +pub const STATUS_IN_PAGE_ERROR: DWORD = 0xC0000006; +pub const STATUS_INVALID_HANDLE: DWORD = 0xC0000008; +pub const STATUS_INVALID_PARAMETER: DWORD = 0xC000000D; +pub const STATUS_NO_MEMORY: DWORD = 0xC0000017; +pub const STATUS_ILLEGAL_INSTRUCTION: DWORD = 0xC000001D; +pub const STATUS_NONCONTINUABLE_EXCEPTION: DWORD = 0xC0000025; +pub const STATUS_INVALID_DISPOSITION: DWORD = 0xC0000026; +pub const STATUS_ARRAY_BOUNDS_EXCEEDED: DWORD = 0xC000008C; +pub const STATUS_FLOAT_DENORMAL_OPERAND: DWORD = 0xC000008D; +pub const STATUS_FLOAT_DIVIDE_BY_ZERO: DWORD = 0xC000008E; +pub const STATUS_FLOAT_INEXACT_RESULT: DWORD = 0xC000008F; +pub const STATUS_FLOAT_INVALID_OPERATION: DWORD = 0xC0000090; +pub const STATUS_FLOAT_OVERFLOW: DWORD = 0xC0000091; +pub const STATUS_FLOAT_STACK_CHECK: DWORD = 0xC0000092; +pub const STATUS_FLOAT_UNDERFLOW: DWORD = 0xC0000093; +pub const STATUS_INTEGER_DIVIDE_BY_ZERO: DWORD = 0xC0000094; +pub const STATUS_INTEGER_OVERFLOW: DWORD = 0xC0000095; +pub const STATUS_PRIVILEGED_INSTRUCTION: DWORD = 0xC0000096; +pub const STATUS_STACK_OVERFLOW: DWORD = 0xC00000FD; +pub const STATUS_DLL_NOT_FOUND: DWORD = 0xC0000135; +pub const STATUS_ORDINAL_NOT_FOUND: DWORD = 0xC0000138; +pub const STATUS_ENTRYPOINT_NOT_FOUND: DWORD = 0xC0000139; +pub const STATUS_CONTROL_C_EXIT: DWORD = 0xC000013A; +pub const STATUS_DLL_INIT_FAILED: DWORD = 0xC0000142; +pub const STATUS_FLOAT_MULTIPLE_FAULTS: DWORD = 0xC00002B4; +pub const STATUS_FLOAT_MULTIPLE_TRAPS: DWORD = 0xC00002B5; +pub const STATUS_REG_NAT_CONSUMPTION: DWORD = 0xC00002C9; +pub const STATUS_HEAP_CORRUPTION: DWORD = 0xC0000374; +pub const STATUS_STACK_BUFFER_OVERRUN: DWORD = 0xC0000409; +pub const STATUS_INVALID_CRUNTIME_PARAMETER: DWORD = 0xC0000417; +pub const STATUS_ASSERTION_FAILURE: DWORD = 0xC0000420; +pub const STATUS_SXS_EARLY_DEACTIVATION: DWORD = 0xC015000F; +pub const STATUS_SXS_INVALID_DEACTIVATION: DWORD = 0xC0150010; +pub const MAXIMUM_WAIT_OBJECTS: DWORD = 64; +pub const MAXIMUM_SUSPEND_COUNT: CHAR = MAXCHAR; +pub type KSPIN_LOCK = ULONG_PTR; +pub type PKSPIN_LOCK = *mut KSPIN_LOCK; +STRUCT!{struct M128A { // FIXME align 16 + Low: ULONGLONG, + High: LONGLONG, +}} +pub type PM128A = *mut M128A; +#[cfg(target_pointer_width = "32")] +STRUCT!{struct XSAVE_FORMAT { // FIXME align 16 + ControlWord: WORD, + StatusWord: WORD, + TagWord: BYTE, + Reserved1: BYTE, + ErrorOpcode: WORD, + ErrorOffset: DWORD, + ErrorSelector: WORD, + Reserved2: WORD, + DataOffset: DWORD, + DataSelector: WORD, + Reserved3: WORD, + MxCsr: DWORD, + MxCsr_Mask: DWORD, + FloatRegisters: [M128A; 8], + XmmRegisters: [M128A; 8], + Reserved4: [BYTE; 224], +}} +#[cfg(target_pointer_width = "64")] +STRUCT!{struct XSAVE_FORMAT { // FIXME align 16 + ControlWord: WORD, + StatusWord: WORD, + TagWord: BYTE, + Reserved1: BYTE, + ErrorOpcode: WORD, + ErrorOffset: DWORD, + ErrorSelector: WORD, + Reserved2: WORD, + DataOffset: DWORD, + DataSelector: WORD, + Reserved3: WORD, + MxCsr: DWORD, + MxCsr_Mask: DWORD, + FloatRegisters: [M128A; 8], + XmmRegisters: [M128A; 16], + Reserved4: [BYTE; 96], +}} +#[cfg(target_arch = "x86")] +STRUCT!{struct XSTATE_CONTEXT { + Mask: DWORD64, + Length: DWORD, + Reserved1: DWORD, + Area: PXSAVE_AREA, + Reserved2: DWORD, + Buffer: PVOID, + Reserved3: DWORD, +}} +#[cfg(not(target_arch = "x86"))] +STRUCT!{struct XSTATE_CONTEXT { + Mask: DWORD64, + Length: DWORD, + Reserved1: DWORD, + Area: PXSAVE_AREA, + Buffer: PVOID, +}} +pub type PXSAVE_FORMAT = *mut XSAVE_FORMAT; +STRUCT!{struct XSAVE_AREA_HEADER { // FIXME align 8 + Mask: DWORD64, + CompactionMask: DWORD64, + Reserved2: [DWORD64; 6], +}} +pub type PXSAVE_AREA_HEADER = *mut XSAVE_AREA_HEADER; +STRUCT!{struct XSAVE_AREA { // FIXME align 16 + LegacyState: XSAVE_FORMAT, + Header: XSAVE_AREA_HEADER, +}} +pub type PXSAVE_AREA = *mut XSAVE_AREA; +pub type PXSTATE_CONTEXT = *mut XSTATE_CONTEXT; +STRUCT!{struct SCOPE_TABLE_AMD64 { + Count: DWORD, + ScopeRecord: [SCOPE_TABLE_AMD64_ScopeRecord; 1], +}} +STRUCT!{struct SCOPE_TABLE_AMD64_ScopeRecord { + BeginAddress: DWORD, + EndAddress: DWORD, + HandlerAddress: DWORD, + JumpTarget: DWORD, +}} +pub type PSCOPE_TABLE_AMD64 = *mut SCOPE_TABLE_AMD64; +STRUCT!{struct SCOPE_TABLE_ARM64 { + Count: DWORD, + ScopeRecord: [SCOPE_TABLE_ARM64_ScopeRecord; 1], +}} +STRUCT!{struct SCOPE_TABLE_ARM64_ScopeRecord { + BeginAddress: DWORD, + EndAddress: DWORD, + HandlerAddress: DWORD, + JumpTarget: DWORD, +}} +pub type PSCOPE_TABLE_ARM64 = *mut SCOPE_TABLE_ARM64; +// Skip interlocked and bit manipulation stuff because it is all intrinsics +// Use the native Rust equivalents instead +#[cfg(target_arch = "x86_64")] +IFDEF!{ +pub const EXCEPTION_READ_FAULT: DWORD = 0; +pub const EXCEPTION_WRITE_FAULT: DWORD = 1; +pub const EXCEPTION_EXECUTE_FAULT: DWORD = 8; +pub const CONTEXT_AMD64: DWORD = 0x00100000; +pub const CONTEXT_CONTROL: DWORD = CONTEXT_AMD64 | 0x00000001; +pub const CONTEXT_INTEGER: DWORD = CONTEXT_AMD64 | 0x00000002; +pub const CONTEXT_SEGMENTS: DWORD = CONTEXT_AMD64 | 0x00000004; +pub const CONTEXT_FLOATING_POINT: DWORD = CONTEXT_AMD64 | 0x00000008; +pub const CONTEXT_DEBUG_REGISTERS: DWORD = CONTEXT_AMD64 | 0x00000010; +pub const CONTEXT_FULL: DWORD = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT; +pub const CONTEXT_ALL: DWORD = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS + | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS; +pub const CONTEXT_XSTATE: DWORD = CONTEXT_AMD64 | 0x00000040; +pub const CONTEXT_EXCEPTION_ACTIVE: DWORD = 0x08000000; +pub const CONTEXT_SERVICE_ACTIVE: DWORD = 0x10000000; +pub const CONTEXT_EXCEPTION_REQUEST: DWORD = 0x40000000; +pub const CONTEXT_EXCEPTION_REPORTING: DWORD = 0x80000000; +pub const INITIAL_MXCSR: DWORD = 0x1f80; +pub const INITIAL_FPCSR: DWORD = 0x027f; +pub type XMM_SAVE_AREA32 = XSAVE_FORMAT; +pub type PXMM_SAVE_AREA32 = *mut XSAVE_FORMAT; +STRUCT!{struct CONTEXT_u_s { + Header: [M128A; 2], + Legacy: [M128A; 8], + Xmm0: M128A, + Xmm1: M128A, + Xmm2: M128A, + Xmm3: M128A, + Xmm4: M128A, + Xmm5: M128A, + Xmm6: M128A, + Xmm7: M128A, + Xmm8: M128A, + Xmm9: M128A, + Xmm10: M128A, + Xmm11: M128A, + Xmm12: M128A, + Xmm13: M128A, + Xmm14: M128A, + Xmm15: M128A, +}} +UNION!{union CONTEXT_u { + [u64; 64], + FltSave FltSave_mut: XMM_SAVE_AREA32, + s s_mut: CONTEXT_u_s, +}} +STRUCT!{struct CONTEXT { // FIXME align 16 + P1Home: DWORD64, + P2Home: DWORD64, + P3Home: DWORD64, + P4Home: DWORD64, + P5Home: DWORD64, + P6Home: DWORD64, + ContextFlags: DWORD, + MxCsr: DWORD, + SegCs: WORD, + SegDs: WORD, + SegEs: WORD, + SegFs: WORD, + SegGs: WORD, + SegSs: WORD, + EFlags: DWORD, + Dr0: DWORD64, + Dr1: DWORD64, + Dr2: DWORD64, + Dr3: DWORD64, + Dr6: DWORD64, + Dr7: DWORD64, + Rax: DWORD64, + Rcx: DWORD64, + Rdx: DWORD64, + Rbx: DWORD64, + Rsp: DWORD64, + Rbp: DWORD64, + Rsi: DWORD64, + Rdi: DWORD64, + R8: DWORD64, + R9: DWORD64, + R10: DWORD64, + R11: DWORD64, + R12: DWORD64, + R13: DWORD64, + R14: DWORD64, + R15: DWORD64, + Rip: DWORD64, + u: CONTEXT_u, + VectorRegister: [M128A; 26], + VectorControl: DWORD64, + DebugControl: DWORD64, + LastBranchToRip: DWORD64, + LastBranchFromRip: DWORD64, + LastExceptionToRip: DWORD64, + LastExceptionFromRip: DWORD64, +}} +pub type PCONTEXT = *mut CONTEXT; +pub type RUNTIME_FUNCTION = IMAGE_RUNTIME_FUNCTION_ENTRY; +pub type PRUNTIME_FUNCTION = *mut IMAGE_RUNTIME_FUNCTION_ENTRY; +pub type SCOPE_TABLE = SCOPE_TABLE_AMD64; +pub type PSCOPE_TABLE = *mut SCOPE_TABLE_AMD64; +pub const RUNTIME_FUNCTION_INDIRECT: DWORD = 0x1; +pub const UNW_FLAG_NHANDLER: DWORD = 0x0; +pub const UNW_FLAG_EHANDLER: DWORD = 0x1; +pub const UNW_FLAG_UHANDLER: DWORD = 0x2; +pub const UNW_FLAG_CHAININFO: DWORD = 0x4; +pub const UNW_FLAG_NO_EPILOGUE: DWORD = 0x80000000; +pub const UNWIND_HISTORY_TABLE_SIZE: usize = 12; +STRUCT!{struct UNWIND_HISTORY_TABLE_ENTRY { + ImageBase: DWORD64, + FunctionEntry: PRUNTIME_FUNCTION, +}} +pub type PUNWIND_HISTORY_TABLE_ENTRY = *mut UNWIND_HISTORY_TABLE_ENTRY; +STRUCT!{struct UNWIND_HISTORY_TABLE { + Count: DWORD, + LocalHint: BYTE, + GlobalHint: BYTE, + Search: BYTE, + Once: BYTE, + LowAddress: DWORD64, + HighAddress: DWORD64, + Entry: [UNWIND_HISTORY_TABLE_ENTRY; UNWIND_HISTORY_TABLE_SIZE], +}} +pub type PUNWIND_HISTORY_TABLE = *mut UNWIND_HISTORY_TABLE; +FN!{cdecl PGET_RUNTIME_FUNCTION_CALLBACK( + ControlPc: DWORD64, + Context: PVOID, +) -> PRUNTIME_FUNCTION} +FN!{cdecl POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK( + Process: HANDLE, + TableAddress: PVOID, + Entries: PDWORD, + Functions: *mut PRUNTIME_FUNCTION, +) -> DWORD} +pub const OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME: &'static str + = "OutOfProcessFunctionTableCallback"; +STRUCT!{struct DISPATCHER_CONTEXT { + ControlPc: DWORD64, + ImageBase: DWORD64, + FunctionEntry: PRUNTIME_FUNCTION, + EstablisherFrame: DWORD64, + TargetIp: DWORD64, + ContextRecord: PCONTEXT, + LanguageHandler: PEXCEPTION_ROUTINE, + HandlerData: PVOID, + HistoryTable: PUNWIND_HISTORY_TABLE, + ScopeIndex: DWORD, + Fill0: DWORD, +}} +pub type PDISPATCHER_CONTEXT = *mut DISPATCHER_CONTEXT; +FN!{cdecl PEXCEPTION_FILTER( + ExceptionPointers: *mut EXCEPTION_POINTERS, + EstablisherFrame: PVOID, +) -> LONG} +FN!{cdecl PTERMINATION_HANDLER( + AbnormalTermination: BOOLEAN, + EstablisherFrame: PVOID, +) -> ()} +STRUCT!{struct KNONVOLATILE_CONTEXT_POINTERS_u1_s { + Xmm0: PM128A, + Xmm1: PM128A, + Xmm2: PM128A, + Xmm3: PM128A, + Xmm4: PM128A, + Xmm5: PM128A, + Xmm6: PM128A, + Xmm7: PM128A, + Xmm8: PM128A, + Xmm9: PM128A, + Xmm10: PM128A, + Xmm11: PM128A, + Xmm12: PM128A, + Xmm13: PM128A, + Xmm14: PM128A, + Xmm15: PM128A, +}} +UNION!{union KNONVOLATILE_CONTEXT_POINTERS_u1 { + [u64; 16], + FloatingContext FloatingContext_mut: [PM128A; 16], + s s_mut: KNONVOLATILE_CONTEXT_POINTERS_u1_s, +}} +STRUCT!{struct KNONVOLATILE_CONTEXT_POINTERS_u2_s { + Rax: PDWORD64, + Rcx: PDWORD64, + Rdx: PDWORD64, + Rbx: PDWORD64, + Rsp: PDWORD64, + Rbp: PDWORD64, + Rsi: PDWORD64, + Rdi: PDWORD64, + R8: PDWORD64, + R9: PDWORD64, + R10: PDWORD64, + R11: PDWORD64, + R12: PDWORD64, + R13: PDWORD64, + R14: PDWORD64, + R15: PDWORD64, +}} +UNION!{union KNONVOLATILE_CONTEXT_POINTERS_u2 { + [u64; 16], + IntegerContext IntegerContext_mut: [PDWORD64; 16], + s s_mut: KNONVOLATILE_CONTEXT_POINTERS_u2_s, +}} +STRUCT!{struct KNONVOLATILE_CONTEXT_POINTERS { + u1: KNONVOLATILE_CONTEXT_POINTERS_u1, + u2: KNONVOLATILE_CONTEXT_POINTERS_u2, +}} +pub type PKNONVOLATILE_CONTEXT_POINTERS = *mut KNONVOLATILE_CONTEXT_POINTERS; +} // IFDEF(x86_64) +#[cfg(target_arch = "x86")] +IFDEF!{ +pub const EXCEPTION_READ_FAULT: DWORD = 0; +pub const EXCEPTION_WRITE_FAULT: DWORD = 1; +pub const EXCEPTION_EXECUTE_FAULT: DWORD = 8; +pub const SIZE_OF_80387_REGISTERS: usize = 80; +pub const CONTEXT_i386: DWORD = 0x00010000; +pub const CONTEXT_i486: DWORD = 0x00010000; +pub const CONTEXT_CONTROL: DWORD = CONTEXT_i386 | 0x00000001; +pub const CONTEXT_INTEGER: DWORD = CONTEXT_i386 | 0x00000002; +pub const CONTEXT_SEGMENTS: DWORD = CONTEXT_i386 | 0x00000004; +pub const CONTEXT_FLOATING_POINT: DWORD = CONTEXT_i386 | 0x00000008; +pub const CONTEXT_DEBUG_REGISTERS: DWORD = CONTEXT_i386 | 0x00000010; +pub const CONTEXT_EXTENDED_REGISTERS: DWORD = CONTEXT_i386 | 0x00000020; +pub const CONTEXT_FULL: DWORD = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS; +pub const CONTEXT_ALL: DWORD = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS + | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS; +pub const CONTEXT_XSTATE: DWORD = CONTEXT_i386 | 0x00000040; +pub const CONTEXT_EXCEPTION_ACTIVE: DWORD = 0x08000000; +pub const CONTEXT_SERVICE_ACTIVE: DWORD = 0x10000000; +pub const CONTEXT_EXCEPTION_REQUEST: DWORD = 0x40000000; +pub const CONTEXT_EXCEPTION_REPORTING: DWORD = 0x80000000; +STRUCT!{struct FLOATING_SAVE_AREA { + ControlWord: DWORD, + StatusWord: DWORD, + TagWord: DWORD, + ErrorOffset: DWORD, + ErrorSelector: DWORD, + DataOffset: DWORD, + DataSelector: DWORD, + RegisterArea: [BYTE; SIZE_OF_80387_REGISTERS], + Spare0: DWORD, +}} +pub type PFLOATING_SAVE_AREA = *mut FLOATING_SAVE_AREA; +pub const MAXIMUM_SUPPORTED_EXTENSION: usize = 512; +STRUCT!{struct CONTEXT { + ContextFlags: DWORD, + Dr0: DWORD, + Dr1: DWORD, + Dr2: DWORD, + Dr3: DWORD, + Dr6: DWORD, + Dr7: DWORD, + FloatSave: FLOATING_SAVE_AREA, + SegGs: DWORD, + SegFs: DWORD, + SegEs: DWORD, + SegDs: DWORD, + Edi: DWORD, + Esi: DWORD, + Ebx: DWORD, + Edx: DWORD, + Ecx: DWORD, + Eax: DWORD, + Ebp: DWORD, + Eip: DWORD, + SegCs: DWORD, + EFlags: DWORD, + Esp: DWORD, + SegSs: DWORD, + ExtendedRegisters: [BYTE; MAXIMUM_SUPPORTED_EXTENSION], +}} +pub type PCONTEXT = *mut CONTEXT; +} // IFDEF(x86) +STRUCT!{struct LDT_ENTRY_Bytes { + BaseMid: BYTE, + Flags1: BYTE, + Flags2: BYTE, + BaseHi: BYTE, +}} +STRUCT!{struct LDT_ENTRY_Bits { + Bitfield: DWORD, +}} +BITFIELD!{LDT_ENTRY_Bits Bitfield: DWORD [ + BaseMid set_BaseMid[0..8], + Type set_Type[8..13], + Dpl set_Dpl[13..15], + Pres set_Pres[15..16], + LimitHi set_LimitHi[16..20], + Sys set_Sys[20..21], + Reserved_0 set_Reserved_0[21..22], + Default_Big set_Default_Big[22..23], + Granularity set_Granularity[23..24], + BaseHi set_BaseHi[24..32], +]} +UNION!{union LDT_ENTRY_HighWord { + [u32; 1], + Bytes Bytes_mut: LDT_ENTRY_Bytes, + Bits Bits_mut: LDT_ENTRY_Bits, +}} +STRUCT!{struct LDT_ENTRY { + LimitLow: WORD, + BaseLow: WORD, + HighWord: LDT_ENTRY_HighWord, +}} +pub type PLDT_ENTRY = *mut LDT_ENTRY; +#[cfg(target_arch = "aarch64")] +IFDEF!{ +pub const ARM64_MAX_BREAKPOINTS: usize = 8; +pub const ARM64_MAX_WATCHPOINTS: usize = 2; +pub const EXCEPTION_READ_FAULT: DWORD = 0; +pub const EXCEPTION_WRITE_FAULT: DWORD = 1; +pub const EXCEPTION_EXECUTE_FAULT: DWORD = 8; +pub const CONTEXT_ARM64: DWORD = 0x00400000; +pub const CONTEXT_CONTROL: DWORD = CONTEXT_ARM64 | 0x00000001; +pub const CONTEXT_INTEGER: DWORD = CONTEXT_ARM64 | 0x00000002; +pub const CONTEXT_FLOATING_POINT: DWORD = CONTEXT_ARM64 | 0x00000004; +pub const CONTEXT_DEBUG_REGISTERS: DWORD = CONTEXT_ARM64 | 0x00000008; +pub const CONTEXT_X18: DWORD = CONTEXT_ARM64 | 0x00000010; +pub const CONTEXT_FULL: DWORD = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT; +pub const CONTEXT_ALL: DWORD = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT + | CONTEXT_DEBUG_REGISTERS | CONTEXT_X18; +pub const CONTEXT_EXCEPTION_ACTIVE: DWORD = 0x08000000; +pub const CONTEXT_SERVICE_ACTIVE: DWORD = 0x10000000; +pub const CONTEXT_EXCEPTION_REQUEST: DWORD = 0x40000000; +pub const CONTEXT_EXCEPTION_REPORTING: DWORD = 0x80000000; +STRUCT!{struct CONTEXT_u_s { + X0: DWORD64, + X1: DWORD64, + X2: DWORD64, + X3: DWORD64, + X4: DWORD64, + X5: DWORD64, + X6: DWORD64, + X7: DWORD64, + X8: DWORD64, + X9: DWORD64, + X10: DWORD64, + X11: DWORD64, + X12: DWORD64, + X13: DWORD64, + X14: DWORD64, + X15: DWORD64, + X16: DWORD64, + X17: DWORD64, + X18: DWORD64, + X19: DWORD64, + X20: DWORD64, + X21: DWORD64, + X22: DWORD64, + X23: DWORD64, + X24: DWORD64, + X25: DWORD64, + X26: DWORD64, + X27: DWORD64, + X28: DWORD64, + Fp: DWORD64, + Lr: DWORD64, +}} +UNION!{union CONTEXT_u { + [u64; 31], + s s_mut: CONTEXT_u_s, +}} +STRUCT!{struct ARM64_NT_NEON128_s { + Low: ULONGLONG, + High: LONGLONG, +}} +UNION!{union ARM64_NT_NEON128 { + [u64; 2], + s s_mut: ARM64_NT_NEON128_s, + D D_mut: [f64; 2], + S S_mut: [f32; 4], + H H_mut: [WORD; 8], + B B_mut: [BYTE; 16], +}} +STRUCT!{struct CONTEXT { // FIXME align 16 + ContextFlags: DWORD, + Cpsr: DWORD, + u: CONTEXT_u, + Sp: DWORD64, + Pc: DWORD64, + V: [ARM64_NT_NEON128; 32], + Fpcr: DWORD, + Fpsr: DWORD, + Bcr: [DWORD; ARM64_MAX_BREAKPOINTS], + Bvr: [DWORD64; ARM64_MAX_BREAKPOINTS], + Wcr: [DWORD; ARM64_MAX_WATCHPOINTS], + Wvr: [DWORD64; ARM64_MAX_WATCHPOINTS], +}} +pub type PCONTEXT = *mut CONTEXT; +pub type RUNTIME_FUNCTION = IMAGE_RUNTIME_FUNCTION_ENTRY; +pub type PRUNTIME_FUNCTION = *mut IMAGE_RUNTIME_FUNCTION_ENTRY; +pub type SCOPE_TABLE = SCOPE_TABLE_ARM64; +pub type PSCOPE_TABLE = *mut SCOPE_TABLE_ARM64; +pub const RUNTIME_FUNCTION_INDIRECT: DWORD = 0x1; +pub const UNW_FLAG_NHANDLER: DWORD = 0x0; +pub const UNW_FLAG_EHANDLER: DWORD = 0x1; +pub const UNW_FLAG_UHANDLER: DWORD = 0x2; +pub const UNWIND_HISTORY_TABLE_SIZE: usize = 12; +STRUCT!{struct UNWIND_HISTORY_TABLE_ENTRY { + ImageBase: DWORD64, + FunctionEntry: PRUNTIME_FUNCTION, +}} +pub type PUNWIND_HISTORY_TABLE_ENTRY = *mut UNWIND_HISTORY_TABLE_ENTRY; +STRUCT!{struct UNWIND_HISTORY_TABLE { + Count: DWORD, + LocalHint: BYTE, + GlobalHint: BYTE, + Search: BYTE, + Once: BYTE, + LowAddress: DWORD64, + HighAddress: DWORD64, + Entry: [UNWIND_HISTORY_TABLE_ENTRY; UNWIND_HISTORY_TABLE_SIZE], +}} +pub type PUNWIND_HISTORY_TABLE = *mut UNWIND_HISTORY_TABLE; +FN!{cdecl PGET_RUNTIME_FUNCTION_CALLBACK( + ControlPc: DWORD64, + Context: PVOID, +) -> PRUNTIME_FUNCTION} +FN!{cdecl POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK( + Process: HANDLE, + TableAddress: PVOID, + Entries: PDWORD, + Functions: *mut PRUNTIME_FUNCTION, +) -> DWORD} +pub const OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME: &'static str + = "OutOfProcessFunctionTableCallback"; +STRUCT!{struct DISPATCHER_CONTEXT { + ControlPc: ULONG_PTR, + ImageBase: ULONG_PTR, + FunctionEntry: PRUNTIME_FUNCTION, + EstablisherFrame: ULONG_PTR, + TargetPc: ULONG_PTR, + ContextRecord: PCONTEXT, + LanguageHandler: PEXCEPTION_ROUTINE, + HandlerData: PVOID, + HistoryTable: PUNWIND_HISTORY_TABLE, + ScopeIndex: DWORD, + ControlPcIsUnwound: BOOLEAN, + NonVolatileRegisters: PBYTE, +}} +pub type PDISPATCHER_CONTEXT = *mut DISPATCHER_CONTEXT; +FN!{cdecl PEXCEPTION_FILTER( + ExceptionPointers: *mut EXCEPTION_POINTERS, + EstablisherFrame: DWORD64, +) -> LONG} +FN!{cdecl PTERMINATION_HANDLER( + AbnormalTermination: BOOLEAN, + EstablisherFrame: DWORD64, +) -> ()} +STRUCT!{struct KNONVOLATILE_CONTEXT_POINTERS { + X19: PDWORD64, + X20: PDWORD64, + X21: PDWORD64, + X22: PDWORD64, + X23: PDWORD64, + X24: PDWORD64, + X25: PDWORD64, + X26: PDWORD64, + X27: PDWORD64, + X28: PDWORD64, + Fp: PDWORD64, + Lr: PDWORD64, + D8: PDWORD64, + D9: PDWORD64, + D10: PDWORD64, + D11: PDWORD64, + D12: PDWORD64, + D13: PDWORD64, + D14: PDWORD64, + D15: PDWORD64, +}} +pub type PKNONVOLATILE_CONTEXT_POINTERS = *mut KNONVOLATILE_CONTEXT_POINTERS; +} // IFDEF(aarch64) +#[cfg(target_arch = "arm")] +IFDEF!{ +pub const ARM_MAX_BREAKPOINTS: usize = 8; +pub const ARM_MAX_WATCHPOINTS: usize = 1; +STRUCT!{struct NEON128 { + Low: ULONGLONG, + High: LONGLONG, +}} +pub type PNEON128 = *mut NEON128; +UNION!{union CONTEXT_u { + [u64; 32], + Q Q_mut: [NEON128; 16], + D D_mut: [ULONGLONG; 32], + S S_mut: [DWORD; 32], +}} +STRUCT!{struct CONTEXT { + ContextFlags: DWORD, + R0: DWORD, + R1: DWORD, + R2: DWORD, + R3: DWORD, + R4: DWORD, + R5: DWORD, + R6: DWORD, + R7: DWORD, + R8: DWORD, + R9: DWORD, + R10: DWORD, + R11: DWORD, + R12: DWORD, + Sp: DWORD, + Lr: DWORD, + Pc: DWORD, + Cpsr: DWORD, + Fpsrc: DWORD, + Padding: DWORD, + u: CONTEXT_u, + Bvr: [DWORD; ARM_MAX_BREAKPOINTS], + Bcr: [DWORD; ARM_MAX_BREAKPOINTS], + Wvr: [DWORD; ARM_MAX_WATCHPOINTS], + Wcr: [DWORD; ARM_MAX_WATCHPOINTS], + Padding2: [DWORD; 2], +}} +pub type PCONTEXT = *mut CONTEXT; +} // IFDEF(arm) +pub const WOW64_CONTEXT_i386: DWORD = 0x00010000; +pub const WOW64_CONTEXT_i486: DWORD = 0x00010000; +pub const WOW64_CONTEXT_CONTROL: DWORD = WOW64_CONTEXT_i386 | 0x00000001; +pub const WOW64_CONTEXT_INTEGER: DWORD = WOW64_CONTEXT_i386 | 0x00000002; +pub const WOW64_CONTEXT_SEGMENTS: DWORD = WOW64_CONTEXT_i386 | 0x00000004; +pub const WOW64_CONTEXT_FLOATING_POINT: DWORD = WOW64_CONTEXT_i386 | 0x00000008; +pub const WOW64_CONTEXT_DEBUG_REGISTERS: DWORD = WOW64_CONTEXT_i386 | 0x00000010; +pub const WOW64_CONTEXT_EXTENDED_REGISTERS: DWORD = WOW64_CONTEXT_i386 | 0x00000020; +pub const WOW64_CONTEXT_FULL: DWORD = WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER + | WOW64_CONTEXT_SEGMENTS; +pub const WOW64_CONTEXT_ALL: DWORD = WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER + | WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | WOW64_CONTEXT_DEBUG_REGISTERS + | WOW64_CONTEXT_EXTENDED_REGISTERS; +pub const WOW64_CONTEXT_XSTATE: DWORD = WOW64_CONTEXT_i386 | 0x00000040; +pub const WOW64_CONTEXT_EXCEPTION_ACTIVE: DWORD = 0x08000000; +pub const WOW64_CONTEXT_SERVICE_ACTIVE: DWORD = 0x10000000; +pub const WOW64_CONTEXT_EXCEPTION_REQUEST: DWORD = 0x40000000; +pub const WOW64_CONTEXT_EXCEPTION_REPORTING: DWORD = 0x80000000; +pub const WOW64_SIZE_OF_80387_REGISTERS: usize = 80; +pub const WOW64_MAXIMUM_SUPPORTED_EXTENSION: usize = 512; +STRUCT!{struct WOW64_FLOATING_SAVE_AREA { + ControlWord: DWORD, + StatusWord: DWORD, + TagWord: DWORD, + ErrorOffset: DWORD, + ErrorSelector: DWORD, + DataOffset: DWORD, + DataSelector: DWORD, + RegisterArea: [BYTE; WOW64_SIZE_OF_80387_REGISTERS], + Cr0NpxState: DWORD, +}} +pub type PWOW64_FLOATING_SAVE_AREA = *mut WOW64_FLOATING_SAVE_AREA; +STRUCT!{struct WOW64_CONTEXT { + ContextFlags: DWORD, + Dr0: DWORD, + Dr1: DWORD, + Dr2: DWORD, + Dr3: DWORD, + Dr6: DWORD, + Dr7: DWORD, + FloatSave: WOW64_FLOATING_SAVE_AREA, + SegGs: DWORD, + SegFs: DWORD, + SegEs: DWORD, + SegDs: DWORD, + Edi: DWORD, + Esi: DWORD, + Ebx: DWORD, + Edx: DWORD, + Ecx: DWORD, + Eax: DWORD, + Ebp: DWORD, + Eip: DWORD, + SegCs: DWORD, + EFlags: DWORD, + Esp: DWORD, + SegSs: DWORD, + ExtendedRegisters: [BYTE; WOW64_MAXIMUM_SUPPORTED_EXTENSION], +}} +pub type PWOW64_CONTEXT = *mut WOW64_CONTEXT; +STRUCT!{struct WOW64_LDT_ENTRY_Bytes { + BaseMid: BYTE, + Flags1: BYTE, + Flags2: BYTE, + BaseHi: BYTE, +}} +STRUCT!{struct WOW64_LDT_ENTRY_Bits { + BitFields: DWORD, +}} +BITFIELD!{WOW64_LDT_ENTRY_Bits BitFields: DWORD [ + BaseMid set_BaseMid[0..8], + Type set_Type[8..13], + Dpl set_Dpl[13..15], + Pres set_Pres[15..16], + LimitHi set_LimitHi[16..20], + Sys set_Sys[20..21], + Reserved_0 set_Reserved_0[21..22], + Default_Big set_Default_Big[22..23], + Granularity set_Granularity[23..24], + BaseHi set_BaseHi[24..32], +]} +UNION!{union WOW64_LDT_ENTRY_HighWord { + [u32; 1], + Bytes Bytes_mut: WOW64_LDT_ENTRY_Bytes, + Bits Bits_mut: WOW64_LDT_ENTRY_Bits, +}} +STRUCT!{struct WOW64_LDT_ENTRY { + LimitLow: WORD, + BaseLow: WORD, + HighWord: WOW64_LDT_ENTRY_HighWord, +}} +pub type PWOW64_LDT_ENTRY = *mut WOW64_LDT_ENTRY; +STRUCT!{struct WOW64_DESCRIPTOR_TABLE_ENTRY { + Selector: DWORD, + Descriptor: WOW64_LDT_ENTRY, +}} +pub type PWOW64_DESCRIPTOR_TABLE_ENTRY = *mut WOW64_DESCRIPTOR_TABLE_ENTRY; +pub const EXCEPTION_NONCONTINUABLE: DWORD = 0x1; +pub const EXCEPTION_UNWINDING: DWORD = 0x2; +pub const EXCEPTION_EXIT_UNWIND: DWORD = 0x4; +pub const EXCEPTION_STACK_INVALID: DWORD = 0x8; +pub const EXCEPTION_NESTED_CALL: DWORD = 0x10; +pub const EXCEPTION_TARGET_UNWIND: DWORD = 0x20; +pub const EXCEPTION_COLLIDED_UNWIND: DWORD = 0x40; +pub const EXCEPTION_UNWIND: DWORD = EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND + | EXCEPTION_TARGET_UNWIND | EXCEPTION_COLLIDED_UNWIND; +#[inline] +pub fn IS_UNWINDING(Flag: DWORD) -> bool { + (Flag & EXCEPTION_UNWIND) != 0 +} +#[inline] +pub fn IS_DISPATCHING(Flag: DWORD) -> bool { + (Flag & EXCEPTION_UNWIND) == 0 +} +#[inline] +pub fn IS_TARGET_UNWIND(Flag: DWORD) -> bool { + (Flag & EXCEPTION_TARGET_UNWIND) != 0 +} +pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15; +STRUCT!{struct EXCEPTION_RECORD { + ExceptionCode: DWORD, + ExceptionFlags: DWORD, + ExceptionRecord: *mut EXCEPTION_RECORD, + ExceptionAddress: PVOID, + NumberParameters: DWORD, + ExceptionInformation: [ULONG_PTR; EXCEPTION_MAXIMUM_PARAMETERS], +}} +pub type PEXCEPTION_RECORD = *mut EXCEPTION_RECORD; +STRUCT!{struct EXCEPTION_RECORD32 { + ExceptionCode: DWORD, + ExceptionFlags: DWORD, + ExceptionRecord: DWORD, + ExceptionAddress: DWORD, + NumberParameters: DWORD, + ExceptionInformation: [DWORD; EXCEPTION_MAXIMUM_PARAMETERS], +}} +pub type PEXCEPTION_RECORD32 = *mut EXCEPTION_RECORD32; +STRUCT!{struct EXCEPTION_RECORD64 { + ExceptionCode: DWORD, + ExceptionFlags: DWORD, + ExceptionRecord: DWORD64, + ExceptionAddress: DWORD64, + NumberParameters: DWORD, + __unusedAlignment: DWORD, + ExceptionInformation: [DWORD64; EXCEPTION_MAXIMUM_PARAMETERS], +}} +pub type PEXCEPTION_RECORD64 = *mut EXCEPTION_RECORD64; +STRUCT!{struct EXCEPTION_POINTERS { + ExceptionRecord: PEXCEPTION_RECORD, + ContextRecord: PCONTEXT, +}} +pub type PEXCEPTION_POINTERS = *mut EXCEPTION_POINTERS; +pub type PACCESS_TOKEN = PVOID; +pub type PSECURITY_DESCRIPTOR = PVOID; +pub type PSID = PVOID; +pub type PCLAIMS_BLOB = PVOID; +pub type ACCESS_MASK = DWORD; +pub type PACCESS_MASK = *mut ACCESS_MASK; +pub const DELETE: DWORD = 0x00010000; +pub const READ_CONTROL: DWORD = 0x00020000; +pub const WRITE_DAC: DWORD = 0x00040000; +pub const WRITE_OWNER: DWORD = 0x00080000; +pub const SYNCHRONIZE: DWORD = 0x00100000; +pub const STANDARD_RIGHTS_REQUIRED: DWORD = 0x000F0000; +pub const STANDARD_RIGHTS_READ: DWORD = READ_CONTROL; +pub const STANDARD_RIGHTS_WRITE: DWORD = READ_CONTROL; +pub const STANDARD_RIGHTS_EXECUTE: DWORD = READ_CONTROL; +pub const STANDARD_RIGHTS_ALL: DWORD = 0x001F0000; +pub const SPECIFIC_RIGHTS_ALL: DWORD = 0x0000FFFF; +pub const ACCESS_SYSTEM_SECURITY: DWORD = 0x01000000; +pub const MAXIMUM_ALLOWED: DWORD = 0x02000000; +pub const GENERIC_READ: DWORD = 0x80000000; +pub const GENERIC_WRITE: DWORD = 0x40000000; +pub const GENERIC_EXECUTE: DWORD = 0x20000000; +pub const GENERIC_ALL: DWORD = 0x10000000; +STRUCT!{struct GENERIC_MAPPING { + GenericRead: ACCESS_MASK, + GenericWrite: ACCESS_MASK, + GenericExecute: ACCESS_MASK, + GenericAll: ACCESS_MASK, +}} +pub type PGENERIC_MAPPING = *mut GENERIC_MAPPING; +STRUCT!{struct LUID_AND_ATTRIBUTES { + Luid: LUID, + Attributes: DWORD, +}} +pub type PLUID_AND_ATTRIBUTES = *mut LUID_AND_ATTRIBUTES; +pub type LUID_AND_ATTRIBUTES_ARRAY = LUID_AND_ATTRIBUTES; +pub type PLUID_AND_ATTRIBUTES_ARRAY = *mut LUID_AND_ATTRIBUTES; +STRUCT!{struct SID_IDENTIFIER_AUTHORITY { + Value: [BYTE; 6], +}} +pub type PSID_IDENTIFIER_AUTHORITY = *mut SID_IDENTIFIER_AUTHORITY; +STRUCT!{struct SID { + Revision: BYTE, + SubAuthorityCount: BYTE, + IdentifierAuthority: SID_IDENTIFIER_AUTHORITY, + SubAuthority: [DWORD; 1], +}} +pub type PISID = *mut SID; +pub const SID_REVISION: BYTE = 1; +pub const SID_MAX_SUB_AUTHORITIES: BYTE = 15; +pub const SID_RECOMMENDED_SUB_AUTHORITIES: BYTE = 1; +pub const SECURITY_MAX_SID_SIZE: usize = 12 - 4 + (SID_MAX_SUB_AUTHORITIES as usize * 4); +pub const SECURITY_MAX_SID_STRING_CHARACTERS: BYTE = 2 + 4 + 15 + (11 * SID_MAX_SUB_AUTHORITIES) + + 1; +UNION!{union SE_SID { + [u32; 17], + Sid Sid_mut: SID, + Buffer Buffer_mut: [BYTE; SECURITY_MAX_SID_SIZE], +}} +pub type PSE_SID = *mut SE_SID; +ENUM!{enum SID_NAME_USE { + SidTypeUser = 1, + SidTypeGroup, + SidTypeDomain, + SidTypeAlias, + SidTypeWellKnownGroup, + SidTypeDeletedAccount, + SidTypeInvalid, + SidTypeUnknown, + SidTypeComputer, + SidTypeLabel, + SidTypeLogonSession, +}} +pub type PSID_NAME_USE = *mut SID_NAME_USE; +STRUCT!{struct SID_AND_ATTRIBUTES { + Sid: PSID, + Attributes: DWORD, +}} +pub type PSID_AND_ATTRIBUTES = *mut SID_AND_ATTRIBUTES; +pub type SID_AND_ATTRIBUTES_ARRAY = SID_AND_ATTRIBUTES; +pub type PSID_AND_ATTRIBUTES_ARRAY = *mut SID_AND_ATTRIBUTES; +pub const SID_HASH_SIZE: usize = 32; +pub type SID_HASH_ENTRY = ULONG_PTR; +pub type PSID_HASH_ENTRY = *mut ULONG_PTR; +STRUCT!{struct SID_AND_ATTRIBUTES_HASH { + SidCount: DWORD, + SidAttr: PSID_AND_ATTRIBUTES, + Hash: [SID_HASH_ENTRY; SID_HASH_SIZE], +}} +pub type PSID_AND_ATTRIBUTES_HASH = *mut SID_AND_ATTRIBUTES_HASH; +pub const SECURITY_NULL_SID_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 0]; +pub const SECURITY_WORLD_SID_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 1]; +pub const SECURITY_LOCAL_SID_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 2]; +pub const SECURITY_CREATOR_SID_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 3]; +pub const SECURITY_NON_UNIQUE_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 4]; +pub const SECURITY_RESOURCE_MANAGER_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 9]; +pub const SECURITY_NULL_RID: DWORD = 0x00000000; +pub const SECURITY_WORLD_RID: DWORD = 0x00000000; +pub const SECURITY_LOCAL_RID: DWORD = 0x00000000; +pub const SECURITY_LOCAL_LOGON_RID: DWORD = 0x00000001; +pub const SECURITY_CREATOR_OWNER_RID: DWORD = 0x00000000; +pub const SECURITY_CREATOR_GROUP_RID: DWORD = 0x00000001; +pub const SECURITY_CREATOR_OWNER_SERVER_RID: DWORD = 0x00000002; +pub const SECURITY_CREATOR_GROUP_SERVER_RID: DWORD = 0x00000003; +pub const SECURITY_CREATOR_OWNER_RIGHTS_RID: DWORD = 0x00000004; +pub const SECURITY_NT_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 5]; +pub const SECURITY_DIALUP_RID: DWORD = 0x00000001; +pub const SECURITY_NETWORK_RID: DWORD = 0x00000002; +pub const SECURITY_BATCH_RID: DWORD = 0x00000003; +pub const SECURITY_INTERACTIVE_RID: DWORD = 0x00000004; +pub const SECURITY_LOGON_IDS_RID: DWORD = 0x00000005; +pub const SECURITY_LOGON_IDS_RID_COUNT: DWORD = 3; +pub const SECURITY_SERVICE_RID: DWORD = 0x00000006; +pub const SECURITY_ANONYMOUS_LOGON_RID: DWORD = 0x00000007; +pub const SECURITY_PROXY_RID: DWORD = 0x00000008; +pub const SECURITY_ENTERPRISE_CONTROLLERS_RID: DWORD = 0x00000009; +pub const SECURITY_SERVER_LOGON_RID: DWORD = SECURITY_ENTERPRISE_CONTROLLERS_RID; +pub const SECURITY_PRINCIPAL_SELF_RID: DWORD = 0x0000000A; +pub const SECURITY_AUTHENTICATED_USER_RID: DWORD = 0x0000000B; +pub const SECURITY_RESTRICTED_CODE_RID: DWORD = 0x0000000C; +pub const SECURITY_TERMINAL_SERVER_RID: DWORD = 0x0000000D; +pub const SECURITY_REMOTE_LOGON_RID: DWORD = 0x0000000E; +pub const SECURITY_THIS_ORGANIZATION_RID: DWORD = 0x0000000F; +pub const SECURITY_IUSER_RID: DWORD = 0x00000011; +pub const SECURITY_LOCAL_SYSTEM_RID: DWORD = 0x00000012; +pub const SECURITY_LOCAL_SERVICE_RID: DWORD = 0x00000013; +pub const SECURITY_NETWORK_SERVICE_RID: DWORD = 0x00000014; +pub const SECURITY_NT_NON_UNIQUE: DWORD = 0x00000015; +pub const SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT: DWORD = 3; +pub const SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID: DWORD = 0x00000016; +pub const SECURITY_BUILTIN_DOMAIN_RID: DWORD = 0x00000020; +pub const SECURITY_WRITE_RESTRICTED_CODE_RID: DWORD = 0x00000021; +pub const SECURITY_PACKAGE_BASE_RID: DWORD = 0x00000040; +pub const SECURITY_PACKAGE_RID_COUNT: DWORD = 2; +pub const SECURITY_PACKAGE_NTLM_RID: DWORD = 0x0000000A; +pub const SECURITY_PACKAGE_SCHANNEL_RID: DWORD = 0x0000000E; +pub const SECURITY_PACKAGE_DIGEST_RID: DWORD = 0x00000015; +pub const SECURITY_CRED_TYPE_BASE_RID: DWORD = 0x00000041; +pub const SECURITY_CRED_TYPE_RID_COUNT: DWORD = 2; +pub const SECURITY_CRED_TYPE_THIS_ORG_CERT_RID: DWORD = 0x00000001; +pub const SECURITY_MIN_BASE_RID: DWORD = 0x00000050; +pub const SECURITY_SERVICE_ID_BASE_RID: DWORD = 0x00000050; +pub const SECURITY_SERVICE_ID_RID_COUNT: DWORD = 6; +pub const SECURITY_RESERVED_ID_BASE_RID: DWORD = 0x00000051; +pub const SECURITY_APPPOOL_ID_BASE_RID: DWORD = 0x00000052; +pub const SECURITY_APPPOOL_ID_RID_COUNT: DWORD = 6; +pub const SECURITY_VIRTUALSERVER_ID_BASE_RID: DWORD = 0x00000053; +pub const SECURITY_VIRTUALSERVER_ID_RID_COUNT: DWORD = 6; +pub const SECURITY_USERMODEDRIVERHOST_ID_BASE_RID: DWORD = 0x00000054; +pub const SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT: DWORD = 6; +pub const SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID: DWORD = 0x00000055; +pub const SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT: DWORD = 6; +pub const SECURITY_WMIHOST_ID_BASE_RID: DWORD = 0x00000056; +pub const SECURITY_WMIHOST_ID_RID_COUNT: DWORD = 6; +pub const SECURITY_TASK_ID_BASE_RID: DWORD = 0x00000057; +pub const SECURITY_NFS_ID_BASE_RID: DWORD = 0x00000058; +pub const SECURITY_COM_ID_BASE_RID: DWORD = 0x00000059; +pub const SECURITY_WINDOW_MANAGER_BASE_RID: DWORD = 0x0000005A; +pub const SECURITY_RDV_GFX_BASE_RID: DWORD = 0x0000005B; +pub const SECURITY_DASHOST_ID_BASE_RID: DWORD = 0x0000005C; +pub const SECURITY_DASHOST_ID_RID_COUNT: DWORD = 6; +pub const SECURITY_USERMANAGER_ID_BASE_RID: DWORD = 0x0000005D; +pub const SECURITY_USERMANAGER_ID_RID_COUNT: DWORD = 6; +pub const SECURITY_WINRM_ID_BASE_RID: DWORD = 0x0000005E; +pub const SECURITY_WINRM_ID_RID_COUNT: DWORD = 6; +pub const SECURITY_CCG_ID_BASE_RID: DWORD = 0x0000005F; +pub const SECURITY_UMFD_BASE_RID: DWORD = 0x00000060; +pub const SECURITY_VIRTUALACCOUNT_ID_RID_COUNT: DWORD = 6; +pub const SECURITY_MAX_BASE_RID: DWORD = 0x0000006F; +pub const SECURITY_MAX_ALWAYS_FILTERED: DWORD = 0x000003E7; +pub const SECURITY_MIN_NEVER_FILTERED: DWORD = 0x000003E8; +pub const SECURITY_OTHER_ORGANIZATION_RID: DWORD = 0x000003E8; +pub const SECURITY_WINDOWSMOBILE_ID_BASE_RID: DWORD = 0x00000070; +pub const SECURITY_INSTALLER_GROUP_CAPABILITY_BASE: DWORD = 0x20; +pub const SECURITY_INSTALLER_GROUP_CAPABILITY_RID_COUNT: DWORD = 9; +pub const SECURITY_INSTALLER_CAPABILITY_RID_COUNT: DWORD = 10; +pub const SECURITY_LOCAL_ACCOUNT_RID: DWORD = 0x00000071; +pub const SECURITY_LOCAL_ACCOUNT_AND_ADMIN_RID: DWORD = 0x00000072; +pub const DOMAIN_GROUP_RID_AUTHORIZATION_DATA_IS_COMPOUNDED: DWORD = 0x000001F0; +pub const DOMAIN_GROUP_RID_AUTHORIZATION_DATA_CONTAINS_CLAIMS: DWORD = 0x000001F1; +pub const DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS: DWORD = 0x000001F2; +pub const FOREST_USER_RID_MAX: DWORD = 0x000001F3; +pub const DOMAIN_USER_RID_ADMIN: DWORD = 0x000001F4; +pub const DOMAIN_USER_RID_GUEST: DWORD = 0x000001F5; +pub const DOMAIN_USER_RID_KRBTGT: DWORD = 0x000001F6; +pub const DOMAIN_USER_RID_DEFAULT_ACCOUNT: DWORD = 0x000001F7; +pub const DOMAIN_USER_RID_MAX: DWORD = 0x000003E7; +pub const DOMAIN_GROUP_RID_ADMINS: DWORD = 0x00000200; +pub const DOMAIN_GROUP_RID_USERS: DWORD = 0x00000201; +pub const DOMAIN_GROUP_RID_GUESTS: DWORD = 0x00000202; +pub const DOMAIN_GROUP_RID_COMPUTERS: DWORD = 0x00000203; +pub const DOMAIN_GROUP_RID_CONTROLLERS: DWORD = 0x00000204; +pub const DOMAIN_GROUP_RID_CERT_ADMINS: DWORD = 0x00000205; +pub const DOMAIN_GROUP_RID_SCHEMA_ADMINS: DWORD = 0x00000206; +pub const DOMAIN_GROUP_RID_ENTERPRISE_ADMINS: DWORD = 0x00000207; +pub const DOMAIN_GROUP_RID_POLICY_ADMINS: DWORD = 0x00000208; +pub const DOMAIN_GROUP_RID_READONLY_CONTROLLERS: DWORD = 0x00000209; +pub const DOMAIN_GROUP_RID_CLONEABLE_CONTROLLERS: DWORD = 0x0000020A; +pub const DOMAIN_GROUP_RID_CDC_RESERVED: DWORD = 0x0000020C; +pub const DOMAIN_GROUP_RID_PROTECTED_USERS: DWORD = 0x0000020D; +pub const DOMAIN_GROUP_RID_KEY_ADMINS: DWORD = 0x0000020E; +pub const DOMAIN_GROUP_RID_ENTERPRISE_KEY_ADMINS: DWORD = 0x0000020F; +pub const DOMAIN_ALIAS_RID_ADMINS: DWORD = 0x00000220; +pub const DOMAIN_ALIAS_RID_USERS: DWORD = 0x00000221; +pub const DOMAIN_ALIAS_RID_GUESTS: DWORD = 0x00000222; +pub const DOMAIN_ALIAS_RID_POWER_USERS: DWORD = 0x00000223; +pub const DOMAIN_ALIAS_RID_ACCOUNT_OPS: DWORD = 0x00000224; +pub const DOMAIN_ALIAS_RID_SYSTEM_OPS: DWORD = 0x00000225; +pub const DOMAIN_ALIAS_RID_PRINT_OPS: DWORD = 0x00000226; +pub const DOMAIN_ALIAS_RID_BACKUP_OPS: DWORD = 0x00000227; +pub const DOMAIN_ALIAS_RID_REPLICATOR: DWORD = 0x00000228; +pub const DOMAIN_ALIAS_RID_RAS_SERVERS: DWORD = 0x00000229; +pub const DOMAIN_ALIAS_RID_PREW2KCOMPACCESS: DWORD = 0x0000022A; +pub const DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS: DWORD = 0x0000022B; +pub const DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS: DWORD = 0x0000022C; +pub const DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS: DWORD = 0x0000022D; +pub const DOMAIN_ALIAS_RID_MONITORING_USERS: DWORD = 0x0000022E; +pub const DOMAIN_ALIAS_RID_LOGGING_USERS: DWORD = 0x0000022F; +pub const DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS: DWORD = 0x00000230; +pub const DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS: DWORD = 0x00000231; +pub const DOMAIN_ALIAS_RID_DCOM_USERS: DWORD = 0x00000232; +pub const DOMAIN_ALIAS_RID_IUSERS: DWORD = 0x00000238; +pub const DOMAIN_ALIAS_RID_CRYPTO_OPERATORS: DWORD = 0x00000239; +pub const DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP: DWORD = 0x0000023B; +pub const DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP: DWORD = 0x0000023C; +pub const DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP: DWORD = 0x0000023D; +pub const DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP: DWORD = 0x0000023E; +pub const DOMAIN_ALIAS_RID_RDS_REMOTE_ACCESS_SERVERS: DWORD = 0x0000023F; +pub const DOMAIN_ALIAS_RID_RDS_ENDPOINT_SERVERS: DWORD = 0x00000240; +pub const DOMAIN_ALIAS_RID_RDS_MANAGEMENT_SERVERS: DWORD = 0x00000241; +pub const DOMAIN_ALIAS_RID_HYPER_V_ADMINS: DWORD = 0x00000242; +pub const DOMAIN_ALIAS_RID_ACCESS_CONTROL_ASSISTANCE_OPS: DWORD = 0x00000243; +pub const DOMAIN_ALIAS_RID_REMOTE_MANAGEMENT_USERS: DWORD = 0x00000244; +pub const DOMAIN_ALIAS_RID_DEFAULT_ACCOUNT: DWORD = 0x00000245; +pub const DOMAIN_ALIAS_RID_STORAGE_REPLICA_ADMINS: DWORD = 0x00000246; +pub const SECURITY_APP_PACKAGE_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 15]; +pub const SECURITY_APP_PACKAGE_BASE_RID: DWORD = 0x00000002; +pub const SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT: DWORD = 2; +pub const SECURITY_APP_PACKAGE_RID_COUNT: DWORD = 8; +pub const SECURITY_CAPABILITY_BASE_RID: DWORD = 0x00000003; +pub const SECURITY_CAPABILITY_APP_RID: DWORD = 0x00000040; +pub const SECURITY_BUILTIN_CAPABILITY_RID_COUNT: DWORD = 2; +pub const SECURITY_CAPABILITY_RID_COUNT: DWORD = 5; +pub const SECURITY_PARENT_PACKAGE_RID_COUNT: DWORD = SECURITY_APP_PACKAGE_RID_COUNT; +pub const SECURITY_CHILD_PACKAGE_RID_COUNT: DWORD = 12; +pub const SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE: DWORD = 0x00000001; +pub const SECURITY_BUILTIN_PACKAGE_ANY_RESTRICTED_PACKAGE: DWORD = 0x00000002; +pub const SECURITY_CAPABILITY_INTERNET_CLIENT: DWORD = 0x00000001; +pub const SECURITY_CAPABILITY_INTERNET_CLIENT_SERVER: DWORD = 0x00000002; +pub const SECURITY_CAPABILITY_PRIVATE_NETWORK_CLIENT_SERVER: DWORD = 0x00000003; +pub const SECURITY_CAPABILITY_PICTURES_LIBRARY: DWORD = 0x00000004; +pub const SECURITY_CAPABILITY_VIDEOS_LIBRARY: DWORD = 0x00000005; +pub const SECURITY_CAPABILITY_MUSIC_LIBRARY: DWORD = 0x00000006; +pub const SECURITY_CAPABILITY_DOCUMENTS_LIBRARY: DWORD = 0x00000007; +pub const SECURITY_CAPABILITY_ENTERPRISE_AUTHENTICATION: DWORD = 0x00000008; +pub const SECURITY_CAPABILITY_SHARED_USER_CERTIFICATES: DWORD = 0x00000009; +pub const SECURITY_CAPABILITY_REMOVABLE_STORAGE: DWORD = 0x0000000A; +pub const SECURITY_CAPABILITY_APPOINTMENTS: DWORD = 0x0000000B; +pub const SECURITY_CAPABILITY_CONTACTS: DWORD = 0x0000000C; +pub const SECURITY_CAPABILITY_INTERNET_EXPLORER: DWORD = 0x00001000; +pub const SECURITY_MANDATORY_LABEL_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 16]; +pub const SECURITY_MANDATORY_UNTRUSTED_RID: DWORD = 0x00000000; +pub const SECURITY_MANDATORY_LOW_RID: DWORD = 0x00001000; +pub const SECURITY_MANDATORY_MEDIUM_RID: DWORD = 0x00002000; +pub const SECURITY_MANDATORY_MEDIUM_PLUS_RID: DWORD = SECURITY_MANDATORY_MEDIUM_RID + 0x10; +pub const SECURITY_MANDATORY_HIGH_RID: DWORD = 0x00003000; +pub const SECURITY_MANDATORY_SYSTEM_RID: DWORD = 0x00004000; +pub const SECURITY_MANDATORY_MAXIMUM_USER_RID: DWORD = SECURITY_MANDATORY_SYSTEM_RID; +#[inline] +pub fn MANDATORY_LEVEL_TO_MANDATORY_RID(IL: DWORD) -> DWORD { + IL * 0x1000 +} +pub const SECURITY_SCOPED_POLICY_ID_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 17]; +pub const SECURITY_AUTHENTICATION_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 18]; +pub const SECURITY_AUTHENTICATION_AUTHORITY_RID_COUNT: DWORD = 1; +pub const SECURITY_AUTHENTICATION_AUTHORITY_ASSERTED_RID: DWORD = 0x00000001; +pub const SECURITY_AUTHENTICATION_SERVICE_ASSERTED_RID: DWORD = 0x00000002; +pub const SECURITY_AUTHENTICATION_FRESH_KEY_AUTH_RID: DWORD = 0x00000003; +pub const SECURITY_AUTHENTICATION_KEY_TRUST_RID: DWORD = 0x00000004; +pub const SECURITY_AUTHENTICATION_KEY_PROPERTY_MFA_RID: DWORD = 0x00000005; +pub const SECURITY_AUTHENTICATION_KEY_PROPERTY_ATTESTATION_RID: DWORD = 0x00000006; +pub const SECURITY_PROCESS_TRUST_AUTHORITY: [BYTE; 6] = [0, 0, 0, 0, 0, 19]; +pub const SECURITY_PROCESS_TRUST_AUTHORITY_RID_COUNT: DWORD = 2; +pub const SECURITY_PROCESS_PROTECTION_TYPE_FULL_RID: DWORD = 0x00000400; +pub const SECURITY_PROCESS_PROTECTION_TYPE_LITE_RID: DWORD = 0x00000200; +pub const SECURITY_PROCESS_PROTECTION_TYPE_NONE_RID: DWORD = 0x00000000; +pub const SECURITY_PROCESS_PROTECTION_LEVEL_WINTCB_RID: DWORD = 0x00002000; +pub const SECURITY_PROCESS_PROTECTION_LEVEL_WINDOWS_RID: DWORD = 0x00001000; +pub const SECURITY_PROCESS_PROTECTION_LEVEL_APP_RID: DWORD = 0x00000800; +pub const SECURITY_PROCESS_PROTECTION_LEVEL_NONE_RID: DWORD = 0x00000000; +pub const SECURITY_TRUSTED_INSTALLER_RID1: DWORD = 95600888; +pub const SECURITY_TRUSTED_INSTALLER_RID2: DWORD = 341852264; +pub const SECURITY_TRUSTED_INSTALLER_RID3: DWORD = 183103804; +pub const SECURITY_TRUSTED_INSTALLER_RID4: DWORD = 185329263; +pub const SECURITY_TRUSTED_INSTALLER_RID5: DWORD = 227147846; +ENUM!{enum WELL_KNOWN_SID_TYPE { + WinNullSid = 0, + WinWorldSid = 1, + WinLocalSid = 2, + WinCreatorOwnerSid = 3, + WinCreatorGroupSid = 4, + WinCreatorOwnerServerSid = 5, + WinCreatorGroupServerSid = 6, + WinNtAuthoritySid = 7, + WinDialupSid = 8, + WinNetworkSid = 9, + WinBatchSid = 10, + WinInteractiveSid = 11, + WinServiceSid = 12, + WinAnonymousSid = 13, + WinProxySid = 14, + WinEnterpriseControllersSid = 15, + WinSelfSid = 16, + WinAuthenticatedUserSid = 17, + WinRestrictedCodeSid = 18, + WinTerminalServerSid = 19, + WinRemoteLogonIdSid = 20, + WinLogonIdsSid = 21, + WinLocalSystemSid = 22, + WinLocalServiceSid = 23, + WinNetworkServiceSid = 24, + WinBuiltinDomainSid = 25, + WinBuiltinAdministratorsSid = 26, + WinBuiltinUsersSid = 27, + WinBuiltinGuestsSid = 28, + WinBuiltinPowerUsersSid = 29, + WinBuiltinAccountOperatorsSid = 30, + WinBuiltinSystemOperatorsSid = 31, + WinBuiltinPrintOperatorsSid = 32, + WinBuiltinBackupOperatorsSid = 33, + WinBuiltinReplicatorSid = 34, + WinBuiltinPreWindows2000CompatibleAccessSid = 35, + WinBuiltinRemoteDesktopUsersSid = 36, + WinBuiltinNetworkConfigurationOperatorsSid = 37, + WinAccountAdministratorSid = 38, + WinAccountGuestSid = 39, + WinAccountKrbtgtSid = 40, + WinAccountDomainAdminsSid = 41, + WinAccountDomainUsersSid = 42, + WinAccountDomainGuestsSid = 43, + WinAccountComputersSid = 44, + WinAccountControllersSid = 45, + WinAccountCertAdminsSid = 46, + WinAccountSchemaAdminsSid = 47, + WinAccountEnterpriseAdminsSid = 48, + WinAccountPolicyAdminsSid = 49, + WinAccountRasAndIasServersSid = 50, + WinNTLMAuthenticationSid = 51, + WinDigestAuthenticationSid = 52, + WinSChannelAuthenticationSid = 53, + WinThisOrganizationSid = 54, + WinOtherOrganizationSid = 55, + WinBuiltinIncomingForestTrustBuildersSid = 56, + WinBuiltinPerfMonitoringUsersSid = 57, + WinBuiltinPerfLoggingUsersSid = 58, + WinBuiltinAuthorizationAccessSid = 59, + WinBuiltinTerminalServerLicenseServersSid = 60, + WinBuiltinDCOMUsersSid = 61, + WinBuiltinIUsersSid = 62, + WinIUserSid = 63, + WinBuiltinCryptoOperatorsSid = 64, + WinUntrustedLabelSid = 65, + WinLowLabelSid = 66, + WinMediumLabelSid = 67, + WinHighLabelSid = 68, + WinSystemLabelSid = 69, + WinWriteRestrictedCodeSid = 70, + WinCreatorOwnerRightsSid = 71, + WinCacheablePrincipalsGroupSid = 72, + WinNonCacheablePrincipalsGroupSid = 73, + WinEnterpriseReadonlyControllersSid = 74, + WinAccountReadonlyControllersSid = 75, + WinBuiltinEventLogReadersGroup = 76, + WinNewEnterpriseReadonlyControllersSid = 77, + WinBuiltinCertSvcDComAccessGroup = 78, + WinMediumPlusLabelSid = 79, + WinLocalLogonSid = 80, + WinConsoleLogonSid = 81, + WinThisOrganizationCertificateSid = 82, + WinApplicationPackageAuthoritySid = 83, + WinBuiltinAnyPackageSid = 84, + WinCapabilityInternetClientSid = 85, + WinCapabilityInternetClientServerSid = 86, + WinCapabilityPrivateNetworkClientServerSid = 87, + WinCapabilityPicturesLibrarySid = 88, + WinCapabilityVideosLibrarySid = 89, + WinCapabilityMusicLibrarySid = 90, + WinCapabilityDocumentsLibrarySid = 91, + WinCapabilitySharedUserCertificatesSid = 92, + WinCapabilityEnterpriseAuthenticationSid = 93, + WinCapabilityRemovableStorageSid = 94, + WinBuiltinRDSRemoteAccessServersSid = 95, + WinBuiltinRDSEndpointServersSid = 96, + WinBuiltinRDSManagementServersSid = 97, + WinUserModeDriversSid = 98, + WinBuiltinHyperVAdminsSid = 99, + WinAccountCloneableControllersSid = 100, + WinBuiltinAccessControlAssistanceOperatorsSid = 101, + WinBuiltinRemoteManagementUsersSid = 102, + WinAuthenticationAuthorityAssertedSid = 103, + WinAuthenticationServiceAssertedSid = 104, + WinLocalAccountSid = 105, + WinLocalAccountAndAdministratorSid = 106, + WinAccountProtectedUsersSid = 107, + WinCapabilityAppointmentsSid = 108, + WinCapabilityContactsSid = 109, + WinAccountDefaultSystemManagedSid = 110, + WinBuiltinDefaultSystemManagedGroupSid = 111, + WinBuiltinStorageReplicaAdminsSid = 112, + WinAccountKeyAdminsSid = 113, + WinAccountEnterpriseKeyAdminsSid = 114, + WinAuthenticationKeyTrustSid = 115, + WinAuthenticationKeyPropertyMFASid = 116, + WinAuthenticationKeyPropertyAttestationSid = 117, + WinAuthenticationFreshKeyAuthSid = 118, +}} +pub const SYSTEM_LUID: LUID = LUID { LowPart: 0x3e7, HighPart: 0x0 }; +pub const ANONYMOUS_LOGON_LUID: LUID = LUID { LowPart: 0x3e6, HighPart: 0x0 }; +pub const LOCALSERVICE_LUID: LUID = LUID { LowPart: 0x3e5, HighPart: 0x0 }; +pub const NETWORKSERVICE_LUID: LUID = LUID { LowPart: 0x3e4, HighPart: 0x0 }; +pub const IUSER_LUID: LUID = LUID { LowPart: 0x3e3, HighPart: 0x0 }; +pub const SE_GROUP_MANDATORY: DWORD = 0x00000001; +pub const SE_GROUP_ENABLED_BY_DEFAULT: DWORD = 0x00000002; +pub const SE_GROUP_ENABLED: DWORD = 0x00000004; +pub const SE_GROUP_OWNER: DWORD = 0x00000008; +pub const SE_GROUP_USE_FOR_DENY_ONLY: DWORD = 0x00000010; +pub const SE_GROUP_INTEGRITY: DWORD = 0x00000020; +pub const SE_GROUP_INTEGRITY_ENABLED: DWORD = 0x00000040; +pub const SE_GROUP_LOGON_ID: DWORD = 0xC0000000; +pub const SE_GROUP_RESOURCE: DWORD = 0x20000000; +pub const SE_GROUP_VALID_ATTRIBUTES: DWORD = SE_GROUP_MANDATORY | SE_GROUP_ENABLED_BY_DEFAULT + | SE_GROUP_ENABLED | SE_GROUP_OWNER | SE_GROUP_USE_FOR_DENY_ONLY | SE_GROUP_LOGON_ID + | SE_GROUP_RESOURCE | SE_GROUP_INTEGRITY | SE_GROUP_INTEGRITY_ENABLED; +pub const ACL_REVISION: BYTE = 2; +pub const ACL_REVISION_DS: BYTE = 4; +pub const ACL_REVISION1: BYTE = 1; +pub const MIN_ACL_REVISION: BYTE = ACL_REVISION2; +pub const ACL_REVISION2: BYTE = 2; +pub const ACL_REVISION3: BYTE = 3; +pub const ACL_REVISION4: BYTE = 4; +pub const MAX_ACL_REVISION: BYTE = ACL_REVISION4; +STRUCT!{struct ACL { + AclRevision: BYTE, + Sbz1: BYTE, + AclSize: WORD, + AceCount: WORD, + Sbz2: WORD, +}} +pub type PACL = *mut ACL; +STRUCT!{struct ACE_HEADER { + AceType: BYTE, + AceFlags: BYTE, + AceSize: WORD, +}} +pub type PACE_HEADER = *mut ACE_HEADER; +pub const ACCESS_MIN_MS_ACE_TYPE: BYTE = 0x0; +pub const ACCESS_ALLOWED_ACE_TYPE: BYTE = 0x0; +pub const ACCESS_DENIED_ACE_TYPE: BYTE = 0x1; +pub const SYSTEM_AUDIT_ACE_TYPE: BYTE = 0x2; +pub const SYSTEM_ALARM_ACE_TYPE: BYTE = 0x3; +pub const ACCESS_MAX_MS_V2_ACE_TYPE: BYTE = 0x3; +pub const ACCESS_ALLOWED_COMPOUND_ACE_TYPE: BYTE = 0x4; +pub const ACCESS_MAX_MS_V3_ACE_TYPE: BYTE = 0x4; +pub const ACCESS_MIN_MS_OBJECT_ACE_TYPE: BYTE = 0x5; +pub const ACCESS_ALLOWED_OBJECT_ACE_TYPE: BYTE = 0x5; +pub const ACCESS_DENIED_OBJECT_ACE_TYPE: BYTE = 0x6; +pub const SYSTEM_AUDIT_OBJECT_ACE_TYPE: BYTE = 0x7; +pub const SYSTEM_ALARM_OBJECT_ACE_TYPE: BYTE = 0x8; +pub const ACCESS_MAX_MS_OBJECT_ACE_TYPE: BYTE = 0x8; +pub const ACCESS_MAX_MS_V4_ACE_TYPE: BYTE = 0x8; +pub const ACCESS_MAX_MS_ACE_TYPE: BYTE = 0x8; +pub const ACCESS_ALLOWED_CALLBACK_ACE_TYPE: BYTE = 0x9; +pub const ACCESS_DENIED_CALLBACK_ACE_TYPE: BYTE = 0xA; +pub const ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE: BYTE = 0xB; +pub const ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE: BYTE = 0xC; +pub const SYSTEM_AUDIT_CALLBACK_ACE_TYPE: BYTE = 0xD; +pub const SYSTEM_ALARM_CALLBACK_ACE_TYPE: BYTE = 0xE; +pub const SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE: BYTE = 0xF; +pub const SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE: BYTE = 0x10; +pub const SYSTEM_MANDATORY_LABEL_ACE_TYPE: BYTE = 0x11; +pub const SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE: BYTE = 0x12; +pub const SYSTEM_SCOPED_POLICY_ID_ACE_TYPE: BYTE = 0x13; +pub const SYSTEM_PROCESS_TRUST_LABEL_ACE_TYPE: BYTE = 0x14; +pub const SYSTEM_ACCESS_FILTER_ACE_TYPE: BYTE = 0x15; +pub const ACCESS_MAX_MS_V5_ACE_TYPE: BYTE = 0x15; +pub const OBJECT_INHERIT_ACE: BYTE = 0x1; +pub const CONTAINER_INHERIT_ACE: BYTE = 0x2; +pub const NO_PROPAGATE_INHERIT_ACE: BYTE = 0x4; +pub const INHERIT_ONLY_ACE: BYTE = 0x8; +pub const INHERITED_ACE: BYTE = 0x10; +pub const VALID_INHERIT_FLAGS: BYTE = 0x1F; +pub const SUCCESSFUL_ACCESS_ACE_FLAG: BYTE = 0x40; +pub const FAILED_ACCESS_ACE_FLAG: BYTE = 0x80; +pub const TRUST_PROTECTED_FILTER_ACE_FLAG: BYTE = 0x40; +STRUCT!{struct ACCESS_ALLOWED_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PACCESS_ALLOWED_ACE = *mut ACCESS_ALLOWED_ACE; +STRUCT!{struct ACCESS_DENIED_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PACCESS_DENIED_ACE = *mut ACCESS_DENIED_ACE; +STRUCT!{struct SYSTEM_AUDIT_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PSYSTEM_AUDIT_ACE = *mut SYSTEM_AUDIT_ACE; +STRUCT!{struct SYSTEM_ALARM_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PSYSTEM_ALARM_ACE = *mut SYSTEM_ALARM_ACE; +STRUCT!{struct SYSTEM_RESOURCE_ATTRIBUTE_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PSYSTEM_RESOURCE_ATTRIBUTE_ACE = *mut SYSTEM_RESOURCE_ATTRIBUTE_ACE; +STRUCT!{struct SYSTEM_SCOPED_POLICY_ID_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PSYSTEM_SCOPED_POLICY_ID_ACE = *mut SYSTEM_SCOPED_POLICY_ID_ACE; +STRUCT!{struct SYSTEM_MANDATORY_LABEL_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PSYSTEM_MANDATORY_LABEL_ACE = *mut SYSTEM_MANDATORY_LABEL_ACE; +STRUCT!{struct SYSTEM_PROCESS_TRUST_LABEL_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PSYSTEM_PROCESS_TRUST_LABEL_ACE = *mut SYSTEM_PROCESS_TRUST_LABEL_ACE; +STRUCT!{struct SYSTEM_ACCESS_FILTER_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PSYSTEM_ACCESS_FILTER_ACE = *mut SYSTEM_ACCESS_FILTER_ACE; +pub const SYSTEM_MANDATORY_LABEL_NO_WRITE_UP: ACCESS_MASK = 0x1; +pub const SYSTEM_MANDATORY_LABEL_NO_READ_UP: ACCESS_MASK = 0x2; +pub const SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP: ACCESS_MASK = 0x4; +pub const SYSTEM_MANDATORY_LABEL_VALID_MASK: ACCESS_MASK = SYSTEM_MANDATORY_LABEL_NO_WRITE_UP + | SYSTEM_MANDATORY_LABEL_NO_READ_UP | SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP; +pub const SYSTEM_PROCESS_TRUST_LABEL_VALID_MASK: ACCESS_MASK = 0x00ffffff; +pub const SYSTEM_PROCESS_TRUST_NOCONSTRAINT_MASK: ACCESS_MASK = 0xffffffff; +pub const SYSTEM_ACCESS_FILTER_VALID_MASK: ACCESS_MASK = 0x00ffffff; +pub const SYSTEM_ACCESS_FILTER_NOCONSTRAINT_MASK: ACCESS_MASK = 0xffffffff; +STRUCT!{struct ACCESS_ALLOWED_OBJECT_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + Flags: DWORD, + ObjectType: GUID, + InheritedObjectType: GUID, + SidStart: DWORD, +}} +pub type PACCESS_ALLOWED_OBJECT_ACE = *mut ACCESS_ALLOWED_OBJECT_ACE; +STRUCT!{struct ACCESS_DENIED_OBJECT_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + Flags: DWORD, + ObjectType: GUID, + InheritedObjectType: GUID, + SidStart: DWORD, +}} +pub type PACCESS_DENIED_OBJECT_ACE = *mut ACCESS_DENIED_OBJECT_ACE; +STRUCT!{struct SYSTEM_AUDIT_OBJECT_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + Flags: DWORD, + ObjectType: GUID, + InheritedObjectType: GUID, + SidStart: DWORD, +}} +pub type PSYSTEM_AUDIT_OBJECT_ACE = *mut SYSTEM_AUDIT_OBJECT_ACE; +STRUCT!{struct SYSTEM_ALARM_OBJECT_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + Flags: DWORD, + ObjectType: GUID, + InheritedObjectType: GUID, + SidStart: DWORD, +}} +pub type PSYSTEM_ALARM_OBJECT_ACE = *mut SYSTEM_ALARM_OBJECT_ACE; +STRUCT!{struct ACCESS_ALLOWED_CALLBACK_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PACCESS_ALLOWED_CALLBACK_ACE = *mut ACCESS_ALLOWED_CALLBACK_ACE; +STRUCT!{struct ACCESS_DENIED_CALLBACK_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PACCESS_DENIED_CALLBACK_ACE = *mut ACCESS_DENIED_CALLBACK_ACE; +STRUCT!{struct SYSTEM_AUDIT_CALLBACK_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PSYSTEM_AUDIT_CALLBACK_ACE = *mut SYSTEM_AUDIT_CALLBACK_ACE; +STRUCT!{struct SYSTEM_ALARM_CALLBACK_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + SidStart: DWORD, +}} +pub type PSYSTEM_ALARM_CALLBACK_ACE = *mut SYSTEM_ALARM_CALLBACK_ACE; +STRUCT!{struct ACCESS_ALLOWED_CALLBACK_OBJECT_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + Flags: DWORD, + ObjectType: GUID, + InheritedObjectType: GUID, + SidStart: DWORD, +}} +pub type PACCESS_ALLOWED_CALLBACK_OBJECT_ACE = *mut ACCESS_ALLOWED_CALLBACK_OBJECT_ACE; +STRUCT!{struct ACCESS_DENIED_CALLBACK_OBJECT_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + Flags: DWORD, + ObjectType: GUID, + InheritedObjectType: GUID, + SidStart: DWORD, +}} +pub type PACCESS_DENIED_CALLBACK_OBJECT_ACE = *mut ACCESS_DENIED_CALLBACK_OBJECT_ACE; +STRUCT!{struct SYSTEM_AUDIT_CALLBACK_OBJECT_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + Flags: DWORD, + ObjectType: GUID, + InheritedObjectType: GUID, + SidStart: DWORD, +}} +pub type PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE = *mut SYSTEM_AUDIT_CALLBACK_OBJECT_ACE; +STRUCT!{struct SYSTEM_ALARM_CALLBACK_OBJECT_ACE { + Header: ACE_HEADER, + Mask: ACCESS_MASK, + Flags: DWORD, + ObjectType: GUID, + InheritedObjectType: GUID, + SidStart: DWORD, +}} +pub type PSYSTEM_ALARM_CALLBACK_OBJECT_ACE = *mut SYSTEM_ALARM_CALLBACK_OBJECT_ACE; +pub const ACE_OBJECT_TYPE_PRESENT: DWORD = 0x1; +pub const ACE_INHERITED_OBJECT_TYPE_PRESENT: DWORD = 0x2; +ENUM!{enum ACL_INFORMATION_CLASS { + AclRevisionInformation = 1, + AclSizeInformation, +}} +STRUCT!{struct ACL_REVISION_INFORMATION { + AclRevision: DWORD, +}} +pub type PACL_REVISION_INFORMATION = *mut ACL_REVISION_INFORMATION; +STRUCT!{struct ACL_SIZE_INFORMATION { + AceCount: DWORD, + AclBytesInUse: DWORD, + AclBytesFree: DWORD, +}} +pub type PACL_SIZE_INFORMATION = *mut ACL_SIZE_INFORMATION; +pub const SECURITY_DESCRIPTOR_REVISION: DWORD = 1; +pub const SECURITY_DESCRIPTOR_REVISION1: DWORD = 1; +#[cfg(target_pointer_width = "64")] +pub const SECURITY_DESCRIPTOR_MIN_LENGTH: usize = 40; +#[cfg(target_pointer_width = "32")] +pub const SECURITY_DESCRIPTOR_MIN_LENGTH: usize = 20; +pub type SECURITY_DESCRIPTOR_CONTROL = WORD; +pub type PSECURITY_DESCRIPTOR_CONTROL = *mut WORD; +pub const SE_OWNER_DEFAULTED: SECURITY_DESCRIPTOR_CONTROL = 0x0001; +pub const SE_GROUP_DEFAULTED: SECURITY_DESCRIPTOR_CONTROL = 0x0002; +pub const SE_DACL_PRESENT: SECURITY_DESCRIPTOR_CONTROL = 0x0004; +pub const SE_DACL_DEFAULTED: SECURITY_DESCRIPTOR_CONTROL = 0x0008; +pub const SE_SACL_PRESENT: SECURITY_DESCRIPTOR_CONTROL = 0x0010; +pub const SE_SACL_DEFAULTED: SECURITY_DESCRIPTOR_CONTROL = 0x0020; +pub const SE_DACL_AUTO_INHERIT_REQ: SECURITY_DESCRIPTOR_CONTROL = 0x0100; +pub const SE_SACL_AUTO_INHERIT_REQ: SECURITY_DESCRIPTOR_CONTROL = 0x0200; +pub const SE_DACL_AUTO_INHERITED: SECURITY_DESCRIPTOR_CONTROL = 0x0400; +pub const SE_SACL_AUTO_INHERITED: SECURITY_DESCRIPTOR_CONTROL = 0x0800; +pub const SE_DACL_PROTECTED: SECURITY_DESCRIPTOR_CONTROL = 0x1000; +pub const SE_SACL_PROTECTED: SECURITY_DESCRIPTOR_CONTROL = 0x2000; +pub const SE_RM_CONTROL_VALID: SECURITY_DESCRIPTOR_CONTROL = 0x4000; +pub const SE_SELF_RELATIVE: SECURITY_DESCRIPTOR_CONTROL = 0x8000; +STRUCT!{struct SECURITY_DESCRIPTOR_RELATIVE { + Revision: BYTE, + Sbz1: BYTE, + Control: SECURITY_DESCRIPTOR_CONTROL, + Owner: DWORD, + Group: DWORD, + Sacl: DWORD, + Dacl: DWORD, +}} +pub type PISECURITY_DESCRIPTOR_RELATIVE = *mut SECURITY_DESCRIPTOR_RELATIVE; +STRUCT!{struct SECURITY_DESCRIPTOR { + Revision: BYTE, + Sbz1: BYTE, + Control: SECURITY_DESCRIPTOR_CONTROL, + Owner: PSID, + Group: PSID, + Sacl: PACL, + Dacl: PACL, +}} +pub type PISECURITY_DESCRIPTOR = *mut SECURITY_DESCRIPTOR; +STRUCT!{struct SECURITY_OBJECT_AI_PARAMS { + Size: DWORD, + ConstraintMask: DWORD, +}} +pub type PSECURITY_OBJECT_AI_PARAMS = *mut SECURITY_OBJECT_AI_PARAMS; +STRUCT!{struct OBJECT_TYPE_LIST { + Level: WORD, + Sbz: WORD, + ObjectType: *mut GUID, +}} +pub type POBJECT_TYPE_LIST = *mut OBJECT_TYPE_LIST; +pub const ACCESS_OBJECT_GUID: WORD = 0; +pub const ACCESS_PROPERTY_SET_GUID: WORD = 1; +pub const ACCESS_PROPERTY_GUID: WORD = 2; +pub const ACCESS_MAX_LEVEL: WORD = 4; +ENUM!{enum AUDIT_EVENT_TYPE { + AuditEventObjectAccess, + AuditEventDirectoryServiceAccess, +}} +pub const AUDIT_ALLOW_NO_PRIVILEGE: DWORD = 0x1; +pub const ACCESS_DS_SOURCE: &'static str = "DS"; +pub const ACCESS_DS_OBJECT_TYPE_NAME: &'static str = "Directory Service Object"; +pub const SE_PRIVILEGE_ENABLED_BY_DEFAULT: DWORD = 0x00000001; +pub const SE_PRIVILEGE_ENABLED: DWORD = 0x00000002; +pub const SE_PRIVILEGE_REMOVED: DWORD = 0x00000004; +pub const SE_PRIVILEGE_USED_FOR_ACCESS: DWORD = 0x80000000; +pub const SE_PRIVILEGE_VALID_ATTRIBUTES: DWORD = SE_PRIVILEGE_ENABLED_BY_DEFAULT + | SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_REMOVED | SE_PRIVILEGE_USED_FOR_ACCESS; +pub const PRIVILEGE_SET_ALL_NECESSARY: DWORD = 1; +STRUCT!{struct PRIVILEGE_SET { + PrivilegeCount: DWORD, + Control: DWORD, + Privilege: [LUID_AND_ATTRIBUTES; ANYSIZE_ARRAY], +}} +pub type PPRIVILEGE_SET = *mut PRIVILEGE_SET; +pub const ACCESS_REASON_TYPE_MASK: ACCESS_REASON = 0x00ff0000; +pub const ACCESS_REASON_DATA_MASK: ACCESS_REASON = 0x0000ffff; +pub const ACCESS_REASON_STAGING_MASK: ACCESS_REASON = 0x80000000; +pub const ACCESS_REASON_EXDATA_MASK: ACCESS_REASON = 0x7f000000; +ENUM!{enum ACCESS_REASON_TYPE { + AccessReasonNone = 0x00000000, + AccessReasonAllowedAce = 0x00010000, + AccessReasonDeniedAce = 0x00020000, + AccessReasonAllowedParentAce = 0x00030000, + AccessReasonDeniedParentAce = 0x00040000, + AccessReasonNotGrantedByCape = 0x00050000, + AccessReasonNotGrantedByParentCape = 0x00060000, + AccessReasonNotGrantedToAppContainer = 0x00070000, + AccessReasonMissingPrivilege = 0x00100000, + AccessReasonFromPrivilege = 0x00200000, + AccessReasonIntegrityLevel = 0x00300000, + AccessReasonOwnership = 0x00400000, + AccessReasonNullDacl = 0x00500000, + AccessReasonEmptyDacl = 0x00600000, + AccessReasonNoSD = 0x00700000, + AccessReasonNoGrant = 0x00800000, + AccessReasonTrustLabel = 0x00900000, + AccessReasonFilterAce = 0x00a00000, +}} +pub type ACCESS_REASON = DWORD; +STRUCT!{struct ACCESS_REASONS { + Data: [ACCESS_REASON; 32], +}} +pub type PACCESS_REASONS = *mut ACCESS_REASONS; +pub const SE_SECURITY_DESCRIPTOR_FLAG_NO_OWNER_ACE: DWORD = 0x00000001; +pub const SE_SECURITY_DESCRIPTOR_FLAG_NO_LABEL_ACE: DWORD = 0x00000002; +pub const SE_SECURITY_DESCRIPTOR_FLAG_NO_ACCESS_FILTER_ACE: DWORD = 0x00000004; +pub const SE_SECURITY_DESCRIPTOR_VALID_FLAGS: DWORD = 0x00000007; +STRUCT!{struct SE_SECURITY_DESCRIPTOR { + Size: DWORD, + Flags: DWORD, + SecurityDescriptor: PSECURITY_DESCRIPTOR, +}} +pub type PSE_SECURITY_DESCRIPTOR = *mut SE_SECURITY_DESCRIPTOR; +STRUCT!{struct SE_ACCESS_REQUEST { + Size: DWORD, + SeSecurityDescriptor: PSE_SECURITY_DESCRIPTOR, + DesiredAccess: ACCESS_MASK, + PreviouslyGrantedAccess: ACCESS_MASK, + PrincipalSelfSid: PSID, + GenericMapping: PGENERIC_MAPPING, + ObjectTypeListCount: DWORD, + ObjectTypeList: POBJECT_TYPE_LIST, +}} +pub type PSE_ACCESS_REQUEST = *mut SE_ACCESS_REQUEST; +STRUCT!{struct SE_ACCESS_REPLY { + Size: DWORD, + ResultListCount: DWORD, + GrantedAccess: PACCESS_MASK, + AccessStatus: PDWORD, + AccessReason: PACCESS_REASONS, + Privileges: *mut PPRIVILEGE_SET, +}} +pub type PSE_ACCESS_REPLY = *mut SE_ACCESS_REPLY; +pub const SE_CREATE_TOKEN_NAME: &'static str = "SeCreateTokenPrivilege"; +pub const SE_ASSIGNPRIMARYTOKEN_NAME: &'static str = "SeAssignPrimaryTokenPrivilege"; +pub const SE_LOCK_MEMORY_NAME: &'static str = "SeLockMemoryPrivilege"; +pub const SE_INCREASE_QUOTA_NAME: &'static str = "SeIncreaseQuotaPrivilege"; +pub const SE_UNSOLICITED_INPUT_NAME: &'static str = "SeUnsolicitedInputPrivilege"; +pub const SE_MACHINE_ACCOUNT_NAME: &'static str = "SeMachineAccountPrivilege"; +pub const SE_TCB_NAME: &'static str = "SeTcbPrivilege"; +pub const SE_SECURITY_NAME: &'static str = "SeSecurityPrivilege"; +pub const SE_TAKE_OWNERSHIP_NAME: &'static str = "SeTakeOwnershipPrivilege"; +pub const SE_LOAD_DRIVER_NAME: &'static str = "SeLoadDriverPrivilege"; +pub const SE_SYSTEM_PROFILE_NAME: &'static str = "SeSystemProfilePrivilege"; +pub const SE_SYSTEMTIME_NAME: &'static str = "SeSystemtimePrivilege"; +pub const SE_PROF_SINGLE_PROCESS_NAME: &'static str = "SeProfileSingleProcessPrivilege"; +pub const SE_INC_BASE_PRIORITY_NAME: &'static str = "SeIncreaseBasePriorityPrivilege"; +pub const SE_CREATE_PAGEFILE_NAME: &'static str = "SeCreatePagefilePrivilege"; +pub const SE_CREATE_PERMANENT_NAME: &'static str = "SeCreatePermanentPrivilege"; +pub const SE_BACKUP_NAME: &'static str = "SeBackupPrivilege"; +pub const SE_RESTORE_NAME: &'static str = "SeRestorePrivilege"; +pub const SE_SHUTDOWN_NAME: &'static str = "SeShutdownPrivilege"; +pub const SE_DEBUG_NAME: &'static str = "SeDebugPrivilege"; +pub const SE_AUDIT_NAME: &'static str = "SeAuditPrivilege"; +pub const SE_SYSTEM_ENVIRONMENT_NAME: &'static str = "SeSystemEnvironmentPrivilege"; +pub const SE_CHANGE_NOTIFY_NAME: &'static str = "SeChangeNotifyPrivilege"; +pub const SE_REMOTE_SHUTDOWN_NAME: &'static str = "SeRemoteShutdownPrivilege"; +pub const SE_UNDOCK_NAME: &'static str = "SeUndockPrivilege"; +pub const SE_SYNC_AGENT_NAME: &'static str = "SeSyncAgentPrivilege"; +pub const SE_ENABLE_DELEGATION_NAME: &'static str = "SeEnableDelegationPrivilege"; +pub const SE_MANAGE_VOLUME_NAME: &'static str = "SeManageVolumePrivilege"; +pub const SE_IMPERSONATE_NAME: &'static str = "SeImpersonatePrivilege"; +pub const SE_CREATE_GLOBAL_NAME: &'static str = "SeCreateGlobalPrivilege"; +pub const SE_TRUSTED_CREDMAN_ACCESS_NAME: &'static str = "SeTrustedCredManAccessPrivilege"; +pub const SE_RELABEL_NAME: &'static str = "SeRelabelPrivilege"; +pub const SE_INC_WORKING_SET_NAME: &'static str = "SeIncreaseWorkingSetPrivilege"; +pub const SE_TIME_ZONE_NAME: &'static str = "SeTimeZonePrivilege"; +pub const SE_CREATE_SYMBOLIC_LINK_NAME: &'static str = "SeCreateSymbolicLinkPrivilege"; +pub const SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME: &'static str + = "SeDelegateSessionUserImpersonatePrivilege"; +pub const SE_ACTIVATE_AS_USER_CAPABILITY: &'static str = "activateAsUser"; +pub const SE_CONSTRAINED_IMPERSONATION_CAPABILITY: &'static str = "constrainedImpersonation"; +pub const SE_SESSION_IMPERSONATION_CAPABILITY: &'static str = "sessionImpersonation"; +pub const SE_MUMA_CAPABILITY: &'static str = "muma"; +pub const SE_DEVELOPMENT_MODE_NETWORK_CAPABILITY: &'static str = "developmentModeNetwork"; +ENUM!{enum SECURITY_IMPERSONATION_LEVEL { + SecurityAnonymous, + SecurityIdentification, + SecurityImpersonation, + SecurityDelegation, +}} +pub type PSECURITY_IMPERSONATION_LEVEL = *mut SECURITY_IMPERSONATION_LEVEL; +pub const SECURITY_MAX_IMPERSONATION_LEVEL: SECURITY_IMPERSONATION_LEVEL = SecurityDelegation; +pub const SECURITY_MIN_IMPERSONATION_LEVEL: SECURITY_IMPERSONATION_LEVEL = SecurityAnonymous; +pub const DEFAULT_IMPERSONATION_LEVEL: SECURITY_IMPERSONATION_LEVEL = SecurityImpersonation; +#[inline] +pub fn VALID_IMPERSONATION_LEVEL(L: SECURITY_IMPERSONATION_LEVEL) -> bool { + (L >= SECURITY_MIN_IMPERSONATION_LEVEL) && (L <= SECURITY_MAX_IMPERSONATION_LEVEL) +} +pub const TOKEN_ASSIGN_PRIMARY: DWORD = 0x0001; +pub const TOKEN_DUPLICATE: DWORD = 0x0002; +pub const TOKEN_IMPERSONATE: DWORD = 0x0004; +pub const TOKEN_QUERY: DWORD = 0x0008; +pub const TOKEN_QUERY_SOURCE: DWORD = 0x0010; +pub const TOKEN_ADJUST_PRIVILEGES: DWORD = 0x0020; +pub const TOKEN_ADJUST_GROUPS: DWORD = 0x0040; +pub const TOKEN_ADJUST_DEFAULT: DWORD = 0x0080; +pub const TOKEN_ADJUST_SESSIONID: DWORD = 0x0100; +pub const TOKEN_ALL_ACCESS_P: DWORD = STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY + | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE + | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT; +pub const TOKEN_ALL_ACCESS: DWORD = TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID; +pub const TOKEN_READ: DWORD = STANDARD_RIGHTS_READ | TOKEN_QUERY; +pub const TOKEN_WRITE: DWORD = STANDARD_RIGHTS_WRITE | TOKEN_ADJUST_PRIVILEGES + | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT; +pub const TOKEN_EXECUTE: DWORD = STANDARD_RIGHTS_EXECUTE; +pub const TOKEN_TRUST_CONSTRAINT_MASK: DWORD = STANDARD_RIGHTS_READ | TOKEN_QUERY + | TOKEN_QUERY_SOURCE; +pub const TOKEN_ACCESS_PSEUDO_HANDLE_WIN8: DWORD = TOKEN_QUERY | TOKEN_QUERY_SOURCE; +pub const TOKEN_ACCESS_PSEUDO_HANDLE: DWORD = TOKEN_ACCESS_PSEUDO_HANDLE_WIN8; +ENUM!{enum TOKEN_TYPE { + TokenPrimary = 1, + TokenImpersonation, +}} +pub type PTOKEN_TYPE = *mut TOKEN_TYPE; +ENUM!{enum TOKEN_ELEVATION_TYPE { + TokenElevationTypeDefault = 1, + TokenElevationTypeFull, + TokenElevationTypeLimited, +}} +pub type PTOKEN_ELEVATION_TYPE = *mut TOKEN_ELEVATION_TYPE; +ENUM!{enum TOKEN_INFORMATION_CLASS { + TokenUser = 1, + TokenGroups, + TokenPrivileges, + TokenOwner, + TokenPrimaryGroup, + TokenDefaultDacl, + TokenSource, + TokenType, + TokenImpersonationLevel, + TokenStatistics, + TokenRestrictedSids, + TokenSessionId, + TokenGroupsAndPrivileges, + TokenSessionReference, + TokenSandBoxInert, + TokenAuditPolicy, + TokenOrigin, + TokenElevationType, + TokenLinkedToken, + TokenElevation, + TokenHasRestrictions, + TokenAccessInformation, + TokenVirtualizationAllowed, + TokenVirtualizationEnabled, + TokenIntegrityLevel, + TokenUIAccess, + TokenMandatoryPolicy, + TokenLogonSid, + TokenIsAppContainer, + TokenCapabilities, + TokenAppContainerSid, + TokenAppContainerNumber, + TokenUserClaimAttributes, + TokenDeviceClaimAttributes, + TokenRestrictedUserClaimAttributes, + TokenRestrictedDeviceClaimAttributes, + TokenDeviceGroups, + TokenRestrictedDeviceGroups, + TokenSecurityAttributes, + TokenIsRestricted, + TokenProcessTrustLevel, + TokenPrivateNameSpace, + TokenSingletonAttributes, + TokenBnoIsolation, + MaxTokenInfoClass, +}} +pub type PTOKEN_INFORMATION_CLASS = *mut TOKEN_INFORMATION_CLASS; +STRUCT!{struct TOKEN_USER { + User: SID_AND_ATTRIBUTES, +}} +pub type PTOKEN_USER = *mut TOKEN_USER; +UNION!{union SE_TOKEN_USER_u1 { + [usize; 2], + TokenUser TokenUser_mut: TOKEN_USER, + User User_mut: SID_AND_ATTRIBUTES, +}} +UNION!{union SE_TOKEN_USER_u2 { + [u32; 17], + Sid Sid_mut: SID, + Buffer Buffer_mut: [BYTE; SECURITY_MAX_SID_SIZE], +}} +STRUCT!{struct SE_TOKEN_USER { + u1: SE_TOKEN_USER_u1, + u2: SE_TOKEN_USER_u2, +}} +pub type PSE_TOKEN_USER = *mut SE_TOKEN_USER; +STRUCT!{struct TOKEN_GROUPS { + GroupCount: DWORD, + Groups: [SID_AND_ATTRIBUTES; ANYSIZE_ARRAY], +}} +pub type PTOKEN_GROUPS = *mut TOKEN_GROUPS; +STRUCT!{struct TOKEN_PRIVILEGES { + PrivilegeCount: DWORD, + Privileges: [LUID_AND_ATTRIBUTES; ANYSIZE_ARRAY], +}} +pub type PTOKEN_PRIVILEGES = *mut TOKEN_PRIVILEGES; +STRUCT!{struct TOKEN_OWNER { + Owner: PSID, +}} +pub type PTOKEN_OWNER = *mut TOKEN_OWNER; +STRUCT!{struct TOKEN_PRIMARY_GROUP { + PrimaryGroup: PSID, +}} +pub type PTOKEN_PRIMARY_GROUP = *mut TOKEN_PRIMARY_GROUP; +STRUCT!{struct TOKEN_DEFAULT_DACL { + DefaultDacl: PACL, +}} +pub type PTOKEN_DEFAULT_DACL = *mut TOKEN_DEFAULT_DACL; +STRUCT!{struct TOKEN_USER_CLAIMS { + UserClaims: PCLAIMS_BLOB, +}} +pub type PTOKEN_USER_CLAIMS = *mut TOKEN_USER_CLAIMS; +STRUCT!{struct TOKEN_DEVICE_CLAIMS { + DeviceClaims: PCLAIMS_BLOB, +}} +pub type PTOKEN_DEVICE_CLAIMS = *mut TOKEN_DEVICE_CLAIMS; +STRUCT!{struct TOKEN_GROUPS_AND_PRIVILEGES { + SidCount: DWORD, + SidLength: DWORD, + Sids: PSID_AND_ATTRIBUTES, + RestrictedSidCount: DWORD, + RestrictedSidLength: DWORD, + RestrictedSids: PSID_AND_ATTRIBUTES, + PrivilegeCount: DWORD, + PrivilegeLength: DWORD, + Privileges: PLUID_AND_ATTRIBUTES, + AuthenticationId: LUID, +}} +pub type PTOKEN_GROUPS_AND_PRIVILEGES = *mut TOKEN_GROUPS_AND_PRIVILEGES; +STRUCT!{struct TOKEN_LINKED_TOKEN { + LinkedToken: HANDLE, +}} +pub type PTOKEN_LINKED_TOKEN = *mut TOKEN_LINKED_TOKEN; +STRUCT!{struct TOKEN_ELEVATION { + TokenIsElevated: DWORD, +}} +pub type PTOKEN_ELEVATION = *mut TOKEN_ELEVATION; +STRUCT!{struct TOKEN_MANDATORY_LABEL { + Label: SID_AND_ATTRIBUTES, +}} +pub type PTOKEN_MANDATORY_LABEL = *mut TOKEN_MANDATORY_LABEL; +pub const TOKEN_MANDATORY_POLICY_OFF: DWORD = 0x0; +pub const TOKEN_MANDATORY_POLICY_NO_WRITE_UP: DWORD = 0x1; +pub const TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN: DWORD = 0x2; +pub const TOKEN_MANDATORY_POLICY_VALID_MASK: DWORD = TOKEN_MANDATORY_POLICY_NO_WRITE_UP + | TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN; +STRUCT!{struct TOKEN_MANDATORY_POLICY { + Policy: DWORD, +}} +pub type PTOKEN_MANDATORY_POLICY = *mut TOKEN_MANDATORY_POLICY; +pub type PSECURITY_ATTRIBUTES_OPAQUE = PVOID; +STRUCT!{struct TOKEN_ACCESS_INFORMATION { + SidHash: PSID_AND_ATTRIBUTES_HASH, + RestrictedSidHash: PSID_AND_ATTRIBUTES_HASH, + Privileges: PTOKEN_PRIVILEGES, + AuthenticationId: LUID, + TokenType: TOKEN_TYPE, + ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, + MandatoryPolicy: TOKEN_MANDATORY_POLICY, + Flags: DWORD, + AppContainerNumber: DWORD, + PackageSid: PSID, + CapabilitiesHash: PSID_AND_ATTRIBUTES_HASH, + TrustLevelSid: PSID, + SecurityAttributes: PSECURITY_ATTRIBUTES_OPAQUE, +}} +pub type PTOKEN_ACCESS_INFORMATION = *mut TOKEN_ACCESS_INFORMATION; +pub const POLICY_AUDIT_SUBCATEGORY_COUNT: usize = 59; +STRUCT!{struct TOKEN_AUDIT_POLICY { + PerUserPolicy: [BYTE; (POLICY_AUDIT_SUBCATEGORY_COUNT >> 1) + 1], +}} +pub type PTOKEN_AUDIT_POLICY = *mut TOKEN_AUDIT_POLICY; +pub const TOKEN_SOURCE_LENGTH: usize = 8; +STRUCT!{struct TOKEN_SOURCE { + SourceName: [CHAR; TOKEN_SOURCE_LENGTH], + SourceIdentifier: LUID, +}} +pub type PTOKEN_SOURCE = *mut TOKEN_SOURCE; +STRUCT!{struct TOKEN_STATISTICS { + TokenId: LUID, + AuthenticationId: LUID, + ExpirationTime: LARGE_INTEGER, + TokenType: TOKEN_TYPE, + ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, + DynamicCharged: DWORD, + DynamicAvailable: DWORD, + GroupCount: DWORD, + PrivilegeCount: DWORD, + ModifiedId: LUID, +}} +pub type PTOKEN_STATISTICS = *mut TOKEN_STATISTICS; +STRUCT!{struct TOKEN_CONTROL { + TokenId: LUID, + AuthenticationId: LUID, + ModifiedId: LUID, + TokenSource: TOKEN_SOURCE, +}} +pub type PTOKEN_CONTROL = *mut TOKEN_CONTROL; +STRUCT!{struct TOKEN_ORIGIN { + OriginatingLogonSession: LUID, +}} +pub type PTOKEN_ORIGIN = *mut TOKEN_ORIGIN; +ENUM!{enum MANDATORY_LEVEL { + MandatoryLevelUntrusted = 0, + MandatoryLevelLow, + MandatoryLevelMedium, + MandatoryLevelHigh, + MandatoryLevelSystem, + MandatoryLevelSecureProcess, + MandatoryLevelCount, +}} +pub type PMANDATORY_LEVEL = *mut MANDATORY_LEVEL; +STRUCT!{struct TOKEN_APPCONTAINER_INFORMATION { + TokenAppContainer: PSID, +}} +pub type PTOKEN_APPCONTAINER_INFORMATION = *mut TOKEN_APPCONTAINER_INFORMATION; +STRUCT!{struct TOKEN_SID_INFORMATION { + Sid: PSID, +}} +pub type PTOKEN_SID_INFORMATION = *mut TOKEN_SID_INFORMATION; +STRUCT!{struct TOKEN_BNO_ISOLATION_INFORMATION { + IsolationPrefix: PWSTR, + IsolationEnabled: BOOLEAN, +}} +pub type PTOKEN_BNO_ISOLATION_INFORMATION = *mut TOKEN_BNO_ISOLATION_INFORMATION; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_INVALID: WORD = 0x00; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_INT64: WORD = 0x01; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_UINT64: WORD = 0x02; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_STRING: WORD = 0x03; +STRUCT!{struct CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE { + Version: DWORD64, + Name: PWSTR, +}} +pub type PCLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE = *mut CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_FQBN: WORD = 0x04; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_SID: WORD = 0x05; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_BOOLEAN: WORD = 0x06; +STRUCT!{struct CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE { + pValue: PVOID, + ValueLength: DWORD, +}} +pub type PCLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE = + *mut CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE; +pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_OCTET_STRING: WORD = 0x10; +pub const CLAIM_SECURITY_ATTRIBUTE_NON_INHERITABLE: DWORD = 0x0001; +pub const CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE: DWORD = 0x0002; +pub const CLAIM_SECURITY_ATTRIBUTE_USE_FOR_DENY_ONLY: DWORD = 0x0004; +pub const CLAIM_SECURITY_ATTRIBUTE_DISABLED_BY_DEFAULT: DWORD = 0x0008; +pub const CLAIM_SECURITY_ATTRIBUTE_DISABLED: DWORD = 0x0010; +pub const CLAIM_SECURITY_ATTRIBUTE_MANDATORY: DWORD = 0x0020; +pub const CLAIM_SECURITY_ATTRIBUTE_VALID_FLAGS: DWORD = CLAIM_SECURITY_ATTRIBUTE_NON_INHERITABLE + | CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE | CLAIM_SECURITY_ATTRIBUTE_USE_FOR_DENY_ONLY + | CLAIM_SECURITY_ATTRIBUTE_DISABLED_BY_DEFAULT | CLAIM_SECURITY_ATTRIBUTE_DISABLED + | CLAIM_SECURITY_ATTRIBUTE_MANDATORY; +pub const CLAIM_SECURITY_ATTRIBUTE_CUSTOM_FLAGS: DWORD = 0xFFFF0000; +UNION!{union CLAIM_SECURITY_ATTRIBUTE_V1_Values { + [usize; 1], + pInt64 pInt64_mut: PLONG64, + pUint64 pUint64_mut: PDWORD64, + ppString ppString_mut: PWSTR, + pFqbn pFqbn_mut: PCLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE, + pOctetString pOctetString_mut: PCLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE, +}} +STRUCT!{struct CLAIM_SECURITY_ATTRIBUTE_V1 { + Name: PWSTR, + ValueType: WORD, + Reserved: WORD, + Flags: DWORD, + ValueCount: DWORD, + Values: CLAIM_SECURITY_ATTRIBUTE_V1_Values, +}} +pub type PCLAIM_SECURITY_ATTRIBUTE_V1 = *mut CLAIM_SECURITY_ATTRIBUTE_V1; +UNION!{union CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1_Values { + [u32; 1], + pInt64 pInt64_mut: [DWORD; ANYSIZE_ARRAY], + pUint64 pUint64_mut: [DWORD; ANYSIZE_ARRAY], + ppString ppString_mut: [DWORD; ANYSIZE_ARRAY], + pFqbn pFqbn_mut: [DWORD; ANYSIZE_ARRAY], + pOctetString pOctetString_mut: [DWORD; ANYSIZE_ARRAY], +}} +STRUCT!{struct CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 { + Name: DWORD, + ValueType: WORD, + Reserved: WORD, + Flags: DWORD, + ValueCount: DWORD, + Values: CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1_Values, +}} +pub type PCLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 = *mut CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1; +pub const CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION_V1: WORD = 1; +pub const CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION: WORD = + CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION_V1; +UNION!{union CLAIM_SECURITY_ATTRIBUTES_INFORMATION_Attribute { + [usize; 1], + pAttributeV1 pAttributeV1_mut: PCLAIM_SECURITY_ATTRIBUTE_V1, +}} +STRUCT!{struct CLAIM_SECURITY_ATTRIBUTES_INFORMATION { + Version: WORD, + Reserved: WORD, + AttributeCount: DWORD, + Attribute: CLAIM_SECURITY_ATTRIBUTES_INFORMATION_Attribute, +}} +pub type PCLAIM_SECURITY_ATTRIBUTES_INFORMATION = *mut CLAIM_SECURITY_ATTRIBUTES_INFORMATION; +pub const SECURITY_DYNAMIC_TRACKING: BOOLEAN = TRUE as u8; +pub const SECURITY_STATIC_TRACKING: BOOLEAN = FALSE as u8; +pub type SECURITY_CONTEXT_TRACKING_MODE = BOOLEAN; +pub type PSECURITY_CONTEXT_TRACKING_MODE = *mut BOOLEAN; +STRUCT!{struct SECURITY_QUALITY_OF_SERVICE { + Length: DWORD, + ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, + ContextTrackingMode: SECURITY_CONTEXT_TRACKING_MODE, + EffectiveOnly: BOOLEAN, +}} +pub type PSECURITY_QUALITY_OF_SERVICE = *mut SECURITY_QUALITY_OF_SERVICE; +STRUCT!{struct SE_IMPERSONATION_STATE { + Token: PACCESS_TOKEN, + CopyOnOpen: BOOLEAN, + EffectiveOnly: BOOLEAN, + Level: SECURITY_IMPERSONATION_LEVEL, +}} +pub type PSE_IMPERSONATION_STATE = *mut SE_IMPERSONATION_STATE; +pub const DISABLE_MAX_PRIVILEGE: DWORD = 0x1; +pub const SANDBOX_INERT: DWORD = 0x2; +pub const LUA_TOKEN: DWORD = 0x4; +pub const WRITE_RESTRICTED: DWORD = 0x8; +pub type SECURITY_INFORMATION = DWORD; +pub type PSECURITY_INFORMATION = *mut DWORD; +pub const OWNER_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000001; +pub const GROUP_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000002; +pub const DACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000004; +pub const SACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000008; +pub const LABEL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000010; +pub const ATTRIBUTE_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000020; +pub const SCOPE_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000040; +pub const PROCESS_TRUST_LABEL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000080; +pub const ACCESS_FILTER_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000100; +pub const BACKUP_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00010000; +pub const PROTECTED_DACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x80000000; +pub const PROTECTED_SACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x40000000; +pub const UNPROTECTED_DACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x20000000; +pub const UNPROTECTED_SACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x10000000; +pub type SE_SIGNING_LEVEL = BYTE; +pub type PSE_SIGNING_LEVEL = *mut BYTE; +pub const SE_SIGNING_LEVEL_UNCHECKED: BYTE = 0x00000000; +pub const SE_SIGNING_LEVEL_UNSIGNED: BYTE = 0x00000001; +pub const SE_SIGNING_LEVEL_ENTERPRISE: BYTE = 0x00000002; +pub const SE_SIGNING_LEVEL_CUSTOM_1: BYTE = 0x00000003; +pub const SE_SIGNING_LEVEL_AUTHENTICODE: BYTE = 0x00000004; +pub const SE_SIGNING_LEVEL_CUSTOM_2: BYTE = 0x00000005; +pub const SE_SIGNING_LEVEL_STORE: BYTE = 0x00000006; +pub const SE_SIGNING_LEVEL_CUSTOM_3: BYTE = 0x00000007; +pub const SE_SIGNING_LEVEL_ANTIMALWARE: BYTE = SE_SIGNING_LEVEL_CUSTOM_3; +pub const SE_SIGNING_LEVEL_MICROSOFT: BYTE = 0x00000008; +pub const SE_SIGNING_LEVEL_CUSTOM_4: BYTE = 0x00000009; +pub const SE_SIGNING_LEVEL_CUSTOM_5: BYTE = 0x0000000A; +pub const SE_SIGNING_LEVEL_DYNAMIC_CODEGEN: BYTE = 0x0000000B; +pub const SE_SIGNING_LEVEL_WINDOWS: BYTE = 0x0000000C; +pub const SE_SIGNING_LEVEL_CUSTOM_7: BYTE = 0x0000000D; +pub const SE_SIGNING_LEVEL_WINDOWS_TCB: BYTE = 0x0000000E; +pub const SE_SIGNING_LEVEL_CUSTOM_6: BYTE = 0x0000000F; +ENUM!{enum SE_IMAGE_SIGNATURE_TYPE { + SeImageSignatureNone = 0, + SeImageSignatureEmbedded, + SeImageSignatureCache, + SeImageSignatureCatalogCached, + SeImageSignatureCatalogNotCached, + SeImageSignatureCatalogHint, + SeImageSignaturePackageCatalog, +}} +pub type PSE_IMAGE_SIGNATURE_TYPE = *mut SE_IMAGE_SIGNATURE_TYPE; +ENUM!{enum SE_LEARNING_MODE_DATA_TYPE { + SeLearningModeInvalidType = 0, + SeLearningModeSettings, + SeLearningModeMax, +}} +STRUCT!{struct SECURITY_CAPABILITIES { + AppContainerSid: PSID, + Capabilities: PSID_AND_ATTRIBUTES, + CapabilityCount: DWORD, + Reserved: DWORD, +}} +pub type PSECURITY_CAPABILITIES = *mut SECURITY_CAPABILITIES; +pub type LPSECURITY_CAPABILITIES = *mut SECURITY_CAPABILITIES; +pub const PROCESS_TERMINATE: DWORD = 0x0001; +pub const PROCESS_CREATE_THREAD: DWORD = 0x0002; +pub const PROCESS_SET_SESSIONID: DWORD = 0x0004; +pub const PROCESS_VM_OPERATION: DWORD = 0x0008; +pub const PROCESS_VM_READ: DWORD = 0x0010; +pub const PROCESS_VM_WRITE: DWORD = 0x0020; +pub const PROCESS_DUP_HANDLE: DWORD = 0x0040; +pub const PROCESS_CREATE_PROCESS: DWORD = 0x0080; +pub const PROCESS_SET_QUOTA: DWORD = 0x0100; +pub const PROCESS_SET_INFORMATION: DWORD = 0x0200; +pub const PROCESS_QUERY_INFORMATION: DWORD = 0x0400; +pub const PROCESS_SUSPEND_RESUME: DWORD = 0x0800; +pub const PROCESS_QUERY_LIMITED_INFORMATION: DWORD = 0x1000; +pub const PROCESS_SET_LIMITED_INFORMATION: DWORD = 0x2000; +pub const PROCESS_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF; +pub const THREAD_TERMINATE: DWORD = 0x0001; +pub const THREAD_SUSPEND_RESUME: DWORD = 0x0002; +pub const THREAD_GET_CONTEXT: DWORD = 0x0008; +pub const THREAD_SET_CONTEXT: DWORD = 0x0010; +pub const THREAD_QUERY_INFORMATION: DWORD = 0x0040; +pub const THREAD_SET_INFORMATION: DWORD = 0x0020; +pub const THREAD_SET_THREAD_TOKEN: DWORD = 0x0080; +pub const THREAD_IMPERSONATE: DWORD = 0x0100; +pub const THREAD_DIRECT_IMPERSONATION: DWORD = 0x0200; +pub const THREAD_SET_LIMITED_INFORMATION: DWORD = 0x0400; +pub const THREAD_QUERY_LIMITED_INFORMATION: DWORD = 0x0800; +pub const THREAD_RESUME: DWORD = 0x1000; +pub const THREAD_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF; +pub const JOB_OBJECT_ASSIGN_PROCESS: DWORD = 0x0001; +pub const JOB_OBJECT_SET_ATTRIBUTES: DWORD = 0x0002; +pub const JOB_OBJECT_QUERY: DWORD = 0x0004; +pub const JOB_OBJECT_TERMINATE: DWORD = 0x0008; +pub const JOB_OBJECT_SET_SECURITY_ATTRIBUTES: DWORD = 0x0010; +pub const JOB_OBJECT_IMPERSONATE: DWORD = 0x0020; +pub const JOB_OBJECT_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3F; +STRUCT!{struct JOB_SET_ARRAY { + JobHandle: HANDLE, + MemberLevel: DWORD, + Flags: DWORD, +}} +pub type PJOB_SET_ARRAY = *mut JOB_SET_ARRAY; +pub const FLS_MAXIMUM_AVAILABLE: DWORD = 128; +pub const TLS_MINIMUM_AVAILABLE: DWORD = 64; +STRUCT!{struct EXCEPTION_REGISTRATION_RECORD { + Next: *mut EXCEPTION_REGISTRATION_RECORD, + Handler: PEXCEPTION_ROUTINE, +}} +pub type PEXCEPTION_REGISTRATION_RECORD = *mut EXCEPTION_REGISTRATION_RECORD; +UNION!{union NT_TIB_u { + [usize; 1], + FiberData FiberData_mut: PVOID, + Version Version_mut: DWORD, +}} +STRUCT!{struct NT_TIB { + ExceptionList: *mut EXCEPTION_REGISTRATION_RECORD, + StackBase: PVOID, + StackLimit: PVOID, + SubSystemTib: PVOID, + u: NT_TIB_u, + ArbitraryUserPointer: PVOID, + _Self: *mut NT_TIB, +}} +pub type PNT_TIB = *mut NT_TIB; +UNION!{union NT_TIB32_u { + [u32; 1], + FiberData FiberData_mut: DWORD, + Version Version_mut: DWORD, +}} +STRUCT!{struct NT_TIB32 { + ExceptionList: DWORD, + StackBase: DWORD, + StackLimit: DWORD, + SubSystemTib: DWORD, + u: NT_TIB32_u, + ArbitraryUserPointer: DWORD, + Self_: DWORD, +}} +pub type PNT_TIB32 = *mut NT_TIB32; +UNION!{union NT_TIB64_u { + [u64; 1], + FiberData FiberData_mut: DWORD64, + Version Version_mut: DWORD, +}} +STRUCT!{struct NT_TIB64 { + ExceptionList: DWORD64, + StackBase: DWORD64, + StackLimit: DWORD64, + SubSystemTib: DWORD64, + u: NT_TIB64_u, + ArbitraryUserPointer: DWORD64, + _Self: DWORD64, +}} +pub type PNT_TIB64 = *mut NT_TIB64; +pub const THREAD_DYNAMIC_CODE_ALLOW: DWORD = 1; +pub const THREAD_BASE_PRIORITY_LOWRT: DWORD = 15; +pub const THREAD_BASE_PRIORITY_MAX: DWORD = 2; +pub const THREAD_BASE_PRIORITY_MIN: DWORD = -2i32 as u32; +pub const THREAD_BASE_PRIORITY_IDLE: DWORD = -15i32 as u32; +STRUCT!{struct UMS_CREATE_THREAD_ATTRIBUTES { + UmsVersion: DWORD, + UmsContext: PVOID, + UmsCompletionList: PVOID, +}} +pub type PUMS_CREATE_THREAD_ATTRIBUTES = *mut UMS_CREATE_THREAD_ATTRIBUTES; +STRUCT!{struct WOW64_ARCHITECTURE_INFORMATION { + BitFields: DWORD, +}} +pub type PWOW64_ARCHITECTURE_INFORMATION = *mut WOW64_ARCHITECTURE_INFORMATION; +BITFIELD!{WOW64_ARCHITECTURE_INFORMATION BitFields: DWORD [ + Machine set_Machine[0..16], + KernelMode set_KernelMode[16..17], + UserMode set_UserMode[17..18], + Native set_Native[18..19], + Process set_Process[19..20], + ReservedZero0 set_ReservedZero0[20..32], +]} +pub const MEMORY_PRIORITY_LOWEST: ULONG = 0; +pub const MEMORY_PRIORITY_VERY_LOW: ULONG = 1; +pub const MEMORY_PRIORITY_LOW: ULONG = 2; +pub const MEMORY_PRIORITY_MEDIUM: ULONG = 3; +pub const MEMORY_PRIORITY_BELOW_NORMAL: ULONG = 4; +pub const MEMORY_PRIORITY_NORMAL: ULONG = 5; +STRUCT!{struct QUOTA_LIMITS { + PagedPoolLimit: SIZE_T, + NonPagedPoolLimit: SIZE_T, + MinimumWorkingSetSize: SIZE_T, + MaximumWorkingSetSize: SIZE_T, + PagefileLimit: SIZE_T, + TimeLimit: LARGE_INTEGER, +}} +pub type PQUOTA_LIMITS = *mut QUOTA_LIMITS; +pub const QUOTA_LIMITS_HARDWS_MIN_ENABLE: DWORD = 0x00000001; +pub const QUOTA_LIMITS_HARDWS_MIN_DISABLE: DWORD = 0x00000002; +pub const QUOTA_LIMITS_HARDWS_MAX_ENABLE: DWORD = 0x00000004; +pub const QUOTA_LIMITS_HARDWS_MAX_DISABLE: DWORD = 0x00000008; +pub const QUOTA_LIMITS_USE_DEFAULT_LIMITS: DWORD = 0x00000010; +STRUCT!{struct RATE_QUOTA_LIMIT { + RateData: DWORD, +}} +BITFIELD!{RATE_QUOTA_LIMIT RateData: DWORD [ + RatePercent set_RatePercent[0..7], + Reserved0 set_Reserved0[7..32], +]} +pub type PRATE_QUOTA_LIMIT = *mut RATE_QUOTA_LIMIT; +STRUCT!{struct QUOTA_LIMITS_EX { + PagedPoolLimit: SIZE_T, + NonPagedPoolLimit: SIZE_T, + MinimumWorkingSetSize: SIZE_T, + MaximumWorkingSetSize: SIZE_T, + PagefileLimit: SIZE_T, + TimeLimit: LARGE_INTEGER, + WorkingSetLimit: SIZE_T, + Reserved2: SIZE_T, + Reserved3: SIZE_T, + Reserved4: SIZE_T, + Flags: DWORD, + CpuRateLimit: RATE_QUOTA_LIMIT, +}} +pub type PQUOTA_LIMITS_EX = *mut QUOTA_LIMITS_EX; +STRUCT!{struct IO_COUNTERS { + ReadOperationCount: ULONGLONG, + WriteOperationCount: ULONGLONG, + OtherOperationCount: ULONGLONG, + ReadTransferCount: ULONGLONG, + WriteTransferCount: ULONGLONG, + OtherTransferCount: ULONGLONG, +}} +pub type PIO_COUNTERS = *mut IO_COUNTERS; +pub const MAX_HW_COUNTERS: usize = 16; +pub const THREAD_PROFILING_FLAG_DISPATCH: DWORD = 0x00000001; +ENUM!{enum HARDWARE_COUNTER_TYPE { + PMCCounter, + MaxHardwareCounterType, +}} +pub type PHARDWARE_COUNTER_TYPE = *mut HARDWARE_COUNTER_TYPE; +ENUM!{enum PROCESS_MITIGATION_POLICY { + ProcessDEPPolicy, + ProcessASLRPolicy, + ProcessDynamicCodePolicy, + ProcessStrictHandleCheckPolicy, + ProcessSystemCallDisablePolicy, + ProcessMitigationOptionsMask, + ProcessExtensionPointDisablePolicy, + ProcessControlFlowGuardPolicy, + ProcessSignaturePolicy, + ProcessFontDisablePolicy, + ProcessImageLoadPolicy, + MaxProcessMitigationPolicy, +}} +pub type PPROCESS_MITIGATION_POLICY = *mut PROCESS_MITIGATION_POLICY; +STRUCT!{struct PROCESS_MITIGATION_ASLR_POLICY { + Flags: DWORD, +}} +BITFIELD!{PROCESS_MITIGATION_ASLR_POLICY Flags: DWORD [ + EnableBottomUpRandomization set_EnableBottomUpRandomization[0..1], + EnableForceRelocateImages set_EnableForceRelocateImages[1..2], + EnableHighEntropy set_EnableHighEntropy[2..3], + DisallowStrippedImages set_DisallowStrippedImages[3..4], + ReservedFlags set_ReservedFlags[4..32], +]} +pub type PPROCESS_MITIGATION_ASLR_POLICY = *mut PROCESS_MITIGATION_ASLR_POLICY; +STRUCT!{struct PROCESS_MITIGATION_DEP_POLICY { + Flags: DWORD, + Permanent: BOOLEAN, +}} +BITFIELD!{PROCESS_MITIGATION_DEP_POLICY Flags: DWORD [ + Enable set_Enable[0..1], + DisableAtlThunkEmulation set_DisableAtlThunkEmulation[1..2], + ReservedFlags set_ReservedFlags[2..32], +]} +pub type PPROCESS_MITIGATION_DEP_POLICY = *mut PROCESS_MITIGATION_DEP_POLICY; +STRUCT!{struct PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY { + Flags: DWORD, +}} +BITFIELD!{PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY Flags: DWORD [ + RaiseExceptionOnInvalidHandleReference set_RaiseExceptionOnInvalidHandleReference[0..1], + HandleExceptionsPermanentlyEnabled set_HandleExceptionsPermanentlyEnabled[1..2], + ReservedFlags set_ReservedFlags[2..32], +]} +pub type PPROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY + = *mut PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY; +STRUCT!{struct PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY { + Flags: DWORD, +}} +BITFIELD!{PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY Flags: DWORD [ + DisallowWin32kSystemCalls set_DisallowWin32kSystemCalls[0..1], + ReservedFlags set_ReservedFlags[1..32], +]} +pub type PPROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY + = *mut PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY; +STRUCT!{struct PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY { + Flags: DWORD, +}} +BITFIELD!{PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY Flags: DWORD [ + DisableExtensionPoints set_DisableExtensionPoints[0..1], + ReservedFlags set_ReservedFlags[1..32], +]} +pub type PPROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY + = *mut PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY; +STRUCT!{struct PROCESS_MITIGATION_DYNAMIC_CODE_POLICY { + Flags: DWORD, +}} +BITFIELD!{PROCESS_MITIGATION_DYNAMIC_CODE_POLICY Flags: DWORD [ + ProhibitDynamicCode set_ProhibitDynamicCode[0..1], + AllowThreadOptOut set_AllowThreadOptOut[1..2], + AllowRemoteDowngrade set_AllowRemoteDowngrade[2..3], + ReservedFlags set_ReservedFlags[3..32], +]} +pub type PPROCESS_MITIGATION_DYNAMIC_CODE_POLICY = *mut PROCESS_MITIGATION_DYNAMIC_CODE_POLICY; +STRUCT!{struct PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY { + Flags: DWORD, +}} +BITFIELD!{PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY Flags: DWORD [ + EnableControlFlowGuard set_EnableControlFlowGuard[0..1], + EnableExportSuppression set_EnableExportSuppression[1..2], + StrictMode set_StrictMode[2..3], + ReservedFlags set_ReservedFlags[3..32], +]} +pub type PPROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY + = *mut PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY; +STRUCT!{struct PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY { + Flags: DWORD, +}} +BITFIELD!{PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY Flags: DWORD [ + MicrosoftSignedOnly set_MicrosoftSignedOnly[0..1], + StoreSignedOnly set_StoreSignedOnly[1..2], + MitigationOptIn set_MitigationOptIn[2..3], + ReservedFlags set_ReservedFlags[3..32], +]} +pub type PPROCESS_MITIGATION_BINARY_SIGNATURE_POLICY + = *mut PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY; +STRUCT!{struct PROCESS_MITIGATION_FONT_DISABLE_POLICY { + Flags: DWORD, +}} +BITFIELD!{PROCESS_MITIGATION_FONT_DISABLE_POLICY Flags: DWORD [ + DisableNonSystemFonts set_DisableNonSystemFonts[0..1], + AuditNonSystemFontLoading set_AuditNonSystemFontLoading[1..2], + ReservedFlags set_ReservedFlags[2..32], +]} +pub type PPROCESS_MITIGATION_FONT_DISABLE_POLICY = *mut PROCESS_MITIGATION_FONT_DISABLE_POLICY; +STRUCT!{struct PROCESS_MITIGATION_IMAGE_LOAD_POLICY { + Flags: DWORD, +}} +BITFIELD!{PROCESS_MITIGATION_IMAGE_LOAD_POLICY Flags: DWORD [ + NoRemoteImages set_NoRemoteImages[0..1], + NoLowMandatoryLabelImages set_NoLowMandatoryLabelImages[1..2], + PreferSystem32Images set_PreferSystem32Images[2..3], + ReservedFlags set_ReservedFlags[3..32], +]} +pub type PPROCESS_MITIGATION_IMAGE_LOAD_POLICY = *mut PROCESS_MITIGATION_IMAGE_LOAD_POLICY; +STRUCT!{struct PROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY { + Flags: DWORD, +}} +pub type PPPROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY = + *mut PROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY; +BITFIELD!{PROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY Flags: DWORD [ + FilterId set_FilterId[0..4], + ReservedFlags set_ReservedFlags[4..32], +]} +STRUCT!{struct PROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY { + Flags: DWORD, +}} +pub type PPROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY = + *mut PROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY; +BITFIELD!{PROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY Flags: DWORD [ + EnableExportAddressFilter set_EnableExportAddressFilter[0..1], + AuditExportAddressFilter set_AuditExportAddressFilter[1..2], + EnableExportAddressFilterPlus set_EnableExportAddressFilterPlus[2..3], + AuditExportAddressFilterPlus set_AuditExportAddressFilterPlus[3..4], + EnableImportAddressFilter set_EnableImportAddressFilter[4..5], + AuditImportAddressFilter set_AuditImportAddressFilter[5..6], + EnableRopStackPivot set_EnableRopStackPivot[6..7], + AuditRopStackPivot set_AuditRopStackPivot[7..8], + EnableRopCallerCheck set_EnableRopCallerCheck[8..9], + AuditRopCallerCheck set_AuditRopCallerCheck[9..10], + EnableRopSimExec set_EnableRopSimExec[10..11], + AuditRopSimExec set_AuditRopSimExec[11..12], + ReservedFlags set_ReservedFlags[12..32], +]} +STRUCT!{struct PROCESS_MITIGATION_CHILD_PROCESS_POLICY { + Flags: DWORD, +}} +pub type PPROCESS_MITIGATION_CHILD_PROCESS_POLICY = *mut PROCESS_MITIGATION_CHILD_PROCESS_POLICY; +BITFIELD!{PROCESS_MITIGATION_CHILD_PROCESS_POLICY Flags: DWORD [ + NoChildProcessCreation set_NoChildProcessCreation[0..1], + AuditNoChildProcessCreation set_AuditNoChildProcessCreation[1..2], + AllowSecureProcessCreation set_AllowSecureProcessCreation[2..3], + ReservedFlags set_ReservedFlags[3..32], +]} +STRUCT!{struct JOBOBJECT_BASIC_ACCOUNTING_INFORMATION { + TotalUserTime: LARGE_INTEGER, + TotalKernelTime: LARGE_INTEGER, + ThisPeriodTotalUserTime: LARGE_INTEGER, + ThisPeriodTotalKernelTime: LARGE_INTEGER, + TotalPageFaultCount: DWORD, + TotalProcesses: DWORD, + ActiveProcesses: DWORD, + TotalTerminatedProcesses: DWORD, +}} +pub type PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION = *mut JOBOBJECT_BASIC_ACCOUNTING_INFORMATION; +STRUCT!{struct JOBOBJECT_BASIC_LIMIT_INFORMATION { + PerProcessUserTimeLimit: LARGE_INTEGER, + PerJobUserTimeLimit: LARGE_INTEGER, + LimitFlags: DWORD, + MinimumWorkingSetSize: SIZE_T, + MaximumWorkingSetSize: SIZE_T, + ActiveProcessLimit: DWORD, + Affinity: ULONG_PTR, + PriorityClass: DWORD, + SchedulingClass: DWORD, +}} +pub type PJOBOBJECT_BASIC_LIMIT_INFORMATION = *mut JOBOBJECT_BASIC_LIMIT_INFORMATION; +STRUCT!{struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION { + BasicLimitInformation: JOBOBJECT_BASIC_LIMIT_INFORMATION, + IoInfo: IO_COUNTERS, + ProcessMemoryLimit: SIZE_T, + JobMemoryLimit: SIZE_T, + PeakProcessMemoryUsed: SIZE_T, + PeakJobMemoryUsed: SIZE_T, +}} +pub type PJOBOBJECT_EXTENDED_LIMIT_INFORMATION = *mut JOBOBJECT_EXTENDED_LIMIT_INFORMATION; +STRUCT!{struct JOBOBJECT_BASIC_PROCESS_ID_LIST { + NumberOfAssignedProcesses: DWORD, + NumberOfProcessIdsInList: DWORD, + ProcessIdList: [ULONG_PTR; 1], +}} +pub type PJOBOBJECT_BASIC_PROCESS_ID_LIST = *mut JOBOBJECT_BASIC_PROCESS_ID_LIST; +STRUCT!{struct JOBOBJECT_BASIC_UI_RESTRICTIONS { + UIRestrictionsClass: DWORD, +}} +pub type PJOBOBJECT_BASIC_UI_RESTRICTIONS = *mut JOBOBJECT_BASIC_UI_RESTRICTIONS; +STRUCT!{struct JOBOBJECT_SECURITY_LIMIT_INFORMATION { + SecurityLimitFlags: DWORD, + JobToken: HANDLE, + SidsToDisable: PTOKEN_GROUPS, + PrivilegesToDelete: PTOKEN_PRIVILEGES, + RestrictedSids: PTOKEN_GROUPS, +}} +pub type PJOBOBJECT_SECURITY_LIMIT_INFORMATION = *mut JOBOBJECT_SECURITY_LIMIT_INFORMATION; +STRUCT!{struct JOBOBJECT_END_OF_JOB_TIME_INFORMATION { + EndOfJobTimeAction: DWORD, +}} +pub type PJOBOBJECT_END_OF_JOB_TIME_INFORMATION = *mut JOBOBJECT_END_OF_JOB_TIME_INFORMATION; +STRUCT!{struct JOBOBJECT_ASSOCIATE_COMPLETION_PORT { + CompletionKey: PVOID, + CompletionPort: HANDLE, +}} +pub type PJOBOBJECT_ASSOCIATE_COMPLETION_PORT = *mut JOBOBJECT_ASSOCIATE_COMPLETION_PORT; +STRUCT!{struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION { + BasicInfo: JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, + IoInfo: IO_COUNTERS, +}} +pub type PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION + = *mut JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION; +STRUCT!{struct JOBOBJECT_JOBSET_INFORMATION { + MemberLevel: DWORD, +}} +pub type PJOBOBJECT_JOBSET_INFORMATION = *mut JOBOBJECT_JOBSET_INFORMATION; +ENUM!{enum JOBOBJECT_RATE_CONTROL_TOLERANCE { + ToleranceLow = 1, + ToleranceMedium, + ToleranceHigh, +}} +pub type PJOBOBJECT_RATE_CONTROL_TOLERANCE = *mut JOBOBJECT_RATE_CONTROL_TOLERANCE; +ENUM!{enum JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL { + ToleranceIntervalShort = 1, + ToleranceIntervalMedium, + ToleranceIntervalLong, +}} +pub type PJOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL + = *mut JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL; +STRUCT!{struct JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION { + IoReadBytesLimit: DWORD64, + IoWriteBytesLimit: DWORD64, + PerJobUserTimeLimit: LARGE_INTEGER, + JobMemoryLimit: DWORD64, + RateControlTolerance: JOBOBJECT_RATE_CONTROL_TOLERANCE, + RateControlToleranceInterval: JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL, + LimitFlags: DWORD, +}} +pub type PJOBOBJECT_NOTIFICATION_LIMIT_INFORMATION = *mut JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION; +UNION!{union JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION_2_u1 { + [u64; 1], + JobHighMemoryLimit JobHighMemoryLimit_mut: DWORD64, + JobMemoryLimit JobMemoryLimit_mut: DWORD64, +}} +UNION!{union JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION_2_u2 { + [u32; 1], + RateControlTolerance RateControlTolerance_mut: JOBOBJECT_RATE_CONTROL_TOLERANCE, + CpuRateControlTolerance CpuRateControlTolerance_mut: JOBOBJECT_RATE_CONTROL_TOLERANCE, +}} +UNION!{union JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION_2_u3 { + [u32; 1], + RateControlToleranceInterval RateControlToleranceInterval_mut: + JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL, + CpuRateControlToleranceInterval CpuRateControlToleranceInterval_mut: + JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL, +}} +STRUCT!{struct JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION_2 { + IoReadBytesLimit: DWORD64, + IoWriteBytesLimit: DWORD64, + PerJobUserTimeLimit: LARGE_INTEGER, + u1: JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION_2_u1, + u2: JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION_2_u2, + u3: JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION_2_u3, + LimitFlags: DWORD, + IoRateControlTolerance: JOBOBJECT_RATE_CONTROL_TOLERANCE, + JobLowMemoryLimit: DWORD64, + IoRateControlToleranceInterval: JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL, + NetRateControlTolerance: JOBOBJECT_RATE_CONTROL_TOLERANCE, + NetRateControlToleranceInterval: JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL, +}} +STRUCT!{struct JOBOBJECT_LIMIT_VIOLATION_INFORMATION { + LimitFlags: DWORD, + ViolationLimitFlags: DWORD, + IoReadBytes: DWORD64, + IoReadBytesLimit: DWORD64, + IoWriteBytes: DWORD64, + IoWriteBytesLimit: DWORD64, + PerJobUserTime: LARGE_INTEGER, + PerJobUserTimeLimit: LARGE_INTEGER, + JobMemory: DWORD64, + JobMemoryLimit: DWORD64, + RateControlTolerance: JOBOBJECT_RATE_CONTROL_TOLERANCE, + RateControlToleranceLimit: JOBOBJECT_RATE_CONTROL_TOLERANCE, +}} +pub type PJOBOBJECT_LIMIT_VIOLATION_INFORMATION = *mut JOBOBJECT_LIMIT_VIOLATION_INFORMATION; +UNION!{union JOBOBJECT_LIMIT_VIOLATION_INFORMATION_2_u1 { + [u64; 1], + JobHighMemoryLimit JobHighMemoryLimit_mut: DWORD64, + JobMemoryLimit JobMemoryLimit_mut: DWORD64, +}} +UNION!{union JOBOBJECT_LIMIT_VIOLATION_INFORMATION_2_u2 { + [u32; 1], + RateControlTolerance RateControlTolerance_mut: JOBOBJECT_RATE_CONTROL_TOLERANCE, + CpuRateControlTolerance CpuRateControlTolerance_mut: JOBOBJECT_RATE_CONTROL_TOLERANCE, +}} +UNION!{union JOBOBJECT_LIMIT_VIOLATION_INFORMATION_2_u3 { + [u32; 1], + RateControlToleranceLimit RateControlToleranceLimit_mut: JOBOBJECT_RATE_CONTROL_TOLERANCE, + CpuRateControlToleranceLimit CpuRateControlToleranceLimit_mut: + JOBOBJECT_RATE_CONTROL_TOLERANCE, +}} +STRUCT!{struct JOBOBJECT_LIMIT_VIOLATION_INFORMATION_2 { + LimitFlags: DWORD, + ViolationLimitFlags: DWORD, + IoReadBytes: DWORD64, + IoReadBytesLimit: DWORD64, + IoWriteBytes: DWORD64, + IoWriteBytesLimit: DWORD64, + PerJobUserTime: LARGE_INTEGER, + PerJobUserTimeLimit: LARGE_INTEGER, + JobMemory: DWORD64, + u1: JOBOBJECT_LIMIT_VIOLATION_INFORMATION_2_u1, + u2: JOBOBJECT_LIMIT_VIOLATION_INFORMATION_2_u2, + u3: JOBOBJECT_LIMIT_VIOLATION_INFORMATION_2_u3, + JobLowMemoryLimit: DWORD64, + IoRateControlTolerance: JOBOBJECT_RATE_CONTROL_TOLERANCE, + IoRateControlToleranceLimit: JOBOBJECT_RATE_CONTROL_TOLERANCE, + NetRateControlTolerance: JOBOBJECT_RATE_CONTROL_TOLERANCE, + NetRateControlToleranceLimit: JOBOBJECT_RATE_CONTROL_TOLERANCE, +}} +STRUCT!{struct JOBOBJECT_CPU_RATE_CONTROL_INFORMATION_u_s { + MinRate: WORD, + MaxRate: WORD, +}} +UNION!{union JOBOBJECT_CPU_RATE_CONTROL_INFORMATION_u { + [u32; 1], + CpuRate CpuRate_mut: DWORD, + Weight Weight_mut: DWORD, + s s_mut: JOBOBJECT_CPU_RATE_CONTROL_INFORMATION_u_s, +}} +STRUCT!{struct JOBOBJECT_CPU_RATE_CONTROL_INFORMATION { + ControlFlags: DWORD, + u: JOBOBJECT_CPU_RATE_CONTROL_INFORMATION_u, +}} +pub type PJOBOBJECT_CPU_RATE_CONTROL_INFORMATION = *mut JOBOBJECT_CPU_RATE_CONTROL_INFORMATION; +ENUM!{enum JOB_OBJECT_NET_RATE_CONTROL_FLAGS { + JOB_OBJECT_NET_RATE_CONTROL_ENABLE = 0x1, + JOB_OBJECT_NET_RATE_CONTROL_MAX_BANDWIDTH = 0x2, + JOB_OBJECT_NET_RATE_CONTROL_DSCP_TAG = 0x4, + JOB_OBJECT_NET_RATE_CONTROL_VALID_FLAGS = 0x7, +}} +pub const JOB_OBJECT_NET_RATE_CONTROL_MAX_DSCP_TAG: DWORD = 64; +STRUCT!{struct JOBOBJECT_NET_RATE_CONTROL_INFORMATION { + MaxBandwidth: DWORD64, + ControlFlags: JOB_OBJECT_NET_RATE_CONTROL_FLAGS, + DscpTag: BYTE, +}} +ENUM!{enum JOB_OBJECT_IO_RATE_CONTROL_FLAGS { + JOB_OBJECT_IO_RATE_CONTROL_ENABLE = 0x1, + JOB_OBJECT_IO_RATE_CONTROL_STANDALONE_VOLUME = 0x2, + JOB_OBJECT_IO_RATE_CONTROL_VALID_FLAGS = JOB_OBJECT_IO_RATE_CONTROL_ENABLE + | JOB_OBJECT_IO_RATE_CONTROL_STANDALONE_VOLUME, +}} +STRUCT!{struct JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE { + MaxIops: LONG64, + MaxBandwidth: LONG64, + ReservationIops: LONG64, + VolumeName: PWSTR, + BaseIoSize: DWORD, + ControlFlags: JOB_OBJECT_IO_RATE_CONTROL_FLAGS, + VolumeNameLength: WORD, +}} +pub type JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE_V1 + = JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE; +STRUCT!{struct JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE_V2 { + MaxIops: LONG64, + MaxBandwidth: LONG64, + ReservationIops: LONG64, + VolumeName: PWSTR, + BaseIoSize: DWORD, + ControlFlags: JOB_OBJECT_IO_RATE_CONTROL_FLAGS, + VolumeNameLength: WORD, + CriticalReservationIops: LONG64, + ReservationBandwidth: LONG64, + CriticalReservationBandwidth: LONG64, + MaxTimePercent: LONG64, + ReservationTimePercent: LONG64, + CriticalReservationTimePercent: LONG64, +}} +STRUCT!{struct JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE_V3 { + MaxIops: LONG64, + MaxBandwidth: LONG64, + ReservationIops: LONG64, + VolumeName: PWSTR, + BaseIoSize: DWORD, + ControlFlags: JOB_OBJECT_IO_RATE_CONTROL_FLAGS, + VolumeNameLength: WORD, + CriticalReservationIops: LONG64, + ReservationBandwidth: LONG64, + CriticalReservationBandwidth: LONG64, + MaxTimePercent: LONG64, + ReservationTimePercent: LONG64, + CriticalReservationTimePercent: LONG64, + SoftMaxIops: LONG64, + SoftMaxBandwidth: LONG64, + SoftMaxTimePercent: LONG64, + LimitExcessNotifyIops: LONG64, + LimitExcessNotifyBandwidth: LONG64, + LimitExcessNotifyTimePercent: LONG64, +}} +ENUM!{enum JOBOBJECT_IO_ATTRIBUTION_CONTROL_FLAGS { + JOBOBJECT_IO_ATTRIBUTION_CONTROL_ENABLE = 0x1, + JOBOBJECT_IO_ATTRIBUTION_CONTROL_DISABLE = 0x2, + JOBOBJECT_IO_ATTRIBUTION_CONTROL_VALID_FLAGS = 0x3, +}} +STRUCT!{struct JOBOBJECT_IO_ATTRIBUTION_STATS { + IoCount: ULONG_PTR, + TotalNonOverlappedQueueTime: ULONGLONG, + TotalNonOverlappedServiceTime: ULONGLONG, + TotalSize: ULONGLONG, +}} +pub type PJOBOBJECT_IO_ATTRIBUTION_STATS = *mut JOBOBJECT_IO_ATTRIBUTION_STATS; +STRUCT!{struct JOBOBJECT_IO_ATTRIBUTION_INFORMATION { + ControlFlags: DWORD, + ReadStats: JOBOBJECT_IO_ATTRIBUTION_STATS, + WriteStats: JOBOBJECT_IO_ATTRIBUTION_STATS, +}} +pub type PJOBOBJECT_IO_ATTRIBUTION_INFORMATION = *mut JOBOBJECT_IO_ATTRIBUTION_INFORMATION; +pub const JOB_OBJECT_TERMINATE_AT_END_OF_JOB: DWORD = 0; +pub const JOB_OBJECT_POST_AT_END_OF_JOB: DWORD = 1; +pub const JOB_OBJECT_MSG_END_OF_JOB_TIME: DWORD = 1; +pub const JOB_OBJECT_MSG_END_OF_PROCESS_TIME: DWORD = 2; +pub const JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT: DWORD = 3; +pub const JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO: DWORD = 4; +pub const JOB_OBJECT_MSG_NEW_PROCESS: DWORD = 6; +pub const JOB_OBJECT_MSG_EXIT_PROCESS: DWORD = 7; +pub const JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: DWORD = 8; +pub const JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT: DWORD = 9; +pub const JOB_OBJECT_MSG_JOB_MEMORY_LIMIT: DWORD = 10; +pub const JOB_OBJECT_MSG_NOTIFICATION_LIMIT: DWORD = 11; +pub const JOB_OBJECT_MSG_JOB_CYCLE_TIME_LIMIT: DWORD = 12; +pub const JOB_OBJECT_MSG_SILO_TERMINATED: DWORD = 13; +pub const JOB_OBJECT_MSG_MINIMUM: DWORD = 1; +pub const JOB_OBJECT_MSG_MAXIMUM: DWORD = 13; +pub const JOB_OBJECT_VALID_COMPLETION_FILTER: DWORD = ((1 << (JOB_OBJECT_MSG_MAXIMUM + 1)) - 1) + - ((1 << JOB_OBJECT_MSG_MINIMUM) - 1); +pub const JOB_OBJECT_LIMIT_WORKINGSET: DWORD = 0x00000001; +pub const JOB_OBJECT_LIMIT_PROCESS_TIME: DWORD = 0x00000002; +pub const JOB_OBJECT_LIMIT_JOB_TIME: DWORD = 0x00000004; +pub const JOB_OBJECT_LIMIT_ACTIVE_PROCESS: DWORD = 0x00000008; +pub const JOB_OBJECT_LIMIT_AFFINITY: DWORD = 0x00000010; +pub const JOB_OBJECT_LIMIT_PRIORITY_CLASS: DWORD = 0x00000020; +pub const JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME: DWORD = 0x00000040; +pub const JOB_OBJECT_LIMIT_SCHEDULING_CLASS: DWORD = 0x00000080; +pub const JOB_OBJECT_LIMIT_PROCESS_MEMORY: DWORD = 0x00000100; +pub const JOB_OBJECT_LIMIT_JOB_MEMORY: DWORD = 0x00000200; +pub const JOB_OBJECT_LIMIT_JOB_MEMORY_HIGH: DWORD = JOB_OBJECT_LIMIT_JOB_MEMORY; +pub const JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION: DWORD = 0x00000400; +pub const JOB_OBJECT_LIMIT_BREAKAWAY_OK: DWORD = 0x00000800; +pub const JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK: DWORD = 0x00001000; +pub const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: DWORD = 0x00002000; +pub const JOB_OBJECT_LIMIT_SUBSET_AFFINITY: DWORD = 0x00004000; +pub const JOB_OBJECT_LIMIT_JOB_MEMORY_LOW: DWORD = 0x00008000; +pub const JOB_OBJECT_LIMIT_JOB_READ_BYTES: DWORD = 0x00010000; +pub const JOB_OBJECT_LIMIT_JOB_WRITE_BYTES: DWORD = 0x00020000; +pub const JOB_OBJECT_LIMIT_RATE_CONTROL: DWORD = 0x00040000; +pub const JOB_OBJECT_LIMIT_CPU_RATE_CONTROL: DWORD = JOB_OBJECT_LIMIT_RATE_CONTROL; +pub const JOB_OBJECT_LIMIT_IO_RATE_CONTROL: DWORD = 0x00008000; +pub const JOB_OBJECT_LIMIT_NET_RATE_CONTROL: DWORD = 0x00010000; +pub const JOB_OBJECT_LIMIT_VALID_FLAGS: DWORD = 0x0007ffff; +pub const JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS: DWORD = 0x000000ff; +pub const JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS: DWORD = 0x00007fff; +pub const JOB_OBJECT_NOTIFICATION_LIMIT_VALID_FLAGS: DWORD = JOB_OBJECT_LIMIT_JOB_READ_BYTES + | JOB_OBJECT_LIMIT_JOB_WRITE_BYTES | JOB_OBJECT_LIMIT_JOB_TIME + | JOB_OBJECT_LIMIT_JOB_MEMORY_LOW | JOB_OBJECT_LIMIT_JOB_MEMORY_HIGH + | JOB_OBJECT_LIMIT_CPU_RATE_CONTROL | JOB_OBJECT_LIMIT_IO_RATE_CONTROL + | JOB_OBJECT_LIMIT_NET_RATE_CONTROL; +pub const JOB_OBJECT_UILIMIT_NONE: DWORD = 0x00000000; +pub const JOB_OBJECT_UILIMIT_HANDLES: DWORD = 0x00000001; +pub const JOB_OBJECT_UILIMIT_READCLIPBOARD: DWORD = 0x00000002; +pub const JOB_OBJECT_UILIMIT_WRITECLIPBOARD: DWORD = 0x00000004; +pub const JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS: DWORD = 0x00000008; +pub const JOB_OBJECT_UILIMIT_DISPLAYSETTINGS: DWORD = 0x00000010; +pub const JOB_OBJECT_UILIMIT_GLOBALATOMS: DWORD = 0x00000020; +pub const JOB_OBJECT_UILIMIT_DESKTOP: DWORD = 0x00000040; +pub const JOB_OBJECT_UILIMIT_EXITWINDOWS: DWORD = 0x00000080; +pub const JOB_OBJECT_UILIMIT_ALL: DWORD = 0x000000FF; +pub const JOB_OBJECT_UI_VALID_FLAGS: DWORD = 0x000000FF; +pub const JOB_OBJECT_SECURITY_NO_ADMIN: DWORD = 0x00000001; +pub const JOB_OBJECT_SECURITY_RESTRICTED_TOKEN: DWORD = 0x00000002; +pub const JOB_OBJECT_SECURITY_ONLY_TOKEN: DWORD = 0x00000004; +pub const JOB_OBJECT_SECURITY_FILTER_TOKENS: DWORD = 0x00000008; +pub const JOB_OBJECT_SECURITY_VALID_FLAGS: DWORD = 0x0000000f; +pub const JOB_OBJECT_CPU_RATE_CONTROL_ENABLE: DWORD = 0x1; +pub const JOB_OBJECT_CPU_RATE_CONTROL_WEIGHT_BASED: DWORD = 0x2; +pub const JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP: DWORD = 0x4; +pub const JOB_OBJECT_CPU_RATE_CONTROL_NOTIFY: DWORD = 0x8; +pub const JOB_OBJECT_CPU_RATE_CONTROL_MIN_MAX_RATE: DWORD = 0x10; +pub const JOB_OBJECT_CPU_RATE_CONTROL_VALID_FLAGS: DWORD = 0x1f; +ENUM!{enum JOBOBJECTINFOCLASS { + JobObjectBasicAccountingInformation = 1, + JobObjectBasicLimitInformation, + JobObjectBasicProcessIdList, + JobObjectBasicUIRestrictions, + JobObjectSecurityLimitInformation, + JobObjectEndOfJobTimeInformation, + JobObjectAssociateCompletionPortInformation, + JobObjectBasicAndIoAccountingInformation, + JobObjectExtendedLimitInformation, + JobObjectJobSetInformation, + JobObjectGroupInformation, + JobObjectNotificationLimitInformation, + JobObjectLimitViolationInformation, + JobObjectGroupInformationEx, + JobObjectCpuRateControlInformation, + JobObjectCompletionFilter, + JobObjectCompletionCounter, + JobObjectReserved1Information = 18, + JobObjectReserved2Information, + JobObjectReserved3Information, + JobObjectReserved4Information, + JobObjectReserved5Information, + JobObjectReserved6Information, + JobObjectReserved7Information, + JobObjectReserved8Information, + JobObjectReserved9Information, + JobObjectReserved10Information, + JobObjectReserved11Information, + JobObjectReserved12Information, + JobObjectReserved13Information, + JobObjectReserved14Information = 31, + JobObjectNetRateControlInformation, + JobObjectNotificationLimitInformation2, + JobObjectLimitViolationInformation2, + JobObjectCreateSilo, + JobObjectSiloBasicInformation, + JobObjectReserved15Information = 37, + JobObjectReserved16Information = 38, + JobObjectReserved17Information = 39, + JobObjectReserved18Information = 40, + JobObjectReserved19Information = 41, + JobObjectReserved20Information = 42, + JobObjectReserved21Information = 43, + JobObjectReserved22Information = 44, + JobObjectReserved23Information = 45, + JobObjectReserved24Information = 46, + JobObjectReserved25Information = 47, + MaxJobObjectInfoClass, +}} +STRUCT!{struct SILOOBJECT_BASIC_INFORMATION { + SiloId: DWORD, + SiloParentId: DWORD, + NumberOfProcesses: DWORD, + IsInServerSilo: BOOLEAN, + Reserved: [BYTE; 3], +}} +pub type PSILOOBJECT_BASIC_INFORMATION = *mut SILOOBJECT_BASIC_INFORMATION; +ENUM!{enum SERVERSILO_STATE { + SERVERSILO_INITING = 0, + SERVERSILO_STARTED, + SERVERSILO_SHUTTING_DOWN, + SERVERSILO_TERMINATING, + SERVERSILO_TERMINATED, +}} +pub type PSERVERSILO_STATE = *mut SERVERSILO_STATE; +STRUCT!{struct SERVERSILO_BASIC_INFORMATION { + ServiceSessionId: DWORD, + State: SERVERSILO_STATE, + ExitStatus: DWORD, +}} +pub type PSERVERSILO_BASIC_INFORMATION = *mut SERVERSILO_BASIC_INFORMATION; +ENUM!{enum FIRMWARE_TYPE { + FirmwareTypeUnknown, + FirmwareTypeBios, + FirmwareTypeUefi, + FirmwareTypeMax, +}} +pub type PFIRMWARE_TYPE = *mut FIRMWARE_TYPE; +pub const EVENT_MODIFY_STATE: DWORD = 0x0002; +pub const EVENT_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3; +pub const MUTANT_QUERY_STATE: DWORD = 0x0001; +pub const MUTANT_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE; +pub const SEMAPHORE_MODIFY_STATE: DWORD = 0x0002; +pub const SEMAPHORE_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3; +pub const TIMER_QUERY_STATE: DWORD = 0x0001; +pub const TIMER_MODIFY_STATE: DWORD = 0x0002; +pub const TIMER_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE + | TIMER_MODIFY_STATE; +pub const TIME_ZONE_ID_UNKNOWN: DWORD = 0; +pub const TIME_ZONE_ID_STANDARD: DWORD = 1; +pub const TIME_ZONE_ID_DAYLIGHT: DWORD = 2; +ENUM!{enum LOGICAL_PROCESSOR_RELATIONSHIP { + RelationProcessorCore, + RelationNumaNode, + RelationCache, + RelationProcessorPackage, + RelationGroup, + RelationAll = 0xffff, +}} +pub const LTP_PC_SMT: BYTE = 0x1; +ENUM!{enum PROCESSOR_CACHE_TYPE { + CacheUnified, + CacheInstruction, + CacheData, + CacheTrace, +}} +pub const CACHE_FULLY_ASSOCIATIVE: BYTE = 0xFF; +STRUCT!{struct CACHE_DESCRIPTOR { + Level: BYTE, + Associativity: BYTE, + LineSize: WORD, + Size: DWORD, + Type: PROCESSOR_CACHE_TYPE, +}} +pub type PCACHE_DESCRIPTOR = *mut CACHE_DESCRIPTOR; +STRUCT!{struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_ProcessorCore { + Flags: BYTE, +}} +STRUCT!{struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_NumaNode { + NodeNumber: DWORD, +}} +UNION!{union SYSTEM_LOGICAL_PROCESSOR_INFORMATION_u { + [u64; 2], + ProcessorCore ProcessorCore_mut: SYSTEM_LOGICAL_PROCESSOR_INFORMATION_ProcessorCore, + NumaNode NumaNode_mut: SYSTEM_LOGICAL_PROCESSOR_INFORMATION_NumaNode, + Cache Cache_mut: CACHE_DESCRIPTOR, + Reserved Reserved_mut: [ULONGLONG; 2], +}} +STRUCT!{struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION { + ProcessorMask: ULONG_PTR, + Relationship: LOGICAL_PROCESSOR_RELATIONSHIP, + u: SYSTEM_LOGICAL_PROCESSOR_INFORMATION_u, +}} +pub type PSYSTEM_LOGICAL_PROCESSOR_INFORMATION = *mut SYSTEM_LOGICAL_PROCESSOR_INFORMATION; +STRUCT!{struct PROCESSOR_RELATIONSHIP { + Flags: BYTE, + EfficiencyClass: BYTE, + Reserved: [BYTE; 20], + GroupCount: WORD, + GroupMask: [GROUP_AFFINITY; ANYSIZE_ARRAY], +}} +pub type PPROCESSOR_RELATIONSHIP = *mut PROCESSOR_RELATIONSHIP; +STRUCT!{struct NUMA_NODE_RELATIONSHIP { + NodeNumber: DWORD, + Reserved: [BYTE; 20], + GroupMask: GROUP_AFFINITY, +}} +pub type PNUMA_NODE_RELATIONSHIP = *mut NUMA_NODE_RELATIONSHIP; +STRUCT!{struct CACHE_RELATIONSHIP { + Level: BYTE, + Associativity: BYTE, + LineSize: WORD, + CacheSize: DWORD, + Type: PROCESSOR_CACHE_TYPE, + Reserved: [BYTE; 20], + GroupMask: GROUP_AFFINITY, +}} +pub type PCACHE_RELATIONSHIP = *mut CACHE_RELATIONSHIP; +STRUCT!{struct PROCESSOR_GROUP_INFO { + MaximumProcessorCount: BYTE, + ActiveProcessorCount: BYTE, + Reserved: [BYTE; 38], + ActiveProcessorMask: KAFFINITY, +}} +pub type PPROCESSOR_GROUP_INFO = *mut PROCESSOR_GROUP_INFO; +STRUCT!{struct GROUP_RELATIONSHIP { + MaximumGroupCount: WORD, + ActiveGroupCount: WORD, + Reserved: [BYTE; 20], + GroupInfo: [PROCESSOR_GROUP_INFO; ANYSIZE_ARRAY], +}} +pub type PGROUP_RELATIONSHIP = *mut GROUP_RELATIONSHIP; +UNION!{union SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX_u { + [u32; 17] [u64; 9], + Processor Processor_mut: PROCESSOR_RELATIONSHIP, + NumaNode NumaNode_mut: NUMA_NODE_RELATIONSHIP, + Cache Cache_mut: CACHE_RELATIONSHIP, + Group Group_mut: GROUP_RELATIONSHIP, +}} +STRUCT!{struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { + Relationship: LOGICAL_PROCESSOR_RELATIONSHIP, + Size: DWORD, + u: SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX_u, +}} +pub type PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX = *mut SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX; +ENUM!{enum CPU_SET_INFORMATION_TYPE { + CpuSetInformation, +}} +pub type PCPU_SET_INFORMATION_TYPE = *mut CPU_SET_INFORMATION_TYPE; +pub const SYSTEM_CPU_SET_INFORMATION_PARKED: BYTE = 0x1; +pub const SYSTEM_CPU_SET_INFORMATION_ALLOCATED: BYTE = 0x2; +pub const SYSTEM_CPU_SET_INFORMATION_ALLOCATED_TO_TARGET_PROCESS: BYTE = 0x4; +pub const SYSTEM_CPU_SET_INFORMATION_REALTIME: BYTE = 0x8; +STRUCT!{struct SYSTEM_CPU_SET_INFORMATION_CpuSet { + Id: DWORD, + Group: WORD, + LogicalProcessorIndex: BYTE, + CoreIndex: BYTE, + LastLevelCacheIndex: BYTE, + NumaNodeIndex: BYTE, + EfficiencyClass: BYTE, + AllFlags: BYTE, + Reserved: DWORD, + AllocationTag: DWORD64, +}} +BITFIELD!{SYSTEM_CPU_SET_INFORMATION_CpuSet AllFlags: BYTE [ + Parked set_Parked[0..1], + Allocated set_Allocated[1..2], + AllocatedToTargetProcess set_AllocatedToTargetProcess[2..3], + RealTime set_RealTime[3..4], + ReservedFlags set_ReservedFlags[4..8], +]} +STRUCT!{struct SYSTEM_CPU_SET_INFORMATION { + Size: DWORD, + Type: CPU_SET_INFORMATION_TYPE, + CpuSet: SYSTEM_CPU_SET_INFORMATION_CpuSet, +}} +pub type PSYSTEM_CPU_SET_INFORMATION = *mut SYSTEM_CPU_SET_INFORMATION; +STRUCT!{struct SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION { + CycleTime: DWORD64, +}} +pub type PSYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION = *mut SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION; +pub const PROCESSOR_INTEL_386: DWORD = 386; +pub const PROCESSOR_INTEL_486: DWORD = 486; +pub const PROCESSOR_INTEL_PENTIUM: DWORD = 586; +pub const PROCESSOR_INTEL_IA64: DWORD = 2200; +pub const PROCESSOR_AMD_X8664: DWORD = 8664; +pub const PROCESSOR_MIPS_R4000: DWORD = 4000; +pub const PROCESSOR_ALPHA_21064: DWORD = 21064; +pub const PROCESSOR_PPC_601: DWORD = 601; +pub const PROCESSOR_PPC_603: DWORD = 603; +pub const PROCESSOR_PPC_604: DWORD = 604; +pub const PROCESSOR_PPC_620: DWORD = 620; +pub const PROCESSOR_HITACHI_SH3: DWORD = 10003; +pub const PROCESSOR_HITACHI_SH3E: DWORD = 10004; +pub const PROCESSOR_HITACHI_SH4: DWORD = 10005; +pub const PROCESSOR_MOTOROLA_821: DWORD = 821; +pub const PROCESSOR_SHx_SH3: DWORD = 103; +pub const PROCESSOR_SHx_SH4: DWORD = 104; +pub const PROCESSOR_STRONGARM: DWORD = 2577; +pub const PROCESSOR_ARM720: DWORD = 1824; +pub const PROCESSOR_ARM820: DWORD = 2080; +pub const PROCESSOR_ARM920: DWORD = 2336; +pub const PROCESSOR_ARM_7TDMI: DWORD = 70001; +pub const PROCESSOR_OPTIL: DWORD = 0x494f; +pub const PROCESSOR_ARCHITECTURE_INTEL: WORD = 0; +pub const PROCESSOR_ARCHITECTURE_MIPS: WORD = 1; +pub const PROCESSOR_ARCHITECTURE_ALPHA: WORD = 2; +pub const PROCESSOR_ARCHITECTURE_PPC: WORD = 3; +pub const PROCESSOR_ARCHITECTURE_SHX: WORD = 4; +pub const PROCESSOR_ARCHITECTURE_ARM: WORD = 5; +pub const PROCESSOR_ARCHITECTURE_IA64: WORD = 6; +pub const PROCESSOR_ARCHITECTURE_ALPHA64: WORD = 7; +pub const PROCESSOR_ARCHITECTURE_MSIL: WORD = 8; +pub const PROCESSOR_ARCHITECTURE_AMD64: WORD = 9; +pub const PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: WORD = 10; +pub const PROCESSOR_ARCHITECTURE_NEUTRAL: WORD = 11; +pub const PROCESSOR_ARCHITECTURE_ARM64: WORD = 12; +pub const PROCESSOR_ARCHITECTURE_ARM32_ON_WIN64: WORD = 13; +pub const PROCESSOR_ARCHITECTURE_IA32_ON_ARM64: WORD = 14; +pub const PROCESSOR_ARCHITECTURE_UNKNOWN: WORD = 0xFFFF; +pub const PF_FLOATING_POINT_PRECISION_ERRATA: DWORD = 0; +pub const PF_FLOATING_POINT_EMULATED: DWORD = 1; +pub const PF_COMPARE_EXCHANGE_DOUBLE: DWORD = 2; +pub const PF_MMX_INSTRUCTIONS_AVAILABLE: DWORD = 3; +pub const PF_PPC_MOVEMEM_64BIT_OK: DWORD = 4; +pub const PF_ALPHA_BYTE_INSTRUCTIONS: DWORD = 5; +pub const PF_XMMI_INSTRUCTIONS_AVAILABLE: DWORD = 6; +pub const PF_3DNOW_INSTRUCTIONS_AVAILABLE: DWORD = 7; +pub const PF_RDTSC_INSTRUCTION_AVAILABLE: DWORD = 8; +pub const PF_PAE_ENABLED: DWORD = 9; +pub const PF_XMMI64_INSTRUCTIONS_AVAILABLE: DWORD = 10; +pub const PF_SSE_DAZ_MODE_AVAILABLE: DWORD = 11; +pub const PF_NX_ENABLED: DWORD = 12; +pub const PF_SSE3_INSTRUCTIONS_AVAILABLE: DWORD = 13; +pub const PF_COMPARE_EXCHANGE128: DWORD = 14; +pub const PF_COMPARE64_EXCHANGE128: DWORD = 15; +pub const PF_CHANNELS_ENABLED: DWORD = 16; +pub const PF_XSAVE_ENABLED: DWORD = 17; +pub const PF_ARM_VFP_32_REGISTERS_AVAILABLE: DWORD = 18; +pub const PF_ARM_NEON_INSTRUCTIONS_AVAILABLE: DWORD = 19; +pub const PF_SECOND_LEVEL_ADDRESS_TRANSLATION: DWORD = 20; +pub const PF_VIRT_FIRMWARE_ENABLED: DWORD = 21; +pub const PF_RDWRFSGSBASE_AVAILABLE: DWORD = 22; +pub const PF_FASTFAIL_AVAILABLE: DWORD = 23; +pub const PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE: DWORD = 24; +pub const PF_ARM_64BIT_LOADSTORE_ATOMIC: DWORD = 25; +pub const PF_ARM_EXTERNAL_CACHE_AVAILABLE: DWORD = 26; +pub const PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE: DWORD = 27; +pub const PF_RDRAND_INSTRUCTION_AVAILABLE: DWORD = 28; +pub const PF_ARM_V8_INSTRUCTIONS_AVAILABLE: DWORD = 29; +pub const PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE: DWORD = 30; +pub const PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE: DWORD = 31; +pub const PF_RDTSCP_INSTRUCTION_AVAILABLE: DWORD = 32; +pub const XSTATE_LEGACY_FLOATING_POINT: ULONG64 = 0; +pub const XSTATE_LEGACY_SSE: ULONG64 = 1; +pub const XSTATE_GSSE: ULONG64 = 2; +pub const XSTATE_AVX: ULONG64 = XSTATE_GSSE; +pub const XSTATE_MPX_BNDREGS: ULONG64 = 3; +pub const XSTATE_MPX_BNDCSR: ULONG64 = 4; +pub const XSTATE_AVX512_KMASK: ULONG64 = 5; +pub const XSTATE_AVX512_ZMM_H: ULONG64 = 6; +pub const XSTATE_AVX512_ZMM: ULONG64 = 7; +pub const XSTATE_IPT: ULONG64 = 8; +pub const XSTATE_LWP: ULONG64 = 62; +pub const MAXIMUM_XSTATE_FEATURES: usize = 64; +pub const XSTATE_MASK_LEGACY_FLOATING_POINT: ULONG64 = 1 << XSTATE_LEGACY_FLOATING_POINT; +pub const XSTATE_MASK_LEGACY_SSE: ULONG64 = 1 << XSTATE_LEGACY_SSE; +pub const XSTATE_MASK_LEGACY: ULONG64 = XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE; +pub const XSTATE_MASK_GSSE: ULONG64 = 1 << XSTATE_GSSE; +pub const XSTATE_MASK_AVX: ULONG64 = XSTATE_MASK_GSSE; +pub const XSTATE_MASK_MPX: ULONG64 = (1 << XSTATE_MPX_BNDREGS) | (1 << XSTATE_MPX_BNDCSR); +pub const XSTATE_MASK_AVX512: ULONG64 = (1 << XSTATE_AVX512_KMASK) | (1 << XSTATE_AVX512_ZMM_H) + | (1 << XSTATE_AVX512_ZMM); +pub const XSTATE_MASK_IPT: ULONG64 = 1 << XSTATE_IPT; +pub const XSTATE_MASK_LWP: ULONG64 = 1 << XSTATE_LWP; +pub const XSTATE_MASK_ALLOWED: ULONG64 = XSTATE_MASK_LEGACY | XSTATE_MASK_AVX | XSTATE_MASK_MPX + | XSTATE_MASK_AVX512 | XSTATE_MASK_IPT | XSTATE_MASK_LWP; +pub const XSTATE_MASK_PERSISTENT: ULONG64 = (1 << XSTATE_MPX_BNDCSR) | XSTATE_MASK_LWP; +pub const XSTATE_COMPACTION_ENABLE: ULONG64 = 63; +pub const XSTATE_COMPACTION_ENABLE_MASK: ULONG64 = 1 << XSTATE_COMPACTION_ENABLE; +pub const XSTATE_ALIGN_BIT: ULONG64 = 1; +pub const XSTATE_ALIGN_MASK: ULONG64 = 1 << XSTATE_ALIGN_BIT; +pub const XSTATE_CONTROLFLAG_XSAVEOPT_MASK: ULONG64 = 1; +pub const XSTATE_CONTROLFLAG_XSAVEC_MASK: ULONG64 = 2; +pub const XSTATE_CONTROLFLAG_VALID_MASK: ULONG64 = XSTATE_CONTROLFLAG_XSAVEOPT_MASK + | XSTATE_CONTROLFLAG_XSAVEC_MASK; +STRUCT!{struct XSTATE_FEATURE { + Offset: DWORD, + Size: DWORD, +}} +pub type PXSTATE_FEATURE = *mut XSTATE_FEATURE; +STRUCT!{struct XSTATE_CONFIGURATION { + EnabledFeatures: DWORD64, + EnabledVolatileFeatures: DWORD64, + Size: DWORD, + ControlFlags: DWORD, + Features: [XSTATE_FEATURE; MAXIMUM_XSTATE_FEATURES], + EnabledSupervisorFeatures: DWORD64, + AlignedFeatures: DWORD64, + AllFeatureSize: DWORD, + AllFeatures: [DWORD; MAXIMUM_XSTATE_FEATURES], +}} +BITFIELD!{XSTATE_CONFIGURATION ControlFlags: DWORD [ + OptimizedSave set_OptimizedSave[0..1], + CompactionEnabled set_CompactionEnabled[1..2], +]} +pub type PXSTATE_CONFIGURATION = *mut XSTATE_CONFIGURATION; +STRUCT!{struct MEMORY_BASIC_INFORMATION { + BaseAddress: PVOID, + AllocationBase: PVOID, + AllocationProtect: DWORD, + RegionSize: SIZE_T, + State: DWORD, + Protect: DWORD, + Type: DWORD, +}} +pub type PMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; +STRUCT!{struct MEMORY_BASIC_INFORMATION32 { + BaseAddress: DWORD, + AllocationBase: DWORD, + AllocationProtect: DWORD, + RegionSize: DWORD, + State: DWORD, + Protect: DWORD, + Type: DWORD, +}} +pub type PMEMORY_BASIC_INFORMATION32 = *mut MEMORY_BASIC_INFORMATION32; +STRUCT!{struct MEMORY_BASIC_INFORMATION64 { // FIXME: align 16 + BaseAddress: ULONGLONG, + AllocationBase: ULONGLONG, + AllocationProtect: DWORD, + __alignment1: DWORD, + RegionSize: ULONGLONG, + State: DWORD, + Protect: DWORD, + Type: DWORD, + __alignment2: DWORD, +}} +pub type PMEMORY_BASIC_INFORMATION64 = *mut MEMORY_BASIC_INFORMATION64; +pub const CFG_CALL_TARGET_VALID: ULONG_PTR = 0x00000001; +pub const CFG_CALL_TARGET_PROCESSED: ULONG_PTR = 0x00000002; +pub const CFG_CALL_TARGET_CONVERT_EXPORT_SUPPRESSED_TO_VALID: ULONG_PTR = 0x00000004; +STRUCT!{struct CFG_CALL_TARGET_INFO { + Offset: ULONG_PTR, + Flags: ULONG_PTR, +}} +pub type PCFG_CALL_TARGET_INFO = *mut CFG_CALL_TARGET_INFO; +pub const SECTION_QUERY: DWORD = 0x0001; +pub const SECTION_MAP_WRITE: DWORD = 0x0002; +pub const SECTION_MAP_READ: DWORD = 0x0004; +pub const SECTION_MAP_EXECUTE: DWORD = 0x0008; +pub const SECTION_EXTEND_SIZE: DWORD = 0x0010; +pub const SECTION_MAP_EXECUTE_EXPLICIT: DWORD = 0x0020; +pub const SECTION_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY + | SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE; +pub const SESSION_QUERY_ACCESS: DWORD = 0x0001; +pub const SESSION_MODIFY_ACCESS: DWORD = 0x0002; +pub const SESSION_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SESSION_QUERY_ACCESS + | SESSION_MODIFY_ACCESS; +pub const MEMORY_PARTITION_QUERY_ACCESS: DWORD = 0x0001; +pub const MEMORY_PARTITION_MODIFY_ACCESS: DWORD = 0x0002; +pub const MEMORY_PARTITION_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE + | MEMORY_PARTITION_QUERY_ACCESS | MEMORY_PARTITION_MODIFY_ACCESS; +pub const PAGE_NOACCESS: DWORD = 0x01; +pub const PAGE_READONLY: DWORD = 0x02; +pub const PAGE_READWRITE: DWORD = 0x04; +pub const PAGE_WRITECOPY: DWORD = 0x08; +pub const PAGE_EXECUTE: DWORD = 0x10; +pub const PAGE_EXECUTE_READ: DWORD = 0x20; +pub const PAGE_EXECUTE_READWRITE: DWORD = 0x40; +pub const PAGE_EXECUTE_WRITECOPY: DWORD = 0x80; +pub const PAGE_GUARD: DWORD = 0x100; +pub const PAGE_NOCACHE: DWORD = 0x200; +pub const PAGE_WRITECOMBINE: DWORD = 0x400; +pub const PAGE_ENCLAVE_THREAD_CONTROL: DWORD = 0x80000000; +pub const PAGE_REVERT_TO_FILE_MAP: DWORD = 0x80000000; +pub const PAGE_TARGETS_NO_UPDATE: DWORD = 0x40000000; +pub const PAGE_TARGETS_INVALID: DWORD = 0x40000000; +pub const PAGE_ENCLAVE_UNVALIDATED: DWORD = 0x20000000; +pub const PAGE_ENCLAVE_DECOMMIT: DWORD = 0x10000000; +pub const MEM_COMMIT: DWORD = 0x1000; +pub const MEM_RESERVE: DWORD = 0x2000; +pub const MEM_DECOMMIT: DWORD = 0x4000; +pub const MEM_RELEASE: DWORD = 0x8000; +pub const MEM_FREE: DWORD = 0x10000; +pub const MEM_PRIVATE: DWORD = 0x20000; +pub const MEM_MAPPED: DWORD = 0x40000; +pub const MEM_RESET: DWORD = 0x80000; +pub const MEM_TOP_DOWN: DWORD = 0x100000; +pub const MEM_WRITE_WATCH: DWORD = 0x200000; +pub const MEM_PHYSICAL: DWORD = 0x400000; +pub const MEM_ROTATE: DWORD = 0x800000; +pub const MEM_DIFFERENT_IMAGE_BASE_OK: DWORD = 0x800000; +pub const MEM_RESET_UNDO: DWORD = 0x1000000; +pub const MEM_LARGE_PAGES: DWORD = 0x20000000; +pub const MEM_4MB_PAGES: DWORD = 0x80000000; +pub const MEM_64K_PAGES: DWORD = MEM_LARGE_PAGES | MEM_PHYSICAL; +pub const SEC_64K_PAGES: DWORD = 0x00080000; +pub const SEC_FILE: DWORD = 0x800000; +pub const SEC_IMAGE: DWORD = 0x1000000; +pub const SEC_PROTECTED_IMAGE: DWORD = 0x2000000; +pub const SEC_RESERVE: DWORD = 0x4000000; +pub const SEC_COMMIT: DWORD = 0x8000000; +pub const SEC_NOCACHE: DWORD = 0x10000000; +pub const SEC_WRITECOMBINE: DWORD = 0x40000000; +pub const SEC_LARGE_PAGES: DWORD = 0x80000000; +pub const SEC_IMAGE_NO_EXECUTE: DWORD = (SEC_IMAGE | SEC_NOCACHE); +pub const MEM_IMAGE: DWORD = SEC_IMAGE; +pub const WRITE_WATCH_FLAG_RESET: DWORD = 0x01; +pub const MEM_UNMAP_WITH_TRANSIENT_BOOST: DWORD = 0x01; +pub const ENCLAVE_TYPE_SGX: DWORD = 0x00000001; +pub const ENCLAVE_TYPE_SGX2: DWORD = 0x00000002; +STRUCT!{struct ENCLAVE_CREATE_INFO_SGX { + Secs: [BYTE; 4096], +}} +pub type PENCLAVE_CREATE_INFO_SGX = *mut ENCLAVE_CREATE_INFO_SGX; +STRUCT!{struct ENCLAVE_INIT_INFO_SGX { + SigStruct: [BYTE; 1808], + Reserved1: [BYTE; 240], + EInitToken: [BYTE; 304], + Reserved2: [BYTE; 1744], +}} +pub type PENCLAVE_INIT_INFO_SGX = *mut ENCLAVE_INIT_INFO_SGX; +pub const FILE_READ_DATA: DWORD = 0x0001; +pub const FILE_LIST_DIRECTORY: DWORD = 0x0001; +pub const FILE_WRITE_DATA: DWORD = 0x0002; +pub const FILE_ADD_FILE: DWORD = 0x0002; +pub const FILE_APPEND_DATA: DWORD = 0x0004; +pub const FILE_ADD_SUBDIRECTORY: DWORD = 0x0004; +pub const FILE_CREATE_PIPE_INSTANCE: DWORD = 0x0004; +pub const FILE_READ_EA: DWORD = 0x0008; +pub const FILE_WRITE_EA: DWORD = 0x0010; +pub const FILE_EXECUTE: DWORD = 0x0020; +pub const FILE_TRAVERSE: DWORD = 0x0020; +pub const FILE_DELETE_CHILD: DWORD = 0x0040; +pub const FILE_READ_ATTRIBUTES: DWORD = 0x0080; +pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x0100; +pub const FILE_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF; +pub const FILE_GENERIC_READ: DWORD = STANDARD_RIGHTS_READ | FILE_READ_DATA + | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; +pub const FILE_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA + | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE; +pub const FILE_GENERIC_EXECUTE: DWORD = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES + | FILE_EXECUTE | SYNCHRONIZE; +pub const FILE_SHARE_READ: DWORD = 0x00000001; +pub const FILE_SHARE_WRITE: DWORD = 0x00000002; +pub const FILE_SHARE_DELETE: DWORD = 0x00000004; +pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x00000001; +pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x00000002; +pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x00000004; +pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x00000010; +pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x00000020; +pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x00000040; +pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x00000080; +pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x00000100; +pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x00000200; +pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x00000400; +pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x00000800; +pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x00001000; +pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x00002000; +pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x00004000; +pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x00008000; +pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x00010000; +pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x00020000; +pub const FILE_ATTRIBUTE_EA: DWORD = 0x00040000; +pub const FILE_ATTRIBUTE_PINNED: DWORD = 0x00080000; +pub const FILE_ATTRIBUTE_UNPINNED: DWORD = 0x00100000; +pub const FILE_ATTRIBUTE_RECALL_ON_OPEN: DWORD = 0x00040000; +pub const FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS: DWORD = 0x00400000; +pub const FILE_NOTIFY_CHANGE_FILE_NAME: DWORD = 0x00000001; +pub const FILE_NOTIFY_CHANGE_DIR_NAME: DWORD = 0x00000002; +pub const FILE_NOTIFY_CHANGE_ATTRIBUTES: DWORD = 0x00000004; +pub const FILE_NOTIFY_CHANGE_SIZE: DWORD = 0x00000008; +pub const FILE_NOTIFY_CHANGE_LAST_WRITE: DWORD = 0x00000010; +pub const FILE_NOTIFY_CHANGE_LAST_ACCESS: DWORD = 0x00000020; +pub const FILE_NOTIFY_CHANGE_CREATION: DWORD = 0x00000040; +pub const FILE_NOTIFY_CHANGE_SECURITY: DWORD = 0x00000100; +pub const FILE_ACTION_ADDED: DWORD = 0x00000001; +pub const FILE_ACTION_REMOVED: DWORD = 0x00000002; +pub const FILE_ACTION_MODIFIED: DWORD = 0x00000003; +pub const FILE_ACTION_RENAMED_OLD_NAME: DWORD = 0x00000004; +pub const FILE_ACTION_RENAMED_NEW_NAME: DWORD = 0x00000005; +pub const MAILSLOT_NO_MESSAGE: DWORD = 0xFFFFFFFF; +pub const MAILSLOT_WAIT_FOREVER: DWORD = 0xFFFFFFFF; +pub const FILE_CASE_SENSITIVE_SEARCH: DWORD = 0x00000001; +pub const FILE_CASE_PRESERVED_NAMES: DWORD = 0x00000002; +pub const FILE_UNICODE_ON_DISK: DWORD = 0x00000004; +pub const FILE_PERSISTENT_ACLS: DWORD = 0x00000008; +pub const FILE_FILE_COMPRESSION: DWORD = 0x00000010; +pub const FILE_VOLUME_QUOTAS: DWORD = 0x00000020; +pub const FILE_SUPPORTS_SPARSE_FILES: DWORD = 0x00000040; +pub const FILE_SUPPORTS_REPARSE_POINTS: DWORD = 0x00000080; +pub const FILE_SUPPORTS_REMOTE_STORAGE: DWORD = 0x00000100; +pub const FILE_RETURNS_CLEANUP_RESULT_INFO: DWORD = 0x00000200; +pub const FILE_VOLUME_IS_COMPRESSED: DWORD = 0x00008000; +pub const FILE_SUPPORTS_OBJECT_IDS: DWORD = 0x00010000; +pub const FILE_SUPPORTS_ENCRYPTION: DWORD = 0x00020000; +pub const FILE_NAMED_STREAMS: DWORD = 0x00040000; +pub const FILE_READ_ONLY_VOLUME: DWORD = 0x00080000; +pub const FILE_SEQUENTIAL_WRITE_ONCE: DWORD = 0x00100000; +pub const FILE_SUPPORTS_TRANSACTIONS: DWORD = 0x00200000; +pub const FILE_SUPPORTS_HARD_LINKS: DWORD = 0x00400000; +pub const FILE_SUPPORTS_EXTENDED_ATTRIBUTES: DWORD = 0x00800000; +pub const FILE_SUPPORTS_OPEN_BY_FILE_ID: DWORD = 0x01000000; +pub const FILE_SUPPORTS_USN_JOURNAL: DWORD = 0x02000000; +pub const FILE_SUPPORTS_INTEGRITY_STREAMS: DWORD = 0x04000000; +pub const FILE_SUPPORTS_BLOCK_REFCOUNTING: DWORD = 0x08000000; +pub const FILE_SUPPORTS_SPARSE_VDL: DWORD = 0x10000000; +pub const FILE_DAX_VOLUME: DWORD = 0x20000000; +pub const FILE_SUPPORTS_GHOSTING: DWORD = 0x40000000; +pub const FILE_INVALID_FILE_ID: LONGLONG = -1; +STRUCT!{struct FILE_ID_128 { + Identifier: [BYTE; 16], +}} +pub type PFILE_ID_128 = *mut FILE_ID_128; +STRUCT!{struct FILE_NOTIFY_INFORMATION { + NextEntryOffset: DWORD, + Action: DWORD, + FileNameLength: DWORD, + FileName: [WCHAR; 1], +}} +UNION!{union FILE_SEGMENT_ELEMENT { + [u64; 1], + Buffer Buffer_mut: PVOID64, + Alignment Alignment_mut: ULONGLONG, +}} +pub type PFILE_SEGMENT_ELEMENT = *mut FILE_SEGMENT_ELEMENT; +pub const FLUSH_FLAGS_FILE_DATA_ONLY: ULONG = 0x00000001; +pub const FLUSH_FLAGS_NO_SYNC: ULONG = 0x00000002; +pub const FLUSH_FLAGS_FILE_DATA_SYNC_ONLY: ULONG = 0x00000004; +STRUCT!{struct REPARSE_GUID_DATA_BUFFER_GenericReparseBuffer { + DataBuffer: [BYTE; 1], +}} +STRUCT!{struct REPARSE_GUID_DATA_BUFFER { + ReparseTag: DWORD, + ReparseDataLength: WORD, + Reserved: WORD, + ReparseGuid: GUID, + GenericReparseBuffer: REPARSE_GUID_DATA_BUFFER_GenericReparseBuffer, +}} +pub type PREPARSE_GUID_DATA_BUFFER = *mut REPARSE_GUID_DATA_BUFFER; +pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE: DWORD = 16 * 1024; +pub const IO_REPARSE_TAG_RESERVED_ZERO: DWORD = 0; +pub const IO_REPARSE_TAG_RESERVED_ONE: DWORD = 1; +pub const IO_REPARSE_TAG_RESERVED_TWO: DWORD = 2; +pub const IO_REPARSE_TAG_RESERVED_RANGE: DWORD = IO_REPARSE_TAG_RESERVED_TWO; +#[inline] +pub fn IsReparseTagMicrosoft(_tag: DWORD) -> bool { + (_tag & 0x80000000) != 0 +} +#[inline] +pub fn IsReparseTagNameSurrogate(_tag: DWORD) -> bool { + (_tag & 0x20000000) != 0 +} +#[inline] +pub fn IsReparseTagDirectory(_tag: DWORD) -> bool { + (_tag & 0x10000000) != 0 +} +pub const IO_REPARSE_TAG_MOUNT_POINT: DWORD = 0xA0000003; +pub const IO_REPARSE_TAG_HSM: DWORD = 0xC0000004; +pub const IO_REPARSE_TAG_HSM2: DWORD = 0x80000006; +pub const IO_REPARSE_TAG_SIS: DWORD = 0x80000007; +pub const IO_REPARSE_TAG_WIM: DWORD = 0x80000008; +pub const IO_REPARSE_TAG_CSV: DWORD = 0x80000009; +pub const IO_REPARSE_TAG_DFS: DWORD = 0x8000000A; +pub const IO_REPARSE_TAG_SYMLINK: DWORD = 0xA000000C; +pub const IO_REPARSE_TAG_DFSR: DWORD = 0x80000012; +pub const IO_REPARSE_TAG_DEDUP: DWORD = 0x80000013; +pub const IO_REPARSE_TAG_NFS: DWORD = 0x80000014; +pub const IO_REPARSE_TAG_FILE_PLACEHOLDER: DWORD = 0x80000015; +pub const IO_REPARSE_TAG_WOF: DWORD = 0x80000017; +pub const IO_REPARSE_TAG_WCI: DWORD = 0x80000018; +pub const IO_REPARSE_TAG_GLOBAL_REPARSE: DWORD = 0xA0000019; +pub const IO_REPARSE_TAG_CLOUD: DWORD = 0x9000001A; +pub const IO_REPARSE_TAG_CLOUD_ROOT: DWORD = 0x9000101A; +pub const IO_REPARSE_TAG_CLOUD_ON_DEMAND: DWORD = 0x9000201A; +pub const IO_REPARSE_TAG_CLOUD_ROOT_ON_DEMAND: DWORD = 0x9000301A; +pub const IO_REPARSE_TAG_APPEXECLINK: DWORD = 0x8000001B; +pub const IO_REPARSE_TAG_GVFS: DWORD = 0x9000001C; +pub const IO_REPARSE_TAG_WCI_TOMBSTONE: DWORD = 0xA000001F; +pub const IO_REPARSE_TAG_UNHANDLED: DWORD = 0x80000020; +pub const IO_REPARSE_TAG_ONEDRIVE: DWORD = 0x80000021; +pub const IO_REPARSE_TAG_GVFS_TOMBSTONE: DWORD = 0xA0000022; +pub const SCRUB_DATA_INPUT_FLAG_RESUME: DWORD = 0x00000001; +pub const SCRUB_DATA_INPUT_FLAG_SKIP_IN_SYNC: DWORD = 0x00000002; +pub const SCRUB_DATA_INPUT_FLAG_SKIP_NON_INTEGRITY_DATA: DWORD = 0x00000004; +pub const SCRUB_DATA_OUTPUT_FLAG_INCOMPLETE: DWORD = 0x00000001; +pub const SCRUB_DATA_OUTPUT_FLAG_NON_USER_DATA_RANGE: DWORD = 0x00010000; +pub const SCRUB_DATA_OUTPUT_FLAG_PARITY_EXTENT_DATA_RETURNED: DWORD = 0x00020000; +pub const SCRUB_DATA_OUTPUT_FLAG_RESUME_CONTEXT_LENGTH_SPECIFIED: DWORD = 0x00040000; +STRUCT!{struct SCRUB_DATA_INPUT { + Size: DWORD, + Flags: DWORD, + MaximumIos: DWORD, + Reserved: [DWORD; 17], + ResumeContext: [BYTE; 816], +}} +pub type PSCRUB_DATA_INPUT = *mut SCRUB_DATA_INPUT; +STRUCT!{struct SCRUB_PARITY_EXTENT { + Offset: LONGLONG, + Length: ULONGLONG, +}} +pub type PSCRUB_PARITY_EXTENT = *mut SCRUB_PARITY_EXTENT; +STRUCT!{struct SCRUB_PARITY_EXTENT_DATA { + Size: WORD, + Flags: WORD, + NumberOfParityExtents: WORD, + MaximumNumberOfParityExtents: WORD, + ParityExtents: [SCRUB_PARITY_EXTENT; ANYSIZE_ARRAY], +}} +pub type PSCRUB_PARITY_EXTENT_DATA = *mut SCRUB_PARITY_EXTENT_DATA; +STRUCT!{struct SCRUB_DATA_OUTPUT { + Size: DWORD, + Flags: DWORD, + Status: DWORD, + ErrorFileOffset: ULONGLONG, + ErrorLength: ULONGLONG, + NumberOfBytesRepaired: ULONGLONG, + NumberOfBytesFailed: ULONGLONG, + InternalFileReference: ULONGLONG, + ResumeContextLength: WORD, + ParityExtentDataOffset: WORD, + Reserved: [DWORD; 5], + ResumeContext: [BYTE; 816], +}} +pub type PSCRUB_DATA_OUTPUT = *mut SCRUB_DATA_OUTPUT; +ENUM!{enum SharedVirtualDiskSupportType { + SharedVirtualDisksUnsupported = 0, + SharedVirtualDisksSupported = 1, + SharedVirtualDiskSnapshotsSupported = 3, + SharedVirtualDiskCDPSnapshotsSupported = 7, +}} +ENUM!{enum SharedVirtualDiskHandleState { + SharedVirtualDiskHandleStateNone = 0, + SharedVirtualDiskHandleStateFileShared = 1, + SharedVirtualDiskHandleStateHandleShared = 3, +}} +STRUCT!{struct SHARED_VIRTUAL_DISK_SUPPORT { + SharedVirtualDiskSupport: SharedVirtualDiskSupportType, + HandleState: SharedVirtualDiskHandleState, +}} +pub type PSHARED_VIRTUAL_DISK_SUPPORT = *mut SHARED_VIRTUAL_DISK_SUPPORT; +#[inline] +pub fn IsVirtualDiskFileShared(HandleState: SharedVirtualDiskHandleState) -> bool { + (HandleState & SharedVirtualDiskHandleStateFileShared) != 0 +} +pub const IO_COMPLETION_MODIFY_STATE: DWORD = 0x0002; +pub const IO_COMPLETION_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3; +pub const IO_QOS_MAX_RESERVATION: DWORD64 = 1000000000; +pub const SMB_CCF_APP_INSTANCE_EA_NAME: &'static str = "ClusteredApplicationInstance"; +pub const NETWORK_APP_INSTANCE_CSV_FLAGS_VALID_ONLY_IF_CSV_COORDINATOR: DWORD = 0x00000001; +STRUCT!{struct NETWORK_APP_INSTANCE_EA { + AppInstanceID: GUID, + CsvFlags: DWORD, +}} +pub type PNETWORK_APP_INSTANCE_EA = *mut NETWORK_APP_INSTANCE_EA; +pub const DUPLICATE_CLOSE_SOURCE: DWORD = 0x00000001; +pub const DUPLICATE_SAME_ACCESS: DWORD = 0x00000002; +DEFINE_GUID!{GUID_MAX_POWER_SAVINGS, + 0xa1841308, 0x3541, 0x4fab, 0xbc, 0x81, 0xf7, 0x15, 0x56, 0xf2, 0x0b, 0x4a} +DEFINE_GUID!{GUID_MIN_POWER_SAVINGS, + 0x8c5e7fda, 0xe8bf, 0x4a96, 0x9a, 0x85, 0xa6, 0xe2, 0x3a, 0x8c, 0x63, 0x5c} +DEFINE_GUID!{GUID_TYPICAL_POWER_SAVINGS, + 0x381b4222, 0xf694, 0x41f0, 0x96, 0x85, 0xff, 0x5b, 0xb2, 0x60, 0xdf, 0x2e} +DEFINE_GUID!{NO_SUBGROUP_GUID, + 0xfea3413e, 0x7e05, 0x4911, 0x9a, 0x71, 0x70, 0x03, 0x31, 0xf1, 0xc2, 0x94} +DEFINE_GUID!{ALL_POWERSCHEMES_GUID, + 0x68a1e95e, 0x13ea, 0x41e1, 0x80, 0x11, 0x0c, 0x49, 0x6c, 0xa4, 0x90, 0xb0} +DEFINE_GUID!{GUID_POWERSCHEME_PERSONALITY, + 0x245d8541, 0x3943, 0x4422, 0xb0, 0x25, 0x13, 0xa7, 0x84, 0xf6, 0x79, 0xb7} +DEFINE_GUID!{GUID_ACTIVE_POWERSCHEME, + 0x31f9f286, 0x5084, 0x42fe, 0xb7, 0x20, 0x2b, 0x02, 0x64, 0x99, 0x37, 0x63} +DEFINE_GUID!{GUID_IDLE_RESILIENCY_SUBGROUP, + 0x2e601130, 0x5351, 0x4d9d, 0x8e, 0x4, 0x25, 0x29, 0x66, 0xba, 0xd0, 0x54} +DEFINE_GUID!{GUID_IDLE_RESILIENCY_PERIOD, + 0xc42b79aa, 0xaa3a, 0x484b, 0xa9, 0x8f, 0x2c, 0xf3, 0x2a, 0xa9, 0xa, 0x28} +DEFINE_GUID!{GUID_DEEP_SLEEP_ENABLED, + 0xd502f7ee, 0x1dc7, 0x4efd, 0xa5, 0x5d, 0xf0, 0x4b, 0x6f, 0x5c, 0x5, 0x45} +DEFINE_GUID!{GUID_DEEP_SLEEP_PLATFORM_STATE, + 0xd23f2fb8, 0x9536, 0x4038, 0x9c, 0x94, 0x1c, 0xe0, 0x2e, 0x5c, 0x21, 0x52} +DEFINE_GUID!{GUID_DISK_COALESCING_POWERDOWN_TIMEOUT, + 0xc36f0eb4, 0x2988, 0x4a70, 0x8e, 0xee, 0x8, 0x84, 0xfc, 0x2c, 0x24, 0x33} +DEFINE_GUID!{GUID_EXECUTION_REQUIRED_REQUEST_TIMEOUT, + 0x3166bc41, 0x7e98, 0x4e03, 0xb3, 0x4e, 0xec, 0xf, 0x5f, 0x2b, 0x21, 0x8e} +DEFINE_GUID!{GUID_VIDEO_SUBGROUP, + 0x7516b95f, 0xf776, 0x4464, 0x8c, 0x53, 0x06, 0x16, 0x7f, 0x40, 0xcc, 0x99} +DEFINE_GUID!{GUID_VIDEO_POWERDOWN_TIMEOUT, + 0x3c0bc021, 0xc8a8, 0x4e07, 0xa9, 0x73, 0x6b, 0x14, 0xcb, 0xcb, 0x2b, 0x7e} +DEFINE_GUID!{GUID_VIDEO_ANNOYANCE_TIMEOUT, + 0x82dbcf2d, 0xcd67, 0x40c5, 0xbf, 0xdc, 0x9f, 0x1a, 0x5c, 0xcd, 0x46, 0x63} +DEFINE_GUID!{GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, + 0xeed904df, 0xb142, 0x4183, 0xb1, 0x0b, 0x5a, 0x11, 0x97, 0xa3, 0x78, 0x64} +DEFINE_GUID!{GUID_VIDEO_DIM_TIMEOUT, + 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee} +DEFINE_GUID!{GUID_VIDEO_ADAPTIVE_POWERDOWN, + 0x90959d22, 0xd6a1, 0x49b9, 0xaf, 0x93, 0xbc, 0xe8, 0x85, 0xad, 0x33, 0x5b} +DEFINE_GUID!{GUID_MONITOR_POWER_ON, + 0x02731015, 0x4510, 0x4526, 0x99, 0xe6, 0xe5, 0xa1, 0x7e, 0xbd, 0x1a, 0xea} +DEFINE_GUID!{GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, + 0xaded5e82, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb} +DEFINE_GUID!{GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, + 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96} +DEFINE_GUID!{GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, + 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff} +DEFINE_GUID!{GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, + 0xfbd9aa66, 0x9553, 0x4097, 0xba, 0x44, 0xed, 0x6e, 0x9d, 0x65, 0xea, 0xb8} +DEFINE_GUID!{GUID_CONSOLE_DISPLAY_STATE, + 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47} +DEFINE_GUID!{GUID_ALLOW_DISPLAY_REQUIRED, + 0xa9ceb8da, 0xcd46, 0x44fb, 0xa9, 0x8b, 0x02, 0xaf, 0x69, 0xde, 0x46, 0x23} +DEFINE_GUID!{GUID_VIDEO_CONSOLE_LOCK_TIMEOUT, + 0x8ec4b3a5, 0x6868, 0x48c2, 0xbe, 0x75, 0x4f, 0x30, 0x44, 0xbe, 0x88, 0xa7} +DEFINE_GUID!{GUID_ADAPTIVE_POWER_BEHAVIOR_SUBGROUP, + 0x8619b916, 0xe004, 0x4dd8, 0x9b, 0x66, 0xda, 0xe8, 0x6f, 0x80, 0x66, 0x98} +DEFINE_GUID!{GUID_NON_ADAPTIVE_INPUT_TIMEOUT, + 0x5adbbfbc, 0x74e, 0x4da1, 0xba, 0x38, 0xdb, 0x8b, 0x36, 0xb2, 0xc8, 0xf3} +DEFINE_GUID!{GUID_ADAPTIVE_INPUT_CONTROLLER_STATE, + 0xe98fae9, 0xf45a, 0x4de1, 0xa7, 0x57, 0x60, 0x31, 0xf1, 0x97, 0xf6, 0xea} +DEFINE_GUID!{GUID_DISK_SUBGROUP, + 0x0012ee47, 0x9041, 0x4b5d, 0x9b, 0x77, 0x53, 0x5f, 0xba, 0x8b, 0x14, 0x42} +DEFINE_GUID!{GUID_DISK_MAX_POWER, + 0x51dea550, 0xbb38, 0x4bc4, 0x99, 0x1b, 0xea, 0xcf, 0x37, 0xbe, 0x5e, 0xc8} +DEFINE_GUID!{GUID_DISK_POWERDOWN_TIMEOUT, + 0x6738e2c4, 0xe8a5, 0x4a42, 0xb1, 0x6a, 0xe0, 0x40, 0xe7, 0x69, 0x75, 0x6e} +DEFINE_GUID!{GUID_DISK_IDLE_TIMEOUT, + 0x58e39ba8, 0xb8e6, 0x4ef6, 0x90, 0xd0, 0x89, 0xae, 0x32, 0xb2, 0x58, 0xd6} +DEFINE_GUID!{GUID_DISK_BURST_IGNORE_THRESHOLD, + 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63} +DEFINE_GUID!{GUID_DISK_ADAPTIVE_POWERDOWN, + 0x396a32e1, 0x499a, 0x40b2, 0x91, 0x24, 0xa9, 0x6a, 0xfe, 0x70, 0x76, 0x67} +DEFINE_GUID!{GUID_SLEEP_SUBGROUP, + 0x238c9fa8, 0x0aad, 0x41ed, 0x83, 0xf4, 0x97, 0xbe, 0x24, 0x2c, 0x8f, 0x20} +DEFINE_GUID!{GUID_SLEEP_IDLE_THRESHOLD, + 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70} +DEFINE_GUID!{GUID_STANDBY_TIMEOUT, + 0x29f6c1db, 0x86da, 0x48c5, 0x9f, 0xdb, 0xf2, 0xb6, 0x7b, 0x1f, 0x44, 0xda} +DEFINE_GUID!{GUID_UNATTEND_SLEEP_TIMEOUT, + 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0} +DEFINE_GUID!{GUID_HIBERNATE_TIMEOUT, + 0x9d7815a6, 0x7ee4, 0x497e, 0x88, 0x88, 0x51, 0x5a, 0x05, 0xf0, 0x23, 0x64} +DEFINE_GUID!{GUID_HIBERNATE_FASTS4_POLICY, + 0x94ac6d29, 0x73ce, 0x41a6, 0x80, 0x9f, 0x63, 0x63, 0xba, 0x21, 0xb4, 0x7e} +DEFINE_GUID!{GUID_CRITICAL_POWER_TRANSITION, + 0xb7a27025, 0xe569, 0x46c2, 0xa5, 0x04, 0x2b, 0x96, 0xca, 0xd2, 0x25, 0xa1} +DEFINE_GUID!{GUID_SYSTEM_AWAYMODE, + 0x98a7f580, 0x01f7, 0x48aa, 0x9c, 0x0f, 0x44, 0x35, 0x2c, 0x29, 0xe5, 0xc0} +DEFINE_GUID!{GUID_ALLOW_AWAYMODE, + 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87} +DEFINE_GUID!{GUID_USER_PRESENCE_PREDICTION, + 0x82011705, 0xfb95, 0x4d46, 0x8d, 0x35, 0x40, 0x42, 0xb1, 0xd2, 0xd, 0xef} +DEFINE_GUID!{GUID_STANDBY_BUDGET_GRACE_PERIOD, + 0x60c07fe1, 0x0556, 0x45cf, 0x99, 0x03, 0xd5, 0x6e, 0x32, 0x21, 0x2, 0x42} +DEFINE_GUID!{GUID_STANDBY_BUDGET_PERCENT, + 0x9fe527be, 0x1b70, 0x48da, 0x93, 0x0d, 0x7b, 0xcf, 0x17, 0xb4, 0x49, 0x90} +DEFINE_GUID!{GUID_STANDBY_RESERVE_GRACE_PERIOD, + 0xc763ee92, 0x71e8, 0x4127, 0x84, 0xeb, 0xf6, 0xed, 0x04, 0x3a, 0x3e, 0x3d} +DEFINE_GUID!{GUID_STANDBY_RESERVE_TIME, + 0x468fe7e5, 0x1158, 0x46ec, 0x88, 0xbc, 0x5b, 0x96, 0xc9, 0xe4, 0x4f, 0xd0} +DEFINE_GUID!{GUID_STANDBY_RESET_PERCENT, + 0x49cb11a5, 0x56e2, 0x4afb, 0x9d, 0x38, 0x3d, 0xf4, 0x78, 0x72, 0xe2, 0x1b} +DEFINE_GUID!{GUID_ALLOW_STANDBY_STATES, + 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab} +DEFINE_GUID!{GUID_ALLOW_RTC_WAKE, + 0xbd3b718a, 0x0680, 0x4d9d, 0x8a, 0xb2, 0xe1, 0xd2, 0xb4, 0xac, 0x80, 0x6d} +DEFINE_GUID!{GUID_ALLOW_SYSTEM_REQUIRED, + 0xa4b195f5, 0x8225, 0x47d8, 0x80, 0x12, 0x9d, 0x41, 0x36, 0x97, 0x86, 0xe2} +DEFINE_GUID!{GUID_POWER_SAVING_STATUS, + 0xe00958c0, 0xc213, 0x4ace, 0xac, 0x77, 0xfe, 0xcc, 0xed, 0x2e, 0xee, 0xa5} +DEFINE_GUID!{GUID_ENERGY_SAVER_SUBGROUP, + 0xde830923, 0xa562, 0x41af, 0xa0, 0x86, 0xe3, 0xa2, 0xc6, 0xba, 0xd2, 0xda} +DEFINE_GUID!{GUID_ENERGY_SAVER_BATTERY_THRESHOLD, + 0xe69653ca, 0xcf7f, 0x4f05, 0xaa, 0x73, 0xcb, 0x83, 0x3f, 0xa9, 0x0a, 0xd4} +DEFINE_GUID!{GUID_ENERGY_SAVER_BRIGHTNESS, + 0x13d09884, 0xf74e, 0x474a, 0xa8, 0x52, 0xb6, 0xbd, 0xe8, 0xad, 0x03, 0xa8} +DEFINE_GUID!{GUID_ENERGY_SAVER_POLICY, + 0x5c5bb349, 0xad29, 0x4ee2, 0x9d, 0xb, 0x2b, 0x25, 0x27, 0xf, 0x7a, 0x81} +DEFINE_GUID!{GUID_SYSTEM_BUTTON_SUBGROUP, + 0x4f971e89, 0xeebd, 0x4455, 0xa8, 0xde, 0x9e, 0x59, 0x04, 0x0e, 0x73, 0x47} +pub const POWERBUTTON_ACTION_INDEX_NOTHING: DWORD = 0; +pub const POWERBUTTON_ACTION_INDEX_SLEEP: DWORD = 1; +pub const POWERBUTTON_ACTION_INDEX_HIBERNATE: DWORD = 2; +pub const POWERBUTTON_ACTION_INDEX_SHUTDOWN: DWORD = 3; +pub const POWERBUTTON_ACTION_INDEX_TURN_OFF_THE_DISPLAY: DWORD = 4; +pub const POWERBUTTON_ACTION_VALUE_NOTHING: DWORD = 0; +pub const POWERBUTTON_ACTION_VALUE_SLEEP: DWORD = 2; +pub const POWERBUTTON_ACTION_VALUE_HIBERNATE: DWORD = 3; +pub const POWERBUTTON_ACTION_VALUE_SHUTDOWN: DWORD = 6; +pub const POWERBUTTON_ACTION_VALUE_TURN_OFF_THE_DISPLAY: DWORD = 8; +DEFINE_GUID!{GUID_POWERBUTTON_ACTION, + 0x7648efa3, 0xdd9c, 0x4e3e, 0xb5, 0x66, 0x50, 0xf9, 0x29, 0x38, 0x62, 0x80} +DEFINE_GUID!{GUID_SLEEPBUTTON_ACTION, + 0x96996bc0, 0xad50, 0x47ec, 0x92, 0x3b, 0x6f, 0x41, 0x87, 0x4d, 0xd9, 0xeb} +DEFINE_GUID!{GUID_USERINTERFACEBUTTON_ACTION, + 0xa7066653, 0x8d6c, 0x40a8, 0x91, 0x0e, 0xa1, 0xf5, 0x4b, 0x84, 0xc7, 0xe5} +DEFINE_GUID!{GUID_LIDCLOSE_ACTION, + 0x5ca83367, 0x6e45, 0x459f, 0xa2, 0x7b, 0x47, 0x6b, 0x1d, 0x01, 0xc9, 0x36} +DEFINE_GUID!{GUID_LIDOPEN_POWERSTATE, + 0x99ff10e7, 0x23b1, 0x4c07, 0xa9, 0xd1, 0x5c, 0x32, 0x06, 0xd7, 0x41, 0xb4} +DEFINE_GUID!{GUID_BATTERY_SUBGROUP, + 0xe73a048d, 0xbf27, 0x4f12, 0x97, 0x31, 0x8b, 0x20, 0x76, 0xe8, 0x89, 0x1f} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_ACTION_0, + 0x637ea02f, 0xbbcb, 0x4015, 0x8e, 0x2c, 0xa1, 0xc7, 0xb9, 0xc0, 0xb5, 0x46} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_LEVEL_0, + 0x9a66d8d7, 0x4ff7, 0x4ef9, 0xb5, 0xa2, 0x5a, 0x32, 0x6c, 0xa2, 0xa4, 0x69} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_FLAGS_0, + 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_ACTION_1, + 0xd8742dcb, 0x3e6a, 0x4b3c, 0xb3, 0xfe, 0x37, 0x46, 0x23, 0xcd, 0xcf, 0x06} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_LEVEL_1, + 0x8183ba9a, 0xe910, 0x48da, 0x87, 0x69, 0x14, 0xae, 0x6d, 0xc1, 0x17, 0x0a} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_FLAGS_1, + 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_ACTION_2, + 0x421cba38, 0x1a8e, 0x4881, 0xac, 0x89, 0xe3, 0x3a, 0x8b, 0x04, 0xec, 0xe4} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_LEVEL_2, + 0x07a07ca2, 0xadaf, 0x40d7, 0xb0, 0x77, 0x53, 0x3a, 0xad, 0xed, 0x1b, 0xfa} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_FLAGS_2, + 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_ACTION_3, + 0x80472613, 0x9780, 0x455e, 0xb3, 0x08, 0x72, 0xd3, 0x00, 0x3c, 0xf2, 0xf8} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_LEVEL_3, + 0x58afd5a6, 0xc2dd, 0x47d2, 0x9f, 0xbf, 0xef, 0x70, 0xcc, 0x5c, 0x59, 0x65} +DEFINE_GUID!{GUID_BATTERY_DISCHARGE_FLAGS_3, + 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3} +DEFINE_GUID!{GUID_PROCESSOR_SETTINGS_SUBGROUP, + 0x54533251, 0x82be, 0x4824, 0x96, 0xc1, 0x47, 0xb6, 0x0b, 0x74, 0x0d, 0x00} +DEFINE_GUID!{GUID_PROCESSOR_THROTTLE_POLICY, + 0x57027304, 0x4af6, 0x4104, 0x92, 0x60, 0xe3, 0xd9, 0x52, 0x48, 0xfc, 0x36} +pub const PERFSTATE_POLICY_CHANGE_IDEAL: DWORD = 0; +pub const PERFSTATE_POLICY_CHANGE_SINGLE: DWORD = 1; +pub const PERFSTATE_POLICY_CHANGE_ROCKET: DWORD = 2; +pub const PERFSTATE_POLICY_CHANGE_IDEAL_AGGRESSIVE: DWORD = 3; +pub const PERFSTATE_POLICY_CHANGE_DECREASE_MAX: DWORD = PERFSTATE_POLICY_CHANGE_ROCKET; +pub const PERFSTATE_POLICY_CHANGE_INCREASE_MAX: DWORD = PERFSTATE_POLICY_CHANGE_IDEAL_AGGRESSIVE; +DEFINE_GUID!{GUID_PROCESSOR_THROTTLE_MAXIMUM, + 0xbc5038f7, 0x23e0, 0x4960, 0x96, 0xda, 0x33, 0xab, 0xaf, 0x59, 0x35, 0xec} +DEFINE_GUID!{GUID_PROCESSOR_THROTTLE_MAXIMUM_1, + 0xbc5038f7, 0x23e0, 0x4960, 0x96, 0xda, 0x33, 0xab, 0xaf, 0x59, 0x35, 0xed} +DEFINE_GUID!{GUID_PROCESSOR_THROTTLE_MINIMUM, + 0x893dee8e, 0x2bef, 0x41e0, 0x89, 0xc6, 0xb5, 0x5d, 0x09, 0x29, 0x96, 0x4c} +DEFINE_GUID!{GUID_PROCESSOR_THROTTLE_MINIMUM_1, + 0x893dee8e, 0x2bef, 0x41e0, 0x89, 0xc6, 0xb5, 0x5d, 0x09, 0x29, 0x96, 0x4d} +DEFINE_GUID!{GUID_PROCESSOR_FREQUENCY_LIMIT, + 0x75b0ae3f, 0xbce0, 0x45a7, 0x8c, 0x89, 0xc9, 0x61, 0x1c, 0x25, 0xe1, 0x00} +DEFINE_GUID!{GUID_PROCESSOR_FREQUENCY_LIMIT_1, + 0x75b0ae3f, 0xbce0, 0x45a7, 0x8c, 0x89, 0xc9, 0x61, 0x1c, 0x25, 0xe1, 0x01} +DEFINE_GUID!{GUID_PROCESSOR_ALLOW_THROTTLING, + 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb} +pub const PROCESSOR_THROTTLE_DISABLED: DWORD = 0; +pub const PROCESSOR_THROTTLE_ENABLED: DWORD = 1; +pub const PROCESSOR_THROTTLE_AUTOMATIC: DWORD = 2; +DEFINE_GUID!{GUID_PROCESSOR_IDLESTATE_POLICY, + 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c} +DEFINE_GUID!{GUID_PROCESSOR_PERFSTATE_POLICY, + 0xbbdc3814, 0x18e9, 0x4463, 0x8a, 0x55, 0xd1, 0x97, 0x32, 0x7c, 0x45, 0xc0} +DEFINE_GUID!{GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, + 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d} +DEFINE_GUID!{GUID_PROCESSOR_PERF_INCREASE_THRESHOLD_1, + 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5e} +DEFINE_GUID!{GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, + 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6} +DEFINE_GUID!{GUID_PROCESSOR_PERF_DECREASE_THRESHOLD_1, + 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa7} +DEFINE_GUID!{GUID_PROCESSOR_PERF_INCREASE_POLICY, + 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18} +DEFINE_GUID!{GUID_PROCESSOR_PERF_INCREASE_POLICY_1, + 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x19} +DEFINE_GUID!{GUID_PROCESSOR_PERF_DECREASE_POLICY, + 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6} +DEFINE_GUID!{GUID_PROCESSOR_PERF_DECREASE_POLICY_1, + 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc7} +DEFINE_GUID!{GUID_PROCESSOR_PERF_INCREASE_TIME, + 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa} +DEFINE_GUID!{GUID_PROCESSOR_PERF_INCREASE_TIME_1, + 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xab} +DEFINE_GUID!{GUID_PROCESSOR_PERF_DECREASE_TIME, + 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8} +DEFINE_GUID!{GUID_PROCESSOR_PERF_DECREASE_TIME_1, + 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc9} +DEFINE_GUID!{GUID_PROCESSOR_PERF_TIME_CHECK, + 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5} +DEFINE_GUID!{GUID_PROCESSOR_PERF_BOOST_POLICY, + 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59} +pub const PROCESSOR_PERF_BOOST_POLICY_DISABLED: DWORD = 0; +pub const PROCESSOR_PERF_BOOST_POLICY_MAX: DWORD = 100; +DEFINE_GUID!{GUID_PROCESSOR_PERF_BOOST_MODE, + 0xbe337238, 0xd82, 0x4146, 0xa9, 0x60, 0x4f, 0x37, 0x49, 0xd4, 0x70, 0xc7} +pub const PROCESSOR_PERF_BOOST_MODE_DISABLED: DWORD = 0; +pub const PROCESSOR_PERF_BOOST_MODE_ENABLED: DWORD = 1; +pub const PROCESSOR_PERF_BOOST_MODE_AGGRESSIVE: DWORD = 2; +pub const PROCESSOR_PERF_BOOST_MODE_EFFICIENT_ENABLED: DWORD = 3; +pub const PROCESSOR_PERF_BOOST_MODE_EFFICIENT_AGGRESSIVE: DWORD = 4; +pub const PROCESSOR_PERF_BOOST_MODE_AGGRESSIVE_AT_GUARANTEED: DWORD = 5; +pub const PROCESSOR_PERF_BOOST_MODE_EFFICIENT_AGGRESSIVE_AT_GUARANTEED: DWORD = 6; +pub const PROCESSOR_PERF_BOOST_MODE_MAX: DWORD + = PROCESSOR_PERF_BOOST_MODE_EFFICIENT_AGGRESSIVE_AT_GUARANTEED; +DEFINE_GUID!{GUID_PROCESSOR_PERF_AUTONOMOUS_MODE, + 0x8baa4a8a, 0x14c6, 0x4451, 0x8e, 0x8b, 0x14, 0xbd, 0xbd, 0x19, 0x75, 0x37} +pub const PROCESSOR_PERF_AUTONOMOUS_MODE_DISABLED: DWORD = 0; +pub const PROCESSOR_PERF_AUTONOMOUS_MODE_ENABLED: DWORD = 1; +DEFINE_GUID!{GUID_PROCESSOR_PERF_ENERGY_PERFORMANCE_PREFERENCE, + 0x36687f9e, 0xe3a5, 0x4dbf, 0xb1, 0xdc, 0x15, 0xeb, 0x38, 0x1c, 0x68, 0x63} +pub const PROCESSOR_PERF_PERFORMANCE_PREFERENCE: DWORD = 0xff; +pub const PROCESSOR_PERF_ENERGY_PREFERENCE: DWORD = 0; +DEFINE_GUID!{GUID_PROCESSOR_PERF_AUTONOMOUS_ACTIVITY_WINDOW, + 0xcfeda3d0, 0x7697, 0x4566, 0xa9, 0x22, 0xa9, 0x8, 0x6c, 0xd4, 0x9d, 0xfa} +pub const PROCESSOR_PERF_MINIMUM_ACTIVITY_WINDOW: DWORD = 0; +pub const PROCESSOR_PERF_MAXIMUM_ACTIVITY_WINDOW: DWORD = 1270000000; +DEFINE_GUID!{GUID_PROCESSOR_DUTY_CYCLING, + 0x4e4450b3, 0x6179, 0x4e91, 0xb8, 0xf1, 0x5b, 0xb9, 0x93, 0x8f, 0x81, 0xa1} +pub const PROCESSOR_DUTY_CYCLING_DISABLED: DWORD = 0; +pub const PROCESSOR_DUTY_CYCLING_ENABLED: DWORD = 1; +DEFINE_GUID!{GUID_PROCESSOR_IDLE_ALLOW_SCALING, + 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6} +DEFINE_GUID!{GUID_PROCESSOR_IDLE_DISABLE, + 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad} +DEFINE_GUID!{GUID_PROCESSOR_IDLE_STATE_MAXIMUM, + 0x9943e905, 0x9a30, 0x4ec1, 0x9b, 0x99, 0x44, 0xdd, 0x3b, 0x76, 0xf7, 0xa2} +DEFINE_GUID!{GUID_PROCESSOR_IDLE_TIME_CHECK, + 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b} +DEFINE_GUID!{GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, + 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19} +DEFINE_GUID!{GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, + 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, + 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, + 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, + 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6} +pub const CORE_PARKING_POLICY_CHANGE_IDEAL: DWORD = 0; +pub const CORE_PARKING_POLICY_CHANGE_SINGLE: DWORD = 1; +pub const CORE_PARKING_POLICY_CHANGE_ROCKET: DWORD = 2; +pub const CORE_PARKING_POLICY_CHANGE_MULTISTEP: DWORD = 3; +pub const CORE_PARKING_POLICY_CHANGE_MAX: DWORD = CORE_PARKING_POLICY_CHANGE_MULTISTEP; +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, + 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_MAX_CORES, + 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_MAX_CORES_1, + 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x29} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_MIN_CORES, + 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_MIN_CORES_1, + 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x84} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, + 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, + 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, + 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, + 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, + 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, + 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, + 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, + 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb} +DEFINE_GUID!{GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, + 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1} +DEFINE_GUID!{GUID_PROCESSOR_PARKING_CORE_OVERRIDE, + 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f} +DEFINE_GUID!{GUID_PROCESSOR_PARKING_PERF_STATE, + 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b} +DEFINE_GUID!{GUID_PROCESSOR_PARKING_PERF_STATE_1, + 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2c} +DEFINE_GUID!{GUID_PROCESSOR_PARKING_CONCURRENCY_THRESHOLD, + 0x2430ab6f, 0xa520, 0x44a2, 0x96, 0x01, 0xf7, 0xf2, 0x3b, 0x51, 0x34, 0xb1} +DEFINE_GUID!{GUID_PROCESSOR_PARKING_HEADROOM_THRESHOLD, + 0xf735a673, 0x2066, 0x4f80, 0xa0, 0xc5, 0xdd, 0xee, 0x0c, 0xf1, 0xbf, 0x5d} +DEFINE_GUID!{GUID_PROCESSOR_PARKING_DISTRIBUTION_THRESHOLD, + 0x4bdaf4e9, 0xd103, 0x46d7, 0xa5, 0xf0, 0x62, 0x80, 0x12, 0x16, 0x16, 0xef} +DEFINE_GUID!{GUID_PROCESSOR_PERF_HISTORY, + 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f} +DEFINE_GUID!{GUID_PROCESSOR_PERF_HISTORY_1, + 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x60} +DEFINE_GUID!{GUID_PROCESSOR_PERF_INCREASE_HISTORY, + 0x99b3ef01, 0x752f, 0x46a1, 0x80, 0xfb, 0x77, 0x30, 0x1, 0x1f, 0x23, 0x54} +DEFINE_GUID!{GUID_PROCESSOR_PERF_DECREASE_HISTORY, + 0x300f6f8, 0xabd6, 0x45a9, 0xb7, 0x4f, 0x49, 0x8, 0x69, 0x1a, 0x40, 0xb5} +DEFINE_GUID!{GUID_PROCESSOR_PERF_CORE_PARKING_HISTORY, + 0x77d7f282, 0x8f1a, 0x42cd, 0x85, 0x37, 0x45, 0x45, 0xa, 0x83, 0x9b, 0xe8} +DEFINE_GUID!{GUID_PROCESSOR_PERF_LATENCY_HINT, + 0x0822df31, 0x9c83, 0x441c, 0xa0, 0x79, 0x0d, 0xe4, 0xcf, 0x00, 0x9c, 0x7b} +DEFINE_GUID!{GUID_PROCESSOR_PERF_LATENCY_HINT_PERF, + 0x619b7505, 0x3b, 0x4e82, 0xb7, 0xa6, 0x4d, 0xd2, 0x9c, 0x30, 0x9, 0x71} +DEFINE_GUID!{GUID_PROCESSOR_PERF_LATENCY_HINT_PERF_1, + 0x619b7505, 0x3b, 0x4e82, 0xb7, 0xa6, 0x4d, 0xd2, 0x9c, 0x30, 0x9, 0x72} +DEFINE_GUID!{GUID_PROCESSOR_LATENCY_HINT_MIN_UNPARK, + 0x616cdaa5, 0x695e, 0x4545, 0x97, 0xad, 0x97, 0xdc, 0x2d, 0x1b, 0xdd, 0x88} +DEFINE_GUID!{GUID_PROCESSOR_LATENCY_HINT_MIN_UNPARK_1, + 0x616cdaa5, 0x695e, 0x4545, 0x97, 0xad, 0x97, 0xdc, 0x2d, 0x1b, 0xdd, 0x89} +DEFINE_GUID!{GUID_PROCESSOR_DISTRIBUTE_UTILITY, + 0xe0007330, 0xf589, 0x42ed, 0xa4, 0x01, 0x5d, 0xdb, 0x10, 0xe7, 0x85, 0xd3} +DEFINE_GUID!{GUID_PROCESSOR_HETEROGENEOUS_POLICY, + 0x7f2f5cfa, 0xf10c, 0x4823, 0xb5, 0xe1, 0xe9, 0x3a, 0xe8, 0x5f, 0x46, 0xb5} +DEFINE_GUID!{GUID_PROCESSOR_HETERO_DECREASE_TIME, + 0x7f2492b6, 0x60b1, 0x45e5, 0xae, 0x55, 0x77, 0x3f, 0x8c, 0xd5, 0xca, 0xec} +DEFINE_GUID!{GUID_PROCESSOR_HETERO_INCREASE_TIME, + 0x4009efa7, 0xe72d, 0x4cba, 0x9e, 0xdf, 0x91, 0x08, 0x4e, 0xa8, 0xcb, 0xc3} +DEFINE_GUID!{GUID_PROCESSOR_HETERO_DECREASE_THRESHOLD, + 0xf8861c27, 0x95e7, 0x475c, 0x86, 0x5b, 0x13, 0xc0, 0xcb, 0x3f, 0x9d, 0x6b} +DEFINE_GUID!{GUID_PROCESSOR_HETERO_INCREASE_THRESHOLD, + 0xb000397d, 0x9b0b, 0x483d, 0x98, 0xc9, 0x69, 0x2a, 0x60, 0x60, 0xcf, 0xbf} +DEFINE_GUID!{GUID_PROCESSOR_CLASS0_FLOOR_PERF, + 0xfddc842b, 0x8364, 0x4edc, 0x94, 0xcf, 0xc1, 0x7f, 0x60, 0xde, 0x1c, 0x80} +DEFINE_GUID!{GUID_PROCESSOR_CLASS1_INITIAL_PERF, + 0x1facfc65, 0xa930, 0x4bc5, 0x9f, 0x38, 0x50, 0x4e, 0xc0, 0x97, 0xbb, 0xc0} +DEFINE_GUID!{GUID_SYSTEM_COOLING_POLICY, + 0x94d3a615, 0xa899, 0x4ac5, 0xae, 0x2b, 0xe4, 0xd8, 0xf6, 0x34, 0x36, 0x7f} +DEFINE_GUID!{GUID_LOCK_CONSOLE_ON_WAKE, + 0x0e796bdb, 0x100d, 0x47d6, 0xa2, 0xd5, 0xf7, 0xd2, 0xda, 0xa5, 0x1f, 0x51} +DEFINE_GUID!{GUID_DEVICE_IDLE_POLICY, + 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19} +pub const POWER_DEVICE_IDLE_POLICY_PERFORMANCE: DWORD = 0; +pub const POWER_DEVICE_IDLE_POLICY_CONSERVATIVE: DWORD = 1; +DEFINE_GUID!{GUID_CONNECTIVITY_IN_STANDBY, + 0xf15576e8, 0x98b7, 0x4186, 0xb9, 0x44, 0xea, 0xfa, 0x66, 0x44, 0x02, 0xd9} +pub const POWER_CONNECTIVITY_IN_STANDBY_DISABLED: DWORD = 0; +pub const POWER_CONNECTIVITY_IN_STANDBY_ENABLED: DWORD = 1; +pub const POWER_CONNECTIVITY_IN_STANDBY_DISABLED_LID_CLOSE: DWORD = 2; +DEFINE_GUID!{GUID_DISCONNECTED_STANDBY_MODE, + 0x68afb2d9, 0xee95, 0x47a8, 0x8f, 0x50, 0x41, 0x15, 0x08, 0x80, 0x73, 0xb1} +pub const POWER_DISCONNECTED_STANDBY_MODE_NORMAL: DWORD = 0; +pub const POWER_DISCONNECTED_STANDBY_MODE_AGGRESSIVE: DWORD = 1; +DEFINE_GUID!{GUID_ACDC_POWER_SOURCE, + 0x5d3e9a59, 0xe9d5, 0x4b00, 0xa6, 0xbd, 0xff, 0x34, 0xff, 0x51, 0x65, 0x48} +DEFINE_GUID!{GUID_LIDSWITCH_STATE_CHANGE, + 0xba3e0f4d, 0xb817, 0x4094, 0xa2, 0xd1, 0xd5, 0x63, 0x79, 0xe6, 0xa0, 0xf3} +DEFINE_GUID!{GUID_BATTERY_PERCENTAGE_REMAINING, + 0xa7ad8041, 0xb45a, 0x4cae, 0x87, 0xa3, 0xee, 0xcb, 0xb4, 0x68, 0xa9, 0xe1} +DEFINE_GUID!{GUID_BATTERY_COUNT, + 0x7d263f15, 0xfca4, 0x49e5, 0x85, 0x4b, 0xa9, 0xf2, 0xbf, 0xbd, 0x5c, 0x24} +DEFINE_GUID!{GUID_GLOBAL_USER_PRESENCE, + 0x786e8a1d, 0xb427, 0x4344, 0x92, 0x7, 0x9, 0xe7, 0xb, 0xdc, 0xbe, 0xa9} +DEFINE_GUID!{GUID_SESSION_DISPLAY_STATUS, + 0x2b84c20e, 0xad23, 0x4ddf, 0x93, 0xdb, 0x5, 0xff, 0xbd, 0x7e, 0xfc, 0xa5} +DEFINE_GUID!{GUID_SESSION_USER_PRESENCE, + 0x3c0f4548, 0xc03f, 0x4c4d, 0xb9, 0xf2, 0x23, 0x7e, 0xde, 0x68, 0x63, 0x76} +DEFINE_GUID!{GUID_IDLE_BACKGROUND_TASK, + 0x515c31d8, 0xf734, 0x163d, 0xa0, 0xfd, 0x11, 0xa0, 0x8c, 0x91, 0xe8, 0xf1} +DEFINE_GUID!{GUID_BACKGROUND_TASK_NOTIFICATION, + 0xcf23f240, 0x2a54, 0x48d8, 0xb1, 0x14, 0xde, 0x15, 0x18, 0xff, 0x05, 0x2e} +DEFINE_GUID!{GUID_APPLAUNCH_BUTTON, + 0x1a689231, 0x7399, 0x4e9a, 0x8f, 0x99, 0xb7, 0x1f, 0x99, 0x9d, 0xb3, 0xfa} +DEFINE_GUID!{GUID_PCIEXPRESS_SETTINGS_SUBGROUP, + 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20} +DEFINE_GUID!{GUID_PCIEXPRESS_ASPM_POLICY, + 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5} +DEFINE_GUID!{GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, + 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6} +DEFINE_GUID!{GUID_INTSTEER_SUBGROUP, + 0x48672f38, 0x7a9a, 0x4bb2, 0x8b, 0xf8, 0x3d, 0x85, 0xbe, 0x19, 0xde, 0x4e} +DEFINE_GUID!{GUID_INTSTEER_MODE, + 0x2bfc24f9, 0x5ea2, 0x4801, 0x82, 0x13, 0x3d, 0xba, 0xe0, 0x1a, 0xa3, 0x9d} +DEFINE_GUID!{GUID_INTSTEER_LOAD_PER_PROC_TRIGGER, + 0x73cde64d, 0xd720, 0x4bb2, 0xa8, 0x60, 0xc7, 0x55, 0xaf, 0xe7, 0x7e, 0xf2} +DEFINE_GUID!{GUID_INTSTEER_TIME_UNPARK_TRIGGER, + 0xd6ba4903, 0x386f, 0x4c2c, 0x8a, 0xdb, 0x5c, 0x21, 0xb3, 0x32, 0x8d, 0x25} +ENUM!{enum SYSTEM_POWER_STATE { + PowerSystemUnspecified = 0, + PowerSystemWorking = 1, + PowerSystemSleeping1 = 2, + PowerSystemSleeping2 = 3, + PowerSystemSleeping3 = 4, + PowerSystemHibernate = 5, + PowerSystemShutdown = 6, + PowerSystemMaximum = 7, +}} +pub type PSYSTEM_POWER_STATE = *mut SYSTEM_POWER_STATE; +pub const POWER_SYSTEM_MAXIMUM: usize = 7; +ENUM!{enum POWER_ACTION { + PowerActionNone = 0, + PowerActionReserved, + PowerActionSleep, + PowerActionHibernate, + PowerActionShutdown, + PowerActionShutdownReset, + PowerActionShutdownOff, + PowerActionWarmEject, + PowerActionDisplayOff, +}} +pub type PPOWER_ACTION = *mut POWER_ACTION; +ENUM!{enum DEVICE_POWER_STATE { + PowerDeviceUnspecified = 0, + PowerDeviceD0, + PowerDeviceD1, + PowerDeviceD2, + PowerDeviceD3, + PowerDeviceMaximum, +}} +pub type PDEVICE_POWER_STATE = *mut DEVICE_POWER_STATE; +ENUM!{enum MONITOR_DISPLAY_STATE { + PowerMonitorOff = 0, + PowerMonitorOn, + PowerMonitorDim, +}} +pub type PMONITOR_DISPLAY_STATE = *mut MONITOR_DISPLAY_STATE; +ENUM!{enum USER_ACTIVITY_PRESENCE { + PowerUserPresent = 0, + PowerUserNotPresent, + PowerUserInactive, + PowerUserMaximum, + PowerUserInvalid = PowerUserMaximum, +}} +pub type PUSER_ACTIVITY_PRESENCE = *mut USER_ACTIVITY_PRESENCE; +pub const ES_SYSTEM_REQUIRED: DWORD = 0x00000001; +pub const ES_DISPLAY_REQUIRED: DWORD = 0x00000002; +pub const ES_USER_PRESENT: DWORD = 0x00000004; +pub const ES_AWAYMODE_REQUIRED: DWORD = 0x00000040; +pub const ES_CONTINUOUS: DWORD = 0x80000000; +pub type EXECUTION_STATE = DWORD; +pub type PEXECUTION_STATE = *mut DWORD; +ENUM!{enum LATENCY_TIME { + LT_DONT_CARE, + LT_LOWEST_LATENCY, +}} +pub const DIAGNOSTIC_REASON_VERSION: ULONG = 0; +pub const DIAGNOSTIC_REASON_SIMPLE_STRING: ULONG = 0x00000001; +pub const DIAGNOSTIC_REASON_DETAILED_STRING: ULONG = 0x00000002; +pub const DIAGNOSTIC_REASON_NOT_SPECIFIED: ULONG = 0x80000000; +pub const DIAGNOSTIC_REASON_INVALID_FLAGS: ULONG = !0x80000007; +pub const POWER_REQUEST_CONTEXT_VERSION: ULONG = DIAGNOSTIC_REASON_VERSION; +pub const POWER_REQUEST_CONTEXT_SIMPLE_STRING: ULONG = DIAGNOSTIC_REASON_SIMPLE_STRING; +pub const POWER_REQUEST_CONTEXT_DETAILED_STRING: ULONG = DIAGNOSTIC_REASON_DETAILED_STRING; +ENUM!{enum POWER_REQUEST_TYPE { + PowerRequestDisplayRequired, + PowerRequestSystemRequired, + PowerRequestAwayModeRequired, + PowerRequestExecutionRequired, +}} +pub type PPOWER_REQUEST_TYPE = *mut POWER_REQUEST_TYPE; +pub const PDCAP_D0_SUPPORTED: DWORD = 0x00000001; +pub const PDCAP_D1_SUPPORTED: DWORD = 0x00000002; +pub const PDCAP_D2_SUPPORTED: DWORD = 0x00000004; +pub const PDCAP_D3_SUPPORTED: DWORD = 0x00000008; +pub const PDCAP_WAKE_FROM_D0_SUPPORTED: DWORD = 0x00000010; +pub const PDCAP_WAKE_FROM_D1_SUPPORTED: DWORD = 0x00000020; +pub const PDCAP_WAKE_FROM_D2_SUPPORTED: DWORD = 0x00000040; +pub const PDCAP_WAKE_FROM_D3_SUPPORTED: DWORD = 0x00000080; +pub const PDCAP_WARM_EJECT_SUPPORTED: DWORD = 0x00000100; +STRUCT!{struct CM_POWER_DATA { + PD_Size: DWORD, + PD_MostRecentPowerState: DEVICE_POWER_STATE, + PD_Capabilities: DWORD, + PD_D1Latency: DWORD, + PD_D2Latency: DWORD, + PD_D3Latency: DWORD, + PD_PowerStateMapping: [DEVICE_POWER_STATE; POWER_SYSTEM_MAXIMUM], + PD_DeepestSystemWake: SYSTEM_POWER_STATE, +}} +pub type PCM_POWER_DATA = *mut CM_POWER_DATA; +ENUM!{enum POWER_INFORMATION_LEVEL { + SystemPowerPolicyAc, + SystemPowerPolicyDc, + VerifySystemPolicyAc, + VerifySystemPolicyDc, + SystemPowerCapabilities, + SystemBatteryState, + SystemPowerStateHandler, + ProcessorStateHandler, + SystemPowerPolicyCurrent, + AdministratorPowerPolicy, + SystemReserveHiberFile, + ProcessorInformation, + SystemPowerInformation, + ProcessorStateHandler2, + LastWakeTime, + LastSleepTime, + SystemExecutionState, + SystemPowerStateNotifyHandler, + ProcessorPowerPolicyAc, + ProcessorPowerPolicyDc, + VerifyProcessorPowerPolicyAc, + VerifyProcessorPowerPolicyDc, + ProcessorPowerPolicyCurrent, + SystemPowerStateLogging, + SystemPowerLoggingEntry, + SetPowerSettingValue, + NotifyUserPowerSetting, + PowerInformationLevelUnused0, + SystemMonitorHiberBootPowerOff, + SystemVideoState, + TraceApplicationPowerMessage, + TraceApplicationPowerMessageEnd, + ProcessorPerfStates, + ProcessorIdleStates, + ProcessorCap, + SystemWakeSource, + SystemHiberFileInformation, + TraceServicePowerMessage, + ProcessorLoad, + PowerShutdownNotification, + MonitorCapabilities, + SessionPowerInit, + SessionDisplayState, + PowerRequestCreate, + PowerRequestAction, + GetPowerRequestList, + ProcessorInformationEx, + NotifyUserModeLegacyPowerEvent, + GroupPark, + ProcessorIdleDomains, + WakeTimerList, + SystemHiberFileSize, + ProcessorIdleStatesHv, + ProcessorPerfStatesHv, + ProcessorPerfCapHv, + ProcessorSetIdle, + LogicalProcessorIdling, + UserPresence, + PowerSettingNotificationName, + GetPowerSettingValue, + IdleResiliency, + SessionRITState, + SessionConnectNotification, + SessionPowerCleanup, + SessionLockState, + SystemHiberbootState, + PlatformInformation, + PdcInvocation, + MonitorInvocation, + FirmwareTableInformationRegistered, + SetShutdownSelectedTime, + SuspendResumeInvocation, + PlmPowerRequestCreate, + ScreenOff, + CsDeviceNotification, + PlatformRole, + LastResumePerformance, + DisplayBurst, + ExitLatencySamplingPercentage, + RegisterSpmPowerSettings, + PlatformIdleStates, + ProcessorIdleVeto, + PlatformIdleVeto, + SystemBatteryStatePrecise, + ThermalEvent, + PowerRequestActionInternal, + BatteryDeviceState, + PowerInformationInternal, + ThermalStandby, + SystemHiberFileType, + PhysicalPowerButtonPress, + QueryPotentialDripsConstraint, + EnergyTrackerCreate, + EnergyTrackerQuery, + UpdateBlackBoxRecorder, + PowerInformationLevelMaximum, +}} +ENUM!{enum POWER_USER_PRESENCE_TYPE { + UserNotPresent = 0, + UserPresent = 1, + UserUnknown = 0xff, +}} +pub type PPOWER_USER_PRESENCE_TYPE = *mut POWER_USER_PRESENCE_TYPE; +STRUCT!{struct POWER_USER_PRESENCE { + UserPresence: POWER_USER_PRESENCE_TYPE, +}} +pub type PPOWER_USER_PRESENCE = *mut POWER_USER_PRESENCE; +STRUCT!{struct POWER_SESSION_CONNECT { + Connected: BOOLEAN, + Console: BOOLEAN, +}} +pub type PPOWER_SESSION_CONNECT = *mut POWER_SESSION_CONNECT; +STRUCT!{struct POWER_SESSION_TIMEOUTS { + InputTimeout: DWORD, + DisplayTimeout: DWORD, +}} +pub type PPOWER_SESSION_TIMEOUTS = *mut POWER_SESSION_TIMEOUTS; +STRUCT!{struct POWER_SESSION_RIT_STATE { + Active: BOOLEAN, + LastInputTime: DWORD, +}} +pub type PPOWER_SESSION_RIT_STATE = *mut POWER_SESSION_RIT_STATE; +STRUCT!{struct POWER_SESSION_WINLOGON { + SessionId: DWORD, + Console: BOOLEAN, + Locked: BOOLEAN, +}} +pub type PPOWER_SESSION_WINLOGON = *mut POWER_SESSION_WINLOGON; +STRUCT!{struct POWER_IDLE_RESILIENCY { + CoalescingTimeout: DWORD, + IdleResiliencyPeriod: DWORD, +}} +pub type PPOWER_IDLE_RESILIENCY = *mut POWER_IDLE_RESILIENCY; +ENUM!{enum POWER_MONITOR_REQUEST_REASON { + MonitorRequestReasonUnknown, + MonitorRequestReasonPowerButton, + MonitorRequestReasonRemoteConnection, + MonitorRequestReasonScMonitorpower, + MonitorRequestReasonUserInput, + MonitorRequestReasonAcDcDisplayBurst, + MonitorRequestReasonUserDisplayBurst, + MonitorRequestReasonPoSetSystemState, + MonitorRequestReasonSetThreadExecutionState, + MonitorRequestReasonFullWake, + MonitorRequestReasonSessionUnlock, + MonitorRequestReasonScreenOffRequest, + MonitorRequestReasonIdleTimeout, + MonitorRequestReasonPolicyChange, + MonitorRequestReasonSleepButton, + MonitorRequestReasonLid, + MonitorRequestReasonBatteryCountChange, + MonitorRequestReasonGracePeriod, + MonitorRequestReasonPnP, + MonitorRequestReasonDP, + MonitorRequestReasonSxTransition, + MonitorRequestReasonSystemIdle, + MonitorRequestReasonNearProximity, + MonitorRequestReasonThermalStandby, + MonitorRequestReasonResumePdc, + MonitorRequestReasonResumeS4, + MonitorRequestReasonTerminal, + MonitorRequestReasonPdcSignal, + MonitorRequestReasonAcDcDisplayBurstSuppressed, + MonitorRequestReasonSystemStateEntered, + MonitorRequestReasonWinrt, + MonitorRequestReasonMax, +}} +ENUM!{enum POWER_MONITOR_REQUEST_TYPE { + MonitorRequestTypeOff, + MonitorRequestTypeOnAndPresent, + MonitorRequestTypeToggleOn, +}} +STRUCT!{struct POWER_MONITOR_INVOCATION { + Console: BOOLEAN, + RequestReason: POWER_MONITOR_REQUEST_REASON, +}} +pub type PPOWER_MONITOR_INVOCATION = *mut POWER_MONITOR_INVOCATION; +STRUCT!{struct RESUME_PERFORMANCE { + PostTimeMs: DWORD, + TotalResumeTimeMs: ULONGLONG, + ResumeCompleteTimestamp: ULONGLONG, +}} +pub type PRESUME_PERFORMANCE = *mut RESUME_PERFORMANCE; +ENUM!{enum SYSTEM_POWER_CONDITION { + PoAc, + PoDc, + PoHot, + PoConditionMaximum, +}} +STRUCT!{struct SET_POWER_SETTING_VALUE { + Version: DWORD, + Guid: GUID, + PowerCondition: SYSTEM_POWER_CONDITION, + DataLength: DWORD, + Data: [BYTE; ANYSIZE_ARRAY], +}} +pub type PSET_POWER_SETTING_VALUE = *mut SET_POWER_SETTING_VALUE; +STRUCT!{struct NOTIFY_USER_POWER_SETTING { + Guid: GUID, +}} +pub type PNOTIFY_USER_POWER_SETTING = *mut NOTIFY_USER_POWER_SETTING; +STRUCT!{struct APPLICATIONLAUNCH_SETTING_VALUE { + ActivationTime: LARGE_INTEGER, + Flags: DWORD, + ButtonInstanceID: DWORD, +}} +pub type PAPPLICATIONLAUNCH_SETTING_VALUE = *mut APPLICATIONLAUNCH_SETTING_VALUE; +ENUM!{enum POWER_PLATFORM_ROLE { + PlatformRoleUnspecified = 0, + PlatformRoleDesktop, + PlatformRoleMobile, + PlatformRoleWorkstation, + PlatformRoleEnterpriseServer, + PlatformRoleSOHOServer, + PlatformRoleAppliancePC, + PlatformRolePerformanceServer, + PlatformRoleSlate, + PlatformRoleMaximum, +}} +pub type PPOWER_PLATFORM_ROLE = *mut POWER_PLATFORM_ROLE; +pub const POWER_PLATFORM_ROLE_V1: ULONG = 0x00000001; +pub const POWER_PLATFORM_ROLE_V1_MAX: POWER_PLATFORM_ROLE = PlatformRolePerformanceServer + 1; +pub const POWER_PLATFORM_ROLE_V2: ULONG = 0x00000002; +pub const POWER_PLATFORM_ROLE_V2_MAX: POWER_PLATFORM_ROLE = PlatformRoleSlate + 1; +pub const POWER_PLATFORM_ROLE_VERSION: ULONG = POWER_PLATFORM_ROLE_V2; +pub const POWER_PLATFORM_ROLE_VERSION_MAX: POWER_PLATFORM_ROLE = POWER_PLATFORM_ROLE_V2_MAX; +STRUCT!{struct POWER_PLATFORM_INFORMATION { + AoAc: BOOLEAN, +}} +pub type PPOWER_PLATFORM_INFORMATION = *mut POWER_PLATFORM_INFORMATION; +STRUCT!{struct BATTERY_REPORTING_SCALE { + Granularity: DWORD, + Capacity: DWORD, +}} +pub type PBATTERY_REPORTING_SCALE = *mut BATTERY_REPORTING_SCALE; +STRUCT!{struct PPM_WMI_LEGACY_PERFSTATE { + Frequency: DWORD, + Flags: DWORD, + PercentFrequency: DWORD, +}} +pub type PPPM_WMI_LEGACY_PERFSTATE = *mut PPM_WMI_LEGACY_PERFSTATE; +STRUCT!{struct PPM_WMI_IDLE_STATE { + Latency: DWORD, + Power: DWORD, + TimeCheck: DWORD, + PromotePercent: BYTE, + DemotePercent: BYTE, + StateType: BYTE, + Reserved: BYTE, + StateFlags: DWORD, + Context: DWORD, + IdleHandler: DWORD, + Reserved1: DWORD, +}} +pub type PPPM_WMI_IDLE_STATE = *mut PPM_WMI_IDLE_STATE; +STRUCT!{struct PPM_WMI_IDLE_STATES { + Type: DWORD, + Count: DWORD, + TargetState: DWORD, + OldState: DWORD, + TargetProcessors: DWORD64, + State: [PPM_WMI_IDLE_STATE; ANYSIZE_ARRAY], +}} +pub type PPPM_WMI_IDLE_STATES = *mut PPM_WMI_IDLE_STATES; +STRUCT!{struct PPM_WMI_IDLE_STATES_EX { + Type: DWORD, + Count: DWORD, + TargetState: DWORD, + OldState: DWORD, + TargetProcessors: PVOID, + State: [PPM_WMI_IDLE_STATE; ANYSIZE_ARRAY], +}} +pub type PPPM_WMI_IDLE_STATES_EX = *mut PPM_WMI_IDLE_STATES_EX; +STRUCT!{struct PPM_WMI_PERF_STATE { + Frequency: DWORD, + Power: DWORD, + PercentFrequency: BYTE, + IncreaseLevel: BYTE, + DecreaseLevel: BYTE, + Type: BYTE, + IncreaseTime: DWORD, + DecreaseTime: DWORD, + Control: DWORD64, + Status: DWORD64, + HitCount: DWORD, + Reserved1: DWORD, + Reserved2: DWORD64, + Reserved3: DWORD64, +}} +pub type PPPM_WMI_PERF_STATE = *mut PPM_WMI_PERF_STATE; +STRUCT!{struct PPM_WMI_PERF_STATES { + Count: DWORD, + MaxFrequency: DWORD, + CurrentState: DWORD, + MaxPerfState: DWORD, + MinPerfState: DWORD, + LowestPerfState: DWORD, + ThermalConstraint: DWORD, + BusyAdjThreshold: BYTE, + PolicyType: BYTE, + Type: BYTE, + Reserved: BYTE, + TimerInterval: DWORD, + TargetProcessors: DWORD64, + PStateHandler: DWORD, + PStateContext: DWORD, + TStateHandler: DWORD, + TStateContext: DWORD, + FeedbackHandler: DWORD, + Reserved1: DWORD, + Reserved2: DWORD64, + State: [PPM_WMI_PERF_STATE; ANYSIZE_ARRAY], +}} +pub type PPPM_WMI_PERF_STATES = *mut PPM_WMI_PERF_STATES; +STRUCT!{struct PPM_WMI_PERF_STATES_EX { + Count: DWORD, + MaxFrequency: DWORD, + CurrentState: DWORD, + MaxPerfState: DWORD, + MinPerfState: DWORD, + LowestPerfState: DWORD, + ThermalConstraint: DWORD, + BusyAdjThreshold: BYTE, + PolicyType: BYTE, + Type: BYTE, + Reserved: BYTE, + TimerInterval: DWORD, + TargetProcessors: PVOID, + PStateHandler: DWORD, + PStateContext: DWORD, + TStateHandler: DWORD, + TStateContext: DWORD, + FeedbackHandler: DWORD, + Reserved1: DWORD, + Reserved2: DWORD64, + State: [PPM_WMI_PERF_STATE; ANYSIZE_ARRAY], +}} +pub type PPPM_WMI_PERF_STATES_EX = *mut PPM_WMI_PERF_STATES_EX; +pub const PROC_IDLE_BUCKET_COUNT: usize = 6; +STRUCT!{struct PPM_IDLE_STATE_ACCOUNTING { + IdleTransitions: DWORD, + FailedTransitions: DWORD, + InvalidBucketIndex: DWORD, + TotalTime: DWORD64, + IdleTimeBuckets: [DWORD; PROC_IDLE_BUCKET_COUNT], +}} +pub type PPPM_IDLE_STATE_ACCOUNTING = *mut PPM_IDLE_STATE_ACCOUNTING; +STRUCT!{struct PPM_IDLE_ACCOUNTING { + StateCount: DWORD, + TotalTransitions: DWORD, + ResetCount: DWORD, + StartTime: DWORD64, + State: [PPM_IDLE_STATE_ACCOUNTING; ANYSIZE_ARRAY], +}} +pub type PPPM_IDLE_ACCOUNTING = *mut PPM_IDLE_ACCOUNTING; +pub const PROC_IDLE_BUCKET_COUNT_EX: usize = 16; +STRUCT!{struct PPM_IDLE_STATE_BUCKET_EX { + TotalTimeUs: DWORD64, + MinTimeUs: DWORD, + MaxTimeUs: DWORD, + Count: DWORD, +}} +pub type PPPM_IDLE_STATE_BUCKET_EX = *mut PPM_IDLE_STATE_BUCKET_EX; +STRUCT!{struct PPM_IDLE_STATE_ACCOUNTING_EX { + TotalTime: DWORD64, + IdleTransitions: DWORD, + FailedTransitions: DWORD, + InvalidBucketIndex: DWORD, + MinTimeUs: DWORD, + MaxTimeUs: DWORD, + CancelledTransitions: DWORD, + IdleTimeBuckets: [PPM_IDLE_STATE_BUCKET_EX; PROC_IDLE_BUCKET_COUNT_EX], +}} +pub type PPPM_IDLE_STATE_ACCOUNTING_EX = *mut PPM_IDLE_STATE_ACCOUNTING_EX; +STRUCT!{struct PPM_IDLE_ACCOUNTING_EX { + StateCount: DWORD, + TotalTransitions: DWORD, + ResetCount: DWORD, + AbortCount: DWORD, + StartTime: DWORD64, + State: [PPM_IDLE_STATE_ACCOUNTING_EX; ANYSIZE_ARRAY], +}} +pub type PPPM_IDLE_ACCOUNTING_EX = *mut PPM_IDLE_ACCOUNTING_EX; +pub const ACPI_PPM_SOFTWARE_ALL: DWORD = 0xFC; +pub const ACPI_PPM_SOFTWARE_ANY: DWORD = 0xFD; +pub const ACPI_PPM_HARDWARE_ALL: DWORD = 0xFE; +pub const MS_PPM_SOFTWARE_ALL: DWORD = 0x1; +pub const PPM_FIRMWARE_ACPI1C2: DWORD = 0x00000001; +pub const PPM_FIRMWARE_ACPI1C3: DWORD = 0x00000002; +pub const PPM_FIRMWARE_ACPI1TSTATES: DWORD = 0x00000004; +pub const PPM_FIRMWARE_CST: DWORD = 0x00000008; +pub const PPM_FIRMWARE_CSD: DWORD = 0x00000010; +pub const PPM_FIRMWARE_PCT: DWORD = 0x00000020; +pub const PPM_FIRMWARE_PSS: DWORD = 0x00000040; +pub const PPM_FIRMWARE_XPSS: DWORD = 0x00000080; +pub const PPM_FIRMWARE_PPC: DWORD = 0x00000100; +pub const PPM_FIRMWARE_PSD: DWORD = 0x00000200; +pub const PPM_FIRMWARE_PTC: DWORD = 0x00000400; +pub const PPM_FIRMWARE_TSS: DWORD = 0x00000800; +pub const PPM_FIRMWARE_TPC: DWORD = 0x00001000; +pub const PPM_FIRMWARE_TSD: DWORD = 0x00002000; +pub const PPM_FIRMWARE_PCCH: DWORD = 0x00004000; +pub const PPM_FIRMWARE_PCCP: DWORD = 0x00008000; +pub const PPM_FIRMWARE_OSC: DWORD = 0x00010000; +pub const PPM_FIRMWARE_PDC: DWORD = 0x00020000; +pub const PPM_FIRMWARE_CPC: DWORD = 0x00040000; +pub const PPM_FIRMWARE_LPI: DWORD = 0x00080000; +pub const PPM_PERFORMANCE_IMPLEMENTATION_NONE: DWORD = 0x00000000; +pub const PPM_PERFORMANCE_IMPLEMENTATION_PSTATES: DWORD = 0x00000001; +pub const PPM_PERFORMANCE_IMPLEMENTATION_PCCV1: DWORD = 0x00000002; +pub const PPM_PERFORMANCE_IMPLEMENTATION_CPPC: DWORD = 0x00000003; +pub const PPM_PERFORMANCE_IMPLEMENTATION_PEP: DWORD = 0x00000004; +pub const PPM_IDLE_IMPLEMENTATION_NONE: DWORD = 0x00000000; +pub const PPM_IDLE_IMPLEMENTATION_CSTATES: DWORD = 0x00000001; +pub const PPM_IDLE_IMPLEMENTATION_PEP: DWORD = 0x00000002; +pub const PPM_IDLE_IMPLEMENTATION_MICROPEP: DWORD = 0x00000003; +pub const PPM_IDLE_IMPLEMENTATION_LPISTATES: DWORD = 0x00000004; +DEFINE_GUID!{PPM_PERFSTATE_CHANGE_GUID, + 0xa5b32ddd, 0x7f39, 0x4abc, 0xb8, 0x92, 0x90, 0xe, 0x43, 0xb5, 0x9e, 0xbb} +DEFINE_GUID!{PPM_PERFSTATE_DOMAIN_CHANGE_GUID, + 0x995e6b7f, 0xd653, 0x497a, 0xb9, 0x78, 0x36, 0xa3, 0xc, 0x29, 0xbf, 0x1} +DEFINE_GUID!{PPM_IDLESTATE_CHANGE_GUID, + 0x4838fe4f, 0xf71c, 0x4e51, 0x9e, 0xcc, 0x84, 0x30, 0xa7, 0xac, 0x4c, 0x6c} +DEFINE_GUID!{PPM_PERFSTATES_DATA_GUID, + 0x5708cc20, 0x7d40, 0x4bf4, 0xb4, 0xaa, 0x2b, 0x01, 0x33, 0x8d, 0x01, 0x26} +DEFINE_GUID!{PPM_IDLESTATES_DATA_GUID, + 0xba138e10, 0xe250, 0x4ad7, 0x86, 0x16, 0xcf, 0x1a, 0x7a, 0xd4, 0x10, 0xe7} +DEFINE_GUID!{PPM_IDLE_ACCOUNTING_GUID, + 0xe2a26f78, 0xae07, 0x4ee0, 0xa3, 0x0f, 0xce, 0x54, 0xf5, 0x5a, 0x94, 0xcd} +DEFINE_GUID!{PPM_IDLE_ACCOUNTING_EX_GUID, + 0xd67abd39, 0x81f8, 0x4a5e, 0x81, 0x52, 0x72, 0xe3, 0x1e, 0xc9, 0x12, 0xee} +DEFINE_GUID!{PPM_THERMALCONSTRAINT_GUID, + 0xa852c2c8, 0x1a4c, 0x423b, 0x8c, 0x2c, 0xf3, 0x0d, 0x82, 0x93, 0x1a, 0x88} +DEFINE_GUID!{PPM_PERFMON_PERFSTATE_GUID, + 0x7fd18652, 0xcfe, 0x40d2, 0xb0, 0xa1, 0xb, 0x6, 0x6a, 0x87, 0x75, 0x9e} +DEFINE_GUID!{PPM_THERMAL_POLICY_CHANGE_GUID, + 0x48f377b8, 0x6880, 0x4c7b, 0x8b, 0xdc, 0x38, 0x1, 0x76, 0xc6, 0x65, 0x4d} +STRUCT!{struct PPM_PERFSTATE_EVENT { + State: DWORD, + Status: DWORD, + Latency: DWORD, + Speed: DWORD, + Processor: DWORD, +}} +pub type PPPM_PERFSTATE_EVENT = *mut PPM_PERFSTATE_EVENT; +STRUCT!{struct PPM_PERFSTATE_DOMAIN_EVENT { + State: DWORD, + Latency: DWORD, + Speed: DWORD, + Processors: DWORD64, +}} +pub type PPPM_PERFSTATE_DOMAIN_EVENT = *mut PPM_PERFSTATE_DOMAIN_EVENT; +STRUCT!{struct PPM_IDLESTATE_EVENT { + NewState: DWORD, + OldState: DWORD, + Processors: DWORD64, +}} +pub type PPPM_IDLESTATE_EVENT = *mut PPM_IDLESTATE_EVENT; +STRUCT!{struct PPM_THERMALCHANGE_EVENT { + ThermalConstraint: DWORD, + Processors: DWORD64, +}} +pub type PPPM_THERMALCHANGE_EVENT = *mut PPM_THERMALCHANGE_EVENT; +STRUCT!{struct PPM_THERMAL_POLICY_EVENT { + Mode: BYTE, + Processors: DWORD64, +}} +pub type PPPM_THERMAL_POLICY_EVENT = *mut PPM_THERMAL_POLICY_EVENT; +STRUCT!{struct POWER_ACTION_POLICY { + Action: POWER_ACTION, + Flags: DWORD, + EventCode: DWORD, +}} +pub type PPOWER_ACTION_POLICY = *mut POWER_ACTION_POLICY; +pub const POWER_ACTION_QUERY_ALLOWED: DWORD = 0x00000001; +pub const POWER_ACTION_UI_ALLOWED: DWORD = 0x00000002; +pub const POWER_ACTION_OVERRIDE_APPS: DWORD = 0x00000004; +pub const POWER_ACTION_HIBERBOOT: DWORD = 0x00000008; +pub const POWER_ACTION_USER_NOTIFY: DWORD = 0x00000010; +pub const POWER_ACTION_DOZE_TO_HIBERNATE: DWORD = 0x00000020; +pub const POWER_ACTION_PSEUDO_TRANSITION: DWORD = 0x08000000; +pub const POWER_ACTION_LIGHTEST_FIRST: DWORD = 0x10000000; +pub const POWER_ACTION_LOCK_CONSOLE: DWORD = 0x20000000; +pub const POWER_ACTION_DISABLE_WAKES: DWORD = 0x40000000; +pub const POWER_ACTION_CRITICAL: DWORD = 0x80000000; +pub const POWER_LEVEL_USER_NOTIFY_TEXT: DWORD = 0x00000001; +pub const POWER_LEVEL_USER_NOTIFY_SOUND: DWORD = 0x00000002; +pub const POWER_LEVEL_USER_NOTIFY_EXEC: DWORD = 0x00000004; +pub const POWER_USER_NOTIFY_BUTTON: DWORD = 0x00000008; +pub const POWER_USER_NOTIFY_SHUTDOWN: DWORD = 0x00000010; +pub const POWER_USER_NOTIFY_FORCED_SHUTDOWN: DWORD = 0x00000020; +pub const POWER_FORCE_TRIGGER_RESET: DWORD = 0x80000000; +pub const BATTERY_DISCHARGE_FLAGS_EVENTCODE_MASK: DWORD = 0x00000007; +pub const BATTERY_DISCHARGE_FLAGS_ENABLE: DWORD = 0x80000000; +STRUCT!{struct SYSTEM_POWER_LEVEL { + Enable: BOOLEAN, + Spare: [BYTE; 3], + BatteryLevel: DWORD, + PowerPolicy: POWER_ACTION_POLICY, + MinSystemState: SYSTEM_POWER_STATE, +}} +pub type PSYSTEM_POWER_LEVEL = *mut SYSTEM_POWER_LEVEL; +pub const NUM_DISCHARGE_POLICIES: usize = 4; +pub const DISCHARGE_POLICY_CRITICAL: DWORD = 0; +pub const DISCHARGE_POLICY_LOW: DWORD = 1; +STRUCT!{struct SYSTEM_POWER_POLICY { + Revision: DWORD, + PowerButton: POWER_ACTION_POLICY, + SleepButton: POWER_ACTION_POLICY, + LidClose: POWER_ACTION_POLICY, + LidOpenWake: SYSTEM_POWER_STATE, + Reserved: DWORD, + Idle: POWER_ACTION_POLICY, + IdleTimeout: DWORD, + IdleSensitivity: BYTE, + DynamicThrottle: BYTE, + Spare2: [BYTE; 2], + MinSleep: SYSTEM_POWER_STATE, + MaxSleep: SYSTEM_POWER_STATE, + ReducedLatencySleep: SYSTEM_POWER_STATE, + WinLogonFlags: DWORD, + Spare3: DWORD, + DozeS4Timeout: DWORD, + BroadcastCapacityResolution: DWORD, + DischargePolicy: [SYSTEM_POWER_LEVEL; NUM_DISCHARGE_POLICIES], + VideoTimeout: DWORD, + VideoDimDisplay: BOOLEAN, + VideoReserved: [DWORD; 3], + SpindownTimeout: DWORD, + OptimizeForPower: BOOLEAN, + FanThrottleTolerance: BYTE, + ForcedThrottle: BYTE, + MinThrottle: BYTE, + OverThrottled: POWER_ACTION_POLICY, +}} +pub type PSYSTEM_POWER_POLICY = *mut SYSTEM_POWER_POLICY; +pub const PROCESSOR_IDLESTATE_POLICY_COUNT: usize = 0x3; +STRUCT!{struct PROCESSOR_IDLESTATE_INFO { + TimeCheck: DWORD, + DemotePercent: BYTE, + PromotePercent: BYTE, + Spare: [BYTE; 2], +}} +pub type PPROCESSOR_IDLESTATE_INFO = *mut PROCESSOR_IDLESTATE_INFO; +STRUCT!{struct PROCESSOR_IDLESTATE_POLICY_Flags { + AsWORD: WORD, +}} +BITFIELD!{PROCESSOR_IDLESTATE_POLICY_Flags AsWORD: WORD [ + AllowScaling set_AllowScaling[0..1], + Disabled set_Disabled[1..2], + Reserved set_Reserved[2..16], +]} +STRUCT!{struct PROCESSOR_IDLESTATE_POLICY { + Revision: WORD, + Flags: PROCESSOR_IDLESTATE_POLICY_Flags, + PolicyCount: DWORD, + Policy: [PROCESSOR_IDLESTATE_INFO; PROCESSOR_IDLESTATE_POLICY_COUNT], +}} +pub type PPROCESSOR_IDLESTATE_POLICY = *mut PROCESSOR_IDLESTATE_POLICY; +pub const PO_THROTTLE_NONE: DWORD = 0; +pub const PO_THROTTLE_CONSTANT: DWORD = 1; +pub const PO_THROTTLE_DEGRADE: DWORD = 2; +pub const PO_THROTTLE_ADAPTIVE: DWORD = 3; +pub const PO_THROTTLE_MAXIMUM: DWORD = 4; +STRUCT!{struct PROCESSOR_POWER_POLICY_INFO { + TimeCheck: DWORD, + DemoteLimit: DWORD, + PromoteLimit: DWORD, + DemotePercent: BYTE, + PromotePercent: BYTE, + Spare: [BYTE; 2], + Reserved: DWORD, +}} +BITFIELD!{PROCESSOR_POWER_POLICY_INFO Reserved: DWORD [ + AllowDemotion set_AllowDemotion[0..1], + AllowPromotion set_AllowPromotion[1..2], + Reserved set_Reserved[2..32], +]} +pub type PPROCESSOR_POWER_POLICY_INFO = *mut PROCESSOR_POWER_POLICY_INFO; +STRUCT!{struct PROCESSOR_POWER_POLICY { + Revision: DWORD, + DynamicThrottle: BYTE, + Spare: [BYTE; 3], + BitFields: DWORD, + PolicyCount: DWORD, + Policy: [PROCESSOR_POWER_POLICY_INFO; 3], +}} +BITFIELD!{PROCESSOR_POWER_POLICY BitFields: DWORD [ + DisableCStates set_DisableCStates[0..1], + Reserved set_Reserved[1..32], +]} +pub type PPROCESSOR_POWER_POLICY = *mut PROCESSOR_POWER_POLICY; +STRUCT!{struct PROCESSOR_PERFSTATE_POLICY_u_Flags { + AsBYTE: BYTE, +}} +BITFIELD!{PROCESSOR_PERFSTATE_POLICY_u_Flags AsBYTE: BYTE [ + NoDomainAccounting set_NoDomainAccounting[0..1], + IncreasePolicy set_IncreasePolicy[1..3], + DecreasePolicy set_DecreasePolicy[3..5], + Reserved set_Reserved[5..8], +]} +UNION!{union PROCESSOR_PERFSTATE_POLICY_u { + [u8; 1], + Spare Spare_mut: BYTE, + Flags Flags_mut: PROCESSOR_PERFSTATE_POLICY_u_Flags, +}} +STRUCT!{struct PROCESSOR_PERFSTATE_POLICY { + Revision: DWORD, + MaxThrottle: BYTE, + MinThrottle: BYTE, + BusyAdjThreshold: BYTE, + u: PROCESSOR_PERFSTATE_POLICY_u, + TimeCheck: DWORD, + IncreaseTime: DWORD, + DecreaseTime: DWORD, + IncreasePercent: DWORD, + DecreasePercent: DWORD, +}} +pub type PPROCESSOR_PERFSTATE_POLICY = *mut PROCESSOR_PERFSTATE_POLICY; +STRUCT!{struct ADMINISTRATOR_POWER_POLICY { + MinSleep: SYSTEM_POWER_STATE, + MaxSleep: SYSTEM_POWER_STATE, + MinVideoTimeout: DWORD, + MaxVideoTimeout: DWORD, + MinSpindownTimeout: DWORD, + MaxSpindownTimeout: DWORD, +}} +pub type PADMINISTRATOR_POWER_POLICY = *mut ADMINISTRATOR_POWER_POLICY; +ENUM!{enum HIBERFILE_BUCKET_SIZE { + HiberFileBucket1GB = 0, + HiberFileBucket2GB, + HiberFileBucket4GB, + HiberFileBucket8GB, + HiberFileBucket16GB, + HiberFileBucket32GB, + HiberFileBucketUnlimited, + HiberFileBucketMax, +}} +pub const HIBERFILE_TYPE_NONE: BYTE = 0x00; +pub const HIBERFILE_TYPE_REDUCED: BYTE = 0x01; +pub const HIBERFILE_TYPE_FULL: BYTE = 0x02; +pub const HIBERFILE_TYPE_MAX: usize = 0x03; +STRUCT!{struct HIBERFILE_BUCKET { + MaxPhysicalMemory: DWORD64, + PhysicalMemoryPercent: [DWORD; HIBERFILE_TYPE_MAX], +}} +pub type PHIBERFILE_BUCKET = *mut HIBERFILE_BUCKET; +STRUCT!{struct SYSTEM_POWER_CAPABILITIES { + PowerButtonPresent: BOOLEAN, + SleepButtonPresent: BOOLEAN, + LidPresent: BOOLEAN, + SystemS1: BOOLEAN, + SystemS2: BOOLEAN, + SystemS3: BOOLEAN, + SystemS4: BOOLEAN, + SystemS5: BOOLEAN, + HiberFilePresent: BOOLEAN, + FullWake: BOOLEAN, + VideoDimPresent: BOOLEAN, + ApmPresent: BOOLEAN, + UpsPresent: BOOLEAN, + ThermalControl: BOOLEAN, + ProcessorThrottle: BOOLEAN, + ProcessorMinThrottle: BYTE, + ProcessorMaxThrottle: BYTE, + FastSystemS4: BOOLEAN, + Hiberboot: BOOLEAN, + WakeAlarmPresent: BOOLEAN, + AoAc: BOOLEAN, + DiskSpinDown: BOOLEAN, + HiberFileType: BYTE, + AoAcConnectivitySupported: BOOLEAN, + spare3: [BYTE; 6], + SystemBatteriesPresent: BOOLEAN, + BatteriesAreShortTerm: BOOLEAN, + BatteryScale: [BATTERY_REPORTING_SCALE; 3], + AcOnLineWake: SYSTEM_POWER_STATE, + SoftLidWake: SYSTEM_POWER_STATE, + RtcWake: SYSTEM_POWER_STATE, + MinDeviceWakeState: SYSTEM_POWER_STATE, + DefaultLowLatencyWake: SYSTEM_POWER_STATE, +}} +pub type PSYSTEM_POWER_CAPABILITIES = *mut SYSTEM_POWER_CAPABILITIES; +STRUCT!{struct SYSTEM_BATTERY_STATE { + AcOnLine: BOOLEAN, + BatteryPresent: BOOLEAN, + Charging: BOOLEAN, + Discharging: BOOLEAN, + Spare1: [BOOLEAN; 3], + Tag: BYTE, + MaxCapacity: DWORD, + RemainingCapacity: DWORD, + Rate: DWORD, + EstimatedTime: DWORD, + DefaultAlert1: DWORD, + DefaultAlert2: DWORD, +}} +pub type PSYSTEM_BATTERY_STATE = *mut SYSTEM_BATTERY_STATE; +pub const IMAGE_DOS_SIGNATURE: WORD = 0x5A4D; +pub const IMAGE_OS2_SIGNATURE: WORD = 0x454E; +pub const IMAGE_OS2_SIGNATURE_LE: WORD = 0x454C; +pub const IMAGE_VXD_SIGNATURE: WORD = 0x454C; +pub const IMAGE_NT_SIGNATURE: DWORD = 0x00004550; +STRUCT!{struct IMAGE_DOS_HEADER { + e_magic: WORD, + e_cblp: WORD, + e_cp: WORD, + e_crlc: WORD, + e_cparhdr: WORD, + e_minalloc: WORD, + e_maxalloc: WORD, + e_ss: WORD, + e_sp: WORD, + e_csum: WORD, + e_ip: WORD, + e_cs: WORD, + e_lfarlc: WORD, + e_ovno: WORD, + e_res: [WORD; 4], + e_oemid: WORD, + e_oeminfo: WORD, + e_res2: [WORD; 10], + e_lfanew: LONG, +}} +pub type PIMAGE_DOS_HEADER = *mut IMAGE_DOS_HEADER; +STRUCT!{struct IMAGE_OS2_HEADER { + ne_magic: WORD, + ne_ver: CHAR, + ne_rev: CHAR, + ne_enttab: WORD, + ne_cbenttab: WORD, + ne_crc: LONG, + ne_flags: WORD, + ne_autodata: WORD, + ne_heap: WORD, + ne_stack: WORD, + ne_csip: LONG, + ne_sssp: LONG, + ne_cseg: WORD, + ne_cmod: WORD, + ne_cbnrestab: WORD, + ne_segtab: WORD, + ne_rsrctab: WORD, + ne_restab: WORD, + ne_modtab: WORD, + ne_imptab: WORD, + ne_nrestab: LONG, + ne_cmovent: WORD, + ne_align: WORD, + ne_cres: WORD, + ne_exetyp: BYTE, + ne_flagsothers: BYTE, + ne_pretthunks: WORD, + ne_psegrefbytes: WORD, + ne_swaparea: WORD, + ne_expver: WORD, +}} +pub type PIMAGE_OS2_HEADER = *mut IMAGE_OS2_HEADER; +STRUCT!{struct IMAGE_VXD_HEADER { + e32_magic: WORD, + e32_border: BYTE, + e32_worder: BYTE, + e32_level: DWORD, + e32_cpu: WORD, + e32_os: WORD, + e32_ver: DWORD, + e32_mflags: DWORD, + e32_mpages: DWORD, + e32_startobj: DWORD, + e32_eip: DWORD, + e32_stackobj: DWORD, + e32_esp: DWORD, + e32_pagesize: DWORD, + e32_lastpagesize: DWORD, + e32_fixupsize: DWORD, + e32_fixupsum: DWORD, + e32_ldrsize: DWORD, + e32_ldrsum: DWORD, + e32_objtab: DWORD, + e32_objcnt: DWORD, + e32_objmap: DWORD, + e32_itermap: DWORD, + e32_rsrctab: DWORD, + e32_rsrccnt: DWORD, + e32_restab: DWORD, + e32_enttab: DWORD, + e32_dirtab: DWORD, + e32_dircnt: DWORD, + e32_fpagetab: DWORD, + e32_frectab: DWORD, + e32_impmod: DWORD, + e32_impmodcnt: DWORD, + e32_impproc: DWORD, + e32_pagesum: DWORD, + e32_datapage: DWORD, + e32_preload: DWORD, + e32_nrestab: DWORD, + e32_cbnrestab: DWORD, + e32_nressum: DWORD, + e32_autodata: DWORD, + e32_debuginfo: DWORD, + e32_debuglen: DWORD, + e32_instpreload: DWORD, + e32_instdemand: DWORD, + e32_heapsize: DWORD, + e32_res3: [BYTE; 12], + e32_winresoff: DWORD, + e32_winreslen: DWORD, + e32_devid: WORD, + e32_ddkver: WORD, +}} +pub type PIMAGE_VXD_HEADER = *mut IMAGE_VXD_HEADER; +STRUCT!{struct IMAGE_FILE_HEADER { + Machine: WORD, + NumberOfSections: WORD, + TimeDateStamp: DWORD, + PointerToSymbolTable: DWORD, + NumberOfSymbols: DWORD, + SizeOfOptionalHeader: WORD, + Characteristics: WORD, +}} +pub type PIMAGE_FILE_HEADER = *mut IMAGE_FILE_HEADER; +pub const IMAGE_SIZEOF_FILE_HEADER: usize = 20; +pub const IMAGE_FILE_RELOCS_STRIPPED: WORD = 0x0001; +pub const IMAGE_FILE_EXECUTABLE_IMAGE: WORD = 0x0002; +pub const IMAGE_FILE_LINE_NUMS_STRIPPED: WORD = 0x0004; +pub const IMAGE_FILE_LOCAL_SYMS_STRIPPED: WORD = 0x0008; +pub const IMAGE_FILE_AGGRESIVE_WS_TRIM: WORD = 0x0010; +pub const IMAGE_FILE_LARGE_ADDRESS_AWARE: WORD = 0x0020; +pub const IMAGE_FILE_BYTES_REVERSED_LO: WORD = 0x0080; +pub const IMAGE_FILE_32BIT_MACHINE: WORD = 0x0100; +pub const IMAGE_FILE_DEBUG_STRIPPED: WORD = 0x0200; +pub const IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP: WORD = 0x0400; +pub const IMAGE_FILE_NET_RUN_FROM_SWAP: WORD = 0x0800; +pub const IMAGE_FILE_SYSTEM: WORD = 0x1000; +pub const IMAGE_FILE_DLL: WORD = 0x2000; +pub const IMAGE_FILE_UP_SYSTEM_ONLY: WORD = 0x4000; +pub const IMAGE_FILE_BYTES_REVERSED_HI: WORD = 0x8000; +pub const IMAGE_FILE_MACHINE_UNKNOWN: WORD = 0; +pub const IMAGE_FILE_MACHINE_TARGET_HOST: WORD = 0x0001; +pub const IMAGE_FILE_MACHINE_I386: WORD = 0x014c; +pub const IMAGE_FILE_MACHINE_R3000: WORD = 0x0162; +pub const IMAGE_FILE_MACHINE_R4000: WORD = 0x0166; +pub const IMAGE_FILE_MACHINE_R10000: WORD = 0x0168; +pub const IMAGE_FILE_MACHINE_WCEMIPSV2: WORD = 0x0169; +pub const IMAGE_FILE_MACHINE_ALPHA: WORD = 0x0184; +pub const IMAGE_FILE_MACHINE_SH3: WORD = 0x01a2; +pub const IMAGE_FILE_MACHINE_SH3DSP: WORD = 0x01a3; +pub const IMAGE_FILE_MACHINE_SH3E: WORD = 0x01a4; +pub const IMAGE_FILE_MACHINE_SH4: WORD = 0x01a6; +pub const IMAGE_FILE_MACHINE_SH5: WORD = 0x01a8; +pub const IMAGE_FILE_MACHINE_ARM: WORD = 0x01c0; +pub const IMAGE_FILE_MACHINE_THUMB: WORD = 0x01c2; +pub const IMAGE_FILE_MACHINE_ARMNT: WORD = 0x01c4; +pub const IMAGE_FILE_MACHINE_AM33: WORD = 0x01d3; +pub const IMAGE_FILE_MACHINE_POWERPC: WORD = 0x01F0; +pub const IMAGE_FILE_MACHINE_POWERPCFP: WORD = 0x01f1; +pub const IMAGE_FILE_MACHINE_IA64: WORD = 0x0200; +pub const IMAGE_FILE_MACHINE_MIPS16: WORD = 0x0266; +pub const IMAGE_FILE_MACHINE_ALPHA64: WORD = 0x0284; +pub const IMAGE_FILE_MACHINE_MIPSFPU: WORD = 0x0366; +pub const IMAGE_FILE_MACHINE_MIPSFPU16: WORD = 0x0466; +pub const IMAGE_FILE_MACHINE_AXP64: WORD = IMAGE_FILE_MACHINE_ALPHA64; +pub const IMAGE_FILE_MACHINE_TRICORE: WORD = 0x0520; +pub const IMAGE_FILE_MACHINE_CEF: WORD = 0x0CEF; +pub const IMAGE_FILE_MACHINE_EBC: WORD = 0x0EBC; +pub const IMAGE_FILE_MACHINE_AMD64: WORD = 0x8664; +pub const IMAGE_FILE_MACHINE_M32R: WORD = 0x9041; +pub const IMAGE_FILE_MACHINE_ARM64: WORD = 0xAA64; +pub const IMAGE_FILE_MACHINE_CEE: WORD = 0xC0EE; +STRUCT!{struct IMAGE_DATA_DIRECTORY { + VirtualAddress: DWORD, + Size: DWORD, +}} +pub type PIMAGE_DATA_DIRECTORY = *mut IMAGE_DATA_DIRECTORY; +pub const IMAGE_NUMBEROF_DIRECTORY_ENTRIES: usize = 16; +STRUCT!{struct IMAGE_OPTIONAL_HEADER32 { + Magic: WORD, + MajorLinkerVersion: BYTE, + MinorLinkerVersion: BYTE, + SizeOfCode: DWORD, + SizeOfInitializedData: DWORD, + SizeOfUninitializedData: DWORD, + AddressOfEntryPoint: DWORD, + BaseOfCode: DWORD, + BaseOfData: DWORD, + ImageBase: DWORD, + SectionAlignment: DWORD, + FileAlignment: DWORD, + MajorOperatingSystemVersion: WORD, + MinorOperatingSystemVersion: WORD, + MajorImageVersion: WORD, + MinorImageVersion: WORD, + MajorSubsystemVersion: WORD, + MinorSubsystemVersion: WORD, + Win32VersionValue: DWORD, + SizeOfImage: DWORD, + SizeOfHeaders: DWORD, + CheckSum: DWORD, + Subsystem: WORD, + DllCharacteristics: WORD, + SizeOfStackReserve: DWORD, + SizeOfStackCommit: DWORD, + SizeOfHeapReserve: DWORD, + SizeOfHeapCommit: DWORD, + LoaderFlags: DWORD, + NumberOfRvaAndSizes: DWORD, + DataDirectory: [IMAGE_DATA_DIRECTORY; IMAGE_NUMBEROF_DIRECTORY_ENTRIES], +}} +pub type PIMAGE_OPTIONAL_HEADER32 = *mut IMAGE_OPTIONAL_HEADER32; +STRUCT!{struct IMAGE_ROM_OPTIONAL_HEADER { + Magic: WORD, + MajorLinkerVersion: BYTE, + MinorLinkerVersion: BYTE, + SizeOfCode: DWORD, + SizeOfInitializedData: DWORD, + SizeOfUninitializedData: DWORD, + AddressOfEntryPoint: DWORD, + BaseOfCode: DWORD, + BaseOfData: DWORD, + BaseOfBss: DWORD, + GprMask: DWORD, + CprMask: [DWORD; 4], + GpValue: DWORD, +}} +pub type PIMAGE_ROM_OPTIONAL_HEADER = *mut IMAGE_ROM_OPTIONAL_HEADER; +STRUCT!{struct IMAGE_OPTIONAL_HEADER64 { + Magic: WORD, + MajorLinkerVersion: BYTE, + MinorLinkerVersion: BYTE, + SizeOfCode: DWORD, + SizeOfInitializedData: DWORD, + SizeOfUninitializedData: DWORD, + AddressOfEntryPoint: DWORD, + BaseOfCode: DWORD, + ImageBase: ULONGLONG, + SectionAlignment: DWORD, + FileAlignment: DWORD, + MajorOperatingSystemVersion: WORD, + MinorOperatingSystemVersion: WORD, + MajorImageVersion: WORD, + MinorImageVersion: WORD, + MajorSubsystemVersion: WORD, + MinorSubsystemVersion: WORD, + Win32VersionValue: DWORD, + SizeOfImage: DWORD, + SizeOfHeaders: DWORD, + CheckSum: DWORD, + Subsystem: WORD, + DllCharacteristics: WORD, + SizeOfStackReserve: ULONGLONG, + SizeOfStackCommit: ULONGLONG, + SizeOfHeapReserve: ULONGLONG, + SizeOfHeapCommit: ULONGLONG, + LoaderFlags: DWORD, + NumberOfRvaAndSizes: DWORD, + DataDirectory: [IMAGE_DATA_DIRECTORY; IMAGE_NUMBEROF_DIRECTORY_ENTRIES], +}} +pub type PIMAGE_OPTIONAL_HEADER64 = *mut IMAGE_OPTIONAL_HEADER64; +pub const IMAGE_NT_OPTIONAL_HDR32_MAGIC: WORD = 0x10b; +pub const IMAGE_NT_OPTIONAL_HDR64_MAGIC: WORD = 0x20b; +pub const IMAGE_ROM_OPTIONAL_HDR_MAGIC: WORD = 0x107; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +pub type IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER64; +pub type PIMAGE_OPTIONAL_HEADER = PIMAGE_OPTIONAL_HEADER64; +pub const IMAGE_NT_OPTIONAL_HDR_MAGIC: WORD = IMAGE_NT_OPTIONAL_HDR64_MAGIC; +} +#[cfg(target_pointer_width = "32")] +IFDEF!{ +pub type IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER32; +pub type PIMAGE_OPTIONAL_HEADER = PIMAGE_OPTIONAL_HEADER32; +pub const IMAGE_NT_OPTIONAL_HDR_MAGIC: WORD = IMAGE_NT_OPTIONAL_HDR32_MAGIC; +} +STRUCT!{struct IMAGE_NT_HEADERS64 { + Signature: DWORD, + FileHeader: IMAGE_FILE_HEADER, + OptionalHeader: IMAGE_OPTIONAL_HEADER64, +}} +pub type PIMAGE_NT_HEADERS64 = *mut IMAGE_NT_HEADERS64; +STRUCT!{struct IMAGE_NT_HEADERS32 { + Signature: DWORD, + FileHeader: IMAGE_FILE_HEADER, + OptionalHeader: IMAGE_OPTIONAL_HEADER32, +}} +pub type PIMAGE_NT_HEADERS32 = *mut IMAGE_NT_HEADERS32; +STRUCT!{struct IMAGE_ROM_HEADERS { + FileHeader: IMAGE_FILE_HEADER, + OptionalHeader: IMAGE_ROM_OPTIONAL_HEADER, +}} +pub type PIMAGE_ROM_HEADERS = *mut IMAGE_ROM_HEADERS; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +pub type IMAGE_NT_HEADERS = IMAGE_NT_HEADERS64; +pub type PIMAGE_NT_HEADERS = PIMAGE_NT_HEADERS64; +} +#[cfg(target_pointer_width = "32")] +IFDEF!{ +pub type IMAGE_NT_HEADERS = IMAGE_NT_HEADERS32; +pub type PIMAGE_NT_HEADERS = PIMAGE_NT_HEADERS32; +} +pub const IMAGE_SUBSYSTEM_UNKNOWN: WORD = 0; +pub const IMAGE_SUBSYSTEM_NATIVE: WORD = 1; +pub const IMAGE_SUBSYSTEM_WINDOWS_GUI: WORD = 2; +pub const IMAGE_SUBSYSTEM_WINDOWS_CUI: WORD = 3; +pub const IMAGE_SUBSYSTEM_OS2_CUI: WORD = 5; +pub const IMAGE_SUBSYSTEM_POSIX_CUI: WORD = 7; +pub const IMAGE_SUBSYSTEM_NATIVE_WINDOWS: WORD = 8; +pub const IMAGE_SUBSYSTEM_WINDOWS_CE_GUI: WORD = 9; +pub const IMAGE_SUBSYSTEM_EFI_APPLICATION: WORD = 10; +pub const IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER: WORD = 11; +pub const IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER: WORD = 12; +pub const IMAGE_SUBSYSTEM_EFI_ROM: WORD = 13; +pub const IMAGE_SUBSYSTEM_XBOX: WORD = 14; +pub const IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION: WORD = 16; +pub const IMAGE_SUBSYSTEM_XBOX_CODE_CATALOG: WORD = 17; +pub const IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA: WORD = 0x0020; +pub const IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE: WORD = 0x0040; +pub const IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY: WORD = 0x0080; +pub const IMAGE_DLLCHARACTERISTICS_NX_COMPAT: WORD = 0x0100; +pub const IMAGE_DLLCHARACTERISTICS_NO_ISOLATION: WORD = 0x0200; +pub const IMAGE_DLLCHARACTERISTICS_NO_SEH: WORD = 0x0400; +pub const IMAGE_DLLCHARACTERISTICS_NO_BIND: WORD = 0x0800; +pub const IMAGE_DLLCHARACTERISTICS_APPCONTAINER: WORD = 0x1000; +pub const IMAGE_DLLCHARACTERISTICS_WDM_DRIVER: WORD = 0x2000; +pub const IMAGE_DLLCHARACTERISTICS_GUARD_CF: WORD = 0x4000; +pub const IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE: WORD = 0x8000; +pub const IMAGE_DIRECTORY_ENTRY_EXPORT: WORD = 0; +pub const IMAGE_DIRECTORY_ENTRY_IMPORT: WORD = 1; +pub const IMAGE_DIRECTORY_ENTRY_RESOURCE: WORD = 2; +pub const IMAGE_DIRECTORY_ENTRY_EXCEPTION: WORD = 3; +pub const IMAGE_DIRECTORY_ENTRY_SECURITY: WORD = 4; +pub const IMAGE_DIRECTORY_ENTRY_BASERELOC: WORD = 5; +pub const IMAGE_DIRECTORY_ENTRY_DEBUG: WORD = 6; +pub const IMAGE_DIRECTORY_ENTRY_ARCHITECTURE: WORD = 7; +pub const IMAGE_DIRECTORY_ENTRY_GLOBALPTR: WORD = 8; +pub const IMAGE_DIRECTORY_ENTRY_TLS: WORD = 9; +pub const IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG: WORD = 10; +pub const IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT: WORD = 11; +pub const IMAGE_DIRECTORY_ENTRY_IAT: WORD = 12; +pub const IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT: WORD = 13; +pub const IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR: WORD = 14; +STRUCT!{struct ANON_OBJECT_HEADER { + Sig1: WORD, + Sig2: WORD, + Version: WORD, + Machine: WORD, + TimeDateStamp: DWORD, + ClassID: CLSID, + SizeOfData: DWORD, +}} +STRUCT!{struct ANON_OBJECT_HEADER_V2 { + Sig1: WORD, + Sig2: WORD, + Version: WORD, + Machine: WORD, + TimeDateStamp: DWORD, + ClassID: CLSID, + SizeOfData: DWORD, + Flags: DWORD, + MetaDataSize: DWORD, + MetaDataOffset: DWORD, +}} +STRUCT!{struct ANON_OBJECT_HEADER_BIGOBJ { + Sig1: WORD, + Sig2: WORD, + Version: WORD, + Machine: WORD, + TimeDateStamp: DWORD, + ClassID: CLSID, + SizeOfData: DWORD, + Flags: DWORD, + MetaDataSize: DWORD, + MetaDataOffset: DWORD, + NumberOfSections: DWORD, + PointerToSymbolTable: DWORD, + NumberOfSymbols: DWORD, +}} +pub const IMAGE_SIZEOF_SHORT_NAME: usize = 8; +UNION!{union IMAGE_SECTION_HEADER_Misc { + [u32; 1], + PhysicalAddress PhysicalAddress_mut: DWORD, + VirtualSize VirtualSize_mut: DWORD, +}} +STRUCT!{struct IMAGE_SECTION_HEADER { + Name: [BYTE; IMAGE_SIZEOF_SHORT_NAME], + Misc: IMAGE_SECTION_HEADER_Misc, + VirtualAddress: DWORD, + SizeOfRawData: DWORD, + PointerToRawData: DWORD, + PointerToRelocations: DWORD, + PointerToLinenumbers: DWORD, + NumberOfRelocations: WORD, + NumberOfLinenumbers: WORD, + Characteristics: DWORD, +}} +pub type PIMAGE_SECTION_HEADER = *mut IMAGE_SECTION_HEADER; +pub const IMAGE_SIZEOF_SECTION_HEADER: usize = 40; +pub const IMAGE_SCN_TYPE_NO_PAD: DWORD = 0x00000008; +pub const IMAGE_SCN_CNT_CODE: DWORD = 0x00000020; +pub const IMAGE_SCN_CNT_INITIALIZED_DATA: DWORD = 0x00000040; +pub const IMAGE_SCN_CNT_UNINITIALIZED_DATA: DWORD = 0x00000080; +pub const IMAGE_SCN_LNK_OTHER: DWORD = 0x00000100; +pub const IMAGE_SCN_LNK_INFO: DWORD = 0x00000200; +pub const IMAGE_SCN_LNK_REMOVE: DWORD = 0x00000800; +pub const IMAGE_SCN_LNK_COMDAT: DWORD = 0x00001000; +pub const IMAGE_SCN_NO_DEFER_SPEC_EXC: DWORD = 0x00004000; +pub const IMAGE_SCN_GPREL: DWORD = 0x00008000; +pub const IMAGE_SCN_MEM_FARDATA: DWORD = 0x00008000; +pub const IMAGE_SCN_MEM_PURGEABLE: DWORD = 0x00020000; +pub const IMAGE_SCN_MEM_16BIT: DWORD = 0x00020000; +pub const IMAGE_SCN_MEM_LOCKED: DWORD = 0x00040000; +pub const IMAGE_SCN_MEM_PRELOAD: DWORD = 0x00080000; +pub const IMAGE_SCN_ALIGN_1BYTES: DWORD = 0x00100000; +pub const IMAGE_SCN_ALIGN_2BYTES: DWORD = 0x00200000; +pub const IMAGE_SCN_ALIGN_4BYTES: DWORD = 0x00300000; +pub const IMAGE_SCN_ALIGN_8BYTES: DWORD = 0x00400000; +pub const IMAGE_SCN_ALIGN_16BYTES: DWORD = 0x00500000; +pub const IMAGE_SCN_ALIGN_32BYTES: DWORD = 0x00600000; +pub const IMAGE_SCN_ALIGN_64BYTES: DWORD = 0x00700000; +pub const IMAGE_SCN_ALIGN_128BYTES: DWORD = 0x00800000; +pub const IMAGE_SCN_ALIGN_256BYTES: DWORD = 0x00900000; +pub const IMAGE_SCN_ALIGN_512BYTES: DWORD = 0x00A00000; +pub const IMAGE_SCN_ALIGN_1024BYTES: DWORD = 0x00B00000; +pub const IMAGE_SCN_ALIGN_2048BYTES: DWORD = 0x00C00000; +pub const IMAGE_SCN_ALIGN_4096BYTES: DWORD = 0x00D00000; +pub const IMAGE_SCN_ALIGN_8192BYTES: DWORD = 0x00E00000; +pub const IMAGE_SCN_ALIGN_MASK: DWORD = 0x00F00000; +pub const IMAGE_SCN_LNK_NRELOC_OVFL: DWORD = 0x01000000; +pub const IMAGE_SCN_MEM_DISCARDABLE: DWORD = 0x02000000; +pub const IMAGE_SCN_MEM_NOT_CACHED: DWORD = 0x04000000; +pub const IMAGE_SCN_MEM_NOT_PAGED: DWORD = 0x08000000; +pub const IMAGE_SCN_MEM_SHARED: DWORD = 0x10000000; +pub const IMAGE_SCN_MEM_EXECUTE: DWORD = 0x20000000; +pub const IMAGE_SCN_MEM_READ: DWORD = 0x40000000; +pub const IMAGE_SCN_MEM_WRITE: DWORD = 0x80000000; +pub const IMAGE_SCN_SCALE_INDEX: DWORD = 0x00000001; +STRUCT!{struct IMAGE_SYMBOL_N_Name { + Short: DWORD, + Long: DWORD, +}} +UNION!{union IMAGE_SYMBOL_N { + [u32; 2], + ShortName ShortName_mut: [BYTE; 8], + Name Name_mut: IMAGE_SYMBOL_N_Name, + LongName LongName_mut: [DWORD; 2], +}} +STRUCT!{struct IMAGE_SYMBOL { + N: IMAGE_SYMBOL_N, + Value: DWORD, + SectionNumber: SHORT, + Type: WORD, + StorageClass: BYTE, + NumberOfAuxSymbols: BYTE, +}} +pub type PIMAGE_SYMBOL = *mut IMAGE_SYMBOL; +pub const IMAGE_SIZEOF_SYMBOL: usize = 18; +STRUCT!{struct IMAGE_SYMBOL_EX_N_Name { + Short: DWORD, + Long: DWORD, +}} +UNION!{union IMAGE_SYMBOL_EX_N { + [u32; 2], + ShortName ShortName_mut: [BYTE; 8], + Name Name_mut: IMAGE_SYMBOL_EX_N_Name, + LongName LongName_mut: [DWORD; 2], +}} +STRUCT!{struct IMAGE_SYMBOL_EX { + N: IMAGE_SYMBOL_EX_N, + Value: DWORD, + SectionNumber: LONG, + Type: WORD, + StorageClass: BYTE, + NumberOfAuxSymbols: BYTE, +}} +pub type PIMAGE_SYMBOL_EX = *mut IMAGE_SYMBOL_EX; +pub const IMAGE_SYM_UNDEFINED: SHORT = 0; +pub const IMAGE_SYM_ABSOLUTE: SHORT = -1; +pub const IMAGE_SYM_DEBUG: SHORT = -2; +pub const IMAGE_SYM_SECTION_MAX: USHORT = 0xFEFF; +pub const IMAGE_SYM_SECTION_MAX_EX: LONG = MAXLONG; +pub const IMAGE_SYM_TYPE_NULL: WORD = 0x0000; +pub const IMAGE_SYM_TYPE_VOID: WORD = 0x0001; +pub const IMAGE_SYM_TYPE_CHAR: WORD = 0x0002; +pub const IMAGE_SYM_TYPE_SHORT: WORD = 0x0003; +pub const IMAGE_SYM_TYPE_INT: WORD = 0x0004; +pub const IMAGE_SYM_TYPE_LONG: WORD = 0x0005; +pub const IMAGE_SYM_TYPE_FLOAT: WORD = 0x0006; +pub const IMAGE_SYM_TYPE_DOUBLE: WORD = 0x0007; +pub const IMAGE_SYM_TYPE_STRUCT: WORD = 0x0008; +pub const IMAGE_SYM_TYPE_UNION: WORD = 0x0009; +pub const IMAGE_SYM_TYPE_ENUM: WORD = 0x000A; +pub const IMAGE_SYM_TYPE_MOE: WORD = 0x000B; +pub const IMAGE_SYM_TYPE_BYTE: WORD = 0x000C; +pub const IMAGE_SYM_TYPE_WORD: WORD = 0x000D; +pub const IMAGE_SYM_TYPE_UINT: WORD = 0x000E; +pub const IMAGE_SYM_TYPE_DWORD: WORD = 0x000F; +pub const IMAGE_SYM_TYPE_PCODE: WORD = 0x8000; +pub const IMAGE_SYM_DTYPE_NULL: WORD = 0; +pub const IMAGE_SYM_DTYPE_POINTER: WORD = 1; +pub const IMAGE_SYM_DTYPE_FUNCTION: WORD = 2; +pub const IMAGE_SYM_DTYPE_ARRAY: WORD = 3; +pub const IMAGE_SYM_CLASS_END_OF_FUNCTION: BYTE = -1i8 as u8; +pub const IMAGE_SYM_CLASS_NULL: BYTE = 0x0000; +pub const IMAGE_SYM_CLASS_AUTOMATIC: BYTE = 0x0001; +pub const IMAGE_SYM_CLASS_EXTERNAL: BYTE = 0x0002; +pub const IMAGE_SYM_CLASS_STATIC: BYTE = 0x0003; +pub const IMAGE_SYM_CLASS_REGISTER: BYTE = 0x0004; +pub const IMAGE_SYM_CLASS_EXTERNAL_DEF: BYTE = 0x0005; +pub const IMAGE_SYM_CLASS_LABEL: BYTE = 0x0006; +pub const IMAGE_SYM_CLASS_UNDEFINED_LABEL: BYTE = 0x0007; +pub const IMAGE_SYM_CLASS_MEMBER_OF_STRUCT: BYTE = 0x0008; +pub const IMAGE_SYM_CLASS_ARGUMENT: BYTE = 0x0009; +pub const IMAGE_SYM_CLASS_STRUCT_TAG: BYTE = 0x000A; +pub const IMAGE_SYM_CLASS_MEMBER_OF_UNION: BYTE = 0x000B; +pub const IMAGE_SYM_CLASS_UNION_TAG: BYTE = 0x000C; +pub const IMAGE_SYM_CLASS_TYPE_DEFINITION: BYTE = 0x000D; +pub const IMAGE_SYM_CLASS_UNDEFINED_STATIC: BYTE = 0x000E; +pub const IMAGE_SYM_CLASS_ENUM_TAG: BYTE = 0x000F; +pub const IMAGE_SYM_CLASS_MEMBER_OF_ENUM: BYTE = 0x0010; +pub const IMAGE_SYM_CLASS_REGISTER_PARAM: BYTE = 0x0011; +pub const IMAGE_SYM_CLASS_BIT_FIELD: BYTE = 0x0012; +pub const IMAGE_SYM_CLASS_FAR_EXTERNAL: BYTE = 0x0044; +pub const IMAGE_SYM_CLASS_BLOCK: BYTE = 0x0064; +pub const IMAGE_SYM_CLASS_FUNCTION: BYTE = 0x0065; +pub const IMAGE_SYM_CLASS_END_OF_STRUCT: BYTE = 0x0066; +pub const IMAGE_SYM_CLASS_FILE: BYTE = 0x0067; +pub const IMAGE_SYM_CLASS_SECTION: BYTE = 0x0068; +pub const IMAGE_SYM_CLASS_WEAK_EXTERNAL: BYTE = 0x0069; +pub const IMAGE_SYM_CLASS_CLR_TOKEN: BYTE = 0x006B; +pub const N_BTMASK: WORD = 0x000F; +pub const N_TMASK: WORD = 0x0030; +pub const N_TMASK1: WORD = 0x00C0; +pub const N_TMASK2: WORD = 0x00F0; +pub const N_BTSHFT: usize = 4; +pub const N_TSHIFT: usize = 2; +#[inline] +pub fn BTYPE(x: WORD) -> bool { + (x & N_BTMASK) != 0 +} +#[inline] +pub fn ISPTR(x: WORD) -> bool { + (x & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT) +} +#[inline] +pub fn ISFCN(x: WORD) -> bool { + (x & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT) +} +#[inline] +pub fn ISARY(x: WORD) -> bool { + (x & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT) +} +#[inline] +pub fn ISTAG(x: BYTE) -> bool { + (x == IMAGE_SYM_CLASS_STRUCT_TAG) || (x == IMAGE_SYM_CLASS_UNION_TAG) + || (x == IMAGE_SYM_CLASS_ENUM_TAG) +} +#[inline] +pub fn INCREF(x: WORD) -> WORD { + ((x & !N_BTMASK) << N_TSHIFT) | (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT) | (x & N_BTMASK) +} +#[inline] +pub fn DECREF(x: WORD) -> WORD { + ((x >> N_TSHIFT) & !N_BTMASK) | (x & N_BTMASK) +} +STRUCT!{struct IMAGE_AUX_SYMBOL_TOKEN_DEF { + bAuxType: BYTE, + bReserved: BYTE, + SymbolTableIndex: DWORD, + rgbReserved: [BYTE; 12], +}} +pub type PIMAGE_AUX_SYMBOL_TOKEN_DEF = *mut IMAGE_AUX_SYMBOL_TOKEN_DEF; +STRUCT!{struct IMAGE_AUX_SYMBOL_Sym_Misc_LnSz { + Linenumber: WORD, + Size: WORD, +}} +UNION!{union IMAGE_AUX_SYMBOL_Sym_Misc { + [u32; 1], + LnSz LnSz_mut: IMAGE_AUX_SYMBOL_Sym_Misc_LnSz, + TotalSize TotalSize_mut: DWORD, +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_Sym_FcnAry_Function { + PointerToLinenumber: DWORD, + PointerToNextFunction: DWORD, +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_Sym_FcnAry_Array { + Dimension: [WORD; 4], +}} +UNION!{union IMAGE_AUX_SYMBOL_Sym_FcnAry { + [u32; 2], + Function Function_mut: IMAGE_AUX_SYMBOL_Sym_FcnAry_Function, + Array Array_mut: IMAGE_AUX_SYMBOL_Sym_FcnAry_Array, +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_Sym { + TagIndex: DWORD, + Misc: IMAGE_AUX_SYMBOL_Sym_Misc, + FcnAry: IMAGE_AUX_SYMBOL_Sym_FcnAry, + TvIndex: WORD, +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_File { + Name: [BYTE; IMAGE_SIZEOF_SYMBOL], +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_Section { + Length: DWORD, + NumberOfRelocations: WORD, + NumberOfLinenumbers: WORD, + CheckSum: DWORD, + Number: SHORT, + Selection: BYTE, + bReserved: BYTE, + HighNumber: SHORT, +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_CRC { + crc: DWORD, + rgbReserved: [BYTE; 14], +}} +STRUCT!{struct IMAGE_AUX_SYMBOL { + Sym: IMAGE_AUX_SYMBOL_Sym, + File: IMAGE_AUX_SYMBOL_File, + Section: IMAGE_AUX_SYMBOL_Section, + TokenDef: IMAGE_AUX_SYMBOL_TOKEN_DEF, + CRC: IMAGE_AUX_SYMBOL_CRC, +}} +pub type PIMAGE_AUX_SYMBOL = *mut IMAGE_AUX_SYMBOL; +STRUCT!{struct IMAGE_AUX_SYMBOL_EX_Sym { + WeakDefaultSymIndex: DWORD, + WeakSearchType: DWORD, + rgbReserved: [BYTE; 12], +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_EX_File { + Name: [BYTE; 20], +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_EX_Section { + Length: DWORD, + NumberOfRelocations: WORD, + NumberOfLinenumbers: WORD, + CheckSum: DWORD, + Number: SHORT, + Selection: BYTE, + bReserved: BYTE, + HighNumber: SHORT, + rgbReserved: [BYTE; 2], +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_EX_s { + TokenDef: IMAGE_AUX_SYMBOL_TOKEN_DEF, + rgbReserved: [BYTE; 2], +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_EX_CRC { + crc: DWORD, + rgbReserved: [BYTE; 16], +}} +STRUCT!{struct IMAGE_AUX_SYMBOL_EX { + Sym: IMAGE_AUX_SYMBOL_EX_Sym, + File: IMAGE_AUX_SYMBOL_EX_File, + Section: IMAGE_AUX_SYMBOL_EX_Section, + s: IMAGE_AUX_SYMBOL_EX_s, + CRC: IMAGE_AUX_SYMBOL_EX_CRC, +}} +pub type PIMAGE_AUX_SYMBOL_EX = *mut IMAGE_AUX_SYMBOL_EX; +ENUM!{enum IMAGE_AUX_SYMBOL_TYPE { + IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF = 1, +}} +pub const IMAGE_COMDAT_SELECT_NODUPLICATES: BYTE = 1; +pub const IMAGE_COMDAT_SELECT_ANY: BYTE = 2; +pub const IMAGE_COMDAT_SELECT_SAME_SIZE: BYTE = 3; +pub const IMAGE_COMDAT_SELECT_EXACT_MATCH: BYTE = 4; +pub const IMAGE_COMDAT_SELECT_ASSOCIATIVE: BYTE = 5; +pub const IMAGE_COMDAT_SELECT_LARGEST: BYTE = 6; +pub const IMAGE_COMDAT_SELECT_NEWEST: BYTE = 7; +pub const IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY: BYTE = 1; +pub const IMAGE_WEAK_EXTERN_SEARCH_LIBRARY: BYTE = 2; +pub const IMAGE_WEAK_EXTERN_SEARCH_ALIAS: BYTE = 3; +UNION!{union IMAGE_RELOCATION_u { + [u32; 1], + VirtualAddress VirtualAddress_mut: DWORD, + RelocCount RelocCount_mut: DWORD, +}} +STRUCT!{struct IMAGE_RELOCATION { + u: IMAGE_RELOCATION_u, + SymbolTableIndex: DWORD, + Type: WORD, +}} +pub type PIMAGE_RELOCATION = *mut IMAGE_RELOCATION; +pub const IMAGE_REL_I386_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_I386_DIR16: WORD = 0x0001; +pub const IMAGE_REL_I386_REL16: WORD = 0x0002; +pub const IMAGE_REL_I386_DIR32: WORD = 0x0006; +pub const IMAGE_REL_I386_DIR32NB: WORD = 0x0007; +pub const IMAGE_REL_I386_SEG12: WORD = 0x0009; +pub const IMAGE_REL_I386_SECTION: WORD = 0x000A; +pub const IMAGE_REL_I386_SECREL: WORD = 0x000B; +pub const IMAGE_REL_I386_TOKEN: WORD = 0x000C; +pub const IMAGE_REL_I386_SECREL7: WORD = 0x000D; +pub const IMAGE_REL_I386_REL32: WORD = 0x0014; +pub const IMAGE_REL_MIPS_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_MIPS_REFHALF: WORD = 0x0001; +pub const IMAGE_REL_MIPS_REFWORD: WORD = 0x0002; +pub const IMAGE_REL_MIPS_JMPADDR: WORD = 0x0003; +pub const IMAGE_REL_MIPS_REFHI: WORD = 0x0004; +pub const IMAGE_REL_MIPS_REFLO: WORD = 0x0005; +pub const IMAGE_REL_MIPS_GPREL: WORD = 0x0006; +pub const IMAGE_REL_MIPS_LITERAL: WORD = 0x0007; +pub const IMAGE_REL_MIPS_SECTION: WORD = 0x000A; +pub const IMAGE_REL_MIPS_SECREL: WORD = 0x000B; +pub const IMAGE_REL_MIPS_SECRELLO: WORD = 0x000C; +pub const IMAGE_REL_MIPS_SECRELHI: WORD = 0x000D; +pub const IMAGE_REL_MIPS_TOKEN: WORD = 0x000E; +pub const IMAGE_REL_MIPS_JMPADDR16: WORD = 0x0010; +pub const IMAGE_REL_MIPS_REFWORDNB: WORD = 0x0022; +pub const IMAGE_REL_MIPS_PAIR: WORD = 0x0025; +pub const IMAGE_REL_ALPHA_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_ALPHA_REFLONG: WORD = 0x0001; +pub const IMAGE_REL_ALPHA_REFQUAD: WORD = 0x0002; +pub const IMAGE_REL_ALPHA_GPREL32: WORD = 0x0003; +pub const IMAGE_REL_ALPHA_LITERAL: WORD = 0x0004; +pub const IMAGE_REL_ALPHA_LITUSE: WORD = 0x0005; +pub const IMAGE_REL_ALPHA_GPDISP: WORD = 0x0006; +pub const IMAGE_REL_ALPHA_BRADDR: WORD = 0x0007; +pub const IMAGE_REL_ALPHA_HINT: WORD = 0x0008; +pub const IMAGE_REL_ALPHA_INLINE_REFLONG: WORD = 0x0009; +pub const IMAGE_REL_ALPHA_REFHI: WORD = 0x000A; +pub const IMAGE_REL_ALPHA_REFLO: WORD = 0x000B; +pub const IMAGE_REL_ALPHA_PAIR: WORD = 0x000C; +pub const IMAGE_REL_ALPHA_MATCH: WORD = 0x000D; +pub const IMAGE_REL_ALPHA_SECTION: WORD = 0x000E; +pub const IMAGE_REL_ALPHA_SECREL: WORD = 0x000F; +pub const IMAGE_REL_ALPHA_REFLONGNB: WORD = 0x0010; +pub const IMAGE_REL_ALPHA_SECRELLO: WORD = 0x0011; +pub const IMAGE_REL_ALPHA_SECRELHI: WORD = 0x0012; +pub const IMAGE_REL_ALPHA_REFQ3: WORD = 0x0013; +pub const IMAGE_REL_ALPHA_REFQ2: WORD = 0x0014; +pub const IMAGE_REL_ALPHA_REFQ1: WORD = 0x0015; +pub const IMAGE_REL_ALPHA_GPRELLO: WORD = 0x0016; +pub const IMAGE_REL_ALPHA_GPRELHI: WORD = 0x0017; +pub const IMAGE_REL_PPC_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_PPC_ADDR64: WORD = 0x0001; +pub const IMAGE_REL_PPC_ADDR32: WORD = 0x0002; +pub const IMAGE_REL_PPC_ADDR24: WORD = 0x0003; +pub const IMAGE_REL_PPC_ADDR16: WORD = 0x0004; +pub const IMAGE_REL_PPC_ADDR14: WORD = 0x0005; +pub const IMAGE_REL_PPC_REL24: WORD = 0x0006; +pub const IMAGE_REL_PPC_REL14: WORD = 0x0007; +pub const IMAGE_REL_PPC_TOCREL16: WORD = 0x0008; +pub const IMAGE_REL_PPC_TOCREL14: WORD = 0x0009; +pub const IMAGE_REL_PPC_ADDR32NB: WORD = 0x000A; +pub const IMAGE_REL_PPC_SECREL: WORD = 0x000B; +pub const IMAGE_REL_PPC_SECTION: WORD = 0x000C; +pub const IMAGE_REL_PPC_IFGLUE: WORD = 0x000D; +pub const IMAGE_REL_PPC_IMGLUE: WORD = 0x000E; +pub const IMAGE_REL_PPC_SECREL16: WORD = 0x000F; +pub const IMAGE_REL_PPC_REFHI: WORD = 0x0010; +pub const IMAGE_REL_PPC_REFLO: WORD = 0x0011; +pub const IMAGE_REL_PPC_PAIR: WORD = 0x0012; +pub const IMAGE_REL_PPC_SECRELLO: WORD = 0x0013; +pub const IMAGE_REL_PPC_SECRELHI: WORD = 0x0014; +pub const IMAGE_REL_PPC_GPREL: WORD = 0x0015; +pub const IMAGE_REL_PPC_TOKEN: WORD = 0x0016; +pub const IMAGE_REL_PPC_TYPEMASK: WORD = 0x00FF; +pub const IMAGE_REL_PPC_NEG: WORD = 0x0100; +pub const IMAGE_REL_PPC_BRTAKEN: WORD = 0x0200; +pub const IMAGE_REL_PPC_BRNTAKEN: WORD = 0x0400; +pub const IMAGE_REL_PPC_TOCDEFN: WORD = 0x0800; +pub const IMAGE_REL_SH3_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_SH3_DIRECT16: WORD = 0x0001; +pub const IMAGE_REL_SH3_DIRECT32: WORD = 0x0002; +pub const IMAGE_REL_SH3_DIRECT8: WORD = 0x0003; +pub const IMAGE_REL_SH3_DIRECT8_WORD: WORD = 0x0004; +pub const IMAGE_REL_SH3_DIRECT8_LONG: WORD = 0x0005; +pub const IMAGE_REL_SH3_DIRECT4: WORD = 0x0006; +pub const IMAGE_REL_SH3_DIRECT4_WORD: WORD = 0x0007; +pub const IMAGE_REL_SH3_DIRECT4_LONG: WORD = 0x0008; +pub const IMAGE_REL_SH3_PCREL8_WORD: WORD = 0x0009; +pub const IMAGE_REL_SH3_PCREL8_LONG: WORD = 0x000A; +pub const IMAGE_REL_SH3_PCREL12_WORD: WORD = 0x000B; +pub const IMAGE_REL_SH3_STARTOF_SECTION: WORD = 0x000C; +pub const IMAGE_REL_SH3_SIZEOF_SECTION: WORD = 0x000D; +pub const IMAGE_REL_SH3_SECTION: WORD = 0x000E; +pub const IMAGE_REL_SH3_SECREL: WORD = 0x000F; +pub const IMAGE_REL_SH3_DIRECT32_NB: WORD = 0x0010; +pub const IMAGE_REL_SH3_GPREL4_LONG: WORD = 0x0011; +pub const IMAGE_REL_SH3_TOKEN: WORD = 0x0012; +pub const IMAGE_REL_SHM_PCRELPT: WORD = 0x0013; +pub const IMAGE_REL_SHM_REFLO: WORD = 0x0014; +pub const IMAGE_REL_SHM_REFHALF: WORD = 0x0015; +pub const IMAGE_REL_SHM_RELLO: WORD = 0x0016; +pub const IMAGE_REL_SHM_RELHALF: WORD = 0x0017; +pub const IMAGE_REL_SHM_PAIR: WORD = 0x0018; +pub const IMAGE_REL_SH_NOMODE: WORD = 0x8000; +pub const IMAGE_REL_ARM_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_ARM_ADDR32: WORD = 0x0001; +pub const IMAGE_REL_ARM_ADDR32NB: WORD = 0x0002; +pub const IMAGE_REL_ARM_BRANCH24: WORD = 0x0003; +pub const IMAGE_REL_ARM_BRANCH11: WORD = 0x0004; +pub const IMAGE_REL_ARM_TOKEN: WORD = 0x0005; +pub const IMAGE_REL_ARM_GPREL12: WORD = 0x0006; +pub const IMAGE_REL_ARM_GPREL7: WORD = 0x0007; +pub const IMAGE_REL_ARM_BLX24: WORD = 0x0008; +pub const IMAGE_REL_ARM_BLX11: WORD = 0x0009; +pub const IMAGE_REL_ARM_SECTION: WORD = 0x000E; +pub const IMAGE_REL_ARM_SECREL: WORD = 0x000F; +pub const IMAGE_REL_ARM_MOV32A: WORD = 0x0010; +pub const IMAGE_REL_ARM_MOV32: WORD = 0x0010; +pub const IMAGE_REL_ARM_MOV32T: WORD = 0x0011; +pub const IMAGE_REL_THUMB_MOV32: WORD = 0x0011; +pub const IMAGE_REL_ARM_BRANCH20T: WORD = 0x0012; +pub const IMAGE_REL_THUMB_BRANCH20: WORD = 0x0012; +pub const IMAGE_REL_ARM_BRANCH24T: WORD = 0x0014; +pub const IMAGE_REL_THUMB_BRANCH24: WORD = 0x0014; +pub const IMAGE_REL_ARM_BLX23T: WORD = 0x0015; +pub const IMAGE_REL_THUMB_BLX23: WORD = 0x0015; +pub const IMAGE_REL_AM_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_AM_ADDR32: WORD = 0x0001; +pub const IMAGE_REL_AM_ADDR32NB: WORD = 0x0002; +pub const IMAGE_REL_AM_CALL32: WORD = 0x0003; +pub const IMAGE_REL_AM_FUNCINFO: WORD = 0x0004; +pub const IMAGE_REL_AM_REL32_1: WORD = 0x0005; +pub const IMAGE_REL_AM_REL32_2: WORD = 0x0006; +pub const IMAGE_REL_AM_SECREL: WORD = 0x0007; +pub const IMAGE_REL_AM_SECTION: WORD = 0x0008; +pub const IMAGE_REL_AM_TOKEN: WORD = 0x0009; +pub const IMAGE_REL_ARM64_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_ARM64_ADDR32: WORD = 0x0001; +pub const IMAGE_REL_ARM64_ADDR32NB: WORD = 0x0002; +pub const IMAGE_REL_ARM64_BRANCH26: WORD = 0x0003; +pub const IMAGE_REL_ARM64_PAGEBASE_REL21: WORD = 0x0004; +pub const IMAGE_REL_ARM64_REL21: WORD = 0x0005; +pub const IMAGE_REL_ARM64_PAGEOFFSET_12A: WORD = 0x0006; +pub const IMAGE_REL_ARM64_PAGEOFFSET_12L: WORD = 0x0007; +pub const IMAGE_REL_ARM64_SECREL: WORD = 0x0008; +pub const IMAGE_REL_ARM64_SECREL_LOW12A: WORD = 0x0009; +pub const IMAGE_REL_ARM64_SECREL_HIGH12A: WORD = 0x000A; +pub const IMAGE_REL_ARM64_SECREL_LOW12L: WORD = 0x000B; +pub const IMAGE_REL_ARM64_TOKEN: WORD = 0x000C; +pub const IMAGE_REL_ARM64_SECTION: WORD = 0x000D; +pub const IMAGE_REL_ARM64_ADDR64: WORD = 0x000E; +pub const IMAGE_REL_ARM64_BRANCH19: WORD = 0x000F; +pub const IMAGE_REL_AMD64_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_AMD64_ADDR64: WORD = 0x0001; +pub const IMAGE_REL_AMD64_ADDR32: WORD = 0x0002; +pub const IMAGE_REL_AMD64_ADDR32NB: WORD = 0x0003; +pub const IMAGE_REL_AMD64_REL32: WORD = 0x0004; +pub const IMAGE_REL_AMD64_REL32_1: WORD = 0x0005; +pub const IMAGE_REL_AMD64_REL32_2: WORD = 0x0006; +pub const IMAGE_REL_AMD64_REL32_3: WORD = 0x0007; +pub const IMAGE_REL_AMD64_REL32_4: WORD = 0x0008; +pub const IMAGE_REL_AMD64_REL32_5: WORD = 0x0009; +pub const IMAGE_REL_AMD64_SECTION: WORD = 0x000A; +pub const IMAGE_REL_AMD64_SECREL: WORD = 0x000B; +pub const IMAGE_REL_AMD64_SECREL7: WORD = 0x000C; +pub const IMAGE_REL_AMD64_TOKEN: WORD = 0x000D; +pub const IMAGE_REL_AMD64_SREL32: WORD = 0x000E; +pub const IMAGE_REL_AMD64_PAIR: WORD = 0x000F; +pub const IMAGE_REL_AMD64_SSPAN32: WORD = 0x0010; +pub const IMAGE_REL_IA64_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_IA64_IMM14: WORD = 0x0001; +pub const IMAGE_REL_IA64_IMM22: WORD = 0x0002; +pub const IMAGE_REL_IA64_IMM64: WORD = 0x0003; +pub const IMAGE_REL_IA64_DIR32: WORD = 0x0004; +pub const IMAGE_REL_IA64_DIR64: WORD = 0x0005; +pub const IMAGE_REL_IA64_PCREL21B: WORD = 0x0006; +pub const IMAGE_REL_IA64_PCREL21M: WORD = 0x0007; +pub const IMAGE_REL_IA64_PCREL21F: WORD = 0x0008; +pub const IMAGE_REL_IA64_GPREL22: WORD = 0x0009; +pub const IMAGE_REL_IA64_LTOFF22: WORD = 0x000A; +pub const IMAGE_REL_IA64_SECTION: WORD = 0x000B; +pub const IMAGE_REL_IA64_SECREL22: WORD = 0x000C; +pub const IMAGE_REL_IA64_SECREL64I: WORD = 0x000D; +pub const IMAGE_REL_IA64_SECREL32: WORD = 0x000E; +pub const IMAGE_REL_IA64_DIR32NB: WORD = 0x0010; +pub const IMAGE_REL_IA64_SREL14: WORD = 0x0011; +pub const IMAGE_REL_IA64_SREL22: WORD = 0x0012; +pub const IMAGE_REL_IA64_SREL32: WORD = 0x0013; +pub const IMAGE_REL_IA64_UREL32: WORD = 0x0014; +pub const IMAGE_REL_IA64_PCREL60X: WORD = 0x0015; +pub const IMAGE_REL_IA64_PCREL60B: WORD = 0x0016; +pub const IMAGE_REL_IA64_PCREL60F: WORD = 0x0017; +pub const IMAGE_REL_IA64_PCREL60I: WORD = 0x0018; +pub const IMAGE_REL_IA64_PCREL60M: WORD = 0x0019; +pub const IMAGE_REL_IA64_IMMGPREL64: WORD = 0x001A; +pub const IMAGE_REL_IA64_TOKEN: WORD = 0x001B; +pub const IMAGE_REL_IA64_GPREL32: WORD = 0x001C; +pub const IMAGE_REL_IA64_ADDEND: WORD = 0x001F; +pub const IMAGE_REL_CEF_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_CEF_ADDR32: WORD = 0x0001; +pub const IMAGE_REL_CEF_ADDR64: WORD = 0x0002; +pub const IMAGE_REL_CEF_ADDR32NB: WORD = 0x0003; +pub const IMAGE_REL_CEF_SECTION: WORD = 0x0004; +pub const IMAGE_REL_CEF_SECREL: WORD = 0x0005; +pub const IMAGE_REL_CEF_TOKEN: WORD = 0x0006; +pub const IMAGE_REL_CEE_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_CEE_ADDR32: WORD = 0x0001; +pub const IMAGE_REL_CEE_ADDR64: WORD = 0x0002; +pub const IMAGE_REL_CEE_ADDR32NB: WORD = 0x0003; +pub const IMAGE_REL_CEE_SECTION: WORD = 0x0004; +pub const IMAGE_REL_CEE_SECREL: WORD = 0x0005; +pub const IMAGE_REL_CEE_TOKEN: WORD = 0x0006; +pub const IMAGE_REL_M32R_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_M32R_ADDR32: WORD = 0x0001; +pub const IMAGE_REL_M32R_ADDR32NB: WORD = 0x0002; +pub const IMAGE_REL_M32R_ADDR24: WORD = 0x0003; +pub const IMAGE_REL_M32R_GPREL16: WORD = 0x0004; +pub const IMAGE_REL_M32R_PCREL24: WORD = 0x0005; +pub const IMAGE_REL_M32R_PCREL16: WORD = 0x0006; +pub const IMAGE_REL_M32R_PCREL8: WORD = 0x0007; +pub const IMAGE_REL_M32R_REFHALF: WORD = 0x0008; +pub const IMAGE_REL_M32R_REFHI: WORD = 0x0009; +pub const IMAGE_REL_M32R_REFLO: WORD = 0x000A; +pub const IMAGE_REL_M32R_PAIR: WORD = 0x000B; +pub const IMAGE_REL_M32R_SECTION: WORD = 0x000C; +pub const IMAGE_REL_M32R_SECREL32: WORD = 0x000D; +pub const IMAGE_REL_M32R_TOKEN: WORD = 0x000E; +pub const IMAGE_REL_EBC_ABSOLUTE: WORD = 0x0000; +pub const IMAGE_REL_EBC_ADDR32NB: WORD = 0x0001; +pub const IMAGE_REL_EBC_REL32: WORD = 0x0002; +pub const IMAGE_REL_EBC_SECTION: WORD = 0x0003; +pub const IMAGE_REL_EBC_SECREL: WORD = 0x0004; +UNION!{union IMAGE_LINENUMBER_Type { + [u32; 1], + SymbolTableIndex SymbolTableIndex_mut: DWORD, + VirtualAddress VirtualAddress_mut: DWORD, +}} +STRUCT!{struct IMAGE_LINENUMBER { + Type: IMAGE_LINENUMBER_Type, + Linenumber: WORD, +}} +pub type PIMAGE_LINENUMBER = *mut IMAGE_LINENUMBER; +STRUCT!{struct IMAGE_BASE_RELOCATION { + VirtualAddress: DWORD, + SizeOfBlock: DWORD, +}} +pub type PIMAGE_BASE_RELOCATION = *mut IMAGE_BASE_RELOCATION; +pub const IMAGE_REL_BASED_ABSOLUTE: WORD = 0; +pub const IMAGE_REL_BASED_HIGH: WORD = 1; +pub const IMAGE_REL_BASED_LOW: WORD = 2; +pub const IMAGE_REL_BASED_HIGHLOW: WORD = 3; +pub const IMAGE_REL_BASED_HIGHADJ: WORD = 4; +pub const IMAGE_REL_BASED_MACHINE_SPECIFIC_5: WORD = 5; +pub const IMAGE_REL_BASED_RESERVED: WORD = 6; +pub const IMAGE_REL_BASED_MACHINE_SPECIFIC_7: WORD = 7; +pub const IMAGE_REL_BASED_MACHINE_SPECIFIC_8: WORD = 8; +pub const IMAGE_REL_BASED_MACHINE_SPECIFIC_9: WORD = 9; +pub const IMAGE_REL_BASED_DIR64: WORD = 10; +pub const IMAGE_REL_BASED_IA64_IMM64: WORD = 9; +pub const IMAGE_REL_BASED_MIPS_JMPADDR: WORD = 5; +pub const IMAGE_REL_BASED_MIPS_JMPADDR16: WORD = 9; +pub const IMAGE_REL_BASED_ARM_MOV32: WORD = 5; +pub const IMAGE_REL_BASED_THUMB_MOV32: WORD = 7; +pub const IMAGE_ARCHIVE_START_SIZE: usize = 8; +pub const IMAGE_ARCHIVE_START: &'static str = "!<arch>\n"; +pub const IMAGE_ARCHIVE_END: &'static str = "`\n"; +pub const IMAGE_ARCHIVE_PAD: &'static str = "\n"; +pub const IMAGE_ARCHIVE_LINKER_MEMBER: &'static str = "/ "; +pub const IMAGE_ARCHIVE_LONGNAMES_MEMBER: &'static str = "// "; +pub const IMAGE_ARCHIVE_HYBRIDMAP_MEMBER: &'static str = "/<HYBRIDMAP>/ "; +STRUCT!{struct IMAGE_ARCHIVE_MEMBER_HEADER { + Name: [BYTE; 16], + Date: [BYTE; 12], + UserID: [BYTE; 6], + GroupID: [BYTE; 6], + Mode: [BYTE; 8], + Size: [BYTE; 10], + EndHeader: [BYTE; 2], +}} +pub type PIMAGE_ARCHIVE_MEMBER_HEADER = *mut IMAGE_ARCHIVE_MEMBER_HEADER; +pub const IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR: usize = 60; +STRUCT!{struct IMAGE_EXPORT_DIRECTORY { + Characteristics: DWORD, + TimeDateStamp: DWORD, + MajorVersion: WORD, + MinorVersion: WORD, + Name: DWORD, + Base: DWORD, + NumberOfFunctions: DWORD, + NumberOfNames: DWORD, + AddressOfFunctions: DWORD, + AddressOfNames: DWORD, + AddressOfNameOrdinals: DWORD, +}} +pub type PIMAGE_EXPORT_DIRECTORY = *mut IMAGE_EXPORT_DIRECTORY; +STRUCT!{struct IMAGE_IMPORT_BY_NAME { + Hint: WORD, + Name: [CHAR; 1], +}} +pub type PIMAGE_IMPORT_BY_NAME = *mut IMAGE_IMPORT_BY_NAME; +UNION!{union IMAGE_THUNK_DATA64_u1 { + [u64; 1], + ForwarderString ForwarderString_mut: ULONGLONG, + Function Function_mut: ULONGLONG, + Ordinal Ordinal_mut: ULONGLONG, + AddressOfData AddressOfData_mut: ULONGLONG, +}} +STRUCT!{struct IMAGE_THUNK_DATA64 { + u1: IMAGE_THUNK_DATA64_u1, +}} +pub type PIMAGE_THUNK_DATA64 = *mut IMAGE_THUNK_DATA64; +UNION!{union IMAGE_THUNK_DATA32_u1 { + [u32; 1], + ForwarderString ForwarderString_mut: DWORD, + Function Function_mut: DWORD, + Ordinal Ordinal_mut: DWORD, + AddressOfData AddressOfData_mut: DWORD, +}} +STRUCT!{struct IMAGE_THUNK_DATA32 { + u1: IMAGE_THUNK_DATA32_u1, +}} +pub type PIMAGE_THUNK_DATA32 = *mut IMAGE_THUNK_DATA32; +pub const IMAGE_ORDINAL_FLAG64: ULONGLONG = 0x8000000000000000; +pub const IMAGE_ORDINAL_FLAG32: DWORD = 0x80000000; +#[inline] +pub fn IMAGE_ORDINAL64(Ordinal: ULONGLONG) -> ULONGLONG { + Ordinal & 0xffff +} +#[inline] +pub fn IMAGE_ORDINAL32(Ordinal: DWORD) -> DWORD { + Ordinal & 0xffff +} +#[inline] +pub fn IMAGE_SNAP_BY_ORDINAL64(Ordinal: ULONGLONG) -> bool { + (Ordinal & IMAGE_ORDINAL_FLAG64) != 0 +} +#[inline] +pub fn IMAGE_SNAP_BY_ORDINAL32(Ordinal: DWORD) -> bool { + (Ordinal & IMAGE_ORDINAL_FLAG32) != 0 +} +FN!{stdcall PIMAGE_TLS_CALLBACK( + DllHandle: PVOID, + Reason: DWORD, + Reserved: PVOID, +) -> ()} +STRUCT!{struct IMAGE_TLS_DIRECTORY64 { + StartAddressOfRawData: ULONGLONG, + EndAddressOfRawData: ULONGLONG, + AddressOfIndex: ULONGLONG, + AddressOfCallBacks: ULONGLONG, + SizeOfZeroFill: DWORD, + Characteristics: DWORD, +}} +BITFIELD!{IMAGE_TLS_DIRECTORY64 Characteristics: DWORD [ + Reserved0 set_Reserved0[0..20], + Alignment set_Alignment[20..24], + Reserved1 set_Reserved1[24..32], +]} +pub type PIMAGE_TLS_DIRECTORY64 = *mut IMAGE_TLS_DIRECTORY64; +STRUCT!{struct IMAGE_TLS_DIRECTORY32 { + StartAddressOfRawData: DWORD, + EndAddressOfRawData: DWORD, + AddressOfIndex: DWORD, + AddressOfCallBacks: DWORD, + SizeOfZeroFill: DWORD, + Characteristics: DWORD, +}} +BITFIELD!{IMAGE_TLS_DIRECTORY32 Characteristics: DWORD [ + Reserved0 set_Reserved0[0..20], + Alignment set_Alignment[20..24], + Reserved1 set_Reserved1[24..32], +]} +pub type PIMAGE_TLS_DIRECTORY32 = *mut IMAGE_TLS_DIRECTORY32; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +pub const IMAGE_ORDINAL_FLAG: ULONGLONG = IMAGE_ORDINAL_FLAG64; +#[inline] +pub fn IMAGE_ORDINAL(Ordinal: ULONGLONG) -> ULONGLONG { + IMAGE_ORDINAL64(Ordinal) +} +pub type IMAGE_THUNK_DATA = IMAGE_THUNK_DATA64; +pub type PIMAGE_THUNK_DATA = PIMAGE_THUNK_DATA64; +#[inline] +pub fn IMAGE_SNAP_BY_ORDINAL(Ordinal: ULONGLONG) -> bool { + IMAGE_SNAP_BY_ORDINAL64(Ordinal) +} +pub type IMAGE_TLS_DIRECTORY = IMAGE_TLS_DIRECTORY64; +pub type PIMAGE_TLS_DIRECTORY = PIMAGE_TLS_DIRECTORY64; +} +#[cfg(target_pointer_width = "32")] +IFDEF!{ +pub const IMAGE_ORDINAL_FLAG: DWORD = IMAGE_ORDINAL_FLAG32; +#[inline] +pub fn IMAGE_ORDINAL(Ordinal: DWORD) -> DWORD { + IMAGE_ORDINAL32(Ordinal) +} +pub type IMAGE_THUNK_DATA = IMAGE_THUNK_DATA32; +pub type PIMAGE_THUNK_DATA = PIMAGE_THUNK_DATA32; +#[inline] +pub fn IMAGE_SNAP_BY_ORDINAL(Ordinal: DWORD) -> bool { + IMAGE_SNAP_BY_ORDINAL32(Ordinal) +} +pub type IMAGE_TLS_DIRECTORY = IMAGE_TLS_DIRECTORY32; +pub type PIMAGE_TLS_DIRECTORY = PIMAGE_TLS_DIRECTORY32; +} +UNION!{union IMAGE_IMPORT_DESCRIPTOR_u { + [u32; 1], + Characteristics Characteristics_mut: DWORD, + OriginalFirstThunk OriginalFirstThunk_mut: DWORD, +}} +STRUCT!{struct IMAGE_IMPORT_DESCRIPTOR { + u: IMAGE_IMPORT_DESCRIPTOR_u, + TimeDateStamp: DWORD, + ForwarderChain: DWORD, + Name: DWORD, + FirstThunk: DWORD, +}} +pub type PIMAGE_IMPORT_DESCRIPTOR = *mut IMAGE_IMPORT_DESCRIPTOR; +STRUCT!{struct IMAGE_BOUND_IMPORT_DESCRIPTOR { + TimeDateStamp: DWORD, + OffsetModuleName: WORD, + NumberOfModuleForwarderRefs: WORD, +}} +pub type PIMAGE_BOUND_IMPORT_DESCRIPTOR = *mut IMAGE_BOUND_IMPORT_DESCRIPTOR; +STRUCT!{struct IMAGE_BOUND_FORWARDER_REF { + TimeDateStamp: DWORD, + OffsetModuleName: WORD, + Reserved: WORD, +}} +pub type PIMAGE_BOUND_FORWARDER_REF = *mut IMAGE_BOUND_FORWARDER_REF; +STRUCT!{struct IMAGE_DELAYLOAD_DESCRIPTOR_Attributes { + AllAttributes: DWORD, +}} +BITFIELD!{IMAGE_DELAYLOAD_DESCRIPTOR_Attributes AllAttributes: DWORD [ + RvaBased set_RvaBased[0..1], + ReservedAttributes set_ReservedAttributes[1..32], +]} +STRUCT!{struct IMAGE_DELAYLOAD_DESCRIPTOR { + Attributes: IMAGE_DELAYLOAD_DESCRIPTOR_Attributes, + DllNameRVA: DWORD, + ModuleHandleRVA: DWORD, + ImportAddressTableRVA: DWORD, + ImportNameTableRVA: DWORD, + BoundImportAddressTableRVA: DWORD, + UnloadInformationTableRVA: DWORD, + TimeDateStamp: DWORD, +}} +pub type PIMAGE_DELAYLOAD_DESCRIPTOR = *mut IMAGE_DELAYLOAD_DESCRIPTOR; +pub type PCIMAGE_DELAYLOAD_DESCRIPTOR = *const IMAGE_DELAYLOAD_DESCRIPTOR; +STRUCT!{struct IMAGE_RESOURCE_DIRECTORY { + Characteristics: DWORD, + TimeDateStamp: DWORD, + MajorVersion: WORD, + MinorVersion: WORD, + NumberOfNamedEntries: WORD, + NumberOfIdEntries: WORD, +}} +pub type PIMAGE_RESOURCE_DIRECTORY = *mut IMAGE_RESOURCE_DIRECTORY; +pub const IMAGE_RESOURCE_NAME_IS_STRING: DWORD = 0x80000000; +pub const IMAGE_RESOURCE_DATA_IS_DIRECTORY: DWORD = 0x80000000; +STRUCT!{struct IMAGE_RESOURCE_DIRECTORY_ENTRY_u_s { + BitFields: DWORD, +}} +BITFIELD!{IMAGE_RESOURCE_DIRECTORY_ENTRY_u_s BitFields: DWORD [ + NameOffset set_NameOffset[0..31], + NameIsString set_NameIsString[31..32], +]} +UNION!{union IMAGE_RESOURCE_DIRECTORY_ENTRY_u { + [u32; 1], + s s_mut: IMAGE_RESOURCE_DIRECTORY_ENTRY_u_s, + Name Name_mut: DWORD, + Id Id_mut: WORD, +}} +STRUCT!{struct IMAGE_RESOURCE_DIRECTORY_ENTRY { + u: IMAGE_RESOURCE_DIRECTORY_ENTRY_u, + OffsetToData: DWORD, +}} +BITFIELD!{IMAGE_RESOURCE_DIRECTORY_ENTRY OffsetToData: DWORD [ + OffsetToDirectory set_OffsetToDirectory[0..31], + DataIsDirectory set_DataIsDirectory[31..32], +]} +pub type PIMAGE_RESOURCE_DIRECTORY_ENTRY = *mut IMAGE_RESOURCE_DIRECTORY_ENTRY; +STRUCT!{struct IMAGE_RESOURCE_DIRECTORY_STRING { + Length: WORD, + NameString: [CHAR; 1], +}} +pub type PIMAGE_RESOURCE_DIRECTORY_STRING = *mut IMAGE_RESOURCE_DIRECTORY_STRING; +STRUCT!{struct IMAGE_RESOURCE_DIR_STRING_U { + Length: WORD, + NameString: [WCHAR; 1], +}} +pub type PIMAGE_RESOURCE_DIR_STRING_U = *mut IMAGE_RESOURCE_DIR_STRING_U; +STRUCT!{struct IMAGE_RESOURCE_DATA_ENTRY { + OffsetToData: DWORD, + Size: DWORD, + CodePage: DWORD, + Reserved: DWORD, +}} +pub type PIMAGE_RESOURCE_DATA_ENTRY = *mut IMAGE_RESOURCE_DATA_ENTRY; +STRUCT!{struct IMAGE_LOAD_CONFIG_CODE_INTEGRITY { + Flags: WORD, + Catalog: WORD, + CatalogOffset: DWORD, + Reserved: DWORD, +}} +pub type PIMAGE_LOAD_CONFIG_CODE_INTEGRITY = *mut IMAGE_LOAD_CONFIG_CODE_INTEGRITY; +STRUCT!{struct IMAGE_DYNAMIC_RELOCATION_TABLE { + Version: DWORD, + Size: DWORD, +}} +pub type PIMAGE_DYNAMIC_RELOCATION_TABLE = *mut IMAGE_DYNAMIC_RELOCATION_TABLE; +STRUCT!{#[repr(packed)] struct IMAGE_DYNAMIC_RELOCATION32 { + Symbol: DWORD, + BaseRelocSize: DWORD, +}} +pub type PIMAGE_DYNAMIC_RELOCATION32 = *mut IMAGE_DYNAMIC_RELOCATION32; +STRUCT!{#[repr(packed)] struct IMAGE_DYNAMIC_RELOCATION64 { + Symbol: ULONGLONG, + BaseRelocSize: DWORD, +}} +pub type PIMAGE_DYNAMIC_RELOCATION64 = *mut IMAGE_DYNAMIC_RELOCATION64; +STRUCT!{#[repr(packed)] struct IMAGE_DYNAMIC_RELOCATION32_V2 { + HeaderSize: DWORD, + FixupInfoSize: DWORD, + Symbol: DWORD, + SymbolGroup: DWORD, + Flags: DWORD, +}} +pub type PIMAGE_DYNAMIC_RELOCATION32_V2 = *mut IMAGE_DYNAMIC_RELOCATION32_V2; +STRUCT!{#[repr(packed)] struct IMAGE_DYNAMIC_RELOCATION64_V2 { + HeaderSize: DWORD, + FixupInfoSize: DWORD, + Symbol: ULONGLONG, + SymbolGroup: DWORD, + Flags: DWORD, +}} +pub type PIMAGE_DYNAMIC_RELOCATION64_V2 = *mut IMAGE_DYNAMIC_RELOCATION64_V2; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +pub type IMAGE_DYNAMIC_RELOCATION = IMAGE_DYNAMIC_RELOCATION64; +pub type PIMAGE_DYNAMIC_RELOCATION = PIMAGE_DYNAMIC_RELOCATION64; +pub type IMAGE_DYNAMIC_RELOCATION_V2 = IMAGE_DYNAMIC_RELOCATION64_V2; +pub type PIMAGE_DYNAMIC_RELOCATION_V2 = PIMAGE_DYNAMIC_RELOCATION64_V2; +} +#[cfg(target_pointer_width = "32")] +IFDEF!{ +pub type IMAGE_DYNAMIC_RELOCATION = IMAGE_DYNAMIC_RELOCATION32; +pub type PIMAGE_DYNAMIC_RELOCATION = PIMAGE_DYNAMIC_RELOCATION32; +pub type IMAGE_DYNAMIC_RELOCATION_V2 = IMAGE_DYNAMIC_RELOCATION32_V2; +pub type PIMAGE_DYNAMIC_RELOCATION_V2 = PIMAGE_DYNAMIC_RELOCATION32_V2; +} +pub const IMAGE_DYNAMIC_RELOCATION_GUARD_RF_PROLOGUE: DWORD = 0x00000001; +pub const IMAGE_DYNAMIC_RELOCATION_GUARD_RF_EPILOGUE: DWORD = 0x00000002; +STRUCT!{#[repr(packed)] struct IMAGE_PROLOGUE_DYNAMIC_RELOCATION_HEADER { + PrologueByteCount: BYTE, +}} +pub type PIMAGE_PROLOGUE_DYNAMIC_RELOCATION_HEADER = *mut IMAGE_PROLOGUE_DYNAMIC_RELOCATION_HEADER; +STRUCT!{#[repr(packed)] struct IMAGE_EPILOGUE_DYNAMIC_RELOCATION_HEADER { + EpilogueCount: DWORD, + EpilogueByteCount: BYTE, + BranchDescriptorElementSize: BYTE, + BranchDescriptorCount: WORD, +}} +pub type PIMAGE_EPILOGUE_DYNAMIC_RELOCATION_HEADER = *mut IMAGE_EPILOGUE_DYNAMIC_RELOCATION_HEADER; +STRUCT!{struct IMAGE_LOAD_CONFIG_DIRECTORY32 { + Size: DWORD, + TimeDateStamp: DWORD, + MajorVersion: WORD, + MinorVersion: WORD, + GlobalFlagsClear: DWORD, + GlobalFlagsSet: DWORD, + CriticalSectionDefaultTimeout: DWORD, + DeCommitFreeBlockThreshold: DWORD, + DeCommitTotalFreeThreshold: DWORD, + LockPrefixTable: DWORD, + MaximumAllocationSize: DWORD, + VirtualMemoryThreshold: DWORD, + ProcessHeapFlags: DWORD, + ProcessAffinityMask: DWORD, + CSDVersion: WORD, + DependentLoadFlags: WORD, + EditList: DWORD, + SecurityCookie: DWORD, + SEHandlerTable: DWORD, + SEHandlerCount: DWORD, + GuardCFCheckFunctionPointer: DWORD, + GuardCFDispatchFunctionPointer: DWORD, + GuardCFFunctionTable: DWORD, + GuardCFFunctionCount: DWORD, + GuardFlags: DWORD, + CodeIntegrity: IMAGE_LOAD_CONFIG_CODE_INTEGRITY, + GuardAddressTakenIatEntryTable: DWORD, + GuardAddressTakenIatEntryCount: DWORD, + GuardLongJumpTargetTable: DWORD, + GuardLongJumpTargetCount: DWORD, + DynamicValueRelocTable: DWORD, + CHPEMetadataPointer: DWORD, + GuardRFFailureRoutine: DWORD, + GuardRFFailureRoutineFunctionPointer: DWORD, + DynamicValueRelocTableOffset: DWORD, + DynamicValueRelocTableSection: WORD, + Reserved2: WORD, + GuardRFVerifyStackPointerFunctionPointer: DWORD, + HotPatchTableOffset: DWORD, + Reserved3: DWORD, + EnclaveConfigurationPointer: DWORD, +}} +pub type PIMAGE_LOAD_CONFIG_DIRECTORY32 = *mut IMAGE_LOAD_CONFIG_DIRECTORY32; +STRUCT!{struct IMAGE_LOAD_CONFIG_DIRECTORY64 { + Size: DWORD, + TimeDateStamp: DWORD, + MajorVersion: WORD, + MinorVersion: WORD, + GlobalFlagsClear: DWORD, + GlobalFlagsSet: DWORD, + CriticalSectionDefaultTimeout: DWORD, + DeCommitFreeBlockThreshold: ULONGLONG, + DeCommitTotalFreeThreshold: ULONGLONG, + LockPrefixTable: ULONGLONG, + MaximumAllocationSize: ULONGLONG, + VirtualMemoryThreshold: ULONGLONG, + ProcessAffinityMask: ULONGLONG, + ProcessHeapFlags: DWORD, + CSDVersion: WORD, + DependentLoadFlags: WORD, + EditList: ULONGLONG, + SecurityCookie: ULONGLONG, + SEHandlerTable: ULONGLONG, + SEHandlerCount: ULONGLONG, + GuardCFCheckFunctionPointer: ULONGLONG, + GuardCFDispatchFunctionPointer: ULONGLONG, + GuardCFFunctionTable: ULONGLONG, + GuardCFFunctionCount: ULONGLONG, + GuardFlags: DWORD, + CodeIntegrity: IMAGE_LOAD_CONFIG_CODE_INTEGRITY, + GuardAddressTakenIatEntryTable: ULONGLONG, + GuardAddressTakenIatEntryCount: ULONGLONG, + GuardLongJumpTargetTable: ULONGLONG, + GuardLongJumpTargetCount: ULONGLONG, + DynamicValueRelocTable: ULONGLONG, + CHPEMetadataPointer: ULONGLONG, + GuardRFFailureRoutine: ULONGLONG, + GuardRFFailureRoutineFunctionPointer: ULONGLONG, + DynamicValueRelocTableOffset: DWORD, + DynamicValueRelocTableSection: WORD, + Reserved2: WORD, + GuardRFVerifyStackPointerFunctionPointer: ULONGLONG, + HotPatchTableOffset: DWORD, + Reserved3: DWORD, + EnclaveConfigurationPointer: ULONGLONG, +}} +pub type PIMAGE_LOAD_CONFIG_DIRECTORY64 = *mut IMAGE_LOAD_CONFIG_DIRECTORY64; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +pub type IMAGE_LOAD_CONFIG_DIRECTORY = IMAGE_LOAD_CONFIG_DIRECTORY64; +pub type PIMAGE_LOAD_CONFIG_DIRECTORY = PIMAGE_LOAD_CONFIG_DIRECTORY64; +} +#[cfg(target_pointer_width = "32")] +IFDEF!{ +pub type IMAGE_LOAD_CONFIG_DIRECTORY = IMAGE_LOAD_CONFIG_DIRECTORY32; +pub type PIMAGE_LOAD_CONFIG_DIRECTORY = PIMAGE_LOAD_CONFIG_DIRECTORY32; +} +STRUCT!{struct IMAGE_HOT_PATCH_INFO { + Version: DWORD, + Size: DWORD, + SequenceNumber: DWORD, + BaseImageList: DWORD, + BaseImageCount: DWORD, + BufferOffset: DWORD, +}} +pub type PIMAGE_HOT_PATCH_INFO = *mut IMAGE_HOT_PATCH_INFO; +STRUCT!{struct IMAGE_HOT_PATCH_BASE { + SequenceNumber: DWORD, + Flags: DWORD, + OriginalTimeDateStamp: DWORD, + OriginalCheckSum: DWORD, + CodeIntegrityInfo: DWORD, + CodeIntegritySize: DWORD, + PatchTable: DWORD, + BufferOffset: DWORD, +}} +pub type PIMAGE_HOT_PATCH_BASE = *mut IMAGE_HOT_PATCH_BASE; +STRUCT!{struct IMAGE_HOT_PATCH_HASHES { + SHA256: [BYTE; 32], + SHA1: [BYTE; 20], +}} +pub type PIMAGE_HOT_PATCH_HASHES = *mut IMAGE_HOT_PATCH_HASHES; +pub const IMAGE_HOT_PATCH_BASE_OBLIGATORY: DWORD = 0x00000001; +pub const IMAGE_HOT_PATCH_CHUNK_INVERSE: DWORD = 0x80000000; +pub const IMAGE_HOT_PATCH_CHUNK_OBLIGATORY: DWORD = 0x40000000; +pub const IMAGE_HOT_PATCH_CHUNK_RESERVED: DWORD = 0x3FF03000; +pub const IMAGE_HOT_PATCH_CHUNK_TYPE: DWORD = 0x000FC000; +pub const IMAGE_HOT_PATCH_CHUNK_SOURCE_RVA: DWORD = 0x00008000; +pub const IMAGE_HOT_PATCH_CHUNK_TARGET_RVA: DWORD = 0x00004000; +pub const IMAGE_HOT_PATCH_CHUNK_SIZE: DWORD = 0x00000FFF; +pub const IMAGE_HOT_PATCH_NONE: DWORD = 0x00000000; +pub const IMAGE_HOT_PATCH_FUNCTION: DWORD = 0x0001C000; +pub const IMAGE_HOT_PATCH_ABSOLUTE: DWORD = 0x0002C000; +pub const IMAGE_HOT_PATCH_REL32: DWORD = 0x0003C000; +pub const IMAGE_HOT_PATCH_CALL_TARGET: DWORD = 0x00044000; +pub const IMAGE_HOT_PATCH_INDIRECT: DWORD = 0x0005C000; +pub const IMAGE_HOT_PATCH_NO_CALL_TARGET: DWORD = 0x00064000; +pub const IMAGE_HOT_PATCH_DYNAMIC_VALUE: DWORD = 0x00078000; +pub const IMAGE_GUARD_CF_INSTRUMENTED: DWORD = 0x00000100; +pub const IMAGE_GUARD_CFW_INSTRUMENTED: DWORD = 0x00000200; +pub const IMAGE_GUARD_CF_FUNCTION_TABLE_PRESENT: DWORD = 0x00000400; +pub const IMAGE_GUARD_SECURITY_COOKIE_UNUSED: DWORD = 0x00000800; +pub const IMAGE_GUARD_PROTECT_DELAYLOAD_IAT: DWORD = 0x00001000; +pub const IMAGE_GUARD_DELAYLOAD_IAT_IN_ITS_OWN_SECTION: DWORD = 0x00002000; +pub const IMAGE_GUARD_CF_EXPORT_SUPPRESSION_INFO_PRESENT: DWORD = 0x00004000; +pub const IMAGE_GUARD_CF_ENABLE_EXPORT_SUPPRESSION: DWORD = 0x00008000; +pub const IMAGE_GUARD_CF_LONGJUMP_TABLE_PRESENT: DWORD = 0x00010000; +pub const IMAGE_GUARD_RF_INSTRUMENTED: DWORD = 0x00020000; +pub const IMAGE_GUARD_RF_ENABLE: DWORD = 0x00040000; +pub const IMAGE_GUARD_RF_STRICT: DWORD = 0x00080000; +pub const IMAGE_GUARD_CF_FUNCTION_TABLE_SIZE_MASK: DWORD = 0xF0000000; +pub const IMAGE_GUARD_CF_FUNCTION_TABLE_SIZE_SHIFT: usize = 28; +pub const IMAGE_GUARD_FLAG_FID_SUPPRESSED: DWORD = 0x01; +pub const IMAGE_GUARD_FLAG_EXPORT_SUPPRESSED: DWORD = 0x02; +STRUCT!{struct IMAGE_CE_RUNTIME_FUNCTION_ENTRY { + FuncStart: DWORD, + BitFields: DWORD, +}} +BITFIELD!{IMAGE_CE_RUNTIME_FUNCTION_ENTRY BitFields: DWORD [ + PrologLen set_PrologLen[0..8], + FuncLen set_FuncLen[8..30], + ThirtyTwoBit set_ThirtyTwoBit[30..31], + ExceptionFlag set_ExceptionFlag[31..32], +]} +pub type PIMAGE_CE_RUNTIME_FUNCTION_ENTRY = *mut IMAGE_CE_RUNTIME_FUNCTION_ENTRY; +STRUCT!{struct IMAGE_ARM_RUNTIME_FUNCTION_ENTRY { + BeginAddress: DWORD, + UnwindData: DWORD, +}} +BITFIELD!{IMAGE_ARM_RUNTIME_FUNCTION_ENTRY UnwindData: DWORD [ + Flag set_Flag[0..2], + FunctionLength set_FunctionLength[2..13], + Ret set_Ret[13..15], + H set_H[15..16], + Reg set_Reg[16..19], + R set_R[19..20], + L set_L[20..21], + C set_c[21..22], + StackAdjust set_StackAdjust[22..32], +]} +pub type PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY = *mut IMAGE_ARM_RUNTIME_FUNCTION_ENTRY; +STRUCT!{struct IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY { + BeginAddress: DWORD, + UnwindData: DWORD, +}} +BITFIELD!{IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY UnwindData: DWORD [ + Flag set_Flag[0..2], + FunctionLength set_FunctionLength[2..13], + RegF set_RegF[13..16], + RegI set_RegI[16..20], + H set_H[20..21], + CR set_cR[21..23], + FrameSize set_FrameSize[23..32], +]} +pub type PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY = *mut IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY; +STRUCT!{struct IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY { + BeginAddress: ULONGLONG, + EndAddress: ULONGLONG, + ExceptionHandler: ULONGLONG, + HandlerData: ULONGLONG, + PrologEndAddress: ULONGLONG, +}} +pub type PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY = *mut IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY; +STRUCT!{struct IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY { + BeginAddress: DWORD, + EndAddress: DWORD, + ExceptionHandler: DWORD, + HandlerData: DWORD, + PrologEndAddress: DWORD, +}} +pub type PIMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY = *mut IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY; +UNION!{union IMAGE_RUNTIME_FUNCTION_ENTRY_u { + [u32; 1], + UnwindInfoAddress UnwindInfoAddress_mut: DWORD, + UnwindData UnwindData_mut: DWORD, +}} +STRUCT!{struct _IMAGE_RUNTIME_FUNCTION_ENTRY { + BeginAddress: DWORD, + EndAddress: DWORD, + u: IMAGE_RUNTIME_FUNCTION_ENTRY_u, +}} +type _PIMAGE_RUNTIME_FUNCTION_ENTRY = *mut _IMAGE_RUNTIME_FUNCTION_ENTRY; +pub type IMAGE_IA64_RUNTIME_FUNCTION_ENTRY = _IMAGE_RUNTIME_FUNCTION_ENTRY; +pub type PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY = _PIMAGE_RUNTIME_FUNCTION_ENTRY; +#[cfg(target_arch = "aarch64")] +IFDEF!{ +pub type IMAGE_RUNTIME_FUNCTION_ENTRY = IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY; +pub type PIMAGE_RUNTIME_FUNCTION_ENTRY = PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY; +} +#[cfg(not(target_arch = "aarch64"))] +IFDEF!{ +pub type IMAGE_RUNTIME_FUNCTION_ENTRY = _IMAGE_RUNTIME_FUNCTION_ENTRY; +pub type PIMAGE_RUNTIME_FUNCTION_ENTRY = _PIMAGE_RUNTIME_FUNCTION_ENTRY; +} +STRUCT!{struct IMAGE_DEBUG_DIRECTORY { + Characteristics: DWORD, + TimeDateStamp: DWORD, + MajorVersion: WORD, + MinorVersion: WORD, + Type: DWORD, + SizeOfData: DWORD, + AddressOfRawData: DWORD, + PointerToRawData: DWORD, +}} +pub type PIMAGE_DEBUG_DIRECTORY = *mut IMAGE_DEBUG_DIRECTORY; +pub const IMAGE_DEBUG_TYPE_UNKNOWN: DWORD = 0; +pub const IMAGE_DEBUG_TYPE_COFF: DWORD = 1; +pub const IMAGE_DEBUG_TYPE_CODEVIEW: DWORD = 2; +pub const IMAGE_DEBUG_TYPE_FPO: DWORD = 3; +pub const IMAGE_DEBUG_TYPE_MISC: DWORD = 4; +pub const IMAGE_DEBUG_TYPE_EXCEPTION: DWORD = 5; +pub const IMAGE_DEBUG_TYPE_FIXUP: DWORD = 6; +pub const IMAGE_DEBUG_TYPE_OMAP_TO_SRC: DWORD = 7; +pub const IMAGE_DEBUG_TYPE_OMAP_FROM_SRC: DWORD = 8; +pub const IMAGE_DEBUG_TYPE_BORLAND: DWORD = 9; +pub const IMAGE_DEBUG_TYPE_RESERVED10: DWORD = 10; +pub const IMAGE_DEBUG_TYPE_CLSID: DWORD = 11; +pub const IMAGE_DEBUG_TYPE_VC_FEATURE: DWORD = 12; +pub const IMAGE_DEBUG_TYPE_POGO: DWORD = 13; +pub const IMAGE_DEBUG_TYPE_ILTCG: DWORD = 14; +pub const IMAGE_DEBUG_TYPE_MPX: DWORD = 15; +pub const IMAGE_DEBUG_TYPE_REPRO: DWORD = 16; +STRUCT!{struct IMAGE_COFF_SYMBOLS_HEADER { + NumberOfSymbols: DWORD, + LvaToFirstSymbol: DWORD, + NumberOfLinenumbers: DWORD, + LvaToFirstLinenumber: DWORD, + RvaToFirstByteOfCode: DWORD, + RvaToLastByteOfCode: DWORD, + RvaToFirstByteOfData: DWORD, + RvaToLastByteOfData: DWORD, +}} +pub type PIMAGE_COFF_SYMBOLS_HEADER = *mut IMAGE_COFF_SYMBOLS_HEADER; +pub const FRAME_FPO: WORD = 0; +pub const FRAME_TRAP: WORD = 1; +pub const FRAME_TSS: WORD = 2; +pub const FRAME_NONFPO: WORD = 3; +STRUCT!{struct FPO_DATA { + ulOffStart: DWORD, + cbProcSize: DWORD, + cdwLocals: DWORD, + cdwParams: WORD, + BitFields: WORD, +}} +BITFIELD!{FPO_DATA BitFields: WORD [ + cbProlog set_cbProlog[0..8], + cbRegs set_cbRegs[8..11], + fHasSEH set_fHasSEH[11..12], + fUseBP set_fUseBP[12..13], + reserved set_reserved[13..14], + cbFrame set_cbFrame[14..16], +]} +pub type PFPO_DATA = *mut FPO_DATA; +pub const SIZEOF_RFPO_DATA: usize = 16; +pub const IMAGE_DEBUG_MISC_EXENAME: DWORD = 1; +STRUCT!{struct IMAGE_DEBUG_MISC { + DataType: DWORD, + Length: DWORD, + Unicode: BOOLEAN, + Reserved: [BYTE; 3], + Data: [BYTE; 1], +}} +pub type PIMAGE_DEBUG_MISC = *mut IMAGE_DEBUG_MISC; +STRUCT!{struct IMAGE_FUNCTION_ENTRY { + StartingAddress: DWORD, + EndingAddress: DWORD, + EndOfPrologue: DWORD, +}} +pub type PIMAGE_FUNCTION_ENTRY = *mut IMAGE_FUNCTION_ENTRY; +UNION!{union IMAGE_FUNCTION_ENTRY64_u { + [u64; 1], + EndOfPrologue EndOfPrologue_mut: ULONGLONG, + UnwindInfoAddress UnwindInfoAddress_mut: ULONGLONG, +}} +STRUCT!{struct IMAGE_FUNCTION_ENTRY64 { + StartingAddress: ULONGLONG, + EndingAddress: ULONGLONG, + u: IMAGE_FUNCTION_ENTRY64_u, +}} +pub type PIMAGE_FUNCTION_ENTRY64 = *mut IMAGE_FUNCTION_ENTRY64; +STRUCT!{struct IMAGE_SEPARATE_DEBUG_HEADER { + Signature: WORD, + Flags: WORD, + Machine: WORD, + Characteristics: WORD, + TimeDateStamp: DWORD, + CheckSum: DWORD, + ImageBase: DWORD, + SizeOfImage: DWORD, + NumberOfSections: DWORD, + ExportedNamesSize: DWORD, + DebugDirectorySize: DWORD, + SectionAlignment: DWORD, + Reserved: [DWORD; 2], +}} +pub type PIMAGE_SEPARATE_DEBUG_HEADER = *mut IMAGE_SEPARATE_DEBUG_HEADER; +STRUCT!{struct NON_PAGED_DEBUG_INFO { + Signature: WORD, + Flags: WORD, + Size: DWORD, + Machine: WORD, + Characteristics: WORD, + TimeDateStamp: DWORD, + CheckSum: DWORD, + SizeOfImage: DWORD, + ImageBase: ULONGLONG, +}} +pub type PNON_PAGED_DEBUG_INFO = *mut NON_PAGED_DEBUG_INFO; +pub const IMAGE_SEPARATE_DEBUG_SIGNATURE: WORD = 0x4944; +pub const NON_PAGED_DEBUG_SIGNATURE: WORD = 0x494E; +pub const IMAGE_SEPARATE_DEBUG_FLAGS_MASK: WORD = 0x8000; +pub const IMAGE_SEPARATE_DEBUG_MISMATCH: WORD = 0x8000; +STRUCT!{struct IMAGE_ARCHITECTURE_HEADER { + BitFields: c_uint, + FirstEntryRVA: DWORD, +}} +BITFIELD!{IMAGE_ARCHITECTURE_HEADER BitFields: c_uint [ + AmaskValue set_AmaskValue[0..1], + unused1 set_unused1[1..8], + AmaskShift set_AmaskShift[8..16], + unused2 set_unused2[8..32], +]} +pub type PIMAGE_ARCHITECTURE_HEADER = *mut IMAGE_ARCHITECTURE_HEADER; +STRUCT!{struct IMAGE_ARCHITECTURE_ENTRY { + FixupInstRVA: DWORD, + NewInst: DWORD, +}} +pub type PIMAGE_ARCHITECTURE_ENTRY = *mut IMAGE_ARCHITECTURE_ENTRY; +pub const IMPORT_OBJECT_HDR_SIG2: WORD = 0xffff; +UNION!{union IMPORT_OBJECT_HEADER_u { + [u16; 1], + Ordinal Ordinal_mut: WORD, + Hint Hint_mut: WORD, +}} +STRUCT!{struct IMPORT_OBJECT_HEADER { + Sig1: WORD, + Sig2: WORD, + Version: WORD, + Machine: WORD, + TimeDateStamp: DWORD, + SizeOfData: DWORD, + u: IMPORT_OBJECT_HEADER_u, + BitFields: WORD, +}} +BITFIELD!{IMPORT_OBJECT_HEADER BitFields: WORD [ + Type set_Type[0..2], + NameType set_NameType[2..5], + Reserved set_Reserved[5..16], +]} +ENUM!{enum IMPORT_OBJECT_TYPE { + IMPORT_OBJECT_CODE = 0, + IMPORT_OBJECT_DATA = 1, + IMPORT_OBJECT_CONST = 2, +}} +ENUM!{enum IMPORT_OBJECT_NAME_TYPE { + IMPORT_OBJECT_ORDINAL = 0, + IMPORT_OBJECT_NAME = 1, + IMPORT_OBJECT_NAME_NO_PREFIX = 2, + IMPORT_OBJECT_NAME_UNDECORATE = 3, + IMPORT_OBJECT_NAME_EXPORTAS = 4, +}} +ENUM!{enum ReplacesCorHdrNumericDefines { + COMIMAGE_FLAGS_ILONLY = 0x00000001, + COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002, + COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004, + COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008, + COMIMAGE_FLAGS_NATIVE_ENTRYPOINT = 0x00000010, + COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000, + COMIMAGE_FLAGS_32BITPREFERRED = 0x00020000, + COR_VERSION_MAJOR_V2 = 2, + COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2, + COR_VERSION_MINOR = 5, + COR_DELETED_NAME_LENGTH = 8, + COR_VTABLEGAP_NAME_LENGTH = 8, + NATIVE_TYPE_MAX_CB = 1, + COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE= 0xFF, + IMAGE_COR_MIH_METHODRVA = 0x01, + IMAGE_COR_MIH_EHRVA = 0x02, + IMAGE_COR_MIH_BASICBLOCK = 0x08, + COR_VTABLE_32BIT = 0x01, + COR_VTABLE_64BIT = 0x02, + COR_VTABLE_FROM_UNMANAGED = 0x04, + COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN = 0x08, + COR_VTABLE_CALL_MOST_DERIVED = 0x10, + IMAGE_COR_EATJ_THUNK_SIZE = 32, + MAX_CLASS_NAME = 1024, + MAX_PACKAGE_NAME = 1024, +}} +UNION!{union IMAGE_COR20_HEADER_u { + [u32; 1], + EntryPointToken EntryPointToken_mut: DWORD, + EntryPointRVA EntryPointRVA_mut: DWORD, +}} +STRUCT!{struct IMAGE_COR20_HEADER { + cb: DWORD, + MajorRuntimeVersion: WORD, + MinorRuntimeVersion: WORD, + MetaData: IMAGE_DATA_DIRECTORY, + Flags: DWORD, + u: IMAGE_COR20_HEADER_u, + Resources: IMAGE_DATA_DIRECTORY, + StrongNameSignature: IMAGE_DATA_DIRECTORY, + CodeManagerTable: IMAGE_DATA_DIRECTORY, + VTableFixups: IMAGE_DATA_DIRECTORY, + ExportAddressTableJumps: IMAGE_DATA_DIRECTORY, + ManagedNativeHeader: IMAGE_DATA_DIRECTORY, +}} +pub type PIMAGE_COR20_HEADER = *mut IMAGE_COR20_HEADER; +extern "system" { + pub fn RtlCaptureStackBackTrace( + FramesToSkip: DWORD, + FramesToCapture: DWORD, + BackTrace: *mut PVOID, + BackTraceHash: PDWORD, + ) -> WORD; + pub fn RtlCaptureContext( + ContextRecord: PCONTEXT, + ); + pub fn RtlUnwind( + TargetFrame: PVOID, + TargetIp: PVOID, + ExceptionRecord: PEXCEPTION_RECORD, + ReturnValue: PVOID, + ); +} +#[cfg(target_pointer_width = "64")] +extern "system" { + pub fn RtlAddFunctionTable( + FunctionTable: PRUNTIME_FUNCTION, + EntryCount: DWORD, + BaseAddress: DWORD64, + ) -> BOOLEAN; + pub fn RtlDeleteFunctionTable( + FunctionTable: PRUNTIME_FUNCTION, + ) -> BOOLEAN; + pub fn RtlInstallFunctionTableCallback( + TableIdentifier: DWORD64, + BaseAddress: DWORD64, + Length: DWORD, + Callback: PGET_RUNTIME_FUNCTION_CALLBACK, + Context: PVOID, + OutOfProcessCallbackDll: PCWSTR, + ) -> BOOLEAN; + pub fn RtlAddGrowableFunctionTable( + DynamicTable: *mut PVOID, + FunctionTable: PRUNTIME_FUNCTION, + EntryCount: DWORD, + MaximumEntryCount: DWORD, + RangeBase: ULONG_PTR, + RangeEnd: ULONG_PTR, + ) -> DWORD; + pub fn RtlGrowFunctionTable( + DynamicTable: PVOID, + NewEntryCount: DWORD, + ); + pub fn RtlDeleteGrowableFunctionTable( + DynamicTable: PVOID, + ); + pub fn RtlLookupFunctionEntry( + ControlPc: DWORD64, + ImageBase: PDWORD64, + HistoryTable: PUNWIND_HISTORY_TABLE, + ) -> PRUNTIME_FUNCTION; +} +#[cfg(target_arch = "x86_64")] +IFDEF!{ +extern "C" { + pub fn RtlRestoreContext( + ContextRecord: PCONTEXT, + ExceptionRecord: *mut EXCEPTION_RECORD, + ); +} +extern "system" { + pub fn RtlUnwindEx( + TargetFrame: PVOID, + TargetIp: PVOID, + ExceptionRecord: PEXCEPTION_RECORD, + ReturnValue: PVOID, + ContextRecord: PCONTEXT, + HistoryTable: PUNWIND_HISTORY_TABLE, + ); + pub fn RtlVirtualUnwind( + HandlerType: DWORD, + ImageBase: DWORD64, + ControlPc: DWORD64, + FunctionEntry: PRUNTIME_FUNCTION, + ContextRecord: PCONTEXT, + HandlerData: *mut PVOID, + EstablisherFrame: PDWORD64, + ContextPointers: PKNONVOLATILE_CONTEXT_POINTERS, + ) -> PEXCEPTION_ROUTINE; +} +} +extern "system" { + pub fn RtlPcToFileHeader( + PcValue: PVOID, + BaseOfImage: *mut PVOID, + ) -> PVOID; + pub fn RtlCompareMemory( + Source1: *const VOID, + Source2: *const VOID, + Length: SIZE_T, + ) -> SIZE_T; +} +STRUCT!{struct SLIST_ENTRY { + Next: *mut SLIST_ENTRY, +}} +pub type PSLIST_ENTRY = *mut SLIST_ENTRY; +#[cfg(target_pointer_width = "64")] +IFDEF!{ +STRUCT!{struct SLIST_HEADER_s { + Alignment: ULONGLONG, + Region: ULONGLONG, +}} +STRUCT!{struct SLIST_HEADER_HeaderX64 { + BitFields1: ULONGLONG, + BitFields2: ULONGLONG, +}} +BITFIELD!{SLIST_HEADER_HeaderX64 BitFields1: ULONGLONG [ + Depth set_Depth[0..16], + Sequence set_Sequence[16..64], +]} +BITFIELD!{SLIST_HEADER_HeaderX64 BitFields2: ULONGLONG [ + Reserved set_Reserved[0..4], + NextEntry set_NextEntry[4..64], +]} +UNION!{union SLIST_HEADER { + [u64; 2], + s s_mut: SLIST_HEADER_s, + HeaderX64 HeaderX64_mut: SLIST_HEADER_HeaderX64, +}} +pub type PSLIST_HEADER = *mut SLIST_HEADER; +} +#[cfg(target_pointer_width = "32")] +IFDEF!{ +STRUCT!{struct SLIST_HEADER_s { + Next: SLIST_ENTRY, + Depth: WORD, + Reserved: WORD, +}} +UNION!{union SLIST_HEADER { + [u64; 1], + Alignment Alignment_mut: ULONGLONG, + s s_mut: SLIST_HEADER_s, +}} +pub type PSLIST_HEADER = *mut SLIST_HEADER; +} +extern "system" { + pub fn RtlInitializeSListHead( + ListHead: PSLIST_HEADER, + ); + pub fn RtlFirstEntrySList( + ListHead: *const SLIST_HEADER, + ) -> PSLIST_ENTRY; + pub fn RtlInterlockedPopEntrySList( + ListHead: PSLIST_HEADER, + ) -> PSLIST_ENTRY; + pub fn RtlInterlockedPushEntrySList( + ListHead: PSLIST_HEADER, + ListEntry: PSLIST_ENTRY, + ) -> PSLIST_ENTRY; + pub fn RtlInterlockedPushListSListEx( + ListHead: PSLIST_HEADER, + ListEntry: PSLIST_ENTRY, + ListEnd: PSLIST_ENTRY, + Count: DWORD, + ) -> PSLIST_ENTRY; + pub fn RtlInterlockedFlushSList( + ListHead: PSLIST_HEADER, + ) -> PSLIST_ENTRY; + pub fn RtlQueryDepthSList( + ListHead: PSLIST_HEADER, + ) -> WORD; +} +pub const RTL_RUN_ONCE_INIT: RTL_RUN_ONCE = RTL_RUN_ONCE { Ptr: 0 as PVOID }; +pub const RTL_RUN_ONCE_CHECK_ONLY: ULONG = 0x00000001; +pub const RTL_RUN_ONCE_ASYNC: ULONG = 0x00000002; +pub const RTL_RUN_ONCE_INIT_FAILED: ULONG = 0x00000004; +STRUCT!{struct RTL_RUN_ONCE { + Ptr: PVOID, +}} +pub type PRTL_RUN_ONCE = *mut RTL_RUN_ONCE; +STRUCT!{struct RTL_BARRIER { + Reserved1: DWORD, + Reserved2: DWORD, + Reserved3: [ULONG_PTR; 2], + Reserved4: DWORD, + Reserved5: DWORD, +}} +pub type PRTL_BARRIER = *mut RTL_BARRIER; +pub const FAST_FAIL_LEGACY_GS_VIOLATION: c_uint = 0; +pub const FAST_FAIL_VTGUARD_CHECK_FAILURE: c_uint = 1; +pub const FAST_FAIL_STACK_COOKIE_CHECK_FAILURE: c_uint = 2; +pub const FAST_FAIL_CORRUPT_LIST_ENTRY: c_uint = 3; +pub const FAST_FAIL_INCORRECT_STACK: c_uint = 4; +pub const FAST_FAIL_INVALID_ARG: c_uint = 5; +pub const FAST_FAIL_GS_COOKIE_INIT: c_uint = 6; +pub const FAST_FAIL_FATAL_APP_EXIT: c_uint = 7; +pub const FAST_FAIL_RANGE_CHECK_FAILURE: c_uint = 8; +pub const FAST_FAIL_UNSAFE_REGISTRY_ACCESS: c_uint = 9; +pub const FAST_FAIL_GUARD_ICALL_CHECK_FAILURE: c_uint = 10; +pub const FAST_FAIL_GUARD_WRITE_CHECK_FAILURE: c_uint = 11; +pub const FAST_FAIL_INVALID_FIBER_SWITCH: c_uint = 12; +pub const FAST_FAIL_INVALID_SET_OF_CONTEXT: c_uint = 13; +pub const FAST_FAIL_INVALID_REFERENCE_COUNT: c_uint = 14; +pub const FAST_FAIL_INVALID_JUMP_BUFFER: c_uint = 18; +pub const FAST_FAIL_MRDATA_MODIFIED: c_uint = 19; +pub const FAST_FAIL_CERTIFICATION_FAILURE: c_uint = 20; +pub const FAST_FAIL_INVALID_EXCEPTION_CHAIN: c_uint = 21; +pub const FAST_FAIL_CRYPTO_LIBRARY: c_uint = 22; +pub const FAST_FAIL_INVALID_CALL_IN_DLL_CALLOUT: c_uint = 23; +pub const FAST_FAIL_INVALID_IMAGE_BASE: c_uint = 24; +pub const FAST_FAIL_DLOAD_PROTECTION_FAILURE: c_uint = 25; +pub const FAST_FAIL_UNSAFE_EXTENSION_CALL: c_uint = 26; +pub const FAST_FAIL_DEPRECATED_SERVICE_INVOKED: c_uint = 27; +pub const FAST_FAIL_INVALID_BUFFER_ACCESS: c_uint = 28; +pub const FAST_FAIL_INVALID_BALANCED_TREE: c_uint = 29; +pub const FAST_FAIL_INVALID_NEXT_THREAD: c_uint = 30; +pub const FAST_FAIL_GUARD_ICALL_CHECK_SUPPRESSED: c_uint = 31; +pub const FAST_FAIL_APCS_DISABLED: c_uint = 32; +pub const FAST_FAIL_INVALID_IDLE_STATE: c_uint = 33; +pub const FAST_FAIL_MRDATA_PROTECTION_FAILURE: c_uint = 34; +pub const FAST_FAIL_UNEXPECTED_HEAP_EXCEPTION: c_uint = 35; +pub const FAST_FAIL_INVALID_LOCK_STATE: c_uint = 36; +pub const FAST_FAIL_GUARD_JUMPTABLE: c_uint = 37; +pub const FAST_FAIL_INVALID_LONGJUMP_TARGET: c_uint = 38; +pub const FAST_FAIL_INVALID_DISPATCH_CONTEXT: c_uint = 39; +pub const FAST_FAIL_INVALID_THREAD: c_uint = 40; +pub const FAST_FAIL_INVALID_SYSCALL_NUMBER: c_uint = 41; +pub const FAST_FAIL_INVALID_FILE_OPERATION: c_uint = 42; +pub const FAST_FAIL_LPAC_ACCESS_DENIED: c_uint = 43; +pub const FAST_FAIL_GUARD_SS_FAILURE: c_uint = 44; +pub const FAST_FAIL_LOADER_CONTINUITY_FAILURE: c_uint = 45; +pub const FAST_FAIL_GUARD_EXPORT_SUPPRESSION_FAILURE: c_uint = 46; +pub const FAST_FAIL_INVALID_CONTROL_STACK: c_uint = 47; +pub const FAST_FAIL_SET_CONTEXT_DENIED: c_uint = 48; +pub const FAST_FAIL_INVALID_FAST_FAIL_CODE: c_uint = 0xFFFFFFFF; +pub const HEAP_NO_SERIALIZE: DWORD = 0x00000001; +pub const HEAP_GROWABLE: DWORD = 0x00000002; +pub const HEAP_GENERATE_EXCEPTIONS: DWORD = 0x00000004; +pub const HEAP_ZERO_MEMORY: DWORD = 0x00000008; +pub const HEAP_REALLOC_IN_PLACE_ONLY: DWORD = 0x00000010; +pub const HEAP_TAIL_CHECKING_ENABLED: DWORD = 0x00000020; +pub const HEAP_FREE_CHECKING_ENABLED: DWORD = 0x00000040; +pub const HEAP_DISABLE_COALESCE_ON_FREE: DWORD = 0x00000080; +pub const HEAP_CREATE_ALIGN_16: DWORD = 0x00010000; +pub const HEAP_CREATE_ENABLE_TRACING: DWORD = 0x00020000; +pub const HEAP_CREATE_ENABLE_EXECUTE: DWORD = 0x00040000; +pub const HEAP_MAXIMUM_TAG: DWORD = 0x0FFF; +pub const HEAP_PSEUDO_TAG_FLAG: DWORD = 0x8000; +pub const HEAP_TAG_SHIFT: usize = 18; +pub const HEAP_CREATE_SEGMENT_HEAP: DWORD = 0x00000100; +pub const HEAP_CREATE_HARDENED: DWORD = 0x00000200; +#[inline] +pub fn HEAP_MAKE_TAG_FLAGS(TagBase: DWORD, Tag: DWORD) -> DWORD { + TagBase + (Tag << HEAP_TAG_SHIFT) +} +pub const IS_TEXT_UNICODE_ASCII16: INT = 0x0001; +pub const IS_TEXT_UNICODE_REVERSE_ASCII16: INT = 0x0010; +pub const IS_TEXT_UNICODE_STATISTICS: INT = 0x0002; +pub const IS_TEXT_UNICODE_REVERSE_STATISTICS: INT = 0x0020; +pub const IS_TEXT_UNICODE_CONTROLS: INT = 0x0004; +pub const IS_TEXT_UNICODE_REVERSE_CONTROLS: INT = 0x0040; +pub const IS_TEXT_UNICODE_SIGNATURE: INT = 0x0008; +pub const IS_TEXT_UNICODE_REVERSE_SIGNATURE: INT = 0x0080; +pub const IS_TEXT_UNICODE_ILLEGAL_CHARS: INT = 0x0100; +pub const IS_TEXT_UNICODE_ODD_LENGTH: INT = 0x0200; +pub const IS_TEXT_UNICODE_DBCS_LEADBYTE: INT = 0x0400; +pub const IS_TEXT_UNICODE_NULL_BYTES: INT = 0x1000; +pub const IS_TEXT_UNICODE_UNICODE_MASK: INT = 0x000F; +pub const IS_TEXT_UNICODE_REVERSE_MASK: INT = 0x00F0; +pub const IS_TEXT_UNICODE_NOT_UNICODE_MASK: INT = 0x0F00; +pub const IS_TEXT_UNICODE_NOT_ASCII_MASK: INT = 0xF000; +pub const COMPRESSION_FORMAT_NONE: USHORT = 0x0000; +pub const COMPRESSION_FORMAT_DEFAULT: USHORT = 0x0001; +pub const COMPRESSION_FORMAT_LZNT1: USHORT = 0x0002; +pub const COMPRESSION_FORMAT_XPRESS: USHORT = 0x0003; +pub const COMPRESSION_FORMAT_XPRESS_HUFF: USHORT = 0x0004; +pub const COMPRESSION_ENGINE_STANDARD: USHORT = 0x0000; +pub const COMPRESSION_ENGINE_MAXIMUM: USHORT = 0x0100; +pub const COMPRESSION_ENGINE_HIBER: USHORT = 0x0200; +// RtlEqualMemory +#[inline] +pub unsafe fn RtlMoveMemory(Destination: *mut c_void, Source: *const c_void, Length: usize) { + use core::ptr::copy; + copy(Source as *const u8, Destination as *mut u8, Length); +} +#[inline] +pub unsafe fn RtlCopyMemory(Destination: *mut c_void, Source: *const c_void, Length: usize) { + use core::ptr::copy_nonoverlapping; + copy_nonoverlapping(Source as *const u8, Destination as *mut u8, Length); +} +#[inline] +pub unsafe fn RtlFillMemory(Destination: *mut c_void, Length: usize, Fill: u8) { + use core::ptr::write_bytes; + write_bytes(Destination as *mut u8, Fill, Length); +} +#[inline] +pub unsafe fn RtlZeroMemory(Destination: *mut c_void, Length: usize) { + use core::ptr::write_bytes; + write_bytes(Destination as *mut u8, 0, Length); +} +pub const SEF_DACL_AUTO_INHERIT: ULONG = 0x01; +pub const SEF_SACL_AUTO_INHERIT: ULONG = 0x02; +pub const SEF_DEFAULT_DESCRIPTOR_FOR_OBJECT: ULONG = 0x04; +pub const SEF_AVOID_PRIVILEGE_CHECK: ULONG = 0x08; +pub const SEF_AVOID_OWNER_CHECK: ULONG = 0x10; +pub const SEF_DEFAULT_OWNER_FROM_PARENT: ULONG = 0x20; +pub const SEF_DEFAULT_GROUP_FROM_PARENT: ULONG = 0x40; +pub const SEF_MACL_NO_WRITE_UP: ULONG = 0x100; +pub const SEF_MACL_NO_READ_UP: ULONG = 0x200; +pub const SEF_MACL_NO_EXECUTE_UP: ULONG = 0x400; +pub const SEF_AI_USE_EXTRA_PARAMS: ULONG = 0x800; +pub const SEF_AVOID_OWNER_RESTRICTION: ULONG = 0x1000; +pub const SEF_MACL_VALID_FLAGS: ULONG = SEF_MACL_NO_WRITE_UP | SEF_MACL_NO_READ_UP + | SEF_MACL_NO_EXECUTE_UP; +STRUCT!{struct MESSAGE_RESOURCE_ENTRY { + Length: WORD, + Flags: WORD, + Text: [BYTE; 1], +}} +pub type PMESSAGE_RESOURCE_ENTRY = *mut MESSAGE_RESOURCE_ENTRY; +pub const MESSAGE_RESOURCE_UNICODE: WORD = 0x0001; +STRUCT!{struct MESSAGE_RESOURCE_BLOCK { + LowId: DWORD, + HighId: DWORD, + OffsetToEntries: DWORD, +}} +pub type PMESSAGE_RESOURCE_BLOCK = *mut MESSAGE_RESOURCE_BLOCK; +STRUCT!{struct MESSAGE_RESOURCE_DATA { + NumberOfBlocks: DWORD, + Blocks: [MESSAGE_RESOURCE_BLOCK; 1], +}} +pub type PMESSAGE_RESOURCE_DATA = *mut MESSAGE_RESOURCE_DATA; +STRUCT!{struct OSVERSIONINFOA { + dwOSVersionInfoSize: DWORD, + dwMajorVersion: DWORD, + dwMinorVersion: DWORD, + dwBuildNumber: DWORD, + dwPlatformId: DWORD, + szCSDVersion: [CHAR; 128], +}} +pub type POSVERSIONINFOA = *mut OSVERSIONINFOA; +pub type LPOSVERSIONINFOA = *mut OSVERSIONINFOA; +STRUCT!{struct OSVERSIONINFOW { + dwOSVersionInfoSize: DWORD, + dwMajorVersion: DWORD, + dwMinorVersion: DWORD, + dwBuildNumber: DWORD, + dwPlatformId: DWORD, + szCSDVersion: [WCHAR; 128], +}} +pub type POSVERSIONINFOW = *mut OSVERSIONINFOW; +pub type LPOSVERSIONINFOW = *mut OSVERSIONINFOW; +pub type RTL_OSVERSIONINFOW = OSVERSIONINFOW; +pub type PRTL_OSVERSIONINFOW = *mut OSVERSIONINFOW; +STRUCT!{struct OSVERSIONINFOEXA { + dwOSVersionInfoSize: DWORD, + dwMajorVersion: DWORD, + dwMinorVersion: DWORD, + dwBuildNumber: DWORD, + dwPlatformId: DWORD, + szCSDVersion: [CHAR; 128], + wServicePackMajor: WORD, + wServicePackMinor: WORD, + wSuiteMask: WORD, + wProductType: BYTE, + wReserved: BYTE, +}} +pub type POSVERSIONINFOEXA = *mut OSVERSIONINFOEXA; +pub type LPOSVERSIONINFOEXA = *mut OSVERSIONINFOEXA; +STRUCT!{struct OSVERSIONINFOEXW { + dwOSVersionInfoSize: DWORD, + dwMajorVersion: DWORD, + dwMinorVersion: DWORD, + dwBuildNumber: DWORD, + dwPlatformId: DWORD, + szCSDVersion: [WCHAR; 128], + wServicePackMajor: WORD, + wServicePackMinor: WORD, + wSuiteMask: WORD, + wProductType: BYTE, + wReserved: BYTE, +}} +pub type POSVERSIONINFOEXW = *mut OSVERSIONINFOEXW; +pub type LPOSVERSIONINFOEXW = *mut OSVERSIONINFOEXW; +pub type RTL_OSVERSIONINFOEXW = OSVERSIONINFOEXW; +pub type PRTL_OSVERSIONINFOEXW = *mut OSVERSIONINFOEXW; +pub const VER_EQUAL: BYTE = 1; +pub const VER_GREATER: BYTE = 2; +pub const VER_GREATER_EQUAL: BYTE = 3; +pub const VER_LESS: BYTE = 4; +pub const VER_LESS_EQUAL: BYTE = 5; +pub const VER_AND: BYTE = 6; +pub const VER_OR: BYTE = 7; +pub const VER_CONDITION_MASK: BYTE = 7; +pub const VER_NUM_BITS_PER_CONDITION_MASK: BYTE = 3; +pub const VER_MINORVERSION: DWORD = 0x0000001; +pub const VER_MAJORVERSION: DWORD = 0x0000002; +pub const VER_BUILDNUMBER: DWORD = 0x0000004; +pub const VER_PLATFORMID: DWORD = 0x0000008; +pub const VER_SERVICEPACKMINOR: DWORD = 0x0000010; +pub const VER_SERVICEPACKMAJOR: DWORD = 0x0000020; +pub const VER_SUITENAME: DWORD = 0x0000040; +pub const VER_PRODUCT_TYPE: DWORD = 0x0000080; +pub const VER_NT_WORKSTATION: BYTE = 0x0000001; +pub const VER_NT_DOMAIN_CONTROLLER: BYTE = 0x0000002; +pub const VER_NT_SERVER: BYTE = 0x0000003; +pub const VER_PLATFORM_WIN32s: DWORD = 0; +pub const VER_PLATFORM_WIN32_WINDOWS: DWORD = 1; +pub const VER_PLATFORM_WIN32_NT: DWORD = 2; +extern "system" { + pub fn VerSetConditionMask( + ConditionMask: ULONGLONG, + TypeMask: DWORD, + Condition: BYTE, + ) -> ULONGLONG; + pub fn RtlGetProductInfo( + OSMajorVersion: DWORD, + OSMinorVersion: DWORD, + SpMajorVersion: DWORD, + SpMinorVersion: DWORD, + ReturnedProductType: PDWORD, + ) -> BOOLEAN; +} +pub const RTL_UMS_VERSION: DWORD = 0x100; +ENUM!{enum RTL_UMS_THREAD_INFO_CLASS { + UmsThreadInvalidInfoClass = 0, + UmsThreadUserContext, + UmsThreadPriority, + UmsThreadAffinity, + UmsThreadTeb, + UmsThreadIsSuspended, + UmsThreadIsTerminated, + UmsThreadMaxInfoClass, +}} +ENUM!{enum RTL_UMS_SCHEDULER_REASON { + UmsSchedulerStartup = 0, + UmsSchedulerThreadBlocked, + UmsSchedulerThreadYield, +}} +FN!{stdcall PRTL_UMS_SCHEDULER_ENTRY_POINT( + Reason: RTL_UMS_SCHEDULER_REASON, + ActivationPayload: ULONG_PTR, + SchedulerParam: PVOID, +) -> ()} +#[inline] +pub fn IS_VALIDATION_ENABLED(C: DWORD, L: DWORD) -> bool { + (L & C) != 0 +} +pub const VRL_PREDEFINED_CLASS_BEGIN: DWORD = 1 << 0; +pub const VRL_CUSTOM_CLASS_BEGIN: DWORD = 1 << 8; +pub const VRL_CLASS_CONSISTENCY: DWORD = VRL_CUSTOM_CLASS_BEGIN << 8; +pub const VRL_ENABLE_KERNEL_BREAKS: DWORD = 1 << 31; +pub const CTMF_INCLUDE_APPCONTAINER: ULONG = 0x00000001; +pub const CTMF_INCLUDE_LPAC: ULONG = 0x00000002; +pub const CTMF_VALID_FLAGS: ULONG = CTMF_INCLUDE_APPCONTAINER | CTMF_INCLUDE_LPAC; +extern "system" { + pub fn RtlCrc32( + Buffer: *const c_void, + Size: size_t, + InitialCrc: DWORD, + ) -> DWORD; + pub fn RtlCrc64( + Buffer: *const c_void, + Size: size_t, + InitialCrc: ULONGLONG, + ) -> ULONGLONG; +} +ENUM!{enum OS_DEPLOYEMENT_STATE_VALUES { + OS_DEPLOYMENT_STANDARD = 1, + OS_DEPLOYMENT_COMPACT, +}} +extern "system" { + pub fn RtlOsDeploymentState( + Flags: DWORD, + ) -> OS_DEPLOYEMENT_STATE_VALUES; +} +#[cfg(target_arch = "x86_64")] +IFDEF!{ +STRUCT!{struct NV_MEMORY_RANGE { + BaseAddress: *mut VOID, + Length: SIZE_T, +}} +pub type PNV_MEMORY_RANGE = *mut NV_MEMORY_RANGE; +pub const FLUSH_NV_MEMORY_IN_FLAG_NO_DRAIN: ULONG = 0x00000001; +pub const FLUSH_NV_MEMORY_DEFAULT_TOKEN: ULONG_PTR = -1isize as usize; +} +STRUCT!{struct RTL_CRITICAL_SECTION_DEBUG { + Type: WORD, + CreatorBackTraceIndex: WORD, + CriticalSection: *mut RTL_CRITICAL_SECTION, + ProcessLocksList: LIST_ENTRY, + EntryCount: DWORD, + ContentionCount: DWORD, + Flags: DWORD, + CreatorBackTraceIndexHigh: WORD, + SpareWORD: WORD, +}} +pub type PRTL_CRITICAL_SECTION_DEBUG = *mut RTL_CRITICAL_SECTION_DEBUG; +pub type RTL_RESOURCE_DEBUG = RTL_CRITICAL_SECTION_DEBUG; +pub type PRTL_RESOURCE_DEBUG = *mut RTL_CRITICAL_SECTION_DEBUG; +pub const RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO: ULONG_PTR = 0x01000000; +pub const RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN: ULONG_PTR = 0x02000000; +pub const RTL_CRITICAL_SECTION_FLAG_STATIC_INIT: ULONG_PTR = 0x04000000; +pub const RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE: ULONG_PTR = 0x08000000; +pub const RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO: ULONG_PTR = 0x10000000; +pub const RTL_CRITICAL_SECTION_ALL_FLAG_BITS: ULONG_PTR = 0xFF000000; +pub const RTL_CRITICAL_SECTION_FLAG_RESERVED: ULONG_PTR = RTL_CRITICAL_SECTION_ALL_FLAG_BITS + & !(RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO | RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN + | RTL_CRITICAL_SECTION_FLAG_STATIC_INIT | RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE + | RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); +pub const RTL_CRITICAL_SECTION_DEBUG_FLAG_STATIC_INIT: DWORD = 0x00000001; +STRUCT!{struct RTL_CRITICAL_SECTION { + DebugInfo: PRTL_CRITICAL_SECTION_DEBUG, + LockCount: LONG, + RecursionCount: LONG, + OwningThread: HANDLE, + LockSemaphore: HANDLE, + SpinCount: ULONG_PTR, +}} +pub type PRTL_CRITICAL_SECTION = *mut RTL_CRITICAL_SECTION; +STRUCT!{struct RTL_SRWLOCK { + Ptr: PVOID, +}} +pub type PRTL_SRWLOCK = *mut RTL_SRWLOCK; +pub const RTL_SRWLOCK_INIT: RTL_SRWLOCK = RTL_SRWLOCK { Ptr: 0 as PVOID }; +STRUCT!{struct RTL_CONDITION_VARIABLE { + Ptr: PVOID, +}} +pub type PRTL_CONDITION_VARIABLE = *mut RTL_CONDITION_VARIABLE; +pub const RTL_CONDITION_VARIABLE_INIT: RTL_CONDITION_VARIABLE = RTL_CONDITION_VARIABLE { + Ptr: 0 as PVOID, +}; +pub const RTL_CONDITION_VARIABLE_LOCKMODE_SHARED: DWORD = 0x1; +FN!{stdcall PAPCFUNC( + Parameter: ULONG_PTR, +) -> ()} +FN!{stdcall PVECTORED_EXCEPTION_HANDLER( + ExceptionInfo: *mut EXCEPTION_POINTERS, +) -> LONG} +ENUM!{enum HEAP_INFORMATION_CLASS { + HeapCompatibilityInformation = 0, + HeapEnableTerminationOnCorruption = 1, + HeapOptimizeResources = 3, +}} +pub const HEAP_OPTIMIZE_RESOURCES_CURRENT_VERSION: DWORD = 1; +STRUCT!{struct HEAP_OPTIMIZE_RESOURCES_INFORMATION { + Version: DWORD, + Flags: DWORD, +}} +pub type PHEAP_OPTIMIZE_RESOURCES_INFORMATION = *mut HEAP_OPTIMIZE_RESOURCES_INFORMATION; +pub const WT_EXECUTEDEFAULT: ULONG = 0x00000000; +pub const WT_EXECUTEINIOTHREAD: ULONG = 0x00000001; +pub const WT_EXECUTEINUITHREAD: ULONG = 0x00000002; +pub const WT_EXECUTEINWAITTHREAD: ULONG = 0x00000004; +pub const WT_EXECUTEONLYONCE: ULONG = 0x00000008; +pub const WT_EXECUTEINTIMERTHREAD: ULONG = 0x00000020; +pub const WT_EXECUTELONGFUNCTION: ULONG = 0x00000010; +pub const WT_EXECUTEINPERSISTENTIOTHREAD: ULONG = 0x00000040; +pub const WT_EXECUTEINPERSISTENTTHREAD: ULONG = 0x00000080; +pub const WT_TRANSFER_IMPERSONATION: ULONG = 0x00000100; +#[inline] +pub fn WT_SET_MAX_THREADPOOL_THREADS(Flags: ULONG, Limit: ULONG) -> ULONG { + Flags | (Limit << 16) +} +FN!{stdcall WAITORTIMERCALLBACKFUNC( + PVOID, + BOOLEAN, +) -> ()} +FN!{stdcall WORKERCALLBACKFUNC( + PVOID, +) -> ()} +FN!{stdcall APC_CALLBACK_FUNCTION( + DWORD, + PVOID, + PVOID, +) -> ()} +pub type WAITORTIMERCALLBACK = WAITORTIMERCALLBACKFUNC; +FN!{stdcall PFLS_CALLBACK_FUNCTION( + lpFlsData: PVOID, +) -> ()} +FN!{stdcall PSECURE_MEMORY_CACHE_CALLBACK( + Addr: PVOID, + Range: SIZE_T, +) -> BOOLEAN} +pub const WT_EXECUTEINLONGTHREAD: ULONG = 0x00000010; +pub const WT_EXECUTEDELETEWAIT: ULONG = 0x00000008; +ENUM!{enum ACTIVATION_CONTEXT_INFO_CLASS { + ActivationContextBasicInformation = 1, + ActivationContextDetailedInformation = 2, + AssemblyDetailedInformationInActivationContext = 3, + FileInformationInAssemblyOfAssemblyInActivationContext = 4, + RunlevelInformationInActivationContext = 5, + CompatibilityInformationInActivationContext = 6, + ActivationContextManifestResourceName = 7, + MaxActivationContextInfoClass, + AssemblyDetailedInformationInActivationContxt = 3, + FileInformationInAssemblyOfAssemblyInActivationContxt = 4, +}} +pub type ACTIVATIONCONTEXTINFOCLASS = ACTIVATION_CONTEXT_INFO_CLASS; +STRUCT!{struct ACTIVATION_CONTEXT_QUERY_INDEX { + ulAssemblyIndex: DWORD, + ulFileIndexInAssembly: DWORD, +}} +pub type PACTIVATION_CONTEXT_QUERY_INDEX = *mut ACTIVATION_CONTEXT_QUERY_INDEX; +pub type PCACTIVATION_CONTEXT_QUERY_INDEX = *const ACTIVATION_CONTEXT_QUERY_INDEX; +pub const ACTIVATION_CONTEXT_PATH_TYPE_NONE: DWORD = 1; +pub const ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE: DWORD = 2; +pub const ACTIVATION_CONTEXT_PATH_TYPE_URL: DWORD = 3; +pub const ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF: DWORD = 4; +STRUCT!{struct ASSEMBLY_FILE_DETAILED_INFORMATION { + ulFlags: DWORD, + ulFilenameLength: DWORD, + ulPathLength: DWORD, + lpFileName: PCWSTR, + lpFilePath: PCWSTR, +}} +pub type PASSEMBLY_FILE_DETAILED_INFORMATION = *mut ASSEMBLY_FILE_DETAILED_INFORMATION; +pub type PCASSEMBLY_FILE_DETAILED_INFORMATION = *const ASSEMBLY_FILE_DETAILED_INFORMATION; +pub type ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION = ASSEMBLY_FILE_DETAILED_INFORMATION; +pub type PASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION = PASSEMBLY_FILE_DETAILED_INFORMATION; +pub type PCASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION = PCASSEMBLY_FILE_DETAILED_INFORMATION; +STRUCT!{struct ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION { + ulFlags: DWORD, + ulEncodedAssemblyIdentityLength: DWORD, + ulManifestPathType: DWORD, + ulManifestPathLength: DWORD, + liManifestLastWriteTime: LARGE_INTEGER, + ulPolicyPathType: DWORD, + ulPolicyPathLength: DWORD, + liPolicyLastWriteTime: LARGE_INTEGER, + ulMetadataSatelliteRosterIndex: DWORD, + ulManifestVersionMajor: DWORD, + ulManifestVersionMinor: DWORD, + ulPolicyVersionMajor: DWORD, + ulPolicyVersionMinor: DWORD, + ulAssemblyDirectoryNameLength: DWORD, + lpAssemblyEncodedAssemblyIdentity: PCWSTR, + lpAssemblyManifestPath: PCWSTR, + lpAssemblyPolicyPath: PCWSTR, + lpAssemblyDirectoryName: PCWSTR, + ulFileCount: DWORD, +}} +pub type PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION + = *mut ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION; +pub type PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION + = *const ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION; +ENUM!{enum ACTCTX_REQUESTED_RUN_LEVEL { + ACTCTX_RUN_LEVEL_UNSPECIFIED = 0, + ACTCTX_RUN_LEVEL_AS_INVOKER, + ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE, + ACTCTX_RUN_LEVEL_REQUIRE_ADMIN, + ACTCTX_RUN_LEVEL_NUMBERS, +}} +STRUCT!{struct ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION { + ulFlags: DWORD, + RunLevel: ACTCTX_REQUESTED_RUN_LEVEL, + UiAccess: DWORD, +}} +pub type PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION = *mut ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION; +pub type PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION + = *const ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION; +ENUM!{enum ACTCTX_COMPATIBILITY_ELEMENT_TYPE { + ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN = 0, + ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS, + ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION, +}} +STRUCT!{struct COMPATIBILITY_CONTEXT_ELEMENT { + Id: GUID, + Type: ACTCTX_COMPATIBILITY_ELEMENT_TYPE, +}} +pub type PCOMPATIBILITY_CONTEXT_ELEMENT = *mut COMPATIBILITY_CONTEXT_ELEMENT; +pub type PCCOMPATIBILITY_CONTEXT_ELEMENT = *const COMPATIBILITY_CONTEXT_ELEMENT; +STRUCT!{struct ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION { + ElementCount: DWORD, + Elements: [COMPATIBILITY_CONTEXT_ELEMENT; 0], +}} +pub type PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION + = *mut ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION; +pub type PCACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION + = *const ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION; +STRUCT!{struct SUPPORTED_OS_INFO { + MajorVersion: WORD, + MinorVersion: WORD, +}} +pub type PSUPPORTED_OS_INFO = *mut SUPPORTED_OS_INFO; +STRUCT!{struct ACTIVATION_CONTEXT_DETAILED_INFORMATION { + dwFlags: DWORD, + ulFormatVersion: DWORD, + ulAssemblyCount: DWORD, + ulRootManifestPathType: DWORD, + ulRootManifestPathChars: DWORD, + ulRootConfigurationPathType: DWORD, + ulRootConfigurationPathChars: DWORD, + ulAppDirPathType: DWORD, + ulAppDirPathChars: DWORD, + lpRootManifestPath: PCWSTR, + lpRootConfigurationPath: PCWSTR, + lpAppDirPath: PCWSTR, +}} +pub type PACTIVATION_CONTEXT_DETAILED_INFORMATION = *mut ACTIVATION_CONTEXT_DETAILED_INFORMATION; +pub type PCACTIVATION_CONTEXT_DETAILED_INFORMATION + = *const ACTIVATION_CONTEXT_DETAILED_INFORMATION; +pub const CREATE_BOUNDARY_DESCRIPTOR_ADD_APPCONTAINER_SID: DWORD = 0x1; +STRUCT!{struct HARDWARE_COUNTER_DATA { + Type: HARDWARE_COUNTER_TYPE, + Reserved: DWORD, + Value: DWORD64, +}} +pub type PHARDWARE_COUNTER_DATA = *mut HARDWARE_COUNTER_DATA; +pub const PERFORMANCE_DATA_VERSION: BYTE = 1; +STRUCT!{struct PERFORMANCE_DATA { + Size: WORD, + Version: BYTE, + HwCountersCount: BYTE, + ContextSwitchCount: DWORD, + WaitReasonBitMap: DWORD64, + CycleTime: DWORD64, + RetryCount: DWORD, + Reserved: DWORD, + HwCounters: [HARDWARE_COUNTER_DATA; MAX_HW_COUNTERS], +}} +pub type PPERFORMANCE_DATA = *mut PERFORMANCE_DATA; +pub const READ_THREAD_PROFILING_FLAG_DISPATCHING: DWORD = 0x00000001; +pub const READ_THREAD_PROFILING_FLAG_HARDWARE_COUNTERS: DWORD = 0x00000002; +pub const UNIFIEDBUILDREVISION_KEY: &'static str + = "\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion"; +pub const UNIFIEDBUILDREVISION_VALUE: &'static str = "UBR"; +pub const UNIFIEDBUILDREVISION_MIN: DWORD = 0x00000000; +pub const DEVICEFAMILYDEVICEFORM_KEY: &'static str + = "\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\OEM"; +pub const DEVICEFAMILYDEVICEFORM_VALUE: &'static str = "DeviceForm"; +pub const DEVICEFAMILYINFOENUM_UAP: DWORD = 0x00000000; +pub const DEVICEFAMILYINFOENUM_WINDOWS_8X: DWORD = 0x00000001; +pub const DEVICEFAMILYINFOENUM_WINDOWS_PHONE_8X: DWORD = 0x00000002; +pub const DEVICEFAMILYINFOENUM_DESKTOP: DWORD = 0x00000003; +pub const DEVICEFAMILYINFOENUM_MOBILE: DWORD = 0x00000004; +pub const DEVICEFAMILYINFOENUM_XBOX: DWORD = 0x00000005; +pub const DEVICEFAMILYINFOENUM_TEAM: DWORD = 0x00000006; +pub const DEVICEFAMILYINFOENUM_IOT: DWORD = 0x00000007; +pub const DEVICEFAMILYINFOENUM_IOT_HEADLESS: DWORD = 0x00000008; +pub const DEVICEFAMILYINFOENUM_SERVER: DWORD = 0x00000009; +pub const DEVICEFAMILYINFOENUM_HOLOGRAPHIC: DWORD = 0x0000000A; +pub const DEVICEFAMILYINFOENUM_XBOXSRA: DWORD = 0x0000000B; +pub const DEVICEFAMILYINFOENUM_XBOXERA: DWORD = 0x0000000C; +pub const DEVICEFAMILYINFOENUM_SERVER_NANO: DWORD = 0x0000000D; +pub const DEVICEFAMILYINFOENUM_MAX: DWORD = 0x0000000D; +pub const DEVICEFAMILYDEVICEFORM_UNKNOWN: DWORD = 0x00000000; +pub const DEVICEFAMILYDEVICEFORM_PHONE: DWORD = 0x00000001; +pub const DEVICEFAMILYDEVICEFORM_TABLET: DWORD = 0x00000002; +pub const DEVICEFAMILYDEVICEFORM_DESKTOP: DWORD = 0x00000003; +pub const DEVICEFAMILYDEVICEFORM_NOTEBOOK: DWORD = 0x00000004; +pub const DEVICEFAMILYDEVICEFORM_CONVERTIBLE: DWORD = 0x00000005; +pub const DEVICEFAMILYDEVICEFORM_DETACHABLE: DWORD = 0x00000006; +pub const DEVICEFAMILYDEVICEFORM_ALLINONE: DWORD = 0x00000007; +pub const DEVICEFAMILYDEVICEFORM_STICKPC: DWORD = 0x00000008; +pub const DEVICEFAMILYDEVICEFORM_PUCK: DWORD = 0x00000009; +pub const DEVICEFAMILYDEVICEFORM_LARGESCREEN: DWORD = 0x0000000A; +pub const DEVICEFAMILYDEVICEFORM_HMD: DWORD = 0x0000000B; +pub const DEVICEFAMILYDEVICEFORM_INDUSTRY_HANDHELD: DWORD = 0x0000000C; +pub const DEVICEFAMILYDEVICEFORM_INDUSTRY_TABLET: DWORD = 0x0000000D; +pub const DEVICEFAMILYDEVICEFORM_BANKING: DWORD = 0x0000000E; +pub const DEVICEFAMILYDEVICEFORM_BUILDING_AUTOMATION: DWORD = 0x0000000F; +pub const DEVICEFAMILYDEVICEFORM_DIGITAL_SIGNAGE: DWORD = 0x00000010; +pub const DEVICEFAMILYDEVICEFORM_GAMING: DWORD = 0x00000011; +pub const DEVICEFAMILYDEVICEFORM_HOME_AUTOMATION: DWORD = 0x00000012; +pub const DEVICEFAMILYDEVICEFORM_INDUSTRIAL_AUTOMATION: DWORD = 0x00000013; +pub const DEVICEFAMILYDEVICEFORM_KIOSK: DWORD = 0x00000014; +pub const DEVICEFAMILYDEVICEFORM_MAKER_BOARD: DWORD = 0x00000015; +pub const DEVICEFAMILYDEVICEFORM_MEDICAL: DWORD = 0x00000016; +pub const DEVICEFAMILYDEVICEFORM_NETWORKING: DWORD = 0x00000017; +pub const DEVICEFAMILYDEVICEFORM_POINT_OF_SERVICE: DWORD = 0x00000018; +pub const DEVICEFAMILYDEVICEFORM_PRINTING: DWORD = 0x00000019; +pub const DEVICEFAMILYDEVICEFORM_THIN_CLIENT: DWORD = 0x0000001A; +pub const DEVICEFAMILYDEVICEFORM_TOY: DWORD = 0x0000001B; +pub const DEVICEFAMILYDEVICEFORM_VENDING: DWORD = 0x0000001C; +pub const DEVICEFAMILYDEVICEFORM_INDUSTRY_OTHER: DWORD = 0x0000001D; +pub const DEVICEFAMILYDEVICEFORM_MAX: DWORD = 0x0000001D; +extern "system" { + pub fn RtlGetDeviceFamilyInfoEnum( + pullUAPInfo: *mut ULONGLONG, + pulDeviceFamily: *mut DWORD, + pulDeviceForm: *mut DWORD, + ); + pub fn RtlConvertDeviceFamilyInfoToString( + pulDeviceFamilyBufferSize: PDWORD, + pulDeviceFormBufferSize: PDWORD, + DeviceFamily: PWSTR, + DeviceForm: PWSTR, + ) -> DWORD; + pub fn RtlSwitchedVVI( + VersionInfo: PRTL_OSVERSIONINFOEXW, + TypeMask: DWORD, + ConditionMask: ULONGLONG, + ) -> DWORD; +} +pub const DLL_PROCESS_ATTACH: DWORD = 1; +pub const DLL_THREAD_ATTACH: DWORD = 2; +pub const DLL_THREAD_DETACH: DWORD = 3; +pub const DLL_PROCESS_DETACH: DWORD = 0; +pub const EVENTLOG_SEQUENTIAL_READ: DWORD = 0x0001; +pub const EVENTLOG_SEEK_READ: DWORD = 0x0002; +pub const EVENTLOG_FORWARDS_READ: DWORD = 0x0004; +pub const EVENTLOG_BACKWARDS_READ: DWORD = 0x0008; +pub const EVENTLOG_SUCCESS: WORD = 0x0000; +pub const EVENTLOG_ERROR_TYPE: WORD = 0x0001; +pub const EVENTLOG_WARNING_TYPE: WORD = 0x0002; +pub const EVENTLOG_INFORMATION_TYPE: WORD = 0x0004; +pub const EVENTLOG_AUDIT_SUCCESS: WORD = 0x0008; +pub const EVENTLOG_AUDIT_FAILURE: WORD = 0x0010; +pub const EVENTLOG_START_PAIRED_EVENT: WORD = 0x0001; +pub const EVENTLOG_END_PAIRED_EVENT: WORD = 0x0002; +pub const EVENTLOG_END_ALL_PAIRED_EVENTS: WORD = 0x0004; +pub const EVENTLOG_PAIRED_EVENT_ACTIVE: WORD = 0x0008; +pub const EVENTLOG_PAIRED_EVENT_INACTIVE: WORD = 0x0010; +STRUCT!{struct EVENTLOGRECORD { + Length: DWORD, + Reserved: DWORD, + RecordNumber: DWORD, + TimeGenerated: DWORD, + TimeWritten: DWORD, + EventID: DWORD, + EventType: WORD, + NumStrings: WORD, + EventCategory: WORD, + ReservedFlags: WORD, + ClosingRecordNumber: DWORD, + StringOffset: DWORD, + UserSidLength: DWORD, + UserSidOffset: DWORD, + DataLength: DWORD, + DataOffset: DWORD, +}} +pub type PEVENTLOGRECORD = *mut EVENTLOGRECORD; +pub const MAXLOGICALLOGNAMESIZE: usize = 256; +pub type PEVENTSFORLOGFILE = *mut EVENTSFORLOGFILE; +pub type PPACKEDEVENTINFO = *mut PACKEDEVENTINFO; +STRUCT!{struct EVENTSFORLOGFILE { + ulSize: DWORD, + szLogicalLogFile: [WCHAR; MAXLOGICALLOGNAMESIZE], + ulNumRecords: DWORD, + pEventLogRecords: [EVENTLOGRECORD; 0], +}} +STRUCT!{struct PACKEDEVENTINFO { + ulSize: DWORD, + ulNumEventsForLogFile: DWORD, + ulOffsets: [DWORD; 0], +}} +pub const KEY_QUERY_VALUE: u32 = 0x0001; +pub const KEY_SET_VALUE: u32 = 0x0002; +pub const KEY_CREATE_SUB_KEY: u32 = 0x0004; +pub const KEY_ENUMERATE_SUB_KEYS: u32 = 0x0008; +pub const KEY_NOTIFY: u32 = 0x0010; +pub const KEY_CREATE_LINK: u32 = 0x0020; +pub const KEY_WOW64_32KEY: u32 = 0x0200; +pub const KEY_WOW64_64KEY: u32 = 0x0100; +pub const KEY_WOW64_RES: u32 = 0x0300; +pub const KEY_READ: u32 = (STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS + | KEY_NOTIFY) & !SYNCHRONIZE; +pub const KEY_WRITE: u32 = (STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) + & !SYNCHRONIZE; +pub const KEY_EXECUTE: u32 = KEY_READ & !SYNCHRONIZE; +pub const KEY_ALL_ACCESS: u32 = (STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE + | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & !SYNCHRONIZE; +pub const REG_OPTION_RESERVED: DWORD = 0x00000000; +pub const REG_OPTION_NON_VOLATILE: DWORD = 0x00000000; +pub const REG_OPTION_VOLATILE: DWORD = 0x00000001; +pub const REG_OPTION_CREATE_LINK: DWORD = 0x00000002; +pub const REG_OPTION_BACKUP_RESTORE: DWORD = 0x00000004; +pub const REG_OPTION_OPEN_LINK: DWORD = 0x00000008; +pub const REG_OPTION_DONT_VIRTUALIZE: DWORD = 0x00000010; +pub const REG_LEGAL_OPTION: DWORD = REG_OPTION_RESERVED | REG_OPTION_NON_VOLATILE + | REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK | REG_OPTION_BACKUP_RESTORE + | REG_OPTION_OPEN_LINK | REG_OPTION_DONT_VIRTUALIZE; +pub const REG_OPEN_LEGAL_OPTION: DWORD = REG_OPTION_RESERVED | REG_OPTION_BACKUP_RESTORE + | REG_OPTION_OPEN_LINK | REG_OPTION_DONT_VIRTUALIZE; +pub const REG_CREATED_NEW_KEY: DWORD = 0x00000001; +pub const REG_OPENED_EXISTING_KEY: DWORD = 0x00000002; +pub const REG_STANDARD_FORMAT: DWORD = 1; +pub const REG_LATEST_FORMAT: DWORD = 2; +pub const REG_NO_COMPRESSION: DWORD = 4; +pub const REG_WHOLE_HIVE_VOLATILE: DWORD = 0x00000001; +pub const REG_REFRESH_HIVE: DWORD = 0x00000002; +pub const REG_NO_LAZY_FLUSH: DWORD = 0x00000004; +pub const REG_FORCE_RESTORE: DWORD = 0x00000008; +pub const REG_APP_HIVE: DWORD = 0x00000010; +pub const REG_PROCESS_PRIVATE: DWORD = 0x00000020; +pub const REG_START_JOURNAL: DWORD = 0x00000040; +pub const REG_HIVE_EXACT_FILE_GROWTH: DWORD = 0x00000080; +pub const REG_HIVE_NO_RM: DWORD = 0x00000100; +pub const REG_HIVE_SINGLE_LOG: DWORD = 0x00000200; +pub const REG_BOOT_HIVE: DWORD = 0x00000400; +pub const REG_LOAD_HIVE_OPEN_HANDLE: DWORD = 0x00000800; +pub const REG_FLUSH_HIVE_FILE_GROWTH: DWORD = 0x00001000; +pub const REG_OPEN_READ_ONLY: DWORD = 0x00002000; +pub const REG_IMMUTABLE: DWORD = 0x00004000; +pub const REG_APP_HIVE_OPEN_READ_ONLY: DWORD = REG_OPEN_READ_ONLY; +pub const REG_FORCE_UNLOAD: DWORD = 1; +pub const REG_UNLOAD_LEGAL_FLAGS: DWORD = REG_FORCE_UNLOAD; +pub const REG_NOTIFY_CHANGE_NAME: DWORD = 0x00000001; +pub const REG_NOTIFY_CHANGE_ATTRIBUTES: DWORD = 0x00000002; +pub const REG_NOTIFY_CHANGE_LAST_SET: DWORD = 0x00000004; +pub const REG_NOTIFY_CHANGE_SECURITY: DWORD = 0x00000008; +pub const REG_NOTIFY_THREAD_AGNOSTIC: DWORD = 0x10000000; +pub const REG_LEGAL_CHANGE_FILTER: DWORD = REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES + | REG_NOTIFY_CHANGE_LAST_SET | REG_NOTIFY_CHANGE_SECURITY | REG_NOTIFY_THREAD_AGNOSTIC; +pub const REG_NONE: DWORD = 0; +pub const REG_SZ: DWORD = 1; +pub const REG_EXPAND_SZ: DWORD = 2; +pub const REG_BINARY: DWORD = 3; +pub const REG_DWORD: DWORD = 4; +pub const REG_DWORD_LITTLE_ENDIAN: DWORD = 4; +pub const REG_DWORD_BIG_ENDIAN: DWORD = 5; +pub const REG_LINK: DWORD = 6; +pub const REG_MULTI_SZ: DWORD = 7; +pub const REG_RESOURCE_LIST: DWORD = 8; +pub const REG_FULL_RESOURCE_DESCRIPTOR: DWORD = 9; +pub const REG_RESOURCE_REQUIREMENTS_LIST: DWORD = 10; +pub const REG_QWORD: DWORD = 11; +pub const REG_QWORD_LITTLE_ENDIAN: DWORD = 11; +pub const SERVICE_KERNEL_DRIVER: DWORD = 0x00000001; +pub const SERVICE_FILE_SYSTEM_DRIVER: DWORD = 0x00000002; +pub const SERVICE_ADAPTER: DWORD = 0x00000004; +pub const SERVICE_RECOGNIZER_DRIVER: DWORD = 0x00000008; +pub const SERVICE_DRIVER: DWORD = SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER + | SERVICE_RECOGNIZER_DRIVER; +pub const SERVICE_WIN32_OWN_PROCESS: DWORD = 0x00000010; +pub const SERVICE_WIN32_SHARE_PROCESS: DWORD = 0x00000020; +pub const SERVICE_WIN32: DWORD = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS; +pub const SERVICE_USER_SERVICE: DWORD = 0x00000040; +pub const SERVICE_USERSERVICE_INSTANCE: DWORD = 0x00000080; +pub const SERVICE_USER_SHARE_PROCESS: DWORD = SERVICE_USER_SERVICE | SERVICE_WIN32_SHARE_PROCESS; +pub const SERVICE_USER_OWN_PROCESS: DWORD = SERVICE_USER_SERVICE | SERVICE_WIN32_OWN_PROCESS; +pub const SERVICE_INTERACTIVE_PROCESS: DWORD = 0x00000100; +pub const SERVICE_PKG_SERVICE: DWORD = 0x00000200; +pub const SERVICE_TYPE_ALL: DWORD = SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER + | SERVICE_INTERACTIVE_PROCESS | SERVICE_USER_SERVICE | SERVICE_USERSERVICE_INSTANCE + | SERVICE_PKG_SERVICE; +pub const SERVICE_BOOT_START: DWORD = 0x00000000; +pub const SERVICE_SYSTEM_START: DWORD = 0x00000001; +pub const SERVICE_AUTO_START: DWORD = 0x00000002; +pub const SERVICE_DEMAND_START: DWORD = 0x00000003; +pub const SERVICE_DISABLED: DWORD = 0x00000004; +pub const SERVICE_ERROR_IGNORE: DWORD = 0x00000000; +pub const SERVICE_ERROR_NORMAL: DWORD = 0x00000001; +pub const SERVICE_ERROR_SEVERE: DWORD = 0x00000002; +pub const SERVICE_ERROR_CRITICAL: DWORD = 0x00000003; +ENUM!{enum SERVICE_NODE_TYPE { + DriverType = SERVICE_KERNEL_DRIVER, + FileSystemType = SERVICE_FILE_SYSTEM_DRIVER, + Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS, + Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS, + AdapterType = SERVICE_ADAPTER, + RecognizerType = SERVICE_RECOGNIZER_DRIVER, +}} +ENUM!{enum SERVICE_LOAD_TYPE { + BootLoad = SERVICE_BOOT_START, + SystemLoad = SERVICE_SYSTEM_START, + AutoLoad = SERVICE_AUTO_START, + DemandLoad = SERVICE_DEMAND_START, + DisableLoad = SERVICE_DISABLED, +}} +ENUM!{enum SERVICE_ERROR_TYPE { + IgnoreError = SERVICE_ERROR_IGNORE, + NormalError = SERVICE_ERROR_NORMAL, + SevereError = SERVICE_ERROR_SEVERE, + CriticalError = SERVICE_ERROR_CRITICAL, +}} +pub const CM_SERVICE_NETWORK_BOOT_LOAD: DWORD = 0x00000001; +pub const CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD: DWORD = 0x00000002; +pub const CM_SERVICE_USB_DISK_BOOT_LOAD: DWORD = 0x00000004; +pub const CM_SERVICE_SD_DISK_BOOT_LOAD: DWORD = 0x00000008; +pub const CM_SERVICE_USB3_DISK_BOOT_LOAD: DWORD = 0x00000010; +pub const CM_SERVICE_MEASURED_BOOT_LOAD: DWORD = 0x00000020; +pub const CM_SERVICE_VERIFIER_BOOT_LOAD: DWORD = 0x00000040; +pub const CM_SERVICE_WINPE_BOOT_LOAD: DWORD = 0x00000080; +pub const CM_SERVICE_VALID_PROMOTION_MASK: DWORD = CM_SERVICE_NETWORK_BOOT_LOAD + | CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD | CM_SERVICE_USB_DISK_BOOT_LOAD + | CM_SERVICE_SD_DISK_BOOT_LOAD | CM_SERVICE_USB3_DISK_BOOT_LOAD + | CM_SERVICE_MEASURED_BOOT_LOAD | CM_SERVICE_VERIFIER_BOOT_LOAD | CM_SERVICE_WINPE_BOOT_LOAD; +pub const TAPE_ERASE_SHORT: DWORD = 0; +pub const TAPE_ERASE_LONG: DWORD = 1; +STRUCT!{struct TAPE_ERASE { + Type: DWORD, + Immediate: BOOLEAN, +}} +pub type PTAPE_ERASE = *mut TAPE_ERASE; +pub const TAPE_LOAD: DWORD = 0; +pub const TAPE_UNLOAD: DWORD = 1; +pub const TAPE_TENSION: DWORD = 2; +pub const TAPE_LOCK: DWORD = 3; +pub const TAPE_UNLOCK: DWORD = 4; +pub const TAPE_FORMAT: DWORD = 5; +STRUCT!{struct TAPE_PREPARE { + Operation: DWORD, + Immediate: BOOLEAN, +}} +pub type PTAPE_PREPARE = *mut TAPE_PREPARE; +pub const TAPE_SETMARKS: DWORD = 0; +pub const TAPE_FILEMARKS: DWORD = 1; +pub const TAPE_SHORT_FILEMARKS: DWORD = 2; +pub const TAPE_LONG_FILEMARKS: DWORD = 3; +STRUCT!{struct TAPE_WRITE_MARKS { + Type: DWORD, + Count: DWORD, + Immediate: BOOLEAN, +}} +pub type PTAPE_WRITE_MARKS = *mut TAPE_WRITE_MARKS; +pub const TAPE_ABSOLUTE_POSITION: DWORD = 0; +pub const TAPE_LOGICAL_POSITION: DWORD = 1; +pub const TAPE_PSEUDO_LOGICAL_POSITION: DWORD = 2; +STRUCT!{struct TAPE_GET_POSITION { + Type: DWORD, + Partition: DWORD, + Offset: LARGE_INTEGER, +}} +pub type PTAPE_GET_POSITION = *mut TAPE_GET_POSITION; +pub const TAPE_REWIND: DWORD = 0; +pub const TAPE_ABSOLUTE_BLOCK: DWORD = 1; +pub const TAPE_LOGICAL_BLOCK: DWORD = 2; +pub const TAPE_PSEUDO_LOGICAL_BLOCK: DWORD = 3; +pub const TAPE_SPACE_END_OF_DATA: DWORD = 4; +pub const TAPE_SPACE_RELATIVE_BLOCKS: DWORD = 5; +pub const TAPE_SPACE_FILEMARKS: DWORD = 6; +pub const TAPE_SPACE_SEQUENTIAL_FMKS: DWORD = 7; +pub const TAPE_SPACE_SETMARKS: DWORD = 8; +pub const TAPE_SPACE_SEQUENTIAL_SMKS: DWORD = 9; +STRUCT!{struct TAPE_SET_POSITION { + Method: DWORD, + Partition: DWORD, + Offset: LARGE_INTEGER, + Immediate: BOOLEAN, +}} +pub type PTAPE_SET_POSITION = *mut TAPE_SET_POSITION; +pub const TAPE_DRIVE_FIXED: DWORD = 0x00000001; +pub const TAPE_DRIVE_SELECT: DWORD = 0x00000002; +pub const TAPE_DRIVE_INITIATOR: DWORD = 0x00000004; +pub const TAPE_DRIVE_ERASE_SHORT: DWORD = 0x00000010; +pub const TAPE_DRIVE_ERASE_LONG: DWORD = 0x00000020; +pub const TAPE_DRIVE_ERASE_BOP_ONLY: DWORD = 0x00000040; +pub const TAPE_DRIVE_ERASE_IMMEDIATE: DWORD = 0x00000080; +pub const TAPE_DRIVE_TAPE_CAPACITY: DWORD = 0x00000100; +pub const TAPE_DRIVE_TAPE_REMAINING: DWORD = 0x00000200; +pub const TAPE_DRIVE_FIXED_BLOCK: DWORD = 0x00000400; +pub const TAPE_DRIVE_VARIABLE_BLOCK: DWORD = 0x00000800; +pub const TAPE_DRIVE_WRITE_PROTECT: DWORD = 0x00001000; +pub const TAPE_DRIVE_EOT_WZ_SIZE: DWORD = 0x00002000; +pub const TAPE_DRIVE_ECC: DWORD = 0x00010000; +pub const TAPE_DRIVE_COMPRESSION: DWORD = 0x00020000; +pub const TAPE_DRIVE_PADDING: DWORD = 0x00040000; +pub const TAPE_DRIVE_REPORT_SMKS: DWORD = 0x00080000; +pub const TAPE_DRIVE_GET_ABSOLUTE_BLK: DWORD = 0x00100000; +pub const TAPE_DRIVE_GET_LOGICAL_BLK: DWORD = 0x00200000; +pub const TAPE_DRIVE_SET_EOT_WZ_SIZE: DWORD = 0x00400000; +pub const TAPE_DRIVE_EJECT_MEDIA: DWORD = 0x01000000; +pub const TAPE_DRIVE_CLEAN_REQUESTS: DWORD = 0x02000000; +pub const TAPE_DRIVE_SET_CMP_BOP_ONLY: DWORD = 0x04000000; +pub const TAPE_DRIVE_RESERVED_BIT: DWORD = 0x80000000; +pub const TAPE_DRIVE_LOAD_UNLOAD: DWORD = 0x80000001; +pub const TAPE_DRIVE_TENSION: DWORD = 0x80000002; +pub const TAPE_DRIVE_LOCK_UNLOCK: DWORD = 0x80000004; +pub const TAPE_DRIVE_REWIND_IMMEDIATE: DWORD = 0x80000008; +pub const TAPE_DRIVE_SET_BLOCK_SIZE: DWORD = 0x80000010; +pub const TAPE_DRIVE_LOAD_UNLD_IMMED: DWORD = 0x80000020; +pub const TAPE_DRIVE_TENSION_IMMED: DWORD = 0x80000040; +pub const TAPE_DRIVE_LOCK_UNLK_IMMED: DWORD = 0x80000080; +pub const TAPE_DRIVE_SET_ECC: DWORD = 0x80000100; +pub const TAPE_DRIVE_SET_COMPRESSION: DWORD = 0x80000200; +pub const TAPE_DRIVE_SET_PADDING: DWORD = 0x80000400; +pub const TAPE_DRIVE_SET_REPORT_SMKS: DWORD = 0x80000800; +pub const TAPE_DRIVE_ABSOLUTE_BLK: DWORD = 0x80001000; +pub const TAPE_DRIVE_ABS_BLK_IMMED: DWORD = 0x80002000; +pub const TAPE_DRIVE_LOGICAL_BLK: DWORD = 0x80004000; +pub const TAPE_DRIVE_LOG_BLK_IMMED: DWORD = 0x80008000; +pub const TAPE_DRIVE_END_OF_DATA: DWORD = 0x80010000; +pub const TAPE_DRIVE_RELATIVE_BLKS: DWORD = 0x80020000; +pub const TAPE_DRIVE_FILEMARKS: DWORD = 0x80040000; +pub const TAPE_DRIVE_SEQUENTIAL_FMKS: DWORD = 0x80080000; +pub const TAPE_DRIVE_SETMARKS: DWORD = 0x80100000; +pub const TAPE_DRIVE_SEQUENTIAL_SMKS: DWORD = 0x80200000; +pub const TAPE_DRIVE_REVERSE_POSITION: DWORD = 0x80400000; +pub const TAPE_DRIVE_SPACE_IMMEDIATE: DWORD = 0x80800000; +pub const TAPE_DRIVE_WRITE_SETMARKS: DWORD = 0x81000000; +pub const TAPE_DRIVE_WRITE_FILEMARKS: DWORD = 0x82000000; +pub const TAPE_DRIVE_WRITE_SHORT_FMKS: DWORD = 0x84000000; +pub const TAPE_DRIVE_WRITE_LONG_FMKS: DWORD = 0x88000000; +pub const TAPE_DRIVE_WRITE_MARK_IMMED: DWORD = 0x90000000; +pub const TAPE_DRIVE_FORMAT: DWORD = 0xA0000000; +pub const TAPE_DRIVE_FORMAT_IMMEDIATE: DWORD = 0xC0000000; +pub const TAPE_DRIVE_HIGH_FEATURES: DWORD = 0x80000000; +STRUCT!{struct TAPE_GET_DRIVE_PARAMETERS { + ECC: BOOLEAN, + Compression: BOOLEAN, + DataPadding: BOOLEAN, + ReportSetmarks: BOOLEAN, + DefaultBlockSize: DWORD, + MaximumBlockSize: DWORD, + MinimumBlockSize: DWORD, + MaximumPartitionCount: DWORD, + FeaturesLow: DWORD, + FeaturesHigh: DWORD, + EOTWarningZoneSize: DWORD, +}} +pub type PTAPE_GET_DRIVE_PARAMETERS = *mut TAPE_GET_DRIVE_PARAMETERS; +STRUCT!{struct TAPE_SET_DRIVE_PARAMETERS { + ECC: BOOLEAN, + Compression: BOOLEAN, + DataPadding: BOOLEAN, + ReportSetmarks: BOOLEAN, + EOTWarningZoneSize: DWORD, +}} +pub type PTAPE_SET_DRIVE_PARAMETERS = *mut TAPE_SET_DRIVE_PARAMETERS; +STRUCT!{struct TAPE_GET_MEDIA_PARAMETERS { + Capacity: LARGE_INTEGER, + Remaining: LARGE_INTEGER, + BlockSize: DWORD, + PartitionCount: DWORD, + WriteProtected: BOOLEAN, +}} +pub type PTAPE_GET_MEDIA_PARAMETERS = *mut TAPE_GET_MEDIA_PARAMETERS; +STRUCT!{struct TAPE_SET_MEDIA_PARAMETERS { + BlockSize: DWORD, +}} +pub type PTAPE_SET_MEDIA_PARAMETERS = *mut TAPE_SET_MEDIA_PARAMETERS; +pub const TAPE_FIXED_PARTITIONS: DWORD = 0; +pub const TAPE_SELECT_PARTITIONS: DWORD = 1; +pub const TAPE_INITIATOR_PARTITIONS: DWORD = 2; +STRUCT!{struct TAPE_CREATE_PARTITION { + Method: DWORD, + Count: DWORD, + Size: DWORD, +}} +pub type PTAPE_CREATE_PARTITION = *mut TAPE_CREATE_PARTITION; +pub const TAPE_QUERY_DRIVE_PARAMETERS: DWORD = 0; +pub const TAPE_QUERY_MEDIA_CAPACITY: DWORD = 1; +pub const TAPE_CHECK_FOR_DRIVE_PROBLEM: DWORD = 2; +pub const TAPE_QUERY_IO_ERROR_DATA: DWORD = 3; +pub const TAPE_QUERY_DEVICE_ERROR_DATA: DWORD = 4; +STRUCT!{struct TAPE_WMI_OPERATIONS { + Method: DWORD, + DataBufferSize: DWORD, + DataBuffer: PVOID, +}} +pub type PTAPE_WMI_OPERATIONS = *mut TAPE_WMI_OPERATIONS; +ENUM!{enum TAPE_DRIVE_PROBLEM_TYPE { + TapeDriveProblemNone, + TapeDriveReadWriteWarning, + TapeDriveReadWriteError, + TapeDriveReadWarning, + TapeDriveWriteWarning, + TapeDriveReadError, + TapeDriveWriteError, + TapeDriveHardwareError, + TapeDriveUnsupportedMedia, + TapeDriveScsiConnectionError, + TapeDriveTimetoClean, + TapeDriveCleanDriveNow, + TapeDriveMediaLifeExpired, + TapeDriveSnappedTape, +}} +pub const TRANSACTIONMANAGER_QUERY_INFORMATION: DWORD = 0x0001; +pub const TRANSACTIONMANAGER_SET_INFORMATION: DWORD = 0x0002; +pub const TRANSACTIONMANAGER_RECOVER: DWORD = 0x0004; +pub const TRANSACTIONMANAGER_RENAME: DWORD = 0x0008; +pub const TRANSACTIONMANAGER_CREATE_RM: DWORD = 0x0010; +pub const TRANSACTIONMANAGER_BIND_TRANSACTION: DWORD = 0x0020; +pub const TRANSACTIONMANAGER_GENERIC_READ: DWORD = STANDARD_RIGHTS_READ + | TRANSACTIONMANAGER_QUERY_INFORMATION; +pub const TRANSACTIONMANAGER_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE + | TRANSACTIONMANAGER_SET_INFORMATION | TRANSACTIONMANAGER_RECOVER | TRANSACTIONMANAGER_RENAME + | TRANSACTIONMANAGER_CREATE_RM; +pub const TRANSACTIONMANAGER_GENERIC_EXECUTE: DWORD = STANDARD_RIGHTS_EXECUTE; +pub const TRANSACTIONMANAGER_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED + | TRANSACTIONMANAGER_GENERIC_READ | TRANSACTIONMANAGER_GENERIC_WRITE + | TRANSACTIONMANAGER_GENERIC_EXECUTE | TRANSACTIONMANAGER_BIND_TRANSACTION; +pub const TRANSACTION_QUERY_INFORMATION: DWORD = 0x0001; +pub const TRANSACTION_SET_INFORMATION: DWORD = 0x0002; +pub const TRANSACTION_ENLIST: DWORD = 0x0004; +pub const TRANSACTION_COMMIT: DWORD = 0x0008; +pub const TRANSACTION_ROLLBACK: DWORD = 0x0010; +pub const TRANSACTION_PROPAGATE: DWORD = 0x0020; +pub const TRANSACTION_RIGHT_RESERVED1: DWORD = 0x0040; +pub const TRANSACTION_GENERIC_READ: DWORD = STANDARD_RIGHTS_READ | TRANSACTION_QUERY_INFORMATION + | SYNCHRONIZE; +pub const TRANSACTION_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE | TRANSACTION_SET_INFORMATION + | TRANSACTION_COMMIT | TRANSACTION_ENLIST | TRANSACTION_ROLLBACK | TRANSACTION_PROPAGATE + | SYNCHRONIZE; +pub const TRANSACTION_GENERIC_EXECUTE: DWORD = STANDARD_RIGHTS_EXECUTE | TRANSACTION_COMMIT + | TRANSACTION_ROLLBACK | SYNCHRONIZE; +pub const TRANSACTION_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | TRANSACTION_GENERIC_READ + | TRANSACTION_GENERIC_WRITE | TRANSACTION_GENERIC_EXECUTE; +pub const TRANSACTION_RESOURCE_MANAGER_RIGHTS: DWORD = TRANSACTION_GENERIC_READ + | STANDARD_RIGHTS_WRITE | TRANSACTION_SET_INFORMATION | TRANSACTION_ENLIST + | TRANSACTION_ROLLBACK | TRANSACTION_PROPAGATE | SYNCHRONIZE; +pub const RESOURCEMANAGER_QUERY_INFORMATION: DWORD = 0x0001; +pub const RESOURCEMANAGER_SET_INFORMATION: DWORD = 0x0002; +pub const RESOURCEMANAGER_RECOVER: DWORD = 0x0004; +pub const RESOURCEMANAGER_ENLIST: DWORD = 0x0008; +pub const RESOURCEMANAGER_GET_NOTIFICATION: DWORD = 0x0010; +pub const RESOURCEMANAGER_REGISTER_PROTOCOL: DWORD = 0x0020; +pub const RESOURCEMANAGER_COMPLETE_PROPAGATION: DWORD = 0x0040; +pub const RESOURCEMANAGER_GENERIC_READ: DWORD = STANDARD_RIGHTS_READ + | RESOURCEMANAGER_QUERY_INFORMATION | SYNCHRONIZE; +pub const RESOURCEMANAGER_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE + | RESOURCEMANAGER_SET_INFORMATION | RESOURCEMANAGER_RECOVER | RESOURCEMANAGER_ENLIST + | RESOURCEMANAGER_GET_NOTIFICATION | RESOURCEMANAGER_REGISTER_PROTOCOL + | RESOURCEMANAGER_COMPLETE_PROPAGATION | SYNCHRONIZE; +pub const RESOURCEMANAGER_GENERIC_EXECUTE: DWORD = STANDARD_RIGHTS_EXECUTE + | RESOURCEMANAGER_RECOVER | RESOURCEMANAGER_ENLIST | RESOURCEMANAGER_GET_NOTIFICATION + | RESOURCEMANAGER_COMPLETE_PROPAGATION | SYNCHRONIZE; +pub const RESOURCEMANAGER_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED + | RESOURCEMANAGER_GENERIC_READ | RESOURCEMANAGER_GENERIC_WRITE + | RESOURCEMANAGER_GENERIC_EXECUTE; +pub const ENLISTMENT_QUERY_INFORMATION: DWORD = 0x0001; +pub const ENLISTMENT_SET_INFORMATION: DWORD = 0x0002; +pub const ENLISTMENT_RECOVER: DWORD = 0x0004; +pub const ENLISTMENT_SUBORDINATE_RIGHTS: DWORD = 0x0008; +pub const ENLISTMENT_SUPERIOR_RIGHTS: DWORD = 0x0010; +pub const ENLISTMENT_GENERIC_READ: DWORD = STANDARD_RIGHTS_READ | ENLISTMENT_QUERY_INFORMATION; +pub const ENLISTMENT_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE | ENLISTMENT_SET_INFORMATION + | ENLISTMENT_RECOVER | ENLISTMENT_SUBORDINATE_RIGHTS | ENLISTMENT_SUPERIOR_RIGHTS; +pub const ENLISTMENT_GENERIC_EXECUTE: DWORD = STANDARD_RIGHTS_EXECUTE | ENLISTMENT_RECOVER + | ENLISTMENT_SUBORDINATE_RIGHTS | ENLISTMENT_SUPERIOR_RIGHTS; +pub const ENLISTMENT_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | ENLISTMENT_GENERIC_READ + | ENLISTMENT_GENERIC_WRITE | ENLISTMENT_GENERIC_EXECUTE; +ENUM!{enum TRANSACTION_OUTCOME { + TransactionOutcomeUndetermined = 1, + TransactionOutcomeCommitted, + TransactionOutcomeAborted, +}} +ENUM!{enum TRANSACTION_STATE { + TransactionStateNormal = 1, + TransactionStateIndoubt, + TransactionStateCommittedNotify, +}} +STRUCT!{struct TRANSACTION_BASIC_INFORMATION { + TransactionId: GUID, + State: DWORD, + Outcome: DWORD, +}} +pub type PTRANSACTION_BASIC_INFORMATION = *mut TRANSACTION_BASIC_INFORMATION; +STRUCT!{struct TRANSACTIONMANAGER_BASIC_INFORMATION { + TmIdentity: GUID, + VirtualClock: LARGE_INTEGER, +}} +pub type PTRANSACTIONMANAGER_BASIC_INFORMATION = *mut TRANSACTIONMANAGER_BASIC_INFORMATION; +STRUCT!{struct TRANSACTIONMANAGER_LOG_INFORMATION { + LogIdentity: GUID, +}} +pub type PTRANSACTIONMANAGER_LOG_INFORMATION = *mut TRANSACTIONMANAGER_LOG_INFORMATION; +STRUCT!{struct TRANSACTIONMANAGER_LOGPATH_INFORMATION { + LogPathLength: DWORD, + LogPath: [WCHAR; 1], +}} +pub type PTRANSACTIONMANAGER_LOGPATH_INFORMATION = *mut TRANSACTIONMANAGER_LOGPATH_INFORMATION; +STRUCT!{struct TRANSACTIONMANAGER_RECOVERY_INFORMATION { + LastRecoveredLsn: ULONGLONG, +}} +pub type PTRANSACTIONMANAGER_RECOVERY_INFORMATION = *mut TRANSACTIONMANAGER_RECOVERY_INFORMATION; +STRUCT!{struct TRANSACTIONMANAGER_OLDEST_INFORMATION { + OldestTransactionGuid: GUID, +}} +pub type PTRANSACTIONMANAGER_OLDEST_INFORMATION = *mut TRANSACTIONMANAGER_OLDEST_INFORMATION; +STRUCT!{struct TRANSACTION_PROPERTIES_INFORMATION { + IsolationLevel: DWORD, + IsolationFlags: DWORD, + Timeout: LARGE_INTEGER, + Outcome: DWORD, + DescriptionLength: DWORD, + Description: [WCHAR; 1], +}} +pub type PTRANSACTION_PROPERTIES_INFORMATION = *mut TRANSACTION_PROPERTIES_INFORMATION; +STRUCT!{struct TRANSACTION_BIND_INFORMATION { + TmHandle: HANDLE, +}} +pub type PTRANSACTION_BIND_INFORMATION = *mut TRANSACTION_BIND_INFORMATION; +STRUCT!{struct TRANSACTION_ENLISTMENT_PAIR { + EnlistmentId: GUID, + ResourceManagerId: GUID, +}} +pub type PTRANSACTION_ENLISTMENT_PAIR = *mut TRANSACTION_ENLISTMENT_PAIR; +STRUCT!{struct TRANSACTION_ENLISTMENTS_INFORMATION { + NumberOfEnlistments: DWORD, + EnlistmentPair: [TRANSACTION_ENLISTMENT_PAIR; 1], +}} +pub type PTRANSACTION_ENLISTMENTS_INFORMATION = *mut TRANSACTION_ENLISTMENTS_INFORMATION; +STRUCT!{struct TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION { + SuperiorEnlistmentPair: TRANSACTION_ENLISTMENT_PAIR, +}} +pub type PTRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION + = *mut TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION; +STRUCT!{struct RESOURCEMANAGER_BASIC_INFORMATION { + ResourceManagerId: GUID, + DescriptionLength: DWORD, + Description: [WCHAR; 1], +}} +pub type PRESOURCEMANAGER_BASIC_INFORMATION = *mut RESOURCEMANAGER_BASIC_INFORMATION; +STRUCT!{struct RESOURCEMANAGER_COMPLETION_INFORMATION { + IoCompletionPortHandle: HANDLE, + CompletionKey: ULONG_PTR, +}} +pub type PRESOURCEMANAGER_COMPLETION_INFORMATION = *mut RESOURCEMANAGER_COMPLETION_INFORMATION; +ENUM!{enum TRANSACTION_INFORMATION_CLASS { + TransactionBasicInformation, + TransactionPropertiesInformation, + TransactionEnlistmentInformation, + TransactionSuperiorEnlistmentInformation, + TransactionBindInformation, + TransactionDTCPrivateInformation, +}} +ENUM!{enum TRANSACTIONMANAGER_INFORMATION_CLASS { + TransactionManagerBasicInformation, + TransactionManagerLogInformation, + TransactionManagerLogPathInformation, + TransactionManagerRecoveryInformation = 4, + TransactionManagerOnlineProbeInformation = 3, + TransactionManagerOldestTransactionInformation = 5, +}} +ENUM!{enum RESOURCEMANAGER_INFORMATION_CLASS { + ResourceManagerBasicInformation, + ResourceManagerCompletionInformation, +}} +STRUCT!{struct ENLISTMENT_BASIC_INFORMATION { + EnlistmentId: GUID, + TransactionId: GUID, + ResourceManagerId: GUID, +}} +pub type PENLISTMENT_BASIC_INFORMATION = *mut ENLISTMENT_BASIC_INFORMATION; +STRUCT!{struct ENLISTMENT_CRM_INFORMATION { + CrmTransactionManagerId: GUID, + CrmResourceManagerId: GUID, + CrmEnlistmentId: GUID, +}} +pub type PENLISTMENT_CRM_INFORMATION = *mut ENLISTMENT_CRM_INFORMATION; +ENUM!{enum ENLISTMENT_INFORMATION_CLASS { + EnlistmentBasicInformation, + EnlistmentRecoveryInformation, + EnlistmentCrmInformation, +}} +STRUCT!{struct TRANSACTION_LIST_ENTRY { + UOW: UOW, +}} +pub type PTRANSACTION_LIST_ENTRY = *mut TRANSACTION_LIST_ENTRY; +STRUCT!{struct TRANSACTION_LIST_INFORMATION { + NumberOfTransactions: DWORD, + TransactionInformation: [TRANSACTION_LIST_ENTRY; 1], +}} +pub type PTRANSACTION_LIST_INFORMATION = *mut TRANSACTION_LIST_INFORMATION; +ENUM!{enum KTMOBJECT_TYPE { + KTMOBJECT_TRANSACTION, + KTMOBJECT_TRANSACTION_MANAGER, + KTMOBJECT_RESOURCE_MANAGER, + KTMOBJECT_ENLISTMENT, + KTMOBJECT_INVALID, +}} +pub type PKTMOBJECT_TYPE = *mut KTMOBJECT_TYPE; +STRUCT!{struct KTMOBJECT_CURSOR { + LastQuery: GUID, + ObjectIdCount: DWORD, + ObjectIds: [GUID; 1], +}} +pub type PKTMOBJECT_CURSOR = *mut KTMOBJECT_CURSOR; +pub type TP_VERSION = DWORD; +pub type PTP_VERSION = *mut DWORD; +STRUCT!{struct TP_CALLBACK_INSTANCE { + dummy: *mut c_void, +}} +pub type PTP_CALLBACK_INSTANCE = *mut TP_CALLBACK_INSTANCE; +FN!{stdcall PTP_SIMPLE_CALLBACK( + Instance: PTP_CALLBACK_INSTANCE, + Context: PVOID, +) -> ()} +STRUCT!{struct TP_POOL { + dummy: *mut c_void, +}} +pub type PTP_POOL = *mut TP_POOL; +ENUM!{enum TP_CALLBACK_PRIORITY { + TP_CALLBACK_PRIORITY_HIGH, + TP_CALLBACK_PRIORITY_NORMAL, + TP_CALLBACK_PRIORITY_LOW, + TP_CALLBACK_PRIORITY_INVALID, + TP_CALLBACK_PRIORITY_COUNT = TP_CALLBACK_PRIORITY_INVALID, +}} +STRUCT!{struct TP_POOL_STACK_INFORMATION { + StackReserve: SIZE_T, + StackCommit: SIZE_T, +}} +pub type PTP_POOL_STACK_INFORMATION = *mut TP_POOL_STACK_INFORMATION; +STRUCT!{struct TP_CLEANUP_GROUP { + dummy: *mut c_void, +}} +pub type PTP_CLEANUP_GROUP = *mut TP_CLEANUP_GROUP; +FN!{stdcall PTP_CLEANUP_GROUP_CANCEL_CALLBACK( + ObjectContext: PVOID, + CleanupContext: PVOID, +) -> ()} +STRUCT!{struct TP_CALLBACK_ENVIRON_V3_u_s { + BitFields: DWORD, +}} +BITFIELD!{TP_CALLBACK_ENVIRON_V3_u_s BitFields: DWORD [ + LongFunction set_LongFunction[0..1], + Persistent set_Persistent[1..2], + Private set_Private[2..32], +]} +UNION!{union TP_CALLBACK_ENVIRON_V3_u { + [u32; 1], + Flags Flags_mut: DWORD, + s s_mut: TP_CALLBACK_ENVIRON_V3_u_s, +}} +STRUCT!{struct TP_CALLBACK_ENVIRON_V3 { + Version: TP_VERSION, + Pool: PTP_POOL, + CleanupGroup: PTP_CLEANUP_GROUP, + CleanupGroupCancelCallback: PTP_CLEANUP_GROUP_CANCEL_CALLBACK, + RaceDll: PVOID, + ActivationContext: *mut ACTIVATION_CONTEXT, + FinalizationCallback: PTP_SIMPLE_CALLBACK, + u: TP_CALLBACK_ENVIRON_V3_u, + CallbackPriority: TP_CALLBACK_PRIORITY, + Size: DWORD, +}} +pub type TP_CALLBACK_ENVIRON = TP_CALLBACK_ENVIRON_V3; +pub type PTP_CALLBACK_ENVIRON = *mut TP_CALLBACK_ENVIRON_V3; +STRUCT!{struct TP_WORK { + dummy: *mut c_void, +}} +pub type PTP_WORK = *mut TP_WORK; +FN!{stdcall PTP_WORK_CALLBACK( + Instance: PTP_CALLBACK_INSTANCE, + Context: PVOID, + Work: PTP_WORK, +) -> ()} +STRUCT!{struct TP_TIMER { + dummy: *mut c_void, +}} +pub type PTP_TIMER = *mut TP_TIMER; +FN!{stdcall PTP_TIMER_CALLBACK( + Instance: PTP_CALLBACK_INSTANCE, + Context: PVOID, + Timer: PTP_TIMER, +) -> ()} +pub type TP_WAIT_RESULT = DWORD; +STRUCT!{struct TP_WAIT { + dummy: *mut c_void, +}} +pub type PTP_WAIT = *mut TP_WAIT; +FN!{stdcall PTP_WAIT_CALLBACK( + Instance: PTP_CALLBACK_INSTANCE, + Context: PVOID, + Wait: PTP_WAIT, + WaitResult: TP_WAIT_RESULT, +) -> ()} +STRUCT!{struct TP_IO { + dummy: *mut c_void, +}} +pub type PTP_IO = *mut TP_IO; +pub const ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION: ULONG = 1; +pub const ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION: ULONG = 2; +pub const ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION: ULONG = 3; +pub const ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION: ULONG = 4; +pub const ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION: ULONG = 5; +pub const ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION: ULONG = 6; +pub const ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION: ULONG = 7; +pub const ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE: ULONG = 8; +pub const ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES: ULONG = 9; +pub const ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS: ULONG = 10; +pub const ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO: ULONG = 11; +STRUCT!{struct ACTIVATION_CONTEXT { + dummy: *mut c_void, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winreg.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winreg.rs new file mode 100644 index 0000000..3097ef0 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winreg.rs @@ -0,0 +1,490 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::DWORD_PTR; +use shared::minwindef::{ + BOOL, BYTE, DWORD, HKEY, LPBYTE, LPCVOID, LPDWORD, PFILETIME, PHKEY, ULONG +}; +use um::minwinbase::LPSECURITY_ATTRIBUTES; +use um::winnt::{ACCESS_MASK, HANDLE, LONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PVOID}; +pub type LSTATUS = LONG; +pub const RRF_RT_REG_NONE: DWORD = 0x00000001; +pub const RRF_RT_REG_SZ: DWORD = 0x00000002; +pub const RRF_RT_REG_EXPAND_SZ: DWORD = 0x00000004; +pub const RRF_RT_REG_BINARY: DWORD = 0x00000008; +pub const RRF_RT_REG_DWORD: DWORD = 0x00000010; +pub const RRF_RT_REG_MULTI_SZ: DWORD = 0x00000020; +pub const RRF_RT_REG_QWORD: DWORD = 0x00000040; +pub const RRF_RT_DWORD: DWORD = RRF_RT_REG_BINARY | RRF_RT_REG_DWORD; +pub const RRF_RT_QWORD: DWORD = RRF_RT_REG_BINARY | RRF_RT_REG_QWORD; +pub const RRF_RT_ANY: DWORD = 0x0000ffff; +pub const RRF_SUBKEY_WOW6464KEY: DWORD = 0x00010000; +pub const RRF_SUBKEY_WOW6432KEY: DWORD = 0x00020000; +pub const RRF_WOW64_MASK: DWORD = 0x00030000; +pub const RRF_NOEXPAND: DWORD = 0x10000000; +pub const RRF_ZEROONFAILURE: DWORD = 0x20000000; +pub const REG_PROCESS_APPKEY: DWORD = 0x00000001; +pub type REGSAM = ACCESS_MASK; +pub const HKEY_CLASSES_ROOT: HKEY = 0x80000000i32 as isize as HKEY; +pub const HKEY_CURRENT_USER: HKEY = 0x80000001i32 as isize as HKEY; +pub const HKEY_LOCAL_MACHINE: HKEY = 0x80000002i32 as isize as HKEY; +pub const HKEY_USERS: HKEY = 0x80000003i32 as isize as HKEY; +pub const HKEY_PERFORMANCE_DATA: HKEY = 0x80000004i32 as isize as HKEY; +pub const HKEY_PERFORMANCE_TEXT: HKEY = 0x80000050i32 as isize as HKEY; +pub const HKEY_PERFORMANCE_NLSTEXT: HKEY = 0x80000060i32 as isize as HKEY; +pub const HKEY_CURRENT_CONFIG: HKEY = 0x80000005i32 as isize as HKEY; +pub const HKEY_DYN_DATA: HKEY = 0x80000006i32 as isize as HKEY; +pub const HKEY_CURRENT_USER_LOCAL_SETTINGS: HKEY = 0x80000007i32 as isize as HKEY; +// PROVIDER_KEEPS_VALUE_LENGTH +// val_context +// PVALUEA +// PVALUEW +// QUERYHANDLER +// REG_PROVIDER +STRUCT!{struct VALENTA { + ve_valuename: LPSTR, + ve_valuelen: DWORD, + ve_valueptr: DWORD_PTR, + ve_type: DWORD, +}} +pub type PVALENTA = *mut VALENTA; +STRUCT!{struct VALENTW { + ve_valuename: LPWSTR, + ve_valuelen: DWORD, + ve_valueptr: DWORD_PTR, + ve_type: DWORD, +}} +pub type PVALENTW = *mut VALENTW; +// WIN31_CLASS +pub const REG_MUI_STRING_TRUNCATE: DWORD = 0x00000001; +pub const REG_SECURE_CONNECTION: DWORD = 1; +extern "system" { + pub fn RegCloseKey( + hKey: HKEY, + ) -> LSTATUS; + pub fn RegOverridePredefKey( + hKey: HKEY, + hNewHKey: HKEY, + ) -> LSTATUS; + pub fn RegOpenUserClassesRoot( + hToken: HANDLE, + dwOptions: DWORD, + samDesired: REGSAM, + phkResult: PHKEY, + ) -> LSTATUS; + pub fn RegOpenCurrentUser( + samDesired: REGSAM, + phkResult: PHKEY, + ) -> LSTATUS; + pub fn RegDisablePredefinedCache() -> LSTATUS; + pub fn RegDisablePredefinedCacheEx() -> LSTATUS; + pub fn RegConnectRegistryA( + lpMachineName: LPCSTR, + hKey: HKEY, + phkResult: PHKEY, + ) -> LSTATUS; + pub fn RegConnectRegistryW( + lpMachineName: LPCWSTR, + hKey: HKEY, + phkResult: PHKEY, + ) -> LSTATUS; + pub fn RegConnectRegistryExA( + lpMachineName: LPCSTR, + hKey: HKEY, + flags: ULONG, + phkResult: PHKEY, + ) -> LSTATUS; + pub fn RegConnectRegistryExW( + lpMachineName: LPCWSTR, + hKey: HKEY, + flags: ULONG, + phkResult: PHKEY, + ) -> LSTATUS; + pub fn RegCreateKeyA( + hKey: HKEY, + lpSubKey: LPCSTR, + phkResult: PHKEY, + ) -> LSTATUS; + pub fn RegCreateKeyW( + hKey: HKEY, + lpSubKey: LPCWSTR, + phkResult: PHKEY, + ) -> LSTATUS; + pub fn RegCreateKeyExA( + hKey: HKEY, + lpSubKey: LPCSTR, + Reserved: DWORD, + lpClass: LPSTR, + dwOptions: DWORD, + samDesired: REGSAM, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + phkResult: PHKEY, + lpdwDisposition: LPDWORD, + ) -> LSTATUS; + pub fn RegCreateKeyExW( + hKey: HKEY, + lpSubKey: LPCWSTR, + Reserved: DWORD, + lpClass: LPWSTR, + dwOptions: DWORD, + samDesired: REGSAM, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + phkResult: PHKEY, + lpdwDisposition: LPDWORD, + ) -> LSTATUS; + pub fn RegCreateKeyTransactedA( + hKey: HKEY, + lpSubKey: LPCSTR, + Reserved: DWORD, + lpClass: LPSTR, + dwOptions: DWORD, + samDesired: REGSAM, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + phkResult: PHKEY, + lpdwDisposition: LPDWORD, + hTransaction: HANDLE, + pExtendedParemeter: PVOID, + ) -> LSTATUS; + pub fn RegCreateKeyTransactedW( + hKey: HKEY, + lpSubKey: LPCWSTR, + Reserved: DWORD, + lpClass: LPWSTR, + dwOptions: DWORD, + samDesired: REGSAM, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + phkResult: PHKEY, + lpdwDisposition: LPDWORD, + hTransaction: HANDLE, + pExtendedParemeter: PVOID, + ) -> LSTATUS; + pub fn RegDeleteKeyA( + hKey: HKEY, + lpSubKey: LPCSTR, + ) -> LSTATUS; + pub fn RegDeleteKeyW( + hKey: HKEY, + lpSubKey: LPCWSTR, + ) -> LSTATUS; + pub fn RegDeleteKeyExA( + hKey: HKEY, + lpSubKey: LPCSTR, + samDesired: REGSAM, + Reserved: DWORD, + ) -> LSTATUS; + pub fn RegDeleteKeyExW( + hKey: HKEY, + lpSubKey: LPCWSTR, + samDesired: REGSAM, + Reserved: DWORD, + ) -> LSTATUS; + pub fn RegDeleteKeyTransactedA( + hKey: HKEY, + lpSubKey: LPCSTR, + samDesired: REGSAM, + Reserved: DWORD, + hTransaction: HANDLE, + pExtendedParemeter: PVOID, + ) -> LSTATUS; + pub fn RegDeleteKeyTransactedW( + hKey: HKEY, + lpSubKey: LPCWSTR, + samDesired: REGSAM, + Reserved: DWORD, + hTransaction: HANDLE, + pExtendedParemeter: PVOID, + ) -> LSTATUS; + pub fn RegDisableReflectionKey( + hBase: HKEY, + ) -> LONG; + pub fn RegEnableReflectionKey( + hBase: HKEY, + ) -> LONG; + pub fn RegQueryReflectionKey( + hBase: HKEY, + bIsReflectionDisabled: *mut BOOL, + ) -> LONG; + pub fn RegDeleteValueA( + hKey: HKEY, + lpValueName: LPCSTR, + ) -> LSTATUS; + pub fn RegDeleteValueW( + hKey: HKEY, + lpValueName: LPCWSTR, + ) -> LSTATUS; + // pub fn RegEnumKeyA(); + // pub fn RegEnumKeyW(); + pub fn RegEnumKeyExA( + hKey: HKEY, + dwIndex: DWORD, + lpName: LPSTR, + lpcName: LPDWORD, + lpReserved: LPDWORD, + lpClass: LPSTR, + lpcClass: LPDWORD, + lpftLastWriteTime: PFILETIME, + ) -> LSTATUS; + pub fn RegEnumKeyExW( + hKey: HKEY, + dwIndex: DWORD, + lpName: LPWSTR, + lpcName: LPDWORD, + lpReserved: LPDWORD, + lpClass: LPWSTR, + lpcClass: LPDWORD, + lpftLastWriteTime: PFILETIME, + ) -> LSTATUS; + pub fn RegEnumValueA( + hKey: HKEY, + dwIndex: DWORD, + lpValueName: LPSTR, + lpcchValueName: LPDWORD, + lpReserved: LPDWORD, + lpType: LPDWORD, + lpData: LPBYTE, + lpcbData: LPDWORD, + ) -> LSTATUS; + pub fn RegEnumValueW( + hKey: HKEY, + dwIndex: DWORD, + lpValueName: LPWSTR, + lpcchValueName: LPDWORD, + lpReserved: LPDWORD, + lpType: LPDWORD, + lpData: LPBYTE, + lpcbData: LPDWORD, + ) -> LSTATUS; + pub fn RegFlushKey( + hKey: HKEY, + ) -> LSTATUS; + // pub fn RegGetKeySecurity(); + // pub fn RegLoadKeyA(); + // pub fn RegLoadKeyW(); + pub fn RegNotifyChangeKeyValue( + hKey: HKEY, + bWatchSubtree: BOOL, + dwNotifyFilter: DWORD, + hEvent: HANDLE, + fAsynchronous: BOOL, + ) -> LSTATUS; + // pub fn RegOpenKeyA(); + // pub fn RegOpenKeyW(); + pub fn RegOpenKeyExA( + hKey: HKEY, + lpSubKey: LPCSTR, + ulOptions: DWORD, + samDesired: REGSAM, + phkResult: PHKEY, + ) -> LSTATUS; + pub fn RegOpenKeyExW( + hKey: HKEY, + lpSubKey: LPCWSTR, + ulOptions: DWORD, + samDesired: REGSAM, + phkResult: PHKEY, + ) -> LSTATUS; + pub fn RegOpenKeyTransactedA( + hKey: HKEY, + lpSubKey: LPCSTR, + ulOptions: DWORD, + samDesired: REGSAM, + phkResult: PHKEY, + hTransaction: HANDLE, + pExtendedParemeter: PVOID, + ) -> LSTATUS; + pub fn RegOpenKeyTransactedW( + hKey: HKEY, + lpSubKey: LPCWSTR, + ulOptions: DWORD, + samDesired: REGSAM, + phkResult: PHKEY, + hTransaction: HANDLE, + pExtendedParemeter: PVOID, + ) -> LSTATUS; + pub fn RegQueryInfoKeyA( + hKey: HKEY, + lpClass: LPSTR, + lpcClass: LPDWORD, + lpReserved: LPDWORD, + lpcSubKeys: LPDWORD, + lpcMaxSubKeyLen: LPDWORD, + lpcMaxClassLen: LPDWORD, + lpcValues: LPDWORD, + lpcMaxValueNameLen: LPDWORD, + lpcMaxValueLen: LPDWORD, + lpcbSecurityDescriptor: LPDWORD, + lpftLastWriteTime: PFILETIME, + ) -> LSTATUS; + pub fn RegQueryInfoKeyW( + hKey: HKEY, + lpClass: LPWSTR, + lpcClass: LPDWORD, + lpReserved: LPDWORD, + lpcSubKeys: LPDWORD, + lpcMaxSubKeyLen: LPDWORD, + lpcMaxClassLen: LPDWORD, + lpcValues: LPDWORD, + lpcMaxValueNameLen: LPDWORD, + lpcMaxValueLen: LPDWORD, + lpcbSecurityDescriptor: LPDWORD, + lpftLastWriteTime: PFILETIME, + ) -> LSTATUS; + // pub fn RegQueryValueA(); + // pub fn RegQueryValueW(); + pub fn RegQueryMultipleValuesA( + hKey: HKEY, + val_list: PVALENTA, + num_vals: DWORD, + lpValueBuf: LPSTR, + ldwTotsize: LPDWORD, + ) -> LSTATUS; + pub fn RegQueryMultipleValuesW( + hKey: HKEY, + val_list: PVALENTW, + num_vals: DWORD, + lpValueBuf: LPWSTR, + ldwTotsize: LPDWORD, + ) -> LSTATUS; + pub fn RegQueryValueExA( + hKey: HKEY, + lpValueName: LPCSTR, + lpReserved: LPDWORD, + lpType: LPDWORD, + lpData: LPBYTE, + lpcbData: LPDWORD, + ) -> LSTATUS; + pub fn RegQueryValueExW( + hKey: HKEY, + lpValueName: LPCWSTR, + lpReserved: LPDWORD, + lpType: LPDWORD, + lpData: LPBYTE, + lpcbData: LPDWORD, + ) -> LSTATUS; + // pub fn RegReplaceKeyA(); + // pub fn RegReplaceKeyW(); + // pub fn RegRestoreKeyA(); + // pub fn RegRestoreKeyW(); + // pub fn RegRenameKey(); + // pub fn RegSaveKeyA(); + // pub fn RegSaveKeyW(); + // pub fn RegSetKeySecurity(); + // pub fn RegSetValueA(); + // pub fn RegSetValueW(); + pub fn RegSetValueExA( + hKey: HKEY, + lpValueName: LPCSTR, + Reserved: DWORD, + dwType: DWORD, + lpData: *const BYTE, + cbData: DWORD, + ) -> LSTATUS; + pub fn RegSetValueExW( + hKey: HKEY, + lpValueName: LPCWSTR, + Reserved: DWORD, + dwType: DWORD, + lpData: *const BYTE, + cbData: DWORD, + ) -> LSTATUS; + // pub fn RegUnLoadKeyA(); + // pub fn RegUnLoadKeyW(); + pub fn RegDeleteKeyValueA( + hKey: HKEY, + lpSubKey: LPCSTR, + lpValueName: LPCSTR, + ) -> LSTATUS; + pub fn RegDeleteKeyValueW( + hKey: HKEY, + lpSubKey: LPCWSTR, + lpValueName: LPCWSTR, + ) -> LSTATUS; + pub fn RegSetKeyValueA( + hKey: HKEY, + lpSubKey: LPCSTR, + lpValueName: LPCSTR, + dwType: DWORD, + lpData: LPCVOID, + cbData: DWORD, + ) -> LSTATUS; + pub fn RegSetKeyValueW( + hKey: HKEY, + lpSubKey: LPCWSTR, + lpValueName: LPCWSTR, + dwType: DWORD, + lpData: LPCVOID, + cbData: DWORD, + ) -> LSTATUS; + pub fn RegDeleteTreeA( + hKey: HKEY, + lpSubKey: LPCSTR, + ) -> LSTATUS; + pub fn RegDeleteTreeW( + hKey: HKEY, + lpSubKey: LPCWSTR, + ) -> LSTATUS; + pub fn RegCopyTreeA( + hKeySrc: HKEY, + lpSubKey: LPCSTR, + hKeyDest: HKEY, + ) -> LSTATUS; + pub fn RegGetValueA( + hkey: HKEY, + lpSubKey: LPCSTR, + lpValue: LPCSTR, + dwFlags: DWORD, + pdwType: LPDWORD, + pvData: PVOID, + pcbData: LPDWORD, + ) -> LSTATUS; + pub fn RegGetValueW( + hkey: HKEY, + lpSubKey: LPCWSTR, + lpValue: LPCWSTR, + dwFlags: DWORD, + pdwType: LPDWORD, + pvData: PVOID, + pcbData: LPDWORD, + ) -> LSTATUS; + pub fn RegCopyTreeW( + hKeySrc: HKEY, + lpSubKey: LPCWSTR, + hKeyDest: HKEY, + ) -> LSTATUS; + // pub fn RegLoadMUIStringA(); + pub fn RegLoadMUIStringW( + hKey: HKEY, + pszValue: LPCWSTR, + pszOutBuf: LPWSTR, + cbOutBuf: DWORD, + pcbData: LPDWORD, + Flags: DWORD, + pszDirectory: LPCWSTR, + ) -> LSTATUS; + // pub fn RegLoadAppKeyA(); + // pub fn RegLoadAppKeyW(); + // pub fn InitiateSystemShutdownA(); + // pub fn InitiateSystemShutdownW(); + pub fn AbortSystemShutdownA( + lpMachineName: LPSTR, + ) -> BOOL; + pub fn AbortSystemShutdownW( + lpMachineName: LPWSTR, + ) -> BOOL; +} +// REASON_* +// MAX_SHUTDOWN_TIMEOUT +extern "system" { + // pub fn InitiateSystemShutdownExA(); + // pub fn InitiateSystemShutdownExW(); +} +// SHUTDOWN_* +extern "system" { + // pub fn InitiateShutdownA(); + // pub fn InitiateShutdownW(); + // pub fn CheckForHiberboot(); + // pub fn RegSaveKeyExA(); + // pub fn RegSaveKeyExW(); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winsafer.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winsafer.rs new file mode 100644 index 0000000..9607b67 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winsafer.rs @@ -0,0 +1,228 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{SIZE_T, ULONG64}; +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, BYTE, DWORD, FILETIME, LPBYTE, LPDWORD, LPVOID, PDWORD}; +use shared::windef::HWND; +use um::wincrypt::ALG_ID; +use um::winnt::{BOOLEAN, HANDLE, LARGE_INTEGER, LPCWSTR, PHANDLE, PVOID, PWCHAR, WCHAR}; +DECLARE_HANDLE!{SAFER_LEVEL_HANDLE, __SAFER_LEVEL_HANDLE} +pub const SAFER_SCOPEID_MACHINE: DWORD = 1; +pub const SAFER_SCOPEID_USER: DWORD = 2; +pub const SAFER_LEVELID_DISALLOWED: DWORD = 0x00000; +pub const SAFER_LEVELID_UNTRUSTED: DWORD = 0x01000; +pub const SAFER_LEVELID_CONSTRAINED: DWORD = 0x10000; +pub const SAFER_LEVELID_NORMALUSER: DWORD = 0x20000; +pub const SAFER_LEVELID_FULLYTRUSTED: DWORD = 0x40000; +pub const SAFER_LEVEL_OPEN: DWORD = 1; +pub const SAFER_MAX_FRIENDLYNAME_SIZE: SIZE_T = 256; +pub const SAFER_MAX_DESCRIPTION_SIZE: SIZE_T = 256; +pub const SAFER_MAX_HASH_SIZE: SIZE_T = 64; +pub const SAFER_TOKEN_NULL_IF_EQUAL: DWORD = 0x00000001; +pub const SAFER_TOKEN_COMPARE_ONLY: DWORD = 0x00000002; +pub const SAFER_TOKEN_MAKE_INERT: DWORD = 0x00000004; +pub const SAFER_TOKEN_WANT_FLAGS: DWORD = 0x00000008; +pub const SAFER_CRITERIA_IMAGEPATH: DWORD = 0x00001; +pub const SAFER_CRITERIA_NOSIGNEDHASH: DWORD = 0x00002; +pub const SAFER_CRITERIA_IMAGEHASH: DWORD = 0x00004; +pub const SAFER_CRITERIA_AUTHENTICODE: DWORD = 0x00008; +pub const SAFER_CRITERIA_URLZONE: DWORD = 0x00010; +pub const SAFER_CRITERIA_APPX_PACKAGE: DWORD = 0x00020; +pub const SAFER_CRITERIA_IMAGEPATH_NT: DWORD = 0x01000; +STRUCT!{struct SAFER_CODE_PROPERTIES_V1 { + cbSize: DWORD, + dwCheckFlags: DWORD, + ImagePath: LPCWSTR, + hImageFileHandle: HANDLE, + UrlZoneId: DWORD, + ImageHash: [BYTE; SAFER_MAX_HASH_SIZE], + dwImageHashSize: DWORD, + ImageSize: LARGE_INTEGER, + HashAlgorithm: ALG_ID, + pByteBlock: LPBYTE, + hWndParent: HWND, + dwWVTUIChoice: DWORD, +}} +pub type PSAFER_CODE_PROPERTIES_V1 = *mut SAFER_CODE_PROPERTIES_V1; +STRUCT!{struct SAFER_CODE_PROPERTIES_V2 { + cbSize: DWORD, + dwCheckFlags: DWORD, + ImagePath: LPCWSTR, + hImageFileHandle: HANDLE, + UrlZoneId: DWORD, + ImageHash: [BYTE; SAFER_MAX_HASH_SIZE], + dwImageHashSize: DWORD, + ImageSize: LARGE_INTEGER, + HashAlgorithm: ALG_ID, + pByteBlock: LPBYTE, + hWndParent: HWND, + dwWVTUIChoice: DWORD, + PackageMoniker: LPCWSTR, + PackagePublisher: LPCWSTR, + PackageName: LPCWSTR, + PackageVersion: ULONG64, + PackageIsFramework: BOOL, +}} +pub type PSAFER_CODE_PROPERTIES_V2 = *mut SAFER_CODE_PROPERTIES_V2; +pub type SAFER_CODE_PROPERTIES = SAFER_CODE_PROPERTIES_V2; +pub type PSAFER_CODE_PROPERTIES = *mut SAFER_CODE_PROPERTIES; +pub const SAFER_POLICY_JOBID_MASK: DWORD = 0xFF000000; +pub const SAFER_POLICY_JOBID_CONSTRAINED: DWORD = 0x04000000; +pub const SAFER_POLICY_JOBID_UNTRUSTED: DWORD = 0x03000000; +pub const SAFER_POLICY_ONLY_EXES: DWORD = 0x00010000; +pub const SAFER_POLICY_SANDBOX_INERT: DWORD = 0x00020000; +pub const SAFER_POLICY_HASH_DUPLICATE: DWORD = 0x00040000; +pub const SAFER_POLICY_ONLY_AUDIT: DWORD = 0x00001000; +pub const SAFER_POLICY_BLOCK_CLIENT_UI: DWORD = 0x00002000; +pub const SAFER_POLICY_UIFLAGS_MASK: DWORD = 0x000000FF; +pub const SAFER_POLICY_UIFLAGS_INFORMATION_PROMPT: DWORD = 0x00000001; +pub const SAFER_POLICY_UIFLAGS_OPTION_PROMPT: DWORD = 0x00000002; +pub const SAFER_POLICY_UIFLAGS_HIDDEN: DWORD = 0x00000004; +ENUM!{enum SAFER_POLICY_INFO_CLASS { + SaferPolicyLevelList = 1, + SaferPolicyEnableTransparentEnforcement, + SaferPolicyDefaultLevel, + SaferPolicyEvaluateUserScope, + SaferPolicyScopeFlags, + SaferPolicyDefaultLevelFlags, + SaferPolicyAuthenticodeEnabled, +}} +ENUM!{enum SAFER_OBJECT_INFO_CLASS { + SaferObjectLevelId = 1, + SaferObjectScopeId, + SaferObjectFriendlyName, + SaferObjectDescription, + SaferObjectBuiltin, + SaferObjectDisallowed, + SaferObjectDisableMaxPrivilege, + SaferObjectInvertDeletedPrivileges, + SaferObjectDeletedPrivileges, + SaferObjectDefaultOwner, + SaferObjectSidsToDisable, + SaferObjectRestrictedSidsInverted, + SaferObjectRestrictedSidsAdded, + SaferObjectAllIdentificationGuids, + SaferObjectSingleIdentification, + SaferObjectExtendedError, +}} +ENUM!{enum SAFER_IDENTIFICATION_TYPES { + SaferIdentityDefault, + SaferIdentityTypeImageName = 1, + SaferIdentityTypeImageHash, + SaferIdentityTypeUrlZone, + SaferIdentityTypeCertificate, +}} +STRUCT!{struct SAFER_IDENTIFICATION_HEADER { + dwIdentificationType: SAFER_IDENTIFICATION_TYPES, + cbStructSize: DWORD, + IdentificationGuid: GUID, + lastModified: FILETIME, +}} +pub type PSAFER_IDENTIFICATION_HEADER = *mut SAFER_IDENTIFICATION_HEADER; +STRUCT!{struct SAFER_PATHNAME_IDENTIFICATION { + header: SAFER_IDENTIFICATION_HEADER, + Description: [WCHAR; SAFER_MAX_DESCRIPTION_SIZE], + ImageName: PWCHAR, + dwSaferFlags: DWORD, +}} +pub type PSAFER_PATHNAME_IDENTIFICATION = *mut SAFER_PATHNAME_IDENTIFICATION; +STRUCT!{struct SAFER_HASH_IDENTIFICATION { + header: SAFER_IDENTIFICATION_HEADER, + Description: [WCHAR; SAFER_MAX_DESCRIPTION_SIZE], + FriendlyName: [WCHAR; SAFER_MAX_DESCRIPTION_SIZE], + HashSize: DWORD, + ImageHash: [BYTE; SAFER_MAX_HASH_SIZE], + HashAlgorithm: ALG_ID, + ImageSize: LARGE_INTEGER, + dwSaferFlags: DWORD, +}} +pub type PSAFER_HASH_IDENTIFICATION = *mut SAFER_HASH_IDENTIFICATION; +STRUCT!{struct SAFER_HASH_IDENTIFICATION2 { + hashIdentification: SAFER_HASH_IDENTIFICATION, + HashSize: DWORD, + ImageHash: [BYTE; SAFER_MAX_HASH_SIZE], + HashAlgorithm: ALG_ID, +}} +pub type PSAFER_HASH_IDENTIFICATION2 = *mut SAFER_HASH_IDENTIFICATION2; +STRUCT!{struct SAFER_URLZONE_IDENTIFICATION { + header: SAFER_IDENTIFICATION_HEADER, + UrlZoneId: DWORD, + dwSaferFlags: DWORD, +}} +pub type PSAFER_URLZONE_IDENTIFICATION = *mut SAFER_URLZONE_IDENTIFICATION; +extern "system" { + pub fn SaferGetPolicyInformation( + dwScopeId: DWORD, + SaferPolicyInfoClass: SAFER_POLICY_INFO_CLASS, + InfoBufferSize: DWORD, + InfoBuffer: PVOID, + InfoBufferRetSize: PDWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn SaferSetPolicyInformation( + dwScopeId: DWORD, + SaferPolicyInfoClass: SAFER_POLICY_INFO_CLASS, + InfoBufferSize: DWORD, + InfoBuffer: PVOID, + lpReserved: LPVOID, + ) -> BOOL; + pub fn SaferCreateLevel( + dwScopeId: DWORD, + dwLevelId: DWORD, + OpenFlags: DWORD, + pLevelHandle: *mut SAFER_LEVEL_HANDLE, + lpReserved: LPVOID, + ) -> BOOL; + pub fn SaferCloseLevel( + hLevelHandle: SAFER_LEVEL_HANDLE, + ) -> BOOL; + pub fn SaferIdentifyLevel( + dwNumProperties: DWORD, + pCodeProperties: PSAFER_CODE_PROPERTIES, + pLevelHandle: *mut SAFER_LEVEL_HANDLE, + lpReserved: LPVOID, + ) -> BOOL; + pub fn SaferComputeTokenFromLevel( + LevelHandle: SAFER_LEVEL_HANDLE, + InAccessToken: HANDLE, + OutAccessToken: PHANDLE, + dwFlags: DWORD, + lpReserved: LPVOID, + ) -> BOOL; + pub fn SaferGetLevelInformation( + LevelHandle: SAFER_LEVEL_HANDLE, + dwInfoType: SAFER_OBJECT_INFO_CLASS, + lpQueryBuffer: LPVOID, + dwInBufferSize: DWORD, + lpdwOutBufferSize: LPDWORD, + ) -> BOOL; + pub fn SaferSetLevelInformation( + LevelHandle: SAFER_LEVEL_HANDLE, + dwInfoType: SAFER_OBJECT_INFO_CLASS, + lpQueryBuffer: LPVOID, + dwInBufferSize: DWORD, + ) -> BOOL; + pub fn SaferRecordEventLogEntry( + hLevel: SAFER_LEVEL_HANDLE, + szTargetPath: LPCWSTR, + lpReserved: LPVOID, + ) -> BOOL; + pub fn SaferiIsExecutableFileType( + szFullPath: LPCWSTR, + bFromShellExecute: BOOLEAN, + ) -> BOOL; +} +pub const SRP_POLICY_EXE: &'static str = "EXE"; +pub const SRP_POLICY_DLL: &'static str = "DLL"; +pub const SRP_POLICY_MSI: &'static str = "MSI"; +pub const SRP_POLICY_SCRIPT: &'static str = "SCRIPT"; +pub const SRP_POLICY_SHELL: &'static str = "SHELL"; +pub const SRP_POLICY_NOV2: &'static str = "IGNORESRPV2"; +pub const SRP_POLICY_APPX: &'static str = "APPX"; +pub const SRP_POLICY_WLDPMSI: &'static str = "WLDPMSI"; +pub const SRP_POLICY_WLDPSCRIPT: &'static str = "WLDPSCRIPT"; +pub const SRP_POLICY_WLDPCONFIGCI: &'static str = "WLDPCONFIGCI"; +pub const SRP_POLICY_MANAGEDINSTALLER: &'static str = "MANAGEDINSTALLER"; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winscard.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winscard.rs new file mode 100644 index 0000000..5adaec7 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winscard.rs @@ -0,0 +1,709 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Data Protection API Prototypes and Definitions +// This header file provides the definitions and symbols necessary for an +// Application or Smart Card Service Provider to access the Smartcard Subsystem. +use shared::basetsd::ULONG_PTR; +use shared::guiddef::{LPCGUID, LPGUID}; +use shared::minwindef::{BOOL, BYTE, DWORD, LPBYTE, LPCVOID, LPDWORD, LPVOID, PBYTE}; +use shared::rpcdce::UUID; +use shared::windef::{HICON, HWND}; +use um::winnt::{CHAR, HANDLE, LONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PVOID, WCHAR}; +use um::winsmcrd::{LPCSCARD_IO_REQUEST, LPSCARD_IO_REQUEST}; +pub type LPCBYTE = *const BYTE; +pub type SCARDCONTEXT = ULONG_PTR; +pub type PSCARDCONTEXT = *mut SCARDCONTEXT; +pub type LPSCARDCONTEXT = *mut SCARDCONTEXT; +pub type SCARDHANDLE = ULONG_PTR; +pub type PSCARDHANDLE = *mut SCARDHANDLE; +pub type LPSCARDHANDLE = *mut SCARDHANDLE; +pub const SCARD_AUTOALLOCATE: DWORD = -1i32 as u32; +pub const SCARD_SCOPE_USER: DWORD = 0; +pub const SCARD_SCOPE_TERMINAL: DWORD = 1; +pub const SCARD_SCOPE_SYSTEM: DWORD = 2; +extern "system" { + pub fn SCardEstablishContext( + dwScope: DWORD, + pvReserved1: LPCVOID, + pvReserved2: LPCVOID, + phContext: LPSCARDCONTEXT, + ) -> LONG; + pub fn SCardReleaseContext( + hContext: SCARDCONTEXT, + ) -> LONG; + pub fn SCardIsValidContext( + hContext: SCARDCONTEXT, + ) -> LONG; +} +pub const SCARD_PROVIDER_PRIMARY: DWORD = 1; +pub const SCARD_PROVIDER_CSP: DWORD = 2; +pub const SCARD_PROVIDER_KSP: DWORD = 3; +extern "system" { + pub fn SCardListReaderGroupsA( + hContext: SCARDCONTEXT, + mszGroups: LPSTR, + pcchGroups: LPDWORD, + ) -> LONG; + pub fn SCardListReaderGroupsW( + hContext: SCARDCONTEXT, + mszGroups: LPWSTR, + pcchGroups: LPDWORD, + ) -> LONG; + pub fn SCardListReadersA( + hContext: SCARDCONTEXT, + mszGroups: LPCSTR, + mszReaders: LPSTR, + pcchReaders: LPDWORD, + ) -> LONG; + pub fn SCardListReadersW( + hContext: SCARDCONTEXT, + mszGroups: LPCWSTR, + mszReaders: LPWSTR, + pcchReaders: LPDWORD, + ) -> LONG; + pub fn SCardListCardsA( + hContext: SCARDCONTEXT, + pbAtr: LPCBYTE, + rgquidInterfaces: LPCGUID, + cguidInterfaceCount: DWORD, + mszCards: *mut CHAR, + pcchCards: LPDWORD, + ) -> LONG; + pub fn SCardListCardsW( + hContext: SCARDCONTEXT, + pbAtr: LPCBYTE, + rgquidInterfaces: LPCGUID, + cguidInterfaceCount: DWORD, + mszCards: *mut WCHAR, + pcchCards: LPDWORD, + ) -> LONG; + pub fn SCardListInterfacesA( + hContext: SCARDCONTEXT, + szCard: LPCSTR, + pguidInterfaces: LPGUID, + pcguidInterfaces: LPDWORD, + ) -> LONG; + pub fn SCardListInterfacesW( + hContext: SCARDCONTEXT, + szCard: LPCWSTR, + pguidInterfaces: LPGUID, + pcguidInterfaces: LPDWORD, + ) -> LONG; + pub fn SCardGetProviderIdA( + hContext: SCARDCONTEXT, + szCard: LPCSTR, + pguidProviderId: LPGUID, + ) -> LONG; + pub fn SCardGetProviderIdW( + hContext: SCARDCONTEXT, + szCard: LPCWSTR, + pguidProviderId: LPGUID, + ) -> LONG; + pub fn SCardGetCardTypeProviderNameA( + hContext: SCARDCONTEXT, + szCardName: LPCSTR, + dwProviderId: DWORD, + szProvider: *mut CHAR, + pcchProvider: LPDWORD, + ) -> LONG; + pub fn SCardGetCardTypeProviderNameW( + hContext: SCARDCONTEXT, + szCardName: LPCWSTR, + dwProviderId: DWORD, + szProvider: *mut WCHAR, + pcchProvider: LPDWORD, + ) -> LONG; + pub fn SCardIntroduceReaderGroupA( + hContext: SCARDCONTEXT, + szGroupName: LPCSTR, + ) -> LONG; + pub fn SCardIntroduceReaderGroupW( + hContext: SCARDCONTEXT, + szGroupName: LPCWSTR, + ) -> LONG; + pub fn SCardForgetReaderGroupA( + hContext: SCARDCONTEXT, + szGroupName: LPCSTR, + ) -> LONG; + pub fn SCardForgetReaderGroupW( + hContext: SCARDCONTEXT, + szGroupName: LPCWSTR, + ) -> LONG; + pub fn SCardIntroduceReaderA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + szDeviceName: LPCSTR, + ) -> LONG; + pub fn SCardIntroduceReaderW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + szDeviceName: LPCWSTR, + ) -> LONG; + pub fn SCardForgetReaderA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + ) -> LONG; + pub fn SCardForgetReaderW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + ) -> LONG; + pub fn SCardAddReaderToGroupA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + szGroupName: LPCSTR, + ) -> LONG; + pub fn SCardAddReaderToGroupW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + szGroupName: LPCWSTR, + ) -> LONG; + pub fn SCardRemoveReaderFromGroupA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + szGroupName: LPCSTR, + ) -> LONG; + pub fn SCardRemoveReaderFromGroupW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + szGroupName: LPCWSTR, + ) -> LONG; + pub fn SCardIntroduceCardTypeA( + hContext: SCARDCONTEXT, + szCardName: LPCSTR, + pguidPrimaryProvider: LPCGUID, + rgguidInterfaces: LPCGUID, + dwInterfaceCount: DWORD, + pbAtr: LPCBYTE, + pbAtrMask: LPCBYTE, + cbAtrLen: DWORD, + ) -> LONG; + pub fn SCardIntroduceCardTypeW( + hContext: SCARDCONTEXT, + szCardName: LPCWSTR, + pguidPrimaryProvider: LPCGUID, + rgguidInterfaces: LPCGUID, + dwInterfaceCount: DWORD, + pbAtr: LPCBYTE, + pbAtrMask: LPCBYTE, + cbAtrLen: DWORD, + ) -> LONG; + pub fn SCardSetCardTypeProviderNameA( + hContext: SCARDCONTEXT, + szCardName: LPCSTR, + dwProviderId: DWORD, + szProvider: LPCSTR, + ) -> LONG; + pub fn SCardSetCardTypeProviderNameW( + hContext: SCARDCONTEXT, + szCardName: LPCWSTR, + dwProviderId: DWORD, + szProvider: LPCWSTR, + ) -> LONG; + pub fn SCardForgetCardTypeA( + hContext: SCARDCONTEXT, + szCardName: LPCSTR, + ) -> LONG; + pub fn SCardForgetCardTypeW( + hContext: SCARDCONTEXT, + szCardName: LPCWSTR, + ) -> LONG; + pub fn SCardFreeMemory( + hContext: SCARDCONTEXT, + pvMem: LPCVOID, + ) -> LONG; + pub fn SCardAccessStartedEvent() -> HANDLE; + pub fn SCardReleaseStartedEvent(); +} +STRUCT!{struct SCARD_READERSTATEA { + szReader: LPCSTR, + pvUserData: LPVOID, + dwCurrentState: DWORD, + dwEventState: DWORD, + cbAtr: DWORD, + rgbAtr: [BYTE; 36], +}} +pub type PSCARD_READERSTATEA = *mut SCARD_READERSTATEA; +pub type LPSCARD_READERSTATEA = *mut SCARD_READERSTATEA; +STRUCT!{struct SCARD_READERSTATEW { + szReader: LPCWSTR, + pvUserData: LPVOID, + dwCurrentState: DWORD, + dwEventState: DWORD, + cbAtr: DWORD, + rgbAtr: [BYTE; 36], +}} +pub type PSCARD_READERSTATEW = *mut SCARD_READERSTATEW; +pub type LPSCARD_READERSTATEW = *mut SCARD_READERSTATEW; +pub type SCARD_READERSTATE_A = SCARD_READERSTATEA; +pub type SCARD_READERSTATE_W = SCARD_READERSTATEW; +pub type PSCARD_READERSTATE_A = PSCARD_READERSTATEA; +pub type PSCARD_READERSTATE_W = PSCARD_READERSTATEW; +pub type LPSCARD_READERSTATE_A = LPSCARD_READERSTATEA; +pub type LPSCARD_READERSTATE_W = LPSCARD_READERSTATEW; +pub const SCARD_STATE_UNAWARE: DWORD = 0x00000000; +pub const SCARD_STATE_IGNORE: DWORD = 0x00000001; +pub const SCARD_STATE_CHANGED: DWORD = 0x00000002; +pub const SCARD_STATE_UNKNOWN: DWORD = 0x00000004; +pub const SCARD_STATE_UNAVAILABLE: DWORD = 0x00000008; +pub const SCARD_STATE_EMPTY: DWORD = 0x00000010; +pub const SCARD_STATE_PRESENT: DWORD = 0x00000020; +pub const SCARD_STATE_ATRMATCH: DWORD = 0x00000040; +pub const SCARD_STATE_EXCLUSIVE: DWORD = 0x00000080; +pub const SCARD_STATE_INUSE: DWORD = 0x00000100; +pub const SCARD_STATE_MUTE: DWORD = 0x00000200; +pub const SCARD_STATE_UNPOWERED: DWORD = 0x00000400; +extern "system" { + pub fn SCardLocateCardsA( + hContext: SCARDCONTEXT, + mszCards: LPCSTR, + rgReaderStates: LPSCARD_READERSTATEA, + cReaders: DWORD, + ) -> LONG; + pub fn SCardLocateCardsW( + hContext: SCARDCONTEXT, + mszCards: LPCWSTR, + rgReaderStates: LPSCARD_READERSTATEW, + cReaders: DWORD, + ) -> LONG; +} +STRUCT!{struct SCARD_ATRMASK { + cbAtr: DWORD, + rgbAtr: [BYTE; 36], + rgbMask: [BYTE; 36], +}} +pub type PSCARD_ATRMASK = *mut SCARD_ATRMASK; +pub type LPSCARD_ATRMASK = *mut SCARD_ATRMASK; +extern "system" { + pub fn SCardLocateCardsByATRA( + hContext: SCARDCONTEXT, + rgAtrMasks: LPSCARD_ATRMASK, + cAtrs: DWORD, + rgReaderStates: LPSCARD_READERSTATEA, + cReaders: DWORD, + ) -> LONG; + pub fn SCardLocateCardsByATRW( + hContext: SCARDCONTEXT, + rgAtrMasks: LPSCARD_ATRMASK, + cAtrs: DWORD, + rgReaderStates: LPSCARD_READERSTATEW, + cReaders: DWORD, + ) -> LONG; + pub fn SCardGetStatusChangeA( + hContext: SCARDCONTEXT, + dwTimeout: DWORD, + rgReaderStates: LPSCARD_READERSTATEA, + cReaders: DWORD, + ) -> LONG; + pub fn SCardGetStatusChangeW( + hContext: SCARDCONTEXT, + dwTimeout: DWORD, + rgReaderStates: LPSCARD_READERSTATEW, + cReaders: DWORD, + ) -> LONG; + pub fn SCardCancel( + hContext: SCARDCONTEXT, + ) -> LONG; +} +pub const SCARD_SHARE_EXCLUSIVE: DWORD = 1; +pub const SCARD_SHARE_SHARED: DWORD = 2; +pub const SCARD_SHARE_DIRECT: DWORD = 3; +pub const SCARD_LEAVE_CARD: DWORD = 0; +pub const SCARD_RESET_CARD: DWORD = 1; +pub const SCARD_UNPOWER_CARD: DWORD = 2; +pub const SCARD_EJECT_CARD: DWORD = 3; +extern "system" { + pub fn SCardConnectA( + hContext: SCARDCONTEXT, + szReader: LPCSTR, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + phCard: LPSCARDHANDLE, + pdwActiveProtocol: LPDWORD, + ) -> LONG; + pub fn SCardConnectW( + hContext: SCARDCONTEXT, + szReader: LPCWSTR, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + phCard: LPSCARDHANDLE, + pdwActiveProtocol: LPDWORD, + ) -> LONG; + pub fn SCardReconnect( + hCard: SCARDHANDLE, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + dwInitialization: DWORD, + pdwActiveProtocol: LPDWORD, + ) -> LONG; + pub fn SCardDisconnect( + hCard: SCARDHANDLE, + dwDisposition: DWORD, + ) -> LONG; + pub fn SCardBeginTransaction( + hCard: SCARDHANDLE, + ) -> LONG; + pub fn SCardEndTransaction( + hCard: SCARDHANDLE, + dwDisposition: DWORD, + ) -> LONG; + pub fn SCardState( + hCard: SCARDHANDLE, + pdwState: LPDWORD, + pdwProtocol: LPDWORD, + pbAtr: LPBYTE, + pcbAtrLen: LPDWORD, + ) -> LONG; + pub fn SCardStatusA( + hCard: SCARDHANDLE, + mszReaderNames: LPSTR, + pcchReaderLen: LPDWORD, + pdwState: LPDWORD, + pdwProtocol: LPDWORD, + pbAtr: LPBYTE, + pcbAtrLen: LPDWORD, + ) -> LONG; + pub fn SCardStatusW( + hCard: SCARDHANDLE, + mszReaderNames: LPWSTR, + pcchReaderLen: LPDWORD, + pdwState: LPDWORD, + pdwProtocol: LPDWORD, + pbAtr: LPBYTE, + pcbAtrLen: LPDWORD, + ) -> LONG; + pub fn SCardTransmit( + hCard: SCARDHANDLE, + pioSendPci: LPCSCARD_IO_REQUEST, + pbSendBuffer: LPCBYTE, + cbSendLength: DWORD, + pioRecvPci: LPSCARD_IO_REQUEST, + pbRecvBuffer: LPBYTE, + pcbRecvLength: LPDWORD, + ) -> LONG; + pub fn SCardGetTransmitCount( + hCard: SCARDHANDLE, + pcTransmitCount: LPDWORD, + ) -> LONG; + pub fn SCardControl( + hCard: SCARDHANDLE, + dwControlCode: DWORD, + lpInBuffer: LPCVOID, + cbInBufferSize: DWORD, + lpOutBuffer: LPVOID, + cbOutBufferSize: DWORD, + lpBytesReturned: LPDWORD, + ) -> LONG; + pub fn SCardGetAttrib( + hCard: SCARDHANDLE, + dwAttrId: DWORD, + pbAttr: LPBYTE, + pcbAttrLen: LPDWORD, + ) -> LONG; + pub fn SCardSetAttrib( + hCard: SCARDHANDLE, + dwAttrId: DWORD, + pbAttr: LPCBYTE, + cbAttrLen: DWORD, + ) -> LONG; +} +pub const SC_DLG_MINIMAL_UI: DWORD = 0x01; +pub const SC_DLG_NO_UI: DWORD = 0x02; +pub const SC_DLG_FORCE_UI: DWORD = 0x04; +pub const SCERR_NOCARDNAME: DWORD = 0x4000; +pub const SCERR_NOGUIDS: DWORD = 0x8000; +FN!{stdcall LPOCNCONNPROCA( + SCARDCONTEXT, + LPSTR, + LPSTR, + PVOID, +) -> SCARDHANDLE} +FN!{stdcall LPOCNCONNPROCW( + SCARDCONTEXT, + LPWSTR, + LPWSTR, + PVOID, +) -> SCARDHANDLE} +FN!{stdcall LPOCNCHKPROC( + SCARDCONTEXT, + SCARDHANDLE, + PVOID, +) -> BOOL} +FN!{stdcall LPOCNDSCPROC( + SCARDCONTEXT, + SCARDHANDLE, + PVOID, +) -> ()} +STRUCT!{struct OPENCARD_SEARCH_CRITERIAA { + dwStructSize: DWORD, + lpstrGroupNames: LPSTR, + nMaxGroupNames: DWORD, + rgguidInterfaces: LPCGUID, + cguidInterfaces: DWORD, + lpstrCardNames: LPSTR, + nMaxCardNames: DWORD, + lpfnCheck: LPOCNCHKPROC, + lpfnConnect: LPOCNCONNPROCA, + lpfnDisconnect: LPOCNDSCPROC, + pvUserData: LPVOID, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, +}} +pub type POPENCARD_SEARCH_CRITERIAA = *mut OPENCARD_SEARCH_CRITERIAA; +pub type LPOPENCARD_SEARCH_CRITERIAA = *mut OPENCARD_SEARCH_CRITERIAA; +STRUCT!{struct OPENCARD_SEARCH_CRITERIAW { + dwStructSize: DWORD, + lpstrGroupNames: LPWSTR, + nMaxGroupNames: DWORD, + rgguidInterfaces: LPCGUID, + cguidInterfaces: DWORD, + lpstrCardNames: LPWSTR, + nMaxCardNames: DWORD, + lpfnCheck: LPOCNCHKPROC, + lpfnConnect: LPOCNCONNPROCW, + lpfnDisconnect: LPOCNDSCPROC, + pvUserData: LPVOID, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, +}} +pub type POPENCARD_SEARCH_CRITERIAW = *mut OPENCARD_SEARCH_CRITERIAW; +pub type LPOPENCARD_SEARCH_CRITERIAW = *mut OPENCARD_SEARCH_CRITERIAW; +STRUCT!{struct OPENCARDNAME_EXA { + dwStructSize: DWORD, + hSCardContext: SCARDCONTEXT, + hwndOwner: HWND, + dwFlags: DWORD, + lpstrTitle: LPCSTR, + lpstrSearchDesc: LPCSTR, + hIcon: HICON, + pOpenCardSearchCriteria: POPENCARD_SEARCH_CRITERIAA, + lpfnConnect: LPOCNCONNPROCA, + pvUserData: LPVOID, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + lpstrRdr: LPSTR, + nMaxRdr: DWORD, + lpstrCard: LPSTR, + nMaxCard: DWORD, + dwActiveProtocol: DWORD, + hCardHandle: SCARDHANDLE, +}} +pub type POPENCARDNAME_EXA = *mut OPENCARDNAME_EXA; +pub type LPOPENCARDNAME_EXA = *mut OPENCARDNAME_EXA; +STRUCT!{struct OPENCARDNAME_EXW { + dwStructSize: DWORD, + hSCardContext: SCARDCONTEXT, + hwndOwner: HWND, + dwFlags: DWORD, + lpstrTitle: LPCWSTR, + lpstrSearchDesc: LPCWSTR, + hIcon: HICON, + pOpenCardSearchCriteria: POPENCARD_SEARCH_CRITERIAW, + lpfnConnect: LPOCNCONNPROCW, + pvUserData: LPVOID, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + lpstrRdr: LPWSTR, + nMaxRdr: DWORD, + lpstrCard: LPWSTR, + nMaxCard: DWORD, + dwActiveProtocol: DWORD, + hCardHandle: SCARDHANDLE, +}} +pub type POPENCARDNAME_EXW = *mut OPENCARDNAME_EXW; +pub type LPOPENCARDNAME_EXW = *mut OPENCARDNAME_EXW; +pub type OPENCARDNAMEA_EX = OPENCARDNAME_EXA; +pub type OPENCARDNAMEW_EX = OPENCARDNAME_EXW; +pub type POPENCARDNAMEA_EX = POPENCARDNAME_EXA; +pub type POPENCARDNAMEW_EX = POPENCARDNAME_EXW; +pub type LPOPENCARDNAMEA_EX = LPOPENCARDNAME_EXA; +pub type LPOPENCARDNAMEW_EX = LPOPENCARDNAME_EXW; +pub const SCARD_READER_SEL_AUTH_PACKAGE: DWORD = -629i32 as u32; +ENUM!{enum READER_SEL_REQUEST_MATCH_TYPE { + RSR_MATCH_TYPE_READER_AND_CONTAINER = 1, + RSR_MATCH_TYPE_SERIAL_NUMBER, + RSR_MATCH_TYPE_ALL_CARDS, +}} +STRUCT!{struct READER_SEL_REQUEST_ReaderAndContainerParameter { + cbReaderNameOffset: DWORD, + cchReaderNameLength: DWORD, + cbContainerNameOffset: DWORD, + cchContainerNameLength: DWORD, + dwDesiredCardModuleVersion: DWORD, + dwCspFlags: DWORD, +}} +STRUCT!{struct READER_SEL_REQUEST_SerialNumberParameter { + cbSerialNumberOffset: DWORD, + cbSerialNumberLength: DWORD, + dwDesiredCardModuleVersion: DWORD, +}} +UNION!{union READER_SEL_REQUEST_u { + [u32; 6], + ReaderAndContainerParameter ReaderAndContainerParameter_mut: + READER_SEL_REQUEST_ReaderAndContainerParameter, + SerialNumberParameter SerialNumberParameter_mut: READER_SEL_REQUEST_SerialNumberParameter, +}} +STRUCT!{struct READER_SEL_REQUEST { + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + MatchType: READER_SEL_REQUEST_MATCH_TYPE, + u: READER_SEL_REQUEST_u, +}} +pub type PREADER_SEL_REQUEST = *mut READER_SEL_REQUEST; +STRUCT!{struct READER_SEL_RESPONSE { + cbReaderNameOffset: DWORD, + cchReaderNameLength: DWORD, + cbCardNameOffset: DWORD, + cchCardNameLength: DWORD, +}} +pub type PREADER_SEL_RESPONSE = *mut READER_SEL_RESPONSE; +STRUCT!{struct OPENCARDNAMEA { + dwStructSize: DWORD, + hwndOwner: HWND, + hSCardContext: SCARDCONTEXT, + lpstrGroupNames: LPSTR, + nMaxGroupNames: DWORD, + lpstrCardNames: LPSTR, + nMaxCardNames: DWORD, + rgguidInterfaces: LPCGUID, + cguidInterfaces: DWORD, + lpstrRdr: LPSTR, + nMaxRdr: DWORD, + lpstrCard: LPSTR, + nMaxCard: DWORD, + lpstrTitle: LPCSTR, + dwFlags: DWORD, + pvUserData: LPVOID, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + dwActiveProtocol: DWORD, + lpfnConnect: LPOCNCONNPROCA, + lpfnCheck: LPOCNCHKPROC, + lpfnDisconnect: LPOCNDSCPROC, + hCardHandle: SCARDHANDLE, +}} +pub type POPENCARDNAMEA = *mut OPENCARDNAMEA; +pub type LPOPENCARDNAMEA = *mut OPENCARDNAMEA; +STRUCT!{struct OPENCARDNAMEW { + dwStructSize: DWORD, + hwndOwner: HWND, + hSCardContext: SCARDCONTEXT, + lpstrGroupNames: LPWSTR, + nMaxGroupNames: DWORD, + lpstrCardNames: LPWSTR, + nMaxCardNames: DWORD, + rgguidInterfaces: LPCGUID, + cguidInterfaces: DWORD, + lpstrRdr: LPWSTR, + nMaxRdr: DWORD, + lpstrCard: LPWSTR, + nMaxCard: DWORD, + lpstrTitle: LPCWSTR, + dwFlags: DWORD, + pvUserData: LPVOID, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + dwActiveProtocol: DWORD, + lpfnConnect: LPOCNCONNPROCW, + lpfnCheck: LPOCNCHKPROC, + lpfnDisconnect: LPOCNDSCPROC, + hCardHandle: SCARDHANDLE, +}} +pub type POPENCARDNAMEW = *mut OPENCARDNAMEW; +pub type LPOPENCARDNAMEW = *mut OPENCARDNAMEW; +pub type OPENCARDNAME_A = OPENCARDNAMEA; +pub type OPENCARDNAME_W = OPENCARDNAMEW; +pub type POPENCARDNAME_A = POPENCARDNAMEA; +pub type POPENCARDNAME_W = POPENCARDNAMEW; +pub type LPOPENCARDNAME_A = LPOPENCARDNAMEA; +pub type LPOPENCARDNAME_W = LPOPENCARDNAMEW; +extern "system" { + pub fn SCardReadCacheA( + hContext: SCARDCONTEXT, + CardIdentifier: *mut UUID, + FreshnessCounter: DWORD, + LookupName: LPSTR, + Data: PBYTE, + DataLen: *mut DWORD, + ) -> LONG; + pub fn SCardReadCacheW( + hContext: SCARDCONTEXT, + CardIdentifier: *mut UUID, + FreshnessCounter: DWORD, + LookupName: LPWSTR, + Data: PBYTE, + DataLen: *mut DWORD, + ) -> LONG; + pub fn SCardWriteCacheA( + hContext: SCARDCONTEXT, + CardIdentifier: *mut UUID, + FreshnessCounter: DWORD, + LookupName: LPSTR, + Data: PBYTE, + DataLen: DWORD, + ) -> LONG; + pub fn SCardWriteCacheW( + hContext: SCARDCONTEXT, + CardIdentifier: *mut UUID, + FreshnessCounter: DWORD, + LookupName: LPWSTR, + Data: PBYTE, + DataLen: DWORD, + ) -> LONG; + pub fn SCardGetReaderIconA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + pbIcon: LPBYTE, + pcbIcon: LPDWORD, + ) -> LONG; + pub fn SCardGetReaderIconW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + pbIcon: LPBYTE, + pcbIcon: LPDWORD, + ) -> LONG; + pub fn SCardGetDeviceTypeIdA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + pdwDeviceTypeId: LPDWORD, + ) -> LONG; + pub fn SCardGetDeviceTypeIdW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + pdwDeviceTypeId: LPDWORD, + ) -> LONG; + pub fn SCardGetReaderDeviceInstanceIdA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + szDeviceInstanceId: LPSTR, + pcchDeviceInstanceId: LPDWORD, + ) -> LONG; + pub fn SCardGetReaderDeviceInstanceIdW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + szDeviceInstanceId: LPWSTR, + pcchDeviceInstanceId: LPDWORD, + ) -> LONG; + pub fn SCardListReadersWithDeviceInstanceIdA( + hContext: SCARDCONTEXT, + szDeviceInstanceId: LPCSTR, + mszReaders: LPSTR, + pcchReaders: LPDWORD, + ) -> LONG; + pub fn SCardListReadersWithDeviceInstanceIdW( + hContext: SCARDCONTEXT, + szDeviceInstanceId: LPCWSTR, + mszReaders: LPWSTR, + pcchReaders: LPDWORD, + ) -> LONG; +} +pub const SCARD_AUDIT_CHV_FAILURE: DWORD = 0x0; +pub const SCARD_AUDIT_CHV_SUCCESS: DWORD = 0x1; +extern "system" { + pub fn SCardAudit( + hContext: SCARDCONTEXT, + dwEvent: DWORD, + ) -> LONG; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winsmcrd.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winsmcrd.rs new file mode 100644 index 0000000..227bf7b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winsmcrd.rs @@ -0,0 +1,166 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Smart Card class/port IOCTL codes. +use shared::minwindef::{BYTE, DWORD, ULONG, WORD}; +use um::winioctl::{FILE_ANY_ACCESS, FILE_DEVICE_SMARTCARD, METHOD_BUFFERED}; +pub type UWORD = WORD; +DEFINE_GUID!{GUID_DEVINTERFACE_SMARTCARD_READER, + 0x50DD5230, 0xBA8A, 0x11D1, 0xBF, 0x5D, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30} +pub const SCARD_ATR_LENGTHL: DWORD = 33; +pub const SCARD_PROTOCOL_UNDEFINED: DWORD = 0x00000000; +pub const SCARD_PROTOCOL_T0: DWORD = 0x00000001; +pub const SCARD_PROTOCOL_T1: DWORD = 0x00000002; +pub const SCARD_PROTOCOL_RAW: DWORD = 0x00010000; +pub const SCARD_PROTOCOL_Tx: DWORD = SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1; +pub const SCARD_PROTOCOL_DEFAULT: DWORD = 0x80000000; +pub const SCARD_PROTOCOL_OPTIMAL: DWORD = 0x00000000; +pub const SCARD_POWER_DOWN: DWORD = 0; +pub const SCARD_COLD_RESET: DWORD = 1; +pub const SCARD_WARM_RESET: DWORD = 2; +pub const IOCTL_SMARTCARD_POWER: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 1, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_GET_ATTRIBUTE: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 2, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_SET_ATTRIBUTE: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 3, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_CONFISCATE: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 4, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_TRANSMIT: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 5, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_EJECT: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 6, METHOD_BUFFERED, + FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_SWALLOW: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 7, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_IS_PRESENT: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 10, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_IS_ABSENT: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 11, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_SET_PROTOCOL: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 12, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_GET_STATE: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 14, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_GET_LAST_ERROR: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 15, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const IOCTL_SMARTCARD_GET_PERF_CNTR: DWORD = CTL_CODE!(FILE_DEVICE_SMARTCARD, 16, + METHOD_BUFFERED, FILE_ANY_ACCESS); +pub const MAXIMUM_ATTR_STRING_LENGTH: DWORD = 32; +pub const MAXIMUM_SMARTCARD_READERS: DWORD = 10; +pub const SCARD_CLASS_VENDOR_INFO: ULONG = 1; +pub const SCARD_CLASS_COMMUNICATIONS: ULONG = 2; +pub const SCARD_CLASS_PROTOCOL: ULONG = 3; +pub const SCARD_CLASS_POWER_MGMT: ULONG = 4; +pub const SCARD_CLASS_SECURITY: ULONG = 5; +pub const SCARD_CLASS_MECHANICAL: ULONG = 6; +pub const SCARD_CLASS_VENDOR_DEFINED: ULONG = 7; +pub const SCARD_CLASS_IFD_PROTOCOL: ULONG = 8; +pub const SCARD_CLASS_ICC_STATE: ULONG = 9; +pub const SCARD_CLASS_PERF: ULONG = 0x7ffe; +pub const SCARD_CLASS_SYSTEM: ULONG = 0x7fff; +pub const SCARD_ATTR_VENDOR_NAME: ULONG = SCARD_CLASS_VENDOR_INFO << 16 | 0x0100; +pub const SCARD_ATTR_VENDOR_IFD_TYPE: ULONG = SCARD_CLASS_VENDOR_INFO << 16 | 0x0101; +pub const SCARD_ATTR_VENDOR_IFD_VERSION: ULONG = SCARD_CLASS_VENDOR_INFO << 16 | 0x0102; +pub const SCARD_ATTR_VENDOR_IFD_SERIAL_NO: ULONG = SCARD_CLASS_VENDOR_INFO << 16 | 0x0103; +pub const SCARD_ATTR_CHANNEL_ID: ULONG = SCARD_CLASS_COMMUNICATIONS << 16 | 0x0110; +pub const SCARD_ATTR_PROTOCOL_TYPES: ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0120; +pub const SCARD_ATTR_DEFAULT_CLK: ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0121; +pub const SCARD_ATTR_MAX_CLK: ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0122; +pub const SCARD_ATTR_DEFAULT_DATA_RATE: ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0123; +pub const SCARD_ATTR_MAX_DATA_RATE: ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0124; +pub const SCARD_ATTR_MAX_IFSD: ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0125; +pub const SCARD_ATTR_POWER_MGMT_SUPPORT: ULONG = SCARD_CLASS_POWER_MGMT << 16 | 0x0131; +pub const SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE: ULONG = SCARD_CLASS_SECURITY << 16 | 0x0140; +pub const SCARD_ATTR_USER_AUTH_INPUT_DEVICE: ULONG = SCARD_CLASS_SECURITY << 16 | 0x0142; +pub const SCARD_ATTR_CHARACTERISTICS: ULONG = SCARD_CLASS_MECHANICAL << 16 | 0x0150; +pub const SCARD_ATTR_CURRENT_PROTOCOL_TYPE: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0201; +pub const SCARD_ATTR_CURRENT_CLK: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0202; +pub const SCARD_ATTR_CURRENT_F: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0203; +pub const SCARD_ATTR_CURRENT_D: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0204; +pub const SCARD_ATTR_CURRENT_N: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0205; +pub const SCARD_ATTR_CURRENT_W: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0206; +pub const SCARD_ATTR_CURRENT_IFSC: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0207; +pub const SCARD_ATTR_CURRENT_IFSD: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0208; +pub const SCARD_ATTR_CURRENT_BWT: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0209; +pub const SCARD_ATTR_CURRENT_CWT: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x020a; +pub const SCARD_ATTR_CURRENT_EBC_ENCODING: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x020b; +pub const SCARD_ATTR_EXTENDED_BWT: ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x020c; +pub const SCARD_ATTR_ICC_PRESENCE: ULONG = SCARD_CLASS_ICC_STATE << 16 | 0x0300; +pub const SCARD_ATTR_ICC_INTERFACE_STATUS: ULONG = SCARD_CLASS_ICC_STATE << 16 | 0x0301; +pub const SCARD_ATTR_CURRENT_IO_STATE: ULONG = SCARD_CLASS_ICC_STATE << 16 | 0x0302; +pub const SCARD_ATTR_ATR_STRING: ULONG = SCARD_CLASS_ICC_STATE << 16 | 0x0303; +pub const SCARD_ATTR_ICC_TYPE_PER_ATR: ULONG = SCARD_CLASS_ICC_STATE << 16 | 0x0304; +pub const SCARD_ATTR_ESC_RESET: ULONG = SCARD_CLASS_VENDOR_DEFINED << 16 | 0xA000; +pub const SCARD_ATTR_ESC_CANCEL: ULONG = SCARD_CLASS_VENDOR_DEFINED << 16 | 0xA003; +pub const SCARD_ATTR_ESC_AUTHREQUEST: ULONG = SCARD_CLASS_VENDOR_DEFINED << 16 | 0xA005; +pub const SCARD_ATTR_MAXINPUT: ULONG = SCARD_CLASS_VENDOR_DEFINED << 16 | 0xA007; +pub const SCARD_ATTR_DEVICE_UNIT: ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0001; +pub const SCARD_ATTR_DEVICE_IN_USE: ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0002; +pub const SCARD_ATTR_DEVICE_FRIENDLY_NAME_A: ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0003; +pub const SCARD_ATTR_DEVICE_SYSTEM_NAME_A: ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0004; +pub const SCARD_ATTR_DEVICE_FRIENDLY_NAME_W: ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0005; +pub const SCARD_ATTR_DEVICE_SYSTEM_NAME_W: ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0006; +pub const SCARD_ATTR_SUPRESS_T1_IFS_REQUEST: ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0007; +pub const SCARD_PERF_NUM_TRANSMISSIONS: ULONG = SCARD_CLASS_PERF << 16 | 0x0001; +pub const SCARD_PERF_BYTES_TRANSMITTED: ULONG = SCARD_CLASS_PERF << 16 | 0x0002; +pub const SCARD_PERF_TRANSMISSION_TIME: ULONG = SCARD_CLASS_PERF << 16 | 0x0003; +pub const SCARD_T0_HEADER_LENGTH: DWORD = 7; +pub const SCARD_T0_CMD_LENGTH: DWORD = 5; +pub const SCARD_T1_PROLOGUE_LENGTH: DWORD = 3; +pub const SCARD_T1_EPILOGUE_LENGTH: DWORD = 2; +pub const SCARD_T1_MAX_IFS: DWORD = 254; +pub const SCARD_UNKNOWN: ULONG = 0; +pub const SCARD_ABSENT: ULONG = 1; +pub const SCARD_PRESENT: ULONG = 2; +pub const SCARD_SWALLOWED: ULONG = 3; +pub const SCARD_POWERED: ULONG = 4; +pub const SCARD_NEGOTIABLE: ULONG = 5; +pub const SCARD_SPECIFIC: ULONG = 6; +STRUCT!{struct SCARD_IO_REQUEST { + dwProtocol: DWORD, + cbPciLength: DWORD, +}} +pub type PSCARD_IO_REQUEST = *mut SCARD_IO_REQUEST; +pub type LPSCARD_IO_REQUEST = *mut SCARD_IO_REQUEST; +pub type LPCSCARD_IO_REQUEST = *const SCARD_IO_REQUEST; +STRUCT!{struct SCARD_T0_COMMAND { + bCla: BYTE, + bIns: BYTE, + bP1: BYTE, + bP2: BYTE, + bP3: BYTE, +}} +pub type LPSCARD_T0_COMMAND = *mut SCARD_T0_COMMAND; +UNION!{union SCARD_T0_REQUEST_u { + [u8; 5], + CmdBytes CmdBytes_mut: SCARD_T0_COMMAND, + rgbHeader rgbHeader_mut: [BYTE; 5], +}} +STRUCT!{struct SCARD_T0_REQUEST { + ioRequest: SCARD_IO_REQUEST, + bSw1: BYTE, + bSw2: BYTE, + u: SCARD_T0_REQUEST_u, +}} +pub type PSCARD_T0_REQUEST = *mut SCARD_T0_REQUEST; +pub type LPSCARD_T0_REQUEST = *mut SCARD_T0_REQUEST; +STRUCT!{struct SCARD_T1_REQUEST { + ioRequest: SCARD_IO_REQUEST, +}} +pub type PSCARD_T1_REQUEST = *mut SCARD_T1_REQUEST; +pub type LPSCARD_T1_REQUEST = *mut SCARD_T1_REQUEST; +pub const SCARD_READER_SWALLOWS: ULONG = 0x00000001; +pub const SCARD_READER_EJECTS: ULONG = 0x00000002; +pub const SCARD_READER_CONFISCATES: ULONG = 0x00000004; +pub const SCARD_READER_TYPE_SERIAL: ULONG = 0x01; +pub const SCARD_READER_TYPE_PARALELL: ULONG = 0x02; +pub const SCARD_READER_TYPE_KEYBOARD: ULONG = 0x04; +pub const SCARD_READER_TYPE_SCSI: ULONG = 0x08; +pub const SCARD_READER_TYPE_IDE: ULONG = 0x10; +pub const SCARD_READER_TYPE_USB: ULONG = 0x20; +pub const SCARD_READER_TYPE_PCMCIA: ULONG = 0x40; +pub const SCARD_READER_TYPE_TPM: ULONG = 0x80; +pub const SCARD_READER_TYPE_NFC: ULONG = 0x100; +pub const SCARD_READER_TYPE_UICC: ULONG = 0x200; +pub const SCARD_READER_TYPE_VENDOR: ULONG = 0xF0; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winsock2.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winsock2.rs new file mode 100644 index 0000000..36793fb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winsock2.rs @@ -0,0 +1,1450 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Definitions to be used with the WinSock 2 DLL and WinSock 2 applications. +use ctypes::{ + __uint32, __uint64, c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, + c_ulong, c_ushort, +}; +use shared::basetsd::{DWORD_PTR, UINT_PTR, ULONG_PTR}; +use shared::guiddef::{GUID, LPGUID}; +use shared::inaddr::in_addr; +use shared::minwindef::{ + BOOL, DWORD, FARPROC, HIWORD, INT, LOWORD, LPDWORD, LPHANDLE, LPINT, LPVOID, MAKELONG, UINT, + ULONG, WORD, WPARAM, +}; +use shared::qos::FLOWSPEC; +use shared::windef::HWND; +use shared::winerror::{ + ERROR_INVALID_HANDLE, ERROR_INVALID_PARAMETER, ERROR_IO_INCOMPLETE, ERROR_IO_PENDING, + ERROR_NOT_ENOUGH_MEMORY, ERROR_OPERATION_ABORTED, WAIT_TIMEOUT, +}; +use shared::ws2def::{ + AF_APPLETALK, AF_ATM, AF_BAN, AF_BTH, AF_CCITT, AF_CHAOS, AF_DATAKIT, AF_DECnet, AF_DLI, + AF_ECMA, AF_FIREFOX, AF_HYLINK, AF_IMPLINK, AF_INET, AF_INET6, AF_IPX, AF_ISO, AF_LAT, + AF_MAX, AF_NS, AF_OSI, AF_PUP, AF_SNA, AF_UNIX, AF_UNKNOWN1, AF_UNSPEC, AF_VOICEVIEW, + INADDR_ANY, LPCSADDR_INFO, LPSOCKADDR, LPWSABUF, LPWSAMSG, PSOCKET_ADDRESS_LIST, SOCKADDR, + SOCKADDR_IN, WSABUF, +}; +use shared::wtypesbase::{BLOB, LPBLOB}; +use um::minwinbase::OVERLAPPED; +use um::winbase::{INFINITE, WAIT_FAILED, WAIT_IO_COMPLETION, WAIT_OBJECT_0}; +use um::winnt::{ + CHAR, HANDLE, LONG, LPCSTR, LPSTR, LPWSTR, MAXIMUM_WAIT_OBJECTS, PWSTR, SHORT, WCHAR, +}; +pub const WINSOCK_VERSION: WORD = 2 | (2 << 8); +pub type u_char = c_uchar; +pub type u_short = c_ushort; +pub type u_int = c_uint; +pub type u_long = c_ulong; +pub type u_int64 = __uint64; +pub type SOCKET = UINT_PTR; +pub const FD_SETSIZE: usize = 64; +STRUCT!{struct fd_set { + fd_count: u_int, + fd_array: [SOCKET; FD_SETSIZE], +}} +extern "system" { + pub fn __WSAFDIsSet( + fd: SOCKET, + _: *mut fd_set, + ) -> c_int; +} +STRUCT!{struct timeval { + tv_sec: c_long, + tv_usec: c_long, +}} +pub const IOCPARM_MASK: c_long = 0x7f; +pub const IOC_VOID: c_long = 0x20000000; +pub const IOC_OUT: c_long = 0x40000000; +pub const IOC_IN: c_long = 0x80000000; +pub const IOC_INOUT: c_long = IOC_IN | IOC_OUT; +pub const FIONREAD: c_long = IOC_OUT | ((4 & IOCPARM_MASK) << 16) | (0x66 << 8) | 127; +pub const FIONBIO: c_long = IOC_IN | ((4 & IOCPARM_MASK) << 16) | (0x66 << 8) | 126; +pub const FIOASYNC: c_long = IOC_IN | ((4 & IOCPARM_MASK) << 16) | (0x66 << 8) | 125; +pub const SIOCSHIWAT: c_long = IOC_IN | ((4 & IOCPARM_MASK) << 16) | (0x73 << 8) | 0; +pub const SIOCGHIWAT: c_long = IOC_OUT | ((4 & IOCPARM_MASK) << 16) | (0x73 << 8) | 1; +pub const SIOCSLOWAT: c_long = IOC_IN | ((4 & IOCPARM_MASK) << 16) | (0x73 << 8) | 2; +pub const SIOCGLOWAT: c_long = IOC_OUT | ((4 & IOCPARM_MASK) << 16) | (0x73 << 8) | 3; +pub const SIOCATMARK: c_long = IOC_OUT | ((4 & IOCPARM_MASK) << 16) | (0x73 << 8) | 7; +STRUCT!{struct hostent { + h_name: *mut c_char, + h_aliases: *mut *mut c_char, + h_addrtype: c_short, + h_length: c_short, + h_addr_list: *mut *mut c_char, +}} +STRUCT!{struct netent { + n_name: *mut c_char, + n_aliases: *mut *mut c_char, + n_addrtype: c_short, + n_net: u_long, +}} +#[cfg(target_pointer_width = "32")] +STRUCT!{struct servent { + s_name: *mut c_char, + s_aliases: *mut *mut c_char, + s_port: c_short, + s_proto: *mut c_char, +}} +#[cfg(target_pointer_width = "64")] +STRUCT!{struct servent { + s_name: *mut c_char, + s_aliases: *mut *mut c_char, + s_proto: *mut c_char, + s_port: c_short, +}} +STRUCT!{struct protoent { + p_name: *mut c_char, + p_aliases: *mut *mut c_char, + p_proto: c_short, +}} +pub const IPPORT_ECHO: c_short = 7; +pub const IPPORT_DISCARD: c_short = 9; +pub const IPPORT_SYSTAT: c_short = 11; +pub const IPPORT_DAYTIME: c_short = 13; +pub const IPPORT_NETSTAT: c_short = 15; +pub const IPPORT_FTP: c_short = 21; +pub const IPPORT_TELNET: c_short = 23; +pub const IPPORT_SMTP: c_short = 25; +pub const IPPORT_TIMESERVER: c_short = 37; +pub const IPPORT_NAMESERVER: c_short = 42; +pub const IPPORT_WHOIS: c_short = 43; +pub const IPPORT_MTP: c_short = 57; +pub const IPPORT_TFTP: c_short = 69; +pub const IPPORT_RJE: c_short = 77; +pub const IPPORT_FINGER: c_short = 79; +pub const IPPORT_TTYLINK: c_short = 87; +pub const IPPORT_SUPDUP: c_short = 95; +pub const IPPORT_EXECSERVER: c_short = 512; +pub const IPPORT_LOGINSERVER: c_short = 513; +pub const IPPORT_CMDSERVER: c_short = 514; +pub const IPPORT_EFSSERVER: c_short = 520; +pub const IPPORT_BIFFUDP: c_short = 512; +pub const IPPORT_WHOSERVER: c_short = 513; +pub const IPPORT_ROUTESERVER: c_short = 520; +pub const IPPORT_RESERVED: c_short = 1024; +pub const IMPLINK_IP: c_short = 155; +pub const IMPLINK_LOWEXPER: c_short = 156; +pub const IMPLINK_HIGHEXPER: c_short = 158; +pub const ADDR_ANY: ULONG = INADDR_ANY; +pub const WSADESCRIPTION_LEN: usize = 256; +pub const WSASYS_STATUS_LEN: usize = 128; +#[cfg(target_pointer_width = "32")] +STRUCT!{struct WSADATA { + wVersion: WORD, + wHighVersion: WORD, + szDescription: [c_char; WSADESCRIPTION_LEN + 1], + szSystemStatus: [c_char; WSASYS_STATUS_LEN + 1], + iMaxSockets: c_ushort, + iMaxUdpDg: c_ushort, + lpVendorInfo: *mut c_char, +}} +#[cfg(target_pointer_width = "64")] +STRUCT!{struct WSADATA { + wVersion: WORD, + wHighVersion: WORD, + iMaxSockets: c_ushort, + iMaxUdpDg: c_ushort, + lpVendorInfo: *mut c_char, + szDescription: [c_char; WSADESCRIPTION_LEN + 1], + szSystemStatus: [c_char; WSASYS_STATUS_LEN + 1], +}} +pub type LPWSADATA = *mut WSADATA; +pub const INVALID_SOCKET: SOCKET = !0; +pub const SOCKET_ERROR: c_int = -1; +pub const FROM_PROTOCOL_INFO: c_int = -1; +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SO_DEBUG: c_int = 0x0001; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_DONTLINGER: c_int = !SO_LINGER; +pub const SO_EXCLUSIVEADDRUSE: c_int = !SO_REUSEADDR; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; +pub const SO_GROUP_ID: c_int = 0x2001; +pub const SO_GROUP_PRIORITY: c_int = 0x2002; +pub const SO_MAX_MSG_SIZE: c_int = 0x2003; +pub const SO_PROTOCOL_INFOA: c_int = 0x2004; +pub const SO_PROTOCOL_INFOW: c_int = 0x2005; +pub const PVD_CONFIG: c_int = 0x3001; +pub const SO_CONDITIONAL_ACCEPT: c_int = 0x3002; +STRUCT!{struct sockproto { + sp_family: u_short, + sp_protocol: u_short, +}} +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_UNIX: c_int = AF_UNIX; +pub const PF_INET: c_int = AF_INET; +pub const PF_IMPLINK: c_int = AF_IMPLINK; +pub const PF_PUP: c_int = AF_PUP; +pub const PF_CHAOS: c_int = AF_CHAOS; +pub const PF_NS: c_int = AF_NS; +pub const PF_IPX: c_int = AF_IPX; +pub const PF_ISO: c_int = AF_ISO; +pub const PF_OSI: c_int = AF_OSI; +pub const PF_ECMA: c_int = AF_ECMA; +pub const PF_DATAKIT: c_int = AF_DATAKIT; +pub const PF_CCITT: c_int = AF_CCITT; +pub const PF_SNA: c_int = AF_SNA; +pub const PF_DECnet: c_int = AF_DECnet; +pub const PF_DLI: c_int = AF_DLI; +pub const PF_LAT: c_int = AF_LAT; +pub const PF_HYLINK: c_int = AF_HYLINK; +pub const PF_APPLETALK: c_int = AF_APPLETALK; +pub const PF_VOICEVIEW: c_int = AF_VOICEVIEW; +pub const PF_FIREFOX: c_int = AF_FIREFOX; +pub const PF_UNKNOWN1: c_int = AF_UNKNOWN1; +pub const PF_BAN: c_int = AF_BAN; +pub const PF_ATM: c_int = AF_ATM; +pub const PF_INET6: c_int = AF_INET6; +pub const PF_BTH: c_int = AF_BTH; +pub const PF_MAX: c_int = AF_MAX; +STRUCT!{struct linger { + l_onoff: u_short, + l_linger: u_short, +}} +pub const SOL_SOCKET: c_int = 0xffff; +pub const SOMAXCONN: c_int = 0x7fffffff; +#[inline] +pub fn SOMAXCONN_HINT(b: c_int) -> c_int { + -b +} +pub const MSG_OOB: c_int = 0x1; +pub const MSG_PEEK: c_int = 0x2; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_WAITALL: c_int = 0x8; +pub const MSG_PUSH_IMMEDIATE: c_int = 0x20; +pub const MSG_PARTIAL: c_int = 0x8000; +pub const MSG_INTERRUPT: c_int = 0x10; +pub const MSG_MAXIOVLEN: c_int = 16; +pub const MAXGETHOSTSTRUCT: usize = 1024; +pub const FD_READ_BIT: c_long = 0; +pub const FD_READ: c_long = 1 << FD_READ_BIT; +pub const FD_WRITE_BIT: c_long = 1; +pub const FD_WRITE: c_long = 1 << FD_WRITE_BIT; +pub const FD_OOB_BIT: c_long = 2; +pub const FD_OOB: c_long = 1 << FD_OOB_BIT; +pub const FD_ACCEPT_BIT: c_long = 3; +pub const FD_ACCEPT: c_long = 1 << FD_ACCEPT_BIT; +pub const FD_CONNECT_BIT: c_long = 4; +pub const FD_CONNECT: c_long = 1 << FD_CONNECT_BIT; +pub const FD_CLOSE_BIT: c_long = 5; +pub const FD_CLOSE: c_long = 1 << FD_CLOSE_BIT; +pub const FD_QOS_BIT: c_long = 6; +pub const FD_QOS: c_long = 1 << FD_QOS_BIT; +pub const FD_GROUP_QOS_BIT: c_long = 7; +pub const FD_GROUP_QOS: c_long = 1 << FD_GROUP_QOS_BIT; +pub const FD_ROUTING_INTERFACE_CHANGE_BIT: c_long = 8; +pub const FD_ROUTING_INTERFACE_CHANGE: c_long = 1 << FD_ROUTING_INTERFACE_CHANGE_BIT; +pub const FD_ADDRESS_LIST_CHANGE_BIT: c_long = 9; +pub const FD_ADDRESS_LIST_CHANGE: c_long = 1 << FD_ADDRESS_LIST_CHANGE_BIT; +pub const FD_MAX_EVENTS: usize = 10; +pub const FD_ALL_EVENTS: c_long = (1 << FD_MAX_EVENTS) - 1; +pub const WSABASEERR: c_int = 10000; +pub const WSAEINTR: c_int = WSABASEERR+4; +pub const WSAEBADF: c_int = WSABASEERR+9; +pub const WSAEACCES: c_int = WSABASEERR+13; +pub const WSAEFAULT: c_int = WSABASEERR+14; +pub const WSAEINVAL: c_int = WSABASEERR+22; +pub const WSAEMFILE: c_int = WSABASEERR+24; +pub const WSAEWOULDBLOCK: c_int = WSABASEERR+35; +pub const WSAEINPROGRESS: c_int = WSABASEERR+36; +pub const WSAEALREADY: c_int = WSABASEERR+37; +pub const WSAENOTSOCK: c_int = WSABASEERR+38; +pub const WSAEDESTADDRREQ: c_int = WSABASEERR+39; +pub const WSAEMSGSIZE: c_int = WSABASEERR+40; +pub const WSAEPROTOTYPE: c_int = WSABASEERR+41; +pub const WSAENOPROTOOPT: c_int = WSABASEERR+42; +pub const WSAEPROTONOSUPPORT: c_int = WSABASEERR+43; +pub const WSAESOCKTNOSUPPORT: c_int = WSABASEERR+44; +pub const WSAEOPNOTSUPP: c_int = WSABASEERR+45; +pub const WSAEPFNOSUPPORT: c_int = WSABASEERR+46; +pub const WSAEAFNOSUPPORT: c_int = WSABASEERR+47; +pub const WSAEADDRINUSE: c_int = WSABASEERR+48; +pub const WSAEADDRNOTAVAIL: c_int = WSABASEERR+49; +pub const WSAENETDOWN: c_int = WSABASEERR+50; +pub const WSAENETUNREACH: c_int = WSABASEERR+51; +pub const WSAENETRESET: c_int = WSABASEERR+52; +pub const WSAECONNABORTED: c_int = WSABASEERR+53; +pub const WSAECONNRESET: c_int = WSABASEERR+54; +pub const WSAENOBUFS: c_int = WSABASEERR+55; +pub const WSAEISCONN: c_int = WSABASEERR+56; +pub const WSAENOTCONN: c_int = WSABASEERR+57; +pub const WSAESHUTDOWN: c_int = WSABASEERR+58; +pub const WSAETOOMANYREFS: c_int = WSABASEERR+59; +pub const WSAETIMEDOUT: c_int = WSABASEERR+60; +pub const WSAECONNREFUSED: c_int = WSABASEERR+61; +pub const WSAELOOP: c_int = WSABASEERR+62; +pub const WSAENAMETOOLONG: c_int = WSABASEERR+63; +pub const WSAEHOSTDOWN: c_int = WSABASEERR+64; +pub const WSAEHOSTUNREACH: c_int = WSABASEERR+65; +pub const WSAENOTEMPTY: c_int = WSABASEERR+66; +pub const WSAEPROCLIM: c_int = WSABASEERR+67; +pub const WSAEUSERS: c_int = WSABASEERR+68; +pub const WSAEDQUOT: c_int = WSABASEERR+69; +pub const WSAESTALE: c_int = WSABASEERR+70; +pub const WSAEREMOTE: c_int = WSABASEERR+71; +pub const WSASYSNOTREADY: c_int = WSABASEERR+91; +pub const WSAVERNOTSUPPORTED: c_int = WSABASEERR+92; +pub const WSANOTINITIALISED: c_int = WSABASEERR+93; +pub const WSAEDISCON: c_int = WSABASEERR+101; +pub const WSAENOMORE: c_int = WSABASEERR+102; +pub const WSAECANCELLED: c_int = WSABASEERR+103; +pub const WSAEINVALIDPROCTABLE: c_int = WSABASEERR+104; +pub const WSAEINVALIDPROVIDER: c_int = WSABASEERR+105; +pub const WSAEPROVIDERFAILEDINIT: c_int = WSABASEERR+106; +pub const WSASYSCALLFAILURE: c_int = WSABASEERR+107; +pub const WSASERVICE_NOT_FOUND: c_int = WSABASEERR+108; +pub const WSATYPE_NOT_FOUND: c_int = WSABASEERR+109; +pub const WSA_E_NO_MORE: c_int = WSABASEERR+110; +pub const WSA_E_CANCELLED: c_int = WSABASEERR+111; +pub const WSAEREFUSED: c_int = WSABASEERR+112; +pub const WSAHOST_NOT_FOUND: c_int = WSABASEERR+1001; +pub const WSATRY_AGAIN: c_int = WSABASEERR+1002; +pub const WSANO_RECOVERY: c_int = WSABASEERR+1003; +pub const WSANO_DATA: c_int = WSABASEERR+1004; +pub const WSA_QOS_RECEIVERS: c_int = WSABASEERR + 1005; +pub const WSA_QOS_SENDERS: c_int = WSABASEERR + 1006; +pub const WSA_QOS_NO_SENDERS: c_int = WSABASEERR + 1007; +pub const WSA_QOS_NO_RECEIVERS: c_int = WSABASEERR + 1008; +pub const WSA_QOS_REQUEST_CONFIRMED: c_int = WSABASEERR + 1009; +pub const WSA_QOS_ADMISSION_FAILURE: c_int = WSABASEERR + 1010; +pub const WSA_QOS_POLICY_FAILURE: c_int = WSABASEERR + 1011; +pub const WSA_QOS_BAD_STYLE: c_int = WSABASEERR + 1012; +pub const WSA_QOS_BAD_OBJECT: c_int = WSABASEERR + 1013; +pub const WSA_QOS_TRAFFIC_CTRL_ERROR: c_int = WSABASEERR + 1014; +pub const WSA_QOS_GENERIC_ERROR: c_int = WSABASEERR + 1015; +pub const WSA_QOS_ESERVICETYPE: c_int = WSABASEERR + 1016; +pub const WSA_QOS_EFLOWSPEC: c_int = WSABASEERR + 1017; +pub const WSA_QOS_EPROVSPECBUF: c_int = WSABASEERR + 1018; +pub const WSA_QOS_EFILTERSTYLE: c_int = WSABASEERR + 1019; +pub const WSA_QOS_EFILTERTYPE: c_int = WSABASEERR + 1020; +pub const WSA_QOS_EFILTERCOUNT: c_int = WSABASEERR + 1021; +pub const WSA_QOS_EOBJLENGTH: c_int = WSABASEERR + 1022; +pub const WSA_QOS_EFLOWCOUNT: c_int = WSABASEERR + 1023; +pub const WSA_QOS_EUNKOWNPSOBJ: c_int = WSABASEERR + 1024; +pub const WSA_QOS_EPOLICYOBJ: c_int = WSABASEERR + 1025; +pub const WSA_QOS_EFLOWDESC: c_int = WSABASEERR + 1026; +pub const WSA_QOS_EPSFLOWSPEC: c_int = WSABASEERR + 1027; +pub const WSA_QOS_EPSFILTERSPEC: c_int = WSABASEERR + 1028; +pub const WSA_QOS_ESDMODEOBJ: c_int = WSABASEERR + 1029; +pub const WSA_QOS_ESHAPERATEOBJ: c_int = WSABASEERR + 1030; +pub const WSA_QOS_RESERVED_PETYPE: c_int = WSABASEERR + 1031; +#[inline] +pub unsafe fn h_errno() -> c_int { + WSAGetLastError() +} +pub const HOST_NOT_FOUND: c_int = WSAHOST_NOT_FOUND; +pub const TRY_AGAIN: c_int = WSATRY_AGAIN; +pub const NO_RECOVERY: c_int = WSANO_RECOVERY; +pub const NO_DATA: c_int = WSANO_DATA; +pub const WSANO_ADDRESS: c_int = WSANO_DATA; +pub const NO_ADDRESS: c_int = WSANO_ADDRESS; +pub type WSAEVENT = HANDLE; +pub type LPWSAEVENT = LPHANDLE; +pub type WSAOVERLAPPED = OVERLAPPED; +pub type LPWSAOVERLAPPED = *mut OVERLAPPED; +pub const WSA_IO_PENDING: c_int = ERROR_IO_PENDING as i32; +pub const WSA_IO_INCOMPLETE: c_int = ERROR_IO_INCOMPLETE as i32; +pub const WSA_INVALID_HANDLE: c_int = ERROR_INVALID_HANDLE as i32; +pub const WSA_INVALID_PARAMETER: c_int = ERROR_INVALID_PARAMETER as i32; +pub const WSA_NOT_ENOUGH_MEMORY: c_int = ERROR_NOT_ENOUGH_MEMORY as i32; +pub const WSA_OPERATION_ABORTED: c_int = ERROR_OPERATION_ABORTED as i32; +pub const WSA_INVALID_EVENT: WSAEVENT = 0 as WSAEVENT; +pub const WSA_MAXIMUM_WAIT_EVENTS: DWORD = MAXIMUM_WAIT_OBJECTS; +pub const WSA_WAIT_FAILED: DWORD = WAIT_FAILED; +pub const WSA_WAIT_EVENT_0: DWORD = WAIT_OBJECT_0; +pub const WSA_WAIT_IO_COMPLETION: DWORD = WAIT_IO_COMPLETION; +pub const WSA_WAIT_TIMEOUT: DWORD = WAIT_TIMEOUT; +pub const WSA_INFINITE: DWORD = INFINITE; +STRUCT!{struct QOS { + SendingFlowspec: FLOWSPEC, + FLOWSPEC: FLOWSPEC, + ProviderSpecific: WSABUF, +}} +pub type LPQOS = *mut QOS; +pub const CF_ACCEPT: c_int = 0x0000; +pub const CF_REJECT: c_int = 0x0001; +pub const CF_DEFER: c_int = 0x0002; +pub const SD_RECEIVE: c_int = 0x00; +pub const SD_SEND: c_int = 0x01; +pub const SD_BOTH: c_int = 0x02; +pub type GROUP = c_uint; +pub const SG_UNCONSTRAINED_GROUP: GROUP = 0x01; +pub const SG_CONSTRAINED_GROUP: GROUP = 0x02; +STRUCT!{struct WSANETWORKEVENTS { + lNetworkEvents: c_long, + iErrorCode: [c_int; FD_MAX_EVENTS], +}} +pub type LPWSANETWORKEVENTS = *mut WSANETWORKEVENTS; +pub const MAX_PROTOCOL_CHAIN: usize = 7; +pub const BASE_PROTOCOL: c_int = 1; +pub const LAYERED_PROTOCOL: c_int = 0; +STRUCT!{struct WSAPROTOCOLCHAIN { + ChainLen: c_int, + ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN], +}} +pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; +pub const WSAPROTOCOL_LEN: usize = 255; +STRUCT!{struct WSAPROTOCOL_INFOA { + dwServiceFlags1: DWORD, + dwServiceFlags2: DWORD, + dwServiceFlags3: DWORD, + dwServiceFlags4: DWORD, + dwServiceFlags5: DWORD, + ProviderId: GUID, + dwCatalogEntryId: DWORD, + ProtocolChain: WSAPROTOCOLCHAIN, + iVersion: c_int, + iAddressFamily: c_int, + iMaxSockAddr: c_int, + iMinSockAddr: c_int, + iSocketType: c_int, + iProtocol: c_int, + iProtocolMaxOffset: c_int, + iNetworkByteOrder: c_int, + iSecurityScheme: c_int, + dwMessageSize: DWORD, + dwProviderReserved: DWORD, + szProtocol: [CHAR; WSAPROTOCOL_LEN + 1], +}} +pub type LPWSAPROTOCOL_INFOA = *mut WSAPROTOCOL_INFOA; +STRUCT!{struct WSAPROTOCOL_INFOW { + dwServiceFlags1: DWORD, + dwServiceFlags2: DWORD, + dwServiceFlags3: DWORD, + dwServiceFlags4: DWORD, + dwServiceFlags5: DWORD, + ProviderId: GUID, + dwCatalogEntryId: DWORD, + ProtocolChain: WSAPROTOCOLCHAIN, + iVersion: c_int, + iAddressFamily: c_int, + iMaxSockAddr: c_int, + iMinSockAddr: c_int, + iSocketType: c_int, + iProtocol: c_int, + iProtocolMaxOffset: c_int, + iNetworkByteOrder: c_int, + iSecurityScheme: c_int, + dwMessageSize: DWORD, + dwProviderReserved: DWORD, + szProtocol: [WCHAR; WSAPROTOCOL_LEN + 1], +}} +pub type LPWSAPROTOCOL_INFOW = *mut WSAPROTOCOL_INFOW; +pub const PFL_MULTIPLE_PROTO_ENTRIES: DWORD = 0x00000001; +pub const PFL_RECOMMENDED_PROTO_ENTRY: DWORD = 0x00000002; +pub const PFL_HIDDEN: DWORD = 0x00000004; +pub const PFL_MATCHES_PROTOCOL_ZERO: DWORD = 0x00000008; +pub const PFL_NETWORKDIRECT_PROVIDER: DWORD = 0x00000010; +pub const XP1_CONNECTIONLESS: DWORD = 0x00000001; +pub const XP1_GUARANTEED_DELIVERY: DWORD = 0x00000002; +pub const XP1_GUARANTEED_ORDER: DWORD = 0x00000004; +pub const XP1_MESSAGE_ORIENTED: DWORD = 0x00000008; +pub const XP1_PSEUDO_STREAM: DWORD = 0x00000010; +pub const XP1_GRACEFUL_CLOSE: DWORD = 0x00000020; +pub const XP1_EXPEDITED_DATA: DWORD = 0x00000040; +pub const XP1_CONNECT_DATA: DWORD = 0x00000080; +pub const XP1_DISCONNECT_DATA: DWORD = 0x00000100; +pub const XP1_SUPPORT_BROADCAST: DWORD = 0x00000200; +pub const XP1_SUPPORT_MULTIPOINT: DWORD = 0x00000400; +pub const XP1_MULTIPOINT_CONTROL_PLANE: DWORD = 0x00000800; +pub const XP1_MULTIPOINT_DATA_PLANE: DWORD = 0x00001000; +pub const XP1_QOS_SUPPORTED: DWORD = 0x00002000; +pub const XP1_INTERRUPT: DWORD = 0x00004000; +pub const XP1_UNI_SEND: DWORD = 0x00008000; +pub const XP1_UNI_RECV: DWORD = 0x00010000; +pub const XP1_IFS_HANDLES: DWORD = 0x00020000; +pub const XP1_PARTIAL_MESSAGE: DWORD = 0x00040000; +pub const XP1_SAN_SUPPORT_SDP: DWORD = 0x00080000; +pub const BIGENDIAN: DWORD = 0x0000; +pub const LITTLEENDIAN: DWORD = 0x0001; +pub const SECURITY_PROTOCOL_NONE: DWORD = 0x0000; +pub const JL_SENDER_ONLY: DWORD = 0x01; +pub const JL_RECEIVER_ONLY: DWORD = 0x02; +pub const JL_BOTH: DWORD = 0x04; +pub const WSA_FLAG_OVERLAPPED: DWORD = 0x01; +pub const WSA_FLAG_MULTIPOINT_C_ROOT: DWORD = 0x02; +pub const WSA_FLAG_MULTIPOINT_C_LEAF: DWORD = 0x04; +pub const WSA_FLAG_MULTIPOINT_D_ROOT: DWORD = 0x08; +pub const WSA_FLAG_MULTIPOINT_D_LEAF: DWORD = 0x10; +pub const WSA_FLAG_ACCESS_SYSTEM_SECURITY: DWORD = 0x40; +pub const WSA_FLAG_NO_HANDLE_INHERIT: DWORD = 0x80; +pub const WSA_FLAG_REGISTERED_IO: DWORD = 0x100; +FN!{stdcall LPCONDITIONPROC( + lpCallerId: LPWSABUF, + lpCallerData: LPWSABUF, + lpSQOS: LPQOS, + lpGQOS: LPQOS, + lpCalleeId: LPWSABUF, + lpCalleeData: LPWSABUF, + g: *mut GROUP, + dwCallbackData: DWORD, +) -> c_int} +FN!{stdcall LPWSAOVERLAPPED_COMPLETION_ROUTINE( + dwError: DWORD, + cbTransferred: DWORD, + lpOverlapped: LPWSAOVERLAPPED, + dwFlags: DWORD, +) -> ()} +ENUM!{enum WSACOMPLETIONTYPE { + NSP_NOTIFY_IMMEDIATELY = 0, + NSP_NOTIFY_HWND, + NSP_NOTIFY_EVENT, + NSP_NOTIFY_PORT, + NSP_NOTIFY_APC, +}} +pub type PWSACOMPLETIONTYPE = *mut WSACOMPLETIONTYPE; +pub type LPWSACOMPLETIONTYPE = *mut WSACOMPLETIONTYPE; +STRUCT!{struct WSACOMPLETION_WindowMessage { + hWnd: HWND, + uMsg: UINT, + context: WPARAM, +}} +STRUCT!{struct WSACOMPLETION_Event { + lpOverlapped: LPWSAOVERLAPPED, +}} +STRUCT!{struct WSACOMPLETION_Apc { + lpOverlapped: LPWSAOVERLAPPED, + lpfnCompletionProc: LPWSAOVERLAPPED_COMPLETION_ROUTINE, +}} +STRUCT!{struct WSACOMPLETION_Port { + lpOverlapped: LPWSAOVERLAPPED, + hPort: HANDLE, + Key: ULONG_PTR, +}} +UNION!{union WSACOMPLETION_Parameter { + [usize; 3], + WindowMessage WindowMessage_mut: WSACOMPLETION_WindowMessage, + Event Event_mut: WSACOMPLETION_Event, + Apc Apc_mut: WSACOMPLETION_Apc, + Port Port_mut: WSACOMPLETION_Port, +}} +STRUCT!{struct WSACOMPLETION { + Type: WSACOMPLETIONTYPE, + Parameters: WSACOMPLETION_Parameter, +}} +pub type PWSACOMPLETION = *mut WSACOMPLETION; +pub type LPWSACOMPLETION = *mut WSACOMPLETION; +pub const TH_NETDEV: DWORD = 0x00000001; +pub const TH_TAPI: DWORD = 0x00000002; +pub const SERVICE_MULTIPLE: DWORD = 0x00000001; +pub const NS_ALL: DWORD = 0; +pub const NS_SAP: DWORD = 1; +pub const NS_NDS: DWORD = 2; +pub const NS_PEER_BROWSE: DWORD = 3; +pub const NS_SLP: DWORD = 5; +pub const NS_DHCP: DWORD = 6; +pub const NS_TCPIP_LOCAL: DWORD = 10; +pub const NS_TCPIP_HOSTS: DWORD = 11; +pub const NS_DNS: DWORD = 12; +pub const NS_NETBT: DWORD = 13; +pub const NS_WINS: DWORD = 14; +pub const NS_NLA: DWORD = 15; +pub const NS_BTH: DWORD = 16; +pub const NS_LOCALNAME: DWORD = 19; +pub const NS_NBP: DWORD = 20; +pub const NS_MS: DWORD = 30; +pub const NS_STDA: DWORD = 31; +pub const NS_NTDS: DWORD = 32; +pub const NS_EMAIL: DWORD = 37; +pub const NS_PNRPNAME: DWORD = 38; +pub const NS_PNRPCLOUD: DWORD = 39; +pub const NS_X500: DWORD = 40; +pub const NS_NIS: DWORD = 41; +pub const NS_NISPLUS: DWORD = 42; +pub const NS_WRQ: DWORD = 50; +pub const NS_NETDES: DWORD = 60; +pub const RES_UNUSED_1: DWORD = 0x00000001; +pub const RES_FLUSH_CACHE: DWORD = 0x00000002; +pub const RES_SERVICE: DWORD = 0x00000004; +pub const SERVICE_TYPE_VALUE_IPXPORT: &'static str = "IpxSocket"; +pub const SERVICE_TYPE_VALUE_SAPID: &'static str = "SapId"; +pub const SERVICE_TYPE_VALUE_TCPPORT: &'static str = "TcpPort"; +pub const SERVICE_TYPE_VALUE_UDPPORT: &'static str = "UdpPort"; +pub const SERVICE_TYPE_VALUE_OBJECTID: &'static str = "ObjectId"; +STRUCT!{struct AFPROTOCOLS { + iAddressFamily: INT, + iProtocol: INT, +}} +pub type PAFPROTOCOLS = *mut AFPROTOCOLS; +pub type LPAFPROTOCOLS = *mut AFPROTOCOLS; +ENUM!{enum WSAECOMPARATOR { + COMP_EQUAL = 0, + COMP_NOTLESS, +}} +pub type PWSAECOMPARATOR = *mut WSAECOMPARATOR; +pub type LPWSAECOMPARATOR = *mut WSAECOMPARATOR; +STRUCT!{struct WSAVERSION { + dwVersion: DWORD, + ecHow: WSAECOMPARATOR, +}} +pub type PWSAVERSION = *mut WSAVERSION; +pub type LPWSAVERSION = *mut WSAVERSION; +STRUCT!{struct WSAQUERYSETA { + dwSize: DWORD, + lpszServiceInstanceName: LPSTR, + lpServiceClassId: LPGUID, + lpVersion: LPWSAVERSION, + lpszComment: LPSTR, + dwNameSpace: DWORD, + lpNSProviderId: LPGUID, + lpszContext: LPSTR, + dwNumberOfProtocols: DWORD, + lpafpProtocols: LPAFPROTOCOLS, + lpszQueryString: LPSTR, + dwNumberOfCsAddrs: DWORD, + lpcsaBuffer: LPCSADDR_INFO, + dwOutputFlags: DWORD, + lpBlob: LPBLOB, +}} +pub type PWSAQUERYSETA = *mut WSAQUERYSETA; +pub type LPWSAQUERYSETA = *mut WSAQUERYSETA; +STRUCT!{struct WSAQUERYSETW { + dwSize: DWORD, + lpszServiceInstanceName: LPWSTR, + lpServiceClassId: LPGUID, + lpVersion: LPWSAVERSION, + lpszComment: LPWSTR, + dwNameSpace: DWORD, + lpNSProviderId: LPGUID, + lpszContext: LPWSTR, + dwNumberOfProtocols: DWORD, + lpafpProtocols: LPAFPROTOCOLS, + lpszQueryString: LPWSTR, + dwNumberOfCsAddrs: DWORD, + lpcsaBuffer: LPCSADDR_INFO, + dwOutputFlags: DWORD, + lpBlob: LPBLOB, +}} +pub type PWSAQUERYSETW = *mut WSAQUERYSETW; +pub type LPWSAQUERYSETW = *mut WSAQUERYSETW; +STRUCT!{struct WSAQUERYSET2A { + dwSize: DWORD, + lpszServiceInstanceName: LPSTR, + lpVersion: LPWSAVERSION, + lpszComment: LPSTR, + dwNameSpace: DWORD, + lpNSProviderId: LPGUID, + lpszContext: LPSTR, + dwNumberOfProtocols: DWORD, + lpafpProtocols: LPAFPROTOCOLS, + lpszQueryString: LPSTR, + dwNumberOfCsAddrs: DWORD, + lpcsaBuffer: LPCSADDR_INFO, + dwOutputFlags: DWORD, + lpBlob: LPBLOB, +}} +pub type PWSAQUERYSET2A = *mut WSAQUERYSET2A; +pub type LPWSAQUERYSET2A = *mut WSAQUERYSET2A; +STRUCT!{struct WSAQUERYSET2W { + dwSize: DWORD, + lpszServiceInstanceName: LPWSTR, + lpVersion: LPWSAVERSION, + lpszComment: LPWSTR, + dwNameSpace: DWORD, + lpNSProviderId: LPGUID, + lpszContext: LPWSTR, + dwNumberOfProtocols: DWORD, + lpafpProtocols: LPAFPROTOCOLS, + lpszQueryString: LPWSTR, + dwNumberOfCsAddrs: DWORD, + lpcsaBuffer: LPCSADDR_INFO, + dwOutputFlags: DWORD, + lpBlob: LPBLOB, +}} +pub type PWSAQUERYSET2W = *mut WSAQUERYSET2W; +pub type LPWSAQUERYSET2W = *mut WSAQUERYSET2W; +pub const LUP_DEEP: DWORD = 0x0001; +pub const LUP_CONTAINERS: DWORD = 0x0002; +pub const LUP_NOCONTAINERS: DWORD = 0x0004; +pub const LUP_NEAREST: DWORD = 0x0008; +pub const LUP_RETURN_NAME: DWORD = 0x0010; +pub const LUP_RETURN_TYPE: DWORD = 0x0020; +pub const LUP_RETURN_VERSION: DWORD = 0x0040; +pub const LUP_RETURN_COMMENT: DWORD = 0x0080; +pub const LUP_RETURN_ADDR: DWORD = 0x0100; +pub const LUP_RETURN_BLOB: DWORD = 0x0200; +pub const LUP_RETURN_ALIASES: DWORD = 0x0400; +pub const LUP_RETURN_QUERY_STRING: DWORD = 0x0800; +pub const LUP_RETURN_ALL: DWORD = 0x0FF0; +pub const LUP_RES_SERVICE: DWORD = 0x8000; +pub const LUP_FLUSHCACHE: DWORD = 0x1000; +pub const LUP_FLUSHPREVIOUS: DWORD = 0x2000; +pub const LUP_NON_AUTHORITATIVE: DWORD = 0x4000; +pub const LUP_SECURE: DWORD = 0x8000; +pub const LUP_RETURN_PREFERRED_NAMES: DWORD = 0x10000; +pub const LUP_DNS_ONLY: DWORD = 0x20000; +pub const LUP_ADDRCONFIG: DWORD = 0x00100000; +pub const LUP_DUAL_ADDR: DWORD = 0x00200000; +pub const LUP_FILESERVER: DWORD = 0x00400000; +pub const LUP_DISABLE_IDN_ENCODING: DWORD = 0x00800000; +pub const LUP_API_ANSI: DWORD = 0x01000000; +pub const LUP_RESOLUTION_HANDLE: DWORD = 0x80000000; +pub const RESULT_IS_ALIAS: DWORD = 0x0001; +pub const RESULT_IS_ADDED: DWORD = 0x0010; +pub const RESULT_IS_CHANGED: DWORD = 0x0020; +pub const RESULT_IS_DELETED: DWORD = 0x0040; +ENUM!{enum WSAESETSERVICEOP { + RNRSERVICE_REGISTER = 0, + RNRSERVICE_DEREGISTER, + RNRSERVICE_DELETE, +}} +pub type PWSAESETSERVICEOP = *mut WSAESETSERVICEOP; +pub type LPWSAESETSERVICEOP = *mut WSAESETSERVICEOP; +STRUCT!{struct WSANSCLASSINFOA { + lpszName: LPSTR, + dwNameSpace: DWORD, + dwValueType: DWORD, + dwValueSize: DWORD, + lpValue: LPVOID, +}} +pub type PWSANSCLASSINFOA = *mut WSANSCLASSINFOA; +pub type LPWSANSCLASSINFOA = *mut WSANSCLASSINFOA; +STRUCT!{struct WSANSCLASSINFOW { + lpszName: LPWSTR, + dwNameSpace: DWORD, + dwValueType: DWORD, + dwValueSize: DWORD, + lpValue: LPVOID, +}} +pub type PWSANSCLASSINFOW = *mut WSANSCLASSINFOW; +pub type LPWSANSCLASSINFOW = *mut WSANSCLASSINFOW; +STRUCT!{struct WSASERVICECLASSINFOA { + lpServiceClassId: LPGUID, + lpszServiceClassName: LPSTR, + dwCount: DWORD, + lpClassInfos: LPWSANSCLASSINFOA, +}} +pub type PWSASERVICECLASSINFOA = *mut WSASERVICECLASSINFOA; +pub type LPWSASERVICECLASSINFOA = *mut WSASERVICECLASSINFOA; +STRUCT!{struct WSASERVICECLASSINFOW { + lpServiceClassId: LPGUID, + lpszServiceClassName: LPWSTR, + dwCount: DWORD, + lpClassInfos: LPWSANSCLASSINFOW, +}} +pub type PWSASERVICECLASSINFOW = *mut WSASERVICECLASSINFOW; +pub type LPWSASERVICECLASSINFOW = *mut WSASERVICECLASSINFOW; +STRUCT!{struct WSANAMESPACE_INFOA { + NSProviderId: GUID, + dwNameSpace: DWORD, + fActive: BOOL, + dwVersion: DWORD, + lpszIdentifier: LPSTR, +}} +pub type PWSANAMESPACE_INFOA = *mut WSANAMESPACE_INFOA; +pub type LPWSANAMESPACE_INFOA = *mut WSANAMESPACE_INFOA; +STRUCT!{struct WSANAMESPACE_INFOW { + NSProviderId: GUID, + dwNameSpace: DWORD, + fActive: BOOL, + dwVersion: DWORD, + lpszIdentifier: LPWSTR, +}} +pub type PWSANAMESPACE_INFOW = *mut WSANAMESPACE_INFOW; +pub type LPWSANAMESPACE_INFOW = *mut WSANAMESPACE_INFOW; +STRUCT!{struct WSANAMESPACE_INFOEXA { + NSProviderId: GUID, + dwNameSpace: DWORD, + fActive: BOOL, + dwVersion: DWORD, + lpszIdentifier: LPSTR, + ProviderSpecific: BLOB, +}} +pub type PWSANAMESPACE_INFOEXA = *mut WSANAMESPACE_INFOEXA; +pub type LPWSANAMESPACE_INFOEXA = *mut WSANAMESPACE_INFOEXA; +STRUCT!{struct WSANAMESPACE_INFOEXW { + NSProviderId: GUID, + dwNameSpace: DWORD, + fActive: BOOL, + dwVersion: DWORD, + lpszIdentifier: LPWSTR, + ProviderSpecific: BLOB, +}} +pub type PWSANAMESPACE_INFOEXW = *mut WSANAMESPACE_INFOEXW; +pub type LPWSANAMESPACE_INFOEXW = *mut WSANAMESPACE_INFOEXW; +pub const POLLRDNORM: SHORT = 0x0100; +pub const POLLRDBAND: SHORT = 0x0200; +pub const POLLIN: SHORT = POLLRDNORM | POLLRDBAND; +pub const POLLPRI: SHORT = 0x0400; +pub const POLLWRNORM: SHORT = 0x0010; +pub const POLLOUT: SHORT = POLLWRNORM; +pub const POLLWRBAND: SHORT = 0x0020; +pub const POLLERR: SHORT = 0x0001; +pub const POLLHUP: SHORT = 0x0002; +pub const POLLNVAL: SHORT = 0x0004; +STRUCT!{struct WSAPOLLFD { + fd: SOCKET, + events: SHORT, + revents: SHORT, +}} +pub type PWSAPOLLFD = *mut WSAPOLLFD; +pub type LPWSAPOLLFD = *mut WSAPOLLFD; +extern "system" { + pub fn accept( + s: SOCKET, + addr: *mut SOCKADDR, + addrlen: *mut c_int, + ) -> SOCKET; + pub fn bind(s: SOCKET, + name: *const SOCKADDR, + namelen: c_int, + ) -> c_int; + pub fn closesocket( + s: SOCKET, + ) -> c_int; + pub fn connect( + s: SOCKET, + name: *const SOCKADDR, + namelen: c_int, + ) -> c_int; + pub fn ioctlsocket( + s: SOCKET, + cmd: c_long, + argp: *mut u_long, + ) -> c_int; + pub fn getpeername( + s: SOCKET, + name: *mut SOCKADDR, + namelen: *mut c_int, + ) -> c_int; + pub fn getsockname( + s: SOCKET, + name: *mut SOCKADDR, + namelen: *mut c_int, + ) -> c_int; + pub fn getsockopt( + s: SOCKET, + level: c_int, + optname: c_int, + optval: *mut c_char, + optlen: *mut c_int, + ) -> c_int; + pub fn htonl( + hostlong: u_long, + ) -> u_long; + pub fn htons( + hostshort: u_short, + ) -> u_short; + pub fn inet_addr( + cp: *const c_char, + ) -> c_ulong; + pub fn inet_ntoa( + _in: in_addr, + ) -> *mut c_char; +} +#[inline] +pub fn _WS2_32_WINSOCK_SWAP_LONG(l: __uint32) -> __uint32 { + ((l >> 24) & 0x000000FF) | ((l >> 8) & 0x0000FF00) | ((l << 8) & 0x00FF0000) + | ((l << 24) & 0xFF000000) +} +#[inline] +pub fn _WS2_32_WINSOCK_SWAP_LONGLONG(l: __uint64) -> __uint64 { + ((l >> 56) & 0x00000000000000FF) | ((l >> 40) & 0x000000000000FF00) + | ((l >> 24) & 0x0000000000FF0000) | ((l >> 8) & 0x00000000FF000000) + | ((l << 8) & 0x000000FF00000000) | ((l << 24) & 0x0000FF0000000000) + | ((l << 40) & 0x00FF000000000000) | ((l << 56) & 0xFF00000000000000) +} +#[inline] +pub fn htonll(Value: __uint64) -> __uint64 { + _WS2_32_WINSOCK_SWAP_LONGLONG(Value) +} +#[inline] +pub fn ntohll(Value: __uint64) -> __uint64 { + _WS2_32_WINSOCK_SWAP_LONGLONG(Value) +} +#[inline] +pub fn htonf(Value: c_float) -> __uint32 { + let Tempval: __uint32 = unsafe { ::core::mem::transmute(Value) }; + _WS2_32_WINSOCK_SWAP_LONG(Tempval) +} +#[inline] +pub fn ntohf(Value: __uint32) -> c_float { + let Tempval = _WS2_32_WINSOCK_SWAP_LONG(Value); + unsafe { ::core::mem::transmute(Tempval) } +} +#[inline] +pub fn htond(Value: c_double) -> __uint64 { + let Tempval: __uint64 = unsafe { ::core::mem::transmute(Value) }; + _WS2_32_WINSOCK_SWAP_LONGLONG(Tempval) +} +#[inline] +pub fn ntohd(Value: __uint64) -> c_double { + let Tempval = _WS2_32_WINSOCK_SWAP_LONGLONG(Value); + unsafe { ::core::mem::transmute(Tempval) } +} +extern "system" { + pub fn listen( + s: SOCKET, + backlog: c_int, + ) -> c_int; + pub fn ntohl( + netlong: u_long, + ) -> u_long; + pub fn ntohs( + netshort: u_short, + ) -> u_short; + pub fn recv( + s: SOCKET, + buf: *mut c_char, + len: c_int, + flags: c_int, + ) -> c_int; + pub fn recvfrom( + s: SOCKET, + buf: *mut c_char, + len: c_int, + flags: c_int, + from: *mut SOCKADDR, + fromlen: *mut c_int, + ) -> c_int; + pub fn select( + nfds: c_int, + readfds: *mut fd_set, + writefds: *mut fd_set, + exceptfds: *mut fd_set, + timeout: *const timeval, + ) -> c_int; + pub fn send( + s: SOCKET, + buf: *const c_char, + len: c_int, + flags: c_int, + ) -> c_int; + pub fn sendto( + s: SOCKET, + buf: *const c_char, + len: c_int, + flags: c_int, + to: *const SOCKADDR, + tolen: c_int, + ) -> c_int; + pub fn setsockopt( + s: SOCKET, + level: c_int, + optname: c_int, + optval: *const c_char, + optlen: c_int, + ) -> c_int; + pub fn shutdown( + s: SOCKET, + how: c_int, + ) -> c_int; + pub fn socket( + af: c_int, + _type: c_int, + protocol: c_int, + ) -> SOCKET; + pub fn gethostbyaddr( + addr: *const c_char, + len: c_int, + _type: c_int, + ) -> *mut hostent; + pub fn gethostbyname( + name: *const c_char, + ) -> *mut hostent; + pub fn gethostname( + name: *mut c_char, + namelen: c_int, + ) -> c_int; + pub fn GetHostNameW( + name: PWSTR, + namelen: c_int, + ) -> c_int; + pub fn getservbyport( + port: c_int, + proto: *const c_char, + ) -> *mut servent; + pub fn getservbyname( + name: *const c_char, + proto: *const c_char, + ) -> *mut servent; + pub fn getprotobynumber( + number: c_int, + ) -> *mut protoent; + pub fn getprotobyname( + name: *const c_char, + ) -> *mut protoent; + pub fn WSAStartup( + wVersionRequested: WORD, + lpWSAData: LPWSADATA, + ) -> c_int; + pub fn WSACleanup() -> c_int; + pub fn WSASetLastError( + iError: c_int, + ); + pub fn WSAGetLastError() -> c_int; + pub fn WSAIsBlocking() -> BOOL; + pub fn WSAUnhookBlockingHook() -> c_int; + pub fn WSASetBlockingHook( + lpBlockFunc: FARPROC, + ) -> FARPROC; + pub fn WSACancelBlockingCall() -> c_int; + pub fn WSAAsyncGetServByName( + hWnd: HWND, + wMsg: u_int, + name: *const c_char, + proto: *const c_char, + buf: *mut c_char, + buflen: c_int, + ) -> HANDLE; + pub fn WSAAsyncGetServByPort( + hWnd: HWND, + wMsg: u_int, + port: c_int, + proto: *const c_char, + buf: *mut c_char, + buflen: c_int, + ) -> HANDLE; + pub fn WSAAsyncGetProtoByName( + hWnd: HWND, + wMsg: u_int, + name: *const c_char, + buf: *mut c_char, + buflen: c_int, + ) -> HANDLE; + pub fn WSAAsyncGetProtoByNumber( + hWnd: HWND, + wMsg: u_int, + number: c_int, + buf: *mut c_char, + buflen: c_int, + ) -> HANDLE; + pub fn WSAAsyncGetHostByName( + hWnd: HWND, + wMsg: u_int, + name: *const c_char, + buf: *mut c_char, + buflen: c_int, + ) -> HANDLE; + pub fn WSAAsyncGetHostByAddr( + hWnd: HWND, + wMsg: u_int, + addr: *const c_char, + len: c_int, + _type: c_int, + buf: *mut c_char, + buflen: c_int, + ) -> HANDLE; + pub fn WSACancelAsyncRequest( + hAsyncTaskHandle: HANDLE, + ) -> c_int; + pub fn WSAAsyncSelect( + s: SOCKET, + hWnd: HWND, + wMsg: u_int, + lEvent: c_long, + ) -> c_int; + pub fn WSAAccept( + s: SOCKET, + addr: *mut SOCKADDR, + addrlen: LPINT, + lpfnCondition: LPCONDITIONPROC, + dwCallbackData: DWORD_PTR, + ) -> SOCKET; + pub fn WSACloseEvent( + hEvent: WSAEVENT, + ) -> BOOL; + pub fn WSAConnect( + s: SOCKET, + name: *const SOCKADDR, + namelen: c_int, + lpCallerData: LPWSABUF, + lpCalleeData: LPWSABUF, + lpSQOS: LPQOS, + lpGQOS: LPQOS, + ) -> c_int; + pub fn WSAConnectByNameW( + s: SOCKET, + nodename: LPWSTR, + servicename: LPWSTR, + LocalAddressLength: LPDWORD, + LocalAddress: LPSOCKADDR, + RemoteAddressLength: LPDWORD, + RemoteAddress: LPSOCKADDR, + timeout: *const timeval, + Reserved: LPWSAOVERLAPPED, + ) -> BOOL; + pub fn WSAConnectByNameA( + s: SOCKET, + nodename: LPCSTR, + servicename: LPCSTR, + LocalAddressLength: LPDWORD, + LocalAddress: LPSOCKADDR, + RemoteAddressLength: LPDWORD, + RemoteAddress: LPSOCKADDR, + timeout: *const timeval, + Reserved: LPWSAOVERLAPPED, + ) -> BOOL; + pub fn WSAConnectByList( + s: SOCKET, + SocketAddress: PSOCKET_ADDRESS_LIST, + LocalAddressLength: LPDWORD, + LocalAddress: LPSOCKADDR, + RemoteAddressLength: LPDWORD, + RemoteAddress: LPSOCKADDR, + timeout: *const timeval, + Reserved: LPWSAOVERLAPPED, + ) -> BOOL; + pub fn WSACreateEvent() -> WSAEVENT; + pub fn WSADuplicateSocketA( + s: SOCKET, + dwProcessId: DWORD, + lpProtocolInfo: LPWSAPROTOCOL_INFOA, + ) -> c_int; + pub fn WSADuplicateSocketW( + s: SOCKET, + dwProcessId: DWORD, + lpProtocolInfo: LPWSAPROTOCOL_INFOW, + ) -> c_int; + pub fn WSAEnumNetworkEvents( + s: SOCKET, + hEventObject: WSAEVENT, + lpNetworkEvents: LPWSANETWORKEVENTS, + ) -> c_int; + pub fn WSAEnumProtocolsA( + lpiProtocols: LPINT, + lpProtocolBuffer: LPWSAPROTOCOL_INFOA, + lpdwBufferLength: LPDWORD, + ) -> c_int; + pub fn WSAEnumProtocolsW( + lpiProtocols: LPINT, + lpProtocolBuffer: LPWSAPROTOCOL_INFOW, + lpdwBufferLength: LPDWORD, + ) -> c_int; + pub fn WSAEventSelect( + s: SOCKET, + hEventObject: WSAEVENT, + lNetworkEvents: c_long, + ) -> c_int; + pub fn WSAGetOverlappedResult( + s: SOCKET, + lpOverlapped: LPWSAOVERLAPPED, + lpcbTransfer: LPDWORD, + fWait: BOOL, + lpdwFlags: LPDWORD, + ) -> BOOL; + pub fn WSAGetQOSByName( + s: SOCKET, + lpQOSName: LPWSABUF, + lpQOS: LPQOS, + ) -> BOOL; + pub fn WSAHtonl( + s: SOCKET, + hostlong: u_long, + lpnetlong: *mut u_long, + ) -> c_int; + pub fn WSAHtons(s: SOCKET, + hostshort: u_short, + lpnetshort: *mut u_short, + ) -> c_int; + pub fn WSAIoctl( + s: SOCKET, + dwIoControlCode: DWORD, + lpvInBuffer: LPVOID, + cbInBuffer: DWORD, + lpvOutBuffer: LPVOID, + cbOutBuffer: DWORD, + lpcbBytesReturned: LPDWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> c_int; + pub fn WSAJoinLeaf( + s: SOCKET, + name: *const SOCKADDR, + namelen: c_int, + lpCallerData: LPWSABUF, + lpCalleeData: LPWSABUF, + lpSQOS: LPQOS, + lpGQOS: LPQOS, + dwFlags: DWORD, + ) -> SOCKET; + pub fn WSANtohl( + s: SOCKET, + netlong: u_long, + lphostlong: *mut c_long, + ) -> c_int; + pub fn WSANtohs( + s: SOCKET, + netshort: u_short, + lphostshort: *mut c_short, + ) -> c_int; + pub fn WSARecv( + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, + lpNumberOfBytesRecvd: LPDWORD, + lpFlags: LPDWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> c_int; + pub fn WSARecvDisconnect( + s: SOCKET, + lpInboundDisconnectData: LPWSABUF, + ) -> c_int; + pub fn WSARecvFrom( + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, + lpNumberOfBytesRecvd: LPDWORD, + lpFlags: LPDWORD, + lpFrom: *mut SOCKADDR, + lpFromlen: LPINT, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> c_int; + pub fn WSAResetEvent( + hEvent: WSAEVENT, + ) -> BOOL; + pub fn WSASend( + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, + lpNumberOfBytesSent: LPDWORD, + dwFlags: DWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> c_int; + pub fn WSASendMsg( + Handle: SOCKET, + lpMsg: LPWSAMSG, + dwFlags: DWORD, + lpNumberOfBytesSent: LPDWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> c_int; + pub fn WSASendDisconnect( + s: SOCKET, + lpOutboundDisconnectData: LPWSABUF, + ) -> c_int; + pub fn WSASendTo( + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, + lpNumberOfBytesSent: LPDWORD, + dwFlags: DWORD, + lpTo: *const SOCKADDR, + iToLen: c_int, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> c_int; + pub fn WSASetEvent( + hEvent: WSAEVENT, + ) -> BOOL; + pub fn WSASocketA( + af: c_int, + _type: c_int, + protocol: c_int, + lpProtocolInfo: LPWSAPROTOCOL_INFOA, + g: GROUP, + dwFlags: DWORD, + ) -> SOCKET; + pub fn WSASocketW( + af: c_int, + _type: c_int, + protocol: c_int, + lpProtocolInfo: LPWSAPROTOCOL_INFOW, + g: GROUP, + dwFlags: DWORD, + ) -> SOCKET; + pub fn WSAWaitForMultipleEvents( + cEvents: DWORD, + lphEvents: *const WSAEVENT, + fWaitAll: BOOL, + dwTimeout: DWORD, + fAlertable: BOOL, + ) -> DWORD; + pub fn WSAAddressToStringA( + lpsaAddress: LPSOCKADDR, + dwAddressLength: DWORD, + lpProtocolInfo: LPWSAPROTOCOL_INFOA, + lpszAddressString: LPSTR, + lpdwAddressStringLength: LPDWORD, + ) -> INT; + pub fn WSAAddressToStringW( + lpsaAddress: LPSOCKADDR, + dwAddressLength: DWORD, + lpProtocolInfo: LPWSAPROTOCOL_INFOW, + lpszAddressString: LPWSTR, + lpdwAddressStringLength: LPDWORD, + ) -> INT; + pub fn WSAStringToAddressA( + AddressString: LPSTR, + AddressFamily: INT, + lpProtocolInfo: LPWSAPROTOCOL_INFOA, + lpAddress: LPSOCKADDR, + lpAddressLength: LPINT, + ) -> INT; + pub fn WSAStringToAddressW( + AddressString: LPWSTR, + AddressFamily: INT, + lpProtocolInfo: LPWSAPROTOCOL_INFOW, + lpAddress: LPSOCKADDR, + lpAddressLength: LPINT, + ) -> INT; + pub fn WSALookupServiceBeginA( + lpqsRestrictions: LPWSAQUERYSETA, + dwControlFlags: DWORD, + lphLookup: LPHANDLE, + ) -> INT; + pub fn WSALookupServiceBeginW( + lpqsRestrictions: LPWSAQUERYSETW, + dwControlFlags: DWORD, + lphLookup: LPHANDLE, + ) -> INT; + pub fn WSALookupServiceNextA( + hLookup: HANDLE, + dwControlFlags: DWORD, + lpdwBufferLength: LPDWORD, + lpqsResults: LPWSAQUERYSETA, + ) -> INT; + pub fn WSALookupServiceNextW( + hLookup: HANDLE, + dwControlFlags: DWORD, + lpdwBufferLength: LPDWORD, + lpqsResults: LPWSAQUERYSETW, + ) -> INT; + pub fn WSANSPIoctl( + hLookup: HANDLE, + dwControlFlags: DWORD, + lpvInBuffer: LPVOID, + cbInBuffer: DWORD, + lpvOutBuffer: LPVOID, + cbOutBuffer: DWORD, + lpcbBytesReturned: LPDWORD, + lpCompletion: LPWSACOMPLETION, + ) -> INT; + pub fn WSALookupServiceEnd( + hLookup: HANDLE, + ) -> INT; + pub fn WSAInstallServiceClassA( + lpServiceClassInfo: LPWSASERVICECLASSINFOA, + ) -> INT; + pub fn WSAInstallServiceClassW( + lpServiceClassInfo: LPWSASERVICECLASSINFOW, + ) -> INT; + pub fn WSARemoveServiceClass( + lpServiceClassId: LPGUID, + ) -> INT; + pub fn WSAGetServiceClassInfoA( + lpProviderId: LPGUID, + lpServiceClassId: LPGUID, + lpdwBufSize: LPDWORD, + lpServiceClassInfo: LPWSASERVICECLASSINFOA, + ) -> INT; + pub fn WSAGetServiceClassInfoW( + lpProviderId: LPGUID, + lpServiceClassId: LPGUID, + lpdwBufSize: LPDWORD, + lpServiceClassInfo: LPWSASERVICECLASSINFOW, + ) -> INT; + pub fn WSAEnumNameSpaceProvidersA( + lpdwBufferLength: LPDWORD, + lpnspBuffer: LPWSANAMESPACE_INFOA, + ) -> INT; + pub fn WSAEnumNameSpaceProvidersW( + lpdwBufferLength: LPDWORD, + lpnspBuffer: LPWSANAMESPACE_INFOW, + ) -> INT; + pub fn WSAEnumNameSpaceProvidersExA( + lpdwBufferLength: LPDWORD, + lpnspBuffer: LPWSANAMESPACE_INFOEXA, + ) -> INT; + pub fn WSAEnumNameSpaceProvidersExW( + lpdwBufferLength: LPDWORD, + lpnspBuffer: LPWSANAMESPACE_INFOEXW, + ) -> INT; + pub fn WSAGetServiceClassNameByClassIdA( + lpServiceClassId: LPGUID, + lpszServiceClassName: LPSTR, + lpdwBufferLength: LPDWORD, + ) -> INT; + pub fn WSAGetServiceClassNameByClassIdW( + lpServiceClassId: LPGUID, + lpszServiceClassName: LPWSTR, + lpdwBufferLength: LPDWORD, + ) -> INT; + pub fn WSASetServiceA( + lpqsRegInfo: LPWSAQUERYSETA, + essoperation: WSAESETSERVICEOP, + dwControlFlags: DWORD, + ) -> INT; + pub fn WSASetServiceW( + lpqsRegInfo: LPWSAQUERYSETW, + essoperation: WSAESETSERVICEOP, + dwControlFlags: DWORD, + ) -> INT; + pub fn WSAProviderConfigChange( + lpNotificationHandle: LPHANDLE, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> INT; + pub fn WSAPoll( + fdArray: LPWSAPOLLFD, + fds: ULONG, + timeout: INT, + ) -> c_int; +} +pub type LPSOCKADDR_IN = *mut SOCKADDR_IN; +pub type LINGER = linger; +pub type PLINGER = *mut linger; +pub type LPLINGER = *mut linger; +pub type FD_SET = fd_set; +pub type PFD_SET = *mut fd_set; +pub type LPFD_SET = *mut fd_set; +pub type HOSTENT = hostent; +pub type PHOSTENT = *mut hostent; +pub type LPHOSTENT = *mut hostent; +pub type SERVENT = servent; +pub type PSERVENT = *mut servent; +pub type LPSERVENT = *mut servent; +pub type PROTOENT = protoent; +pub type PPROTOENT = *mut protoent; +pub type LPPROTOENT = *mut protoent; +pub type TIMEVAL = timeval; +pub type PTIMEVAL = *mut timeval; +pub type LPTIMEVAL = *mut timeval; +#[inline] +pub fn WSAMAKEASYNCREPLY(buflen: WORD, error: WORD) -> LONG { + MAKELONG(buflen, error) +} +#[inline] +pub fn WSAMAKESELECTREPLY(event: WORD, error: WORD) -> LONG { + MAKELONG(event, error) +} +#[inline] +pub fn WSAGETASYNCBUFLEN(lParam: DWORD) -> WORD { + LOWORD(lParam) +} +#[inline] +pub fn WSAGETASYNCERROR(lParam: DWORD) -> WORD { + HIWORD(lParam) +} +#[inline] +pub fn WSAGETSELECTEVENT(lParam: DWORD) -> WORD { + LOWORD(lParam) +} +#[inline] +pub fn WSAGETSELECTERROR(lParam: DWORD) -> WORD { + HIWORD(lParam) +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winspool.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winspool.rs new file mode 100644 index 0000000..a4e3302 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winspool.rs @@ -0,0 +1,2433 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Winspool header file +use shared::guiddef::GUID; +use shared::minwindef::{ + BOOL, BYTE, DWORD, FILETIME, FLOAT, LPBYTE, LPDWORD, LPHANDLE, LPVOID, MAX_PATH, PBYTE, PDWORD, + PULONG, PWORD, UINT, ULONG, WORD, +}; +use shared::windef::{HWND, RECTL, SIZEL}; +use shared::winerror::ERROR_NOT_SUPPORTED; +use um::minwinbase::SYSTEMTIME; +use um::wingdi::{LPDEVMODEA, LPDEVMODEW, PDEVMODEA, PDEVMODEW}; +use um::winnt::{ + ACCESS_MASK, CHAR, DWORDLONG, HANDLE, HRESULT, LANGID, LONG, LONGLONG, LPCSTR, LPCWSTR, LPSTR, + LPWSTR, PCWSTR, PSECURITY_DESCRIPTOR, PVOID, PWSTR, STANDARD_RIGHTS_EXECUTE, + STANDARD_RIGHTS_READ, STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_WRITE, WCHAR, +}; +use vc::vcruntime::size_t; +STRUCT!{struct PRINTER_INFO_1A { + Flags: DWORD, + pDescription: LPSTR, + pName: LPSTR, + pComment: LPSTR, +}} +pub type PPRINTER_INFO_1A = *mut PRINTER_INFO_1A; +pub type LPPRINTER_INFO_1A = *mut PRINTER_INFO_1A; +STRUCT!{struct PRINTER_INFO_1W { + Flags: DWORD, + pDescription: LPWSTR, + pName: LPWSTR, + pComment: LPWSTR, +}} +pub type PPRINTER_INFO_1W = *mut PRINTER_INFO_1W; +pub type LPPRINTER_INFO_1W = *mut PRINTER_INFO_1W; +STRUCT!{struct PRINTER_INFO_2A { + pServerName: LPSTR, + pPrinterName: LPSTR, + pShareName: LPSTR, + pPortName: LPSTR, + pDriverName: LPSTR, + pComment: LPSTR, + pLocation: LPSTR, + pDevMode: LPDEVMODEA, + pSepFile: LPSTR, + pPrintProcessor: LPSTR, + pDatatype: LPSTR, + pParameters: LPSTR, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + Attributes: DWORD, + Priority: DWORD, + DefaultPriority: DWORD, + StartTime: DWORD, + UntilTime: DWORD, + Status: DWORD, + cJobs: DWORD, + AveragePPM: DWORD, +}} +pub type PPRINTER_INFO_2A = *mut PRINTER_INFO_2A; +pub type LPPRINTER_INFO_2A = *mut PRINTER_INFO_2A; +STRUCT!{struct PRINTER_INFO_2W { + pServerName: LPWSTR, + pPrinterName: LPWSTR, + pShareName: LPWSTR, + pPortName: LPWSTR, + pDriverName: LPWSTR, + pComment: LPWSTR, + pLocation: LPWSTR, + pDevMode: LPDEVMODEW, + pSepFile: LPWSTR, + pPrintProcessor: LPWSTR, + pDatatype: LPWSTR, + pParameters: LPWSTR, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + Attributes: DWORD, + Priority: DWORD, + DefaultPriority: DWORD, + StartTime: DWORD, + UntilTime: DWORD, + Status: DWORD, + cJobs: DWORD, + AveragePPM: DWORD, +}} +pub type PPRINTER_INFO_2W = *mut PRINTER_INFO_2W; +pub type LPPRINTER_INFO_2W = *mut PRINTER_INFO_2W; +STRUCT!{struct PRINTER_INFO_3 { + pSecurityDescriptor: PSECURITY_DESCRIPTOR, +}} +pub type PPRINTER_INFO_3 = *mut PRINTER_INFO_3; +pub type LPPRINTER_INFO_3 = *mut PRINTER_INFO_3; +STRUCT!{struct PRINTER_INFO_4A { + pPrinterName: LPSTR, + pServerName: LPSTR, + Attributes: DWORD, +}} +pub type PPRINTER_INFO_4A = *mut PRINTER_INFO_4A; +pub type LPPRINTER_INFO_4A = *mut PRINTER_INFO_4A; +STRUCT!{struct PRINTER_INFO_4W { + pPrinterName: LPWSTR, + pServerName: LPWSTR, + Attributes: DWORD, +}} +pub type PPRINTER_INFO_4W = *mut PRINTER_INFO_4W; +pub type LPPRINTER_INFO_4W = *mut PRINTER_INFO_4W; +STRUCT!{struct PRINTER_INFO_5A { + pPrinterName: LPSTR, + pPortName: LPSTR, + Attributes: DWORD, + DeviceNotSelectedTimeout: DWORD, + TransmissionRetryTimeout: DWORD, +}} +pub type PPRINTER_INFO_5A = *mut PRINTER_INFO_5A; +pub type LPPRINTER_INFO_5A = *mut PRINTER_INFO_5A; +STRUCT!{struct PRINTER_INFO_5W { + pPrinterName: LPWSTR, + pPortName: LPWSTR, + Attributes: DWORD, + DeviceNotSelectedTimeout: DWORD, + TransmissionRetryTimeout: DWORD, +}} +pub type PPRINTER_INFO_5W = *mut PRINTER_INFO_5W; +pub type LPPRINTER_INFO_5W = *mut PRINTER_INFO_5W; +STRUCT!{struct PRINTER_INFO_6 { + dwStatus: DWORD, +}} +pub type PPRINTER_INFO_6 = *mut PRINTER_INFO_6; +pub type LPPRINTER_INFO_6 = *mut PRINTER_INFO_6; +STRUCT!{struct PRINTER_INFO_7A { + pszObjectGUID: LPSTR, + dwAction: DWORD, +}} +pub type PPRINTER_INFO_7A = *mut PRINTER_INFO_7A; +pub type LPPRINTER_INFO_7A = *mut PRINTER_INFO_7A; +STRUCT!{struct PRINTER_INFO_7W { + pszObjectGUID: LPWSTR, + dwAction: DWORD, +}} +pub type PPRINTER_INFO_7W = *mut PRINTER_INFO_7W; +pub type LPPRINTER_INFO_7W = *mut PRINTER_INFO_7W; +pub const DSPRINT_PUBLISH: DWORD = 0x00000001; +pub const DSPRINT_UPDATE: DWORD = 0x00000002; +pub const DSPRINT_UNPUBLISH: DWORD = 0x00000004; +pub const DSPRINT_REPUBLISH: DWORD = 0x00000008; +pub const DSPRINT_PENDING: DWORD = 0x80000000; +STRUCT!{struct PRINTER_INFO_8A { + pDevMode: LPDEVMODEA, +}} +pub type PPRINTER_INFO_8A = *mut PRINTER_INFO_8A; +pub type LPPRINTER_INFO_8A = *mut PRINTER_INFO_8A; +STRUCT!{struct PRINTER_INFO_8W { + pDevMode: LPDEVMODEW, +}} +pub type PPRINTER_INFO_8W = *mut PRINTER_INFO_8W; +pub type LPPRINTER_INFO_8W = *mut PRINTER_INFO_8W; +STRUCT!{struct PRINTER_INFO_9A { + pDevMode: LPDEVMODEA, +}} +pub type PPRINTER_INFO_9A = *mut PRINTER_INFO_9A; +pub type LPPRINTER_INFO_9A = *mut PRINTER_INFO_9A; +STRUCT!{struct PRINTER_INFO_9W { + pDevMode: LPDEVMODEA, +}} +pub type PPRINTER_INFO_9W = *mut PRINTER_INFO_9W; +pub type LPPRINTER_INFO_9W = *mut PRINTER_INFO_9W; +pub const PRINTER_CONTROL_PAUSE: DWORD = 1; +pub const PRINTER_CONTROL_RESUME: DWORD = 2; +pub const PRINTER_CONTROL_PURGE: DWORD = 3; +pub const PRINTER_CONTROL_SET_STATUS: DWORD = 4; +pub const PRINTER_STATUS_PAUSED: DWORD = 0x00000001; +pub const PRINTER_STATUS_ERROR: DWORD = 0x00000002; +pub const PRINTER_STATUS_PENDING_DELETION: DWORD = 0x00000004; +pub const PRINTER_STATUS_PAPER_JAM: DWORD = 0x00000008; +pub const PRINTER_STATUS_PAPER_OUT: DWORD = 0x00000010; +pub const PRINTER_STATUS_MANUAL_FEED: DWORD = 0x00000020; +pub const PRINTER_STATUS_PAPER_PROBLEM: DWORD = 0x00000040; +pub const PRINTER_STATUS_OFFLINE: DWORD = 0x00000080; +pub const PRINTER_STATUS_IO_ACTIVE: DWORD = 0x00000100; +pub const PRINTER_STATUS_BUSY: DWORD = 0x00000200; +pub const PRINTER_STATUS_PRINTING: DWORD = 0x00000400; +pub const PRINTER_STATUS_OUTPUT_BIN_FULL: DWORD = 0x00000800; +pub const PRINTER_STATUS_NOT_AVAILABLE: DWORD = 0x00001000; +pub const PRINTER_STATUS_WAITING: DWORD = 0x00002000; +pub const PRINTER_STATUS_PROCESSING: DWORD = 0x00004000; +pub const PRINTER_STATUS_INITIALIZING: DWORD = 0x00008000; +pub const PRINTER_STATUS_WARMING_UP: DWORD = 0x00010000; +pub const PRINTER_STATUS_TONER_LOW: DWORD = 0x00020000; +pub const PRINTER_STATUS_NO_TONER: DWORD = 0x00040000; +pub const PRINTER_STATUS_PAGE_PUNT: DWORD = 0x00080000; +pub const PRINTER_STATUS_USER_INTERVENTION: DWORD = 0x00100000; +pub const PRINTER_STATUS_OUT_OF_MEMORY: DWORD = 0x00200000; +pub const PRINTER_STATUS_DOOR_OPEN: DWORD = 0x00400000; +pub const PRINTER_STATUS_SERVER_UNKNOWN: DWORD = 0x00800000; +pub const PRINTER_STATUS_POWER_SAVE: DWORD = 0x01000000; +pub const PRINTER_STATUS_SERVER_OFFLINE: DWORD = 0x02000000; +pub const PRINTER_STATUS_DRIVER_UPDATE_NEEDED: DWORD = 0x04000000; +pub const PRINTER_ATTRIBUTE_QUEUED: DWORD = 0x00000001; +pub const PRINTER_ATTRIBUTE_DIRECT: DWORD = 0x00000002; +pub const PRINTER_ATTRIBUTE_DEFAULT: DWORD = 0x00000004; +pub const PRINTER_ATTRIBUTE_SHARED: DWORD = 0x00000008; +pub const PRINTER_ATTRIBUTE_NETWORK: DWORD = 0x00000010; +pub const PRINTER_ATTRIBUTE_HIDDEN: DWORD = 0x00000020; +pub const PRINTER_ATTRIBUTE_LOCAL: DWORD = 0x00000040; +pub const PRINTER_ATTRIBUTE_ENABLE_DEVQ: DWORD = 0x00000080; +pub const PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS: DWORD = 0x00000100; +pub const PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST: DWORD = 0x00000200; +pub const PRINTER_ATTRIBUTE_WORK_OFFLINE: DWORD = 0x00000400; +pub const PRINTER_ATTRIBUTE_ENABLE_BIDI: DWORD = 0x00000800; +pub const PRINTER_ATTRIBUTE_RAW_ONLY: DWORD = 0x00001000; +pub const PRINTER_ATTRIBUTE_PUBLISHED: DWORD = 0x00002000; +pub const PRINTER_ATTRIBUTE_FAX: DWORD = 0x00004000; +pub const PRINTER_ATTRIBUTE_TS: DWORD = 0x00008000; +pub const PRINTER_ATTRIBUTE_PUSHED_USER: DWORD = 0x00020000; +pub const PRINTER_ATTRIBUTE_PUSHED_MACHINE: DWORD = 0x00040000; +pub const PRINTER_ATTRIBUTE_MACHINE: DWORD = 0x00080000; +pub const PRINTER_ATTRIBUTE_FRIENDLY_NAME: DWORD = 0x00100000; +pub const PRINTER_ATTRIBUTE_TS_GENERIC_DRIVER: DWORD = 0x00200000; +pub const PRINTER_ATTRIBUTE_PER_USER: DWORD = 0x00400000; +pub const PRINTER_ATTRIBUTE_ENTERPRISE_CLOUD: DWORD = 0x00800000; +pub const NO_PRIORITY: DWORD = 0; +pub const MAX_PRIORITY: DWORD = 99; +pub const MIN_PRIORITY: DWORD = 1; +pub const DEF_PRIORITY: DWORD = 1; +STRUCT!{struct JOB_INFO_1A { + JobId: DWORD, + pPrinterName: LPSTR, + pMachineName: LPSTR, + pUserName: LPSTR, + pDocument: LPSTR, + pDatatype: LPSTR, + pStatus: LPSTR, + Status: DWORD, + Priority: DWORD, + Position: DWORD, + TotalPages: DWORD, + PagesPrinted: DWORD, + Submitted: SYSTEMTIME, +}} +pub type PJOB_INFO_1A = *mut JOB_INFO_1A; +pub type LPJOB_INFO_1A = *mut JOB_INFO_1A; +STRUCT!{struct JOB_INFO_1W { + JobId: DWORD, + pPrinterName: LPWSTR, + pMachineName: LPWSTR, + pUserName: LPWSTR, + pDocument: LPWSTR, + pDatatype: LPWSTR, + pStatus: LPWSTR, + Status: DWORD, + Priority: DWORD, + Position: DWORD, + TotalPages: DWORD, + PagesPrinted: DWORD, + Submitted: SYSTEMTIME, +}} +pub type PJOB_INFO_1W = *mut JOB_INFO_1W; +pub type LPJOB_INFO_1W = *mut JOB_INFO_1W; +STRUCT!{struct JOB_INFO_2A { + JobId: DWORD, + pPrinterName: LPSTR, + pMachineName: LPSTR, + pUserName: LPSTR, + pDocument: LPSTR, + pNotifyName: LPSTR, + pDatatype: LPSTR, + pPrintProcessor: LPSTR, + pParameters: LPSTR, + pDriverName: LPSTR, + pDevMode: LPDEVMODEA, + pStatus: LPSTR, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + Status: DWORD, + Priority: DWORD, + Position: DWORD, + StartTime: DWORD, + UntilTime: DWORD, + TotalPages: DWORD, + Size: DWORD, + Submitted: SYSTEMTIME, + Time: DWORD, + PagesPrinted: DWORD, +}} +pub type PJOB_INFO_2A = *mut JOB_INFO_2A; +pub type LPJOB_INFO_2A = *mut JOB_INFO_2A; +STRUCT!{struct JOB_INFO_2W { + JobId: DWORD, + pPrinterName: LPWSTR, + pMachineName: LPWSTR, + pUserName: LPWSTR, + pDocument: LPWSTR, + pNotifyName: LPWSTR, + pDatatype: LPWSTR, + pPrintProcessor: LPWSTR, + pParameters: LPWSTR, + pDriverName: LPWSTR, + pDevMode: LPDEVMODEW, + pStatus: LPWSTR, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + Status: DWORD, + Priority: DWORD, + Position: DWORD, + StartTime: DWORD, + UntilTime: DWORD, + TotalPages: DWORD, + Size: DWORD, + Submitted: SYSTEMTIME, + Time: DWORD, + PagesPrinted: DWORD, +}} +pub type PJOB_INFO_2W = *mut JOB_INFO_2W; +pub type LPJOB_INFO_2W = *mut JOB_INFO_2W; +STRUCT!{struct JOB_INFO_3 { + JobId: DWORD, + NextJobId: DWORD, + Reserved: DWORD, +}} +pub type PJOB_INFO_3 = *mut JOB_INFO_3; +pub type LPJOB_INFO_3 = *mut JOB_INFO_3; +STRUCT!{struct JOB_INFO_4A { + JobId: DWORD, + pPrinterName: LPSTR, + pMachineName: LPSTR, + pUserName: LPSTR, + pDocument: LPSTR, + pNotifyName: LPSTR, + pDatatype: LPSTR, + pPrintProcessor: LPSTR, + pParameters: LPSTR, + pDriverName: LPSTR, + pDevMode: LPDEVMODEA, + pStatus: LPSTR, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + Status: DWORD, + Priority: DWORD, + Position: DWORD, + StartTime: DWORD, + UntilTime: DWORD, + TotalPages: DWORD, + Size: DWORD, + Submitted: SYSTEMTIME, + Time: DWORD, + PagesPrinted: DWORD, + SizeHigh: LONG, +}} +pub type PJOB_INFO_4A = *mut JOB_INFO_4A; +pub type LPJOB_INFO_4A = *mut JOB_INFO_4A; +STRUCT!{struct JOB_INFO_4W { + JobId: DWORD, + pPrinterName: LPWSTR, + pMachineName: LPWSTR, + pUserName: LPWSTR, + pDocument: LPWSTR, + pNotifyName: LPWSTR, + pDatatype: LPWSTR, + pPrintProcessor: LPWSTR, + pParameters: LPWSTR, + pDriverName: LPWSTR, + pDevMode: LPDEVMODEW, + pStatus: LPWSTR, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + Status: DWORD, + Priority: DWORD, + Position: DWORD, + StartTime: DWORD, + UntilTime: DWORD, + TotalPages: DWORD, + Size: DWORD, + Submitted: SYSTEMTIME, + Time: DWORD, + PagesPrinted: DWORD, + SizeHigh: LONG, +}} +pub type PJOB_INFO_4W = *mut JOB_INFO_4W; +pub type LPJOB_INFO_4W = *mut JOB_INFO_4W; +pub const JOB_CONTROL_PAUSE: DWORD = 1; +pub const JOB_CONTROL_RESUME: DWORD = 2; +pub const JOB_CONTROL_CANCEL: DWORD = 3; +pub const JOB_CONTROL_RESTART: DWORD = 4; +pub const JOB_CONTROL_DELETE: DWORD = 5; +pub const JOB_CONTROL_SENT_TO_PRINTER: DWORD = 6; +pub const JOB_CONTROL_LAST_PAGE_EJECTED: DWORD = 7; +pub const JOB_STATUS_PAUSED: DWORD = 0x00000001; +pub const JOB_STATUS_ERROR: DWORD = 0x00000002; +pub const JOB_STATUS_DELETING: DWORD = 0x00000004; +pub const JOB_STATUS_SPOOLING: DWORD = 0x00000008; +pub const JOB_STATUS_PRINTING: DWORD = 0x00000010; +pub const JOB_STATUS_OFFLINE: DWORD = 0x00000020; +pub const JOB_STATUS_PAPEROUT: DWORD = 0x00000040; +pub const JOB_STATUS_PRINTED: DWORD = 0x00000080; +pub const JOB_STATUS_DELETED: DWORD = 0x00000100; +pub const JOB_STATUS_BLOCKED_DEVQ: DWORD = 0x00000200; +pub const JOB_STATUS_USER_INTERVENTION: DWORD = 0x00000400; +pub const JOB_STATUS_RESTART: DWORD = 0x00000800; +pub const JOB_POSITION_UNSPECIFIED: DWORD = 0; +STRUCT!{struct ADDJOB_INFO_1A { + Path: LPSTR, + JobId: DWORD, +}} +pub type PADDJOB_INFO_1A = *mut ADDJOB_INFO_1A; +pub type LPADDJOB_INFO_1A = *mut ADDJOB_INFO_1A; +STRUCT!{struct ADDJOB_INFO_1W { + Path: LPWSTR, + JobId: DWORD, +}} +pub type PADDJOB_INFO_1W = *mut ADDJOB_INFO_1W; +pub type LPADDJOB_INFO_1W = *mut ADDJOB_INFO_1W; +STRUCT!{struct DRIVER_INFO_1A { + pName: LPSTR, +}} +pub type PDRIVER_INFO_1A = *mut DRIVER_INFO_1A; +pub type LPDRIVER_INFO_1A = *mut DRIVER_INFO_1A; +STRUCT!{struct DRIVER_INFO_1W { + pName: LPWSTR, +}} +pub type PDRIVER_INFO_1W = *mut DRIVER_INFO_1W; +pub type LPDRIVER_INFO_1W = *mut DRIVER_INFO_1W; +STRUCT!{struct DRIVER_INFO_2A { + cVersion: DWORD, + pName: LPSTR, + pEnvironment: LPSTR, + pDriverPath: LPSTR, + pDataFile: LPSTR, + pConfigFile: LPSTR, +}} +pub type PDRIVER_INFO_2A = *mut DRIVER_INFO_2A; +pub type LPDRIVER_INFO_2A = *mut DRIVER_INFO_2A; +STRUCT!{struct DRIVER_INFO_2W { + cVersion: DWORD, + pName: LPWSTR, + pEnvironment: LPWSTR, + pDriverPath: LPWSTR, + pDataFile: LPWSTR, + pConfigFile: LPWSTR, +}} +pub type PDRIVER_INFO_2W = *mut DRIVER_INFO_2W; +pub type LPDRIVER_INFO_2W = *mut DRIVER_INFO_2W; +STRUCT!{struct DRIVER_INFO_3A { + cVersion: DWORD, + pName: LPSTR, + pEnvironment: LPSTR, + pDriverPath: LPSTR, + pDataFile: LPSTR, + pConfigFile: LPSTR, + pHelpFile: LPSTR, + pDependentFiles: LPSTR, + pMonitorName: LPSTR, + pDefaultDataType: LPSTR, +}} +pub type PDRIVER_INFO_3A = *mut DRIVER_INFO_3A; +pub type LPDRIVER_INFO_3A = *mut DRIVER_INFO_3A; +STRUCT!{struct DRIVER_INFO_3W { + cVersion: DWORD, + pName: LPWSTR, + pEnvironment: LPWSTR, + pDriverPath: LPWSTR, + pDataFile: LPWSTR, + pConfigFile: LPWSTR, + pHelpFile: LPWSTR, + pDependentFiles: LPWSTR, + pMonitorName: LPWSTR, + pDefaultDataType: LPWSTR, +}} +pub type PDRIVER_INFO_3W = *mut DRIVER_INFO_3W; +pub type LPDRIVER_INFO_3W = *mut DRIVER_INFO_3W; +STRUCT!{struct DRIVER_INFO_4A { + cVersion: DWORD, + pName: LPSTR, + pEnvironment: LPSTR, + pDriverPath: LPSTR, + pDataFile: LPSTR, + pConfigFile: LPSTR, + pHelpFile: LPSTR, + pDependentFiles: LPSTR, + pMonitorName: LPSTR, + pDefaultDataType: LPSTR, + pszzPreviousNames: LPSTR, +}} +pub type PDRIVER_INFO_4A = *mut DRIVER_INFO_4A; +pub type LPDRIVER_INFO_4A = *mut DRIVER_INFO_4A; +STRUCT!{struct DRIVER_INFO_4W { + cVersion: DWORD, + pName: LPWSTR, + pEnvironment: LPWSTR, + pDriverPath: LPWSTR, + pDataFile: LPWSTR, + pConfigFile: LPWSTR, + pHelpFile: LPWSTR, + pDependentFiles: LPWSTR, + pMonitorName: LPWSTR, + pDefaultDataType: LPWSTR, + pszzPreviousNames: LPWSTR, +}} +pub type PDRIVER_INFO_4W = *mut DRIVER_INFO_4W; +pub type LPDRIVER_INFO_4W = *mut DRIVER_INFO_4W; +STRUCT!{struct DRIVER_INFO_5A { + cVersion: DWORD, + pName: LPSTR, + pEnvironment: LPSTR, + pDriverPath: LPSTR, + pDataFile: LPSTR, + pConfigFile: LPSTR, + dwDriverAttributes: DWORD, + dwConfigVersion: DWORD, + dwDriverVersion: DWORD, +}} +pub type PDRIVER_INFO_5A = *mut DRIVER_INFO_5A; +pub type LPDRIVER_INFO_5A = *mut DRIVER_INFO_5A; +STRUCT!{struct DRIVER_INFO_5W { + cVersion: DWORD, + pName: LPWSTR, + pEnvironment: LPWSTR, + pDriverPath: LPWSTR, + pDataFile: LPWSTR, + pConfigFile: LPWSTR, + dwDriverAttributes: DWORD, + dwConfigVersion: DWORD, + dwDriverVersion: DWORD, +}} +pub type PDRIVER_INFO_5W = *mut DRIVER_INFO_5W; +pub type LPDRIVER_INFO_5W = *mut DRIVER_INFO_5W; +STRUCT!{struct DRIVER_INFO_6A { + cVersion: DWORD, + pName: LPSTR, + pEnvironment: LPSTR, + pDriverPath: LPSTR, + pDataFile: LPSTR, + pConfigFile: LPSTR, + pHelpFile: LPSTR, + pDependentFiles: LPSTR, + pMonitorName: LPSTR, + pDefaultDataType: LPSTR, + pszzPreviousNames: LPSTR, + ftDriverDate: FILETIME, + dwlDriverVersion: DWORDLONG, + pszMfgName: LPSTR, + pszOEMUrl: LPSTR, + pszHardwareID: LPSTR, + pszProvider: LPSTR, +}} +pub type PDRIVER_INFO_6A = *mut DRIVER_INFO_6A; +pub type LPDRIVER_INFO_6A = *mut DRIVER_INFO_6A; +STRUCT!{struct DRIVER_INFO_6W { + cVersion: DWORD, + pName: LPWSTR, + pEnvironment: LPWSTR, + pDriverPath: LPWSTR, + pDataFile: LPWSTR, + pConfigFile: LPWSTR, + pHelpFile: LPWSTR, + pDependentFiles: LPWSTR, + pMonitorName: LPWSTR, + pDefaultDataType: LPWSTR, + pszzPreviousNames: LPWSTR, + ftDriverDate: FILETIME, + dwlDriverVersion: DWORDLONG, + pszMfgName: LPWSTR, + pszOEMUrl: LPWSTR, + pszHardwareID: LPWSTR, + pszProvider: LPWSTR, +}} +pub type PDRIVER_INFO_6W = *mut DRIVER_INFO_6W; +pub type LPDRIVER_INFO_6W = *mut DRIVER_INFO_6W; +pub const PRINTER_DRIVER_PACKAGE_AWARE: DWORD = 0x00000001; +pub const PRINTER_DRIVER_XPS: DWORD = 0x00000002; +pub const PRINTER_DRIVER_SANDBOX_ENABLED: DWORD = 0x00000004; +pub const PRINTER_DRIVER_CLASS: DWORD = 0x00000008; +pub const PRINTER_DRIVER_DERIVED: DWORD = 0x00000010; +pub const PRINTER_DRIVER_NOT_SHAREABLE: DWORD = 0x00000020; +pub const PRINTER_DRIVER_CATEGORY_FAX: DWORD = 0x00000040; +pub const PRINTER_DRIVER_CATEGORY_FILE: DWORD = 0x00000080; +pub const PRINTER_DRIVER_CATEGORY_VIRTUAL: DWORD = 0x00000100; +pub const PRINTER_DRIVER_CATEGORY_SERVICE: DWORD = 0x00000200; +pub const PRINTER_DRIVER_SOFT_RESET_REQUIRED: DWORD = 0x00000400; +pub const PRINTER_DRIVER_SANDBOX_DISABLED: DWORD = 0x00000800; +pub const PRINTER_DRIVER_CATEGORY_3D: DWORD = 0x00001000; +pub const PRINTER_DRIVER_CATEGORY_CLOUD: DWORD = 0x00002000; +STRUCT!{struct DRIVER_INFO_8A { + cVersion: DWORD, + pName: LPSTR, + pEnvironment: LPSTR, + pDriverPath: LPSTR, + pDataFile: LPSTR, + pConfigFile: LPSTR, + pHelpFile: LPSTR, + pDependentFiles: LPSTR, + pMonitorName: LPSTR, + pDefaultDataType: LPSTR, + pszzPreviousNames: LPSTR, + ftDriverDate: FILETIME, + dwlDriverVersion: DWORDLONG, + pszMfgName: LPSTR, + pszOEMUrl: LPSTR, + pszHardwareID: LPSTR, + pszProvider: LPSTR, + pszPrintProcessor: LPSTR, + pszVendorSetup: LPSTR, + pszzColorProfiles: LPSTR, + pszInfPath: LPSTR, + dwPrinterDriverAttributes: DWORD, + pszzCoreDriverDependencies: LPSTR, + ftMinInboxDriverVerDate: FILETIME, + dwlMinInboxDriverVerVersion: DWORDLONG, +}} +pub type PDRIVER_INFO_8A = *mut DRIVER_INFO_8A; +pub type LPDRIVER_INFO_8A = *mut DRIVER_INFO_8A; +STRUCT!{struct DRIVER_INFO_8W { + cVersion: DWORD, + pName: LPWSTR, + pEnvironment: LPWSTR, + pDriverPath: LPWSTR, + pDataFile: LPWSTR, + pConfigFile: LPWSTR, + pHelpFile: LPWSTR, + pDependentFiles: LPWSTR, + pMonitorName: LPWSTR, + pDefaultDataType: LPWSTR, + pszzPreviousNames: LPWSTR, + ftDriverDate: FILETIME, + dwlDriverVersion: DWORDLONG, + pszMfgName: LPWSTR, + pszOEMUrl: LPWSTR, + pszHardwareID: LPWSTR, + pszProvider: LPWSTR, + pszPrintProcessor: LPWSTR, + pszVendorSetup: LPWSTR, + pszzColorProfiles: LPWSTR, + pszInfPath: LPWSTR, + dwPrinterDriverAttributes: DWORD, + pszzCoreDriverDependencies: LPWSTR, + ftMinInboxDriverVerDate: FILETIME, + dwlMinInboxDriverVerVersion: DWORDLONG, +}} +pub type PDRIVER_INFO_8W = *mut DRIVER_INFO_8W; +pub type LPDRIVER_INFO_8W = *mut DRIVER_INFO_8W; +pub const DRIVER_KERNELMODE: DWORD = 0x00000001; +pub const DRIVER_USERMODE: DWORD = 0x00000002; +pub const DPD_DELETE_UNUSED_FILES: DWORD = 0x00000001; +pub const DPD_DELETE_SPECIFIC_VERSION: DWORD = 0x00000002; +pub const DPD_DELETE_ALL_FILES: DWORD = 0x00000004; +pub const APD_STRICT_UPGRADE: DWORD = 0x00000001; +pub const APD_STRICT_DOWNGRADE: DWORD = 0x00000002; +pub const APD_COPY_ALL_FILES: DWORD = 0x00000004; +pub const APD_COPY_NEW_FILES: DWORD = 0x00000008; +pub const APD_COPY_FROM_DIRECTORY: DWORD = 0x00000010; +STRUCT!{struct DOC_INFO_1A { + pDocName: LPSTR, + pOutputFile: LPSTR, + pDatatype: LPSTR, +}} +pub type PDOC_INFO_1A = *mut DOC_INFO_1A; +pub type LPDOC_INFO_1A = *mut DOC_INFO_1A; +STRUCT!{struct DOC_INFO_1W { + pDocName: LPWSTR, + pOutputFile: LPWSTR, + pDatatype: LPWSTR, +}} +pub type PDOC_INFO_1W = *mut DOC_INFO_1W; +pub type LPDOC_INFO_1W = *mut DOC_INFO_1W; +STRUCT!{struct FORM_INFO_1A { + Flags: DWORD, + pName: LPSTR, + Size: SIZEL, + ImageableArea: RECTL, +}} +pub type PFORM_INFO_1A = *mut FORM_INFO_1A; +pub type LPFORM_INFO_1A = *mut FORM_INFO_1A; +STRUCT!{struct FORM_INFO_1W { + Flags: DWORD, + pName: LPWSTR, + Size: SIZEL, + ImageableArea: RECTL, +}} +pub type PFORM_INFO_1W = *mut FORM_INFO_1W; +pub type LPFORM_INFO_1W = *mut FORM_INFO_1W; +pub const STRING_NONE: DWORD = 0x00000001; +pub const STRING_MUIDLL: DWORD = 0x00000002; +pub const STRING_LANGPAIR: DWORD = 0x00000004; +pub const MAX_FORM_KEYWORD_LENGTH: usize = 63 + 1; +STRUCT!{struct FORM_INFO_2A { + Flags: DWORD, + pName: LPCSTR, + Size: SIZEL, + ImageableArea: RECTL, + pKeyword: LPCSTR, + StringType: DWORD, + pMuiDll: LPCSTR, + dwResourceId: DWORD, + pDisplayName: LPCSTR, + wLangId: LANGID, +}} +pub type PFORM_INFO_2A = *mut FORM_INFO_2A; +pub type LPFORM_INFO_2A = *mut FORM_INFO_2A; +STRUCT!{struct FORM_INFO_2W { + Flags: DWORD, + pName: LPCWSTR, + Size: SIZEL, + ImageableArea: RECTL, + pKeyword: LPCSTR, + StringType: DWORD, + pMuiDll: LPCWSTR, + dwResourceId: DWORD, + pDisplayName: LPCWSTR, + wLangId: LANGID, +}} +pub type PFORM_INFO_2W = *mut FORM_INFO_2W; +pub type LPFORM_INFO_2W = *mut FORM_INFO_2W; +STRUCT!{struct DOC_INFO_2A { + pDocName: LPSTR, + pOutputFile: LPSTR, + pDatatype: LPSTR, + dwMode: DWORD, + JobId: DWORD, +}} +pub type PDOC_INFO_2A = *mut DOC_INFO_2A; +pub type LPDOC_INFO_2A = *mut DOC_INFO_2A; +STRUCT!{struct DOC_INFO_2W { + pDocName: LPWSTR, + pOutputFile: LPWSTR, + pDatatype: LPWSTR, + dwMode: DWORD, + JobId: DWORD, +}} +pub type PDOC_INFO_2W = *mut DOC_INFO_2W; +pub type LPDOC_INFO_2W = *mut DOC_INFO_2W; +pub const DI_CHANNEL: DWORD = 1; +pub const DI_READ_SPOOL_JOB: DWORD = 3; +STRUCT!{struct DOC_INFO_3A { + pDocName: LPSTR, + pOutputFile: LPSTR, + pDatatype: LPSTR, + dwFlags: DWORD, +}} +pub type PDOC_INFO_3A = *mut DOC_INFO_3A; +pub type LPDOC_INFO_3A = *mut DOC_INFO_3A; +STRUCT!{struct DOC_INFO_3W { + pDocName: LPWSTR, + pOutputFile: LPWSTR, + pDatatype: LPWSTR, + dwFlags: DWORD, +}} +pub type PDOC_INFO_3W = *mut DOC_INFO_3W; +pub type LPDOC_INFO_3W = *mut DOC_INFO_3W; +pub const DI_MEMORYMAP_WRITE: DWORD = 0x00000001; +pub const FORM_USER: DWORD = 0x00000000; +pub const FORM_BUILTIN: DWORD = 0x00000001; +pub const FORM_PRINTER: DWORD = 0x00000002; +STRUCT!{struct PRINTPROCESSOR_INFO_1A { + pName: LPSTR, +}} +pub type PPRINTPROCESSOR_INFO_1A = *mut PRINTPROCESSOR_INFO_1A; +pub type LPPRINTPROCESSOR_INFO_1A = *mut PRINTPROCESSOR_INFO_1A; +STRUCT!{struct PRINTPROCESSOR_INFO_1W { + pName: LPWSTR, +}} +pub type PPRINTPROCESSOR_INFO_1W = *mut PRINTPROCESSOR_INFO_1W; +pub type LPPRINTPROCESSOR_INFO_1W = *mut PRINTPROCESSOR_INFO_1W; +STRUCT!{struct PRINTPROCESSOR_CAPS_1 { + dwLevel: DWORD, + dwNupOptions: DWORD, + dwPageOrderFlags: DWORD, + dwNumberOfCopies: DWORD, +}} +pub type PPRINTPROCESSOR_CAPS_1 = *mut PRINTPROCESSOR_CAPS_1; +STRUCT!{struct PRINTPROCESSOR_CAPS_2 { + dwLevel: DWORD, + dwNupOptions: DWORD, + dwPageOrderFlags: DWORD, + dwNumberOfCopies: DWORD, + dwDuplexHandlingCaps: DWORD, + dwNupDirectionCaps: DWORD, + dwNupBorderCaps: DWORD, + dwBookletHandlingCaps: DWORD, + dwScalingCaps: DWORD, +}} +pub type PPRINTPROCESSOR_CAPS_2 = *mut PRINTPROCESSOR_CAPS_2; +pub const PPCAPS_RIGHT_THEN_DOWN: DWORD = 0x00000001; +pub const PPCAPS_DOWN_THEN_RIGHT: DWORD = 0x00000001 << 1; +pub const PPCAPS_LEFT_THEN_DOWN: DWORD = 0x00000001 << 2; +pub const PPCAPS_DOWN_THEN_LEFT: DWORD = 0x00000001 << 3; +pub const PPCAPS_BORDER_PRINT: DWORD = 0x00000001; +pub const PPCAPS_BOOKLET_EDGE: DWORD = 0x00000001; +pub const PPCAPS_REVERSE_PAGES_FOR_REVERSE_DUPLEX: DWORD = 0x00000001; +pub const PPCAPS_DONT_SEND_EXTRA_PAGES_FOR_DUPLEX: DWORD = 0x00000001 << 1; +pub const PPCAPS_SQUARE_SCALING: DWORD = 0x00000001; +STRUCT!{struct PORT_INFO_1A { + pName: LPSTR, +}} +pub type PPORT_INFO_1A = *mut PORT_INFO_1A; +pub type LPPORT_INFO_1A = *mut PORT_INFO_1A; +STRUCT!{struct PORT_INFO_1W { + pName: LPWSTR, +}} +pub type PPORT_INFO_1W = *mut PORT_INFO_1W; +pub type LPPORT_INFO_1W = *mut PORT_INFO_1W; +STRUCT!{struct PORT_INFO_2A { + pPortName: LPSTR, + pMonitorName: LPSTR, + pDescription: LPSTR, + fPortType: DWORD, + Reserved: DWORD, +}} +pub type PPORT_INFO_2A = *mut PORT_INFO_2A; +pub type LPPORT_INFO_2A = *mut PORT_INFO_2A; +STRUCT!{struct PORT_INFO_2W { + pPortName: LPWSTR, + pMonitorName: LPWSTR, + pDescription: LPWSTR, + fPortType: DWORD, + Reserved: DWORD, +}} +pub type PPORT_INFO_2W = *mut PORT_INFO_2W; +pub type LPPORT_INFO_2W = *mut PORT_INFO_2W; +pub const PORT_TYPE_WRITE: DWORD = 0x0001; +pub const PORT_TYPE_READ: DWORD = 0x0002; +pub const PORT_TYPE_REDIRECTED: DWORD = 0x0004; +pub const PORT_TYPE_NET_ATTACHED: DWORD = 0x0008; +STRUCT!{struct PORT_INFO_3A { + dwStatus: DWORD, + pszStatus: LPSTR, + dwSeverity: DWORD, +}} +pub type PPORT_INFO_3A = *mut PORT_INFO_3A; +pub type LPPORT_INFO_3A = *mut PORT_INFO_3A; +STRUCT!{struct PORT_INFO_3W { + dwStatus: DWORD, + pszStatus: LPWSTR, + dwSeverity: DWORD, +}} +pub type PPORT_INFO_3W = *mut PORT_INFO_3W; +pub type LPPORT_INFO_3W = *mut PORT_INFO_3W; +pub const PORT_STATUS_TYPE_ERROR: DWORD = 1; +pub const PORT_STATUS_TYPE_WARNING: DWORD = 2; +pub const PORT_STATUS_TYPE_INFO: DWORD = 3; +pub const PORT_STATUS_OFFLINE: DWORD = 1; +pub const PORT_STATUS_PAPER_JAM: DWORD = 2; +pub const PORT_STATUS_PAPER_OUT: DWORD = 3; +pub const PORT_STATUS_OUTPUT_BIN_FULL: DWORD = 4; +pub const PORT_STATUS_PAPER_PROBLEM: DWORD = 5; +pub const PORT_STATUS_NO_TONER: DWORD = 6; +pub const PORT_STATUS_DOOR_OPEN: DWORD = 7; +pub const PORT_STATUS_USER_INTERVENTION: DWORD = 8; +pub const PORT_STATUS_OUT_OF_MEMORY: DWORD = 9; +pub const PORT_STATUS_TONER_LOW: DWORD = 10; +pub const PORT_STATUS_WARMING_UP: DWORD = 11; +pub const PORT_STATUS_POWER_SAVE: DWORD = 12; +STRUCT!{struct MONITOR_INFO_1A { + pName: LPSTR, +}} +pub type PMONITOR_INFO_1A = *mut MONITOR_INFO_1A; +pub type LPMONITOR_INFO_1A = *mut MONITOR_INFO_1A; +STRUCT!{struct MONITOR_INFO_1W { + pName: LPWSTR, +}} +pub type PMONITOR_INFO_1W = *mut MONITOR_INFO_1W; +pub type LPMONITOR_INFO_1W = *mut MONITOR_INFO_1W; +STRUCT!{struct MONITOR_INFO_2A { + pName: LPSTR, + pEnvironment: LPSTR, + pDLLName: LPSTR, +}} +pub type PMONITOR_INFO_2A = *mut MONITOR_INFO_2A; +pub type LPMONITOR_INFO_2A = *mut MONITOR_INFO_2A; +STRUCT!{struct MONITOR_INFO_2W { + pName: LPWSTR, + pEnvironment: LPWSTR, + pDLLName: LPWSTR, +}} +pub type PMONITOR_INFO_2W = *mut MONITOR_INFO_2W; +pub type LPMONITOR_INFO_2W = *mut MONITOR_INFO_2W; +STRUCT!{struct DATATYPES_INFO_1A { + pName: LPSTR, +}} +pub type PDATATYPES_INFO_1A = *mut DATATYPES_INFO_1A; +pub type LPDATATYPES_INFO_1A = *mut DATATYPES_INFO_1A; +STRUCT!{struct DATATYPES_INFO_1W { + pName: LPWSTR, +}} +pub type PDATATYPES_INFO_1W = *mut DATATYPES_INFO_1W; +pub type LPDATATYPES_INFO_1W = *mut DATATYPES_INFO_1W; +STRUCT!{struct PRINTER_DEFAULTSA { + pDataType: LPSTR, + pDevMode: LPDEVMODEA, + DesiredAccess: ACCESS_MASK, +}} +pub type PPRINTER_DEFAULTSA = *mut PRINTER_DEFAULTSA; +pub type LPPRINTER_DEFAULTSA = *mut PRINTER_DEFAULTSA; +STRUCT!{struct PRINTER_DEFAULTSW { + pDataType: LPWSTR, + pDevMode: LPDEVMODEW, + DesiredAccess: ACCESS_MASK, +}} +pub type PPRINTER_DEFAULTSW = *mut PRINTER_DEFAULTSW; +pub type LPPRINTER_DEFAULTSW = *mut PRINTER_DEFAULTSW; +STRUCT!{struct PRINTER_ENUM_VALUESA { + pValueName: LPSTR, + cbValueName: DWORD, + dwType: DWORD, + pData: LPBYTE, + cbData: DWORD, +}} +pub type PPRINTER_ENUM_VALUESA = *mut PRINTER_ENUM_VALUESA; +pub type LPPRINTER_ENUM_VALUESA = *mut PRINTER_ENUM_VALUESA; +STRUCT!{struct PRINTER_ENUM_VALUESW { + pValueName: LPWSTR, + cbValueName: DWORD, + dwType: DWORD, + pData: LPBYTE, + cbData: DWORD, +}} +pub type PPRINTER_ENUM_VALUESW = *mut PRINTER_ENUM_VALUESW; +pub type LPPRINTER_ENUM_VALUESW = *mut PRINTER_ENUM_VALUESW; +extern "system" { + pub fn EnumPrintersA( + Flags: DWORD, + Name: LPSTR, + Level: DWORD, + pPrinterEnum: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn EnumPrintersW( + Flags: DWORD, + Name: LPWSTR, + Level: DWORD, + pPrinterEnum: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; +} +pub const PRINTER_ENUM_DEFAULT: DWORD = 0x00000001; +pub const PRINTER_ENUM_LOCAL: DWORD = 0x00000002; +pub const PRINTER_ENUM_CONNECTIONS: DWORD = 0x00000004; +pub const PRINTER_ENUM_FAVORITE: DWORD = 0x00000004; +pub const PRINTER_ENUM_NAME: DWORD = 0x00000008; +pub const PRINTER_ENUM_REMOTE: DWORD = 0x00000010; +pub const PRINTER_ENUM_SHARED: DWORD = 0x00000020; +pub const PRINTER_ENUM_NETWORK: DWORD = 0x00000040; +pub const PRINTER_ENUM_EXPAND: DWORD = 0x00004000; +pub const PRINTER_ENUM_CONTAINER: DWORD = 0x00008000; +pub const PRINTER_ENUM_ICONMASK: DWORD = 0x00ff0000; +pub const PRINTER_ENUM_ICON1: DWORD = 0x00010000; +pub const PRINTER_ENUM_ICON2: DWORD = 0x00020000; +pub const PRINTER_ENUM_ICON3: DWORD = 0x00040000; +pub const PRINTER_ENUM_ICON4: DWORD = 0x00080000; +pub const PRINTER_ENUM_ICON5: DWORD = 0x00100000; +pub const PRINTER_ENUM_ICON6: DWORD = 0x00200000; +pub const PRINTER_ENUM_ICON7: DWORD = 0x00400000; +pub const PRINTER_ENUM_ICON8: DWORD = 0x00800000; +pub const PRINTER_ENUM_HIDE: DWORD = 0x01000000; +pub const PRINTER_ENUM_CATEGORY_ALL: DWORD = 0x02000000; +pub const PRINTER_ENUM_CATEGORY_3D: DWORD = 0x04000000; +pub const SPOOL_FILE_PERSISTENT: DWORD = 0x00000001; +pub const SPOOL_FILE_TEMPORARY: DWORD = 0x00000002; +extern "system" { + pub fn GetSpoolFileHandle( + hPrinter: HANDLE, + ) -> HANDLE; + pub fn CommitSpoolData( + hPrinter: HANDLE, + hSpoolFile: HANDLE, + cbCommit: DWORD, + ) -> HANDLE; + pub fn CloseSpoolFileHandle( + hPrinter: HANDLE, + hSpoolFile: HANDLE, + ) -> BOOL; + pub fn OpenPrinterA( + pPrinterName: LPSTR, + phPrinter: LPHANDLE, + pDefault: LPPRINTER_DEFAULTSA, + ) -> BOOL; + pub fn OpenPrinterW( + pPrinterName: LPWSTR, + phPrinter: LPHANDLE, + pDefault: LPPRINTER_DEFAULTSW, + ) -> BOOL; + pub fn ResetPrinterA( + hPrinter: HANDLE, + pDefault: LPPRINTER_DEFAULTSA, + ) -> BOOL; + pub fn ResetPrinterW( + hPrinter: HANDLE, + pDefault: LPPRINTER_DEFAULTSW, + ) -> BOOL; + pub fn SetJobA( + hPrinter: HANDLE, + JobId: DWORD, + Level: DWORD, + pJob: LPBYTE, + Command: DWORD, + ) -> BOOL; + pub fn SetJobW( + hPrinter: HANDLE, + JobId: DWORD, + Level: DWORD, + pJob: LPBYTE, + Command: DWORD, + ) -> BOOL; + pub fn GetJobA( + hPrinter: HANDLE, + JobId: DWORD, + Level: DWORD, + pJob: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn GetJobW( + hPrinter: HANDLE, + JobId: DWORD, + Level: DWORD, + pJob: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn EnumJobsA( + hPrinter: HANDLE, + FirstJob: DWORD, + NoJobs: DWORD, + Level: DWORD, + pJob: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn EnumJobsW( + hPrinter: HANDLE, + FirstJob: DWORD, + NoJobs: DWORD, + Level: DWORD, + pJob: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn AddPrinterA( + pName: LPSTR, + Level: DWORD, + pPrinter: LPBYTE, + ) -> HANDLE; + pub fn AddPrinterW( + pName: LPWSTR, + Level: DWORD, + pPrinter: LPBYTE, + ) -> HANDLE; + pub fn DeletePrinter( + hPrinter: HANDLE, + ) -> BOOL; + pub fn SetPrinterA( + hPrinter: HANDLE, + Level: DWORD, + pPrinter: LPBYTE, + Command: DWORD, + ) -> BOOL; + pub fn SetPrinterW( + hPrinter: HANDLE, + Level: DWORD, + pPrinter: LPBYTE, + Command: DWORD, + ) -> BOOL; + pub fn GetPrinterA( + hPrinter: HANDLE, + Level: DWORD, + pPrinter: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn GetPrinterW( + hPrinter: HANDLE, + Level: DWORD, + pPrinter: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn AddPrinterDriverA( + pName: LPSTR, + Level: DWORD, + pDriverInfo: LPBYTE, + ) -> BOOL; + pub fn AddPrinterDriverW( + pName: LPWSTR, + Level: DWORD, + pDriverInfo: LPBYTE, + ) -> BOOL; + pub fn AddPrinterDriverExA( + pName: LPSTR, + Level: DWORD, + pDriverInfo: PBYTE, + dwFileCopyFlags: DWORD, + ) -> BOOL; + pub fn AddPrinterDriverExW( + pName: LPWSTR, + Level: DWORD, + pDriverInfo: PBYTE, + dwFileCopyFlags: DWORD, + ) -> BOOL; + pub fn EnumPrinterDriversA( + pName: LPSTR, + pEnvironment: LPSTR, + Level: DWORD, + pDriverInfo: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn EnumPrinterDriversW( + pName: LPWSTR, + pEnvironment: LPWSTR, + Level: DWORD, + pDriverInfo: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn GetPrinterDriverA( + hPrinter: HANDLE, + pEnvironment: LPSTR, + Level: DWORD, + pDriverInfo: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn GetPrinterDriverW( + hPrinter: HANDLE, + pEnvironment: LPWSTR, + Level: DWORD, + pDriverInfo: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn GetPrinterDriverDirectoryA( + pName: LPSTR, + pEnvironment: LPSTR, + Level: DWORD, + pDriverDirectory: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn GetPrinterDriverDirectoryW( + pName: LPWSTR, + pEnvironment: LPWSTR, + Level: DWORD, + pDriverDirectory: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn DeletePrinterDriverA( + pName: LPSTR, + pEnvironment: LPSTR, + pDriverName: LPSTR, + ) -> BOOL; + pub fn DeletePrinterDriverW( + pName: LPWSTR, + pEnvironment: LPWSTR, + pDriverName: LPWSTR, + ) -> BOOL; + pub fn DeletePrinterDriverExA( + pName: LPSTR, + pEnvironment: LPSTR, + pDriverName: LPSTR, + dwDeleteFlag: DWORD, + dwVersionFlag: DWORD, + ) -> BOOL; + pub fn DeletePrinterDriverExW( + pName: LPWSTR, + pEnvironment: LPWSTR, + pDriverName: LPWSTR, + dwDeleteFlag: DWORD, + dwVersionFlag: DWORD, + ) -> BOOL; + pub fn AddPrintProcessorA( + pName: LPSTR, + pEnvironment: LPSTR, + pPathName: LPSTR, + pPrintProcessorName: LPSTR, + ) -> BOOL; + pub fn AddPrintProcessorW( + pName: LPWSTR, + pEnvironment: LPWSTR, + pPathName: LPWSTR, + pPrintProcessorName: LPWSTR, + ) -> BOOL; + pub fn EnumPrintProcessorsA( + pName: LPSTR, + pEnvironment: LPSTR, + Level: DWORD, + pPrintProcessorInfo: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn EnumPrintProcessorsW( + pName: LPWSTR, + pEnvironment: LPWSTR, + Level: DWORD, + pPrintProcessorInfo: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn GetPrintProcessorDirectoryA( + pName: LPSTR, + pEnvironment: LPSTR, + Level: DWORD, + pPrintProcessorInfo: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn GetPrintProcessorDirectoryW( + pName: LPWSTR, + pEnvironment: LPWSTR, + Level: DWORD, + pPrintProcessorInfo: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn EnumPrintProcessorDatatypesA( + pName: LPSTR, + pPrintProcessorName: LPSTR, + Level: DWORD, + pDatatypes: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn EnumPrintProcessorDatatypesW( + pName: LPWSTR, + pPrintProcessorName: LPWSTR, + Level: DWORD, + pDatatypes: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn DeletePrintProcessorA( + pName: LPSTR, + pEnvironment: LPSTR, + pPrintProcessorName: LPSTR, + ) -> BOOL; + pub fn DeletePrintProcessorW( + pName: LPWSTR, + pEnvironment: LPWSTR, + pPrintProcessorName: LPWSTR, + ) -> BOOL; + pub fn StartDocPrinterA( + hPrinter: HANDLE, + Level: DWORD, + pDocInfo: LPBYTE, + ) -> DWORD; + pub fn StartDocPrinterW( + hPrinter: HANDLE, + Level: DWORD, + pDocInfo: LPBYTE, + ) -> DWORD; + pub fn StartPagePrinter( + hPrinter: HANDLE, + ) -> BOOL; + pub fn WritePrinter( + hPrinter: HANDLE, + pBuf: LPVOID, + cbBuf: DWORD, + pcWritten: LPDWORD, + ) -> BOOL; + pub fn FlushPrinter( + hPrinter: HANDLE, + pBuf: LPVOID, + cbBuf: DWORD, + pcWritten: LPDWORD, + cSleep: DWORD, + ) -> BOOL; + pub fn EndPagePrinter( + hPrinter: HANDLE, + ) -> BOOL; + pub fn AbortPrinter( + hPrinter: HANDLE, + ) -> BOOL; + pub fn ReadPrinter( + hPrinter: HANDLE, + pBuf: LPVOID, + cbBuf: DWORD, + pNoBytesRead: LPDWORD, + ) -> BOOL; + pub fn EndDocPrinter( + hPrinter: HANDLE, + ) -> BOOL; + pub fn AddJobA( + hPrinter: HANDLE, + Level: DWORD, + pData: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn AddJobW( + hPrinter: HANDLE, + Level: DWORD, + pData: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn ScheduleJob( + hPrinter: HANDLE, + JobId: DWORD, + ) -> BOOL; + pub fn PrinterProperties( + hWnd: HWND, + hPrinter: HANDLE, + ) -> BOOL; + pub fn DocumentPropertiesA( + hWnd: HWND, + hPrinter: HANDLE, + pDeviceName: LPSTR, + pDevModeOutput: PDEVMODEA, + pDevModeInput: PDEVMODEA, + fMode: DWORD, + ) -> LONG; + pub fn DocumentPropertiesW( + hWnd: HWND, + hPrinter: HANDLE, + pDeviceName: LPWSTR, + pDevModeOutput: PDEVMODEW, + pDevModeInput: PDEVMODEW, + fMode: DWORD, + ) -> LONG; + pub fn AdvancedDocumentPropertiesA( + hWnd: HWND, + hPrinter: HANDLE, + pDeviceName: LPSTR, + pDevModeOutput: PDEVMODEA, + pDevModeInput: PDEVMODEA, + ) -> LONG; + pub fn AdvancedDocumentPropertiesW( + hWnd: HWND, + hPrinter: HANDLE, + pDeviceName: LPWSTR, + pDevModeOutput: PDEVMODEW, + pDevModeInput: PDEVMODEW, + ) -> LONG; + pub fn ExtDeviceMode( + hWnd: HWND, + hInst: HANDLE, + pDevModeOutput: LPDEVMODEA, + pDeviceName: LPSTR, + pPort: LPSTR, + pDevModeInput: LPDEVMODEA, + pProfile: LPSTR, + fMode: DWORD, + ) -> LONG; + pub fn GetPrinterDataA( + hPrinter: HANDLE, + pValueName: LPSTR, + pType: LPDWORD, + pData: LPBYTE, + nSize: DWORD, + pcbNeeded: LPDWORD, + ) -> DWORD; + pub fn GetPrinterDataW( + hPrinter: HANDLE, + pValueName: LPWSTR, + pType: LPDWORD, + pData: LPBYTE, + nSize: DWORD, + pcbNeeded: LPDWORD, + ) -> DWORD; + pub fn GetPrinterDataExA( + hPrinter: HANDLE, + pKeyName: LPCSTR, + pValueName: LPCSTR, + pType: LPDWORD, + pData: LPBYTE, + nSize: DWORD, + pcbNeeded: LPDWORD, + ) -> DWORD; + pub fn GetPrinterDataExW( + hPrinter: HANDLE, + pKeyName: LPCWSTR, + pValueName: LPCWSTR, + pType: LPDWORD, + pData: LPBYTE, + nSize: DWORD, + pcbNeeded: LPDWORD, + ) -> DWORD; + pub fn EnumPrinterDataA( + hPrinter: HANDLE, + dwIndex: DWORD, + pValueName: LPSTR, + cbValueName: DWORD, + pcbValueName: LPDWORD, + pType: LPDWORD, + pData: LPBYTE, + cbData: DWORD, + pcbData: LPDWORD, + ) -> DWORD; + pub fn EnumPrinterDataW( + hPrinter: HANDLE, + dwIndex: DWORD, + pValueName: LPWSTR, + cbValueName: DWORD, + pcbValueName: LPDWORD, + pType: LPDWORD, + pData: LPBYTE, + cbData: DWORD, + pcbData: LPDWORD, + ) -> DWORD; + pub fn EnumPrinterDataExA( + hPrinter: HANDLE, + pKeyName: LPCSTR, + pEnumValues: LPBYTE, + cbEnumValues: DWORD, + pcbEnumValues: LPDWORD, + pnEnumValues: LPDWORD, + ) -> DWORD; + pub fn EnumPrinterDataExW( + hPrinter: HANDLE, + pKeyName: LPCWSTR, + pEnumValues: LPBYTE, + cbEnumValues: DWORD, + pcbEnumValues: LPDWORD, + pnEnumValues: LPDWORD, + ) -> DWORD; + pub fn EnumPrinterKeyA( + hPrinter: HANDLE, + pKeyName: LPCSTR, + pSubKey: LPSTR, + cbSubkey: DWORD, + pcbSubkey: LPDWORD, + ) -> DWORD; + pub fn EnumPrinterKeyW( + hPrinter: HANDLE, + pKeyName: LPCWSTR, + pSubKey: LPWSTR, + cbSubkey: DWORD, + pcbSubkey: LPDWORD, + ) -> DWORD; + pub fn SetPrinterDataA( + hPrinter: HANDLE, + pValueName: LPSTR, + Type: DWORD, + pData: LPBYTE, + cbData: DWORD, + ) -> DWORD; + pub fn SetPrinterDataW( + hPrinter: HANDLE, + pValueName: LPWSTR, + Type: DWORD, + pData: LPBYTE, + cbData: DWORD, + ) -> DWORD; + pub fn SetPrinterDataExA( + hPrinter: HANDLE, + pKeyName: LPCSTR, + pValueName: LPCSTR, + Type: DWORD, + pData: LPBYTE, + cbData: DWORD, + ) -> DWORD; + pub fn SetPrinterDataExW( + hPrinter: HANDLE, + pKeyName: LPCWSTR, + pValueName: LPCWSTR, + Type: DWORD, + pData: LPBYTE, + cbData: DWORD, + ) -> DWORD; + pub fn DeletePrinterDataA( + hPrinter: HANDLE, + pValueName: LPSTR, + ) -> DWORD; + pub fn DeletePrinterDataW( + hPrinter: HANDLE, + pValueName: LPWSTR, + ) -> DWORD; + pub fn DeletePrinterDataExA( + hPrinter: HANDLE, + pKeyName: LPCSTR, + pValueName: LPCSTR, + ) -> DWORD; + pub fn DeletePrinterDataExW( + hPrinter: HANDLE, + pKeyName: LPCWSTR, + pValueName: LPCWSTR, + ) -> DWORD; + pub fn DeletePrinterKeyA( + hPrinter: HANDLE, + pKeyName: LPCSTR, + ) -> DWORD; + pub fn DeletePrinterKeyW( + hPrinter: HANDLE, + pKeyName: LPCWSTR, + ) -> DWORD; +} +pub const PRINTER_NOTIFY_TYPE: DWORD = 0x00; +pub const JOB_NOTIFY_TYPE: DWORD = 0x01; +pub const SERVER_NOTIFY_TYPE: DWORD = 0x02; +pub const PRINTER_NOTIFY_FIELD_SERVER_NAME: DWORD = 0x00; +pub const PRINTER_NOTIFY_FIELD_PRINTER_NAME: DWORD = 0x01; +pub const PRINTER_NOTIFY_FIELD_SHARE_NAME: DWORD = 0x02; +pub const PRINTER_NOTIFY_FIELD_PORT_NAME: DWORD = 0x03; +pub const PRINTER_NOTIFY_FIELD_DRIVER_NAME: DWORD = 0x04; +pub const PRINTER_NOTIFY_FIELD_COMMENT: DWORD = 0x05; +pub const PRINTER_NOTIFY_FIELD_LOCATION: DWORD = 0x06; +pub const PRINTER_NOTIFY_FIELD_DEVMODE: DWORD = 0x07; +pub const PRINTER_NOTIFY_FIELD_SEPFILE: DWORD = 0x08; +pub const PRINTER_NOTIFY_FIELD_PRINT_PROCESSOR: DWORD = 0x09; +pub const PRINTER_NOTIFY_FIELD_PARAMETERS: DWORD = 0x0A; +pub const PRINTER_NOTIFY_FIELD_DATATYPE: DWORD = 0x0B; +pub const PRINTER_NOTIFY_FIELD_SECURITY_DESCRIPTOR: DWORD = 0x0C; +pub const PRINTER_NOTIFY_FIELD_ATTRIBUTES: DWORD = 0x0D; +pub const PRINTER_NOTIFY_FIELD_PRIORITY: DWORD = 0x0E; +pub const PRINTER_NOTIFY_FIELD_DEFAULT_PRIORITY: DWORD = 0x0F; +pub const PRINTER_NOTIFY_FIELD_START_TIME: DWORD = 0x10; +pub const PRINTER_NOTIFY_FIELD_UNTIL_TIME: DWORD = 0x11; +pub const PRINTER_NOTIFY_FIELD_STATUS: DWORD = 0x12; +pub const PRINTER_NOTIFY_FIELD_STATUS_STRING: DWORD = 0x13; +pub const PRINTER_NOTIFY_FIELD_CJOBS: DWORD = 0x14; +pub const PRINTER_NOTIFY_FIELD_AVERAGE_PPM: DWORD = 0x15; +pub const PRINTER_NOTIFY_FIELD_TOTAL_PAGES: DWORD = 0x16; +pub const PRINTER_NOTIFY_FIELD_PAGES_PRINTED: DWORD = 0x17; +pub const PRINTER_NOTIFY_FIELD_TOTAL_BYTES: DWORD = 0x18; +pub const PRINTER_NOTIFY_FIELD_BYTES_PRINTED: DWORD = 0x19; +pub const PRINTER_NOTIFY_FIELD_OBJECT_GUID: DWORD = 0x1A; +pub const PRINTER_NOTIFY_FIELD_FRIENDLY_NAME: DWORD = 0x1B; +pub const PRINTER_NOTIFY_FIELD_BRANCH_OFFICE_PRINTING: DWORD = 0x1C; +pub const JOB_NOTIFY_FIELD_PRINTER_NAME: DWORD = 0x00; +pub const JOB_NOTIFY_FIELD_MACHINE_NAME: DWORD = 0x01; +pub const JOB_NOTIFY_FIELD_PORT_NAME: DWORD = 0x02; +pub const JOB_NOTIFY_FIELD_USER_NAME: DWORD = 0x03; +pub const JOB_NOTIFY_FIELD_NOTIFY_NAME: DWORD = 0x04; +pub const JOB_NOTIFY_FIELD_DATATYPE: DWORD = 0x05; +pub const JOB_NOTIFY_FIELD_PRINT_PROCESSOR: DWORD = 0x06; +pub const JOB_NOTIFY_FIELD_PARAMETERS: DWORD = 0x07; +pub const JOB_NOTIFY_FIELD_DRIVER_NAME: DWORD = 0x08; +pub const JOB_NOTIFY_FIELD_DEVMODE: DWORD = 0x09; +pub const JOB_NOTIFY_FIELD_STATUS: DWORD = 0x0A; +pub const JOB_NOTIFY_FIELD_STATUS_STRING: DWORD = 0x0B; +pub const JOB_NOTIFY_FIELD_SECURITY_DESCRIPTOR: DWORD = 0x0C; +pub const JOB_NOTIFY_FIELD_DOCUMENT: DWORD = 0x0D; +pub const JOB_NOTIFY_FIELD_PRIORITY: DWORD = 0x0E; +pub const JOB_NOTIFY_FIELD_POSITION: DWORD = 0x0F; +pub const JOB_NOTIFY_FIELD_SUBMITTED: DWORD = 0x10; +pub const JOB_NOTIFY_FIELD_START_TIME: DWORD = 0x11; +pub const JOB_NOTIFY_FIELD_UNTIL_TIME: DWORD = 0x12; +pub const JOB_NOTIFY_FIELD_TIME: DWORD = 0x13; +pub const JOB_NOTIFY_FIELD_TOTAL_PAGES: DWORD = 0x14; +pub const JOB_NOTIFY_FIELD_PAGES_PRINTED: DWORD = 0x15; +pub const JOB_NOTIFY_FIELD_TOTAL_BYTES: DWORD = 0x16; +pub const JOB_NOTIFY_FIELD_BYTES_PRINTED: DWORD = 0x17; +pub const JOB_NOTIFY_FIELD_REMOTE_JOB_ID: DWORD = 0x18; +pub const SERVER_NOTIFY_FIELD_PRINT_DRIVER_ISOLATION_GROUP: DWORD = 0x00; +pub const PRINTER_NOTIFY_CATEGORY_ALL: DWORD = 0x001000; +pub const PRINTER_NOTIFY_CATEGORY_3D: DWORD = 0x002000; +STRUCT!{struct PRINTER_NOTIFY_OPTIONS_TYPE { + Type: WORD, + Reserved0: WORD, + Reserved1: DWORD, + Reserved2: DWORD, + Count: DWORD, + pFields: PWORD, +}} +pub type PPRINTER_NOTIFY_OPTIONS_TYPE = *mut PRINTER_NOTIFY_OPTIONS_TYPE; +pub type LPPRINTER_NOTIFY_OPTIONS_TYPE = *mut PRINTER_NOTIFY_OPTIONS_TYPE; +pub const PRINTER_NOTIFY_OPTIONS_REFRESH: DWORD = 0x01; +STRUCT!{struct PRINTER_NOTIFY_OPTIONS { + Version: DWORD, + Flags: DWORD, + Count: DWORD, + pTypes: PPRINTER_NOTIFY_OPTIONS_TYPE, +}} +pub type PPRINTER_NOTIFY_OPTIONS = *mut PRINTER_NOTIFY_OPTIONS; +pub type LPPRINTER_NOTIFY_OPTIONS = *mut PRINTER_NOTIFY_OPTIONS; +pub const PRINTER_NOTIFY_INFO_DISCARDED: DWORD = 0x01; +STRUCT!{struct PRINTER_NOTIFY_INFO_DATA_NotifyData_Data { + cbBuf: DWORD, + pBuf: LPVOID, +}} +UNION!{union PRINTER_NOTIFY_INFO_DATA_NotifyData { + [usize; 2], + adwData adwData_mut: [DWORD; 2], + Data Data_mut: PRINTER_NOTIFY_INFO_DATA_NotifyData_Data, +}} +STRUCT!{struct PRINTER_NOTIFY_INFO_DATA { + Type: WORD, + Field: WORD, + Reserved: DWORD, + Id: DWORD, + NotifyData: PRINTER_NOTIFY_INFO_DATA_NotifyData, +}} +pub type PPRINTER_NOTIFY_INFO_DATA = *mut PRINTER_NOTIFY_INFO_DATA; +pub type LPPRINTER_NOTIFY_INFO_DATA = *mut PRINTER_NOTIFY_INFO_DATA; +STRUCT!{struct PRINTER_NOTIFY_INFO { + Version: DWORD, + Flags: DWORD, + Count: DWORD, + aData: [PRINTER_NOTIFY_INFO_DATA; 1], +}} +pub type PPRINTER_NOTIFY_INFO = *mut PRINTER_NOTIFY_INFO; +pub type LPPRINTER_NOTIFY_INFO = *mut PRINTER_NOTIFY_INFO; +STRUCT!{struct BINARY_CONTAINER { + cbBuf: DWORD, + pData: LPBYTE, +}} +pub type PBINARY_CONTAINER = *mut BINARY_CONTAINER; +UNION!{union BIDI_DATA_u { + [usize; 2], + bData bData_mut: BOOL, + iData iData_mut: LONG, + sData sData_mut: LPWSTR, + fData fData_mut: FLOAT, + biData biData_mut: BINARY_CONTAINER, +}} +STRUCT!{struct BIDI_DATA { + dwBidiType: DWORD, + u: BIDI_DATA_u, +}} +pub type PBIDI_DATA = *mut BIDI_DATA; +pub type LPBIDI_DATA = *mut BIDI_DATA; +STRUCT!{struct BIDI_REQUEST_DATA { + dwReqNumber: DWORD, + pSchema: LPWSTR, + data: BIDI_DATA, +}} +pub type PBIDI_REQUEST_DATA = *mut BIDI_REQUEST_DATA; +pub type LPBIDI_REQUEST_DATA = *mut BIDI_REQUEST_DATA; +STRUCT!{struct BIDI_REQUEST_CONTAINER { + Version: DWORD, + Flags: DWORD, + Count: DWORD, + aData: [BIDI_REQUEST_DATA; 1], +}} +pub type PBIDI_REQUEST_CONTAINER = *mut BIDI_REQUEST_CONTAINER; +pub type LPBIDI_REQUEST_CONTAINER = *mut BIDI_REQUEST_CONTAINER; +STRUCT!{struct BIDI_RESPONSE_DATA { + dwResult: DWORD, + dwReqNumber: DWORD, + pSchema: LPWSTR, + data: BIDI_DATA, +}} +pub type PBIDI_RESPONSE_DATA = *mut BIDI_RESPONSE_DATA; +pub type LPBIDI_RESPONSE_DATA = *mut BIDI_RESPONSE_DATA; +STRUCT!{struct BIDI_RESPONSE_CONTAINER { + Version: DWORD, + Flags: DWORD, + Count: DWORD, + aData: [BIDI_RESPONSE_DATA; 1], +}} +pub type PBIDI_RESPONSE_CONTAINER = *mut BIDI_RESPONSE_CONTAINER; +pub type LPBIDI_RESPONSE_CONTAINER = *mut BIDI_RESPONSE_CONTAINER; +pub const BIDI_ACTION_ENUM_SCHEMA: &'static str = "EnumSchema"; +pub const BIDI_ACTION_GET: &'static str = "Get"; +pub const BIDI_ACTION_SET: &'static str = "Set"; +pub const BIDI_ACTION_GET_ALL: &'static str = "GetAll"; +pub const BIDI_ACTION_GET_WITH_ARGUMENT: &'static str = "GetWithArgument"; +ENUM!{enum BIDI_TYPE { + BIDI_NULL = 0, + BIDI_INT = 1, + BIDI_FLOAT = 2, + BIDI_BOOL = 3, + BIDI_STRING = 4, + BIDI_TEXT = 5, + BIDI_ENUM = 6, + BIDI_BLOB = 7, +}} +pub const BIDI_ACCESS_ADMINISTRATOR: DWORD = 0x1; +pub const BIDI_ACCESS_USER: DWORD = 0x2; +pub const ERROR_BIDI_STATUS_OK: DWORD = 0; +pub const ERROR_BIDI_NOT_SUPPORTED: DWORD = ERROR_NOT_SUPPORTED; +pub const ERROR_BIDI_ERROR_BASE: DWORD = 13000; +pub const ERROR_BIDI_STATUS_WARNING: DWORD = ERROR_BIDI_ERROR_BASE + 1; +pub const ERROR_BIDI_SCHEMA_READ_ONLY: DWORD = ERROR_BIDI_ERROR_BASE + 2; +pub const ERROR_BIDI_SERVER_OFFLINE: DWORD = ERROR_BIDI_ERROR_BASE + 3; +pub const ERROR_BIDI_DEVICE_OFFLINE: DWORD = ERROR_BIDI_ERROR_BASE + 4; +pub const ERROR_BIDI_SCHEMA_NOT_SUPPORTED: DWORD = ERROR_BIDI_ERROR_BASE + 5; +pub const ERROR_BIDI_SET_DIFFERENT_TYPE: DWORD = ERROR_BIDI_ERROR_BASE + 6; +pub const ERROR_BIDI_SET_MULTIPLE_SCHEMAPATH: DWORD = ERROR_BIDI_ERROR_BASE + 7; +pub const ERROR_BIDI_SET_INVALID_SCHEMAPATH: DWORD = ERROR_BIDI_ERROR_BASE + 8; +pub const ERROR_BIDI_SET_UNKNOWN_FAILURE: DWORD = ERROR_BIDI_ERROR_BASE + 9; +pub const ERROR_BIDI_SCHEMA_WRITE_ONLY: DWORD = ERROR_BIDI_ERROR_BASE + 10; +pub const ERROR_BIDI_GET_REQUIRES_ARGUMENT: DWORD = ERROR_BIDI_ERROR_BASE + 11; +pub const ERROR_BIDI_GET_ARGUMENT_NOT_SUPPORTED: DWORD = ERROR_BIDI_ERROR_BASE + 12; +pub const ERROR_BIDI_GET_MISSING_ARGUMENT: DWORD = ERROR_BIDI_ERROR_BASE + 13; +pub const ERROR_BIDI_DEVICE_CONFIG_UNCHANGED: DWORD = ERROR_BIDI_ERROR_BASE + 14; +pub const ERROR_BIDI_NO_LOCALIZED_RESOURCES: DWORD = ERROR_BIDI_ERROR_BASE + 15; +pub const ERROR_BIDI_NO_BIDI_SCHEMA_EXTENSIONS: DWORD = ERROR_BIDI_ERROR_BASE + 16; +pub const ERROR_BIDI_UNSUPPORTED_CLIENT_LANGUAGE: DWORD = ERROR_BIDI_ERROR_BASE + 17; +pub const ERROR_BIDI_UNSUPPORTED_RESOURCE_FORMAT: DWORD = ERROR_BIDI_ERROR_BASE + 18; +extern "system" { + pub fn WaitForPrinterChange( + hPrinter: HANDLE, + Flags: DWORD, + ) -> DWORD; + pub fn FindFirstPrinterChangeNotification( + hPrinter: HANDLE, + fdwFilter: DWORD, + fdwOptions: DWORD, + pPrinterNotifyOptions: LPVOID, + ) -> HANDLE; + pub fn FindNextPrinterChangeNotification( + hChange: HANDLE, + pdwChange: PDWORD, + pPrinterNotifyOptions: LPVOID, + ppPrinterNotifyInfo: *mut LPVOID, + ) -> BOOL; + pub fn FreePrinterNotifyInfo( + pPrinterNotifyInfo: PPRINTER_NOTIFY_INFO, + ) -> BOOL; + pub fn FindClosePrinterChangeNotification( + hChange: HANDLE, + ) -> BOOL; +} +pub const PRINTER_CHANGE_ADD_PRINTER: DWORD = 0x00000001; +pub const PRINTER_CHANGE_SET_PRINTER: DWORD = 0x00000002; +pub const PRINTER_CHANGE_DELETE_PRINTER: DWORD = 0x00000004; +pub const PRINTER_CHANGE_FAILED_CONNECTION_PRINTER: DWORD = 0x00000008; +pub const PRINTER_CHANGE_PRINTER: DWORD = 0x000000FF; +pub const PRINTER_CHANGE_ADD_JOB: DWORD = 0x00000100; +pub const PRINTER_CHANGE_SET_JOB: DWORD = 0x00000200; +pub const PRINTER_CHANGE_DELETE_JOB: DWORD = 0x00000400; +pub const PRINTER_CHANGE_WRITE_JOB: DWORD = 0x00000800; +pub const PRINTER_CHANGE_JOB: DWORD = 0x0000FF00; +pub const PRINTER_CHANGE_ADD_FORM: DWORD = 0x00010000; +pub const PRINTER_CHANGE_SET_FORM: DWORD = 0x00020000; +pub const PRINTER_CHANGE_DELETE_FORM: DWORD = 0x00040000; +pub const PRINTER_CHANGE_FORM: DWORD = 0x00070000; +pub const PRINTER_CHANGE_ADD_PORT: DWORD = 0x00100000; +pub const PRINTER_CHANGE_CONFIGURE_PORT: DWORD = 0x00200000; +pub const PRINTER_CHANGE_DELETE_PORT: DWORD = 0x00400000; +pub const PRINTER_CHANGE_PORT: DWORD = 0x00700000; +pub const PRINTER_CHANGE_ADD_PRINT_PROCESSOR: DWORD = 0x01000000; +pub const PRINTER_CHANGE_DELETE_PRINT_PROCESSOR: DWORD = 0x04000000; +pub const PRINTER_CHANGE_PRINT_PROCESSOR: DWORD = 0x07000000; +pub const PRINTER_CHANGE_SERVER: DWORD = 0x08000000; +pub const PRINTER_CHANGE_ADD_PRINTER_DRIVER: DWORD = 0x10000000; +pub const PRINTER_CHANGE_SET_PRINTER_DRIVER: DWORD = 0x20000000; +pub const PRINTER_CHANGE_DELETE_PRINTER_DRIVER: DWORD = 0x40000000; +pub const PRINTER_CHANGE_PRINTER_DRIVER: DWORD = 0x70000000; +pub const PRINTER_CHANGE_TIMEOUT: DWORD = 0x80000000; +pub const PRINTER_CHANGE_ALL: DWORD = 0x7F77FFFF; +extern "system" { + pub fn PrinterMessageBoxA( + hPrinter: HANDLE, + Error: DWORD, + hWnd: HWND, + pText: LPSTR, + pCaption: LPSTR, + dwType: DWORD, + ) -> DWORD; + pub fn PrinterMessageBoxW( + hPrinter: HANDLE, + Error: DWORD, + hWnd: HWND, + pText: LPWSTR, + pCaption: LPWSTR, + dwType: DWORD, + ) -> DWORD; +} +pub const PRINTER_ERROR_INFORMATION: DWORD = 0x80000000; +pub const PRINTER_ERROR_WARNING: DWORD = 0x40000000; +pub const PRINTER_ERROR_SEVERE: DWORD = 0x20000000; +pub const PRINTER_ERROR_OUTOFPAPER: DWORD = 0x00000001; +pub const PRINTER_ERROR_JAM: DWORD = 0x00000002; +pub const PRINTER_ERROR_OUTOFTONER: DWORD = 0x00000004; +extern "system" { + pub fn ClosePrinter( + hPrinter: HANDLE, + ) -> BOOL; + pub fn AddFormA( + hPrinter: HANDLE, + Level: DWORD, + pForm: LPBYTE, + ) -> BOOL; + pub fn AddFormW( + hPrinter: HANDLE, + Level: DWORD, + pForm: LPBYTE, + ) -> BOOL; + pub fn DeleteFormA( + hPrinter: HANDLE, + pFormName: LPSTR, + ) -> BOOL; + pub fn DeleteFormW( + hPrinter: HANDLE, + pFormName: LPWSTR, + ) -> BOOL; + pub fn GetFormA( + hPrinter: HANDLE, + pFormName: LPSTR, + Level: DWORD, + pForm: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn GetFormW( + hPrinter: HANDLE, + pFormName: LPWSTR, + Level: DWORD, + pForm: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn SetFormA( + hPrinter: HANDLE, + pFormName: LPSTR, + Level: DWORD, + pForm: LPBYTE, + ) -> BOOL; + pub fn SetFormW( + hPrinter: HANDLE, + pFormName: LPWSTR, + Level: DWORD, + pForm: LPBYTE, + ) -> BOOL; + pub fn EnumFormsA( + hPrinter: HANDLE, + Level: DWORD, + pForm: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn EnumFormsW( + hPrinter: HANDLE, + Level: DWORD, + pForm: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn EnumMonitorsA( + pName: LPSTR, + Level: DWORD, + pMonitor: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn EnumMonitorsW( + pName: LPWSTR, + Level: DWORD, + pMonitor: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn AddMonitorA( + pName: LPSTR, + Level: DWORD, + pMonitors: LPBYTE, + ) -> BOOL; + pub fn AddMonitorW( + pName: LPWSTR, + Level: DWORD, + pMonitors: LPBYTE, + ) -> BOOL; + pub fn DeleteMonitorA( + pName: LPSTR, + pEnvironment: LPSTR, + pMonitorName: LPSTR, + ) -> BOOL; + pub fn DeleteMonitorW( + pName: LPWSTR, + pEnvironment: LPWSTR, + pMonitorName: LPWSTR, + ) -> BOOL; + pub fn EnumPortsA( + pName: LPSTR, + Level: DWORD, + pPort: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn EnumPortsW( + pName: LPWSTR, + Level: DWORD, + pPort: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + pcReturned: LPDWORD, + ) -> BOOL; + pub fn AddPortA( + pName: LPSTR, + hWnd: HWND, + pMonitorName: LPSTR, + ) -> BOOL; + pub fn AddPortW( + pName: LPWSTR, + hWnd: HWND, + pMonitorName: LPWSTR, + ) -> BOOL; + pub fn ConfigurePortA( + pName: LPSTR, + hWnd: HWND, + pPortName: LPSTR, + ) -> BOOL; + pub fn ConfigurePortW( + pName: LPWSTR, + hWnd: HWND, + pPortName: LPWSTR, + ) -> BOOL; + pub fn DeletePortA( + pName: LPSTR, + hWnd: HWND, + pPortName: LPSTR, + ) -> BOOL; + pub fn DeletePortW( + pName: LPWSTR, + hWnd: HWND, + pPortName: LPWSTR, + ) -> BOOL; + pub fn XcvDataW( + hXcv: HANDLE, + pszDataName: PCWSTR, + pInputData: PBYTE, + cbInputData: DWORD, + pOutputData: PBYTE, + cbOutputData: DWORD, + pcbOutputNeeded: PDWORD, + pdwStatus: PDWORD, + ) -> BOOL; + pub fn GetDefaultPrinterA( + pszBuffer: LPSTR, + pcchBuffer: LPDWORD, + ) -> BOOL; + pub fn GetDefaultPrinterW( + pszBuffer: LPWSTR, + pcchBuffer: LPDWORD, + ) -> BOOL; + pub fn SetDefaultPrinterA( + pszPrinter: LPCSTR, + ) -> BOOL; + pub fn SetDefaultPrinterW( + pszPrinter: LPCWSTR, + ) -> BOOL; + pub fn SetPortA( + pName: LPSTR, + pPortName: LPSTR, + dwLevel: DWORD, + pPortInfo: LPBYTE, + ) -> BOOL; + pub fn SetPortW(pName: LPWSTR, + pPortName: LPWSTR, + dwLevel: DWORD, + pPortInfo: LPBYTE, + ) -> BOOL; + pub fn AddPrinterConnectionA( + pName: LPSTR, + ) -> BOOL; + pub fn AddPrinterConnectionW( + pName: LPWSTR, + ) -> BOOL; + pub fn DeletePrinterConnectionA( + pName: LPSTR, + ) -> BOOL; + pub fn DeletePrinterConnectionW( + pName: LPWSTR, + ) -> BOOL; + pub fn ConnectToPrinterDlg( + hwnd: HWND, + Flags: DWORD, + ) -> HANDLE; +} +STRUCT!{struct PROVIDOR_INFO_1A { + pName: LPSTR, + pEnvironment: LPSTR, + pDLLName: LPSTR, +}} +pub type PPROVIDOR_INFO_1A = *mut PROVIDOR_INFO_1A; +pub type LPPROVIDOR_INFO_1A = *mut PROVIDOR_INFO_1A; +STRUCT!{struct PROVIDOR_INFO_1W { + pName: LPWSTR, + pEnvironment: LPWSTR, + pDLLName: LPWSTR, +}} +pub type PPROVIDOR_INFO_1W = *mut PROVIDOR_INFO_1W; +pub type LPPROVIDOR_INFO_1W = *mut PROVIDOR_INFO_1W; +STRUCT!{struct PROVIDOR_INFO_2A { + pOrder: LPSTR, +}} +pub type PPROVIDOR_INFO_2A = *mut PROVIDOR_INFO_2A; +pub type LPPROVIDOR_INFO_2A = *mut PROVIDOR_INFO_2A; +STRUCT!{struct PROVIDOR_INFO_2W { + pOrder: LPWSTR, +}} +pub type PPROVIDOR_INFO_2W = *mut PROVIDOR_INFO_2W; +pub type LPPROVIDOR_INFO_2W = *mut PROVIDOR_INFO_2W; +extern "system" { + pub fn AddPrintProvidorA( + pName: LPSTR, + Level: DWORD, + pProvidorInfo: LPBYTE, + ) -> BOOL; + pub fn AddPrintProvidorW( + pName: LPWSTR, + Level: DWORD, + pProvidorInfo: LPBYTE, + ) -> BOOL; + pub fn DeletePrintProvidorA( + pName: LPSTR, + pEnvironment: LPSTR, + pPrintProvidorName: LPSTR, + ) -> BOOL; + pub fn DeletePrintProvidorW( + pName: LPWSTR, + pEnvironment: LPWSTR, + pPrintProvidorName: LPWSTR, + ) -> BOOL; + pub fn IsValidDevmodeA( + pDevmode: PDEVMODEA, + DevmodeSize: size_t, + ) -> BOOL; + pub fn IsValidDevmodeW( + pDevmode: PDEVMODEW, + DevmodeSize: size_t, + ) -> BOOL; +} +pub const SPLREG_DEFAULT_SPOOL_DIRECTORY: &'static str = "DefaultSpoolDirectory"; +pub const SPLREG_PORT_THREAD_PRIORITY_DEFAULT: &'static str = "PortThreadPriorityDefault"; +pub const SPLREG_PORT_THREAD_PRIORITY: &'static str = "PortThreadPriority"; +pub const SPLREG_SCHEDULER_THREAD_PRIORITY_DEFAULT: &'static str + = "SchedulerThreadPriorityDefault"; +pub const SPLREG_SCHEDULER_THREAD_PRIORITY: &'static str = "SchedulerThreadPriority"; +pub const SPLREG_BEEP_ENABLED: &'static str = "BeepEnabled"; +pub const SPLREG_NET_POPUP: &'static str = "NetPopup"; +pub const SPLREG_RETRY_POPUP: &'static str = "RetryPopup"; +pub const SPLREG_NET_POPUP_TO_COMPUTER: &'static str = "NetPopupToComputer"; +pub const SPLREG_EVENT_LOG: &'static str = "EventLog"; +pub const SPLREG_MAJOR_VERSION: &'static str = "MajorVersion"; +pub const SPLREG_MINOR_VERSION: &'static str = "MinorVersion"; +pub const SPLREG_ARCHITECTURE: &'static str = "Architecture"; +pub const SPLREG_OS_VERSION: &'static str = "OSVersion"; +pub const SPLREG_OS_VERSIONEX: &'static str = "OSVersionEx"; +pub const SPLREG_DS_PRESENT: &'static str = "DsPresent"; +pub const SPLREG_DS_PRESENT_FOR_USER: &'static str = "DsPresentForUser"; +pub const SPLREG_REMOTE_FAX: &'static str = "RemoteFax"; +pub const SPLREG_RESTART_JOB_ON_POOL_ERROR: &'static str = "RestartJobOnPoolError"; +pub const SPLREG_RESTART_JOB_ON_POOL_ENABLED: &'static str = "RestartJobOnPoolEnabled"; +pub const SPLREG_DNS_MACHINE_NAME: &'static str = "DNSMachineName"; +pub const SPLREG_ALLOW_USER_MANAGEFORMS: &'static str = "AllowUserManageForms"; +pub const SPLREG_WEBSHAREMGMT: &'static str = "WebShareMgmt"; +pub const SPLREG_PRINT_DRIVER_ISOLATION_GROUPS_SEPARATOR: &'static str = "\\"; +pub const SPLREG_PRINT_DRIVER_ISOLATION_GROUPS: &'static str = "PrintDriverIsolationGroups"; +pub const SPLREG_PRINT_DRIVER_ISOLATION_TIME_BEFORE_RECYCLE: &'static str + = "PrintDriverIsolationTimeBeforeRecycle"; +pub const SPLREG_PRINT_DRIVER_ISOLATION_MAX_OBJECTS_BEFORE_RECYCLE: &'static str + = "PrintDriverIsolationMaxobjsBeforeRecycle"; +pub const SPLREG_PRINT_DRIVER_ISOLATION_IDLE_TIMEOUT: &'static str + = "PrintDriverIsolationIdleTimeout"; +pub const SPLREG_PRINT_DRIVER_ISOLATION_EXECUTION_POLICY: &'static str + = "PrintDriverIsolationExecutionPolicy"; +pub const SPLREG_PRINT_DRIVER_ISOLATION_OVERRIDE_POLICY: &'static str + = "PrintDriverIsolationOverrideCompat"; +pub const SPLREG_PRINT_QUEUE_V4_DRIVER_DIRECTORY: &'static str = "PrintQueueV4DriverDirectory"; +pub const SERVER_ACCESS_ADMINISTER: DWORD = 0x00000001; +pub const SERVER_ACCESS_ENUMERATE: DWORD = 0x00000002; +pub const PRINTER_ACCESS_ADMINISTER: DWORD = 0x00000004; +pub const PRINTER_ACCESS_USE: DWORD = 0x00000008; +pub const JOB_ACCESS_ADMINISTER: DWORD = 0x00000010; +pub const JOB_ACCESS_READ: DWORD = 0x00000020; +pub const PRINTER_ACCESS_MANAGE_LIMITED: DWORD = 0x00000040; +pub const SERVER_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SERVER_ACCESS_ADMINISTER + | SERVER_ACCESS_ENUMERATE; +pub const SERVER_READ: DWORD = STANDARD_RIGHTS_READ | SERVER_ACCESS_ENUMERATE; +pub const SERVER_WRITE: DWORD = STANDARD_RIGHTS_WRITE | SERVER_ACCESS_ADMINISTER + | SERVER_ACCESS_ENUMERATE; +pub const SERVER_EXECUTE: DWORD = STANDARD_RIGHTS_EXECUTE | SERVER_ACCESS_ENUMERATE; +pub const PRINTER_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | PRINTER_ACCESS_ADMINISTER + | PRINTER_ACCESS_USE; +pub const PRINTER_READ: DWORD = STANDARD_RIGHTS_READ | PRINTER_ACCESS_USE; +pub const PRINTER_WRITE: DWORD = STANDARD_RIGHTS_WRITE | PRINTER_ACCESS_USE; +pub const PRINTER_EXECUTE: DWORD = STANDARD_RIGHTS_EXECUTE | PRINTER_ACCESS_USE; +pub const JOB_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | JOB_ACCESS_ADMINISTER + | JOB_ACCESS_READ; +pub const JOB_READ: DWORD = STANDARD_RIGHTS_READ | JOB_ACCESS_READ; +pub const JOB_WRITE: DWORD = STANDARD_RIGHTS_WRITE | JOB_ACCESS_ADMINISTER; +pub const JOB_EXECUTE: DWORD = STANDARD_RIGHTS_EXECUTE | JOB_ACCESS_ADMINISTER; +pub const SPLDS_SPOOLER_KEY: &'static str = "DsSpooler"; +pub const SPLDS_DRIVER_KEY: &'static str = "DsDriver"; +pub const SPLDS_USER_KEY: &'static str = "DsUser"; +pub const SPLDS_ASSET_NUMBER: &'static str = "assetNumber"; +pub const SPLDS_BYTES_PER_MINUTE: &'static str = "bytesPerMinute"; +pub const SPLDS_DESCRIPTION: &'static str = "description"; +pub const SPLDS_DRIVER_NAME: &'static str = "driverName"; +pub const SPLDS_DRIVER_VERSION: &'static str = "driverVersion"; +pub const SPLDS_LOCATION: &'static str = "location"; +pub const SPLDS_PORT_NAME: &'static str = "portName"; +pub const SPLDS_PRINT_ATTRIBUTES: &'static str = "printAttributes"; +pub const SPLDS_PRINT_BIN_NAMES: &'static str = "printBinNames"; +pub const SPLDS_PRINT_COLLATE: &'static str = "printCollate"; +pub const SPLDS_PRINT_COLOR: &'static str = "printColor"; +pub const SPLDS_PRINT_DUPLEX_SUPPORTED: &'static str = "printDuplexSupported"; +pub const SPLDS_PRINT_END_TIME: &'static str = "printEndTime"; +pub const SPLDS_PRINTER_CLASS: &'static str = "printQueue"; +pub const SPLDS_PRINTER_NAME: &'static str = "printerName"; +pub const SPLDS_PRINT_KEEP_PRINTED_JOBS: &'static str = "printKeepPrintedJobs"; +pub const SPLDS_PRINT_LANGUAGE: &'static str = "printLanguage"; +pub const SPLDS_PRINT_MAC_ADDRESS: &'static str = "printMACAddress"; +pub const SPLDS_PRINT_MAX_X_EXTENT: &'static str = "printMaxXExtent"; +pub const SPLDS_PRINT_MAX_Y_EXTENT: &'static str = "printMaxYExtent"; +pub const SPLDS_PRINT_MAX_RESOLUTION_SUPPORTED: &'static str = "printMaxResolutionSupported"; +pub const SPLDS_PRINT_MEDIA_READY: &'static str = "printMediaReady"; +pub const SPLDS_PRINT_MEDIA_SUPPORTED: &'static str = "printMediaSupported"; +pub const SPLDS_PRINT_MEMORY: &'static str = "printMemory"; +pub const SPLDS_PRINT_MIN_X_EXTENT: &'static str = "printMinXExtent"; +pub const SPLDS_PRINT_MIN_Y_EXTENT: &'static str = "printMinYExtent"; +pub const SPLDS_PRINT_NETWORK_ADDRESS: &'static str = "printNetworkAddress"; +pub const SPLDS_PRINT_NOTIFY: &'static str = "printNotify"; +pub const SPLDS_PRINT_NUMBER_UP: &'static str = "printNumberUp"; +pub const SPLDS_PRINT_ORIENTATIONS_SUPPORTED: &'static str = "printOrientationsSupported"; +pub const SPLDS_PRINT_OWNER: &'static str = "printOwner"; +pub const SPLDS_PRINT_PAGES_PER_MINUTE: &'static str = "printPagesPerMinute"; +pub const SPLDS_PRINT_RATE: &'static str = "printRate"; +pub const SPLDS_PRINT_RATE_UNIT: &'static str = "printRateUnit"; +pub const SPLDS_PRINT_SEPARATOR_FILE: &'static str = "printSeparatorFile"; +pub const SPLDS_PRINT_SHARE_NAME: &'static str = "printShareName"; +pub const SPLDS_PRINT_SPOOLING: &'static str = "printSpooling"; +pub const SPLDS_PRINT_STAPLING_SUPPORTED: &'static str = "printStaplingSupported"; +pub const SPLDS_PRINT_START_TIME: &'static str = "printStartTime"; +pub const SPLDS_PRINT_STATUS: &'static str = "printStatus"; +pub const SPLDS_PRIORITY: &'static str = "priority"; +pub const SPLDS_SERVER_NAME: &'static str = "serverName"; +pub const SPLDS_SHORT_SERVER_NAME: &'static str = "shortServerName"; +pub const SPLDS_UNC_NAME: &'static str = "uNCName"; +pub const SPLDS_URL: &'static str = "url"; +pub const SPLDS_FLAGS: &'static str = "flags"; +pub const SPLDS_VERSION_NUMBER: &'static str = "versionNumber"; +pub const SPLDS_PRINTER_NAME_ALIASES: &'static str = "printerNameAliases"; +pub const SPLDS_PRINTER_LOCATIONS: &'static str = "printerLocations"; +pub const SPLDS_PRINTER_MODEL: &'static str = "printerModel"; +ENUM!{enum PRINTER_OPTION_FLAGS { + PRINTER_OPTION_NO_CACHE = 1 << 0, + PRINTER_OPTION_CACHE = 1 << 1, + PRINTER_OPTION_CLIENT_CHANGE = 1 << 2, + PRINTER_OPTION_NO_CLIENT_DATA = 1 << 3, +}} +STRUCT!{struct PRINTER_OPTIONSA { + cbSize: UINT, + dwFlags: DWORD, +}} +pub type PPRINTER_OPTIONSA = *mut PRINTER_OPTIONSA; +pub type LPPRINTER_OPTIONSA = *mut PRINTER_OPTIONSA; +STRUCT!{struct PRINTER_OPTIONSW { + cbSize: UINT, + dwFlags: DWORD, +}} +pub type PPRINTER_OPTIONSW = *mut PRINTER_OPTIONSW; +pub type LPPRINTER_OPTIONSW = *mut PRINTER_OPTIONSW; +extern "system" { + pub fn OpenPrinter2A( + pPrinterName: LPCSTR, + phPrinter: LPHANDLE, + pDefault: PPRINTER_DEFAULTSA, + pOptions: PPRINTER_OPTIONSA, + ) -> BOOL; + pub fn OpenPrinter2W( + pPrinterName: LPCWSTR, + phPrinter: LPHANDLE, + pDefault: PPRINTER_DEFAULTSW, + pOptions: PPRINTER_OPTIONSW, + ) -> BOOL; +} +pub const PRINTER_CONNECTION_MISMATCH: DWORD = 0x00000020; +pub const PRINTER_CONNECTION_NO_UI: DWORD = 0x00000040; +STRUCT!{struct PRINTER_CONNECTION_INFO_1A { + dwFlags: DWORD, + pszDriverName: LPSTR, +}} +pub type PPRINTER_CONNECTION_INFO_1A = *mut PRINTER_CONNECTION_INFO_1A; +pub type LPPRINTER_CONNECTION_INFO_1A = *mut PRINTER_CONNECTION_INFO_1A; +STRUCT!{struct PRINTER_CONNECTION_INFO_1W { + dwFlags: DWORD, + pszDriverName: LPWSTR, +}} +pub type PPRINTER_CONNECTION_INFO_1W = *mut PRINTER_CONNECTION_INFO_1W; +pub type LPPRINTER_CONNECTION_INFO_1W = *mut PRINTER_CONNECTION_INFO_1W; +extern "system" { + pub fn AddPrinterConnection2A( + hWnd: HWND, + pszName: LPCSTR, + dwLevel: DWORD, + pConnectionInfo: PVOID, + ) -> BOOL; + pub fn AddPrinterConnection2W( + hWnd: HWND, + pszName: LPCWSTR, + dwLevel: DWORD, + pConnectionInfo: PVOID, + ) -> BOOL; +} +pub const IPDFP_COPY_ALL_FILES: DWORD = 0x00000001; +extern "system" { + pub fn InstallPrinterDriverFromPackageA( + pszServer: LPCSTR, + pszInfPath: LPCSTR, + pszDriverName: LPCSTR, + pszEnvironment: LPCSTR, + dwFlags: DWORD, + ) -> HRESULT; + pub fn InstallPrinterDriverFromPackageW( + pszServer: LPCWSTR, + pszInfPath: LPCWSTR, + pszDriverName: LPCWSTR, + pszEnvironment: LPCWSTR, + dwFlags: DWORD, + ) -> HRESULT; +} +pub const UPDP_SILENT_UPLOAD: DWORD = 0x00000001; +pub const UPDP_UPLOAD_ALWAYS: DWORD = 0x00000002; +pub const UPDP_CHECK_DRIVERSTORE: DWORD = 0x00000004; +extern "system" { + pub fn UploadPrinterDriverPackageA( + pszServer: LPCSTR, + pszInfPath: LPCSTR, + pszEnvironment: LPCSTR, + dwFlags: DWORD, + hwnd: HWND, + pszDestInfPath: LPSTR, + pcchDestInfPath: PULONG, + ) -> HRESULT; + pub fn UploadPrinterDriverPackageW( + pszServer: LPCWSTR, + pszInfPath: LPCWSTR, + pszEnvironment: LPCWSTR, + dwFlags: DWORD, + hwnd: HWND, + pszDestInfPath: LPWSTR, + pcchDestInfPath: PULONG, + ) -> HRESULT; +} +STRUCT!{struct CORE_PRINTER_DRIVERA { + CoreDriverGUID: GUID, + ftDriverDate: FILETIME, + dwlDriverVersion: DWORDLONG, + szPackageID: [CHAR; MAX_PATH], +}} +pub type PCORE_PRINTER_DRIVERA = *mut CORE_PRINTER_DRIVERA; +STRUCT!{struct CORE_PRINTER_DRIVERW { + CoreDriverGUID: GUID, + ftDriverDate: FILETIME, + dwlDriverVersion: DWORDLONG, + szPackageID: [WCHAR; MAX_PATH], +}} +pub type PCORE_PRINTER_DRIVERW = *mut CORE_PRINTER_DRIVERW; +extern "system" { + pub fn GetCorePrinterDriversA( + pszServer: LPCSTR, + pszEnvironment: LPCSTR, + pszzCoreDriverDependencies: LPCSTR, + cCorePrinterDrivers: DWORD, + pCorePrinterDrivers: PCORE_PRINTER_DRIVERA, + ) -> HRESULT; + pub fn GetCorePrinterDriversW( + pszServer: LPCWSTR, + pszEnvironment: LPCWSTR, + pszzCoreDriverDependencies: LPCWSTR, + cCorePrinterDrivers: DWORD, + pCorePrinterDrivers: PCORE_PRINTER_DRIVERW, + ) -> HRESULT; + pub fn CorePrinterDriverInstalledA( + pszServer: LPCSTR, + pszEnvironment: LPCSTR, + CoreDriverGUID: GUID, + ftDriverDate: FILETIME, + dwlDriverVersion: DWORDLONG, + pbDriverInstalled: *mut BOOL, + ) -> HRESULT; + pub fn CorePrinterDriverInstalledW( + pszServer: LPCWSTR, + pszEnvironment: LPCWSTR, + CoreDriverGUID: GUID, + ftDriverDate: FILETIME, + dwlDriverVersion: DWORDLONG, + pbDriverInstalled: *mut BOOL, + ) -> HRESULT; + pub fn GetPrinterDriverPackagePathA( + pszServer: LPCSTR, + pszEnvironment: LPCSTR, + pszLanguage: LPCSTR, + pszPackageID: LPCSTR, + pszDriverPackageCab: LPSTR, + cchDriverPackageCab: DWORD, + pcchRequiredSize: LPDWORD, + ) -> HRESULT; + pub fn GetPrinterDriverPackagePathW( + pszServer: LPCWSTR, + pszEnvironment: LPCWSTR, + pszLanguage: LPCWSTR, + pszPackageID: LPCWSTR, + pszDriverPackageCab: LPWSTR, + cchDriverPackageCab: DWORD, + pcchRequiredSize: LPDWORD, + ) -> HRESULT; + pub fn DeletePrinterDriverPackageA( + pszServer: LPCSTR, + pszInfPath: LPCSTR, + pszEnvironment: LPCSTR, + ) -> HRESULT; + pub fn DeletePrinterDriverPackageW( + pszServer: LPCWSTR, + pszInfPath: LPCWSTR, + pszEnvironment: LPCWSTR, + ) -> HRESULT; +} +ENUM!{enum EPrintPropertyType { + kPropertyTypeString = 1, + kPropertyTypeInt32, + kPropertyTypeInt64, + kPropertyTypeByte, + kPropertyTypeTime, + kPropertyTypeDevMode, + kPropertyTypeSD, + kPropertyTypeNotificationReply, + kPropertyTypeNotificationOptions, + kPropertyTypeBuffer, +}} +ENUM!{enum EPrintXPSJobProgress { + kAddingDocumentSequence = 0, + kDocumentSequenceAdded = 1, + kAddingFixedDocument = 2, + kFixedDocumentAdded = 3, + kAddingFixedPage = 4, + kFixedPageAdded = 5, + kResourceAdded = 6, + kFontAdded = 7, + kImageAdded = 8, + kXpsDocumentCommitted = 9, +}} +ENUM!{enum EPrintXPSJobOperation { + kJobProduction = 1, + kJobConsumption, +}} +STRUCT!{struct PrintPropertyValue_value_propertyBlob { + cbBuf: DWORD, + pBuf: LPVOID, +}} +UNION!{union PrintPropertyValue_value { + [u64; 1] [u64; 2], + propertyByte propertyByte_mut: BYTE, + propertyString propertyString_mut: PWSTR, + propertyInt32 propertyInt32_mut: LONG, + propertyInt64 propertyInt64_mut: LONGLONG, + propertyBlob propertyBlob_mut: PrintPropertyValue_value_propertyBlob, +}} +STRUCT!{struct PrintPropertyValue { + ePropertyType: EPrintPropertyType, + value: PrintPropertyValue_value, +}} +STRUCT!{struct PrintNamedProperty { + propertyName: *mut WCHAR, + propertyValue: PrintPropertyValue, +}} +STRUCT!{struct PrintPropertiesCollection { + numberOfProperties: ULONG, + propertiesCollection: *mut PrintNamedProperty, +}} +extern "system" { + pub fn ReportJobProcessingProgress( + printerHandle: HANDLE, + jobId: ULONG, + jobOperation: EPrintXPSJobOperation, + jobProgress: EPrintXPSJobProgress, + ) -> HRESULT; + pub fn GetPrinterDriver2A( + hWnd: HWND, + hPrinter: HANDLE, + pEnvironment: LPSTR, + Level: DWORD, + pDriverInfo: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; + pub fn GetPrinterDriver2W( + hWnd: HWND, + hPrinter: HANDLE, + pEnvironment: LPWSTR, + Level: DWORD, + pDriverInfo: LPBYTE, + cbBuf: DWORD, + pcbNeeded: LPDWORD, + ) -> BOOL; +} +ENUM!{enum PRINT_EXECUTION_CONTEXT { + PRINT_EXECUTION_CONTEXT_APPLICATION = 0, + PRINT_EXECUTION_CONTEXT_SPOOLER_SERVICE = 1, + PRINT_EXECUTION_CONTEXT_SPOOLER_ISOLATION_HOST = 2, + PRINT_EXECUTION_CONTEXT_FILTER_PIPELINE = 3, + PRINT_EXECUTION_CONTEXT_WOW64 = 4, +}} +STRUCT!{struct PRINT_EXECUTION_DATA { + context: PRINT_EXECUTION_CONTEXT, + clientAppPID: DWORD, +}} +extern "system" { + pub fn GetPrintExecutionData( + pData: *mut PRINT_EXECUTION_DATA, + ) -> BOOL; + pub fn GetJobNamedPropertyValue( + hPrinter: HANDLE, + JobId: DWORD, + pszName: PCWSTR, + pValue: *mut PrintPropertyValue, + ) -> DWORD; + pub fn FreePrintPropertyValue( + pValue: *mut PrintPropertyValue, + ); + pub fn FreePrintNamedPropertyArray( + cProperties: DWORD, + ppProperties: *mut *mut PrintNamedProperty, + ); + pub fn SetJobNamedProperty( + hPrinter: HANDLE, + JobId: DWORD, + pProperty: *const PrintNamedProperty, + ) -> DWORD; + pub fn DeleteJobNamedProperty( + hPrinter: HANDLE, + JobId: DWORD, + pszName: PCWSTR, + ) -> DWORD; + pub fn EnumJobNamedProperties( + hPrinter: HANDLE, + JobId: DWORD, + pcProperties: *mut DWORD, + ppProperties: *mut *mut PrintNamedProperty, + ) -> DWORD; + pub fn GetPrintOutputInfo( + hWnd: HWND, + pszPrinter: PCWSTR, + phFile: *mut HANDLE, + ppszOutputFile: *mut PWSTR, + ) -> HRESULT; +} +pub const MS_PRINT_JOB_OUTPUT_FILE: &'static str = "MsPrintJobOutputFile"; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winsvc.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winsvc.rs new file mode 100644 index 0000000..702164c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winsvc.rs @@ -0,0 +1,665 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Header file for the Service Control Manager +use shared::minwindef::{BOOL, DWORD, LPBYTE, LPDWORD, LPVOID}; +use um::winnt::{ + HANDLE, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PSECURITY_DESCRIPTOR, PVOID, + SECURITY_INFORMATION, STANDARD_RIGHTS_REQUIRED +}; +pub const SERVICE_NO_CHANGE: DWORD = 0xffffffff; +pub const SERVICE_ACTIVE: DWORD = 0x00000001; +pub const SERVICE_INACTIVE: DWORD = 0x00000002; +pub const SERVICE_STATE_ALL: DWORD = SERVICE_ACTIVE | SERVICE_INACTIVE; +pub const SERVICE_CONTROL_STOP: DWORD = 0x00000001; +pub const SERVICE_CONTROL_PAUSE: DWORD = 0x00000002; +pub const SERVICE_CONTROL_CONTINUE: DWORD = 0x00000003; +pub const SERVICE_CONTROL_INTERROGATE: DWORD = 0x00000004; +pub const SERVICE_CONTROL_SHUTDOWN: DWORD = 0x00000005; +pub const SERVICE_CONTROL_PARAMCHANGE: DWORD = 0x00000006; +pub const SERVICE_CONTROL_NETBINDADD: DWORD = 0x00000007; +pub const SERVICE_CONTROL_NETBINDREMOVE: DWORD = 0x00000008; +pub const SERVICE_CONTROL_NETBINDENABLE: DWORD = 0x00000009; +pub const SERVICE_CONTROL_NETBINDDISABLE: DWORD = 0x0000000A; +pub const SERVICE_CONTROL_DEVICEEVENT: DWORD = 0x0000000B; +pub const SERVICE_CONTROL_HARDWAREPROFILECHANGE: DWORD = 0x0000000C; +pub const SERVICE_CONTROL_POWEREVENT: DWORD = 0x0000000D; +pub const SERVICE_CONTROL_SESSIONCHANGE: DWORD = 0x0000000E; +pub const SERVICE_CONTROL_PRESHUTDOWN: DWORD = 0x0000000F; +pub const SERVICE_CONTROL_TIMECHANGE: DWORD = 0x00000010; +pub const SERVICE_CONTROL_TRIGGEREVENT: DWORD = 0x00000020; +pub const SERVICE_STOPPED: DWORD = 0x00000001; +pub const SERVICE_START_PENDING: DWORD = 0x00000002; +pub const SERVICE_STOP_PENDING: DWORD = 0x00000003; +pub const SERVICE_RUNNING: DWORD = 0x00000004; +pub const SERVICE_CONTINUE_PENDING: DWORD = 0x00000005; +pub const SERVICE_PAUSE_PENDING: DWORD = 0x00000006; +pub const SERVICE_PAUSED: DWORD = 0x00000007; +pub const SERVICE_ACCEPT_STOP: DWORD = 0x00000001; +pub const SERVICE_ACCEPT_PAUSE_CONTINUE: DWORD = 0x00000002; +pub const SERVICE_ACCEPT_SHUTDOWN: DWORD = 0x00000004; +pub const SERVICE_ACCEPT_PARAMCHANGE: DWORD = 0x00000008; +pub const SERVICE_ACCEPT_NETBINDCHANGE: DWORD = 0x00000010; +pub const SERVICE_ACCEPT_HARDWAREPROFILECHANGE: DWORD = 0x00000020; +pub const SERVICE_ACCEPT_POWEREVENT: DWORD = 0x00000040; +pub const SERVICE_ACCEPT_SESSIONCHANGE: DWORD = 0x00000080; +pub const SERVICE_ACCEPT_PRESHUTDOWN: DWORD = 0x00000100; +pub const SERVICE_ACCEPT_TIMECHANGE: DWORD = 0x00000200; +pub const SERVICE_ACCEPT_TRIGGEREVENT: DWORD = 0x00000400; +// SERVICE_ACCEPT_USER_LOGOFF +pub const SC_MANAGER_CONNECT: DWORD = 0x0001; +pub const SC_MANAGER_CREATE_SERVICE: DWORD = 0x0002; +pub const SC_MANAGER_ENUMERATE_SERVICE: DWORD = 0x0004; +pub const SC_MANAGER_LOCK: DWORD = 0x0008; +pub const SC_MANAGER_QUERY_LOCK_STATUS: DWORD = 0x0010; +pub const SC_MANAGER_MODIFY_BOOT_CONFIG: DWORD = 0x0020; +pub const SC_MANAGER_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT + | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK + | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG; +pub const SERVICE_QUERY_CONFIG: DWORD = 0x0001; +pub const SERVICE_CHANGE_CONFIG: DWORD = 0x0002; +pub const SERVICE_QUERY_STATUS: DWORD = 0x0004; +pub const SERVICE_ENUMERATE_DEPENDENTS: DWORD = 0x0008; +pub const SERVICE_START: DWORD = 0x0010; +pub const SERVICE_STOP: DWORD = 0x0020; +pub const SERVICE_PAUSE_CONTINUE: DWORD = 0x0040; +pub const SERVICE_INTERROGATE: DWORD = 0x0080; +pub const SERVICE_USER_DEFINED_CONTROL: DWORD = 0x0100; +pub const SERVICE_ALL_ACCESS: DWORD = STANDARD_RIGHTS_REQUIRED | SERVICE_QUERY_CONFIG + | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_START + | SERVICE_STOP | SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE | SERVICE_USER_DEFINED_CONTROL; +pub const SERVICE_RUNS_IN_SYSTEM_PROCESS: DWORD = 0x00000001; +pub const SERVICE_CONFIG_DESCRIPTION: DWORD = 1; +pub const SERVICE_CONFIG_FAILURE_ACTIONS: DWORD = 2; +pub const SERVICE_CONFIG_DELAYED_AUTO_START_INFO: DWORD = 3; +pub const SERVICE_CONFIG_FAILURE_ACTIONS_FLAG: DWORD = 4; +pub const SERVICE_CONFIG_SERVICE_SID_INFO: DWORD = 5; +pub const SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO: DWORD = 6; +pub const SERVICE_CONFIG_PRESHUTDOWN_INFO: DWORD = 7; +pub const SERVICE_CONFIG_TRIGGER_INFO: DWORD = 8; +pub const SERVICE_CONFIG_PREFERRED_NODE: DWORD = 9; +pub const SERVICE_CONFIG_LAUNCH_PROTECTED: DWORD = 12; +pub const SERVICE_NOTIFY_STATUS_CHANGE_1: DWORD = 1; +pub const SERVICE_NOTIFY_STATUS_CHANGE_2: DWORD = 2; +pub const SERVICE_NOTIFY_STATUS_CHANGE: DWORD = SERVICE_NOTIFY_STATUS_CHANGE_2; +pub const SERVICE_NOTIFY_STOPPED: DWORD = 0x00000001; +pub const SERVICE_NOTIFY_START_PENDING: DWORD = 0x00000002; +pub const SERVICE_NOTIFY_STOP_PENDING: DWORD = 0x00000004; +pub const SERVICE_NOTIFY_RUNNING: DWORD = 0x00000008; +pub const SERVICE_NOTIFY_CONTINUE_PENDING: DWORD = 0x00000010; +pub const SERVICE_NOTIFY_PAUSE_PENDING: DWORD = 0x00000020; +pub const SERVICE_NOTIFY_PAUSED: DWORD = 0x00000040; +pub const SERVICE_NOTIFY_CREATED: DWORD = 0x00000080; +pub const SERVICE_NOTIFY_DELETED: DWORD = 0x00000100; +pub const SERVICE_NOTIFY_DELETE_PENDING: DWORD = 0x00000200; +pub const SERVICE_STOP_REASON_FLAG_MIN: DWORD = 0x00000000; +pub const SERVICE_STOP_REASON_FLAG_UNPLANNED: DWORD = 0x10000000; +pub const SERVICE_STOP_REASON_FLAG_CUSTOM: DWORD = 0x20000000; +pub const SERVICE_STOP_REASON_FLAG_PLANNED: DWORD = 0x40000000; +pub const SERVICE_STOP_REASON_FLAG_MAX: DWORD = 0x80000000; +pub const SERVICE_STOP_REASON_MAJOR_MIN: DWORD = 0x00000000; +pub const SERVICE_STOP_REASON_MAJOR_OTHER: DWORD = 0x00010000; +pub const SERVICE_STOP_REASON_MAJOR_HARDWARE: DWORD = 0x00020000; +pub const SERVICE_STOP_REASON_MAJOR_OPERATINGSYSTEM: DWORD = 0x00030000; +pub const SERVICE_STOP_REASON_MAJOR_SOFTWARE: DWORD = 0x00040000; +pub const SERVICE_STOP_REASON_MAJOR_APPLICATION: DWORD = 0x00050000; +pub const SERVICE_STOP_REASON_MAJOR_NONE: DWORD = 0x00060000; +pub const SERVICE_STOP_REASON_MAJOR_MAX: DWORD = 0x00070000; +pub const SERVICE_STOP_REASON_MAJOR_MIN_CUSTOM: DWORD = 0x00400000; +pub const SERVICE_STOP_REASON_MAJOR_MAX_CUSTOM: DWORD = 0x00ff0000; +pub const SERVICE_STOP_REASON_MINOR_MIN: DWORD = 0x00000000; +pub const SERVICE_STOP_REASON_MINOR_OTHER: DWORD = 0x00000001; +pub const SERVICE_STOP_REASON_MINOR_MAINTENANCE: DWORD = 0x00000002; +pub const SERVICE_STOP_REASON_MINOR_INSTALLATION: DWORD = 0x00000003; +pub const SERVICE_STOP_REASON_MINOR_UPGRADE: DWORD = 0x00000004; +pub const SERVICE_STOP_REASON_MINOR_RECONFIG: DWORD = 0x00000005; +pub const SERVICE_STOP_REASON_MINOR_HUNG: DWORD = 0x00000006; +pub const SERVICE_STOP_REASON_MINOR_UNSTABLE: DWORD = 0x00000007; +pub const SERVICE_STOP_REASON_MINOR_DISK: DWORD = 0x00000008; +pub const SERVICE_STOP_REASON_MINOR_NETWORKCARD: DWORD = 0x00000009; +pub const SERVICE_STOP_REASON_MINOR_ENVIRONMENT: DWORD = 0x0000000a; +pub const SERVICE_STOP_REASON_MINOR_HARDWARE_DRIVER: DWORD = 0x0000000b; +pub const SERVICE_STOP_REASON_MINOR_OTHERDRIVER: DWORD = 0x0000000c; +pub const SERVICE_STOP_REASON_MINOR_SERVICEPACK: DWORD = 0x0000000d; +pub const SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE: DWORD = 0x0000000e; +pub const SERVICE_STOP_REASON_MINOR_SECURITYFIX: DWORD = 0x0000000f; +pub const SERVICE_STOP_REASON_MINOR_SECURITY: DWORD = 0x00000010; +pub const SERVICE_STOP_REASON_MINOR_NETWORK_CONNECTIVITY: DWORD = 0x00000011; +pub const SERVICE_STOP_REASON_MINOR_WMI: DWORD = 0x00000012; +pub const SERVICE_STOP_REASON_MINOR_SERVICEPACK_UNINSTALL: DWORD = 0x00000013; +pub const SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE_UNINSTALL: DWORD = 0x00000014; +pub const SERVICE_STOP_REASON_MINOR_SECURITYFIX_UNINSTALL: DWORD = 0x00000015; +pub const SERVICE_STOP_REASON_MINOR_MMC: DWORD = 0x00000016; +pub const SERVICE_STOP_REASON_MINOR_NONE: DWORD = 0x00000017; +pub const SERVICE_STOP_REASON_MINOR_MAX: DWORD = 0x00000018; +pub const SERVICE_STOP_REASON_MINOR_MIN_CUSTOM: DWORD = 0x00000100; +pub const SERVICE_STOP_REASON_MINOR_MAX_CUSTOM: DWORD = 0x0000FFFF; +pub const SERVICE_CONTROL_STATUS_REASON_INFO: DWORD = 1; +pub const SERVICE_SID_TYPE_NONE: DWORD = 0x00000000; +pub const SERVICE_SID_TYPE_UNRESTRICTED: DWORD = 0x00000001; +pub const SERVICE_SID_TYPE_RESTRICTED: DWORD = 0x00000002 | SERVICE_SID_TYPE_UNRESTRICTED; +pub const SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL: DWORD = 1; +pub const SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY: DWORD = 2; +pub const SERVICE_TRIGGER_TYPE_DOMAIN_JOIN: DWORD = 3; +pub const SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT: DWORD = 4; +pub const SERVICE_TRIGGER_TYPE_GROUP_POLICY: DWORD = 5; +pub const SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT: DWORD = 6; +pub const SERVICE_TRIGGER_TYPE_CUSTOM_SYSTEM_STATE_CHANGE: DWORD = 7; +pub const SERVICE_TRIGGER_TYPE_CUSTOM: DWORD = 20; +pub const SERVICE_TRIGGER_DATA_TYPE_BINARY: DWORD = 1; +pub const SERVICE_TRIGGER_DATA_TYPE_STRING: DWORD = 2; +pub const SERVICE_TRIGGER_DATA_TYPE_LEVEL: DWORD = 3; +pub const SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY: DWORD = 4; +pub const SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL: DWORD = 5; +pub const SERVICE_START_REASON_DEMAND: DWORD = 0x00000001; +pub const SERVICE_START_REASON_AUTO: DWORD = 0x00000002; +pub const SERVICE_START_REASON_TRIGGER: DWORD = 0x00000004; +pub const SERVICE_START_REASON_RESTART_ON_FAILURE: DWORD = 0x00000008; +pub const SERVICE_START_REASON_DELAYEDAUTO: DWORD = 0x00000010; +pub const SERVICE_DYNAMIC_INFORMATION_LEVEL_START_REASON: DWORD = 1; +pub const SERVICE_LAUNCH_PROTECTED_NONE: DWORD = 0; +pub const SERVICE_LAUNCH_PROTECTED_WINDOWS: DWORD = 1; +pub const SERVICE_LAUNCH_PROTECTED_WINDOWS_LIGHT: DWORD = 2; +pub const SERVICE_LAUNCH_PROTECTED_ANTIMALWARE_LIGHT: DWORD = 3; +DEFINE_GUID!{NETWORK_MANAGER_FIRST_IP_ADDRESS_ARRIVAL_GUID, + 0x4f27f2de, 0x14e2, 0x430b, 0xa5, 0x49, 0x7c, 0xd4, 0x8c, 0xbc, 0x82, 0x45} +DEFINE_GUID!{NETWORK_MANAGER_LAST_IP_ADDRESS_REMOVAL_GUID, + 0xcc4ba62a, 0x162e, 0x4648, 0x84, 0x7a, 0xb6, 0xbd, 0xf9, 0x93, 0xe3, 0x35} +DEFINE_GUID!{DOMAIN_JOIN_GUID, + 0x1ce20aba, 0x9851, 0x4421, 0x94, 0x30, 0x1d, 0xde, 0xb7, 0x66, 0xe8, 0x09} +DEFINE_GUID!{DOMAIN_LEAVE_GUID, + 0xddaf516e, 0x58c2, 0x4866, 0x95, 0x74, 0xc3, 0xb6, 0x15, 0xd4, 0x2e, 0xa1} +DEFINE_GUID!{FIREWALL_PORT_OPEN_GUID, + 0xb7569e07, 0x8421, 0x4ee0, 0xad, 0x10, 0x86, 0x91, 0x5a, 0xfd, 0xad, 0x09} +DEFINE_GUID!{FIREWALL_PORT_CLOSE_GUID, + 0xa144ed38, 0x8e12, 0x4de4, 0x9d, 0x96, 0xe6, 0x47, 0x40, 0xb1, 0xa5, 0x24} +DEFINE_GUID!{MACHINE_POLICY_PRESENT_GUID, + 0x659fcae6, 0x5bdb, 0x4da9, 0xb1, 0xff, 0xca, 0x2a, 0x17, 0x8d, 0x46, 0xe0} +DEFINE_GUID!{USER_POLICY_PRESENT_GUID, + 0x54fb46c8, 0xf089, 0x464c, 0xb1, 0xfd, 0x59, 0xd1, 0xb6, 0x2c, 0x3b, 0x50} +DEFINE_GUID!{RPC_INTERFACE_EVENT_GUID, + 0xbc90d167, 0x9470, 0x4139, 0xa9, 0xba, 0xbe, 0x0b, 0xbb, 0xf5, 0xb7, 0x4d} +DEFINE_GUID!{NAMED_PIPE_EVENT_GUID, + 0x1f81d131, 0x3fac, 0x4537, 0x9e, 0x0c, 0x7e, 0x7b, 0x0c, 0x2f, 0x4b, 0x55} +DEFINE_GUID!{CUSTOM_SYSTEM_STATE_CHANGE_EVENT_GUID, + 0x2d7a2816, 0x0c5e, 0x45fc, 0x9c, 0xe7, 0x57, 0x0e, 0x5e, 0xcd, 0xe9, 0xc9} +DECLARE_HANDLE!{SC_HANDLE, SC_HANDLE__} +pub type LPSC_HANDLE = *mut SC_HANDLE; +DECLARE_HANDLE!{SERVICE_STATUS_HANDLE, SERVICE_STATUS_HANDLE__} +ENUM!{enum SC_STATUS_TYPE { + SC_STATUS_PROCESS_INFO = 0, +}} +ENUM!{enum SC_ENUM_TYPE { + SC_ENUM_PROCESS_INFO = 0, +}} +STRUCT!{struct SERVICE_STATUS { + dwServiceType: DWORD, + dwCurrentState: DWORD, + dwControlsAccepted: DWORD, + dwWin32ExitCode: DWORD, + dwServiceSpecificExitCode: DWORD, + dwCheckPoint: DWORD, + dwWaitHint: DWORD, +}} +pub type LPSERVICE_STATUS = *mut SERVICE_STATUS; +STRUCT!{struct SERVICE_STATUS_PROCESS { + dwServiceType: DWORD, + dwCurrentState: DWORD, + dwControlsAccepted: DWORD, + dwWin32ExitCode: DWORD, + dwServiceSpecificExitCode: DWORD, + dwCheckPoint: DWORD, + dwWaitHint: DWORD, + dwProcessId: DWORD, + dwServiceFlags: DWORD, +}} +pub type LPSERVICE_STATUS_PROCESS = *mut SERVICE_STATUS_PROCESS; +STRUCT!{struct ENUM_SERVICE_STATUSA { + lpServiceName: LPSTR, + lpDisplayName: LPSTR, + ServiceStatus: SERVICE_STATUS, +}} +pub type LPENUM_SERVICE_STATUSA = *mut ENUM_SERVICE_STATUSA; +STRUCT!{struct ENUM_SERVICE_STATUSW { + lpServiceName: LPWSTR, + lpDisplayName: LPWSTR, + ServiceStatus: SERVICE_STATUS, +}} +pub type LPENUM_SERVICE_STATUSW = *mut ENUM_SERVICE_STATUSW; +STRUCT!{struct ENUM_SERVICE_STATUS_PROCESSA { + lpServiceName: LPSTR, + lpDisplayName: LPSTR, + ServiceStatusProcess: SERVICE_STATUS_PROCESS, +}} +pub type LPENUM_SERVICE_STATUS_PROCESSA = *mut ENUM_SERVICE_STATUS_PROCESSA; +STRUCT!{struct ENUM_SERVICE_STATUS_PROCESSW { + lpServiceName: LPWSTR, + lpDisplayName: LPWSTR, + ServiceStatusProcess: SERVICE_STATUS_PROCESS, +}} +pub type LPENUM_SERVICE_STATUS_PROCESSW = *mut ENUM_SERVICE_STATUS_PROCESSW; +pub type SC_LOCK = LPVOID; +STRUCT!{struct QUERY_SERVICE_LOCK_STATUSA { + fIsLocked: DWORD, + lpLockOwner: LPSTR, + dwLockDuration: DWORD, +}} +pub type LPQUERY_SERVICE_LOCK_STATUSA = *mut QUERY_SERVICE_LOCK_STATUSA; +STRUCT!{struct QUERY_SERVICE_LOCK_STATUSW { + fIsLocked: DWORD, + lpLockOwner: LPWSTR, + dwLockDuration: DWORD, +}} +pub type LPQUERY_SERVICE_LOCK_STATUSW = *mut QUERY_SERVICE_LOCK_STATUSW; +STRUCT!{struct QUERY_SERVICE_CONFIGA { + dwServiceType: DWORD, + dwStartType: DWORD, + dwErrorControl: DWORD, + lpBinaryPathName: LPSTR, + lpLoadOrderGroup: LPSTR, + dwTagId: DWORD, + lpDependencies: LPSTR, + lpServiceStartName: LPSTR, + lpDisplayName: LPSTR, +}} +pub type LPQUERY_SERVICE_CONFIGA = *mut QUERY_SERVICE_CONFIGA; +STRUCT!{struct QUERY_SERVICE_CONFIGW { + dwServiceType: DWORD, + dwStartType: DWORD, + dwErrorControl: DWORD, + lpBinaryPathName: LPWSTR, + lpLoadOrderGroup: LPWSTR, + dwTagId: DWORD, + lpDependencies: LPWSTR, + lpServiceStartName: LPWSTR, + lpDisplayName: LPWSTR, +}} +pub type LPQUERY_SERVICE_CONFIGW = *mut QUERY_SERVICE_CONFIGW; +FN!{stdcall LPSERVICE_MAIN_FUNCTIONW( + dwNumServicesArgs: DWORD, + lpServiceArgVectors: *mut LPWSTR, +) -> ()} +FN!{stdcall LPSERVICE_MAIN_FUNCTIONA( + dwNumServicesArgs: DWORD, + lpServiceArgVectors: *mut LPSTR, +) -> ()} +STRUCT!{struct SERVICE_TABLE_ENTRYA { + lpServiceName: LPCSTR, + lpServiceProc: LPSERVICE_MAIN_FUNCTIONA, +}} +pub type LPSERVICE_TABLE_ENTRYA = *mut SERVICE_TABLE_ENTRYA; +STRUCT!{struct SERVICE_TABLE_ENTRYW { + lpServiceName: LPCWSTR, + lpServiceProc: LPSERVICE_MAIN_FUNCTIONW, +}} +pub type LPSERVICE_TABLE_ENTRYW = *mut SERVICE_TABLE_ENTRYW; +FN!{stdcall LPHANDLER_FUNCTION( + dwControl: DWORD, +) -> ()} +FN!{stdcall LPHANDLER_FUNCTION_EX( + dwControl: DWORD, + dwEventType: DWORD, + lpEventData: LPVOID, + lpContext: LPVOID, +) -> DWORD} +FN!{stdcall PFN_SC_NOTIFY_CALLBACK( + pParameter: PVOID, +) -> ()} +STRUCT!{struct SERVICE_NOTIFY_1 { + dwVersion: DWORD, + pfnNotifyCallback: PFN_SC_NOTIFY_CALLBACK, + pContext: PVOID, + dwNotificationStatus: DWORD, + ServiceStatus: SERVICE_STATUS_PROCESS, +}} +pub type PSERVICE_NOTIFY_1 = *mut SERVICE_NOTIFY_1; +STRUCT!{struct SERVICE_NOTIFY_2A { + dwVersion: DWORD, + pfnNotifyCallback: PFN_SC_NOTIFY_CALLBACK, + pContext: PVOID, + dwNotificationStatus: DWORD, + ServiceStatus: SERVICE_STATUS_PROCESS, + dwNotificationTriggered: DWORD, + pszServiceNames: LPSTR, +}} +pub type PSERVICE_NOTIFY_2A = *mut SERVICE_NOTIFY_2A; +STRUCT!{struct SERVICE_NOTIFY_2W { + dwVersion: DWORD, + pfnNotifyCallback: PFN_SC_NOTIFY_CALLBACK, + pContext: PVOID, + dwNotificationStatus: DWORD, + ServiceStatus: SERVICE_STATUS_PROCESS, + dwNotificationTriggered: DWORD, + pszServiceNames: LPWSTR, +}} +pub type PSERVICE_NOTIFY_2W = *mut SERVICE_NOTIFY_2W; +pub type SERVICE_NOTIFYA = SERVICE_NOTIFY_2A; +pub type PSERVICE_NOTIFYA = PSERVICE_NOTIFY_2A; +pub type SERVICE_NOTIFYW = SERVICE_NOTIFY_2W; +pub type PSERVICE_NOTIFYW = PSERVICE_NOTIFY_2W; +extern "system" { + pub fn ChangeServiceConfigA( + hService: SC_HANDLE, + dwServiceType: DWORD, + dsStartType: DWORD, + dwErrorControl: DWORD, + lpBinaryPathName: LPCSTR, + lpLoadOrderGroup: LPCSTR, + lpdwTagId: LPDWORD, + lpDependencies: LPCSTR, + lpServiceStartName: LPCSTR, + lpPassword: LPCSTR, + lpDisplayName: LPCSTR, + ) -> BOOL; + pub fn ChangeServiceConfigW( + hService: SC_HANDLE, + dwServiceType: DWORD, + dsStartType: DWORD, + dwErrorControl: DWORD, + lpBinaryPathName: LPCWSTR, + lpLoadOrderGroup: LPCWSTR, + lpdwTagId: LPDWORD, + lpDependencies: LPCWSTR, + lpServiceStartName: LPCWSTR, + lpPassword: LPCWSTR, + lpDisplayName: LPCWSTR, + ) -> BOOL; + pub fn ChangeServiceConfig2A( + hService: SC_HANDLE, + dwInfoLevel: DWORD, + lpInfo: LPVOID, + ) -> BOOL; + pub fn ChangeServiceConfig2W( + hService: SC_HANDLE, + dwInfoLevel: DWORD, + lpInfo: LPVOID, + ) -> BOOL; + pub fn CloseServiceHandle( + hSCObject: SC_HANDLE, + ) -> BOOL; + pub fn ControlService( + hService: SC_HANDLE, + dwControl: DWORD, + lpServiceStatus: LPSERVICE_STATUS, + ) -> BOOL; + pub fn CreateServiceA( + hSCManager: SC_HANDLE, + lpServiceName: LPCSTR, + lpDisplayName: LPCSTR, + dwDesiredAccess: DWORD, + dwServiceType: DWORD, + dwStartType: DWORD, + dwErrorControl: DWORD, + lpBinaryPathName: LPCSTR, + lpLoadOrderGroup: LPCSTR, + lpdwTagId: LPDWORD, + lpDependencies: LPCSTR, + lpServiceStartName: LPCSTR, + lpPassword: LPCSTR, + ) -> SC_HANDLE; + pub fn CreateServiceW( + hSCManager: SC_HANDLE, + lpServiceName: LPCWSTR, + lpDisplayName: LPCWSTR, + dwDesiredAccess: DWORD, + dwServiceType: DWORD, + dwStartType: DWORD, + dwErrorControl: DWORD, + lpBinaryPathName: LPCWSTR, + lpLoadOrderGroup: LPCWSTR, + lpdwTagId: LPDWORD, + lpDependencies: LPCWSTR, + lpServiceStartName: LPCWSTR, + lpPassword: LPCWSTR, + ) -> SC_HANDLE; + pub fn DeleteService( + hService: SC_HANDLE, + ) -> BOOL; + pub fn EnumDependentServicesA( + hService: SC_HANDLE, + dwServiceState: DWORD, + lpServices: LPENUM_SERVICE_STATUSA, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + lpServicesReturned: LPDWORD, + ) -> BOOL; + pub fn EnumDependentServicesW( + hService: SC_HANDLE, + dwServiceState: DWORD, + lpServices: LPENUM_SERVICE_STATUSW, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + lpServicesReturned: LPDWORD, + ) -> BOOL; + pub fn EnumServicesStatusA( + hSCManager: SC_HANDLE, + dwServiceType: DWORD, + dwServiceState: DWORD, + lpServices: LPENUM_SERVICE_STATUSA, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + lpServicesReturned: LPDWORD, + lpResumeHandle: LPDWORD, + ) -> BOOL; + pub fn EnumServicesStatusW( + hSCManager: SC_HANDLE, + dwServiceType: DWORD, + dwServiceState: DWORD, + lpServices: LPENUM_SERVICE_STATUSW, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + lpServicesReturned: LPDWORD, + lpResumeHandle: LPDWORD, + ) -> BOOL; + pub fn EnumServicesStatusExA( + hSCManager: SC_HANDLE, + InfoLevel: SC_ENUM_TYPE, + dwServiceType: DWORD, + dwServiceState: DWORD, + lpServices: LPBYTE, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + lpServicesReturned: LPDWORD, + lpResumeHandle: LPDWORD, + pszGroupName: LPCSTR, + ) -> BOOL; + pub fn EnumServicesStatusExW( + hSCManager: SC_HANDLE, + InfoLevel: SC_ENUM_TYPE, + dwServiceType: DWORD, + dwServiceState: DWORD, + lpServices: LPBYTE, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + lpServicesReturned: LPDWORD, + lpResumeHandle: LPDWORD, + pszGroupName: LPCWSTR, + ) -> BOOL; + pub fn GetServiceKeyNameA( + hSCManager: SC_HANDLE, + lpDisplayName: LPCSTR, + lpServiceName: LPSTR, + lpcchBuffer: LPDWORD, + ) -> BOOL; + pub fn GetServiceKeyNameW( + hSCManager: SC_HANDLE, + lpDisplayName: LPCWSTR, + lpServiceName: LPWSTR, + lpcchBuffer: LPDWORD, + ) -> BOOL; + pub fn GetServiceDisplayNameA( + hSCManager: SC_HANDLE, + lpServiceName: LPCSTR, + lpDisplayName: LPSTR, + lpcchBuffer: LPDWORD, + ) -> BOOL; + pub fn GetServiceDisplayNameW( + hSCManager: SC_HANDLE, + lpServiceName: LPCWSTR, + lpDisplayName: LPWSTR, + lpcchBuffer: LPDWORD, + ) -> BOOL; + pub fn LockServiceDatabase( + hSCManager: SC_HANDLE, + ) -> SC_LOCK; + pub fn NotifyBootConfigStatus( + BootAcceptable: BOOL, + ) -> BOOL; + pub fn OpenSCManagerA( + lpMachineName: LPCSTR, + lpDatabaseName: LPCSTR, + dwDesiredAccess: DWORD, + ) -> SC_HANDLE; + pub fn OpenSCManagerW( + lpMachineName: LPCWSTR, + lpDatabaseName: LPCWSTR, + dwDesiredAccess: DWORD, + ) -> SC_HANDLE; + pub fn OpenServiceA( + hSCManager: SC_HANDLE, + lpServiceName: LPCSTR, + dwDesiredAccess: DWORD, + ) -> SC_HANDLE; + pub fn OpenServiceW( + hSCManager: SC_HANDLE, + lpServiceName: LPCWSTR, + dwDesiredAccess: DWORD, + ) -> SC_HANDLE; + pub fn QueryServiceConfigA( + hService: SC_HANDLE, + lpServiceConfig: LPQUERY_SERVICE_CONFIGA, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + ) -> BOOL; + pub fn QueryServiceConfigW( + hService: SC_HANDLE, + lpServiceConfig: LPQUERY_SERVICE_CONFIGW, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + ) -> BOOL; + pub fn QueryServiceConfig2A( + hService: SC_HANDLE, + dwInfoLevel: DWORD, + lpBuffer: LPBYTE, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + ) -> BOOL; + pub fn QueryServiceConfig2W( + hService: SC_HANDLE, + dwInfoLevel: DWORD, + lpBuffer: LPBYTE, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + ) -> BOOL; + pub fn QueryServiceLockStatusA( + hSCManager: SC_HANDLE, + lpLockStatus: LPQUERY_SERVICE_LOCK_STATUSA, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + ) -> BOOL; + pub fn QueryServiceLockStatusW( + hSCManager: SC_HANDLE, + lpLockStatus: LPQUERY_SERVICE_LOCK_STATUSW, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + ) -> BOOL; + pub fn QueryServiceObjectSecurity( + hService: SC_HANDLE, + dwSecurityInformation: SECURITY_INFORMATION, + lpSecurityDescriptor: PSECURITY_DESCRIPTOR, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + ) -> BOOL; + pub fn QueryServiceStatus( + hService: SC_HANDLE, + lpServiceStatus: LPSERVICE_STATUS, + ) -> BOOL; + pub fn QueryServiceStatusEx( + hService: SC_HANDLE, + InfoLevel: SC_STATUS_TYPE, + lpBuffer: LPBYTE, + cbBufSize: DWORD, + pcbBytesNeeded: LPDWORD, + ) -> BOOL; + pub fn RegisterServiceCtrlHandlerA( + lpServiceName: LPCSTR, + lpHandlerProc: LPHANDLER_FUNCTION, + ) -> SERVICE_STATUS_HANDLE; + pub fn RegisterServiceCtrlHandlerW( + lpServiceName: LPCWSTR, + lpHandlerProc: LPHANDLER_FUNCTION, + ) -> SERVICE_STATUS_HANDLE; + pub fn RegisterServiceCtrlHandlerExA( + lpServiceName: LPCSTR, + lpHandlerProc: LPHANDLER_FUNCTION_EX, + lpContext: LPVOID, + ) -> SERVICE_STATUS_HANDLE; + pub fn RegisterServiceCtrlHandlerExW( + lpServiceName: LPCWSTR, + lpHandlerProc: LPHANDLER_FUNCTION_EX, + lpContext: LPVOID, + ) -> SERVICE_STATUS_HANDLE; + pub fn SetServiceObjectSecurity( + hService: SC_HANDLE, + dwSecurityInformation: SECURITY_INFORMATION, + lpSecurityDescriptor: PSECURITY_DESCRIPTOR, + ) -> BOOL; + pub fn SetServiceStatus( + hServiceStatus: SERVICE_STATUS_HANDLE, + lpServiceStatus: LPSERVICE_STATUS, + ) -> BOOL; + pub fn StartServiceCtrlDispatcherA( + lpServiceStartTable: *const SERVICE_TABLE_ENTRYA, + ) -> BOOL; + pub fn StartServiceCtrlDispatcherW( + lpServiceStartTable: *const SERVICE_TABLE_ENTRYW, + ) -> BOOL; + pub fn StartServiceA( + hService: SC_HANDLE, + dwNumServiceArgs: DWORD, + lpServiceArgVectors: *mut LPCSTR, + ) -> BOOL; + pub fn StartServiceW( + hService: SC_HANDLE, + dwNumServiceArgs: DWORD, + lpServiceArgVectors: *mut LPCWSTR, + ) -> BOOL; + pub fn UnlockServiceDatabase( + ScLock: SC_LOCK, + ) -> BOOL; + pub fn NotifyServiceStatusChangeA( + hService: SC_HANDLE, + dwNotifyMask: DWORD, + pNotifyBuffer: PSERVICE_NOTIFYA, + ) -> DWORD; + pub fn NotifyServiceStatusChangeW( + hService: SC_HANDLE, + dwNotifyMask: DWORD, + pNotifyBuffer: PSERVICE_NOTIFYW, + ) -> DWORD; + pub fn ControlServiceExA( + hService: SC_HANDLE, + dwControl: DWORD, + dwInfoLevel: DWORD, + pControlParams: PVOID, + ) -> BOOL; + pub fn ControlServiceExW( + hService: SC_HANDLE, + dwControl: DWORD, + dwInfoLevel: DWORD, + pControlParams: PVOID, + ) -> BOOL; + pub fn QueryServiceDynamicInformation( + hServiceStatus: SERVICE_STATUS_HANDLE, + dwInfoLevel: DWORD, + ppDynamicInfo: *mut PVOID, + ) -> BOOL; + pub fn WaitServiceState ( + hService: SC_HANDLE, + dwNotify: DWORD, + dwTimeout: DWORD, + hCancelEvent: HANDLE, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winusb.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winusb.rs new file mode 100644 index 0000000..c72e368 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winusb.rs @@ -0,0 +1,224 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! FFI bindings to winusb. +use shared::minwindef::{BOOL, LPDWORD, PUCHAR, PULONG, UCHAR, ULONG, USHORT}; +use shared::usb::PUSBD_ISO_PACKET_DESCRIPTOR; +use shared::usbspec::PUSB_CONFIGURATION_DESCRIPTOR; +use shared::winusbio::{PWINUSB_PIPE_INFORMATION, PWINUSB_PIPE_INFORMATION_EX}; +use um::minwinbase::LPOVERLAPPED; +use um::winnt::{HANDLE, LARGE_INTEGER, LONG, PVOID}; +pub type WINUSB_INTERFACE_HANDLE = PVOID; +pub type PWINUSB_INTERFACE_HANDLE = *mut PVOID; +pub type WINUSB_ISOCH_BUFFER_HANDLE = PVOID; +pub type PWINUSB_ISOCH_BUFFER_HANDLE = *mut PVOID; +STRUCT!{#[repr(packed)] struct WINUSB_SETUP_PACKET { + RequestType: UCHAR, + Request: UCHAR, + Value: USHORT, + Index: USHORT, + Length: USHORT, +}} +pub type PWINUSB_SETUP_PACKET = *mut WINUSB_SETUP_PACKET; +extern "system" { + pub fn WinUsb_Initialize( + DeviceHandle: HANDLE, + InterfaceHandle: PWINUSB_INTERFACE_HANDLE, + ) -> BOOL; + pub fn WinUsb_Free( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + ) -> BOOL; + pub fn WinUsb_GetAssociatedInterface( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + AssociatedInterfaceIndex: UCHAR, + AssociatedInterfaceHandle: PWINUSB_INTERFACE_HANDLE, + ) -> BOOL; + pub fn WinUsb_GetDescriptor( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + DescriptorType: UCHAR, + Index: UCHAR, + LanguageID: USHORT, + Buffer: PUCHAR, + BufferLength: ULONG, + LengthTransferred: PULONG, + ) -> BOOL; + pub fn WinUsb_QueryInterfaceSettings( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + AlternateInterfaceNumber: UCHAR, + UsbAltInterfaceDescriptor: PUSB_INTERFACE_DESCRIPTOR, + ) -> BOOL; + pub fn WinUsb_QueryDeviceInformation( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + InformationType: ULONG, + BufferLength: PULONG, + Buffer: PVOID, + ) -> BOOL; + pub fn WinUsb_SetCurrentAlternateSetting( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + SettingNumber: UCHAR, + ) -> BOOL; + pub fn WinUsb_GetCurrentAlternateSetting( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + SettingNumber: PUCHAR, + ) -> BOOL; + pub fn WinUsb_QueryPipe( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + AlternateInterfaceNumber: UCHAR, + PipeIndex: UCHAR, + PipeInformationEx: PWINUSB_PIPE_INFORMATION, + ) -> BOOL; + pub fn WinUsb_QueryPipeEx( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + AlternateInterfaceNumber: UCHAR, + PipeIndex: UCHAR, + PipeInformationEx: PWINUSB_PIPE_INFORMATION_EX, + ) -> BOOL; + pub fn WinUsb_SetPipePolicy( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + PipeID: UCHAR, + PolicyType: ULONG, + ValueLength: ULONG, + Value: PVOID, + ) -> BOOL; + pub fn WinUsb_GetPipePolicy( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + PipeID: UCHAR, + PolicyType: ULONG, + ValueLength: PULONG, + Value: PVOID, + ) -> BOOL; + pub fn WinUsb_ReadPipe( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + PipeID: UCHAR, + Buffer: PUCHAR, + BufferLength: ULONG, + LengthTransferred: PULONG, + Overlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn WinUsb_WritePipe( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + PipeID: UCHAR, + Buffer: PUCHAR, + BufferLength: ULONG, + LengthTransferred: PULONG, + Overlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn WinUsb_ControlTransfer( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + SetupPacket: WINUSB_SETUP_PACKET, + Buffer: PUCHAR, + BufferLength: ULONG, + LengthTransferred: PULONG, + Overlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn WinUsb_ResetPipe( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + PipeID: UCHAR, + ) -> BOOL; + pub fn WinUsb_AbortPipe( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + PipeID: UCHAR, + ) -> BOOL; + pub fn WinUsb_FlushPipe( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + PipeID: UCHAR, + ) -> BOOL; + pub fn WinUsb_SetPowerPolicy( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + PolicyType: ULONG, + ValueLength: ULONG, + Value: PVOID, + ) -> BOOL; + pub fn WinUsb_GetPowerPolicy( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + PolicyType: ULONG, + ValueLength: PULONG, + Value: PVOID, + ) -> BOOL; + pub fn WinUsb_GetOverlappedResult( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + lpOverlapped: LPOVERLAPPED, + lpNumberOfBytesTransferred: LPDWORD, + bWait: BOOL, + ) -> BOOL; + pub fn WinUsb_ParseConfigurationDescriptor( + ConfigurationDescriptor: PUSB_CONFIGURATION_DESCRIPTOR, + StartPosition: PVOID, + InterfaceNumber: LONG, + AlternateSetting: LONG, + InterfaceClass: LONG, + InterfaceSubClass: LONG, + InterfaceProtocol: LONG, + ) -> BOOL; + pub fn WinUsb_ParseDescriptors( + DescriptorBuffer: PVOID, + TotalLength: ULONG, + StartPosition: PVOID, + DescriptorType: LONG, + ) -> BOOL; + pub fn WinUsb_GetCurrentFrameNumber( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + CurrentFrameNumber: PULONG, + TimeStamp: *mut LARGE_INTEGER, + ) -> BOOL; + pub fn WinUsb_GetAdjustedFrameNumber( + CurrentFrameNumber: PULONG, + TimeStamp: LARGE_INTEGER, + ) -> BOOL; + pub fn WinUsb_RegisterIsochBuffer( + InterfaceHandle: WINUSB_INTERFACE_HANDLE, + PipeID: UCHAR, + Buffer: PUCHAR, + BufferLength: ULONG, + IsochBufferHandle: PWINUSB_ISOCH_BUFFER_HANDLE, + ) -> BOOL; + pub fn WinUsb_UnregisterIsochBuffer( + IsochBufferHandle: WINUSB_ISOCH_BUFFER_HANDLE, + ) -> BOOL; + pub fn WinUsb_WriteIsochPipe( + BufferHandle: WINUSB_ISOCH_BUFFER_HANDLE, + Offset: ULONG, + Length: ULONG, + FrameNumber: PULONG, + Overlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn WinUsb_ReadIsochPipe( + BufferHandle: WINUSB_ISOCH_BUFFER_HANDLE, + Offset: ULONG, + Length: ULONG, + FrameNumber: PULONG, + NumberOfPackets: ULONG, + IsoPacketDescriptors: PUSBD_ISO_PACKET_DESCRIPTOR, + Overlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn WinUsb_WriteIsochPipeAsap( + BufferHandle: WINUSB_ISOCH_BUFFER_HANDLE, + Offset: ULONG, + Length: ULONG, + ContinueStream: BOOL, + Overlapped: LPOVERLAPPED, + ) -> BOOL; + pub fn WinUsb_ReadIsochPipeAsap( + BufferHandle: WINUSB_ISOCH_BUFFER_HANDLE, + Offset: ULONG, + Length: ULONG, + ContinueStream: BOOL, + NumberOfPackets: ULONG, + IsoPacketDescriptors: PUSBD_ISO_PACKET_DESCRIPTOR, + Overlapped: LPOVERLAPPED, + ) -> BOOL; +} +STRUCT!{struct USB_INTERFACE_DESCRIPTOR { + bLength: UCHAR, + bDescriptorType: UCHAR, + bInterfaceNumber: UCHAR, + bAlternateSetting: UCHAR, + bNumEndpoints: UCHAR, + bInterfaceClass: UCHAR, + bInterfaceSubClass: UCHAR, + bInterfaceProtocol: UCHAR, + iInterface: UCHAR, +}} +pub type PUSB_INTERFACE_DESCRIPTOR = *mut USB_INTERFACE_DESCRIPTOR; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winuser.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winuser.rs new file mode 100644 index 0000000..d3cc4b8 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winuser.rs @@ -0,0 +1,7205 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! USER procedure declarations, constant definitions and macros +use ctypes::{c_int, c_long, c_short, c_uint}; +use shared::basetsd::{ + DWORD_PTR, INT32, INT_PTR, PDWORD_PTR, UINT16, UINT32, UINT64, UINT_PTR, ULONG_PTR, +}; +#[cfg(target_pointer_width = "64")] +use shared::basetsd::LONG_PTR; +use shared::guiddef::{GUID, LPCGUID}; +use shared::minwindef::{ + ATOM, BOOL, BYTE, DWORD, HINSTANCE, HIWORD, HKL, HMODULE, HRGN, HWINSTA, INT, LOWORD, LPARAM, + LPBYTE, LPDWORD, LPINT, LPVOID, LPWORD, LRESULT, PBYTE, PUINT, PULONG, TRUE, UCHAR, UINT, + ULONG, USHORT, WORD, WPARAM, +}; +use shared::windef::{ + COLORREF, DPI_AWARENESS, DPI_AWARENESS_CONTEXT, DPI_HOSTING_BEHAVIOR, HACCEL, HBITMAP, HBRUSH, + HCURSOR, HDC, HDESK, HHOOK, HICON, HMENU, HMONITOR, HWINEVENTHOOK, HWND, LPCRECT, LPPOINT, + LPRECT, POINT, RECT, SIZE, +}; +use um::minwinbase::LPSECURITY_ATTRIBUTES; +use um::wingdi::{ + BLENDFUNCTION, DEVMODEA, DEVMODEW, LOGFONTA, LOGFONTW, PDISPLAY_DEVICEA, PDISPLAY_DEVICEW +}; +use um::winnt::{ + ACCESS_MASK, BOOLEAN, CHAR, HANDLE, LONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, LUID, + PSECURITY_DESCRIPTOR, PSECURITY_INFORMATION, PVOID, SHORT, VOID, WCHAR, +}; +use vc::limits::UINT_MAX; +use vc::vadefs::va_list; +pub type HDWP = HANDLE; +pub type MENUTEMPLATEA = VOID; +pub type MENUTEMPLATEW = VOID; +pub type LPMENUTEMPLATEA = PVOID; +pub type LPMENUTEMPLATEW = PVOID; +FN!{stdcall WNDPROC( + HWND, + UINT, + WPARAM, + LPARAM, +) -> LRESULT} +FN!{stdcall DLGPROC( + HWND, + UINT, + WPARAM, + LPARAM, +) -> INT_PTR} +FN!{stdcall TIMERPROC( + HWND, + UINT, + UINT_PTR, + DWORD, +) -> ()} +FN!{stdcall GRAYSTRINGPROC( + HDC, + LPARAM, + c_int, +) -> BOOL} +FN!{stdcall WNDENUMPROC( + HWND, + LPARAM, +) -> BOOL} +FN!{stdcall HOOKPROC( + code: c_int, + wParam: WPARAM, + lParam: LPARAM, +) -> LRESULT} +FN!{stdcall SENDASYNCPROC( + HWND, + UINT, + ULONG_PTR, + LRESULT, +) -> ()} +FN!{stdcall PROPENUMPROCA( + HWND, + LPCSTR, + HANDLE, +) -> BOOL} +FN!{stdcall PROPENUMPROCW( + HWND, + LPCWSTR, + HANDLE, +) -> BOOL} +FN!{stdcall PROPENUMPROCEXA( + HWND, + LPSTR, + HANDLE, + ULONG_PTR, +) -> BOOL} +FN!{stdcall PROPENUMPROCEXW( + HWND, + LPWSTR, + HANDLE, + ULONG_PTR, +) -> BOOL} +FN!{stdcall EDITWORDBREAKPROCA( + lpch: LPSTR, + ichCurrent: c_int, + cch: c_int, + code: c_int, +) -> c_int} +FN!{stdcall EDITWORDBREAKPROCW( + lpch: LPWSTR, + ichCurrent: c_int, + cch: c_int, + code: c_int, +) -> c_int} +FN!{stdcall DRAWSTATEPROC( + hdc: HDC, + lData: LPARAM, + wData: WPARAM, + cx: c_int, + cy: c_int, +) -> BOOL} +FN!{stdcall NAMEENUMPROCA( + LPSTR, + LPARAM, +) -> BOOL} +FN!{stdcall NAMEENUMPROCW( + LPWSTR, + LPARAM, +) -> BOOL} +pub type WINSTAENUMPROCA = NAMEENUMPROCA; +pub type DESKTOPENUMPROCA = NAMEENUMPROCA; +pub type WINSTAENUMPROCW = NAMEENUMPROCW; +pub type DESKTOPENUMPROCW = NAMEENUMPROCW; +#[inline] +pub fn IS_INTRESOURCE(r: ULONG_PTR) -> bool { + (r >> 16) == 0 +} +#[inline] +pub fn MAKEINTRESOURCEA(i: WORD) -> LPSTR { + i as ULONG_PTR as LPSTR +} +#[inline] +pub fn MAKEINTRESOURCEW(i: WORD) -> LPWSTR { + i as ULONG_PTR as LPWSTR +} +pub const RT_CURSOR: LPWSTR = MAKEINTRESOURCE!(1); +pub const RT_BITMAP: LPWSTR = MAKEINTRESOURCE!(2); +pub const RT_ICON: LPWSTR = MAKEINTRESOURCE!(3); +pub const RT_MENU: LPWSTR = MAKEINTRESOURCE!(4); +pub const RT_DIALOG: LPWSTR = MAKEINTRESOURCE!(5); +pub const RT_STRING: LPWSTR = MAKEINTRESOURCE!(6); +pub const RT_FONTDIR: LPWSTR = MAKEINTRESOURCE!(7); +pub const RT_FONT: LPWSTR = MAKEINTRESOURCE!(8); +pub const RT_ACCELERATOR: LPWSTR = MAKEINTRESOURCE!(9); +pub const RT_RCDATA: LPWSTR = MAKEINTRESOURCE!(10); +pub const RT_MESSAGETABLE: LPWSTR = MAKEINTRESOURCE!(11); +pub const DIFFERENCE: WORD = 11; +pub const RT_GROUP_CURSOR: LPWSTR = MAKEINTRESOURCE!(1 + DIFFERENCE); +pub const RT_GROUP_ICON: LPWSTR = MAKEINTRESOURCE!(3 + DIFFERENCE); +pub const RT_VERSION: LPWSTR = MAKEINTRESOURCE!(16); +pub const RT_DLGINCLUDE: LPWSTR = MAKEINTRESOURCE!(17); +pub const RT_PLUGPLAY: LPWSTR = MAKEINTRESOURCE!(19); +pub const RT_VXD: LPWSTR = MAKEINTRESOURCE!(20); +pub const RT_ANICURSOR: LPWSTR = MAKEINTRESOURCE!(21); +pub const RT_ANIICON: LPWSTR = MAKEINTRESOURCE!(22); +pub const RT_HTML: LPWSTR = MAKEINTRESOURCE!(23); +pub const RT_MANIFEST: LPWSTR = MAKEINTRESOURCE!(24); +pub const CREATEPROCESS_MANIFEST_RESOURCE_ID: LPWSTR = MAKEINTRESOURCE!(1); +pub const ISOLATIONAWARE_MANIFEST_RESOURCE_ID: LPWSTR = MAKEINTRESOURCE!(2); +pub const ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID: LPWSTR + = MAKEINTRESOURCE!(3); +pub const MINIMUM_RESERVED_MANIFEST_RESOURCE_ID: LPWSTR = MAKEINTRESOURCE!(1); +pub const MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID: LPWSTR = MAKEINTRESOURCE!(16); +extern "system" { + pub fn wvsprintfA( + _: LPSTR, + _: LPCSTR, + arglist: va_list, + ) -> c_int; + pub fn wvsprintfW( + _: LPWSTR, + _: LPCWSTR, + arglist: va_list, + ) -> c_int; +} +extern "C" { + pub fn wsprintfA( + _: LPSTR, + _: LPCSTR, + ... + ) -> c_int; + pub fn wsprintfW( + _: LPWSTR, + _: LPCWSTR, + ... + ) -> c_int; +} +pub const SETWALLPAPER_DEFAULT: LPWSTR = -1isize as LPWSTR; +pub const SB_HORZ: UINT = 0; +pub const SB_VERT: UINT = 1; +pub const SB_CTL: UINT = 2; +pub const SB_BOTH: UINT = 3; +pub const SB_LINEUP: LPARAM = 0; +pub const SB_LINELEFT: LPARAM = 0; +pub const SB_LINEDOWN: LPARAM = 1; +pub const SB_LINERIGHT: LPARAM = 1; +pub const SB_PAGEUP: LPARAM = 2; +pub const SB_PAGELEFT: LPARAM = 2; +pub const SB_PAGEDOWN: LPARAM = 3; +pub const SB_PAGERIGHT: LPARAM = 3; +pub const SB_THUMBPOSITION: LPARAM = 4; +pub const SB_THUMBTRACK: LPARAM = 5; +pub const SB_TOP: LPARAM = 6; +pub const SB_LEFT: LPARAM = 6; +pub const SB_BOTTOM: LPARAM = 7; +pub const SB_RIGHT: LPARAM = 7; +pub const SB_ENDSCROLL: LPARAM = 8; +pub const SW_HIDE: c_int = 0; +pub const SW_SHOWNORMAL: c_int = 1; +pub const SW_NORMAL: c_int = 1; +pub const SW_SHOWMINIMIZED: c_int = 2; +pub const SW_SHOWMAXIMIZED: c_int = 3; +pub const SW_MAXIMIZE: c_int = 3; +pub const SW_SHOWNOACTIVATE: c_int = 4; +pub const SW_SHOW: c_int = 5; +pub const SW_MINIMIZE: c_int = 6; +pub const SW_SHOWMINNOACTIVE: c_int = 7; +pub const SW_SHOWNA: c_int = 8; +pub const SW_RESTORE: c_int = 9; +pub const SW_SHOWDEFAULT: c_int = 10; +pub const SW_FORCEMINIMIZE: c_int = 11; +pub const SW_MAX: c_int = 11; +pub const HIDE_WINDOW: c_int = 0; +pub const SHOW_OPENWINDOW: c_int = 1; +pub const SHOW_ICONWINDOW: c_int = 2; +pub const SHOW_FULLSCREEN: c_int = 3; +pub const SHOW_OPENNOACTIVATE: c_int = 4; +pub const SW_PARENTCLOSING: LPARAM = 1; +pub const SW_OTHERZOOM: LPARAM = 2; +pub const SW_PARENTOPENING: LPARAM = 3; +pub const SW_OTHERUNZOOM: LPARAM = 4; +pub const AW_HOR_POSITIVE: DWORD = 0x00000001; +pub const AW_HOR_NEGATIVE: DWORD = 0x00000002; +pub const AW_VER_POSITIVE: DWORD = 0x00000004; +pub const AW_VER_NEGATIVE: DWORD = 0x00000008; +pub const AW_CENTER: DWORD = 0x00000010; +pub const AW_HIDE: DWORD = 0x00010000; +pub const AW_ACTIVATE: DWORD = 0x00020000; +pub const AW_SLIDE: DWORD = 0x00040000; +pub const AW_BLEND: DWORD = 0x00080000; +pub const KF_EXTENDED: WORD = 0x0100; +pub const KF_DLGMODE: WORD = 0x0800; +pub const KF_MENUMODE: WORD = 0x1000; +pub const KF_ALTDOWN: WORD = 0x2000; +pub const KF_REPEAT: WORD = 0x4000; +pub const KF_UP: WORD = 0x8000; +pub const VK_LBUTTON: c_int = 0x01; +pub const VK_RBUTTON: c_int = 0x02; +pub const VK_CANCEL: c_int = 0x03; +pub const VK_MBUTTON: c_int = 0x04; +pub const VK_XBUTTON1: c_int = 0x05; +pub const VK_XBUTTON2: c_int = 0x06; +pub const VK_BACK: c_int = 0x08; +pub const VK_TAB: c_int = 0x09; +pub const VK_CLEAR: c_int = 0x0C; +pub const VK_RETURN: c_int = 0x0D; +pub const VK_SHIFT: c_int = 0x10; +pub const VK_CONTROL: c_int = 0x11; +pub const VK_MENU: c_int = 0x12; +pub const VK_PAUSE: c_int = 0x13; +pub const VK_CAPITAL: c_int = 0x14; +pub const VK_KANA: c_int = 0x15; +pub const VK_HANGEUL: c_int = 0x15; +pub const VK_HANGUL: c_int = 0x15; +pub const VK_JUNJA: c_int = 0x17; +pub const VK_FINAL: c_int = 0x18; +pub const VK_HANJA: c_int = 0x19; +pub const VK_KANJI: c_int = 0x19; +pub const VK_ESCAPE: c_int = 0x1B; +pub const VK_CONVERT: c_int = 0x1C; +pub const VK_NONCONVERT: c_int = 0x1D; +pub const VK_ACCEPT: c_int = 0x1E; +pub const VK_MODECHANGE: c_int = 0x1F; +pub const VK_SPACE: c_int = 0x20; +pub const VK_PRIOR: c_int = 0x21; +pub const VK_NEXT: c_int = 0x22; +pub const VK_END: c_int = 0x23; +pub const VK_HOME: c_int = 0x24; +pub const VK_LEFT: c_int = 0x25; +pub const VK_UP: c_int = 0x26; +pub const VK_RIGHT: c_int = 0x27; +pub const VK_DOWN: c_int = 0x28; +pub const VK_SELECT: c_int = 0x29; +pub const VK_PRINT: c_int = 0x2A; +pub const VK_EXECUTE: c_int = 0x2B; +pub const VK_SNAPSHOT: c_int = 0x2C; +pub const VK_INSERT: c_int = 0x2D; +pub const VK_DELETE: c_int = 0x2E; +pub const VK_HELP: c_int = 0x2F; +pub const VK_LWIN: c_int = 0x5B; +pub const VK_RWIN: c_int = 0x5C; +pub const VK_APPS: c_int = 0x5D; +pub const VK_SLEEP: c_int = 0x5F; +pub const VK_NUMPAD0: c_int = 0x60; +pub const VK_NUMPAD1: c_int = 0x61; +pub const VK_NUMPAD2: c_int = 0x62; +pub const VK_NUMPAD3: c_int = 0x63; +pub const VK_NUMPAD4: c_int = 0x64; +pub const VK_NUMPAD5: c_int = 0x65; +pub const VK_NUMPAD6: c_int = 0x66; +pub const VK_NUMPAD7: c_int = 0x67; +pub const VK_NUMPAD8: c_int = 0x68; +pub const VK_NUMPAD9: c_int = 0x69; +pub const VK_MULTIPLY: c_int = 0x6A; +pub const VK_ADD: c_int = 0x6B; +pub const VK_SEPARATOR: c_int = 0x6C; +pub const VK_SUBTRACT: c_int = 0x6D; +pub const VK_DECIMAL: c_int = 0x6E; +pub const VK_DIVIDE: c_int = 0x6F; +pub const VK_F1: c_int = 0x70; +pub const VK_F2: c_int = 0x71; +pub const VK_F3: c_int = 0x72; +pub const VK_F4: c_int = 0x73; +pub const VK_F5: c_int = 0x74; +pub const VK_F6: c_int = 0x75; +pub const VK_F7: c_int = 0x76; +pub const VK_F8: c_int = 0x77; +pub const VK_F9: c_int = 0x78; +pub const VK_F10: c_int = 0x79; +pub const VK_F11: c_int = 0x7A; +pub const VK_F12: c_int = 0x7B; +pub const VK_F13: c_int = 0x7C; +pub const VK_F14: c_int = 0x7D; +pub const VK_F15: c_int = 0x7E; +pub const VK_F16: c_int = 0x7F; +pub const VK_F17: c_int = 0x80; +pub const VK_F18: c_int = 0x81; +pub const VK_F19: c_int = 0x82; +pub const VK_F20: c_int = 0x83; +pub const VK_F21: c_int = 0x84; +pub const VK_F22: c_int = 0x85; +pub const VK_F23: c_int = 0x86; +pub const VK_F24: c_int = 0x87; +pub const VK_NAVIGATION_VIEW: c_int = 0x88; +pub const VK_NAVIGATION_MENU: c_int = 0x89; +pub const VK_NAVIGATION_UP: c_int = 0x8A; +pub const VK_NAVIGATION_DOWN: c_int = 0x8B; +pub const VK_NAVIGATION_LEFT: c_int = 0x8C; +pub const VK_NAVIGATION_RIGHT: c_int = 0x8D; +pub const VK_NAVIGATION_ACCEPT: c_int = 0x8E; +pub const VK_NAVIGATION_CANCEL: c_int = 0x8F; +pub const VK_NUMLOCK: c_int = 0x90; +pub const VK_SCROLL: c_int = 0x91; +pub const VK_OEM_NEC_EQUAL: c_int = 0x92; +pub const VK_OEM_FJ_JISHO: c_int = 0x92; +pub const VK_OEM_FJ_MASSHOU: c_int = 0x93; +pub const VK_OEM_FJ_TOUROKU: c_int = 0x94; +pub const VK_OEM_FJ_LOYA: c_int = 0x95; +pub const VK_OEM_FJ_ROYA: c_int = 0x96; +pub const VK_LSHIFT: c_int = 0xA0; +pub const VK_RSHIFT: c_int = 0xA1; +pub const VK_LCONTROL: c_int = 0xA2; +pub const VK_RCONTROL: c_int = 0xA3; +pub const VK_LMENU: c_int = 0xA4; +pub const VK_RMENU: c_int = 0xA5; +pub const VK_BROWSER_BACK: c_int = 0xA6; +pub const VK_BROWSER_FORWARD: c_int = 0xA7; +pub const VK_BROWSER_REFRESH: c_int = 0xA8; +pub const VK_BROWSER_STOP: c_int = 0xA9; +pub const VK_BROWSER_SEARCH: c_int = 0xAA; +pub const VK_BROWSER_FAVORITES: c_int = 0xAB; +pub const VK_BROWSER_HOME: c_int = 0xAC; +pub const VK_VOLUME_MUTE: c_int = 0xAD; +pub const VK_VOLUME_DOWN: c_int = 0xAE; +pub const VK_VOLUME_UP: c_int = 0xAF; +pub const VK_MEDIA_NEXT_TRACK: c_int = 0xB0; +pub const VK_MEDIA_PREV_TRACK: c_int = 0xB1; +pub const VK_MEDIA_STOP: c_int = 0xB2; +pub const VK_MEDIA_PLAY_PAUSE: c_int = 0xB3; +pub const VK_LAUNCH_MAIL: c_int = 0xB4; +pub const VK_LAUNCH_MEDIA_SELECT: c_int = 0xB5; +pub const VK_LAUNCH_APP1: c_int = 0xB6; +pub const VK_LAUNCH_APP2: c_int = 0xB7; +pub const VK_OEM_1: c_int = 0xBA; +pub const VK_OEM_PLUS: c_int = 0xBB; +pub const VK_OEM_COMMA: c_int = 0xBC; +pub const VK_OEM_MINUS: c_int = 0xBD; +pub const VK_OEM_PERIOD: c_int = 0xBE; +pub const VK_OEM_2: c_int = 0xBF; +pub const VK_OEM_3: c_int = 0xC0; +pub const VK_GAMEPAD_A: c_int = 0xC3; +pub const VK_GAMEPAD_B: c_int = 0xC4; +pub const VK_GAMEPAD_X: c_int = 0xC5; +pub const VK_GAMEPAD_Y: c_int = 0xC6; +pub const VK_GAMEPAD_RIGHT_SHOULDER: c_int = 0xC7; +pub const VK_GAMEPAD_LEFT_SHOULDER: c_int = 0xC8; +pub const VK_GAMEPAD_LEFT_TRIGGER: c_int = 0xC9; +pub const VK_GAMEPAD_RIGHT_TRIGGER: c_int = 0xCA; +pub const VK_GAMEPAD_DPAD_UP: c_int = 0xCB; +pub const VK_GAMEPAD_DPAD_DOWN: c_int = 0xCC; +pub const VK_GAMEPAD_DPAD_LEFT: c_int = 0xCD; +pub const VK_GAMEPAD_DPAD_RIGHT: c_int = 0xCE; +pub const VK_GAMEPAD_MENU: c_int = 0xCF; +pub const VK_GAMEPAD_VIEW: c_int = 0xD0; +pub const VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON: c_int = 0xD1; +pub const VK_GAMEPAD_RIGHT_THUMBSTICK_BUTTON: c_int = 0xD2; +pub const VK_GAMEPAD_LEFT_THUMBSTICK_UP: c_int = 0xD3; +pub const VK_GAMEPAD_LEFT_THUMBSTICK_DOWN: c_int = 0xD4; +pub const VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT: c_int = 0xD5; +pub const VK_GAMEPAD_LEFT_THUMBSTICK_LEFT: c_int = 0xD6; +pub const VK_GAMEPAD_RIGHT_THUMBSTICK_UP: c_int = 0xD7; +pub const VK_GAMEPAD_RIGHT_THUMBSTICK_DOWN: c_int = 0xD8; +pub const VK_GAMEPAD_RIGHT_THUMBSTICK_RIGHT: c_int = 0xD9; +pub const VK_GAMEPAD_RIGHT_THUMBSTICK_LEFT: c_int = 0xDA; +pub const VK_OEM_4: c_int = 0xDB; +pub const VK_OEM_5: c_int = 0xDC; +pub const VK_OEM_6: c_int = 0xDD; +pub const VK_OEM_7: c_int = 0xDE; +pub const VK_OEM_8: c_int = 0xDF; +pub const VK_OEM_AX: c_int = 0xE1; +pub const VK_OEM_102: c_int = 0xE2; +pub const VK_ICO_HELP: c_int = 0xE3; +pub const VK_ICO_00: c_int = 0xE4; +pub const VK_PROCESSKEY: c_int = 0xE5; +pub const VK_ICO_CLEAR: c_int = 0xE6; +pub const VK_PACKET: c_int = 0xE7; +pub const VK_OEM_RESET: c_int = 0xE9; +pub const VK_OEM_JUMP: c_int = 0xEA; +pub const VK_OEM_PA1: c_int = 0xEB; +pub const VK_OEM_PA2: c_int = 0xEC; +pub const VK_OEM_PA3: c_int = 0xED; +pub const VK_OEM_WSCTRL: c_int = 0xEE; +pub const VK_OEM_CUSEL: c_int = 0xEF; +pub const VK_OEM_ATTN: c_int = 0xF0; +pub const VK_OEM_FINISH: c_int = 0xF1; +pub const VK_OEM_COPY: c_int = 0xF2; +pub const VK_OEM_AUTO: c_int = 0xF3; +pub const VK_OEM_ENLW: c_int = 0xF4; +pub const VK_OEM_BACKTAB: c_int = 0xF5; +pub const VK_ATTN: c_int = 0xF6; +pub const VK_CRSEL: c_int = 0xF7; +pub const VK_EXSEL: c_int = 0xF8; +pub const VK_EREOF: c_int = 0xF9; +pub const VK_PLAY: c_int = 0xFA; +pub const VK_ZOOM: c_int = 0xFB; +pub const VK_NONAME: c_int = 0xFC; +pub const VK_PA1: c_int = 0xFD; +pub const VK_OEM_CLEAR: c_int = 0xFE; +pub const WH_MIN: c_int = -1; +pub const WH_MSGFILTER: c_int = -1; +pub const WH_JOURNALRECORD: c_int = 0; +pub const WH_JOURNALPLAYBACK: c_int = 1; +pub const WH_KEYBOARD: c_int = 2; +pub const WH_GETMESSAGE: c_int = 3; +pub const WH_CALLWNDPROC: c_int = 4; +pub const WH_CBT: c_int = 5; +pub const WH_SYSMSGFILTER: c_int = 6; +pub const WH_MOUSE: c_int = 7; +pub const WH_HARDWARE: c_int = 8; +pub const WH_DEBUG: c_int = 9; +pub const WH_SHELL: c_int = 10; +pub const WH_FOREGROUNDIDLE: c_int = 11; +pub const WH_CALLWNDPROCRET: c_int = 12; +pub const WH_KEYBOARD_LL: c_int = 13; +pub const WH_MOUSE_LL: c_int = 14; +pub const WH_MAX: c_int = 14; +pub const WH_MINHOOK: c_int = WH_MIN; +pub const WH_MAXHOOK: c_int = WH_MAX; +pub const HC_ACTION: c_int = 0; +pub const HC_GETNEXT: c_int = 1; +pub const HC_SKIP: c_int = 2; +pub const HC_NOREMOVE: c_int = 3; +pub const HC_NOREM: c_int = HC_NOREMOVE; +pub const HC_SYSMODALON: c_int = 4; +pub const HC_SYSMODALOFF: c_int = 5; +pub const HCBT_MOVESIZE: c_int = 0; +pub const HCBT_MINMAX: c_int = 1; +pub const HCBT_QS: c_int = 2; +pub const HCBT_CREATEWND: c_int = 3; +pub const HCBT_DESTROYWND: c_int = 4; +pub const HCBT_ACTIVATE: c_int = 5; +pub const HCBT_CLICKSKIPPED: c_int = 6; +pub const HCBT_KEYSKIPPED: c_int = 7; +pub const HCBT_SYSCOMMAND: c_int = 8; +pub const HCBT_SETFOCUS: c_int = 9; +STRUCT!{struct CBT_CREATEWNDA { + lpcs: *mut CREATESTRUCTA, + hwndInsertAfter: HWND, +}} +pub type LPCBT_CREATEWNDA = *mut CBT_CREATEWNDA; +STRUCT!{struct CBT_CREATEWNDW { + lpcs: *mut CREATESTRUCTW, + hwndInsertAfter: HWND, +}} +pub type LPCBT_CREATEWNDW = *mut CBT_CREATEWNDW; +STRUCT!{struct CBTACTIVATESTRUCT { + fMouse: BOOL, + hWndActive: HWND, +}} +pub type LPCBTACTIVATESTRUCT = *mut CBTACTIVATESTRUCT; +STRUCT!{struct WTSSESSION_NOTIFICATION { + cbSize: DWORD, + dwSessionId: DWORD, +}} +pub type PWTSSESSION_NOTIFICATION = *mut WTSSESSION_NOTIFICATION; +pub const WTS_CONSOLE_CONNECT: WPARAM = 0x1; +pub const WTS_CONSOLE_DISCONNECT: WPARAM = 0x2; +pub const WTS_REMOTE_CONNECT: WPARAM = 0x3; +pub const WTS_REMOTE_DISCONNECT: WPARAM = 0x4; +pub const WTS_SESSION_LOGON: WPARAM = 0x5; +pub const WTS_SESSION_LOGOFF: WPARAM = 0x6; +pub const WTS_SESSION_LOCK: WPARAM = 0x7; +pub const WTS_SESSION_UNLOCK: WPARAM = 0x8; +pub const WTS_SESSION_REMOTE_CONTROL: WPARAM = 0x9; +pub const WTS_SESSION_CREATE: WPARAM = 0xa; +pub const WTS_SESSION_TERMINATE: WPARAM = 0xb; +pub const MSGF_DIALOGBOX: c_int = 0; +pub const MSGF_MESSAGEBOX: c_int = 1; +pub const MSGF_MENU: c_int = 2; +pub const MSGF_SCROLLBAR: c_int = 5; +pub const MSGF_NEXTWINDOW: c_int = 6; +pub const MSGF_MAX: c_int = 8; +pub const MSGF_USER: c_int = 4096; +pub const HSHELL_WINDOWCREATED: c_int = 1; +pub const HSHELL_WINDOWDESTROYED: c_int = 2; +pub const HSHELL_ACTIVATESHELLWINDOW: c_int = 3; +pub const HSHELL_WINDOWACTIVATED: c_int = 4; +pub const HSHELL_GETMINRECT: c_int = 5; +pub const HSHELL_REDRAW: c_int = 6; +pub const HSHELL_TASKMAN: c_int = 7; +pub const HSHELL_LANGUAGE: c_int = 8; +pub const HSHELL_SYSMENU: c_int = 9; +pub const HSHELL_ENDTASK: c_int = 10; +pub const HSHELL_ACCESSIBILITYSTATE: c_int = 11; +pub const HSHELL_APPCOMMAND: c_int = 12; +pub const HSHELL_WINDOWREPLACED: c_int = 13; +pub const HSHELL_WINDOWREPLACING: c_int = 14; +pub const HSHELL_MONITORCHANGED: c_int = 16; +pub const HSHELL_HIGHBIT: c_int = 0x8000; +pub const HSHELL_FLASH: c_int = HSHELL_REDRAW | HSHELL_HIGHBIT; +pub const HSHELL_RUDEAPPACTIVATED: c_int = HSHELL_WINDOWACTIVATED | HSHELL_HIGHBIT; +pub const APPCOMMAND_BROWSER_BACKWARD: c_short = 1; +pub const APPCOMMAND_BROWSER_FORWARD: c_short = 2; +pub const APPCOMMAND_BROWSER_REFRESH: c_short = 3; +pub const APPCOMMAND_BROWSER_STOP: c_short = 4; +pub const APPCOMMAND_BROWSER_SEARCH: c_short = 5; +pub const APPCOMMAND_BROWSER_FAVORITES: c_short = 6; +pub const APPCOMMAND_BROWSER_HOME: c_short = 7; +pub const APPCOMMAND_VOLUME_MUTE: c_short = 8; +pub const APPCOMMAND_VOLUME_DOWN: c_short = 9; +pub const APPCOMMAND_VOLUME_UP: c_short = 10; +pub const APPCOMMAND_MEDIA_NEXTTRACK: c_short = 11; +pub const APPCOMMAND_MEDIA_PREVIOUSTRACK: c_short = 12; +pub const APPCOMMAND_MEDIA_STOP: c_short = 13; +pub const APPCOMMAND_MEDIA_PLAY_PAUSE: c_short = 14; +pub const APPCOMMAND_LAUNCH_MAIL: c_short = 15; +pub const APPCOMMAND_LAUNCH_MEDIA_SELECT: c_short = 16; +pub const APPCOMMAND_LAUNCH_APP1: c_short = 17; +pub const APPCOMMAND_LAUNCH_APP2: c_short = 18; +pub const APPCOMMAND_BASS_DOWN: c_short = 19; +pub const APPCOMMAND_BASS_BOOST: c_short = 20; +pub const APPCOMMAND_BASS_UP: c_short = 21; +pub const APPCOMMAND_TREBLE_DOWN: c_short = 22; +pub const APPCOMMAND_TREBLE_UP: c_short = 23; +pub const APPCOMMAND_MICROPHONE_VOLUME_MUTE: c_short = 24; +pub const APPCOMMAND_MICROPHONE_VOLUME_DOWN: c_short = 25; +pub const APPCOMMAND_MICROPHONE_VOLUME_UP: c_short = 26; +pub const APPCOMMAND_HELP: c_short = 27; +pub const APPCOMMAND_FIND: c_short = 28; +pub const APPCOMMAND_NEW: c_short = 29; +pub const APPCOMMAND_OPEN: c_short = 30; +pub const APPCOMMAND_CLOSE: c_short = 31; +pub const APPCOMMAND_SAVE: c_short = 32; +pub const APPCOMMAND_PRINT: c_short = 33; +pub const APPCOMMAND_UNDO: c_short = 34; +pub const APPCOMMAND_REDO: c_short = 35; +pub const APPCOMMAND_COPY: c_short = 36; +pub const APPCOMMAND_CUT: c_short = 37; +pub const APPCOMMAND_PASTE: c_short = 38; +pub const APPCOMMAND_REPLY_TO_MAIL: c_short = 39; +pub const APPCOMMAND_FORWARD_MAIL: c_short = 40; +pub const APPCOMMAND_SEND_MAIL: c_short = 41; +pub const APPCOMMAND_SPELL_CHECK: c_short = 42; +pub const APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE: c_short = 43; +pub const APPCOMMAND_MIC_ON_OFF_TOGGLE: c_short = 44; +pub const APPCOMMAND_CORRECTION_LIST: c_short = 45; +pub const APPCOMMAND_MEDIA_PLAY: c_short = 46; +pub const APPCOMMAND_MEDIA_PAUSE: c_short = 47; +pub const APPCOMMAND_MEDIA_RECORD: c_short = 48; +pub const APPCOMMAND_MEDIA_FAST_FORWARD: c_short = 49; +pub const APPCOMMAND_MEDIA_REWIND: c_short = 50; +pub const APPCOMMAND_MEDIA_CHANNEL_UP: c_short = 51; +pub const APPCOMMAND_MEDIA_CHANNEL_DOWN: c_short = 52; +pub const APPCOMMAND_DELETE: c_short = 53; +pub const APPCOMMAND_DWM_FLIP3D: c_short = 54; +pub const FAPPCOMMAND_MOUSE: WORD = 0x8000; +pub const FAPPCOMMAND_KEY: WORD = 0; +pub const FAPPCOMMAND_OEM: WORD = 0x1000; +pub const FAPPCOMMAND_MASK: WORD = 0xF000; +#[inline] +pub fn GET_APPCOMMAND_LPARAM(lParam: LPARAM) -> c_short { + (HIWORD(lParam as DWORD) & !FAPPCOMMAND_MASK) as c_short +} +#[inline] +pub fn GET_DEVICE_LPARAM(lParam: LPARAM) -> WORD { + HIWORD(lParam as DWORD) & FAPPCOMMAND_MASK +} +pub use self::GET_DEVICE_LPARAM as GET_MOUSEORKEY_LPARAM; +pub use shared::minwindef::LOWORD as GET_FLAGS_LPARAM; +pub use self::GET_FLAGS_LPARAM as GET_KEYSTATE_LPARAM; +STRUCT!{struct SHELLHOOKINFO { + hwnd: HWND, + rc: RECT, +}} +pub type LPSHELLHOOKINFO = *mut SHELLHOOKINFO; +STRUCT!{struct EVENTMSG { + message: UINT, + paramL: UINT, + paramH: UINT, + time: DWORD, + hwnd: HWND, +}} +pub type PEVENTMSGMSG = *mut EVENTMSG; +pub type NPEVENTMSGMSG = *mut EVENTMSG; +pub type LPEVENTMSGMSG = *mut EVENTMSG; +pub type PEVENTMSG = *mut EVENTMSG; +pub type NPEVENTMSG = *mut EVENTMSG; +pub type LPEVENTMSG = *mut EVENTMSG; +STRUCT!{struct CWPSTRUCT { + lParam: LPARAM, + wParam: WPARAM, + message: UINT, + hwnd: HWND, +}} +pub type PCWPSTRUCT = *mut CWPSTRUCT; +pub type NPCWPSTRUCT = *mut CWPSTRUCT; +pub type LPCWPSTRUCT = *mut CWPSTRUCT; +STRUCT!{struct CWPRETSTRUCT { + lResult: LRESULT, + lParam: LPARAM, + wParam: WPARAM, + message: UINT, + hwnd: HWND, +}} +pub type PCWPRETSTRUCT = *mut CWPRETSTRUCT; +pub type NPCWPRETSTRUCT = *mut CWPRETSTRUCT; +pub type LPCWPRETSTRUCT = *mut CWPRETSTRUCT; +pub const LLKHF_EXTENDED: DWORD = (KF_EXTENDED >> 8) as u32; +pub const LLKHF_INJECTED: DWORD = 0x00000010; +pub const LLKHF_ALTDOWN: DWORD = (KF_ALTDOWN >> 8) as u32; +pub const LLKHF_UP: DWORD = (KF_UP >> 8) as u32; +pub const LLKHF_LOWER_IL_INJECTED: DWORD = 0x00000002; +pub const LLMHF_INJECTED: DWORD = 0x00000001; +pub const LLMHF_LOWER_IL_INJECTED: DWORD = 0x00000002; +STRUCT!{struct KBDLLHOOKSTRUCT { + vkCode: DWORD, + scanCode: DWORD, + flags: DWORD, + time: DWORD, + dwExtraInfo: ULONG_PTR, +}} +pub type LPKBDLLHOOKSTRUCT = *mut KBDLLHOOKSTRUCT; +pub type PKBDLLHOOKSTRUCT = *mut KBDLLHOOKSTRUCT; +STRUCT!{struct MSLLHOOKSTRUCT { + pt: POINT, + mouseData: DWORD, + flags: DWORD, + time: DWORD, + dwExtraInfo: ULONG_PTR, +}} +pub type LPMSLLHOOKSTRUCT = *mut MSLLHOOKSTRUCT; +pub type PMSLLHOOKSTRUCT = *mut MSLLHOOKSTRUCT; +STRUCT!{struct DEBUGHOOKINFO { + idThread: DWORD, + idThreadInstaller: DWORD, + lParam: LPARAM, + wParam: WPARAM, + code: c_int, +}} +pub type PDEBUGHOOKINFO = *mut DEBUGHOOKINFO; +pub type NPDEBUGHOOKINFO = *mut DEBUGHOOKINFO; +pub type LPDEBUGHOOKINFO = *mut DEBUGHOOKINFO; +STRUCT!{struct MOUSEHOOKSTRUCT { + pt: POINT, + hwnd: HWND, + wHitTestCode: UINT, + dwExtraInfo: ULONG_PTR, +}} +pub type LPMOUSEHOOKSTRUCT = *mut MOUSEHOOKSTRUCT; +pub type PMOUSEHOOKSTRUCT = *mut MOUSEHOOKSTRUCT; +STRUCT!{struct MOUSEHOOKSTRUCTEX { + parent: MOUSEHOOKSTRUCT, + mouseData: DWORD, +}} +pub type LPMOUSEHOOKSTRUCTEX = *mut MOUSEHOOKSTRUCTEX; +pub type PMOUSEHOOKSTRUCTEX = *mut MOUSEHOOKSTRUCTEX; +STRUCT!{struct HARDWAREHOOKSTRUCT { + hwnd: HWND, + message: UINT, + wParam: WPARAM, + lParam: LPARAM, +}} +pub type LPHARDWAREHOOKSTRUCT = *mut HARDWAREHOOKSTRUCT; +pub type PHARDWAREHOOKSTRUCT = *mut HARDWAREHOOKSTRUCT; +pub const HKL_PREV: HKL = 0 as HKL; +pub const HKL_NEXT: HKL = 1 as HKL; +pub const KLF_ACTIVATE: UINT = 0x00000001; +pub const KLF_SUBSTITUTE_OK: UINT = 0x00000002; +pub const KLF_REORDER: UINT = 0x00000008; +pub const KLF_REPLACELANG: UINT = 0x00000010; +pub const KLF_NOTELLSHELL: UINT = 0x00000080; +pub const KLF_SETFORPROCESS: UINT = 0x00000100; +pub const KLF_SHIFTLOCK: UINT = 0x00010000; +pub const KLF_RESET: UINT = 0x40000000; +pub const INPUTLANGCHANGE_SYSCHARSET: WPARAM = 0x0001; +pub const INPUTLANGCHANGE_FORWARD: WPARAM = 0x0002; +pub const INPUTLANGCHANGE_BACKWARD: WPARAM = 0x0004; +pub const KL_NAMELENGTH: usize = 9; +extern "system" { + pub fn LoadKeyboardLayoutA( + pwszKLID: LPCSTR, + Flags: DWORD, + ) -> HKL; + pub fn LoadKeyboardLayoutW( + pwszKLID: LPCWSTR, + Flags: DWORD, + ) -> HKL; + pub fn ActivateKeyboardLayout( + hkl: HKL, + Flags: UINT, + ) -> HKL; + pub fn ToUnicodeEx( + wVirtKey: UINT, + wScanCode: UINT, + lpKeyState: *const BYTE, + pwszBuff: LPWSTR, + cchBuff: c_int, + wFlags: UINT, + dwhkl: HKL, + ) -> c_int; + pub fn UnloadKeyboardLayout( + hkl: HKL, + ) -> BOOL; + pub fn GetKeyboardLayoutNameA( + pwszKLID: LPSTR, + ) -> BOOL; + pub fn GetKeyboardLayoutNameW( + pwszKLID: LPWSTR, + ) -> BOOL; + pub fn GetKeyboardLayoutList( + nBuff: c_int, + lpList: *mut HKL, + ) -> c_int; + pub fn GetKeyboardLayout( + idThread: DWORD, + ) -> HKL; +} +STRUCT!{struct MOUSEMOVEPOINT { + x: c_int, + y: c_int, + time: DWORD, + dwExtraInfo: ULONG_PTR, +}} +pub type PMOUSEMOVEPOINT = *mut MOUSEMOVEPOINT; +pub type LPMOUSEMOVEPOINT = *mut MOUSEMOVEPOINT; +pub const GMMP_USE_DISPLAY_POINTS: DWORD = 1; +pub const GMMP_USE_HIGH_RESOLUTION_POINTS: DWORD = 2; +extern "system" { + pub fn GetMouseMovePointsEx( + cbSize: UINT, + lppt: LPMOUSEMOVEPOINT, + lpptBuf: LPMOUSEMOVEPOINT, + nBufPoints: c_int, + resolution: DWORD, + ) -> c_int; +} +pub const DESKTOP_READOBJECTS: DWORD = 0x0001; +pub const DESKTOP_CREATEWINDOW: DWORD = 0x0002; +pub const DESKTOP_CREATEMENU: DWORD = 0x0004; +pub const DESKTOP_HOOKCONTROL: DWORD = 0x0008; +pub const DESKTOP_JOURNALRECORD: DWORD = 0x0010; +pub const DESKTOP_JOURNALPLAYBACK: DWORD = 0x0020; +pub const DESKTOP_ENUMERATE: DWORD = 0x0040; +pub const DESKTOP_WRITEOBJECTS: DWORD = 0x0080; +pub const DESKTOP_SWITCHDESKTOP: DWORD = 0x0100; +pub const DF_ALLOWOTHERACCOUNTHOOK: DWORD = 0x0001; +extern "system" { + pub fn CreateDesktopA( + lpszDesktop: LPCSTR, + lpszDevice: LPCSTR, + pDevmode: *mut DEVMODEA, + dwFlags: DWORD, + dwDesiredAccess: ACCESS_MASK, + lpsa: LPSECURITY_ATTRIBUTES, + ) -> HDESK; + pub fn CreateDesktopW( + lpszDesktop: LPCWSTR, + lpszDevice: LPCWSTR, + pDevmode: *mut DEVMODEW, + dwFlags: DWORD, + dwDesiredAccess: ACCESS_MASK, + lpsa: LPSECURITY_ATTRIBUTES, + ) -> HDESK; + pub fn CreateDesktopExA( + lpszDesktop: LPCSTR, + lpszDevice: LPCSTR, + pDevmode: *mut DEVMODEA, + dwFlags: DWORD, + dwDesiredAccess: ACCESS_MASK, + lpsa: LPSECURITY_ATTRIBUTES, + ulHeapSize: ULONG, + pvoid: PVOID, + ) -> HDESK; + pub fn CreateDesktopExW( + lpszDesktop: LPCWSTR, + lpszDevice: LPCWSTR, + pDevmode: *mut DEVMODEW, + dwFlags: DWORD, + dwDesiredAccess: ACCESS_MASK, + lpsa: LPSECURITY_ATTRIBUTES, + ulHeapSize: ULONG, + pvoid: PVOID, + ) -> HDESK; + pub fn OpenDesktopA( + lpszDesktop: LPCSTR, + dwFlags: DWORD, + fInherit: BOOL, + dwDesiredAccess: ACCESS_MASK, + ) -> HDESK; + pub fn OpenDesktopW( + lpszDesktop: LPCWSTR, + dwFlags: DWORD, + fInherit: BOOL, + dwDesiredAccess: ACCESS_MASK, + ) -> HDESK; + pub fn OpenInputDesktop( + dwFlags: DWORD, + fInherit: BOOL, + dwDesiredAccess: ACCESS_MASK, + ) -> HDESK; + pub fn EnumDesktopsA( + hwinsta: HWINSTA, + lpEnumFunc: DESKTOPENUMPROCA, + lParam: LPARAM, + ) -> BOOL; + pub fn EnumDesktopsW( + hwinsta: HWINSTA, + lpEnumFunc: DESKTOPENUMPROCW, + lParam: LPARAM, + ) -> BOOL; + pub fn EnumDesktopWindows( + hDesktop: HDESK, + lpfn: WNDENUMPROC, + lParam: LPARAM, + ) -> BOOL; + pub fn SwitchDesktop( + hDesktop: HDESK, + ) -> BOOL; + pub fn SetThreadDesktop( + hDesktop: HDESK, + ) -> BOOL; + pub fn CloseDesktop( + hDesktop: HDESK, + ) -> BOOL; + pub fn GetThreadDesktop( + dwThreadId: DWORD, + ) -> HDESK; +} +pub const WINSTA_ENUMDESKTOPS: DWORD = 0x0001; +pub const WINSTA_READATTRIBUTES: DWORD = 0x0002; +pub const WINSTA_ACCESSCLIPBOARD: DWORD = 0x0004; +pub const WINSTA_CREATEDESKTOP: DWORD = 0x0008; +pub const WINSTA_WRITEATTRIBUTES: DWORD = 0x0010; +pub const WINSTA_ACCESSGLOBALATOMS: DWORD = 0x0020; +pub const WINSTA_EXITWINDOWS: DWORD = 0x0040; +pub const WINSTA_ENUMERATE: DWORD = 0x0100; +pub const WINSTA_READSCREEN: DWORD = 0x0200; +pub const WINSTA_ALL_ACCESS: DWORD = WINSTA_ENUMDESKTOPS | WINSTA_READATTRIBUTES + | WINSTA_ACCESSCLIPBOARD | WINSTA_CREATEDESKTOP | WINSTA_WRITEATTRIBUTES + | WINSTA_ACCESSGLOBALATOMS | WINSTA_EXITWINDOWS | WINSTA_ENUMERATE | WINSTA_READSCREEN; +pub const CWF_CREATE_ONLY: DWORD = 0x00000001; +pub const WSF_VISIBLE: DWORD = 0x0001; +extern "system" { + pub fn CreateWindowStationA( + lpwinsta: LPCSTR, + dwFlags: DWORD, + dwDesiredAccess: ACCESS_MASK, + lpsa: LPSECURITY_ATTRIBUTES, + ) -> HWINSTA; + pub fn CreateWindowStationW( + lpwinsta: LPCWSTR, + dwFlags: DWORD, + dwDesiredAccess: ACCESS_MASK, + lpsa: LPSECURITY_ATTRIBUTES, + ) -> HWINSTA; + pub fn OpenWindowStationA( + lpszWinSta: LPCSTR, + fInherit: BOOL, + dwDesiredAccess: ACCESS_MASK, + ) -> HWINSTA; + pub fn OpenWindowStationW( + lpszWinSta: LPCWSTR, + fInherit: BOOL, + dwDesiredAccess: ACCESS_MASK, + ) -> HWINSTA; + pub fn EnumWindowStationsA( + lpEnumFunc: WINSTAENUMPROCA, + lParam: LPARAM, + ) -> BOOL; + pub fn EnumWindowStationsW( + lpEnumFunc: WINSTAENUMPROCW, + lParam: LPARAM, + ) -> BOOL; + pub fn CloseWindowStation( + hWinSta: HWINSTA, + ) -> BOOL; + pub fn SetProcessWindowStation( + hWinSta: HWINSTA, + ) -> BOOL; + pub fn GetProcessWindowStation() -> HWINSTA; + pub fn SetUserObjectSecurity( + hObj: HANDLE, + pSIRequested: PSECURITY_INFORMATION, + pSID: PSECURITY_DESCRIPTOR, + ) -> BOOL; + pub fn GetUserObjectSecurity( + hObj: HANDLE, + pSIRequested: PSECURITY_INFORMATION, + pSID: PSECURITY_DESCRIPTOR, + nLength: DWORD, + lpnLengthNeeded: LPDWORD, + ) -> BOOL; +} +pub const UOI_FLAGS: DWORD = 1; +pub const UOI_NAME: DWORD = 2; +pub const UOI_TYPE: DWORD = 3; +pub const UOI_USER_SID: DWORD = 4; +pub const UOI_HEAPSIZE: DWORD = 5; +pub const UOI_IO: DWORD = 6; +pub const UOI_TIMERPROC_EXCEPTION_SUPPRESSION: DWORD = 7; +STRUCT!{struct USEROBJECTFLAGS { + fInherit: BOOL, + fReserved: BOOL, + dwFlags: DWORD, +}} +pub type PUSEROBJECTFLAGS = *mut USEROBJECTFLAGS; +extern "system" { + pub fn GetUserObjectInformationA( + hObj: HANDLE, + nIndex: c_int, + pvInfo: PVOID, + nLength: DWORD, + lpnLengthNeeded: LPDWORD, + ) -> BOOL; + pub fn GetUserObjectInformationW( + hObj: HANDLE, + nIndex: c_int, + pvInfo: PVOID, + nLength: DWORD, + lpnLengthNeeded: LPDWORD, + ) -> BOOL; + pub fn SetUserObjectInformationA( + hObj: HANDLE, + nIndex: c_int, + pvInfo: PVOID, + nLength: DWORD, + ) -> BOOL; + pub fn SetUserObjectInformationW( + hObj: HANDLE, + nIndex: c_int, + pvInfo: PVOID, + nLength: DWORD, + ) -> BOOL; +} +STRUCT!{struct WNDCLASSEXA { + cbSize: UINT, + style: UINT, + lpfnWndProc: WNDPROC, + cbClsExtra: c_int, + cbWndExtra: c_int, + hInstance: HINSTANCE, + hIcon: HICON, + hCursor: HCURSOR, + hbrBackground: HBRUSH, + lpszMenuName: LPCSTR, + lpszClassName: LPCSTR, + hIconSm: HICON, +}} +pub type PWNDCLASSEXA = *mut WNDCLASSEXA; +pub type NPWNDCLASSEXA = *mut WNDCLASSEXA; +pub type LPWNDCLASSEXA = *mut WNDCLASSEXA; +STRUCT!{struct WNDCLASSEXW { + cbSize: UINT, + style: UINT, + lpfnWndProc: WNDPROC, + cbClsExtra: c_int, + cbWndExtra: c_int, + hInstance: HINSTANCE, + hIcon: HICON, + hCursor: HCURSOR, + hbrBackground: HBRUSH, + lpszMenuName: LPCWSTR, + lpszClassName: LPCWSTR, + hIconSm: HICON, +}} +pub type PWNDCLASSEXW = *mut WNDCLASSEXW; +pub type NPWNDCLASSEXW = *mut WNDCLASSEXW; +pub type LPWNDCLASSEXW = *mut WNDCLASSEXW; +STRUCT!{struct WNDCLASSA { + style: UINT, + lpfnWndProc: WNDPROC, + cbClsExtra: c_int, + cbWndExtra: c_int, + hInstance: HINSTANCE, + hIcon: HICON, + hCursor: HCURSOR, + hbrBackground: HBRUSH, + lpszMenuName: LPCSTR, + lpszClassName: LPCSTR, +}} +pub type PWNDCLASSA = *mut WNDCLASSA; +pub type NPWNDCLASSA = *mut WNDCLASSA; +pub type LPWNDCLASSA = *mut WNDCLASSA; +STRUCT!{struct WNDCLASSW { + style: UINT, + lpfnWndProc: WNDPROC, + cbClsExtra: c_int, + cbWndExtra: c_int, + hInstance: HINSTANCE, + hIcon: HICON, + hCursor: HCURSOR, + hbrBackground: HBRUSH, + lpszMenuName: LPCWSTR, + lpszClassName: LPCWSTR, +}} +pub type PWNDCLASSW = *mut WNDCLASSW; +pub type NPWNDCLASSW = *mut WNDCLASSW; +pub type LPWNDCLASSW = *mut WNDCLASSW; +extern "system" { + pub fn IsHungAppWindow( + hwnd: HWND, + ) -> BOOL; + pub fn DisableProcessWindowsGhosting(); +} +STRUCT!{struct MSG { + hwnd: HWND, + message: UINT, + wParam: WPARAM, + lParam: LPARAM, + time: DWORD, + pt: POINT, +}} +pub type PMSG = *mut MSG; +pub type NPMSG = *mut MSG; +pub type LPMSG = *mut MSG; +//POINTSTOPOINT +//POINTTOPOINTS +//MAKEWPARAM +//MAKELPARAM +//MAKELRESULT +pub const GWL_WNDPROC: c_int = -4; +pub const GWL_HINSTANCE: c_int = -6; +pub const GWL_HWNDPARENT: c_int = -8; +pub const GWL_STYLE: c_int = -16; +pub const GWL_EXSTYLE: c_int = -20; +pub const GWL_USERDATA: c_int = -21; +pub const GWL_ID: c_int = -12; +pub const GWLP_WNDPROC: c_int = -4; +pub const GWLP_HINSTANCE: c_int = -6; +pub const GWLP_HWNDPARENT: c_int = -8; +pub const GWLP_USERDATA: c_int = -21; +pub const GWLP_ID: c_int = -12; +pub const GCL_MENUNAME: c_int = -8; +pub const GCL_HBRBACKGROUND: c_int = -10; +pub const GCL_HCURSOR: c_int = -12; +pub const GCL_HICON: c_int = -14; +pub const GCL_HMODULE: c_int = -16; +pub const GCL_CBWNDEXTRA: c_int = -18; +pub const GCL_CBCLSEXTRA: c_int = -20; +pub const GCL_WNDPROC: c_int = -24; +pub const GCL_STYLE: c_int = -26; +pub const GCW_ATOM: c_int = -32; +pub const GCL_HICONSM: c_int = -34; +pub const GCLP_MENUNAME: c_int = -8; +pub const GCLP_HBRBACKGROUND: c_int = -10; +pub const GCLP_HCURSOR: c_int = -12; +pub const GCLP_HICON: c_int = -14; +pub const GCLP_HMODULE: c_int = -16; +pub const GCLP_WNDPROC: c_int = -24; +pub const GCLP_HICONSM: c_int = -34; +pub const WM_NULL: UINT = 0x0000; +pub const WM_CREATE: UINT = 0x0001; +pub const WM_DESTROY: UINT = 0x0002; +pub const WM_MOVE: UINT = 0x0003; +pub const WM_SIZE: UINT = 0x0005; +pub const WM_ACTIVATE: UINT = 0x0006; +pub const WA_INACTIVE: WORD = 0; +pub const WA_ACTIVE: WORD = 1; +pub const WA_CLICKACTIVE: WORD = 2; +pub const WM_SETFOCUS: UINT = 0x0007; +pub const WM_KILLFOCUS: UINT = 0x0008; +pub const WM_ENABLE: UINT = 0x000A; +pub const WM_SETREDRAW: UINT = 0x000B; +pub const WM_SETTEXT: UINT = 0x000C; +pub const WM_GETTEXT: UINT = 0x000D; +pub const WM_GETTEXTLENGTH: UINT = 0x000E; +pub const WM_PAINT: UINT = 0x000F; +pub const WM_CLOSE: UINT = 0x0010; +pub const WM_QUERYENDSESSION: UINT = 0x0011; +pub const WM_QUERYOPEN: UINT = 0x0013; +pub const WM_ENDSESSION: UINT = 0x0016; +pub const WM_QUIT: UINT = 0x0012; +pub const WM_ERASEBKGND: UINT = 0x0014; +pub const WM_SYSCOLORCHANGE: UINT = 0x0015; +pub const WM_SHOWWINDOW: UINT = 0x0018; +pub const WM_WININICHANGE: UINT = 0x001A; +pub const WM_SETTINGCHANGE: UINT = WM_WININICHANGE; +pub const WM_DEVMODECHANGE: UINT = 0x001B; +pub const WM_ACTIVATEAPP: UINT = 0x001C; +pub const WM_FONTCHANGE: UINT = 0x001D; +pub const WM_TIMECHANGE: UINT = 0x001E; +pub const WM_CANCELMODE: UINT = 0x001F; +pub const WM_SETCURSOR: UINT = 0x0020; +pub const WM_MOUSEACTIVATE: UINT = 0x0021; +pub const WM_CHILDACTIVATE: UINT = 0x0022; +pub const WM_QUEUESYNC: UINT = 0x0023; +pub const WM_GETMINMAXINFO: UINT = 0x0024; +STRUCT!{struct MINMAXINFO { + ptReserved: POINT, + ptMaxSize: POINT, + ptMaxPosition: POINT, + ptMinTrackSize: POINT, + ptMaxTrackSize: POINT, +}} +pub type PMINMAXINFO = *mut MINMAXINFO; +pub type LPMINMAXINFO = *mut MINMAXINFO; +pub const WM_PAINTICON: UINT = 0x0026; +pub const WM_ICONERASEBKGND: UINT = 0x0027; +pub const WM_NEXTDLGCTL: UINT = 0x0028; +pub const WM_SPOOLERSTATUS: UINT = 0x002A; +pub const WM_DRAWITEM: UINT = 0x002B; +pub const WM_MEASUREITEM: UINT = 0x002C; +pub const WM_DELETEITEM: UINT = 0x002D; +pub const WM_VKEYTOITEM: UINT = 0x002E; +pub const WM_CHARTOITEM: UINT = 0x002F; +pub const WM_SETFONT: UINT = 0x0030; +pub const WM_GETFONT: UINT = 0x0031; +pub const WM_SETHOTKEY: UINT = 0x0032; +pub const WM_GETHOTKEY: UINT = 0x0033; +pub const WM_QUERYDRAGICON: UINT = 0x0037; +pub const WM_COMPAREITEM: UINT = 0x0039; +pub const WM_GETOBJECT: UINT = 0x003D; +pub const WM_COMPACTING: UINT = 0x0041; +pub const WM_COMMNOTIFY: UINT = 0x0044; +pub const WM_WINDOWPOSCHANGING: UINT = 0x0046; +pub const WM_WINDOWPOSCHANGED: UINT = 0x0047; +pub const WM_POWER: UINT = 0x0048; +pub const PWR_OK: WPARAM = 1; +pub const PWR_FAIL: WPARAM = -1isize as usize; +pub const PWR_SUSPENDREQUEST: WPARAM = 1; +pub const PWR_SUSPENDRESUME: WPARAM = 2; +pub const PWR_CRITICALRESUME: WPARAM = 3; +pub const WM_COPYDATA: UINT = 0x004A; +pub const WM_CANCELJOURNAL: UINT = 0x004B; +STRUCT!{struct COPYDATASTRUCT { + dwData: ULONG_PTR, + cbData: DWORD, + lpData: PVOID, +}} +pub type PCOPYDATASTRUCT = *mut COPYDATASTRUCT; +STRUCT!{struct MDINEXTMENU { + hmenuIn: HMENU, + hmenuNext: HMENU, + hwndNext: HWND, +}} +pub type PMDINEXTMENU = *mut MDINEXTMENU; +pub type LPMDINEXTMENU = *mut MDINEXTMENU; +pub const WM_NOTIFY: UINT = 0x004E; +pub const WM_INPUTLANGCHANGEREQUEST: UINT = 0x0050; +pub const WM_INPUTLANGCHANGE: UINT = 0x0051; +pub const WM_TCARD: UINT = 0x0052; +pub const WM_HELP: UINT = 0x0053; +pub const WM_USERCHANGED: UINT = 0x0054; +pub const WM_NOTIFYFORMAT: UINT = 0x0055; +pub const NFR_ANSI: LRESULT = 1; +pub const NFR_UNICODE: LRESULT = 2; +pub const NF_QUERY: LPARAM = 3; +pub const NF_REQUERY: LPARAM = 4; +pub const WM_CONTEXTMENU: UINT = 0x007B; +pub const WM_STYLECHANGING: UINT = 0x007C; +pub const WM_STYLECHANGED: UINT = 0x007D; +pub const WM_DISPLAYCHANGE: UINT = 0x007E; +pub const WM_GETICON: UINT = 0x007F; +pub const WM_SETICON: UINT = 0x0080; +pub const WM_NCCREATE: UINT = 0x0081; +pub const WM_NCDESTROY: UINT = 0x0082; +pub const WM_NCCALCSIZE: UINT = 0x0083; +pub const WM_NCHITTEST: UINT = 0x0084; +pub const WM_NCPAINT: UINT = 0x0085; +pub const WM_NCACTIVATE: UINT = 0x0086; +pub const WM_GETDLGCODE: UINT = 0x0087; +pub const WM_SYNCPAINT: UINT = 0x0088; +pub const WM_NCMOUSEMOVE: UINT = 0x00A0; +pub const WM_NCLBUTTONDOWN: UINT = 0x00A1; +pub const WM_NCLBUTTONUP: UINT = 0x00A2; +pub const WM_NCLBUTTONDBLCLK: UINT = 0x00A3; +pub const WM_NCRBUTTONDOWN: UINT = 0x00A4; +pub const WM_NCRBUTTONUP: UINT = 0x00A5; +pub const WM_NCRBUTTONDBLCLK: UINT = 0x00A6; +pub const WM_NCMBUTTONDOWN: UINT = 0x00A7; +pub const WM_NCMBUTTONUP: UINT = 0x00A8; +pub const WM_NCMBUTTONDBLCLK: UINT = 0x00A9; +pub const WM_NCXBUTTONDOWN: UINT = 0x00AB; +pub const WM_NCXBUTTONUP: UINT = 0x00AC; +pub const WM_NCXBUTTONDBLCLK: UINT = 0x00AD; +pub const WM_INPUT_DEVICE_CHANGE: UINT = 0x00FE; +pub const WM_INPUT: UINT = 0x00FF; +pub const WM_KEYFIRST: UINT = 0x0100; +pub const WM_KEYDOWN: UINT = 0x0100; +pub const WM_KEYUP: UINT = 0x0101; +pub const WM_CHAR: UINT = 0x0102; +pub const WM_DEADCHAR: UINT = 0x0103; +pub const WM_SYSKEYDOWN: UINT = 0x0104; +pub const WM_SYSKEYUP: UINT = 0x0105; +pub const WM_SYSCHAR: UINT = 0x0106; +pub const WM_SYSDEADCHAR: UINT = 0x0107; +pub const WM_UNICHAR: UINT = 0x0109; +pub const WM_KEYLAST: UINT = 0x0109; +pub const UNICODE_NOCHAR: WPARAM = 0xFFFF; +pub const WM_IME_STARTCOMPOSITION: UINT = 0x010D; +pub const WM_IME_ENDCOMPOSITION: UINT = 0x010E; +pub const WM_IME_COMPOSITION: UINT = 0x010F; +pub const WM_IME_KEYLAST: UINT = 0x010F; +pub const WM_INITDIALOG: UINT = 0x0110; +pub const WM_COMMAND: UINT = 0x0111; +pub const WM_SYSCOMMAND: UINT = 0x0112; +pub const WM_TIMER: UINT = 0x0113; +pub const WM_HSCROLL: UINT = 0x0114; +pub const WM_VSCROLL: UINT = 0x0115; +pub const WM_INITMENU: UINT = 0x0116; +pub const WM_INITMENUPOPUP: UINT = 0x0117; +pub const WM_GESTURE: UINT = 0x0119; +pub const WM_GESTURENOTIFY: UINT = 0x011A; +pub const WM_MENUSELECT: UINT = 0x011F; +pub const WM_MENUCHAR: UINT = 0x0120; +pub const WM_ENTERIDLE: UINT = 0x0121; +pub const WM_MENURBUTTONUP: UINT = 0x0122; +pub const WM_MENUDRAG: UINT = 0x0123; +pub const WM_MENUGETOBJECT: UINT = 0x0124; +pub const WM_UNINITMENUPOPUP: UINT = 0x0125; +pub const WM_MENUCOMMAND: UINT = 0x0126; +pub const WM_CHANGEUISTATE: UINT = 0x0127; +pub const WM_UPDATEUISTATE: UINT = 0x0128; +pub const WM_QUERYUISTATE: UINT = 0x0129; +pub const UIS_SET: WORD = 1; +pub const UIS_CLEAR: WORD = 2; +pub const UIS_INITIALIZE: WORD = 3; +pub const UISF_HIDEFOCUS: WORD = 0x1; +pub const UISF_HIDEACCEL: WORD = 0x2; +pub const UISF_ACTIVE: WORD = 0x4; +pub const WM_CTLCOLORMSGBOX: UINT = 0x0132; +pub const WM_CTLCOLOREDIT: UINT = 0x0133; +pub const WM_CTLCOLORLISTBOX: UINT = 0x0134; +pub const WM_CTLCOLORBTN: UINT = 0x0135; +pub const WM_CTLCOLORDLG: UINT = 0x0136; +pub const WM_CTLCOLORSCROLLBAR: UINT = 0x0137; +pub const WM_CTLCOLORSTATIC: UINT = 0x0138; +pub const MN_GETHMENU: UINT = 0x01E1; +pub const WM_MOUSEFIRST: UINT = 0x0200; +pub const WM_MOUSEMOVE: UINT = 0x0200; +pub const WM_LBUTTONDOWN: UINT = 0x0201; +pub const WM_LBUTTONUP: UINT = 0x0202; +pub const WM_LBUTTONDBLCLK: UINT = 0x0203; +pub const WM_RBUTTONDOWN: UINT = 0x0204; +pub const WM_RBUTTONUP: UINT = 0x0205; +pub const WM_RBUTTONDBLCLK: UINT = 0x0206; +pub const WM_MBUTTONDOWN: UINT = 0x0207; +pub const WM_MBUTTONUP: UINT = 0x0208; +pub const WM_MBUTTONDBLCLK: UINT = 0x0209; +pub const WM_MOUSEWHEEL: UINT = 0x020A; +pub const WM_XBUTTONDOWN: UINT = 0x020B; +pub const WM_XBUTTONUP: UINT = 0x020C; +pub const WM_XBUTTONDBLCLK: UINT = 0x020D; +pub const WM_MOUSEHWHEEL: UINT = 0x020E; +pub const WM_MOUSELAST: UINT = 0x020E; +pub const WHEEL_DELTA: c_short = 120; +#[inline] +pub fn GET_WHEEL_DELTA_WPARAM(wParam: WPARAM) -> c_short { + HIWORD(wParam as DWORD) as c_short +} +pub const WHEEL_PAGESCROLL: UINT = UINT_MAX; +#[inline] +pub fn GET_KEYSTATE_WPARAM(wParam: WPARAM) -> WORD { + LOWORD(wParam as DWORD) +} +#[inline] +pub fn GET_NCHITTEST_WPARAM(wParam: WPARAM) -> c_short { + LOWORD(wParam as DWORD) as c_short +} +#[inline] +pub fn GET_XBUTTON_WPARAM(wParam: WPARAM) -> WORD { + HIWORD(wParam as DWORD) +} +pub const XBUTTON1: WORD = 0x0001; +pub const XBUTTON2: WORD = 0x0002; +pub const WM_PARENTNOTIFY: UINT = 0x0210; +pub const WM_ENTERMENULOOP: UINT = 0x0211; +pub const WM_EXITMENULOOP: UINT = 0x0212; +pub const WM_NEXTMENU: UINT = 0x0213; +pub const WM_SIZING: UINT = 0x0214; +pub const WM_CAPTURECHANGED: UINT = 0x0215; +pub const WM_MOVING: UINT = 0x0216; +pub const WM_POWERBROADCAST: UINT = 0x0218; +pub const PBT_APMQUERYSUSPEND: WPARAM = 0x0000; +pub const PBT_APMQUERYSTANDBY: WPARAM = 0x0001; +pub const PBT_APMQUERYSUSPENDFAILED: WPARAM = 0x0002; +pub const PBT_APMQUERYSTANDBYFAILED: WPARAM = 0x0003; +pub const PBT_APMSUSPEND: WPARAM = 0x0004; +pub const PBT_APMSTANDBY: WPARAM = 0x0005; +pub const PBT_APMRESUMECRITICAL: WPARAM = 0x0006; +pub const PBT_APMRESUMESUSPEND: WPARAM = 0x0007; +pub const PBT_APMRESUMESTANDBY: WPARAM = 0x0008; +pub const PBTF_APMRESUMEFROMFAILURE: LPARAM = 0x00000001; +pub const PBT_APMBATTERYLOW: WPARAM = 0x0009; +pub const PBT_APMPOWERSTATUSCHANGE: WPARAM = 0x000A; +pub const PBT_APMOEMEVENT: WPARAM = 0x000B; +pub const PBT_APMRESUMEAUTOMATIC: WPARAM = 0x0012; +pub const PBT_POWERSETTINGCHANGE: WPARAM = 0x8013; +STRUCT!{struct POWERBROADCAST_SETTING { + PowerSetting: GUID, + DataLength: DWORD, + Data: [UCHAR; 1], +}} +pub type PPOWERBROADCAST_SETTING = *mut POWERBROADCAST_SETTING; +pub const WM_DEVICECHANGE: UINT = 0x0219; +pub const WM_MDICREATE: UINT = 0x0220; +pub const WM_MDIDESTROY: UINT = 0x0221; +pub const WM_MDIACTIVATE: UINT = 0x0222; +pub const WM_MDIRESTORE: UINT = 0x0223; +pub const WM_MDINEXT: UINT = 0x0224; +pub const WM_MDIMAXIMIZE: UINT = 0x0225; +pub const WM_MDITILE: UINT = 0x0226; +pub const WM_MDICASCADE: UINT = 0x0227; +pub const WM_MDIICONARRANGE: UINT = 0x0228; +pub const WM_MDIGETACTIVE: UINT = 0x0229; +pub const WM_MDISETMENU: UINT = 0x0230; +pub const WM_ENTERSIZEMOVE: UINT = 0x0231; +pub const WM_EXITSIZEMOVE: UINT = 0x0232; +pub const WM_DROPFILES: UINT = 0x0233; +pub const WM_MDIREFRESHMENU: UINT = 0x0234; +pub const WM_POINTERDEVICECHANGE: UINT = 0x238; +pub const WM_POINTERDEVICEINRANGE: UINT = 0x239; +pub const WM_POINTERDEVICEOUTOFRANGE: UINT = 0x23A; +pub const WM_TOUCH: UINT = 0x0240; +pub const WM_NCPOINTERUPDATE: UINT = 0x0241; +pub const WM_NCPOINTERDOWN: UINT = 0x0242; +pub const WM_NCPOINTERUP: UINT = 0x0243; +pub const WM_POINTERUPDATE: UINT = 0x0245; +pub const WM_POINTERDOWN: UINT = 0x0246; +pub const WM_POINTERUP: UINT = 0x0247; +pub const WM_POINTERENTER: UINT = 0x0249; +pub const WM_POINTERLEAVE: UINT = 0x024A; +pub const WM_POINTERACTIVATE: UINT = 0x024B; +pub const WM_POINTERCAPTURECHANGED: UINT = 0x024C; +pub const WM_TOUCHHITTESTING: UINT = 0x024D; +pub const WM_POINTERWHEEL: UINT = 0x024E; +pub const WM_POINTERHWHEEL: UINT = 0x024F; +pub const DM_POINTERHITTEST: UINT = 0x0250; +pub const WM_POINTERROUTEDTO: UINT = 0x0251; +pub const WM_POINTERROUTEDAWAY: UINT = 0x0252; +pub const WM_POINTERROUTEDRELEASED: UINT = 0x0253; +pub const WM_IME_SETCONTEXT: UINT = 0x0281; +pub const WM_IME_NOTIFY: UINT = 0x0282; +pub const WM_IME_CONTROL: UINT = 0x0283; +pub const WM_IME_COMPOSITIONFULL: UINT = 0x0284; +pub const WM_IME_SELECT: UINT = 0x0285; +pub const WM_IME_CHAR: UINT = 0x0286; +pub const WM_IME_REQUEST: UINT = 0x0288; +pub const WM_IME_KEYDOWN: UINT = 0x0290; +pub const WM_IME_KEYUP: UINT = 0x0291; +pub const WM_MOUSEHOVER: UINT = 0x02A1; +pub const WM_MOUSELEAVE: UINT = 0x02A3; +pub const WM_NCMOUSEHOVER: UINT = 0x02A0; +pub const WM_NCMOUSELEAVE: UINT = 0x02A2; +pub const WM_WTSSESSION_CHANGE: UINT = 0x02B1; +pub const WM_TABLET_FIRST: UINT = 0x02c0; +pub const WM_TABLET_LAST: UINT = 0x02df; +pub const WM_DPICHANGED: UINT = 0x02E0; +pub const WM_DPICHANGED_BEFOREPARENT: UINT = 0x02E2; +pub const WM_DPICHANGED_AFTERPARENT: UINT = 0x02E3; +pub const WM_GETDPISCALEDSIZE: UINT = 0x02E4; +pub const WM_CUT: UINT = 0x0300; +pub const WM_COPY: UINT = 0x0301; +pub const WM_PASTE: UINT = 0x0302; +pub const WM_CLEAR: UINT = 0x0303; +pub const WM_UNDO: UINT = 0x0304; +pub const WM_RENDERFORMAT: UINT = 0x0305; +pub const WM_RENDERALLFORMATS: UINT = 0x0306; +pub const WM_DESTROYCLIPBOARD: UINT = 0x0307; +pub const WM_DRAWCLIPBOARD: UINT = 0x0308; +pub const WM_PAINTCLIPBOARD: UINT = 0x0309; +pub const WM_VSCROLLCLIPBOARD: UINT = 0x030A; +pub const WM_SIZECLIPBOARD: UINT = 0x030B; +pub const WM_ASKCBFORMATNAME: UINT = 0x030C; +pub const WM_CHANGECBCHAIN: UINT = 0x030D; +pub const WM_HSCROLLCLIPBOARD: UINT = 0x030E; +pub const WM_QUERYNEWPALETTE: UINT = 0x030F; +pub const WM_PALETTEISCHANGING: UINT = 0x0310; +pub const WM_PALETTECHANGED: UINT = 0x0311; +pub const WM_HOTKEY: UINT = 0x0312; +pub const WM_PRINT: UINT = 0x0317; +pub const WM_PRINTCLIENT: UINT = 0x0318; +pub const WM_APPCOMMAND: UINT = 0x0319; +pub const WM_THEMECHANGED: UINT = 0x031A; +pub const WM_CLIPBOARDUPDATE: UINT = 0x031D; +pub const WM_DWMCOMPOSITIONCHANGED: UINT = 0x031E; +pub const WM_DWMNCRENDERINGCHANGED: UINT = 0x031F; +pub const WM_DWMCOLORIZATIONCOLORCHANGED: UINT = 0x0320; +pub const WM_DWMWINDOWMAXIMIZEDCHANGE: UINT = 0x0321; +pub const WM_DWMSENDICONICTHUMBNAIL: UINT = 0x0323; +pub const WM_DWMSENDICONICLIVEPREVIEWBITMAP: UINT = 0x0326; +pub const WM_GETTITLEBARINFOEX: UINT = 0x033F; +pub const WM_HANDHELDFIRST: UINT = 0x0358; +pub const WM_HANDHELDLAST: UINT = 0x035F; +pub const WM_AFXFIRST: UINT = 0x0360; +pub const WM_AFXLAST: UINT = 0x037F; +pub const WM_PENWINFIRST: UINT = 0x0380; +pub const WM_PENWINLAST: UINT = 0x038F; +pub const WM_APP: UINT = 0x8000; +pub const WM_USER: UINT = 0x0400; +pub const WMSZ_LEFT: UINT = 1; +pub const WMSZ_RIGHT: UINT = 2; +pub const WMSZ_TOP: UINT = 3; +pub const WMSZ_TOPLEFT: UINT = 4; +pub const WMSZ_TOPRIGHT: UINT = 5; +pub const WMSZ_BOTTOM: UINT = 6; +pub const WMSZ_BOTTOMLEFT: UINT = 7; +pub const WMSZ_BOTTOMRIGHT: UINT = 8; +pub const HTERROR: LRESULT = (-2); +pub const HTTRANSPARENT: LRESULT = (-1); +pub const HTNOWHERE: LRESULT = 0; +pub const HTCLIENT: LRESULT = 1; +pub const HTCAPTION: LRESULT = 2; +pub const HTSYSMENU: LRESULT = 3; +pub const HTGROWBOX: LRESULT = 4; +pub const HTSIZE: LRESULT = HTGROWBOX; +pub const HTMENU: LRESULT = 5; +pub const HTHSCROLL: LRESULT = 6; +pub const HTVSCROLL: LRESULT = 7; +pub const HTMINBUTTON: LRESULT = 8; +pub const HTMAXBUTTON: LRESULT = 9; +pub const HTLEFT: LRESULT = 10; +pub const HTRIGHT: LRESULT = 11; +pub const HTTOP: LRESULT = 12; +pub const HTTOPLEFT: LRESULT = 13; +pub const HTTOPRIGHT: LRESULT = 14; +pub const HTBOTTOM: LRESULT = 15; +pub const HTBOTTOMLEFT: LRESULT = 16; +pub const HTBOTTOMRIGHT: LRESULT = 17; +pub const HTBORDER: LRESULT = 18; +pub const HTREDUCE: LRESULT = HTMINBUTTON; +pub const HTZOOM: LRESULT = HTMAXBUTTON; +pub const HTSIZEFIRST: LRESULT = HTLEFT; +pub const HTSIZELAST: LRESULT = HTBOTTOMRIGHT; +pub const HTOBJECT: LRESULT = 19; +pub const HTCLOSE: LRESULT = 20; +pub const HTHELP: LRESULT = 21; +pub const SMTO_NORMAL: UINT = 0x0000; +pub const SMTO_BLOCK: UINT = 0x0001; +pub const SMTO_ABORTIFHUNG: UINT = 0x0002; +pub const SMTO_NOTIMEOUTIFNOTHUNG: UINT = 0x0008; +pub const SMTO_ERRORONEXIT: UINT = 0x0020; +pub const MA_ACTIVATE: UINT = 1; +pub const MA_ACTIVATEANDEAT: UINT = 2; +pub const MA_NOACTIVATE: UINT = 3; +pub const MA_NOACTIVATEANDEAT: UINT = 4; +pub const ICON_SMALL: UINT = 0; +pub const ICON_BIG: UINT = 1; +pub const ICON_SMALL2: UINT = 2; +extern "system" { + pub fn RegisterWindowMessageA( + lpString: LPCSTR, + ) -> UINT; + pub fn RegisterWindowMessageW( + lpString: LPCWSTR, + ) -> UINT; +} +pub const SIZE_RESTORED: WPARAM = 0; +pub const SIZE_MINIMIZED: WPARAM = 1; +pub const SIZE_MAXIMIZED: WPARAM = 2; +pub const SIZE_MAXSHOW: WPARAM = 3; +pub const SIZE_MAXHIDE: WPARAM = 4; +pub const SIZENORMAL: WPARAM = SIZE_RESTORED; +pub const SIZEICONIC: WPARAM = SIZE_MINIMIZED; +pub const SIZEFULLSCREEN: WPARAM = SIZE_MAXIMIZED; +pub const SIZEZOOMSHOW: WPARAM = SIZE_MAXSHOW; +pub const SIZEZOOMHIDE: WPARAM = SIZE_MAXHIDE; +STRUCT!{struct WINDOWPOS { + hwnd: HWND, + hwndInsertAfter: HWND, + x: c_int, + y: c_int, + cx: c_int, + cy: c_int, + flags: UINT, +}} +pub type LPWINDOWPOS = *mut WINDOWPOS; +pub type PWINDOWPOS = *mut WINDOWPOS; +STRUCT!{struct NCCALCSIZE_PARAMS { + rgrc: [RECT; 3], + lppos: PWINDOWPOS, +}} +pub type LPNCCALCSIZE_PARAMS = *mut NCCALCSIZE_PARAMS; +pub const WVR_ALIGNTOP: LRESULT = 0x0010; +pub const WVR_ALIGNLEFT: LRESULT = 0x0020; +pub const WVR_ALIGNBOTTOM: LRESULT = 0x0040; +pub const WVR_ALIGNRIGHT: LRESULT = 0x0080; +pub const WVR_HREDRAW: LRESULT = 0x0100; +pub const WVR_VREDRAW: LRESULT = 0x0200; +pub const WVR_REDRAW: LRESULT = WVR_HREDRAW | WVR_VREDRAW; +pub const WVR_VALIDRECTS: LRESULT = 0x0400; +pub const MK_LBUTTON: WPARAM = 0x0001; +pub const MK_RBUTTON: WPARAM = 0x0002; +pub const MK_SHIFT: WPARAM = 0x0004; +pub const MK_CONTROL: WPARAM = 0x0008; +pub const MK_MBUTTON: WPARAM = 0x0010; +pub const MK_XBUTTON1: WPARAM = 0x0020; +pub const MK_XBUTTON2: WPARAM = 0x0040; +pub const TME_HOVER: DWORD = 0x00000001; +pub const TME_LEAVE: DWORD = 0x00000002; +pub const TME_NONCLIENT: DWORD = 0x00000010; +pub const TME_QUERY: DWORD = 0x40000000; +pub const TME_CANCEL: DWORD = 0x80000000; +pub const HOVER_DEFAULT: DWORD = 0xFFFFFFFF; +STRUCT!{struct TRACKMOUSEEVENT { + cbSize: DWORD, + dwFlags: DWORD, + hwndTrack: HWND, + dwHoverTime: DWORD, +}} +pub type LPTRACKMOUSEEVENT = *mut TRACKMOUSEEVENT; +extern "system" { + pub fn TrackMouseEvent( + lpEventTrack: LPTRACKMOUSEEVENT, + ) -> BOOL; +} +pub const WS_OVERLAPPED: DWORD = 0x00000000; +pub const WS_POPUP: DWORD = 0x80000000; +pub const WS_CHILD: DWORD = 0x40000000; +pub const WS_MINIMIZE: DWORD = 0x20000000; +pub const WS_VISIBLE: DWORD = 0x10000000; +pub const WS_DISABLED: DWORD = 0x08000000; +pub const WS_CLIPSIBLINGS: DWORD = 0x04000000; +pub const WS_CLIPCHILDREN: DWORD = 0x02000000; +pub const WS_MAXIMIZE: DWORD = 0x01000000; +pub const WS_CAPTION: DWORD = 0x00C00000; +pub const WS_BORDER: DWORD = 0x00800000; +pub const WS_DLGFRAME: DWORD = 0x00400000; +pub const WS_VSCROLL: DWORD = 0x00200000; +pub const WS_HSCROLL: DWORD = 0x00100000; +pub const WS_SYSMENU: DWORD = 0x00080000; +pub const WS_THICKFRAME: DWORD = 0x00040000; +pub const WS_GROUP: DWORD = 0x00020000; +pub const WS_TABSTOP: DWORD = 0x00010000; +pub const WS_MINIMIZEBOX: DWORD = 0x00020000; +pub const WS_MAXIMIZEBOX: DWORD = 0x00010000; +pub const WS_TILED: DWORD = WS_OVERLAPPED; +pub const WS_ICONIC: DWORD = WS_MINIMIZE; +pub const WS_SIZEBOX: DWORD = WS_THICKFRAME; +pub const WS_TILEDWINDOW: DWORD = WS_OVERLAPPEDWINDOW; +pub const WS_OVERLAPPEDWINDOW: DWORD = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME + | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; +pub const WS_POPUPWINDOW: DWORD = WS_POPUP | WS_BORDER | WS_SYSMENU; +pub const WS_CHILDWINDOW: DWORD = WS_CHILD; +pub const WS_EX_DLGMODALFRAME: DWORD = 0x00000001; +pub const WS_EX_NOPARENTNOTIFY: DWORD = 0x00000004; +pub const WS_EX_TOPMOST: DWORD = 0x00000008; +pub const WS_EX_ACCEPTFILES: DWORD = 0x00000010; +pub const WS_EX_TRANSPARENT: DWORD = 0x00000020; +pub const WS_EX_MDICHILD: DWORD = 0x00000040; +pub const WS_EX_TOOLWINDOW: DWORD = 0x00000080; +pub const WS_EX_WINDOWEDGE: DWORD = 0x00000100; +pub const WS_EX_CLIENTEDGE: DWORD = 0x00000200; +pub const WS_EX_CONTEXTHELP: DWORD = 0x00000400; +pub const WS_EX_RIGHT: DWORD = 0x00001000; +pub const WS_EX_LEFT: DWORD = 0x00000000; +pub const WS_EX_RTLREADING: DWORD = 0x00002000; +pub const WS_EX_LTRREADING: DWORD = 0x00000000; +pub const WS_EX_LEFTSCROLLBAR: DWORD = 0x00004000; +pub const WS_EX_RIGHTSCROLLBAR: DWORD = 0x00000000; +pub const WS_EX_CONTROLPARENT: DWORD = 0x00010000; +pub const WS_EX_STATICEDGE: DWORD = 0x00020000; +pub const WS_EX_APPWINDOW: DWORD = 0x00040000; +pub const WS_EX_OVERLAPPEDWINDOW: DWORD = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE; +pub const WS_EX_PALETTEWINDOW: DWORD = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST; +pub const WS_EX_LAYERED: DWORD = 0x00080000; +pub const WS_EX_NOINHERITLAYOUT: DWORD = 0x00100000; +pub const WS_EX_NOREDIRECTIONBITMAP: DWORD = 0x00200000; +pub const WS_EX_LAYOUTRTL: DWORD = 0x00400000; +pub const WS_EX_COMPOSITED: DWORD = 0x02000000; +pub const WS_EX_NOACTIVATE: DWORD = 0x08000000; +pub const CS_VREDRAW: UINT = 0x0001; +pub const CS_HREDRAW: UINT = 0x0002; +pub const CS_DBLCLKS: UINT = 0x0008; +pub const CS_OWNDC: UINT = 0x0020; +pub const CS_CLASSDC: UINT = 0x0040; +pub const CS_PARENTDC: UINT = 0x0080; +pub const CS_NOCLOSE: UINT = 0x0200; +pub const CS_SAVEBITS: UINT = 0x0800; +pub const CS_BYTEALIGNCLIENT: UINT = 0x1000; +pub const CS_BYTEALIGNWINDOW: UINT = 0x2000; +pub const CS_GLOBALCLASS: UINT = 0x4000; +pub const CS_IME: UINT = 0x00010000; +pub const CS_DROPSHADOW: UINT = 0x00020000; +pub const PRF_CHECKVISIBLE: UINT = 0x00000001; +pub const PRF_NONCLIENT: UINT = 0x00000002; +pub const PRF_CLIENT: UINT = 0x00000004; +pub const PRF_ERASEBKGND: UINT = 0x00000008; +pub const PRF_CHILDREN: UINT = 0x00000010; +pub const PRF_OWNED: UINT = 0x00000020; +pub const BDR_RAISEDOUTER: UINT = 0x0001; +pub const BDR_SUNKENOUTER: UINT = 0x0002; +pub const BDR_RAISEDINNER: UINT = 0x0004; +pub const BDR_SUNKENINNER: UINT = 0x0008; +pub const BDR_OUTER: UINT = BDR_RAISEDOUTER | BDR_SUNKENOUTER; +pub const BDR_INNER: UINT = BDR_RAISEDINNER | BDR_SUNKENINNER; +pub const BDR_RAISED: UINT = BDR_RAISEDOUTER | BDR_RAISEDINNER; +pub const BDR_SUNKEN: UINT = BDR_SUNKENOUTER | BDR_SUNKENINNER; +pub const EDGE_RAISED: UINT = BDR_RAISEDOUTER | BDR_RAISEDINNER; +pub const EDGE_SUNKEN: UINT = BDR_SUNKENOUTER | BDR_SUNKENINNER; +pub const EDGE_ETCHED: UINT = BDR_SUNKENOUTER | BDR_RAISEDINNER; +pub const EDGE_BUMP: UINT = BDR_RAISEDOUTER | BDR_SUNKENINNER; +pub const BF_LEFT: UINT = 0x0001; +pub const BF_TOP: UINT = 0x0002; +pub const BF_RIGHT: UINT = 0x0004; +pub const BF_BOTTOM: UINT = 0x0008; +pub const BF_TOPLEFT: UINT = BF_TOP | BF_LEFT; +pub const BF_TOPRIGHT: UINT = BF_TOP | BF_RIGHT; +pub const BF_BOTTOMLEFT: UINT = BF_BOTTOM | BF_LEFT; +pub const BF_BOTTOMRIGHT: UINT = BF_BOTTOM | BF_RIGHT; +pub const BF_RECT: UINT = BF_LEFT | BF_TOP | BF_RIGHT | BF_BOTTOM; +pub const BF_DIAGONAL: UINT = 0x0010; +pub const BF_DIAGONAL_ENDTOPRIGHT: UINT = BF_DIAGONAL | BF_TOP | BF_RIGHT; +pub const BF_DIAGONAL_ENDTOPLEFT: UINT = BF_DIAGONAL | BF_TOP | BF_LEFT; +pub const BF_DIAGONAL_ENDBOTTOMLEFT: UINT = BF_DIAGONAL | BF_BOTTOM | BF_LEFT; +pub const BF_DIAGONAL_ENDBOTTOMRIGHT: UINT = BF_DIAGONAL | BF_BOTTOM | BF_RIGHT; +pub const BF_MIDDLE: UINT = 0x0800; +pub const BF_SOFT: UINT = 0x1000; +pub const BF_ADJUST: UINT = 0x2000; +pub const BF_FLAT: UINT = 0x4000; +pub const BF_MONO: UINT = 0x8000; +extern "system" { + pub fn DrawEdge( + hdc: HDC, + qrc: LPRECT, + edge: UINT, + grfFlags: UINT, + ) -> BOOL; +} +pub const DFC_CAPTION: UINT = 1; +pub const DFC_MENU: UINT = 2; +pub const DFC_SCROLL: UINT = 3; +pub const DFC_BUTTON: UINT = 4; +pub const DFC_POPUPMENU: UINT = 5; +pub const DFCS_CAPTIONCLOSE: UINT = 0x0000; +pub const DFCS_CAPTIONMIN: UINT = 0x0001; +pub const DFCS_CAPTIONMAX: UINT = 0x0002; +pub const DFCS_CAPTIONRESTORE: UINT = 0x0003; +pub const DFCS_CAPTIONHELP: UINT = 0x0004; +pub const DFCS_MENUARROW: UINT = 0x0000; +pub const DFCS_MENUCHECK: UINT = 0x0001; +pub const DFCS_MENUBULLET: UINT = 0x0002; +pub const DFCS_MENUARROWRIGHT: UINT = 0x0004; +pub const DFCS_SCROLLUP: UINT = 0x0000; +pub const DFCS_SCROLLDOWN: UINT = 0x0001; +pub const DFCS_SCROLLLEFT: UINT = 0x0002; +pub const DFCS_SCROLLRIGHT: UINT = 0x0003; +pub const DFCS_SCROLLCOMBOBOX: UINT = 0x0005; +pub const DFCS_SCROLLSIZEGRIP: UINT = 0x0008; +pub const DFCS_SCROLLSIZEGRIPRIGHT: UINT = 0x0010; +pub const DFCS_BUTTONCHECK: UINT = 0x0000; +pub const DFCS_BUTTONRADIOIMAGE: UINT = 0x0001; +pub const DFCS_BUTTONRADIOMASK: UINT = 0x0002; +pub const DFCS_BUTTONRADIO: UINT = 0x0004; +pub const DFCS_BUTTON3STATE: UINT = 0x0008; +pub const DFCS_BUTTONPUSH: UINT = 0x0010; +pub const DFCS_INACTIVE: UINT = 0x0100; +pub const DFCS_PUSHED: UINT = 0x0200; +pub const DFCS_CHECKED: UINT = 0x0400; +pub const DFCS_TRANSPARENT: UINT = 0x0800; +pub const DFCS_HOT: UINT = 0x1000; +pub const DFCS_ADJUSTRECT: UINT = 0x2000; +pub const DFCS_FLAT: UINT = 0x4000; +pub const DFCS_MONO: UINT = 0x8000; +extern "system" { + pub fn DrawFrameControl( + hdc: HDC, + lprc: LPRECT, + uType: UINT, + uState: UINT, + ) -> BOOL; +} +pub const DC_ACTIVE: UINT = 0x0001; +pub const DC_SMALLCAP: UINT = 0x0002; +pub const DC_ICON: UINT = 0x0004; +pub const DC_TEXT: UINT = 0x0008; +pub const DC_INBUTTON: UINT = 0x0010; +pub const DC_GRADIENT: UINT = 0x0020; +pub const DC_BUTTONS: UINT = 0x1000; +extern "system" { + pub fn DrawCaption( + hwnd: HWND, + hdc: HDC, + lprect: *const RECT, + flags: UINT, + ) -> BOOL; +} +pub const IDANI_OPEN: c_int = 1; +pub const IDANI_CAPTION: c_int = 3; +extern "system" { + pub fn DrawAnimatedRects( + hwnd: HWND, + idAni: c_int, + lprcFrom: *const RECT, + lprcTo: *const RECT, + ) -> BOOL; +} +pub const CF_TEXT: UINT = 1; +pub const CF_BITMAP: UINT = 2; +pub const CF_METAFILEPICT: UINT = 3; +pub const CF_SYLK: UINT = 4; +pub const CF_DIF: UINT = 5; +pub const CF_TIFF: UINT = 6; +pub const CF_OEMTEXT: UINT = 7; +pub const CF_DIB: UINT = 8; +pub const CF_PALETTE: UINT = 9; +pub const CF_PENDATA: UINT = 10; +pub const CF_RIFF: UINT = 11; +pub const CF_WAVE: UINT = 12; +pub const CF_UNICODETEXT: UINT = 13; +pub const CF_ENHMETAFILE: UINT = 14; +pub const CF_HDROP: UINT = 15; +pub const CF_LOCALE: UINT = 16; +pub const CF_DIBV5: UINT = 17; +pub const CF_MAX: UINT = 18; +pub const CF_OWNERDISPLAY: UINT = 0x0080; +pub const CF_DSPTEXT: UINT = 0x0081; +pub const CF_DSPBITMAP: UINT = 0x0082; +pub const CF_DSPMETAFILEPICT: UINT = 0x0083; +pub const CF_DSPENHMETAFILE: UINT = 0x008E; +pub const CF_PRIVATEFIRST: UINT = 0x0200; +pub const CF_PRIVATELAST: UINT = 0x02FF; +pub const CF_GDIOBJFIRST: UINT = 0x0300; +pub const CF_GDIOBJLAST: UINT = 0x03FF; +pub const FVIRTKEY: BYTE = TRUE as u8; +pub const FNOINVERT: BYTE = 0x02; +pub const FSHIFT: BYTE = 0x04; +pub const FCONTROL: BYTE = 0x08; +pub const FALT: BYTE = 0x10; +STRUCT!{struct ACCEL { + fVirt: BYTE, + key: WORD, + cmd: WORD, +}} +pub type LPACCEL = *mut ACCEL; +STRUCT!{struct PAINTSTRUCT { + hdc: HDC, + fErase: BOOL, + rcPaint: RECT, + fRestore: BOOL, + fIncUpdate: BOOL, + rgbReserved: [BYTE; 32], +}} +pub type PPAINTSTRUCT = *mut PAINTSTRUCT; +pub type NPPAINTSTRUCT = *mut PAINTSTRUCT; +pub type LPPAINTSTRUCT = *mut PAINTSTRUCT; +STRUCT!{struct CREATESTRUCTA { + lpCreateParams: LPVOID, + hInstance: HINSTANCE, + hMenu: HMENU, + hwndParent: HWND, + cy: c_int, + cx: c_int, + y: c_int, + x: c_int, + style: LONG, + lpszName: LPCSTR, + lpszClass: LPCSTR, + dwExStyle: DWORD, +}} +pub type LPCREATESTRUCTA = *mut CREATESTRUCTA; +STRUCT!{struct CREATESTRUCTW { + lpCreateParams: LPVOID, + hInstance: HINSTANCE, + hMenu: HMENU, + hwndParent: HWND, + cy: c_int, + cx: c_int, + y: c_int, + x: c_int, + style: LONG, + lpszName: LPCWSTR, + lpszClass: LPCWSTR, + dwExStyle: DWORD, +}} +pub type LPCREATESTRUCTW = *mut CREATESTRUCTW; +STRUCT!{struct WINDOWPLACEMENT { + length: UINT, + flags: UINT, + showCmd: UINT, + ptMinPosition: POINT, + ptMaxPosition: POINT, + rcNormalPosition: RECT, +}} +pub type PWINDOWPLACEMENT = *mut WINDOWPLACEMENT; +pub type LPWINDOWPLACEMENT = *mut WINDOWPLACEMENT; +pub const WPF_SETMINPOSITION: UINT = 0x0001; +pub const WPF_RESTORETOMAXIMIZED: UINT = 0x0002; +pub const WPF_ASYNCWINDOWPLACEMENT: UINT = 0x0004; +STRUCT!{struct NMHDR { + hwndFrom: HWND, + idFrom: UINT_PTR, + code: UINT, +}} +pub type LPNMHDR = *mut NMHDR; +STRUCT!{struct STYLESTRUCT { + styleOld: DWORD, + styleNew: DWORD, +}} +pub type LPSTYLESTRUCT = *mut STYLESTRUCT; +pub const ODT_MENU: UINT = 1; +pub const ODT_LISTBOX: UINT = 2; +pub const ODT_COMBOBOX: UINT = 3; +pub const ODT_BUTTON: UINT = 4; +pub const ODT_STATIC: UINT = 5; +pub const ODA_DRAWENTIRE: UINT = 0x0001; +pub const ODA_SELECT: UINT = 0x0002; +pub const ODA_FOCUS: UINT = 0x0004; +pub const ODS_SELECTED: UINT = 0x0001; +pub const ODS_GRAYED: UINT = 0x0002; +pub const ODS_DISABLED: UINT = 0x0004; +pub const ODS_CHECKED: UINT = 0x0008; +pub const ODS_FOCUS: UINT = 0x0010; +pub const ODS_DEFAULT: UINT = 0x0020; +pub const ODS_COMBOBOXEDIT: UINT = 0x1000; +pub const ODS_HOTLIGHT: UINT = 0x0040; +pub const ODS_INACTIVE: UINT = 0x0080; +pub const ODS_NOACCEL: UINT = 0x0100; +pub const ODS_NOFOCUSRECT: UINT = 0x0200; +STRUCT!{struct MEASUREITEMSTRUCT { + CtlType: UINT, + CtlID: UINT, + itemID: UINT, + itemWidth: UINT, + itemHeight: UINT, + itemData: ULONG_PTR, +}} +pub type PMEASUREITEMSTRUCT = *mut MEASUREITEMSTRUCT; +pub type LPMEASUREITEMSTRUCT = *mut MEASUREITEMSTRUCT; +STRUCT!{struct DRAWITEMSTRUCT { + CtlType: UINT, + CtlID: UINT, + itemID: UINT, + itemAction: UINT, + itemState: UINT, + hwndItem: HWND, + hDC: HDC, + rcItem: RECT, + itemData: ULONG_PTR, +}} +pub type PDRAWITEMSTRUCT = *mut DRAWITEMSTRUCT; +pub type LPDRAWITEMSTRUCT = *mut DRAWITEMSTRUCT; +STRUCT!{struct DELETEITEMSTRUCT { + CtlType: UINT, + CtlID: UINT, + itemID: UINT, + hwndItem: HWND, + itemData: ULONG_PTR, +}} +pub type PDELETEITEMSTRUCT = *mut DELETEITEMSTRUCT; +pub type LPDELETEITEMSTRUCT = *mut DELETEITEMSTRUCT; +STRUCT!{struct COMPAREITEMSTRUCT { + CtlType: UINT, + CtlID: UINT, + hwndItem: HWND, + itemID1: UINT, + itemData1: ULONG_PTR, + itemID2: UINT, + itemData2: ULONG_PTR, + dwLocaleId: DWORD, +}} +pub type PCOMPAREITEMSTRUCT = *mut COMPAREITEMSTRUCT; +pub type LPCOMPAREITEMSTRUCT = *mut COMPAREITEMSTRUCT; +extern "system" { + pub fn GetMessageA( + lpMsg: LPMSG, + hWnd: HWND, + wMsgFilterMin: UINT, + wMsgFilterMax: UINT, + ) -> BOOL; + pub fn GetMessageW( + lpMsg: LPMSG, + hWnd: HWND, + wMsgFilterMin: UINT, + wMsgFilterMax: UINT, + ) -> BOOL; + pub fn TranslateMessage( + lpmsg: *const MSG, + ) -> BOOL; + pub fn DispatchMessageA( + lpmsg: *const MSG, + ) -> LRESULT; + pub fn DispatchMessageW( + lpmsg: *const MSG, + ) -> LRESULT; + pub fn SetMessageQueue( + cMessagesMax: c_int, + ) -> BOOL; + pub fn PeekMessageA( + lpMsg: LPMSG, + hWnd: HWND, + wMsgFilterMin: UINT, + wMsgFilterMax: UINT, + wRemoveMsg: UINT, + ) -> BOOL; + pub fn PeekMessageW( + lpMsg: LPMSG, + hWnd: HWND, + wMsgFilterMin: UINT, + wMsgFilterMax: UINT, + wRemoveMsg: UINT, + ) -> BOOL; +} +pub const PM_NOREMOVE: UINT = 0x0000; +pub const PM_REMOVE: UINT = 0x0001; +pub const PM_NOYIELD: UINT = 0x0002; +pub const PM_QS_INPUT: UINT = QS_INPUT << 16; +pub const PM_QS_POSTMESSAGE: UINT = (QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER) << 16; +pub const PM_QS_PAINT: UINT = QS_PAINT << 16; +pub const PM_QS_SENDMESSAGE: UINT = QS_SENDMESSAGE << 16; +extern "system" { + pub fn RegisterHotKey( + hwnd: HWND, + id: c_int, + fsModifiers: UINT, + vk: UINT, + ) -> BOOL; + pub fn UnregisterHotKey( + hWnd: HWND, + id: c_int, + ) -> BOOL; +} +pub const MOD_ALT: LPARAM = 0x0001; +pub const MOD_CONTROL: LPARAM = 0x0002; +pub const MOD_SHIFT: LPARAM = 0x0004; +pub const MOD_WIN: LPARAM = 0x0008; +pub const MOD_NOREPEAT: LPARAM = 0x4000; +pub const IDHOT_SNAPWINDOW: WPARAM = -1isize as usize; +pub const IDHOT_SNAPDESKTOP: WPARAM = -2isize as usize; +pub const ENDSESSION_CLOSEAPP: UINT = 0x00000001; +pub const ENDSESSION_CRITICAL: UINT = 0x40000000; +pub const ENDSESSION_LOGOFF: UINT = 0x80000000; +pub const EWX_LOGOFF: UINT = 0x00000000; +pub const EWX_SHUTDOWN: UINT = 0x00000001; +pub const EWX_REBOOT: UINT = 0x00000002; +pub const EWX_FORCE: UINT = 0x00000004; +pub const EWX_POWEROFF: UINT = 0x00000008; +pub const EWX_FORCEIFHUNG: UINT = 0x00000010; +pub const EWX_QUICKRESOLVE: UINT = 0x00000020; +pub const EWX_RESTARTAPPS: UINT = 0x00000040; +pub const EWX_HYBRID_SHUTDOWN: UINT = 0x00400000; +pub const EWX_BOOTOPTIONS: UINT = 0x01000000; +// ExitWindows +extern "system" { + pub fn ExitWindowsEx( + uFlags: UINT, + dwReason: DWORD, + ) -> BOOL; + pub fn SwapMouseButton( + fSwap: BOOL, + ) -> BOOL; + pub fn GetMessagePos() -> DWORD; + pub fn GetMessageTime() -> LONG; + pub fn GetMessageExtraInfo() -> LPARAM; + pub fn GetUnpredictedMessagePos() -> DWORD; + pub fn IsWow64Message() -> BOOL; + pub fn SetMessageExtraInfo( + lParam: LPARAM, + ) -> LPARAM; + pub fn SendMessageA( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn SendMessageW( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn SendMessageTimeoutA( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + fuFlags: UINT, + uTimeout: UINT, + lpdwResult: PDWORD_PTR, + ) -> LRESULT; + pub fn SendMessageTimeoutW( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + fuFlags: UINT, + uTimeout: UINT, + lpdwResult: PDWORD_PTR, + ) -> LRESULT; + pub fn SendNotifyMessageA( + hWnd: HWND, + msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> BOOL; + pub fn SendNotifyMessageW( + hWnd: HWND, + msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> BOOL; + pub fn SendMessageCallbackA( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + lpResultCallBack: SENDASYNCPROC, + dwData: ULONG_PTR, + ) -> BOOL; + pub fn SendMessageCallbackW( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + lpResultCallBack: SENDASYNCPROC, + dwData: ULONG_PTR, + ) -> BOOL; +} +STRUCT!{struct BSMINFO { + cbSize: UINT, + hdesk: HDESK, + hwnd: HWND, + luid: LUID, +}} +pub type PBSMINFO = *mut BSMINFO; +extern "system" { + pub fn BroadcastSystemMessageExA( + flags: DWORD, + lpInfo: LPDWORD, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + pbsmInfo: PBSMINFO, + ) -> c_long; + pub fn BroadcastSystemMessageExW( + flags: DWORD, + lpInfo: LPDWORD, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + pbsmInfo: PBSMINFO, + ) -> c_long; + pub fn BroadcastSystemMessageA( + flags: DWORD, + lpInfo: LPDWORD, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LONG; + pub fn BroadcastSystemMessageW( + flags: DWORD, + lpInfo: LPDWORD, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LONG; +} +pub const BSM_ALLCOMPONENTS: DWORD = 0x00000000; +pub const BSM_VXDS: DWORD = 0x00000001; +pub const BSM_NETDRIVER: DWORD = 0x00000002; +pub const BSM_INSTALLABLEDRIVERS: DWORD = 0x00000004; +pub const BSM_APPLICATIONS: DWORD = 0x00000008; +pub const BSM_ALLDESKTOPS: DWORD = 0x00000010; +pub const BSF_QUERY: DWORD = 0x00000001; +pub const BSF_IGNORECURRENTTASK: DWORD = 0x00000002; +pub const BSF_FLUSHDISK: DWORD = 0x00000004; +pub const BSF_NOHANG: DWORD = 0x00000008; +pub const BSF_POSTMESSAGE: DWORD = 0x00000010; +pub const BSF_FORCEIFHUNG: DWORD = 0x00000020; +pub const BSF_NOTIMEOUTIFNOTHUNG: DWORD = 0x00000040; +pub const BSF_ALLOWSFW: DWORD = 0x00000080; +pub const BSF_SENDNOTIFYMESSAGE: DWORD = 0x00000100; +pub const BSF_RETURNHDESK: DWORD = 0x00000200; +pub const BSF_LUID: DWORD = 0x00000400; +pub const BROADCAST_QUERY_DENY: DWORD = 0x424D5144; +pub type HDEVNOTIFY = PVOID; +pub type PHDEVNOTIFY = *mut HDEVNOTIFY; +pub const DEVICE_NOTIFY_WINDOW_HANDLE: DWORD = 0x00000000; +pub const DEVICE_NOTIFY_SERVICE_HANDLE: DWORD = 0x00000001; +pub const DEVICE_NOTIFY_ALL_INTERFACE_CLASSES: DWORD = 0x00000004; +extern "system" { + pub fn RegisterDeviceNotificationA( + hRecipient: HANDLE, + notificationFilter: LPVOID, + flags: DWORD, + ) -> HDEVNOTIFY; + pub fn RegisterDeviceNotificationW( + hRecipient: HANDLE, + notificationFilter: LPVOID, + flags: DWORD, + ) -> HDEVNOTIFY; + pub fn UnregisterDeviceNotification( + Handle: HDEVNOTIFY, + ) -> BOOL; +} +pub type HPOWERNOTIFY = PVOID; +pub type PHPOWERNOTIFY = *mut HPOWERNOTIFY; +extern "system" { + pub fn RegisterPowerSettingNotification( + hRecipient: HANDLE, + PowerSettingGuid: LPCGUID, + Flags: DWORD, + ) -> HPOWERNOTIFY; + pub fn UnregisterPowerSettingNotification( + Handle: HPOWERNOTIFY, + ) -> BOOL; + pub fn RegisterSuspendResumeNotification( + hRecipient: HANDLE, + Flags: DWORD, + ) -> HPOWERNOTIFY; + pub fn UnregisterSuspendResumeNotification( + Handle: HPOWERNOTIFY, + ) -> BOOL; + pub fn PostMessageA( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> BOOL; + pub fn PostMessageW( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> BOOL; + pub fn PostThreadMessageA( + idThread: DWORD, + msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> BOOL; + pub fn PostThreadMessageW( + idThread: DWORD, + msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> BOOL; +} +// PostAppMessageA +// PostAppMessageW +pub const HWND_BROADCAST: HWND = 0xffff as HWND; +pub const HWND_MESSAGE: HWND = -3isize as HWND; +extern "system" { + pub fn AttachThreadInput( + idAttach: DWORD, + idAttachTo: DWORD, + fAttach: BOOL, + ) -> BOOL; + pub fn ReplyMessage( + lResult: LRESULT, + ) -> BOOL; + pub fn WaitMessage() -> BOOL; + pub fn WaitForInputIdle( + hProcess: HANDLE, + dwMilliseconds: DWORD, + ) -> DWORD; + pub fn DefWindowProcA( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn DefWindowProcW( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn PostQuitMessage( + nExitCode: c_int, + ); + pub fn CallWindowProcA( + lpPrevWndFunc: WNDPROC, + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn CallWindowProcW( + lpPrevWndFunc: WNDPROC, + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn InSendMessage() -> BOOL; + pub fn InSendMessageEx( + lpReserved: LPVOID, + ) -> DWORD; +} +pub const ISMEX_NOSEND: DWORD = 0x00000000; +pub const ISMEX_SEND: DWORD = 0x00000001; +pub const ISMEX_NOTIFY: DWORD = 0x00000002; +pub const ISMEX_CALLBACK: DWORD = 0x00000004; +pub const ISMEX_REPLIED: DWORD = 0x00000008; +extern "system" { + pub fn GetDoubleClickTime() -> UINT; + pub fn SetDoubleClickTime( + uInterval: UINT, + ) -> BOOL; + pub fn RegisterClassA( + lpWndClass: *const WNDCLASSA, + ) -> ATOM; + pub fn RegisterClassW( + lpWndClass: *const WNDCLASSW, + ) -> ATOM; + pub fn UnregisterClassA( + lpClassName: LPCSTR, + hInstance: HINSTANCE, + ) -> BOOL; + pub fn UnregisterClassW( + lpClassName: LPCWSTR, + hInstance: HINSTANCE, + ) -> BOOL; + pub fn GetClassInfoA( + hInstance: HINSTANCE, + lpClassName: LPCSTR, + lpWndClass: LPWNDCLASSA, + ) -> BOOL; + pub fn GetClassInfoW( + hInstance: HINSTANCE, + lpClassName: LPCWSTR, + lpWndClass: LPWNDCLASSW, + ) -> BOOL; + pub fn RegisterClassExA( + lpWndClass: *const WNDCLASSEXA, + ) -> ATOM; + pub fn RegisterClassExW( + lpWndClass: *const WNDCLASSEXW, + ) -> ATOM; + pub fn GetClassInfoExA( + hinst: HINSTANCE, + lpszClass: LPCSTR, + lpwcx: LPWNDCLASSEXA, + ) -> BOOL; + pub fn GetClassInfoExW( + hinst: HINSTANCE, + lpszClass: LPCWSTR, + lpwcx: LPWNDCLASSEXW, + ) -> BOOL; +} +pub const CW_USEDEFAULT: c_int = 0x80000000; +pub const HWND_DESKTOP: HWND = 0 as HWND; +FN!{stdcall PREGISTERCLASSNAMEW( + LPCWSTR, +) -> BOOLEAN} +extern "system" { + pub fn CreateWindowExA( + dwExStyle: DWORD, + lpClassName: LPCSTR, + lpWindowName: LPCSTR, + dwStyle: DWORD, + x: c_int, + y: c_int, + nWidth: c_int, + nHeight: c_int, + hWndParent: HWND, + hMenu: HMENU, + hInstance: HINSTANCE, + lpParam: LPVOID, + ) -> HWND; + pub fn CreateWindowExW( + dwExStyle: DWORD, + lpClassName: LPCWSTR, + lpWindowName: LPCWSTR, + dwStyle: DWORD, + x: c_int, + y: c_int, + nWidth: c_int, + nHeight: c_int, + hWndParent: HWND, + hMenu: HMENU, + hInstance: HINSTANCE, + lpParam: LPVOID, + ) -> HWND; +} +// CreateWindowA +// CreateWindowW +extern "system" { + pub fn IsWindow( + hWnd: HWND, + ) -> BOOL; + pub fn IsMenu( + hMenu: HMENU, + ) -> BOOL; + pub fn IsChild( + hWndParent: HWND, + hWnd: HWND, + ) -> BOOL; + pub fn DestroyWindow( + hWnd: HWND, + ) -> BOOL; + pub fn ShowWindow( + hWnd: HWND, + nCmdShow: c_int, + ) -> BOOL; + pub fn AnimateWindow( + hWnd: HWND, + dwTime: DWORD, + dwFlags: DWORD, + ) -> BOOL; + pub fn UpdateLayeredWindow( + hWnd: HWND, + hdcDst: HDC, + pptDst: *mut POINT, + psize: *mut SIZE, + hdcSrc: HDC, + pptSrc: *mut POINT, + crKey: COLORREF, + pblend: *mut BLENDFUNCTION, + dwFlags: DWORD, + ) -> BOOL; +} +STRUCT!{struct UPDATELAYEREDWINDOWINFO { + cbSize: DWORD, + hdcDst: HDC, + pptDst: *const POINT, + psize: *const SIZE, + hdcSrc: HDC, + pptSrc: *const POINT, + crKey: COLORREF, + pblend: *const BLENDFUNCTION, + dwFlags: DWORD, + prcDirty: *const RECT, +}} +pub type PUPDATELAYEREDWINDOWINFO = *mut UPDATELAYEREDWINDOWINFO; +extern "system" { + pub fn UpdateLayeredWindowIndirect( + hWnd: HWND, + pULWInfo: *mut UPDATELAYEREDWINDOWINFO, + ) -> BOOL; + pub fn GetLayeredWindowAttributes( + hwnd: HWND, + pcrKey: *mut COLORREF, + pbAlpha: *mut BYTE, + pdwFlags: *mut DWORD, + ) -> BOOL; +} +pub const PW_CLIENTONLY: DWORD = 0x00000001; +pub const PW_RENDERFULLCONTENT: DWORD = 0x00000002; +extern "system" { + pub fn PrintWindow( + hwnd: HWND, + hdcBlt: HDC, + nFlags: UINT, + ) -> BOOL; + pub fn SetLayeredWindowAttributes( + hwnd: HWND, + crKey: COLORREF, + bAlpha: BYTE, + dwFlags: DWORD, + ) -> BOOL; +} +pub const LWA_COLORKEY: DWORD = 0x00000001; +pub const LWA_ALPHA: DWORD = 0x00000002; +pub const ULW_COLORKEY: DWORD = 0x00000001; +pub const ULW_ALPHA: DWORD = 0x00000002; +pub const ULW_OPAQUE: DWORD = 0x00000004; +pub const ULW_EX_NORESIZE: DWORD = 0x00000008; +extern "system" { + pub fn ShowWindowAsync( + hWnd: HWND, + nCmdShow: c_int, + ) -> BOOL; + pub fn FlashWindow( + hwnd: HWND, + bInvert: BOOL, + ) -> BOOL; +} +STRUCT!{struct FLASHWINFO { + cbSize: UINT, + hwnd: HWND, + dwFlags: DWORD, + uCount: UINT, + dwTimeout: DWORD, +}} +pub type PFLASHWINFO = *mut FLASHWINFO; +extern "system" { + pub fn FlashWindowEx( + pfwi: PFLASHWINFO, + ) -> BOOL; +} +pub const FLASHW_STOP: DWORD = 0; +pub const FLASHW_CAPTION: DWORD = 0x00000001; +pub const FLASHW_TRAY: DWORD = 0x00000002; +pub const FLASHW_ALL: DWORD = FLASHW_CAPTION | FLASHW_TRAY; +pub const FLASHW_TIMER: DWORD = 0x00000004; +pub const FLASHW_TIMERNOFG: DWORD = 0x0000000C; +extern "system" { + pub fn ShowOwnedPopups( + hWnd: HWND, + fShow: BOOL, + ) -> BOOL; + pub fn OpenIcon( + hWnd: HWND, + ) -> BOOL; + pub fn CloseWindow( + hWnd: HWND, + ) -> BOOL; + pub fn MoveWindow( + hWnd: HWND, + X: c_int, + Y: c_int, + nWidth: c_int, + nHeight: c_int, + bRepaint: BOOL, + ) -> BOOL; + pub fn SetWindowPos( + hWnd: HWND, + hWndInsertAfter: HWND, + X: c_int, + Y: c_int, + cx: c_int, + cy: c_int, + uFlags: UINT, + ) -> BOOL; + pub fn GetWindowPlacement( + hWnd: HWND, + lpwndpl: *mut WINDOWPLACEMENT, + ) -> BOOL; + pub fn SetWindowPlacement( + hWnd: HWND, + lpwndpl: *const WINDOWPLACEMENT, + ) -> BOOL; +} +pub const WDA_NONE: DWORD = 0x00000000; +pub const WDA_MONITOR: DWORD = 0x00000001; +extern "system" { + pub fn GetWindowDisplayAffinity( + hWnd: HWND, + pdwAffinity: *mut DWORD, + ) -> BOOL; + pub fn SetWindowDisplayAffinity( + hWnd: HWND, + dwAffinity: DWORD, + ) -> BOOL; + pub fn BeginDeferWindowPos( + nNumWindows: c_int, + ) -> HDWP; + pub fn DeferWindowPos( + hWinPosInfo: HDWP, + hWnd: HWND, + hWndInserAfter: HWND, + x: c_int, + y: c_int, + cx: c_int, + cy: c_int, + uFlags: UINT, + ) -> HDWP; + pub fn EndDeferWindowPos( + hWinPosInfo: HDWP, + ) -> BOOL; + pub fn IsWindowVisible( + hWnd: HWND, + ) -> BOOL; + pub fn IsIconic( + hWnd: HWND, + ) -> BOOL; + pub fn AnyPopup() -> BOOL; + pub fn BringWindowToTop( + hWnd: HWND, + ) -> BOOL; + pub fn IsZoomed( + hwnd: HWND, + ) -> BOOL; +} +pub const SWP_NOSIZE: UINT = 0x0001; +pub const SWP_NOMOVE: UINT = 0x0002; +pub const SWP_NOZORDER: UINT = 0x0004; +pub const SWP_NOREDRAW: UINT = 0x0008; +pub const SWP_NOACTIVATE: UINT = 0x0010; +pub const SWP_FRAMECHANGED: UINT = 0x0020; +pub const SWP_SHOWWINDOW: UINT = 0x0040; +pub const SWP_HIDEWINDOW: UINT = 0x0080; +pub const SWP_NOCOPYBITS: UINT = 0x0100; +pub const SWP_NOOWNERZORDER: UINT = 0x0200; +pub const SWP_NOSENDCHANGING: UINT = 0x0400; +pub const SWP_DRAWFRAME: UINT = SWP_FRAMECHANGED; +pub const SWP_NOREPOSITION: UINT = SWP_NOOWNERZORDER; +pub const SWP_DEFERERASE: UINT = 0x2000; +pub const SWP_ASYNCWINDOWPOS: UINT = 0x4000; +pub const HWND_TOP: HWND = 0 as HWND; +pub const HWND_BOTTOM: HWND = 1 as HWND; +pub const HWND_TOPMOST: HWND = -1isize as HWND; +pub const HWND_NOTOPMOST: HWND = -2isize as HWND; +STRUCT!{struct DLGTEMPLATE { + style: DWORD, + dwExtendedStyle: DWORD, + cdit: WORD, + x: c_short, + y: c_short, + cx: c_short, + cy: c_short, +}} +pub type LPDLGTEMPLATEA = *mut DLGTEMPLATE; +pub type LPDLGTEMPLATEW = *mut DLGTEMPLATE; +pub type LPCDLGTEMPLATEA = *const DLGTEMPLATE; +pub type LPCDLGTEMPLATEW = *const DLGTEMPLATE; +STRUCT!{struct DLGITEMTEMPLATE { + style: DWORD, + dwExtendedStyle: DWORD, + x: c_short, + y: c_short, + cx: c_short, + cy: c_short, + id: WORD, +}} +pub type PDLGITEMTEMPLATEA = *mut DLGITEMTEMPLATE; +pub type PDLGITEMTEMPLATEW = *mut DLGITEMTEMPLATE; +pub type LPDLGITEMTEMPLATEA = *mut DLGITEMTEMPLATE; +pub type LPDLGITEMTEMPLATEW = *mut DLGITEMTEMPLATE; +extern "system" { + pub fn CreateDialogParamA( + hInstance: HINSTANCE, + lpTemplateName: LPCSTR, + hWndParent: HWND, + lpDialogFunc: DLGPROC, + dwInitParam: LPARAM, + ) -> HWND; + pub fn CreateDialogParamW( + hInstance: HINSTANCE, + lpTemplateName: LPCWSTR, + hWndParent: HWND, + lpDialogFunc: DLGPROC, + dwInitParam: LPARAM, + ) -> HWND; + pub fn CreateDialogIndirectParamA( + hInstance: HINSTANCE, + lpTemplate: LPCDLGTEMPLATEA, + hWndParent: HWND, + lpDialogFunc: DLGPROC, + dwInitParam: LPARAM, + ) -> HWND; + pub fn CreateDialogIndirectParamW( + hInstance: HINSTANCE, + lpTemplate: LPCDLGTEMPLATEW, + hWndParent: HWND, + lpDialogFunc: DLGPROC, + dwInitParam: LPARAM, + ) -> HWND; +} +// CreateDialogA +// CreateDialogW +// CreateDialogIndirectA +// CreateDialogIndirectW +extern "system" { + pub fn DialogBoxParamA( + hInstance: HINSTANCE, + lpTemplateName: LPCSTR, + hWndParent: HWND, + lpDialogFunc: DLGPROC, + dwInitParam: LPARAM, + ) -> INT_PTR; + pub fn DialogBoxParamW( + hInstance: HINSTANCE, + lpTemplateName: LPCWSTR, + hWndParent: HWND, + lpDialogFunc: DLGPROC, + dwInitParam: LPARAM, + ) -> INT_PTR; + pub fn DialogBoxIndirectParamA( + hInstance: HINSTANCE, + hDialogTemplate: LPCDLGTEMPLATEA, + hWndParent: HWND, + lpDialogFunc: DLGPROC, + dwInitParam: LPARAM, + ) -> INT_PTR; + pub fn DialogBoxIndirectParamW( + hInstance: HINSTANCE, + hDialogTemplate: LPCDLGTEMPLATEW, + hWndParent: HWND, + lpDialogFunc: DLGPROC, + dwInitParam: LPARAM, + ) -> INT_PTR; +} +// DialogBoxA +// DialogBoxW +// DialogBoxIndirectA +// DialogBoxIndirectW +extern "system" { + pub fn EndDialog( + hDlg: HWND, + nResult: INT_PTR, + ) -> BOOL; + pub fn GetDlgItem( + hDlg: HWND, + nIDDlgItem: c_int, + ) -> HWND; + pub fn SetDlgItemInt( + hDlg: HWND, + nIDDlgItem: c_int, + uValue: UINT, + bSigned: BOOL, + ) -> BOOL; + pub fn GetDlgItemInt( + hDlg: HWND, + nIDDlgItem: c_int, + lpTranslated: *mut BOOL, + bSigned: BOOL, + ) -> UINT; + pub fn SetDlgItemTextA( + hDlg: HWND, + nIDDlgItem: c_int, + lpString: LPCSTR, + ) -> BOOL; + pub fn SetDlgItemTextW( + hDlg: HWND, + nIDDlgItem: c_int, + lpString: LPCWSTR, + ) -> BOOL; + pub fn GetDlgItemTextA( + hDlg: HWND, + nIDDlgItem: c_int, + lpString: LPSTR, + nMaxCount: c_int, + ) -> UINT; + pub fn GetDlgItemTextW( + hDlg: HWND, + nIDDlgItem: c_int, + lpString: LPWSTR, + nMaxCount: c_int, + ) -> UINT; + pub fn CheckDlgButton( + hDlg: HWND, + nIDButton: c_int, + uCheck: UINT, + ) -> BOOL; + pub fn CheckRadioButton( + hDlg: HWND, + nIDFirstButton: c_int, + nIDLasatButton: c_int, + nIDCheckButton: c_int, + ) -> BOOL; + pub fn IsDlgButtonChecked( + hDlg: HWND, + nIDButton: c_int, + ) -> UINT; + pub fn SendDlgItemMessageA( + hDlg: HWND, + nIDDlgItem: c_int, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn SendDlgItemMessageW( + hDlg: HWND, + nIDDlgItem: c_int, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn GetNextDlgGroupItem( + hDlg: HWND, + hCtl: HWND, + bPrevious: BOOL, + ) -> HWND; + pub fn GetNextDlgTabItem( + hDlg: HWND, + hCtl: HWND, + bPrevious: BOOL, + ) -> HWND; + pub fn GetDlgCtrlID( + hwnd: HWND, + ) -> c_int; + pub fn GetDialogBaseUnits() -> LONG; + pub fn DefDlgProcA( + hDlg: HWND, + msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn DefDlgProcW( + hDlg: HWND, + msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; +} +ENUM!{enum DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS { + DCDC_DEFAULT = 0x0000, + DCDC_DISABLE_FONT_UPDATE = 0x0001, + DCDC_DISABLE_RELAYOUT = 0x0002, +}} +extern "system" { + pub fn SetDialogControlDpiChangeBehavior( + hwnd: HWND, + mask: DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS, + values: DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS, + ) -> BOOL; + pub fn GetDialogControlDpiChangeBehavior( + hwnd: HWND, + ) -> DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS; +} +ENUM!{enum DIALOG_DPI_CHANGE_BEHAVIORS { + DDC_DEFAULT = 0x0000, + DDC_DISABLE_ALL = 0x0001, + DDC_DISABLE_RESIZE = 0x0002, + DDC_DISABLE_CONTROL_RELAYOUT = 0x0004, +}} +extern "system" { + pub fn SetDialogDpiChangeBehavior( + hDlg: HWND, + mask: DIALOG_DPI_CHANGE_BEHAVIORS, + values: DIALOG_DPI_CHANGE_BEHAVIORS, + ) -> BOOL; + pub fn GetDialogDpiChangeBehavior( + hDlg: HWND, + ) -> DIALOG_DPI_CHANGE_BEHAVIORS; + pub fn CallMsgFilterA( + lpMsg: LPMSG, + nCode: c_int, + ) -> BOOL; + pub fn CallMsgFilterW( + lpMsg: LPMSG, + nCode: c_int, + ) -> BOOL; + pub fn OpenClipboard( + hWnd: HWND, + ) -> BOOL; + pub fn CloseClipboard() -> BOOL; + pub fn GetClipboardSequenceNumber() -> DWORD; + pub fn GetClipboardOwner() -> HWND; + pub fn SetClipboardViewer( + hWndNewViewer: HWND, + ) -> HWND; + pub fn GetClipboardViewer() -> HWND; + pub fn ChangeClipboardChain( + hwndRemove: HWND, + hwndNewNext: HWND, + ) -> BOOL; + pub fn SetClipboardData( + uFormat: UINT, + hMem: HANDLE, + ) -> HANDLE; + pub fn GetClipboardData( + uFormat: UINT, + ) -> HANDLE; + pub fn RegisterClipboardFormatA( + lpszFormat: LPCSTR, + ) -> UINT; + pub fn RegisterClipboardFormatW( + lpszFormat: LPCWSTR, + ) -> UINT; + pub fn CountClipboardFormats() -> c_int; + pub fn EnumClipboardFormats( + format: UINT, + ) -> UINT; + pub fn GetClipboardFormatNameA( + format: UINT, + lpszFormatName: LPSTR, + cchMaxCount: c_int, + ) -> c_int; + pub fn GetClipboardFormatNameW( + format: UINT, + lpszFormatName: LPWSTR, + cchMaxCount: c_int, + ) -> c_int; + pub fn EmptyClipboard() -> BOOL; + pub fn IsClipboardFormatAvailable( + format: UINT, + ) -> BOOL; + pub fn GetPriorityClipboardFormat( + paFormatPriorityList: *mut UINT, + cFormats: c_int, + ) -> c_int; + pub fn GetOpenClipboardWindow() -> HWND; + pub fn AddClipboardFormatListener( + hWnd: HWND, + ) -> BOOL; + pub fn RemoveClipboardFormatListener( + hWnd: HWND, + ) -> BOOL; + pub fn GetUpdatedClipboardFormats( + lpuiFormats: PUINT, + cFormats: UINT, + pcFormatsOUT: PUINT, + ) -> BOOL; + pub fn CharToOemA( + pSrc: LPCSTR, + pDst: LPSTR, + ) -> BOOL; + pub fn CharToOemW( + pSrc: LPCWSTR, + pDst: LPSTR, + ) -> BOOL; + pub fn OemToCharA( + pSrc: LPCSTR, + pDst: LPSTR, + ) -> BOOL; + pub fn OemToCharW( + pSrc: LPCSTR, + pDst: LPWSTR, + ) -> BOOL; + pub fn CharToOemBuffA( + lpszSrc: LPCSTR, + lpszDst: LPSTR, + cchDstLength: DWORD, + ) -> BOOL; + pub fn CharToOemBuffW( + lpszSrc: LPCWSTR, + lpszDst: LPSTR, + cchDstLength: DWORD, + ) -> BOOL; + pub fn OemToCharBuffA( + lpszSrc: LPCSTR, + lpszDst: LPSTR, + cchDstLength: DWORD, + ) -> BOOL; + pub fn OemToCharBuffW( + lpszSrc: LPCSTR, + lpszDst: LPWSTR, + cchDstLength: DWORD, + ) -> BOOL; + pub fn CharUpperA( + lpsz: LPSTR, + ) -> LPSTR; + pub fn CharUpperW( + lpsz: LPWSTR, + ) -> LPWSTR; + pub fn CharUpperBuffA( + lpsz: LPSTR, + cchLength: DWORD, + ) -> DWORD; + pub fn CharUpperBuffW( + lpsz: LPWSTR, + cchLength: DWORD, + ) -> DWORD; + pub fn CharLowerA( + lpsz: LPSTR, + ) -> LPSTR; + pub fn CharLowerW( + lpsz: LPWSTR, + ) -> LPWSTR; + pub fn CharLowerBuffA( + lpsz: LPSTR, + cchLength: DWORD, + ) -> DWORD; + pub fn CharLowerBuffW( + lpsz: LPWSTR, + cchLength: DWORD, + ) -> DWORD; + pub fn CharNextA( + lpsz: LPCSTR, + ) -> LPSTR; + pub fn CharNextW( + lpsz: LPCWSTR, + ) -> LPWSTR; + pub fn CharPrevA( + lpszStart: LPCSTR, + lpszCurrent: LPCSTR, + ) -> LPSTR; + pub fn CharPrevW( + lpszStart: LPCWSTR, + lpszCurrent: LPCWSTR, + ) -> LPWSTR; + pub fn CharNextExA( + codePage: WORD, + lpCurrentChar: LPSTR, + dwFlags: DWORD, + ) -> LPSTR; + pub fn CharPrevExA( + codePage: WORD, + lpStart: LPCSTR, + lpCurrentChar: LPCSTR, + dwFlags: DWORD, + ) -> LPSTR; +} +// AnsiToOem +// OemToAnsi +// AnsiToOemBuff +// OemToAnsiBuff +// AnsiUpper +// AnsiUpperBuff +// AnsiLower +// AnsiLowerBuff +// AnsiNext +// AnsiPrev +extern "system" { + pub fn IsCharAlphaA( + ch: CHAR, + ) -> BOOL; + pub fn IsCharAlphaW( + ch: WCHAR, + ) -> BOOL; + pub fn IsCharAlphaNumericA( + ch: CHAR, + ) -> BOOL; + pub fn IsCharAlphaNumericW( + ch: WCHAR, + ) -> BOOL; + pub fn IsCharUpperA( + ch: CHAR, + ) -> BOOL; + pub fn IsCharUpperW( + ch: WCHAR, + ) -> BOOL; + pub fn IsCharLowerA( + ch: CHAR, + ) -> BOOL; + pub fn IsCharLowerW( + ch: WCHAR, + ) -> BOOL; + pub fn SetFocus( + hWnd: HWND, + ) -> HWND; + pub fn GetActiveWindow() -> HWND; + pub fn GetFocus() -> HWND; + pub fn GetKBCodePage() -> UINT; + pub fn GetKeyState( + nVirtKey: c_int, + ) -> SHORT; + pub fn GetAsyncKeyState( + vKey: c_int, + ) -> SHORT; + pub fn GetKeyboardState( + lpKeyState: PBYTE, + ) -> BOOL; + pub fn SetKeyboardState( + lpKeyState: LPBYTE, + ) -> BOOL; + pub fn GetKeyNameTextA( + lparam: LONG, + lpString: LPSTR, + cchSize: c_int, + ) -> c_int; + pub fn GetKeyNameTextW( + lParam: LONG, + lpString: LPWSTR, + cchSize: c_int, + ) -> c_int; + pub fn GetKeyboardType( + nTypeFlag: c_int, + ) -> c_int; + pub fn ToAscii( + uVirtKey: UINT, + uScanCode: UINT, + lpKeyState: *const BYTE, + lpChar: LPWORD, + uFlags: UINT, + ) -> c_int; + pub fn ToAsciiEx( + uVirtKey: UINT, + uScanCode: UINT, + lpKeyState: *const BYTE, + lpChar: LPWORD, + uFlags: UINT, + dwhkl: HKL, + ) -> c_int; + pub fn ToUnicode( + wVirtKey: UINT, + wScanCode: UINT, + lpKeyState: *const BYTE, + lwszBuff: LPWSTR, + cchBuff: c_int, + wFlags: UINT, + ) -> c_int; + pub fn OemKeyScan( + wOemChar: WORD, + ) -> DWORD; + pub fn VkKeyScanA( + ch: CHAR, + ) -> SHORT; + pub fn VkKeyScanW( + ch: WCHAR, + ) -> SHORT; + pub fn VkKeyScanExA( + ch: CHAR, + dwhkl: HKL, + ) -> SHORT; + pub fn VkKeyScanExW( + ch: WCHAR, + dwhkl: HKL, + ) -> SHORT; +} +pub const KEYEVENTF_EXTENDEDKEY: DWORD = 0x0001; +pub const KEYEVENTF_KEYUP: DWORD = 0x0002; +pub const KEYEVENTF_UNICODE: DWORD = 0x0004; +pub const KEYEVENTF_SCANCODE: DWORD = 0x0008; +extern "system" { + pub fn keybd_event( + bVk: BYTE, + bScan: BYTE, + dwFlags: DWORD, + dwExtraInfo: ULONG_PTR, + ); +} +pub const MOUSEEVENTF_MOVE: DWORD = 0x0001; +pub const MOUSEEVENTF_LEFTDOWN: DWORD = 0x0002; +pub const MOUSEEVENTF_LEFTUP: DWORD = 0x0004; +pub const MOUSEEVENTF_RIGHTDOWN: DWORD = 0x0008; +pub const MOUSEEVENTF_RIGHTUP: DWORD = 0x0010; +pub const MOUSEEVENTF_MIDDLEDOWN: DWORD = 0x0020; +pub const MOUSEEVENTF_MIDDLEUP: DWORD = 0x0040; +pub const MOUSEEVENTF_XDOWN: DWORD = 0x0080; +pub const MOUSEEVENTF_XUP: DWORD = 0x0100; +pub const MOUSEEVENTF_WHEEL: DWORD = 0x0800; +pub const MOUSEEVENTF_HWHEEL: DWORD = 0x01000; +pub const MOUSEEVENTF_MOVE_NOCOALESCE: DWORD = 0x2000; +pub const MOUSEEVENTF_VIRTUALDESK: DWORD = 0x4000; +pub const MOUSEEVENTF_ABSOLUTE: DWORD = 0x8000; +extern "system" { + pub fn mouse_event( + dwFlags: DWORD, + dx: DWORD, + dy: DWORD, + dwData: DWORD, + dwExtraInfo: ULONG_PTR, + ); +} +STRUCT!{struct MOUSEINPUT { + dx: LONG, + dy: LONG, + mouseData: DWORD, + dwFlags: DWORD, + time: DWORD, + dwExtraInfo: ULONG_PTR, +}} +pub type PMOUSEINPUT = *mut MOUSEINPUT; +pub type LPMOUSEINPUT = *mut MOUSEINPUT; +STRUCT!{struct KEYBDINPUT { + wVk: WORD, + wScan: WORD, + dwFlags: DWORD, + time: DWORD, + dwExtraInfo: ULONG_PTR, +}} +pub type PKEYBDINPUT = *mut KEYBDINPUT; +pub type LPKEYBDINPUT = *mut KEYBDINPUT; +STRUCT!{struct HARDWAREINPUT { + uMsg: DWORD, + wParamL: WORD, + wParamH: WORD, +}} +pub type PHARDWAREINPUT = *mut HARDWAREINPUT; +pub type LPHARDWAREINPUT= *mut HARDWAREINPUT; +pub const INPUT_MOUSE: DWORD = 0; +pub const INPUT_KEYBOARD: DWORD = 1; +pub const INPUT_HARDWARE: DWORD = 2; +UNION!{union INPUT_u { + [u32; 6] [u64; 4], + mi mi_mut: MOUSEINPUT, + ki ki_mut: KEYBDINPUT, + hi hi_mut: HARDWAREINPUT, +}} +STRUCT!{struct INPUT { + type_: DWORD, + u: INPUT_u, +}} +pub type PINPUT = *mut INPUT; +pub type LPINPUT = *mut INPUT; +extern "system" { + pub fn SendInput( + cInputs: UINT, + pInputs: LPINPUT, + cbSize: c_int, + ) -> UINT; +} +DECLARE_HANDLE!{HTOUCHINPUT, HTOUCHINPUT__} +STRUCT!{struct TOUCHINPUT { + x: LONG, + y: LONG, + hSource: HANDLE, + dwID: DWORD, + dwFlags: DWORD, + dwMask: DWORD, + dwTime: DWORD, + dwExtraInfo: ULONG_PTR, + cxContact: DWORD, + cyContact: DWORD, +}} +pub type PTOUCHINPUT = *mut TOUCHINPUT; +pub type PCTOUCHINPUT = *const TOUCHINPUT; +// TOUCH_COORD_TO_PIXEL +pub const TOUCHEVENTF_MOVE: DWORD = 0x0001; +pub const TOUCHEVENTF_DOWN: DWORD = 0x0002; +pub const TOUCHEVENTF_UP: DWORD = 0x0004; +pub const TOUCHEVENTF_INRANGE: DWORD = 0x0008; +pub const TOUCHEVENTF_PRIMARY: DWORD = 0x0010; +pub const TOUCHEVENTF_NOCOALESCE: DWORD = 0x0020; +pub const TOUCHEVENTF_PEN: DWORD = 0x0040; +pub const TOUCHEVENTF_PALM: DWORD = 0x0080; +pub const TOUCHINPUTMASKF_TIMEFROMSYSTEM: DWORD = 0x0001; +pub const TOUCHINPUTMASKF_EXTRAINFO: DWORD = 0x0002; +pub const TOUCHINPUTMASKF_CONTACTAREA: DWORD = 0x0004; +extern "system" { + pub fn GetTouchInputInfo( + hTouchInput: HTOUCHINPUT, + cInputs: c_uint, + pInputs: PTOUCHINPUT, + cbSize: c_int, + ) -> BOOL; + pub fn CloseTouchInputHandle( + hTouchInput: HTOUCHINPUT, + ) -> BOOL; +} +pub const TWF_FINETOUCH: DWORD = 0x00000001; +pub const TWF_WANTPALM: DWORD = 0x00000002; +extern "system" { + pub fn RegisterTouchWindow( + hWnd: HWND, + flags: ULONG, + ) -> BOOL; + pub fn UnregisterTouchWindow( + hwnd: HWND, + ) -> BOOL; + pub fn IsTouchWindow( + hwnd: HWND, + pulFlags: PULONG, + ) -> BOOL; +} +ENUM!{enum POINTER_INPUT_TYPE { + PT_POINTER = 0x00000001, + PT_TOUCH = 0x00000002, + PT_PEN = 0x00000003, + PT_MOUSE = 0x00000004, + PT_TOUCHPAD = 0x00000005, +}} +ENUM!{enum POINTER_FLAGS { + POINTER_FLAG_NONE = 0x00000000, + POINTER_FLAG_NEW = 0x00000001, + POINTER_FLAG_INRANGE = 0x00000002, + POINTER_FLAG_INCONTACT = 0x00000004, + POINTER_FLAG_FIRSTBUTTON = 0x00000010, + POINTER_FLAG_SECONDBUTTON = 0x00000020, + POINTER_FLAG_THIRDBUTTON = 0x00000040, + POINTER_FLAG_FOURTHBUTTON = 0x00000080, + POINTER_FLAG_FIFTHBUTTON = 0x00000100, + POINTER_FLAG_PRIMARY = 0x00002000, + POINTER_FLAG_CONFIDENCE = 0x00004000, + POINTER_FLAG_CANCELED = 0x00008000, + POINTER_FLAG_DOWN = 0x00010000, + POINTER_FLAG_UPDATE = 0x00020000, + POINTER_FLAG_UP = 0x00040000, + POINTER_FLAG_WHEEL = 0x00080000, + POINTER_FLAG_HWHEEL = 0x00100000, + POINTER_FLAG_CAPTURECHANGED = 0x00200000, + POINTER_FLAG_HASTRANSFORM = 0x00400000, +}} +pub const POINTER_MOD_SHIFT: DWORD = 0x0004; +pub const POINTER_MOD_CTRL: DWORD = 0x0008; +ENUM!{enum POINTER_BUTTON_CHANGE_TYPE { + POINTER_CHANGE_NONE, + POINTER_CHANGE_FIRSTBUTTON_DOWN, + POINTER_CHANGE_FIRSTBUTTON_UP, + POINTER_CHANGE_SECONDBUTTON_DOWN, + POINTER_CHANGE_SECONDBUTTON_UP, + POINTER_CHANGE_THIRDBUTTON_DOWN, + POINTER_CHANGE_THIRDBUTTON_UP, + POINTER_CHANGE_FOURTHBUTTON_DOWN, + POINTER_CHANGE_FOURTHBUTTON_UP, + POINTER_CHANGE_FIFTHBUTTON_DOWN, + POINTER_CHANGE_FIFTHBUTTON_UP, +}} +STRUCT!{struct POINTER_INFO { + pointerType: POINTER_INPUT_TYPE, + pointerId: UINT32, + frameId: UINT32, + pointerFlags: POINTER_FLAGS, + sourceDevice: HANDLE, + hwndTarget: HWND, + ptPixelLocation: POINT, + ptHimetricLocation: POINT, + ptPixelLocationRaw: POINT, + ptHimetricLocationRaw: POINT, + dwTime: DWORD, + historyCount: UINT32, + InputData: INT32, + dwKeyStates: DWORD, + PerformanceCount: UINT64, + ButtonChangeType: POINTER_BUTTON_CHANGE_TYPE, +}} +ENUM!{enum TOUCH_FLAGS { + TOUCH_FLAG_NONE = 0x00000000, +}} +ENUM!{enum TOUCH_MASK { + TOUCH_MASK_NONE = 0x00000000, + TOUCH_MASK_CONTACTAREA = 0x00000001, + TOUCH_MASK_ORIENTATION = 0x00000002, + TOUCH_MASK_PRESSURE = 0x00000004, +}} +STRUCT!{struct POINTER_TOUCH_INFO { + pointerInfo: POINTER_INFO, + touchFlags: TOUCH_FLAGS, + touchMask: TOUCH_MASK, + rcContact: RECT, + rcContactRaw: RECT, + orientation: UINT32, + pressure: UINT32, +}} +ENUM!{enum PEN_FLAGS { + PEN_FLAG_NONE = 0x00000000, + PEN_FLAG_BARREL = 0x00000001, + PEN_FLAG_INVERTED = 0x00000002, + PEN_FLAG_ERASER = 0x00000004, +}} +ENUM!{enum PEN_MASK { + PEN_MASK_NONE = 0x00000000, + PEN_MASK_PRESSURE = 0x00000001, + PEN_MASK_ROTATION = 0x00000002, + PEN_MASK_TILT_X = 0x00000004, + PEN_MASK_TILT_Y = 0x00000008, +}} +STRUCT!{struct POINTER_PEN_INFO { + pointerInfo: POINTER_INFO, + penFlags: PEN_FLAGS, + penMask: PEN_MASK, + pressure: UINT32, + rotation: UINT32, + tiltX: INT32, + tiltY: INT32, +}} +pub const POINTER_MESSAGE_FLAG_NEW: DWORD = 0x00000001; +pub const POINTER_MESSAGE_FLAG_INRANGE: DWORD = 0x00000002; +pub const POINTER_MESSAGE_FLAG_INCONTACT: DWORD = 0x00000004; +pub const POINTER_MESSAGE_FLAG_FIRSTBUTTON: DWORD = 0x00000010; +pub const POINTER_MESSAGE_FLAG_SECONDBUTTON: DWORD = 0x00000020; +pub const POINTER_MESSAGE_FLAG_THIRDBUTTON: DWORD = 0x00000040; +pub const POINTER_MESSAGE_FLAG_FOURTHBUTTON: DWORD = 0x00000080; +pub const POINTER_MESSAGE_FLAG_FIFTHBUTTON: DWORD = 0x00000100; +pub const POINTER_MESSAGE_FLAG_PRIMARY: DWORD = 0x00002000; +pub const POINTER_MESSAGE_FLAG_CONFIDENCE: DWORD = 0x00004000; +pub const POINTER_MESSAGE_FLAG_CANCELED: DWORD = 0x00008000; +pub const PA_ACTIVATE: UINT = MA_ACTIVATE; +pub const PA_NOACTIVATE: UINT = MA_NOACTIVATE; +pub const MAX_TOUCH_COUNT: UINT32 = 256; +pub const TOUCH_FEEDBACK_DEFAULT: DWORD = 0x1; +pub const TOUCH_FEEDBACK_INDIRECT: DWORD = 0x2; +pub const TOUCH_FEEDBACK_NONE: DWORD = 0x3; +extern "system" { + pub fn InitializeTouchInjection( + maxCount: UINT32, + dwMode: DWORD, + ) -> BOOL; + pub fn InjectTouchInput( + count: UINT32, + contacts: *const POINTER_TOUCH_INFO, + ) -> BOOL; +} +STRUCT!{struct USAGE_PROPERTIES { + level: USHORT, + page: USHORT, + usage: USHORT, + logicalMinimum: INT32, + logicalMaximum: INT32, + unit: USHORT, + exponent: USHORT, + count: BYTE, + physicalMinimum: INT32, + physicalMaximum: INT32, +}} +pub type PUSAGE_PROPERTIES = *mut USAGE_PROPERTIES; +UNION!{union POINTER_TYPE_INFO_u { + [u64; 17] [u64; 18], + touchInfo touchInfo_mut: POINTER_TOUCH_INFO, + penInfo penInfo_mut: POINTER_PEN_INFO, +}} +STRUCT!{struct POINTER_TYPE_INFO { + type_: POINTER_INPUT_TYPE, + u: POINTER_TYPE_INFO_u, +}} +pub type PPOINTER_TYPE_INFO = *mut POINTER_TYPE_INFO; +STRUCT!{struct INPUT_INJECTION_VALUE { + page: USHORT, + usage: USHORT, + value: INT32, + index: USHORT, +}} +pub type PINPUT_INJECTION_VALUE = *mut INPUT_INJECTION_VALUE; +extern "system" { + pub fn GetPointerType( + pointerId: UINT32, + pointerType: *mut POINTER_INPUT_TYPE, + ) -> BOOL; + pub fn GetPointerCursorId( + pointerId: UINT32, + cursorId: *mut UINT32, + ) -> BOOL; + pub fn GetPointerInfo( + pointerId: UINT32, + pointerInfo: *mut POINTER_INFO, + ) -> BOOL; + pub fn GetPointerInfoHistory( + pointerId: UINT32, + entriesCount: *mut UINT32, + pointerInfo: *mut POINTER_INFO, + ) -> BOOL; + pub fn GetPointerFrameInfo( + pointerId: UINT32, + pointerCount: *mut UINT32, + pointerInfo: *mut POINTER_INFO, + ) -> BOOL; + pub fn GetPointerFrameInfoHistory( + pointerId: UINT32, + entriesCount: *mut UINT32, + pointerCount: *mut UINT32, + pointerInfo: *mut POINTER_INFO, + ) -> BOOL; + pub fn GetPointerTouchInfo( + pointerId: UINT32, + touchInfo: *mut POINTER_TOUCH_INFO, + ) -> BOOL; + pub fn GetPointerTouchInfoHistory( + pointerId: UINT32, + entriesCount: *mut UINT32, + touchInfo: *mut POINTER_TOUCH_INFO, + ) -> BOOL; + pub fn GetPointerFrameTouchInfo( + pointerId: UINT32, + pointerCount: *mut UINT32, + touchInfo: *mut POINTER_TOUCH_INFO, + ) -> BOOL; + pub fn GetPointerFrameTouchInfoHistory( + pointerId: UINT32, + entriesCount: *mut UINT32, + pointerCount: *mut UINT32, + touchInfo: *mut POINTER_TOUCH_INFO, + ) -> BOOL; + pub fn GetPointerPenInfo( + pointerId: UINT32, + penInfo: *mut POINTER_PEN_INFO, + ) -> BOOL; + pub fn GetPointerPenInfoHistory( + pointerId: UINT32, + entriesCount: *mut UINT32, + penInfo: *mut POINTER_PEN_INFO, + ) -> BOOL; + pub fn GetPointerFramePenInfo( + pointerId: UINT32, + pointerCount: *mut UINT32, + penInfo: *mut POINTER_PEN_INFO, + ) -> BOOL; + pub fn GetPointerFramePenInfoHistory( + pointerId: UINT32, + entriesCount: *mut UINT32, + pointerCount: *mut UINT32, + penInfo: *mut POINTER_PEN_INFO, + ) -> BOOL; + pub fn SkipPointerFrameMessages( + pointerId: UINT32, + ) -> BOOL; + pub fn RegisterPointerInputTarget( + hwnd: HWND, + pointerType: POINTER_INPUT_TYPE, + ) -> BOOL; + pub fn UnregisterPointerInputTarget( + hwnd: HWND, + pointerType: POINTER_INPUT_TYPE, + ) -> BOOL; + pub fn RegisterPointerInputTargetEx( + hwnd: HWND, + pointerType: POINTER_INPUT_TYPE, + fObserve: BOOL, + ) -> BOOL; + pub fn UnregisterPointerInputTargetEx( + hwnd: HWND, + pointerType: POINTER_INPUT_TYPE, + ) -> BOOL; + pub fn EnableMouseInPointer( + fEnable: BOOL, + ) -> BOOL; + pub fn IsMouseInPointerEnabled() -> BOOL; +} +pub const TOUCH_HIT_TESTING_DEFAULT: ULONG = 0x0; +pub const TOUCH_HIT_TESTING_CLIENT: ULONG = 0x1; +pub const TOUCH_HIT_TESTING_NONE: ULONG = 0x2; +extern "system" { + pub fn RegisterTouchHitTestingWindow( + hwnd: HWND, + value: ULONG, + ) -> BOOL; +} +STRUCT!{struct TOUCH_HIT_TESTING_PROXIMITY_EVALUATION { + score: UINT16, + adjustedPoint: POINT, +}} +pub type PTOUCH_HIT_TESTING_PROXIMITY_EVALUATION = *mut TOUCH_HIT_TESTING_PROXIMITY_EVALUATION; +STRUCT!{struct TOUCH_HIT_TESTING_INPUT { + pointerId: UINT32, + point: POINT, + boundingBox: RECT, + nonOccludedBoundingBox: RECT, + orientation: UINT32, +}} +pub type PTOUCH_HIT_TESTING_INPUT = *mut TOUCH_HIT_TESTING_INPUT; +pub const TOUCH_HIT_TESTING_PROXIMITY_CLOSEST: UINT16 = 0x0; +pub const TOUCH_HIT_TESTING_PROXIMITY_FARTHEST: UINT16 = 0xFFF; +extern "system" { + pub fn EvaluateProximityToRect( + controlBoundingBox: *const RECT, + pHitTestingInput: *const TOUCH_HIT_TESTING_INPUT, + pProximityEval: *mut TOUCH_HIT_TESTING_PROXIMITY_EVALUATION, + ) -> BOOL; + pub fn EvaluateProximityToPolygon( + numVertices: UINT32, + controlPolygon: *const POINT, + pHitTestingInput: *const TOUCH_HIT_TESTING_INPUT, + pProximityEval: *mut TOUCH_HIT_TESTING_PROXIMITY_EVALUATION, + ) -> BOOL; + pub fn PackTouchHitTestingProximityEvaluation( + pHitTestingInput: *const TOUCH_HIT_TESTING_INPUT, + pProximityEval: *const TOUCH_HIT_TESTING_PROXIMITY_EVALUATION, + ) -> LRESULT; +} +ENUM!{enum FEEDBACK_TYPE { + FEEDBACK_TOUCH_CONTACTVISUALIZATION = 1, + FEEDBACK_PEN_BARRELVISUALIZATION = 2, + FEEDBACK_PEN_TAP = 3, + FEEDBACK_PEN_DOUBLETAP = 4, + FEEDBACK_PEN_PRESSANDHOLD = 5, + FEEDBACK_PEN_RIGHTTAP = 6, + FEEDBACK_TOUCH_TAP = 7, + FEEDBACK_TOUCH_DOUBLETAP = 8, + FEEDBACK_TOUCH_PRESSANDHOLD = 9, + FEEDBACK_TOUCH_RIGHTTAP = 10, + FEEDBACK_GESTURE_PRESSANDTAP = 11, + FEEDBACK_MAX = 0xFFFFFFFF, +}} +pub const GWFS_INCLUDE_ANCESTORS: DWORD = 0x00000001; +extern "system" { + pub fn GetWindowFeedbackSetting( + hwnd: HWND, + feedback: FEEDBACK_TYPE, + dwFlags: DWORD, + pSize: *mut UINT32, + config: *mut VOID, + ) -> BOOL; + pub fn SetWindowFeedbackSetting( + hwnd: HWND, + feedback: FEEDBACK_TYPE, + dwFlags: DWORD, + size: UINT32, + configuration: *const VOID, + ) -> BOOL; +} +STRUCT!{struct INPUT_TRANSFORM { + m: [[f32; 4]; 4], +}} +extern "system" { + pub fn GetPointerInputTransform( + pointerId: UINT32, + historyCount: UINT32, + inputTransform: *mut INPUT_TRANSFORM, + ) -> BOOL; +} +STRUCT!{struct LASTINPUTINFO { + cbSize: UINT, + dwTime: DWORD, +}} +pub type PLASTINPUTINFO = *mut LASTINPUTINFO; +extern "system" { + pub fn GetLastInputInfo( + plii: PLASTINPUTINFO, + ) -> BOOL; + pub fn MapVirtualKeyA( + nCode: UINT, + uMapType: UINT, + ) -> UINT; + pub fn MapVirtualKeyW( + nCode: UINT, + uMapType: UINT, + ) -> UINT; + pub fn MapVirtualKeyExA( + nCode: UINT, + uMapType: UINT, + dwhkl: HKL, + ) -> UINT; + pub fn MapVirtualKeyExW( + nCode: UINT, + uMapType: UINT, + dwhkl: HKL, + ) -> UINT; +} +pub const MAPVK_VK_TO_VSC: UINT = 0; +pub const MAPVK_VSC_TO_VK: UINT = 1; +pub const MAPVK_VK_TO_CHAR: UINT = 2; +pub const MAPVK_VSC_TO_VK_EX: UINT = 3; +pub const MAPVK_VK_TO_VSC_EX: UINT = 4; +extern "system" { + pub fn GetInputState() -> BOOL; + pub fn GetQueueStatus( + flags: UINT, + ) -> DWORD; + pub fn GetCapture() -> HWND; + pub fn SetCapture( + hWnd: HWND, + ) -> HWND; + pub fn ReleaseCapture() -> BOOL; + pub fn MsgWaitForMultipleObjects( + nCount: DWORD, + pHandles: *const HANDLE, + fWaitAll: BOOL, + dwMilliseconds: DWORD, + dwWakeMask: DWORD, + ) -> DWORD; + pub fn MsgWaitForMultipleObjectsEx( + nCount: DWORD, + pHandles: *const HANDLE, + dwMilliseconds: DWORD, + dwWakeMask: DWORD, + dwFlags: DWORD, + ) -> DWORD; +} +pub const MWMO_WAITALL: UINT = 0x0001; +pub const MWMO_ALERTABLE: UINT = 0x0002; +pub const MWMO_INPUTAVAILABLE: UINT = 0x0004; +pub const QS_KEY: UINT = 0x0001; +pub const QS_MOUSEMOVE: UINT = 0x0002; +pub const QS_MOUSEBUTTON: UINT = 0x0004; +pub const QS_POSTMESSAGE: UINT = 0x0008; +pub const QS_TIMER: UINT = 0x0010; +pub const QS_PAINT: UINT = 0x0020; +pub const QS_SENDMESSAGE: UINT = 0x0040; +pub const QS_HOTKEY: UINT = 0x0080; +pub const QS_ALLPOSTMESSAGE: UINT = 0x0100; +pub const QS_RAWINPUT: UINT = 0x0400; +pub const QS_TOUCH: UINT = 0x0800; +pub const QS_POINTER: UINT = 0x1000; +pub const QS_MOUSE: UINT = QS_MOUSEMOVE | QS_MOUSEBUTTON; +pub const QS_INPUT: UINT = QS_MOUSE | QS_KEY | QS_RAWINPUT | QS_TOUCH | QS_POINTER; +pub const QS_ALLEVENTS: UINT = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY; +pub const QS_ALLINPUT: UINT = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY + | QS_SENDMESSAGE; +pub const USER_TIMER_MAXIMUM: UINT = 0x7FFFFFFF; +pub const USER_TIMER_MINIMUM: UINT = 0x0000000A; +extern "system" { + pub fn SetTimer( + hWnd: HWND, + nIDEvent: UINT_PTR, + uElapse: UINT, + lpTimerFunc: TIMERPROC, + ) -> UINT_PTR; +} +pub const TIMERV_DEFAULT_COALESCING: ULONG = 0; +pub const TIMERV_NO_COALESCING: ULONG = 0xFFFFFFFF; +pub const TIMERV_COALESCING_MIN: ULONG = 1; +pub const TIMERV_COALESCING_MAX: ULONG = 0x7FFFFFF5; +extern "system" { + pub fn SetCoalescableTimer( + hWnd: HWND, + nIDEvent: UINT_PTR, + uElapse: UINT, + lpTimerFunc: TIMERPROC, + uToleranceDelay: ULONG, + ) -> UINT_PTR; + pub fn KillTimer( + hWnd: HWND, + uIDEvent: UINT_PTR, + ) -> BOOL; + pub fn IsWindowUnicode( + hWnd: HWND, + ) -> BOOL; + pub fn EnableWindow( + hWnd: HWND, + bEnable: BOOL, + ) -> BOOL; + pub fn IsWindowEnabled( + hWnd: HWND, + ) -> BOOL; + pub fn LoadAcceleratorsA( + hInstance: HINSTANCE, + lpTableName: LPCSTR, + ) -> HACCEL; + pub fn LoadAcceleratorsW( + hInstance: HINSTANCE, + lpTableName: LPCWSTR, + ) -> HACCEL; + pub fn CreateAcceleratorTableA( + paccel: LPACCEL, + cAccel: c_int, + ) -> HACCEL; + pub fn CreateAcceleratorTableW( + paccel: LPACCEL, + cAccel: c_int, + ) -> HACCEL; + pub fn DestroyAcceleratorTable( + hAccel: HACCEL, + ) -> BOOL; + pub fn CopyAcceleratorTableA( + hAccelSrc: HACCEL, + lpAccelDst: LPACCEL, + cAccelEntries: c_int, + ) -> c_int; + pub fn CopyAcceleratorTableW( + hAccelSrc: HACCEL, + lpAccelDst: LPACCEL, + cAccelEntries: c_int, + ) -> c_int; + pub fn TranslateAcceleratorA( + hWnd: HWND, + hAccTable: HACCEL, + lpMsg: LPMSG, + ) -> c_int; + pub fn TranslateAcceleratorW( + hWnd: HWND, + hAccTable: HACCEL, + lpMsg: LPMSG, + ) -> c_int; +} +pub const SM_CXSCREEN: c_int = 0; +pub const SM_CYSCREEN: c_int = 1; +pub const SM_CXVSCROLL: c_int = 2; +pub const SM_CYHSCROLL: c_int = 3; +pub const SM_CYCAPTION: c_int = 4; +pub const SM_CXBORDER: c_int = 5; +pub const SM_CYBORDER: c_int = 6; +pub const SM_CXDLGFRAME: c_int = 7; +pub const SM_CYDLGFRAME: c_int = 8; +pub const SM_CYVTHUMB: c_int = 9; +pub const SM_CXHTHUMB: c_int = 10; +pub const SM_CXICON: c_int = 11; +pub const SM_CYICON: c_int = 12; +pub const SM_CXCURSOR: c_int = 13; +pub const SM_CYCURSOR: c_int = 14; +pub const SM_CYMENU: c_int = 15; +pub const SM_CXFULLSCREEN: c_int = 16; +pub const SM_CYFULLSCREEN: c_int = 17; +pub const SM_CYKANJIWINDOW: c_int = 18; +pub const SM_MOUSEPRESENT: c_int = 19; +pub const SM_CYVSCROLL: c_int = 20; +pub const SM_CXHSCROLL: c_int = 21; +pub const SM_DEBUG: c_int = 22; +pub const SM_SWAPBUTTON: c_int = 23; +pub const SM_RESERVED1: c_int = 24; +pub const SM_RESERVED2: c_int = 25; +pub const SM_RESERVED3: c_int = 26; +pub const SM_RESERVED4: c_int = 27; +pub const SM_CXMIN: c_int = 28; +pub const SM_CYMIN: c_int = 29; +pub const SM_CXSIZE: c_int = 30; +pub const SM_CYSIZE: c_int = 31; +pub const SM_CXFRAME: c_int = 32; +pub const SM_CYFRAME: c_int = 33; +pub const SM_CXMINTRACK: c_int = 34; +pub const SM_CYMINTRACK: c_int = 35; +pub const SM_CXDOUBLECLK: c_int = 36; +pub const SM_CYDOUBLECLK: c_int = 37; +pub const SM_CXICONSPACING: c_int = 38; +pub const SM_CYICONSPACING: c_int = 39; +pub const SM_MENUDROPALIGNMENT: c_int = 40; +pub const SM_PENWINDOWS: c_int = 41; +pub const SM_DBCSENABLED: c_int = 42; +pub const SM_CMOUSEBUTTONS: c_int = 43; +pub const SM_CXFIXEDFRAME: c_int = SM_CXDLGFRAME; +pub const SM_CYFIXEDFRAME: c_int = SM_CYDLGFRAME; +pub const SM_CXSIZEFRAME: c_int = SM_CXFRAME; +pub const SM_CYSIZEFRAME: c_int = SM_CYFRAME; +pub const SM_SECURE: c_int = 44; +pub const SM_CXEDGE: c_int = 45; +pub const SM_CYEDGE: c_int = 46; +pub const SM_CXMINSPACING: c_int = 47; +pub const SM_CYMINSPACING: c_int = 48; +pub const SM_CXSMICON: c_int = 49; +pub const SM_CYSMICON: c_int = 50; +pub const SM_CYSMCAPTION: c_int = 51; +pub const SM_CXSMSIZE: c_int = 52; +pub const SM_CYSMSIZE: c_int = 53; +pub const SM_CXMENUSIZE: c_int = 54; +pub const SM_CYMENUSIZE: c_int = 55; +pub const SM_ARRANGE: c_int = 56; +pub const SM_CXMINIMIZED: c_int = 57; +pub const SM_CYMINIMIZED: c_int = 58; +pub const SM_CXMAXTRACK: c_int = 59; +pub const SM_CYMAXTRACK: c_int = 60; +pub const SM_CXMAXIMIZED: c_int = 61; +pub const SM_CYMAXIMIZED: c_int = 62; +pub const SM_NETWORK: c_int = 63; +pub const SM_CLEANBOOT: c_int = 67; +pub const SM_CXDRAG: c_int = 68; +pub const SM_CYDRAG: c_int = 69; +pub const SM_SHOWSOUNDS: c_int = 70; +pub const SM_CXMENUCHECK: c_int = 71; +pub const SM_CYMENUCHECK: c_int = 72; +pub const SM_SLOWMACHINE: c_int = 73; +pub const SM_MIDEASTENABLED: c_int = 74; +pub const SM_MOUSEWHEELPRESENT: c_int = 75; +pub const SM_XVIRTUALSCREEN: c_int = 76; +pub const SM_YVIRTUALSCREEN: c_int = 77; +pub const SM_CXVIRTUALSCREEN: c_int = 78; +pub const SM_CYVIRTUALSCREEN: c_int = 79; +pub const SM_CMONITORS: c_int = 80; +pub const SM_SAMEDISPLAYFORMAT: c_int = 81; +pub const SM_IMMENABLED: c_int = 82; +pub const SM_CXFOCUSBORDER: c_int = 83; +pub const SM_CYFOCUSBORDER: c_int = 84; +pub const SM_TABLETPC: c_int = 86; +pub const SM_MEDIACENTER: c_int = 87; +pub const SM_STARTER: c_int = 88; +pub const SM_SERVERR2: c_int = 89; +pub const SM_MOUSEHORIZONTALWHEELPRESENT: c_int = 91; +pub const SM_CXPADDEDBORDER: c_int = 92; +pub const SM_DIGITIZER: c_int = 94; +pub const SM_MAXIMUMTOUCHES: c_int = 95; +pub const SM_CMETRICS: c_int = 97; +pub const SM_REMOTESESSION: c_int = 0x1000; +pub const SM_SHUTTINGDOWN: c_int = 0x2000; +pub const SM_REMOTECONTROL: c_int = 0x2001; +pub const SM_CARETBLINKINGENABLED: c_int = 0x2002; +pub const SM_CONVERTIBLESLATEMODE: c_int = 0x2003; +pub const SM_SYSTEMDOCKED: c_int = 0x2004; +extern "system" { + pub fn GetSystemMetrics( + nIndex: c_int, + ) -> c_int; + pub fn GetSystemMetricsForDpi( + nIndex: c_int, + dpi: UINT, + ) -> c_int; + pub fn LoadMenuA( + hInstance: HINSTANCE, + lpMenuName: LPCSTR, + ) -> HMENU; + pub fn LoadMenuW( + hInstance: HINSTANCE, + lpMenuName: LPCWSTR, + ) -> HMENU; + pub fn LoadMenuIndirectA( + lpMenuTemplate: *const MENUTEMPLATEA, + ) -> HMENU; + pub fn LoadMenuIndirectW( + lpMenuTemplate: *const MENUTEMPLATEW, + ) -> HMENU; + pub fn GetMenu( + hWnd: HWND, + ) -> HMENU; + pub fn SetMenu( + hWnd: HWND, + hMenu: HMENU, + ) -> BOOL; + pub fn ChangeMenuA( + hMenu: HMENU, + cmd: UINT, + lpszNewItem: LPCSTR, + cmdInsert: UINT, + flags: UINT, + ) -> BOOL; + pub fn ChangeMenuW( + hMenu: HMENU, + cmd: UINT, + lpszNewItem: LPCWSTR, + cmdInsert: UINT, + flags: UINT, + ) -> BOOL; + pub fn HiliteMenuItem( + hWnd: HWND, + hMenu: HMENU, + uIDHiliteItem: UINT, + uHilite: UINT, + ) -> BOOL; + pub fn GetMenuStringA( + hMenu: HMENU, + uIDItem: UINT, + lpString: LPSTR, + cchMax: c_int, + flags: UINT, + ) -> c_int; + pub fn GetMenuStringW( + hMenu: HMENU, + uIDItem: UINT, + lpString: LPWSTR, + cchMax: c_int, + flags: UINT, + ) -> c_int; + pub fn GetMenuState( + hMenu: HMENU, + uId: UINT, + uFlags: UINT, + ) -> UINT; + pub fn DrawMenuBar( + hwnd: HWND, + ) -> BOOL; +} +pub const PMB_ACTIVE: DWORD = 0x00000001; +extern "system" { + pub fn GetSystemMenu( + hWnd: HWND, + bRevert: BOOL, + ) -> HMENU; + pub fn CreateMenu() -> HMENU; + pub fn CreatePopupMenu() ->HMENU; + pub fn DestroyMenu( + hMenu: HMENU, + ) -> BOOL; + pub fn CheckMenuItem( + hMenu: HMENU, + uIDCheckItem: UINT, + uCheck: UINT, + ) -> DWORD; + pub fn EnableMenuItem( + hMenu: HMENU, + uIDEnableItem: UINT, + uEnable: UINT, + ) -> BOOL; + pub fn GetSubMenu( + hMenu: HMENU, + nPos: c_int, + ) -> HMENU; + pub fn GetMenuItemID( + hMenu: HMENU, + nPos: c_int, + ) -> UINT; + pub fn GetMenuItemCount( + hMenu: HMENU, + ) -> c_int; + pub fn InsertMenuA( + hMenu: HMENU, + uPosition: UINT, + uFlags: UINT, + uIDNewItem: UINT_PTR, + lpNewItem: LPCSTR, + ) -> BOOL; + pub fn InsertMenuW( + hMenu: HMENU, + uPosition: UINT, + uFlags: UINT, + uIDNewItem: UINT_PTR, + lpNewItem: LPCWSTR, + ) -> BOOL; + pub fn AppendMenuA( + hMenu: HMENU, + uFlags: UINT, + uIDNewItem: UINT_PTR, + lpNewItem: LPCSTR, + ) -> BOOL; + pub fn AppendMenuW( + hMenu: HMENU, + uFlags: UINT, + uIDNewItem: UINT_PTR, + lpNewItem: LPCWSTR, + ) -> BOOL; + pub fn ModifyMenuA( + hMnu: HMENU, + uPosition: UINT, + uFlags: UINT, + uIDNewItem: UINT_PTR, + lpNewItem: LPCSTR, + ) -> BOOL; + pub fn ModifyMenuW( + hMnu: HMENU, + uPosition: UINT, + uFlags: UINT, + uIDNewItem: UINT_PTR, + lpNewItem: LPCWSTR, + ) -> BOOL; + pub fn RemoveMenu( + hMenu: HMENU, + uPosition: UINT, + uFlags: UINT, + ) -> BOOL; + pub fn DeleteMenu( + hMenu: HMENU, + uPosition: UINT, + uFlags: UINT, + ) -> BOOL; + pub fn SetMenuItemBitmaps( + hMenu: HMENU, + uPosition: UINT, + uFlags: UINT, + hBitmapUnchecked: HBITMAP, + hBitmapChecked: HBITMAP, + ) -> BOOL; + pub fn GetMenuCheckMarkDimensions() -> LONG; + pub fn TrackPopupMenu( + hMenu: HMENU, + uFlags: UINT, + x: c_int, + y: c_int, + nReserved: c_int, + hWnd: HWND, + prcRect: *const RECT, + ) -> BOOL; +} +pub const MNC_IGNORE: DWORD = 0; +pub const MNC_CLOSE: DWORD = 1; +pub const MNC_EXECUTE: DWORD = 2; +pub const MNC_SELECT: DWORD = 3; +STRUCT!{struct TPMPARAMS { + cbSize: UINT, + rcExclude: RECT, +}} +pub type LPTPMPARAMS = *mut TPMPARAMS; +extern "system" { + pub fn TrackPopupMenuEx( + hMenu: HMENU, + uFlags: UINT, + x: INT, + y: INT, + hwnd: HWND, + lptpm: LPTPMPARAMS, + ) -> BOOL; + pub fn CalculatePopupWindowPosition( + anchorPoint: *const POINT, + windowSize: *const SIZE, + flags: UINT, + excludeRect: *mut RECT, + popupWindowPosition: *mut RECT, + ) -> BOOL; +} +pub const MNS_NOCHECK: DWORD = 0x80000000; +pub const MNS_MODELESS: DWORD = 0x40000000; +pub const MNS_DRAGDROP: DWORD = 0x20000000; +pub const MNS_AUTODISMISS: DWORD = 0x10000000; +pub const MNS_NOTIFYBYPOS: DWORD = 0x08000000; +pub const MNS_CHECKORBMP: DWORD = 0x04000000; +pub const MIM_MAXHEIGHT: DWORD = 0x00000001; +pub const MIM_BACKGROUND: DWORD = 0x00000002; +pub const MIM_HELPID: DWORD = 0x00000004; +pub const MIM_MENUDATA: DWORD = 0x00000008; +pub const MIM_STYLE: DWORD = 0x00000010; +pub const MIM_APPLYTOSUBMENUS: DWORD = 0x80000000; +STRUCT!{struct MENUINFO { + cbSize: DWORD, + fMask: DWORD, + dwStyle: DWORD, + cyMax: UINT, + hbrBack: HBRUSH, + dwContextHelpID: DWORD, + dwMenuData: ULONG_PTR, +}} +pub type LPMENUINFO = *mut MENUINFO; +pub type LPCMENUINFO = *const MENUINFO; +extern "system" { + pub fn GetMenuInfo( + hMenu: HMENU, + lpcmi: LPMENUINFO, + ) -> BOOL; + pub fn SetMenuInfo( + hMenu: HMENU, + lpcmi: LPCMENUINFO, + ) -> BOOL; + pub fn EndMenu( + hMenu: HMENU, + uFlags: UINT, + uIDNewItem: UINT_PTR, + lpNewItem: LPCSTR, + ) -> BOOL; +} +pub const MND_CONTINUE: DWORD = 0; +pub const MND_ENDMENU: DWORD = 1; +STRUCT!{struct MENUGETOBJECTINFO { + dwFlags: DWORD, + uPos: UINT, + hmenu: HMENU, + riid: PVOID, + pvObj: PVOID, +}} +pub type PMENUGETOBJECTINFO = *mut MENUGETOBJECTINFO; +pub const MNGOF_TOPGAP: DWORD = 0x00000001; +pub const MNGOF_BOTTOMGAP: DWORD = 0x00000002; +pub const MNGO_NOINTERFACE: DWORD = 0x00000000; +pub const MNGO_NOERROR: DWORD = 0x00000001; +pub const MIIM_STATE: DWORD = 0x00000001; +pub const MIIM_ID: DWORD = 0x00000002; +pub const MIIM_SUBMENU: DWORD = 0x00000004; +pub const MIIM_CHECKMARKS: DWORD = 0x00000008; +pub const MIIM_TYPE: DWORD = 0x00000010; +pub const MIIM_DATA: DWORD = 0x00000020; +pub const MIIM_STRING: DWORD = 0x00000040; +pub const MIIM_BITMAP: DWORD = 0x00000080; +pub const MIIM_FTYPE: DWORD = 0x00000100; +pub const HBMMENU_CALLBACK: HBITMAP = -1isize as HBITMAP; +pub const HBMMENU_SYSTEM: HBITMAP = 1 as HBITMAP; +pub const HBMMENU_MBAR_RESTORE: HBITMAP = 2 as HBITMAP; +pub const HBMMENU_MBAR_MINIMIZE: HBITMAP = 3 as HBITMAP; +pub const HBMMENU_MBAR_CLOSE: HBITMAP = 5 as HBITMAP; +pub const HBMMENU_MBAR_CLOSE_D: HBITMAP = 6 as HBITMAP; +pub const HBMMENU_MBAR_MINIMIZE_D: HBITMAP = 7 as HBITMAP; +pub const HBMMENU_POPUP_CLOSE: HBITMAP = 8 as HBITMAP; +pub const HBMMENU_POPUP_RESTORE: HBITMAP = 9 as HBITMAP; +pub const HBMMENU_POPUP_MAXIMIZE: HBITMAP = 10 as HBITMAP; +pub const HBMMENU_POPUP_MINIMIZE: HBITMAP = 11 as HBITMAP; +STRUCT!{struct MENUITEMINFOA { + cbSize: UINT, + fMask: UINT, + fType: UINT, + fState: UINT, + wID: UINT, + hSubMenu: HMENU, + hbmpChecked: HBITMAP, + hbmpUnchecked: HBITMAP, + dwItemData: ULONG_PTR, + dwTypeData: LPSTR, + cch: UINT, + hbmpItem: HBITMAP, +}} +pub type LPMENUITEMINFOA = *mut MENUITEMINFOA; +pub type LPCMENUITEMINFOA = *const MENUITEMINFOA; +STRUCT!{struct MENUITEMINFOW { + cbSize: UINT, + fMask: UINT, + fType: UINT, + fState: UINT, + wID: UINT, + hSubMenu: HMENU, + hbmpChecked: HBITMAP, + hbmpUnchecked: HBITMAP, + dwItemData: ULONG_PTR, + dwTypeData: LPWSTR, + cch: UINT, + hbmpItem: HBITMAP, +}} +pub type LPMENUITEMINFOW = *mut MENUITEMINFOW; +pub type LPCMENUITEMINFOW = *const MENUITEMINFOW; +extern "system" { + pub fn InsertMenuItemA( + hmenu: HMENU, + item: UINT, + fByPosition: BOOL, + lpmi: LPCMENUITEMINFOA, + ) -> BOOL; + pub fn InsertMenuItemW( + hmenu: HMENU, + item: UINT, + fByPosition: BOOL, + lpmi: LPCMENUITEMINFOW, + ) -> BOOL; + pub fn GetMenuItemInfoA( + hMenu: HMENU, + uItem: UINT, + fByPosition: BOOL, + lpmii: LPMENUITEMINFOA, + ) -> BOOL; + pub fn GetMenuItemInfoW( + hMenu: HMENU, + uItem: UINT, + fByPosition: BOOL, + lpmii: LPMENUITEMINFOW, + ) -> BOOL; + pub fn SetMenuItemInfoA( + hmenu: HMENU, + item: UINT, + fByPositon: BOOL, + lpmii: LPCMENUITEMINFOA, + ) -> BOOL; + pub fn SetMenuItemInfoW( + hmenu: HMENU, + item: UINT, + fByPositon: BOOL, + lpmii: LPCMENUITEMINFOW, + ) -> BOOL; +} +pub const GMDI_USEDISABLED: DWORD = 0x0001; +pub const GMDI_GOINTOPOPUPS: DWORD = 0x0002; +extern "system" { + pub fn GetMenuDefaultItem( + hMenu: HMENU, + fByPos: UINT, + gmdiFlags: UINT, + ) -> UINT; + pub fn SetMenuDefaultItem( + hMenu: HMENU, + uItem: UINT, + fByPos: UINT, + ) -> BOOL; + pub fn GetMenuItemRect( + hWnd: HWND, + hMenu: HMENU, + uItem: UINT, + lprcItem: LPRECT, + ) -> BOOL; + pub fn MenuItemFromPoint( + hWnd: HWND, + hMenu: HMENU, + ptScreen: POINT, + ) -> c_int; +} +pub const TPM_LEFTBUTTON: UINT = 0x0000; +pub const TPM_RIGHTBUTTON: UINT = 0x0002; +pub const TPM_LEFTALIGN: UINT = 0x0000; +pub const TPM_CENTERALIGN: UINT = 0x0004; +pub const TPM_RIGHTALIGN: UINT = 0x0008; +pub const TPM_TOPALIGN: UINT = 0x0000; +pub const TPM_VCENTERALIGN: UINT = 0x0010; +pub const TPM_BOTTOMALIGN: UINT = 0x0020; +pub const TPM_HORIZONTAL: UINT = 0x0000; +pub const TPM_VERTICAL: UINT = 0x0040; +pub const TPM_NONOTIFY: UINT = 0x0080; +pub const TPM_RETURNCMD: UINT = 0x0100; +pub const TPM_RECURSE: UINT = 0x0001; +pub const TPM_HORPOSANIMATION: UINT = 0x0400; +pub const TPM_HORNEGANIMATION: UINT = 0x0800; +pub const TPM_VERPOSANIMATION: UINT = 0x1000; +pub const TPM_VERNEGANIMATION: UINT = 0x2000; +pub const TPM_NOANIMATION: UINT = 0x4000; +pub const TPM_LAYOUTRTL: UINT = 0x8000; +pub const TPM_WORKAREA: UINT = 0x10000; +STRUCT!{struct DROPSTRUCT { + hwndSource: HWND, + hwndSink: HWND, + wFmt: DWORD, + dwData: ULONG_PTR, + ptDrop: POINT, + dwControlData: DWORD, +}} +pub type PDROPSTRUCT = *mut DROPSTRUCT; +pub type LPDROPSTRUCT = *mut DROPSTRUCT; +pub const DOF_EXECUTABLE: DWORD = 0x8001; +pub const DOF_DOCUMENT: DWORD = 0x8002; +pub const DOF_DIRECTORY: DWORD = 0x8003; +pub const DOF_MULTIPLE: DWORD = 0x8004; +pub const DOF_PROGMAN: DWORD = 0x0001; +pub const DOF_SHELLDATA: DWORD = 0x0002; +pub const DO_DROPFILE: DWORD = 0x454C4946; +pub const DO_PRINTFILE: DWORD = 0x544E5250; +extern "system" { + pub fn DragObject( + hwndParent: HWND, + hwndFrom: HWND, + fmt: UINT, + data: ULONG_PTR, + hcur: HCURSOR, + ) -> DWORD; + pub fn DragDetect( + hwnd: HWND, + pt: POINT, + ) -> BOOL; + pub fn DrawIcon( + hDC: HDC, + x: c_int, + y: c_int, + hIcon: HICON, + ) -> BOOL; +} +pub const DT_TOP: UINT = 0x00000000; +pub const DT_LEFT: UINT = 0x00000000; +pub const DT_CENTER: UINT = 0x00000001; +pub const DT_RIGHT: UINT = 0x00000002; +pub const DT_VCENTER: UINT = 0x00000004; +pub const DT_BOTTOM: UINT = 0x00000008; +pub const DT_WORDBREAK: UINT = 0x00000010; +pub const DT_SINGLELINE: UINT = 0x00000020; +pub const DT_EXPANDTABS: UINT = 0x00000040; +pub const DT_TABSTOP: UINT = 0x00000080; +pub const DT_NOCLIP: UINT = 0x00000100; +pub const DT_EXTERNALLEADING: UINT = 0x00000200; +pub const DT_CALCRECT: UINT = 0x00000400; +pub const DT_NOPREFIX: UINT = 0x00000800; +pub const DT_INTERNAL: UINT = 0x00001000; +pub const DT_EDITCONTROL: UINT = 0x00002000; +pub const DT_PATH_ELLIPSIS: UINT = 0x00004000; +pub const DT_END_ELLIPSIS: UINT = 0x00008000; +pub const DT_MODIFYSTRING: UINT = 0x00010000; +pub const DT_RTLREADING: UINT = 0x00020000; +pub const DT_WORD_ELLIPSIS: UINT = 0x00040000; +pub const DT_NOFULLWIDTHCHARBREAK: UINT = 0x00080000; +pub const DT_HIDEPREFIX: UINT = 0x00100000; +pub const DT_PREFIXONLY: UINT = 0x00200000; +STRUCT!{struct DRAWTEXTPARAMS { + cbSize: UINT, + iTabLength: c_int, + iLeftMargin: c_int, + iRightMargin: c_int, + uiLengthDrawn: UINT, +}} +pub type LPDRAWTEXTPARAMS = *mut DRAWTEXTPARAMS; +extern "system" { + pub fn DrawTextA( + hdc: HDC, + lpchText: LPCSTR, + cchText: c_int, + lprc: LPRECT, + format: UINT, + ) -> c_int; + pub fn DrawTextW( + hdc: HDC, + lpchText: LPCWSTR, + cchText: c_int, + lprc: LPRECT, + format: UINT, + ) -> c_int; + pub fn DrawTextExA( + hdc: HDC, + lpchText: LPCSTR, + cchText: c_int, + lprc: LPRECT, + format: UINT, + lpdtp: LPDRAWTEXTPARAMS, + ) -> c_int; + pub fn DrawTextExW( + hdc: HDC, + lpchText: LPCWSTR, + cchText: c_int, + lprc: LPRECT, + format: UINT, + lpdtp: LPDRAWTEXTPARAMS, + ) -> c_int; + pub fn GrayStringA( + hDC: HDC, + hBrush: HBRUSH, + lpOutputFunc: GRAYSTRINGPROC, + lpData: LPARAM, + nCount: c_int, + X: c_int, + Y: c_int, + nWidth: c_int, + nHeight: c_int, + ) -> BOOL; + pub fn GrayStringW( + hDC: HDC, + hBrush: HBRUSH, + lpOutputFunc: GRAYSTRINGPROC, + lpData: LPARAM, + nCount: c_int, + X: c_int, + Y: c_int, + nWidth: c_int, + nHeight: c_int, + ) -> BOOL; +} +pub const DST_COMPLEX: UINT = 0x0000; +pub const DST_TEXT: UINT = 0x0001; +pub const DST_PREFIXTEXT: UINT = 0x0002; +pub const DST_ICON: UINT = 0x0003; +pub const DST_BITMAP: UINT = 0x0004; +pub const DSS_NORMAL: UINT = 0x0000; +pub const DSS_UNION: UINT = 0x0010; +pub const DSS_DISABLED: UINT = 0x0020; +pub const DSS_MONO: UINT = 0x0080; +pub const DSS_HIDEPREFIX: UINT = 0x0200; +pub const DSS_PREFIXONLY: UINT = 0x0400; +pub const DSS_RIGHT: UINT = 0x8000; +extern "system" { + pub fn DrawStateA( + hdc: HDC, + hbrFore: HBRUSH, + qfnCallBack: DRAWSTATEPROC, + lData: LPARAM, + wData: WPARAM, + x: c_int, + y: c_int, + cx: c_int, + cy: c_int, + uFlags: UINT, + ) -> BOOL; + pub fn DrawStateW( + hdc: HDC, + hbrFore: HBRUSH, + qfnCallBack: DRAWSTATEPROC, + lData: LPARAM, + wData: WPARAM, + x: c_int, + y: c_int, + cx: c_int, + cy: c_int, + uFlags: UINT, + ) -> BOOL; + pub fn TabbedTextOutA( + hdc: HDC, + x: c_int, + y: c_int, + lpString: LPCSTR, + chCount: c_int, + nTabPositions: c_int, + lpnTabStopPositions: *const INT, + nTabOrigin: c_int, + ) -> LONG; + pub fn TabbedTextOutW( + hdc: HDC, + x: c_int, + y: c_int, + lpString: LPCWSTR, + chCount: c_int, + nTabPositions: c_int, + lpnTabStopPositions: *const INT, + nTabOrigin: c_int, + ) -> LONG; + pub fn GetTabbedTextExtentA( + hdc: HDC, + lpString: LPCSTR, + chCount: c_int, + nTabPositions: c_int, + lpnTabStopPositions: *const INT, + ) -> DWORD; + pub fn GetTabbedTextExtentW( + hdc: HDC, + lpString: LPCWSTR, + chCount: c_int, + nTabPositions: c_int, + lpnTabStopPositions: *const INT, + ) -> DWORD; + pub fn UpdateWindow( + hWnd: HWND, + ) -> BOOL; + pub fn SetActiveWindow( + hWnd: HWND, + ) -> HWND; + pub fn GetForegroundWindow() -> HWND; + pub fn PaintDesktop( + hdc: HDC, + ) -> BOOL; + pub fn SwitchToThisWindow( + hwnd: HWND, + fUnknown: BOOL, + ); + pub fn SetForegroundWindow( + hWnd: HWND, + ) -> BOOL; + pub fn AllowSetForegroundWindow( + dwProcessId: DWORD, + ) -> BOOL; +} +pub const ASFW_ANY: DWORD = -1i32 as u32; +extern "system" { + pub fn LockSetForegroundWindow( + uLockCode: UINT, + ) -> BOOL; +} +pub const LSFW_LOCK: UINT = 1; +pub const LSFW_UNLOCK: UINT = 2; +extern "system" { + pub fn WindowFromDC( + hDC: HDC, + ) -> HWND; + pub fn GetDC( + hWnd: HWND, + ) -> HDC; + pub fn GetDCEx( + hWnd: HWND, + hrgnClip: HRGN, + flags: DWORD, + ) -> HDC; +} +pub const DCX_WINDOW: DWORD = 0x00000001; +pub const DCX_CACHE: DWORD = 0x00000002; +pub const DCX_NORESETATTRS: DWORD = 0x00000004; +pub const DCX_CLIPCHILDREN: DWORD = 0x00000008; +pub const DCX_CLIPSIBLINGS: DWORD = 0x00000010; +pub const DCX_PARENTCLIP: DWORD = 0x00000020; +pub const DCX_EXCLUDERGN: DWORD = 0x00000040; +pub const DCX_INTERSECTRGN: DWORD = 0x00000080; +pub const DCX_EXCLUDEUPDATE: DWORD = 0x00000100; +pub const DCX_INTERSECTUPDATE: DWORD = 0x00000200; +pub const DCX_LOCKWINDOWUPDATE: DWORD = 0x00000400; +pub const DCX_VALIDATE: DWORD = 0x00200000; +extern "system" { + pub fn GetWindowDC( + hWnd: HWND, + ) -> HDC; + pub fn ReleaseDC( + hWnd: HWND, + hDC: HDC, + ) -> c_int; + pub fn BeginPaint( + hwnd: HWND, + lpPaint: LPPAINTSTRUCT, + ) -> HDC; + pub fn EndPaint( + hWnd: HWND, + lpPaint: *const PAINTSTRUCT, + ) -> BOOL; + pub fn GetUpdateRect( + hWnd: HWND, + lpRect: LPRECT, + bErase: BOOL, + ) -> BOOL; + pub fn GetUpdateRgn( + hWnd: HWND, + hRgn: HRGN, + bErase: BOOL, + ) -> c_int; + pub fn SetWindowRgn( + hWnd: HWND, + hRgn: HRGN, + bRedraw: BOOL, + ) -> c_int; + pub fn GetWindowRgn( + hWnd: HWND, + hRgn: HRGN, + ) -> c_int; + pub fn GetWindowRgnBox( + hWnd: HWND, + lprc: LPRECT, + ) -> c_int; + pub fn ExcludeUpdateRgn( + hDC: HDC, + hWnd: HWND, + ) -> c_int; + pub fn InvalidateRect( + hWnd: HWND, + lpRect: *const RECT, + bErase: BOOL, + ) -> BOOL; + pub fn ValidateRect( + hWnd: HWND, + lpRect: *const RECT, + ) -> BOOL; + pub fn InvalidateRgn( + hWnd: HWND, + hRgn: HRGN, + bErase: BOOL, + ) -> BOOL; + pub fn ValidateRgn( + hWnd: HWND, + hRgn: HRGN, + ) -> BOOL; + pub fn RedrawWindow( + hwnd: HWND, + lprcUpdate: *const RECT, + hrgnUpdate: HRGN, + flags: UINT, + ) -> BOOL; +} +pub const RDW_INVALIDATE: UINT = 0x0001; +pub const RDW_INTERNALPAINT: UINT = 0x0002; +pub const RDW_ERASE: UINT = 0x0004; +pub const RDW_VALIDATE: UINT = 0x0008; +pub const RDW_NOINTERNALPAINT: UINT = 0x0010; +pub const RDW_NOERASE: UINT = 0x0020; +pub const RDW_NOCHILDREN: UINT = 0x0040; +pub const RDW_ALLCHILDREN: UINT = 0x0080; +pub const RDW_UPDATENOW: UINT = 0x0100; +pub const RDW_ERASENOW: UINT = 0x0200; +pub const RDW_FRAME: UINT = 0x0400; +pub const RDW_NOFRAME: UINT = 0x0800; +extern "system" { + pub fn LockWindowUpdate( + hWndLock: HWND, + ) -> BOOL; + pub fn ScrollWindow( + hWnd: HWND, + xAmount: c_int, + yAmount: c_int, + lpRect: *const RECT, + lpClipRect: *const RECT, + ) -> BOOL; + pub fn ScrollDC( + hDC: HDC, + dx: c_int, + dy: c_int, + lprcScroll: *const RECT, + lprcClip: *const RECT, + hrgnUpdate: HRGN, + lprcUpdate: LPRECT, + ) -> BOOL; + pub fn ScrollWindowEx( + hWnd: HWND, + dx: c_int, + dy: c_int, + prcScroll: *const RECT, + prcClip: *const RECT, + hrgnUpdate: HRGN, + prcUpdate: LPRECT, + flags: UINT, + ) -> c_int; +} +pub const SW_SCROLLCHILDREN: UINT = 0x0001; +pub const SW_INVALIDATE: UINT = 0x0002; +pub const SW_ERASE: UINT = 0x0004; +pub const SW_SMOOTHSCROLL: UINT = 0x0010; +extern "system" { + pub fn SetScrollPos( + hWnd: HWND, + nBar: c_int, + nPos: c_int, + bRedraw: BOOL, + ) -> c_int; + pub fn GetScrollPos( + hWnd: HWND, + nBar: c_int, + ) -> c_int; + pub fn SetScrollRange( + hWnd: HWND, + nBar: c_int, + nMinPos: c_int, + nMaxPos: c_int, + bRedraw: BOOL, + ) -> BOOL; + pub fn GetScrollRange( + hWnd: HWND, + nBar: c_int, + lpMinPos: LPINT, + lpMaxPos: LPINT, + ) -> BOOL; + pub fn ShowScrollBar( + hWnd: HWND, + wBar: c_int, + bShow: BOOL, + ) -> BOOL; + pub fn EnableScrollBar( + hWnd: HWND, + wSBflags: UINT, + wArrows: UINT, + ) -> BOOL; +} +pub const ESB_ENABLE_BOTH: UINT = 0x0000; +pub const ESB_DISABLE_BOTH: UINT = 0x0003; +pub const ESB_DISABLE_LEFT: UINT = 0x0001; +pub const ESB_DISABLE_RIGHT: UINT = 0x0002; +pub const ESB_DISABLE_UP: UINT = 0x0001; +pub const ESB_DISABLE_DOWN: UINT = 0x0002; +pub const ESB_DISABLE_LTUP: UINT = ESB_DISABLE_LEFT; +pub const ESB_DISABLE_RTDN: UINT = ESB_DISABLE_RIGHT; +extern "system" { + pub fn SetPropA( + hWnd: HWND, + lpString: LPCSTR, + hData: HANDLE, + ) -> BOOL; + pub fn SetPropW( + hWnd: HWND, + lpString: LPCWSTR, + hData: HANDLE, + ) -> BOOL; + pub fn GetPropA( + hwnd: HWND, + lpString: LPCSTR, + ) -> HANDLE; + pub fn GetPropW( + hwnd: HWND, + lpString: LPCWSTR, + ) -> HANDLE; + pub fn RemovePropA( + hWnd: HWND, + lpStr: LPCSTR, + ) -> HANDLE; + pub fn RemovePropW( + hWnd: HWND, + lpStr: LPCWSTR, + ) -> HANDLE; + pub fn EnumPropsExA( + hWnd: HWND, + lpEnumFunc: PROPENUMPROCA, + lParam: LPARAM, + ) -> c_int; + pub fn EnumPropsExW( + hWnd: HWND, + lpEnumFunc: PROPENUMPROCW, + lParam: LPARAM, + ) -> c_int; + pub fn EnumPropsA( + hWnd: HWND, + lpEnumFunc: PROPENUMPROCA, + ) -> c_int; + pub fn EnumPropsW( + hWnd: HWND, + lpEnumFunc: PROPENUMPROCW, + ) -> c_int; + pub fn SetWindowTextA( + hWnd: HWND, + lpString: LPCSTR, + ) -> BOOL; + pub fn SetWindowTextW( + hWnd: HWND, + lpString: LPCWSTR, + ) -> BOOL; + pub fn GetWindowTextA( + hWnd: HWND, + lpString: LPSTR, + nMaxCount: c_int, + ) -> c_int; + pub fn GetWindowTextW( + hWnd: HWND, + lpString: LPWSTR, + nMaxCount: c_int, + ) -> c_int; + pub fn GetWindowTextLengthA( + hWnd: HWND, + ) -> c_int; + pub fn GetWindowTextLengthW( + hWnd: HWND, + ) -> c_int; + pub fn GetClientRect( + hWnd: HWND, + lpRect: LPRECT, + ) -> BOOL; + pub fn GetWindowRect( + hWnd: HWND, + lpRect: LPRECT, + ) -> BOOL; + pub fn AdjustWindowRect( + lpRect: LPRECT, + dwStyle: DWORD, + bMenu: BOOL, + ) -> BOOL; + pub fn AdjustWindowRectEx( + lpRect: LPRECT, + dwStyle: DWORD, + bMenu: BOOL, + dwExStyle: DWORD, + ) -> BOOL; + pub fn AdjustWindowRectExForDpi( + lpRect: LPRECT, + dwStyle: DWORD, + bMenu: BOOL, + dwExStyle: DWORD, + dpi: UINT, + ) -> BOOL; +} +pub const HELPINFO_WINDOW: UINT = 0x0001; +pub const HELPINFO_MENUITEM: UINT = 0x0002; +STRUCT!{struct HELPINFO { + cbSize: UINT, + iContextType: c_int, + iCtrlId: c_int, + hItemHandle: HANDLE, + dwContextId: DWORD, + MousePos: POINT, +}} +pub type LPHELPINFO = *mut HELPINFO; +extern "system" { + pub fn SetWindowContextHelpId( + _: HWND, + _: DWORD, + ) -> BOOL; + pub fn GetWindowContextHelpId( + _: HWND, + ) -> DWORD; + pub fn SetMenuContextHelpId( + _: HMENU, + _: DWORD, + ) -> BOOL; + pub fn GetMenuContextHelpId( + _: HMENU, + ) -> DWORD; +} +pub const MB_OK: UINT = 0x00000000; +pub const MB_OKCANCEL: UINT = 0x00000001; +pub const MB_ABORTRETRYIGNORE: UINT = 0x00000002; +pub const MB_YESNOCANCEL: UINT = 0x00000003; +pub const MB_YESNO: UINT = 0x00000004; +pub const MB_RETRYCANCEL: UINT = 0x00000005; +pub const MB_CANCELTRYCONTINUE: UINT = 0x00000006; +pub const MB_ICONHAND: UINT = 0x00000010; +pub const MB_ICONQUESTION: UINT = 0x00000020; +pub const MB_ICONEXCLAMATION: UINT = 0x00000030; +pub const MB_ICONASTERISK: UINT = 0x00000040; +pub const MB_USERICON: UINT = 0x00000080; +pub const MB_ICONWARNING: UINT = MB_ICONEXCLAMATION; +pub const MB_ICONERROR: UINT = MB_ICONHAND; +pub const MB_ICONINFORMATION: UINT = MB_ICONASTERISK; +pub const MB_ICONSTOP: UINT = MB_ICONHAND; +pub const MB_DEFBUTTON1: UINT = 0x00000000; +pub const MB_DEFBUTTON2: UINT = 0x00000100; +pub const MB_DEFBUTTON3: UINT = 0x00000200; +pub const MB_DEFBUTTON4: UINT = 0x00000300; +pub const MB_APPLMODAL: UINT = 0x00000000; +pub const MB_SYSTEMMODAL: UINT = 0x00001000; +pub const MB_TASKMODAL: UINT = 0x00002000; +pub const MB_HELP: UINT = 0x00004000; +pub const MB_NOFOCUS: UINT = 0x00008000; +pub const MB_SETFOREGROUND: UINT = 0x00010000; +pub const MB_DEFAULT_DESKTOP_ONLY: UINT = 0x00020000; +pub const MB_TOPMOST: UINT = 0x00040000; +pub const MB_RIGHT: UINT = 0x00080000; +pub const MB_RTLREADING: UINT = 0x00100000; +pub const MB_SERVICE_NOTIFICATION: UINT = 0x00200000; +pub const MB_SERVICE_NOTIFICATION_NT3X: UINT = 0x00040000; +pub const MB_TYPEMASK: UINT = 0x0000000F; +pub const MB_ICONMASK: UINT = 0x000000F0; +pub const MB_DEFMASK: UINT = 0x00000F00; +pub const MB_MODEMASK: UINT = 0x00003000; +pub const MB_MISCMASK: UINT = 0x0000C000; +extern "system" { + pub fn MessageBoxA( + hWnd: HWND, + lpText: LPCSTR, + lpCaption: LPCSTR, + uType: UINT, + ) -> c_int; + pub fn MessageBoxW( + hWnd: HWND, + lpText: LPCWSTR, + lpCaption: LPCWSTR, + uType: UINT, + ) -> c_int; + pub fn MessageBoxExA( + hWnd: HWND, + lpText: LPCSTR, + lpCaption: LPCSTR, + uType: UINT, + wLanguageId: WORD, + ) -> c_int; + pub fn MessageBoxExW( + hWnd: HWND, + lpText: LPCWSTR, + lpCaption: LPCWSTR, + uType: UINT, + wLanguageId: WORD, + ) -> c_int; +} +FN!{stdcall MSGBOXCALLBACK( + LPHELPINFO, +) -> ()} +STRUCT!{struct MSGBOXPARAMSA { + cbSize: UINT, + hwndOwner: HWND, + hInstance: HINSTANCE, + lpszText: LPCSTR, + lpszCaption: LPCSTR, + dwStyle: DWORD, + lpszIcon: LPCSTR, + dwContextHelpId: DWORD_PTR, + lpfnMsgBoxCallback: MSGBOXCALLBACK, + dwLanguageId: DWORD, +}} +pub type PMSGBOXPARAMSA = *mut MSGBOXPARAMSA; +pub type LPMSGBOXPARAMSA = *mut MSGBOXPARAMSA; +STRUCT!{struct MSGBOXPARAMSW { + cbSize: UINT, + hwndOwner: HWND, + hInstance: HINSTANCE, + lpszText: LPCWSTR, + lpszCaption: LPCWSTR, + dwStyle: DWORD, + lpszIcon: LPCWSTR, + dwContextHelpId: DWORD_PTR, + lpfnMsgBoxCallback: MSGBOXCALLBACK, + dwLanguageId: DWORD, +}} +pub type PMSGBOXPARAMSW = *mut MSGBOXPARAMSW; +pub type LPMSGBOXPARAMSW = *mut MSGBOXPARAMSW; +extern "system" { + pub fn MessageBoxIndirectA( + lpmbp: *const MSGBOXPARAMSA, + ) -> c_int; + pub fn MessageBoxIndirectW( + lpmbp: *const MSGBOXPARAMSW, + ) -> c_int; + pub fn MessageBeep( + uType: UINT, + ) -> BOOL; + pub fn ShowCursor( + bShow: BOOL, + ) -> c_int; + pub fn SetCursorPos( + X: c_int, + Y: c_int, + ) -> BOOL; + pub fn SetPhysicalCursorPos( + X: c_int, + Y: c_int, + ) -> BOOL; + pub fn SetCursor( + hCursor: HCURSOR, + ) -> HCURSOR; + pub fn GetCursorPos( + lpPoint: LPPOINT, + ) -> BOOL; + pub fn GetPhysicalCursorPos( + lpPoint: LPPOINT, + ) -> BOOL; + pub fn GetClipCursor( + lpRect: LPRECT, + ) -> BOOL; + pub fn GetCursor() -> HCURSOR; + pub fn CreateCaret( + hWnd: HWND, + hBitmap: HBITMAP, + nWidth: c_int, + nHeight: c_int, + ) -> BOOL; + pub fn GetCaretBlinkTime() -> UINT; + pub fn SetCaretBlinkTime( + uMSeconds: UINT, + ) -> BOOL; + pub fn DestroyCaret() -> BOOL; + pub fn HideCaret( + hWnd: HWND, + ) -> BOOL; + pub fn ShowCaret( + hWnd: HWND, + ) -> BOOL; + pub fn SetCaretPos( + X: c_int, + Y: c_int, + ) -> BOOL; + pub fn GetCaretPos( + lpPoint: LPPOINT, + ) -> BOOL; + pub fn ClientToScreen( + hWnd: HWND, + lpPoint: LPPOINT, + ) -> BOOL; + pub fn ScreenToClient( + hWnd: HWND, + lpPoint: LPPOINT, + ) -> BOOL; + pub fn LogicalToPhysicalPoint( + hWnd: HWND, + lpPoint: LPPOINT, + ) -> BOOL; + pub fn PhysicalToLogicalPoint( + hWnd: HWND, + lpPoint: LPPOINT, + ) -> BOOL; + pub fn LogicalToPhysicalPointForPerMonitorDPI( + hWnd: HWND, + lpPoint: LPPOINT, + ) -> BOOL; + pub fn PhysicalToLogicalPointForPerMonitorDPI( + hWnd: HWND, + lpPoint: LPPOINT, + ) -> BOOL; + pub fn MapWindowPoints( + hWndFrom: HWND, + hWndTo: HWND, + lpPoints: LPPOINT, + cPoints: UINT, + ) -> c_int; + pub fn WindowFromPoint( + Point: POINT, + ) -> HWND; + pub fn WindowFromPhysicalPoint( + Point: POINT, + ) -> HWND; + pub fn ChildWindowFromPoint( + hWndParent: HWND, + point: POINT, + ) -> HWND; + pub fn ClipCursor( + lpRect: *const RECT, + ) -> BOOL; +} +pub const CWP_ALL: UINT = 0x0000; +pub const CWP_SKIPINVISIBLE: UINT = 0x0001; +pub const CWP_SKIPDISABLED: UINT = 0x0002; +pub const CWP_SKIPTRANSPARENT: UINT = 0x0004; +extern "system" { + pub fn ChildWindowFromPointEx( + hwnd: HWND, + pt: POINT, + flags: UINT, + ) -> HWND; +} +pub const CTLCOLOR_MSGBOX: c_int = 0; +pub const CTLCOLOR_EDIT: c_int = 1; +pub const CTLCOLOR_LISTBOX: c_int = 2; +pub const CTLCOLOR_BTN: c_int = 3; +pub const CTLCOLOR_DLG: c_int = 4; +pub const CTLCOLOR_SCROLLBAR: c_int = 5; +pub const CTLCOLOR_STATIC: c_int = 6; +pub const CTLCOLOR_MAX: c_int = 7; +pub const COLOR_SCROLLBAR: c_int = 0; +pub const COLOR_BACKGROUND: c_int = 1; +pub const COLOR_ACTIVECAPTION: c_int = 2; +pub const COLOR_INACTIVECAPTION: c_int = 3; +pub const COLOR_MENU: c_int = 4; +pub const COLOR_WINDOW: c_int = 5; +pub const COLOR_WINDOWFRAME: c_int = 6; +pub const COLOR_MENUTEXT: c_int = 7; +pub const COLOR_WINDOWTEXT: c_int = 8; +pub const COLOR_CAPTIONTEXT: c_int = 9; +pub const COLOR_ACTIVEBORDER: c_int = 10; +pub const COLOR_INACTIVEBORDER: c_int = 11; +pub const COLOR_APPWORKSPACE: c_int = 12; +pub const COLOR_HIGHLIGHT: c_int = 13; +pub const COLOR_HIGHLIGHTTEXT: c_int = 14; +pub const COLOR_BTNFACE: c_int = 15; +pub const COLOR_BTNSHADOW: c_int = 16; +pub const COLOR_GRAYTEXT: c_int = 17; +pub const COLOR_BTNTEXT: c_int = 18; +pub const COLOR_INACTIVECAPTIONTEXT: c_int = 19; +pub const COLOR_BTNHIGHLIGHT: c_int = 20; +pub const COLOR_3DDKSHADOW: c_int = 21; +pub const COLOR_3DLIGHT: c_int = 22; +pub const COLOR_INFOTEXT: c_int = 23; +pub const COLOR_INFOBK: c_int = 24; +pub const COLOR_HOTLIGHT: c_int = 26; +pub const COLOR_GRADIENTACTIVECAPTION: c_int = 27; +pub const COLOR_GRADIENTINACTIVECAPTION: c_int = 28; +pub const COLOR_MENUHILIGHT: c_int = 29; +pub const COLOR_MENUBAR: c_int = 30; +pub const COLOR_DESKTOP: c_int = COLOR_BACKGROUND; +pub const COLOR_3DFACE: c_int = COLOR_BTNFACE; +pub const COLOR_3DSHADOW: c_int = COLOR_BTNSHADOW; +pub const COLOR_3DHIGHLIGHT: c_int = COLOR_BTNHIGHLIGHT; +pub const COLOR_3DHILIGHT: c_int = COLOR_BTNHIGHLIGHT; +pub const COLOR_BTNHILIGHT: c_int = COLOR_BTNHIGHLIGHT; +extern "system" { + pub fn GetSysColor( + nIndex: c_int, + ) -> DWORD; + pub fn GetSysColorBrush( + nIndex: c_int, + ) -> HBRUSH; + pub fn SetSysColors( + cElements: c_int, + lpaElements: *const INT, + lpaRgbValues: *const COLORREF, + ) -> BOOL; + pub fn DrawFocusRect( + hDC: HDC, + lprc: *const RECT, + ) -> BOOL; + pub fn FillRect( + hDC: HDC, + lprc: *const RECT, + hbr: HBRUSH, + ) -> c_int; + pub fn FrameRect( + hDC: HDC, + lprc: *const RECT, + hbr: HBRUSH, + ) -> c_int; + pub fn InvertRect( + hDC: HDC, + lprc: *const RECT, + ) -> BOOL; + pub fn SetRect( + lprc: LPRECT, + xLeft: c_int, + yTop: c_int, + xRight: c_int, + yBottom: c_int, + ) -> BOOL; + pub fn SetRectEmpty( + lprc: LPRECT, + ) -> BOOL; + pub fn CopyRect( + lprcDst: LPRECT, + lprcSrc: *const RECT, + ) -> BOOL; + pub fn InflateRect( + lprc: LPRECT, + dx: c_int, + dy: c_int, + ) -> BOOL; + pub fn IntersectRect( + lprcDst: LPRECT, + lprcSrc1: *const RECT, + lprcSrc2: *const RECT, + ) -> BOOL; + pub fn UnionRect( + lprcDst: LPRECT, + lprcSrc1: *const RECT, + lprcSrc2: *const RECT, + ) -> BOOL; + pub fn SubtractRect( + lprcDst: LPRECT, + lprcSrc1: *const RECT, + lprcSrc2: *const RECT, + ) -> BOOL; + pub fn OffsetRect( + lprc: LPRECT, + dx: c_int, + dy: c_int, + ) -> BOOL; + pub fn IsRectEmpty( + lprc: *const RECT, + ) -> BOOL; + pub fn EqualRect( + lprc1: *const RECT, + lprc2: *const RECT, + ) -> BOOL; + pub fn PtInRect( + lprc: *const RECT, + pt: POINT, + ) -> BOOL; + pub fn GetWindowWord( + hWnd: HWND, + nIndex: c_int, + ) -> WORD; + pub fn SetWindowWord( + hwnd: HWND, + nIndex: c_int, + wNewWord: WORD, + ) -> WORD; + pub fn GetWindowLongA( + hWnd: HWND, + nIndex: c_int, + ) -> LONG; + pub fn GetWindowLongW( + hWnd: HWND, + nIndex: c_int, + ) -> LONG; + pub fn SetWindowLongA( + hWnd: HWND, + nIndex: c_int, + dwNewLong: LONG, + ) -> LONG; + pub fn SetWindowLongW( + hWnd: HWND, + nIndex: c_int, + dwNewLong: LONG, + ) -> LONG; + #[cfg(target_pointer_width = "64")] + pub fn GetWindowLongPtrA( + hWnd: HWND, + nIndex: c_int, + ) -> LONG_PTR; + #[cfg(target_pointer_width = "64")] + pub fn GetWindowLongPtrW( + hWnd: HWND, + nIndex: c_int, + ) -> LONG_PTR; + #[cfg(target_pointer_width = "64")] + pub fn SetWindowLongPtrA( + hWnd: HWND, + nIndex: c_int, + dwNewLong: LONG_PTR, + ) -> LONG_PTR; + #[cfg(target_pointer_width = "64")] + pub fn SetWindowLongPtrW( + hWnd: HWND, + nIndex: c_int, + dwNewLong: LONG_PTR, + ) -> LONG_PTR; +} +#[cfg(target_pointer_width = "32")] +pub use self::GetWindowLongA as GetWindowLongPtrA; +#[cfg(target_pointer_width = "32")] +pub use self::GetWindowLongW as GetWindowLongPtrW; +#[cfg(target_pointer_width = "32")] +pub use self::SetWindowLongA as SetWindowLongPtrA; +#[cfg(target_pointer_width = "32")] +pub use self::SetWindowLongW as SetWindowLongPtrW; +extern "system" { + pub fn GetClassWord( + hWnd: HWND, + nIndex: c_int, + ) -> WORD; + pub fn SetClassWord( + hWnd: HWND, + nIndex: c_int, + wNewWord: WORD, + ) -> WORD; + pub fn GetClassLongA( + hWnd: HWND, + nIndex: c_int, + ) -> DWORD; + pub fn GetClassLongW( + hWnd: HWND, + nIndex: c_int, + ) -> DWORD; + pub fn SetClassLongA( + hWnd: HWND, + nIndex: c_int, + dwNewLong: LONG, + ) -> DWORD; + pub fn SetClassLongW( + hWnd: HWND, + nIndex: c_int, + dwNewLong: LONG, + ) -> DWORD; + #[cfg(target_pointer_width = "64")] + pub fn GetClassLongPtrA( + hWnd: HWND, + nIndex: c_int, + ) -> ULONG_PTR; + #[cfg(target_pointer_width = "64")] + pub fn GetClassLongPtrW( + hWnd: HWND, + nIndex: c_int, + ) -> ULONG_PTR; + #[cfg(target_pointer_width = "64")] + pub fn SetClassLongPtrA( + hWnd: HWND, + nIndex: c_int, + dwNewLong: LONG_PTR, + ) -> ULONG_PTR; + #[cfg(target_pointer_width = "64")] + pub fn SetClassLongPtrW( + hWnd: HWND, + nIndex: c_int, + dwNewLong: LONG_PTR, + ) -> ULONG_PTR; +} +#[cfg(target_pointer_width = "32")] +pub use self::GetClassLongA as GetClassLongPtrA; +#[cfg(target_pointer_width = "32")] +pub use self::GetClassLongW as GetClassLongPtrW; +#[cfg(target_pointer_width = "32")] +pub use self::SetClassLongA as SetClassLongPtrA; +#[cfg(target_pointer_width = "32")] +pub use self::SetClassLongW as SetClassLongPtrW; +extern "system" { + pub fn GetProcessDefaultLayout( + pdwDefaultLayout: *mut DWORD, + ) -> BOOL; + pub fn SetProcessDefaultLayout( + dwDefaultLayout: DWORD, + ) -> BOOL; + pub fn GetDesktopWindow() -> HWND; + pub fn GetParent( + hWnd: HWND, + ) -> HWND; + pub fn SetParent( + hWndChild: HWND, + hWndNewParent: HWND, + ) -> HWND; + pub fn EnumChildWindows( + hWndParent: HWND, + lpEnumFunc: WNDENUMPROC, + lParam: LPARAM, + ) -> BOOL; + pub fn FindWindowA( + lpClassName: LPCSTR, + lpWindowName: LPCSTR, + ) -> HWND; + pub fn FindWindowW( + lpClassName: LPCWSTR, + lpWindowName: LPCWSTR, + ) -> HWND; + pub fn FindWindowExA( + hWndParent: HWND, + hWndChildAfter: HWND, + lpszClass: LPCSTR, + lpszWindow: LPCSTR, + ) -> HWND; + pub fn FindWindowExW( + hWndParent: HWND, + hWndChildAfter: HWND, + lpszClass: LPCWSTR, + lpszWindow: LPCWSTR, + ) -> HWND; + pub fn GetShellWindow() -> HWND; + pub fn RegisterShellHookWindow( + hwnd: HWND, + ) -> BOOL; + pub fn DeregisterShellHookWindow( + hwnd: HWND, + ) -> BOOL; + pub fn EnumWindows( + lpEnumFunc: WNDENUMPROC, + lParam: LPARAM, + ) -> BOOL; + pub fn EnumThreadWindows( + dwThreadId: DWORD, + lpfn: WNDENUMPROC, + lParam: LPARAM, + ) -> BOOL; +} +// EnumTaskWindows +extern "system" { + pub fn GetClassNameA( + hWnd: HWND, + lpClassName: LPCSTR, + nMaxCount: c_int, + ) -> c_int; + pub fn GetClassNameW( + hWnd: HWND, + lpClassName: LPCWSTR, + nMaxCount: c_int, + ) -> c_int; + pub fn GetTopWindow( + hWnd: HWND, + ) -> HWND; +} +// GetNextWindow +// GetSysModalWindow +// SetSysModalWindow +extern "system" { + pub fn GetWindowThreadProcessId( + hWnd: HWND, + lpdwProcessId: LPDWORD, + ) -> DWORD; + pub fn IsGUIThread( + bConvert: BOOL, + ) -> BOOL; + pub fn GetLastActivePopup( + hWnd: HWND, + ) -> HWND; +} +pub const GW_HWNDFIRST: UINT = 0; +pub const GW_HWNDLAST: UINT = 1; +pub const GW_HWNDNEXT: UINT = 2; +pub const GW_HWNDPREV: UINT = 3; +pub const GW_OWNER: UINT = 4; +pub const GW_CHILD: UINT = 5; +pub const GW_ENABLEDPOPUP: UINT = 6; +pub const GW_MAX: UINT = 6; +extern "system" { + pub fn GetWindow( + hWnd: HWND, + uCmd: UINT, + ) -> HWND; + pub fn SetWindowsHookA( + nFilterType: c_int, + pfnFilterProc: HOOKPROC, + ) -> HHOOK; + pub fn SetWindowsHookW( + nFilterType: c_int, + pfnFilterProc: HOOKPROC, + ) -> HHOOK; + pub fn UnhookWindowsHook( + nFilterType: c_int, + pfnFilterProc: HOOKPROC, + ) -> BOOL; + pub fn SetWindowsHookExA( + idHook: c_int, + lpfn: HOOKPROC, + hmod: HINSTANCE, + dwThreadId: DWORD, + ) -> HHOOK; + pub fn SetWindowsHookExW( + idHook: c_int, + lpfn: HOOKPROC, + hmod: HINSTANCE, + dwThreadId: DWORD, + ) -> HHOOK; + pub fn UnhookWindowsHookEx( + hhk: HHOOK, + ) -> BOOL; + pub fn CallNextHookEx( + hhk: HHOOK, + nCode: c_int, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; +} +// DefHookProc +pub const MF_INSERT: UINT = 0x00000000; +pub const MF_CHANGE: UINT = 0x00000080; +pub const MF_APPEND: UINT = 0x00000100; +pub const MF_DELETE: UINT = 0x00000200; +pub const MF_REMOVE: UINT = 0x00001000; +pub const MF_BYCOMMAND: UINT = 0x00000000; +pub const MF_BYPOSITION: UINT = 0x00000400; +pub const MF_SEPARATOR: UINT = 0x00000800; +pub const MF_ENABLED: UINT = 0x00000000; +pub const MF_GRAYED: UINT = 0x00000001; +pub const MF_DISABLED: UINT = 0x00000002; +pub const MF_UNCHECKED: UINT = 0x00000000; +pub const MF_CHECKED: UINT = 0x00000008; +pub const MF_USECHECKBITMAPS: UINT = 0x00000200; +pub const MF_STRING: UINT = 0x00000000; +pub const MF_BITMAP: UINT = 0x00000004; +pub const MF_OWNERDRAW: UINT = 0x00000100; +pub const MF_POPUP: UINT = 0x00000010; +pub const MF_MENUBARBREAK: UINT = 0x00000020; +pub const MF_MENUBREAK: UINT = 0x00000040; +pub const MF_UNHILITE: UINT = 0x00000000; +pub const MF_HILITE: UINT = 0x00000080; +pub const MF_DEFAULT: UINT = 0x00001000; +pub const MF_SYSMENU: UINT = 0x00002000; +pub const MF_HELP: UINT = 0x00004000; +pub const MF_RIGHTJUSTIFY: UINT = 0x00004000; +pub const MF_MOUSESELECT: UINT = 0x00008000; +pub const MF_END: UINT = 0x00000080; +pub const MFT_STRING: UINT = MF_STRING; +pub const MFT_BITMAP: UINT = MF_BITMAP; +pub const MFT_MENUBARBREAK: UINT = MF_MENUBARBREAK; +pub const MFT_MENUBREAK: UINT = MF_MENUBREAK; +pub const MFT_OWNERDRAW: UINT = MF_OWNERDRAW; +pub const MFT_RADIOCHECK: UINT = 0x00000200; +pub const MFT_SEPARATOR: UINT = MF_SEPARATOR; +pub const MFT_RIGHTORDER: UINT = 0x00002000; +pub const MFT_RIGHTJUSTIFY: UINT = MF_RIGHTJUSTIFY; +pub const MFS_GRAYED: UINT = 0x00000003; +pub const MFS_DISABLED: UINT = MFS_GRAYED; +pub const MFS_CHECKED: UINT = MF_CHECKED; +pub const MFS_HILITE: UINT = MF_HILITE; +pub const MFS_ENABLED: UINT = MF_ENABLED; +pub const MFS_UNCHECKED: UINT = MF_UNCHECKED; +pub const MFS_UNHILITE: UINT = MF_UNHILITE; +pub const MFS_DEFAULT: UINT = MF_DEFAULT; +extern "system" { + pub fn CheckMenuRadioItem( + hMenu: HMENU, + first: UINT, + last: UINT, + check: UINT, + flags: UINT, + ) -> BOOL; +} +//10225 +pub const SC_SIZE: WPARAM = 0xF000; +pub const SC_MOVE: WPARAM = 0xF010; +pub const SC_MINIMIZE: WPARAM = 0xF020; +pub const SC_MAXIMIZE: WPARAM = 0xF030; +pub const SC_NEXTWINDOW: WPARAM = 0xF040; +pub const SC_PREVWINDOW: WPARAM = 0xF050; +pub const SC_CLOSE: WPARAM = 0xF060; +pub const SC_VSCROLL: WPARAM = 0xF070; +pub const SC_HSCROLL: WPARAM = 0xF080; +pub const SC_MOUSEMENU: WPARAM = 0xF090; +pub const SC_KEYMENU: WPARAM = 0xF100; +pub const SC_ARRANGE: WPARAM = 0xF110; +pub const SC_RESTORE: WPARAM = 0xF120; +pub const SC_TASKLIST: WPARAM = 0xF130; +pub const SC_SCREENSAVE: WPARAM = 0xF140; +pub const SC_HOTKEY: WPARAM = 0xF150; +pub const SC_DEFAULT: WPARAM = 0xF160; +pub const SC_MONITORPOWER: WPARAM = 0xF170; +pub const SC_CONTEXTHELP: WPARAM = 0xF180; +pub const SC_SEPARATOR: WPARAM = 0xF00F; +//10269 +extern "system" { + pub fn LoadBitmapA( + hInstance: HINSTANCE, + lpBitmapName: LPCSTR, + ) -> HBITMAP; + pub fn LoadBitmapW( + hInstance: HINSTANCE, + lpBitmapName: LPCWSTR, + ) -> HBITMAP; + pub fn LoadCursorA( + hInstance: HINSTANCE, + lpCursorName: LPCSTR, + ) -> HCURSOR; + pub fn LoadCursorW( + hInstance: HINSTANCE, + lpCursorName: LPCWSTR, + ) -> HCURSOR; + pub fn LoadCursorFromFileA( + lpFileName: LPCSTR, + ) -> HCURSOR; + pub fn LoadCursorFromFileW( + lpFileName: LPCWSTR, + ) -> HCURSOR; + pub fn CreateCursor( + hInst: HINSTANCE, + xHotSpot: c_int, + yHotSpot: c_int, + nWidth: c_int, + nHeight: c_int, + pvAndPlane: *const VOID, + pvXORPlane: *const VOID, + ) -> HCURSOR; + pub fn DestroyCursor( + hCursor: HCURSOR, + ) -> BOOL; +} +//10355 +pub const IDC_ARROW: LPCWSTR = 32512 as LPCWSTR; +pub const IDC_IBEAM: LPCWSTR = 32513 as LPCWSTR; +pub const IDC_WAIT: LPCWSTR = 32514 as LPCWSTR; +pub const IDC_CROSS: LPCWSTR = 32515 as LPCWSTR; +pub const IDC_UPARROW: LPCWSTR = 32516 as LPCWSTR; +pub const IDC_SIZE: LPCWSTR = 32640 as LPCWSTR; +pub const IDC_ICON: LPCWSTR = 32641 as LPCWSTR; +pub const IDC_SIZENWSE: LPCWSTR = 32642 as LPCWSTR; +pub const IDC_SIZENESW: LPCWSTR = 32643 as LPCWSTR; +pub const IDC_SIZEWE: LPCWSTR = 32644 as LPCWSTR; +pub const IDC_SIZENS: LPCWSTR = 32645 as LPCWSTR; +pub const IDC_SIZEALL: LPCWSTR = 32646 as LPCWSTR; +pub const IDC_NO: LPCWSTR = 32648 as LPCWSTR; +pub const IDC_HAND: LPCWSTR = 32649 as LPCWSTR; +pub const IDC_APPSTARTING: LPCWSTR = 32650 as LPCWSTR; +pub const IDC_HELP: LPCWSTR = 32651 as LPCWSTR; +extern "system" { + pub fn SetSystemCursor( + hcur: HCURSOR, + id: DWORD, + ) -> BOOL; +} +STRUCT!{struct ICONINFO { + fIcon: BOOL, + xHotspot: DWORD, + yHotspot: DWORD, + hbmMask: HBITMAP, + hbmColor: HBITMAP, +}} +pub type PICONINFO = *mut ICONINFO; +extern "system" { + pub fn LoadIconA( + hInstance: HINSTANCE, + lpIconName: LPCSTR, + ) -> HICON; + pub fn LoadIconW( + hInstance: HINSTANCE, + lpIconName: LPCWSTR, + ) -> HICON; +} +//10449 +extern "system" { + pub fn CreateIcon( + hInstance: HINSTANCE, + nWidth: c_int, + nHeight: c_int, + cPlanes: BYTE, + cBitsPixel: BYTE, + lpbANDbits: *const BYTE, + lpbXORbits: *const BYTE, + ) -> HICON; + pub fn DestroyIcon( + hIcon: HICON, + ) -> BOOL; + pub fn LookupIconIdFromDirectory( + presbits: PBYTE, + fIcon: BOOL, + ) -> c_int; + pub fn LookupIconIdFromDirectoryEx( + presbits: PBYTE, + fIcon: BOOL, + cxDesired: c_int, + cyDesired: c_int, + Flags: UINT, + ) -> c_int; + pub fn CreateIconFromResource( + presbits: PBYTE, + dwResSize: DWORD, + fIcon: BOOL, + dwVer: DWORD, + ) -> HICON; + pub fn CreateIconFromResourceEx( + presbits: PBYTE, + dwResSize: DWORD, + fIcon: BOOL, + dwVer: DWORD, + cxDesired: c_int, + cyDesired: c_int, + Flags: UINT, + ) -> HICON; +} +//10524 +pub const IMAGE_BITMAP: UINT = 0; +pub const IMAGE_ICON: UINT = 1; +pub const IMAGE_CURSOR: UINT = 2; +pub const IMAGE_ENHMETAFILE: UINT = 3; +pub const LR_DEFAULTCOLOR: UINT = 0x00000000; +pub const LR_MONOCHROME: UINT = 0x00000001; +pub const LR_COLOR: UINT = 0x00000002; +pub const LR_COPYRETURNORG: UINT = 0x00000004; +pub const LR_COPYDELETEORG: UINT = 0x00000008; +pub const LR_LOADFROMFILE: UINT = 0x00000010; +pub const LR_LOADTRANSPARENT: UINT = 0x00000020; +pub const LR_DEFAULTSIZE: UINT = 0x00000040; +pub const LR_VGACOLOR: UINT = 0x00000080; +pub const LR_LOADMAP3DCOLORS: UINT = 0x00001000; +pub const LR_CREATEDIBSECTION: UINT = 0x00002000; +pub const LR_COPYFROMRESOURCE: UINT = 0x00004000; +pub const LR_SHARED: UINT = 0x00008000; +extern "system" { + pub fn LoadImageA( + hInst: HINSTANCE, + name: LPCSTR, + type_: UINT, + cx: c_int, + cy: c_int, + fuLoad: UINT, + ) -> HANDLE; + pub fn LoadImageW( + hInst: HINSTANCE, + name: LPCWSTR, + type_: UINT, + cx: c_int, + cy: c_int, + fuLoad: UINT, + ) -> HANDLE; + pub fn CopyImage( + h: HANDLE, + type_: UINT, + cx: c_int, + cy: c_int, + flags: UINT, + ) -> HANDLE; +} +//10592 +extern "system" { + pub fn DrawIconEx( + hdc: HDC, + xLeft: c_int, + yTop: c_int, + hIcon: HICON, + cxWidth: c_int, + cyWidth: c_int, + istepIfAniCur: UINT, + hbrFlickerFreeDraw: HBRUSH, + diFlags: UINT, + ) -> BOOL; + pub fn CreateIconIndirect( + piconinfo: PICONINFO, + ) -> HICON; + pub fn CopyIcon( + hIcon: HICON, + ) -> HICON; + pub fn GetIconInfo( + hIcon: HICON, + piconinfo: PICONINFO, + ) -> BOOL; +} +//10781 +pub const IDI_APPLICATION: LPCWSTR = 32512 as LPCWSTR; +pub const IDI_HAND: LPCWSTR = 32513 as LPCWSTR; +pub const IDI_QUESTION: LPCWSTR = 32514 as LPCWSTR; +pub const IDI_EXCLAMATION: LPCWSTR = 32515 as LPCWSTR; +pub const IDI_ASTERISK: LPCWSTR = 32516 as LPCWSTR; +pub const IDI_WINLOGO: LPCWSTR = 32517 as LPCWSTR; +pub const IDI_SHIELD: LPCWSTR = 32518 as LPCWSTR; +pub const IDI_WARNING: LPCWSTR = IDI_EXCLAMATION; +pub const IDI_ERROR: LPCWSTR = IDI_HAND; +pub const IDI_INFORMATION: LPCWSTR = IDI_ASTERISK; +//10853 +pub const IDOK: c_int = 1; +pub const IDCANCEL: c_int = 2; +pub const IDABORT: c_int = 3; +pub const IDRETRY: c_int = 4; +pub const IDIGNORE: c_int = 5; +pub const IDYES: c_int = 6; +pub const IDNO: c_int = 7; +pub const IDCLOSE: c_int = 8; +pub const IDHELP: c_int = 9; +pub const IDTRYAGAIN: c_int = 10; +pub const IDCONTINUE: c_int = 11; +pub const IDTIMEOUT: c_int = 32000; +pub const ES_LEFT: DWORD = 0x0000; +pub const ES_CENTER: DWORD = 0x0001; +pub const ES_RIGHT: DWORD = 0x0002; +pub const ES_MULTILINE: DWORD = 0x0004; +pub const ES_UPPERCASE: DWORD = 0x0008; +pub const ES_LOWERCASE: DWORD = 0x0010; +pub const ES_PASSWORD: DWORD = 0x0020; +pub const ES_AUTOVSCROLL: DWORD = 0x0040; +pub const ES_AUTOHSCROLL: DWORD = 0x0080; +pub const ES_NOHIDESEL: DWORD = 0x0100; +pub const ES_OEMCONVERT: DWORD = 0x0400; +pub const ES_READONLY: DWORD = 0x0800; +pub const ES_WANTRETURN: DWORD = 0x1000; +pub const ES_NUMBER: DWORD = 0x2000; +pub const EN_SETFOCUS: WORD = 0x0100; +pub const EN_KILLFOCUS: WORD = 0x0200; +pub const EN_CHANGE: WORD = 0x0300; +pub const EN_UPDATE: WORD = 0x0400; +pub const EN_ERRSPACE: WORD = 0x0500; +pub const EN_MAXTEXT: WORD = 0x0501; +pub const EN_HSCROLL: WORD = 0x0601; +pub const EN_VSCROLL: WORD = 0x0602; +pub const EN_ALIGN_LTR_EC: WORD = 0x0700; +pub const EN_ALIGN_RTL_EC: WORD = 0x0701; +pub const EC_LEFTMARGIN: WORD = 0x0001; +pub const EC_RIGHTMARGIN: WORD = 0x0002; +pub const EC_USEFONTINFO: WORD = 0xffff; +pub const EMSIS_COMPOSITIONSTRING: WORD = 0x0001; +pub const EIMES_GETCOMPSTRATONCE: WORD = 0x0001; +pub const EIMES_CANCELCOMPSTRINFOCUS: WORD = 0x0002; +pub const EIMES_COMPLETECOMPSTRKILLFOCUS: WORD = 0x0004; +pub const EM_GETSEL: WORD = 0x00B0; +pub const EM_SETSEL: WORD = 0x00B1; +pub const EM_GETRECT: WORD = 0x00B2; +pub const EM_SETRECT: WORD = 0x00B3; +pub const EM_SETRECTNP: WORD = 0x00B4; +pub const EM_SCROLL: WORD = 0x00B5; +pub const EM_LINESCROLL: WORD = 0x00B6; +pub const EM_SCROLLCARET: WORD = 0x00B7; +pub const EM_GETMODIFY: WORD = 0x00B8; +pub const EM_SETMODIFY: WORD = 0x00B9; +pub const EM_GETLINECOUNT: WORD = 0x00BA; +pub const EM_LINEINDEX: WORD = 0x00BB; +pub const EM_SETHANDLE: WORD = 0x00BC; +pub const EM_GETHANDLE: WORD = 0x00BD; +pub const EM_GETTHUMB: WORD = 0x00BE; +pub const EM_LINELENGTH: WORD = 0x00C1; +pub const EM_REPLACESEL: WORD = 0x00C2; +pub const EM_GETLINE: WORD = 0x00C4; +pub const EM_LIMITTEXT: WORD = 0x00C5; +pub const EM_CANUNDO: WORD = 0x00C6; +pub const EM_UNDO: WORD = 0x00C7; +pub const EM_FMTLINES: WORD = 0x00C8; +pub const EM_LINEFROMCHAR: WORD = 0x00C9; +pub const EM_SETTABSTOPS: WORD = 0x00CB; +pub const EM_SETPASSWORDCHAR: WORD = 0x00CC; +pub const EM_EMPTYUNDOBUFFER: WORD = 0x00CD; +pub const EM_GETFIRSTVISIBLELINE: WORD = 0x00CE; +pub const EM_SETREADONLY: WORD = 0x00CF; +pub const EM_SETWORDBREAKPROC: WORD = 0x00D0; +pub const EM_GETWORDBREAKPROC: WORD = 0x00D1; +pub const EM_GETPASSWORDCHAR: WORD = 0x00D2; +pub const EM_SETMARGINS: WORD = 0x00D3; +pub const EM_GETMARGINS: WORD = 0x00D4; +pub const EM_SETLIMITTEXT: WORD = EM_LIMITTEXT; +pub const EM_GETLIMITTEXT: WORD = 0x00D5; +pub const EM_POSFROMCHAR: WORD = 0x00D6; +pub const EM_CHARFROMPOS: WORD = 0x00D7; +pub const EM_SETIMESTATUS: WORD = 0x00D8; +pub const EM_GETIMESTATUS: WORD = 0x00D9; +pub const WB_LEFT: WORD = 0; +pub const WB_RIGHT: WORD = 1; +pub const WB_ISDELIMITER: WORD = 2; +pub const BN_CLICKED: WORD = 0; +pub const BN_PAINT: WORD = 1; +pub const BN_HILITE: WORD = 2; +pub const BN_UNHILITE: WORD = 3; +pub const BN_DISABLE: WORD = 4; +pub const BN_DOUBLECLICKED: WORD = 5; +pub const BN_PUSHED: WORD = BN_HILITE; +pub const BN_UNPUSHED: WORD = BN_UNHILITE; +pub const BN_DBLCLK: WORD = BN_DOUBLECLICKED; +pub const BN_SETFOCUS: WORD = 6; +pub const BN_KILLFOCUS: WORD = 7; +pub const BS_PUSHBUTTON: DWORD = 0x00000000; +pub const BS_DEFPUSHBUTTON: DWORD = 0x00000001; +pub const BS_CHECKBOX: DWORD = 0x00000002; +pub const BS_AUTOCHECKBOX: DWORD = 0x00000003; +pub const BS_RADIOBUTTON: DWORD = 0x00000004; +pub const BS_3STATE: DWORD = 0x00000005; +pub const BS_AUTO3STATE: DWORD = 0x00000006; +pub const BS_GROUPBOX: DWORD = 0x00000007; +pub const BS_USERBUTTON: DWORD = 0x00000008; +pub const BS_AUTORADIOBUTTON: DWORD = 0x00000009; +pub const BS_PUSHBOX: DWORD = 0x0000000A; +pub const BS_OWNERDRAW: DWORD = 0x0000000B; +pub const BS_TYPEMASK: DWORD = 0x0000000F; +pub const BS_LEFTTEXT: DWORD = 0x00000020; +pub const BS_TEXT: DWORD = 0x00000000; +pub const BS_ICON: DWORD = 0x00000040; +pub const BS_BITMAP: DWORD = 0x00000080; +pub const BS_LEFT: DWORD = 0x00000100; +pub const BS_RIGHT: DWORD = 0x00000200; +pub const BS_CENTER: DWORD = 0x00000300; +pub const BS_TOP: DWORD = 0x00000400; +pub const BS_BOTTOM: DWORD = 0x00000800; +pub const BS_VCENTER: DWORD = 0x00000C00; +pub const BS_PUSHLIKE: DWORD = 0x00001000; +pub const BS_MULTILINE: DWORD = 0x00002000; +pub const BS_NOTIFY: DWORD = 0x00004000; +pub const BS_FLAT: DWORD = 0x00008000; +pub const BS_RIGHTBUTTON: DWORD = BS_LEFTTEXT; +pub const BM_GETCHECK: UINT = 0x00F0; +pub const BM_SETCHECK: UINT = 0x00F1; +pub const BM_GETSTATE: UINT = 0x00F2; +pub const BM_SETSTATE: UINT = 0x00F3; +pub const BM_SETSTYLE: UINT = 0x00F4; +pub const BM_CLICK: UINT = 0x00F5; +pub const BM_GETIMAGE: UINT = 0x00F6; +pub const BM_SETIMAGE: UINT = 0x00F7; +pub const BM_SETDONTCLICK: UINT = 0x00F8; +pub const BST_UNCHECKED: WPARAM = 0x0000; +pub const BST_CHECKED: WPARAM = 0x0001; +pub const BST_INDETERMINATE: WPARAM = 0x0002; +pub const BST_PUSHED: LRESULT = 0x0004; +pub const BST_FOCUS: LRESULT = 0x0008; +pub const SS_LEFT: DWORD = 0x00000000; +pub const SS_CENTER: DWORD = 0x00000001; +pub const SS_RIGHT: DWORD = 0x00000002; +pub const SS_ICON: DWORD = 0x00000003; +pub const SS_BLACKRECT: DWORD = 0x00000004; +pub const SS_GRAYRECT: DWORD = 0x00000005; +pub const SS_WHITERECT: DWORD = 0x00000006; +pub const SS_BLACKFRAME: DWORD = 0x00000007; +pub const SS_GRAYFRAME: DWORD = 0x00000008; +pub const SS_WHITEFRAME: DWORD = 0x00000009; +pub const SS_USERITEM: DWORD = 0x0000000A; +pub const SS_SIMPLE: DWORD = 0x0000000B; +pub const SS_LEFTNOWORDWRAP: DWORD = 0x0000000C; +pub const SS_OWNERDRAW: DWORD = 0x0000000D; +pub const SS_BITMAP: DWORD = 0x0000000E; +pub const SS_ENHMETAFILE: DWORD = 0x0000000F; +pub const SS_ETCHEDHORZ: DWORD = 0x00000010; +pub const SS_ETCHEDVERT: DWORD = 0x00000011; +pub const SS_ETCHEDFRAME: DWORD = 0x00000012; +pub const SS_TYPEMASK: DWORD = 0x0000001F; +pub const SS_REALSIZECONTROL: DWORD = 0x00000040; +pub const SS_NOPREFIX: DWORD = 0x00000080; +pub const SS_NOTIFY: DWORD = 0x00000100; +pub const SS_CENTERIMAGE: DWORD = 0x00000200; +pub const SS_RIGHTJUST: DWORD = 0x00000400; +pub const SS_REALSIZEIMAGE: DWORD = 0x00000800; +pub const SS_SUNKEN: DWORD = 0x00001000; +pub const SS_EDITCONTROL: DWORD = 0x00002000; +pub const SS_ENDELLIPSIS: DWORD = 0x00004000; +pub const SS_PATHELLIPSIS: DWORD = 0x00008000; +pub const SS_WORDELLIPSIS: DWORD = 0x0000C000; +pub const SS_ELLIPSISMASK: DWORD = 0x0000C000; +pub const STM_SETICON: UINT = 0x0170; +pub const STM_GETICON: UINT = 0x0171; +pub const STM_SETIMAGE: UINT = 0x0172; +pub const STM_GETIMAGE: UINT = 0x0173; +pub const STN_CLICKED: WORD = 0; +pub const STN_DBLCLK: WORD = 1; +pub const STN_ENABLE: WORD = 2; +pub const STN_DISABLE: WORD = 3; +pub const STM_MSGMAX: WORD = 0x0174; +//11194 +extern "system" { + pub fn IsDialogMessageA( + hDlg: HWND, + lpMsg: LPMSG, + ) -> BOOL; + pub fn IsDialogMessageW( + hDlg: HWND, + lpMsg: LPMSG, + ) -> BOOL; + pub fn MapDialogRect( + hDlg: HWND, + lpRect: LPRECT, + ) -> BOOL; + pub fn DlgDirListA( + hDlg: HWND, + lpPathSpec: LPSTR, + nIDListBox: c_int, + nIDStaticPath: c_int, + uFileType: UINT, + ) -> c_int; + pub fn DlgDirListW( + hDlg: HWND, + lpPathSpec: LPWSTR, + nIDListBox: c_int, + nIDStaticPath: c_int, + uFileType: UINT, + ) -> c_int; +} +//11265 +extern "system" { + pub fn DlgDirSelectExA( + hwndDlg: HWND, + lpString: LPSTR, + chCount: c_int, + idListBox: c_int, + ) -> BOOL; + pub fn DlgDirSelectExW( + hwndDlg: HWND, + lpString: LPWSTR, + chCount: c_int, + idListBox: c_int, + ) -> BOOL; + pub fn DlgDirListComboBoxA( + hDlg: HWND, + lpPathSpec: LPSTR, + nIDComboBox: c_int, + nIDStaticPath: c_int, + uFiletype: UINT, + ) -> c_int; + pub fn DlgDirListComboBoxW( + hDlg: HWND, + lpPathSpec: LPWSTR, + nIDComboBox: c_int, + nIDStaticPath: c_int, + uFiletype: UINT, + ) -> c_int; + pub fn DlgDirSelectComboBoxExA( + hwndDlg: HWND, + lpString: LPSTR, + cchOut: c_int, + idComboBox: c_int, + ) -> BOOL; + pub fn DlgDirSelectComboBoxExW( + hwndDlg: HWND, + lpString: LPWSTR, + cchOut: c_int, + idComboBox: c_int, + ) -> BOOL; +} +pub const DS_ABSALIGN: DWORD = 0x01; +pub const DS_SYSMODAL: DWORD = 0x02; +pub const DS_LOCALEDIT: DWORD = 0x20; +pub const DS_SETFONT: DWORD = 0x40; +pub const DS_MODALFRAME: DWORD = 0x80; +pub const DS_NOIDLEMSG: DWORD = 0x100; +pub const DS_SETFOREGROUND: DWORD = 0x200; +pub const DS_3DLOOK: DWORD = 0x0004; +pub const DS_FIXEDSYS: DWORD = 0x0008; +pub const DS_NOFAILCREATE: DWORD = 0x0010; +pub const DS_CONTROL: DWORD = 0x0400; +pub const DS_CENTER: DWORD = 0x0800; +pub const DS_CENTERMOUSE: DWORD = 0x1000; +pub const DS_CONTEXTHELP: DWORD = 0x2000; +pub const DS_SHELLFONT: DWORD = DS_SETFONT | DS_FIXEDSYS; +pub const DS_USEPIXELS: DWORD = 0x8000; +pub const DM_GETDEFID: UINT = WM_USER + 0; +pub const DM_SETDEFID: UINT = WM_USER + 1; +pub const DM_REPOSITION: UINT = WM_USER + 2; +pub const DC_HASDEFID: WORD = 0x534B; +pub const DLGC_WANTARROWS: LRESULT = 0x0001; +pub const DLGC_WANTTAB: LRESULT = 0x0002; +pub const DLGC_WANTALLKEYS: LRESULT = 0x0004; +pub const DLGC_WANTMESSAGE: LRESULT = 0x0004; +pub const DLGC_HASSETSEL: LRESULT = 0x0008; +pub const DLGC_DEFPUSHBUTTON: LRESULT = 0x0010; +pub const DLGC_UNDEFPUSHBUTTON: LRESULT = 0x0020; +pub const DLGC_RADIOBUTTON: LRESULT = 0x0040; +pub const DLGC_WANTCHARS: LRESULT = 0x0080; +pub const DLGC_STATIC: LRESULT = 0x0100; +pub const DLGC_BUTTON: LRESULT = 0x2000; +pub const LB_OKAY: LRESULT = 0; +pub const LB_ERR: LRESULT = -1; +pub const LB_ERRSPACE: LRESULT = -2; +pub const LBN_ERRSPACE: WORD = -2i16 as u16; +pub const LBN_SELCHANGE: WORD = 1; +pub const LBN_DBLCLK: WORD = 2; +pub const LBN_SELCANCEL: WORD = 3; +pub const LBN_SETFOCUS: WORD = 4; +pub const LBN_KILLFOCUS: WORD = 5; +pub const LB_ADDSTRING: UINT = 0x0180; +pub const LB_INSERTSTRING: UINT = 0x0181; +pub const LB_DELETESTRING: UINT = 0x0182; +pub const LB_SELITEMRANGEEX: UINT = 0x0183; +pub const LB_RESETCONTENT: UINT = 0x0184; +pub const LB_SETSEL: UINT = 0x0185; +pub const LB_SETCURSEL: UINT = 0x0186; +pub const LB_GETSEL: UINT = 0x0187; +pub const LB_GETCURSEL: UINT = 0x0188; +pub const LB_GETTEXT: UINT = 0x0189; +pub const LB_GETTEXTLEN: UINT = 0x018A; +pub const LB_GETCOUNT: UINT = 0x018B; +pub const LB_SELECTSTRING: UINT = 0x018C; +pub const LB_DIR: UINT = 0x018D; +pub const LB_GETTOPINDEX: UINT = 0x018E; +pub const LB_FINDSTRING: UINT = 0x018F; +pub const LB_GETSELCOUNT: UINT = 0x0190; +pub const LB_GETSELITEMS: UINT = 0x0191; +pub const LB_SETTABSTOPS: UINT = 0x0192; +pub const LB_GETHORIZONTALEXTENT: UINT = 0x0193; +pub const LB_SETHORIZONTALEXTENT: UINT = 0x0194; +pub const LB_SETCOLUMNWIDTH: UINT = 0x0195; +pub const LB_ADDFILE: UINT = 0x0196; +pub const LB_SETTOPINDEX: UINT = 0x0197; +pub const LB_GETITEMRECT: UINT = 0x0198; +pub const LB_GETITEMDATA: UINT = 0x0199; +pub const LB_SETITEMDATA: UINT = 0x019A; +pub const LB_SELITEMRANGE: UINT = 0x019B; +pub const LB_SETANCHORINDEX: UINT = 0x019C; +pub const LB_GETANCHORINDEX: UINT = 0x019D; +pub const LB_SETCARETINDEX: UINT = 0x019E; +pub const LB_GETCARETINDEX: UINT = 0x019F; +pub const LB_SETITEMHEIGHT: UINT = 0x01A0; +pub const LB_GETITEMHEIGHT: UINT = 0x01A1; +pub const LB_FINDSTRINGEXACT: UINT = 0x01A2; +pub const LB_SETLOCALE: UINT = 0x01A5; +pub const LB_GETLOCALE: UINT = 0x01A6; +pub const LB_SETCOUNT: UINT = 0x01A7; +pub const LB_INITSTORAGE: UINT = 0x01A8; +pub const LB_ITEMFROMPOINT: UINT = 0x01A9; +pub const LB_MULTIPLEADDSTRING: UINT = 0x01B1; +pub const LB_GETLISTBOXINFO: UINT = 0x01B2; +pub const LB_MSGMAX: UINT = 0x01B3; +pub const LBS_NOTIFY: DWORD = 0x0001; +pub const LBS_SORT: DWORD = 0x0002; +pub const LBS_NOREDRAW: DWORD = 0x0004; +pub const LBS_MULTIPLESEL: DWORD = 0x0008; +pub const LBS_OWNERDRAWFIXED: DWORD = 0x0010; +pub const LBS_OWNERDRAWVARIABLE: DWORD = 0x0020; +pub const LBS_HASSTRINGS: DWORD = 0x0040; +pub const LBS_USETABSTOPS: DWORD = 0x0080; +pub const LBS_NOINTEGRALHEIGHT: DWORD = 0x0100; +pub const LBS_MULTICOLUMN: DWORD = 0x0200; +pub const LBS_WANTKEYBOARDINPUT: DWORD = 0x0400; +pub const LBS_EXTENDEDSEL: DWORD = 0x0800; +pub const LBS_DISABLENOSCROLL: DWORD = 0x1000; +pub const LBS_NODATA: DWORD = 0x2000; +pub const LBS_NOSEL: DWORD = 0x4000; +pub const LBS_COMBOBOX: DWORD = 0x8000; +pub const LBS_STANDARD: DWORD = LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER; +pub const CB_OKAY: LRESULT = 0; +pub const CB_ERR: LRESULT = -1; +pub const CB_ERRSPACE: LRESULT = -2; +pub const CBN_ERRSPACE: WORD = -1i16 as u16; +pub const CBN_SELCHANGE: WORD = 1; +pub const CBN_DBLCLK: WORD = 2; +pub const CBN_SETFOCUS: WORD = 3; +pub const CBN_KILLFOCUS: WORD = 4; +pub const CBN_EDITCHANGE: WORD = 5; +pub const CBN_EDITUPDATE: WORD = 6; +pub const CBN_DROPDOWN: WORD = 7; +pub const CBN_CLOSEUP: WORD = 8; +pub const CBN_SELENDOK: WORD = 9; +pub const CBN_SELENDCANCEL: WORD = 10; +pub const CBS_SIMPLE: DWORD = 0x0001; +pub const CBS_DROPDOWN: DWORD = 0x0002; +pub const CBS_DROPDOWNLIST: DWORD = 0x0003; +pub const CBS_OWNERDRAWFIXED: DWORD = 0x0010; +pub const CBS_OWNERDRAWVARIABLE: DWORD = 0x0020; +pub const CBS_AUTOHSCROLL: DWORD = 0x0040; +pub const CBS_OEMCONVERT: DWORD = 0x0080; +pub const CBS_SORT: DWORD = 0x0100; +pub const CBS_HASSTRINGS: DWORD = 0x0200; +pub const CBS_NOINTEGRALHEIGHT: DWORD = 0x0400; +pub const CBS_DISABLENOSCROLL: DWORD = 0x0800; +pub const CBS_UPPERCASE: DWORD = 0x2000; +pub const CBS_LOWERCASE: DWORD = 0x4000; +//11571 +pub const CB_GETEDITSEL: UINT = 0x0140; +pub const CB_LIMITTEXT: UINT = 0x0141; +pub const CB_SETEDITSEL: UINT = 0x0142; +pub const CB_ADDSTRING: UINT = 0x0143; +pub const CB_DELETESTRING: UINT = 0x0144; +pub const CB_DIR: UINT = 0x0145; +pub const CB_GETCOUNT: UINT = 0x0146; +pub const CB_GETCURSEL: UINT = 0x0147; +pub const CB_GETLBTEXT: UINT = 0x0148; +pub const CB_GETLBTEXTLEN: UINT = 0x0149; +pub const CB_INSERTSTRING: UINT = 0x014A; +pub const CB_RESETCONTENT: UINT = 0x014B; +pub const CB_FINDSTRING: UINT = 0x014C; +pub const CB_SELECTSTRING: UINT = 0x014D; +pub const CB_SETCURSEL: UINT = 0x014E; +pub const CB_SHOWDROPDOWN: UINT = 0x014F; +pub const CB_GETITEMDATA: UINT = 0x0150; +pub const CB_SETITEMDATA: UINT = 0x0151; +pub const CB_GETDROPPEDCONTROLRECT: UINT = 0x0152; +pub const CB_SETITEMHEIGHT: UINT = 0x0153; +pub const CB_GETITEMHEIGHT: UINT = 0x0154; +pub const CB_SETEXTENDEDUI: UINT = 0x0155; +pub const CB_GETEXTENDEDUI: UINT = 0x0156; +pub const CB_GETDROPPEDSTATE: UINT = 0x0157; +pub const CB_FINDSTRINGEXACT: UINT = 0x0158; +pub const CB_SETLOCALE: UINT = 0x0159; +pub const CB_GETLOCALE: UINT = 0x015A; +pub const CB_GETTOPINDEX: UINT = 0x015b; +pub const CB_SETTOPINDEX: UINT = 0x015c; +pub const CB_GETHORIZONTALEXTENT: UINT = 0x015d; +pub const CB_SETHORIZONTALEXTENT: UINT = 0x015e; +pub const CB_GETDROPPEDWIDTH: UINT = 0x015f; +pub const CB_SETDROPPEDWIDTH: UINT = 0x0160; +pub const CB_INITSTORAGE: UINT = 0x0161; +pub const CB_MULTIPLEADDSTRING: UINT = 0x0163; +pub const CB_GETCOMBOBOXINFO: UINT = 0x0164; +pub const CB_MSGMAX: UINT = 0x0165; +pub const SBS_HORZ: DWORD = 0x0000; +pub const SBS_VERT: DWORD = 0x0001; +pub const SBS_TOPALIGN: DWORD = 0x0002; +pub const SBS_LEFTALIGN: DWORD = 0x0002; +pub const SBS_BOTTOMALIGN: DWORD = 0x0004; +pub const SBS_RIGHTALIGN: DWORD = 0x0004; +pub const SBS_SIZEBOXTOPLEFTALIGN: DWORD = 0x0002; +pub const SBS_SIZEBOXBOTTOMRIGHTALIGN: DWORD = 0x0004; +pub const SBS_SIZEBOX: DWORD = 0x0008; +pub const SBS_SIZEGRIP: DWORD = 0x0010; +pub const SBM_SETPOS: UINT = 0x00E0; +pub const SBM_GETPOS: UINT = 0x00E1; +pub const SBM_SETRANGE: UINT = 0x00E2; +pub const SBM_SETRANGEREDRAW: UINT = 0x00E6; +pub const SBM_GETRANGE: UINT = 0x00E3; +pub const SBM_ENABLE_ARROWS: UINT = 0x00E4; +pub const SBM_SETSCROLLINFO: UINT = 0x00E9; +pub const SBM_GETSCROLLINFO: UINT = 0x00EA; +pub const SBM_GETSCROLLBARINFO: UINT = 0x00EB; +pub const SIF_RANGE: UINT = 0x0001; +pub const SIF_PAGE: UINT = 0x0002; +pub const SIF_POS: UINT = 0x0004; +pub const SIF_DISABLENOSCROLL: UINT = 0x0008; +pub const SIF_TRACKPOS: UINT = 0x0010; +pub const SIF_ALL: UINT = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS; +STRUCT!{struct SCROLLINFO { + cbSize: UINT, + fMask: UINT, + nMin: c_int, + nMax: c_int, + nPage: UINT, + nPos: c_int, + nTrackPos: c_int, +}} +pub type LPSCROLLINFO = *mut SCROLLINFO; +pub type LPCSCROLLINFO = *const SCROLLINFO; +extern "system" { + pub fn SetScrollInfo( + hwnd: HWND, + nBar: c_int, + lpsi: *const SCROLLINFO, + redraw: BOOL, + ) -> c_int; + pub fn GetScrollInfo( + hwnd: HWND, + nBar: c_int, + lpsi: *mut SCROLLINFO, + ) -> BOOL; +} +pub const MDITILE_VERTICAL: UINT = 0x0000; +pub const MDITILE_HORIZONTAL: UINT = 0x0001; +pub const MDITILE_SKIPDISABLED: UINT = 0x0002; +pub const MDITILE_ZORDER: UINT = 0x0004; +//11776 +extern "system" { + pub fn DefFrameProcA( + hwnd: HWND, + hwndMDIClient: HWND, + uMsg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn DefFrameProcW( + hwnd: HWND, + hwndMDIClient: HWND, + uMsg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn DefMDIChildProcA( + hwnd: HWND, + uMsg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn DefMDIChildProcW( + hwnd: HWND, + uMsg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> LRESULT; + pub fn ArrangeIconicWindows( + hWnd: HWND, + ) -> UINT; + pub fn CreateMDIWindowA( + lpClassName: LPCSTR, + lpWindowName: LPCSTR, + dwStyle: DWORD, + X: c_int, + Y: c_int, + nWidth: c_int, + nHeight: c_int, + hWndParent: HWND, + hInstance: HINSTANCE, + lParam: LPARAM, + ) -> HWND; + pub fn CreateMDIWindowW( + lpClassName: LPCWSTR, + lpWindowName: LPCWSTR, + dwStyle: DWORD, + X: c_int, + Y: c_int, + nWidth: c_int, + nHeight: c_int, + hWndParent: HWND, + hInstance: HINSTANCE, + lParam: LPARAM, + ) -> HWND; + pub fn CascadeWindows( + hwndParent: HWND, + wHow: UINT, + lpRect: *const RECT, + cKids: UINT, + lpKids: *const HWND, + ) -> WORD; +} +//12016 +extern "system" { + pub fn WinHelpA( + hWndMain: HWND, + lpszHelp: LPCSTR, + uCommand: UINT, + dwData: ULONG_PTR, + ) -> BOOL; + pub fn WinHelpW( + hWndMain: HWND, + lpszHelp: LPCWSTR, + uCommand: UINT, + dwData: ULONG_PTR, + ) -> BOOL; +} +//12083 +pub const SPI_GETBEEP: UINT = 0x0001; +pub const SPI_SETBEEP: UINT = 0x0002; +pub const SPI_GETMOUSE: UINT = 0x0003; +pub const SPI_SETMOUSE: UINT = 0x0004; +pub const SPI_GETBORDER: UINT = 0x0005; +pub const SPI_SETBORDER: UINT = 0x0006; +pub const SPI_GETKEYBOARDSPEED: UINT = 0x000A; +pub const SPI_SETKEYBOARDSPEED: UINT = 0x000B; +pub const SPI_LANGDRIVER: UINT = 0x000C; +pub const SPI_ICONHORIZONTALSPACING: UINT = 0x000D; +pub const SPI_GETSCREENSAVETIMEOUT: UINT = 0x000E; +pub const SPI_SETSCREENSAVETIMEOUT: UINT = 0x000F; +pub const SPI_GETSCREENSAVEACTIVE: UINT = 0x0010; +pub const SPI_SETSCREENSAVEACTIVE: UINT = 0x0011; +pub const SPI_GETGRIDGRANULARITY: UINT = 0x0012; +pub const SPI_SETGRIDGRANULARITY: UINT = 0x0013; +pub const SPI_SETDESKWALLPAPER: UINT = 0x0014; +pub const SPI_SETDESKPATTERN: UINT = 0x0015; +pub const SPI_GETKEYBOARDDELAY: UINT = 0x0016; +pub const SPI_SETKEYBOARDDELAY: UINT = 0x0017; +pub const SPI_ICONVERTICALSPACING: UINT = 0x0018; +pub const SPI_GETICONTITLEWRAP: UINT = 0x0019; +pub const SPI_SETICONTITLEWRAP: UINT = 0x001A; +pub const SPI_GETMENUDROPALIGNMENT: UINT = 0x001B; +pub const SPI_SETMENUDROPALIGNMENT: UINT = 0x001C; +pub const SPI_SETDOUBLECLKWIDTH: UINT = 0x001D; +pub const SPI_SETDOUBLECLKHEIGHT: UINT = 0x001E; +pub const SPI_GETICONTITLELOGFONT: UINT = 0x001F; +pub const SPI_SETDOUBLECLICKTIME: UINT = 0x0020; +pub const SPI_SETMOUSEBUTTONSWAP: UINT = 0x0021; +pub const SPI_SETICONTITLELOGFONT: UINT = 0x0022; +pub const SPI_GETFASTTASKSWITCH: UINT = 0x0023; +pub const SPI_SETFASTTASKSWITCH: UINT = 0x0024; +pub const SPI_SETDRAGFULLWINDOWS: UINT = 0x0025; +pub const SPI_GETDRAGFULLWINDOWS: UINT = 0x0026; +pub const SPI_GETNONCLIENTMETRICS: UINT = 0x0029; +pub const SPI_SETNONCLIENTMETRICS: UINT = 0x002A; +pub const SPI_GETMINIMIZEDMETRICS: UINT = 0x002B; +pub const SPI_SETMINIMIZEDMETRICS: UINT = 0x002C; +pub const SPI_GETICONMETRICS: UINT = 0x002D; +pub const SPI_SETICONMETRICS: UINT = 0x002E; +pub const SPI_SETWORKAREA: UINT = 0x002F; +pub const SPI_GETWORKAREA: UINT = 0x0030; +pub const SPI_SETPENWINDOWS: UINT = 0x0031; +pub const SPI_GETHIGHCONTRAST: UINT = 0x0042; +pub const SPI_SETHIGHCONTRAST: UINT = 0x0043; +pub const SPI_GETKEYBOARDPREF: UINT = 0x0044; +pub const SPI_SETKEYBOARDPREF: UINT = 0x0045; +pub const SPI_GETSCREENREADER: UINT = 0x0046; +pub const SPI_SETSCREENREADER: UINT = 0x0047; +pub const SPI_GETANIMATION: UINT = 0x0048; +pub const SPI_SETANIMATION: UINT = 0x0049; +pub const SPI_GETFONTSMOOTHING: UINT = 0x004A; +pub const SPI_SETFONTSMOOTHING: UINT = 0x004B; +pub const SPI_SETDRAGWIDTH: UINT = 0x004C; +pub const SPI_SETDRAGHEIGHT: UINT = 0x004D; +pub const SPI_SETHANDHELD: UINT = 0x004E; +pub const SPI_GETLOWPOWERTIMEOUT: UINT = 0x004F; +pub const SPI_GETPOWEROFFTIMEOUT: UINT = 0x0050; +pub const SPI_SETLOWPOWERTIMEOUT: UINT = 0x0051; +pub const SPI_SETPOWEROFFTIMEOUT: UINT = 0x0052; +pub const SPI_GETLOWPOWERACTIVE: UINT = 0x0053; +pub const SPI_GETPOWEROFFACTIVE: UINT = 0x0054; +pub const SPI_SETLOWPOWERACTIVE: UINT = 0x0055; +pub const SPI_SETPOWEROFFACTIVE: UINT = 0x0056; +pub const SPI_SETCURSORS: UINT = 0x0057; +pub const SPI_SETICONS: UINT = 0x0058; +pub const SPI_GETDEFAULTINPUTLANG: UINT = 0x0059; +pub const SPI_SETDEFAULTINPUTLANG: UINT = 0x005A; +pub const SPI_SETLANGTOGGLE: UINT = 0x005B; +pub const SPI_GETWINDOWSEXTENSION: UINT = 0x005C; +pub const SPI_SETMOUSETRAILS: UINT = 0x005D; +pub const SPI_GETMOUSETRAILS: UINT = 0x005E; +pub const SPI_SETSCREENSAVERRUNNING: UINT = 0x0061; +pub const SPI_SCREENSAVERRUNNING: UINT = SPI_SETSCREENSAVERRUNNING; +pub const SPI_GETFILTERKEYS: UINT = 0x0032; +pub const SPI_SETFILTERKEYS: UINT = 0x0033; +pub const SPI_GETTOGGLEKEYS: UINT = 0x0034; +pub const SPI_SETTOGGLEKEYS: UINT = 0x0035; +pub const SPI_GETMOUSEKEYS: UINT = 0x0036; +pub const SPI_SETMOUSEKEYS: UINT = 0x0037; +pub const SPI_GETSHOWSOUNDS: UINT = 0x0038; +pub const SPI_SETSHOWSOUNDS: UINT = 0x0039; +pub const SPI_GETSTICKYKEYS: UINT = 0x003A; +pub const SPI_SETSTICKYKEYS: UINT = 0x003B; +pub const SPI_GETACCESSTIMEOUT: UINT = 0x003C; +pub const SPI_SETACCESSTIMEOUT: UINT = 0x003D; +pub const SPI_GETSERIALKEYS: UINT = 0x003E; +pub const SPI_SETSERIALKEYS: UINT = 0x003F; +pub const SPI_GETSOUNDSENTRY: UINT = 0x0040; +pub const SPI_SETSOUNDSENTRY: UINT = 0x0041; +pub const SPI_GETSNAPTODEFBUTTON: UINT = 0x005F; +pub const SPI_SETSNAPTODEFBUTTON: UINT = 0x0060; +pub const SPI_GETMOUSEHOVERWIDTH: UINT = 0x0062; +pub const SPI_SETMOUSEHOVERWIDTH: UINT = 0x0063; +pub const SPI_GETMOUSEHOVERHEIGHT: UINT = 0x0064; +pub const SPI_SETMOUSEHOVERHEIGHT: UINT = 0x0065; +pub const SPI_GETMOUSEHOVERTIME: UINT = 0x0066; +pub const SPI_SETMOUSEHOVERTIME: UINT = 0x0067; +pub const SPI_GETWHEELSCROLLLINES: UINT = 0x0068; +pub const SPI_SETWHEELSCROLLLINES: UINT = 0x0069; +pub const SPI_GETMENUSHOWDELAY: UINT = 0x006A; +pub const SPI_SETMENUSHOWDELAY: UINT = 0x006B; +pub const SPI_GETWHEELSCROLLCHARS: UINT = 0x006C; +pub const SPI_SETWHEELSCROLLCHARS: UINT = 0x006D; +pub const SPI_GETSHOWIMEUI: UINT = 0x006E; +pub const SPI_SETSHOWIMEUI: UINT = 0x006F; +pub const SPI_GETMOUSESPEED: UINT = 0x0070; +pub const SPI_SETMOUSESPEED: UINT = 0x0071; +pub const SPI_GETSCREENSAVERRUNNING: UINT = 0x0072; +pub const SPI_GETDESKWALLPAPER: UINT = 0x0073; +pub const SPI_GETAUDIODESCRIPTION: UINT = 0x0074; +pub const SPI_SETAUDIODESCRIPTION: UINT = 0x0075; +pub const SPI_GETSCREENSAVESECURE: UINT = 0x0076; +pub const SPI_SETSCREENSAVESECURE: UINT = 0x0077; +pub const SPI_GETHUNGAPPTIMEOUT: UINT = 0x0078; +pub const SPI_SETHUNGAPPTIMEOUT: UINT = 0x0079; +pub const SPI_GETWAITTOKILLTIMEOUT: UINT = 0x007A; +pub const SPI_SETWAITTOKILLTIMEOUT: UINT = 0x007B; +pub const SPI_GETWAITTOKILLSERVICETIMEOUT: UINT = 0x007C; +pub const SPI_SETWAITTOKILLSERVICETIMEOUT: UINT = 0x007D; +pub const SPI_GETMOUSEDOCKTHRESHOLD: UINT = 0x007E; +pub const SPI_SETMOUSEDOCKTHRESHOLD: UINT = 0x007F; +pub const SPI_GETPENDOCKTHRESHOLD: UINT = 0x0080; +pub const SPI_SETPENDOCKTHRESHOLD: UINT = 0x0081; +pub const SPI_GETWINARRANGING: UINT = 0x0082; +pub const SPI_SETWINARRANGING: UINT = 0x0083; +pub const SPI_GETMOUSEDRAGOUTTHRESHOLD: UINT = 0x0084; +pub const SPI_SETMOUSEDRAGOUTTHRESHOLD: UINT = 0x0085; +pub const SPI_GETPENDRAGOUTTHRESHOLD: UINT = 0x0086; +pub const SPI_SETPENDRAGOUTTHRESHOLD: UINT = 0x0087; +pub const SPI_GETMOUSESIDEMOVETHRESHOLD: UINT = 0x0088; +pub const SPI_SETMOUSESIDEMOVETHRESHOLD: UINT = 0x0089; +pub const SPI_GETPENSIDEMOVETHRESHOLD: UINT = 0x008A; +pub const SPI_SETPENSIDEMOVETHRESHOLD: UINT = 0x008B; +pub const SPI_GETDRAGFROMMAXIMIZE: UINT = 0x008C; +pub const SPI_SETDRAGFROMMAXIMIZE: UINT = 0x008D; +pub const SPI_GETSNAPSIZING: UINT = 0x008E; +pub const SPI_SETSNAPSIZING: UINT = 0x008F; +pub const SPI_GETDOCKMOVING: UINT = 0x0090; +pub const SPI_SETDOCKMOVING: UINT = 0x0091; +pub const SPI_GETACTIVEWINDOWTRACKING: UINT = 0x1000; +pub const SPI_SETACTIVEWINDOWTRACKING: UINT = 0x1001; +pub const SPI_GETMENUANIMATION: UINT = 0x1002; +pub const SPI_SETMENUANIMATION: UINT = 0x1003; +pub const SPI_GETCOMBOBOXANIMATION: UINT = 0x1004; +pub const SPI_SETCOMBOBOXANIMATION: UINT = 0x1005; +pub const SPI_GETLISTBOXSMOOTHSCROLLING: UINT = 0x1006; +pub const SPI_SETLISTBOXSMOOTHSCROLLING: UINT = 0x1007; +pub const SPI_GETGRADIENTCAPTIONS: UINT = 0x1008; +pub const SPI_SETGRADIENTCAPTIONS: UINT = 0x1009; +pub const SPI_GETKEYBOARDCUES: UINT = 0x100A; +pub const SPI_SETKEYBOARDCUES: UINT = 0x100B; +pub const SPI_GETMENUUNDERLINES: UINT = SPI_GETKEYBOARDCUES; +pub const SPI_SETMENUUNDERLINES: UINT = SPI_SETKEYBOARDCUES; +pub const SPI_GETACTIVEWNDTRKZORDER: UINT = 0x100C; +pub const SPI_SETACTIVEWNDTRKZORDER: UINT = 0x100D; +pub const SPI_GETHOTTRACKING: UINT = 0x100E; +pub const SPI_SETHOTTRACKING: UINT = 0x100F; +pub const SPI_GETMENUFADE: UINT = 0x1012; +pub const SPI_SETMENUFADE: UINT = 0x1013; +pub const SPI_GETSELECTIONFADE: UINT = 0x1014; +pub const SPI_SETSELECTIONFADE: UINT = 0x1015; +pub const SPI_GETTOOLTIPANIMATION: UINT = 0x1016; +pub const SPI_SETTOOLTIPANIMATION: UINT = 0x1017; +pub const SPI_GETTOOLTIPFADE: UINT = 0x1018; +pub const SPI_SETTOOLTIPFADE: UINT = 0x1019; +pub const SPI_GETCURSORSHADOW: UINT = 0x101A; +pub const SPI_SETCURSORSHADOW: UINT = 0x101B; +pub const SPI_GETMOUSESONAR: UINT = 0x101C; +pub const SPI_SETMOUSESONAR: UINT = 0x101D; +pub const SPI_GETMOUSECLICKLOCK: UINT = 0x101E; +pub const SPI_SETMOUSECLICKLOCK: UINT = 0x101F; +pub const SPI_GETMOUSEVANISH: UINT = 0x1020; +pub const SPI_SETMOUSEVANISH: UINT = 0x1021; +pub const SPI_GETFLATMENU: UINT = 0x1022; +pub const SPI_SETFLATMENU: UINT = 0x1023; +pub const SPI_GETDROPSHADOW: UINT = 0x1024; +pub const SPI_SETDROPSHADOW: UINT = 0x1025; +pub const SPI_GETBLOCKSENDINPUTRESETS: UINT = 0x1026; +pub const SPI_SETBLOCKSENDINPUTRESETS: UINT = 0x1027; +pub const SPI_GETUIEFFECTS: UINT = 0x103E; +pub const SPI_SETUIEFFECTS: UINT = 0x103F; +pub const SPI_GETDISABLEOVERLAPPEDCONTENT: UINT = 0x1040; +pub const SPI_SETDISABLEOVERLAPPEDCONTENT: UINT = 0x1041; +pub const SPI_GETCLIENTAREAANIMATION: UINT = 0x1042; +pub const SPI_SETCLIENTAREAANIMATION: UINT = 0x1043; +pub const SPI_GETCLEARTYPE: UINT = 0x1048; +pub const SPI_SETCLEARTYPE: UINT = 0x1049; +pub const SPI_GETSPEECHRECOGNITION: UINT = 0x104A; +pub const SPI_SETSPEECHRECOGNITION: UINT = 0x104B; +pub const SPI_GETFOREGROUNDLOCKTIMEOUT: UINT = 0x2000; +pub const SPI_SETFOREGROUNDLOCKTIMEOUT: UINT = 0x2001; +pub const SPI_GETACTIVEWNDTRKTIMEOUT: UINT = 0x2002; +pub const SPI_SETACTIVEWNDTRKTIMEOUT: UINT = 0x2003; +pub const SPI_GETFOREGROUNDFLASHCOUNT: UINT = 0x2004; +pub const SPI_SETFOREGROUNDFLASHCOUNT: UINT = 0x2005; +pub const SPI_GETCARETWIDTH: UINT = 0x2006; +pub const SPI_SETCARETWIDTH: UINT = 0x2007; +pub const SPI_GETMOUSECLICKLOCKTIME: UINT = 0x2008; +pub const SPI_SETMOUSECLICKLOCKTIME: UINT = 0x2009; +pub const SPI_GETFONTSMOOTHINGTYPE: UINT = 0x200A; +pub const SPI_SETFONTSMOOTHINGTYPE: UINT = 0x200B; +pub const FE_FONTSMOOTHINGSTANDARD: UINT = 0x0001; +pub const FE_FONTSMOOTHINGCLEARTYPE: UINT = 0x0002; +pub const SPI_GETFONTSMOOTHINGCONTRAST: UINT = 0x200C; +pub const SPI_SETFONTSMOOTHINGCONTRAST: UINT = 0x200D; +pub const SPI_GETFOCUSBORDERWIDTH: UINT = 0x200E; +pub const SPI_SETFOCUSBORDERWIDTH: UINT = 0x200F; +pub const SPI_GETFOCUSBORDERHEIGHT: UINT = 0x2010; +pub const SPI_SETFOCUSBORDERHEIGHT: UINT = 0x2011; +pub const SPI_GETFONTSMOOTHINGORIENTATION: UINT = 0x2012; +pub const SPI_SETFONTSMOOTHINGORIENTATION: UINT = 0x2013; +pub const FE_FONTSMOOTHINGORIENTATIONBGR: UINT = 0x0000; +pub const FE_FONTSMOOTHINGORIENTATIONRGB: UINT = 0x0001; +pub const SPI_GETMINIMUMHITRADIUS: UINT = 0x2014; +pub const SPI_SETMINIMUMHITRADIUS: UINT = 0x2015; +pub const SPI_GETMESSAGEDURATION: UINT = 0x2016; +pub const SPI_SETMESSAGEDURATION: UINT = 0x2017; +//12472 +pub const SPIF_UPDATEINIFILE: UINT = 0x0001; +pub const SPIF_SENDWININICHANGE: UINT = 0x0002; +pub const SPIF_SENDCHANGE: UINT = SPIF_SENDWININICHANGE; +//12484 +STRUCT!{struct NONCLIENTMETRICSA { + cbSize: UINT, + iBorderWidth: c_int, + iScrollWidth: c_int, + iScrollHeight: c_int, + iCaptionWidth: c_int, + iCaptionHeight: c_int, + lfCaptionFont: LOGFONTA, + iSmCaptionWidth: c_int, + iSmCaptionHeight: c_int, + lfSmCaptionFont: LOGFONTA, + iMenuWidth: c_int, + iMenuHeight: c_int, + lfMenuFont: LOGFONTA, + lfStatusFont: LOGFONTA, + lfMessageFont: LOGFONTA, + iPaddedBorderWidth: c_int, +}} +pub type LPNONCLIENTMETRICSA = *mut NONCLIENTMETRICSA; +STRUCT!{struct NONCLIENTMETRICSW { + cbSize: UINT, + iBorderWidth: c_int, + iScrollWidth: c_int, + iScrollHeight: c_int, + iCaptionWidth: c_int, + iCaptionHeight: c_int, + lfCaptionFont: LOGFONTW, + iSmCaptionWidth: c_int, + iSmCaptionHeight: c_int, + lfSmCaptionFont: LOGFONTW, + iMenuWidth: c_int, + iMenuHeight: c_int, + lfMenuFont: LOGFONTW, + lfStatusFont: LOGFONTW, + lfMessageFont: LOGFONTW, + iPaddedBorderWidth: c_int, +}} +pub type LPNONCLIENTMETRICSW = *mut NONCLIENTMETRICSW; +//12598 +STRUCT!{struct ANIMATIONINFO { + cbSize: UINT, + iMinAnimate: c_int, +}} +pub type LPANIMATIONINFO = *mut ANIMATIONINFO; +//12672 +pub const CDS_UPDATEREGISTRY: DWORD = 0x00000001; +pub const CDS_TEST: DWORD = 0x00000002; +pub const CDS_FULLSCREEN: DWORD = 0x00000004; +pub const CDS_GLOBAL: DWORD = 0x00000008; +pub const CDS_SET_PRIMARY: DWORD = 0x00000010; +pub const CDS_VIDEOPARAMETERS: DWORD = 0x00000020; +pub const CDS_ENABLE_UNSAFE_MODES: DWORD = 0x00000100; +pub const CDS_DISABLE_UNSAFE_MODES: DWORD = 0x00000200; +pub const CDS_RESET: DWORD = 0x40000000; +pub const CDS_RESET_EX: DWORD = 0x20000000; +pub const CDS_NORESET: DWORD = 0x10000000; +pub const DISP_CHANGE_SUCCESSFUL: LONG = 0; +pub const DISP_CHANGE_RESTART: LONG = 1; +pub const DISP_CHANGE_FAILED: LONG = -1; +pub const DISP_CHANGE_BADMODE: LONG = -2; +pub const DISP_CHANGE_NOTUPDATED: LONG = -3; +pub const DISP_CHANGE_BADFLAGS: LONG = -4; +pub const DISP_CHANGE_BADPARAM: LONG = -5; +pub const DISP_CHANGE_BADDUALVIEW: LONG = -6; +extern "system" { + pub fn ChangeDisplaySettingsA( + lpDevMode: *mut DEVMODEA, + dwFlags: DWORD, + ) -> LONG; + pub fn ChangeDisplaySettingsW( + lpDevMode: *mut DEVMODEW, + dwFlags: DWORD, + ) -> LONG; + pub fn ChangeDisplaySettingsExA( + lpszDeviceName: LPCSTR, + lpDevMode: *mut DEVMODEA, + hwnd: HWND, + dwFlags: DWORD, + lParam: LPVOID, + ) -> LONG; + pub fn ChangeDisplaySettingsExW( + lpszDeviceName: LPCWSTR, + lpDevMode: *mut DEVMODEW, + hwnd: HWND, + dwFlags: DWORD, + lParam: LPVOID, + ) -> LONG; +} +pub const ENUM_CURRENT_SETTINGS: DWORD = 0xFFFFFFFF; +pub const ENUM_REGISTRY_SETTINGS: DWORD = 0xFFFFFFFE; +extern "system" { + pub fn EnumDisplaySettingsA( + lpszDeviceName: LPCSTR, + iModeNum: DWORD, + lpDevMode: *mut DEVMODEA, + ) -> BOOL; + pub fn EnumDisplaySettingsW( + lpszDeviceName: LPCWSTR, + iModeNum: DWORD, + lpDevMode: *mut DEVMODEW, + ) -> BOOL; + pub fn EnumDisplaySettingsExA( + lpszDeviceName: LPCSTR, + iModeNum: DWORD, + lpDevMode: *mut DEVMODEA, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumDisplaySettingsExW( + lpszDeviceName: LPCWSTR, + iModeNum: DWORD, + lpDevMode: *mut DEVMODEW, + dwFlags: DWORD, + ) -> BOOL; +} +pub const EDS_RAWMODE: DWORD = 0x00000002; +pub const EDS_ROTATEDMODE: DWORD = 0x00000004; +extern "system" { + pub fn EnumDisplayDevicesA( + lpDevice: LPCSTR, + iDevNum: DWORD, + lpDisplayDevice: PDISPLAY_DEVICEA, + dwFlags: DWORD, + ) -> BOOL; + pub fn EnumDisplayDevicesW( + lpDevice: LPCWSTR, + iDevNum: DWORD, + lpDisplayDevice: PDISPLAY_DEVICEW, + dwFlags: DWORD, + ) -> BOOL; +} +pub const EDD_GET_DEVICE_INTERFACE_NAME: DWORD = 0x00000001; +extern "system" { + pub fn SystemParametersInfoA( + uiAction: UINT, + uiParam: UINT, + pvParam: PVOID, + fWinIni: UINT, + ) -> BOOL; + pub fn SystemParametersInfoW( + uiAction: UINT, + uiParam: UINT, + pvParam: PVOID, + fWinIni: UINT, + ) -> BOOL; + pub fn SystemParametersInfoForDpi( + uiAction: UINT, + uiParam: UINT, + pvParam: PVOID, + fWinIni: UINT, + dpi: UINT, + ) -> BOOL; +} +//13191 +extern "system" { + pub fn SetLastErrorEx( + dwErrCode: DWORD, + dwType: DWORD, + ); + pub fn InternalGetWindowText( + hWnd: HWND, + pString: LPWSTR, + cchMaxCount: c_int, + ) -> c_int; + pub fn EndTask( + hWnd: HWND, + fShutDown: BOOL, + fForce: BOOL, + ) -> BOOL; + pub fn CancelShutdown() -> BOOL; +} +pub const MONITOR_DEFAULTTONULL: DWORD = 0x00000000; +pub const MONITOR_DEFAULTTOPRIMARY: DWORD = 0x00000001; +pub const MONITOR_DEFAULTTONEAREST: DWORD = 0x00000002; +extern "system" { + pub fn MonitorFromPoint( + pt: POINT, + dwFlags: DWORD, + ) -> HMONITOR; + pub fn MonitorFromRect( + lprc: LPCRECT, + dwFlags: DWORD, + ) -> HMONITOR; + pub fn MonitorFromWindow( + hwnd: HWND, + dwFlags: DWORD, + ) -> HMONITOR; +} +pub const MONITORINFOF_PRIMARY: DWORD = 1; +pub const CCHDEVICENAME: usize = 32; +STRUCT!{struct MONITORINFO { + cbSize: DWORD, + rcMonitor: RECT, + rcWork: RECT, + dwFlags: DWORD, +}} +pub type LPMONITORINFO = *mut MONITORINFO; +STRUCT!{struct MONITORINFOEXA { + cbSize: DWORD, + rcMonitor: RECT, + rcWork: RECT, + dwFlags: DWORD, + szDevice: [CHAR; CCHDEVICENAME], +}} +pub type LPMONITORINFOEXA = *mut MONITORINFOEXA; +STRUCT!{struct MONITORINFOEXW { + cbSize: DWORD, + rcMonitor: RECT, + rcWork: RECT, + dwFlags: DWORD, + szDevice: [WCHAR; CCHDEVICENAME], +}} +pub type LPMONITORINFOEXW = *mut MONITORINFOEXW; +extern "system" { + pub fn GetMonitorInfoA( + hMonitor: HMONITOR, + lpmi: LPMONITORINFO, + ) -> BOOL; + pub fn GetMonitorInfoW( + hMonitor: HMONITOR, + lpmi: LPMONITORINFO, + ) -> BOOL; +} +FN!{stdcall MONITORENUMPROC( + HMONITOR, + HDC, + LPRECT, + LPARAM, +) -> BOOL} +extern "system" { + pub fn EnumDisplayMonitors( + hdc: HDC, + lprcClip: LPCRECT, + lpfnEnum: MONITORENUMPROC, + dwData: LPARAM, + ) -> BOOL; + pub fn NotifyWinEvent( + event: DWORD, + hwnd: HWND, + idObject: LONG, + idChild: LONG, + ); +} +FN!{stdcall WINEVENTPROC( + HWINEVENTHOOK, + DWORD, + HWND, + LONG, + LONG, + DWORD, + DWORD, +) -> ()} +extern "system" { + pub fn SetWinEventHook( + eventMin: DWORD, + eventMax: DWORD, + hmodWinEventProc: HMODULE, + pfnWinEventProc: WINEVENTPROC, + idProcess: DWORD, + idThread: DWORD, + dwFlags: DWORD, + ) -> HWINEVENTHOOK; + pub fn IsWinEventHookInstalled( + event: DWORD, + ) -> BOOL; +} +pub const WINEVENT_OUTOFCONTEXT: UINT = 0x0000; +pub const WINEVENT_SKIPOWNTHREAD: UINT = 0x0001; +pub const WINEVENT_SKIPOWNPROCESS: UINT = 0x0002; +pub const WINEVENT_INCONTEXT: UINT = 0x0004; +extern "system" { + pub fn UnhookWinEvent( + hWinEventHook: HWINEVENTHOOK, + ) -> BOOL; +} +pub const CHILDID_SELF: LONG = 0; +pub const INDEXID_OBJECT: LONG = 0; +pub const INDEXID_CONTAINER: LONG = 0; +pub const OBJID_WINDOW: LONG = 0x0000; +pub const OBJID_SYSMENU: LONG = 0xFFFFFFFF; +pub const OBJID_TITLEBAR: LONG = 0xFFFFFFFE; +pub const OBJID_MENU: LONG = 0xFFFFFFFD; +pub const OBJID_CLIENT: LONG = 0xFFFFFFFC; +pub const OBJID_VSCROLL: LONG = 0xFFFFFFFB; +pub const OBJID_HSCROLL: LONG = 0xFFFFFFFA; +pub const OBJID_SIZEGRIP: LONG = 0xFFFFFFF9; +pub const OBJID_CARET: LONG = 0xFFFFFFF8; +pub const OBJID_CURSOR: LONG = 0xFFFFFFF7; +pub const OBJID_ALERT: LONG = 0xFFFFFFF6; +pub const OBJID_SOUND: LONG = 0xFFFFFFF5; +pub const OBJID_QUERYCLASSNAMEIDX: LONG = 0xFFFFFFF4; +pub const OBJID_NATIVEOM: LONG = 0xFFFFFFF0; +pub const EVENT_MIN: UINT = 0x0001; +pub const EVENT_MAX: UINT = 0x7FFFFFFF; +pub const EVENT_SYSTEM_SOUND: UINT = 0x0001; +pub const EVENT_SYSTEM_ALERT: UINT = 0x0002; +pub const EVENT_SYSTEM_FOREGROUND: UINT = 0x0003; +pub const EVENT_SYSTEM_MENUSTART: UINT = 0x0004; +pub const EVENT_SYSTEM_MENUEND: UINT = 0x0005; +pub const EVENT_SYSTEM_MENUPOPUPSTART: UINT = 0x0006; +pub const EVENT_SYSTEM_MENUPOPUPEND: UINT = 0x0007; +pub const EVENT_SYSTEM_CAPTURESTART: UINT = 0x0008; +pub const EVENT_SYSTEM_CAPTUREEND: UINT = 0x0009; +pub const EVENT_SYSTEM_MOVESIZESTART: UINT = 0x000A; +pub const EVENT_SYSTEM_MOVESIZEEND: UINT = 0x000B; +pub const EVENT_SYSTEM_CONTEXTHELPSTART: UINT = 0x000C; +pub const EVENT_SYSTEM_CONTEXTHELPEND: UINT = 0x000D; +pub const EVENT_SYSTEM_DRAGDROPSTART: UINT = 0x000E; +pub const EVENT_SYSTEM_DRAGDROPEND: UINT = 0x000F; +pub const EVENT_SYSTEM_DIALOGSTART: UINT = 0x0010; +pub const EVENT_SYSTEM_DIALOGEND: UINT = 0x0011; +pub const EVENT_SYSTEM_SCROLLINGSTART: UINT = 0x0012; +pub const EVENT_SYSTEM_SCROLLINGEND: UINT = 0x0013; +pub const EVENT_SYSTEM_SWITCHSTART: UINT = 0x0014; +pub const EVENT_SYSTEM_SWITCHEND: UINT = 0x0015; +pub const EVENT_SYSTEM_MINIMIZESTART: UINT = 0x0016; +pub const EVENT_SYSTEM_MINIMIZEEND: UINT = 0x0017; +pub const EVENT_SYSTEM_DESKTOPSWITCH: UINT = 0x0020; +pub const EVENT_SYSTEM_SWITCHER_APPGRABBED: UINT = 0x0024; +pub const EVENT_SYSTEM_SWITCHER_APPOVERTARGET: UINT = 0x0025; +pub const EVENT_SYSTEM_SWITCHER_APPDROPPED: UINT = 0x0026; +pub const EVENT_SYSTEM_SWITCHER_CANCELLED: UINT = 0x0027; +pub const EVENT_SYSTEM_IME_KEY_NOTIFICATION: UINT = 0x0029; +pub const EVENT_SYSTEM_END: UINT = 0x00FF; +pub const EVENT_OEM_DEFINED_START: UINT = 0x0101; +pub const EVENT_OEM_DEFINED_END: UINT = 0x01FF; +pub const EVENT_UIA_EVENTID_START: UINT = 0x4E00; +pub const EVENT_UIA_EVENTID_END: UINT = 0x4EFF; +pub const EVENT_UIA_PROPID_START: UINT = 0x7500; +pub const EVENT_UIA_PROPID_END: UINT = 0x75FF; +pub const EVENT_CONSOLE_CARET: UINT = 0x4001; +pub const EVENT_CONSOLE_UPDATE_REGION: UINT = 0x4002; +pub const EVENT_CONSOLE_UPDATE_SIMPLE: UINT = 0x4003; +pub const EVENT_CONSOLE_UPDATE_SCROLL: UINT = 0x4004; +pub const EVENT_CONSOLE_LAYOUT: UINT = 0x4005; +pub const EVENT_CONSOLE_START_APPLICATION: UINT = 0x4006; +pub const EVENT_CONSOLE_END_APPLICATION: UINT = 0x4007; +#[cfg(target_pointer_width = "64")] +pub const CONSOLE_APPLICATION_16BIT: LONG = 0x0000; +#[cfg(target_pointer_width = "32")] +pub const CONSOLE_APPLICATION_16BIT: LONG = 0x0001; +pub const CONSOLE_CARET_SELECTION: LONG = 0x0001; +pub const CONSOLE_CARET_VISIBLE: LONG = 0x0002; +pub const EVENT_CONSOLE_END: UINT = 0x40FF; +pub const EVENT_OBJECT_CREATE: UINT = 0x8000; +pub const EVENT_OBJECT_DESTROY: UINT = 0x8001; +pub const EVENT_OBJECT_SHOW: UINT = 0x8002; +pub const EVENT_OBJECT_HIDE: UINT = 0x8003; +pub const EVENT_OBJECT_REORDER: UINT = 0x8004; +pub const EVENT_OBJECT_FOCUS: UINT = 0x8005; +pub const EVENT_OBJECT_SELECTION: UINT = 0x8006; +pub const EVENT_OBJECT_SELECTIONADD: UINT = 0x8007; +pub const EVENT_OBJECT_SELECTIONREMOVE: UINT = 0x8008; +pub const EVENT_OBJECT_SELECTIONWITHIN: UINT = 0x8009; +pub const EVENT_OBJECT_STATECHANGE: UINT = 0x800A; +pub const EVENT_OBJECT_LOCATIONCHANGE: UINT = 0x800B; +pub const EVENT_OBJECT_NAMECHANGE: UINT = 0x800C; +pub const EVENT_OBJECT_DESCRIPTIONCHANGE: UINT = 0x800D; +pub const EVENT_OBJECT_VALUECHANGE: UINT = 0x800E; +pub const EVENT_OBJECT_PARENTCHANGE: UINT = 0x800F; +pub const EVENT_OBJECT_HELPCHANGE: UINT = 0x8010; +pub const EVENT_OBJECT_DEFACTIONCHANGE: UINT = 0x8011; +pub const EVENT_OBJECT_ACCELERATORCHANGE: UINT = 0x8012; +pub const EVENT_OBJECT_INVOKED: UINT = 0x8013; +pub const EVENT_OBJECT_TEXTSELECTIONCHANGED: UINT = 0x8014; +pub const EVENT_OBJECT_CONTENTSCROLLED: UINT = 0x8015; +pub const EVENT_SYSTEM_ARRANGMENTPREVIEW: UINT = 0x8016; +pub const EVENT_OBJECT_CLOAKED: UINT = 0x8017; +pub const EVENT_OBJECT_UNCLOAKED: UINT = 0x8018; +pub const EVENT_OBJECT_LIVEREGIONCHANGED: UINT = 0x8019; +pub const EVENT_OBJECT_HOSTEDOBJECTSINVALIDATED: UINT = 0x8020; +pub const EVENT_OBJECT_DRAGSTART: UINT = 0x8021; +pub const EVENT_OBJECT_DRAGCANCEL: UINT = 0x8022; +pub const EVENT_OBJECT_DRAGCOMPLETE: UINT = 0x8023; +pub const EVENT_OBJECT_DRAGENTER: UINT = 0x8024; +pub const EVENT_OBJECT_DRAGLEAVE: UINT = 0x8025; +pub const EVENT_OBJECT_DRAGDROPPED: UINT = 0x8026; +pub const EVENT_OBJECT_IME_SHOW: UINT = 0x8027; +pub const EVENT_OBJECT_IME_HIDE: UINT = 0x8028; +pub const EVENT_OBJECT_IME_CHANGE: UINT = 0x8029; +pub const EVENT_OBJECT_TEXTEDIT_CONVERSIONTARGETCHANGED: UINT = 0x8030; +pub const EVENT_OBJECT_END: UINT = 0x80FF; +pub const EVENT_AIA_START: UINT = 0xA000; +pub const EVENT_AIA_END: UINT = 0xAFFF; +pub const ALERT_SYSTEM_INFORMATIONAL: LONG = 1; +pub const ALERT_SYSTEM_WARNING: LONG = 2; +pub const ALERT_SYSTEM_ERROR: LONG = 3; +pub const ALERT_SYSTEM_QUERY: LONG = 4; +pub const ALERT_SYSTEM_CRITICAL: LONG = 5; +pub const CALERT_SYSTEM: LONG = 6; +STRUCT!{struct GUITHREADINFO { + cbSize: DWORD, + flags: DWORD, + hwndActive: HWND, + hwndFocus: HWND, + hwndCapture: HWND, + hwndMenuOwner: HWND, + hwndMoveSize: HWND, + hwndCaret: HWND, + rcCaret: RECT, +}} +pub type PGUITHREADINFO = *mut GUITHREADINFO; +pub type LPGUITHREADINFO = *mut GUITHREADINFO; +pub const GUI_CARETBLINKING: DWORD = 0x00000001; +pub const GUI_INMOVESIZE: DWORD = 0x00000002; +pub const GUI_INMENUMODE: DWORD = 0x00000004; +pub const GUI_SYSTEMMENUMODE: DWORD = 0x00000008; +pub const GUI_POPUPMENUMODE: DWORD = 0x00000010; +#[cfg(target_arch = "x86_64")] +pub const GUI_16BITTASK: DWORD = 0x00000000; +#[cfg(target_arch = "x86")] +pub const GUI_16BITTASK: DWORD = 0x00000020; +extern "system" { + pub fn GetGUIThreadInfo( + idThread: DWORD, + pgui: PGUITHREADINFO, + ) -> BOOL; + pub fn BlockInput( + fBlockIt: BOOL, + ) -> BOOL; +} +pub const USER_DEFAULT_SCREEN_DPI: LONG = 96; +extern "system" { + pub fn SetProcessDPIAware() -> BOOL; + pub fn IsProcessDPIAware() -> BOOL; + pub fn SetThreadDpiAwarenessContext( + dpiContext: DPI_AWARENESS_CONTEXT, + ) -> DPI_AWARENESS_CONTEXT; + pub fn GetThreadDpiAwarenessContext() -> DPI_AWARENESS_CONTEXT; + pub fn GetWindowDpiAwarenessContext( + hwnd: HWND, + ) -> DPI_AWARENESS_CONTEXT; + pub fn GetAwarenessFromDpiAwarenessContext( + value: DPI_AWARENESS_CONTEXT, + ) -> DPI_AWARENESS; + pub fn GetDpiFromDpiAwarenessContext( + value: DPI_AWARENESS_CONTEXT, + ) -> UINT; + pub fn AreDpiAwarenessContextsEqual( + dpiContextA: DPI_AWARENESS_CONTEXT, + dpiContextB: DPI_AWARENESS_CONTEXT, + ) -> BOOL; + pub fn IsValidDpiAwarenessContext( + value: DPI_AWARENESS_CONTEXT, + ) -> BOOL; + pub fn GetDpiForWindow( + hwnd: HWND, + ) -> UINT; + pub fn GetDpiForSystem() -> UINT; + pub fn GetSystemDpiForProcess( + hProcess: HANDLE, + ) -> UINT; + pub fn EnableNonClientDpiScaling( + hwnd: HWND, + ) -> BOOL; + pub fn SetProcessDpiAwarenessContext( + value: DPI_AWARENESS_CONTEXT, + ) -> BOOL; + pub fn SetThreadDpiHostingBehavior( + value: DPI_HOSTING_BEHAVIOR, + ) -> DPI_HOSTING_BEHAVIOR; + pub fn GetThreadDpiHostingBehavior() -> DPI_HOSTING_BEHAVIOR; + pub fn GetWindowDpiHostingBehavior( + hwnd: HWND, + ) -> DPI_HOSTING_BEHAVIOR; + pub fn GetWindowModuleFileNameA( + hWnd: HWND, + lpszFileName: LPCSTR, + cchFileNameMax: UINT, + ) -> UINT; + pub fn GetWindowModuleFileNameW( + hWnd: HWND, + lpszFileName: LPWSTR, + cchFileNameMax: UINT, + ) -> UINT; +} +pub const STATE_SYSTEM_UNAVAILABLE: DWORD = 0x00000001; +pub const STATE_SYSTEM_SELECTED: DWORD = 0x00000002; +pub const STATE_SYSTEM_FOCUSED: DWORD = 0x00000004; +pub const STATE_SYSTEM_PRESSED: DWORD = 0x00000008; +pub const STATE_SYSTEM_CHECKED: DWORD = 0x00000010; +pub const STATE_SYSTEM_MIXED: DWORD = 0x00000020; +pub const STATE_SYSTEM_INDETERMINATE: DWORD = STATE_SYSTEM_MIXED; +pub const STATE_SYSTEM_READONLY: DWORD = 0x00000040; +pub const STATE_SYSTEM_HOTTRACKED: DWORD = 0x00000080; +pub const STATE_SYSTEM_DEFAULT: DWORD = 0x00000100; +pub const STATE_SYSTEM_EXPANDED: DWORD = 0x00000200; +pub const STATE_SYSTEM_COLLAPSED: DWORD = 0x00000400; +pub const STATE_SYSTEM_BUSY: DWORD = 0x00000800; +pub const STATE_SYSTEM_FLOATING: DWORD = 0x00001000; +pub const STATE_SYSTEM_MARQUEED: DWORD = 0x00002000; +pub const STATE_SYSTEM_ANIMATED: DWORD = 0x00004000; +pub const STATE_SYSTEM_INVISIBLE: DWORD = 0x00008000; +pub const STATE_SYSTEM_OFFSCREEN: DWORD = 0x00010000; +pub const STATE_SYSTEM_SIZEABLE: DWORD = 0x00020000; +pub const STATE_SYSTEM_MOVEABLE: DWORD = 0x00040000; +pub const STATE_SYSTEM_SELFVOICING: DWORD = 0x00080000; +pub const STATE_SYSTEM_FOCUSABLE: DWORD = 0x00100000; +pub const STATE_SYSTEM_SELECTABLE: DWORD = 0x00200000; +pub const STATE_SYSTEM_LINKED: DWORD = 0x00400000; +pub const STATE_SYSTEM_TRAVERSED: DWORD = 0x00800000; +pub const STATE_SYSTEM_MULTISELECTABLE: DWORD = 0x01000000; +pub const STATE_SYSTEM_EXTSELECTABLE: DWORD = 0x02000000; +pub const STATE_SYSTEM_ALERT_LOW: DWORD = 0x04000000; +pub const STATE_SYSTEM_ALERT_MEDIUM: DWORD = 0x08000000; +pub const STATE_SYSTEM_ALERT_HIGH: DWORD = 0x10000000; +pub const STATE_SYSTEM_PROTECTED: DWORD = 0x20000000; +pub const STATE_SYSTEM_VALID: DWORD = 0x3fffffff; +pub const CCHILDREN_TITLEBAR: usize = 5; +pub const CCHILDREN_SCROLLBAR: usize = 5; +STRUCT!{struct CURSORINFO { + cbSize: DWORD, + flags: DWORD, + hCursor: HCURSOR, + ptScreenPos: POINT, +}} +pub type PCURSORINFO = *mut CURSORINFO; +pub type LPCURSORINFO = *mut CURSORINFO; +pub const CURSOR_SHOWING: DWORD = 0x00000001; +pub const CURSOR_SUPPRESSED: DWORD = 0x00000002; +extern "system" { + pub fn GetCursorInfo( + pci: PCURSORINFO, + ) -> BOOL; +} +STRUCT!{struct WINDOWINFO { + cbSize: DWORD, + rcWindow: RECT, + rcClient: RECT, + dwStyle: DWORD, + dwExStyle: DWORD, + dwWindowStatus: DWORD, + cxWindowBorders: UINT, + cyWindowBorders: UINT, + atomWindowType: ATOM, + wCreatorVersion: WORD, +}} +pub type PWINDOWINFO = *mut WINDOWINFO; +pub type LPWINDOWINFO = *mut WINDOWINFO; +pub const WS_ACTIVECAPTION: DWORD = 0x0001; +extern "system" { + pub fn GetWindowInfo( + hwnd: HWND, + pwi: PWINDOWINFO, + ) -> BOOL; +} +STRUCT!{struct TITLEBARINFO { + cbSize: DWORD, + rcTitleBar: RECT, + rgstate: [DWORD; CCHILDREN_TITLEBAR + 1], +}} +pub type PTITLEBARINFO = *mut TITLEBARINFO; +pub type LPTITLEBARINFO = *mut TITLEBARINFO; +extern "system" { + pub fn GetTitleBarInfo( + hwnd: HWND, + pti: PTITLEBARINFO, + ) -> BOOL; +} +STRUCT!{struct TITLEBARINFOEX { + cbSize: DWORD, + rcTitleBar: RECT, + rgstate: [DWORD; CCHILDREN_TITLEBAR + 1], + rgrect: [RECT; CCHILDREN_TITLEBAR + 1], +}} +pub type PTITLEBARINFOEX = *mut TITLEBARINFOEX; +pub type LPTITLEBARINFOEX = *mut TITLEBARINFOEX; +STRUCT!{struct MENUBARINFO { + cbSize: DWORD, + rcBar: RECT, + hMenu: HMENU, + hwndMenu: HWND, + BitFields: BOOL, +}} +BITFIELD!{MENUBARINFO BitFields: BOOL [ + fBarFocused set_fBarFocused[0..1], + fFocused set_fFocused[1..2], +]} +pub type PMENUBARINFO = *mut MENUBARINFO; +pub type LPMENUBARINFO = *mut MENUBARINFO; +extern "system" { + pub fn GetMenuBarInfo( + hwnd: HWND, + idObject: LONG, + idItem: LONG, + pmbi: PMENUBARINFO, + ) -> BOOL; +} +STRUCT!{struct SCROLLBARINFO { + cbSize: DWORD, + rcScrollBar: RECT, + dxyLineButton: c_int, + xyThumbTop: c_int, + xyThumbBottom: c_int, + reserved: c_int, + rgstate: [DWORD; CCHILDREN_SCROLLBAR + 1], +}} +pub type PSCROLLBARINFO = *mut SCROLLBARINFO; +pub type LPSCROLLBARINFO = *mut SCROLLBARINFO; +extern "system" { + pub fn GetScrollBarInfo( + hwnd: HWND, + idObject: LONG, + psbi: PSCROLLBARINFO, + ) -> BOOL; +} +STRUCT!{struct COMBOBOXINFO { + cbSize: DWORD, + rcItem: RECT, + rcButton: RECT, + stateButton: DWORD, + hwndCombo: HWND, + hwndItem: HWND, + hwndList: HWND, +}} +pub type PCOMBOBOXINFO = *mut COMBOBOXINFO; +pub type LPCOMBOBOXINFO = *mut COMBOBOXINFO; +extern "system" { + pub fn GetComboBoxInfo( + hwndCombo: HWND, + pcbi: PCOMBOBOXINFO, + ) -> BOOL; +} +pub const GA_PARENT: UINT = 1; +pub const GA_ROOT: UINT = 2; +pub const GA_ROOTOWNER: UINT = 3; +extern "system" { + pub fn GetAncestor( + hWnd: HWND, + gaFlags: UINT, + ) -> HWND; + pub fn RealChildWindowFromPoint( + hwndParent: HWND, + ptParentClientCoords: POINT, + ) -> HWND; + pub fn RealGetWindowClassA( + hwnd: HWND, + ptszClassName: LPSTR, + cchClassNameMax: UINT, + ) -> UINT; + pub fn RealGetWindowClassW( + hwnd: HWND, + ptszClassName: LPWSTR, + cchClassNameMax: UINT, + ) -> UINT; +} +STRUCT!{struct ALTTABINFO { + cbSize: DWORD, + cItems: c_int, + cColumns: c_int, + cRows: c_int, + iColFocus: c_int, + iRowFocus: c_int, + cxItem: c_int, + cyItem: c_int, + ptStart: POINT, +}} +pub type PALTTABINFO = *mut ALTTABINFO; +pub type LPALTTABINFO = *mut ALTTABINFO; +extern "system" { + pub fn GetAltTabInfoA( + hwnd: HWND, + iItem: c_int, + pati: PALTTABINFO, + pszItemText: LPSTR, + cchItemText: UINT, + ) -> BOOL; + pub fn GetAltTabInfoW( + hwnd: HWND, + iItem: c_int, + pati: PALTTABINFO, + pszItemText: LPWSTR, + cchItemText: UINT, + ) -> BOOL; + pub fn GetListBoxInfo( + hwnd: HWND, + ) -> DWORD; + pub fn LockWorkStation() -> BOOL; + pub fn UserHandleGrantAccess( + hUserHandle: HANDLE, + hJob: HANDLE, + bGrant: BOOL, + ) -> BOOL; +} +DECLARE_HANDLE!{HRAWINPUT, HRAWINPUT__} +#[inline] +pub fn GET_RAWINPUT_CODE_WPARAM(wParam: WPARAM) -> WPARAM { wParam & 0xff } +pub const RIM_INPUT: WPARAM = 0; +pub const RIM_INPUTSINK: WPARAM = 1; +STRUCT!{struct RAWINPUTHEADER { + dwType: DWORD, + dwSize: DWORD, + hDevice: HANDLE, + wParam: WPARAM, +}} +pub type PRAWINPUTHEADER = *mut RAWINPUTHEADER; +pub type LPRAWINPUTHEADER = *mut RAWINPUTHEADER; +pub const RIM_TYPEMOUSE: DWORD = 0; +pub const RIM_TYPEKEYBOARD: DWORD = 1; +pub const RIM_TYPEHID: DWORD = 2; +STRUCT!{struct RAWMOUSE { + usFlags: USHORT, + memory_padding: USHORT, // 16bit Padding for 32bit align in following union + usButtonFlags: USHORT, + usButtonData: USHORT, + ulRawButtons: ULONG, + lLastX: LONG, + lLastY: LONG, + ulExtraInformation: ULONG, +}} +pub type PRAWMOUSE = *mut RAWMOUSE; +pub type LPRAWMOUSE = *mut RAWMOUSE; +pub const RI_MOUSE_LEFT_BUTTON_DOWN: USHORT = 0x0001; +pub const RI_MOUSE_LEFT_BUTTON_UP: USHORT = 0x0002; +pub const RI_MOUSE_RIGHT_BUTTON_DOWN: USHORT = 0x0004; +pub const RI_MOUSE_RIGHT_BUTTON_UP: USHORT = 0x0008; +pub const RI_MOUSE_MIDDLE_BUTTON_DOWN: USHORT = 0x0010; +pub const RI_MOUSE_MIDDLE_BUTTON_UP: USHORT = 0x0020; +pub const RI_MOUSE_BUTTON_1_DOWN: USHORT = RI_MOUSE_LEFT_BUTTON_DOWN; +pub const RI_MOUSE_BUTTON_1_UP: USHORT = RI_MOUSE_LEFT_BUTTON_UP; +pub const RI_MOUSE_BUTTON_2_DOWN: USHORT = RI_MOUSE_RIGHT_BUTTON_DOWN; +pub const RI_MOUSE_BUTTON_2_UP: USHORT = RI_MOUSE_RIGHT_BUTTON_UP; +pub const RI_MOUSE_BUTTON_3_DOWN: USHORT = RI_MOUSE_MIDDLE_BUTTON_DOWN; +pub const RI_MOUSE_BUTTON_3_UP: USHORT = RI_MOUSE_MIDDLE_BUTTON_UP; +pub const RI_MOUSE_BUTTON_4_DOWN: USHORT = 0x0040; +pub const RI_MOUSE_BUTTON_4_UP: USHORT = 0x0080; +pub const RI_MOUSE_BUTTON_5_DOWN: USHORT = 0x0100; +pub const RI_MOUSE_BUTTON_5_UP: USHORT = 0x0200; +pub const RI_MOUSE_WHEEL: USHORT = 0x0400; +pub const MOUSE_MOVE_RELATIVE: USHORT = 0; +pub const MOUSE_MOVE_ABSOLUTE: USHORT = 1; +pub const MOUSE_VIRTUAL_DESKTOP: USHORT = 0x02; +pub const MOUSE_ATTRIBUTES_CHANGED: USHORT = 0x04; +pub const MOUSE_MOVE_NOCOALESCE: USHORT = 0x08; +STRUCT!{struct RAWKEYBOARD { + MakeCode: USHORT, + Flags: USHORT, + Reserved: USHORT, + VKey: USHORT, + Message: UINT, + ExtraInformation: ULONG, +}} +pub type PRAWKEYBOARD = *mut RAWKEYBOARD; +pub type LPRAWKEYBOARD = *mut RAWKEYBOARD; +pub const KEYBOARD_OVERRUN_MAKE_CODE: DWORD = 0xFF; +pub const RI_KEY_MAKE: DWORD = 0; +pub const RI_KEY_BREAK: DWORD = 1; +pub const RI_KEY_E0: DWORD = 2; +pub const RI_KEY_E1: DWORD = 4; +pub const RI_KEY_TERMSRV_SET_LED: DWORD = 8; +pub const RI_KEY_TERMSRV_SHADOW: DWORD = 0x10; +STRUCT!{struct RAWHID { + dwSizeHid: DWORD, + dwCount: DWORD, + bRawData: [BYTE; 1], +}} +pub type PRAWHID = *mut RAWHID; +pub type LPRAWHID = *mut RAWHID; +UNION!{union RAWINPUT_data { + [u32; 6], + mouse mouse_mut: RAWMOUSE, + keyboard keyboard_mut: RAWKEYBOARD, + hid hid_mut: RAWHID, +}} +STRUCT!{struct RAWINPUT { + header: RAWINPUTHEADER, + data: RAWINPUT_data, +}} +pub type PRAWINPUT = *mut RAWINPUT; +pub type LPRAWINPUT = *mut RAWINPUT; +pub const RID_INPUT: DWORD = 0x10000003; +pub const RID_HEADER: DWORD = 0x10000005; +extern "system" { + pub fn GetRawInputData( + hRawInput: HRAWINPUT, + uiCommand: UINT, + pData: LPVOID, + pcbSize: PUINT, + cbSizeHeader: UINT, + ) -> UINT; +} +pub const RIDI_PREPARSEDDATA: DWORD = 0x20000005; +pub const RIDI_DEVICENAME: DWORD = 0x20000007; +pub const RIDI_DEVICEINFO: DWORD = 0x2000000b; +STRUCT!{struct RID_DEVICE_INFO_MOUSE { + dwId: DWORD, + dwNumberOfButtons: DWORD, + dwSampleRate: DWORD, + fHasHorizontalWheel: BOOL, +}} +pub type PRID_DEVICE_INFO_MOUSE = *mut RID_DEVICE_INFO_MOUSE; +STRUCT!{struct RID_DEVICE_INFO_KEYBOARD { + dwType: DWORD, + dwSubType: DWORD, + dwKeyboardMode: DWORD, + dwNumberOfFunctionKeys: DWORD, + dwNumberOfIndicators: DWORD, + dwNumberOfKeysTotal: DWORD, +}} +pub type PRID_DEVICE_INFO_KEYBOARD = *mut RID_DEVICE_INFO_KEYBOARD; +STRUCT!{struct RID_DEVICE_INFO_HID { + dwVendorId: DWORD, + dwProductId: DWORD, + dwVersionNumber: DWORD, + usUsagePage: USHORT, + usUsage: USHORT, +}} +pub type PRID_DEVICE_INFO_HID = *mut RID_DEVICE_INFO_HID; +UNION!{union RID_DEVICE_INFO_u { + [u32; 6], + mouse mouse_mut: RID_DEVICE_INFO_MOUSE, + keyboard keyboard_mut: RID_DEVICE_INFO_KEYBOARD, + hid hid_mut: RID_DEVICE_INFO_HID, +}} +STRUCT!{struct RID_DEVICE_INFO { + cbSize: DWORD, + dwType: DWORD, + u: RID_DEVICE_INFO_u, +}} +pub type PRID_DEVICE_INFO = *mut RID_DEVICE_INFO; +pub type LPRID_DEVICE_INFO = *mut RID_DEVICE_INFO; +extern "system" { + pub fn GetRawInputDeviceInfoA( + hDevice: HANDLE, + uiCommand: UINT, + pData: LPVOID, + pcbSize: PUINT, + ) -> UINT; + pub fn GetRawInputDeviceInfoW( + hDevice: HANDLE, + uiCommand: UINT, + pData: LPVOID, + pcbSize: PUINT, + ) -> UINT; + pub fn GetRawInputBuffer( + pData: PRAWINPUT, + pcbSize: PUINT, + cbSizeHeader: UINT, + ) -> UINT; +} +STRUCT!{struct RAWINPUTDEVICE { + usUsagePage: USHORT, + usUsage: USHORT, + dwFlags: DWORD, + hwndTarget: HWND, +}} +pub type PRAWINPUTDEVICE = *mut RAWINPUTDEVICE; +pub type LPRAWINPUTDEVICE = *mut RAWINPUTDEVICE; +pub type PCRAWINPUTDEVICE = *const RAWINPUTDEVICE; +pub const RIDEV_REMOVE: DWORD = 0x00000001; +pub const RIDEV_EXCLUDE: DWORD = 0x00000010; +pub const RIDEV_PAGEONLY: DWORD = 0x00000020; +pub const RIDEV_NOLEGACY: DWORD = 0x00000030; +pub const RIDEV_INPUTSINK: DWORD = 0x00000100; +pub const RIDEV_CAPTUREMOUSE: DWORD = 0x00000200; +pub const RIDEV_NOHOTKEYS: DWORD = 0x00000200; +pub const RIDEV_APPKEYS: DWORD = 0x00000400; +pub const RIDEV_EXINPUTSINK: DWORD = 0x00001000; +pub const RIDEV_DEVNOTIFY: DWORD = 0x00002000; +pub const RIDEV_EXMODEMASK: DWORD = 0x000000F0; +pub const GIDC_ARRIVAL: DWORD = 1; +pub const GIDC_REMOVAL: DWORD = 2; +extern "system" { + pub fn RegisterRawInputDevices( + pRawInputDevices: PCRAWINPUTDEVICE, + uiNumDevices: UINT, + cbSize: UINT, + ) -> BOOL; + pub fn GetRegisteredRawInputDevices( + pRawInputDevices: PRAWINPUTDEVICE, + puiNumDevices: PUINT, + cbSize: UINT, + ) -> UINT; +} +STRUCT!{struct RAWINPUTDEVICELIST { + hDevice: HANDLE, + dwType: DWORD, +}} +pub type PRAWINPUTDEVICELIST = *mut RAWINPUTDEVICELIST; +extern "system" { + pub fn GetRawInputDeviceList( + pRawInputDeviceList: PRAWINPUTDEVICELIST, + puiNumDevices: PUINT, + cbSize: UINT, + ) -> UINT; + pub fn DefRawInputProc( + paRawInput: *mut PRAWINPUT, + nInput: INT, + cbSizeHeader: UINT, + ) -> LRESULT; + pub fn ChangeWindowMessageFilter( + message: UINT, + dwFlag: DWORD, + ) -> BOOL; +} +//15165 +STRUCT!{struct CHANGEFILTERSTRUCT { + cbSize: DWORD, + ExtStatus: DWORD, +}} +extern "system" { + pub fn ChangeWindowMessageFilterEx( + hwnd: HWND, + message: UINT, + action: DWORD, + pChangeFilterStruct: PCHANGEFILTERSTRUCT, + ) -> BOOL; +} +pub type PCHANGEFILTERSTRUCT = *mut CHANGEFILTERSTRUCT; +//15427 +pub const NID_INTEGRATED_TOUCH: UINT = 0x00000001; +pub const NID_EXTERNAL_TOUCH: UINT = 0x00000002; +pub const NID_INTEGRATED_PEN: UINT = 0x00000004; +pub const NID_EXTERNAL_PEN: UINT = 0x00000008; +pub const NID_MULTI_INPUT: UINT = 0x00000040; +pub const NID_READY: UINT = 0x00000080; +pub const MAX_STR_BLOCKREASON: usize = 256; +extern "system" { + pub fn ShutdownBlockReasonCreate( + hWnd: HWND, + pwszReason: LPCWSTR, + ) -> BOOL; + pub fn ShutdownBlockReasonQuery( + hWnd: HWND, + pwszBuff: LPWSTR, + pcchBuff: *mut DWORD, + ) -> BOOL; + pub fn ShutdownBlockReasonDestroy( + hWnd: HWND, + ) -> BOOL; +} +//15615 +extern "system" { + pub fn IsImmersiveProcess( + hProcess: HANDLE, + ) -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/winver.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/winver.rs new file mode 100644 index 0000000..5d25c67 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/winver.rs @@ -0,0 +1,53 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! Version management functions, types, and definitions +use ctypes::c_void; +use shared::minwindef::{BOOL, DWORD, LPCVOID, LPVOID, PUINT}; +use um::winnt::{LPCSTR, LPCWSTR, LPSTR, LPWSTR}; +extern "system" { + pub fn GetFileVersionInfoSizeA( + lptstrFilename: LPCSTR, + lpdwHandle: *mut DWORD, + ) -> DWORD; + pub fn GetFileVersionInfoSizeW( + lptstrFilename: LPCWSTR, + lpdwHandle: *mut DWORD, + ) -> DWORD; + pub fn GetFileVersionInfoA( + lptstrFilename: LPCSTR, + dwHandle: DWORD, + dwLen: DWORD, + lpData: *mut c_void, + ) -> BOOL; + pub fn GetFileVersionInfoW( + lptstrFilename: LPCWSTR, + dwHandle: DWORD, + dwLen: DWORD, + lpData: *mut c_void, + ) -> BOOL; + pub fn VerQueryValueA( + pBlock: LPCVOID, + lpSubBlock: LPCSTR, + lplpBuffer: &mut LPVOID, + puLen: PUINT, + ) -> BOOL; + pub fn VerQueryValueW( + pBlock: LPCVOID, + lpSubBlock: LPCWSTR, + lplpBuffer: &mut LPVOID, + puLen: PUINT, + ) -> BOOL; + pub fn VerLanguageNameA( + wLang: DWORD, + szLang: LPSTR, + cchLang: DWORD, + ) -> DWORD; + pub fn VerLanguageNameW( + wLang: DWORD, + szLang: LPWSTR, + cchLang: DWORD, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wow64apiset.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wow64apiset.rs new file mode 100644 index 0000000..b8ce4aa --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wow64apiset.rs @@ -0,0 +1,27 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{BOOL, PBOOL, UINT}; +use um::winnt::{HANDLE, LPSTR, LPWSTR, PVOID}; +extern "system" { + pub fn Wow64DisableWow64FsRedirection( + OldValue: *mut PVOID, + ) -> BOOL; + pub fn Wow64RevertWow64FsRedirection( + OlValue: PVOID, + ) -> BOOL; + pub fn IsWow64Process( + hProcess: HANDLE, + Wow64Process: PBOOL, + ) -> BOOL; + pub fn GetSystemWow64DirectoryA( + lpBuffer: LPSTR, + uSize: UINT, + ) -> UINT; + pub fn GetSystemWow64DirectoryW( + lpBuffer: LPWSTR, + uSize: UINT, + ) -> UINT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/wpdmtpextensions.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/wpdmtpextensions.rs new file mode 100644 index 0000000..7ff0b6d --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/wpdmtpextensions.rs @@ -0,0 +1,60 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::wtypes::PROPERTYKEY; +DEFINE_GUID!{WPD_CATEGORY_MTP_EXT_VENDOR_OPERATIONS, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56} +DEFINE_PROPERTYKEY!{WPD_COMMAND_MTP_EXT_GET_SUPPORTED_VENDOR_OPCODES, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 11} +DEFINE_PROPERTYKEY!{WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITHOUT_DATA_PHASE, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 12} +DEFINE_PROPERTYKEY!{WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_READ, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 13} +DEFINE_PROPERTYKEY!{WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_WRITE, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 14} +DEFINE_PROPERTYKEY!{WPD_COMMAND_MTP_EXT_READ_DATA, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 15} +DEFINE_PROPERTYKEY!{WPD_COMMAND_MTP_EXT_WRITE_DATA, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 16} +DEFINE_PROPERTYKEY!{WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 17} +DEFINE_PROPERTYKEY!{WPD_COMMAND_MTP_EXT_GET_VENDOR_EXTENSION_DESCRIPTION, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 18} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_OPERATION_CODE, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1001} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_OPERATION_PARAMS, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1002} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_RESPONSE_CODE, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1003} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_RESPONSE_PARAMS, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1004} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_VENDOR_OPERATION_CODES, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1005} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1006} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_TRANSFER_TOTAL_DATA_SIZE, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1007} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_TO_READ, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1008} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_READ, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1009} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_TO_WRITE, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1010} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_WRITTEN, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1011} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1012} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_OPTIMAL_TRANSFER_BUFFER_SIZE, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1013} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_VENDOR_EXTENSION_DESCRIPTION, + 0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x08, 0x19, 0xfc, 0x56, 1014} +DEFINE_GUID!{WPD_PROPERTIES_MTP_VENDOR_EXTENDED_OBJECT_PROPS, + 0x4d545058, 0x4fce, 0x4578, 0x95, 0xc8, 0x86, 0x98, 0xa9, 0xbc, 0x0f, 0x49} +DEFINE_GUID!{WPD_PROPERTIES_MTP_VENDOR_EXTENDED_DEVICE_PROPS, + 0x4d545058, 0x8900, 0x40b3, 0x8f, 0x1d, 0xdc, 0x24, 0x6e, 0x1e, 0x83, 0x70} +DEFINE_GUID!{WPD_EVENT_MTP_VENDOR_EXTENDED_EVENTS, + 0x00000000, 0x5738, 0x4ff2, 0x84, 0x45, 0xbe, 0x31, 0x26, 0x69, 0x10, 0x59} +DEFINE_PROPERTYKEY!{WPD_PROPERTY_MTP_EXT_EVENT_PARAMS, + 0x4d545058, 0xef88, 0x4e4d, 0x95, 0xc3, 0x4f, 0x32, 0x7f, 0x72, 0x8a, 0x96, 1011} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ws2bth.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ws2bth.rs new file mode 100644 index 0000000..d3f9a9c --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ws2bth.rs @@ -0,0 +1,211 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::bthdef::{ + BTH_ADDR, MAX_L2CAP_INFO_DATA_LENGTH, MAX_L2CAP_PING_DATA_LENGTH, MAX_UUIDS_IN_QUERY, +}; +use shared::bthsdpdef::{SdpAttributeRange, SdpQueryUuid}; +use shared::guiddef::GUID; +use shared::minwindef::{DWORD, PULONG, UCHAR, ULONG, USHORT}; +use shared::ws2def::IOC_VENDOR; +use um::winnt::HANDLE; +pub const BT_PORT_ANY: ULONG = -1i32 as ULONG; +pub const BT_PORT_MIN: ULONG = 0x1; +pub const BT_PORT_MAX: ULONG = 0xffff; +pub const BT_PORT_DYN_FIRST: ULONG = 0x1001; +pub const AF_BTH: USHORT = 32; +pub const PH_BTH: USHORT = AF_BTH; +pub const NS_BTH: USHORT = 16; +STRUCT!{#[repr(packed)] struct SOCKADDR_BTH { + addressFamily: USHORT, + btAddr: BTH_ADDR, + serviceClassId: GUID, + port: ULONG, +}} +pub type PSOCKADDR_BTH = *mut SOCKADDR_BTH; +DEFINE_GUID!{SVCID_BTH_PROVIDER, + 0x6aa63e0, 0x7d60, 0x41ff, 0xaf, 0xb2, 0x3e, 0xe6, 0xd2, 0xd9, 0x39, 0x2d} +pub const BTH_ADDR_STRING_SIZE: DWORD = 12; +pub const BTHPROTO_RFCOMM: USHORT = 0x0003; +pub const BTHPROTO_L2CAP: USHORT = 0x0100; +pub const SOL_RFCOMM: USHORT = BTHPROTO_RFCOMM; +pub const SOL_L2CAP: USHORT = BTHPROTO_L2CAP; +pub const SOL_SDP: USHORT = 0x0101; +pub const SO_BTH_AUTHENTICATE: ULONG = 0x80000001; +pub const SO_BTH_ENCRYPT: ULONG = 0x00000002; +pub const SO_BTH_MTU: ULONG = 0x80000007; +pub const SO_BTH_MTU_MAX: ULONG = 0x80000008; +pub const SO_BTH_MTU_MIN: ULONG = 0x8000000a; +pub const RFCOMM_MAX_MTU: ULONG = 0x000003F3; +pub const RFCOMM_MIN_MTU: ULONG = 0x00000017; +pub const BTH_SDP_VERSION: ULONG = 1; +STRUCT!{#[repr(packed)] struct BTH_SET_SERVICE { + pSdpVersion: PULONG, + pRecordHandle: HANDLE, + fCodService: ULONG, + Reserved: [ULONG; 5], + ulRecordLength: ULONG, + pRecord: [UCHAR; 1], +}} +pub type PBTH_SET_SERVICE = *mut BTH_SET_SERVICE; +pub const SDP_DEFAULT_INQUIRY_SECONDS: UCHAR = 6; +pub const SDP_MAX_INQUIRY_SECONDS: UCHAR = 60; +pub const SDP_DEFAULT_INQUIRY_MAX_RESPONSES: UCHAR = 255; +pub const SDP_SERVICE_SEARCH_REQUEST: ULONG = 1; +pub const SDP_SERVICE_ATTRIBUTE_REQUEST: ULONG = 2; +pub const SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST: ULONG = 3; +STRUCT!{#[repr(packed)] struct BTH_QUERY_DEVICE { + LAP: ULONG, + length: UCHAR, +}} +pub type PBTH_QUERY_DEVICE = *mut BTH_QUERY_DEVICE; +STRUCT!{#[repr(packed)] struct BTH_QUERY_SERVICE { + type_: ULONG, + serviceHandle: ULONG, + uuids: [SdpQueryUuid; MAX_UUIDS_IN_QUERY], + numRange: ULONG, + pRange: [SdpAttributeRange; 1], +}} +pub type PBTH_QUERY_SERVICE = *mut BTH_QUERY_SERVICE; +pub const BTHNS_RESULT_DEVICE_CONNECTED: DWORD = 0x00010000; +pub const BTHNS_RESULT_DEVICE_REMEMBERED: DWORD = 0x00020000; +pub const BTHNS_RESULT_DEVICE_AUTHENTICATED: DWORD = 0x00040000; +pub const SIO_RFCOMM_SEND_COMMAND: DWORD = _WSAIORW!(IOC_VENDOR, 101); +pub const SIO_RFCOMM_WAIT_COMMAND: DWORD = _WSAIORW!(IOC_VENDOR, 102); +pub const SIO_BTH_PING: DWORD = _WSAIORW!(IOC_VENDOR, 8); +pub const SIO_BTH_INFO: DWORD = _WSAIORW!(IOC_VENDOR, 9); +pub const SIO_RFCOMM_SESSION_FLOW_OFF: DWORD = _WSAIORW!(IOC_VENDOR, 103); +pub const SIO_RFCOMM_TEST: DWORD = _WSAIORW!(IOC_VENDOR, 104); +pub const SIO_RFCOMM_USECFC: DWORD = _WSAIORW!(IOC_VENDOR, 105); +macro_rules! BIT { + ($b:expr) => { + 1 << $b + }; +} +STRUCT!{#[repr(packed)] struct RFCOMM_MSC_DATA { + Signals: UCHAR, + Break: UCHAR, +}} +pub type PRFCOMM_MSC_DATA = *mut RFCOMM_MSC_DATA; +pub const MSC_EA_BIT: UCHAR = BIT!(0); +pub const MSC_FC_BIT: UCHAR = BIT!(1); +pub const MSC_RTC_BIT: UCHAR = BIT!(2); +pub const MSC_RTR_BIT: UCHAR = BIT!(3); +pub const MSC_RESERVED: UCHAR = (BIT!(4) | BIT!(5)); +pub const MSC_IC_BIT: UCHAR = BIT!(6); +pub const MSC_DV_BIT: UCHAR = BIT!(7); +pub const MSC_BREAK_BIT: UCHAR = BIT!(1); +macro_rules! MSC_SET_BREAK_LENGTH { + ($b: expr, $l: expr) => { + ($b & 0x3) | (($l & 0xf) << 4) + }; +} +STRUCT!{#[repr(packed)] struct RFCOMM_RLS_DATA { + LineStatus: UCHAR, +}} +pub type PRFCOMM_RLS_DATA = *mut RFCOMM_RLS_DATA; +pub const RLS_ERROR: UCHAR = 0x01; +pub const RLS_OVERRUN: UCHAR = 0x02; +pub const RLS_PARITY: UCHAR = 0x04; +pub const RLS_FRAMING: UCHAR = 0x08; +STRUCT!{#[repr(packed)] struct RFCOMM_RPN_DATA { + Baud: UCHAR, + Data: UCHAR, + FlowControl: UCHAR, + XonChar: UCHAR, + XoffChar: UCHAR, + ParameterMask1: UCHAR, + ParameterMask2: UCHAR, +}} +pub type PRFCOMM_RPN_DATA = *mut RFCOMM_RPN_DATA; +pub const RPN_BAUD_2400: UCHAR = 0; +pub const RPN_BAUD_4800: UCHAR = 1; +pub const RPN_BAUD_7200: UCHAR = 2; +pub const RPN_BAUD_9600: UCHAR = 3; +pub const RPN_BAUD_19200: UCHAR = 4; +pub const RPN_BAUD_38400: UCHAR = 5; +pub const RPN_BAUD_57600: UCHAR = 6; +pub const RPN_BAUD_115200: UCHAR = 7; +pub const RPN_BAUD_230400: UCHAR = 8; +pub const RPN_DATA_5: UCHAR = 0x0; +pub const RPN_DATA_6: UCHAR = 0x1; +pub const RPN_DATA_7: UCHAR = 0x2; +pub const RPN_DATA_8: UCHAR = 0x3; +pub const RPN_STOP_1: UCHAR = 0x0; +pub const RPN_STOP_1_5: UCHAR = 0x4; +pub const RPN_PARITY_NONE: UCHAR = 0x00; +pub const RPN_PARITY_ODD: UCHAR = 0x08; +pub const RPN_PARITY_EVEN: UCHAR = 0x18; +pub const RPN_PARITY_MARK: UCHAR = 0x28; +pub const RPN_PARITY_SPACE: UCHAR = 0x38; +pub const RPN_FLOW_X_IN: UCHAR = 0x01; +pub const RPN_FLOW_X_OUT: UCHAR = 0x02; +pub const RPN_FLOW_RTR_IN: UCHAR = 0x04; +pub const RPN_FLOW_RTR_OUT: UCHAR = 0x08; +pub const RPN_FLOW_RTC_IN: UCHAR = 0x10; +pub const RPN_FLOW_RTC_OUT: UCHAR = 0x20; +pub const RPN_PARAM_BAUD: UCHAR = 0x01; +pub const RPN_PARAM_DATA: UCHAR = 0x02; +pub const RPN_PARAM_STOP: UCHAR = 0x04; +pub const RPN_PARAM_PARITY: UCHAR = 0x08; +pub const RPN_PARAM_P_TYPE: UCHAR = 0x10; +pub const RPN_PARAM_XON: UCHAR = 0x20; +pub const RPN_PARAM_XOFF: UCHAR = 0x40; +pub const RPN_PARAM_X_IN: UCHAR = 0x01; +pub const RPN_PARAM_X_OUT: UCHAR = 0x02; +pub const RPN_PARAM_RTR_IN: UCHAR = 0x04; +pub const RPN_PARAM_RTR_OUT: UCHAR = 0x08; +pub const RPN_PARAM_RTC_IN: UCHAR = 0x10; +pub const RPN_PARAM_RTC_OUT: UCHAR = 0x20; +pub const RFCOMM_CMD_NONE: UCHAR = 0; +pub const RFCOMM_CMD_MSC: UCHAR = 1; +pub const RFCOMM_CMD_RLS: UCHAR = 2; +pub const RFCOMM_CMD_RPN: UCHAR = 3; +pub const RFCOMM_CMD_RPN_REQUEST: UCHAR = 4; +pub const RFCOMM_CMD_RPN_RESPONSE: UCHAR = 5; +UNION!{#[repr(packed)] union RFCOMM_COMMAND_Data { + [u8; 7], + MSC MSC_mut: RFCOMM_MSC_DATA, + RLS RLS_mut: RFCOMM_RLS_DATA, + RPN RPN_mut: RFCOMM_RPN_DATA, +}} +STRUCT!{#[repr(packed)] struct RFCOMM_COMMAND { + CmdType: ULONG, + Data: RFCOMM_COMMAND_Data, +}} +pub type PRFCOMM_COMMAND = *mut RFCOMM_COMMAND; +STRUCT!{#[repr(packed)] struct BTH_PING_REQ { + btAddr: BTH_ADDR, + dataLen: UCHAR, + data: [UCHAR; MAX_L2CAP_PING_DATA_LENGTH], +}} +pub type PBTH_PING_REQ = *mut BTH_PING_REQ; +STRUCT!{#[repr(packed)] struct BTH_PING_RSP { + dataLen: UCHAR, + data: [UCHAR; MAX_L2CAP_PING_DATA_LENGTH], +}} +pub type PBTH_PING_RSP = *mut BTH_PING_RSP; +STRUCT!{#[repr(packed)] struct BTH_INFO_REQ { + btAddr: BTH_ADDR, + infoType: USHORT, +}} +pub type PBTH_INFO_REQ = *mut BTH_INFO_REQ; +UNION!{#[repr(packed)] union BTH_INFO_RSP_u { + [u8; MAX_L2CAP_INFO_DATA_LENGTH], + connectionlessMTU connectionlessMTU_mut: USHORT, + data data_mut: [UCHAR; MAX_L2CAP_INFO_DATA_LENGTH], +}} +STRUCT!{#[repr(packed)] struct BTH_INFO_RSP { + result: USHORT, + dataLen: UCHAR, + u: BTH_INFO_RSP_u, +}} +pub type PBTH_INFO_RSP = *mut BTH_INFO_RSP; +pub type BTHNS_SETBLOB = BTH_SET_SERVICE; +pub type PBTHNS_SETBLOB = PBTH_SET_SERVICE; +pub type BTHNS_INQUIRYBLOB = BTH_QUERY_DEVICE; +pub type PBTHNS_INQUIRYBLOB = PBTH_QUERY_DEVICE; +pub type BTHNS_RESTRICTIONBLOB = BTH_QUERY_SERVICE; +pub type PBTHNS_RESTRICTIONBLOB = PBTH_QUERY_SERVICE; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ws2spi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ws2spi.rs new file mode 100644 index 0000000..d261289 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ws2spi.rs @@ -0,0 +1,909 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Definitions to be used with the WinSock service provider. +use ctypes::{c_char, c_int, c_long, c_uint}; +use shared::basetsd::{DWORD_PTR, PDWORD_PTR, ULONG_PTR}; +use shared::guiddef::{GUID, LPGUID}; +use shared::minwindef::{ + BOOL, DWORD, INT, LPARAM, LPDWORD, LPHANDLE, LPINT, LPVOID, PBYTE, UINT, WORD, WPARAM, +}; +use shared::windef::HWND; +use shared::ws2def::{LPSOCKADDR, LPWSABUF, SOCKADDR}; +use shared::wtypesbase::LPBLOB; +use um::winnt::{HANDLE, LPCWSTR, LPWSTR, PVOID, WCHAR}; +use um::winsock2::{ + GROUP, LPCONDITIONPROC, LPQOS, LPWSACOMPLETION, LPWSANETWORKEVENTS, LPWSAOVERLAPPED, + LPWSAOVERLAPPED_COMPLETION_ROUTINE, LPWSAPROTOCOL_INFOW, LPWSAQUERYSET2W, LPWSAQUERYSETW, + LPWSASERVICECLASSINFOW, SOCKET, WSAESETSERVICEOP, WSAEVENT, fd_set, timeval, +}; +#[cfg(target_pointer_width = "64")] +use um::winsock2::{LPWSANAMESPACE_INFOEXW, LPWSANAMESPACE_INFOW}; +use vc::vcruntime::size_t; +pub const WSPDESCRIPTION_LEN: usize = 255; +pub const WSS_OPERATION_IN_PROGRESS: ULONG_PTR = 0x00000103; +STRUCT!{struct WSPDATA { + wVersion: WORD, + wHighVersion: WORD, + szDescription: [WCHAR; WSPDESCRIPTION_LEN + 1], +}} +pub type LPWSPDATA = *mut WSPDATA; +STRUCT!{struct WSATHREADID { + ThreadHandle: HANDLE, + Reserved: DWORD_PTR, +}} +pub type LPWSATHREADID = *mut WSATHREADID; +FN!{stdcall LPBLOCKINGCALLBACK( + dwContext: DWORD_PTR, +) -> BOOL} +FN!{stdcall LPWSAUSERAPC( + dwContext: DWORD_PTR, +) -> ()} +FN!{stdcall LPWSPACCEPT( + s: SOCKET, + addr: *mut SOCKADDR, + addrlen: LPINT, + lpfnCondition: LPCONDITIONPROC, + dwCallbackData: DWORD_PTR, + lpErrno: LPINT, +) -> SOCKET} +FN!{stdcall LPWSPADDRESSTOSTRING( + lpsaAddress: LPSOCKADDR, + dwAddressLength: DWORD, + lpProtocolInfo: LPWSAPROTOCOL_INFOW, + lpszAddressString: LPWSTR, + lpdwAddressStringLength: LPDWORD, + lpErrno: LPINT, +) -> INT} +FN!{stdcall LPWSPASYNCSELECT( + s: SOCKET, + hWnd: HWND, + wMsg: c_uint, + lEvent: c_long, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPBIND( + s: SOCKET, + name: *mut SOCKADDR, + namelen: c_int, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPCANCELBLOCKINGCALL( + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPCLEANUP( + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPCLOSESOCKET( + s: SOCKET, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPCONNECT( + s: SOCKET, + name: *mut SOCKADDR, + namelen: c_int, + lpCallerData: LPWSABUF, + lpCalleeData: LPWSABUF, + lpSQOS: LPQOS, + lpGQOS: LPQOS, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPDUPLICATESOCKET( + s: SOCKET, + dwProcessId: DWORD, + lpProtocolInfo: LPWSAPROTOCOL_INFOW, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPENUMNETWORKEVENTS( + s: SOCKET, + hEventObject: WSAEVENT, + lpNetworkEvents: LPWSANETWORKEVENTS, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPEVENTSELECT( + s: SOCKET, + hEventObject: WSAEVENT, + lNetworkEvents: c_long, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPGETOVERLAPPEDRESULT( + s: SOCKET, + lpOverlapped: LPWSAOVERLAPPED, + lpcbTransfer: LPDWORD, + fWait: BOOL, + lpdwFlags: LPDWORD, + lpErrno: LPINT, +) -> BOOL} +FN!{stdcall LPWSPGETPEERNAME( + s: SOCKET, + name: *mut SOCKADDR, + namelen: LPINT, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPGETSOCKNAME( + s: SOCKET, + name: *mut SOCKADDR, + namelen: LPINT, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPGETSOCKOPT( + s: SOCKET, + level: c_int, + optname: c_int, + optval: *mut c_char, + optlen: LPINT, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPGETQOSBYNAME( + s: SOCKET, + lpQOSName: LPWSABUF, + lpQOS: LPQOS, + lpErrno: LPINT, +) -> BOOL} +FN!{stdcall LPWSPIOCTL( + s: SOCKET, + dwIoControlCode: DWORD, + lpvInBuffer: LPVOID, + cbInBuffer: DWORD, + lpvOutBuffer: LPVOID, + cbOutBuffer: DWORD, + lpcbBytesReturned: LPDWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + lpThreadId: LPWSATHREADID, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPJOINLEAF( + s: SOCKET, + name: *mut SOCKADDR, + namelen: c_int, + lpCallerData: LPWSABUF, + lpCalleeData: LPWSABUF, + lpSQOS: LPQOS, + lpGQOS: LPQOS, + dwFlags: DWORD, + lpErrno: LPINT, +) -> SOCKET} +FN!{stdcall LPWSPLISTEN( + s: SOCKET, + backlog: c_int, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPRECV( + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, + lpNumberOfBytesRecvd: LPDWORD, + lpFlags: LPDWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + lpThreadId: LPWSATHREADID, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPRECVDISCONNECT( + s: SOCKET, + lpInboundDisconnectData: LPWSABUF, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPRECVFROM( + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, + lpNumberOfBytesRecvd: LPDWORD, + lpFlags: LPDWORD, + lpFrom: *mut SOCKADDR, + lpFromlen: LPINT, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + lpThreadId: LPWSATHREADID, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPSELECT( + nfds: c_int, + readfds: *mut fd_set, + writefds: *mut fd_set, + exceptfds: *mut fd_set, + timeout: *const timeval, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPSEND( + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, + lpNumberOfBytesSent: LPDWORD, + dwFlags: DWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + lpThreadId: LPWSATHREADID, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPSENDDISCONNECT( + s: SOCKET, + lpOutboundDisconnectData: LPWSABUF, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPSENDTO( + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, + lpNumberOfBytesSent: LPDWORD, + dwFlags: DWORD, + lpTo: *const SOCKADDR, + iTolen: c_int, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + lpThreadId: LPWSATHREADID, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPSETSOCKOPT( + s: SOCKET, + level: c_int, + optname: c_int, + optval: *const c_char, + optlen: c_int, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPSHUTDOWN( + s: SOCKET, + how: c_int, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWSPSOCKET( + af: c_int, + _type: c_int, + protocol: c_int, + lpProtocolInfo: LPWSAPROTOCOL_INFOW, + g: GROUP, + dwFlags: DWORD, + lpErrno: LPINT, +) -> SOCKET} +FN!{stdcall LPWSPSTRINGTOADDRESS( + AddressString: LPWSTR, + AddressFamily: INT, + lpProtocolInfo: LPWSAPROTOCOL_INFOW, + lpAddress: LPSOCKADDR, + lpAddressLength: LPINT, + lpErrno: LPINT, +) -> c_int} +STRUCT!{struct WSPPROC_TABLE { + lpWSPAccept: LPWSPACCEPT, + lpWSPAddressToString: LPWSPADDRESSTOSTRING, + lpWSPAsyncSelect: LPWSPASYNCSELECT, + lpWSPBind: LPWSPBIND, + lpWSPCancelBlockingCall: LPWSPCANCELBLOCKINGCALL, + lpWSPCleanup: LPWSPCLEANUP, + lpWSPCloseSocket: LPWSPCLOSESOCKET, + lpWSPConnect: LPWSPCONNECT, + lpWSPDuplicateSocket: LPWSPDUPLICATESOCKET, + lpWSPEnumNetworkEvents: LPWSPENUMNETWORKEVENTS, + lpWSPEventSelect: LPWSPEVENTSELECT, + lpWSPGetOverlappedResult: LPWSPGETOVERLAPPEDRESULT, + lpWSPGetPeerName: LPWSPGETPEERNAME, + lpWSPGetSockName: LPWSPGETSOCKNAME, + lpWSPGetSockOpt: LPWSPGETSOCKOPT, + lpWSPGetQOSByName: LPWSPGETQOSBYNAME, + lpWSPIoctl: LPWSPIOCTL, + lpWSPJoinLeaf: LPWSPJOINLEAF, + lpWSPListen: LPWSPLISTEN, + lpWSPRecv: LPWSPRECV, + lpWSPRecvDisconnect: LPWSPRECVDISCONNECT, + lpWSPRecvFrom: LPWSPRECVFROM, + lpWSPSelect: LPWSPSELECT, + lpWSPSend: LPWSPSEND, + lpWSPSendDisconnect: LPWSPSENDDISCONNECT, + lpWSPSendTo: LPWSPSENDTO, + lpWSPSetSockOpt: LPWSPSETSOCKOPT, + lpWSPShutdown: LPWSPSHUTDOWN, + lpWSPSocket: LPWSPSOCKET, + lpWSPStringToAddress: LPWSPSTRINGTOADDRESS, +}} +pub type LPWSPPROC_TABLE = *mut WSPPROC_TABLE; +FN!{stdcall LPWPUCLOSEEVENT( + hEvent: WSAEVENT, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWPUCLOSESOCKETHANDLE( + s: SOCKET, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWPUCREATEEVENT( + lpErrno: LPINT, +) -> WSAEVENT} +FN!{stdcall LPWPUCREATESOCKETHANDLE( + dwCatalogEntryId: DWORD, + dwContext: DWORD_PTR, + lpErrno: LPINT, +) -> SOCKET} +FN!{stdcall LPWPUFDISSET( + s: SOCKET, + fdset: *mut fd_set, +) -> c_int} +FN!{stdcall LPWPUGETPROVIDERPATH( + lpProviderId: LPGUID, + lpszProviderDllPath: *mut WCHAR, + lpProviderDllPathLen: LPINT, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWPUMODIFYIFSHANDLE( + dwCatalogEntryId: DWORD, + ProposedHandle: SOCKET, + lpErrno: LPINT, +) -> SOCKET} +FN!{stdcall LPWPUPOSTMESSAGE( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, +) -> BOOL} +FN!{stdcall LPWPUQUERYBLOCKINGCALLBACK( + dwCatalogEntryId: DWORD, + lplpfnCallback: *mut LPBLOCKINGCALLBACK, + lpdwContext: PDWORD_PTR, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWPUQUERYSOCKETHANDLECONTEXT( + s: SOCKET, + lpContext: PDWORD_PTR, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWPUQUEUEAPC( + lpThreadId: LPWSATHREADID, + lpfnUserApc: LPWSAUSERAPC, + dwContext: DWORD_PTR, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWPURESETEVENT( + hEvent: WSAEVENT, + lpErrno: LPINT, +) -> BOOL} +FN!{stdcall LPWPUSETEVENT( + hEvent: WSAEVENT, + lpErrno: LPINT, +) -> BOOL} +FN!{stdcall LPWPUOPENCURRENTTHREAD( + lpThreadId: LPWSATHREADID, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWPUCLOSETHREAD( + lpThreadId: LPWSATHREADID, + lpErrno: LPINT, +) -> c_int} +FN!{stdcall LPWPUCOMPLETEOVERLAPPEDREQUEST( + s: SOCKET, + lpOverlapped: LPWSAOVERLAPPED, + dwError: DWORD, + cbTransferred: DWORD, + lpErrno: LPINT, +) -> c_int} +STRUCT!{struct WSPUPCALLTABLE { + lpWPUCloseEvent: LPWPUCLOSEEVENT, + lpWPUCloseSocketHandle: LPWPUCLOSESOCKETHANDLE, + lpWPUCreateEvent: LPWPUCREATEEVENT, + lpWPUCreateSocketHandle: LPWPUCREATESOCKETHANDLE, + lpWPUFDIsSet: LPWPUFDISSET, + lpWPUGetProviderPath: LPWPUGETPROVIDERPATH, + lpWPUModifyIFSHandle: LPWPUMODIFYIFSHANDLE, + lpWPUPostMessage: LPWPUPOSTMESSAGE, + lpWPUQueryBlockingCallback: LPWPUQUERYBLOCKINGCALLBACK, + lpWPUQuerySocketHandleContext: LPWPUQUERYSOCKETHANDLECONTEXT, + lpWPUQueueApc: LPWPUQUEUEAPC, + lpWPUResetEvent: LPWPURESETEVENT, + lpWPUSetEvent: LPWPUSETEVENT, + lpWPUOpenCurrentThread: LPWPUOPENCURRENTTHREAD, + lpWPUCloseThread: LPWPUCLOSETHREAD, +}} +pub type LPWSPUPCALLTABLE = *mut WSPUPCALLTABLE; +extern "system" { + pub fn WSPStartup( + wVersionRequested: WORD, + lpWSPData: LPWSPDATA, + lpProtocolInfo: LPWSAPROTOCOL_INFOW, + UpcallTable: WSPUPCALLTABLE, + lpProcTable: LPWSPPROC_TABLE, + ) -> c_int; +} +FN!{stdcall LPWSPSTARTUP( + wVersionRequested: WORD, + lpWSPData: LPWSPDATA, + lpProtocolInfo: LPWSAPROTOCOL_INFOW, + UpcallTable: WSPUPCALLTABLE, + lpProcTable: LPWSPPROC_TABLE, +) -> c_int} +extern "system" { + pub fn WSCEnumProtocols( + lpiProtocols: LPINT, + lpProtocolBuffer: LPWSAPROTOCOL_INFOW, + lpdwBufferLength: LPDWORD, + lpErrno: LPINT, + ) -> c_int; +} +FN!{stdcall LPWSCENUMPROTOCOLS( + lpiProtocols: LPINT, + lpProtocolBuffer: LPWSAPROTOCOL_INFOW, + lpdwBufferLength: LPDWORD, + lpErrno: LPINT, +) -> c_int} +extern "system" { + #[cfg(target_pointer_width = "64")] + pub fn WSCEnumProtocols32( + lpiProtocols: LPINT, + lpProtocolBuffer: LPWSAPROTOCOL_INFOW, + lpdwBufferLength: LPDWORD, + lpErrno: LPINT, + ) -> c_int; + pub fn WSCDeinstallProvider( + lpProviderId: LPGUID, + lpErrno: LPINT, + ) -> c_int; +} +FN!{stdcall LPWSCDEINSTALLPROVIDER( + lpProviderId: LPGUID, + lpErrno: LPINT, +) -> c_int} +extern "system" { + #[cfg(target_pointer_width = "64")] + pub fn WSCDeinstallProvider32( + lpProviderId: LPGUID, + lpErrno: LPINT, + ) -> c_int; + pub fn WSCInstallProvider( + lpProviderId: LPGUID, + lpszProviderDllPath: *const WCHAR, + lpProtocolInfoList: LPWSAPROTOCOL_INFOW, + dwNumberOfEntries: DWORD, + lpErrno: LPINT, + ) -> c_int; +} +FN!{stdcall LPWSCINSTALLPROVIDER( + lpProviderId: LPGUID, + lpszProviderDllPath: *const WCHAR, + lpProtocolInfoList: LPWSAPROTOCOL_INFOW, + dwNumberOfEntries: DWORD, + lpErrno: LPINT, +) -> c_int} +extern "system" { + #[cfg(target_pointer_width = "64")] + pub fn WSCInstallProvider64_32( + lpProviderId: LPGUID, + lpszProviderDllPath: *const WCHAR, + lpProtocolInfoList: LPWSAPROTOCOL_INFOW, + dwNumberOfEntries: DWORD, + lpErrno: LPINT, + ) -> c_int; + pub fn WSCGetProviderPath( + lpProviderId: LPGUID, + lpszProviderDllPath: *mut WCHAR, + lpProviderDllPathLen: LPINT, + lpErrno: LPINT, + ) -> c_int; +} +FN!{stdcall LPWSCGETPROVIDERPATH( + lpProviderId: LPGUID, + lpszProviderDllPath: *mut WCHAR, + lpProviderDllPathLen: LPINT, + lpErrno: LPINT, +) -> c_int} +extern "system" { + #[cfg(target_pointer_width = "64")] + pub fn WSCGetProviderPath32( + lpProviderId: LPGUID, + lpszProviderDllPath: *mut WCHAR, + lpProviderDllPathLen: LPINT, + lpErrno: LPINT, + ) -> c_int; + pub fn WSCUpdateProvider( + lpProviderId: LPGUID, + lpszProviderDllPath: *const WCHAR, + lpProtocolInfoList: LPWSAPROTOCOL_INFOW, + dwNumberOfEntries: DWORD, + lpErrno: LPINT, + ) -> c_int; +} +FN!{stdcall LPWSCUPDATEPROVIDER( + lpProviderId: LPGUID, + lpszProviderDllPath: *const WCHAR, + lpProtocolInfoList: LPWSAPROTOCOL_INFOW, + dwNumberOfEntries: DWORD, + lpErrno: LPINT, +) -> c_int} +#[cfg(target_pointer_width = "64")] +extern "system" { + pub fn WSCUpdateProvider32( + lpProviderId: LPGUID, + lpszProviderDllPath: *const WCHAR, + lpProtocolInfoList: LPWSAPROTOCOL_INFOW, + dwNumberOfEntries: DWORD, + lpErrno: LPINT, + ) -> c_int; +} +pub const LSP_SYSTEM: DWORD = 0x80000000; +pub const LSP_INSPECTOR: DWORD = 0x00000001; +pub const LSP_REDIRECTOR: DWORD = 0x00000002; +pub const LSP_PROXY: DWORD = 0x00000004; +pub const LSP_FIREWALL: DWORD = 0x00000008; +pub const LSP_INBOUND_MODIFY: DWORD = 0x00000010; +pub const LSP_OUTBOUND_MODIFY: DWORD = 0x00000020; +pub const LSP_CRYPTO_COMPRESS: DWORD = 0x00000040; +pub const LSP_LOCAL_CACHE: DWORD = 0x00000080; +ENUM!{enum WSC_PROVIDER_INFO_TYPE { + ProviderInfoLspCategories, + ProviderInfoAudit, +}} +STRUCT!{struct WSC_PROVIDER_AUDIT_INFO { + RecordSize: DWORD, + Reserved: PVOID, +}} +extern "system" { + pub fn WSCSetProviderInfo( + lpProviderId: LPGUID, + InfoType: WSC_PROVIDER_INFO_TYPE, + Info: PBYTE, + InfoSize: size_t, + Flags: DWORD, + lpErrno: LPINT, + ) -> c_int; + pub fn WSCGetProviderInfo( + lpProviderId: LPGUID, + InfoType: WSC_PROVIDER_INFO_TYPE, + Info: PBYTE, + InfoSize: *mut size_t, + Flags: DWORD, + lpErrno: LPINT, + ) -> c_int; + #[cfg(target_pointer_width = "64")] + pub fn WSCSetProviderInfo32( + lpProviderId: LPGUID, + InfoType: WSC_PROVIDER_INFO_TYPE, + Info: PBYTE, + InfoSize: size_t, + Flags: DWORD, + lpErrno: LPINT, + ) -> c_int; + #[cfg(target_pointer_width = "64")] + pub fn WSCGetProviderInfo32( + lpProviderId: LPGUID, + InfoType: WSC_PROVIDER_INFO_TYPE, + Info: PBYTE, + InfoSize: *mut size_t, + Flags: DWORD, + lpErrno: LPINT, + ) -> c_int; + pub fn WSCSetApplicationCategory( + Path: LPCWSTR, + PathLength: DWORD, + Extra: LPCWSTR, + ExtraLength: DWORD, + PermittedLspCategories: DWORD, + pPrevPermLspCat: *mut DWORD, + lpErrno: LPINT, + ) -> c_int; + pub fn WSCGetApplicationCategory( + Path: LPCWSTR, + PathLength: DWORD, + Extra: LPCWSTR, + ExtraLength: DWORD, + pPermittedLspCategories: *mut DWORD, + lpErrno: LPINT, + ) -> c_int; + pub fn WPUCloseEvent( + hEvent: WSAEVENT, + lpErrno: LPINT, + ) -> BOOL; + pub fn WPUCloseSocketHandle( + s: SOCKET, + lpErrno: LPINT, + ) -> c_int; + pub fn WPUCreateEvent( + lpErrno: LPINT, + ) -> WSAEVENT; + pub fn WPUCreateSocketHandle( + dwCatalogEntryId: DWORD, + dwContext: DWORD_PTR, + lpErrno: LPINT, + ) -> SOCKET; + pub fn WPUFDIsSet( + s: SOCKET, + fdset: *mut fd_set, + ) -> c_int; + pub fn WPUGetProviderPath( + lpProviderId: LPGUID, + lpszProviderDllPath: *mut WCHAR, + lpProviderDllPathLen: LPINT, + lpErrno: LPINT, + ) -> c_int; + pub fn WPUModifyIFSHandle( + dwCatalogEntryId: DWORD, + ProposedHandle: SOCKET, + lpErrno: LPINT, + ) -> SOCKET; + pub fn WPUPostMessage( + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + ) -> BOOL; + pub fn WPUQueryBlockingCallback( + dwCatalogEntryId: DWORD, + lplpfnCallback: *mut LPBLOCKINGCALLBACK, + lpdwContext: PDWORD_PTR, + lpErrno: LPINT, + ) -> c_int; + pub fn WPUQuerySocketHandleContext( + s: SOCKET, + lpContext: PDWORD_PTR, + lpErrno: LPINT, + ) -> c_int; + pub fn WPUQueueApc( + lpThreadId: LPWSATHREADID, + lpfnUserApc: LPWSAUSERAPC, + dwContext: DWORD_PTR, + lpErrno: LPINT, + ) -> c_int; + pub fn WPUResetEvent( + hEvent: WSAEVENT, + lpErrno: LPINT, + ) -> BOOL; + pub fn WPUSetEvent( + hEvent: WSAEVENT, + lpErrno: LPINT, + ) -> BOOL; + pub fn WPUCompleteOverlappedRequest( + s: SOCKET, + lpOverlapped: LPWSAOVERLAPPED, + dwError: DWORD, + cbTransferred: DWORD, + lpErrno: LPINT, + ) -> c_int; + pub fn WPUOpenCurrentThread( + lpThreadId: LPWSATHREADID, + lpErrno: LPINT, + ) -> c_int; + pub fn WPUCloseThread( + lpThreadId: LPWSATHREADID, + lpErrno: LPINT, + ) -> c_int; + #[cfg(target_pointer_width = "64")] + pub fn WSCEnumNameSpaceProviders32( + lpdwBufferLength: LPDWORD, + lpnspBuffer: LPWSANAMESPACE_INFOW, + ) -> INT; + #[cfg(target_pointer_width = "64")] + pub fn WSCEnumNameSpaceProvidersEx32( + lpdwBufferLength: LPDWORD, + lpnspBuffer: LPWSANAMESPACE_INFOEXW, + ) -> INT; + pub fn WSCInstallNameSpace( + lpszIdentifier: LPWSTR, + lpszPathName: LPWSTR, + dwNameSpace: DWORD, + dwVersion: DWORD, + lpProviderId: LPGUID, + ) -> INT; +} +FN!{stdcall LPWSCINSTALLNAMESPACE( + lpszIdentifier: LPWSTR, + lpszPathName: LPWSTR, + dwNameSpace: DWORD, + dwVersion: DWORD, + lpProviderId: LPGUID, +) -> INT} +extern "system" { + #[cfg(target_pointer_width = "64")] + pub fn WSCInstallNameSpace32( + lpszIdentifier: LPWSTR, + lpszPathName: LPWSTR, + dwNameSpace: DWORD, + dwVersion: DWORD, + lpProviderId: LPGUID, + ) -> INT; + pub fn WSCUnInstallNameSpace( + lpProviderId: LPGUID, + ) -> INT; +} +FN!{stdcall LPWSCUNINSTALLNAMESPACE( + lpProviderId: LPGUID, +) -> INT} +extern "system" { + pub fn WSCInstallNameSpaceEx( + lpszIdentifier: LPWSTR, + lpszPathName: LPWSTR, + dwNameSpace: DWORD, + dwVersion: DWORD, + lpProviderId: LPGUID, + lpProviderSpecific: LPBLOB, + ) -> INT; + #[cfg(target_pointer_width = "64")] + pub fn WSCInstallNameSpaceEx32( + lpszIdentifier: LPWSTR, + lpszPathName: LPWSTR, + dwNameSpace: DWORD, + dwVersion: DWORD, + lpProviderId: LPGUID, + lpProviderSpecific: LPBLOB, + ) -> INT; + #[cfg(target_pointer_width = "64")] + pub fn WSCUnInstallNameSpace32( + lpProviderId: LPGUID, + ) -> INT; + pub fn WSCEnableNSProvider( + lpProviderId: LPGUID, + fEnable: BOOL, + ) -> INT; +} +FN!{stdcall LPWSCENABLENSPROVIDER( + lpProviderId: LPGUID, + fEnable: BOOL, +) -> INT} +extern "system" { + #[cfg(target_pointer_width = "64")] + pub fn WSCEnableNSProvider32( + lpProviderId: LPGUID, + fEnable: BOOL, + ) -> INT; + #[cfg(target_pointer_width = "64")] + pub fn WSCInstallProviderAndChains64_32( + lpProviderId: LPGUID, + lpszProviderDllPath: LPWSTR, + lpszProviderDllPath32: LPWSTR, + lpszLspName: LPWSTR, + dwServiceFlags: DWORD, + lpProtocolInfoList: LPWSAPROTOCOL_INFOW, + dwNumberOfEntries: DWORD, + lpdwCatalogEntryId: LPDWORD, + lpErrno: LPINT, + ) -> c_int; + #[cfg(target_pointer_width = "32")] + pub fn WSCInstallProviderAndChains( + lpProviderId: LPGUID, + lpszProviderDllPath: LPWSTR, + lpszLspName: LPWSTR, + dwServiceFlags: DWORD, + lpProtocolInfoList: LPWSAPROTOCOL_INFOW, + dwNumberOfEntries: DWORD, + lpdwCatalogEntryId: LPDWORD, + lpErrno: LPINT, + ) -> c_int; +} +FN!{stdcall LPNSPCLEANUP( + lpProviderId: LPGUID, +) -> INT} +FN!{stdcall LPNSPLOOKUPSERVICEBEGIN( + lpProviderId: LPGUID, + lpqsRestrictions: LPWSAQUERYSETW, + lpServiceClassInfo: LPWSASERVICECLASSINFOW, + dwControlFlags: DWORD, + lphLookup: LPHANDLE, +) -> INT} +FN!{stdcall LPNSPLOOKUPSERVICENEXT( + hLookup: HANDLE, + dwControlFlags: DWORD, + lpdwBufferLength: LPDWORD, + lpqsResults: LPWSAQUERYSETW, +) -> INT} +FN!{stdcall LPNSPIOCTL( + hLookup: HANDLE, + dwControlCode: DWORD, + lpvInBuffer: LPVOID, + cbInBuffer: DWORD, + lpvOutBuffer: LPVOID, + cbOutBuffer: DWORD, + lpcbBytesReturned: LPDWORD, + lpCompletion: LPWSACOMPLETION, + lpThreadId: LPWSATHREADID, +) -> INT} +FN!{stdcall LPNSPLOOKUPSERVICEEND( + hLookup: HANDLE, +) -> INT} +FN!{stdcall LPNSPSETSERVICE( + lpProviderId: LPGUID, + lpServiceClassInfo: LPWSASERVICECLASSINFOW, + lpqsRegInfo: LPWSAQUERYSETW, + essOperation: WSAESETSERVICEOP, + dwControlFlags: DWORD, +) -> INT} +FN!{stdcall LPNSPINSTALLSERVICECLASS( + lpProviderId: LPGUID, + lpServiceClassInfo: LPWSASERVICECLASSINFOW, +) -> INT} +FN!{stdcall LPNSPREMOVESERVICECLASS( + lpProviderId: LPGUID, + lpServiceClassId: LPGUID, +) -> INT} +FN!{stdcall LPNSPGETSERVICECLASSINFO( + lpProviderId: LPGUID, + lpdwBufSize: LPDWORD, + lpServiceClassInfo: LPWSASERVICECLASSINFOW, +) -> INT} +STRUCT!{struct NSP_ROUTINE { + cbSize: DWORD, + dwMajorVersion: DWORD, + dwMinorVersion: DWORD, + NSPCleanup: LPNSPCLEANUP, + NSPLookupServiceBegin: LPNSPLOOKUPSERVICEBEGIN, + NSPLookupServiceNext: LPNSPLOOKUPSERVICENEXT, + NSPLookupServiceEnd: LPNSPLOOKUPSERVICEEND, + NSPSetService: LPNSPSETSERVICE, + NSPInstallServiceClass: LPNSPINSTALLSERVICECLASS, + NSPRemoveServiceClass: LPNSPREMOVESERVICECLASS, + NSPGetServiceClassInfo: LPNSPGETSERVICECLASSINFO, + NSPIoctl: LPNSPIOCTL, +}} +pub type LPNSP_ROUTINE = *mut NSP_ROUTINE; +extern "system" { + pub fn NSPStartup( + lpProviderId: LPGUID, + lpnspRoutines: LPNSP_ROUTINE, + ) -> INT; +} +FN!{stdcall LPNSPSTARTUP( + lpProviderId: LPGUID, + lpnspRoutines: LPNSP_ROUTINE, +) -> INT} +FN!{stdcall LPNSPV2STARTUP( + lpProviderId: LPGUID, + ppvClientSessionArg: *mut LPVOID, +) -> INT} +FN!{stdcall LPNSPV2CLEANUP( + lpProviderId: LPGUID, + pvClientSessionArg: LPVOID, +) -> INT} +FN!{stdcall LPNSPV2LOOKUPSERVICEBEGIN( + lpProviderId: LPGUID, + lpqsRestrictions: LPWSAQUERYSET2W, + dwControlFlags: DWORD, + lpvClientSessionArg: LPVOID, + lphLookup: LPHANDLE, +) -> INT} +FN!{stdcall LPNSPV2LOOKUPSERVICENEXTEX( + hAsyncCall: HANDLE, + hLookup: HANDLE, + dwControlFlags: DWORD, + lpdwBufferLength: LPDWORD, + lpqsResults: LPWSAQUERYSET2W, +) -> ()} +FN!{stdcall LPNSPV2LOOKUPSERVICEEND( + hLookup: HANDLE, +) -> INT} +FN!{stdcall LPNSPV2SETSERVICEEX( + hAsyncCall: HANDLE, + lpProviderId: LPGUID, + lpqsRegInfo: LPWSAQUERYSET2W, + essOperation: WSAESETSERVICEOP, + dwControlFlags: DWORD, + lpvClientSessionArg: LPVOID, +) -> ()} +FN!{stdcall LPNSPV2CLIENTSESSIONRUNDOWN( + lpProviderId: LPGUID, + pvClientSessionArg: LPVOID, +) -> ()} +STRUCT!{struct NSPV2_ROUTINE { + cbSize: DWORD, + dwMajorVersion: DWORD, + dwMinorVersion: DWORD, + NSPv2Startup: LPNSPV2STARTUP, + NSPv2Cleanup: LPNSPV2CLEANUP, + NSPv2LookupServiceBegin: LPNSPV2LOOKUPSERVICEBEGIN, + NSPv2LookupServiceNextEx: LPNSPV2LOOKUPSERVICENEXTEX, + NSPv2LookupServiceEnd: LPNSPV2LOOKUPSERVICEEND, + NSPv2SetServiceEx: LPNSPV2SETSERVICEEX, + NSPv2ClientSessionRundown: LPNSPV2CLIENTSESSIONRUNDOWN, +}} +pub type PNSPV2_ROUTINE = *mut NSPV2_ROUTINE; +pub type LPNSPV2_ROUTINE = *mut NSPV2_ROUTINE; +pub type PCNSPV2_ROUTINE = *const NSPV2_ROUTINE; +pub type LPCNSPV2_ROUTINE = *const NSPV2_ROUTINE; +extern "system" { + pub fn WSAAdvertiseProvider( + puuidProviderId: *const GUID, + pNSPv2Routine: *const LPCNSPV2_ROUTINE, + ) -> INT; + pub fn WSAUnadvertiseProvider( + puuidProviderId: *const GUID, + ) -> INT; + pub fn WSAProviderCompleteAsyncCall( + hAsyncCall: HANDLE, + iRetCode: INT, + ) -> INT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/ws2tcpip.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/ws2tcpip.rs new file mode 100644 index 0000000..4867c74 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/ws2tcpip.rs @@ -0,0 +1,346 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! WinSock2 Extension for TCP/IP protocols +use ctypes::c_int; +use shared::guiddef::LPGUID; +use shared::minwindef::{DWORD, INT, LPHANDLE, ULONG}; +use shared::mstcpip::{ + SOCKET_PEER_TARGET_NAME, SOCKET_SECURITY_QUERY_INFO, SOCKET_SECURITY_QUERY_TEMPLATE, + SOCKET_SECURITY_SETTINGS, +}; +use shared::winerror::{ + WSAEAFNOSUPPORT, WSAEINVAL, WSAESOCKTNOSUPPORT, WSAHOST_NOT_FOUND, WSANO_RECOVERY, + WSATRY_AGAIN, WSATYPE_NOT_FOUND, WSA_IPSEC_NAME_POLICY_ERROR, WSA_SECURE_HOST_NOT_FOUND, +}; +use shared::ws2def::{ + ADDRINFOA, ADDRINFOEXA, ADDRINFOEXW, ADDRINFOW, PADDRINFOA, PADDRINFOEXA, PADDRINFOEXW, + PADDRINFOW, SOCKADDR, SOCKET_ADDRESS, +}; +use shared::wtypesbase::LPBLOB; +use um::minwinbase::LPOVERLAPPED; +use um::winnt::{PCHAR, PCSTR, PCWSTR, PSTR, PVOID, PWCHAR, PWSTR, VOID}; +use um::winsock2::{ + LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE, SOCKET, WSA_NOT_ENOUGH_MEMORY, timeval, +}; +use vc::vcruntime::size_t; +pub const UDP_NOCHECKSUM: c_int = 1; +pub const UDP_CHECKSUM_COVERAGE: c_int = 20; +pub const EAI_AGAIN: DWORD = WSATRY_AGAIN; +pub const EAI_BADFLAGS: DWORD = WSAEINVAL; +pub const EAI_FAIL: DWORD = WSANO_RECOVERY; +pub const EAI_FAMILY: DWORD = WSAEAFNOSUPPORT; +pub const EAI_MEMORY: DWORD = WSA_NOT_ENOUGH_MEMORY as u32; +pub const EAI_NOSECURENAME: DWORD = WSA_SECURE_HOST_NOT_FOUND; +pub const EAI_NONAME: DWORD = WSAHOST_NOT_FOUND; +pub const EAI_SERVICE: DWORD = WSATYPE_NOT_FOUND; +pub const EAI_SOCKTYPE: DWORD = WSAESOCKTNOSUPPORT; +pub const EAI_IPSECPOLICY: DWORD = WSA_IPSEC_NAME_POLICY_ERROR; +pub const EAI_NODATA: DWORD = EAI_NONAME; +pub type ADDRINFO = ADDRINFOA; +pub type LPADDRINFO = *mut ADDRINFOA; +extern "system" { + pub fn getaddrinfo( + pNodeName: PCSTR, + pServiceName: PCSTR, + pHints: *const ADDRINFOA, + ppResult: *mut PADDRINFOA, + ) -> INT; + pub fn GetAddrInfoW( + pNodeName: PCWSTR, + pServiceName: PCWSTR, + pHints: *const ADDRINFOW, + ppResult: *mut PADDRINFOW, + ) -> INT; +} +FN!{stdcall LPFN_GETADDRINFO( + pNodeName: PCSTR, + pServiceName: PCSTR, + pHints: *const ADDRINFOA, + ppResult: *mut PADDRINFOA, +) -> INT} +FN!{stdcall LPFN_GETADDRINFOW( + pNodeName: PCWSTR, + pServiceName: PCWSTR, + pHints: *const ADDRINFOW, + ppResult: *mut PADDRINFOW, +) -> INT} +FN!{stdcall LPLOOKUPSERVICE_COMPLETION_ROUTINE( + dwError: DWORD, + dwBytes: DWORD, + lpOverlapped: LPWSAOVERLAPPED, +) -> ()} +extern "system" { + pub fn GetAddrInfoExA( + pName: PCSTR, + pServiceName: PCSTR, + dwNameSpace: DWORD, + lpNspId: LPGUID, + hints: *const ADDRINFOEXA, + ppResult: *mut PADDRINFOEXA, + timeout: *mut timeval, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, + lpNameHandle: LPHANDLE, + ) -> INT; + pub fn GetAddrInfoExW( + pName: PCWSTR, + pServiceName: PCWSTR, + dwNameSpace: DWORD, + lpNspId: LPGUID, + hints: *const ADDRINFOEXW, + ppResult: *mut PADDRINFOEXW, + timeout: *mut timeval, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, + lpNameHandle: LPHANDLE, + ) -> INT; + pub fn GetAddrInfoExCancel( + lpHandle: LPHANDLE, + ) -> INT; + pub fn GetAddrInfoExOverlappedResult( + lpOverlapped: LPOVERLAPPED, + ) -> INT; +} +FN!{stdcall LPFN_GETADDRINFOEXA( + pName: PCSTR, + pServiceName: PCSTR, + dwNameSpace: DWORD, + lpNspId: LPGUID, + hints: *const ADDRINFOEXA, + ppResult: *mut PADDRINFOEXA, + timeout: *mut timeval, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, + lpNameHandle: LPHANDLE, +) -> INT} +FN!{stdcall LPFN_GETADDRINFOEXW( + pName: PCWSTR, + pServiceName: PCWSTR, + dwNameSpace: DWORD, + lpNspId: LPGUID, + hints: *const ADDRINFOEXW, + ppResult: *mut PADDRINFOEXW, + timeout: *mut timeval, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, + lpNameHandle: LPHANDLE, +) -> INT} +FN!{stdcall LPFN_GETADDRINFOEXCANCEL( + lpHandle: LPHANDLE, +) -> INT} +FN!{stdcall LPFN_GETADDRINFOEXOVERLAPPEDRESULT( + lpOverlapped: LPOVERLAPPED, +) -> INT} +extern "system" { + pub fn SetAddrInfoExA( + pName: PCSTR, + pServiceName: PCSTR, + pAddresses: *mut SOCKET_ADDRESS, + dwAddressCount: DWORD, + lpBlob: LPBLOB, + dwFlags: DWORD, + dwNameSpace: DWORD, + lpNspId: LPGUID, + timeout: *mut timeval, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, + lpNameHandle: LPHANDLE, + ) -> INT; + pub fn SetAddrInfoExW( + pName: PCWSTR, + pServiceName: PCWSTR, + pAddresses: *mut SOCKET_ADDRESS, + dwAddressCount: DWORD, + lpBlob: LPBLOB, + dwFlags: DWORD, + dwNameSpace: DWORD, + lpNspId: LPGUID, + timeout: *mut timeval, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, + lpNameHandle: LPHANDLE, + ) -> INT; +} +FN!{stdcall LPFN_SETADDRINFOEXA( + pName: PCSTR, + pServiceName: PCSTR, + pAddresses: *mut SOCKET_ADDRESS, + dwAddressCount: DWORD, + lpBlob: LPBLOB, + dwFlags: DWORD, + dwNameSpace: DWORD, + lpNspId: LPGUID, + timeout: *mut timeval, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, + lpNameHandle: LPHANDLE, +) -> INT} +FN!{stdcall LPFN_SETADDRINFOEXW( + pName: PCWSTR, + pServiceName: PCWSTR, + pAddresses: *mut SOCKET_ADDRESS, + dwAddressCount: DWORD, + lpBlob: LPBLOB, + dwFlags: DWORD, + dwNameSpace: DWORD, + lpNspId: LPGUID, + timeout: *mut timeval, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, + lpNameHandle: LPHANDLE, +) -> INT} +extern "system" { + pub fn freeaddrinfo( + pAddrInfo: PADDRINFOA, + ); + pub fn FreeAddrInfoW( + pAddrInfo: PADDRINFOW, + ); +} +FN!{stdcall LPFN_FREEADDRINFO( + pAddrInfo: PADDRINFOA, +) -> ()} +FN!{stdcall LPFN_FREEADDRINFOW( + pAddrInfo: PADDRINFOW, +) -> ()} +extern "system" { + pub fn FreeAddrInfoEx( + pAddrInfoEx: PADDRINFOEXA, + ); + pub fn FreeAddrInfoExW( + pAddrInfoEx: PADDRINFOEXW, + ); +} +FN!{stdcall LPFN_FREEADDRINFOEXA( + pAddrInfoEx: PADDRINFOEXA, +) -> ()} +FN!{stdcall LPFN_FREEADDRINFOEXW( + pAddrInfoEx: PADDRINFOEXW, +) -> ()} +pub type socklen_t = c_int; +extern "system" { + pub fn getnameinfo( + pSockaddr: *const SOCKADDR, + SockaddrLength: socklen_t, + pNodeBuffer: PCHAR, + NodeBufferSize: DWORD, + pServiceBuffer: PCHAR, + ServiceBufferSize: DWORD, + Flags: INT, + ) -> INT; + pub fn GetNameInfoW( + pSockaddr: *const SOCKADDR, + SockaddrLength: socklen_t, + pNodeBuffer: PWCHAR, + NodeBufferSize: DWORD, + pServiceBuffer: PWCHAR, + ServiceBufferSize: DWORD, + Flags: INT, + ) -> INT; +} +FN!{stdcall LPFN_GETNAMEINFO( + pSockaddr: *const SOCKADDR, + SockaddrLength: socklen_t, + pNodeBuffer: PCHAR, + NodeBufferSize: DWORD, + pServiceBuffer: PCHAR, + ServiceBufferSize: DWORD, + Flags: INT, +) -> c_int} +FN!{stdcall LPFN_GETNAMEINFOW( + pSockaddr: *const SOCKADDR, + SockaddrLength: socklen_t, + pNodeBuffer: PWCHAR, + NodeBufferSize: DWORD, + pServiceBuffer: PWCHAR, + ServiceBufferSize: DWORD, + Flags: INT, +) -> INT} +extern "system" { + pub fn inet_pton( + Family: INT, + pszAddrString: PCSTR, + pAddrBuf: PVOID, + ) -> INT; + pub fn InetPtonW( + Family: INT, + pszAddrString: PCWSTR, + pAddrBuf: PVOID, + ) -> INT; + pub fn inet_ntop( + Family: INT, + pAddr: *const VOID, + pStringBuf: PSTR, + StringBufSize: size_t, + ) -> PCSTR; + pub fn InetNtopW( + Family: INT, + pAddr: *const VOID, + pStringBuf: PWSTR, + StringBufSize: size_t, + ) -> PCWSTR; +} +FN!{stdcall LPFN_INET_PTONA( + Family: INT, + pszAddrString: PCSTR, + pAddrBuf: PVOID, +) -> INT} +FN!{stdcall LPFN_INET_PTONW( + Family: INT, + pszAddrString: PCWSTR, + pAddrBuf: PVOID, +) -> INT} +FN!{stdcall LPFN_INET_NTOPA( + Family: INT, + pAddr: *const VOID, + pStringBuf: PSTR, + StringBufSize: size_t, +) -> PCSTR} +FN!{stdcall LPFN_INET_NTOPW( + Family: INT, + pAddr: *const VOID, + pStringBuf: PWSTR, + StringBufSize: size_t, +) -> PCWSTR} +pub const GAI_STRERROR_BUFFER_SIZE: usize = 1024; +extern "system" { + pub fn WSASetSocketSecurity( + Socket: SOCKET, + SecuritySettings: *const SOCKET_SECURITY_SETTINGS, + SecuritySettingsLen: ULONG, + Overlapped: LPWSAOVERLAPPED, + CompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> INT; + pub fn WSAQuerySocketSecurity( + Socket: SOCKET, + SecurityQueryTemplate: *const SOCKET_SECURITY_QUERY_TEMPLATE, + SecurityQueryTemplateLen: ULONG, + SecurityQueryInfo: *mut SOCKET_SECURITY_QUERY_INFO, + SecurityQueryInfoLen: *mut ULONG, + Overlapped: LPWSAOVERLAPPED, + CompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> INT; + pub fn WSASetSocketPeerTargetName( + Socket: SOCKET, + PeerTargetName: *const SOCKET_PEER_TARGET_NAME, + PeerTargetNameLen: ULONG, + Overlapped: LPWSAOVERLAPPED, + CompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> INT; + pub fn WSADeleteSocketPeerTargetName( + Socket: SOCKET, + PeerAddr: *const SOCKADDR, + PeerAddrLen: ULONG, + Overlapped: LPWSAOVERLAPPED, + CompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> INT; + pub fn WSAImpersonateSocketPeer( + Socket: SOCKET, + PeerAddr: *const SOCKADDR, + PeerAddrLen: ULONG, + ) -> INT; + pub fn WSARevertImpersonation(); +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/um/xinput.rs b/third_party/cargo/vendor/winapi-0.3.8/src/um/xinput.rs new file mode 100644 index 0000000..e583c1e --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/um/xinput.rs @@ -0,0 +1,165 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! XInput procedure declarations, constant definitions and macros +use shared::guiddef::GUID; +use shared::minwindef::{BOOL, BYTE, DWORD, UINT, WORD}; +use um::winnt::{LPWSTR, SHORT, WCHAR}; +pub const XINPUT_DEVTYPE_GAMEPAD: BYTE = 0x01; +pub const XINPUT_DEVSUBTYPE_GAMEPAD: BYTE = 0x01; +pub const XINPUT_DEVSUBTYPE_WHEEL: BYTE = 0x02; +pub const XINPUT_DEVSUBTYPE_ARCADE_STICK: BYTE = 0x03; +pub const XINPUT_DEVSUBTYPE_FLIGHT_SICK: BYTE = 0x04; +pub const XINPUT_DEVSUBTYPE_DANCE_PAD: BYTE = 0x05; +pub const XINPUT_DEVSUBTYPE_GUITAR: BYTE = 0x06; +pub const XINPUT_DEVSUBTYPE_DRUM_KIT: BYTE = 0x08; +pub const XINPUT_CAPS_VOICE_SUPPORTED: WORD = 0x0004; +pub const XINPUT_GAMEPAD_DPAD_UP: WORD = 0x0001; +pub const XINPUT_GAMEPAD_DPAD_DOWN: WORD = 0x0002; +pub const XINPUT_GAMEPAD_DPAD_LEFT: WORD = 0x0004; +pub const XINPUT_GAMEPAD_DPAD_RIGHT: WORD = 0x0008; +pub const XINPUT_GAMEPAD_START: WORD = 0x0010; +pub const XINPUT_GAMEPAD_BACK: WORD = 0x0020; +pub const XINPUT_GAMEPAD_LEFT_THUMB: WORD = 0x0040; +pub const XINPUT_GAMEPAD_RIGHT_THUMB: WORD = 0x0080; +pub const XINPUT_GAMEPAD_LEFT_SHOULDER: WORD = 0x0100; +pub const XINPUT_GAMEPAD_RIGHT_SHOULDER: WORD = 0x0200; +pub const XINPUT_GAMEPAD_A: WORD = 0x1000; +pub const XINPUT_GAMEPAD_B: WORD = 0x2000; +pub const XINPUT_GAMEPAD_X: WORD = 0x4000; +pub const XINPUT_GAMEPAD_Y: WORD = 0x8000; +pub const XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE: SHORT = 7849; +pub const XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE: SHORT = 8689; +pub const XINPUT_GAMEPAD_TRIGGER_THRESHOLD: BYTE = 30; +pub const XINPUT_FLAG_GAMEPAD: DWORD = 0x00000001; +pub const BATTERY_DEVTYPE_GAMEPAD: BYTE = 0x00; +pub const BATTERY_DEVTYPE_HEADSET: BYTE = 0x01; +pub const BATTERY_TYPE_DISCONNECTED: BYTE = 0x00; +pub const BATTERY_TYPE_WIRED: BYTE = 0x01; +pub const BATTERY_TYPE_ALKALINE: BYTE = 0x02; +pub const BATTERY_TYPE_NIMH: BYTE = 0x03; +pub const BATTERY_TYPE_UNKNOWN: BYTE = 0xFF; +pub const BATTERY_LEVEL_EMPTY: BYTE = 0x00; +pub const BATTERY_LEVEL_LOW: BYTE = 0x01; +pub const BATTERY_LEVEL_MEDIUM: BYTE = 0x02; +pub const BATTERY_LEVEL_FULL: BYTE = 0x03; +pub const XUSER_MAX_COUNT: DWORD = 4; +pub const XUSER_INDEX_ANY: DWORD = 0x000000FF; +pub const VK_PAD_A: WORD = 0x5800; +pub const VK_PAD_B: WORD = 0x5801; +pub const VK_PAD_X: WORD = 0x5802; +pub const VK_PAD_Y: WORD = 0x5803; +pub const VK_PAD_RSHOULDER: WORD = 0x5804; +pub const VK_PAD_LSHOULDER: WORD = 0x5805; +pub const VK_PAD_LTRIGGER: WORD = 0x5806; +pub const VK_PAD_RTRIGGER: WORD = 0x5807; +pub const VK_PAD_DPAD_UP: WORD = 0x5810; +pub const VK_PAD_DPAD_DOWN: WORD = 0x5811; +pub const VK_PAD_DPAD_LEFT: WORD = 0x5812; +pub const VK_PAD_DPAD_RIGHT: WORD = 0x5813; +pub const VK_PAD_START: WORD = 0x5814; +pub const VK_PAD_BACK: WORD = 0x5815; +pub const VK_PAD_LTHUMB_PRESS: WORD = 0x5816; +pub const VK_PAD_RTHUMB_PRESS: WORD = 0x5817; +pub const VK_PAD_LTHUMB_UP: WORD = 0x5820; +pub const VK_PAD_LTHUMB_DOWN: WORD = 0x5821; +pub const VK_PAD_LTHUMB_RIGHT: WORD = 0x5822; +pub const VK_PAD_LTHUMB_LEFT: WORD = 0x5823; +pub const VK_PAD_LTHUMB_UPLEFT: WORD = 0x5824; +pub const VK_PAD_LTHUMB_UPRIGHT: WORD = 0x5825; +pub const VK_PAD_LTHUMB_DOWNRIGHT: WORD = 0x5826; +pub const VK_PAD_LTHUMB_DOWNLEFT: WORD = 0x5827; +pub const VK_PAD_RTHUMB_UP: WORD = 0x5830; +pub const VK_PAD_RTHUMB_DOWN: WORD = 0x5831; +pub const VK_PAD_RTHUMB_RIGHT: WORD = 0x5832; +pub const VK_PAD_RTHUMB_LEFT: WORD = 0x5833; +pub const VK_PAD_RTHUMB_UPLEFT: WORD = 0x5834; +pub const VK_PAD_RTHUMB_UPRIGHT: WORD = 0x5835; +pub const VK_PAD_RTHUMB_DOWNRIGHT: WORD = 0x5836; +pub const VK_PAD_RTHUMB_DOWNLEFT: WORD = 0x5837; +pub const XINPUT_KEYSTROKE_KEYDOWN: WORD = 0x0001; +pub const XINPUT_KEYSTROKE_KEYUP: WORD = 0x0002; +pub const XINPUT_KEYSTROKE_REPEAT: WORD = 0x0004; +STRUCT!{struct XINPUT_GAMEPAD { + wButtons: WORD, + bLeftTrigger: BYTE, + bRightTrigger: BYTE, + sThumbLX: SHORT, + sThumbLY: SHORT, + sThumbRX: SHORT, + sThumbRY: SHORT, +}} +pub type PXINPUT_GAMEPAD = *mut XINPUT_GAMEPAD; +STRUCT!{struct XINPUT_STATE { + dwPacketNumber: DWORD, + Gamepad: XINPUT_GAMEPAD, +}} +pub type PXINPUT_STATE = *mut XINPUT_STATE; +STRUCT!{struct XINPUT_VIBRATION { + wLeftMotorSpeed: WORD, + wRightMotorSpeed: WORD, +}} +pub type PXINPUT_VIBRATION = *mut XINPUT_VIBRATION; +STRUCT!{struct XINPUT_CAPABILITIES { + Type: BYTE, + SubType: BYTE, + Flags: WORD, + Gamepad: XINPUT_GAMEPAD, + Vibration: XINPUT_VIBRATION, +}} +pub type PXINPUT_CAPABILITIES = *mut XINPUT_CAPABILITIES; +STRUCT!{struct XINPUT_BATTERY_INFORMATION { + BatteryType: BYTE, + BatteryLevel: BYTE, +}} +pub type PXINPUT_BATTERY_INFORMATION = *mut XINPUT_BATTERY_INFORMATION; +STRUCT!{struct XINPUT_KEYSTROKE { + VirtualKey: WORD, + Unicode: WCHAR, + Flags: WORD, + UserIndex: BYTE, + HidCode: BYTE, +}} +pub type PXINPUT_KEYSTROKE = *mut XINPUT_KEYSTROKE; +extern "system" { + pub fn XInputGetState( + dwUserIndex: DWORD, + pState: *mut XINPUT_STATE, + ) -> DWORD; + pub fn XInputSetState( + dwUserIndex: DWORD, + pVibration: *mut XINPUT_VIBRATION, + ) -> DWORD; + pub fn XInputGetCapabilities( + dwUserIndex: DWORD, + dwFlags: DWORD, + pCapabilities: *mut XINPUT_CAPABILITIES, + ) -> DWORD; + pub fn XInputEnable( + enable: BOOL, + ); + pub fn XInputGetAudioDeviceIds( + dwUserIndex: DWORD, + pRenderDeviceId: LPWSTR, + pRenderCount: *mut UINT, + pCaptureDeviceId: LPWSTR, + pCaptureCount: *mut UINT, + ) -> DWORD; + pub fn XInputGetBatteryInformation( + dwUserIndex: DWORD, + devType: BYTE, + pBatteryInformation: *mut XINPUT_BATTERY_INFORMATION, + ) -> DWORD; + pub fn XInputGetKeystroke( + dwUserIndex: DWORD, + dwReserved: DWORD, + pKeystroke: PXINPUT_KEYSTROKE, + ) -> DWORD; + pub fn XInputGetDSoundAudioDeviceGuids( + dwUserIndex: DWORD, + pDSoundRenderGuid: *mut GUID, + pDSoundCaptureGuid: *mut GUID, + ) -> DWORD; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/vc/excpt.rs b/third_party/cargo/vendor/winapi-0.3.8/src/vc/excpt.rs new file mode 100644 index 0000000..a4f4d91 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/vc/excpt.rs @@ -0,0 +1,18 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! The declarations of the compiler-dependent intrinsics, support functions, and keywords which +//! implement the structured exception handling extensions. +ENUM!{enum EXCEPTION_DISPOSITION { + ExceptionContinueExecution, + ExceptionContinueSearch, + ExceptionNestedException, + ExceptionCollidedUnwind, +}} +// While there are functions defined here in `excpt.h`, they are actually intrinsics which have +// special black magic in the msvc compiler. Thus bindings cannot be provided for them. +pub const EXCEPTION_EXECUTE_HANDLER: i32 = 1; +pub const EXCEPTION_CONTINUE_SEARCH: i32 = 0; +pub const EXCEPTION_CONTINUE_EXECUTION: i32 = -1; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/vc/limits.rs b/third_party/cargo/vendor/winapi-0.3.8/src/vc/limits.rs new file mode 100644 index 0000000..31509ad --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/vc/limits.rs @@ -0,0 +1,7 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_uint; +pub const UINT_MAX: c_uint = 0xffffffff; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/vc/mod.rs b/third_party/cargo/vendor/winapi-0.3.8/src/vc/mod.rs new file mode 100644 index 0000000..0c0606b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/vc/mod.rs @@ -0,0 +1,10 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Headers that come with VC. Notably, these are not part of the Windows SDK. +#[cfg(feature = "excpt")] pub mod excpt; +#[cfg(feature = "limits")] pub mod limits; +#[cfg(feature = "vadefs")] pub mod vadefs; +#[cfg(feature = "vcruntime")] pub mod vcruntime; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/vc/vadefs.rs b/third_party/cargo/vendor/winapi-0.3.8/src/vc/vadefs.rs new file mode 100644 index 0000000..d44cc04 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/vc/vadefs.rs @@ -0,0 +1,8 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::c_char; +pub type uintptr_t = usize; +pub type va_list = *mut c_char; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/vc/vcruntime.rs b/third_party/cargo/vendor/winapi-0.3.8/src/vc/vcruntime.rs new file mode 100644 index 0000000..63c671b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/vc/vcruntime.rs @@ -0,0 +1,9 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Declarations used throughout the VCRuntime library. +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/winrt/activation.rs b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/activation.rs new file mode 100644 index 0000000..dca597b --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/activation.rs @@ -0,0 +1,13 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use um::winnt::HRESULT; +use winrt::inspectable::{IInspectable, IInspectableVtbl}; +RIDL!{#[uuid(0x00000035, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IActivationFactory(IActivationFactoryVtbl): IInspectable(IInspectableVtbl) { + fn ActivateInstance( + instance: *mut *mut IInspectable, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/winrt/hstring.rs b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/hstring.rs new file mode 100644 index 0000000..3eae6e0 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/hstring.rs @@ -0,0 +1,25 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! This interface definition contains typedefs for Windows Runtime data types. +use ctypes::c_char; +use um::winnt::PVOID; +DECLARE_HANDLE!{HSTRING, HSTRING__} +#[cfg(target_pointer_width = "32")] +UNION!{union HSTRING_HEADER_Reserved { + [u32; 5], + Reserved1 Reserved1_mut: PVOID, + Reserved2 Reserved2_mut: [c_char; 20], +}} +#[cfg(target_pointer_width = "64")] +UNION!{union HSTRING_HEADER_Reserved { + [u64; 3], + Reserved1 Reserved1_mut: PVOID, + Reserved2 Reserved2_mut: [c_char; 24], +}} +STRUCT!{struct HSTRING_HEADER { + Reserved: HSTRING_HEADER_Reserved, +}} +DECLARE_HANDLE!{HSTRING_BUFFER, HSTRING_BUFFER__} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/winrt/inspectable.rs b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/inspectable.rs new file mode 100644 index 0000000..fb1e433 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/inspectable.rs @@ -0,0 +1,29 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::guiddef::IID; +use shared::minwindef::ULONG; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::HRESULT; +use winrt::hstring::HSTRING; +pub type LPINSPECTABLE = *mut IInspectable; +ENUM!{enum TrustLevel { + BaseTrust = 0, + PartialTrust, + FullTrust, +}} +RIDL!{#[uuid(0xaf86e2e0, 0xb12d, 0x4c6a, 0x9c, 0x5a, 0xd7, 0xaa, 0x65, 0x10, 0x1e, 0x90)] +interface IInspectable(IInspectableVtbl): IUnknown(IUnknownVtbl) { + fn GetIids( + iidCount: *mut ULONG, + iids: *mut *mut IID, + ) -> HRESULT, + fn GetRuntimeClassName( + className: *mut HSTRING, + ) -> HRESULT, + fn GetTrustLevel( + trustLevel: *mut TrustLevel, + ) -> HRESULT, +}} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/winrt/mod.rs b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/mod.rs new file mode 100644 index 0000000..47e3867 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/mod.rs @@ -0,0 +1,12 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +#[cfg(feature = "activation")] pub mod activation; +#[cfg(feature = "hstring")] pub mod hstring; +#[cfg(feature = "inspectable")] pub mod inspectable; +#[cfg(feature = "roapi")] pub mod roapi; +#[cfg(feature = "robuffer")] pub mod robuffer; +#[cfg(feature = "roerrorapi")] pub mod roerrorapi; +#[cfg(feature = "winstring")] pub mod winstring; diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/winrt/roapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/roapi.rs new file mode 100644 index 0000000..47b9880 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/roapi.rs @@ -0,0 +1,60 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{UINT32, UINT64}; +use shared::guiddef::REFIID; +use um::objidl::IApartmentShutdown; +use um::winnt::{HRESULT, VOID}; +use winrt::activation::IActivationFactory; +use winrt::hstring::HSTRING; +use winrt::inspectable::IInspectable; +ENUM!{enum RO_INIT_TYPE { + RO_INIT_SINGLETHREADED = 0, + RO_INIT_MULTITHREADED = 1, +}} +pub enum RO_REGISTRATION_COOKIE__ {} +pub type RO_REGISTRATION_COOKIE = *mut RO_REGISTRATION_COOKIE__; +FN!{stdcall PFNGETACTIVATIONFACTORY( + HSTRING, + *mut *mut IActivationFactory, +) -> HRESULT} +extern "system" { + pub fn RoInitialize( + initType: RO_INIT_TYPE, + ) -> HRESULT; + pub fn RoUninitialize(); + pub fn RoActivateInstance( + activatableClassId: HSTRING, + instance: *mut *mut IInspectable, + ) -> HRESULT; + pub fn RoRegisterActivationFactories( + activatableClassIds: *const HSTRING, + activationFactoryCallbacks: *const PFNGETACTIVATIONFACTORY, + count: UINT32, + cookie: *mut RO_REGISTRATION_COOKIE, + ) -> HRESULT; + pub fn RoRevokeActivationFactories( + cookie: RO_REGISTRATION_COOKIE, + ); + pub fn RoGetActivationFactory( + activatableClassId: HSTRING, + iid: REFIID, + factory: *mut *mut VOID, + ) -> HRESULT; +} +DECLARE_HANDLE!{APARTMENT_SHUTDOWN_REGISTRATION_COOKIE, APARTMENT_SHUTDOWN_REGISTRATION_COOKIE__} +extern "system" { + pub fn RoRegisterForApartmentShutdown( + callbackObject: *const IApartmentShutdown, + apartmentIdentifier: *mut UINT64, + regCookie: *mut APARTMENT_SHUTDOWN_REGISTRATION_COOKIE, + ) -> HRESULT; + pub fn RoUnregisterForApartmentShutdown( + regCookie: APARTMENT_SHUTDOWN_REGISTRATION_COOKIE, + ) -> HRESULT; + pub fn RoGetApartmentIdentifier( + apartmentIdentifier: *mut UINT64, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/winrt/robuffer.rs b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/robuffer.rs new file mode 100644 index 0000000..b0192fb --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/robuffer.rs @@ -0,0 +1,12 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use um::objidl::IMarshal; +use um::winnt::HRESULT; +extern "system" { + pub fn RoGetBufferMarshaler( + bufferMarshaler: *mut *mut IMarshal, + ) -> HRESULT; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/winrt/roerrorapi.rs b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/roerrorapi.rs new file mode 100644 index 0000000..aa9f683 --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/roerrorapi.rs @@ -0,0 +1,103 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{UINT32, UINT_PTR}; +use shared::minwindef::{BOOL, BYTE, UINT, USHORT}; +use um::restrictederrorinfo::IRestrictedErrorInfo; +use um::unknwnbase::IUnknown; +use um::winnt::{HRESULT, PCWSTR, PVOID, VOID}; +use winrt::hstring::HSTRING; +ENUM!{enum RO_ERROR_REPORTING_FLAGS { + RO_ERROR_REPORTING_NONE = 0x00000000, + RO_ERROR_REPORTING_SUPPRESSEXCEPTIONS = 0x00000001, + RO_ERROR_REPORTING_FORCEEXCEPTIONS = 0x00000002, + RO_ERROR_REPORTING_USESETERRORINFO = 0x00000004, + RO_ERROR_REPORTING_SUPPRESSSETERRORINFO = 0x00000008, +}} +extern "system" { + pub fn RoGetErrorReportingFlags( + pflags: *mut UINT32, + ) -> HRESULT; + pub fn RoSetErrorReportingFlags( + flags: UINT32, + ) -> HRESULT; + pub fn RoResolveRestrictedErrorInfoReference( + reference: PCWSTR, + ppRestrictedErrorInfo: *mut *mut IRestrictedErrorInfo , + ) -> HRESULT; + pub fn SetRestrictedErrorInfo( + pRestrictedErrorInfo: *const IRestrictedErrorInfo, + ) -> HRESULT; + pub fn GetRestrictedErrorInfo( + ppRestrictedErrorInfo: *mut *mut IRestrictedErrorInfo, + ) -> HRESULT; + pub fn RoOriginateErrorW( + error: HRESULT, + cchMax: UINT, + message: PCWSTR, + ) -> BOOL; + pub fn RoOriginateError( + error: HRESULT, + message: HSTRING, + ) -> BOOL; + pub fn RoTransformErrorW( + oldError: HRESULT, + newError: HRESULT, + cchMax: UINT, + message: PCWSTR, + ) -> BOOL; + pub fn RoTransformError( + oldError: HRESULT, + newError: HRESULT, + message: HSTRING, + ) -> BOOL; + pub fn RoCaptureErrorContext( + hr: HRESULT, + ) -> HRESULT; + pub fn RoFailFastWithErrorContext( + hrError: HRESULT, + ); + pub fn RoOriginateLanguageException( + error: HRESULT, + message: HSTRING, + languageException: *const IUnknown, + ) -> BOOL; + pub fn RoClearError(); + pub fn RoReportUnhandledError( + pRestrictedErrorInfo: *const IRestrictedErrorInfo, + ) -> HRESULT; +} +FN!{stdcall PINSPECT_MEMORY_CALLBACK( + *const VOID, + UINT_PTR, + UINT32, + *mut BYTE, +) -> HRESULT} +extern "system" { + pub fn RoInspectThreadErrorInfo( + targetTebAddress: UINT_PTR, + machine: USHORT, + readMemoryCallback: PINSPECT_MEMORY_CALLBACK, + context: PVOID, + targetErrorInfoAddress: *mut UINT_PTR, + ) -> HRESULT; + pub fn RoInspectCapturedStackBackTrace( + targetErrorInfoAddress: UINT_PTR, + machine: USHORT, + readMemoryCallback: PINSPECT_MEMORY_CALLBACK, + context: PVOID, + frameCount: *mut UINT32, + targetBackTraceAddress: *mut UINT_PTR, + ) -> HRESULT; + pub fn RoGetMatchingRestrictedErrorInfo( + hrIn: HRESULT, + ppRestrictedErrorInfo: *mut *mut IRestrictedErrorInfo, + ) -> HRESULT; + pub fn RoReportFailedDelegate( + punkDelegate: *const IUnknown, + pRestrictedErrorInfo: *const IRestrictedErrorInfo, + ) -> HRESULT; + pub fn IsErrorPropagationEnabled() -> BOOL; +} diff --git a/third_party/cargo/vendor/winapi-0.3.8/src/winrt/winstring.rs b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/winstring.rs new file mode 100644 index 0000000..ecbfcdf --- /dev/null +++ b/third_party/cargo/vendor/winapi-0.3.8/src/winrt/winstring.rs @@ -0,0 +1,150 @@ +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::basetsd::{INT32, UINT32, UINT_PTR}; +use shared::minwindef::{BOOL, BYTE, UCHAR, ULONG, USHORT}; +use um::winnt::{HRESULT, PCWSTR, VOID, WCHAR}; +use winrt::hstring::{HSTRING, HSTRING_BUFFER, HSTRING_HEADER}; +extern "system" { + pub fn WindowsCreateString( + sourceString: PCWSTR, + length: UINT32, + string: *mut HSTRING, + ) -> HRESULT; + pub fn WindowsCreateStringReference( + sourceString: PCWSTR, + length: UINT32, + hstringHeader: *mut HSTRING_HEADER, + string: *mut HSTRING, + ) -> HRESULT; + pub fn WindowsDeleteString( + string: HSTRING, + ) -> HRESULT; + pub fn WindowsDuplicateString( + string: HSTRING, + newString: *mut HSTRING, + ) -> HRESULT; + pub fn WindowsGetStringLen( + string: HSTRING, + ) -> UINT32; + pub fn WindowsGetStringRawBuffer( + string: HSTRING, + length: *mut UINT32, + ) -> PCWSTR; + pub fn WindowsIsStringEmpty( + string: HSTRING, + ) -> BOOL; + pub fn WindowsStringHasEmbeddedNull( + string: HSTRING, + hasEmbedNull: *mut BOOL, + ) -> HRESULT; + pub fn WindowsCompareStringOrdinal( + string1: HSTRING, + string2: HSTRING, + result: *mut INT32, + ) -> HRESULT; + pub fn WindowsSubstring( + string: HSTRING, + startIndex: UINT32, + newString: *mut HSTRING, + ) -> HSTRING; + pub fn WindowsSubstringWithSpecifiedLength( + string: HSTRING, + startIndex: UINT32, + length: UINT32, + newString: *mut HSTRING, + ) -> HRESULT; + pub fn WindowsConcatString( + string1: HSTRING, + string2: HSTRING, + newString: *mut HSTRING, + ) -> HRESULT; + pub fn WindowsReplaceString( + string: HSTRING, + stringReplaced: HSTRING, + stringReplaceWith: HSTRING, + newString: *mut HSTRING, + ) -> HRESULT; + pub fn WindowsTrimStringStart( + string: HSTRING, + trimString: HSTRING, + newString: *mut HSTRING, + ) -> HRESULT; + pub fn WindowsTrimStringEnd( + string: HSTRING, + trimString: HSTRING, + newString: *mut HSTRING, + ) -> HRESULT; + pub fn WindowsPreallocateStringBuffer( + length: UINT32, + charBuffer: *mut *mut WCHAR, + bufferHandle: *mut HSTRING_BUFFER, + ) -> HRESULT; + pub fn WindowsPromoteStringBuffer( + bufferHandle: HSTRING_BUFFER, + string: *mut HSTRING, + ) -> HRESULT; + pub fn WindowsDeleteStringBuffer( + bufferHandle: HSTRING_BUFFER, + ) -> HRESULT; +} +FN!{stdcall PINSPECT_HSTRING_CALLBACK( + *const VOID, + UINT_PTR, + UINT32, + *mut BYTE, +) -> HRESULT} +extern "system" { + pub fn WindowsInspectString( + targetHString: UINT_PTR, + machine: USHORT, + callback: PINSPECT_HSTRING_CALLBACK, + context: *const VOID, + length: *mut UINT32, + targetStringAddress: *mut UINT_PTR, + ) -> HRESULT; + pub fn HSTRING_UserSize( + pFlags: *const ULONG, + StartingSize: ULONG, + ppidl: *const HSTRING, + ) -> ULONG; + pub fn HSTRING_UserMarshal( + pFlags: *const ULONG, + pBuffer: *mut UCHAR, + ppidl: *const HSTRING, + ) -> *mut UCHAR; + pub fn HSTRING_UserUnmarshal( + pFlags: *const ULONG, + pBuffer: *const UCHAR, + ppidl: *mut HSTRING, + ) -> *mut UCHAR; + pub fn HSTRING_UserFree( + pFlags: *const ULONG, + ppidl: *const HSTRING, + ); + #[cfg(target_arch = "x86_64")] + pub fn HSTRING_UserSize64( + pFlags: *const ULONG, + StartingSize: ULONG, + ppidl: *const HSTRING, + ) -> ULONG; + #[cfg(target_arch = "x86_64")] + pub fn HSTRING_UserMarshal64( + pFlags: *const ULONG, + pBuffer: *mut UCHAR, + ppidl: *const HSTRING, + ) -> *mut UCHAR; + #[cfg(target_arch = "x86_64")] + pub fn HSTRING_UserUnmarshal64( + pFlags: *const ULONG, + pBuffer: *const UCHAR, + ppidl: *mut HSTRING, + ) -> *mut UCHAR; + #[cfg(target_arch = "x86_64")] + pub fn HSTRING_UserFree64( + pFlags: *const ULONG, + ppidl: *const HSTRING, + ); +} diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/.cargo-checksum.json b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/.cargo-checksum.json new file mode 100644 index 0000000..a17fa1b --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"9652222664ffc7e2a26fdcdebdce0917a455b39d8fbcbf451bf0b011a3067bf7","build.rs":"4344ce95f51197e1377429cd9ef7a8e3f97d39546776705857991f2f9416f545","lib/libwinapi_aclui.a":"0fbe9d7eba9a106e90db5b015ed7751761c67f239dc6514a2cfad4e530f92490","lib/libwinapi_activeds.a":"68625fcfe4d6a203982fc319b5cc11e6ad07a57ecac442d07f0240e0aac5b28c","lib/libwinapi_advapi32.a":"9ac26b513ab07aed0435d7fe264d811a3d221619d70a34e49261fe0fa78c2cb0","lib/libwinapi_advpack.a":"52b75cb9f96fbe517c52b64bdfc12c928cfc427f4448151828e3c74460334c4d","lib/libwinapi_amsi.a":"72601859db74036937fdb75b8e7f3323f88c52261f4b49f55d1796e8f18e258f","lib/libwinapi_api-ms-win-net-isolation-l1-1-0.a":"8be3322ca57f3b37c8a5f77455fde9f901eebc1533b3aea5783312cbecf1f7e4","lib/libwinapi_apidll.a":"5e8500ef8566b8057585cc9a442feb62487f92cd3ab44831375455138a34d824","lib/libwinapi_appmgmts.a":"c1abfaadf53df46e9e8cc53aa857ffa94f2018b2ac43d9eb9af5fb6351824aa8","lib/libwinapi_appnotify.a":"2aa211c2947c93f913e0d820adc988902664d501c6c19f024bf0c9631e237f4a","lib/libwinapi_asycfilt.a":"dcfb20c70c45f5effccea72ca1cf0ec7169437b666e08d0e6d1a1c9b1246f43e","lib/libwinapi_audioeng.a":"8fd59a757df15225867ed3a9da1fd0e89bb8510da0d864dfe7ee19c6cf8f128e","lib/libwinapi_authz.a":"c5f91aa9ed03b794b760f468122e38c321a936b851ee3127934bb7e5b3480373","lib/libwinapi_avifil32.a":"abb571ed8955cc629b21049cc26a9268d2a4b026d445472b9df13079362b7ae2","lib/libwinapi_avrt.a":"d5ffc07ffb0bcd8708982137d7707941d775d50dae8f8a48a7f34019593e32cd","lib/libwinapi_basesrv.a":"97947ae129d72d598ab1048621ed66ffdf8015c3ed48a4043b399ca5c39348f7","lib/libwinapi_bcrypt.a":"e326aa515c54b84398aefbb1f89cc25aa8e015e6de5aa9657bd520b571a3dbf8","lib/libwinapi_bluetoothapis.a":"fd0c6920651b1d2cc58aba2bd5dc2fdce24008311de9c2a64d214e759d0b5daf","lib/libwinapi_bthprops.a":"210d9ae0b3f8b5d541d247ce9f5dcc9f6f76fa742c679feddac7e734c1f67428","lib/libwinapi_cabinet.a":"0a939ce654b1da5e476ba96e3133ca91005d754ace0b8731192cef71c2aba610","lib/libwinapi_certadm.a":"fde5cbb6c17d881e9910ff1f92f6c7398fce6d9ac86e9953c22517f6efa3a95d","lib/libwinapi_certpoleng.a":"f10c0228d72cdd0d90c74710438f32874e2abc790b2147c553da0f66811b7597","lib/libwinapi_cfgmgr32.a":"d03afff062eb551659da083557e12ff0a475a910216aedf0b62c66ab2b12bca3","lib/libwinapi_chakrart.a":"68f5267b9fc1c58343c60767afac09353fed9072b1ec90de6af7ae148c588064","lib/libwinapi_cldapi.a":"f9d6edbbf01a27ebee6202a33031df41c25a0dddf4f883f5424a7e6992fe31e1","lib/libwinapi_clfsw32.a":"2e06e28b09b1e33711f3f8b26201841098c3b21b2a798c5e1f06d43d57d2dfed","lib/libwinapi_clusapi.a":"c9ff19d78cdb9ee4840c9670c50876dd592f13c1270fb47bff56ca639631a3a6","lib/libwinapi_comctl32.a":"ac22f45bcfa30dc99aca01f7bbdcc74e8c5c42174fed2433d72ab9394d874965","lib/libwinapi_comdlg32.a":"8627efe7eae1299973356102941d37717014a209d057e72a7ab0d939dac7c4df","lib/libwinapi_comppkgsup.a":"0b23a6896cbb77be7b61e2803dc813fd8045e55cebd404dafb906fd0490ef349","lib/libwinapi_compstui.a":"51d0b2a1f59132521a02e10af2456b39ad717b69584fd455f53897666a3135d2","lib/libwinapi_comsvcs.a":"850811393316175ba229824303af68b79d5e5298d139ff72739611fb6b0b51e8","lib/libwinapi_coremessaging.a":"e7f09278971204cd768d87aeaf360762a577e61487efbd506edfe98c532e5a00","lib/libwinapi_credui.a":"20f8d03a576e27450836d417d68bd2efbd95a24dd48747d628ac1f961d59dcf0","lib/libwinapi_crypt32.a":"d6636245cfaebc8dc5231782b89d720665e87c41cabce1f8bec8d16b22d3f29e","lib/libwinapi_cryptdll.a":"82c5078c0c1597a78c8ceb57b56c32c950903c30feb896811abdc56fd07dfb98","lib/libwinapi_cryptnet.a":"641416ef4ca071ecebea4df802ce962d2fa66d7d4d6fd79ebb4a5bed5a272df7","lib/libwinapi_cryptui.a":"b6cda968797c29c01fb18866cf572e07dadbba84536e57971b4f3f952111d6b4","lib/libwinapi_cryptxml.a":"a0549ca925339de1147171c3ea7a0290d5b25c11c2ba81e88967aceb6edb2bb8","lib/libwinapi_cscapi.a":"ee700f192690598942164bb7b68401941209d32a4ff7d337c4975f921b12dedf","lib/libwinapi_cscdll.a":"2c3102f7b9ece5bf5e76f31450b68f2918a49b38f423cfec4008b17926c15d1b","lib/libwinapi_d2d1.a":"2c5ef4461d9a423a70754b352df2c482a87fa9095de45117da6de9947313fa0f","lib/libwinapi_d3d10.a":"f4ab0d6f2f5fbb00b0695f2caa571fd4cfefedef0875c4dc9ec5d46b9394589e","lib/libwinapi_d3d10_1.a":"bbe5b92965a987c5ed5dd860218bc51cf2e1c8fffda4314ff608283655e53d73","lib/libwinapi_d3d11.a":"90e6d40c9faaecb427cc835b6d35f9c97b03fa6343b96254877ba1e0c5fc5be0","lib/libwinapi_d3d12.a":"78576e2db7b47ed1690d825e853e3d1674bf61b860da0efd4a4e14bd6aacbc61","lib/libwinapi_d3d9.a":"213ac512f39f2ffd714160465b86d75fba2a06fe62808c2a957f2d92b54d306e","lib/libwinapi_d3dcompiler.a":"424680ef712001ce3b9af808ceabd54c3510c3cc35a7fb65505994a3ea6f8406","lib/libwinapi_d3dcsx.a":"f85eed17ab41d79f7ffef10e586359a90ad70cecbff80cdeb51015f1440df91f","lib/libwinapi_d3dcsxd.a":"6d5e5c53acfe3eb8e292188aa2f777e07c2161fd1740d1eada9d8b0c271b3453","lib/libwinapi_davclnt.a":"0a99a29e6292f55e14a7c2d403b35d5b4de7125d77dc0ccb218f9d58de0d0f94","lib/libwinapi_dbgeng.a":"77eee9c92f9ebd54fdf746df2af14b8cc744f3e8c729d68ad7fc38af85f70fc5","lib/libwinapi_dbghelp.a":"f0ae8d1d66bee0b1d13e8699da7118a0556ba6912976544fbccaeb2d7b0a2f1c","lib/libwinapi_dciman32.a":"f22380ae622f6228d0062931ba26c5a8d6f82db059a3ef935cf568bec711734c","lib/libwinapi_dcomp.a":"2fbcba609dfbbf5be4698488c4576a6b672d05c7f7ee3596b4c7b0eaa7b5aeb2","lib/libwinapi_ddraw.a":"6c48b9705f4d8bd99c72fb046289403161e1cda68e20833c9976fbb2e7c2ad85","lib/libwinapi_deviceaccess.a":"3b304c6f3a7f608ced8ca1c1d12f80451c5c3e5c38a31ad6afbe1331def5da8c","lib/libwinapi_devmgr.a":"582335b229c0c41f117ecb231f2a3f454c1e4101a748006df5e48174063309ef","lib/libwinapi_dflayout.a":"ee4d80b5babc4e5c86a5a42c2ac81db97968b2ff0c4f90ae290893f575c0ccc3","lib/libwinapi_dhcpcsvc.a":"b56ecceb638e762306f5f1f211efdd18b00a50ff68043db24129008d22757732","lib/libwinapi_dhcpcsvc6.a":"4fcdb0360d94492060e8ff6447ac457ef574111c2ad609c93044a8e122ee9a80","lib/libwinapi_dhcpsapi.a":"d3ff30b18ba039ba0dbbb5b6ec1d72b1cb3f4dae9cbab0225ea6140e2006f58f","lib/libwinapi_difxapi.a":"bf7d9dcd82e317a49838ba62fe7a2f14bf7ac0c8532f37005eed70d3ac0a40df","lib/libwinapi_dinput8.a":"34110fbc33a44cba74d4ca6d6d929ad2ae966d94910f0219413e8940da3b2729","lib/libwinapi_dmprocessxmlfiltered.a":"44c65bfa21a4f02cb9da6ca37c6f0a9b96e8b4fa38a41ca579e89514d8c1af47","lib/libwinapi_dnsapi.a":"aa56f391dc111521f4fa1ab4f30f3ee865b62c6be8a0de8a4734058829651896","lib/libwinapi_dnsperf.a":"aefb3a4844da409f0400434521411f962865504ea7da7aa8f5d438adc518f8c5","lib/libwinapi_dnsrslvr.a":"ac9bb5a3501088c341e883bc9d57280cc27634e07f23910240cf72d190344be5","lib/libwinapi_dpx.a":"e6cee99989005e4437765d62d559abf7020c28eb153811af3044ec86472c86c9","lib/libwinapi_drt.a":"2d34b2d341f315055c4995616c3e403a512f9a082107328e0d4de3f2dfef19be","lib/libwinapi_drtprov.a":"6d843ca33dbf724a9144560c9ac102f93040aa4f497871b35b2b9f04742ec17c","lib/libwinapi_drttransport.a":"359e0e38a56303c810d0c0cde22ebb79c1d4d35b4ef05666ea4cc63b7db1b6a8","lib/libwinapi_dsound.a":"ca4ef310b1a647ac8ce805440fbec9b6ff5fa2c4cb182c9f036d5b1f722917b1","lib/libwinapi_dsprop.a":"9b6388208daa1fd6b3a9cf3b824562c080a33b3700f9ab0e900ec65bb72ac84c","lib/libwinapi_dssec.a":"67ad35bc06b48ae9fbff63ebb557ae659221ca205adc87ea0794673db3b2f5f1","lib/libwinapi_dststlog.a":"2c21e4394caba6685c241269a969e691aba2002a3a0d5231b9593e35b39ae09a","lib/libwinapi_dsuiext.a":"bffa87caa660df48f451c042bd508a0ebf42164e0d21b2fc28fa257e3176e9e3","lib/libwinapi_dwmapi.a":"90bfb9cc29ab4c1727ad5ce3d2377f4de3844a33fdef9c4fc8c1884a352366e0","lib/libwinapi_dwrite.a":"25175cc1f319922defc1250458235fc928220dc8c83ca47debc8c394c530272c","lib/libwinapi_dxgi.a":"a34fbbffc722a65e3dee7bd343922410bd967ee83312a51d012197719cebe914","lib/libwinapi_dxva2.a":"7e1e4970e62fcdd79e4da6c115cf86958f8b700d10cfe866cbf6de295b066927","lib/libwinapi_eappcfg.a":"f44b33f18ab48d02c0d0b3959d4e4b74e274ee7f16a0b379ecd2630060600eda","lib/libwinapi_eappprxy.a":"ef3613d4431002f745dfef5c86bff39bc46cfdb1a2613c08dc3bcd1c92f9cae1","lib/libwinapi_easregprov.a":"167ddbd0c62e76c61c20376abc5f3bd0a2e9a10b69b9ab406d43bb33375d15b2","lib/libwinapi_efswrt.a":"40de24aca17035eab38f9635c72304599b58df37c3ff1fabf62aefc036f31a5f","lib/libwinapi_elscore.a":"8790f716c925482c8f3a90e9f102e1cbd2a98a95d2da74e6ecb40cb213f98f72","lib/libwinapi_esent.a":"84fd8fd3a6a0a230a1932dbeded85e32e353eaa35bfbca14cb45de1c80f73bf1","lib/libwinapi_evr.a":"488b674f133d784acd30eb724f364f2ab95967be96f5644084d8909f573178ba","lib/libwinapi_faultrep.a":"a95e078bb07fe9e06a891013bcbd55eaeaba2fd08c79554803cd7f83e3a294e2","lib/libwinapi_feclient.a":"ca0dae89be31ef2cc4da0256882fb7807ef6b73d87eedd44a9199b85c19e1dae","lib/libwinapi_fhsvcctl.a":"31dd77b721e1f7e45231538d587984a2315b7e2881ae74ab078107f4ec344378","lib/libwinapi_fltlib.a":"75bc50b732fbfc074dc20a6807400d007697840414402d44f7efd8b6d80c6c3a","lib/libwinapi_fontsub.a":"32428decf64e4fc27eecd8f251ccbbfb4d5141f652f879998dbbd7bb259265ef","lib/libwinapi_framedyd.a":"bb0ab50255f033944d8193fd470344c00b8f780e37fe96a56b5e801debb2241a","lib/libwinapi_framedyn.a":"8f6c42e8c79b4e19e214136706aa4f8e45f89f46eeaefce9d3f1f37637dbc451","lib/libwinapi_fwpuclnt.a":"6f06cca6905ce91d0486dcfc14c3d855c8b04082e0d3b86995a4a54a408a9bea","lib/libwinapi_fxsutility.a":"86e20adbecb1ff711df062069687e1604ce8eedd8dc3e08e63610b60aa2e50d1","lib/libwinapi_gdi32.a":"090e67291731b23a6d72d905cfd2638007158413beba4857d822a13a99f90cbf","lib/libwinapi_gdiplus.a":"d74fc74cd1d29c5cd280a7e95a5a4d445af7bd91ab22641f3ae6299a47d1e3e0","lib/libwinapi_glmf32.a":"9906033164f6ea75e0f04794b4999584713a0fb368e026888a66650b10b99460","lib/libwinapi_glu32.a":"eff06b5b5ade0f732f52a989eb530bb4c40113272297d481187e554dc4742fdd","lib/libwinapi_gpedit.a":"a5dfaa48f7e5119fdb3aeecba3f054c3cba02bcd37976438b3214a6b383b2f3b","lib/libwinapi_hbaapi.a":"866f67233b72526add51607300951699f3898f89d6819b4aa17cc6632056588e","lib/libwinapi_hid.a":"153a556c5c938350af4a2bc4df1f365292450fd8f8587c94a397e9e2dfc10f68","lib/libwinapi_hlink.a":"2b9768209993f82cc588b9c5747834bb98332e5e2c0fe36360357e74b6477438","lib/libwinapi_hrtfapo.a":"737fab6f539c737dd6e3bc954646cd0544f779571832ee210bd6d480a2fe4a61","lib/libwinapi_httpapi.a":"06bd3ad3b5c053c25068b3a7e94f5e7f3d78640de81f2aa1ff47405eb39ce0d1","lib/libwinapi_iashlpr.a":"cd2f12894d85028c6d4f10ab126ec7e5232625ca9e5e5970d0afce9062193ece","lib/libwinapi_icm32.a":"fcfa09d72832a65d156b2bb368643cf8aad7305e503cc2a78f700fbda0585aba","lib/libwinapi_icmui.a":"b27fc55b65dd7e25ee29d164c2d419917c9d9051ed8d6ab1a014bfb44223c1ec","lib/libwinapi_icuin.a":"597ed6d86344cb2edebb6fb49a289a8c57bd2b7aef461a82e59b12fe7e7ca06e","lib/libwinapi_icuuc.a":"813ec6598db79798351b2360106b874e74891c864d238cbc2223ddba2c445a4f","lib/libwinapi_imagehlp.a":"052721c9e7c20fc720f99440b022ea8078423541e62c0ea29c977caf5c442309","lib/libwinapi_imgutil.a":"6c7e2e560c7af9de94e1564940cffebc461879f0e3ff584cdf7b455cf721d529","lib/libwinapi_imm32.a":"cd915a1cd725b687422819b3c0ae2ce44b5c7888464ff0d2ff1676688adfd60b","lib/libwinapi_infocardapi.a":"4f18800709730f89f173de9326d81d06e2073aa27c7baf8311cd7f8e6d5dd667","lib/libwinapi_inkobjcore.a":"33e0db4e11e77ed4bc6114d45ca529939b3b77bab57cf87118c9c76e6bc02cf0","lib/libwinapi_inseng.a":"d195b7f2386197d31441b3c38a54984a645af9f1bdc55478ac0203b69c694573","lib/libwinapi_iphlpapi.a":"744eb5929f23063698b334b0215366127b56355245cd13b54ca3aad43538a782","lib/libwinapi_iprop.a":"0fb9770f187923cdab0a3651073ca541c1fbe73235648bd5de294b16416a84eb","lib/libwinapi_irprops.a":"23fdc1e1a97503d3ecb0e80e2ec2dd26b976a81f314d4f68f17fd7ae0baea612","lib/libwinapi_iscsidsc.a":"6eb819c654e9e5fff54eec5bb8a92b39d83e99735279ad619d21049ba021a66c","lib/libwinapi_jsrt.a":"7c763e81a81b50fa22fa4ee8ee7c0aca94a5b4cd5dd1a3ada92a0af9a92ee191","lib/libwinapi_kernel32.a":"0388f0d48e65b04acca610f1810bef501c45d73a2262214d78ef849dfc01587d","lib/libwinapi_ksproxy.a":"542c343abc37f44ed008029b6225a45a450dea4dd44914e2f3f31b2b776d42af","lib/libwinapi_ksuser.a":"66e034242fcf78b7855ee275a55fbab76f7601b20bdc6523792f5d5728685d32","lib/libwinapi_ktmw32.a":"cb3ea9233bf46cbf14b498678af82aa5b3334629babda943ae145d35c9b9a4eb","lib/libwinapi_loadperf.a":"58ad561fcfdb9cba315222570c314e2f4ca35b385a4d50495a44ce367552b1c5","lib/libwinapi_lz32.a":"c67ea712f48e6f585fdbaca006a1a5735992d341f14f368f7a0e291ea082bdce","lib/libwinapi_magnification.a":"dc6703ab97d304c5382be388b985e22b2e1b46f32b3b522b79d7efc1935f1709","lib/libwinapi_mapi32.a":"886643d423fd9dbfb68f33cead4f3b170eb1bea241d504545dcd3e8e573c6fa4","lib/libwinapi_mciole32.a":"b698d2060864952d2bf8014aa372e664cbbf198e893768cd6739f1469fa3d149","lib/libwinapi_mdmlocalmanagement.a":"9b0c642332bff843e4ab02eec8cd00d5d08c7d2d1047b203b022601ef6785760","lib/libwinapi_mdmregistration.a":"065d25244ce5c866a3489e54b8b7772d8a1e92cd95ea39e13b838ef2d6109c31","lib/libwinapi_mf.a":"136eff680a3ed1d47826286ee61a0a77ee7776b6cbf78751ae4e7683dddcf23a","lib/libwinapi_mfcore.a":"8d086314d9f2a5d8e1facd389304de147c064b428874ec1834adebc71581614a","lib/libwinapi_mfplat.a":"f4ef284f7c5acda4ad72ea27389485b386fe1f76405981695d4387323235a6e2","lib/libwinapi_mfplay.a":"5db7d76cd8a3d4689381055685b4d2d9b03ad1e346de02fa998dd0c46d630f8f","lib/libwinapi_mfreadwrite.a":"ce1ba6835835b16445a2dea51cb8957d1fb1fe3f26c2501c4aedacf40eed2d13","lib/libwinapi_mfsensorgroup.a":"641454e135aa030f835088d98b42c1b5ed9ca1d605fe9f30da94de9bd7624e7c","lib/libwinapi_mfsrcsnk.a":"edc08719f808d2d56157647e991573222112856f1e1d26f6bc91e00bfdbb302a","lib/libwinapi_mgmtapi.a":"9605a3306379c2857226758b2feb1bfb9db5bd6ddd3c959eac818b633438c1f6","lib/libwinapi_mi.a":"2a0dca38bb4338a37c77f5b8dd964a33392db42b8d2c7b91db0ed9c3443d01f0","lib/libwinapi_mincore-api-ms-win-core-com-l1-1-0.a":"0a768dd0f0cdfee293589a8d63e9831a7c0f35a3e8d21a537ea6860f924769f5","lib/libwinapi_mincore-api-ms-win-core-com-l1-1-1.a":"edbeed560863d20918f95425c1ad2f2036bd0c638cd391b13685049b34761e10","lib/libwinapi_mincore-api-ms-win-core-com-l1-1-2.a":"b9832dd7d7405f7a10170555afa6d34bd4589eba680da1e4e9418ab3e5dffc5c","lib/libwinapi_mincore-api-ms-win-core-com-midlproxystub-l1-1-0.a":"6dfc0a2c4d89b578d665551a7f4edf4d1f518821e74081a3cbcd79e10eb60f4c","lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-0.a":"ddb31dfe647ed2edbbc9be435aefe222aadb9742af5986928c7d439dbd2aaa43","lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-1.a":"b778aea784de837bbc7c5909cb30935d088aa952ff6d032ec14ff935cf6fd561","lib/libwinapi_mincore-api-ms-win-core-console-l1-1-0.a":"69f925fccd8af3f57b671bf3a0df5766d9152044ee1e7417b6846241464ae914","lib/libwinapi_mincore-api-ms-win-core-console-l2-1-0.a":"8cc653f70efe3f0429365811f1b135eedd70b07c485c6483dbfec4d3faf25b22","lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-0.a":"fd818a070d14bb364d6c880ea2ff48ccb60e63739eb9be6c86c5f54d2ad000f2","lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-1.a":"dd45c010f178a8b81c8c6c778d9e59ff2952b2cfd37caca1060b4165637936d9","lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-2.a":"cbadd8bab30baa53143b4083ab0b51a4782585eedd34687840ac5e7b409ed0bb","lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-0.a":"a6e126bb0f223f14951a2cd6fefc3724c94936901653d2f4054bb37723725aad","lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-1.a":"7fe5fb93c165948f5c364d856fb247f028d001990532fac5e738cf7952e6d86b","lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-2.a":"3881a5490d4fda0b41991ed9205b536cb2520a79855599168bbe2520612a6958","lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-0.a":"ec0a01289b7f908e2162791e2eecb2ef36b93ed51921ec70ff2ea3231551202d","lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-1.a":"6f2e56ef3a7715a5d2916749b87004e87f483be10f847c9ebcd1bb983cb46638","lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-0.a":"05c6265c3d0a1fdfb345cbdafeec960ead6595fe1b0d065131dd43fd8adab78e","lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-1.a":"d02379934fb212ec84e9df5d3b0f21b7728775134509b55b595a3c91f26d03cf","lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-2.a":"682afd441ce478b1b7792b058934ef98690e096f3d944f7b2a52bc1158c021ec","lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-3.a":"fa8ed8f3f501b8d87437fd1689edbc3a1b3ca5f87b007e30cb998249eb03c1c7","lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-0.a":"406eef3acd78a7d0ed3a882a72dd5e3ecccdebaf72de13a376288525c8b5b67e","lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-1.a":"aaf79b1f6cdc1078564041ac49e438f2603aaf432b8cfc219190994c7d23b37f","lib/libwinapi_mincore-api-ms-win-core-file-l1-1-0.a":"63bebd6f1cb8a22715e72ed90ee2b5ea2d3b0eb400273775de4a6bb1533eadc8","lib/libwinapi_mincore-api-ms-win-core-file-l1-2-0.a":"bae933701c0c334170e98e8d495ed06de8b0d8843cba538ab63e4f66cc27a47d","lib/libwinapi_mincore-api-ms-win-core-file-l1-2-1.a":"ab106bafb84360fa31fd4326d5a1aed6cbc694682ca0997f6e780d43d0422505","lib/libwinapi_mincore-api-ms-win-core-file-l1-2-2.a":"810cc1400bd09c037ebcead50b625edc80025ae4325d652af14efce21c982d3f","lib/libwinapi_mincore-api-ms-win-core-file-l2-1-0.a":"1732b133cb5e7f1825546daddeccfc9848575ba92837d8fe420c06015aca4bee","lib/libwinapi_mincore-api-ms-win-core-file-l2-1-1.a":"d083935f4238714d013811a5c064b0fadcffe770e37c89054fbd8467b1b28c2d","lib/libwinapi_mincore-api-ms-win-core-file-l2-1-2.a":"148e266b040b29ce152a4d7627fea8081b30df0386dcf1d88be4c8bd0ff477b2","lib/libwinapi_mincore-api-ms-win-core-file-l2-1-3.a":"076f2e6cb81e13f8e81df3f59c8c3b7bcfb1a1e954f3ced5684e925100e73ae7","lib/libwinapi_mincore-api-ms-win-core-firmware-l1-1-0.a":"b60822892e24eca9a137c60b9919f6fabafd797284736e1033ea468502bf20f7","lib/libwinapi_mincore-api-ms-win-core-handle-l1-1-0.a":"66714b765c428ba3d48a87cb388572abe76eb370a726a201fee6ffae6b58c58a","lib/libwinapi_mincore-api-ms-win-core-heap-l1-1-0.a":"c0e31d6801d3ab01cbf7150b3cbd9b1f0d3de949064ac1c91cb315f199c9789c","lib/libwinapi_mincore-api-ms-win-core-heap-l2-1-0.a":"fe494eef68d5369999f3f955e543033ee66bddb10b220bf6752a9a1152d4e7ed","lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-1-0.a":"b7655e26bd63619c3c441fc8909be9f7901bf66e68ea89744ac1b6bdc1bdd888","lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-2-0.a":"0c08a4eb795089082da5f02100855804486f6456fc6490045ea2be6e8f78ffb6","lib/libwinapi_mincore-api-ms-win-core-io-l1-1-0.a":"f1ae60c245a584968603acafcf39291df60575ae54a6af91346f3cd55dbe60c7","lib/libwinapi_mincore-api-ms-win-core-io-l1-1-1.a":"a3c4ae167b393d11c804dfe1023011bad0355ba64dd1855764249ebd09d9546c","lib/libwinapi_mincore-api-ms-win-core-job-l1-1-0.a":"e9fde2a40ec9b032fc4a368e8c20310d6381cc7cb75461c7f765b3256723b48f","lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-0.a":"90380759dce4dc4f4d79f313313883b79ad05dcf458ca6ae707a4c5135fc62b8","lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-1.a":"aa6b6648ccd5ed03b82f95ce236f0e515b3370389791f32c768ea5b1e9cd698b","lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-2.a":"9f8425260a2ea46de8c1ac47f3066cb9034320713d6c0256f600e5a68fc9025d","lib/libwinapi_mincore-api-ms-win-core-libraryloader-l2-1-0.a":"b80d4fe131e88cd1b7aff511f9a8801a24e8979d36ddbefd6af38e90c8b0f340","lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-0.a":"2b8e6b1e236d1446210ae3c04478333be3b05affc61f2d87f79cc746cf3061b7","lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-1.a":"9db8557b6d16de78ddb17aeda7a9ee53f5bab317bf8d6eda670af140613cea41","lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-2.a":"cf24d229ed67439ba165ca88690733f6749cf96e6fc3389101744b213ce329db","lib/libwinapi_mincore-api-ms-win-core-localization-l2-1-0.a":"4a27c7bc16d1457f4958c11d811356b2ca8031d1294b49b0403e956476f649ff","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-0.a":"bba88f3d4b15ebcddea1d24e5960e4b672a1ba98efa1aa4eea80cea6497ddba6","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-1.a":"887438b3d8e0442cbc7249ebd56858914393aff5a450343355c56d2c58ec83be","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-2.a":"9f3dab5af0070cd7803478647dfc1a302613af901bdb901012def3869e59ad0b","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-3.a":"e821d0e25650112acbd7b4eb9e386a5a332328035b830f5cec134eacb0c86865","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-4.a":"0db1359bfd1dccb45542ffd01cf506d3566d5c2373c3cfd2072beb3c1e6458db","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-5.a":"fbd3c250b3903d847f12d6b532f42d55845a90f98d9ae824b4f6abea63c157f2","lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-1-0.a":"d174eee6bea84eef6ec5ae42bd6b22e238914d9fa5c78debc4dd0bd1f77d3419","lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-1.a":"93055270f2a4f829c54e6da5d183488c6e34b2f908a86c1b7b4f88cb2f7e4caf","lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-2.a":"520bbec5c993575fb8bbcab7f0e5324d1cad7b25b02ae9e9d4c2e1a37efcb0b9","lib/libwinapi_mincore-api-ms-win-core-namespace-l1-1-0.a":"3adce79118ad0d94c87d593ffe1d27cbe119671dc27e610d1d8376b0d228176d","lib/libwinapi_mincore-api-ms-win-core-path-l1-1-0.a":"84d2733438369fd440a732bb3a253a45f36489a3b91dbbce8bcf2adbc1af64f6","lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-1-0.a":"a769055d3f0d668d259b201a7cf7e5eca2ddc660c356abd3f2fd0e85cb4b2f72","lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-2-0.a":"5fcf5cc4bfecb5f85d3724f6ce0efc16ebef41cfc70afe7abcfbd18741d4ce50","lib/libwinapi_mincore-api-ms-win-core-processsnapshot-l1-1-0.a":"2de13a8f3b4c2ee0a255979e098c20b2a887b579aa14025d4b11af1462137fbc","lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-0.a":"6b41760bf3765dd0f23cc2e3ec7e47791c9fcd22b91bab90d6a4dff5b70ce7de","lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-1.a":"daba67d5d58df11f17ab5ba338527d9072b50a5c993d7dfac7cf9dfa00f28252","lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-2.a":"90ca7e44d4348b1fb7f748bdd555ebd46a13a4ed9ca5c2fcff013759a99d6bb1","lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-3.a":"99b6b7d260adbb22cfbde40c0cf4861687683fa0d466eb987c2fc45bf034dc33","lib/libwinapi_mincore-api-ms-win-core-processtopology-l1-1-0.a":"f284ac99690d0dba0c71a130ba2b76c7b3e8613c39a4bb24d3950ce86152dfcd","lib/libwinapi_mincore-api-ms-win-core-profile-l1-1-0.a":"5353045a09d71f476ebc7b5bfe997f771ed9ea5175aad5d71349fd0d9b1c82f4","lib/libwinapi_mincore-api-ms-win-core-psapi-l1-1-0.a":"3c68ee1e3dc7d727cfe7a59713388e15caf6c0bc815727687ff85c9e94fe938b","lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-0.a":"a41d662b9aa2b75d2850a4767df778c04dc2d84a6df30bf1f54bab12ee575635","lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-1.a":"399dca0788789249e60b9dd864d71d8492bf2fb4a40e3b7c7f1ef75e90e07a37","lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-0.a":"5ab31736b264962e259667cbbc562f3806a565997da9f6a4a856ec61b45cba35","lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-1.a":"dc73efb3037801cb681734dfa2bde7df449234f36cb8d96d50c8f717f20b423d","lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-2.a":"d5a4ddca6419ef157f40bcd53e586246f9ba406792c2099bdd018ff007992c68","lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-0.a":"0f9f5987025d2a73d7bbb781bf5ee107a9a69d334ade820e762ff825d81e36a1","lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-1.a":"6fc2f7bcd71a503b86ca4280100db839fd7323aa54a4213626d8b39d45ae98ff","lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-2.a":"89eefb0e50e7742bc6449e92964588c149eb709bfd66e1c650177ca7e57abaac","lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-1-0.a":"1e1d445734682622d17a01c68878c0e701394fb60b67ba5ac9048406a870bb86","lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-2-0.a":"00bda2cb8e87172c51f64c9e561e083342cffa5e25f47a2af9cb3ce647063aea","lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-0.a":"1be72599a305d240d3db2a5b2d14215dc6bd7523bb50f51581318c9a8142d9a0","lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-1.a":"8cef705b7c111f4b419b1e3501fc8238ac8fb20e23e30a58ec8003a6841822aa","lib/libwinapi_mincore-api-ms-win-core-string-l1-1-0.a":"d50c3141fe9565a3d6840032fda736e661e5df6104c83747666cd48e02072138","lib/libwinapi_mincore-api-ms-win-core-string-l2-1-0.a":"453e9e4a96badb784e0d78c034bd6c762b54c9fd3a868337c5ee9b867003f889","lib/libwinapi_mincore-api-ms-win-core-string-l2-1-1.a":"396fc7787a3f8ed7229f764d7bef572e03ed177fbf240281e9feee523808803f","lib/libwinapi_mincore-api-ms-win-core-synch-l1-1-0.a":"7fe7823e6d066aee13460c2a29b7b1d87ac50c3434c03d178eb251516660becb","lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-0.a":"13d8aaa16280287bda16a94140174e0f120acdd74d5ce9060a1af6258bb4e60f","lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-1.a":"5bf2000f1448a7d9769a456262eed663762a757ebf9f32dc239044213e9b641c","lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-1-0.a":"e96433e23e06f4bb679d6597611b29f7b5ccbc5e2017d1cccb9476611f8ee7ed","lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-0.a":"d726f97fb99d6afe1d1b571531a91acb651ba72d6c5a88692348502c9b69fe9b","lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-1.a":"cb3bf9f785a332aaf67b35671dede4f0c5151fc01ee12ec2c24a1d065e201615","lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-2.a":"e14e1da2967718d7af259cc05bc92690effce83c2eff95de28201c9441df3352","lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-3.a":"c7629e320ce40ba12d269f5d0a0e7b42c1c77c247a54609842bc935dcc289481","lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-0.a":"7e48665fe920c9274ad9ad32efebf2cdd7c494f4e02a51a94b5c3c1fee37953a","lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-1.a":"3933565c0fa91f18e579aa50d13f3957983e785d8fc86cab1ea4e0c32004164a","lib/libwinapi_mincore-api-ms-win-core-threadpool-l1-2-0.a":"38978f8427f5ce000c303ef76be6c8c3b53bd77232f09d57c1fd09cca3b10a96","lib/libwinapi_mincore-api-ms-win-core-timezone-l1-1-0.a":"deb71b00625e45b52c77a86b20b6ded210231cd8393f408aca36b53f87d14777","lib/libwinapi_mincore-api-ms-win-core-util-l1-1-0.a":"39430cbe7717727cf39c10d6daa268b2c6d2bd4edafb321aa47804471152894c","lib/libwinapi_mincore-api-ms-win-core-util-l1-1-1.a":"023c1d785eb7eb05f68b09cdd4e705f726dcfe12132ba591ecd49a978009392a","lib/libwinapi_mincore-api-ms-win-core-version-l1-1-0.a":"e3231d5b7ed82b40539d6cce58770f486be5e540e1b34074fbb71dc8434ee684","lib/libwinapi_mincore-api-ms-win-core-version-l1-1-1.a":"b56a474c026fd90945b5c87ec250715abc675db7efbc9de72f05e2b81f8bb8e0","lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-0.a":"c1bd6e9c3070c8bc1ccec1a070fb0fe4845e26f2f9319ef8d5ce2f296eeef376","lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-1.a":"d4c9658171d702015fe1f09d189773d08f92287572ff60d9c9b5880818ed6a79","lib/libwinapi_mincore-api-ms-win-core-winrt-l1-1-0.a":"8bc675d80fcf0c76eabbaad929696820993e8033039681bdf587e42d274bef0c","lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-0.a":"f4f83aa4ca2fa88a9e5f30ec1a249bc3345b113b250193b5516fe0d363221b12","lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-1.a":"96bc5168f805d40107ffcfb3240fb91cb0cc8f543f8d11fc2f44ba9b68d016f2","lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-0.a":"961ea44da0db20c1fc5fc3b55c38ff42a21bab671e8f3c28718a81ee7d0443cb","lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-1.a":"d741c43543343760166a79eb8ef5053f5bd3722d9b0018130352e187a3246c7f","lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-2.a":"aceef78b2dd9a72d3166068015a5f3df6697701ff7044524af691a209e466eea","lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-0.a":"9f67b5ecd99ebf53c56456d6ec1e8a9c8985417a0dc51b8be68980a1b8a83ae6","lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-1.a":"24ec470de618f9dfc426e450a07cb85cab05235d81077f3477f1ffe7ce0c9e5b","lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-2.a":"4399c090ea8eaeb449e06419afc8287ed6a56e44f0971e25d4ac6b9b0b216f4d","lib/libwinapi_mincore-api-ms-win-core-xstate-l2-1-0.a":"5a91eb1a242a21befd15584e5a4741e25d83186a42c58aa921630d2937da1bb6","lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-1.a":"cf9810fec10165072812b8e31a3a951e73be581720ed19a562ad82cf465c056a","lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-2.a":"780cfad93f3fc5e95ebec5181045ccb1426bc385253ce2668c483efa39c1b404","lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-0.a":"d837d7329ed6767d0487c814916fef36335a460fe1f62fdb85b46d36747c8d6a","lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-1.a":"3f85f22ca21b5df8e6173522085649e67ce84da16b77e9cae3d80c9f0e3ecf66","lib/libwinapi_mincore-api-ms-win-eventing-classicprovider-l1-1-0.a":"22e024a0968fd319b5b65df792f93e15116b50575911c0f7f1502dc1d8c70bd5","lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-0.a":"6cb298bb1a9908a2912c331e19774fc19bf80ead0f4cb63c3fc659f79035617c","lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-1.a":"2c6898a3d5bf294ec96de606bc608827dde28e3d3a185b741915ed9045564dd5","lib/libwinapi_mincore-api-ms-win-eventing-controller-l1-1-0.a":"a39ed9b36bb3cc0552d79ef532fc7e3cedfd67e9936e8bc08192b9c0aca2a9fb","lib/libwinapi_mincore-api-ms-win-eventing-provider-l1-1-0.a":"a27242e68654421c9b4dba80b1ff3389854dcf112258cbaeb20e5476a125d752","lib/libwinapi_mincore-api-ms-win-power-base-l1-1-0.a":"d136c5fe2c00a2318b5417bacd8eca2497e3d2446fb17e88af179588110f59ff","lib/libwinapi_mincore-api-ms-win-power-setting-l1-1-0.a":"5f15aea882f82ee5dc2d8d754a362ea04c5a4f862f03a00f7e74b0abbae984df","lib/libwinapi_mincore-api-ms-win-security-appcontainer-l1-1-0.a":"db86b02c2a0aff2984244461868a6b071b98765f4ab0b51b82c9e041eecb913f","lib/libwinapi_mincore-api-ms-win-security-base-l1-1-0.a":"2c5d63db76b846b908ce0b2d3baf783c140a536030d0baf7c658ae11b3fb1d1b","lib/libwinapi_mincore-api-ms-win-security-base-l1-2-0.a":"34f3af57df1e30cdaf70db34222df8e00ca72865be76b7242304aebb69c75465","lib/libwinapi_mincore-api-ms-win-security-base-l1-2-1.a":"8f2a38ea004085ebc2a424842ba7bc2c8ce9b15856823ce3cef74b165be9a06a","lib/libwinapi_mincore-api-ms-win-security-base-l1-2-2.a":"318c666ff4a8cd75cecb55526d5b42215f7020562c8577aa01276372e4ff213d","lib/libwinapi_mincore-api-ms-win-security-credentials-l1-1-0.a":"a1694e7a1b3d1a3fb5b22f93f4c06f400c017fed99e137521ca02e263b70c829","lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-0.a":"a68cd2ecff6a805f1f85200d5c2cd90e5a89745f8a78e57bfadb7442723cdbf4","lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-1.a":"add16314ad45f91498b7a7c2da6a34c6475455c0a866f7631b8ca5326153722c","lib/libwinapi_mincore-api-ms-win-security-sddl-l1-1-0.a":"c9eb0c4a5b7350b06e37638dcb4335cf7fe77261a89ea1a90201d066f85b1d1b","lib/libwinapi_mincore-api-ms-win-service-core-l1-1-0.a":"81a070d545cf9f7f9f8923c5de7368276fc061eecba8535c5437632d96f613d6","lib/libwinapi_mincore-api-ms-win-service-core-l1-1-1.a":"3bf1941875d31d4d2c7095647d366883efb613c23a983695f38de69905e22a0f","lib/libwinapi_mincore-api-ms-win-service-core-l1-1-2.a":"13ec744c7560f2a192b50b5bf23ed4faa59325f1048377f7a9844a47e2087dac","lib/libwinapi_mincore-api-ms-win-service-management-l1-1-0.a":"b8b7db62594b714406368918089a48868ca3b1cbfbf5e8440911a13b5bf28594","lib/libwinapi_mincore-api-ms-win-service-management-l2-1-0.a":"2ee6f8b431124f281650c94b544fd734c7719071b491d7b0fafaf71a9e1fdbe2","lib/libwinapi_mincore-api-ms-win-service-winsvc-l1-1-0.a":"16a711568a8a1ee771c8eac1508a27605f240dfce72e9162f620474c3b186ffb","lib/libwinapi_mincore-authz.a":"e99db6195035386f6848a397f465d23201e5f6c132901ab2e29b179467fdea7b","lib/libwinapi_mincore-bcrypt.a":"5f4d9f4146e24ac50ac50e846bf62088f99d23b5e55cb03e6a32661057822fa4","lib/libwinapi_mincore-cabinet.a":"c1b3263b233e95742a438e628644a7ab4014ff4e3b01547850d0832f4eea2674","lib/libwinapi_mincore-crypt32.a":"e84423856f2d7b5dda7dafd0843c4d1fdfa656f1b61677bd68edfcfa3fa84658","lib/libwinapi_mincore-cryptbase.a":"3566bd4fa7a9b4f441a6ba4af984ac0567e024d01efce922b503176f0a56ea97","lib/libwinapi_mincore-cryptnet.a":"92a5d8dfb436ab9792312d397e98d91f9b95771af48cf925fd3d867ca73d2823","lib/libwinapi_mincore-dfscli.a":"da814011c527a253e71a397b76595ac7a387c86c1bdfeed8e01209a260dd4fdd","lib/libwinapi_mincore-dnsapi.a":"14a2b0ceee12116cda15871aa7e0292c35452d7e6406a51e1708b4c8484ca5df","lib/libwinapi_mincore-dsparse.a":"11cc209fd1b87a1b2a68c7124e1d89da2a4221b591cbf6ce67e338b1183baab4","lib/libwinapi_mincore-dsrole.a":"61fcffb3afee81be3f3615d9ec09e875d5a5529c2f63c182a59b6c6fcc529158","lib/libwinapi_mincore-iphlpapi.a":"835004f7cb51eca876d2f85bbe6ad43260da907e10b03e019c188ee951de1fbb","lib/libwinapi_mincore-logoncli.a":"e5dc889da62fc4baad78290998d9bd22b843e7cf119fd7845c7b9e9fe1a77e65","lib/libwinapi_mincore-mpr.a":"dd07ae245db6f88c8d29f1397b0df0e9c44b2422be551e16dcb01c5a895636bb","lib/libwinapi_mincore-mswsock.a":"f48d2a370a9d62d46cf272a08629c3713eff8b9ecd2c16052e1cb5961f10a0cf","lib/libwinapi_mincore-ncrypt.a":"9c37a0e796b74654ee8ff25ae005ffa314a845255c74ff9e2c491fcfb8ef321d","lib/libwinapi_mincore-netutils.a":"68ad06d0fb08607b070f053286fecfff083ebbb456d631b209c62db4ad117134","lib/libwinapi_mincore-oleaut32.a":"fcec9caba52ef935cc1d0aa3f5e05aa56851446f2e6a864a7c152d4ec1afd978","lib/libwinapi_mincore-rpcrt4.a":"c1e4586166db2f2a082ef1c0018c6739c58bd343962048aaf4dce07ccc47ddd8","lib/libwinapi_mincore-samcli.a":"f5063f8c04cccf85db4782020c4cb4642e66850a259f7d63ac1c3d08909a827c","lib/libwinapi_mincore-schedcli.a":"2e84730fb110f1a0c83756145ac627b80450f847a64eca8652e5ca3044c5d5b0","lib/libwinapi_mincore-srvcli.a":"a79012855d575dcc1330d2619778b26e1956dc3e7bc0f4b3684e178a7be3088a","lib/libwinapi_mincore-sspicli.a":"5541c31892701510763c94b9eec15348a3886c7f6704f7c761ed759c2782a539","lib/libwinapi_mincore-userenv.a":"f3ca99855c0220cba5a1ff522d059f88ce269ea9d3726badafd73b40e3d44883","lib/libwinapi_mincore-websocket.a":"f5ee7e537a4f7d7c1bdafb5287aa437d5411010b41fb8a8eb6205b4aacca6458","lib/libwinapi_mincore-winhttp.a":"04a5911f093e885a5f14e0907d5ab3edbcaf43b4b060d45216ea435e52b23fed","lib/libwinapi_mincore-wkscli.a":"cbaf2dbc36dc6d77889dae85012523d40aa755f1489c4687eb7054ca6b6f8048","lib/libwinapi_mincore-wldap32.a":"fa72998300a3430697b64b3cbe4bade361ac705d5dc429572e1259e66c703eba","lib/libwinapi_mincore-ws2_32.a":"9e3911f8a7bff472e039fd91fe9acdc181aed3bde9a902ecb739e56ad48c699e","lib/libwinapi_mincore.a":"6825a9caee041465fd378b5107dafca1ac6cec81e60f0de331912985da0edbb3","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l1-1-0.a":"753630af44454ec3c92ebfb3c29d85a9590118608a111bac7657f0f06e36ed80","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l2-1-0.a":"f40742474b39a3aa908e3c15dab78de4f73fde4b4ed9ff9cc8f38a4a3e6bb776","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-normaliz-l1-1-0.a":"521d37a4d77b558db157129ec34f1a9cec364f82021f7f2c9a4c42ff6d9ea8b5","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-ole32-l1-1-0.a":"21afab5e6b411cf9f1b8839c352314229aa89af03a16cfe9d1428ba0a8941ade","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shell32-l1-1-0.a":"c66675b5475c93e63dcbd4e3001a0e7ceb41eeeba74e3619935ba27c7511d59e","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l1-1-0.a":"ebc30c785e96e1b2b802ca1e997fd1ec6966adfc150ef5b97c761f8aa49b7359","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l2-1-0.a":"a5c180c4f39d4922449fc20bc72f1cf8bd30d768a56c00b12b19050ab52ce99a","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-user32-l1-1-0.a":"f3aa55bc305ed82258dc9d21fee4395f85a3aed1de0db1931817c3e75fc70f81","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-version-l1-1-0.a":"2f0fceb87948246ec375e2496fea888e2c99bddc0b953a06c953666ed3082688","lib/libwinapi_mincore_downlevel.a":"3d70f323b3fca7aef18d833b72ca3fbe60d376af109a1b4a919e6bcec22d860c","lib/libwinapi_mmdevapi.a":"2d79710fe620fd4f3ed41becab17a6c4923fcd1c0929700fed0d18d6d3514e02","lib/libwinapi_mpr.a":"680c8e016f20cb6e22a2849368e55643551f0206235b668d3893fa42d2144090","lib/libwinapi_mprapi.a":"3bae5791f784d3bf157d27c021c8e594964d4651ccef317822d4b2a17b9a04ee","lib/libwinapi_mprsnap.a":"5aac04f6244a965e8c3fffdf28de78a09fd9313c69b9e127528f174eacf057ba","lib/libwinapi_mqrt.a":"ca0c39e4301366ebede9384432054b7bc69cbbb0714af59c94ccab4ded35ca00","lib/libwinapi_mrmsupport.a":"4c877ee85c1c91721983488eb58ed617f672aa007e5ca631075889c845d95e8f","lib/libwinapi_msacm32.a":"93d5738ee1d7ea8239408436b074c43d5fbfd8f459543cb730d3c79d21ef59a2","lib/libwinapi_msajapi.a":"645e84f8175f03112007c3af7b06cfe11962d8b8dda6267ee9de8239a9543019","lib/libwinapi_mscms.a":"47fe5dd1a3a5d7c3c262701341a8228c3bae0a5e7aa132a58d4e583032997054","lib/libwinapi_msctfmonitor.a":"9fd55476a28cd5fb3329d79a0c4876222187944093fbdeece837f0123dead523","lib/libwinapi_msdelta.a":"037e08c128576a4801ebe10d5399b5932698e4c50e0885e9b6555b3f97d04afe","lib/libwinapi_msdmo.a":"bfcdeaeb2ebcfacf5d77c7985b4e647601bb018c737f8778c37562dae755bd96","lib/libwinapi_msdrm.a":"66f327106d29dadebfe6263fa5f734a3c3036d989e68cf739521a5ff66bb06b1","lib/libwinapi_msi.a":"98e5ea9ec823ed5e1b44f8732d5a897ab6e5d7de1d87411d2d4a8ae6ee4db5fc","lib/libwinapi_msimg32.a":"2f2d8c1fe1cd2fcc9e0689210e8a992423e32ea50ca030f92dab5f38e28377df","lib/libwinapi_mspatcha.a":"bf373ec37fe1f869b803cae997cb9d1304e9d2014b2f36677937f4adb5728bec","lib/libwinapi_mspatchc.a":"2fef8c9ec3f4185c20d4b8c20bdf97e97c5a890b874f2e2afd927e374079e3eb","lib/libwinapi_msports.a":"bf82dbc15ac2c02eb19e32b9dd6fa7ff840e85bff591ef63c69b3f4cf1fc1aa3","lib/libwinapi_msrating.a":"45df5b0e0f916e71d591195d6e896f21075d3ee2d455bb2b6400c0c050c44453","lib/libwinapi_mstask.a":"e5722cf20ff19d01ecbad869a1f609934e17b9ae350d424c5e3c5e73d5bd779e","lib/libwinapi_msv1_0.a":"62f3792e17ee38d086f544f0e750c5a1f537b128281c1ac4f5e687e636977e59","lib/libwinapi_msvfw32.a":"742e7b83ca4abbdfe708e1f5a5028bb033b3bf7c8004f8b7b9ee5dd0827ffa3e","lib/libwinapi_mswsock.a":"fdf2482eb3b9876986d8fb8b76d98da74f2abe2e65b1ddbdb9e76a3a2ba9faf6","lib/libwinapi_mtx.a":"97ce797761704ecdb75986c0cdfec06cd942af626da3d98ca614fe90cf1b1783","lib/libwinapi_mtxdm.a":"80f87abded3d644a60c25ccb693189f785e0eba3d831d97481ac7b91970da6b3","lib/libwinapi_ncrypt.a":"64b382c756d3047a29c5cb9af53003ea639c2f216298b2a7fa867eda4147c932","lib/libwinapi_nddeapi.a":"3c316dd45fe6bb0d26a6bc18d0859654bc8ecf7a2115d0623fca8dfb3f892bf3","lib/libwinapi_ndfapi.a":"618fe36ac1a948165c197df523696e4fdfb7cbb40da53c68eb349daafb947124","lib/libwinapi_netapi32.a":"bad05df64806485c12fe425b62cd56dca9757195db23383a28f2e80a3033f0eb","lib/libwinapi_netsh.a":"93011663fee375bd21bf79955495acea760ce0982da464983ce741afc94563ba","lib/libwinapi_newdev.a":"4b4c90a7ac3abb42db40b26a4c02b4eb58ae62ff3cd58af1cc15d4349a95bdbb","lib/libwinapi_ninput.a":"ab64698e33cb680fbb68d70de33615932dc10c16d436c8097dda7ad0cd662da7","lib/libwinapi_normaliz.a":"d6feb9a233918d62f9454a71a1b7984182bd243491be1729d4f75c9e4148ad7d","lib/libwinapi_ntdll.a":"1592142cd1e0bb1d7a67e4dd5aa6d08317db172674abe24e00b4562d272fdb35","lib/libwinapi_ntdsa.a":"eac08fe7f827b4a46b19957629228c4d070e8f38592c07cd6a17d6a60ec0cf3e","lib/libwinapi_ntdsapi.a":"f304dddd7a4b9cd1c3d43f1fae4931e7512bf31f752f7e44539721b75b9ccc14","lib/libwinapi_ntdsatq.a":"9771992eaae766af41ec3f7ce6dc573542126db45bb9221f6f788ec08efaced6","lib/libwinapi_ntdsetup.a":"1f81ab7713b55bdf9ef1ad78a97cd73b2d66b4dd633282f7dfe0329d6f35ff54","lib/libwinapi_ntfrsapi.a":"2dc8b0078f2c7351acebe9b9c86c55f125a9472855c4209b07cddf71e60ba077","lib/libwinapi_ntlanman.a":"ef144c29c940a04bb2dab839b5f00cc319273e6e2f611aee2acca8e8a16c0af1","lib/libwinapi_ntmarta.a":"5e5174c266e8189fb3799666aee9a1bc1c455f36dc38b26c326fcae61c3140c2","lib/libwinapi_ntquery.a":"bfab792990bde5de31c62b4f13cbc641cac611cc9ae5245c3adb166207ec52db","lib/libwinapi_ntvdm.a":"bd6d965ab94264566b978b6e1b814ad077a4ae79cb4c0c48c4b2f4e7cfcb7d4c","lib/libwinapi_odbc32.a":"70ade3b90849ecfb16285ce0dd664d0994fe17df23438d17da4214b34e8c2013","lib/libwinapi_odbcbcp.a":"a4286035e5d4bbef4dd81f7625bf7f8dc08e18893204091d9b4ca57ee45debb2","lib/libwinapi_oemlicense.a":"0b7a4c869927a60159e6fb52e0a770edcc762d78a8527d7c13d97b315caab8e3","lib/libwinapi_ole32.a":"7b6f2c7046748c82132ef02c85e66f32d98c05f50aeae8343dd9b85cc387dcbe","lib/libwinapi_oleacc.a":"d2fa43b88db071e48699116521e257246abcfc821f5996707d60214b9df9f75a","lib/libwinapi_oleaut32.a":"5f382f9501450e65108816190e1edf8661de0b83e76476732710f6bbd080c391","lib/libwinapi_olecli32.a":"9e69e6423b631c566735c8b696d3b65d0aa81411b8fbd08c079c9b539f591cc4","lib/libwinapi_oledlg.a":"eb5b1dc4a96444011e21ab25e1ecc8346e46255ab012b8f50d340fbe1f4947d6","lib/libwinapi_olepro32.a":"c2bb05450b0d75ddb2cfd724fc2353ad052e1e6398af67ff47090d6d63ae1cb8","lib/libwinapi_olesvr32.a":"8118417ac2b6266fb92873af089a55a9a8b52b64ac61ce5a156d4bb6064a3bb5","lib/libwinapi_ondemandconnroutehelper.a":"d5f4267a2f92a18b0a9c9a62c399466dd2b5e5c6c8383d41961992f23fd89888","lib/libwinapi_onecore-api-ms-win-core-atoms-l1-1-0.a":"7ce33ab13f8df12229ca991e33fed617cd4f9aaa9d190af14f975ae07c44062b","lib/libwinapi_onecore-api-ms-win-core-calendar-l1-1-0.a":"9ae8b55b700c97e5c327e6b39cbcfaa66648876dbefe21b7eb5e2b159a9f18b9","lib/libwinapi_onecore-api-ms-win-core-com-l1-1-0.a":"f3e4312912dc7cbb61414318a4c2966a7b0c80551be23679e0f58548864d7955","lib/libwinapi_onecore-api-ms-win-core-com-l1-1-1.a":"e314b1f3fab2a56d2d6112400cd932bb7cd3e95a09be144bc665e0be5480dc43","lib/libwinapi_onecore-api-ms-win-core-com-l1-1-2.a":"6aa14e1c117d293d295ee1568a3e6a81d21f15a0f155646c10c5cfa2224ae645","lib/libwinapi_onecore-api-ms-win-core-com-midlproxystub-l1-1-0.a":"a949240ab052c52430aa5349a284bbab08e790a8aad25f37cf9467537616583d","lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-0.a":"98bd85008746e5c33aa8de5a40171fa578e33950c6c4645a965833f4c1cdd062","lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-1.a":"b61e46a85881068c3bb64ebe00623482dc1bc96476130f9ae2b4248fdf8d1fd6","lib/libwinapi_onecore-api-ms-win-core-console-ansi-l2-1-0.a":"fff26f99c7f76b1e074671efc4ceba790e555fec74a8f34c725736060c200082","lib/libwinapi_onecore-api-ms-win-core-console-l1-1-0.a":"b82d11e22cb47b53cae43f7f0ddeddebcce8e7436e6353dd955ffa1b36feafe8","lib/libwinapi_onecore-api-ms-win-core-console-l2-1-0.a":"9c2c3c24387d5a46885802bb080c0baa05bec2ab1b41e0f3ed003136023ab534","lib/libwinapi_onecore-api-ms-win-core-console-l3-1-0.a":"97dedb121055645fd946238998374d81a8dfab4d8495a2e3e6581aa4827e88b0","lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-0.a":"370c50c9d69d0dea47756ee9129c0358a5a0730cfd9cf16cb3bf38a293d270e2","lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-1.a":"9164e60e37d8bc70987abce632fb608c4e804581070a244abb1e8e2c477bca91","lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-2.a":"2032dde8a93b2fff4427eb79d561dd67ed550cafb00f066f823e4f686ebc87da","lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-0.a":"c825d6d04a0e302786c8ed95b9a2c2da747d3eb13f90afc96b671a356d982f09","lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-1.a":"76c7ef02046d20f400874ccbb68eb9e1653fdbf1b095cb42f95d665eabce099c","lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-2.a":"ea26792152225541f2649c57be0431ed4c444b56121a9d30e56c9913f235ba71","lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-0.a":"3072b4a9bad48fdd1f3ada0787b455580665f677493630e152aa6fd9d48a1af9","lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-1.a":"2abf03e85a577726e4ab1b5daa83bb6b7d0e909857d22dd14199180b809aa463","lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-0.a":"0439a0a7bc74a01589f3c55f2d149976c51c80fa021e72379dcfd7174fad3cbd","lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-1.a":"584da1dfd8c18c4bb67768da13ccaf85831df644f64a6fb30e5c9a3463ddb728","lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-0.a":"b5de61d47e252cdc6c268777c9fdd3300a1ccdb62d3049e299d986d2070773e4","lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-1.a":"c17226cb3dc4da0b2f16ed8cc538f2f666ba5341a0a506e99ad982147a6fe278","lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-2.a":"757fcd24354081b7d79ff164e865c1427f49de3b20948ea4170c453c460c018e","lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-3.a":"a2db8dca687000a7e1cee4382428fb8e325a9d76edd9bdef1e0d231dce42b48a","lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-0.a":"5d6e77c87c0429e8a22b69045b1c11be1818a1b656734bc5f84d3da355b0effe","lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-1.a":"6b9373447d69641afa916ce0f5ddec0f29c56e20d78f8873a65d61a70b1de500","lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-0.a":"66ca30c41fde5c4a99abfe5cc2146636e5b719d557af9abd77a90f8dc9b00032","lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-1.a":"eb51ac48674d0f9d338cd12156a216fcc3904c9efd058c3d2a579609f3c04987","lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-0.a":"fecea4e014a4034a23084021f068a6918ccb99f4ad495fcf93f16ab7d6c1a04a","lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-1.a":"d126b04f4561358fe1040eeec70186530de9e6667d9eb39b8a6a87e2488c354b","lib/libwinapi_onecore-api-ms-win-core-file-ansi-l1-1-0.a":"1ae79be5539951386656160661d39f0b4eef82464336a91443a7cbec41f7f3f7","lib/libwinapi_onecore-api-ms-win-core-file-ansi-l2-1-0.a":"5b1251a929535a44ddf256f4c5bbe607bb1ed66d444c6630c0e936598293e21e","lib/libwinapi_onecore-api-ms-win-core-file-l1-1-0.a":"2148eba5a06d1348001981c08cc4066ba7d65f4432b8aa88f0c422b80f19b36d","lib/libwinapi_onecore-api-ms-win-core-file-l1-2-0.a":"6a68a5ec48ea223c786f5bcddca1e04358f63b536217f2b014554388e392dd72","lib/libwinapi_onecore-api-ms-win-core-file-l1-2-1.a":"771cfff31cb38327610579cdb123522ac32432794be9f601bc4f83bfc2aac4ff","lib/libwinapi_onecore-api-ms-win-core-file-l1-2-2.a":"0c3fcfa360a3163168fa0951c3f61772ea7b50cd521539ea5424e897085b7412","lib/libwinapi_onecore-api-ms-win-core-file-l2-1-0.a":"c27e89c1639e2380837b01edba5fc3cbaf4bb3078c8e7a661e008a1a7ab0cda2","lib/libwinapi_onecore-api-ms-win-core-file-l2-1-1.a":"ea3d8cc0c78d730a56b0d4b9ab93fc6afbf1309f2e481bd8b590d3a128011faf","lib/libwinapi_onecore-api-ms-win-core-file-l2-1-2.a":"3de9d7a4ad6acc06f2a522ca536959f50ef35eb072f71991ab7e2bacf8a012eb","lib/libwinapi_onecore-api-ms-win-core-file-l2-1-3.a":"d1c4172bd2996b5ef4340bdc1ad96787ced73baac1d949d6cf35d2c2a38bf31a","lib/libwinapi_onecore-api-ms-win-core-firmware-l1-1-0.a":"0aae856a71f3126972c06a184e4550586744d0e88eda0a4007f1e2e87da984b3","lib/libwinapi_onecore-api-ms-win-core-handle-l1-1-0.a":"1968042df145c916017c3a7933e0014ecbd5f93e5c9065435f5e2bfcbb907820","lib/libwinapi_onecore-api-ms-win-core-heap-l1-1-0.a":"feffc41ff97440175ea1e188eb31a504d1e8b6e581ca2c6155f3fb859ccab2f1","lib/libwinapi_onecore-api-ms-win-core-heap-l2-1-0.a":"dbadd682960ea85e36d9d785684ac1bae01ad71a175d62247caec06045eda86a","lib/libwinapi_onecore-api-ms-win-core-heap-obsolete-l1-1-0.a":"6c0414ae95319079f2deff62274cac9e41b8c677dd59c6f8db128ac395d7d89e","lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-1-0.a":"34d058aa1622e922dfbb8ebcee6f64070191fd1116c85d8ab409298e9e216a1d","lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-2-0.a":"bcb0745904648e1ca6c4ab1c9dc7f4222c877bfefa3f1d064a79cd7bc83cf262","lib/libwinapi_onecore-api-ms-win-core-io-l1-1-0.a":"441dfb6c4d99734a6ed891497eb938d0296f40cf42a8eda197bd50c6885e163d","lib/libwinapi_onecore-api-ms-win-core-io-l1-1-1.a":"cf941cffa0d3b8a888bbed9752c9f5b0c03d553b6d199ff6258c19f1452d59b1","lib/libwinapi_onecore-api-ms-win-core-job-l1-1-0.a":"b293df0ca91ae8c286b46e06ad2969d8041be6fe20d5052fc20c0d57dd46bbd5","lib/libwinapi_onecore-api-ms-win-core-job-l2-1-0.a":"f29e41ba33e081765dba0ff04a961d7bc0673f9cf7e49351aa3ebc2446596cb3","lib/libwinapi_onecore-api-ms-win-core-job-l2-1-1.a":"4b4460884be3397e693d3ec6eae9e98e39405eb16028c2b09f7f90886d04cf38","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a":"3ac3369f2a9603d9c71b2e560c94436b58f50d144753a13cff85e1a410fd5fba","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-0.a":"5ca6ed6ff56a1c79a55399467bd3378a2033e438a5caae478a98c4993c3ef5fd","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-1.a":"6a493082455ec79ee94c2ec8855dbc7009f9ee0001bd0aed5e58042d6fc75efd","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-2.a":"88fdddb5f66280d31962782a02c4763196d6e518475ba573fb1d3f069bff30df","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-3.a":"d4a5e8cc328af09f59246f0c9b7e3d35cf0f4343946a622f39e3f920294a37db","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-4.a":"53e09de7b3daad97ae55823d82a3b7835926499c8c05e693b6c050c39e9e69bd","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-5.a":"510c0da995c955e2bb644eaa9216f23aaac0112feee526a0546757be2409729e","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-6.a":"debe275148636bfb197070e7fe2c50cdf09da53ebfb5d4ee997e925157f3bcac","lib/libwinapi_onecore-api-ms-win-core-largeinteger-l1-1-0.a":"595390057644c4a29afee502797c5db21cd470aee631b79e4c45320607c46b4a","lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-0.a":"181e309b5e204ae6f024bb0179a87202b60403eda9984be1924116cfc474f212","lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-1.a":"4c8c0b639bbfb3601c206405408fc9eee0317c50b9a4966a2dd46c87702559e0","lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-2.a":"361bdc6179d8dd066c66e8f5c43be9f85d5119c55cd4622c61869bd94168c80c","lib/libwinapi_onecore-api-ms-win-core-libraryloader-l2-1-0.a":"0db1bc8a5f3b4bef33e5443c991d3ece14833e2b28e925777ab48c5b4b716b5b","lib/libwinapi_onecore-api-ms-win-core-localization-ansi-l1-1-0.a":"a954ea83bb16f191fcd6c1ffa4954437c1aa587ddc370c6d0717a05aef6b3839","lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-0.a":"ff332e34ef131f3f0fb62304e6671a507ba984be58a75ab26f52267ac6231d97","lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-1.a":"f51f7ca530a6edd45a0bb824064a52894a511bf9bcc1cf1e81514c1e9ede7821","lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-2.a":"e210ce2302727ea65ce9e3d651a908ddcddf0a160567fa00c0083c0f9f90aafd","lib/libwinapi_onecore-api-ms-win-core-localization-l2-1-0.a":"396c2c716fe85d651568681d6bc39b75754cd62d1d252a39ae3a4cc5fa50dd0e","lib/libwinapi_onecore-api-ms-win-core-localization-obsolete-l1-2-0.a":"4d6dd4f6456cbfd5f5ab3b77a308f23dec9a13968b7e4f6cfda037708ea379d4","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-0.a":"6457c46d1f8d693178159c9392e0fe56a4b50e27fb39b3ccfa8881e015e4306c","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-1.a":"c0e5ae12c989f02ce1bf2057f8979afdc2627ad108848045ce5f473b475084c5","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-2.a":"eda30a9d8d2b844e18f8e5839ca97065ae88acb569d2e060e3260ad5476f29bc","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-3.a":"aef9dbd4d28af47fd00d96aa20d2fefa14fba4cd56b1317b03214404dfa7df3e","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-4.a":"c3c5482c182529e3e5c8b07b40e4bc368b8eff21fa0b83342a30eca4d1bca2c4","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-5.a":"4df545b80104e32455474f20acff7f9da59257a5d4f3c74bf1124d4f8b5d8de9","lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-0.a":"5db78ea3889742c53e0e3882f4857d15e7db0e8e9db41bdd637d633c42d5b17e","lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-1.a":"849fc1d4f4d82a04d496e659d2ec52521f77e20ba93744d8277ae91ba2db1a65","lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-1-0.a":"4eb71e08030eca03ea393f2688f4e43899e226165348c8b0a239184fdabbf53c","lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-1.a":"8ce5c4d7569414b3d17a92516d6b10e2a2e9d3496d36a835ea78f999d70fc909","lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-2.a":"54293fbd0e570b6f37da02a14b02586f4c3cf1a3ed89d85e5f0aea7f4cd15c2c","lib/libwinapi_onecore-api-ms-win-core-namespace-ansi-l1-1-0.a":"99cab897df8772fd9e5573bf8c2c9bba8ca0c89796bb22e3ea1a7d521924a50e","lib/libwinapi_onecore-api-ms-win-core-namespace-l1-1-0.a":"1456c0f4ab7ccb9a9c67b0bb8bc6ae2ca37900f63eafc1f35cd6faa6c3f803f5","lib/libwinapi_onecore-api-ms-win-core-normalization-l1-1-0.a":"7fc88257b8e2569f3688b52c6f796ea3e733147a951b1c3c7214e130e6f7f8aa","lib/libwinapi_onecore-api-ms-win-core-path-l1-1-0.a":"61ad59ac5e91f6c99daab8495f3d0b0b977bc4bfdfa0fe4d11057a0f909783f8","lib/libwinapi_onecore-api-ms-win-core-perfcounters-l1-1-0.a":"71b0dc0c564b008e7bca39ae7b68f073fe17294846c80080c5d2787d64292af1","lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-0.a":"4d19c8751472e2cc17a367fa1c2aa3ceeb6ec2980e126e020b110e0ef7e593e9","lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-1.a":"b5c2cb75007b2b0f0ee1f9c9222ac9b7a96d3dbf4d2cc8934541c88c9455fae1","lib/libwinapi_onecore-api-ms-win-core-processenvironment-ansi-l1-1-0.a":"4c7549d5194f12429ed5caaf9e48a34f71a25bbed1de17f346fb42eeea9622f7","lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-1-0.a":"171d55c0a02aac157754b2f5dae64f31759d7f72fe34b3da3ef020bb6b772daa","lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-2-0.a":"a6e0932b840ffbcf397b498a73f03b08b3c364b0bee2ccb950a3d1f6256e4fd1","lib/libwinapi_onecore-api-ms-win-core-processsnapshot-l1-1-0.a":"d18f7d9b576d7f132ee979199aaf01b9888a6780be17a4884c068457cb461070","lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-0.a":"6bd979768806ef4ad76f4587e11e1fb03af221e58db6bfc4e21f3458cbdf902f","lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-1.a":"9b6e58a775abe1934b2eee8bfb3f119f868133416f40ca64ee3b21626d26c651","lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-2.a":"401b925ff83dc5a3a351b2bdfd2806a76901a1c8a6bb55ddcfab8428dcf20106","lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-3.a":"2b4b44dbdf98db7949e21bd950328a2513f1be268413fc732820bb1d81394c56","lib/libwinapi_onecore-api-ms-win-core-processtopology-l1-1-0.a":"f583a535849b8f45978bbe38f3ae80cd6c53dccec5e3e2425ebddd67ba15dbff","lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a":"43e5b5bbb7dbecace68a4f4a0d4b4f39df4aff180ec328dcfc0a5b37b5f5619e","lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a":"f87bf26cff6015b4b95107506627aa85da9ae63183494bdf37724cff2dc489d3","lib/libwinapi_onecore-api-ms-win-core-profile-l1-1-0.a":"7a2356a7e5b902f95e9d275ee11ff71be319dda03853d62d485fa38e2e4fcf54","lib/libwinapi_onecore-api-ms-win-core-psapi-ansi-l1-1-0.a":"287444f91238567da77e5b65005df039a26ea955e753a1b396abf0b52843954d","lib/libwinapi_onecore-api-ms-win-core-psapi-l1-1-0.a":"7478bf6e874171709669abbb4a8d6b9176995f749a66bd0916ef791ec0518421","lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-0.a":"d9d46d5045f1729d5cca3f4e5134038307783e3c5b6e84c840c13e04861a5c93","lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-1.a":"1e46ac200bdf5dd373e987cbec26b4eddc382dda60bde84bfe11785aeddaea37","lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-0.a":"ca985d1b45f7cd6daa4502a4919af7312b6caf9b721c77aaaffdc30245dff83f","lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-1.a":"31a042b0553caa596949da48b89446b8049fd41a55b5c51c81c338f64c9d82a2","lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-2.a":"42e4da8ce6a813cde55035c7e44b18b3d3f12250a12489a54a89dec7cffcd163","lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-0.a":"0e4b0dbd290409ae848f63e56286490f0b2b2ac4ed76fb65c81745c52046e460","lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-1.a":"799fe6984e2413f28889bf497c659fc993f04939570652614322ef67fd606cab","lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-2.a":"0c13cd0f1731b933452e94e5a3010a38084946d5068ea32e3e54a9e67448e585","lib/libwinapi_onecore-api-ms-win-core-registry-l2-1-0.a":"a62258830da75dad67ba90a38e697666eea061730b680c6f1f35ea1929e8bb60","lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-1-0.a":"38cc3759687a82153c13704b82148e297439bd72427f6bfb0c0fb79a04ded5ad","lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-2-0.a":"ce35d7cdebedb07195bca23616bab8d7cb209a712ef1d306b01806229e514097","lib/libwinapi_onecore-api-ms-win-core-shutdown-ansi-l1-1-0.a":"bf1b67c53946eafbe27b895a37194fe33abb697506fb2ca8deaa38f8b354633b","lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-0.a":"008c0f90de663907480e3433d7e500907d0ceeaa8d3e08eadf029db1c632642b","lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-1.a":"fb8f227a8978db53b29a1506dbd460f2fac8a3a09e808234772c2196ea608ab7","lib/libwinapi_onecore-api-ms-win-core-sidebyside-ansi-l1-1-0.a":"ebe918eb1ee104f12c95753cfe2862caaf1bae2a8ccb4da7f35273a5dec9f31c","lib/libwinapi_onecore-api-ms-win-core-sidebyside-l1-1-0.a":"72f07cfc1e27a4166d10c1737b246d4dc722018f785c64581689860af90cb089","lib/libwinapi_onecore-api-ms-win-core-string-l1-1-0.a":"f13eae10c3f7a9a0bb1023e9d3426cba9b606782bd151aded523086eeba7652b","lib/libwinapi_onecore-api-ms-win-core-string-l2-1-0.a":"e059034de6817aa5ddc8c2dcbf0a0efd7453f48111f84d787c77b70e0185e834","lib/libwinapi_onecore-api-ms-win-core-string-l2-1-1.a":"ee3935afebd0bad19b9013de25cdec58e1d923a5ad5763cb0715233564f0a6d0","lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-0.a":"166374b396d5767b0d405c9d4956a35eba6c817effb4f5fed5f905b41a7217da","lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-1.a":"c3d5f969f191e92c9cffb4e454b23d75dafa859dc88c01749e169ff50e250baa","lib/libwinapi_onecore-api-ms-win-core-stringansi-l1-1-0.a":"683862e54edec7a9ef7760889cc464ddcfc85f2d032ac3539699696722ae8b31","lib/libwinapi_onecore-api-ms-win-core-synch-ansi-l1-1-0.a":"0c9e4393920eb49b1d9f93374313285b4687431eac6b36c298de9b2cd63d161d","lib/libwinapi_onecore-api-ms-win-core-synch-l1-1-0.a":"68333d231f6b90f6abcd887cfabf61264c4676083c0bcfabff09d2552565495a","lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-0.a":"d45becb8167e3fd123eb7352ab70adca4c6fdea53ee8d7f632f623e39dc4975a","lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-1.a":"2cdd52a7baf3a5649174cc5a1e27e209f856c7e671c738ce643a5a31a9abf973","lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-1-0.a":"f7cf60bb402b7ab962a814b4706c925d5f8f36c2e9aca12de5e75797583f4a3e","lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-0.a":"fbd3a3877515f1be804ed8bee1e8f61a7dc722de70bc9da1414f4308d45dce5d","lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-1.a":"2d6ffeb92f9161d9e27242422705f8db162caba86f387b75fa476c71963518ab","lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-2.a":"788419c2f5c2dbd75676d27fbb34d5a898ce0c14c196dd79abcd355e9f3a7c5a","lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-3.a":"a3219664f76e064b676e8657ebc24bb26f0ed84da68381e38d3b547fcd5c3be3","lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-0.a":"fc793505ed82f5e9eb13382a895c95bbf0e189c8944af6f8110eb9205b7178c8","lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-1.a":"086b22b1bf1e6da2497362368a0e38c5092a0753d2f442d6dfd49efe058315b3","lib/libwinapi_onecore-api-ms-win-core-threadpool-l1-2-0.a":"263492b035f0d42f54997bd840d07415dcc84bf462901a20e06d337be29c3202","lib/libwinapi_onecore-api-ms-win-core-threadpool-legacy-l1-1-0.a":"0feabb26b0cff391271fd23d6c3cede97dfdd16af797ba3dd9b7c1b1285a8366","lib/libwinapi_onecore-api-ms-win-core-timezone-l1-1-0.a":"af55dace54c25f147137e747f444f348c7ac78b0b602f41b136e24e22d9fb47a","lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-0.a":"257c0445150a7da2c6c690f1d5d9a00eeb47b96b68a4b0ab9baa363063632c12","lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-1.a":"f634288c210ec13680ce347935e75a272f66787c3627d1c6fe3846d991c631ac","lib/libwinapi_onecore-api-ms-win-core-url-l1-1-0.a":"cd389802670d9cc261bcb07c7272c905da572f4365e87f8e691db8cd4d477d04","lib/libwinapi_onecore-api-ms-win-core-util-l1-1-0.a":"f76e77406c82761f9667a810e6338d815381990de372e41304663540ad56866d","lib/libwinapi_onecore-api-ms-win-core-util-l1-1-1.a":"a82268f0b237601994c56ce203191bdbbff0fb479539c569e0f2741c196b0cfc","lib/libwinapi_onecore-api-ms-win-core-version-l1-1-0.a":"8f3ac9011b2a26b62d97e2ebc8f39024c31f007e2871e61c029ca65a05471bf7","lib/libwinapi_onecore-api-ms-win-core-version-l1-1-1.a":"f70ab9ef523347c2b22803443fa70ccd73d45b7308c3e88832a19d7690cead78","lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-0.a":"e5779c9294450ab4f479406bdbe01c5ec33aa3fe8ae9b9f61876b7997829a3f0","lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-1.a":"70aa42246b091ef8d716dc90414a588b9aa25f8c77470d8bea57e5de97e9d79b","lib/libwinapi_onecore-api-ms-win-core-windowsceip-l1-1-0.a":"2d6fbe48c4083874933887f0d22efcc2e30a8395da48d959593ce0d7d1e6642f","lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-0.a":"9e3c56f2154799a69add217cd9c77a86e6a1bde64bbf33460d4e70e3687d8b9f","lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-1.a":"525df54260b84f1b9269c87f1144f1e5a0cd89fafd65360a62c601d6ba6ddbc2","lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-2.a":"55e4cee223037780a42484456c77eb1e9770edc17045827e81b8e919cbb85737","lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-0.a":"5da39d2b1e8010cdf9b43227ab568c1756d0147b3dab8cb80167f5e78ededee6","lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-1.a":"faf697a2ae01bc6b761292fcadce0560e7c53022db2bd0ae6a0f3c875fbbe435","lib/libwinapi_onecore-api-ms-win-core-winrt-l1-1-0.a":"44bc68cde89ed432570a3a333d3ca70f6d10598075352fb81d8417caec5b51de","lib/libwinapi_onecore-api-ms-win-core-winrt-registration-l1-1-0.a":"d1f598a6e5f679f1c5cbf39d7aa943cedf5a6c55292e00ae18661de492f32709","lib/libwinapi_onecore-api-ms-win-core-winrt-robuffer-l1-1-0.a":"6966b4c35904d9615bbee8696aba3f00162f9384ce72fb7295a4a7f5b3a7c036","lib/libwinapi_onecore-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a":"c2992ea72fab9b721807c5c31dc0e94569540290af864d5c5bbe7adf9a154e5e","lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-0.a":"a922f544b8205ff46043f3143b267efbbb838c8a9f13ea088c6999ff78f67eb3","lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-1.a":"33123c82b4e595ad6a687831cf3ba94089be31bbfd23e63aaeef3fc869297399","lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-0.a":"91fcc265a2126384e079dfab0816ef424043138880e89aa779441444271d6ff8","lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-1.a":"46e4dcc37b939b91dfcfe917ba6f9d9ee6e607a55ff9b6bedcccf75e3c1905a6","lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-2.a":"2d344bb7c91132a539d488ce16a683e8146c6f4ef61c5e85c3d9501b42b6d930","lib/libwinapi_onecore-api-ms-win-core-xstate-l2-1-0.a":"6e090e7f7a713f5678abd290b2f43db5d97a4fda54dce7b1219667424292de71","lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-1.a":"58e6da81b7f5632de81c1e1df8cba71ff4af193b930686f06613593e44f534a6","lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-2.a":"d631fce3bf17a13ddd797a70b9cf63a144ba179511f451ab5c0bb8339970404b","lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-0.a":"a3a5179693fd5c8125c1709c0f7da0840e357352fd2675c285a80b4d340c6072","lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-1.a":"b3f42576a838eee69fad89e4d98bc59e6094f7e4fcb211960176f57a355e22b5","lib/libwinapi_onecore-api-ms-win-eventing-classicprovider-l1-1-0.a":"ad9e71140c583e5a06e73fd60079e4be8a4ce5a176de88f4c92c2a73a8044d5b","lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-0.a":"35b30ec4b0654649148fdc900550d903ba7ca6bb2557e12c2be816c2b8c402f5","lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-1.a":"1691aea951f9e97a5630606af45ecef1d35e0405ea1732d15bd4c169b41ee819","lib/libwinapi_onecore-api-ms-win-eventing-controller-l1-1-0.a":"edff320a89daf18d86701107d734c1b0b4a8ccd1ec46d50cbd16ba9b7a0c1173","lib/libwinapi_onecore-api-ms-win-eventing-legacy-l1-1-0.a":"9ced4f3c4f2336f28fa00f3f5cb5ba1dbe847f8cd60419368975a00fbc451097","lib/libwinapi_onecore-api-ms-win-eventing-obsolete-l1-1-0.a":"c2657a0b8af03da164208aeb2e1d1fcf81c109ab1346a48b00f60425d89a05a1","lib/libwinapi_onecore-api-ms-win-eventing-provider-l1-1-0.a":"47b3e6bc27ddc5c087a416678ea1793a30f348b3c41d6e07db7cdc9c22831c03","lib/libwinapi_onecore-api-ms-win-eventing-tdh-l1-1-0.a":"0f11e4cf0225f263288544cb9a7f0ab6f591ee1be60fc42cf9406de04854c5ca","lib/libwinapi_onecore-api-ms-win-gaming-deviceinformation-l1-1-0.a":"be96a1a7edf036cd8722f9e6726463687198706db532c800ecf7c81813b66903","lib/libwinapi_onecore-api-ms-win-mm-time-l1-1-0.a":"94f97eb87b5bf72bf96fd7d504bfa1fde396bb34fb52b5b14b03f8a72502b6df","lib/libwinapi_onecore-api-ms-win-oobe-notification-l1-1-0.a":"c3c2475a9324e792dcd4a813c6611d1c56c8fc15b093b55095f7be62eacf3f48","lib/libwinapi_onecore-api-ms-win-perf-legacy-l1-1-0.a":"d05aa84c6342b405a1667e69545c45da23511c7395091434cb86433123905f27","lib/libwinapi_onecore-api-ms-win-power-base-l1-1-0.a":"c099b2534f8225c5f459f006cef2079fe69eefc5c5c0814ad65b6266dfce6d5b","lib/libwinapi_onecore-api-ms-win-power-limitsmanagement-l1-1-0.a":"906dcd96ef83bc1ec4960208f28d20c11d3c4b4a9285457829ea9615d5f3ebdc","lib/libwinapi_onecore-api-ms-win-power-setting-l1-1-0.a":"8fc5951fb7aeffe7b26121a7b5e2843def7ef2022c177280ade4d1dc5edadf6b","lib/libwinapi_onecore-api-ms-win-ro-typeresolution-l1-1-0.a":"3b62535868ee933138b5f51622609f2ef6993f696854353d7a32417efd4c1357","lib/libwinapi_onecore-api-ms-win-security-appcontainer-l1-1-0.a":"843241145aa98032ad2607c3ff4882773dbac60c52087c107bc94ce553ae41f4","lib/libwinapi_onecore-api-ms-win-security-base-ansi-l1-1-0.a":"d825cd08215e04a66d6c2b0a2bf22a8fdd459c79df96d0900de1c9357f07670e","lib/libwinapi_onecore-api-ms-win-security-base-l1-1-0.a":"991613a90774d30321847f229737037e980ee4e1cf2530591bc15dd7136bd19c","lib/libwinapi_onecore-api-ms-win-security-base-l1-2-0.a":"1bde30f5f2bdee0463b0a6f218760866c7d8cbbd5caa195b592366fd5c696d39","lib/libwinapi_onecore-api-ms-win-security-base-l1-2-1.a":"007f08d1eb7eced643f122ddb82440bbe76e2ab2d7bc53c72fecf3715cbfb01c","lib/libwinapi_onecore-api-ms-win-security-base-l1-2-2.a":"2cbbc75286c357dbb97e043ad4cb4bcd5648db803634de04e213a482f72357f3","lib/libwinapi_onecore-api-ms-win-security-credentials-l1-1-0.a":"3ce050b1f472132076a4fc3f20355b6ed1e21d2729acc8b18f807077227287c5","lib/libwinapi_onecore-api-ms-win-security-cryptoapi-l1-1-0.a":"ae00a17a300e44df9e056f31676341cc3bdf008435b3ff13f2ce1509c428fdd0","lib/libwinapi_onecore-api-ms-win-security-isolatedcontainer-l1-1-0.a":"2e93b45b7e4ca0758ba473edcc4a75b068b9651187914ef4cd34623b9c04df25","lib/libwinapi_onecore-api-ms-win-security-lsalookup-ansi-l2-1-0.a":"6000fdc93f1a6a6a3be35c77764f06fe25c242e84c97459199b89ef39905a9ca","lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-0.a":"a8386c72dab1edd4001c38a8d81711bbe3fc376064b9eec14a56af3eb743e76b","lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-1.a":"ac9524bb45b8c7ced98b7ff5884f6949b7861be9a555938c28aaafd9e838bb44","lib/libwinapi_onecore-api-ms-win-security-provider-ansi-l1-1-0.a":"af68dc5e041cbeaef887e4ba3fa9aeb15155f99f90fca1860c1d5fc6cf744877","lib/libwinapi_onecore-api-ms-win-security-provider-l1-1-0.a":"4d155455dadec07a3b3e9927d5ebc15339b74d08cbb269ac4257832e2de17654","lib/libwinapi_onecore-api-ms-win-security-sddl-ansi-l1-1-0.a":"5444fff280642dd147181d1831dc1864a12175d928d10a1d1c66ea765771d61b","lib/libwinapi_onecore-api-ms-win-security-sddl-l1-1-0.a":"741a704b4e6b31b07a62bb662bd762ac23d991c7287ce5eed9e68593a533dc1c","lib/libwinapi_onecore-api-ms-win-security-systemfunctions-l1-1-0.a":"532d5bdbf0a544f46135549a09993232c88f25702d994dbb067cdc1883e75ec4","lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-0.a":"a7e67d849fa4be88b88f8fedd848fe139ab771520d9cab10fa3856ee121dfc21","lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-1.a":"cd9d6e3bce83e2c81a825337285fdae77d9d59016b8dccecc9d81e7c72e0b7c7","lib/libwinapi_onecore-api-ms-win-service-core-l1-1-0.a":"7bbffec6a893991136217e7677c88670faf88cc1ff6ea299bbfcbc3a442463b5","lib/libwinapi_onecore-api-ms-win-service-core-l1-1-1.a":"2d24e67d5e1d8cf53cf536565eb1d2a2c66b77bfc3d86dd7d41b25f9abaa5ee5","lib/libwinapi_onecore-api-ms-win-service-core-l1-1-2.a":"dc3cfa35578e93cc3c12fa34202491ff32833567d0a890390453e5ea99587c01","lib/libwinapi_onecore-api-ms-win-service-management-l1-1-0.a":"19990b2d2df2193e1a11aaaf1cbd7e14627ab764428c6a3e1425f25ce36f3145","lib/libwinapi_onecore-api-ms-win-service-management-l2-1-0.a":"dc8c68d4c9609d4e10432ea73d2ae81657cf4b3a46df476bc09bb8f935ed8c9d","lib/libwinapi_onecore-api-ms-win-service-winsvc-l1-1-0.a":"f0d2373f6692424d3552dea976a0a4b4a8ac4a51a9f1cbe98dfb8d4aada03741","lib/libwinapi_onecore-api-ms-win-shcore-path-l1-1-0.a":"6068069825c12832d9238011a47b6029c26a8e4f9327fd0822fc101628669115","lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-0.a":"b7668ae7c15d01fe3bc580ef64af32458281c249873c048c9e874d7af428643c","lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-1.a":"43fc980cf389793c54845afa83d4cbf1d89a8b24b3a4149e8064f8072df20d57","lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-0.a":"9f54ad31643cfc61c7ddea1b66cb04cd60c0ee0a3c16845534d52dbe4af753e5","lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-1.a":"1a02a3670ff8446f475bb6bd060f117a6b9ced76cb7ca859ba8b7f4a0768a11c","lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-2.a":"8e8d97698699baa2d0a4a3c6d3b7b197145b1bfd97247080bf6ba58990567ede","lib/libwinapi_onecore-api-ms-win-shcore-stream-winrt-l1-1-0.a":"f64cb18ac2baf4b1b9bc3a6fac1cca5829ebb958b2ea1864170f113e2ce085f0","lib/libwinapi_onecore-api-ms-win-shcore-sysinfo-l1-1-0.a":"c8f7c2be5391623d4384b2e6e0c375a4fe355ab359db707aa61ec3cca651ff7f","lib/libwinapi_onecore-api-ms-win-shcore-unicodeansi-l1-1-0.a":"1f300cfb0b58d4bddf27e03b81968076f229cbab10132746c8356d62fce4b36e","lib/libwinapi_onecore-api-ms-win-shell-shdirectory-l1-1-0.a":"a027bcccec10f79a351e65285830cdf50d46aaa5dd8c3af0aca6116f1ab7bad7","lib/libwinapi_onecore-authz.a":"c89f36c61fc7e48696568a3d2986c52e3071457b3a742b514900ce5f22c05e55","lib/libwinapi_onecore-bcrypt.a":"f9084f955c2614f3c478590a22a3e325e9f544138f7349d3d449d1366a0893be","lib/libwinapi_onecore-cabinet.a":"ee558f2fd9798a054ab5a1968ea301321417dd2bfca9f62527564111c54866de","lib/libwinapi_onecore-crypt32.a":"cddc073ca75649a707f804d9f1b11a2a8b3b4692309348ce6d55111577b5f4da","lib/libwinapi_onecore-cryptbase.a":"287fd63dc36f7037000e56c1da96dc6bf9836d7b484b21c6d8a0484b9bcadd4d","lib/libwinapi_onecore-cryptnet.a":"9e8ea0194d504ec9d80d9b83ee75d0596a9c183429b7913a8ac9e7fe8733aa9a","lib/libwinapi_onecore-dfscli.a":"30325d84bf52b50e784bf19b367141d85efbc278271015608335b680e3dc0580","lib/libwinapi_onecore-dnsapi.a":"e707bbf995c6648d1f89bf13f1852c2e7d8c4e355d821bc7cd0f1135d7b38a8a","lib/libwinapi_onecore-dsparse.a":"a5273bdcc29806fcc3313a4fbb6a756f1f2e5eb40a966fd8bbf3890cac674981","lib/libwinapi_onecore-dsrole.a":"28303cd4189df6a713db163e3ff2d838474d7092bfe5041a4fe92d1ff2a55da6","lib/libwinapi_onecore-fltlib.a":"44152e55ca753ba58a7e368511d38460410ce3be226ad63bd677ce2a549ebfa5","lib/libwinapi_onecore-iphlpapi.a":"4f6960e63e756adda1a5dcf96e7d6f68af9180ea6f8053dae6d442dd830a4e86","lib/libwinapi_onecore-logoncli.a":"4b52c029e23daa9a599294ebe808a9fb5a03d9eb35f3a7de3dc5611a6d1d7589","lib/libwinapi_onecore-mpr.a":"68822897ad26a22e8f260e65b9fe32bc09d8a9365ecc700b3217e911893734df","lib/libwinapi_onecore-mswsock.a":"ecb16deaa836f5b044c00764d787f6085933c618f0b28767aca5193f68795625","lib/libwinapi_onecore-ncrypt.a":"724065809a811e15848f2bde0900ea72623104ea952702864075cd4dd2af12c8","lib/libwinapi_onecore-netutils.a":"55b8269a1d66d70b7737568010a9b1ec5b8cb40cd9ddfc11ba3afa932cca74af","lib/libwinapi_onecore-ntdll.a":"9713c2aba3f363c0896ce9b41452e33b89ee086cbaf4bac5767f1cb7f3063f26","lib/libwinapi_onecore-oleaut32.a":"c1e9036ef62d38e665b262a84cbda4700347f81b7c51ef34366e41349664f234","lib/libwinapi_onecore-powrprof.a":"46d90ce9de053c665ababf56198282b837da18f6baafaa23fb31ecea0006c64c","lib/libwinapi_onecore-profapi.a":"df82267198948d81c4ca40e9ad63e5a7070fda8952136aabc51ed06645262181","lib/libwinapi_onecore-rpcrt4.a":"1e09fc72e60b15ccd9bd63a9ad1157f6fd1b493b45f74bb7438fe4e1f01808e4","lib/libwinapi_onecore-samcli.a":"4084b9afc3d3fc538bb3dc38ac4e51f237358ba468170c2cc31fd676d75ad3d4","lib/libwinapi_onecore-schedcli.a":"5153ef0da92bfb66a2fd1afe65bca65e31c7197e72731d3c6ece693f6253d571","lib/libwinapi_onecore-srvcli.a":"8697381d4fc81b6b1b7495219a8222ecff52bc3a5494dbe491bc209dd30baa65","lib/libwinapi_onecore-sspicli.a":"d85433520cdb952ef3145e6b097f9da6e5aba2c4126a1aa48b77b54325deebc3","lib/libwinapi_onecore-tokenbinding.a":"e6d97f0b962ba9447e201ee8f496c619e5e4d0bc813fbcf079c0c4180eb0c6bb","lib/libwinapi_onecore-userenv.a":"f087f66aca67f1a15ff3d151f3641be41b8986f8c4a38d2530ab2762f03263d8","lib/libwinapi_onecore-websocket.a":"87b2be52bc1c38c2e3009b47d17cbb929f6b4eeba2686de82da8754e4e869ebb","lib/libwinapi_onecore-winhttp.a":"c559378240c38cbb1d5921c1f77b07d6a94ac3683ad2b58689cd7f429b76dcf4","lib/libwinapi_onecore-wkscli.a":"550d7d3456b98551ddbd0f807873a31e4277bc9ece242011a01f7fbf44f9fcc0","lib/libwinapi_onecore-wldap32.a":"503951e442826910c99adfaffad67058c7d1f5b912a7e0ab5832a95272019ee3","lib/libwinapi_onecore-ws2_32.a":"fe9591008ba78154904c03e942f3c3e80910fa8642bc3cd786a749fccf995fff","lib/libwinapi_onecore-xmllite.a":"d2c04f0a5904f91a5d738039459c3fab2a913e06a9da77d6efd3e688d2fb948b","lib/libwinapi_onecore.a":"79f5ca419b388bf58352e9a4e988306e353a07ecd8a303ae4b75b71148dc477a","lib/libwinapi_onecore_downlevel-advapi32.a":"9a1470de3f901ff6d7346be7df21c2f6ecbb7f8c7b76725529aa7e485749da19","lib/libwinapi_onecore_downlevel-apphelp.a":"0924884d9445e27828f0e9c3e60f3a66e0270eda43122e52108b37b6234128da","lib/libwinapi_onecore_downlevel-comctl32.a":"af493e0072a3bb5ef7dc58f69b96926e0381b5f71df8f7397ae24285fa4b9f68","lib/libwinapi_onecore_downlevel-comdlg32.a":"90c4c25cf1bb25540a0c8a9c9713584e4882c25bf9a0e7e706d58383faf8e57b","lib/libwinapi_onecore_downlevel-d3d10.a":"d5d6ab17b1a35597ee630ac91fdac4f34d70be9321f099c01f193a80c05f1901","lib/libwinapi_onecore_downlevel-d3d9.a":"f5afd3767aff431bf2b96d5b716e4f0171bdd50e08e76520ded95d4b0105d8a7","lib/libwinapi_onecore_downlevel-d3dx10_47.a":"1a7c23582aef6cc6a4237a4fbe47e2bd5768bc405f33822e62d89c8b2b767ed9","lib/libwinapi_onecore_downlevel-difxapi.a":"f1042623f702d415ff8ecb33ac6dfb2467139c0f469b1cd1af349018bff2ae81","lib/libwinapi_onecore_downlevel-gdi32.a":"cfe9846de5dd823bacc40a1dcc7647a47cdc3547338b79c73c70f56b582cd60b","lib/libwinapi_onecore_downlevel-input.a":"0ee64638a356f8d225de89e88a0e5e0500c748f3cd3fc34bd74401e654eb63fd","lib/libwinapi_onecore_downlevel-kernel32.a":"f12a7e4f4d3cb78c42c2465ec74ecf2175ade86e59a7c6465765c636cca842ce","lib/libwinapi_onecore_downlevel-msi.a":"2233db7b130a7d98f178e924bdbdc495d25854bf35a9af2e46d413bb67d38da8","lib/libwinapi_onecore_downlevel-newdev.a":"3e98c28ddb2b78644d0823dfc234f28d33e6e5609268f86f5e1a918ee6ad7427","lib/libwinapi_onecore_downlevel-ole32.a":"e73a2282f0d79562ac9c676276548d7cc65099cfa59dddf6890c96640fce5afc","lib/libwinapi_onecore_downlevel-oleacc.a":"167aaea317be2a53f866cfde4ac381df3cc14349b05a5f45b8025ea6dfafc504","lib/libwinapi_onecore_downlevel-oleaut32.a":"3c09885c10a0e9f5b242716cb8c54c98d84d56ecec477376294d813e98070643","lib/libwinapi_onecore_downlevel-oledlg.a":"a5058dcf256384272424dfeaebb7dfb68a0156c51a7c4cf0a4aa5509a80c3137","lib/libwinapi_onecore_downlevel-pdh.a":"c08012da446bcc019dd4677ca81c8fe8c84a690d35910858b8d5c33bd43df784","lib/libwinapi_onecore_downlevel-psapi.a":"ce0f455594f25fb5ccd1780a42bea521c497e3979ee6e38aab5ca4c5b51e56d5","lib/libwinapi_onecore_downlevel-resutils.a":"eb85ead723be66a8bcd679153240809ce3eaca19f5e09fb50916389b2ec44bf9","lib/libwinapi_onecore_downlevel-rstrtmgr.a":"5b71806cce0ef47a12f04512af24068e0b28dbf8c73c821d33f40fc53afe8185","lib/libwinapi_onecore_downlevel-secur32.a":"b9b3c0dbf3453119cf38b030f9ac7c2c8b05c9a50064e83e647604bfc2716751","lib/libwinapi_onecore_downlevel-setupapi.a":"b4f8966901324fb3dc3542b5e3b1b9b61dcae54bfa3429e36b8dd8b9ed23b0ff","lib/libwinapi_onecore_downlevel-shell32.a":"750024575945363851dd13ef5ed07085f0d393d851b5b6182d0167da93e2d9ad","lib/libwinapi_onecore_downlevel-shlwapi.a":"bdda84057a267a2c96e92ab9902ee2c106a92ae8a2d9d6f6057c70004684e8f6","lib/libwinapi_onecore_downlevel-tdh.a":"9c0ef09e849e277b0dfc7d7cd8050e656b8f8b71226d46e332bc510f68fdf8af","lib/libwinapi_onecore_downlevel-twinapi.a":"da6071d2f9383b1918bca8f8e43e068f6110e0279bd4c2bb550aa51623740196","lib/libwinapi_onecore_downlevel-user32.a":"45162b307e5d0bd8558fc9d1546c0e74a8eaba61372ac3cd645944bbe385e62b","lib/libwinapi_onecore_downlevel-uxtheme.a":"64c40a49a0f21ecb41a1192c64ef00815b785e6ee4030575ae5b1d203666a832","lib/libwinapi_onecore_downlevel-version.a":"42dbd6b1186fd4e6da3bfde88c51199414f7c2980da46da12f9d6c760fa2686a","lib/libwinapi_onecore_downlevel-winmm.a":"2a17d8e31a4131334d59ed41e0f7a7763772be02454f12ca75254d3852ed2e21","lib/libwinapi_onecore_downlevel-winspool.a":"061b6216f3b343307d156833364f433116305f5e4d3e85de6bc146d65464702c","lib/libwinapi_onecore_downlevel-wtsapi32.a":"27cfe4b37a87e4e5c15fb61e400ec5ca949999bbcb18472864d14927c88ea6dc","lib/libwinapi_onecore_downlevel-xinput1_4.a":"c68a20b83e6c2ac77d7f98be2b4fad1601aa33d8996b613caabb02bc77e02ea1","lib/libwinapi_onecore_downlevel.a":"b970765271ccbbf0a2843dfb757f678f6b6fec0404914e861f24e289656335e8","lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-0.a":"d3c86590ac61e5d3b0d4d429a93632c2cbcb5842d84b8449e5b0a6807ba5c475","lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-1.a":"48415e10ec3ab60fcd7185def0b8e69cf7d4f81a3b7ae0edcf4c0eb4f9aad10a","lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-2.a":"267bdee09d1c9ebe8785ce68b65f5ca5a8664d29d0878286ce19eb145362837e","lib/libwinapi_onecoreuap-api-ms-win-core-atoms-l1-1-0.a":"4e3ee6e74bd59cabee0f82fb6764378d26bfc5ae3aec39de0a02e64d83bd7e69","lib/libwinapi_onecoreuap-api-ms-win-core-calendar-l1-1-0.a":"679c9a2425099afe8c74612d35969364b47dcad3773055c7854be1f495f6f5a2","lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-0.a":"3f1a775d67835415d1afdb0f4034ca71bac4b51439690ec03f1b389e1b775120","lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-1.a":"980b79f176613805271d73fd7ad35f763763858dbca5f564d2fa814a2bf31c0b","lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-2.a":"00c8b599b3383b705a3d4c9c49ddbbd56371b4ce2b416da26219a8611e666585","lib/libwinapi_onecoreuap-api-ms-win-core-com-l2-1-1.a":"23324345965bff97ef1234889beff115969ddc2277338b22b0264deacd81e380","lib/libwinapi_onecoreuap-api-ms-win-core-com-midlproxystub-l1-1-0.a":"c81a1d129ead2cdd57f0a8957983e63d1f88ce29877823f16d24af2999218734","lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-0.a":"c1cb62129b8fdfa7e8fc585af0aa3737b177d2752825d9606ddb646ba5b567e3","lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-1.a":"125a0152d091e2e3d5a5b310332e001bcd0dd8d642144bbaf3d50904c0aa3637","lib/libwinapi_onecoreuap-api-ms-win-core-console-ansi-l2-1-0.a":"1c832fbd6f8f8c5c25164afaee442578e9fa3635bb49797d7634e75a897fd3a9","lib/libwinapi_onecoreuap-api-ms-win-core-console-l1-1-0.a":"f7b1bcdc025d31db9d43b8b6c8658ae9a66eaa9aa32454cd1547fdd917634d3a","lib/libwinapi_onecoreuap-api-ms-win-core-console-l2-1-0.a":"42cc06853f79b623e08556f05ca526610fa445d6023de2595c3ec49ac0c9fd14","lib/libwinapi_onecoreuap-api-ms-win-core-console-l3-1-0.a":"68a5a7b1d92129979588aa31c42fb97958461b928dfd2f7a045d70204311f0cb","lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-0.a":"3b7b10e05a546839a77d7c5084a78a30bff0925c90e2a4ae6d92c478027cc4a5","lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-1.a":"7881818a8ee239d8aac81b5b2911ebe648c44cc236dbaac2173455912a5a2b88","lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-2.a":"f3cd722d06cf0357e7c028053f40e9153e2793b201bce822dd3581d3a046e88e","lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-0.a":"556fb78c433cfd083c07c74ca3925176f4d8b48c9a58e03daa62d19fd935397c","lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-1.a":"011e563fbe9356ca9917ae2dc9aafd8aea4735d166aba189fe29341f3537215f","lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-2.a":"cfbf8d52bad634cda3fc5441a5dffb72f12fc89da4a5620f390c9c70a22a2b2b","lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-0.a":"eb7db447807c59b3f3c4a4896d16ce15e6bc4f1eee3bd6f53d1ef5e17ea5ac54","lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-1.a":"36f22ac58c2fb1e420284e3fde54ccb0d9ca8a3eff842aa339ecea7edc51d220","lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-0.a":"a31ad417ae86adacb47880039736845ddb7c318dd955f5f309ccb946706a8800","lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-1.a":"db5331242f77516456e0fde1f53b3ae98cb5c9363a8e286cbf9b66c01495259a","lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-0.a":"34789245073349fc68aa33a8ede222c967a551aadf31b3f86d56fb3915570f81","lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-1.a":"8fde5f5f7a1a8b7bcda0b509a222c1d0ca75d97ad1b398159b3ebfecbfc603d9","lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-2.a":"369d289445328091c31e346e78970619e77c4af3e50edd5425bc0203215b4462","lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-3.a":"7f9093cf4d44540d295d6adbf96ec90b8ce3298aba899aad5d682ac7f4bc2fc5","lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-0.a":"29d814a804f4778ef6fd4d1619a555c5644e5aaf7bf37ab7ad119addd721d5f4","lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-1.a":"2f28d21147401dd8fbba19bfa040c215e7a6c62314305f527443bdb5ddf56ca3","lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-0.a":"981daa2b794228cc1b0f5c83c08f1d2836e03ac460558fa58a3e7742f8cd2e5a","lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-1.a":"b6e7b745b8b588189b817363e576a019067f2e30e7d00f0f941eb66078f687af","lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-0.a":"b128dd7fb6ada26dd227ce86a98a7a096782f96178ec278be06cd04b4042b8d8","lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-1.a":"9bb377627f9c2443f33a43c6cc3820106075cf950a9fcc02b3daf791f1ef219e","lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l1-1-0.a":"d50709c46fbc52669a7d9896789cf4da085aba50bb1f2139f6e23b49d8100016","lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l2-1-0.a":"ff2c9d565b71bb16f7e5bc730cfee673a469e6ff5a1ed83f33ede97c705c4fa6","lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-1-0.a":"0eab57ca33867b10954c19bb791eef9d02b60edeba765f7f277301ecd5ad8659","lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-0.a":"ea73055041fe18e9709b1094fb0c31b11b271ffb95b3a2e15fb249777adfd568","lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-1.a":"0ae8a2d85d00854e933f163707e7773a14d49b4ede621d87d3bc5097c6378b74","lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-2.a":"7a47049dee70562ee2070ace79a8212ec6f863c5dbcfe21aebb4fd7c1b69d9d5","lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-0.a":"dd4beceb423668b7f214dc32e66c60575112d7dd3d51a60517318427f23baa1e","lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-1.a":"aa8f1713e5696b03737c2591d84d23c5f0ed5143dcd198da14c67987e3711d3a","lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-2.a":"85f8439e5786e36b585a2e2d94c4b81f23a8bc56dffcbc62270fb37066c5ab4f","lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-3.a":"7aa9b32763e55c5c7a43b836a515b59d650ec6c09725a3b2670518bf787f77b2","lib/libwinapi_onecoreuap-api-ms-win-core-firmware-l1-1-0.a":"2674c264db3753cedd4c411d7b487fada1b6efbb0be8ca2d115d6f63fc1e7a31","lib/libwinapi_onecoreuap-api-ms-win-core-handle-l1-1-0.a":"8173abd5dfa36041c40923e65a16f02d9d6ca1397d6989e163239ef0b02bbe7b","lib/libwinapi_onecoreuap-api-ms-win-core-heap-l1-1-0.a":"3fcb04bce35545010b408f9ff4eb0ed16a0bf10be5d144f020299f87561748be","lib/libwinapi_onecoreuap-api-ms-win-core-heap-l2-1-0.a":"e39429d77525812669745c72a9574f93a431a8de9477771e1b7a1c312ef48335","lib/libwinapi_onecoreuap-api-ms-win-core-heap-obsolete-l1-1-0.a":"091ad5944fcc5136bc162915bdf64d58381ca8ea9a63ce839348ffc53ee330c6","lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-1-0.a":"0f52705fdbfdce70ba03c5c036ac5d0c0079ef3b3b4b35d2f672e64932962575","lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-2-0.a":"51a677e70953b1999902ad9aa8547a0eded32a2fab3dc307ff787d00e8d61377","lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-0.a":"bcf91b892cbf3678c6b2706e8cb7dc6797b47fc77cd449a0ffdd922e437d3c03","lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-1.a":"4c197c4be209f216dce71d520d21261634874b54e23bc0c24cb2892e5a011137","lib/libwinapi_onecoreuap-api-ms-win-core-job-l1-1-0.a":"4d7be6925bbb3d7c0d1916fb417613e0dab2b57e6c0f2c4be0b564fbf12c51c7","lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-0.a":"4b1a622cda0d57fe752d78c09c333883f290625f3015f7497bcb7857063a09ff","lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-1.a":"74f765a2a11db158c10c3348adc510f29c27c725f29e3bb1069eed17c4784a0a","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a":"bc31126b29484275b43c947596bf2e08f5fef6f2d83df78a299d2962165814f9","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-0.a":"94d5af97c1664a9e53cc2d3b85d2d02ad28231b89ed50847a90c29d21fd815ec","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-1.a":"75eb1e9161df1fc6e58d8183c9a63016d28c28d5adcb5872875ce51662f546b2","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-2.a":"c353ce2dd1f7c3411d83b0683215fadd3585d88667ddec2a6a8bd381ba1c2603","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-3.a":"21b13e0ecdc7c3a14512dbdf2846f86996cc16de0797f90e0472a97201e47fa2","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-4.a":"42b846000ee1b172d2f1520e308f3877bf60dd8fe4eb5ec71b208dd0efa98866","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-5.a":"dfa6f81a89f7e5e8019715b74145be5fd9ae68be722d93fb0ee93c04f3045326","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-6.a":"383b0645ed61362b0c07a7c4cfb2509eca3351b22e2bf3684d426c7622aab6c2","lib/libwinapi_onecoreuap-api-ms-win-core-largeinteger-l1-1-0.a":"3b23a209df9ab14d089bb2b5844e05b97db3a6f7b82cacf6dec70d7686e25d3d","lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-0.a":"fcd6d6b4641fa4fc9e098218ac5e5394f4d73cb27bb008b08cce6e7f643f2ba7","lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-1.a":"72a96e6532a6a27bae67a5ef133f03e30fb84ebdc36f4c900ad39d3e07ca3844","lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-2.a":"d4f534c0b116466c6899ab60a86ed81983a40db61e2e92d3a37e688cddd5ad0d","lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l2-1-0.a":"df036740da839181843676ade50cf20603b3479aefce6e793df39707a6fdf173","lib/libwinapi_onecoreuap-api-ms-win-core-localization-ansi-l1-1-0.a":"8c1da62a7dae359d4bd22d63683cf0d32f4857b3ae99f68d38738efcdecef988","lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-0.a":"1c3870806e36a4e9c588899e28f4e5c4de8106dc329d79ef90da99c863e4152d","lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-1.a":"3fa775366f4b011dd6361cd2cebf12f9624782b69f573dce0e50102fff96b44e","lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-2.a":"15411409b7eb5d2a1d3eec112d987a3c6d5ab106e5241f83d58c88cffd8ece0f","lib/libwinapi_onecoreuap-api-ms-win-core-localization-l2-1-0.a":"325684e8db77a522ad2afba966f4a2b49f0acea66b2aed43d9ae325cfdaabb4a","lib/libwinapi_onecoreuap-api-ms-win-core-localization-obsolete-l1-2-0.a":"22b7c413f185dab06cffd0be7771cc721fbf6f83fbc2cea0dae7e65337f6055a","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-0.a":"0ce9df0fc760bf6cc1aef4bfe066a76705a83066a5bec486a8514beefaaee6c3","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-1.a":"6fdb709c20b1d43029298b014d56ab4c06b2d395a88e7518caad576b4f88398d","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-2.a":"243cd4c16e8dc7ec9fd644013c10b4949aad0af52dd8e3db3dafb5cb2bd8eabf","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-3.a":"f24c7f20b0ab73a80201b20f6a1eccd48b9cba236725c059c2312fce629212e4","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-4.a":"1934abec8171e72074d5c24208313b3ec344593fbed1161176bfd125d683e620","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-5.a":"d980764c22793fb004b9d6ad38cba6f24df6a602375d9880ebcfbdcc7379223d","lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-0.a":"1cb14815487346aef5a3dbbd3a2b0d30940cce6bc9971f67959c5e9be379daaf","lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-1.a":"c5de9ae7e429fbf795a23d062c52c5727137a963abdd0dc84841b31b63a636aa","lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-1-0.a":"486b3f95eeb2683798486d68d11d4eecbc6c280087e41125290ca393d80a8222","lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-1.a":"0c17ff9e0d8a23dff2fe3050b9fbb195be65b7427c04b2212b6ccee8aaf5ee60","lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-2.a":"4b8dc31f16b2949308ed19af7cb9aca027e7895502498e545d50ebacd99366a3","lib/libwinapi_onecoreuap-api-ms-win-core-namespace-ansi-l1-1-0.a":"2fef444f0abe8c0920f31cce744e644ef7eb12e499d912595a7ed14222ad85d1","lib/libwinapi_onecoreuap-api-ms-win-core-namespace-l1-1-0.a":"4c76d9807883478f3120cd07b6cbefbdface7395579f97e0fed6f6b3a24ecc4c","lib/libwinapi_onecoreuap-api-ms-win-core-normalization-l1-1-0.a":"29609814bc5f82d39f4d7bb54194422bd2157e453222d19e0a6f506d08c107d4","lib/libwinapi_onecoreuap-api-ms-win-core-path-l1-1-0.a":"2f75edf68e1c98f473116442cf5d9eb2b423b9837e5adc86f92341a9ce211680","lib/libwinapi_onecoreuap-api-ms-win-core-perfcounters-l1-1-0.a":"9315a89cd14353866fd275198f8de1d1cf4f6b65061c5cc14bfdcea77e63de43","lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-0.a":"10c02c555b6dbdda7b9ad0d92b84246e3b1184c6cbbb2d0f7084895345c05fea","lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-1.a":"f92d83afc6664e46a881ac5fac52d4fb6964e96eee2e30cff6322cea97c0bef7","lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-ansi-l1-1-0.a":"09464dc83a12cd3c2d0853677087466a4204f31bda5dbb281988626b5e40e199","lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-1-0.a":"545f03e2c75ed3c32169a6c434613a48b62302ff7331c473fb91b17b605e6cc5","lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-2-0.a":"ee3e0e9a02a6ca01167b1dc76d9fb3424189407e4a847e11627d3864159bcac1","lib/libwinapi_onecoreuap-api-ms-win-core-processsnapshot-l1-1-0.a":"df1b934538dc0a4f882494a1c8abdf48b0d53a4e438178efd467e1cfc4a4d81d","lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-0.a":"ccc89a05d8d0c99105e6d0ad1fbf2bc38f2892892ae9d15f9fff407311571246","lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-1.a":"d4cb12d32b81cf5705686ad082f02029d92db818d7efd8b207d36541764637dc","lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-2.a":"8fd3d7ea7a813f933a361328faca0e38c8b0b16b1d5520aa267662718b1b7c57","lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-3.a":"2f155c81b6e30343acdc75c552555dca1f9a8926c032c6b3acee14cff972f960","lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-l1-1-0.a":"5ce093dc8df1636e4cf347f5d51b8538ac857bf2d9722d3d99511143e781fd04","lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a":"38880be551d3f1f978c331e1ca5d8cc8b55cafa1e1871ee67fb739b9c612d04a","lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a":"76ef29dad970a16e1c40549ff34b0ee0b86bd584527f2a137b21be768ff7933b","lib/libwinapi_onecoreuap-api-ms-win-core-profile-l1-1-0.a":"dcfd4b505c08ffe79a5757fa94e09a77b1d4de56495422f057871ba4aefbb210","lib/libwinapi_onecoreuap-api-ms-win-core-psapi-ansi-l1-1-0.a":"ddd3168ed388af231eec3856534213d48bab350fa7bf4066029b0467dceebe6d","lib/libwinapi_onecoreuap-api-ms-win-core-psapi-l1-1-0.a":"41455407280d072f955e31fe23e35cb4fc5d21b1fede9c75414a9d18533a6bdc","lib/libwinapi_onecoreuap-api-ms-win-core-psm-appnotify-l1-1-0.a":"d606d6b977ec5743cffa24a78023cd1689e9a49f980f384257e1f26c45202f86","lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-0.a":"51837092eefa3cf79f2bce33634edfd16f6c2e7afc1e126b8fb2ce544eb7e598","lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-1.a":"e5238ceec5d73cabc0dd3eafe895c225cc486ea1a50d8a06f41b841d1a10a95c","lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-0.a":"4d6a1d3393cd4148b33d03bfabf78e4192d0b36c757b608e207a407c7e51258d","lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-1.a":"4c0ac153ed29cbf086eba2a213618dc1bd160bc10600651a62699e71574970e0","lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-2.a":"48b271dffbe9fd590c75a03b07b95d296846b74865a985952571a3ed767230d6","lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-0.a":"8e5364b76783a2a057e65bde14fefef76e45d75980f95bdf73f1ae85ce0a4c2f","lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-1.a":"c249ee18479948017c89cdc72319f06936766f6f4b67c44ca45f345846009253","lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-2.a":"fcd5e36aa26ff5956633691bf2fcc29597e208cbf7d990f63aab6740237e3b3b","lib/libwinapi_onecoreuap-api-ms-win-core-registry-l2-1-0.a":"5870b00b573a1af4c9027bbf4d85fe8a7d399567a0b12a37003c2f4c61483117","lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-1-0.a":"2781431bfaf5ce5ebefcca998dd8795cbf8fcd5146c116a7c987a1354f77103d","lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-2-0.a":"202e861a1b520b3240b2a29392ab6533685a4961577278d03e4a7edeb8b2ef0f","lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-ansi-l1-1-0.a":"d7658dbb5857d59b26239394cae3febae0bb3f42d08127fff44fa4ad3ecc9f6d","lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-0.a":"aaef3a002e3861a9fde26b62a8212343c6edf5fa40133be2a559dbb5e53c9a12","lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-1.a":"680ab1e2bc0ac585b7ea087dde64235a96e7b4f88bf9a09be2bff9705f6842ac","lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-ansi-l1-1-0.a":"f5bbe60a885264a82aa4d77b4615326038f66911a063f45859ef11a9aaec90df","lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-l1-1-0.a":"e6f0c4062d080c0a04b203b9bdb1444a19cff033fa605b90a419dc0881c4fc13","lib/libwinapi_onecoreuap-api-ms-win-core-slapi-l1-1-0.a":"215a69c1cbb52b067e37292b95b86de28a0648d89388ef5a15e8c40cca10f1b7","lib/libwinapi_onecoreuap-api-ms-win-core-string-l1-1-0.a":"451780a4598e947d000ff30b7eb10e360091b563bf70e20af2c94c7eec51a9c8","lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-0.a":"1d4394e37606fa4baea5d0f6bce1da43775524b0b045d7963926e110180cc6cc","lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-1.a":"d05d1992c5bcd95cd2ce7501625e634992c11a7211dd38c27e73a91502be2c4a","lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-0.a":"6ea0a007e81fa48e1fa2588944deda7385ad7c095828effb01b862c31da50a43","lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-1.a":"d9bb5b58d9300e8c02a6308ea5f00b8c4262bff684dad472a1cc2b29ea7e077f","lib/libwinapi_onecoreuap-api-ms-win-core-stringansi-l1-1-0.a":"a86890ba722cf2d6d004566cfcec8b4af09fd47b12816312a082b36c6bf075c2","lib/libwinapi_onecoreuap-api-ms-win-core-synch-ansi-l1-1-0.a":"4352877cd0720a1603f8075146fde3f099066f58aa0ec8302281321cd3d4b98d","lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-1-0.a":"5f0218f025935c7e4b65961e11eeed266492bd1f0301ce6c25ac24d002b22b62","lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-0.a":"e725dc6a2ef1d60d775efa4d343293909aa5517750cca04164bcb61d46e5916f","lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-1.a":"ac297b8eb54fc34eafa7b759bfed04dc18c93daa7f93e7f0f2cea3a7c475a7d6","lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-1-0.a":"98c68375875558c4f411a88bad4dd37a340d6e4163fc032293d711d4db0d9284","lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-0.a":"2a2fdc4266fe6b331347d856efbed6c31aef1095a2395958dfb138a22e7e0593","lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-1.a":"32db6c6d93a4d037b50116bcc7910c6225d6e8d2a3608cd394284e1823f62808","lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-2.a":"67dbe9be1cdf2767f1d3b3bec1a2c9df8f3c5eb0a975524e7556b9b0ea78a2aa","lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-3.a":"8b1afcca9eaef220bbd5d8f0cdb6e88aa9036e90fc1ee9de96c2c1111c409bc8","lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-0.a":"47cff5f175894c712e6d20d1c404090459d35d4dae53b3497d9242ef2f2d73e3","lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-1.a":"f1d4efcd0ec7d87bc7c8dda10663fe8240c8d48aa07197bec6652ed525690649","lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-l1-2-0.a":"b19ac8221162a0f9566c9eb87ce2b86e87a1910fe2a7881820211f38ee3aeba7","lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-legacy-l1-1-0.a":"ad138cfa5e31068274a952129ef479bb7119d3b42b34374644dd41e49458ad27","lib/libwinapi_onecoreuap-api-ms-win-core-timezone-l1-1-0.a":"f21e218279a75c78afc87c40d2a2b754342da2bd0cc8af897f95f8af5a288d3b","lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-0.a":"f00cc735cc566b693c5b742bfb2d2d354108bbcfe586c65614f014170d6dffa9","lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-1.a":"68359a6e23bc3f7e0b28649b2043636878b3ab9b51d2ea654af5cc0dd121d3a5","lib/libwinapi_onecoreuap-api-ms-win-core-url-l1-1-0.a":"be126eccd520e8277bfc8d6a19c4c46ba1fff311c26cd06edb74f9051ad99893","lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-0.a":"42c356e09939dda837beb51b64ba7f97166eeeda2f266cdcb6df896a04de3aaf","lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-1.a":"ba0fea23ced4dac28a60163c4e8fd09f21e01f50b7f530b54ae011052a168bc9","lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-0.a":"052ed9804659bd50c539cde044099ef780c243485a9115a69b8f63072db7a982","lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-1.a":"d9e70d125b57d17914aa6bc13eb016d7ab4f91e7000a2c7080b8e87e295707c0","lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-0.a":"bbc4afbd98ce59031aee26fa274422ad398495992645d1cfced87c9190814275","lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-1.a":"1db4d7b4c6533b76908e02d0f10c503a462cdfab31943f0dd5977cdaebe80efe","lib/libwinapi_onecoreuap-api-ms-win-core-windowsceip-l1-1-0.a":"71083395675d6a70737a536740c738fc5a78fd994f2765e805114c7abf967145","lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a":"815bde766214e8c587755e7a64b414e8c36ef5254271d349c8ccd83f572c2554","lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a":"0a81e3a58b0eea1700b4c34aa134a6331d4676af07cb95d743629486410db5f6","lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a":"d247c358caad935a249046662bd264177bc64c42bf7ee5fff3800c3bbe5a5cb4","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-0.a":"4efad1a7223a869ac244611db554b0aedd7d71b3eceb5b1a05ca86ac227f18d9","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-1.a":"18a5899b0514067a826165a2dc8b7269af1215fb6ebcb73f6d66ba5ac8cc6126","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-l1-1-0.a":"89fb7e6c8a71f2bd94e8b2c8582e364cb2c16bbc7ac6ccfd09a3d4928bc8e155","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-registration-l1-1-0.a":"3018bc64cbcad0a5e4f2971d9809fde825354fd0ae26687cc3e60360305f3eb9","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-robuffer-l1-1-0.a":"31ac7ba09d20175054ff31f9af80c08ad85c0a29be39cfc1635ed2b27e81eddb","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a":"636c8cd23dc6562b21eb38c5f669b24f35e6bdbcbbaa98b307e59c4f0f0a275f","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-0.a":"b48880147bd2d1a80250763917d241d22f5a8e3a6f6e166794981b25f844d2bc","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-1.a":"b610a885501f6cc752b489604dcba7263369c9d5bd77b2da2cab13f53b6bbb35","lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-0.a":"d142984bd3e767cdc58fcac0424531a2c2d9b9a144a980f915f4284201853376","lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-1.a":"4085cab48e40967e5e1e8e97e434b71ee99f6b61d37e0de094cf75e1aaac48f9","lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-2.a":"59db977a01e378e44b99b1948c48ac05629ade8d7a765eb9bf5b907417dda47d","lib/libwinapi_onecoreuap-api-ms-win-core-xstate-l2-1-0.a":"673a6cd40adcdec372e4f19137bbd7313590d2b15968beeba81f621c614b0ebb","lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-1.a":"2005e03b1501f8132abdcefcc57f67bb035980921ce5a2fd1b3b562a09317fe5","lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-2.a":"c2c12007510ddebfd1bd0e728b5d2c22f7f3b2f1709e3292fdbef51272ea0e62","lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-0.a":"39c656589749fdf35c69a1766d78e72f7d8752bb0160ecfb420dcd90b88aa641","lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-1.a":"4b88fc33d145f75980a2c41c9e388a4b7306a188864bba2d691ef8e7b3b11be5","lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-0.a":"678c64c107c4bc675c560beafd5825486b6df2a2fc188edd8486a557ad4dfabd","lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-1.a":"bb05f6eb1f0653bb73a95f81e4ca4372cdfc4d8d5c1fd2bac77e42bcb1bba309","lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-2.a":"4d3e3af73a57347050bcaf7fc41e6d808764fa76e4a376285bc80eb59148d7ed","lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-3.a":"081c8645869cb668c6ad3afee70e2c34f195385415e709e9ae7535932f4da08a","lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-4.a":"0bb03b24f02b1c7ba97178ee8e8f3b39e6bfa55afcade1f8bd8939f3b67f55f4","lib/libwinapi_onecoreuap-api-ms-win-eventing-classicprovider-l1-1-0.a":"db1288414b42cdc7044406f9921a81c5fb186bc73312e468749f156f6f03c40f","lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-0.a":"2c79559696b2f870e4908288fa5408c847beb64b8dc73beb08cdcf0b1a40f6cd","lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-1.a":"9e94fe7e1ffb578ca39bc43b0e0101205be66e6ac43a725f07f6548ed087300b","lib/libwinapi_onecoreuap-api-ms-win-eventing-controller-l1-1-0.a":"2a063c56d77f0addd6a16e8ea6d88e1462c023c702c991b2b86736f002ffebe0","lib/libwinapi_onecoreuap-api-ms-win-eventing-legacy-l1-1-0.a":"d4cd460dcb927feceb0dce96ae90d1642c82dc529cb3ccb4589a915b25fe1c34","lib/libwinapi_onecoreuap-api-ms-win-eventing-obsolete-l1-1-0.a":"025b8bcdca89ed47485c49dde4853e5970f7ed786f69b0ab5807ec06e7bba366","lib/libwinapi_onecoreuap-api-ms-win-eventing-provider-l1-1-0.a":"7876289ee5040a3f11148aefb7b01fa202ca79cb9069da5b8caf86737b437426","lib/libwinapi_onecoreuap-api-ms-win-eventing-tdh-l1-1-0.a":"89667e7ec7dae91e79ed5fa13d891c37a8e286bb45dd8de9a8dd448a2f736dce","lib/libwinapi_onecoreuap-api-ms-win-gaming-deviceinformation-l1-1-0.a":"5fd19100b3260241e8878141cd5bd8f3617ed4c48d6b6452e14aaf08cdd27089","lib/libwinapi_onecoreuap-api-ms-win-gaming-expandedresources-l1-1-0.a":"5e1cdc4cd8cec594d30db4914b729ebe6583a6f5af036ff93a177f099ad9ee53","lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-0.a":"38dfcc7ed83bcfe38b7e905561133b27cf594dfc1fbb96fa03b80feba76ca16c","lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-1.a":"38af3947214e5d665c024c29f9f39414c943707cd9c86b87dc2fb18d2295b0bb","lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-0.a":"da3d65e5bd1915f53eec24d849e20091633a6b13f5a8d1be73388b0213e3439c","lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-1.a":"0bd2282616214fb725aeda88bd59b7091059f6f5002d52ae2e8d754d7d06ae6f","lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-2.a":"92a3e07e323a2f1614cdb421cfd140d427ec9703f8edfd2a114677246286c705","lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-3.a":"9f93f9d9abe2634fbbec022e66b9d8adc281cbcfac531c9431e041c5cf9a89b6","lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-4.a":"489159c1464d80c3fb0969411fab3f43b9aa1c285099a2975b61b28bb1875b64","lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-0.a":"297a027aba604387f23060466cd5304cced64d47052f338bc86c2af9cf687b64","lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-1.a":"fdc97903a1bacbec67e55d45b07b23bef41f4cc03a8616c5a648bf487a70e0a4","lib/libwinapi_onecoreuap-api-ms-win-mm-mme-l1-1-0.a":"a46a947a4eb895937163b34da1636c7409db1b1abd7062a48a36f3c35e8eabd9","lib/libwinapi_onecoreuap-api-ms-win-mm-playsound-l1-1-0.a":"c6aa65feeda4b5f202beadaaf82e6653dfbfe50262e3945d3d82136ab3b97f11","lib/libwinapi_onecoreuap-api-ms-win-mm-time-l1-1-0.a":"81d7edf1275352ac2fdd63d5ed7f7345fd264e352c9f52757de771e668b6e7a0","lib/libwinapi_onecoreuap-api-ms-win-ntuser-sysparams-l1-1-0.a":"7ca93f87be1e2a1d3216727b40f54af4877408697b366d7a8775fd3f0932ba05","lib/libwinapi_onecoreuap-api-ms-win-oobe-notification-l1-1-0.a":"5013e2276a50c14ee76197c6975d5e7e49477b9b94b7731b324528a43c8d8149","lib/libwinapi_onecoreuap-api-ms-win-perf-legacy-l1-1-0.a":"302d3b509146b4f79224111a98537bc5312f2b7462431b78041fd20180370ba2","lib/libwinapi_onecoreuap-api-ms-win-power-base-l1-1-0.a":"de568a8e22d5641b02b1ce215f40d928a994b5a812f7ddc6073ef990d14395de","lib/libwinapi_onecoreuap-api-ms-win-power-limitsmanagement-l1-1-0.a":"c571b5c61c89101d79153fd5e325e529746a4f935009502eccf49be2639fbcd0","lib/libwinapi_onecoreuap-api-ms-win-power-setting-l1-1-0.a":"ba367b58b92a4849b9d42358e114975fa77ae61db6566ad17b64b117767b7ac2","lib/libwinapi_onecoreuap-api-ms-win-ro-typeresolution-l1-1-0.a":"588c8f8e2a29ab4f8f42592a1a4b1bae39952e5e048ba009bb455241d94b9d6e","lib/libwinapi_onecoreuap-api-ms-win-security-appcontainer-l1-1-0.a":"91e9d15d917625efb826adbe249caf52b9374b73b69a3705590f9449f7a9728c","lib/libwinapi_onecoreuap-api-ms-win-security-base-ansi-l1-1-0.a":"e99e7d5084b34115b5857a0b0da2312c3b3bb35a19124a0fa9b6fb158df7a827","lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-1-0.a":"29177671bb7aa2dc730255cc4e9e5a776d33627908d6fa804f613d502288fb1a","lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-0.a":"3ccde6785b18b4ccb9954c58fcdfcbdc9ac956510fd3b6b5f673916e822a284f","lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-1.a":"bdd276e8ee3b5bbcd4c963a125b7aeb41f09ba78f9393b9a782e75d701202cc5","lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-2.a":"d73d1b267be96b03a77b62a0f0109ed57ca963d263c40cf0b8392376b7019737","lib/libwinapi_onecoreuap-api-ms-win-security-credentials-l1-1-0.a":"7db8b25fe27e4118a11ee1ce592ebc1ec02f311f24e4ad728a52c14bd57b5388","lib/libwinapi_onecoreuap-api-ms-win-security-cryptoapi-l1-1-0.a":"e78d3845b2d2a998071316cf02b84cf8768b4cec8c07f61ea6529b047c02e8bb","lib/libwinapi_onecoreuap-api-ms-win-security-isolatedcontainer-l1-1-0.a":"b39deb635c9b75ad994434ccb40a34ffa5a009537da8f2daa24be9e5f2e5b52f","lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-ansi-l2-1-0.a":"0e053bcb2dfedf93db1f0d1cc10fa6376291c74fe42d0632e446e651d4bdbfdd","lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-0.a":"ea06cd6eb2ef5f91ce5842db474e25d932f6ea9a2308beed0987b1d87cecbe33","lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-1.a":"7ff8b66d0cae038647b654a51971c03cb68dd2d276367494a42e12c68329e43a","lib/libwinapi_onecoreuap-api-ms-win-security-provider-ansi-l1-1-0.a":"55a1489c8a5fdc42c9c8837e9a60fb8ca846437bec53f15a622c273b5383ebfc","lib/libwinapi_onecoreuap-api-ms-win-security-provider-l1-1-0.a":"90fb932b6acfb04c18ad578d21e92d650bf85a533011cd0a475d0ec82a59bc2d","lib/libwinapi_onecoreuap-api-ms-win-security-sddl-ansi-l1-1-0.a":"a473d99ce6bb8322d7e689b15984663c800d7c1f3e67d1b3c5ccd9d96b959c88","lib/libwinapi_onecoreuap-api-ms-win-security-sddl-l1-1-0.a":"0ee760ace08e164fab85f820006ce8815044fc433231d68b6e9c3d159443acf6","lib/libwinapi_onecoreuap-api-ms-win-security-systemfunctions-l1-1-0.a":"b5c6e51d36999fc72d7522530cc2bbb0f217828aa95b32bc6c08392ab66e8af6","lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-0.a":"00237c5c1db6884ce4838160ed785152cb40c41375e7b1629c681aea13adcd60","lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-1.a":"80b7b1504cc24abe588f7ecd0790eedcb8b2c211ca663cce314c076f09a1b670","lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-0.a":"db753a291d09fe4ec26112375fb6373b0aabed532d410b70c6ed24f23a51308c","lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-1.a":"a781ed18c9c34337d5a4371c8a462b6113513e948421ff05c66aa6e75a769ea9","lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-2.a":"034bc5dc8aca49021307759180266ae2356027122e448881c2802950afcbfd41","lib/libwinapi_onecoreuap-api-ms-win-service-management-l1-1-0.a":"a519ae4dc74c73a907c6eacc0a139c6d711dc197bd7ca20156d0b1b0fe3fff22","lib/libwinapi_onecoreuap-api-ms-win-service-management-l2-1-0.a":"aab7256caa9592403af60bb53576826db02ab98ee3ad159f28d7cc07b3b26ff7","lib/libwinapi_onecoreuap-api-ms-win-service-winsvc-l1-1-0.a":"e5cdb3ca221f979bf4a95b18fb6e10f37c8b5528ea2307a3aab168f05ef7d78c","lib/libwinapi_onecoreuap-api-ms-win-shcore-path-l1-1-0.a":"25745fd8cccea13271fb1e5bb77ce8e586fb6373083fa85c7643ca889c826cd5","lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-0.a":"83d9460385c14ca2b1c2d31cfba4a6f458c26b50ae6a881f69a2ada5438c0d8b","lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-1.a":"afc589549c805deb270fba1858895303b8c85009a5ea6f8a8ee851f2ec1fc435","lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-0.a":"b55fe6d9d8fc9ae5caaf6dcd600d9e85e2565a5fd7d2ad935ac718ad071b66a8","lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-1.a":"cff41a245275ce4997a00cbe133530bd53a2d1e11478bb0916216e04d9f3770c","lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-2.a":"0789a760a1eff7954397e0c0bbf6a4361d207e768ebe7462408efa2bfe230245","lib/libwinapi_onecoreuap-api-ms-win-shcore-stream-winrt-l1-1-0.a":"912b8527edc807990ebe2e9b2d897f8999d2f46afa0f18a40a1f95bbb4da7260","lib/libwinapi_onecoreuap-api-ms-win-shcore-sysinfo-l1-1-0.a":"f93089f8d3b65e117a7e2da3a070c21020f17ba7fd4896007b49f835db63ec65","lib/libwinapi_onecoreuap-api-ms-win-shcore-unicodeansi-l1-1-0.a":"09a8c1c51c429f9d1372fa8da39e5347b04936ae4b91c9b42d5b7717289575b7","lib/libwinapi_onecoreuap-api-ms-win-shell-namespace-l1-1-0.a":"818744fc89764f3cede4ce7705477aa08f9b5fae7c268f7fda7a51632eb4ba4e","lib/libwinapi_onecoreuap-api-ms-win-shell-shdirectory-l1-1-0.a":"d9eae63e869b060ca7baf0d11636cd364ffed32d82e539ca49910708ac070ace","lib/libwinapi_onecoreuap-authz.a":"b0087e02bdc1ba5a6b604507ca7a0b4adc4911898edad9313fbbbe31ab5148f8","lib/libwinapi_onecoreuap-bcrypt.a":"4dfc5046f245c441eb73374f223191a4d31fe9e298f9da0c250deddf7e63fded","lib/libwinapi_onecoreuap-cabinet.a":"997c70e81fe1ee8aae77a783f8c22d113e0942364b79e6fee59ba98e88a6e28c","lib/libwinapi_onecoreuap-chakra.a":"4da85e72edbc4ab7f5f203f4721d062fa292706cb8a8e20553e5cb3f29f311d5","lib/libwinapi_onecoreuap-coremessaging.a":"e6bf985ee95bfa007e76fe4af6e692864afe304b598e284666ea99fb3e0c2e70","lib/libwinapi_onecoreuap-crypt32.a":"8f2f9990ef20feac1f86fc2fd53d0446e3bbff05e89a5db3d5040df557e129d7","lib/libwinapi_onecoreuap-cryptbase.a":"85deea089b92e7af4eb762b2d2ec37be6b7cf7becaeffbcb55b98b7e5158a959","lib/libwinapi_onecoreuap-cryptnet.a":"898938fde8b3a27249816d93ac806bdee05000fb4d154da57b66bcd9f0ef5c49","lib/libwinapi_onecoreuap-d2d1.a":"3f5e8bd1c3efed072f2b800c597b883e911a3688e008b3f61bf65329e001e230","lib/libwinapi_onecoreuap-d3d11.a":"16286d720860c65476daf0e1a2edd456a53e794881edfc9132f8f672cb6de336","lib/libwinapi_onecoreuap-d3d12.a":"275cf82ad1dadc157f6451a6e1e005115c99503a005b4b81f3c11c7e82aedc65","lib/libwinapi_onecoreuap-d3dcompiler_47.a":"69e4e84582ceda25cb6ced4da20a35f0714a174621a04eb781eb66a296ef900a","lib/libwinapi_onecoreuap-deviceaccess.a":"7e623da399c5b7ffcb22585fab44f19e9c6883730d58eaad12da4e62e683047f","lib/libwinapi_onecoreuap-dfscli.a":"ca27fe9acf7b684586eeb5adee70e3481da216d8a50fd040fa2cb90f03d8c3bc","lib/libwinapi_onecoreuap-dhcpcsvc.a":"189dc2186e79e0d69ba477ac57997d358697b6875e39068d28bb25e7487da647","lib/libwinapi_onecoreuap-dhcpcsvc6.a":"3cf7fa8066a4705acdfddf0b8807811eda2504d37e3cda9d4844b5307d0004bb","lib/libwinapi_onecoreuap-dnsapi.a":"0b23ce68f4dc3215ecd833f8fba9c0ae9dc3b65ef52eeca247dc2733c7858545","lib/libwinapi_onecoreuap-dsparse.a":"b1f3525fcc509959f68094b613f24fffa1ca79a0421e5e0700fa743fc22382e9","lib/libwinapi_onecoreuap-dsrole.a":"56a7e387412285e2be1aa2a9abeb58dea338d2fb952ca45653ed404edef4f6e5","lib/libwinapi_onecoreuap-dwrite.a":"7d70b0cea50eedc373bb21b0aedf0d37ca2073cf165a7a20024a3d8ec4b6f040","lib/libwinapi_onecoreuap-dxgi.a":"296c5520cad1dff933e00a3cce5f0c04a9bcbac7eedca01410f3cd5270cefa12","lib/libwinapi_onecoreuap-esent.a":"ca9b7ef4d8260391d985d6faa9778880d2923d5dff5808581ca15ef851c16a80","lib/libwinapi_onecoreuap-ext-ms-win-core-iuri-l1-1-0.a":"c21683fb91594c9e41a64bf85427e4dc2841817cf28af76db288109bb98f1607","lib/libwinapi_onecoreuap-ext-ms-win-gaming-xinput-l1-1-0.a":"0d6c985cb498bbad3aa7b8e4d838ce6b2e198ce51b62c411c557fd32d7ea7822","lib/libwinapi_onecoreuap-ext-ms-win-networking-wlanapi-l1-1-0.a":"daeeee3af2d3fc5604db26ae3944d5da419c2fe36682835199a7d67b0e9335e3","lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-0.a":"6db0f416b2e2b41c16c13083acf107c966f878736d669f0b6bb4e434fbe56e5c","lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-1.a":"f1a8b3c486a9deebe4ceaf19b5e6abe2854e7583565a52d00dff0e90efb82b40","lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-0.a":"af6153478f9ecd5351c8177172037b5b88717c8cf3af620c8ad0f36655fc0fe1","lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-1.a":"42e77d1277a6c9d8338d228776e773baa7402126ea3414e0578ca4c2812e1f83","lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-2.a":"b0bfe4bdf945ceafd3e2555f933c6ed2890558094573b56c641468089ee2d0f8","lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-3.a":"02f0d2d6e6389be7367468eb30d1dc8c096b6bdfcf7150799a1ec05a88094274","lib/libwinapi_onecoreuap-fltlib.a":"b888de58402865fc62b30e12161819e454edeeb81469aceb8bb537954e64ea7c","lib/libwinapi_onecoreuap-hid.a":"e721b5f6b4a14311c2989b3061daa6ac4846ef52f20ea0aa8c1cea8d452e9af1","lib/libwinapi_onecoreuap-hrtfapo.a":"e508ba82ef44b6eb4d598e7541b54f3a1d2f7dc09792b68fe9698b41844bba38","lib/libwinapi_onecoreuap-inkobjcore.a":"1e322dd27abaf96975a65c5a192ef8ee781964a15f0ce874b3c846720d768a5c","lib/libwinapi_onecoreuap-iphlpapi.a":"af8e1d386d8c772e58656d2ca189e35be48485bdd4cca82d0f0986d7cb256544","lib/libwinapi_onecoreuap-logoncli.a":"2b9fd321ddede7d228d2827338aea5f96ae3fc029791a5667389e4be89298934","lib/libwinapi_onecoreuap-mf.a":"a7eb11455bbdc1cbce6e76ae8deba2ff2063fa522378f2a6ee7fd51af60e2ec6","lib/libwinapi_onecoreuap-mfplat.a":"0c29638fd4287f7ecd0e50e3deb7f90c6ec742606301c648426b511f811e74da","lib/libwinapi_onecoreuap-mfreadwrite.a":"a8a5a490c6f5c0c65c86d0ec5b8d5e85a9490f95cb6d394270512ebd729984eb","lib/libwinapi_onecoreuap-mfsensorgroup.a":"f520843b4b52d97669beeb7ab1b909ad28d486468eeaa322692e7e46131097f6","lib/libwinapi_onecoreuap-mmdevapi.a":"45b7bf35c10cfc14a5e583befee0ea1b941f21284c1fd1e151dcc63a8dd2c0ea","lib/libwinapi_onecoreuap-mpr.a":"97a29ac8014e56c94128d495f833128fc82ec324f4a6422c9904f7be563669ac","lib/libwinapi_onecoreuap-msajapi.a":"387e2374ef7c7811f9b2fad493715bc2b4222a61c51780736ae1ff5161cf8227","lib/libwinapi_onecoreuap-mswsock.a":"fffb40fc34f6d1c814c708a8538cae9a063609ff00d303af8282f5bde64392ed","lib/libwinapi_onecoreuap-ncrypt.a":"92784794cde4bd1740b5a05c64dcc5cef5d74f9b0de75e5896f7fb93fb71793a","lib/libwinapi_onecoreuap-netutils.a":"479cb4ec40e4cfdd8922d2faeecac43574878a6aac4b79a40dab9ca4e06e8136","lib/libwinapi_onecoreuap-ntdll.a":"1d595844847f342d4aea12a72244b6a026c59cc1bcc53a22f897851ba3d7d78e","lib/libwinapi_onecoreuap-oleaut32.a":"b7cd9486d641252ff347d2789b5056eaf5e6aca133abf55f038d03bbe30b5cdd","lib/libwinapi_onecoreuap-powrprof.a":"ecbba8769819c8e4b875e811e6b16431ae72823eb1ecdc44ef6c0edd20ba251d","lib/libwinapi_onecoreuap-profapi.a":"6ca6834e6f360fba79663814de78f063cc66c91097a5022d38487d9ebeb17418","lib/libwinapi_onecoreuap-propsys.a":"06693d40f11365d3c5d02820a12438a28bb6bc303ba963de8e3db794db8b6d0a","lib/libwinapi_onecoreuap-rometadata.a":"5ce482d52f176128e7e21e21496e3a792b9aab7257d86833052f2a4d438d1881","lib/libwinapi_onecoreuap-rpcrt4.a":"a2201586d6b38834a9b5d6365f1370c223464dd00f02b4cd64f35cd6a818fdd7","lib/libwinapi_onecoreuap-samcli.a":"42de91bef47de2bacc6bbc87d8eb08539755679946a0e90b0063d85fd3271427","lib/libwinapi_onecoreuap-schedcli.a":"9b02171c8ff00202939861898e19d8b2179253174c2b13d5aa1cf7bf442136b1","lib/libwinapi_onecoreuap-srvcli.a":"5f4200132e924a3eacf5062efce801cfb013936cc2367dab171259a690aae9f8","lib/libwinapi_onecoreuap-sspicli.a":"0cb8421e125bf93af55e64d181013a57f319d6a2e789eaa01cd9bf77272ba0f1","lib/libwinapi_onecoreuap-tokenbinding.a":"4cd364aebc64795031bf77ace65846ff78b9a9b276ff98ee470ee446d2e4cc08","lib/libwinapi_onecoreuap-uiautomationcore.a":"2a3d7e26b81d7c5c16a430080a5b770ac4f29644f7fb881e073c3b5d26764105","lib/libwinapi_onecoreuap-urlmon.a":"174501cb43a18a7f888b1199f59e65417d63c77a548d0dda237ecffd5c324d17","lib/libwinapi_onecoreuap-userenv.a":"53949d2d08e0281903b926ece14d552864384875c0c2910f4b78013c59d30d78","lib/libwinapi_onecoreuap-webservices.a":"d4c2dafbd1940dd63a0650defdfe1295a52ee6578faacdfd5291f89770417e6b","lib/libwinapi_onecoreuap-websocket.a":"ef3391e989003ca6f0b2f5564cf50c96f7b7137d6a4a2f35646beba83368f474","lib/libwinapi_onecoreuap-windows.data.pdf.a":"1dd8dfa235ad8ac7dfc5bb180677a684de59f5db8ed5bc1f971504cdc2c296fd","lib/libwinapi_onecoreuap-windows.networking.a":"0efeb95876b2cdbca86d0ca4bd9f9779356a99b8ce6b79c082eb081d0ea6cb10","lib/libwinapi_onecoreuap-windowscodecs.a":"27283a7ecf13a918f0eb64dc8661098b8f4c99dd19418f23813c1f051ec16bd8","lib/libwinapi_onecoreuap-winhttp.a":"cee254504e5d88ac2fdac8a27aff6cdab52007e25ba9a88288d9e1e10b06badf","lib/libwinapi_onecoreuap-wintrust.a":"c310ffc6b7dbd2f2d94ba4f2b9be475a93e4ae2ee58fa4d0a3d01de3c12d12ef","lib/libwinapi_onecoreuap-wkscli.a":"e8831fd954aa9673eb5183d09160fd55aeee64d57ce99d93d33558d67973f371","lib/libwinapi_onecoreuap-wlanapi.a":"943692ec7c733dd0bd784f7fbc11d62d5e2f6d7372cea44d16054e92b78e650a","lib/libwinapi_onecoreuap-wldap32.a":"e589d481a5145ea87bb59092696c1208334333174e1b5e263ceaa0e4467a0cd3","lib/libwinapi_onecoreuap-wpprecorderum.a":"e79472031220317c981ee91825bab52852a0abd28cda89384cba1eb35b5c2cc6","lib/libwinapi_onecoreuap-ws2_32.a":"01d39c4c553d30d52266a44e0f6cd51aa13a4455d2ebd5ffd8aac506a572124b","lib/libwinapi_onecoreuap-xaudio2_9.a":"c26f6eb5ffcb6a9d0f6fcb1a0094940bc158bc983e18b2c4a68c78fb11921f2c","lib/libwinapi_onecoreuap-xmllite.a":"87e3282045b56f24691c48f3f317dfa1e75ccf2590cc3e64d6da0f93b9a9a961","lib/libwinapi_onecoreuap.a":"f2e1e86ce76b7aa86b93da35edf53d1811e8d52a10fe14de3c561d863834b116","lib/libwinapi_onecoreuap_downlevel-advapi32.a":"25951e37054b4a39380286855db8e8adc0faf7eaf77047129d9368fa195143d6","lib/libwinapi_onecoreuap_downlevel-apphelp.a":"08116313490555530b7b58cc3f830f95e0d8ae65dd645086be4dd379e97ca945","lib/libwinapi_onecoreuap_downlevel-comctl32.a":"86c35f513051d4f485822b57b0ff902738b818b6c6bdc1224c75db56d0a34225","lib/libwinapi_onecoreuap_downlevel-comdlg32.a":"b748579f6f3ab5976261d45247af5a3fa9295ac420d54c092cfbc97f7a207bd8","lib/libwinapi_onecoreuap_downlevel-d3d10.a":"bac5b376a858f0f2a4b95b21c44f251b114a767e58c09b8cf572fa66f93f31a3","lib/libwinapi_onecoreuap_downlevel-d3d9.a":"3824e7e31b12918efee786e170d200a1b920e19dae6a5d9e39c646cd8d3eb2c2","lib/libwinapi_onecoreuap_downlevel-d3dx10_47.a":"81e84968bdcce883ede84bad6d495bebc3303adb1ca7d70fed9e3d74c191413a","lib/libwinapi_onecoreuap_downlevel-difxapi.a":"1bfcf44f7098ba291c6899ea4bddb95ba2f7b0b93c4ad285bc83c7bef51e0243","lib/libwinapi_onecoreuap_downlevel-gdi32.a":"62fe9be7e7ccd0e47f415567240aa3fef909a6875145987c1ab4fc331a1e0106","lib/libwinapi_onecoreuap_downlevel-input.a":"fc7400b5de73bdb9f6bf313ef474b93364cddcdfeefae79d5eec744ccf6c20f6","lib/libwinapi_onecoreuap_downlevel-kernel32.a":"56bf726b936fd50ea3050f49eb1bbd156329b492b1dc9c843b1ffdda80a9057b","lib/libwinapi_onecoreuap_downlevel-msi.a":"d15452e3e099c2a5991c0b91760f4aac5eac944fe69f286bc3c63024826263f9","lib/libwinapi_onecoreuap_downlevel-newdev.a":"4210387641e4c1bc745ff9db429c1c572c81f8014cd4379bc00d8a1c6496bb10","lib/libwinapi_onecoreuap_downlevel-ole32.a":"e67f5790d85b1ee77263149e62a0f5b661b386c1da7f240058a4518354aa9edf","lib/libwinapi_onecoreuap_downlevel-oleacc.a":"ff9536113d3213fde19cbc9d0084fe031949d9705ed28a5338c5001f0401037c","lib/libwinapi_onecoreuap_downlevel-oleaut32.a":"2706f1dee8865df8adae8719b067b89ecbc974b5778c459c109cbc08162319bd","lib/libwinapi_onecoreuap_downlevel-oledlg.a":"eecb3aab1378d1c45d7e9aa7729e43c1b5717791770de9192230347cca902eb0","lib/libwinapi_onecoreuap_downlevel-pdh.a":"73820b4cc0348960c714080473696ceb67d89f0f570258ce93d52441e029b7a2","lib/libwinapi_onecoreuap_downlevel-psapi.a":"570746d0a825bdeaa71a7dfea67bb32657a27f5afe1624944750d209329c14c0","lib/libwinapi_onecoreuap_downlevel-resutils.a":"397de845de00297801c927c5d82d0b91bbcb2a0cda70066c817fbc5236123db9","lib/libwinapi_onecoreuap_downlevel-rstrtmgr.a":"827d5635d748a418dc1731ba057aa468725e907bfc9e60d6724adb1ce9bbd2c8","lib/libwinapi_onecoreuap_downlevel-secur32.a":"9a70ba1ced874cda827fe98af149b3d451adfb360c88c31862ed306a998f5f76","lib/libwinapi_onecoreuap_downlevel-setupapi.a":"0c82ad883260fef3f91ec1d7c2c5cb4677d26d091487fec4936f9f988462e720","lib/libwinapi_onecoreuap_downlevel-shell32.a":"bc7513e499984e3f43c2f9486f9ab68c9acb905e5f97bdfadb0f5ebbba1c4a46","lib/libwinapi_onecoreuap_downlevel-shlwapi.a":"e2b37f5820ac99c7532245623b5d16f5db7befb2e6b806070b80833ab74f1bd2","lib/libwinapi_onecoreuap_downlevel-tdh.a":"13dc97358c731f00d2a6ee35fa4cb0982b45dd4d2714048a4804d7f58e76a49d","lib/libwinapi_onecoreuap_downlevel-twinapi.a":"b86c1a5e36f38a9c0f31e682dc7f9fda58959ec0ed42cfeb9c566404c302d598","lib/libwinapi_onecoreuap_downlevel-user32.a":"c3179b1306b79d96f0b9b6c6c5626e17980514a87b805a4ccfc2857b187b92b3","lib/libwinapi_onecoreuap_downlevel-uxtheme.a":"7162baa362708a6f74d57bb41176537632aee62a1f21114e74e0d3137e28709b","lib/libwinapi_onecoreuap_downlevel-version.a":"250eb5e293a7615f14527959102ff12ba330964b81396d27c53c56231a955ed6","lib/libwinapi_onecoreuap_downlevel-winmm.a":"f5ada9831b7910c5a8242e24bd8cd212b522badfc4bfb264b703e0963a1225ae","lib/libwinapi_onecoreuap_downlevel-winspool.a":"f141ba828f5e27d4db6cb679d3bcdb27a558ee47ac1534b6ba89c199e776fd27","lib/libwinapi_onecoreuap_downlevel-wtsapi32.a":"5329f116b8eeb756c67230eb4a0e596d0a9e1ab0f13c934a0ba73f2dfb8debfd","lib/libwinapi_onecoreuap_downlevel-xinput1_4.a":"6608aab2240b67bb31862a6937f30a444f31d241ac7879db950903ea9a4dc946","lib/libwinapi_onecoreuap_downlevel.a":"27eea31922cb3fd8d246e99c301bc944cc7b533b4a7cbdf5df3576bce26f27a2","lib/libwinapi_opengl32.a":"a21d2c9027b5e12b0a301d91a342d1e0c4e09f1b17c0e9993516d6afbb8588bd","lib/libwinapi_p2p.a":"e326c9adf1a6a7463a07ab3d12d892b6e1742a68ba310bb0c79a3a3f15455336","lib/libwinapi_p2pgraph.a":"00450a6a4d2150ee58a953aff26c2aace3164774003634df2cc6cd4ed77d5917","lib/libwinapi_pathcch.a":"1afac1bcecb5829d4cdb6578781c90cd0df0e2bea8451eeae90530ef3d4572cc","lib/libwinapi_pdh.a":"d6c7f04fe2c3644b991b01158a2c4adfd7be1dbe92586a4f23a06399a6463d62","lib/libwinapi_peerdist.a":"8d76c8fdf7ce8ac440e870f58b41b6dcf40f76195f47dfe9af73dc56e14a9407","lib/libwinapi_powrprof.a":"229503fca740daf72ab00d667382ba9c7fece889e3cd1a71a3489acb75d72ddd","lib/libwinapi_prntvpt.a":"9ebba37677a82b045e82158a83c97b9f0e85c35b22d4685d56d39aa39c2b6d0c","lib/libwinapi_propsys.a":"772ef5cdd2543d6154e5ccd3e0e56238418cc26439668129a89a08018d07d323","lib/libwinapi_psapi.a":"6229c9845a705e1cf162d4d4c7d1c6963ed6984699295956e98c4c1387547328","lib/libwinapi_quartz.a":"e696d2cd3294d2440bbab92718f63af882414f7cb1df2b5a9e13a8900f327e76","lib/libwinapi_query.a":"f7db7da06e63f535f0af57a9b45e8d15c366b362afac56177765c137f46bdaa5","lib/libwinapi_qwave.a":"5454630cdf31cdd56e607f2c7bff2bba2d24ba2e00e0195e334418a7108e6f83","lib/libwinapi_rasapi32.a":"c4fac15981c0415e61104ee04de7a020735fb1ae53e684a7ced3f4be3ed95928","lib/libwinapi_rasdlg.a":"ed56000994e9e730e3926719d077e5882c316ddb440326ef7fbd77739a3f6c35","lib/libwinapi_resutils.a":"0dc8ca17810cc24f67330e7a60884a5603eac4b2701c3d7145e72ce26063523f","lib/libwinapi_rometadata.a":"112b0138a0d51f185ad2c8d7a996a96407b43509137223b9c09bf564df8d8990","lib/libwinapi_rpcexts.a":"b6ede0532c9e73afff9f4671c3047a33d43491088be0f65a9180f1e37641cec3","lib/libwinapi_rpcns4.a":"37c556274e43e069010547feecd4aabda21dba5d4ebc6ac44f8181bc72c082db","lib/libwinapi_rpcproxy.a":"081bebf46536fcc39e5a3502271c699f6954ed73ef5df0039f21b198053403b0","lib/libwinapi_rpcrt4.a":"ffa2d37f78b279cb94983f4b5bcf119b2eafc0b0eec6e454b3d314ccd79e58ea","lib/libwinapi_rstrtmgr.a":"628be186aafdaa96bc203f45a5c5f44418158886522fe48fc1c58ca2c11b1615","lib/libwinapi_rtm.a":"8e7d04db58dbb4e482fd83fb704afb44f79bb306a2671bb1cf795d75badeb52e","lib/libwinapi_rtutils.a":"4192a21edf7cbc36c094a91ad176e380ec7bd678419be3d2bc82a417485f559b","lib/libwinapi_rtworkq.a":"cf81238e5438972bee626c9a220c037f0fea65b13ab364617c35f00a2623a61a","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-0.a":"c4e388681f040fbe1ab6553fb23004b647b5cf6162b41e2d00976a033d1288c2","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-1.a":"1cb7108bd745cb6976f17119a2a4cf7c6e394aacb041946e9392185919589043","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-l1-1-0.a":"ea568779a9686d229b704fc0b55b09c01d231474bba2e3da89f0ac984f5c925e","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-registration-l1-1-0.a":"3ab533f82dc0809199c2f5832c4990479dd318595db52ffd6454b4163efc043c","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-robuffer-l1-1-0.a":"7a072baf8e59a84da283db866eae3759fd5b7b189b95c6fd9ddef1fc09b29b4d","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a":"d99870cde4fc641fe7fa82d9407cdf545c8418be12fc8a23c743970efbd8a458","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-string-l1-1-0.a":"e0a04ed845ee40af3ed6dafb8ccd6d5a4a02b62cb3fe711244c245482b168769","lib/libwinapi_runtimeobject-api-ms-win-ro-typeresolution-l1-1-0.a":"0374718fe78077f795409e34ddd72ecd859531db0b8299e32fca799133cdc611","lib/libwinapi_runtimeobject.a":"72696bdf24b57c25bb32bd8c4d2673625b5c7ee72c7933e4b95f907198b85b55","lib/libwinapi_samlib.a":"60d825306f7f501eec0c814dd5083f25cdd60eea31557a158708861ce87cd9fc","lib/libwinapi_samsrv.a":"7fe3c2d10a98985f2798360f4e54dd8acf4f0cc6c595f41b6b9c349669eaf3e2","lib/libwinapi_sas.a":"671ce72d72339636993a558b07c77706a99ffa568fb9146a93dfd08c1afb79fc","lib/libwinapi_scarddlg.a":"067d27d48528d706acb69b3c5c65f54350ff60c4aba6dadd15a84ec073e5225d","lib/libwinapi_scecli.a":"6ee7ee37fe3b701239a7fd68a251926e436dcce30738911096c023923f7a5fec","lib/libwinapi_scesrv.a":"506ad42e7752933622d402b9f2a93b2df9594e72803e0b5a3d0fa59408b998e6","lib/libwinapi_schannel.a":"191033c5eba0a29d3fede1a466cce4d2e5f7ab092b26405996e4305e33e14556","lib/libwinapi_secur32.a":"da204b8aeafe5d279a7a0a0951525685316cbb9a42055d129e2e245e10b65ec1","lib/libwinapi_security.a":"1be744253e860d65ccc2e692b572b7049b86d9211a7605da32ba6d3c64519a1a","lib/libwinapi_sens.a":"693fe45c5e369acc65b45b4a9674b766e1a898169791ede962c0995e532dce3e","lib/libwinapi_sensapi.a":"4f0596c3eed566208b21900679770ad1efb8eb566f5537feb31d68d43a15bf79","lib/libwinapi_sensorsutils.a":"2ba2441022e5ec201e4241cab6231441576ec078039052a75c4e10fbe2e0fe3a","lib/libwinapi_setupapi.a":"063417b0069302c187ede7df0f60b230941d4689addcfc0485795aeda5dedd18","lib/libwinapi_sfc.a":"1e78e5a5d401237b38560a9ff6b1a8533d6090c8b3d215d81e049477698e2520","lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-0.a":"98344bc027a9dd80dbf08a575dd1b6fc97d97e02c539c1e20f22c757a68504eb","lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-1.a":"04c2e6d47229324177b05cbd600190d5b2abf3ed228ee6e03fafef2db892e7b1","lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-0.a":"19eef865f78baddb60fc1f47289df74a07b72083d28ca68b85941c99ca550c80","lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-1.a":"e166a6ec67a36b3f2918be018977a8159b8635491b55605cb5dd3167386d7e8a","lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-2.a":"adf03c5853efb9b41d617cec9ebce4078cde77070c0bc2b3d325afd335a7fc6a","lib/libwinapi_shcore-api-ms-win-shcore-stream-winrt-l1-1-0.a":"632993df8e26c359cc5204b9e8daa13387a0aec8764f17556e41967550e4dc4b","lib/libwinapi_shcore.a":"0aae36b16b6c0fdba17f39f73cfae64d856ba9aaa06b4f1fca2437aa11c1c4c5","lib/libwinapi_shdocvw.a":"4bc14620d0cbe176991915bff0860601f62fa19fd08799b577eadf8b7587fdf6","lib/libwinapi_shell32.a":"8986ca544482cb3fa6fa4dbd0fbfa0fbd675d84623b902a6b107ff6983d0be74","lib/libwinapi_shfolder.a":"40b4ef0df707e9fe84490a5517b397bbf35df2f11845c00fd65ea5ebe327e0af","lib/libwinapi_shlwapi.a":"56f5b4b9aa857e7e2abec5e29e90cb604c30e0e378a217f5c63d0749ace2c378","lib/libwinapi_slc.a":"d1e968e1e2cd1f5517a0cb292d1bed0de352c3eb7f08a03bc256b6c9898bffde","lib/libwinapi_slcext.a":"3f435fb66d862b437381e155de17116bd25dfc3cdabbbb979e52e9f17eafcf6b","lib/libwinapi_slwga.a":"0daa0bb484b78fda78b198b0a1fe8e1ff01f2103155fb96396f76735540a392d","lib/libwinapi_snmpapi.a":"5fb36e79337358e343d2691a27e04e47b584c21869da9c4ea0cc04fecb851b4b","lib/libwinapi_spoolss.a":"4728dabac3364039ff2b3df5be911003ba6074b4022127f72b86b6d6bf792a3e","lib/libwinapi_sporder.a":"33bfc4229b72197bb74020eca4ccde0770512deb3eac0fb814cda40203969473","lib/libwinapi_srpapi.a":"2d074a6570ac4994014d7aa4f84f22353340541bdacb0d2033cea4fcac7d9f71","lib/libwinapi_ssdpapi.a":"2186218218995a2454dc5ffea0a3949f97dd4faad038ad2f22e09ad93e8e152e","lib/libwinapi_sti.a":"42835149c10ef8bb50e7e562af45009551003fc127278e9218d624d86a1ffc33","lib/libwinapi_swdevice.a":"16fa5d455edc79db45808633411d6eae89f65b6da1f99f775fb8c26e9edaa120","lib/libwinapi_synchronization.a":"46e1da98de3f92e2b8cf7d135e35978c418d4887080a4848a047eda81703c4ab","lib/libwinapi_t2embed.a":"f538b7f0a9add3796fa6bc18651c926c7ba0746f10d806f579cb98e734070d70","lib/libwinapi_tapi32.a":"bbc8dc40668a19af85e1782de0e994a55b2e2f4d3b073b75a687be4240448856","lib/libwinapi_tbs.a":"8bc36c289fcaf79f4c49ce8f10c28eb1e363c3ef63c6994b139b7c1ba95763b0","lib/libwinapi_tdh.a":"0dbd6204b039e117793145a6fbaed7109caa57fff41cec835977491ec280b538","lib/libwinapi_thunk32.a":"fdc3b4eaaf945bacdb88cbe5666c8717a0348f041858cad0f15d31d7bd83b6cc","lib/libwinapi_tokenbinding.a":"2067fb7f60368fe9ba420f13d508601e8c94e1c2abb5c7b831508fc54255e057","lib/libwinapi_traffic.a":"425d4da6b2df282bd8d0ca1e9626e419b2bc12d29e577bb3dc5a15dd1ddb9053","lib/libwinapi_tsec.a":"39071d6abdf019105c61f85eca91d578d2a0d480282856668ef0d62dcb12d9e1","lib/libwinapi_twain_32.a":"78d7b81b0353e749c36bcc8c07b3f4d1680f55fc43ee949d5ab84461f9ccbb14","lib/libwinapi_txfw32.a":"5e79373cfb16e47823a157305ca001420ba1f2f4cab5f52a79b71a3e93985c91","lib/libwinapi_ualapi.a":"48a778d2a2197f1921207badb2b07b6051e5ef2965dc816dc469b94eefe5044b","lib/libwinapi_uiautomationcore.a":"2247d182ec3eb1dc784f54c1bda305f9940b449047ab3c43f0dfddd308a22059","lib/libwinapi_umpdddi.a":"535ca1121764955e8c528ad0c8642d4c357afa5fa0ba28dbaf5e03cf5c60ddc5","lib/libwinapi_urlmon.a":"55be74bd0f8384c0bf84527cbb8b27601dc45b7c423809bc52760b729a5f86ef","lib/libwinapi_user32.a":"9d218297f1a130912c318391d3b159a487e6650c524aeff4656f4ac702dab2fc","lib/libwinapi_userenv.a":"8ff2850ba4437cd5fcf879d1dfcc9cbc5aef50ef205d9d397dd1a4700ae210da","lib/libwinapi_usp10.a":"e223cdb9e7a913eb3bc038f1a963c2cb4c669b084828bcf92539bd0595b62fde","lib/libwinapi_uxtheme.a":"d622c584adad49beeffe2d2641b72a31065340b16c16687cde46e7c41ac67b5f","lib/libwinapi_vdmdbg.a":"4f9390d8cda1b21a470724f85312e92a39edd5038621c0a1f051f2e83d776a7c","lib/libwinapi_version.a":"af226c499d3ec2f3aa9c128554b1a10a1d2c3658322f3137be0a5d4505d28c9a","lib/libwinapi_vfw32-avicap32.a":"516f00894b2cd61dc26b8a5d5ea59cbdf93c66a471f5aa5ab035d9629f187401","lib/libwinapi_vfw32-avifil32.a":"c356e4a74fbdc381143c6b84dc3edd117c43ad11b324d48619a40ab05e406b94","lib/libwinapi_vfw32-msvfw32.a":"4a3d662b600beddb1f973fea167e804965e1dd5cacb52a1433e1356e0418673d","lib/libwinapi_vfw32.a":"1f7bf15b2c0d637ef6a424ea0173f26d9adabb2bfbcc5711a95b408e060a7d96","lib/libwinapi_virtdisk.a":"f1e7237e523eef73b73cab8c7f9ee40b3df68f3003fd39dab9fb8bfd6d9a54bd","lib/libwinapi_vssapi.a":"0e0cbbeae26ab962bb1b7e738049e1b6d5cacafa01026aea553a37496bfd91fa","lib/libwinapi_wcmapi.a":"6d2f7593ba8c626b50f76072f07e1a49c249b14a3a8444e49d1932e2bad33f88","lib/libwinapi_wdsbp.a":"e904217b4f2b189b2d4cb2ef8f64896812e8a856ae3cb4eface35f1e38d3854d","lib/libwinapi_wdsclientapi.a":"47e5fcbbba5ad750586d102985f1f67cae7e7360fca331cbc866fff05ecebc00","lib/libwinapi_wdsmc.a":"97277aa23d70ff2b7d5d2f0ffbd70e6dabbe48d53fce30504a5176d6940d958e","lib/libwinapi_wdspxe.a":"a0668a171b4930c900c321d1d9d11e968fa4b2de32d36fa4238af8ebeeaf855f","lib/libwinapi_wdstptc.a":"ecd1ec06a48e3b98266d99a88797801a75bdc14956f92df90ec2d934d234fad4","lib/libwinapi_webservices.a":"889091e71202e8448edfaa7b02b299e9ffa8641635410eb85d41d4a41c592b59","lib/libwinapi_websocket.a":"b6d9f28c222fe4593b2587e95ab5f21a55ff16f96988a7843281b1d56548b105","lib/libwinapi_wecapi.a":"b206762c19af9ae83c0776754405b364f1aecc659d063b82f0f85a90e9ec39a2","lib/libwinapi_wer.a":"e69b6439516ddea86a7957de563719bc7a7e0794b70733659aed29d835ed26f1","lib/libwinapi_wevtapi.a":"da8dabe5e4a11e6a467c6b42c0bd193a7e097a2ff91c3b3743df8143e24dfe05","lib/libwinapi_wiaservc.a":"98af80f5e16013bc1f4a3da5a58debd00b879885d92a5c0fc90029229d20dd70","lib/libwinapi_winbio.a":"2f6275f01c300f097331fd3df333641453d855ec56d4cdf26586bd69b258bcfb","lib/libwinapi_windows.data.pdf.a":"78fc20ab685d930e28e113c2f26b8d8f137956d00c7a8406686543387a0a5dee","lib/libwinapi_windows.networking.a":"8e3c12ab2e0014c62c1d628fedf1fd2d7a5199a5b0324afb8d7c5715725ed59c","lib/libwinapi_windows.ui.a":"bd1c725946cabc374fdf6640c9e23550c05ec4309150e7cc7446cd13cddeff32","lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-0.a":"c5b0f910c4f44a2b4ccbc4f1e5e7fe61441f3035c0f654b71022c3be347f1744","lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-1.a":"921b323d3e681629b679b7afc1c83fd1c4cf8dd7b7331c59bbcaae5e42545b99","lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-0.a":"d2677e3f095cc9b75de682c89ad058e3030ed6d572b3d4d173d8a2280ef7728b","lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-1.a":"747263417baca3be11cd9746ecdc4a5204bae67f4e18bcb01989cd8fbcef33e4","lib/libwinapi_windowsapp-api-ms-win-core-com-l2-1-1.a":"8911d4bef439812de4e56f48f6a1e7fb45f345d0d165ac73e37a396675886e7e","lib/libwinapi_windowsapp-api-ms-win-core-com-midlproxystub-l1-1-0.a":"3887370abb1c93d8086c19b79e64a20be3fd0cbe0cd18e521932a66dd29991e4","lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-0.a":"0fed3d2349d58b01779bdccb151389118c253fc3788eb22da84e74d4f7fe1659","lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-1.a":"79a9cc1cfc7e68b9d5fa2413887dbaa06b174c63bf70445803f9f4edbccaa5d6","lib/libwinapi_windowsapp-api-ms-win-core-console-l1-1-0.a":"19490ac714cb91b47a0675babc6fb04b89917643fcbe748263dfb292fb3d2afa","lib/libwinapi_windowsapp-api-ms-win-core-console-l2-1-0.a":"b7df6615a287a325a92d6aeee71b8900e56b366a06f34653be04a20803e08b68","lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-1.a":"ef8097217b975f461e84bc49c995421e4655fa5905f45fd6ffab5b66a0a23e50","lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-2.a":"35f73c31046c03d050648d08d33448ae03df778fbfa209fdace98e0881a97998","lib/libwinapi_windowsapp-api-ms-win-core-debug-l1-1-0.a":"9b84a711d2f9062a84a8ae10847fc6dbb55a43fef4aae5bf822513d8e86995a0","lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-0.a":"0ea1333d7f77f97935d48cf5310fc09e21761a6bbe2ca16bf83884ab8bfabb75","lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-1.a":"61bd430910acb86c226ef8f25922ed18e181f5ea3961e8d437199de0b93c27d2","lib/libwinapi_windowsapp-api-ms-win-core-enclave-l1-1-0.a":"aae4fc49d326bcf224af545c5acc2ca73a882ee99823c010c2ce7fa4f3463934","lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-0.a":"b91bd32bb31b3bbc11d7879afbfa3835fb9e37dd95eb3a70aeecd5d5b3fb88e8","lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-2.a":"c7800772191799c701373b1057abef0884ad2b35d6361870c319a1929b579ca7","lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-3.a":"f7af10fa4da9fb9784d46078d3358caed4e5fb076a4f9e4b87faf4d69d1b1f2a","lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-0.a":"1dd99452503b5ae1b1887e6d3f4fb83b33ecd3d782a65acd776aefb208d98aa8","lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-1.a":"c106369ed8b7893b66af9822394181cab93cd05323bf770a6d6f21e4cf61f22e","lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-0.a":"30fca3d3c91ecba19fdfa03c07f1d0b34011c032b0f8fe4d35d6a26981a7280b","lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-1.a":"62fec7d91958134636b0eb473d0606709a222567c7c23c3661aea9b014d84d06","lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-0.a":"0aa99edd2c9ccfe972b8433a8d1489563ebc573524af956332257fabd8a9c162","lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-1.a":"29990a25dc42702f3b0cb7de68616c1d95bccb352c2438e7a1fa659f0056fd4c","lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l1-1-0.a":"4e3ad6c8b2c40e3fc18fbbf50ddac70e4dcbf8384def7004212eb1082aa717ab","lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l2-1-0.a":"a88c1593ae4c736332b59c35d4706f08f5a3a723234f13ccf1b88e4c1f4c573f","lib/libwinapi_windowsapp-api-ms-win-core-file-l1-1-0.a":"f79d009d3d96ec1e6141c366eab82ec9b2393a9a53d24573da11f92bdb64d8e1","lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-0.a":"cb43ae3737d19690c7590deaaec247296b4619e297d0f10a3c675cdbfb5b0b14","lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-2.a":"ec97314860cb28f6ac8e1c86be3d792753654b95cb97c01382719114e6bed03c","lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-0.a":"1b901ed918a4185500efd56d6b256f6ac1f533b95588e8bd91d039cc901dd8d8","lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-2.a":"c193e49f907ed28eadf228f1eec4f87f94ff1ded7aea62f7971ce400d9410c02","lib/libwinapi_windowsapp-api-ms-win-core-handle-l1-1-0.a":"c8965920439c950f8f5aa10d96fb47dabce00cfb583771ba3a004dcf81339d2f","lib/libwinapi_windowsapp-api-ms-win-core-heap-l1-1-0.a":"97bc9f0aabb84ac3d4f1eaccb2611ebc4c4e641057ae321823fce5bab135bb24","lib/libwinapi_windowsapp-api-ms-win-core-heap-l2-1-0.a":"f6653db4e2db6cdcf3dd5c67378a4960585b4f9d2d756d37bde43493030d6dde","lib/libwinapi_windowsapp-api-ms-win-core-heap-obsolete-l1-1-0.a":"6e0c202293a3a4d82db8e7761b3be4873934e23be1cbb5ca034e16a9c5a95516","lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-1-0.a":"0db40d463c43faf20da093c8adf7bcfc694d60ad39c703840bb3dfe41d87d867","lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-2-0.a":"4249e889356ddb2e03c71847d5a279aa9d55ab71c33af0841a174396df75c70b","lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-0.a":"139c4d1d6d7701c92c7235212ea18d8d41e3c80814d0009e7d2208456e19d88d","lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-1.a":"5b3679ae87db26dcfd813fba6e7219127e0be4164174e767dea31344dc7ab2fe","lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a":"ae2f6723973befc952038c82c5ecf1ab298a12d5a67e42cbe412ecd2cc3cb237","lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-l1-1-0.a":"bcc7ff242a65f295251e799c3981ad9ecfffa94122bc5acfb806f12368dbdfb9","lib/libwinapi_windowsapp-api-ms-win-core-largeinteger-l1-1-0.a":"7c95358ed9d08491fe9b4dcc2abe44f33a32731152aebf85600908b817aa5cdd","lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l1-2-0.a":"5f13a5baf504172298384a4f5894c4f015181c05cff13e7649b6d91709abc173","lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l2-1-0.a":"efc29ecfc1c177eae1b371304d809cd4c04e8c882bc9e8517315cc3024ca559d","lib/libwinapi_windowsapp-api-ms-win-core-localization-ansi-l1-1-0.a":"84a3683b612de399923e1ca199f504c5b6f07724ba1eb7cf31629a0ecf124b20","lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-0.a":"70a9205a700f6f4692b76897a4b2af9d962b2bef4f8985a3f8d497d3fcb42df3","lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-1.a":"5d6da3f78c52fc78b6e0e38202e7d0a14337c4e9645fcc1409d6fa8a284c340b","lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-2.a":"dd10409d20098123b9ce8cbed2b84cd80422e7c915cc6aa558f9159918e68c25","lib/libwinapi_windowsapp-api-ms-win-core-localization-l2-1-0.a":"9477d17fd1a7fa542469845ea465551f48208d1e7a20508772eec708127171a8","lib/libwinapi_windowsapp-api-ms-win-core-localization-obsolete-l1-2-0.a":"c6aa11d3471a2ac848e7f4cd166aa5c27ec40a8ee236a3041819ab95860c5ff3","lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-0.a":"ff78df5353763aadbab865dc35fb8d341108934ecb836e4aeed6d6ed239051ed","lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-1.a":"cb79f0638f79e94417b9260b05a511dff38a65484662facff84b90c3ab944dba","lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-2.a":"c6af86f6b2d53ad5e919598485e76db5c573b1723c8e8aeafd987669d83a1be0","lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-3.a":"04954fbf299df7f7a82afdfd43de1c38f3570a0e418a5d2bd15fb468641e3da8","lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-0.a":"7390ed65bd34f830f34193e07a47a3386f2ea786adc752e9af9e667b3eae566d","lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-1.a":"3e7d32bfe57a7abc58a6bab31ebfdb2135583a08779038169ae953b379813a21","lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-1-0.a":"fec51f0b6ccf8fff21613039a69d7521e6086cfcaae762a8e5eef8ac8cccfcb9","lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-1.a":"8de55da9f36c953a8eadd98ddbf1de68b6be21800117f5d81cd94ead505f9bc6","lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-2.a":"22c4a7796605757145ce1ad6346f80d34f2b85ba948b6f7cf099cf8034a044e2","lib/libwinapi_windowsapp-api-ms-win-core-namespace-ansi-l1-1-0.a":"abeec4e5001de5abaf99087505ad1d9db334f216d6b6f0a086f949705607aa18","lib/libwinapi_windowsapp-api-ms-win-core-namespace-l1-1-0.a":"2a27d24879f73c7cf97f062d62948f92d3481cd3328af42f50fe3b9fd4593424","lib/libwinapi_windowsapp-api-ms-win-core-normalization-l1-1-0.a":"9e39a5fd470276e47d539c8363e41a2990a1177b7ef50ffc8572a8901bab2daf","lib/libwinapi_windowsapp-api-ms-win-core-path-l1-1-0.a":"9ad56c85293c2b75a8bf6f7bbc27d20cddfaf4a7f4a1864b572963717d0af10d","lib/libwinapi_windowsapp-api-ms-win-core-processenvironment-l1-1-0.a":"dd1dbd548a66b9544931f37af2bbe883360de543ba2682e0a252308127ad16a0","lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-0.a":"fb9f08901b2f4bd4788054ed67a5802a16b449a7ae7c8bdcef99e7baaf78958d","lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-1.a":"a5639c7a442b6832cd55097454a35c011204919e903e69d951d959b53dcde57e","lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-2.a":"b096b4581ece69959a8d5ebfd72fd0dfb036653f9710ad2de49952418a2769b2","lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-3.a":"68a523bb89aa76d957a6273bd8cd3e74ae272663086125f6596d87b54f73579c","lib/libwinapi_windowsapp-api-ms-win-core-processtopology-obsolete-l1-1-0.a":"cdc0393343eb169ef12f81fa31beb0351656dc915c93b8f23e27f08b8a1c11d5","lib/libwinapi_windowsapp-api-ms-win-core-profile-l1-1-0.a":"9316cdffcbf672f173d567f7a92d2466824140c7eb2384953107d81d3c3f348d","lib/libwinapi_windowsapp-api-ms-win-core-psapi-ansi-l1-1-0.a":"301062e0fb6842804778b03340600c8ec456b88c5556926d493d8a04d5596d1b","lib/libwinapi_windowsapp-api-ms-win-core-psapi-l1-1-0.a":"dddea56f7b9ce98346e62d212732813f2cb1814e55bd46b1a9590f012c9655d0","lib/libwinapi_windowsapp-api-ms-win-core-psm-appnotify-l1-1-0.a":"e09456eb053d27e437f93b6cce33e53ee84235ec4bd178eede7183f914b23bbc","lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-0.a":"ea4282c8e630531123f26680eeb0106e47151a8cc3eed133fd287579d0d6187b","lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-1.a":"560b6d11f2bdc6cac22e1a48898c0715fa5f115fdf7ec968431fcc079fc0378c","lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-2.a":"b1afb018e3339b40964c892a60ad60420f3be0ed09c9e881c38e4e51c0c80d8c","lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-1-0.a":"8b680a4624d674a535b8c2c15a0ffda9e8895b5c8d166ba96dfe4c8a480c9705","lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-2-0.a":"c3620f180a6f35812cea5cfac3b7de6a539220622a45b1b3e9142bc4ae3067f3","lib/libwinapi_windowsapp-api-ms-win-core-slapi-l1-1-0.a":"29e9e940b3a2734479127e3ea4ab5d802cd8247fb203ed8524331e238ad788f6","lib/libwinapi_windowsapp-api-ms-win-core-string-l1-1-0.a":"0e00bce3914402e978d4b002b7a97fb2088cc22777541cf57a4709d75d619279","lib/libwinapi_windowsapp-api-ms-win-core-synch-ansi-l1-1-0.a":"aa18983363e672d6ba0e02edca860ec3e49327890920590fa84afa41cfadc966","lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-1-0.a":"a4fa5e25373c7c20b4055cce63617dc5b55088fe3b791b956c66bd962dde002c","lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-0.a":"e3339a7e092b42f837b920bd9bdbe925c2aa96524bade80249122090b93aab26","lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-1.a":"2a61c5c41d4f8bd0a1b2a018bb598b4105694b234cb779dd043d2b6f001fee64","lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-1-0.a":"07921deba9927172e88c9d7d247fafd36a80bfc3d7f56ca50e75494945b7387c","lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-0.a":"8ef0f417775f5f71aad900bf1d88428135e78dcc2453119a13e8276940172a91","lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-3.a":"3f77471cc4f5d6236f05afdd38d3aaec2537c73c0f77ae656a733d972c092bd2","lib/libwinapi_windowsapp-api-ms-win-core-threadpool-l1-2-0.a":"245f6cc49e7f28d23621cddde69613d08fcc3e9cdcb0f30f7bebb7f50a274601","lib/libwinapi_windowsapp-api-ms-win-core-timezone-l1-1-0.a":"3584394f9ee238a7b232e129f3761f48ed6dc08a1357840960b18dac87915e81","lib/libwinapi_windowsapp-api-ms-win-core-url-l1-1-0.a":"c93ba0c9b773af99e804414ae0cd5669edcd6d871c4422083586143a05694e6f","lib/libwinapi_windowsapp-api-ms-win-core-util-l1-1-0.a":"186cf4a8e6c5f48844488ef3e55b8b971fc487a4cae5f9f4306a36a384c31831","lib/libwinapi_windowsapp-api-ms-win-core-version-l1-1-0.a":"ea2abf3263cab4a37afe88804808c52e24f25a39bead22213448d383816bcf48","lib/libwinapi_windowsapp-api-ms-win-core-versionansi-l1-1-0.a":"e3a25f12131eb8efbbde17a6957b6ac91db0f218f81012bfb579c3491e600cd5","lib/libwinapi_windowsapp-api-ms-win-core-windowsceip-l1-1-0.a":"788f5b224086241ef514a46acd048402c26d0248ba010e5751b4dbf2739fbabc","lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a":"d70660ee6f87669d5a5be3d30498a0f8db90d47e213ef4673c9b22489aa8b8e3","lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a":"792d5c8d2f043151c658a150a2275243ad6f01eea274dbcd13c811cbd74fa023","lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a":"aedb7ca0091ecbf259e56a8ebcc191390b8a2751d6421f887f39d00522ef7348","lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-0.a":"992628a35f6cdc4e80e85b4994f0def4c4faf5b9e4065d66c180e903bfe99f69","lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-1.a":"f47f0a3c6ccf57afb975dd87be54d9a084d3758fb719f443e759bf0ae26f5be3","lib/libwinapi_windowsapp-api-ms-win-core-winrt-l1-1-0.a":"164925079d2aa31bc8d188ef464d5acaa04f557558ad227002d5ea3142498411","lib/libwinapi_windowsapp-api-ms-win-core-winrt-registration-l1-1-0.a":"abf0c280fcfd0e0a4bad6242e7684e80fbfa72aa663481a116f9b1f9b3cf2ea8","lib/libwinapi_windowsapp-api-ms-win-core-winrt-robuffer-l1-1-0.a":"c4f3a9e897910b6a82605e83d186294172f235db39364d22b82694f609d37e17","lib/libwinapi_windowsapp-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a":"dff3886a90efc4b7ed3c9c70b00353a882005e26129bb19c115ca010ebc68ff8","lib/libwinapi_windowsapp-api-ms-win-core-winrt-string-l1-1-0.a":"a1a4c84bc894e63abef803b40aaad5e5893fc3eb270e943fcefcb4eb386f5b56","lib/libwinapi_windowsapp-api-ms-win-core-wow64-l1-1-0.a":"683ecee0f94d0c6b85b8a378575bf0fdf51a6c0c6c69d3fa862beb847868b13a","lib/libwinapi_windowsapp-api-ms-win-core-xstate-l2-1-0.a":"3642f35e4c5a55deda3a44986e2481d27b3d9e546ee8950ec27c3122840556ab","lib/libwinapi_windowsapp-api-ms-win-eventing-classicprovider-l1-1-0.a":"e4043cd19d71c8a127fe349f024f8d61c3e73184bfc24c0826797aa94b5707d3","lib/libwinapi_windowsapp-api-ms-win-eventing-consumer-l1-1-0.a":"6e2ab9f1b1530861419b0e33f5f3d668248d86bebc9e0c4f2245f8d3834053e8","lib/libwinapi_windowsapp-api-ms-win-eventing-controller-l1-1-0.a":"b527178f285e0cb4697239812bd440550c256a283bd748c2cb410fae2adf0f92","lib/libwinapi_windowsapp-api-ms-win-eventing-legacy-l1-1-0.a":"3014d8d9ded6a717b207db72a80c6fc1f1b3f1f3f3f29c876da8771d43dd00c9","lib/libwinapi_windowsapp-api-ms-win-eventing-provider-l1-1-0.a":"e5944795e4f2884876ad23d27f91219357f10c7487dd814f93ea4b28c0f220ea","lib/libwinapi_windowsapp-api-ms-win-gaming-deviceinformation-l1-1-0.a":"05ee4a354736be759019d34b80abaacdd3e5f0baead949283ebb7568ab337e0f","lib/libwinapi_windowsapp-api-ms-win-gaming-expandedresources-l1-1-0.a":"16496885611e587698b8e92908770c4cd2554a0b9e69a7c813a27c907ff15aca","lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-0.a":"38a138b8bc2778de5f9dec25b0a617a58de6c1edf0aaeb03255c21fa694b291b","lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-1.a":"7be997fc4193df0e92a143c5059093518215f294c3c8c32860834f9acc39511f","lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-0.a":"81a29ddddfa1ae233ee03e8f8155a30291730d2cc6d3eb2df735026efb199c7e","lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-1.a":"057258f17e45d83448ed3bf0f4dcf0c6b8f41b6f935e05595ca8e92da5b1e5c8","lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-2.a":"ea2d90390134f09f9fdb25db1a912cc386b7e3b7cb9cd97ecf2570624f54dc6d","lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-3.a":"03f6c50bc09e454a5988aa1e42eddf3efc8eb8024332feb02b066940b142a193","lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-4.a":"68142802477c61b59281344bc37a8f9ad74c2c3af99f3043b214ffea1751b0a5","lib/libwinapi_windowsapp-api-ms-win-ro-typeresolution-l1-1-0.a":"a823078b3d1fc528b7950b508573fdd3c5536ed59d6cb15d93daf01e0d09088a","lib/libwinapi_windowsapp-api-ms-win-security-base-l1-1-0.a":"a49fe302203c43b070ce7caac2ec2714b80f4f3349c3b763e011b2b97d347478","lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-0.a":"88c3548c16f1d4a6904675ddc2397a20a3da0974ad020244309181b6410fcca7","lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-1.a":"15574beb90cd18fff8d4ad3caf30eae1726b0d910b7271b7fec7251274a3f45e","lib/libwinapi_windowsapp-api-ms-win-security-cryptoapi-l1-1-0.a":"bac4066bc55c1c4ffaf883bbe621858625503b3557f252e50a87668e79f1d824","lib/libwinapi_windowsapp-api-ms-win-security-isolatedcontainer-l1-1-0.a":"5b5457ebf554266f90dfe8d1d802d0148ecee08fc32ddb26e4395de15d86c186","lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-ansi-l2-1-0.a":"2872f87618c9802b02c02dd526f985ba6cde3f6e7cb40c9fb020bffa40a86874","lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-l2-1-0.a":"f071517edb870d01283ff286076c4c69df68c3c3cb829bd0c7f9a963601cc09a","lib/libwinapi_windowsapp-api-ms-win-security-provider-ansi-l1-1-0.a":"cd4f492580f823ab76f767eeac8d83831f800dc7e8a7f7e3ebbe43f3a54c89b6","lib/libwinapi_windowsapp-api-ms-win-security-provider-l1-1-0.a":"67d89ae227bff24b8d9e642db5b8e0998c8904e076e3b31c5a930141a8f00b17","lib/libwinapi_windowsapp-api-ms-win-security-sddl-ansi-l1-1-0.a":"b680af515fe0218cf7e604c284e2d2cc3480cd42481dfd879cef7ee70da266b7","lib/libwinapi_windowsapp-api-ms-win-security-sddl-l1-1-0.a":"4854167c5d9c7b8d34f74c3b44d6b2dba2acce0b8cdc0d109a1e469b3acc5608","lib/libwinapi_windowsapp-api-ms-win-shcore-stream-winrt-l1-1-0.a":"6d403a8601eed410c7a7f88d6748b409510f7e97b6e3a8c90289491a5c34e4eb","lib/libwinapi_windowsapp-bcrypt.a":"973d55bc8d0b6e2e122270ae600bbb18fdcb19b358dfd2272d391fdb1dd36b39","lib/libwinapi_windowsapp-cabinet.a":"e84848066eb95f124eebff7da387586edabe953d3a57f410189bd7bdb77805ef","lib/libwinapi_windowsapp-chakra.a":"63ea1fc35871431493a0a316d91c3dd5bfe8a7d8f4717520a45beb9e936c3207","lib/libwinapi_windowsapp-coremessaging.a":"b2128fc3272977ce1d2698fa32b1392074853065c99b06fa4b8c96f5d6a5483f","lib/libwinapi_windowsapp-crypt32.a":"493f49ce5c585348fc7d3b7ea08fe0af317179b5d8978e43a4a8240589470924","lib/libwinapi_windowsapp-d2d1.a":"d19873d7c58bdbb34f5b047745e9c8a1461c5704a50f826621642c9076f7292a","lib/libwinapi_windowsapp-d3d11.a":"248e78e5913704107d3d2d04a6d949eba042eddb37a7a8823e2b9fea4cc755b5","lib/libwinapi_windowsapp-d3d12.a":"b43672fff645cdc5efbba81fe586aa71e9f4382e8f18490bca8c6a6626f80c8d","lib/libwinapi_windowsapp-d3dcompiler_47.a":"1ca1d96fe7cb943aa00d403ae96920ffe27b638b092ebe6975111c07a6481268","lib/libwinapi_windowsapp-deviceaccess.a":"e9be49e0cf5cc6e5c9eab3c31663cf6878320de064dca1fb9f91c0a24ec61363","lib/libwinapi_windowsapp-dhcpcsvc.a":"9b5f1fbaab5da120ddc0c3372d3fcdec309c6fae14c1f51480a89a39b551446e","lib/libwinapi_windowsapp-dhcpcsvc6.a":"13f15a4fd529f6fc68d910b50a7ae98a8be86a6d9d8af612cea977c610d234d1","lib/libwinapi_windowsapp-dwrite.a":"ee0478385c40b02c2b1df0d79ccc2aa224dab79f44c0db04bfcdcd5ae9af48ff","lib/libwinapi_windowsapp-dxgi.a":"d6a739e1bfa9fcb0f89717af65cce753e29d8bfc59017e2f846887805c0697bf","lib/libwinapi_windowsapp-esent.a":"037e46482a2b46da13b75048f73807cfa56d5d24ef36065ed50b279bae6ad246","lib/libwinapi_windowsapp-ext-ms-win-core-iuri-l1-1-0.a":"edeec625207e515fdb625b07e7e2b38c2cd73667c6b452f4456605b326a95864","lib/libwinapi_windowsapp-ext-ms-win-gaming-xinput-l1-1-0.a":"d5433d65cfa7cfe7b171d9f917a30c35cee237a807e92659f545b08d5ee8caea","lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-0.a":"35260db55143ab8d0247cd7621a1d915f3c91dc1408aceddb77a42f5666e2285","lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-1.a":"0ee840c8dcbddaa9ee9e48e89828c35e28b3d4bf80f699154d3ac445360feb82","lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-2.a":"dea5a78aaf77341c658b482b907537469263e2f10c1e4270ca2ef7c3ad75e139","lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-3.a":"6d302c7da5ba17b2d45c55a0937697545477d728adb6cdd9911fcc7d3f7fbf03","lib/libwinapi_windowsapp-hrtfapo.a":"1b02cfbe7eb71cecdd5da34b456f781f75c6eaf3e65eaed64bb786eb44c22823","lib/libwinapi_windowsapp-inkobjcore.a":"4ebaaa0305eee0c2edc21adb68da23869d6ee9ce0fe44578e650ad83369887f8","lib/libwinapi_windowsapp-iphlpapi.a":"e75029d637f81f91e51bab5b619dec0f0c58ee1dd18859d1b72290f35984f347","lib/libwinapi_windowsapp-mf.a":"2ae013b2f8c6c95fa29aaeb71781dfb5e25c87aabd5590eadbabe25556ced7d3","lib/libwinapi_windowsapp-mfplat.a":"20a7d1940ae503602322aaa57d74ed7e5f3ff344e193085d4d9eeb43e90bd759","lib/libwinapi_windowsapp-mfreadwrite.a":"9fd47afbfb271049090e26cf0d9767e2111ef74e6915ce19a417606255a80184","lib/libwinapi_windowsapp-mfsensorgroup.a":"abc64f326a4f5834dedd23e1ce3aca75c567e4afcff9a3e131837a5937e6763a","lib/libwinapi_windowsapp-mmdevapi.a":"66958af2e7ad7e872e0051440c618aede0ee623c2e3a2e1d194af18c0218a6b2","lib/libwinapi_windowsapp-msajapi.a":"e5c98e56b11c7bda04ad12acdafedd3760fe5cfd4a7162c947cba91e1e21d387","lib/libwinapi_windowsapp-mswsock.a":"9ea5245062abab4d6f986a8c22c7c8b82d253087ed16df5697aa0779dc7d2cab","lib/libwinapi_windowsapp-ncrypt.a":"26f25244ddbc526e1c09f746066b63d8c6e35ae8fa04a6c17496ecb923277710","lib/libwinapi_windowsapp-ntdll.a":"fa8044cf86e4874eee74c9469627d9c3d4b3e75b39c0a38f6cb541c778041b76","lib/libwinapi_windowsapp-oleaut32.a":"915fbe29c0d10e02ae07ce448b8e30d840dbbb9300e877419f6dd135ba1d400f","lib/libwinapi_windowsapp-propsys.a":"051a77cba76c77027e48073af393029330ae3e67910bb1bb2ab084dd0c2e1141","lib/libwinapi_windowsapp-rometadata.a":"562dac0a8fccf405618a18bbf52e12805ad2891cddef9826cf025544aef16bdb","lib/libwinapi_windowsapp-rpcrt4.a":"8f27df2bad159eefbf5220fe431a97d3b9992f11aca355468d80275a942e4065","lib/libwinapi_windowsapp-sspicli.a":"4fef993264ee3b667928d716aa7226386f8b400b9488544eae37f751dafe4db1","lib/libwinapi_windowsapp-uiautomationcore.a":"225604ed82687fd285341fd13e50a3f12ffb4fcc72e26a9a6fac89b52ff492ef","lib/libwinapi_windowsapp-urlmon.a":"107de902b8071750b28ccd2191b0fffc2e7a0d10df269debc53d6be3a218a500","lib/libwinapi_windowsapp-webservices.a":"fedf002ca88c8808428dba5e9a02e3582bd614638518bdfd450e00dff51b10fb","lib/libwinapi_windowsapp-windows.data.pdf.a":"6a5610f4886b3f3647f1ffe3aa9ef7af27e99cc35a7d819f8af4757203707440","lib/libwinapi_windowsapp-windows.networking.a":"315b0b15a77f52a734fe128cdebd993bce6370d4c08c4f9e3ddfd6788699ad1a","lib/libwinapi_windowsapp-windowscodecs.a":"5c76fcb37ebb0fb3cb9a16211d477e59c0d3550d21c169dff733cfbd8005640e","lib/libwinapi_windowsapp-ws2_32.a":"362558ef21906aa66e1e827152ef53b227667e033bcebbde8eb1216086d50889","lib/libwinapi_windowsapp-xaudio2_9.a":"b93cb26bb1c5c49b4b835ab7115695e914fbdfa8fef19bc00c998667dfb28ecb","lib/libwinapi_windowsapp-xmllite.a":"82a0624f77b63748c2cc456408ffd9da0516dfb0e23d24b06fdaf9c29b53183f","lib/libwinapi_windowsapp.a":"dfddd13a1be53af64a03d5d473a6c2c80c747fc7999e1cad7e7aad50d887a813","lib/libwinapi_windowsapp_downlevel-advapi32.a":"b15b64350cd697ed96ebd6c59716536c69c78cb589989058c83a5d2f4e8be98c","lib/libwinapi_windowsapp_downlevel-api-ms-win-core-localization-l1-2-0.a":"565299f3aea03821f84e8052b1142225a8ac05d71808aa660e2aec78b115a3f5","lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-l1-1-0.a":"f4d80cc039da4a39579155f7b30298e46ace98a936a387db47dbd64eb917d064","lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-robuffer-l1-1-0.a":"c941a5cfd8d2148bb8ec06c9a9b3c8a70723b37fc2634575e36c1c49d1df73cc","lib/libwinapi_windowsapp_downlevel-cabinet.a":"89a12c6584e2cdc05364aef6f6e17f77d0083769633adfab47b5d6793ad884e6","lib/libwinapi_windowsapp_downlevel-d2d1.a":"bda9d05a33ca5e056cf5937fef2a52a59b6700fe45578131391116ca4a4c5b31","lib/libwinapi_windowsapp_downlevel-d3d11.a":"151c55f421ac527340a812b669da6b35faf8e9b45d1e2d0e08deb982063a24e8","lib/libwinapi_windowsapp_downlevel-d3dcompiler_47.a":"b1377cd66a4f5e603f7713d253a8257da5942b4cdeb124f6172cc22573ec4f37","lib/libwinapi_windowsapp_downlevel-deviceaccess.a":"dae3ef67aedc2f6be5934edd881e94f0f1d557157eb120603033c3b33056b790","lib/libwinapi_windowsapp_downlevel-dhcpcsvc.a":"71c09c6b4a7957e41326568aa5c3843e3b801e64b8402fe29c39ef722de2f2cd","lib/libwinapi_windowsapp_downlevel-dhcpcsvc6.a":"1b2e5fe6ebe47482a817032559f7f7fef399e0af20c8a65263976efa41cfad30","lib/libwinapi_windowsapp_downlevel-dwrite.a":"8ec12a94050fb6be30d9ce89e9a3a3fdf229aef3ef851e934fac59a8c805c34d","lib/libwinapi_windowsapp_downlevel-dxgi.a":"5b399ce9491ac65f985c474bf8a12c052bceaeb9ef4287f1b52276652afed04f","lib/libwinapi_windowsapp_downlevel-esent.a":"b1410b4797fa48ff20422267b1be926d59cc4857aa7b95fb6e52f4f9ce7994ff","lib/libwinapi_windowsapp_downlevel-kernel32.a":"7a7c838ea5b0cdc182a1a6d258d70817dfc160c074258ce680a2db2cf7c10578","lib/libwinapi_windowsapp_downlevel-mf.a":"fe2d036c4a667eeb030566ce65f3f89b989c1fc1abe5f83945ca44fdc0b70c13","lib/libwinapi_windowsapp_downlevel-mfplat.a":"e5bee9fab643169b89c88cf568045bac6e6f016faf293f8aa30284f88a256238","lib/libwinapi_windowsapp_downlevel-mfreadwrite.a":"c5de9e0ce1202e8352f16d8b67f9a6fe1be12fbafa0daf61538225f499f69605","lib/libwinapi_windowsapp_downlevel-mmdevapi.a":"9c981c2a505652b7ce2455ba30ee8574427948ee7b67571bf5d09a8dc97ea375","lib/libwinapi_windowsapp_downlevel-msajapi.a":"7e59dbf0b6e104a79ecdbac529f45e44b0ddcbee1d38863d8aa7cf2674eaad67","lib/libwinapi_windowsapp_downlevel-mscoree.a":"1b062a2632e68b73495c1247e5279839e3033e3de02b5f5db104cbbc68af2be4","lib/libwinapi_windowsapp_downlevel-mswsock.a":"3f58e0deac30f5a96f3f2a6b4d1a80f2496dd6b1dbbd01235bf0755d51afe986","lib/libwinapi_windowsapp_downlevel-ole32.a":"e4b79dfc1813ee67f496b671e596cc01d2e0ba1c79f0d4d6ae2d7201f56a760d","lib/libwinapi_windowsapp_downlevel-oleaut32.a":"69308892c1dea408b9384284943e45f2147da04e74caacf4ab44de11cc2d364f","lib/libwinapi_windowsapp_downlevel-propsys.a":"b8b6552d2b28a7018468994d3394519b8a7101534b3f4e50173aa1813201f853","lib/libwinapi_windowsapp_downlevel-rpcrt4.a":"8eed742ab752bd17b586d1603e796339c5555e0b0bec3ee1f1d9532521c6e52d","lib/libwinapi_windowsapp_downlevel-uiautomationcore.a":"8d467b3c25c5e390893a47b1e3f8770776e2a36372a8bf0531c25a492f1125a0","lib/libwinapi_windowsapp_downlevel-urlmon.a":"42ad1a91664810df9c2908cdbf8050729db56f14e36125fbc71cf463243f7806","lib/libwinapi_windowsapp_downlevel-webservices.a":"89fadc0f43b06e47b373e9a44632c61b14b4f7a2f2e9ee82136c3e0bbdaf1f80","lib/libwinapi_windowsapp_downlevel-windows.data.pdf.a":"731707bc16a683848d60aa38954b1938900f089acb91a15c7e3613fa34784dfc","lib/libwinapi_windowsapp_downlevel-windows.networking.a":"3f03402c0a4dfef0d0064915f17f88604c8526edf7f03864ffc2a07838311407","lib/libwinapi_windowsapp_downlevel-windowscodecs.a":"f57a96186c4180602cdcb4ff71b3195cec7159d7f6fc32e4ef842d2616a8164d","lib/libwinapi_windowsapp_downlevel-ws2_32.a":"fbf4bee29fefae79bddfca5f7d26ef4b3fba39cd4ca38c69999ddf3b16ffc352","lib/libwinapi_windowsapp_downlevel-xaudio2_8.a":"575a6971d93bb159b37c4910495669d337e6644bae4d7b6f4148ace23d7bb89f","lib/libwinapi_windowsapp_downlevel-xinput1_4.a":"8ebe2d1cf4cc25f05f3f6cfafa9084295e07d022fb7849c655d3d29f40c65b78","lib/libwinapi_windowsapp_downlevel-xmllite.a":"499ea167ece4491d8a1e9a52344c4ba7edd04bdff77a6c79e32dacf57808a33f","lib/libwinapi_windowsapp_downlevel.a":"2194d9b733835788488e418bcb32fad827b37be22f4c4bf60ab2a9a79909b61e","lib/libwinapi_windowscodecs.a":"1d9a617d8619f0f754bd96735db2f21efec8f7c7bc4a14c5815e454b1b316d16","lib/libwinapi_winfax.a":"98cf3f776b3f05ea74eaf7fe7dc767db42e76bd07b4d253eb007349358f3cc80","lib/libwinapi_winhttp.a":"cce6f8284c2f68dd07b5cf7c5a4d1573f8a15645f8bfa465968709d2dd721920","lib/libwinapi_wininet.a":"01d3a33678e0b27ab1c07d0a160bf2382ef9069545f8a54a91e11d5c5f504228","lib/libwinapi_winmm.a":"edc07d91a9cfdb84393c2a1fd148ce6374c4c5cb8a8de8c3dbb6df0f9bf0a4aa","lib/libwinapi_winscard.a":"55058b121a5930e72c4e9b5c67b7d39b4da0af64cccc9d67e04604c1b6c6ff2d","lib/libwinapi_winspool.a":"cdb1f6a9d6b85f15e912b1e9d5cc20851297d0421bcace0f8f47ec200825055c","lib/libwinapi_winsqlite3.a":"a089b8a8083e37e93d77d3f8f94039157c7f4389026d19563cf6cc868cf1a1bb","lib/libwinapi_winsta.a":"618c97b3204cd65b588ec2c3821207207596170b7cc7bbba3f3c59db4d746d8c","lib/libwinapi_wintrust.a":"79e2228fb8ea93e0565c7b9db89bd35cbb6824ba4d384d295460495c21cad6a7","lib/libwinapi_winusb.a":"80e1e8b3ea87e67eba6d82026c611ca46e481134f65dc0a65e7cb8ab6b3cdf84","lib/libwinapi_wlanapi.a":"5efb1954fdface46feef7639ed76d1b13c0f9f38ff5d2879fc4cb7e26940466d","lib/libwinapi_wlanui.a":"990c834c28a1087962948e556e0427fd6c31e79e1dc81b34c6f744ef67c0f9be","lib/libwinapi_wldap32.a":"4c399e2d32d3d53359361a89ef059d4751412d8c68f5a0c2396462b34681e7bb","lib/libwinapi_wmip.a":"318d6e8f08041e59a05d82eb2a70e8794d123c91cd71339a65a1bff0d7b990be","lib/libwinapi_wmvcore.a":"df64a1a7af862fe93cf2cb3301504417148e5fad917e0182a41df0b3bb3dae83","lib/libwinapi_wofutil.a":"330612632e94d06d2ab63ba3e85db69e4c689b02fa14bd4602505be088c6b8b3","lib/libwinapi_wow32.a":"49bf68f714be90aa6cef22241be0b55f6553ff6405ca147824fc5653a60fda1b","lib/libwinapi_ws2_32.a":"b02a3fb740261e1e72cc6d88ae06f228565d39a253198122c23ac965b606982b","lib/libwinapi_wscapi.a":"4a9236b6557411c5bcef90c4f3062aef4377e0421fcf6f6fc7d3483014edeb92","lib/libwinapi_wsclient.a":"b3be16fa22186b2e36537feba46f81c70ec66978459d715a03600c1fa10c4baa","lib/libwinapi_wsdapi.a":"c8824e6b5d4aef2e8695b674905960fcaf1af8881965915235454d25bbb5c667","lib/libwinapi_wsmsvc.a":"11d5e8f6c72b2a16eddf3fe8c4db08932c3f70398808e57c9a797ef9ce8f548d","lib/libwinapi_wsnmp32.a":"4c8dbbe49a58aa683655b84952ec5e5dd6bc68cc4d062cdf6d000daa31a36aa2","lib/libwinapi_wsock32.a":"204c14be3fe2cc95e1ab464b4f4d86e59e56bcebd054dbda55cef49d676ea037","lib/libwinapi_wtsapi32.a":"6b0541ecba6bb1a20571ac9cf3cc6e3909c7592214128e9fe5259d8a520353b8","lib/libwinapi_xaudio2.a":"7ed568b3851cf3dea6d2a2a88b2d5f4c56899dbc8d7f6d8126a06ca7ee2ae139","lib/libwinapi_xaudio2_8.a":"d6717d6e560fa321413dba473d5b741c6d44d3730145c7089de3b996279494d8","lib/libwinapi_xinput.a":"b0edd4a52d698ca8b714ba86dc185ff75e1aa4c9179150dfdd5e01b766f93a36","lib/libwinapi_xinput9_1_0.a":"455441428a9a0bed23abf9cbf316e27bfbdb545d2eb5e7f4319eea8a02938512","lib/libwinapi_xinputuap.a":"7b9cbe2a468180055aea890071308a802d938ccdb81d324e4f904020820f29d1","lib/libwinapi_xmllite.a":"33792fc30a0332b48e0d93d90ac0cb08bcc6331c10d8d9813a5c27dff101b12f","lib/libwinapi_xolehlp.a":"23f63c0a9df8909599f487b90cbdb747781642f4fa60f2b1a2fb24beba4a01d6","lib/libwinapi_xpsdocumenttargetprint.a":"6880144760502cc9643ab5841befa150f05d59dc81be1ed530dcb582d31e6b93","lib/libwinapi_xpsprint.a":"55aef7583e713244611d79c87ff9c955760cdb9060a081fa8e28dc9cc58f27cd","src/lib.rs":"79212a91f610f8a77aa6ed4cc77212c2531eeb35630388bf07323cc328fcca42"},"package":"ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"} \ No newline at end of file diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/BUILD b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/BUILD new file mode 100644 index 0000000..e0dd09e --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "winapi_i686_pc_windows_gnu", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/Cargo.toml b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/Cargo.toml new file mode 100644 index 0000000..e3bd0c6 --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/Cargo.toml @@ -0,0 +1,22 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +authors = ["Peter Atashian <retep998@gmail.com>"] +build = "build.rs" +include = ["src/*", "lib/*", "Cargo.toml", "build.rs"] +description = "Import libraries for the i686-pc-windows-gnu target. Please don't use this crate directly, depend on winapi instead." +keywords = ["windows"] +license = "MIT/Apache-2.0" +repository = "https://github.com/retep998/winapi-rs" diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/build.rs b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/build.rs new file mode 100644 index 0000000..7130b30 --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/build.rs @@ -0,0 +1,18 @@ +// Copyright © 2016-2018 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +fn main() { + use std::env::var; + use std::path::Path; + println!("cargo:rerun-if-env-changed=WINAPI_NO_BUNDLED_LIBRARIES"); + if var("WINAPI_NO_BUNDLED_LIBRARIES").is_ok() { + return; + } + if var("TARGET").map(|target| target == "i686-pc-windows-gnu").unwrap_or(false) { + let dir = var("CARGO_MANIFEST_DIR").unwrap(); + println!("cargo:rustc-link-search=native={}", Path::new(&dir).join("lib").display()); + } +} diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_aclui.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_aclui.a new file mode 100644 index 0000000..5ccf8e5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_aclui.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_activeds.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_activeds.a new file mode 100644 index 0000000..e913225 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_activeds.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_advapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_advapi32.a new file mode 100644 index 0000000..6c52a36 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_advapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_advpack.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_advpack.a new file mode 100644 index 0000000..e7eae3c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_advpack.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_amsi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_amsi.a new file mode 100644 index 0000000..971e597 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_amsi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_api-ms-win-net-isolation-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_api-ms-win-net-isolation-l1-1-0.a new file mode 100644 index 0000000..70f11d7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_api-ms-win-net-isolation-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_apidll.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_apidll.a new file mode 100644 index 0000000..12f8738 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_apidll.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_appmgmts.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_appmgmts.a new file mode 100644 index 0000000..1b6c97a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_appmgmts.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_appnotify.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_appnotify.a new file mode 100644 index 0000000..5bd2147 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_appnotify.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_asycfilt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_asycfilt.a new file mode 100644 index 0000000..1d443dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_asycfilt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_audioeng.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_audioeng.a new file mode 100644 index 0000000..a058f8d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_audioeng.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_authz.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_authz.a new file mode 100644 index 0000000..ace31de Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_authz.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_avifil32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_avifil32.a new file mode 100644 index 0000000..8b1033d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_avifil32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_avrt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_avrt.a new file mode 100644 index 0000000..263dc0d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_avrt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_basesrv.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_basesrv.a new file mode 100644 index 0000000..3694b3f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_basesrv.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_bcrypt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_bcrypt.a new file mode 100644 index 0000000..4e38eb0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_bcrypt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_bluetoothapis.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_bluetoothapis.a new file mode 100644 index 0000000..4a73919 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_bluetoothapis.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_bthprops.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_bthprops.a new file mode 100644 index 0000000..17ddc90 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_bthprops.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cabinet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cabinet.a new file mode 100644 index 0000000..7d55bc2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_certadm.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_certadm.a new file mode 100644 index 0000000..ea47836 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_certadm.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_certpoleng.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_certpoleng.a new file mode 100644 index 0000000..6a824a2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_certpoleng.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cfgmgr32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cfgmgr32.a new file mode 100644 index 0000000..8bcca88 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cfgmgr32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_chakrart.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_chakrart.a new file mode 100644 index 0000000..edd1a2f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_chakrart.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cldapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cldapi.a new file mode 100644 index 0000000..5b8b4a8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cldapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_clfsw32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_clfsw32.a new file mode 100644 index 0000000..6879e86 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_clfsw32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_clusapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_clusapi.a new file mode 100644 index 0000000..69ecbff Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_clusapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comctl32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comctl32.a new file mode 100644 index 0000000..cb75459 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comctl32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comdlg32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comdlg32.a new file mode 100644 index 0000000..9cfdcf6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comdlg32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comppkgsup.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comppkgsup.a new file mode 100644 index 0000000..081ae6c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comppkgsup.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_compstui.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_compstui.a new file mode 100644 index 0000000..f47a638 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_compstui.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comsvcs.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comsvcs.a new file mode 100644 index 0000000..7378ba5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_comsvcs.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_coremessaging.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_coremessaging.a new file mode 100644 index 0000000..b4a6f02 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_coremessaging.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_credui.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_credui.a new file mode 100644 index 0000000..10a1e5b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_credui.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_crypt32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_crypt32.a new file mode 100644 index 0000000..48f43df Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_crypt32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptdll.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptdll.a new file mode 100644 index 0000000..71752c1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptdll.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptnet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptnet.a new file mode 100644 index 0000000..25d046d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptnet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptui.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptui.a new file mode 100644 index 0000000..104e7af Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptui.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptxml.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptxml.a new file mode 100644 index 0000000..e1d4725 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cryptxml.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cscapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cscapi.a new file mode 100644 index 0000000..5c12838 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cscapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cscdll.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cscdll.a new file mode 100644 index 0000000..25dfaad Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_cscdll.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d2d1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d2d1.a new file mode 100644 index 0000000..304db07 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d2d1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10.a new file mode 100644 index 0000000..dd59522 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10_1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10_1.a new file mode 100644 index 0000000..9b97e07 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10_1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d11.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d11.a new file mode 100644 index 0000000..5ef0648 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d11.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d12.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d12.a new file mode 100644 index 0000000..af625e9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d12.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d9.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d9.a new file mode 100644 index 0000000..639ac8d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3d9.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcompiler.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcompiler.a new file mode 100644 index 0000000..1fd8e8a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcompiler.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsx.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsx.a new file mode 100644 index 0000000..0646117 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsx.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsxd.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsxd.a new file mode 100644 index 0000000..25e1db1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsxd.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_davclnt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_davclnt.a new file mode 100644 index 0000000..b6f0b9d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_davclnt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dbgeng.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dbgeng.a new file mode 100644 index 0000000..e23a4e6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dbgeng.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dbghelp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dbghelp.a new file mode 100644 index 0000000..e847dbc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dbghelp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dciman32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dciman32.a new file mode 100644 index 0000000..0c4f056 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dciman32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dcomp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dcomp.a new file mode 100644 index 0000000..e38ec83 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dcomp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ddraw.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ddraw.a new file mode 100644 index 0000000..9b0da8b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ddraw.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_deviceaccess.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_deviceaccess.a new file mode 100644 index 0000000..70a1ae3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_deviceaccess.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_devmgr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_devmgr.a new file mode 100644 index 0000000..83badc6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_devmgr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dflayout.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dflayout.a new file mode 100644 index 0000000..90f7f49 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dflayout.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc.a new file mode 100644 index 0000000..4b9e89d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc6.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc6.a new file mode 100644 index 0000000..94e7d19 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc6.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpsapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpsapi.a new file mode 100644 index 0000000..9b5f149 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpsapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_difxapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_difxapi.a new file mode 100644 index 0000000..38e0f75 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_difxapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dinput8.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dinput8.a new file mode 100644 index 0000000..0def510 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dinput8.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dmprocessxmlfiltered.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dmprocessxmlfiltered.a new file mode 100644 index 0000000..4d0d6f5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dmprocessxmlfiltered.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dnsapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dnsapi.a new file mode 100644 index 0000000..32d6f44 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dnsapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dnsperf.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dnsperf.a new file mode 100644 index 0000000..e980e4b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dnsperf.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dnsrslvr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dnsrslvr.a new file mode 100644 index 0000000..98fd6ec Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dnsrslvr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dpx.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dpx.a new file mode 100644 index 0000000..11596b4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dpx.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_drt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_drt.a new file mode 100644 index 0000000..d73c32c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_drt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_drtprov.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_drtprov.a new file mode 100644 index 0000000..e99a635 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_drtprov.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_drttransport.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_drttransport.a new file mode 100644 index 0000000..48975da Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_drttransport.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dsound.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dsound.a new file mode 100644 index 0000000..e9bfe42 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dsound.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dsprop.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dsprop.a new file mode 100644 index 0000000..4b0706b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dsprop.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dssec.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dssec.a new file mode 100644 index 0000000..3de363e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dssec.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dststlog.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dststlog.a new file mode 100644 index 0000000..7a2c3e5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dststlog.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dsuiext.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dsuiext.a new file mode 100644 index 0000000..2f42acf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dsuiext.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dwmapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dwmapi.a new file mode 100644 index 0000000..3daa809 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dwmapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dwrite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dwrite.a new file mode 100644 index 0000000..57af416 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dwrite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dxgi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dxgi.a new file mode 100644 index 0000000..3bae477 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dxgi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dxva2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dxva2.a new file mode 100644 index 0000000..d495dc4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_dxva2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_eappcfg.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_eappcfg.a new file mode 100644 index 0000000..3069ee9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_eappcfg.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_eappprxy.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_eappprxy.a new file mode 100644 index 0000000..5dda01c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_eappprxy.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_easregprov.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_easregprov.a new file mode 100644 index 0000000..4d12d53 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_easregprov.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_efswrt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_efswrt.a new file mode 100644 index 0000000..7e1a167 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_efswrt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_elscore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_elscore.a new file mode 100644 index 0000000..1cebdc9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_elscore.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_esent.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_esent.a new file mode 100644 index 0000000..b49e343 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_esent.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_evr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_evr.a new file mode 100644 index 0000000..c8aa1a9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_evr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_faultrep.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_faultrep.a new file mode 100644 index 0000000..4de5c1e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_faultrep.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_feclient.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_feclient.a new file mode 100644 index 0000000..0a5cc40 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_feclient.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fhsvcctl.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fhsvcctl.a new file mode 100644 index 0000000..88de829 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fhsvcctl.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fltlib.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fltlib.a new file mode 100644 index 0000000..f6a9623 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fltlib.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fontsub.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fontsub.a new file mode 100644 index 0000000..42d704e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fontsub.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_framedyd.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_framedyd.a new file mode 100644 index 0000000..ea81552 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_framedyd.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_framedyn.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_framedyn.a new file mode 100644 index 0000000..2913ed6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_framedyn.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fwpuclnt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fwpuclnt.a new file mode 100644 index 0000000..3e89cda Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fwpuclnt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fxsutility.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fxsutility.a new file mode 100644 index 0000000..3465f81 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_fxsutility.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_gdi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_gdi32.a new file mode 100644 index 0000000..5987d47 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_gdi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_gdiplus.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_gdiplus.a new file mode 100644 index 0000000..a6056e8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_gdiplus.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_glmf32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_glmf32.a new file mode 100644 index 0000000..32b72a9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_glmf32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_glu32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_glu32.a new file mode 100644 index 0000000..d79482a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_glu32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_gpedit.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_gpedit.a new file mode 100644 index 0000000..a787bf8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_gpedit.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hbaapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hbaapi.a new file mode 100644 index 0000000..b2a136c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hbaapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hid.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hid.a new file mode 100644 index 0000000..6d4b4ac Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hid.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hlink.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hlink.a new file mode 100644 index 0000000..45734a1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hlink.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hrtfapo.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hrtfapo.a new file mode 100644 index 0000000..745618b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_hrtfapo.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_httpapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_httpapi.a new file mode 100644 index 0000000..f603042 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_httpapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iashlpr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iashlpr.a new file mode 100644 index 0000000..ab56ad2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iashlpr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icm32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icm32.a new file mode 100644 index 0000000..13d1ef7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icm32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icmui.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icmui.a new file mode 100644 index 0000000..5ced197 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icmui.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icuin.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icuin.a new file mode 100644 index 0000000..2a9be36 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icuin.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icuuc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icuuc.a new file mode 100644 index 0000000..a3b6948 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_icuuc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_imagehlp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_imagehlp.a new file mode 100644 index 0000000..c01e369 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_imagehlp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_imgutil.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_imgutil.a new file mode 100644 index 0000000..48437d9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_imgutil.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_imm32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_imm32.a new file mode 100644 index 0000000..d500ee5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_imm32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_infocardapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_infocardapi.a new file mode 100644 index 0000000..6753ecc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_infocardapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_inkobjcore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_inkobjcore.a new file mode 100644 index 0000000..66cf097 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_inkobjcore.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_inseng.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_inseng.a new file mode 100644 index 0000000..00ec097 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_inseng.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iphlpapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iphlpapi.a new file mode 100644 index 0000000..eb66c63 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iphlpapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iprop.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iprop.a new file mode 100644 index 0000000..9a7ef16 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iprop.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_irprops.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_irprops.a new file mode 100644 index 0000000..20aeab6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_irprops.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iscsidsc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iscsidsc.a new file mode 100644 index 0000000..d399a3c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_iscsidsc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_jsrt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_jsrt.a new file mode 100644 index 0000000..7e51def Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_jsrt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_kernel32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_kernel32.a new file mode 100644 index 0000000..69a7f7d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_kernel32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ksproxy.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ksproxy.a new file mode 100644 index 0000000..9a4219f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ksproxy.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ksuser.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ksuser.a new file mode 100644 index 0000000..5f0e47b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ksuser.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ktmw32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ktmw32.a new file mode 100644 index 0000000..c158f8a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ktmw32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_loadperf.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_loadperf.a new file mode 100644 index 0000000..f8512d0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_loadperf.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_lz32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_lz32.a new file mode 100644 index 0000000..9b75f05 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_lz32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_magnification.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_magnification.a new file mode 100644 index 0000000..7f3ecbb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_magnification.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mapi32.a new file mode 100644 index 0000000..74373c3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mciole32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mciole32.a new file mode 100644 index 0000000..584e44b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mciole32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mdmlocalmanagement.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mdmlocalmanagement.a new file mode 100644 index 0000000..c69ce2a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mdmlocalmanagement.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mdmregistration.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mdmregistration.a new file mode 100644 index 0000000..eb34316 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mdmregistration.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mf.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mf.a new file mode 100644 index 0000000..01ea7a8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mf.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfcore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfcore.a new file mode 100644 index 0000000..004e477 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfcore.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfplat.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfplat.a new file mode 100644 index 0000000..b24669f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfplat.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfplay.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfplay.a new file mode 100644 index 0000000..e3d553d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfplay.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfreadwrite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfreadwrite.a new file mode 100644 index 0000000..23c1acb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfreadwrite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfsensorgroup.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfsensorgroup.a new file mode 100644 index 0000000..a53cc65 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfsensorgroup.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfsrcsnk.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfsrcsnk.a new file mode 100644 index 0000000..6392a5f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mfsrcsnk.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mgmtapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mgmtapi.a new file mode 100644 index 0000000..47b697d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mgmtapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mi.a new file mode 100644 index 0000000..9591de8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-0.a new file mode 100644 index 0000000..14c7d2f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-1.a new file mode 100644 index 0000000..b9b85dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-2.a new file mode 100644 index 0000000..84e841a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-midlproxystub-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-midlproxystub-l1-1-0.a new file mode 100644 index 0000000..c5512ba Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-midlproxystub-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-0.a new file mode 100644 index 0000000..5cabc06 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-1.a new file mode 100644 index 0000000..3d966f0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l1-1-0.a new file mode 100644 index 0000000..2a3267c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l2-1-0.a new file mode 100644 index 0000000..aa3f0e7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-0.a new file mode 100644 index 0000000..8e90a74 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-1.a new file mode 100644 index 0000000..7eb338f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-2.a new file mode 100644 index 0000000..80283d9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-0.a new file mode 100644 index 0000000..84a229a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-1.a new file mode 100644 index 0000000..2b55ef4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-2.a new file mode 100644 index 0000000..a362e4b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-0.a new file mode 100644 index 0000000..21d4b30 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-1.a new file mode 100644 index 0000000..374c29b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-0.a new file mode 100644 index 0000000..5d0f55a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-1.a new file mode 100644 index 0000000..5dd1442 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-2.a new file mode 100644 index 0000000..fe0d52b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-3.a new file mode 100644 index 0000000..9c30fab Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-0.a new file mode 100644 index 0000000..eedee5e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-1.a new file mode 100644 index 0000000..621f718 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-1-0.a new file mode 100644 index 0000000..1f4f2a0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-0.a new file mode 100644 index 0000000..774a4f7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-1.a new file mode 100644 index 0000000..e413b4c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-2.a new file mode 100644 index 0000000..721cd89 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-0.a new file mode 100644 index 0000000..384a2bc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-1.a new file mode 100644 index 0000000..c84610c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-2.a new file mode 100644 index 0000000..1ae7618 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-3.a new file mode 100644 index 0000000..06c276a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-firmware-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-firmware-l1-1-0.a new file mode 100644 index 0000000..f0eb4fd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-firmware-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-handle-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-handle-l1-1-0.a new file mode 100644 index 0000000..6104102 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-handle-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l1-1-0.a new file mode 100644 index 0000000..ce95b8d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l2-1-0.a new file mode 100644 index 0000000..3749945 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-1-0.a new file mode 100644 index 0000000..c9c88e6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-2-0.a new file mode 100644 index 0000000..cee5059 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-0.a new file mode 100644 index 0000000..45dd559 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-1.a new file mode 100644 index 0000000..30d1c51 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-job-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-job-l1-1-0.a new file mode 100644 index 0000000..1db1f24 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-job-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-0.a new file mode 100644 index 0000000..c5175f3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-1.a new file mode 100644 index 0000000..0154f3b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-2.a new file mode 100644 index 0000000..55126ff Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l2-1-0.a new file mode 100644 index 0000000..d4e8e23 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-0.a new file mode 100644 index 0000000..e50b351 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-1.a new file mode 100644 index 0000000..1eb5327 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-2.a new file mode 100644 index 0000000..038cdfc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l2-1-0.a new file mode 100644 index 0000000..64bd0e7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-0.a new file mode 100644 index 0000000..119c5fd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-1.a new file mode 100644 index 0000000..81184f9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-2.a new file mode 100644 index 0000000..d0187b7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-3.a new file mode 100644 index 0000000..b91f642 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-4.a new file mode 100644 index 0000000..f87a247 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-5.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-5.a new file mode 100644 index 0000000..2a231cb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-5.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-1-0.a new file mode 100644 index 0000000..37ce0f1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-1.a new file mode 100644 index 0000000..89d0f5f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-2.a new file mode 100644 index 0000000..be7983c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namespace-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namespace-l1-1-0.a new file mode 100644 index 0000000..834c92c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namespace-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-path-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-path-l1-1-0.a new file mode 100644 index 0000000..402354e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-1-0.a new file mode 100644 index 0000000..0f0ebac Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-2-0.a new file mode 100644 index 0000000..e758600 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processsnapshot-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processsnapshot-l1-1-0.a new file mode 100644 index 0000000..d672800 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processsnapshot-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-0.a new file mode 100644 index 0000000..f39ad97 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-1.a new file mode 100644 index 0000000..969522d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-2.a new file mode 100644 index 0000000..d204c52 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-3.a new file mode 100644 index 0000000..fa97a52 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processtopology-l1-1-0.a new file mode 100644 index 0000000..f552d00 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-profile-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-profile-l1-1-0.a new file mode 100644 index 0000000..757d311 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-profile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-psapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-psapi-l1-1-0.a new file mode 100644 index 0000000..1720dd8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-psapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-0.a new file mode 100644 index 0000000..239f327 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-1.a new file mode 100644 index 0000000..819ac5a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-0.a new file mode 100644 index 0000000..5f32d95 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-1.a new file mode 100644 index 0000000..fa19448 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-2.a new file mode 100644 index 0000000..f010078 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-0.a new file mode 100644 index 0000000..ec7063e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-1.a new file mode 100644 index 0000000..4b09d25 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-2.a new file mode 100644 index 0000000..c1424f5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-1-0.a new file mode 100644 index 0000000..7967076 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-2-0.a new file mode 100644 index 0000000..00bc726 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-0.a new file mode 100644 index 0000000..5afe8f7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-1.a new file mode 100644 index 0000000..7f23bdd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l1-1-0.a new file mode 100644 index 0000000..6bd2f7e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-0.a new file mode 100644 index 0000000..78ab95f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-1.a new file mode 100644 index 0000000..89e4916 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-1-0.a new file mode 100644 index 0000000..f0eda03 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-0.a new file mode 100644 index 0000000..01f5995 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-1.a new file mode 100644 index 0000000..b7fe044 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-1-0.a new file mode 100644 index 0000000..746ad46 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-0.a new file mode 100644 index 0000000..4e9f38e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-1.a new file mode 100644 index 0000000..9cbc37b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-2.a new file mode 100644 index 0000000..c13288c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-3.a new file mode 100644 index 0000000..ce77384 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-0.a new file mode 100644 index 0000000..595f4e4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-1.a new file mode 100644 index 0000000..98be2bc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-threadpool-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-threadpool-l1-2-0.a new file mode 100644 index 0000000..4200883 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-threadpool-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-timezone-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-timezone-l1-1-0.a new file mode 100644 index 0000000..9da7852 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-timezone-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-0.a new file mode 100644 index 0000000..1f35371 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-1.a new file mode 100644 index 0000000..425efa2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-0.a new file mode 100644 index 0000000..8f5ed3f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-1.a new file mode 100644 index 0000000..f22c0fd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-0.a new file mode 100644 index 0000000..be6a661 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-1.a new file mode 100644 index 0000000..ccf64b8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..2810b8e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-0.a new file mode 100644 index 0000000..b53b5ee Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-1.a new file mode 100644 index 0000000..53a2fd9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-0.a new file mode 100644 index 0000000..a35e143 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-1.a new file mode 100644 index 0000000..685f805 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-2.a new file mode 100644 index 0000000..3ada2fb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-0.a new file mode 100644 index 0000000..f124666 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-1.a new file mode 100644 index 0000000..2face46 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-2.a new file mode 100644 index 0000000..a5e1060 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l2-1-0.a new file mode 100644 index 0000000..b450a24 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-1.a new file mode 100644 index 0000000..65da450 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-2.a new file mode 100644 index 0000000..019825e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-0.a new file mode 100644 index 0000000..c5aea92 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-1.a new file mode 100644 index 0000000..7c6a174 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-classicprovider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-classicprovider-l1-1-0.a new file mode 100644 index 0000000..75c6170 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-classicprovider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-0.a new file mode 100644 index 0000000..fb632e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-1.a new file mode 100644 index 0000000..3579e9e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-controller-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-controller-l1-1-0.a new file mode 100644 index 0000000..e677121 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-controller-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-provider-l1-1-0.a new file mode 100644 index 0000000..0c36fa5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-base-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-base-l1-1-0.a new file mode 100644 index 0000000..c14203c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-setting-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-setting-l1-1-0.a new file mode 100644 index 0000000..1b63259 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-setting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-appcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-appcontainer-l1-1-0.a new file mode 100644 index 0000000..32a362f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-appcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-1-0.a new file mode 100644 index 0000000..ab6bd64 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-0.a new file mode 100644 index 0000000..47962db Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-1.a new file mode 100644 index 0000000..f5e4890 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-2.a new file mode 100644 index 0000000..52398c2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-credentials-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-credentials-l1-1-0.a new file mode 100644 index 0000000..7074024 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-credentials-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-0.a new file mode 100644 index 0000000..d6a7109 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-1.a new file mode 100644 index 0000000..14e437d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-sddl-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-sddl-l1-1-0.a new file mode 100644 index 0000000..4d123f2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-sddl-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-0.a new file mode 100644 index 0000000..ee666ae Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-1.a new file mode 100644 index 0000000..7103b2c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-2.a new file mode 100644 index 0000000..ad5dbab Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l1-1-0.a new file mode 100644 index 0000000..fb03fd9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l2-1-0.a new file mode 100644 index 0000000..422c9ba Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-winsvc-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-winsvc-l1-1-0.a new file mode 100644 index 0000000..f482472 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-winsvc-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-authz.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-authz.a new file mode 100644 index 0000000..c30bf23 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-authz.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-bcrypt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-bcrypt.a new file mode 100644 index 0000000..96f403f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-bcrypt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cabinet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cabinet.a new file mode 100644 index 0000000..91af31b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-crypt32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-crypt32.a new file mode 100644 index 0000000..0e95678 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-crypt32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptbase.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptbase.a new file mode 100644 index 0000000..e7dc455 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptbase.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptnet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptnet.a new file mode 100644 index 0000000..83dac37 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptnet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dfscli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dfscli.a new file mode 100644 index 0000000..6924427 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dfscli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dnsapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dnsapi.a new file mode 100644 index 0000000..9071743 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dnsapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsparse.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsparse.a new file mode 100644 index 0000000..2465dcb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsparse.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsrole.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsrole.a new file mode 100644 index 0000000..7b0ca0b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsrole.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-iphlpapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-iphlpapi.a new file mode 100644 index 0000000..4fed4d0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-iphlpapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-logoncli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-logoncli.a new file mode 100644 index 0000000..c2fbf6b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-logoncli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mpr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mpr.a new file mode 100644 index 0000000..7a54437 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mpr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mswsock.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mswsock.a new file mode 100644 index 0000000..0fb20c1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ncrypt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ncrypt.a new file mode 100644 index 0000000..82ec851 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ncrypt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-netutils.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-netutils.a new file mode 100644 index 0000000..bcd8050 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-netutils.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-oleaut32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-oleaut32.a new file mode 100644 index 0000000..e85bdfe Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-rpcrt4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-rpcrt4.a new file mode 100644 index 0000000..7633192 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-samcli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-samcli.a new file mode 100644 index 0000000..667f7e0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-samcli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-schedcli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-schedcli.a new file mode 100644 index 0000000..4038590 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-schedcli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-srvcli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-srvcli.a new file mode 100644 index 0000000..6c9a31b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-srvcli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-sspicli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-sspicli.a new file mode 100644 index 0000000..64a2993 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-sspicli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-userenv.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-userenv.a new file mode 100644 index 0000000..0252b87 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-userenv.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-websocket.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-websocket.a new file mode 100644 index 0000000..854e4f4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-websocket.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-winhttp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-winhttp.a new file mode 100644 index 0000000..4b4125e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-winhttp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wkscli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wkscli.a new file mode 100644 index 0000000..8689894 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wkscli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wldap32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wldap32.a new file mode 100644 index 0000000..9a2fcaf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wldap32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ws2_32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ws2_32.a new file mode 100644 index 0000000..cb75167 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore.a new file mode 100644 index 0000000..1d283d8 --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore.a @@ -0,0 +1,167 @@ +INPUT( +libwinapi_mincore-dfscli.a +libwinapi_mincore-api-ms-win-core-version-l1-1-1.a +libwinapi_mincore-api-ms-win-core-processthreads-l1-1-1.a +libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-0.a +libwinapi_mincore-api-ms-win-devices-config-l1-1-1.a +libwinapi_mincore-api-ms-win-core-xstate-l1-1-2.a +libwinapi_mincore-api-ms-win-service-management-l2-1-0.a +libwinapi_mincore-api-ms-win-core-rtlsupport-l1-1-0.a +libwinapi_mincore-ncrypt.a +libwinapi_mincore-api-ms-win-core-profile-l1-1-0.a +libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-1.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-3.a +libwinapi_mincore-api-ms-win-core-debug-l1-1-0.a +libwinapi_mincore-api-ms-win-core-io-l1-1-0.a +libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-0.a +libwinapi_mincore-api-ms-win-core-threadpool-l1-2-0.a +libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-1.a +libwinapi_mincore-dsparse.a +libwinapi_mincore-api-ms-win-core-fibers-l1-1-0.a +libwinapi_mincore-cabinet.a +libwinapi_mincore-api-ms-win-core-processthreads-l1-1-2.a +libwinapi_mincore-api-ms-win-core-string-l1-1-0.a +libwinapi_mincore-wldap32.a +libwinapi_mincore-api-ms-win-core-quirks-l1-1-1.a +libwinapi_mincore-api-ms-win-core-file-l1-2-0.a +libwinapi_mincore-api-ms-win-devices-config-l1-1-2.a +libwinapi_mincore-websocket.a +libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-2.a +libwinapi_mincore-api-ms-win-core-string-l2-1-0.a +libwinapi_mincore-api-ms-win-power-setting-l1-1-0.a +libwinapi_mincore-api-ms-win-core-file-l1-2-1.a +libwinapi_mincore-api-ms-win-core-quirks-l1-1-0.a +libwinapi_mincore-api-ms-win-core-delayload-l1-1-0.a +libwinapi_mincore-api-ms-win-core-path-l1-1-0.a +libwinapi_mincore-dsrole.a +libwinapi_mincore-api-ms-win-core-job-l1-1-0.a +libwinapi_mincore-api-ms-win-core-wow64-l1-1-0.a +libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-0.a +libwinapi_mincore-api-ms-win-core-string-l2-1-1.a +libwinapi_mincore-api-ms-win-core-io-l1-1-1.a +libwinapi_mincore-api-ms-win-core-datetime-l1-1-2.a +libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-1.a +libwinapi_mincore-api-ms-win-power-base-l1-1-0.a +libwinapi_mincore-api-ms-win-service-core-l1-1-1.a +libwinapi_mincore-api-ms-win-core-registry-l1-1-1.a +libwinapi_mincore-api-ms-win-core-processtopology-l1-1-0.a +libwinapi_mincore-api-ms-win-core-processenvironment-l1-2-0.a +libwinapi_mincore-api-ms-win-core-file-l1-2-2.a +libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-1.a +libwinapi_mincore-sspicli.a +libwinapi_mincore-api-ms-win-core-winrt-l1-1-0.a +libwinapi_mincore-api-ms-win-core-com-midlproxystub-l1-1-0.a +libwinapi_mincore-api-ms-win-security-base-l1-2-1.a +libwinapi_mincore-wkscli.a +libwinapi_mincore-logoncli.a +libwinapi_mincore-netutils.a +libwinapi_mincore-api-ms-win-core-delayload-l1-1-1.a +libwinapi_mincore-api-ms-win-core-localization-l1-2-2.a +libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-0.a +libwinapi_mincore-api-ms-win-eventing-controller-l1-1-0.a +libwinapi_mincore-api-ms-win-core-registry-l1-1-0.a +libwinapi_mincore-api-ms-win-core-localization-l1-2-1.a +libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-2.a +libwinapi_mincore-api-ms-win-core-version-l1-1-0.a +libwinapi_mincore-api-ms-win-security-credentials-l1-1-0.a +libwinapi_mincore-api-ms-win-core-debug-l1-1-2.a +libwinapi_mincore-api-ms-win-core-shutdown-l1-1-1.a +libwinapi_mincore-api-ms-win-core-timezone-l1-1-0.a +libwinapi_mincore-api-ms-win-core-realtime-l1-1-2.a +libwinapi_mincore-api-ms-win-security-base-l1-2-0.a +libwinapi_mincore-api-ms-win-core-realtime-l1-1-0.a +libwinapi_mincore-api-ms-win-core-firmware-l1-1-0.a +libwinapi_mincore-userenv.a +libwinapi_mincore-api-ms-win-core-heap-l2-1-0.a +libwinapi_mincore-ws2_32.a +libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-0.a +libwinapi_mincore-mpr.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-5.a +libwinapi_mincore-api-ms-win-core-file-l2-1-2.a +libwinapi_mincore-api-ms-win-security-base-l1-1-0.a +libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-3.a +libwinapi_mincore-api-ms-win-core-file-l2-1-0.a +libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-1.a +libwinapi_mincore-api-ms-win-core-synch-l1-2-1.a +libwinapi_mincore-samcli.a +libwinapi_mincore-api-ms-win-core-debug-l1-1-1.a +libwinapi_mincore-api-ms-win-core-processthreads-l1-1-0.a +libwinapi_mincore-api-ms-win-service-core-l1-1-2.a +libwinapi_mincore-api-ms-win-core-synch-l1-1-0.a +libwinapi_mincore-api-ms-win-core-wow64-l1-1-2.a +libwinapi_mincore-api-ms-win-eventing-classicprovider-l1-1-0.a +libwinapi_mincore-api-ms-win-core-synch-l1-2-0.a +libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-2.a +libwinapi_mincore-api-ms-win-core-psapi-l1-1-0.a +libwinapi_mincore-api-ms-win-core-interlocked-l1-1-0.a +libwinapi_mincore-api-ms-win-core-processthreads-l1-1-3.a +libwinapi_mincore-api-ms-win-core-xstate-l1-1-1.a +libwinapi_mincore-api-ms-win-service-core-l1-1-0.a +libwinapi_mincore-iphlpapi.a +libwinapi_mincore-api-ms-win-core-realtime-l1-1-1.a +libwinapi_mincore-api-ms-win-core-xstate-l1-1-0.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-2.a +libwinapi_mincore-api-ms-win-core-file-l2-1-1.a +libwinapi_mincore-authz.a +libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-1.a +libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-0.a +libwinapi_mincore-dnsapi.a +libwinapi_mincore-api-ms-win-service-management-l1-1-0.a +libwinapi_mincore-api-ms-win-core-localization-l1-2-0.a +libwinapi_mincore-api-ms-win-eventing-provider-l1-1-0.a +libwinapi_mincore-api-ms-win-core-fibers-l1-1-1.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-0.a +libwinapi_mincore-api-ms-win-core-util-l1-1-1.a +libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-0.a +libwinapi_mincore-api-ms-win-core-file-l2-1-3.a +libwinapi_mincore-api-ms-win-security-appcontainer-l1-1-0.a +libwinapi_mincore-api-ms-win-core-handle-l1-1-0.a +libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-1.a +libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-1.a +libwinapi_mincore-api-ms-win-core-comm-l1-1-1.a +libwinapi_mincore-api-ms-win-core-console-l1-1-0.a +libwinapi_mincore-api-ms-win-core-util-l1-1-0.a +libwinapi_mincore-cryptbase.a +libwinapi_mincore-mswsock.a +libwinapi_mincore-api-ms-win-core-com-l1-1-1.a +libwinapi_mincore-schedcli.a +libwinapi_mincore-winhttp.a +libwinapi_mincore-bcrypt.a +libwinapi_mincore-api-ms-win-core-sysinfo-l1-1-0.a +libwinapi_mincore-api-ms-win-core-xstate-l2-1-0.a +libwinapi_mincore-api-ms-win-core-processenvironment-l1-1-0.a +libwinapi_mincore-api-ms-win-core-processsnapshot-l1-1-0.a +libwinapi_mincore-cryptnet.a +libwinapi_mincore-api-ms-win-service-winsvc-l1-1-0.a +libwinapi_mincore-api-ms-win-core-comm-l1-1-0.a +libwinapi_mincore-crypt32.a +libwinapi_mincore-api-ms-win-security-base-l1-2-2.a +libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-1.a +libwinapi_mincore-api-ms-win-core-file-l1-1-0.a +libwinapi_mincore-api-ms-win-core-libraryloader-l2-1-0.a +libwinapi_mincore-api-ms-win-core-wow64-l1-1-1.a +libwinapi_mincore-api-ms-win-core-namespace-l1-1-0.a +libwinapi_mincore-srvcli.a +libwinapi_mincore-api-ms-win-core-localization-l2-1-0.a +libwinapi_mincore-api-ms-win-core-interlocked-l1-2-0.a +libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-2.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-1.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-4.a +libwinapi_mincore-api-ms-win-security-sddl-l1-1-0.a +libwinapi_mincore-api-ms-win-core-datetime-l1-1-0.a +libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-1.a +libwinapi_mincore-api-ms-win-core-rtlsupport-l1-2-0.a +libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-0.a +libwinapi_mincore-api-ms-win-core-shutdown-l1-1-0.a +libwinapi_mincore-api-ms-win-core-com-l1-1-2.a +libwinapi_mincore-oleaut32.a +libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-0.a +libwinapi_mincore-api-ms-win-core-registry-l1-1-2.a +libwinapi_mincore-api-ms-win-core-heap-l1-1-0.a +libwinapi_mincore-api-ms-win-core-datetime-l1-1-1.a +libwinapi_mincore-api-ms-win-core-com-l1-1-0.a +libwinapi_mincore-api-ms-win-core-console-l2-1-0.a +libwinapi_mincore-api-ms-win-core-namedpipe-l1-1-0.a +libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-3.a +libwinapi_mincore-rpcrt4.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l1-1-0.a new file mode 100644 index 0000000..7c2897d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l2-1-0.a new file mode 100644 index 0000000..0894bd9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-normaliz-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-normaliz-l1-1-0.a new file mode 100644 index 0000000..d683aa6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-normaliz-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-ole32-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-ole32-l1-1-0.a new file mode 100644 index 0000000..0589330 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-ole32-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shell32-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shell32-l1-1-0.a new file mode 100644 index 0000000..6640c94 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shell32-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l1-1-0.a new file mode 100644 index 0000000..d72679f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l2-1-0.a new file mode 100644 index 0000000..33cff85 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-user32-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-user32-l1-1-0.a new file mode 100644 index 0000000..c5a94c9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-user32-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-version-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-version-l1-1-0.a new file mode 100644 index 0000000..3507ea3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-version-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel.a new file mode 100644 index 0000000..9b663e3 --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel.a @@ -0,0 +1,11 @@ +INPUT( +libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l2-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-normaliz-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-version-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-ole32-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l2-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-user32-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-shell32-l1-1-0.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mmdevapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mmdevapi.a new file mode 100644 index 0000000..a4f7bbd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mmdevapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mpr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mpr.a new file mode 100644 index 0000000..5c41254 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mpr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mprapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mprapi.a new file mode 100644 index 0000000..f343e2a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mprapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mprsnap.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mprsnap.a new file mode 100644 index 0000000..34f2f4c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mprsnap.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mqrt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mqrt.a new file mode 100644 index 0000000..f3b36dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mqrt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mrmsupport.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mrmsupport.a new file mode 100644 index 0000000..d3318cb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mrmsupport.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msacm32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msacm32.a new file mode 100644 index 0000000..71095a9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msacm32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msajapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msajapi.a new file mode 100644 index 0000000..65d2c66 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msajapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mscms.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mscms.a new file mode 100644 index 0000000..ed61a87 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mscms.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msctfmonitor.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msctfmonitor.a new file mode 100644 index 0000000..d033b00 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msctfmonitor.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msdelta.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msdelta.a new file mode 100644 index 0000000..0f2648c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msdelta.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msdmo.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msdmo.a new file mode 100644 index 0000000..27d746e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msdmo.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msdrm.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msdrm.a new file mode 100644 index 0000000..ab8eab3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msdrm.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msi.a new file mode 100644 index 0000000..84945d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msimg32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msimg32.a new file mode 100644 index 0000000..dddd689 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msimg32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mspatcha.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mspatcha.a new file mode 100644 index 0000000..a98c319 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mspatcha.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mspatchc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mspatchc.a new file mode 100644 index 0000000..d3b4abe Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mspatchc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msports.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msports.a new file mode 100644 index 0000000..2271289 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msports.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msrating.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msrating.a new file mode 100644 index 0000000..4f0538f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msrating.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mstask.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mstask.a new file mode 100644 index 0000000..aa60fc9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mstask.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msv1_0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msv1_0.a new file mode 100644 index 0000000..a3942de Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msv1_0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msvfw32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msvfw32.a new file mode 100644 index 0000000..af8b929 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_msvfw32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mswsock.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mswsock.a new file mode 100644 index 0000000..ce52ad2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mtx.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mtx.a new file mode 100644 index 0000000..d882f20 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mtx.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mtxdm.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mtxdm.a new file mode 100644 index 0000000..a2e9d83 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_mtxdm.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ncrypt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ncrypt.a new file mode 100644 index 0000000..7fc769e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ncrypt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_nddeapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_nddeapi.a new file mode 100644 index 0000000..342763b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_nddeapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ndfapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ndfapi.a new file mode 100644 index 0000000..84cb302 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ndfapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_netapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_netapi32.a new file mode 100644 index 0000000..c911148 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_netapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_netsh.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_netsh.a new file mode 100644 index 0000000..7d61716 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_netsh.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_newdev.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_newdev.a new file mode 100644 index 0000000..ab8c387 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_newdev.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ninput.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ninput.a new file mode 100644 index 0000000..59c4f6d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ninput.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_normaliz.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_normaliz.a new file mode 100644 index 0000000..1d94079 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_normaliz.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdll.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdll.a new file mode 100644 index 0000000..80e7086 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdll.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsa.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsa.a new file mode 100644 index 0000000..49ca435 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsa.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsapi.a new file mode 100644 index 0000000..0680ac2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsatq.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsatq.a new file mode 100644 index 0000000..6693ddd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsatq.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsetup.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsetup.a new file mode 100644 index 0000000..cd7ec60 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsetup.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntfrsapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntfrsapi.a new file mode 100644 index 0000000..c7e9963 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntfrsapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntlanman.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntlanman.a new file mode 100644 index 0000000..edc6cc8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntlanman.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntmarta.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntmarta.a new file mode 100644 index 0000000..4ae7a31 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntmarta.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntquery.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntquery.a new file mode 100644 index 0000000..4d3de9e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntquery.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntvdm.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntvdm.a new file mode 100644 index 0000000..3e89f04 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ntvdm.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_odbc32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_odbc32.a new file mode 100644 index 0000000..fd23646 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_odbc32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_odbcbcp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_odbcbcp.a new file mode 100644 index 0000000..757bfe6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_odbcbcp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oemlicense.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oemlicense.a new file mode 100644 index 0000000..b4fa945 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oemlicense.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ole32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ole32.a new file mode 100644 index 0000000..d67b9e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ole32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oleacc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oleacc.a new file mode 100644 index 0000000..7798bcc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oleacc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oleaut32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oleaut32.a new file mode 100644 index 0000000..c4ca15d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_olecli32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_olecli32.a new file mode 100644 index 0000000..df0134c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_olecli32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oledlg.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oledlg.a new file mode 100644 index 0000000..13ede5e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_oledlg.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_olepro32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_olepro32.a new file mode 100644 index 0000000..0d72e0a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_olepro32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_olesvr32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_olesvr32.a new file mode 100644 index 0000000..1a7bcc6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_olesvr32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ondemandconnroutehelper.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ondemandconnroutehelper.a new file mode 100644 index 0000000..9bc7f41 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ondemandconnroutehelper.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-atoms-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-atoms-l1-1-0.a new file mode 100644 index 0000000..c2c4ee8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-atoms-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-calendar-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-calendar-l1-1-0.a new file mode 100644 index 0000000..7c61e51 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-calendar-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-0.a new file mode 100644 index 0000000..2db53c2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-1.a new file mode 100644 index 0000000..2ed3791 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-2.a new file mode 100644 index 0000000..8c3b0a5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-midlproxystub-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-midlproxystub-l1-1-0.a new file mode 100644 index 0000000..a44583d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-midlproxystub-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-0.a new file mode 100644 index 0000000..debbd87 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-1.a new file mode 100644 index 0000000..6173eda Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-ansi-l2-1-0.a new file mode 100644 index 0000000..ccfb05f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l1-1-0.a new file mode 100644 index 0000000..513c391 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l2-1-0.a new file mode 100644 index 0000000..b855681 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l3-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l3-1-0.a new file mode 100644 index 0000000..17292db Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l3-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-0.a new file mode 100644 index 0000000..259340a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-1.a new file mode 100644 index 0000000..e975367 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-2.a new file mode 100644 index 0000000..8f6cf0b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-0.a new file mode 100644 index 0000000..661692e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-1.a new file mode 100644 index 0000000..42e2427 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-2.a new file mode 100644 index 0000000..d07ed03 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-0.a new file mode 100644 index 0000000..65ddcb5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-1.a new file mode 100644 index 0000000..ff137d7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-0.a new file mode 100644 index 0000000..6fb5125 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-1.a new file mode 100644 index 0000000..99e1e13 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-0.a new file mode 100644 index 0000000..7ec7fae Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-1.a new file mode 100644 index 0000000..fddd283 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-2.a new file mode 100644 index 0000000..be10c87 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-3.a new file mode 100644 index 0000000..58b13cf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-0.a new file mode 100644 index 0000000..d16ed5b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-1.a new file mode 100644 index 0000000..b8f32c9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-0.a new file mode 100644 index 0000000..6a7be5c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-1.a new file mode 100644 index 0000000..6e4bd97 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-0.a new file mode 100644 index 0000000..0ec0998 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-1.a new file mode 100644 index 0000000..7b2318d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l1-1-0.a new file mode 100644 index 0000000..81cbf56 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l2-1-0.a new file mode 100644 index 0000000..1a28c11 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-1-0.a new file mode 100644 index 0000000..3e154d8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-0.a new file mode 100644 index 0000000..0952178 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-1.a new file mode 100644 index 0000000..30c22b8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-2.a new file mode 100644 index 0000000..41c50e0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-0.a new file mode 100644 index 0000000..46ee400 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-1.a new file mode 100644 index 0000000..6e9102c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-2.a new file mode 100644 index 0000000..85ccdbd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-3.a new file mode 100644 index 0000000..fed64c7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-firmware-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-firmware-l1-1-0.a new file mode 100644 index 0000000..6eba749 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-firmware-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-handle-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-handle-l1-1-0.a new file mode 100644 index 0000000..cf11e43 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-handle-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l1-1-0.a new file mode 100644 index 0000000..fbb7798 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l2-1-0.a new file mode 100644 index 0000000..06c17f9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-obsolete-l1-1-0.a new file mode 100644 index 0000000..4583e29 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-1-0.a new file mode 100644 index 0000000..c12dcbc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-2-0.a new file mode 100644 index 0000000..147347f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-0.a new file mode 100644 index 0000000..cb1ba6e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-1.a new file mode 100644 index 0000000..475dabd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l1-1-0.a new file mode 100644 index 0000000..2283c49 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-0.a new file mode 100644 index 0000000..9df1ae4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-1.a new file mode 100644 index 0000000..2800170 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a new file mode 100644 index 0000000..f68f945 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-0.a new file mode 100644 index 0000000..99829cd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-1.a new file mode 100644 index 0000000..fa8f4ca Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-2.a new file mode 100644 index 0000000..3684462 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-3.a new file mode 100644 index 0000000..f6b9b1f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-4.a new file mode 100644 index 0000000..5bd0df1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-5.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-5.a new file mode 100644 index 0000000..f92da9a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-5.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-6.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-6.a new file mode 100644 index 0000000..b6a2856 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-6.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-largeinteger-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-largeinteger-l1-1-0.a new file mode 100644 index 0000000..27329df Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-largeinteger-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-0.a new file mode 100644 index 0000000..eef9876 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-1.a new file mode 100644 index 0000000..1e80258 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-2.a new file mode 100644 index 0000000..4d3d079 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l2-1-0.a new file mode 100644 index 0000000..91f3c84 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-ansi-l1-1-0.a new file mode 100644 index 0000000..26ce433 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-0.a new file mode 100644 index 0000000..9a14a0d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-1.a new file mode 100644 index 0000000..83379f2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-2.a new file mode 100644 index 0000000..fa02d66 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l2-1-0.a new file mode 100644 index 0000000..ea220e5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-obsolete-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-obsolete-l1-2-0.a new file mode 100644 index 0000000..87596ba Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-obsolete-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-0.a new file mode 100644 index 0000000..eca5a6d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-1.a new file mode 100644 index 0000000..2b38223 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-2.a new file mode 100644 index 0000000..d5eff90 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-3.a new file mode 100644 index 0000000..b15224b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-4.a new file mode 100644 index 0000000..13f8dac Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-5.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-5.a new file mode 100644 index 0000000..aacbef7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-5.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-0.a new file mode 100644 index 0000000..5856a2d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-1.a new file mode 100644 index 0000000..cce807e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-1-0.a new file mode 100644 index 0000000..80ed8f7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-1.a new file mode 100644 index 0000000..1f3847f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-2.a new file mode 100644 index 0000000..fbb9ae5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-ansi-l1-1-0.a new file mode 100644 index 0000000..bb3a894 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-l1-1-0.a new file mode 100644 index 0000000..37c9286 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-normalization-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-normalization-l1-1-0.a new file mode 100644 index 0000000..73467bf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-normalization-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-path-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-path-l1-1-0.a new file mode 100644 index 0000000..d5ec99b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-perfcounters-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-perfcounters-l1-1-0.a new file mode 100644 index 0000000..bd95a8e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-perfcounters-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-0.a new file mode 100644 index 0000000..c315b80 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-1.a new file mode 100644 index 0000000..e9ad789 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-ansi-l1-1-0.a new file mode 100644 index 0000000..194897f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-1-0.a new file mode 100644 index 0000000..f9b9240 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-2-0.a new file mode 100644 index 0000000..d764462 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processsnapshot-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processsnapshot-l1-1-0.a new file mode 100644 index 0000000..1ce0f27 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processsnapshot-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-0.a new file mode 100644 index 0000000..7cc0145 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-1.a new file mode 100644 index 0000000..380b17d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-2.a new file mode 100644 index 0000000..f839784 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-3.a new file mode 100644 index 0000000..8184fdb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-l1-1-0.a new file mode 100644 index 0000000..adacab8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a new file mode 100644 index 0000000..2864517 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a new file mode 100644 index 0000000..bd18213 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-profile-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-profile-l1-1-0.a new file mode 100644 index 0000000..bf3ec65 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-profile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-ansi-l1-1-0.a new file mode 100644 index 0000000..2fa6889 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-l1-1-0.a new file mode 100644 index 0000000..9219940 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-0.a new file mode 100644 index 0000000..01cbecd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-1.a new file mode 100644 index 0000000..1004cc7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-0.a new file mode 100644 index 0000000..d57a762 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-1.a new file mode 100644 index 0000000..50bd71b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-2.a new file mode 100644 index 0000000..d0681f4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-0.a new file mode 100644 index 0000000..6aa4e5e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-1.a new file mode 100644 index 0000000..d498e10 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-2.a new file mode 100644 index 0000000..2220e0b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l2-1-0.a new file mode 100644 index 0000000..ef780e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-1-0.a new file mode 100644 index 0000000..b8ebe48 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-2-0.a new file mode 100644 index 0000000..90f300e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-ansi-l1-1-0.a new file mode 100644 index 0000000..6ce9bfe Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-0.a new file mode 100644 index 0000000..689a947 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-1.a new file mode 100644 index 0000000..f38473f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-ansi-l1-1-0.a new file mode 100644 index 0000000..be66082 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-l1-1-0.a new file mode 100644 index 0000000..81d1d55 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l1-1-0.a new file mode 100644 index 0000000..b7f3b32 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-0.a new file mode 100644 index 0000000..3ac0d3e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-1.a new file mode 100644 index 0000000..802f6ab Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-0.a new file mode 100644 index 0000000..6f97616 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-1.a new file mode 100644 index 0000000..8575b17 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-stringansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-stringansi-l1-1-0.a new file mode 100644 index 0000000..0cb8c5b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-stringansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-ansi-l1-1-0.a new file mode 100644 index 0000000..81eb6ff Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-1-0.a new file mode 100644 index 0000000..9f7c44b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-0.a new file mode 100644 index 0000000..ddf3657 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-1.a new file mode 100644 index 0000000..8869781 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-1-0.a new file mode 100644 index 0000000..9502df4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-0.a new file mode 100644 index 0000000..32bc9b5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-1.a new file mode 100644 index 0000000..f7d3a71 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-2.a new file mode 100644 index 0000000..96b44ba Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-3.a new file mode 100644 index 0000000..0bcca45 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-0.a new file mode 100644 index 0000000..0b9b344 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-1.a new file mode 100644 index 0000000..ae2704a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-l1-2-0.a new file mode 100644 index 0000000..1e776e6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-legacy-l1-1-0.a new file mode 100644 index 0000000..0728238 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-timezone-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-timezone-l1-1-0.a new file mode 100644 index 0000000..cc8d2d1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-timezone-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-0.a new file mode 100644 index 0000000..b850a71 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-1.a new file mode 100644 index 0000000..5be0ae2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-url-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-url-l1-1-0.a new file mode 100644 index 0000000..4fe81e6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-url-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-0.a new file mode 100644 index 0000000..8540db9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-1.a new file mode 100644 index 0000000..4776cf0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-0.a new file mode 100644 index 0000000..42e9fc7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-1.a new file mode 100644 index 0000000..cae8f2b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-0.a new file mode 100644 index 0000000..66013bb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-1.a new file mode 100644 index 0000000..d75ae32 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowsceip-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowsceip-l1-1-0.a new file mode 100644 index 0000000..e7bf92d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowsceip-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-0.a new file mode 100644 index 0000000..c1d7610 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-1.a new file mode 100644 index 0000000..02beef3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-2.a new file mode 100644 index 0000000..187c36d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-0.a new file mode 100644 index 0000000..5241405 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-1.a new file mode 100644 index 0000000..36a8368 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..e04d55a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-registration-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-registration-l1-1-0.a new file mode 100644 index 0000000..5809036 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-registration-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-robuffer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-robuffer-l1-1-0.a new file mode 100644 index 0000000..4e2fc98 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-robuffer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a new file mode 100644 index 0000000..87546a3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-0.a new file mode 100644 index 0000000..0a0efd3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-1.a new file mode 100644 index 0000000..c4b1b7a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-0.a new file mode 100644 index 0000000..83383b5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-1.a new file mode 100644 index 0000000..9df889c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-2.a new file mode 100644 index 0000000..2a7c925 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-xstate-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-xstate-l2-1-0.a new file mode 100644 index 0000000..0fadeb8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-xstate-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-1.a new file mode 100644 index 0000000..1d7150d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-2.a new file mode 100644 index 0000000..6d2cc7f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-0.a new file mode 100644 index 0000000..dbd9b16 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-1.a new file mode 100644 index 0000000..48f2bfc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-classicprovider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-classicprovider-l1-1-0.a new file mode 100644 index 0000000..295bd58 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-classicprovider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-0.a new file mode 100644 index 0000000..864abc4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-1.a new file mode 100644 index 0000000..c264aa5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-controller-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-controller-l1-1-0.a new file mode 100644 index 0000000..ea213e6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-controller-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-legacy-l1-1-0.a new file mode 100644 index 0000000..4d50887 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-obsolete-l1-1-0.a new file mode 100644 index 0000000..3b1c82d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-provider-l1-1-0.a new file mode 100644 index 0000000..71e1e78 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-tdh-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-tdh-l1-1-0.a new file mode 100644 index 0000000..e60e2ca Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-tdh-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-gaming-deviceinformation-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-gaming-deviceinformation-l1-1-0.a new file mode 100644 index 0000000..fc97f88 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-gaming-deviceinformation-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-mm-time-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-mm-time-l1-1-0.a new file mode 100644 index 0000000..96300ac Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-mm-time-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-oobe-notification-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-oobe-notification-l1-1-0.a new file mode 100644 index 0000000..ad8d94c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-oobe-notification-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-perf-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-perf-legacy-l1-1-0.a new file mode 100644 index 0000000..1f6c661 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-perf-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-base-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-base-l1-1-0.a new file mode 100644 index 0000000..4984baf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-limitsmanagement-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-limitsmanagement-l1-1-0.a new file mode 100644 index 0000000..4a63543 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-limitsmanagement-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-setting-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-setting-l1-1-0.a new file mode 100644 index 0000000..15a7576 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-setting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-ro-typeresolution-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-ro-typeresolution-l1-1-0.a new file mode 100644 index 0000000..78fe45c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-ro-typeresolution-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-appcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-appcontainer-l1-1-0.a new file mode 100644 index 0000000..b72174d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-appcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-ansi-l1-1-0.a new file mode 100644 index 0000000..7479dcb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-1-0.a new file mode 100644 index 0000000..5ff5c77 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-0.a new file mode 100644 index 0000000..01ca929 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-1.a new file mode 100644 index 0000000..0b8c454 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-2.a new file mode 100644 index 0000000..1456aa2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-credentials-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-credentials-l1-1-0.a new file mode 100644 index 0000000..fea42bc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-credentials-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-cryptoapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-cryptoapi-l1-1-0.a new file mode 100644 index 0000000..05bc54f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-cryptoapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-isolatedcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-isolatedcontainer-l1-1-0.a new file mode 100644 index 0000000..a40304e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-isolatedcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-ansi-l2-1-0.a new file mode 100644 index 0000000..c7d2ac5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-0.a new file mode 100644 index 0000000..ff570a4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-1.a new file mode 100644 index 0000000..70171ff Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-ansi-l1-1-0.a new file mode 100644 index 0000000..130a97a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-l1-1-0.a new file mode 100644 index 0000000..44769ba Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-ansi-l1-1-0.a new file mode 100644 index 0000000..71abeae Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-l1-1-0.a new file mode 100644 index 0000000..c76980e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-systemfunctions-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-systemfunctions-l1-1-0.a new file mode 100644 index 0000000..fb1ecf9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-systemfunctions-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-0.a new file mode 100644 index 0000000..2bf98a2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-1.a new file mode 100644 index 0000000..8617b78 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-0.a new file mode 100644 index 0000000..51823b6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-1.a new file mode 100644 index 0000000..31cc7bd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-2.a new file mode 100644 index 0000000..08da8f9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l1-1-0.a new file mode 100644 index 0000000..26e0595 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l2-1-0.a new file mode 100644 index 0000000..627d39a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-winsvc-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-winsvc-l1-1-0.a new file mode 100644 index 0000000..1565aec Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-winsvc-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-path-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-path-l1-1-0.a new file mode 100644 index 0000000..a52709c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-0.a new file mode 100644 index 0000000..8640562 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-1.a new file mode 100644 index 0000000..21a7b25 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-0.a new file mode 100644 index 0000000..060bb7e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-1.a new file mode 100644 index 0000000..16b4cfa Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-2.a new file mode 100644 index 0000000..241fe8a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-stream-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-stream-winrt-l1-1-0.a new file mode 100644 index 0000000..090a767 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-stream-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-sysinfo-l1-1-0.a new file mode 100644 index 0000000..8ffbed6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-unicodeansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-unicodeansi-l1-1-0.a new file mode 100644 index 0000000..85b89e5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-unicodeansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shell-shdirectory-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shell-shdirectory-l1-1-0.a new file mode 100644 index 0000000..e5cc513 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shell-shdirectory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-authz.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-authz.a new file mode 100644 index 0000000..dc567b9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-authz.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-bcrypt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-bcrypt.a new file mode 100644 index 0000000..342fb81 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-bcrypt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cabinet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cabinet.a new file mode 100644 index 0000000..6bdc6f7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-crypt32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-crypt32.a new file mode 100644 index 0000000..969e65c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-crypt32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptbase.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptbase.a new file mode 100644 index 0000000..6ac75f3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptbase.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptnet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptnet.a new file mode 100644 index 0000000..6902bb9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptnet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dfscli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dfscli.a new file mode 100644 index 0000000..21032cb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dfscli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dnsapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dnsapi.a new file mode 100644 index 0000000..1790b32 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dnsapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsparse.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsparse.a new file mode 100644 index 0000000..7f3c473 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsparse.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsrole.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsrole.a new file mode 100644 index 0000000..9a47f73 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsrole.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-fltlib.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-fltlib.a new file mode 100644 index 0000000..64acccb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-fltlib.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-iphlpapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-iphlpapi.a new file mode 100644 index 0000000..4a4d381 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-iphlpapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-logoncli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-logoncli.a new file mode 100644 index 0000000..f1bedd2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-logoncli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mpr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mpr.a new file mode 100644 index 0000000..5eedf3e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mpr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mswsock.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mswsock.a new file mode 100644 index 0000000..9628c6e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ncrypt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ncrypt.a new file mode 100644 index 0000000..8c3ce43 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ncrypt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-netutils.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-netutils.a new file mode 100644 index 0000000..507b426 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-netutils.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ntdll.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ntdll.a new file mode 100644 index 0000000..80bb8a3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ntdll.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-oleaut32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-oleaut32.a new file mode 100644 index 0000000..0826152 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-powrprof.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-powrprof.a new file mode 100644 index 0000000..a3c11c7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-powrprof.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-profapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-profapi.a new file mode 100644 index 0000000..9c1963a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-profapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-rpcrt4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-rpcrt4.a new file mode 100644 index 0000000..d31ddcf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-samcli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-samcli.a new file mode 100644 index 0000000..a152c1c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-samcli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-schedcli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-schedcli.a new file mode 100644 index 0000000..3710a6c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-schedcli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-srvcli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-srvcli.a new file mode 100644 index 0000000..22fedc0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-srvcli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-sspicli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-sspicli.a new file mode 100644 index 0000000..0a757d8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-sspicli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-tokenbinding.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-tokenbinding.a new file mode 100644 index 0000000..cb011b9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-tokenbinding.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-userenv.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-userenv.a new file mode 100644 index 0000000..e738082 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-userenv.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-websocket.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-websocket.a new file mode 100644 index 0000000..7132ea0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-websocket.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-winhttp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-winhttp.a new file mode 100644 index 0000000..9663971 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-winhttp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wkscli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wkscli.a new file mode 100644 index 0000000..c81dae9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wkscli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wldap32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wldap32.a new file mode 100644 index 0000000..4204b02 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wldap32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ws2_32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ws2_32.a new file mode 100644 index 0000000..dd6afac Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-xmllite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-xmllite.a new file mode 100644 index 0000000..11a809b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-xmllite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore.a new file mode 100644 index 0000000..c3ad603 --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore.a @@ -0,0 +1,257 @@ +INPUT( +libwinapi_onecore-api-ms-win-core-processtopology-l1-1-0.a +libwinapi_onecore-dsparse.a +libwinapi_onecore-api-ms-win-core-fibers-l2-1-1.a +libwinapi_onecore-api-ms-win-service-core-l1-1-1.a +libwinapi_onecore-api-ms-win-core-rtlsupport-l1-1-0.a +libwinapi_onecore-api-ms-win-core-heap-l2-1-0.a +libwinapi_onecore-netutils.a +libwinapi_onecore-profapi.a +libwinapi_onecore-api-ms-win-core-rtlsupport-l1-2-0.a +libwinapi_onecore-sspicli.a +libwinapi_onecore-websocket.a +libwinapi_onecore-api-ms-win-power-base-l1-1-0.a +libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-2.a +libwinapi_onecore-api-ms-win-core-largeinteger-l1-1-0.a +libwinapi_onecore-api-ms-win-core-namespace-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-wow64-l1-1-2.a +libwinapi_onecore-api-ms-win-core-debug-l1-1-1.a +libwinapi_onecore-rpcrt4.a +libwinapi_onecore-api-ms-win-eventing-controller-l1-1-0.a +libwinapi_onecore-api-ms-win-security-base-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-console-l1-1-0.a +libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-2.a +libwinapi_onecore-mswsock.a +libwinapi_onecore-api-ms-win-core-fibers-l2-1-0.a +libwinapi_onecore-api-ms-win-shell-shdirectory-l1-1-0.a +libwinapi_onecore-api-ms-win-core-version-l1-1-1.a +libwinapi_onecore-api-ms-win-core-processthreads-l1-1-2.a +libwinapi_onecore-dsrole.a +libwinapi_onecore-schedcli.a +libwinapi_onecore-api-ms-win-core-winrt-l1-1-0.a +libwinapi_onecore-api-ms-win-core-perfcounters-l1-1-0.a +libwinapi_onecore-api-ms-win-core-stringansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-2.a +libwinapi_onecore-api-ms-win-core-debug-l1-1-2.a +libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-1.a +libwinapi_onecore-api-ms-win-shcore-registry-l1-1-0.a +libwinapi_onecore-api-ms-win-core-com-l1-1-1.a +libwinapi_onecore-api-ms-win-devices-config-l1-1-1.a +libwinapi_onecore-api-ms-win-core-datetime-l1-1-1.a +libwinapi_onecore-api-ms-win-service-management-l1-1-0.a +libwinapi_onecore-api-ms-win-core-windowsceip-l1-1-0.a +libwinapi_onecore-api-ms-win-core-threadpool-legacy-l1-1-0.a +libwinapi_onecore-api-ms-win-security-base-l1-2-2.a +libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-0.a +libwinapi_onecore-api-ms-win-security-base-l1-2-0.a +libwinapi_onecore-api-ms-win-core-namedpipe-l1-1-0.a +libwinapi_onecore-api-ms-win-core-timezone-l1-1-0.a +libwinapi_onecore-api-ms-win-core-shutdown-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-threadpool-l1-2-0.a +libwinapi_onecore-api-ms-win-core-file-l2-1-0.a +libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-debug-l1-1-0.a +libwinapi_onecore-fltlib.a +libwinapi_onecore-api-ms-win-core-fibers-l1-1-0.a +libwinapi_onecore-api-ms-win-core-versionansi-l1-1-0.a +libwinapi_onecore-winhttp.a +libwinapi_onecore-api-ms-win-core-file-l1-2-2.a +libwinapi_onecore-api-ms-win-core-registry-l1-1-1.a +libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-3.a +libwinapi_onecore-tokenbinding.a +libwinapi_onecore-api-ms-win-core-shutdown-l1-1-0.a +libwinapi_onecore-api-ms-win-power-setting-l1-1-0.a +libwinapi_onecore-api-ms-win-core-comm-l1-1-0.a +libwinapi_onecore-srvcli.a +libwinapi_onecore-api-ms-win-core-versionansi-l1-1-1.a +libwinapi_onecore-api-ms-win-core-console-l2-1-0.a +libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-1.a +libwinapi_onecore-api-ms-win-shcore-unicodeansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-0.a +libwinapi_onecore-api-ms-win-security-sddl-l1-1-0.a +libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-2.a +libwinapi_onecore-api-ms-win-core-sidebyside-ansi-l1-1-0.a +libwinapi_onecore-logoncli.a +libwinapi_onecore-api-ms-win-core-path-l1-1-0.a +libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-0.a +libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-1.a +libwinapi_onecore-api-ms-win-core-realtime-l1-1-2.a +libwinapi_onecore-api-ms-win-core-com-l1-1-2.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-0.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-1.a +libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-1.a +libwinapi_onecore-api-ms-win-service-core-l1-1-0.a +libwinapi_onecore-wldap32.a +libwinapi_onecore-api-ms-win-eventing-classicprovider-l1-1-0.a +libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-0.a +libwinapi_onecore-api-ms-win-core-url-l1-1-0.a +libwinapi_onecore-api-ms-win-security-appcontainer-l1-1-0.a +libwinapi_onecore-api-ms-win-core-firmware-l1-1-0.a +libwinapi_onecore-api-ms-win-core-delayload-l1-1-0.a +libwinapi_onecore-api-ms-win-core-psapi-ansi-l1-1-0.a +libwinapi_onecore-iphlpapi.a +libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-util-l1-1-0.a +libwinapi_onecore-api-ms-win-core-job-l2-1-1.a +libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-3.a +libwinapi_onecore-ws2_32.a +libwinapi_onecore-api-ms-win-core-xstate-l2-1-0.a +libwinapi_onecore-api-ms-win-core-enclave-l1-1-0.a +libwinapi_onecore-api-ms-win-shcore-path-l1-1-0.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-0.a +libwinapi_onecore-api-ms-win-eventing-tdh-l1-1-0.a +libwinapi_onecore-api-ms-win-core-file-l1-1-0.a +libwinapi_onecore-bcrypt.a +libwinapi_onecore-api-ms-win-core-synch-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-processthreads-l1-1-0.a +libwinapi_onecore-api-ms-win-security-cryptoapi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-1.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-console-l3-1-0.a +libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-1.a +libwinapi_onecore-api-ms-win-core-psapi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-sysinfo-l1-1-0.a +libwinapi_onecore-cabinet.a +libwinapi_onecore-api-ms-win-core-string-l1-1-0.a +libwinapi_onecore-api-ms-win-devices-config-l1-1-2.a +libwinapi_onecore-api-ms-win-core-processenvironment-l1-2-0.a +libwinapi_onecore-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a +libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-1.a +libwinapi_onecore-api-ms-win-shcore-stream-winrt-l1-1-0.a +libwinapi_onecore-api-ms-win-power-limitsmanagement-l1-1-0.a +libwinapi_onecore-api-ms-win-core-profile-l1-1-0.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-2.a +libwinapi_onecore-api-ms-win-core-winrt-robuffer-l1-1-0.a +libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-1.a +libwinapi_onecore-api-ms-win-security-systemfunctions-l1-1-0.a +libwinapi_onecore-api-ms-win-security-isolatedcontainer-l1-1-0.a +libwinapi_onecore-api-ms-win-core-enclave-l1-1-1.a +libwinapi_onecore-api-ms-win-eventing-legacy-l1-1-0.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-3.a +libwinapi_onecore-api-ms-win-core-registry-l2-1-0.a +libwinapi_onecore-api-ms-win-core-datetime-l1-1-2.a +libwinapi_onecore-api-ms-win-core-wow64-l1-1-1.a +libwinapi_onecore-api-ms-win-core-synch-l1-1-0.a +libwinapi_onecore-api-ms-win-core-namespace-l1-1-0.a +libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-1.a +libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-0.a +libwinapi_onecore-api-ms-win-core-job-l1-1-0.a +libwinapi_onecore-api-ms-win-core-processenvironment-l1-1-0.a +libwinapi_onecore-api-ms-win-core-file-ansi-l2-1-0.a +libwinapi_onecore-oleaut32.a +libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-0.a +libwinapi_onecore-api-ms-win-core-file-l1-2-1.a +libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-0.a +libwinapi_onecore-api-ms-win-core-io-l1-1-1.a +libwinapi_onecore-api-ms-win-oobe-notification-l1-1-0.a +libwinapi_onecore-userenv.a +libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-0.a +libwinapi_onecore-api-ms-win-core-localization-l2-1-0.a +libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-1.a +libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-2.a +libwinapi_onecore-api-ms-win-core-file-l2-1-2.a +libwinapi_onecore-api-ms-win-core-version-l1-1-0.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-5.a +libwinapi_onecore-api-ms-win-core-calendar-l1-1-0.a +libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-1.a +libwinapi_onecore-api-ms-win-core-interlocked-l1-1-0.a +libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-1.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-4.a +libwinapi_onecore-xmllite.a +libwinapi_onecore-api-ms-win-core-fibers-l1-1-1.a +libwinapi_onecore-api-ms-win-core-com-midlproxystub-l1-1-0.a +libwinapi_onecore-api-ms-win-gaming-deviceinformation-l1-1-0.a +libwinapi_onecore-api-ms-win-ro-typeresolution-l1-1-0.a +libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-1.a +libwinapi_onecore-wkscli.a +libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-1.a +libwinapi_onecore-api-ms-win-core-file-l1-2-0.a +libwinapi_onecore-api-ms-win-core-localization-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-normalization-l1-1-0.a +libwinapi_onecore-mpr.a +libwinapi_onecore-powrprof.a +libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-0.a +libwinapi_onecore-api-ms-win-core-delayload-l1-1-1.a +libwinapi_onecore-dfscli.a +libwinapi_onecore-api-ms-win-core-processsnapshot-l1-1-0.a +libwinapi_onecore-crypt32.a +libwinapi_onecore-api-ms-win-service-winsvc-l1-1-0.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-1.a +libwinapi_onecore-api-ms-win-security-provider-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-2.a +libwinapi_onecore-api-ms-win-core-quirks-l1-1-0.a +libwinapi_onecore-api-ms-win-core-realtime-l1-1-0.a +libwinapi_onecore-api-ms-win-core-localization-l1-2-1.a +libwinapi_onecore-api-ms-win-core-handle-l1-1-0.a +libwinapi_onecore-api-ms-win-core-registry-l1-1-0.a +libwinapi_onecore-api-ms-win-core-winrt-registration-l1-1-0.a +libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-0.a +libwinapi_onecore-api-ms-win-core-file-l2-1-1.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-5.a +libwinapi_onecore-api-ms-win-core-quirks-l1-1-1.a +libwinapi_onecore-cryptbase.a +libwinapi_onecore-api-ms-win-core-localization-obsolete-l1-2-0.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-2.a +libwinapi_onecore-api-ms-win-core-file-l2-1-3.a +libwinapi_onecore-api-ms-win-core-util-l1-1-1.a +libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-0.a +libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-0.a +libwinapi_onecore-authz.a +libwinapi_onecore-api-ms-win-core-processenvironment-ansi-l1-1-0.a +libwinapi_onecore-cryptnet.a +libwinapi_onecore-samcli.a +libwinapi_onecore-api-ms-win-security-provider-l1-1-0.a +libwinapi_onecore-api-ms-win-core-io-l1-1-0.a +libwinapi_onecore-api-ms-win-core-processthreads-l1-1-1.a +libwinapi_onecore-api-ms-win-core-string-l2-1-0.a +libwinapi_onecore-api-ms-win-core-com-l1-1-0.a +libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a +libwinapi_onecore-api-ms-win-core-sidebyside-l1-1-0.a +libwinapi_onecore-api-ms-win-core-synch-l1-2-1.a +libwinapi_onecore-api-ms-win-core-file-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-synch-l1-2-0.a +libwinapi_onecore-api-ms-win-security-sddl-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-registry-l1-1-2.a +libwinapi_onecore-api-ms-win-core-job-l2-1-0.a +libwinapi_onecore-api-ms-win-eventing-obsolete-l1-1-0.a +libwinapi_onecore-api-ms-win-shcore-registry-l1-1-1.a +libwinapi_onecore-api-ms-win-core-processthreads-l1-1-3.a +libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-1.a +libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-1.a +libwinapi_onecore-api-ms-win-core-console-ansi-l2-1-0.a +libwinapi_onecore-ntdll.a +libwinapi_onecore-api-ms-win-core-heap-l1-1-0.a +libwinapi_onecore-api-ms-win-core-shutdown-l1-1-1.a +libwinapi_onecore-api-ms-win-security-lsalookup-ansi-l2-1-0.a +libwinapi_onecore-api-ms-win-core-atoms-l1-1-0.a +libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-0.a +libwinapi_onecore-api-ms-win-service-core-l1-1-2.a +libwinapi_onecore-api-ms-win-perf-legacy-l1-1-0.a +libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a +libwinapi_onecore-api-ms-win-security-base-l1-2-1.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-6.a +libwinapi_onecore-api-ms-win-mm-time-l1-1-0.a +libwinapi_onecore-api-ms-win-core-interlocked-l1-2-0.a +libwinapi_onecore-api-ms-win-security-base-l1-1-0.a +libwinapi_onecore-api-ms-win-core-string-l2-1-1.a +libwinapi_onecore-dnsapi.a +libwinapi_onecore-api-ms-win-security-credentials-l1-1-0.a +libwinapi_onecore-api-ms-win-core-localization-l1-2-0.a +libwinapi_onecore-api-ms-win-core-realtime-l1-1-1.a +libwinapi_onecore-ncrypt.a +libwinapi_onecore-api-ms-win-eventing-provider-l1-1-0.a +libwinapi_onecore-api-ms-win-core-heap-obsolete-l1-1-0.a +libwinapi_onecore-api-ms-win-core-libraryloader-l2-1-0.a +libwinapi_onecore-api-ms-win-service-management-l2-1-0.a +libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-0.a +libwinapi_onecore-api-ms-win-core-wow64-l1-1-0.a +libwinapi_onecore-api-ms-win-core-comm-l1-1-1.a +libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-1.a +libwinapi_onecore-api-ms-win-shcore-sysinfo-l1-1-0.a +libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-1.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-4.a +libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-0.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-3.a +libwinapi_onecore-api-ms-win-core-datetime-l1-1-0.a +libwinapi_onecore-api-ms-win-core-localization-l1-2-2.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-advapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-advapi32.a new file mode 100644 index 0000000..314d810 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-advapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-apphelp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-apphelp.a new file mode 100644 index 0000000..2ef14fc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-apphelp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comctl32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comctl32.a new file mode 100644 index 0000000..602b8d9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comctl32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comdlg32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comdlg32.a new file mode 100644 index 0000000..38f813a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comdlg32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d10.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d10.a new file mode 100644 index 0000000..dd5bb6f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d10.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d9.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d9.a new file mode 100644 index 0000000..64b7af3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d9.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3dx10_47.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3dx10_47.a new file mode 100644 index 0000000..58d4988 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3dx10_47.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-difxapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-difxapi.a new file mode 100644 index 0000000..50dbbce Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-difxapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-gdi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-gdi32.a new file mode 100644 index 0000000..add0a8a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-gdi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-input.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-input.a new file mode 100644 index 0000000..04d65a5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-input.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-kernel32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-kernel32.a new file mode 100644 index 0000000..684b7fe Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-kernel32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-msi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-msi.a new file mode 100644 index 0000000..51066ec Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-msi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-newdev.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-newdev.a new file mode 100644 index 0000000..6cec780 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-newdev.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-ole32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-ole32.a new file mode 100644 index 0000000..dfed73c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-ole32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleacc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleacc.a new file mode 100644 index 0000000..148ebb6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleacc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleaut32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleaut32.a new file mode 100644 index 0000000..9b7ad48 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oledlg.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oledlg.a new file mode 100644 index 0000000..db4cadb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oledlg.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-pdh.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-pdh.a new file mode 100644 index 0000000..2e35094 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-pdh.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-psapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-psapi.a new file mode 100644 index 0000000..35392b5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-psapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-resutils.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-resutils.a new file mode 100644 index 0000000..cef1a98 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-resutils.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-rstrtmgr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-rstrtmgr.a new file mode 100644 index 0000000..2c39e82 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-rstrtmgr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-secur32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-secur32.a new file mode 100644 index 0000000..8fb6e17 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-secur32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-setupapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-setupapi.a new file mode 100644 index 0000000..8a2da40 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-setupapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shell32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shell32.a new file mode 100644 index 0000000..4c28c5e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shell32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shlwapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shlwapi.a new file mode 100644 index 0000000..5d29e54 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shlwapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-tdh.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-tdh.a new file mode 100644 index 0000000..68c9cfc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-tdh.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-twinapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-twinapi.a new file mode 100644 index 0000000..f64e27f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-twinapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-user32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-user32.a new file mode 100644 index 0000000..7580f01 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-user32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-uxtheme.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-uxtheme.a new file mode 100644 index 0000000..7c0324e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-uxtheme.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-version.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-version.a new file mode 100644 index 0000000..96c37d5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-version.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winmm.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winmm.a new file mode 100644 index 0000000..62408c8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winmm.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winspool.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winspool.a new file mode 100644 index 0000000..310598e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winspool.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-wtsapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-wtsapi32.a new file mode 100644 index 0000000..03c2196 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-wtsapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-xinput1_4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-xinput1_4.a new file mode 100644 index 0000000..1fae183 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-xinput1_4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel.a new file mode 100644 index 0000000..1f06d2c --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel.a @@ -0,0 +1,36 @@ +INPUT( +libwinapi_onecore_downlevel-wtsapi32.a +libwinapi_onecore_downlevel-advapi32.a +libwinapi_onecore_downlevel-rstrtmgr.a +libwinapi_onecore_downlevel-setupapi.a +libwinapi_onecore_downlevel-apphelp.a +libwinapi_onecore_downlevel-gdi32.a +libwinapi_onecore_downlevel-winmm.a +libwinapi_onecore_downlevel-d3d10.a +libwinapi_onecore_downlevel-uxtheme.a +libwinapi_onecore_downlevel-ole32.a +libwinapi_onecore_downlevel-psapi.a +libwinapi_onecore_downlevel-kernel32.a +libwinapi_onecore_downlevel-winspool.a +libwinapi_onecore_downlevel-oleaut32.a +libwinapi_onecore_downlevel-tdh.a +libwinapi_onecore_downlevel-twinapi.a +libwinapi_onecore_downlevel-secur32.a +libwinapi_onecore_downlevel-shlwapi.a +libwinapi_onecore_downlevel-newdev.a +libwinapi_onecore_downlevel-difxapi.a +libwinapi_onecore_downlevel-oledlg.a +libwinapi_onecore_downlevel-input.a +libwinapi_onecore_downlevel-d3d9.a +libwinapi_onecore_downlevel-msi.a +libwinapi_onecore_downlevel-user32.a +libwinapi_onecore_downlevel-d3dx10_47.a +libwinapi_onecore_downlevel-resutils.a +libwinapi_onecore_downlevel-shell32.a +libwinapi_onecore_downlevel-version.a +libwinapi_onecore_downlevel-xinput1_4.a +libwinapi_onecore_downlevel-comctl32.a +libwinapi_onecore_downlevel-comdlg32.a +libwinapi_onecore_downlevel-pdh.a +libwinapi_onecore_downlevel-oleacc.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-0.a new file mode 100644 index 0000000..34c5cfe Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-1.a new file mode 100644 index 0000000..5377724 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-2.a new file mode 100644 index 0000000..9c2a560 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-atoms-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-atoms-l1-1-0.a new file mode 100644 index 0000000..580b121 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-atoms-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-calendar-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-calendar-l1-1-0.a new file mode 100644 index 0000000..ac6ad70 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-calendar-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-0.a new file mode 100644 index 0000000..12c03a9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-1.a new file mode 100644 index 0000000..e651f7a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-2.a new file mode 100644 index 0000000..ef3e283 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l2-1-1.a new file mode 100644 index 0000000..200562f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-midlproxystub-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-midlproxystub-l1-1-0.a new file mode 100644 index 0000000..d919aa0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-midlproxystub-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-0.a new file mode 100644 index 0000000..fad1bbd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-1.a new file mode 100644 index 0000000..0fbf6f0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-ansi-l2-1-0.a new file mode 100644 index 0000000..f93dcca Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l1-1-0.a new file mode 100644 index 0000000..86571f8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l2-1-0.a new file mode 100644 index 0000000..f05df95 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l3-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l3-1-0.a new file mode 100644 index 0000000..0fdb740 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l3-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-0.a new file mode 100644 index 0000000..17ad076 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-1.a new file mode 100644 index 0000000..ad82476 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-2.a new file mode 100644 index 0000000..d80882c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-0.a new file mode 100644 index 0000000..120d9c2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-1.a new file mode 100644 index 0000000..5830e40 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-2.a new file mode 100644 index 0000000..3c79b22 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-0.a new file mode 100644 index 0000000..4a549f5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-1.a new file mode 100644 index 0000000..eeff9d7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-0.a new file mode 100644 index 0000000..4cb11c5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-1.a new file mode 100644 index 0000000..cbf774d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-0.a new file mode 100644 index 0000000..9eaefd3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-1.a new file mode 100644 index 0000000..2e09d38 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-2.a new file mode 100644 index 0000000..c6a8116 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-3.a new file mode 100644 index 0000000..87b7de3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-0.a new file mode 100644 index 0000000..934487f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-1.a new file mode 100644 index 0000000..5914210 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-0.a new file mode 100644 index 0000000..34bc395 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-1.a new file mode 100644 index 0000000..5be5cdc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-0.a new file mode 100644 index 0000000..89f3886 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-1.a new file mode 100644 index 0000000..33455c4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l1-1-0.a new file mode 100644 index 0000000..d5c537f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l2-1-0.a new file mode 100644 index 0000000..fd16532 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-1-0.a new file mode 100644 index 0000000..d9e9d62 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-0.a new file mode 100644 index 0000000..afd312a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-1.a new file mode 100644 index 0000000..c696160 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-2.a new file mode 100644 index 0000000..3f2827f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-0.a new file mode 100644 index 0000000..1a69ba4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-1.a new file mode 100644 index 0000000..a41758d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-2.a new file mode 100644 index 0000000..b6b82a0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-3.a new file mode 100644 index 0000000..168c5d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-firmware-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-firmware-l1-1-0.a new file mode 100644 index 0000000..d6d8f33 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-firmware-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-handle-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-handle-l1-1-0.a new file mode 100644 index 0000000..a10670a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-handle-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l1-1-0.a new file mode 100644 index 0000000..66aa0a2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l2-1-0.a new file mode 100644 index 0000000..fb98b8c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-obsolete-l1-1-0.a new file mode 100644 index 0000000..66e3bc3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-1-0.a new file mode 100644 index 0000000..9e3f04a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-2-0.a new file mode 100644 index 0000000..7b25460 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-0.a new file mode 100644 index 0000000..e48f18b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-1.a new file mode 100644 index 0000000..46c278a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l1-1-0.a new file mode 100644 index 0000000..8a37379 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-0.a new file mode 100644 index 0000000..f6b963f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-1.a new file mode 100644 index 0000000..57f6c65 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a new file mode 100644 index 0000000..bfe0a0e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-0.a new file mode 100644 index 0000000..b7b0e5d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-1.a new file mode 100644 index 0000000..04032ed Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-2.a new file mode 100644 index 0000000..501a25d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-3.a new file mode 100644 index 0000000..bff675b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-4.a new file mode 100644 index 0000000..80385d3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-5.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-5.a new file mode 100644 index 0000000..6da5dbd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-5.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-6.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-6.a new file mode 100644 index 0000000..28392ac Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-6.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-largeinteger-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-largeinteger-l1-1-0.a new file mode 100644 index 0000000..fb18a93 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-largeinteger-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-0.a new file mode 100644 index 0000000..cc2f7f6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-1.a new file mode 100644 index 0000000..4bdd3e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-2.a new file mode 100644 index 0000000..7f5b87a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l2-1-0.a new file mode 100644 index 0000000..554bd28 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-ansi-l1-1-0.a new file mode 100644 index 0000000..e8e2de6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-0.a new file mode 100644 index 0000000..592dfbd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-1.a new file mode 100644 index 0000000..2ae920c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-2.a new file mode 100644 index 0000000..fe5b83e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l2-1-0.a new file mode 100644 index 0000000..e2802fb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-obsolete-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-obsolete-l1-2-0.a new file mode 100644 index 0000000..13ace7e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-obsolete-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-0.a new file mode 100644 index 0000000..5ea3f73 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-1.a new file mode 100644 index 0000000..ad8ab07 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-2.a new file mode 100644 index 0000000..0ebc619 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-3.a new file mode 100644 index 0000000..0cef9f3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-4.a new file mode 100644 index 0000000..753ae77 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-5.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-5.a new file mode 100644 index 0000000..09c84fb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-5.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-0.a new file mode 100644 index 0000000..f0b46fd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-1.a new file mode 100644 index 0000000..2507b50 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-1-0.a new file mode 100644 index 0000000..9e6286d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-1.a new file mode 100644 index 0000000..015ee5d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-2.a new file mode 100644 index 0000000..0428af6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-ansi-l1-1-0.a new file mode 100644 index 0000000..f2cd0b1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-l1-1-0.a new file mode 100644 index 0000000..cfc0784 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-normalization-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-normalization-l1-1-0.a new file mode 100644 index 0000000..5cbe569 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-normalization-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-path-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-path-l1-1-0.a new file mode 100644 index 0000000..ffa1556 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-perfcounters-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-perfcounters-l1-1-0.a new file mode 100644 index 0000000..f05622b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-perfcounters-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-0.a new file mode 100644 index 0000000..29798b6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-1.a new file mode 100644 index 0000000..ffcd310 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-ansi-l1-1-0.a new file mode 100644 index 0000000..067a60c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-1-0.a new file mode 100644 index 0000000..997ac98 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-2-0.a new file mode 100644 index 0000000..695643a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processsnapshot-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processsnapshot-l1-1-0.a new file mode 100644 index 0000000..7cf42b4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processsnapshot-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-0.a new file mode 100644 index 0000000..6797fde Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-1.a new file mode 100644 index 0000000..2c4338e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-2.a new file mode 100644 index 0000000..1e3138d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-3.a new file mode 100644 index 0000000..6a586c1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-l1-1-0.a new file mode 100644 index 0000000..57c3695 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a new file mode 100644 index 0000000..73ce0f5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a new file mode 100644 index 0000000..ca85063 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-profile-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-profile-l1-1-0.a new file mode 100644 index 0000000..b8ac190 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-profile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-ansi-l1-1-0.a new file mode 100644 index 0000000..ad8a3a4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-l1-1-0.a new file mode 100644 index 0000000..9ea89d7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psm-appnotify-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psm-appnotify-l1-1-0.a new file mode 100644 index 0000000..10c384d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psm-appnotify-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-0.a new file mode 100644 index 0000000..d5834e0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-1.a new file mode 100644 index 0000000..66c5c94 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-0.a new file mode 100644 index 0000000..26b7c19 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-1.a new file mode 100644 index 0000000..c9f33f5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-2.a new file mode 100644 index 0000000..e59b5ec Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-0.a new file mode 100644 index 0000000..ce96bf8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-1.a new file mode 100644 index 0000000..5a91f16 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-2.a new file mode 100644 index 0000000..1f0820d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l2-1-0.a new file mode 100644 index 0000000..fdcbb87 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-1-0.a new file mode 100644 index 0000000..3145e29 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-2-0.a new file mode 100644 index 0000000..e8cf817 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-ansi-l1-1-0.a new file mode 100644 index 0000000..ea1726f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-0.a new file mode 100644 index 0000000..beeee46 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-1.a new file mode 100644 index 0000000..ba74c11 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-ansi-l1-1-0.a new file mode 100644 index 0000000..28def18 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-l1-1-0.a new file mode 100644 index 0000000..aebb07b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-slapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-slapi-l1-1-0.a new file mode 100644 index 0000000..ffc11e7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-slapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l1-1-0.a new file mode 100644 index 0000000..e72a485 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-0.a new file mode 100644 index 0000000..fcd0eb3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-1.a new file mode 100644 index 0000000..da27e77 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-0.a new file mode 100644 index 0000000..4e99c1d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-1.a new file mode 100644 index 0000000..d08cd3c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-stringansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-stringansi-l1-1-0.a new file mode 100644 index 0000000..59a2f6f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-stringansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-ansi-l1-1-0.a new file mode 100644 index 0000000..5639c68 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-1-0.a new file mode 100644 index 0000000..65827d5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-0.a new file mode 100644 index 0000000..afe6820 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-1.a new file mode 100644 index 0000000..2619859 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-1-0.a new file mode 100644 index 0000000..ed4e679 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-0.a new file mode 100644 index 0000000..b04ac45 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-1.a new file mode 100644 index 0000000..cfc8edf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-2.a new file mode 100644 index 0000000..cf1d702 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-3.a new file mode 100644 index 0000000..59178e5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-0.a new file mode 100644 index 0000000..3200d4f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-1.a new file mode 100644 index 0000000..45a2304 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-l1-2-0.a new file mode 100644 index 0000000..505b8f7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-legacy-l1-1-0.a new file mode 100644 index 0000000..16cda2f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-timezone-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-timezone-l1-1-0.a new file mode 100644 index 0000000..7d171d4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-timezone-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-0.a new file mode 100644 index 0000000..f7f1ad7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-1.a new file mode 100644 index 0000000..53787d3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-url-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-url-l1-1-0.a new file mode 100644 index 0000000..c19d288 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-url-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-0.a new file mode 100644 index 0000000..fcd1bc1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-1.a new file mode 100644 index 0000000..e5117f9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-0.a new file mode 100644 index 0000000..7dd490a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-1.a new file mode 100644 index 0000000..3eb5e6b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-0.a new file mode 100644 index 0000000..389f92c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-1.a new file mode 100644 index 0000000..3a293c6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowsceip-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowsceip-l1-1-0.a new file mode 100644 index 0000000..1c463ab Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowsceip-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a new file mode 100644 index 0000000..deeae06 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a new file mode 100644 index 0000000..61584e6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a new file mode 100644 index 0000000..9bc4437 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-0.a new file mode 100644 index 0000000..132ab0f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-1.a new file mode 100644 index 0000000..b9cddf3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..5ad3588 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-registration-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-registration-l1-1-0.a new file mode 100644 index 0000000..e04bfdb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-registration-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-robuffer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-robuffer-l1-1-0.a new file mode 100644 index 0000000..680d316 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-robuffer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a new file mode 100644 index 0000000..e55af95 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-0.a new file mode 100644 index 0000000..254594c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-1.a new file mode 100644 index 0000000..6c44c61 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-0.a new file mode 100644 index 0000000..f14b696 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-1.a new file mode 100644 index 0000000..f2dc119 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-2.a new file mode 100644 index 0000000..d9c378d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-xstate-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-xstate-l2-1-0.a new file mode 100644 index 0000000..6990a64 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-xstate-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-1.a new file mode 100644 index 0000000..bc33f19 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-2.a new file mode 100644 index 0000000..23a26f1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-0.a new file mode 100644 index 0000000..382765c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-1.a new file mode 100644 index 0000000..c8b3f5f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-0.a new file mode 100644 index 0000000..ecf299c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-1.a new file mode 100644 index 0000000..63ea82f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-2.a new file mode 100644 index 0000000..e73c4a1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-3.a new file mode 100644 index 0000000..7403a48 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-4.a new file mode 100644 index 0000000..a1b5ed0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-classicprovider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-classicprovider-l1-1-0.a new file mode 100644 index 0000000..0802e2e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-classicprovider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-0.a new file mode 100644 index 0000000..016d946 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-1.a new file mode 100644 index 0000000..a98c8f4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-controller-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-controller-l1-1-0.a new file mode 100644 index 0000000..21d2081 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-controller-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-legacy-l1-1-0.a new file mode 100644 index 0000000..d4efbca Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-obsolete-l1-1-0.a new file mode 100644 index 0000000..aaa254b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-provider-l1-1-0.a new file mode 100644 index 0000000..847c7e2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-tdh-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-tdh-l1-1-0.a new file mode 100644 index 0000000..10e36b7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-tdh-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-deviceinformation-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-deviceinformation-l1-1-0.a new file mode 100644 index 0000000..1a8fe04 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-deviceinformation-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-expandedresources-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-expandedresources-l1-1-0.a new file mode 100644 index 0000000..95fd7d1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-expandedresources-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-0.a new file mode 100644 index 0000000..597ff12 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-1.a new file mode 100644 index 0000000..a56a94c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-0.a new file mode 100644 index 0000000..c561c1e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-1.a new file mode 100644 index 0000000..05cdb00 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-2.a new file mode 100644 index 0000000..086b68d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-3.a new file mode 100644 index 0000000..20c3f18 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-4.a new file mode 100644 index 0000000..c2aa06c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-0.a new file mode 100644 index 0000000..0a091d0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-1.a new file mode 100644 index 0000000..358062e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-mme-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-mme-l1-1-0.a new file mode 100644 index 0000000..fa768e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-mme-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-playsound-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-playsound-l1-1-0.a new file mode 100644 index 0000000..463e22e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-playsound-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-time-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-time-l1-1-0.a new file mode 100644 index 0000000..fd432fe Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-time-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ntuser-sysparams-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ntuser-sysparams-l1-1-0.a new file mode 100644 index 0000000..bdb658f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ntuser-sysparams-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-oobe-notification-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-oobe-notification-l1-1-0.a new file mode 100644 index 0000000..203bbfd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-oobe-notification-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-perf-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-perf-legacy-l1-1-0.a new file mode 100644 index 0000000..e464314 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-perf-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-base-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-base-l1-1-0.a new file mode 100644 index 0000000..ce2b637 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-limitsmanagement-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-limitsmanagement-l1-1-0.a new file mode 100644 index 0000000..1958f31 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-limitsmanagement-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-setting-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-setting-l1-1-0.a new file mode 100644 index 0000000..42efc57 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-setting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ro-typeresolution-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ro-typeresolution-l1-1-0.a new file mode 100644 index 0000000..435d0db Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ro-typeresolution-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-appcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-appcontainer-l1-1-0.a new file mode 100644 index 0000000..aafc8b2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-appcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-ansi-l1-1-0.a new file mode 100644 index 0000000..55e2f9c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-1-0.a new file mode 100644 index 0000000..f8469ac Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-0.a new file mode 100644 index 0000000..3787967 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-1.a new file mode 100644 index 0000000..0365228 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-2.a new file mode 100644 index 0000000..9eedb80 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-credentials-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-credentials-l1-1-0.a new file mode 100644 index 0000000..74754a1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-credentials-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-cryptoapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-cryptoapi-l1-1-0.a new file mode 100644 index 0000000..8c0a7ae Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-cryptoapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-isolatedcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-isolatedcontainer-l1-1-0.a new file mode 100644 index 0000000..84764c3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-isolatedcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-ansi-l2-1-0.a new file mode 100644 index 0000000..8c23885 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-0.a new file mode 100644 index 0000000..de67410 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-1.a new file mode 100644 index 0000000..8578e07 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-ansi-l1-1-0.a new file mode 100644 index 0000000..1d7e632 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-l1-1-0.a new file mode 100644 index 0000000..229e9bd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-ansi-l1-1-0.a new file mode 100644 index 0000000..c7b6cfb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-l1-1-0.a new file mode 100644 index 0000000..dad1909 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-systemfunctions-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-systemfunctions-l1-1-0.a new file mode 100644 index 0000000..ad3581f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-systemfunctions-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-0.a new file mode 100644 index 0000000..51ea417 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-1.a new file mode 100644 index 0000000..dedd048 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-0.a new file mode 100644 index 0000000..562e9aa Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-1.a new file mode 100644 index 0000000..a21bf92 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-2.a new file mode 100644 index 0000000..ea0f2b7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l1-1-0.a new file mode 100644 index 0000000..b93de07 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l2-1-0.a new file mode 100644 index 0000000..92798e0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-winsvc-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-winsvc-l1-1-0.a new file mode 100644 index 0000000..6026a1a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-winsvc-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-path-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-path-l1-1-0.a new file mode 100644 index 0000000..0a1043f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-0.a new file mode 100644 index 0000000..60f0263 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-1.a new file mode 100644 index 0000000..c3a335e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-0.a new file mode 100644 index 0000000..c557cb3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-1.a new file mode 100644 index 0000000..b52b7a7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-2.a new file mode 100644 index 0000000..d3ac5aa Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-stream-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-stream-winrt-l1-1-0.a new file mode 100644 index 0000000..1eb8484 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-stream-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-sysinfo-l1-1-0.a new file mode 100644 index 0000000..b612206 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-unicodeansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-unicodeansi-l1-1-0.a new file mode 100644 index 0000000..243f042 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-unicodeansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-namespace-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-namespace-l1-1-0.a new file mode 100644 index 0000000..9efb3c5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-namespace-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-shdirectory-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-shdirectory-l1-1-0.a new file mode 100644 index 0000000..bad59d1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-shdirectory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-authz.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-authz.a new file mode 100644 index 0000000..15e9e11 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-authz.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-bcrypt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-bcrypt.a new file mode 100644 index 0000000..c30fef3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-bcrypt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cabinet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cabinet.a new file mode 100644 index 0000000..53a60d5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-chakra.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-chakra.a new file mode 100644 index 0000000..e841d04 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-chakra.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-coremessaging.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-coremessaging.a new file mode 100644 index 0000000..c668dff Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-coremessaging.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-crypt32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-crypt32.a new file mode 100644 index 0000000..7a73706 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-crypt32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptbase.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptbase.a new file mode 100644 index 0000000..aa9f7fc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptbase.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptnet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptnet.a new file mode 100644 index 0000000..c01378c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptnet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d2d1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d2d1.a new file mode 100644 index 0000000..49e871a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d2d1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d11.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d11.a new file mode 100644 index 0000000..724c339 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d11.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d12.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d12.a new file mode 100644 index 0000000..4e3dbea Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d12.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3dcompiler_47.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3dcompiler_47.a new file mode 100644 index 0000000..b9e8ee3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3dcompiler_47.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-deviceaccess.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-deviceaccess.a new file mode 100644 index 0000000..af67121 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-deviceaccess.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dfscli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dfscli.a new file mode 100644 index 0000000..df1fb51 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dfscli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc.a new file mode 100644 index 0000000..398abcf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc6.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc6.a new file mode 100644 index 0000000..3109464 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc6.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dnsapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dnsapi.a new file mode 100644 index 0000000..ea78b92 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dnsapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsparse.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsparse.a new file mode 100644 index 0000000..89e3c74 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsparse.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsrole.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsrole.a new file mode 100644 index 0000000..45fe803 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsrole.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dwrite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dwrite.a new file mode 100644 index 0000000..228a1ad Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dwrite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dxgi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dxgi.a new file mode 100644 index 0000000..28bf741 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dxgi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-esent.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-esent.a new file mode 100644 index 0000000..0d4ee9e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-esent.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-core-iuri-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-core-iuri-l1-1-0.a new file mode 100644 index 0000000..2eee14c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-core-iuri-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-gaming-xinput-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-gaming-xinput-l1-1-0.a new file mode 100644 index 0000000..8a7a337 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-gaming-xinput-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-networking-wlanapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-networking-wlanapi-l1-1-0.a new file mode 100644 index 0000000..c5aa602 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-networking-wlanapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-0.a new file mode 100644 index 0000000..c19278c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-1.a new file mode 100644 index 0000000..cb0a327 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-0.a new file mode 100644 index 0000000..4843b04 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-1.a new file mode 100644 index 0000000..796dfb8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-2.a new file mode 100644 index 0000000..fbc7a9d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-3.a new file mode 100644 index 0000000..faba24e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-fltlib.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-fltlib.a new file mode 100644 index 0000000..5c928ba Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-fltlib.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hid.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hid.a new file mode 100644 index 0000000..8a037ee Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hid.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hrtfapo.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hrtfapo.a new file mode 100644 index 0000000..7064908 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hrtfapo.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-inkobjcore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-inkobjcore.a new file mode 100644 index 0000000..0bdd645 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-inkobjcore.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-iphlpapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-iphlpapi.a new file mode 100644 index 0000000..304b43b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-iphlpapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-logoncli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-logoncli.a new file mode 100644 index 0000000..cb66132 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-logoncli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mf.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mf.a new file mode 100644 index 0000000..d445b01 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mf.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfplat.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfplat.a new file mode 100644 index 0000000..14b1ec1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfplat.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfreadwrite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfreadwrite.a new file mode 100644 index 0000000..e26c890 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfreadwrite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfsensorgroup.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfsensorgroup.a new file mode 100644 index 0000000..54e931a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfsensorgroup.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mmdevapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mmdevapi.a new file mode 100644 index 0000000..f011a72 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mmdevapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mpr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mpr.a new file mode 100644 index 0000000..ce3a087 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mpr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-msajapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-msajapi.a new file mode 100644 index 0000000..6bc3728 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-msajapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mswsock.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mswsock.a new file mode 100644 index 0000000..a35a24b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ncrypt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ncrypt.a new file mode 100644 index 0000000..d674404 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ncrypt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-netutils.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-netutils.a new file mode 100644 index 0000000..ce2fe89 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-netutils.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ntdll.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ntdll.a new file mode 100644 index 0000000..06b17d0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ntdll.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-oleaut32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-oleaut32.a new file mode 100644 index 0000000..1060a64 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-powrprof.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-powrprof.a new file mode 100644 index 0000000..443bb25 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-powrprof.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-profapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-profapi.a new file mode 100644 index 0000000..ac0c5f6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-profapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-propsys.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-propsys.a new file mode 100644 index 0000000..cf72a6d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-propsys.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rometadata.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rometadata.a new file mode 100644 index 0000000..29fde97 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rometadata.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rpcrt4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rpcrt4.a new file mode 100644 index 0000000..dbd709f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-samcli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-samcli.a new file mode 100644 index 0000000..003b052 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-samcli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-schedcli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-schedcli.a new file mode 100644 index 0000000..3be2e78 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-schedcli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-srvcli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-srvcli.a new file mode 100644 index 0000000..8bc846c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-srvcli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-sspicli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-sspicli.a new file mode 100644 index 0000000..06fb1b8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-sspicli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-tokenbinding.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-tokenbinding.a new file mode 100644 index 0000000..1645819 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-tokenbinding.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-uiautomationcore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-uiautomationcore.a new file mode 100644 index 0000000..a58c9c8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-uiautomationcore.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-urlmon.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-urlmon.a new file mode 100644 index 0000000..3c2f720 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-urlmon.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-userenv.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-userenv.a new file mode 100644 index 0000000..deeb4b7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-userenv.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-webservices.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-webservices.a new file mode 100644 index 0000000..30db0a1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-webservices.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-websocket.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-websocket.a new file mode 100644 index 0000000..3fa52c5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-websocket.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.data.pdf.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.data.pdf.a new file mode 100644 index 0000000..31121fd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.data.pdf.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.networking.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.networking.a new file mode 100644 index 0000000..3a2bb93 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.networking.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windowscodecs.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windowscodecs.a new file mode 100644 index 0000000..60ac153 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windowscodecs.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-winhttp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-winhttp.a new file mode 100644 index 0000000..29e1071 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-winhttp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wintrust.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wintrust.a new file mode 100644 index 0000000..97a1b02 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wintrust.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wkscli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wkscli.a new file mode 100644 index 0000000..50a2e38 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wkscli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wlanapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wlanapi.a new file mode 100644 index 0000000..f4cc8dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wlanapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wldap32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wldap32.a new file mode 100644 index 0000000..bec0b25 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wldap32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wpprecorderum.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wpprecorderum.a new file mode 100644 index 0000000..78027e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wpprecorderum.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ws2_32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ws2_32.a new file mode 100644 index 0000000..f4a8932 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xaudio2_9.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xaudio2_9.a new file mode 100644 index 0000000..ce5e291 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xaudio2_9.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xmllite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xmllite.a new file mode 100644 index 0000000..df91aad Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xmllite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap.a new file mode 100644 index 0000000..34c606f --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap.a @@ -0,0 +1,324 @@ +INPUT( +libwinapi_onecoreuap-api-ms-win-core-largeinteger-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-1.a +libwinapi_onecoreuap-esent.a +libwinapi_onecoreuap-api-ms-win-eventing-provider-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-service-management-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-threadpool-legacy-l1-1-0.a +libwinapi_onecoreuap-wkscli.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-ntuser-sysparams-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-mm-time-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-synch-l1-1-0.a +libwinapi_onecoreuap-ws2_32.a +libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-shell-shdirectory-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-3.a +libwinapi_onecoreuap-logoncli.a +libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-2.a +libwinapi_onecoreuap-api-ms-win-shcore-stream-winrt-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-perf-legacy-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-base-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processtopology-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-3.a +libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-1.a +libwinapi_onecoreuap-api-ms-win-core-io-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-0.a +libwinapi_onecoreuap-winhttp.a +libwinapi_onecoreuap-api-ms-win-core-com-l2-1-1.a +libwinapi_onecoreuap-api-ms-win-core-calendar-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-stringansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-heap-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-2.a +libwinapi_onecoreuap-api-ms-win-power-base-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-localization-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-path-l1-1-0.a +libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-registry-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-file-l2-1-2.a +libwinapi_onecoreuap-xmllite.a +libwinapi_onecoreuap-dsparse.a +libwinapi_onecoreuap-cabinet.a +libwinapi_onecoreuap-api-ms-win-service-management-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-0.a +libwinapi_onecoreuap-mswsock.a +libwinapi_onecoreuap-mpr.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-3.a +libwinapi_onecoreuap-coremessaging.a +libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-4.a +libwinapi_onecoreuap-powrprof.a +libwinapi_onecoreuap-api-ms-win-core-localization-obsolete-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-util-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-1.a +libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-1.a +libwinapi_onecoreuap-dsrole.a +libwinapi_onecoreuap-dnsapi.a +libwinapi_onecoreuap-wldap32.a +libwinapi_onecoreuap-api-ms-win-core-localization-ansi-l1-1-0.a +libwinapi_onecoreuap-dfscli.a +libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-0.a +libwinapi_onecoreuap-crypt32.a +libwinapi_onecoreuap-api-ms-win-core-io-l1-1-1.a +libwinapi_onecoreuap-netutils.a +libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-job-l2-1-1.a +libwinapi_onecoreuap-cryptbase.a +libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-4.a +libwinapi_onecoreuap-api-ms-win-security-lsalookup-ansi-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-normalization-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-processsnapshot-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l2-1-3.a +libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-winrt-registration-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-string-l2-1-1.a +libwinapi_onecoreuap-samcli.a +libwinapi_onecoreuap-authz.a +libwinapi_onecoreuap-ntdll.a +libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-1.a +libwinapi_onecoreuap-api-ms-win-core-heap-obsolete-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-eventing-obsolete-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-mm-playsound-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-job-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-gaming-deviceinformation-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-1.a +libwinapi_onecoreuap-ext-ms-win-networking-wlanapi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-1.a +libwinapi_onecoreuap-oleaut32.a +libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-service-core-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-com-midlproxystub-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-2.a +libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-1.a +libwinapi_onecoreuap-api-ms-win-core-namespace-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-service-core-l1-1-0.a +libwinapi_onecoreuap-tokenbinding.a +libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-5.a +libwinapi_onecoreuap-d3d12.a +libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-0.a +libwinapi_onecoreuap-d3dcompiler_47.a +libwinapi_onecoreuap-api-ms-win-security-sddl-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-1.a +libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-firmware-l1-1-0.a +libwinapi_onecoreuap-d3d11.a +libwinapi_onecoreuap-api-ms-win-core-file-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-2.a +libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-2.a +libwinapi_onecoreuap-mfplat.a +libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-perfcounters-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-service-core-l1-1-2.a +libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-0.a +libwinapi_onecoreuap-urlmon.a +libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-1.a +libwinapi_onecoreuap-inkobjcore.a +libwinapi_onecoreuap-windows.networking.a +libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-string-l1-1-0.a +libwinapi_onecoreuap-ncrypt.a +libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-4.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-1.a +libwinapi_onecoreuap-dwrite.a +libwinapi_onecoreuap-api-ms-win-core-slapi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-provider-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-power-limitsmanagement-l1-1-0.a +libwinapi_onecoreuap-chakra.a +libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-0.a +libwinapi_onecoreuap-d2d1.a +libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-mm-mme-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-1-0.a +libwinapi_onecoreuap-hid.a +libwinapi_onecoreuap-api-ms-win-core-windowsceip-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-atoms-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l2-1-1.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-5.a +libwinapi_onecoreuap-srvcli.a +libwinapi_onecoreuap-dxgi.a +libwinapi_onecoreuap-api-ms-win-ro-typeresolution-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-handle-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-3.a +libwinapi_onecoreuap-wpprecorderum.a +libwinapi_onecoreuap-api-ms-win-gaming-expandedresources-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-namespace-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-2.a +libwinapi_onecoreuap-bcrypt.a +libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-0.a +libwinapi_onecoreuap-sspicli.a +libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-shcore-sysinfo-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-com-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-credentials-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-util-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-threadpool-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-0.a +libwinapi_onecoreuap-xaudio2_9.a +libwinapi_onecoreuap-api-ms-win-core-sidebyside-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-winrt-robuffer-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-base-l1-1-0.a +libwinapi_onecoreuap-rometadata.a +libwinapi_onecoreuap-api-ms-win-core-console-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-shcore-path-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-4.a +libwinapi_onecoreuap-api-ms-win-core-url-l1-1-0.a +libwinapi_onecoreuap-msajapi.a +libwinapi_onecoreuap-ext-ms-win-gaming-xinput-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-libraryloader-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processenvironment-ansi-l1-1-0.a +libwinapi_onecoreuap-mf.a +libwinapi_onecoreuap-api-ms-win-security-appcontainer-l1-1-0.a +libwinapi_onecoreuap-userenv.a +libwinapi_onecoreuap-websocket.a +libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-console-ansi-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-security-isolatedcontainer-l1-1-0.a +libwinapi_onecoreuap-wintrust.a +libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-security-base-l1-2-1.a +libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-3.a +libwinapi_onecoreuap-api-ms-win-core-timezone-l1-1-0.a +libwinapi_onecoreuap-mmdevapi.a +libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-sidebyside-l1-1-0.a +libwinapi_onecoreuap-rpcrt4.a +libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-shcore-unicodeansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-psm-appnotify-l1-1-0.a +libwinapi_onecoreuap-iphlpapi.a +libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-1.a +libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-winrt-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-console-l1-1-0.a +libwinapi_onecoreuap-propsys.a +libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-3.a +libwinapi_onecoreuap-api-ms-win-core-com-l1-1-1.a +libwinapi_onecoreuap-profapi.a +libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-security-sddl-l1-1-0.a +libwinapi_onecoreuap-cryptnet.a +libwinapi_onecoreuap-schedcli.a +libwinapi_onecoreuap-api-ms-win-oobe-notification-l1-1-0.a +libwinapi_onecoreuap-deviceaccess.a +libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-security-base-l1-2-2.a +libwinapi_onecoreuap-windows.data.pdf.a +libwinapi_onecoreuap-api-ms-win-core-psapi-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-0.a +libwinapi_onecoreuap-uiautomationcore.a +libwinapi_onecoreuap-api-ms-win-core-file-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-shell-namespace-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-synch-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-eventing-controller-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-heap-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-eventing-legacy-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-xstate-l2-1-0.a +libwinapi_onecoreuap-webservices.a +libwinapi_onecoreuap-api-ms-win-core-shutdown-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-job-l2-1-0.a +libwinapi_onecoreuap-fltlib.a +libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-file-l1-2-1.a +libwinapi_onecoreuap-api-ms-win-core-version-l1-1-0.a +libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-0.a +libwinapi_onecoreuap-dhcpcsvc6.a +libwinapi_onecoreuap-api-ms-win-security-provider-ansi-l1-1-0.a +libwinapi_onecoreuap-mfreadwrite.a +libwinapi_onecoreuap-api-ms-win-power-setting-l1-1-0.a +libwinapi_onecoreuap-windowscodecs.a +libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-1.a +libwinapi_onecoreuap-dhcpcsvc.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-6.a +libwinapi_onecoreuap-api-ms-win-core-string-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-cryptoapi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l1-2-2.a +libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-security-systemfunctions-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-com-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-version-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-profile-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-eventing-classicprovider-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-service-winsvc-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-psapi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-ansi-l2-1-0.a +libwinapi_onecoreuap-hrtfapo.a +libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-0.a +libwinapi_onecoreuap-mfsensorgroup.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-3.a +libwinapi_onecoreuap-wlanapi.a +libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-3.a +libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-1.a +libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-console-l3-1-0.a +libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-eventing-tdh-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-base-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-1.a +libwinapi_onecoreuap-ext-ms-win-core-iuri-l1-1-0.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-advapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-advapi32.a new file mode 100644 index 0000000..dc84544 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-advapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-apphelp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-apphelp.a new file mode 100644 index 0000000..bde9a76 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-apphelp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comctl32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comctl32.a new file mode 100644 index 0000000..85ecf8a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comctl32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comdlg32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comdlg32.a new file mode 100644 index 0000000..b18f4b7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comdlg32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d10.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d10.a new file mode 100644 index 0000000..405c24e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d10.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d9.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d9.a new file mode 100644 index 0000000..27b5d93 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d9.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3dx10_47.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3dx10_47.a new file mode 100644 index 0000000..d633b8c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3dx10_47.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-difxapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-difxapi.a new file mode 100644 index 0000000..64916fd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-difxapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-gdi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-gdi32.a new file mode 100644 index 0000000..958b3dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-gdi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-input.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-input.a new file mode 100644 index 0000000..074e846 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-input.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-kernel32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-kernel32.a new file mode 100644 index 0000000..cf79425 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-kernel32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-msi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-msi.a new file mode 100644 index 0000000..49400a3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-msi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-newdev.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-newdev.a new file mode 100644 index 0000000..b26457f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-newdev.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-ole32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-ole32.a new file mode 100644 index 0000000..f7101ca Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-ole32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleacc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleacc.a new file mode 100644 index 0000000..f899180 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleacc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleaut32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleaut32.a new file mode 100644 index 0000000..51763a7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oledlg.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oledlg.a new file mode 100644 index 0000000..0e12e13 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oledlg.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-pdh.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-pdh.a new file mode 100644 index 0000000..65e2049 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-pdh.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-psapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-psapi.a new file mode 100644 index 0000000..1662889 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-psapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-resutils.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-resutils.a new file mode 100644 index 0000000..7fda090 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-resutils.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-rstrtmgr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-rstrtmgr.a new file mode 100644 index 0000000..8aaa208 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-rstrtmgr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-secur32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-secur32.a new file mode 100644 index 0000000..61b6248 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-secur32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-setupapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-setupapi.a new file mode 100644 index 0000000..7b64204 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-setupapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shell32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shell32.a new file mode 100644 index 0000000..e1e2f26 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shell32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shlwapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shlwapi.a new file mode 100644 index 0000000..82c6bf3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shlwapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-tdh.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-tdh.a new file mode 100644 index 0000000..37677ab Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-tdh.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-twinapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-twinapi.a new file mode 100644 index 0000000..d01bb8d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-twinapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-user32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-user32.a new file mode 100644 index 0000000..ebe7580 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-user32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-uxtheme.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-uxtheme.a new file mode 100644 index 0000000..6e72a4d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-uxtheme.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-version.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-version.a new file mode 100644 index 0000000..f6abea7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-version.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winmm.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winmm.a new file mode 100644 index 0000000..8f325eb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winmm.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winspool.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winspool.a new file mode 100644 index 0000000..89d1b70 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winspool.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-wtsapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-wtsapi32.a new file mode 100644 index 0000000..42f4971 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-wtsapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-xinput1_4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-xinput1_4.a new file mode 100644 index 0000000..3fe875b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-xinput1_4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel.a new file mode 100644 index 0000000..0d94fe2 --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel.a @@ -0,0 +1,36 @@ +INPUT( +libwinapi_onecoreuap_downlevel-uxtheme.a +libwinapi_onecoreuap_downlevel-pdh.a +libwinapi_onecoreuap_downlevel-psapi.a +libwinapi_onecoreuap_downlevel-shlwapi.a +libwinapi_onecoreuap_downlevel-advapi32.a +libwinapi_onecoreuap_downlevel-wtsapi32.a +libwinapi_onecoreuap_downlevel-xinput1_4.a +libwinapi_onecoreuap_downlevel-difxapi.a +libwinapi_onecoreuap_downlevel-d3d10.a +libwinapi_onecoreuap_downlevel-newdev.a +libwinapi_onecoreuap_downlevel-setupapi.a +libwinapi_onecoreuap_downlevel-user32.a +libwinapi_onecoreuap_downlevel-secur32.a +libwinapi_onecoreuap_downlevel-oledlg.a +libwinapi_onecoreuap_downlevel-winmm.a +libwinapi_onecoreuap_downlevel-apphelp.a +libwinapi_onecoreuap_downlevel-shell32.a +libwinapi_onecoreuap_downlevel-ole32.a +libwinapi_onecoreuap_downlevel-resutils.a +libwinapi_onecoreuap_downlevel-winspool.a +libwinapi_onecoreuap_downlevel-comdlg32.a +libwinapi_onecoreuap_downlevel-d3dx10_47.a +libwinapi_onecoreuap_downlevel-comctl32.a +libwinapi_onecoreuap_downlevel-gdi32.a +libwinapi_onecoreuap_downlevel-twinapi.a +libwinapi_onecoreuap_downlevel-version.a +libwinapi_onecoreuap_downlevel-tdh.a +libwinapi_onecoreuap_downlevel-d3d9.a +libwinapi_onecoreuap_downlevel-kernel32.a +libwinapi_onecoreuap_downlevel-oleacc.a +libwinapi_onecoreuap_downlevel-rstrtmgr.a +libwinapi_onecoreuap_downlevel-input.a +libwinapi_onecoreuap_downlevel-msi.a +libwinapi_onecoreuap_downlevel-oleaut32.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_opengl32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_opengl32.a new file mode 100644 index 0000000..5ca150b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_opengl32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_p2p.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_p2p.a new file mode 100644 index 0000000..2f7bcc9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_p2p.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_p2pgraph.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_p2pgraph.a new file mode 100644 index 0000000..c6e0cd9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_p2pgraph.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_pathcch.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_pathcch.a new file mode 100644 index 0000000..54462ac Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_pathcch.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_pdh.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_pdh.a new file mode 100644 index 0000000..f74b21e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_pdh.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_peerdist.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_peerdist.a new file mode 100644 index 0000000..ffc8f0b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_peerdist.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_powrprof.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_powrprof.a new file mode 100644 index 0000000..23cd940 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_powrprof.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_prntvpt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_prntvpt.a new file mode 100644 index 0000000..245f275 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_prntvpt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_propsys.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_propsys.a new file mode 100644 index 0000000..2fadbd9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_propsys.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_psapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_psapi.a new file mode 100644 index 0000000..b3a875f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_psapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_quartz.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_quartz.a new file mode 100644 index 0000000..49fc68b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_quartz.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_query.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_query.a new file mode 100644 index 0000000..4f0bdc0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_query.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_qwave.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_qwave.a new file mode 100644 index 0000000..fc74f80 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_qwave.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rasapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rasapi32.a new file mode 100644 index 0000000..6b9f89d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rasapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rasdlg.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rasdlg.a new file mode 100644 index 0000000..6f014fe Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rasdlg.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_resutils.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_resutils.a new file mode 100644 index 0000000..520d7b7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_resutils.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rometadata.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rometadata.a new file mode 100644 index 0000000..d473f43 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rometadata.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcexts.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcexts.a new file mode 100644 index 0000000..ee44784 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcexts.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcns4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcns4.a new file mode 100644 index 0000000..d52203d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcns4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcproxy.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcproxy.a new file mode 100644 index 0000000..cc6381e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcproxy.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcrt4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcrt4.a new file mode 100644 index 0000000..5439485 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rstrtmgr.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rstrtmgr.a new file mode 100644 index 0000000..a523d23 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rstrtmgr.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rtm.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rtm.a new file mode 100644 index 0000000..fbfeeb8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rtm.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rtutils.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rtutils.a new file mode 100644 index 0000000..b10358e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rtutils.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rtworkq.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rtworkq.a new file mode 100644 index 0000000..e9a7dbf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_rtworkq.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-0.a new file mode 100644 index 0000000..bc13dd4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-1.a new file mode 100644 index 0000000..08f54f6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..19c21a5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-registration-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-registration-l1-1-0.a new file mode 100644 index 0000000..808c7d4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-registration-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-robuffer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-robuffer-l1-1-0.a new file mode 100644 index 0000000..e8b7339 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-robuffer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a new file mode 100644 index 0000000..b1c2c40 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-string-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-string-l1-1-0.a new file mode 100644 index 0000000..54d59d7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-ro-typeresolution-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-ro-typeresolution-l1-1-0.a new file mode 100644 index 0000000..504848a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-ro-typeresolution-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject.a new file mode 100644 index 0000000..57114fb --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject.a @@ -0,0 +1,10 @@ +INPUT( +libwinapi_runtimeobject-api-ms-win-core-winrt-registration-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-1.a +libwinapi_runtimeobject-api-ms-win-ro-typeresolution-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-string-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-robuffer-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-l1-1-0.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_samlib.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_samlib.a new file mode 100644 index 0000000..4ec0af0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_samlib.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_samsrv.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_samsrv.a new file mode 100644 index 0000000..8cf2e63 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_samsrv.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sas.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sas.a new file mode 100644 index 0000000..ab8cc47 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sas.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_scarddlg.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_scarddlg.a new file mode 100644 index 0000000..2514139 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_scarddlg.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_scecli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_scecli.a new file mode 100644 index 0000000..955ecfd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_scecli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_scesrv.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_scesrv.a new file mode 100644 index 0000000..fbd750c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_scesrv.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_schannel.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_schannel.a new file mode 100644 index 0000000..067b6f5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_schannel.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_secur32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_secur32.a new file mode 100644 index 0000000..53671d1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_secur32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_security.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_security.a new file mode 100644 index 0000000..c86e022 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_security.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sens.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sens.a new file mode 100644 index 0000000..9344086 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sens.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sensapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sensapi.a new file mode 100644 index 0000000..d7e09d9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sensapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sensorsutils.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sensorsutils.a new file mode 100644 index 0000000..2b29363 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sensorsutils.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_setupapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_setupapi.a new file mode 100644 index 0000000..dce8dea Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_setupapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sfc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sfc.a new file mode 100644 index 0000000..857ca87 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sfc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-0.a new file mode 100644 index 0000000..1b06b89 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-1.a new file mode 100644 index 0000000..11d544d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-0.a new file mode 100644 index 0000000..b2d21ea Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-1.a new file mode 100644 index 0000000..1681ba1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-2.a new file mode 100644 index 0000000..724b88d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-stream-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-stream-winrt-l1-1-0.a new file mode 100644 index 0000000..8b5c567 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-stream-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore.a new file mode 100644 index 0000000..e0cb942 --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shcore.a @@ -0,0 +1,8 @@ +INPUT( +libwinapi_shcore-api-ms-win-shcore-stream-winrt-l1-1-0.a +libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-1.a +libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-2.a +libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-1.a +libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-0.a +libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-0.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shdocvw.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shdocvw.a new file mode 100644 index 0000000..7ce2c21 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shdocvw.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shell32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shell32.a new file mode 100644 index 0000000..9b36306 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shell32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shfolder.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shfolder.a new file mode 100644 index 0000000..a254a36 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shfolder.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shlwapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shlwapi.a new file mode 100644 index 0000000..c3dd5fd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_shlwapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_slc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_slc.a new file mode 100644 index 0000000..d785e65 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_slc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_slcext.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_slcext.a new file mode 100644 index 0000000..43f3b62 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_slcext.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_slwga.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_slwga.a new file mode 100644 index 0000000..8d10f0d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_slwga.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_snmpapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_snmpapi.a new file mode 100644 index 0000000..4c17ec1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_snmpapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_spoolss.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_spoolss.a new file mode 100644 index 0000000..a05c7dd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_spoolss.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sporder.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sporder.a new file mode 100644 index 0000000..6366f0d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sporder.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_srpapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_srpapi.a new file mode 100644 index 0000000..5020754 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_srpapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ssdpapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ssdpapi.a new file mode 100644 index 0000000..5e54d88 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ssdpapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sti.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sti.a new file mode 100644 index 0000000..8375b1b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_sti.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_swdevice.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_swdevice.a new file mode 100644 index 0000000..6934d38 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_swdevice.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_synchronization.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_synchronization.a new file mode 100644 index 0000000..99a0914 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_synchronization.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_t2embed.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_t2embed.a new file mode 100644 index 0000000..c8348f2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_t2embed.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tapi32.a new file mode 100644 index 0000000..36123f3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tbs.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tbs.a new file mode 100644 index 0000000..f61e08d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tbs.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tdh.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tdh.a new file mode 100644 index 0000000..879c4c2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tdh.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_thunk32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_thunk32.a new file mode 100644 index 0000000..0fcb4ab Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_thunk32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tokenbinding.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tokenbinding.a new file mode 100644 index 0000000..c42846d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tokenbinding.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_traffic.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_traffic.a new file mode 100644 index 0000000..2942625 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_traffic.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tsec.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tsec.a new file mode 100644 index 0000000..17dfcbb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_tsec.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_twain_32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_twain_32.a new file mode 100644 index 0000000..c23fa15 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_twain_32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_txfw32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_txfw32.a new file mode 100644 index 0000000..f0eb04d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_txfw32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ualapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ualapi.a new file mode 100644 index 0000000..850c8c6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ualapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_uiautomationcore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_uiautomationcore.a new file mode 100644 index 0000000..7fd55e2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_uiautomationcore.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_umpdddi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_umpdddi.a new file mode 100644 index 0000000..3978c02 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_umpdddi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_urlmon.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_urlmon.a new file mode 100644 index 0000000..4be2717 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_urlmon.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_user32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_user32.a new file mode 100644 index 0000000..433c991 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_user32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_userenv.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_userenv.a new file mode 100644 index 0000000..157037f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_userenv.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_usp10.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_usp10.a new file mode 100644 index 0000000..6f7c99f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_usp10.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_uxtheme.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_uxtheme.a new file mode 100644 index 0000000..e7535e4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_uxtheme.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vdmdbg.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vdmdbg.a new file mode 100644 index 0000000..3fffa46 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vdmdbg.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_version.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_version.a new file mode 100644 index 0000000..ced80c6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_version.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avicap32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avicap32.a new file mode 100644 index 0000000..e5aa932 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avicap32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avifil32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avifil32.a new file mode 100644 index 0000000..203a54e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avifil32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-msvfw32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-msvfw32.a new file mode 100644 index 0000000..ce9faa0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-msvfw32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32.a new file mode 100644 index 0000000..4ee8733 --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32.a @@ -0,0 +1,5 @@ +INPUT( +libwinapi_vfw32-msvfw32.a +libwinapi_vfw32-avicap32.a +libwinapi_vfw32-avifil32.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_virtdisk.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_virtdisk.a new file mode 100644 index 0000000..fedb813 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_virtdisk.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vssapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vssapi.a new file mode 100644 index 0000000..16394ae Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_vssapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wcmapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wcmapi.a new file mode 100644 index 0000000..1aa7179 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wcmapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdsbp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdsbp.a new file mode 100644 index 0000000..920e6b4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdsbp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdsclientapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdsclientapi.a new file mode 100644 index 0000000..2680c98 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdsclientapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdsmc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdsmc.a new file mode 100644 index 0000000..597419a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdsmc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdspxe.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdspxe.a new file mode 100644 index 0000000..d02e02f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdspxe.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdstptc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdstptc.a new file mode 100644 index 0000000..713cd9c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wdstptc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_webservices.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_webservices.a new file mode 100644 index 0000000..4b78f3c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_webservices.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_websocket.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_websocket.a new file mode 100644 index 0000000..4471858 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_websocket.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wecapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wecapi.a new file mode 100644 index 0000000..3bf0a96 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wecapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wer.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wer.a new file mode 100644 index 0000000..cd69a4c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wer.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wevtapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wevtapi.a new file mode 100644 index 0000000..79387dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wevtapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wiaservc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wiaservc.a new file mode 100644 index 0000000..d5ff213 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wiaservc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winbio.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winbio.a new file mode 100644 index 0000000..ae98228 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winbio.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windows.data.pdf.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windows.data.pdf.a new file mode 100644 index 0000000..18779a8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windows.data.pdf.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windows.networking.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windows.networking.a new file mode 100644 index 0000000..31fbef1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windows.networking.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windows.ui.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windows.ui.a new file mode 100644 index 0000000..cda5fbe Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windows.ui.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-0.a new file mode 100644 index 0000000..7d94e04 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-1.a new file mode 100644 index 0000000..f8be944 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-0.a new file mode 100644 index 0000000..735ac65 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-1.a new file mode 100644 index 0000000..4bed1b1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l2-1-1.a new file mode 100644 index 0000000..f776baa Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-midlproxystub-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-midlproxystub-l1-1-0.a new file mode 100644 index 0000000..01292a5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-midlproxystub-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-0.a new file mode 100644 index 0000000..16a1296 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-1.a new file mode 100644 index 0000000..5371dda Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l1-1-0.a new file mode 100644 index 0000000..2f1c414 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l2-1-0.a new file mode 100644 index 0000000..1e4e42c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-1.a new file mode 100644 index 0000000..3e26ac7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-2.a new file mode 100644 index 0000000..58e50e5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-debug-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-debug-l1-1-0.a new file mode 100644 index 0000000..56a3e36 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-debug-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-0.a new file mode 100644 index 0000000..3d67aed Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-1.a new file mode 100644 index 0000000..dad567b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-enclave-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-enclave-l1-1-0.a new file mode 100644 index 0000000..b2cb11e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-enclave-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-0.a new file mode 100644 index 0000000..d5697b9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-2.a new file mode 100644 index 0000000..11be6da Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-3.a new file mode 100644 index 0000000..2718e46 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-0.a new file mode 100644 index 0000000..220a68c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-1.a new file mode 100644 index 0000000..f660315 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-0.a new file mode 100644 index 0000000..e762f52 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-1.a new file mode 100644 index 0000000..4faeaa1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-0.a new file mode 100644 index 0000000..fe26c3d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-1.a new file mode 100644 index 0000000..8effb19 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l1-1-0.a new file mode 100644 index 0000000..d6527fd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l2-1-0.a new file mode 100644 index 0000000..44e462b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-1-0.a new file mode 100644 index 0000000..17706d8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-0.a new file mode 100644 index 0000000..55954cd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-2.a new file mode 100644 index 0000000..918697f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-0.a new file mode 100644 index 0000000..7907b3b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-2.a new file mode 100644 index 0000000..a6d2599 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-handle-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-handle-l1-1-0.a new file mode 100644 index 0000000..eb3d5fa Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-handle-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l1-1-0.a new file mode 100644 index 0000000..1cd50fc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l2-1-0.a new file mode 100644 index 0000000..5ba6e4e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-obsolete-l1-1-0.a new file mode 100644 index 0000000..9f34125 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-1-0.a new file mode 100644 index 0000000..d1fdf0a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-2-0.a new file mode 100644 index 0000000..13808fc Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-0.a new file mode 100644 index 0000000..af43d3c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-1.a new file mode 100644 index 0000000..9a00e82 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a new file mode 100644 index 0000000..a851e73 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-l1-1-0.a new file mode 100644 index 0000000..95527be Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-largeinteger-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-largeinteger-l1-1-0.a new file mode 100644 index 0000000..90fde2e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-largeinteger-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l1-2-0.a new file mode 100644 index 0000000..e2d23b9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l2-1-0.a new file mode 100644 index 0000000..0757c26 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-ansi-l1-1-0.a new file mode 100644 index 0000000..6a3e88e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-0.a new file mode 100644 index 0000000..77ed271 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-1.a new file mode 100644 index 0000000..974c1c1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-2.a new file mode 100644 index 0000000..0ca1500 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l2-1-0.a new file mode 100644 index 0000000..0b23b2b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-obsolete-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-obsolete-l1-2-0.a new file mode 100644 index 0000000..3c36c78 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-obsolete-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-0.a new file mode 100644 index 0000000..ebfbc92 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-1.a new file mode 100644 index 0000000..bb694d4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-2.a new file mode 100644 index 0000000..24be928 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-3.a new file mode 100644 index 0000000..98eb6cd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-0.a new file mode 100644 index 0000000..d2bca07 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-1.a new file mode 100644 index 0000000..c9ae77c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-1-0.a new file mode 100644 index 0000000..1e51efd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-1.a new file mode 100644 index 0000000..91a4e62 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-2.a new file mode 100644 index 0000000..8d4fd34 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-ansi-l1-1-0.a new file mode 100644 index 0000000..ed77b26 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-l1-1-0.a new file mode 100644 index 0000000..79323d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-normalization-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-normalization-l1-1-0.a new file mode 100644 index 0000000..a55ddae Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-normalization-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-path-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-path-l1-1-0.a new file mode 100644 index 0000000..d46c94d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processenvironment-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processenvironment-l1-1-0.a new file mode 100644 index 0000000..8f36637 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processenvironment-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-0.a new file mode 100644 index 0000000..2fe0022 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-1.a new file mode 100644 index 0000000..d0cca93 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-2.a new file mode 100644 index 0000000..3ecc222 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-3.a new file mode 100644 index 0000000..696ae36 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processtopology-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processtopology-obsolete-l1-1-0.a new file mode 100644 index 0000000..84bc77d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processtopology-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-profile-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-profile-l1-1-0.a new file mode 100644 index 0000000..c3612ca Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-profile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-ansi-l1-1-0.a new file mode 100644 index 0000000..a159c31 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-l1-1-0.a new file mode 100644 index 0000000..460e619 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psm-appnotify-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psm-appnotify-l1-1-0.a new file mode 100644 index 0000000..0a86c5b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psm-appnotify-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-0.a new file mode 100644 index 0000000..c4d1ba2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-1.a new file mode 100644 index 0000000..2d4b41f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-2.a new file mode 100644 index 0000000..6b7d9cd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-1-0.a new file mode 100644 index 0000000..95bdd3c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-2-0.a new file mode 100644 index 0000000..ade2b49 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-slapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-slapi-l1-1-0.a new file mode 100644 index 0000000..8f61e69 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-slapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-string-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-string-l1-1-0.a new file mode 100644 index 0000000..ecb2735 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-ansi-l1-1-0.a new file mode 100644 index 0000000..5501d11 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-1-0.a new file mode 100644 index 0000000..da73411 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-0.a new file mode 100644 index 0000000..cf630b5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-1.a new file mode 100644 index 0000000..d407733 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-1-0.a new file mode 100644 index 0000000..977ac4e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-0.a new file mode 100644 index 0000000..34833cb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-3.a new file mode 100644 index 0000000..57858f2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-threadpool-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-threadpool-l1-2-0.a new file mode 100644 index 0000000..21f7322 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-threadpool-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-timezone-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-timezone-l1-1-0.a new file mode 100644 index 0000000..cec79cb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-timezone-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-url-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-url-l1-1-0.a new file mode 100644 index 0000000..c7163a6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-url-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-util-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-util-l1-1-0.a new file mode 100644 index 0000000..b6d8cc7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-util-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-version-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-version-l1-1-0.a new file mode 100644 index 0000000..6105470 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-version-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-versionansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-versionansi-l1-1-0.a new file mode 100644 index 0000000..cd19c2f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-versionansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowsceip-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowsceip-l1-1-0.a new file mode 100644 index 0000000..00d7552 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowsceip-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a new file mode 100644 index 0000000..ef34952 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a new file mode 100644 index 0000000..ca2761f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a new file mode 100644 index 0000000..105f5c8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-0.a new file mode 100644 index 0000000..5a14013 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-1.a new file mode 100644 index 0000000..4e49d67 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..d0ec877 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-registration-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-registration-l1-1-0.a new file mode 100644 index 0000000..95a9bfb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-registration-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-robuffer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-robuffer-l1-1-0.a new file mode 100644 index 0000000..067a348 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-robuffer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a new file mode 100644 index 0000000..dae18e8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-string-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-string-l1-1-0.a new file mode 100644 index 0000000..a5115c3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-wow64-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-wow64-l1-1-0.a new file mode 100644 index 0000000..38b2821 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-wow64-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-xstate-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-xstate-l2-1-0.a new file mode 100644 index 0000000..91f0599 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-xstate-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-classicprovider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-classicprovider-l1-1-0.a new file mode 100644 index 0000000..9f00d28 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-classicprovider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-consumer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-consumer-l1-1-0.a new file mode 100644 index 0000000..9fa8e24 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-consumer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-controller-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-controller-l1-1-0.a new file mode 100644 index 0000000..59ae352 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-controller-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-legacy-l1-1-0.a new file mode 100644 index 0000000..02d4560 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-provider-l1-1-0.a new file mode 100644 index 0000000..f81e6ce Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-deviceinformation-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-deviceinformation-l1-1-0.a new file mode 100644 index 0000000..15596e5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-deviceinformation-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-expandedresources-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-expandedresources-l1-1-0.a new file mode 100644 index 0000000..fb4d210 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-expandedresources-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-0.a new file mode 100644 index 0000000..9c4c74b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-1.a new file mode 100644 index 0000000..da49791 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-0.a new file mode 100644 index 0000000..1362a96 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-1.a new file mode 100644 index 0000000..4b46f36 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-2.a new file mode 100644 index 0000000..e5fc8cf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-3.a new file mode 100644 index 0000000..90c4726 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-4.a new file mode 100644 index 0000000..05b5b8a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-ro-typeresolution-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-ro-typeresolution-l1-1-0.a new file mode 100644 index 0000000..be4994c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-ro-typeresolution-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-1-0.a new file mode 100644 index 0000000..51e89ca Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-0.a new file mode 100644 index 0000000..493442d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-1.a new file mode 100644 index 0000000..b5cd1aa Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-cryptoapi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-cryptoapi-l1-1-0.a new file mode 100644 index 0000000..a8c6c09 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-cryptoapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-isolatedcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-isolatedcontainer-l1-1-0.a new file mode 100644 index 0000000..0b65884 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-isolatedcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-ansi-l2-1-0.a new file mode 100644 index 0000000..3bc3b94 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-l2-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-l2-1-0.a new file mode 100644 index 0000000..fb8c8ec Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-ansi-l1-1-0.a new file mode 100644 index 0000000..83b64c0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-l1-1-0.a new file mode 100644 index 0000000..953406d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-ansi-l1-1-0.a new file mode 100644 index 0000000..3c758ff Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-l1-1-0.a new file mode 100644 index 0000000..9ce4fd9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-shcore-stream-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-shcore-stream-winrt-l1-1-0.a new file mode 100644 index 0000000..86bbbcb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-shcore-stream-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-bcrypt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-bcrypt.a new file mode 100644 index 0000000..5951094 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-bcrypt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-cabinet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-cabinet.a new file mode 100644 index 0000000..8dfa306 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-chakra.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-chakra.a new file mode 100644 index 0000000..c6073e6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-chakra.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-coremessaging.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-coremessaging.a new file mode 100644 index 0000000..c29811a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-coremessaging.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-crypt32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-crypt32.a new file mode 100644 index 0000000..08a1b26 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-crypt32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d2d1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d2d1.a new file mode 100644 index 0000000..f1e6491 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d2d1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d11.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d11.a new file mode 100644 index 0000000..424039b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d11.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d12.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d12.a new file mode 100644 index 0000000..b9c76f5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d12.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3dcompiler_47.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3dcompiler_47.a new file mode 100644 index 0000000..4338e8e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3dcompiler_47.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-deviceaccess.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-deviceaccess.a new file mode 100644 index 0000000..e795079 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-deviceaccess.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc.a new file mode 100644 index 0000000..4e96e11 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc6.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc6.a new file mode 100644 index 0000000..d4af08b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc6.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dwrite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dwrite.a new file mode 100644 index 0000000..252c278 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dwrite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dxgi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dxgi.a new file mode 100644 index 0000000..7bc0efe Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dxgi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-esent.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-esent.a new file mode 100644 index 0000000..4ea456e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-esent.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-core-iuri-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-core-iuri-l1-1-0.a new file mode 100644 index 0000000..79b13d5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-core-iuri-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-gaming-xinput-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-gaming-xinput-l1-1-0.a new file mode 100644 index 0000000..23a078c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-gaming-xinput-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-0.a new file mode 100644 index 0000000..9b91355 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-1.a new file mode 100644 index 0000000..89e6572 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-2.a new file mode 100644 index 0000000..75f3516 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-3.a new file mode 100644 index 0000000..3b79a34 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-hrtfapo.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-hrtfapo.a new file mode 100644 index 0000000..0072969 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-hrtfapo.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-inkobjcore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-inkobjcore.a new file mode 100644 index 0000000..88e4a44 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-inkobjcore.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-iphlpapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-iphlpapi.a new file mode 100644 index 0000000..33947ec Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-iphlpapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mf.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mf.a new file mode 100644 index 0000000..737149a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mf.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfplat.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfplat.a new file mode 100644 index 0000000..c86f9a5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfplat.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfreadwrite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfreadwrite.a new file mode 100644 index 0000000..ea2bce6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfreadwrite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfsensorgroup.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfsensorgroup.a new file mode 100644 index 0000000..44aedc1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfsensorgroup.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mmdevapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mmdevapi.a new file mode 100644 index 0000000..50ea8b5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mmdevapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-msajapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-msajapi.a new file mode 100644 index 0000000..0ade382 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-msajapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mswsock.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mswsock.a new file mode 100644 index 0000000..c0b6089 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ncrypt.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ncrypt.a new file mode 100644 index 0000000..c92ecc9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ncrypt.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ntdll.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ntdll.a new file mode 100644 index 0000000..55d704d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ntdll.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-oleaut32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-oleaut32.a new file mode 100644 index 0000000..7fd7ed3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-propsys.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-propsys.a new file mode 100644 index 0000000..d3e929e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-propsys.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rometadata.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rometadata.a new file mode 100644 index 0000000..1f03910 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rometadata.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rpcrt4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rpcrt4.a new file mode 100644 index 0000000..ccd98d6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-sspicli.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-sspicli.a new file mode 100644 index 0000000..7e24e2b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-sspicli.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-uiautomationcore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-uiautomationcore.a new file mode 100644 index 0000000..d6ffecd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-uiautomationcore.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-urlmon.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-urlmon.a new file mode 100644 index 0000000..3865073 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-urlmon.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-webservices.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-webservices.a new file mode 100644 index 0000000..c782f15 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-webservices.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.data.pdf.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.data.pdf.a new file mode 100644 index 0000000..f0e48b3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.data.pdf.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.networking.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.networking.a new file mode 100644 index 0000000..131affb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.networking.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windowscodecs.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windowscodecs.a new file mode 100644 index 0000000..f7f0abe Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windowscodecs.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ws2_32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ws2_32.a new file mode 100644 index 0000000..321fd2f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xaudio2_9.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xaudio2_9.a new file mode 100644 index 0000000..b0f72c9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xaudio2_9.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xmllite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xmllite.a new file mode 100644 index 0000000..e4e0462 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xmllite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp.a new file mode 100644 index 0000000..5ef765f --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp.a @@ -0,0 +1,183 @@ +INPUT( +libwinapi_windowsapp-api-ms-win-core-memory-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-file-l2-1-2.a +libwinapi_windowsapp-api-ms-win-core-windowsceip-l1-1-0.a +libwinapi_windowsapp-api-ms-win-security-sddl-ansi-l1-1-0.a +libwinapi_windowsapp-ws2_32.a +libwinapi_windowsapp-api-ms-win-security-provider-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-psapi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-eventing-controller-l1-1-0.a +libwinapi_windowsapp-d3dcompiler_47.a +libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-1.a +libwinapi_windowsapp-mswsock.a +libwinapi_windowsapp-api-ms-win-core-file-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-winrt-string-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-0.a +libwinapi_windowsapp-msajapi.a +libwinapi_windowsapp-api-ms-win-core-winrt-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-2.a +libwinapi_windowsapp-api-ms-win-core-string-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-com-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-file-ansi-l2-1-0.a +libwinapi_windowsapp-api-ms-win-core-comm-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-interlocked-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-heap-obsolete-l1-1-0.a +libwinapi_windowsapp-xmllite.a +libwinapi_windowsapp-api-ms-win-core-largeinteger-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-normalization-l1-1-0.a +libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-localization-l1-2-0.a +libwinapi_windowsapp-d2d1.a +libwinapi_windowsapp-propsys.a +libwinapi_windowsapp-api-ms-win-security-cryptoapi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-localization-obsolete-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-interlocked-l1-1-0.a +libwinapi_windowsapp-ntdll.a +libwinapi_windowsapp-rpcrt4.a +libwinapi_windowsapp-api-ms-win-core-libraryloader-l2-1-0.a +libwinapi_windowsapp-api-ms-win-core-winrt-registration-l1-1-0.a +libwinapi_windowsapp-ext-ms-win-gaming-xinput-l1-1-0.a +libwinapi_windowsapp-api-ms-win-eventing-legacy-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-1.a +libwinapi_windowsapp-windows.networking.a +libwinapi_windowsapp-api-ms-win-core-io-l1-1-1.a +libwinapi_windowsapp-bcrypt.a +libwinapi_windowsapp-api-ms-win-core-wow64-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-file-l1-2-2.a +libwinapi_windowsapp-api-ms-win-core-localization-l1-2-2.a +libwinapi_windowsapp-api-ms-win-eventing-classicprovider-l1-1-0.a +libwinapi_windowsapp-d3d12.a +libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-threadpool-l1-2-0.a +libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-4.a +libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-1.a +libwinapi_windowsapp-xaudio2_9.a +libwinapi_windowsapp-api-ms-win-core-url-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-xstate-l2-1-0.a +libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-2.a +libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a +libwinapi_windowsapp-esent.a +libwinapi_windowsapp-api-ms-win-core-debug-l1-1-0.a +libwinapi_windowsapp-coremessaging.a +libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-1.a +libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-comm-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-1.a +libwinapi_windowsapp-dxgi.a +libwinapi_windowsapp-api-ms-win-core-version-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-psm-appnotify-l1-1-0.a +libwinapi_windowsapp-deviceaccess.a +libwinapi_windowsapp-api-ms-win-core-memory-l1-1-3.a +libwinapi_windowsapp-api-ms-win-core-console-l2-1-0.a +libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-handle-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-namespace-ansi-l1-1-0.a +libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-1.a +libwinapi_windowsapp-oleaut32.a +libwinapi_windowsapp-webservices.a +libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-com-l2-1-1.a +libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-memory-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-console-l1-1-0.a +libwinapi_windowsapp-crypt32.a +libwinapi_windowsapp-windows.data.pdf.a +libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-3.a +libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-libraryloader-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-namespace-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-synch-l1-2-1.a +libwinapi_windowsapp-api-ms-win-security-sddl-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-processtopology-obsolete-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-psapi-ansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-synch-ansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-3.a +libwinapi_windowsapp-d3d11.a +libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-2.a +libwinapi_windowsapp-rometadata.a +libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-2.a +libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-3.a +libwinapi_windowsapp-api-ms-win-core-com-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-file-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-1-0.a +libwinapi_windowsapp-cabinet.a +libwinapi_windowsapp-mfreadwrite.a +libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-security-base-l1-1-0.a +libwinapi_windowsapp-dwrite.a +libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-io-l1-1-0.a +libwinapi_windowsapp-api-ms-win-ro-typeresolution-l1-1-0.a +libwinapi_windowsapp-api-ms-win-security-provider-ansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-winrt-robuffer-l1-1-0.a +libwinapi_windowsapp-windowscodecs.a +libwinapi_windowsapp-uiautomationcore.a +libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-3.a +libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-2.a +libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-1.a +libwinapi_windowsapp-api-ms-win-security-lsalookup-l2-1-0.a +libwinapi_windowsapp-api-ms-win-core-com-midlproxystub-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-synch-l1-1-0.a +libwinapi_windowsapp-ext-ms-win-core-iuri-l1-1-0.a +libwinapi_windowsapp-ncrypt.a +libwinapi_windowsapp-api-ms-win-gaming-expandedresources-l1-1-0.a +libwinapi_windowsapp-mf.a +libwinapi_windowsapp-api-ms-win-core-localization-l1-2-1.a +libwinapi_windowsapp-inkobjcore.a +libwinapi_windowsapp-sspicli.a +libwinapi_windowsapp-api-ms-win-core-file-ansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-enclave-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-2.a +libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-3.a +libwinapi_windowsapp-api-ms-win-security-lsalookup-ansi-l2-1-0.a +libwinapi_windowsapp-dhcpcsvc.a +libwinapi_windowsapp-api-ms-win-core-localization-l2-1-0.a +libwinapi_windowsapp-api-ms-win-core-path-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-versionansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-timezone-l1-1-0.a +libwinapi_windowsapp-api-ms-win-eventing-consumer-l1-1-0.a +libwinapi_windowsapp-api-ms-win-eventing-provider-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a +libwinapi_windowsapp-dhcpcsvc6.a +libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-0.a +libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-l1-1-0.a +libwinapi_windowsapp-urlmon.a +libwinapi_windowsapp-api-ms-win-core-localization-ansi-l1-1-0.a +libwinapi_windowsapp-mfsensorgroup.a +libwinapi_windowsapp-iphlpapi.a +libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-file-l2-1-0.a +libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-processenvironment-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-0.a +libwinapi_windowsapp-api-ms-win-security-base-l1-2-0.a +libwinapi_windowsapp-chakra.a +libwinapi_windowsapp-hrtfapo.a +libwinapi_windowsapp-api-ms-win-gaming-deviceinformation-l1-1-0.a +libwinapi_windowsapp-api-ms-win-shcore-stream-winrt-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-slapi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-synch-l1-2-0.a +libwinapi_windowsapp-api-ms-win-security-base-l1-2-1.a +libwinapi_windowsapp-mfplat.a +libwinapi_windowsapp-mmdevapi.a +libwinapi_windowsapp-api-ms-win-core-profile-l1-1-0.a +libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-heap-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-heap-l2-1-0.a +libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-2.a +libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-util-l1-1-0.a +libwinapi_windowsapp-api-ms-win-security-isolatedcontainer-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-memory-l1-1-2.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-advapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-advapi32.a new file mode 100644 index 0000000..2608a19 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-advapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-localization-l1-2-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-localization-l1-2-0.a new file mode 100644 index 0000000..7222809 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-localization-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..b8f9f7a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-robuffer-l1-1-0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-robuffer-l1-1-0.a new file mode 100644 index 0000000..91bc763 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-robuffer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-cabinet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-cabinet.a new file mode 100644 index 0000000..eb78e07 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d2d1.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d2d1.a new file mode 100644 index 0000000..0929639 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d2d1.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3d11.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3d11.a new file mode 100644 index 0000000..8f16d84 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3d11.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3dcompiler_47.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3dcompiler_47.a new file mode 100644 index 0000000..5bcd587 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3dcompiler_47.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-deviceaccess.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-deviceaccess.a new file mode 100644 index 0000000..f20bd44 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-deviceaccess.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc.a new file mode 100644 index 0000000..71c58f8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc6.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc6.a new file mode 100644 index 0000000..1a91cd7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc6.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dwrite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dwrite.a new file mode 100644 index 0000000..a16a066 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dwrite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dxgi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dxgi.a new file mode 100644 index 0000000..6846f7e Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dxgi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-esent.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-esent.a new file mode 100644 index 0000000..2cd8067 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-esent.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-kernel32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-kernel32.a new file mode 100644 index 0000000..14873d3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-kernel32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mf.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mf.a new file mode 100644 index 0000000..f0e11a0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mf.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfplat.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfplat.a new file mode 100644 index 0000000..74c7c8a Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfplat.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfreadwrite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfreadwrite.a new file mode 100644 index 0000000..61958f3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfreadwrite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mmdevapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mmdevapi.a new file mode 100644 index 0000000..1fa5240 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mmdevapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-msajapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-msajapi.a new file mode 100644 index 0000000..d74c314 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-msajapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mscoree.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mscoree.a new file mode 100644 index 0000000..52227cb Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mscoree.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mswsock.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mswsock.a new file mode 100644 index 0000000..5c8d001 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ole32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ole32.a new file mode 100644 index 0000000..6804238 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ole32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-oleaut32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-oleaut32.a new file mode 100644 index 0000000..30c5ad1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-propsys.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-propsys.a new file mode 100644 index 0000000..b1712ab Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-propsys.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-rpcrt4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-rpcrt4.a new file mode 100644 index 0000000..4099340 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-uiautomationcore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-uiautomationcore.a new file mode 100644 index 0000000..8e19c7f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-uiautomationcore.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-urlmon.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-urlmon.a new file mode 100644 index 0000000..bc09346 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-urlmon.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-webservices.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-webservices.a new file mode 100644 index 0000000..bf1e18b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-webservices.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.data.pdf.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.data.pdf.a new file mode 100644 index 0000000..b126463 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.data.pdf.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.networking.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.networking.a new file mode 100644 index 0000000..d478811 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.networking.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windowscodecs.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windowscodecs.a new file mode 100644 index 0000000..8421f86 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windowscodecs.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ws2_32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ws2_32.a new file mode 100644 index 0000000..710f54b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xaudio2_8.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xaudio2_8.a new file mode 100644 index 0000000..3ce3d6b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xaudio2_8.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xinput1_4.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xinput1_4.a new file mode 100644 index 0000000..ab91188 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xinput1_4.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xmllite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xmllite.a new file mode 100644 index 0000000..aa99796 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xmllite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel.a new file mode 100644 index 0000000..f6c44ec --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel.a @@ -0,0 +1,38 @@ +INPUT( +libwinapi_windowsapp_downlevel-dhcpcsvc.a +libwinapi_windowsapp_downlevel-rpcrt4.a +libwinapi_windowsapp_downlevel-esent.a +libwinapi_windowsapp_downlevel-dwrite.a +libwinapi_windowsapp_downlevel-d3dcompiler_47.a +libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-l1-1-0.a +libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-robuffer-l1-1-0.a +libwinapi_windowsapp_downlevel-dhcpcsvc6.a +libwinapi_windowsapp_downlevel-urlmon.a +libwinapi_windowsapp_downlevel-mfreadwrite.a +libwinapi_windowsapp_downlevel-propsys.a +libwinapi_windowsapp_downlevel-cabinet.a +libwinapi_windowsapp_downlevel-kernel32.a +libwinapi_windowsapp_downlevel-msajapi.a +libwinapi_windowsapp_downlevel-mscoree.a +libwinapi_windowsapp_downlevel-xinput1_4.a +libwinapi_windowsapp_downlevel-xmllite.a +libwinapi_windowsapp_downlevel-mmdevapi.a +libwinapi_windowsapp_downlevel-xaudio2_8.a +libwinapi_windowsapp_downlevel-oleaut32.a +libwinapi_windowsapp_downlevel-ws2_32.a +libwinapi_windowsapp_downlevel-uiautomationcore.a +libwinapi_windowsapp_downlevel-d2d1.a +libwinapi_windowsapp_downlevel-windows.networking.a +libwinapi_windowsapp_downlevel-windowscodecs.a +libwinapi_windowsapp_downlevel-webservices.a +libwinapi_windowsapp_downlevel-windows.data.pdf.a +libwinapi_windowsapp_downlevel-mf.a +libwinapi_windowsapp_downlevel-d3d11.a +libwinapi_windowsapp_downlevel-ole32.a +libwinapi_windowsapp_downlevel-dxgi.a +libwinapi_windowsapp_downlevel-deviceaccess.a +libwinapi_windowsapp_downlevel-advapi32.a +libwinapi_windowsapp_downlevel-mfplat.a +libwinapi_windowsapp_downlevel-mswsock.a +libwinapi_windowsapp_downlevel-api-ms-win-core-localization-l1-2-0.a +) diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowscodecs.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowscodecs.a new file mode 100644 index 0000000..42ee672 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_windowscodecs.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winfax.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winfax.a new file mode 100644 index 0000000..e482dcd Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winfax.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winhttp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winhttp.a new file mode 100644 index 0000000..8d6ae88 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winhttp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wininet.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wininet.a new file mode 100644 index 0000000..dfcd544 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wininet.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winmm.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winmm.a new file mode 100644 index 0000000..7ddc07b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winmm.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winscard.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winscard.a new file mode 100644 index 0000000..31e9f20 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winscard.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winspool.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winspool.a new file mode 100644 index 0000000..c99f830 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winspool.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winsqlite3.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winsqlite3.a new file mode 100644 index 0000000..2f5f941 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winsqlite3.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winsta.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winsta.a new file mode 100644 index 0000000..8faad47 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winsta.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wintrust.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wintrust.a new file mode 100644 index 0000000..066e7a8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wintrust.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winusb.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winusb.a new file mode 100644 index 0000000..7e2cd87 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_winusb.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wlanapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wlanapi.a new file mode 100644 index 0000000..dd0d898 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wlanapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wlanui.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wlanui.a new file mode 100644 index 0000000..1e9ead8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wlanui.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wldap32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wldap32.a new file mode 100644 index 0000000..70e88d9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wldap32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wmip.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wmip.a new file mode 100644 index 0000000..1acabc3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wmip.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wmvcore.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wmvcore.a new file mode 100644 index 0000000..3c06a11 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wmvcore.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wofutil.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wofutil.a new file mode 100644 index 0000000..d5c38d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wofutil.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wow32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wow32.a new file mode 100644 index 0000000..0b0c431 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wow32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ws2_32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ws2_32.a new file mode 100644 index 0000000..55cc1be Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wscapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wscapi.a new file mode 100644 index 0000000..8394bdf Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wscapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsclient.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsclient.a new file mode 100644 index 0000000..7a00a57 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsclient.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsdapi.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsdapi.a new file mode 100644 index 0000000..51e0541 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsdapi.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsmsvc.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsmsvc.a new file mode 100644 index 0000000..2b0490c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsmsvc.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsnmp32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsnmp32.a new file mode 100644 index 0000000..87bf3de Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsnmp32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsock32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsock32.a new file mode 100644 index 0000000..97ce32f Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wsock32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wtsapi32.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wtsapi32.a new file mode 100644 index 0000000..5f3988c Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_wtsapi32.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2.a new file mode 100644 index 0000000..04a0a06 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2_8.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2_8.a new file mode 100644 index 0000000..52d4642 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2_8.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xinput.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xinput.a new file mode 100644 index 0000000..46ee0c7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xinput.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xinput9_1_0.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xinput9_1_0.a new file mode 100644 index 0000000..93bb330 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xinput9_1_0.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xinputuap.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xinputuap.a new file mode 100644 index 0000000..9976a4b Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xinputuap.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xmllite.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xmllite.a new file mode 100644 index 0000000..b65232d Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xmllite.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xolehlp.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xolehlp.a new file mode 100644 index 0000000..7e0af57 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xolehlp.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xpsdocumenttargetprint.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xpsdocumenttargetprint.a new file mode 100644 index 0000000..e65dd68 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xpsdocumenttargetprint.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xpsprint.a b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xpsprint.a new file mode 100644 index 0000000..3101fb6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/lib/libwinapi_xpsprint.a differ diff --git a/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/src/lib.rs b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/src/lib.rs new file mode 100644 index 0000000..3b7f827 --- /dev/null +++ b/third_party/cargo/vendor/winapi-i686-pc-windows-gnu-0.4.0/src/lib.rs @@ -0,0 +1,7 @@ +// Copyright © 2016 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +#![no_std] diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/.cargo-checksum.json b/third_party/cargo/vendor/winapi-util-0.1.3/.cargo-checksum.json new file mode 100644 index 0000000..9e11fe2 --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"COPYING":"01c266bced4a434da0051174d6bee16a4c82cf634e2679b6155d40d75012390f","Cargo.toml":"c0e2974076ab1e0f134f055c894f2732cca3aeba9ab7f33da959aa5f2124d185","LICENSE-MIT":"cb3c929a05e6cbc9de9ab06a4c57eeb60ca8c724bef6c138c87d3a577e27aa14","README.md":"b97062c8af7a615725a19394c8d26a19460a1840979196f0c119a1c1432d15f1","UNLICENSE":"7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c","rustfmt.toml":"1ca600239a27401c4a43f363cf3f38183a212affc1f31bff3ae93234bbaec228","src/console.rs":"609b67c3f0919b757308857885581ab7054c13f61ad95eb7c208a2e45287cc5d","src/file.rs":"5e2b5f60de7f8a2eeeafe165701eb0e442a0bafbf6df6e2e0d92fdccafd7a8bf","src/lib.rs":"36aba07c7bd526e341382b6471212ccfef8030f27b73a607f2539b307ccff8d1","src/win.rs":"146b65eae8fe2fe3c567609d7d7be0a983f607fc9d3fcdb5cd7ca6f2cc7bde33"},"package":"4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"} \ No newline at end of file diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/BUILD b/third_party/cargo/vendor/winapi-util-0.1.3/BUILD new file mode 100644 index 0000000..f99cc5e --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" + "unencumbered", # "Unlicense" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "winapi_util", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.3", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/COPYING b/third_party/cargo/vendor/winapi-util-0.1.3/COPYING new file mode 100644 index 0000000..bb9c20a --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/Cargo.toml b/third_party/cargo/vendor/winapi-util-0.1.3/Cargo.toml new file mode 100644 index 0000000..b1d64ab --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/Cargo.toml @@ -0,0 +1,28 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "winapi-util" +version = "0.1.3" +authors = ["Andrew Gallant <jamslam@gmail.com>"] +description = "A dumping ground for high level safe wrappers over winapi." +homepage = "https://github.com/BurntSushi/winapi-util" +documentation = "https://docs.rs/winapi-util" +readme = "README.md" +keywords = ["windows", "winapi", "util", "win"] +categories = ["os::windows-apis", "external-ffi-bindings"] +license = "Unlicense/MIT" +repository = "https://github.com/BurntSushi/winapi-util" +[target."cfg(windows)".dependencies.winapi] +version = "0.3" +features = ["std", "consoleapi", "errhandlingapi", "fileapi", "minwindef", "processenv", "winbase", "wincon", "winerror", "winnt"] diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/LICENSE-MIT b/third_party/cargo/vendor/winapi-util-0.1.3/LICENSE-MIT new file mode 100644 index 0000000..3303149 --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/README.md b/third_party/cargo/vendor/winapi-util-0.1.3/README.md new file mode 100644 index 0000000..79e4730 --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/README.md @@ -0,0 +1,58 @@ +winapi-util +=========== +This crate provides a smattering of safe wrappers around various parts of the +[winapi](https://crates.io/crates/winapi) crate. + +[![Build status](https://github.com/BurntSushi/winapi-util/workflows/ci/badge.svg)](https://github.com/BurntSushi/winapi-util/actions) +[![](http://meritbadge.herokuapp.com/winapi-util)](https://crates.io/crates/winapi-util) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + + +### Documentation + +https://docs.rs/winapi-util + + +### Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +winapi-util = "0.1" +``` + + +### Notes + +This crate was born out of frustration with having to write lots of little +ffi utility bindings in a variety of crates in order to get Windows support. +Eventually, I started needing to copy & paste a lot of those utility routines. +Since they are utility routines, they often don't make sense to expose directly +in the crate in which they are defined. Instead of continuing this process, +I decided to make a crate instead. + +Normally, I'm not a huge fan of "utility" crates like this that don't have a +well defined scope, but this is primarily a practical endeavor to make it +easier to isolate Windows specific ffi code. + +While I don't have a long term vision for this crate, I will welcome additional +PRs that add more high level routines/types on an as-needed basis. + +**WARNING:** I am not a Windows developer, so extra review to make sure I've +got things right is most appreciated. + + +### Minimum Rust version policy + +This crate's minimum supported `rustc` version is `1.34.0`. + +The current policy is that the minimum Rust version required to use this crate +can be increased in non-breaking version updates. For example, if `crate 1.0` +requires Rust 1.20.0, then `crate 1.0.z` for all values of `z` will also +require Rust 1.20.0 or newer. However, `crate 1.y` for `y > 0` may require a +newer minimum version of Rust. + +In general, this crate will be conservative with respect to the minimum +supported version of Rust. diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/UNLICENSE b/third_party/cargo/vendor/winapi-util-0.1.3/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <http://unlicense.org/> diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/rustfmt.toml b/third_party/cargo/vendor/winapi-util-0.1.3/rustfmt.toml new file mode 100644 index 0000000..aa37a21 --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/rustfmt.toml @@ -0,0 +1,2 @@ +max_width = 79 +use_small_heuristics = "max" diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/src/console.rs b/third_party/cargo/vendor/winapi-util-0.1.3/src/console.rs new file mode 100644 index 0000000..afefa15 --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/src/console.rs @@ -0,0 +1,377 @@ +use std::io; +use std::mem; + +use winapi::shared::minwindef::WORD; +use winapi::um::consoleapi::{GetConsoleMode, SetConsoleMode}; +use winapi::um::wincon::{ + self, GetConsoleScreenBufferInfo, SetConsoleTextAttribute, + CONSOLE_SCREEN_BUFFER_INFO, FOREGROUND_BLUE as FG_BLUE, + FOREGROUND_GREEN as FG_GREEN, FOREGROUND_INTENSITY as FG_INTENSITY, + FOREGROUND_RED as FG_RED, +}; + +use crate::{AsHandleRef, HandleRef}; + +const FG_CYAN: WORD = FG_BLUE | FG_GREEN; +const FG_MAGENTA: WORD = FG_BLUE | FG_RED; +const FG_YELLOW: WORD = FG_GREEN | FG_RED; +const FG_WHITE: WORD = FG_BLUE | FG_GREEN | FG_RED; + +/// Query the given handle for information about the console's screen buffer. +/// +/// The given handle should represent a console. Otherwise, an error is +/// returned. +/// +/// This corresponds to calling [`GetConsoleScreenBufferInfo`]. +/// +/// [`GetConsoleScreenBufferInfo`]: https://docs.microsoft.com/en-us/windows/console/getconsolescreenbufferinfo +pub fn screen_buffer_info<H: AsHandleRef>( + h: H, +) -> io::Result<ScreenBufferInfo> { + unsafe { + let mut info: CONSOLE_SCREEN_BUFFER_INFO = mem::zeroed(); + let rc = GetConsoleScreenBufferInfo(h.as_raw(), &mut info); + if rc == 0 { + return Err(io::Error::last_os_error()); + } + Ok(ScreenBufferInfo(info)) + } +} + +/// Set the text attributes of the console represented by the given handle. +/// +/// This corresponds to calling [`SetConsoleTextAttribute`]. +/// +/// [`SetConsoleTextAttribute`]: https://docs.microsoft.com/en-us/windows/console/setconsoletextattribute +pub fn set_text_attributes<H: AsHandleRef>( + h: H, + attributes: u16, +) -> io::Result<()> { + if unsafe { SetConsoleTextAttribute(h.as_raw(), attributes) } == 0 { + Err(io::Error::last_os_error()) + } else { + Ok(()) + } +} + +/// Query the mode of the console represented by the given handle. +/// +/// This corresponds to calling [`GetConsoleMode`], which describes the return +/// value. +/// +/// [`GetConsoleMode`]: https://docs.microsoft.com/en-us/windows/console/getconsolemode +pub fn mode<H: AsHandleRef>(h: H) -> io::Result<u32> { + let mut mode = 0; + if unsafe { GetConsoleMode(h.as_raw(), &mut mode) } == 0 { + Err(io::Error::last_os_error()) + } else { + Ok(mode) + } +} + +/// Set the mode of the console represented by the given handle. +/// +/// This corresponds to calling [`SetConsoleMode`], which describes the format +/// of the mode parameter. +/// +/// [`SetConsoleMode`]: https://docs.microsoft.com/en-us/windows/console/setconsolemode +pub fn set_mode<H: AsHandleRef>(h: H, mode: u32) -> io::Result<()> { + if unsafe { SetConsoleMode(h.as_raw(), mode) } == 0 { + Err(io::Error::last_os_error()) + } else { + Ok(()) + } +} + +/// Represents console screen buffer information such as size, cursor position +/// and styling attributes. +/// +/// This wraps a [`CONSOLE_SCREEN_BUFFER_INFO`]. +/// +/// [`CONSOLE_SCREEN_BUFFER_INFO`]: https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str +#[derive(Clone)] +pub struct ScreenBufferInfo(CONSOLE_SCREEN_BUFFER_INFO); + +impl ScreenBufferInfo { + /// Returns the size of the console screen buffer, in character columns and + /// rows. + /// + /// This corresponds to `dwSize`. + pub fn size(&self) -> (i16, i16) { + (self.0.dwSize.X, self.0.dwSize.Y) + } + + /// Returns the position of the cursor in terms of column and row + /// coordinates of the console screen buffer. + /// + /// This corresponds to `dwCursorPosition`. + pub fn cursor_position(&self) -> (i16, i16) { + (self.0.dwCursorPosition.X, self.0.dwCursorPosition.Y) + } + + /// Returns the character attributes associated with this console. + /// + /// This corresponds to `wAttributes`. + /// + /// See [`char info`] for more details. + /// + /// [`char info`]: https://docs.microsoft.com/en-us/windows/console/char-info-str + pub fn attributes(&self) -> u16 { + self.0.wAttributes + } + + /// Returns the maximum size of the console window, in character columns + /// and rows, given the current screen buffer size and font and the screen + /// size. + pub fn max_window_size(&self) -> (i16, i16) { + (self.0.dwMaximumWindowSize.X, self.0.dwMaximumWindowSize.Y) + } +} + +/// A Windows console. +/// +/// This represents a very limited set of functionality available to a Windows +/// console. In particular, it can only change text attributes such as color +/// and intensity. This may grow over time. If you need more routines, please +/// file an issue and/or PR. +/// +/// There is no way to "write" to this console. Simply write to +/// stdout or stderr instead, while interleaving instructions to the console +/// to change text attributes. +/// +/// A common pitfall when using a console is to forget to flush writes to +/// stdout before setting new text attributes. +/// +/// # Example +/// ```no_run +/// # #[cfg(windows)] +/// # { +/// use winapi_util::console::{Console, Color, Intense}; +/// +/// let mut con = Console::stdout().unwrap(); +/// con.fg(Intense::Yes, Color::Cyan).unwrap(); +/// println!("This text will be intense cyan."); +/// con.reset().unwrap(); +/// println!("This text will be normal."); +/// # } +/// ``` +#[derive(Debug)] +pub struct Console { + kind: HandleKind, + start_attr: TextAttributes, + cur_attr: TextAttributes, +} + +#[derive(Clone, Copy, Debug)] +enum HandleKind { + Stdout, + Stderr, +} + +impl HandleKind { + fn handle(&self) -> HandleRef { + match *self { + HandleKind::Stdout => HandleRef::stdout(), + HandleKind::Stderr => HandleRef::stderr(), + } + } +} + +impl Console { + /// Get a console for a standard I/O stream. + fn create_for_stream(kind: HandleKind) -> io::Result<Console> { + let h = kind.handle(); + let info = screen_buffer_info(&h)?; + let attr = TextAttributes::from_word(info.attributes()); + Ok(Console { kind: kind, start_attr: attr, cur_attr: attr }) + } + + /// Create a new Console to stdout. + /// + /// If there was a problem creating the console, then an error is returned. + pub fn stdout() -> io::Result<Console> { + Self::create_for_stream(HandleKind::Stdout) + } + + /// Create a new Console to stderr. + /// + /// If there was a problem creating the console, then an error is returned. + pub fn stderr() -> io::Result<Console> { + Self::create_for_stream(HandleKind::Stderr) + } + + /// Applies the current text attributes. + fn set(&mut self) -> io::Result<()> { + set_text_attributes(self.kind.handle(), self.cur_attr.to_word()) + } + + /// Apply the given intensity and color attributes to the console + /// foreground. + /// + /// If there was a problem setting attributes on the console, then an error + /// is returned. + pub fn fg(&mut self, intense: Intense, color: Color) -> io::Result<()> { + self.cur_attr.fg_color = color; + self.cur_attr.fg_intense = intense; + self.set() + } + + /// Apply the given intensity and color attributes to the console + /// background. + /// + /// If there was a problem setting attributes on the console, then an error + /// is returned. + pub fn bg(&mut self, intense: Intense, color: Color) -> io::Result<()> { + self.cur_attr.bg_color = color; + self.cur_attr.bg_intense = intense; + self.set() + } + + /// Reset the console text attributes to their original settings. + /// + /// The original settings correspond to the text attributes on the console + /// when this `Console` value was created. + /// + /// If there was a problem setting attributes on the console, then an error + /// is returned. + pub fn reset(&mut self) -> io::Result<()> { + self.cur_attr = self.start_attr; + self.set() + } + + /// Toggle virtual terminal processing. + /// + /// This method attempts to toggle virtual terminal processing for this + /// console. If there was a problem toggling it, then an error returned. + /// On success, the caller may assume that toggling it was successful. + /// + /// When virtual terminal processing is enabled, characters emitted to the + /// console are parsed for VT100 and similar control character sequences + /// that control color and other similar operations. + pub fn set_virtual_terminal_processing( + &mut self, + yes: bool, + ) -> io::Result<()> { + let vt = wincon::ENABLE_VIRTUAL_TERMINAL_PROCESSING; + + let handle = self.kind.handle(); + let old_mode = mode(&handle)?; + let new_mode = if yes { old_mode | vt } else { old_mode & !vt }; + if old_mode == new_mode { + return Ok(()); + } + set_mode(&handle, new_mode) + } +} + +/// A representation of text attributes for the Windows console. +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct TextAttributes { + fg_color: Color, + fg_intense: Intense, + bg_color: Color, + bg_intense: Intense, +} + +impl TextAttributes { + fn to_word(&self) -> WORD { + let mut w = 0; + w |= self.fg_color.to_fg(); + w |= self.fg_intense.to_fg(); + w |= self.bg_color.to_bg(); + w |= self.bg_intense.to_bg(); + w + } + + fn from_word(word: WORD) -> TextAttributes { + TextAttributes { + fg_color: Color::from_fg(word), + fg_intense: Intense::from_fg(word), + bg_color: Color::from_bg(word), + bg_intense: Intense::from_bg(word), + } + } +} + +/// Whether to use intense colors or not. +#[allow(missing_docs)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum Intense { + Yes, + No, +} + +impl Intense { + fn to_bg(&self) -> WORD { + self.to_fg() << 4 + } + + fn from_bg(word: WORD) -> Intense { + Intense::from_fg(word >> 4) + } + + fn to_fg(&self) -> WORD { + match *self { + Intense::No => 0, + Intense::Yes => FG_INTENSITY, + } + } + + fn from_fg(word: WORD) -> Intense { + if word & FG_INTENSITY > 0 { + Intense::Yes + } else { + Intense::No + } + } +} + +/// The set of available colors for use with a Windows console. +#[allow(missing_docs)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum Color { + Black, + Blue, + Green, + Red, + Cyan, + Magenta, + Yellow, + White, +} + +impl Color { + fn to_bg(&self) -> WORD { + self.to_fg() << 4 + } + + fn from_bg(word: WORD) -> Color { + Color::from_fg(word >> 4) + } + + fn to_fg(&self) -> WORD { + match *self { + Color::Black => 0, + Color::Blue => FG_BLUE, + Color::Green => FG_GREEN, + Color::Red => FG_RED, + Color::Cyan => FG_CYAN, + Color::Magenta => FG_MAGENTA, + Color::Yellow => FG_YELLOW, + Color::White => FG_WHITE, + } + } + + fn from_fg(word: WORD) -> Color { + match word & 0b111 { + FG_BLUE => Color::Blue, + FG_GREEN => Color::Green, + FG_RED => Color::Red, + FG_CYAN => Color::Cyan, + FG_MAGENTA => Color::Magenta, + FG_YELLOW => Color::Yellow, + FG_WHITE => Color::White, + _ => Color::Black, + } + } +} diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/src/file.rs b/third_party/cargo/vendor/winapi-util-0.1.3/src/file.rs new file mode 100644 index 0000000..56a1e41 --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/src/file.rs @@ -0,0 +1,168 @@ +use std::io; +use std::mem; + +use winapi::shared::minwindef::FILETIME; +use winapi::shared::winerror::NO_ERROR; +use winapi::um::errhandlingapi::GetLastError; +use winapi::um::fileapi::{ + GetFileInformationByHandle, GetFileType, BY_HANDLE_FILE_INFORMATION, +}; +use winapi::um::winnt; + +use crate::AsHandleRef; + +/// Return various pieces of information about a file. +/// +/// This includes information such as a file's size, unique identifier and +/// time related fields. +/// +/// This corresponds to calling [`GetFileInformationByHandle`]. +/// +/// [`GetFileInformationByHandle`]: https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle +pub fn information<H: AsHandleRef>(h: H) -> io::Result<Information> { + unsafe { + let mut info: BY_HANDLE_FILE_INFORMATION = mem::zeroed(); + let rc = GetFileInformationByHandle(h.as_raw(), &mut info); + if rc == 0 { + return Err(io::Error::last_os_error()); + }; + Ok(Information(info)) + } +} + +/// Returns the file type of the given handle. +/// +/// If there was a problem querying the file type, then an error is returned. +/// +/// This corresponds to calling [`GetFileType`]. +/// +/// [`GetFileType`]: https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfiletype +pub fn typ<H: AsHandleRef>(h: H) -> io::Result<Type> { + unsafe { + let rc = GetFileType(h.as_raw()); + if rc == 0 && GetLastError() != NO_ERROR { + return Err(io::Error::last_os_error()); + } + Ok(Type(rc)) + } +} + +/// Returns true if and only if the given file attributes contain the +/// `FILE_ATTRIBUTE_HIDDEN` attribute. +pub fn is_hidden(file_attributes: u64) -> bool { + file_attributes & (winnt::FILE_ATTRIBUTE_HIDDEN as u64) > 0 +} + +/// Represents file information such as creation time, file size, etc. +/// +/// This wraps a [`BY_HANDLE_FILE_INFORMATION`]. +/// +/// [`BY_HANDLE_FILE_INFORMATION`]: https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information +#[derive(Clone)] +pub struct Information(BY_HANDLE_FILE_INFORMATION); + +impl Information { + /// Returns file attributes. + /// + /// This corresponds to `dwFileAttributes`. + pub fn file_attributes(&self) -> u64 { + self.0.dwFileAttributes as u64 + } + + /// Returns true if and only if this file information has the + /// `FILE_ATTRIBUTE_HIDDEN` attribute. + pub fn is_hidden(&self) -> bool { + is_hidden(self.file_attributes()) + } + + /// Return the creation time, if one exists. + /// + /// This corresponds to `ftCreationTime`. + pub fn creation_time(&self) -> Option<u64> { + filetime_to_u64(self.0.ftCreationTime) + } + + /// Return the last access time, if one exists. + /// + /// This corresponds to `ftLastAccessTime`. + pub fn last_access_time(&self) -> Option<u64> { + filetime_to_u64(self.0.ftLastAccessTime) + } + + /// Return the last write time, if one exists. + /// + /// This corresponds to `ftLastWriteTime`. + pub fn last_write_time(&self) -> Option<u64> { + filetime_to_u64(self.0.ftLastWriteTime) + } + + /// Return the serial number of the volume that the file is on. + /// + /// This corresponds to `dwVolumeSerialNumber`. + pub fn volume_serial_number(&self) -> u64 { + self.0.dwVolumeSerialNumber as u64 + } + + /// Return the file size, in bytes. + /// + /// This corresponds to `nFileSizeHigh` and `nFileSizeLow`. + pub fn file_size(&self) -> u64 { + ((self.0.nFileSizeHigh as u64) << 32) | (self.0.nFileSizeLow as u64) + } + + /// Return the number of links to this file. + /// + /// This corresponds to `nNumberOfLinks`. + pub fn number_of_links(&self) -> u64 { + self.0.nNumberOfLinks as u64 + } + + /// Return the index of this file. The index of a file is a purpotedly + /// unique identifier for a file within a particular volume. + pub fn file_index(&self) -> u64 { + ((self.0.nFileIndexHigh as u64) << 32) | (self.0.nFileIndexLow as u64) + } +} + +/// Represents a Windows file type. +/// +/// This wraps the result of [`GetFileType`]. +/// +/// [`GetFileType`]: https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfiletype +#[derive(Clone)] +pub struct Type(u32); + +impl Type { + /// Returns true if this type represents a character file, which is + /// typically an LPT device or a console. + pub fn is_char(&self) -> bool { + self.0 == ::winapi::um::winbase::FILE_TYPE_CHAR + } + + /// Returns true if this type represents a disk file. + pub fn is_disk(&self) -> bool { + self.0 == ::winapi::um::winbase::FILE_TYPE_DISK + } + + /// Returns true if this type represents a sock, named pipe or an + /// anonymous pipe. + pub fn is_pipe(&self) -> bool { + self.0 == ::winapi::um::winbase::FILE_TYPE_PIPE + } + + /// Returns true if this type is not known. + /// + /// Note that this never corresponds to a failure. + pub fn is_unknown(&self) -> bool { + self.0 == ::winapi::um::winbase::FILE_TYPE_UNKNOWN + } +} + +fn filetime_to_u64(t: FILETIME) -> Option<u64> { + let v = ((t.dwHighDateTime as u64) << 32) | (t.dwLowDateTime as u64); + if v == 0 { + None + } else { + Some(v) + } +} diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/src/lib.rs b/third_party/cargo/vendor/winapi-util-0.1.3/src/lib.rs new file mode 100644 index 0000000..0bb259d --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/src/lib.rs @@ -0,0 +1,32 @@ +/*! +This crate provides a smattering of safe routines for parts of winapi. The +primary purpose of this crate is to serve as a dumping ground for various +utility functions that make interactions with winapi safe. This permits the +centralization of `unsafe` when dealing with Windows APIs, and thus makes it +easier to audit. + +A key abstraction in this crate is the combination of the +[`Handle`](struct.Handle.html) +and +[`HandleRef`](struct.HandleRef.html) +types. Both represent a valid Windows handle to an I/O-like object, where +`Handle` is owned (the resource is closed when the handle is dropped) and +`HandleRef` is borrowed (the resource is not closed when the handle is +dropped). Many of the routines in this crate work on handles and accept +anything that can be safely converted into a `HandleRef`. This includes +standard library types such as `File`, `Stdin`, `Stdout` and `Stderr`. + +Note that this crate is completely empty on non-Windows platforms. +*/ + +#[cfg(windows)] +pub use win::*; + +/// Safe routines for dealing with the Windows console. +#[cfg(windows)] +pub mod console; +/// Safe routines for dealing with files and handles on Windows. +#[cfg(windows)] +pub mod file; +#[cfg(windows)] +mod win; diff --git a/third_party/cargo/vendor/winapi-util-0.1.3/src/win.rs b/third_party/cargo/vendor/winapi-util-0.1.3/src/win.rs new file mode 100644 index 0000000..9c77c0d --- /dev/null +++ b/third_party/cargo/vendor/winapi-util-0.1.3/src/win.rs @@ -0,0 +1,246 @@ +use std::fs::File; +use std::io; +use std::os::windows::io::{ + AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle, +}; +use std::path::Path; +use std::process; + +/// A handle represents an owned and valid Windows handle to a file-like +/// object. +/// +/// When an owned handle is dropped, then the underlying raw handle is closed. +/// To get a borrowed handle, use `HandleRef`. +#[derive(Debug)] +pub struct Handle(File); + +impl AsRawHandle for Handle { + fn as_raw_handle(&self) -> RawHandle { + self.0.as_raw_handle() + } +} + +impl FromRawHandle for Handle { + unsafe fn from_raw_handle(handle: RawHandle) -> Handle { + Handle(File::from_raw_handle(handle)) + } +} + +impl IntoRawHandle for Handle { + fn into_raw_handle(self) -> RawHandle { + self.0.into_raw_handle() + } +} + +impl Handle { + /// Create an owned handle to the given file. + /// + /// When the returned handle is dropped, the file is closed. + /// + /// Note that if the given file represents a handle to a directory, then + /// it is generally required that it have been opened with the + /// [`FILE_FLAG_BACKUP_SEMANTICS`] flag in order to use it in various + /// calls such as `information` or `typ`. To have this done automatically + /// for you, use the `from_path_any` constructor. + /// + /// [`FILE_FLAG_BACKUP_SEMANTICS`]: https://docs.microsoft.com/en-us/windows/desktop/api/FileAPI/nf-fileapi-createfilea + pub fn from_file(file: File) -> Handle { + Handle(file) + } + + /// Open a file to the given file path, and return an owned handle to that + /// file. + /// + /// When the returned handle is dropped, the file is closed. + /// + /// If there was a problem opening the file, then the corresponding error + /// is returned. + pub fn from_path<P: AsRef<Path>>(path: P) -> io::Result<Handle> { + Ok(Handle::from_file(File::open(path)?)) + } + + /// Like `from_path`, but supports opening directory handles as well. + /// + /// If you use `from_path` on a directory, then subsequent queries using + /// that handle will fail. + pub fn from_path_any<P: AsRef<Path>>(path: P) -> io::Result<Handle> { + use std::fs::OpenOptions; + use std::os::windows::fs::OpenOptionsExt; + use winapi::um::winbase::FILE_FLAG_BACKUP_SEMANTICS; + + let file = OpenOptions::new() + .read(true) + .custom_flags(FILE_FLAG_BACKUP_SEMANTICS) + .open(path)?; + Ok(Handle::from_file(file)) + } + + /// Return this handle as a standard `File` reference. + pub fn as_file(&self) -> &File { + &self.0 + } + + /// Return this handle as a standard `File` mutable reference. + pub fn as_file_mut(&mut self) -> &mut File { + &mut self.0 + } +} + +/// Represents a borrowed and valid Windows handle to a file-like object, such +/// as stdin/stdout/stderr or an actual file. +/// +/// When a borrowed handle is dropped, then the underlying raw handle is +/// **not** closed. To get an owned handle, use `Handle`. +#[derive(Debug)] +pub struct HandleRef(HandleRefInner); + +/// The representation of a HandleRef, on which we define a custom Drop impl +/// that avoids closing the underlying raw handle. +#[derive(Debug)] +struct HandleRefInner(Option<File>); + +impl Drop for HandleRefInner { + fn drop(&mut self) { + self.0.take().unwrap().into_raw_handle(); + } +} + +impl AsRawHandle for HandleRef { + fn as_raw_handle(&self) -> RawHandle { + self.as_file().as_raw_handle() + } +} + +impl Clone for HandleRef { + fn clone(&self) -> HandleRef { + unsafe { HandleRef::from_raw_handle(self.as_raw_handle()) } + } +} + +impl HandleRef { + /// Create a borrowed handle to stdin. + /// + /// When the returned handle is dropped, stdin is not closed. + pub fn stdin() -> HandleRef { + unsafe { HandleRef::from_raw_handle(io::stdin().as_raw_handle()) } + } + + /// Create a handle to stdout. + /// + /// When the returned handle is dropped, stdout is not closed. + pub fn stdout() -> HandleRef { + unsafe { HandleRef::from_raw_handle(io::stdout().as_raw_handle()) } + } + + /// Create a handle to stderr. + /// + /// When the returned handle is dropped, stderr is not closed. + pub fn stderr() -> HandleRef { + unsafe { HandleRef::from_raw_handle(io::stderr().as_raw_handle()) } + } + + /// Create a borrowed handle to the given file. + /// + /// When the returned handle is dropped, the file is not closed. + pub fn from_file(file: &File) -> HandleRef { + unsafe { HandleRef::from_raw_handle(file.as_raw_handle()) } + } + + /// Create a borrowed handle from the given raw handle. + /// + /// Note that unlike the `FromRawHandle` trait, this constructor does + /// **not** consume ownership of the given handle. That is, when the + /// borrowed handle created by this constructor is dropped, the underlying + /// handle will not be closed. + /// + /// # Safety + /// + /// This is unsafe because there is no guarantee that the given raw handle + /// is a valid handle. The caller must ensure this is true before invoking + /// this constructor. + pub unsafe fn from_raw_handle(handle: RawHandle) -> HandleRef { + HandleRef(HandleRefInner(Some(File::from_raw_handle(handle)))) + } + + /// Return this handle as a standard `File` reference. + pub fn as_file(&self) -> &File { + (self.0).0.as_ref().unwrap() + } + + /// Return this handle as a standard `File` mutable reference. + pub fn as_file_mut(&mut self) -> &mut File { + (self.0).0.as_mut().unwrap() + } +} + +/// Construct borrowed and valid Windows handles from file-like objects. +pub trait AsHandleRef { + /// A borrowed handle that wraps the raw handle of the `Self` object. + fn as_handle_ref(&self) -> HandleRef; + + /// A convenience routine for extracting a `HandleRef` from `Self`, and + /// then extracting a raw handle from the `HandleRef`. + fn as_raw(&self) -> RawHandle { + self.as_handle_ref().as_raw_handle() + } +} + +impl<'a, T: AsHandleRef> AsHandleRef for &'a T { + fn as_handle_ref(&self) -> HandleRef { + (**self).as_handle_ref() + } +} + +impl AsHandleRef for Handle { + fn as_handle_ref(&self) -> HandleRef { + unsafe { HandleRef::from_raw_handle(self.as_raw_handle()) } + } +} + +impl AsHandleRef for HandleRef { + fn as_handle_ref(&self) -> HandleRef { + self.clone() + } +} + +impl AsHandleRef for File { + fn as_handle_ref(&self) -> HandleRef { + HandleRef::from_file(self) + } +} + +impl AsHandleRef for io::Stdin { + fn as_handle_ref(&self) -> HandleRef { + unsafe { HandleRef::from_raw_handle(self.as_raw_handle()) } + } +} + +impl AsHandleRef for io::Stdout { + fn as_handle_ref(&self) -> HandleRef { + unsafe { HandleRef::from_raw_handle(self.as_raw_handle()) } + } +} + +impl AsHandleRef for io::Stderr { + fn as_handle_ref(&self) -> HandleRef { + unsafe { HandleRef::from_raw_handle(self.as_raw_handle()) } + } +} + +impl AsHandleRef for process::ChildStdin { + fn as_handle_ref(&self) -> HandleRef { + unsafe { HandleRef::from_raw_handle(self.as_raw_handle()) } + } +} + +impl AsHandleRef for process::ChildStdout { + fn as_handle_ref(&self) -> HandleRef { + unsafe { HandleRef::from_raw_handle(self.as_raw_handle()) } + } +} + +impl AsHandleRef for process::ChildStderr { + fn as_handle_ref(&self) -> HandleRef { + unsafe { HandleRef::from_raw_handle(self.as_raw_handle()) } + } +} diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/.cargo-checksum.json b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/.cargo-checksum.json new file mode 100644 index 0000000..10b1852 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"a88605a11db5def9b6cf73398e83b3edb72228cb43ea935729fac5cd33cec22c","build.rs":"b4ab421e1dc98159dd4440813cdaf7d9ea98278324bc6118d0f7cf378933f371","lib/libwinapi_aclui.a":"276ddeb3f36f3bce5c1b65d6244c5d814ea6212a443023fd9f1755b815ab0183","lib/libwinapi_activeds.a":"f2a3162aafe48121cdd8f10092a5eec4ec1facba87f7a543e90f2fa79b8d5aa0","lib/libwinapi_advapi32.a":"61cea4489a1fd706ef7d8e67b836fd77b2d9d39167edba3a51fe4b0a3ead5640","lib/libwinapi_advpack.a":"d448fd3029b9bf1fed6da3259053abecc7481fe21392fd5218b61495e1bfa1bb","lib/libwinapi_amsi.a":"7549daec74980b0b0f5d9bd1b4f314433dc0ce0a170128a0c1aae6fc2526193d","lib/libwinapi_api-ms-win-net-isolation-l1-1-0.a":"1fe5ca42932d19191127555040e4ad2aa59636f9c17f9f3a3afaa1438cf9fdb3","lib/libwinapi_appmgmts.a":"7a4747e1d307d3b8bd50b1d0611c4f0454cf30bebee6de2bbd3e9bf3f66fcb2b","lib/libwinapi_appnotify.a":"b1a62c3d0a87866aded8f4bc3dd31cf52972a91f5c4bdb966f7b8a2432a50443","lib/libwinapi_audioeng.a":"73b5de7d57738e4067ceefea0cf654ae05e50a59d044461ccd5c79eb7feb6532","lib/libwinapi_authz.a":"adfe67282df67cd3a52d81407a98cc1ce8466d6b67bafa3a884b688b5624045d","lib/libwinapi_avifil32.a":"d80ede7f93091fe3670019291695183142eca029c4b2359b9b1d760803682554","lib/libwinapi_avrt.a":"246c2c6892823de74fb0dfc1ef889798d01e28f110498723a1b33120fa393d72","lib/libwinapi_basesrv.a":"73044d5e44b30581e91d6f3341ee98f99f0ed77d577a4210aa0e9f097e5f68b9","lib/libwinapi_bcrypt.a":"0c19e9a1b649b7226b6954948060edcdf4e4052e0f9e56c218a52b5d36014a99","lib/libwinapi_bluetoothapis.a":"f9178dc2281ca623497f7f83280c3a4d150fb8a55cf7d9efb0bc5c7d41d01ac2","lib/libwinapi_bthprops.a":"dd2aec07378487dc47ff1640b0c91458c90fd8991847c5bde3c97b2bedb801ef","lib/libwinapi_cabinet.a":"6ceb101c96c4bdc62be7362f45c62e9cf1469d5d81bd1bc282b2284b55855582","lib/libwinapi_certadm.a":"d3302510a8197ab0c513101c10cb92dc004f64c039843047bd382f96eb7edf6b","lib/libwinapi_certpoleng.a":"5081b94579847f972dd9549570ff12b78aef42ca10f90981d3de886fa7f0cafa","lib/libwinapi_cfgmgr32.a":"3b18b12d0bbe4e5bc3ef7683beb3fda64b32f459f8dbc78f44a40233e694b2be","lib/libwinapi_chakrart.a":"f1936dfcbd3357255735ca59df3c076a55a676abb9f1a883e0500fef36f26842","lib/libwinapi_cldapi.a":"985226ad1768a637d0ed6b4b868617033d655f1bcac8a0d6e0fd43e3c7f4977d","lib/libwinapi_clfsw32.a":"14a16bacc58aedd81521aa1b2902814cbe335b148662a58f859c520470ed7626","lib/libwinapi_clusapi.a":"dd4f925f888246934353bc109df338f545e5e79e7114fcd7d4b5ba98d39f7f83","lib/libwinapi_comctl32.a":"21b6ebe43ffe405d6be881741423d04e1b5d76c264fea3a131652be307ce17e6","lib/libwinapi_comdlg32.a":"62009b40ffcf2fcc5c4ba0f43922c6c386ccdc42db09c7fa598fe72330a44f1b","lib/libwinapi_comppkgsup.a":"fbea5db62858b6abe5411c9ef5f1ca87876807bb18d10db2cdccca4d0f8989db","lib/libwinapi_compstui.a":"71c05683ff02d0d1963ac72e9e22a1c21e72dc3e8465bd5d6f0d01fea2237b3f","lib/libwinapi_comsvcs.a":"a685111c8104c2c4c4dc20475c3c30e6d1e1ece855b2d35631a3ffe42ed8b2b3","lib/libwinapi_coremessaging.a":"467d27a2c2f3268ae91d37e825d3d54cea24212265c7b6011b3b38002074d459","lib/libwinapi_credui.a":"b965b731004fafe74539c0c9c4f8966ffdf856bf24b5dd584a5e9fe6e0dee7fa","lib/libwinapi_crypt32.a":"d12a2c398e5fa6fb366f768ab11d2e0b5e06ac3c0a5237dc822f291d2ca2e540","lib/libwinapi_cryptdll.a":"29d24bd4ee508988ff5839ded74e41b1849fb24383b45efb308eab935979888c","lib/libwinapi_cryptnet.a":"292ed55e95c5487af424aaf81c8b66f6f007fd3adbef2b85e66e687d1ab4628e","lib/libwinapi_cryptui.a":"c8dd855f6c16395b122eea8f1144e52837e49fc7887fdfe86cd29cbd34133f3b","lib/libwinapi_cryptxml.a":"0454ab761f153936ee26ea36013bdf0612c9b44449d617ee0bffd7b5ec9006b3","lib/libwinapi_cscapi.a":"b0cf26d0ee575dfdb761244e9e0b1b5255a8a56716c2eb01d4a0428709eff88e","lib/libwinapi_cscdll.a":"faa2988a37bf527a964c1772901de933660824bfd13fbe428a0eaa3a5f7cfb4a","lib/libwinapi_d2d1.a":"542b8de881286d507bf96791b68fa94a9529734e891e78dd839aeafc77373fb6","lib/libwinapi_d3d10.a":"287e4ab2b679444dae0254f047a7d2ac326d4110e72a603c0223ccb1a6b97ad9","lib/libwinapi_d3d10_1.a":"95141cf53dce108d49e60728740fa9f32be925bb3f5c07fea1b3e134870d090a","lib/libwinapi_d3d11.a":"792513e2b6829c7a003c24612b8c6440d90fc3dafea80cc0bf4782c0050131df","lib/libwinapi_d3d12.a":"d86f53d148ba6f7fc35518706ea9e8bafc63c39e9ab6bb65790ed1f413bbfaf5","lib/libwinapi_d3d9.a":"e9ddfdb0f0962d18fe6dccc1d6d5d6d1fd2cdcd9b3f070b98af23e6bafc66670","lib/libwinapi_d3dcompiler.a":"a945ee212af78ce62089be910300d251e3b29c52daabe7a5588e5ef87b3c01b4","lib/libwinapi_d3dcsx.a":"60f643b18f4f918c417f4f7258ee4c0dc4a359152952e0d98dd9de344b0d7480","lib/libwinapi_d3dcsxd.a":"062715028b50b17bed4fa0d7c5258f813b19fe09155f9fb3589e55b6c587fb01","lib/libwinapi_davclnt.a":"a050ad2a4c81336bbddc606e4be755c69ffea0dc37aeca118f03155b18d1fbec","lib/libwinapi_dbgeng.a":"4ea8c7e5caf3f437636c7c30df9760d7778646e482047afeed952de0f0c57398","lib/libwinapi_dbghelp.a":"430c90a39ebca43ef942d1794b542df388d0efb7b83793ec5f992feba2af3bed","lib/libwinapi_dciman32.a":"d0d4e849fb3ddc991a7e85d48089860a04d38365d7eb3e78c21fa1a4b386bc13","lib/libwinapi_dcomp.a":"d3c9ca747f96c899880b33b6bd58e3ad288f6e0c069d8cc97429178d841d9555","lib/libwinapi_ddraw.a":"dce5230d762bbd5e9ee997965187219893136cd7c0c800333284b3ad1c317ae5","lib/libwinapi_deviceaccess.a":"7f6ec4878c7d5294c28f9254258596b98722ac859618883a80817c4d7057740d","lib/libwinapi_devmgr.a":"0faf91b6fbdd85be3403477dfed36072ed0525543d4b8d9ed6a7b68a1f7fbb77","lib/libwinapi_dflayout.a":"82690fd574097cc7717707c3b6ed30317f326a906acde16004430265d1985d81","lib/libwinapi_dhcpcsvc.a":"20b578bc8abafd130d53145608d1daccf4c128fd7fba4cc58d815a1dfc2b1ac6","lib/libwinapi_dhcpcsvc6.a":"c620c2ab946015c9cd2a8e4fdad3d40bb70fbd765d12fe0ec14de932d80631b2","lib/libwinapi_dhcpsapi.a":"5408133e6e424729f957755ff13b0fd032998ad4e6eccf03ae3ab8795b21862a","lib/libwinapi_difxapi.a":"5944ce1a74924fbfbc6f15aa8832e1e3583f9f0bfa3cb37daa23ae001e9d9aee","lib/libwinapi_dinput8.a":"809cc0fd5bb0395cf9688e4bf72471c60df69c707cbb0f0ca2d76a347c292b5d","lib/libwinapi_dmprocessxmlfiltered.a":"02bbdef0b20fd01f80e53d64ffb7fe7ff1162134ab8032394b5a1ee4ea673e36","lib/libwinapi_dnsapi.a":"206041acf0e47cbbc1a9966d1e39cea349f3681edea8391c8b8bc59683144249","lib/libwinapi_dnsperf.a":"b79b560261e6d314cc5d8f4bed92ba3df4a8154ab0f720c9aaa8a21880b5d25e","lib/libwinapi_dnsrslvr.a":"6c22ba18a82dcc9abe3acb084481da21087203dce52ac90a6908198f9f782148","lib/libwinapi_dpx.a":"1d0705704952e7f3b482f14520f1ee9e0ca0241bff565f90c595a2a3b95c5b8b","lib/libwinapi_drt.a":"9c7a21f7b4d7b1cfb113d3bd8ca6070f6087727102b5ed02488bcf457cb66a26","lib/libwinapi_drtprov.a":"21fbb117f8d5ae07ce008e72b263461103ec3e94bfecff343ef68cdefdd17d12","lib/libwinapi_drttransport.a":"c3219661e16a06b0a7236cbcdb29f2dce052f404bd171713566a95b9185e34b8","lib/libwinapi_dsound.a":"971f74621612a1e7bfa746502732d5a744ced5fa9ccdb696ebfb9502b3c19141","lib/libwinapi_dsprop.a":"fee99d28a0831bfcab736c62b5ec94ef0b007088865074a9a0989bbb7186fc32","lib/libwinapi_dssec.a":"bddb5274732250390e746874ea74a8aa5088a62eb092d68d71966f7e476f27af","lib/libwinapi_dststlog.a":"4da2f1146cd9882f7e96c1e534b46f8c458480fad5fcb9d1c067d4dda218d04c","lib/libwinapi_dsuiext.a":"6ee8892083f731bee1e8f233bb58a43e5329252625435305a1d27bd6d8b0b900","lib/libwinapi_dwmapi.a":"d55cbdecc52c5051616383fb037ad0fd09947a5f45d1522cea2c443e3affbe4d","lib/libwinapi_dwrite.a":"ac3c297df0e44ecd5123d47a997bc5f2de73934d9808a429132c0f1cf299feba","lib/libwinapi_dxgi.a":"91ad18a2778be45cdcf701d357b32224879432da3f32d14f8717fc238ce2d02b","lib/libwinapi_dxva2.a":"34aa513c106f1deda9f71795ebaecfc01bb800b41993846a0503691c0acc3739","lib/libwinapi_eappcfg.a":"2b7cbebd80a61019356e7168fa57c68dbc5633ffdf3f566593d54b14104d637d","lib/libwinapi_eappprxy.a":"86f2289e79ffa1509ce41293bee75785851d87be7e657126e497c1c9d9a52005","lib/libwinapi_easregprov.a":"be44f53e21b54075aa3b24a45481eccf24219f6991d4551e41e3dd97538b862a","lib/libwinapi_efswrt.a":"5394eea8d86fc66f4df8cd5a8675ddaa39954164d89b7d9c96fd48a43dfd84b9","lib/libwinapi_elscore.a":"46a1f20b5e0616af5b8dc0a7f8db8aa837ea32fe4f8118016d6a2a10f15852c6","lib/libwinapi_esent.a":"e5fa9fd1095dc6c3980191f7665523e72c421e443a474500f41f8403402bf208","lib/libwinapi_evr.a":"b29f7e7997e8bfadcc81d247c2032381f21897d0a2a5ad0304e84945f7e913b2","lib/libwinapi_faultrep.a":"d332eeac469e87925e44ee9ed41408196e87ed1f8972e81540a19f20b1485102","lib/libwinapi_feclient.a":"9abe648543524e3a6024a63a454f7d36b6758d2fc5994efb4b9a513e06348041","lib/libwinapi_fhsvcctl.a":"8f26fdf62798fc19f0aa118e9887c4f5fd715b3505df723cdf87c9341d6600de","lib/libwinapi_fltlib.a":"0681ffdc1f4e87810dbfd664dcaf50592c96b07b9935bc49342982ed90b26a1f","lib/libwinapi_fontsub.a":"07676e49f5a46143fb9c5183e1177cac26c709db1daffc839a36fc72d32e9760","lib/libwinapi_framedyd.a":"cb13a8b7974bb247d497f56f1322a9d9926bfa7b0d3f083a323415e6f78704ab","lib/libwinapi_framedyn.a":"38ad80dd8f8b3fc5d881dc24ae6ae58bf641b3bc24702d205d7a1a8769d89c83","lib/libwinapi_fwpuclnt.a":"bf9d1fe3fe94b35d019ca51e30b0c3b4df085f7ec1a8626c917a4e07eb1bd887","lib/libwinapi_fxsutility.a":"4d2baf6d2d794039e34d07b876afab8963c7847fb90dc8b00150e699a5a88350","lib/libwinapi_gdi32.a":"2b3a916c16e4f91a2cd09386a52c2824bdc4d651166644d72ef5c85c767e6c10","lib/libwinapi_gdiplus.a":"9b1fee0f9f1b6237d0d62fd121e6a6dbf9e37de5690e84e9d41a1c27faee9867","lib/libwinapi_glmf32.a":"d3124a868592e0c37a9beb8e2b6c7b3d2b94c07ae687289a6f0669132072119c","lib/libwinapi_glu32.a":"ddb53f0d0c5f4c2d411e9fded6ae8e0be2b8f9a8a1c5962806f46e9ec03e70df","lib/libwinapi_gpedit.a":"d34919000fefbb37c6f6168fed15261506b6bbc025cb195fa5420f2257c3d4c7","lib/libwinapi_hbaapi.a":"a33dfefc4280c5e0e2b8b57a3ad3266a37bad1a2cef18a308d9f6378e76751b0","lib/libwinapi_hid.a":"6f15a85717f22156e2fb9b208beca41d1c10f90a77f85a54373ad8eee9cd0e2b","lib/libwinapi_hlink.a":"5ee9abfba000d2330a8b8eecbe7264e6a75eaa769314e509d87263574fabdf10","lib/libwinapi_hrtfapo.a":"5fc399db01ea1c885f967666ec3bf784be0ca743207863f4741973b1c57a734d","lib/libwinapi_httpapi.a":"01011dc404f7c79d1dda41cc07cf61a4aeedd4bdc5d7c5e9951a48fe263a169a","lib/libwinapi_iashlpr.a":"a3f8e4a9e57bc6c4ee9b2648e810b495b6d91b9a65388c9be203e44295a52364","lib/libwinapi_icm32.a":"38f11c45477be5e7a9db97803c777be7e897f624a038ee0aa963fb94b585b767","lib/libwinapi_icmui.a":"e44009b1e129de72112e85c305c07c97891590513427866eaebeef000686dcb5","lib/libwinapi_icuin.a":"8f8e4211c97344c7e18b2dc916311be77fdd2f57277d84d66e2fc747134da2a4","lib/libwinapi_icuuc.a":"6673008d48e04f68995c9312417693a97df0f509e06771e5f8fe463526a2ead5","lib/libwinapi_imagehlp.a":"a809cff5d98cbedef8a5c6c7e42f38d3c7dfc8c11d6a9faee124315aa59018b4","lib/libwinapi_imgutil.a":"cfb14abb38c53b4260c38984aadf719f47a1bec9ef649d8a27c3a7ef0c0242f3","lib/libwinapi_imm32.a":"f26dda47a3459748d872bd930aec687840a8d13b7f4831e05a4416e7333960af","lib/libwinapi_infocardapi.a":"1856c6b82964e75147dee0e9f44f7a212cf7352bf99e34d7be3ba9e889e96061","lib/libwinapi_inkobjcore.a":"136437815a0ea7de686880b3dc93c9f15acb99df63017b50c1b6b131d6fbf1e5","lib/libwinapi_inseng.a":"41df87d43fcdf2273da7fe5bb1a569d016b4bff77b1be9b18a0805230df77a2a","lib/libwinapi_iphlpapi.a":"2fd06dd2698d0943b0395ac431ae48df4317503ac8d1c35e127cb498ac6365df","lib/libwinapi_iprop.a":"cdae05efccc1fb56df272f9b4368db1943e23f299fdefa106fd8522c33935a2b","lib/libwinapi_irprops.a":"ca9d940ec3e8d4a15cf3650fa76665f7037fa9c1019c4eada59c867057c8c972","lib/libwinapi_iscsidsc.a":"12ffbd3ff5b6fa6e35dbed15920f9ee71a844b974c04752220585a4c69af4bc4","lib/libwinapi_jsrt.a":"d84cd2be85df653a0ebc2160559a955e9ff565989ea2d4916f1fabee4b96177b","lib/libwinapi_kernel32.a":"95d9ea840920496d039eab257c28b8ade71088d3f4a57aaf038207055231fc9a","lib/libwinapi_ksproxy.a":"1e5bf114bcab137b6c40b779509fe0db92b31456ec6a5f52df14d029ff53047e","lib/libwinapi_ksuser.a":"c0e457ec782e0ee328b26e84d4aadcec7a4764eff69311788820352b11a4a340","lib/libwinapi_ktmw32.a":"d500f383a098291825867758d7c6a00334ceb9aa5497894fce4532aa91405f6a","lib/libwinapi_loadperf.a":"82d539c5665e285f6842b282f872a73408cbe34e251a7c650864c0a1dafd6d69","lib/libwinapi_lz32.a":"359d76f02d09f9edc08322b2121dd683d2478ef696d861802797e46e0e213095","lib/libwinapi_magnification.a":"780c596bba6a4662eed52ccd123316d4d5c06ffb906f483aa8a3440cd50b7bc0","lib/libwinapi_mapi32.a":"287653cfedaf4d85e34de3ccf8f42297d02e8ff53407750d82efd6d264661188","lib/libwinapi_mciole32.a":"a7f54b102fd8e249be177c0afef73245a2ff750a6ba096b7fe51c5611f88fcba","lib/libwinapi_mdmlocalmanagement.a":"aa0cc66939649aacd882ca1263c778fb14b7779f6d2d0182d1a6519d3b7cd9ca","lib/libwinapi_mdmregistration.a":"8e51628bbae7b499509b45b72666b3a7593e00924aed10a4532f08529b19a958","lib/libwinapi_mf.a":"680d1931e07461ab845c17b126f59897c31d68bdb929e3d85cca347f5d5412f3","lib/libwinapi_mfcore.a":"2b20dc1c73b1a7e3f69b1ff003ed7147a58f3469911b25b2124ce9c64c9c8719","lib/libwinapi_mfplat.a":"986fefa67121059fb0e94f9dbea92641cf7bdd168e4a1d6aa99fef6d398c2c5e","lib/libwinapi_mfplay.a":"2570b1aae5f1e4f1f5354ffc14e63b164036c07814ea4d5c7dcd077e7901183c","lib/libwinapi_mfreadwrite.a":"11d82e73075a6c7eb134dc9007b082a98c66ed4e47b7afa48de2ee14b2862ae9","lib/libwinapi_mfsensorgroup.a":"517e80d135e00bfb906ce0836a1ef6a20d7dda394f07658f033b3aa9c60034eb","lib/libwinapi_mfsrcsnk.a":"510a26b17eaca78752fad354028568bfaa6aef06f77a1cdadfb425a785f5ed33","lib/libwinapi_mgmtapi.a":"982226ffd60eae1231da0ebd8bbe6178de804554a76c32777f75820113d137a2","lib/libwinapi_mi.a":"dfa3d4f68e432b3f1601fabc3425ec5d97c3afff14177721122d6444d34caced","lib/libwinapi_mincore-api-ms-win-core-com-l1-1-0.a":"76485df97f6a262297e42b7da5e4e0d8f4909d35c170e202454a1c60b7476c2f","lib/libwinapi_mincore-api-ms-win-core-com-l1-1-1.a":"ce95bce7429e6f6438ca9796350761679985297870763366bd24a7481742cd11","lib/libwinapi_mincore-api-ms-win-core-com-l1-1-2.a":"dc4ee3eee502ebb86eb6f254b1e8b9054b9ed4f8e10183f1c8279289ff67f528","lib/libwinapi_mincore-api-ms-win-core-com-midlproxystub-l1-1-0.a":"115f4ee281b2ec9b44c2c7d9ee36404a319324825acdd839a95bd5827e15672f","lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-0.a":"11da992cddf9437b7962f503392cdbc324a015a4eb339462ffe490424a290e59","lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-1.a":"d0ed125830b0d1f10d897d1ec50da10c5f9b2fc7add84c6eeb225eb604cb6292","lib/libwinapi_mincore-api-ms-win-core-console-l1-1-0.a":"d4083302dacd0bae7f3ad447e67277d537647df23ddf44a399fe327f430793b6","lib/libwinapi_mincore-api-ms-win-core-console-l2-1-0.a":"495cb87554da1f912c999261f5be4cddfa3e0b8af8669625d1ed3e9625d26eb7","lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-0.a":"131bcd3b2e44bc48d739b78a6a2c162d86b4db93423ec58163ca8ebf0f4b1127","lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-1.a":"16c8fedfa7b80e8208b99538e439d6b77348668560241978842b65fa820a18d9","lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-2.a":"af6dc27b8170b4b05ccb15734310c6a0c5eed201e86e2bbc6772ac9e215efb8b","lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-0.a":"55ed7347bf664967590340f71d6bc0cc8387fe76a056a809a2942410c0d5a747","lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-1.a":"3a4f57fbd03af27049b080f6845acfac07e3c3c7bed85abfee1a3d5b9fe2a762","lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-2.a":"b225bb3ce5569915eb0a263069ba085bfaeaf45c470f04288b41f9f8521617c6","lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-0.a":"d81c5c1dc60979c59b7eff1b223055295343cf3845d2a0517e17035a14dd0880","lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-1.a":"e7bbb5f9e98f85df4db9b7aeec6039c481d039c7a268ad5923c5810673c4ca69","lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-0.a":"f10fc3c99ecbb414a1d5389b9f3d3a340f0496500914678b11565003a882fb7e","lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-1.a":"ddd872dd19a575e3dbd8ec25b2b34c2951ccfcdd61b38427126cf0a65f4a0cb4","lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-2.a":"7d599b936357f4ac8f38582874345ed12215252f359988c751cc60cd32a8db17","lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-3.a":"337ffa10980babe0b17cfb17f4e44c1d243d4483ed8cac16bdbc213a99e2373e","lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-0.a":"fe878234568e92961e718322c3c081e3c0989eeafd6e5b0ee545bfc68eb81d44","lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-1.a":"e24ca6fd32df62cf49a7a8d616c350b344c22a0c8cb6d8627c675f201f4d9904","lib/libwinapi_mincore-api-ms-win-core-file-l1-1-0.a":"a97938a9e8f5eaa5b6fb2f489f93bb4f4fc58871f2d8d6269e14e19a337a53fb","lib/libwinapi_mincore-api-ms-win-core-file-l1-2-0.a":"37f05a0469dfe19cff5ece1406f4e959a063a981440cfcf3a5916e17a4e382dd","lib/libwinapi_mincore-api-ms-win-core-file-l1-2-1.a":"3569117f29b0d08505df253e61c0fcee12cf5b12177793a32e7af80d2d56a2f4","lib/libwinapi_mincore-api-ms-win-core-file-l1-2-2.a":"68d39750dc408b28594269d5d6ec80a5984dee8ae001b1b025002bd84e770085","lib/libwinapi_mincore-api-ms-win-core-file-l2-1-0.a":"207be2f5cdbedd2fcf0e6e67b5680adcc32b8e9117837716dbce43aa5ca4b165","lib/libwinapi_mincore-api-ms-win-core-file-l2-1-1.a":"ae5feb37150c28b3c344c0d395be86a28a484f4acd0b496ce183bcdcbf1eec0e","lib/libwinapi_mincore-api-ms-win-core-file-l2-1-2.a":"b494cb791848ece954b1972e99e530b2ad48b4b0a4d05cba7b77bd2beff46096","lib/libwinapi_mincore-api-ms-win-core-file-l2-1-3.a":"c5bee07c3af2b8a191caa6c95fd047f2081b701c3a32fcb60e979c83f8a83fa8","lib/libwinapi_mincore-api-ms-win-core-firmware-l1-1-0.a":"d37f2e483f7ce07ea1f13da2bd6d11fd90b3d6e74b2eab16dd6675701d925dec","lib/libwinapi_mincore-api-ms-win-core-handle-l1-1-0.a":"4e4db210d18e80f5eab092933076a52378240696125d7e438555286fbea7bfa1","lib/libwinapi_mincore-api-ms-win-core-heap-l1-1-0.a":"a63ce183e48c98a1f03eb7e81d49431567e6a9e1434b950390038cd86d0c58ca","lib/libwinapi_mincore-api-ms-win-core-heap-l2-1-0.a":"d37b86d396eed705ff66ca7a15b9790cc771cca3781f9afe30595556b5b2e516","lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-1-0.a":"ee2d2f445d8340bb7079a9a0ebfac3e776350bf06714b04d2d71f44f39c31ee5","lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-2-0.a":"20a24186dcf33096ba39ecaa06144e16fa8e13508c4070fe2f4787e02a10b678","lib/libwinapi_mincore-api-ms-win-core-io-l1-1-0.a":"1a7e2901d936cfb930c10b5bd01e1cb174e155d63e389b9d0f93a67fe7767e7f","lib/libwinapi_mincore-api-ms-win-core-io-l1-1-1.a":"c2031a37160d4cc6cd10c7a1bb146242bd97bede479e38591514ca28f1c34052","lib/libwinapi_mincore-api-ms-win-core-job-l1-1-0.a":"2c6e24c3f21548b2a672cababc065f49dd6e8c77f5ca9c0931ea3cb842dffe2f","lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-0.a":"de5b19aad7597b6ff8676d50cb57080a96314aa4a57e483b470fe27fcdc467a2","lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-1.a":"0b082aa3bd4acbfdc92b698512b102d4e0f90e5d1853da62d0acf74fdb5b672c","lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-2.a":"5989b4597e769277940c2f6c0492753c09c12292b28c932cfb5aba5f4fb24faa","lib/libwinapi_mincore-api-ms-win-core-libraryloader-l2-1-0.a":"074fcc7d7d03cf010f4c536a97447b2ea8b20d709b1001270cbea88240e43624","lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-0.a":"25ffcd1067b026bccfafedf7d20505eec04632eb6af16698bfda0b7b62f93d9e","lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-1.a":"9b2d7399e10336891b842516659ddc64a8d3d56ba014b5695c71c432d1d33d8c","lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-2.a":"fedcced3e72d1353f075d4be8ec105b6860dca592c181ab240288fcb8595e0c0","lib/libwinapi_mincore-api-ms-win-core-localization-l2-1-0.a":"bf89dd69e8c7b6606b6b2978fcbedff972984423912489c955a2bd16ec421bc1","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-0.a":"b2e414d41d55a770b1ee5510f26e49658acde1a905da2699828d74e70f1a0911","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-1.a":"d8bd0584274bab01eafde0a2d345c795733f4f02687ba57c7732a796f6c615e1","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-2.a":"72048537dc3a79da7c288b317d1aada14a94b0c0ed81949b2a847265da04d68c","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-3.a":"c88dbc65f56198c6fb8b13dde3d831731c19062594ecc76d64ebd6519eaddb91","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-4.a":"503ab8fb1df38b8c92af9084bc04970b96210820f8453a4f0a8c393dad6648fe","lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-5.a":"7092d745039c3614851ee3be3f3515104cd868d1135bfaeef67f3ae29d400ced","lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-1-0.a":"5a16f49d70f33f4a199722985ce6e006c9a7272865f12ddad38b4624c4939326","lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-1.a":"e7bee4535d9795e94a9acd93e70a771774f827c0bcc277b7363558a02243159c","lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-2.a":"df7e86061d0cb4f6564f0f7c0d6ecb41d3b1b37ff41804c3a340ba3046b0099a","lib/libwinapi_mincore-api-ms-win-core-namespace-l1-1-0.a":"8970229a62f4132de23f5801940eba485dfdd1809546cebe7a18d7c0184c48ac","lib/libwinapi_mincore-api-ms-win-core-path-l1-1-0.a":"91b50dd2d0c32a1aaf298f893cad0cdfb6685e20fba44dea649b89c50ed4c9a6","lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-1-0.a":"3e59f3ae56977fca3e452d1c7077fbd79ba4618378d6b3f6338670da2264b318","lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-2-0.a":"ba69dcc28276bc983a1bd59feda56528408c79fe18b2bc2f7245e2fbc3e8d75a","lib/libwinapi_mincore-api-ms-win-core-processsnapshot-l1-1-0.a":"bb0e5002cbce0a6cad7a0af82f456acfef3a7573de25ab4f2c76360185e1371a","lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-0.a":"77067e3e43fb1db6d711b01c3ca6ee076a0ef87d96409ddba4be9732723cc2ba","lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-1.a":"2c2e7b7ce85816c7974f605510cafc16ec3500876b490da4f462dcc967c6ad40","lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-2.a":"af21a90245d69e44b82b66857797168b206b282a1e54cda6ca8cdd6e0c64912a","lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-3.a":"a364ce3355f5c3a2719e3ecbe42f5b0e9e0d6b87146f7c762bd6752f0f3c9534","lib/libwinapi_mincore-api-ms-win-core-processtopology-l1-1-0.a":"9fdde1b7df00b8677e2f2978ceca2b9ef3e1539756f48fa5ed527c3d3229937b","lib/libwinapi_mincore-api-ms-win-core-profile-l1-1-0.a":"a9b8f92be12fc12ab7f278c5751dfbafe8a1c6c70b8a7895c601bcde27a49e4b","lib/libwinapi_mincore-api-ms-win-core-psapi-l1-1-0.a":"28af76aedcbe8e5d2fb1e3d71cb401381a3400bb802d0f61137509ddab50ceea","lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-0.a":"1a3d2f2a9cf9c43d2425b0200ec3985f3e411a89f90778beedeeacb7edb0929e","lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-1.a":"4f15f699337cd42650bd16f8503984aedb70a3f1ba581c0e131a6f798f3968c9","lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-0.a":"2602a72063a047c5767aa1d20248d701b81ce3ccde8c4ef07a6a107a9c3de9af","lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-1.a":"3a06e02a57871cb36caecfb78fd4139ca851b66474ca5bfb5b3b2a6037682d29","lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-2.a":"7faf55c7bb4c862a269bd5fe2be72c8858dd54b5b949399beb2892d7d4f891f9","lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-0.a":"798c2464d813e306d061741351a2a56f570b8e363e550223f62be1c1608cffe8","lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-1.a":"d165ef00b715eba2a96248ce2aab275d39c7d5c927c71fc2bc70cebed43b85f7","lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-2.a":"92115b5933781d78b2d615b141732a6b8ef08a084bb97010aa844f75058ec465","lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-1-0.a":"25d6790ed18e0921a38c57e1e390152a24f709e121b9b7296153720f2306e523","lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-2-0.a":"2b3ef6c250e8be66cfb026436bff96f4c3ab04d9b8970fbf19cda9d24cd53889","lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-0.a":"b549a555192a445540c93480d7c547fab359fcbb49254b75b58a6b624194d526","lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-1.a":"c68db7f4c33cabd2818d0d1b47167672b1ee612ea70e0a88726f818b5f75a537","lib/libwinapi_mincore-api-ms-win-core-string-l1-1-0.a":"e6c31d64254c944e35513b540a525cefaf4b58665d6909a8e8964415453be06c","lib/libwinapi_mincore-api-ms-win-core-string-l2-1-0.a":"b218af872027015c5848985f7fb9cc6ede8cbb5451e85aaf8c51744a3acf2439","lib/libwinapi_mincore-api-ms-win-core-string-l2-1-1.a":"3c7be7fc72f0e3c21668c3ea854f2d097bc8c9e2f1592ab81480e03b17fd9649","lib/libwinapi_mincore-api-ms-win-core-synch-l1-1-0.a":"3662cf22a2ff4e0be5e95d7aea716ad92f5ffbc3d241556353658995885e2729","lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-0.a":"ec56d87919192c2aa2c3babe67c2dae04afa31075ba3e89bc3941c00ac3280bf","lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-1.a":"a6583348b7e00a8b291a70c17f5290251e43c8741937b134f8fd3a56460ef88c","lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-1-0.a":"bbdd30605debb51d2f2d94688716024e5d75770500205f566080006a5d556ca4","lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-0.a":"9ae56c06c30361106526eeea1d5db47082b838cacaf8b54d46c285bbc4b6e6e6","lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-1.a":"0349a394597567544c5ea204ed880b54861f2760876e2ccda4176900c8a8352b","lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-2.a":"ee54a2da3a078b1d1332b1ec5a1a053e816f7a3b6ace3c01f508282e985f5c67","lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-3.a":"0d2db7aaf08e283c04022b23d616e39f9403d7886af8ddddc02597ca3bdf42b2","lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-0.a":"c7befe692a33c5c2c3e1f273ba2513f649502b93012ea6da895131f8eb648f8b","lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-1.a":"d441a2feb8334a5680a8d5d354fc5a69aa63d89623d1be13f4ff600cb93dbf9c","lib/libwinapi_mincore-api-ms-win-core-threadpool-l1-2-0.a":"beaf292dd62a83315423fd580d057adec9b78aa3ba5ee08e35e9e785d0297ddd","lib/libwinapi_mincore-api-ms-win-core-timezone-l1-1-0.a":"775a51aa310c249d057df10cf67a05a85246a0be6df6e2889b64d640ab811d6b","lib/libwinapi_mincore-api-ms-win-core-util-l1-1-0.a":"5d3fbb17a4fb24d10279ebb137d11ec31b1fc3a6dc0e830bcd44e73330dfa92b","lib/libwinapi_mincore-api-ms-win-core-util-l1-1-1.a":"4885b71ff3c5fa95eca7a29bc0f4a9261ee57eb77c9b5a21705a394a6b888cb7","lib/libwinapi_mincore-api-ms-win-core-version-l1-1-0.a":"575b5e9d97ccbc3c4dac43496d6753209f5ee20103ff7c52c107a65236c174f9","lib/libwinapi_mincore-api-ms-win-core-version-l1-1-1.a":"1796148f6e9724cb3d4059b8b79f22f901de240bc460057250a3f4dd62cf450e","lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-0.a":"f6c9542def9f9be896602499debd7debb72808bc41e6c735ef189b29e0cac421","lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-1.a":"464f39672be5e9ecc1a95e9074a46bb3d1beb1abdf6cc4e705e95ac656bcd027","lib/libwinapi_mincore-api-ms-win-core-winrt-l1-1-0.a":"a0c9ea99fd5fda8a20591f2c88cf8eb52733be1520da706c636c08883578854a","lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-0.a":"b5bed34136bdd91e155dd0b347321ef8c9189544cf5dd94f93fce3092ae8d4c9","lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-1.a":"7426f42dd85d665bea5fc7bc7c1433d8005468902f8608b6b9ea8cb0698e2c3b","lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-0.a":"1f7b9a3be312c964092aab8b85f2241e348ffae828447be09804fa35f040770d","lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-1.a":"7133822afea480f54c3b6ce36cc000cff40bc50ee25c292711c14d0dd48dda30","lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-2.a":"02a87ebca8f6206f65e958ddeafb020672cb7c68d907098e056df0ac48ccb5ef","lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-0.a":"cdae8ce3826b8e94e76f3948eb386feb4145113d3c84d5159efc2aebb49a3822","lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-1.a":"b494ac0d24d2da51a6bebf16be7823e09952a3fc4beb60faed04d853304429af","lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-2.a":"90c7065fe698f38b2f24c2d4abdcd0ffc5e968c2aa9c77c40116297a71671bc2","lib/libwinapi_mincore-api-ms-win-core-xstate-l2-1-0.a":"1de3c7cac5fb4e6e4586afc825dd2ea308a0c008e7ffc5a9a3dc964a67af481e","lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-1.a":"799d9550b9c6f19636b9becf563b4fa134df2f038a8054d86ec3468fb6003249","lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-2.a":"56c9013e02a91971a55e3a8f7317eca162d73187e07749e4f2e6a2cab1be28c0","lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-0.a":"14ad208d3a557860b153480c8ccb779ff94febe333fb9ced466371a81249250e","lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-1.a":"7611317eddaeb55896baba49e4500a2bbd27542c461747cb0ada9dd9e8f88740","lib/libwinapi_mincore-api-ms-win-eventing-classicprovider-l1-1-0.a":"44693253b456e6e88051fae853cf6abac787f1317361237a4129466ac0460f56","lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-0.a":"2218e4b6463c52ac282b2cbdb4fd8710b6944db59bbcf938ccc502f9f87587f6","lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-1.a":"cb9801e38e8de95efc6c9e7b751568d21cba1de5e1e3e1150753d290aa6c1e5c","lib/libwinapi_mincore-api-ms-win-eventing-controller-l1-1-0.a":"147c26ebb856c0d66418d65b579aa9bdcdad35b76ddaea8e9eb51c1cbe9c4ad6","lib/libwinapi_mincore-api-ms-win-eventing-provider-l1-1-0.a":"293099241adaea5ddb48e81d00b692f26959d8b1b81a4dd8fdfab78d5cd51eb5","lib/libwinapi_mincore-api-ms-win-power-base-l1-1-0.a":"2a3e535ca1c92f9421a5259c07d534585682d4f6648b95507c24f478b1fe243f","lib/libwinapi_mincore-api-ms-win-power-setting-l1-1-0.a":"75579f3ab3bf8aa738ce064a3fc93ea2a77c3a07be84b2fc8c465cfbef884fe4","lib/libwinapi_mincore-api-ms-win-security-appcontainer-l1-1-0.a":"3f967e6487e80799c080e8b9750960c3133d115f8c7974ee5ab70d71ae38b52e","lib/libwinapi_mincore-api-ms-win-security-base-l1-1-0.a":"bd3ff6b57beabe52f0bf678e560b412d530bffa64515393235e0fc65aa712121","lib/libwinapi_mincore-api-ms-win-security-base-l1-2-0.a":"1d0184140d34f7c7b0e28ab71d16cd2b996e8bb4eb423b95ea83cd1eda494f11","lib/libwinapi_mincore-api-ms-win-security-base-l1-2-1.a":"639bf97214b059e78d4fd683a13ebfb79effabd2f3c38a86ceb20d98d1a848f8","lib/libwinapi_mincore-api-ms-win-security-base-l1-2-2.a":"9a7e3a5e1b55f82d12a9a2e927658ee9fd925658e8586cded710d79c9d979e57","lib/libwinapi_mincore-api-ms-win-security-credentials-l1-1-0.a":"04ff7d0965ef4f55369eb1fed1334a6b25e5e7e0767da732cfd43a70b18a180b","lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-0.a":"9f06f963a86647f8e5454b1e5a30dc4edacaae156eed0fb22ab322a71072102f","lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-1.a":"b39db949209210603da7c0f15ade2d206e92b8b519cc3a4d909d30d93531f79f","lib/libwinapi_mincore-api-ms-win-security-sddl-l1-1-0.a":"8c2e5f4cd8d7b65f0107464206636579dc23de724fc082442234a501068623e9","lib/libwinapi_mincore-api-ms-win-service-core-l1-1-0.a":"d4058a3f1d3680a81c151b15d33c73a4b5e912120ffcdc176ab7e4c7a1570b25","lib/libwinapi_mincore-api-ms-win-service-core-l1-1-1.a":"a358042a13a9815582fa09b992ed9ca94c28c4de0c8345faf1852cf7579922fe","lib/libwinapi_mincore-api-ms-win-service-core-l1-1-2.a":"e53544c3ce3f33431748dbff6e04e718868f1941ddbab5757b332d0bd42acec3","lib/libwinapi_mincore-api-ms-win-service-management-l1-1-0.a":"6bfc8493bda22dbd82cb0ea3e3dbf34cd37988cb593480d0527d97324e5820c5","lib/libwinapi_mincore-api-ms-win-service-management-l2-1-0.a":"b867beeac24056d3f25d5d7047a2b864e63db9b257e625513079ce0e172402af","lib/libwinapi_mincore-api-ms-win-service-winsvc-l1-1-0.a":"d29586bdb7382582f07ec2f66309f10e5ea36783c0c7d5a400bbb3889807c588","lib/libwinapi_mincore-authz.a":"78c90a4f4fdfab54ec3c9cdaaed95bcdfc1d5a904bc939d663c415ca4138ab1a","lib/libwinapi_mincore-bcrypt.a":"8028ddda07a33cfa4c1d0b1557a7fba85ea809c0f714532cb4222df561f7a1df","lib/libwinapi_mincore-cabinet.a":"99074d908dfa970113bfc9075dd05f6125982eed3f201588b7cba7e46d530146","lib/libwinapi_mincore-crypt32.a":"96efd8c18f1842c08f5c00c1e8781b6abe66db706d1f8bd7e4ad80727d13bdea","lib/libwinapi_mincore-cryptbase.a":"e4cae4a43dc43263c3189b607d6a28bb379b741e874802c6e867571a4c617a34","lib/libwinapi_mincore-cryptnet.a":"ec5d7b695f29b86a185ee392050a6845c19890afbd7ff517746ba51b833e0b61","lib/libwinapi_mincore-dfscli.a":"59392a64972249a746bc6fa9aee7ec2f43bd90f7edf96621874e7b1572b9a27d","lib/libwinapi_mincore-dnsapi.a":"c2b4aa0db97117ecd9ce97dc07647dd63d35167e91c5af0b078e4e37db3b9d35","lib/libwinapi_mincore-dsparse.a":"a016dd7f536dbd25316223eb51a55b4efbebf6e01e0e258a5f3b7d891d92e763","lib/libwinapi_mincore-dsrole.a":"7170af583eb32cc16cfeed9ac04de800c9ca29ab9e4f8eda3179c9f2ba14e5ed","lib/libwinapi_mincore-iphlpapi.a":"9a62c837eb80f1f18658fba4b0b3d4f2da9715b72301e7c714c8616c566183c7","lib/libwinapi_mincore-logoncli.a":"5ff77d42dc2c4ea94a04821d923ba949c9dcadd1c67806698ce5777f55894179","lib/libwinapi_mincore-mpr.a":"5bd99b5c3a615bd12ff81a6b25a33acd47ababb0f53b0b72b8f32f0c3ba18647","lib/libwinapi_mincore-mswsock.a":"b059e1eee395e608bbbfd95c4206041c9746652c19bdbb0bad0863950e9763e5","lib/libwinapi_mincore-ncrypt.a":"8e4014e7528270f379ccb28b1e18a623497e3a98177f3b6d0ef1f49106417c8b","lib/libwinapi_mincore-netutils.a":"78345bb6becd68887936be88abc58a258f6bf20156fb8ae4f0560d44eeebda90","lib/libwinapi_mincore-oleaut32.a":"49b78e0b2562aef799df49a8ea32a43ec593498ee0b6477f74b24f4eeadde287","lib/libwinapi_mincore-rpcrt4.a":"e8f651a7e06a3f4d2f5c3a6ede9f19c710229b18e66b0463abb937501e487150","lib/libwinapi_mincore-samcli.a":"7ae6ea2a6fc33eb2e664817fff4ac87002657b628a6bd05d596b6d05d8c2c891","lib/libwinapi_mincore-schedcli.a":"5e260d4c0a255d422cca310cca1e9c44d15479b07931aa50d99b90a45b9e9728","lib/libwinapi_mincore-srvcli.a":"2627f35c6e08b2180c91fccc2e44f3d38e905150a716175e263b83b41bc27db0","lib/libwinapi_mincore-sspicli.a":"7906f8cd451f63d520328db6bfccf85997e569b65f21585036a33cbd80dee600","lib/libwinapi_mincore-userenv.a":"46a3e75f2b40c32186d6c6f153127d5953d457ca39dab64d981e5e67eda27159","lib/libwinapi_mincore-websocket.a":"257a0439a55f732fe53a81c116a917e00aa7639dc5c422b126845fc847c501fc","lib/libwinapi_mincore-winhttp.a":"a227894d136c0c0c251f9fb385b1508226b7330b446010b4f9aa394b8c8192a1","lib/libwinapi_mincore-wkscli.a":"a744cd61255baabfe96463b3df9427e48af630b8946cc5ccbdcb2fbd61b70713","lib/libwinapi_mincore-wldap32.a":"433bedfc97cba10ab1069ad965653762a5529e37689197dfae8b40832a96a057","lib/libwinapi_mincore-ws2_32.a":"0bcd38e75dd94bc11c1a05ccec976bd2c9dd2ff65d01649b983f6be1b58cfb26","lib/libwinapi_mincore.a":"bbd52720f360b925bd6d3838a10407029f4b3659771bb22dfcabfe5dd914e97f","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l1-1-0.a":"c028b2a23e1134089d5b3e63d7ccd3e7d6984b17fb837755cb3569162cdc92ff","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l2-1-0.a":"be31168bd95083953baecbc47c6e31a6563353d4dee2d378db4c7de0da119847","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-normaliz-l1-1-0.a":"42812dc895f6489f96cef6e05131083afe8305a97eeac2aa580291831206d44f","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-ole32-l1-1-0.a":"0bc587f2d6418e987a6f9c07e6cf57cd2bc5d2fbe76a94f558e91d5dbcf9d18c","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shell32-l1-1-0.a":"a9d7438cc5e37c1bd98d7a3cdc8e587b6a03310f289003aafeac05a4d5d6e205","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l1-1-0.a":"55237a627af67ff560fe0a008270b4d408aed6192d5c1fa53bec4b7f0bbd1559","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l2-1-0.a":"9d5731e369dae3f6a7ea57f9fbc94cf9500a2b283507f53038c8e089c1c9f797","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-user32-l1-1-0.a":"fe02038c2d5eda74736dc4efcd6c9139464f680c1d6b74fde9fa4532b2edd894","lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-version-l1-1-0.a":"53b0522c269674cf18f43b64755dc378c90e15adbaa4e17021fd7e5793c24696","lib/libwinapi_mincore_downlevel.a":"36d63238be9e28ba41d89c21b6e4883b8bd01c7205e7f32d71848c9c762fe5ec","lib/libwinapi_mmdevapi.a":"56e34422597206e90ad3f7174837231f60652ac407f3645da6d08ddbec20df01","lib/libwinapi_mpr.a":"7406a65ace451acbd8974ceee8286f20e9159f3d2a164602afecd9bcedab8204","lib/libwinapi_mprapi.a":"ceb642c2aeec33437df6c092ca94273e3bcfdd859a484a4a2d7a7968a37e411b","lib/libwinapi_mprsnap.a":"cc44baa98a5414a6a5ccbda8a0de5a2e618e8beff3a241cd9002739eb051cde1","lib/libwinapi_mqrt.a":"9892fe3cc11c52076f8d9f5cbdcea5a5206bff0d217dc65d0828c65005f4b533","lib/libwinapi_mrmsupport.a":"63cdebd6fe466661f10a0c6bc3404d0e54e64d692e94ab007e95805c492aecaf","lib/libwinapi_msacm32.a":"f60a75b3408003c0d8b5d46d1cbfd5a8c992dc42adb1e763d58528df25fafa49","lib/libwinapi_msajapi.a":"a0b46a7d600516877f94edc4548586b7f073d4e6ae84433ef69b351b9837c069","lib/libwinapi_mscms.a":"b5fc1891c4e13744871a8b7b47445ab1fe5c142c1edb469d842f3b9fe977bbcd","lib/libwinapi_msctfmonitor.a":"510636f80e65611b8b234c15daf0756e23d00e6b2c33e10250ac03d892393a4c","lib/libwinapi_msdelta.a":"f45d9f984ead08c81c82aa6eaa972f76406e121110d276d735013194847b056d","lib/libwinapi_msdmo.a":"aa3b4a716b8c0d6d7bd5d3adc4709660dccc9145e202a3d9d666d099899ae37f","lib/libwinapi_msdrm.a":"3c52ccff324fe4f064930b829c5076a74780a0ed82c7bf717e5aacb034d11885","lib/libwinapi_msi.a":"0c6aadc211fd5619b0d49ad64281a158caaee1660613fbfa2e608029c00cd725","lib/libwinapi_msimg32.a":"b957bfe3b092087c037931bc32af15b6f34796b749935f3c47ee255c7ecbc624","lib/libwinapi_mspatcha.a":"4c3bbfd791c2d2c518de608139bee2795a2c17f654326d95c2e554d86d946c29","lib/libwinapi_mspatchc.a":"601f4995cd4c734203f4ed75266dd89a2cc5066b5c0a3048767d05e66b21e679","lib/libwinapi_msports.a":"fc87678647395a4dedaae3af5766b4c5f4f394fd542377b565684aa0144c7d24","lib/libwinapi_msrating.a":"6c9acbc1d3426bb5e71f2107a229a152f81d0ef7d71c61a508aae7f847e6d957","lib/libwinapi_mstask.a":"9b32f0e7ad02309bdc681dcd48fc5c471b312db307778a1021571752f75663fb","lib/libwinapi_msv1_0.a":"93a80a8ac2130ebc3cc35b120f79391a34c83daee7ef33e11f0f6dab113292bf","lib/libwinapi_msvfw32.a":"3cf557fa7f9f31f23d8f498add4930b6ffc304a055d371ff6d59c64824134e87","lib/libwinapi_mswsock.a":"381afc6ec584272549384654be6f1e52139a3d6768a6d9d101258bf92e711c2d","lib/libwinapi_mtx.a":"7f94c16ae24a21d23cee0914d0bc1fe96e680c54d40ec5ebf47007c16748f4e7","lib/libwinapi_mtxdm.a":"08081c65d362502423aa0e9113658f9df0f4022f87be81592b5b059fb3dfb66e","lib/libwinapi_nanosrv-api-ms-win-net-isolation-l1-1-0.a":"423f0645557c42b13ac439544e73ab721577fdea996615604d641c30f111b86f","lib/libwinapi_nanosrv-api-ms-win-net-isolation-l1-1-1.a":"61df616253b837284b9541c67086d902162dff7b2c915f8b059abdca33a48779","lib/libwinapi_nanosrv-clfsw32.a":"3b4d6434f3a4fd39e6d1bf4530e25d654bd24e37e685a22de23fc2cd378a57e4","lib/libwinapi_nanosrv-clusapi.a":"e55758fba6a73cde2f06124b8014860a39946df814158d8c0d6328b266b9a090","lib/libwinapi_nanosrv-cryptxml.a":"1d8444463051db7479bb541da43ccdb303f581ca8da74bd7c3fe5d4f5ee124b0","lib/libwinapi_nanosrv-dbgeng.a":"c2229ccb5959f07cc33a3553a2b96257379b601ee5c934fc2dc3173dede7fa95","lib/libwinapi_nanosrv-dbghelp.a":"4c5aa4edfb424c9b646f69e61f046e830a576a3cbc299d959b9b68e33834d5f3","lib/libwinapi_nanosrv-dnsperf.a":"51df95c4624745ca014c4064f9791d5f5a87f8e140e751b631078369cd951b67","lib/libwinapi_nanosrv-esent.a":"a27c8b50358d89cc85b5c5660520a912d5cc553d58acf03ac68f61d687a5c4d9","lib/libwinapi_nanosrv-faultrep.a":"9bddb8af62f936b76c9ab737b5e1a4fd71fe50e7d593d0226749f5fdf6b9753f","lib/libwinapi_nanosrv-framedynos.a":"ad8888d9f3426524fbb7ba5642ecf9173a2c8c972e6dc8a37ef7be3c36fa7fab","lib/libwinapi_nanosrv-fwpuclnt.a":"fe0e1f4ab2120396508cf4c61599cab66b8d1cb6e23b874a3f6f97879dd6f904","lib/libwinapi_nanosrv-hbaapi.a":"b9da44f2995f25608cb3eac7bc128e5ee5081e95382fbfbb79c3d9a126c2393f","lib/libwinapi_nanosrv-httpapi.a":"b58e460ef867312f210a6c914b74645eba848c957fb915bf75f0a06164cc438b","lib/libwinapi_nanosrv-iscsidsc.a":"780bed8fed327ff5169fdb6d9d261bd2d13cd8e41615ec7a2630a2ec1d366bb8","lib/libwinapi_nanosrv-ktmw32.a":"a266994f59e7dd4100a7434a10359af18bc06d65e24da38cb67b4869fe449004","lib/libwinapi_nanosrv-loadperf.a":"a2dfbb2b3328fd5484a1297ba7559fca69456fe5185b1b9966b49985bf4fe3c5","lib/libwinapi_nanosrv-mprapi.a":"dd1e92fdecc614bb55400cad71e05748d035a30ccc8be3112a896dc10ae3d256","lib/libwinapi_nanosrv-netsh.a":"508ed31e1dcff117a481e22b1a9cf715603e39797b1be841c285fac1242bb111","lib/libwinapi_nanosrv-ntdsapi.a":"da6b41c87a140aa5955e12146450c06ee69def0b4403df08fff03ab360691f03","lib/libwinapi_nanosrv-ntlanman.a":"e388f2e52d7725a131458fdc5b3819ccfa4b9693ee744ea60774b55ee8b1d97f","lib/libwinapi_nanosrv-pdh.a":"0293a1dc8cf65943d752591bab9fc7e35e52d8d3e434caffe01501efa12c7725","lib/libwinapi_nanosrv-resutils.a":"d07b9ae21e09e9fd1cf2a34e29d15083b4488cd379e86450e43fe96c94fa7c1a","lib/libwinapi_nanosrv-snmpapi.a":"23801069b59bfa63e1ddc1215952bc7cdf5c3759d737391b3f0022e3447fa342","lib/libwinapi_nanosrv-tbs.a":"0b238cecb91ac3f3009dadcd6ba5ab97966dd8ffb04fb2f02192b9d684572cc9","lib/libwinapi_nanosrv-traffic.a":"f785453c167afc1c307ccfdfe118623dbd76da7eca57693f8c3b0b48f5c99f54","lib/libwinapi_nanosrv-virtdisk.a":"e00fa531feb4605d0c57bd0fe666013cacb32f6a6f3b507783db1e6fc30bd5bc","lib/libwinapi_nanosrv-vssapi.a":"3f2d034551025175703eed381e2c7a57f066c338d03df1e928d65824cfd66a4c","lib/libwinapi_nanosrv-webservices.a":"2ae64d017c4e93543315c80651b85c50fe657a436dfa4981ccba86267fb1a27a","lib/libwinapi_nanosrv-wer.a":"63a98d54282376fc4164514ea6b3d0e52b24af62b2061e2f4470e4ddbee524f7","lib/libwinapi_nanosrv-wevtapi.a":"a92de1acd31bb0de7561d0639d43758d52a21b36e4bf31301e0b6684c7f2bb72","lib/libwinapi_nanosrv-wintrust.a":"b64d805e86062b99e3c91852e0d3b06cc730275353c6a0f5e73d37035a2d4452","lib/libwinapi_nanosrv-wnvapi.a":"4e9cc9f9c40c69cd8a35b347c65281340f8fee3a62c95589c4af382904b7113e","lib/libwinapi_nanosrv-wsmsvc.a":"ebf84b310b64ac901848e585bb2dc70052555685e327de26af717bde7d4edeb4","lib/libwinapi_nanosrv.a":"466d7a38f0751d8d45510cf885835ada4c6b620f04010bfe78088cc3af4466a3","lib/libwinapi_ncrypt.a":"9528d1ea3137810ff543e4a400e45694b3012bd020dc4d16d822bdd4c849c345","lib/libwinapi_nddeapi.a":"925181b8f854a2d3d1199c295973e72ccd41c6305d0e02acd14531f19a08e2c0","lib/libwinapi_ndfapi.a":"5ec4360cbb064903a5efedd5396b57a10233c377e823e69b95766d843023e11e","lib/libwinapi_netapi32.a":"feef4a95ccf8733c20ad24c3cd7ca44637663714121a5bc94ec52d0f7bb10613","lib/libwinapi_netsh.a":"72aaf2d1b4ce73e1b61d60fc82c7e9e4f2d02767bf25981012f3359ca7cf2114","lib/libwinapi_newdev.a":"90773a4fd90abb7e64c3bc5dbccbe070ef0035bc66c5747187d683c933ef2c55","lib/libwinapi_ninput.a":"34a426eb6ad23e4d5b6e0d947d6e10ef0dc119157d6d762be4926bfc0893c96c","lib/libwinapi_normaliz.a":"7e1b6bc02ace0c902a18244e907446411155a5fe5dbeb8f160bc5198c804266c","lib/libwinapi_ntdll.a":"3f2d8d2a13023b62c490611cb24585a8a5cafacf794e9ee5655a90678de03fe0","lib/libwinapi_ntdsa.a":"4137b9f3447a798fed0f916bcaa82d9413ac98fa1a7bc6dceaeb4e0ae7f45bb1","lib/libwinapi_ntdsapi.a":"b8671ed8ce19dc28f5daaefd891f6e621610523f180c70588764107b57ffae5c","lib/libwinapi_ntdsatq.a":"d2c39463900a5bcf52561dcac9fc8527f3a0348f61183f1b1e4e3b6e782eb8e4","lib/libwinapi_ntdsetup.a":"9d786bc32c3f4f9ad534cafdc07e81a9c375618eb6e1f342f7a89b9d1258f184","lib/libwinapi_ntfrsapi.a":"9c3095b92625fef6531bce0d2d08536f83fca0f8ee28d495f95976bbe73619f9","lib/libwinapi_ntlanman.a":"1bc7aa39f5d6bb0af7b3863d4902027af95414b9246b244d6b40c306b6dcb74c","lib/libwinapi_ntmarta.a":"cf146621e756a21cd45bb9ab5f4d8a016fa2081dbf4e108861b2b131dfde5d9f","lib/libwinapi_ntquery.a":"652de6a12f9d4bc5fe4462f1b476f1ad559d8407eafc28e0080bc59a3ad57a4d","lib/libwinapi_odbc32.a":"5d8ec8c2a587a5eb00eb8f6f08d7d7e00ed1e03cfaca2070efb1d0f4da6a9562","lib/libwinapi_odbcbcp.a":"8c99d188cd45f740a2a58ff7281b611ffdcf651be2bbb5af15543b60f872f6ea","lib/libwinapi_oemlicense.a":"bc88d3b4bb4a91945e8c288539e415d2a1ce5db6d3c342f3ec5860ba1e300df1","lib/libwinapi_ole32.a":"7ef3b297c9d0c5cdf5ed7517247829466da34fcd19d8348f3f2d6c775ca3ff65","lib/libwinapi_oleacc.a":"ed4c0afe844de194371ed21f8f2e18b48c80eb42377c143baba7e70dbc556456","lib/libwinapi_oleaut32.a":"b25824f0023161a0610e9c7d6d9731ebe7b541c6a31c34fa7bbe552b6754540d","lib/libwinapi_olecli32.a":"b3dd8c5f9dc52bbc832c7bf850a3e738ebd9de7b0fffca03b272721ecb687886","lib/libwinapi_oledlg.a":"3ab9a3c0688897d538e66926b1f01ad88719ac959fbda99be2f661baa9c24097","lib/libwinapi_olesvr32.a":"cb7cfb28a777c5f9e8cde3067d98fad5ccb3526acc5d9bbdd5d2d1bf981c37e0","lib/libwinapi_ondemandconnroutehelper.a":"0bcb234cde4260ffce27aafb540bd893cf99415dfc9ebf1060876e06987fbfa9","lib/libwinapi_onecore-api-ms-win-core-atoms-l1-1-0.a":"0812399abc86ab0215582f2f91886652038a12af419cbeadf0a1ae52168f5467","lib/libwinapi_onecore-api-ms-win-core-calendar-l1-1-0.a":"74994ed6e3beab0a6a2a7ac5c47c0f965305447c1a94db08c9475be3918dbd34","lib/libwinapi_onecore-api-ms-win-core-com-l1-1-0.a":"11a832d46628bf355e710643dbf7a4497fad47b22c2a5510fbce5bd1619fba05","lib/libwinapi_onecore-api-ms-win-core-com-l1-1-1.a":"553270f375f8be0fc596cb2e1435cc96b54a8270cc2898d6118e926c7a4131e7","lib/libwinapi_onecore-api-ms-win-core-com-l1-1-2.a":"94ac798c39cb9beb94082a6a62d55cf28a1122d3d81e982f2727a5548e96d27e","lib/libwinapi_onecore-api-ms-win-core-com-midlproxystub-l1-1-0.a":"000e19cab23d0aaf80f3d0421f217df0855fe6406418d898261125947c806b30","lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-0.a":"c2f2465b2f801de6e60611e2341b7f6fd5816042fb0406edc8d6c283331b70ff","lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-1.a":"512d357839150ce54a7e49d33f51492015a553babdc33cb4f38a60e61f6ae5d8","lib/libwinapi_onecore-api-ms-win-core-console-ansi-l2-1-0.a":"6aaaac3062b71b8c27397b362d1cd37f5ce0dd95bbf59f8993498dedfc960f4e","lib/libwinapi_onecore-api-ms-win-core-console-l1-1-0.a":"11714e54306dc6aa754da51731b711211bcce620d8f353ce58d4138e396237e0","lib/libwinapi_onecore-api-ms-win-core-console-l2-1-0.a":"e772713586ca9e3760e48d3c582742e68a06753f0f9417f9013a4393c5267fa5","lib/libwinapi_onecore-api-ms-win-core-console-l3-1-0.a":"d730564120a07cff27689d061caffe675421c109f48325a734c268afcb86ffa2","lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-0.a":"225560d62b6c7ed4cd540a98e7a13bed54860adc230390b182a8636f91739b63","lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-1.a":"aa94d82f882c7de0ca31a5120bd50387bb8cfb1bf46b37d667562d31a5035153","lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-2.a":"f229e2c630e9f0ed6393a116562b55f32a9eccd82db8ae7bb7dc59da6030d711","lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-0.a":"e9a5c6d8fa217a81afb3265c8eb25d879f714974bc8893f3487ea82b996bf19f","lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-1.a":"3ca35a5579d682998fd8165c7297e7897e878d314d8e4d36c9cad977b1bcf16f","lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-2.a":"af5b2c57682045533e88c3b0cc2f135a18a70e92f1aef01d63d7004ec967e779","lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-0.a":"99f6670388088ca1887fb5dd1c9137431bda35f9a745c2a1c44c799aa48644d5","lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-1.a":"f573eb9a19338214d65bb2761ef980505f8e2c5baa1dd12e7c5b42ece09f3c49","lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-0.a":"3cadda78b2cf277479cb4a02e46239cc21758571f3624e95eada3f7ed1bb2cba","lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-1.a":"dec9e42133f0bee3d7401ef0b5047b4f256a9e04a93e009a6bdc74b604815b33","lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-0.a":"3bc506d06a39131955c3b4e29649f46ab06151c3fa4fedbf869d8c679530929f","lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-1.a":"14799617aaf44690708c4fcfaff49a70e773fb9b8943b88211a96c26f1a01280","lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-2.a":"52c25a2c52724b98857d34dc5aad36282823fbb932e51f86c9d5712d9aec5df2","lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-3.a":"252bb3e39ed81e47c3f149119859ec65ceb2d1e65e7288e0a0bd0f552d56b597","lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-0.a":"e2df929933e2c413b3b8dd9c9f16abe5e2543ba89b9cd74a427a10a759453220","lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-1.a":"04cd671c6e0dc98b930c832db1c26a90a49c9073b8051dc23817cb56c59c559f","lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-0.a":"36501ad8bb5fa4f78dd28471ceb93b98e211c1dd550c0e3466ac97470fa7a3ff","lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-1.a":"0337bae492fd8e18731498095ac2a0ce523fe048eeff4d2159b4704bba32d7ad","lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-0.a":"d59ddaa31a6c62b75b6ebccb0f85c6fd454e87165127b1e4bc6bd3f7493c0410","lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-1.a":"4cb5b72b4737b3c953ac5d46d6a7438745f4f0c1d0d71dc7a05f3926293d3739","lib/libwinapi_onecore-api-ms-win-core-file-ansi-l1-1-0.a":"9e7c0db27b3362214c1b2d18ae63bb4d77b66b6aa4a26e104faf176a9584da05","lib/libwinapi_onecore-api-ms-win-core-file-ansi-l2-1-0.a":"386beeddd388cfd272c8d851e1a16f70f6c2e0fd467407651f548c90edbc2ff8","lib/libwinapi_onecore-api-ms-win-core-file-l1-1-0.a":"a51ece2c03202c0abc6b8a85f1ec7a6ef459cea1d1305e87bd61820a0b80151b","lib/libwinapi_onecore-api-ms-win-core-file-l1-2-0.a":"3256c7a1b9a18162d1e087c01833decfb3b423d9bdc798d024c0181add03279a","lib/libwinapi_onecore-api-ms-win-core-file-l1-2-1.a":"0cc7df4c4e9b351e98f855fa535705aa2e66b57419e21f5bee873e37f428cef7","lib/libwinapi_onecore-api-ms-win-core-file-l1-2-2.a":"d10c5a1bb1ea57a670cdd1963cee2634162e2609b603f13f0540ac6820d99639","lib/libwinapi_onecore-api-ms-win-core-file-l2-1-0.a":"6c280211556cbea0f974ae0184f97d9d77062e2005068f017db1a37355acd452","lib/libwinapi_onecore-api-ms-win-core-file-l2-1-1.a":"11199d60fb9f6ff631401da8add46a90420c36bdc5fa9f775026984c514ce1f2","lib/libwinapi_onecore-api-ms-win-core-file-l2-1-2.a":"0e33bd2b47ab2abd61e9c8192b5bd6b74b709aa88eac9e6543e144435c233ab6","lib/libwinapi_onecore-api-ms-win-core-file-l2-1-3.a":"51f3f8a48bdf98220863dd08254cf13bacd3565b775c277a579a995b42ef8511","lib/libwinapi_onecore-api-ms-win-core-firmware-l1-1-0.a":"0c5ba3b62f84a3c09f9fd96d7cfb095c32ea239945df75105b8ae3c8d4d68d5d","lib/libwinapi_onecore-api-ms-win-core-handle-l1-1-0.a":"5274984398f2722c8bd9de4379f861dfb459e9996adb161161f097477a12996b","lib/libwinapi_onecore-api-ms-win-core-heap-l1-1-0.a":"9b740168c4b0c590322d58c04a4a03399a6fa5a4fb3417c7a22d536b13d62258","lib/libwinapi_onecore-api-ms-win-core-heap-l2-1-0.a":"3cb8d04859c3d52d7fca1ec72ce333dc80f57edd6d6a2e4469f906572af2cbfe","lib/libwinapi_onecore-api-ms-win-core-heap-obsolete-l1-1-0.a":"a46949618369e6ca98b4ecbf9a7ba11e0a499875a57b7d3823e2d47cdad51ed7","lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-1-0.a":"ef84da9b01bd67d9ca5e4cb6e7cb940b0c87e328433ae21622493cfba643bad4","lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-2-0.a":"f1885d437d2c71a165dbe1acec1004e9c0e46d867b99c98f2b8672ba3fa65d0b","lib/libwinapi_onecore-api-ms-win-core-io-l1-1-0.a":"00e3af3b885ebe7168dd41ed22ce70ed0d86c8b3e177d5e75cfdea6b7c58f10a","lib/libwinapi_onecore-api-ms-win-core-io-l1-1-1.a":"f625df3356c5b38ee99a3b333b64711e44a624994995a9e10934668df93097f9","lib/libwinapi_onecore-api-ms-win-core-job-l1-1-0.a":"ee0ac0735a10054b65f4938215d7e41ef644f9b2e5e81af6659868673c318cb0","lib/libwinapi_onecore-api-ms-win-core-job-l2-1-0.a":"903ea43d84e08de9d666196caa15153b08e662a928ee2e18215833fea3c11f39","lib/libwinapi_onecore-api-ms-win-core-job-l2-1-1.a":"37c8fa3a59f8f90ecefed722ba2c803b9673f3946d0ad978ef9a0de85399f448","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a":"0866b4788c59fe3bffdc96eef646b2f478ec36d24933fbaa8a8f33f92f97e428","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-0.a":"c81e555151a68d16ff8e04ceb9683c0d892ac05194a4d69819c60e5ac2c7a764","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-1.a":"f53901accee09d4bb6a1a9cd9bbe02b7c064885c4134e7ba41921264a057d1af","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-2.a":"2da3e0c1b26cbed327d20ea42595819e6c4f35ddcf891539adb76c222a51572c","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-3.a":"95c16a2c24de3bc76574937ef81202d79506a8cd02ac9fad8ed0b2b8cc6b4986","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-4.a":"fe9f7eabb02c5db5bab6f22e76843e93b9a7a1885435ffc51a50e5010bbd584b","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-5.a":"adc4ccf4230b51f7b8a52af5076f9a236817234dbdcfcf3d4268c35d9601b982","lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-6.a":"b758191d8a9d730f571b6022d466ddefa3309ac2980a4da350bf48ba424386d8","lib/libwinapi_onecore-api-ms-win-core-largeinteger-l1-1-0.a":"a22ba51cf66d25f83d07ea6eac7e7dec65c084ae74046e7247c5e3dc2e2140f6","lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-0.a":"68677b52813aa0b0ea5ef424b7855f96dae57ce90df274c58d602a5ca43909fb","lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-1.a":"4e39c567d18195f2ad4da9a8f0bc2b78118ebf674f2d28435c2cad4ec0f118f6","lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-2.a":"09f3783f156e9aafef1513f82b111e153d4742b8060e811234d08ce4cd7f9df5","lib/libwinapi_onecore-api-ms-win-core-libraryloader-l2-1-0.a":"a690308b96b335744482dc37e8e60946ff9e2ae1010c5c35547a1f4d03464e00","lib/libwinapi_onecore-api-ms-win-core-localization-ansi-l1-1-0.a":"4f1aa0006bb4f60f02a8202006ae9e28330330f1a7bf43a5c1a84eaa55e64ae0","lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-0.a":"4dd512fa973a9af26b48beb0cbaebd4a0e0fdbb86e5e39cfec515e4e59915766","lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-1.a":"36b1ad3787f9e65956608eac3851959246de8440f84cb6714dce8b97bb340eb2","lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-2.a":"bbb7f176f1bd373f4344722d6800b27d3aad7e47e8ab588ce204d04e616c4488","lib/libwinapi_onecore-api-ms-win-core-localization-l2-1-0.a":"ae00c55870a9b20bee701ea81e9886bb34dce92581780b12d523b46f6b2fa2b1","lib/libwinapi_onecore-api-ms-win-core-localization-obsolete-l1-2-0.a":"d31290baa301772ce4aa988d2d5b8f299c199b5bfa887fbd5473102cb3babc07","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-0.a":"5240bbda416bb5ec960f7bbf79f08d475f5506000f72f1d9cfc9cd66596a06cb","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-1.a":"bd7235df3b99350337da93eed158cca56c4e78f3642b93e3d5ddcb0e9cef34c9","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-2.a":"2e6a99934abbd9efabdcbf881a5a98aebe2fa66ad8666c8441a68255de78d95c","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-3.a":"04b4aa2f4348cdb534d9b6acb5928ad215dcbf3bfea9a722be3dd0ba9f6082e4","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-4.a":"ce3cb40fe7191c017aadadb8014e4350151566c1a8699604c104e9853c63c828","lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-5.a":"7d57f64caf57b70d1f608c9c4232405203217721d20ba21addccad59a255e860","lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-0.a":"91cdd0ea0d8ab1b7c6a8f6d14860d465b1906dab20a087da0e056531bed9b544","lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-1.a":"7378bc3ed7e88fc2f6183fb98e455fd749d14eef8a4af1247625ffb187862a8a","lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-1-0.a":"556b0d07663cd467eddab9f790f0a0c74e4dab4c032a0ae2d2f9f43d7e07c9a0","lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-1.a":"72a85c923fc506a03ce0004e0c8b1e4e52518ee8ac820b8ebb00da4d6a3ef9d2","lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-2.a":"89bc3d4b973fdafec0c0d3c3f90d5aaeef251151159c492b74893dd395fd6818","lib/libwinapi_onecore-api-ms-win-core-namespace-ansi-l1-1-0.a":"94334cbaa4d5be581a2dde5355703c7fd15ca8073b782566d8723b5ab5346875","lib/libwinapi_onecore-api-ms-win-core-namespace-l1-1-0.a":"7a66ecb0556eafd9eb5df60d1f803b2b8aadd97b774f9411531a4a3a61ec6bd6","lib/libwinapi_onecore-api-ms-win-core-normalization-l1-1-0.a":"0f267f6e3eef425ac76f6e7c0bdf112093f41aaef21865658ee8f745979042f8","lib/libwinapi_onecore-api-ms-win-core-path-l1-1-0.a":"6e79e97e807cdefc677bc39f2021a72f35089a454c3f5ac7338851bad48e0e0c","lib/libwinapi_onecore-api-ms-win-core-perfcounters-l1-1-0.a":"2f58c2aa61bc159d13daacf746353279e959b2543c48f32ac0c848eba2a66c53","lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-0.a":"6bd0917eb64474d9759928e9a8573bfad27ce0100b5d0b135e6fd8764dec52bf","lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-1.a":"d99e384c885a50e3eaa338fdd3622b203f3be5bb27963ce885ec43def000e887","lib/libwinapi_onecore-api-ms-win-core-processenvironment-ansi-l1-1-0.a":"324b59dceb78356919f696843114145930f8c4e8f9d927a7bd7bd1b4ce29ab11","lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-1-0.a":"446fdd1a3f8d9e761022248c8442e7c9db0950e50eedbb9ee7839c10cdd021ce","lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-2-0.a":"94490242107b24a541305dbbd617e8b04619ea688e28269ab0a685daec51a054","lib/libwinapi_onecore-api-ms-win-core-processsnapshot-l1-1-0.a":"c4556ba06d127b26cb13af4c60f5a35a13e7ff78ec63fcc2e5a7f0edd13af81f","lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-0.a":"ace2860be9a90df5c430acbfaed6054a27a978f9e98f4a0604ee4b2796982741","lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-1.a":"1234e12026f9f68bd59227aa20c5be4324d2f04eb9983a8fc99ab8e8dd39a8ec","lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-2.a":"7fca19a6df8946d2be7f55ebdcf85cdc6a267b9ef5bc9fa26f47867d3fa4c132","lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-3.a":"909e60143db5394c1207eaf8ceddc6df9be08cf595e012611d1f3f5211cc53bc","lib/libwinapi_onecore-api-ms-win-core-processtopology-l1-1-0.a":"d1143e676ad231352b8b00bed0b485091860bc3ce6f5e0f8b137a3580ea3d4c2","lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a":"ebbe6e1ba85d1433cf9d9026e40a104b102241ebf947c025a4859e91e0694343","lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a":"e119951f4458646e6ed9c43bbb8de80e7036e62ff455f98e1a9aee25d2e28cd6","lib/libwinapi_onecore-api-ms-win-core-profile-l1-1-0.a":"e85b0a4602e1e77c8de8bdf7f9e9b13e57240d1496e28304d9e8a092e4e1c12d","lib/libwinapi_onecore-api-ms-win-core-psapi-ansi-l1-1-0.a":"98fd2d3982e8e4713beb48f99974e73fd544cc4c2aff54e50109db2a07c14e15","lib/libwinapi_onecore-api-ms-win-core-psapi-l1-1-0.a":"bb00b81fd4fb193c85a6437b7ee986cf2e60362fb32831ca88f7dfea345c29e5","lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-0.a":"dfd8122b210a76758087e8c07b1ecc52f869d615d98ba3e4e76a90005448d5b2","lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-1.a":"b3b71a4db59b0c5419869cb5cf92c14fc17381b110b17cd4cfc8f5c4c74479a2","lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-0.a":"ad90128213421e6758c154b3e84c259dfb6d04db1986926342258a933266684a","lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-1.a":"1684a81e385a25f8690233b4b2e66695a955b516bed25c0da4ee59ddae5e79ce","lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-2.a":"bd31c35d7daec22904c6f08ed6ff684eba9b8e0f1b51ab22c60aa41667b4c3ec","lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-0.a":"75e7e87e3f11ec241326ee839455f3e347771d56649390ffccededc021ba543c","lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-1.a":"c20fbea2b3cdbc0226a08468a264354da50434ac664c737496fc9d6c9f84e2e1","lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-2.a":"750b3188270989da73a237cb9a0d1f50cdc9e14711076161882f909bc98b0b5a","lib/libwinapi_onecore-api-ms-win-core-registry-l2-1-0.a":"f01e53c0fc755a96177623988e55f1b90cfaa5ab461ae94a30522a52a3cc626e","lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-1-0.a":"ffe64e3fe1cf8b31250e77499e0dc7a7effaa0e9c8975affeb23cc6ad9e62e1a","lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-2-0.a":"b9bcba8e05a69402ed0d42c42d9f3a0b02a78f049a3414866c4cb612e52d3d44","lib/libwinapi_onecore-api-ms-win-core-shutdown-ansi-l1-1-0.a":"1378aebbd3383751ac51943e258afe8cec4ca0642a7de787eabb867900beeeec","lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-0.a":"8415bd37b28325d9f12ba022ecad9cced0a1a53cb98bd2d7bf5ca08f434af9cb","lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-1.a":"5a386dbb47081c4835d4c712b5530c7ee8d2307d0d04c85d473011d20933826c","lib/libwinapi_onecore-api-ms-win-core-sidebyside-ansi-l1-1-0.a":"4694382000fbb05b54077132f0a5022a90a2eedd7973fa9d6e73ed71cb1a0350","lib/libwinapi_onecore-api-ms-win-core-sidebyside-l1-1-0.a":"95cb9ab35d06338b411cd22232df3f4ab7ef0a10782859f5bd861a2d3762c6b6","lib/libwinapi_onecore-api-ms-win-core-string-l1-1-0.a":"6d104770540533f00fb9b96ee8416a86483c692bef598804a55d73a8b7c56130","lib/libwinapi_onecore-api-ms-win-core-string-l2-1-0.a":"099570484acd8b263271b80cd6027f1a0ae98d2970acd686f63db6790834a55b","lib/libwinapi_onecore-api-ms-win-core-string-l2-1-1.a":"6f1090d7736991cadfc84ee9a6bda4410059142255d338990d3065d335e3de85","lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-0.a":"cf77b087474ef60964614f323df7b94cc3f2a915860a7543ff3f35d9e773718b","lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-1.a":"934ab5b1cd5a2a1bacb740e06d7bb028845d17185775106ee02456320d154c87","lib/libwinapi_onecore-api-ms-win-core-stringansi-l1-1-0.a":"5fe3329d1602f505c2336841d3984b3a894ad551dc4a0935d08035fa85d1e4d3","lib/libwinapi_onecore-api-ms-win-core-synch-ansi-l1-1-0.a":"65d6ceb10e4bcd2d49e539f2cd92e0eb598a74ccddff21b72c55d184b9eda1f9","lib/libwinapi_onecore-api-ms-win-core-synch-l1-1-0.a":"ed400709404d9f5a06929518da72eb212768ff315c08a66a07f3ad2b40a04310","lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-0.a":"3eec255608b4a09359e6213d3222fe2bf21a6eb3584e2efa40bdfeae1ec2eef6","lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-1.a":"7795df40583158c625c53dbc6a567ac6074fcb89524207233915a42e6b192842","lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-1-0.a":"540a4ca86c9a10b5279437858fe0b8aa3265ada2c362ef60adfdf4abd8617fc1","lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-0.a":"ea94de89764b714a3b8ed0798f727699172cb496b91eaa217afa064def19d268","lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-1.a":"6f20ed61a65bb14ca16df5c3036cd919b5a41cb437b8b685a0c496d794255d5c","lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-2.a":"5400ee8df09fa91470514c59b0c2d3862f19ec17c2ac53ab7cbeafef87e53a89","lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-3.a":"3c261a651b256e46bfa7bc518ab3c13783b3347ebcc8e02605f602d9ee0da1c9","lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-0.a":"a622795b6f3ba89aac17004549109f56eabaac6ae39ab3a92bc036210c3c39ec","lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-1.a":"0c4a4d58b42e982a269654a9b2a532f365e6ef6c2008dd30d4a9d255f3d24f1c","lib/libwinapi_onecore-api-ms-win-core-threadpool-l1-2-0.a":"cad2d51ce58c2ebeedad4cdb2d5cc5fe29fd4541d95a506185c40ea05e0782ef","lib/libwinapi_onecore-api-ms-win-core-threadpool-legacy-l1-1-0.a":"8034dad817b3b416added42802f7113a4ebe3262d22caeccbe436915a59e1df5","lib/libwinapi_onecore-api-ms-win-core-timezone-l1-1-0.a":"7e0f32bddb29e8243718fdb75d0484d6ab22ff190bc18464106f2f36984ba71a","lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-0.a":"5bb0e5476698fa8705032534cf4a14dc78967966b0d85f73b4ac6a47f683d173","lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-1.a":"406e1630f1f21547269a90b3d924320f21b0283a852c63be6e219a24489aed3f","lib/libwinapi_onecore-api-ms-win-core-url-l1-1-0.a":"a7fd5be6b75d6331126d56347a04f5325999d768dbea3fe41765bdbfab15a393","lib/libwinapi_onecore-api-ms-win-core-util-l1-1-0.a":"b373c42a81ed6e05ef9f6974d02d84b7a62f05982c6c91d2248457b2e75d7c58","lib/libwinapi_onecore-api-ms-win-core-util-l1-1-1.a":"318e7f0eb69f65a6541c73604ccb86acea6b8a057e2e3f2b992d7d5251c73ee0","lib/libwinapi_onecore-api-ms-win-core-version-l1-1-0.a":"80b563faec0b94b2c03418f91a5cbc4561b37054b70699bf931872f208e1e2f0","lib/libwinapi_onecore-api-ms-win-core-version-l1-1-1.a":"8503c18952cd31a1d98a917a4611ad9bcca9885d1b269b55ef411466d5d5d92f","lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-0.a":"e8ebcd5e4b1d1c01315f7574af5240c107fba23655dd47e49adcb241abc5d4d7","lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-1.a":"cc4532d656729f50dd0cf42fcbb8d6cb4023803afbd3c6ccb71543b1a54ab472","lib/libwinapi_onecore-api-ms-win-core-windowsceip-l1-1-0.a":"3f7c40c879b153cd9f66bd4c18137ac0d6aafeb17ed157439beb8f8591a3edd3","lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-0.a":"cc4059edc72485280ce47980ae015ce4152f621367897065b2cb9a5509b235fd","lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-1.a":"b1abe2529852fc309b692bea80d8c60611a40f48068ea6a9e7f19134611501a2","lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-2.a":"ede7bf4ecfad8d0a9fc58fddd308b06ca815da52d6177cb531052c549134684c","lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-0.a":"3c2c0ca0e39ea6d7e376ebf309020ced4d2222975a33ed95547e4dd161d39f61","lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-1.a":"df55987015d91bbd5dd22763b011ad3f78dcf78fef76ce019a96d694361b9f24","lib/libwinapi_onecore-api-ms-win-core-winrt-l1-1-0.a":"4685cde798ecfc1e51915ef4c958f506dc881ffcbef15d544b9e6d3cfa973b4e","lib/libwinapi_onecore-api-ms-win-core-winrt-registration-l1-1-0.a":"7f777f480dc4be64729cc3675029b92bce019d498f6f70f05b32b9cfdcd416bb","lib/libwinapi_onecore-api-ms-win-core-winrt-robuffer-l1-1-0.a":"678aeed581412d7f57d7f5952a3fd26711743a0316c13c048b225f93dc416d63","lib/libwinapi_onecore-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a":"2d490f02015684e8bdc4513d0e98a0f4e2a7a137d4707b680d496fe32d5b08b5","lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-0.a":"17729e054168b9fff9d59aa70808e237561bf6bf6681c7c9a254e40e05a3dd8e","lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-1.a":"efa6a01c28f7087c559b2c3a62d89c2349f31b4bf26ed5b3bd96481852315ac9","lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-0.a":"eb8473b785c6f7a15c73a46f08b8244c3b50096464555bea8cdf5d97150d20af","lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-1.a":"a2580ddc6724143c43623d5a8616a631fce81b215537ea01a7debf0a7d0df4dc","lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-2.a":"0fb50f5b9fb8db51e3b10fa2751ce2d13c15a11476049062a7d765c82e296cb3","lib/libwinapi_onecore-api-ms-win-core-xstate-l2-1-0.a":"59273163fbd4bf35b5c77030b8eeb90deb24400690c3709497198e4bc82fa2c7","lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-1.a":"56cc37d116f3b1c33f994507e20745702f160576f6f2405cc96eb501947aa6d0","lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-2.a":"4c09217fc1f3e02608a71a36374f484697f7f7b7b4358be96653e6e3bad62234","lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-0.a":"0900989505caab7232ed73b5226dcbc30aad0c8a368ba6e8d733005c7f29b5f8","lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-1.a":"97c280911041c2f23ddfa24495d6c93f3e1184a732c05d3e6c873bbe67bb00ef","lib/libwinapi_onecore-api-ms-win-eventing-classicprovider-l1-1-0.a":"15b91234bd09670b2568c5e7b55b4aec80973f3b202bf59825437c60b37b45f8","lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-0.a":"502d877f0201f26732fc4a248049104e795b9f9f092d3b3f386ee148393da278","lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-1.a":"8684bb1e5507cf59e72cdb6b5c6adf60763657da95cd10207a72043e582e533d","lib/libwinapi_onecore-api-ms-win-eventing-controller-l1-1-0.a":"090323e98c1beda70440b499b27c360f8302e0ba5ae1fab8d48ba0f3037cb349","lib/libwinapi_onecore-api-ms-win-eventing-legacy-l1-1-0.a":"fc67ebc5ac0848e4a33266f88f6d78c5b4b86f52a43a909449d9f17cd44a85de","lib/libwinapi_onecore-api-ms-win-eventing-obsolete-l1-1-0.a":"9c3d8b7093047bb97af5c27b5094a85b4782dd40a65e4d09c32bfae29504b341","lib/libwinapi_onecore-api-ms-win-eventing-provider-l1-1-0.a":"9d083184f86b32bbf9f39339c8212db340bcc7204752749b91baba95ee0613d0","lib/libwinapi_onecore-api-ms-win-eventing-tdh-l1-1-0.a":"591aa0488133e53750db593dc0b5c1582dd1edddce9b3c07c645196bd15d80c6","lib/libwinapi_onecore-api-ms-win-gaming-deviceinformation-l1-1-0.a":"ac2eb3fedac7b16eb1137872aa10b3afda45f28a32ee7aa8f4e925014830c047","lib/libwinapi_onecore-api-ms-win-mm-time-l1-1-0.a":"8d31f4c9ce21d88d0331e1d721b4cca1e4dbedf193205f06ea857d2009367e7a","lib/libwinapi_onecore-api-ms-win-oobe-notification-l1-1-0.a":"65d2fbbb95fcb8a3b9dd3f383f3512a0ce4184a6e55168da3c43f2ae4de2f5d0","lib/libwinapi_onecore-api-ms-win-perf-legacy-l1-1-0.a":"f7dcae744e4e547b4c03974cda3cfca00b4c2eded5d288a01b622b1f1c8dee0e","lib/libwinapi_onecore-api-ms-win-power-base-l1-1-0.a":"ff1ff30822a8ae0489f71da371548569fd77c9d9fc7545090449a46c5a8289e8","lib/libwinapi_onecore-api-ms-win-power-limitsmanagement-l1-1-0.a":"59f2e3ceefa32e21b581421d8f53e4c6fdfda9cd9023d59a799e74d887b7d692","lib/libwinapi_onecore-api-ms-win-power-setting-l1-1-0.a":"0b429639fea442d6355d39b873ab8f2a4b434da2584be7813e4342a3029f2cf1","lib/libwinapi_onecore-api-ms-win-ro-typeresolution-l1-1-0.a":"349e6ca3c5b4bb467986317ba926f4a758384fe307229509579eabd973ba5797","lib/libwinapi_onecore-api-ms-win-security-appcontainer-l1-1-0.a":"2d2c1cb17bff1c13883b801aa7670f1794dd6035952427f50791c46090967d07","lib/libwinapi_onecore-api-ms-win-security-base-ansi-l1-1-0.a":"8369a1aa014110ffba11e84e0700c0006f9408677a4642bd1d4b9ef122734b21","lib/libwinapi_onecore-api-ms-win-security-base-l1-1-0.a":"00af2a7b42aadd401a9d8365ed0c8b544bb8ac62ffb2575c0611fe52a0eb77db","lib/libwinapi_onecore-api-ms-win-security-base-l1-2-0.a":"c0e7042956cf6bd167299086cbe250445a398f00417b5867a072c2a7a53cad56","lib/libwinapi_onecore-api-ms-win-security-base-l1-2-1.a":"1c74d3623c867e670dd3a43f6d9604a294d49ca10c8b584736775f988b7d7be8","lib/libwinapi_onecore-api-ms-win-security-base-l1-2-2.a":"e4ae626216830d21353522e0505d97bb41432a50798bb9ae2695ee4ea2d734a0","lib/libwinapi_onecore-api-ms-win-security-credentials-l1-1-0.a":"e2144642234de5f25bae8b719fbdccd34f0e83c7095f3909484f6bb572b8cd5e","lib/libwinapi_onecore-api-ms-win-security-cryptoapi-l1-1-0.a":"fe82598cf64786f69ebbe50262c92ee2e47303965cabfd46dddf52d3c29b3181","lib/libwinapi_onecore-api-ms-win-security-isolatedcontainer-l1-1-0.a":"eafca150987c4555dda05254c24454d0c035678d9dd9874a53e75614e32cbfe2","lib/libwinapi_onecore-api-ms-win-security-lsalookup-ansi-l2-1-0.a":"83b8bfb3724bfec221da2d5375675c1d972c1f65c88ce76260b4cce04ad0a90b","lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-0.a":"b3d93de7b83c76989e5be54a88fef493788b42e0269cdddb2035af5157644ab4","lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-1.a":"196fc35c8341a1e6964e164d98bcc1c1865f7751fa9b0f55445b885348d40729","lib/libwinapi_onecore-api-ms-win-security-provider-ansi-l1-1-0.a":"4b0f69acab66ce2afae8ed1a3bb44def669c3ec3e79eb1bed600eb66a8f5510c","lib/libwinapi_onecore-api-ms-win-security-provider-l1-1-0.a":"3607832456f9dc634c54f62f9015f6367a39c98545d0d1b60d76a2cb625ab38d","lib/libwinapi_onecore-api-ms-win-security-sddl-ansi-l1-1-0.a":"1b9998bae9a3f0c528cf798bcf8289912bd2747b1036739f3a421b9903e5008a","lib/libwinapi_onecore-api-ms-win-security-sddl-l1-1-0.a":"46452b33c2b9072de7931697b171c2f1c3a9f59184a1a7a728c4476a71612a95","lib/libwinapi_onecore-api-ms-win-security-systemfunctions-l1-1-0.a":"05f8bf2312e31fb15777f123e78be2635e99e9c8400bebf6858420990d82b24d","lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-0.a":"a214ee3ca07f06379f6ed1e7fe8492acade3dbac987bb9e05762ad61401477f4","lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-1.a":"1db42bfbc9470319a9e8fe161b22e174b06ef2f2ec2d98b3e6855160fd6d584d","lib/libwinapi_onecore-api-ms-win-service-core-l1-1-0.a":"963d16a443487762259857c127a1e93b455bdd659c831d601070d84fc165b597","lib/libwinapi_onecore-api-ms-win-service-core-l1-1-1.a":"381be039e2b937716a9378b04811b7f2d203043355aa0a6d665e60a16030a237","lib/libwinapi_onecore-api-ms-win-service-core-l1-1-2.a":"535892bc1cbfb57e6790d29dce29762de300187bf6711c129994360e8bc1af25","lib/libwinapi_onecore-api-ms-win-service-management-l1-1-0.a":"4676abab985cdcc5bfc05793431085ce090755767dad44e9d0f56917042161db","lib/libwinapi_onecore-api-ms-win-service-management-l2-1-0.a":"03e0749be1872a53c158eef8b9dcba7edef537034f82950527fc2d078e798e7e","lib/libwinapi_onecore-api-ms-win-service-winsvc-l1-1-0.a":"8507ec80f896c4cd292135beb33a39fc206873df7b0f85aa4efabacccd7965d8","lib/libwinapi_onecore-api-ms-win-shcore-path-l1-1-0.a":"03ebefd78e4e29d993adfb90e5adb2e674a91777d9e05981d7212fd515e2ae8b","lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-0.a":"dbf5f6b9e2c97a864dc064ebbbf34ee7f4c876fe50791894fbb825007bc41698","lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-1.a":"0b2d927ced5e272176d05ae2abfa458c2c1e8e1c7d402f3dc37c3b7cc113ff57","lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-0.a":"29c15701fa34edad9f07ebc62844ff8e0c7da7eb7879c2dcf790656729648657","lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-1.a":"823bb058035b58960d43dca45129e1c2d89c302281735e9f7397c3804700c98a","lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-2.a":"bd89d9adea94b9f60b74164b5c1c5552055263649399acfa4740d0326bc6fad5","lib/libwinapi_onecore-api-ms-win-shcore-stream-winrt-l1-1-0.a":"998dd225c130263e62b1422f1c6a07b9d6d99e761c80c2f4a22104f635166e86","lib/libwinapi_onecore-api-ms-win-shcore-sysinfo-l1-1-0.a":"ffb5112c8111c6f53c8d40f28833f9cd9b3e7f1037b6081883c9bcf956654406","lib/libwinapi_onecore-api-ms-win-shcore-unicodeansi-l1-1-0.a":"a6e0a2beb10da108f4346e44e551b65fb117a3b30db64d1dcbefc07dc498aced","lib/libwinapi_onecore-api-ms-win-shell-shdirectory-l1-1-0.a":"21d0bdfc474eea6cc0d54794591e7dffa35e3cbd46100d2d0c9af0d5fd9ace20","lib/libwinapi_onecore-authz.a":"49a58f5609fa0cce0ea9264c9e84e1901675696685a74a9e747a3924c63fbf1d","lib/libwinapi_onecore-bcrypt.a":"717fed5354b9505899ad794a2c9c01aaba0e566deaafeec46d6719b74c583ea7","lib/libwinapi_onecore-cabinet.a":"12116c8eb10af853d0e8154ae7cb0b53b4240a5084115fb24d82df6f13cbd9fb","lib/libwinapi_onecore-crypt32.a":"2319a22c1112ef3bc4f7992812945ef87593e4e42a1e1a72c70d06a30e9170af","lib/libwinapi_onecore-cryptbase.a":"acf88705ff0ebd208c17547ff41b35b5f489f59e4c37f5c8e31638dd6ca4ffb2","lib/libwinapi_onecore-cryptnet.a":"c3ce7255256fd6f0feb10879ea437c8b1caf54854d19e4c43746dd02924c39b7","lib/libwinapi_onecore-dfscli.a":"a1c83b4b2eeb361dbd82e7aa806182caa1f7386049b512764fa2b100f648329b","lib/libwinapi_onecore-dnsapi.a":"19aa00039284a9963e3e7b93f06e9f6f22f4e2f509d892bb91511b83925f9de9","lib/libwinapi_onecore-dsparse.a":"360b6e2a94e4e3f00917c4355b3181b97d965e3cfd567bf771c5f553b1e44252","lib/libwinapi_onecore-dsrole.a":"e44f0a3c7c012f3ff6e1a9074569939a596459ce865a32f346b2f192d80ec561","lib/libwinapi_onecore-fltlib.a":"431ce9d5a8a04b4538bb78e9f022720ed937c7aa255a32a803723225952d2832","lib/libwinapi_onecore-iphlpapi.a":"aafd64df92275cb714a16e5e7c3b89098c8a9b7222dd61986a6861d2f31adc00","lib/libwinapi_onecore-logoncli.a":"1a7b0a7cbe4427c403656addaff583ffa46cb3d3b21e8a293f9d36dab8e6fb71","lib/libwinapi_onecore-mpr.a":"d9851af2203bd2e135bfdcf07b30b699bf359e2552b580177c047bfc83ec4aba","lib/libwinapi_onecore-mswsock.a":"25311be32bf6762e7ce0afbbee1dcabd4d0671f25eacc81ef0df1bbda038673e","lib/libwinapi_onecore-ncrypt.a":"087dfe8b0de2be412397868c6ac3c22302f5062c49a35adf02049bfc39d7466c","lib/libwinapi_onecore-netutils.a":"a438a3673029c25ec1b11c518bb1f5998b8306df0aa57e23b860013e84c6536a","lib/libwinapi_onecore-ntdll.a":"ff8d3e71e411a1d8f93b62ff37e5aee91fc1141bb4a2d341c95badbfbfda8a71","lib/libwinapi_onecore-oleaut32.a":"bc4eda49c1613e15278f4d8a3f60aa01c59a871ad839d72fff3e93bad379552c","lib/libwinapi_onecore-powrprof.a":"ded544f89c79bbbaac63283a479bbfe0f6eda8695e3f03993538f837228586b9","lib/libwinapi_onecore-profapi.a":"58f6975302c178463b97388f58d13b5761a546c9d5d17ec77645c1a3c6196a06","lib/libwinapi_onecore-rpcrt4.a":"ed8143d7a2ebefad19460a937dbe08381346a208fc56bdc179f556385f44c2f5","lib/libwinapi_onecore-samcli.a":"3b4e5e362a4f4ca2cf09c505ade1feb5adef669c4d0e39a6efa0e258e4a45ab2","lib/libwinapi_onecore-schedcli.a":"f5d15c598ec6d8716457523b86d41ddfd012aed591f17237bd4190c1f22f7360","lib/libwinapi_onecore-srvcli.a":"fda98b9f248725979155b3bcde4118475bbeb9ac20b949632b6e25f81004e787","lib/libwinapi_onecore-sspicli.a":"ed3f3ca04a6b5b0f3c83785e40d75d9d73f4d5907c2ac62b90b0d37c304c2be2","lib/libwinapi_onecore-tokenbinding.a":"1fec2c3a85c528c8ac756c2b590446805886ce333de57fcc24a29f976177cf27","lib/libwinapi_onecore-userenv.a":"aa8e86961ec9dad96e8af293b535b18e43779cc99cf6a3262cc6ca96c18a91c7","lib/libwinapi_onecore-websocket.a":"a3192322098b110272dc4bd604ce2d90feab14393ce444358bd7cc9c2951d2f6","lib/libwinapi_onecore-winhttp.a":"ec3c64ef5b250ec3721b9c8a500e580f0e52873a0ab3071ad9a07717e898243b","lib/libwinapi_onecore-wkscli.a":"c07edd7e8b0efd63a31ae95d776f29700d8240355bda5982aa4cba1a4903b3d9","lib/libwinapi_onecore-wldap32.a":"f98ec840c25a4682b2bf3b27d7eeeedfc88182b76689bd5aa6767aaa5b31e404","lib/libwinapi_onecore-ws2_32.a":"b188d2e13765f6de978f53389512053bd9ba79434a86bcaa78151aecd1c79f45","lib/libwinapi_onecore-xmllite.a":"20e6eb39eeee75e3ef15b9a69ad11e6d665d3163686968c1a0d1a482fb26314b","lib/libwinapi_onecore.a":"b1b438f02522fa8511e7b61620d7cbe3841cecd575f9ce2d9487433413d6482c","lib/libwinapi_onecore_downlevel-advapi32.a":"48dc1206ddb4d6340addd0a57e485c20d73df8e9472c48b63d948830aadafb14","lib/libwinapi_onecore_downlevel-apphelp.a":"d861b0c9d0a9ec3429b789c491399b7f4f05552f5558a4d962e74f9a20491ebb","lib/libwinapi_onecore_downlevel-comctl32.a":"21c56dd6d89207523a0e54fa70e5610d26dac00f5f7c09845c3d1d321f9fa584","lib/libwinapi_onecore_downlevel-comdlg32.a":"0efb7387918178f59bb1a22b819a0a7f3f4c38772f633769d981df78bad33997","lib/libwinapi_onecore_downlevel-d3d10.a":"fb03e4884e8c89b2b2594389a979df0a15788b28e70e6c9141eeb273577ab4f6","lib/libwinapi_onecore_downlevel-d3d9.a":"8a7f5a3567e085d59181f1e1f9913aad3deab24248be70d7d89ee3946750a195","lib/libwinapi_onecore_downlevel-d3dx10_47.a":"da96a15d9ed6f5fc08a9fe19d4c1284af3a31714c9bcf7a90eb3607cdfc29dd4","lib/libwinapi_onecore_downlevel-difxapi.a":"20d592d0b07b753c35555e5aea48b71f199273e4cd41fed4d30e770cdb731dab","lib/libwinapi_onecore_downlevel-gdi32.a":"3b45e6f50209f32b1b00c222e57376bd1e22731bd334949eb8bb44126dc6d358","lib/libwinapi_onecore_downlevel-input.a":"d8021ed7e5dc1fe11b966a32e581c52ba672c020254870626947108c06d213b4","lib/libwinapi_onecore_downlevel-kernel32.a":"7f1a8b6870b6b5a117fe0b9ccbcd1a6b9133173baf6b0fdd91daf32ff2f3a920","lib/libwinapi_onecore_downlevel-msi.a":"3950469b8eabd579f17707f38029ff1d1d9485711b02ec516a95b99bdb1fba05","lib/libwinapi_onecore_downlevel-newdev.a":"0369225398f2d772410b3943a6635c26d5117f6711e03e49dde13a5f0db44f2b","lib/libwinapi_onecore_downlevel-ole32.a":"b5579a04a5777a471687c6e3fce7d8ebc87be0e3f3dfba3f358eb7dc3cd4c715","lib/libwinapi_onecore_downlevel-oleacc.a":"856fb87b2bcfedcfe10a104ec8a0e4275840f042efdce23e3aeea8fb90b3622a","lib/libwinapi_onecore_downlevel-oleaut32.a":"a9461245046a904f1e8ff78b7bdf00534746756a83b3e4de04e889c8c1df2244","lib/libwinapi_onecore_downlevel-oledlg.a":"d460a3f03bca729456a5e315e75af9b4cf3e79343c2bd81d827d377a4d4b05d0","lib/libwinapi_onecore_downlevel-pdh.a":"208131ebe23e8bcd31f03af369900ce7956b9a1e51bcf8be6e46ec1ff24576d7","lib/libwinapi_onecore_downlevel-psapi.a":"ca31fdd6661f575ddd7e15cf68a6cb97fa405677d01cfa00b70364ffc138ae81","lib/libwinapi_onecore_downlevel-resutils.a":"07e1b645395bef6352820aeb6867498dfecf1c576436be218e81db12fe8a3602","lib/libwinapi_onecore_downlevel-rstrtmgr.a":"87bfdc17145dce5ca717dbdd007970ab1139f7dfa7ecc17c9cb3c8cbdbaeaa58","lib/libwinapi_onecore_downlevel-secur32.a":"90d6b2fa7ff6b2e9555718c8a088614a461c5f5276fd2586cef7ee2058301e67","lib/libwinapi_onecore_downlevel-setupapi.a":"6af80ea73c581f1e21f5ac714f5da3b33ed50e9d1a9cac19e020ad24986202a8","lib/libwinapi_onecore_downlevel-shell32.a":"4b86e0540f359563ff2a81880f9fc4b40ce7f52409bcadeda2e678e1e28b3657","lib/libwinapi_onecore_downlevel-shlwapi.a":"3dbbe36f2d6473e88b1b2b6e71eefcb82bdfcbd85a09d5b96d618b0bad63d99a","lib/libwinapi_onecore_downlevel-tdh.a":"ba341ea2345143d5b1b55f264366aa72ea707ec955b1b079f47f00eabf4d51bc","lib/libwinapi_onecore_downlevel-twinapi.a":"7b18b95de7696d38c6a2bd24ab02301a95d6c856705a8ae4eb0206e293e1d8df","lib/libwinapi_onecore_downlevel-user32.a":"bcc698c26293e631b93825aa8d1ed5a3eccd0ba99db635cef2b95dfcc476a680","lib/libwinapi_onecore_downlevel-uxtheme.a":"788dffd0226fe85f4bc0f43ddf7d6d69e35e028742a8094c44c065a5a796d7e9","lib/libwinapi_onecore_downlevel-version.a":"706c173ea490ede7d5d8a3cf8a207f0a84efd3a045f8ec6e5111a36c569706f9","lib/libwinapi_onecore_downlevel-winmm.a":"b2fe34c14402f41101d658964d62f5abca5be0106f4dfb27ba630cd35d127277","lib/libwinapi_onecore_downlevel-winspool.a":"f7b78470b47ddc11240de3ab2a153e91620e281c0ca499e82a9c25dfbc68e80e","lib/libwinapi_onecore_downlevel-wtsapi32.a":"ec17d91e47de2d55dd4043318800415591832c9424cf9ed0350a4cb17c6eced2","lib/libwinapi_onecore_downlevel-xinput1_4.a":"3e0a8d45e88418b3c61455fdf91f39057108f9cd39dd5b00c41ec86c31f05f27","lib/libwinapi_onecore_downlevel.a":"9350efe517d660865703d03a12d0aea519ce286a1b90f8655f8211ba9e5d1176","lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-0.a":"208882e4e2230dd12d8b317d7a093f0bcbdc8179665778bc552fcbb898e9ee5b","lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-1.a":"91790658be1a8be50ddcde5ac956a1a56ca774dc7a690b2ef75021e9c3330951","lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-2.a":"6d7aa69999def908cd89ef1249f6c1116d418a11e897293e1aa1a716a74ef7a4","lib/libwinapi_onecoreuap-api-ms-win-core-atoms-l1-1-0.a":"f2489b312e02e70ff3b347f5a95b92fbf94ce4d4cac8dc8d2430a3ce07bce8b5","lib/libwinapi_onecoreuap-api-ms-win-core-calendar-l1-1-0.a":"1b1897310842d69519c547af2d07da04a432eeaee55809fe844cfe3bab463079","lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-0.a":"ed5f934a0b2317af63fdc5140cc369dfb6cc54f0c2ed6e6108f77c2db49120e9","lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-1.a":"9caf1ed02c8944e21ee329661d6e86525d48adcb30a0262e8bc651126fac05d0","lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-2.a":"2d0f0a22bede0f52df0eb87983690bafadab0a8cc3ab055e774f0b7e81faac9f","lib/libwinapi_onecoreuap-api-ms-win-core-com-l2-1-1.a":"bd93ea942b8ace1884d16040fbbe418d7aabcce933d9a769173dcbbfef2ffcae","lib/libwinapi_onecoreuap-api-ms-win-core-com-midlproxystub-l1-1-0.a":"0cecd6ca334de304c25b825732ecbcc4ae1f0903b92fbb07642f2b60b6e32ab0","lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-0.a":"5dd747af301bd8a87a169fb4be5b27f35fe8d641e442da9650a681bb1ebca5fe","lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-1.a":"4af23fb67510708febfca2ab3c88b049cfa72dc8209ce3b10073345a2cc90ad4","lib/libwinapi_onecoreuap-api-ms-win-core-console-ansi-l2-1-0.a":"0d5642a37f8c438e8af493d14ce2e76dfce51fb77aa9e657b28883d6dfef105b","lib/libwinapi_onecoreuap-api-ms-win-core-console-l1-1-0.a":"6b8a4dab5532b978cc0b78a75d7e617041f70275ffec6c3ab2e09bd257490df3","lib/libwinapi_onecoreuap-api-ms-win-core-console-l2-1-0.a":"9b43334c98f0355bade21041cd010435f87f4a9f8ae2ff2da1daa77a1c58c7c6","lib/libwinapi_onecoreuap-api-ms-win-core-console-l3-1-0.a":"ae6bcfebc7a6e9d24a91f712e67e345c3716174ac13a1b086139d0dd42fc3aa4","lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-0.a":"def26a1441d88fcf69a0cf71f2f37f585585027b181453ecd66b500869c1325e","lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-1.a":"796cb7d7094c8cad58a4feb4d23659aa9931a4006fad2d95cbff1821f4590844","lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-2.a":"81937e6fa94d1212375e5c14e3dbc5b9259f693bd657c198f1294e84670cbf83","lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-0.a":"1e4421bc92825052e1c6da76c5fb9f0b3b7b9e59e8297acf476e264a50f79b59","lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-1.a":"57b9316068a5a96938f30e7f6f23e720d4812e46a7cc4802135ff09284177f21","lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-2.a":"780fc66e5b9309f137092b8b0a4d0bdaa2b8f45d89d9ae8b0e9f2bc29e69c424","lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-0.a":"6e350ff7b3c6329df2be85d6d709fe666742318019079a88e385a180500793bb","lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-1.a":"3e718e8e2364bdcd6730ae57e138c09234583a2e5ae232228f383e3d040af377","lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-0.a":"97552843d0f8b760db838172f22d443a491bc4885c35de15f4b3d579b373fd31","lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-1.a":"cd81f5d09d6fb6f4125fc2770ec5086838ee72f0daf8368c392d51f5320e66ba","lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-0.a":"f5b5904942ebb75a537ed4618b917b0d8b762dac20da0a0c0de7e57036fe72cf","lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-1.a":"eed735344f097f222c660379acb00aeea935e730abf2253f9a4a26993c8fd344","lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-2.a":"b3690a5e72008de4c4a8f82b1f5e352ae987f11229df791f6fdfc7e0ee862837","lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-3.a":"4495bcbe1eccbf406b59a8cb55d3afbb8af8db728808c5f30d2a6be9727e91b0","lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-0.a":"43e391c884a4a4f2b49c27a211d69161c24f6b916e9da7d171da447e8916493c","lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-1.a":"1f8415d190ccb338224387f5319edb3c99942e77ff78808b8e2d07bf878889d8","lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-0.a":"da3f54a70d3ae49cd4f1720af4a60f17840f813903cf906ebbc30959396173c8","lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-1.a":"b0216bbabbd686401ad98754a5c049d8960d57541ae77a3d20358a66ff9adcba","lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-0.a":"d45a173aa1f26ec0a4e43d6c27da3a7dc7a96917f9004f1b7b79ab612ca28975","lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-1.a":"eabd8fde033e5a57b6c0b9a7c12c260de1d83394bc89d12c189f8e5717870e13","lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l1-1-0.a":"fb58299452583cd8a8ac33d4bc5e9b7ebb9ac1e3f2028bdae5359cda166b3f1d","lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l2-1-0.a":"ad8c10b9fd3fc027585c1d687b79b0e69d70600d44b9ce90aef6a66655a5d8e8","lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-1-0.a":"199c464c17bce4d3dd0bceab0451a0cadca8aa1e2437be72f2f7ea6ed3fa93b1","lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-0.a":"6d356b9052c0239a2ac548b2df4dbff1b4e6dbff31044ce2c0327753983e8e50","lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-1.a":"4cc9d17c3a077bd35e3828510d1909898881d0b25c3affba7f456ddf113c63c3","lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-2.a":"51501263dd66fc8121864da921eb14c0900b189a822ca1adfe47f1311b902792","lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-0.a":"ab6f71c8c65ea6e7d513750a01626faf3175339e222ea54968e0ff0ad90a8b45","lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-1.a":"b9314710e7a45bc933aea2aa0e57ec45167ab20fa09d747aedbeb097ab36da5e","lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-2.a":"70479bdc939f5817083356c93964e10ec375829b1863ab538886b39b00aef7db","lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-3.a":"9127441476b674a7a73f3222accb5be3dcfa63fcb7f1b95b6edcc93e6a652f48","lib/libwinapi_onecoreuap-api-ms-win-core-firmware-l1-1-0.a":"14c5e5fae456396c87d962a22cee320231ac759ce842de4bcf9a457b22cb0eac","lib/libwinapi_onecoreuap-api-ms-win-core-handle-l1-1-0.a":"7a5de073a89c411e4679f8b6796a7201a9f276bde8119392584efd788b3f8e89","lib/libwinapi_onecoreuap-api-ms-win-core-heap-l1-1-0.a":"1370ad95210fa9dd3e3aad0ab7caff8439ca05d0ccb6b3941fd7d26cd03ba6f6","lib/libwinapi_onecoreuap-api-ms-win-core-heap-l2-1-0.a":"7a497a59068adc9757ff546a78dcfd5c27184ff4ac566334baaee95cabeaed97","lib/libwinapi_onecoreuap-api-ms-win-core-heap-obsolete-l1-1-0.a":"0f64537add3fac2532141036a963fe64a98b5046804df3b685bf30986a0c2f0c","lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-1-0.a":"0d196cf294402e3b8a50eaa3413756b034680294c6b91bdda7547f3cf6f9c579","lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-2-0.a":"ca050c2d460caba9e6978b1745b22e0932c0ac148a06c1a1612eb08e512eec75","lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-0.a":"ff28edf42698b4bc72ddbd143062132908c614536d60a732ba3000940b5a85f0","lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-1.a":"93780a27ddfc82d162d7ab804a760faa78b5904471d8c36af19937d967457829","lib/libwinapi_onecoreuap-api-ms-win-core-job-l1-1-0.a":"a97523d85a93bcb4a6c857f115931afe45020769d7667759ee7038304b955311","lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-0.a":"c44d11b52b83661540fa32202b7c7b425aee93b94381821325c292c2f6124fd9","lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-1.a":"8325c8020cc66fd1baaa9e2d2c2275b14ca6245183a5fd2c38aa67ac69a2d99a","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a":"f25ff2bd0c4f841a4d48895c22b0a883eff15adc3494075d3a481724ba904998","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-0.a":"3348ace857245ff8567ee5eef16d0874da46e154a34db8045c2ebbedd6148e15","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-1.a":"9a753479c78dfd40aa71452860e294ef02204828d7743d18552bff78417eecc7","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-2.a":"6ebd97e5c62c047022a761b3293d51c864c40744473cd26bb14d24dcbe5028f6","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-3.a":"036f12e35650d8c350496613a856c27da923a24ab802c0d9657d7af8fc0cabd5","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-4.a":"a30a9756ec2296c149c0a463af96addff7cb6c0d00db847a5c9f77f1bcd6b655","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-5.a":"979f0d08708b6f80d1aa452a5a387f0d4311c76d88b5dbcadffe66d638cde66a","lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-6.a":"edc5f8763d03d84025dc7e083d698893cff79920e36f239de7e18f91bad6ef99","lib/libwinapi_onecoreuap-api-ms-win-core-largeinteger-l1-1-0.a":"e36f5ef88232466f1bfe08402d21c6ff1562bcd2d630387d45ad1187dc3345b1","lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-0.a":"caca648ad69b3f52c628e977c18f149087f5777cf0079546f92a2414887b2d05","lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-1.a":"93ec184d7ab34060ef1db49cd2270e80e95ee217bb5fc481946b51dba7c75339","lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-2.a":"c5b4969372c801175c789b3b90f23d296b48922084fb2a3e6de34bc76f0c4452","lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l2-1-0.a":"1a85b7be572525b0cd28edaee04b97c1027090e6d67273328113894c7d9d60f5","lib/libwinapi_onecoreuap-api-ms-win-core-localization-ansi-l1-1-0.a":"e1b13deb0d9f7aa240295a87cdcc398edb816e0c2b8d72261e259b17577d0496","lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-0.a":"8c7dbfc3176c0bb0487c7ba7a9d04036b5600c7f124cab8ac3e4ddacf013c875","lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-1.a":"34b04e8150846ee19c15ac417555cfd3a712cb4fadc564d6a9cc7ecd6c174f23","lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-2.a":"fec9c576052f90d882c90e0e2dfdb717f94a5cfae111db76246e560501dc9c81","lib/libwinapi_onecoreuap-api-ms-win-core-localization-l2-1-0.a":"edc59db7005da93b96bb2e1eff6e6de2796f5fd6d0fb02a95ead84ad3d679996","lib/libwinapi_onecoreuap-api-ms-win-core-localization-obsolete-l1-2-0.a":"2b9eebd89310ac43ed54dbb9553172b36757a5a51b59ee5e14c31cfc8210d78e","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-0.a":"097862322accbc132b0b753698cdfd33cc68b22643f994bcf5b2fcf02c0a3dd8","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-1.a":"fafb08266b6465d3b283b5dfcc1924507e84bc0c0d658f3b111a237e88284791","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-2.a":"4d0dc0b85d99ec900d64193039f6442886e2f7cb57a45ca7de62b9c1c5738860","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-3.a":"40a6455f8fa2d5124cc69bc89de96a238b6ab3c83583c5ece746b281c70dc426","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-4.a":"59da5b17fec35fd627ef32ec5333c93bfc3cf71be9c78fc714ae0c695d628cee","lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-5.a":"d104bccd2274b6bc0f51c06489822ed46d3395c77ea421276f33a4be45847867","lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-0.a":"d8530787e73d174403d40232a09d0f01bae47f8d83c39cd6d818e8afed18d640","lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-1.a":"acb7f179f7c58f93457d17ac57feaf18deecc7c43a718c9e73bb895e7433244d","lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-1-0.a":"1a099dba3ab2aff0de9b82afde85e02d8f52ce39a5fc049ffcf9c0e6055e1be0","lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-1.a":"daf2d469a631f337a749317cc282f8ce30f84cba094fc61506472bc2418784a8","lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-2.a":"76594e230e567f5f12379b7319e35ee1add83f51625b156908e87a63ae781895","lib/libwinapi_onecoreuap-api-ms-win-core-namespace-ansi-l1-1-0.a":"2df4f0d625e6313eb906f7fffe85e951d877d6bb063d6e51b93a317be2b7b474","lib/libwinapi_onecoreuap-api-ms-win-core-namespace-l1-1-0.a":"088eeee18edd58dedbfceef865fc38c32024eb9bf59b960b657893d89b242e46","lib/libwinapi_onecoreuap-api-ms-win-core-normalization-l1-1-0.a":"396abf7a271322dbc05f49e9b2018d8d2bddb0cdaa8d8885f5d1f1ba0103b188","lib/libwinapi_onecoreuap-api-ms-win-core-path-l1-1-0.a":"d9beb78fe6740ec2c31d8a6982da695fdb293aa0bd26726a1e73b0a71605fc9e","lib/libwinapi_onecoreuap-api-ms-win-core-perfcounters-l1-1-0.a":"d8c8f703a295f6c1d6e5a6cc7eaa06f254ca31eb02f5acf2b3189d98724b11c8","lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-0.a":"44e2595ba027013f8638b3964bf49051e1c873fb9e43bf869967701074b001c9","lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-1.a":"c32cc3af4fe8f1df5e4f14e3a0a9751a7493fca87cf2aad5c7009ed2667ab9bf","lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-ansi-l1-1-0.a":"42c74a8f731111df9aa02616708a9773b53d354898588d46a9592e6431bddc0a","lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-1-0.a":"994978a054487a2549dc794a0135ad806ae747085bb46b169850c19feaf48f0d","lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-2-0.a":"d32d2b2a6fb33136b6f982b03526efd6357fa95e8e68e0c24c429f906e2133dc","lib/libwinapi_onecoreuap-api-ms-win-core-processsnapshot-l1-1-0.a":"999d3c142a4f09d58897dd1862f0e3f3d01adc6426ed6858ae14c64cad2abe1a","lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-0.a":"9900f0ab25eca8d5ecdabcdcdd24c2d741f8be6cac29e7fb137d47bb303f1942","lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-1.a":"42c4aae5bb149898ffdf1db738ed2eb34564b2aaabd3580a44f4c40670cea7d3","lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-2.a":"cbc354e5975489e90efe70d05fa7eaedc5625b48de0d8d7c42834a8c72d350db","lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-3.a":"d7787f9e7e25a936dbaf33e1f768ed9edbd76a45bec7898a802e3b46f5046294","lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-l1-1-0.a":"0ee0eb2dfdbdf642645168cbf4df1004c8514dbcf4fcf68455170830039918bf","lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a":"fc787ca7ea17bd41447e8c7856f58ce1463132a7f9197cbd16fd21d51d626455","lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a":"3610f5a44c1696800b731cabd502ab9d674ae5e466e77e8cffd752449def98bf","lib/libwinapi_onecoreuap-api-ms-win-core-profile-l1-1-0.a":"8175c06e4065023e1d83a794458f668b575829a462859c4a9cdb1b317c417100","lib/libwinapi_onecoreuap-api-ms-win-core-psapi-ansi-l1-1-0.a":"cf60483967f15bb48a8104fea73abf63c96bee46db6436c5be5baada0bd65b5a","lib/libwinapi_onecoreuap-api-ms-win-core-psapi-l1-1-0.a":"ddcd4ed25ba23c6719b4d3143299bd3a0d3319aa66bcaf8209e91edc31e33f77","lib/libwinapi_onecoreuap-api-ms-win-core-psm-appnotify-l1-1-0.a":"05ecfb5ce0f45ba854917356d2a90b8c8933d4697a34aa7ed3df424ad5777f68","lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-0.a":"4c8f9adf440d7d69732e0f8caedc22e8cc1e6aa3e9949084f2ad6d3cfac40202","lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-1.a":"923e8bc57d1196eb3acb217a0f73b09886b1e0c8656de744bfeb3b4226028d6e","lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-0.a":"36b66d1781bef9d74b1996b194642cfb12e21e503fbc796e5ad27e08e858e13b","lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-1.a":"85e2bb960d2cb17a6fdfd14d745cffa998c5c16de55e0e5399009c0da9bdfb7d","lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-2.a":"b21f1b497c03ba20cc30b9cf5c53824c93e542e74d05b8f8e7803c8fed674946","lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-0.a":"f9fd25609615daa0c846bbccb1e1afb9df97457f3523928f18879cfc144bdb90","lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-1.a":"029da1015d4150f207086cb60e457e4cd0a34dbf7a3b264b9b8bd348791dda05","lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-2.a":"4e782b6afe5855007f30450045e421a35a1bbb61dbe1cd435ad228797b221895","lib/libwinapi_onecoreuap-api-ms-win-core-registry-l2-1-0.a":"1af46b02de30fc3183bdc8186a7ecc81461748cf22d05ad375ca3b436782d9ee","lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-1-0.a":"0fd519fe8af39e22c1a39ec37690b52d114591cb79e289351ed2e0d230dcecf8","lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-2-0.a":"74c170e870b9c767c3d0908f7c02f172dea37b2c2309701bc456f7a9ba24f6f7","lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-ansi-l1-1-0.a":"28007b4f34f31ac5d0a340e759957598b945d7315b2ffb5fcfdef34831498899","lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-0.a":"584dc53a4aaad360864d643575b1197dabedf3366002c62fded126aa1ceb2794","lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-1.a":"2bb92bb8c085be0d875b73c8b0dd923862827cb1f8ffe775dc5bbb54aec8a3cb","lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-ansi-l1-1-0.a":"993aa0e559d8f069fe0e0a1179dee06e597e2bd3d02876f1a0082f37c729a30a","lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-l1-1-0.a":"badb929faa6993e9f2bb6b7fa26259ad8c7abbda8ba3d42d2e8ecfa453fb7eea","lib/libwinapi_onecoreuap-api-ms-win-core-slapi-l1-1-0.a":"f320eefb3763cc503aac9fbcc0489f38a939e3b38db1d39719e570717ea3e476","lib/libwinapi_onecoreuap-api-ms-win-core-string-l1-1-0.a":"f3037f023ee2c8578417e29cd698be3f7df598a62f3e6369978e7037be7fcd62","lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-0.a":"c0757666e6a507d0c4fbc0b50902326712ce6cc2f4a365f94a890b564c9a94ef","lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-1.a":"fac6581561dbf5794fb62c8fc43267274ca07a08213c4c93bdccb405ee23bcc4","lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-0.a":"a1cdb22e603571bcec39c1a5547600528cf89d28ed87d3e9dbf8caddc28aac7b","lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-1.a":"e66d86dbf902d9dd57734339a2129f921bc62d490ff524a5bb8c490f1d994425","lib/libwinapi_onecoreuap-api-ms-win-core-stringansi-l1-1-0.a":"7d9dddea1019f027215c65209127ccce9c221ea4cfab79405502920bf97fec17","lib/libwinapi_onecoreuap-api-ms-win-core-synch-ansi-l1-1-0.a":"c9c244acba6d4fa1b367d6d6e6f2673b4c256e2f6e02cd0b651f254ef1da78b6","lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-1-0.a":"291d20badb0ed98dcfee4b61a87ca7de71d91cc2f5fd5210c64e0495610ea422","lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-0.a":"2891ffc03c3859f46872611e6003078443a0f05245dcf5bb9d77f8dd3748686e","lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-1.a":"a7a8108a8c26843eff1c9a48c28b600c42f8431a488e13fc8c0839671fd0666a","lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-1-0.a":"52e2a89087c219765f2dd2fb898466a01df2f9fdaef7a84e6e0a16b144121940","lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-0.a":"1b107fa62b4b75121f42f9bfda4f304d1febbd83193309f0585dfeecdd207d29","lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-1.a":"1af830ba3ae3c3790c77add6643305401172fc4e8a088bc9f6be4a888c9072bd","lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-2.a":"b33a8c59f35e5843d016b58c6edbe9a58a9c81aec1324847fd86a612cb038e24","lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-3.a":"fcf4b87d9d11784559a9bc4c5b06366dd9784be852ec7a0235a3e247ee506df3","lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-0.a":"7e07a6e2854593a0edf944ae6d993ca9fafee53fb5185ef70b0ca9765dd4a288","lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-1.a":"6ede88a05d440fa2d9d5ee26e8645a2d31e5e05662b975b4e1c54dced4d21d91","lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-l1-2-0.a":"be01809a2c48a1be2311cab632ab5979983f2d15e84161b44734fc9372fca2c9","lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-legacy-l1-1-0.a":"ad6c73e76b6e6af4746968e218bad365d42b3882c5352d449071b14743307ce6","lib/libwinapi_onecoreuap-api-ms-win-core-timezone-l1-1-0.a":"59b4bf42c2cb3243cc36728b6612f98956fdd99aa774acdfc277e393cc70011e","lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-0.a":"4587831f353137ea730c40920e0a2d19645a868e76c41242462d734c6acd9756","lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-1.a":"92aa37a2a7b14d0142d591e5f34dc2f15d19ca8073140e97a8bbd251017b3c98","lib/libwinapi_onecoreuap-api-ms-win-core-url-l1-1-0.a":"d7fdea9b8e4f30d68c3457952429670b7fa85c88ffab3652517d6b86e24d552a","lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-0.a":"6f5cbf84f6bc55c73a4d3bfe56ee7cea780a66647d8f9c4859fabd59e97952f0","lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-1.a":"5c768687034e6bc0bb740ddf3399cac95bb78e81cef1c195562c36c2198f1abe","lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-0.a":"9d549df648d09ca88023c8270d1039564ed6033f2c834b98ae5b8de81f6350c7","lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-1.a":"fcfa3edeef60bb20e4de99753123b69ce693f7a33b1b25ab9c998f7b4f4af7e7","lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-0.a":"aa56a4aabbad386571997c850488f8024f079ab10cf29c3f5018435e74280739","lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-1.a":"bc9e01a2e3e557cce8d365f54f0a1c4467e6da12524574f6884b1ff772fe3fa1","lib/libwinapi_onecoreuap-api-ms-win-core-windowsceip-l1-1-0.a":"b5037bebdccdc4636afb830078aa6fc78d142d5f4e4c069462a400106590c29c","lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a":"442a64c404179f700fca3b620f4aeaefeb2f761d45fea88f8c289658355a56a5","lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a":"8cb856aa014e3176b38f81cb98455b137597dd454aba9994544bd8d06808e0ad","lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a":"bbf701fbf1a80d36acad75ba68f840623027872e8d0885c98932238ffe8b5c12","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-0.a":"a5317cc287f2d8e822e2cf5c2c3d906b39f13603bfd001f83ba16c8cff2e5667","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-1.a":"3c861782bc5bc28c0332e3d3a9fb1a82dd625fe0622af2ae8c6ce355fdc97b64","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-l1-1-0.a":"024505f5b3606fd9c6a6e6b9f1f2375a961e87ea2955f251ba7c87f665bab7ab","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-registration-l1-1-0.a":"311a0cd15ff274e5da94d1450635e2ac1ff80c769f4d6bb248a1d1c627f98165","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-robuffer-l1-1-0.a":"fc830efa784cec9681b78ba985e7676948004763c3e005daf5dbf4a76f7fff2a","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a":"e85de983d19dbf0eca5d8ba1f15c22a4345fb5ee91b1b5f17bf54592e83823d2","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-0.a":"60c9ef2a7ff31e2c329add49379ee3df011f97d28f08b86a00d8dfb6af3937ff","lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-1.a":"d277c8f1d589ae2135519b5dcfaa4da6f3e81430e7e0b653637684e81750d414","lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-0.a":"43ed6811af9baffcbe6563cbfcf7098fe882d57c4de63f6f020a190cdb372f49","lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-1.a":"37bfa87f4004ed6e9d485815f858ecf87da18bc004e4e5b6195d5da8e9628e7c","lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-2.a":"b0bb3c836cf3f6b5079881fbc13d7ae0a29bb183121428c616400beaabc002a1","lib/libwinapi_onecoreuap-api-ms-win-core-xstate-l2-1-0.a":"41eaa65110287a9464924629fd20efc322a72682f7497eca0691ce8253f5d37c","lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-1.a":"791f257672dd55fa79dda0009a63ee6239045fb973df8ad1130c00303dd808ce","lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-2.a":"95df360f764e15b615fbce0cc242b0ae6a3065928de31be6d0f3d4e3e3e3ee9e","lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-0.a":"a554ea50453252787740f501cd7a40985070da4c6b5b097933f96d01b20e8f3f","lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-1.a":"298fb5fe0a10116fe88c405f42a3e7bc21c051b6a87de9e80438577319f635fc","lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-0.a":"058b5f62ad4dfa972e1d45797e1a8693508c082c3a7ad66713c98d4cc0703689","lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-1.a":"3da5018232fbdb7d941e248e167d5f2c19585cf6bd872a12c32de58d55eb7c30","lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-2.a":"f032334d1603206c061405a6878a8baab0b7acf002fa537dbdba1ec3bfaa1818","lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-3.a":"5eef46c15cba4181037e204b498803516eb7a6ec18af4fc43e229395bf2a6b1a","lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-4.a":"e6c8abd4a28d996ff487e32ef92d606ab3c84f45fc9926e3ef548695d9efb5f7","lib/libwinapi_onecoreuap-api-ms-win-eventing-classicprovider-l1-1-0.a":"a69661d64a7c2398c03d521e0213f851bdf8cb969f02a99051e26a5c540cca47","lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-0.a":"a96ce246518f17897a2d1e7427d0c3efed740e53cb743eea81b16472c675046d","lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-1.a":"7146a9646aa0031bd7a368879da07d30c27e922f11de8d36acd08a7ebe1938ba","lib/libwinapi_onecoreuap-api-ms-win-eventing-controller-l1-1-0.a":"1b0ed3d9c8ba0b3486d3ace7e91d6a9cf59be0f59e6db299ef2a832270d0d799","lib/libwinapi_onecoreuap-api-ms-win-eventing-legacy-l1-1-0.a":"e0a32a81dbbde1b9b641e68603a9c160b7bd1e6b07c5325c681c590697977610","lib/libwinapi_onecoreuap-api-ms-win-eventing-obsolete-l1-1-0.a":"b9ee4fa1e5adcdc9cfdafec75d75fa42eda21ad976017ddabedf94e8df60ba68","lib/libwinapi_onecoreuap-api-ms-win-eventing-provider-l1-1-0.a":"70d16559b1a3706d53a787e0735bdaedd7dfdb6c594d72ede3b437e953de2598","lib/libwinapi_onecoreuap-api-ms-win-eventing-tdh-l1-1-0.a":"5ac9ae5f9757476280440b30a65e9e7cf99e72d7daf9b010cd39afe5b6d9165b","lib/libwinapi_onecoreuap-api-ms-win-gaming-deviceinformation-l1-1-0.a":"9b2c3120ab0d4ea1d3542f50f4224e8da43e807fbdaa7f6b9e77310c3e875698","lib/libwinapi_onecoreuap-api-ms-win-gaming-expandedresources-l1-1-0.a":"1e0bfd59214f3c0342d704d74b72b9668e6898388c9163fc5efbd7f10e05fa9f","lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-0.a":"41261c397970104547f4abfd1be9247021d69f74176e22fb2de9f28e6a954e43","lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-1.a":"012e835e10cff03ded37b67e60de23983e131125dbc9581a8002a0cdca177f6f","lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-0.a":"5d59468964dbd7ab046296e4f6486e77ff111fa845ced7de61c5a0883255b2b8","lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-1.a":"2d4b4edd5057460d3896749eb75d009ec7adf15be62f878d792757ea785216c3","lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-2.a":"80412694d39f6110a5d1104839c3e750dca6ec1ddb1904e832564fdef92a55a5","lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-3.a":"fbe27441bd2787d535874abacdf2d31700a9f5334d708e3186f3067e651d9b6a","lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-4.a":"e1d5380c0b980bb1b07726d3cf4f2a02fcbc0ab88e954b4d1baf7f6d7a733474","lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-0.a":"50d5e4e1e9659baee3d1225659c102deea61d72ce812593715d49f35f4c1b090","lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-1.a":"6627afb481b3acfcb47045321aaa5e643aff3788490ced6a503fc973b6d701d6","lib/libwinapi_onecoreuap-api-ms-win-mm-mme-l1-1-0.a":"83d3cc59c5623f446ed2f4d21f5daaeab0e375b2d601576553e4da193e657d96","lib/libwinapi_onecoreuap-api-ms-win-mm-playsound-l1-1-0.a":"34376861728ccb4680372402c3e1f469d21a00dc396d4df143d5185aa8f529e9","lib/libwinapi_onecoreuap-api-ms-win-mm-time-l1-1-0.a":"e7a060c94e7076d45a4a4091825ef970869d2a54b3627bc670bfb8092a20d725","lib/libwinapi_onecoreuap-api-ms-win-ntuser-sysparams-l1-1-0.a":"2a44f39da22ab5b0ed37dc5e9562d42db9cc9d7e600b37ab0adfc4364bfd82a4","lib/libwinapi_onecoreuap-api-ms-win-oobe-notification-l1-1-0.a":"002f4467b7f58d7620b389ebd6d3983562ed859d527274bbc844d293539a1490","lib/libwinapi_onecoreuap-api-ms-win-perf-legacy-l1-1-0.a":"792efb6916e2cb05f7a443fca19d03943495e939b9aeea702ffeadfb399523d9","lib/libwinapi_onecoreuap-api-ms-win-power-base-l1-1-0.a":"e561f70c0420c63f20d1aec5ff2af3e744bcf4a8bfca6a1fca49bdf16e8f9e62","lib/libwinapi_onecoreuap-api-ms-win-power-limitsmanagement-l1-1-0.a":"40dae4c8443ad5839f8d04f82c293998b9ae1f8ac42a71924bae9d6c8a0ea0dd","lib/libwinapi_onecoreuap-api-ms-win-power-setting-l1-1-0.a":"f38422e9864a986d4779217c30e6be45e01c31255f7e46c79442d2db191d50a2","lib/libwinapi_onecoreuap-api-ms-win-ro-typeresolution-l1-1-0.a":"fb464a3682905b034a28e87d7c3fa52fe40b3d8974c5ff2f2a8366bd09a44773","lib/libwinapi_onecoreuap-api-ms-win-security-appcontainer-l1-1-0.a":"97e800780d16a3f303f192160406bc0718d5b0489cbdd9ee0051f02bcb9bc32b","lib/libwinapi_onecoreuap-api-ms-win-security-base-ansi-l1-1-0.a":"e7d2ca5998a14e92f06b0545918f42537d2463a7f90aeb8bacdea553c94582ad","lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-1-0.a":"8ff1ee61e01a1a7c5c5be07aa83c79eacc0987ca9d136bd64e183cb43c6b496c","lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-0.a":"1aa8bd19d74445826bb01cd74fa35fe9c4fba40a14388d9f179bfdf17ebe6f26","lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-1.a":"5afeadeef24773505904bc67250964fcc0c34bc5090088866a85e0dd463c5943","lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-2.a":"47dc7722b5899f6784d0de8799739885836f4c7753b2997f0692ebcadc7bdb0b","lib/libwinapi_onecoreuap-api-ms-win-security-credentials-l1-1-0.a":"0ff5ca478d2d34c9e54ddb2b19a95351b342d64cc110045b2cac78e1cf3525f2","lib/libwinapi_onecoreuap-api-ms-win-security-cryptoapi-l1-1-0.a":"c4efab90162893f22bcb1537ec564183b15917df952f81343a6315a99f014816","lib/libwinapi_onecoreuap-api-ms-win-security-isolatedcontainer-l1-1-0.a":"66d1d8b4c1d84ac76730df213a3f069e5bfebba5c338b9d7c17a51254ad6b780","lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-ansi-l2-1-0.a":"ad470f69c2d9486c92a96ec928fcefea6a2974855cc381309ca03f0f9078ccb7","lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-0.a":"0165762604948743fd61ee01b032fb7c8c6ef7dcb9f1edb109cf1dfcb11b82d4","lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-1.a":"e005dd2fd576330c8b4625219ee0014902ca6f990a92dac83be1a53722c80f4b","lib/libwinapi_onecoreuap-api-ms-win-security-provider-ansi-l1-1-0.a":"5ab8ea352510350036e7550d4b3ce6ff6cc49785063b65cbfe164bc7582b9b34","lib/libwinapi_onecoreuap-api-ms-win-security-provider-l1-1-0.a":"eadd184eeed25c2f689548611c17795c4ec7f14826fa9ebaf4181e9b14a410df","lib/libwinapi_onecoreuap-api-ms-win-security-sddl-ansi-l1-1-0.a":"03559b78a5214ed4f83dd341c0202700d69ff4acfe577ae6b92d4c862af590f8","lib/libwinapi_onecoreuap-api-ms-win-security-sddl-l1-1-0.a":"e04b7ac2b9aafe32392f30d03ecc836b39ab2956f98f4b6f13ea45e7cb9083de","lib/libwinapi_onecoreuap-api-ms-win-security-systemfunctions-l1-1-0.a":"12123b9729c86c8f4bf2e924908ed751e2f6a984c62141acff9858a3ea3da1f1","lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-0.a":"70189c4736b78d0b9835feefbc77278f4a1fb79630d3bd8c79e85595b4a4e8a6","lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-1.a":"a372303d42971dcfc465e226c5bf635e23dbb7a4df8a100e6b1ae668efcfc30e","lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-0.a":"f9c50e32ff811decf56451868b8f2a08ec60fed80b5b6abb2b1b37dab442479b","lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-1.a":"793d6d2e5d708b611c8c51b995eb26447f034c2f8f71804f26ab3b7eb5b4ea7f","lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-2.a":"83e215dbdf6191426ec5974569fdac9725377933761ad73d51c0733f5312f160","lib/libwinapi_onecoreuap-api-ms-win-service-management-l1-1-0.a":"2d7240b34c6ab9b95d0b0c638baa254e7e174767d64d98a179e7b246a4cf5ac3","lib/libwinapi_onecoreuap-api-ms-win-service-management-l2-1-0.a":"060d20b241b8c0bfd28ea2ecb5a4efba76e2e77afc4388c42450ba18012c8f20","lib/libwinapi_onecoreuap-api-ms-win-service-winsvc-l1-1-0.a":"5e50383f61a8fdad9d0fba5e001933a17269a37d873428d3467b667c56bc6f14","lib/libwinapi_onecoreuap-api-ms-win-shcore-path-l1-1-0.a":"b121dcdc4e0bc485026d367c6b8f2322a02708b5a9aff2d156d6af3ed643c0a0","lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-0.a":"59cbe50f08a2c522a39d119ca3a3e9fb58cebd802b43f0a9d1e30165865f2cfd","lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-1.a":"bb99fca97f8654df71f7d39835cf067027a13f494c727c088f5bb24fb8e7914b","lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-0.a":"132711f478eeeb8c13178eae7a4333a1dabe173cb290dafc1e63029d8ed3bf30","lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-1.a":"c101777b4e550af3154997d7084e011535fe1fcff63fc1f308b56d5460a61da6","lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-2.a":"851ad8f0e7e429ce19970c01c153847ac623331654477ca2471702afcda7c824","lib/libwinapi_onecoreuap-api-ms-win-shcore-stream-winrt-l1-1-0.a":"4beba4de71ef8d8e594d4eb11847a4b4f0b4af39065ab2d0514dbc21d6ece6b0","lib/libwinapi_onecoreuap-api-ms-win-shcore-sysinfo-l1-1-0.a":"903b8e5f31b2c0a7a51a1025068e776239f84d5576998e34b59a6c8c26b9076b","lib/libwinapi_onecoreuap-api-ms-win-shcore-unicodeansi-l1-1-0.a":"664a323b72d24e364c71ed70882f5cb88c3bcdbecab910a8011bb1d9b3db03a4","lib/libwinapi_onecoreuap-api-ms-win-shell-namespace-l1-1-0.a":"8d834943307f112bb5aafeba5a827220d46c2a98c3b3265db42c5c59208f1455","lib/libwinapi_onecoreuap-api-ms-win-shell-shdirectory-l1-1-0.a":"b2e7c8daf52e57e635ddd1968a5772a19d0224479d1a3e968c4c9ef388b113be","lib/libwinapi_onecoreuap-authz.a":"e0f0da30836359036e4eec83e11a38a613a91607b98372d3dca8d1df132d49e5","lib/libwinapi_onecoreuap-bcrypt.a":"b868acfe9f72de551803d49fa3cc69e4d96144d056a2b5d504453a17fef5972f","lib/libwinapi_onecoreuap-cabinet.a":"8542118dbca3daaf1c20059b5cf51fc217bc8d07f9be9371b73008a850eaf2a9","lib/libwinapi_onecoreuap-chakra.a":"996172c0c7155ff516e495530d1ac6acbd121dca5c1d31470c6d4ad0b8d50ed1","lib/libwinapi_onecoreuap-coremessaging.a":"4cd12df5bf31689a1a6224ae0c5b33c2d163de405343e496e6b878dd2d1f61fa","lib/libwinapi_onecoreuap-crypt32.a":"cf03822b1d0a289625f4ca5808763128bdfdf3211a7d98acbc70e351161c6de2","lib/libwinapi_onecoreuap-cryptbase.a":"669510bf3c470a2dd3d1006df48570af0b955a7db9fba70a7e3258e08a499c29","lib/libwinapi_onecoreuap-cryptnet.a":"881273b4aaf2d960a204125ab8effafb218a3b0c5c9ed015f00b23939ca825d6","lib/libwinapi_onecoreuap-d2d1.a":"5f241921ed594d78c66a70e2b8c81502a2ded3924f5ccd3a1b26599ef9128038","lib/libwinapi_onecoreuap-d3d11.a":"1b65a3d086ebd9ceae0060310a2336eae0df09e46d3e2ea3ad6415a99e4366e7","lib/libwinapi_onecoreuap-d3d12.a":"63ff81940648454813139c1f03ab0d4bcebc1b00a3a695cab8a31e0519e58aa0","lib/libwinapi_onecoreuap-d3dcompiler_47.a":"d1e48f68f3fd48eac3c440f3d47c4415fba29840f9cafce61b6f9ee5ed2d6701","lib/libwinapi_onecoreuap-deviceaccess.a":"426276a40e8cf0f39c15b6696e3877391599420894a4372c127375eb30acc4ed","lib/libwinapi_onecoreuap-dfscli.a":"a952b4318eff08d4bb48418b2a7f9fe47c342d29130d82d0fdda4b35b939d574","lib/libwinapi_onecoreuap-dhcpcsvc.a":"e14fa60521ec4281a5563bc541009ea65eca6ae8f2b27bfbb905f98a882e9200","lib/libwinapi_onecoreuap-dhcpcsvc6.a":"9307eb9eafac5e56eb8736e0460ccfabbeb7033c22370f6d63dbec15750c2c7d","lib/libwinapi_onecoreuap-dnsapi.a":"4e9cc60fff43de5e6bc12d0aee71780efde002c73b1a2b3e4d7f43849ffab9e1","lib/libwinapi_onecoreuap-dsparse.a":"7bcca65477240d1c54454f202f6415a2f349c8df0720b95c1396c75f109d96e1","lib/libwinapi_onecoreuap-dsrole.a":"750f331c4aea4e08e0bf57517eb5cf83f965320a40278aae5bb81a44f2e6a370","lib/libwinapi_onecoreuap-dwrite.a":"49281a37b0aee062ceb2d19efbcb065c64acf4c9a3ccf7fb53ae5e3bdb3f93fc","lib/libwinapi_onecoreuap-dxgi.a":"b978adb600527a5fa0e13033c0bd0550451543223e39b2eb55448e24283fcdde","lib/libwinapi_onecoreuap-esent.a":"44bddaf8c8a5c2c487583477978f1c726472cecf578b96a90ef9d5d94d10767a","lib/libwinapi_onecoreuap-ext-ms-win-core-iuri-l1-1-0.a":"15077a429ee981c3889f5f80f0d80908403032e9374923065d18dc5bb5f0cc21","lib/libwinapi_onecoreuap-ext-ms-win-gaming-xinput-l1-1-0.a":"d748bce05acf164423b9f51af34d27e156c3410b11a9124472dc754b125a227b","lib/libwinapi_onecoreuap-ext-ms-win-networking-wlanapi-l1-1-0.a":"04a60651bd9c7ac36c123da5385cf803be1493f5cb24c44d653dbfa99aaadf95","lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-0.a":"a499bd46bc48917584d8b2a787936f61d1de854c2fafbc079505fbc4f25eb662","lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-1.a":"111fca4ebf3213be20875af33b7347bcd93a183a81ab25e11d2cdb54bf73e6a3","lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-0.a":"82bff3ea77bf75b0a77c0c425c8a421a50f25daca665216919ea39ce56af6ad1","lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-1.a":"4d43bfe29e7456fd1c2564dcacdd87257376ca49a8cb99c0a3cd9c5a227959ce","lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-2.a":"aa5222069f5cf71d21576f8d163996a1a3f1911075027c8eaaec6cb48035e52a","lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-3.a":"8861213886555fa0c546526d976f5bd49eef5b08de37aef719e2de567da217f6","lib/libwinapi_onecoreuap-fltlib.a":"911feb95d3b46095c2590284fd4e88c281332573c16d8d72503d766e3536460d","lib/libwinapi_onecoreuap-hid.a":"b8cef8cbabee8fbe7268f574fd480b3bf02c45a600b72113f3024ceee0c47ad2","lib/libwinapi_onecoreuap-hrtfapo.a":"10a3665b5176bc622b462f1716b0a60ba83df18d63bdc960e90bb6400da78d19","lib/libwinapi_onecoreuap-inkobjcore.a":"058b9849faf46a66e49661b8f898803f440de328037ab7815fbe0d95ccc2ed66","lib/libwinapi_onecoreuap-iphlpapi.a":"7c85f15f4bf6b7fe151b274255c9ad03db1743397616ec68f90c1f4d30bdc5ec","lib/libwinapi_onecoreuap-logoncli.a":"10741f4518a7afb84b9db379c00a5331d5c4b28496f079a3eddc71871752782d","lib/libwinapi_onecoreuap-mf.a":"86f4f4346b4370da7717db46685fc92558c1fca013e8610c3cef8c10a0fb1bf2","lib/libwinapi_onecoreuap-mfplat.a":"a9dc0e798d2cc9dc4a5e75d308a9d839b105960b8152624359ac61d28085a482","lib/libwinapi_onecoreuap-mfreadwrite.a":"d91b57b8fb1babcc90f2e2a1e1fcfa893917ead5827fbc1a22fc55a6b4635488","lib/libwinapi_onecoreuap-mfsensorgroup.a":"def6ddf843cf014ed2d160b35f3a25dbb252eb95c22b4e1844df78214bc8d1a8","lib/libwinapi_onecoreuap-mmdevapi.a":"51b3a515eae39cce8d75ca9bf918373b42ea43c5c33e98195d1ba57e4b3d9c4a","lib/libwinapi_onecoreuap-mpr.a":"1b4b7839d796c512c1ea75e0317dfbb16f4b450eb939927132009e8911ead967","lib/libwinapi_onecoreuap-msajapi.a":"c5af226bc61eb42442d4ccfa0de3ae9e10c64fae32e99cae4f955b5cce83d2ac","lib/libwinapi_onecoreuap-mswsock.a":"99dba4dac3253cd88010bb41dee7d614451e02e1f97c5c4ab1d6e6741a40a371","lib/libwinapi_onecoreuap-ncrypt.a":"0325fad3e5e48c0b38c06ced23f902803ae756e977a8dcbddfe375972a56a40e","lib/libwinapi_onecoreuap-netutils.a":"495bf6025aa07914547714e9d40c41e5e849aae50d8a62076059180b17b0f8cd","lib/libwinapi_onecoreuap-ntdll.a":"42edae05c46b040e6602b48f41d9d2e2d634ee1b19702045dfb3ed6a948c3526","lib/libwinapi_onecoreuap-oleaut32.a":"67c0810d64b9aaf7d5acc2ad2177aa21c3422a32fda8f8dfc98370dd3443613a","lib/libwinapi_onecoreuap-powrprof.a":"cb06fc8b9ed56f4d14e29ec5914ef51bd2edf8a61e25ecfce3b2d6be6fb368f8","lib/libwinapi_onecoreuap-profapi.a":"edf98a33a7377ea7affa0847479cdce329af615a9ff90ce271e4311a275a4cdd","lib/libwinapi_onecoreuap-propsys.a":"e91eeeeb49bc5703934a86dfbbb2a458c77c11841583af037f771c068680739a","lib/libwinapi_onecoreuap-rometadata.a":"a36bf05aff08f2d227a96d0b0178d401c68a8a289f53a84dfb41c3f47f105cc5","lib/libwinapi_onecoreuap-rpcrt4.a":"e0fbd8c5a2374c45601de615672f568204dea9e700669c7c8aa5f57661b3e8f3","lib/libwinapi_onecoreuap-samcli.a":"87afe7ca91002af17023dc87fca3273ea7e1b8c528ddef4090bdf999b52c8286","lib/libwinapi_onecoreuap-schedcli.a":"926f2b3f46e738c629fc0c25d638f21265db4935fa0e88ea0534bc034f8461fa","lib/libwinapi_onecoreuap-srvcli.a":"97440b0de6f0d6c44f5cb164bd0bd003439aae65010d9776a15943755e03b4ac","lib/libwinapi_onecoreuap-sspicli.a":"f76d297919833bce142c60628afd8262001ced9167ddf0e5a4a88e0fd4bb3132","lib/libwinapi_onecoreuap-tokenbinding.a":"367436cc51ea44815e6787f36c94cc79d000695064a1af10d4838960df8ae23a","lib/libwinapi_onecoreuap-uiautomationcore.a":"8478851f63c4aaf3d4ebec90d401f600a1d5d766ace095f37e8a9e92806ae06c","lib/libwinapi_onecoreuap-urlmon.a":"377442751f9e9f60a975a719d64a218a6a6ef395705b81d24769f449a4045098","lib/libwinapi_onecoreuap-userenv.a":"e4521774b639d11c5f44a34f8d3e6e5dbe6d23b1dd96d8c7708334aa46bbc23e","lib/libwinapi_onecoreuap-webservices.a":"60ac62ece62892bb6ae6c56a59d75cbfb9e3cae4f93e043a45f7cabde83545c3","lib/libwinapi_onecoreuap-websocket.a":"1a05bc66523baac5824c146aa8926c35b6b2acfe1df2ab830e0897c44dcbd25b","lib/libwinapi_onecoreuap-windows.data.pdf.a":"26a379975426aabe528ff0fc7ea303618f72549f8db06c3c7e01e76d78b3bced","lib/libwinapi_onecoreuap-windows.networking.a":"d8a72775acb279a2506861da526f3157576a663eb3accc17cf9526d0c88724a2","lib/libwinapi_onecoreuap-windowscodecs.a":"7efa18011d3656e3fdbc212275e4d18dfbd0e761209eea62cb0a63607d473fe8","lib/libwinapi_onecoreuap-winhttp.a":"45349940a99a4be7bf19b3b62a8e9f422807bf49790c9af88cd7421b462da425","lib/libwinapi_onecoreuap-wintrust.a":"c0b468f69150163c919d067fa65adce769dc2c3b03a19b4b3146d6d677a0ad1b","lib/libwinapi_onecoreuap-wkscli.a":"eb5b920b6f24c96a0cf522adc25fe75f511ccf765f1d8ca35bb617f89397812a","lib/libwinapi_onecoreuap-wlanapi.a":"213899a6dc7d4c4429e297b633758e85fc416a90de41878661c14ed252734f1a","lib/libwinapi_onecoreuap-wldap32.a":"afcd3b76aa882d56bb07ca241fe82c5c44cb93c222002419d28469bcb662309e","lib/libwinapi_onecoreuap-wpprecorderum.a":"e0e7813d542aa825d4f8146c7c7532ba83586d2a28a05315fdf43b81b1d34c86","lib/libwinapi_onecoreuap-ws2_32.a":"d4b7bc67a1b2ef2c3b454cf47ccfef81539bed541bc7a254bf6de379082e6a96","lib/libwinapi_onecoreuap-xaudio2_9.a":"983acf7b29684338c3cfac1009d1f3ea1f0ce12e826018f8297e5aff40474343","lib/libwinapi_onecoreuap-xmllite.a":"15a707fbd4170432fe2f8d8ab1befc7621f67dc1f89d229feab79f551a44de85","lib/libwinapi_onecoreuap.a":"4e300d7c78faa2b7d468aa0a6638fc58c670537dce77cd5a2eb6ddb02b56d052","lib/libwinapi_onecoreuap_downlevel-advapi32.a":"446b131e441165d435585c347444f55eb11086da6d23e58e2cef7bac5de0ea1d","lib/libwinapi_onecoreuap_downlevel-apphelp.a":"6f450c64be21886b051f4110a30771fc5cdfe4c9494424ec5bd9add3c15efe90","lib/libwinapi_onecoreuap_downlevel-comctl32.a":"a5f4814e9854f7185466e0161ae4627d5a081d070c2e2598d4cc73794d098e25","lib/libwinapi_onecoreuap_downlevel-comdlg32.a":"ee490f9621d47e6adf6ee7e2a713829936f90808c6a09941a09a4c1e224b201f","lib/libwinapi_onecoreuap_downlevel-d3d10.a":"9ba34746f018aeb00629d1d9690d341e09770e0fd5f10dfbb81b63f6eed35e42","lib/libwinapi_onecoreuap_downlevel-d3d9.a":"a2a97b7dcda9519a50206b3cabb04517a7de6e5dcc51201eef932e5bcede3b73","lib/libwinapi_onecoreuap_downlevel-d3dx10_47.a":"3a964f22faa80576bca7d2d4d4b73fb0448dc87ba1c293e7e711b301705666fa","lib/libwinapi_onecoreuap_downlevel-difxapi.a":"f99ed8c8c4386ca76a0e0d09f8711577a636768b76a24a4586c294ef52784ab9","lib/libwinapi_onecoreuap_downlevel-gdi32.a":"f546864a2563ecef8edc6b1789ce4fe392e00f23c4e5b18dd572172b4d762d4d","lib/libwinapi_onecoreuap_downlevel-input.a":"8f059f86c0ba3e9f7352e01e6d19a40b0666aed67c464ebc2e8b4eaa132037c7","lib/libwinapi_onecoreuap_downlevel-kernel32.a":"f68ce42f050eaf7dde5a36de2f073e3a7021e13d0715b4c5a9b9b29c0bc0ad42","lib/libwinapi_onecoreuap_downlevel-msi.a":"727a6ad9ef23c36ba9dc511b39e6b5d08f8a06fb97357b70a3741dbf6196688b","lib/libwinapi_onecoreuap_downlevel-newdev.a":"1494c911ef6039ec297ed14800aac6aa694f4a75d80fd8ac3d7218b5dbf851fb","lib/libwinapi_onecoreuap_downlevel-ole32.a":"99934cc9b0f520238540aee73c345390fb657b51bd8d1a66723086a647ea3310","lib/libwinapi_onecoreuap_downlevel-oleacc.a":"2fb46c4eb802dcbcd767f81505f3ef2972be7133290ee38ea117338784a3d5a4","lib/libwinapi_onecoreuap_downlevel-oleaut32.a":"0085bfcb320c8129a2612f556fc7045ef71f2b521923292855574b7f10792e3a","lib/libwinapi_onecoreuap_downlevel-oledlg.a":"b2ca13d5a826424c60fbe47db98164fcc0c566acc9c52a5cd2eeeb4bdf305fe2","lib/libwinapi_onecoreuap_downlevel-pdh.a":"3a3083755e865e489cb362dcb5a13cad45f399dea58ae9509ee91a7e79b79e5c","lib/libwinapi_onecoreuap_downlevel-psapi.a":"6fd037774d3b2cf0c40e4b2a023f96133eb7d29d2adc2e95354c8fad39debf7b","lib/libwinapi_onecoreuap_downlevel-resutils.a":"36d52efc86720df0876fddd88d806c41f69809880e69239317d736f681a48951","lib/libwinapi_onecoreuap_downlevel-rstrtmgr.a":"fb4efcbc9c0d907c829fada91abb26cb922f1a2790fb01852fea812f18534257","lib/libwinapi_onecoreuap_downlevel-secur32.a":"3e7351302d67974e1c613d3734ef43db2aaa5ebd73f2b8a775b175db47741b8f","lib/libwinapi_onecoreuap_downlevel-setupapi.a":"fa6597834a8abe76e05dfed0a3e016929fcb077d6ea9c0200ec00b6cd9f1c6b1","lib/libwinapi_onecoreuap_downlevel-shell32.a":"94ec337fc06b86503f2418e483cb768ca16da2b63f8317cb84ac75fba9475f37","lib/libwinapi_onecoreuap_downlevel-shlwapi.a":"30021f8e94ed49fba0d48c496a9240424010b09c571a8f7cbcb4f94158f10e0d","lib/libwinapi_onecoreuap_downlevel-tdh.a":"2d9e5f8ec479e7cc72b88ca8a7eb1204dbafee1363c02c7451b83c191fd3ed1b","lib/libwinapi_onecoreuap_downlevel-twinapi.a":"0900ea4abb2b66ecef125c036aa1fe992f3ec77371c229743bd70e01d0af8346","lib/libwinapi_onecoreuap_downlevel-user32.a":"362b2072ff4c99501bff9bc5dc6aeb1f5808f78e3eb78c7c75f5a1af3363ac29","lib/libwinapi_onecoreuap_downlevel-uxtheme.a":"29b3faa13cfe3b390d8ebf41b9c08d56c84aa801c71cbdc5d9173381e61152d7","lib/libwinapi_onecoreuap_downlevel-version.a":"b03dcf6bf1ba34ba56b620ea8022a7179c7bddc967dedfdc8b60d3346db0f9e0","lib/libwinapi_onecoreuap_downlevel-winmm.a":"853ec28ba94036b193c79c85d1dad2b4db5fd913f737c6b796bc983c7ba17c99","lib/libwinapi_onecoreuap_downlevel-winspool.a":"510d3b0f0f11d3c51cb88bd6eac65c9a96b118550ea8d243493d5cd8ced4db43","lib/libwinapi_onecoreuap_downlevel-wtsapi32.a":"6306d9a9027228ef56769312823ff6e9631e4878ae7787e97bd10a8c321a3f64","lib/libwinapi_onecoreuap_downlevel-xinput1_4.a":"2dd8563974547350ad927aa5ae72b8286137685c91235a3e9657fb454780f64f","lib/libwinapi_onecoreuap_downlevel.a":"6122e2af86381e597496cae0a138331539bbc7ef6056086e4700e17cf7da3614","lib/libwinapi_opengl32.a":"cd61467bd26c2f04263a328e8f24a0eab68b5b4aadbfbe3783434ea3863a84e8","lib/libwinapi_opmxbox.a":"17754f6ac6a65ee1ad76cd4f9736a861900899e4b6e8d933158a9d9e7a356b60","lib/libwinapi_p2p.a":"6080dc0993d44a7fcb3d7823771389b94a1e6d98ea6c246d54b3a072d7e4c7ec","lib/libwinapi_p2pgraph.a":"8ba6ce395e5a033aa787a01caa231ff21e76cd474b8dc2a006252c41f5bcaf48","lib/libwinapi_pathcch.a":"ee5b051516e4c8ca29cfd16f0faf0ee38699be03f76c0eb2d16a7dc48fa2e10c","lib/libwinapi_pdh.a":"c38a909863a22830824d9970dbc026354846b5b54674694544c3928d25469f85","lib/libwinapi_peerdist.a":"c73e4b074e62add8b4030c6e2534ab2388ed5a4c8ba628284c65d27c5c64a777","lib/libwinapi_powrprof.a":"4c15dfa756dcab2e0433b76de463e0ee1ad68531a047bce5ea27e055d1f5f537","lib/libwinapi_prntvpt.a":"1c9516faafb35dfc21d52982cafb9dab98bd8f6942251ba7a4343445d711bc22","lib/libwinapi_propsys.a":"20757cbaec15022c8ed44b465a99f88f9d0bb42936fdc7751330df8dfe13442c","lib/libwinapi_psapi.a":"f6f67c5beee3e36eef891343bb7a93eed84735ea39e45097087830d775dbb651","lib/libwinapi_quartz.a":"173172c1bec299b8c6483950e531f5ad0d7716d2033e06b82aaa16149fd5b6f9","lib/libwinapi_query.a":"d78614fd2084f15e1c832ac41799cdbee92c98580323b4cf47a1344c41eccd05","lib/libwinapi_qwave.a":"8b393b0d5e937d30f57f649b389e6f4f654b5edbbdfe8bc60d7acbf5a44797f9","lib/libwinapi_rasapi32.a":"b1acb42a2631daafc18eb694619288b49fa47cc37f64be62313de9319b3c1d64","lib/libwinapi_rasdlg.a":"00391874f0541e15c9060d07c1035046669c122d2c620dd4ce1c08c0f2750b5a","lib/libwinapi_resutils.a":"d58453d2906d115579550ce88b3d34873262a600eb103f9130ef95356b748044","lib/libwinapi_rometadata.a":"5fd852779025837e7b66422dd543b4f8fdfb188b6f7fc5a6d758aed4f666043d","lib/libwinapi_rpcexts.a":"dcfb0696cb99c7c4fb66e614f991e9f5e6093557a88afd5da3d557d3d47f0262","lib/libwinapi_rpcns4.a":"7c642bd1aa5f392a8167459f84f942d60ce5ddea53f7e65d1cefc35b90313c89","lib/libwinapi_rpcproxy.a":"744bac498456a0d486cb1250390c57708479d815d1d028fb88222a45bbb9a31c","lib/libwinapi_rpcrt4.a":"81ad88b3cb4bda2a013695376a32d39d20a8c847fac82c1a640fb14ac2874cb4","lib/libwinapi_rstrtmgr.a":"58695aa1de3f1a45a3551e337d2278363e99e8994fde5bb7429ca91bf01eb670","lib/libwinapi_rtm.a":"e279ed0560e4e178a1e16c2f017b401bf4709f15f0bf48bbe5705edde7ed4ea9","lib/libwinapi_rtutils.a":"e4fbdd5ce86a67f0839adeaacddc5e3fb4dc1a44e443f51f79366311a27e8641","lib/libwinapi_rtworkq.a":"558abac8f635cfddae0806bca089faf1103b84222c7677c258e6d18325eee0aa","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-0.a":"3c22240ddf62dfa3d893adc44e25040b26b3a38ebe772854e6bc9fea4628013d","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-1.a":"cfda587f4371f9e7e0bdea96859b98d874ae18daa437b75725563d5c423e99e8","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-l1-1-0.a":"907707ad032da229b20bbae0d25c7306d22e996a7f977b3097c3a01d5317f261","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-registration-l1-1-0.a":"49618d57bd1a24aae006acf0103ae8095b9e66421a631e1e9ed384a7197d07f8","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-robuffer-l1-1-0.a":"70581a27d058901a5a9bbf41a16aa5d16bf72f65b12af4fb85984bb48e3ee1dc","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a":"07200e5f0379ae3cfbde9b851ddd5d91183b4b1994aa3e4b5b0484e302341612","lib/libwinapi_runtimeobject-api-ms-win-core-winrt-string-l1-1-0.a":"fffd7d400e5dfead0b73981ed370ea2b082382b07ebb93fc7232f374de10eadc","lib/libwinapi_runtimeobject-api-ms-win-ro-typeresolution-l1-1-0.a":"48a032b080076be0ea91bc87e0a0a6f7415e8091b9db50fab0c6baca209e3a95","lib/libwinapi_runtimeobject.a":"7a0548c5ef5fc5788025e031aa642d18ea94559299b48fca507d3f52ef2e4b9a","lib/libwinapi_samlib.a":"91ee9a8d2bdb3501c6766343d1bb6bae46c39a20fc587812c78830173f1396a3","lib/libwinapi_samsrv.a":"d08bf3016166a2f335d04301a3064c433853db5466f5bf5a86653e42e93c5d2a","lib/libwinapi_sas.a":"405d7376cb9c77f67cfd5670bcea8a01cc16b19be6c74a7d1df53a7b9c42017d","lib/libwinapi_scarddlg.a":"fcc2ce4de77b26febb5d4775a1d8ded0509663f0ed17a8e79348cbcece2b7e1d","lib/libwinapi_scecli.a":"da81628253676a97948a59b44c0c16e760a34bc3b7ae87191dc235f07960c0d9","lib/libwinapi_scesrv.a":"639df7dce2b17166d0258e7368712e1024035a51293a2c169b42ccecdfe11aa4","lib/libwinapi_schannel.a":"e9f5890a84dc3b8314ec11f29301ff8471d94b5937d46d25d3ed6081c2ab8073","lib/libwinapi_secur32.a":"ea9cb6b2cf08d69c851ba23894cded1f7c4d832264af7fe91be7b9e862f8d20e","lib/libwinapi_security.a":"ff008080e458fcc7ffbfbd79bfa4da9dfe867c88015490f2b01424afe20086b7","lib/libwinapi_sens.a":"44b53c350bca96699a47e731c60996bfb7a441b49eeb37baa7c3d0d6fef559d9","lib/libwinapi_sensapi.a":"19841a881728565c15ef3c431e7e317f8301813e6b046146f01203cca0fc3292","lib/libwinapi_sensorsutils.a":"e4073214a0d131b4a6429606a07ce59d90367b7700ec1a642813b8f62ee65c4f","lib/libwinapi_setupapi.a":"ca332f657ed83d5a06a576d90529c1519d90fbeafa93c71f3542d4cf6b03eb3b","lib/libwinapi_sfc.a":"2dc50bb6cb53e5424a6ffef118fdc727ad22964687da87d0a101659b08984139","lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-0.a":"fffb49f303f5b25760ca8aa705ef97be92f642e647346687fab8aeb1883ecc8a","lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-1.a":"47e523efb180adc869d72e03c084b895ebe56ae5120b49a9cec6c6883fd687ad","lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-0.a":"0f4d8acbe62d2437d856d45e09bac00f65f0ade09dc5c326581d9704957fd75f","lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-1.a":"d244e9560e96e214d80806f8598e71e98ba9103b653d372dbde5f45fa33a117b","lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-2.a":"b2e1d7ae641a34f3c1049b788300044c1bfaa5504533cc57e046d9a13e386ec0","lib/libwinapi_shcore-api-ms-win-shcore-stream-winrt-l1-1-0.a":"4c3a88da7377928ff249a0620741cd949355f7ae8c3a11db78c3a1b375a8eb89","lib/libwinapi_shcore.a":"e2d0fa7e9c0d06bfec41008a6f41c47769cd4ba6ca839efdb99bc2e0cf4e1a39","lib/libwinapi_shdocvw.a":"1e0f3f43046b0ea779d69a3c46ef31450386baf3a135f8198a2299f9e6531fe5","lib/libwinapi_shell32.a":"342bbf0eac1dc3441526dbda7ba79e269219a5820a9a54a6c41050e8b28b4d5a","lib/libwinapi_shfolder.a":"64695b29cf965c9de61fa26aacf27acc43d9653166edcf47cce011a4bc171f27","lib/libwinapi_shlwapi.a":"e111842c79bb11433d74b9f52d51a74ae8f78527470bfc401565847b9c59c5ba","lib/libwinapi_slc.a":"9841bf76a2366a73b33d7d14c220813aefd2cf0462f090231f0ab44e7b5bfdc2","lib/libwinapi_slcext.a":"f5141e0529d6788add8b0bd0fdd0b4268f25deafee8d2dd59f427fed82f63b6c","lib/libwinapi_slwga.a":"3a32c92e0d192e675b1aeb8a71272dc14608cc62b26aa6b9db0ec1c3fb6ff556","lib/libwinapi_snmpapi.a":"a1456434d462c80e906523d7c389792be7ea5eaa17dd0d162e65a1b543368e57","lib/libwinapi_spoolss.a":"f53249a979dfed0e0038db4e8f4a8536b1f6382998112429e2d0bfbb0bae6bde","lib/libwinapi_sporder.a":"c18d86b92469bed1231057ce4c2dd76be4fa325e5576cab1828ef04b11af0e26","lib/libwinapi_srpapi.a":"d9301c3d6778da6efd7fc82b081931548ac0f9cc0fa0985bceab6fdb533abada","lib/libwinapi_ssdpapi.a":"66300e9a08686873fb992c8398284c80b40d8a28b8d55cb9455024b8e3888acd","lib/libwinapi_sti.a":"1a674eeb27c4a0854d01a14b50ca2fec8cf116662087887c485f93315440072e","lib/libwinapi_swdevice.a":"1d6363c447b68581d2a9f0cf6b874c6296878f974f239e9ac1808eea1a2b9d06","lib/libwinapi_synchronization.a":"fdc8df30efc2b7fe58d83d4eefa6245f35f2e534bfa6357c069e061da91aaef1","lib/libwinapi_t2embed.a":"79a7a2ded05e377b286fe3319ff30840632c8e6b08cfebe619aed4ef18dcd701","lib/libwinapi_tapi32.a":"b92b8648e4d8024f6457a84f80432048c83e3946a069e3ee241fe7a0188e1329","lib/libwinapi_tbs.a":"85a9741c2789221e90d4677df38f12ca837235c46b6ca765d1516e5dd9b8b89f","lib/libwinapi_tdh.a":"7a40b11938eb4c888283edb75b523ce58ba7bc80598dacea4c9ccb674bf71603","lib/libwinapi_tokenbinding.a":"faa88b4ca04226baedacd9b34d9dc46bc332c1e8aa87a2bf1a7f152c106623a3","lib/libwinapi_traffic.a":"7838ad22ff777a4de867353c5f2960ada912bc502b421c70d2c1ab814af37696","lib/libwinapi_tsec.a":"94d58b06c649ac6febd1be8c0a14ad112871fdcad75122ef4bc39ee52d2744af","lib/libwinapi_txfw32.a":"630f274d67e4956ab9d066d3cf79cba5de57b173fa8988c242520be574ae0f2c","lib/libwinapi_ualapi.a":"dafc0cc5db2358020464598f1750ed79fb5deef00eff70332d134d922e08bea2","lib/libwinapi_uiautomationcore.a":"9386c67bc47a45637e8ad963133f2bef11adb1ba0f7744200378b7cad245a571","lib/libwinapi_umpdddi.a":"6917cd155ea1efc89df72102d9b240d5deebfd09d8131b1376fc30e44bd4cefc","lib/libwinapi_urlmon.a":"15500bc9703d990df5c76e9fc982549eff5137e912901833c36731cbb1ef03cd","lib/libwinapi_user32.a":"cab4ffa1522d2cd626585ef27f0355b89ca2cf6a1af208cb0a08a851be676c2a","lib/libwinapi_userenv.a":"490004a87dc9a33eaa5178d4e0f9d4e2e5704f227c28eab018c9ebdb329ad003","lib/libwinapi_usp10.a":"9388553f5594b2cb0fb5de349f86462945969b215baae6ec3563ef422c0ff236","lib/libwinapi_uxtheme.a":"e79890801a208f5a97a032527f1b6580860fc170fcad13f60af7025bc55816c9","lib/libwinapi_version.a":"9b39a94cd041c08006833571ef2c5010ad002580bd7a7f959ccae4b7bb2a53a2","lib/libwinapi_vertdll.a":"2d9e673b14ac040402fb01b7cae7c38a8f069de117f24ee528c48d2200dc046b","lib/libwinapi_vfw32-avicap32.a":"6539084f6426499412e3e227a60ade3f66c9c7cfc0c3b56574c247ad8ab20b6b","lib/libwinapi_vfw32-avifil32.a":"a46baae68ee4545847d0f943217b607b3db4c0e98c8f636bd0e6cb5358385f53","lib/libwinapi_vfw32-msvfw32.a":"df741fa382f893f72277d9c9c61186252df1b3a53fd46fef0bd4054eea583dbe","lib/libwinapi_vfw32.a":"1f7bf15b2c0d637ef6a424ea0173f26d9adabb2bfbcc5711a95b408e060a7d96","lib/libwinapi_virtdisk.a":"b49c9ad313c8f3721d471aa92efbb671a9033104d9b455fc001e7d51fe554c03","lib/libwinapi_vssapi.a":"b6419c12a1aa251b7afe503b506b3cc2d2110bfe7b63329974915535f7ffcba8","lib/libwinapi_wcmapi.a":"d7d5892554e47394023a11be4073dd8d37d68bae06445fae9031d9c4fe25550d","lib/libwinapi_wdsbp.a":"d66a854206703421d8047aab169c0164f5601d72b18aa9995866023df455ea5d","lib/libwinapi_wdsclientapi.a":"28cb87834670a97daee6b59bd2e3f93d7054591fa8534dc31b496c57c45605c8","lib/libwinapi_wdsmc.a":"64197d80127a7f2fd6d2a86dce0d22d279859bc30cc50990acc484e1f2268def","lib/libwinapi_wdspxe.a":"44a2932596e7332447c45e60d361bf2fcf07e4d80dd505e4d9154e1c104abed9","lib/libwinapi_wdstptc.a":"c080d87fc9aa5c90d9eb936a4c4087a90703b612109c415b319533e6b32aedaf","lib/libwinapi_webservices.a":"bbd4e2a1d1129f2402faa311d232b16d5459b8a735cf08172677e83e19eb232c","lib/libwinapi_websocket.a":"c43b8eda7cde0a8040732b4ac093a1197fc4e2408ee9b8014659da745c25829b","lib/libwinapi_wecapi.a":"88a7259bae69e5c6ecef972a56b529d50151170b5886503216010e3f0bda4b1f","lib/libwinapi_wer.a":"a345247b177870607ee9f53653ac31618b258f2167b08fd1f4e064f4bf7eb9b4","lib/libwinapi_wevtapi.a":"83f302ff302968a7baf739ba768669e4b9a4173377ca00ae2f9f273ed7f7a494","lib/libwinapi_wiaservc.a":"acdd02371456418233a310bc6c9f3b89679b1f404189610c4c8e4b2dc391289a","lib/libwinapi_winbio.a":"849ebb2527d786c4b9e7c003c1d0b3d6870760af55fb459d95b5ec5a9ac23841","lib/libwinapi_windows.data.pdf.a":"3bfaa6d9063849a48231a0f0389bff1d943fa8731e8f9dd0f44e60a1fe83b273","lib/libwinapi_windows.networking.a":"4779dcaaf565e38ba1b70de811a7b054f71b8518560aa197b31cda6e19dea6f2","lib/libwinapi_windows.ui.a":"ceacde478768ba266891473df34530edcbace3f0d2f63fd4ebc77f2db5ae035e","lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-0.a":"ae5a529ae45288b871632f3ec12db35ce4dc1ce8535963928263e57a9b00e938","lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-1.a":"83b45b3b1764b8bade36adf6be1e7b4129000deb8fa6a74da66010c2e1972d3b","lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-0.a":"4e371b5c9bc78e90de4bccfb5f8591f1a00ea52dcf3ebb5ac28d42cebd5323e4","lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-1.a":"508fdae146d10f709f241b72e50538b806411365bfd25d0b058f930087d48468","lib/libwinapi_windowsapp-api-ms-win-core-com-l2-1-1.a":"eb431ce92e4089fb2b4041beb5a1c6cb5b3a6b260f7c7b5b2cc939163842709d","lib/libwinapi_windowsapp-api-ms-win-core-com-midlproxystub-l1-1-0.a":"7732e7fb9cbcc6f7420942491e7e6ffda9d4d342df6cdc6d6ce8ba703db38280","lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-0.a":"2854591f2764af61e6e9d0eecded807cd4d1bf1105c11d8443149f63faca95f6","lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-1.a":"cb8d5769116f8bbfebf7ee76d5dd0328a07bd40c5fafedf9f77ab4233cbf0145","lib/libwinapi_windowsapp-api-ms-win-core-console-l1-1-0.a":"47cee44464b1b6ab8f830bed46a74268588123fb2fefbab2f995a5f4ecc6b05a","lib/libwinapi_windowsapp-api-ms-win-core-console-l2-1-0.a":"d1d821fbfa3dbd91b8e979132a8f8489a027ff012bef7dd966ae84887b264207","lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-1.a":"2d7c594d910f03157c45bd42746da0270fef7908068cc30700d07f6bf3549e0e","lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-2.a":"68d751df1f53f2076de469949b57bd90bb6ebc5b146835b43aa786bc6235a6fd","lib/libwinapi_windowsapp-api-ms-win-core-debug-l1-1-0.a":"09381a9efd95ddf5eeee4bb4f9a726f930c7de0cd33c559e5f18306d56ae97ac","lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-0.a":"3d346fa6b1fe9d9a73b0f8d0b9444cf57917bf59bce6ffa3579932788a8e11be","lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-1.a":"a2feab35eb695d0f9e6b2cd7ca5889831353ba5cf7e6a7101ccf7a054f97f2c8","lib/libwinapi_windowsapp-api-ms-win-core-enclave-l1-1-0.a":"567dafb75dbef76c3c323fccb2a0b53a2a38c22f4e62a9d67f59df122a1fb5ee","lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-0.a":"1759d5d8488b35db38e39328b66608ab3e253deb3a1241e14e79e7b329da024d","lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-2.a":"23fc0a3663b50a1961af9d96f6765cdb5fbab4093a5d39181ca0eb244f44478c","lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-3.a":"b4cfaf6b55bb108a94a5e68124d2e9e0c674390fd7a35b9b3c625ea5798b2774","lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-0.a":"74f32a510cce263ff575350680506802c6e3bb23d7088db7d0308725cd9da80b","lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-1.a":"363e8d61b1012f11ff747e76c23d271b3115dcd50b8c0269d7407c77e1792b7b","lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-0.a":"e3a89400ce02e583cdaa8fa4de050d8e65ee0339b13ea82f73d5096de7cda622","lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-1.a":"00e98c96b9ed76b067c279fe68582d292476186b4c2f2bbbe3ef414e89848571","lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-0.a":"96c54ff9391a8c24f3c3437d1dc25ab3c84c360d3159f7ccd0d0e8c7f351d9e5","lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-1.a":"a7aabc370c4945162648ad40feb159defa54ea457c6d6def04e2bae1935bea5b","lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l1-1-0.a":"fe2f464e89d569e63bd5d87ceceb81beb440bba950b89e537a067f36319f92a2","lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l2-1-0.a":"6f9530c4aac755d101bd7d3106c44fa5ea3244e33f4a3c19a75d9a9407934d94","lib/libwinapi_windowsapp-api-ms-win-core-file-l1-1-0.a":"199bee21f074cbefa33b60301865ba5e4f1376f75c912147f13b55c7dea05610","lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-0.a":"1f5673e6408eb3f6bca799abd9296c32ef0cd32d97f5d9ca4133a99611dbd8c3","lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-2.a":"c37cb5b9d56b54b02d5938bbe8143637267d4c36dcb923e641fcac497c1b3f17","lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-0.a":"677786bc9efc8691621ef64dffb264bc16b7b1163efe6baaeafeb7c6e36ba389","lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-2.a":"a9a139d309cb0c125c4fa65307fafd2638786f336f0e6d6fd1a7449eee13da49","lib/libwinapi_windowsapp-api-ms-win-core-handle-l1-1-0.a":"26caaf18006bc0abbe3d56a73ff96a9698111d9f4b98fb1f0e790f4447d5ba59","lib/libwinapi_windowsapp-api-ms-win-core-heap-l1-1-0.a":"bfd091b593c6be02e8d274c3d175b0c220fd2984837dd87d135c351159e201b3","lib/libwinapi_windowsapp-api-ms-win-core-heap-l2-1-0.a":"73ea930467212eb507cfc65b6aa44d0afda3d61944d985f75b931e457087a8ab","lib/libwinapi_windowsapp-api-ms-win-core-heap-obsolete-l1-1-0.a":"ef5e4130be7b1a1b883df609dbefc06f9e54672ea9f4a24bcda165b2e9037cbe","lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-1-0.a":"394b682dd8369924304efac3c96c0725ff708e9347aca12bcb0507bc1b12d9cd","lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-2-0.a":"21d8e69b6b3c0d0842ead7195e4eeae70235eb4efd83672d370eb68c30230eb3","lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-0.a":"b2226ebecc94545b17792169b91fd2b9c484ef3fc57c2f2ee7fc8c24732b93d2","lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-1.a":"fb8c39c016226f510786f877ecf22aa3a0aad36035f43bf52e38eeb1d1d0dc2f","lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a":"075f58aefa7fb31879599afc6307ed2d6d21877106741cfc60198a6cdaaf47db","lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-l1-1-0.a":"dfc425b74e9c9b8a9ce0ac16d6b07720eb27039bb82d24b1d6f73f31453c7700","lib/libwinapi_windowsapp-api-ms-win-core-largeinteger-l1-1-0.a":"c842bd5d226d538229d7fa7b354c5ed80ab9e16abe4d05d687c7b5aa6166a7bc","lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l1-2-0.a":"dd46e937f2215d3b8066a73fb33dcf31612cd4c74aabe86cb17ba7dfb6c3541d","lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l2-1-0.a":"e19d3c11346e736ced16193b8419f6c887d7bc19d0b77bf64445467f8da453c1","lib/libwinapi_windowsapp-api-ms-win-core-localization-ansi-l1-1-0.a":"1b4eba533a023b9b2c1a0489fd4a8e1dabe129772414c8784b939c6b209a8393","lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-0.a":"63b4a889f279bbcce34503874b546c12b610af3c336e94ab1b12a321af219da9","lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-1.a":"798a833babb6b8901ae06ea1621a1d14ff4d573c9dd80be964ab2895ba1763d8","lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-2.a":"25dcc0836462742853efb4b704e709ff182935495e7a4b6c385cfa30cf7b771e","lib/libwinapi_windowsapp-api-ms-win-core-localization-l2-1-0.a":"1e448b81a7d1ee34ca4915917f11762550fb0895619bd6aa8ce11522798abfcc","lib/libwinapi_windowsapp-api-ms-win-core-localization-obsolete-l1-2-0.a":"ea08db7dbadd651054597951dc0114e71563df15ccf39e770d7f70b73967db9a","lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-0.a":"5c1b0121f7cc1578b79aa592f3a5a157d471d367e1337ea599281e1df7b308ff","lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-1.a":"a2ec02ac776bb5f3dfcde0bef2478f8ca681c9d62a7ae7396eac3b3bdb5e0018","lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-2.a":"7d3c77019c63c86e19d4a9d007687d2cf32d6c4c3a69597b52fab704bdb9380a","lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-3.a":"bd87331f4656c12e21be4f809d3e6c15dfd3f5f623a26ab1eb816814cb229de5","lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-0.a":"679cf926529bfe1745149cf17072ae8842da2d8d43d51d595e47e50b7cc3ad88","lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-1.a":"f88640101f58332a336fb473ea273e400075bbdfb339c74936491e8d871dbc8e","lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-1-0.a":"ef8ee63a4f86b293b8da715f5879a5a68e1473aca6e9d9def7f80703652586f8","lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-1.a":"8b5111199eabcd7bed60691e5f0560e2fb8cbbef259cc6aeba814036dde1d64c","lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-2.a":"40bcff81cf7fb2dd08bf472a1c20cb5a68366563ef63ee377c2955c0b712eec8","lib/libwinapi_windowsapp-api-ms-win-core-namespace-ansi-l1-1-0.a":"53308d6bc82db5f0b8df19e8c2d0d3cc8ad175491f4afe3ad43d3f2459fa37ad","lib/libwinapi_windowsapp-api-ms-win-core-namespace-l1-1-0.a":"fd98443ae36986e88870d302b821de44f253b812846204c3b320936e94b9dcb8","lib/libwinapi_windowsapp-api-ms-win-core-normalization-l1-1-0.a":"74e7e75117b012a700079e7a8f6bc7dd772fa1b045426476ac4aa285510e8033","lib/libwinapi_windowsapp-api-ms-win-core-path-l1-1-0.a":"f0f658a64b32553cb31da782c975c2c10c89e9b0c4d2db8647c04419ac5afca1","lib/libwinapi_windowsapp-api-ms-win-core-processenvironment-l1-1-0.a":"2a1c018da98ba81eae3c952d3e2246dabd2815d6ecfa9c299597af31f41bc8b0","lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-0.a":"af8ee6bcb56f69f6e8cae367d3e5ca7a7e5767a65ef025ab73444cc4cd84f2c5","lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-1.a":"61283492150d56f27b1565ab137446329db98cab4d8a4686ddbe601f78533199","lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-2.a":"2f3d245f6f1306f1982b9bc6b9f7f189478578475c74ccce41c74e2d0f9fdc71","lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-3.a":"e1ec06ed7a57190a3b362ddae83a2d1673654780aaab2669e4ffa98148392388","lib/libwinapi_windowsapp-api-ms-win-core-processtopology-obsolete-l1-1-0.a":"0b8045cba487a094bdc9968ac70e7c74a06203ffdee79dc7f7161235beb7c3e0","lib/libwinapi_windowsapp-api-ms-win-core-profile-l1-1-0.a":"a21d40fa108dd467e7a1a33f28b275f747a101efc4207e8edf07ea043bd7e89e","lib/libwinapi_windowsapp-api-ms-win-core-psapi-ansi-l1-1-0.a":"d7e300765ebe2b9023a5212fe76fce6da4bf1811f9311c8753694cd4e4340f53","lib/libwinapi_windowsapp-api-ms-win-core-psapi-l1-1-0.a":"bc28e602fb4600315fc2e1c84520eac7ec1e3d21d31cd68b1f21ec2fa0967839","lib/libwinapi_windowsapp-api-ms-win-core-psm-appnotify-l1-1-0.a":"5205a816830618555705303c76171e70e4427f6eade4cf2f0b9925de49f971f5","lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-0.a":"94c517e63ad80396976472250b833a63918768b56fae0a560e9d0f2b7de8e043","lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-1.a":"a6162bad2c4390849f390725e9bc9300960f654c86ea4764d8a7abefa0dc15eb","lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-2.a":"44fde3a07b7f045e20eb7c93d26f760fbe7c77602a829c5393a7cb991383f837","lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-1-0.a":"662a900b3f217c0355ce0b6f9946d39c84b2fa9ae94d0a485c8c52d28ce1f3af","lib/libwinapi_windowsapp-api-ms-win-core-slapi-l1-1-0.a":"da1a0bf48aac28cc96e29822c62333777787193394e9e7fa0aea17ad232a4940","lib/libwinapi_windowsapp-api-ms-win-core-string-l1-1-0.a":"02cb9f55b872652c53b2533ee92e75eb327c2dd52cbb2d327f336ef009f9e93c","lib/libwinapi_windowsapp-api-ms-win-core-synch-ansi-l1-1-0.a":"d46dc40c1ccb40880bb4052aa17a458c858388da0da7cc9eb96da8aa09b5231a","lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-1-0.a":"677778edda4531176ae134475b895cda615e51df45576642dc932c8d8c9a10ee","lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-0.a":"0d3cceadee76b329dc30d501c2d73755bc6276cafeee2697085b4586c544d06e","lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-1.a":"a35894c59b361b4f35bead6a917a8a210508c1c96001826e0a96cc7baa1c842f","lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-1-0.a":"369718cfbdf91609efc62cf9605c8d81de831ff5f1f4fdd0f62df54f832df758","lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-0.a":"bce191f0587c8f9d7f676be1b5190de2de4f996a0910e4c76048e018930e8e88","lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-3.a":"f61f1d99bcfb7b5e8d96a56c52fb725d9a36bedfc7ed08cfd7a3bf1e2311a577","lib/libwinapi_windowsapp-api-ms-win-core-threadpool-l1-2-0.a":"2f51b21fe9a60b81b3c16709fd36d0cae88ff3b8f55c0816872c5c11fb423271","lib/libwinapi_windowsapp-api-ms-win-core-timezone-l1-1-0.a":"945698b1a3027bd6d13127847635311f4918f47797c2cdf00dce03e12beebda5","lib/libwinapi_windowsapp-api-ms-win-core-url-l1-1-0.a":"1053a4ea528bc28aa1c0100eeab95f608f12c6783bfbca11f907a243f7bbce9b","lib/libwinapi_windowsapp-api-ms-win-core-util-l1-1-0.a":"a1655c5410387c0051a553c1b1742553c4773a7eba8e53cf25ce24f886961a13","lib/libwinapi_windowsapp-api-ms-win-core-version-l1-1-0.a":"5df21a1d47100128914dee705e4911b34970157ac74ac254858089396367e281","lib/libwinapi_windowsapp-api-ms-win-core-versionansi-l1-1-0.a":"7aed54533b4709f6bdc9f097465bcb4a71b819431239978d5963fb48f83adab2","lib/libwinapi_windowsapp-api-ms-win-core-windowsceip-l1-1-0.a":"e806b412b7373abe95852102fdf75a2f0a6bbb95f01611154e6e135fe783d54c","lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a":"5ba4d916eed3e36d665efb99922c3e975d12f31ad838f72352b5116dc4adc054","lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a":"ab9513a9773ce626974fc0cd1d024361461396e343589753384e6dd098271d93","lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a":"ddc5f1e9c7748223abfb6b1254a29976c13ffa9b62eeebf4704b6ce778fbec53","lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-0.a":"ec0c3b1bd8ecad5411ae6b7f626132a682795a5d495e5cb8cf8456dacae1fdb9","lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-1.a":"bdcd1862f07ca2fa628fe32c850f02ec51fe31bb4c7169a320b0b3636715d27c","lib/libwinapi_windowsapp-api-ms-win-core-winrt-l1-1-0.a":"074094d4fb9d8cfa85bcf9eb55610b7635cedc0446d7d4bbba23ec29ee81fa23","lib/libwinapi_windowsapp-api-ms-win-core-winrt-registration-l1-1-0.a":"1aae3b87b4daa4ab1646dac2e2ec947c883f33fa5105c2b74a97eec98bf51aba","lib/libwinapi_windowsapp-api-ms-win-core-winrt-robuffer-l1-1-0.a":"45e0c6cc9374dbb69e0a2e4258f3a9372e0eba7165590f52cd8ca7279f38a33b","lib/libwinapi_windowsapp-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a":"13f13a875a47020f343c5e8f45e607da17e865f930c10d7d1bb20e58c7d8d319","lib/libwinapi_windowsapp-api-ms-win-core-winrt-string-l1-1-0.a":"100007c54b80e4b063e81b9cf74e0031a2b7875557a2d39e4c66bb1c6fededc7","lib/libwinapi_windowsapp-api-ms-win-core-wow64-l1-1-0.a":"dc96f89d7d7d2fc4d011835bf72efad31bfaa396450d3bafb60b7b8c3cc3a29f","lib/libwinapi_windowsapp-api-ms-win-core-xstate-l2-1-0.a":"a94abe923e2e1e62e00ee6271c9493c9996d1866ddef1d6ae4baa31e3e193452","lib/libwinapi_windowsapp-api-ms-win-eventing-classicprovider-l1-1-0.a":"4cc2d512c93c466801ff1aba3b269eb6cd8bb5e068fb3997702d7e9de6d69e7b","lib/libwinapi_windowsapp-api-ms-win-eventing-consumer-l1-1-0.a":"0d2bfdf7f4e6bfacce139de90bef4e7b9be2247e46b590f43472bf512f9cd547","lib/libwinapi_windowsapp-api-ms-win-eventing-controller-l1-1-0.a":"f87ff616008bf1f362e6a0d3db8327108ed823f9705ed6d0becc09bd812c4321","lib/libwinapi_windowsapp-api-ms-win-eventing-legacy-l1-1-0.a":"dfc34fcafd7474b13c89c85e12d65f45e54c5c039b409587cd57d86da103fc37","lib/libwinapi_windowsapp-api-ms-win-eventing-provider-l1-1-0.a":"f1815af1a3878fe4ef29e9faa11662adc1695d2f20fd1fc4440ac30a3634a519","lib/libwinapi_windowsapp-api-ms-win-gaming-deviceinformation-l1-1-0.a":"c6dd8bef4e2c33ade7eea1fc40ec9b953f99ff67b6fa7a7af3a2f6b092256832","lib/libwinapi_windowsapp-api-ms-win-gaming-expandedresources-l1-1-0.a":"d4b20d678a7c9fcdea471ade884d25f65604267f9f0ecdfa12216c6739787fde","lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-0.a":"833f719b840c9dc743a859a0c307c6cd6c6135834c861d88d65039ae46e862dd","lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-1.a":"3a56df33b86c8b4120f684f596cacfd9aeb549e04828bf421cd0386e87cfcbd1","lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-0.a":"a61a0f2491b6e8709a77e6f3c2355d699c8c3d66177d88b619219447991475a2","lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-1.a":"c15d3c10174bb320025e4783e7c0325b018454f7c2a5362a522a6c3c81ac2e15","lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-2.a":"e1893322b38da323190f399dcf6fa6a0bf1211d81604ccac0053d7bad8faa2e3","lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-3.a":"9b5b10583e46bdde128c7cdc4eee470fe00e53faa060ea43240d599ea4acb714","lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-4.a":"70ed16b31f947bd7dbad9a2e8ec9ca4b1989dec49114e547a7fedaf0050853d6","lib/libwinapi_windowsapp-api-ms-win-ro-typeresolution-l1-1-0.a":"efb7105f66e30d6b47a4d7c4e4bc855bc93700cffc85c4fcb88c5ed01924c08f","lib/libwinapi_windowsapp-api-ms-win-security-base-l1-1-0.a":"bf3ae73201b0ca57f9e72ff63fc4bb02c8688be9bc1b26f03e7ec8625adce8c1","lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-0.a":"708c5b394d77eef855e38e5def7c20dc68c5eb3f42559da9a2410216b0dc804b","lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-1.a":"f6d0415df84733fbb00367d7ce8a58503b1ae82f00084b4017f43891e260d273","lib/libwinapi_windowsapp-api-ms-win-security-cryptoapi-l1-1-0.a":"08b92bbca14b3caa2800a1c6cb8a422d987453fc79e03f6bba2be6f321955788","lib/libwinapi_windowsapp-api-ms-win-security-isolatedcontainer-l1-1-0.a":"02cd4b104d098858228c9da7d98223aebd6c7cfe79fe04dd92e95b1acac90170","lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-ansi-l2-1-0.a":"713e02a43329a4f7b1b89dcdb6b0978f70ee3f881c2e57b6f2089597afec02f3","lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-l2-1-0.a":"e0c00d82c9c8b644eb66728a31911c0b46aa9bbbeeaf76d1e52a634dc6420489","lib/libwinapi_windowsapp-api-ms-win-security-provider-ansi-l1-1-0.a":"7949eb398bea0952d589f520b863c16b905b1f7336564bce2c56fc7504660116","lib/libwinapi_windowsapp-api-ms-win-security-provider-l1-1-0.a":"563c511de536d18586425400a822d23237fb08641fb7cf162064a318f68ada9d","lib/libwinapi_windowsapp-api-ms-win-security-sddl-ansi-l1-1-0.a":"d6f995485514312d425e618253d66c4e86577dab76338651be5e399b8f8319fa","lib/libwinapi_windowsapp-api-ms-win-security-sddl-l1-1-0.a":"0dc02e652b522c1322a92bdc26969509e8abb4dc8afbb38ceb4b313fd7453691","lib/libwinapi_windowsapp-api-ms-win-shcore-stream-winrt-l1-1-0.a":"a519bd8308ca63cd953624bc125861be000013815936a6a493fd54e5ad7003de","lib/libwinapi_windowsapp-bcrypt.a":"ec1329fa5a61a3b6cd84a3073aaada7b8785a77f63ac11f1d360caa1ae202bff","lib/libwinapi_windowsapp-cabinet.a":"7e29bea56ad7adb0179764acaf5f6b4def59c165c7558d593f63fda86ba368aa","lib/libwinapi_windowsapp-chakra.a":"bde73d3211bb74985a77de624a0f2a69a3a9ef75301651149eaa186111b2b7be","lib/libwinapi_windowsapp-coremessaging.a":"d72d946e4944c83e35a863db105b6f11410d013a4bd773b3e843ad9d53c15e51","lib/libwinapi_windowsapp-crypt32.a":"9b9536ccfc119865a0bdfc0abbc5292aeab79167663ab3667dd9a91453ef6f62","lib/libwinapi_windowsapp-d2d1.a":"4e5448b5f5062deadca8f55eec73dafa579fc8a23d55848700b7056847291429","lib/libwinapi_windowsapp-d3d11.a":"b811cce64afcdb1a0423633d197eb4a03e15a7ebf91026652e7792c69cc1acaf","lib/libwinapi_windowsapp-d3d12.a":"091aaa8fab3b7de11a9af54152575825dc8fac430ae033f4d4723d04b0399e11","lib/libwinapi_windowsapp-d3dcompiler_47.a":"fd94740862b56f0cac0810a6a7e88d625f5760ddf722d782c3d0b538fd357b31","lib/libwinapi_windowsapp-deviceaccess.a":"782f1edafaf4f507b5d6fc225c43442bbbc1392090c225c36b812c78b4008dcd","lib/libwinapi_windowsapp-dhcpcsvc.a":"3f3236df207c9500f86e8983523dffb321dd8e2be5eb046c2af02b7072c59f66","lib/libwinapi_windowsapp-dhcpcsvc6.a":"84770cc3af6607f00cfcc2bc78d7d360d34b1d01dc8b263bbe41fe78b4399111","lib/libwinapi_windowsapp-dwrite.a":"594f8cca0f490d89792bee1d520cd1fc8869fa33f26fd6efc99c2a365f6dab08","lib/libwinapi_windowsapp-dxgi.a":"9c4917fb8ce4fab92b7e5e0ef279935525a5a17ed6954a49a53e4c6cdb61fd6a","lib/libwinapi_windowsapp-esent.a":"c837999f299f9f404032de4e5d5cd8ae21f821ee7c296098be6e0c1290cbc7f2","lib/libwinapi_windowsapp-ext-ms-win-core-iuri-l1-1-0.a":"e174067c0f98d3fe42821d200b6788071ce59a723336f5d351c7dc64073eec81","lib/libwinapi_windowsapp-ext-ms-win-gaming-xinput-l1-1-0.a":"f6ff8db9b176d291809a8de91313a284dbfbbd9392c25ff960983c442f43d658","lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-0.a":"1ddd5c48bf3ff80947f67273494508f03e61867c2c9d7304554edb748515abe1","lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-1.a":"8c218ad73c7cdd0494021fd5bc0b44e2482000b33fa25df544b9f6587c324c17","lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-2.a":"32d41a927d75a74f71490ba8dd8740b3a9a3e76c0dbe2b5203dfef80f75f5c8e","lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-3.a":"16acf3d5961624c5e4056ea513529ff0d8a6635b8f78b7aa102dfc6e6ad4e685","lib/libwinapi_windowsapp-hrtfapo.a":"f7eb622e5c5f03683f8dec62a38d1f4bd5b98df2a43b513ab052a04e14a050e0","lib/libwinapi_windowsapp-inkobjcore.a":"cccafb5cf43ee4a4613d05c638d7fd561548860b9a887fc76023ad628259f154","lib/libwinapi_windowsapp-iphlpapi.a":"bcc5cc9e14d4f47c573a00e4ab1031c13ce24cf68e865ffacf815f1535e3b6e6","lib/libwinapi_windowsapp-mf.a":"a7436da8e6d45c25a13f79b223543dfb073b82052e8abe588d26e92b97aa907e","lib/libwinapi_windowsapp-mfplat.a":"e00177157715c5759d1e35004a84983e3f3356305e64816a9edd066bb3b79b77","lib/libwinapi_windowsapp-mfreadwrite.a":"553ee451e5cfe200ac9b840fe35f234d1aff83ca48ab6f0318e7122bdb8cd957","lib/libwinapi_windowsapp-mfsensorgroup.a":"003bade21115ea520a913c452bc0af48a73ba60dbeea163d82f0127a992647a3","lib/libwinapi_windowsapp-mmdevapi.a":"b702a9ce7e2478d529d879afc7deb90ccb17b48029efddd28e0ecaa458648963","lib/libwinapi_windowsapp-msajapi.a":"81ff5804db8a0db27c57d56b1d238d7db0235dcc1193da621451684e8d94d89f","lib/libwinapi_windowsapp-mswsock.a":"74617292fa905a61eca74ada1440187607e5a0937a35e89290e7d8e1f64851f4","lib/libwinapi_windowsapp-ncrypt.a":"947d9d8dddd3cfcd9645be2f13204e7ef5629e78acba8f528899289c5b1a29a7","lib/libwinapi_windowsapp-ntdll.a":"035272f422deaabaedac61ce9c115ef21895b4eaeedaff7083195a84c01947c7","lib/libwinapi_windowsapp-oleaut32.a":"872e3c75ba251f3f78aa3dd7f392a0c33d285f6c995f6505944e75a4322f7a1b","lib/libwinapi_windowsapp-propsys.a":"3e95866b05f3b7fd53c2d49a4f53c0c2b702db430bce1a3fa8f88ed2f03f094f","lib/libwinapi_windowsapp-rometadata.a":"23d445f9a97153afda848b972af65633e02cfa35efa38c8872d1df88570ed6db","lib/libwinapi_windowsapp-rpcrt4.a":"6577a81b2b25becb9f90706779b716e0b6c2dfe6b1f6cadf7bd10542e46874a4","lib/libwinapi_windowsapp-sspicli.a":"f62ba19b2e0825f21a1fdf9cdaaf6bdda9dc40d0535f3fcb1228e325043156c4","lib/libwinapi_windowsapp-uiautomationcore.a":"542c44f951e5af5b0bcc6b2a6962d68eb8ed3c3cdfb09904b127a7638b1f9a0b","lib/libwinapi_windowsapp-urlmon.a":"de3d0611b244af770ab9e65857039151337d51119202b7483ed85ee84bb3dc78","lib/libwinapi_windowsapp-webservices.a":"ff53c0fb8d4e865aa2b37e689c84e0a6279f817a61289e0e6281c0a0684c2efd","lib/libwinapi_windowsapp-windows.data.pdf.a":"f9b822e9af43233a0a8be75d7b3d4cc6b2690fc292d68768e3ef61faaf9722c3","lib/libwinapi_windowsapp-windows.networking.a":"6aa6690420aaccb3a167cbb70ea8a6a76032872f22fe171934d57c39b3e0600f","lib/libwinapi_windowsapp-windowscodecs.a":"0e80cb4d48197baa7dc382662c8cf4162493605b67c1697ac89b2582ac995bc1","lib/libwinapi_windowsapp-ws2_32.a":"b3068fc789e498347385db2f729b73a0ccfb94170359e350d9169174b6a81c4a","lib/libwinapi_windowsapp-xaudio2_9.a":"ff8b1bfc160dc731a02537f2fce9c64cde48a7fae63232f9cc5c1d9c742f0fdc","lib/libwinapi_windowsapp-xmllite.a":"c99e2624f2c1039902293a13f83fbbafe69171e290b5116b113c1162892469d3","lib/libwinapi_windowsapp.a":"15a0928f6c65e96bddf217bc5fab9166d5bcf4ae7b1618e73ce5ae357f65a78d","lib/libwinapi_windowsapp_downlevel-advapi32.a":"d804e9388eb15e702e31b474c9e64ba16677965fdf5caba76de23a0fb624c026","lib/libwinapi_windowsapp_downlevel-api-ms-win-core-localization-l1-2-0.a":"cebc37539a6264bc56267d7f246bf944a409d7290ae2335aeb47be08cd4691a8","lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-l1-1-0.a":"8c279b034b05b79e0cba7558b761075e46de1410553efaf276c8461a37705ee5","lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-robuffer-l1-1-0.a":"d6e47b4dada0dd89213ddc74ee9543f3cdbe94f91740c05f5e8b8a8b6ac4275d","lib/libwinapi_windowsapp_downlevel-cabinet.a":"ea49a1a0c093425d6e0c322f20701f403a0e30cd2b9b4156fe09b548a7676c06","lib/libwinapi_windowsapp_downlevel-d2d1.a":"c9a1d9bbb75339aa8c5c65ab3ca4e34851b5e49745053434ebe8a526fdb1cf6e","lib/libwinapi_windowsapp_downlevel-d3d11.a":"edee3ff52dcef25cd1c2de9d94dbabd37935c3c6b5ec68d319752a99d44ca238","lib/libwinapi_windowsapp_downlevel-d3dcompiler_47.a":"07be895fb60a47c0630f70019181994c23fa703be133eb92970f3f8ebc268507","lib/libwinapi_windowsapp_downlevel-deviceaccess.a":"54f1efb0754195ef80008a74e3dc7b80ad6ba7e6408f9f5870826df93e10859d","lib/libwinapi_windowsapp_downlevel-dhcpcsvc.a":"9bb795163a31c0c40fe4bb43c2a08a4bdafff513f0fc4d5370c21158e83519a1","lib/libwinapi_windowsapp_downlevel-dhcpcsvc6.a":"3146a9987752eff657fdd33e18e1cf8290ddb927253f06113991796c8fb6a330","lib/libwinapi_windowsapp_downlevel-dwrite.a":"75f782fc139938ff2c321a64e23796febba0bb06bc3476572108fd42e7ae7465","lib/libwinapi_windowsapp_downlevel-dxgi.a":"660dcabf3d62a3d17ef66c226363539a2ee816b40311da7424bcbf9f36c8086c","lib/libwinapi_windowsapp_downlevel-esent.a":"b2decb268c245ed92163af4fe6b78d3bbc68bc8b00a67af963fd62184c674e91","lib/libwinapi_windowsapp_downlevel-kernel32.a":"39c37ea812c53ed3fc5478286cc2b056af45d89f21ca381154126350ca347350","lib/libwinapi_windowsapp_downlevel-mf.a":"e342dd811d7aa4284e29af405382ba79d38a40b3a68422bd4855ec8d1cd90b85","lib/libwinapi_windowsapp_downlevel-mfplat.a":"4229ff3fc4ea43992bd43cf62134571d29abc3cbde12f123ea5ff3109b543084","lib/libwinapi_windowsapp_downlevel-mfreadwrite.a":"ec48614cfcf6cdc3b176d3b5503bff913b5a484f028081ec37c4a10e3b9b52e1","lib/libwinapi_windowsapp_downlevel-mmdevapi.a":"3efa1a3536fe519e8e0956f1e388f592359304dc552a71b4d8b76a22f19585c4","lib/libwinapi_windowsapp_downlevel-msajapi.a":"f6abb91151be743fbe8df9aa317f1901bf64bc1784737b1d627222690daa91fe","lib/libwinapi_windowsapp_downlevel-mscoree.a":"cb5aedee76fe7c835dfba5b3b8a177f6d9a8babbba35a68151d27cd38ec88ab0","lib/libwinapi_windowsapp_downlevel-mswsock.a":"2969f7e7ba5ee53df84f0f55197662ba3be0e469d03d41fe7fb27df743b8fb6f","lib/libwinapi_windowsapp_downlevel-ole32.a":"0e4a0fe7f48178d172f2d65ebf65dadb81c5c6374ea636f57312ac1a25e7fecb","lib/libwinapi_windowsapp_downlevel-oleaut32.a":"df90f481709e792326553f4f0dd9cf5bef8819a7b83cfcaaa0159e94a15a39e0","lib/libwinapi_windowsapp_downlevel-propsys.a":"548af9a83ee1edd4d5e31eac1b73f80360372457f5e7d7ecda76f0ed00828eb6","lib/libwinapi_windowsapp_downlevel-rpcrt4.a":"50ed6864d1407224c0d24fa18704b4a5a0da7a290f7cd43774bc0f9a9b4339b3","lib/libwinapi_windowsapp_downlevel-uiautomationcore.a":"e8a14b5378ce7033982cf5492ed6f533f59cc6831958b24f09ad6cc5331774cb","lib/libwinapi_windowsapp_downlevel-urlmon.a":"ec850a21e8f13934a8aa241558c446bf066f84fe3dd9244af65dc16b8d98a876","lib/libwinapi_windowsapp_downlevel-webservices.a":"59034d8d9f7a7d84470af85a1ff8be61f7bcb8dbb9bb71c8216dc27adbdc1f3d","lib/libwinapi_windowsapp_downlevel-windows.data.pdf.a":"db3815d61dde72d54181491438f985c6bfc798daf94fc2c52b6dcacad753a000","lib/libwinapi_windowsapp_downlevel-windows.networking.a":"c2729b8d6f689c7c5e5837692b94c29e9686e10b28c313af92dd4ee5e2d93ade","lib/libwinapi_windowsapp_downlevel-windowscodecs.a":"7ff7bc125c1bf161d75266274063fe1284f1dbe206cc3e77af9c563f293ea16a","lib/libwinapi_windowsapp_downlevel-ws2_32.a":"c45dab0dd9b2b7a93f727e510e16f63bb1f917b7e20030e6a25c43dae6190aad","lib/libwinapi_windowsapp_downlevel-xaudio2_8.a":"01fa2a11e747d8b54ff562ce005d2ea0600cca6a8bd4769a3f5d0201e8766b08","lib/libwinapi_windowsapp_downlevel-xinput1_4.a":"716a44b40028af673877f3cd3af9a172c2c294c5b0037d2416a577f8d9f0baf4","lib/libwinapi_windowsapp_downlevel-xmllite.a":"af8ad4904f954f829e79b67743d9b412b9aeb34432ec6148bff6bddea254bd0f","lib/libwinapi_windowsapp_downlevel.a":"fd622c0c778e135e02d0e387ad4075c68aa1f564de4c39a2677d87478ab0496e","lib/libwinapi_windowscodecs.a":"2b3a50daec478e8d6c5586d131c3da93b667ab98a3d1874d157887aab05a869b","lib/libwinapi_winfax.a":"009b2d2f2bfa7620b515504c8b9551eca3b4a58d118c59555db0891306c51669","lib/libwinapi_winhttp.a":"0572b9da9ee2740f4074d58030acd3c0235f0087a3ad3da138d22184d361e29f","lib/libwinapi_wininet.a":"c23ef20a00fdfb68052715a00bf17a368eef28359a2f3fccda73d4aae0c7d9f3","lib/libwinapi_winmm.a":"ea571535c90557ca7b9331f70aa04271a77b0f38e85929da604a1472e9ae45be","lib/libwinapi_winscard.a":"07996dd9c98ae95fbb9797a87fbba1b1435c9e148e1401d482ccab08dea91824","lib/libwinapi_winspool.a":"f92b3b0a67b4c598e6cc583e9c9aefd1ed473b3202bdfaec606300a20a58d746","lib/libwinapi_winsqlite3.a":"63e42c08e791103952b60e72b634a43213dfe07f87d4e09f93a1a73c7053e45a","lib/libwinapi_winsta.a":"ac53400d8e9dedc1039a04734048d0260f93bc23b102cf6ab76aef81b2c71a2a","lib/libwinapi_wintrust.a":"2f0db077618eaddc9889ccff5cebe02f61914d689a613852e5c043bd7890df65","lib/libwinapi_winusb.a":"3115eb3c732d9bedec71dc257526f3c6a694c5844f8a5cd4c035b887aaf837ec","lib/libwinapi_wlanapi.a":"ace6c67a6e9b8cda60a4a9fd002191affc37ce729d69bce3a2f7e2ea145219e4","lib/libwinapi_wlanui.a":"a132997ec3188c2faeb13e21a9de81c663830c1d42902817a2c8471360dc031e","lib/libwinapi_wldap32.a":"828be18ed9d8e50d4bdab88630ba0e897914955639b9b45c785408fd3ed6d5c5","lib/libwinapi_wmip.a":"b48306f4382ec01e198eeffa8f9dc29475548838c1b3ac0fb9913c17c5125325","lib/libwinapi_wmvcore.a":"4f7ca2d39f4d3350ffaebd1f5967fa60f32b596cc232284c48de9ed10a033d30","lib/libwinapi_wnvapi.a":"1ebab5c51f70165c898a44801c6aca50e23c81ceaab77a691d14211344de8b69","lib/libwinapi_wofutil.a":"cd804de66b5dfaea2f78175c341e0498799256d20e91a14333fd81deb697115e","lib/libwinapi_ws2_32.a":"eb8c67a0fd619b75d4a097da6c535e36092dc31833da11976f4ea9737736c27c","lib/libwinapi_wscapi.a":"59237ea2addf8ae27350a3a26b56f2d2e1b88ec696f860671f6a9a54df7307b9","lib/libwinapi_wsclient.a":"dfc4151c51d6ac1b2f6f1c6c9ac4ab616109e84670a9dd35fedd0174211d97c2","lib/libwinapi_wsdapi.a":"7deeb90e59f8f8b769ccf07d180a4fa8566b41590e3826199ab7cec1a841cf75","lib/libwinapi_wsmsvc.a":"4eaa3ee281f0112883577efcf46f07592e4b2902e8373447d84c349bda041fda","lib/libwinapi_wsnmp32.a":"0388baf7ca8c080b56f8278069231d88c39bf205833c8f9dbbbd7d20a8974a5e","lib/libwinapi_wsock32.a":"933e7c6f7958ce14f8916fbc4076ebb7a962576e54eb14679a866044e018455d","lib/libwinapi_wtsapi32.a":"1d1f30f69eeaa5ee0f16b247766a14e37379a563554a3aafc2c75a5c916c9327","lib/libwinapi_xaudio2.a":"a93fd7427990945f365a570e5063cfc37cf168319a191c9cced99fd4ac7412c8","lib/libwinapi_xaudio2_8.a":"d81aa8d4571feb7d88662232611a35327d6e794762d86c88ab3bfc00fc1380b2","lib/libwinapi_xinput.a":"60c83153e2a71755e4f1d23871502a0bb63581e5d50f7bace76c72d1097a6080","lib/libwinapi_xinput9_1_0.a":"48419ab7aee0fdacf664322a6c4c4d194dbf27a47395acf6df6711ed9305af6f","lib/libwinapi_xinputuap.a":"a240c14282237577ecedb7e90fffdc990784299690ed0e2d47609a54991b0331","lib/libwinapi_xmllite.a":"74b5c91747bcc207f29b48f55e4592b6d87507cccc769b821568995712ccab19","lib/libwinapi_xolehlp.a":"43d442e8dddca465980518f23769550e2e57f942e97a0bbafb570466de0fb66c","lib/libwinapi_xpsdocumenttargetprint.a":"72ccc29f8c73be0c982ae0107654281cbe304b7e4e494a9dc73589f6cb61c615","lib/libwinapi_xpsprint.a":"15ce739546fda5e2ded348552001a3afe31458aa4d3debe88a7856cc525eb286","src/lib.rs":"79212a91f610f8a77aa6ed4cc77212c2531eeb35630388bf07323cc328fcca42"},"package":"712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"} \ No newline at end of file diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/BUILD b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/BUILD new file mode 100644 index 0000000..27a7891 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "winapi_x86_64_pc_windows_gnu", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/Cargo.toml b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/Cargo.toml new file mode 100644 index 0000000..7e1341b --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/Cargo.toml @@ -0,0 +1,22 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +authors = ["Peter Atashian <retep998@gmail.com>"] +build = "build.rs" +include = ["src/*", "lib/*", "Cargo.toml", "build.rs"] +description = "Import libraries for the x86_64-pc-windows-gnu target. Please don't use this crate directly, depend on winapi instead." +keywords = ["windows"] +license = "MIT/Apache-2.0" +repository = "https://github.com/retep998/winapi-rs" diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/build.rs b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/build.rs new file mode 100644 index 0000000..a655b7c --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/build.rs @@ -0,0 +1,18 @@ +// Copyright © 2016-2018 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +fn main() { + use std::env::var; + use std::path::Path; + println!("cargo:rerun-if-env-changed=WINAPI_NO_BUNDLED_LIBRARIES"); + if var("WINAPI_NO_BUNDLED_LIBRARIES").is_ok() { + return; + } + if var("TARGET").map(|target| target == "x86_64-pc-windows-gnu").unwrap_or(false) { + let dir = var("CARGO_MANIFEST_DIR").unwrap(); + println!("cargo:rustc-link-search=native={}", Path::new(&dir).join("lib").display()); + } +} diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_aclui.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_aclui.a new file mode 100644 index 0000000..9b5c017 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_aclui.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_activeds.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_activeds.a new file mode 100644 index 0000000..aec05b5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_activeds.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_advapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_advapi32.a new file mode 100644 index 0000000..ef376d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_advapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_advpack.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_advpack.a new file mode 100644 index 0000000..9296b80 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_advpack.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_amsi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_amsi.a new file mode 100644 index 0000000..6311be6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_amsi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_api-ms-win-net-isolation-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_api-ms-win-net-isolation-l1-1-0.a new file mode 100644 index 0000000..f5fc53f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_api-ms-win-net-isolation-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_appmgmts.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_appmgmts.a new file mode 100644 index 0000000..6af015f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_appmgmts.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_appnotify.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_appnotify.a new file mode 100644 index 0000000..9a78ee4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_appnotify.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_audioeng.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_audioeng.a new file mode 100644 index 0000000..f1e7489 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_audioeng.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_authz.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_authz.a new file mode 100644 index 0000000..1b810a4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_authz.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_avifil32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_avifil32.a new file mode 100644 index 0000000..7b52eea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_avifil32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_avrt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_avrt.a new file mode 100644 index 0000000..70b6218 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_avrt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_basesrv.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_basesrv.a new file mode 100644 index 0000000..2f81109 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_basesrv.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_bcrypt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_bcrypt.a new file mode 100644 index 0000000..a27364d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_bcrypt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_bluetoothapis.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_bluetoothapis.a new file mode 100644 index 0000000..b5f9f37 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_bluetoothapis.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_bthprops.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_bthprops.a new file mode 100644 index 0000000..948b32c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_bthprops.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cabinet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cabinet.a new file mode 100644 index 0000000..cbea8a2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_certadm.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_certadm.a new file mode 100644 index 0000000..ec28d7c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_certadm.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_certpoleng.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_certpoleng.a new file mode 100644 index 0000000..042dce5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_certpoleng.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cfgmgr32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cfgmgr32.a new file mode 100644 index 0000000..a32bb20 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cfgmgr32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_chakrart.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_chakrart.a new file mode 100644 index 0000000..6102ad9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_chakrart.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cldapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cldapi.a new file mode 100644 index 0000000..e82b065 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cldapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_clfsw32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_clfsw32.a new file mode 100644 index 0000000..0d2fb6f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_clfsw32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_clusapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_clusapi.a new file mode 100644 index 0000000..feedc40 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_clusapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comctl32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comctl32.a new file mode 100644 index 0000000..cfc918a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comctl32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comdlg32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comdlg32.a new file mode 100644 index 0000000..f7f87b6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comdlg32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comppkgsup.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comppkgsup.a new file mode 100644 index 0000000..9835482 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comppkgsup.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_compstui.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_compstui.a new file mode 100644 index 0000000..fd7b718 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_compstui.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comsvcs.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comsvcs.a new file mode 100644 index 0000000..cf09bc4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_comsvcs.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_coremessaging.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_coremessaging.a new file mode 100644 index 0000000..7ff290d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_coremessaging.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_credui.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_credui.a new file mode 100644 index 0000000..e0eb596 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_credui.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_crypt32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_crypt32.a new file mode 100644 index 0000000..85a898c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_crypt32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptdll.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptdll.a new file mode 100644 index 0000000..7073c94 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptdll.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptnet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptnet.a new file mode 100644 index 0000000..79322ae Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptnet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptui.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptui.a new file mode 100644 index 0000000..6d50837 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptui.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptxml.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptxml.a new file mode 100644 index 0000000..d94b99a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cryptxml.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cscapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cscapi.a new file mode 100644 index 0000000..0bb61ac Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cscapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cscdll.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cscdll.a new file mode 100644 index 0000000..9cb80ea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_cscdll.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d2d1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d2d1.a new file mode 100644 index 0000000..fb48763 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d2d1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10.a new file mode 100644 index 0000000..5d2982a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10_1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10_1.a new file mode 100644 index 0000000..f23896d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d10_1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d11.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d11.a new file mode 100644 index 0000000..07bdcf7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d11.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d12.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d12.a new file mode 100644 index 0000000..d77ff38 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d12.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d9.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d9.a new file mode 100644 index 0000000..76a789f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3d9.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcompiler.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcompiler.a new file mode 100644 index 0000000..7202ff5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcompiler.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsx.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsx.a new file mode 100644 index 0000000..5632c6a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsx.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsxd.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsxd.a new file mode 100644 index 0000000..2f687f8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_d3dcsxd.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_davclnt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_davclnt.a new file mode 100644 index 0000000..5fbc216 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_davclnt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dbgeng.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dbgeng.a new file mode 100644 index 0000000..e32cf05 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dbgeng.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dbghelp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dbghelp.a new file mode 100644 index 0000000..68af1df Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dbghelp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dciman32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dciman32.a new file mode 100644 index 0000000..e73db18 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dciman32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dcomp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dcomp.a new file mode 100644 index 0000000..beeeef2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dcomp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ddraw.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ddraw.a new file mode 100644 index 0000000..0ef6fe9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ddraw.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_deviceaccess.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_deviceaccess.a new file mode 100644 index 0000000..8b46a2f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_deviceaccess.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_devmgr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_devmgr.a new file mode 100644 index 0000000..d7eac59 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_devmgr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dflayout.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dflayout.a new file mode 100644 index 0000000..0725743 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dflayout.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc.a new file mode 100644 index 0000000..28d840c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc6.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc6.a new file mode 100644 index 0000000..32d2a6d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpcsvc6.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpsapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpsapi.a new file mode 100644 index 0000000..39cda25 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dhcpsapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_difxapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_difxapi.a new file mode 100644 index 0000000..14af019 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_difxapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dinput8.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dinput8.a new file mode 100644 index 0000000..7107b8f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dinput8.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dmprocessxmlfiltered.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dmprocessxmlfiltered.a new file mode 100644 index 0000000..44850a8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dmprocessxmlfiltered.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dnsapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dnsapi.a new file mode 100644 index 0000000..4c84067 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dnsapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dnsperf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dnsperf.a new file mode 100644 index 0000000..8ee91a6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dnsperf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dnsrslvr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dnsrslvr.a new file mode 100644 index 0000000..2b484ea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dnsrslvr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dpx.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dpx.a new file mode 100644 index 0000000..afa99f2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dpx.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_drt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_drt.a new file mode 100644 index 0000000..aba232d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_drt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_drtprov.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_drtprov.a new file mode 100644 index 0000000..4748b2d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_drtprov.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_drttransport.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_drttransport.a new file mode 100644 index 0000000..7f0175f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_drttransport.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dsound.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dsound.a new file mode 100644 index 0000000..8954c2a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dsound.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dsprop.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dsprop.a new file mode 100644 index 0000000..9a921eb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dsprop.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dssec.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dssec.a new file mode 100644 index 0000000..8cf29e9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dssec.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dststlog.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dststlog.a new file mode 100644 index 0000000..a1ba612 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dststlog.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dsuiext.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dsuiext.a new file mode 100644 index 0000000..f574c83 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dsuiext.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dwmapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dwmapi.a new file mode 100644 index 0000000..244f217 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dwmapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dwrite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dwrite.a new file mode 100644 index 0000000..58d885e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dwrite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dxgi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dxgi.a new file mode 100644 index 0000000..3816b81 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dxgi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dxva2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dxva2.a new file mode 100644 index 0000000..30f262b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_dxva2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_eappcfg.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_eappcfg.a new file mode 100644 index 0000000..7fbba3a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_eappcfg.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_eappprxy.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_eappprxy.a new file mode 100644 index 0000000..5f46d3d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_eappprxy.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_easregprov.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_easregprov.a new file mode 100644 index 0000000..4a5711f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_easregprov.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_efswrt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_efswrt.a new file mode 100644 index 0000000..4d6b046 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_efswrt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_elscore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_elscore.a new file mode 100644 index 0000000..883a09f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_elscore.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_esent.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_esent.a new file mode 100644 index 0000000..2167897 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_esent.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_evr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_evr.a new file mode 100644 index 0000000..4c81d17 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_evr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_faultrep.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_faultrep.a new file mode 100644 index 0000000..f57e082 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_faultrep.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_feclient.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_feclient.a new file mode 100644 index 0000000..a8893ce Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_feclient.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fhsvcctl.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fhsvcctl.a new file mode 100644 index 0000000..56caa24 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fhsvcctl.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fltlib.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fltlib.a new file mode 100644 index 0000000..11b8dbb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fltlib.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fontsub.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fontsub.a new file mode 100644 index 0000000..7fd6358 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fontsub.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_framedyd.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_framedyd.a new file mode 100644 index 0000000..24dc14b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_framedyd.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_framedyn.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_framedyn.a new file mode 100644 index 0000000..45576b3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_framedyn.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fwpuclnt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fwpuclnt.a new file mode 100644 index 0000000..66e8bc2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fwpuclnt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fxsutility.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fxsutility.a new file mode 100644 index 0000000..6d0559b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_fxsutility.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_gdi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_gdi32.a new file mode 100644 index 0000000..219b37d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_gdi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_gdiplus.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_gdiplus.a new file mode 100644 index 0000000..6210e26 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_gdiplus.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_glmf32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_glmf32.a new file mode 100644 index 0000000..8798334 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_glmf32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_glu32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_glu32.a new file mode 100644 index 0000000..3853089 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_glu32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_gpedit.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_gpedit.a new file mode 100644 index 0000000..eb249e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_gpedit.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hbaapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hbaapi.a new file mode 100644 index 0000000..5677bea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hbaapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hid.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hid.a new file mode 100644 index 0000000..3c741a1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hid.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hlink.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hlink.a new file mode 100644 index 0000000..e5b21ff Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hlink.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hrtfapo.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hrtfapo.a new file mode 100644 index 0000000..d8eb49b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_hrtfapo.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_httpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_httpapi.a new file mode 100644 index 0000000..63e0d0e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_httpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iashlpr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iashlpr.a new file mode 100644 index 0000000..1500ab0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iashlpr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icm32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icm32.a new file mode 100644 index 0000000..68363f9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icm32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icmui.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icmui.a new file mode 100644 index 0000000..5088584 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icmui.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icuin.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icuin.a new file mode 100644 index 0000000..b80e877 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icuin.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icuuc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icuuc.a new file mode 100644 index 0000000..0955304 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_icuuc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_imagehlp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_imagehlp.a new file mode 100644 index 0000000..1f9bbc4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_imagehlp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_imgutil.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_imgutil.a new file mode 100644 index 0000000..e150dfd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_imgutil.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_imm32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_imm32.a new file mode 100644 index 0000000..aa94bb3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_imm32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_infocardapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_infocardapi.a new file mode 100644 index 0000000..4d10d47 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_infocardapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_inkobjcore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_inkobjcore.a new file mode 100644 index 0000000..efa3184 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_inkobjcore.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_inseng.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_inseng.a new file mode 100644 index 0000000..e537a53 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_inseng.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iphlpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iphlpapi.a new file mode 100644 index 0000000..9eb2b30 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iphlpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iprop.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iprop.a new file mode 100644 index 0000000..b8f9a99 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iprop.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_irprops.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_irprops.a new file mode 100644 index 0000000..afb2def Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_irprops.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iscsidsc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iscsidsc.a new file mode 100644 index 0000000..6338c77 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_iscsidsc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_jsrt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_jsrt.a new file mode 100644 index 0000000..0ab246c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_jsrt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_kernel32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_kernel32.a new file mode 100644 index 0000000..daa363d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_kernel32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ksproxy.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ksproxy.a new file mode 100644 index 0000000..8100ca9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ksproxy.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ksuser.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ksuser.a new file mode 100644 index 0000000..dd661f6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ksuser.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ktmw32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ktmw32.a new file mode 100644 index 0000000..c661f4f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ktmw32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_loadperf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_loadperf.a new file mode 100644 index 0000000..8a53f99 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_loadperf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_lz32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_lz32.a new file mode 100644 index 0000000..b480294 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_lz32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_magnification.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_magnification.a new file mode 100644 index 0000000..5c39407 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_magnification.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mapi32.a new file mode 100644 index 0000000..684e4d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mciole32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mciole32.a new file mode 100644 index 0000000..37dabbe Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mciole32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mdmlocalmanagement.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mdmlocalmanagement.a new file mode 100644 index 0000000..2c32aa8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mdmlocalmanagement.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mdmregistration.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mdmregistration.a new file mode 100644 index 0000000..1b07148 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mdmregistration.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mf.a new file mode 100644 index 0000000..3dba864 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfcore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfcore.a new file mode 100644 index 0000000..a74394b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfcore.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfplat.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfplat.a new file mode 100644 index 0000000..66ecb3c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfplat.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfplay.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfplay.a new file mode 100644 index 0000000..948ad9c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfplay.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfreadwrite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfreadwrite.a new file mode 100644 index 0000000..3e1222d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfreadwrite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfsensorgroup.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfsensorgroup.a new file mode 100644 index 0000000..92bf2ed Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfsensorgroup.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfsrcsnk.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfsrcsnk.a new file mode 100644 index 0000000..19172ea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mfsrcsnk.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mgmtapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mgmtapi.a new file mode 100644 index 0000000..a6bc0fa Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mgmtapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mi.a new file mode 100644 index 0000000..53c14c3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-0.a new file mode 100644 index 0000000..ff29df6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-1.a new file mode 100644 index 0000000..fa66286 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-2.a new file mode 100644 index 0000000..1bf4b64 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-midlproxystub-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-midlproxystub-l1-1-0.a new file mode 100644 index 0000000..58f6877 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-com-midlproxystub-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-0.a new file mode 100644 index 0000000..8e03f00 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-1.a new file mode 100644 index 0000000..942ee91 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-comm-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l1-1-0.a new file mode 100644 index 0000000..53db5fc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l2-1-0.a new file mode 100644 index 0000000..6ee38d9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-console-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-0.a new file mode 100644 index 0000000..e322d60 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-1.a new file mode 100644 index 0000000..1d82ba3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-2.a new file mode 100644 index 0000000..db27f3c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-datetime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-0.a new file mode 100644 index 0000000..0b3c0f8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-1.a new file mode 100644 index 0000000..4af2e6a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-2.a new file mode 100644 index 0000000..2787d98 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-debug-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-0.a new file mode 100644 index 0000000..2db9431 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-1.a new file mode 100644 index 0000000..cce97da Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-delayload-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-0.a new file mode 100644 index 0000000..2baa86b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-1.a new file mode 100644 index 0000000..e4b19a2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-2.a new file mode 100644 index 0000000..edc7719 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-3.a new file mode 100644 index 0000000..1ed424b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-0.a new file mode 100644 index 0000000..4c8539b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-1.a new file mode 100644 index 0000000..a70dd0a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-fibers-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-1-0.a new file mode 100644 index 0000000..88899bb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-0.a new file mode 100644 index 0000000..42c47ed Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-1.a new file mode 100644 index 0000000..70465e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-2.a new file mode 100644 index 0000000..6db054b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-0.a new file mode 100644 index 0000000..9bae760 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-1.a new file mode 100644 index 0000000..2c1477d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-2.a new file mode 100644 index 0000000..3669aea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-3.a new file mode 100644 index 0000000..2f01048 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-file-l2-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-firmware-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-firmware-l1-1-0.a new file mode 100644 index 0000000..5e82569 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-firmware-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-handle-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-handle-l1-1-0.a new file mode 100644 index 0000000..38deb42 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-handle-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l1-1-0.a new file mode 100644 index 0000000..7933e69 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l2-1-0.a new file mode 100644 index 0000000..99dd8b1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-heap-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-1-0.a new file mode 100644 index 0000000..98cae3e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-2-0.a new file mode 100644 index 0000000..7812f4f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-interlocked-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-0.a new file mode 100644 index 0000000..8493346 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-1.a new file mode 100644 index 0000000..d9e0459 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-io-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-job-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-job-l1-1-0.a new file mode 100644 index 0000000..ab25234 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-job-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-0.a new file mode 100644 index 0000000..68fe5a8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-1.a new file mode 100644 index 0000000..576cd02 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-2.a new file mode 100644 index 0000000..e196712 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l2-1-0.a new file mode 100644 index 0000000..8dfc823 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-libraryloader-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-0.a new file mode 100644 index 0000000..0f50d4f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-1.a new file mode 100644 index 0000000..abbba99 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-2.a new file mode 100644 index 0000000..c4e4b03 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l2-1-0.a new file mode 100644 index 0000000..144278b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-localization-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-0.a new file mode 100644 index 0000000..06d3dc0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-1.a new file mode 100644 index 0000000..8638ee6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-2.a new file mode 100644 index 0000000..3ac8927 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-3.a new file mode 100644 index 0000000..f98e53b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-4.a new file mode 100644 index 0000000..aa2709d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-5.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-5.a new file mode 100644 index 0000000..c2b513d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-memory-l1-1-5.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-1-0.a new file mode 100644 index 0000000..28ad417 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-1.a new file mode 100644 index 0000000..a142db3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-2.a new file mode 100644 index 0000000..e642b55 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namespace-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namespace-l1-1-0.a new file mode 100644 index 0000000..35ddf2f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-namespace-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-path-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-path-l1-1-0.a new file mode 100644 index 0000000..6672ce6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-1-0.a new file mode 100644 index 0000000..4ec4511 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-2-0.a new file mode 100644 index 0000000..b19f1c5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processenvironment-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processsnapshot-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processsnapshot-l1-1-0.a new file mode 100644 index 0000000..da75887 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processsnapshot-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-0.a new file mode 100644 index 0000000..62c713d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-1.a new file mode 100644 index 0000000..08ae7e9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-2.a new file mode 100644 index 0000000..e307074 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-3.a new file mode 100644 index 0000000..d6f945d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processthreads-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processtopology-l1-1-0.a new file mode 100644 index 0000000..2ee0571 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-processtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-profile-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-profile-l1-1-0.a new file mode 100644 index 0000000..392084e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-profile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-psapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-psapi-l1-1-0.a new file mode 100644 index 0000000..caa36ab Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-psapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-0.a new file mode 100644 index 0000000..e3c333f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-1.a new file mode 100644 index 0000000..99ea62b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-quirks-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-0.a new file mode 100644 index 0000000..ab0a13a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-1.a new file mode 100644 index 0000000..6d577ea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-2.a new file mode 100644 index 0000000..8927bae Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-realtime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-0.a new file mode 100644 index 0000000..8b5c539 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-1.a new file mode 100644 index 0000000..dcebe9c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-2.a new file mode 100644 index 0000000..a3b907f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-registry-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-1-0.a new file mode 100644 index 0000000..f67d7b4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-2-0.a new file mode 100644 index 0000000..011f72a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-rtlsupport-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-0.a new file mode 100644 index 0000000..37d79bb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-1.a new file mode 100644 index 0000000..ca54004 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-shutdown-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l1-1-0.a new file mode 100644 index 0000000..1832556 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-0.a new file mode 100644 index 0000000..7d0c64d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-1.a new file mode 100644 index 0000000..6ce5a9f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-string-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-1-0.a new file mode 100644 index 0000000..ff4e915 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-0.a new file mode 100644 index 0000000..7c0b81e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-1.a new file mode 100644 index 0000000..342c2f8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-synch-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-1-0.a new file mode 100644 index 0000000..7e23224 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-0.a new file mode 100644 index 0000000..a6f94e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-1.a new file mode 100644 index 0000000..62ca5f7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-2.a new file mode 100644 index 0000000..ddfaba8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-3.a new file mode 100644 index 0000000..65e9a30 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-0.a new file mode 100644 index 0000000..b5e62b0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-1.a new file mode 100644 index 0000000..5ddac42 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-threadpool-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-threadpool-l1-2-0.a new file mode 100644 index 0000000..2517dc2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-threadpool-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-timezone-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-timezone-l1-1-0.a new file mode 100644 index 0000000..047cde3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-timezone-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-0.a new file mode 100644 index 0000000..38005fc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-1.a new file mode 100644 index 0000000..71966ef Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-util-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-0.a new file mode 100644 index 0000000..102b713 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-1.a new file mode 100644 index 0000000..3d5f9d9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-version-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-0.a new file mode 100644 index 0000000..e7003e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-1.a new file mode 100644 index 0000000..ac4bd5d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..9a083ac Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-0.a new file mode 100644 index 0000000..bce4a2b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-1.a new file mode 100644 index 0000000..6d4a413 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-0.a new file mode 100644 index 0000000..e3f0112 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-1.a new file mode 100644 index 0000000..0b33c8a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-2.a new file mode 100644 index 0000000..4396b1c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-wow64-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-0.a new file mode 100644 index 0000000..ebf7e08 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-1.a new file mode 100644 index 0000000..b2999aa Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-2.a new file mode 100644 index 0000000..31855cd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l2-1-0.a new file mode 100644 index 0000000..8ac5491 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-core-xstate-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-1.a new file mode 100644 index 0000000..e99797b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-2.a new file mode 100644 index 0000000..6a518b4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-config-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-0.a new file mode 100644 index 0000000..c10cebc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-1.a new file mode 100644 index 0000000..d4b95d5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-classicprovider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-classicprovider-l1-1-0.a new file mode 100644 index 0000000..352a380 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-classicprovider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-0.a new file mode 100644 index 0000000..ceeaf15 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-1.a new file mode 100644 index 0000000..d56e26f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-controller-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-controller-l1-1-0.a new file mode 100644 index 0000000..baafaee Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-controller-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-provider-l1-1-0.a new file mode 100644 index 0000000..949f6e7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-eventing-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-base-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-base-l1-1-0.a new file mode 100644 index 0000000..9c977b6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-setting-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-setting-l1-1-0.a new file mode 100644 index 0000000..5a649b7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-power-setting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-appcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-appcontainer-l1-1-0.a new file mode 100644 index 0000000..87de266 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-appcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-1-0.a new file mode 100644 index 0000000..9a3b5ea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-0.a new file mode 100644 index 0000000..8487b79 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-1.a new file mode 100644 index 0000000..2cd8af8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-2.a new file mode 100644 index 0000000..1c98d99 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-base-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-credentials-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-credentials-l1-1-0.a new file mode 100644 index 0000000..ef9a25a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-credentials-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-0.a new file mode 100644 index 0000000..716ef4e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-1.a new file mode 100644 index 0000000..06c3727 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-sddl-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-sddl-l1-1-0.a new file mode 100644 index 0000000..14e680b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-security-sddl-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-0.a new file mode 100644 index 0000000..811d677 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-1.a new file mode 100644 index 0000000..eead8f1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-2.a new file mode 100644 index 0000000..3710d1e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-core-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l1-1-0.a new file mode 100644 index 0000000..612254a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l2-1-0.a new file mode 100644 index 0000000..48f1c67 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-management-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-winsvc-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-winsvc-l1-1-0.a new file mode 100644 index 0000000..d310e5a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-api-ms-win-service-winsvc-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-authz.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-authz.a new file mode 100644 index 0000000..a8ced6a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-authz.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-bcrypt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-bcrypt.a new file mode 100644 index 0000000..e05b33b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-bcrypt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cabinet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cabinet.a new file mode 100644 index 0000000..349ef84 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-crypt32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-crypt32.a new file mode 100644 index 0000000..3ba6b61 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-crypt32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptbase.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptbase.a new file mode 100644 index 0000000..1de2709 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptbase.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptnet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptnet.a new file mode 100644 index 0000000..0525373 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-cryptnet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dfscli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dfscli.a new file mode 100644 index 0000000..043ca84 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dfscli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dnsapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dnsapi.a new file mode 100644 index 0000000..72eb94a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dnsapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsparse.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsparse.a new file mode 100644 index 0000000..de7169c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsparse.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsrole.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsrole.a new file mode 100644 index 0000000..3ede301 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-dsrole.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-iphlpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-iphlpapi.a new file mode 100644 index 0000000..d536a71 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-iphlpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-logoncli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-logoncli.a new file mode 100644 index 0000000..a2ce88f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-logoncli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mpr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mpr.a new file mode 100644 index 0000000..7a962d8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mpr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mswsock.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mswsock.a new file mode 100644 index 0000000..156ec1a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ncrypt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ncrypt.a new file mode 100644 index 0000000..123c440 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ncrypt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-netutils.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-netutils.a new file mode 100644 index 0000000..0768556 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-netutils.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-oleaut32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-oleaut32.a new file mode 100644 index 0000000..daf7ad3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-rpcrt4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-rpcrt4.a new file mode 100644 index 0000000..ccddf3f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-samcli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-samcli.a new file mode 100644 index 0000000..7cf01dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-samcli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-schedcli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-schedcli.a new file mode 100644 index 0000000..8734367 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-schedcli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-srvcli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-srvcli.a new file mode 100644 index 0000000..10efc0e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-srvcli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-sspicli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-sspicli.a new file mode 100644 index 0000000..cd66704 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-sspicli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-userenv.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-userenv.a new file mode 100644 index 0000000..d739a9b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-userenv.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-websocket.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-websocket.a new file mode 100644 index 0000000..b95d433 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-websocket.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-winhttp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-winhttp.a new file mode 100644 index 0000000..7716784 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-winhttp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wkscli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wkscli.a new file mode 100644 index 0000000..8cfa672 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wkscli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wldap32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wldap32.a new file mode 100644 index 0000000..bd1859d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-wldap32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ws2_32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ws2_32.a new file mode 100644 index 0000000..9826b93 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore-ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore.a new file mode 100644 index 0000000..d2e567d --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore.a @@ -0,0 +1,167 @@ +INPUT( +libwinapi_mincore-api-ms-win-core-winrt-l1-1-0.a +libwinapi_mincore-api-ms-win-security-credentials-l1-1-0.a +libwinapi_mincore-wkscli.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-5.a +libwinapi_mincore-api-ms-win-core-datetime-l1-1-2.a +libwinapi_mincore-websocket.a +libwinapi_mincore-api-ms-win-core-processenvironment-l1-2-0.a +libwinapi_mincore-api-ms-win-core-synch-l1-2-1.a +libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-1.a +libwinapi_mincore-api-ms-win-core-xstate-l1-1-1.a +libwinapi_mincore-api-ms-win-core-debug-l1-1-0.a +libwinapi_mincore-api-ms-win-security-base-l1-1-0.a +libwinapi_mincore-oleaut32.a +libwinapi_mincore-api-ms-win-security-base-l1-2-2.a +libwinapi_mincore-api-ms-win-core-util-l1-1-0.a +libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-3.a +libwinapi_mincore-iphlpapi.a +libwinapi_mincore-api-ms-win-core-quirks-l1-1-0.a +libwinapi_mincore-api-ms-win-core-realtime-l1-1-2.a +libwinapi_mincore-api-ms-win-core-realtime-l1-1-1.a +libwinapi_mincore-winhttp.a +libwinapi_mincore-crypt32.a +libwinapi_mincore-api-ms-win-core-processtopology-l1-1-0.a +libwinapi_mincore-api-ms-win-core-synch-l1-2-0.a +libwinapi_mincore-api-ms-win-core-path-l1-1-0.a +libwinapi_mincore-api-ms-win-security-sddl-l1-1-0.a +libwinapi_mincore-schedcli.a +libwinapi_mincore-samcli.a +libwinapi_mincore-api-ms-win-core-debug-l1-1-2.a +libwinapi_mincore-api-ms-win-core-localization-l1-2-0.a +libwinapi_mincore-api-ms-win-core-file-l2-1-1.a +libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-0.a +libwinapi_mincore-api-ms-win-core-firmware-l1-1-0.a +libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-1.a +libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-1.a +libwinapi_mincore-dfscli.a +libwinapi_mincore-api-ms-win-core-realtime-l1-1-0.a +libwinapi_mincore-api-ms-win-core-sysinfo-l1-1-0.a +libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-3.a +libwinapi_mincore-ws2_32.a +libwinapi_mincore-api-ms-win-core-processthreads-l1-1-2.a +libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-0.a +libwinapi_mincore-srvcli.a +libwinapi_mincore-api-ms-win-core-file-l2-1-0.a +libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-2.a +libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-0.a +libwinapi_mincore-api-ms-win-core-localization-l2-1-0.a +libwinapi_mincore-api-ms-win-core-wow64-l1-1-0.a +libwinapi_mincore-api-ms-win-security-appcontainer-l1-1-0.a +libwinapi_mincore-netutils.a +libwinapi_mincore-api-ms-win-service-core-l1-1-2.a +libwinapi_mincore-api-ms-win-eventing-classicprovider-l1-1-0.a +libwinapi_mincore-api-ms-win-core-profile-l1-1-0.a +libwinapi_mincore-api-ms-win-service-management-l2-1-0.a +libwinapi_mincore-dsparse.a +libwinapi_mincore-api-ms-win-core-com-midlproxystub-l1-1-0.a +libwinapi_mincore-api-ms-win-core-wow64-l1-1-2.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-0.a +libwinapi_mincore-api-ms-win-core-processthreads-l1-1-1.a +libwinapi_mincore-api-ms-win-core-string-l2-1-0.a +libwinapi_mincore-api-ms-win-power-setting-l1-1-0.a +libwinapi_mincore-api-ms-win-core-xstate-l1-1-2.a +libwinapi_mincore-api-ms-win-service-winsvc-l1-1-0.a +libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-0.a +libwinapi_mincore-api-ms-win-core-shutdown-l1-1-0.a +libwinapi_mincore-api-ms-win-core-console-l1-1-0.a +libwinapi_mincore-api-ms-win-service-core-l1-1-1.a +libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-2.a +libwinapi_mincore-api-ms-win-core-winrt-error-l1-1-1.a +libwinapi_mincore-wldap32.a +libwinapi_mincore-api-ms-win-service-management-l1-1-0.a +libwinapi_mincore-api-ms-win-core-file-l1-2-0.a +libwinapi_mincore-cryptbase.a +libwinapi_mincore-api-ms-win-core-errorhandling-l1-1-0.a +libwinapi_mincore-api-ms-win-core-io-l1-1-0.a +libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-1.a +libwinapi_mincore-mswsock.a +libwinapi_mincore-api-ms-win-core-localization-l1-2-2.a +libwinapi_mincore-api-ms-win-core-processenvironment-l1-1-0.a +libwinapi_mincore-api-ms-win-core-processsnapshot-l1-1-0.a +libwinapi_mincore-api-ms-win-service-core-l1-1-0.a +libwinapi_mincore-api-ms-win-core-io-l1-1-1.a +libwinapi_mincore-api-ms-win-core-heap-l2-1-0.a +libwinapi_mincore-api-ms-win-core-namespace-l1-1-0.a +libwinapi_mincore-api-ms-win-core-delayload-l1-1-1.a +libwinapi_mincore-api-ms-win-security-base-l1-2-1.a +libwinapi_mincore-api-ms-win-core-file-l2-1-3.a +libwinapi_mincore-cabinet.a +libwinapi_mincore-api-ms-win-core-rtlsupport-l1-2-0.a +libwinapi_mincore-api-ms-win-core-namedpipe-l1-2-2.a +libwinapi_mincore-api-ms-win-core-systemtopology-l1-1-0.a +libwinapi_mincore-api-ms-win-core-string-l2-1-1.a +libwinapi_mincore-api-ms-win-security-base-l1-2-0.a +libwinapi_mincore-cryptnet.a +libwinapi_mincore-api-ms-win-core-xstate-l2-1-0.a +libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-0.a +libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-1.a +libwinapi_mincore-api-ms-win-core-registry-l1-1-2.a +libwinapi_mincore-api-ms-win-security-lsalookup-l2-1-1.a +libwinapi_mincore-api-ms-win-core-wow64-l1-1-1.a +libwinapi_mincore-api-ms-win-core-libraryloader-l2-1-0.a +libwinapi_mincore-api-ms-win-core-util-l1-1-1.a +libwinapi_mincore-api-ms-win-core-delayload-l1-1-0.a +libwinapi_mincore-api-ms-win-core-threadpool-l1-2-0.a +libwinapi_mincore-api-ms-win-core-comm-l1-1-1.a +libwinapi_mincore-api-ms-win-core-handle-l1-1-0.a +libwinapi_mincore-api-ms-win-core-shutdown-l1-1-1.a +libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-1.a +libwinapi_mincore-api-ms-win-core-file-l1-1-0.a +libwinapi_mincore-dsrole.a +libwinapi_mincore-api-ms-win-core-localization-l1-2-1.a +libwinapi_mincore-api-ms-win-devices-swdevice-l1-1-0.a +libwinapi_mincore-sspicli.a +libwinapi_mincore-authz.a +libwinapi_mincore-api-ms-win-core-xstate-l1-1-0.a +libwinapi_mincore-api-ms-win-core-datetime-l1-1-0.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-3.a +libwinapi_mincore-api-ms-win-core-job-l1-1-0.a +libwinapi_mincore-api-ms-win-core-comm-l1-1-0.a +libwinapi_mincore-api-ms-win-eventing-provider-l1-1-0.a +libwinapi_mincore-api-ms-win-core-com-l1-1-2.a +libwinapi_mincore-api-ms-win-core-psapi-l1-1-0.a +libwinapi_mincore-api-ms-win-core-processthreads-l1-1-0.a +libwinapi_mincore-api-ms-win-core-string-l1-1-0.a +libwinapi_mincore-ncrypt.a +libwinapi_mincore-api-ms-win-core-com-l1-1-1.a +libwinapi_mincore-api-ms-win-core-sysinfo-l1-2-2.a +libwinapi_mincore-api-ms-win-core-version-l1-1-0.a +libwinapi_mincore-api-ms-win-core-quirks-l1-1-1.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-4.a +libwinapi_mincore-api-ms-win-core-interlocked-l1-2-0.a +libwinapi_mincore-api-ms-win-core-namedpipe-l1-1-0.a +libwinapi_mincore-api-ms-win-core-rtlsupport-l1-1-0.a +libwinapi_mincore-mpr.a +libwinapi_mincore-api-ms-win-core-synch-l1-1-0.a +libwinapi_mincore-bcrypt.a +libwinapi_mincore-api-ms-win-core-version-l1-1-1.a +libwinapi_mincore-api-ms-win-core-timezone-l1-1-0.a +libwinapi_mincore-dnsapi.a +libwinapi_mincore-api-ms-win-core-datetime-l1-1-1.a +libwinapi_mincore-logoncli.a +libwinapi_mincore-rpcrt4.a +libwinapi_mincore-api-ms-win-devices-config-l1-1-1.a +libwinapi_mincore-api-ms-win-core-file-l1-2-2.a +libwinapi_mincore-api-ms-win-core-libraryloader-l1-2-0.a +libwinapi_mincore-api-ms-win-core-registry-l1-1-1.a +libwinapi_mincore-api-ms-win-core-file-l1-2-1.a +libwinapi_mincore-api-ms-win-core-fibers-l1-1-1.a +libwinapi_mincore-api-ms-win-core-debug-l1-1-1.a +libwinapi_mincore-userenv.a +libwinapi_mincore-api-ms-win-core-fibers-l1-1-0.a +libwinapi_mincore-api-ms-win-core-winrt-string-l1-1-1.a +libwinapi_mincore-api-ms-win-power-base-l1-1-0.a +libwinapi_mincore-api-ms-win-core-registry-l1-1-0.a +libwinapi_mincore-api-ms-win-devices-config-l1-1-2.a +libwinapi_mincore-api-ms-win-core-com-l1-1-0.a +libwinapi_mincore-api-ms-win-core-console-l2-1-0.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-2.a +libwinapi_mincore-api-ms-win-eventing-consumer-l1-1-1.a +libwinapi_mincore-api-ms-win-core-memory-l1-1-1.a +libwinapi_mincore-api-ms-win-core-interlocked-l1-1-0.a +libwinapi_mincore-api-ms-win-core-file-l2-1-2.a +libwinapi_mincore-api-ms-win-core-processthreads-l1-1-3.a +libwinapi_mincore-api-ms-win-core-heap-l1-1-0.a +libwinapi_mincore-api-ms-win-eventing-controller-l1-1-0.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l1-1-0.a new file mode 100644 index 0000000..7b4de17 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l2-1-0.a new file mode 100644 index 0000000..09b8589 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-normaliz-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-normaliz-l1-1-0.a new file mode 100644 index 0000000..7572554 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-normaliz-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-ole32-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-ole32-l1-1-0.a new file mode 100644 index 0000000..df8fd93 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-ole32-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shell32-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shell32-l1-1-0.a new file mode 100644 index 0000000..b1aeac5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shell32-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l1-1-0.a new file mode 100644 index 0000000..0608aab Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l2-1-0.a new file mode 100644 index 0000000..eaf6123 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-user32-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-user32-l1-1-0.a new file mode 100644 index 0000000..99be014 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-user32-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-version-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-version-l1-1-0.a new file mode 100644 index 0000000..b313ab0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel-api-ms-win-downlevel-version-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel.a new file mode 100644 index 0000000..fb66599 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mincore_downlevel.a @@ -0,0 +1,11 @@ +INPUT( +libwinapi_mincore_downlevel-api-ms-win-downlevel-ole32-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-advapi32-l2-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-version-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l2-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-shell32-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-user32-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-normaliz-l1-1-0.a +libwinapi_mincore_downlevel-api-ms-win-downlevel-shlwapi-l1-1-0.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mmdevapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mmdevapi.a new file mode 100644 index 0000000..a127d29 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mmdevapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mpr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mpr.a new file mode 100644 index 0000000..9d0e793 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mpr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mprapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mprapi.a new file mode 100644 index 0000000..959ae67 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mprapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mprsnap.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mprsnap.a new file mode 100644 index 0000000..8d324ca Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mprsnap.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mqrt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mqrt.a new file mode 100644 index 0000000..66b280b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mqrt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mrmsupport.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mrmsupport.a new file mode 100644 index 0000000..8be378e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mrmsupport.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msacm32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msacm32.a new file mode 100644 index 0000000..abf9a53 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msacm32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msajapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msajapi.a new file mode 100644 index 0000000..05382a4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msajapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mscms.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mscms.a new file mode 100644 index 0000000..c400892 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mscms.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msctfmonitor.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msctfmonitor.a new file mode 100644 index 0000000..afe449b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msctfmonitor.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msdelta.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msdelta.a new file mode 100644 index 0000000..5a53a36 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msdelta.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msdmo.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msdmo.a new file mode 100644 index 0000000..56ee4bc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msdmo.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msdrm.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msdrm.a new file mode 100644 index 0000000..ee83b3a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msdrm.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msi.a new file mode 100644 index 0000000..64f1cff Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msimg32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msimg32.a new file mode 100644 index 0000000..2f704d3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msimg32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mspatcha.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mspatcha.a new file mode 100644 index 0000000..43cc515 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mspatcha.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mspatchc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mspatchc.a new file mode 100644 index 0000000..14b103d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mspatchc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msports.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msports.a new file mode 100644 index 0000000..58749ed Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msports.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msrating.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msrating.a new file mode 100644 index 0000000..790a965 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msrating.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mstask.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mstask.a new file mode 100644 index 0000000..7603a13 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mstask.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msv1_0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msv1_0.a new file mode 100644 index 0000000..b2d85d6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msv1_0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msvfw32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msvfw32.a new file mode 100644 index 0000000..11c75ab Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_msvfw32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mswsock.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mswsock.a new file mode 100644 index 0000000..89a0984 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mtx.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mtx.a new file mode 100644 index 0000000..4d4e2b0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mtx.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mtxdm.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mtxdm.a new file mode 100644 index 0000000..2650cd8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_mtxdm.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-api-ms-win-net-isolation-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-api-ms-win-net-isolation-l1-1-0.a new file mode 100644 index 0000000..e09d66b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-api-ms-win-net-isolation-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-api-ms-win-net-isolation-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-api-ms-win-net-isolation-l1-1-1.a new file mode 100644 index 0000000..0def121 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-api-ms-win-net-isolation-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-clfsw32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-clfsw32.a new file mode 100644 index 0000000..cfd9dd2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-clfsw32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-clusapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-clusapi.a new file mode 100644 index 0000000..5970ee3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-clusapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-cryptxml.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-cryptxml.a new file mode 100644 index 0000000..74fba90 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-cryptxml.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-dbgeng.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-dbgeng.a new file mode 100644 index 0000000..8bf7734 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-dbgeng.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-dbghelp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-dbghelp.a new file mode 100644 index 0000000..d945fb6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-dbghelp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-dnsperf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-dnsperf.a new file mode 100644 index 0000000..cbf3fd6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-dnsperf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-esent.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-esent.a new file mode 100644 index 0000000..6fe9290 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-esent.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-faultrep.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-faultrep.a new file mode 100644 index 0000000..5bb5fea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-faultrep.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-framedynos.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-framedynos.a new file mode 100644 index 0000000..355f44d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-framedynos.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-fwpuclnt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-fwpuclnt.a new file mode 100644 index 0000000..9080983 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-fwpuclnt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-hbaapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-hbaapi.a new file mode 100644 index 0000000..9fc81e2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-hbaapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-httpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-httpapi.a new file mode 100644 index 0000000..38fc207 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-httpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-iscsidsc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-iscsidsc.a new file mode 100644 index 0000000..671cc8f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-iscsidsc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-ktmw32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-ktmw32.a new file mode 100644 index 0000000..f65813e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-ktmw32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-loadperf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-loadperf.a new file mode 100644 index 0000000..e67b376 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-loadperf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-mprapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-mprapi.a new file mode 100644 index 0000000..668f7f7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-mprapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-netsh.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-netsh.a new file mode 100644 index 0000000..22bf2b0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-netsh.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-ntdsapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-ntdsapi.a new file mode 100644 index 0000000..3af5629 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-ntdsapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-ntlanman.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-ntlanman.a new file mode 100644 index 0000000..aa0dab8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-ntlanman.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-pdh.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-pdh.a new file mode 100644 index 0000000..5fcc947 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-pdh.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-resutils.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-resutils.a new file mode 100644 index 0000000..33e44ce Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-resutils.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-snmpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-snmpapi.a new file mode 100644 index 0000000..532dd1a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-snmpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-tbs.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-tbs.a new file mode 100644 index 0000000..475f3bf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-tbs.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-traffic.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-traffic.a new file mode 100644 index 0000000..40bfd33 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-traffic.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-virtdisk.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-virtdisk.a new file mode 100644 index 0000000..92cab8b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-virtdisk.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-vssapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-vssapi.a new file mode 100644 index 0000000..8fb796a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-vssapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-webservices.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-webservices.a new file mode 100644 index 0000000..b3ca8f0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-webservices.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wer.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wer.a new file mode 100644 index 0000000..4e2227e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wer.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wevtapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wevtapi.a new file mode 100644 index 0000000..04f8e43 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wevtapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wintrust.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wintrust.a new file mode 100644 index 0000000..1f79b33 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wintrust.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wnvapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wnvapi.a new file mode 100644 index 0000000..bb9e17d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wnvapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wsmsvc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wsmsvc.a new file mode 100644 index 0000000..b0189ea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv-wsmsvc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv.a new file mode 100644 index 0000000..0cd62da --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nanosrv.a @@ -0,0 +1,36 @@ +INPUT( +libwinapi_nanosrv-netsh.a +libwinapi_nanosrv-hbaapi.a +libwinapi_nanosrv-virtdisk.a +libwinapi_nanosrv-ntdsapi.a +libwinapi_nanosrv-vssapi.a +libwinapi_nanosrv-api-ms-win-net-isolation-l1-1-1.a +libwinapi_nanosrv-dbgeng.a +libwinapi_nanosrv-pdh.a +libwinapi_nanosrv-ktmw32.a +libwinapi_nanosrv-clusapi.a +libwinapi_nanosrv-wer.a +libwinapi_nanosrv-httpapi.a +libwinapi_nanosrv-snmpapi.a +libwinapi_nanosrv-clfsw32.a +libwinapi_nanosrv-esent.a +libwinapi_nanosrv-wintrust.a +libwinapi_nanosrv-mprapi.a +libwinapi_nanosrv-traffic.a +libwinapi_nanosrv-tbs.a +libwinapi_nanosrv-ntlanman.a +libwinapi_nanosrv-iscsidsc.a +libwinapi_nanosrv-faultrep.a +libwinapi_nanosrv-dnsperf.a +libwinapi_nanosrv-wevtapi.a +libwinapi_nanosrv-resutils.a +libwinapi_nanosrv-wsmsvc.a +libwinapi_nanosrv-dbghelp.a +libwinapi_nanosrv-loadperf.a +libwinapi_nanosrv-wnvapi.a +libwinapi_nanosrv-fwpuclnt.a +libwinapi_nanosrv-cryptxml.a +libwinapi_nanosrv-api-ms-win-net-isolation-l1-1-0.a +libwinapi_nanosrv-framedynos.a +libwinapi_nanosrv-webservices.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ncrypt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ncrypt.a new file mode 100644 index 0000000..ea1cf5a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ncrypt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nddeapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nddeapi.a new file mode 100644 index 0000000..1fc19b2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_nddeapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ndfapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ndfapi.a new file mode 100644 index 0000000..c63db8a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ndfapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_netapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_netapi32.a new file mode 100644 index 0000000..ed625a4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_netapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_netsh.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_netsh.a new file mode 100644 index 0000000..9bd1f99 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_netsh.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_newdev.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_newdev.a new file mode 100644 index 0000000..c6b4305 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_newdev.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ninput.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ninput.a new file mode 100644 index 0000000..efc3749 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ninput.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_normaliz.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_normaliz.a new file mode 100644 index 0000000..c09e953 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_normaliz.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdll.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdll.a new file mode 100644 index 0000000..a8115e6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdll.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsa.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsa.a new file mode 100644 index 0000000..f83d7be Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsa.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsapi.a new file mode 100644 index 0000000..b2f0c7a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsatq.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsatq.a new file mode 100644 index 0000000..05fe288 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsatq.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsetup.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsetup.a new file mode 100644 index 0000000..6d339a7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntdsetup.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntfrsapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntfrsapi.a new file mode 100644 index 0000000..ac632db Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntfrsapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntlanman.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntlanman.a new file mode 100644 index 0000000..e96d7fa Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntlanman.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntmarta.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntmarta.a new file mode 100644 index 0000000..8e615be Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntmarta.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntquery.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntquery.a new file mode 100644 index 0000000..7eabf2e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ntquery.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_odbc32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_odbc32.a new file mode 100644 index 0000000..a9deb72 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_odbc32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_odbcbcp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_odbcbcp.a new file mode 100644 index 0000000..58e32ba Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_odbcbcp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oemlicense.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oemlicense.a new file mode 100644 index 0000000..0a15b7f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oemlicense.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ole32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ole32.a new file mode 100644 index 0000000..9e63fcc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ole32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oleacc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oleacc.a new file mode 100644 index 0000000..3794183 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oleacc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oleaut32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oleaut32.a new file mode 100644 index 0000000..1ba6706 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_olecli32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_olecli32.a new file mode 100644 index 0000000..a601f64 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_olecli32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oledlg.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oledlg.a new file mode 100644 index 0000000..51e77ac Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_oledlg.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_olesvr32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_olesvr32.a new file mode 100644 index 0000000..3b97242 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_olesvr32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ondemandconnroutehelper.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ondemandconnroutehelper.a new file mode 100644 index 0000000..f2f6cec Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ondemandconnroutehelper.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-atoms-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-atoms-l1-1-0.a new file mode 100644 index 0000000..87920a1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-atoms-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-calendar-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-calendar-l1-1-0.a new file mode 100644 index 0000000..edd5b98 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-calendar-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-0.a new file mode 100644 index 0000000..8f47df2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-1.a new file mode 100644 index 0000000..53dd13b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-2.a new file mode 100644 index 0000000..dbb682a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-midlproxystub-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-midlproxystub-l1-1-0.a new file mode 100644 index 0000000..8bfce59 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-com-midlproxystub-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-0.a new file mode 100644 index 0000000..bf188d6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-1.a new file mode 100644 index 0000000..b5c267c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-comm-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-ansi-l2-1-0.a new file mode 100644 index 0000000..61b9123 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l1-1-0.a new file mode 100644 index 0000000..baeb6f4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l2-1-0.a new file mode 100644 index 0000000..f6e4ba4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l3-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l3-1-0.a new file mode 100644 index 0000000..73e3cc0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-console-l3-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-0.a new file mode 100644 index 0000000..2e5d78c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-1.a new file mode 100644 index 0000000..0cde1ef Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-2.a new file mode 100644 index 0000000..d7bb859 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-datetime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-0.a new file mode 100644 index 0000000..0dfe6dd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-1.a new file mode 100644 index 0000000..624c7c4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-2.a new file mode 100644 index 0000000..8578294 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-debug-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-0.a new file mode 100644 index 0000000..922e68c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-1.a new file mode 100644 index 0000000..aace11e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-delayload-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-0.a new file mode 100644 index 0000000..4370369 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-1.a new file mode 100644 index 0000000..fde61e0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-enclave-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-0.a new file mode 100644 index 0000000..8d475ad Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-1.a new file mode 100644 index 0000000..7fca348 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-2.a new file mode 100644 index 0000000..5ea3df1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-3.a new file mode 100644 index 0000000..b28b721 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-0.a new file mode 100644 index 0000000..9506351 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-1.a new file mode 100644 index 0000000..50a0eed Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-0.a new file mode 100644 index 0000000..eae9ed9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-1.a new file mode 100644 index 0000000..9f0a7f8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-0.a new file mode 100644 index 0000000..5d4ce9e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-1.a new file mode 100644 index 0000000..fdccf67 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-fibers-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l1-1-0.a new file mode 100644 index 0000000..632c71e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l2-1-0.a new file mode 100644 index 0000000..8d99088 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-1-0.a new file mode 100644 index 0000000..ba40d51 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-0.a new file mode 100644 index 0000000..f8f32b9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-1.a new file mode 100644 index 0000000..8765f89 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-2.a new file mode 100644 index 0000000..cfe9892 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-0.a new file mode 100644 index 0000000..fc4f3f5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-1.a new file mode 100644 index 0000000..2e05450 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-2.a new file mode 100644 index 0000000..75c9289 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-3.a new file mode 100644 index 0000000..c0adc7b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-file-l2-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-firmware-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-firmware-l1-1-0.a new file mode 100644 index 0000000..dd74677 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-firmware-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-handle-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-handle-l1-1-0.a new file mode 100644 index 0000000..94f2b88 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-handle-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l1-1-0.a new file mode 100644 index 0000000..7bf1cf1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l2-1-0.a new file mode 100644 index 0000000..14aae16 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-obsolete-l1-1-0.a new file mode 100644 index 0000000..f95a326 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-heap-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-1-0.a new file mode 100644 index 0000000..046c4b9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-2-0.a new file mode 100644 index 0000000..5fcacf2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-interlocked-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-0.a new file mode 100644 index 0000000..8158b7c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-1.a new file mode 100644 index 0000000..3f235e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-io-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l1-1-0.a new file mode 100644 index 0000000..a88281b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-0.a new file mode 100644 index 0000000..0aa221c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-1.a new file mode 100644 index 0000000..904f87e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-job-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a new file mode 100644 index 0000000..e1cf8eb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-0.a new file mode 100644 index 0000000..a6ade32 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-1.a new file mode 100644 index 0000000..155b2b3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-2.a new file mode 100644 index 0000000..6e3debc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-3.a new file mode 100644 index 0000000..ef9d17e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-4.a new file mode 100644 index 0000000..db5c54e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-5.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-5.a new file mode 100644 index 0000000..ffca9df Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-5.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-6.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-6.a new file mode 100644 index 0000000..e87e404 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-6.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-largeinteger-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-largeinteger-l1-1-0.a new file mode 100644 index 0000000..2def2c8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-largeinteger-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-0.a new file mode 100644 index 0000000..e390a2c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-1.a new file mode 100644 index 0000000..7e32220 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-2.a new file mode 100644 index 0000000..c03ba14 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l2-1-0.a new file mode 100644 index 0000000..1f76298 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-libraryloader-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-ansi-l1-1-0.a new file mode 100644 index 0000000..a5450e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-0.a new file mode 100644 index 0000000..ec19275 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-1.a new file mode 100644 index 0000000..04db6c7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-2.a new file mode 100644 index 0000000..e01b733 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l2-1-0.a new file mode 100644 index 0000000..7bb9fae Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-obsolete-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-obsolete-l1-2-0.a new file mode 100644 index 0000000..29c100c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-localization-obsolete-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-0.a new file mode 100644 index 0000000..4275876 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-1.a new file mode 100644 index 0000000..0140955 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-2.a new file mode 100644 index 0000000..447c686 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-3.a new file mode 100644 index 0000000..e5eec8c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-4.a new file mode 100644 index 0000000..adf5eec Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-5.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-5.a new file mode 100644 index 0000000..3231b19 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-memory-l1-1-5.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-0.a new file mode 100644 index 0000000..6660b29 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-1.a new file mode 100644 index 0000000..38ab3fb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-1-0.a new file mode 100644 index 0000000..286097f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-1.a new file mode 100644 index 0000000..a15a95b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-2.a new file mode 100644 index 0000000..c431e08 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-ansi-l1-1-0.a new file mode 100644 index 0000000..70d421d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-l1-1-0.a new file mode 100644 index 0000000..8283513 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-namespace-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-normalization-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-normalization-l1-1-0.a new file mode 100644 index 0000000..311a01c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-normalization-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-path-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-path-l1-1-0.a new file mode 100644 index 0000000..888789a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-perfcounters-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-perfcounters-l1-1-0.a new file mode 100644 index 0000000..cd52aa5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-perfcounters-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-0.a new file mode 100644 index 0000000..4cae328 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-1.a new file mode 100644 index 0000000..7cc315e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-ansi-l1-1-0.a new file mode 100644 index 0000000..eeb1202 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-1-0.a new file mode 100644 index 0000000..9abe0b8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-2-0.a new file mode 100644 index 0000000..7ea0422 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processenvironment-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processsnapshot-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processsnapshot-l1-1-0.a new file mode 100644 index 0000000..0529465 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processsnapshot-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-0.a new file mode 100644 index 0000000..30835b4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-1.a new file mode 100644 index 0000000..6b5192e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-2.a new file mode 100644 index 0000000..f488b03 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-3.a new file mode 100644 index 0000000..7a057ae Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processthreads-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-l1-1-0.a new file mode 100644 index 0000000..4947d65 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a new file mode 100644 index 0000000..9b6e6be Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a new file mode 100644 index 0000000..5c8d995 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-profile-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-profile-l1-1-0.a new file mode 100644 index 0000000..1c5420d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-profile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-ansi-l1-1-0.a new file mode 100644 index 0000000..e4e209c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-l1-1-0.a new file mode 100644 index 0000000..f32e75e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-psapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-0.a new file mode 100644 index 0000000..5004db8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-1.a new file mode 100644 index 0000000..886d7f2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-quirks-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-0.a new file mode 100644 index 0000000..b8fb910 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-1.a new file mode 100644 index 0000000..8480840 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-2.a new file mode 100644 index 0000000..994fad5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-realtime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-0.a new file mode 100644 index 0000000..cb78933 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-1.a new file mode 100644 index 0000000..eb40f9d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-2.a new file mode 100644 index 0000000..5b2e934 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l2-1-0.a new file mode 100644 index 0000000..6218d2d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-registry-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-1-0.a new file mode 100644 index 0000000..72c270e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-2-0.a new file mode 100644 index 0000000..81481f0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-rtlsupport-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-ansi-l1-1-0.a new file mode 100644 index 0000000..b21ca1d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-0.a new file mode 100644 index 0000000..613818c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-1.a new file mode 100644 index 0000000..bc85027 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-shutdown-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-ansi-l1-1-0.a new file mode 100644 index 0000000..96440d1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-l1-1-0.a new file mode 100644 index 0000000..ea1a271 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sidebyside-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l1-1-0.a new file mode 100644 index 0000000..d9cdc6d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-0.a new file mode 100644 index 0000000..0e79303 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-1.a new file mode 100644 index 0000000..4ed0527 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-0.a new file mode 100644 index 0000000..f3ea414 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-1.a new file mode 100644 index 0000000..bb61bd6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-stringansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-stringansi-l1-1-0.a new file mode 100644 index 0000000..fefe50c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-stringansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-ansi-l1-1-0.a new file mode 100644 index 0000000..a8eb122 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-1-0.a new file mode 100644 index 0000000..35b239c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-0.a new file mode 100644 index 0000000..01b5f0e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-1.a new file mode 100644 index 0000000..10c68e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-synch-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-1-0.a new file mode 100644 index 0000000..c418749 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-0.a new file mode 100644 index 0000000..ac24223 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-1.a new file mode 100644 index 0000000..e32f5ea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-2.a new file mode 100644 index 0000000..e8ed02e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-3.a new file mode 100644 index 0000000..48cd52e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-0.a new file mode 100644 index 0000000..b2f7c2c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-1.a new file mode 100644 index 0000000..e8c768f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-l1-2-0.a new file mode 100644 index 0000000..697b0f0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-legacy-l1-1-0.a new file mode 100644 index 0000000..894669e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-threadpool-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-timezone-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-timezone-l1-1-0.a new file mode 100644 index 0000000..107277e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-timezone-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-0.a new file mode 100644 index 0000000..35ad9ef Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-1.a new file mode 100644 index 0000000..424f121 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-url-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-url-l1-1-0.a new file mode 100644 index 0000000..32047b9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-url-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-0.a new file mode 100644 index 0000000..3facd6d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-1.a new file mode 100644 index 0000000..0032a54 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-util-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-0.a new file mode 100644 index 0000000..cf48fa5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-1.a new file mode 100644 index 0000000..0005443 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-version-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-0.a new file mode 100644 index 0000000..5ee0343 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-1.a new file mode 100644 index 0000000..56512f4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-versionansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowsceip-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowsceip-l1-1-0.a new file mode 100644 index 0000000..840ad3d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowsceip-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-0.a new file mode 100644 index 0000000..cf72ff5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-1.a new file mode 100644 index 0000000..158c2dd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-2.a new file mode 100644 index 0000000..482c8df Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-0.a new file mode 100644 index 0000000..6c3369f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-1.a new file mode 100644 index 0000000..0c48c43 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..a619e5f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-registration-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-registration-l1-1-0.a new file mode 100644 index 0000000..8eefbaf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-registration-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-robuffer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-robuffer-l1-1-0.a new file mode 100644 index 0000000..42c56f6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-robuffer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a new file mode 100644 index 0000000..c5d853d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-0.a new file mode 100644 index 0000000..8bebbf2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-1.a new file mode 100644 index 0000000..0081ed2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-0.a new file mode 100644 index 0000000..7bd6ddf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-1.a new file mode 100644 index 0000000..3d76d2e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-2.a new file mode 100644 index 0000000..a0c0a79 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-wow64-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-xstate-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-xstate-l2-1-0.a new file mode 100644 index 0000000..f4f87ec Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-xstate-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-1.a new file mode 100644 index 0000000..1b19466 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-2.a new file mode 100644 index 0000000..98b54d3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-config-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-0.a new file mode 100644 index 0000000..cf03890 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-1.a new file mode 100644 index 0000000..c501e6a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-classicprovider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-classicprovider-l1-1-0.a new file mode 100644 index 0000000..3d6883c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-classicprovider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-0.a new file mode 100644 index 0000000..ffdf7de Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-1.a new file mode 100644 index 0000000..f53689e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-controller-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-controller-l1-1-0.a new file mode 100644 index 0000000..0cb309e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-controller-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-legacy-l1-1-0.a new file mode 100644 index 0000000..586b878 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-obsolete-l1-1-0.a new file mode 100644 index 0000000..7098dea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-provider-l1-1-0.a new file mode 100644 index 0000000..f47eea5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-tdh-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-tdh-l1-1-0.a new file mode 100644 index 0000000..14cac29 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-eventing-tdh-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-gaming-deviceinformation-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-gaming-deviceinformation-l1-1-0.a new file mode 100644 index 0000000..29458f6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-gaming-deviceinformation-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-mm-time-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-mm-time-l1-1-0.a new file mode 100644 index 0000000..0919a9c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-mm-time-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-oobe-notification-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-oobe-notification-l1-1-0.a new file mode 100644 index 0000000..6b65168 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-oobe-notification-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-perf-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-perf-legacy-l1-1-0.a new file mode 100644 index 0000000..df4b909 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-perf-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-base-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-base-l1-1-0.a new file mode 100644 index 0000000..18cc39f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-limitsmanagement-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-limitsmanagement-l1-1-0.a new file mode 100644 index 0000000..75f77ba Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-limitsmanagement-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-setting-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-setting-l1-1-0.a new file mode 100644 index 0000000..2e67a71 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-power-setting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-ro-typeresolution-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-ro-typeresolution-l1-1-0.a new file mode 100644 index 0000000..f5f2f1e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-ro-typeresolution-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-appcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-appcontainer-l1-1-0.a new file mode 100644 index 0000000..c666323 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-appcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-ansi-l1-1-0.a new file mode 100644 index 0000000..9ebf89a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-1-0.a new file mode 100644 index 0000000..48e50af Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-0.a new file mode 100644 index 0000000..5433b74 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-1.a new file mode 100644 index 0000000..dc93145 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-2.a new file mode 100644 index 0000000..7b979d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-base-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-credentials-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-credentials-l1-1-0.a new file mode 100644 index 0000000..7f60c70 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-credentials-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-cryptoapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-cryptoapi-l1-1-0.a new file mode 100644 index 0000000..da06049 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-cryptoapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-isolatedcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-isolatedcontainer-l1-1-0.a new file mode 100644 index 0000000..94293b4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-isolatedcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-ansi-l2-1-0.a new file mode 100644 index 0000000..f9b23c5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-0.a new file mode 100644 index 0000000..0f4f177 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-1.a new file mode 100644 index 0000000..30b9493 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-ansi-l1-1-0.a new file mode 100644 index 0000000..3878a06 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-l1-1-0.a new file mode 100644 index 0000000..83b2ce9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-ansi-l1-1-0.a new file mode 100644 index 0000000..ba1e9d6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-l1-1-0.a new file mode 100644 index 0000000..806feca Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-sddl-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-systemfunctions-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-systemfunctions-l1-1-0.a new file mode 100644 index 0000000..8ba2573 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-security-systemfunctions-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-0.a new file mode 100644 index 0000000..676481b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-1.a new file mode 100644 index 0000000..5f44695 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-0.a new file mode 100644 index 0000000..5f839c3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-1.a new file mode 100644 index 0000000..a675a98 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-2.a new file mode 100644 index 0000000..78191e9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-core-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l1-1-0.a new file mode 100644 index 0000000..095c6f7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l2-1-0.a new file mode 100644 index 0000000..42f56be Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-management-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-winsvc-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-winsvc-l1-1-0.a new file mode 100644 index 0000000..022bfde Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-service-winsvc-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-path-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-path-l1-1-0.a new file mode 100644 index 0000000..78d88c5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-0.a new file mode 100644 index 0000000..23a7618 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-1.a new file mode 100644 index 0000000..1b4f5f4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-registry-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-0.a new file mode 100644 index 0000000..c0727cb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-1.a new file mode 100644 index 0000000..4dff840 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-2.a new file mode 100644 index 0000000..d5b5a8c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-stream-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-stream-winrt-l1-1-0.a new file mode 100644 index 0000000..b1db715 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-stream-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-sysinfo-l1-1-0.a new file mode 100644 index 0000000..863c254 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-unicodeansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-unicodeansi-l1-1-0.a new file mode 100644 index 0000000..79ea315 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shcore-unicodeansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shell-shdirectory-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shell-shdirectory-l1-1-0.a new file mode 100644 index 0000000..4303612 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-shell-shdirectory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-authz.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-authz.a new file mode 100644 index 0000000..ed3b2db Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-authz.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-bcrypt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-bcrypt.a new file mode 100644 index 0000000..404271f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-bcrypt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cabinet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cabinet.a new file mode 100644 index 0000000..19e8cc8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-crypt32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-crypt32.a new file mode 100644 index 0000000..e6415b2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-crypt32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptbase.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptbase.a new file mode 100644 index 0000000..3af9a71 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptbase.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptnet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptnet.a new file mode 100644 index 0000000..9d7a148 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-cryptnet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dfscli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dfscli.a new file mode 100644 index 0000000..01bb89a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dfscli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dnsapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dnsapi.a new file mode 100644 index 0000000..fc0c71f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dnsapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsparse.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsparse.a new file mode 100644 index 0000000..c650e9d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsparse.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsrole.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsrole.a new file mode 100644 index 0000000..24ce85a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-dsrole.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-fltlib.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-fltlib.a new file mode 100644 index 0000000..f225936 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-fltlib.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-iphlpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-iphlpapi.a new file mode 100644 index 0000000..9a565f3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-iphlpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-logoncli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-logoncli.a new file mode 100644 index 0000000..223150a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-logoncli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mpr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mpr.a new file mode 100644 index 0000000..5c6d851 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mpr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mswsock.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mswsock.a new file mode 100644 index 0000000..1513278 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ncrypt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ncrypt.a new file mode 100644 index 0000000..8c0346d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ncrypt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-netutils.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-netutils.a new file mode 100644 index 0000000..742b903 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-netutils.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ntdll.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ntdll.a new file mode 100644 index 0000000..7713ea7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ntdll.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-oleaut32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-oleaut32.a new file mode 100644 index 0000000..f4d0be6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-powrprof.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-powrprof.a new file mode 100644 index 0000000..7c2fc90 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-powrprof.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-profapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-profapi.a new file mode 100644 index 0000000..b0f7ac0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-profapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-rpcrt4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-rpcrt4.a new file mode 100644 index 0000000..07d1abc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-samcli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-samcli.a new file mode 100644 index 0000000..bbbb1ea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-samcli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-schedcli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-schedcli.a new file mode 100644 index 0000000..7a558b2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-schedcli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-srvcli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-srvcli.a new file mode 100644 index 0000000..e0bd55b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-srvcli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-sspicli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-sspicli.a new file mode 100644 index 0000000..f371912 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-sspicli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-tokenbinding.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-tokenbinding.a new file mode 100644 index 0000000..c9e8a97 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-tokenbinding.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-userenv.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-userenv.a new file mode 100644 index 0000000..53b72e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-userenv.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-websocket.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-websocket.a new file mode 100644 index 0000000..1e1426f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-websocket.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-winhttp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-winhttp.a new file mode 100644 index 0000000..71812a4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-winhttp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wkscli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wkscli.a new file mode 100644 index 0000000..2c5a0bc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wkscli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wldap32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wldap32.a new file mode 100644 index 0000000..822dba5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-wldap32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ws2_32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ws2_32.a new file mode 100644 index 0000000..740404c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-xmllite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-xmllite.a new file mode 100644 index 0000000..cde101e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-xmllite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore.a new file mode 100644 index 0000000..73de4a1 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore.a @@ -0,0 +1,257 @@ +INPUT( +libwinapi_onecore-api-ms-win-core-timezone-l1-1-0.a +libwinapi_onecore-api-ms-win-service-winsvc-l1-1-0.a +libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-1.a +libwinapi_onecore-api-ms-win-core-com-midlproxystub-l1-1-0.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-0.a +libwinapi_onecore-api-ms-win-core-io-l1-1-1.a +libwinapi_onecore-api-ms-win-core-comm-l1-1-0.a +libwinapi_onecore-api-ms-win-service-core-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-service-management-l2-1-0.a +libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-0.a +libwinapi_onecore-api-ms-win-core-enclave-l1-1-0.a +libwinapi_onecore-api-ms-win-security-sddl-l1-1-0.a +libwinapi_onecore-api-ms-win-core-io-l1-1-0.a +libwinapi_onecore-api-ms-win-core-realtime-l1-1-1.a +libwinapi_onecore-dsparse.a +libwinapi_onecore-wkscli.a +libwinapi_onecore-api-ms-win-core-processenvironment-l1-1-0.a +libwinapi_onecore-api-ms-win-core-processthreads-l1-1-0.a +libwinapi_onecore-api-ms-win-security-provider-l1-1-0.a +libwinapi_onecore-api-ms-win-core-util-l1-1-1.a +libwinapi_onecore-api-ms-win-core-enclave-l1-1-1.a +libwinapi_onecore-api-ms-win-core-file-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-eventing-obsolete-l1-1-0.a +libwinapi_onecore-api-ms-win-service-core-l1-1-1.a +libwinapi_onecore-api-ms-win-security-isolatedcontainer-l1-1-0.a +libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-1.a +libwinapi_onecore-api-ms-win-core-processenvironment-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-util-l1-1-0.a +libwinapi_onecore-api-ms-win-core-file-l1-2-1.a +libwinapi_onecore-cryptbase.a +libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-0.a +libwinapi_onecore-api-ms-win-core-version-l1-1-0.a +libwinapi_onecore-api-ms-win-core-interlocked-l1-2-0.a +libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-0.a +libwinapi_onecore-ws2_32.a +libwinapi_onecore-api-ms-win-security-base-l1-2-0.a +libwinapi_onecore-api-ms-win-core-sidebyside-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-perfcounters-l1-1-0.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-5.a +libwinapi_onecore-api-ms-win-security-credentials-l1-1-0.a +libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-1.a +libwinapi_onecore-api-ms-win-core-sysinfo-l1-1-0.a +libwinapi_onecore-api-ms-win-core-job-l2-1-1.a +libwinapi_onecore-api-ms-win-core-threadpool-l1-2-0.a +libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-2.a +libwinapi_onecore-api-ms-win-shell-shdirectory-l1-1-0.a +libwinapi_onecore-api-ms-win-service-core-l1-1-2.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-3.a +libwinapi_onecore-api-ms-win-eventing-tdh-l1-1-0.a +libwinapi_onecore-api-ms-win-security-base-l1-2-2.a +libwinapi_onecore-api-ms-win-core-console-l1-1-0.a +libwinapi_onecore-api-ms-win-core-string-l1-1-0.a +libwinapi_onecore-srvcli.a +libwinapi_onecore-api-ms-win-core-registry-l2-1-0.a +libwinapi_onecore-api-ms-win-mm-time-l1-1-0.a +libwinapi_onecore-userenv.a +libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-2.a +libwinapi_onecore-api-ms-win-core-winrt-string-l1-1-0.a +libwinapi_onecore-api-ms-win-core-interlocked-l1-1-0.a +libwinapi_onecore-api-ms-win-core-file-l1-1-0.a +libwinapi_onecore-api-ms-win-core-console-l3-1-0.a +libwinapi_onecore-api-ms-win-core-synch-l1-1-0.a +libwinapi_onecore-api-ms-win-core-console-l2-1-0.a +libwinapi_onecore-ntdll.a +libwinapi_onecore-api-ms-win-core-fibers-l2-1-1.a +libwinapi_onecore-api-ms-win-core-delayload-l1-1-1.a +libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-1.a +libwinapi_onecore-authz.a +libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-1.a +libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-1.a +libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-0.a +libwinapi_onecore-api-ms-win-core-file-l1-2-2.a +libwinapi_onecore-api-ms-win-shcore-registry-l1-1-1.a +libwinapi_onecore-api-ms-win-core-realtime-l1-1-2.a +libwinapi_onecore-dsrole.a +libwinapi_onecore-api-ms-win-core-comm-l1-1-1.a +libwinapi_onecore-xmllite.a +libwinapi_onecore-api-ms-win-core-sidebyside-l1-1-0.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-5.a +libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-1.a +libwinapi_onecore-api-ms-win-core-job-l1-1-0.a +libwinapi_onecore-api-ms-win-core-quirks-l1-1-1.a +libwinapi_onecore-api-ms-win-core-registry-l1-1-1.a +libwinapi_onecore-api-ms-win-eventing-legacy-l1-1-0.a +libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-1.a +libwinapi_onecore-api-ms-win-core-file-l1-2-0.a +libwinapi_onecore-api-ms-win-security-base-l1-1-0.a +libwinapi_onecore-fltlib.a +libwinapi_onecore-mswsock.a +libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-0.a +libwinapi_onecore-api-ms-win-security-cryptoapi-l1-1-0.a +libwinapi_onecore-cryptnet.a +libwinapi_onecore-iphlpapi.a +libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-0.a +libwinapi_onecore-oleaut32.a +libwinapi_onecore-api-ms-win-core-localization-l1-2-1.a +libwinapi_onecore-api-ms-win-core-psapi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-quirks-l1-1-0.a +libwinapi_onecore-api-ms-win-core-libraryloader-l1-2-0.a +libwinapi_onecore-api-ms-win-core-threadpool-legacy-l1-1-0.a +libwinapi_onecore-api-ms-win-core-shutdown-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a +libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a +libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-1.a +libwinapi_onecore-api-ms-win-core-localization-l1-2-2.a +libwinapi_onecore-api-ms-win-core-shutdown-l1-1-0.a +libwinapi_onecore-api-ms-win-devices-config-l1-1-2.a +libwinapi_onecore-api-ms-win-core-localization-l2-1-0.a +libwinapi_onecore-api-ms-win-core-datetime-l1-1-1.a +libwinapi_onecore-api-ms-win-devices-config-l1-1-1.a +libwinapi_onecore-api-ms-win-core-wow64-l1-1-1.a +libwinapi_onecore-api-ms-win-core-winrt-l1-1-0.a +libwinapi_onecore-api-ms-win-core-xstate-l2-1-0.a +libwinapi_onecore-api-ms-win-core-toolhelp-l1-1-1.a +libwinapi_onecore-api-ms-win-core-wow64-l1-1-0.a +libwinapi_onecore-api-ms-win-core-registry-l1-1-2.a +libwinapi_onecore-api-ms-win-power-setting-l1-1-0.a +libwinapi_onecore-api-ms-win-core-console-ansi-l2-1-0.a +libwinapi_onecore-api-ms-win-core-datetime-l1-1-2.a +libwinapi_onecore-api-ms-win-core-atoms-l1-1-0.a +libwinapi_onecore-logoncli.a +libwinapi_onecore-api-ms-win-core-namespace-l1-1-0.a +libwinapi_onecore-api-ms-win-core-handle-l1-1-0.a +libwinapi_onecore-api-ms-win-core-realtime-l1-1-0.a +libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-1.a +libwinapi_onecore-sspicli.a +libwinapi_onecore-api-ms-win-security-provider-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-winrt-error-l1-1-0.a +libwinapi_onecore-api-ms-win-security-appcontainer-l1-1-0.a +libwinapi_onecore-api-ms-win-core-versionansi-l1-1-1.a +libwinapi_onecore-api-ms-win-core-shutdown-l1-1-1.a +libwinapi_onecore-api-ms-win-core-job-l2-1-0.a +libwinapi_onecore-api-ms-win-core-processenvironment-l1-2-0.a +libwinapi_onecore-api-ms-win-core-wow64-l1-1-2.a +libwinapi_onecore-samcli.a +libwinapi_onecore-crypt32.a +libwinapi_onecore-api-ms-win-core-rtlsupport-l1-2-0.a +libwinapi_onecore-api-ms-win-core-namedpipe-l1-1-0.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-0.a +libwinapi_onecore-api-ms-win-shcore-scaling-l1-1-1.a +libwinapi_onecore-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a +libwinapi_onecore-api-ms-win-core-synch-l1-2-1.a +libwinapi_onecore-api-ms-win-core-file-l2-1-1.a +libwinapi_onecore-api-ms-win-core-privateprofile-l1-1-1.a +libwinapi_onecore-api-ms-win-core-firmware-l1-1-0.a +libwinapi_onecore-api-ms-win-core-winrt-robuffer-l1-1-0.a +libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-0.a +libwinapi_onecore-api-ms-win-eventing-controller-l1-1-0.a +libwinapi_onecore-api-ms-win-power-limitsmanagement-l1-1-0.a +libwinapi_onecore-api-ms-win-core-datetime-l1-1-0.a +libwinapi_onecore-schedcli.a +libwinapi_onecore-api-ms-win-core-processthreads-l1-1-1.a +libwinapi_onecore-api-ms-win-core-localization-l1-2-0.a +libwinapi_onecore-profapi.a +libwinapi_onecore-api-ms-win-ro-typeresolution-l1-1-0.a +libwinapi_onecore-api-ms-win-core-namespace-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-shcore-registry-l1-1-0.a +libwinapi_onecore-api-ms-win-core-string-l2-1-1.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-1.a +libwinapi_onecore-api-ms-win-core-fibers-l2-1-0.a +libwinapi_onecore-api-ms-win-security-sddl-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-eventing-consumer-l1-1-1.a +libwinapi_onecore-api-ms-win-core-localization-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-file-l2-1-2.a +libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-2.a +libwinapi_onecore-api-ms-win-security-base-l1-2-1.a +libwinapi_onecore-api-ms-win-core-localization-obsolete-l1-2-0.a +libwinapi_onecore-api-ms-win-core-heap-obsolete-l1-1-0.a +libwinapi_onecore-tokenbinding.a +libwinapi_onecore-rpcrt4.a +libwinapi_onecore-api-ms-win-core-fibers-l1-1-1.a +libwinapi_onecore-powrprof.a +libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-0.a +libwinapi_onecore-api-ms-win-core-synch-ansi-l1-1-0.a +libwinapi_onecore-dnsapi.a +libwinapi_onecore-api-ms-win-core-debug-l1-1-2.a +libwinapi_onecore-api-ms-win-core-registry-l1-1-0.a +libwinapi_onecore-api-ms-win-core-file-l2-1-0.a +libwinapi_onecore-api-ms-win-core-calendar-l1-1-0.a +libwinapi_onecore-api-ms-win-core-processthreads-l1-1-3.a +libwinapi_onecore-api-ms-win-core-version-l1-1-1.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-2.a +libwinapi_onecore-api-ms-win-core-largeinteger-l1-1-0.a +libwinapi_onecore-api-ms-win-core-namedpipe-l1-2-2.a +libwinapi_onecore-api-ms-win-service-core-l1-1-0.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-shcore-unicodeansi-l1-1-0.a +libwinapi_onecore-mpr.a +libwinapi_onecore-api-ms-win-shcore-path-l1-1-0.a +libwinapi_onecore-api-ms-win-core-processsnapshot-l1-1-0.a +libwinapi_onecore-api-ms-win-core-windowserrorreporting-l1-1-2.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-1.a +libwinapi_onecore-api-ms-win-shcore-stream-winrt-l1-1-0.a +libwinapi_onecore-api-ms-win-core-namedpipe-ansi-l1-1-1.a +libwinapi_onecore-api-ms-win-service-management-l1-1-0.a +libwinapi_onecore-api-ms-win-core-stringansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-featurestaging-l1-1-1.a +libwinapi_onecore-api-ms-win-core-windowsceip-l1-1-0.a +libwinapi_onecore-api-ms-win-core-path-l1-1-0.a +libwinapi_onecore-api-ms-win-core-url-l1-1-0.a +libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-3.a +libwinapi_onecore-websocket.a +libwinapi_onecore-api-ms-win-perf-legacy-l1-1-0.a +libwinapi_onecore-api-ms-win-devices-swdevice-l1-1-0.a +libwinapi_onecore-api-ms-win-core-systemtopology-l1-1-0.a +libwinapi_onecore-cabinet.a +libwinapi_onecore-api-ms-win-eventing-classicprovider-l1-1-0.a +libwinapi_onecore-netutils.a +libwinapi_onecore-api-ms-win-core-string-l2-1-0.a +libwinapi_onecore-api-ms-win-core-heap-l1-1-0.a +libwinapi_onecore-api-ms-win-core-debug-l1-1-0.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-2.a +libwinapi_onecore-api-ms-win-core-debug-l1-1-1.a +libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-0.a +libwinapi_onecore-api-ms-win-core-file-l2-1-3.a +libwinapi_onecore-api-ms-win-security-base-ansi-l1-1-0.a +libwinapi_onecore-api-ms-win-core-com-l1-1-0.a +libwinapi_onecore-api-ms-win-core-winrt-registration-l1-1-0.a +libwinapi_onecore-api-ms-win-core-com-l1-1-1.a +libwinapi_onecore-bcrypt.a +libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-3.a +libwinapi_onecore-api-ms-win-security-lsalookup-l2-1-0.a +libwinapi_onecore-api-ms-win-core-versionansi-l1-1-0.a +libwinapi_onecore-api-ms-win-eventing-provider-l1-1-0.a +libwinapi_onecore-winhttp.a +libwinapi_onecore-api-ms-win-shcore-sysinfo-l1-1-0.a +libwinapi_onecore-api-ms-win-core-fibers-l1-1-0.a +libwinapi_onecore-api-ms-win-security-systemfunctions-l1-1-0.a +libwinapi_onecore-api-ms-win-security-lsalookup-ansi-l2-1-0.a +libwinapi_onecore-api-ms-win-core-heap-l2-1-0.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-4.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-4.a +libwinapi_onecore-api-ms-win-core-file-ansi-l2-1-0.a +libwinapi_onecore-api-ms-win-core-processthreads-l1-1-2.a +libwinapi_onecore-api-ms-win-core-profile-l1-1-0.a +libwinapi_onecore-ncrypt.a +libwinapi_onecore-api-ms-win-core-psapi-ansi-l1-1-0.a +libwinapi_onecore-dfscli.a +libwinapi_onecore-api-ms-win-power-base-l1-1-0.a +libwinapi_onecore-api-ms-win-core-errorhandling-l1-1-1.a +libwinapi_onecore-api-ms-win-core-rtlsupport-l1-1-0.a +libwinapi_onecore-api-ms-win-core-memory-l1-1-3.a +libwinapi_onecore-api-ms-win-core-synch-l1-2-0.a +libwinapi_onecore-api-ms-win-core-processtopology-l1-1-0.a +libwinapi_onecore-api-ms-win-core-normalization-l1-1-0.a +libwinapi_onecore-api-ms-win-gaming-deviceinformation-l1-1-0.a +libwinapi_onecore-api-ms-win-oobe-notification-l1-1-0.a +libwinapi_onecore-api-ms-win-core-sysinfo-l1-2-2.a +libwinapi_onecore-api-ms-win-core-kernel32-legacy-l1-1-6.a +libwinapi_onecore-api-ms-win-core-delayload-l1-1-0.a +libwinapi_onecore-wldap32.a +libwinapi_onecore-api-ms-win-core-libraryloader-l2-1-0.a +libwinapi_onecore-api-ms-win-core-com-l1-1-2.a +libwinapi_onecore-api-ms-win-core-string-obsolete-l1-1-1.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-advapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-advapi32.a new file mode 100644 index 0000000..13b6ff7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-advapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-apphelp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-apphelp.a new file mode 100644 index 0000000..7fb1309 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-apphelp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comctl32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comctl32.a new file mode 100644 index 0000000..2ef0585 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comctl32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comdlg32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comdlg32.a new file mode 100644 index 0000000..01f2d7c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-comdlg32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d10.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d10.a new file mode 100644 index 0000000..a4a11a8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d10.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d9.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d9.a new file mode 100644 index 0000000..07f693a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3d9.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3dx10_47.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3dx10_47.a new file mode 100644 index 0000000..f1525b3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-d3dx10_47.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-difxapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-difxapi.a new file mode 100644 index 0000000..4fc85db Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-difxapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-gdi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-gdi32.a new file mode 100644 index 0000000..0aaead0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-gdi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-input.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-input.a new file mode 100644 index 0000000..33824c8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-input.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-kernel32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-kernel32.a new file mode 100644 index 0000000..c6aa4b1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-kernel32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-msi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-msi.a new file mode 100644 index 0000000..ccad8d4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-msi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-newdev.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-newdev.a new file mode 100644 index 0000000..23b79e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-newdev.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-ole32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-ole32.a new file mode 100644 index 0000000..5d32d2d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-ole32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleacc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleacc.a new file mode 100644 index 0000000..456ecfe Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleacc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleaut32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleaut32.a new file mode 100644 index 0000000..4fec75c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oledlg.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oledlg.a new file mode 100644 index 0000000..27f2a8f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-oledlg.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-pdh.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-pdh.a new file mode 100644 index 0000000..9cdfffb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-pdh.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-psapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-psapi.a new file mode 100644 index 0000000..a13c23a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-psapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-resutils.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-resutils.a new file mode 100644 index 0000000..45ca5d5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-resutils.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-rstrtmgr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-rstrtmgr.a new file mode 100644 index 0000000..c7ad535 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-rstrtmgr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-secur32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-secur32.a new file mode 100644 index 0000000..dd5a816 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-secur32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-setupapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-setupapi.a new file mode 100644 index 0000000..440f89c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-setupapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shell32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shell32.a new file mode 100644 index 0000000..80bd734 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shell32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shlwapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shlwapi.a new file mode 100644 index 0000000..b4f9a91 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-shlwapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-tdh.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-tdh.a new file mode 100644 index 0000000..deb433a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-tdh.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-twinapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-twinapi.a new file mode 100644 index 0000000..24d40ed Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-twinapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-user32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-user32.a new file mode 100644 index 0000000..57c2392 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-user32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-uxtheme.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-uxtheme.a new file mode 100644 index 0000000..d70e492 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-uxtheme.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-version.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-version.a new file mode 100644 index 0000000..b6f5f4f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-version.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winmm.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winmm.a new file mode 100644 index 0000000..2504470 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winmm.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winspool.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winspool.a new file mode 100644 index 0000000..b719e9e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-winspool.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-wtsapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-wtsapi32.a new file mode 100644 index 0000000..bc6b087 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-wtsapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-xinput1_4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-xinput1_4.a new file mode 100644 index 0000000..d40324e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel-xinput1_4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel.a new file mode 100644 index 0000000..d9d2e7f --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore_downlevel.a @@ -0,0 +1,36 @@ +INPUT( +libwinapi_onecore_downlevel-d3d9.a +libwinapi_onecore_downlevel-resutils.a +libwinapi_onecore_downlevel-wtsapi32.a +libwinapi_onecore_downlevel-rstrtmgr.a +libwinapi_onecore_downlevel-input.a +libwinapi_onecore_downlevel-d3d10.a +libwinapi_onecore_downlevel-setupapi.a +libwinapi_onecore_downlevel-d3dx10_47.a +libwinapi_onecore_downlevel-gdi32.a +libwinapi_onecore_downlevel-user32.a +libwinapi_onecore_downlevel-newdev.a +libwinapi_onecore_downlevel-comctl32.a +libwinapi_onecore_downlevel-kernel32.a +libwinapi_onecore_downlevel-winspool.a +libwinapi_onecore_downlevel-secur32.a +libwinapi_onecore_downlevel-uxtheme.a +libwinapi_onecore_downlevel-oleacc.a +libwinapi_onecore_downlevel-oledlg.a +libwinapi_onecore_downlevel-oleaut32.a +libwinapi_onecore_downlevel-pdh.a +libwinapi_onecore_downlevel-apphelp.a +libwinapi_onecore_downlevel-difxapi.a +libwinapi_onecore_downlevel-psapi.a +libwinapi_onecore_downlevel-tdh.a +libwinapi_onecore_downlevel-comdlg32.a +libwinapi_onecore_downlevel-winmm.a +libwinapi_onecore_downlevel-twinapi.a +libwinapi_onecore_downlevel-advapi32.a +libwinapi_onecore_downlevel-ole32.a +libwinapi_onecore_downlevel-xinput1_4.a +libwinapi_onecore_downlevel-version.a +libwinapi_onecore_downlevel-shlwapi.a +libwinapi_onecore_downlevel-shell32.a +libwinapi_onecore_downlevel-msi.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-0.a new file mode 100644 index 0000000..4b60a8d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-1.a new file mode 100644 index 0000000..37796dd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-2.a new file mode 100644 index 0000000..3c8e1bd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-atoms-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-atoms-l1-1-0.a new file mode 100644 index 0000000..bd8771b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-atoms-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-calendar-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-calendar-l1-1-0.a new file mode 100644 index 0000000..f3de0ed Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-calendar-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-0.a new file mode 100644 index 0000000..23886f8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-1.a new file mode 100644 index 0000000..b69e68d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-2.a new file mode 100644 index 0000000..7965562 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l2-1-1.a new file mode 100644 index 0000000..79c95c6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-midlproxystub-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-midlproxystub-l1-1-0.a new file mode 100644 index 0000000..6ebfb7d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-com-midlproxystub-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-0.a new file mode 100644 index 0000000..75e8159 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-1.a new file mode 100644 index 0000000..3b30281 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-ansi-l2-1-0.a new file mode 100644 index 0000000..96e1b51 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l1-1-0.a new file mode 100644 index 0000000..38d587f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l2-1-0.a new file mode 100644 index 0000000..eab795a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l3-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l3-1-0.a new file mode 100644 index 0000000..8ea7355 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-console-l3-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-0.a new file mode 100644 index 0000000..e3acd55 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-1.a new file mode 100644 index 0000000..813b54b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-2.a new file mode 100644 index 0000000..02f67a6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-0.a new file mode 100644 index 0000000..afb379d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-1.a new file mode 100644 index 0000000..b1e7108 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-2.a new file mode 100644 index 0000000..5ed0238 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-0.a new file mode 100644 index 0000000..bffab6b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-1.a new file mode 100644 index 0000000..624dc47 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-0.a new file mode 100644 index 0000000..a245ec1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-1.a new file mode 100644 index 0000000..dd4595f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-0.a new file mode 100644 index 0000000..4b63773 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-1.a new file mode 100644 index 0000000..d0fe7e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-2.a new file mode 100644 index 0000000..f2fce25 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-3.a new file mode 100644 index 0000000..99f64f2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-0.a new file mode 100644 index 0000000..885eb7f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-1.a new file mode 100644 index 0000000..7f8b077 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-0.a new file mode 100644 index 0000000..e4d2df1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-1.a new file mode 100644 index 0000000..bcb9cfb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-0.a new file mode 100644 index 0000000..36ccc1a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-1.a new file mode 100644 index 0000000..b08e2df Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l1-1-0.a new file mode 100644 index 0000000..a1c8e5b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l2-1-0.a new file mode 100644 index 0000000..b96341b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-1-0.a new file mode 100644 index 0000000..ba013a7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-0.a new file mode 100644 index 0000000..fd67434 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-1.a new file mode 100644 index 0000000..40a8d28 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-2.a new file mode 100644 index 0000000..ee9b5c6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-0.a new file mode 100644 index 0000000..81afd31 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-1.a new file mode 100644 index 0000000..67353c0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-2.a new file mode 100644 index 0000000..68dc695 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-3.a new file mode 100644 index 0000000..be48281 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-file-l2-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-firmware-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-firmware-l1-1-0.a new file mode 100644 index 0000000..d3694d1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-firmware-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-handle-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-handle-l1-1-0.a new file mode 100644 index 0000000..77c9101 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-handle-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l1-1-0.a new file mode 100644 index 0000000..2dc7874 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l2-1-0.a new file mode 100644 index 0000000..7ead055 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-obsolete-l1-1-0.a new file mode 100644 index 0000000..e718fdd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-heap-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-1-0.a new file mode 100644 index 0000000..15adb8b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-2-0.a new file mode 100644 index 0000000..752ff63 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-0.a new file mode 100644 index 0000000..e8d8ac0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-1.a new file mode 100644 index 0000000..8e7f8b1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-io-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l1-1-0.a new file mode 100644 index 0000000..9d442cf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-0.a new file mode 100644 index 0000000..d78ed97 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-1.a new file mode 100644 index 0000000..54128f3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-job-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a new file mode 100644 index 0000000..98bc763 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-0.a new file mode 100644 index 0000000..cdd5223 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-1.a new file mode 100644 index 0000000..bb3e669 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-2.a new file mode 100644 index 0000000..babbd4b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-3.a new file mode 100644 index 0000000..57aaed6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-4.a new file mode 100644 index 0000000..3e4629f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-5.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-5.a new file mode 100644 index 0000000..c62d4e4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-5.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-6.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-6.a new file mode 100644 index 0000000..48ff45e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-6.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-largeinteger-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-largeinteger-l1-1-0.a new file mode 100644 index 0000000..5be8cc8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-largeinteger-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-0.a new file mode 100644 index 0000000..8f9d8cc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-1.a new file mode 100644 index 0000000..0dbcbde Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-2.a new file mode 100644 index 0000000..ba93a51 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l2-1-0.a new file mode 100644 index 0000000..5beddeb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-libraryloader-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-ansi-l1-1-0.a new file mode 100644 index 0000000..fe53ca1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-0.a new file mode 100644 index 0000000..6b6f3ab Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-1.a new file mode 100644 index 0000000..597a734 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-2.a new file mode 100644 index 0000000..ff3a73b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l2-1-0.a new file mode 100644 index 0000000..73068c9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-obsolete-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-obsolete-l1-2-0.a new file mode 100644 index 0000000..e184b14 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-localization-obsolete-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-0.a new file mode 100644 index 0000000..d482db3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-1.a new file mode 100644 index 0000000..85bb282 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-2.a new file mode 100644 index 0000000..35c5b4e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-3.a new file mode 100644 index 0000000..057d218 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-4.a new file mode 100644 index 0000000..9ec4f1e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-5.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-5.a new file mode 100644 index 0000000..2779da8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-5.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-0.a new file mode 100644 index 0000000..830399c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-1.a new file mode 100644 index 0000000..e5b93eb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-1-0.a new file mode 100644 index 0000000..3289282 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-1.a new file mode 100644 index 0000000..a6cf11f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-2.a new file mode 100644 index 0000000..d010b48 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-ansi-l1-1-0.a new file mode 100644 index 0000000..62b4a79 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-l1-1-0.a new file mode 100644 index 0000000..716f5ff Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-namespace-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-normalization-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-normalization-l1-1-0.a new file mode 100644 index 0000000..e9813e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-normalization-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-path-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-path-l1-1-0.a new file mode 100644 index 0000000..df20308 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-perfcounters-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-perfcounters-l1-1-0.a new file mode 100644 index 0000000..709550e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-perfcounters-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-0.a new file mode 100644 index 0000000..f03bf5b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-1.a new file mode 100644 index 0000000..7a54333 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-ansi-l1-1-0.a new file mode 100644 index 0000000..3a5497b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-1-0.a new file mode 100644 index 0000000..e2dac06 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-2-0.a new file mode 100644 index 0000000..300ebbd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processsnapshot-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processsnapshot-l1-1-0.a new file mode 100644 index 0000000..c3529db Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processsnapshot-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-0.a new file mode 100644 index 0000000..a31d61f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-1.a new file mode 100644 index 0000000..4139db2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-2.a new file mode 100644 index 0000000..b261a17 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-3.a new file mode 100644 index 0000000..6b5ac6a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-l1-1-0.a new file mode 100644 index 0000000..3660d62 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a new file mode 100644 index 0000000..c022a8d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a new file mode 100644 index 0000000..e450b83 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-profile-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-profile-l1-1-0.a new file mode 100644 index 0000000..5e63038 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-profile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-ansi-l1-1-0.a new file mode 100644 index 0000000..f2df8d7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-l1-1-0.a new file mode 100644 index 0000000..145f005 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psm-appnotify-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psm-appnotify-l1-1-0.a new file mode 100644 index 0000000..c213a69 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-psm-appnotify-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-0.a new file mode 100644 index 0000000..8dfc0ab Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-1.a new file mode 100644 index 0000000..2e935e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-0.a new file mode 100644 index 0000000..5d00a3e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-1.a new file mode 100644 index 0000000..4fddfeb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-2.a new file mode 100644 index 0000000..3cc9213 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-0.a new file mode 100644 index 0000000..109b4ee Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-1.a new file mode 100644 index 0000000..b90ba3d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-2.a new file mode 100644 index 0000000..de745de Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l2-1-0.a new file mode 100644 index 0000000..4c586ad Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-registry-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-1-0.a new file mode 100644 index 0000000..0ba540a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-2-0.a new file mode 100644 index 0000000..e5541c3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-ansi-l1-1-0.a new file mode 100644 index 0000000..0be5f13 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-0.a new file mode 100644 index 0000000..7c1dc69 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-1.a new file mode 100644 index 0000000..9faf458 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-ansi-l1-1-0.a new file mode 100644 index 0000000..cbdd359 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-l1-1-0.a new file mode 100644 index 0000000..cdcb061 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sidebyside-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-slapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-slapi-l1-1-0.a new file mode 100644 index 0000000..a525c4f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-slapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l1-1-0.a new file mode 100644 index 0000000..fb526b6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-0.a new file mode 100644 index 0000000..1f4b851 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-1.a new file mode 100644 index 0000000..1f782cd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-0.a new file mode 100644 index 0000000..9e05ef6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-1.a new file mode 100644 index 0000000..022212b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-stringansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-stringansi-l1-1-0.a new file mode 100644 index 0000000..019e70e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-stringansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-ansi-l1-1-0.a new file mode 100644 index 0000000..e0af344 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-1-0.a new file mode 100644 index 0000000..3992b7d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-0.a new file mode 100644 index 0000000..50be97b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-1.a new file mode 100644 index 0000000..939e55f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-1-0.a new file mode 100644 index 0000000..1fe3ad0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-0.a new file mode 100644 index 0000000..6df8704 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-1.a new file mode 100644 index 0000000..31c58dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-2.a new file mode 100644 index 0000000..eff7804 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-3.a new file mode 100644 index 0000000..67abc3c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-0.a new file mode 100644 index 0000000..130c974 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-1.a new file mode 100644 index 0000000..10259ec Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-l1-2-0.a new file mode 100644 index 0000000..614cac5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-legacy-l1-1-0.a new file mode 100644 index 0000000..a1ca3fe Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-threadpool-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-timezone-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-timezone-l1-1-0.a new file mode 100644 index 0000000..244ecea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-timezone-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-0.a new file mode 100644 index 0000000..b273fc9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-1.a new file mode 100644 index 0000000..561916f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-url-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-url-l1-1-0.a new file mode 100644 index 0000000..6c0b50e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-url-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-0.a new file mode 100644 index 0000000..8a156fd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-1.a new file mode 100644 index 0000000..b96b6c8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-util-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-0.a new file mode 100644 index 0000000..2d15770 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-1.a new file mode 100644 index 0000000..dade58d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-version-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-0.a new file mode 100644 index 0000000..cd16699 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-1.a new file mode 100644 index 0000000..95111af Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowsceip-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowsceip-l1-1-0.a new file mode 100644 index 0000000..21e50b2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowsceip-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a new file mode 100644 index 0000000..36a62c6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a new file mode 100644 index 0000000..1658383 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a new file mode 100644 index 0000000..1c8f1bd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-0.a new file mode 100644 index 0000000..749a8cc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-1.a new file mode 100644 index 0000000..7a0c18f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..cec82e9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-registration-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-registration-l1-1-0.a new file mode 100644 index 0000000..a8e03e7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-registration-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-robuffer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-robuffer-l1-1-0.a new file mode 100644 index 0000000..bc51a0a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-robuffer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a new file mode 100644 index 0000000..4de28a7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-0.a new file mode 100644 index 0000000..3b9e69d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-1.a new file mode 100644 index 0000000..3b559d7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-0.a new file mode 100644 index 0000000..bb8d5f0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-1.a new file mode 100644 index 0000000..4a1bb3c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-2.a new file mode 100644 index 0000000..a1cd338 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-xstate-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-xstate-l2-1-0.a new file mode 100644 index 0000000..f52fb73 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-xstate-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-1.a new file mode 100644 index 0000000..129a71d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-2.a new file mode 100644 index 0000000..7437b46 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-0.a new file mode 100644 index 0000000..5231128 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-1.a new file mode 100644 index 0000000..b7d359a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-0.a new file mode 100644 index 0000000..6b36a72 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-1.a new file mode 100644 index 0000000..0eb01e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-2.a new file mode 100644 index 0000000..8658e42 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-3.a new file mode 100644 index 0000000..245d2d8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-4.a new file mode 100644 index 0000000..66598ae Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-classicprovider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-classicprovider-l1-1-0.a new file mode 100644 index 0000000..ec27513 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-classicprovider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-0.a new file mode 100644 index 0000000..d86ed7f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-1.a new file mode 100644 index 0000000..cbc8cf9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-controller-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-controller-l1-1-0.a new file mode 100644 index 0000000..dce5d5b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-controller-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-legacy-l1-1-0.a new file mode 100644 index 0000000..bb5d05f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-obsolete-l1-1-0.a new file mode 100644 index 0000000..de185ea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-provider-l1-1-0.a new file mode 100644 index 0000000..1ffddea Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-tdh-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-tdh-l1-1-0.a new file mode 100644 index 0000000..9032501 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-eventing-tdh-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-deviceinformation-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-deviceinformation-l1-1-0.a new file mode 100644 index 0000000..95bdab5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-deviceinformation-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-expandedresources-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-expandedresources-l1-1-0.a new file mode 100644 index 0000000..6a6ef39 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-expandedresources-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-0.a new file mode 100644 index 0000000..2ab5d41 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-1.a new file mode 100644 index 0000000..7274d76 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-0.a new file mode 100644 index 0000000..da9d062 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-1.a new file mode 100644 index 0000000..9d610fe Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-2.a new file mode 100644 index 0000000..ef08053 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-3.a new file mode 100644 index 0000000..681fdd0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-4.a new file mode 100644 index 0000000..7f55f5e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-0.a new file mode 100644 index 0000000..a4fbccf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-1.a new file mode 100644 index 0000000..96e382d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-mme-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-mme-l1-1-0.a new file mode 100644 index 0000000..b62fbec Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-mme-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-playsound-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-playsound-l1-1-0.a new file mode 100644 index 0000000..48785f2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-playsound-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-time-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-time-l1-1-0.a new file mode 100644 index 0000000..f5d1752 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-mm-time-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ntuser-sysparams-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ntuser-sysparams-l1-1-0.a new file mode 100644 index 0000000..b318596 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ntuser-sysparams-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-oobe-notification-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-oobe-notification-l1-1-0.a new file mode 100644 index 0000000..3eca894 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-oobe-notification-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-perf-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-perf-legacy-l1-1-0.a new file mode 100644 index 0000000..bce843c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-perf-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-base-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-base-l1-1-0.a new file mode 100644 index 0000000..343e40d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-limitsmanagement-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-limitsmanagement-l1-1-0.a new file mode 100644 index 0000000..2f2f9fe Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-limitsmanagement-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-setting-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-setting-l1-1-0.a new file mode 100644 index 0000000..416beb7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-power-setting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ro-typeresolution-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ro-typeresolution-l1-1-0.a new file mode 100644 index 0000000..02c3c40 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-ro-typeresolution-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-appcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-appcontainer-l1-1-0.a new file mode 100644 index 0000000..e4c8e76 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-appcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-ansi-l1-1-0.a new file mode 100644 index 0000000..883e43b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-1-0.a new file mode 100644 index 0000000..4852884 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-0.a new file mode 100644 index 0000000..0c2049c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-1.a new file mode 100644 index 0000000..ae1b072 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-2.a new file mode 100644 index 0000000..9a1ae24 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-base-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-credentials-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-credentials-l1-1-0.a new file mode 100644 index 0000000..3412dd2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-credentials-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-cryptoapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-cryptoapi-l1-1-0.a new file mode 100644 index 0000000..1ad1429 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-cryptoapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-isolatedcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-isolatedcontainer-l1-1-0.a new file mode 100644 index 0000000..f392077 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-isolatedcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-ansi-l2-1-0.a new file mode 100644 index 0000000..02dc0e4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-0.a new file mode 100644 index 0000000..1c49d62 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-1.a new file mode 100644 index 0000000..fb8bb05 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-ansi-l1-1-0.a new file mode 100644 index 0000000..9a7c5a1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-l1-1-0.a new file mode 100644 index 0000000..673f4d5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-ansi-l1-1-0.a new file mode 100644 index 0000000..e11adfe Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-l1-1-0.a new file mode 100644 index 0000000..a7d7272 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-sddl-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-systemfunctions-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-systemfunctions-l1-1-0.a new file mode 100644 index 0000000..29b71e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-security-systemfunctions-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-0.a new file mode 100644 index 0000000..2bc4656 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-1.a new file mode 100644 index 0000000..56625cf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-0.a new file mode 100644 index 0000000..87b6296 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-1.a new file mode 100644 index 0000000..53a3262 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-2.a new file mode 100644 index 0000000..103d475 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-core-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l1-1-0.a new file mode 100644 index 0000000..db48c5f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l2-1-0.a new file mode 100644 index 0000000..58f7df3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-management-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-winsvc-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-winsvc-l1-1-0.a new file mode 100644 index 0000000..2b0db2c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-service-winsvc-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-path-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-path-l1-1-0.a new file mode 100644 index 0000000..7f76679 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-0.a new file mode 100644 index 0000000..fba58aa Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-1.a new file mode 100644 index 0000000..23e421b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-0.a new file mode 100644 index 0000000..214063d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-1.a new file mode 100644 index 0000000..d01e791 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-2.a new file mode 100644 index 0000000..847b757 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-stream-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-stream-winrt-l1-1-0.a new file mode 100644 index 0000000..eebc1b7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-stream-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-sysinfo-l1-1-0.a new file mode 100644 index 0000000..9186943 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-unicodeansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-unicodeansi-l1-1-0.a new file mode 100644 index 0000000..8d0c8ac Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shcore-unicodeansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-namespace-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-namespace-l1-1-0.a new file mode 100644 index 0000000..a9927de Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-namespace-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-shdirectory-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-shdirectory-l1-1-0.a new file mode 100644 index 0000000..68f7f5c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-shell-shdirectory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-authz.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-authz.a new file mode 100644 index 0000000..e8a4dc2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-authz.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-bcrypt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-bcrypt.a new file mode 100644 index 0000000..ee8432f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-bcrypt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cabinet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cabinet.a new file mode 100644 index 0000000..06a76bf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-chakra.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-chakra.a new file mode 100644 index 0000000..8cc5a47 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-chakra.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-coremessaging.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-coremessaging.a new file mode 100644 index 0000000..9d5b919 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-coremessaging.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-crypt32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-crypt32.a new file mode 100644 index 0000000..25d1f16 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-crypt32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptbase.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptbase.a new file mode 100644 index 0000000..79492c6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptbase.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptnet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptnet.a new file mode 100644 index 0000000..1e3317d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-cryptnet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d2d1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d2d1.a new file mode 100644 index 0000000..2e7c373 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d2d1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d11.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d11.a new file mode 100644 index 0000000..185ed02 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d11.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d12.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d12.a new file mode 100644 index 0000000..ab43f59 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3d12.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3dcompiler_47.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3dcompiler_47.a new file mode 100644 index 0000000..d058b1e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-d3dcompiler_47.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-deviceaccess.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-deviceaccess.a new file mode 100644 index 0000000..ded2380 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-deviceaccess.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dfscli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dfscli.a new file mode 100644 index 0000000..03cae08 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dfscli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc.a new file mode 100644 index 0000000..c929899 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc6.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc6.a new file mode 100644 index 0000000..60c5b58 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dhcpcsvc6.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dnsapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dnsapi.a new file mode 100644 index 0000000..628d219 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dnsapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsparse.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsparse.a new file mode 100644 index 0000000..56c7261 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsparse.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsrole.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsrole.a new file mode 100644 index 0000000..67c8734 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dsrole.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dwrite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dwrite.a new file mode 100644 index 0000000..671f2bf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dwrite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dxgi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dxgi.a new file mode 100644 index 0000000..15771d9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-dxgi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-esent.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-esent.a new file mode 100644 index 0000000..cd95792 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-esent.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-core-iuri-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-core-iuri-l1-1-0.a new file mode 100644 index 0000000..28eb32d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-core-iuri-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-gaming-xinput-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-gaming-xinput-l1-1-0.a new file mode 100644 index 0000000..7f295e4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-gaming-xinput-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-networking-wlanapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-networking-wlanapi-l1-1-0.a new file mode 100644 index 0000000..a274bf5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-networking-wlanapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-0.a new file mode 100644 index 0000000..c2f7ff4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-1.a new file mode 100644 index 0000000..77efe4b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-0.a new file mode 100644 index 0000000..7b968d5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-1.a new file mode 100644 index 0000000..c7b52d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-2.a new file mode 100644 index 0000000..3d44de2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-3.a new file mode 100644 index 0000000..37624df Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-fltlib.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-fltlib.a new file mode 100644 index 0000000..7bae6bd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-fltlib.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hid.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hid.a new file mode 100644 index 0000000..580cbac Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hid.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hrtfapo.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hrtfapo.a new file mode 100644 index 0000000..f20f592 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-hrtfapo.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-inkobjcore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-inkobjcore.a new file mode 100644 index 0000000..f46c488 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-inkobjcore.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-iphlpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-iphlpapi.a new file mode 100644 index 0000000..fa5a85c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-iphlpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-logoncli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-logoncli.a new file mode 100644 index 0000000..32864e9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-logoncli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mf.a new file mode 100644 index 0000000..c7d76bb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfplat.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfplat.a new file mode 100644 index 0000000..2dc6733 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfplat.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfreadwrite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfreadwrite.a new file mode 100644 index 0000000..89a4eb5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfreadwrite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfsensorgroup.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfsensorgroup.a new file mode 100644 index 0000000..ae5de25 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mfsensorgroup.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mmdevapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mmdevapi.a new file mode 100644 index 0000000..18de81d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mmdevapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mpr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mpr.a new file mode 100644 index 0000000..e1d81ba Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mpr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-msajapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-msajapi.a new file mode 100644 index 0000000..77c0f0c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-msajapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mswsock.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mswsock.a new file mode 100644 index 0000000..126b7a9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ncrypt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ncrypt.a new file mode 100644 index 0000000..63beb78 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ncrypt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-netutils.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-netutils.a new file mode 100644 index 0000000..db37a10 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-netutils.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ntdll.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ntdll.a new file mode 100644 index 0000000..4c43b2d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ntdll.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-oleaut32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-oleaut32.a new file mode 100644 index 0000000..d1dbb03 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-powrprof.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-powrprof.a new file mode 100644 index 0000000..667c2bc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-powrprof.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-profapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-profapi.a new file mode 100644 index 0000000..31668fe Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-profapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-propsys.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-propsys.a new file mode 100644 index 0000000..2bc2a70 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-propsys.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rometadata.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rometadata.a new file mode 100644 index 0000000..8808e74 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rometadata.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rpcrt4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rpcrt4.a new file mode 100644 index 0000000..a689c15 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-samcli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-samcli.a new file mode 100644 index 0000000..625e341 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-samcli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-schedcli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-schedcli.a new file mode 100644 index 0000000..04a19c1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-schedcli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-srvcli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-srvcli.a new file mode 100644 index 0000000..fd4a96b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-srvcli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-sspicli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-sspicli.a new file mode 100644 index 0000000..f631e9c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-sspicli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-tokenbinding.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-tokenbinding.a new file mode 100644 index 0000000..22e4d16 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-tokenbinding.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-uiautomationcore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-uiautomationcore.a new file mode 100644 index 0000000..c143cb7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-uiautomationcore.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-urlmon.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-urlmon.a new file mode 100644 index 0000000..d8aaf37 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-urlmon.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-userenv.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-userenv.a new file mode 100644 index 0000000..d61f5d7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-userenv.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-webservices.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-webservices.a new file mode 100644 index 0000000..86b5f17 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-webservices.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-websocket.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-websocket.a new file mode 100644 index 0000000..972de6e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-websocket.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.data.pdf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.data.pdf.a new file mode 100644 index 0000000..cca1b80 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.data.pdf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.networking.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.networking.a new file mode 100644 index 0000000..de73a8b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windows.networking.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windowscodecs.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windowscodecs.a new file mode 100644 index 0000000..4e054e2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-windowscodecs.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-winhttp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-winhttp.a new file mode 100644 index 0000000..d5573c4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-winhttp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wintrust.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wintrust.a new file mode 100644 index 0000000..927cf9a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wintrust.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wkscli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wkscli.a new file mode 100644 index 0000000..fd517c2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wkscli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wlanapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wlanapi.a new file mode 100644 index 0000000..7c4faa1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wlanapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wldap32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wldap32.a new file mode 100644 index 0000000..e78cb6c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wldap32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wpprecorderum.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wpprecorderum.a new file mode 100644 index 0000000..f0b68b8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-wpprecorderum.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ws2_32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ws2_32.a new file mode 100644 index 0000000..aa9aeb8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xaudio2_9.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xaudio2_9.a new file mode 100644 index 0000000..560f316 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xaudio2_9.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xmllite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xmllite.a new file mode 100644 index 0000000..cd8228c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-xmllite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap.a new file mode 100644 index 0000000..8e19e51 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap.a @@ -0,0 +1,324 @@ +INPUT( +libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-largeinteger-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-0.a +libwinapi_onecoreuap-d3d12.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-slapi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l1-2-2.a +libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-normalization-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l2-1-0.a +libwinapi_onecoreuap-mf.a +libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-1.a +libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-1.a +libwinapi_onecoreuap-chakra.a +libwinapi_onecoreuap-esent.a +libwinapi_onecoreuap-api-ms-win-security-provider-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-profile-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-localization-obsolete-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-winrt-registration-l1-1-0.a +libwinapi_onecoreuap-hid.a +libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-1.a +libwinapi_onecoreuap-wintrust.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-5.a +libwinapi_onecoreuap-api-ms-win-core-psapi-ansi-l1-1-0.a +libwinapi_onecoreuap-wldap32.a +libwinapi_onecoreuap-mfreadwrite.a +libwinapi_onecoreuap-api-ms-win-core-winrt-string-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processsnapshot-l1-1-0.a +libwinapi_onecoreuap-profapi.a +libwinapi_onecoreuap-api-ms-win-core-localization-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-job-l2-1-1.a +libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-1.a +libwinapi_onecoreuap-netutils.a +libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-service-winsvc-l1-1-0.a +libwinapi_onecoreuap-bcrypt.a +libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-0.a +libwinapi_onecoreuap-cryptnet.a +libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processtopology-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-io-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-shcore-stream-winrt-l1-1-0.a +libwinapi_onecoreuap-logoncli.a +libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-0.a +libwinapi_onecoreuap-rpcrt4.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-service-core-l1-1-2.a +libwinapi_onecoreuap-mpr.a +libwinapi_onecoreuap-api-ms-win-core-com-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-base-l1-2-1.a +libwinapi_onecoreuap-api-ms-win-core-string-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-gaming-deviceinformation-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-heap-obsolete-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-localization-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-1.a +libwinapi_onecoreuap-api-ms-win-core-xstate-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-com-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-4.a +libwinapi_onecoreuap-winhttp.a +libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l1-2-1.a +libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-3.a +libwinapi_onecoreuap-api-ms-win-core-quirks-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-path-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-firmware-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-heap-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-3.a +libwinapi_onecoreuap-mfplat.a +libwinapi_onecoreuap-api-ms-win-shcore-unicodeansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-0.a +libwinapi_onecoreuap-xaudio2_9.a +libwinapi_onecoreuap-api-ms-win-mm-misc-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-mm-time-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-provider-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-eventing-controller-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-3.a +libwinapi_onecoreuap-dnsapi.a +libwinapi_onecoreuap-api-ms-win-core-namespace-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-timezone-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-privateprofile-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-shell-namespace-l1-1-0.a +libwinapi_onecoreuap-fltlib.a +libwinapi_onecoreuap-api-ms-win-core-winrt-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-base-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-0.a +libwinapi_onecoreuap-inkobjcore.a +libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-2.a +libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-1.a +libwinapi_onecoreuap-ncrypt.a +libwinapi_onecoreuap-webservices.a +libwinapi_onecoreuap-crypt32.a +libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-service-management-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-synch-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-libraryloader-l2-1-0.a +libwinapi_onecoreuap-coremessaging.a +libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-2.a +libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-1.a +libwinapi_onecoreuap-mswsock.a +libwinapi_onecoreuap-sspicli.a +libwinapi_onecoreuap-api-ms-win-core-io-l1-1-0.a +libwinapi_onecoreuap-windows.data.pdf.a +libwinapi_onecoreuap-srvcli.a +libwinapi_onecoreuap-ext-ms-win-networking-wlanapi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-1-0.a +libwinapi_onecoreuap-uiautomationcore.a +libwinapi_onecoreuap-api-ms-win-core-util-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-2.a +libwinapi_onecoreuap-api-ms-win-core-version-l1-1-1.a +libwinapi_onecoreuap-ws2_32.a +libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-rtlsupport-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-0.a +libwinapi_onecoreuap-dxgi.a +libwinapi_onecoreuap-dfscli.a +libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-devices-config-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-fibers-l2-1-0.a +libwinapi_onecoreuap-ext-ms-win-gaming-xinput-l1-1-0.a +libwinapi_onecoreuap-urlmon.a +libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-oobe-notification-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-url-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-string-obsolete-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-console-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-shell-shdirectory-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-windowsceip-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-power-limitsmanagement-l1-1-0.a +libwinapi_onecoreuap-authz.a +libwinapi_onecoreuap-ext-ms-win-shell32-shellfolders-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-security-credentials-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-ro-typeresolution-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-namespace-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processenvironment-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-psm-appnotify-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-ntuser-sysparams-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-1.a +libwinapi_onecoreuap-api-ms-win-security-sddl-l1-1-0.a +libwinapi_onecoreuap-d2d1.a +libwinapi_onecoreuap-api-ms-win-appmodel-runtime-l1-1-2.a +libwinapi_onecoreuap-d3d11.a +libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-util-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-power-setting-l1-1-0.a +libwinapi_onecoreuap-wkscli.a +libwinapi_onecoreuap-api-ms-win-core-console-l2-1-0.a +libwinapi_onecoreuap-mfsensorgroup.a +libwinapi_onecoreuap-api-ms-win-core-toolhelp-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-synch-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-1-0.a +libwinapi_onecoreuap-hrtfapo.a +libwinapi_onecoreuap-rometadata.a +libwinapi_onecoreuap-api-ms-win-core-string-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-3.a +libwinapi_onecoreuap-api-ms-win-core-com-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-comm-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-winrt-robuffer-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-4.a +libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-winrt-error-l1-1-1.a +libwinapi_onecoreuap-oleaut32.a +libwinapi_onecoreuap-api-ms-win-core-synch-l1-2-1.a +libwinapi_onecoreuap-cryptbase.a +libwinapi_onecoreuap-api-ms-win-core-file-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-eventing-provider-l1-1-0.a +libwinapi_onecoreuap-xmllite.a +libwinapi_onecoreuap-api-ms-win-core-file-l2-1-3.a +libwinapi_onecoreuap-api-ms-win-eventing-classicprovider-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-3.a +libwinapi_onecoreuap-api-ms-win-core-systemtopology-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-shutdown-ansi-l1-1-0.a +libwinapi_onecoreuap-cabinet.a +libwinapi_onecoreuap-userenv.a +libwinapi_onecoreuap-api-ms-win-security-base-l1-2-2.a +libwinapi_onecoreuap-windowscodecs.a +libwinapi_onecoreuap-schedcli.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-3.a +libwinapi_onecoreuap-wpprecorderum.a +libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-gaming-expandedresources-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-1.a +libwinapi_onecoreuap-ext-ms-win-core-iuri-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-registry-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-2.a +libwinapi_onecoreuap-deviceaccess.a +libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-2.a +libwinapi_onecoreuap-api-ms-win-service-core-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-registry-l2-1-0.a +libwinapi_onecoreuap-tokenbinding.a +libwinapi_onecoreuap-api-ms-win-eventing-tdh-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-1.a +libwinapi_onecoreuap-api-ms-win-power-base-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-appcontainer-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-job-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-console-ansi-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-calendar-l1-1-0.a +libwinapi_onecoreuap-msajapi.a +libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-wow64-l1-1-2.a +libwinapi_onecoreuap-dsparse.a +libwinapi_onecoreuap-api-ms-win-eventing-obsolete-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-psapi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-1.a +libwinapi_onecoreuap-api-ms-win-gaming-gamemonitor-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-com-midlproxystub-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-base-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-localization-l1-2-0.a +libwinapi_onecoreuap-d3dcompiler_47.a +libwinapi_onecoreuap-api-ms-win-core-handle-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-com-l2-1-1.a +libwinapi_onecoreuap-samcli.a +libwinapi_onecoreuap-api-ms-win-core-versionansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-eventing-legacy-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-dx-d3dkmt-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-sidebyside-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-string-l2-1-1.a +libwinapi_onecoreuap-dhcpcsvc.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-4.a +libwinapi_onecoreuap-api-ms-win-core-namedpipe-l1-2-1.a +libwinapi_onecoreuap-api-ms-win-service-management-l1-1-0.a +libwinapi_onecoreuap-dwrite.a +libwinapi_onecoreuap-api-ms-win-security-isolatedcontainer-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-job-l2-1-0.a +libwinapi_onecoreuap-iphlpapi.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-threadpool-legacy-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-perfcounters-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-lsalookup-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-5.a +libwinapi_onecoreuap-propsys.a +libwinapi_onecoreuap-api-ms-win-core-delayload-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-devices-swdevice-l1-1-1.a +libwinapi_onecoreuap-wlanapi.a +libwinapi_onecoreuap-mmdevapi.a +libwinapi_onecoreuap-api-ms-win-security-cryptoapi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-sddl-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-memory-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-service-core-ansi-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-interlocked-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l2-1-1.a +libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-stringansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-processthreads-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-console-l3-1-0.a +libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-eventing-consumer-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-systemfunctions-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-sysinfo-l1-2-3.a +libwinapi_onecoreuap-api-ms-win-shcore-registry-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-0.a +libwinapi_onecoreuap-dhcpcsvc6.a +libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-core-processenvironment-ansi-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-threadpool-l1-2-0.a +libwinapi_onecoreuap-api-ms-win-shcore-scaling-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-libraryloader-l1-2-1.a +libwinapi_onecoreuap-api-ms-win-shcore-sysinfo-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-3.a +libwinapi_onecoreuap-api-ms-win-core-heap-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-fibers-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-realtime-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-service-core-l1-1-0.a +libwinapi_onecoreuap-ntdll.a +libwinapi_onecoreuap-api-ms-win-core-featurestaging-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-atoms-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-core-errorhandling-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-namedpipe-ansi-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-kernel32-legacy-l1-1-6.a +libwinapi_onecoreuap-api-ms-win-shcore-path-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-version-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-mm-mme-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-mm-playsound-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-gaming-tcui-l1-1-4.a +libwinapi_onecoreuap-api-ms-win-core-file-ansi-l2-1-0.a +libwinapi_onecoreuap-api-ms-win-core-sidebyside-l1-1-0.a +libwinapi_onecoreuap-windows.networking.a +libwinapi_onecoreuap-powrprof.a +libwinapi_onecoreuap-api-ms-win-core-shutdown-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-datetime-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-file-l2-1-2.a +libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-2.a +libwinapi_onecoreuap-api-ms-win-perf-legacy-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-core-debug-l1-1-1.a +libwinapi_onecoreuap-api-ms-win-core-enclave-l1-1-1.a +libwinapi_onecoreuap-dsrole.a +libwinapi_onecoreuap-ext-ms-win-uiacore-l1-1-0.a +libwinapi_onecoreuap-api-ms-win-security-base-ansi-l1-1-0.a +libwinapi_onecoreuap-websocket.a +libwinapi_onecoreuap-api-ms-win-security-lsalookup-ansi-l2-1-0.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-advapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-advapi32.a new file mode 100644 index 0000000..d5fdc1d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-advapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-apphelp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-apphelp.a new file mode 100644 index 0000000..1fab811 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-apphelp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comctl32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comctl32.a new file mode 100644 index 0000000..09acba7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comctl32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comdlg32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comdlg32.a new file mode 100644 index 0000000..641f77b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-comdlg32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d10.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d10.a new file mode 100644 index 0000000..edee55c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d10.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d9.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d9.a new file mode 100644 index 0000000..73dc282 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3d9.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3dx10_47.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3dx10_47.a new file mode 100644 index 0000000..2785192 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-d3dx10_47.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-difxapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-difxapi.a new file mode 100644 index 0000000..a8adedc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-difxapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-gdi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-gdi32.a new file mode 100644 index 0000000..29a649c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-gdi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-input.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-input.a new file mode 100644 index 0000000..ded06de Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-input.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-kernel32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-kernel32.a new file mode 100644 index 0000000..b6a5000 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-kernel32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-msi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-msi.a new file mode 100644 index 0000000..e3cffbc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-msi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-newdev.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-newdev.a new file mode 100644 index 0000000..c5038ac Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-newdev.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-ole32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-ole32.a new file mode 100644 index 0000000..a987556 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-ole32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleacc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleacc.a new file mode 100644 index 0000000..49f6a39 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleacc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleaut32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleaut32.a new file mode 100644 index 0000000..8370d6a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oledlg.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oledlg.a new file mode 100644 index 0000000..6bb7fe4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-oledlg.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-pdh.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-pdh.a new file mode 100644 index 0000000..44fbc78 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-pdh.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-psapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-psapi.a new file mode 100644 index 0000000..d378254 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-psapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-resutils.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-resutils.a new file mode 100644 index 0000000..bd9e367 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-resutils.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-rstrtmgr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-rstrtmgr.a new file mode 100644 index 0000000..5f36160 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-rstrtmgr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-secur32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-secur32.a new file mode 100644 index 0000000..af61a3a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-secur32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-setupapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-setupapi.a new file mode 100644 index 0000000..2d1f9c1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-setupapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shell32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shell32.a new file mode 100644 index 0000000..fc53fd2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shell32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shlwapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shlwapi.a new file mode 100644 index 0000000..cc44364 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-shlwapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-tdh.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-tdh.a new file mode 100644 index 0000000..246ce3b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-tdh.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-twinapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-twinapi.a new file mode 100644 index 0000000..208fe4e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-twinapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-user32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-user32.a new file mode 100644 index 0000000..2486aac Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-user32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-uxtheme.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-uxtheme.a new file mode 100644 index 0000000..37922ca Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-uxtheme.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-version.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-version.a new file mode 100644 index 0000000..9ffb0e7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-version.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winmm.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winmm.a new file mode 100644 index 0000000..5e36466 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winmm.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winspool.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winspool.a new file mode 100644 index 0000000..78d0942 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-winspool.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-wtsapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-wtsapi32.a new file mode 100644 index 0000000..f13249d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-wtsapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-xinput1_4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-xinput1_4.a new file mode 100644 index 0000000..82aec5e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel-xinput1_4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel.a new file mode 100644 index 0000000..a412d18 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap_downlevel.a @@ -0,0 +1,36 @@ +INPUT( +libwinapi_onecoreuap_downlevel-advapi32.a +libwinapi_onecoreuap_downlevel-version.a +libwinapi_onecoreuap_downlevel-winspool.a +libwinapi_onecoreuap_downlevel-shell32.a +libwinapi_onecoreuap_downlevel-xinput1_4.a +libwinapi_onecoreuap_downlevel-tdh.a +libwinapi_onecoreuap_downlevel-msi.a +libwinapi_onecoreuap_downlevel-winmm.a +libwinapi_onecoreuap_downlevel-oleaut32.a +libwinapi_onecoreuap_downlevel-d3d10.a +libwinapi_onecoreuap_downlevel-setupapi.a +libwinapi_onecoreuap_downlevel-psapi.a +libwinapi_onecoreuap_downlevel-oleacc.a +libwinapi_onecoreuap_downlevel-rstrtmgr.a +libwinapi_onecoreuap_downlevel-resutils.a +libwinapi_onecoreuap_downlevel-apphelp.a +libwinapi_onecoreuap_downlevel-comctl32.a +libwinapi_onecoreuap_downlevel-user32.a +libwinapi_onecoreuap_downlevel-newdev.a +libwinapi_onecoreuap_downlevel-d3dx10_47.a +libwinapi_onecoreuap_downlevel-shlwapi.a +libwinapi_onecoreuap_downlevel-uxtheme.a +libwinapi_onecoreuap_downlevel-wtsapi32.a +libwinapi_onecoreuap_downlevel-ole32.a +libwinapi_onecoreuap_downlevel-oledlg.a +libwinapi_onecoreuap_downlevel-secur32.a +libwinapi_onecoreuap_downlevel-d3d9.a +libwinapi_onecoreuap_downlevel-pdh.a +libwinapi_onecoreuap_downlevel-comdlg32.a +libwinapi_onecoreuap_downlevel-input.a +libwinapi_onecoreuap_downlevel-difxapi.a +libwinapi_onecoreuap_downlevel-kernel32.a +libwinapi_onecoreuap_downlevel-twinapi.a +libwinapi_onecoreuap_downlevel-gdi32.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_opengl32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_opengl32.a new file mode 100644 index 0000000..ffc45dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_opengl32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_opmxbox.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_opmxbox.a new file mode 100644 index 0000000..c88f52e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_opmxbox.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_p2p.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_p2p.a new file mode 100644 index 0000000..9daf258 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_p2p.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_p2pgraph.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_p2pgraph.a new file mode 100644 index 0000000..38235cd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_p2pgraph.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_pathcch.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_pathcch.a new file mode 100644 index 0000000..75520ff Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_pathcch.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_pdh.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_pdh.a new file mode 100644 index 0000000..1cd6167 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_pdh.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_peerdist.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_peerdist.a new file mode 100644 index 0000000..7469347 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_peerdist.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_powrprof.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_powrprof.a new file mode 100644 index 0000000..31e03e4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_powrprof.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_prntvpt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_prntvpt.a new file mode 100644 index 0000000..f4f187e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_prntvpt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_propsys.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_propsys.a new file mode 100644 index 0000000..995c244 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_propsys.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_psapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_psapi.a new file mode 100644 index 0000000..faaf0c4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_psapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_quartz.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_quartz.a new file mode 100644 index 0000000..062b1b2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_quartz.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_query.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_query.a new file mode 100644 index 0000000..24c3681 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_query.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_qwave.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_qwave.a new file mode 100644 index 0000000..e61f5dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_qwave.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rasapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rasapi32.a new file mode 100644 index 0000000..580468f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rasapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rasdlg.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rasdlg.a new file mode 100644 index 0000000..c1ae179 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rasdlg.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_resutils.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_resutils.a new file mode 100644 index 0000000..9817f08 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_resutils.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rometadata.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rometadata.a new file mode 100644 index 0000000..9548701 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rometadata.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcexts.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcexts.a new file mode 100644 index 0000000..1de9056 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcexts.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcns4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcns4.a new file mode 100644 index 0000000..f65bfa0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcns4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcproxy.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcproxy.a new file mode 100644 index 0000000..ed10fc6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcproxy.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcrt4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcrt4.a new file mode 100644 index 0000000..1c275df Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rstrtmgr.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rstrtmgr.a new file mode 100644 index 0000000..b13b6d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rstrtmgr.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rtm.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rtm.a new file mode 100644 index 0000000..818088f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rtm.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rtutils.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rtutils.a new file mode 100644 index 0000000..c98f447 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rtutils.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rtworkq.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rtworkq.a new file mode 100644 index 0000000..4b5f7ee Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_rtworkq.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-0.a new file mode 100644 index 0000000..1801c67 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-1.a new file mode 100644 index 0000000..da5c065 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..3a96659 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-registration-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-registration-l1-1-0.a new file mode 100644 index 0000000..5c961d1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-registration-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-robuffer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-robuffer-l1-1-0.a new file mode 100644 index 0000000..5b8da42 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-robuffer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a new file mode 100644 index 0000000..53f6fe0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-string-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-string-l1-1-0.a new file mode 100644 index 0000000..d689c06 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-core-winrt-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-ro-typeresolution-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-ro-typeresolution-l1-1-0.a new file mode 100644 index 0000000..79b665b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject-api-ms-win-ro-typeresolution-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject.a new file mode 100644 index 0000000..bf368a2 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_runtimeobject.a @@ -0,0 +1,10 @@ +INPUT( +libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-string-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-ro-typeresolution-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-error-l1-1-1.a +libwinapi_runtimeobject-api-ms-win-core-winrt-robuffer-l1-1-0.a +libwinapi_runtimeobject-api-ms-win-core-winrt-registration-l1-1-0.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_samlib.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_samlib.a new file mode 100644 index 0000000..b9525b0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_samlib.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_samsrv.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_samsrv.a new file mode 100644 index 0000000..4782838 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_samsrv.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sas.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sas.a new file mode 100644 index 0000000..5425965 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sas.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_scarddlg.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_scarddlg.a new file mode 100644 index 0000000..acf3310 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_scarddlg.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_scecli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_scecli.a new file mode 100644 index 0000000..5811d57 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_scecli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_scesrv.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_scesrv.a new file mode 100644 index 0000000..909f4b9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_scesrv.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_schannel.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_schannel.a new file mode 100644 index 0000000..aea8ed1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_schannel.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_secur32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_secur32.a new file mode 100644 index 0000000..e6c8ad8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_secur32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_security.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_security.a new file mode 100644 index 0000000..6544213 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_security.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sens.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sens.a new file mode 100644 index 0000000..17a72cb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sens.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sensapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sensapi.a new file mode 100644 index 0000000..93cf942 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sensapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sensorsutils.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sensorsutils.a new file mode 100644 index 0000000..4f86fa7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sensorsutils.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_setupapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_setupapi.a new file mode 100644 index 0000000..1d657d5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_setupapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sfc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sfc.a new file mode 100644 index 0000000..b4fc6a6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sfc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-0.a new file mode 100644 index 0000000..a4e75b9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-1.a new file mode 100644 index 0000000..c4b902b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-0.a new file mode 100644 index 0000000..1925c13 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-1.a new file mode 100644 index 0000000..7c1f77b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-2.a new file mode 100644 index 0000000..3f53c73 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-stream-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-stream-winrt-l1-1-0.a new file mode 100644 index 0000000..47c152c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore-api-ms-win-shcore-stream-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore.a new file mode 100644 index 0000000..2c5f786 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shcore.a @@ -0,0 +1,8 @@ +INPUT( +libwinapi_shcore-api-ms-win-shcore-stream-winrt-l1-1-0.a +libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-2.a +libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-0.a +libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-1.a +libwinapi_shcore-api-ms-win-shcore-scaling-l1-1-0.a +libwinapi_shcore-api-ms-win-core-featurestaging-l1-1-1.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shdocvw.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shdocvw.a new file mode 100644 index 0000000..5d8cad8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shdocvw.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shell32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shell32.a new file mode 100644 index 0000000..98cf7d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shell32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shfolder.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shfolder.a new file mode 100644 index 0000000..326fefd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shfolder.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shlwapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shlwapi.a new file mode 100644 index 0000000..30656c1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_shlwapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_slc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_slc.a new file mode 100644 index 0000000..1e63672 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_slc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_slcext.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_slcext.a new file mode 100644 index 0000000..5865ad6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_slcext.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_slwga.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_slwga.a new file mode 100644 index 0000000..eeed243 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_slwga.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_snmpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_snmpapi.a new file mode 100644 index 0000000..38258ee Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_snmpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_spoolss.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_spoolss.a new file mode 100644 index 0000000..95ed860 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_spoolss.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sporder.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sporder.a new file mode 100644 index 0000000..3383fe3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sporder.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_srpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_srpapi.a new file mode 100644 index 0000000..8de830f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_srpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ssdpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ssdpapi.a new file mode 100644 index 0000000..7d26780 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ssdpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sti.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sti.a new file mode 100644 index 0000000..03201e9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_sti.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_swdevice.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_swdevice.a new file mode 100644 index 0000000..793ba3a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_swdevice.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_synchronization.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_synchronization.a new file mode 100644 index 0000000..4e3b2af Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_synchronization.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_t2embed.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_t2embed.a new file mode 100644 index 0000000..1c44954 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_t2embed.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tapi32.a new file mode 100644 index 0000000..5587002 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tbs.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tbs.a new file mode 100644 index 0000000..11a57b5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tbs.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tdh.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tdh.a new file mode 100644 index 0000000..2dc5dc9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tdh.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tokenbinding.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tokenbinding.a new file mode 100644 index 0000000..883b231 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tokenbinding.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_traffic.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_traffic.a new file mode 100644 index 0000000..a1bb167 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_traffic.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tsec.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tsec.a new file mode 100644 index 0000000..a025734 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_tsec.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_txfw32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_txfw32.a new file mode 100644 index 0000000..097b8e4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_txfw32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ualapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ualapi.a new file mode 100644 index 0000000..a97b24c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ualapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_uiautomationcore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_uiautomationcore.a new file mode 100644 index 0000000..fa32a1c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_uiautomationcore.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_umpdddi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_umpdddi.a new file mode 100644 index 0000000..36cbb19 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_umpdddi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_urlmon.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_urlmon.a new file mode 100644 index 0000000..060ebc5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_urlmon.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_user32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_user32.a new file mode 100644 index 0000000..63ce1cd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_user32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_userenv.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_userenv.a new file mode 100644 index 0000000..354fdd7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_userenv.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_usp10.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_usp10.a new file mode 100644 index 0000000..bd0e21c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_usp10.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_uxtheme.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_uxtheme.a new file mode 100644 index 0000000..fc162f2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_uxtheme.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_version.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_version.a new file mode 100644 index 0000000..634cf67 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_version.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vertdll.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vertdll.a new file mode 100644 index 0000000..7b1ca44 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vertdll.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avicap32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avicap32.a new file mode 100644 index 0000000..7d346d9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avicap32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avifil32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avifil32.a new file mode 100644 index 0000000..169484e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-avifil32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-msvfw32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-msvfw32.a new file mode 100644 index 0000000..27f29f5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32-msvfw32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32.a new file mode 100644 index 0000000..4ee8733 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vfw32.a @@ -0,0 +1,5 @@ +INPUT( +libwinapi_vfw32-msvfw32.a +libwinapi_vfw32-avicap32.a +libwinapi_vfw32-avifil32.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_virtdisk.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_virtdisk.a new file mode 100644 index 0000000..e2da0b6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_virtdisk.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vssapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vssapi.a new file mode 100644 index 0000000..c3ee9a6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_vssapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wcmapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wcmapi.a new file mode 100644 index 0000000..829682c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wcmapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdsbp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdsbp.a new file mode 100644 index 0000000..d62c5d1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdsbp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdsclientapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdsclientapi.a new file mode 100644 index 0000000..2447565 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdsclientapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdsmc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdsmc.a new file mode 100644 index 0000000..e869d40 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdsmc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdspxe.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdspxe.a new file mode 100644 index 0000000..67e2f2d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdspxe.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdstptc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdstptc.a new file mode 100644 index 0000000..f0e2dd9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wdstptc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_webservices.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_webservices.a new file mode 100644 index 0000000..dbb557b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_webservices.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_websocket.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_websocket.a new file mode 100644 index 0000000..3db218f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_websocket.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wecapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wecapi.a new file mode 100644 index 0000000..77817cc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wecapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wer.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wer.a new file mode 100644 index 0000000..24f470a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wer.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wevtapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wevtapi.a new file mode 100644 index 0000000..f6b9852 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wevtapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wiaservc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wiaservc.a new file mode 100644 index 0000000..0328e92 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wiaservc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winbio.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winbio.a new file mode 100644 index 0000000..392c615 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winbio.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windows.data.pdf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windows.data.pdf.a new file mode 100644 index 0000000..d23124b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windows.data.pdf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windows.networking.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windows.networking.a new file mode 100644 index 0000000..24ee966 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windows.networking.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windows.ui.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windows.ui.a new file mode 100644 index 0000000..594416d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windows.ui.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-0.a new file mode 100644 index 0000000..376dc93 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-1.a new file mode 100644 index 0000000..4fb5722 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-0.a new file mode 100644 index 0000000..7f91042 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-1.a new file mode 100644 index 0000000..8dcb225 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l2-1-1.a new file mode 100644 index 0000000..667c2d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-midlproxystub-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-midlproxystub-l1-1-0.a new file mode 100644 index 0000000..16d7f6e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-com-midlproxystub-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-0.a new file mode 100644 index 0000000..e8e919b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-1.a new file mode 100644 index 0000000..c197afe Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-comm-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l1-1-0.a new file mode 100644 index 0000000..7b0609a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l2-1-0.a new file mode 100644 index 0000000..cf05f2b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-console-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-1.a new file mode 100644 index 0000000..76347e7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-2.a new file mode 100644 index 0000000..57cef70 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-debug-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-debug-l1-1-0.a new file mode 100644 index 0000000..f540772 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-debug-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-0.a new file mode 100644 index 0000000..f56e67f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-1.a new file mode 100644 index 0000000..816e82f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-enclave-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-enclave-l1-1-0.a new file mode 100644 index 0000000..04311d4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-enclave-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-0.a new file mode 100644 index 0000000..85a80d3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-2.a new file mode 100644 index 0000000..c4248e6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-3.a new file mode 100644 index 0000000..fa7974e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-0.a new file mode 100644 index 0000000..f6ba05e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-1.a new file mode 100644 index 0000000..330cc42 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-0.a new file mode 100644 index 0000000..70c994f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-1.a new file mode 100644 index 0000000..5f69666 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-0.a new file mode 100644 index 0000000..e51c23b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-1.a new file mode 100644 index 0000000..4f5a52f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l1-1-0.a new file mode 100644 index 0000000..436bf76 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l2-1-0.a new file mode 100644 index 0000000..b7549f8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-1-0.a new file mode 100644 index 0000000..af7bed7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-0.a new file mode 100644 index 0000000..c05ebeb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-2.a new file mode 100644 index 0000000..aa87bb8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-0.a new file mode 100644 index 0000000..af5188d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-2.a new file mode 100644 index 0000000..b030a9e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-file-l2-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-handle-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-handle-l1-1-0.a new file mode 100644 index 0000000..6b25481 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-handle-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l1-1-0.a new file mode 100644 index 0000000..0cd981e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l2-1-0.a new file mode 100644 index 0000000..8a8c4de Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-obsolete-l1-1-0.a new file mode 100644 index 0000000..aae89c5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-heap-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-1-0.a new file mode 100644 index 0000000..25055ff Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-2-0.a new file mode 100644 index 0000000..d1e7cbf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-interlocked-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-0.a new file mode 100644 index 0000000..9f25dbf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-1.a new file mode 100644 index 0000000..fd60dbd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-io-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a new file mode 100644 index 0000000..d25acbe Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-l1-1-0.a new file mode 100644 index 0000000..1c07fae Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-largeinteger-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-largeinteger-l1-1-0.a new file mode 100644 index 0000000..58ae12d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-largeinteger-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l1-2-0.a new file mode 100644 index 0000000..05f0e1e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l2-1-0.a new file mode 100644 index 0000000..0af2c38 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-libraryloader-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-ansi-l1-1-0.a new file mode 100644 index 0000000..42d1bd6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-0.a new file mode 100644 index 0000000..aebd13d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-1.a new file mode 100644 index 0000000..ddd7680 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-2.a new file mode 100644 index 0000000..0339611 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l2-1-0.a new file mode 100644 index 0000000..8053248 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-obsolete-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-obsolete-l1-2-0.a new file mode 100644 index 0000000..6bcde92 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-localization-obsolete-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-0.a new file mode 100644 index 0000000..080203d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-1.a new file mode 100644 index 0000000..0eabec9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-2.a new file mode 100644 index 0000000..121bf61 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-3.a new file mode 100644 index 0000000..f620651 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-memory-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-0.a new file mode 100644 index 0000000..9b112fc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-1.a new file mode 100644 index 0000000..cf45466 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-1-0.a new file mode 100644 index 0000000..04822e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-1.a new file mode 100644 index 0000000..a63de14 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-2.a new file mode 100644 index 0000000..05741b0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-ansi-l1-1-0.a new file mode 100644 index 0000000..f29fc1a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-l1-1-0.a new file mode 100644 index 0000000..14da17e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-namespace-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-normalization-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-normalization-l1-1-0.a new file mode 100644 index 0000000..2446d34 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-normalization-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-path-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-path-l1-1-0.a new file mode 100644 index 0000000..1767c2f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-path-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processenvironment-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processenvironment-l1-1-0.a new file mode 100644 index 0000000..7bcf4de Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processenvironment-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-0.a new file mode 100644 index 0000000..0ef8670 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-1.a new file mode 100644 index 0000000..8e3594c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-2.a new file mode 100644 index 0000000..e885e26 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-3.a new file mode 100644 index 0000000..4a68e2e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processtopology-obsolete-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processtopology-obsolete-l1-1-0.a new file mode 100644 index 0000000..0b44ad2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-processtopology-obsolete-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-profile-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-profile-l1-1-0.a new file mode 100644 index 0000000..367a07a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-profile-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-ansi-l1-1-0.a new file mode 100644 index 0000000..ac268c6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-l1-1-0.a new file mode 100644 index 0000000..6cbeeff Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psm-appnotify-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psm-appnotify-l1-1-0.a new file mode 100644 index 0000000..371a4c7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-psm-appnotify-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-0.a new file mode 100644 index 0000000..5bf4999 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-1.a new file mode 100644 index 0000000..11ddaa6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-2.a new file mode 100644 index 0000000..e93a81c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-1-0.a new file mode 100644 index 0000000..f369789 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-slapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-slapi-l1-1-0.a new file mode 100644 index 0000000..42b61df Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-slapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-string-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-string-l1-1-0.a new file mode 100644 index 0000000..698ddad Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-ansi-l1-1-0.a new file mode 100644 index 0000000..0ef6bbf Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-1-0.a new file mode 100644 index 0000000..0709646 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-0.a new file mode 100644 index 0000000..b268543 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-1.a new file mode 100644 index 0000000..e789bba Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-synch-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-1-0.a new file mode 100644 index 0000000..80f9c9c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-0.a new file mode 100644 index 0000000..2fcf885 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-3.a new file mode 100644 index 0000000..03d507f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-threadpool-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-threadpool-l1-2-0.a new file mode 100644 index 0000000..e20a3b8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-threadpool-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-timezone-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-timezone-l1-1-0.a new file mode 100644 index 0000000..a94e2d0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-timezone-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-url-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-url-l1-1-0.a new file mode 100644 index 0000000..0f9d699 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-url-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-util-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-util-l1-1-0.a new file mode 100644 index 0000000..8279d72 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-util-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-version-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-version-l1-1-0.a new file mode 100644 index 0000000..f34b40a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-version-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-versionansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-versionansi-l1-1-0.a new file mode 100644 index 0000000..fa6483c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-versionansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowsceip-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowsceip-l1-1-0.a new file mode 100644 index 0000000..1507037 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowsceip-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a new file mode 100644 index 0000000..febb567 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a new file mode 100644 index 0000000..6499d7d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a new file mode 100644 index 0000000..fb9c0d4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-0.a new file mode 100644 index 0000000..8f1751f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-1.a new file mode 100644 index 0000000..25a56ca Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..ab32b87 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-registration-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-registration-l1-1-0.a new file mode 100644 index 0000000..0a0cfad Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-registration-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-robuffer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-robuffer-l1-1-0.a new file mode 100644 index 0000000..469de78 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-robuffer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a new file mode 100644 index 0000000..b8f36b0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-string-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-string-l1-1-0.a new file mode 100644 index 0000000..4acaa7d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-winrt-string-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-wow64-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-wow64-l1-1-0.a new file mode 100644 index 0000000..0cf2878 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-wow64-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-xstate-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-xstate-l2-1-0.a new file mode 100644 index 0000000..3384e15 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-xstate-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-classicprovider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-classicprovider-l1-1-0.a new file mode 100644 index 0000000..f4f0e8b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-classicprovider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-consumer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-consumer-l1-1-0.a new file mode 100644 index 0000000..1368f89 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-consumer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-controller-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-controller-l1-1-0.a new file mode 100644 index 0000000..7d03ec5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-controller-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-legacy-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-legacy-l1-1-0.a new file mode 100644 index 0000000..3ba774b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-legacy-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-provider-l1-1-0.a new file mode 100644 index 0000000..673e82c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-eventing-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-deviceinformation-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-deviceinformation-l1-1-0.a new file mode 100644 index 0000000..7d08bb6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-deviceinformation-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-expandedresources-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-expandedresources-l1-1-0.a new file mode 100644 index 0000000..4c85c1f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-expandedresources-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-0.a new file mode 100644 index 0000000..54f7238 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-1.a new file mode 100644 index 0000000..616a29d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-0.a new file mode 100644 index 0000000..601f05a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-1.a new file mode 100644 index 0000000..ca1e9b8 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-2.a new file mode 100644 index 0000000..117874f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-3.a new file mode 100644 index 0000000..694a409 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-4.a new file mode 100644 index 0000000..7eef865 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-ro-typeresolution-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-ro-typeresolution-l1-1-0.a new file mode 100644 index 0000000..6b3d0c6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-ro-typeresolution-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-1-0.a new file mode 100644 index 0000000..62581e4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-0.a new file mode 100644 index 0000000..be5df7e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-1.a new file mode 100644 index 0000000..3f7c7fb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-base-l1-2-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-cryptoapi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-cryptoapi-l1-1-0.a new file mode 100644 index 0000000..70fd9fc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-cryptoapi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-isolatedcontainer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-isolatedcontainer-l1-1-0.a new file mode 100644 index 0000000..3c8658c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-isolatedcontainer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-ansi-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-ansi-l2-1-0.a new file mode 100644 index 0000000..f24a529 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-ansi-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-l2-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-l2-1-0.a new file mode 100644 index 0000000..46c5f2f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-lsalookup-l2-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-ansi-l1-1-0.a new file mode 100644 index 0000000..4d5c84b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-l1-1-0.a new file mode 100644 index 0000000..5124e60 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-provider-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-ansi-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-ansi-l1-1-0.a new file mode 100644 index 0000000..2a4cf78 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-ansi-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-l1-1-0.a new file mode 100644 index 0000000..e2a7cc4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-security-sddl-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-shcore-stream-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-shcore-stream-winrt-l1-1-0.a new file mode 100644 index 0000000..a75e822 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-shcore-stream-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-bcrypt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-bcrypt.a new file mode 100644 index 0000000..2a6a511 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-bcrypt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-cabinet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-cabinet.a new file mode 100644 index 0000000..e320391 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-chakra.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-chakra.a new file mode 100644 index 0000000..7ac6d0b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-chakra.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-coremessaging.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-coremessaging.a new file mode 100644 index 0000000..dcff55a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-coremessaging.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-crypt32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-crypt32.a new file mode 100644 index 0000000..e6c125e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-crypt32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d2d1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d2d1.a new file mode 100644 index 0000000..711f95b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d2d1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d11.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d11.a new file mode 100644 index 0000000..0187191 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d11.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d12.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d12.a new file mode 100644 index 0000000..983d997 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3d12.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3dcompiler_47.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3dcompiler_47.a new file mode 100644 index 0000000..675d156 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-d3dcompiler_47.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-deviceaccess.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-deviceaccess.a new file mode 100644 index 0000000..0cfcf38 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-deviceaccess.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc.a new file mode 100644 index 0000000..19e57e1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc6.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc6.a new file mode 100644 index 0000000..acf659f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dhcpcsvc6.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dwrite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dwrite.a new file mode 100644 index 0000000..242e438 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dwrite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dxgi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dxgi.a new file mode 100644 index 0000000..c0dc910 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-dxgi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-esent.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-esent.a new file mode 100644 index 0000000..6607169 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-esent.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-core-iuri-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-core-iuri-l1-1-0.a new file mode 100644 index 0000000..3e22034 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-core-iuri-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-gaming-xinput-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-gaming-xinput-l1-1-0.a new file mode 100644 index 0000000..b06b03e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-gaming-xinput-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-0.a new file mode 100644 index 0000000..ea046a4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-1.a new file mode 100644 index 0000000..bbfb183 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-2.a new file mode 100644 index 0000000..6bcc881 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-3.a new file mode 100644 index 0000000..e8c2809 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-hrtfapo.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-hrtfapo.a new file mode 100644 index 0000000..a629a8c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-hrtfapo.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-inkobjcore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-inkobjcore.a new file mode 100644 index 0000000..82d731b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-inkobjcore.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-iphlpapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-iphlpapi.a new file mode 100644 index 0000000..42d054f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-iphlpapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mf.a new file mode 100644 index 0000000..a484762 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfplat.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfplat.a new file mode 100644 index 0000000..02e0797 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfplat.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfreadwrite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfreadwrite.a new file mode 100644 index 0000000..61f695b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfreadwrite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfsensorgroup.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfsensorgroup.a new file mode 100644 index 0000000..b56d743 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mfsensorgroup.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mmdevapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mmdevapi.a new file mode 100644 index 0000000..a2d7db1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mmdevapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-msajapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-msajapi.a new file mode 100644 index 0000000..722445a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-msajapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mswsock.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mswsock.a new file mode 100644 index 0000000..e265260 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ncrypt.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ncrypt.a new file mode 100644 index 0000000..230fd2a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ncrypt.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ntdll.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ntdll.a new file mode 100644 index 0000000..9ab94f4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ntdll.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-oleaut32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-oleaut32.a new file mode 100644 index 0000000..39e7d2c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-propsys.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-propsys.a new file mode 100644 index 0000000..bc96421 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-propsys.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rometadata.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rometadata.a new file mode 100644 index 0000000..8a8eef5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rometadata.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rpcrt4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rpcrt4.a new file mode 100644 index 0000000..ac77cc6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-sspicli.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-sspicli.a new file mode 100644 index 0000000..9760833 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-sspicli.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-uiautomationcore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-uiautomationcore.a new file mode 100644 index 0000000..fdc6b99 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-uiautomationcore.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-urlmon.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-urlmon.a new file mode 100644 index 0000000..0a4aad3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-urlmon.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-webservices.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-webservices.a new file mode 100644 index 0000000..4a4442f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-webservices.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.data.pdf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.data.pdf.a new file mode 100644 index 0000000..16ea84e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.data.pdf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.networking.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.networking.a new file mode 100644 index 0000000..3c383d0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windows.networking.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windowscodecs.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windowscodecs.a new file mode 100644 index 0000000..994c633 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-windowscodecs.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ws2_32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ws2_32.a new file mode 100644 index 0000000..81770ca Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xaudio2_9.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xaudio2_9.a new file mode 100644 index 0000000..4578472 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xaudio2_9.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xmllite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xmllite.a new file mode 100644 index 0000000..3a8aa60 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-xmllite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp.a new file mode 100644 index 0000000..a85aad8 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp.a @@ -0,0 +1,182 @@ +INPUT( +libwinapi_windowsapp-dhcpcsvc6.a +libwinapi_windowsapp-api-ms-win-core-file-ansi-l2-1-0.a +libwinapi_windowsapp-api-ms-win-core-file-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-2.a +libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-winrt-string-l1-1-0.a +libwinapi_windowsapp-api-ms-win-security-isolatedcontainer-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-largeinteger-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-xstate-l2-1-0.a +libwinapi_windowsapp-windowscodecs.a +libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-1.a +libwinapi_windowsapp-api-ms-win-core-memory-l1-1-1.a +libwinapi_windowsapp-sspicli.a +libwinapi_windowsapp-api-ms-win-core-libraryloader-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-memory-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-string-l1-1-0.a +libwinapi_windowsapp-urlmon.a +libwinapi_windowsapp-mswsock.a +libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-1.a +libwinapi_windowsapp-ntdll.a +libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-1.a +libwinapi_windowsapp-api-ms-win-security-provider-ansi-l1-1-0.a +libwinapi_windowsapp-ws2_32.a +libwinapi_windowsapp-api-ms-win-gaming-deviceinformation-l1-1-0.a +libwinapi_windowsapp-dwrite.a +libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-3.a +libwinapi_windowsapp-api-ms-win-core-processtopology-obsolete-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-timezone-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-namedpipe-ansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-psapi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-security-lsalookup-l2-1-0.a +libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-com-l1-1-0.a +libwinapi_windowsapp-api-ms-win-eventing-consumer-l1-1-0.a +libwinapi_windowsapp-cabinet.a +libwinapi_windowsapp-oleaut32.a +libwinapi_windowsapp-api-ms-win-core-psm-appnotify-l1-1-0.a +libwinapi_windowsapp-d2d1.a +libwinapi_windowsapp-api-ms-win-core-winrt-l1-1-0.a +libwinapi_windowsapp-mfplat.a +libwinapi_windowsapp-ncrypt.a +libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-0.a +libwinapi_windowsapp-d3dcompiler_47.a +libwinapi_windowsapp-ext-ms-win-core-iuri-l1-1-0.a +libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-2.a +libwinapi_windowsapp-xmllite.a +libwinapi_windowsapp-api-ms-win-security-sddl-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-io-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-localization-l2-1-0.a +libwinapi_windowsapp-api-ms-win-eventing-controller-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-2.a +libwinapi_windowsapp-api-ms-win-core-profile-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-rtlsupport-l1-1-0.a +libwinapi_windowsapp-mf.a +libwinapi_windowsapp-api-ms-win-core-namespace-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-3.a +libwinapi_windowsapp-api-ms-win-core-synch-l1-2-0.a +libwinapi_windowsapp-webservices.a +libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-file-ansi-l1-1-0.a +libwinapi_windowsapp-xaudio2_9.a +libwinapi_windowsapp-api-ms-win-core-io-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-localization-l1-2-2.a +libwinapi_windowsapp-api-ms-win-core-threadpool-l1-2-0.a +libwinapi_windowsapp-inkobjcore.a +libwinapi_windowsapp-uiautomationcore.a +libwinapi_windowsapp-api-ms-win-core-file-l2-1-0.a +libwinapi_windowsapp-iphlpapi.a +libwinapi_windowsapp-rometadata.a +libwinapi_windowsapp-api-ms-win-core-heap-obsolete-l1-1-0.a +libwinapi_windowsapp-rpcrt4.a +libwinapi_windowsapp-api-ms-win-core-synch-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-versionansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-file-l1-2-2.a +libwinapi_windowsapp-api-ms-win-core-com-midlproxystub-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-slapi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-synch-ansi-l1-1-0.a +libwinapi_windowsapp-ext-ms-win-gaming-xinput-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-com-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-processenvironment-l1-1-0.a +libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-1.a +libwinapi_windowsapp-bcrypt.a +libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-3.a +libwinapi_windowsapp-windows.data.pdf.a +libwinapi_windowsapp-api-ms-win-core-interlocked-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-localization-l1-2-1.a +libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-delayload-l1-1-0.a +libwinapi_windowsapp-api-ms-win-ro-typeresolution-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-fibers-l1-1-1.a +libwinapi_windowsapp-api-ms-win-security-base-l1-2-1.a +libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-1.a +libwinapi_windowsapp-api-ms-win-core-memory-l1-1-3.a +libwinapi_windowsapp-d3d12.a +libwinapi_windowsapp-api-ms-win-core-heap-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-console-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-file-l2-1-2.a +libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-url-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-synch-l1-2-1.a +libwinapi_windowsapp-d3d11.a +libwinapi_windowsapp-api-ms-win-core-memory-l1-1-2.a +libwinapi_windowsapp-api-ms-win-core-localization-obsolete-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-com-l2-1-1.a +libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-2.a +libwinapi_windowsapp-api-ms-win-core-util-l1-1-0.a +libwinapi_windowsapp-ext-ms-win-uiacore-l1-1-3.a +libwinapi_windowsapp-api-ms-win-core-debug-l1-1-0.a +libwinapi_windowsapp-api-ms-win-gaming-expandedresources-l1-1-0.a +libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-4.a +libwinapi_windowsapp-api-ms-win-core-interlocked-l1-2-0.a +libwinapi_windowsapp-api-ms-win-gaming-tcui-l1-1-2.a +libwinapi_windowsapp-api-ms-win-core-file-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-fibers-l2-1-0.a +libwinapi_windowsapp-hrtfapo.a +libwinapi_windowsapp-api-ms-win-security-cryptoapi-l1-1-0.a +libwinapi_windowsapp-dxgi.a +libwinapi_windowsapp-deviceaccess.a +libwinapi_windowsapp-api-ms-win-core-heap-l2-1-0.a +libwinapi_windowsapp-msajapi.a +libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a +libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-3.a +libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-kernel32-legacy-ansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-processthreads-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-namespace-ansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-handle-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-localization-l1-2-0.a +libwinapi_windowsapp-api-ms-win-core-errorhandling-l1-1-0.a +libwinapi_windowsapp-api-ms-win-security-sddl-ansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-gaming-gamemonitor-l1-1-0.a +libwinapi_windowsapp-api-ms-win-shcore-stream-winrt-l1-1-0.a +libwinapi_windowsapp-crypt32.a +libwinapi_windowsapp-api-ms-win-core-comm-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-winrt-error-l1-1-0.a +libwinapi_windowsapp-mmdevapi.a +libwinapi_windowsapp-api-ms-win-core-namedpipe-l1-2-2.a +libwinapi_windowsapp-windows.networking.a +libwinapi_windowsapp-api-ms-win-core-winrt-registration-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-normalization-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-console-l2-1-0.a +libwinapi_windowsapp-api-ms-win-core-localization-ansi-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-wow64-l1-1-0.a +libwinapi_windowsapp-coremessaging.a +libwinapi_windowsapp-api-ms-win-core-sysinfo-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-windowsceip-l1-1-0.a +libwinapi_windowsapp-api-ms-win-security-lsalookup-ansi-l2-1-0.a +libwinapi_windowsapp-api-ms-win-core-realtime-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-winrt-roparameterizediid-l1-1-0.a +libwinapi_windowsapp-api-ms-win-eventing-legacy-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-enclave-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-psapi-ansi-l1-1-0.a +libwinapi_windowsapp-esent.a +libwinapi_windowsapp-mfsensorgroup.a +libwinapi_windowsapp-api-ms-win-security-base-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-path-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-winrt-robuffer-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-datetime-l1-1-2.a +libwinapi_windowsapp-propsys.a +libwinapi_windowsapp-api-ms-win-core-featurestaging-l1-1-0.a +libwinapi_windowsapp-api-ms-win-eventing-classicprovider-l1-1-0.a +libwinapi_windowsapp-api-ms-win-security-provider-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-libraryloader-l2-1-0.a +libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-0.a +libwinapi_windowsapp-mfreadwrite.a +libwinapi_windowsapp-api-ms-win-core-version-l1-1-0.a +libwinapi_windowsapp-api-ms-win-appmodel-runtime-l1-1-1.a +libwinapi_windowsapp-api-ms-win-core-comm-l1-1-0.a +libwinapi_windowsapp-dhcpcsvc.a +libwinapi_windowsapp-chakra.a +libwinapi_windowsapp-api-ms-win-eventing-provider-l1-1-0.a +libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a +libwinapi_windowsapp-api-ms-win-security-base-l1-2-0.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-advapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-advapi32.a new file mode 100644 index 0000000..6813101 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-advapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-localization-l1-2-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-localization-l1-2-0.a new file mode 100644 index 0000000..2a07b48 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-localization-l1-2-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-l1-1-0.a new file mode 100644 index 0000000..891b09e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-robuffer-l1-1-0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-robuffer-l1-1-0.a new file mode 100644 index 0000000..bf98a41 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-robuffer-l1-1-0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-cabinet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-cabinet.a new file mode 100644 index 0000000..40f0062 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-cabinet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d2d1.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d2d1.a new file mode 100644 index 0000000..96bc6aa Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d2d1.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3d11.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3d11.a new file mode 100644 index 0000000..ddf0ff9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3d11.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3dcompiler_47.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3dcompiler_47.a new file mode 100644 index 0000000..dc2ef2d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-d3dcompiler_47.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-deviceaccess.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-deviceaccess.a new file mode 100644 index 0000000..6a6ca89 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-deviceaccess.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc.a new file mode 100644 index 0000000..4319f0a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc6.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc6.a new file mode 100644 index 0000000..7350198 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dhcpcsvc6.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dwrite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dwrite.a new file mode 100644 index 0000000..68a3c24 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dwrite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dxgi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dxgi.a new file mode 100644 index 0000000..4c41bfc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-dxgi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-esent.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-esent.a new file mode 100644 index 0000000..df960f5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-esent.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-kernel32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-kernel32.a new file mode 100644 index 0000000..4818f29 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-kernel32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mf.a new file mode 100644 index 0000000..df6d532 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfplat.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfplat.a new file mode 100644 index 0000000..95a95c6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfplat.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfreadwrite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfreadwrite.a new file mode 100644 index 0000000..3b64b76 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mfreadwrite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mmdevapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mmdevapi.a new file mode 100644 index 0000000..3af3528 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mmdevapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-msajapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-msajapi.a new file mode 100644 index 0000000..593538e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-msajapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mscoree.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mscoree.a new file mode 100644 index 0000000..b220187 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mscoree.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mswsock.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mswsock.a new file mode 100644 index 0000000..f3dba4f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-mswsock.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ole32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ole32.a new file mode 100644 index 0000000..3685c4d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ole32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-oleaut32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-oleaut32.a new file mode 100644 index 0000000..dfbadd7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-oleaut32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-propsys.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-propsys.a new file mode 100644 index 0000000..f6ca572 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-propsys.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-rpcrt4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-rpcrt4.a new file mode 100644 index 0000000..8c88d33 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-rpcrt4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-uiautomationcore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-uiautomationcore.a new file mode 100644 index 0000000..8bef6eb Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-uiautomationcore.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-urlmon.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-urlmon.a new file mode 100644 index 0000000..d459032 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-urlmon.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-webservices.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-webservices.a new file mode 100644 index 0000000..ce2f0d2 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-webservices.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.data.pdf.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.data.pdf.a new file mode 100644 index 0000000..5b1679c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.data.pdf.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.networking.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.networking.a new file mode 100644 index 0000000..30c12b7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windows.networking.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windowscodecs.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windowscodecs.a new file mode 100644 index 0000000..bfb543e Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-windowscodecs.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ws2_32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ws2_32.a new file mode 100644 index 0000000..c557407 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xaudio2_8.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xaudio2_8.a new file mode 100644 index 0000000..0c21219 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xaudio2_8.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xinput1_4.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xinput1_4.a new file mode 100644 index 0000000..abf088d Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xinput1_4.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xmllite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xmllite.a new file mode 100644 index 0000000..1f95da6 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel-xmllite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel.a new file mode 100644 index 0000000..83a2d27 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp_downlevel.a @@ -0,0 +1,38 @@ +INPUT( +libwinapi_windowsapp_downlevel-dhcpcsvc.a +libwinapi_windowsapp_downlevel-urlmon.a +libwinapi_windowsapp_downlevel-dhcpcsvc6.a +libwinapi_windowsapp_downlevel-mscoree.a +libwinapi_windowsapp_downlevel-ole32.a +libwinapi_windowsapp_downlevel-esent.a +libwinapi_windowsapp_downlevel-windows.networking.a +libwinapi_windowsapp_downlevel-oleaut32.a +libwinapi_windowsapp_downlevel-dxgi.a +libwinapi_windowsapp_downlevel-xmllite.a +libwinapi_windowsapp_downlevel-xinput1_4.a +libwinapi_windowsapp_downlevel-deviceaccess.a +libwinapi_windowsapp_downlevel-d3d11.a +libwinapi_windowsapp_downlevel-dwrite.a +libwinapi_windowsapp_downlevel-propsys.a +libwinapi_windowsapp_downlevel-kernel32.a +libwinapi_windowsapp_downlevel-mf.a +libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-l1-1-0.a +libwinapi_windowsapp_downlevel-d3dcompiler_47.a +libwinapi_windowsapp_downlevel-windowscodecs.a +libwinapi_windowsapp_downlevel-mfplat.a +libwinapi_windowsapp_downlevel-api-ms-win-core-localization-l1-2-0.a +libwinapi_windowsapp_downlevel-d2d1.a +libwinapi_windowsapp_downlevel-msajapi.a +libwinapi_windowsapp_downlevel-uiautomationcore.a +libwinapi_windowsapp_downlevel-mfreadwrite.a +libwinapi_windowsapp_downlevel-webservices.a +libwinapi_windowsapp_downlevel-ws2_32.a +libwinapi_windowsapp_downlevel-advapi32.a +libwinapi_windowsapp_downlevel-rpcrt4.a +libwinapi_windowsapp_downlevel-windows.data.pdf.a +libwinapi_windowsapp_downlevel-xaudio2_8.a +libwinapi_windowsapp_downlevel-mmdevapi.a +libwinapi_windowsapp_downlevel-api-ms-win-core-winrt-robuffer-l1-1-0.a +libwinapi_windowsapp_downlevel-mswsock.a +libwinapi_windowsapp_downlevel-cabinet.a +) diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowscodecs.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowscodecs.a new file mode 100644 index 0000000..bf44edd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowscodecs.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winfax.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winfax.a new file mode 100644 index 0000000..1ad799c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winfax.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winhttp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winhttp.a new file mode 100644 index 0000000..afea448 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winhttp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wininet.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wininet.a new file mode 100644 index 0000000..360fbca Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wininet.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winmm.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winmm.a new file mode 100644 index 0000000..20a0aed Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winmm.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winscard.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winscard.a new file mode 100644 index 0000000..4ddddbc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winscard.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winspool.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winspool.a new file mode 100644 index 0000000..a8302fd Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winspool.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winsqlite3.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winsqlite3.a new file mode 100644 index 0000000..d681e08 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winsqlite3.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winsta.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winsta.a new file mode 100644 index 0000000..a7cdc51 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winsta.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wintrust.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wintrust.a new file mode 100644 index 0000000..b5d435a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wintrust.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winusb.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winusb.a new file mode 100644 index 0000000..5dfdad4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_winusb.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wlanapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wlanapi.a new file mode 100644 index 0000000..a7e75b5 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wlanapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wlanui.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wlanui.a new file mode 100644 index 0000000..7018a29 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wlanui.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wldap32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wldap32.a new file mode 100644 index 0000000..20dc6d7 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wldap32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wmip.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wmip.a new file mode 100644 index 0000000..1243b41 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wmip.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wmvcore.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wmvcore.a new file mode 100644 index 0000000..41a5a9c Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wmvcore.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wnvapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wnvapi.a new file mode 100644 index 0000000..8770cee Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wnvapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wofutil.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wofutil.a new file mode 100644 index 0000000..d4a89ff Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wofutil.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ws2_32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ws2_32.a new file mode 100644 index 0000000..d61898a Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_ws2_32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wscapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wscapi.a new file mode 100644 index 0000000..6e4f3dc Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wscapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsclient.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsclient.a new file mode 100644 index 0000000..4a01997 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsclient.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsdapi.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsdapi.a new file mode 100644 index 0000000..24c1c70 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsdapi.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsmsvc.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsmsvc.a new file mode 100644 index 0000000..783acfa Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsmsvc.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsnmp32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsnmp32.a new file mode 100644 index 0000000..e9bffd1 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsnmp32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsock32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsock32.a new file mode 100644 index 0000000..8d12830 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wsock32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wtsapi32.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wtsapi32.a new file mode 100644 index 0000000..07dabb9 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_wtsapi32.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2.a new file mode 100644 index 0000000..ab28547 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2_8.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2_8.a new file mode 100644 index 0000000..36dcc81 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xaudio2_8.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xinput.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xinput.a new file mode 100644 index 0000000..8fcf22f Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xinput.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xinput9_1_0.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xinput9_1_0.a new file mode 100644 index 0000000..8409ae4 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xinput9_1_0.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xinputuap.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xinputuap.a new file mode 100644 index 0000000..8f778e3 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xinputuap.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xmllite.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xmllite.a new file mode 100644 index 0000000..4da29d0 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xmllite.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xolehlp.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xolehlp.a new file mode 100644 index 0000000..524c5fe Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xolehlp.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xpsdocumenttargetprint.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xpsdocumenttargetprint.a new file mode 100644 index 0000000..07d7d9b Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xpsdocumenttargetprint.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xpsprint.a b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xpsprint.a new file mode 100644 index 0000000..22cf101 Binary files /dev/null and b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_xpsprint.a differ diff --git a/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/src/lib.rs b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/src/lib.rs new file mode 100644 index 0000000..3b7f827 --- /dev/null +++ b/third_party/cargo/vendor/winapi-x86_64-pc-windows-gnu-0.4.0/src/lib.rs @@ -0,0 +1,7 @@ +// Copyright © 2016 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +#![no_std] diff --git a/third_party/cargo/vendor/winit-0.18.1/.cargo-checksum.json b/third_party/cargo/vendor/winit-0.18.1/.cargo-checksum.json new file mode 100644 index 0000000..eab3c62 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"21bc78e0ba4ef6b69846554ec723b4b0ad4568427d94cad2d1d8d521611d37b6","CONTRIBUTING.md":"b2ce30780143f51c660b7d575f8854bec10561a37bccaaf611f5a23041a99cc1","Cargo.toml":"797e6f14f44723b9c7eed8dfc36aeb2f8557ca010297d2467fe844de685f31fe","LICENSE":"6dc0e068dcf3a5bc8e054205b85b7720e1d49265bbc64bf515d2cf79197df69a","README.md":"12286e856c1859aa6a1b350ce24e0d5de54d97a9a9b829abeb90593637a5e633","appveyor.yml":"5238507dc1a10b6fa09883a367b5e4d5be850a04793fd8b88bde8af823df97dd","examples/cursor.rs":"e3380a2cb9d234ebe17ea35d42f72ad93876ef8ece2ade27bbfa8b347f391529","examples/cursor_grab.rs":"b2e43b7e1dfe0fb687b8e764b92ebf5f99a62e033afe724a207be0c7e407be2c","examples/fullscreen.rs":"5c31df4f6d0d990075136056b91abc7087f89ae2ff8344e5c6b0c0c3aa21a9bf","examples/handling_close.rs":"69ec624074de4af2fb4baaca5df7354a1815918103f408ddd24d556ea6529993","examples/icon.png":"4340d72fb8b5d95a10e3b2c02230f1060dff0950a137bd1d830c63dbc020dd45","examples/min_max_size.rs":"be6333d35d413f69a8247ea8198122f0488fc10929c74584e5a8e46a28b13c54","examples/monitor_list.rs":"fe0b1b5e3e309ffea053faf3b0b3e8342851af282bc89bf885235ee4a6b132e7","examples/multiwindow.rs":"55e4c88746019482e67ee7926546120bac3d371e19cc2971577e3d9757715232","examples/proxy.rs":"e1e4e6cff2dc2e393023c46061503b78622754bd653ebf8f786eaaa8958a217a","examples/resizable.rs":"e07d92e9b88f504ae7fd903a4eba0112c0113d1cb0922a534068ac331cc192f8","examples/transparent.rs":"e7a4c31c3c9f3e4a97e1bc272b10ca050a0f87931c988bd57ebc0ae137edb4a9","examples/window.rs":"3ebb9df8c8680782941a1612605e8d9e676872ab645b4ea594c7ac2c3983de28","examples/window_icon.rs":"875f1dba4deb9b669a6e52ff6936a3ae343f58d913dfcfd2fc7f23637a8a38b4","src/dpi.rs":"2d9b952576e0cf37cc09facab5140c7cbafbbc22854e574282a2bdf81fd31725","src/events.rs":"c8e9dd3508bdf9440664b73b4e04b9a2e2e499501ec4dd505e3fe599abd1f327","src/icon.rs":"3f59ac9213e4f1113fa64138e3d09505ad06561f562d2da1ce511a1ee772068d","src/lib.rs":"94d861c169f518bcfa4cbcf85c21451119f4bf3db015416317c9d4a4477a186c","src/os/android.rs":"f0a3a8acc8d33645b997338df297378510642547c1cd443c7593577bc35d43f7","src/os/ios.rs":"ebff4e61f92b48b435861030a4c48358852b05d9a644267ad1c106d5a5dde43c","src/os/macos.rs":"f26e38ac2ca36f442fc74839e9e1bbe3dc71df8cacbfff79e1adcd4ef594f25b","src/os/mod.rs":"ef2009932ff2f2e783681a997d14cd60750a5837b698444a2968b0499b9a5d0c","src/os/unix.rs":"4dfbc9dd8e26a91085b27279b7081882acf493fd874f6d9bbdfb5053da719671","src/os/windows.rs":"bf5a98340e63e32a7436be0357910a3227b2ff7af48a821114936f9b4bf9f2ec","src/platform/android/ffi.rs":"229b59cf0d8a482835ce4ec154643c1698f8baa3e2ebc52e1116eee0f2c04f9d","src/platform/android/mod.rs":"907824f8aa09ef94fa958e5c395f2e87622fbc223badef976e52e5a21704d7e7","src/platform/emscripten/ffi.rs":"7bc7d06f6a37583f9693b1793e769584b1b2ce4c107556c831160c3c75b05e81","src/platform/emscripten/mod.rs":"5e319a90b37176c7260ee603477e5bff3211bcd1eaecaaf9e21a67b96c0e492f","src/platform/ios/ffi.rs":"b2737d51d1f8c6fec58af346bd0033eb84f4ce8b165034ae9a3721748526cc98","src/platform/ios/mod.rs":"90b54a17677e68c01728b3187d67d274e185f02c8b29cf3c84208a29c402450f","src/platform/linux/dlopen.rs":"bb3da0d4c37cd8001d987b91fb0a3516bff318d9d531b78210ae66d799e9c241","src/platform/linux/mod.rs":"ed4ff513d9876d8ff40256b092aed07366e73be0f96928b1fe5df1c9bbf50fca","src/platform/linux/wayland/event_loop.rs":"ee6ec7db28319fc52afe133d5b3c7a50084c3d8bca0ef5ba8750d30630d64b4a","src/platform/linux/wayland/keyboard.rs":"69b052282d0dd44903a059823e391d910e0c32b8e36d3784a643e5000db46c92","src/platform/linux/wayland/mod.rs":"94e2a06d4c1e7db9aae126863750eaf1b1f16fed09dc1ee6efa7320c91c876ab","src/platform/linux/wayland/pointer.rs":"645873302efb578528eafcac5f4825d5aa8da14556feb99b36716f5078bd0a0b","src/platform/linux/wayland/touch.rs":"532616829085978b20b716c4a23a6c918dd4a1aa1ef1c449aef4a66e366d9f05","src/platform/linux/wayland/window.rs":"569f2855351193e2b257da878c69008b14dcd4f8ee2a2726bd1d4b0313776b88","src/platform/linux/x11/dnd.rs":"e8f08b6f732f21819ca0f561757c7af226dd084dcdd926b86b3c7ff8ece63825","src/platform/linux/x11/events.rs":"0307003d6c5d8ae68458b226fac9766920cd80ee3ba8a9bd9f0fb55e0e056181","src/platform/linux/x11/ffi.rs":"1e4b73679de689953c101a0072e9631b7be195ec5bbdbdab0526a40c6caee65e","src/platform/linux/x11/ime/callbacks.rs":"68ab9eedaae2d1a5c203edb46a940406c8215f32e3d02494f8089988fbd97c21","src/platform/linux/x11/ime/context.rs":"4fb3d2be0eaa07c084ecd453b7f6ca070fd2db5dbe475663948860c23c66a498","src/platform/linux/x11/ime/inner.rs":"8ee005cb68ea12432f8c526f185ff461498efba4f7f76c81b9386a751f5c5dcf","src/platform/linux/x11/ime/input_method.rs":"9fbddd9068f7b6400b9914b05c1a91046cc8f4f72433a7debb5bd79f7e0f0aac","src/platform/linux/x11/ime/mod.rs":"e4b81489f170daa525dddafa38f53a759c5ec9dc2b75f30a559dbceabc943e79","src/platform/linux/x11/mod.rs":"2672f96e82c735665b27a37d270e0c8b96564176d8695b7e401edd62c1638a7d","src/platform/linux/x11/monitor.rs":"a59df2bdd8555b1fe5d274f28334bf35c01fd7f686a4f6d2e2666942bff1f1fb","src/platform/linux/x11/util/atom.rs":"557b546ef237dd7a51820e40077c02e26c6c3581ffbe904875f4c60b06191337","src/platform/linux/x11/util/client_msg.rs":"206c5481e8bd2163b59a8c75bf0a50b40a8307612884cb4fe9cd8044f026fa14","src/platform/linux/x11/util/format.rs":"01c19e93c04bb05cd67988f0594a26281d74e4464c2c96115eb5912801b81caa","src/platform/linux/x11/util/geometry.rs":"389c112e8ba74e6b982c785775da2521cb585f6597f93f4bdfe390940efa81f0","src/platform/linux/x11/util/hint.rs":"071e3b68640804e69341068fec59a6207c1a7f61619532ba38fdff8271693046","src/platform/linux/x11/util/icon.rs":"8c435ccd89148697ea6746a44208105f41bdab4a61d363637e2ffba3e9cae0d8","src/platform/linux/x11/util/input.rs":"24a6c356f05f2d57abab7f1c42efb0850ba0e0323b3e8537c027b42942396320","src/platform/linux/x11/util/memory.rs":"aa35e341e78878cbc8f856dde2b7aeb31a34d88cb61f9132c76b336a9c8c37b7","src/platform/linux/x11/util/mod.rs":"e7f5f3591ff8b85b6cc1cc71c8d1e98921f51c889cbff6f35163048bfc41bc32","src/platform/linux/x11/util/randr.rs":"1aee592ded5c3b5fdc6ec17ed8beb91a182209c0ba7230d553e801fd94207185","src/platform/linux/x11/util/window_property.rs":"479a8791ba06a64794e18b26db61e2f1904a9773061c48f6e43eb9391bafc1fb","src/platform/linux/x11/util/wm.rs":"a2ea247d2c65da5ee1feb22b0eb8ca8181c9e69e54835c3a6bff9d85fcd84b67","src/platform/linux/x11/window.rs":"44ae08a4d5560f11d169eb9e4b2595f6dd0ad58fdc8422d64453d920f0628e75","src/platform/linux/x11/xdisplay.rs":"e8391c9374b11cace9c3297df4554cbe5b0dc26b7ef8c23814b74b06d402cc57","src/platform/macos/events_loop.rs":"a82f9ced90f3c30b43d0df5c6810ec1f42aa0acaffd012ee06b77b7c54ff4c3a","src/platform/macos/ffi.rs":"05dfa9d37e6e25ca931704a7703d638b914e207a712097616b99d76d2e6dbe1f","src/platform/macos/mod.rs":"5060640a333aea78f560b90376335abb54339b7a11fc3ba04ad954cc1592d64a","src/platform/macos/monitor.rs":"e77d7bea35ac9b4e10fa1270099043b2d8283921af4ece31c772fe13833c311d","src/platform/macos/util/cursor.rs":"6355e64e1ff62028f69daac0cbacbe43ff9919b52dbe45d946e0c106d5256944","src/platform/macos/util/into_option.rs":"7bbfe330a5e32fc342ca471471a95f5d9c9b986946334ccdbe5f5ce617078363","src/platform/macos/util/mod.rs":"4f65062a069db738848cc6a1ad345ebcc2cabc2f5077d6873e292d2b801c2a9e","src/platform/macos/view.rs":"9f8ff5ed9598416df1cbfcb7ec1c9833273b00e5ec227bc073cdbd9ca6387340","src/platform/macos/window.rs":"6b5f0a28de4760c66b5785137be0fa3b4074a6e96582c3c8d8448de704e3913f","src/platform/mod.rs":"46ab9469d5cceb8d6c8abeb6702afff192026430a13c53ba53d1fa54317c45db","src/platform/windows/dpi.rs":"676001f721cf6a19f94e8e918e5e196063eca84b842fb1cf2d98120b452cde24","src/platform/windows/drop_handler.rs":"ba15e54c4bafa822377cf68abbb162b1f2490ec130d947c5a537735d1c4754c8","src/platform/windows/event.rs":"e4ac1baa001bf0df41ec8ae82bcdc4d3c216a46fe82f19439743cad5eb3eb4da","src/platform/windows/events_loop.rs":"9c7367571c66f553123bb5313a4ea8472f33938d8d62d59248ea0fa534db6bf1","src/platform/windows/icon.rs":"36ebdbbb13159021baa4ab83cfffeabfe0fd41a1281eb170374b9ad773015ac0","src/platform/windows/mod.rs":"3147d497ba297658565ff5121e498ce2ba5b771dd51addd7d14c834902b48f62","src/platform/windows/monitor.rs":"6b7895366c693ad44c1719a931a32baedf21ef4bc33d906adfccc99ff4e1f4d7","src/platform/windows/raw_input.rs":"407a2b7f75145cc0f5f5423c45a13b24865f690c5173d76a0396e4e0f1dcc634","src/platform/windows/util.rs":"91c1525a3cbaa7217c4485165dc7c558f1993a82bb29371e39039155b2dda6b7","src/platform/windows/window.rs":"3b8a4bc032150c17ea2fe2cfc14c9f7b293f66afee90d7ed2c824f8ec001d92c","src/window.rs":"be0fc4232fde4ce0032d2d7a892f1473c83501fba93b0d954886b5116416da08","tests/send_objects.rs":"8afcfed9702d1ef656e478ee7bdd1f3f2f8b9c092306c9b3e2240ebbeb01dde0","tests/serde_objects.rs":"0f29db9a798db854e4f06f8aca7977f247a6e3b3f90a492a19638a42ec9c7595","tests/sync_object.rs":"70ebde6478cb4404c004c4e59a1f4da293a34c14763ca86c87c59521a0a38c00"},"package":"8c57c15bd4c0ef18dff33e263e452abe32d00e2e05771cacaa410a14cc1c0776"} \ No newline at end of file diff --git a/third_party/cargo/vendor/winit-0.18.1/BUILD b/third_party/cargo/vendor/winit-0.18.1/BUILD new file mode 100644 index 0000000..5e2e9da --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/BUILD @@ -0,0 +1,65 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "cursor" with type "example" omitted +# Unsupported target "cursor_grab" with type "example" omitted +# Unsupported target "fullscreen" with type "example" omitted +# Unsupported target "handling_close" with type "example" omitted +# Unsupported target "min_max_size" with type "example" omitted +# Unsupported target "monitor_list" with type "example" omitted +# Unsupported target "multiwindow" with type "example" omitted +# Unsupported target "proxy" with type "example" omitted +# Unsupported target "resizable" with type "example" omitted +# Unsupported target "send_objects" with type "test" omitted +# Unsupported target "serde_objects" with type "test" omitted +# Unsupported target "sync_object" with type "test" omitted +# Unsupported target "transparent" with type "example" omitted +# Unsupported target "window" with type "example" omitted +# Unsupported target "window_icon" with type "example" omitted + +rust_library( + name = "winit", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/log-0.4.8:log", + "//third_party/cargo/vendor/parking_lot-0.7.1:parking_lot", + "//third_party/cargo/vendor/percent-encoding-1.0.1:percent_encoding", + "//third_party/cargo/vendor/smithay-client-toolkit-0.4.6:smithay_client_toolkit", + "//third_party/cargo/vendor/wayland-client-0.21.13:wayland_client", + "//third_party/cargo/vendor/x11-dl-2.18.4:x11_dl", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.18.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/winit-0.18.1/CHANGELOG.md b/third_party/cargo/vendor/winit-0.18.1/CHANGELOG.md new file mode 100644 index 0000000..00b8dc3 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/CHANGELOG.md @@ -0,0 +1,305 @@ +# Unreleased + +# Version 0.18.1 (2018-12-30) + +- On macOS, fix `Yen` (JIS) so applications receive the event. +- On X11 with a tiling WM, fixed high CPU usage when moving windows across monitors. +- On X11, fixed panic caused by dropping the window before running the event loop. +- on macOS, added `WindowExt::set_simple_fullscreen` which does not require a separate space +- Introduce `WindowBuilderExt::with_app_id` to allow setting the application ID on Wayland. +- On Windows, catch panics in event loop child thread and forward them to the parent thread. This prevents an invocation of undefined behavior due to unwinding into foreign code. +- On Windows, fix issue where resizing or moving window combined with grabbing the cursor would freeze program. +- On Windows, fix issue where resizing or moving window would eat `Awakened` events. +- On Windows, exiting fullscreen after entering fullscreen with disabled decorations no longer shrinks window. +- On X11, fixed a segfault when using virtual monitors with XRandR. +- Derive `Ord` and `PartialOrd` for `VirtualKeyCode` enum. +- On Windows, fix issue where hovering or dropping a non file item would create a panic. +- On Wayland, fix resizing and DPI calculation when a `wl_output` is removed without sending a `leave` event to the `wl_surface`, such as disconnecting a monitor from a laptop. +- On Wayland, DPI calculation is handled by smithay-client-toolkit. +- On X11, `WindowBuilder::with_min_dimensions` and `WindowBuilder::with_max_dimensions` now correctly account for DPI. +- Added support for generating dummy `DeviceId`s and `WindowId`s to better support unit testing. +- On macOS, fixed unsoundness in drag-and-drop that could result in drops being rejected. +- On macOS, implemented `WindowEvent::Refresh`. +- On macOS, all `MouseCursor` variants are now implemented and the cursor will no longer reset after unfocusing. +- Removed minimum supported Rust version guarantee. + +# Version 0.18.0 (2018-11-07) + +- **Breaking:** `image` crate upgraded to 0.20. This is exposed as part of the `icon_loading` API. +- On Wayland, pointer events will now provide the current modifiers state. +- On Wayland, titles will now be displayed in the window header decoration. +- On Wayland, key repetition is now ended when keyboard loses focus. +- On Wayland, windows will now use more stylish and modern client side decorations. +- On Wayland, windows will use server-side decorations when available. +- **Breaking:** Added support for F16-F24 keys (variants were added to the `VirtualKeyCode` enum). +- Fixed graphical glitches when resizing on Wayland. +- On Windows, fix freezes when performing certain actions after a window resize has been triggered. Reintroduces some visual artifacts when resizing. +- Updated window manager hints under X11 to v1.5 of [Extended Window Manager Hints](https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#idm140200472629520). +- Added `WindowBuilderExt::with_gtk_theme_variant` to X11-specific `WindowBuilder` functions. +- Fixed UTF8 handling bug in X11 `set_title` function. +- On Windows, `Window::set_cursor` now applies immediately instead of requiring specific events to occur first. +- On Windows, the `HoveredFile` and `HoveredFileCancelled` events are now implemented. +- On Windows, fix `Window::set_maximized`. +- On Windows 10, fix transparency (#260). +- On macOS, fix modifiers during key repeat. +- Implemented the `Debug` trait for `Window`, `EventsLoop`, `EventsLoopProxy` and `WindowBuilder`. +- On X11, now a `Resized` event will always be generated after a DPI change to ensure the window's logical size is consistent with the new DPI. +- Added further clarifications to the DPI docs. +- On Linux, if neither X11 nor Wayland manage to initialize, the corresponding panic now consists of a single line only. +- Add optional `serde` feature with implementations of `Serialize`/`Deserialize` for DPI types and various event types. +- Add `PartialEq`, `Eq`, and `Hash` implementations on public types that could have them but were missing them. +- On X11, drag-and-drop receiving an unsupported drop type can no longer cause the WM to freeze. +- Fix issue whereby the OpenGL context would not appear at startup on macOS Mojave (#1069). +- **Breaking:** Removed `From<NSApplicationActivationPolicy>` impl from `ActivationPolicy` on macOS. +- On macOS, the application can request the user's attention with `WindowExt::request_user_attention`. + +# Version 0.17.2 (2018-08-19) + +- On macOS, fix `<C-Tab>` so applications receive the event. +- On macOS, fix `<Cmd-{key}>` so applications receive the event. +- On Wayland, key press events will now be repeated. + +# Version 0.17.1 (2018-08-05) + +- On X11, prevent a compilation failure in release mode for versions of Rust greater than or equal to 1.30. +- Fixed deadlock that broke fullscreen mode on Windows. + +# Version 0.17.0 (2018-08-02) + +- Cocoa and core-graphics updates. +- Fixed thread-safety issues in several `Window` functions on Windows. +- On MacOS, the key state for modifiers key events is now properly set. +- On iOS, the view is now set correctly. This makes it possible to render things (instead of being stuck on a black screen), and touch events work again. +- Added NetBSD support. +- **Breaking:** On iOS, `UIView` is now the default root view. `WindowBuilderExt::with_root_view_class` can be used to set the root view objective-c class to `GLKView` (OpenGLES) or `MTKView` (Metal/MoltenVK). +- On iOS, the `UIApplication` is not started until `Window::new` is called. +- Fixed thread unsafety with cursor hiding on macOS. +- On iOS, fixed the size of the `JmpBuf` type used for `setjmp`/`longjmp` calls. Previously this was a buffer overflow on most architectures. +- On Windows, use cached window DPI instead of repeatedly querying the system. This fixes sporadic crashes on Windows 7. + +# Version 0.16.2 (2018-07-07) + +- On Windows, non-resizable windows now have the maximization button disabled. This is consistent with behavior on macOS and popular X11 WMs. +- Corrected incorrect `unreachable!` usage when guessing the DPI factor with no detected monitors. + +# Version 0.16.1 (2018-07-02) + +- Added logging through `log`. Logging will become more extensive over time. +- On X11 and Windows, the window's DPI factor is guessed before creating the window. This *greatly* cuts back on unsightly auto-resizing that would occur immediately after window creation. +- Fixed X11 backend compilation for environments where `c_char` is unsigned. + +# Version 0.16.0 (2018-06-25) + +- Windows additionally has `WindowBuilderExt::with_no_redirection_bitmap`. +- **Breaking:** Removed `VirtualKeyCode::LMenu` and `VirtualKeyCode::RMenu`; Windows now generates `VirtualKeyCode::LAlt` and `VirtualKeyCode::RAlt` instead. +- On X11, exiting fullscreen no longer leaves the window in the monitor's top left corner. +- **Breaking:** `Window::hidpi_factor` has been renamed to `Window::get_hidpi_factor` for better consistency. `WindowEvent::HiDPIFactorChanged` has been renamed to `WindowEvent::HiDpiFactorChanged`. DPI factors are always represented as `f64` instead of `f32` now. +- The Windows backend is now DPI aware. `WindowEvent::HiDpiFactorChanged` is implemented, and `MonitorId::get_hidpi_factor` and `Window::hidpi_factor` return accurate values. +- Implemented `WindowEvent::HiDpiFactorChanged` on X11. +- On macOS, `Window::set_cursor_position` is now relative to the client area. +- On macOS, setting the maximum and minimum dimensions now applies to the client area dimensions rather than to the window dimensions. +- On iOS, `MonitorId::get_dimensions` has been implemented and both `MonitorId::get_hidpi_factor` and `Window::get_hidpi_factor` return accurate values. +- On Emscripten, `MonitorId::get_hidpi_factor` now returns the same value as `Window::get_hidpi_factor` (it previously would always return 1.0). +- **Breaking:** The entire API for sizes, positions, etc. has changed. In the majority of cases, winit produces and consumes positions and sizes as `LogicalPosition` and `LogicalSize`, respectively. The notable exception is `MonitorId` methods, which deal in `PhysicalPosition` and `PhysicalSize`. See the documentation for specifics and explanations of the types. Additionally, winit automatically conserves logical size when the DPI factor changes. +- **Breaking:** All deprecated methods have been removed. For `Window::platform_display` and `Window::platform_window`, switch to the appropriate platform-specific `WindowExt` methods. For `Window::get_inner_size_points` and `Window::get_inner_size_pixels`, use the `LogicalSize` returned by `Window::get_inner_size` and convert as needed. +- HiDPI support for Wayland. +- `EventsLoop::get_available_monitors` and `EventsLoop::get_primary_monitor` now have identical counterparts on `Window`, so this information can be acquired without an `EventsLoop` borrow. +- `AvailableMonitorsIter` now implements `Debug`. +- Fixed quirk on macOS where certain keys would generate characters at twice the normal rate when held down. +- On X11, all event loops now share the same `XConnection`. +- **Breaking:** `Window::set_cursor_state` and `CursorState` enum removed in favor of the more composable `Window::grab_cursor` and `Window::hide_cursor`. As a result, grabbing the cursor no longer automatically hides it; you must call both methods to retain the old behavior on Windows and macOS. `Cursor::NoneCursor` has been removed, as it's no longer useful. +- **Breaking:** `Window::set_cursor_position` now returns `Result<(), String>`, thus allowing for `Box<Error>` conversion via `?`. + +# Version 0.15.1 (2018-06-13) + +- On X11, the `Moved` event is no longer sent when the window is resized without changing position. +- `MouseCursor` and `CursorState` now implement `Default`. +- `WindowBuilder::with_resizable` implemented for Windows, X11, Wayland, and macOS. +- `Window::set_resizable` implemented for Windows, X11, Wayland, and macOS. +- On X11, if the monitor's width or height in millimeters is reported as 0, the DPI is now 1.0 instead of +inf. +- On X11, the environment variable `WINIT_HIDPI_FACTOR` has been added for overriding DPI factor. +- On X11, enabling transparency no longer causes the window contents to flicker when resizing. +- On X11, `with_override_redirect` now actually enables override redirect. +- macOS now generates `VirtualKeyCode::LAlt` and `VirtualKeyCode::RAlt` instead of `None` for both. +- On macOS, `VirtualKeyCode::RWin` and `VirtualKeyCode::LWin` are no longer switched. +- On macOS, windows without decorations can once again be resized. +- Fixed race conditions when creating an `EventsLoop` on X11, most commonly manifesting as "[xcb] Unknown sequence number while processing queue". +- On macOS, `CursorMoved` and `MouseInput` events are only generated if they occurs within the window's client area. +- On macOS, resizing the window no longer generates a spurious `MouseInput` event. + +# Version 0.15.0 (2018-05-22) + +- `Icon::to_cardinals` is no longer public, since it was never supposed to be. +- Wayland: improve diagnostics if initialization fails +- Fix some system event key doesn't work when focused, do not block keyevent forward to system on macOS +- On X11, the scroll wheel position is now correctly reset on i3 and other WMs that have the same quirk. +- On X11, `Window::get_current_monitor` now reliably returns the correct monitor. +- On X11, `Window::hidpi_factor` returns values from XRandR rather than the inaccurate values previously queried from the core protocol. +- On X11, the primary monitor is detected correctly even when using versions of XRandR less than 1.5. +- `MonitorId` now implements `Debug`. +- Fixed bug on macOS where using `with_decorations(false)` would cause `set_decorations(true)` to produce a transparent titlebar with no title. +- Implemented `MonitorId::get_position` on macOS. +- On macOS, `Window::get_current_monitor` now returns accurate values. +- Added `WindowBuilderExt::with_resize_increments` to macOS. +- **Breaking:** On X11, `WindowBuilderExt::with_resize_increments` and `WindowBuilderExt::with_base_size` now take `u32` values rather than `i32`. +- macOS keyboard handling has been overhauled, allowing for the use of dead keys, IME, etc. Right modifier keys are also no longer reported as being left. +- Added the `Window::set_ime_spot(x: i32, y: i32)` method, which is implemented on X11 and macOS. +- **Breaking**: `os::unix::WindowExt::send_xim_spot(x: i16, y: i16)` no longer exists. Switch to the new `Window::set_ime_spot(x: i32, y: i32)`, which has equivalent functionality. +- Fixed detection of `Pause` and `Scroll` keys on Windows. +- On Windows, alt-tabbing while the cursor is grabbed no longer makes it impossible to re-grab the cursor. +- On Windows, using `CursorState::Hide` when the cursor is grabbed now ungrabs the cursor first. +- Implemented `MouseCursor::NoneCursor` on Windows. +- Added `WindowBuilder::with_always_on_top` and `Window::set_always_on_top`. Implemented on Windows, macOS, and X11. +- On X11, `WindowBuilderExt` now has `with_class`, `with_override_redirect`, and `with_x11_window_type` to allow for more control over window creation. `WindowExt` additionally has `set_urgent`. +- More hints are set by default on X11, including `_NET_WM_PID` and `WM_CLIENT_MACHINE`. Note that prior to this, the `WM_CLASS` hint was automatically set to whatever value was passed to `with_title`. It's now set to the executable name to better conform to expectations and the specification; if this is undesirable, you must explicitly use `WindowBuilderExt::with_class`. + +# Version 0.14.0 (2018-05-09) + +- Created the `Copy`, `Paste` and `Cut` `VirtualKeyCode`s and added support for them on X11 and Wayland +- Fix `.with_decorations(false)` in macOS +- On Mac, `NSWindow` and supporting objects might be alive long after they were `closed` which resulted in apps consuming more heap then needed. Mainly it was affecting multi window applications. Not expecting any user visible change of behaviour after the fix. +- Fix regression of Window platform extensions for macOS where `NSFullSizeContentViewWindowMask` was not being correctly applied to `.fullsize_content_view`. +- Corrected `get_position` on Windows to be relative to the screen rather than to the taskbar. +- Corrected `Moved` event on Windows to use position values equivalent to those returned by `get_position`. It previously supplied client area positions instead of window positions, and would additionally interpret negative values as being very large (around `u16::MAX`). +- Implemented `Moved` event on macOS. +- On X11, the `Moved` event correctly use window positions rather than client area positions. Additionally, a stray `Moved` that unconditionally accompanied `Resized` with the client area position relative to the parent has been eliminated; `Moved` is still received alongside `Resized`, but now only once and always correctly. +- On Windows, implemented all variants of `DeviceEvent` other than `Text`. Mouse `DeviceEvent`s are now received even if the window isn't in the foreground. +- `DeviceId` on Windows is no longer a unit struct, and now contains a `u32`. For `WindowEvent`s, this will always be 0, but on `DeviceEvent`s it will be the handle to that device. `DeviceIdExt::get_persistent_identifier` can be used to acquire a unique identifier for that device that persists across replugs/reboots/etc. +- Corrected `run_forever` on X11 to stop discarding `Awakened` events. +- Various safety and correctness improvements to the X11 backend internals. +- Fixed memory leak on X11 every time the mouse entered the window. +- On X11, drag and drop now works reliably in release mode. +- Added `WindowBuilderExt::with_resize_increments` and `WindowBuilderExt::with_base_size` to X11, allowing for more optional hints to be set. +- Rework of the wayland backend, migrating it to use [Smithay's Client Toolkit](https://github.com/Smithay/client-toolkit). +- Added `WindowBuilder::with_window_icon` and `Window::set_window_icon`, finally making it possible to set the window icon on Windows and X11. The `icon_loading` feature can be enabled to allow for icons to be easily loaded; see example program `window_icon.rs` for usage. +- Windows additionally has `WindowBuilderExt::with_taskbar_icon` and `WindowExt::set_taskbar_icon`. +- On Windows, fix panic when trying to call `set_fullscreen(None)` on a window that has not been fullscreened prior. + +# Version 0.13.1 (2018-04-26) + +- Ensure necessary `x11-dl` version is used. + +# Version 0.13.0 (2018-04-25) + +- Implement `WindowBuilder::with_maximized`, `Window::set_fullscreen`, `Window::set_maximized` and `Window::set_decorations` for MacOS. +- Implement `WindowBuilder::with_maximized`, `Window::set_fullscreen`, `Window::set_maximized` and `Window::set_decorations` for Windows. +- On Windows, `WindowBuilder::with_fullscreen` no longer changing monitor display resolution. +- Overhauled X11 window geometry calculations. `get_position` and `set_position` are more universally accurate across different window managers, and `get_outer_size` actually works now. +- Fixed SIGSEGV/SIGILL crashes on macOS caused by stabilization of the `!` (never) type. +- Implement `WindowEvent::HiDPIFactorChanged` for macOS +- On X11, input methods now work completely out of the box, no longer requiring application developers to manually call `setlocale`. Additionally, when input methods are started, stopped, or restarted on the server end, it's correctly handled. +- Implemented `Refresh` event on Windows. +- Properly calculate the minimum and maximum window size on Windows, including window decorations. +- Map more `MouseCursor` variants to cursor icons on Windows. +- Corrected `get_position` on macOS to return outer frame position, not content area position. +- Corrected `set_position` on macOS to set outer frame position, not content area position. +- Added `get_inner_position` method to `Window`, which gets the position of the window's client area. This is implemented on all applicable platforms (all desktop platforms other than Wayland, where this isn't possible). +- **Breaking:** the `Closed` event has been replaced by `CloseRequested` and `Destroyed`. To migrate, you typically just need to replace all usages of `Closed` with `CloseRequested`; see example programs for more info. The exception is iOS, where `Closed` must be replaced by `Destroyed`. + +# Version 0.12.0 (2018-04-06) + +- Added subclass to macos windows so they can be made resizable even with no decorations. +- Dead keys now work properly on X11, no longer resulting in a panic. +- On X11, input method creation first tries to use the value from the user's `XMODIFIERS` environment variable, so application developers should no longer need to manually call `XSetLocaleModifiers`. If that fails, fallbacks are tried, which should prevent input method initialization from ever outright failing. +- Fixed thread safety issues with input methods on X11. +- Add support for `Touch` for win32 backend. +- Fixed `Window::get_inner_size` and friends to return the size in pixels instead of points when using HIDPI displays on OSX. + +# Version 0.11.3 (2018-03-28) + +- Added `set_min_dimensions` and `set_max_dimensions` methods to `Window`, and implemented on Windows, X11, Wayland, and OSX. +- On X11, dropping a `Window` actually closes it now, and clicking the window's × button (or otherwise having the WM signal to close it) will result in the window closing. +- Added `WindowBuilderExt` methods for macos: `with_titlebar_transparent`, + `with_title_hidden`, `with_titlebar_buttons_hidden`, + `with_fullsize_content_view`. +- Mapped X11 numpad keycodes (arrows, Home, End, PageUp, PageDown, Insert and Delete) to corresponding virtual keycodes + +# Version 0.11.2 (2018-03-06) + +- Impl `Hash`, `PartialEq`, and `Eq` for `events::ModifiersState`. +- Implement `MonitorId::get_hidpi_factor` for MacOS. +- Added method `os::macos::MonitorIdExt::get_nsscreen() -> *mut c_void` that gets a `NSScreen` object matching the monitor ID. +- Send `Awakened` event on Android when event loop is woken up. + +# Version 0.11.1 (2018-02-19) + +- Fixed windows not receiving mouse events when click-dragging the mouse outside the client area of a window, on Windows platforms. +- Added method `os::android::EventsLoopExt:set_suspend_callback(Option<Box<Fn(bool) -> ()>>)` that allows glutin to register a callback when a suspend event happens + +# Version 0.11.0 (2018-02-09) + +- Implement `MonitorId::get_dimensions` for Android. +- Added method `os::macos::WindowBuilderExt::with_movable_by_window_background(bool)` that allows to move a window without a titlebar - `with_decorations(false)` +- Implement `Window::set_fullscreen`, `Window::set_maximized` and `Window::set_decorations` for Wayland. +- Added `Caret` as VirtualKeyCode and support OSX ^-Key with german input. + +# Version 0.10.1 (2018-02-05) + +*Yanked* + +# Version 0.10.0 (2017-12-27) + +- Add support for `Touch` for emscripten backend. +- Added support for `DroppedFile`, `HoveredFile`, and `HoveredFileCancelled` to X11 backend. +- **Breaking:** `unix::WindowExt` no longer returns pointers for things that aren't actually pointers; `get_xlib_window` now returns `Option<std::os::raw::c_ulong>` and `get_xlib_screen_id` returns `Option<std::os::raw::c_int>`. Additionally, methods that previously returned `libc::c_void` have been changed to return `std::os::raw::c_void`, which are not interchangeable types, so users wanting the former will need to explicitly cast. +- Added `set_decorations` method to `Window` to allow decorations to be toggled after the window is built. Presently only implemented on X11. +- Raised the minimum supported version of Rust to 1.20 on MacOS due to usage of associated constants in new versions of cocoa and core-graphics. +- Added `modifiers` field to `MouseInput`, `MouseWheel`, and `CursorMoved` events to track the modifiers state (`ModifiersState`). +- Fixed the emscripten backend to return the size of the canvas instead of the size of the window. + +# Version 0.9.0 (2017-12-01) + +- Added event `WindowEvent::HiDPIFactorChanged`. +- Added method `MonitorId::get_hidpi_factor`. +- Deprecated `get_inner_size_pixels` and `get_inner_size_points` methods of `Window` in favor of +`get_inner_size`. +- **Breaking:** `EventsLoop` is `!Send` and `!Sync` because of platform-dependant constraints, + but `Window`, `WindowId`, `DeviceId` and `MonitorId` guaranteed to be `Send`. +- `MonitorId::get_position` now returns `(i32, i32)` instead of `(u32, u32)`. +- Rewrite of the wayland backend to use wayland-client-0.11 +- Support for dead keys on wayland for keyboard utf8 input +- Monitor enumeration on Windows is now implemented using `EnumDisplayMonitors` instead of +`EnumDisplayDevices`. This changes the value returned by `MonitorId::get_name()`. +- On Windows added `MonitorIdExt::hmonitor` method +- Impl `Clone` for `EventsLoopProxy` +- `EventsLoop::get_primary_monitor()` on X11 will fallback to any available monitor if no primary is found +- Support for touch event on wayland +- `WindowEvent`s `MouseMoved`, `MouseEntered`, and `MouseLeft` have been renamed to +`CursorMoved`, `CursorEntered`, and `CursorLeft`. +- New `DeviceEvent`s added, `MouseMotion` and `MouseWheel`. +- Send `CursorMoved` event after `CursorEntered` and `Focused` events. +- Add support for `ModifiersState`, `MouseMove`, `MouseInput`, `MouseMotion` for emscripten backend. + +# Version 0.8.3 (2017-10-11) + +- Fixed issue of calls to `set_inner_size` blocking on Windows. +- Mapped `ISO_Left_Tab` to `VirtualKeyCode::Tab` to make the key work with modifiers +- Fixed the X11 backed on 32bit targets + +# Version 0.8.2 (2017-09-28) + +- Uniformize keyboard scancode values accross Wayland and X11 (#297). +- Internal rework of the wayland event loop +- Added method `os::linux::WindowExt::is_ready` + +# Version 0.8.1 (2017-09-22) + +- Added various methods to `os::linux::EventsLoopExt`, plus some hidden items necessary to make + glutin work. + +# Version 0.8.0 (2017-09-21) + +- Added `Window::set_maximized`, `WindowAttributes::maximized` and `WindowBuilder::with_maximized`. +- Added `Window::set_fullscreen`. +- Changed `with_fullscreen` to take a `Option<MonitorId>` instead of a `MonitorId`. +- Removed `MonitorId::get_native_identifer()` in favor of platform-specific traits in the `os` + module. +- Changed `get_available_monitors()` and `get_primary_monitor()` to be methods of `EventsLoop` + instead of stand-alone methods. +- Changed `EventsLoop` to be tied to a specific X11 or Wayland connection. +- Added a `os::linux::EventsLoopExt` trait that makes it possible to configure the connection. +- Fixed the emscripten code, which now compiles. +- Changed the X11 fullscreen code to use `xrandr` instead of `xxf86vm`. +- Fixed the Wayland backend to produce `Refresh` event after window creation. +- Changed the `Suspended` event to be outside of `WindowEvent`. +- Fixed the X11 backend sometimes reporting the wrong virtual key (#273). diff --git a/third_party/cargo/vendor/winit-0.18.1/CONTRIBUTING.md b/third_party/cargo/vendor/winit-0.18.1/CONTRIBUTING.md new file mode 100644 index 0000000..d32ec8a --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/CONTRIBUTING.md @@ -0,0 +1,70 @@ +# Winit Contributing Guidelines + +## Scope + +Winit aims to provide a generic platform abstracting the main graphic platforms (Windows, macOS, X11, +Wayland, Android, iOS and the web platform via Emscripten). + +Most platforms expose capabilities that cannot be meaningfully transposed to the others. Winit does not +aim to support every single functionality of every platform, but rather to abstract the set of +capabilities that is common to all platforms. In this context, APIs exposed in winit can be split into +different "support levels": + +- Tier 1: features which are in the main scope of winit. They are part of the common API of winit, and + are taken care of by the maintainers. Any part of these features that is not working correctly is + considered a bug in winit. +- Tier 2: some platform-specific features can be sufficiently fundamental to the platform that winit can + integrate support for them in the platform-specific part of the API. These features are not considered + directly handled by the maintainers of winit. If you have a strong incentive to have such a feature + integrated in winit, consider implementing it and proposing yourself to maintain it in the future. +- Tier 3: these features are not directly exposed by winit, but rather can be implemented using the + raw handles to the underlying platform that winit exposes. If your feature of interest is rather + niche, this is probably where it belongs. + +The exact list of supported Tier 1 features is tracked in this issue: +[#252](https://github.com/tomaka/winit/issues/252). + +## Reporting an issue + +When reporting an issue, in order to help the maintainers understand what the problem is, please make +your description of the issue as detailed as possible: + +- if it is a bug, please provide clear explanation of what happens, what should happen, and how to + reproduce the issue, ideally by providing a minimal program exhibiting the problem +- if it is a feature request, please provide a clear argumentation about why you believe this feature + should be supported by winit + +## Making a pull request + +When making a code contribution to winit, before opening your pull request, please make sure that: + +- you tested your modifications on all the platforms impacted, or if not possible detail which platforms + were not tested, and what should be tested, so that a maintainer or another contributor can test them +- you updated any relevant documentation in winit +- you left comments in your code explaining any part that is not straightforward, so that the + maintainers and future contributors don't have to try to guess what your code is supposed to do +- your PR adds an entry to the changelog file if the introduced change is relevant to winit users + +Once your PR is open, you can ask for review by a maintainer of your platform. Winit's merging policy +is that a PR must be approved by at least two maintainers of winit before being merged, including +at least a maintainer of the platform (a maintainer making a PR themselves counts as approving it). + +## Maintainers & Testers + +Winit is managed by several people, each with their specialities, and each maintaining a subset of the +backends of winit. As such, depending on your platform of interest, your contacts will be different. + +This table summarizes who can be contacted in which case, with the following legend: + +- `M`: is a main maintainer for this platform +- `R`: can review code for this platform +- `T`: has the ability of testing the platform +- ` `: knows nothing of this platform + +| Platform | Windows | macOS | X11 | Wayland | Android | iOS | Emscripten | +| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| @francesca64 | R | M | M | | M | R | | +| @mitchmindtree | T | | T | T | | | | +| @Osspial | M | | T | T | T | | T | +| @vberger | | | T | M | | | | +| @mtak- | | T | | | T | M | | diff --git a/third_party/cargo/vendor/winit-0.18.1/Cargo.toml b/third_party/cargo/vendor/winit-0.18.1/Cargo.toml new file mode 100644 index 0000000..259997e --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/Cargo.toml @@ -0,0 +1,81 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "winit" +version = "0.18.1" +authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"] +description = "Cross-platform window creation library." +documentation = "https://docs.rs/winit" +readme = "README.md" +keywords = ["windowing"] +categories = ["gui"] +license = "Apache-2.0" +repository = "https://github.com/tomaka/winit" +[package.metadata.docs.rs] +features = ["icon_loading", "serde"] +[dependencies.image] +version = "0.20.1" +optional = true + +[dependencies.lazy_static] +version = "1" + +[dependencies.libc] +version = "0.2" + +[dependencies.log] +version = "0.4" + +[dependencies.serde] +version = "1" +features = ["serde_derive"] +optional = true + +[features] +icon_loading = ["image"] +[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies.parking_lot] +version = "0.7" + +[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies.percent-encoding] +version = "1.0" + +[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies.smithay-client-toolkit] +version = "0.4.3" + +[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies.wayland-client] +version = "0.21" +features = ["dlopen", "egl", "cursor"] + +[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies.x11-dl] +version = "2.18.3" +[target."cfg(target_os = \"android\")".dependencies.android_glue] +version = "0.2" +[target."cfg(target_os = \"ios\")".dependencies.objc] +version = "0.2.3" +[target."cfg(target_os = \"macos\")".dependencies.cocoa] +version = "0.18.4" + +[target."cfg(target_os = \"macos\")".dependencies.core-foundation] +version = "0.6" + +[target."cfg(target_os = \"macos\")".dependencies.core-graphics] +version = "0.17.3" + +[target."cfg(target_os = \"macos\")".dependencies.objc] +version = "0.2.3" +[target."cfg(target_os = \"windows\")".dependencies.backtrace] +version = "0.3" + +[target."cfg(target_os = \"windows\")".dependencies.winapi] +version = "0.3.6" +features = ["combaseapi", "dwmapi", "errhandlingapi", "hidusage", "libloaderapi", "objbase", "ole2", "processthreadsapi", "shellapi", "shellscalingapi", "shobjidl_core", "unknwnbase", "winbase", "windowsx", "winerror", "wingdi", "winnt", "winuser"] diff --git a/third_party/cargo/vendor/winit-0.18.1/LICENSE b/third_party/cargo/vendor/winit-0.18.1/LICENSE new file mode 100644 index 0000000..ad410e1 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/third_party/cargo/vendor/winit-0.18.1/README.md b/third_party/cargo/vendor/winit-0.18.1/README.md new file mode 100644 index 0000000..0360e12 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/README.md @@ -0,0 +1,62 @@ +# winit - Cross-platform window creation and management in Rust + +[![](http://meritbadge.herokuapp.com/winit)](https://crates.io/crates/winit) +[![Docs.rs](https://docs.rs/winit/badge.svg)](https://docs.rs/winit) +[![Build Status](https://travis-ci.org/tomaka/winit.svg?branch=master)](https://travis-ci.org/tomaka/winit) +[![Build status](https://ci.appveyor.com/api/projects/status/5h87hj0g4q2xe3j9/branch/master?svg=true)](https://ci.appveyor.com/project/tomaka/winit/branch/master) + +```toml +[dependencies] +winit = "0.18.1" +``` + +## [Documentation](https://docs.rs/winit) + +## Usage + +Winit is a window creation and management library. It can create windows and lets you handle +events (for example: the window being resized, a key being pressed, a mouse movement, etc.) +produced by window. + +Winit is designed to be a low-level brick in a hierarchy of libraries. Consequently, in order to +show something on the window you need to use the platform-specific getters provided by winit, or +another library. + +```rust +extern crate winit; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + let window = winit::Window::new(&events_loop).unwrap(); + + events_loop.run_forever(|event| { + match event { + winit::Event::WindowEvent { + event: winit::WindowEvent::CloseRequested, + .. + } => winit::ControlFlow::Break, + _ => winit::ControlFlow::Continue, + } + }); +} +``` + +Winit is only officially supported on the latest stable version of the Rust compiler. + +### Cargo Features + +Winit provides the following features, which can be enabled in your `Cargo.toml` file: +* `icon_loading`: Enables loading window icons directly from files. Depends on the [`image` crate](https://crates.io/crates/image). +* `serde`: Enables serialization/deserialization of certain types with [Serde](https://crates.io/crates/serde). + +### Platform-specific usage + +#### Emscripten and WebAssembly + +Building a binary will yield a `.js` file. In order to use it in an HTML file, you need to: + +- Put a `<canvas id="my_id"></canvas>` element somewhere. A canvas corresponds to a winit "window". +- Write a Javascript code that creates a global variable named `Module`. Set `Module.canvas` to + the element of the `<canvas>` element (in the example you would retrieve it via `document.getElementById("my_id")`). + More information [here](https://kripken.github.io/emscripten-site/docs/api_reference/module.html). +- Make sure that you insert the `.js` file generated by Rust after the `Module` variable is created. diff --git a/third_party/cargo/vendor/winit-0.18.1/appveyor.yml b/third_party/cargo/vendor/winit-0.18.1/appveyor.yml new file mode 100644 index 0000000..4722a5a --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/appveyor.yml @@ -0,0 +1,24 @@ +environment: + matrix: + - TARGET: x86_64-pc-windows-msvc + CHANNEL: nightly + - TARGET: x86_64-pc-windows-msvc + CHANNEL: stable + - TARGET: i686-pc-windows-msvc + CHANNEL: nightly + - TARGET: i686-pc-windows-gnu + CHANNEL: nightly +install: + - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe + - rustup-init -yv --default-toolchain %CHANNEL% --default-host %TARGET% + - SET PATH=%PATH%;%USERPROFILE%\.cargo\bin + - SET PATH=%PATH%;C:\MinGW\bin + - rustc -V + - cargo -V + +build: false + +test_script: + - cargo test --verbose + - cargo test --features serde --verbose + - cargo test --features icon_loading --verbose diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/cursor.rs b/third_party/cargo/vendor/winit-0.18.1/examples/cursor.rs new file mode 100644 index 0000000..d2df71a --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/cursor.rs @@ -0,0 +1,32 @@ +extern crate winit; + +use winit::{Event, ElementState, MouseCursor, WindowEvent, KeyboardInput, ControlFlow}; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + + let window = winit::WindowBuilder::new().build(&events_loop).unwrap(); + window.set_title("A fantastic window!"); + + let cursors = [MouseCursor::Default, MouseCursor::Crosshair, MouseCursor::Hand, MouseCursor::Arrow, MouseCursor::Move, MouseCursor::Text, MouseCursor::Wait, MouseCursor::Help, MouseCursor::Progress, MouseCursor::NotAllowed, MouseCursor::ContextMenu, MouseCursor::Cell, MouseCursor::VerticalText, MouseCursor::Alias, MouseCursor::Copy, MouseCursor::NoDrop, MouseCursor::Grab, MouseCursor::Grabbing, MouseCursor::AllScroll, MouseCursor::ZoomIn, MouseCursor::ZoomOut, MouseCursor::EResize, MouseCursor::NResize, MouseCursor::NeResize, MouseCursor::NwResize, MouseCursor::SResize, MouseCursor::SeResize, MouseCursor::SwResize, MouseCursor::WResize, MouseCursor::EwResize, MouseCursor::NsResize, MouseCursor::NeswResize, MouseCursor::NwseResize, MouseCursor::ColResize, MouseCursor::RowResize]; + let mut cursor_idx = 0; + + events_loop.run_forever(|event| { + match event { + Event::WindowEvent { event: WindowEvent::KeyboardInput { input: KeyboardInput { state: ElementState::Pressed, .. }, .. }, .. } => { + println!("Setting cursor to \"{:?}\"", cursors[cursor_idx]); + window.set_cursor(cursors[cursor_idx]); + if cursor_idx < cursors.len() - 1 { + cursor_idx += 1; + } else { + cursor_idx = 0; + } + }, + Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => { + return ControlFlow::Break; + }, + _ => () + } + ControlFlow::Continue + }); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/cursor_grab.rs b/third_party/cargo/vendor/winit-0.18.1/examples/cursor_grab.rs new file mode 100644 index 0000000..641a324 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/cursor_grab.rs @@ -0,0 +1,38 @@ +extern crate winit; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + + let window = winit::WindowBuilder::new() + .with_title("Super Cursor Grab'n'Hide Simulator 9000") + .build(&events_loop) + .unwrap(); + + events_loop.run_forever(|event| { + if let winit::Event::WindowEvent { event, .. } = event { + use winit::WindowEvent::*; + match event { + CloseRequested => return winit::ControlFlow::Break, + KeyboardInput { + input: winit::KeyboardInput { + state: winit::ElementState::Released, + virtual_keycode: Some(key), + modifiers, + .. + }, + .. + } => { + use winit::VirtualKeyCode::*; + match key { + Escape => return winit::ControlFlow::Break, + G => window.grab_cursor(!modifiers.shift).unwrap(), + H => window.hide_cursor(!modifiers.shift), + _ => (), + } + } + _ => (), + } + } + winit::ControlFlow::Continue + }); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/fullscreen.rs b/third_party/cargo/vendor/winit-0.18.1/examples/fullscreen.rs new file mode 100644 index 0000000..c29013c --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/fullscreen.rs @@ -0,0 +1,121 @@ +extern crate winit; + +use std::io::{self, Write}; +use winit::{ControlFlow, Event, WindowEvent}; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + + #[cfg(target_os = "macos")] + let mut macos_use_simple_fullscreen = false; + + let monitor = { + // On macOS there are two fullscreen modes "native" and "simple" + #[cfg(target_os = "macos")] + { + print!("Please choose the fullscreen mode: (1) native, (2) simple: "); + io::stdout().flush().unwrap(); + + let mut num = String::new(); + io::stdin().read_line(&mut num).unwrap(); + let num = num.trim().parse().ok().expect("Please enter a number"); + match num { + 2 => macos_use_simple_fullscreen = true, + _ => {} + } + + // Prompt for monitor when using native fullscreen + if !macos_use_simple_fullscreen { + Some(prompt_for_monitor(&events_loop)) + } else { + None + } + } + + #[cfg(not(target_os = "macos"))] + Some(prompt_for_monitor(&events_loop)) + }; + + let mut is_fullscreen = monitor.is_some(); + let mut is_maximized = false; + let mut decorations = true; + + let window = winit::WindowBuilder::new() + .with_title("Hello world!") + .with_fullscreen(monitor) + .build(&events_loop) + .unwrap(); + + events_loop.run_forever(|event| { + println!("{:?}", event); + + match event { + Event::WindowEvent { event, .. } => match event { + WindowEvent::CloseRequested => return ControlFlow::Break, + WindowEvent::KeyboardInput { + input: + winit::KeyboardInput { + virtual_keycode: Some(virtual_code), + state, + .. + }, + .. + } => match (virtual_code, state) { + (winit::VirtualKeyCode::Escape, _) => return ControlFlow::Break, + (winit::VirtualKeyCode::F, winit::ElementState::Pressed) => { + #[cfg(target_os = "macos")] + { + if macos_use_simple_fullscreen { + use winit::os::macos::WindowExt; + if WindowExt::set_simple_fullscreen(&window, !is_fullscreen) { + is_fullscreen = !is_fullscreen; + } + + return ControlFlow::Continue; + } + } + + is_fullscreen = !is_fullscreen; + if !is_fullscreen { + window.set_fullscreen(None); + } else { + window.set_fullscreen(Some(window.get_current_monitor())); + } + } + (winit::VirtualKeyCode::M, winit::ElementState::Pressed) => { + is_maximized = !is_maximized; + window.set_maximized(is_maximized); + } + (winit::VirtualKeyCode::D, winit::ElementState::Pressed) => { + decorations = !decorations; + window.set_decorations(decorations); + } + _ => (), + }, + _ => (), + }, + _ => {} + } + + ControlFlow::Continue + }); +} + +// Enumerate monitors and prompt user to choose one +fn prompt_for_monitor(events_loop: &winit::EventsLoop) -> winit::MonitorId { + for (num, monitor) in events_loop.get_available_monitors().enumerate() { + println!("Monitor #{}: {:?}", num, monitor.get_name()); + } + + print!("Please write the number of the monitor to use: "); + io::stdout().flush().unwrap(); + + let mut num = String::new(); + io::stdin().read_line(&mut num).unwrap(); + let num = num.trim().parse().ok().expect("Please enter a number"); + let monitor = events_loop.get_available_monitors().nth(num).expect("Please enter a valid ID"); + + println!("Using {:?}", monitor.get_name()); + + monitor +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/handling_close.rs b/third_party/cargo/vendor/winit-0.18.1/examples/handling_close.rs new file mode 100644 index 0000000..101f45c --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/handling_close.rs @@ -0,0 +1,74 @@ +extern crate winit; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + + let _window = winit::WindowBuilder::new() + .with_title("Your faithful window") + .build(&events_loop) + .unwrap(); + + let mut close_requested = false; + + events_loop.run_forever(|event| { + use winit::WindowEvent::*; + use winit::ElementState::Released; + use winit::VirtualKeyCode::{N, Y}; + + match event { + winit::Event::WindowEvent { event, .. } => match event { + CloseRequested => { + // `CloseRequested` is sent when the close button on the window is pressed (or + // through whatever other mechanisms the window manager provides for closing a + // window). If you don't handle this event, the close button won't actually do + // anything. + + // A common thing to do here is prompt the user if they have unsaved work. + // Creating a proper dialog box for that is far beyond the scope of this + // example, so here we'll just respond to the Y and N keys. + println!("Are you ready to bid your window farewell? [Y/N]"); + close_requested = true; + + // In applications where you can safely close the window without further + // action from the user, this is generally where you'd handle cleanup before + // closing the window. How to close the window is detailed in the handler for + // the Y key. + } + KeyboardInput { + input: + winit::KeyboardInput { + virtual_keycode: Some(virtual_code), + state: Released, + .. + }, + .. + } => match virtual_code { + Y => { + if close_requested { + // This is where you'll want to do any cleanup you need. + println!("Buh-bye!"); + + // For a single-window application like this, you'd normally just + // break out of the event loop here. If you wanted to keep running the + // event loop (i.e. if it's a multi-window application), you need to + // drop the window. That closes it, and results in `Destroyed` being + // sent. + return winit::ControlFlow::Break; + } + } + N => { + if close_requested { + println!("Your window will continue to stay by your side."); + close_requested = false; + } + } + _ => (), + }, + _ => (), + }, + _ => (), + } + + winit::ControlFlow::Continue + }); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/icon.png b/third_party/cargo/vendor/winit-0.18.1/examples/icon.png new file mode 100644 index 0000000..aa3fbf3 Binary files /dev/null and b/third_party/cargo/vendor/winit-0.18.1/examples/icon.png differ diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/min_max_size.rs b/third_party/cargo/vendor/winit-0.18.1/examples/min_max_size.rs new file mode 100644 index 0000000..06f4aa1 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/min_max_size.rs @@ -0,0 +1,23 @@ +extern crate winit; + +use winit::dpi::LogicalSize; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + + let window = winit::WindowBuilder::new() + .build(&events_loop) + .unwrap(); + + window.set_min_dimensions(Some(LogicalSize::new(400.0, 200.0))); + window.set_max_dimensions(Some(LogicalSize::new(800.0, 400.0))); + + events_loop.run_forever(|event| { + println!("{:?}", event); + + match event { + winit::Event::WindowEvent { event: winit::WindowEvent::CloseRequested, .. } => winit::ControlFlow::Break, + _ => winit::ControlFlow::Continue, + } + }); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/monitor_list.rs b/third_party/cargo/vendor/winit-0.18.1/examples/monitor_list.rs new file mode 100644 index 0000000..e40ac30 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/monitor_list.rs @@ -0,0 +1,7 @@ +extern crate winit; + +fn main() { + let event_loop = winit::EventsLoop::new(); + let window = winit::WindowBuilder::new().build(&event_loop).unwrap(); + println!("{:#?}\nPrimary: {:#?}", window.get_available_monitors(), window.get_primary_monitor()); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/multiwindow.rs b/third_party/cargo/vendor/winit-0.18.1/examples/multiwindow.rs new file mode 100644 index 0000000..b558aa2 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/multiwindow.rs @@ -0,0 +1,33 @@ +extern crate winit; + +use std::collections::HashMap; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + + let mut windows = HashMap::new(); + for _ in 0..3 { + let window = winit::Window::new(&events_loop).unwrap(); + windows.insert(window.id(), window); + } + + events_loop.run_forever(|event| { + match event { + winit::Event::WindowEvent { + event: winit::WindowEvent::CloseRequested, + window_id, + } => { + println!("Window {:?} has received the signal to close", window_id); + + // This drops the window, causing it to close. + windows.remove(&window_id); + + if windows.is_empty() { + return winit::ControlFlow::Break; + } + } + _ => (), + } + winit::ControlFlow::Continue + }) +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/proxy.rs b/third_party/cargo/vendor/winit-0.18.1/examples/proxy.rs new file mode 100644 index 0000000..a975181 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/proxy.rs @@ -0,0 +1,29 @@ +extern crate winit; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + + let _window = winit::WindowBuilder::new() + .with_title("A fantastic window!") + .build(&events_loop) + .unwrap(); + + let proxy = events_loop.create_proxy(); + + std::thread::spawn(move || { + // Wake up the `events_loop` once every second. + loop { + std::thread::sleep(std::time::Duration::from_secs(1)); + proxy.wakeup().unwrap(); + } + }); + + events_loop.run_forever(|event| { + println!("{:?}", event); + match event { + winit::Event::WindowEvent { event: winit::WindowEvent::CloseRequested, .. } => + winit::ControlFlow::Break, + _ => winit::ControlFlow::Continue, + } + }); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/resizable.rs b/third_party/cargo/vendor/winit-0.18.1/examples/resizable.rs new file mode 100644 index 0000000..749e852 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/resizable.rs @@ -0,0 +1,38 @@ +extern crate winit; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + + let mut resizable = false; + + let window = winit::WindowBuilder::new() + .with_title("Hit space to toggle resizability.") + .with_dimensions((400, 200).into()) + .with_resizable(resizable) + .build(&events_loop) + .unwrap(); + + events_loop.run_forever(|event| { + match event { + winit::Event::WindowEvent { event, .. } => match event { + winit::WindowEvent::CloseRequested => return winit::ControlFlow::Break, + winit::WindowEvent::KeyboardInput { + input: + winit::KeyboardInput { + virtual_keycode: Some(winit::VirtualKeyCode::Space), + state: winit::ElementState::Released, + .. + }, + .. + } => { + resizable = !resizable; + println!("Resizable: {}", resizable); + window.set_resizable(resizable); + } + _ => (), + }, + _ => (), + }; + winit::ControlFlow::Continue + }); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/transparent.rs b/third_party/cargo/vendor/winit-0.18.1/examples/transparent.rs new file mode 100644 index 0000000..a558350 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/transparent.rs @@ -0,0 +1,20 @@ +extern crate winit; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + + let window = winit::WindowBuilder::new().with_decorations(false) + .with_transparency(true) + .build(&events_loop).unwrap(); + + window.set_title("A fantastic window!"); + + events_loop.run_forever(|event| { + println!("{:?}", event); + + match event { + winit::Event::WindowEvent { event: winit::WindowEvent::CloseRequested, .. } => winit::ControlFlow::Break, + _ => winit::ControlFlow::Continue, + } + }); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/window.rs b/third_party/cargo/vendor/winit-0.18.1/examples/window.rs new file mode 100644 index 0000000..fcc7d9e --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/window.rs @@ -0,0 +1,22 @@ +extern crate winit; + +fn main() { + let mut events_loop = winit::EventsLoop::new(); + + let _window = winit::WindowBuilder::new() + .with_title("A fantastic window!") + .build(&events_loop) + .unwrap(); + + events_loop.run_forever(|event| { + println!("{:?}", event); + + match event { + winit::Event::WindowEvent { + event: winit::WindowEvent::CloseRequested, + .. + } => winit::ControlFlow::Break, + _ => winit::ControlFlow::Continue, + } + }); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/examples/window_icon.rs b/third_party/cargo/vendor/winit-0.18.1/examples/window_icon.rs new file mode 100644 index 0000000..5be1433 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/examples/window_icon.rs @@ -0,0 +1,94 @@ +// Heads up: you need to compile this example with `--features icon_loading`. +// `Icon::from_path` won't be available otherwise, though for your own applications, you could use +// `Icon::from_rgba` if you don't want to depend on the `image` crate. + +extern crate winit; +#[cfg(feature = "icon_loading")] +extern crate image; + +#[cfg(feature = "icon_loading")] +fn main() { + use winit::Icon; + // You'll have to choose an icon size at your own discretion. On X11, the desired size varies + // by WM, and on Windows, you still have to account for screen scaling. Here we use 32px, + // since it seems to work well enough in most cases. Be careful about going too high, or + // you'll be bitten by the low-quality downscaling built into the WM. + let path = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/icon.png"); + // While `Icon::from_path` is the most straightforward, you have a few other options. If you + // want to use the `include_bytes` macro, then pass the result to `Icon::from_bytes`. See the + // docs for the full list of options (you'll have to generate the docs with the `icon_loading` + // feature enabled). + let icon = Icon::from_path(path).expect("Failed to open icon"); + + let mut events_loop = winit::EventsLoop::new(); + + let window = winit::WindowBuilder::new() + .with_title("An iconic window!") + // At present, this only does anything on Windows and X11, so if you want to save load + // time, you can put icon loading behind a function that returns `None` on other platforms. + .with_window_icon(Some(icon)) + .build(&events_loop) + .unwrap(); + + events_loop.run_forever(|event| { + if let winit::Event::WindowEvent { event, .. } = event { + use winit::WindowEvent::*; + match event { + CloseRequested => return winit::ControlFlow::Break, + DroppedFile(path) => { + use image::GenericImageView; + + let icon_image = image::open(path).expect("Failed to open window icon"); + + let (width, height) = icon_image.dimensions(); + const DESIRED_SIZE: u32 = 32; + let (new_width, new_height) = if width == height { + (DESIRED_SIZE, DESIRED_SIZE) + } else { + // Note that this will never divide by zero, due to the previous condition. + let aspect_adjustment = DESIRED_SIZE as f64 + / std::cmp::max(width, height) as f64; + ( + (width as f64 * aspect_adjustment) as u32, + (height as f64 * aspect_adjustment) as u32, + ) + }; + + // By scaling the icon ourselves, we get higher-quality filtering and save + // some memory. + let icon = image::imageops::resize( + &icon_image, + new_width, + new_height, + image::FilterType::Lanczos3, + ); + + let (offset_x, offset_y) = ( + (DESIRED_SIZE - new_width) / 2, + (DESIRED_SIZE - new_height) / 2, + ); + + let mut canvas = image::ImageBuffer::new(DESIRED_SIZE, DESIRED_SIZE); + image::imageops::replace( + &mut canvas, + &icon, + offset_x, + offset_y, + ); + + window.set_window_icon(Some(canvas.into())); + }, + _ => (), + } + } + winit::ControlFlow::Continue + }); +} + +#[cfg(not(feature = "icon_loading"))] +fn main() { + print!( +r#"This example requires the `icon_loading` feature: + cargo run --example window_icon --features icon_loading +"#); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/dpi.rs b/third_party/cargo/vendor/winit-0.18.1/src/dpi.rs new file mode 100644 index 0000000..0d15142 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/dpi.rs @@ -0,0 +1,331 @@ + +//! DPI is important, so read the docs for this module if you don't want to be confused. +//! +//! Originally, `winit` dealt entirely in physical pixels (excluding unintentional inconsistencies), but now all +//! window-related functions both produce and consume logical pixels. Monitor-related functions still use physical +//! pixels, as do any context-related functions in `glutin`. +//! +//! If you've never heard of these terms before, then you're not alone, and this documentation will explain the +//! concepts. +//! +//! Modern screens have a defined physical resolution, most commonly 1920x1080. Indepedent of that is the amount of +//! space the screen occupies, which is to say, the height and width in millimeters. The relationship between these two +//! measurements is the *pixel density*. Mobile screens require a high pixel density, as they're held close to the +//! eyes. Larger displays also require a higher pixel density, hence the growing presence of 1440p and 4K displays. +//! +//! So, this presents a problem. Let's say we want to render a square 100px button. It will occupy 100x100 of the +//! screen's pixels, which in many cases, seems perfectly fine. However, because this size doesn't account for the +//! screen's dimensions or pixel density, the button's size can vary quite a bit. On a 4K display, it would be unusably +//! small. +//! +//! That's a description of what happens when the button is 100x100 *physical* pixels. Instead, let's try using 100x100 +//! *logical* pixels. To map logical pixels to physical pixels, we simply multiply by the DPI (dots per inch) factor. +//! On a "typical" desktop display, the DPI factor will be 1.0, so 100x100 logical pixels equates to 100x100 physical +//! pixels. However, a 1440p display may have a DPI factor of 1.25, so the button is rendered as 125x125 physical pixels. +//! Ideally, the button now has approximately the same perceived size across varying displays. +//! +//! Failure to account for the DPI factor can create a badly degraded user experience. Most notably, it can make users +//! feel like they have bad eyesight, which will potentially cause them to think about growing elderly, resulting in +//! them entering an existential panic. Once users enter that state, they will no longer be focused on your application. +//! +//! There are two ways to get the DPI factor: +//! - You can track the [`HiDpiFactorChanged`](../enum.WindowEvent.html#variant.HiDpiFactorChanged) event of your +//! windows. This event is sent any time the DPI factor changes, either because the window moved to another monitor, +//! or because the user changed the configuration of their screen. +//! - You can also retrieve the DPI factor of a monitor by calling +//! [`MonitorId::get_hidpi_factor`](../struct.MonitorId.html#method.get_hidpi_factor), or the +//! current DPI factor applied to a window by calling +//! [`Window::get_hidpi_factor`](../struct.Window.html#method.get_hidpi_factor), which is roughly equivalent +//! to `window.get_current_monitor().get_hidpi_factor()`. +//! +//! Depending on the platform, the window's actual DPI factor may only be known after +//! the event loop has started and your window has been drawn once. To properly handle these cases, +//! the most robust way is to monitor the [`HiDpiFactorChanged`](../enum.WindowEvent.html#variant.HiDpiFactorChanged) +//! event and dynamically adapt your drawing logic to follow the DPI factor. +//! +//! Here's an overview of what sort of DPI factors you can expect, and where they come from: +//! - **Windows:** On Windows 8 and 10, per-monitor scaling is readily configured by users from the display settings. +//! While users are free to select any option they want, they're only given a selection of "nice" DPI factors, i.e. +//! 1.0, 1.25, 1.5... on Windows 7, the DPI factor is global and changing it requires logging out. +//! - **macOS:** The buzzword is "retina displays", which have a DPI factor of 2.0. Otherwise, the DPI factor is 1.0. +//! Intermediate DPI factors are never used, thus 1440p displays/etc. aren't properly supported. It's possible for any +//! display to use that 2.0 DPI factor, given the use of the command line. +//! - **X11:** On X11, we calcuate the DPI factor based on the millimeter dimensions provided by XRandR. This can +//! result in a wide range of possible values, including some interesting ones like 1.0833333333333333. This can be +//! overridden using the `WINIT_HIDPI_FACTOR` environment variable, though that's not recommended. +//! - **Wayland:** On Wayland, DPI factors are set per-screen by the server, and are always integers (most often 1 or 2). +//! - **iOS:** DPI factors are both constant and device-specific on iOS. +//! - **Android:** This feature isn't yet implemented on Android, so the DPI factor will always be returned as 1.0. +//! +//! The window's logical size is conserved across DPI changes, resulting in the physical size changing instead. This +//! may be surprising on X11, but is quite standard elsewhere. Physical size changes always produce a +//! [`Resized`](../enum.WindowEvent.html#variant.Resized) event, even on platforms where no resize actually occurs, +//! such as macOS and Wayland. As a result, it's not necessary to separately handle +//! [`HiDpiFactorChanged`](../enum.WindowEvent.html#variant.HiDpiFactorChanged) if you're only listening for size. +//! +//! Your GPU has no awareness of the concept of logical pixels, and unless you like wasting pixel density, your +//! framebuffer's size should be in physical pixels. +//! +//! `winit` will send [`Resized`](../enum.WindowEvent.html#variant.Resized) events whenever a window's logical size +//! changes, and [`HiDpiFactorChanged`](../enum.WindowEvent.html#variant.HiDpiFactorChanged) events +//! whenever the DPI factor changes. Receiving either of these events means that the physical size of your window has +//! changed, and you should recompute it using the latest values you received for each. If the logical size and the +//! DPI factor change simultaneously, `winit` will send both events together; thus, it's recommended to buffer +//! these events and process them at the end of the queue. +//! +//! If you never received any [`HiDpiFactorChanged`](../enum.WindowEvent.html#variant.HiDpiFactorChanged) events, +//! then your window's DPI factor is 1. + +/// Checks that the DPI factor is a normal positive `f64`. +/// +/// All functions that take a DPI factor assert that this will return `true`. If you're sourcing DPI factors from +/// anywhere other than winit, it's recommended to validate them using this function before passing them to winit; +/// otherwise, you risk panics. +#[inline] +pub fn validate_hidpi_factor(dpi_factor: f64) -> bool { + dpi_factor.is_sign_positive() && dpi_factor.is_normal() +} + +/// A position represented in logical pixels. +/// +/// The position is stored as floats, so please be careful. Casting floats to integers truncates the fractional part, +/// which can cause noticable issues. To help with that, an `Into<(i32, i32)>` implementation is provided which +/// does the rounding for you. +#[derive(Debug, Copy, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub struct LogicalPosition { + pub x: f64, + pub y: f64, +} + +impl LogicalPosition { + #[inline] + pub fn new(x: f64, y: f64) -> Self { + LogicalPosition { x, y } + } + + #[inline] + pub fn from_physical<T: Into<PhysicalPosition>>(physical: T, dpi_factor: f64) -> Self { + physical.into().to_logical(dpi_factor) + } + + #[inline] + pub fn to_physical(&self, dpi_factor: f64) -> PhysicalPosition { + assert!(validate_hidpi_factor(dpi_factor)); + let x = self.x * dpi_factor; + let y = self.y * dpi_factor; + PhysicalPosition::new(x, y) + } +} + +impl From<(f64, f64)> for LogicalPosition { + #[inline] + fn from((x, y): (f64, f64)) -> Self { + Self::new(x, y) + } +} + +impl From<(i32, i32)> for LogicalPosition { + #[inline] + fn from((x, y): (i32, i32)) -> Self { + Self::new(x as f64, y as f64) + } +} + +impl Into<(f64, f64)> for LogicalPosition { + #[inline] + fn into(self) -> (f64, f64) { + (self.x, self.y) + } +} + +impl Into<(i32, i32)> for LogicalPosition { + /// Note that this rounds instead of truncating. + #[inline] + fn into(self) -> (i32, i32) { + (self.x.round() as _, self.y.round() as _) + } +} + +/// A position represented in physical pixels. +/// +/// The position is stored as floats, so please be careful. Casting floats to integers truncates the fractional part, +/// which can cause noticable issues. To help with that, an `Into<(i32, i32)>` implementation is provided which +/// does the rounding for you. +#[derive(Debug, Copy, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub struct PhysicalPosition { + pub x: f64, + pub y: f64, +} + +impl PhysicalPosition { + #[inline] + pub fn new(x: f64, y: f64) -> Self { + PhysicalPosition { x, y } + } + + #[inline] + pub fn from_logical<T: Into<LogicalPosition>>(logical: T, dpi_factor: f64) -> Self { + logical.into().to_physical(dpi_factor) + } + + #[inline] + pub fn to_logical(&self, dpi_factor: f64) -> LogicalPosition { + assert!(validate_hidpi_factor(dpi_factor)); + let x = self.x / dpi_factor; + let y = self.y / dpi_factor; + LogicalPosition::new(x, y) + } +} + +impl From<(f64, f64)> for PhysicalPosition { + #[inline] + fn from((x, y): (f64, f64)) -> Self { + Self::new(x, y) + } +} + +impl From<(i32, i32)> for PhysicalPosition { + #[inline] + fn from((x, y): (i32, i32)) -> Self { + Self::new(x as f64, y as f64) + } +} + +impl Into<(f64, f64)> for PhysicalPosition { + #[inline] + fn into(self) -> (f64, f64) { + (self.x, self.y) + } +} + +impl Into<(i32, i32)> for PhysicalPosition { + /// Note that this rounds instead of truncating. + #[inline] + fn into(self) -> (i32, i32) { + (self.x.round() as _, self.y.round() as _) + } +} + +/// A size represented in logical pixels. +/// +/// The size is stored as floats, so please be careful. Casting floats to integers truncates the fractional part, +/// which can cause noticable issues. To help with that, an `Into<(u32, u32)>` implementation is provided which +/// does the rounding for you. +#[derive(Debug, Copy, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub struct LogicalSize { + pub width: f64, + pub height: f64, +} + +impl LogicalSize { + #[inline] + pub fn new(width: f64, height: f64) -> Self { + LogicalSize { width, height } + } + + #[inline] + pub fn from_physical<T: Into<PhysicalSize>>(physical: T, dpi_factor: f64) -> Self { + physical.into().to_logical(dpi_factor) + } + + #[inline] + pub fn to_physical(&self, dpi_factor: f64) -> PhysicalSize { + assert!(validate_hidpi_factor(dpi_factor)); + let width = self.width * dpi_factor; + let height = self.height * dpi_factor; + PhysicalSize::new(width, height) + } +} + +impl From<(f64, f64)> for LogicalSize { + #[inline] + fn from((width, height): (f64, f64)) -> Self { + Self::new(width, height) + } +} + +impl From<(u32, u32)> for LogicalSize { + #[inline] + fn from((width, height): (u32, u32)) -> Self { + Self::new(width as f64, height as f64) + } +} + +impl Into<(f64, f64)> for LogicalSize { + #[inline] + fn into(self) -> (f64, f64) { + (self.width, self.height) + } +} + +impl Into<(u32, u32)> for LogicalSize { + /// Note that this rounds instead of truncating. + #[inline] + fn into(self) -> (u32, u32) { + (self.width.round() as _, self.height.round() as _) + } +} + +/// A size represented in physical pixels. +/// +/// The size is stored as floats, so please be careful. Casting floats to integers truncates the fractional part, +/// which can cause noticable issues. To help with that, an `Into<(u32, u32)>` implementation is provided which +/// does the rounding for you. +#[derive(Debug, Copy, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub struct PhysicalSize { + pub width: f64, + pub height: f64, +} + +impl PhysicalSize { + #[inline] + pub fn new(width: f64, height: f64) -> Self { + PhysicalSize { width, height } + } + + #[inline] + pub fn from_logical<T: Into<LogicalSize>>(logical: T, dpi_factor: f64) -> Self { + logical.into().to_physical(dpi_factor) + } + + #[inline] + pub fn to_logical(&self, dpi_factor: f64) -> LogicalSize { + assert!(validate_hidpi_factor(dpi_factor)); + let width = self.width / dpi_factor; + let height = self.height / dpi_factor; + LogicalSize::new(width, height) + } +} + +impl From<(f64, f64)> for PhysicalSize { + #[inline] + fn from((width, height): (f64, f64)) -> Self { + Self::new(width, height) + } +} + +impl From<(u32, u32)> for PhysicalSize { + #[inline] + fn from((width, height): (u32, u32)) -> Self { + Self::new(width as f64, height as f64) + } +} + +impl Into<(f64, f64)> for PhysicalSize { + #[inline] + fn into(self) -> (f64, f64) { + (self.width, self.height) + } +} + +impl Into<(u32, u32)> for PhysicalSize { + /// Note that this rounds instead of truncating. + #[inline] + fn into(self) -> (u32, u32) { + (self.width.round() as _, self.height.round() as _) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/events.rs b/third_party/cargo/vendor/winit-0.18.1/src/events.rs new file mode 100644 index 0000000..69a8ec7 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/events.rs @@ -0,0 +1,480 @@ +use std::path::PathBuf; + +use {DeviceId, LogicalPosition, LogicalSize, WindowId}; + +/// Describes a generic event. +#[derive(Clone, Debug, PartialEq)] +pub enum Event { + WindowEvent { + window_id: WindowId, + event: WindowEvent, + }, + DeviceEvent { + device_id: DeviceId, + event: DeviceEvent, + }, + Awakened, + + /// The application has been suspended or resumed. + /// + /// The parameter is true if app was suspended, and false if it has been resumed. + Suspended(bool), +} + +/// Describes an event from a `Window`. +#[derive(Clone, Debug, PartialEq)] +pub enum WindowEvent { + /// The size of the window has changed. Contains the client area's new dimensions. + Resized(LogicalSize), + + /// The position of the window has changed. Contains the window's new position. + Moved(LogicalPosition), + + /// The window has been requested to close. + CloseRequested, + + /// The window has been destroyed. + Destroyed, + + /// A file has been dropped into the window. + /// + /// When the user drops multiple files at once, this event will be emitted for each file + /// separately. + DroppedFile(PathBuf), + + /// A file is being hovered over the window. + /// + /// When the user hovers multiple files at once, this event will be emitted for each file + /// separately. + HoveredFile(PathBuf), + + /// A file was hovered, but has exited the window. + /// + /// There will be a single `HoveredFileCancelled` event triggered even if multiple files were + /// hovered. + HoveredFileCancelled, + + /// The window received a unicode character. + ReceivedCharacter(char), + + /// The window gained or lost focus. + /// + /// The parameter is true if the window has gained focus, and false if it has lost focus. + Focused(bool), + + /// An event from the keyboard has been received. + KeyboardInput { device_id: DeviceId, input: KeyboardInput }, + + /// The cursor has moved on the window. + CursorMoved { + device_id: DeviceId, + + /// (x,y) coords in pixels relative to the top-left corner of the window. Because the range of this data is + /// limited by the display area and it may have been transformed by the OS to implement effects such as cursor + /// acceleration, it should not be used to implement non-cursor-like interactions such as 3D camera control. + position: LogicalPosition, + modifiers: ModifiersState + }, + + /// The cursor has entered the window. + CursorEntered { device_id: DeviceId }, + + /// The cursor has left the window. + CursorLeft { device_id: DeviceId }, + + /// A mouse wheel movement or touchpad scroll occurred. + MouseWheel { device_id: DeviceId, delta: MouseScrollDelta, phase: TouchPhase, modifiers: ModifiersState }, + + /// An mouse button press has been received. + MouseInput { device_id: DeviceId, state: ElementState, button: MouseButton, modifiers: ModifiersState }, + + + /// Touchpad pressure event. + /// + /// At the moment, only supported on Apple forcetouch-capable macbooks. + /// The parameters are: pressure level (value between 0 and 1 representing how hard the touchpad + /// is being pressed) and stage (integer representing the click level). + TouchpadPressure { device_id: DeviceId, pressure: f32, stage: i64 }, + + /// Motion on some analog axis. May report data redundant to other, more specific events. + AxisMotion { device_id: DeviceId, axis: AxisId, value: f64 }, + + /// The window needs to be redrawn. + Refresh, + + /// Touch event has been received + Touch(Touch), + + /// The DPI factor of the window has changed. + /// + /// The following user actions can cause DPI changes: + /// + /// * Changing the display's resolution. + /// * Changing the display's DPI factor (e.g. in Control Panel on Windows). + /// * Moving the window to a display with a different DPI factor. + /// + /// For more information about DPI in general, see the [`dpi`](dpi/index.html) module. + HiDpiFactorChanged(f64), +} + +/// Represents raw hardware events that are not associated with any particular window. +/// +/// Useful for interactions that diverge significantly from a conventional 2D GUI, such as 3D camera or first-person +/// game controls. Many physical actions, such as mouse movement, can produce both device and window events. Because +/// window events typically arise from virtual devices (corresponding to GUI cursors and keyboard focus) the device IDs +/// may not match. +/// +/// Note that these events are delivered regardless of input focus. +#[derive(Clone, Debug, PartialEq)] +pub enum DeviceEvent { + Added, + Removed, + + /// Change in physical position of a pointing device. + /// + /// This represents raw, unfiltered physical motion. Not to be confused with `WindowEvent::CursorMoved`. + MouseMotion { + /// (x, y) change in position in unspecified units. + /// + /// Different devices may use different units. + delta: (f64, f64), + }, + + /// Physical scroll event + MouseWheel { + delta: MouseScrollDelta, + }, + + /// Motion on some analog axis. This event will be reported for all arbitrary input devices + /// that winit supports on this platform, including mouse devices. If the device is a mouse + /// device then this will be reported alongside the MouseMotion event. + Motion { axis: AxisId, value: f64 }, + + Button { button: ButtonId, state: ElementState }, + Key(KeyboardInput), + Text { codepoint: char }, +} + +/// Describes a keyboard input event. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub struct KeyboardInput { + /// Identifies the physical key pressed + /// + /// This should not change if the user adjusts the host's keyboard map. Use when the physical location of the + /// key is more important than the key's host GUI semantics, such as for movement controls in a first-person + /// game. + pub scancode: ScanCode, + + pub state: ElementState, + + /// Identifies the semantic meaning of the key + /// + /// Use when the semantics of the key are more important than the physical location of the key, such as when + /// implementing appropriate behavior for "page up." + pub virtual_keycode: Option<VirtualKeyCode>, + + /// Modifier keys active at the time of this input. + /// + /// This is tracked internally to avoid tracking errors arising from modifier key state changes when events from + /// this device are not being delivered to the application, e.g. due to keyboard focus being elsewhere. + pub modifiers: ModifiersState +} + +/// Describes touch-screen input state. +#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum TouchPhase { + Started, + Moved, + Ended, + Cancelled +} + +/// Represents touch event +/// +/// Every time user touches screen new Start event with some finger id is generated. +/// When the finger is removed from the screen End event with same id is generated. +/// +/// For every id there will be at least 2 events with phases Start and End (or Cancelled). +/// There may be 0 or more Move events. +/// +/// +/// Depending on platform implementation id may or may not be reused by system after End event. +/// +/// Gesture regonizer using this event should assume that Start event received with same id +/// as previously received End event is a new finger and has nothing to do with an old one. +/// +/// Touch may be cancelled if for example window lost focus. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Touch { + pub device_id: DeviceId, + pub phase: TouchPhase, + pub location: LogicalPosition, + /// unique identifier of a finger. + pub id: u64 +} + +/// Hardware-dependent keyboard scan code. +pub type ScanCode = u32; + +/// Identifier for a specific analog axis on some device. +pub type AxisId = u32; + +/// Identifier for a specific button on some device. +pub type ButtonId = u32; + +/// Describes the input state of a key. +#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum ElementState { + Pressed, + Released, +} + +/// Describes a button of a mouse controller. +#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum MouseButton { + Left, + Right, + Middle, + Other(u8), +} + +/// Describes a difference in the mouse scroll wheel state. +#[derive(Debug, Clone, Copy, PartialEq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum MouseScrollDelta { + /// Amount in lines or rows to scroll in the horizontal + /// and vertical directions. + /// + /// Positive values indicate movement forward + /// (away from the user) or rightwards. + LineDelta(f32, f32), + /// Amount in pixels to scroll in the horizontal and + /// vertical direction. + /// + /// Scroll events are expressed as a PixelDelta if + /// supported by the device (eg. a touchpad) and + /// platform. + PixelDelta(LogicalPosition), +} + +/// Symbolic name for a keyboard key. +#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy)] +#[repr(u32)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum VirtualKeyCode { + /// The '1' key over the letters. + Key1, + /// The '2' key over the letters. + Key2, + /// The '3' key over the letters. + Key3, + /// The '4' key over the letters. + Key4, + /// The '5' key over the letters. + Key5, + /// The '6' key over the letters. + Key6, + /// The '7' key over the letters. + Key7, + /// The '8' key over the letters. + Key8, + /// The '9' key over the letters. + Key9, + /// The '0' key over the 'O' and 'P' keys. + Key0, + + A, + B, + C, + D, + E, + F, + G, + H, + I, + J, + K, + L, + M, + N, + O, + P, + Q, + R, + S, + T, + U, + V, + W, + X, + Y, + Z, + + /// The Escape key, next to F1. + Escape, + + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + F16, + F17, + F18, + F19, + F20, + F21, + F22, + F23, + F24, + + /// Print Screen/SysRq. + Snapshot, + /// Scroll Lock. + Scroll, + /// Pause/Break key, next to Scroll lock. + Pause, + + /// `Insert`, next to Backspace. + Insert, + Home, + Delete, + End, + PageDown, + PageUp, + + Left, + Up, + Right, + Down, + + /// The Backspace key, right over Enter. + // TODO: rename + Back, + /// The Enter key. + Return, + /// The space bar. + Space, + + /// The "Compose" key on Linux. + Compose, + + Caret, + + Numlock, + Numpad0, + Numpad1, + Numpad2, + Numpad3, + Numpad4, + Numpad5, + Numpad6, + Numpad7, + Numpad8, + Numpad9, + + AbntC1, + AbntC2, + Add, + Apostrophe, + Apps, + At, + Ax, + Backslash, + Calculator, + Capital, + Colon, + Comma, + Convert, + Decimal, + Divide, + Equals, + Grave, + Kana, + Kanji, + LAlt, + LBracket, + LControl, + LShift, + LWin, + Mail, + MediaSelect, + MediaStop, + Minus, + Multiply, + Mute, + MyComputer, + NavigateForward, // also called "Prior" + NavigateBackward, // also called "Next" + NextTrack, + NoConvert, + NumpadComma, + NumpadEnter, + NumpadEquals, + OEM102, + Period, + PlayPause, + Power, + PrevTrack, + RAlt, + RBracket, + RControl, + RShift, + RWin, + Semicolon, + Slash, + Sleep, + Stop, + Subtract, + Sysrq, + Tab, + Underline, + Unlabeled, + VolumeDown, + VolumeUp, + Wake, + WebBack, + WebFavorites, + WebForward, + WebHome, + WebRefresh, + WebSearch, + WebStop, + Yen, + Copy, + Paste, + Cut, +} + +/// Represents the current state of the keyboard modifiers +/// +/// Each field of this struct represents a modifier and is `true` if this modifier is active. +#[derive(Default, Debug, Hash, PartialEq, Eq, Clone, Copy)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", serde(default))] +pub struct ModifiersState { + /// The "shift" key + pub shift: bool, + /// The "control" key + pub ctrl: bool, + /// The "alt" key + pub alt: bool, + /// The "logo" key + /// + /// This is the "windows" key on PC and "command" key on Mac. + pub logo: bool +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/icon.rs b/third_party/cargo/vendor/winit-0.18.1/src/icon.rs new file mode 100644 index 0000000..404fc29 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/icon.rs @@ -0,0 +1,170 @@ +use std::{fmt, mem}; +use std::error::Error; +#[cfg(feature = "icon_loading")] +use std::io::{BufRead, Seek}; +#[cfg(feature = "icon_loading")] +use std::path::Path; + +#[cfg(feature = "icon_loading")] +use image; + +#[repr(C)] +#[derive(Debug)] +pub(crate) struct Pixel { + pub(crate) r: u8, + pub(crate) g: u8, + pub(crate) b: u8, + pub(crate) a: u8, +} + +pub(crate) const PIXEL_SIZE: usize = mem::size_of::<Pixel>(); + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +/// An error produced when using `Icon::from_rgba` with invalid arguments. +pub enum BadIcon { + /// Produced when the length of the `rgba` argument isn't divisible by 4, thus `rgba` can't be + /// safely interpreted as 32bpp RGBA pixels. + ByteCountNotDivisibleBy4 { + byte_count: usize, + }, + /// Produced when the number of pixels (`rgba.len() / 4`) isn't equal to `width * height`. + /// At least one of your arguments is incorrect. + DimensionsVsPixelCount { + width: u32, + height: u32, + width_x_height: usize, + pixel_count: usize, + }, +} + +impl fmt::Display for BadIcon { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let msg = match self { + &BadIcon::ByteCountNotDivisibleBy4 { byte_count } => format!( + "The length of the `rgba` argument ({:?}) isn't divisible by 4, making it impossible to interpret as 32bpp RGBA pixels.", + byte_count, + ), + &BadIcon::DimensionsVsPixelCount { + width, + height, + width_x_height, + pixel_count, + } => format!( + "The specified dimensions ({:?}x{:?}) don't match the number of pixels supplied by the `rgba` argument ({:?}). For those dimensions, the expected pixel count is {:?}.", + width, height, pixel_count, width_x_height, + ), + }; + write!(formatter, "{}", msg) + } +} + +impl Error for BadIcon { + fn description(&self) -> &str { + "A valid icon cannot be created from these arguments" + } + + fn cause(&self) -> Option<&Error> { + Some(self) + } +} + +#[derive(Debug, Clone, PartialEq, Eq)] +/// An icon used for the window titlebar, taskbar, etc. +/// +/// Enabling the `icon_loading` feature provides you with several convenience methods for creating +/// an `Icon` from any format supported by the [image](https://github.com/PistonDevelopers/image) +/// crate. +pub struct Icon { + pub(crate) rgba: Vec<u8>, + pub(crate) width: u32, + pub(crate) height: u32, +} + +impl Icon { + /// Creates an `Icon` from 32bpp RGBA data. + /// + /// The length of `rgba` must be divisible by 4, and `width * height` must equal + /// `rgba.len() / 4`. Otherwise, this will return a `BadIcon` error. + pub fn from_rgba(rgba: Vec<u8>, width: u32, height: u32) -> Result<Self, BadIcon> { + if rgba.len() % PIXEL_SIZE != 0 { + return Err(BadIcon::ByteCountNotDivisibleBy4 { byte_count: rgba.len() }); + } + let pixel_count = rgba.len() / PIXEL_SIZE; + if pixel_count != (width * height) as usize { + Err(BadIcon::DimensionsVsPixelCount { + width, + height, + width_x_height: (width * height) as usize, + pixel_count, + }) + } else { + Ok(Icon { rgba, width, height }) + } + } + + #[cfg(feature = "icon_loading")] + /// Loads an `Icon` from the path of an image on the filesystem. + /// + /// Requires the `icon_loading` feature. + pub fn from_path<P: AsRef<Path>>(path: P) -> image::ImageResult<Self> { + image::open(path).map(Into::into) + } + + #[cfg(feature = "icon_loading")] + /// Loads an `Icon` from anything implementing `BufRead` and `Seek`. + /// + /// Requires the `icon_loading` feature. + pub fn from_reader<R: BufRead + Seek>( + reader: R, + format: image::ImageFormat, + ) -> image::ImageResult<Self> { + image::load(reader, format).map(Into::into) + } + + #[cfg(feature = "icon_loading")] + /// Loads an `Icon` from the unprocessed bytes of an image file. + /// Uses heuristics to determine format. + /// + /// Requires the `icon_loading` feature. + pub fn from_bytes(bytes: &[u8]) -> image::ImageResult<Self> { + image::load_from_memory(bytes).map(Into::into) + } + + #[cfg(feature = "icon_loading")] + /// Loads an `Icon` from the unprocessed bytes of an image. + /// + /// Requires the `icon_loading` feature. + pub fn from_bytes_with_format( + bytes: &[u8], + format: image::ImageFormat, + ) -> image::ImageResult<Self> { + image::load_from_memory_with_format(bytes, format).map(Into::into) + } +} + +#[cfg(feature = "icon_loading")] +/// Requires the `icon_loading` feature. +impl From<image::DynamicImage> for Icon { + fn from(image: image::DynamicImage) -> Self { + use image::{GenericImageView, Pixel}; + let (width, height) = image.dimensions(); + let mut rgba = Vec::with_capacity((width * height) as usize * PIXEL_SIZE); + for (_, _, pixel) in image.pixels() { + rgba.extend_from_slice(&pixel.to_rgba().data); + } + Icon { rgba, width, height } + } +} + +#[cfg(feature = "icon_loading")] +/// Requires the `icon_loading` feature. +impl From<image::RgbaImage> for Icon { + fn from(buf: image::RgbaImage) -> Self { + let (width, height) = buf.dimensions(); + let mut rgba = Vec::with_capacity((width * height) as usize * PIXEL_SIZE); + for (_, _, pixel) in buf.enumerate_pixels() { + rgba.extend_from_slice(&pixel.data); + } + Icon { rgba, width, height } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/lib.rs b/third_party/cargo/vendor/winit-0.18.1/src/lib.rs new file mode 100644 index 0000000..ece7d35 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/lib.rs @@ -0,0 +1,539 @@ +//! Winit allows you to build a window on as many platforms as possible. +//! +//! # Building a window +//! +//! Before you can build a window, you first need to build an `EventsLoop`. This is done with the +//! `EventsLoop::new()` function. Example: +//! +//! ```no_run +//! use winit::EventsLoop; +//! let events_loop = EventsLoop::new(); +//! ``` +//! +//! Once this is done there are two ways to create a window: +//! +//! - Calling `Window::new(&events_loop)`. +//! - Calling `let builder = WindowBuilder::new()` then `builder.build(&events_loop)`. +//! +//! The first way is the simplest way and will give you default values for everything. +//! +//! The second way allows you to customize the way your window will look and behave by modifying +//! the fields of the `WindowBuilder` object before you create the window. +//! +//! # Events handling +//! +//! Once a window has been created, it will *generate events*. For example whenever the user moves +//! the window, resizes the window, moves the mouse, etc. an event is generated. +//! +//! The events generated by a window can be retrieved from the `EventsLoop` the window was created +//! with. +//! +//! There are two ways to do so. The first is to call `events_loop.poll_events(...)`, which will +//! retrieve all the events pending on the windows and immediately return after no new event is +//! available. You usually want to use this method in application that render continuously on the +//! screen, such as video games. +//! +//! ```no_run +//! use winit::{Event, WindowEvent}; +//! use winit::dpi::LogicalSize; +//! # use winit::EventsLoop; +//! # let mut events_loop = EventsLoop::new(); +//! +//! loop { +//! events_loop.poll_events(|event| { +//! match event { +//! Event::WindowEvent { +//! event: WindowEvent::Resized(LogicalSize { width, height }), +//! .. +//! } => { +//! println!("The window was resized to {}x{}", width, height); +//! }, +//! _ => () +//! } +//! }); +//! } +//! ``` +//! +//! The second way is to call `events_loop.run_forever(...)`. As its name tells, it will run +//! forever unless it is stopped by returning `ControlFlow::Break`. +//! +//! ```no_run +//! use winit::{ControlFlow, Event, WindowEvent}; +//! # use winit::EventsLoop; +//! # let mut events_loop = EventsLoop::new(); +//! +//! events_loop.run_forever(|event| { +//! match event { +//! Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => { +//! println!("The close button was pressed; stopping"); +//! ControlFlow::Break +//! }, +//! _ => ControlFlow::Continue, +//! } +//! }); +//! ``` +//! +//! If you use multiple windows, the `WindowEvent` event has a member named `window_id`. You can +//! compare it with the value returned by the `id()` method of `Window` in order to know which +//! window has received the event. +//! +//! # Drawing on the window +//! +//! Winit doesn't provide any function that allows drawing on a window. However it allows you to +//! retrieve the raw handle of the window (see the `os` module for that), which in turn allows you +//! to create an OpenGL/Vulkan/DirectX/Metal/etc. context that will draw on the window. +//! + +#[allow(unused_imports)] +#[macro_use] +extern crate lazy_static; +extern crate libc; +#[macro_use] +extern crate log; +#[cfg(feature = "icon_loading")] +extern crate image; +#[cfg(feature = "serde")] +#[macro_use] +extern crate serde; + +#[cfg(target_os = "windows")] +extern crate winapi; +#[cfg(target_os = "windows")] +extern crate backtrace; +#[cfg(any(target_os = "macos", target_os = "ios"))] +#[macro_use] +extern crate objc; +#[cfg(target_os = "macos")] +extern crate cocoa; +#[cfg(target_os = "macos")] +extern crate core_foundation; +#[cfg(target_os = "macos")] +extern crate core_graphics; +#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] +extern crate x11_dl; +#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] +extern crate parking_lot; +#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] +extern crate percent_encoding; +#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] +extern crate smithay_client_toolkit as sctk; + +pub(crate) use dpi::*; // TODO: Actually change the imports throughout the codebase. +pub use events::*; +pub use window::{AvailableMonitorsIter, MonitorId}; +pub use icon::*; + +pub mod dpi; +mod events; +mod icon; +mod platform; +mod window; + +pub mod os; + +/// Represents a window. +/// +/// # Example +/// +/// ```no_run +/// use winit::{Event, EventsLoop, Window, WindowEvent, ControlFlow}; +/// +/// let mut events_loop = EventsLoop::new(); +/// let window = Window::new(&events_loop).unwrap(); +/// +/// events_loop.run_forever(|event| { +/// match event { +/// Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => { +/// ControlFlow::Break +/// }, +/// _ => ControlFlow::Continue, +/// } +/// }); +/// ``` +pub struct Window { + window: platform::Window, +} + +impl std::fmt::Debug for Window { + fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result { + fmtr.pad("Window { .. }") + } +} + +/// Identifier of a window. Unique for each window. +/// +/// Can be obtained with `window.id()`. +/// +/// Whenever you receive an event specific to a window, this event contains a `WindowId` which you +/// can then compare to the ids of your windows. +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct WindowId(platform::WindowId); + +impl WindowId { + /// Returns a dummy `WindowId`, useful for unit testing. The only guarantee made about the return + /// value of this function is that it will always be equal to itself and to future values returned + /// by this function. No other guarantees are made. This may be equal to a real `WindowId`. + /// + /// **Passing this into a winit function will result in undefined behavior.** + pub unsafe fn dummy() -> Self { + WindowId(platform::WindowId::dummy()) + } +} + +/// Identifier of an input device. +/// +/// Whenever you receive an event arising from a particular input device, this event contains a `DeviceId` which +/// identifies its origin. Note that devices may be virtual (representing an on-screen cursor and keyboard focus) or +/// physical. Virtual devices typically aggregate inputs from multiple physical devices. +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct DeviceId(platform::DeviceId); + +impl DeviceId { + /// Returns a dummy `DeviceId`, useful for unit testing. The only guarantee made about the return + /// value of this function is that it will always be equal to itself and to future values returned + /// by this function. No other guarantees are made. This may be equal to a real `DeviceId`. + /// + /// **Passing this into a winit function will result in undefined behavior.** + pub unsafe fn dummy() -> Self { + DeviceId(platform::DeviceId::dummy()) + } +} + +/// Provides a way to retrieve events from the system and from the windows that were registered to +/// the events loop. +/// +/// An `EventsLoop` can be seen more or less as a "context". Calling `EventsLoop::new()` +/// initializes everything that will be required to create windows. For example on Linux creating +/// an events loop opens a connection to the X or Wayland server. +/// +/// To wake up an `EventsLoop` from a another thread, see the `EventsLoopProxy` docs. +/// +/// Note that the `EventsLoop` cannot be shared accross threads (due to platform-dependant logic +/// forbiding it), as such it is neither `Send` nor `Sync`. If you need cross-thread access, the +/// `Window` created from this `EventsLoop` _can_ be sent to an other thread, and the +/// `EventsLoopProxy` allows you to wakeup an `EventsLoop` from an other thread. +pub struct EventsLoop { + events_loop: platform::EventsLoop, + _marker: ::std::marker::PhantomData<*mut ()> // Not Send nor Sync +} + +impl std::fmt::Debug for EventsLoop { + fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result { + fmtr.pad("EventsLoop { .. }") + } +} + +/// Returned by the user callback given to the `EventsLoop::run_forever` method. +/// +/// Indicates whether the `run_forever` method should continue or complete. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum ControlFlow { + /// Continue looping and waiting for events. + Continue, + /// Break from the event loop. + Break, +} + +impl EventsLoop { + /// Builds a new events loop. + /// + /// Usage will result in display backend initialisation, this can be controlled on linux + /// using an environment variable `WINIT_UNIX_BACKEND`. Legal values are `x11` and `wayland`. + /// If it is not set, winit will try to connect to a wayland connection, and if it fails will + /// fallback on x11. If this variable is set with any other value, winit will panic. + pub fn new() -> EventsLoop { + EventsLoop { + events_loop: platform::EventsLoop::new(), + _marker: ::std::marker::PhantomData, + } + } + + /// Returns the list of all the monitors available on the system. + /// + // Note: should be replaced with `-> impl Iterator` once stable. + #[inline] + pub fn get_available_monitors(&self) -> AvailableMonitorsIter { + let data = self.events_loop.get_available_monitors(); + AvailableMonitorsIter{ data: data.into_iter() } + } + + /// Returns the primary monitor of the system. + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + MonitorId { inner: self.events_loop.get_primary_monitor() } + } + + /// Fetches all the events that are pending, calls the callback function for each of them, + /// and returns. + #[inline] + pub fn poll_events<F>(&mut self, callback: F) + where F: FnMut(Event) + { + self.events_loop.poll_events(callback) + } + + /// Calls `callback` every time an event is received. If no event is available, sleeps the + /// current thread and waits for an event. If the callback returns `ControlFlow::Break` then + /// `run_forever` will immediately return. + /// + /// # Danger! + /// + /// The callback is run after *every* event, so if its execution time is non-trivial the event queue may not empty + /// at a sufficient rate. Rendering in the callback with vsync enabled **will** cause significant lag. + #[inline] + pub fn run_forever<F>(&mut self, callback: F) + where F: FnMut(Event) -> ControlFlow + { + self.events_loop.run_forever(callback) + } + + /// Creates an `EventsLoopProxy` that can be used to wake up the `EventsLoop` from another + /// thread. + pub fn create_proxy(&self) -> EventsLoopProxy { + EventsLoopProxy { + events_loop_proxy: self.events_loop.create_proxy(), + } + } +} + +/// Used to wake up the `EventsLoop` from another thread. +#[derive(Clone)] +pub struct EventsLoopProxy { + events_loop_proxy: platform::EventsLoopProxy, +} + +impl std::fmt::Debug for EventsLoopProxy { + fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result { + fmtr.pad("EventsLoopProxy { .. }") + } +} + +impl EventsLoopProxy { + /// Wake up the `EventsLoop` from which this proxy was created. + /// + /// This causes the `EventsLoop` to emit an `Awakened` event. + /// + /// Returns an `Err` if the associated `EventsLoop` no longer exists. + pub fn wakeup(&self) -> Result<(), EventsLoopClosed> { + self.events_loop_proxy.wakeup() + } +} + +/// The error that is returned when an `EventsLoopProxy` attempts to wake up an `EventsLoop` that +/// no longer exists. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct EventsLoopClosed; + +impl std::fmt::Display for EventsLoopClosed { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{}", std::error::Error::description(self)) + } +} + +impl std::error::Error for EventsLoopClosed { + fn description(&self) -> &str { + "Tried to wake up a closed `EventsLoop`" + } +} + +/// Object that allows you to build windows. +#[derive(Clone)] +pub struct WindowBuilder { + /// The attributes to use to create the window. + pub window: WindowAttributes, + + // Platform-specific configuration. Private. + platform_specific: platform::PlatformSpecificWindowBuilderAttributes, +} + +impl std::fmt::Debug for WindowBuilder { + fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result { + fmtr.debug_struct("WindowBuilder") + .field("window", &self.window) + .finish() + } +} + +/// Error that can happen while creating a window or a headless renderer. +#[derive(Debug, Clone)] +pub enum CreationError { + OsError(String), + /// TODO: remove this error + NotSupported, +} + +impl CreationError { + fn to_string(&self) -> &str { + match *self { + CreationError::OsError(ref text) => &text, + CreationError::NotSupported => "Some of the requested attributes are not supported", + } + } +} + +impl std::fmt::Display for CreationError { + fn fmt(&self, formatter: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + formatter.write_str(self.to_string()) + } +} + +impl std::error::Error for CreationError { + fn description(&self) -> &str { + self.to_string() + } +} + +/// Describes the appearance of the mouse cursor. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum MouseCursor { + /// The platform-dependent default cursor. + Default, + /// A simple crosshair. + Crosshair, + /// A hand (often used to indicate links in web browsers). + Hand, + /// Self explanatory. + Arrow, + /// Indicates something is to be moved. + Move, + /// Indicates text that may be selected or edited. + Text, + /// Program busy indicator. + Wait, + /// Help indicator (often rendered as a "?") + Help, + /// Progress indicator. Shows that processing is being done. But in contrast + /// with "Wait" the user may still interact with the program. Often rendered + /// as a spinning beach ball, or an arrow with a watch or hourglass. + Progress, + + /// Cursor showing that something cannot be done. + NotAllowed, + ContextMenu, + Cell, + VerticalText, + Alias, + Copy, + NoDrop, + Grab, + Grabbing, + AllScroll, + ZoomIn, + ZoomOut, + + /// Indicate that some edge is to be moved. For example, the 'SeResize' cursor + /// is used when the movement starts from the south-east corner of the box. + EResize, + NResize, + NeResize, + NwResize, + SResize, + SeResize, + SwResize, + WResize, + EwResize, + NsResize, + NeswResize, + NwseResize, + ColResize, + RowResize, +} + +impl Default for MouseCursor { + fn default() -> Self { + MouseCursor::Default + } +} + +/// Attributes to use when creating a window. +#[derive(Debug, Clone)] +pub struct WindowAttributes { + /// The dimensions of the window. If this is `None`, some platform-specific dimensions will be + /// used. + /// + /// The default is `None`. + pub dimensions: Option<LogicalSize>, + + /// The minimum dimensions a window can be, If this is `None`, the window will have no minimum dimensions (aside from reserved). + /// + /// The default is `None`. + pub min_dimensions: Option<LogicalSize>, + + /// The maximum dimensions a window can be, If this is `None`, the maximum will have no maximum or will be set to the primary monitor's dimensions by the platform. + /// + /// The default is `None`. + pub max_dimensions: Option<LogicalSize>, + + /// Whether the window is resizable or not. + /// + /// The default is `true`. + pub resizable: bool, + + /// Whether the window should be set as fullscreen upon creation. + /// + /// The default is `None`. + pub fullscreen: Option<MonitorId>, + + /// The title of the window in the title bar. + /// + /// The default is `"winit window"`. + pub title: String, + + /// Whether the window should be maximized upon creation. + /// + /// The default is `false`. + pub maximized: bool, + + /// Whether the window should be immediately visible upon creation. + /// + /// The default is `true`. + pub visible: bool, + + /// Whether the the window should be transparent. If this is true, writing colors + /// with alpha values different than `1.0` will produce a transparent window. + /// + /// The default is `false`. + pub transparent: bool, + + /// Whether the window should have borders and bars. + /// + /// The default is `true`. + pub decorations: bool, + + /// Whether the window should always be on top of other windows. + /// + /// The default is `false`. + pub always_on_top: bool, + + /// The window icon. + /// + /// The default is `None`. + pub window_icon: Option<Icon>, + + /// [iOS only] Enable multitouch, + /// see [multipleTouchEnabled](https://developer.apple.com/documentation/uikit/uiview/1622519-multipletouchenabled) + pub multitouch: bool, +} + +impl Default for WindowAttributes { + #[inline] + fn default() -> WindowAttributes { + WindowAttributes { + dimensions: None, + min_dimensions: None, + max_dimensions: None, + resizable: true, + title: "winit window".to_owned(), + maximized: false, + fullscreen: None, + visible: true, + transparent: false, + decorations: true, + always_on_top: false, + window_icon: None, + multitouch: false, + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/os/android.rs b/third_party/cargo/vendor/winit-0.18.1/src/os/android.rs new file mode 100644 index 0000000..06661a3 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/os/android.rs @@ -0,0 +1,38 @@ +#![cfg(any(target_os = "android"))] + +use std::os::raw::c_void; +use EventsLoop; +use Window; +use WindowBuilder; + +/// Additional methods on `EventsLoop` that are specific to Android. +pub trait EventsLoopExt { + /// Makes it possible for glutin to register a callback when a suspend event happens on Android + fn set_suspend_callback(&self, cb: Option<Box<Fn(bool) -> ()>>); +} + +impl EventsLoopExt for EventsLoop { + fn set_suspend_callback(&self, cb: Option<Box<Fn(bool) -> ()>>) { + self.events_loop.set_suspend_callback(cb); + } +} + +/// Additional methods on `Window` that are specific to Android. +pub trait WindowExt { + fn get_native_window(&self) -> *const c_void; +} + +impl WindowExt for Window { + #[inline] + fn get_native_window(&self) -> *const c_void { + self.window.get_native_window() + } +} + +/// Additional methods on `WindowBuilder` that are specific to Android. +pub trait WindowBuilderExt { + +} + +impl WindowBuilderExt for WindowBuilder { +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/os/ios.rs b/third_party/cargo/vendor/winit-0.18.1/src/os/ios.rs new file mode 100644 index 0000000..62c2c24 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/os/ios.rs @@ -0,0 +1,59 @@ +#![cfg(target_os = "ios")] + +use std::os::raw::c_void; + +use {MonitorId, Window, WindowBuilder}; + +/// Additional methods on `Window` that are specific to iOS. +pub trait WindowExt { + /// Returns a pointer to the `UIWindow` that is used by this window. + /// + /// The pointer will become invalid when the `Window` is destroyed. + fn get_uiwindow(&self) -> *mut c_void; + + /// Returns a pointer to the `UIView` that is used by this window. + /// + /// The pointer will become invalid when the `Window` is destroyed. + fn get_uiview(&self) -> *mut c_void; +} + +impl WindowExt for Window { + #[inline] + fn get_uiwindow(&self) -> *mut c_void { + self.window.get_uiwindow() as _ + } + + #[inline] + fn get_uiview(&self) -> *mut c_void { + self.window.get_uiview() as _ + } +} + +/// Additional methods on `WindowBuilder` that are specific to iOS. +pub trait WindowBuilderExt { + /// Sets the root view class used by the `Window`, otherwise a barebones `UIView` is provided. + /// + /// The class will be initialized by calling `[root_view initWithFrame:CGRect]` + fn with_root_view_class(self, root_view_class: *const c_void) -> WindowBuilder; +} + +impl WindowBuilderExt for WindowBuilder { + #[inline] + fn with_root_view_class(mut self, root_view_class: *const c_void) -> WindowBuilder { + self.platform_specific.root_view_class = unsafe { &*(root_view_class as *const _) }; + self + } +} + +/// Additional methods on `MonitorId` that are specific to iOS. +pub trait MonitorIdExt { + /// Returns a pointer to the `UIScreen` that is used by this monitor. + fn get_uiscreen(&self) -> *mut c_void; +} + +impl MonitorIdExt for MonitorId { + #[inline] + fn get_uiscreen(&self) -> *mut c_void { + self.inner.get_uiscreen() as _ + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/os/macos.rs b/third_party/cargo/vendor/winit-0.18.1/src/os/macos.rs new file mode 100644 index 0000000..b9ea993 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/os/macos.rs @@ -0,0 +1,171 @@ +#![cfg(target_os = "macos")] + +use std::os::raw::c_void; +use {LogicalSize, MonitorId, Window, WindowBuilder}; + +/// Additional methods on `Window` that are specific to MacOS. +pub trait WindowExt { + /// Returns a pointer to the cocoa `NSWindow` that is used by this window. + /// + /// The pointer will become invalid when the `Window` is destroyed. + fn get_nswindow(&self) -> *mut c_void; + + /// Returns a pointer to the cocoa `NSView` that is used by this window. + /// + /// The pointer will become invalid when the `Window` is destroyed. + fn get_nsview(&self) -> *mut c_void; + + /// Request user attention, causing the application's dock icon to bounce. + /// Note that this has no effect if the application is already focused. + /// + /// The `is_critical` flag has the following effects: + /// - `false`: the dock icon will only bounce once. + /// - `true`: the dock icon will bounce until the application is focused. + fn request_user_attention(&self, is_critical: bool); + + /// Toggles a fullscreen mode that doesn't require a new macOS space. + /// Returns a boolean indicating whether the transition was successful (this + /// won't work if the window was already in the native fullscreen). + /// + /// This is how fullscreen used to work on macOS in versions before Lion. + /// And allows the user to have a fullscreen window without using another + /// space or taking control over the entire monitor. + fn set_simple_fullscreen(&self, fullscreen: bool) -> bool; +} + +impl WindowExt for Window { + #[inline] + fn get_nswindow(&self) -> *mut c_void { + self.window.get_nswindow() + } + + #[inline] + fn get_nsview(&self) -> *mut c_void { + self.window.get_nsview() + } + + #[inline] + fn request_user_attention(&self, is_critical: bool) { + self.window.request_user_attention(is_critical) + } + + #[inline] + fn set_simple_fullscreen(&self, fullscreen: bool) -> bool { + self.window.set_simple_fullscreen(fullscreen) + } +} + +/// Corresponds to `NSApplicationActivationPolicy`. +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum ActivationPolicy { + /// Corresponds to `NSApplicationActivationPolicyRegular`. + Regular, + /// Corresponds to `NSApplicationActivationPolicyAccessory`. + Accessory, + /// Corresponds to `NSApplicationActivationPolicyProhibited`. + Prohibited, +} + +impl Default for ActivationPolicy { + fn default() -> Self { + ActivationPolicy::Regular + } +} + +/// Additional methods on `WindowBuilder` that are specific to MacOS. +/// +/// **Note:** Properties dealing with the titlebar will be overwritten by the `with_decorations` method +/// on the base `WindowBuilder`: +/// +/// - `with_titlebar_transparent` +/// - `with_title_hidden` +/// - `with_titlebar_hidden` +/// - `with_titlebar_buttons_hidden` +/// - `with_fullsize_content_view` +pub trait WindowBuilderExt { + /// Sets the activation policy for the window being built. + fn with_activation_policy(self, activation_policy: ActivationPolicy) -> WindowBuilder; + /// Enables click-and-drag behavior for the entire window, not just the titlebar. + fn with_movable_by_window_background(self, movable_by_window_background: bool) -> WindowBuilder; + /// Makes the titlebar transparent and allows the content to appear behind it. + fn with_titlebar_transparent(self, titlebar_transparent: bool) -> WindowBuilder; + /// Hides the window title. + fn with_title_hidden(self, title_hidden: bool) -> WindowBuilder; + /// Hides the window titlebar. + fn with_titlebar_hidden(self, titlebar_hidden: bool) -> WindowBuilder; + /// Hides the window titlebar buttons. + fn with_titlebar_buttons_hidden(self, titlebar_buttons_hidden: bool) -> WindowBuilder; + /// Makes the window content appear behind the titlebar. + fn with_fullsize_content_view(self, fullsize_content_view: bool) -> WindowBuilder; + /// Build window with `resizeIncrements` property. Values must not be 0. + fn with_resize_increments(self, increments: LogicalSize) -> WindowBuilder; +} + +impl WindowBuilderExt for WindowBuilder { + #[inline] + fn with_activation_policy(mut self, activation_policy: ActivationPolicy) -> WindowBuilder { + self.platform_specific.activation_policy = activation_policy; + self + } + + #[inline] + fn with_movable_by_window_background(mut self, movable_by_window_background: bool) -> WindowBuilder { + self.platform_specific.movable_by_window_background = movable_by_window_background; + self + } + + #[inline] + fn with_titlebar_transparent(mut self, titlebar_transparent: bool) -> WindowBuilder { + self.platform_specific.titlebar_transparent = titlebar_transparent; + self + } + + #[inline] + fn with_titlebar_hidden(mut self, titlebar_hidden: bool) -> WindowBuilder { + self.platform_specific.titlebar_hidden = titlebar_hidden; + self + } + + #[inline] + fn with_titlebar_buttons_hidden(mut self, titlebar_buttons_hidden: bool) -> WindowBuilder { + self.platform_specific.titlebar_buttons_hidden = titlebar_buttons_hidden; + self + } + + #[inline] + fn with_title_hidden(mut self, title_hidden: bool) -> WindowBuilder { + self.platform_specific.title_hidden = title_hidden; + self + } + + #[inline] + fn with_fullsize_content_view(mut self, fullsize_content_view: bool) -> WindowBuilder { + self.platform_specific.fullsize_content_view = fullsize_content_view; + self + } + + #[inline] + fn with_resize_increments(mut self, increments: LogicalSize) -> WindowBuilder { + self.platform_specific.resize_increments = Some(increments.into()); + self + } +} + +/// Additional methods on `MonitorId` that are specific to MacOS. +pub trait MonitorIdExt { + /// Returns the identifier of the monitor for Cocoa. + fn native_id(&self) -> u32; + /// Returns a pointer to the NSScreen representing this monitor. + fn get_nsscreen(&self) -> Option<*mut c_void>; +} + +impl MonitorIdExt for MonitorId { + #[inline] + fn native_id(&self) -> u32 { + self.inner.get_native_identifier() + } + + fn get_nsscreen(&self) -> Option<*mut c_void> { + self.inner.get_nsscreen().map(|s| s as *mut c_void) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/os/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/os/mod.rs new file mode 100644 index 0000000..2496769 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/os/mod.rs @@ -0,0 +1,17 @@ +//! Contains traits with platform-specific methods in them. +//! +//! Contains the follow modules: +//! +//! - `android` +//! - `ios` +//! - `macos` +//! - `unix` +//! - `windows` +//! +//! However only the module corresponding to the platform you're compiling to will be available. +//! +pub mod android; +pub mod ios; +pub mod macos; +pub mod unix; +pub mod windows; diff --git a/third_party/cargo/vendor/winit-0.18.1/src/os/unix.rs b/third_party/cargo/vendor/winit-0.18.1/src/os/unix.rs new file mode 100644 index 0000000..3d1525b --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/os/unix.rs @@ -0,0 +1,306 @@ +#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] + +use std::os::raw; +use std::ptr; +use std::sync::Arc; + +use { + EventsLoop, + LogicalSize, + MonitorId, + Window, + WindowBuilder, +}; +use platform::{ + EventsLoop as LinuxEventsLoop, + Window as LinuxWindow, +}; +use platform::x11::XConnection; +use platform::x11::ffi::XVisualInfo; + +// TODO: stupid hack so that glutin can do its work +#[doc(hidden)] +pub use platform::x11; + +pub use platform::XNotSupported; +pub use platform::x11::util::WindowType as XWindowType; + +/// Additional methods on `EventsLoop` that are specific to Linux. +pub trait EventsLoopExt { + /// Builds a new `EventsLoop` that is forced to use X11. + fn new_x11() -> Result<Self, XNotSupported> + where Self: Sized; + + /// Builds a new `EventsLoop` that is forced to use Wayland. + fn new_wayland() -> Self + where Self: Sized; + + /// True if the `EventsLoop` uses Wayland. + fn is_wayland(&self) -> bool; + + /// True if the `EventsLoop` uses X11. + fn is_x11(&self) -> bool; + + #[doc(hidden)] + fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>; +} + +impl EventsLoopExt for EventsLoop { + #[inline] + fn new_x11() -> Result<Self, XNotSupported> { + LinuxEventsLoop::new_x11().map(|ev| + EventsLoop { + events_loop: ev, + _marker: ::std::marker::PhantomData, + } + ) + } + + #[inline] + fn new_wayland() -> Self { + EventsLoop { + events_loop: match LinuxEventsLoop::new_wayland() { + Ok(e) => e, + Err(_) => panic!() // TODO: propagate + }, + _marker: ::std::marker::PhantomData, + } + } + + #[inline] + fn is_wayland(&self) -> bool { + self.events_loop.is_wayland() + } + + #[inline] + fn is_x11(&self) -> bool { + !self.events_loop.is_wayland() + } + + #[inline] + #[doc(hidden)] + fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>> { + self.events_loop.x_connection().cloned() + } +} + +/// Additional methods on `Window` that are specific to Unix. +pub trait WindowExt { + /// Returns the ID of the `Window` xlib object that is used by this window. + /// + /// Returns `None` if the window doesn't use xlib (if it uses wayland for example). + fn get_xlib_window(&self) -> Option<raw::c_ulong>; + + /// Returns a pointer to the `Display` object of xlib that is used by this window. + /// + /// Returns `None` if the window doesn't use xlib (if it uses wayland for example). + /// + /// The pointer will become invalid when the glutin `Window` is destroyed. + fn get_xlib_display(&self) -> Option<*mut raw::c_void>; + + fn get_xlib_screen_id(&self) -> Option<raw::c_int>; + + #[doc(hidden)] + fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>; + + /// Set window urgency hint (`XUrgencyHint`). Only relevant on X. + fn set_urgent(&self, is_urgent: bool); + + /// This function returns the underlying `xcb_connection_t` of an xlib `Display`. + /// + /// Returns `None` if the window doesn't use xlib (if it uses wayland for example). + /// + /// The pointer will become invalid when the glutin `Window` is destroyed. + fn get_xcb_connection(&self) -> Option<*mut raw::c_void>; + + /// Returns a pointer to the `wl_surface` object of wayland that is used by this window. + /// + /// Returns `None` if the window doesn't use wayland (if it uses xlib for example). + /// + /// The pointer will become invalid when the glutin `Window` is destroyed. + fn get_wayland_surface(&self) -> Option<*mut raw::c_void>; + + /// Returns a pointer to the `wl_display` object of wayland that is used by this window. + /// + /// Returns `None` if the window doesn't use wayland (if it uses xlib for example). + /// + /// The pointer will become invalid when the glutin `Window` is destroyed. + fn get_wayland_display(&self) -> Option<*mut raw::c_void>; + + /// Check if the window is ready for drawing + /// + /// It is a remnant of a previous implementation detail for the + /// wayland backend, and is no longer relevant. + /// + /// Always return true. + #[deprecated] + fn is_ready(&self) -> bool; +} + +impl WindowExt for Window { + #[inline] + fn get_xlib_window(&self) -> Option<raw::c_ulong> { + match self.window { + LinuxWindow::X(ref w) => Some(w.get_xlib_window()), + _ => None + } + } + + #[inline] + fn get_xlib_display(&self) -> Option<*mut raw::c_void> { + match self.window { + LinuxWindow::X(ref w) => Some(w.get_xlib_display()), + _ => None + } + } + + #[inline] + fn get_xlib_screen_id(&self) -> Option<raw::c_int> { + match self.window { + LinuxWindow::X(ref w) => Some(w.get_xlib_screen_id()), + _ => None + } + } + + #[inline] + #[doc(hidden)] + fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>> { + match self.window { + LinuxWindow::X(ref w) => Some(w.get_xlib_xconnection()), + _ => None + } + } + + #[inline] + fn get_xcb_connection(&self) -> Option<*mut raw::c_void> { + match self.window { + LinuxWindow::X(ref w) => Some(w.get_xcb_connection()), + _ => None + } + } + + #[inline] + fn set_urgent(&self, is_urgent: bool) { + if let LinuxWindow::X(ref w) = self.window { + w.set_urgent(is_urgent); + } + } + + #[inline] + fn get_wayland_surface(&self) -> Option<*mut raw::c_void> { + match self.window { + LinuxWindow::Wayland(ref w) => Some(w.get_surface().c_ptr() as *mut _), + _ => None + } + } + + #[inline] + fn get_wayland_display(&self) -> Option<*mut raw::c_void> { + match self.window { + LinuxWindow::Wayland(ref w) => Some(w.get_display().c_ptr() as *mut _), + _ => None + } + } + + #[inline] + fn is_ready(&self) -> bool { + true + } +} + +/// Additional methods on `WindowBuilder` that are specific to Unix. +pub trait WindowBuilderExt { + fn with_x11_visual<T>(self, visual_infos: *const T) -> WindowBuilder; + fn with_x11_screen(self, screen_id: i32) -> WindowBuilder; + + /// Build window with `WM_CLASS` hint; defaults to the name of the binary. Only relevant on X11. + fn with_class(self, class: String, instance: String) -> WindowBuilder; + /// Build window with override-redirect flag; defaults to false. Only relevant on X11. + fn with_override_redirect(self, override_redirect: bool) -> WindowBuilder; + /// Build window with `_NET_WM_WINDOW_TYPE` hint; defaults to `Normal`. Only relevant on X11. + fn with_x11_window_type(self, x11_window_type: XWindowType) -> WindowBuilder; + /// Build window with `_GTK_THEME_VARIANT` hint set to the specified value. Currently only relevant on X11. + fn with_gtk_theme_variant(self, variant: String) -> WindowBuilder; + /// Build window with resize increment hint. Only implemented on X11. + fn with_resize_increments(self, increments: LogicalSize) -> WindowBuilder; + /// Build window with base size hint. Only implemented on X11. + fn with_base_size(self, base_size: LogicalSize) -> WindowBuilder; + + /// Build window with a given application ID. It should match the `.desktop` file distributed with + /// your program. Only relevant on Wayland. + /// + /// For details about application ID conventions, see the + /// [Desktop Entry Spec](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#desktop-file-id) + fn with_app_id(self, app_id: String) -> WindowBuilder; +} + +impl WindowBuilderExt for WindowBuilder { + #[inline] + fn with_x11_visual<T>(mut self, visual_infos: *const T) -> WindowBuilder { + self.platform_specific.visual_infos = Some( + unsafe { ptr::read(visual_infos as *const XVisualInfo) } + ); + self + } + + #[inline] + fn with_x11_screen(mut self, screen_id: i32) -> WindowBuilder { + self.platform_specific.screen_id = Some(screen_id); + self + } + + #[inline] + fn with_class(mut self, instance: String, class: String) -> WindowBuilder { + self.platform_specific.class = Some((instance, class)); + self + } + + #[inline] + fn with_override_redirect(mut self, override_redirect: bool) -> WindowBuilder { + self.platform_specific.override_redirect = override_redirect; + self + } + + #[inline] + fn with_x11_window_type(mut self, x11_window_type: XWindowType) -> WindowBuilder { + self.platform_specific.x11_window_type = x11_window_type; + self + } + + #[inline] + fn with_resize_increments(mut self, increments: LogicalSize) -> WindowBuilder { + self.platform_specific.resize_increments = Some(increments.into()); + self + } + + #[inline] + fn with_base_size(mut self, base_size: LogicalSize) -> WindowBuilder { + self.platform_specific.base_size = Some(base_size.into()); + self + } + + #[inline] + fn with_gtk_theme_variant(mut self, variant: String) -> WindowBuilder { + self.platform_specific.gtk_theme_variant = Some(variant); + self + } + + #[inline] + fn with_app_id(mut self, app_id: String) -> WindowBuilder { + self.platform_specific.app_id = Some(app_id); + self + } +} + +/// Additional methods on `MonitorId` that are specific to Linux. +pub trait MonitorIdExt { + /// Returns the inner identifier of the monitor. + fn native_id(&self) -> u32; +} + +impl MonitorIdExt for MonitorId { + #[inline] + fn native_id(&self) -> u32 { + self.inner.get_native_identifier() + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/os/windows.rs b/third_party/cargo/vendor/winit-0.18.1/src/os/windows.rs new file mode 100644 index 0000000..62b16c7 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/os/windows.rs @@ -0,0 +1,117 @@ +#![cfg(target_os = "windows")] + +use std::os::raw::c_void; + +use libc; +use winapi::shared::windef::HWND; + +use {DeviceId, EventsLoop, Icon, MonitorId, Window, WindowBuilder}; +use platform::EventsLoop as WindowsEventsLoop; + +/// Additional methods on `EventsLoop` that are specific to Windows. +pub trait EventsLoopExt { + /// By default, winit on Windows will attempt to enable process-wide DPI awareness. If that's + /// undesirable, you can create an `EventsLoop` using this function instead. + fn new_dpi_unaware() -> Self where Self: Sized; +} + +impl EventsLoopExt for EventsLoop { + #[inline] + fn new_dpi_unaware() -> Self { + EventsLoop { + events_loop: WindowsEventsLoop::with_dpi_awareness(false), + _marker: ::std::marker::PhantomData, + } + } +} + +/// Additional methods on `Window` that are specific to Windows. +pub trait WindowExt { + /// Returns the native handle that is used by this window. + /// + /// The pointer will become invalid when the native window was destroyed. + fn get_hwnd(&self) -> *mut libc::c_void; + + /// This sets `ICON_BIG`. A good ceiling here is 256x256. + fn set_taskbar_icon(&self, taskbar_icon: Option<Icon>); +} + +impl WindowExt for Window { + #[inline] + fn get_hwnd(&self) -> *mut libc::c_void { + self.window.hwnd() as *mut _ + } + + #[inline] + fn set_taskbar_icon(&self, taskbar_icon: Option<Icon>) { + self.window.set_taskbar_icon(taskbar_icon) + } +} + +/// Additional methods on `WindowBuilder` that are specific to Windows. +pub trait WindowBuilderExt { + /// Sets a parent to the window to be created. + fn with_parent_window(self, parent: HWND) -> WindowBuilder; + + /// This sets `ICON_BIG`. A good ceiling here is 256x256. + fn with_taskbar_icon(self, taskbar_icon: Option<Icon>) -> WindowBuilder; + + /// This sets `WS_EX_NOREDIRECTIONBITMAP`. + fn with_no_redirection_bitmap(self, flag: bool) -> WindowBuilder; +} + +impl WindowBuilderExt for WindowBuilder { + #[inline] + fn with_parent_window(mut self, parent: HWND) -> WindowBuilder { + self.platform_specific.parent = Some(parent); + self + } + + #[inline] + fn with_taskbar_icon(mut self, taskbar_icon: Option<Icon>) -> WindowBuilder { + self.platform_specific.taskbar_icon = taskbar_icon; + self + } + + #[inline] + fn with_no_redirection_bitmap(mut self, flag: bool) -> WindowBuilder { + self.platform_specific.no_redirection_bitmap = flag; + self + } +} + +/// Additional methods on `MonitorId` that are specific to Windows. +pub trait MonitorIdExt { + /// Returns the name of the monitor adapter specific to the Win32 API. + fn native_id(&self) -> String; + + /// Returns the handle of the monitor - `HMONITOR`. + fn hmonitor(&self) -> *mut c_void; +} + +impl MonitorIdExt for MonitorId { + #[inline] + fn native_id(&self) -> String { + self.inner.get_native_identifier() + } + + #[inline] + fn hmonitor(&self) -> *mut c_void { + self.inner.get_hmonitor() as *mut _ + } +} + +/// Additional methods on `DeviceId` that are specific to Windows. +pub trait DeviceIdExt { + /// Returns an identifier that persistently refers to this specific device. + /// + /// Will return `None` if the device is no longer available. + fn get_persistent_identifier(&self) -> Option<String>; +} + +impl DeviceIdExt for DeviceId { + #[inline] + fn get_persistent_identifier(&self) -> Option<String> { + self.0.get_persistent_identifier() + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/android/ffi.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/android/ffi.rs new file mode 100644 index 0000000..af8c50b --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/android/ffi.rs @@ -0,0 +1,108 @@ +#![allow(dead_code)] +#![allow(non_snake_case)] +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +use libc; +use std::os::raw; + +#[link(name = "android")] +#[link(name = "EGL")] +#[link(name = "GLESv2")] +extern {} + +/** + * asset_manager.h + */ +pub type AAssetManager = raw::c_void; + +/** + * native_window.h + */ +pub type ANativeWindow = raw::c_void; + +extern { + pub fn ANativeWindow_getHeight(window: *const ANativeWindow) -> libc::int32_t; + pub fn ANativeWindow_getWidth(window: *const ANativeWindow) -> libc::int32_t; +} + +/** + * native_activity.h + */ +pub type JavaVM = (); +pub type JNIEnv = (); +pub type jobject = *const libc::c_void; + +pub type AInputQueue = (); // FIXME: wrong +pub type ARect = (); // FIXME: wrong + +#[repr(C)] +pub struct ANativeActivity { + pub callbacks: *mut ANativeActivityCallbacks, + pub vm: *mut JavaVM, + pub env: *mut JNIEnv, + pub clazz: jobject, + pub internalDataPath: *const libc::c_char, + pub externalDataPath: *const libc::c_char, + pub sdkVersion: libc::int32_t, + pub instance: *mut libc::c_void, + pub assetManager: *mut AAssetManager, + pub obbPath: *const libc::c_char, +} + +#[repr(C)] +pub struct ANativeActivityCallbacks { + pub onStart: extern fn(*mut ANativeActivity), + pub onResume: extern fn(*mut ANativeActivity), + pub onSaveInstanceState: extern fn(*mut ANativeActivity, *mut libc::size_t), + pub onPause: extern fn(*mut ANativeActivity), + pub onStop: extern fn(*mut ANativeActivity), + pub onDestroy: extern fn(*mut ANativeActivity), + pub onWindowFocusChanged: extern fn(*mut ANativeActivity, libc::c_int), + pub onNativeWindowCreated: extern fn(*mut ANativeActivity, *const ANativeWindow), + pub onNativeWindowResized: extern fn(*mut ANativeActivity, *const ANativeWindow), + pub onNativeWindowRedrawNeeded: extern fn(*mut ANativeActivity, *const ANativeWindow), + pub onNativeWindowDestroyed: extern fn(*mut ANativeActivity, *const ANativeWindow), + pub onInputQueueCreated: extern fn(*mut ANativeActivity, *mut AInputQueue), + pub onInputQueueDestroyed: extern fn(*mut ANativeActivity, *mut AInputQueue), + pub onContentRectChanged: extern fn(*mut ANativeActivity, *const ARect), + pub onConfigurationChanged: extern fn(*mut ANativeActivity), + pub onLowMemory: extern fn(*mut ANativeActivity), +} + +/** + * looper.h + */ +pub type ALooper = (); + +#[link(name = "android")] +extern { + pub fn ALooper_forThread() -> *const ALooper; + pub fn ALooper_acquire(looper: *const ALooper); + pub fn ALooper_release(looper: *const ALooper); + pub fn ALooper_prepare(opts: libc::c_int) -> *const ALooper; + pub fn ALooper_pollOnce(timeoutMillis: libc::c_int, outFd: *mut libc::c_int, + outEvents: *mut libc::c_int, outData: *mut *mut libc::c_void) -> libc::c_int; + pub fn ALooper_pollAll(timeoutMillis: libc::c_int, outFd: *mut libc::c_int, + outEvents: *mut libc::c_int, outData: *mut *mut libc::c_void) -> libc::c_int; + pub fn ALooper_wake(looper: *const ALooper); + pub fn ALooper_addFd(looper: *const ALooper, fd: libc::c_int, ident: libc::c_int, + events: libc::c_int, callback: ALooper_callbackFunc, data: *mut libc::c_void) + -> libc::c_int; + pub fn ALooper_removeFd(looper: *const ALooper, fd: libc::c_int) -> libc::c_int; +} + +pub const ALOOPER_PREPARE_ALLOW_NON_CALLBACKS: libc::c_int = 1 << 0; + +pub const ALOOPER_POLL_WAKE: libc::c_int = -1; +pub const ALOOPER_POLL_CALLBACK: libc::c_int = -2; +pub const ALOOPER_POLL_TIMEOUT: libc::c_int = -3; +pub const ALOOPER_POLL_ERROR: libc::c_int = -4; + +pub const ALOOPER_EVENT_INPUT: libc::c_int = 1 << 0; +pub const ALOOPER_EVENT_OUTPUT: libc::c_int = 1 << 1; +pub const ALOOPER_EVENT_ERROR: libc::c_int = 1 << 2; +pub const ALOOPER_EVENT_HANGUP: libc::c_int = 1 << 3; +pub const ALOOPER_EVENT_INVALID: libc::c_int = 1 << 4; + +pub type ALooper_callbackFunc = extern fn(libc::c_int, libc::c_int, *mut libc::c_void) -> libc::c_int; diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/android/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/android/mod.rs new file mode 100644 index 0000000..dad7380 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/android/mod.rs @@ -0,0 +1,424 @@ +#![cfg(target_os = "android")] + +extern crate android_glue; + +mod ffi; + +use std::cell::RefCell; +use std::collections::VecDeque; +use std::fmt; +use std::os::raw::c_void; +use std::sync::mpsc::{Receiver, channel}; + +use { + CreationError, + Event, + LogicalPosition, + LogicalSize, + MouseCursor, + PhysicalPosition, + PhysicalSize, + WindowAttributes, + WindowEvent, + WindowId as RootWindowId, +}; +use CreationError::OsError; +use events::{Touch, TouchPhase}; +use window::MonitorId as RootMonitorId; + +pub struct EventsLoop { + event_rx: Receiver<android_glue::Event>, + suspend_callback: RefCell<Option<Box<Fn(bool) -> ()>>>, +} + +#[derive(Clone)] +pub struct EventsLoopProxy; + +impl EventsLoop { + pub fn new() -> EventsLoop { + let (tx, rx) = channel(); + android_glue::add_sender(tx); + EventsLoop { + event_rx: rx, + suspend_callback: Default::default(), + } + } + + #[inline] + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + let mut rb = VecDeque::with_capacity(1); + rb.push_back(MonitorId); + rb + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + MonitorId + } + + pub fn poll_events<F>(&mut self, mut callback: F) + where F: FnMut(::Event) + { + while let Ok(event) = self.event_rx.try_recv() { + let e = match event{ + android_glue::Event::EventMotion(motion) => { + let dpi_factor = MonitorId.get_hidpi_factor(); + let location = LogicalPosition::from_physical( + (motion.x as f64, motion.y as f64), + dpi_factor, + ); + Some(Event::WindowEvent { + window_id: RootWindowId(WindowId), + event: WindowEvent::Touch(Touch { + phase: match motion.action { + android_glue::MotionAction::Down => TouchPhase::Started, + android_glue::MotionAction::Move => TouchPhase::Moved, + android_glue::MotionAction::Up => TouchPhase::Ended, + android_glue::MotionAction::Cancel => TouchPhase::Cancelled, + }, + location, + id: motion.pointer_id as u64, + device_id: DEVICE_ID, + }), + }) + }, + android_glue::Event::InitWindow => { + // The activity went to foreground. + if let Some(cb) = self.suspend_callback.borrow().as_ref() { + (*cb)(false); + } + Some(Event::Suspended(false)) + }, + android_glue::Event::TermWindow => { + // The activity went to background. + if let Some(cb) = self.suspend_callback.borrow().as_ref() { + (*cb)(true); + } + Some(Event::Suspended(true)) + }, + android_glue::Event::WindowResized | + android_glue::Event::ConfigChanged => { + // Activity Orientation changed or resized. + let native_window = unsafe { android_glue::get_native_window() }; + if native_window.is_null() { + None + } else { + let dpi_factor = MonitorId.get_hidpi_factor(); + let physical_size = MonitorId.get_dimensions(); + let size = LogicalSize::from_physical(physical_size, dpi_factor); + Some(Event::WindowEvent { + window_id: RootWindowId(WindowId), + event: WindowEvent::Resized(size), + }) + } + }, + android_glue::Event::WindowRedrawNeeded => { + // The activity needs to be redrawn. + Some(Event::WindowEvent { + window_id: RootWindowId(WindowId), + event: WindowEvent::Refresh, + }) + } + android_glue::Event::Wake => { + Some(Event::Awakened) + } + _ => { + None + } + }; + + if let Some(event) = e { + callback(event); + } + }; + } + + pub fn set_suspend_callback(&self, cb: Option<Box<Fn(bool) -> ()>>) { + *self.suspend_callback.borrow_mut() = cb; + } + + pub fn run_forever<F>(&mut self, mut callback: F) + where F: FnMut(::Event) -> ::ControlFlow, + { + // Yeah that's a very bad implementation. + loop { + let mut control_flow = ::ControlFlow::Continue; + self.poll_events(|e| { + if let ::ControlFlow::Break = callback(e) { + control_flow = ::ControlFlow::Break; + } + }); + if let ::ControlFlow::Break = control_flow { + break; + } + ::std::thread::sleep(::std::time::Duration::from_millis(5)); + } + } + + pub fn create_proxy(&self) -> EventsLoopProxy { + EventsLoopProxy + } +} + +impl EventsLoopProxy { + pub fn wakeup(&self) -> Result<(), ::EventsLoopClosed> { + android_glue::wake_event_loop(); + Ok(()) + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct WindowId; + +impl WindowId { + pub unsafe fn dummy() -> Self { + WindowId + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct DeviceId; + +impl DeviceId { + pub unsafe fn dummy() -> Self { + DeviceId + } +} + +pub struct Window { + native_window: *const c_void, +} + +#[derive(Clone)] +pub struct MonitorId; + +impl fmt::Debug for MonitorId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[derive(Debug)] + struct MonitorId { + name: Option<String>, + dimensions: PhysicalSize, + position: PhysicalPosition, + hidpi_factor: f64, + } + + let monitor_id_proxy = MonitorId { + name: self.get_name(), + dimensions: self.get_dimensions(), + position: self.get_position(), + hidpi_factor: self.get_hidpi_factor(), + }; + + monitor_id_proxy.fmt(f) + } +} + +impl MonitorId { + #[inline] + pub fn get_name(&self) -> Option<String> { + Some("Primary".to_string()) + } + + #[inline] + pub fn get_dimensions(&self) -> PhysicalSize { + unsafe { + let window = android_glue::get_native_window(); + ( + ffi::ANativeWindow_getWidth(window) as f64, + ffi::ANativeWindow_getHeight(window) as f64, + ).into() + } + } + + #[inline] + pub fn get_position(&self) -> PhysicalPosition { + // Android assumes single screen + (0, 0).into() + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + 1.0 + } +} + +#[derive(Clone, Default)] +pub struct PlatformSpecificWindowBuilderAttributes; +#[derive(Clone, Default)] +pub struct PlatformSpecificHeadlessBuilderAttributes; + +impl Window { + pub fn new(_: &EventsLoop, win_attribs: WindowAttributes, + _: PlatformSpecificWindowBuilderAttributes) + -> Result<Window, CreationError> + { + let native_window = unsafe { android_glue::get_native_window() }; + if native_window.is_null() { + return Err(OsError(format!("Android's native window is null"))); + } + + android_glue::set_multitouch(win_attribs.multitouch); + + Ok(Window { + native_window: native_window as *const _, + }) + } + + #[inline] + pub fn get_native_window(&self) -> *const c_void { + self.native_window + } + + #[inline] + pub fn set_title(&self, _: &str) { + // N/A + } + + #[inline] + pub fn show(&self) { + // N/A + } + + #[inline] + pub fn hide(&self) { + // N/A + } + + #[inline] + pub fn get_position(&self) -> Option<LogicalPosition> { + // N/A + None + } + + #[inline] + pub fn get_inner_position(&self) -> Option<LogicalPosition> { + // N/A + None + } + + #[inline] + pub fn set_position(&self, _position: LogicalPosition) { + // N/A + } + + #[inline] + pub fn set_min_dimensions(&self, _dimensions: Option<LogicalSize>) { + // N/A + } + + #[inline] + pub fn set_max_dimensions(&self, _dimensions: Option<LogicalSize>) { + // N/A + } + + #[inline] + pub fn set_resizable(&self, _resizable: bool) { + // N/A + } + + #[inline] + pub fn get_inner_size(&self) -> Option<LogicalSize> { + if self.native_window.is_null() { + None + } else { + let dpi_factor = self.get_hidpi_factor(); + let physical_size = self.get_current_monitor().get_dimensions(); + Some(LogicalSize::from_physical(physical_size, dpi_factor)) + } + } + + #[inline] + pub fn get_outer_size(&self) -> Option<LogicalSize> { + self.get_inner_size() + } + + #[inline] + pub fn set_inner_size(&self, _size: LogicalSize) { + // N/A + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + self.get_current_monitor().get_hidpi_factor() + } + + #[inline] + pub fn set_cursor(&self, _: MouseCursor) { + // N/A + } + + #[inline] + pub fn grab_cursor(&self, _grab: bool) -> Result<(), String> { + Err("Cursor grabbing is not possible on Android.".to_owned()) + } + + #[inline] + pub fn hide_cursor(&self, _hide: bool) { + // N/A + } + + #[inline] + pub fn set_cursor_position(&self, _position: LogicalPosition) -> Result<(), String> { + Err("Setting cursor position is not possible on Android.".to_owned()) + } + + #[inline] + pub fn set_maximized(&self, _maximized: bool) { + // N/A + // Android has single screen maximized apps so nothing to do + } + + #[inline] + pub fn set_fullscreen(&self, _monitor: Option<RootMonitorId>) { + // N/A + // Android has single screen maximized apps so nothing to do + } + + #[inline] + pub fn set_decorations(&self, _decorations: bool) { + // N/A + } + + #[inline] + pub fn set_always_on_top(&self, _always_on_top: bool) { + // N/A + } + + #[inline] + pub fn set_window_icon(&self, _icon: Option<::Icon>) { + // N/A + } + + #[inline] + pub fn set_ime_spot(&self, _spot: LogicalPosition) { + // N/A + } + + #[inline] + pub fn get_current_monitor(&self) -> RootMonitorId { + RootMonitorId { inner: MonitorId } + } + + #[inline] + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + let mut rb = VecDeque::with_capacity(1); + rb.push_back(MonitorId); + rb + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + MonitorId + } + + #[inline] + pub fn id(&self) -> WindowId { + WindowId + } +} + +unsafe impl Send for Window {} +unsafe impl Sync for Window {} + +// Constant device ID, to be removed when this backend is updated to report real device IDs. +const DEVICE_ID: ::DeviceId = ::DeviceId(DeviceId); diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/emscripten/ffi.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/emscripten/ffi.rs new file mode 100644 index 0000000..8da2663 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/emscripten/ffi.rs @@ -0,0 +1,314 @@ +#![allow(dead_code, non_camel_case_types, non_snake_case)] + +use std::os::raw::{c_int, c_char, c_void, c_ulong, c_double, c_long, c_ushort}; +#[cfg(test)] +use std::mem; + +pub type EM_BOOL = c_int; +pub type EM_UTF8 = c_char; +pub type EMSCRIPTEN_RESULT = c_int; + +pub const EM_TRUE: EM_BOOL = 1; +pub const EM_FALSE: EM_BOOL = 0; + +// values for EMSCRIPTEN_RESULT +pub const EMSCRIPTEN_RESULT_SUCCESS: c_int = 0; +pub const EMSCRIPTEN_RESULT_DEFERRED: c_int = 1; +pub const EMSCRIPTEN_RESULT_NOT_SUPPORTED: c_int = -1; +pub const EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED: c_int = -2; +pub const EMSCRIPTEN_RESULT_INVALID_TARGET: c_int = -3; +pub const EMSCRIPTEN_RESULT_UNKNOWN_TARGET: c_int = -4; +pub const EMSCRIPTEN_RESULT_INVALID_PARAM: c_int = -5; +pub const EMSCRIPTEN_RESULT_FAILED: c_int = -6; +pub const EMSCRIPTEN_RESULT_NO_DATA: c_int = -7; + +// values for EMSCRIPTEN EVENT +pub const EMSCRIPTEN_EVENT_KEYPRESS: c_int = 1; +pub const EMSCRIPTEN_EVENT_KEYDOWN: c_int = 2; +pub const EMSCRIPTEN_EVENT_KEYUP: c_int = 3; +pub const EMSCRIPTEN_EVENT_CLICK: c_int = 4; +pub const EMSCRIPTEN_EVENT_MOUSEDOWN: c_int = 5; +pub const EMSCRIPTEN_EVENT_MOUSEUP: c_int = 6; +pub const EMSCRIPTEN_EVENT_DBLCLICK: c_int = 7; +pub const EMSCRIPTEN_EVENT_MOUSEMOVE: c_int = 8; +pub const EMSCRIPTEN_EVENT_WHEEL: c_int = 9; +pub const EMSCRIPTEN_EVENT_RESIZE: c_int = 10; +pub const EMSCRIPTEN_EVENT_SCROLL: c_int = 11; +pub const EMSCRIPTEN_EVENT_BLUR: c_int = 12; +pub const EMSCRIPTEN_EVENT_FOCUS: c_int = 13; +pub const EMSCRIPTEN_EVENT_FOCUSIN: c_int = 14; +pub const EMSCRIPTEN_EVENT_FOCUSOUT: c_int = 15; +pub const EMSCRIPTEN_EVENT_DEVICEORIENTATION: c_int = 16; +pub const EMSCRIPTEN_EVENT_DEVICEMOTION: c_int = 17; +pub const EMSCRIPTEN_EVENT_ORIENTATIONCHANGE: c_int = 18; +pub const EMSCRIPTEN_EVENT_FULLSCREENCHANGE: c_int = 19; +pub const EMSCRIPTEN_EVENT_POINTERLOCKCHANGE: c_int = 20; +pub const EMSCRIPTEN_EVENT_VISIBILITYCHANGE: c_int = 21; +pub const EMSCRIPTEN_EVENT_TOUCHSTART: c_int = 22; +pub const EMSCRIPTEN_EVENT_TOUCHEND: c_int = 23; +pub const EMSCRIPTEN_EVENT_TOUCHMOVE: c_int = 24; +pub const EMSCRIPTEN_EVENT_TOUCHCANCEL: c_int = 25; +pub const EMSCRIPTEN_EVENT_GAMEPADCONNECTED: c_int = 26; +pub const EMSCRIPTEN_EVENT_GAMEPADDISCONNECTED: c_int = 27; +pub const EMSCRIPTEN_EVENT_BEFOREUNLOAD: c_int = 28; +pub const EMSCRIPTEN_EVENT_BATTERYCHARGINGCHANGE: c_int = 29; +pub const EMSCRIPTEN_EVENT_BATTERYLEVELCHANGE: c_int = 30; +pub const EMSCRIPTEN_EVENT_WEBGLCONTEXTLOST: c_int = 31; +pub const EMSCRIPTEN_EVENT_WEBGLCONTEXTRESTORED: c_int = 32; +pub const EMSCRIPTEN_EVENT_MOUSEENTER: c_int = 33; +pub const EMSCRIPTEN_EVENT_MOUSELEAVE: c_int = 34; +pub const EMSCRIPTEN_EVENT_MOUSEOVER: c_int = 35; +pub const EMSCRIPTEN_EVENT_MOUSEOUT: c_int = 36; +pub const EMSCRIPTEN_EVENT_CANVASRESIZED: c_int = 37; +pub const EMSCRIPTEN_EVENT_POINTERLOCKERROR: c_int = 38; + +pub const EM_HTML5_SHORT_STRING_LEN_BYTES: usize = 32; + +pub const DOM_KEY_LOCATION_STANDARD: c_ulong = 0x00; +pub const DOM_KEY_LOCATION_LEFT: c_ulong = 0x01; +pub const DOM_KEY_LOCATION_RIGHT: c_ulong = 0x02; +pub const DOM_KEY_LOCATION_NUMPAD: c_ulong = 0x03; + +pub type em_callback_func = Option<unsafe extern "C" fn()>; + +pub type em_key_callback_func = Option<unsafe extern "C" fn( + eventType: c_int, + keyEvent: *const EmscriptenKeyboardEvent, + userData: *mut c_void) -> EM_BOOL>; + +pub type em_mouse_callback_func = Option<unsafe extern "C" fn( + eventType: c_int, + mouseEvent: *const EmscriptenMouseEvent, + userData: *mut c_void) -> EM_BOOL>; + +pub type em_pointerlockchange_callback_func = Option<unsafe extern "C" fn( + eventType: c_int, + pointerlockChangeEvent: *const EmscriptenPointerlockChangeEvent, + userData: *mut c_void) -> EM_BOOL>; + +pub type em_fullscreenchange_callback_func = Option<unsafe extern "C" fn( + eventType: c_int, + fullscreenChangeEvent: *const EmscriptenFullscreenChangeEvent, + userData: *mut c_void) -> EM_BOOL>; + +pub type em_touch_callback_func = Option<unsafe extern "C" fn( + eventType: c_int, + touchEvent: *const EmscriptenTouchEvent, + userData: *mut c_void) -> EM_BOOL>; + +#[repr(C)] +pub struct EmscriptenFullscreenChangeEvent { + pub isFullscreen: c_int, + pub fullscreenEnabled: c_int, + pub nodeName: [c_char; 128usize], + pub id: [c_char; 128usize], + pub elementWidth: c_int, + pub elementHeight: c_int, + pub screenWidth: c_int, + pub screenHeight: c_int, +} +#[test] +fn bindgen_test_layout_EmscriptenFullscreenChangeEvent() { + assert_eq!(mem::size_of::<EmscriptenFullscreenChangeEvent>(), 280usize); + assert_eq!(mem::align_of::<EmscriptenFullscreenChangeEvent>(), 4usize); +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct EmscriptenKeyboardEvent { + pub key: [c_char; 32usize], + pub code: [c_char; 32usize], + pub location: c_ulong, + pub ctrlKey: c_int, + pub shiftKey: c_int, + pub altKey: c_int, + pub metaKey: c_int, + pub repeat: c_int, + pub locale: [c_char; 32usize], + pub charValue: [c_char; 32usize], + pub charCode: c_ulong, + pub keyCode: c_ulong, + pub which: c_ulong, +} +#[test] +fn bindgen_test_layout_EmscriptenKeyboardEvent() { + assert_eq!(mem::size_of::<EmscriptenKeyboardEvent>(), 184usize); + assert_eq!(mem::align_of::<EmscriptenKeyboardEvent>(), 8usize); +} +impl Clone for EmscriptenKeyboardEvent { + fn clone(&self) -> Self { *self } +} + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct EmscriptenMouseEvent { + pub timestamp: f64, + pub screenX: c_long, + pub screenY: c_long, + pub clientX: c_long, + pub clientY: c_long, + pub ctrlKey: c_int, + pub shiftKey: c_int, + pub altKey: c_int, + pub metaKey: c_int, + pub button: c_ushort, + pub buttons: c_ushort, + pub movementX: c_long, + pub movementY: c_long, + pub targetX: c_long, + pub targetY: c_long, + pub canvasX: c_long, + pub canvasY: c_long, + pub padding: c_long, +} +#[test] +fn bindgen_test_layout_EmscriptenMouseEvent() { + assert_eq!(mem::size_of::<EmscriptenMouseEvent>(), 120usize); + assert_eq!(mem::align_of::<EmscriptenMouseEvent>(), 8usize); +} + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct EmscriptenTouchPoint { + pub identifier: c_long, + pub screenX: c_long, + pub screenY: c_long, + pub clientX: c_long, + pub clientY: c_long, + pub pageX: c_long, + pub pageY: c_long, + pub isChanged: c_int, + pub onTarget: c_int, + pub targetX: c_long, + pub targetY: c_long, + pub canvasX: c_long, + pub canvasY: c_long, +} +#[test] +fn bindgen_test_layout_EmscriptenTouchPoint() { + assert_eq!(mem::size_of::<EmscriptenTouchPoint>(), 96usize); + assert_eq!(mem::align_of::<EmscriptenTouchPoint>(), 8usize); +} + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct EmscriptenTouchEvent { + pub numTouches: c_int, + pub ctrlKey: c_int, + pub shiftKey: c_int, + pub altKey: c_int, + pub metaKey: c_int, + pub touches: [EmscriptenTouchPoint; 32usize], +} +#[test] +fn bindgen_test_layout_EmscriptenTouchEvent() { + assert_eq!(mem::size_of::<EmscriptenTouchEvent>(), 3096usize); + assert_eq!(mem::align_of::<EmscriptenTouchEvent>(), 8usize); +} + +#[repr(C)] +pub struct EmscriptenPointerlockChangeEvent { + pub isActive: c_int, + pub nodeName: [c_char; 128usize], + pub id: [c_char; 128usize], +} +#[test] +fn bindgen_test_layout_EmscriptenPointerlockChangeEvent() { + assert_eq!(mem::size_of::<EmscriptenPointerlockChangeEvent>(), 260usize); + assert_eq!(mem::align_of::<EmscriptenPointerlockChangeEvent>(), 4usize); +} + +extern "C" { + pub fn emscripten_set_canvas_size( + width: c_int, height: c_int) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_get_canvas_size( + width: *mut c_int, height: *mut c_int, + is_fullscreen: *mut c_int) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_element_css_size( + target: *const c_char, width: c_double, + height: c_double) -> EMSCRIPTEN_RESULT; + + pub fn emscripten_get_element_css_size( + target: *const c_char, width: *mut c_double, + height: *mut c_double) -> EMSCRIPTEN_RESULT; + + pub fn emscripten_request_pointerlock( + target: *const c_char, deferUntilInEventHandler: EM_BOOL) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_exit_pointerlock() -> EMSCRIPTEN_RESULT; + + pub fn emscripten_request_fullscreen( + target: *const c_char, deferUntilInEventHandler: EM_BOOL) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_exit_fullscreen() -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_keydown_callback( + target: *const c_char, userData: *mut c_void, + useCapture: EM_BOOL, callback: em_key_callback_func) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_keyup_callback( + target: *const c_char, userData: *mut c_void, + useCapture: EM_BOOL, callback: em_key_callback_func) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_mousemove_callback( + target: *const c_char, user_data: *mut c_void, + use_capture: EM_BOOL, callback: em_mouse_callback_func) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_mousedown_callback( + target: *const c_char, user_data: *mut c_void, + use_capture: EM_BOOL, callback: em_mouse_callback_func) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_mouseup_callback( + target: *const c_char, user_data: *mut c_void, + use_capture: EM_BOOL, callback: em_mouse_callback_func) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_hide_mouse(); + + pub fn emscripten_get_device_pixel_ratio() -> f64; + + pub fn emscripten_set_pointerlockchange_callback( + target: *const c_char, userData: *mut c_void, useCapture: EM_BOOL, + callback: em_pointerlockchange_callback_func) -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_fullscreenchange_callback( + target: *const c_char, userData: *mut c_void, useCapture: EM_BOOL, + callback: em_fullscreenchange_callback_func) -> EMSCRIPTEN_RESULT; + + pub fn emscripten_asm_const(code: *const c_char); + + pub fn emscripten_set_main_loop( + func: em_callback_func, fps: c_int, simulate_infinite_loop: EM_BOOL); + + pub fn emscripten_cancel_main_loop(); + + pub fn emscripten_set_touchstart_callback( + target: *const c_char, userData: *mut c_void, + useCapture: c_int, callback: em_touch_callback_func) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_touchend_callback( + target: *const c_char, userData: *mut c_void, + useCapture: c_int, callback: em_touch_callback_func) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_touchmove_callback( + target: *const c_char, userData: *mut c_void, + useCapture: c_int, callback: em_touch_callback_func) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_touchcancel_callback( + target: *const c_char, userData: *mut c_void, + useCapture: c_int, callback: em_touch_callback_func) + -> EMSCRIPTEN_RESULT; +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/emscripten/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/emscripten/mod.rs new file mode 100644 index 0000000..3a5feb6 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/emscripten/mod.rs @@ -0,0 +1,1135 @@ +#![cfg(target_os = "emscripten")] + +mod ffi; + +use std::{mem, ptr, str}; +use std::cell::RefCell; +use std::collections::VecDeque; +use std::os::raw::{c_char, c_void, c_double, c_ulong, c_int}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Mutex, Arc}; + +use dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize}; +use window::MonitorId as RootMonitorId; + +const DOCUMENT_NAME: &'static str = "#document\0"; + +fn get_hidpi_factor() -> f64 { + unsafe { ffi::emscripten_get_device_pixel_ratio() as f64 } +} + +#[derive(Clone, Default)] +pub struct PlatformSpecificWindowBuilderAttributes; + +unsafe impl Send for PlatformSpecificWindowBuilderAttributes {} +unsafe impl Sync for PlatformSpecificWindowBuilderAttributes {} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct DeviceId; + +impl DeviceId { + pub unsafe fn dummy() -> Self { + DeviceId + } +} + +#[derive(Clone, Default)] +pub struct PlatformSpecificHeadlessBuilderAttributes; + +#[derive(Debug, Clone)] +pub struct MonitorId; + +impl MonitorId { + #[inline] + pub fn get_name(&self) -> Option<String> { + Some("Canvas".to_owned()) + } + + #[inline] + pub fn get_position(&self) -> PhysicalPosition { + unimplemented!() + } + + #[inline] + pub fn get_dimensions(&self) -> PhysicalSize { + (0, 0).into() + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + get_hidpi_factor() + } +} + +// Used to assign a callback to emscripten main loop +thread_local!(static MAIN_LOOP_CALLBACK: RefCell<*mut c_void> = RefCell::new(ptr::null_mut())); + +// Used to assign a callback to emscripten main loop +pub fn set_main_loop_callback<F>(callback : F) where F : FnMut() { + MAIN_LOOP_CALLBACK.with(|log| { + *log.borrow_mut() = &callback as *const _ as *mut c_void; + }); + + unsafe { ffi::emscripten_set_main_loop(Some(wrapper::<F>), 0, 1); } + + unsafe extern "C" fn wrapper<F>() where F : FnMut() { + MAIN_LOOP_CALLBACK.with(|z| { + let closure = *z.borrow_mut() as *mut F; + (*closure)(); + }); + } +} + +#[derive(Clone)] +pub struct EventsLoopProxy; + +impl EventsLoopProxy { + pub fn wakeup(&self) -> Result<(), ::EventsLoopClosed> { + unimplemented!() + } +} + +pub struct EventsLoop { + window: Mutex<Option<Arc<Window2>>>, + interrupted: AtomicBool, +} + +impl EventsLoop { + pub fn new() -> EventsLoop { + EventsLoop { + window: Mutex::new(None), + interrupted: AtomicBool::new(false), + } + } + + #[inline] + pub fn interrupt(&self) { + self.interrupted.store(true, Ordering::Relaxed); + } + + #[inline] + pub fn create_proxy(&self) -> EventsLoopProxy { + unimplemented!() + } + + #[inline] + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + let mut list = VecDeque::with_capacity(1); + list.push_back(MonitorId); + list + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + MonitorId + } + + pub fn poll_events<F>(&self, mut callback: F) + where F: FnMut(::Event) + { + let ref mut window = *self.window.lock().unwrap(); + if let &mut Some(ref mut window) = window { + while let Some(event) = window.events.lock().unwrap().pop_front() { + callback(event) + } + } + } + + pub fn run_forever<F>(&self, mut callback: F) + where F: FnMut(::Event) -> ::ControlFlow + { + self.interrupted.store(false, Ordering::Relaxed); + + // TODO: handle control flow + + set_main_loop_callback(|| { + self.poll_events(|e| { callback(e); }); + ::std::thread::sleep(::std::time::Duration::from_millis(5)); + if self.interrupted.load(Ordering::Relaxed) { + unsafe { ffi::emscripten_cancel_main_loop(); } + } + }); + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct WindowId(usize); + +impl WindowId { + pub unsafe fn dummy() -> Self { + WindowId(0) + } +} + +pub struct Window2 { + cursor_grabbed: Mutex<bool>, + cursor_hidden: Mutex<bool>, + is_fullscreen: bool, + events: Box<Mutex<VecDeque<::Event>>>, +} + +pub struct Window { + window: Arc<Window2>, +} + +fn show_mouse() { + // Hide mouse hasn't show mouse equivalent. + // There is a pull request on emscripten that hasn't been merged #4616 + // that contains: + // + // var styleSheet = document.styleSheets[0]; + // var rules = styleSheet.cssRules; + // for (var i = 0; i < rules.length; i++) { + // if (rules[i].cssText.substr(0, 6) == 'canvas') { + // styleSheet.deleteRule(i); + // i--; + // } + // } + // styleSheet.insertRule('canvas.emscripten { border: none; cursor: auto; }', 0); + unsafe { + ffi::emscripten_asm_const(b"var styleSheet = document.styleSheets[0]; var rules = styleSheet.cssRules; for (var i = 0; i < rules.length; i++) { if (rules[i].cssText.substr(0, 6) == 'canvas') { styleSheet.deleteRule(i); i--; } } styleSheet.insertRule('canvas.emscripten { border: none; cursor: auto; }', 0);\0".as_ptr() as *const c_char); + } +} + +extern "C" fn mouse_callback( + event_type: c_int, + event: *const ffi::EmscriptenMouseEvent, + event_queue: *mut c_void) -> ffi::EM_BOOL +{ + unsafe { + let queue: &Mutex<VecDeque<::Event>> = mem::transmute(event_queue); + + let modifiers = ::ModifiersState { + shift: (*event).shiftKey == ffi::EM_TRUE, + ctrl: (*event).ctrlKey == ffi::EM_TRUE, + alt: (*event).altKey == ffi::EM_TRUE, + logo: (*event).metaKey == ffi::EM_TRUE, + }; + + match event_type { + ffi::EMSCRIPTEN_EVENT_MOUSEMOVE => { + let dpi_factor = get_hidpi_factor(); + let position = LogicalPosition::from_physical( + ((*event).canvasX as f64, (*event).canvasY as f64), + dpi_factor, + ); + queue.lock().unwrap().push_back(::Event::WindowEvent { + window_id: ::WindowId(WindowId(0)), + event: ::WindowEvent::CursorMoved { + device_id: ::DeviceId(DeviceId), + position, + modifiers: modifiers, + } + }); + queue.lock().unwrap().push_back(::Event::DeviceEvent { + device_id: ::DeviceId(DeviceId), + event: ::DeviceEvent::MouseMotion { + delta: ((*event).movementX as f64, (*event).movementY as f64), + } + }); + }, + mouse_input @ ffi::EMSCRIPTEN_EVENT_MOUSEDOWN | + mouse_input @ ffi::EMSCRIPTEN_EVENT_MOUSEUP => { + let button = match (*event).button { + 0 => ::MouseButton::Left, + 1 => ::MouseButton::Middle, + 2 => ::MouseButton::Right, + other => ::MouseButton::Other(other as u8), + }; + let state = match mouse_input { + ffi::EMSCRIPTEN_EVENT_MOUSEDOWN => ::ElementState::Pressed, + ffi::EMSCRIPTEN_EVENT_MOUSEUP => ::ElementState::Released, + _ => unreachable!(), + }; + queue.lock().unwrap().push_back(::Event::WindowEvent { + window_id: ::WindowId(WindowId(0)), + event: ::WindowEvent::MouseInput { + device_id: ::DeviceId(DeviceId), + state: state, + button: button, + modifiers: modifiers, + } + }) + }, + _ => { + } + } + } + ffi::EM_FALSE +} + +extern "C" fn keyboard_callback( + event_type: c_int, + event: *const ffi::EmscriptenKeyboardEvent, + event_queue: *mut c_void) -> ffi::EM_BOOL +{ + unsafe { + let queue: &Mutex<VecDeque<::Event>> = mem::transmute(event_queue); + + let modifiers = ::ModifiersState { + shift: (*event).shiftKey == ffi::EM_TRUE, + ctrl: (*event).ctrlKey == ffi::EM_TRUE, + alt: (*event).altKey == ffi::EM_TRUE, + logo: (*event).metaKey == ffi::EM_TRUE, + }; + + match event_type { + ffi::EMSCRIPTEN_EVENT_KEYDOWN => { + queue.lock().unwrap().push_back(::Event::WindowEvent { + window_id: ::WindowId(WindowId(0)), + event: ::WindowEvent::KeyboardInput { + device_id: ::DeviceId(DeviceId), + input: ::KeyboardInput { + scancode: key_translate((*event).key) as u32, + state: ::ElementState::Pressed, + virtual_keycode: key_translate_virt((*event).key, (*event).location), + modifiers, + }, + }, + }); + }, + ffi::EMSCRIPTEN_EVENT_KEYUP => { + queue.lock().unwrap().push_back(::Event::WindowEvent { + window_id: ::WindowId(WindowId(0)), + event: ::WindowEvent::KeyboardInput { + device_id: ::DeviceId(DeviceId), + input: ::KeyboardInput { + scancode: key_translate((*event).key) as u32, + state: ::ElementState::Released, + virtual_keycode: key_translate_virt((*event).key, (*event).location), + modifiers, + }, + }, + }); + }, + _ => { + } + } + } + ffi::EM_FALSE +} + +extern fn touch_callback( + event_type: c_int, + event: *const ffi::EmscriptenTouchEvent, + event_queue: *mut c_void) -> ffi::EM_BOOL +{ + unsafe { + let queue: &Mutex<VecDeque<::Event>> = mem::transmute(event_queue); + + let phase = match event_type { + ffi::EMSCRIPTEN_EVENT_TOUCHSTART => ::TouchPhase::Started, + ffi::EMSCRIPTEN_EVENT_TOUCHEND => ::TouchPhase::Ended, + ffi::EMSCRIPTEN_EVENT_TOUCHMOVE => ::TouchPhase::Moved, + ffi::EMSCRIPTEN_EVENT_TOUCHCANCEL => ::TouchPhase::Cancelled, + _ => return ffi::EM_FALSE, + }; + + for touch in 0..(*event).numTouches as usize { + let touch = (*event).touches[touch]; + if touch.isChanged == ffi::EM_TRUE { + let dpi_factor = get_hidpi_factor(); + let location = LogicalPosition::from_physical( + (touch.canvasX as f64, touch.canvasY as f64), + dpi_factor, + ); + queue.lock().unwrap().push_back(::Event::WindowEvent { + window_id: ::WindowId(WindowId(0)), + event: ::WindowEvent::Touch(::Touch { + device_id: ::DeviceId(DeviceId), + phase, + id: touch.identifier as u64, + location, + }), + }); + } + } + } + ffi::EM_FALSE +} + +// In case of fullscreen window this method will request fullscreen on change +#[allow(non_snake_case)] +unsafe extern "C" fn fullscreen_callback( + _eventType: c_int, + _fullscreenChangeEvent: *const ffi::EmscriptenFullscreenChangeEvent, + _userData: *mut c_void) -> ffi::EM_BOOL +{ + ffi::emscripten_request_fullscreen(ptr::null(), ffi::EM_TRUE); + ffi::EM_FALSE +} + +// In case of pointer grabbed this method will request pointer lock on change +#[allow(non_snake_case)] +unsafe extern "C" fn pointerlockchange_callback( + _eventType: c_int, + _pointerlockChangeEvent: *const ffi::EmscriptenPointerlockChangeEvent, + _userData: *mut c_void) -> ffi::EM_BOOL +{ + ffi::emscripten_request_pointerlock(ptr::null(), ffi::EM_TRUE); + ffi::EM_FALSE +} + +fn em_try(res: ffi::EMSCRIPTEN_RESULT) -> Result<(), String> { + match res { + ffi::EMSCRIPTEN_RESULT_SUCCESS | ffi::EMSCRIPTEN_RESULT_DEFERRED => Ok(()), + r @ _ => Err(error_to_str(r).to_string()), + } +} + +impl Window { + pub fn new(events_loop: &EventsLoop, attribs: ::WindowAttributes, + _pl_attribs: PlatformSpecificWindowBuilderAttributes) + -> Result<Window, ::CreationError> + { + if events_loop.window.lock().unwrap().is_some() { + return Err(::CreationError::OsError("Cannot create another window".to_owned())); + } + + let w = Window2 { + cursor_grabbed: Default::default(), + cursor_hidden: Default::default(), + events: Default::default(), + is_fullscreen: attribs.fullscreen.is_some(), + }; + + let window = Window { + window: Arc::new(w), + }; + + + // TODO: set up more event callbacks + unsafe { + em_try(ffi::emscripten_set_mousemove_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(mouse_callback))) + .map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?; + em_try(ffi::emscripten_set_mousedown_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(mouse_callback))) + .map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?; + em_try(ffi::emscripten_set_mouseup_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(mouse_callback))) + .map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?; + em_try(ffi::emscripten_set_keydown_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(keyboard_callback))) + .map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?; + em_try(ffi::emscripten_set_keyup_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(keyboard_callback))) + .map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?; + em_try(ffi::emscripten_set_touchstart_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(touch_callback))) + .map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?; + em_try(ffi::emscripten_set_touchend_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(touch_callback))) + .map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?; + em_try(ffi::emscripten_set_touchmove_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(touch_callback))) + .map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?; + em_try(ffi::emscripten_set_touchcancel_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(touch_callback))) + .map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?; + } + + if attribs.fullscreen.is_some() { + unsafe { + em_try(ffi::emscripten_request_fullscreen(ptr::null(), ffi::EM_TRUE)) + .map_err(|e| ::CreationError::OsError(e))?; + em_try(ffi::emscripten_set_fullscreenchange_callback(ptr::null(), 0 as *mut c_void, ffi::EM_FALSE, Some(fullscreen_callback))) + .map_err(|e| ::CreationError::OsError(e))?; + } + } else if let Some(size) = attribs.dimensions { + window.set_inner_size(size); + } + + *events_loop.window.lock().unwrap() = Some(window.window.clone()); + Ok(window) + } + + #[inline] + pub fn id(&self) -> WindowId { + WindowId(0) + } + + #[inline] + pub fn set_title(&self, _title: &str) { + } + + #[inline] + pub fn get_position(&self) -> Option<LogicalPosition> { + Some((0, 0).into()) + } + + #[inline] + pub fn get_inner_position(&self) -> Option<LogicalPosition> { + Some((0, 0).into()) + } + + #[inline] + pub fn set_position(&self, _: LogicalPosition) { + } + + #[inline] + pub fn get_inner_size(&self) -> Option<LogicalSize> { + unsafe { + let mut width = 0; + let mut height = 0; + let mut fullscreen = 0; + + if ffi::emscripten_get_canvas_size(&mut width, &mut height, &mut fullscreen) + != ffi::EMSCRIPTEN_RESULT_SUCCESS + { + None + } else { + let dpi_factor = self.get_hidpi_factor(); + let logical = LogicalSize::from_physical((width as u32, height as u32), dpi_factor); + Some(logical) + } + } + } + + #[inline] + pub fn get_outer_size(&self) -> Option<LogicalSize> { + self.get_inner_size() + } + + #[inline] + pub fn set_inner_size(&self, size: LogicalSize) { + unsafe { + let dpi_factor = self.get_hidpi_factor(); + let physical = PhysicalSize::from_logical(size, dpi_factor); + let (width, height): (u32, u32) = physical.into(); + ffi::emscripten_set_element_css_size( + ptr::null(), + width as c_double, + height as c_double, + ); + } + } + + #[inline] + pub fn set_min_dimensions(&self, _dimensions: Option<LogicalSize>) { + // N/A + } + + #[inline] + pub fn set_max_dimensions(&self, _dimensions: Option<LogicalSize>) { + // N/A + } + + #[inline] + pub fn set_resizable(&self, _resizable: bool) { + // N/A + } + + #[inline] + pub fn show(&self) { + // N/A + } + + #[inline] + pub fn hide(&self) { + // N/A + } + + #[inline] + pub fn set_cursor(&self, _cursor: ::MouseCursor) { + // N/A + } + + #[inline] + pub fn grab_cursor(&self, grab: bool) -> Result<(), String> { + let mut grabbed_lock = self.window.cursor_grabbed.lock().unwrap(); + if grab == *grabbed_lock { return Ok(()); } + unsafe { + if grab { + em_try(ffi::emscripten_set_pointerlockchange_callback( + ptr::null(), + 0 as *mut c_void, + ffi::EM_FALSE, + Some(pointerlockchange_callback), + ))?; + em_try(ffi::emscripten_request_pointerlock(ptr::null(), ffi::EM_TRUE))?; + } else { + em_try(ffi::emscripten_set_pointerlockchange_callback( + ptr::null(), + 0 as *mut c_void, + ffi::EM_FALSE, + None, + ))?; + em_try(ffi::emscripten_exit_pointerlock())?; + } + } + *grabbed_lock = grab; + Ok(()) + } + + #[inline] + pub fn hide_cursor(&self, hide: bool) { + let mut hidden_lock = self.window.cursor_hidden.lock().unwrap(); + if hide == *hidden_lock { return; } + if hide { + unsafe { ffi::emscripten_hide_mouse() }; + } else { + show_mouse(); + } + *hidden_lock = hide; + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + get_hidpi_factor() + } + + #[inline] + pub fn set_cursor_position(&self, _position: LogicalPosition) -> Result<(), String> { + Err("Setting cursor position is not possible on Emscripten.".to_owned()) + } + + #[inline] + pub fn set_maximized(&self, _maximized: bool) { + // iOS has single screen maximized apps so nothing to do + } + + #[inline] + pub fn set_fullscreen(&self, _monitor: Option<::MonitorId>) { + // iOS has single screen maximized apps so nothing to do + } + + #[inline] + pub fn set_decorations(&self, _decorations: bool) { + // N/A + } + + #[inline] + pub fn set_always_on_top(&self, _always_on_top: bool) { + // N/A + } + + #[inline] + pub fn set_window_icon(&self, _icon: Option<::Icon>) { + // N/A + } + + #[inline] + pub fn set_ime_spot(&self, _logical_spot: LogicalPosition) { + // N/A + } + + #[inline] + pub fn get_current_monitor(&self) -> RootMonitorId { + RootMonitorId { inner: MonitorId } + } + + #[inline] + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + let mut list = VecDeque::with_capacity(1); + list.push_back(MonitorId); + list + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + MonitorId + } +} + +impl Drop for Window { + fn drop(&mut self) { + // Delete window from events_loop + // TODO: ? + /*if let Some(ev) = self.events_loop.upgrade() { + let _ = ev.window.lock().unwrap().take().unwrap(); + }*/ + + unsafe { + // Return back to normal cursor state + self.hide_cursor(false); + self.grab_cursor(false); + + // Exit fullscreen if on + if self.window.is_fullscreen { + ffi::emscripten_set_fullscreenchange_callback(ptr::null(), 0 as *mut c_void, ffi::EM_FALSE, None); + ffi::emscripten_exit_fullscreen(); + } + + // Delete callbacks + ffi::emscripten_set_keydown_callback(DOCUMENT_NAME.as_ptr() as *const c_char, 0 as *mut c_void, ffi::EM_FALSE,None); + ffi::emscripten_set_keyup_callback(DOCUMENT_NAME.as_ptr() as *const c_char, 0 as *mut c_void, ffi::EM_FALSE,None); + } + } +} + +fn error_to_str(code: ffi::EMSCRIPTEN_RESULT) -> &'static str { + match code { + ffi::EMSCRIPTEN_RESULT_SUCCESS | ffi::EMSCRIPTEN_RESULT_DEFERRED + => "Internal error in the library (success detected as failure)", + + ffi::EMSCRIPTEN_RESULT_NOT_SUPPORTED => "Not supported", + ffi::EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED => "Failed not deferred", + ffi::EMSCRIPTEN_RESULT_INVALID_TARGET => "Invalid target", + ffi::EMSCRIPTEN_RESULT_UNKNOWN_TARGET => "Unknown target", + ffi::EMSCRIPTEN_RESULT_INVALID_PARAM => "Invalid parameter", + ffi::EMSCRIPTEN_RESULT_FAILED => "Failed", + ffi::EMSCRIPTEN_RESULT_NO_DATA => "No data", + + _ => "Undocumented error" + } +} + +fn key_translate(input: [ffi::EM_UTF8; ffi::EM_HTML5_SHORT_STRING_LEN_BYTES]) -> u8 { + let slice = &input[0..input.iter().take_while(|x| **x != 0).count()]; + let maybe_key = unsafe { str::from_utf8(mem::transmute::<_, &[u8]>(slice)) }; + let key = match maybe_key { + Ok(key) => key, + Err(_) => { return 0; }, + }; + if key.chars().count() == 1 { + key.as_bytes()[0] + } else { + 0 + } +} + +fn key_translate_virt(input: [ffi::EM_UTF8; ffi::EM_HTML5_SHORT_STRING_LEN_BYTES], + location: c_ulong) -> Option<::VirtualKeyCode> +{ + let slice = &input[0..input.iter().take_while(|x| **x != 0).count()]; + let maybe_key = unsafe { str::from_utf8(mem::transmute::<_, &[u8]>(slice)) }; + let key = match maybe_key { + Ok(key) => key, + Err(_) => { return None; }, + }; + use VirtualKeyCode::*; + match key { + "Alt" => match location { + ffi::DOM_KEY_LOCATION_LEFT => Some(LAlt), + ffi::DOM_KEY_LOCATION_RIGHT => Some(RAlt), + _ => None, + }, + "AltGraph" => None, + "CapsLock" => None, + "Control" => match location { + ffi::DOM_KEY_LOCATION_LEFT => Some(LControl), + ffi::DOM_KEY_LOCATION_RIGHT => Some(RControl), + _ => None, + }, + "Fn" => None, + "FnLock" => None, + "Hyper" => None, + "Meta" => None, + "NumLock" => Some(Numlock), + "ScrollLock" => Some(Scroll), + "Shift" => match location { + ffi::DOM_KEY_LOCATION_LEFT => Some(LShift), + ffi::DOM_KEY_LOCATION_RIGHT => Some(RShift), + _ => None, + }, + "Super" => None, + "Symbol" => None, + "SymbolLock" => None, + + "Enter" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(NumpadEnter), + _ => Some(Return), + }, + "Tab" => Some(Tab), + " " => Some(Space), + + "ArrowDown" => Some(Down), + "ArrowLeft" => Some(Left), + "ArrowRight" => Some(Right), + "ArrowUp" => Some(Up), + "End" => None, + "Home" => None, + "PageDown" => None, + "PageUp" => None, + + "Backspace" => Some(Back), + "Clear" => None, + "Copy" => None, + "CrSel" => None, + "Cut" => None, + "Delete" => None, + "EraseEof" => None, + "ExSel" => None, + "Insert" => Some(Insert), + "Paste" => None, + "Redo" => None, + "Undo" => None, + + "Accept" => None, + "Again" => None, + "Attn" => None, + "Cancel" => None, + "ContextMenu" => None, + "Escape" => Some(Escape), + "Execute" => None, + "Find" => None, + "Finish" => None, + "Help" => None, + "Pause" => Some(Pause), + "Play" => None, + "Props" => None, + "Select" => None, + "ZoomIn" => None, + "ZoomOut" => None, + + "BrightnessDown" => None, + "BrightnessUp" => None, + "Eject" => None, + "LogOff" => None, + "Power" => Some(Power), + "PowerOff" => None, + "PrintScreen" => Some(Snapshot), + "Hibernate" => None, + "Standby" => Some(Sleep), + "WakeUp" => Some(Wake), + + "AllCandidates" => None, + "Alphanumeric" => None, + "CodeInput" => None, + "Compose" => Some(Compose), + "Convert" => Some(Convert), + "Dead" => None, + "FinalMode" => None, + "GroupFirst" => None, + "GroupLast" => None, + "GroupNext" => None, + "GroupPrevious" => None, + "ModeChange" => None, + "NextCandidate" => None, + "NonConvert" => None, + "PreviousCandidate" => None, + "Process" => None, + "SingleCandidate" => None, + + "HangulMode" => None, + "HanjaMode" => None, + "JunjaMode" => None, + + "Eisu" => None, + "Hankaku" => None, + "Hiragana" => None, + "HiraganaKatakana" => None, + "KanaMode" => Some(Kana), + "KanjiMode" => Some(Kanji), + "Romaji" => None, + "Zenkaku" => None, + "ZenkakuHanaku" => None, + + "F1" => Some(F1), + "F2" => Some(F2), + "F3" => Some(F3), + "F4" => Some(F4), + "F5" => Some(F5), + "F6" => Some(F6), + "F7" => Some(F7), + "F8" => Some(F8), + "F9" => Some(F9), + "F10" => Some(F10), + "F11" => Some(F11), + "F12" => Some(F12), + "F13" => Some(F13), + "F14" => Some(F14), + "F15" => Some(F15), + "F16" => Some(F16), + "F17" => Some(F17), + "F18" => Some(F18), + "F19" => Some(F19), + "F20" => Some(F20), + "F21" => Some(F21), + "F22" => Some(F22), + "F23" => Some(F23), + "F24" => Some(F24), + "Soft1" => None, + "Soft2" => None, + "Soft3" => None, + "Soft4" => None, + + "AppSwitch" => None, + "Call" => None, + "Camera" => None, + "CameraFocus" => None, + "EndCall" => None, + "GoBack" => None, + "GoHome" => None, + "HeadsetHook" => None, + "LastNumberRedial" => None, + "Notification" => None, + "MannerMode" => None, + "VoiceDial" => None, + + "ChannelDown" => None, + "ChannelUp" => None, + "MediaFastForward" => None, + "MediaPause" => None, + "MediaPlay" => None, + "MediaPlayPause" => Some(PlayPause), + "MediaRecord" => None, + "MediaRewind" => None, + "MediaStop" => Some(MediaStop), + "MediaTrackNext" => Some(NextTrack), + "MediaTrackPrevious" => Some(PrevTrack), + + "AudioBalanceLeft" => None, + "AudioBalanceRight" => None, + "AudioBassDown" => None, + "AudioBassBoostDown" => None, + "AudioBassBoostToggle" => None, + "AudioBassBoostUp" => None, + "AudioBassUp" => None, + "AudioFaderFront" => None, + "AudioFaderRear" => None, + "AudioSurroundModeNext" => None, + "AudioTrebleDown" => None, + "AudioTrebleUp" => None, + "AudioVolumeDown" => Some(VolumeDown), + "AudioVolumeMute" => Some(Mute), + "AudioVolumeUp" => Some(VolumeUp), + "MicrophoneToggle" => None, + "MicrophoneVolumeDown" => None, + "MicrophoneVolumeMute" => None, + "MicrophoneVolumeUp" => None, + + "TV" => None, + "TV3DMode" => None, + "TVAntennaCable" => None, + "TVAudioDescription" => None, + "TVAudioDescriptionMixDown" => None, + "TVAudioDescriptionMixUp" => None, + "TVContentsMenu" => None, + "TVDataService" => None, + "TVInput" => None, + "TVInputComponent1" => None, + "TVInputComponent2" => None, + "TVInputComposite1" => None, + "TVInputComposite2" => None, + "TVInputHDM1" => None, + "TVInputHDM2" => None, + "TVInputHDM3" => None, + "TVInputHDM4" => None, + "TVInputVGA1" => None, + "TVMediaContext" => None, + "TVNetwork" => None, + "TVNumberEntry" => None, + "TVPower" => None, + "TVRadioService" => None, + "TVSatellite" => None, + "TVSatelliteBS" => None, + "TVSatelliteCS" => None, + "TVSatelliteToggle" => None, + "TVTerrestrialAnalog" => None, + "TVTerrestrialDigital" => None, + "TVTimer" => None, + + "AVRInput" => None, + "AVRPower" => None, + "ColorF0Red" => None, + "ColorF1Green" => None, + "ColorF2Yellow" => None, + "ColorF3Blue" => None, + "ColorF4Grey" => None, + "ColorF5Brown" => None, + "ClosedCaptionToggle" => None, + "Dimmer" => None, + "DisplaySwap" => None, + "DVR" => None, + "Exit" => None, + "FavoriteClear0" => None, + "FavoriteClear1" => None, + "FavoriteClear2" => None, + "FavoriteClear3" => None, + "FavoriteRecall0" => None, + "FavoriteRecall1" => None, + "FavoriteRecall2" => None, + "FavoriteRecall3" => None, + "FavoriteStore0" => None, + "FavoriteStore1" => None, + "FavoriteStore2" => None, + "FavoriteStore3" => None, + "FavoriteStore4" => None, + "Guide" => None, + "GuideNextDay" => None, + "GuidePreviousDay" => None, + "Info" => None, + "InstantReplay" => None, + "Link" => None, + "ListProgram" => None, + "LiveContent" => None, + "Lock" => None, + "MediaApps" => None, + "MediaAudioTrack" => None, + "MediaLast" => None, + "MediaSkipBackward" => None, + "MediaSkipForward" => None, + "MediaStepBackward" => None, + "MediaStepForward" => None, + "MediaTopMenu" => None, + "NavigateIn" => None, + "NavigateNext" => None, + "NavigateOut" => None, + "NavigatePrevious" => None, + "NextFavoriteChannel" => None, + "NextUserProfile" => None, + "OnDemand" => None, + "Pairing" => None, + "PinPDown" => None, + "PinPMove" => None, + "PinPToggle" => None, + "PinPUp" => None, + "PlaySpeedDown" => None, + "PlaySpeedReset" => None, + "PlaySpeedUp" => None, + "RandomToggle" => None, + "RcLowBattery" => None, + "RecordSpeedNext" => None, + "RfBypass" => None, + "ScanChannelsToggle" => None, + "ScreenModeNext" => None, + "Settings" => None, + "SplitScreenToggle" => None, + "STBInput" => None, + "STBPower" => None, + "Subtitle" => None, + "Teletext" => None, + "VideoModeNext" => None, + "Wink" => None, + "ZoomToggle" => None, + + "SpeechCorrectionList" => None, + "SpeechInputToggle" => None, + + "Close" => None, + "New" => None, + "Open" => None, + "Print" => None, + "Save" => None, + "SpellCheck" => None, + "MailForward" => None, + "MailReply" => None, + "MailSend" => None, + + "LaunchCalculator" => Some(Calculator), + "LaunchCalendar" => None, + "LaunchContacts" => None, + "LaunchMail" => Some(Mail), + "LaunchMediaPlayer" => None, + "LaunchMusicPlayer" => None, + "LaunchMyComputer" => Some(MyComputer), + "LaunchPhone" => None, + "LaunchScreenSaver" => None, + "LaunchSpreadsheet" => None, + "LaunchWebCam" => None, + "LaunchWordProcessor" => None, + "LaunchApplication1" => None, + "LaunchApplication2" => None, + "LaunchApplication3" => None, + "LaunchApplication4" => None, + "LaunchApplication5" => None, + "LaunchApplication6" => None, + "LaunchApplication7" => None, + "LaunchApplication8" => None, + "LaunchApplication9" => None, + "LaunchApplication10" => None, + "LaunchApplication11" => None, + "LaunchApplication12" => None, + "LaunchApplication13" => None, + "LaunchApplication14" => None, + "LaunchApplication15" => None, + "LaunchApplication16" => None, + + "BrowserBack" => Some(WebBack), + "BrowserFavorites" => Some(WebFavorites), + "BrowserForward" => Some(WebForward), + "BrowserHome" => Some(WebHome), + "BrowserRefresh" => Some(WebRefresh), + "BrowserSearch" => Some(WebSearch), + "BrowserStop" => Some(WebStop), + + "Decimal" => Some(Decimal), + "Key11" => None, + "Key12" => None, + "Multiply" | "*" => Some(Multiply), + "Add" | "+" => Some(Add), + // "Clear" => None, + "Divide" => Some(Divide), + "Subtract" | "-" => Some(Subtract), + "Separator" => None, + "0" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad0), + _ => Some(Key0), + }, + "1" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad1), + _ => Some(Key1), + }, + "2" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad2), + _ => Some(Key2), + }, + "3" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad3), + _ => Some(Key3), + }, + "4" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad4), + _ => Some(Key4), + }, + "5" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad5), + _ => Some(Key5), + }, + "6" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad6), + _ => Some(Key6), + }, + "7" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad7), + _ => Some(Key7), + }, + "8" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad8), + _ => Some(Key8), + }, + "9" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad9), + _ => Some(Key9), + }, + + "A" | "a" => Some(A), + "B" | "b" => Some(B), + "C" | "c" => Some(C), + "D" | "d" => Some(D), + "E" | "e" => Some(E), + "F" | "f" => Some(F), + "G" | "g" => Some(G), + "H" | "h" => Some(H), + "I" | "i" => Some(I), + "J" | "j" => Some(J), + "K" | "k" => Some(K), + "L" | "l" => Some(L), + "M" | "m" => Some(M), + "N" | "n" => Some(N), + "O" | "o" => Some(O), + "P" | "p" => Some(P), + "Q" | "q" => Some(Q), + "R" | "r" => Some(R), + "S" | "s" => Some(S), + "T" | "t" => Some(T), + "U" | "u" => Some(U), + "V" | "v" => Some(V), + "W" | "w" => Some(W), + "X" | "x" => Some(X), + "Y" | "y" => Some(Y), + "Z" | "z" => Some(Z), + + "'" => Some(Apostrophe), + "\\" => Some(Backslash), + ":" => Some(Colon), + "," => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(NumpadComma), + _ => Some(Comma), + }, + "=" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(NumpadEquals), + _ => Some(Equals), + }, + "{" => Some(LBracket), + "." => Some(Period), + "}" => Some(RBracket), + ";" => Some(Semicolon), + "/" => Some(Slash), + + _ => None, + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/ios/ffi.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/ios/ffi.rs new file mode 100644 index 0000000..6fd1a7c --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/ios/ffi.rs @@ -0,0 +1,110 @@ +#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)] + +use std::ffi::CString; +use std::os::raw::*; + +use objc::runtime::Object; + +pub type id = *mut Object; +pub const nil: id = 0 as id; + +pub type CFStringRef = *const c_void; +pub type CFTimeInterval = f64; +pub type Boolean = u32; + +pub const kCFRunLoopRunHandledSource: i32 = 4; + +#[cfg(target_pointer_width = "32")] +pub type CGFloat = f32; +#[cfg(target_pointer_width = "64")] +pub type CGFloat = f64; + +#[repr(C)] +#[derive(Debug, Clone)] +pub struct CGPoint { + pub x: CGFloat, + pub y: CGFloat, +} + +#[repr(C)] +#[derive(Debug, Clone)] +pub struct CGRect { + pub origin: CGPoint, + pub size: CGSize, +} + +#[repr(C)] +#[derive(Debug, Clone)] +pub struct CGSize { + pub width: CGFloat, + pub height: CGFloat, +} + +#[link(name = "UIKit", kind = "framework")] +#[link(name = "CoreFoundation", kind = "framework")] +#[link(name = "GlKit", kind = "framework")] +extern { + pub static kCFRunLoopDefaultMode: CFStringRef; + + // int UIApplicationMain ( int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName ); + pub fn UIApplicationMain( + argc: c_int, + argv: *const c_char, + principalClassName: id, + delegateClassName: id, + ) -> c_int; + + // SInt32 CFRunLoopRunInMode ( CFStringRef mode, CFTimeInterval seconds, Boolean returnAfterSourceHandled ); + pub fn CFRunLoopRunInMode( + mode: CFStringRef, + seconds: CFTimeInterval, + returnAfterSourceHandled: Boolean, + ) -> i32; +} + +extern { + pub fn setjmp(env: *mut c_void) -> c_int; + pub fn longjmp(env: *mut c_void, val: c_int) -> !; +} + +// values taken from "setjmp.h" header in xcode iPhoneOS/iPhoneSimulator SDK +#[cfg(any(target_arch = "x86_64"))] +pub const JBLEN: usize = (9 * 2) + 3 + 16; +#[cfg(any(target_arch = "x86"))] +pub const JBLEN: usize = 18; +#[cfg(target_arch = "arm")] +pub const JBLEN: usize = 10 + 16 + 2; +#[cfg(target_arch = "aarch64")] +pub const JBLEN: usize = (14 + 8 + 2) * 2; + +pub type JmpBuf = [c_int; JBLEN]; + +pub trait NSString: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSString), alloc] + } + + unsafe fn initWithUTF8String_(self, c_string: *const c_char) -> id; + unsafe fn stringByAppendingString_(self, other: id) -> id; + unsafe fn init_str(self, string: &str) -> Self; + unsafe fn UTF8String(self) -> *const c_char; +} + +impl NSString for id { + unsafe fn initWithUTF8String_(self, c_string: *const c_char) -> id { + msg_send![self, initWithUTF8String:c_string as id] + } + + unsafe fn stringByAppendingString_(self, other: id) -> id { + msg_send![self, stringByAppendingString:other] + } + + unsafe fn init_str(self, string: &str) -> id { + let cstring = CString::new(string).unwrap(); + self.initWithUTF8String_(cstring.as_ptr()) + } + + unsafe fn UTF8String(self) -> *const c_char { + msg_send![self, UTF8String] + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/ios/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/ios/mod.rs new file mode 100644 index 0000000..6830ace --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/ios/mod.rs @@ -0,0 +1,702 @@ +//! iOS support +//! +//! # Building app +//! To build ios app you will need rustc built for this targets: +//! +//! - armv7-apple-ios +//! - armv7s-apple-ios +//! - i386-apple-ios +//! - aarch64-apple-ios +//! - x86_64-apple-ios +//! +//! Then +//! +//! ``` +//! cargo build --target=... +//! ``` +//! The simplest way to integrate your app into xcode environment is to build it +//! as a static library. Wrap your main function and export it. +//! +//! ```rust, ignore +//! #[no_mangle] +//! pub extern fn start_winit_app() { +//! start_inner() +//! } +//! +//! fn start_inner() { +//! ... +//! } +//! +//! ``` +//! +//! Compile project and then drag resulting .a into Xcode project. Add winit.h to xcode. +//! +//! ```ignore +//! void start_winit_app(); +//! ``` +//! +//! Use start_winit_app inside your xcode's main function. +//! +//! +//! # App lifecycle and events +//! +//! iOS environment is very different from other platforms and you must be very +//! careful with it's events. Familiarize yourself with +//! [app lifecycle](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/). +//! +//! +//! This is how those event are represented in winit: +//! +//! - applicationDidBecomeActive is Focused(true) +//! - applicationWillResignActive is Focused(false) +//! - applicationDidEnterBackground is Suspended(true) +//! - applicationWillEnterForeground is Suspended(false) +//! - applicationWillTerminate is Destroyed +//! +//! Keep in mind that after Destroyed event is received every attempt to draw with +//! opengl will result in segfault. +//! +//! Also note that app will not receive Destroyed event if suspended, it will be SIGKILL'ed + +#![cfg(target_os = "ios")] + +use std::{fmt, mem, ptr}; +use std::cell::RefCell; +use std::collections::VecDeque; +use std::os::raw::*; +use std::sync::Arc; + +use objc::declare::ClassDecl; +use objc::runtime::{BOOL, Class, Object, Sel, YES}; + +use { + CreationError, + Event, + LogicalPosition, + LogicalSize, + MouseCursor, + PhysicalPosition, + PhysicalSize, + WindowAttributes, + WindowEvent, + WindowId as RootEventId, +}; +use events::{Touch, TouchPhase}; +use window::MonitorId as RootMonitorId; + +mod ffi; +use self::ffi::{ + CFTimeInterval, + CFRunLoopRunInMode, + CGFloat, + CGPoint, + CGRect, + id, + JBLEN, + JmpBuf, + kCFRunLoopDefaultMode, + kCFRunLoopRunHandledSource, + longjmp, + nil, + NSString, + setjmp, + UIApplicationMain, + }; + +static mut JMPBUF: Option<Box<JmpBuf>> = None; + +pub struct Window { + _events_queue: Arc<RefCell<VecDeque<Event>>>, + delegate_state: Box<DelegateState>, +} + +unsafe impl Send for Window {} +unsafe impl Sync for Window {} + +#[derive(Debug)] +struct DelegateState { + window: id, + controller: id, + view: id, + size: LogicalSize, + scale: f64, +} + +impl DelegateState { + fn new(window: id, controller: id, view: id, size: LogicalSize, scale: f64) -> DelegateState { + DelegateState { + window, + controller, + view, + size, + scale, + } + } +} + +impl Drop for DelegateState { + fn drop(&mut self) { + unsafe { + let _: () = msg_send![self.window, release]; + let _: () = msg_send![self.controller, release]; + let _: () = msg_send![self.view, release]; + } + } +} + +#[derive(Clone)] +pub struct MonitorId; + +impl fmt::Debug for MonitorId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[derive(Debug)] + struct MonitorId { + name: Option<String>, + dimensions: PhysicalSize, + position: PhysicalPosition, + hidpi_factor: f64, + } + + let monitor_id_proxy = MonitorId { + name: self.get_name(), + dimensions: self.get_dimensions(), + position: self.get_position(), + hidpi_factor: self.get_hidpi_factor(), + }; + + monitor_id_proxy.fmt(f) + } +} + +impl MonitorId { + #[inline] + pub fn get_uiscreen(&self) -> id { + let class = class!(UIScreen); + unsafe { msg_send![class, mainScreen] } + } + + #[inline] + pub fn get_name(&self) -> Option<String> { + Some("Primary".to_string()) + } + + #[inline] + pub fn get_dimensions(&self) -> PhysicalSize { + let bounds: CGRect = unsafe { msg_send![self.get_uiscreen(), nativeBounds] }; + (bounds.size.width as f64, bounds.size.height as f64).into() + } + + #[inline] + pub fn get_position(&self) -> PhysicalPosition { + // iOS assumes single screen + (0, 0).into() + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + let scale: CGFloat = unsafe { msg_send![self.get_uiscreen(), nativeScale] }; + scale as f64 + } +} + +pub struct EventsLoop { + events_queue: Arc<RefCell<VecDeque<Event>>>, +} + +#[derive(Clone)] +pub struct EventsLoopProxy; + +impl EventsLoop { + pub fn new() -> EventsLoop { + unsafe { + if !msg_send![class!(NSThread), isMainThread] { + panic!("`EventsLoop` can only be created on the main thread on iOS"); + } + } + EventsLoop { events_queue: Default::default() } + } + + #[inline] + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + let mut rb = VecDeque::with_capacity(1); + rb.push_back(MonitorId); + rb + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + MonitorId + } + + pub fn poll_events<F>(&mut self, mut callback: F) + where F: FnMut(::Event) + { + if let Some(event) = self.events_queue.borrow_mut().pop_front() { + callback(event); + return; + } + + unsafe { + // jump hack, so we won't quit on willTerminate event before processing it + assert!(JMPBUF.is_some(), "`EventsLoop::poll_events` must be called after window creation on iOS"); + if setjmp(mem::transmute_copy(&mut JMPBUF)) != 0 { + if let Some(event) = self.events_queue.borrow_mut().pop_front() { + callback(event); + return; + } + } + } + + unsafe { + // run runloop + let seconds: CFTimeInterval = 0.000002; + while CFRunLoopRunInMode(kCFRunLoopDefaultMode, seconds, 1) == kCFRunLoopRunHandledSource {} + } + + if let Some(event) = self.events_queue.borrow_mut().pop_front() { + callback(event) + } + } + + pub fn run_forever<F>(&mut self, mut callback: F) + where F: FnMut(::Event) -> ::ControlFlow, + { + // Yeah that's a very bad implementation. + loop { + let mut control_flow = ::ControlFlow::Continue; + self.poll_events(|e| { + if let ::ControlFlow::Break = callback(e) { + control_flow = ::ControlFlow::Break; + } + }); + if let ::ControlFlow::Break = control_flow { + break; + } + ::std::thread::sleep(::std::time::Duration::from_millis(5)); + } + } + + pub fn create_proxy(&self) -> EventsLoopProxy { + EventsLoopProxy + } +} + +impl EventsLoopProxy { + pub fn wakeup(&self) -> Result<(), ::EventsLoopClosed> { + unimplemented!() + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct WindowId; + +impl WindowId { + pub unsafe fn dummy() -> Self { + WindowId + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct DeviceId; + +impl DeviceId { + pub unsafe fn dummy() -> Self { + DeviceId + } +} + +#[derive(Clone)] +pub struct PlatformSpecificWindowBuilderAttributes { + pub root_view_class: &'static Class, +} + +impl Default for PlatformSpecificWindowBuilderAttributes { + fn default() -> Self { + PlatformSpecificWindowBuilderAttributes { + root_view_class: class!(UIView), + } + } +} + +// TODO: AFAIK transparency is enabled by default on iOS, +// so to be consistent with other platforms we have to change that. +impl Window { + pub fn new( + ev: &EventsLoop, + _attributes: WindowAttributes, + pl_attributes: PlatformSpecificWindowBuilderAttributes, + ) -> Result<Window, CreationError> { + unsafe { + debug_assert!(mem::size_of_val(&JMPBUF) == mem::size_of::<Box<JmpBuf>>()); + assert!(mem::replace(&mut JMPBUF, Some(Box::new([0; JBLEN]))).is_none(), "Only one `Window` is supported on iOS"); + } + + unsafe { + if setjmp(mem::transmute_copy(&mut JMPBUF)) != 0 { + let app_class = class!(UIApplication); + let app: id = msg_send![app_class, sharedApplication]; + let delegate: id = msg_send![app, delegate]; + let state: *mut c_void = *(&*delegate).get_ivar("winitState"); + let mut delegate_state = Box::from_raw(state as *mut DelegateState); + let events_queue = &*ev.events_queue; + (&mut *delegate).set_ivar("eventsQueue", mem::transmute::<_, *mut c_void>(events_queue)); + + // easiest? way to get access to PlatformSpecificWindowBuilderAttributes to configure the view + let rect: CGRect = msg_send![MonitorId.get_uiscreen(), bounds]; + + let uiview_class = class!(UIView); + let root_view_class = pl_attributes.root_view_class; + let is_uiview: BOOL = msg_send![root_view_class, isSubclassOfClass:uiview_class]; + assert!(is_uiview == YES, "`root_view_class` must inherit from `UIView`"); + + delegate_state.view = msg_send![root_view_class, alloc]; + assert!(!delegate_state.view.is_null(), "Failed to create `UIView` instance"); + delegate_state.view = msg_send![delegate_state.view, initWithFrame:rect]; + assert!(!delegate_state.view.is_null(), "Failed to initialize `UIView` instance"); + + let _: () = msg_send![delegate_state.controller, setView:delegate_state.view]; + let _: () = msg_send![delegate_state.window, makeKeyAndVisible]; + + return Ok(Window { + _events_queue: ev.events_queue.clone(), + delegate_state, + }); + } + } + + create_delegate_class(); + start_app(); + + panic!("Couldn't create `UIApplication`!") + } + + #[inline] + pub fn get_uiwindow(&self) -> id { + self.delegate_state.window + } + + #[inline] + pub fn get_uiview(&self) -> id { + self.delegate_state.view + } + + #[inline] + pub fn set_title(&self, _title: &str) { + // N/A + } + + #[inline] + pub fn show(&self) { + // N/A + } + + #[inline] + pub fn hide(&self) { + // N/A + } + + #[inline] + pub fn get_position(&self) -> Option<LogicalPosition> { + // N/A + None + } + + #[inline] + pub fn get_inner_position(&self) -> Option<LogicalPosition> { + // N/A + None + } + + #[inline] + pub fn set_position(&self, _position: LogicalPosition) { + // N/A + } + + #[inline] + pub fn get_inner_size(&self) -> Option<LogicalSize> { + Some(self.delegate_state.size) + } + + #[inline] + pub fn get_outer_size(&self) -> Option<LogicalSize> { + self.get_inner_size() + } + + #[inline] + pub fn set_inner_size(&self, _size: LogicalSize) { + // N/A + } + + #[inline] + pub fn set_min_dimensions(&self, _dimensions: Option<LogicalSize>) { + // N/A + } + + #[inline] + pub fn set_max_dimensions(&self, _dimensions: Option<LogicalSize>) { + // N/A + } + + #[inline] + pub fn set_resizable(&self, _resizable: bool) { + // N/A + } + + #[inline] + pub fn set_cursor(&self, _cursor: MouseCursor) { + // N/A + } + + #[inline] + pub fn grab_cursor(&self, _grab: bool) -> Result<(), String> { + Err("Cursor grabbing is not possible on iOS.".to_owned()) + } + + #[inline] + pub fn hide_cursor(&self, _hide: bool) { + // N/A + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + self.delegate_state.scale + } + + #[inline] + pub fn set_cursor_position(&self, _position: LogicalPosition) -> Result<(), String> { + Err("Setting cursor position is not possible on iOS.".to_owned()) + } + + #[inline] + pub fn set_maximized(&self, _maximized: bool) { + // N/A + // iOS has single screen maximized apps so nothing to do + } + + #[inline] + pub fn set_fullscreen(&self, _monitor: Option<RootMonitorId>) { + // N/A + // iOS has single screen maximized apps so nothing to do + } + + #[inline] + pub fn set_decorations(&self, _decorations: bool) { + // N/A + } + + #[inline] + pub fn set_always_on_top(&self, _always_on_top: bool) { + // N/A + } + + #[inline] + pub fn set_window_icon(&self, _icon: Option<::Icon>) { + // N/A + } + + #[inline] + pub fn set_ime_spot(&self, _logical_spot: LogicalPosition) { + // N/A + } + + #[inline] + pub fn get_current_monitor(&self) -> RootMonitorId { + RootMonitorId { inner: MonitorId } + } + + #[inline] + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + let mut rb = VecDeque::with_capacity(1); + rb.push_back(MonitorId); + rb + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + MonitorId + } + + #[inline] + pub fn id(&self) -> WindowId { + WindowId + } +} + +fn create_delegate_class() { + extern fn did_finish_launching(this: &mut Object, _: Sel, _: id, _: id) -> BOOL { + let screen_class = class!(UIScreen); + let window_class = class!(UIWindow); + let controller_class = class!(UIViewController); + unsafe { + let main_screen: id = msg_send![screen_class, mainScreen]; + let bounds: CGRect = msg_send![main_screen, bounds]; + let scale: CGFloat = msg_send![main_screen, nativeScale]; + + let window: id = msg_send![window_class, alloc]; + let window: id = msg_send![window, initWithFrame:bounds.clone()]; + + let size = (bounds.size.width as f64, bounds.size.height as f64).into(); + + let view_controller: id = msg_send![controller_class, alloc]; + let view_controller: id = msg_send![view_controller, init]; + + let _: () = msg_send![window, setRootViewController:view_controller]; + + let state = Box::new(DelegateState::new(window, view_controller, ptr::null_mut(), size, scale as f64)); + let state_ptr: *mut DelegateState = mem::transmute(state); + this.set_ivar("winitState", state_ptr as *mut c_void); + + // The `UIView` is setup in `Window::new` which gets `longjmp`'ed to here. + // This makes it easier to configure the specific `UIView` type. + let _: () = msg_send![this, performSelector:sel!(postLaunch:) withObject:nil afterDelay:0.0]; + } + YES + } + + extern fn post_launch(_: &Object, _: Sel, _: id) { + unsafe { longjmp(mem::transmute_copy(&mut JMPBUF), 1); } + } + + extern fn did_become_active(this: &Object, _: Sel, _: id) { + unsafe { + let events_queue: *mut c_void = *this.get_ivar("eventsQueue"); + let events_queue = &*(events_queue as *const RefCell<VecDeque<Event>>); + events_queue.borrow_mut().push_back(Event::WindowEvent { + window_id: RootEventId(WindowId), + event: WindowEvent::Focused(true), + }); + } + } + + extern fn will_resign_active(this: &Object, _: Sel, _: id) { + unsafe { + let events_queue: *mut c_void = *this.get_ivar("eventsQueue"); + let events_queue = &*(events_queue as *const RefCell<VecDeque<Event>>); + events_queue.borrow_mut().push_back(Event::WindowEvent { + window_id: RootEventId(WindowId), + event: WindowEvent::Focused(false), + }); + } + } + + extern fn will_enter_foreground(this: &Object, _: Sel, _: id) { + unsafe { + let events_queue: *mut c_void = *this.get_ivar("eventsQueue"); + let events_queue = &*(events_queue as *const RefCell<VecDeque<Event>>); + events_queue.borrow_mut().push_back(Event::Suspended(false)); + } + } + + extern fn did_enter_background(this: &Object, _: Sel, _: id) { + unsafe { + let events_queue: *mut c_void = *this.get_ivar("eventsQueue"); + let events_queue = &*(events_queue as *const RefCell<VecDeque<Event>>); + events_queue.borrow_mut().push_back(Event::Suspended(true)); + } + } + + extern fn will_terminate(this: &Object, _: Sel, _: id) { + unsafe { + let events_queue: *mut c_void = *this.get_ivar("eventsQueue"); + let events_queue = &*(events_queue as *const RefCell<VecDeque<Event>>); + // push event to the front to garantee that we'll process it + // immidiatly after jump + events_queue.borrow_mut().push_front(Event::WindowEvent { + window_id: RootEventId(WindowId), + event: WindowEvent::Destroyed, + }); + longjmp(mem::transmute_copy(&mut JMPBUF), 1); + } + } + + extern fn handle_touches(this: &Object, _: Sel, touches: id, _:id) { + unsafe { + let events_queue: *mut c_void = *this.get_ivar("eventsQueue"); + let events_queue = &*(events_queue as *const RefCell<VecDeque<Event>>); + + let touches_enum: id = msg_send![touches, objectEnumerator]; + + loop { + let touch: id = msg_send![touches_enum, nextObject]; + if touch == nil { + break + } + let location: CGPoint = msg_send![touch, locationInView:nil]; + let touch_id = touch as u64; + let phase: i32 = msg_send![touch, phase]; + + events_queue.borrow_mut().push_back(Event::WindowEvent { + window_id: RootEventId(WindowId), + event: WindowEvent::Touch(Touch { + device_id: DEVICE_ID, + id: touch_id, + location: (location.x as f64, location.y as f64).into(), + phase: match phase { + 0 => TouchPhase::Started, + 1 => TouchPhase::Moved, + // 2 is UITouchPhaseStationary and is not expected here + 3 => TouchPhase::Ended, + 4 => TouchPhase::Cancelled, + _ => panic!("unexpected touch phase: {:?}", phase) + } + }), + }); + } + } + } + + let ui_responder = class!(UIResponder); + let mut decl = ClassDecl::new("AppDelegate", ui_responder).expect("Failed to declare class `AppDelegate`"); + + unsafe { + decl.add_method(sel!(application:didFinishLaunchingWithOptions:), + did_finish_launching as extern fn(&mut Object, Sel, id, id) -> BOOL); + + decl.add_method(sel!(applicationDidBecomeActive:), + did_become_active as extern fn(&Object, Sel, id)); + + decl.add_method(sel!(applicationWillResignActive:), + will_resign_active as extern fn(&Object, Sel, id)); + + decl.add_method(sel!(applicationWillEnterForeground:), + will_enter_foreground as extern fn(&Object, Sel, id)); + + decl.add_method(sel!(applicationDidEnterBackground:), + did_enter_background as extern fn(&Object, Sel, id)); + + decl.add_method(sel!(applicationWillTerminate:), + will_terminate as extern fn(&Object, Sel, id)); + + + decl.add_method(sel!(touchesBegan:withEvent:), + handle_touches as extern fn(this: &Object, _: Sel, _: id, _:id)); + + decl.add_method(sel!(touchesMoved:withEvent:), + handle_touches as extern fn(this: &Object, _: Sel, _: id, _:id)); + + decl.add_method(sel!(touchesEnded:withEvent:), + handle_touches as extern fn(this: &Object, _: Sel, _: id, _:id)); + + decl.add_method(sel!(touchesCancelled:withEvent:), + handle_touches as extern fn(this: &Object, _: Sel, _: id, _:id)); + + + decl.add_method(sel!(postLaunch:), + post_launch as extern fn(&Object, Sel, id)); + + decl.add_ivar::<*mut c_void>("winitState"); + decl.add_ivar::<*mut c_void>("eventsQueue"); + + decl.register(); + } +} + +#[inline] +fn start_app() { + unsafe { + UIApplicationMain(0, ptr::null(), nil, NSString::alloc(nil).init_str("AppDelegate")); + } +} + +// Constant device ID, to be removed when this backend is updated to report real device IDs. +const DEVICE_ID: ::DeviceId = ::DeviceId(DeviceId); diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/dlopen.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/dlopen.rs new file mode 100644 index 0000000..d9ad3fb --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/dlopen.rs @@ -0,0 +1,15 @@ +#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] +#![allow(dead_code)] + +use std::os::raw::{c_void, c_char, c_int}; + +pub const RTLD_LAZY: c_int = 0x001; +pub const RTLD_NOW: c_int = 0x002; + +#[link="dl"] +extern { + pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; + pub fn dlerror() -> *mut c_char; + pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; + pub fn dlclose(handle: *mut c_void) -> c_int; +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/mod.rs new file mode 100644 index 0000000..1f88cdf --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/mod.rs @@ -0,0 +1,542 @@ +#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] + +use std::collections::VecDeque; +use std::{env, mem}; +use std::ffi::CStr; +use std::os::raw::*; +use std::sync::Arc; + +use parking_lot::Mutex; +use sctk::reexports::client::ConnectError; + +use { + CreationError, + EventsLoopClosed, + Icon, + MouseCursor, + ControlFlow, + WindowAttributes, +}; +use dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize}; +use window::MonitorId as RootMonitorId; +use self::x11::{XConnection, XError}; +use self::x11::ffi::XVisualInfo; +pub use self::x11::XNotSupported; + +mod dlopen; +pub mod wayland; +pub mod x11; + +/// Environment variable specifying which backend should be used on unix platform. +/// +/// Legal values are x11 and wayland. If this variable is set only the named backend +/// will be tried by winit. If it is not set, winit will try to connect to a wayland connection, +/// and if it fails will fallback on x11. +/// +/// If this variable is set with any other value, winit will panic. +const BACKEND_PREFERENCE_ENV_VAR: &str = "WINIT_UNIX_BACKEND"; + +#[derive(Clone, Default)] +pub struct PlatformSpecificWindowBuilderAttributes { + pub visual_infos: Option<XVisualInfo>, + pub screen_id: Option<i32>, + pub resize_increments: Option<(u32, u32)>, + pub base_size: Option<(u32, u32)>, + pub class: Option<(String, String)>, + pub override_redirect: bool, + pub x11_window_type: x11::util::WindowType, + pub gtk_theme_variant: Option<String>, + pub app_id: Option<String> +} + +lazy_static!( + pub static ref X11_BACKEND: Mutex<Result<Arc<XConnection>, XNotSupported>> = { + Mutex::new(XConnection::new(Some(x_error_callback)).map(Arc::new)) + }; +); + +pub enum Window { + X(x11::Window), + Wayland(wayland::Window), +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum WindowId { + X(x11::WindowId), + Wayland(wayland::WindowId), +} + +impl WindowId { + pub unsafe fn dummy() -> Self { + WindowId::X(x11::WindowId::dummy()) + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum DeviceId { + X(x11::DeviceId), + Wayland(wayland::DeviceId), +} + +impl DeviceId { + pub unsafe fn dummy() -> Self { + DeviceId::X(x11::DeviceId::dummy()) + } +} + +#[derive(Debug, Clone)] +pub enum MonitorId { + X(x11::MonitorId), + Wayland(wayland::MonitorId), +} + +impl MonitorId { + #[inline] + pub fn get_name(&self) -> Option<String> { + match self { + &MonitorId::X(ref m) => m.get_name(), + &MonitorId::Wayland(ref m) => m.get_name(), + } + } + + #[inline] + pub fn get_native_identifier(&self) -> u32 { + match self { + &MonitorId::X(ref m) => m.get_native_identifier(), + &MonitorId::Wayland(ref m) => m.get_native_identifier(), + } + } + + #[inline] + pub fn get_dimensions(&self) -> PhysicalSize { + match self { + &MonitorId::X(ref m) => m.get_dimensions(), + &MonitorId::Wayland(ref m) => m.get_dimensions(), + } + } + + #[inline] + pub fn get_position(&self) -> PhysicalPosition { + match self { + &MonitorId::X(ref m) => m.get_position(), + &MonitorId::Wayland(ref m) => m.get_position(), + } + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + match self { + &MonitorId::X(ref m) => m.get_hidpi_factor(), + &MonitorId::Wayland(ref m) => m.get_hidpi_factor() as f64, + } + } +} + +impl Window { + #[inline] + pub fn new( + events_loop: &EventsLoop, + attribs: WindowAttributes, + pl_attribs: PlatformSpecificWindowBuilderAttributes, + ) -> Result<Self, CreationError> { + match *events_loop { + EventsLoop::Wayland(ref events_loop) => { + wayland::Window::new(events_loop, attribs, pl_attribs).map(Window::Wayland) + }, + EventsLoop::X(ref events_loop) => { + x11::Window::new(events_loop, attribs, pl_attribs).map(Window::X) + }, + } + } + + #[inline] + pub fn id(&self) -> WindowId { + match self { + &Window::X(ref w) => WindowId::X(w.id()), + &Window::Wayland(ref w) => WindowId::Wayland(w.id()), + } + } + + #[inline] + pub fn set_title(&self, title: &str) { + match self { + &Window::X(ref w) => w.set_title(title), + &Window::Wayland(ref w) => w.set_title(title), + } + } + + #[inline] + pub fn show(&self) { + match self { + &Window::X(ref w) => w.show(), + &Window::Wayland(ref w) => w.show(), + } + } + + #[inline] + pub fn hide(&self) { + match self { + &Window::X(ref w) => w.hide(), + &Window::Wayland(ref w) => w.hide(), + } + } + + #[inline] + pub fn get_position(&self) -> Option<LogicalPosition> { + match self { + &Window::X(ref w) => w.get_position(), + &Window::Wayland(ref w) => w.get_position(), + } + } + + #[inline] + pub fn get_inner_position(&self) -> Option<LogicalPosition> { + match self { + &Window::X(ref m) => m.get_inner_position(), + &Window::Wayland(ref m) => m.get_inner_position(), + } + } + + #[inline] + pub fn set_position(&self, position: LogicalPosition) { + match self { + &Window::X(ref w) => w.set_position(position), + &Window::Wayland(ref w) => w.set_position(position), + } + } + + #[inline] + pub fn get_inner_size(&self) -> Option<LogicalSize> { + match self { + &Window::X(ref w) => w.get_inner_size(), + &Window::Wayland(ref w) => w.get_inner_size(), + } + } + + #[inline] + pub fn get_outer_size(&self) -> Option<LogicalSize> { + match self { + &Window::X(ref w) => w.get_outer_size(), + &Window::Wayland(ref w) => w.get_outer_size(), + } + } + + #[inline] + pub fn set_inner_size(&self, size: LogicalSize) { + match self { + &Window::X(ref w) => w.set_inner_size(size), + &Window::Wayland(ref w) => w.set_inner_size(size), + } + } + + #[inline] + pub fn set_min_dimensions(&self, dimensions: Option<LogicalSize>) { + match self { + &Window::X(ref w) => w.set_min_dimensions(dimensions), + &Window::Wayland(ref w) => w.set_min_dimensions(dimensions), + } + } + + #[inline] + pub fn set_max_dimensions(&self, dimensions: Option<LogicalSize>) { + match self { + &Window::X(ref w) => w.set_max_dimensions(dimensions), + &Window::Wayland(ref w) => w.set_max_dimensions(dimensions), + } + } + + #[inline] + pub fn set_resizable(&self, resizable: bool) { + match self { + &Window::X(ref w) => w.set_resizable(resizable), + &Window::Wayland(ref w) => w.set_resizable(resizable), + } + } + + #[inline] + pub fn set_cursor(&self, cursor: MouseCursor) { + match self { + &Window::X(ref w) => w.set_cursor(cursor), + &Window::Wayland(ref w) => w.set_cursor(cursor) + } + } + + #[inline] + pub fn grab_cursor(&self, grab: bool) -> Result<(), String> { + match self { + &Window::X(ref window) => window.grab_cursor(grab), + &Window::Wayland(ref window) => window.grab_cursor(grab), + } + } + + #[inline] + pub fn hide_cursor(&self, hide: bool) { + match self { + &Window::X(ref window) => window.hide_cursor(hide), + &Window::Wayland(ref window) => window.hide_cursor(hide), + } + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + match self { + &Window::X(ref w) => w.get_hidpi_factor(), + &Window::Wayland(ref w) => w.hidpi_factor() as f64, + } + } + + #[inline] + pub fn set_cursor_position(&self, position: LogicalPosition) -> Result<(), String> { + match self { + &Window::X(ref w) => w.set_cursor_position(position), + &Window::Wayland(ref w) => w.set_cursor_position(position), + } + } + + #[inline] + pub fn set_maximized(&self, maximized: bool) { + match self { + &Window::X(ref w) => w.set_maximized(maximized), + &Window::Wayland(ref w) => w.set_maximized(maximized), + } + } + + #[inline] + pub fn set_fullscreen(&self, monitor: Option<RootMonitorId>) { + match self { + &Window::X(ref w) => w.set_fullscreen(monitor), + &Window::Wayland(ref w) => w.set_fullscreen(monitor) + } + } + + #[inline] + pub fn set_decorations(&self, decorations: bool) { + match self { + &Window::X(ref w) => w.set_decorations(decorations), + &Window::Wayland(ref w) => w.set_decorations(decorations) + } + } + + #[inline] + pub fn set_always_on_top(&self, always_on_top: bool) { + match self { + &Window::X(ref w) => w.set_always_on_top(always_on_top), + &Window::Wayland(_) => (), + } + } + + #[inline] + pub fn set_window_icon(&self, window_icon: Option<Icon>) { + match self { + &Window::X(ref w) => w.set_window_icon(window_icon), + &Window::Wayland(_) => (), + } + } + + #[inline] + pub fn set_ime_spot(&self, position: LogicalPosition) { + match self { + &Window::X(ref w) => w.set_ime_spot(position), + &Window::Wayland(_) => (), + } + } + + #[inline] + pub fn get_current_monitor(&self) -> RootMonitorId { + match self { + &Window::X(ref window) => RootMonitorId { inner: MonitorId::X(window.get_current_monitor()) }, + &Window::Wayland(ref window) => RootMonitorId { inner: MonitorId::Wayland(window.get_current_monitor()) }, + } + } + + #[inline] + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + match self { + &Window::X(ref window) => window.get_available_monitors() + .into_iter() + .map(MonitorId::X) + .collect(), + &Window::Wayland(ref window) => window.get_available_monitors() + .into_iter() + .map(MonitorId::Wayland) + .collect(), + } + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + match self { + &Window::X(ref window) => MonitorId::X(window.get_primary_monitor()), + &Window::Wayland(ref window) => MonitorId::Wayland(window.get_primary_monitor()), + } + } +} + +unsafe extern "C" fn x_error_callback( + display: *mut x11::ffi::Display, + event: *mut x11::ffi::XErrorEvent, +) -> c_int { + let xconn_lock = X11_BACKEND.lock(); + if let Ok(ref xconn) = *xconn_lock { + let mut buf: [c_char; 1024] = mem::uninitialized(); + (xconn.xlib.XGetErrorText)( + display, + (*event).error_code as c_int, + buf.as_mut_ptr(), + buf.len() as c_int, + ); + let description = CStr::from_ptr(buf.as_ptr()).to_string_lossy(); + + let error = XError { + description: description.into_owned(), + error_code: (*event).error_code, + request_code: (*event).request_code, + minor_code: (*event).minor_code, + }; + + error!("X11 error: {:#?}", error); + + *xconn.latest_error.lock() = Some(error); + } + // Fun fact: this return value is completely ignored. + 0 +} + +pub enum EventsLoop { + Wayland(wayland::EventsLoop), + X(x11::EventsLoop) +} + +#[derive(Clone)] +pub enum EventsLoopProxy { + X(x11::EventsLoopProxy), + Wayland(wayland::EventsLoopProxy), +} + +impl EventsLoop { + pub fn new() -> EventsLoop { + if let Ok(env_var) = env::var(BACKEND_PREFERENCE_ENV_VAR) { + match env_var.as_str() { + "x11" => { + // TODO: propagate + return EventsLoop::new_x11().expect("Failed to initialize X11 backend"); + }, + "wayland" => { + return EventsLoop::new_wayland() + .expect("Failed to initialize Wayland backend"); + }, + _ => panic!( + "Unknown environment variable value for {}, try one of `x11`,`wayland`", + BACKEND_PREFERENCE_ENV_VAR, + ), + } + } + + let wayland_err = match EventsLoop::new_wayland() { + Ok(event_loop) => return event_loop, + Err(err) => err, + }; + + let x11_err = match EventsLoop::new_x11() { + Ok(event_loop) => return event_loop, + Err(err) => err, + }; + + let err_string = format!( + "Failed to initialize any backend! Wayland status: {:?} X11 status: {:?}", + wayland_err, + x11_err, + ); + panic!(err_string); + } + + pub fn new_wayland() -> Result<EventsLoop, ConnectError> { + wayland::EventsLoop::new() + .map(EventsLoop::Wayland) + } + + pub fn new_x11() -> Result<EventsLoop, XNotSupported> { + X11_BACKEND + .lock() + .as_ref() + .map(Arc::clone) + .map(x11::EventsLoop::new) + .map(EventsLoop::X) + .map_err(|err| err.clone()) + } + + #[inline] + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + match *self { + EventsLoop::Wayland(ref evlp) => evlp + .get_available_monitors() + .into_iter() + .map(MonitorId::Wayland) + .collect(), + EventsLoop::X(ref evlp) => evlp + .x_connection() + .get_available_monitors() + .into_iter() + .map(MonitorId::X) + .collect(), + } + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + match *self { + EventsLoop::Wayland(ref evlp) => MonitorId::Wayland(evlp.get_primary_monitor()), + EventsLoop::X(ref evlp) => MonitorId::X(evlp.x_connection().get_primary_monitor()), + } + } + + pub fn create_proxy(&self) -> EventsLoopProxy { + match *self { + EventsLoop::Wayland(ref evlp) => EventsLoopProxy::Wayland(evlp.create_proxy()), + EventsLoop::X(ref evlp) => EventsLoopProxy::X(evlp.create_proxy()), + } + } + + pub fn poll_events<F>(&mut self, callback: F) + where F: FnMut(::Event) + { + match *self { + EventsLoop::Wayland(ref mut evlp) => evlp.poll_events(callback), + EventsLoop::X(ref mut evlp) => evlp.poll_events(callback) + } + } + + pub fn run_forever<F>(&mut self, callback: F) + where F: FnMut(::Event) -> ControlFlow + { + match *self { + EventsLoop::Wayland(ref mut evlp) => evlp.run_forever(callback), + EventsLoop::X(ref mut evlp) => evlp.run_forever(callback) + } + } + + #[inline] + pub fn is_wayland(&self) -> bool { + match *self { + EventsLoop::Wayland(_) => true, + EventsLoop::X(_) => false, + } + } + + #[inline] + pub fn x_connection(&self) -> Option<&Arc<XConnection>> { + match *self { + EventsLoop::Wayland(_) => None, + EventsLoop::X(ref ev) => Some(ev.x_connection()), + } + } +} + +impl EventsLoopProxy { + pub fn wakeup(&self) -> Result<(), EventsLoopClosed> { + match *self { + EventsLoopProxy::Wayland(ref proxy) => proxy.wakeup(), + EventsLoopProxy::X(ref proxy) => proxy.wakeup(), + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/event_loop.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/event_loop.rs new file mode 100644 index 0000000..ee48348 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/event_loop.rs @@ -0,0 +1,534 @@ +use std::cell::RefCell; +use std::collections::VecDeque; +use std::fmt; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex, Weak}; + +use {ControlFlow, EventsLoopClosed, PhysicalPosition, PhysicalSize}; + +use super::window::WindowStore; +use super::WindowId; + +use sctk::output::OutputMgr; +use sctk::reexports::client::protocol::{ + wl_keyboard, wl_output, wl_pointer, wl_registry, wl_seat, wl_touch, +}; +use sctk::reexports::client::{ConnectError, Display, EventQueue, GlobalEvent, Proxy}; +use sctk::Environment; + +use sctk::reexports::client::protocol::wl_display::RequestsTrait as DisplayRequests; +use sctk::reexports::client::protocol::wl_surface::RequestsTrait; + +use ModifiersState; + +pub struct EventsLoopSink { + buffer: VecDeque<::Event>, +} + +impl EventsLoopSink { + pub fn new() -> EventsLoopSink { + EventsLoopSink { + buffer: VecDeque::new(), + } + } + + pub fn send_event(&mut self, evt: ::WindowEvent, wid: WindowId) { + let evt = ::Event::WindowEvent { + event: evt, + window_id: ::WindowId(::platform::WindowId::Wayland(wid)), + }; + self.buffer.push_back(evt); + } + + pub fn send_raw_event(&mut self, evt: ::Event) { + self.buffer.push_back(evt); + } + + fn empty_with<F>(&mut self, callback: &mut F) + where + F: FnMut(::Event), + { + for evt in self.buffer.drain(..) { + callback(evt) + } + } +} + +pub struct EventsLoop { + // The Event Queue + pub evq: RefCell<EventQueue>, + // our sink, shared with some handlers, buffering the events + sink: Arc<Mutex<EventsLoopSink>>, + // Whether or not there is a pending `Awakened` event to be emitted. + pending_wakeup: Arc<AtomicBool>, + // The window store + pub store: Arc<Mutex<WindowStore>>, + // the env + pub env: Environment, + // a cleanup switch to prune dead windows + pub cleanup_needed: Arc<Mutex<bool>>, + // The wayland display + pub display: Arc<Display>, + // The list of seats + pub seats: Arc<Mutex<Vec<(u32, Proxy<wl_seat::WlSeat>)>>>, +} + +// A handle that can be sent across threads and used to wake up the `EventsLoop`. +// +// We should only try and wake up the `EventsLoop` if it still exists, so we hold Weak ptrs. +#[derive(Clone)] +pub struct EventsLoopProxy { + display: Weak<Display>, + pending_wakeup: Weak<AtomicBool>, +} + +impl EventsLoopProxy { + // Causes the `EventsLoop` to stop blocking on `run_forever` and emit an `Awakened` event. + // + // Returns `Err` if the associated `EventsLoop` no longer exists. + pub fn wakeup(&self) -> Result<(), EventsLoopClosed> { + let display = self.display.upgrade(); + let wakeup = self.pending_wakeup.upgrade(); + match (display, wakeup) { + (Some(display), Some(wakeup)) => { + // Update the `EventsLoop`'s `pending_wakeup` flag. + wakeup.store(true, Ordering::Relaxed); + // Cause the `EventsLoop` to break from `dispatch` if it is currently blocked. + let _ = display.sync(|callback| callback.implement(|_, _| {}, ())); + display.flush().map_err(|_| EventsLoopClosed)?; + Ok(()) + } + _ => Err(EventsLoopClosed), + } + } +} + +impl EventsLoop { + pub fn new() -> Result<EventsLoop, ConnectError> { + let (display, mut event_queue) = Display::connect_to_env()?; + + let display = Arc::new(display); + let pending_wakeup = Arc::new(AtomicBool::new(false)); + let sink = Arc::new(Mutex::new(EventsLoopSink::new())); + let store = Arc::new(Mutex::new(WindowStore::new())); + let seats = Arc::new(Mutex::new(Vec::new())); + + let mut seat_manager = SeatManager { + sink: sink.clone(), + store: store.clone(), + seats: seats.clone(), + events_loop_proxy: EventsLoopProxy { + display: Arc::downgrade(&display), + pending_wakeup: Arc::downgrade(&pending_wakeup), + }, + }; + + let env = Environment::from_display_with_cb( + &display, + &mut event_queue, + move |event, registry| { + match event { + GlobalEvent::New { id, ref interface, version } => { + if interface == "wl_seat" { + seat_manager.add_seat(id, version, registry) + } + }, + GlobalEvent::Removed { id, ref interface } => { + if interface == "wl_seat" { + seat_manager.remove_seat(id) + } + }, + } + }, + ).unwrap(); + + Ok(EventsLoop { + display, + evq: RefCell::new(event_queue), + sink, + pending_wakeup, + store, + env, + cleanup_needed: Arc::new(Mutex::new(false)), + seats, + }) + } + + pub fn create_proxy(&self) -> EventsLoopProxy { + EventsLoopProxy { + display: Arc::downgrade(&self.display), + pending_wakeup: Arc::downgrade(&self.pending_wakeup), + } + } + + pub fn poll_events<F>(&mut self, mut callback: F) + where + F: FnMut(::Event), + { + // send pending events to the server + self.display.flush().expect("Wayland connection lost."); + + // dispatch any pre-buffered events + self.sink.lock().unwrap().empty_with(&mut callback); + + // try to read pending events + if let Some(h) = self.evq.get_mut().prepare_read() { + h.read_events().expect("Wayland connection lost."); + } + // dispatch wayland events + self.evq + .get_mut() + .dispatch_pending() + .expect("Wayland connection lost."); + self.post_dispatch_triggers(); + + // dispatch buffered events to client + self.sink.lock().unwrap().empty_with(&mut callback); + } + + pub fn run_forever<F>(&mut self, mut callback: F) + where + F: FnMut(::Event) -> ControlFlow, + { + // send pending events to the server + self.display.flush().expect("Wayland connection lost."); + + // Check for control flow by wrapping the callback. + let control_flow = ::std::cell::Cell::new(ControlFlow::Continue); + let mut callback = |event| { + if let ControlFlow::Break = callback(event) { + control_flow.set(ControlFlow::Break); + } + }; + + // dispatch any pre-buffered events + self.post_dispatch_triggers(); + self.sink.lock().unwrap().empty_with(&mut callback); + + loop { + // dispatch events blocking if needed + self.evq + .get_mut() + .dispatch() + .expect("Wayland connection lost."); + self.post_dispatch_triggers(); + + // empty buffer of events + self.sink.lock().unwrap().empty_with(&mut callback); + + if let ControlFlow::Break = control_flow.get() { + break; + } + } + } + + pub fn get_primary_monitor(&self) -> MonitorId { + get_primary_monitor(&self.env.outputs) + } + + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + get_available_monitors(&self.env.outputs) + } +} + +/* + * Private EventsLoop Internals + */ + +impl EventsLoop { + fn post_dispatch_triggers(&mut self) { + let mut sink = self.sink.lock().unwrap(); + // process a possible pending wakeup call + if self.pending_wakeup.load(Ordering::Relaxed) { + sink.send_raw_event(::Event::Awakened); + self.pending_wakeup.store(false, Ordering::Relaxed); + } + // prune possible dead windows + { + let mut cleanup_needed = self.cleanup_needed.lock().unwrap(); + if *cleanup_needed { + let pruned = self.store.lock().unwrap().cleanup(); + *cleanup_needed = false; + for wid in pruned { + sink.send_event(::WindowEvent::Destroyed, wid); + } + } + } + // process pending resize/refresh + self.store.lock().unwrap().for_each( + |newsize, size, new_dpi, refresh, frame_refresh, closed, wid, frame| { + if let Some(frame) = frame { + if let Some((w, h)) = newsize { + frame.resize(w, h); + frame.refresh(); + let logical_size = ::LogicalSize::new(w as f64, h as f64); + sink.send_event(::WindowEvent::Resized(logical_size), wid); + *size = (w, h); + } else if frame_refresh { + frame.refresh(); + if !refresh { + frame.surface().commit() + } + } + } + if let Some(dpi) = new_dpi { + sink.send_event(::WindowEvent::HiDpiFactorChanged(dpi as f64), wid); + } + if refresh { + sink.send_event(::WindowEvent::Refresh, wid); + } + if closed { + sink.send_event(::WindowEvent::CloseRequested, wid); + } + }, + ) + } +} + +/* + * Wayland protocol implementations + */ + +struct SeatManager { + sink: Arc<Mutex<EventsLoopSink>>, + store: Arc<Mutex<WindowStore>>, + seats: Arc<Mutex<Vec<(u32, Proxy<wl_seat::WlSeat>)>>>, + events_loop_proxy: EventsLoopProxy, +} + +impl SeatManager { + fn add_seat(&mut self, id: u32, version: u32, registry: Proxy<wl_registry::WlRegistry>) { + use self::wl_registry::RequestsTrait as RegistryRequests; + use std::cmp::min; + + let mut seat_data = SeatData { + sink: self.sink.clone(), + store: self.store.clone(), + pointer: None, + keyboard: None, + touch: None, + events_loop_proxy: self.events_loop_proxy.clone(), + modifiers_tracker: Arc::new(Mutex::new(ModifiersState::default())), + }; + let seat = registry + .bind(min(version, 5), id, move |seat| { + seat.implement(move |event, seat| { + seat_data.receive(event, seat) + }, ()) + }) + .unwrap(); + self.store.lock().unwrap().new_seat(&seat); + self.seats.lock().unwrap().push((id, seat)); + } + + fn remove_seat(&mut self, id: u32) { + use self::wl_seat::RequestsTrait as SeatRequests; + let mut seats = self.seats.lock().unwrap(); + if let Some(idx) = seats.iter().position(|&(i, _)| i == id) { + let (_, seat) = seats.swap_remove(idx); + if seat.version() >= 5 { + seat.release(); + } + } + } +} + +struct SeatData { + sink: Arc<Mutex<EventsLoopSink>>, + store: Arc<Mutex<WindowStore>>, + pointer: Option<Proxy<wl_pointer::WlPointer>>, + keyboard: Option<Proxy<wl_keyboard::WlKeyboard>>, + touch: Option<Proxy<wl_touch::WlTouch>>, + events_loop_proxy: EventsLoopProxy, + modifiers_tracker: Arc<Mutex<ModifiersState>>, +} + +impl SeatData { + fn receive(&mut self, evt: wl_seat::Event, seat: Proxy<wl_seat::WlSeat>) { + match evt { + wl_seat::Event::Name { .. } => (), + wl_seat::Event::Capabilities { capabilities } => { + // create pointer if applicable + if capabilities.contains(wl_seat::Capability::Pointer) && self.pointer.is_none() { + self.pointer = Some(super::pointer::implement_pointer( + &seat, + self.sink.clone(), + self.store.clone(), + self.modifiers_tracker.clone(), + )) + } + // destroy pointer if applicable + if !capabilities.contains(wl_seat::Capability::Pointer) { + if let Some(pointer) = self.pointer.take() { + if pointer.version() >= 3 { + use self::wl_pointer::RequestsTrait; + pointer.release(); + } + } + } + // create keyboard if applicable + if capabilities.contains(wl_seat::Capability::Keyboard) && self.keyboard.is_none() { + self.keyboard = Some(super::keyboard::init_keyboard( + &seat, + self.sink.clone(), + self.events_loop_proxy.clone(), + self.modifiers_tracker.clone(), + )) + } + // destroy keyboard if applicable + if !capabilities.contains(wl_seat::Capability::Keyboard) { + if let Some(kbd) = self.keyboard.take() { + if kbd.version() >= 3 { + use self::wl_keyboard::RequestsTrait; + kbd.release(); + } + } + } + // create touch if applicable + if capabilities.contains(wl_seat::Capability::Touch) && self.touch.is_none() { + self.touch = Some(super::touch::implement_touch( + &seat, + self.sink.clone(), + self.store.clone(), + )) + } + // destroy touch if applicable + if !capabilities.contains(wl_seat::Capability::Touch) { + if let Some(touch) = self.touch.take() { + if touch.version() >= 3 { + use self::wl_touch::RequestsTrait; + touch.release(); + } + } + } + } + } + } +} + +impl Drop for SeatData { + fn drop(&mut self) { + if let Some(pointer) = self.pointer.take() { + if pointer.version() >= 3 { + use self::wl_pointer::RequestsTrait; + pointer.release(); + } + } + if let Some(kbd) = self.keyboard.take() { + if kbd.version() >= 3 { + use self::wl_keyboard::RequestsTrait; + kbd.release(); + } + } + if let Some(touch) = self.touch.take() { + if touch.version() >= 3 { + use self::wl_touch::RequestsTrait; + touch.release(); + } + } + } +} + +/* + * Monitor stuff + */ + +pub struct MonitorId { + pub(crate) proxy: Proxy<wl_output::WlOutput>, + pub(crate) mgr: OutputMgr, +} + +impl Clone for MonitorId { + fn clone(&self) -> MonitorId { + MonitorId { + proxy: self.proxy.clone(), + mgr: self.mgr.clone(), + } + } +} + +impl fmt::Debug for MonitorId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[derive(Debug)] + struct MonitorId { + name: Option<String>, + native_identifier: u32, + dimensions: PhysicalSize, + position: PhysicalPosition, + hidpi_factor: i32, + } + + let monitor_id_proxy = MonitorId { + name: self.get_name(), + native_identifier: self.get_native_identifier(), + dimensions: self.get_dimensions(), + position: self.get_position(), + hidpi_factor: self.get_hidpi_factor(), + }; + + monitor_id_proxy.fmt(f) + } +} + +impl MonitorId { + pub fn get_name(&self) -> Option<String> { + self.mgr.with_info(&self.proxy, |_, info| { + format!("{} ({})", info.model, info.make) + }) + } + + #[inline] + pub fn get_native_identifier(&self) -> u32 { + self.mgr.with_info(&self.proxy, |id, _| id).unwrap_or(0) + } + + pub fn get_dimensions(&self) -> PhysicalSize { + match self.mgr.with_info(&self.proxy, |_, info| { + info.modes + .iter() + .find(|m| m.is_current) + .map(|m| m.dimensions) + }) { + Some(Some((w, h))) => (w as u32, h as u32), + _ => (0, 0), + }.into() + } + + pub fn get_position(&self) -> PhysicalPosition { + self.mgr + .with_info(&self.proxy, |_, info| info.location) + .unwrap_or((0, 0)) + .into() + } + + #[inline] + pub fn get_hidpi_factor(&self) -> i32 { + self.mgr + .with_info(&self.proxy, |_, info| info.scale_factor) + .unwrap_or(1) + } +} + +pub fn get_primary_monitor(outputs: &OutputMgr) -> MonitorId { + outputs.with_all(|list| { + if let Some(&(_, ref proxy, _)) = list.first() { + MonitorId { + proxy: proxy.clone(), + mgr: outputs.clone(), + } + } else { + panic!("No monitor is available.") + } + }) +} + +pub fn get_available_monitors(outputs: &OutputMgr) -> VecDeque<MonitorId> { + outputs.with_all(|list| { + list.iter() + .map(|&(_, ref proxy, _)| MonitorId { + proxy: proxy.clone(), + mgr: outputs.clone(), + }) + .collect() + }) +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/keyboard.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/keyboard.rs new file mode 100644 index 0000000..1b48712 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/keyboard.rs @@ -0,0 +1,363 @@ +use std::sync::{Arc, Mutex}; + +use super::{make_wid, DeviceId, EventsLoopProxy, EventsLoopSink}; +use sctk::keyboard::{ + self, map_keyboard_auto_with_repeat, Event as KbEvent, KeyRepeatEvent, KeyRepeatKind, +}; +use sctk::reexports::client::protocol::wl_keyboard; +use sctk::reexports::client::Proxy; +use sctk::reexports::client::protocol::wl_seat; +use sctk::reexports::client::protocol::wl_seat::RequestsTrait as SeatRequests; + +use {ElementState, KeyboardInput, ModifiersState, VirtualKeyCode, WindowEvent}; + +pub fn init_keyboard( + seat: &Proxy<wl_seat::WlSeat>, + sink: Arc<Mutex<EventsLoopSink>>, + events_loop_proxy: EventsLoopProxy, + modifiers_tracker: Arc<Mutex<ModifiersState>>, +) -> Proxy<wl_keyboard::WlKeyboard> { + // { variables to be captured by the closures + let target = Arc::new(Mutex::new(None)); + let my_sink = sink.clone(); + let repeat_sink = sink.clone(); + let repeat_target = target.clone(); + let my_modifiers = modifiers_tracker.clone(); + // } + let ret = map_keyboard_auto_with_repeat( + seat, + KeyRepeatKind::System, + move |evt: KbEvent, _| match evt { + KbEvent::Enter { surface, .. } => { + let wid = make_wid(&surface); + my_sink + .lock() + .unwrap() + .send_event(WindowEvent::Focused(true), wid); + *target.lock().unwrap() = Some(wid); + } + KbEvent::Leave { surface, .. } => { + let wid = make_wid(&surface); + my_sink + .lock() + .unwrap() + .send_event(WindowEvent::Focused(false), wid); + *target.lock().unwrap() = None; + } + KbEvent::Key { + rawkey, + keysym, + state, + utf8, + .. + } => { + if let Some(wid) = *target.lock().unwrap() { + let state = match state { + wl_keyboard::KeyState::Pressed => ElementState::Pressed, + wl_keyboard::KeyState::Released => ElementState::Released, + }; + let vkcode = key_to_vkey(rawkey, keysym); + let mut guard = my_sink.lock().unwrap(); + guard.send_event( + WindowEvent::KeyboardInput { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + input: KeyboardInput { + state: state, + scancode: rawkey, + virtual_keycode: vkcode, + modifiers: modifiers_tracker.lock().unwrap().clone(), + }, + }, + wid, + ); + // send char event only on key press, not release + if let ElementState::Released = state { + return; + } + if let Some(txt) = utf8 { + for chr in txt.chars() { + guard.send_event(WindowEvent::ReceivedCharacter(chr), wid); + } + } + } + } + KbEvent::RepeatInfo { .. } => { /* Handled by smithay client toolkit */ } + KbEvent::Modifiers { modifiers: event_modifiers } => { + *modifiers_tracker.lock().unwrap() = event_modifiers.into() + } + }, + move |repeat_event: KeyRepeatEvent, _| { + if let Some(wid) = *repeat_target.lock().unwrap() { + let state = ElementState::Pressed; + let vkcode = key_to_vkey(repeat_event.rawkey, repeat_event.keysym); + let mut guard = repeat_sink.lock().unwrap(); + guard.send_event( + WindowEvent::KeyboardInput { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + input: KeyboardInput { + state: state, + scancode: repeat_event.rawkey, + virtual_keycode: vkcode, + modifiers: my_modifiers.lock().unwrap().clone(), + }, + }, + wid, + ); + if let Some(txt) = repeat_event.utf8 { + for chr in txt.chars() { + guard.send_event(WindowEvent::ReceivedCharacter(chr), wid); + } + } + events_loop_proxy.wakeup().unwrap(); + } + }, + ); + + match ret { + Ok(keyboard) => keyboard, + Err(_) => { + // This is a fallback impl if libxkbcommon was not available + // This case should probably never happen, as most wayland + // compositors _need_ libxkbcommon anyway... + // + // In this case, we don't have the keymap information (it is + // supposed to be serialized by the compositor using libxkbcommon) + + // { variables to be captured by the closure + let mut target = None; + let my_sink = sink; + // } + seat.get_keyboard(|keyboard| { + keyboard.implement(move |evt, _| match evt { + wl_keyboard::Event::Enter { surface, .. } => { + let wid = make_wid(&surface); + my_sink + .lock() + .unwrap() + .send_event(WindowEvent::Focused(true), wid); + target = Some(wid); + } + wl_keyboard::Event::Leave { surface, .. } => { + let wid = make_wid(&surface); + my_sink + .lock() + .unwrap() + .send_event(WindowEvent::Focused(false), wid); + target = None; + } + wl_keyboard::Event::Key { key, state, .. } => { + if let Some(wid) = target { + let state = match state { + wl_keyboard::KeyState::Pressed => ElementState::Pressed, + wl_keyboard::KeyState::Released => ElementState::Released, + }; + my_sink.lock().unwrap().send_event( + WindowEvent::KeyboardInput { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + input: KeyboardInput { + state: state, + scancode: key, + virtual_keycode: None, + modifiers: ModifiersState::default(), + }, + }, + wid, + ); + } + } + _ => (), + }, ()) + }).unwrap() + } + } +} + +fn key_to_vkey(rawkey: u32, keysym: u32) -> Option<VirtualKeyCode> { + match rawkey { + 1 => Some(VirtualKeyCode::Escape), + 2 => Some(VirtualKeyCode::Key1), + 3 => Some(VirtualKeyCode::Key2), + 4 => Some(VirtualKeyCode::Key3), + 5 => Some(VirtualKeyCode::Key4), + 6 => Some(VirtualKeyCode::Key5), + 7 => Some(VirtualKeyCode::Key6), + 8 => Some(VirtualKeyCode::Key7), + 9 => Some(VirtualKeyCode::Key8), + 10 => Some(VirtualKeyCode::Key9), + 11 => Some(VirtualKeyCode::Key0), + _ => keysym_to_vkey(keysym), + } +} + +fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCode> { + use sctk::keyboard::keysyms; + match keysym { + // letters + keysyms::XKB_KEY_A | keysyms::XKB_KEY_a => Some(VirtualKeyCode::A), + keysyms::XKB_KEY_B | keysyms::XKB_KEY_b => Some(VirtualKeyCode::B), + keysyms::XKB_KEY_C | keysyms::XKB_KEY_c => Some(VirtualKeyCode::C), + keysyms::XKB_KEY_D | keysyms::XKB_KEY_d => Some(VirtualKeyCode::D), + keysyms::XKB_KEY_E | keysyms::XKB_KEY_e => Some(VirtualKeyCode::E), + keysyms::XKB_KEY_F | keysyms::XKB_KEY_f => Some(VirtualKeyCode::F), + keysyms::XKB_KEY_G | keysyms::XKB_KEY_g => Some(VirtualKeyCode::G), + keysyms::XKB_KEY_H | keysyms::XKB_KEY_h => Some(VirtualKeyCode::H), + keysyms::XKB_KEY_I | keysyms::XKB_KEY_i => Some(VirtualKeyCode::I), + keysyms::XKB_KEY_J | keysyms::XKB_KEY_j => Some(VirtualKeyCode::J), + keysyms::XKB_KEY_K | keysyms::XKB_KEY_k => Some(VirtualKeyCode::K), + keysyms::XKB_KEY_L | keysyms::XKB_KEY_l => Some(VirtualKeyCode::L), + keysyms::XKB_KEY_M | keysyms::XKB_KEY_m => Some(VirtualKeyCode::M), + keysyms::XKB_KEY_N | keysyms::XKB_KEY_n => Some(VirtualKeyCode::N), + keysyms::XKB_KEY_O | keysyms::XKB_KEY_o => Some(VirtualKeyCode::O), + keysyms::XKB_KEY_P | keysyms::XKB_KEY_p => Some(VirtualKeyCode::P), + keysyms::XKB_KEY_Q | keysyms::XKB_KEY_q => Some(VirtualKeyCode::Q), + keysyms::XKB_KEY_R | keysyms::XKB_KEY_r => Some(VirtualKeyCode::R), + keysyms::XKB_KEY_S | keysyms::XKB_KEY_s => Some(VirtualKeyCode::S), + keysyms::XKB_KEY_T | keysyms::XKB_KEY_t => Some(VirtualKeyCode::T), + keysyms::XKB_KEY_U | keysyms::XKB_KEY_u => Some(VirtualKeyCode::U), + keysyms::XKB_KEY_V | keysyms::XKB_KEY_v => Some(VirtualKeyCode::V), + keysyms::XKB_KEY_W | keysyms::XKB_KEY_w => Some(VirtualKeyCode::W), + keysyms::XKB_KEY_X | keysyms::XKB_KEY_x => Some(VirtualKeyCode::X), + keysyms::XKB_KEY_Y | keysyms::XKB_KEY_y => Some(VirtualKeyCode::Y), + keysyms::XKB_KEY_Z | keysyms::XKB_KEY_z => Some(VirtualKeyCode::Z), + // F-- + keysyms::XKB_KEY_F1 => Some(VirtualKeyCode::F1), + keysyms::XKB_KEY_F2 => Some(VirtualKeyCode::F2), + keysyms::XKB_KEY_F3 => Some(VirtualKeyCode::F3), + keysyms::XKB_KEY_F4 => Some(VirtualKeyCode::F4), + keysyms::XKB_KEY_F5 => Some(VirtualKeyCode::F5), + keysyms::XKB_KEY_F6 => Some(VirtualKeyCode::F6), + keysyms::XKB_KEY_F7 => Some(VirtualKeyCode::F7), + keysyms::XKB_KEY_F8 => Some(VirtualKeyCode::F8), + keysyms::XKB_KEY_F9 => Some(VirtualKeyCode::F9), + keysyms::XKB_KEY_F10 => Some(VirtualKeyCode::F10), + keysyms::XKB_KEY_F11 => Some(VirtualKeyCode::F11), + keysyms::XKB_KEY_F12 => Some(VirtualKeyCode::F12), + keysyms::XKB_KEY_F13 => Some(VirtualKeyCode::F13), + keysyms::XKB_KEY_F14 => Some(VirtualKeyCode::F14), + keysyms::XKB_KEY_F15 => Some(VirtualKeyCode::F15), + keysyms::XKB_KEY_F16 => Some(VirtualKeyCode::F16), + keysyms::XKB_KEY_F17 => Some(VirtualKeyCode::F17), + keysyms::XKB_KEY_F18 => Some(VirtualKeyCode::F18), + keysyms::XKB_KEY_F19 => Some(VirtualKeyCode::F19), + keysyms::XKB_KEY_F20 => Some(VirtualKeyCode::F20), + keysyms::XKB_KEY_F21 => Some(VirtualKeyCode::F21), + keysyms::XKB_KEY_F22 => Some(VirtualKeyCode::F22), + keysyms::XKB_KEY_F23 => Some(VirtualKeyCode::F23), + keysyms::XKB_KEY_F24 => Some(VirtualKeyCode::F24), + // flow control + keysyms::XKB_KEY_Print => Some(VirtualKeyCode::Snapshot), + keysyms::XKB_KEY_Scroll_Lock => Some(VirtualKeyCode::Scroll), + keysyms::XKB_KEY_Pause => Some(VirtualKeyCode::Pause), + keysyms::XKB_KEY_Insert => Some(VirtualKeyCode::Insert), + keysyms::XKB_KEY_Home => Some(VirtualKeyCode::Home), + keysyms::XKB_KEY_Delete => Some(VirtualKeyCode::Delete), + keysyms::XKB_KEY_End => Some(VirtualKeyCode::End), + keysyms::XKB_KEY_Page_Down => Some(VirtualKeyCode::PageDown), + keysyms::XKB_KEY_Page_Up => Some(VirtualKeyCode::PageUp), + // arrows + keysyms::XKB_KEY_Left => Some(VirtualKeyCode::Left), + keysyms::XKB_KEY_Up => Some(VirtualKeyCode::Up), + keysyms::XKB_KEY_Right => Some(VirtualKeyCode::Right), + keysyms::XKB_KEY_Down => Some(VirtualKeyCode::Down), + // + keysyms::XKB_KEY_BackSpace => Some(VirtualKeyCode::Back), + keysyms::XKB_KEY_Return => Some(VirtualKeyCode::Return), + keysyms::XKB_KEY_space => Some(VirtualKeyCode::Space), + // keypad + keysyms::XKB_KEY_Num_Lock => Some(VirtualKeyCode::Numlock), + keysyms::XKB_KEY_KP_0 => Some(VirtualKeyCode::Numpad0), + keysyms::XKB_KEY_KP_1 => Some(VirtualKeyCode::Numpad1), + keysyms::XKB_KEY_KP_2 => Some(VirtualKeyCode::Numpad2), + keysyms::XKB_KEY_KP_3 => Some(VirtualKeyCode::Numpad3), + keysyms::XKB_KEY_KP_4 => Some(VirtualKeyCode::Numpad4), + keysyms::XKB_KEY_KP_5 => Some(VirtualKeyCode::Numpad5), + keysyms::XKB_KEY_KP_6 => Some(VirtualKeyCode::Numpad6), + keysyms::XKB_KEY_KP_7 => Some(VirtualKeyCode::Numpad7), + keysyms::XKB_KEY_KP_8 => Some(VirtualKeyCode::Numpad8), + keysyms::XKB_KEY_KP_9 => Some(VirtualKeyCode::Numpad9), + // misc + // => Some(VirtualKeyCode::AbntC1), + // => Some(VirtualKeyCode::AbntC2), + keysyms::XKB_KEY_plus => Some(VirtualKeyCode::Add), + keysyms::XKB_KEY_apostrophe => Some(VirtualKeyCode::Apostrophe), + // => Some(VirtualKeyCode::Apps), + // => Some(VirtualKeyCode::At), + // => Some(VirtualKeyCode::Ax), + keysyms::XKB_KEY_backslash => Some(VirtualKeyCode::Backslash), + // => Some(VirtualKeyCode::Calculator), + // => Some(VirtualKeyCode::Capital), + keysyms::XKB_KEY_colon => Some(VirtualKeyCode::Colon), + keysyms::XKB_KEY_comma => Some(VirtualKeyCode::Comma), + // => Some(VirtualKeyCode::Convert), + // => Some(VirtualKeyCode::Decimal), + // => Some(VirtualKeyCode::Divide), + keysyms::XKB_KEY_equal => Some(VirtualKeyCode::Equals), + // => Some(VirtualKeyCode::Grave), + // => Some(VirtualKeyCode::Kana), + // => Some(VirtualKeyCode::Kanji), + keysyms::XKB_KEY_Alt_L => Some(VirtualKeyCode::LAlt), + // => Some(VirtualKeyCode::LBracket), + keysyms::XKB_KEY_Control_L => Some(VirtualKeyCode::LControl), + keysyms::XKB_KEY_Shift_L => Some(VirtualKeyCode::LShift), + // => Some(VirtualKeyCode::LWin), + // => Some(VirtualKeyCode::Mail), + // => Some(VirtualKeyCode::MediaSelect), + // => Some(VirtualKeyCode::MediaStop), + keysyms::XKB_KEY_minus => Some(VirtualKeyCode::Minus), + keysyms::XKB_KEY_asterisk => Some(VirtualKeyCode::Multiply), + // => Some(VirtualKeyCode::Mute), + // => Some(VirtualKeyCode::MyComputer), + // => Some(VirtualKeyCode::NextTrack), + // => Some(VirtualKeyCode::NoConvert), + keysyms::XKB_KEY_KP_Separator => Some(VirtualKeyCode::NumpadComma), + keysyms::XKB_KEY_KP_Enter => Some(VirtualKeyCode::NumpadEnter), + keysyms::XKB_KEY_KP_Equal => Some(VirtualKeyCode::NumpadEquals), + // => Some(VirtualKeyCode::OEM102), + // => Some(VirtualKeyCode::Period), + // => Some(VirtualKeyCode::Playpause), + // => Some(VirtualKeyCode::Power), + // => Some(VirtualKeyCode::Prevtrack), + keysyms::XKB_KEY_Alt_R => Some(VirtualKeyCode::RAlt), + // => Some(VirtualKeyCode::RBracket), + keysyms::XKB_KEY_Control_R => Some(VirtualKeyCode::RControl), + keysyms::XKB_KEY_Shift_R => Some(VirtualKeyCode::RShift), + // => Some(VirtualKeyCode::RWin), + keysyms::XKB_KEY_semicolon => Some(VirtualKeyCode::Semicolon), + keysyms::XKB_KEY_slash => Some(VirtualKeyCode::Slash), + // => Some(VirtualKeyCode::Sleep), + // => Some(VirtualKeyCode::Stop), + // => Some(VirtualKeyCode::Subtract), + // => Some(VirtualKeyCode::Sysrq), + keysyms::XKB_KEY_Tab => Some(VirtualKeyCode::Tab), + keysyms::XKB_KEY_ISO_Left_Tab => Some(VirtualKeyCode::Tab), + // => Some(VirtualKeyCode::Underline), + // => Some(VirtualKeyCode::Unlabeled), + keysyms::XKB_KEY_XF86AudioLowerVolume => Some(VirtualKeyCode::VolumeDown), + keysyms::XKB_KEY_XF86AudioRaiseVolume => Some(VirtualKeyCode::VolumeUp), + // => Some(VirtualKeyCode::Wake), + // => Some(VirtualKeyCode::Webback), + // => Some(VirtualKeyCode::WebFavorites), + // => Some(VirtualKeyCode::WebForward), + // => Some(VirtualKeyCode::WebHome), + // => Some(VirtualKeyCode::WebRefresh), + // => Some(VirtualKeyCode::WebSearch), + // => Some(VirtualKeyCode::WebStop), + // => Some(VirtualKeyCode::Yen), + keysyms::XKB_KEY_XF86Copy => Some(VirtualKeyCode::Copy), + keysyms::XKB_KEY_XF86Paste => Some(VirtualKeyCode::Paste), + keysyms::XKB_KEY_XF86Cut => Some(VirtualKeyCode::Cut), + // fallback + _ => None, + } +} + +impl From<keyboard::ModifiersState> for ModifiersState { + fn from(mods: keyboard::ModifiersState) -> ModifiersState { + ModifiersState { + shift: mods.shift, + ctrl: mods.ctrl, + alt: mods.alt, + logo: mods.logo, + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/mod.rs new file mode 100644 index 0000000..659cb7a --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/mod.rs @@ -0,0 +1,37 @@ +#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", + target_os = "netbsd", target_os = "openbsd"))] + +pub use self::window::Window; +pub use self::event_loop::{EventsLoop, EventsLoopProxy, EventsLoopSink, MonitorId}; + +use sctk::reexports::client::protocol::wl_surface; +use sctk::reexports::client::Proxy; + +mod event_loop; +mod pointer; +mod touch; +mod keyboard; +mod window; + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct DeviceId; + +impl DeviceId { + pub unsafe fn dummy() -> Self { + DeviceId + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct WindowId(usize); + +impl WindowId { + pub unsafe fn dummy() -> Self { + WindowId(0) + } +} + +#[inline] +fn make_wid(s: &Proxy<wl_surface::WlSurface>) -> WindowId { + WindowId(s.c_ptr() as usize) +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/pointer.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/pointer.rs new file mode 100644 index 0000000..ebe9d10 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/pointer.rs @@ -0,0 +1,189 @@ +use std::sync::{Arc, Mutex}; + +use {ElementState, MouseButton, MouseScrollDelta, TouchPhase, WindowEvent}; +use events::ModifiersState; + +use super::DeviceId; +use super::event_loop::EventsLoopSink; +use super::window::WindowStore; + +use sctk::reexports::client::Proxy; +use sctk::reexports::client::protocol::wl_pointer::{self, Event as PtrEvent, WlPointer}; +use sctk::reexports::client::protocol::wl_seat; +use sctk::reexports::client::protocol::wl_seat::RequestsTrait as SeatRequests; + +pub fn implement_pointer( + seat: &Proxy<wl_seat::WlSeat>, + sink: Arc<Mutex<EventsLoopSink>>, + store: Arc<Mutex<WindowStore>>, + modifiers_tracker: Arc<Mutex<ModifiersState>>, +) -> Proxy<WlPointer> { + let mut mouse_focus = None; + let mut axis_buffer = None; + let mut axis_discrete_buffer = None; + let mut axis_state = TouchPhase::Ended; + + seat.get_pointer(|pointer| { + pointer.implement(move |evt, pointer| { + let mut sink = sink.lock().unwrap(); + let store = store.lock().unwrap(); + match evt { + PtrEvent::Enter { + surface, + surface_x, + surface_y, + .. + } => { + let wid = store.find_wid(&surface); + if let Some(wid) = wid { + mouse_focus = Some(wid); + sink.send_event( + WindowEvent::CursorEntered { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + }, + wid, + ); + sink.send_event( + WindowEvent::CursorMoved { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + position: (surface_x, surface_y).into(), + modifiers: modifiers_tracker.lock().unwrap().clone(), + }, + wid, + ); + } + } + PtrEvent::Leave { surface, .. } => { + mouse_focus = None; + let wid = store.find_wid(&surface); + if let Some(wid) = wid { + sink.send_event( + WindowEvent::CursorLeft { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + }, + wid, + ); + } + } + PtrEvent::Motion { + surface_x, + surface_y, + .. + } => { + if let Some(wid) = mouse_focus { + sink.send_event( + WindowEvent::CursorMoved { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + position: (surface_x, surface_y).into(), + modifiers: modifiers_tracker.lock().unwrap().clone(), + }, + wid, + ); + } + } + PtrEvent::Button { button, state, .. } => { + if let Some(wid) = mouse_focus { + let state = match state { + wl_pointer::ButtonState::Pressed => ElementState::Pressed, + wl_pointer::ButtonState::Released => ElementState::Released, + }; + let button = match button { + 0x110 => MouseButton::Left, + 0x111 => MouseButton::Right, + 0x112 => MouseButton::Middle, + // TODO figure out the translation ? + _ => return, + }; + sink.send_event( + WindowEvent::MouseInput { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + state: state, + button: button, + modifiers: modifiers_tracker.lock().unwrap().clone(), + }, + wid, + ); + } + } + PtrEvent::Axis { axis, value, .. } => { + if let Some(wid) = mouse_focus { + if pointer.version() < 5 { + let (mut x, mut y) = (0.0, 0.0); + // old seat compatibility + match axis { + // wayland vertical sign convention is the inverse of winit + wl_pointer::Axis::VerticalScroll => y -= value as f32, + wl_pointer::Axis::HorizontalScroll => x += value as f32, + } + sink.send_event( + WindowEvent::MouseWheel { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + delta: MouseScrollDelta::PixelDelta((x as f64, y as f64).into()), + phase: TouchPhase::Moved, + modifiers: modifiers_tracker.lock().unwrap().clone(), + }, + wid, + ); + } else { + let (mut x, mut y) = axis_buffer.unwrap_or((0.0, 0.0)); + match axis { + // wayland vertical sign convention is the inverse of winit + wl_pointer::Axis::VerticalScroll => y -= value as f32, + wl_pointer::Axis::HorizontalScroll => x += value as f32, + } + axis_buffer = Some((x, y)); + axis_state = match axis_state { + TouchPhase::Started | TouchPhase::Moved => TouchPhase::Moved, + _ => TouchPhase::Started, + } + } + } + } + PtrEvent::Frame => { + let axis_buffer = axis_buffer.take(); + let axis_discrete_buffer = axis_discrete_buffer.take(); + if let Some(wid) = mouse_focus { + if let Some((x, y)) = axis_discrete_buffer { + sink.send_event( + WindowEvent::MouseWheel { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + delta: MouseScrollDelta::LineDelta(x as f32, y as f32), + phase: axis_state, + modifiers: modifiers_tracker.lock().unwrap().clone(), + }, + wid, + ); + } else if let Some((x, y)) = axis_buffer { + sink.send_event( + WindowEvent::MouseWheel { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + delta: MouseScrollDelta::PixelDelta((x as f64, y as f64).into()), + phase: axis_state, + modifiers: modifiers_tracker.lock().unwrap().clone(), + }, + wid, + ); + } + } + } + PtrEvent::AxisSource { .. } => (), + PtrEvent::AxisStop { .. } => { + axis_state = TouchPhase::Ended; + } + PtrEvent::AxisDiscrete { axis, discrete } => { + let (mut x, mut y) = axis_discrete_buffer.unwrap_or((0, 0)); + match axis { + // wayland vertical sign convention is the inverse of winit + wl_pointer::Axis::VerticalScroll => y -= discrete, + wl_pointer::Axis::HorizontalScroll => x += discrete, + } + axis_discrete_buffer = Some((x, y)); + axis_state = match axis_state { + TouchPhase::Started | TouchPhase::Moved => TouchPhase::Moved, + _ => TouchPhase::Started, + } + } + } + }, ()) + }).unwrap() +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/touch.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/touch.rs new file mode 100644 index 0000000..e9e28d6 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/touch.rs @@ -0,0 +1,97 @@ +use std::sync::{Arc, Mutex}; + +use {TouchPhase, WindowEvent}; + +use super::{DeviceId, WindowId}; +use super::event_loop::EventsLoopSink; +use super::window::WindowStore; + +use sctk::reexports::client::Proxy; +use sctk::reexports::client::protocol::wl_touch::{Event as TouchEvent, WlTouch}; +use sctk::reexports::client::protocol::wl_seat; +use sctk::reexports::client::protocol::wl_seat::RequestsTrait as SeatRequests; + +struct TouchPoint { + wid: WindowId, + location: (f64, f64), + id: i32, +} + +pub(crate) fn implement_touch( + seat: &Proxy<wl_seat::WlSeat>, + sink: Arc<Mutex<EventsLoopSink>>, + store: Arc<Mutex<WindowStore>>, +) -> Proxy<WlTouch> { + let mut pending_ids = Vec::new(); + seat.get_touch(|touch| { + touch.implement(move |evt, _| { + let mut sink = sink.lock().unwrap(); + let store = store.lock().unwrap(); + match evt { + TouchEvent::Down { + surface, id, x, y, .. + } => { + let wid = store.find_wid(&surface); + if let Some(wid) = wid { + sink.send_event( + WindowEvent::Touch(::Touch { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + phase: TouchPhase::Started, + location: (x, y).into(), + id: id as u64, + }), + wid, + ); + pending_ids.push(TouchPoint { + wid: wid, + location: (x, y), + id: id, + }); + } + } + TouchEvent::Up { id, .. } => { + let idx = pending_ids.iter().position(|p| p.id == id); + if let Some(idx) = idx { + let pt = pending_ids.remove(idx); + sink.send_event( + WindowEvent::Touch(::Touch { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + phase: TouchPhase::Ended, + location: pt.location.into(), + id: id as u64, + }), + pt.wid, + ); + } + } + TouchEvent::Motion { id, x, y, .. } => { + let pt = pending_ids.iter_mut().find(|p| p.id == id); + if let Some(pt) = pt { + pt.location = (x, y); + sink.send_event( + WindowEvent::Touch(::Touch { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + phase: TouchPhase::Moved, + location: (x, y).into(), + id: id as u64, + }), + pt.wid, + ); + } + } + TouchEvent::Frame => (), + TouchEvent::Cancel => for pt in pending_ids.drain(..) { + sink.send_event( + WindowEvent::Touch(::Touch { + device_id: ::DeviceId(::platform::DeviceId::Wayland(DeviceId)), + phase: TouchPhase::Cancelled, + location: pt.location.into(), + id: pt.id as u64, + }), + pt.wid, + ); + }, + } + }, ()) + }).unwrap() +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/window.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/window.rs new file mode 100644 index 0000000..62a74be --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/wayland/window.rs @@ -0,0 +1,383 @@ +use std::collections::VecDeque; +use std::sync::{Arc, Mutex, Weak}; + +use {CreationError, MouseCursor, WindowAttributes}; +use dpi::{LogicalPosition, LogicalSize}; +use platform::{MonitorId as PlatformMonitorId, PlatformSpecificWindowBuilderAttributes as PlAttributes}; +use window::MonitorId as RootMonitorId; + +use sctk::surface::{get_dpi_factor, get_outputs}; +use sctk::window::{ConceptFrame, Event as WEvent, Window as SWindow}; +use sctk::reexports::client::{Display, Proxy}; +use sctk::reexports::client::protocol::{wl_seat, wl_surface}; +use sctk::reexports::client::protocol::wl_surface::RequestsTrait as SurfaceRequests; +use sctk::output::OutputMgr; + +use super::{make_wid, EventsLoop, MonitorId, WindowId}; +use platform::platform::wayland::event_loop::{get_available_monitors, get_primary_monitor}; + +pub struct Window { + surface: Proxy<wl_surface::WlSurface>, + frame: Arc<Mutex<SWindow<ConceptFrame>>>, + outputs: OutputMgr, // Access to info for all monitors + size: Arc<Mutex<(u32, u32)>>, + kill_switch: (Arc<Mutex<bool>>, Arc<Mutex<bool>>), + display: Arc<Display>, + need_frame_refresh: Arc<Mutex<bool>>, +} + +impl Window { + pub fn new(evlp: &EventsLoop, attributes: WindowAttributes, pl_attribs: PlAttributes) -> Result<Window, CreationError> { + let (width, height) = attributes.dimensions.map(Into::into).unwrap_or((800, 600)); + // Create the window + let size = Arc::new(Mutex::new((width, height))); + + let window_store = evlp.store.clone(); + let surface = evlp.env.create_surface(move |dpi, surface| { + window_store.lock().unwrap().dpi_change(&surface, dpi); + surface.set_buffer_scale(dpi); + }); + + let window_store = evlp.store.clone(); + let my_surface = surface.clone(); + let mut frame = SWindow::<ConceptFrame>::init_from_env( + &evlp.env, + surface.clone(), + (width, height), + move |event| match event { + WEvent::Configure { new_size, .. } => { + let mut store = window_store.lock().unwrap(); + for window in &mut store.windows { + if window.surface.equals(&my_surface) { + window.newsize = new_size; + window.need_refresh = true; + *(window.need_frame_refresh.lock().unwrap()) = true; + return; + } + } + } + WEvent::Refresh => { + let store = window_store.lock().unwrap(); + for window in &store.windows { + if window.surface.equals(&my_surface) { + *(window.need_frame_refresh.lock().unwrap()) = true; + return; + } + } + } + WEvent::Close => { + let mut store = window_store.lock().unwrap(); + for window in &mut store.windows { + if window.surface.equals(&my_surface) { + window.closed = true; + return; + } + } + } + }, + ).unwrap(); + + if let Some(app_id) = pl_attribs.app_id { + frame.set_app_id(app_id); + } + + for &(_, ref seat) in evlp.seats.lock().unwrap().iter() { + frame.new_seat(seat); + } + + // Check for fullscreen requirements + if let Some(RootMonitorId { + inner: PlatformMonitorId::Wayland(ref monitor_id), + }) = attributes.fullscreen + { + frame.set_fullscreen(Some(&monitor_id.proxy)); + } else if attributes.maximized { + frame.set_maximized(); + } + + frame.set_resizable(attributes.resizable); + + // set decorations + frame.set_decorate(attributes.decorations); + + // min-max dimensions + frame.set_min_size(attributes.min_dimensions.map(Into::into)); + frame.set_max_size(attributes.max_dimensions.map(Into::into)); + + let kill_switch = Arc::new(Mutex::new(false)); + let need_frame_refresh = Arc::new(Mutex::new(true)); + let frame = Arc::new(Mutex::new(frame)); + + evlp.store.lock().unwrap().windows.push(InternalWindow { + closed: false, + newsize: None, + size: size.clone(), + need_refresh: false, + need_frame_refresh: need_frame_refresh.clone(), + surface: surface.clone(), + kill_switch: kill_switch.clone(), + frame: Arc::downgrade(&frame), + current_dpi: 1, + new_dpi: None, + }); + evlp.evq.borrow_mut().sync_roundtrip().unwrap(); + + Ok(Window { + display: evlp.display.clone(), + surface: surface, + frame: frame, + outputs: evlp.env.outputs.clone(), + size: size, + kill_switch: (kill_switch, evlp.cleanup_needed.clone()), + need_frame_refresh: need_frame_refresh, + }) + } + + #[inline] + pub fn id(&self) -> WindowId { + make_wid(&self.surface) + } + + pub fn set_title(&self, title: &str) { + self.frame.lock().unwrap().set_title(title.into()); + } + + #[inline] + pub fn show(&self) { + // TODO + } + + #[inline] + pub fn hide(&self) { + // TODO + } + + #[inline] + pub fn get_position(&self) -> Option<LogicalPosition> { + // Not possible with wayland + None + } + + #[inline] + pub fn get_inner_position(&self) -> Option<LogicalPosition> { + // Not possible with wayland + None + } + + #[inline] + pub fn set_position(&self, _pos: LogicalPosition) { + // Not possible with wayland + } + + pub fn get_inner_size(&self) -> Option<LogicalSize> { + Some(self.size.lock().unwrap().clone().into()) + } + + #[inline] + pub fn get_outer_size(&self) -> Option<LogicalSize> { + let (w, h) = self.size.lock().unwrap().clone(); + // let (w, h) = super::wayland_window::add_borders(w as i32, h as i32); + Some((w, h).into()) + } + + #[inline] + // NOTE: This will only resize the borders, the contents must be updated by the user + pub fn set_inner_size(&self, size: LogicalSize) { + let (w, h) = size.into(); + self.frame.lock().unwrap().resize(w, h); + *(self.size.lock().unwrap()) = (w, h); + } + + #[inline] + pub fn set_min_dimensions(&self, dimensions: Option<LogicalSize>) { + self.frame.lock().unwrap().set_min_size(dimensions.map(Into::into)); + } + + #[inline] + pub fn set_max_dimensions(&self, dimensions: Option<LogicalSize>) { + self.frame.lock().unwrap().set_max_size(dimensions.map(Into::into)); + } + + #[inline] + pub fn set_resizable(&self, resizable: bool) { + self.frame.lock().unwrap().set_resizable(resizable); + } + + #[inline] + pub fn hidpi_factor(&self) -> i32 { + get_dpi_factor(&self.surface) + } + + pub fn set_decorations(&self, decorate: bool) { + self.frame.lock().unwrap().set_decorate(decorate); + *(self.need_frame_refresh.lock().unwrap()) = true; + } + + pub fn set_maximized(&self, maximized: bool) { + if maximized { + self.frame.lock().unwrap().set_maximized(); + } else { + self.frame.lock().unwrap().unset_maximized(); + } + } + + pub fn set_fullscreen(&self, monitor: Option<RootMonitorId>) { + if let Some(RootMonitorId { + inner: PlatformMonitorId::Wayland(ref monitor_id), + }) = monitor + { + self.frame + .lock() + .unwrap() + .set_fullscreen(Some(&monitor_id.proxy)); + } else { + self.frame.lock().unwrap().unset_fullscreen(); + } + } + + #[inline] + pub fn set_cursor(&self, _cursor: MouseCursor) { + // TODO + } + + #[inline] + pub fn hide_cursor(&self, _hide: bool) { + // TODO: This isn't possible on Wayland yet + } + + #[inline] + pub fn grab_cursor(&self, _grab: bool) -> Result<(), String> { + Err("Cursor grabbing is not yet possible on Wayland.".to_owned()) + } + + #[inline] + pub fn set_cursor_position(&self, _pos: LogicalPosition) -> Result<(), String> { + Err("Setting the cursor position is not yet possible on Wayland.".to_owned()) + } + + pub fn get_display(&self) -> &Display { + &*self.display + } + + pub fn get_surface(&self) -> &Proxy<wl_surface::WlSurface> { + &self.surface + } + + pub fn get_current_monitor(&self) -> MonitorId { + let output = get_outputs(&self.surface).last().unwrap().clone(); + MonitorId { + proxy: output, + mgr: self.outputs.clone(), + } + } + + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + get_available_monitors(&self.outputs) + } + + pub fn get_primary_monitor(&self) -> MonitorId { + get_primary_monitor(&self.outputs) + } +} + +impl Drop for Window { + fn drop(&mut self) { + *(self.kill_switch.0.lock().unwrap()) = true; + *(self.kill_switch.1.lock().unwrap()) = true; + } +} + +/* + * Internal store for windows + */ + +struct InternalWindow { + surface: Proxy<wl_surface::WlSurface>, + newsize: Option<(u32, u32)>, + size: Arc<Mutex<(u32, u32)>>, + need_refresh: bool, + need_frame_refresh: Arc<Mutex<bool>>, + closed: bool, + kill_switch: Arc<Mutex<bool>>, + frame: Weak<Mutex<SWindow<ConceptFrame>>>, + current_dpi: i32, + new_dpi: Option<i32>, +} + +pub struct WindowStore { + windows: Vec<InternalWindow>, +} + +impl WindowStore { + pub fn new() -> WindowStore { + WindowStore { + windows: Vec::new(), + } + } + + pub fn find_wid(&self, surface: &Proxy<wl_surface::WlSurface>) -> Option<WindowId> { + for window in &self.windows { + if surface.equals(&window.surface) { + return Some(make_wid(surface)); + } + } + None + } + + pub fn cleanup(&mut self) -> Vec<WindowId> { + let mut pruned = Vec::new(); + self.windows.retain(|w| { + if *w.kill_switch.lock().unwrap() { + // window is dead, cleanup + pruned.push(make_wid(&w.surface)); + w.surface.destroy(); + false + } else { + true + } + }); + pruned + } + + pub fn new_seat(&self, seat: &Proxy<wl_seat::WlSeat>) { + for window in &self.windows { + if let Some(w) = window.frame.upgrade() { + w.lock().unwrap().new_seat(seat); + } + } + } + + fn dpi_change(&mut self, surface: &Proxy<wl_surface::WlSurface>, new: i32) { + for window in &mut self.windows { + if surface.equals(&window.surface) { + window.new_dpi = Some(new); + } + } + } + + pub fn for_each<F>(&mut self, mut f: F) + where + F: FnMut(Option<(u32, u32)>, &mut (u32, u32), Option<i32>, bool, bool, bool, WindowId, Option<&mut SWindow<ConceptFrame>>), + { + for window in &mut self.windows { + let opt_arc = window.frame.upgrade(); + let mut opt_mutex_lock = opt_arc.as_ref().map(|m| m.lock().unwrap()); + f( + window.newsize.take(), + &mut *(window.size.lock().unwrap()), + window.new_dpi, + window.need_refresh, + ::std::mem::replace(&mut *window.need_frame_refresh.lock().unwrap(), false), + window.closed, + make_wid(&window.surface), + opt_mutex_lock.as_mut().map(|m| &mut **m), + ); + if let Some(dpi) = window.new_dpi.take() { + window.current_dpi = dpi; + } + window.need_refresh = false; + // avoid re-spamming the event + window.closed = false; + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/dnd.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/dnd.rs new file mode 100644 index 0000000..c8221fb --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/dnd.rs @@ -0,0 +1,219 @@ +use std::io; +use std::sync::Arc; +use std::path::{Path, PathBuf}; +use std::str::Utf8Error; +use std::os::raw::*; + +use percent_encoding::percent_decode; + +use super::{ffi, util, XConnection, XError}; + +#[derive(Debug)] +pub struct DndAtoms { + pub aware: ffi::Atom, + pub enter: ffi::Atom, + pub leave: ffi::Atom, + pub drop: ffi::Atom, + pub position: ffi::Atom, + pub status: ffi::Atom, + pub action_private: ffi::Atom, + pub selection: ffi::Atom, + pub finished: ffi::Atom, + pub type_list: ffi::Atom, + pub uri_list: ffi::Atom, + pub none: ffi::Atom, +} + +impl DndAtoms { + pub fn new(xconn: &Arc<XConnection>) -> Result<Self, XError> { + let names = [ + b"XdndAware\0".as_ptr() as *mut c_char, + b"XdndEnter\0".as_ptr() as *mut c_char, + b"XdndLeave\0".as_ptr() as *mut c_char, + b"XdndDrop\0".as_ptr() as *mut c_char, + b"XdndPosition\0".as_ptr() as *mut c_char, + b"XdndStatus\0".as_ptr() as *mut c_char, + b"XdndActionPrivate\0".as_ptr() as *mut c_char, + b"XdndSelection\0".as_ptr() as *mut c_char, + b"XdndFinished\0".as_ptr() as *mut c_char, + b"XdndTypeList\0".as_ptr() as *mut c_char, + b"text/uri-list\0".as_ptr() as *mut c_char, + b"None\0".as_ptr() as *mut c_char, + ]; + let atoms = unsafe { xconn.get_atoms(&names) }?; + Ok(DndAtoms { + aware: atoms[0], + enter: atoms[1], + leave: atoms[2], + drop: atoms[3], + position: atoms[4], + status: atoms[5], + action_private: atoms[6], + selection: atoms[7], + finished: atoms[8], + type_list: atoms[9], + uri_list: atoms[10], + none: atoms[11], + }) + } +} + +#[derive(Debug, Clone, Copy)] +pub enum DndState { + Accepted, + Rejected, +} + +#[derive(Debug)] +pub enum DndDataParseError { + EmptyData, + InvalidUtf8(Utf8Error), + HostnameSpecified(String), + UnexpectedProtocol(String), + UnresolvablePath(io::Error), +} + +impl From<Utf8Error> for DndDataParseError { + fn from(e: Utf8Error) -> Self { + DndDataParseError::InvalidUtf8(e) + } +} + +impl From<io::Error> for DndDataParseError { + fn from(e: io::Error) -> Self { + DndDataParseError::UnresolvablePath(e) + } +} + +pub struct Dnd { + xconn: Arc<XConnection>, + pub atoms: DndAtoms, + // Populated by XdndEnter event handler + pub version: Option<c_long>, + pub type_list: Option<Vec<c_ulong>>, + // Populated by XdndPosition event handler + pub source_window: Option<c_ulong>, + // Populated by SelectionNotify event handler (triggered by XdndPosition event handler) + pub result: Option<Result<Vec<PathBuf>, DndDataParseError>>, +} + +impl Dnd { + pub fn new(xconn: Arc<XConnection>) -> Result<Self, XError> { + let atoms = DndAtoms::new(&xconn)?; + Ok(Dnd { + xconn, + atoms, + version: None, + type_list: None, + source_window: None, + result: None, + }) + } + + pub fn reset(&mut self) { + self.version = None; + self.type_list = None; + self.source_window = None; + self.result = None; + } + + pub unsafe fn send_status( + &self, + this_window: c_ulong, + target_window: c_ulong, + state: DndState, + ) -> Result<(), XError> { + let (accepted, action) = match state { + DndState::Accepted => (1, self.atoms.action_private as c_long), + DndState::Rejected => (0, self.atoms.none as c_long), + }; + self.xconn.send_client_msg( + target_window, + target_window, + self.atoms.status, + None, + [this_window as c_long, accepted, 0, 0, action], + ).flush() + } + + pub unsafe fn send_finished( + &self, + this_window: c_ulong, + target_window: c_ulong, + state: DndState, + ) -> Result<(), XError> { + let (accepted, action) = match state { + DndState::Accepted => (1, self.atoms.action_private as c_long), + DndState::Rejected => (0, self.atoms.none as c_long), + }; + self.xconn.send_client_msg( + target_window, + target_window, + self.atoms.finished, + None, + [this_window as c_long, accepted, action, 0, 0], + ).flush() + } + + pub unsafe fn get_type_list( + &self, + source_window: c_ulong, + ) -> Result<Vec<ffi::Atom>, util::GetPropertyError> { + self.xconn.get_property( + source_window, + self.atoms.type_list, + ffi::XA_ATOM, + ) + } + + pub unsafe fn convert_selection(&self, window: c_ulong, time: c_ulong) { + (self.xconn.xlib.XConvertSelection)( + self.xconn.display, + self.atoms.selection, + self.atoms.uri_list, + self.atoms.selection, + window, + time, + ); + } + + pub unsafe fn read_data( + &self, + window: c_ulong, + ) -> Result<Vec<c_uchar>, util::GetPropertyError> { + self.xconn.get_property( + window, + self.atoms.selection, + self.atoms.uri_list, + ) + } + + pub fn parse_data(&self, data: &mut Vec<c_uchar>) -> Result<Vec<PathBuf>, DndDataParseError> { + if !data.is_empty() { + let mut path_list = Vec::new(); + let decoded = percent_decode(data).decode_utf8()?.into_owned(); + for uri in decoded.split("\r\n").filter(|u| !u.is_empty()) { + // The format is specified as protocol://host/path + // However, it's typically simply protocol:///path + let path_str = if uri.starts_with("file://") { + let path_str = uri.replace("file://", ""); + if !path_str.starts_with('/') { + // A hostname is specified + // Supporting this case is beyond the scope of my mental health + return Err(DndDataParseError::HostnameSpecified(path_str)); + } + path_str + } else { + // Only the file protocol is supported + return Err(DndDataParseError::UnexpectedProtocol(uri.to_owned())); + }; + + let path = Path::new(&path_str).canonicalize()?; + path_list.push(path); + } + Ok(path_list) + } else { + Err(DndDataParseError::EmptyData) + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/events.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/events.rs new file mode 100644 index 0000000..037ee4c --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/events.rs @@ -0,0 +1,1008 @@ +use {events, libc}; +use super::ffi; +use VirtualKeyCode; + +pub fn keysym_to_element(keysym: libc::c_uint) -> Option<VirtualKeyCode> { + Some(match keysym { + ffi::XK_BackSpace => events::VirtualKeyCode::Back, + ffi::XK_Tab => events::VirtualKeyCode::Tab, + //ffi::XK_Linefeed => events::VirtualKeyCode::Linefeed, + //ffi::XK_Clear => events::VirtualKeyCode::Clear, + ffi::XK_Return => events::VirtualKeyCode::Return, + //ffi::XK_Pause => events::VirtualKeyCode::Pause, + //ffi::XK_Scroll_Lock => events::VirtualKeyCode::Scroll_lock, + //ffi::XK_Sys_Req => events::VirtualKeyCode::Sys_req, + ffi::XK_Escape => events::VirtualKeyCode::Escape, + ffi::XK_Delete => events::VirtualKeyCode::Delete, + ffi::XK_Multi_key => events::VirtualKeyCode::Compose, + //ffi::XK_Kanji => events::VirtualKeyCode::Kanji, + //ffi::XK_Muhenkan => events::VirtualKeyCode::Muhenkan, + //ffi::XK_Henkan_Mode => events::VirtualKeyCode::Henkan_mode, + //ffi::XK_Henkan => events::VirtualKeyCode::Henkan, + //ffi::XK_Romaji => events::VirtualKeyCode::Romaji, + //ffi::XK_Hiragana => events::VirtualKeyCode::Hiragana, + //ffi::XK_Katakana => events::VirtualKeyCode::Katakana, + //ffi::XK_Hiragana_Katakana => events::VirtualKeyCode::Hiragana_katakana, + //ffi::XK_Zenkaku => events::VirtualKeyCode::Zenkaku, + //ffi::XK_Hankaku => events::VirtualKeyCode::Hankaku, + //ffi::XK_Zenkaku_Hankaku => events::VirtualKeyCode::Zenkaku_hankaku, + //ffi::XK_Touroku => events::VirtualKeyCode::Touroku, + //ffi::XK_Massyo => events::VirtualKeyCode::Massyo, + //ffi::XK_Kana_Lock => events::VirtualKeyCode::Kana_lock, + //ffi::XK_Kana_Shift => events::VirtualKeyCode::Kana_shift, + //ffi::XK_Eisu_Shift => events::VirtualKeyCode::Eisu_shift, + //ffi::XK_Eisu_toggle => events::VirtualKeyCode::Eisu_toggle, + ffi::XK_Home => events::VirtualKeyCode::Home, + ffi::XK_Left => events::VirtualKeyCode::Left, + ffi::XK_Up => events::VirtualKeyCode::Up, + ffi::XK_Right => events::VirtualKeyCode::Right, + ffi::XK_Down => events::VirtualKeyCode::Down, + //ffi::XK_Prior => events::VirtualKeyCode::Prior, + ffi::XK_Page_Up => events::VirtualKeyCode::PageUp, + //ffi::XK_Next => events::VirtualKeyCode::Next, + ffi::XK_Page_Down => events::VirtualKeyCode::PageDown, + ffi::XK_End => events::VirtualKeyCode::End, + //ffi::XK_Begin => events::VirtualKeyCode::Begin, + //ffi::XK_Win_L => events::VirtualKeyCode::Win_l, + //ffi::XK_Win_R => events::VirtualKeyCode::Win_r, + //ffi::XK_App => events::VirtualKeyCode::App, + //ffi::XK_Select => events::VirtualKeyCode::Select, + //ffi::XK_Print => events::VirtualKeyCode::Print, + //ffi::XK_Execute => events::VirtualKeyCode::Execute, + ffi::XK_Insert => events::VirtualKeyCode::Insert, + //ffi::XK_Undo => events::VirtualKeyCode::Undo, + //ffi::XK_Redo => events::VirtualKeyCode::Redo, + //ffi::XK_Menu => events::VirtualKeyCode::Menu, + //ffi::XK_Find => events::VirtualKeyCode::Find, + //ffi::XK_Cancel => events::VirtualKeyCode::Cancel, + //ffi::XK_Help => events::VirtualKeyCode::Help, + //ffi::XK_Break => events::VirtualKeyCode::Break, + //ffi::XK_Mode_switch => events::VirtualKeyCode::Mode_switch, + //ffi::XK_script_switch => events::VirtualKeyCode::Script_switch, + //ffi::XK_Num_Lock => events::VirtualKeyCode::Num_lock, + //ffi::XK_KP_Space => events::VirtualKeyCode::Kp_space, + //ffi::XK_KP_Tab => events::VirtualKeyCode::Kp_tab, + //ffi::XK_KP_Enter => events::VirtualKeyCode::Kp_enter, + //ffi::XK_KP_F1 => events::VirtualKeyCode::Kp_f1, + //ffi::XK_KP_F2 => events::VirtualKeyCode::Kp_f2, + //ffi::XK_KP_F3 => events::VirtualKeyCode::Kp_f3, + //ffi::XK_KP_F4 => events::VirtualKeyCode::Kp_f4, + ffi::XK_KP_Home => events::VirtualKeyCode::Home, + ffi::XK_KP_Left => events::VirtualKeyCode::Left, + ffi::XK_KP_Up => events::VirtualKeyCode::Up, + ffi::XK_KP_Right => events::VirtualKeyCode::Right, + ffi::XK_KP_Down => events::VirtualKeyCode::Down, + //ffi::XK_KP_Prior => events::VirtualKeyCode::Kp_prior, + ffi::XK_KP_Page_Up => events::VirtualKeyCode::PageUp, + //ffi::XK_KP_Next => events::VirtualKeyCode::Kp_next, + ffi::XK_KP_Page_Down => events::VirtualKeyCode::PageDown, + ffi::XK_KP_End => events::VirtualKeyCode::End, + //ffi::XK_KP_Begin => events::VirtualKeyCode::Kp_begin, + ffi::XK_KP_Insert => events::VirtualKeyCode::Insert, + ffi::XK_KP_Delete => events::VirtualKeyCode::Delete, + ffi::XK_KP_Equal => events::VirtualKeyCode::NumpadEquals, + //ffi::XK_KP_Multiply => events::VirtualKeyCode::NumpadMultiply, + //ffi::XK_KP_Add => events::VirtualKeyCode::NumpadAdd, + //ffi::XK_KP_Separator => events::VirtualKeyCode::Kp_separator, + //ffi::XK_KP_Subtract => events::VirtualKeyCode::NumpadSubtract, + //ffi::XK_KP_Decimal => events::VirtualKeyCode::Kp_decimal, + //ffi::XK_KP_Divide => events::VirtualKeyCode::NumpadDivide, + ffi::XK_KP_0 => events::VirtualKeyCode::Numpad0, + ffi::XK_KP_1 => events::VirtualKeyCode::Numpad1, + ffi::XK_KP_2 => events::VirtualKeyCode::Numpad2, + ffi::XK_KP_3 => events::VirtualKeyCode::Numpad3, + ffi::XK_KP_4 => events::VirtualKeyCode::Numpad4, + ffi::XK_KP_5 => events::VirtualKeyCode::Numpad5, + ffi::XK_KP_6 => events::VirtualKeyCode::Numpad6, + ffi::XK_KP_7 => events::VirtualKeyCode::Numpad7, + ffi::XK_KP_8 => events::VirtualKeyCode::Numpad8, + ffi::XK_KP_9 => events::VirtualKeyCode::Numpad9, + ffi::XK_F1 => events::VirtualKeyCode::F1, + ffi::XK_F2 => events::VirtualKeyCode::F2, + ffi::XK_F3 => events::VirtualKeyCode::F3, + ffi::XK_F4 => events::VirtualKeyCode::F4, + ffi::XK_F5 => events::VirtualKeyCode::F5, + ffi::XK_F6 => events::VirtualKeyCode::F6, + ffi::XK_F7 => events::VirtualKeyCode::F7, + ffi::XK_F8 => events::VirtualKeyCode::F8, + ffi::XK_F9 => events::VirtualKeyCode::F9, + ffi::XK_F10 => events::VirtualKeyCode::F10, + ffi::XK_F11 => events::VirtualKeyCode::F11, + //ffi::XK_L1 => events::VirtualKeyCode::L1, + ffi::XK_F12 => events::VirtualKeyCode::F12, + //ffi::XK_L2 => events::VirtualKeyCode::L2, + ffi::XK_F13 => events::VirtualKeyCode::F13, + //ffi::XK_L3 => events::VirtualKeyCode::L3, + ffi::XK_F14 => events::VirtualKeyCode::F14, + //ffi::XK_L4 => events::VirtualKeyCode::L4, + ffi::XK_F15 => events::VirtualKeyCode::F15, + //ffi::XK_L5 => events::VirtualKeyCode::L5, + ffi::XK_F16 => events::VirtualKeyCode::F16, + //ffi::XK_L6 => events::VirtualKeyCode::L6, + ffi::XK_F17 => events::VirtualKeyCode::F17, + //ffi::XK_L7 => events::VirtualKeyCode::L7, + ffi::XK_F18 => events::VirtualKeyCode::F18, + //ffi::XK_L8 => events::VirtualKeyCode::L8, + ffi::XK_F19 => events::VirtualKeyCode::F19, + //ffi::XK_L9 => events::VirtualKeyCode::L9, + ffi::XK_F20 => events::VirtualKeyCode::F20, + //ffi::XK_L10 => events::VirtualKeyCode::L10, + ffi::XK_F21 => events::VirtualKeyCode::F21, + //ffi::XK_R1 => events::VirtualKeyCode::R1, + ffi::XK_F22 => events::VirtualKeyCode::F22, + //ffi::XK_R2 => events::VirtualKeyCode::R2, + ffi::XK_F23 => events::VirtualKeyCode::F23, + //ffi::XK_R3 => events::VirtualKeyCode::R3, + ffi::XK_F24 => events::VirtualKeyCode::F24, + //ffi::XK_R4 => events::VirtualKeyCode::R4, + //ffi::XK_F25 => events::VirtualKeyCode::F25, + //ffi::XK_R5 => events::VirtualKeyCode::R5, + //ffi::XK_F26 => events::VirtualKeyCode::F26, + //ffi::XK_R6 => events::VirtualKeyCode::R6, + //ffi::XK_F27 => events::VirtualKeyCode::F27, + //ffi::XK_R7 => events::VirtualKeyCode::R7, + //ffi::XK_F28 => events::VirtualKeyCode::F28, + //ffi::XK_R8 => events::VirtualKeyCode::R8, + //ffi::XK_F29 => events::VirtualKeyCode::F29, + //ffi::XK_R9 => events::VirtualKeyCode::R9, + //ffi::XK_F30 => events::VirtualKeyCode::F30, + //ffi::XK_R10 => events::VirtualKeyCode::R10, + //ffi::XK_F31 => events::VirtualKeyCode::F31, + //ffi::XK_R11 => events::VirtualKeyCode::R11, + //ffi::XK_F32 => events::VirtualKeyCode::F32, + //ffi::XK_R12 => events::VirtualKeyCode::R12, + //ffi::XK_F33 => events::VirtualKeyCode::F33, + //ffi::XK_R13 => events::VirtualKeyCode::R13, + //ffi::XK_F34 => events::VirtualKeyCode::F34, + //ffi::XK_R14 => events::VirtualKeyCode::R14, + //ffi::XK_F35 => events::VirtualKeyCode::F35, + //ffi::XK_R15 => events::VirtualKeyCode::R15, + ffi::XK_Shift_L => events::VirtualKeyCode::LShift, + ffi::XK_Shift_R => events::VirtualKeyCode::RShift, + ffi::XK_Control_L => events::VirtualKeyCode::LControl, + ffi::XK_Control_R => events::VirtualKeyCode::RControl, + //ffi::XK_Caps_Lock => events::VirtualKeyCode::Caps_lock, + //ffi::XK_Shift_Lock => events::VirtualKeyCode::Shift_lock, + //ffi::XK_Meta_L => events::VirtualKeyCode::Meta_l, + //ffi::XK_Meta_R => events::VirtualKeyCode::Meta_r, + ffi::XK_Alt_L => events::VirtualKeyCode::LAlt, + ffi::XK_Alt_R => events::VirtualKeyCode::RAlt, + //ffi::XK_Super_L => events::VirtualKeyCode::Super_l, + //ffi::XK_Super_R => events::VirtualKeyCode::Super_r, + //ffi::XK_Hyper_L => events::VirtualKeyCode::Hyper_l, + //ffi::XK_Hyper_R => events::VirtualKeyCode::Hyper_r, + ffi::XK_ISO_Left_Tab => events::VirtualKeyCode::Tab, + ffi::XK_space => events::VirtualKeyCode::Space, + //ffi::XK_exclam => events::VirtualKeyCode::Exclam, + //ffi::XK_quotedbl => events::VirtualKeyCode::Quotedbl, + //ffi::XK_numbersign => events::VirtualKeyCode::Numbersign, + //ffi::XK_dollar => events::VirtualKeyCode::Dollar, + //ffi::XK_percent => events::VirtualKeyCode::Percent, + //ffi::XK_ampersand => events::VirtualKeyCode::Ampersand, + ffi::XK_apostrophe => events::VirtualKeyCode::Apostrophe, + //ffi::XK_quoteright => events::VirtualKeyCode::Quoteright, + //ffi::XK_parenleft => events::VirtualKeyCode::Parenleft, + //ffi::XK_parenright => events::VirtualKeyCode::Parenright, + //ffi::XK_asterisk => events::VirtualKeyCode::Asterisk, + ffi::XK_plus => events::VirtualKeyCode::Add, + ffi::XK_comma => events::VirtualKeyCode::Comma, + ffi::XK_minus => events::VirtualKeyCode::Subtract, + ffi::XK_period => events::VirtualKeyCode::Period, + ffi::XK_slash => events::VirtualKeyCode::Slash, + ffi::XK_0 => events::VirtualKeyCode::Key0, + ffi::XK_1 => events::VirtualKeyCode::Key1, + ffi::XK_2 => events::VirtualKeyCode::Key2, + ffi::XK_3 => events::VirtualKeyCode::Key3, + ffi::XK_4 => events::VirtualKeyCode::Key4, + ffi::XK_5 => events::VirtualKeyCode::Key5, + ffi::XK_6 => events::VirtualKeyCode::Key6, + ffi::XK_7 => events::VirtualKeyCode::Key7, + ffi::XK_8 => events::VirtualKeyCode::Key8, + ffi::XK_9 => events::VirtualKeyCode::Key9, + ffi::XK_colon => events::VirtualKeyCode::Colon, + ffi::XK_semicolon => events::VirtualKeyCode::Semicolon, + //ffi::XK_less => events::VirtualKeyCode::Less, + ffi::XK_equal => events::VirtualKeyCode::Equals, + //ffi::XK_greater => events::VirtualKeyCode::Greater, + //ffi::XK_question => events::VirtualKeyCode::Question, + ffi::XK_at => events::VirtualKeyCode::At, + ffi::XK_A => events::VirtualKeyCode::A, + ffi::XK_B => events::VirtualKeyCode::B, + ffi::XK_C => events::VirtualKeyCode::C, + ffi::XK_D => events::VirtualKeyCode::D, + ffi::XK_E => events::VirtualKeyCode::E, + ffi::XK_F => events::VirtualKeyCode::F, + ffi::XK_G => events::VirtualKeyCode::G, + ffi::XK_H => events::VirtualKeyCode::H, + ffi::XK_I => events::VirtualKeyCode::I, + ffi::XK_J => events::VirtualKeyCode::J, + ffi::XK_K => events::VirtualKeyCode::K, + ffi::XK_L => events::VirtualKeyCode::L, + ffi::XK_M => events::VirtualKeyCode::M, + ffi::XK_N => events::VirtualKeyCode::N, + ffi::XK_O => events::VirtualKeyCode::O, + ffi::XK_P => events::VirtualKeyCode::P, + ffi::XK_Q => events::VirtualKeyCode::Q, + ffi::XK_R => events::VirtualKeyCode::R, + ffi::XK_S => events::VirtualKeyCode::S, + ffi::XK_T => events::VirtualKeyCode::T, + ffi::XK_U => events::VirtualKeyCode::U, + ffi::XK_V => events::VirtualKeyCode::V, + ffi::XK_W => events::VirtualKeyCode::W, + ffi::XK_X => events::VirtualKeyCode::X, + ffi::XK_Y => events::VirtualKeyCode::Y, + ffi::XK_Z => events::VirtualKeyCode::Z, + ffi::XK_bracketleft => events::VirtualKeyCode::LBracket, + ffi::XK_backslash => events::VirtualKeyCode::Backslash, + ffi::XK_bracketright => events::VirtualKeyCode::RBracket, + //ffi::XK_asciicircum => events::VirtualKeyCode::Asciicircum, + //ffi::XK_underscore => events::VirtualKeyCode::Underscore, + ffi::XK_grave => events::VirtualKeyCode::Grave, + //ffi::XK_quoteleft => events::VirtualKeyCode::Quoteleft, + ffi::XK_a => events::VirtualKeyCode::A, + ffi::XK_b => events::VirtualKeyCode::B, + ffi::XK_c => events::VirtualKeyCode::C, + ffi::XK_d => events::VirtualKeyCode::D, + ffi::XK_e => events::VirtualKeyCode::E, + ffi::XK_f => events::VirtualKeyCode::F, + ffi::XK_g => events::VirtualKeyCode::G, + ffi::XK_h => events::VirtualKeyCode::H, + ffi::XK_i => events::VirtualKeyCode::I, + ffi::XK_j => events::VirtualKeyCode::J, + ffi::XK_k => events::VirtualKeyCode::K, + ffi::XK_l => events::VirtualKeyCode::L, + ffi::XK_m => events::VirtualKeyCode::M, + ffi::XK_n => events::VirtualKeyCode::N, + ffi::XK_o => events::VirtualKeyCode::O, + ffi::XK_p => events::VirtualKeyCode::P, + ffi::XK_q => events::VirtualKeyCode::Q, + ffi::XK_r => events::VirtualKeyCode::R, + ffi::XK_s => events::VirtualKeyCode::S, + ffi::XK_t => events::VirtualKeyCode::T, + ffi::XK_u => events::VirtualKeyCode::U, + ffi::XK_v => events::VirtualKeyCode::V, + ffi::XK_w => events::VirtualKeyCode::W, + ffi::XK_x => events::VirtualKeyCode::X, + ffi::XK_y => events::VirtualKeyCode::Y, + ffi::XK_z => events::VirtualKeyCode::Z, + //ffi::XK_braceleft => events::VirtualKeyCode::Braceleft, + //ffi::XK_bar => events::VirtualKeyCode::Bar, + //ffi::XK_braceright => events::VirtualKeyCode::Braceright, + //ffi::XK_asciitilde => events::VirtualKeyCode::Asciitilde, + //ffi::XK_nobreakspace => events::VirtualKeyCode::Nobreakspace, + //ffi::XK_exclamdown => events::VirtualKeyCode::Exclamdown, + //ffi::XK_cent => events::VirtualKeyCode::Cent, + //ffi::XK_sterling => events::VirtualKeyCode::Sterling, + //ffi::XK_currency => events::VirtualKeyCode::Currency, + //ffi::XK_yen => events::VirtualKeyCode::Yen, + //ffi::XK_brokenbar => events::VirtualKeyCode::Brokenbar, + //ffi::XK_section => events::VirtualKeyCode::Section, + //ffi::XK_diaeresis => events::VirtualKeyCode::Diaeresis, + //ffi::XK_copyright => events::VirtualKeyCode::Copyright, + //ffi::XK_ordfeminine => events::VirtualKeyCode::Ordfeminine, + //ffi::XK_guillemotleft => events::VirtualKeyCode::Guillemotleft, + //ffi::XK_notsign => events::VirtualKeyCode::Notsign, + //ffi::XK_hyphen => events::VirtualKeyCode::Hyphen, + //ffi::XK_registered => events::VirtualKeyCode::Registered, + //ffi::XK_macron => events::VirtualKeyCode::Macron, + //ffi::XK_degree => events::VirtualKeyCode::Degree, + //ffi::XK_plusminus => events::VirtualKeyCode::Plusminus, + //ffi::XK_twosuperior => events::VirtualKeyCode::Twosuperior, + //ffi::XK_threesuperior => events::VirtualKeyCode::Threesuperior, + //ffi::XK_acute => events::VirtualKeyCode::Acute, + //ffi::XK_mu => events::VirtualKeyCode::Mu, + //ffi::XK_paragraph => events::VirtualKeyCode::Paragraph, + //ffi::XK_periodcentered => events::VirtualKeyCode::Periodcentered, + //ffi::XK_cedilla => events::VirtualKeyCode::Cedilla, + //ffi::XK_onesuperior => events::VirtualKeyCode::Onesuperior, + //ffi::XK_masculine => events::VirtualKeyCode::Masculine, + //ffi::XK_guillemotright => events::VirtualKeyCode::Guillemotright, + //ffi::XK_onequarter => events::VirtualKeyCode::Onequarter, + //ffi::XK_onehalf => events::VirtualKeyCode::Onehalf, + //ffi::XK_threequarters => events::VirtualKeyCode::Threequarters, + //ffi::XK_questiondown => events::VirtualKeyCode::Questiondown, + //ffi::XK_Agrave => events::VirtualKeyCode::Agrave, + //ffi::XK_Aacute => events::VirtualKeyCode::Aacute, + //ffi::XK_Acircumflex => events::VirtualKeyCode::Acircumflex, + //ffi::XK_Atilde => events::VirtualKeyCode::Atilde, + //ffi::XK_Adiaeresis => events::VirtualKeyCode::Adiaeresis, + //ffi::XK_Aring => events::VirtualKeyCode::Aring, + //ffi::XK_AE => events::VirtualKeyCode::Ae, + //ffi::XK_Ccedilla => events::VirtualKeyCode::Ccedilla, + //ffi::XK_Egrave => events::VirtualKeyCode::Egrave, + //ffi::XK_Eacute => events::VirtualKeyCode::Eacute, + //ffi::XK_Ecircumflex => events::VirtualKeyCode::Ecircumflex, + //ffi::XK_Ediaeresis => events::VirtualKeyCode::Ediaeresis, + //ffi::XK_Igrave => events::VirtualKeyCode::Igrave, + //ffi::XK_Iacute => events::VirtualKeyCode::Iacute, + //ffi::XK_Icircumflex => events::VirtualKeyCode::Icircumflex, + //ffi::XK_Idiaeresis => events::VirtualKeyCode::Idiaeresis, + //ffi::XK_ETH => events::VirtualKeyCode::Eth, + //ffi::XK_Eth => events::VirtualKeyCode::Eth, + //ffi::XK_Ntilde => events::VirtualKeyCode::Ntilde, + //ffi::XK_Ograve => events::VirtualKeyCode::Ograve, + //ffi::XK_Oacute => events::VirtualKeyCode::Oacute, + //ffi::XK_Ocircumflex => events::VirtualKeyCode::Ocircumflex, + //ffi::XK_Otilde => events::VirtualKeyCode::Otilde, + //ffi::XK_Odiaeresis => events::VirtualKeyCode::Odiaeresis, + //ffi::XK_multiply => events::VirtualKeyCode::Multiply, + //ffi::XK_Ooblique => events::VirtualKeyCode::Ooblique, + //ffi::XK_Ugrave => events::VirtualKeyCode::Ugrave, + //ffi::XK_Uacute => events::VirtualKeyCode::Uacute, + //ffi::XK_Ucircumflex => events::VirtualKeyCode::Ucircumflex, + //ffi::XK_Udiaeresis => events::VirtualKeyCode::Udiaeresis, + //ffi::XK_Yacute => events::VirtualKeyCode::Yacute, + //ffi::XK_THORN => events::VirtualKeyCode::Thorn, + //ffi::XK_Thorn => events::VirtualKeyCode::Thorn, + //ffi::XK_ssharp => events::VirtualKeyCode::Ssharp, + //ffi::XK_agrave => events::VirtualKeyCode::Agrave, + //ffi::XK_aacute => events::VirtualKeyCode::Aacute, + //ffi::XK_acircumflex => events::VirtualKeyCode::Acircumflex, + //ffi::XK_atilde => events::VirtualKeyCode::Atilde, + //ffi::XK_adiaeresis => events::VirtualKeyCode::Adiaeresis, + //ffi::XK_aring => events::VirtualKeyCode::Aring, + //ffi::XK_ae => events::VirtualKeyCode::Ae, + //ffi::XK_ccedilla => events::VirtualKeyCode::Ccedilla, + //ffi::XK_egrave => events::VirtualKeyCode::Egrave, + //ffi::XK_eacute => events::VirtualKeyCode::Eacute, + //ffi::XK_ecircumflex => events::VirtualKeyCode::Ecircumflex, + //ffi::XK_ediaeresis => events::VirtualKeyCode::Ediaeresis, + //ffi::XK_igrave => events::VirtualKeyCode::Igrave, + //ffi::XK_iacute => events::VirtualKeyCode::Iacute, + //ffi::XK_icircumflex => events::VirtualKeyCode::Icircumflex, + //ffi::XK_idiaeresis => events::VirtualKeyCode::Idiaeresis, + //ffi::XK_eth => events::VirtualKeyCode::Eth, + //ffi::XK_ntilde => events::VirtualKeyCode::Ntilde, + //ffi::XK_ograve => events::VirtualKeyCode::Ograve, + //ffi::XK_oacute => events::VirtualKeyCode::Oacute, + //ffi::XK_ocircumflex => events::VirtualKeyCode::Ocircumflex, + //ffi::XK_otilde => events::VirtualKeyCode::Otilde, + //ffi::XK_odiaeresis => events::VirtualKeyCode::Odiaeresis, + //ffi::XK_division => events::VirtualKeyCode::Division, + //ffi::XK_oslash => events::VirtualKeyCode::Oslash, + //ffi::XK_ugrave => events::VirtualKeyCode::Ugrave, + //ffi::XK_uacute => events::VirtualKeyCode::Uacute, + //ffi::XK_ucircumflex => events::VirtualKeyCode::Ucircumflex, + //ffi::XK_udiaeresis => events::VirtualKeyCode::Udiaeresis, + //ffi::XK_yacute => events::VirtualKeyCode::Yacute, + //ffi::XK_thorn => events::VirtualKeyCode::Thorn, + //ffi::XK_ydiaeresis => events::VirtualKeyCode::Ydiaeresis, + //ffi::XK_Aogonek => events::VirtualKeyCode::Aogonek, + //ffi::XK_breve => events::VirtualKeyCode::Breve, + //ffi::XK_Lstroke => events::VirtualKeyCode::Lstroke, + //ffi::XK_Lcaron => events::VirtualKeyCode::Lcaron, + //ffi::XK_Sacute => events::VirtualKeyCode::Sacute, + //ffi::XK_Scaron => events::VirtualKeyCode::Scaron, + //ffi::XK_Scedilla => events::VirtualKeyCode::Scedilla, + //ffi::XK_Tcaron => events::VirtualKeyCode::Tcaron, + //ffi::XK_Zacute => events::VirtualKeyCode::Zacute, + //ffi::XK_Zcaron => events::VirtualKeyCode::Zcaron, + //ffi::XK_Zabovedot => events::VirtualKeyCode::Zabovedot, + //ffi::XK_aogonek => events::VirtualKeyCode::Aogonek, + //ffi::XK_ogonek => events::VirtualKeyCode::Ogonek, + //ffi::XK_lstroke => events::VirtualKeyCode::Lstroke, + //ffi::XK_lcaron => events::VirtualKeyCode::Lcaron, + //ffi::XK_sacute => events::VirtualKeyCode::Sacute, + //ffi::XK_caron => events::VirtualKeyCode::Caron, + //ffi::XK_scaron => events::VirtualKeyCode::Scaron, + //ffi::XK_scedilla => events::VirtualKeyCode::Scedilla, + //ffi::XK_tcaron => events::VirtualKeyCode::Tcaron, + //ffi::XK_zacute => events::VirtualKeyCode::Zacute, + //ffi::XK_doubleacute => events::VirtualKeyCode::Doubleacute, + //ffi::XK_zcaron => events::VirtualKeyCode::Zcaron, + //ffi::XK_zabovedot => events::VirtualKeyCode::Zabovedot, + //ffi::XK_Racute => events::VirtualKeyCode::Racute, + //ffi::XK_Abreve => events::VirtualKeyCode::Abreve, + //ffi::XK_Lacute => events::VirtualKeyCode::Lacute, + //ffi::XK_Cacute => events::VirtualKeyCode::Cacute, + //ffi::XK_Ccaron => events::VirtualKeyCode::Ccaron, + //ffi::XK_Eogonek => events::VirtualKeyCode::Eogonek, + //ffi::XK_Ecaron => events::VirtualKeyCode::Ecaron, + //ffi::XK_Dcaron => events::VirtualKeyCode::Dcaron, + //ffi::XK_Dstroke => events::VirtualKeyCode::Dstroke, + //ffi::XK_Nacute => events::VirtualKeyCode::Nacute, + //ffi::XK_Ncaron => events::VirtualKeyCode::Ncaron, + //ffi::XK_Odoubleacute => events::VirtualKeyCode::Odoubleacute, + //ffi::XK_Rcaron => events::VirtualKeyCode::Rcaron, + //ffi::XK_Uring => events::VirtualKeyCode::Uring, + //ffi::XK_Udoubleacute => events::VirtualKeyCode::Udoubleacute, + //ffi::XK_Tcedilla => events::VirtualKeyCode::Tcedilla, + //ffi::XK_racute => events::VirtualKeyCode::Racute, + //ffi::XK_abreve => events::VirtualKeyCode::Abreve, + //ffi::XK_lacute => events::VirtualKeyCode::Lacute, + //ffi::XK_cacute => events::VirtualKeyCode::Cacute, + //ffi::XK_ccaron => events::VirtualKeyCode::Ccaron, + //ffi::XK_eogonek => events::VirtualKeyCode::Eogonek, + //ffi::XK_ecaron => events::VirtualKeyCode::Ecaron, + //ffi::XK_dcaron => events::VirtualKeyCode::Dcaron, + //ffi::XK_dstroke => events::VirtualKeyCode::Dstroke, + //ffi::XK_nacute => events::VirtualKeyCode::Nacute, + //ffi::XK_ncaron => events::VirtualKeyCode::Ncaron, + //ffi::XK_odoubleacute => events::VirtualKeyCode::Odoubleacute, + //ffi::XK_udoubleacute => events::VirtualKeyCode::Udoubleacute, + //ffi::XK_rcaron => events::VirtualKeyCode::Rcaron, + //ffi::XK_uring => events::VirtualKeyCode::Uring, + //ffi::XK_tcedilla => events::VirtualKeyCode::Tcedilla, + //ffi::XK_abovedot => events::VirtualKeyCode::Abovedot, + //ffi::XK_Hstroke => events::VirtualKeyCode::Hstroke, + //ffi::XK_Hcircumflex => events::VirtualKeyCode::Hcircumflex, + //ffi::XK_Iabovedot => events::VirtualKeyCode::Iabovedot, + //ffi::XK_Gbreve => events::VirtualKeyCode::Gbreve, + //ffi::XK_Jcircumflex => events::VirtualKeyCode::Jcircumflex, + //ffi::XK_hstroke => events::VirtualKeyCode::Hstroke, + //ffi::XK_hcircumflex => events::VirtualKeyCode::Hcircumflex, + //ffi::XK_idotless => events::VirtualKeyCode::Idotless, + //ffi::XK_gbreve => events::VirtualKeyCode::Gbreve, + //ffi::XK_jcircumflex => events::VirtualKeyCode::Jcircumflex, + //ffi::XK_Cabovedot => events::VirtualKeyCode::Cabovedot, + //ffi::XK_Ccircumflex => events::VirtualKeyCode::Ccircumflex, + //ffi::XK_Gabovedot => events::VirtualKeyCode::Gabovedot, + //ffi::XK_Gcircumflex => events::VirtualKeyCode::Gcircumflex, + //ffi::XK_Ubreve => events::VirtualKeyCode::Ubreve, + //ffi::XK_Scircumflex => events::VirtualKeyCode::Scircumflex, + //ffi::XK_cabovedot => events::VirtualKeyCode::Cabovedot, + //ffi::XK_ccircumflex => events::VirtualKeyCode::Ccircumflex, + //ffi::XK_gabovedot => events::VirtualKeyCode::Gabovedot, + //ffi::XK_gcircumflex => events::VirtualKeyCode::Gcircumflex, + //ffi::XK_ubreve => events::VirtualKeyCode::Ubreve, + //ffi::XK_scircumflex => events::VirtualKeyCode::Scircumflex, + //ffi::XK_kra => events::VirtualKeyCode::Kra, + //ffi::XK_kappa => events::VirtualKeyCode::Kappa, + //ffi::XK_Rcedilla => events::VirtualKeyCode::Rcedilla, + //ffi::XK_Itilde => events::VirtualKeyCode::Itilde, + //ffi::XK_Lcedilla => events::VirtualKeyCode::Lcedilla, + //ffi::XK_Emacron => events::VirtualKeyCode::Emacron, + //ffi::XK_Gcedilla => events::VirtualKeyCode::Gcedilla, + //ffi::XK_Tslash => events::VirtualKeyCode::Tslash, + //ffi::XK_rcedilla => events::VirtualKeyCode::Rcedilla, + //ffi::XK_itilde => events::VirtualKeyCode::Itilde, + //ffi::XK_lcedilla => events::VirtualKeyCode::Lcedilla, + //ffi::XK_emacron => events::VirtualKeyCode::Emacron, + //ffi::XK_gcedilla => events::VirtualKeyCode::Gcedilla, + //ffi::XK_tslash => events::VirtualKeyCode::Tslash, + //ffi::XK_ENG => events::VirtualKeyCode::Eng, + //ffi::XK_eng => events::VirtualKeyCode::Eng, + //ffi::XK_Amacron => events::VirtualKeyCode::Amacron, + //ffi::XK_Iogonek => events::VirtualKeyCode::Iogonek, + //ffi::XK_Eabovedot => events::VirtualKeyCode::Eabovedot, + //ffi::XK_Imacron => events::VirtualKeyCode::Imacron, + //ffi::XK_Ncedilla => events::VirtualKeyCode::Ncedilla, + //ffi::XK_Omacron => events::VirtualKeyCode::Omacron, + //ffi::XK_Kcedilla => events::VirtualKeyCode::Kcedilla, + //ffi::XK_Uogonek => events::VirtualKeyCode::Uogonek, + //ffi::XK_Utilde => events::VirtualKeyCode::Utilde, + //ffi::XK_Umacron => events::VirtualKeyCode::Umacron, + //ffi::XK_amacron => events::VirtualKeyCode::Amacron, + //ffi::XK_iogonek => events::VirtualKeyCode::Iogonek, + //ffi::XK_eabovedot => events::VirtualKeyCode::Eabovedot, + //ffi::XK_imacron => events::VirtualKeyCode::Imacron, + //ffi::XK_ncedilla => events::VirtualKeyCode::Ncedilla, + //ffi::XK_omacron => events::VirtualKeyCode::Omacron, + //ffi::XK_kcedilla => events::VirtualKeyCode::Kcedilla, + //ffi::XK_uogonek => events::VirtualKeyCode::Uogonek, + //ffi::XK_utilde => events::VirtualKeyCode::Utilde, + //ffi::XK_umacron => events::VirtualKeyCode::Umacron, + //ffi::XK_overline => events::VirtualKeyCode::Overline, + //ffi::XK_kana_fullstop => events::VirtualKeyCode::Kana_fullstop, + //ffi::XK_kana_openingbracket => events::VirtualKeyCode::Kana_openingbracket, + //ffi::XK_kana_closingbracket => events::VirtualKeyCode::Kana_closingbracket, + //ffi::XK_kana_comma => events::VirtualKeyCode::Kana_comma, + //ffi::XK_kana_conjunctive => events::VirtualKeyCode::Kana_conjunctive, + //ffi::XK_kana_middledot => events::VirtualKeyCode::Kana_middledot, + //ffi::XK_kana_WO => events::VirtualKeyCode::Kana_wo, + //ffi::XK_kana_a => events::VirtualKeyCode::Kana_a, + //ffi::XK_kana_i => events::VirtualKeyCode::Kana_i, + //ffi::XK_kana_u => events::VirtualKeyCode::Kana_u, + //ffi::XK_kana_e => events::VirtualKeyCode::Kana_e, + //ffi::XK_kana_o => events::VirtualKeyCode::Kana_o, + //ffi::XK_kana_ya => events::VirtualKeyCode::Kana_ya, + //ffi::XK_kana_yu => events::VirtualKeyCode::Kana_yu, + //ffi::XK_kana_yo => events::VirtualKeyCode::Kana_yo, + //ffi::XK_kana_tsu => events::VirtualKeyCode::Kana_tsu, + //ffi::XK_kana_tu => events::VirtualKeyCode::Kana_tu, + //ffi::XK_prolongedsound => events::VirtualKeyCode::Prolongedsound, + //ffi::XK_kana_A => events::VirtualKeyCode::Kana_a, + //ffi::XK_kana_I => events::VirtualKeyCode::Kana_i, + //ffi::XK_kana_U => events::VirtualKeyCode::Kana_u, + //ffi::XK_kana_E => events::VirtualKeyCode::Kana_e, + //ffi::XK_kana_O => events::VirtualKeyCode::Kana_o, + //ffi::XK_kana_KA => events::VirtualKeyCode::Kana_ka, + //ffi::XK_kana_KI => events::VirtualKeyCode::Kana_ki, + //ffi::XK_kana_KU => events::VirtualKeyCode::Kana_ku, + //ffi::XK_kana_KE => events::VirtualKeyCode::Kana_ke, + //ffi::XK_kana_KO => events::VirtualKeyCode::Kana_ko, + //ffi::XK_kana_SA => events::VirtualKeyCode::Kana_sa, + //ffi::XK_kana_SHI => events::VirtualKeyCode::Kana_shi, + //ffi::XK_kana_SU => events::VirtualKeyCode::Kana_su, + //ffi::XK_kana_SE => events::VirtualKeyCode::Kana_se, + //ffi::XK_kana_SO => events::VirtualKeyCode::Kana_so, + //ffi::XK_kana_TA => events::VirtualKeyCode::Kana_ta, + //ffi::XK_kana_CHI => events::VirtualKeyCode::Kana_chi, + //ffi::XK_kana_TI => events::VirtualKeyCode::Kana_ti, + //ffi::XK_kana_TSU => events::VirtualKeyCode::Kana_tsu, + //ffi::XK_kana_TU => events::VirtualKeyCode::Kana_tu, + //ffi::XK_kana_TE => events::VirtualKeyCode::Kana_te, + //ffi::XK_kana_TO => events::VirtualKeyCode::Kana_to, + //ffi::XK_kana_NA => events::VirtualKeyCode::Kana_na, + //ffi::XK_kana_NI => events::VirtualKeyCode::Kana_ni, + //ffi::XK_kana_NU => events::VirtualKeyCode::Kana_nu, + //ffi::XK_kana_NE => events::VirtualKeyCode::Kana_ne, + //ffi::XK_kana_NO => events::VirtualKeyCode::Kana_no, + //ffi::XK_kana_HA => events::VirtualKeyCode::Kana_ha, + //ffi::XK_kana_HI => events::VirtualKeyCode::Kana_hi, + //ffi::XK_kana_FU => events::VirtualKeyCode::Kana_fu, + //ffi::XK_kana_HU => events::VirtualKeyCode::Kana_hu, + //ffi::XK_kana_HE => events::VirtualKeyCode::Kana_he, + //ffi::XK_kana_HO => events::VirtualKeyCode::Kana_ho, + //ffi::XK_kana_MA => events::VirtualKeyCode::Kana_ma, + //ffi::XK_kana_MI => events::VirtualKeyCode::Kana_mi, + //ffi::XK_kana_MU => events::VirtualKeyCode::Kana_mu, + //ffi::XK_kana_ME => events::VirtualKeyCode::Kana_me, + //ffi::XK_kana_MO => events::VirtualKeyCode::Kana_mo, + //ffi::XK_kana_YA => events::VirtualKeyCode::Kana_ya, + //ffi::XK_kana_YU => events::VirtualKeyCode::Kana_yu, + //ffi::XK_kana_YO => events::VirtualKeyCode::Kana_yo, + //ffi::XK_kana_RA => events::VirtualKeyCode::Kana_ra, + //ffi::XK_kana_RI => events::VirtualKeyCode::Kana_ri, + //ffi::XK_kana_RU => events::VirtualKeyCode::Kana_ru, + //ffi::XK_kana_RE => events::VirtualKeyCode::Kana_re, + //ffi::XK_kana_RO => events::VirtualKeyCode::Kana_ro, + //ffi::XK_kana_WA => events::VirtualKeyCode::Kana_wa, + //ffi::XK_kana_N => events::VirtualKeyCode::Kana_n, + //ffi::XK_voicedsound => events::VirtualKeyCode::Voicedsound, + //ffi::XK_semivoicedsound => events::VirtualKeyCode::Semivoicedsound, + //ffi::XK_kana_switch => events::VirtualKeyCode::Kana_switch, + //ffi::XK_Arabic_comma => events::VirtualKeyCode::Arabic_comma, + //ffi::XK_Arabic_semicolon => events::VirtualKeyCode::Arabic_semicolon, + //ffi::XK_Arabic_question_mark => events::VirtualKeyCode::Arabic_question_mark, + //ffi::XK_Arabic_hamza => events::VirtualKeyCode::Arabic_hamza, + //ffi::XK_Arabic_maddaonalef => events::VirtualKeyCode::Arabic_maddaonalef, + //ffi::XK_Arabic_hamzaonalef => events::VirtualKeyCode::Arabic_hamzaonalef, + //ffi::XK_Arabic_hamzaonwaw => events::VirtualKeyCode::Arabic_hamzaonwaw, + //ffi::XK_Arabic_hamzaunderalef => events::VirtualKeyCode::Arabic_hamzaunderalef, + //ffi::XK_Arabic_hamzaonyeh => events::VirtualKeyCode::Arabic_hamzaonyeh, + //ffi::XK_Arabic_alef => events::VirtualKeyCode::Arabic_alef, + //ffi::XK_Arabic_beh => events::VirtualKeyCode::Arabic_beh, + //ffi::XK_Arabic_tehmarbuta => events::VirtualKeyCode::Arabic_tehmarbuta, + //ffi::XK_Arabic_teh => events::VirtualKeyCode::Arabic_teh, + //ffi::XK_Arabic_theh => events::VirtualKeyCode::Arabic_theh, + //ffi::XK_Arabic_jeem => events::VirtualKeyCode::Arabic_jeem, + //ffi::XK_Arabic_hah => events::VirtualKeyCode::Arabic_hah, + //ffi::XK_Arabic_khah => events::VirtualKeyCode::Arabic_khah, + //ffi::XK_Arabic_dal => events::VirtualKeyCode::Arabic_dal, + //ffi::XK_Arabic_thal => events::VirtualKeyCode::Arabic_thal, + //ffi::XK_Arabic_ra => events::VirtualKeyCode::Arabic_ra, + //ffi::XK_Arabic_zain => events::VirtualKeyCode::Arabic_zain, + //ffi::XK_Arabic_seen => events::VirtualKeyCode::Arabic_seen, + //ffi::XK_Arabic_sheen => events::VirtualKeyCode::Arabic_sheen, + //ffi::XK_Arabic_sad => events::VirtualKeyCode::Arabic_sad, + //ffi::XK_Arabic_dad => events::VirtualKeyCode::Arabic_dad, + //ffi::XK_Arabic_tah => events::VirtualKeyCode::Arabic_tah, + //ffi::XK_Arabic_zah => events::VirtualKeyCode::Arabic_zah, + //ffi::XK_Arabic_ain => events::VirtualKeyCode::Arabic_ain, + //ffi::XK_Arabic_ghain => events::VirtualKeyCode::Arabic_ghain, + //ffi::XK_Arabic_tatweel => events::VirtualKeyCode::Arabic_tatweel, + //ffi::XK_Arabic_feh => events::VirtualKeyCode::Arabic_feh, + //ffi::XK_Arabic_qaf => events::VirtualKeyCode::Arabic_qaf, + //ffi::XK_Arabic_kaf => events::VirtualKeyCode::Arabic_kaf, + //ffi::XK_Arabic_lam => events::VirtualKeyCode::Arabic_lam, + //ffi::XK_Arabic_meem => events::VirtualKeyCode::Arabic_meem, + //ffi::XK_Arabic_noon => events::VirtualKeyCode::Arabic_noon, + //ffi::XK_Arabic_ha => events::VirtualKeyCode::Arabic_ha, + //ffi::XK_Arabic_heh => events::VirtualKeyCode::Arabic_heh, + //ffi::XK_Arabic_waw => events::VirtualKeyCode::Arabic_waw, + //ffi::XK_Arabic_alefmaksura => events::VirtualKeyCode::Arabic_alefmaksura, + //ffi::XK_Arabic_yeh => events::VirtualKeyCode::Arabic_yeh, + //ffi::XK_Arabic_fathatan => events::VirtualKeyCode::Arabic_fathatan, + //ffi::XK_Arabic_dammatan => events::VirtualKeyCode::Arabic_dammatan, + //ffi::XK_Arabic_kasratan => events::VirtualKeyCode::Arabic_kasratan, + //ffi::XK_Arabic_fatha => events::VirtualKeyCode::Arabic_fatha, + //ffi::XK_Arabic_damma => events::VirtualKeyCode::Arabic_damma, + //ffi::XK_Arabic_kasra => events::VirtualKeyCode::Arabic_kasra, + //ffi::XK_Arabic_shadda => events::VirtualKeyCode::Arabic_shadda, + //ffi::XK_Arabic_sukun => events::VirtualKeyCode::Arabic_sukun, + //ffi::XK_Arabic_switch => events::VirtualKeyCode::Arabic_switch, + //ffi::XK_Serbian_dje => events::VirtualKeyCode::Serbian_dje, + //ffi::XK_Macedonia_gje => events::VirtualKeyCode::Macedonia_gje, + //ffi::XK_Cyrillic_io => events::VirtualKeyCode::Cyrillic_io, + //ffi::XK_Ukrainian_ie => events::VirtualKeyCode::Ukrainian_ie, + //ffi::XK_Ukranian_je => events::VirtualKeyCode::Ukranian_je, + //ffi::XK_Macedonia_dse => events::VirtualKeyCode::Macedonia_dse, + //ffi::XK_Ukrainian_i => events::VirtualKeyCode::Ukrainian_i, + //ffi::XK_Ukranian_i => events::VirtualKeyCode::Ukranian_i, + //ffi::XK_Ukrainian_yi => events::VirtualKeyCode::Ukrainian_yi, + //ffi::XK_Ukranian_yi => events::VirtualKeyCode::Ukranian_yi, + //ffi::XK_Cyrillic_je => events::VirtualKeyCode::Cyrillic_je, + //ffi::XK_Serbian_je => events::VirtualKeyCode::Serbian_je, + //ffi::XK_Cyrillic_lje => events::VirtualKeyCode::Cyrillic_lje, + //ffi::XK_Serbian_lje => events::VirtualKeyCode::Serbian_lje, + //ffi::XK_Cyrillic_nje => events::VirtualKeyCode::Cyrillic_nje, + //ffi::XK_Serbian_nje => events::VirtualKeyCode::Serbian_nje, + //ffi::XK_Serbian_tshe => events::VirtualKeyCode::Serbian_tshe, + //ffi::XK_Macedonia_kje => events::VirtualKeyCode::Macedonia_kje, + //ffi::XK_Byelorussian_shortu => events::VirtualKeyCode::Byelorussian_shortu, + //ffi::XK_Cyrillic_dzhe => events::VirtualKeyCode::Cyrillic_dzhe, + //ffi::XK_Serbian_dze => events::VirtualKeyCode::Serbian_dze, + //ffi::XK_numerosign => events::VirtualKeyCode::Numerosign, + //ffi::XK_Serbian_DJE => events::VirtualKeyCode::Serbian_dje, + //ffi::XK_Macedonia_GJE => events::VirtualKeyCode::Macedonia_gje, + //ffi::XK_Cyrillic_IO => events::VirtualKeyCode::Cyrillic_io, + //ffi::XK_Ukrainian_IE => events::VirtualKeyCode::Ukrainian_ie, + //ffi::XK_Ukranian_JE => events::VirtualKeyCode::Ukranian_je, + //ffi::XK_Macedonia_DSE => events::VirtualKeyCode::Macedonia_dse, + //ffi::XK_Ukrainian_I => events::VirtualKeyCode::Ukrainian_i, + //ffi::XK_Ukranian_I => events::VirtualKeyCode::Ukranian_i, + //ffi::XK_Ukrainian_YI => events::VirtualKeyCode::Ukrainian_yi, + //ffi::XK_Ukranian_YI => events::VirtualKeyCode::Ukranian_yi, + //ffi::XK_Cyrillic_JE => events::VirtualKeyCode::Cyrillic_je, + //ffi::XK_Serbian_JE => events::VirtualKeyCode::Serbian_je, + //ffi::XK_Cyrillic_LJE => events::VirtualKeyCode::Cyrillic_lje, + //ffi::XK_Serbian_LJE => events::VirtualKeyCode::Serbian_lje, + //ffi::XK_Cyrillic_NJE => events::VirtualKeyCode::Cyrillic_nje, + //ffi::XK_Serbian_NJE => events::VirtualKeyCode::Serbian_nje, + //ffi::XK_Serbian_TSHE => events::VirtualKeyCode::Serbian_tshe, + //ffi::XK_Macedonia_KJE => events::VirtualKeyCode::Macedonia_kje, + //ffi::XK_Byelorussian_SHORTU => events::VirtualKeyCode::Byelorussian_shortu, + //ffi::XK_Cyrillic_DZHE => events::VirtualKeyCode::Cyrillic_dzhe, + //ffi::XK_Serbian_DZE => events::VirtualKeyCode::Serbian_dze, + //ffi::XK_Cyrillic_yu => events::VirtualKeyCode::Cyrillic_yu, + //ffi::XK_Cyrillic_a => events::VirtualKeyCode::Cyrillic_a, + //ffi::XK_Cyrillic_be => events::VirtualKeyCode::Cyrillic_be, + //ffi::XK_Cyrillic_tse => events::VirtualKeyCode::Cyrillic_tse, + //ffi::XK_Cyrillic_de => events::VirtualKeyCode::Cyrillic_de, + //ffi::XK_Cyrillic_ie => events::VirtualKeyCode::Cyrillic_ie, + //ffi::XK_Cyrillic_ef => events::VirtualKeyCode::Cyrillic_ef, + //ffi::XK_Cyrillic_ghe => events::VirtualKeyCode::Cyrillic_ghe, + //ffi::XK_Cyrillic_ha => events::VirtualKeyCode::Cyrillic_ha, + //ffi::XK_Cyrillic_i => events::VirtualKeyCode::Cyrillic_i, + //ffi::XK_Cyrillic_shorti => events::VirtualKeyCode::Cyrillic_shorti, + //ffi::XK_Cyrillic_ka => events::VirtualKeyCode::Cyrillic_ka, + //ffi::XK_Cyrillic_el => events::VirtualKeyCode::Cyrillic_el, + //ffi::XK_Cyrillic_em => events::VirtualKeyCode::Cyrillic_em, + //ffi::XK_Cyrillic_en => events::VirtualKeyCode::Cyrillic_en, + //ffi::XK_Cyrillic_o => events::VirtualKeyCode::Cyrillic_o, + //ffi::XK_Cyrillic_pe => events::VirtualKeyCode::Cyrillic_pe, + //ffi::XK_Cyrillic_ya => events::VirtualKeyCode::Cyrillic_ya, + //ffi::XK_Cyrillic_er => events::VirtualKeyCode::Cyrillic_er, + //ffi::XK_Cyrillic_es => events::VirtualKeyCode::Cyrillic_es, + //ffi::XK_Cyrillic_te => events::VirtualKeyCode::Cyrillic_te, + //ffi::XK_Cyrillic_u => events::VirtualKeyCode::Cyrillic_u, + //ffi::XK_Cyrillic_zhe => events::VirtualKeyCode::Cyrillic_zhe, + //ffi::XK_Cyrillic_ve => events::VirtualKeyCode::Cyrillic_ve, + //ffi::XK_Cyrillic_softsign => events::VirtualKeyCode::Cyrillic_softsign, + //ffi::XK_Cyrillic_yeru => events::VirtualKeyCode::Cyrillic_yeru, + //ffi::XK_Cyrillic_ze => events::VirtualKeyCode::Cyrillic_ze, + //ffi::XK_Cyrillic_sha => events::VirtualKeyCode::Cyrillic_sha, + //ffi::XK_Cyrillic_e => events::VirtualKeyCode::Cyrillic_e, + //ffi::XK_Cyrillic_shcha => events::VirtualKeyCode::Cyrillic_shcha, + //ffi::XK_Cyrillic_che => events::VirtualKeyCode::Cyrillic_che, + //ffi::XK_Cyrillic_hardsign => events::VirtualKeyCode::Cyrillic_hardsign, + //ffi::XK_Cyrillic_YU => events::VirtualKeyCode::Cyrillic_yu, + //ffi::XK_Cyrillic_A => events::VirtualKeyCode::Cyrillic_a, + //ffi::XK_Cyrillic_BE => events::VirtualKeyCode::Cyrillic_be, + //ffi::XK_Cyrillic_TSE => events::VirtualKeyCode::Cyrillic_tse, + //ffi::XK_Cyrillic_DE => events::VirtualKeyCode::Cyrillic_de, + //ffi::XK_Cyrillic_IE => events::VirtualKeyCode::Cyrillic_ie, + //ffi::XK_Cyrillic_EF => events::VirtualKeyCode::Cyrillic_ef, + //ffi::XK_Cyrillic_GHE => events::VirtualKeyCode::Cyrillic_ghe, + //ffi::XK_Cyrillic_HA => events::VirtualKeyCode::Cyrillic_ha, + //ffi::XK_Cyrillic_I => events::VirtualKeyCode::Cyrillic_i, + //ffi::XK_Cyrillic_SHORTI => events::VirtualKeyCode::Cyrillic_shorti, + //ffi::XK_Cyrillic_KA => events::VirtualKeyCode::Cyrillic_ka, + //ffi::XK_Cyrillic_EL => events::VirtualKeyCode::Cyrillic_el, + //ffi::XK_Cyrillic_EM => events::VirtualKeyCode::Cyrillic_em, + //ffi::XK_Cyrillic_EN => events::VirtualKeyCode::Cyrillic_en, + //ffi::XK_Cyrillic_O => events::VirtualKeyCode::Cyrillic_o, + //ffi::XK_Cyrillic_PE => events::VirtualKeyCode::Cyrillic_pe, + //ffi::XK_Cyrillic_YA => events::VirtualKeyCode::Cyrillic_ya, + //ffi::XK_Cyrillic_ER => events::VirtualKeyCode::Cyrillic_er, + //ffi::XK_Cyrillic_ES => events::VirtualKeyCode::Cyrillic_es, + //ffi::XK_Cyrillic_TE => events::VirtualKeyCode::Cyrillic_te, + //ffi::XK_Cyrillic_U => events::VirtualKeyCode::Cyrillic_u, + //ffi::XK_Cyrillic_ZHE => events::VirtualKeyCode::Cyrillic_zhe, + //ffi::XK_Cyrillic_VE => events::VirtualKeyCode::Cyrillic_ve, + //ffi::XK_Cyrillic_SOFTSIGN => events::VirtualKeyCode::Cyrillic_softsign, + //ffi::XK_Cyrillic_YERU => events::VirtualKeyCode::Cyrillic_yeru, + //ffi::XK_Cyrillic_ZE => events::VirtualKeyCode::Cyrillic_ze, + //ffi::XK_Cyrillic_SHA => events::VirtualKeyCode::Cyrillic_sha, + //ffi::XK_Cyrillic_E => events::VirtualKeyCode::Cyrillic_e, + //ffi::XK_Cyrillic_SHCHA => events::VirtualKeyCode::Cyrillic_shcha, + //ffi::XK_Cyrillic_CHE => events::VirtualKeyCode::Cyrillic_che, + //ffi::XK_Cyrillic_HARDSIGN => events::VirtualKeyCode::Cyrillic_hardsign, + //ffi::XK_Greek_ALPHAaccent => events::VirtualKeyCode::Greek_alphaaccent, + //ffi::XK_Greek_EPSILONaccent => events::VirtualKeyCode::Greek_epsilonaccent, + //ffi::XK_Greek_ETAaccent => events::VirtualKeyCode::Greek_etaaccent, + //ffi::XK_Greek_IOTAaccent => events::VirtualKeyCode::Greek_iotaaccent, + //ffi::XK_Greek_IOTAdiaeresis => events::VirtualKeyCode::Greek_iotadiaeresis, + //ffi::XK_Greek_OMICRONaccent => events::VirtualKeyCode::Greek_omicronaccent, + //ffi::XK_Greek_UPSILONaccent => events::VirtualKeyCode::Greek_upsilonaccent, + //ffi::XK_Greek_UPSILONdieresis => events::VirtualKeyCode::Greek_upsilondieresis, + //ffi::XK_Greek_OMEGAaccent => events::VirtualKeyCode::Greek_omegaaccent, + //ffi::XK_Greek_accentdieresis => events::VirtualKeyCode::Greek_accentdieresis, + //ffi::XK_Greek_horizbar => events::VirtualKeyCode::Greek_horizbar, + //ffi::XK_Greek_alphaaccent => events::VirtualKeyCode::Greek_alphaaccent, + //ffi::XK_Greek_epsilonaccent => events::VirtualKeyCode::Greek_epsilonaccent, + //ffi::XK_Greek_etaaccent => events::VirtualKeyCode::Greek_etaaccent, + //ffi::XK_Greek_iotaaccent => events::VirtualKeyCode::Greek_iotaaccent, + //ffi::XK_Greek_iotadieresis => events::VirtualKeyCode::Greek_iotadieresis, + //ffi::XK_Greek_iotaaccentdieresis => events::VirtualKeyCode::Greek_iotaaccentdieresis, + //ffi::XK_Greek_omicronaccent => events::VirtualKeyCode::Greek_omicronaccent, + //ffi::XK_Greek_upsilonaccent => events::VirtualKeyCode::Greek_upsilonaccent, + //ffi::XK_Greek_upsilondieresis => events::VirtualKeyCode::Greek_upsilondieresis, + //ffi::XK_Greek_upsilonaccentdieresis => events::VirtualKeyCode::Greek_upsilonaccentdieresis, + //ffi::XK_Greek_omegaaccent => events::VirtualKeyCode::Greek_omegaaccent, + //ffi::XK_Greek_ALPHA => events::VirtualKeyCode::Greek_alpha, + //ffi::XK_Greek_BETA => events::VirtualKeyCode::Greek_beta, + //ffi::XK_Greek_GAMMA => events::VirtualKeyCode::Greek_gamma, + //ffi::XK_Greek_DELTA => events::VirtualKeyCode::Greek_delta, + //ffi::XK_Greek_EPSILON => events::VirtualKeyCode::Greek_epsilon, + //ffi::XK_Greek_ZETA => events::VirtualKeyCode::Greek_zeta, + //ffi::XK_Greek_ETA => events::VirtualKeyCode::Greek_eta, + //ffi::XK_Greek_THETA => events::VirtualKeyCode::Greek_theta, + //ffi::XK_Greek_IOTA => events::VirtualKeyCode::Greek_iota, + //ffi::XK_Greek_KAPPA => events::VirtualKeyCode::Greek_kappa, + //ffi::XK_Greek_LAMDA => events::VirtualKeyCode::Greek_lamda, + //ffi::XK_Greek_LAMBDA => events::VirtualKeyCode::Greek_lambda, + //ffi::XK_Greek_MU => events::VirtualKeyCode::Greek_mu, + //ffi::XK_Greek_NU => events::VirtualKeyCode::Greek_nu, + //ffi::XK_Greek_XI => events::VirtualKeyCode::Greek_xi, + //ffi::XK_Greek_OMICRON => events::VirtualKeyCode::Greek_omicron, + //ffi::XK_Greek_PI => events::VirtualKeyCode::Greek_pi, + //ffi::XK_Greek_RHO => events::VirtualKeyCode::Greek_rho, + //ffi::XK_Greek_SIGMA => events::VirtualKeyCode::Greek_sigma, + //ffi::XK_Greek_TAU => events::VirtualKeyCode::Greek_tau, + //ffi::XK_Greek_UPSILON => events::VirtualKeyCode::Greek_upsilon, + //ffi::XK_Greek_PHI => events::VirtualKeyCode::Greek_phi, + //ffi::XK_Greek_CHI => events::VirtualKeyCode::Greek_chi, + //ffi::XK_Greek_PSI => events::VirtualKeyCode::Greek_psi, + //ffi::XK_Greek_OMEGA => events::VirtualKeyCode::Greek_omega, + //ffi::XK_Greek_alpha => events::VirtualKeyCode::Greek_alpha, + //ffi::XK_Greek_beta => events::VirtualKeyCode::Greek_beta, + //ffi::XK_Greek_gamma => events::VirtualKeyCode::Greek_gamma, + //ffi::XK_Greek_delta => events::VirtualKeyCode::Greek_delta, + //ffi::XK_Greek_epsilon => events::VirtualKeyCode::Greek_epsilon, + //ffi::XK_Greek_zeta => events::VirtualKeyCode::Greek_zeta, + //ffi::XK_Greek_eta => events::VirtualKeyCode::Greek_eta, + //ffi::XK_Greek_theta => events::VirtualKeyCode::Greek_theta, + //ffi::XK_Greek_iota => events::VirtualKeyCode::Greek_iota, + //ffi::XK_Greek_kappa => events::VirtualKeyCode::Greek_kappa, + //ffi::XK_Greek_lamda => events::VirtualKeyCode::Greek_lamda, + //ffi::XK_Greek_lambda => events::VirtualKeyCode::Greek_lambda, + //ffi::XK_Greek_mu => events::VirtualKeyCode::Greek_mu, + //ffi::XK_Greek_nu => events::VirtualKeyCode::Greek_nu, + //ffi::XK_Greek_xi => events::VirtualKeyCode::Greek_xi, + //ffi::XK_Greek_omicron => events::VirtualKeyCode::Greek_omicron, + //ffi::XK_Greek_pi => events::VirtualKeyCode::Greek_pi, + //ffi::XK_Greek_rho => events::VirtualKeyCode::Greek_rho, + //ffi::XK_Greek_sigma => events::VirtualKeyCode::Greek_sigma, + //ffi::XK_Greek_finalsmallsigma => events::VirtualKeyCode::Greek_finalsmallsigma, + //ffi::XK_Greek_tau => events::VirtualKeyCode::Greek_tau, + //ffi::XK_Greek_upsilon => events::VirtualKeyCode::Greek_upsilon, + //ffi::XK_Greek_phi => events::VirtualKeyCode::Greek_phi, + //ffi::XK_Greek_chi => events::VirtualKeyCode::Greek_chi, + //ffi::XK_Greek_psi => events::VirtualKeyCode::Greek_psi, + //ffi::XK_Greek_omega => events::VirtualKeyCode::Greek_omega, + //ffi::XK_Greek_switch => events::VirtualKeyCode::Greek_switch, + //ffi::XK_leftradical => events::VirtualKeyCode::Leftradical, + //ffi::XK_topleftradical => events::VirtualKeyCode::Topleftradical, + //ffi::XK_horizconnector => events::VirtualKeyCode::Horizconnector, + //ffi::XK_topintegral => events::VirtualKeyCode::Topintegral, + //ffi::XK_botintegral => events::VirtualKeyCode::Botintegral, + //ffi::XK_vertconnector => events::VirtualKeyCode::Vertconnector, + //ffi::XK_topleftsqbracket => events::VirtualKeyCode::Topleftsqbracket, + //ffi::XK_botleftsqbracket => events::VirtualKeyCode::Botleftsqbracket, + //ffi::XK_toprightsqbracket => events::VirtualKeyCode::Toprightsqbracket, + //ffi::XK_botrightsqbracket => events::VirtualKeyCode::Botrightsqbracket, + //ffi::XK_topleftparens => events::VirtualKeyCode::Topleftparens, + //ffi::XK_botleftparens => events::VirtualKeyCode::Botleftparens, + //ffi::XK_toprightparens => events::VirtualKeyCode::Toprightparens, + //ffi::XK_botrightparens => events::VirtualKeyCode::Botrightparens, + //ffi::XK_leftmiddlecurlybrace => events::VirtualKeyCode::Leftmiddlecurlybrace, + //ffi::XK_rightmiddlecurlybrace => events::VirtualKeyCode::Rightmiddlecurlybrace, + //ffi::XK_topleftsummation => events::VirtualKeyCode::Topleftsummation, + //ffi::XK_botleftsummation => events::VirtualKeyCode::Botleftsummation, + //ffi::XK_topvertsummationconnector => events::VirtualKeyCode::Topvertsummationconnector, + //ffi::XK_botvertsummationconnector => events::VirtualKeyCode::Botvertsummationconnector, + //ffi::XK_toprightsummation => events::VirtualKeyCode::Toprightsummation, + //ffi::XK_botrightsummation => events::VirtualKeyCode::Botrightsummation, + //ffi::XK_rightmiddlesummation => events::VirtualKeyCode::Rightmiddlesummation, + //ffi::XK_lessthanequal => events::VirtualKeyCode::Lessthanequal, + //ffi::XK_notequal => events::VirtualKeyCode::Notequal, + //ffi::XK_greaterthanequal => events::VirtualKeyCode::Greaterthanequal, + //ffi::XK_integral => events::VirtualKeyCode::Integral, + //ffi::XK_therefore => events::VirtualKeyCode::Therefore, + //ffi::XK_variation => events::VirtualKeyCode::Variation, + //ffi::XK_infinity => events::VirtualKeyCode::Infinity, + //ffi::XK_nabla => events::VirtualKeyCode::Nabla, + //ffi::XK_approximate => events::VirtualKeyCode::Approximate, + //ffi::XK_similarequal => events::VirtualKeyCode::Similarequal, + //ffi::XK_ifonlyif => events::VirtualKeyCode::Ifonlyif, + //ffi::XK_implies => events::VirtualKeyCode::Implies, + //ffi::XK_identical => events::VirtualKeyCode::Identical, + //ffi::XK_radical => events::VirtualKeyCode::Radical, + //ffi::XK_includedin => events::VirtualKeyCode::Includedin, + //ffi::XK_includes => events::VirtualKeyCode::Includes, + //ffi::XK_intersection => events::VirtualKeyCode::Intersection, + //ffi::XK_union => events::VirtualKeyCode::Union, + //ffi::XK_logicaland => events::VirtualKeyCode::Logicaland, + //ffi::XK_logicalor => events::VirtualKeyCode::Logicalor, + //ffi::XK_partialderivative => events::VirtualKeyCode::Partialderivative, + //ffi::XK_function => events::VirtualKeyCode::Function, + //ffi::XK_leftarrow => events::VirtualKeyCode::Leftarrow, + //ffi::XK_uparrow => events::VirtualKeyCode::Uparrow, + //ffi::XK_rightarrow => events::VirtualKeyCode::Rightarrow, + //ffi::XK_downarrow => events::VirtualKeyCode::Downarrow, + //ffi::XK_blank => events::VirtualKeyCode::Blank, + //ffi::XK_soliddiamond => events::VirtualKeyCode::Soliddiamond, + //ffi::XK_checkerboard => events::VirtualKeyCode::Checkerboard, + //ffi::XK_ht => events::VirtualKeyCode::Ht, + //ffi::XK_ff => events::VirtualKeyCode::Ff, + //ffi::XK_cr => events::VirtualKeyCode::Cr, + //ffi::XK_lf => events::VirtualKeyCode::Lf, + //ffi::XK_nl => events::VirtualKeyCode::Nl, + //ffi::XK_vt => events::VirtualKeyCode::Vt, + //ffi::XK_lowrightcorner => events::VirtualKeyCode::Lowrightcorner, + //ffi::XK_uprightcorner => events::VirtualKeyCode::Uprightcorner, + //ffi::XK_upleftcorner => events::VirtualKeyCode::Upleftcorner, + //ffi::XK_lowleftcorner => events::VirtualKeyCode::Lowleftcorner, + //ffi::XK_crossinglines => events::VirtualKeyCode::Crossinglines, + //ffi::XK_horizlinescan1 => events::VirtualKeyCode::Horizlinescan1, + //ffi::XK_horizlinescan3 => events::VirtualKeyCode::Horizlinescan3, + //ffi::XK_horizlinescan5 => events::VirtualKeyCode::Horizlinescan5, + //ffi::XK_horizlinescan7 => events::VirtualKeyCode::Horizlinescan7, + //ffi::XK_horizlinescan9 => events::VirtualKeyCode::Horizlinescan9, + //ffi::XK_leftt => events::VirtualKeyCode::Leftt, + //ffi::XK_rightt => events::VirtualKeyCode::Rightt, + //ffi::XK_bott => events::VirtualKeyCode::Bott, + //ffi::XK_topt => events::VirtualKeyCode::Topt, + //ffi::XK_vertbar => events::VirtualKeyCode::Vertbar, + //ffi::XK_emspace => events::VirtualKeyCode::Emspace, + //ffi::XK_enspace => events::VirtualKeyCode::Enspace, + //ffi::XK_em3space => events::VirtualKeyCode::Em3space, + //ffi::XK_em4space => events::VirtualKeyCode::Em4space, + //ffi::XK_digitspace => events::VirtualKeyCode::Digitspace, + //ffi::XK_punctspace => events::VirtualKeyCode::Punctspace, + //ffi::XK_thinspace => events::VirtualKeyCode::Thinspace, + //ffi::XK_hairspace => events::VirtualKeyCode::Hairspace, + //ffi::XK_emdash => events::VirtualKeyCode::Emdash, + //ffi::XK_endash => events::VirtualKeyCode::Endash, + //ffi::XK_signifblank => events::VirtualKeyCode::Signifblank, + //ffi::XK_ellipsis => events::VirtualKeyCode::Ellipsis, + //ffi::XK_doubbaselinedot => events::VirtualKeyCode::Doubbaselinedot, + //ffi::XK_onethird => events::VirtualKeyCode::Onethird, + //ffi::XK_twothirds => events::VirtualKeyCode::Twothirds, + //ffi::XK_onefifth => events::VirtualKeyCode::Onefifth, + //ffi::XK_twofifths => events::VirtualKeyCode::Twofifths, + //ffi::XK_threefifths => events::VirtualKeyCode::Threefifths, + //ffi::XK_fourfifths => events::VirtualKeyCode::Fourfifths, + //ffi::XK_onesixth => events::VirtualKeyCode::Onesixth, + //ffi::XK_fivesixths => events::VirtualKeyCode::Fivesixths, + //ffi::XK_careof => events::VirtualKeyCode::Careof, + //ffi::XK_figdash => events::VirtualKeyCode::Figdash, + //ffi::XK_leftanglebracket => events::VirtualKeyCode::Leftanglebracket, + //ffi::XK_decimalpoint => events::VirtualKeyCode::Decimalpoint, + //ffi::XK_rightanglebracket => events::VirtualKeyCode::Rightanglebracket, + //ffi::XK_marker => events::VirtualKeyCode::Marker, + //ffi::XK_oneeighth => events::VirtualKeyCode::Oneeighth, + //ffi::XK_threeeighths => events::VirtualKeyCode::Threeeighths, + //ffi::XK_fiveeighths => events::VirtualKeyCode::Fiveeighths, + //ffi::XK_seveneighths => events::VirtualKeyCode::Seveneighths, + //ffi::XK_trademark => events::VirtualKeyCode::Trademark, + //ffi::XK_signaturemark => events::VirtualKeyCode::Signaturemark, + //ffi::XK_trademarkincircle => events::VirtualKeyCode::Trademarkincircle, + //ffi::XK_leftopentriangle => events::VirtualKeyCode::Leftopentriangle, + //ffi::XK_rightopentriangle => events::VirtualKeyCode::Rightopentriangle, + //ffi::XK_emopencircle => events::VirtualKeyCode::Emopencircle, + //ffi::XK_emopenrectangle => events::VirtualKeyCode::Emopenrectangle, + //ffi::XK_leftsinglequotemark => events::VirtualKeyCode::Leftsinglequotemark, + //ffi::XK_rightsinglequotemark => events::VirtualKeyCode::Rightsinglequotemark, + //ffi::XK_leftdoublequotemark => events::VirtualKeyCode::Leftdoublequotemark, + //ffi::XK_rightdoublequotemark => events::VirtualKeyCode::Rightdoublequotemark, + //ffi::XK_prescription => events::VirtualKeyCode::Prescription, + //ffi::XK_minutes => events::VirtualKeyCode::Minutes, + //ffi::XK_seconds => events::VirtualKeyCode::Seconds, + //ffi::XK_latincross => events::VirtualKeyCode::Latincross, + //ffi::XK_hexagram => events::VirtualKeyCode::Hexagram, + //ffi::XK_filledrectbullet => events::VirtualKeyCode::Filledrectbullet, + //ffi::XK_filledlefttribullet => events::VirtualKeyCode::Filledlefttribullet, + //ffi::XK_filledrighttribullet => events::VirtualKeyCode::Filledrighttribullet, + //ffi::XK_emfilledcircle => events::VirtualKeyCode::Emfilledcircle, + //ffi::XK_emfilledrect => events::VirtualKeyCode::Emfilledrect, + //ffi::XK_enopencircbullet => events::VirtualKeyCode::Enopencircbullet, + //ffi::XK_enopensquarebullet => events::VirtualKeyCode::Enopensquarebullet, + //ffi::XK_openrectbullet => events::VirtualKeyCode::Openrectbullet, + //ffi::XK_opentribulletup => events::VirtualKeyCode::Opentribulletup, + //ffi::XK_opentribulletdown => events::VirtualKeyCode::Opentribulletdown, + //ffi::XK_openstar => events::VirtualKeyCode::Openstar, + //ffi::XK_enfilledcircbullet => events::VirtualKeyCode::Enfilledcircbullet, + //ffi::XK_enfilledsqbullet => events::VirtualKeyCode::Enfilledsqbullet, + //ffi::XK_filledtribulletup => events::VirtualKeyCode::Filledtribulletup, + //ffi::XK_filledtribulletdown => events::VirtualKeyCode::Filledtribulletdown, + //ffi::XK_leftpointer => events::VirtualKeyCode::Leftpointer, + //ffi::XK_rightpointer => events::VirtualKeyCode::Rightpointer, + //ffi::XK_club => events::VirtualKeyCode::Club, + //ffi::XK_diamond => events::VirtualKeyCode::Diamond, + //ffi::XK_heart => events::VirtualKeyCode::Heart, + //ffi::XK_maltesecross => events::VirtualKeyCode::Maltesecross, + //ffi::XK_dagger => events::VirtualKeyCode::Dagger, + //ffi::XK_doubledagger => events::VirtualKeyCode::Doubledagger, + //ffi::XK_checkmark => events::VirtualKeyCode::Checkmark, + //ffi::XK_ballotcross => events::VirtualKeyCode::Ballotcross, + //ffi::XK_musicalsharp => events::VirtualKeyCode::Musicalsharp, + //ffi::XK_musicalflat => events::VirtualKeyCode::Musicalflat, + //ffi::XK_malesymbol => events::VirtualKeyCode::Malesymbol, + //ffi::XK_femalesymbol => events::VirtualKeyCode::Femalesymbol, + //ffi::XK_telephone => events::VirtualKeyCode::Telephone, + //ffi::XK_telephonerecorder => events::VirtualKeyCode::Telephonerecorder, + //ffi::XK_phonographcopyright => events::VirtualKeyCode::Phonographcopyright, + //ffi::XK_caret => events::VirtualKeyCode::Caret, + //ffi::XK_singlelowquotemark => events::VirtualKeyCode::Singlelowquotemark, + //ffi::XK_doublelowquotemark => events::VirtualKeyCode::Doublelowquotemark, + //ffi::XK_cursor => events::VirtualKeyCode::Cursor, + //ffi::XK_leftcaret => events::VirtualKeyCode::Leftcaret, + //ffi::XK_rightcaret => events::VirtualKeyCode::Rightcaret, + //ffi::XK_downcaret => events::VirtualKeyCode::Downcaret, + //ffi::XK_upcaret => events::VirtualKeyCode::Upcaret, + //ffi::XK_overbar => events::VirtualKeyCode::Overbar, + //ffi::XK_downtack => events::VirtualKeyCode::Downtack, + //ffi::XK_upshoe => events::VirtualKeyCode::Upshoe, + //ffi::XK_downstile => events::VirtualKeyCode::Downstile, + //ffi::XK_underbar => events::VirtualKeyCode::Underbar, + //ffi::XK_jot => events::VirtualKeyCode::Jot, + //ffi::XK_quad => events::VirtualKeyCode::Quad, + //ffi::XK_uptack => events::VirtualKeyCode::Uptack, + //ffi::XK_circle => events::VirtualKeyCode::Circle, + //ffi::XK_upstile => events::VirtualKeyCode::Upstile, + //ffi::XK_downshoe => events::VirtualKeyCode::Downshoe, + //ffi::XK_rightshoe => events::VirtualKeyCode::Rightshoe, + //ffi::XK_leftshoe => events::VirtualKeyCode::Leftshoe, + //ffi::XK_lefttack => events::VirtualKeyCode::Lefttack, + //ffi::XK_righttack => events::VirtualKeyCode::Righttack, + //ffi::XK_hebrew_doublelowline => events::VirtualKeyCode::Hebrew_doublelowline, + //ffi::XK_hebrew_aleph => events::VirtualKeyCode::Hebrew_aleph, + //ffi::XK_hebrew_bet => events::VirtualKeyCode::Hebrew_bet, + //ffi::XK_hebrew_beth => events::VirtualKeyCode::Hebrew_beth, + //ffi::XK_hebrew_gimel => events::VirtualKeyCode::Hebrew_gimel, + //ffi::XK_hebrew_gimmel => events::VirtualKeyCode::Hebrew_gimmel, + //ffi::XK_hebrew_dalet => events::VirtualKeyCode::Hebrew_dalet, + //ffi::XK_hebrew_daleth => events::VirtualKeyCode::Hebrew_daleth, + //ffi::XK_hebrew_he => events::VirtualKeyCode::Hebrew_he, + //ffi::XK_hebrew_waw => events::VirtualKeyCode::Hebrew_waw, + //ffi::XK_hebrew_zain => events::VirtualKeyCode::Hebrew_zain, + //ffi::XK_hebrew_zayin => events::VirtualKeyCode::Hebrew_zayin, + //ffi::XK_hebrew_chet => events::VirtualKeyCode::Hebrew_chet, + //ffi::XK_hebrew_het => events::VirtualKeyCode::Hebrew_het, + //ffi::XK_hebrew_tet => events::VirtualKeyCode::Hebrew_tet, + //ffi::XK_hebrew_teth => events::VirtualKeyCode::Hebrew_teth, + //ffi::XK_hebrew_yod => events::VirtualKeyCode::Hebrew_yod, + //ffi::XK_hebrew_finalkaph => events::VirtualKeyCode::Hebrew_finalkaph, + //ffi::XK_hebrew_kaph => events::VirtualKeyCode::Hebrew_kaph, + //ffi::XK_hebrew_lamed => events::VirtualKeyCode::Hebrew_lamed, + //ffi::XK_hebrew_finalmem => events::VirtualKeyCode::Hebrew_finalmem, + //ffi::XK_hebrew_mem => events::VirtualKeyCode::Hebrew_mem, + //ffi::XK_hebrew_finalnun => events::VirtualKeyCode::Hebrew_finalnun, + //ffi::XK_hebrew_nun => events::VirtualKeyCode::Hebrew_nun, + //ffi::XK_hebrew_samech => events::VirtualKeyCode::Hebrew_samech, + //ffi::XK_hebrew_samekh => events::VirtualKeyCode::Hebrew_samekh, + //ffi::XK_hebrew_ayin => events::VirtualKeyCode::Hebrew_ayin, + //ffi::XK_hebrew_finalpe => events::VirtualKeyCode::Hebrew_finalpe, + //ffi::XK_hebrew_pe => events::VirtualKeyCode::Hebrew_pe, + //ffi::XK_hebrew_finalzade => events::VirtualKeyCode::Hebrew_finalzade, + //ffi::XK_hebrew_finalzadi => events::VirtualKeyCode::Hebrew_finalzadi, + //ffi::XK_hebrew_zade => events::VirtualKeyCode::Hebrew_zade, + //ffi::XK_hebrew_zadi => events::VirtualKeyCode::Hebrew_zadi, + //ffi::XK_hebrew_qoph => events::VirtualKeyCode::Hebrew_qoph, + //ffi::XK_hebrew_kuf => events::VirtualKeyCode::Hebrew_kuf, + //ffi::XK_hebrew_resh => events::VirtualKeyCode::Hebrew_resh, + //ffi::XK_hebrew_shin => events::VirtualKeyCode::Hebrew_shin, + //ffi::XK_hebrew_taw => events::VirtualKeyCode::Hebrew_taw, + //ffi::XK_hebrew_taf => events::VirtualKeyCode::Hebrew_taf, + //ffi::XK_Hebrew_switch => events::VirtualKeyCode::Hebrew_switch, + ffi::XF86XK_Back => VirtualKeyCode::NavigateBackward, + ffi::XF86XK_Forward => VirtualKeyCode::NavigateForward, + ffi::XF86XK_Copy => VirtualKeyCode::Copy, + ffi::XF86XK_Paste => VirtualKeyCode::Paste, + ffi::XF86XK_Cut => VirtualKeyCode::Cut, + _ => return None + }) +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ffi.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ffi.rs new file mode 100644 index 0000000..964b0ce --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ffi.rs @@ -0,0 +1,8 @@ +pub use x11_dl::keysym::*; +pub use x11_dl::xcursor::*; +pub use x11_dl::xlib::*; +pub use x11_dl::xinput::*; +pub use x11_dl::xinput2::*; +pub use x11_dl::xlib_xcb::*; +pub use x11_dl::error::OpenError; +pub use x11_dl::xrandr::*; diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/callbacks.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/callbacks.rs new file mode 100644 index 0000000..0618b23 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/callbacks.rs @@ -0,0 +1,185 @@ +use std::ptr; +use std::sync::Arc; +use std::collections::HashMap; +use std::os::raw::c_char; + +use super::{ffi, XConnection, XError}; + +use super::inner::{close_im, ImeInner}; +use super::input_method::PotentialInputMethods; +use super::context::{ImeContextCreationError, ImeContext}; + +pub unsafe fn xim_set_callback( + xconn: &Arc<XConnection>, + xim: ffi::XIM, + field: *const c_char, + callback: *mut ffi::XIMCallback, +) -> Result<(), XError> { + // It's advisable to wrap variadic FFI functions in our own functions, as we want to minimize + // access that isn't type-checked. + (xconn.xlib.XSetIMValues)( + xim, + field, + callback, + ptr::null_mut::<()>(), + ); + xconn.check_errors() +} + +// Set a callback for when an input method matching the current locale modifiers becomes +// available. Note that this has nothing to do with what input methods are open or able to be +// opened, and simply uses the modifiers that are set when the callback is set. +// * This is called per locale modifier, not per input method opened with that locale modifier. +// * Trying to set this for multiple locale modifiers causes problems, i.e. one of the rebuilt +// input contexts would always silently fail to use the input method. +pub unsafe fn set_instantiate_callback( + xconn: &Arc<XConnection>, + client_data: ffi::XPointer, +) -> Result<(), XError> { + (xconn.xlib.XRegisterIMInstantiateCallback)( + xconn.display, + ptr::null_mut(), + ptr::null_mut(), + ptr::null_mut(), + Some(xim_instantiate_callback), + client_data, + ); + xconn.check_errors() +} + +pub unsafe fn unset_instantiate_callback( + xconn: &Arc<XConnection>, + client_data: ffi::XPointer, +) -> Result<(), XError> { + (xconn.xlib.XUnregisterIMInstantiateCallback)( + xconn.display, + ptr::null_mut(), + ptr::null_mut(), + ptr::null_mut(), + Some(xim_instantiate_callback), + client_data, + ); + xconn.check_errors() +} + +pub unsafe fn set_destroy_callback( + xconn: &Arc<XConnection>, + im: ffi::XIM, + inner: &ImeInner, +) -> Result<(), XError> { + xim_set_callback( + &xconn, + im, + ffi::XNDestroyCallback_0.as_ptr() as *const _, + &inner.destroy_callback as *const _ as *mut _, + ) +} + +#[derive(Debug)] +enum ReplaceImError { + MethodOpenFailed(PotentialInputMethods), + ContextCreationFailed(ImeContextCreationError), + SetDestroyCallbackFailed(XError), +} + +// Attempt to replace current IM (which may or may not be presently valid) with a new one. This +// includes replacing all existing input contexts and free'ing resources as necessary. This only +// modifies existing state if all operations succeed. +unsafe fn replace_im(inner: *mut ImeInner) -> Result<(), ReplaceImError> { + let xconn = &(*inner).xconn; + + let (new_im, is_fallback) = { + let new_im = (*inner).potential_input_methods.open_im(xconn, None); + let is_fallback = new_im.is_fallback(); + ( + new_im.ok().ok_or_else(|| { + ReplaceImError::MethodOpenFailed((*inner).potential_input_methods.clone()) + })?, + is_fallback, + ) + }; + + // It's important to always set a destroy callback, since there's otherwise potential for us + // to try to use or free a resource that's already been destroyed on the server. + { + let result = set_destroy_callback(xconn, new_im.im, &*inner); + if result.is_err() { + let _ = close_im(xconn, new_im.im); + } + result + }.map_err(ReplaceImError::SetDestroyCallbackFailed)?; + + let mut new_contexts = HashMap::new(); + for (window, old_context) in (*inner).contexts.iter() { + let spot = old_context.as_ref().map(|old_context| old_context.ic_spot); + let new_context = { + let result = ImeContext::new( + xconn, + new_im.im, + *window, + spot, + ); + if result.is_err() { + let _ = close_im(xconn, new_im.im); + } + result.map_err(ReplaceImError::ContextCreationFailed)? + }; + new_contexts.insert(*window, Some(new_context)); + } + + // If we've made it this far, everything succeeded. + let _ = (*inner).destroy_all_contexts_if_necessary(); + let _ = (*inner).close_im_if_necessary(); + (*inner).im = new_im.im; + (*inner).contexts = new_contexts; + (*inner).is_destroyed = false; + (*inner).is_fallback = is_fallback; + Ok(()) +} + +pub unsafe extern fn xim_instantiate_callback( + _display: *mut ffi::Display, + client_data: ffi::XPointer, + // This field is unsupplied. + _call_data: ffi::XPointer, +) { + let inner: *mut ImeInner = client_data as _; + if !inner.is_null() { + let xconn = &(*inner).xconn; + let result = replace_im(inner); + if result.is_ok() { + let _ = unset_instantiate_callback(xconn, client_data); + (*inner).is_fallback = false; + } else if result.is_err() && (*inner).is_destroyed { + // We have no usable input methods! + result.expect("Failed to reopen input method"); + } + } +} + +// This callback is triggered when the input method is closed on the server end. When this +// happens, XCloseIM/XDestroyIC doesn't need to be called, as the resources have already been +// free'd (attempting to do so causes our connection to freeze). +pub unsafe extern fn xim_destroy_callback( + _xim: ffi::XIM, + client_data: ffi::XPointer, + // This field is unsupplied. + _call_data: ffi::XPointer, +) { + let inner: *mut ImeInner = client_data as _; + if !inner.is_null() { + (*inner).is_destroyed = true; + let xconn = &(*inner).xconn; + if !(*inner).is_fallback { + let _ = set_instantiate_callback(xconn, client_data); + // Attempt to open fallback input method. + let result = replace_im(inner); + if result.is_ok() { + (*inner).is_fallback = true; + } else { + // We have no usable input methods! + result.expect("Failed to open fallback input method"); + } + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/context.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/context.rs new file mode 100644 index 0000000..598cd48 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/context.rs @@ -0,0 +1,134 @@ +use std::ptr; +use std::sync::Arc; +use std::os::raw::{c_short, c_void}; + +use super::{ffi, util, XConnection, XError}; + +#[derive(Debug)] +pub enum ImeContextCreationError { + XError(XError), + Null, +} + +unsafe fn create_pre_edit_attr<'a>( + xconn: &'a Arc<XConnection>, + ic_spot: &'a ffi::XPoint, +) -> util::XSmartPointer<'a, c_void> { + util::XSmartPointer::new( + xconn, + (xconn.xlib.XVaCreateNestedList)( + 0, + ffi::XNSpotLocation_0.as_ptr() as *const _, + ic_spot, + ptr::null_mut::<()>(), + ), + ).expect("XVaCreateNestedList returned NULL") +} + +// WARNING: this struct doesn't destroy its XIC resource when dropped. +// This is intentional, as it doesn't have enough information to know whether or not the context +// still exists on the server. Since `ImeInner` has that awareness, destruction must be handled +// through `ImeInner`. +#[derive(Debug)] +pub struct ImeContext { + pub ic: ffi::XIC, + pub ic_spot: ffi::XPoint, +} + +impl ImeContext { + pub unsafe fn new( + xconn: &Arc<XConnection>, + im: ffi::XIM, + window: ffi::Window, + ic_spot: Option<ffi::XPoint>, + ) -> Result<Self, ImeContextCreationError> { + let ic = if let Some(ic_spot) = ic_spot { + ImeContext::create_ic_with_spot(xconn, im, window, ic_spot) + } else { + ImeContext::create_ic(xconn, im, window) + }; + + let ic = ic.ok_or(ImeContextCreationError::Null)?; + xconn.check_errors().map_err(ImeContextCreationError::XError)?; + + Ok(ImeContext { + ic, + ic_spot: ic_spot.unwrap_or_else(|| ffi::XPoint { x: 0, y: 0 }), + }) + } + + unsafe fn create_ic( + xconn: &Arc<XConnection>, + im: ffi::XIM, + window: ffi::Window, + ) -> Option<ffi::XIC> { + let ic = (xconn.xlib.XCreateIC)( + im, + ffi::XNInputStyle_0.as_ptr() as *const _, + ffi::XIMPreeditNothing | ffi::XIMStatusNothing, + ffi::XNClientWindow_0.as_ptr() as *const _, + window, + ptr::null_mut::<()>(), + ); + if ic.is_null() { + None + } else { + Some(ic) + } + } + + unsafe fn create_ic_with_spot( + xconn: &Arc<XConnection>, + im: ffi::XIM, + window: ffi::Window, + ic_spot: ffi::XPoint, + ) -> Option<ffi::XIC> { + let pre_edit_attr = create_pre_edit_attr(xconn, &ic_spot); + let ic = (xconn.xlib.XCreateIC)( + im, + ffi::XNInputStyle_0.as_ptr() as *const _, + ffi::XIMPreeditNothing | ffi::XIMStatusNothing, + ffi::XNClientWindow_0.as_ptr() as *const _, + window, + ffi::XNPreeditAttributes_0.as_ptr() as *const _, + pre_edit_attr.ptr, + ptr::null_mut::<()>(), + ); + if ic.is_null() { + None + } else { + Some(ic) + } + } + + pub fn focus(&self, xconn: &Arc<XConnection>) -> Result<(), XError> { + unsafe { + (xconn.xlib.XSetICFocus)(self.ic); + } + xconn.check_errors() + } + + pub fn unfocus(&self, xconn: &Arc<XConnection>) -> Result<(), XError> { + unsafe { + (xconn.xlib.XUnsetICFocus)(self.ic); + } + xconn.check_errors() + } + + pub fn set_spot(&mut self, xconn: &Arc<XConnection>, x: c_short, y: c_short) { + if self.ic_spot.x == x && self.ic_spot.y == y { + return; + } + self.ic_spot = ffi::XPoint { x, y }; + + unsafe { + let pre_edit_attr = create_pre_edit_attr(xconn, &self.ic_spot); + (xconn.xlib.XSetICValues)( + self.ic, + ffi::XNPreeditAttributes_0.as_ptr() as *const _, + pre_edit_attr.ptr, + ptr::null_mut::<()>(), + ); + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/inner.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/inner.rs new file mode 100644 index 0000000..34bfbe7 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/inner.rs @@ -0,0 +1,75 @@ +use std::mem; +use std::ptr; +use std::sync::Arc; +use std::collections::HashMap; + +use super::{ffi, XConnection, XError}; + +use super::input_method::PotentialInputMethods; +use super::context::ImeContext; + +pub unsafe fn close_im(xconn: &Arc<XConnection>, im: ffi::XIM) -> Result<(), XError> { + (xconn.xlib.XCloseIM)(im); + xconn.check_errors() +} + +pub unsafe fn destroy_ic(xconn: &Arc<XConnection>, ic: ffi::XIC) -> Result<(), XError> { + (xconn.xlib.XDestroyIC)(ic); + xconn.check_errors() +} + +pub struct ImeInner { + pub xconn: Arc<XConnection>, + // WARNING: this is initially null! + pub im: ffi::XIM, + pub potential_input_methods: PotentialInputMethods, + pub contexts: HashMap<ffi::Window, Option<ImeContext>>, + // WARNING: this is initially zeroed! + pub destroy_callback: ffi::XIMCallback, + // Indicates whether or not the the input method was destroyed on the server end + // (i.e. if ibus/fcitx/etc. was terminated/restarted) + pub is_destroyed: bool, + pub is_fallback: bool, +} + +impl ImeInner { + pub fn new( + xconn: Arc<XConnection>, + potential_input_methods: PotentialInputMethods, + ) -> Self { + ImeInner { + xconn, + im: ptr::null_mut(), + potential_input_methods, + contexts: HashMap::new(), + destroy_callback: unsafe { mem::zeroed() }, + is_destroyed: false, + is_fallback: false, + } + } + + pub unsafe fn close_im_if_necessary(&self) -> Result<bool, XError> { + if !self.is_destroyed { + close_im(&self.xconn, self.im).map(|_| true) + } else { + Ok(false) + } + } + + pub unsafe fn destroy_ic_if_necessary(&self, ic: ffi::XIC) -> Result<bool, XError> { + if !self.is_destroyed { + destroy_ic(&self.xconn, ic).map(|_| true) + } else { + Ok(false) + } + } + + pub unsafe fn destroy_all_contexts_if_necessary(&self) -> Result<bool, XError> { + for context in self.contexts.values() { + if let &Some(ref context) = context { + self.destroy_ic_if_necessary(context.ic)?; + } + } + Ok(!self.is_destroyed) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/input_method.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/input_method.rs new file mode 100644 index 0000000..fee0a14 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/input_method.rs @@ -0,0 +1,283 @@ +use std::env; +use std::fmt; +use std::ptr; +use std::sync::Arc; +use std::os::raw::c_char; +use std::ffi::{CStr, CString, IntoStringError}; + +use parking_lot::Mutex; + +use super::{ffi, util, XConnection, XError}; + +lazy_static! { + static ref GLOBAL_LOCK: Mutex<()> = Default::default(); +} + +unsafe fn open_im( + xconn: &Arc<XConnection>, + locale_modifiers: &CStr, +) -> Option<ffi::XIM> { + let _lock = GLOBAL_LOCK.lock(); + + // XSetLocaleModifiers returns... + // * The current locale modifiers if it's given a NULL pointer. + // * The new locale modifiers if we succeeded in setting them. + // * NULL if the locale modifiers string is malformed. + (xconn.xlib.XSetLocaleModifiers)(locale_modifiers.as_ptr()); + + let im = (xconn.xlib.XOpenIM)( + xconn.display, + ptr::null_mut(), + ptr::null_mut(), + ptr::null_mut(), + ); + + if im.is_null() { + None + } else { + Some(im) + } +} + +#[derive(Debug)] +pub struct InputMethod { + pub im: ffi::XIM, + name: String, +} + +impl InputMethod { + fn new(im: ffi::XIM, name: String) -> Self { + InputMethod { im, name } + } +} + +#[derive(Debug)] +pub enum InputMethodResult { + /// Input method used locale modifier from `XMODIFIERS` environment variable. + XModifiers(InputMethod), + /// Input method used internal fallback locale modifier. + Fallback(InputMethod), + /// Input method could not be opened using any locale modifier tried. + Failure, +} + +impl InputMethodResult { + pub fn is_fallback(&self) -> bool { + if let &InputMethodResult::Fallback(_) = self { + true + } else { + false + } + } + + pub fn ok(self) -> Option<InputMethod> { + use self::InputMethodResult::*; + match self { + XModifiers(im) | Fallback(im) => Some(im), + Failure => None, + } + } +} + +#[derive(Debug, Clone)] +enum GetXimServersError { + XError(XError), + GetPropertyError(util::GetPropertyError), + InvalidUtf8(IntoStringError), +} + +// The root window has a property named XIM_SERVERS, which contains a list of atoms represeting +// the availabile XIM servers. For instance, if you're using ibus, it would contain an atom named +// "@server=ibus". It's possible for this property to contain multiple atoms, though presumably +// rare. Note that we replace "@server=" with "@im=" in order to match the format of locale +// modifiers, since we don't want a user who's looking at logs to ask "am I supposed to set +// XMODIFIERS to `@server=ibus`?!?" +unsafe fn get_xim_servers(xconn: &Arc<XConnection>) -> Result<Vec<String>, GetXimServersError> { + let servers_atom = xconn.get_atom_unchecked(b"XIM_SERVERS\0"); + + let root = (xconn.xlib.XDefaultRootWindow)(xconn.display); + + let mut atoms: Vec<ffi::Atom> = xconn.get_property( + root, + servers_atom, + ffi::XA_ATOM, + ).map_err(GetXimServersError::GetPropertyError)?; + + let mut names: Vec<*const c_char> = Vec::with_capacity(atoms.len()); + (xconn.xlib.XGetAtomNames)( + xconn.display, + atoms.as_mut_ptr(), + atoms.len() as _, + names.as_mut_ptr() as _, + ); + names.set_len(atoms.len()); + + let mut formatted_names = Vec::with_capacity(names.len()); + for name in names { + let string = CStr::from_ptr(name) + .to_owned() + .into_string() + .map_err(GetXimServersError::InvalidUtf8)?; + (xconn.xlib.XFree)(name as _); + formatted_names.push(string.replace("@server=", "@im=")); + } + xconn.check_errors().map_err(GetXimServersError::XError)?; + Ok(formatted_names) +} + +#[derive(Clone)] +struct InputMethodName { + c_string: CString, + string: String, +} + +impl InputMethodName { + pub fn from_string(string: String) -> Self { + let c_string = CString::new(string.clone()) + .expect("String used to construct CString contained null byte"); + InputMethodName { + c_string, + string, + } + } + + pub fn from_str(string: &str) -> Self { + let c_string = CString::new(string) + .expect("String used to construct CString contained null byte"); + InputMethodName { + c_string, + string: string.to_owned(), + } + } +} + +impl fmt::Debug for InputMethodName { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.string.fmt(f) + } +} + +#[derive(Debug, Clone)] +struct PotentialInputMethod { + name: InputMethodName, + successful: Option<bool>, +} + +impl PotentialInputMethod { + pub fn from_string(string: String) -> Self { + PotentialInputMethod { + name: InputMethodName::from_string(string), + successful: None, + } + } + + pub fn from_str(string: &str) -> Self { + PotentialInputMethod { + name: InputMethodName::from_str(string), + successful: None, + } + } + + pub fn reset(&mut self) { + self.successful = None; + } + + pub fn open_im(&mut self, xconn: &Arc<XConnection>) -> Option<InputMethod> { + let im = unsafe { open_im(xconn, &self.name.c_string) }; + self.successful = Some(im.is_some()); + im.map(|im| InputMethod::new(im, self.name.string.clone())) + } +} + +// By logging this struct, you get a sequential listing of every locale modifier tried, where it +// came from, and if it succceeded. +#[derive(Debug, Clone)] +pub struct PotentialInputMethods { + // On correctly configured systems, the XMODIFIERS environemnt variable tells us everything we + // need to know. + xmodifiers: Option<PotentialInputMethod>, + // We have some standard options at our disposal that should ostensibly always work. For users + // who only need compose sequences, this ensures that the program launches without a hitch + // For users who need more sophisticated IME features, this is more or less a silent failure. + // Logging features should be added in the future to allow both audiences to be effectively + // served. + fallbacks: [PotentialInputMethod; 2], + // For diagnostic purposes, we include the list of XIM servers that the server reports as + // being available. + _xim_servers: Result<Vec<String>, GetXimServersError>, +} + +impl PotentialInputMethods { + pub fn new(xconn: &Arc<XConnection>) -> Self { + let xmodifiers = env::var("XMODIFIERS") + .ok() + .map(PotentialInputMethod::from_string); + PotentialInputMethods { + // Since passing "" to XSetLocaleModifiers results in it defaulting to the value of + // XMODIFIERS, it's worth noting what happens if XMODIFIERS is also "". If simply + // running the program with `XMODIFIERS="" cargo run`, then assuming XMODIFIERS is + // defined in the profile (or parent environment) then that parent XMODIFIERS is used. + // If that XMODIFIERS value is also "" (i.e. if you ran `export XMODIFIERS=""`), then + // XSetLocaleModifiers uses the default local input method. Note that defining + // XMODIFIERS as "" is different from XMODIFIERS not being defined at all, since in + // that case, we get `None` and end up skipping ahead to the next method. + xmodifiers, + fallbacks: [ + // This is a standard input method that supports compose equences, which should + // always be available. `@im=none` appears to mean the same thing. + PotentialInputMethod::from_str("@im=local"), + // This explicitly specifies to use the implementation-dependent default, though + // that seems to be equivalent to just using the local input method. + PotentialInputMethod::from_str("@im="), + ], + // The XIM_SERVERS property can have surprising values. For instance, when I exited + // ibus to run fcitx, it retained the value denoting ibus. Even more surprising is + // that the fcitx input method could only be successfully opened using "@im=ibus". + // Presumably due to this quirk, it's actually possible to alternate between ibus and + // fcitx in a running application. + _xim_servers: unsafe { get_xim_servers(xconn) }, + } + } + + // This resets the `successful` field of every potential input method, ensuring we have + // accurate information when this struct is re-used by the destruction/instantiation callbacks. + fn reset(&mut self) { + if let Some(ref mut input_method) = self.xmodifiers { + input_method.reset(); + } + + for input_method in &mut self.fallbacks { + input_method.reset(); + } + } + + pub fn open_im( + &mut self, + xconn: &Arc<XConnection>, + callback: Option<&Fn() -> ()>, + ) -> InputMethodResult { + use self::InputMethodResult::*; + + self.reset(); + + if let Some(ref mut input_method) = self.xmodifiers { + let im = input_method.open_im(xconn); + if let Some(im) = im { + return XModifiers(im); + } else { + if let Some(ref callback) = callback { + callback(); + } + } + } + + for input_method in &mut self.fallbacks { + let im = input_method.open_im(xconn); + if let Some(im) = im { + return Fallback(im); + } + } + + Failure + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/mod.rs new file mode 100644 index 0000000..2298050 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/ime/mod.rs @@ -0,0 +1,165 @@ +// Important: all XIM calls need to happen from the same thread! + +mod inner; +mod input_method; +mod context; +mod callbacks; + +use std::sync::Arc; +use std::sync::mpsc::{Receiver, Sender}; + +use super::{ffi, util, XConnection, XError}; + +use self::inner::{close_im, ImeInner}; +use self::input_method::PotentialInputMethods; +use self::context::{ImeContextCreationError, ImeContext}; +use self::callbacks::*; + +pub type ImeReceiver = Receiver<(ffi::Window, i16, i16)>; +pub type ImeSender = Sender<(ffi::Window, i16, i16)>; + +#[derive(Debug)] +pub enum ImeCreationError { + OpenFailure(PotentialInputMethods), + SetDestroyCallbackFailed(XError), +} + +pub struct Ime { + xconn: Arc<XConnection>, + // The actual meat of this struct is boxed away, since it needs to have a fixed location in + // memory so we can pass a pointer to it around. + inner: Box<ImeInner>, +} + +impl Ime { + pub fn new(xconn: Arc<XConnection>) -> Result<Self, ImeCreationError> { + let potential_input_methods = PotentialInputMethods::new(&xconn); + + let (mut inner, client_data) = { + let mut inner = Box::new(ImeInner::new( + xconn, + potential_input_methods, + )); + let inner_ptr = Box::into_raw(inner); + let client_data = inner_ptr as _; + let destroy_callback = ffi::XIMCallback { + client_data, + callback: Some(xim_destroy_callback), + }; + inner = unsafe { Box::from_raw(inner_ptr) }; + inner.destroy_callback = destroy_callback; + (inner, client_data) + }; + + let xconn = Arc::clone(&inner.xconn); + + let input_method = inner.potential_input_methods.open_im(&xconn, Some(&|| { + let _ = unsafe { set_instantiate_callback(&xconn, client_data) }; + })); + + let is_fallback = input_method.is_fallback(); + if let Some(input_method) = input_method.ok() { + inner.im = input_method.im; + inner.is_fallback = is_fallback; + unsafe { + let result = set_destroy_callback(&xconn, input_method.im, &*inner) + .map_err(ImeCreationError::SetDestroyCallbackFailed); + if result.is_err() { + let _ = close_im(&xconn, input_method.im); + } + result?; + } + Ok(Ime { xconn, inner }) + } else { + Err(ImeCreationError::OpenFailure(inner.potential_input_methods)) + } + } + + pub fn is_destroyed(&self) -> bool { + self.inner.is_destroyed + } + + // This pattern is used for various methods here: + // Ok(_) indicates that nothing went wrong internally + // Ok(true) indicates that the action was actually performed + // Ok(false) indicates that the action is not presently applicable + pub fn create_context(&mut self, window: ffi::Window) + -> Result<bool, ImeContextCreationError> + { + let context = if self.is_destroyed() { + // Create empty entry in map, so that when IME is rebuilt, this window has a context. + None + } else { + Some(unsafe { ImeContext::new( + &self.inner.xconn, + self.inner.im, + window, + None, + ) }?) + }; + self.inner.contexts.insert(window, context); + Ok(!self.is_destroyed()) + } + + pub fn get_context(&self, window: ffi::Window) -> Option<ffi::XIC> { + if self.is_destroyed() { + return None; + } + if let Some(&Some(ref context)) = self.inner.contexts.get(&window) { + Some(context.ic) + } else { + None + } + } + + pub fn remove_context(&mut self, window: ffi::Window) -> Result<bool, XError> { + if let Some(Some(context)) = self.inner.contexts.remove(&window) { + unsafe { + self.inner.destroy_ic_if_necessary(context.ic)?; + } + Ok(true) + } else { + Ok(false) + } + } + + pub fn focus(&mut self, window: ffi::Window) -> Result<bool, XError> { + if self.is_destroyed() { + return Ok(false); + } + if let Some(&mut Some(ref mut context)) = self.inner.contexts.get_mut(&window) { + context.focus(&self.xconn).map(|_| true) + } else { + Ok(false) + } + } + + pub fn unfocus(&mut self, window: ffi::Window) -> Result<bool, XError> { + if self.is_destroyed() { + return Ok(false); + } + if let Some(&mut Some(ref mut context)) = self.inner.contexts.get_mut(&window) { + context.unfocus(&self.xconn).map(|_| true) + } else { + Ok(false) + } + } + + pub fn send_xim_spot(&mut self, window: ffi::Window, x: i16, y: i16) { + if self.is_destroyed() { + return; + } + if let Some(&mut Some(ref mut context)) = self.inner.contexts.get_mut(&window) { + context.set_spot(&self.xconn, x as _, y as _); + } + } +} + +impl Drop for Ime { + fn drop(&mut self) { + unsafe { + let _ = self.inner.destroy_all_contexts_if_necessary(); + let _ = self.inner.close_im_if_necessary(); + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/mod.rs new file mode 100644 index 0000000..3171289 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/mod.rs @@ -0,0 +1,1447 @@ +#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] + +pub mod ffi; +mod events; +mod monitor; +mod window; +mod xdisplay; +mod dnd; +mod ime; +pub mod util; + +pub use self::monitor::MonitorId; +pub use self::window::UnownedWindow; +pub use self::xdisplay::{XConnection, XNotSupported, XError}; + +use std::{mem, ptr, slice}; +use std::cell::RefCell; +use std::collections::HashMap; +use std::ffi::CStr; +use std::ops::Deref; +use std::os::raw::*; +use std::sync::{Arc, mpsc, Weak}; +use std::sync::atomic::{self, AtomicBool}; + +use libc::{self, setlocale, LC_CTYPE}; + +use { + ControlFlow, + CreationError, + DeviceEvent, + Event, + EventsLoopClosed, + KeyboardInput, + LogicalPosition, + LogicalSize, + WindowAttributes, + WindowEvent, +}; +use events::ModifiersState; +use platform::PlatformSpecificWindowBuilderAttributes; +use self::dnd::{Dnd, DndState}; +use self::ime::{ImeReceiver, ImeSender, ImeCreationError, Ime}; + +pub struct EventsLoop { + xconn: Arc<XConnection>, + wm_delete_window: ffi::Atom, + dnd: Dnd, + ime_receiver: ImeReceiver, + ime_sender: ImeSender, + ime: RefCell<Ime>, + randr_event_offset: c_int, + windows: RefCell<HashMap<WindowId, Weak<UnownedWindow>>>, + devices: RefCell<HashMap<DeviceId, Device>>, + xi2ext: XExtension, + pending_wakeup: Arc<AtomicBool>, + root: ffi::Window, + // A dummy, `InputOnly` window that we can use to receive wakeup events and interrupt blocking + // `XNextEvent` calls. + wakeup_dummy_window: ffi::Window, +} + +#[derive(Clone)] +pub struct EventsLoopProxy { + pending_wakeup: Weak<AtomicBool>, + xconn: Weak<XConnection>, + wakeup_dummy_window: ffi::Window, +} + +impl EventsLoop { + pub fn new(xconn: Arc<XConnection>) -> EventsLoop { + let root = unsafe { (xconn.xlib.XDefaultRootWindow)(xconn.display) }; + + let wm_delete_window = unsafe { xconn.get_atom_unchecked(b"WM_DELETE_WINDOW\0") }; + + let dnd = Dnd::new(Arc::clone(&xconn)) + .expect("Failed to call XInternAtoms when initializing drag and drop"); + + let (ime_sender, ime_receiver) = mpsc::channel(); + // Input methods will open successfully without setting the locale, but it won't be + // possible to actually commit pre-edit sequences. + unsafe { setlocale(LC_CTYPE, b"\0".as_ptr() as *const _); } + let ime = RefCell::new({ + let result = Ime::new(Arc::clone(&xconn)); + if let Err(ImeCreationError::OpenFailure(ref state)) = result { + panic!(format!("Failed to open input method: {:#?}", state)); + } + result.expect("Failed to set input method destruction callback") + }); + + let randr_event_offset = xconn.select_xrandr_input(root) + .expect("Failed to query XRandR extension"); + + let xi2ext = unsafe { + let mut result = XExtension { + opcode: mem::uninitialized(), + first_event_id: mem::uninitialized(), + first_error_id: mem::uninitialized(), + }; + let res = (xconn.xlib.XQueryExtension)( + xconn.display, + b"XInputExtension\0".as_ptr() as *const c_char, + &mut result.opcode as *mut c_int, + &mut result.first_event_id as *mut c_int, + &mut result.first_error_id as *mut c_int); + if res == ffi::False { + panic!("X server missing XInput extension"); + } + result + }; + + unsafe { + let mut xinput_major_ver = ffi::XI_2_Major; + let mut xinput_minor_ver = ffi::XI_2_Minor; + if (xconn.xinput2.XIQueryVersion)( + xconn.display, + &mut xinput_major_ver, + &mut xinput_minor_ver, + ) != ffi::Success as libc::c_int { + panic!( + "X server has XInput extension {}.{} but does not support XInput2", + xinput_major_ver, + xinput_minor_ver, + ); + } + } + + xconn.update_cached_wm_info(root); + + let wakeup_dummy_window = unsafe { + let (x, y, w, h) = (10, 10, 10, 10); + let (border_w, border_px, background_px) = (0, 0, 0); + (xconn.xlib.XCreateSimpleWindow)( + xconn.display, + root, + x, + y, + w, + h, + border_w, + border_px, + background_px, + ) + }; + + let result = EventsLoop { + xconn, + wm_delete_window, + dnd, + ime_receiver, + ime_sender, + ime, + randr_event_offset, + windows: Default::default(), + devices: Default::default(), + xi2ext, + pending_wakeup: Default::default(), + root, + wakeup_dummy_window, + }; + + // Register for device hotplug events + // (The request buffer is flushed during `init_device`) + result.xconn.select_xinput_events( + root, + ffi::XIAllDevices, + ffi::XI_HierarchyChangedMask, + ).queue(); + + result.init_device(ffi::XIAllDevices); + + result + } + + /// Returns the `XConnection` of this events loop. + #[inline] + pub fn x_connection(&self) -> &Arc<XConnection> { + &self.xconn + } + + pub fn create_proxy(&self) -> EventsLoopProxy { + EventsLoopProxy { + pending_wakeup: Arc::downgrade(&self.pending_wakeup), + xconn: Arc::downgrade(&self.xconn), + wakeup_dummy_window: self.wakeup_dummy_window, + } + } + + pub fn poll_events<F>(&mut self, mut callback: F) + where F: FnMut(Event) + { + let mut xev = unsafe { mem::uninitialized() }; + loop { + // Get next event + unsafe { + // Ensure XNextEvent won't block + let count = (self.xconn.xlib.XPending)(self.xconn.display); + if count == 0 { + break; + } + + (self.xconn.xlib.XNextEvent)(self.xconn.display, &mut xev); + } + self.process_event(&mut xev, &mut callback); + } + } + + pub fn run_forever<F>(&mut self, mut callback: F) + where F: FnMut(Event) -> ControlFlow + { + let mut xev = unsafe { mem::uninitialized() }; + + loop { + unsafe { (self.xconn.xlib.XNextEvent)(self.xconn.display, &mut xev) }; // Blocks as necessary + + let mut control_flow = ControlFlow::Continue; + + // Track whether or not `Break` was returned when processing the event. + { + let mut cb = |event| { + if let ControlFlow::Break = callback(event) { + control_flow = ControlFlow::Break; + } + }; + + self.process_event(&mut xev, &mut cb); + } + + if let ControlFlow::Break = control_flow { + break; + } + } + } + + fn process_event<F>(&mut self, xev: &mut ffi::XEvent, mut callback: F) + where F: FnMut(Event) + { + // XFilterEvent tells us when an event has been discarded by the input method. + // Specifically, this involves all of the KeyPress events in compose/pre-edit sequences, + // along with an extra copy of the KeyRelease events. This also prevents backspace and + // arrow keys from being detected twice. + if ffi::True == unsafe { (self.xconn.xlib.XFilterEvent)( + xev, + { let xev: &ffi::XAnyEvent = xev.as_ref(); xev.window } + ) } { + return; + } + + let event_type = xev.get_type(); + match event_type { + ffi::MappingNotify => { + unsafe { (self.xconn.xlib.XRefreshKeyboardMapping)(xev.as_mut()); } + self.xconn.check_errors().expect("Failed to call XRefreshKeyboardMapping"); + } + + ffi::ClientMessage => { + let client_msg: &ffi::XClientMessageEvent = xev.as_ref(); + + let window = client_msg.window; + let window_id = mkwid(window); + + if client_msg.data.get_long(0) as ffi::Atom == self.wm_delete_window { + callback(Event::WindowEvent { window_id, event: WindowEvent::CloseRequested }); + } else if client_msg.message_type == self.dnd.atoms.enter { + let source_window = client_msg.data.get_long(0) as c_ulong; + let flags = client_msg.data.get_long(1); + let version = flags >> 24; + self.dnd.version = Some(version); + let has_more_types = flags - (flags & (c_long::max_value() - 1)) == 1; + if !has_more_types { + let type_list = vec![ + client_msg.data.get_long(2) as c_ulong, + client_msg.data.get_long(3) as c_ulong, + client_msg.data.get_long(4) as c_ulong + ]; + self.dnd.type_list = Some(type_list); + } else if let Ok(more_types) = unsafe { self.dnd.get_type_list(source_window) } { + self.dnd.type_list = Some(more_types); + } + } else if client_msg.message_type == self.dnd.atoms.position { + // This event occurs every time the mouse moves while a file's being dragged + // over our window. We emit HoveredFile in response; while the macOS backend + // does that upon a drag entering, XDND doesn't have access to the actual drop + // data until this event. For parity with other platforms, we only emit + // `HoveredFile` the first time, though if winit's API is later extended to + // supply position updates with `HoveredFile` or another event, implementing + // that here would be trivial. + + let source_window = client_msg.data.get_long(0) as c_ulong; + + // Equivalent to `(x << shift) | y` + // where `shift = mem::size_of::<c_short>() * 8` + // Note that coordinates are in "desktop space", not "window space" + // (in X11 parlance, they're root window coordinates) + //let packed_coordinates = client_msg.data.get_long(2); + //let shift = mem::size_of::<libc::c_short>() * 8; + //let x = packed_coordinates >> shift; + //let y = packed_coordinates & !(x << shift); + + // By our own state flow, `version` should never be `None` at this point. + let version = self.dnd.version.unwrap_or(5); + + // Action is specified in versions 2 and up, though we don't need it anyway. + //let action = client_msg.data.get_long(4); + + let accepted = if let Some(ref type_list) = self.dnd.type_list { + type_list.contains(&self.dnd.atoms.uri_list) + } else { + false + }; + + if accepted { + self.dnd.source_window = Some(source_window); + unsafe { + if self.dnd.result.is_none() { + let time = if version >= 1 { + client_msg.data.get_long(3) as c_ulong + } else { + // In version 0, time isn't specified + ffi::CurrentTime + }; + // This results in the `SelectionNotify` event below + self.dnd.convert_selection(window, time); + } + self.dnd.send_status(window, source_window, DndState::Accepted) + .expect("Failed to send `XdndStatus` message."); + } + } else { + unsafe { + self.dnd.send_status(window, source_window, DndState::Rejected) + .expect("Failed to send `XdndStatus` message."); + } + self.dnd.reset(); + } + } else if client_msg.message_type == self.dnd.atoms.drop { + let (source_window, state) = if let Some(source_window) = self.dnd.source_window { + if let Some(Ok(ref path_list)) = self.dnd.result { + for path in path_list { + callback(Event::WindowEvent { + window_id, + event: WindowEvent::DroppedFile(path.clone()), + }); + } + } + (source_window, DndState::Accepted) + } else { + // `source_window` won't be part of our DND state if we already rejected the drop in our + // `XdndPosition` handler. + let source_window = client_msg.data.get_long(0) as c_ulong; + (source_window, DndState::Rejected) + }; + unsafe { + self.dnd.send_finished(window, source_window, state) + .expect("Failed to send `XdndFinished` message."); + } + self.dnd.reset(); + } else if client_msg.message_type == self.dnd.atoms.leave { + self.dnd.reset(); + callback(Event::WindowEvent { + window_id, + event: WindowEvent::HoveredFileCancelled, + }); + } else if self.pending_wakeup.load(atomic::Ordering::Relaxed) { + self.pending_wakeup.store(false, atomic::Ordering::Relaxed); + callback(Event::Awakened); + } + } + + ffi::SelectionNotify => { + let xsel: &ffi::XSelectionEvent = xev.as_ref(); + + let window = xsel.requestor; + let window_id = mkwid(window); + + if xsel.property == self.dnd.atoms.selection { + let mut result = None; + + // This is where we receive data from drag and drop + if let Ok(mut data) = unsafe { self.dnd.read_data(window) } { + let parse_result = self.dnd.parse_data(&mut data); + if let Ok(ref path_list) = parse_result { + for path in path_list { + callback(Event::WindowEvent { + window_id, + event: WindowEvent::HoveredFile(path.clone()), + }); + } + } + result = Some(parse_result); + } + + self.dnd.result = result; + } + } + + ffi::ConfigureNotify => { + #[derive(Debug, Default)] + struct Events { + resized: Option<WindowEvent>, + moved: Option<WindowEvent>, + dpi_changed: Option<WindowEvent>, + } + + let xev: &ffi::XConfigureEvent = xev.as_ref(); + let xwindow = xev.window; + let events = self.with_window(xwindow, |window| { + // So apparently... + // `XSendEvent` (synthetic `ConfigureNotify`) -> position relative to root + // `XConfigureNotify` (real `ConfigureNotify`) -> position relative to parent + // https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.5 + // We don't want to send `Moved` when this is false, since then every `Resized` + // (whether the window moved or not) is accompanied by an extraneous `Moved` event + // that has a position relative to the parent window. + let is_synthetic = xev.send_event == ffi::True; + + // These are both in physical space. + let new_inner_size = (xev.width as u32, xev.height as u32); + let new_inner_position = (xev.x as i32, xev.y as i32); + + let mut monitor = window.get_current_monitor(); // This must be done *before* locking! + let mut shared_state_lock = window.shared_state.lock(); + + let (mut resized, moved) = { + let resized = util::maybe_change(&mut shared_state_lock.size, new_inner_size); + let moved = if is_synthetic { + util::maybe_change(&mut shared_state_lock.inner_position, new_inner_position) + } else { + // Detect when frame extents change. + // Since this isn't synthetic, as per the notes above, this position is relative to the + // parent window. + let rel_parent = new_inner_position; + if util::maybe_change(&mut shared_state_lock.inner_position_rel_parent, rel_parent) { + // This ensures we process the next `Moved`. + shared_state_lock.inner_position = None; + // Extra insurance against stale frame extents. + shared_state_lock.frame_extents = None; + } + false + }; + (resized, moved) + }; + + let mut events = Events::default(); + + let new_outer_position = if moved || shared_state_lock.position.is_none() { + // We need to convert client area position to window position. + let frame_extents = shared_state_lock.frame_extents + .as_ref() + .cloned() + .unwrap_or_else(|| { + let frame_extents = self.xconn.get_frame_extents_heuristic(xwindow, self.root); + shared_state_lock.frame_extents = Some(frame_extents.clone()); + frame_extents + }); + let outer = frame_extents.inner_pos_to_outer(new_inner_position.0, new_inner_position.1); + shared_state_lock.position = Some(outer); + if moved { + let logical_position = LogicalPosition::from_physical(outer, monitor.hidpi_factor); + events.moved = Some(WindowEvent::Moved(logical_position)); + } + outer + } else { + shared_state_lock.position.unwrap() + }; + + if is_synthetic { + // If we don't use the existing adjusted value when available, then the user can screw up the + // resizing by dragging across monitors *without* dropping the window. + let (width, height) = shared_state_lock.dpi_adjusted + .unwrap_or_else(|| (xev.width as f64, xev.height as f64)); + let last_hidpi_factor = shared_state_lock.guessed_dpi + .take() + .unwrap_or_else(|| { + shared_state_lock.last_monitor + .as_ref() + .map(|last_monitor| last_monitor.hidpi_factor) + .unwrap_or(1.0) + }); + let new_hidpi_factor = { + let window_rect = util::AaRect::new(new_outer_position, new_inner_size); + monitor = self.xconn.get_monitor_for_window(Some(window_rect)); + let new_hidpi_factor = monitor.hidpi_factor; + shared_state_lock.last_monitor = Some(monitor.clone()); + new_hidpi_factor + }; + if last_hidpi_factor != new_hidpi_factor { + events.dpi_changed = Some(WindowEvent::HiDpiFactorChanged(new_hidpi_factor)); + let (new_width, new_height, flusher) = window.adjust_for_dpi( + last_hidpi_factor, + new_hidpi_factor, + width, + height, + ); + flusher.queue(); + shared_state_lock.dpi_adjusted = Some((new_width, new_height)); + // if the DPI factor changed, force a resize event to ensure the logical + // size is computed with the right DPI factor + resized = true; + } + } + + // This is a hack to ensure that the DPI adjusted resize is actually applied on all WMs. KWin + // doesn't need this, but Xfwm does. The hack should not be run on other WMs, since tiling + // WMs constrain the window size, making the resize fail. This would cause an endless stream of + // XResizeWindow requests, making Xorg, the winit client, and the WM consume 100% of CPU. + if let Some(adjusted_size) = shared_state_lock.dpi_adjusted { + let rounded_size = (adjusted_size.0.round() as u32, adjusted_size.1.round() as u32); + if new_inner_size == rounded_size || !util::wm_name_is_one_of(&["Xfwm4"]) { + // When this finally happens, the event will not be synthetic. + shared_state_lock.dpi_adjusted = None; + } else { + unsafe { + (self.xconn.xlib.XResizeWindow)( + self.xconn.display, + xwindow, + rounded_size.0 as c_uint, + rounded_size.1 as c_uint, + ); + } + } + } + + if resized { + let logical_size = LogicalSize::from_physical(new_inner_size, monitor.hidpi_factor); + events.resized = Some(WindowEvent::Resized(logical_size)); + } + + events + }); + + if let Some(events) = events { + let window_id = mkwid(xwindow); + if let Some(event) = events.dpi_changed { + callback(Event::WindowEvent { window_id, event }); + } + if let Some(event) = events.resized { + callback(Event::WindowEvent { window_id, event }); + } + if let Some(event) = events.moved { + callback(Event::WindowEvent { window_id, event }); + } + } + } + + ffi::ReparentNotify => { + let xev: &ffi::XReparentEvent = xev.as_ref(); + + // This is generally a reliable way to detect when the window manager's been + // replaced, though this event is only fired by reparenting window managers + // (which is almost all of them). Failing to correctly update WM info doesn't + // really have much impact, since on the WMs affected (xmonad, dwm, etc.) the only + // effect is that we waste some time trying to query unsupported properties. + self.xconn.update_cached_wm_info(self.root); + + self.with_window(xev.window, |window| { + window.invalidate_cached_frame_extents(); + }); + } + + ffi::DestroyNotify => { + let xev: &ffi::XDestroyWindowEvent = xev.as_ref(); + + let window = xev.window; + let window_id = mkwid(window); + + // In the event that the window's been destroyed without being dropped first, we + // cleanup again here. + self.windows.borrow_mut().remove(&WindowId(window)); + + // Since all XIM stuff needs to happen from the same thread, we destroy the input + // context here instead of when dropping the window. + self.ime + .borrow_mut() + .remove_context(window) + .expect("Failed to destroy input context"); + + callback(Event::WindowEvent { window_id, event: WindowEvent::Destroyed }); + } + + ffi::Expose => { + let xev: &ffi::XExposeEvent = xev.as_ref(); + + let window = xev.window; + let window_id = mkwid(window); + + callback(Event::WindowEvent { window_id, event: WindowEvent::Refresh }); + } + + ffi::KeyPress | ffi::KeyRelease => { + use events::ElementState::{Pressed, Released}; + + // Note that in compose/pre-edit sequences, this will always be Released. + let state = if xev.get_type() == ffi::KeyPress { + Pressed + } else { + Released + }; + + let xkev: &mut ffi::XKeyEvent = xev.as_mut(); + + let window = xkev.window; + let window_id = mkwid(window); + + // Standard virtual core keyboard ID. XInput2 needs to be used to get a reliable + // value, though this should only be an issue under multiseat configurations. + let device = util::VIRTUAL_CORE_KEYBOARD; + let device_id = mkdid(device); + + // When a compose sequence or IME pre-edit is finished, it ends in a KeyPress with + // a keycode of 0. + if xkev.keycode != 0 { + let modifiers = ModifiersState { + alt: xkev.state & ffi::Mod1Mask != 0, + shift: xkev.state & ffi::ShiftMask != 0, + ctrl: xkev.state & ffi::ControlMask != 0, + logo: xkev.state & ffi::Mod4Mask != 0, + }; + + let keysym = unsafe { + let mut keysym = 0; + (self.xconn.xlib.XLookupString)( + xkev, + ptr::null_mut(), + 0, + &mut keysym, + ptr::null_mut(), + ); + self.xconn.check_errors().expect("Failed to lookup keysym"); + keysym + }; + let virtual_keycode = events::keysym_to_element(keysym as c_uint); + + callback(Event::WindowEvent { + window_id, + event: WindowEvent::KeyboardInput { + device_id, + input: KeyboardInput { + state, + scancode: xkev.keycode - 8, + virtual_keycode, + modifiers, + }, + } + }); + } + + if state == Pressed { + let written = if let Some(ic) = self.ime.borrow().get_context(window) { + self.xconn.lookup_utf8(ic, xkev) + } else { + return; + }; + + for chr in written.chars() { + let event = Event::WindowEvent { + window_id, + event: WindowEvent::ReceivedCharacter(chr), + }; + callback(event); + } + } + } + + ffi::GenericEvent => { + let guard = if let Some(e) = GenericEventCookie::from_event(&self.xconn, *xev) { e } else { return }; + let xev = &guard.cookie; + if self.xi2ext.opcode != xev.extension { + return; + } + + use events::WindowEvent::{Focused, CursorEntered, MouseInput, CursorLeft, CursorMoved, MouseWheel, AxisMotion}; + use events::ElementState::{Pressed, Released}; + use events::MouseButton::{Left, Right, Middle, Other}; + use events::MouseScrollDelta::LineDelta; + use events::{Touch, TouchPhase}; + + match xev.evtype { + ffi::XI_ButtonPress | ffi::XI_ButtonRelease => { + let xev: &ffi::XIDeviceEvent = unsafe { &*(xev.data as *const _) }; + let window_id = mkwid(xev.event); + let device_id = mkdid(xev.deviceid); + if (xev.flags & ffi::XIPointerEmulated) != 0 { + // Deliver multi-touch events instead of emulated mouse events. + let return_now = self + .with_window(xev.event, |window| window.multitouch) + .unwrap_or(true); + if return_now { return; } + } + + let modifiers = ModifiersState::from(xev.mods); + + let state = if xev.evtype == ffi::XI_ButtonPress { + Pressed + } else { + Released + }; + match xev.detail as u32 { + ffi::Button1 => callback(Event::WindowEvent { + window_id, + event: MouseInput { + device_id, + state, + button: Left, + modifiers, + }, + }), + ffi::Button2 => callback(Event::WindowEvent { + window_id, + event: MouseInput { + device_id, + state, + button: Middle, + modifiers, + }, + }), + ffi::Button3 => callback(Event::WindowEvent { + window_id, + event: MouseInput { + device_id, + state, + button: Right, + modifiers, + }, + }), + + // Suppress emulated scroll wheel clicks, since we handle the real motion events for those. + // In practice, even clicky scroll wheels appear to be reported by evdev (and XInput2 in + // turn) as axis motion, so we don't otherwise special-case these button presses. + 4 | 5 | 6 | 7 => if xev.flags & ffi::XIPointerEmulated == 0 { + callback(Event::WindowEvent { + window_id, + event: MouseWheel { + device_id, + delta: match xev.detail { + 4 => LineDelta(0.0, 1.0), + 5 => LineDelta(0.0, -1.0), + 6 => LineDelta(-1.0, 0.0), + 7 => LineDelta(1.0, 0.0), + _ => unreachable!(), + }, + phase: TouchPhase::Moved, + modifiers, + }, + }); + }, + + x => callback(Event::WindowEvent { + window_id, + event: MouseInput { + device_id, + state, + button: Other(x as u8), + modifiers, + }, + }), + } + } + ffi::XI_Motion => { + let xev: &ffi::XIDeviceEvent = unsafe { &*(xev.data as *const _) }; + let device_id = mkdid(xev.deviceid); + let window_id = mkwid(xev.event); + let new_cursor_pos = (xev.event_x, xev.event_y); + + let modifiers = ModifiersState::from(xev.mods); + + let cursor_moved = self.with_window(xev.event, |window| { + let mut shared_state_lock = window.shared_state.lock(); + util::maybe_change(&mut shared_state_lock.cursor_pos, new_cursor_pos) + }); + if cursor_moved == Some(true) { + let dpi_factor = self.with_window(xev.event, |window| { + window.get_hidpi_factor() + }); + if let Some(dpi_factor) = dpi_factor { + let position = LogicalPosition::from_physical( + (xev.event_x as f64, xev.event_y as f64), + dpi_factor, + ); + callback(Event::WindowEvent { + window_id, + event: CursorMoved { + device_id, + position, + modifiers, + }, + }); + } else { + return; + } + } else if cursor_moved.is_none() { + return; + } + + // More gymnastics, for self.devices + let mut events = Vec::new(); + { + let mask = unsafe { slice::from_raw_parts(xev.valuators.mask, xev.valuators.mask_len as usize) }; + let mut devices = self.devices.borrow_mut(); + let physical_device = match devices.get_mut(&DeviceId(xev.sourceid)) { + Some(device) => device, + None => return, + }; + + let mut value = xev.valuators.values; + for i in 0..xev.valuators.mask_len*8 { + if ffi::XIMaskIsSet(mask, i) { + let x = unsafe { *value }; + if let Some(&mut (_, ref mut info)) = physical_device.scroll_axes.iter_mut().find(|&&mut (axis, _)| axis == i) { + let delta = (x - info.position) / info.increment; + info.position = x; + events.push(Event::WindowEvent { + window_id, + event: MouseWheel { + device_id, + delta: match info.orientation { + ScrollOrientation::Horizontal => LineDelta(delta as f32, 0.0), + // X11 vertical scroll coordinates are opposite to winit's + ScrollOrientation::Vertical => LineDelta(0.0, -delta as f32), + }, + phase: TouchPhase::Moved, + modifiers, + }, + }); + } else { + events.push(Event::WindowEvent { + window_id, + event: AxisMotion { + device_id, + axis: i as u32, + value: unsafe { *value }, + }, + }); + } + value = unsafe { value.offset(1) }; + } + } + } + for event in events { + callback(event); + } + } + + ffi::XI_Enter => { + let xev: &ffi::XIEnterEvent = unsafe { &*(xev.data as *const _) }; + + let window_id = mkwid(xev.event); + let device_id = mkdid(xev.deviceid); + + if let Some(all_info) = DeviceInfo::get(&self.xconn, ffi::XIAllDevices) { + let mut devices = self.devices.borrow_mut(); + for device_info in all_info.iter() { + if device_info.deviceid == xev.sourceid + // This is needed for resetting to work correctly on i3, and + // presumably some other WMs. On those, `XI_Enter` doesn't include + // the physical device ID, so both `sourceid` and `deviceid` are + // the virtual device. + || device_info.attachment == xev.sourceid { + let device_id = DeviceId(device_info.deviceid); + if let Some(device) = devices.get_mut(&device_id) { + device.reset_scroll_position(device_info); + } + } + } + } + callback(Event::WindowEvent { + window_id, + event: CursorEntered { device_id }, + }); + + if let Some(dpi_factor) = self.with_window(xev.event, |window| { + window.get_hidpi_factor() + }) { + let position = LogicalPosition::from_physical( + (xev.event_x as f64, xev.event_y as f64), + dpi_factor, + ); + + // The mods field on this event isn't actually populated, so query the + // pointer device. In the future, we can likely remove this round-trip by + // relying on `Xkb` for modifier values. + // + // This needs to only be done after confirming the window still exists, + // since otherwise we risk getting a `BadWindow` error if the window was + // dropped with queued events. + let modifiers = self.xconn + .query_pointer(xev.event, xev.deviceid) + .expect("Failed to query pointer device") + .get_modifier_state(); + + callback(Event::WindowEvent { + window_id, + event: CursorMoved { + device_id, + position, + modifiers, + }, + }); + } + } + ffi::XI_Leave => { + let xev: &ffi::XILeaveEvent = unsafe { &*(xev.data as *const _) }; + + // Leave, FocusIn, and FocusOut can be received by a window that's already + // been destroyed, which the user presumably doesn't want to deal with. + let window_closed = !self.window_exists(xev.event); + if !window_closed { + callback(Event::WindowEvent { + window_id: mkwid(xev.event), + event: CursorLeft { device_id: mkdid(xev.deviceid) }, + }); + } + } + ffi::XI_FocusIn => { + let xev: &ffi::XIFocusInEvent = unsafe { &*(xev.data as *const _) }; + + let dpi_factor = match self.with_window(xev.event, |window| { + window.get_hidpi_factor() + }) { + Some(dpi_factor) => dpi_factor, + None => return, + }; + let window_id = mkwid(xev.event); + + self.ime + .borrow_mut() + .focus(xev.event) + .expect("Failed to focus input context"); + + callback(Event::WindowEvent { window_id, event: Focused(true) }); + + // The deviceid for this event is for a keyboard instead of a pointer, + // so we have to do a little extra work. + let pointer_id = self.devices + .borrow() + .get(&DeviceId(xev.deviceid)) + .map(|device| device.attachment) + .unwrap_or(2); + + let position = LogicalPosition::from_physical( + (xev.event_x as f64, xev.event_y as f64), + dpi_factor, + ); + callback(Event::WindowEvent { + window_id, + event: CursorMoved { + device_id: mkdid(pointer_id), + position, + modifiers: ModifiersState::from(xev.mods), + } + }); + } + ffi::XI_FocusOut => { + let xev: &ffi::XIFocusOutEvent = unsafe { &*(xev.data as *const _) }; + if !self.window_exists(xev.event) { return; } + self.ime + .borrow_mut() + .unfocus(xev.event) + .expect("Failed to unfocus input context"); + callback(Event::WindowEvent { + window_id: mkwid(xev.event), + event: Focused(false), + }) + } + + ffi::XI_TouchBegin | ffi::XI_TouchUpdate | ffi::XI_TouchEnd => { + let xev: &ffi::XIDeviceEvent = unsafe { &*(xev.data as *const _) }; + let window_id = mkwid(xev.event); + let phase = match xev.evtype { + ffi::XI_TouchBegin => TouchPhase::Started, + ffi::XI_TouchUpdate => TouchPhase::Moved, + ffi::XI_TouchEnd => TouchPhase::Ended, + _ => unreachable!() + }; + let dpi_factor = self.with_window(xev.event, |window| { + window.get_hidpi_factor() + }); + if let Some(dpi_factor) = dpi_factor { + let location = LogicalPosition::from_physical( + (xev.event_x as f64, xev.event_y as f64), + dpi_factor, + ); + callback(Event::WindowEvent { + window_id, + event: WindowEvent::Touch(Touch { + device_id: mkdid(xev.deviceid), + phase, + location, + id: xev.detail as u64, + }), + }) + } + } + + ffi::XI_RawButtonPress | ffi::XI_RawButtonRelease => { + let xev: &ffi::XIRawEvent = unsafe { &*(xev.data as *const _) }; + if xev.flags & ffi::XIPointerEmulated == 0 { + callback(Event::DeviceEvent { device_id: mkdid(xev.deviceid), event: DeviceEvent::Button { + button: xev.detail as u32, + state: match xev.evtype { + ffi::XI_RawButtonPress => Pressed, + ffi::XI_RawButtonRelease => Released, + _ => unreachable!(), + }, + }}); + } + } + + ffi::XI_RawMotion => { + let xev: &ffi::XIRawEvent = unsafe { &*(xev.data as *const _) }; + let did = mkdid(xev.deviceid); + + let mask = unsafe { slice::from_raw_parts(xev.valuators.mask, xev.valuators.mask_len as usize) }; + let mut value = xev.raw_values; + let mut mouse_delta = (0.0, 0.0); + let mut scroll_delta = (0.0, 0.0); + for i in 0..xev.valuators.mask_len*8 { + if ffi::XIMaskIsSet(mask, i) { + let x = unsafe { *value }; + // We assume that every XInput2 device with analog axes is a pointing device emitting + // relative coordinates. + match i { + 0 => mouse_delta.0 = x, + 1 => mouse_delta.1 = x, + 2 => scroll_delta.0 = x as f32, + 3 => scroll_delta.1 = x as f32, + _ => {}, + } + callback(Event::DeviceEvent { device_id: did, event: DeviceEvent::Motion { + axis: i as u32, + value: x, + }}); + value = unsafe { value.offset(1) }; + } + } + if mouse_delta != (0.0, 0.0) { + callback(Event::DeviceEvent { device_id: did, event: DeviceEvent::MouseMotion { + delta: mouse_delta, + }}); + } + if scroll_delta != (0.0, 0.0) { + callback(Event::DeviceEvent { device_id: did, event: DeviceEvent::MouseWheel { + delta: LineDelta(scroll_delta.0, scroll_delta.1), + }}); + } + } + + ffi::XI_RawKeyPress | ffi::XI_RawKeyRelease => { + let xev: &ffi::XIRawEvent = unsafe { &*(xev.data as *const _) }; + + let state = match xev.evtype { + ffi::XI_RawKeyPress => Pressed, + ffi::XI_RawKeyRelease => Released, + _ => unreachable!(), + }; + + let device_id = xev.sourceid; + let keycode = xev.detail; + if keycode < 8 { return; } + let scancode = (keycode - 8) as u32; + + let keysym = unsafe { + (self.xconn.xlib.XKeycodeToKeysym)( + self.xconn.display, + xev.detail as ffi::KeyCode, + 0, + ) + }; + self.xconn.check_errors().expect("Failed to lookup raw keysym"); + + let virtual_keycode = events::keysym_to_element(keysym as c_uint); + + callback(Event::DeviceEvent { + device_id: mkdid(device_id), + event: DeviceEvent::Key(KeyboardInput { + scancode, + virtual_keycode, + state, + // So, in an ideal world we can use libxkbcommon to get modifiers. + // However, libxkbcommon-x11 isn't as commonly installed as one + // would hope. We can still use the Xkb extension to get + // comprehensive keyboard state updates, but interpreting that + // info manually is going to be involved. + modifiers: ModifiersState::default(), + }), + }); + } + + ffi::XI_HierarchyChanged => { + let xev: &ffi::XIHierarchyEvent = unsafe { &*(xev.data as *const _) }; + for info in unsafe { slice::from_raw_parts(xev.info, xev.num_info as usize) } { + if 0 != info.flags & (ffi::XISlaveAdded | ffi::XIMasterAdded) { + self.init_device(info.deviceid); + callback(Event::DeviceEvent { device_id: mkdid(info.deviceid), event: DeviceEvent::Added }); + } else if 0 != info.flags & (ffi::XISlaveRemoved | ffi::XIMasterRemoved) { + callback(Event::DeviceEvent { device_id: mkdid(info.deviceid), event: DeviceEvent::Removed }); + let mut devices = self.devices.borrow_mut(); + devices.remove(&DeviceId(info.deviceid)); + } + } + } + + _ => {} + } + }, + _ => { + if event_type == self.randr_event_offset { + // In the future, it would be quite easy to emit monitor hotplug events. + let prev_list = monitor::invalidate_cached_monitor_list(); + if let Some(prev_list) = prev_list { + let new_list = self.xconn.get_available_monitors(); + for new_monitor in new_list { + prev_list + .iter() + .find(|prev_monitor| prev_monitor.name == new_monitor.name) + .map(|prev_monitor| { + if new_monitor.hidpi_factor != prev_monitor.hidpi_factor { + for (window_id, window) in self.windows.borrow().iter() { + if let Some(window) = window.upgrade() { + // Check if the window is on this monitor + let monitor = window.get_current_monitor(); + if monitor.name == new_monitor.name { + callback(Event::WindowEvent { + window_id: mkwid(window_id.0), + event: WindowEvent::HiDpiFactorChanged( + new_monitor.hidpi_factor + ), + }); + let (width, height) = match window.get_inner_size_physical() { + Some(result) => result, + None => continue, + }; + let (_, _, flusher) = window.adjust_for_dpi( + prev_monitor.hidpi_factor, + new_monitor.hidpi_factor, + width as f64, + height as f64, + ); + flusher.queue(); + } + } + } + } + }); + } + } + } + }, + } + + match self.ime_receiver.try_recv() { + Ok((window_id, x, y)) => { + self.ime.borrow_mut().send_xim_spot(window_id, x, y); + }, + Err(_) => (), + } + } + + fn init_device(&self, device: c_int) { + let mut devices = self.devices.borrow_mut(); + if let Some(info) = DeviceInfo::get(&self.xconn, device) { + for info in info.iter() { + devices.insert(DeviceId(info.deviceid), Device::new(&self, info)); + } + } + } + + fn with_window<F, T>(&self, window_id: ffi::Window, callback: F) -> Option<T> + where F: Fn(&UnownedWindow) -> T + { + let mut deleted = false; + let window_id = WindowId(window_id); + let result = self.windows + .borrow() + .get(&window_id) + .and_then(|window| { + let arc = window.upgrade(); + deleted = arc.is_none(); + arc + }) + .map(|window| callback(&*window)); + if deleted { + // Garbage collection + self.windows.borrow_mut().remove(&window_id); + } + result + } + + fn window_exists(&self, window_id: ffi::Window) -> bool { + self.with_window(window_id, |_| ()).is_some() + } +} + +impl EventsLoopProxy { + pub fn wakeup(&self) -> Result<(), EventsLoopClosed> { + // Update the `EventsLoop`'s `pending_wakeup` flag. + let display = match (self.pending_wakeup.upgrade(), self.xconn.upgrade()) { + (Some(wakeup), Some(display)) => { + wakeup.store(true, atomic::Ordering::Relaxed); + display + }, + _ => return Err(EventsLoopClosed), + }; + + // Push an event on the X event queue so that methods run_forever will advance. + // + // NOTE: This design is taken from the old `WindowProxy::wakeup` implementation. It + // assumes that X11 is thread safe. Is this true? + // (WARNING: it's probably not true) + display.send_client_msg( + self.wakeup_dummy_window, + self.wakeup_dummy_window, + 0, + None, + [0, 0, 0, 0, 0], + ).flush().expect("Failed to call XSendEvent after wakeup"); + + Ok(()) + } +} + +struct DeviceInfo<'a> { + xconn: &'a XConnection, + info: *const ffi::XIDeviceInfo, + count: usize, +} + +impl<'a> DeviceInfo<'a> { + fn get(xconn: &'a XConnection, device: c_int) -> Option<Self> { + unsafe { + let mut count = mem::uninitialized(); + let info = (xconn.xinput2.XIQueryDevice)(xconn.display, device, &mut count); + xconn.check_errors() + .ok() + .and_then(|_| { + if info.is_null() || count == 0 { + None + } else { + Some(DeviceInfo { + xconn, + info, + count: count as usize, + }) + } + }) + } + } +} + +impl<'a> Drop for DeviceInfo<'a> { + fn drop(&mut self) { + assert!(!self.info.is_null()); + unsafe { (self.xconn.xinput2.XIFreeDeviceInfo)(self.info as *mut _) }; + } +} + +impl<'a> Deref for DeviceInfo<'a> { + type Target = [ffi::XIDeviceInfo]; + fn deref(&self) -> &Self::Target { + unsafe { slice::from_raw_parts(self.info, self.count) } + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct WindowId(ffi::Window); + +impl WindowId { + pub unsafe fn dummy() -> Self { + WindowId(0) + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct DeviceId(c_int); + +impl DeviceId { + pub unsafe fn dummy() -> Self { + DeviceId(0) + } +} + +pub struct Window(Arc<UnownedWindow>); + +impl Deref for Window { + type Target = UnownedWindow; + #[inline] + fn deref(&self) -> &UnownedWindow { + &*self.0 + } +} + +impl Window { + pub fn new( + event_loop: &EventsLoop, + attribs: WindowAttributes, + pl_attribs: PlatformSpecificWindowBuilderAttributes + ) -> Result<Self, CreationError> { + let window = Arc::new(UnownedWindow::new(&event_loop, attribs, pl_attribs)?); + event_loop.windows + .borrow_mut() + .insert(window.id(), Arc::downgrade(&window)); + Ok(Window(window)) + } +} + +impl Drop for Window { + fn drop(&mut self) { + let window = self.deref(); + let xconn = &window.xconn; + unsafe { + (xconn.xlib.XDestroyWindow)(xconn.display, window.id().0); + // If the window was somehow already destroyed, we'll get a `BadWindow` error, which we don't care about. + let _ = xconn.check_errors(); + } + } +} + +/// XEvents of type GenericEvent store their actual data in an XGenericEventCookie data structure. This is a wrapper to +/// extract the cookie from a GenericEvent XEvent and release the cookie data once it has been processed +struct GenericEventCookie<'a> { + xconn: &'a XConnection, + cookie: ffi::XGenericEventCookie +} + +impl<'a> GenericEventCookie<'a> { + fn from_event<'b>(xconn: &'b XConnection, event: ffi::XEvent) -> Option<GenericEventCookie<'b>> { + unsafe { + let mut cookie: ffi::XGenericEventCookie = From::from(event); + if (xconn.xlib.XGetEventData)(xconn.display, &mut cookie) == ffi::True { + Some(GenericEventCookie { xconn, cookie }) + } else { + None + } + } + } +} + +impl<'a> Drop for GenericEventCookie<'a> { + fn drop(&mut self) { + unsafe { + (self.xconn.xlib.XFreeEventData)(self.xconn.display, &mut self.cookie); + } + } +} + +#[derive(Debug, Copy, Clone)] +struct XExtension { + opcode: c_int, + first_event_id: c_int, + first_error_id: c_int, +} + +fn mkwid(w: ffi::Window) -> ::WindowId { ::WindowId(::platform::WindowId::X(WindowId(w))) } +fn mkdid(w: c_int) -> ::DeviceId { ::DeviceId(::platform::DeviceId::X(DeviceId(w))) } + +#[derive(Debug)] +struct Device { + name: String, + scroll_axes: Vec<(i32, ScrollAxis)>, + // For master devices, this is the paired device (pointer <-> keyboard). + // For slave devices, this is the master. + attachment: c_int, +} + +#[derive(Debug, Copy, Clone)] +struct ScrollAxis { + increment: f64, + orientation: ScrollOrientation, + position: f64, +} + +#[derive(Debug, Copy, Clone)] +enum ScrollOrientation { + Vertical, + Horizontal, +} + +impl Device { + fn new(el: &EventsLoop, info: &ffi::XIDeviceInfo) -> Self { + let name = unsafe { CStr::from_ptr(info.name).to_string_lossy() }; + let mut scroll_axes = Vec::new(); + + if Device::physical_device(info) { + // Register for global raw events + let mask = ffi::XI_RawMotionMask + | ffi::XI_RawButtonPressMask + | ffi::XI_RawButtonReleaseMask + | ffi::XI_RawKeyPressMask + | ffi::XI_RawKeyReleaseMask; + // The request buffer is flushed when we poll for events + el.xconn.select_xinput_events(el.root, info.deviceid, mask).queue(); + + // Identify scroll axes + for class_ptr in Device::classes(info) { + let class = unsafe { &**class_ptr }; + match class._type { + ffi::XIScrollClass => { + let info = unsafe { mem::transmute::<&ffi::XIAnyClassInfo, &ffi::XIScrollClassInfo>(class) }; + scroll_axes.push((info.number, ScrollAxis { + increment: info.increment, + orientation: match info.scroll_type { + ffi::XIScrollTypeHorizontal => ScrollOrientation::Horizontal, + ffi::XIScrollTypeVertical => ScrollOrientation::Vertical, + _ => { unreachable!() } + }, + position: 0.0, + })); + } + _ => {} + } + } + } + + let mut device = Device { + name: name.into_owned(), + scroll_axes: scroll_axes, + attachment: info.attachment, + }; + device.reset_scroll_position(info); + device + } + + fn reset_scroll_position(&mut self, info: &ffi::XIDeviceInfo) { + if Device::physical_device(info) { + for class_ptr in Device::classes(info) { + let class = unsafe { &**class_ptr }; + match class._type { + ffi::XIValuatorClass => { + let info = unsafe { mem::transmute::<&ffi::XIAnyClassInfo, &ffi::XIValuatorClassInfo>(class) }; + if let Some(&mut (_, ref mut axis)) = self.scroll_axes.iter_mut().find(|&&mut (axis, _)| axis == info.number) { + axis.position = info.value; + } + } + _ => {} + } + } + } + } + + #[inline] + fn physical_device(info: &ffi::XIDeviceInfo) -> bool { + info._use == ffi::XISlaveKeyboard || info._use == ffi::XISlavePointer || info._use == ffi::XIFloatingSlave + } + + #[inline] + fn classes(info: &ffi::XIDeviceInfo) -> &[*const ffi::XIAnyClassInfo] { + unsafe { slice::from_raw_parts(info.classes as *const *const ffi::XIAnyClassInfo, info.num_classes as usize) } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/monitor.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/monitor.rs new file mode 100644 index 0000000..d6309f6 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/monitor.rs @@ -0,0 +1,269 @@ +use std::os::raw::*; + +use parking_lot::Mutex; + +use {PhysicalPosition, PhysicalSize}; +use super::{util, XConnection, XError}; +use super::ffi::{ + RRCrtcChangeNotifyMask, + RROutputPropertyNotifyMask, + RRScreenChangeNotifyMask, + True, + Window, + XRRScreenResources, +}; + +// Used to test XRandR < 1.5 code path. This should always be committed as false. +const FORCE_RANDR_COMPAT: bool = false; +// Also used for testing. This should always be committed as false. +const DISABLE_MONITOR_LIST_CACHING: bool = false; + +lazy_static! { + static ref XRANDR_VERSION: Mutex<Option<(c_int, c_int)>> = Mutex::default(); + static ref MONITORS: Mutex<Option<Vec<MonitorId>>> = Mutex::default(); +} + +fn version_is_at_least(major: c_int, minor: c_int) -> bool { + if let Some((avail_major, avail_minor)) = *XRANDR_VERSION.lock() { + if avail_major == major { + avail_minor >= minor + } else { + avail_major > major + } + } else { + unreachable!(); + } +} + +pub fn invalidate_cached_monitor_list() -> Option<Vec<MonitorId>> { + // We update this lazily. + (*MONITORS.lock()).take() +} + +#[derive(Debug, Clone)] +pub struct MonitorId { + /// The actual id + id: u32, + /// The name of the monitor + pub(crate) name: String, + /// The size of the monitor + dimensions: (u32, u32), + /// The position of the monitor in the X screen + position: (i32, i32), + /// If the monitor is the primary one + primary: bool, + /// The DPI scale factor + pub(crate) hidpi_factor: f64, + /// Used to determine which windows are on this monitor + pub(crate) rect: util::AaRect, +} + +impl MonitorId { + fn from_repr( + xconn: &XConnection, + resources: *mut XRRScreenResources, + id: u32, + repr: util::MonitorRepr, + primary: bool, + ) -> Option<Self> { + let (name, hidpi_factor) = unsafe { xconn.get_output_info(resources, &repr)? }; + let (dimensions, position) = unsafe { (repr.get_dimensions(), repr.get_position()) }; + let rect = util::AaRect::new(position, dimensions); + Some(MonitorId { + id, + name, + hidpi_factor, + dimensions, + position, + primary, + rect, + }) + } + + pub fn get_name(&self) -> Option<String> { + Some(self.name.clone()) + } + + #[inline] + pub fn get_native_identifier(&self) -> u32 { + self.id as u32 + } + + pub fn get_dimensions(&self) -> PhysicalSize { + self.dimensions.into() + } + + pub fn get_position(&self) -> PhysicalPosition { + self.position.into() + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + self.hidpi_factor + } +} + +impl XConnection { + pub fn get_monitor_for_window(&self, window_rect: Option<util::AaRect>) -> MonitorId { + let monitors = self.get_available_monitors(); + let default = monitors + .get(0) + .expect("[winit] Failed to find any monitors using XRandR."); + + let window_rect = match window_rect { + Some(rect) => rect, + None => return default.to_owned(), + }; + + let mut largest_overlap = 0; + let mut matched_monitor = default; + for monitor in &monitors { + let overlapping_area = window_rect.get_overlapping_area(&monitor.rect); + if overlapping_area > largest_overlap { + largest_overlap = overlapping_area; + matched_monitor = &monitor; + } + } + + matched_monitor.to_owned() + } + + fn query_monitor_list(&self) -> Vec<MonitorId> { + unsafe { + let root = (self.xlib.XDefaultRootWindow)(self.display); + // WARNING: this function is supposedly very slow, on the order of hundreds of ms. + // Upon failure, `resources` will be null. + let resources = (self.xrandr.XRRGetScreenResources)(self.display, root); + if resources.is_null() { + panic!("[winit] `XRRGetScreenResources` returned NULL. That should only happen if the root window doesn't exist."); + } + + let mut available; + let mut has_primary = false; + + if self.xrandr_1_5.is_some() && version_is_at_least(1, 5) && !FORCE_RANDR_COMPAT { + // We're in XRandR >= 1.5, enumerate monitors. This supports things like MST and + // videowalls. + let xrandr_1_5 = self.xrandr_1_5.as_ref().unwrap(); + let mut monitor_count = 0; + let monitors = (xrandr_1_5.XRRGetMonitors)(self.display, root, 1, &mut monitor_count); + assert!(monitor_count >= 0); + available = Vec::with_capacity(monitor_count as usize); + for monitor_index in 0..monitor_count { + let monitor = monitors.offset(monitor_index as isize); + let is_primary = (*monitor).primary != 0; + has_primary |= is_primary; + MonitorId::from_repr( + self, + resources, + monitor_index as u32, + monitor.into(), + is_primary, + ).map(|monitor_id| available.push(monitor_id)); + } + (xrandr_1_5.XRRFreeMonitors)(monitors); + } else { + // We're in XRandR < 1.5, enumerate CRTCs. Everything will work except MST and + // videowall setups will also show monitors that aren't in the logical groups the user + // cares about. + let primary = (self.xrandr.XRRGetOutputPrimary)(self.display, root); + available = Vec::with_capacity((*resources).ncrtc as usize); + for crtc_index in 0..(*resources).ncrtc { + let crtc_id = *((*resources).crtcs.offset(crtc_index as isize)); + let crtc = (self.xrandr.XRRGetCrtcInfo)(self.display, resources, crtc_id); + let is_active = (*crtc).width > 0 && (*crtc).height > 0 && (*crtc).noutput > 0; + if is_active { + let crtc = util::MonitorRepr::from(crtc); + let is_primary = crtc.get_output() == primary; + has_primary |= is_primary; + MonitorId::from_repr( + self, + resources, + crtc_id as u32, + crtc, + is_primary, + ).map(|monitor_id| available.push(monitor_id)); + } + (self.xrandr.XRRFreeCrtcInfo)(crtc); + } + } + + // If no monitors were detected as being primary, we just pick one ourselves! + if !has_primary { + if let Some(ref mut fallback) = available.first_mut() { + // Setting this here will come in handy if we ever add an `is_primary` method. + fallback.primary = true; + } + } + + (self.xrandr.XRRFreeScreenResources)(resources); + available + } + } + + pub fn get_available_monitors(&self) -> Vec<MonitorId> { + let mut monitors_lock = MONITORS.lock(); + (*monitors_lock) + .as_ref() + .cloned() + .or_else(|| { + let monitors = Some(self.query_monitor_list()); + if !DISABLE_MONITOR_LIST_CACHING { + (*monitors_lock) = monitors.clone(); + } + monitors + }) + .unwrap() + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + self.get_available_monitors() + .into_iter() + .find(|monitor| monitor.primary) + .expect("[winit] Failed to find any monitors using XRandR.") + } + + pub fn select_xrandr_input(&self, root: Window) -> Result<c_int, XError> { + { + let mut version_lock = XRANDR_VERSION.lock(); + if version_lock.is_none() { + let mut major = 0; + let mut minor = 0; + let has_extension = unsafe { + (self.xrandr.XRRQueryVersion)( + self.display, + &mut major, + &mut minor, + ) + }; + if has_extension != True { + panic!("[winit] XRandR extension not available."); + } + *version_lock = Some((major, minor)); + } + } + + let mut event_offset = 0; + let mut error_offset = 0; + let status = unsafe { + (self.xrandr.XRRQueryExtension)( + self.display, + &mut event_offset, + &mut error_offset, + ) + }; + + if status != True { + self.check_errors()?; + unreachable!("[winit] `XRRQueryExtension` failed but no error was received."); + } + + let mask = RRCrtcChangeNotifyMask + | RROutputPropertyNotifyMask + | RRScreenChangeNotifyMask; + unsafe { (self.xrandr.XRRSelectInput)(self.display, root, mask) }; + + Ok(event_offset) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/atom.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/atom.rs new file mode 100644 index 0000000..fe97d3a --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/atom.rs @@ -0,0 +1,72 @@ +use std::collections::HashMap; +use std::ffi::{CStr, CString}; +use std::fmt::Debug; +use std::os::raw::*; + +use parking_lot::Mutex; + +use super::*; + +type AtomCache = HashMap<CString, ffi::Atom>; + +lazy_static! { + static ref ATOM_CACHE: Mutex<AtomCache> = Mutex::new(HashMap::with_capacity(2048)); +} + +impl XConnection { + pub fn get_atom<T: AsRef<CStr> + Debug>(&self, name: T) -> ffi::Atom { + let name = name.as_ref(); + let mut atom_cache_lock = ATOM_CACHE.lock(); + let cached_atom = (*atom_cache_lock).get(name).cloned(); + if let Some(atom) = cached_atom { + atom + } else { + let atom = unsafe { (self.xlib.XInternAtom)( + self.display, + name.as_ptr() as *const c_char, + ffi::False, + ) }; + if atom == 0 { + let msg = format!( + "`XInternAtom` failed, which really shouldn't happen. Atom: {:?}, Error: {:#?}", + name, + self.check_errors(), + ); + panic!(msg); + } + /*println!( + "XInternAtom name:{:?} atom:{:?}", + name, + atom, + );*/ + (*atom_cache_lock).insert(name.to_owned(), atom); + atom + } + } + + pub unsafe fn get_atom_unchecked(&self, name: &[u8]) -> ffi::Atom { + debug_assert!(CStr::from_bytes_with_nul(name).is_ok()); + let name = CStr::from_bytes_with_nul_unchecked(name); + self.get_atom(name) + } + + // Note: this doesn't use caching, for the sake of simplicity. + // If you're dealing with this many atoms, you'll usually want to cache them locally anyway. + pub unsafe fn get_atoms(&self, names: &[*mut c_char]) -> Result<Vec<ffi::Atom>, XError> { + let mut atoms = Vec::with_capacity(names.len()); + (self.xlib.XInternAtoms)( + self.display, + names.as_ptr() as *mut _, + names.len() as c_int, + ffi::False, + atoms.as_mut_ptr(), + ); + self.check_errors()?; + atoms.set_len(names.len()); + /*println!( + "XInternAtoms atoms:{:?}", + atoms, + );*/ + Ok(atoms) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/client_msg.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/client_msg.rs new file mode 100644 index 0000000..399db4f --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/client_msg.rs @@ -0,0 +1,95 @@ +use super::*; + +pub type ClientMsgPayload = [c_long; 5]; + +impl XConnection { + pub fn send_event<T: Into<ffi::XEvent>>( + &self, + target_window: c_ulong, + event_mask: Option<c_long>, + event: T, + ) -> Flusher { + let event_mask = event_mask.unwrap_or(ffi::NoEventMask); + unsafe { + (self.xlib.XSendEvent)( + self.display, + target_window, + ffi::False, + event_mask, + &mut event.into(), + ); + } + Flusher::new(self) + } + + pub fn send_client_msg( + &self, + window: c_ulong, // The window this is "about"; not necessarily this window + target_window: c_ulong, // The window we're sending to + message_type: ffi::Atom, + event_mask: Option<c_long>, + data: ClientMsgPayload, + ) -> Flusher { + let mut event: ffi::XClientMessageEvent = unsafe { mem::uninitialized() }; + event.type_ = ffi::ClientMessage; + event.display = self.display; + event.window = window; + event.message_type = message_type; + event.format = c_long::FORMAT as c_int; + event.data = unsafe { mem::transmute(data) }; + self.send_event(target_window, event_mask, event) + } + + // Prepare yourself for the ultimate in unsafety! + // You should favor `send_client_msg` whenever possible, but some protocols (i.e. startup notification) require you + // to send more than one message worth of data. + pub fn send_client_msg_multi<T: Formattable>( + &self, + window: c_ulong, // The window this is "about"; not necessarily this window + target_window: c_ulong, // The window we're sending to + message_type: ffi::Atom, + event_mask: Option<c_long>, + data: &[T], + ) -> Flusher { + let format = T::FORMAT; + let size_of_t = mem::size_of::<T>(); + debug_assert_eq!(size_of_t, format.get_actual_size()); + let mut event: ffi::XClientMessageEvent = unsafe { mem::uninitialized() }; + event.type_ = ffi::ClientMessage; + event.display = self.display; + event.window = window; + event.message_type = message_type; + event.format = format as c_int; + + let t_per_payload = format.get_payload_size() / size_of_t; + assert!(t_per_payload > 0); + let payload_count = data.len() / t_per_payload; + let payload_remainder = data.len() % t_per_payload; + let payload_ptr = data.as_ptr() as *const ClientMsgPayload; + + let mut payload_index = 0; + while payload_index < payload_count { + let payload = unsafe { payload_ptr.offset(payload_index as isize) }; + payload_index += 1; + event.data = unsafe { mem::transmute(*payload) }; + self.send_event(target_window, event_mask, &event).queue(); + } + + if payload_remainder > 0 { + let mut payload: ClientMsgPayload = [0; 5]; + let t_payload = payload.as_mut_ptr() as *mut T; + let invalid_payload = unsafe { payload_ptr.offset(payload_index as isize) }; + let invalid_t_payload = invalid_payload as *const T; + let mut t_index = 0; + while t_index < payload_remainder { + let valid_t = unsafe { invalid_t_payload.offset(t_index as isize) }; + unsafe { (*t_payload.offset(t_index as isize)) = (*valid_t).clone() }; + t_index += 1; + } + event.data = unsafe { mem::transmute(payload) }; + self.send_event(target_window, event_mask, &event).queue(); + } + + Flusher::new(self) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/format.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/format.rs new file mode 100644 index 0000000..1be8b64 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/format.rs @@ -0,0 +1,58 @@ +use std::fmt::Debug; +use std::mem; +use std::os::raw::*; + +// This isn't actually the number of the bits in the format. +// X11 does a match on this value to determine which type to call sizeof on. +// Thus, we use 32 for c_long, since 32 maps to c_long which maps to 64. +// ...if that sounds confusing, then you know why this enum is here. +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +pub enum Format { + Char = 8, + Short = 16, + Long = 32, +} + +impl Format { + pub fn from_format(format: usize) -> Option<Self> { + match format { + 8 => Some(Format::Char), + 16 => Some(Format::Short), + 32 => Some(Format::Long), + _ => None, + } + } + + pub fn is_same_size_as<T>(&self) -> bool { + mem::size_of::<T>() == self.get_actual_size() + } + + pub fn get_actual_size(&self) -> usize { + match self { + &Format::Char => mem::size_of::<c_char>(), + &Format::Short => mem::size_of::<c_short>(), + &Format::Long => mem::size_of::<c_long>(), + } + } + + pub fn get_payload_size(&self) -> usize { + match self { + // Due to the wonders of X11, half the space goes unused if you're not using longs (on 64-bit). + &Format::Char => mem::size_of::<c_char>() * 20, + &Format::Short => mem::size_of::<c_short>() * 10, + &Format::Long => mem::size_of::<c_long>() * 5, + } + } +} + +pub trait Formattable: Debug + Clone + Copy + PartialEq + PartialOrd { + const FORMAT: Format; +} + +// You might be surprised by the absence of c_int, but not as surprised as X11 would be by the presence of it. +impl Formattable for c_schar { const FORMAT: Format = Format::Char; } +impl Formattable for c_uchar { const FORMAT: Format = Format::Char; } +impl Formattable for c_short { const FORMAT: Format = Format::Short; } +impl Formattable for c_ushort { const FORMAT: Format = Format::Short; } +impl Formattable for c_long { const FORMAT: Format = Format::Long; } +impl Formattable for c_ulong { const FORMAT: Format = Format::Long; } diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/geometry.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/geometry.rs new file mode 100644 index 0000000..1a85b1c --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/geometry.rs @@ -0,0 +1,387 @@ +use std::cmp; + +use super::*; +use {LogicalPosition, LogicalSize}; + +// Friendly neighborhood axis-aligned rectangle +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct AaRect { + x: i64, + y: i64, + width: i64, + height: i64, +} + +impl AaRect { + pub fn new((x, y): (i32, i32), (width, height): (u32, u32)) -> Self { + let (x, y) = (x as i64, y as i64); + let (width, height) = (width as i64, height as i64); + AaRect { x, y, width, height } + } + + pub fn contains_point(&self, x: i64, y: i64) -> bool { + x >= self.x && x <= self.x + self.width && y >= self.y && y <= self.y + self.height + } + + pub fn get_overlapping_area(&self, other: &Self) -> i64 { + let x_overlap = cmp::max( + 0, + cmp::min(self.x + self.width, other.x + other.width) - cmp::max(self.x, other.x), + ); + let y_overlap = cmp::max( + 0, + cmp::min(self.y + self.height, other.y + other.height) - cmp::max(self.y, other.y), + ); + x_overlap * y_overlap + } +} + +#[derive(Debug)] +pub struct TranslatedCoords { + pub x_rel_root: c_int, + pub y_rel_root: c_int, + pub child: ffi::Window, +} + +#[derive(Debug)] +pub struct Geometry { + pub root: ffi::Window, + // If you want positions relative to the root window, use translate_coords. + // Note that the overwhelming majority of window managers are reparenting WMs, thus the window + // ID we get from window creation is for a nested window used as the window's client area. If + // you call get_geometry with that window ID, then you'll get the position of that client area + // window relative to the parent it's nested in (the frame), which isn't helpful if you want + // to know the frame position. + pub x_rel_parent: c_int, + pub y_rel_parent: c_int, + // In that same case, this will give you client area size. + pub width: c_uint, + pub height: c_uint, + // xmonad and dwm were the only WMs tested that use the border return at all. + // The majority of WMs seem to simply fill it with 0 unconditionally. + pub border: c_uint, + pub depth: c_uint, +} + +#[derive(Debug, Clone)] +pub struct FrameExtents { + pub left: c_ulong, + pub right: c_ulong, + pub top: c_ulong, + pub bottom: c_ulong, +} + +impl FrameExtents { + pub fn new(left: c_ulong, right: c_ulong, top: c_ulong, bottom: c_ulong) -> Self { + FrameExtents { left, right, top, bottom } + } + + pub fn from_border(border: c_ulong) -> Self { + Self::new(border, border, border, border) + } + + pub fn as_logical(&self, factor: f64) -> LogicalFrameExtents { + let logicalize = |value: c_ulong| value as f64 / factor; + LogicalFrameExtents { + left: logicalize(self.left), + right: logicalize(self.right), + top: logicalize(self.top), + bottom: logicalize(self.bottom), + } + } +} + +#[derive(Debug, Clone)] +pub struct LogicalFrameExtents { + pub left: f64, + pub right: f64, + pub top: f64, + pub bottom: f64, +} + +#[derive(Debug, Clone, PartialEq)] +pub enum FrameExtentsHeuristicPath { + Supported, + UnsupportedNested, + UnsupportedBordered, +} + +#[derive(Debug, Clone)] +pub struct FrameExtentsHeuristic { + pub frame_extents: FrameExtents, + pub heuristic_path: FrameExtentsHeuristicPath, +} + +impl FrameExtentsHeuristic { + pub fn inner_pos_to_outer(&self, x: i32, y: i32) -> (i32, i32) { + use self::FrameExtentsHeuristicPath::*; + if self.heuristic_path != UnsupportedBordered { + (x - self.frame_extents.left as i32, y - self.frame_extents.top as i32) + } else { + (x, y) + } + } + + pub fn inner_pos_to_outer_logical(&self, mut logical: LogicalPosition, factor: f64) -> LogicalPosition { + use self::FrameExtentsHeuristicPath::*; + if self.heuristic_path != UnsupportedBordered { + let frame_extents = self.frame_extents.as_logical(factor); + logical.x -= frame_extents.left; + logical.y -= frame_extents.top; + } + logical + } + + pub fn inner_size_to_outer(&self, width: u32, height: u32) -> (u32, u32) { + ( + width.saturating_add( + self.frame_extents.left.saturating_add(self.frame_extents.right) as u32 + ), + height.saturating_add( + self.frame_extents.top.saturating_add(self.frame_extents.bottom) as u32 + ), + ) + } + + pub fn inner_size_to_outer_logical(&self, mut logical: LogicalSize, factor: f64) -> LogicalSize { + let frame_extents = self.frame_extents.as_logical(factor); + logical.width += frame_extents.left + frame_extents.right; + logical.height += frame_extents.top + frame_extents.bottom; + logical + } +} + +impl XConnection { + // This is adequate for get_inner_position + pub fn translate_coords(&self, window: ffi::Window, root: ffi::Window) -> Result<TranslatedCoords, XError> { + let mut translated_coords: TranslatedCoords = unsafe { mem::uninitialized() }; + unsafe { + (self.xlib.XTranslateCoordinates)( + self.display, + window, + root, + 0, + 0, + &mut translated_coords.x_rel_root, + &mut translated_coords.y_rel_root, + &mut translated_coords.child, + ); + } + //println!("XTranslateCoordinates coords:{:?}", translated_coords); + self.check_errors().map(|_| translated_coords) + } + + // This is adequate for get_inner_size + pub fn get_geometry(&self, window: ffi::Window) -> Result<Geometry, XError> { + let mut geometry: Geometry = unsafe { mem::uninitialized() }; + let _status = unsafe { + (self.xlib.XGetGeometry)( + self.display, + window, + &mut geometry.root, + &mut geometry.x_rel_parent, + &mut geometry.y_rel_parent, + &mut geometry.width, + &mut geometry.height, + &mut geometry.border, + &mut geometry.depth, + ) + }; + //println!("XGetGeometry geo:{:?}", geometry); + self.check_errors().map(|_| geometry) + } + + fn get_frame_extents(&self, window: ffi::Window) -> Option<FrameExtents> { + let extents_atom = unsafe { self.get_atom_unchecked(b"_NET_FRAME_EXTENTS\0") }; + + if !hint_is_supported(extents_atom) { + return None; + } + + // Of the WMs tested, xmonad, i3, dwm, IceWM (1.3.x and earlier), and blackbox don't + // support this. As this is part of EWMH (Extended Window Manager Hints), it's likely to + // be unsupported by many smaller WMs. + let extents: Option<Vec<c_ulong>> = self.get_property( + window, + extents_atom, + ffi::XA_CARDINAL, + ).ok(); + + extents.and_then(|extents| { + if extents.len() >= 4 { + Some(FrameExtents { + left: extents[0], + right: extents[1], + top: extents[2], + bottom: extents[3], + }) + } else { + None + } + }) + } + + pub fn is_top_level(&self, window: ffi::Window, root: ffi::Window) -> Option<bool> { + let client_list_atom = unsafe { self.get_atom_unchecked(b"_NET_CLIENT_LIST\0") }; + + if !hint_is_supported(client_list_atom) { + return None; + } + + let client_list: Option<Vec<ffi::Window>> = self.get_property( + root, + client_list_atom, + ffi::XA_WINDOW, + ).ok(); + + client_list.map(|client_list| client_list.contains(&window)) + } + + fn get_parent_window(&self, window: ffi::Window) -> Result<ffi::Window, XError> { + let parent = unsafe { + let mut root: ffi::Window = mem::uninitialized(); + let mut parent: ffi::Window = mem::uninitialized(); + let mut children: *mut ffi::Window = ptr::null_mut(); + let mut nchildren: c_uint = mem::uninitialized(); + + // What's filled into `parent` if `window` is the root window? + let _status = (self.xlib.XQueryTree)( + self.display, + window, + &mut root, + &mut parent, + &mut children, + &mut nchildren, + ); + + // The list of children isn't used + if children != ptr::null_mut() { + (self.xlib.XFree)(children as *mut _); + } + + parent + }; + self.check_errors().map(|_| parent) + } + + fn climb_hierarchy(&self, window: ffi::Window, root: ffi::Window) -> Result<ffi::Window, XError> { + let mut outer_window = window; + loop { + let candidate = self.get_parent_window(outer_window)?; + if candidate == root { + break; + } + outer_window = candidate; + } + Ok(outer_window) + } + + pub fn get_frame_extents_heuristic(&self, window: ffi::Window, root: ffi::Window) -> FrameExtentsHeuristic { + use self::FrameExtentsHeuristicPath::*; + + // Position relative to root window. + // With rare exceptions, this is the position of a nested window. Cases where the window + // isn't nested are outlined in the comments throghout this function, but in addition to + // that, fullscreen windows often aren't nested. + let (inner_y_rel_root, child) = { + let coords = self.translate_coords(window, root).expect("Failed to translate window coordinates"); + ( + coords.y_rel_root, + coords.child, + ) + }; + + let (width, height, border) = { + let inner_geometry = self.get_geometry(window).expect("Failed to get inner window geometry"); + ( + inner_geometry.width, + inner_geometry.height, + inner_geometry.border, + ) + }; + + // The first condition is only false for un-nested windows, but isn't always false for + // un-nested windows. Mutter/Muffin/Budgie and Marco present a mysterious discrepancy: + // when y is on the range [0, 2] and if the window has been unfocused since being + // undecorated (or was undecorated upon construction), the first condition is true, + // requiring us to rely on the second condition. + let nested = !(window == child || self.is_top_level(child, root) == Some(true)); + + // Hopefully the WM supports EWMH, allowing us to get exact info on the window frames. + if let Some(mut frame_extents) = self.get_frame_extents(window) { + // Mutter/Muffin/Budgie and Marco preserve their decorated frame extents when + // decorations are disabled, but since the window becomes un-nested, it's easy to + // catch. + if !nested { + frame_extents = FrameExtents::new(0, 0, 0, 0); + } + + // The difference between the nested window's position and the outermost window's + // position is equivalent to the frame size. In most scenarios, this is equivalent to + // manually climbing the hierarchy as is done in the case below. Here's a list of + // known discrepancies: + // * Mutter/Muffin/Budgie gives decorated windows a margin of 9px (only 7px on top) in + // addition to a 1px semi-transparent border. The margin can be easily observed by + // using a screenshot tool to get a screenshot of a selected window, and is + // presumably used for drawing drop shadows. Getting window geometry information + // via hierarchy-climbing results in this margin being included in both the + // position and outer size, so a window positioned at (0, 0) would be reported as + // having a position (-10, -8). + // * Compiz has a drop shadow margin just like Mutter/Muffin/Budgie, though it's 10px + // on all sides, and there's no additional border. + // * Enlightenment otherwise gets a y position equivalent to inner_y_rel_root. + // Without decorations, there's no difference. This is presumably related to + // Enlightenment's fairly unique concept of window position; it interprets + // positions given to XMoveWindow as a client area position rather than a position + // of the overall window. + + FrameExtentsHeuristic { + frame_extents, + heuristic_path: Supported, + } + } else if nested { + // If the position value we have is for a nested window used as the client area, we'll + // just climb up the hierarchy and get the geometry of the outermost window we're + // nested in. + let outer_window = self.climb_hierarchy(window, root).expect("Failed to climb window hierarchy"); + let (outer_y, outer_width, outer_height) = { + let outer_geometry = self.get_geometry(outer_window).expect("Failed to get outer window geometry"); + ( + outer_geometry.y_rel_parent, + outer_geometry.width, + outer_geometry.height, + ) + }; + + // Since we have the geometry of the outermost window and the geometry of the client + // area, we can figure out what's in between. + let diff_x = outer_width.saturating_sub(width); + let diff_y = outer_height.saturating_sub(height); + let offset_y = inner_y_rel_root.saturating_sub(outer_y) as c_uint; + + let left = diff_x / 2; + let right = left; + let top = offset_y; + let bottom = diff_y.saturating_sub(offset_y); + + let frame_extents = FrameExtents::new( + left.into(), + right.into(), + top.into(), + bottom.into(), + ); + FrameExtentsHeuristic { + frame_extents, + heuristic_path: UnsupportedNested, + } + } else { + // This is the case for xmonad and dwm, AKA the only WMs tested that supplied a + // border value. This is convenient, since we can use it to get an accurate frame. + let frame_extents = FrameExtents::from_border(border.into()); + FrameExtentsHeuristic { + frame_extents, + heuristic_path: UnsupportedBordered, + } + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/hint.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/hint.rs new file mode 100644 index 0000000..c58e908 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/hint.rs @@ -0,0 +1,235 @@ +use std::sync::Arc; + +use super::*; + +pub const MWM_HINTS_DECORATIONS: c_ulong = 2; + +#[derive(Debug)] +pub enum StateOperation { + Remove = 0, // _NET_WM_STATE_REMOVE + Add = 1, // _NET_WM_STATE_ADD + Toggle = 2, // _NET_WM_STATE_TOGGLE +} + +impl From<bool> for StateOperation { + fn from(op: bool) -> Self { + if op { + StateOperation::Add + } else { + StateOperation::Remove + } + } +} + +/// X window type. Maps directly to +/// [`_NET_WM_WINDOW_TYPE`](https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html). +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum WindowType { + /// A desktop feature. This can include a single window containing desktop icons with the same dimensions as the + /// screen, allowing the desktop environment to have full control of the desktop, without the need for proxying + /// root window clicks. + Desktop, + /// A dock or panel feature. Typically a Window Manager would keep such windows on top of all other windows. + Dock, + /// Toolbar windows. "Torn off" from the main application. + Toolbar, + /// Pinnable menu windows. "Torn off" from the main application. + Menu, + /// A small persistent utility window, such as a palette or toolbox. + Utility, + /// The window is a splash screen displayed as an application is starting up. + Splash, + /// This is a dialog window. + Dialog, + /// A dropdown menu that usually appears when the user clicks on an item in a menu bar. + /// This property is typically used on override-redirect windows. + DropdownMenu, + /// A popup menu that usually appears when the user right clicks on an object. + /// This property is typically used on override-redirect windows. + PopupMenu, + /// A tooltip window. Usually used to show additional information when hovering over an object with the cursor. + /// This property is typically used on override-redirect windows. + Tooltip, + /// The window is a notification. + /// This property is typically used on override-redirect windows. + Notification, + /// This should be used on the windows that are popped up by combo boxes. + /// This property is typically used on override-redirect windows. + Combo, + /// This indicates the the window is being dragged. + /// This property is typically used on override-redirect windows. + Dnd, + /// This is a normal, top-level window. + Normal, +} + +impl Default for WindowType { + fn default() -> Self { + WindowType::Normal + } +} + +impl WindowType { + pub(crate) fn as_atom(&self, xconn: &Arc<XConnection>) -> ffi::Atom { + use self::WindowType::*; + let atom_name: &[u8] = match self { + &Desktop => b"_NET_WM_WINDOW_TYPE_DESKTOP\0", + &Dock => b"_NET_WM_WINDOW_TYPE_DOCK\0", + &Toolbar => b"_NET_WM_WINDOW_TYPE_TOOLBAR\0", + &Menu => b"_NET_WM_WINDOW_TYPE_MENU\0", + &Utility => b"_NET_WM_WINDOW_TYPE_UTILITY\0", + &Splash => b"_NET_WM_WINDOW_TYPE_SPLASH\0", + &Dialog => b"_NET_WM_WINDOW_TYPE_DIALOG\0", + &DropdownMenu => b"_NET_WM_WINDOW_TYPE_DROPDOWN_MENU\0", + &PopupMenu => b"_NET_WM_WINDOW_TYPE_POPUP_MENU\0", + &Tooltip => b"_NET_WM_WINDOW_TYPE_TOOLTIP\0", + &Notification => b"_NET_WM_WINDOW_TYPE_NOTIFICATION\0", + &Combo => b"_NET_WM_WINDOW_TYPE_COMBO\0", + &Dnd => b"_NET_WM_WINDOW_TYPE_DND\0", + &Normal => b"_NET_WM_WINDOW_TYPE_NORMAL\0", + }; + unsafe { xconn.get_atom_unchecked(atom_name) } + } +} + +pub struct NormalHints<'a> { + size_hints: XSmartPointer<'a, ffi::XSizeHints>, +} + +impl<'a> NormalHints<'a> { + pub fn new(xconn: &'a XConnection) -> Self { + NormalHints { size_hints: xconn.alloc_size_hints() } + } + + pub fn has_flag(&self, flag: c_long) -> bool { + has_flag(self.size_hints.flags, flag) + } + + fn getter(&self, flag: c_long, field1: &c_int, field2: &c_int) -> Option<(u32, u32)> { + if self.has_flag(flag) { + Some((*field1 as _, *field2 as _)) + } else { + None + } + } + + pub fn get_size(&self) -> Option<(u32, u32)> { + self.getter(ffi::PSize, &self.size_hints.width, &self.size_hints.height) + } + + // WARNING: This hint is obsolete + pub fn set_size(&mut self, size: Option<(u32, u32)>) { + if let Some((width, height)) = size { + self.size_hints.flags |= ffi::PSize; + self.size_hints.width = width as c_int; + self.size_hints.height = height as c_int; + } else { + self.size_hints.flags &= !ffi::PSize; + } + } + + pub fn get_max_size(&self) -> Option<(u32, u32)> { + self.getter(ffi::PMaxSize, &self.size_hints.max_width, &self.size_hints.max_height) + } + + pub fn set_max_size(&mut self, max_size: Option<(u32, u32)>) { + if let Some((max_width, max_height)) = max_size { + self.size_hints.flags |= ffi::PMaxSize; + self.size_hints.max_width = max_width as c_int; + self.size_hints.max_height = max_height as c_int; + } else { + self.size_hints.flags &= !ffi::PMaxSize; + } + } + + pub fn get_min_size(&self) -> Option<(u32, u32)> { + self.getter(ffi::PMinSize, &self.size_hints.min_width, &self.size_hints.min_height) + } + + pub fn set_min_size(&mut self, min_size: Option<(u32, u32)>) { + if let Some((min_width, min_height)) = min_size { + self.size_hints.flags |= ffi::PMinSize; + self.size_hints.min_width = min_width as c_int; + self.size_hints.min_height = min_height as c_int; + } else { + self.size_hints.flags &= !ffi::PMinSize; + } + } + + pub fn get_resize_increments(&self) -> Option<(u32, u32)> { + self.getter(ffi::PResizeInc, &self.size_hints.width_inc, &self.size_hints.height_inc) + } + + pub fn set_resize_increments(&mut self, resize_increments: Option<(u32, u32)>) { + if let Some((width_inc, height_inc)) = resize_increments { + self.size_hints.flags |= ffi::PResizeInc; + self.size_hints.width_inc = width_inc as c_int; + self.size_hints.height_inc = height_inc as c_int; + } else { + self.size_hints.flags &= !ffi::PResizeInc; + } + } + + pub fn get_base_size(&self) -> Option<(u32, u32)> { + self.getter(ffi::PBaseSize, &self.size_hints.base_width, &self.size_hints.base_height) + } + + pub fn set_base_size(&mut self, base_size: Option<(u32, u32)>) { + if let Some((base_width, base_height)) = base_size { + self.size_hints.flags |= ffi::PBaseSize; + self.size_hints.base_width = base_width as c_int; + self.size_hints.base_height = base_height as c_int; + } else { + self.size_hints.flags &= !ffi::PBaseSize; + } + } +} + +impl XConnection { + pub fn get_wm_hints(&self, window: ffi::Window) -> Result<XSmartPointer<ffi::XWMHints>, XError> { + let wm_hints = unsafe { (self.xlib.XGetWMHints)(self.display, window) }; + self.check_errors()?; + let wm_hints = if wm_hints.is_null() { + self.alloc_wm_hints() + } else { + XSmartPointer::new(self, wm_hints).unwrap() + }; + Ok(wm_hints) + } + + pub fn set_wm_hints(&self, window: ffi::Window, wm_hints: XSmartPointer<ffi::XWMHints>) -> Flusher { + unsafe { + (self.xlib.XSetWMHints)( + self.display, + window, + wm_hints.ptr, + ); + } + Flusher::new(self) + } + + pub fn get_normal_hints(&self, window: ffi::Window) -> Result<NormalHints, XError> { + let size_hints = self.alloc_size_hints(); + let mut supplied_by_user: c_long = unsafe { mem::uninitialized() }; + unsafe { + (self.xlib.XGetWMNormalHints)( + self.display, + window, + size_hints.ptr, + &mut supplied_by_user, + ); + } + self.check_errors().map(|_| NormalHints { size_hints }) + } + + pub fn set_normal_hints(&self, window: ffi::Window, normal_hints: NormalHints) -> Flusher { + unsafe { + (self.xlib.XSetWMNormalHints)( + self.display, + window, + normal_hints.size_hints.ptr, + ); + } + Flusher::new(self) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/icon.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/icon.rs new file mode 100644 index 0000000..c19b52a --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/icon.rs @@ -0,0 +1,34 @@ +use {Icon, Pixel, PIXEL_SIZE}; +use super::*; + +impl Pixel { + pub fn to_packed_argb(&self) -> Cardinal { + let mut cardinal = 0; + assert!(CARDINAL_SIZE >= PIXEL_SIZE); + let as_bytes = &mut cardinal as *mut _ as *mut u8; + unsafe { + *as_bytes.offset(0) = self.b; + *as_bytes.offset(1) = self.g; + *as_bytes.offset(2) = self.r; + *as_bytes.offset(3) = self.a; + } + cardinal + } +} + +impl Icon { + pub(crate) fn to_cardinals(&self) -> Vec<Cardinal> { + assert_eq!(self.rgba.len() % PIXEL_SIZE, 0); + let pixel_count = self.rgba.len() / PIXEL_SIZE; + assert_eq!(pixel_count, (self.width * self.height) as usize); + let mut data = Vec::with_capacity(pixel_count); + data.push(self.width as Cardinal); + data.push(self.height as Cardinal); + let pixels = self.rgba.as_ptr() as *const Pixel; + for pixel_index in 0..pixel_count { + let pixel = unsafe { &*pixels.offset(pixel_index as isize) }; + data.push(pixel.to_packed_argb()); + } + data + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/input.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/input.rs new file mode 100644 index 0000000..4b75df2 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/input.rs @@ -0,0 +1,159 @@ +use std::str; + +use super::*; +use events::ModifiersState; + +pub const VIRTUAL_CORE_POINTER: c_int = 2; +pub const VIRTUAL_CORE_KEYBOARD: c_int = 3; + +// A base buffer size of 1kB uses a negligible amount of RAM while preventing us from having to +// re-allocate (and make another round-trip) in the *vast* majority of cases. +// To test if `lookup_utf8` works correctly, set this to 1. +const TEXT_BUFFER_SIZE: usize = 1024; + +impl From<ffi::XIModifierState> for ModifiersState { + fn from(mods: ffi::XIModifierState) -> Self { + let state = mods.effective as c_uint; + ModifiersState { + alt: state & ffi::Mod1Mask != 0, + shift: state & ffi::ShiftMask != 0, + ctrl: state & ffi::ControlMask != 0, + logo: state & ffi::Mod4Mask != 0, + } + } +} + +pub struct PointerState<'a> { + xconn: &'a XConnection, + root: ffi::Window, + child: ffi::Window, + pub root_x: c_double, + pub root_y: c_double, + win_x: c_double, + win_y: c_double, + buttons: ffi::XIButtonState, + modifiers: ffi::XIModifierState, + group: ffi::XIGroupState, + relative_to_window: bool, +} + +impl<'a> PointerState<'a> { + pub fn get_modifier_state(&self) -> ModifiersState { + self.modifiers.into() + } +} + +impl<'a> Drop for PointerState<'a> { + fn drop(&mut self) { + if !self.buttons.mask.is_null() { + unsafe { + // This is why you need to read the docs carefully... + (self.xconn.xlib.XFree)(self.buttons.mask as _); + } + } + } +} + +impl XConnection { + pub fn select_xinput_events(&self, window: c_ulong, device_id: c_int, mask: i32) -> Flusher { + let mut event_mask = ffi::XIEventMask { + deviceid: device_id, + mask: &mask as *const _ as *mut c_uchar, + mask_len: mem::size_of_val(&mask) as c_int, + }; + unsafe { + (self.xinput2.XISelectEvents)( + self.display, + window, + &mut event_mask as *mut ffi::XIEventMask, + 1, // number of masks to read from pointer above + ); + } + Flusher::new(self) + } + + #[allow(dead_code)] + pub fn select_xkb_events(&self, device_id: c_uint, mask: c_ulong) -> Option<Flusher> { + let status = unsafe { + (self.xlib.XkbSelectEvents)( + self.display, + device_id, + mask, + mask, + ) + }; + if status == ffi::True { + Some(Flusher::new(self)) + } else { + None + } + } + + pub fn query_pointer(&self, window: ffi::Window, device_id: c_int) -> Result<PointerState, XError> { + unsafe { + let mut pointer_state: PointerState = mem::uninitialized(); + pointer_state.xconn = self; + pointer_state.relative_to_window = (self.xinput2.XIQueryPointer)( + self.display, + device_id, + window, + &mut pointer_state.root, + &mut pointer_state.child, + &mut pointer_state.root_x, + &mut pointer_state.root_y, + &mut pointer_state.win_x, + &mut pointer_state.win_y, + &mut pointer_state.buttons, + &mut pointer_state.modifiers, + &mut pointer_state.group, + ) == ffi::True; + if let Err(err) = self.check_errors() { + // Running the destrutor would be bad news for us... + mem::forget(pointer_state); + Err(err) + } else { + Ok(pointer_state) + } + } + } + + fn lookup_utf8_inner( + &self, + ic: ffi::XIC, + key_event: &mut ffi::XKeyEvent, + buffer: &mut [u8], + ) -> (ffi::KeySym, ffi::Status, c_int) { + let mut keysym: ffi::KeySym = 0; + let mut status: ffi::Status = 0; + let count = unsafe { + (self.xlib.Xutf8LookupString)( + ic, + key_event, + buffer.as_mut_ptr() as *mut c_char, + buffer.len() as c_int, + &mut keysym, + &mut status, + ) + }; + (keysym, status, count) + } + + pub fn lookup_utf8(&self, ic: ffi::XIC, key_event: &mut ffi::XKeyEvent) -> String { + let mut buffer: [u8; TEXT_BUFFER_SIZE] = unsafe { mem::uninitialized() }; + let (_, status, count) = self.lookup_utf8_inner(ic, key_event, &mut buffer); + // The buffer overflowed, so we'll make a new one on the heap. + if status == ffi::XBufferOverflow { + let mut buffer = Vec::with_capacity(count as usize); + unsafe { buffer.set_len(count as usize) }; + let (_, _, new_count) = self.lookup_utf8_inner(ic, key_event, &mut buffer); + debug_assert_eq!(count, new_count); + str::from_utf8(&buffer[..count as usize]) + .unwrap_or("") + .to_string() + } else { + str::from_utf8(&buffer[..count as usize]) + .unwrap_or("") + .to_string() + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/memory.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/memory.rs new file mode 100644 index 0000000..eef0bdc --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/memory.rs @@ -0,0 +1,62 @@ +use std::ops::{Deref, DerefMut}; + +use super::*; + +pub struct XSmartPointer<'a, T> { + xconn: &'a XConnection, + pub ptr: *mut T, +} + +impl<'a, T> XSmartPointer<'a, T> { + // You're responsible for only passing things to this that should be XFree'd. + // Returns None if ptr is null. + pub fn new(xconn: &'a XConnection, ptr: *mut T) -> Option<Self> { + if !ptr.is_null() { + Some(XSmartPointer { + xconn, + ptr, + }) + } else { + None + } + } +} + +impl<'a, T> Deref for XSmartPointer<'a, T> { + type Target = T; + + fn deref(&self) -> &T { + unsafe { &*self.ptr } + } +} + +impl<'a, T> DerefMut for XSmartPointer<'a, T> { + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *self.ptr } + } +} + +impl<'a, T> Drop for XSmartPointer<'a, T> { + fn drop(&mut self) { + unsafe { + (self.xconn.xlib.XFree)(self.ptr as *mut _); + } + } +} + +impl XConnection { + pub fn alloc_class_hint(&self) -> XSmartPointer<ffi::XClassHint> { + XSmartPointer::new(self, unsafe { (self.xlib.XAllocClassHint)() }) + .expect("`XAllocClassHint` returned null; out of memory") + } + + pub fn alloc_size_hints(&self) -> XSmartPointer<ffi::XSizeHints> { + XSmartPointer::new(self, unsafe { (self.xlib.XAllocSizeHints)() }) + .expect("`XAllocSizeHints` returned null; out of memory") + } + + pub fn alloc_wm_hints(&self) -> XSmartPointer<ffi::XWMHints> { + XSmartPointer::new(self, unsafe { (self.xlib.XAllocWMHints)() }) + .expect("`XAllocWMHints` returned null; out of memory") + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/mod.rs new file mode 100644 index 0000000..ccef6e4 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/mod.rs @@ -0,0 +1,104 @@ +// Welcome to the util module, where we try to keep you from shooting yourself in the foot. +// *results may vary + +mod atom; +mod client_msg; +mod format; +mod geometry; +mod hint; +mod icon; +mod input; +mod memory; +mod randr; +mod window_property; +mod wm; + +pub use self::atom::*; +pub use self::client_msg::*; +pub use self::format::*; +pub use self::geometry::*; +pub use self::hint::*; +pub use self::icon::*; +pub use self::input::*; +pub use self::memory::*; +pub use self::randr::*; +pub use self::window_property::*; +pub use self::wm::*; + +use std::mem; +use std::ptr; +use std::ops::BitAnd; +use std::os::raw::*; + +use super::{ffi, XConnection, XError}; + +pub fn reinterpret<'a, A, B>(a: &'a A) -> &'a B { + let b_ptr = a as *const _ as *const B; + unsafe { &*b_ptr } +} + +pub fn maybe_change<T: PartialEq>(field: &mut Option<T>, value: T) -> bool { + let wrapped = Some(value); + if *field != wrapped { + *field = wrapped; + true + } else { + false + } +} + +pub fn has_flag<T>(bitset: T, flag: T) -> bool +where T: + Copy + PartialEq + BitAnd<T, Output = T> +{ + bitset & flag == flag +} + +#[must_use = "This request was made asynchronously, and is still in the output buffer. You must explicitly choose to either `.flush()` (empty the output buffer, sending the request now) or `.queue()` (wait to send the request, allowing you to continue to add more requests without additional round-trips). For more information, see the documentation for `util::flush_requests`."] +pub struct Flusher<'a> { + xconn: &'a XConnection, +} + +impl<'a> Flusher<'a> { + pub fn new(xconn: &'a XConnection) -> Self { + Flusher { xconn } + } + + // "I want this request sent now!" + pub fn flush(self) -> Result<(), XError> { + self.xconn.flush_requests() + } + + // "I want the response now too!" + pub fn sync(self) -> Result<(), XError> { + self.xconn.sync_with_server() + } + + // "I'm aware that this request hasn't been sent, and I'm okay with waiting." + pub fn queue(self) {} +} + +impl XConnection { + // This is impoartant, so pay attention! + // Xlib has an output buffer, and tries to hide the async nature of X from you. + // This buffer contains the requests you make, and is flushed under various circumstances: + // 1. `XPending`, `XNextEvent`, and `XWindowEvent` flush "as needed" + // 2. `XFlush` explicitly flushes + // 3. `XSync` flushes and blocks until all requests are responded to + // 4. Calls that have a return dependent on a response (i.e. `XGetWindowProperty`) sync internally. + // When in doubt, check the X11 source; if a function calls `_XReply`, it flushes and waits. + // All util functions that abstract an async function will return a `Flusher`. + pub fn flush_requests(&self) -> Result<(), XError> { + unsafe { (self.xlib.XFlush)(self.display) }; + //println!("XFlush"); + // This isn't necessarily a useful time to check for errors (since our request hasn't + // necessarily been processed yet) + self.check_errors() + } + + pub fn sync_with_server(&self) -> Result<(), XError> { + unsafe { (self.xlib.XSync)(self.display, ffi::False) }; + //println!("XSync"); + self.check_errors() + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/randr.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/randr.rs new file mode 100644 index 0000000..e730469 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/randr.rs @@ -0,0 +1,111 @@ +use std::{env, slice}; +use std::str::FromStr; + +use validate_hidpi_factor; +use super::*; + +pub fn calc_dpi_factor( + (width_px, height_px): (u32, u32), + (width_mm, height_mm): (u64, u64), +) -> f64 { + // Override DPI if `WINIT_HIDPI_FACTOR` variable is set + let dpi_override = env::var("WINIT_HIDPI_FACTOR") + .ok() + .and_then(|var| f64::from_str(&var).ok()); + if let Some(dpi_override) = dpi_override { + if !validate_hidpi_factor(dpi_override) { + panic!( + "`WINIT_HIDPI_FACTOR` invalid; DPI factors must be normal floats greater than 0. Got `{}`", + dpi_override, + ); + } + return dpi_override; + } + + // See http://xpra.org/trac/ticket/728 for more information. + if width_mm == 0 || width_mm == 0 { + warn!("XRandR reported that the display's 0mm in size, which is certifiably insane"); + return 1.0; + } + + let ppmm = ( + (width_px as f64 * height_px as f64) / (width_mm as f64 * height_mm as f64) + ).sqrt(); + // Quantize 1/12 step size + let dpi_factor = ((ppmm * (12.0 * 25.4 / 96.0)).round() / 12.0).max(1.0); + assert!(validate_hidpi_factor(dpi_factor)); + dpi_factor +} + +pub enum MonitorRepr { + Monitor(*mut ffi::XRRMonitorInfo), + Crtc(*mut ffi::XRRCrtcInfo), +} + +impl MonitorRepr { + pub unsafe fn get_output(&self) -> ffi::RROutput { + match *self { + // Same member names, but different locations within the struct... + MonitorRepr::Monitor(monitor) => *((*monitor).outputs.offset(0)), + MonitorRepr::Crtc(crtc) => *((*crtc).outputs.offset(0)), + } + } + + pub unsafe fn get_dimensions(&self) -> (u32, u32) { + match *self { + MonitorRepr::Monitor(monitor) => ((*monitor).width as u32, (*monitor).height as u32), + MonitorRepr::Crtc(crtc) => ((*crtc).width as u32, (*crtc).height as u32), + } + } + + pub unsafe fn get_position(&self) -> (i32, i32) { + match *self { + MonitorRepr::Monitor(monitor) => ((*monitor).x as i32, (*monitor).y as i32), + MonitorRepr::Crtc(crtc) => ((*crtc).x as i32, (*crtc).y as i32), + } + } +} + +impl From<*mut ffi::XRRMonitorInfo> for MonitorRepr { + fn from(monitor: *mut ffi::XRRMonitorInfo) -> Self { + MonitorRepr::Monitor(monitor) + } +} + +impl From<*mut ffi::XRRCrtcInfo> for MonitorRepr { + fn from(crtc: *mut ffi::XRRCrtcInfo) -> Self { + MonitorRepr::Crtc(crtc) + } +} + +impl XConnection { + pub unsafe fn get_output_info( + &self, + resources: *mut ffi::XRRScreenResources, + repr: &MonitorRepr, + ) -> Option<(String, f64)> { + let output_info = (self.xrandr.XRRGetOutputInfo)( + self.display, + resources, + repr.get_output(), + ); + if output_info.is_null() { + // When calling `XRRGetOutputInfo` on a virtual monitor (versus a physical display) + // it's possible for it to return null. + // https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=816596 + let _ = self.check_errors(); // discard `BadRROutput` error + return None; + } + let name_slice = slice::from_raw_parts( + (*output_info).name as *mut u8, + (*output_info).nameLen as usize, + ); + let name = String::from_utf8_lossy(name_slice).into(); + let hidpi_factor = calc_dpi_factor( + repr.get_dimensions(), + ((*output_info).mm_width as u64, (*output_info).mm_height as u64), + ); + (self.xrandr.XRRFreeOutputInfo)(output_info); + Some((name, hidpi_factor)) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/window_property.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/window_property.rs new file mode 100644 index 0000000..47d984e --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/window_property.rs @@ -0,0 +1,144 @@ +use std; + +use super::*; + +pub type Cardinal = c_long; +pub const CARDINAL_SIZE: usize = mem::size_of::<c_long>(); + +#[derive(Debug, Clone)] +pub enum GetPropertyError { + XError(XError), + TypeMismatch(ffi::Atom), + FormatMismatch(c_int), + NothingAllocated, +} + +impl GetPropertyError { + pub fn is_actual_property_type(&self, t: ffi::Atom) -> bool { + if let GetPropertyError::TypeMismatch(actual_type) = *self { + actual_type == t + } else { + false + } + } +} + +// Number of 32-bit chunks to retrieve per iteration of get_property's inner loop. +// To test if `get_property` works correctly, set this to 1. +const PROPERTY_BUFFER_SIZE: c_long = 1024; // 4k of RAM ought to be enough for anyone! + +#[derive(Debug)] +pub enum PropMode { + Replace = ffi::PropModeReplace as isize, + Prepend = ffi::PropModePrepend as isize, + Append = ffi::PropModeAppend as isize, +} + +impl XConnection { + pub fn get_property<T: Formattable>( + &self, + window: c_ulong, + property: ffi::Atom, + property_type: ffi::Atom, + ) -> Result<Vec<T>, GetPropertyError> { + let mut data = Vec::new(); + let mut offset = 0; + + let mut done = false; + while !done { + unsafe { + let mut actual_type: ffi::Atom = mem::uninitialized(); + let mut actual_format: c_int = mem::uninitialized(); + let mut quantity_returned: c_ulong = mem::uninitialized(); + let mut bytes_after: c_ulong = mem::uninitialized(); + let mut buf: *mut c_uchar = ptr::null_mut(); + (self.xlib.XGetWindowProperty)( + self.display, + window, + property, + // This offset is in terms of 32-bit chunks. + offset, + // This is the quanity of 32-bit chunks to receive at once. + PROPERTY_BUFFER_SIZE, + ffi::False, + property_type, + &mut actual_type, + &mut actual_format, + // This is the quantity of items we retrieved in our format, NOT of 32-bit chunks! + &mut quantity_returned, + // ...and this is a quantity of bytes. So, this function deals in 3 different units. + &mut bytes_after, + &mut buf, + ); + + if let Err(e) = self.check_errors() { + return Err(GetPropertyError::XError(e)); + } + + if actual_type != property_type { + return Err(GetPropertyError::TypeMismatch(actual_type)); + } + + let format_mismatch = Format::from_format(actual_format as _) != Some(T::FORMAT); + if format_mismatch { + return Err(GetPropertyError::FormatMismatch(actual_format)); + } + + if !buf.is_null() { + offset += PROPERTY_BUFFER_SIZE; + let new_data = std::slice::from_raw_parts( + buf as *mut T, + quantity_returned as usize, + ); + /*println!( + "XGetWindowProperty prop:{:?} fmt:{:02} len:{:02} off:{:02} out:{:02}, buf:{:?}", + property, + mem::size_of::<T>() * 8, + data.len(), + offset, + quantity_returned, + new_data, + );*/ + data.extend_from_slice(&new_data); + // Fun fact: XGetWindowProperty allocates one extra byte at the end. + (self.xlib.XFree)(buf as _); // Don't try to access new_data after this. + } else { + return Err(GetPropertyError::NothingAllocated); + } + + done = bytes_after == 0; + } + } + + Ok(data) + } + + pub fn change_property<'a, T: Formattable>( + &'a self, + window: c_ulong, + property: ffi::Atom, + property_type: ffi::Atom, + mode: PropMode, + new_value: &[T], + ) -> Flusher<'a> { + debug_assert_eq!(mem::size_of::<T>(), T::FORMAT.get_actual_size()); + unsafe { + (self.xlib.XChangeProperty)( + self.display, + window, + property, + property_type, + T::FORMAT as c_int, + mode as c_int, + new_value.as_ptr() as *const c_uchar, + new_value.len() as c_int, + ); + } + /*println!( + "XChangeProperty prop:{:?} val:{:?}", + property, + new_value, + );*/ + Flusher::new(self) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/wm.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/wm.rs new file mode 100644 index 0000000..738ab76 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/util/wm.rs @@ -0,0 +1,141 @@ +use parking_lot::Mutex; + +use super::*; + +// This info is global to the window manager. +lazy_static! { + static ref SUPPORTED_HINTS: Mutex<Vec<ffi::Atom>> = Mutex::new(Vec::with_capacity(0)); + static ref WM_NAME: Mutex<Option<String>> = Mutex::new(None); +} + +pub fn hint_is_supported(hint: ffi::Atom) -> bool { + (*SUPPORTED_HINTS.lock()).contains(&hint) +} + +pub fn wm_name_is_one_of(names: &[&str]) -> bool { + if let Some(ref name) = *WM_NAME.lock() { + names.contains(&name.as_str()) + } else { + false + } +} + +impl XConnection { + pub fn update_cached_wm_info(&self, root: ffi::Window) { + *SUPPORTED_HINTS.lock() = self.get_supported_hints(root); + *WM_NAME.lock() = self.get_wm_name(root); + } + + fn get_supported_hints(&self, root: ffi::Window) -> Vec<ffi::Atom> { + let supported_atom = unsafe { self.get_atom_unchecked(b"_NET_SUPPORTED\0") }; + self.get_property( + root, + supported_atom, + ffi::XA_ATOM, + ).unwrap_or_else(|_| Vec::with_capacity(0)) + } + + fn get_wm_name(&self, root: ffi::Window) -> Option<String> { + let check_atom = unsafe { self.get_atom_unchecked(b"_NET_SUPPORTING_WM_CHECK\0") }; + let wm_name_atom = unsafe { self.get_atom_unchecked(b"_NET_WM_NAME\0") }; + + // Mutter/Muffin/Budgie doesn't have _NET_SUPPORTING_WM_CHECK in its _NET_SUPPORTED, despite + // it working and being supported. This has been reported upstream, but due to the + // inavailability of time machines, we'll just try to get _NET_SUPPORTING_WM_CHECK + // regardless of whether or not the WM claims to support it. + // + // Blackbox 0.70 also incorrectly reports not supporting this, though that appears to be fixed + // in 0.72. + /*if !supported_hints.contains(&check_atom) { + return None; + }*/ + + // IceWM (1.3.x and earlier) doesn't report supporting _NET_WM_NAME, but will nonetheless + // provide us with a value for it. Note that the unofficial 1.4 fork of IceWM works fine. + /*if !supported_hints.contains(&wm_name_atom) { + return None; + }*/ + + // Of the WMs tested, only xmonad and dwm fail to provide a WM name. + + // Querying this property on the root window will give us the ID of a child window created by + // the WM. + let root_window_wm_check = { + let result = self.get_property( + root, + check_atom, + ffi::XA_WINDOW, + ); + + let wm_check = result + .ok() + .and_then(|wm_check| wm_check.get(0).cloned()); + + if let Some(wm_check) = wm_check { + wm_check + } else { + return None; + } + }; + + // Querying the same property on the child window we were given, we should get this child + // window's ID again. + let child_window_wm_check = { + let result = self.get_property( + root_window_wm_check, + check_atom, + ffi::XA_WINDOW, + ); + + let wm_check = result + .ok() + .and_then(|wm_check| wm_check.get(0).cloned()); + + if let Some(wm_check) = wm_check { + wm_check + } else { + return None; + } + }; + + // These values should be the same. + if root_window_wm_check != child_window_wm_check { + return None; + } + + // All of that work gives us a window ID that we can get the WM name from. + let wm_name = { + let utf8_string_atom = unsafe { self.get_atom_unchecked(b"UTF8_STRING\0") }; + + let result = self.get_property( + root_window_wm_check, + wm_name_atom, + utf8_string_atom, + ); + + // IceWM requires this. IceWM was also the only WM tested that returns a null-terminated + // string. For more fun trivia, IceWM is also unique in including version and uname + // information in this string (this means you'll have to be careful if you want to match + // against it, though). + // The unofficial 1.4 fork of IceWM still includes the extra details, but properly + // returns a UTF8 string that isn't null-terminated. + let no_utf8 = if let Err(ref err) = result { + err.is_actual_property_type(ffi::XA_STRING) + } else { + false + }; + + if no_utf8 { + self.get_property( + root_window_wm_check, + wm_name_atom, + ffi::XA_STRING, + ) + } else { + result + } + }.ok(); + + wm_name.and_then(|wm_name| String::from_utf8(wm_name).ok()) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/window.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/window.rs new file mode 100644 index 0000000..8a5f711 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/window.rs @@ -0,0 +1,1213 @@ +use std::{cmp, env, mem}; +use std::ffi::CString; +use std::os::raw::*; +use std::path::Path; +use std::sync::Arc; + +use libc; +use parking_lot::Mutex; + +use {Icon, MouseCursor, WindowAttributes}; +use CreationError::{self, OsError}; +use dpi::{LogicalPosition, LogicalSize}; +use platform::MonitorId as PlatformMonitorId; +use platform::PlatformSpecificWindowBuilderAttributes; +use platform::x11::MonitorId as X11MonitorId; +use window::MonitorId as RootMonitorId; + +use super::{ffi, util, ImeSender, XConnection, XError, WindowId, EventsLoop}; + +unsafe extern "C" fn visibility_predicate( + _display: *mut ffi::Display, + event: *mut ffi::XEvent, + arg: ffi::XPointer, // We populate this with the window ID (by value) when we call XIfEvent +) -> ffi::Bool { + let event: &ffi::XAnyEvent = (*event).as_ref(); + let window = arg as ffi::Window; + (event.window == window && event.type_ == ffi::VisibilityNotify) as _ +} + +#[derive(Debug, Default)] +pub struct SharedState { + pub cursor_pos: Option<(f64, f64)>, + pub size: Option<(u32, u32)>, + pub position: Option<(i32, i32)>, + pub inner_position: Option<(i32, i32)>, + pub inner_position_rel_parent: Option<(i32, i32)>, + pub guessed_dpi: Option<f64>, + pub last_monitor: Option<X11MonitorId>, + pub dpi_adjusted: Option<(f64, f64)>, + // Used to restore position after exiting fullscreen. + pub restore_position: Option<(i32, i32)>, + pub frame_extents: Option<util::FrameExtentsHeuristic>, + pub min_dimensions: Option<LogicalSize>, + pub max_dimensions: Option<LogicalSize>, +} + +impl SharedState { + fn new(dpi_factor: f64) -> Mutex<Self> { + let mut shared_state = SharedState::default(); + shared_state.guessed_dpi = Some(dpi_factor); + Mutex::new(shared_state) + } +} + +unsafe impl Send for UnownedWindow {} +unsafe impl Sync for UnownedWindow {} + +pub struct UnownedWindow { + pub xconn: Arc<XConnection>, // never changes + xwindow: ffi::Window, // never changes + root: ffi::Window, // never changes + screen_id: i32, // never changes + cursor: Mutex<MouseCursor>, + cursor_grabbed: Mutex<bool>, + cursor_hidden: Mutex<bool>, + ime_sender: Mutex<ImeSender>, + pub multitouch: bool, // never changes + pub shared_state: Mutex<SharedState>, +} + +impl UnownedWindow { + pub fn new( + event_loop: &EventsLoop, + window_attrs: WindowAttributes, + pl_attribs: PlatformSpecificWindowBuilderAttributes, + ) -> Result<UnownedWindow, CreationError> { + let xconn = &event_loop.xconn; + let root = event_loop.root; + + let monitors = xconn.get_available_monitors(); + let dpi_factor = if !monitors.is_empty() { + let mut dpi_factor = Some(monitors[0].get_hidpi_factor()); + for monitor in &monitors { + if Some(monitor.get_hidpi_factor()) != dpi_factor { + dpi_factor = None; + } + } + dpi_factor.unwrap_or_else(|| { + xconn.query_pointer(root, util::VIRTUAL_CORE_POINTER) + .ok() + .and_then(|pointer_state| { + let (x, y) = (pointer_state.root_x as i64, pointer_state.root_y as i64); + let mut dpi_factor = None; + for monitor in &monitors { + if monitor.rect.contains_point(x, y) { + dpi_factor = Some(monitor.get_hidpi_factor()); + break; + } + } + dpi_factor + }) + .unwrap_or(1.0) + }) + } else { + return Err(OsError(format!("No monitors were detected."))); + }; + + info!("Guessed window DPI factor: {}", dpi_factor); + + let max_dimensions: Option<(u32, u32)> = window_attrs.max_dimensions.map(|size| { + size.to_physical(dpi_factor).into() + }); + let min_dimensions: Option<(u32, u32)> = window_attrs.min_dimensions.map(|size| { + size.to_physical(dpi_factor).into() + }); + + let dimensions = { + // x11 only applies constraints when the window is actively resized + // by the user, so we have to manually apply the initial constraints + let mut dimensions: (u32, u32) = window_attrs.dimensions + .or_else(|| Some((800, 600).into())) + .map(|size| size.to_physical(dpi_factor)) + .map(Into::into) + .unwrap(); + if let Some(max) = max_dimensions { + dimensions.0 = cmp::min(dimensions.0, max.0); + dimensions.1 = cmp::min(dimensions.1, max.1); + } + if let Some(min) = min_dimensions { + dimensions.0 = cmp::max(dimensions.0, min.0); + dimensions.1 = cmp::max(dimensions.1, min.1); + } + debug!("Calculated physical dimensions: {}x{}", dimensions.0, dimensions.1); + dimensions + }; + + let screen_id = match pl_attribs.screen_id { + Some(id) => id, + None => unsafe { (xconn.xlib.XDefaultScreen)(xconn.display) }, + }; + + // creating + let mut set_win_attr = { + let mut swa: ffi::XSetWindowAttributes = unsafe { mem::zeroed() }; + swa.colormap = if let Some(vi) = pl_attribs.visual_infos { + unsafe { + let visual = vi.visual; + (xconn.xlib.XCreateColormap)(xconn.display, root, visual, ffi::AllocNone) + } + } else { 0 }; + swa.event_mask = ffi::ExposureMask + | ffi::StructureNotifyMask + | ffi::VisibilityChangeMask + | ffi::KeyPressMask + | ffi::KeyReleaseMask + | ffi::KeymapStateMask + | ffi::ButtonPressMask + | ffi::ButtonReleaseMask + | ffi::PointerMotionMask; + swa.border_pixel = 0; + swa.override_redirect = pl_attribs.override_redirect as c_int; + swa + }; + + let mut window_attributes = ffi::CWBorderPixel | ffi::CWColormap | ffi::CWEventMask; + + if pl_attribs.override_redirect { + window_attributes |= ffi::CWOverrideRedirect; + } + + // finally creating the window + let xwindow = unsafe { + (xconn.xlib.XCreateWindow)( + xconn.display, + root, + 0, + 0, + dimensions.0 as c_uint, + dimensions.1 as c_uint, + 0, + match pl_attribs.visual_infos { + Some(vi) => vi.depth, + None => ffi::CopyFromParent, + }, + ffi::InputOutput as c_uint, + match pl_attribs.visual_infos { + Some(vi) => vi.visual, + None => ffi::CopyFromParent as *mut ffi::Visual, + }, + window_attributes, + &mut set_win_attr, + ) + }; + + let window = UnownedWindow { + xconn: Arc::clone(xconn), + xwindow, + root, + screen_id, + cursor: Default::default(), + cursor_grabbed: Default::default(), + cursor_hidden: Default::default(), + ime_sender: Mutex::new(event_loop.ime_sender.clone()), + multitouch: window_attrs.multitouch, + shared_state: SharedState::new(dpi_factor), + }; + + // Title must be set before mapping. Some tiling window managers (i.e. i3) use the window + // title to determine placement/etc., so doing this after mapping would cause the WM to + // act on the wrong title state. + window.set_title_inner(&window_attrs.title).queue(); + window.set_decorations_inner(window_attrs.decorations).queue(); + + { + // Enable drag and drop (TODO: extend API to make this toggleable) + unsafe { + let dnd_aware_atom = xconn.get_atom_unchecked(b"XdndAware\0"); + let version = &[5 as c_ulong]; // Latest version; hasn't changed since 2002 + xconn.change_property( + window.xwindow, + dnd_aware_atom, + ffi::XA_ATOM, + util::PropMode::Replace, + version, + ) + }.queue(); + + // WM_CLASS must be set *before* mapping the window, as per ICCCM! + { + let (class, instance) = if let Some((instance, class)) = pl_attribs.class { + let instance = CString::new(instance.as_str()) + .expect("`WM_CLASS` instance contained null byte"); + let class = CString::new(class.as_str()) + .expect("`WM_CLASS` class contained null byte"); + (instance, class) + } else { + let class = env::args() + .next() + .as_ref() + // Default to the name of the binary (via argv[0]) + .and_then(|path| Path::new(path).file_name()) + .and_then(|bin_name| bin_name.to_str()) + .map(|bin_name| bin_name.to_owned()) + .or_else(|| Some(window_attrs.title.clone())) + .and_then(|string| CString::new(string.as_str()).ok()) + .expect("Default `WM_CLASS` class contained null byte"); + // This environment variable is extraordinarily unlikely to actually be used... + let instance = env::var("RESOURCE_NAME") + .ok() + .and_then(|instance| CString::new(instance.as_str()).ok()) + .or_else(|| Some(class.clone())) + .expect("Default `WM_CLASS` instance contained null byte"); + (instance, class) + }; + + let mut class_hint = xconn.alloc_class_hint(); + (*class_hint).res_name = class.as_ptr() as *mut c_char; + (*class_hint).res_class = instance.as_ptr() as *mut c_char; + + unsafe { + (xconn.xlib.XSetClassHint)( + xconn.display, + window.xwindow, + class_hint.ptr, + ); + }//.queue(); + } + + window.set_pid().map(|flusher| flusher.queue()); + + if pl_attribs.x11_window_type != Default::default() { + window.set_window_type(pl_attribs.x11_window_type).queue(); + } + + if let Some(variant) = pl_attribs.gtk_theme_variant { + window.set_gtk_theme_variant(variant).queue(); + } + + // set size hints + { + let mut min_dimensions = window_attrs.min_dimensions + .map(|size| size.to_physical(dpi_factor)); + let mut max_dimensions = window_attrs.max_dimensions + .map(|size| size.to_physical(dpi_factor)); + if !window_attrs.resizable { + if util::wm_name_is_one_of(&["Xfwm4"]) { + warn!("To avoid a WM bug, disabling resizing has no effect on Xfwm4"); + } else { + max_dimensions = Some(dimensions.into()); + min_dimensions = Some(dimensions.into()); + + let mut shared_state_lock = window.shared_state.lock(); + shared_state_lock.min_dimensions = window_attrs.min_dimensions; + shared_state_lock.max_dimensions = window_attrs.max_dimensions; + } + } + + let mut normal_hints = util::NormalHints::new(xconn); + normal_hints.set_size(Some(dimensions)); + normal_hints.set_min_size(min_dimensions.map(Into::into)); + normal_hints.set_max_size(max_dimensions.map(Into::into)); + normal_hints.set_resize_increments(pl_attribs.resize_increments); + normal_hints.set_base_size(pl_attribs.base_size); + xconn.set_normal_hints(window.xwindow, normal_hints).queue(); + } + + // Set window icons + if let Some(icon) = window_attrs.window_icon { + window.set_icon_inner(icon).queue(); + } + + // Opt into handling window close + unsafe { + (xconn.xlib.XSetWMProtocols)( + xconn.display, + window.xwindow, + &event_loop.wm_delete_window as *const ffi::Atom as *mut ffi::Atom, + 1, + ); + }//.queue(); + + // Set visibility (map window) + if window_attrs.visible { + unsafe { + (xconn.xlib.XMapRaised)(xconn.display, window.xwindow); + }//.queue(); + } + + // Attempt to make keyboard input repeat detectable + unsafe { + let mut supported_ptr = ffi::False; + (xconn.xlib.XkbSetDetectableAutoRepeat)( + xconn.display, + ffi::True, + &mut supported_ptr, + ); + if supported_ptr == ffi::False { + return Err(OsError(format!("`XkbSetDetectableAutoRepeat` failed"))); + } + } + + // Select XInput2 events + let mask = { + let mut mask = ffi::XI_MotionMask + | ffi::XI_ButtonPressMask + | ffi::XI_ButtonReleaseMask + //| ffi::XI_KeyPressMask + //| ffi::XI_KeyReleaseMask + | ffi::XI_EnterMask + | ffi::XI_LeaveMask + | ffi::XI_FocusInMask + | ffi::XI_FocusOutMask; + if window_attrs.multitouch { + mask |= ffi::XI_TouchBeginMask + | ffi::XI_TouchUpdateMask + | ffi::XI_TouchEndMask; + } + mask + }; + xconn.select_xinput_events(window.xwindow, ffi::XIAllMasterDevices, mask).queue(); + + { + let result = event_loop.ime + .borrow_mut() + .create_context(window.xwindow); + if let Err(err) = result { + return Err(OsError(format!("Failed to create input context: {:?}", err))); + } + } + + // These properties must be set after mapping + if window_attrs.maximized { + window.set_maximized_inner(window_attrs.maximized).queue(); + } + if window_attrs.fullscreen.is_some() { + window.set_fullscreen_inner(window_attrs.fullscreen.clone()).queue(); + } + if window_attrs.always_on_top { + window.set_always_on_top_inner(window_attrs.always_on_top).queue(); + } + + if window_attrs.visible { + unsafe { + // XSetInputFocus generates an error if the window is not visible, so we wait + // until we receive VisibilityNotify. + let mut event = mem::uninitialized(); + (xconn.xlib.XIfEvent)( // This will flush the request buffer IF it blocks. + xconn.display, + &mut event as *mut ffi::XEvent, + Some(visibility_predicate), + window.xwindow as _, + ); + (xconn.xlib.XSetInputFocus)( + xconn.display, + window.xwindow, + ffi::RevertToParent, + ffi::CurrentTime, + ); + } + } + } + + // We never want to give the user a broken window, since by then, it's too late to handle. + xconn.sync_with_server() + .map(|_| window) + .map_err(|x_err| OsError( + format!("X server returned error while building window: {:?}", x_err) + )) + } + + fn logicalize_coords(&self, (x, y): (i32, i32)) -> LogicalPosition { + let dpi = self.get_hidpi_factor(); + LogicalPosition::from_physical((x, y), dpi) + } + + fn logicalize_size(&self, (width, height): (u32, u32)) -> LogicalSize { + let dpi = self.get_hidpi_factor(); + LogicalSize::from_physical((width, height), dpi) + } + + fn set_pid(&self) -> Option<util::Flusher> { + let pid_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_PID\0") }; + let client_machine_atom = unsafe { self.xconn.get_atom_unchecked(b"WM_CLIENT_MACHINE\0") }; + unsafe { + let (hostname, hostname_length) = { + // 64 would suffice for Linux, but 256 will be enough everywhere (as per SUSv2). For instance, this is + // the limit defined by OpenBSD. + const MAXHOSTNAMELEN: usize = 256; + let mut hostname: [c_char; MAXHOSTNAMELEN] = mem::uninitialized(); + let status = libc::gethostname(hostname.as_mut_ptr(), hostname.len()); + if status != 0 { return None; } + hostname[MAXHOSTNAMELEN - 1] = '\0' as c_char; // a little extra safety + let hostname_length = libc::strlen(hostname.as_ptr()); + (hostname, hostname_length as usize) + }; + self.xconn.change_property( + self.xwindow, + pid_atom, + ffi::XA_CARDINAL, + util::PropMode::Replace, + &[libc::getpid() as util::Cardinal], + ).queue(); + let flusher = self.xconn.change_property( + self.xwindow, + client_machine_atom, + ffi::XA_STRING, + util::PropMode::Replace, + &hostname[0..hostname_length], + ); + Some(flusher) + } + } + + fn set_window_type(&self, window_type: util::WindowType) -> util::Flusher { + let hint_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_WINDOW_TYPE\0") }; + let window_type_atom = window_type.as_atom(&self.xconn); + self.xconn.change_property( + self.xwindow, + hint_atom, + ffi::XA_ATOM, + util::PropMode::Replace, + &[window_type_atom], + ) + } + + fn set_gtk_theme_variant(&self, variant: String) -> util::Flusher { + let hint_atom = unsafe { self.xconn.get_atom_unchecked(b"_GTK_THEME_VARIANT\0") }; + let utf8_atom = unsafe { self.xconn.get_atom_unchecked(b"UTF8_STRING\0") }; + let variant = CString::new(variant).expect("`_GTK_THEME_VARIANT` contained null byte"); + self.xconn.change_property( + self.xwindow, + hint_atom, + utf8_atom, + util::PropMode::Replace, + variant.as_bytes(), + ) + } + + #[inline] + pub fn set_urgent(&self, is_urgent: bool) { + let mut wm_hints = self.xconn.get_wm_hints(self.xwindow).expect("`XGetWMHints` failed"); + if is_urgent { + (*wm_hints).flags |= ffi::XUrgencyHint; + } else { + (*wm_hints).flags &= !ffi::XUrgencyHint; + } + self.xconn.set_wm_hints(self.xwindow, wm_hints).flush().expect("Failed to set urgency hint"); + } + + fn set_netwm( + &self, + operation: util::StateOperation, + properties: (c_long, c_long, c_long, c_long), + ) -> util::Flusher { + let state_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE\0") }; + self.xconn.send_client_msg( + self.xwindow, + self.root, + state_atom, + Some(ffi::SubstructureRedirectMask | ffi::SubstructureNotifyMask), + [ + operation as c_long, + properties.0, + properties.1, + properties.2, + properties.3, + ], + ) + } + + fn set_fullscreen_hint(&self, fullscreen: bool) -> util::Flusher { + let fullscreen_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE_FULLSCREEN\0") }; + self.set_netwm(fullscreen.into(), (fullscreen_atom as c_long, 0, 0, 0)) + } + + fn set_fullscreen_inner(&self, monitor: Option<RootMonitorId>) -> util::Flusher { + match monitor { + None => { + let flusher = self.set_fullscreen_hint(false); + if let Some(position) = self.shared_state.lock().restore_position.take() { + self.set_position_inner(position.0, position.1).queue(); + } + flusher + }, + Some(RootMonitorId { inner: PlatformMonitorId::X(monitor) }) => { + let window_position = self.get_position_physical(); + self.shared_state.lock().restore_position = window_position; + let monitor_origin: (i32, i32) = monitor.get_position().into(); + self.set_position_inner(monitor_origin.0, monitor_origin.1).queue(); + self.set_fullscreen_hint(true) + } + _ => unreachable!(), + } + } + + #[inline] + pub fn set_fullscreen(&self, monitor: Option<RootMonitorId>) { + self.set_fullscreen_inner(monitor) + .flush() + .expect("Failed to change window fullscreen state"); + self.invalidate_cached_frame_extents(); + } + + fn get_rect(&self) -> Option<util::AaRect> { + // TODO: This might round-trip more times than needed. + if let (Some(position), Some(size)) = (self.get_position_physical(), self.get_outer_size_physical()) { + Some(util::AaRect::new(position, size)) + } else { + None + } + } + + #[inline] + pub fn get_current_monitor(&self) -> X11MonitorId { + let monitor = self.shared_state + .lock() + .last_monitor + .as_ref() + .cloned(); + monitor + .unwrap_or_else(|| { + let monitor = self.xconn.get_monitor_for_window(self.get_rect()).to_owned(); + self.shared_state.lock().last_monitor = Some(monitor.clone()); + monitor + }) + } + + pub fn get_available_monitors(&self) -> Vec<X11MonitorId> { + self.xconn.get_available_monitors() + } + + pub fn get_primary_monitor(&self) -> X11MonitorId { + self.xconn.get_primary_monitor() + } + + fn set_maximized_inner(&self, maximized: bool) -> util::Flusher { + let horz_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE_MAXIMIZED_HORZ\0") }; + let vert_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE_MAXIMIZED_VERT\0") }; + self.set_netwm(maximized.into(), (horz_atom as c_long, vert_atom as c_long, 0, 0)) + } + + #[inline] + pub fn set_maximized(&self, maximized: bool) { + self.set_maximized_inner(maximized) + .flush() + .expect("Failed to change window maximization"); + self.invalidate_cached_frame_extents(); + } + + fn set_title_inner(&self, title: &str) -> util::Flusher { + let wm_name_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_NAME\0") }; + let utf8_atom = unsafe { self.xconn.get_atom_unchecked(b"UTF8_STRING\0") }; + let title = CString::new(title).expect("Window title contained null byte"); + unsafe { + (self.xconn.xlib.XStoreName)( + self.xconn.display, + self.xwindow, + title.as_ptr() as *const c_char, + ); + self.xconn.change_property( + self.xwindow, + wm_name_atom, + utf8_atom, + util::PropMode::Replace, + title.as_bytes(), + ) + } + } + + #[inline] + pub fn set_title(&self, title: &str) { + self.set_title_inner(title) + .flush() + .expect("Failed to set window title"); + } + + fn set_decorations_inner(&self, decorations: bool) -> util::Flusher { + let wm_hints = unsafe { self.xconn.get_atom_unchecked(b"_MOTIF_WM_HINTS\0") }; + self.xconn.change_property( + self.xwindow, + wm_hints, + wm_hints, + util::PropMode::Replace, + &[ + util::MWM_HINTS_DECORATIONS, // flags + 0, // functions + decorations as c_ulong, // decorations + 0, // input mode + 0, // status + ], + ) + } + + #[inline] + pub fn set_decorations(&self, decorations: bool) { + self.set_decorations_inner(decorations) + .flush() + .expect("Failed to set decoration state"); + self.invalidate_cached_frame_extents(); + } + + fn set_always_on_top_inner(&self, always_on_top: bool) -> util::Flusher { + let above_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE_ABOVE\0") }; + self.set_netwm(always_on_top.into(), (above_atom as c_long, 0, 0, 0)) + } + + #[inline] + pub fn set_always_on_top(&self, always_on_top: bool) { + self.set_always_on_top_inner(always_on_top) + .flush() + .expect("Failed to set always-on-top state"); + } + + fn set_icon_inner(&self, icon: Icon) -> util::Flusher { + let icon_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_ICON\0") }; + let data = icon.to_cardinals(); + self.xconn.change_property( + self.xwindow, + icon_atom, + ffi::XA_CARDINAL, + util::PropMode::Replace, + data.as_slice(), + ) + } + + fn unset_icon_inner(&self) -> util::Flusher { + let icon_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_ICON\0") }; + let empty_data: [util::Cardinal; 0] = []; + self.xconn.change_property( + self.xwindow, + icon_atom, + ffi::XA_CARDINAL, + util::PropMode::Replace, + &empty_data, + ) + } + + #[inline] + pub fn set_window_icon(&self, icon: Option<Icon>) { + match icon { + Some(icon) => self.set_icon_inner(icon), + None => self.unset_icon_inner(), + }.flush().expect("Failed to set icons"); + } + + #[inline] + pub fn show(&self) { + unsafe { + (self.xconn.xlib.XMapRaised)(self.xconn.display, self.xwindow); + self.xconn.flush_requests() + .expect("Failed to call XMapRaised"); + } + } + + #[inline] + pub fn hide(&self) { + unsafe { + (self.xconn.xlib.XUnmapWindow)(self.xconn.display, self.xwindow); + self.xconn.flush_requests() + .expect("Failed to call XUnmapWindow"); + } + } + + fn update_cached_frame_extents(&self) { + let extents = self.xconn.get_frame_extents_heuristic(self.xwindow, self.root); + (*self.shared_state.lock()).frame_extents = Some(extents); + } + + pub(crate) fn invalidate_cached_frame_extents(&self) { + (*self.shared_state.lock()).frame_extents.take(); + } + + pub(crate) fn get_position_physical(&self) -> Option<(i32, i32)> { + let extents = (*self.shared_state.lock()).frame_extents.clone(); + if let Some(extents) = extents { + self.get_inner_position_physical() + .map(|(x, y)| extents.inner_pos_to_outer(x, y)) + } else { + self.update_cached_frame_extents(); + self.get_position_physical() + } + } + + #[inline] + pub fn get_position(&self) -> Option<LogicalPosition> { + let extents = (*self.shared_state.lock()).frame_extents.clone(); + if let Some(extents) = extents { + self.get_inner_position() + .map(|logical| extents.inner_pos_to_outer_logical(logical, self.get_hidpi_factor())) + } else { + self.update_cached_frame_extents(); + self.get_position() + } + } + + pub(crate) fn get_inner_position_physical(&self) -> Option<(i32, i32)> { + self.xconn.translate_coords(self.xwindow, self.root) + .ok() + .map(|coords| (coords.x_rel_root, coords.y_rel_root)) + } + + #[inline] + pub fn get_inner_position(&self) -> Option<LogicalPosition> { + self.get_inner_position_physical() + .map(|coords| self.logicalize_coords(coords)) + } + + pub(crate) fn set_position_inner(&self, mut x: i32, mut y: i32) -> util::Flusher { + // There are a few WMs that set client area position rather than window position, so + // we'll translate for consistency. + if util::wm_name_is_one_of(&["Enlightenment", "FVWM"]) { + let extents = (*self.shared_state.lock()).frame_extents.clone(); + if let Some(extents) = extents { + x += extents.frame_extents.left as i32; + y += extents.frame_extents.top as i32; + } else { + self.update_cached_frame_extents(); + return self.set_position_inner(x, y); + } + } + unsafe { + (self.xconn.xlib.XMoveWindow)( + self.xconn.display, + self.xwindow, + x as c_int, + y as c_int, + ); + } + util::Flusher::new(&self.xconn) + } + + pub(crate) fn set_position_physical(&self, x: i32, y: i32) { + self.set_position_inner(x, y) + .flush() + .expect("Failed to call `XMoveWindow`"); + } + + #[inline] + pub fn set_position(&self, logical_position: LogicalPosition) { + let (x, y) = logical_position.to_physical(self.get_hidpi_factor()).into(); + self.set_position_physical(x, y); + } + + pub(crate) fn get_inner_size_physical(&self) -> Option<(u32, u32)> { + self.xconn.get_geometry(self.xwindow) + .ok() + .map(|geo| (geo.width, geo.height)) + } + + #[inline] + pub fn get_inner_size(&self) -> Option<LogicalSize> { + self.get_inner_size_physical() + .map(|size| self.logicalize_size(size)) + } + + pub(crate) fn get_outer_size_physical(&self) -> Option<(u32, u32)> { + let extents = self.shared_state.lock().frame_extents.clone(); + if let Some(extents) = extents { + self.get_inner_size_physical() + .map(|(w, h)| extents.inner_size_to_outer(w, h)) + } else { + self.update_cached_frame_extents(); + self.get_outer_size_physical() + } + } + + #[inline] + pub fn get_outer_size(&self) -> Option<LogicalSize> { + let extents = self.shared_state.lock().frame_extents.clone(); + if let Some(extents) = extents { + self.get_inner_size() + .map(|logical| extents.inner_size_to_outer_logical(logical, self.get_hidpi_factor())) + } else { + self.update_cached_frame_extents(); + self.get_outer_size() + } + } + + pub(crate) fn set_inner_size_physical(&self, width: u32, height: u32) { + unsafe { + (self.xconn.xlib.XResizeWindow)( + self.xconn.display, + self.xwindow, + width as c_uint, + height as c_uint, + ); + self.xconn.flush_requests() + }.expect("Failed to call `XResizeWindow`"); + } + + #[inline] + pub fn set_inner_size(&self, logical_size: LogicalSize) { + let dpi_factor = self.get_hidpi_factor(); + let (width, height) = logical_size.to_physical(dpi_factor).into(); + self.set_inner_size_physical(width, height); + } + + fn update_normal_hints<F>(&self, callback: F) -> Result<(), XError> + where F: FnOnce(&mut util::NormalHints) -> () + { + let mut normal_hints = self.xconn.get_normal_hints(self.xwindow)?; + callback(&mut normal_hints); + self.xconn.set_normal_hints(self.xwindow, normal_hints).flush() + } + + pub(crate) fn set_min_dimensions_physical(&self, dimensions: Option<(u32, u32)>) { + self.update_normal_hints(|normal_hints| normal_hints.set_min_size(dimensions)) + .expect("Failed to call `XSetWMNormalHints`"); + } + + #[inline] + pub fn set_min_dimensions(&self, logical_dimensions: Option<LogicalSize>) { + self.shared_state.lock().min_dimensions = logical_dimensions; + let physical_dimensions = logical_dimensions.map(|logical_dimensions| { + logical_dimensions.to_physical(self.get_hidpi_factor()).into() + }); + self.set_min_dimensions_physical(physical_dimensions); + } + + pub(crate) fn set_max_dimensions_physical(&self, dimensions: Option<(u32, u32)>) { + self.update_normal_hints(|normal_hints| normal_hints.set_max_size(dimensions)) + .expect("Failed to call `XSetWMNormalHints`"); + } + + #[inline] + pub fn set_max_dimensions(&self, logical_dimensions: Option<LogicalSize>) { + self.shared_state.lock().max_dimensions = logical_dimensions; + let physical_dimensions = logical_dimensions.map(|logical_dimensions| { + logical_dimensions.to_physical(self.get_hidpi_factor()).into() + }); + self.set_max_dimensions_physical(physical_dimensions); + } + + pub(crate) fn adjust_for_dpi( + &self, + old_dpi_factor: f64, + new_dpi_factor: f64, + width: f64, + height: f64, + ) -> (f64, f64, util::Flusher) { + let scale_factor = new_dpi_factor / old_dpi_factor; + let new_width = width * scale_factor; + let new_height = height * scale_factor; + self.update_normal_hints(|normal_hints| { + let dpi_adjuster = |(width, height): (u32, u32)| -> (u32, u32) { + let new_width = width as f64 * scale_factor; + let new_height = height as f64 * scale_factor; + (new_width.round() as u32, new_height.round() as u32) + }; + let max_size = normal_hints.get_max_size().map(&dpi_adjuster); + let min_size = normal_hints.get_min_size().map(&dpi_adjuster); + let resize_increments = normal_hints.get_resize_increments().map(&dpi_adjuster); + let base_size = normal_hints.get_base_size().map(&dpi_adjuster); + normal_hints.set_max_size(max_size); + normal_hints.set_min_size(min_size); + normal_hints.set_resize_increments(resize_increments); + normal_hints.set_base_size(base_size); + }).expect("Failed to update normal hints"); + unsafe { + (self.xconn.xlib.XResizeWindow)( + self.xconn.display, + self.xwindow, + new_width.round() as c_uint, + new_height.round() as c_uint, + ); + } + (new_width, new_height, util::Flusher::new(&self.xconn)) + } + + pub fn set_resizable(&self, resizable: bool) { + if util::wm_name_is_one_of(&["Xfwm4"]) { + // Making the window unresizable on Xfwm prevents further changes to `WM_NORMAL_HINTS` from being detected. + // This makes it impossible for resizing to be re-enabled, and also breaks DPI scaling. As such, we choose + // the lesser of two evils and do nothing. + warn!("To avoid a WM bug, disabling resizing has no effect on Xfwm4"); + return; + } + + let (logical_min, logical_max) = if resizable { + let shared_state_lock = self.shared_state.lock(); + (shared_state_lock.min_dimensions, shared_state_lock.max_dimensions) + } else { + let window_size = self.get_inner_size(); + (window_size.clone(), window_size) + }; + + let dpi_factor = self.get_hidpi_factor(); + let min_dimensions = logical_min + .map(|logical_size| logical_size.to_physical(dpi_factor)) + .map(Into::into); + let max_dimensions = logical_max + .map(|logical_size| logical_size.to_physical(dpi_factor)) + .map(Into::into); + self.update_normal_hints(|normal_hints| { + normal_hints.set_min_size(min_dimensions); + normal_hints.set_max_size(max_dimensions); + }).expect("Failed to call `XSetWMNormalHints`"); + } + + #[inline] + pub fn get_xlib_display(&self) -> *mut c_void { + self.xconn.display as _ + } + + #[inline] + pub fn get_xlib_screen_id(&self) -> c_int { + self.screen_id + } + + #[inline] + pub fn get_xlib_xconnection(&self) -> Arc<XConnection> { + Arc::clone(&self.xconn) + } + + #[inline] + pub fn get_xlib_window(&self) -> c_ulong { + self.xwindow + } + + #[inline] + pub fn get_xcb_connection(&self) -> *mut c_void { + unsafe { + (self.xconn.xlib_xcb.XGetXCBConnection)(self.xconn.display) as *mut _ + } + } + + fn load_cursor(&self, name: &[u8]) -> ffi::Cursor { + unsafe { + (self.xconn.xcursor.XcursorLibraryLoadCursor)( + self.xconn.display, + name.as_ptr() as *const c_char, + ) + } + } + + fn load_first_existing_cursor(&self, names: &[&[u8]]) -> ffi::Cursor { + for name in names.iter() { + let xcursor = self.load_cursor(name); + if xcursor != 0 { + return xcursor; + } + } + 0 + } + + fn get_cursor(&self, cursor: MouseCursor) -> ffi::Cursor { + let load = |name: &[u8]| { + self.load_cursor(name) + }; + + let loadn = |names: &[&[u8]]| { + self.load_first_existing_cursor(names) + }; + + // Try multiple names in some cases where the name + // differs on the desktop environments or themes. + // + // Try the better looking (or more suiting) names first. + match cursor { + MouseCursor::Alias => load(b"link\0"), + MouseCursor::Arrow => load(b"arrow\0"), + MouseCursor::Cell => load(b"plus\0"), + MouseCursor::Copy => load(b"copy\0"), + MouseCursor::Crosshair => load(b"crosshair\0"), + MouseCursor::Default => load(b"left_ptr\0"), + MouseCursor::Hand => loadn(&[b"hand2\0", b"hand1\0"]), + MouseCursor::Help => load(b"question_arrow\0"), + MouseCursor::Move => load(b"move\0"), + MouseCursor::Grab => loadn(&[b"openhand\0", b"grab\0"]), + MouseCursor::Grabbing => loadn(&[b"closedhand\0", b"grabbing\0"]), + MouseCursor::Progress => load(b"left_ptr_watch\0"), + MouseCursor::AllScroll => load(b"all-scroll\0"), + MouseCursor::ContextMenu => load(b"context-menu\0"), + + MouseCursor::NoDrop => loadn(&[b"no-drop\0", b"circle\0"]), + MouseCursor::NotAllowed => load(b"crossed_circle\0"), + + + // Resize cursors + MouseCursor::EResize => load(b"right_side\0"), + MouseCursor::NResize => load(b"top_side\0"), + MouseCursor::NeResize => load(b"top_right_corner\0"), + MouseCursor::NwResize => load(b"top_left_corner\0"), + MouseCursor::SResize => load(b"bottom_side\0"), + MouseCursor::SeResize => load(b"bottom_right_corner\0"), + MouseCursor::SwResize => load(b"bottom_left_corner\0"), + MouseCursor::WResize => load(b"left_side\0"), + MouseCursor::EwResize => load(b"h_double_arrow\0"), + MouseCursor::NsResize => load(b"v_double_arrow\0"), + MouseCursor::NwseResize => loadn(&[b"bd_double_arrow\0", b"size_bdiag\0"]), + MouseCursor::NeswResize => loadn(&[b"fd_double_arrow\0", b"size_fdiag\0"]), + MouseCursor::ColResize => loadn(&[b"split_h\0", b"h_double_arrow\0"]), + MouseCursor::RowResize => loadn(&[b"split_v\0", b"v_double_arrow\0"]), + + MouseCursor::Text => loadn(&[b"text\0", b"xterm\0"]), + MouseCursor::VerticalText => load(b"vertical-text\0"), + + MouseCursor::Wait => load(b"watch\0"), + + MouseCursor::ZoomIn => load(b"zoom-in\0"), + MouseCursor::ZoomOut => load(b"zoom-out\0"), + } + } + + fn update_cursor(&self, cursor: ffi::Cursor) { + unsafe { + (self.xconn.xlib.XDefineCursor)(self.xconn.display, self.xwindow, cursor); + if cursor != 0 { + (self.xconn.xlib.XFreeCursor)(self.xconn.display, cursor); + } + self.xconn.flush_requests().expect("Failed to set or free the cursor"); + } + } + + #[inline] + pub fn set_cursor(&self, cursor: MouseCursor) { + *self.cursor.lock() = cursor; + if !*self.cursor_hidden.lock() { + self.update_cursor(self.get_cursor(cursor)); + } + } + + // TODO: This could maybe be cached. I don't think it's worth + // the complexity, since cursor changes are not so common, + // and this is just allocating a 1x1 pixmap... + fn create_empty_cursor(&self) -> Option<ffi::Cursor> { + let data = 0; + let pixmap = unsafe { + (self.xconn.xlib.XCreateBitmapFromData)( + self.xconn.display, + self.xwindow, + &data, + 1, + 1, + ) + }; + if pixmap == 0 { + // Failed to allocate + return None; + } + + let cursor = unsafe { + // We don't care about this color, since it only fills bytes + // in the pixmap which are not 0 in the mask. + let dummy_color: ffi::XColor = mem::uninitialized(); + let cursor = (self.xconn.xlib.XCreatePixmapCursor)( + self.xconn.display, + pixmap, + pixmap, + &dummy_color as *const _ as *mut _, + &dummy_color as *const _ as *mut _, + 0, + 0, + ); + (self.xconn.xlib.XFreePixmap)(self.xconn.display, pixmap); + cursor + }; + Some(cursor) + } + + #[inline] + pub fn grab_cursor(&self, grab: bool) -> Result<(), String> { + let mut grabbed_lock = self.cursor_grabbed.lock(); + if grab == *grabbed_lock { return Ok(()); } + unsafe { + // We ungrab before grabbing to prevent passive grabs from causing `AlreadyGrabbed`. + // Therefore, this is common to both codepaths. + (self.xconn.xlib.XUngrabPointer)(self.xconn.display, ffi::CurrentTime); + } + let result = if grab { + let result = unsafe { + (self.xconn.xlib.XGrabPointer)( + self.xconn.display, + self.xwindow, + ffi::True, + ( + ffi::ButtonPressMask + | ffi::ButtonReleaseMask + | ffi::EnterWindowMask + | ffi::LeaveWindowMask + | ffi::PointerMotionMask + | ffi::PointerMotionHintMask + | ffi::Button1MotionMask + | ffi::Button2MotionMask + | ffi::Button3MotionMask + | ffi::Button4MotionMask + | ffi::Button5MotionMask + | ffi::ButtonMotionMask + | ffi::KeymapStateMask + ) as c_uint, + ffi::GrabModeAsync, + ffi::GrabModeAsync, + self.xwindow, + 0, + ffi::CurrentTime, + ) + }; + + match result { + ffi::GrabSuccess => Ok(()), + ffi::AlreadyGrabbed => Err("Cursor could not be grabbed: already grabbed by another client"), + ffi::GrabInvalidTime => Err("Cursor could not be grabbed: invalid time"), + ffi::GrabNotViewable => Err("Cursor could not be grabbed: grab location not viewable"), + ffi::GrabFrozen => Err("Cursor could not be grabbed: frozen by another client"), + _ => unreachable!(), + }.map_err(|err| err.to_owned()) + } else { + self.xconn.flush_requests() + .map_err(|err| format!("Failed to call `XUngrabPointer`: {:?}", err)) + }; + if result.is_ok() { + *grabbed_lock = grab; + } + result + } + + #[inline] + pub fn hide_cursor(&self, hide: bool) { + let mut hidden_lock = self.cursor_hidden.lock(); + if hide == *hidden_lock {return; } + let cursor = if hide { + self.create_empty_cursor().expect("Failed to create empty cursor") + } else { + self.get_cursor(*self.cursor.lock()) + }; + *hidden_lock = hide; + drop(hidden_lock); + self.update_cursor(cursor); + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + self.get_current_monitor().hidpi_factor + } + + pub fn set_cursor_position_physical(&self, x: i32, y: i32) -> Result<(), String> { + unsafe { + (self.xconn.xlib.XWarpPointer)( + self.xconn.display, + 0, + self.xwindow, + 0, + 0, + 0, + 0, + x, + y, + ); + self.xconn.flush_requests().map_err(|e| format!("`XWarpPointer` failed: {:?}", e)) + } + } + + #[inline] + pub fn set_cursor_position(&self, logical_position: LogicalPosition) -> Result<(), String> { + let (x, y) = logical_position.to_physical(self.get_hidpi_factor()).into(); + self.set_cursor_position_physical(x, y) + } + + pub(crate) fn set_ime_spot_physical(&self, x: i32, y: i32) { + let _ = self.ime_sender + .lock() + .send((self.xwindow, x as i16, y as i16)); + } + + #[inline] + pub fn set_ime_spot(&self, logical_spot: LogicalPosition) { + let (x, y) = logical_spot.to_physical(self.get_hidpi_factor()).into(); + self.set_ime_spot_physical(x, y); + } + + #[inline] + pub fn id(&self) -> WindowId { WindowId(self.xwindow) } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/xdisplay.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/xdisplay.rs new file mode 100644 index 0000000..c0f1e7d --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/linux/x11/xdisplay.rs @@ -0,0 +1,155 @@ +use std::ptr; +use std::fmt; +use std::error::Error; + +use libc; +use parking_lot::Mutex; + +use super::ffi; + +/// A connection to an X server. +pub struct XConnection { + pub xlib: ffi::Xlib, + /// Exposes XRandR functions from version < 1.5 + pub xrandr: ffi::Xrandr_2_2_0, + /// Exposes XRandR functions from version = 1.5 + pub xrandr_1_5: Option<ffi::Xrandr>, + pub xcursor: ffi::Xcursor, + pub xinput2: ffi::XInput2, + pub xlib_xcb: ffi::Xlib_xcb, + pub display: *mut ffi::Display, + pub latest_error: Mutex<Option<XError>>, +} + +unsafe impl Send for XConnection {} +unsafe impl Sync for XConnection {} + +pub type XErrorHandler = Option<unsafe extern fn(*mut ffi::Display, *mut ffi::XErrorEvent) -> libc::c_int>; + +impl XConnection { + pub fn new(error_handler: XErrorHandler) -> Result<XConnection, XNotSupported> { + // opening the libraries + let xlib = ffi::Xlib::open()?; + let xcursor = ffi::Xcursor::open()?; + let xrandr = ffi::Xrandr_2_2_0::open()?; + let xrandr_1_5 = ffi::Xrandr::open().ok(); + let xinput2 = ffi::XInput2::open()?; + let xlib_xcb = ffi::Xlib_xcb::open()?; + + unsafe { (xlib.XInitThreads)() }; + unsafe { (xlib.XSetErrorHandler)(error_handler) }; + + // calling XOpenDisplay + let display = unsafe { + let display = (xlib.XOpenDisplay)(ptr::null()); + if display.is_null() { + return Err(XNotSupported::XOpenDisplayFailed); + } + display + }; + + Ok(XConnection { + xlib, + xrandr, + xrandr_1_5, + xcursor, + xinput2, + xlib_xcb, + display, + latest_error: Mutex::new(None), + }) + } + + /// Checks whether an error has been triggered by the previous function calls. + #[inline] + pub fn check_errors(&self) -> Result<(), XError> { + let error = self.latest_error.lock().take(); + if let Some(error) = error { + Err(error) + } else { + Ok(()) + } + } + + /// Ignores any previous error. + #[inline] + pub fn ignore_error(&self) { + *self.latest_error.lock() = None; + } +} + +impl fmt::Debug for XConnection { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.display.fmt(f) + } +} + +impl Drop for XConnection { + #[inline] + fn drop(&mut self) { + unsafe { (self.xlib.XCloseDisplay)(self.display) }; + } +} + +/// Error triggered by xlib. +#[derive(Debug, Clone)] +pub struct XError { + pub description: String, + pub error_code: u8, + pub request_code: u8, + pub minor_code: u8, +} + +impl Error for XError { + #[inline] + fn description(&self) -> &str { + &self.description + } +} + +impl fmt::Display for XError { + fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(formatter, "X error: {} (code: {}, request code: {}, minor code: {})", + self.description, self.error_code, self.request_code, self.minor_code) + } +} + +/// Error returned if this system doesn't have XLib or can't create an X connection. +#[derive(Clone, Debug)] +pub enum XNotSupported { + /// Failed to load one or several shared libraries. + LibraryOpenError(ffi::OpenError), + /// Connecting to the X server with `XOpenDisplay` failed. + XOpenDisplayFailed, // TODO: add better message +} + +impl From<ffi::OpenError> for XNotSupported { + #[inline] + fn from(err: ffi::OpenError) -> XNotSupported { + XNotSupported::LibraryOpenError(err) + } +} + +impl Error for XNotSupported { + #[inline] + fn description(&self) -> &str { + match *self { + XNotSupported::LibraryOpenError(_) => "Failed to load one of xlib's shared libraries", + XNotSupported::XOpenDisplayFailed => "Failed to open connection to X server", + } + } + + #[inline] + fn cause(&self) -> Option<&Error> { + match *self { + XNotSupported::LibraryOpenError(ref err) => Some(err), + _ => None + } + } +} + +impl fmt::Display for XNotSupported { + fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + formatter.write_str(self.description()) + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/events_loop.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/events_loop.rs new file mode 100644 index 0000000..ca1ff17 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/events_loop.rs @@ -0,0 +1,742 @@ +use {ControlFlow, EventsLoopClosed}; +use cocoa::{self, appkit, foundation}; +use cocoa::appkit::{NSApplication, NSEvent, NSEventMask, NSEventModifierFlags, NSEventPhase, NSView, NSWindow}; +use events::{self, ElementState, Event, TouchPhase, WindowEvent, DeviceEvent, ModifiersState, KeyboardInput}; +use std::collections::VecDeque; +use std::sync::{Arc, Mutex, Weak}; +use super::window::Window2; +use std; +use std::os::raw::*; +use super::DeviceId; + +pub struct EventsLoop { + modifiers: Modifiers, + pub shared: Arc<Shared>, +} + +// State shared between the `EventsLoop` and its registered windows. +pub struct Shared { + pub windows: Mutex<Vec<Weak<Window2>>>, + pub pending_events: Mutex<VecDeque<Event>>, + // The user event callback given via either of the `poll_events` or `run_forever` methods. + // + // We store the user's callback here so that it may be accessed by each of the window delegate + // callbacks (e.g. resize, close, etc) for the duration of a call to either of the + // `poll_events` or `run_forever` methods. + // + // This is *only* `Some` for the duration of a call to either of these methods and will be + // `None` otherwise. + user_callback: UserCallback, +} + +#[derive(Clone)] +pub struct Proxy {} + +struct Modifiers { + shift_pressed: bool, + ctrl_pressed: bool, + win_pressed: bool, + alt_pressed: bool, +} + +// Wrapping the user callback in a type allows us to: +// +// - ensure the callback pointer is never accidentally cloned +// - ensure that only the `EventsLoop` can `store` and `drop` the callback pointer +// - Share access to the user callback with the NSWindow callbacks. +pub struct UserCallback { + mutex: Mutex<Option<*mut FnMut(Event)>>, +} + + +impl Shared { + + pub fn new() -> Self { + Shared { + windows: Mutex::new(Vec::new()), + pending_events: Mutex::new(VecDeque::new()), + user_callback: UserCallback { mutex: Mutex::new(None) }, + } + } + + fn call_user_callback_with_pending_events(&self) { + loop { + let event = match self.pending_events.lock().unwrap().pop_front() { + Some(event) => event, + None => return, + }; + unsafe { + self.user_callback.call_with_event(event); + } + } + } + + // Calls the user callback if one exists. + // + // Otherwise, stores the event in the `pending_events` queue. + // + // This is necessary for the case when `WindowDelegate` callbacks are triggered during a call + // to the user's callback. + pub fn call_user_callback_with_event_or_store_in_pending(&self, event: Event) { + if self.user_callback.mutex.lock().unwrap().is_some() { + unsafe { + self.user_callback.call_with_event(event); + } + } else { + self.pending_events.lock().unwrap().push_back(event); + } + } + + // Removes the window with the given `Id` from the `windows` list. + // + // This is called in response to `windowWillClose`. + pub fn find_and_remove_window(&self, id: super::window::Id) { + if let Ok(mut windows) = self.windows.lock() { + windows.retain(|w| match w.upgrade() { + Some(w) => w.id() != id, + None => false, + }); + } + } + +} + + +impl Modifiers { + pub fn new() -> Self { + Modifiers { + shift_pressed: false, + ctrl_pressed: false, + win_pressed: false, + alt_pressed: false, + } + } +} + + +impl UserCallback { + + // Here we store user's `callback` behind the mutex so that they may be safely shared between + // each of the window delegates. + // + // In order to make sure that the pointer is always valid, we must manually guarantee that it + // is dropped before the callback itself is dropped. Thus, this should *only* be called at the + // beginning of a call to `poll_events` and `run_forever`, both of which *must* drop the + // callback at the end of their scope using the `drop` method. + fn store<F>(&self, callback: &mut F) + where F: FnMut(Event) + { + let trait_object = callback as &mut FnMut(Event); + let trait_object_ptr = trait_object as *const FnMut(Event) as *mut FnMut(Event); + *self.mutex.lock().unwrap() = Some(trait_object_ptr); + } + + // Emits the given event via the user-given callback. + // + // This is unsafe as it requires dereferencing the pointer to the user-given callback. We + // guarantee this is safe by ensuring the `UserCallback` never lives longer than the user-given + // callback. + // + // Note that the callback may not always be `Some`. This is because some `NSWindowDelegate` + // callbacks can be triggered by means other than `NSApp().sendEvent`. For example, if a window + // is destroyed or created during a call to the user's callback, the `WindowDelegate` methods + // may be called with `windowShouldClose` or `windowDidResignKey`. + unsafe fn call_with_event(&self, event: Event) { + let callback = match self.mutex.lock().unwrap().take() { + Some(callback) => callback, + None => return, + }; + (*callback)(event); + *self.mutex.lock().unwrap() = Some(callback); + } + + // Used to drop the user callback pointer at the end of the `poll_events` and `run_forever` + // methods. This is done to enforce our guarantee that the top callback will never live longer + // than the call to either `poll_events` or `run_forever` to which it was given. + fn drop(&self) { + self.mutex.lock().unwrap().take(); + } + +} + + +impl EventsLoop { + + pub fn new() -> Self { + // Mark this thread as the main thread of the Cocoa event system. + // + // This must be done before any worker threads get a chance to call it + // (e.g., via `EventsLoopProxy::wakeup()`), causing a wrong thread to be + // marked as the main thread. + unsafe { appkit::NSApp(); } + + EventsLoop { + shared: Arc::new(Shared::new()), + modifiers: Modifiers::new(), + } + } + + pub fn poll_events<F>(&mut self, mut callback: F) + where F: FnMut(Event), + { + unsafe { + if !msg_send![class!(NSThread), isMainThread] { + panic!("Events can only be polled from the main thread on macOS"); + } + } + + self.shared.user_callback.store(&mut callback); + + // Loop as long as we have pending events to return. + loop { + unsafe { + // First, yield all pending events. + self.shared.call_user_callback_with_pending_events(); + + let pool = foundation::NSAutoreleasePool::new(cocoa::base::nil); + + // Poll for the next event, returning `nil` if there are none. + let ns_event = appkit::NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_( + NSEventMask::NSAnyEventMask.bits() | NSEventMask::NSEventMaskPressure.bits(), + foundation::NSDate::distantPast(cocoa::base::nil), + foundation::NSDefaultRunLoopMode, + cocoa::base::YES); + + let event = self.ns_event_to_event(ns_event); + + let _: () = msg_send![pool, release]; + + match event { + // Call the user's callback. + Some(event) => self.shared.user_callback.call_with_event(event), + None => break, + } + } + } + + self.shared.user_callback.drop(); + } + + pub fn run_forever<F>(&mut self, mut callback: F) + where F: FnMut(Event) -> ControlFlow + { + unsafe { + if !msg_send![class!(NSThread), isMainThread] { + panic!("Events can only be polled from the main thread on macOS"); + } + } + + // Track whether or not control flow has changed. + let control_flow = std::cell::Cell::new(ControlFlow::Continue); + + let mut callback = |event| { + if let ControlFlow::Break = callback(event) { + control_flow.set(ControlFlow::Break); + } + }; + + self.shared.user_callback.store(&mut callback); + + loop { + unsafe { + // First, yield all pending events. + self.shared.call_user_callback_with_pending_events(); + if let ControlFlow::Break = control_flow.get() { + break; + } + + let pool = foundation::NSAutoreleasePool::new(cocoa::base::nil); + + // Wait for the next event. Note that this function blocks during resize. + let ns_event = appkit::NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_( + NSEventMask::NSAnyEventMask.bits() | NSEventMask::NSEventMaskPressure.bits(), + foundation::NSDate::distantFuture(cocoa::base::nil), + foundation::NSDefaultRunLoopMode, + cocoa::base::YES); + + let maybe_event = self.ns_event_to_event(ns_event); + + // Release the pool before calling the top callback in case the user calls either + // `run_forever` or `poll_events` within the callback. + let _: () = msg_send![pool, release]; + + if let Some(event) = maybe_event { + self.shared.user_callback.call_with_event(event); + if let ControlFlow::Break = control_flow.get() { + break; + } + } + } + } + + self.shared.user_callback.drop(); + } + + // Convert some given `NSEvent` into a winit `Event`. + unsafe fn ns_event_to_event(&mut self, ns_event: cocoa::base::id) -> Option<Event> { + if ns_event == cocoa::base::nil { + return None; + } + + // FIXME: Despite not being documented anywhere, an `NSEvent` is produced when a user opens + // Spotlight while the NSApplication is in focus. This `NSEvent` produces a `NSEventType` + // with value `21`. This causes a SEGFAULT as soon as we try to match on the `NSEventType` + // enum as there is no variant associated with the value. Thus, we return early if this + // sneaky event occurs. If someone does find some documentation on this, please fix this by + // adding an appropriate variant to the `NSEventType` enum in the cocoa-rs crate. + if ns_event.eventType() as u64 == 21 { + return None; + } + + let event_type = ns_event.eventType(); + let ns_window = ns_event.window(); + let window_id = super::window::get_window_id(ns_window); + + // FIXME: Document this. Why do we do this? Seems like it passes on events to window/app. + // If we don't do this, window does not become main for some reason. + appkit::NSApp().sendEvent_(ns_event); + + let windows = self.shared.windows.lock().unwrap(); + let maybe_window = windows.iter() + .filter_map(Weak::upgrade) + .find(|window| window_id == window.id()); + + let into_event = |window_event| Event::WindowEvent { + window_id: ::WindowId(window_id), + event: window_event, + }; + + // Returns `Some` window if one of our windows is the key window. + let maybe_key_window = || windows.iter() + .filter_map(Weak::upgrade) + .find(|window| { + let is_key_window: cocoa::base::BOOL = msg_send![*window.window, isKeyWindow]; + is_key_window == cocoa::base::YES + }); + + match event_type { + // https://github.com/glfw/glfw/blob/50eccd298a2bbc272b4977bd162d3e4b55f15394/src/cocoa_window.m#L881 + appkit::NSKeyUp => { + if let Some(key_window) = maybe_key_window() { + if event_mods(ns_event).logo { + let _: () = msg_send![*key_window.window, sendEvent:ns_event]; + } + } + None + }, + // similar to above, but for `<Cmd-.>`, the keyDown is suppressed instead of the + // KeyUp, and the above trick does not appear to work. + appkit::NSKeyDown => { + let modifiers = event_mods(ns_event); + let keycode = NSEvent::keyCode(ns_event); + if modifiers.logo && keycode == 47 { + modifier_event(ns_event, NSEventModifierFlags::NSCommandKeyMask, false) + .map(into_event) + } else { + None + } + }, + appkit::NSFlagsChanged => { + let mut events = std::collections::VecDeque::new(); + + if let Some(window_event) = modifier_event( + ns_event, + NSEventModifierFlags::NSShiftKeyMask, + self.modifiers.shift_pressed, + ) { + self.modifiers.shift_pressed = !self.modifiers.shift_pressed; + events.push_back(into_event(window_event)); + } + + if let Some(window_event) = modifier_event( + ns_event, + NSEventModifierFlags::NSControlKeyMask, + self.modifiers.ctrl_pressed, + ) { + self.modifiers.ctrl_pressed = !self.modifiers.ctrl_pressed; + events.push_back(into_event(window_event)); + } + + if let Some(window_event) = modifier_event( + ns_event, + NSEventModifierFlags::NSCommandKeyMask, + self.modifiers.win_pressed, + ) { + self.modifiers.win_pressed = !self.modifiers.win_pressed; + events.push_back(into_event(window_event)); + } + + if let Some(window_event) = modifier_event( + ns_event, + NSEventModifierFlags::NSAlternateKeyMask, + self.modifiers.alt_pressed, + ) { + self.modifiers.alt_pressed = !self.modifiers.alt_pressed; + events.push_back(into_event(window_event)); + } + + let event = events.pop_front(); + self.shared.pending_events + .lock() + .unwrap() + .extend(events.into_iter()); + event + }, + + appkit::NSMouseEntered => { + let window = match maybe_window.or_else(maybe_key_window) { + Some(window) => window, + None => return None, + }; + + let window_point = ns_event.locationInWindow(); + let view_point = if ns_window == cocoa::base::nil { + let ns_size = foundation::NSSize::new(0.0, 0.0); + let ns_rect = foundation::NSRect::new(window_point, ns_size); + let window_rect = window.window.convertRectFromScreen_(ns_rect); + window.view.convertPoint_fromView_(window_rect.origin, cocoa::base::nil) + } else { + window.view.convertPoint_fromView_(window_point, cocoa::base::nil) + }; + + let view_rect = NSView::frame(*window.view); + let x = view_point.x as f64; + let y = (view_rect.size.height - view_point.y) as f64; + let window_event = WindowEvent::CursorMoved { + device_id: DEVICE_ID, + position: (x, y).into(), + modifiers: event_mods(ns_event), + }; + let event = Event::WindowEvent { window_id: ::WindowId(window.id()), event: window_event }; + self.shared.pending_events.lock().unwrap().push_back(event); + Some(into_event(WindowEvent::CursorEntered { device_id: DEVICE_ID })) + }, + appkit::NSMouseExited => { Some(into_event(WindowEvent::CursorLeft { device_id: DEVICE_ID })) }, + + appkit::NSMouseMoved | + appkit::NSLeftMouseDragged | + appkit::NSOtherMouseDragged | + appkit::NSRightMouseDragged => { + // If the mouse movement was on one of our windows, use it. + // Otherwise, if one of our windows is the key window (receiving input), use it. + // Otherwise, return `None`. + match maybe_window.or_else(maybe_key_window) { + Some(_window) => (), + None => return None, + } + + let mut events = std::collections::VecDeque::with_capacity(3); + + let delta_x = ns_event.deltaX() as f64; + if delta_x != 0.0 { + let motion_event = DeviceEvent::Motion { axis: 0, value: delta_x }; + let event = Event::DeviceEvent { device_id: DEVICE_ID, event: motion_event }; + events.push_back(event); + } + + let delta_y = ns_event.deltaY() as f64; + if delta_y != 0.0 { + let motion_event = DeviceEvent::Motion { axis: 1, value: delta_y }; + let event = Event::DeviceEvent { device_id: DEVICE_ID, event: motion_event }; + events.push_back(event); + } + + if delta_x != 0.0 || delta_y != 0.0 { + let motion_event = DeviceEvent::MouseMotion { delta: (delta_x, delta_y) }; + let event = Event::DeviceEvent { device_id: DEVICE_ID, event: motion_event }; + events.push_back(event); + } + + let event = events.pop_front(); + self.shared.pending_events.lock().unwrap().extend(events.into_iter()); + event + }, + + appkit::NSScrollWheel => { + // If none of the windows received the scroll, return `None`. + if maybe_window.is_none() { + return None; + } + + use events::MouseScrollDelta::{LineDelta, PixelDelta}; + let delta = if ns_event.hasPreciseScrollingDeltas() == cocoa::base::YES { + PixelDelta(( + ns_event.scrollingDeltaX() as f64, + ns_event.scrollingDeltaY() as f64, + ).into()) + } else { + // TODO: This is probably wrong + LineDelta( + ns_event.scrollingDeltaX() as f32, + ns_event.scrollingDeltaY() as f32, + ) + }; + let phase = match ns_event.phase() { + NSEventPhase::NSEventPhaseMayBegin | NSEventPhase::NSEventPhaseBegan => TouchPhase::Started, + NSEventPhase::NSEventPhaseEnded => TouchPhase::Ended, + _ => TouchPhase::Moved, + }; + self.shared.pending_events.lock().unwrap().push_back(Event::DeviceEvent { + device_id: DEVICE_ID, + event: DeviceEvent::MouseWheel { + delta: if ns_event.hasPreciseScrollingDeltas() == cocoa::base::YES { + PixelDelta(( + ns_event.scrollingDeltaX() as f64, + ns_event.scrollingDeltaY() as f64, + ).into()) + } else { + LineDelta( + ns_event.scrollingDeltaX() as f32, + ns_event.scrollingDeltaY() as f32, + ) + }, + } + }); + let window_event = WindowEvent::MouseWheel { device_id: DEVICE_ID, delta: delta, phase: phase, modifiers: event_mods(ns_event) }; + Some(into_event(window_event)) + }, + + appkit::NSEventTypePressure => { + let pressure = ns_event.pressure(); + let stage = ns_event.stage(); + let window_event = WindowEvent::TouchpadPressure { device_id: DEVICE_ID, pressure: pressure, stage: stage }; + Some(into_event(window_event)) + }, + + appkit::NSApplicationDefined => match ns_event.subtype() { + appkit::NSEventSubtype::NSApplicationActivatedEventType => { + Some(Event::Awakened) + }, + _ => None, + }, + + _ => None, + } + } + + pub fn create_proxy(&self) -> Proxy { + Proxy {} + } + +} + +impl Proxy { + pub fn wakeup(&self) -> Result<(), EventsLoopClosed> { + // Awaken the event loop by triggering `NSApplicationActivatedEventType`. + unsafe { + let pool = foundation::NSAutoreleasePool::new(cocoa::base::nil); + let event = + NSEvent::otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_( + cocoa::base::nil, + appkit::NSApplicationDefined, + foundation::NSPoint::new(0.0, 0.0), + appkit::NSEventModifierFlags::empty(), + 0.0, + 0, + cocoa::base::nil, + appkit::NSEventSubtype::NSApplicationActivatedEventType, + 0, + 0); + appkit::NSApp().postEvent_atStart_(event, cocoa::base::NO); + foundation::NSAutoreleasePool::drain(pool); + } + Ok(()) + } +} + +pub fn to_virtual_key_code(code: c_ushort) -> Option<events::VirtualKeyCode> { + Some(match code { + 0x00 => events::VirtualKeyCode::A, + 0x01 => events::VirtualKeyCode::S, + 0x02 => events::VirtualKeyCode::D, + 0x03 => events::VirtualKeyCode::F, + 0x04 => events::VirtualKeyCode::H, + 0x05 => events::VirtualKeyCode::G, + 0x06 => events::VirtualKeyCode::Z, + 0x07 => events::VirtualKeyCode::X, + 0x08 => events::VirtualKeyCode::C, + 0x09 => events::VirtualKeyCode::V, + //0x0a => World 1, + 0x0b => events::VirtualKeyCode::B, + 0x0c => events::VirtualKeyCode::Q, + 0x0d => events::VirtualKeyCode::W, + 0x0e => events::VirtualKeyCode::E, + 0x0f => events::VirtualKeyCode::R, + 0x10 => events::VirtualKeyCode::Y, + 0x11 => events::VirtualKeyCode::T, + 0x12 => events::VirtualKeyCode::Key1, + 0x13 => events::VirtualKeyCode::Key2, + 0x14 => events::VirtualKeyCode::Key3, + 0x15 => events::VirtualKeyCode::Key4, + 0x16 => events::VirtualKeyCode::Key6, + 0x17 => events::VirtualKeyCode::Key5, + 0x18 => events::VirtualKeyCode::Equals, + 0x19 => events::VirtualKeyCode::Key9, + 0x1a => events::VirtualKeyCode::Key7, + 0x1b => events::VirtualKeyCode::Minus, + 0x1c => events::VirtualKeyCode::Key8, + 0x1d => events::VirtualKeyCode::Key0, + 0x1e => events::VirtualKeyCode::RBracket, + 0x1f => events::VirtualKeyCode::O, + 0x20 => events::VirtualKeyCode::U, + 0x21 => events::VirtualKeyCode::LBracket, + 0x22 => events::VirtualKeyCode::I, + 0x23 => events::VirtualKeyCode::P, + 0x24 => events::VirtualKeyCode::Return, + 0x25 => events::VirtualKeyCode::L, + 0x26 => events::VirtualKeyCode::J, + 0x27 => events::VirtualKeyCode::Apostrophe, + 0x28 => events::VirtualKeyCode::K, + 0x29 => events::VirtualKeyCode::Semicolon, + 0x2a => events::VirtualKeyCode::Backslash, + 0x2b => events::VirtualKeyCode::Comma, + 0x2c => events::VirtualKeyCode::Slash, + 0x2d => events::VirtualKeyCode::N, + 0x2e => events::VirtualKeyCode::M, + 0x2f => events::VirtualKeyCode::Period, + 0x30 => events::VirtualKeyCode::Tab, + 0x31 => events::VirtualKeyCode::Space, + 0x32 => events::VirtualKeyCode::Grave, + 0x33 => events::VirtualKeyCode::Back, + //0x34 => unkown, + 0x35 => events::VirtualKeyCode::Escape, + 0x36 => events::VirtualKeyCode::LWin, + 0x37 => events::VirtualKeyCode::RWin, + 0x38 => events::VirtualKeyCode::LShift, + //0x39 => Caps lock, + 0x3a => events::VirtualKeyCode::LAlt, + 0x3b => events::VirtualKeyCode::LControl, + 0x3c => events::VirtualKeyCode::RShift, + 0x3d => events::VirtualKeyCode::RAlt, + 0x3e => events::VirtualKeyCode::RControl, + //0x3f => Fn key, + 0x40 => events::VirtualKeyCode::F17, + 0x41 => events::VirtualKeyCode::Decimal, + //0x42 -> unkown, + 0x43 => events::VirtualKeyCode::Multiply, + //0x44 => unkown, + 0x45 => events::VirtualKeyCode::Add, + //0x46 => unkown, + 0x47 => events::VirtualKeyCode::Numlock, + //0x48 => KeypadClear, + 0x49 => events::VirtualKeyCode::VolumeUp, + 0x4a => events::VirtualKeyCode::VolumeDown, + 0x4b => events::VirtualKeyCode::Divide, + 0x4c => events::VirtualKeyCode::NumpadEnter, + //0x4d => unkown, + 0x4e => events::VirtualKeyCode::Subtract, + 0x4f => events::VirtualKeyCode::F18, + 0x50 => events::VirtualKeyCode::F19, + 0x51 => events::VirtualKeyCode::NumpadEquals, + 0x52 => events::VirtualKeyCode::Numpad0, + 0x53 => events::VirtualKeyCode::Numpad1, + 0x54 => events::VirtualKeyCode::Numpad2, + 0x55 => events::VirtualKeyCode::Numpad3, + 0x56 => events::VirtualKeyCode::Numpad4, + 0x57 => events::VirtualKeyCode::Numpad5, + 0x58 => events::VirtualKeyCode::Numpad6, + 0x59 => events::VirtualKeyCode::Numpad7, + 0x5a => events::VirtualKeyCode::F20, + 0x5b => events::VirtualKeyCode::Numpad8, + 0x5c => events::VirtualKeyCode::Numpad9, + 0x5d => events::VirtualKeyCode::Yen, + //0x5e => JIS Ro, + //0x5f => unkown, + 0x60 => events::VirtualKeyCode::F5, + 0x61 => events::VirtualKeyCode::F6, + 0x62 => events::VirtualKeyCode::F7, + 0x63 => events::VirtualKeyCode::F3, + 0x64 => events::VirtualKeyCode::F8, + 0x65 => events::VirtualKeyCode::F9, + //0x66 => JIS Eisuu (macOS), + 0x67 => events::VirtualKeyCode::F11, + //0x68 => JIS Kana (macOS), + 0x69 => events::VirtualKeyCode::F13, + 0x6a => events::VirtualKeyCode::F16, + 0x6b => events::VirtualKeyCode::F14, + //0x6c => unkown, + 0x6d => events::VirtualKeyCode::F10, + //0x6e => unkown, + 0x6f => events::VirtualKeyCode::F12, + //0x70 => unkown, + 0x71 => events::VirtualKeyCode::F15, + 0x72 => events::VirtualKeyCode::Insert, + 0x73 => events::VirtualKeyCode::Home, + 0x74 => events::VirtualKeyCode::PageUp, + 0x75 => events::VirtualKeyCode::Delete, + 0x76 => events::VirtualKeyCode::F4, + 0x77 => events::VirtualKeyCode::End, + 0x78 => events::VirtualKeyCode::F2, + 0x79 => events::VirtualKeyCode::PageDown, + 0x7a => events::VirtualKeyCode::F1, + 0x7b => events::VirtualKeyCode::Left, + 0x7c => events::VirtualKeyCode::Right, + 0x7d => events::VirtualKeyCode::Down, + 0x7e => events::VirtualKeyCode::Up, + //0x7f => unkown, + + 0xa => events::VirtualKeyCode::Caret, + _ => return None, + }) +} + +pub fn check_additional_virtual_key_codes( + s: &Option<String> +) -> Option<events::VirtualKeyCode> { + if let &Some(ref s) = s { + if let Some(ch) = s.encode_utf16().next() { + return Some(match ch { + 0xf718 => events::VirtualKeyCode::F21, + 0xf719 => events::VirtualKeyCode::F22, + 0xf71a => events::VirtualKeyCode::F23, + 0xf71b => events::VirtualKeyCode::F24, + _ => return None, + }) + } + } + None +} + +pub fn event_mods(event: cocoa::base::id) -> ModifiersState { + let flags = unsafe { + NSEvent::modifierFlags(event) + }; + ModifiersState { + shift: flags.contains(NSEventModifierFlags::NSShiftKeyMask), + ctrl: flags.contains(NSEventModifierFlags::NSControlKeyMask), + alt: flags.contains(NSEventModifierFlags::NSAlternateKeyMask), + logo: flags.contains(NSEventModifierFlags::NSCommandKeyMask), + } +} + +unsafe fn modifier_event( + ns_event: cocoa::base::id, + keymask: NSEventModifierFlags, + was_key_pressed: bool, +) -> Option<WindowEvent> { + if !was_key_pressed && NSEvent::modifierFlags(ns_event).contains(keymask) + || was_key_pressed && !NSEvent::modifierFlags(ns_event).contains(keymask) { + let state = if was_key_pressed { + ElementState::Released + } else { + ElementState::Pressed + }; + let keycode = NSEvent::keyCode(ns_event); + let scancode = keycode as u32; + let virtual_keycode = to_virtual_key_code(keycode); + Some(WindowEvent::KeyboardInput { + device_id: DEVICE_ID, + input: KeyboardInput { + state, + scancode, + virtual_keycode, + modifiers: event_mods(ns_event), + }, + }) + } else { + None + } +} + +// Constant device ID, to be removed when this backend is updated to report real device IDs. +pub const DEVICE_ID: ::DeviceId = ::DeviceId(DeviceId); diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/ffi.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/ffi.rs new file mode 100644 index 0000000..31c9ed1 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/ffi.rs @@ -0,0 +1,107 @@ +// TODO: Upstream these + +#![allow(dead_code, non_snake_case, non_upper_case_globals)] + +use cocoa::base::id; +use cocoa::foundation::{NSInteger, NSUInteger}; +use objc; + +pub const NSNotFound: NSInteger = NSInteger::max_value(); + +#[repr(C)] +pub struct NSRange { + pub location: NSUInteger, + pub length: NSUInteger, +} + +impl NSRange { + #[inline] + pub fn new(location: NSUInteger, length: NSUInteger) -> NSRange { + NSRange { location, length } + } +} + +unsafe impl objc::Encode for NSRange { + fn encode() -> objc::Encoding { + let encoding = format!( + // TODO: Verify that this is correct + "{{NSRange={}{}}}", + NSUInteger::encode().as_str(), + NSUInteger::encode().as_str(), + ); + unsafe { objc::Encoding::from_str(&encoding) } + } +} + +pub trait NSMutableAttributedString: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSMutableAttributedString), alloc] + } + + unsafe fn init(self) -> id; // *mut NSMutableAttributedString + unsafe fn initWithString(self, string: id) -> id; + unsafe fn initWithAttributedString(self, string: id) -> id; + + unsafe fn string(self) -> id; // *mut NSString + unsafe fn mutableString(self) -> id; // *mut NSMutableString + unsafe fn length(self) -> NSUInteger; +} + +impl NSMutableAttributedString for id { + unsafe fn init(self) -> id { + msg_send![self, init] + } + + unsafe fn initWithString(self, string: id) -> id { + msg_send![self, initWithString:string] + } + + unsafe fn initWithAttributedString(self, string: id) -> id { + msg_send![self, initWithAttributedString:string] + } + + unsafe fn string(self) -> id { + msg_send![self, string] + } + + unsafe fn mutableString(self) -> id { + msg_send![self, mutableString] + } + + unsafe fn length(self) -> NSUInteger { + msg_send![self, length] + } +} + +pub const kCGBaseWindowLevelKey: NSInteger = 0; +pub const kCGMinimumWindowLevelKey: NSInteger = 1; +pub const kCGDesktopWindowLevelKey: NSInteger = 2; +pub const kCGBackstopMenuLevelKey: NSInteger = 3; +pub const kCGNormalWindowLevelKey: NSInteger = 4; +pub const kCGFloatingWindowLevelKey: NSInteger = 5; +pub const kCGTornOffMenuWindowLevelKey: NSInteger = 6; +pub const kCGDockWindowLevelKey: NSInteger = 7; +pub const kCGMainMenuWindowLevelKey: NSInteger = 8; +pub const kCGStatusWindowLevelKey: NSInteger = 9; +pub const kCGModalPanelWindowLevelKey: NSInteger = 10; +pub const kCGPopUpMenuWindowLevelKey: NSInteger = 11; +pub const kCGDraggingWindowLevelKey: NSInteger = 12; +pub const kCGScreenSaverWindowLevelKey: NSInteger = 13; +pub const kCGMaximumWindowLevelKey: NSInteger = 14; +pub const kCGOverlayWindowLevelKey: NSInteger = 15; +pub const kCGHelpWindowLevelKey: NSInteger = 16; +pub const kCGUtilityWindowLevelKey: NSInteger = 17; +pub const kCGDesktopIconWindowLevelKey: NSInteger = 18; +pub const kCGCursorWindowLevelKey: NSInteger = 19; +pub const kCGNumberOfWindowLevelKeys: NSInteger = 20; + +pub enum NSWindowLevel { + NSNormalWindowLevel = kCGBaseWindowLevelKey as _, + NSFloatingWindowLevel = kCGFloatingWindowLevelKey as _, + NSTornOffMenuWindowLevel = kCGTornOffMenuWindowLevelKey as _, + NSModalPanelWindowLevel = kCGModalPanelWindowLevelKey as _, + NSMainMenuWindowLevel = kCGMainMenuWindowLevelKey as _, + NSStatusWindowLevel = kCGStatusWindowLevelKey as _, + NSPopUpMenuWindowLevel = kCGPopUpMenuWindowLevelKey as _, + NSScreenSaverWindowLevel = kCGScreenSaverWindowLevelKey as _, +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/mod.rs new file mode 100644 index 0000000..1091648 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/mod.rs @@ -0,0 +1,51 @@ +#![cfg(target_os = "macos")] + +pub use self::events_loop::{EventsLoop, Proxy as EventsLoopProxy}; +pub use self::monitor::MonitorId; +pub use self::window::{Id as WindowId, PlatformSpecificWindowBuilderAttributes, Window2}; +use std::sync::Arc; + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct DeviceId; + +impl DeviceId { + pub unsafe fn dummy() -> Self { + DeviceId + } +} + +use {CreationError}; + +pub struct Window { + pub window: Arc<Window2>, +} + +impl ::std::ops::Deref for Window { + type Target = Window2; + #[inline] + fn deref(&self) -> &Window2 { + &*self.window + } +} + +impl Window { + + pub fn new(events_loop: &EventsLoop, + attributes: ::WindowAttributes, + pl_attribs: PlatformSpecificWindowBuilderAttributes) -> Result<Self, CreationError> + { + let weak_shared = Arc::downgrade(&events_loop.shared); + let window = Arc::new(try!(Window2::new(weak_shared, attributes, pl_attribs))); + let weak_window = Arc::downgrade(&window); + events_loop.shared.windows.lock().unwrap().push(weak_window); + Ok(Window { window: window }) + } + +} + +mod events_loop; +mod ffi; +mod monitor; +mod util; +mod view; +mod window; diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/monitor.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/monitor.rs new file mode 100644 index 0000000..c8786f9 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/monitor.rs @@ -0,0 +1,147 @@ +use std::collections::VecDeque; +use std::fmt; + +use cocoa::appkit::NSScreen; +use cocoa::base::{id, nil}; +use cocoa::foundation::{NSString, NSUInteger}; +use core_graphics::display::{CGDirectDisplayID, CGDisplay, CGDisplayBounds}; + +use {PhysicalPosition, PhysicalSize}; +use super::EventsLoop; +use super::window::{IdRef, Window2}; + +#[derive(Clone, PartialEq)] +pub struct MonitorId(CGDirectDisplayID); + +fn get_available_monitors() -> VecDeque<MonitorId> { + if let Ok(displays) = CGDisplay::active_displays() { + let mut monitors = VecDeque::with_capacity(displays.len()); + for d in displays { + monitors.push_back(MonitorId(d)); + } + monitors + } else { + VecDeque::with_capacity(0) + } +} + +pub fn get_primary_monitor() -> MonitorId { + let id = MonitorId(CGDisplay::main().id); + id +} + +impl EventsLoop { + #[inline] + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + get_available_monitors() + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + get_primary_monitor() + } + + pub fn make_monitor_from_display(id: CGDirectDisplayID) -> MonitorId { + let id = MonitorId(id); + id + } +} + +impl Window2 { + #[inline] + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + get_available_monitors() + } + + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + get_primary_monitor() + } +} + +impl fmt::Debug for MonitorId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[derive(Debug)] + struct MonitorId { + name: Option<String>, + native_identifier: u32, + dimensions: PhysicalSize, + position: PhysicalPosition, + hidpi_factor: f64, + } + + let monitor_id_proxy = MonitorId { + name: self.get_name(), + native_identifier: self.get_native_identifier(), + dimensions: self.get_dimensions(), + position: self.get_position(), + hidpi_factor: self.get_hidpi_factor(), + }; + + monitor_id_proxy.fmt(f) + } +} + +impl MonitorId { + pub fn get_name(&self) -> Option<String> { + let MonitorId(display_id) = *self; + let screen_num = CGDisplay::new(display_id).model_number(); + Some(format!("Monitor #{}", screen_num)) + } + + #[inline] + pub fn get_native_identifier(&self) -> u32 { + self.0 + } + + pub fn get_dimensions(&self) -> PhysicalSize { + let MonitorId(display_id) = *self; + let display = CGDisplay::new(display_id); + let height = display.pixels_high(); + let width = display.pixels_wide(); + PhysicalSize::from_logical( + (width as f64, height as f64), + self.get_hidpi_factor(), + ) + } + + #[inline] + pub fn get_position(&self) -> PhysicalPosition { + let bounds = unsafe { CGDisplayBounds(self.get_native_identifier()) }; + PhysicalPosition::from_logical( + (bounds.origin.x as f64, bounds.origin.y as f64), + self.get_hidpi_factor(), + ) + } + + pub fn get_hidpi_factor(&self) -> f64 { + let screen = match self.get_nsscreen() { + Some(screen) => screen, + None => return 1.0, // default to 1.0 when we can't find the screen + }; + unsafe { NSScreen::backingScaleFactor(screen) as f64 } + } + + pub(crate) fn get_nsscreen(&self) -> Option<id> { + unsafe { + let native_id = self.get_native_identifier(); + let screens = NSScreen::screens(nil); + let count: NSUInteger = msg_send![screens, count]; + let key = IdRef::new(NSString::alloc(nil).init_str("NSScreenNumber")); + let mut matching_screen: Option<id> = None; + for i in 0..count { + let screen = msg_send![screens, objectAtIndex: i as NSUInteger]; + let device_description = NSScreen::deviceDescription(screen); + let value: id = msg_send![device_description, objectForKey:*key]; + if value != nil { + let screen_number: NSUInteger = msg_send![value, unsignedIntegerValue]; + if screen_number as u32 == native_id { + matching_screen = Some(screen); + break; + } + } + } + matching_screen + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/util/cursor.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/util/cursor.rs new file mode 100644 index 0000000..e7815d7 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/util/cursor.rs @@ -0,0 +1,149 @@ +use cocoa::{ + appkit::NSImage, base::{id, nil, YES}, + foundation::{NSDictionary, NSPoint, NSString}, +}; +use objc::runtime::Sel; + +use super::IntoOption; +use MouseCursor; + +pub enum Cursor { + Native(&'static str), + Undocumented(&'static str), + WebKit(&'static str), +} + +impl From<MouseCursor> for Cursor { + fn from(cursor: MouseCursor) -> Self { + match cursor { + MouseCursor::Arrow | MouseCursor::Default => Cursor::Native("arrowCursor"), + MouseCursor::Hand => Cursor::Native("pointingHandCursor"), + MouseCursor::Grabbing | MouseCursor::Grab => Cursor::Native("closedHandCursor"), + MouseCursor::Text => Cursor::Native("IBeamCursor"), + MouseCursor::VerticalText => Cursor::Native("IBeamCursorForVerticalLayout"), + MouseCursor::Copy => Cursor::Native("dragCopyCursor"), + MouseCursor::Alias => Cursor::Native("dragLinkCursor"), + MouseCursor::NotAllowed | MouseCursor::NoDrop => Cursor::Native("operationNotAllowedCursor"), + MouseCursor::ContextMenu => Cursor::Native("contextualMenuCursor"), + MouseCursor::Crosshair => Cursor::Native("crosshairCursor"), + MouseCursor::EResize => Cursor::Native("resizeRightCursor"), + MouseCursor::NResize => Cursor::Native("resizeUpCursor"), + MouseCursor::WResize => Cursor::Native("resizeLeftCursor"), + MouseCursor::SResize => Cursor::Native("resizeDownCursor"), + MouseCursor::EwResize | MouseCursor::ColResize => Cursor::Native("resizeLeftRightCursor"), + MouseCursor::NsResize | MouseCursor::RowResize => Cursor::Native("resizeUpDownCursor"), + + // Undocumented cursors: https://stackoverflow.com/a/46635398/5435443 + MouseCursor::Help => Cursor::Undocumented("_helpCursor"), + MouseCursor::ZoomIn => Cursor::Undocumented("_zoomInCursor"), + MouseCursor::ZoomOut => Cursor::Undocumented("_zoomOutCursor"), + MouseCursor::NeResize => Cursor::Undocumented("_windowResizeNorthEastCursor"), + MouseCursor::NwResize => Cursor::Undocumented("_windowResizeNorthWestCursor"), + MouseCursor::SeResize => Cursor::Undocumented("_windowResizeSouthEastCursor"), + MouseCursor::SwResize => Cursor::Undocumented("_windowResizeSouthWestCursor"), + MouseCursor::NeswResize => Cursor::Undocumented("_windowResizeNorthEastSouthWestCursor"), + MouseCursor::NwseResize => Cursor::Undocumented("_windowResizeNorthWestSouthEastCursor"), + + // While these are available, the former just loads a white arrow, + // and the latter loads an ugly deflated beachball! + // MouseCursor::Move => Cursor::Undocumented("_moveCursor"), + // MouseCursor::Wait => Cursor::Undocumented("_waitCursor"), + + // An even more undocumented cursor... + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=522349 + // This is the wrong semantics for `Wait`, but it's the same as + // what's used in Safari and Chrome. + MouseCursor::Wait | MouseCursor::Progress => Cursor::Undocumented("busyButClickableCursor"), + + // For the rest, we can just snatch the cursors from WebKit... + // They fit the style of the native cursors, and will seem + // completely standard to macOS users. + // https://stackoverflow.com/a/21786835/5435443 + MouseCursor::Move | MouseCursor::AllScroll => Cursor::WebKit("move"), + MouseCursor::Cell => Cursor::WebKit("cell"), + } + } +} + +impl Default for Cursor { + fn default() -> Self { + Cursor::Native("arrowCursor") + } +} + +impl Cursor { + pub unsafe fn load(&self) -> id { + match self { + Cursor::Native(cursor_name) => { + let sel = Sel::register(cursor_name); + msg_send![class!(NSCursor), performSelector:sel] + }, + Cursor::Undocumented(cursor_name) => { + let class = class!(NSCursor); + let sel = Sel::register(cursor_name); + let sel = if msg_send![class, respondsToSelector:sel] { + sel + } else { + warn!("Cursor `{}` appears to be invalid", cursor_name); + sel!(arrowCursor) + }; + msg_send![class, performSelector:sel] + }, + Cursor::WebKit(cursor_name) => load_webkit_cursor(cursor_name) + .unwrap_or_else(|message| { + warn!("{}", message); + Self::default().load() + }), + } + } +} + +// Note that loading `busybutclickable` with this code won't animate the frames; +// instead you'll just get them all in a column. +unsafe fn load_webkit_cursor(cursor_name_str: &str) -> Result<id, String> { + static CURSOR_ROOT: &'static str = "/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Resources/cursors"; + let cursor_root = NSString::alloc(nil).init_str(CURSOR_ROOT); + let cursor_name = NSString::alloc(nil).init_str(cursor_name_str); + let cursor_pdf = NSString::alloc(nil).init_str("cursor.pdf"); + let cursor_plist = NSString::alloc(nil).init_str("info.plist"); + let key_x = NSString::alloc(nil).init_str("hotx"); + let key_y = NSString::alloc(nil).init_str("hoty"); + + let cursor_path: id = msg_send![cursor_root, + stringByAppendingPathComponent:cursor_name + ]; + let pdf_path: id = msg_send![cursor_path, + stringByAppendingPathComponent:cursor_pdf + ]; + let info_path: id = msg_send![cursor_path, + stringByAppendingPathComponent:cursor_plist + ]; + + let image = NSImage::alloc(nil) + .initByReferencingFile_(pdf_path) + // This will probably never be `None`, since images are loaded lazily... + .into_option() + // because of that, we need to check for validity. + .filter(|image| image.isValid() == YES) + .ok_or_else(|| + format!("Failed to read image for `{}` cursor", cursor_name_str) + )?; + let info = NSDictionary::dictionaryWithContentsOfFile_(nil, info_path) + .into_option() + .ok_or_else(|| + format!("Failed to read info for `{}` cursor", cursor_name_str) + )?; + let x = info.valueForKey_(key_x); + let y = info.valueForKey_(key_y); + let point = NSPoint::new( + msg_send![x, doubleValue], + msg_send![y, doubleValue], + ); + let cursor: id = msg_send![class!(NSCursor), alloc]; + let cursor: id = msg_send![cursor, initWithImage:image hotSpot:point]; + cursor + .into_option() + .ok_or_else(|| + format!("Failed to initialize `{}` cursor", cursor_name_str) + ) +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/util/into_option.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/util/into_option.rs new file mode 100644 index 0000000..4fd32e7 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/util/into_option.rs @@ -0,0 +1,14 @@ +use cocoa::base::{id, nil}; + +pub trait IntoOption: Sized { + fn into_option(self) -> Option<Self>; +} + +impl IntoOption for id { + fn into_option(self) -> Option<Self> { + match self != nil { + true => Some(self), + false => None, + } + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/util/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/util/mod.rs new file mode 100644 index 0000000..baa0e6e --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/util/mod.rs @@ -0,0 +1,63 @@ +mod cursor; +mod into_option; + +pub use self::{cursor::Cursor, into_option::IntoOption}; + +use cocoa::appkit::NSWindowStyleMask; +use cocoa::base::{id, nil}; +use cocoa::foundation::{NSRect, NSUInteger}; +use core_graphics::display::CGDisplay; +use objc::runtime::{Class, Object}; + +use platform::platform::ffi; +use platform::platform::window::IdRef; + +pub const EMPTY_RANGE: ffi::NSRange = ffi::NSRange { + location: ffi::NSNotFound as NSUInteger, + length: 0, +}; + +// For consistency with other platforms, this will... +// 1. translate the bottom-left window corner into the top-left window corner +// 2. translate the coordinate from a bottom-left origin coordinate system to a top-left one +pub fn bottom_left_to_top_left(rect: NSRect) -> f64 { + CGDisplay::main().pixels_high() as f64 - (rect.origin.y + rect.size.height) +} + +pub unsafe fn set_style_mask(window: id, view: id, mask: NSWindowStyleMask) { + use cocoa::appkit::NSWindow; + window.setStyleMask_(mask); + // If we don't do this, key handling will break. Therefore, never call `setStyleMask` directly! + window.makeFirstResponder_(view); +} + +pub unsafe fn toggle_style_mask(window: id, view: id, mask: NSWindowStyleMask, on: bool) { + use cocoa::appkit::NSWindow; + + let current_style_mask = window.styleMask(); + if on { + window.setStyleMask_(current_style_mask | mask); + } else { + window.setStyleMask_(current_style_mask & (!mask)); + } + + // If we don't do this, key handling will break. Therefore, never call `setStyleMask` directly! + window.makeFirstResponder_(view); +} + +pub unsafe fn superclass<'a>(this: &'a Object) -> &'a Class { + let superclass: id = msg_send![this, superclass]; + &*(superclass as *const _) +} + +pub unsafe fn create_input_context(view: id) -> IdRef { + let input_context: id = msg_send![class!(NSTextInputContext), alloc]; + let input_context: id = msg_send![input_context, initWithClient:view]; + IdRef::new(input_context) +} + +#[allow(dead_code)] +pub unsafe fn open_emoji_picker() { + let app: id = msg_send![class!(NSApplication), sharedApplication]; + let _: () = msg_send![app, orderFrontCharacterPalette:nil]; +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/view.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/view.rs new file mode 100644 index 0000000..97372d1 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/view.rs @@ -0,0 +1,648 @@ +// This is a pretty close port of the implementation in GLFW: +// https://github.com/glfw/glfw/blob/7ef34eb06de54dd9186d3d21a401b2ef819b59e7/src/cocoa_window.m + +use std::{slice, str}; +use std::boxed::Box; +use std::collections::VecDeque; +use std::os::raw::*; +use std::sync::{Arc, Mutex, Weak}; + +use cocoa::base::{id, nil}; +use cocoa::appkit::{NSEvent, NSView, NSWindow}; +use cocoa::foundation::{NSPoint, NSRect, NSSize, NSString, NSUInteger}; +use objc::declare::ClassDecl; +use objc::runtime::{Class, Object, Protocol, Sel, BOOL, YES}; + +use {ElementState, Event, KeyboardInput, MouseButton, WindowEvent, WindowId}; +use platform::platform::events_loop::{DEVICE_ID, event_mods, Shared, to_virtual_key_code, check_additional_virtual_key_codes}; +use platform::platform::util; +use platform::platform::ffi::*; +use platform::platform::window::{get_window_id, IdRef}; + +struct ViewState { + window: id, + shared: Weak<Shared>, + cursor: Arc<Mutex<util::Cursor>>, + ime_spot: Option<(f64, f64)>, + raw_characters: Option<String>, + is_key_down: bool, +} + +pub fn new_view(window: id, shared: Weak<Shared>) -> (IdRef, Weak<Mutex<util::Cursor>>) { + let cursor = Default::default(); + let cursor_access = Arc::downgrade(&cursor); + let state = ViewState { + window, + shared, + cursor, + ime_spot: None, + raw_characters: None, + is_key_down: false, + }; + unsafe { + // This is free'd in `dealloc` + let state_ptr = Box::into_raw(Box::new(state)) as *mut c_void; + let view: id = msg_send![VIEW_CLASS.0, alloc]; + (IdRef::new(msg_send![view, initWithWinit:state_ptr]), cursor_access) + } +} + +pub fn set_ime_spot(view: id, input_context: id, x: f64, y: f64) { + unsafe { + let state_ptr: *mut c_void = *(*view).get_mut_ivar("winitState"); + let state = &mut *(state_ptr as *mut ViewState); + let content_rect = NSWindow::contentRectForFrameRect_( + state.window, + NSWindow::frame(state.window), + ); + let base_x = content_rect.origin.x as f64; + let base_y = (content_rect.origin.y + content_rect.size.height) as f64; + state.ime_spot = Some((base_x + x, base_y - y)); + let _: () = msg_send![input_context, invalidateCharacterCoordinates]; + } +} + +struct ViewClass(*const Class); +unsafe impl Send for ViewClass {} +unsafe impl Sync for ViewClass {} + +lazy_static! { + static ref VIEW_CLASS: ViewClass = unsafe { + let superclass = class!(NSView); + let mut decl = ClassDecl::new("WinitView", superclass).unwrap(); + decl.add_method(sel!(dealloc), dealloc as extern fn(&Object, Sel)); + decl.add_method( + sel!(initWithWinit:), + init_with_winit as extern fn(&Object, Sel, *mut c_void) -> id, + ); + decl.add_method( + sel!(drawRect:), + draw_rect as extern fn(&Object, Sel, NSRect), + ); + decl.add_method( + sel!(resetCursorRects), + reset_cursor_rects as extern fn(&Object, Sel), + ); + decl.add_method(sel!(hasMarkedText), has_marked_text as extern fn(&Object, Sel) -> BOOL); + decl.add_method( + sel!(markedRange), + marked_range as extern fn(&Object, Sel) -> NSRange, + ); + decl.add_method(sel!(selectedRange), selected_range as extern fn(&Object, Sel) -> NSRange); + decl.add_method( + sel!(setMarkedText:selectedRange:replacementRange:), + set_marked_text as extern fn(&mut Object, Sel, id, NSRange, NSRange), + ); + decl.add_method(sel!(unmarkText), unmark_text as extern fn(&Object, Sel)); + decl.add_method( + sel!(validAttributesForMarkedText), + valid_attributes_for_marked_text as extern fn(&Object, Sel) -> id, + ); + decl.add_method( + sel!(attributedSubstringForProposedRange:actualRange:), + attributed_substring_for_proposed_range + as extern fn(&Object, Sel, NSRange, *mut c_void) -> id, + ); + decl.add_method( + sel!(insertText:replacementRange:), + insert_text as extern fn(&Object, Sel, id, NSRange), + ); + decl.add_method( + sel!(characterIndexForPoint:), + character_index_for_point as extern fn(&Object, Sel, NSPoint) -> NSUInteger, + ); + decl.add_method( + sel!(firstRectForCharacterRange:actualRange:), + first_rect_for_character_range + as extern fn(&Object, Sel, NSRange, *mut c_void) -> NSRect, + ); + decl.add_method( + sel!(doCommandBySelector:), + do_command_by_selector as extern fn(&Object, Sel, Sel), + ); + decl.add_method(sel!(keyDown:), key_down as extern fn(&Object, Sel, id)); + decl.add_method(sel!(keyUp:), key_up as extern fn(&Object, Sel, id)); + decl.add_method(sel!(insertTab:), insert_tab as extern fn(&Object, Sel, id)); + decl.add_method(sel!(insertBackTab:), insert_back_tab as extern fn(&Object, Sel, id)); + decl.add_method(sel!(mouseDown:), mouse_down as extern fn(&Object, Sel, id)); + decl.add_method(sel!(mouseUp:), mouse_up as extern fn(&Object, Sel, id)); + decl.add_method(sel!(rightMouseDown:), right_mouse_down as extern fn(&Object, Sel, id)); + decl.add_method(sel!(rightMouseUp:), right_mouse_up as extern fn(&Object, Sel, id)); + decl.add_method(sel!(otherMouseDown:), other_mouse_down as extern fn(&Object, Sel, id)); + decl.add_method(sel!(otherMouseUp:), other_mouse_up as extern fn(&Object, Sel, id)); + decl.add_method(sel!(mouseMoved:), mouse_moved as extern fn(&Object, Sel, id)); + decl.add_method(sel!(mouseDragged:), mouse_dragged as extern fn(&Object, Sel, id)); + decl.add_method(sel!(rightMouseDragged:), right_mouse_dragged as extern fn(&Object, Sel, id)); + decl.add_method(sel!(otherMouseDragged:), other_mouse_dragged as extern fn(&Object, Sel, id)); + decl.add_method(sel!(_wantsKeyDownForEvent:), wants_key_down_for_event as extern fn(&Object, Sel, id) -> BOOL); + decl.add_ivar::<*mut c_void>("winitState"); + decl.add_ivar::<id>("markedText"); + let protocol = Protocol::get("NSTextInputClient").unwrap(); + decl.add_protocol(&protocol); + ViewClass(decl.register()) + }; +} + +extern fn dealloc(this: &Object, _sel: Sel) { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let marked_text: id = *this.get_ivar("markedText"); + let _: () = msg_send![marked_text, release]; + Box::from_raw(state as *mut ViewState); + } +} + +extern fn init_with_winit(this: &Object, _sel: Sel, state: *mut c_void) -> id { + unsafe { + let this: id = msg_send![this, init]; + if this != nil { + (*this).set_ivar("winitState", state); + let marked_text = <id as NSMutableAttributedString>::init( + NSMutableAttributedString::alloc(nil), + ); + (*this).set_ivar("markedText", marked_text); + } + this + } +} + +extern fn draw_rect(this: &Object, _sel: Sel, rect: NSRect) { + unsafe { + let state_ptr: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state_ptr as *mut ViewState); + + if let Some(shared) = state.shared.upgrade() { + let window_event = Event::WindowEvent { + window_id: WindowId(get_window_id(state.window)), + event: WindowEvent::Refresh, + }; + shared.pending_events + .lock() + .unwrap() + .push_back(window_event); + } + + let superclass = util::superclass(this); + let () = msg_send![super(this, superclass), drawRect:rect]; + } +} + +extern fn reset_cursor_rects(this: &Object, _sel: Sel) { + unsafe { + let state_ptr: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state_ptr as *mut ViewState); + + let bounds: NSRect = msg_send![this, bounds]; + let cursor = state.cursor.lock().unwrap().load(); + let _: () = msg_send![this, + addCursorRect:bounds + cursor:cursor + ]; + } +} + +extern fn has_marked_text(this: &Object, _sel: Sel) -> BOOL { + //println!("hasMarkedText"); + unsafe { + let marked_text: id = *this.get_ivar("markedText"); + (marked_text.length() > 0) as i8 + } +} + +extern fn marked_range(this: &Object, _sel: Sel) -> NSRange { + //println!("markedRange"); + unsafe { + let marked_text: id = *this.get_ivar("markedText"); + let length = marked_text.length(); + if length > 0 { + NSRange::new(0, length - 1) + } else { + util::EMPTY_RANGE + } + } +} + +extern fn selected_range(_this: &Object, _sel: Sel) -> NSRange { + //println!("selectedRange"); + util::EMPTY_RANGE +} + +extern fn set_marked_text( + this: &mut Object, + _sel: Sel, + string: id, + _selected_range: NSRange, + _replacement_range: NSRange, +) { + //println!("setMarkedText"); + unsafe { + let marked_text_ref: &mut id = this.get_mut_ivar("markedText"); + let _: () = msg_send![(*marked_text_ref), release]; + let marked_text = NSMutableAttributedString::alloc(nil); + let has_attr = msg_send![string, isKindOfClass:class!(NSAttributedString)]; + if has_attr { + marked_text.initWithAttributedString(string); + } else { + marked_text.initWithString(string); + }; + *marked_text_ref = marked_text; + } +} + +extern fn unmark_text(this: &Object, _sel: Sel) { + //println!("unmarkText"); + unsafe { + let marked_text: id = *this.get_ivar("markedText"); + let mutable_string = marked_text.mutableString(); + let _: () = msg_send![mutable_string, setString:""]; + let input_context: id = msg_send![this, inputContext]; + let _: () = msg_send![input_context, discardMarkedText]; + } +} + +extern fn valid_attributes_for_marked_text(_this: &Object, _sel: Sel) -> id { + //println!("validAttributesForMarkedText"); + unsafe { msg_send![class!(NSArray), array] } +} + +extern fn attributed_substring_for_proposed_range( + _this: &Object, + _sel: Sel, + _range: NSRange, + _actual_range: *mut c_void, // *mut NSRange +) -> id { + //println!("attributedSubstringForProposedRange"); + nil +} + +extern fn character_index_for_point(_this: &Object, _sel: Sel, _point: NSPoint) -> NSUInteger { + //println!("characterIndexForPoint"); + 0 +} + +extern fn first_rect_for_character_range( + this: &Object, + _sel: Sel, + _range: NSRange, + _actual_range: *mut c_void, // *mut NSRange +) -> NSRect { + //println!("firstRectForCharacterRange"); + unsafe { + let state_ptr: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state_ptr as *mut ViewState); + let (x, y) = state.ime_spot.unwrap_or_else(|| { + let content_rect = NSWindow::contentRectForFrameRect_( + state.window, + NSWindow::frame(state.window), + ); + let x = content_rect.origin.x; + let y = util::bottom_left_to_top_left(content_rect); + (x, y) + }); + + NSRect::new( + NSPoint::new(x as _, y as _), + NSSize::new(0.0, 0.0), + ) + } +} + +extern fn insert_text(this: &Object, _sel: Sel, string: id, _replacement_range: NSRange) { + //println!("insertText"); + unsafe { + let state_ptr: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state_ptr as *mut ViewState); + + let has_attr = msg_send![string, isKindOfClass:class!(NSAttributedString)]; + let characters = if has_attr { + // This is a *mut NSAttributedString + msg_send![string, string] + } else { + // This is already a *mut NSString + string + }; + + let slice = slice::from_raw_parts( + characters.UTF8String() as *const c_uchar, + characters.len(), + ); + let string = str::from_utf8_unchecked(slice); + state.is_key_down = true; + + // We don't need this now, but it's here if that changes. + //let event: id = msg_send![class!(NSApp), currentEvent]; + + let mut events = VecDeque::with_capacity(characters.len()); + for character in string.chars() { + events.push_back(Event::WindowEvent { + window_id: WindowId(get_window_id(state.window)), + event: WindowEvent::ReceivedCharacter(character), + }); + } + + if let Some(shared) = state.shared.upgrade() { + shared.pending_events + .lock() + .unwrap() + .append(&mut events); + } + } +} + +extern fn do_command_by_selector(this: &Object, _sel: Sel, command: Sel) { + //println!("doCommandBySelector"); + // Basically, we're sent this message whenever a keyboard event that doesn't generate a "human readable" character + // happens, i.e. newlines, tabs, and Ctrl+C. + unsafe { + let state_ptr: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state_ptr as *mut ViewState); + + let shared = if let Some(shared) = state.shared.upgrade() { + shared + } else { + return; + }; + + let mut events = VecDeque::with_capacity(1); + if command == sel!(insertNewline:) { + // The `else` condition would emit the same character, but I'm keeping this here both... + // 1) as a reminder for how `doCommandBySelector` works + // 2) to make our use of carriage return explicit + events.push_back(Event::WindowEvent { + window_id: WindowId(get_window_id(state.window)), + event: WindowEvent::ReceivedCharacter('\r'), + }); + } else { + let raw_characters = state.raw_characters.take(); + if let Some(raw_characters) = raw_characters { + for character in raw_characters.chars() { + events.push_back(Event::WindowEvent { + window_id: WindowId(get_window_id(state.window)), + event: WindowEvent::ReceivedCharacter(character), + }); + } + } + }; + + shared.pending_events + .lock() + .unwrap() + .append(&mut events); + } +} + +fn get_characters(event: id) -> Option<String> { + unsafe { + let characters: id = msg_send![event, characters]; + let slice = slice::from_raw_parts( + characters.UTF8String() as *const c_uchar, + characters.len(), + ); + let string = str::from_utf8_unchecked(slice); + Some(string.to_owned()) + } +} + +extern fn key_down(this: &Object, _sel: Sel, event: id) { + //println!("keyDown"); + unsafe { + let state_ptr: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state_ptr as *mut ViewState); + let window_id = WindowId(get_window_id(state.window)); + + state.raw_characters = get_characters(event); + + let keycode: c_ushort = msg_send![event, keyCode]; + // We are checking here for F21-F24 keys, since their keycode + // can vary, but we know that they are encoded + // in characters property. + let virtual_keycode = to_virtual_key_code(keycode) + .or_else(|| { + check_additional_virtual_key_codes(&state.raw_characters) + }); + let scancode = keycode as u32; + let is_repeat = msg_send![event, isARepeat]; + + let window_event = Event::WindowEvent { + window_id, + event: WindowEvent::KeyboardInput { + device_id: DEVICE_ID, + input: KeyboardInput { + state: ElementState::Pressed, + scancode, + virtual_keycode, + modifiers: event_mods(event), + }, + }, + }; + + let characters: id = msg_send![event, characters]; + let slice = slice::from_raw_parts( + characters.UTF8String() as *const c_uchar, + characters.len(), + ); + let string = str::from_utf8_unchecked(slice); + + state.raw_characters = { + Some(string.to_owned()) + }; + + if let Some(shared) = state.shared.upgrade() { + shared.pending_events + .lock() + .unwrap() + .push_back(window_event); + // Emit `ReceivedCharacter` for key repeats + if is_repeat && state.is_key_down{ + for character in string.chars() { + let window_event = Event::WindowEvent { + window_id, + event: WindowEvent::ReceivedCharacter(character), + }; + shared.pending_events + .lock() + .unwrap() + .push_back(window_event); + } + } else { + // Some keys (and only *some*, with no known reason) don't trigger `insertText`, while others do... + // So, we don't give repeats the opportunity to trigger that, since otherwise our hack will cause some + // keys to generate twice as many characters. + let array: id = msg_send![class!(NSArray), arrayWithObject:event]; + let (): _ = msg_send![this, interpretKeyEvents:array]; + } + } + } +} + +extern fn key_up(this: &Object, _sel: Sel, event: id) { + //println!("keyUp"); + unsafe { + let state_ptr: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state_ptr as *mut ViewState); + + state.is_key_down = false; + + // We need characters here to check for additional keys such as + // F21-F24. + let characters = get_characters(event); + + let keycode: c_ushort = msg_send![event, keyCode]; + let virtual_keycode = to_virtual_key_code(keycode) + .or_else(|| { + check_additional_virtual_key_codes(&characters) + }); + let scancode = keycode as u32; + let window_event = Event::WindowEvent { + window_id: WindowId(get_window_id(state.window)), + event: WindowEvent::KeyboardInput { + device_id: DEVICE_ID, + input: KeyboardInput { + state: ElementState::Released, + scancode, + virtual_keycode, + modifiers: event_mods(event), + }, + }, + }; + + if let Some(shared) = state.shared.upgrade() { + shared.pending_events + .lock() + .unwrap() + .push_back(window_event); + } + } +} + +extern fn insert_tab(this: &Object, _sel: Sel, _sender: id) { + unsafe { + let window: id = msg_send![this, window]; + let first_responder: id = msg_send![window, firstResponder]; + let this_ptr = this as *const _ as *mut _; + if first_responder == this_ptr { + let (): _ = msg_send![window, selectNextKeyView:this]; + } + } +} + +extern fn insert_back_tab(this: &Object, _sel: Sel, _sender: id) { + unsafe { + let window: id = msg_send![this, window]; + let first_responder: id = msg_send![window, firstResponder]; + let this_ptr = this as *const _ as *mut _; + if first_responder == this_ptr { + let (): _ = msg_send![window, selectPreviousKeyView:this]; + } + } +} + +fn mouse_click(this: &Object, event: id, button: MouseButton, button_state: ElementState) { + unsafe { + let state_ptr: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state_ptr as *mut ViewState); + + let window_event = Event::WindowEvent { + window_id: WindowId(get_window_id(state.window)), + event: WindowEvent::MouseInput { + device_id: DEVICE_ID, + state: button_state, + button, + modifiers: event_mods(event), + }, + }; + + if let Some(shared) = state.shared.upgrade() { + shared.pending_events + .lock() + .unwrap() + .push_back(window_event); + } + } +} + +extern fn mouse_down(this: &Object, _sel: Sel, event: id) { + mouse_click(this, event, MouseButton::Left, ElementState::Pressed); +} + +extern fn mouse_up(this: &Object, _sel: Sel, event: id) { + mouse_click(this, event, MouseButton::Left, ElementState::Released); +} + +extern fn right_mouse_down(this: &Object, _sel: Sel, event: id) { + mouse_click(this, event, MouseButton::Right, ElementState::Pressed); +} + +extern fn right_mouse_up(this: &Object, _sel: Sel, event: id) { + mouse_click(this, event, MouseButton::Right, ElementState::Released); +} + +extern fn other_mouse_down(this: &Object, _sel: Sel, event: id) { + mouse_click(this, event, MouseButton::Middle, ElementState::Pressed); +} + +extern fn other_mouse_up(this: &Object, _sel: Sel, event: id) { + mouse_click(this, event, MouseButton::Middle, ElementState::Released); +} + +fn mouse_motion(this: &Object, event: id) { + unsafe { + let state_ptr: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state_ptr as *mut ViewState); + + // We have to do this to have access to the `NSView` trait... + let view: id = this as *const _ as *mut _; + + let window_point = event.locationInWindow(); + let view_point = view.convertPoint_fromView_(window_point, nil); + let view_rect = NSView::frame(view); + + if view_point.x.is_sign_negative() + || view_point.y.is_sign_negative() + || view_point.x > view_rect.size.width + || view_point.y > view_rect.size.height { + // Point is outside of the client area (view) + return; + } + + let x = view_point.x as f64; + let y = view_rect.size.height as f64 - view_point.y as f64; + + let window_event = Event::WindowEvent { + window_id: WindowId(get_window_id(state.window)), + event: WindowEvent::CursorMoved { + device_id: DEVICE_ID, + position: (x, y).into(), + modifiers: event_mods(event), + }, + }; + + if let Some(shared) = state.shared.upgrade() { + shared.pending_events + .lock() + .unwrap() + .push_back(window_event); + } + } +} + +extern fn mouse_moved(this: &Object, _sel: Sel, event: id) { + mouse_motion(this, event); +} + +extern fn mouse_dragged(this: &Object, _sel: Sel, event: id) { + mouse_motion(this, event); +} + +extern fn right_mouse_dragged(this: &Object, _sel: Sel, event: id) { + mouse_motion(this, event); +} + +extern fn other_mouse_dragged(this: &Object, _sel: Sel, event: id) { + mouse_motion(this, event); +} + +// https://github.com/chromium/chromium/blob/a86a8a6bcfa438fa3ac2eba6f02b3ad1f8e0756f/ui/views/cocoa/bridged_content_view.mm#L816 +extern fn wants_key_down_for_event(_this: &Object, _se: Sel, _event: id) -> BOOL { + YES +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/window.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/window.rs new file mode 100644 index 0000000..4fc2732 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/macos/window.rs @@ -0,0 +1,1362 @@ +use std; +use std::cell::{Cell, RefCell}; +use std::f64; +use std::ops::Deref; +use std::os::raw::c_void; +use std::sync::{Mutex, Weak}; +use std::sync::atomic::{Ordering, AtomicBool}; + +use cocoa::appkit::{ + self, + CGFloat, + NSApp, + NSApplication, + NSColor, + NSRequestUserAttentionType, + NSScreen, + NSView, + NSWindow, + NSWindowButton, + NSWindowStyleMask, + NSApplicationActivationPolicy, + NSApplicationPresentationOptions, +}; +use cocoa::base::{id, nil}; +use cocoa::foundation::{NSAutoreleasePool, NSDictionary, NSPoint, NSRect, NSSize, NSString}; + +use core_graphics::display::CGDisplay; + +use objc; +use objc::runtime::{Class, Object, Sel, BOOL, YES, NO}; +use objc::declare::ClassDecl; + +use { + CreationError, + Event, + LogicalPosition, + LogicalSize, + MouseCursor, + WindowAttributes, + WindowEvent, + WindowId, +}; +use CreationError::OsError; +use os::macos::{ActivationPolicy, WindowExt}; +use platform::platform::{ffi, util}; +use platform::platform::events_loop::{EventsLoop, Shared}; +use platform::platform::view::{new_view, set_ime_spot}; +use window::MonitorId as RootMonitorId; + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct Id(pub usize); + +impl Id { + pub unsafe fn dummy() -> Self { + Id(0) + } +} + +// TODO: It's possible for delegate methods to be called asynchronously, causing data races / `RefCell` panics. +pub struct DelegateState { + view: IdRef, + window: IdRef, + shared: Weak<Shared>, + + win_attribs: RefCell<WindowAttributes>, + standard_frame: Cell<Option<NSRect>>, + is_simple_fullscreen: Cell<bool>, + save_style_mask: Cell<Option<NSWindowStyleMask>>, + save_presentation_opts: Cell<Option<NSApplicationPresentationOptions>>, + + // This is set when WindowBuilder::with_fullscreen was set, + // see comments of `window_did_fail_to_enter_fullscreen` + handle_with_fullscreen: bool, + + // During `windowDidResize`, we use this to only send Moved if the position changed. + previous_position: Option<(f64, f64)>, + + // Used to prevent redundant events. + previous_dpi_factor: f64, +} + +impl DelegateState { + fn is_zoomed(&self) -> bool { + unsafe { + // Because isZoomed do not work in Borderless mode, we set it + // resizable temporality + let curr_mask = self.window.styleMask(); + + let required = NSWindowStyleMask::NSTitledWindowMask | NSWindowStyleMask::NSResizableWindowMask; + let needs_temp_mask = !curr_mask.contains(required); + if needs_temp_mask { + util::set_style_mask(*self.window, *self.view, required); + } + + let is_zoomed: BOOL = msg_send![*self.window, isZoomed]; + + // Roll back temp styles + if needs_temp_mask { + util::set_style_mask(*self.window, *self.view, curr_mask); + } + + is_zoomed != 0 + } + } + + unsafe fn saved_style_mask(&self, resizable: bool) -> NSWindowStyleMask { + let base_mask = self.save_style_mask + .take() + .unwrap_or_else(|| self.window.styleMask()); + if resizable { + base_mask | NSWindowStyleMask::NSResizableWindowMask + } else { + base_mask & !NSWindowStyleMask::NSResizableWindowMask + } + } + + fn saved_standard_frame(&self) -> NSRect { + self.standard_frame.get().unwrap_or_else(|| NSRect::new( + NSPoint::new(50.0, 50.0), + NSSize::new(800.0, 600.0), + )) + } + + fn restore_state_from_fullscreen(&mut self) { + let maximized = unsafe { + let mut win_attribs = self.win_attribs.borrow_mut(); + win_attribs.fullscreen = None; + + let mask = self.saved_style_mask(win_attribs.resizable); + util::set_style_mask(*self.window, *self.view, mask); + + win_attribs.maximized + }; + + self.perform_maximized(maximized); + } + + fn perform_maximized(&self, maximized: bool) { + let is_zoomed = self.is_zoomed(); + + if is_zoomed == maximized { + return; + } + + // Save the standard frame sized if it is not zoomed + if !is_zoomed { + unsafe { + self.standard_frame.set(Some(NSWindow::frame(*self.window))); + } + } + + let mut win_attribs = self.win_attribs.borrow_mut(); + win_attribs.maximized = maximized; + + let curr_mask = unsafe { self.window.styleMask() }; + if win_attribs.fullscreen.is_some() { + // Handle it in window_did_exit_fullscreen + return; + } else if curr_mask.contains(NSWindowStyleMask::NSResizableWindowMask) { + // Just use the native zoom if resizable + unsafe { + self.window.zoom_(nil); + } + } else { + // if it's not resizable, we set the frame directly + unsafe { + let new_rect = if maximized { + let screen = NSScreen::mainScreen(nil); + NSScreen::visibleFrame(screen) + } else { + self.saved_standard_frame() + }; + + self.window.setFrame_display_(new_rect, 0); + } + } + } +} + +pub struct WindowDelegate { + state: Box<DelegateState>, + _this: IdRef, +} + +impl WindowDelegate { + // Emits an event via the `EventsLoop`'s callback or stores it in the pending queue. + pub fn emit_event(state: &mut DelegateState, window_event: WindowEvent) { + let window_id = get_window_id(*state.window); + let event = Event::WindowEvent { + window_id: WindowId(window_id), + event: window_event, + }; + if let Some(shared) = state.shared.upgrade() { + shared.call_user_callback_with_event_or_store_in_pending(event); + } + } + + pub fn emit_resize_event(state: &mut DelegateState) { + let rect = unsafe { NSView::frame(*state.view) }; + let size = LogicalSize::new(rect.size.width as f64, rect.size.height as f64); + WindowDelegate::emit_event(state, WindowEvent::Resized(size)); + } + + pub fn emit_move_event(state: &mut DelegateState) { + let rect = unsafe { NSWindow::frame(*state.window) }; + let x = rect.origin.x as f64; + let y = util::bottom_left_to_top_left(rect); + let moved = state.previous_position != Some((x, y)); + if moved { + state.previous_position = Some((x, y)); + WindowDelegate::emit_event(state, WindowEvent::Moved((x, y).into())); + } + } + + /// Get the delegate class, initiailizing it neccessary + fn class() -> *const Class { + use std::os::raw::c_void; + + extern fn window_should_close(this: &Object, _: Sel, _: id) -> BOOL { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + WindowDelegate::emit_event(state, WindowEvent::CloseRequested); + } + NO + } + + extern fn window_will_close(this: &Object, _: Sel, _: id) { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + + WindowDelegate::emit_event(state, WindowEvent::Destroyed); + + // Remove the window from the shared state. + if let Some(shared) = state.shared.upgrade() { + let window_id = get_window_id(*state.window); + shared.find_and_remove_window(window_id); + } + } + } + + extern fn window_did_resize(this: &Object, _: Sel, _: id) { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + WindowDelegate::emit_resize_event(state); + WindowDelegate::emit_move_event(state); + } + } + + // This won't be triggered if the move was part of a resize. + extern fn window_did_move(this: &Object, _: Sel, _: id) { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + WindowDelegate::emit_move_event(state); + } + } + + extern fn window_did_change_screen(this: &Object, _: Sel, _: id) { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + let dpi_factor = NSWindow::backingScaleFactor(*state.window) as f64; + if state.previous_dpi_factor != dpi_factor { + state.previous_dpi_factor = dpi_factor; + WindowDelegate::emit_event(state, WindowEvent::HiDpiFactorChanged(dpi_factor)); + WindowDelegate::emit_resize_event(state); + } + } + } + + // This will always be called before `window_did_change_screen`. + extern fn window_did_change_backing_properties(this: &Object, _:Sel, _:id) { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + let dpi_factor = NSWindow::backingScaleFactor(*state.window) as f64; + if state.previous_dpi_factor != dpi_factor { + state.previous_dpi_factor = dpi_factor; + WindowDelegate::emit_event(state, WindowEvent::HiDpiFactorChanged(dpi_factor)); + WindowDelegate::emit_resize_event(state); + } + } + } + + extern fn window_did_become_key(this: &Object, _: Sel, _: id) { + unsafe { + // TODO: center the cursor if the window had mouse grab when it + // lost focus + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + WindowDelegate::emit_event(state, WindowEvent::Focused(true)); + } + } + + extern fn window_did_resign_key(this: &Object, _: Sel, _: id) { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + WindowDelegate::emit_event(state, WindowEvent::Focused(false)); + } + } + + /// Invoked when the dragged image enters destination bounds or frame + extern fn dragging_entered(this: &Object, _: Sel, sender: id) -> BOOL { + use cocoa::appkit::NSPasteboard; + use cocoa::foundation::NSFastEnumeration; + use std::path::PathBuf; + + let pb: id = unsafe { msg_send![sender, draggingPasteboard] }; + let filenames = unsafe { NSPasteboard::propertyListForType(pb, appkit::NSFilenamesPboardType) }; + + for file in unsafe { filenames.iter() } { + use cocoa::foundation::NSString; + use std::ffi::CStr; + + unsafe { + let f = NSString::UTF8String(file); + let path = CStr::from_ptr(f).to_string_lossy().into_owned(); + + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + WindowDelegate::emit_event(state, WindowEvent::HoveredFile(PathBuf::from(path))); + } + }; + + YES + } + + /// Invoked when the image is released + extern fn prepare_for_drag_operation(_: &Object, _: Sel, _: id) -> BOOL { + YES + } + + /// Invoked after the released image has been removed from the screen + extern fn perform_drag_operation(this: &Object, _: Sel, sender: id) -> BOOL { + use cocoa::appkit::NSPasteboard; + use cocoa::foundation::NSFastEnumeration; + use std::path::PathBuf; + + let pb: id = unsafe { msg_send![sender, draggingPasteboard] }; + let filenames = unsafe { NSPasteboard::propertyListForType(pb, appkit::NSFilenamesPboardType) }; + + for file in unsafe { filenames.iter() } { + use cocoa::foundation::NSString; + use std::ffi::CStr; + + unsafe { + let f = NSString::UTF8String(file); + let path = CStr::from_ptr(f).to_string_lossy().into_owned(); + + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + WindowDelegate::emit_event(state, WindowEvent::DroppedFile(PathBuf::from(path))); + } + }; + + YES + } + + /// Invoked when the dragging operation is complete + extern fn conclude_drag_operation(_: &Object, _: Sel, _: id) {} + + /// Invoked when the dragging operation is cancelled + extern fn dragging_exited(this: &Object, _: Sel, _: id) { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + WindowDelegate::emit_event(state, WindowEvent::HoveredFileCancelled); + } + } + + /// Invoked when entered fullscreen + extern fn window_did_enter_fullscreen(this: &Object, _: Sel, _: id){ + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + state.win_attribs.borrow_mut().fullscreen = Some(get_current_monitor(*state.window)); + + state.handle_with_fullscreen = false; + } + } + + /// Invoked when before enter fullscreen + extern fn window_will_enter_fullscreen(this: &Object, _: Sel, _: id) { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + let is_zoomed = state.is_zoomed(); + + state.win_attribs.borrow_mut().maximized = is_zoomed; + } + } + + /// Invoked when exited fullscreen + extern fn window_did_exit_fullscreen(this: &Object, _: Sel, _: id){ + let state = unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + &mut *(state as *mut DelegateState) + }; + + state.restore_state_from_fullscreen(); + } + + /// Invoked when fail to enter fullscreen + /// + /// When this window launch from a fullscreen app (e.g. launch from VS Code + /// terminal), it creates a new virtual destkop and a transition animation. + /// This animation takes one second and cannot be disable without + /// elevated privileges. In this animation time, all toggleFullscreen events + /// will be failed. In this implementation, we will try again by using + /// performSelector:withObject:afterDelay: until window_did_enter_fullscreen. + /// It should be fine as we only do this at initialzation (i.e with_fullscreen + /// was set). + /// + /// From Apple doc: + /// In some cases, the transition to enter full-screen mode can fail, + /// due to being in the midst of handling some other animation or user gesture. + /// This method indicates that there was an error, and you should clean up any + /// work you may have done to prepare to enter full-screen mode. + extern fn window_did_fail_to_enter_fullscreen(this: &Object, _: Sel, _: id) { + unsafe { + let state: *mut c_void = *this.get_ivar("winitState"); + let state = &mut *(state as *mut DelegateState); + + if state.handle_with_fullscreen { + let _: () = msg_send![*state.window, + performSelector:sel!(toggleFullScreen:) + withObject:nil + afterDelay: 0.5 + ]; + } else { + state.restore_state_from_fullscreen(); + } + } + } + + static mut DELEGATE_CLASS: *const Class = 0 as *const Class; + static INIT: std::sync::Once = std::sync::ONCE_INIT; + + INIT.call_once(|| unsafe { + // Create new NSWindowDelegate + let superclass = class!(NSObject); + let mut decl = ClassDecl::new("WinitWindowDelegate", superclass).unwrap(); + + // Add callback methods + decl.add_method(sel!(windowShouldClose:), + window_should_close as extern fn(&Object, Sel, id) -> BOOL); + decl.add_method(sel!(windowWillClose:), + window_will_close as extern fn(&Object, Sel, id)); + decl.add_method(sel!(windowDidResize:), + window_did_resize as extern fn(&Object, Sel, id)); + decl.add_method(sel!(windowDidMove:), + window_did_move as extern fn(&Object, Sel, id)); + decl.add_method(sel!(windowDidChangeScreen:), + window_did_change_screen as extern fn(&Object, Sel, id)); + decl.add_method(sel!(windowDidChangeBackingProperties:), + window_did_change_backing_properties as extern fn(&Object, Sel, id)); + decl.add_method(sel!(windowDidBecomeKey:), + window_did_become_key as extern fn(&Object, Sel, id)); + decl.add_method(sel!(windowDidResignKey:), + window_did_resign_key as extern fn(&Object, Sel, id)); + + // callbacks for drag and drop events + decl.add_method(sel!(draggingEntered:), + dragging_entered as extern fn(&Object, Sel, id) -> BOOL); + decl.add_method(sel!(prepareForDragOperation:), + prepare_for_drag_operation as extern fn(&Object, Sel, id) -> BOOL); + decl.add_method(sel!(performDragOperation:), + perform_drag_operation as extern fn(&Object, Sel, id) -> BOOL); + decl.add_method(sel!(concludeDragOperation:), + conclude_drag_operation as extern fn(&Object, Sel, id)); + decl.add_method(sel!(draggingExited:), + dragging_exited as extern fn(&Object, Sel, id)); + + // callbacks for fullscreen events + decl.add_method(sel!(windowDidEnterFullScreen:), + window_did_enter_fullscreen as extern fn(&Object, Sel, id)); + decl.add_method(sel!(windowWillEnterFullScreen:), + window_will_enter_fullscreen as extern fn(&Object, Sel, id)); + decl.add_method(sel!(windowDidExitFullScreen:), + window_did_exit_fullscreen as extern fn(&Object, Sel, id)); + decl.add_method(sel!(windowDidFailToEnterFullScreen:), + window_did_fail_to_enter_fullscreen as extern fn(&Object, Sel, id)); + + // Store internal state as user data + decl.add_ivar::<*mut c_void>("winitState"); + + DELEGATE_CLASS = decl.register(); + }); + + unsafe { + DELEGATE_CLASS + } + } + + fn new(state: DelegateState) -> WindowDelegate { + // Box the state so we can give a pointer to it + let mut state = Box::new(state); + let state_ptr: *mut DelegateState = &mut *state; + unsafe { + let delegate = IdRef::new(msg_send![WindowDelegate::class(), new]); + + // setDelegate uses autorelease on objects, + // so need autorelease + let autoreleasepool = NSAutoreleasePool::new(nil); + + (&mut **delegate).set_ivar("winitState", state_ptr as *mut ::std::os::raw::c_void); + let _: () = msg_send![*state.window, setDelegate:*delegate]; + + let _: () = msg_send![autoreleasepool, drain]; + + WindowDelegate { state: state, _this: delegate } + } + } +} + +impl Drop for WindowDelegate { + fn drop(&mut self) { + unsafe { + // Nil the window's delegate so it doesn't still reference us + // NOTE: setDelegate:nil at first retains the previous value, + // and then autoreleases it, so autorelease pool is needed + let autoreleasepool = NSAutoreleasePool::new(nil); + let _: () = msg_send![*self.state.window, setDelegate:nil]; + let _: () = msg_send![autoreleasepool, drain]; + } + } +} + +#[derive(Clone, Default)] +pub struct PlatformSpecificWindowBuilderAttributes { + pub activation_policy: ActivationPolicy, + pub movable_by_window_background: bool, + pub titlebar_transparent: bool, + pub title_hidden: bool, + pub titlebar_hidden: bool, + pub titlebar_buttons_hidden: bool, + pub fullsize_content_view: bool, + pub resize_increments: Option<LogicalSize>, +} + +pub struct Window2 { + pub view: IdRef, + pub window: IdRef, + pub delegate: WindowDelegate, + pub input_context: IdRef, + cursor: Weak<Mutex<util::Cursor>>, + cursor_hidden: AtomicBool, +} + +unsafe impl Send for Window2 {} +unsafe impl Sync for Window2 {} + +unsafe fn get_current_monitor(window: id) -> RootMonitorId { + let screen: id = msg_send![window, screen]; + let desc = NSScreen::deviceDescription(screen); + let key = IdRef::new(NSString::alloc(nil).init_str("NSScreenNumber")); + let value = NSDictionary::valueForKey_(desc, *key); + let display_id = msg_send![value, unsignedIntegerValue]; + RootMonitorId { inner: EventsLoop::make_monitor_from_display(display_id) } +} + +impl Drop for Window2 { + fn drop(&mut self) { + // Remove this window from the `EventLoop`s list of windows. + // The destructor order is: + // Window -> + // Rc<Window2> (makes Weak<..> in shared.windows None) -> + // Window2 + // needed to remove the element from array + let id = self.id(); + if let Some(shared) = self.delegate.state.shared.upgrade() { + shared.find_and_remove_window(id); + } + + // nswindow::close uses autorelease + // so autorelease pool + let autoreleasepool = unsafe { + NSAutoreleasePool::new(nil) + }; + + // Close the window if it has not yet been closed. + let nswindow = *self.window; + if nswindow != nil { + unsafe { + let () = msg_send![nswindow, close]; + } + } + + let _: () = unsafe { msg_send![autoreleasepool, drain] }; + } +} + +impl WindowExt for Window2 { + #[inline] + fn get_nswindow(&self) -> *mut c_void { + *self.window as *mut c_void + } + + #[inline] + fn get_nsview(&self) -> *mut c_void { + *self.view as *mut c_void + } + + #[inline] + fn request_user_attention(&self, is_critical: bool) { + let request_type = if is_critical { + NSRequestUserAttentionType::NSCriticalRequest + } else { + NSRequestUserAttentionType::NSInformationalRequest + }; + + unsafe { + NSApp().requestUserAttention_(request_type); + } + } + + #[inline] + fn set_simple_fullscreen(&self, fullscreen: bool) -> bool { + let state = &self.delegate.state; + + unsafe { + let app = NSApp(); + let win_attribs = state.win_attribs.borrow_mut(); + let is_native_fullscreen = win_attribs.fullscreen.is_some(); + let is_simple_fullscreen = state.is_simple_fullscreen.get(); + + // Do nothing if native fullscreen is active. + if is_native_fullscreen || (fullscreen && is_simple_fullscreen) || (!fullscreen && !is_simple_fullscreen) { + return false; + } + + if fullscreen { + // Remember the original window's settings + state.standard_frame.set(Some(NSWindow::frame(*self.window))); + state.save_style_mask.set(Some(self.window.styleMask())); + state.save_presentation_opts.set(Some(app.presentationOptions_())); + + // Tell our window's state that we're in fullscreen + state.is_simple_fullscreen.set(true); + + // Simulate pre-Lion fullscreen by hiding the dock and menu bar + let presentation_options = + NSApplicationPresentationOptions::NSApplicationPresentationAutoHideDock | + NSApplicationPresentationOptions::NSApplicationPresentationAutoHideMenuBar; + app.setPresentationOptions_(presentation_options); + + // Hide the titlebar + util::toggle_style_mask(*self.window, *self.view, NSWindowStyleMask::NSTitledWindowMask, false); + + // Set the window frame to the screen frame size + let screen = self.window.screen(); + let screen_frame = NSScreen::frame(screen); + NSWindow::setFrame_display_(*self.window, screen_frame, YES); + + // Fullscreen windows can't be resized, minimized, or moved + util::toggle_style_mask(*self.window, *self.view, NSWindowStyleMask::NSMiniaturizableWindowMask, false); + util::toggle_style_mask(*self.window, *self.view, NSWindowStyleMask::NSResizableWindowMask, false); + NSWindow::setMovable_(*self.window, NO); + + true + } else { + let saved_style_mask = state.saved_style_mask(win_attribs.resizable); + util::set_style_mask(*self.window, *self.view, saved_style_mask); + state.is_simple_fullscreen.set(false); + + if let Some(presentation_opts) = state.save_presentation_opts.get() { + app.setPresentationOptions_(presentation_opts); + } + + let frame = state.saved_standard_frame(); + NSWindow::setFrame_display_(*self.window, frame, YES); + NSWindow::setMovable_(*self.window, YES); + + true + } + } + } +} + +impl Window2 { + pub fn new( + shared: Weak<Shared>, + mut win_attribs: WindowAttributes, + pl_attribs: PlatformSpecificWindowBuilderAttributes, + ) -> Result<Window2, CreationError> { + unsafe { + if !msg_send![class!(NSThread), isMainThread] { + panic!("Windows can only be created on the main thread on macOS"); + } + } + + // Might as well save some RAM... + win_attribs.window_icon.take(); + + let autoreleasepool = unsafe { + NSAutoreleasePool::new(nil) + }; + + let app = match Window2::create_app(pl_attribs.activation_policy) { + Some(app) => app, + None => { + let _: () = unsafe { msg_send![autoreleasepool, drain] }; + return Err(OsError(format!("Couldn't create NSApplication"))); + }, + }; + + let window = match Window2::create_window(&win_attribs, &pl_attribs) { + Some(res) => res, + None => { + let _: () = unsafe { msg_send![autoreleasepool, drain] }; + return Err(OsError(format!("Couldn't create NSWindow"))); + }, + }; + let (view, cursor) = match Window2::create_view(*window, Weak::clone(&shared)) { + Some(view) => view, + None => { + let _: () = unsafe { msg_send![autoreleasepool, drain] }; + return Err(OsError(format!("Couldn't create NSView"))); + }, + }; + + let input_context = unsafe { util::create_input_context(*view) }; + + unsafe { + if win_attribs.transparent { + (*window as id).setOpaque_(NO); + (*window as id).setBackgroundColor_(NSColor::clearColor(nil)); + } + + app.activateIgnoringOtherApps_(YES); + + if let Some(dimensions) = win_attribs.min_dimensions { + nswindow_set_min_dimensions(window.0, dimensions); + } + if let Some(dimensions) = win_attribs.max_dimensions { + nswindow_set_max_dimensions(window.0, dimensions); + } + + use cocoa::foundation::NSArray; + // register for drag and drop operations. + let () = msg_send![(*window as id), + registerForDraggedTypes:NSArray::arrayWithObject(nil, appkit::NSFilenamesPboardType)]; + } + + let dpi_factor = unsafe { NSWindow::backingScaleFactor(*window) as f64 }; + + let mut delegate_state = DelegateState { + view: view.clone(), + window: window.clone(), + shared, + win_attribs: RefCell::new(win_attribs.clone()), + standard_frame: Cell::new(None), + is_simple_fullscreen: Cell::new(false), + save_style_mask: Cell::new(None), + save_presentation_opts: Cell::new(None), + handle_with_fullscreen: win_attribs.fullscreen.is_some(), + previous_position: None, + previous_dpi_factor: dpi_factor, + }; + delegate_state.win_attribs.borrow_mut().fullscreen = None; + + if dpi_factor != 1.0 { + WindowDelegate::emit_event(&mut delegate_state, WindowEvent::HiDpiFactorChanged(dpi_factor)); + WindowDelegate::emit_resize_event(&mut delegate_state); + } + + let window = Window2 { + view: view, + window: window, + delegate: WindowDelegate::new(delegate_state), + input_context, + cursor, + cursor_hidden: Default::default(), + }; + + // Set fullscreen mode after we setup everything + if let Some(ref monitor) = win_attribs.fullscreen { + unsafe { + if monitor.inner != get_current_monitor(*window.window).inner { + unimplemented!(); + } + } + window.set_fullscreen(Some(monitor.clone())); + } + + // Make key have to be after set fullscreen + // to prevent normal size window brefly appears + unsafe { + if win_attribs.visible { + window.window.makeKeyAndOrderFront_(nil); + } else { + window.window.makeKeyWindow(); + } + } + + if win_attribs.maximized { + window.delegate.state.perform_maximized(win_attribs.maximized); + } + + let _: () = unsafe { msg_send![autoreleasepool, drain] }; + + Ok(window) + } + + pub fn id(&self) -> Id { + get_window_id(*self.window) + } + + fn create_app(activation_policy: ActivationPolicy) -> Option<id> { + unsafe { + let app = appkit::NSApp(); + if app == nil { + None + } else { + let ns_activation_policy = match activation_policy { + ActivationPolicy::Regular => + NSApplicationActivationPolicy::NSApplicationActivationPolicyRegular, + ActivationPolicy::Accessory => + NSApplicationActivationPolicy::NSApplicationActivationPolicyAccessory, + ActivationPolicy::Prohibited => + NSApplicationActivationPolicy::NSApplicationActivationPolicyProhibited, + }; + app.setActivationPolicy_(ns_activation_policy); + app.finishLaunching(); + Some(app) + } + } + } + + fn class() -> *const Class { + static mut WINDOW2_CLASS: *const Class = 0 as *const Class; + static INIT: std::sync::Once = std::sync::ONCE_INIT; + + INIT.call_once(|| unsafe { + let window_superclass = class!(NSWindow); + let mut decl = ClassDecl::new("WinitWindow", window_superclass).unwrap(); + decl.add_method(sel!(canBecomeMainWindow), yes as extern fn(&Object, Sel) -> BOOL); + decl.add_method(sel!(canBecomeKeyWindow), yes as extern fn(&Object, Sel) -> BOOL); + WINDOW2_CLASS = decl.register(); + }); + + unsafe { + WINDOW2_CLASS + } + } + + fn create_window( + attrs: &WindowAttributes, + pl_attrs: &PlatformSpecificWindowBuilderAttributes + ) -> Option<IdRef> { + unsafe { + let autoreleasepool = NSAutoreleasePool::new(nil); + let screen = match attrs.fullscreen { + Some(ref monitor_id) => { + let monitor_screen = monitor_id.inner.get_nsscreen(); + Some(monitor_screen.unwrap_or(appkit::NSScreen::mainScreen(nil))) + }, + _ => None, + }; + let frame = match screen { + Some(screen) => appkit::NSScreen::frame(screen), + None => { + let (width, height) = attrs.dimensions + .map(|logical| (logical.width, logical.height)) + .unwrap_or((800.0, 600.0)); + NSRect::new(NSPoint::new(0.0, 0.0), NSSize::new(width, height)) + } + }; + + let mut masks = if !attrs.decorations && !screen.is_some() { + // Resizable Window2 without a titlebar or borders + // if decorations is set to false, ignore pl_attrs + NSWindowStyleMask::NSBorderlessWindowMask + | NSWindowStyleMask::NSResizableWindowMask + } else if pl_attrs.titlebar_hidden { + // if the titlebar is hidden, ignore other pl_attrs + NSWindowStyleMask::NSBorderlessWindowMask | + NSWindowStyleMask::NSResizableWindowMask + } else { + // default case, resizable window with titlebar and titlebar buttons + NSWindowStyleMask::NSClosableWindowMask | + NSWindowStyleMask::NSMiniaturizableWindowMask | + NSWindowStyleMask::NSResizableWindowMask | + NSWindowStyleMask::NSTitledWindowMask + }; + + if !attrs.resizable { + masks &= !NSWindowStyleMask::NSResizableWindowMask; + } + + if pl_attrs.fullsize_content_view { + masks |= NSWindowStyleMask::NSFullSizeContentViewWindowMask; + } + + let winit_window = Window2::class(); + + let window: id = msg_send![winit_window, alloc]; + + let window = IdRef::new(window.initWithContentRect_styleMask_backing_defer_( + frame, + masks, + appkit::NSBackingStoreBuffered, + NO, + )); + let res = window.non_nil().map(|window| { + let title = IdRef::new(NSString::alloc(nil).init_str(&attrs.title)); + window.setReleasedWhenClosed_(NO); + window.setTitle_(*title); + window.setAcceptsMouseMovedEvents_(YES); + + if pl_attrs.titlebar_transparent { + window.setTitlebarAppearsTransparent_(YES); + } + if pl_attrs.title_hidden { + window.setTitleVisibility_(appkit::NSWindowTitleVisibility::NSWindowTitleHidden); + } + if pl_attrs.titlebar_buttons_hidden { + let button = window.standardWindowButton_(NSWindowButton::NSWindowFullScreenButton); + let () = msg_send![button, setHidden:YES]; + let button = window.standardWindowButton_(NSWindowButton::NSWindowMiniaturizeButton); + let () = msg_send![button, setHidden:YES]; + let button = window.standardWindowButton_(NSWindowButton::NSWindowCloseButton); + let () = msg_send![button, setHidden:YES]; + let button = window.standardWindowButton_(NSWindowButton::NSWindowZoomButton); + let () = msg_send![button, setHidden:YES]; + } + if pl_attrs.movable_by_window_background { + window.setMovableByWindowBackground_(YES); + } + + if attrs.always_on_top { + let _: () = msg_send![*window, setLevel:ffi::NSWindowLevel::NSFloatingWindowLevel]; + } + + if let Some(increments) = pl_attrs.resize_increments { + let (x, y) = (increments.width, increments.height); + if x >= 1.0 && y >= 1.0 { + let size = NSSize::new(x as CGFloat, y as CGFloat); + window.setResizeIncrements_(size); + } + } + + window.center(); + window + }); + let _: () = msg_send![autoreleasepool, drain]; + res + } + } + + fn create_view(window: id, shared: Weak<Shared>) -> Option<(IdRef, Weak<Mutex<util::Cursor>>)> { + unsafe { + let (view, cursor) = new_view(window, shared); + view.non_nil().map(|view| { + view.setWantsBestResolutionOpenGLSurface_(YES); + + // On Mojave, views automatically become layer-backed shortly after being added to + // a window. Changing the layer-backedness of a view breaks the association between + // the view and its associated OpenGL context. To work around this, on Mojave we + // explicitly make the view layer-backed up front so that AppKit doesn't do it + // itself and break the association with its context. + if f64::floor(appkit::NSAppKitVersionNumber) > appkit::NSAppKitVersionNumber10_12 { + view.setWantsLayer(YES); + } + + window.setContentView_(*view); + window.makeFirstResponder_(*view); + (view, cursor) + }) + } + } + + pub fn set_title(&self, title: &str) { + unsafe { + let title = IdRef::new(NSString::alloc(nil).init_str(title)); + self.window.setTitle_(*title); + } + } + + #[inline] + pub fn show(&self) { + unsafe { NSWindow::makeKeyAndOrderFront_(*self.window, nil); } + } + + #[inline] + pub fn hide(&self) { + unsafe { NSWindow::orderOut_(*self.window, nil); } + } + + pub fn get_position(&self) -> Option<LogicalPosition> { + let frame_rect = unsafe { NSWindow::frame(*self.window) }; + Some(( + frame_rect.origin.x as f64, + util::bottom_left_to_top_left(frame_rect), + ).into()) + } + + pub fn get_inner_position(&self) -> Option<LogicalPosition> { + let content_rect = unsafe { + NSWindow::contentRectForFrameRect_( + *self.window, + NSWindow::frame(*self.window), + ) + }; + Some(( + content_rect.origin.x as f64, + util::bottom_left_to_top_left(content_rect), + ).into()) + } + + pub fn set_position(&self, position: LogicalPosition) { + let dummy = NSRect::new( + NSPoint::new( + position.x, + // While it's true that we're setting the top-left position, it still needs to be + // in a bottom-left coordinate system. + CGDisplay::main().pixels_high() as f64 - position.y, + ), + NSSize::new(0f64, 0f64), + ); + unsafe { + NSWindow::setFrameTopLeftPoint_(*self.window, dummy.origin); + } + } + + #[inline] + pub fn get_inner_size(&self) -> Option<LogicalSize> { + let view_frame = unsafe { NSView::frame(*self.view) }; + Some((view_frame.size.width as f64, view_frame.size.height as f64).into()) + } + + #[inline] + pub fn get_outer_size(&self) -> Option<LogicalSize> { + let view_frame = unsafe { NSWindow::frame(*self.window) }; + Some((view_frame.size.width as f64, view_frame.size.height as f64).into()) + } + + #[inline] + pub fn set_inner_size(&self, size: LogicalSize) { + unsafe { + NSWindow::setContentSize_(*self.window, NSSize::new(size.width as CGFloat, size.height as CGFloat)); + } + } + + pub fn set_min_dimensions(&self, dimensions: Option<LogicalSize>) { + unsafe { + let dimensions = dimensions.unwrap_or_else(|| (0, 0).into()); + nswindow_set_min_dimensions(self.window.0, dimensions); + } + } + + pub fn set_max_dimensions(&self, dimensions: Option<LogicalSize>) { + unsafe { + let dimensions = dimensions.unwrap_or_else(|| (!0, !0).into()); + nswindow_set_max_dimensions(self.window.0, dimensions); + } + } + + #[inline] + pub fn set_resizable(&self, resizable: bool) { + let mut win_attribs = self.delegate.state.win_attribs.borrow_mut(); + win_attribs.resizable = resizable; + if win_attribs.fullscreen.is_none() { + let mut mask = unsafe { self.window.styleMask() }; + if resizable { + mask |= NSWindowStyleMask::NSResizableWindowMask; + } else { + mask &= !NSWindowStyleMask::NSResizableWindowMask; + } + unsafe { util::set_style_mask(*self.window, *self.view, mask) }; + } // Otherwise, we don't change the mask until we exit fullscreen. + } + + pub fn set_cursor(&self, cursor: MouseCursor) { + let cursor = util::Cursor::from(cursor); + if let Some(cursor_access) = self.cursor.upgrade() { + *cursor_access.lock().unwrap() = cursor; + } + unsafe { + let _: () = msg_send![*self.window, + invalidateCursorRectsForView:*self.view + ]; + } + } + + #[inline] + pub fn grab_cursor(&self, grab: bool) -> Result<(), String> { + // TODO: Do this for real https://stackoverflow.com/a/40922095/5435443 + CGDisplay::associate_mouse_and_mouse_cursor_position(!grab) + .map_err(|status| format!("Failed to grab cursor: `CGError` {:?}", status)) + } + + #[inline] + pub fn hide_cursor(&self, hide: bool) { + let cursor_class = class!(NSCursor); + // macOS uses a "hide counter" like Windows does, so we avoid incrementing it more than once. + // (otherwise, `hide_cursor(false)` would need to be called n times!) + if hide != self.cursor_hidden.load(Ordering::Acquire) { + if hide { + let _: () = unsafe { msg_send![cursor_class, hide] }; + } else { + let _: () = unsafe { msg_send![cursor_class, unhide] }; + } + self.cursor_hidden.store(hide, Ordering::Release); + } + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + unsafe { + NSWindow::backingScaleFactor(*self.window) as f64 + } + } + + #[inline] + pub fn set_cursor_position(&self, cursor_position: LogicalPosition) -> Result<(), String> { + let window_position = self.get_inner_position() + .ok_or("`get_inner_position` failed".to_owned())?; + let point = appkit::CGPoint { + x: (cursor_position.x + window_position.x) as CGFloat, + y: (cursor_position.y + window_position.y) as CGFloat, + }; + CGDisplay::warp_mouse_cursor_position(point) + .map_err(|e| format!("`CGWarpMouseCursorPosition` failed: {:?}", e))?; + CGDisplay::associate_mouse_and_mouse_cursor_position(true) + .map_err(|e| format!("`CGAssociateMouseAndMouseCursorPosition` failed: {:?}", e))?; + + Ok(()) + } + + #[inline] + pub fn set_maximized(&self, maximized: bool) { + self.delegate.state.perform_maximized(maximized) + } + + #[inline] + /// TODO: Right now set_fullscreen do not work on switching monitors + /// in fullscreen mode + pub fn set_fullscreen(&self, monitor: Option<RootMonitorId>) { + let state = &self.delegate.state; + + // Do nothing if simple fullscreen is active. + if state.is_simple_fullscreen.get() { + return + } + + let current = { + let win_attribs = state.win_attribs.borrow_mut(); + + let current = win_attribs.fullscreen.clone(); + match (¤t, monitor) { + (&None, None) => { + return; + } + (&Some(ref a), Some(ref b)) if a.inner != b.inner => { + unimplemented!(); + } + (&Some(_), Some(_)) => { + return; + } + _ => (), + } + + current + }; + + unsafe { + // Because toggleFullScreen will not work if the StyleMask is none, + // We set a normal style to it temporary. + // It will clean up at window_did_exit_fullscreen. + if current.is_none() { + let curr_mask = state.window.styleMask(); + let required = NSWindowStyleMask::NSTitledWindowMask | NSWindowStyleMask::NSResizableWindowMask; + if !curr_mask.contains(required) { + util::set_style_mask(*self.window, *self.view, required); + state.save_style_mask.set(Some(curr_mask)); + } + } + + self.window.toggleFullScreen_(nil); + } + } + + #[inline] + pub fn set_decorations(&self, decorations: bool) { + let state = &self.delegate.state; + let mut win_attribs = state.win_attribs.borrow_mut(); + + if win_attribs.decorations == decorations { + return; + } + + win_attribs.decorations = decorations; + + // Skip modifiy if we are in fullscreen mode, + // window_did_exit_fullscreen will handle it + if win_attribs.fullscreen.is_some() { + return; + } + + unsafe { + let mut new_mask = if decorations { + NSWindowStyleMask::NSClosableWindowMask + | NSWindowStyleMask::NSMiniaturizableWindowMask + | NSWindowStyleMask::NSResizableWindowMask + | NSWindowStyleMask::NSTitledWindowMask + } else { + NSWindowStyleMask::NSBorderlessWindowMask + | NSWindowStyleMask::NSResizableWindowMask + }; + if !win_attribs.resizable { + new_mask &= !NSWindowStyleMask::NSResizableWindowMask; + } + util::set_style_mask(*state.window, *state.view, new_mask); + } + } + + #[inline] + pub fn set_always_on_top(&self, always_on_top: bool) { + unsafe { + let level = if always_on_top { + ffi::NSWindowLevel::NSFloatingWindowLevel + } else { + ffi::NSWindowLevel::NSNormalWindowLevel + }; + let _: () = msg_send![*self.window, setLevel:level]; + } + } + + #[inline] + pub fn set_window_icon(&self, _icon: Option<::Icon>) { + // macOS doesn't have window icons. Though, there is `setRepresentedFilename`, but that's + // semantically distinct and should only be used when the window is in some way + // representing a specific file/directory. For instance, Terminal.app uses this for the + // CWD. Anyway, that should eventually be implemented as + // `WindowBuilderExt::with_represented_file` or something, and doesn't have anything to do + // with `set_window_icon`. + // https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/WinPanel/Tasks/SettingWindowTitle.html + } + + #[inline] + pub fn set_ime_spot(&self, logical_spot: LogicalPosition) { + set_ime_spot(*self.view, *self.input_context, logical_spot.x, logical_spot.y); + } + + #[inline] + pub fn get_current_monitor(&self) -> RootMonitorId { + unsafe { + self::get_current_monitor(*self.window) + } + } +} + +// Convert the `cocoa::base::id` associated with a window to a usize to use as a unique identifier +// for the window. +pub fn get_window_id(window_cocoa_id: id) -> Id { + Id(window_cocoa_id as *const objc::runtime::Object as usize) +} + +unsafe fn nswindow_set_min_dimensions<V: NSWindow + Copy>(window: V, mut min_size: LogicalSize) { + let mut current_rect = NSWindow::frame(window); + let content_rect = NSWindow::contentRectForFrameRect_(window, NSWindow::frame(window)); + // Convert from client area size to window size + min_size.width += (current_rect.size.width - content_rect.size.width) as f64; // this tends to be 0 + min_size.height += (current_rect.size.height - content_rect.size.height) as f64; + window.setMinSize_(NSSize { + width: min_size.width as CGFloat, + height: min_size.height as CGFloat, + }); + // If necessary, resize the window to match constraint + if current_rect.size.width < min_size.width { + current_rect.size.width = min_size.width; + window.setFrame_display_(current_rect, 0) + } + if current_rect.size.height < min_size.height { + // The origin point of a rectangle is at its bottom left in Cocoa. + // To ensure the window's top-left point remains the same: + current_rect.origin.y += current_rect.size.height - min_size.height; + current_rect.size.height = min_size.height; + window.setFrame_display_(current_rect, 0) + } +} + +unsafe fn nswindow_set_max_dimensions<V: NSWindow + Copy>(window: V, mut max_size: LogicalSize) { + let mut current_rect = NSWindow::frame(window); + let content_rect = NSWindow::contentRectForFrameRect_(window, NSWindow::frame(window)); + // Convert from client area size to window size + max_size.width += (current_rect.size.width - content_rect.size.width) as f64; // this tends to be 0 + max_size.height += (current_rect.size.height - content_rect.size.height) as f64; + window.setMaxSize_(NSSize { + width: max_size.width as CGFloat, + height: max_size.height as CGFloat, + }); + // If necessary, resize the window to match constraint + if current_rect.size.width > max_size.width { + current_rect.size.width = max_size.width; + window.setFrame_display_(current_rect, 0) + } + if current_rect.size.height > max_size.height { + // The origin point of a rectangle is at its bottom left in Cocoa. + // To ensure the window's top-left point remains the same: + current_rect.origin.y += current_rect.size.height - max_size.height; + current_rect.size.height = max_size.height; + window.setFrame_display_(current_rect, 0) + } +} + +pub struct IdRef(id); + +impl IdRef { + pub fn new(i: id) -> IdRef { + IdRef(i) + } + + #[allow(dead_code)] + pub fn retain(i: id) -> IdRef { + if i != nil { + let _: id = unsafe { msg_send![i, retain] }; + } + IdRef(i) + } + + pub fn non_nil(self) -> Option<IdRef> { + if self.0 == nil { None } else { Some(self) } + } +} + +impl Drop for IdRef { + fn drop(&mut self) { + if self.0 != nil { + unsafe { + let autoreleasepool = NSAutoreleasePool::new(nil); + let _ : () = msg_send![self.0, release]; + let _ : () = msg_send![autoreleasepool, release]; + }; + } + } +} + +impl Deref for IdRef { + type Target = id; + fn deref<'a>(&'a self) -> &'a id { + &self.0 + } +} + +impl Clone for IdRef { + fn clone(&self) -> IdRef { + if self.0 != nil { + let _: id = unsafe { msg_send![self.0, retain] }; + } + IdRef(self.0) + } +} + +extern fn yes(_: &Object, _: Sel) -> BOOL { + YES +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/mod.rs new file mode 100644 index 0000000..be96878 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/mod.rs @@ -0,0 +1,26 @@ +pub use self::platform::*; + +#[cfg(target_os = "windows")] +#[path="windows/mod.rs"] +mod platform; +#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))] +#[path="linux/mod.rs"] +mod platform; +#[cfg(target_os = "macos")] +#[path="macos/mod.rs"] +mod platform; +#[cfg(target_os = "android")] +#[path="android/mod.rs"] +mod platform; +#[cfg(target_os = "ios")] +#[path="ios/mod.rs"] +mod platform; +#[cfg(target_os = "emscripten")] +#[path="emscripten/mod.rs"] +mod platform; + +#[cfg(all(not(target_os = "ios"), not(target_os = "windows"), not(target_os = "linux"), + not(target_os = "macos"), not(target_os = "android"), not(target_os = "dragonfly"), + not(target_os = "freebsd"), not(target_os = "netbsd"), not(target_os = "openbsd"), + not(target_os = "emscripten")))] +compile_error!("The platform you're compiling for is not supported by winit"); diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/dpi.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/dpi.rs new file mode 100644 index 0000000..ea4bc65 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/dpi.rs @@ -0,0 +1,189 @@ +#![allow(non_snake_case, unused_unsafe)] + +use std::mem; +use std::os::raw::c_void; +use std::sync::{Once, ONCE_INIT}; + +use winapi::shared::minwindef::{BOOL, UINT, FALSE}; +use winapi::shared::windef::{ + DPI_AWARENESS_CONTEXT, + DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, + HMONITOR, + HWND, +}; +use winapi::shared::winerror::S_OK; +use winapi::um::libloaderapi::{GetProcAddress, LoadLibraryA}; +use winapi::um::shellscalingapi::{ + MDT_EFFECTIVE_DPI, + MONITOR_DPI_TYPE, + PROCESS_DPI_AWARENESS, + PROCESS_PER_MONITOR_DPI_AWARE, +}; +use winapi::um::wingdi::{GetDeviceCaps, LOGPIXELSX}; +use winapi::um::winnt::{HRESULT, LPCSTR}; +use winapi::um::winuser::{self, MONITOR_DEFAULTTONEAREST}; + +const DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2: DPI_AWARENESS_CONTEXT = -4isize as _; + +type SetProcessDPIAware = unsafe extern "system" fn () -> BOOL; +type SetProcessDpiAwareness = unsafe extern "system" fn ( + value: PROCESS_DPI_AWARENESS, +) -> HRESULT; +type SetProcessDpiAwarenessContext = unsafe extern "system" fn ( + value: DPI_AWARENESS_CONTEXT, +) -> BOOL; +type GetDpiForWindow = unsafe extern "system" fn (hwnd: HWND) -> UINT; +type GetDpiForMonitor = unsafe extern "system" fn ( + hmonitor: HMONITOR, + dpi_type: MONITOR_DPI_TYPE, + dpi_x: *mut UINT, + dpi_y: *mut UINT, +) -> HRESULT; +type EnableNonClientDpiScaling = unsafe extern "system" fn (hwnd: HWND) -> BOOL; + +// Helper function to dynamically load function pointer. +// `library` and `function` must be zero-terminated. +fn get_function_impl(library: &str, function: &str) -> Option<*const c_void> { + assert_eq!(library.chars().last(), Some('\0')); + assert_eq!(function.chars().last(), Some('\0')); + + // Library names we will use are ASCII so we can use the A version to avoid string conversion. + let module = unsafe { LoadLibraryA(library.as_ptr() as LPCSTR) }; + if module.is_null() { + return None; + } + + let function_ptr = unsafe { GetProcAddress(module, function.as_ptr() as LPCSTR) }; + if function_ptr.is_null() { + return None; + } + + Some(function_ptr as _) +} + +macro_rules! get_function { + ($lib:expr, $func:ident) => { + get_function_impl(concat!($lib, '\0'), concat!(stringify!($func), '\0')) + .map(|f| unsafe { mem::transmute::<*const _, $func>(f) }) + } +} + +lazy_static! { + static ref GET_DPI_FOR_WINDOW: Option<GetDpiForWindow> = get_function!( + "user32.dll", + GetDpiForWindow + ); + static ref GET_DPI_FOR_MONITOR: Option<GetDpiForMonitor> = get_function!( + "shcore.dll", + GetDpiForMonitor + ); + static ref ENABLE_NON_CLIENT_DPI_SCALING: Option<EnableNonClientDpiScaling> = get_function!( + "user32.dll", + EnableNonClientDpiScaling + ); +} + +pub fn become_dpi_aware(enable: bool) { + if !enable { return; } + static ENABLE_DPI_AWARENESS: Once = ONCE_INIT; + ENABLE_DPI_AWARENESS.call_once(|| { unsafe { + if let Some(SetProcessDpiAwarenessContext) = get_function!( + "user32.dll", + SetProcessDpiAwarenessContext + ) { + // We are on Windows 10 Anniversary Update (1607) or later. + if SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) + == FALSE { + // V2 only works with Windows 10 Creators Update (1703). Try using the older + // V1 if we can't set V2. + SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE); + } + } else if let Some(SetProcessDpiAwareness) = get_function!( + "shcore.dll", + SetProcessDpiAwareness + ) { + // We are on Windows 8.1 or later. + SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); + } else if let Some(SetProcessDPIAware) = get_function!( + "user32.dll", + SetProcessDPIAware + ) { + // We are on Vista or later. + SetProcessDPIAware(); + } + } }); +} + +pub fn enable_non_client_dpi_scaling(hwnd: HWND) { + unsafe { + if let Some(EnableNonClientDpiScaling) = *ENABLE_NON_CLIENT_DPI_SCALING { + EnableNonClientDpiScaling(hwnd); + } + } +} + +pub fn get_monitor_dpi(hmonitor: HMONITOR) -> Option<u32> { + unsafe { + if let Some(GetDpiForMonitor) = *GET_DPI_FOR_MONITOR { + // We are on Windows 8.1 or later. + let mut dpi_x = 0; + let mut dpi_y = 0; + if GetDpiForMonitor(hmonitor, MDT_EFFECTIVE_DPI, &mut dpi_x, &mut dpi_y) == S_OK { + // MSDN says that "the values of *dpiX and *dpiY are identical. You only need to + // record one of the values to determine the DPI and respond appropriately". + // https://msdn.microsoft.com/en-us/library/windows/desktop/dn280510(v=vs.85).aspx + return Some(dpi_x as u32) + } + } + } + None +} + +pub const BASE_DPI: u32 = 96; +pub fn dpi_to_scale_factor(dpi: u32) -> f64 { + dpi as f64 / BASE_DPI as f64 +} + +pub unsafe fn get_hwnd_dpi(hwnd: HWND) -> u32 { + let hdc = winuser::GetDC(hwnd); + if hdc.is_null() { + panic!("[winit] `GetDC` returned null!"); + } + if let Some(GetDpiForWindow) = *GET_DPI_FOR_WINDOW { + // We are on Windows 10 Anniversary Update (1607) or later. + match GetDpiForWindow(hwnd) { + 0 => BASE_DPI, // 0 is returned if hwnd is invalid + dpi => dpi as u32, + } + } else if let Some(GetDpiForMonitor) = *GET_DPI_FOR_MONITOR { + // We are on Windows 8.1 or later. + let monitor = winuser::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); + if monitor.is_null() { + return BASE_DPI; + } + + let mut dpi_x = 0; + let mut dpi_y = 0; + if GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &mut dpi_x, &mut dpi_y) == S_OK { + dpi_x as u32 + } else { + BASE_DPI + } + } else { + // We are on Vista or later. + if winuser::IsProcessDPIAware() != FALSE { + // If the process is DPI aware, then scaling must be handled by the application using + // this DPI value. + GetDeviceCaps(hdc, LOGPIXELSX) as u32 + } else { + // If the process is DPI unaware, then scaling is performed by the OS; we thus return + // 96 (scale factor 1.0) to prevent the window from being re-scaled by both the + // application and the WM. + BASE_DPI + } + } +} + +pub fn get_hwnd_scale_factor(hwnd: HWND) -> f64 { + dpi_to_scale_factor(unsafe { get_hwnd_dpi(hwnd) }) +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/drop_handler.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/drop_handler.rs new file mode 100644 index 0000000..9b2af7c --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/drop_handler.rs @@ -0,0 +1,226 @@ +use std::ffi::OsString; +use std::os::windows::ffi::OsStringExt; +use std::path::PathBuf; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::{mem, ptr}; + +use winapi::ctypes::c_void; +use winapi::shared::guiddef::REFIID; +use winapi::shared::minwindef::{DWORD, MAX_PATH, UINT, ULONG}; +use winapi::shared::windef::{HWND, POINTL}; +use winapi::shared::winerror::S_OK; +use winapi::um::objidl::IDataObject; +use winapi::um::oleidl::{DROPEFFECT_COPY, DROPEFFECT_NONE, IDropTarget, IDropTargetVtbl}; +use winapi::um::winnt::HRESULT; +use winapi::um::{shellapi, unknwnbase}; + +use platform::platform::events_loop::send_event; +use platform::platform::WindowId; + +use {Event, WindowId as SuperWindowId}; + +#[repr(C)] +pub struct FileDropHandlerData { + pub interface: IDropTarget, + refcount: AtomicUsize, + window: HWND, + cursor_effect: DWORD, + hovered_is_valid: bool, // If the currently hovered item is not valid there must not be any `HoveredFileCancelled` emitted +} + +pub struct FileDropHandler { + pub data: *mut FileDropHandlerData, +} + +#[allow(non_snake_case)] +impl FileDropHandler { + pub fn new(window: HWND) -> FileDropHandler { + let data = Box::new(FileDropHandlerData { + interface: IDropTarget { + lpVtbl: &DROP_TARGET_VTBL as *const IDropTargetVtbl, + }, + refcount: AtomicUsize::new(1), + window, + cursor_effect: DROPEFFECT_NONE, + hovered_is_valid: false, + }); + FileDropHandler { + data: Box::into_raw(data), + } + } + + // Implement IUnknown + pub unsafe extern "system" fn QueryInterface( + _this: *mut unknwnbase::IUnknown, + _riid: REFIID, + _ppvObject: *mut *mut c_void, + ) -> HRESULT { + // This function doesn't appear to be required for an `IDropTarget`. + // An implementation would be nice however. + unimplemented!(); + } + + pub unsafe extern "system" fn AddRef(this: *mut unknwnbase::IUnknown) -> ULONG { + let drop_handler_data = Self::from_interface(this); + let count = drop_handler_data.refcount.fetch_add(1, Ordering::Release) + 1; + count as ULONG + } + + pub unsafe extern "system" fn Release(this: *mut unknwnbase::IUnknown) -> ULONG { + let drop_handler = Self::from_interface(this); + let count = drop_handler.refcount.fetch_sub(1, Ordering::Release) - 1; + if count == 0 { + // Destroy the underlying data + Box::from_raw(drop_handler as *mut FileDropHandlerData); + } + count as ULONG + } + + pub unsafe extern "system" fn DragEnter( + this: *mut IDropTarget, + pDataObj: *const IDataObject, + _grfKeyState: DWORD, + _pt: *const POINTL, + pdwEffect: *mut DWORD, + ) -> HRESULT { + use events::WindowEvent::HoveredFile; + let drop_handler = Self::from_interface(this); + let hdrop = Self::iterate_filenames(pDataObj, |filename| { + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(drop_handler.window)), + event: HoveredFile(filename), + }); + }); + drop_handler.hovered_is_valid = hdrop.is_some(); + drop_handler.cursor_effect = if drop_handler.hovered_is_valid { + DROPEFFECT_COPY + } else { + DROPEFFECT_NONE + }; + *pdwEffect = drop_handler.cursor_effect; + + S_OK + } + + pub unsafe extern "system" fn DragOver( + this: *mut IDropTarget, + _grfKeyState: DWORD, + _pt: *const POINTL, + pdwEffect: *mut DWORD, + ) -> HRESULT { + let drop_handler = Self::from_interface(this); + *pdwEffect = drop_handler.cursor_effect; + + S_OK + } + + pub unsafe extern "system" fn DragLeave(this: *mut IDropTarget) -> HRESULT { + use events::WindowEvent::HoveredFileCancelled; + let drop_handler = Self::from_interface(this); + if drop_handler.hovered_is_valid { + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(drop_handler.window)), + event: HoveredFileCancelled, + }); + } + + S_OK + } + + pub unsafe extern "system" fn Drop( + this: *mut IDropTarget, + pDataObj: *const IDataObject, + _grfKeyState: DWORD, + _pt: *const POINTL, + _pdwEffect: *mut DWORD, + ) -> HRESULT { + use events::WindowEvent::DroppedFile; + let drop_handler = Self::from_interface(this); + let hdrop = Self::iterate_filenames(pDataObj, |filename| { + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(drop_handler.window)), + event: DroppedFile(filename), + }); + }); + if let Some(hdrop) = hdrop { + shellapi::DragFinish(hdrop); + } + + S_OK + } + + unsafe fn from_interface<'a, InterfaceT>(this: *mut InterfaceT) -> &'a mut FileDropHandlerData { + &mut *(this as *mut _) + } + + unsafe fn iterate_filenames<F>(data_obj: *const IDataObject, callback: F) -> Option<shellapi::HDROP> + where + F: Fn(PathBuf), + { + use winapi::ctypes::wchar_t; + use winapi::shared::winerror::{SUCCEEDED, DV_E_FORMATETC}; + use winapi::shared::wtypes::{CLIPFORMAT, DVASPECT_CONTENT}; + use winapi::um::objidl::{FORMATETC, TYMED_HGLOBAL}; + use winapi::um::shellapi::DragQueryFileW; + use winapi::um::winuser::CF_HDROP; + + let mut drop_format = FORMATETC { + cfFormat: CF_HDROP as CLIPFORMAT, + ptd: ptr::null(), + dwAspect: DVASPECT_CONTENT, + lindex: -1, + tymed: TYMED_HGLOBAL, + }; + + let mut medium = mem::uninitialized(); + let get_data_result = (*data_obj).GetData(&mut drop_format, &mut medium); + if SUCCEEDED(get_data_result) { + let hglobal = (*medium.u).hGlobal(); + let hdrop = (*hglobal) as shellapi::HDROP; + + // The second parameter (0xFFFFFFFF) instructs the function to return the item count + let item_count = DragQueryFileW(hdrop, 0xFFFFFFFF, ptr::null_mut(), 0); + + let mut pathbuf: [wchar_t; MAX_PATH] = mem::uninitialized(); + + for i in 0..item_count { + let character_count = + DragQueryFileW(hdrop, i, pathbuf.as_mut_ptr(), MAX_PATH as UINT) as usize; + + if character_count > 0 { + callback(OsString::from_wide(&pathbuf[0..character_count]).into()); + } + } + + return Some(hdrop); + } else if get_data_result == DV_E_FORMATETC { + // If the dropped item is not a file this error will occur. + // In this case it is OK to return without taking further action. + debug!("Error occured while processing dropped/hovered item: item is not a file."); + return None; + } else { + debug!("Unexpected error occured while processing dropped/hovered item."); + return None; + } + } +} + +impl Drop for FileDropHandler { + fn drop(&mut self) { + unsafe { + FileDropHandler::Release(self.data as *mut unknwnbase::IUnknown); + } + } +} + +static DROP_TARGET_VTBL: IDropTargetVtbl = IDropTargetVtbl { + parent: unknwnbase::IUnknownVtbl { + QueryInterface: FileDropHandler::QueryInterface, + AddRef: FileDropHandler::AddRef, + Release: FileDropHandler::Release, + }, + DragEnter: FileDropHandler::DragEnter, + DragOver: FileDropHandler::DragOver, + DragLeave: FileDropHandler::DragLeave, + Drop: FileDropHandler::Drop, +}; diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/event.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/event.rs new file mode 100644 index 0000000..dfdff6e --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/event.rs @@ -0,0 +1,267 @@ +use std::char; +use std::os::raw::c_int; + +use events::VirtualKeyCode; +use events::ModifiersState; + +use winapi::shared::minwindef::{WPARAM, LPARAM, UINT}; +use winapi::um::winuser; + +use ScanCode; + +pub fn get_key_mods() -> ModifiersState { + let mut mods = ModifiersState::default(); + unsafe { + if winuser::GetKeyState(winuser::VK_SHIFT) & (1 << 15) == (1 << 15) { + mods.shift = true; + } + if winuser::GetKeyState(winuser::VK_CONTROL) & (1 << 15) == (1 << 15) { + mods.ctrl = true; + } + if winuser::GetKeyState(winuser::VK_MENU) & (1 << 15) == (1 << 15) { + mods.alt = true; + } + if (winuser::GetKeyState(winuser::VK_LWIN) | winuser::GetKeyState(winuser::VK_RWIN)) & (1 << 15) == (1 << 15) { + mods.logo = true; + } + } + mods +} + +pub fn vkey_to_winit_vkey(vkey: c_int) -> Option<VirtualKeyCode> { + // VK_* codes are documented here https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx + match vkey { + //winuser::VK_LBUTTON => Some(VirtualKeyCode::Lbutton), + //winuser::VK_RBUTTON => Some(VirtualKeyCode::Rbutton), + //winuser::VK_CANCEL => Some(VirtualKeyCode::Cancel), + //winuser::VK_MBUTTON => Some(VirtualKeyCode::Mbutton), + //winuser::VK_XBUTTON1 => Some(VirtualKeyCode::Xbutton1), + //winuser::VK_XBUTTON2 => Some(VirtualKeyCode::Xbutton2), + winuser::VK_BACK => Some(VirtualKeyCode::Back), + winuser::VK_TAB => Some(VirtualKeyCode::Tab), + //winuser::VK_CLEAR => Some(VirtualKeyCode::Clear), + winuser::VK_RETURN => Some(VirtualKeyCode::Return), + winuser::VK_LSHIFT => Some(VirtualKeyCode::LShift), + winuser::VK_RSHIFT => Some(VirtualKeyCode::RShift), + winuser::VK_LCONTROL => Some(VirtualKeyCode::LControl), + winuser::VK_RCONTROL => Some(VirtualKeyCode::RControl), + winuser::VK_LMENU => Some(VirtualKeyCode::LAlt), + winuser::VK_RMENU => Some(VirtualKeyCode::RAlt), + winuser::VK_PAUSE => Some(VirtualKeyCode::Pause), + winuser::VK_CAPITAL => Some(VirtualKeyCode::Capital), + winuser::VK_KANA => Some(VirtualKeyCode::Kana), + //winuser::VK_HANGUEL => Some(VirtualKeyCode::Hanguel), + //winuser::VK_HANGUL => Some(VirtualKeyCode::Hangul), + //winuser::VK_JUNJA => Some(VirtualKeyCode::Junja), + //winuser::VK_FINAL => Some(VirtualKeyCode::Final), + //winuser::VK_HANJA => Some(VirtualKeyCode::Hanja), + winuser::VK_KANJI => Some(VirtualKeyCode::Kanji), + winuser::VK_ESCAPE => Some(VirtualKeyCode::Escape), + winuser::VK_CONVERT => Some(VirtualKeyCode::Convert), + winuser::VK_NONCONVERT => Some(VirtualKeyCode::NoConvert), + //winuser::VK_ACCEPT => Some(VirtualKeyCode::Accept), + //winuser::VK_MODECHANGE => Some(VirtualKeyCode::Modechange), + winuser::VK_SPACE => Some(VirtualKeyCode::Space), + winuser::VK_PRIOR => Some(VirtualKeyCode::PageUp), + winuser::VK_NEXT => Some(VirtualKeyCode::PageDown), + winuser::VK_END => Some(VirtualKeyCode::End), + winuser::VK_HOME => Some(VirtualKeyCode::Home), + winuser::VK_LEFT => Some(VirtualKeyCode::Left), + winuser::VK_UP => Some(VirtualKeyCode::Up), + winuser::VK_RIGHT => Some(VirtualKeyCode::Right), + winuser::VK_DOWN => Some(VirtualKeyCode::Down), + //winuser::VK_SELECT => Some(VirtualKeyCode::Select), + //winuser::VK_PRINT => Some(VirtualKeyCode::Print), + //winuser::VK_EXECUTE => Some(VirtualKeyCode::Execute), + winuser::VK_SNAPSHOT => Some(VirtualKeyCode::Snapshot), + winuser::VK_INSERT => Some(VirtualKeyCode::Insert), + winuser::VK_DELETE => Some(VirtualKeyCode::Delete), + //winuser::VK_HELP => Some(VirtualKeyCode::Help), + 0x30 => Some(VirtualKeyCode::Key0), + 0x31 => Some(VirtualKeyCode::Key1), + 0x32 => Some(VirtualKeyCode::Key2), + 0x33 => Some(VirtualKeyCode::Key3), + 0x34 => Some(VirtualKeyCode::Key4), + 0x35 => Some(VirtualKeyCode::Key5), + 0x36 => Some(VirtualKeyCode::Key6), + 0x37 => Some(VirtualKeyCode::Key7), + 0x38 => Some(VirtualKeyCode::Key8), + 0x39 => Some(VirtualKeyCode::Key9), + 0x41 => Some(VirtualKeyCode::A), + 0x42 => Some(VirtualKeyCode::B), + 0x43 => Some(VirtualKeyCode::C), + 0x44 => Some(VirtualKeyCode::D), + 0x45 => Some(VirtualKeyCode::E), + 0x46 => Some(VirtualKeyCode::F), + 0x47 => Some(VirtualKeyCode::G), + 0x48 => Some(VirtualKeyCode::H), + 0x49 => Some(VirtualKeyCode::I), + 0x4A => Some(VirtualKeyCode::J), + 0x4B => Some(VirtualKeyCode::K), + 0x4C => Some(VirtualKeyCode::L), + 0x4D => Some(VirtualKeyCode::M), + 0x4E => Some(VirtualKeyCode::N), + 0x4F => Some(VirtualKeyCode::O), + 0x50 => Some(VirtualKeyCode::P), + 0x51 => Some(VirtualKeyCode::Q), + 0x52 => Some(VirtualKeyCode::R), + 0x53 => Some(VirtualKeyCode::S), + 0x54 => Some(VirtualKeyCode::T), + 0x55 => Some(VirtualKeyCode::U), + 0x56 => Some(VirtualKeyCode::V), + 0x57 => Some(VirtualKeyCode::W), + 0x58 => Some(VirtualKeyCode::X), + 0x59 => Some(VirtualKeyCode::Y), + 0x5A => Some(VirtualKeyCode::Z), + //winuser::VK_LWIN => Some(VirtualKeyCode::Lwin), + //winuser::VK_RWIN => Some(VirtualKeyCode::Rwin), + winuser::VK_APPS => Some(VirtualKeyCode::Apps), + winuser::VK_SLEEP => Some(VirtualKeyCode::Sleep), + winuser::VK_NUMPAD0 => Some(VirtualKeyCode::Numpad0), + winuser::VK_NUMPAD1 => Some(VirtualKeyCode::Numpad1), + winuser::VK_NUMPAD2 => Some(VirtualKeyCode::Numpad2), + winuser::VK_NUMPAD3 => Some(VirtualKeyCode::Numpad3), + winuser::VK_NUMPAD4 => Some(VirtualKeyCode::Numpad4), + winuser::VK_NUMPAD5 => Some(VirtualKeyCode::Numpad5), + winuser::VK_NUMPAD6 => Some(VirtualKeyCode::Numpad6), + winuser::VK_NUMPAD7 => Some(VirtualKeyCode::Numpad7), + winuser::VK_NUMPAD8 => Some(VirtualKeyCode::Numpad8), + winuser::VK_NUMPAD9 => Some(VirtualKeyCode::Numpad9), + winuser::VK_MULTIPLY => Some(VirtualKeyCode::Multiply), + winuser::VK_ADD => Some(VirtualKeyCode::Add), + //winuser::VK_SEPARATOR => Some(VirtualKeyCode::Separator), + winuser::VK_SUBTRACT => Some(VirtualKeyCode::Subtract), + winuser::VK_DECIMAL => Some(VirtualKeyCode::Decimal), + winuser::VK_DIVIDE => Some(VirtualKeyCode::Divide), + winuser::VK_F1 => Some(VirtualKeyCode::F1), + winuser::VK_F2 => Some(VirtualKeyCode::F2), + winuser::VK_F3 => Some(VirtualKeyCode::F3), + winuser::VK_F4 => Some(VirtualKeyCode::F4), + winuser::VK_F5 => Some(VirtualKeyCode::F5), + winuser::VK_F6 => Some(VirtualKeyCode::F6), + winuser::VK_F7 => Some(VirtualKeyCode::F7), + winuser::VK_F8 => Some(VirtualKeyCode::F8), + winuser::VK_F9 => Some(VirtualKeyCode::F9), + winuser::VK_F10 => Some(VirtualKeyCode::F10), + winuser::VK_F11 => Some(VirtualKeyCode::F11), + winuser::VK_F12 => Some(VirtualKeyCode::F12), + winuser::VK_F13 => Some(VirtualKeyCode::F13), + winuser::VK_F14 => Some(VirtualKeyCode::F14), + winuser::VK_F15 => Some(VirtualKeyCode::F15), + winuser::VK_F16 => Some(VirtualKeyCode::F16), + winuser::VK_F17 => Some(VirtualKeyCode::F17), + winuser::VK_F18 => Some(VirtualKeyCode::F18), + winuser::VK_F19 => Some(VirtualKeyCode::F19), + winuser::VK_F20 => Some(VirtualKeyCode::F20), + winuser::VK_F21 => Some(VirtualKeyCode::F21), + winuser::VK_F22 => Some(VirtualKeyCode::F22), + winuser::VK_F23 => Some(VirtualKeyCode::F23), + winuser::VK_F24 => Some(VirtualKeyCode::F24), + winuser::VK_NUMLOCK => Some(VirtualKeyCode::Numlock), + winuser::VK_SCROLL => Some(VirtualKeyCode::Scroll), + winuser::VK_BROWSER_BACK => Some(VirtualKeyCode::NavigateBackward), + winuser::VK_BROWSER_FORWARD => Some(VirtualKeyCode::NavigateForward), + winuser::VK_BROWSER_REFRESH => Some(VirtualKeyCode::WebRefresh), + winuser::VK_BROWSER_STOP => Some(VirtualKeyCode::WebStop), + winuser::VK_BROWSER_SEARCH => Some(VirtualKeyCode::WebSearch), + winuser::VK_BROWSER_FAVORITES => Some(VirtualKeyCode::WebFavorites), + winuser::VK_BROWSER_HOME => Some(VirtualKeyCode::WebHome), + winuser::VK_VOLUME_MUTE => Some(VirtualKeyCode::Mute), + winuser::VK_VOLUME_DOWN => Some(VirtualKeyCode::VolumeDown), + winuser::VK_VOLUME_UP => Some(VirtualKeyCode::VolumeUp), + winuser::VK_MEDIA_NEXT_TRACK => Some(VirtualKeyCode::NextTrack), + winuser::VK_MEDIA_PREV_TRACK => Some(VirtualKeyCode::PrevTrack), + winuser::VK_MEDIA_STOP => Some(VirtualKeyCode::MediaStop), + winuser::VK_MEDIA_PLAY_PAUSE => Some(VirtualKeyCode::PlayPause), + winuser::VK_LAUNCH_MAIL => Some(VirtualKeyCode::Mail), + winuser::VK_LAUNCH_MEDIA_SELECT => Some(VirtualKeyCode::MediaSelect), + /*winuser::VK_LAUNCH_APP1 => Some(VirtualKeyCode::Launch_app1), + winuser::VK_LAUNCH_APP2 => Some(VirtualKeyCode::Launch_app2),*/ + winuser::VK_OEM_PLUS => Some(VirtualKeyCode::Equals), + winuser::VK_OEM_COMMA => Some(VirtualKeyCode::Comma), + winuser::VK_OEM_MINUS => Some(VirtualKeyCode::Minus), + winuser::VK_OEM_PERIOD => Some(VirtualKeyCode::Period), + winuser::VK_OEM_1 => map_text_keys(vkey), + winuser::VK_OEM_2 => map_text_keys(vkey), + winuser::VK_OEM_3 => map_text_keys(vkey), + winuser::VK_OEM_4 => map_text_keys(vkey), + winuser::VK_OEM_5 => map_text_keys(vkey), + winuser::VK_OEM_6 => map_text_keys(vkey), + winuser::VK_OEM_7 => map_text_keys(vkey), + /*winuser::VK_OEM_8 => Some(VirtualKeyCode::Oem_8), */ + winuser::VK_OEM_102 => Some(VirtualKeyCode::OEM102), + /*winuser::VK_PROCESSKEY => Some(VirtualKeyCode::Processkey), + winuser::VK_PACKET => Some(VirtualKeyCode::Packet), + winuser::VK_ATTN => Some(VirtualKeyCode::Attn), + winuser::VK_CRSEL => Some(VirtualKeyCode::Crsel), + winuser::VK_EXSEL => Some(VirtualKeyCode::Exsel), + winuser::VK_EREOF => Some(VirtualKeyCode::Ereof), + winuser::VK_PLAY => Some(VirtualKeyCode::Play), + winuser::VK_ZOOM => Some(VirtualKeyCode::Zoom), + winuser::VK_NONAME => Some(VirtualKeyCode::Noname), + winuser::VK_PA1 => Some(VirtualKeyCode::Pa1), + winuser::VK_OEM_CLEAR => Some(VirtualKeyCode::Oem_clear),*/ + _ => None + } +} + +pub fn handle_extended_keys(vkey: c_int, mut scancode: UINT, extended: bool) -> Option<(c_int, UINT)> { + // Welcome to hell https://blog.molecular-matters.com/2011/09/05/properly-handling-keyboard-input/ + let vkey = match vkey { + winuser::VK_SHIFT => unsafe { winuser::MapVirtualKeyA( + scancode, + winuser::MAPVK_VSC_TO_VK_EX, + ) as _ }, + winuser::VK_CONTROL => if extended { + winuser::VK_RCONTROL + } else { + winuser::VK_LCONTROL + }, + winuser::VK_MENU => if extended { + winuser::VK_RMENU + } else { + winuser::VK_LMENU + }, + _ => match scancode { + // This is only triggered when using raw input. Without this check, we get two events whenever VK_PAUSE is + // pressed, the first one having scancode 0x1D but vkey VK_PAUSE... + 0x1D if vkey == winuser::VK_PAUSE => return None, + // ...and the second having scancode 0x45 but an unmatched vkey! + 0x45 => winuser::VK_PAUSE, + // VK_PAUSE and VK_SCROLL have the same scancode when using modifiers, alongside incorrect vkey values. + 0x46 => { + if extended { + scancode = 0x45; + winuser::VK_PAUSE + } else { + winuser::VK_SCROLL + } + }, + _ => vkey, + }, + }; + Some((vkey, scancode)) +} + +pub fn process_key_params(wparam: WPARAM, lparam: LPARAM) -> Option<(ScanCode, Option<VirtualKeyCode>)> { + let scancode = ((lparam >> 16) & 0xff) as UINT; + let extended = (lparam & 0x01000000) != 0; + handle_extended_keys(wparam as _, scancode, extended) + .map(|(vkey, scancode)| (scancode, vkey_to_winit_vkey(vkey))) +} + +// This is needed as windows doesn't properly distinguish +// some virtual key codes for different keyboard layouts +fn map_text_keys(win_virtual_key: i32) -> Option<VirtualKeyCode> { + let char_key = unsafe { winuser::MapVirtualKeyA(win_virtual_key as u32, winuser::MAPVK_VK_TO_CHAR) } & 0x7FFF; + match char::from_u32(char_key) { + Some(';') => Some(VirtualKeyCode::Semicolon), + Some('/') => Some(VirtualKeyCode::Slash), + Some('`') => Some(VirtualKeyCode::Grave), + Some('[') => Some(VirtualKeyCode::LBracket), + Some(']') => Some(VirtualKeyCode::RBracket), + Some('\'') => Some(VirtualKeyCode::Apostrophe), + Some('\\') => Some(VirtualKeyCode::Backslash), + _ => None + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/events_loop.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/events_loop.rs new file mode 100644 index 0000000..de4a432 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/events_loop.rs @@ -0,0 +1,1299 @@ +//! An events loop on Win32 is a background thread. +//! +//! Creating an events loop spawns a thread and blocks it in a permanent Win32 events loop. +//! Destroying the events loop stops the thread. +//! +//! You can use the `execute_in_thread` method to execute some code in the background thread. +//! Since Win32 requires you to create a window in the right thread, you must use this method +//! to create a window. +//! +//! If you create a window whose class is set to `callback`, the window's events will be +//! propagated with `run_forever` and `poll_events`. +//! The closure passed to the `execute_in_thread` method takes an `Inserter` that you can use to +//! add a `WindowState` entry to a list of window to be used by the callback. + +use std::{mem, panic, ptr, thread}; +use std::any::Any; +use std::cell::RefCell; +use std::collections::HashMap; +use std::os::windows::io::AsRawHandle; +use std::sync::{Arc, mpsc, Mutex}; + +use backtrace::Backtrace; +use winapi::ctypes::c_int; +use winapi::shared::minwindef::{ + BOOL, + DWORD, + HIWORD, + INT, + LOWORD, + LPARAM, + LRESULT, + UINT, + WPARAM, +}; +use winapi::shared::windef::{HWND, POINT, RECT}; +use winapi::shared::windowsx; +use winapi::shared::winerror::S_OK; +use winapi::um::{libloaderapi, processthreadsapi, ole2, winuser}; +use winapi::um::oleidl::LPDROPTARGET; +use winapi::um::winnt::{LONG, LPCSTR, SHORT}; + +use { + ControlFlow, + Event, + EventsLoopClosed, + KeyboardInput, + LogicalPosition, + LogicalSize, + PhysicalSize, + WindowEvent, + WindowId as SuperWindowId, +}; +use events::{DeviceEvent, Touch, TouchPhase}; +use platform::platform::{event, Cursor, WindowId, DEVICE_ID, wrap_device_id, util}; +use platform::platform::dpi::{ + become_dpi_aware, + dpi_to_scale_factor, + enable_non_client_dpi_scaling, + get_hwnd_scale_factor, +}; +use platform::platform::drop_handler::FileDropHandler; +use platform::platform::event::{handle_extended_keys, process_key_params, vkey_to_winit_vkey}; +use platform::platform::icon::WinIcon; +use platform::platform::raw_input::{get_raw_input_data, get_raw_mouse_button_state}; +use platform::platform::window::adjust_size; + +/// Contains saved window info for switching between fullscreen +#[derive(Clone)] +pub struct SavedWindowInfo { + /// Window style + pub style: LONG, + /// Window ex-style + pub ex_style: LONG, + /// Window position and size + pub client_rect: RECT, + // Since a window can be fullscreened to a different monitor, a DPI change can be triggered. This could result in + // the window being automitcally resized to smaller/larger than it was supposed to be restored to, so we thus must + // check if the post-fullscreen DPI matches the pre-fullscreen DPI. + pub is_fullscreen: bool, + pub dpi_factor: Option<f64>, +} + +/// Contains information about states and the window that the callback is going to use. +#[derive(Clone)] +pub struct WindowState { + /// Cursor to set at the next `WM_SETCURSOR` event received. + pub cursor: Cursor, + pub cursor_grabbed: bool, + pub cursor_hidden: bool, + /// Used by `WM_GETMINMAXINFO`. + pub max_size: Option<PhysicalSize>, + pub min_size: Option<PhysicalSize>, + /// Will contain `true` if the mouse is hovering the window. + pub mouse_in_window: bool, + /// Saved window info for fullscreen restored + pub saved_window_info: Option<SavedWindowInfo>, + // This is different from the value in `SavedWindowInfo`! That one represents the DPI saved upon entering + // fullscreen. This will always be the most recent DPI for the window. + pub dpi_factor: f64, + pub fullscreen: Option<::MonitorId>, + pub window_icon: Option<WinIcon>, + pub taskbar_icon: Option<WinIcon>, + pub decorations: bool, + pub always_on_top: bool, + pub maximized: bool, + pub resizable: bool, +} + +impl WindowState { + pub fn update_min_max(&mut self, old_dpi_factor: f64, new_dpi_factor: f64) { + let scale_factor = new_dpi_factor / old_dpi_factor; + let dpi_adjuster = |mut physical_size: PhysicalSize| -> PhysicalSize { + physical_size.width *= scale_factor; + physical_size.height *= scale_factor; + physical_size + }; + self.max_size = self.max_size.map(&dpi_adjuster); + self.min_size = self.min_size.map(&dpi_adjuster); + } +} + +/// Dummy object that allows inserting a window's state. +// We store a pointer in order to !impl Send and Sync. +pub struct Inserter(*mut u8); + +impl Inserter { + /// Inserts a window's state for the callback to use. The state is removed automatically if the + /// callback receives a `WM_CLOSE` message for the window. + pub fn insert(&self, window: HWND, state: Arc<Mutex<WindowState>>) { + CONTEXT_STASH.with(|context_stash| { + let mut context_stash = context_stash.borrow_mut(); + let was_in = context_stash.as_mut().unwrap().windows.insert(window, state); + assert!(was_in.is_none()); + }); + } +} + +pub struct EventsLoop { + thread_msg_target: HWND, + // Id of the background thread from the Win32 API. + thread_id: DWORD, + // Receiver for the events. The sender is in the background thread. + receiver: mpsc::Receiver<EventsLoopEvent>, + // Sender instance that's paired with the receiver. Used to construct an `EventsLoopProxy`. + sender: mpsc::Sender<EventsLoopEvent>, +} + +enum EventsLoopEvent { + WinitEvent(Event), + Panic(PanicError), +} + +impl EventsLoop { + pub fn new() -> EventsLoop { + Self::with_dpi_awareness(true) + } + + pub fn with_dpi_awareness(dpi_aware: bool) -> EventsLoop { + struct InitData { + thread_msg_target: HWND, + } + unsafe impl Send for InitData {} + + become_dpi_aware(dpi_aware); + + // The main events transfer channel. + let (tx, rx) = mpsc::channel(); + + // Channel to send initialization data created on the event loop thread back to the main + // thread. + let (init_tx, init_rx) = mpsc::sync_channel(0); + + let thread_sender = tx.clone(); + let panic_sender = tx.clone(); + let thread = thread::spawn(move || { + let tx = thread_sender; + let thread_msg_target = thread_event_target_window(); + + CONTEXT_STASH.with(|context_stash| { + *context_stash.borrow_mut() = Some(ThreadLocalData { + sender: tx, + windows: HashMap::with_capacity(4), + file_drop_handlers: HashMap::with_capacity(4), + mouse_buttons_down: 0, + panic_error: None, + }); + }); + + unsafe { + // Calling `PostThreadMessageA` on a thread that does not have an events queue yet + // will fail. In order to avoid this situation, we call `IsGuiThread` to initialize + // it. + winuser::IsGUIThread(1); + // Then only we unblock the `new()` function. We are sure that we don't call + // `PostThreadMessageA()` before `new()` returns. + init_tx.send(InitData{ thread_msg_target }).ok(); + drop(init_tx); + + let mut msg = mem::uninitialized(); + + loop { + if winuser::GetMessageW(&mut msg, ptr::null_mut(), 0, 0) == 0 { + // If a panic occurred in the child callback, forward the panic information + // to the parent thread. + let panic_payload_opt = CONTEXT_STASH.with(|stash| + stash.borrow_mut().as_mut() + .and_then(|s| s.panic_error.take()) + ); + if let Some(panic_payload) = panic_payload_opt { + panic_sender.send(EventsLoopEvent::Panic(panic_payload)).unwrap(); + }; + + // Only happens if the message is `WM_QUIT`. + debug_assert_eq!(msg.message, winuser::WM_QUIT); + break; + } + + // Calls `callback` below. + winuser::TranslateMessage(&msg); + winuser::DispatchMessageW(&msg); + } + } + }); + + // Blocks this function until the background thread has an events loop. See other comments. + let InitData { thread_msg_target } = init_rx.recv().unwrap(); + + let thread_id = unsafe { + let handle = mem::transmute(thread.as_raw_handle()); + processthreadsapi::GetThreadId(handle) + }; + + EventsLoop { + thread_msg_target, + thread_id, + receiver: rx, + sender: tx, + } + } + + pub fn poll_events<F>(&mut self, mut callback: F) + where F: FnMut(Event) + { + loop { + let event = match self.receiver.try_recv() { + Ok(EventsLoopEvent::WinitEvent(e)) => e, + Ok(EventsLoopEvent::Panic(panic)) => { + eprintln!("resuming child thread unwind at: {:?}", Backtrace::new()); + panic::resume_unwind(panic) + }, + Err(_) => break, + }; + + callback(event); + } + } + + pub fn run_forever<F>(&mut self, mut callback: F) + where F: FnMut(Event) -> ControlFlow + { + loop { + let event = match self.receiver.recv() { + Ok(EventsLoopEvent::WinitEvent(e)) => e, + Ok(EventsLoopEvent::Panic(panic)) => { + eprintln!("resuming child thread unwind at: {:?}", Backtrace::new()); + panic::resume_unwind(panic) + }, + Err(_) => break, + }; + + let flow = callback(event); + match flow { + ControlFlow::Continue => continue, + ControlFlow::Break => break, + } + } + } + + pub fn create_proxy(&self) -> EventsLoopProxy { + EventsLoopProxy { + thread_msg_target: self.thread_msg_target, + sender: self.sender.clone(), + } + } + + /// Executes a function in the background thread. + /// + /// Note that we use a FnMut instead of a FnOnce because we're too lazy to create an equivalent + /// to the unstable FnBox. + /// + /// The `Inserted` can be used to inject a `WindowState` for the callback to use. The state is + /// removed automatically if the callback receives a `WM_CLOSE` message for the window. + pub(super) fn execute_in_thread<F>(&self, function: F) + where F: FnMut(Inserter) + Send + 'static + { + self.create_proxy().execute_in_thread(function) + } +} + +impl Drop for EventsLoop { + fn drop(&mut self) { + unsafe { + // Posting `WM_QUIT` will cause `GetMessage` to stop. + winuser::PostThreadMessageA(self.thread_id, winuser::WM_QUIT, 0, 0); + } + } +} + +#[derive(Clone)] +pub struct EventsLoopProxy { + thread_msg_target: HWND, + sender: mpsc::Sender<EventsLoopEvent>, +} + +unsafe impl Send for EventsLoopProxy {} +unsafe impl Sync for EventsLoopProxy {} + +impl EventsLoopProxy { + pub fn wakeup(&self) -> Result<(), EventsLoopClosed> { + self.sender.send(EventsLoopEvent::WinitEvent(Event::Awakened)).map_err(|_| EventsLoopClosed) + } + + /// Executes a function in the background thread. + /// + /// Note that we use FnMut instead of FnOnce because boxing FnOnce won't work on stable Rust + /// until 2030 when the design of Box is finally complete. + /// https://github.com/rust-lang/rust/issues/28796 + /// + /// The `Inserted` can be used to inject a `WindowState` for the callback to use. The state is + /// removed automatically if the callback receives a `WM_CLOSE` message for the window. + /// + /// Note that if you are using this to change some property of a window and updating + /// `WindowState` then you should call this within the lock of `WindowState`. Otherwise the + /// events may be sent to the other thread in different order to the one in which you set + /// `WindowState`, leaving them out of sync. + pub fn execute_in_thread<F>(&self, function: F) + where + F: FnMut(Inserter) + Send + 'static, + { + // We are using double-boxing here because it make casting back much easier + let double_box = Box::new(Box::new(function) as Box<FnMut(_)>); + let raw = Box::into_raw(double_box); + + let res = unsafe { + winuser::PostMessageW( + self.thread_msg_target, + *EXEC_MSG_ID, + raw as *mut () as usize as WPARAM, + 0, + ) + }; + assert!(res != 0, "PostMessage failed; is the messages queue full?"); + } +} + +lazy_static! { + // Message sent when we want to execute a closure in the thread. + // WPARAM contains a Box<Box<FnMut()>> that must be retrieved with `Box::from_raw`, + // and LPARAM is unused. + static ref EXEC_MSG_ID: u32 = { + unsafe { + winuser::RegisterWindowMessageA("Winit::ExecMsg\0".as_ptr() as LPCSTR) + } + }; + // Message sent by a `Window` when it wants to be destroyed by the main thread. + // WPARAM and LPARAM are unused. + pub static ref DESTROY_MSG_ID: u32 = { + unsafe { + winuser::RegisterWindowMessageA("Winit::DestroyMsg\0".as_ptr() as LPCSTR) + } + }; + // Message sent by a `Window` after creation if it has a DPI != 96. + // WPARAM is the the DPI (u32). LOWORD of LPARAM is width, and HIWORD is height. + pub static ref INITIAL_DPI_MSG_ID: u32 = { + unsafe { + winuser::RegisterWindowMessageA("Winit::InitialDpiMsg\0".as_ptr() as LPCSTR) + } + }; + static ref THREAD_EVENT_TARGET_WINDOW_CLASS: Vec<u16> = unsafe { + use std::ffi::OsStr; + use std::os::windows::ffi::OsStrExt; + + let class_name: Vec<_> = OsStr::new("Winit Thread Event Target") + .encode_wide() + .chain(Some(0).into_iter()) + .collect(); + + let class = winuser::WNDCLASSEXW { + cbSize: mem::size_of::<winuser::WNDCLASSEXW>() as UINT, + style: 0, + lpfnWndProc: Some(thread_event_target_callback), + cbClsExtra: 0, + cbWndExtra: 0, + hInstance: libloaderapi::GetModuleHandleW(ptr::null()), + hIcon: ptr::null_mut(), + hCursor: ptr::null_mut(), // must be null in order for cursor state to work properly + hbrBackground: ptr::null_mut(), + lpszMenuName: ptr::null(), + lpszClassName: class_name.as_ptr(), + hIconSm: ptr::null_mut(), + }; + + winuser::RegisterClassExW(&class); + + class_name + }; +} + +fn thread_event_target_window() -> HWND { + unsafe { + let window = winuser::CreateWindowExW( + winuser::WS_EX_NOACTIVATE | winuser::WS_EX_TRANSPARENT | winuser::WS_EX_LAYERED, + THREAD_EVENT_TARGET_WINDOW_CLASS.as_ptr(), + ptr::null_mut(), + 0, + 0, 0, + 0, 0, + ptr::null_mut(), + ptr::null_mut(), + libloaderapi::GetModuleHandleW(ptr::null()), + ptr::null_mut(), + ); + winuser::SetWindowLongPtrW( + window, + winuser::GWL_STYLE, + (winuser::WS_VISIBLE | winuser::WS_POPUP) as _ + ); + + window + } +} + +// There's no parameters passed to the callback function, so it needs to get its context stashed +// in a thread-local variable. +thread_local!(static CONTEXT_STASH: RefCell<Option<ThreadLocalData>> = RefCell::new(None)); +struct ThreadLocalData { + sender: mpsc::Sender<EventsLoopEvent>, + windows: HashMap<HWND, Arc<Mutex<WindowState>>>, + file_drop_handlers: HashMap<HWND, FileDropHandler>, // Each window has its own drop handler. + mouse_buttons_down: u32, + panic_error: Option<PanicError>, +} +type PanicError = Box<Any + Send + 'static>; + +// Utility function that dispatches an event on the current thread. +pub fn send_event(event: Event) { + CONTEXT_STASH.with(|context_stash| { + let context_stash = context_stash.borrow(); + + let _ = context_stash.as_ref().unwrap().sender.send(EventsLoopEvent::WinitEvent(event)); // Ignoring if closed + }); +} + +/// Capture mouse input, allowing `window` to receive mouse events when the cursor is outside of +/// the window. +unsafe fn capture_mouse(window: HWND) { + let set_capture = CONTEXT_STASH.with(|context_stash| { + let mut context_stash = context_stash.borrow_mut(); + if let Some(context_stash) = context_stash.as_mut() { + context_stash.mouse_buttons_down += 1; + true + } else { + false + } + }); + if set_capture { + winuser::SetCapture(window); + } +} + +/// Release mouse input, stopping windows on this thread from receiving mouse input when the cursor +/// is outside the window. +unsafe fn release_mouse() { + let release_capture = CONTEXT_STASH.with(|context_stash| { + let mut context_stash = context_stash.borrow_mut(); + if let Some(context_stash) = context_stash.as_mut() { + context_stash.mouse_buttons_down = context_stash.mouse_buttons_down.saturating_sub(1); + if context_stash.mouse_buttons_down == 0 { + return true; + } + } + false + }); + if release_capture { + winuser::ReleaseCapture(); + } +} + +pub unsafe fn run_catch_panic<F, R>(error: R, f: F) -> R + where F: panic::UnwindSafe + FnOnce() -> R +{ + // If a panic has been triggered, cancel all future operations in the function. + if CONTEXT_STASH.with(|stash| stash.borrow().as_ref().map(|s| s.panic_error.is_some()).unwrap_or(false)) { + return error; + } + + let callback_result = panic::catch_unwind(f); + match callback_result { + Ok(lresult) => lresult, + Err(err) => CONTEXT_STASH.with(|context_stash| { + let mut context_stash = context_stash.borrow_mut(); + if let Some(context_stash) = context_stash.as_mut() { + context_stash.panic_error = Some(err); + winuser::PostQuitMessage(-1); + } + error + }) + } +} + +/// Any window whose callback is configured to this function will have its events propagated +/// through the events loop of the thread the window was created in. +// +// This is the callback that is called by `DispatchMessage` in the events loop. +// +// Returning 0 tells the Win32 API that the message has been processed. +// FIXME: detect WM_DWMCOMPOSITIONCHANGED and call DwmEnableBlurBehindWindow if necessary +pub unsafe extern "system" fn callback( + window: HWND, + msg: UINT, + wparam: WPARAM, + lparam: LPARAM, +) -> LRESULT { + // Unwinding into foreign code is undefined behavior. So we catch any panics that occur in our + // code, and if a panic happens we cancel any future operations. + run_catch_panic(-1, || callback_inner(window, msg, wparam, lparam)) +} + +unsafe fn callback_inner( + window: HWND, + msg: UINT, + wparam: WPARAM, + lparam: LPARAM, +) -> LRESULT { + match msg { + winuser::WM_CREATE => { + use winapi::shared::winerror::{OLE_E_WRONGCOMPOBJ, RPC_E_CHANGED_MODE}; + let ole_init_result = ole2::OleInitialize(ptr::null_mut()); + // It is ok if the initialize result is `S_FALSE` because it might happen that + // multiple windows are created on the same thread. + if ole_init_result == OLE_E_WRONGCOMPOBJ { + panic!("OleInitialize failed! Result was: `OLE_E_WRONGCOMPOBJ`"); + } else if ole_init_result == RPC_E_CHANGED_MODE { + panic!("OleInitialize failed! Result was: `RPC_E_CHANGED_MODE`"); + } + + CONTEXT_STASH.with(|context_stash| { + let mut context_stash = context_stash.borrow_mut(); + + let drop_handlers = &mut context_stash.as_mut().unwrap().file_drop_handlers; + let new_handler = FileDropHandler::new(window); + let handler_interface_ptr = &mut (*new_handler.data).interface as LPDROPTARGET; + drop_handlers.insert(window, new_handler); + + assert_eq!(ole2::RegisterDragDrop(window, handler_interface_ptr), S_OK); + }); + 0 + }, + + winuser::WM_NCCREATE => { + enable_non_client_dpi_scaling(window); + winuser::DefWindowProcW(window, msg, wparam, lparam) + }, + + winuser::WM_CLOSE => { + use events::WindowEvent::CloseRequested; + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: CloseRequested + }); + 0 + }, + + winuser::WM_DESTROY => { + use events::WindowEvent::Destroyed; + CONTEXT_STASH.with(|context_stash| { + let mut context_stash = context_stash.borrow_mut(); + ole2::RevokeDragDrop(window); + let context_stash_mut = context_stash.as_mut().unwrap(); + context_stash_mut.file_drop_handlers.remove(&window); + context_stash_mut.windows.remove(&window); + }); + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: Destroyed + }); + 0 + }, + + winuser::WM_PAINT => { + use events::WindowEvent::Refresh; + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: Refresh, + }); + winuser::DefWindowProcW(window, msg, wparam, lparam) + }, + + // WM_MOVE supplies client area positions, so we send Moved here instead. + winuser::WM_WINDOWPOSCHANGED => { + use events::WindowEvent::Moved; + + let windowpos = lparam as *const winuser::WINDOWPOS; + if (*windowpos).flags & winuser::SWP_NOMOVE != winuser::SWP_NOMOVE { + let dpi_factor = get_hwnd_scale_factor(window); + let logical_position = LogicalPosition::from_physical( + ((*windowpos).x, (*windowpos).y), + dpi_factor, + ); + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: Moved(logical_position), + }); + } + + // This is necessary for us to still get sent WM_SIZE. + winuser::DefWindowProcW(window, msg, wparam, lparam) + }, + + winuser::WM_SIZE => { + use events::WindowEvent::Resized; + let w = LOWORD(lparam as DWORD) as u32; + let h = HIWORD(lparam as DWORD) as u32; + + // Wait for the parent thread to process the resize event before returning from the + // callback. + CONTEXT_STASH.with(|context_stash| { + let mut context_stash = context_stash.borrow_mut(); + let cstash = context_stash.as_mut().unwrap(); + + let dpi_factor = get_hwnd_scale_factor(window); + let logical_size = LogicalSize::from_physical((w, h), dpi_factor); + let event = Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: Resized(logical_size), + }; + + cstash.sender.send(EventsLoopEvent::WinitEvent(event)).ok(); + }); + 0 + }, + + winuser::WM_CHAR => { + use std::mem; + use events::WindowEvent::ReceivedCharacter; + let chr: char = mem::transmute(wparam as u32); + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: ReceivedCharacter(chr), + }); + 0 + }, + + // Prevents default windows menu hotkeys playing unwanted + // "ding" sounds. Alternatively could check for WM_SYSCOMMAND + // with wparam being SC_KEYMENU, but this may prevent some + // other unwanted default hotkeys as well. + winuser::WM_SYSCHAR => { + 0 + } + + winuser::WM_MOUSEMOVE => { + use events::WindowEvent::{CursorEntered, CursorMoved}; + let mouse_outside_window = CONTEXT_STASH.with(|context_stash| { + let mut context_stash = context_stash.borrow_mut(); + if let Some(context_stash) = context_stash.as_mut() { + if let Some(w) = context_stash.windows.get_mut(&window) { + let mut w = w.lock().unwrap(); + if !w.mouse_in_window { + w.mouse_in_window = true; + return true; + } + } + } + + false + }); + + if mouse_outside_window { + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: CursorEntered { device_id: DEVICE_ID }, + }); + + // Calling TrackMouseEvent in order to receive mouse leave events. + winuser::TrackMouseEvent(&mut winuser::TRACKMOUSEEVENT { + cbSize: mem::size_of::<winuser::TRACKMOUSEEVENT>() as DWORD, + dwFlags: winuser::TME_LEAVE, + hwndTrack: window, + dwHoverTime: winuser::HOVER_DEFAULT, + }); + } + + let x = windowsx::GET_X_LPARAM(lparam) as f64; + let y = windowsx::GET_Y_LPARAM(lparam) as f64; + let dpi_factor = get_hwnd_scale_factor(window); + let position = LogicalPosition::from_physical((x, y), dpi_factor); + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: CursorMoved { device_id: DEVICE_ID, position, modifiers: event::get_key_mods() }, + }); + + 0 + }, + + winuser::WM_MOUSELEAVE => { + use events::WindowEvent::CursorLeft; + let mouse_in_window = CONTEXT_STASH.with(|context_stash| { + let mut context_stash = context_stash.borrow_mut(); + if let Some(context_stash) = context_stash.as_mut() { + if let Some(w) = context_stash.windows.get_mut(&window) { + let mut w = w.lock().unwrap(); + if w.mouse_in_window { + w.mouse_in_window = false; + return true; + } + } + } + + false + }); + + if mouse_in_window { + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: CursorLeft { device_id: DEVICE_ID } + }); + } + + 0 + }, + + winuser::WM_MOUSEWHEEL => { + use events::MouseScrollDelta::LineDelta; + use events::TouchPhase; + + let value = (wparam >> 16) as i16; + let value = value as i32; + let value = value as f32 / winuser::WHEEL_DELTA as f32; + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: WindowEvent::MouseWheel { device_id: DEVICE_ID, delta: LineDelta(0.0, value), phase: TouchPhase::Moved, modifiers: event::get_key_mods() }, + }); + + 0 + }, + + winuser::WM_KEYDOWN | winuser::WM_SYSKEYDOWN => { + use events::ElementState::Pressed; + use events::VirtualKeyCode; + if msg == winuser::WM_SYSKEYDOWN && wparam as i32 == winuser::VK_F4 { + winuser::DefWindowProcW(window, msg, wparam, lparam) + } else { + if let Some((scancode, vkey)) = process_key_params(wparam, lparam) { + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: WindowEvent::KeyboardInput { + device_id: DEVICE_ID, + input: KeyboardInput { + state: Pressed, + scancode: scancode, + virtual_keycode: vkey, + modifiers: event::get_key_mods(), + } + } + }); + // Windows doesn't emit a delete character by default, but in order to make it + // consistent with the other platforms we'll emit a delete character here. + if vkey == Some(VirtualKeyCode::Delete) { + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: WindowEvent::ReceivedCharacter('\u{7F}'), + }); + } + } + 0 + } + }, + + winuser::WM_KEYUP | winuser::WM_SYSKEYUP => { + use events::ElementState::Released; + if let Some((scancode, vkey)) = process_key_params(wparam, lparam) { + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: WindowEvent::KeyboardInput { + device_id: DEVICE_ID, + input: KeyboardInput { + state: Released, + scancode: scancode, + virtual_keycode: vkey, + modifiers: event::get_key_mods(), + }, + } + }); + } + 0 + }, + + winuser::WM_LBUTTONDOWN => { + use events::WindowEvent::MouseInput; + use events::MouseButton::Left; + use events::ElementState::Pressed; + + capture_mouse(window); + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: MouseInput { device_id: DEVICE_ID, state: Pressed, button: Left, modifiers: event::get_key_mods() } + }); + 0 + }, + + winuser::WM_LBUTTONUP => { + use events::WindowEvent::MouseInput; + use events::MouseButton::Left; + use events::ElementState::Released; + + release_mouse(); + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: MouseInput { device_id: DEVICE_ID, state: Released, button: Left, modifiers: event::get_key_mods() } + }); + 0 + }, + + winuser::WM_RBUTTONDOWN => { + use events::WindowEvent::MouseInput; + use events::MouseButton::Right; + use events::ElementState::Pressed; + + capture_mouse(window); + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: MouseInput { device_id: DEVICE_ID, state: Pressed, button: Right, modifiers: event::get_key_mods() } + }); + 0 + }, + + winuser::WM_RBUTTONUP => { + use events::WindowEvent::MouseInput; + use events::MouseButton::Right; + use events::ElementState::Released; + + release_mouse(); + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: MouseInput { device_id: DEVICE_ID, state: Released, button: Right, modifiers: event::get_key_mods() } + }); + 0 + }, + + winuser::WM_MBUTTONDOWN => { + use events::WindowEvent::MouseInput; + use events::MouseButton::Middle; + use events::ElementState::Pressed; + + capture_mouse(window); + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: MouseInput { device_id: DEVICE_ID, state: Pressed, button: Middle, modifiers: event::get_key_mods() } + }); + 0 + }, + + winuser::WM_MBUTTONUP => { + use events::WindowEvent::MouseInput; + use events::MouseButton::Middle; + use events::ElementState::Released; + + release_mouse(); + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: MouseInput { device_id: DEVICE_ID, state: Released, button: Middle, modifiers: event::get_key_mods() } + }); + 0 + }, + + winuser::WM_XBUTTONDOWN => { + use events::WindowEvent::MouseInput; + use events::MouseButton::Other; + use events::ElementState::Pressed; + let xbutton = winuser::GET_XBUTTON_WPARAM(wparam); + + capture_mouse(window); + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: MouseInput { device_id: DEVICE_ID, state: Pressed, button: Other(xbutton as u8), modifiers: event::get_key_mods() } + }); + 0 + }, + + winuser::WM_XBUTTONUP => { + use events::WindowEvent::MouseInput; + use events::MouseButton::Other; + use events::ElementState::Released; + let xbutton = winuser::GET_XBUTTON_WPARAM(wparam); + + release_mouse(); + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: MouseInput { device_id: DEVICE_ID, state: Released, button: Other(xbutton as u8), modifiers: event::get_key_mods() } + }); + 0 + }, + + winuser::WM_INPUT_DEVICE_CHANGE => { + let event = match wparam as _ { + winuser::GIDC_ARRIVAL => DeviceEvent::Added, + winuser::GIDC_REMOVAL => DeviceEvent::Removed, + _ => unreachable!(), + }; + + send_event(Event::DeviceEvent { + device_id: wrap_device_id(lparam as _), + event, + }); + + winuser::DefWindowProcW(window, msg, wparam, lparam) + }, + + winuser::WM_INPUT => { + use events::DeviceEvent::{Motion, MouseMotion, MouseWheel, Button, Key}; + use events::MouseScrollDelta::LineDelta; + use events::ElementState::{Pressed, Released}; + + if let Some(data) = get_raw_input_data(lparam as _) { + let device_id = wrap_device_id(data.header.hDevice as _); + + if data.header.dwType == winuser::RIM_TYPEMOUSE { + let mouse = data.data.mouse(); + + if util::has_flag(mouse.usFlags, winuser::MOUSE_MOVE_RELATIVE) { + let x = mouse.lLastX as f64; + let y = mouse.lLastY as f64; + + if x != 0.0 { + send_event(Event::DeviceEvent { + device_id, + event: Motion { axis: 0, value: x } + }); + } + + if y != 0.0 { + send_event(Event::DeviceEvent { + device_id, + event: Motion { axis: 1, value: y } + }); + } + + if x != 0.0 || y != 0.0 { + send_event(Event::DeviceEvent { + device_id, + event: MouseMotion { delta: (x, y) } + }); + } + } + + if util::has_flag(mouse.usButtonFlags, winuser::RI_MOUSE_WHEEL) { + let delta = mouse.usButtonData as SHORT / winuser::WHEEL_DELTA; + send_event(Event::DeviceEvent { + device_id, + event: MouseWheel { delta: LineDelta(0.0, delta as f32) } + }); + } + + let button_state = get_raw_mouse_button_state(mouse.usButtonFlags); + // Left, middle, and right, respectively. + for (index, state) in button_state.iter().enumerate() { + if let Some(state) = *state { + // This gives us consistency with X11, since there doesn't + // seem to be anything else reasonable to do for a mouse + // button ID. + let button = (index + 1) as _; + send_event(Event::DeviceEvent { + device_id, + event: Button { + button, + state, + } + }); + } + } + } else if data.header.dwType == winuser::RIM_TYPEKEYBOARD { + let keyboard = data.data.keyboard(); + + let pressed = keyboard.Message == winuser::WM_KEYDOWN + || keyboard.Message == winuser::WM_SYSKEYDOWN; + let released = keyboard.Message == winuser::WM_KEYUP + || keyboard.Message == winuser::WM_SYSKEYUP; + + if pressed || released { + let state = if pressed { + Pressed + } else { + Released + }; + + let scancode = keyboard.MakeCode as _; + let extended = util::has_flag(keyboard.Flags, winuser::RI_KEY_E0 as _) + | util::has_flag(keyboard.Flags, winuser::RI_KEY_E1 as _); + if let Some((vkey, scancode)) = handle_extended_keys( + keyboard.VKey as _, + scancode, + extended, + ) { + let virtual_keycode = vkey_to_winit_vkey(vkey); + + send_event(Event::DeviceEvent { + device_id, + event: Key(KeyboardInput { + scancode, + state, + virtual_keycode, + modifiers: event::get_key_mods(), + }), + }); + } + } + } + } + + winuser::DefWindowProcW(window, msg, wparam, lparam) + }, + + winuser::WM_TOUCH => { + let pcount = LOWORD( wparam as DWORD ) as usize; + let mut inputs = Vec::with_capacity( pcount ); + inputs.set_len( pcount ); + let htouch = lparam as winuser::HTOUCHINPUT; + if winuser::GetTouchInputInfo( + htouch, + pcount as UINT, + inputs.as_mut_ptr(), + mem::size_of::<winuser::TOUCHINPUT>() as INT, + ) > 0 { + let dpi_factor = get_hwnd_scale_factor(window); + for input in &inputs { + let x = (input.x as f64) / 100f64; + let y = (input.y as f64) / 100f64; + let location = LogicalPosition::from_physical((x, y), dpi_factor); + send_event( Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: WindowEvent::Touch(Touch { + phase: + if input.dwFlags & winuser::TOUCHEVENTF_DOWN != 0 { + TouchPhase::Started + } else if input.dwFlags & winuser::TOUCHEVENTF_UP != 0 { + TouchPhase::Ended + } else if input.dwFlags & winuser::TOUCHEVENTF_MOVE != 0 { + TouchPhase::Moved + } else { + continue; + }, + location, + id: input.dwID as u64, + device_id: DEVICE_ID, + }) + }); + } + } + winuser::CloseTouchInputHandle( htouch ); + 0 + } + + winuser::WM_SETFOCUS => { + use events::WindowEvent::{Focused, CursorMoved}; + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: Focused(true) + }); + + let x = windowsx::GET_X_LPARAM(lparam) as f64; + let y = windowsx::GET_Y_LPARAM(lparam) as f64; + let dpi_factor = get_hwnd_scale_factor(window); + let position = LogicalPosition::from_physical((x, y), dpi_factor); + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: CursorMoved { device_id: DEVICE_ID, position, modifiers: event::get_key_mods() }, + }); + + 0 + }, + + winuser::WM_KILLFOCUS => { + use events::WindowEvent::Focused; + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: Focused(false) + }); + 0 + }, + + winuser::WM_SETCURSOR => { + let call_def_window_proc = CONTEXT_STASH.with(|context_stash| { + context_stash + .borrow() + .as_ref() + .and_then(|cstash| cstash.windows.get(&window)) + .map(|window_state_mutex| { + let window_state = window_state_mutex.lock().unwrap(); + if window_state.mouse_in_window { + let cursor = winuser::LoadCursorW( + ptr::null_mut(), + window_state.cursor.0, + ); + winuser::SetCursor(cursor); + false + } else { + true + } + }) + .unwrap_or(true) + }); + + if call_def_window_proc { + winuser::DefWindowProcW(window, msg, wparam, lparam) + } else { + 0 + } + }, + + winuser::WM_DROPFILES => { + // See `FileDropHandler` for implementation. + 0 + }, + + winuser::WM_GETMINMAXINFO => { + let mmi = lparam as *mut winuser::MINMAXINFO; + //(*mmi).max_position = winapi::shared::windef::POINT { x: -8, y: -8 }; // The upper left corner of the window if it were maximized on the primary monitor. + //(*mmi).max_size = winapi::shared::windef::POINT { x: .., y: .. }; // The dimensions of the primary monitor. + + CONTEXT_STASH.with(|context_stash| { + if let Some(cstash) = context_stash.borrow().as_ref() { + if let Some(wstash) = cstash.windows.get(&window) { + let window_state = wstash.lock().unwrap(); + + if window_state.min_size.is_some() || window_state.max_size.is_some() { + let style = winuser::GetWindowLongA(window, winuser::GWL_STYLE) as DWORD; + let ex_style = winuser::GetWindowLongA(window, winuser::GWL_EXSTYLE) as DWORD; + if let Some(min_size) = window_state.min_size { + let (width, height) = adjust_size(min_size, style, ex_style); + (*mmi).ptMinTrackSize = POINT { x: width as i32, y: height as i32 }; + } + if let Some(max_size) = window_state.max_size { + let (width, height) = adjust_size(max_size, style, ex_style); + (*mmi).ptMaxTrackSize = POINT { x: width as i32, y: height as i32 }; + } + } + } + } + }); + + 0 + }, + + // Only sent on Windows 8.1 or newer. On Windows 7 and older user has to log out to change + // DPI, therefore all applications are closed while DPI is changing. + winuser::WM_DPICHANGED => { + use events::WindowEvent::HiDpiFactorChanged; + + // This message actually provides two DPI values - x and y. However MSDN says that + // "you only need to use either the X-axis or the Y-axis value when scaling your + // application since they are the same". + // https://msdn.microsoft.com/en-us/library/windows/desktop/dn312083(v=vs.85).aspx + let new_dpi_x = u32::from(LOWORD(wparam as DWORD)); + let new_dpi_factor = dpi_to_scale_factor(new_dpi_x); + + let suppress_resize = CONTEXT_STASH.with(|context_stash| { + context_stash + .borrow() + .as_ref() + .and_then(|cstash| cstash.windows.get(&window)) + .map(|window_state_mutex| { + let mut window_state = window_state_mutex.lock().unwrap(); + let suppress_resize = window_state.saved_window_info + .as_mut() + .map(|saved_window_info| { + let dpi_changed = if !saved_window_info.is_fullscreen { + saved_window_info.dpi_factor.take() != Some(new_dpi_factor) + } else { + false + }; + !dpi_changed || saved_window_info.is_fullscreen + }) + .unwrap_or(false); + // Now we adjust the min/max dimensions for the new DPI. + if !suppress_resize { + let old_dpi_factor = window_state.dpi_factor; + window_state.update_min_max(old_dpi_factor, new_dpi_factor); + } + window_state.dpi_factor = new_dpi_factor; + suppress_resize + }) + .unwrap_or(false) + }); + + // This prevents us from re-applying DPI adjustment to the restored size after exiting + // fullscreen (the restored size is already DPI adjusted). + if !suppress_resize { + // Resize window to the size suggested by Windows. + let rect = &*(lparam as *const RECT); + winuser::SetWindowPos( + window, + ptr::null_mut(), + rect.left, + rect.top, + rect.right - rect.left, + rect.bottom - rect.top, + winuser::SWP_NOZORDER | winuser::SWP_NOACTIVATE, + ); + } + + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: HiDpiFactorChanged(new_dpi_factor), + }); + + 0 + }, + + _ => { + if msg == *DESTROY_MSG_ID { + winuser::DestroyWindow(window); + 0 + } else if msg == *INITIAL_DPI_MSG_ID { + use events::WindowEvent::HiDpiFactorChanged; + let scale_factor = dpi_to_scale_factor(wparam as u32); + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: HiDpiFactorChanged(scale_factor), + }); + // Automatically resize for actual DPI + let width = LOWORD(lparam as DWORD) as u32; + let height = HIWORD(lparam as DWORD) as u32; + let (adjusted_width, adjusted_height): (u32, u32) = PhysicalSize::from_logical( + (width, height), + scale_factor, + ).into(); + // We're not done yet! `SetWindowPos` needs the window size, not the client area size. + let mut rect = RECT { + top: 0, + left: 0, + bottom: adjusted_height as LONG, + right: adjusted_width as LONG, + }; + let dw_style = winuser::GetWindowLongA(window, winuser::GWL_STYLE) as DWORD; + let b_menu = !winuser::GetMenu(window).is_null() as BOOL; + let dw_style_ex = winuser::GetWindowLongA(window, winuser::GWL_EXSTYLE) as DWORD; + winuser::AdjustWindowRectEx(&mut rect, dw_style, b_menu, dw_style_ex); + let outer_x = (rect.right - rect.left).abs() as c_int; + let outer_y = (rect.top - rect.bottom).abs() as c_int; + winuser::SetWindowPos( + window, + ptr::null_mut(), + 0, + 0, + outer_x, + outer_y, + winuser::SWP_NOMOVE + | winuser::SWP_NOREPOSITION + | winuser::SWP_NOZORDER + | winuser::SWP_NOACTIVATE, + ); + 0 + } else { + winuser::DefWindowProcW(window, msg, wparam, lparam) + } + } + } +} + +pub unsafe extern "system" fn thread_event_target_callback( + window: HWND, + msg: UINT, + wparam: WPARAM, + lparam: LPARAM, +) -> LRESULT { + // See `callback` comment. + run_catch_panic(-1, || { + match msg { + _ if msg == *EXEC_MSG_ID => { + let mut function: Box<Box<FnMut()>> = Box::from_raw(wparam as usize as *mut _); + function(); + 0 + }, + _ => winuser::DefWindowProcW(window, msg, wparam, lparam) + } + }) +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/icon.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/icon.rs new file mode 100644 index 0000000..6ea1e99 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/icon.rs @@ -0,0 +1,114 @@ +use std::{self, mem, ptr}; +use std::os::windows::ffi::OsStrExt; +use std::path::Path; + +use winapi::ctypes::{c_int, wchar_t}; +use winapi::shared::minwindef::{BYTE, LPARAM, WPARAM}; +use winapi::shared::windef::{HICON, HWND}; +use winapi::um::winuser; + +use {Pixel, PIXEL_SIZE, Icon}; +use platform::platform::util; + +impl Pixel { + fn to_bgra(&mut self) { + mem::swap(&mut self.r, &mut self.b); + } +} + +#[derive(Debug)] +pub enum IconType { + Small = winuser::ICON_SMALL as isize, + Big = winuser::ICON_BIG as isize, +} + +#[derive(Clone, Debug)] +pub struct WinIcon { + pub handle: HICON, +} + +unsafe impl Send for WinIcon {} + +impl WinIcon { + #[allow(dead_code)] + pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, util::WinError> { + let wide_path: Vec<u16> = path.as_ref().as_os_str().encode_wide().collect(); + let handle = unsafe { + winuser::LoadImageW( + ptr::null_mut(), + wide_path.as_ptr() as *const wchar_t, + winuser::IMAGE_ICON, + 0, // 0 indicates that we want to use the actual width + 0, // and height + winuser::LR_LOADFROMFILE, + ) as HICON + }; + if !handle.is_null() { + Ok(WinIcon { handle }) + } else { + Err(util::WinError::from_last_error()) + } + } + + pub fn from_icon(icon: Icon) -> Result<Self, util::WinError> { + Self::from_rgba(icon.rgba, icon.width, icon.height) + } + + pub fn from_rgba(mut rgba: Vec<u8>, width: u32, height: u32) -> Result<Self, util::WinError> { + assert_eq!(rgba.len() % PIXEL_SIZE, 0); + let pixel_count = rgba.len() / PIXEL_SIZE; + assert_eq!(pixel_count, (width * height) as usize); + let mut and_mask = Vec::with_capacity(pixel_count); + let pixels = rgba.as_mut_ptr() as *mut Pixel; // how not to write idiomatic Rust + for pixel_index in 0..pixel_count { + let pixel = unsafe { &mut *pixels.offset(pixel_index as isize) }; + and_mask.push(pixel.a.wrapping_sub(std::u8::MAX)); // invert alpha channel + pixel.to_bgra(); + } + assert_eq!(and_mask.len(), pixel_count); + let handle = unsafe { + winuser::CreateIcon( + ptr::null_mut(), + width as c_int, + height as c_int, + 1, + (PIXEL_SIZE * 8) as BYTE, + and_mask.as_ptr() as *const BYTE, + rgba.as_ptr() as *const BYTE, + ) as HICON + }; + if !handle.is_null() { + Ok(WinIcon { handle }) + } else { + Err(util::WinError::from_last_error()) + } + } + + pub fn set_for_window(&self, hwnd: HWND, icon_type: IconType) { + unsafe { + winuser::SendMessageW( + hwnd, + winuser::WM_SETICON, + icon_type as WPARAM, + self.handle as LPARAM, + ); + } + } +} + +impl Drop for WinIcon { + fn drop(&mut self) { + unsafe { winuser::DestroyIcon(self.handle) }; + } +} + +pub fn unset_for_window(hwnd: HWND, icon_type: IconType) { + unsafe { + winuser::SendMessageW( + hwnd, + winuser::WM_SETICON, + icon_type as WPARAM, + 0 as LPARAM, + ); + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/mod.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/mod.rs new file mode 100644 index 0000000..16f9e14 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/mod.rs @@ -0,0 +1,73 @@ +#![cfg(target_os = "windows")] + +use winapi; +use winapi::shared::windef::HWND; + +pub use self::events_loop::{EventsLoop, EventsLoopProxy}; +pub use self::monitor::MonitorId; +pub use self::window::Window; + +#[derive(Clone, Default)] +pub struct PlatformSpecificWindowBuilderAttributes { + pub parent: Option<HWND>, + pub taskbar_icon: Option<::Icon>, + pub no_redirection_bitmap: bool, +} + +unsafe impl Send for PlatformSpecificWindowBuilderAttributes {} +unsafe impl Sync for PlatformSpecificWindowBuilderAttributes {} + +// Cursor name in UTF-16. Used to set cursor in `WM_SETCURSOR`. +#[derive(Debug, Clone, Copy)] +pub struct Cursor(pub *const winapi::ctypes::wchar_t); +unsafe impl Send for Cursor {} +unsafe impl Sync for Cursor {} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct DeviceId(u32); + +impl DeviceId { + pub unsafe fn dummy() -> Self { + DeviceId(0) + } +} + +impl DeviceId { + pub fn get_persistent_identifier(&self) -> Option<String> { + if self.0 != 0 { + raw_input::get_raw_input_device_name(self.0 as _) + } else { + None + } + } +} + +// Constant device ID, to be removed when this backend is updated to report real device IDs. +const DEVICE_ID: ::DeviceId = ::DeviceId(DeviceId(0)); + +fn wrap_device_id(id: u32) -> ::DeviceId { + ::DeviceId(DeviceId(id)) +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct WindowId(HWND); +unsafe impl Send for WindowId {} +unsafe impl Sync for WindowId {} + +impl WindowId { + pub unsafe fn dummy() -> Self { + use std::ptr::null_mut; + + WindowId(null_mut()) + } +} + +mod dpi; +mod drop_handler; +mod event; +mod events_loop; +mod icon; +mod monitor; +mod raw_input; +mod util; +mod window; diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/monitor.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/monitor.rs new file mode 100644 index 0000000..30394de --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/monitor.rs @@ -0,0 +1,173 @@ +use winapi::shared::minwindef::{BOOL, DWORD, LPARAM, TRUE}; +use winapi::shared::windef::{HDC, HMONITOR, HWND, LPRECT, POINT}; +use winapi::um::winnt::LONG; +use winapi::um::winuser; + +use std::{mem, ptr}; +use std::collections::VecDeque; + +use super::{EventsLoop, util}; +use dpi::{PhysicalPosition, PhysicalSize}; +use platform::platform::dpi::{dpi_to_scale_factor, get_monitor_dpi}; +use platform::platform::window::Window; + +/// Win32 implementation of the main `MonitorId` object. +#[derive(Debug, Clone)] +pub struct MonitorId { + /// Monitor handle. + hmonitor: HMonitor, + /// The system name of the monitor. + monitor_name: String, + /// True if this is the primary monitor. + primary: bool, + /// The position of the monitor in pixels on the desktop. + /// + /// A window that is positioned at these coordinates will overlap the monitor. + position: (i32, i32), + /// The current resolution in pixels on the monitor. + dimensions: (u32, u32), + /// DPI scale factor. + hidpi_factor: f64, +} + +// Send is not implemented for HMONITOR, we have to wrap it and implement it manually. +// For more info see: +// https://github.com/retep998/winapi-rs/issues/360 +// https://github.com/retep998/winapi-rs/issues/396 +#[derive(Debug, Clone)] +struct HMonitor(HMONITOR); + +unsafe impl Send for HMonitor {} + +unsafe extern "system" fn monitor_enum_proc( + hmonitor: HMONITOR, + _hdc: HDC, + _place: LPRECT, + data: LPARAM, +) -> BOOL { + let monitors = data as *mut VecDeque<MonitorId>; + (*monitors).push_back(MonitorId::from_hmonitor(hmonitor)); + TRUE // continue enumeration +} + +pub fn get_available_monitors() -> VecDeque<MonitorId> { + let mut monitors: VecDeque<MonitorId> = VecDeque::new(); + unsafe { + winuser::EnumDisplayMonitors( + ptr::null_mut(), + ptr::null_mut(), + Some(monitor_enum_proc), + &mut monitors as *mut _ as LPARAM, + ); + } + monitors +} + +pub fn get_primary_monitor() -> MonitorId { + const ORIGIN: POINT = POINT { x: 0, y: 0 }; + let hmonitor = unsafe { + winuser::MonitorFromPoint(ORIGIN, winuser::MONITOR_DEFAULTTOPRIMARY) + }; + MonitorId::from_hmonitor(hmonitor) +} + +impl EventsLoop { + // TODO: Investigate opportunities for caching + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + get_available_monitors() + } + + pub fn get_current_monitor(hwnd: HWND) -> MonitorId { + let hmonitor = unsafe { + winuser::MonitorFromWindow(hwnd, winuser::MONITOR_DEFAULTTONEAREST) + }; + MonitorId::from_hmonitor(hmonitor) + } + + pub fn get_primary_monitor(&self) -> MonitorId { + get_primary_monitor() + } +} + +impl Window { + pub fn get_available_monitors(&self) -> VecDeque<MonitorId> { + get_available_monitors() + } + + pub fn get_primary_monitor(&self) -> MonitorId { + get_primary_monitor() + } +} + +fn get_monitor_info(hmonitor: HMONITOR) -> Result<winuser::MONITORINFOEXW, util::WinError> { + let mut monitor_info: winuser::MONITORINFOEXW = unsafe { mem::uninitialized() }; + monitor_info.cbSize = mem::size_of::<winuser::MONITORINFOEXW>() as DWORD; + let status = unsafe { + winuser::GetMonitorInfoW( + hmonitor, + &mut monitor_info as *mut winuser::MONITORINFOEXW as *mut winuser::MONITORINFO, + ) + }; + if status == 0 { + Err(util::WinError::from_last_error()) + } else { + Ok(monitor_info) + } +} + +impl MonitorId { + pub(crate) fn from_hmonitor(hmonitor: HMONITOR) -> Self { + let monitor_info = get_monitor_info(hmonitor).expect("`GetMonitorInfoW` failed"); + let place = monitor_info.rcMonitor; + let dimensions = ( + (place.right - place.left) as u32, + (place.bottom - place.top) as u32, + ); + MonitorId { + hmonitor: HMonitor(hmonitor), + monitor_name: util::wchar_ptr_to_string(monitor_info.szDevice.as_ptr()), + primary: util::has_flag(monitor_info.dwFlags, winuser::MONITORINFOF_PRIMARY), + position: (place.left as i32, place.top as i32), + dimensions, + hidpi_factor: dpi_to_scale_factor(get_monitor_dpi(hmonitor).unwrap_or(96)), + } + } + + pub(crate) fn contains_point(&self, point: &POINT) -> bool { + let left = self.position.0 as LONG; + let right = left + self.dimensions.0 as LONG; + let top = self.position.1 as LONG; + let bottom = top + self.dimensions.1 as LONG; + point.x >= left && point.x <= right && point.y >= top && point.y <= bottom + } + + #[inline] + pub fn get_name(&self) -> Option<String> { + Some(self.monitor_name.clone()) + } + + #[inline] + pub fn get_native_identifier(&self) -> String { + self.monitor_name.clone() + } + + #[inline] + pub fn get_hmonitor(&self) -> HMONITOR { + self.hmonitor.0 + } + + #[inline] + pub fn get_dimensions(&self) -> PhysicalSize { + self.dimensions.into() + } + + #[inline] + pub fn get_position(&self) -> PhysicalPosition { + self.position.into() + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + self.hidpi_factor + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/raw_input.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/raw_input.rs new file mode 100644 index 0000000..2f6e905 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/raw_input.rs @@ -0,0 +1,235 @@ +use std::mem::{self, size_of}; +use std::ptr; + +use winapi::ctypes::wchar_t; +use winapi::shared::minwindef::{UINT, USHORT, TRUE}; +use winapi::shared::hidusage::{ + HID_USAGE_PAGE_GENERIC, + HID_USAGE_GENERIC_MOUSE, + HID_USAGE_GENERIC_KEYBOARD, +}; +use winapi::shared::windef::HWND; +use winapi::um::winnt::HANDLE; +use winapi::um::winuser::{ + self, + RAWINPUTDEVICELIST, + RID_DEVICE_INFO, + RID_DEVICE_INFO_MOUSE, + RID_DEVICE_INFO_KEYBOARD, + RID_DEVICE_INFO_HID, + RIM_TYPEMOUSE, + RIM_TYPEKEYBOARD, + RIM_TYPEHID, + RIDI_DEVICEINFO, + RIDI_DEVICENAME, + RAWINPUTDEVICE, + RIDEV_DEVNOTIFY, + RIDEV_INPUTSINK, + HRAWINPUT, + RAWINPUT, + RAWINPUTHEADER, + RID_INPUT, +}; + +use platform::platform::util; +use events::ElementState; + +#[allow(dead_code)] +pub fn get_raw_input_device_list() -> Option<Vec<RAWINPUTDEVICELIST>> { + let list_size = size_of::<RAWINPUTDEVICELIST>() as UINT; + + let mut num_devices = 0; + let status = unsafe { winuser::GetRawInputDeviceList( + ptr::null_mut(), + &mut num_devices, + list_size, + ) }; + + if status == UINT::max_value() { + return None; + } + + let mut buffer = Vec::with_capacity(num_devices as _); + + let num_stored = unsafe { winuser::GetRawInputDeviceList( + buffer.as_ptr() as _, + &mut num_devices, + list_size, + ) }; + + if num_stored == UINT::max_value() { + return None; + } + + debug_assert_eq!(num_devices, num_stored); + + unsafe { buffer.set_len(num_devices as _) }; + + Some(buffer) +} + +#[allow(dead_code)] +pub enum RawDeviceInfo { + Mouse(RID_DEVICE_INFO_MOUSE), + Keyboard(RID_DEVICE_INFO_KEYBOARD), + Hid(RID_DEVICE_INFO_HID), +} + +impl From<RID_DEVICE_INFO> for RawDeviceInfo { + fn from(info: RID_DEVICE_INFO) -> Self { + unsafe { + match info.dwType { + RIM_TYPEMOUSE => RawDeviceInfo::Mouse(*info.u.mouse()), + RIM_TYPEKEYBOARD => RawDeviceInfo::Keyboard(*info.u.keyboard()), + RIM_TYPEHID => RawDeviceInfo::Hid(*info.u.hid()), + _ => unreachable!(), + } + } + } +} + +#[allow(dead_code)] +pub fn get_raw_input_device_info(handle: HANDLE) -> Option<RawDeviceInfo> { + let mut info: RID_DEVICE_INFO = unsafe { mem::uninitialized() }; + let info_size = size_of::<RID_DEVICE_INFO>() as UINT; + + info.cbSize = info_size; + + let mut minimum_size = 0; + let status = unsafe { winuser::GetRawInputDeviceInfoW( + handle, + RIDI_DEVICEINFO, + &mut info as *mut _ as _, + &mut minimum_size, + ) }; + + if status == UINT::max_value() || status == 0 { + return None; + } + + debug_assert_eq!(info_size, status); + + Some(info.into()) +} + +pub fn get_raw_input_device_name(handle: HANDLE) -> Option<String> { + let mut minimum_size = 0; + let status = unsafe { winuser::GetRawInputDeviceInfoW( + handle, + RIDI_DEVICENAME, + ptr::null_mut(), + &mut minimum_size, + ) }; + + if status != 0 { + return None; + } + + let mut name: Vec<wchar_t> = Vec::with_capacity(minimum_size as _); + + let status = unsafe { winuser::GetRawInputDeviceInfoW( + handle, + RIDI_DEVICENAME, + name.as_ptr() as _, + &mut minimum_size, + ) }; + + if status == UINT::max_value() || status == 0 { + return None; + } + + debug_assert_eq!(minimum_size, status); + + unsafe { name.set_len(minimum_size as _) }; + + Some(util::wchar_to_string(&name)) +} + +pub fn register_raw_input_devices(devices: &[RAWINPUTDEVICE]) -> bool { + let device_size = size_of::<RAWINPUTDEVICE>() as UINT; + + let success = unsafe { winuser::RegisterRawInputDevices( + devices.as_ptr() as _, + devices.len() as _, + device_size, + ) }; + + success == TRUE +} + +pub fn register_all_mice_and_keyboards_for_raw_input(window_handle: HWND) -> bool { + // RIDEV_DEVNOTIFY: receive hotplug events + // RIDEV_INPUTSINK: receive events even if we're not in the foreground + let flags = RIDEV_DEVNOTIFY | RIDEV_INPUTSINK; + + let devices: [RAWINPUTDEVICE; 2] = [ + RAWINPUTDEVICE { + usUsagePage: HID_USAGE_PAGE_GENERIC, + usUsage: HID_USAGE_GENERIC_MOUSE, + dwFlags: flags, + hwndTarget: window_handle, + }, + RAWINPUTDEVICE { + usUsagePage: HID_USAGE_PAGE_GENERIC, + usUsage: HID_USAGE_GENERIC_KEYBOARD, + dwFlags: flags, + hwndTarget: window_handle, + }, + ]; + + register_raw_input_devices(&devices) +} + +pub fn get_raw_input_data(handle: HRAWINPUT) -> Option<RAWINPUT> { + let mut data: RAWINPUT = unsafe { mem::uninitialized() }; + let mut data_size = size_of::<RAWINPUT>() as UINT; + let header_size = size_of::<RAWINPUTHEADER>() as UINT; + + let status = unsafe { winuser::GetRawInputData( + handle, + RID_INPUT, + &mut data as *mut _ as _, + &mut data_size, + header_size, + ) }; + + if status == UINT::max_value() || status == 0 { + return None; + } + + Some(data) +} + + +fn button_flags_to_element_state(button_flags: USHORT, down_flag: USHORT, up_flag: USHORT) + -> Option<ElementState> +{ + // We assume the same button won't be simultaneously pressed and released. + if util::has_flag(button_flags, down_flag) { + Some(ElementState::Pressed) + } else if util::has_flag(button_flags, up_flag) { + Some(ElementState::Released) + } else { + None + } +} + +pub fn get_raw_mouse_button_state(button_flags: USHORT) -> [Option<ElementState>; 3] { + [ + button_flags_to_element_state( + button_flags, + winuser::RI_MOUSE_LEFT_BUTTON_DOWN, + winuser::RI_MOUSE_LEFT_BUTTON_UP, + ), + button_flags_to_element_state( + button_flags, + winuser::RI_MOUSE_MIDDLE_BUTTON_DOWN, + winuser::RI_MOUSE_MIDDLE_BUTTON_UP, + ), + button_flags_to_element_state( + button_flags, + winuser::RI_MOUSE_RIGHT_BUTTON_DOWN, + winuser::RI_MOUSE_RIGHT_BUTTON_UP, + ), + ] +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/util.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/util.rs new file mode 100644 index 0000000..a9f00ec --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/util.rs @@ -0,0 +1,117 @@ +use std::{self, mem, ptr, slice}; +use std::ops::BitAnd; + +use winapi::ctypes::wchar_t; +use winapi::shared::minwindef::{BOOL, DWORD}; +use winapi::shared::windef::{HWND, POINT, RECT}; +use winapi::um::errhandlingapi::GetLastError; +use winapi::um::winbase::{ + FormatMessageW, + FORMAT_MESSAGE_ALLOCATE_BUFFER, + FORMAT_MESSAGE_FROM_SYSTEM, + FORMAT_MESSAGE_IGNORE_INSERTS, + lstrlenW, + LocalFree, +}; +use winapi::um::winnt::{ + LPCWSTR, + MAKELANGID, + LANG_NEUTRAL, + SUBLANG_DEFAULT, +}; +use winapi::um::winuser; + +pub fn has_flag<T>(bitset: T, flag: T) -> bool +where T: + Copy + PartialEq + BitAnd<T, Output = T> +{ + bitset & flag == flag +} + +pub fn wchar_to_string(wchar: &[wchar_t]) -> String { + String::from_utf16_lossy(wchar).to_string() +} + +pub fn wchar_ptr_to_string(wchar: *const wchar_t) -> String { + let len = unsafe { lstrlenW(wchar) } as usize; + let wchar_slice = unsafe { slice::from_raw_parts(wchar, len) }; + wchar_to_string(wchar_slice) +} + +pub unsafe fn status_map<T, F: FnMut(&mut T) -> BOOL>(mut fun: F) -> Option<T> { + let mut data: T = mem::uninitialized(); + if fun(&mut data) != 0 { + Some(data) + } else { + None + } +} + +pub fn get_cursor_pos() -> Option<POINT> { + unsafe { status_map(|cursor_pos| winuser::GetCursorPos(cursor_pos)) } +} + +pub fn get_window_rect(hwnd: HWND) -> Option<RECT> { + unsafe { status_map(|rect| winuser::GetWindowRect(hwnd, rect)) } +} + +pub fn get_client_rect(hwnd: HWND) -> Option<RECT> { + unsafe { status_map(|rect| { + let mut top_left = mem::zeroed(); + if 0 == winuser::ClientToScreen(hwnd, &mut top_left) {return 0;}; + if 0 == winuser::GetClientRect(hwnd, rect) {return 0}; + rect.left += top_left.x; + rect.top += top_left.y; + rect.right += top_left.x; + rect.bottom += top_left.y; + 1 + }) } +} + +// This won't be needed anymore if we just add a derive to winapi. +pub fn rect_eq(a: &RECT, b: &RECT) -> bool { + let left_eq = a.left == b.left; + let right_eq = a.right == b.right; + let top_eq = a.top == b.top; + let bottom_eq = a.bottom == b.bottom; + left_eq && right_eq && top_eq && bottom_eq +} + +#[derive(Debug, Default, Clone, PartialEq, Eq)] +pub struct WinError(Option<String>); + +impl WinError { + pub fn from_last_error() -> Self { + WinError(unsafe { get_last_error() }) + } +} + +pub unsafe fn get_last_error() -> Option<String> { + let err = GetLastError(); + if err != 0 { + let buf_addr: LPCWSTR = { + let mut buf_addr: LPCWSTR = mem::uninitialized(); + FormatMessageW( + FORMAT_MESSAGE_ALLOCATE_BUFFER + | FORMAT_MESSAGE_FROM_SYSTEM + | FORMAT_MESSAGE_IGNORE_INSERTS, + ptr::null(), + err, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) as DWORD, + // This is a pointer to a pointer + &mut buf_addr as *mut LPCWSTR as *mut _, + 0, + ptr::null_mut(), + ); + buf_addr + }; + if !buf_addr.is_null() { + let buf_len = lstrlenW(buf_addr) as usize; + let buf_slice = std::slice::from_raw_parts(buf_addr, buf_len); + let string = wchar_to_string(buf_slice); + LocalFree(buf_addr as *mut _); + return Some(string); + } + } + None +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/window.rs b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/window.rs new file mode 100644 index 0000000..e772742 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/platform/windows/window.rs @@ -0,0 +1,1167 @@ +#![cfg(target_os = "windows")] + +use std::{io, mem, ptr}; +use std::cell::Cell; +use std::ffi::OsStr; +use std::os::windows::ffi::OsStrExt; +use std::sync::{Arc, Mutex}; +use std::sync::mpsc::channel; + +use winapi::ctypes::c_int; +use winapi::shared::minwindef::{BOOL, DWORD, FALSE, LPARAM, TRUE, UINT, WORD, WPARAM}; +use winapi::shared::windef::{HWND, LPPOINT, POINT, RECT}; +use winapi::um::{combaseapi, dwmapi, libloaderapi, winuser}; +use winapi::um::objbase::COINIT_MULTITHREADED; +use winapi::um::shobjidl_core::{CLSID_TaskbarList, ITaskbarList2}; +use winapi::um::wingdi::{CreateRectRgn, DeleteObject}; +use winapi::um::winnt::{LONG, LPCWSTR}; + +use { + CreationError, + Icon, + LogicalPosition, + LogicalSize, + MonitorId as RootMonitorId, + MouseCursor, + PhysicalSize, + WindowAttributes, +}; +use platform::platform::{Cursor, PlatformSpecificWindowBuilderAttributes, WindowId}; +use platform::platform::dpi::{dpi_to_scale_factor, get_hwnd_dpi}; +use platform::platform::events_loop::{self, EventsLoop, DESTROY_MSG_ID, INITIAL_DPI_MSG_ID}; +use platform::platform::events_loop::WindowState; +use platform::platform::icon::{self, IconType, WinIcon}; +use platform::platform::monitor::get_available_monitors; +use platform::platform::raw_input::register_all_mice_and_keyboards_for_raw_input; +use platform::platform::util; + +const WS_RESIZABLE: DWORD = winuser::WS_SIZEBOX | winuser::WS_MAXIMIZEBOX; + +/// The Win32 implementation of the main `Window` object. +pub struct Window { + /// Main handle for the window. + window: WindowWrapper, + + /// The current window state. + window_state: Arc<Mutex<WindowState>>, + + // The events loop proxy. + events_loop_proxy: events_loop::EventsLoopProxy, +} + +impl Window { + pub fn new( + events_loop: &EventsLoop, + w_attr: WindowAttributes, + pl_attr: PlatformSpecificWindowBuilderAttributes, + ) -> Result<Window, CreationError> { + let (tx, rx) = channel(); + let proxy = events_loop.create_proxy(); + events_loop.execute_in_thread(move |inserter| { + // We dispatch an `init` function because of code style. + // First person to remove the need for cloning here gets a cookie! + let win = unsafe { init(w_attr.clone(), pl_attr.clone(), inserter, proxy.clone()) }; + let _ = tx.send(win); + }); + rx.recv().unwrap() + } + + pub fn set_title(&self, text: &str) { + let text = OsStr::new(text) + .encode_wide() + .chain(Some(0).into_iter()) + .collect::<Vec<_>>(); + unsafe { + winuser::SetWindowTextW(self.window.0, text.as_ptr() as LPCWSTR); + } + } + + #[inline] + pub fn show(&self) { + unsafe { + winuser::ShowWindow(self.window.0, winuser::SW_SHOW); + } + } + + #[inline] + pub fn hide(&self) { + unsafe { + winuser::ShowWindow(self.window.0, winuser::SW_HIDE); + } + } + + pub(crate) fn get_position_physical(&self) -> Option<(i32, i32)> { + util::get_window_rect(self.window.0) + .map(|rect| (rect.left as i32, rect.top as i32)) + } + + #[inline] + pub fn get_position(&self) -> Option<LogicalPosition> { + self.get_position_physical() + .map(|physical_position| { + let dpi_factor = self.get_hidpi_factor(); + LogicalPosition::from_physical(physical_position, dpi_factor) + }) + } + + pub(crate) fn get_inner_position_physical(&self) -> Option<(i32, i32)> { + let mut position: POINT = unsafe { mem::zeroed() }; + if unsafe { winuser::ClientToScreen(self.window.0, &mut position) } == 0 { + return None; + } + Some((position.x, position.y)) + } + + #[inline] + pub fn get_inner_position(&self) -> Option<LogicalPosition> { + self.get_inner_position_physical() + .map(|physical_position| { + let dpi_factor = self.get_hidpi_factor(); + LogicalPosition::from_physical(physical_position, dpi_factor) + }) + } + + pub(crate) fn set_position_physical(&self, x: i32, y: i32) { + unsafe { + winuser::SetWindowPos( + self.window.0, + ptr::null_mut(), + x as c_int, + y as c_int, + 0, + 0, + winuser::SWP_ASYNCWINDOWPOS | winuser::SWP_NOZORDER | winuser::SWP_NOSIZE, + ); + winuser::UpdateWindow(self.window.0); + } + } + + #[inline] + pub fn set_position(&self, logical_position: LogicalPosition) { + let dpi_factor = self.get_hidpi_factor(); + let (x, y) = logical_position.to_physical(dpi_factor).into(); + self.set_position_physical(x, y); + } + + pub(crate) fn get_inner_size_physical(&self) -> Option<(u32, u32)> { + let mut rect: RECT = unsafe { mem::uninitialized() }; + if unsafe { winuser::GetClientRect(self.window.0, &mut rect) } == 0 { + return None; + } + Some(( + (rect.right - rect.left) as u32, + (rect.bottom - rect.top) as u32, + )) + } + + #[inline] + pub fn get_inner_size(&self) -> Option<LogicalSize> { + self.get_inner_size_physical() + .map(|physical_size| { + let dpi_factor = self.get_hidpi_factor(); + LogicalSize::from_physical(physical_size, dpi_factor) + }) + } + + pub(crate) fn get_outer_size_physical(&self) -> Option<(u32, u32)> { + util::get_window_rect(self.window.0) + .map(|rect| ( + (rect.right - rect.left) as u32, + (rect.bottom - rect.top) as u32, + )) + } + + #[inline] + pub fn get_outer_size(&self) -> Option<LogicalSize> { + self.get_outer_size_physical() + .map(|physical_size| { + let dpi_factor = self.get_hidpi_factor(); + LogicalSize::from_physical(physical_size, dpi_factor) + }) + } + + pub(crate) fn set_inner_size_physical(&self, x: u32, y: u32) { + unsafe { + let mut rect = RECT { + top: 0, + left: 0, + bottom: y as LONG, + right: x as LONG, + }; + let dw_style = winuser::GetWindowLongA(self.window.0, winuser::GWL_STYLE) as DWORD; + let b_menu = !winuser::GetMenu(self.window.0).is_null() as BOOL; + let dw_style_ex = winuser::GetWindowLongA(self.window.0, winuser::GWL_EXSTYLE) as DWORD; + winuser::AdjustWindowRectEx(&mut rect, dw_style, b_menu, dw_style_ex); + let outer_x = (rect.right - rect.left).abs() as c_int; + let outer_y = (rect.top - rect.bottom).abs() as c_int; + winuser::SetWindowPos( + self.window.0, + ptr::null_mut(), + 0, + 0, + outer_x, + outer_y, + winuser::SWP_ASYNCWINDOWPOS + | winuser::SWP_NOZORDER + | winuser::SWP_NOREPOSITION + | winuser::SWP_NOMOVE, + ); + winuser::UpdateWindow(self.window.0); + } + } + + #[inline] + pub fn set_inner_size(&self, logical_size: LogicalSize) { + let dpi_factor = self.get_hidpi_factor(); + let (width, height) = logical_size.to_physical(dpi_factor).into(); + self.set_inner_size_physical(width, height); + } + + pub(crate) fn set_min_dimensions_physical(&self, dimensions: Option<(u32, u32)>) { + self.window_state.lock().unwrap().min_size = dimensions.map(Into::into); + // Make windows re-check the window size bounds. + self.get_inner_size_physical() + .map(|(width, height)| self.set_inner_size_physical(width, height)); + } + + #[inline] + pub fn set_min_dimensions(&self, logical_size: Option<LogicalSize>) { + let physical_size = logical_size.map(|logical_size| { + let dpi_factor = self.get_hidpi_factor(); + logical_size.to_physical(dpi_factor).into() + }); + self.set_min_dimensions_physical(physical_size); + } + + pub fn set_max_dimensions_physical(&self, dimensions: Option<(u32, u32)>) { + self.window_state.lock().unwrap().max_size = dimensions.map(Into::into); + // Make windows re-check the window size bounds. + self.get_inner_size_physical() + .map(|(width, height)| self.set_inner_size_physical(width, height)); + } + + #[inline] + pub fn set_max_dimensions(&self, logical_size: Option<LogicalSize>) { + let physical_size = logical_size.map(|logical_size| { + let dpi_factor = self.get_hidpi_factor(); + logical_size.to_physical(dpi_factor).into() + }); + self.set_max_dimensions_physical(physical_size); + } + + #[inline] + pub fn set_resizable(&self, resizable: bool) { + let mut window_state = self.window_state.lock().unwrap(); + if mem::replace(&mut window_state.resizable, resizable) != resizable { + // If we're in fullscreen, update stored configuration but don't apply anything. + if window_state.fullscreen.is_none() { + let mut style = unsafe { + winuser::GetWindowLongW(self.window.0, winuser::GWL_STYLE) + }; + + if resizable { + style |= WS_RESIZABLE as LONG; + } else { + style &= !WS_RESIZABLE as LONG; + } + + unsafe { + winuser::SetWindowLongW(self.window.0, winuser::GWL_STYLE, style as _); + }; + } + } + } + + /// Returns the `hwnd` of this window. + #[inline] + pub fn hwnd(&self) -> HWND { + self.window.0 + } + + #[inline] + pub fn set_cursor(&self, cursor: MouseCursor) { + let cursor_id = Cursor(match cursor { + MouseCursor::Arrow | MouseCursor::Default => winuser::IDC_ARROW, + MouseCursor::Hand => winuser::IDC_HAND, + MouseCursor::Crosshair => winuser::IDC_CROSS, + MouseCursor::Text | MouseCursor::VerticalText => winuser::IDC_IBEAM, + MouseCursor::NotAllowed | MouseCursor::NoDrop => winuser::IDC_NO, + MouseCursor::Grab | MouseCursor::Grabbing | + MouseCursor::Move | MouseCursor::AllScroll => winuser::IDC_SIZEALL, + MouseCursor::EResize | MouseCursor::WResize | + MouseCursor::EwResize | MouseCursor::ColResize => winuser::IDC_SIZEWE, + MouseCursor::NResize | MouseCursor::SResize | + MouseCursor::NsResize | MouseCursor::RowResize => winuser::IDC_SIZENS, + MouseCursor::NeResize | MouseCursor::SwResize | + MouseCursor::NeswResize => winuser::IDC_SIZENESW, + MouseCursor::NwResize | MouseCursor::SeResize | + MouseCursor::NwseResize => winuser::IDC_SIZENWSE, + MouseCursor::Wait => winuser::IDC_WAIT, + MouseCursor::Progress => winuser::IDC_APPSTARTING, + MouseCursor::Help => winuser::IDC_HELP, + _ => winuser::IDC_ARROW, // use arrow for the missing cases. + }); + self.window_state.lock().unwrap().cursor = cursor_id; + self.events_loop_proxy.execute_in_thread(move |_| unsafe { + let cursor = winuser::LoadCursorW( + ptr::null_mut(), + cursor_id.0, + ); + winuser::SetCursor(cursor); + }); + } + + unsafe fn cursor_is_grabbed(&self) -> Result<bool, String> { + let mut client_rect: RECT = mem::uninitialized(); + let mut clip_rect: RECT = mem::uninitialized(); + if winuser::GetClientRect(self.window.0, &mut client_rect) == 0 { + return Err("`GetClientRect` failed".to_owned()); + } + // A `POINT` is two `LONG`s (x, y), and the `RECT` field after `left` is `top`. + if winuser::ClientToScreen(self.window.0, &mut client_rect.left as *mut _ as LPPOINT) == 0 { + return Err("`ClientToScreen` (left, top) failed".to_owned()); + } + if winuser::ClientToScreen(self.window.0, &mut client_rect.right as *mut _ as LPPOINT) == 0 { + return Err("`ClientToScreen` (right, bottom) failed".to_owned()); + } + if winuser::GetClipCursor(&mut clip_rect) == 0 { + return Err("`GetClipCursor` failed".to_owned()); + } + Ok(util::rect_eq(&client_rect, &clip_rect)) + } + + pub(crate) unsafe fn grab_cursor_inner(window: &WindowWrapper, grab: bool) -> Result<(), String> { + if grab { + let mut rect = mem::uninitialized(); + if winuser::GetClientRect(window.0, &mut rect) == 0 { + return Err("`GetClientRect` failed".to_owned()); + } + // A `POINT` is two `LONG`s (x, y), and the `RECT` field after `left` is `top`. + if winuser::ClientToScreen(window.0, &mut rect.left as *mut _ as LPPOINT) == 0 { + return Err("`ClientToScreen` (left, top) failed".to_owned()); + } + if winuser::ClientToScreen(window.0, &mut rect.right as *mut _ as LPPOINT) == 0 { + return Err("`ClientToScreen` (right, bottom) failed".to_owned()); + } + if winuser::ClipCursor(&rect) == 0 { + return Err("`ClipCursor` failed".to_owned()); + } + } else { + if winuser::ClipCursor(ptr::null()) == 0 { + return Err("`ClipCursor` failed".to_owned()); + } + } + Ok(()) + } + + #[inline] + pub fn grab_cursor(&self, grab: bool) -> Result<(), String> { + let currently_grabbed = unsafe { self.cursor_is_grabbed() }?; + let window_state_lock = self.window_state.lock().unwrap(); + if currently_grabbed == grab && grab == window_state_lock.cursor_grabbed { + return Ok(()); + } + let window = self.window.clone(); + let window_state = Arc::clone(&self.window_state); + let (tx, rx) = channel(); + self.events_loop_proxy.execute_in_thread(move |_| { + let result = unsafe { Self::grab_cursor_inner(&window, grab) }; + if result.is_ok() { + window_state.lock().unwrap().cursor_grabbed = grab; + } + let _ = tx.send(result); + }); + drop(window_state_lock); + rx.recv().unwrap() + } + + pub(crate) unsafe fn hide_cursor_inner(hide: bool) { + if hide { + winuser::ShowCursor(FALSE); + } else { + winuser::ShowCursor(TRUE); + } + } + + #[inline] + pub fn hide_cursor(&self, hide: bool) { + let window_state_lock = self.window_state.lock().unwrap(); + // We don't want to increment/decrement the display count more than once! + if hide == window_state_lock.cursor_hidden { return; } + let (tx, rx) = channel(); + let window_state = Arc::clone(&self.window_state); + self.events_loop_proxy.execute_in_thread(move |_| { + unsafe { Self::hide_cursor_inner(hide) }; + window_state.lock().unwrap().cursor_hidden = hide; + let _ = tx.send(()); + }); + drop(window_state_lock); + rx.recv().unwrap() + } + + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + self.window_state.lock().unwrap().dpi_factor + } + + fn set_cursor_position_physical(&self, x: i32, y: i32) -> Result<(), String> { + let mut point = POINT { x, y }; + unsafe { + if winuser::ClientToScreen(self.window.0, &mut point) == 0 { + return Err("`ClientToScreen` failed".to_owned()); + } + if winuser::SetCursorPos(point.x, point.y) == 0 { + return Err("`SetCursorPos` failed".to_owned()); + } + } + Ok(()) + } + + #[inline] + pub fn set_cursor_position(&self, logical_position: LogicalPosition) -> Result<(), String> { + let dpi_factor = self.get_hidpi_factor(); + let (x, y) = logical_position.to_physical(dpi_factor).into(); + self.set_cursor_position_physical(x, y) + } + + #[inline] + pub fn id(&self) -> WindowId { + WindowId(self.window.0) + } + + #[inline] + pub fn set_maximized(&self, maximized: bool) { + let mut window_state = self.window_state.lock().unwrap(); + if mem::replace(&mut window_state.maximized, maximized) != maximized { + // We only maximize if we're not in fullscreen. + if window_state.fullscreen.is_none() { + let window = self.window.clone(); + unsafe { + // `ShowWindow` resizes the window, so it must be called from the main thread. + self.events_loop_proxy.execute_in_thread(move |_| { + winuser::ShowWindow( + window.0, + if maximized { + winuser::SW_MAXIMIZE + } else { + winuser::SW_RESTORE + }, + ); + }); + } + } + } + } + + unsafe fn set_fullscreen_style(&self, window_state: &mut WindowState) -> (LONG, LONG) { + if window_state.fullscreen.is_none() || window_state.saved_window_info.is_none() { + let client_rect = util::get_client_rect(self.window.0).expect("client rect retrieval failed"); + let dpi_factor = Some(window_state.dpi_factor); + window_state.saved_window_info = Some(events_loop::SavedWindowInfo { + style: winuser::GetWindowLongW(self.window.0, winuser::GWL_STYLE), + ex_style: winuser::GetWindowLongW(self.window.0, winuser::GWL_EXSTYLE), + client_rect, + is_fullscreen: true, + dpi_factor, + }); + } + + // We sync the system maximized state here, it will be used when restoring + let mut placement: winuser::WINDOWPLACEMENT = mem::zeroed(); + placement.length = mem::size_of::<winuser::WINDOWPLACEMENT>() as u32; + winuser::GetWindowPlacement(self.window.0, &mut placement); + window_state.maximized = placement.showCmd == (winuser::SW_SHOWMAXIMIZED as u32); + let saved_window_info = window_state.saved_window_info.as_ref().unwrap(); + + (saved_window_info.style, saved_window_info.ex_style) + } + + unsafe fn restore_saved_window(&self, window_state_lock: &mut WindowState) { + let (client_rect, mut style, ex_style) = { + // 'saved_window_info' can be None if the window has never been + // in fullscreen mode before this method gets called. + if window_state_lock.saved_window_info.is_none() { + return; + } + + let saved_window_info = window_state_lock.saved_window_info.as_mut().unwrap(); + + // Reset original window style and size. The multiple window size/moves + // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be + // repainted. Better-looking methods welcome. + saved_window_info.is_fullscreen = false; + + let client_rect = saved_window_info.client_rect.clone(); + let (style, ex_style) = (saved_window_info.style, saved_window_info.ex_style); + (client_rect, style, ex_style) + }; + let window = self.window.clone(); + let window_state = Arc::clone(&self.window_state); + + let resizable = window_state_lock.resizable; + let decorations = window_state_lock.decorations; + let maximized = window_state_lock.maximized; + + // We're restoring the window to its size and position from before being fullscreened. + // `ShowWindow` resizes the window, so it must be called from the main thread. + self.events_loop_proxy.execute_in_thread(move |_| { + let _ = Self::grab_cursor_inner(&window, false); + + if resizable && decorations { + style |= WS_RESIZABLE as LONG; + } else { + style &= !WS_RESIZABLE as LONG; + } + winuser::SetWindowLongW(window.0, winuser::GWL_STYLE, style); + winuser::SetWindowLongW(window.0, winuser::GWL_EXSTYLE, ex_style); + + let mut rect = client_rect; + winuser::AdjustWindowRectEx(&mut rect, style as _, 0, ex_style as _); + + winuser::SetWindowPos( + window.0, + ptr::null_mut(), + rect.left, + rect.top, + rect.right - rect.left, + rect.bottom - rect.top, + winuser::SWP_ASYNCWINDOWPOS + | winuser::SWP_NOZORDER + | winuser::SWP_NOACTIVATE + | winuser::SWP_FRAMECHANGED, + ); + + // We apply any requested changes to maximization state that occurred while we were in fullscreen. + winuser::ShowWindow( + window.0, + if maximized { + winuser::SW_MAXIMIZE + } else { + winuser::SW_RESTORE + }, + ); + + mark_fullscreen(window.0, false); + + let window_state_lock = window_state.lock().unwrap(); + let _ = Self::grab_cursor_inner(&window, window_state_lock.cursor_grabbed); + }); + } + + #[inline] + pub fn set_fullscreen(&self, monitor: Option<RootMonitorId>) { + let mut window_state_lock = self.window_state.lock().unwrap(); + unsafe { + match &monitor { + &Some(RootMonitorId { ref inner }) => { + let (x, y): (i32, i32) = inner.get_position().into(); + let (width, height): (u32, u32) = inner.get_dimensions().into(); + let window = self.window.clone(); + let window_state = Arc::clone(&self.window_state); + + let (style, ex_style) = self.set_fullscreen_style(&mut window_state_lock); + self.events_loop_proxy.execute_in_thread(move |_| { + let _ = Self::grab_cursor_inner(&window, false); + + winuser::SetWindowLongW( + window.0, + winuser::GWL_STYLE, + ((style as DWORD) & !(winuser::WS_CAPTION | winuser::WS_THICKFRAME)) + as LONG, + ); + + winuser::SetWindowLongW( + window.0, + winuser::GWL_EXSTYLE, + ((ex_style as DWORD) + & !(winuser::WS_EX_DLGMODALFRAME | winuser::WS_EX_WINDOWEDGE + | winuser::WS_EX_CLIENTEDGE + | winuser::WS_EX_STATICEDGE)) + as LONG, + ); + + winuser::SetWindowPos( + window.0, + ptr::null_mut(), + x as c_int, + y as c_int, + width as c_int, + height as c_int, + winuser::SWP_ASYNCWINDOWPOS | winuser::SWP_NOZORDER + | winuser::SWP_NOACTIVATE + | winuser::SWP_FRAMECHANGED, + ); + + mark_fullscreen(window.0, true); + + let window_state_lock = window_state.lock().unwrap(); + let _ = Self::grab_cursor_inner(&window, window_state_lock.cursor_grabbed); + }); + } + &None => { + self.restore_saved_window(&mut window_state_lock); + } + } + } + + window_state_lock.fullscreen = monitor; + } + + #[inline] + pub fn set_decorations(&self, decorations: bool) { + let mut window_state = self.window_state.lock().unwrap(); + if mem::replace(&mut window_state.decorations, decorations) != decorations { + let style_flags = (winuser::WS_CAPTION | winuser::WS_THICKFRAME) as LONG; + let ex_style_flags = (winuser::WS_EX_WINDOWEDGE) as LONG; + + // if we are in fullscreen mode, we only change the saved window info + if window_state.fullscreen.is_some() { + let resizable = window_state.resizable; + let saved = window_state.saved_window_info.as_mut().unwrap(); + + if decorations { + saved.style = saved.style | style_flags; + saved.ex_style = saved.ex_style | ex_style_flags; + } else { + saved.style = saved.style & !style_flags; + saved.ex_style = saved.ex_style & !ex_style_flags; + } + if resizable { + saved.style |= WS_RESIZABLE as LONG; + } else { + saved.style &= !WS_RESIZABLE as LONG; + } + } else { + unsafe { + let mut rect = util::get_client_rect(self.window.0).expect("Get client rect failed!"); + + let mut style = winuser::GetWindowLongW(self.window.0, winuser::GWL_STYLE); + let mut ex_style = winuser::GetWindowLongW(self.window.0, winuser::GWL_EXSTYLE); + + if decorations { + style = style | style_flags; + ex_style = ex_style | ex_style_flags; + } else { + style = style & !style_flags; + ex_style = ex_style & !ex_style_flags; + } + + let window = self.window.clone(); + + self.events_loop_proxy.execute_in_thread(move |_| { + winuser::SetWindowLongW(window.0, winuser::GWL_STYLE, style); + winuser::SetWindowLongW(window.0, winuser::GWL_EXSTYLE, ex_style); + winuser::AdjustWindowRectEx(&mut rect, style as _, 0, ex_style as _); + + winuser::SetWindowPos( + window.0, + ptr::null_mut(), + rect.left, + rect.top, + rect.right - rect.left, + rect.bottom - rect.top, + winuser::SWP_ASYNCWINDOWPOS + | winuser::SWP_NOZORDER + | winuser::SWP_NOACTIVATE + | winuser::SWP_FRAMECHANGED, + ); + }); + } + } + } + } + + #[inline] + pub fn set_always_on_top(&self, always_on_top: bool) { + let mut window_state = self.window_state.lock().unwrap(); + if mem::replace(&mut window_state.always_on_top, always_on_top) != always_on_top { + let window = self.window.clone(); + self.events_loop_proxy.execute_in_thread(move |_| { + let insert_after = if always_on_top { + winuser::HWND_TOPMOST + } else { + winuser::HWND_NOTOPMOST + }; + unsafe { + winuser::SetWindowPos( + window.0, + insert_after, + 0, + 0, + 0, + 0, + winuser::SWP_ASYNCWINDOWPOS | winuser::SWP_NOMOVE | winuser::SWP_NOSIZE, + ); + winuser::UpdateWindow(window.0); + } + }); + } + } + + #[inline] + pub fn get_current_monitor(&self) -> RootMonitorId { + RootMonitorId { + inner: EventsLoop::get_current_monitor(self.window.0), + } + } + + #[inline] + pub fn set_window_icon(&self, mut window_icon: Option<Icon>) { + let window_icon = window_icon + .take() + .map(|icon| WinIcon::from_icon(icon).expect("Failed to create `ICON_SMALL`")); + if let Some(ref window_icon) = window_icon { + window_icon.set_for_window(self.window.0, IconType::Small); + } else { + icon::unset_for_window(self.window.0, IconType::Small); + } + self.window_state.lock().unwrap().window_icon = window_icon; + } + + #[inline] + pub fn set_taskbar_icon(&self, mut taskbar_icon: Option<Icon>) { + let taskbar_icon = taskbar_icon + .take() + .map(|icon| WinIcon::from_icon(icon).expect("Failed to create `ICON_BIG`")); + if let Some(ref taskbar_icon) = taskbar_icon { + taskbar_icon.set_for_window(self.window.0, IconType::Big); + } else { + icon::unset_for_window(self.window.0, IconType::Big); + } + self.window_state.lock().unwrap().taskbar_icon = taskbar_icon; + } + + #[inline] + pub fn set_ime_spot(&self, _logical_spot: LogicalPosition) { + unimplemented!(); + } +} + +impl Drop for Window { + #[inline] + fn drop(&mut self) { + unsafe { + // The window must be destroyed from the same thread that created it, so we send a + // custom message to be handled by our callback to do the actual work. + winuser::PostMessageW(self.window.0, *DESTROY_MSG_ID, 0, 0); + } + } +} + +/// A simple non-owning wrapper around a window. +#[doc(hidden)] +#[derive(Clone)] +pub struct WindowWrapper(HWND); + +// Send and Sync are not implemented for HWND and HDC, we have to wrap it and implement them manually. +// For more info see: +// https://github.com/retep998/winapi-rs/issues/360 +// https://github.com/retep998/winapi-rs/issues/396 +unsafe impl Sync for WindowWrapper {} +unsafe impl Send for WindowWrapper {} + +pub unsafe fn adjust_size( + physical_size: PhysicalSize, + style: DWORD, + ex_style: DWORD, +) -> (LONG, LONG) { + let (width, height): (u32, u32) = physical_size.into(); + let mut rect = RECT { + left: 0, + right: width as LONG, + top: 0, + bottom: height as LONG, + }; + winuser::AdjustWindowRectEx(&mut rect, style, 0, ex_style); + (rect.right - rect.left, rect.bottom - rect.top) +} + +unsafe fn init( + mut attributes: WindowAttributes, + mut pl_attribs: PlatformSpecificWindowBuilderAttributes, + inserter: events_loop::Inserter, + events_loop_proxy: events_loop::EventsLoopProxy, +) -> Result<Window, CreationError> { + let title = OsStr::new(&attributes.title) + .encode_wide() + .chain(Some(0).into_iter()) + .collect::<Vec<_>>(); + + let window_icon = { + let icon = attributes.window_icon + .take() + .map(WinIcon::from_icon); + if icon.is_some() { + Some(icon.unwrap().map_err(|err| { + CreationError::OsError(format!("Failed to create `ICON_SMALL`: {:?}", err)) + })?) + } else { + None + } + }; + let taskbar_icon = { + let icon = pl_attribs.taskbar_icon + .take() + .map(WinIcon::from_icon); + if icon.is_some() { + Some(icon.unwrap().map_err(|err| { + CreationError::OsError(format!("Failed to create `ICON_BIG`: {:?}", err)) + })?) + } else { + None + } + }; + + // registering the window class + let class_name = register_window_class(&window_icon, &taskbar_icon); + + let guessed_dpi_factor = { + let monitors = get_available_monitors(); + let dpi_factor = if !monitors.is_empty() { + let mut dpi_factor = Some(monitors[0].get_hidpi_factor()); + for monitor in &monitors { + if Some(monitor.get_hidpi_factor()) != dpi_factor { + dpi_factor = None; + } + } + dpi_factor + } else { + return Err(CreationError::OsError(format!("No monitors were detected."))); + }; + dpi_factor.unwrap_or_else(|| { + util::get_cursor_pos() + .and_then(|cursor_pos| { + let mut dpi_factor = None; + for monitor in &monitors { + if monitor.contains_point(&cursor_pos) { + dpi_factor = Some(monitor.get_hidpi_factor()); + break; + } + } + dpi_factor + }) + .unwrap_or(1.0) + }) + }; + info!("Guessed window DPI factor: {}", guessed_dpi_factor); + + let dimensions = attributes.dimensions.unwrap_or_else(|| (1024, 768).into()); + let (width, height): (u32, u32) = dimensions.to_physical(guessed_dpi_factor).into(); + // building a RECT object with coordinates + let mut rect = RECT { + left: 0, + right: width as LONG, + top: 0, + bottom: height as LONG, + }; + + // computing the style and extended style of the window + let (mut ex_style, style) = if !attributes.decorations { + (winuser::WS_EX_APPWINDOW, + //winapi::WS_POPUP is incompatible with winapi::WS_CHILD + if pl_attribs.parent.is_some() { + winuser::WS_CLIPSIBLINGS | winuser::WS_CLIPCHILDREN + } + else { + winuser::WS_POPUP | winuser::WS_CLIPSIBLINGS | winuser::WS_CLIPCHILDREN + } + ) + } else { + (winuser::WS_EX_APPWINDOW | winuser::WS_EX_WINDOWEDGE, + winuser::WS_OVERLAPPEDWINDOW | winuser::WS_CLIPSIBLINGS | winuser::WS_CLIPCHILDREN) + }; + + if attributes.always_on_top { + ex_style |= winuser::WS_EX_TOPMOST; + } + if pl_attribs.no_redirection_bitmap { + ex_style |= winuser::WS_EX_NOREDIRECTIONBITMAP; + } + if attributes.transparent && attributes.decorations { + ex_style |= winuser::WS_EX_LAYERED; + } + + // adjusting the window coordinates using the style + winuser::AdjustWindowRectEx(&mut rect, style, 0, ex_style); + + // creating the real window this time, by using the functions in `extra_functions` + let real_window = { + let (adjusted_width, adjusted_height) = if attributes.dimensions.is_some() { + let min_dimensions = attributes.min_dimensions + .map(|logical_size| PhysicalSize::from_logical(logical_size, guessed_dpi_factor)) + .map(|physical_size| adjust_size(physical_size, style, ex_style)) + .unwrap_or((0, 0)); + let max_dimensions = attributes.max_dimensions + .map(|logical_size| PhysicalSize::from_logical(logical_size, guessed_dpi_factor)) + .map(|physical_size| adjust_size(physical_size, style, ex_style)) + .unwrap_or((c_int::max_value(), c_int::max_value())); + ( + Some((rect.right - rect.left).min(max_dimensions.0).max(min_dimensions.0)), + Some((rect.bottom - rect.top).min(max_dimensions.1).max(min_dimensions.1)) + ) + } else { + (None, None) + }; + + let mut style = if !attributes.visible { + style + } else { + style | winuser::WS_VISIBLE + }; + + if !attributes.resizable { + style &= !WS_RESIZABLE; + } + + if pl_attribs.parent.is_some() { + style |= winuser::WS_CHILD; + } + + let handle = winuser::CreateWindowExW(ex_style | winuser::WS_EX_ACCEPTFILES, + class_name.as_ptr(), + title.as_ptr() as LPCWSTR, + style | winuser::WS_CLIPSIBLINGS | winuser::WS_CLIPCHILDREN, + winuser::CW_USEDEFAULT, winuser::CW_USEDEFAULT, + adjusted_width.unwrap_or(winuser::CW_USEDEFAULT), + adjusted_height.unwrap_or(winuser::CW_USEDEFAULT), + pl_attribs.parent.unwrap_or(ptr::null_mut()), + ptr::null_mut(), + libloaderapi::GetModuleHandleW(ptr::null()), + ptr::null_mut(), + ); + + if handle.is_null() { + return Err(CreationError::OsError(format!("CreateWindowEx function failed: {}", + format!("{}", io::Error::last_os_error())))); + } + + WindowWrapper(handle) + }; + + // Set up raw input + register_all_mice_and_keyboards_for_raw_input(real_window.0); + + // Register for touch events if applicable + { + let digitizer = winuser::GetSystemMetrics( winuser::SM_DIGITIZER ) as u32; + if digitizer & winuser::NID_READY != 0 { + winuser::RegisterTouchWindow( real_window.0, winuser::TWF_WANTPALM ); + } + } + + let dpi = get_hwnd_dpi(real_window.0); + let dpi_factor = dpi_to_scale_factor(dpi); + if dpi_factor != guessed_dpi_factor { + let (width, height): (u32, u32) = dimensions.into(); + let mut packed_dimensions = 0; + // MAKELPARAM isn't provided by winapi yet. + let ptr = &mut packed_dimensions as *mut LPARAM as *mut WORD; + *ptr.offset(0) = width as WORD; + *ptr.offset(1) = height as WORD; + winuser::PostMessageW( + real_window.0, + *INITIAL_DPI_MSG_ID, + dpi as WPARAM, + packed_dimensions, + ); + } + + let window_state = { + let max_size = attributes.max_dimensions + .map(|logical_size| PhysicalSize::from_logical(logical_size, dpi_factor)); + let min_size = attributes.min_dimensions + .map(|logical_size| PhysicalSize::from_logical(logical_size, dpi_factor)); + let mut window_state = events_loop::WindowState { + cursor: Cursor(winuser::IDC_ARROW), // use arrow by default + cursor_grabbed: false, + cursor_hidden: false, + max_size, + min_size, + mouse_in_window: false, + saved_window_info: None, + dpi_factor, + fullscreen: attributes.fullscreen.clone(), + window_icon, + taskbar_icon, + decorations: attributes.decorations, + maximized: attributes.maximized, + resizable: attributes.resizable, + always_on_top: attributes.always_on_top, + }; + // Creating a mutex to track the current window state + Arc::new(Mutex::new(window_state)) + }; + + // making the window transparent + if attributes.transparent && !pl_attribs.no_redirection_bitmap { + let region = CreateRectRgn(0, 0, -1, -1); // makes the window transparent + + let bb = dwmapi::DWM_BLURBEHIND { + dwFlags: dwmapi::DWM_BB_ENABLE | dwmapi::DWM_BB_BLURREGION, + fEnable: 1, + hRgnBlur: region, + fTransitionOnMaximized: 0, + }; + + dwmapi::DwmEnableBlurBehindWindow(real_window.0, &bb); + DeleteObject(region as _); + + if attributes.decorations { + // HACK: When opaque (opacity 255), there is a trail whenever + // the transparent window is moved. By reducing it to 254, + // the window is rendered properly. + let opacity = 254; + + // The color key can be any value except for black (0x0). + let color_key = 0x0030c100; + + winuser::SetLayeredWindowAttributes(real_window.0, color_key, opacity, winuser::LWA_ALPHA); + } + } + + let win = Window { + window: real_window, + window_state, + events_loop_proxy, + }; + + win.set_maximized(attributes.maximized); + if let Some(_) = attributes.fullscreen { + win.set_fullscreen(attributes.fullscreen); + force_window_active(win.window.0); + } + + inserter.insert(win.window.0, win.window_state.clone()); + + Ok(win) +} + +unsafe fn register_window_class( + window_icon: &Option<WinIcon>, + taskbar_icon: &Option<WinIcon>, +) -> Vec<u16> { + let class_name: Vec<_> = OsStr::new("Window Class") + .encode_wide() + .chain(Some(0).into_iter()) + .collect(); + + let h_icon = taskbar_icon + .as_ref() + .map(|icon| icon.handle) + .unwrap_or(ptr::null_mut()); + let h_icon_small = window_icon + .as_ref() + .map(|icon| icon.handle) + .unwrap_or(ptr::null_mut()); + + let class = winuser::WNDCLASSEXW { + cbSize: mem::size_of::<winuser::WNDCLASSEXW>() as UINT, + style: winuser::CS_HREDRAW | winuser::CS_VREDRAW | winuser::CS_OWNDC, + lpfnWndProc: Some(events_loop::callback), + cbClsExtra: 0, + cbWndExtra: 0, + hInstance: libloaderapi::GetModuleHandleW(ptr::null()), + hIcon: h_icon, + hCursor: ptr::null_mut(), // must be null in order for cursor state to work properly + hbrBackground: ptr::null_mut(), + lpszMenuName: ptr::null(), + lpszClassName: class_name.as_ptr(), + hIconSm: h_icon_small, + }; + + // We ignore errors because registering the same window class twice would trigger + // an error, and because errors here are detected during CreateWindowEx anyway. + // Also since there is no weird element in the struct, there is no reason for this + // call to fail. + winuser::RegisterClassExW(&class); + + class_name +} + +struct ComInitialized(*mut ()); +impl Drop for ComInitialized { + fn drop(&mut self) { + unsafe { combaseapi::CoUninitialize() }; + } +} + +thread_local!{ + static COM_INITIALIZED: ComInitialized = { + unsafe { + combaseapi::CoInitializeEx(ptr::null_mut(), COINIT_MULTITHREADED); + ComInitialized(ptr::null_mut()) + } + }; + + static TASKBAR_LIST: Cell<*mut ITaskbarList2> = Cell::new(ptr::null_mut()); +} + +pub fn com_initialized() { + COM_INITIALIZED.with(|_| {}); +} + +// Reference Implementation: +// https://github.com/chromium/chromium/blob/f18e79d901f56154f80eea1e2218544285e62623/ui/views/win/fullscreen_handler.cc +// +// As per MSDN marking the window as fullscreen should ensure that the +// taskbar is moved to the bottom of the Z-order when the fullscreen window +// is activated. If the window is not fullscreen, the Shell falls back to +// heuristics to determine how the window should be treated, which means +// that it could still consider the window as fullscreen. :( +unsafe fn mark_fullscreen(handle: HWND, fullscreen: bool) { + com_initialized(); + + TASKBAR_LIST.with(|task_bar_list_ptr| { + let mut task_bar_list = task_bar_list_ptr.get(); + + if task_bar_list == ptr::null_mut() { + use winapi::shared::winerror::S_OK; + use winapi::Interface; + + let hr = combaseapi::CoCreateInstance( + &CLSID_TaskbarList, + ptr::null_mut(), + combaseapi::CLSCTX_ALL, + &ITaskbarList2::uuidof(), + &mut task_bar_list as *mut _ as *mut _, + ); + + if hr != S_OK || (*task_bar_list).HrInit() != S_OK { + // In some old windows, the taskbar object could not be created, we just ignore it + return; + } + task_bar_list_ptr.set(task_bar_list) + } + + task_bar_list = task_bar_list_ptr.get(); + (*task_bar_list).MarkFullscreenWindow(handle, if fullscreen { 1 } else { 0 }); + }) +} + +unsafe fn force_window_active(handle: HWND) { + // In some situation, calling SetForegroundWindow could not bring up the window, + // This is a little hack which can "steal" the foreground window permission + // We only call this function in the window creation, so it should be fine. + // See : https://stackoverflow.com/questions/10740346/setforegroundwindow-only-working-while-visual-studio-is-open + let alt_sc = winuser::MapVirtualKeyW(winuser::VK_MENU as _, winuser::MAPVK_VK_TO_VSC); + + let mut inputs: [winuser::INPUT; 2] = mem::zeroed(); + inputs[0].type_ = winuser::INPUT_KEYBOARD; + inputs[0].u.ki_mut().wVk = winuser::VK_LMENU as _; + inputs[0].u.ki_mut().wScan = alt_sc as _; + inputs[0].u.ki_mut().dwFlags = winuser::KEYEVENTF_EXTENDEDKEY; + + inputs[1].type_ = winuser::INPUT_KEYBOARD; + inputs[1].u.ki_mut().wVk = winuser::VK_LMENU as _; + inputs[1].u.ki_mut().wScan = alt_sc as _; + inputs[1].u.ki_mut().dwFlags = winuser::KEYEVENTF_EXTENDEDKEY | winuser::KEYEVENTF_KEYUP; + + // Simulate a key press and release + winuser::SendInput( + inputs.len() as _, + inputs.as_mut_ptr(), + mem::size_of::<winuser::INPUT>() as _, + ); + + winuser::SetForegroundWindow(handle); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/src/window.rs b/third_party/cargo/vendor/winit-0.18.1/src/window.rs new file mode 100644 index 0000000..cf36044 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/src/window.rs @@ -0,0 +1,494 @@ +use std::collections::vec_deque::IntoIter as VecDequeIter; + +use { + CreationError, + EventsLoop, + Icon, + LogicalPosition, + LogicalSize, + MouseCursor, + PhysicalPosition, + PhysicalSize, + platform, + Window, + WindowBuilder, + WindowId, +}; + +impl WindowBuilder { + /// Initializes a new `WindowBuilder` with default values. + #[inline] + pub fn new() -> WindowBuilder { + WindowBuilder { + window: Default::default(), + platform_specific: Default::default(), + } + } + + /// Requests the window to be of specific dimensions. + #[inline] + pub fn with_dimensions(mut self, size: LogicalSize) -> WindowBuilder { + self.window.dimensions = Some(size); + self + } + + /// Sets a minimum dimension size for the window + #[inline] + pub fn with_min_dimensions(mut self, min_size: LogicalSize) -> WindowBuilder { + self.window.min_dimensions = Some(min_size); + self + } + + /// Sets a maximum dimension size for the window + #[inline] + pub fn with_max_dimensions(mut self, max_size: LogicalSize) -> WindowBuilder { + self.window.max_dimensions = Some(max_size); + self + } + + /// Sets whether the window is resizable or not + /// + /// Note that making the window unresizable doesn't exempt you from handling `Resized`, as that event can still be + /// triggered by DPI scaling, entering fullscreen mode, etc. + /// + /// ## Platform-specific + /// + /// This only has an effect on desktop platforms. + /// + /// Due to a bug in XFCE, this has no effect on Xfwm. + #[inline] + pub fn with_resizable(mut self, resizable: bool) -> WindowBuilder { + self.window.resizable = resizable; + self + } + + /// Requests a specific title for the window. + #[inline] + pub fn with_title<T: Into<String>>(mut self, title: T) -> WindowBuilder { + self.window.title = title.into(); + self + } + + /// Sets the window fullscreen state. None means a normal window, Some(MonitorId) + /// means a fullscreen window on that specific monitor + #[inline] + pub fn with_fullscreen(mut self, monitor: Option<MonitorId>) -> WindowBuilder { + self.window.fullscreen = monitor; + self + } + + /// Requests maximized mode. + #[inline] + pub fn with_maximized(mut self, maximized: bool) -> WindowBuilder { + self.window.maximized = maximized; + self + } + + /// Sets whether the window will be initially hidden or visible. + #[inline] + pub fn with_visibility(mut self, visible: bool) -> WindowBuilder { + self.window.visible = visible; + self + } + + /// Sets whether the background of the window should be transparent. + #[inline] + pub fn with_transparency(mut self, transparent: bool) -> WindowBuilder { + self.window.transparent = transparent; + self + } + + /// Sets whether the window should have a border, a title bar, etc. + #[inline] + pub fn with_decorations(mut self, decorations: bool) -> WindowBuilder { + self.window.decorations = decorations; + self + } + + /// Sets whether or not the window will always be on top of other windows. + #[inline] + pub fn with_always_on_top(mut self, always_on_top: bool) -> WindowBuilder { + self.window.always_on_top = always_on_top; + self + } + + /// Sets the window icon. On Windows and X11, this is typically the small icon in the top-left + /// corner of the titlebar. + /// + /// ## Platform-specific + /// + /// This only has an effect on Windows and X11. + /// + /// On Windows, this sets `ICON_SMALL`. The base size for a window icon is 16x16, but it's + /// recommended to account for screen scaling and pick a multiple of that, i.e. 32x32. + /// + /// X11 has no universal guidelines for icon sizes, so you're at the whims of the WM. That + /// said, it's usually in the same ballpark as on Windows. + #[inline] + pub fn with_window_icon(mut self, window_icon: Option<Icon>) -> WindowBuilder { + self.window.window_icon = window_icon; + self + } + + /// Enables multitouch. + #[inline] + pub fn with_multitouch(mut self) -> WindowBuilder { + self.window.multitouch = true; + self + } + + /// Builds the window. + /// + /// Error should be very rare and only occur in case of permission denied, incompatible system, + /// out of memory, etc. + #[inline] + pub fn build(mut self, events_loop: &EventsLoop) -> Result<Window, CreationError> { + self.window.dimensions = Some(self.window.dimensions.unwrap_or_else(|| { + if let Some(ref monitor) = self.window.fullscreen { + // resizing the window to the dimensions of the monitor when fullscreen + LogicalSize::from_physical(monitor.get_dimensions(), 1.0) + } else { + // default dimensions + (1024, 768).into() + } + })); + + // building + platform::Window::new( + &events_loop.events_loop, + self.window, + self.platform_specific, + ).map(|window| Window { window }) + } +} + +impl Window { + /// Creates a new Window for platforms where this is appropriate. + /// + /// This function is equivalent to `WindowBuilder::new().build(events_loop)`. + /// + /// Error should be very rare and only occur in case of permission denied, incompatible system, + /// out of memory, etc. + #[inline] + pub fn new(events_loop: &EventsLoop) -> Result<Window, CreationError> { + let builder = WindowBuilder::new(); + builder.build(events_loop) + } + + /// Modifies the title of the window. + /// + /// This is a no-op if the window has already been closed. + #[inline] + pub fn set_title(&self, title: &str) { + self.window.set_title(title) + } + + /// Shows the window if it was hidden. + /// + /// ## Platform-specific + /// + /// - Has no effect on Android + /// + #[inline] + pub fn show(&self) { + self.window.show() + } + + /// Hides the window if it was visible. + /// + /// ## Platform-specific + /// + /// - Has no effect on Android + /// + #[inline] + pub fn hide(&self) { + self.window.hide() + } + + /// Returns the position of the top-left hand corner of the window relative to the + /// top-left hand corner of the desktop. + /// + /// Note that the top-left hand corner of the desktop is not necessarily the same as + /// the screen. If the user uses a desktop with multiple monitors, the top-left hand corner + /// of the desktop is the top-left hand corner of the monitor at the top-left of the desktop. + /// + /// The coordinates can be negative if the top-left hand corner of the window is outside + /// of the visible screen region. + /// + /// Returns `None` if the window no longer exists. + #[inline] + pub fn get_position(&self) -> Option<LogicalPosition> { + self.window.get_position() + } + + /// Returns the position of the top-left hand corner of the window's client area relative to the + /// top-left hand corner of the desktop. + /// + /// The same conditions that apply to `get_position` apply to this method. + #[inline] + pub fn get_inner_position(&self) -> Option<LogicalPosition> { + self.window.get_inner_position() + } + + /// Modifies the position of the window. + /// + /// See `get_position` for more information about the coordinates. + /// + /// This is a no-op if the window has already been closed. + #[inline] + pub fn set_position(&self, position: LogicalPosition) { + self.window.set_position(position) + } + + /// Returns the logical size of the window's client area. + /// + /// The client area is the content of the window, excluding the title bar and borders. + /// + /// Converting the returned `LogicalSize` to `PhysicalSize` produces the size your framebuffer should be. + /// + /// Returns `None` if the window no longer exists. + #[inline] + pub fn get_inner_size(&self) -> Option<LogicalSize> { + self.window.get_inner_size() + } + + /// Returns the logical size of the entire window. + /// + /// These dimensions include the title bar and borders. If you don't want that (and you usually don't), + /// use `get_inner_size` instead. + /// + /// Returns `None` if the window no longer exists. + #[inline] + pub fn get_outer_size(&self) -> Option<LogicalSize> { + self.window.get_outer_size() + } + + /// Modifies the inner size of the window. + /// + /// See `get_inner_size` for more information about the values. + /// + /// This is a no-op if the window has already been closed. + #[inline] + pub fn set_inner_size(&self, size: LogicalSize) { + self.window.set_inner_size(size) + } + + /// Sets a minimum dimension size for the window. + #[inline] + pub fn set_min_dimensions(&self, dimensions: Option<LogicalSize>) { + self.window.set_min_dimensions(dimensions) + } + + /// Sets a maximum dimension size for the window. + #[inline] + pub fn set_max_dimensions(&self, dimensions: Option<LogicalSize>) { + self.window.set_max_dimensions(dimensions) + } + + /// Sets whether the window is resizable or not. + /// + /// Note that making the window unresizable doesn't exempt you from handling `Resized`, as that event can still be + /// triggered by DPI scaling, entering fullscreen mode, etc. + /// + /// ## Platform-specific + /// + /// This only has an effect on desktop platforms. + /// + /// Due to a bug in XFCE, this has no effect on Xfwm. + #[inline] + pub fn set_resizable(&self, resizable: bool) { + self.window.set_resizable(resizable) + } + + /// Returns the DPI factor that can be used to map logical pixels to physical pixels, and vice versa. + /// + /// See the [`dpi`](dpi/index.html) module for more information. + /// + /// Note that this value can change depending on user action (for example if the window is + /// moved to another screen); as such, tracking `WindowEvent::HiDpiFactorChanged` events is + /// the most robust way to track the DPI you need to use to draw. + /// + /// ## Platform-specific + /// + /// - **X11:** Can be overridden using the `WINIT_HIDPI_FACTOR` environment variable. + /// - **Android:** Always returns 1.0. + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + self.window.get_hidpi_factor() + } + + /// Modifies the mouse cursor of the window. + /// Has no effect on Android. + #[inline] + pub fn set_cursor(&self, cursor: MouseCursor) { + self.window.set_cursor(cursor); + } + + /// Changes the position of the cursor in window coordinates. + #[inline] + pub fn set_cursor_position(&self, position: LogicalPosition) -> Result<(), String> { + self.window.set_cursor_position(position) + } + + /// Grabs the cursor, preventing it from leaving the window. + /// + /// ## Platform-specific + /// + /// On macOS, this presently merely locks the cursor in a fixed location, which looks visually awkward. + /// + /// This has no effect on Android or iOS. + #[inline] + pub fn grab_cursor(&self, grab: bool) -> Result<(), String> { + self.window.grab_cursor(grab) + } + + /// Hides the cursor, making it invisible but still usable. + /// + /// ## Platform-specific + /// + /// On Windows and X11, the cursor is only hidden within the confines of the window. + /// + /// On macOS, the cursor is hidden as long as the window has input focus, even if the cursor is outside of the + /// window. + /// + /// This has no effect on Android or iOS. + #[inline] + pub fn hide_cursor(&self, hide: bool) { + self.window.hide_cursor(hide) + } + + /// Sets the window to maximized or back + #[inline] + pub fn set_maximized(&self, maximized: bool) { + self.window.set_maximized(maximized) + } + + /// Sets the window to fullscreen or back + #[inline] + pub fn set_fullscreen(&self, monitor: Option<MonitorId>) { + self.window.set_fullscreen(monitor) + } + + /// Turn window decorations on or off. + #[inline] + pub fn set_decorations(&self, decorations: bool) { + self.window.set_decorations(decorations) + } + + /// Change whether or not the window will always be on top of other windows. + #[inline] + pub fn set_always_on_top(&self, always_on_top: bool) { + self.window.set_always_on_top(always_on_top) + } + + /// Sets the window icon. On Windows and X11, this is typically the small icon in the top-left + /// corner of the titlebar. + /// + /// For more usage notes, see `WindowBuilder::with_window_icon`. + /// + /// ## Platform-specific + /// + /// This only has an effect on Windows and X11. + #[inline] + pub fn set_window_icon(&self, window_icon: Option<Icon>) { + self.window.set_window_icon(window_icon) + } + + /// Sets location of IME candidate box in client area coordinates relative to the top left. + #[inline] + pub fn set_ime_spot(&self, position: LogicalPosition) { + self.window.set_ime_spot(position) + } + + /// Returns the monitor on which the window currently resides + #[inline] + pub fn get_current_monitor(&self) -> MonitorId { + self.window.get_current_monitor() + } + + /// Returns the list of all the monitors available on the system. + /// + /// This is the same as `EventsLoop::get_available_monitors`, and is provided for convenience. + #[inline] + pub fn get_available_monitors(&self) -> AvailableMonitorsIter { + let data = self.window.get_available_monitors(); + AvailableMonitorsIter { data: data.into_iter() } + } + + /// Returns the primary monitor of the system. + /// + /// This is the same as `EventsLoop::get_primary_monitor`, and is provided for convenience. + #[inline] + pub fn get_primary_monitor(&self) -> MonitorId { + MonitorId { inner: self.window.get_primary_monitor() } + } + + #[inline] + pub fn id(&self) -> WindowId { + WindowId(self.window.id()) + } +} + +/// An iterator for the list of available monitors. +// Implementation note: we retrieve the list once, then serve each element by one by one. +// This may change in the future. +#[derive(Debug)] +pub struct AvailableMonitorsIter { + pub(crate) data: VecDequeIter<platform::MonitorId>, +} + +impl Iterator for AvailableMonitorsIter { + type Item = MonitorId; + + #[inline] + fn next(&mut self) -> Option<MonitorId> { + self.data.next().map(|id| MonitorId { inner: id }) + } + + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { + self.data.size_hint() + } +} + +/// Identifier for a monitor. +#[derive(Debug, Clone)] +pub struct MonitorId { + pub(crate) inner: platform::MonitorId +} + +impl MonitorId { + /// Returns a human-readable name of the monitor. + /// + /// Returns `None` if the monitor doesn't exist anymore. + #[inline] + pub fn get_name(&self) -> Option<String> { + self.inner.get_name() + } + + /// Returns the monitor's resolution. + #[inline] + pub fn get_dimensions(&self) -> PhysicalSize { + self.inner.get_dimensions() + } + + /// Returns the top-left corner position of the monitor relative to the larger full + /// screen area. + #[inline] + pub fn get_position(&self) -> PhysicalPosition { + self.inner.get_position() + } + + /// Returns the DPI factor that can be used to map logical pixels to physical pixels, and vice versa. + /// + /// See the [`dpi`](dpi/index.html) module for more information. + /// + /// ## Platform-specific + /// + /// - **X11:** Can be overridden using the `WINIT_HIDPI_FACTOR` environment variable. + /// - **Android:** Always returns 1.0. + #[inline] + pub fn get_hidpi_factor(&self) -> f64 { + self.inner.get_hidpi_factor() + } +} diff --git a/third_party/cargo/vendor/winit-0.18.1/tests/send_objects.rs b/third_party/cargo/vendor/winit-0.18.1/tests/send_objects.rs new file mode 100644 index 0000000..f3328c1 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/tests/send_objects.rs @@ -0,0 +1,23 @@ +extern crate winit; + +fn needs_send<T:Send>() {} + +#[test] +fn events_loop_proxy_send() { + // ensures that `winit::EventsLoopProxy` implements `Send` + needs_send::<winit::EventsLoopProxy>(); +} + +#[test] +fn window_send() { + // ensures that `winit::Window` implements `Send` + needs_send::<winit::Window>(); +} + +#[test] +fn ids_send() { + // ensures that the various `..Id` types implement `Send` + needs_send::<winit::WindowId>(); + needs_send::<winit::DeviceId>(); + needs_send::<winit::MonitorId>(); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/tests/serde_objects.rs b/third_party/cargo/vendor/winit-0.18.1/tests/serde_objects.rs new file mode 100644 index 0000000..b5a4963 --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/tests/serde_objects.rs @@ -0,0 +1,39 @@ +#![cfg(feature = "serde")] + +extern crate serde; +extern crate winit; + +use winit::{ControlFlow, MouseCursor}; +use winit::{ + KeyboardInput, TouchPhase, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode, + ModifiersState +}; +use winit::dpi::{LogicalPosition, PhysicalPosition, LogicalSize, PhysicalSize}; +use serde::{Serialize, Deserialize}; + +fn needs_serde<S: Serialize + Deserialize<'static>>() {} + +#[test] +fn root_serde() { + needs_serde::<ControlFlow>(); + needs_serde::<MouseCursor>(); +} + +#[test] +fn events_serde() { + needs_serde::<KeyboardInput>(); + needs_serde::<TouchPhase>(); + needs_serde::<ElementState>(); + needs_serde::<MouseButton>(); + needs_serde::<MouseScrollDelta>(); + needs_serde::<VirtualKeyCode>(); + needs_serde::<ModifiersState>(); +} + +#[test] +fn dpi_serde() { + needs_serde::<LogicalPosition>(); + needs_serde::<PhysicalPosition>(); + needs_serde::<LogicalSize>(); + needs_serde::<PhysicalSize>(); +} diff --git a/third_party/cargo/vendor/winit-0.18.1/tests/sync_object.rs b/third_party/cargo/vendor/winit-0.18.1/tests/sync_object.rs new file mode 100644 index 0000000..eb9a06e --- /dev/null +++ b/third_party/cargo/vendor/winit-0.18.1/tests/sync_object.rs @@ -0,0 +1,9 @@ +extern crate winit; + +fn needs_sync<T:Sync>() {} + +#[test] +fn window_sync() { + // ensures that `winit::Window` implements `Sync` + needs_sync::<winit::Window>(); +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/.cargo-checksum.json b/third_party/cargo/vendor/x11-dl-2.18.4/.cargo-checksum.json new file mode 100644 index 0000000..0c5c641 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"c3b22b54535692af6a7b4e24ef7cd6329dddcce09e6a201aef1bc90cbcddf310","build.rs":"946f0429fd5c740ae9fa70ae5d773761e219a0152cbaad9b0ba28aa7332e3876","examples/hello-world-dl.rs":"683fb674f803b9617d2383e3d9b4a18875181549e1a06dce5803831bad5e9ac3","src/dpms.rs":"77cb9237a0262350bf6553e40d6cc9e97a599bca089a457ef87c57c9b9cf6194","src/error.rs":"a0189c011dae4b95acc44f4785bde73c4c6612899d90c596898eaacc6ac65e74","src/glx.rs":"b559c1e9663069f417bf70f1f86eb3e1103739c7041ee6a9103759030fac1126","src/internal.rs":"9e1f269e36e6a92325be4f5e67185d60c12e4a74b98c454759c0161325d0d1e4","src/keysym.rs":"4d65901072224729fe18fb5c815242e51e75a34c1dfc88e5ac1cea19e8a423a8","src/lib.rs":"5b0049ed9c7bea875e9cc310e22b478e33a0ffe351cb48e22c270b8244c5e1fd","src/link.rs":"112106710baa91807e406eddc43ec70f26ac0784df73f8ee1055b06e2fb6cfe0","src/old_xrandr.rs":"5263a72435ed8e87e5c81b0b149d38b72e780842e3f7c59b5962b5213852085d","src/xcursor.rs":"d4d87186c78c42bbff7318fb530851bdb61e38b431233644a3b2295bb0081841","src/xf86vmode.rs":"46f4dd10c118309ebcbde76989824b8bc756a885d070d1af04f42b10795c3280","src/xfixes.rs":"cc2a1681415c3d2d32331dd610567376b6eaa5f42d58b8940a1ff1d765d9cc85","src/xft.rs":"0951bc2f362c4c9722554b89c87ab67e7d60698734820fd88207f874fa84dee9","src/xinerama.rs":"c4bd4f21f044d695b2fc052a20d554aac1f2227459e38da9b66125c60b6d33b7","src/xinput.rs":"3876865629612690d0ab3b551a7e6303eaf9818ff0a56c0d803281c16c7c475a","src/xinput2.rs":"b5a0eba5b1ae5f89534b3fad30fd13f45b02b4ef6b492734fbf4b0c66a7391e1","src/xlib.rs":"65221fbbf70bf25d828692bacf288ab4ebdc073ba09917a3790b5bc0c2bbb70b","src/xlib_xcb.rs":"71ee6274e261bb8f0b82ea260afffa9273531f0f87df9541152412b88aff468f","src/xmd.rs":"149c818c19e90a14c8f60016cd18a04d0de4fd702fc5df89e5283f6ee1ce4852","src/xmu.rs":"262df634c584dac47d0d898dd75b6b2de7c4256b9b494cf89123d8279dad3020","src/xrandr.rs":"c137fadcd035142536567a4ab2591331f040a8c77306746a70ffc5df2bdf6979","src/xrecord.rs":"82e4ad59079ce6c6ad0097ef4b44935d2448b363784abe008919f89cb02ae8c4","src/xrender.rs":"d6642eb83709bc8ff913dd382677e94d5153618f005fead645962947b8ff50b4","src/xss.rs":"8322f210627a59d825a11256ff4daff42c53c6e8ba626f55b3859bf938e8a7b2","src/xt.rs":"fa2324391a91387f44eeee6742c50676329f08d941d002ff70d4eb99f36af7bc","src/xtest.rs":"dcd0eb130ffb3cf96165d1699d6b625649c28ed819036a85b5f175c2a3479918"},"package":"be65e1342a3baae65439cd03306778831a3d133b0d20243a7fb83fd5cf403c58"} \ No newline at end of file diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/BUILD b/third_party/cargo/vendor/x11-dl-2.18.4/BUILD new file mode 100644 index 0000000..e9f8416 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/BUILD @@ -0,0 +1,84 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "unencumbered", # "CC0-1.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + +rust_binary( + name = "x11_dl_build_script", + srcs = glob(["**/*.rs"]), + crate_root = "build.rs", + edition = "2015", + deps = [ + "//third_party/cargo/vendor/pkg-config-0.3.17:pkg_config", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + crate_features = [ + ], + data = glob(["*"]), + version = "2.18.4", + visibility = ["//visibility:private"], +) + +genrule( + name = "x11_dl_build_script_executor", + srcs = glob(["*", "**/*.rs"]), + outs = ["x11_dl_out_dir_outputs.tar.gz"], + tools = [ + ":x11_dl_build_script", + ], + tags = ["no-sandbox"], + cmd = "mkdir -p $$(dirname $@)/x11_dl_out_dir_outputs/;" + + " (export CARGO_MANIFEST_DIR=\"$$PWD/$$(dirname $(location :Cargo.toml))\";" + # TODO(acmcarther): This needs to be revisited as part of the cross compilation story. + # See also: https://github.com/google/cargo-raze/pull/54 + + " export TARGET='x86_64-unknown-linux-gnu';" + + " export RUST_BACKTRACE=1;" + + " export OUT_DIR=$$PWD/$$(dirname $@)/x11_dl_out_dir_outputs;" + + " export BINARY_PATH=\"$$PWD/$(location :x11_dl_build_script)\";" + + " export OUT_TAR=$$PWD/$@;" + + " cd $$(dirname $(location :Cargo.toml)) && $$BINARY_PATH && tar -czf $$OUT_TAR -C $$OUT_DIR .)" +) + +# Unsupported target "hello-world-dl" with type "example" omitted + +rust_library( + name = "x11_dl", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/maybe-uninit-2.0.0:maybe_uninit", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + out_dir_tar = ":x11_dl_build_script_executor", + version = "2.18.4", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/Cargo.toml b/third_party/cargo/vendor/x11-dl-2.18.4/Cargo.toml new file mode 100644 index 0000000..b8d0b5f --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/Cargo.toml @@ -0,0 +1,31 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "x11-dl" +version = "2.18.4" +authors = ["daggerbot <daggerbot@gmail.com>", "Erle Pereira <erle@erlepereira.com>"] +build = "build.rs" +description = "X11 library bindings for Rust" +documentation = "https://docs.rs/x11-dl" +license = "CC0-1.0" +repository = "https://github.com/erlepereira/x11-rs.git" +[dependencies.lazy_static] +version = "1" + +[dependencies.libc] +version = "0.2" + +[dependencies.maybe-uninit] +version = "2.0.0" +[build-dependencies.pkg-config] +version = "0.3.8" diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/build.rs b/third_party/cargo/vendor/x11-dl-2.18.4/build.rs new file mode 100644 index 0000000..63cc7d6 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/build.rs @@ -0,0 +1,52 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +extern crate pkg_config; + +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::Path; + +fn main() { + let libraries = [ + // lib pkgconfig name + ("xext", "xext"), + ("gl", "gl"), + ("xcursor", "xcursor"), + ("xxf86vm", "xxf86vm"), + ("xft", "xft"), + ("xinerama", "xinerama"), + ("xi", "xi"), + ("x11", "x11"), + ("xlib_xcb", "x11-xcb"), + ("xmu", "xmu"), + ("xrandr", "xrandr"), + ("xtst", "xtst"), + ("xrender", "xrender"), + ("xscrnsaver", "xscrnsaver"), + ("xt", "xt"), + ]; + + let mut config = String::new(); + for &(lib, pcname) in libraries.iter() { + let libdir = match pkg_config::get_variable(pcname, "libdir") { + Ok(libdir) => format!("Some(\"{}\")", libdir), + Err(_) => "None".to_string(), + }; + config.push_str(&format!("pub const {}: Option<&'static str> = {};\n", lib, libdir)); + } + let config = format!("pub mod config {{ pub mod libdir {{\n{}}}\n}}", config); + let out_dir = env::var("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("config.rs"); + let mut f = File::create(&dest_path).unwrap(); + f.write_all(&config.into_bytes()).unwrap(); + + let target = env::var("TARGET").unwrap(); + if target.contains("linux") { + println!("cargo:rustc-link-lib=dl"); + } else if target.contains("freebsd") || target.contains("dragonfly") { + println!("cargo:rustc-link-lib=c"); + } +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/examples/hello-world-dl.rs b/third_party/cargo/vendor/x11-dl-2.18.4/examples/hello-world-dl.rs new file mode 100644 index 0000000..3e01eae --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/examples/hello-world-dl.rs @@ -0,0 +1,83 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +extern crate x11_dl; + +use std::ffi::CString; +use std::mem; +use std::os::raw::*; +use std::ptr; + +use x11_dl::xlib; + +fn main () { + unsafe { + // Load Xlib library. + let xlib = xlib::Xlib::open().unwrap(); + + // Open display connection. + let display = (xlib.XOpenDisplay)(ptr::null()); + + if display.is_null() { + panic!("XOpenDisplay failed"); + } + + // Create window. + let screen = (xlib.XDefaultScreen)(display); + let root = (xlib.XRootWindow)(display, screen); + + let mut attributes: xlib::XSetWindowAttributes = mem::uninitialized(); + attributes.background_pixel = (xlib.XWhitePixel)(display, screen); + + let window = (xlib.XCreateWindow)(display, root, + 0, 0, 400, 300, + 0, 0, + xlib::InputOutput as c_uint, ptr::null_mut(), + xlib::CWBackPixel, &mut attributes); + + // Set window title. + let title_str = CString::new("hello-world").unwrap(); + (xlib.XStoreName)(display, window, title_str.as_ptr() as *mut c_char); + + // Hook close requests. + let wm_protocols_str = CString::new("WM_PROTOCOLS").unwrap(); + let wm_delete_window_str = CString::new("WM_DELETE_WINDOW").unwrap(); + + let wm_protocols = (xlib.XInternAtom)(display, wm_protocols_str.as_ptr(), xlib::False); + let wm_delete_window = (xlib.XInternAtom)(display, wm_delete_window_str.as_ptr(), xlib::False); + + let mut protocols = [wm_delete_window]; + + (xlib.XSetWMProtocols)(display, window, protocols.as_mut_ptr(), protocols.len() as c_int); + + // Show window. + (xlib.XMapWindow)(display, window); + + // Main loop. + let mut event: xlib::XEvent = mem::uninitialized(); + + loop { + (xlib.XNextEvent)(display, &mut event); + + match event.get_type() { + xlib::ClientMessage => { + let xclient = xlib::XClientMessageEvent::from(event); + + if xclient.message_type == wm_protocols && xclient.format == 32 { + let protocol = xclient.data.get_long(0) as xlib::Atom; + + if protocol == wm_delete_window { + break; + } + } + }, + + _ => () + } + } + + // Shut down. + (xlib.XCloseDisplay)(display); + } +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/dpms.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/dpms.rs new file mode 100644 index 0000000..a19a9de --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/dpms.rs @@ -0,0 +1,44 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ c_int }; + +use xlib::{ Display, Status, Bool }; +use xmd::{ CARD16, BOOL }; + + +// +// functions +// + + +x11_link! { Xext, xext, ["libXext.so.6", "libXext.so"], 9, + pub fn DPMSQueryExtension (_1: *mut Display, _2: *mut c_int, _3: *mut c_int) -> Bool, + pub fn DPMSGetVersion (_1: *mut Display, _2: *mut c_int, _3: *mut c_int) -> Status, + pub fn DPMSCapable (_1: *mut Display) -> Bool, + pub fn DPMSSetTimeouts (_1: *mut Display, _2: CARD16, _3: CARD16, _4: CARD16) -> Status, + pub fn DPMSGetTimeouts (_1: *mut Display, _2: *mut CARD16, _3: *mut CARD16, _4: *mut CARD16) -> Bool, + pub fn DPMSEnable (_1: *mut Display) -> Status, + pub fn DPMSDisable (_1: *mut Display) -> Status, + pub fn DPMSForceLevel (_1: *mut Display, _2: CARD16) -> Status, + pub fn DPMSInfo (_1: *mut Display, _2: *mut CARD16, _3: *mut BOOL) -> Status, +variadic: +globals: +} + + +// +// constants +// + + +pub const DPMSMajorVersion: c_int = 1; +pub const DPMSMinorVersion: c_int = 1; + +pub const DPMSExtensionName: &'static str = "DPMS"; + +pub const DPMSModeOn: CARD16 = 0; +pub const DPMSModeStandby: CARD16 = 1; +pub const DPMSModeSuspend: CARD16 = 2; +pub const DPMSModeOff: CARD16 = 3; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/error.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/error.rs new file mode 100644 index 0000000..fce7315 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/error.rs @@ -0,0 +1,77 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::error::Error; +use std::fmt::{ + Display, + Formatter, +}; + + +// +// OpenError +// + + +#[derive(Clone, Debug)] +pub struct OpenError { + kind: OpenErrorKind, + detail: String, +} + +impl OpenError { + pub fn detail (&self) -> &str { + self.detail.as_ref() + } + + pub fn kind (&self) -> OpenErrorKind { + self.kind + } + + pub fn new (kind: OpenErrorKind, detail: String) -> OpenError { + OpenError { + kind: kind, + detail: detail, + } + } +} + +impl Display for OpenError { + fn fmt (&self, f: &mut Formatter) -> Result<(), ::std::fmt::Error> { + try!(f.write_str(self.kind.as_str())); + if !self.detail.is_empty() { + try!(f.write_str(" (")); + try!(f.write_str(self.detail.as_ref())); + try!(f.write_str(")")); + } + return Ok(()); + } +} + +impl Error for OpenError { + fn description (&self) -> &str { + self.kind.as_str() + } +} + + +// +// OpenErrorKind +// + + +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub enum OpenErrorKind { + Library, + Symbol, +} + +impl OpenErrorKind { + pub fn as_str (self) -> &'static str { + match self { + OpenErrorKind::Library => "opening library failed", + OpenErrorKind::Symbol => "loading symbol failed", + } + } +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/glx.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/glx.rs new file mode 100644 index 0000000..bafff0f --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/glx.rs @@ -0,0 +1,249 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ + c_char, + c_int, + c_uchar, + c_uint, + c_ulong, +}; + +use ::xlib::{ + Display, + XID, + XVisualInfo, +}; + + +// +// functions +// + + +x11_link! { Glx, gl, ["libGL.so.1", "libGL.so"], 40, + pub fn glXChooseFBConfig (_4: *mut Display, _3: c_int, _2: *const c_int, _1: *mut c_int) -> *mut GLXFBConfig, + pub fn glXChooseVisual (_3: *mut Display, _2: c_int, _1: *mut c_int) -> *mut XVisualInfo, + pub fn glXCopyContext (_4: *mut Display, _3: GLXContext, _2: GLXContext, _1: c_ulong) -> (), + pub fn glXCreateContext (_4: *mut Display, _3: *mut XVisualInfo, _2: GLXContext, _1: c_int) -> GLXContext, + pub fn glXCreateGLXPixmap (_3: *mut Display, _2: *mut XVisualInfo, _1: c_ulong) -> c_ulong, + pub fn glXCreateNewContext (_5: *mut Display, _4: GLXFBConfig, _3: c_int, _2: GLXContext, _1: c_int) -> GLXContext, + pub fn glXCreatePbuffer (_3: *mut Display, _2: GLXFBConfig, _1: *const c_int) -> c_ulong, + pub fn glXCreatePixmap (_4: *mut Display, _3: GLXFBConfig, _2: c_ulong, _1: *const c_int) -> c_ulong, + pub fn glXCreateWindow (_4: *mut Display, _3: GLXFBConfig, _2: c_ulong, _1: *const c_int) -> c_ulong, + pub fn glXDestroyContext (_2: *mut Display, _1: GLXContext) -> (), + pub fn glXDestroyGLXPixmap (_2: *mut Display, _1: c_ulong) -> (), + pub fn glXDestroyPbuffer (_2: *mut Display, _1: c_ulong) -> (), + pub fn glXDestroyPixmap (_2: *mut Display, _1: c_ulong) -> (), + pub fn glXDestroyWindow (_2: *mut Display, _1: c_ulong) -> (), + pub fn glXGetClientString (_2: *mut Display, _1: c_int) -> *const c_char, + pub fn glXGetConfig (_4: *mut Display, _3: *mut XVisualInfo, _2: c_int, _1: *mut c_int) -> c_int, + pub fn glXGetCurrentContext () -> GLXContext, + pub fn glXGetCurrentDisplay () -> *mut Display, + pub fn glXGetCurrentDrawable () -> c_ulong, + pub fn glXGetCurrentReadDrawable () -> c_ulong, + pub fn glXGetFBConfigAttrib (_4: *mut Display, _3: GLXFBConfig, _2: c_int, _1: *mut c_int) -> c_int, + pub fn glXGetFBConfigs (_3: *mut Display, _2: c_int, _1: *mut c_int) -> *mut GLXFBConfig, + pub fn glXGetProcAddress (_1: *const c_uchar) -> Option<unsafe extern "C" fn ()>, + pub fn glXGetProcAddressARB (_1: *const c_uchar) -> Option<unsafe extern "C" fn ()>, + pub fn glXGetSelectedEvent (_3: *mut Display, _2: c_ulong, _1: *mut c_ulong) -> (), + pub fn glXGetVisualFromFBConfig (_2: *mut Display, _1: GLXFBConfig) -> *mut XVisualInfo, + pub fn glXIsDirect (_2: *mut Display, _1: GLXContext) -> c_int, + pub fn glXMakeContextCurrent (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: GLXContext) -> c_int, + pub fn glXMakeCurrent (_3: *mut Display, _2: c_ulong, _1: GLXContext) -> c_int, + pub fn glXQueryContext (_4: *mut Display, _3: GLXContext, _2: c_int, _1: *mut c_int) -> c_int, + pub fn glXQueryDrawable (_4: *mut Display, _3: c_ulong, _2: c_int, _1: *mut c_uint) -> (), + pub fn glXQueryExtension (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn glXQueryExtensionsString (_2: *mut Display, _1: c_int) -> *const c_char, + pub fn glXQueryServerString (_3: *mut Display, _2: c_int, _1: c_int) -> *const c_char, + pub fn glXQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn glXSelectEvent (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> (), + pub fn glXSwapBuffers (_2: *mut Display, _1: c_ulong) -> (), + pub fn glXUseXFont (_4: c_ulong, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn glXWaitGL () -> (), + pub fn glXWaitX () -> (), +variadic: +globals: +} + + +// +// types +// + + +// opaque structures +#[repr(C)] pub struct __GLXcontextRec; +#[repr(C)] pub struct __GLXFBConfigRec; + +// types +pub type GLXContext = *mut __GLXcontextRec; +pub type GLXContextID = XID; +pub type GLXDrawable = XID; +pub type GLXFBConfig = *mut __GLXFBConfigRec; +pub type GLXFBConfigID = XID; +pub type GLXPbuffer = XID; +pub type GLXPixmap = XID; +pub type GLXWindow = XID; + + +// +// constants +// + + +// config caveats +pub const GLX_SLOW_CONFIG: c_int = 0x8001; +pub const GLX_NON_CONFORMANT_CONFIG: c_int = 0x800d; + +// drawable type mask +pub const GLX_WINDOW_BIT: c_int = 0x0001; +pub const GLX_PIXMAP_BIT: c_int = 0x0002; +pub const GLX_PBUFFER_BIT: c_int = 0x0004; + +// framebuffer attributes +pub const GLX_USE_GL: c_int = 0x0001; +pub const GLX_BUFFER_SIZE: c_int = 0x0002; +pub const GLX_LEVEL: c_int = 0x0003; +pub const GLX_RGBA: c_int = 0x0004; +pub const GLX_DOUBLEBUFFER: c_int = 0x0005; +pub const GLX_STEREO: c_int = 0x0006; +pub const GLX_AUX_BUFFERS: c_int = 0x0007; +pub const GLX_RED_SIZE: c_int = 0x0008; +pub const GLX_GREEN_SIZE: c_int = 0x0009; +pub const GLX_BLUE_SIZE: c_int = 0x000a; +pub const GLX_ALPHA_SIZE: c_int = 0x000b; +pub const GLX_DEPTH_SIZE: c_int = 0x000c; +pub const GLX_STENCIL_SIZE: c_int = 0x000d; +pub const GLX_ACCUM_RED_SIZE: c_int = 0x000e; +pub const GLX_ACCUM_GREEN_SIZE: c_int = 0x000f; +pub const GLX_ACCUM_BLUE_SIZE: c_int = 0x0010; +pub const GLX_ACCUM_ALPHA_SIZE: c_int = 0x0011; +pub const GLX_CONFIG_CAVEAT: c_int = 0x0020; +pub const GLX_X_VISUAL_TYPE: c_int = 0x0022; +pub const GLX_TRANSPARENT_TYPE: c_int = 0x0023; +pub const GLX_TRANSPARENT_INDEX_VALUE: c_int = 0x0024; +pub const GLX_TRANSPARENT_RED_VALUE: c_int = 0x0025; +pub const GLX_TRANSPARENT_GREEN_VALUE: c_int = 0x0026; +pub const GLX_TRANSPARENT_BLUE_VALUE: c_int = 0x0027; +pub const GLX_TRANSPARENT_ALPHA_VALUE: c_int = 0x0028; +pub const GLX_VISUAL_ID: c_int = 0x800B; +pub const GLX_SCREEN: c_int = 0x800C; +pub const GLX_DRAWABLE_TYPE: c_int = 0x8010; +pub const GLX_RENDER_TYPE: c_int = 0x8011; +pub const GLX_X_RENDERABLE: c_int = 0x8012; +pub const GLX_FBCONFIG_ID: c_int = 0x8013; +pub const GLX_MAX_PBUFFER_WIDTH: c_int = 0x8016; +pub const GLX_MAX_PBUFFER_HEIGHT: c_int = 0x8017; +pub const GLX_MAX_PBUFFER_PIXELS: c_int = 0x8018; +pub const GLX_SAMPLE_BUFFERS: c_int = 0x1_86a0; +pub const GLX_SAMPLES: c_int = 0x1_86a1; + +// misc +pub const GLX_DONT_CARE: c_int = -1; +pub const GLX_NONE: c_int = 0x8000; + +// render type mask +pub const GLX_RGBA_BIT: c_int = 0x0001; +pub const GLX_COLOR_INDEX_BIT: c_int = 0x0002; + +// transparent types +pub const GLX_TRANSPARENT_RGB: c_int = 0x8008; +pub const GLX_TRANSPARENT_INDEX: c_int = 0x8009; + +// visual types +pub const GLX_TRUE_COLOR: c_int = 0x8002; +pub const GLX_DIRECT_COLOR: c_int = 0x8003; +pub const GLX_PSEUDO_COLOR: c_int = 0x8004; +pub const GLX_STATIC_COLOR: c_int = 0x8005; +pub const GLX_GRAY_SCALE: c_int = 0x8006; +pub const GLX_STATIC_GRAY: c_int = 0x8007; + +// glXGetConfig errors +pub const GLX_BAD_SCREEN: c_int = 1; +pub const GLX_BAD_ATTRIBUTE: c_int = 2; +pub const GLX_NO_EXTENSION: c_int = 3; +pub const GLX_BAD_VISUAL: c_int = 4; +pub const GLX_BAD_CONTEXT: c_int = 5; +pub const GLX_BAD_VALUE: c_int = 6; +pub const GLX_BAD_ENUM: c_int = 7; + +// glXGetClientString names +pub const GLX_VENDOR: c_int = 1; +pub const GLX_VERSION: c_int = 2; +pub const GLX_EXTENSIONS: c_int = 3; + +// drawable type mask? +pub const GLX_FRONT_LEFT_BUFFER_BIT: c_uint = 0x0001; +pub const GLX_FRONT_RIGHT_BUFFER_BIT: c_uint = 0x0002; +pub const GLX_BACK_LEFT_BUFFER_BIT: c_uint = 0x0004; +pub const GLX_BACK_RIGHT_BUFFER_BIT: c_uint = 0x0008; +pub const GLX_AUX_BUFFERS_BIT: c_uint = 0x0010; +pub const GLX_DEPTH_BUFFER_BIT: c_uint = 0x0020; +pub const GLX_STENCIL_BUFFER_BIT: c_uint = 0x0040; +pub const GLX_ACCUM_BUFFER_BIT: c_uint = 0080; + +// render type for glXCreateNewContext +pub const GLX_RGBA_TYPE: c_int = 0x8014; +pub const GLX_COLOR_INDEX_TYPE: c_int = 0x8015; + +// drawable attributes +pub const GLX_PRESERVED_CONTENTS: c_int = 0x801B; +pub const GLX_LARGEST_PBUFFER: c_int = 0x801C; +pub const GLX_WIDTH: c_int = 0x801D; +pub const GLX_HEIGHT: c_int = 0x801E; +pub const GLX_PBUFFER_HEIGHT: c_int = 0x8040; +pub const GLX_PBUFFER_WIDTH: c_int = 0x8041; + +// other? +pub const GLX_EVENT_MASK: c_int = 0x801F; + +// event mask +pub const GLX_PBUFFER_CLOBBER_MASK: c_ulong = 0x0800_0000; + +// event types +pub const GLX_DAMAGED: c_int = 0x8020; +pub const GLX_SAVED: c_int = 0x8021; + +// drawable types +pub const GLX_WINDOW: c_int = 0x8022; +pub const GLX_PBUFFER: c_int = 0x8023; + + +// +// ARB extensions +// + + +pub mod arb { + use std::os::raw::c_int; + + // context attributes + pub const GLX_CONTEXT_MAJOR_VERSION_ARB: c_int = 0x2091; + pub const GLX_CONTEXT_MINOR_VERSION_ARB: c_int = 0x2092; + pub const GLX_CONTEXT_FLAGS_ARB: c_int = 0x2094; + pub const GLX_CONTEXT_PROFILE_MASK_ARB: c_int = 0x9126; + + // context flags + pub const GLX_CONTEXT_DEBUG_BIT_ARB: c_int = 0x0001; + pub const GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB: c_int = 0x0002; + + // context profile mask + pub const GLX_CONTEXT_CORE_PROFILE_BIT_ARB: c_int = 0x0001; + pub const GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB: c_int = 0x0002; +} + + +// +// EXT extensions +// + + +pub mod ext { + use std::os::raw::c_int; + + // drawable attributes + pub const GLX_SWAP_INTERVAL_EXT: c_int = 0x20f1; + pub const GLX_MAX_SWAP_INTERVAL_EXT: c_int = 0x20f2; +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/internal.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/internal.rs new file mode 100644 index 0000000..b1ec344 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/internal.rs @@ -0,0 +1,41 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::cmp::min; +use std::mem::{ + size_of, + zeroed, +}; + + +// +// public functions +// + + +pub unsafe fn mem_eq<T: Sized> (a: &T, b: &T) -> bool { + let a_addr = a as *const T as usize; + let b_addr = b as *const T as usize; + + for i in 0..size_of::<T>() { + if *((a_addr + i) as *const u8) != *((b_addr + i) as *const u8) { + return false; + } + } + + return true; +} + +pub unsafe fn transmute_union<I, O> (input: &I) -> O + where I : Sized, O : Sized +{ + let mut output: O = zeroed(); + let copy_len = min(size_of::<I>(), size_of::<O>()); + + for i in 0..copy_len { + *((&mut output as *mut O as usize + i) as *mut u8) = *((input as *const I as usize + i) as *const u8); + } + + return output; +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/keysym.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/keysym.rs new file mode 100644 index 0000000..f075794 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/keysym.rs @@ -0,0 +1,1332 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::c_uint; + +pub const XK_BackSpace: c_uint = 0xFF08; +pub const XK_Tab: c_uint = 0xFF09; +pub const XK_Linefeed: c_uint = 0xFF0A; +pub const XK_Clear: c_uint = 0xFF0B; +pub const XK_Return: c_uint = 0xFF0D; +pub const XK_Pause: c_uint = 0xFF13; +pub const XK_Scroll_Lock: c_uint = 0xFF14; +pub const XK_Sys_Req: c_uint = 0xFF15; +pub const XK_Escape: c_uint = 0xFF1B; +pub const XK_Delete: c_uint = 0xFFFF; +pub const XK_Multi_key: c_uint = 0xFF20; +pub const XK_Kanji: c_uint = 0xFF21; +pub const XK_Muhenkan: c_uint = 0xFF22; +pub const XK_Henkan_Mode: c_uint = 0xFF23; +pub const XK_Henkan: c_uint = 0xFF23; +pub const XK_Romaji: c_uint = 0xFF24; +pub const XK_Hiragana: c_uint = 0xFF25; +pub const XK_Katakana: c_uint = 0xFF26; +pub const XK_Hiragana_Katakana: c_uint = 0xFF27; +pub const XK_Zenkaku: c_uint = 0xFF28; +pub const XK_Hankaku: c_uint = 0xFF29; +pub const XK_Zenkaku_Hankaku: c_uint = 0xFF2A; +pub const XK_Touroku: c_uint = 0xFF2B; +pub const XK_Massyo: c_uint = 0xFF2C; +pub const XK_Kana_Lock: c_uint = 0xFF2D; +pub const XK_Kana_Shift: c_uint = 0xFF2E; +pub const XK_Eisu_Shift: c_uint = 0xFF2F; +pub const XK_Eisu_toggle: c_uint = 0xFF30; +pub const XK_Home: c_uint = 0xFF50; +pub const XK_Left: c_uint = 0xFF51; +pub const XK_Up: c_uint = 0xFF52; +pub const XK_Right: c_uint = 0xFF53; +pub const XK_Down: c_uint = 0xFF54; +pub const XK_Prior: c_uint = 0xFF55; +pub const XK_Page_Up: c_uint = 0xFF55; +pub const XK_Next: c_uint = 0xFF56; +pub const XK_Page_Down: c_uint = 0xFF56; +pub const XK_End: c_uint = 0xFF57; +pub const XK_Begin: c_uint = 0xFF58; +pub const XK_Win_L: c_uint = 0xFF5B; +pub const XK_Win_R: c_uint = 0xFF5C; +pub const XK_App: c_uint = 0xFF5D; +pub const XK_Select: c_uint = 0xFF60; +pub const XK_Print: c_uint = 0xFF61; +pub const XK_Execute: c_uint = 0xFF62; +pub const XK_Insert: c_uint = 0xFF63; +pub const XK_Undo: c_uint = 0xFF65; +pub const XK_Redo: c_uint = 0xFF66; +pub const XK_Menu: c_uint = 0xFF67; +pub const XK_Find: c_uint = 0xFF68; +pub const XK_Cancel: c_uint = 0xFF69; +pub const XK_Help: c_uint = 0xFF6A; +pub const XK_Break: c_uint = 0xFF6B; +pub const XK_Mode_switch: c_uint = 0xFF7E; +pub const XK_script_switch: c_uint = 0xFF7E; +pub const XK_Num_Lock: c_uint = 0xFF7F; +pub const XK_KP_Space: c_uint = 0xFF80; +pub const XK_KP_Tab: c_uint = 0xFF89; +pub const XK_KP_Enter: c_uint = 0xFF8D; +pub const XK_KP_F1: c_uint = 0xFF91; +pub const XK_KP_F2: c_uint = 0xFF92; +pub const XK_KP_F3: c_uint = 0xFF93; +pub const XK_KP_F4: c_uint = 0xFF94; +pub const XK_KP_Home: c_uint = 0xFF95; +pub const XK_KP_Left: c_uint = 0xFF96; +pub const XK_KP_Up: c_uint = 0xFF97; +pub const XK_KP_Right: c_uint = 0xFF98; +pub const XK_KP_Down: c_uint = 0xFF99; +pub const XK_KP_Prior: c_uint = 0xFF9A; +pub const XK_KP_Page_Up: c_uint = 0xFF9A; +pub const XK_KP_Next: c_uint = 0xFF9B; +pub const XK_KP_Page_Down: c_uint = 0xFF9B; +pub const XK_KP_End: c_uint = 0xFF9C; +pub const XK_KP_Begin: c_uint = 0xFF9D; +pub const XK_KP_Insert: c_uint = 0xFF9E; +pub const XK_KP_Delete: c_uint = 0xFF9F; +pub const XK_KP_Equal: c_uint = 0xFFBD; +pub const XK_KP_Multiply: c_uint = 0xFFAA; +pub const XK_KP_Add: c_uint = 0xFFAB; +pub const XK_KP_Separator: c_uint = 0xFFAC; +pub const XK_KP_Subtract: c_uint = 0xFFAD; +pub const XK_KP_Decimal: c_uint = 0xFFAE; +pub const XK_KP_Divide: c_uint = 0xFFAF; +pub const XK_KP_0: c_uint = 0xFFB0; +pub const XK_KP_1: c_uint = 0xFFB1; +pub const XK_KP_2: c_uint = 0xFFB2; +pub const XK_KP_3: c_uint = 0xFFB3; +pub const XK_KP_4: c_uint = 0xFFB4; +pub const XK_KP_5: c_uint = 0xFFB5; +pub const XK_KP_6: c_uint = 0xFFB6; +pub const XK_KP_7: c_uint = 0xFFB7; +pub const XK_KP_8: c_uint = 0xFFB8; +pub const XK_KP_9: c_uint = 0xFFB9; +pub const XK_F1: c_uint = 0xFFBE; +pub const XK_F2: c_uint = 0xFFBF; +pub const XK_F3: c_uint = 0xFFC0; +pub const XK_F4: c_uint = 0xFFC1; +pub const XK_F5: c_uint = 0xFFC2; +pub const XK_F6: c_uint = 0xFFC3; +pub const XK_F7: c_uint = 0xFFC4; +pub const XK_F8: c_uint = 0xFFC5; +pub const XK_F9: c_uint = 0xFFC6; +pub const XK_F10: c_uint = 0xFFC7; +pub const XK_F11: c_uint = 0xFFC8; +pub const XK_L1: c_uint = 0xFFC8; +pub const XK_F12: c_uint = 0xFFC9; +pub const XK_L2: c_uint = 0xFFC9; +pub const XK_F13: c_uint = 0xFFCA; +pub const XK_L3: c_uint = 0xFFCA; +pub const XK_F14: c_uint = 0xFFCB; +pub const XK_L4: c_uint = 0xFFCB; +pub const XK_F15: c_uint = 0xFFCC; +pub const XK_L5: c_uint = 0xFFCC; +pub const XK_F16: c_uint = 0xFFCD; +pub const XK_L6: c_uint = 0xFFCD; +pub const XK_F17: c_uint = 0xFFCE; +pub const XK_L7: c_uint = 0xFFCE; +pub const XK_F18: c_uint = 0xFFCF; +pub const XK_L8: c_uint = 0xFFCF; +pub const XK_F19: c_uint = 0xFFD0; +pub const XK_L9: c_uint = 0xFFD0; +pub const XK_F20: c_uint = 0xFFD1; +pub const XK_L10: c_uint = 0xFFD1; +pub const XK_F21: c_uint = 0xFFD2; +pub const XK_R1: c_uint = 0xFFD2; +pub const XK_F22: c_uint = 0xFFD3; +pub const XK_R2: c_uint = 0xFFD3; +pub const XK_F23: c_uint = 0xFFD4; +pub const XK_R3: c_uint = 0xFFD4; +pub const XK_F24: c_uint = 0xFFD5; +pub const XK_R4: c_uint = 0xFFD5; +pub const XK_F25: c_uint = 0xFFD6; +pub const XK_R5: c_uint = 0xFFD6; +pub const XK_F26: c_uint = 0xFFD7; +pub const XK_R6: c_uint = 0xFFD7; +pub const XK_F27: c_uint = 0xFFD8; +pub const XK_R7: c_uint = 0xFFD8; +pub const XK_F28: c_uint = 0xFFD9; +pub const XK_R8: c_uint = 0xFFD9; +pub const XK_F29: c_uint = 0xFFDA; +pub const XK_R9: c_uint = 0xFFDA; +pub const XK_F30: c_uint = 0xFFDB; +pub const XK_R10: c_uint = 0xFFDB; +pub const XK_F31: c_uint = 0xFFDC; +pub const XK_R11: c_uint = 0xFFDC; +pub const XK_F32: c_uint = 0xFFDD; +pub const XK_R12: c_uint = 0xFFDD; +pub const XK_F33: c_uint = 0xFFDE; +pub const XK_R13: c_uint = 0xFFDE; +pub const XK_F34: c_uint = 0xFFDF; +pub const XK_R14: c_uint = 0xFFDF; +pub const XK_F35: c_uint = 0xFFE0; +pub const XK_R15: c_uint = 0xFFE0; +pub const XK_Shift_L: c_uint = 0xFFE1; +pub const XK_Shift_R: c_uint = 0xFFE2; +pub const XK_Control_L: c_uint = 0xFFE3; +pub const XK_Control_R: c_uint = 0xFFE4; +pub const XK_Caps_Lock: c_uint = 0xFFE5; +pub const XK_Shift_Lock: c_uint = 0xFFE6; +pub const XK_Meta_L: c_uint = 0xFFE7; +pub const XK_Meta_R: c_uint = 0xFFE8; +pub const XK_Alt_L: c_uint = 0xFFE9; +pub const XK_Alt_R: c_uint = 0xFFEA; +pub const XK_Super_L: c_uint = 0xFFEB; +pub const XK_Super_R: c_uint = 0xFFEC; +pub const XK_Hyper_L: c_uint = 0xFFED; +pub const XK_Hyper_R: c_uint = 0xFFEE; +pub const XK_space: c_uint = 0x020; +pub const XK_exclam: c_uint = 0x021; +pub const XK_quotedbl: c_uint = 0x022; +pub const XK_numbersign: c_uint = 0x023; +pub const XK_dollar: c_uint = 0x024; +pub const XK_percent: c_uint = 0x025; +pub const XK_ampersand: c_uint = 0x026; +pub const XK_apostrophe: c_uint = 0x027; +pub const XK_quoteright: c_uint = 0x027; +pub const XK_parenleft: c_uint = 0x028; +pub const XK_parenright: c_uint = 0x029; +pub const XK_asterisk: c_uint = 0x02a; +pub const XK_plus: c_uint = 0x02b; +pub const XK_comma: c_uint = 0x02c; +pub const XK_minus: c_uint = 0x02d; +pub const XK_period: c_uint = 0x02e; +pub const XK_slash: c_uint = 0x02f; +pub const XK_0: c_uint = 0x030; +pub const XK_1: c_uint = 0x031; +pub const XK_2: c_uint = 0x032; +pub const XK_3: c_uint = 0x033; +pub const XK_4: c_uint = 0x034; +pub const XK_5: c_uint = 0x035; +pub const XK_6: c_uint = 0x036; +pub const XK_7: c_uint = 0x037; +pub const XK_8: c_uint = 0x038; +pub const XK_9: c_uint = 0x039; +pub const XK_colon: c_uint = 0x03a; +pub const XK_semicolon: c_uint = 0x03b; +pub const XK_less: c_uint = 0x03c; +pub const XK_equal: c_uint = 0x03d; +pub const XK_greater: c_uint = 0x03e; +pub const XK_question: c_uint = 0x03f; +pub const XK_at: c_uint = 0x040; +pub const XK_A: c_uint = 0x041; +pub const XK_B: c_uint = 0x042; +pub const XK_C: c_uint = 0x043; +pub const XK_D: c_uint = 0x044; +pub const XK_E: c_uint = 0x045; +pub const XK_F: c_uint = 0x046; +pub const XK_G: c_uint = 0x047; +pub const XK_H: c_uint = 0x048; +pub const XK_I: c_uint = 0x049; +pub const XK_J: c_uint = 0x04a; +pub const XK_K: c_uint = 0x04b; +pub const XK_L: c_uint = 0x04c; +pub const XK_M: c_uint = 0x04d; +pub const XK_N: c_uint = 0x04e; +pub const XK_O: c_uint = 0x04f; +pub const XK_P: c_uint = 0x050; +pub const XK_Q: c_uint = 0x051; +pub const XK_R: c_uint = 0x052; +pub const XK_S: c_uint = 0x053; +pub const XK_T: c_uint = 0x054; +pub const XK_U: c_uint = 0x055; +pub const XK_V: c_uint = 0x056; +pub const XK_W: c_uint = 0x057; +pub const XK_X: c_uint = 0x058; +pub const XK_Y: c_uint = 0x059; +pub const XK_Z: c_uint = 0x05a; +pub const XK_bracketleft: c_uint = 0x05b; +pub const XK_backslash: c_uint = 0x05c; +pub const XK_bracketright: c_uint = 0x05d; +pub const XK_asciicircum: c_uint = 0x05e; +pub const XK_underscore: c_uint = 0x05f; +pub const XK_grave: c_uint = 0x060; +pub const XK_quoteleft: c_uint = 0x060; +pub const XK_a: c_uint = 0x061; +pub const XK_b: c_uint = 0x062; +pub const XK_c: c_uint = 0x063; +pub const XK_d: c_uint = 0x064; +pub const XK_e: c_uint = 0x065; +pub const XK_f: c_uint = 0x066; +pub const XK_g: c_uint = 0x067; +pub const XK_h: c_uint = 0x068; +pub const XK_i: c_uint = 0x069; +pub const XK_j: c_uint = 0x06a; +pub const XK_k: c_uint = 0x06b; +pub const XK_l: c_uint = 0x06c; +pub const XK_m: c_uint = 0x06d; +pub const XK_n: c_uint = 0x06e; +pub const XK_o: c_uint = 0x06f; +pub const XK_p: c_uint = 0x070; +pub const XK_q: c_uint = 0x071; +pub const XK_r: c_uint = 0x072; +pub const XK_s: c_uint = 0x073; +pub const XK_t: c_uint = 0x074; +pub const XK_u: c_uint = 0x075; +pub const XK_v: c_uint = 0x076; +pub const XK_w: c_uint = 0x077; +pub const XK_x: c_uint = 0x078; +pub const XK_y: c_uint = 0x079; +pub const XK_z: c_uint = 0x07a; +pub const XK_braceleft: c_uint = 0x07b; +pub const XK_bar: c_uint = 0x07c; +pub const XK_braceright: c_uint = 0x07d; +pub const XK_asciitilde: c_uint = 0x07e; +pub const XK_nobreakspace: c_uint = 0x0a0; +pub const XK_exclamdown: c_uint = 0x0a1; +pub const XK_cent: c_uint = 0x0a2; +pub const XK_sterling: c_uint = 0x0a3; +pub const XK_currency: c_uint = 0x0a4; +pub const XK_yen: c_uint = 0x0a5; +pub const XK_brokenbar: c_uint = 0x0a6; +pub const XK_section: c_uint = 0x0a7; +pub const XK_diaeresis: c_uint = 0x0a8; +pub const XK_copyright: c_uint = 0x0a9; +pub const XK_ordfeminine: c_uint = 0x0aa; +pub const XK_guillemotleft: c_uint = 0x0ab; +pub const XK_notsign: c_uint = 0x0ac; +pub const XK_hyphen: c_uint = 0x0ad; +pub const XK_registered: c_uint = 0x0ae; +pub const XK_macron: c_uint = 0x0af; +pub const XK_degree: c_uint = 0x0b0; +pub const XK_plusminus: c_uint = 0x0b1; +pub const XK_twosuperior: c_uint = 0x0b2; +pub const XK_threesuperior: c_uint = 0x0b3; +pub const XK_acute: c_uint = 0x0b4; +pub const XK_mu: c_uint = 0x0b5; +pub const XK_paragraph: c_uint = 0x0b6; +pub const XK_periodcentered: c_uint = 0x0b7; +pub const XK_cedilla: c_uint = 0x0b8; +pub const XK_onesuperior: c_uint = 0x0b9; +pub const XK_masculine: c_uint = 0x0ba; +pub const XK_guillemotright: c_uint = 0x0bb; +pub const XK_onequarter: c_uint = 0x0bc; +pub const XK_onehalf: c_uint = 0x0bd; +pub const XK_threequarters: c_uint = 0x0be; +pub const XK_questiondown: c_uint = 0x0bf; +pub const XK_Agrave: c_uint = 0x0c0; +pub const XK_Aacute: c_uint = 0x0c1; +pub const XK_Acircumflex: c_uint = 0x0c2; +pub const XK_Atilde: c_uint = 0x0c3; +pub const XK_Adiaeresis: c_uint = 0x0c4; +pub const XK_Aring: c_uint = 0x0c5; +pub const XK_AE: c_uint = 0x0c6; +pub const XK_Ccedilla: c_uint = 0x0c7; +pub const XK_Egrave: c_uint = 0x0c8; +pub const XK_Eacute: c_uint = 0x0c9; +pub const XK_Ecircumflex: c_uint = 0x0ca; +pub const XK_Ediaeresis: c_uint = 0x0cb; +pub const XK_Igrave: c_uint = 0x0cc; +pub const XK_Iacute: c_uint = 0x0cd; +pub const XK_Icircumflex: c_uint = 0x0ce; +pub const XK_Idiaeresis: c_uint = 0x0cf; +pub const XK_ETH: c_uint = 0x0d0; +pub const XK_Eth: c_uint = 0x0d0; +pub const XK_Ntilde: c_uint = 0x0d1; +pub const XK_Ograve: c_uint = 0x0d2; +pub const XK_Oacute: c_uint = 0x0d3; +pub const XK_Ocircumflex: c_uint = 0x0d4; +pub const XK_Otilde: c_uint = 0x0d5; +pub const XK_Odiaeresis: c_uint = 0x0d6; +pub const XK_multiply: c_uint = 0x0d7; +pub const XK_Ooblique: c_uint = 0x0d8; +pub const XK_Ugrave: c_uint = 0x0d9; +pub const XK_Uacute: c_uint = 0x0da; +pub const XK_Ucircumflex: c_uint = 0x0db; +pub const XK_Udiaeresis: c_uint = 0x0dc; +pub const XK_Yacute: c_uint = 0x0dd; +pub const XK_THORN: c_uint = 0x0de; +pub const XK_Thorn: c_uint = 0x0de; +pub const XK_ssharp: c_uint = 0x0df; +pub const XK_agrave: c_uint = 0x0e0; +pub const XK_aacute: c_uint = 0x0e1; +pub const XK_acircumflex: c_uint = 0x0e2; +pub const XK_atilde: c_uint = 0x0e3; +pub const XK_adiaeresis: c_uint = 0x0e4; +pub const XK_aring: c_uint = 0x0e5; +pub const XK_ae: c_uint = 0x0e6; +pub const XK_ccedilla: c_uint = 0x0e7; +pub const XK_egrave: c_uint = 0x0e8; +pub const XK_eacute: c_uint = 0x0e9; +pub const XK_ecircumflex: c_uint = 0x0ea; +pub const XK_ediaeresis: c_uint = 0x0eb; +pub const XK_igrave: c_uint = 0x0ec; +pub const XK_iacute: c_uint = 0x0ed; +pub const XK_icircumflex: c_uint = 0x0ee; +pub const XK_idiaeresis: c_uint = 0x0ef; +pub const XK_eth: c_uint = 0x0f0; +pub const XK_ntilde: c_uint = 0x0f1; +pub const XK_ograve: c_uint = 0x0f2; +pub const XK_oacute: c_uint = 0x0f3; +pub const XK_ocircumflex: c_uint = 0x0f4; +pub const XK_otilde: c_uint = 0x0f5; +pub const XK_odiaeresis: c_uint = 0x0f6; +pub const XK_division: c_uint = 0x0f7; +pub const XK_oslash: c_uint = 0x0f8; +pub const XK_ugrave: c_uint = 0x0f9; +pub const XK_uacute: c_uint = 0x0fa; +pub const XK_ucircumflex: c_uint = 0x0fb; +pub const XK_udiaeresis: c_uint = 0x0fc; +pub const XK_yacute: c_uint = 0x0fd; +pub const XK_thorn: c_uint = 0x0fe; +pub const XK_ydiaeresis: c_uint = 0x0ff; +pub const XK_Aogonek: c_uint = 0x1a1; +pub const XK_breve: c_uint = 0x1a2; +pub const XK_Lstroke: c_uint = 0x1a3; +pub const XK_Lcaron: c_uint = 0x1a5; +pub const XK_Sacute: c_uint = 0x1a6; +pub const XK_Scaron: c_uint = 0x1a9; +pub const XK_Scedilla: c_uint = 0x1aa; +pub const XK_Tcaron: c_uint = 0x1ab; +pub const XK_Zacute: c_uint = 0x1ac; +pub const XK_Zcaron: c_uint = 0x1ae; +pub const XK_Zabovedot: c_uint = 0x1af; +pub const XK_aogonek: c_uint = 0x1b1; +pub const XK_ogonek: c_uint = 0x1b2; +pub const XK_lstroke: c_uint = 0x1b3; +pub const XK_lcaron: c_uint = 0x1b5; +pub const XK_sacute: c_uint = 0x1b6; +pub const XK_caron: c_uint = 0x1b7; +pub const XK_scaron: c_uint = 0x1b9; +pub const XK_scedilla: c_uint = 0x1ba; +pub const XK_tcaron: c_uint = 0x1bb; +pub const XK_zacute: c_uint = 0x1bc; +pub const XK_doubleacute: c_uint = 0x1bd; +pub const XK_zcaron: c_uint = 0x1be; +pub const XK_zabovedot: c_uint = 0x1bf; +pub const XK_Racute: c_uint = 0x1c0; +pub const XK_Abreve: c_uint = 0x1c3; +pub const XK_Lacute: c_uint = 0x1c5; +pub const XK_Cacute: c_uint = 0x1c6; +pub const XK_Ccaron: c_uint = 0x1c8; +pub const XK_Eogonek: c_uint = 0x1ca; +pub const XK_Ecaron: c_uint = 0x1cc; +pub const XK_Dcaron: c_uint = 0x1cf; +pub const XK_Dstroke: c_uint = 0x1d0; +pub const XK_Nacute: c_uint = 0x1d1; +pub const XK_Ncaron: c_uint = 0x1d2; +pub const XK_Odoubleacute: c_uint = 0x1d5; +pub const XK_Rcaron: c_uint = 0x1d8; +pub const XK_Uring: c_uint = 0x1d9; +pub const XK_Udoubleacute: c_uint = 0x1db; +pub const XK_Tcedilla: c_uint = 0x1de; +pub const XK_racute: c_uint = 0x1e0; +pub const XK_abreve: c_uint = 0x1e3; +pub const XK_lacute: c_uint = 0x1e5; +pub const XK_cacute: c_uint = 0x1e6; +pub const XK_ccaron: c_uint = 0x1e8; +pub const XK_eogonek: c_uint = 0x1ea; +pub const XK_ecaron: c_uint = 0x1ec; +pub const XK_dcaron: c_uint = 0x1ef; +pub const XK_dstroke: c_uint = 0x1f0; +pub const XK_nacute: c_uint = 0x1f1; +pub const XK_ncaron: c_uint = 0x1f2; +pub const XK_odoubleacute: c_uint = 0x1f5; +pub const XK_udoubleacute: c_uint = 0x1fb; +pub const XK_rcaron: c_uint = 0x1f8; +pub const XK_uring: c_uint = 0x1f9; +pub const XK_tcedilla: c_uint = 0x1fe; +pub const XK_abovedot: c_uint = 0x1ff; +pub const XK_Hstroke: c_uint = 0x2a1; +pub const XK_Hcircumflex: c_uint = 0x2a6; +pub const XK_Iabovedot: c_uint = 0x2a9; +pub const XK_Gbreve: c_uint = 0x2ab; +pub const XK_Jcircumflex: c_uint = 0x2ac; +pub const XK_hstroke: c_uint = 0x2b1; +pub const XK_hcircumflex: c_uint = 0x2b6; +pub const XK_idotless: c_uint = 0x2b9; +pub const XK_gbreve: c_uint = 0x2bb; +pub const XK_jcircumflex: c_uint = 0x2bc; +pub const XK_Cabovedot: c_uint = 0x2c5; +pub const XK_Ccircumflex: c_uint = 0x2c6; +pub const XK_Gabovedot: c_uint = 0x2d5; +pub const XK_Gcircumflex: c_uint = 0x2d8; +pub const XK_Ubreve: c_uint = 0x2dd; +pub const XK_Scircumflex: c_uint = 0x2de; +pub const XK_cabovedot: c_uint = 0x2e5; +pub const XK_ccircumflex: c_uint = 0x2e6; +pub const XK_gabovedot: c_uint = 0x2f5; +pub const XK_gcircumflex: c_uint = 0x2f8; +pub const XK_ubreve: c_uint = 0x2fd; +pub const XK_scircumflex: c_uint = 0x2fe; +pub const XK_kra: c_uint = 0x3a2; +pub const XK_kappa: c_uint = 0x3a2; +pub const XK_Rcedilla: c_uint = 0x3a3; +pub const XK_Itilde: c_uint = 0x3a5; +pub const XK_Lcedilla: c_uint = 0x3a6; +pub const XK_Emacron: c_uint = 0x3aa; +pub const XK_Gcedilla: c_uint = 0x3ab; +pub const XK_Tslash: c_uint = 0x3ac; +pub const XK_rcedilla: c_uint = 0x3b3; +pub const XK_itilde: c_uint = 0x3b5; +pub const XK_lcedilla: c_uint = 0x3b6; +pub const XK_emacron: c_uint = 0x3ba; +pub const XK_gcedilla: c_uint = 0x3bb; +pub const XK_tslash: c_uint = 0x3bc; +pub const XK_ENG: c_uint = 0x3bd; +pub const XK_eng: c_uint = 0x3bf; +pub const XK_Amacron: c_uint = 0x3c0; +pub const XK_Iogonek: c_uint = 0x3c7; +pub const XK_Eabovedot: c_uint = 0x3cc; +pub const XK_Imacron: c_uint = 0x3cf; +pub const XK_Ncedilla: c_uint = 0x3d1; +pub const XK_Omacron: c_uint = 0x3d2; +pub const XK_Kcedilla: c_uint = 0x3d3; +pub const XK_Uogonek: c_uint = 0x3d9; +pub const XK_Utilde: c_uint = 0x3dd; +pub const XK_Umacron: c_uint = 0x3de; +pub const XK_amacron: c_uint = 0x3e0; +pub const XK_iogonek: c_uint = 0x3e7; +pub const XK_eabovedot: c_uint = 0x3ec; +pub const XK_imacron: c_uint = 0x3ef; +pub const XK_ncedilla: c_uint = 0x3f1; +pub const XK_omacron: c_uint = 0x3f2; +pub const XK_kcedilla: c_uint = 0x3f3; +pub const XK_uogonek: c_uint = 0x3f9; +pub const XK_utilde: c_uint = 0x3fd; +pub const XK_umacron: c_uint = 0x3fe; +pub const XK_overline: c_uint = 0x47e; +pub const XK_kana_fullstop: c_uint = 0x4a1; +pub const XK_kana_openingbracket: c_uint = 0x4a2; +pub const XK_kana_closingbracket: c_uint = 0x4a3; +pub const XK_kana_comma: c_uint = 0x4a4; +pub const XK_kana_conjunctive: c_uint = 0x4a5; +pub const XK_kana_middledot: c_uint = 0x4a5; +pub const XK_kana_WO: c_uint = 0x4a6; +pub const XK_kana_a: c_uint = 0x4a7; +pub const XK_kana_i: c_uint = 0x4a8; +pub const XK_kana_u: c_uint = 0x4a9; +pub const XK_kana_e: c_uint = 0x4aa; +pub const XK_kana_o: c_uint = 0x4ab; +pub const XK_kana_ya: c_uint = 0x4ac; +pub const XK_kana_yu: c_uint = 0x4ad; +pub const XK_kana_yo: c_uint = 0x4ae; +pub const XK_kana_tsu: c_uint = 0x4af; +pub const XK_kana_tu: c_uint = 0x4af; +pub const XK_prolongedsound: c_uint = 0x4b0; +pub const XK_kana_A: c_uint = 0x4b1; +pub const XK_kana_I: c_uint = 0x4b2; +pub const XK_kana_U: c_uint = 0x4b3; +pub const XK_kana_E: c_uint = 0x4b4; +pub const XK_kana_O: c_uint = 0x4b5; +pub const XK_kana_KA: c_uint = 0x4b6; +pub const XK_kana_KI: c_uint = 0x4b7; +pub const XK_kana_KU: c_uint = 0x4b8; +pub const XK_kana_KE: c_uint = 0x4b9; +pub const XK_kana_KO: c_uint = 0x4ba; +pub const XK_kana_SA: c_uint = 0x4bb; +pub const XK_kana_SHI: c_uint = 0x4bc; +pub const XK_kana_SU: c_uint = 0x4bd; +pub const XK_kana_SE: c_uint = 0x4be; +pub const XK_kana_SO: c_uint = 0x4bf; +pub const XK_kana_TA: c_uint = 0x4c0; +pub const XK_kana_CHI: c_uint = 0x4c1; +pub const XK_kana_TI: c_uint = 0x4c1; +pub const XK_kana_TSU: c_uint = 0x4c2; +pub const XK_kana_TU: c_uint = 0x4c2; +pub const XK_kana_TE: c_uint = 0x4c3; +pub const XK_kana_TO: c_uint = 0x4c4; +pub const XK_kana_NA: c_uint = 0x4c5; +pub const XK_kana_NI: c_uint = 0x4c6; +pub const XK_kana_NU: c_uint = 0x4c7; +pub const XK_kana_NE: c_uint = 0x4c8; +pub const XK_kana_NO: c_uint = 0x4c9; +pub const XK_kana_HA: c_uint = 0x4ca; +pub const XK_kana_HI: c_uint = 0x4cb; +pub const XK_kana_FU: c_uint = 0x4cc; +pub const XK_kana_HU: c_uint = 0x4cc; +pub const XK_kana_HE: c_uint = 0x4cd; +pub const XK_kana_HO: c_uint = 0x4ce; +pub const XK_kana_MA: c_uint = 0x4cf; +pub const XK_kana_MI: c_uint = 0x4d0; +pub const XK_kana_MU: c_uint = 0x4d1; +pub const XK_kana_ME: c_uint = 0x4d2; +pub const XK_kana_MO: c_uint = 0x4d3; +pub const XK_kana_YA: c_uint = 0x4d4; +pub const XK_kana_YU: c_uint = 0x4d5; +pub const XK_kana_YO: c_uint = 0x4d6; +pub const XK_kana_RA: c_uint = 0x4d7; +pub const XK_kana_RI: c_uint = 0x4d8; +pub const XK_kana_RU: c_uint = 0x4d9; +pub const XK_kana_RE: c_uint = 0x4da; +pub const XK_kana_RO: c_uint = 0x4db; +pub const XK_kana_WA: c_uint = 0x4dc; +pub const XK_kana_N: c_uint = 0x4dd; +pub const XK_voicedsound: c_uint = 0x4de; +pub const XK_semivoicedsound: c_uint = 0x4df; +pub const XK_kana_switch: c_uint = 0xFF7E; +pub const XK_Arabic_comma: c_uint = 0x5ac; +pub const XK_Arabic_semicolon: c_uint = 0x5bb; +pub const XK_Arabic_question_mark: c_uint = 0x5bf; +pub const XK_Arabic_hamza: c_uint = 0x5c1; +pub const XK_Arabic_maddaonalef: c_uint = 0x5c2; +pub const XK_Arabic_hamzaonalef: c_uint = 0x5c3; +pub const XK_Arabic_hamzaonwaw: c_uint = 0x5c4; +pub const XK_Arabic_hamzaunderalef: c_uint = 0x5c5; +pub const XK_Arabic_hamzaonyeh: c_uint = 0x5c6; +pub const XK_Arabic_alef: c_uint = 0x5c7; +pub const XK_Arabic_beh: c_uint = 0x5c8; +pub const XK_Arabic_tehmarbuta: c_uint = 0x5c9; +pub const XK_Arabic_teh: c_uint = 0x5ca; +pub const XK_Arabic_theh: c_uint = 0x5cb; +pub const XK_Arabic_jeem: c_uint = 0x5cc; +pub const XK_Arabic_hah: c_uint = 0x5cd; +pub const XK_Arabic_khah: c_uint = 0x5ce; +pub const XK_Arabic_dal: c_uint = 0x5cf; +pub const XK_Arabic_thal: c_uint = 0x5d0; +pub const XK_Arabic_ra: c_uint = 0x5d1; +pub const XK_Arabic_zain: c_uint = 0x5d2; +pub const XK_Arabic_seen: c_uint = 0x5d3; +pub const XK_Arabic_sheen: c_uint = 0x5d4; +pub const XK_Arabic_sad: c_uint = 0x5d5; +pub const XK_Arabic_dad: c_uint = 0x5d6; +pub const XK_Arabic_tah: c_uint = 0x5d7; +pub const XK_Arabic_zah: c_uint = 0x5d8; +pub const XK_Arabic_ain: c_uint = 0x5d9; +pub const XK_Arabic_ghain: c_uint = 0x5da; +pub const XK_Arabic_tatweel: c_uint = 0x5e0; +pub const XK_Arabic_feh: c_uint = 0x5e1; +pub const XK_Arabic_qaf: c_uint = 0x5e2; +pub const XK_Arabic_kaf: c_uint = 0x5e3; +pub const XK_Arabic_lam: c_uint = 0x5e4; +pub const XK_Arabic_meem: c_uint = 0x5e5; +pub const XK_Arabic_noon: c_uint = 0x5e6; +pub const XK_Arabic_ha: c_uint = 0x5e7; +pub const XK_Arabic_heh: c_uint = 0x5e7; +pub const XK_Arabic_waw: c_uint = 0x5e8; +pub const XK_Arabic_alefmaksura: c_uint = 0x5e9; +pub const XK_Arabic_yeh: c_uint = 0x5ea; +pub const XK_Arabic_fathatan: c_uint = 0x5eb; +pub const XK_Arabic_dammatan: c_uint = 0x5ec; +pub const XK_Arabic_kasratan: c_uint = 0x5ed; +pub const XK_Arabic_fatha: c_uint = 0x5ee; +pub const XK_Arabic_damma: c_uint = 0x5ef; +pub const XK_Arabic_kasra: c_uint = 0x5f0; +pub const XK_Arabic_shadda: c_uint = 0x5f1; +pub const XK_Arabic_sukun: c_uint = 0x5f2; +pub const XK_Arabic_switch: c_uint = 0xFF7E; +pub const XK_Serbian_dje: c_uint = 0x6a1; +pub const XK_Macedonia_gje: c_uint = 0x6a2; +pub const XK_Cyrillic_io: c_uint = 0x6a3; +pub const XK_Ukrainian_ie: c_uint = 0x6a4; +pub const XK_Ukranian_je: c_uint = 0x6a4; +pub const XK_Macedonia_dse: c_uint = 0x6a5; +pub const XK_Ukrainian_i: c_uint = 0x6a6; +pub const XK_Ukranian_i: c_uint = 0x6a6; +pub const XK_Ukrainian_yi: c_uint = 0x6a7; +pub const XK_Ukranian_yi: c_uint = 0x6a7; +pub const XK_Cyrillic_je: c_uint = 0x6a8; +pub const XK_Serbian_je: c_uint = 0x6a8; +pub const XK_Cyrillic_lje: c_uint = 0x6a9; +pub const XK_Serbian_lje: c_uint = 0x6a9; +pub const XK_Cyrillic_nje: c_uint = 0x6aa; +pub const XK_Serbian_nje: c_uint = 0x6aa; +pub const XK_Serbian_tshe: c_uint = 0x6ab; +pub const XK_Macedonia_kje: c_uint = 0x6ac; +pub const XK_Byelorussian_shortu: c_uint = 0x6ae; +pub const XK_Cyrillic_dzhe: c_uint = 0x6af; +pub const XK_Serbian_dze: c_uint = 0x6af; +pub const XK_numerosign: c_uint = 0x6b0; +pub const XK_Serbian_DJE: c_uint = 0x6b1; +pub const XK_Macedonia_GJE: c_uint = 0x6b2; +pub const XK_Cyrillic_IO: c_uint = 0x6b3; +pub const XK_Ukrainian_IE: c_uint = 0x6b4; +pub const XK_Ukranian_JE: c_uint = 0x6b4; +pub const XK_Macedonia_DSE: c_uint = 0x6b5; +pub const XK_Ukrainian_I: c_uint = 0x6b6; +pub const XK_Ukranian_I: c_uint = 0x6b6; +pub const XK_Ukrainian_YI: c_uint = 0x6b7; +pub const XK_Ukranian_YI: c_uint = 0x6b7; +pub const XK_Cyrillic_JE: c_uint = 0x6b8; +pub const XK_Serbian_JE: c_uint = 0x6b8; +pub const XK_Cyrillic_LJE: c_uint = 0x6b9; +pub const XK_Serbian_LJE: c_uint = 0x6b9; +pub const XK_Cyrillic_NJE: c_uint = 0x6ba; +pub const XK_Serbian_NJE: c_uint = 0x6ba; +pub const XK_Serbian_TSHE: c_uint = 0x6bb; +pub const XK_Macedonia_KJE: c_uint = 0x6bc; +pub const XK_Byelorussian_SHORTU: c_uint = 0x6be; +pub const XK_Cyrillic_DZHE: c_uint = 0x6bf; +pub const XK_Serbian_DZE: c_uint = 0x6bf; +pub const XK_Cyrillic_yu: c_uint = 0x6c0; +pub const XK_Cyrillic_a: c_uint = 0x6c1; +pub const XK_Cyrillic_be: c_uint = 0x6c2; +pub const XK_Cyrillic_tse: c_uint = 0x6c3; +pub const XK_Cyrillic_de: c_uint = 0x6c4; +pub const XK_Cyrillic_ie: c_uint = 0x6c5; +pub const XK_Cyrillic_ef: c_uint = 0x6c6; +pub const XK_Cyrillic_ghe: c_uint = 0x6c7; +pub const XK_Cyrillic_ha: c_uint = 0x6c8; +pub const XK_Cyrillic_i: c_uint = 0x6c9; +pub const XK_Cyrillic_shorti: c_uint = 0x6ca; +pub const XK_Cyrillic_ka: c_uint = 0x6cb; +pub const XK_Cyrillic_el: c_uint = 0x6cc; +pub const XK_Cyrillic_em: c_uint = 0x6cd; +pub const XK_Cyrillic_en: c_uint = 0x6ce; +pub const XK_Cyrillic_o: c_uint = 0x6cf; +pub const XK_Cyrillic_pe: c_uint = 0x6d0; +pub const XK_Cyrillic_ya: c_uint = 0x6d1; +pub const XK_Cyrillic_er: c_uint = 0x6d2; +pub const XK_Cyrillic_es: c_uint = 0x6d3; +pub const XK_Cyrillic_te: c_uint = 0x6d4; +pub const XK_Cyrillic_u: c_uint = 0x6d5; +pub const XK_Cyrillic_zhe: c_uint = 0x6d6; +pub const XK_Cyrillic_ve: c_uint = 0x6d7; +pub const XK_Cyrillic_softsign: c_uint = 0x6d8; +pub const XK_Cyrillic_yeru: c_uint = 0x6d9; +pub const XK_Cyrillic_ze: c_uint = 0x6da; +pub const XK_Cyrillic_sha: c_uint = 0x6db; +pub const XK_Cyrillic_e: c_uint = 0x6dc; +pub const XK_Cyrillic_shcha: c_uint = 0x6dd; +pub const XK_Cyrillic_che: c_uint = 0x6de; +pub const XK_Cyrillic_hardsign: c_uint = 0x6df; +pub const XK_Cyrillic_YU: c_uint = 0x6e0; +pub const XK_Cyrillic_A: c_uint = 0x6e1; +pub const XK_Cyrillic_BE: c_uint = 0x6e2; +pub const XK_Cyrillic_TSE: c_uint = 0x6e3; +pub const XK_Cyrillic_DE: c_uint = 0x6e4; +pub const XK_Cyrillic_IE: c_uint = 0x6e5; +pub const XK_Cyrillic_EF: c_uint = 0x6e6; +pub const XK_Cyrillic_GHE: c_uint = 0x6e7; +pub const XK_Cyrillic_HA: c_uint = 0x6e8; +pub const XK_Cyrillic_I: c_uint = 0x6e9; +pub const XK_Cyrillic_SHORTI: c_uint = 0x6ea; +pub const XK_Cyrillic_KA: c_uint = 0x6eb; +pub const XK_Cyrillic_EL: c_uint = 0x6ec; +pub const XK_Cyrillic_EM: c_uint = 0x6ed; +pub const XK_Cyrillic_EN: c_uint = 0x6ee; +pub const XK_Cyrillic_O: c_uint = 0x6ef; +pub const XK_Cyrillic_PE: c_uint = 0x6f0; +pub const XK_Cyrillic_YA: c_uint = 0x6f1; +pub const XK_Cyrillic_ER: c_uint = 0x6f2; +pub const XK_Cyrillic_ES: c_uint = 0x6f3; +pub const XK_Cyrillic_TE: c_uint = 0x6f4; +pub const XK_Cyrillic_U: c_uint = 0x6f5; +pub const XK_Cyrillic_ZHE: c_uint = 0x6f6; +pub const XK_Cyrillic_VE: c_uint = 0x6f7; +pub const XK_Cyrillic_SOFTSIGN: c_uint = 0x6f8; +pub const XK_Cyrillic_YERU: c_uint = 0x6f9; +pub const XK_Cyrillic_ZE: c_uint = 0x6fa; +pub const XK_Cyrillic_SHA: c_uint = 0x6fb; +pub const XK_Cyrillic_E: c_uint = 0x6fc; +pub const XK_Cyrillic_SHCHA: c_uint = 0x6fd; +pub const XK_Cyrillic_CHE: c_uint = 0x6fe; +pub const XK_Cyrillic_HARDSIGN: c_uint = 0x6ff; +pub const XK_Greek_ALPHAaccent: c_uint = 0x7a1; +pub const XK_Greek_EPSILONaccent: c_uint = 0x7a2; +pub const XK_Greek_ETAaccent: c_uint = 0x7a3; +pub const XK_Greek_IOTAaccent: c_uint = 0x7a4; +pub const XK_Greek_IOTAdiaeresis: c_uint = 0x7a5; +pub const XK_Greek_OMICRONaccent: c_uint = 0x7a7; +pub const XK_Greek_UPSILONaccent: c_uint = 0x7a8; +pub const XK_Greek_UPSILONdieresis: c_uint = 0x7a9; +pub const XK_Greek_OMEGAaccent: c_uint = 0x7ab; +pub const XK_Greek_accentdieresis: c_uint = 0x7ae; +pub const XK_Greek_horizbar: c_uint = 0x7af; +pub const XK_Greek_alphaaccent: c_uint = 0x7b1; +pub const XK_Greek_epsilonaccent: c_uint = 0x7b2; +pub const XK_Greek_etaaccent: c_uint = 0x7b3; +pub const XK_Greek_iotaaccent: c_uint = 0x7b4; +pub const XK_Greek_iotadieresis: c_uint = 0x7b5; +pub const XK_Greek_iotaaccentdieresis: c_uint = 0x7b6; +pub const XK_Greek_omicronaccent: c_uint = 0x7b7; +pub const XK_Greek_upsilonaccent: c_uint = 0x7b8; +pub const XK_Greek_upsilondieresis: c_uint = 0x7b9; +pub const XK_Greek_upsilonaccentdieresis: c_uint = 0x7ba; +pub const XK_Greek_omegaaccent: c_uint = 0x7bb; +pub const XK_Greek_ALPHA: c_uint = 0x7c1; +pub const XK_Greek_BETA: c_uint = 0x7c2; +pub const XK_Greek_GAMMA: c_uint = 0x7c3; +pub const XK_Greek_DELTA: c_uint = 0x7c4; +pub const XK_Greek_EPSILON: c_uint = 0x7c5; +pub const XK_Greek_ZETA: c_uint = 0x7c6; +pub const XK_Greek_ETA: c_uint = 0x7c7; +pub const XK_Greek_THETA: c_uint = 0x7c8; +pub const XK_Greek_IOTA: c_uint = 0x7c9; +pub const XK_Greek_KAPPA: c_uint = 0x7ca; +pub const XK_Greek_LAMDA: c_uint = 0x7cb; +pub const XK_Greek_LAMBDA: c_uint = 0x7cb; +pub const XK_Greek_MU: c_uint = 0x7cc; +pub const XK_Greek_NU: c_uint = 0x7cd; +pub const XK_Greek_XI: c_uint = 0x7ce; +pub const XK_Greek_OMICRON: c_uint = 0x7cf; +pub const XK_Greek_PI: c_uint = 0x7d0; +pub const XK_Greek_RHO: c_uint = 0x7d1; +pub const XK_Greek_SIGMA: c_uint = 0x7d2; +pub const XK_Greek_TAU: c_uint = 0x7d4; +pub const XK_Greek_UPSILON: c_uint = 0x7d5; +pub const XK_Greek_PHI: c_uint = 0x7d6; +pub const XK_Greek_CHI: c_uint = 0x7d7; +pub const XK_Greek_PSI: c_uint = 0x7d8; +pub const XK_Greek_OMEGA: c_uint = 0x7d9; +pub const XK_Greek_alpha: c_uint = 0x7e1; +pub const XK_Greek_beta: c_uint = 0x7e2; +pub const XK_Greek_gamma: c_uint = 0x7e3; +pub const XK_Greek_delta: c_uint = 0x7e4; +pub const XK_Greek_epsilon: c_uint = 0x7e5; +pub const XK_Greek_zeta: c_uint = 0x7e6; +pub const XK_Greek_eta: c_uint = 0x7e7; +pub const XK_Greek_theta: c_uint = 0x7e8; +pub const XK_Greek_iota: c_uint = 0x7e9; +pub const XK_Greek_kappa: c_uint = 0x7ea; +pub const XK_Greek_lamda: c_uint = 0x7eb; +pub const XK_Greek_lambda: c_uint = 0x7eb; +pub const XK_Greek_mu: c_uint = 0x7ec; +pub const XK_Greek_nu: c_uint = 0x7ed; +pub const XK_Greek_xi: c_uint = 0x7ee; +pub const XK_Greek_omicron: c_uint = 0x7ef; +pub const XK_Greek_pi: c_uint = 0x7f0; +pub const XK_Greek_rho: c_uint = 0x7f1; +pub const XK_Greek_sigma: c_uint = 0x7f2; +pub const XK_Greek_finalsmallsigma: c_uint = 0x7f3; +pub const XK_Greek_tau: c_uint = 0x7f4; +pub const XK_Greek_upsilon: c_uint = 0x7f5; +pub const XK_Greek_phi: c_uint = 0x7f6; +pub const XK_Greek_chi: c_uint = 0x7f7; +pub const XK_Greek_psi: c_uint = 0x7f8; +pub const XK_Greek_omega: c_uint = 0x7f9; +pub const XK_Greek_switch: c_uint = 0xFF7E; +pub const XK_leftradical: c_uint = 0x8a1; +pub const XK_topleftradical: c_uint = 0x8a2; +pub const XK_horizconnector: c_uint = 0x8a3; +pub const XK_topintegral: c_uint = 0x8a4; +pub const XK_botintegral: c_uint = 0x8a5; +pub const XK_vertconnector: c_uint = 0x8a6; +pub const XK_topleftsqbracket: c_uint = 0x8a7; +pub const XK_botleftsqbracket: c_uint = 0x8a8; +pub const XK_toprightsqbracket: c_uint = 0x8a9; +pub const XK_botrightsqbracket: c_uint = 0x8aa; +pub const XK_topleftparens: c_uint = 0x8ab; +pub const XK_botleftparens: c_uint = 0x8ac; +pub const XK_toprightparens: c_uint = 0x8ad; +pub const XK_botrightparens: c_uint = 0x8ae; +pub const XK_leftmiddlecurlybrace: c_uint = 0x8af; +pub const XK_rightmiddlecurlybrace: c_uint = 0x8b0; +pub const XK_topleftsummation: c_uint = 0x8b1; +pub const XK_botleftsummation: c_uint = 0x8b2; +pub const XK_topvertsummationconnector: c_uint = 0x8b3; +pub const XK_botvertsummationconnector: c_uint = 0x8b4; +pub const XK_toprightsummation: c_uint = 0x8b5; +pub const XK_botrightsummation: c_uint = 0x8b6; +pub const XK_rightmiddlesummation: c_uint = 0x8b7; +pub const XK_lessthanequal: c_uint = 0x8bc; +pub const XK_notequal: c_uint = 0x8bd; +pub const XK_greaterthanequal: c_uint = 0x8be; +pub const XK_integral: c_uint = 0x8bf; +pub const XK_therefore: c_uint = 0x8c0; +pub const XK_variation: c_uint = 0x8c1; +pub const XK_infinity: c_uint = 0x8c2; +pub const XK_nabla: c_uint = 0x8c5; +pub const XK_approximate: c_uint = 0x8c8; +pub const XK_similarequal: c_uint = 0x8c9; +pub const XK_ifonlyif: c_uint = 0x8cd; +pub const XK_implies: c_uint = 0x8ce; +pub const XK_identical: c_uint = 0x8cf; +pub const XK_radical: c_uint = 0x8d6; +pub const XK_includedin: c_uint = 0x8da; +pub const XK_includes: c_uint = 0x8db; +pub const XK_intersection: c_uint = 0x8dc; +pub const XK_union: c_uint = 0x8dd; +pub const XK_logicaland: c_uint = 0x8de; +pub const XK_logicalor: c_uint = 0x8df; +pub const XK_partialderivative: c_uint = 0x8ef; +pub const XK_function: c_uint = 0x8f6; +pub const XK_leftarrow: c_uint = 0x8fb; +pub const XK_uparrow: c_uint = 0x8fc; +pub const XK_rightarrow: c_uint = 0x8fd; +pub const XK_downarrow: c_uint = 0x8fe; +pub const XK_blank: c_uint = 0x9df; +pub const XK_soliddiamond: c_uint = 0x9e0; +pub const XK_checkerboard: c_uint = 0x9e1; +pub const XK_ht: c_uint = 0x9e2; +pub const XK_ff: c_uint = 0x9e3; +pub const XK_cr: c_uint = 0x9e4; +pub const XK_lf: c_uint = 0x9e5; +pub const XK_nl: c_uint = 0x9e8; +pub const XK_vt: c_uint = 0x9e9; +pub const XK_lowrightcorner: c_uint = 0x9ea; +pub const XK_uprightcorner: c_uint = 0x9eb; +pub const XK_upleftcorner: c_uint = 0x9ec; +pub const XK_lowleftcorner: c_uint = 0x9ed; +pub const XK_crossinglines: c_uint = 0x9ee; +pub const XK_horizlinescan1: c_uint = 0x9ef; +pub const XK_horizlinescan3: c_uint = 0x9f0; +pub const XK_horizlinescan5: c_uint = 0x9f1; +pub const XK_horizlinescan7: c_uint = 0x9f2; +pub const XK_horizlinescan9: c_uint = 0x9f3; +pub const XK_leftt: c_uint = 0x9f4; +pub const XK_rightt: c_uint = 0x9f5; +pub const XK_bott: c_uint = 0x9f6; +pub const XK_topt: c_uint = 0x9f7; +pub const XK_vertbar: c_uint = 0x9f8; +pub const XK_emspace: c_uint = 0xaa1; +pub const XK_enspace: c_uint = 0xaa2; +pub const XK_em3space: c_uint = 0xaa3; +pub const XK_em4space: c_uint = 0xaa4; +pub const XK_digitspace: c_uint = 0xaa5; +pub const XK_punctspace: c_uint = 0xaa6; +pub const XK_thinspace: c_uint = 0xaa7; +pub const XK_hairspace: c_uint = 0xaa8; +pub const XK_emdash: c_uint = 0xaa9; +pub const XK_endash: c_uint = 0xaaa; +pub const XK_signifblank: c_uint = 0xaac; +pub const XK_ellipsis: c_uint = 0xaae; +pub const XK_doubbaselinedot: c_uint = 0xaaf; +pub const XK_onethird: c_uint = 0xab0; +pub const XK_twothirds: c_uint = 0xab1; +pub const XK_onefifth: c_uint = 0xab2; +pub const XK_twofifths: c_uint = 0xab3; +pub const XK_threefifths: c_uint = 0xab4; +pub const XK_fourfifths: c_uint = 0xab5; +pub const XK_onesixth: c_uint = 0xab6; +pub const XK_fivesixths: c_uint = 0xab7; +pub const XK_careof: c_uint = 0xab8; +pub const XK_figdash: c_uint = 0xabb; +pub const XK_leftanglebracket: c_uint = 0xabc; +pub const XK_decimalpoint: c_uint = 0xabd; +pub const XK_rightanglebracket: c_uint = 0xabe; +pub const XK_marker: c_uint = 0xabf; +pub const XK_oneeighth: c_uint = 0xac3; +pub const XK_threeeighths: c_uint = 0xac4; +pub const XK_fiveeighths: c_uint = 0xac5; +pub const XK_seveneighths: c_uint = 0xac6; +pub const XK_trademark: c_uint = 0xac9; +pub const XK_signaturemark: c_uint = 0xaca; +pub const XK_trademarkincircle: c_uint = 0xacb; +pub const XK_leftopentriangle: c_uint = 0xacc; +pub const XK_rightopentriangle: c_uint = 0xacd; +pub const XK_emopencircle: c_uint = 0xace; +pub const XK_emopenrectangle: c_uint = 0xacf; +pub const XK_leftsinglequotemark: c_uint = 0xad0; +pub const XK_rightsinglequotemark: c_uint = 0xad1; +pub const XK_leftdoublequotemark: c_uint = 0xad2; +pub const XK_rightdoublequotemark: c_uint = 0xad3; +pub const XK_prescription: c_uint = 0xad4; +pub const XK_minutes: c_uint = 0xad6; +pub const XK_seconds: c_uint = 0xad7; +pub const XK_latincross: c_uint = 0xad9; +pub const XK_hexagram: c_uint = 0xada; +pub const XK_filledrectbullet: c_uint = 0xadb; +pub const XK_filledlefttribullet: c_uint = 0xadc; +pub const XK_filledrighttribullet: c_uint = 0xadd; +pub const XK_emfilledcircle: c_uint = 0xade; +pub const XK_emfilledrect: c_uint = 0xadf; +pub const XK_enopencircbullet: c_uint = 0xae0; +pub const XK_enopensquarebullet: c_uint = 0xae1; +pub const XK_openrectbullet: c_uint = 0xae2; +pub const XK_opentribulletup: c_uint = 0xae3; +pub const XK_opentribulletdown: c_uint = 0xae4; +pub const XK_openstar: c_uint = 0xae5; +pub const XK_enfilledcircbullet: c_uint = 0xae6; +pub const XK_enfilledsqbullet: c_uint = 0xae7; +pub const XK_filledtribulletup: c_uint = 0xae8; +pub const XK_filledtribulletdown: c_uint = 0xae9; +pub const XK_leftpointer: c_uint = 0xaea; +pub const XK_rightpointer: c_uint = 0xaeb; +pub const XK_club: c_uint = 0xaec; +pub const XK_diamond: c_uint = 0xaed; +pub const XK_heart: c_uint = 0xaee; +pub const XK_maltesecross: c_uint = 0xaf0; +pub const XK_dagger: c_uint = 0xaf1; +pub const XK_doubledagger: c_uint = 0xaf2; +pub const XK_checkmark: c_uint = 0xaf3; +pub const XK_ballotcross: c_uint = 0xaf4; +pub const XK_musicalsharp: c_uint = 0xaf5; +pub const XK_musicalflat: c_uint = 0xaf6; +pub const XK_malesymbol: c_uint = 0xaf7; +pub const XK_femalesymbol: c_uint = 0xaf8; +pub const XK_telephone: c_uint = 0xaf9; +pub const XK_telephonerecorder: c_uint = 0xafa; +pub const XK_phonographcopyright: c_uint = 0xafb; +pub const XK_caret: c_uint = 0xafc; +pub const XK_singlelowquotemark: c_uint = 0xafd; +pub const XK_doublelowquotemark: c_uint = 0xafe; +pub const XK_cursor: c_uint = 0xaff; +pub const XK_leftcaret: c_uint = 0xba3; +pub const XK_rightcaret: c_uint = 0xba6; +pub const XK_downcaret: c_uint = 0xba8; +pub const XK_upcaret: c_uint = 0xba9; +pub const XK_overbar: c_uint = 0xbc0; +pub const XK_downtack: c_uint = 0xbc2; +pub const XK_upshoe: c_uint = 0xbc3; +pub const XK_downstile: c_uint = 0xbc4; +pub const XK_underbar: c_uint = 0xbc6; +pub const XK_jot: c_uint = 0xbca; +pub const XK_quad: c_uint = 0xbcc; +pub const XK_uptack: c_uint = 0xbce; +pub const XK_circle: c_uint = 0xbcf; +pub const XK_upstile: c_uint = 0xbd3; +pub const XK_downshoe: c_uint = 0xbd6; +pub const XK_rightshoe: c_uint = 0xbd8; +pub const XK_leftshoe: c_uint = 0xbda; +pub const XK_lefttack: c_uint = 0xbdc; +pub const XK_righttack: c_uint = 0xbfc; +pub const XK_hebrew_doublelowline: c_uint = 0xcdf; +pub const XK_hebrew_aleph: c_uint = 0xce0; +pub const XK_hebrew_bet: c_uint = 0xce1; +pub const XK_hebrew_beth: c_uint = 0xce1; +pub const XK_hebrew_gimel: c_uint = 0xce2; +pub const XK_hebrew_gimmel: c_uint = 0xce2; +pub const XK_hebrew_dalet: c_uint = 0xce3; +pub const XK_hebrew_daleth: c_uint = 0xce3; +pub const XK_hebrew_he: c_uint = 0xce4; +pub const XK_hebrew_waw: c_uint = 0xce5; +pub const XK_hebrew_zain: c_uint = 0xce6; +pub const XK_hebrew_zayin: c_uint = 0xce6; +pub const XK_hebrew_chet: c_uint = 0xce7; +pub const XK_hebrew_het: c_uint = 0xce7; +pub const XK_hebrew_tet: c_uint = 0xce8; +pub const XK_hebrew_teth: c_uint = 0xce8; +pub const XK_hebrew_yod: c_uint = 0xce9; +pub const XK_hebrew_finalkaph: c_uint = 0xcea; +pub const XK_hebrew_kaph: c_uint = 0xceb; +pub const XK_hebrew_lamed: c_uint = 0xcec; +pub const XK_hebrew_finalmem: c_uint = 0xced; +pub const XK_hebrew_mem: c_uint = 0xcee; +pub const XK_hebrew_finalnun: c_uint = 0xcef; +pub const XK_hebrew_nun: c_uint = 0xcf0; +pub const XK_hebrew_samech: c_uint = 0xcf1; +pub const XK_hebrew_samekh: c_uint = 0xcf1; +pub const XK_hebrew_ayin: c_uint = 0xcf2; +pub const XK_hebrew_finalpe: c_uint = 0xcf3; +pub const XK_hebrew_pe: c_uint = 0xcf4; +pub const XK_hebrew_finalzade: c_uint = 0xcf5; +pub const XK_hebrew_finalzadi: c_uint = 0xcf5; +pub const XK_hebrew_zade: c_uint = 0xcf6; +pub const XK_hebrew_zadi: c_uint = 0xcf6; +pub const XK_hebrew_qoph: c_uint = 0xcf7; +pub const XK_hebrew_kuf: c_uint = 0xcf7; +pub const XK_hebrew_resh: c_uint = 0xcf8; +pub const XK_hebrew_shin: c_uint = 0xcf9; +pub const XK_hebrew_taw: c_uint = 0xcfa; +pub const XK_hebrew_taf: c_uint = 0xcfa; +pub const XK_Hebrew_switch: c_uint = 0xFF7E; + +pub const XF86XK_ModeLock: c_uint = 0x1008FF01; +pub const XF86XK_MonBrightnessUp: c_uint = 0x1008FF02; +pub const XF86XK_MonBrightnessDown: c_uint = 0x1008FF03; +pub const XF86XK_KbdLightOnOff: c_uint = 0x1008FF04; +pub const XF86XK_KbdBrightnessUp: c_uint = 0x1008FF05; +pub const XF86XK_KbdBrightnessDown: c_uint = 0x1008FF06; +pub const XF86XK_Standby: c_uint = 0x1008FF10; +pub const XF86XK_AudioLowerVolume: c_uint = 0x1008FF11; +pub const XF86XK_AudioMute: c_uint = 0x1008FF12; +pub const XF86XK_AudioRaiseVolume: c_uint = 0x1008FF13; +pub const XF86XK_AudioPlay: c_uint = 0x1008FF14; +pub const XF86XK_AudioStop: c_uint = 0x1008FF15; +pub const XF86XK_AudioPrev: c_uint = 0x1008FF16; +pub const XF86XK_AudioNext: c_uint = 0x1008FF17; +pub const XF86XK_HomePage: c_uint = 0x1008FF18; +pub const XF86XK_Mail: c_uint = 0x1008FF19; +pub const XF86XK_Start: c_uint = 0x1008FF1A; +pub const XF86XK_Search: c_uint = 0x1008FF1B; +pub const XF86XK_AudioRecord: c_uint = 0x1008FF1C; +pub const XF86XK_Calculator: c_uint = 0x1008FF1D; +pub const XF86XK_Memo: c_uint = 0x1008FF1E; +pub const XF86XK_ToDoList: c_uint = 0x1008FF1F; +pub const XF86XK_Calendar: c_uint = 0x1008FF20; +pub const XF86XK_PowerDown: c_uint = 0x1008FF21; +pub const XF86XK_ContrastAdjust: c_uint = 0x1008FF22; +pub const XF86XK_RockerUp: c_uint = 0x1008FF23; +pub const XF86XK_RockerDown: c_uint = 0x1008FF24; +pub const XF86XK_RockerEnter: c_uint = 0x1008FF25; +pub const XF86XK_Back: c_uint = 0x1008FF26; +pub const XF86XK_Forward: c_uint = 0x1008FF27; +pub const XF86XK_Stop: c_uint = 0x1008FF28; +pub const XF86XK_Refresh: c_uint = 0x1008FF29; +pub const XF86XK_PowerOff: c_uint = 0x1008FF2A; +pub const XF86XK_WakeUp: c_uint = 0x1008FF2B; +pub const XF86XK_Eject: c_uint = 0x1008FF2C; +pub const XF86XK_ScreenSaver: c_uint = 0x1008FF2D; +pub const XF86XK_WWW: c_uint = 0x1008FF2E; +pub const XF86XK_Sleep: c_uint = 0x1008FF2F; +pub const XF86XK_Favorites: c_uint = 0x1008FF30; +pub const XF86XK_AudioPause: c_uint = 0x1008FF31; +pub const XF86XK_AudioMedia: c_uint = 0x1008FF32; +pub const XF86XK_MyComputer: c_uint = 0x1008FF33; +pub const XF86XK_VendorHome: c_uint = 0x1008FF34; +pub const XF86XK_LightBulb: c_uint = 0x1008FF35; +pub const XF86XK_Shop: c_uint = 0x1008FF36; +pub const XF86XK_History: c_uint = 0x1008FF37; +pub const XF86XK_OpenURL: c_uint = 0x1008FF38; +pub const XF86XK_AddFavorite: c_uint = 0x1008FF39; +pub const XF86XK_HotLinks: c_uint = 0x1008FF3A; +pub const XF86XK_BrightnessAdjust: c_uint = 0x1008FF3B; +pub const XF86XK_Finance: c_uint = 0x1008FF3C; +pub const XF86XK_Community: c_uint = 0x1008FF3D; +pub const XF86XK_AudioRewind: c_uint = 0x1008FF3E; +pub const XF86XK_BackForward: c_uint = 0x1008FF3F; +pub const XF86XK_Launch0: c_uint = 0x1008FF40; +pub const XF86XK_Launch1: c_uint = 0x1008FF41; +pub const XF86XK_Launch2: c_uint = 0x1008FF42; +pub const XF86XK_Launch3: c_uint = 0x1008FF43; +pub const XF86XK_Launch4: c_uint = 0x1008FF44; +pub const XF86XK_Launch5: c_uint = 0x1008FF45; +pub const XF86XK_Launch6: c_uint = 0x1008FF46; +pub const XF86XK_Launch7: c_uint = 0x1008FF47; +pub const XF86XK_Launch8: c_uint = 0x1008FF48; +pub const XF86XK_Launch9: c_uint = 0x1008FF49; +pub const XF86XK_LaunchA: c_uint = 0x1008FF4A; +pub const XF86XK_LaunchB: c_uint = 0x1008FF4B; +pub const XF86XK_LaunchC: c_uint = 0x1008FF4C; +pub const XF86XK_LaunchD: c_uint = 0x1008FF4D; +pub const XF86XK_LaunchE: c_uint = 0x1008FF4E; +pub const XF86XK_LaunchF: c_uint = 0x1008FF4F; +pub const XF86XK_ApplicationLeft: c_uint = 0x1008FF50; +pub const XF86XK_ApplicationRight: c_uint = 0x1008FF51; +pub const XF86XK_Book: c_uint = 0x1008FF52; +pub const XF86XK_CD: c_uint = 0x1008FF53; +pub const XF86XK_Calculater: c_uint = 0x1008FF54; +pub const XF86XK_Clear: c_uint = 0x1008FF55; +pub const XF86XK_Close: c_uint = 0x1008FF56; +pub const XF86XK_Copy: c_uint = 0x1008FF57; +pub const XF86XK_Cut: c_uint = 0x1008FF58; +pub const XF86XK_Display: c_uint = 0x1008FF59; +pub const XF86XK_DOS: c_uint = 0x1008FF5A; +pub const XF86XK_Documents: c_uint = 0x1008FF5B; +pub const XF86XK_Excel: c_uint = 0x1008FF5C; +pub const XF86XK_Explorer: c_uint = 0x1008FF5D; +pub const XF86XK_Game: c_uint = 0x1008FF5E; +pub const XF86XK_Go: c_uint = 0x1008FF5F; +pub const XF86XK_iTouch: c_uint = 0x1008FF60; +pub const XF86XK_LogOff: c_uint = 0x1008FF61; +pub const XF86XK_Market: c_uint = 0x1008FF62; +pub const XF86XK_Meeting: c_uint = 0x1008FF63; +pub const XF86XK_MenuKB: c_uint = 0x1008FF65; +pub const XF86XK_MenuPB: c_uint = 0x1008FF66; +pub const XF86XK_MySites: c_uint = 0x1008FF67; +pub const XF86XK_New: c_uint = 0x1008FF68; +pub const XF86XK_News: c_uint = 0x1008FF69; +pub const XF86XK_OfficeHome: c_uint = 0x1008FF6A; +pub const XF86XK_Open: c_uint = 0x1008FF6B; +pub const XF86XK_Option: c_uint = 0x1008FF6C; +pub const XF86XK_Paste: c_uint = 0x1008FF6D; +pub const XF86XK_Phone: c_uint = 0x1008FF6E; +pub const XF86XK_Q: c_uint = 0x1008FF70; +pub const XF86XK_Reply: c_uint = 0x1008FF72; +pub const XF86XK_Reload: c_uint = 0x1008FF73; +pub const XF86XK_RotateWindows: c_uint = 0x1008FF74; +pub const XF86XK_RotationPB: c_uint = 0x1008FF75; +pub const XF86XK_RotationKB: c_uint = 0x1008FF76; +pub const XF86XK_Save: c_uint = 0x1008FF77; +pub const XF86XK_ScrollUp: c_uint = 0x1008FF78; +pub const XF86XK_ScrollDown: c_uint = 0x1008FF79; +pub const XF86XK_ScrollClick: c_uint = 0x1008FF7A; +pub const XF86XK_Send: c_uint = 0x1008FF7B; +pub const XF86XK_Spell: c_uint = 0x1008FF7C; +pub const XF86XK_SplitScreen: c_uint = 0x1008FF7D; +pub const XF86XK_Support: c_uint = 0x1008FF7E; +pub const XF86XK_TaskPane: c_uint = 0x1008FF7F; +pub const XF86XK_Terminal: c_uint = 0x1008FF80; +pub const XF86XK_Tools: c_uint = 0x1008FF81; +pub const XF86XK_Travel: c_uint = 0x1008FF82; +pub const XF86XK_UserPB: c_uint = 0x1008FF84; +pub const XF86XK_User1KB: c_uint = 0x1008FF85; +pub const XF86XK_User2KB: c_uint = 0x1008FF86; +pub const XF86XK_Video: c_uint = 0x1008FF87; +pub const XF86XK_WheelButton: c_uint = 0x1008FF88; +pub const XF86XK_Word: c_uint = 0x1008FF89; +pub const XF86XK_Xfer: c_uint = 0x1008FF8A; +pub const XF86XK_ZoomIn: c_uint = 0x1008FF8B; +pub const XF86XK_ZoomOut: c_uint = 0x1008FF8C; +pub const XF86XK_Away: c_uint = 0x1008FF8D; +pub const XF86XK_Messenger: c_uint = 0x1008FF8E; +pub const XF86XK_WebCam: c_uint = 0x1008FF8F; +pub const XF86XK_MailForward: c_uint = 0x1008FF90; +pub const XF86XK_Pictures: c_uint = 0x1008FF91; +pub const XF86XK_Music: c_uint = 0x1008FF92; +pub const XF86XK_Battery: c_uint = 0x1008FF93; +pub const XF86XK_Bluetooth: c_uint = 0x1008FF94; +pub const XF86XK_WLAN: c_uint = 0x1008FF95; +pub const XF86XK_UWB: c_uint = 0x1008FF96; +pub const XF86XK_AudioForward: c_uint = 0x1008FF97; +pub const XF86XK_AudioRepeat: c_uint = 0x1008FF98; +pub const XF86XK_AudioRandomPlay: c_uint = 0x1008FF99; +pub const XF86XK_Subtitle: c_uint = 0x1008FF9A; +pub const XF86XK_AudioCycleTrack: c_uint = 0x1008FF9B; +pub const XF86XK_CycleAngle: c_uint = 0x1008FF9C; +pub const XF86XK_FrameBack: c_uint = 0x1008FF9D; +pub const XF86XK_FrameForward: c_uint = 0x1008FF9E; +pub const XF86XK_Time: c_uint = 0x1008FF9F; +pub const XF86XK_Select: c_uint = 0x1008FFA0; +pub const XF86XK_View: c_uint = 0x1008FFA1; +pub const XF86XK_TopMenu: c_uint = 0x1008FFA2; +pub const XF86XK_Red: c_uint = 0x1008FFA3; +pub const XF86XK_Green: c_uint = 0x1008FFA4; +pub const XF86XK_Yellow: c_uint = 0x1008FFA5; +pub const XF86XK_Blue: c_uint = 0x1008FFA6; +pub const XF86XK_Suspend: c_uint = 0x1008FFA7; +pub const XF86XK_Hibernate: c_uint = 0x1008FFA8; +pub const XF86XK_TouchpadToggle: c_uint = 0x1008FFA9; +pub const XF86XK_TouchpadOn: c_uint = 0x1008FFB0; +pub const XF86XK_TouchpadOff: c_uint = 0x1008FFB1; +pub const XF86XK_AudioMicMute: c_uint = 0x1008FFB2; +pub const XF86XK_Switch_VT_1: c_uint = 0x1008FE01; +pub const XF86XK_Switch_VT_2: c_uint = 0x1008FE02; +pub const XF86XK_Switch_VT_3: c_uint = 0x1008FE03; +pub const XF86XK_Switch_VT_4: c_uint = 0x1008FE04; +pub const XF86XK_Switch_VT_5: c_uint = 0x1008FE05; +pub const XF86XK_Switch_VT_6: c_uint = 0x1008FE06; +pub const XF86XK_Switch_VT_7: c_uint = 0x1008FE07; +pub const XF86XK_Switch_VT_8: c_uint = 0x1008FE08; +pub const XF86XK_Switch_VT_9: c_uint = 0x1008FE09; +pub const XF86XK_Switch_VT_10: c_uint = 0x1008FE0A; +pub const XF86XK_Switch_VT_11: c_uint = 0x1008FE0B; +pub const XF86XK_Switch_VT_12: c_uint = 0x1008FE0C; +pub const XF86XK_Ungrab: c_uint = 0x1008FE20; +pub const XF86XK_ClearGrab: c_uint = 0x1008FE21; +pub const XF86XK_Next_VMode: c_uint = 0x1008FE22; +pub const XF86XK_Prev_VMode: c_uint = 0x1008FE23; +pub const XF86XK_LogWindowTree: c_uint = 0x1008FE24; +pub const XF86XK_LogGrabInfo: c_uint = 0x1008FE25; + +pub const XK_ISO_Lock: c_uint = 0xfe01; +pub const XK_ISO_Level2_Latch: c_uint = 0xfe02; +pub const XK_ISO_Level3_Shift: c_uint = 0xfe03; +pub const XK_ISO_Level3_Latch: c_uint = 0xfe04; +pub const XK_ISO_Level3_Lock: c_uint = 0xfe05; +pub const XK_ISO_Level5_Shift: c_uint = 0xfe11; +pub const XK_ISO_Level5_Latch: c_uint = 0xfe12; +pub const XK_ISO_Level5_Lock: c_uint = 0xfe13; +pub const XK_ISO_Group_Shift: c_uint = 0xff7e; +pub const XK_ISO_Group_Latch: c_uint = 0xfe06; +pub const XK_ISO_Group_Lock: c_uint = 0xfe07; +pub const XK_ISO_Next_Group: c_uint = 0xfe08; +pub const XK_ISO_Next_Group_Lock: c_uint = 0xfe09; +pub const XK_ISO_Prev_Group: c_uint = 0xfe0a; +pub const XK_ISO_Prev_Group_Lock: c_uint = 0xfe0b; +pub const XK_ISO_First_Group: c_uint = 0xfe0c; +pub const XK_ISO_First_Group_Lock: c_uint = 0xfe0d; +pub const XK_ISO_Last_Group: c_uint = 0xfe0e; +pub const XK_ISO_Last_Group_Lock: c_uint = 0xfe0f; + +pub const XK_ISO_Left_Tab: c_uint = 0xfe20; +pub const XK_ISO_Move_Line_Up: c_uint = 0xfe21; +pub const XK_ISO_Move_Line_Down: c_uint = 0xfe22; +pub const XK_ISO_Partial_Line_Up: c_uint = 0xfe23; +pub const XK_ISO_Partial_Line_Down: c_uint = 0xfe24; +pub const XK_ISO_Partial_Space_Left: c_uint = 0xfe25; +pub const XK_ISO_Partial_Space_Right: c_uint = 0xfe26; +pub const XK_ISO_Set_Margin_Left: c_uint = 0xfe27; +pub const XK_ISO_Set_Margin_Right: c_uint = 0xfe28; +pub const XK_ISO_Release_Margin_Left: c_uint = 0xfe29; +pub const XK_ISO_Release_Margin_Right: c_uint = 0xfe2a; +pub const XK_ISO_Release_Both_Margins: c_uint = 0xfe2b; +pub const XK_ISO_Fast_Cursor_Left: c_uint = 0xfe2c; +pub const XK_ISO_Fast_Cursor_Right: c_uint = 0xfe2d; +pub const XK_ISO_Fast_Cursor_Up: c_uint = 0xfe2e; +pub const XK_ISO_Fast_Cursor_Down: c_uint = 0xfe2f; +pub const XK_ISO_Continuous_Underline: c_uint = 0xfe30; +pub const XK_ISO_Discontinuous_Underline: c_uint = 0xfe31; +pub const XK_ISO_Emphasize: c_uint = 0xfe32; +pub const XK_ISO_Center_Object: c_uint = 0xfe33; +pub const XK_ISO_Enter: c_uint = 0xfe34; + +pub const XK_dead_grave: c_uint = 0xfe50; +pub const XK_dead_acute: c_uint = 0xfe51; +pub const XK_dead_circumflex: c_uint = 0xfe52; +pub const XK_dead_tilde: c_uint = 0xfe53; +pub const XK_dead_perispomeni: c_uint = 0xfe53; +pub const XK_dead_macron: c_uint = 0xfe54; +pub const XK_dead_breve: c_uint = 0xfe55; +pub const XK_dead_abovedot: c_uint = 0xfe56; +pub const XK_dead_diaeresis: c_uint = 0xfe57; +pub const XK_dead_abovering: c_uint = 0xfe58; +pub const XK_dead_doubleacute: c_uint = 0xfe59; +pub const XK_dead_caron: c_uint = 0xfe5a; +pub const XK_dead_cedilla: c_uint = 0xfe5b; +pub const XK_dead_ogonek: c_uint = 0xfe5c; +pub const XK_dead_iota: c_uint = 0xfe5d; +pub const XK_dead_voiced_sound: c_uint = 0xfe5e; +pub const XK_dead_semivoiced_sound: c_uint = 0xfe5f; +pub const XK_dead_belowdot: c_uint = 0xfe60; +pub const XK_dead_hook: c_uint = 0xfe61; +pub const XK_dead_horn: c_uint = 0xfe62; +pub const XK_dead_stroke: c_uint = 0xfe63; +pub const XK_dead_abovecomma: c_uint = 0xfe64; +pub const XK_dead_psili: c_uint = 0xfe64; +pub const XK_dead_abovereversedcomma: c_uint = 0xfe65; +pub const XK_dead_dasia: c_uint = 0xfe65; +pub const XK_dead_doublegrave: c_uint = 0xfe66; +pub const XK_dead_belowring: c_uint = 0xfe67; +pub const XK_dead_belowmacron: c_uint = 0xfe68; +pub const XK_dead_belowcircumflex: c_uint = 0xfe69; +pub const XK_dead_belowtilde: c_uint = 0xfe6a; +pub const XK_dead_belowbreve: c_uint = 0xfe6b; +pub const XK_dead_belowdiaeresis: c_uint = 0xfe6c; +pub const XK_dead_invertedbreve: c_uint = 0xfe6d; +pub const XK_dead_belowcomma: c_uint = 0xfe6e; +pub const XK_dead_currency: c_uint = 0xfe6f; + +pub const XK_dead_lowline: c_uint = 0xfe90; +pub const XK_dead_aboveverticalline: c_uint = 0xfe91; +pub const XK_dead_belowverticalline: c_uint = 0xfe92; +pub const XK_dead_longsolidusoverlay: c_uint = 0xfe93; + +pub const XK_dead_a: c_uint = 0xfe80; +pub const XK_dead_A: c_uint = 0xfe81; +pub const XK_dead_e: c_uint = 0xfe82; +pub const XK_dead_E: c_uint = 0xfe83; +pub const XK_dead_i: c_uint = 0xfe84; +pub const XK_dead_I: c_uint = 0xfe85; +pub const XK_dead_o: c_uint = 0xfe86; +pub const XK_dead_O: c_uint = 0xfe87; +pub const XK_dead_u: c_uint = 0xfe88; +pub const XK_dead_U: c_uint = 0xfe89; +pub const XK_dead_small_schwa: c_uint = 0xfe8a; +pub const XK_dead_capital_schwa: c_uint = 0xfe8b; + +pub const XK_dead_greek: c_uint = 0xfe8c; + +pub const XK_First_Virtual_Screen: c_uint = 0xfed0; +pub const XK_Prev_Virtual_Screen: c_uint = 0xfed1; +pub const XK_Next_Virtual_Screen: c_uint = 0xfed2; +pub const XK_Last_Virtual_Screen: c_uint = 0xfed4; +pub const XK_Terminate_Server: c_uint = 0xfed5; + +pub const XK_AccessX_Enable: c_uint = 0xfe70; +pub const XK_AccessX_Feedback_Enable: c_uint = 0xfe71; +pub const XK_RepeatKeys_Enable: c_uint = 0xfe72; +pub const XK_SlowKeys_Enable: c_uint = 0xfe73; +pub const XK_BounceKeys_Enable: c_uint = 0xfe74; +pub const XK_StickyKeys_Enable: c_uint = 0xfe75; +pub const XK_MouseKeys_Enable: c_uint = 0xfe76; +pub const XK_MouseKeys_Accel_Enable: c_uint = 0xfe77; +pub const XK_Overlay1_Enable: c_uint = 0xfe78; +pub const XK_Overlay2_Enable: c_uint = 0xfe79; +pub const XK_AudibleBell_Enable: c_uint = 0xfe7a; + +pub const XK_Pointer_Left: c_uint = 0xfee0; +pub const XK_Pointer_Right: c_uint = 0xfee1; +pub const XK_Pointer_Up: c_uint = 0xfee2; +pub const XK_Pointer_Down: c_uint = 0xfee3; +pub const XK_Pointer_UpLeft: c_uint = 0xfee4; +pub const XK_Pointer_UpRight: c_uint = 0xfee5; +pub const XK_Pointer_DownLeft: c_uint = 0xfee6; +pub const XK_Pointer_DownRight: c_uint = 0xfee7; +pub const XK_Pointer_Button_Dflt: c_uint = 0xfee8; +pub const XK_Pointer_Button1: c_uint = 0xfee9; +pub const XK_Pointer_Button2: c_uint = 0xfeea; +pub const XK_Pointer_Button3: c_uint = 0xfeeb; +pub const XK_Pointer_Button4: c_uint = 0xfeec; +pub const XK_Pointer_Button5: c_uint = 0xfeed; +pub const XK_Pointer_DblClick_Dflt: c_uint = 0xfeee; +pub const XK_Pointer_DblClick1: c_uint = 0xfeef; +pub const XK_Pointer_DblClick2: c_uint = 0xfef0; +pub const XK_Pointer_DblClick3: c_uint = 0xfef1; +pub const XK_Pointer_DblClick4: c_uint = 0xfef2; +pub const XK_Pointer_DblClick5: c_uint = 0xfef3; +pub const XK_Pointer_Drag_Dflt: c_uint = 0xfef4; +pub const XK_Pointer_Drag1: c_uint = 0xfef5; +pub const XK_Pointer_Drag2: c_uint = 0xfef6; +pub const XK_Pointer_Drag3: c_uint = 0xfef7; +pub const XK_Pointer_Drag4: c_uint = 0xfef8; +pub const XK_Pointer_Drag5: c_uint = 0xfefd; + +pub const XK_Pointer_EnableKeys: c_uint = 0xfef9; +pub const XK_Pointer_Accelerate: c_uint = 0xfefa; +pub const XK_Pointer_DfltBtnNext: c_uint = 0xfefb; +pub const XK_Pointer_DfltBtnPrev: c_uint = 0xfefc; + +pub const XK_ch: c_uint = 0xfea0; +pub const XK_Ch: c_uint = 0xfea1; +pub const XK_CH: c_uint = 0xfea2; +pub const XK_c_h: c_uint = 0xfea3; +pub const XK_C_h: c_uint = 0xfea4; +pub const XK_C_H: c_uint = 0xfea5; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/lib.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/lib.rs new file mode 100644 index 0000000..65a89e6 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/lib.rs @@ -0,0 +1,46 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] + +#[macro_use] +extern crate lazy_static; + +extern crate libc; +extern crate maybe_uninit; + +#[macro_use] +mod link; +mod internal; + +pub mod error; + +#[macro_use] +pub mod xlib; + +pub mod dpms; +pub mod glx; +pub mod keysym; +pub mod xcursor; +pub mod xf86vmode; +pub mod xfixes; +pub mod xft; +pub mod xinerama; +pub mod xinput; +pub mod xinput2; +pub mod xmd; +pub mod xmu; +pub mod xrecord; +pub mod xrender; +pub mod xss; +pub mod xt; +pub mod xtest; +pub mod xlib_xcb; + +pub mod xrandr { + include!("xrandr.rs"); + include!("old_xrandr.rs"); +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/link.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/link.rs new file mode 100644 index 0000000..6a8613c --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/link.rs @@ -0,0 +1,172 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::ffi::{ CStr, CString }; +use std::path::Path; +use std::os::raw::{ c_char, c_void }; + +use libc; + +use error::{ OpenError, OpenErrorKind }; + +include!(concat!(env!("OUT_DIR"), "/config.rs")); + +// +// x11_link! +// + +macro_rules! x11_link { + { $struct_name:ident, $pkg_name:ident, [$($lib_name:expr),*], $nsyms:expr, + $(pub fn $fn_name:ident ($($param_name:ident : $param_type:ty),*) -> $ret_type:ty,)* + variadic: + $(pub fn $vfn_name:ident ($($vparam_name: ident : $vparam_type:ty),+) -> $vret_type:ty,)* + globals: + $(pub static $var_name:ident : $var_type:ty,)* + } => { + pub struct $struct_name { + #[allow(dead_code)] + lib: ::link::DynamicLibrary, + $(pub $fn_name: unsafe extern "C" fn ($($param_type),*) -> $ret_type,)* + $(pub $vfn_name: unsafe extern "C" fn ($($vparam_type),+, ...) -> $vret_type,)* + $(pub $var_name: *mut $var_type,)* + } + + unsafe impl Send for $struct_name {} + unsafe impl Sync for $struct_name {} + + impl $struct_name { + unsafe fn init (this: *mut Self) -> Result<(), $crate::error::OpenError> { + lazy_static! { + static ref SYMS: [(&'static str, usize); $nsyms] = unsafe {[ + $((stringify!($fn_name), &((*(0 as *const $struct_name)).$fn_name) as *const _ as usize),)* + $((stringify!($vfn_name), &((*(0 as *const $struct_name)).$vfn_name) as *const _ as usize),)* + $((stringify!($var_name), &((*(0 as *const $struct_name)).$var_name) as *const _ as usize),)* + ]}; + } + let offset = this as usize; + for &(name, sym_offset) in SYMS.iter() { + *((offset + sym_offset) as *mut *mut _) = try!((*this).lib.symbol(name)); + } + Ok(()) + } + + pub fn open () -> Result<$struct_name, $crate::error::OpenError> { + unsafe { + let libdir = $crate::link::config::libdir::$pkg_name; + let lib = try!($crate::link::DynamicLibrary::open_multi(libdir, &[$($lib_name),*])); + let mut this = ::maybe_uninit::MaybeUninit::<$struct_name>::uninit(); + let this_ptr = this.as_mut_ptr(); + ::std::ptr::write(&mut (*this_ptr).lib, lib); + try!(Self::init(this_ptr)); + Ok(this.assume_init()) + } + } + } + }; +} + + +// +// DynamicLibrary +// + + +pub struct DynamicLibrary { + handle: *mut c_void, +} + +impl DynamicLibrary { + pub fn open (name: &str) -> Result<DynamicLibrary, OpenError> { + unsafe { + let cname = match CString::new(name) { + Ok(cname) => cname, + Err(_) => { + return Err(OpenError::new(OpenErrorKind::Library, + String::from("library name contains NUL byte(s)"))); + }, + }; + + let handle = libc::dlopen(cname.as_ptr(), libc::RTLD_LAZY); + + if handle.is_null() { + let msg = libc::dlerror(); + + if msg.is_null() { + return Err(OpenError::new(OpenErrorKind::Library, String::new())); + } + + let cmsg = CStr::from_ptr(msg as *const c_char); + let detail = cmsg.to_string_lossy().into_owned(); + return Err(OpenError::new(OpenErrorKind::Library, detail)); + } + + Ok(DynamicLibrary { handle: handle as *mut c_void }) + } + } + + pub fn open_multi (libdir: Option<&'static str>, names: &[&str]) -> Result<DynamicLibrary, OpenError> { + assert!(!names.is_empty()); + + let paths = libdir.map_or(Vec::new(), |dir| { + let path = Path::new(dir); + names.iter().map(|name| path.join(name).to_str().unwrap().to_string()).collect::<Vec<_>>() + }); + + let mut msgs = Vec::new(); + + for name in names.iter().map(|x| *x).chain(paths.iter().map(|x| &**x)) { + match DynamicLibrary::open(name) { + Ok(lib) => { return Ok(lib); }, + Err(err) => { msgs.push(format!("{}", err)); }, + } + } + + let mut detail = String::new(); + + for i in 0..msgs.len() { + if i != 0 { + detail.push_str("; "); + } + detail.push_str(msgs[i].as_ref()); + } + + Err(OpenError::new(OpenErrorKind::Library, detail)) + } + + pub fn symbol (&self, name: &str) -> Result<*mut c_void, OpenError> { + unsafe { + let cname = match CString::new(name) { + Ok(cname) => cname, + Err(_) => { + return Err(OpenError::new(OpenErrorKind::Symbol, + String::from("symbol name contains NUL byte(s)"))); + }, + }; + + let sym = libc::dlsym(self.handle as *mut _, cname.as_ptr()); + + if sym.is_null() { + let msg = libc::dlerror(); + + if msg.is_null() { + return Err(OpenError::new(OpenErrorKind::Symbol, String::from(name))); + } + + let cmsg = CStr::from_ptr(msg as *const c_char); + let detail = format!("{} - {}", name, cmsg.to_string_lossy().into_owned());; + return Err(OpenError::new(OpenErrorKind::Symbol, detail)); + } + + Ok(sym as *mut c_void) + } + } +} + +impl Drop for DynamicLibrary { + fn drop (&mut self) { + unsafe { + libc::dlclose(self.handle as *mut _); + } + } +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/old_xrandr.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/old_xrandr.rs new file mode 100644 index 0000000..07f19dc --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/old_xrandr.rs @@ -0,0 +1,73 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +x11_link! { Xrandr_2_2_0, xrandr, ["libXrandr.so.2.2.0", "libXrandr.so.2", "libXrandr.so"], 65, + pub fn XRRAddOutputMode (dpy: *mut Display, output: RROutput, mode: RRMode) -> (), + pub fn XRRAllocGamma (size: c_int) -> *mut XRRCrtcGamma, + pub fn XRRAllocModeInfo (name: *const c_char, nameLength: c_int) -> *mut XRRModeInfo, + pub fn XRRChangeOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, type_: Atom, format: c_int, mode: c_int, data: *const c_uchar, nelements: c_int) -> (), + pub fn XRRChangeProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, type_: Atom, format: c_int, mode: c_int, data: *const c_uchar, nelements: c_int) -> (), + pub fn XRRConfigCurrentConfiguration (config: *mut XRRScreenConfiguration, rotation: *mut Rotation) -> SizeID, + pub fn XRRConfigCurrentRate (config: *mut XRRScreenConfiguration) -> c_short, + pub fn XRRConfigRates (config: *mut XRRScreenConfiguration, sizeID: c_int, nrates: *mut c_int) -> *mut c_short, + pub fn XRRConfigRotations (config: *mut XRRScreenConfiguration, current_rotation: *mut Rotation) -> Rotation, + pub fn XRRConfigSizes (config: *mut XRRScreenConfiguration, nsizes: *mut c_int) -> *mut XRRScreenSize, + pub fn XRRConfigTimes (config: *mut XRRScreenConfiguration, config_timestamp: *mut Time) -> Time, + pub fn XRRConfigureOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, pending: Bool, range: Bool, num_values: c_int, values: *mut c_long) -> (), + pub fn XRRConfigureProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, pending: Bool, range: Bool, num_values: c_int, values: *mut c_long) -> (), + pub fn XRRCreateMode (dpy: *mut Display, window: Window, modeInfo: *mut XRRModeInfo) -> RRMode, + pub fn XRRDeleteOutputMode (dpy: *mut Display, output: RROutput, mode: RRMode) -> (), + pub fn XRRDeleteOutputProperty (dpy: *mut Display, output: RROutput, property: Atom) -> (), + pub fn XRRDeleteProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom) -> (), + pub fn XRRDestroyMode (dpy: *mut Display, mode: RRMode) -> (), + pub fn XRRFreeCrtcInfo (crtcInfo: *mut XRRCrtcInfo) -> (), + pub fn XRRFreeGamma (gamma: *mut XRRCrtcGamma) -> (), + pub fn XRRFreeModeInfo (modeInfo: *mut XRRModeInfo) -> (), + pub fn XRRFreeOutputInfo (outputInfo: *mut XRROutputInfo) -> (), + pub fn XRRFreePanning (panning: *mut XRRPanning) -> (), + pub fn XRRFreeProviderInfo (provider: *mut XRRProviderInfo) -> (), + pub fn XRRFreeProviderResources (resources: *mut XRRProviderResources) -> (), + pub fn XRRFreeScreenConfigInfo (config: *mut XRRScreenConfiguration) -> (), + pub fn XRRFreeScreenResources (resources: *mut XRRScreenResources) -> (), + pub fn XRRGetCrtcGamma (dpy: *mut Display, crtc: RRCrtc) -> *mut XRRCrtcGamma, + pub fn XRRGetCrtcGammaSize (dpy: *mut Display, crtc: RRCrtc) -> c_int, + pub fn XRRGetCrtcInfo (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc) -> *mut XRRCrtcInfo, + pub fn XRRGetCrtcTransform (dpy: *mut Display, crtc: RRCrtc, attributes: *mut *mut XRRCrtcTransformAttributes) -> Status, + pub fn XRRGetOutputInfo (dpy: *mut Display, resources: *mut XRRScreenResources, output: RROutput) -> *mut XRROutputInfo, + pub fn XRRGetOutputPrimary (dpy: *mut Display, window: Window) -> RROutput, + pub fn XRRGetOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, offset: c_long, length: c_long, _delete: Bool, pending: Bool, req_type: Atom, actual_type: *mut Atom, actual_format: *mut c_int, nitems: *mut c_ulong, bytes_after: *mut c_ulong, prop: *mut *mut c_uchar) -> c_int, + pub fn XRRGetPanning (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc) -> *mut XRRPanning, + pub fn XRRGetProviderInfo (dpy: *mut Display, resources: *mut XRRScreenResources, provider: RRProvider) -> *mut XRRProviderInfo, + pub fn XRRGetProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, offset: c_long, length: c_long, _delete: Bool, pending: Bool, req_type: Atom, actual_type: *mut Atom, actual_format: *mut c_int, nitems: *mut c_ulong, bytes_after: *mut c_ulong, prop: *mut *mut c_uchar) -> c_int, + pub fn XRRGetProviderResources (dpy: *mut Display, window: Window) -> *mut XRRProviderResources, + pub fn XRRGetScreenInfo (dpy: *mut Display, window: Window) -> *mut XRRScreenConfiguration, + pub fn XRRGetScreenResources (dpy: *mut Display, window: Window) -> *mut XRRScreenResources, + pub fn XRRGetScreenResourcesCurrent (dpy: *mut Display, window: Window) -> *mut XRRScreenResources, + pub fn XRRGetScreenSizeRange (dpy: *mut Display, window: Window, minWidth: *mut c_int, minHeight: *mut c_int, maxWidth: *mut c_int, maxHeight: *mut c_int) -> Status, + pub fn XRRListOutputProperties (dpy: *mut Display, output: RROutput, nprop: *mut c_int) -> *mut Atom, + pub fn XRRListProviderProperties (dpy: *mut Display, provider: RRProvider, nprop: *mut c_int) -> *mut Atom, + pub fn XRRQueryExtension (dpy: *mut Display, event_base_return: *mut c_int, error_base_return: *mut c_int) -> Bool, + pub fn XRRQueryOutputProperty (dpy: *mut Display, output: RROutput, property: Atom) -> *mut XRRPropertyInfo, + pub fn XRRQueryProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom) -> *mut XRRPropertyInfo, + pub fn XRRQueryVersion (dpy: *mut Display, major_version_return: *mut c_int, minor_version_return: *mut c_int) -> Status, + pub fn XRRRates (dpy: *mut Display, screen: c_int, sizeID: c_int, nrates: *mut c_int) -> *mut c_short, + pub fn XRRRootToScreen (dpy: *mut Display, root: Window) -> c_int, + pub fn XRRRotations (dpy: *mut Display, screen: c_int, current_rotation: *mut Rotation) -> Rotation, + pub fn XRRSelectInput (dpy: *mut Display, window: Window, mask: c_int) -> (), + pub fn XRRSetCrtcConfig (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc, timestamp: Time, x: c_int, y: c_int, mode: RRMode, rotation: Rotation, outputs: *mut RROutput, noutputs: c_int) -> Status, + pub fn XRRSetCrtcGamma (dpy: *mut Display, crtc: RRCrtc, gamma: *mut XRRCrtcGamma) -> (), + pub fn XRRSetCrtcTransform (dpy: *mut Display, crtc: RRCrtc, transform: *mut XTransform, filter: *const c_char, params: *mut XFixed, nparams: c_int) -> (), + pub fn XRRSetOutputPrimary (dpy: *mut Display, window: Window, output: RROutput) -> (), + pub fn XRRSetPanning (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc, panning: *mut XRRPanning) -> Status, + pub fn XRRSetProviderOffloadSink (dpy: *mut Display, provider: XID, sink_provider: XID) -> c_int, + pub fn XRRSetProviderOutputSource (dpy: *mut Display, provider: XID, source_provider: XID) -> c_int, + pub fn XRRSetScreenConfig (dpy: *mut Display, config: *mut XRRScreenConfiguration, draw: Drawable, size_index: c_int, rotation: Rotation, timestamp: Time) -> Status, + pub fn XRRSetScreenConfigAndRate (dpy: *mut Display, config: *mut XRRScreenConfiguration, draw: Drawable, size_index: c_int, rotation: Rotation, rate: c_short, timestamp: Time) -> Status, + pub fn XRRSetScreenSize (dpy: *mut Display, window: Window, width: c_int, height: c_int, mmWidth: c_int, mmHeight: c_int) -> (), + pub fn XRRSizes (dpy: *mut Display, screen: c_int, nsizes: *mut c_int) -> *mut XRRScreenSize, + pub fn XRRTimes (dpy: *mut Display, screen: c_int, config_timestamp: *mut Time) -> Time, + pub fn XRRUpdateConfiguration (event: *mut XEvent) -> c_int, +variadic: +globals: +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xcursor.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xcursor.rs new file mode 100644 index 0000000..0c5f8fa --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xcursor.rs @@ -0,0 +1,211 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ + c_char, + c_int, + c_long, + c_uchar, + c_uint, + c_ulong, + c_void, +}; +use libc::FILE; + +use ::xlib::{ + Cursor, + Display, + XColor, + XImage, +}; + + +// +// functions +// + + +x11_link! { Xcursor, xcursor, ["libXcursor.so.1", "libXcursor.so"], 59, + pub fn XcursorAnimateCreate (_1: *mut XcursorCursors) -> *mut XcursorAnimate, + pub fn XcursorAnimateDestroy (_1: *mut XcursorAnimate) -> (), + pub fn XcursorAnimateNext (_1: *mut XcursorAnimate) -> c_ulong, + pub fn XcursorCommentCreate (_2: c_uint, _1: c_int) -> *mut XcursorComment, + pub fn XcursorCommentDestroy (_1: *mut XcursorComment) -> (), + pub fn XcursorCommentsCreate (_1: c_int) -> *mut XcursorComments, + pub fn XcursorCommentsDestroy (_1: *mut XcursorComments) -> (), + pub fn XcursorCursorsCreate (_2: *mut Display, _1: c_int) -> *mut XcursorCursors, + pub fn XcursorCursorsDestroy (_1: *mut XcursorCursors) -> (), + pub fn XcursorFileLoad (_3: *mut FILE, _2: *mut *mut XcursorComments, _1: *mut *mut XcursorImages) -> c_int, + pub fn XcursorFileLoadAllImages (_1: *mut FILE) -> *mut XcursorImages, + pub fn XcursorFileLoadImage (_2: *mut FILE, _1: c_int) -> *mut XcursorImage, + pub fn XcursorFileLoadImages (_2: *mut FILE, _1: c_int) -> *mut XcursorImages, + pub fn XcursorFilenameLoad (_3: *const c_char, _2: *mut *mut XcursorComments, _1: *mut *mut XcursorImages) -> c_int, + pub fn XcursorFilenameLoadAllImages (_1: *const c_char) -> *mut XcursorImages, + pub fn XcursorFilenameLoadCursor (_2: *mut Display, _1: *const c_char) -> c_ulong, + pub fn XcursorFilenameLoadCursors (_2: *mut Display, _1: *const c_char) -> *mut XcursorCursors, + pub fn XcursorFilenameLoadImage (_2: *const c_char, _1: c_int) -> *mut XcursorImage, + pub fn XcursorFilenameLoadImages (_2: *const c_char, _1: c_int) -> *mut XcursorImages, + pub fn XcursorFilenameSave (_3: *const c_char, _2: *const XcursorComments, _1: *const XcursorImages) -> c_int, + pub fn XcursorFilenameSaveImages (_2: *const c_char, _1: *const XcursorImages) -> c_int, + pub fn XcursorFileSave (_3: *mut FILE, _2: *const XcursorComments, _1: *const XcursorImages) -> c_int, + pub fn XcursorFileSaveImages (_2: *mut FILE, _1: *const XcursorImages) -> c_int, + pub fn XcursorGetDefaultSize (_1: *mut Display) -> c_int, + pub fn XcursorGetTheme (_1: *mut Display) -> *mut c_char, + pub fn XcursorGetThemeCore (_1: *mut Display) -> c_int, + pub fn XcursorImageCreate (_2: c_int, _1: c_int) -> *mut XcursorImage, + pub fn XcursorImageDestroy (_1: *mut XcursorImage) -> (), + pub fn XcursorImageHash (_2: *mut XImage, _1: *mut c_uchar) -> (), + pub fn XcursorImageLoadCursor (_2: *mut Display, _1: *const XcursorImage) -> c_ulong, + pub fn XcursorImagesCreate (_1: c_int) -> *mut XcursorImages, + pub fn XcursorImagesDestroy (_1: *mut XcursorImages) -> (), + pub fn XcursorImagesLoadCursor (_2: *mut Display, _1: *const XcursorImages) -> c_ulong, + pub fn XcursorImagesLoadCursors (_2: *mut Display, _1: *const XcursorImages) -> *mut XcursorCursors, + pub fn XcursorImagesSetName (_2: *mut XcursorImages, _1: *const c_char) -> (), + pub fn XcursorLibraryLoadCursor (_2: *mut Display, _1: *const c_char) -> c_ulong, + pub fn XcursorLibraryLoadCursors (_2: *mut Display, _1: *const c_char) -> *mut XcursorCursors, + pub fn XcursorLibraryLoadImage (_3: *const c_char, _2: *const c_char, _1: c_int) -> *mut XcursorImage, + pub fn XcursorLibraryLoadImages (_3: *const c_char, _2: *const c_char, _1: c_int) -> *mut XcursorImages, + pub fn XcursorLibraryPath () -> *const c_char, + pub fn XcursorLibraryShape (_1: *const c_char) -> c_int, + pub fn XcursorNoticeCreateBitmap (_4: *mut Display, _3: c_ulong, _2: c_uint, _1: c_uint) -> (), + pub fn XcursorNoticePutBitmap (_3: *mut Display, _2: c_ulong, _1: *mut XImage) -> (), + pub fn XcursorSetDefaultSize (_2: *mut Display, _1: c_int) -> c_int, + pub fn XcursorSetTheme (_2: *mut Display, _1: *const c_char) -> c_int, + pub fn XcursorSetThemeCore (_2: *mut Display, _1: c_int) -> c_int, + pub fn XcursorShapeLoadCursor (_2: *mut Display, _1: c_uint) -> c_ulong, + pub fn XcursorShapeLoadCursors (_2: *mut Display, _1: c_uint) -> *mut XcursorCursors, + pub fn XcursorShapeLoadImage (_3: c_uint, _2: *const c_char, _1: c_int) -> *mut XcursorImage, + pub fn XcursorShapeLoadImages (_3: c_uint, _2: *const c_char, _1: c_int) -> *mut XcursorImages, + pub fn XcursorSupportsAnim (_1: *mut Display) -> c_int, + pub fn XcursorSupportsARGB (_1: *mut Display) -> c_int, + pub fn XcursorTryShapeBitmapCursor (_7: *mut Display, _6: c_ulong, _5: c_ulong, _4: *mut XColor, _3: *mut XColor, _2: c_uint, _1: c_uint) -> c_ulong, + pub fn XcursorTryShapeCursor (_7: *mut Display, _6: c_ulong, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *const XColor, _1: *const XColor) -> c_ulong, + pub fn XcursorXcFileLoad (_3: *mut XcursorFile, _2: *mut *mut XcursorComments, _1: *mut *mut XcursorImages) -> c_int, + pub fn XcursorXcFileLoadAllImages (_1: *mut XcursorFile) -> *mut XcursorImages, + pub fn XcursorXcFileLoadImage (_2: *mut XcursorFile, _1: c_int) -> *mut XcursorImage, + pub fn XcursorXcFileLoadImages (_2: *mut XcursorFile, _1: c_int) -> *mut XcursorImages, + pub fn XcursorXcFileSave (_3: *mut XcursorFile, _2: *const XcursorComments, _1: *const XcursorImages) -> c_int, +variadic: +globals: +} + + +// +// types +// + + +pub type XcursorBool = c_int; +pub type XcursorDim = XcursorUInt; +pub type XcursorPixel = XcursorUInt; +pub type XcursorUInt = c_uint; + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct _XcursorAnimate { + pub cursors: *mut XcursorCursors, + pub sequence: c_int, +} +pub type XcursorAnimate = _XcursorAnimate; + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct _XcursorChunkHeader { + pub header: XcursorUInt, + pub type_: XcursorUInt, + pub subtype: XcursorUInt, + pub version: XcursorUInt, +} +pub type XcursorChunkHeader = _XcursorChunkHeader; + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct _XcursorComment { + pub version: XcursorUInt, + pub comment_type: XcursorUInt, + pub comment: *mut c_char, +} +pub type XcursorComment = _XcursorComment; + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct _XcursorComments { + pub ncomment: c_int, + pub comments: *mut *mut XcursorComment, +} +pub type XcursorComments = _XcursorComments; + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct _XcursorCursors { + pub dpy: *mut Display, + pub ref_: c_int, + pub ncursor: c_int, + pub cursors: *mut Cursor, +} +pub type XcursorCursors = _XcursorCursors; + +#[derive(Debug, Copy)] +#[repr(C)] +pub struct _XcursorFile { + pub closure: *mut c_void, + pub read: Option<unsafe extern "C" fn (*mut XcursorFile, *mut c_uchar, c_int) -> c_int>, + pub write: Option<unsafe extern "C" fn (*mut XcursorFile, *mut c_uchar, c_int) -> c_int>, + pub seek: Option<unsafe extern "C" fn (*mut XcursorFile, c_long, c_int) -> c_int>, +} +pub type XcursorFile = _XcursorFile; + +impl Clone for _XcursorFile { + fn clone (&self) -> _XcursorFile { + _XcursorFile { + closure: self.closure, + read: self.read, + write: self.write, + seek: self.seek, + } + } +} + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct _XcursorFileHeader { + pub magic: XcursorUInt, + pub header: XcursorUInt, + pub version: XcursorUInt, + pub ntoc: XcursorUInt, + pub tocs: *mut XcursorFileToc, +} +pub type XcursorFileHeader = _XcursorFileHeader; + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct _XcursorFileToc { + pub type_: XcursorUInt, + pub subtype: XcursorUInt, + pub position: XcursorUInt, +} +pub type XcursorFileToc = _XcursorFileToc; + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct _XcursorImage { + pub version: XcursorUInt, + pub size: XcursorDim, + pub width: XcursorDim, + pub height: XcursorDim, + pub xhot: XcursorDim, + pub yhot: XcursorDim, + pub delay: XcursorUInt, + pub pixels: *mut XcursorPixel, +} +pub type XcursorImage = _XcursorImage; + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct _XcursorImages { + pub nimage: c_int, + pub images: *mut *mut XcursorImage, + pub name: *mut c_char, +} +pub type XcursorImages = _XcursorImages; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xf86vmode.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xf86vmode.rs new file mode 100644 index 0000000..393344b --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xf86vmode.rs @@ -0,0 +1,146 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ + c_char, + c_float, + c_int, + c_uchar, + c_uint, + c_ulong, + c_ushort, +}; + +use ::xlib::{ + Bool, + Display, + Time, + Window, + XEvent, +}; + + +// +// functions +// + + +x11_link! { Xf86vmode, xxf86vm, ["libXxf86vm.so.1", "libXxf86vm.so"], 22, + pub fn XF86VidModeAddModeLine (_4: *mut Display, _3: c_int, _2: *mut XF86VidModeModeInfo, _1: *mut XF86VidModeModeInfo) -> c_int, + pub fn XF86VidModeDeleteModeLine (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeModeInfo) -> c_int, + pub fn XF86VidModeGetAllModeLines (_4: *mut Display, _3: c_int, _2: *mut c_int, _1: *mut *mut *mut XF86VidModeModeInfo) -> c_int, + pub fn XF86VidModeGetDotClocks (_6: *mut Display, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut *mut c_int) -> c_int, + pub fn XF86VidModeGetGamma (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeGamma) -> c_int, + pub fn XF86VidModeGetGammaRamp (_6: *mut Display, _5: c_int, _4: c_int, _3: *mut c_ushort, _2: *mut c_ushort, _1: *mut c_ushort) -> c_int, + pub fn XF86VidModeGetGammaRampSize (_3: *mut Display, _2: c_int, _1: *mut c_int) -> c_int, + pub fn XF86VidModeGetModeLine (_4: *mut Display, _3: c_int, _2: *mut c_int, _1: *mut XF86VidModeModeLine) -> c_int, + pub fn XF86VidModeGetMonitor (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeMonitor) -> c_int, + pub fn XF86VidModeGetPermissions (_3: *mut Display, _2: c_int, _1: *mut c_int) -> c_int, + pub fn XF86VidModeGetViewPort (_4: *mut Display, _3: c_int, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XF86VidModeLockModeSwitch (_3: *mut Display, _2: c_int, _1: c_int) -> c_int, + pub fn XF86VidModeModModeLine (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeModeLine) -> c_int, + pub fn XF86VidModeQueryExtension (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XF86VidModeQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XF86VidModeSetClientVersion (_1: *mut Display) -> c_int, + pub fn XF86VidModeSetGamma (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeGamma) -> c_int, + pub fn XF86VidModeSetGammaRamp (_6: *mut Display, _5: c_int, _4: c_int, _3: *mut c_ushort, _2: *mut c_ushort, _1: *mut c_ushort) -> c_int, + pub fn XF86VidModeSetViewPort (_4: *mut Display, _3: c_int, _2: c_int, _1: c_int) -> c_int, + pub fn XF86VidModeSwitchMode (_3: *mut Display, _2: c_int, _1: c_int) -> c_int, + pub fn XF86VidModeSwitchToMode (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeModeInfo) -> c_int, + pub fn XF86VidModeValidateModeLine (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeModeInfo) -> c_int, +variadic: +globals: +} + + +// +// types +// + + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct XF86VidModeGamma { + pub red: c_float, + pub green: c_float, + pub blue: c_float, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XF86VidModeModeInfo { + pub dotclock: c_uint, + pub hdisplay: c_ushort, + pub hsyncstart: c_ushort, + pub hsyncend: c_ushort, + pub htotal: c_ushort, + pub hskew: c_ushort, + pub vdisplay: c_ushort, + pub vsyncstart: c_ushort, + pub vsyncend: c_ushort, + pub vtotal: c_ushort, + pub flags: c_uint, + pub privsize: c_int, + pub private: *mut i32, +} + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct XF86VidModeModeLine { + pub hdisplay: c_ushort, + pub hsyncstart: c_ushort, + pub hsyncend: c_ushort, + pub htotal: c_ushort, + pub hskew: c_ushort, + pub vdisplay: c_ushort, + pub vsyncstart: c_ushort, + pub vsyncend: c_ushort, + pub vtotal: c_ushort, + pub flags: c_uint, + pub privsize: c_int, + pub private: *mut i32, +} + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct XF86VidModeMonitor { + pub vendor: *mut c_char, + pub model: *mut c_char, + pub EMPTY: c_float, + pub nhsync: c_uchar, + pub hsync: *mut XF86VidModeSyncRange, + pub nvsync: c_uchar, + pub vsync: *mut XF86VidModeSyncRange, +} + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct XF86VidModeSyncRange { + pub hi: c_float, + pub lo: c_float, +} + + +// +// event structures +// + + +#[derive(Debug, Clone, Copy)] +#[repr(C)] +pub struct XF86VidModeNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub root: Window, + pub state: c_int, + pub kind: c_int, + pub forced: Bool, + pub time: Time, +} + +event_conversions_and_tests! { + xf86vm_notify: XF86VidModeNotifyEvent, +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xfixes.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xfixes.rs new file mode 100644 index 0000000..0277cbf --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xfixes.rs @@ -0,0 +1,13 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use ::xlib::XID; + + +// +// types +// + + +pub type PointerBarrier = XID; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xft.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xft.rs new file mode 100644 index 0000000..b213cc3 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xft.rs @@ -0,0 +1,219 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::*; + +use xlib::{Display, Region, Visual, XRectangle}; +use xrender::{XGlyphInfo, XRenderColor}; + + +// +// external types +// + + +// freetype +pub enum FT_FaceRec {} +pub type FT_UInt = c_uint; + +// fontconfig +pub type FcChar32 = c_uint; +pub enum FcCharSet {} +pub enum FcPattern {} + +#[repr(C)] +pub enum FcEndian { Big, Little } + +#[repr(C)] +pub enum FcResult { Match, NoMatch, TypeMismatch, NoId, OutOfMemory } + + +// +// functions +// + + +x11_link! { Xft, xft, ["libXft.so.2", "libXft.so"], 77, + pub fn XftCharExists (_2: *mut Display, _1: *mut XftFont, _0: c_uint) -> c_int, + pub fn XftCharFontSpecRender (_7: *mut Display, _6: c_int, _5: c_ulong, _4: c_ulong, _3: c_int, _2: c_int, _1: *const XftCharFontSpec, _0: c_int) -> (), + pub fn XftCharIndex (_2: *mut Display, _1: *mut XftFont, _0: c_uint) -> c_uint, + pub fn XftCharSpecRender (_8: *mut Display, _7: c_int, _6: c_ulong, _5: *mut XftFont, _4: c_ulong, _3: c_int, _2: c_int, _1: *const XftCharSpec, _0: c_int) -> (), + pub fn XftColorAllocName (_4: *mut Display, _3: *const Visual, _2: c_ulong, _1: *const c_char, _0: *mut XftColor) -> c_int, + pub fn XftColorAllocValue (_4: *mut Display, _3: *mut Visual, _2: c_ulong, _1: *const XRenderColor, _0: *mut XftColor) -> c_int, + pub fn XftColorFree (_3: *mut Display, _2: *mut Visual, _1: c_ulong, _0: *mut XftColor) -> (), + pub fn XftDefaultHasRender (_0: *mut Display) -> c_int, + pub fn XftDefaultSet (_1: *mut Display, _0: *mut FcPattern) -> c_int, + pub fn XftDefaultSubstitute (_2: *mut Display, _1: c_int, _0: *mut FcPattern) -> (), + pub fn XftDrawChange (_1: *mut XftDraw, _0: c_ulong) -> (), + pub fn XftDrawCharFontSpec (_3: *mut XftDraw, _2: *const XftColor, _1: *const XftCharFontSpec, _0: c_int) -> (), + pub fn XftDrawCharSpec (_4: *mut XftDraw, _3: *const XftColor, _2: *mut XftFont, _1: *const XftCharSpec, _0: c_int) -> (), + pub fn XftDrawColormap (_0: *mut XftDraw) -> c_ulong, + pub fn XftDrawCreate (_3: *mut Display, _2: c_ulong, _1: *mut Visual, _0: c_ulong) -> *mut XftDraw, + pub fn XftDrawCreateAlpha (_2: *mut Display, _1: c_ulong, _0: c_int) -> *mut XftDraw, + pub fn XftDrawCreateBitmap (_1: *mut Display, _0: c_ulong) -> *mut XftDraw, + pub fn XftDrawDestroy (_0: *mut XftDraw) -> (), + pub fn XftDrawDisplay (_0: *mut XftDraw) -> *mut Display, + pub fn XftDrawDrawable (_0: *mut XftDraw) -> c_ulong, + pub fn XftDrawGlyphFontSpec (_3: *mut XftDraw, _2: *const XftColor, _1: *const XftGlyphFontSpec, _0: c_int) -> (), + pub fn XftDrawGlyphs (_6: *mut XftDraw, _5: *const XftColor, _4: *mut XftFont, _3: c_int, _2: c_int, _1: *const c_uint, _0: c_int) -> (), + pub fn XftDrawGlyphSpec (_4: *mut XftDraw, _3: *const XftColor, _2: *mut XftFont, _1: *const XftGlyphSpec, _0: c_int) -> (), + pub fn XftDrawPicture (_0: *mut XftDraw) -> c_ulong, + pub fn XftDrawRect (_5: *mut XftDraw, _4: *const XftColor, _3: c_int, _2: c_int, _1: c_uint, _0: c_uint) -> (), + pub fn XftDrawSetClip (_1: *mut XftDraw, _0: Region) -> c_int, + pub fn XftDrawSetClipRectangles (_4: *mut XftDraw, _3: c_int, _2: c_int, _1: *const XRectangle, _0: c_int) -> c_int, + pub fn XftDrawSetSubwindowMode (_1: *mut XftDraw, _0: c_int) -> (), + pub fn XftDrawSrcPicture (_1: *mut XftDraw, _0: *const XftColor) -> c_ulong, + pub fn XftDrawString16 (_6: *mut XftDraw, _5: *const XftColor, _4: *mut XftFont, _3: c_int, _2: c_int, _1: *const c_ushort, _0: c_int) -> (), + pub fn XftDrawString32 (_6: *mut XftDraw, _5: *const XftColor, _4: *mut XftFont, _3: c_int, _2: c_int, _1: *const c_uint, _0: c_int) -> (), + pub fn XftDrawString8 (_6: *mut XftDraw, _5: *const XftColor, _4: *mut XftFont, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), + pub fn XftDrawStringUtf16 (_7: *mut XftDraw, _6: *const XftColor, _5: *mut XftFont, _4: c_int, _3: c_int, _2: *const c_uchar, _1: FcEndian, _0: c_int) -> (), + pub fn XftDrawStringUtf8 (_6: *mut XftDraw, _5: *const XftColor, _4: *mut XftFont, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), + pub fn XftDrawVisual (_0: *mut XftDraw) -> *mut Visual, + pub fn XftFontCheckGlyph (_5: *mut Display, _4: *mut XftFont, _3: c_int, _2: c_uint, _1: *mut c_uint, _0: *mut c_int) -> c_int, + pub fn XftFontClose (_1: *mut Display, _0: *mut XftFont) -> (), + pub fn XftFontCopy (_1: *mut Display, _0: *mut XftFont) -> *mut XftFont, + pub fn XftFontInfoCreate (_1: *mut Display, _0: *const FcPattern) -> *mut XftFontInfo, + pub fn XftFontInfoDestroy (_1: *mut Display, _0: *mut XftFontInfo) -> (), + pub fn XftFontInfoEqual (_1: *const XftFontInfo, _0: *const XftFontInfo) -> c_int, + pub fn XftFontInfoHash (_0: *const XftFontInfo) -> c_uint, + pub fn XftFontLoadGlyphs (_4: *mut Display, _3: *mut XftFont, _2: c_int, _1: *const c_uint, _0: c_int) -> (), + pub fn XftFontMatch (_3: *mut Display, _2: c_int, _1: *const FcPattern, _0: *mut FcResult) -> *mut FcPattern, + pub fn XftFontOpenInfo (_2: *mut Display, _1: *mut FcPattern, _0: *mut XftFontInfo) -> *mut XftFont, + pub fn XftFontOpenName (_2: *mut Display, _1: c_int, _0: *const c_char) -> *mut XftFont, + pub fn XftFontOpenPattern (_1: *mut Display, _0: *mut FcPattern) -> *mut XftFont, + pub fn XftFontOpenXlfd (_2: *mut Display, _1: c_int, _0: *const c_char) -> *mut XftFont, + pub fn XftFontUnloadGlyphs (_3: *mut Display, _2: *mut XftFont, _1: *const c_uint, _0: c_int) -> (), + pub fn XftGetVersion () -> c_int, + pub fn XftGlyphExtents (_4: *mut Display, _3: *mut XftFont, _2: *const c_uint, _1: c_int, _0: *mut XGlyphInfo) -> (), + pub fn XftGlyphFontSpecRender (_7: *mut Display, _6: c_int, _5: c_ulong, _4: c_ulong, _3: c_int, _2: c_int, _1: *const XftGlyphFontSpec, _0: c_int) -> (), + pub fn XftGlyphRender (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uint, _0: c_int) -> (), + pub fn XftGlyphSpecRender (_8: *mut Display, _7: c_int, _6: c_ulong, _5: *mut XftFont, _4: c_ulong, _3: c_int, _2: c_int, _1: *const XftGlyphSpec, _0: c_int) -> (), + pub fn XftInit (_0: *const c_char) -> c_int, + pub fn XftInitFtLibrary () -> c_int, + pub fn XftLockFace (_0: *mut XftFont) -> *mut FT_FaceRec, + pub fn XftNameParse (_0: *const c_char) -> *mut FcPattern, + pub fn XftNameUnparse (_2: *mut FcPattern, _1: *mut c_char, _0: c_int) -> c_int, + pub fn XftTextExtents16 (_4: *mut Display, _3: *mut XftFont, _2: *const c_ushort, _1: c_int, _0: *mut XGlyphInfo) -> (), + pub fn XftTextExtents32 (_4: *mut Display, _3: *mut XftFont, _2: *const c_uint, _1: c_int, _0: *mut XGlyphInfo) -> (), + pub fn XftTextExtents8 (_4: *mut Display, _3: *mut XftFont, _2: *const c_uchar, _1: c_int, _0: *mut XGlyphInfo) -> (), + pub fn XftTextExtentsUtf16 (_5: *mut Display, _4: *mut XftFont, _3: *const c_uchar, _2: FcEndian, _1: c_int, _0: *mut XGlyphInfo) -> (), + pub fn XftTextExtentsUtf8 (_4: *mut Display, _3: *mut XftFont, _2: *const c_uchar, _1: c_int, _0: *mut XGlyphInfo) -> (), + pub fn XftTextRender16 (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_ushort, _0: c_int) -> (), + pub fn XftTextRender16BE (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), + pub fn XftTextRender16LE (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), + pub fn XftTextRender32 (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uint, _0: c_int) -> (), + pub fn XftTextRender32BE (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), + pub fn XftTextRender32LE (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), + pub fn XftTextRender8 (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), + pub fn XftTextRenderUtf16 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: *mut XftFont, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_uchar, _1: FcEndian, _0: c_int) -> (), + pub fn XftTextRenderUtf8 (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), + pub fn XftUnlockFace (_0: *mut XftFont) -> (), + pub fn XftXlfdParse (_2: *const c_char, _1: c_int, _0: c_int) -> *mut FcPattern, +variadic: + pub fn XftFontOpen (_1: *mut Display, _0: c_int) -> *mut XftFont, + pub fn XftListFonts (_1: *mut Display, _0: c_int) -> *mut XftFontSet, +globals: +} + + +// +// types +// + + +pub enum XftFontInfo {} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XftFont { + pub ascent: c_int, + pub descent: c_int, + pub height: c_int, + pub max_advance_width: c_int, + pub charset: *mut FcCharSet, + pub pattern: *mut FcPattern, +} + +pub enum XftDraw {} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XftColor { + pub pixel: c_ulong, + pub color: XRenderColor, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XftCharSpec { + pub ucs4: FcChar32, + pub x: c_short, + pub y: c_short, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XftCharFontSpec { + pub font: *mut XftFont, + pub ucs4: FcChar32, + pub x: c_short, + pub y: c_short, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XftFontSet { + pub nfont: c_int, + pub sfont: c_int, + pub fonts: *mut *mut XftPattern, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XftGlyphSpec { + pub glyph: FT_UInt, + pub x: c_short, + pub y: c_short, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XftGlyphFontSpec { + pub font: *mut XftFont, + pub glyph: FT_UInt, + pub x: c_short, + pub y: c_short, +} + +pub enum XftPattern {} + + +// +// constants +// + + +// font attributes +pub const XFT_FAMILY: &'static str = "family"; +pub const XFT_STYLE: &'static str = "style"; +pub const XFT_SLANT: &'static str = "slant"; +pub const XFT_WEIGHT: &'static str = "weight"; +pub const XFT_SIZE: &'static str = "size"; +pub const XFT_PIXEL_SIZE: &'static str = "pixelsize"; +pub const XFT_SPACING: &'static str = "spacing"; +pub const XFT_FOUNDRY: &'static str = "foundry"; +pub const XFT_ANTIALIAS: &'static str = "antialias"; + +// slant values +pub const XFT_SLANT_ROMAN: c_int = 0; +pub const XFT_SLANT_ITALIC: c_int = 100; +pub const XFT_SLANT_OBLIQUE: c_int = 110; + +// attribute types +pub const XftTypeVoid: c_int = 0; +pub const XftTypeInteger: c_int = 1; +pub const XftTypeDouble: c_int = 2; +pub const XftTypeString: c_int = 3; +pub const XftTypeBool: c_int = 4; +pub const XftTypeMatrix: c_int = 5; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xinerama.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xinerama.rs new file mode 100644 index 0000000..b7472a2 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xinerama.rs @@ -0,0 +1,66 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ + c_int, + c_short, +}; + +use ::xlib::{ + Bool, + Display, + Drawable, + Status, + Window, + XID, +}; + + +// +// functions +// + + +x11_link! { Xlib, xinerama, ["libXinerama.so.1", "libXinerama.so"], 10, + pub fn XineramaIsActive (dpy: *mut Display) -> Bool, + pub fn XineramaQueryExtension (dpy: *mut Display, event_base: *mut c_int, error_base: *mut c_int) -> Bool, + pub fn XineramaQueryScreens (dpy: *mut Display, number: *mut c_int) -> *mut XineramaScreenInfo, + pub fn XineramaQueryVersion (dpy: *mut Display, major_versionp: *mut c_int, minor_versionp: *mut c_int) -> Status, + pub fn XPanoramiXAllocInfo () -> *mut XPanoramiXInfo, + pub fn XPanoramiXGetScreenCount (dpy: *mut Display, drawable: Drawable, panoramiX_info: *mut XPanoramiXInfo) -> Status, + pub fn XPanoramiXGetScreenSize (dpy: *mut Display, drawable: Drawable, screen_num: c_int, panoramiX_info: *mut XPanoramiXInfo) -> Status, + pub fn XPanoramiXGetState (dpy: *mut Display, drawable: Drawable, panoramiX_info: *mut XPanoramiXInfo) -> Status, + pub fn XPanoramiXQueryExtension (dpy: *mut Display, event_base_return: *mut c_int, error_base_return: *mut c_int) -> Bool, + pub fn XPanoramiXQueryVersion (dpy: *mut Display, major_version_return: *mut c_int, minor_version_return: *mut c_int) -> Status, +variadic: +globals: +} + + +// +// types +// + + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XineramaScreenInfo { + pub screen_number: c_int, + pub x_org: c_short, + pub y_org: c_short, + pub width: c_short, + pub height: c_short, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XPanoramiXInfo { + pub window: Window, + pub screen: c_int, + pub State: c_int, + pub width: c_int, + pub height: c_int, + pub ScreenCount: c_int, + pub eventMask: XID, +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xinput.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xinput.rs new file mode 100644 index 0000000..649065c --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xinput.rs @@ -0,0 +1,165 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ + c_char, + c_int, + c_long, + c_short, + c_uchar, + c_uint, + c_ulong, +}; + +use ::xlib::{ + Atom, + Display, + Time, + XEvent, + XID, + XModifierKeymap, +}; + +// +// functions +// + +x11_link! { XInput, xi, ["libXi.so.6", "libXi.so"], 44, + pub fn XAllowDeviceEvents (_4: *mut Display, _3: *mut XDevice, _2: c_int, _1: c_ulong) -> c_int, + pub fn XChangeDeviceControl (_4: *mut Display, _3: *mut XDevice, _2: c_int, _1: *mut XDeviceControl) -> c_int, + pub fn XChangeDeviceDontPropagateList (_5: *mut Display, _4: c_ulong, _3: c_int, _2: *mut c_ulong, _1: c_int) -> c_int, + pub fn XChangeDeviceKeyMapping (_6: *mut Display, _5: *mut XDevice, _4: c_int, _3: c_int, _2: *mut c_ulong, _1: c_int) -> c_int, + pub fn XChangeDeviceProperty (_8: *mut Display, _7: *mut XDevice, _6: c_ulong, _5: c_ulong, _4: c_int, _3: c_int, _2: *const c_uchar, _1: c_int) -> (), + pub fn XChangeFeedbackControl (_4: *mut Display, _3: *mut XDevice, _2: c_ulong, _1: *mut XFeedbackControl) -> c_int, + pub fn XChangeKeyboardDevice (_2: *mut Display, _1: *mut XDevice) -> c_int, + pub fn XChangePointerDevice (_4: *mut Display, _3: *mut XDevice, _2: c_int, _1: c_int) -> c_int, + pub fn XCloseDevice (_2: *mut Display, _1: *mut XDevice) -> c_int, + pub fn XDeleteDeviceProperty (_3: *mut Display, _2: *mut XDevice, _1: c_ulong) -> (), + pub fn XDeviceBell (_5: *mut Display, _4: *mut XDevice, _3: c_ulong, _2: c_ulong, _1: c_int) -> c_int, + pub fn XFreeDeviceControl (_1: *mut XDeviceControl) -> (), + pub fn XFreeDeviceList (_1: *mut XDeviceInfo) -> (), + pub fn XFreeDeviceMotionEvents (_1: *mut XDeviceTimeCoord) -> (), + pub fn XFreeDeviceState (_1: *mut XDeviceState) -> (), + pub fn XFreeFeedbackList (_1: *mut XFeedbackState) -> (), + pub fn XGetDeviceButtonMapping (_4: *mut Display, _3: *mut XDevice, _2: *mut c_uchar, _1: c_uint) -> c_int, + pub fn XGetDeviceControl (_3: *mut Display, _2: *mut XDevice, _1: c_int) -> *mut XDeviceControl, + pub fn XGetDeviceDontPropagateList (_3: *mut Display, _2: c_ulong, _1: *mut c_int) -> *mut c_ulong, + pub fn XGetDeviceFocus (_5: *mut Display, _4: *mut XDevice, _3: *mut c_ulong, _2: *mut c_int, _1: *mut c_ulong) -> c_int, + pub fn XGetDeviceKeyMapping (_5: *mut Display, _4: *mut XDevice, _3: c_uchar, _2: c_int, _1: *mut c_int) -> *mut c_ulong, + pub fn XGetDeviceModifierMapping (_2: *mut Display, _1: *mut XDevice) -> *mut XModifierKeymap, + pub fn XGetDeviceMotionEvents (_7: *mut Display, _6: *mut XDevice, _5: c_ulong, _4: c_ulong, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> *mut XDeviceTimeCoord, + pub fn XGetDeviceProperty (_12: *mut Display, _11: *mut XDevice, _10: c_ulong, _9: c_long, _8: c_long, _7: c_int, _6: c_ulong, _5: *mut c_ulong, _4: *mut c_int, _3: *mut c_ulong, _2: *mut c_ulong, _1: *mut *mut c_uchar) -> c_int, + pub fn XGetExtensionVersion (_2: *mut Display, _1: *const c_char) -> *mut XExtensionVersion, + pub fn XGetFeedbackControl (_3: *mut Display, _2: *mut XDevice, _1: *mut c_int) -> *mut XFeedbackState, + pub fn XGetSelectedExtensionEvents (_6: *mut Display, _5: c_ulong, _4: *mut c_int, _3: *mut *mut c_ulong, _2: *mut c_int, _1: *mut *mut c_ulong) -> c_int, + pub fn XGrabDevice (_9: *mut Display, _8: *mut XDevice, _7: c_ulong, _6: c_int, _5: c_int, _4: *mut c_ulong, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XGrabDeviceButton (_11: *mut Display, _10: *mut XDevice, _9: c_uint, _8: c_uint, _7: *mut XDevice, _6: c_ulong, _5: c_int, _4: c_uint, _3: *mut c_ulong, _2: c_int, _1: c_int) -> c_int, + pub fn XGrabDeviceKey (_11: *mut Display, _10: *mut XDevice, _9: c_uint, _8: c_uint, _7: *mut XDevice, _6: c_ulong, _5: c_int, _4: c_uint, _3: *mut c_ulong, _2: c_int, _1: c_int) -> c_int, + + pub fn XListDeviceProperties (_3: *mut Display, _2: *mut XDevice, _1: *mut c_int) -> *mut c_ulong, + pub fn XListInputDevices (_2: *mut Display, _1: *mut c_int) -> *mut XDeviceInfo, + pub fn XOpenDevice (_2: *mut Display, _1: c_ulong) -> *mut XDevice, + pub fn XQueryDeviceState (_2: *mut Display, _1: *mut XDevice) -> *mut XDeviceState, + pub fn XSelectExtensionEvent (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int, + pub fn XSendExtensionEvent (_7: *mut Display, _6: *mut XDevice, _5: c_ulong, _4: c_int, _3: c_int, _2: *mut c_ulong, _1: *mut XEvent) -> c_int, + pub fn XSetDeviceButtonMapping (_4: *mut Display, _3: *mut XDevice, _2: *mut c_uchar, _1: c_int) -> c_int, + pub fn XSetDeviceFocus (_5: *mut Display, _4: *mut XDevice, _3: c_ulong, _2: c_int, _1: c_ulong) -> c_int, + pub fn XSetDeviceMode (_3: *mut Display, _2: *mut XDevice, _1: c_int) -> c_int, + pub fn XSetDeviceModifierMapping (_3: *mut Display, _2: *mut XDevice, _1: *mut XModifierKeymap) -> c_int, + pub fn XSetDeviceValuators (_5: *mut Display, _4: *mut XDevice, _3: *mut c_int, _2: c_int, _1: c_int) -> c_int, + pub fn XUngrabDevice (_3: *mut Display, _2: *mut XDevice, _1: c_ulong) -> c_int, + pub fn XUngrabDeviceButton (_6: *mut Display, _5: *mut XDevice, _4: c_uint, _3: c_uint, _2: *mut XDevice, _1: c_ulong) -> c_int, + pub fn XUngrabDeviceKey (_6: *mut Display, _5: *mut XDevice, _4: c_uint, _3: c_uint, _2: *mut XDevice, _1: c_ulong) -> c_int, +variadic: +globals: +} + + +// +// types +// + +pub enum _XAnyClassinfo {} + +pub type XAnyClassPtr = *mut _XAnyClassinfo; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XDevice { + pub device_id: XID, + pub num_classes: c_int, + pub classes: *mut XInputClassInfo, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XDeviceControl { + pub control: XID, + pub length: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XDeviceInfo { + pub id: XID, + pub type_: Atom, + pub name: *mut c_char, + pub num_classes: c_int, + pub use_: c_int, + pub inputclassinfo: XAnyClassPtr, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XDeviceState { + pub device_id: XID, + pub num_classes: c_int, + pub data: *mut XInputClass, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XDeviceTimeCoord { + pub time: Time, + pub data: *mut c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XExtensionVersion { + pub present: c_int, + pub major_version: c_short, + pub minor_version: c_short, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XFeedbackControl { + pub class: XID, + pub length: c_int, + pub id: XID, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XFeedbackState { + pub class: XID, + pub length: c_int, + pub id: XID, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XInputClass { + pub class: c_uchar, + pub length: c_uchar, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XInputClassInfo { + pub input_class: c_uchar, + pub event_type_base: c_uchar, +} + diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xinput2.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xinput2.rs new file mode 100644 index 0000000..b78cd37 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xinput2.rs @@ -0,0 +1,758 @@ +use xfixes::PointerBarrier; +use xlib::{Atom, Display, Time, Window}; +use std::os::raw::{c_int, c_uint, c_long, c_double, c_ulong, c_uchar}; + +// +// macro translations +// +fn mask_byte(mask_flag: i32) -> usize { + (mask_flag >> 3) as usize +} + +pub fn XISetMask(mask: &mut [::std::os::raw::c_uchar], event: i32) { + mask[mask_byte(event)] |= 1 << (event & 7); +} + +pub fn XIClearMask(mask: &mut [::std::os::raw::c_uchar], event: i32) { + mask[mask_byte(event)] &= 1 << (event & 7); +} + +pub fn XIMaskIsSet(mask: &[::std::os::raw::c_uchar], event: i32) -> bool { + (mask[mask_byte(event)] & (1 << (event & 7))) != 0 +} + +// +// functions +// +x11_link! { XInput2, xi, ["libXi.so.6", "libXi.so"], 34, + pub fn XIAllowEvents (_4: *mut Display, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XIAllowTouchEvents (_5: *mut Display, _4: c_int, _3: c_uint, _2: c_ulong, _1: c_int) -> c_int, + pub fn XIBarrierReleasePointer (_4: *mut Display, _3: c_int, _2: c_ulong, _1: c_uint) -> (), + pub fn XIBarrierReleasePointers (_3: *mut Display, _2: *mut XIBarrierReleasePointerInfo, _1: c_int) -> (), + pub fn XIChangeHierarchy (_3: *mut Display, _2: *mut XIAnyHierarchyChangeInfo, _1: c_int) -> c_int, + pub fn XIChangeProperty (_8: *mut Display, _7: c_int, _6: c_ulong, _5: c_ulong, _4: c_int, _3: c_int, _2: *mut c_uchar, _1: c_int) -> (), + pub fn XIDefineCursor (_4: *mut Display, _3: c_int, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XIDeleteProperty (_3: *mut Display, _2: c_int, _1: c_ulong) -> (), + pub fn XIFreeDeviceInfo (_1: *mut XIDeviceInfo) -> (), + pub fn XIGetClientPointer (_3: *mut Display, _2: c_ulong, _1: *mut c_int) -> c_int, + pub fn XIGetFocus (_3: *mut Display, _2: c_int, _1: *mut c_ulong) -> c_int, + pub fn XIGetProperty (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_long, _8: c_long, _7: c_int, _6: c_ulong, _5: *mut c_ulong, _4: *mut c_int, _3: *mut c_ulong, _2: *mut c_ulong, _1: *mut *mut c_uchar) -> c_int, + pub fn XIGetSelectedEvents (_3: *mut Display, _2: c_ulong, _1: *mut c_int) -> *mut XIEventMask, + pub fn XIGrabButton (_11: *mut Display, _10: c_int, _9: c_int, _8: c_ulong, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: *mut XIEventMask, _2: c_int, _1: *mut XIGrabModifiers) -> c_int, + pub fn XIGrabDevice (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: c_ulong, _4: c_int, _3: c_int, _2: c_int, _1: *mut XIEventMask) -> c_int, + pub fn XIGrabEnter (_10: *mut Display, _9: c_int, _8: c_ulong, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: *mut XIEventMask, _2: c_int, _1: *mut XIGrabModifiers) -> c_int, + pub fn XIGrabFocusIn (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: *mut XIEventMask, _2: c_int, _1: *mut XIGrabModifiers) -> c_int, + pub fn XIGrabKeycode (_10: *mut Display, _9: c_int, _8: c_int, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: *mut XIEventMask, _2: c_int, _1: *mut XIGrabModifiers) -> c_int, + pub fn XIGrabTouchBegin (_7: *mut Display, _6: c_int, _5: c_ulong, _4: c_int, _3: *mut XIEventMask, _2: c_int, _1: *mut XIGrabModifiers) -> c_int, + pub fn XIListProperties (_3: *mut Display, _2: c_int, _1: *mut c_int) -> *mut c_ulong, + pub fn XIQueryDevice (_3: *mut Display, _2: c_int, _1: *mut c_int) -> *mut XIDeviceInfo, + pub fn XIQueryPointer (_12: *mut Display, _11: c_int, _10: c_ulong, _9: *mut c_ulong, _8: *mut c_ulong, _7: *mut c_double, _6: *mut c_double, _5: *mut c_double, _4: *mut c_double, _3: *mut XIButtonState, _2: *mut XIModifierState, _1: *mut XIModifierState) -> c_int, + pub fn XIQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XISelectEvents (_4: *mut Display, _3: c_ulong, _2: *mut XIEventMask, _1: c_int) -> c_int, + pub fn XISetClientPointer (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int, + pub fn XISetFocus (_4: *mut Display, _3: c_int, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XIUndefineCursor (_3: *mut Display, _2: c_int, _1: c_ulong) -> c_int, + pub fn XIUngrabButton (_6: *mut Display, _5: c_int, _4: c_int, _3: c_ulong, _2: c_int, _1: *mut XIGrabModifiers) -> c_int, + pub fn XIUngrabDevice (_3: *mut Display, _2: c_int, _1: c_ulong) -> c_int, + pub fn XIUngrabEnter (_5: *mut Display, _4: c_int, _3: c_ulong, _2: c_int, _1: *mut XIGrabModifiers) -> c_int, + pub fn XIUngrabFocusIn (_5: *mut Display, _4: c_int, _3: c_ulong, _2: c_int, _1: *mut XIGrabModifiers) -> c_int, + pub fn XIUngrabKeycode (_6: *mut Display, _5: c_int, _4: c_int, _3: c_ulong, _2: c_int, _1: *mut XIGrabModifiers) -> c_int, + pub fn XIUngrabTouchBegin (_5: *mut Display, _4: c_int, _3: c_ulong, _2: c_int, _1: *mut XIGrabModifiers) -> c_int, + pub fn XIWarpPointer (_10: *mut Display, _9: c_int, _8: c_ulong, _7: c_ulong, _6: c_double, _5: c_double, _4: c_uint, _3: c_uint, _2: c_double, _1: c_double) -> c_int, +variadic: +globals: +} + +// +// constants +// (auto-generated with cmacros) +// + +pub const XInput_2_0: i32 = 7; +pub const XI_2_Major: i32 = 2; +pub const XI_2_Minor: i32 = 3; +pub const XIPropertyDeleted: i32 = 0; +pub const XIPropertyCreated: i32 = 1; +pub const XIPropertyModified: i32 = 2; +pub const XIPropModeReplace: i32 = 0; +pub const XIPropModePrepend: i32 = 1; +pub const XIPropModeAppend: i32 = 2; +pub const XINotifyNormal: i32 = 0; +pub const XINotifyGrab: i32 = 1; +pub const XINotifyUngrab: i32 = 2; +pub const XINotifyWhileGrabbed: i32 = 3; +pub const XINotifyPassiveGrab: i32 = 4; +pub const XINotifyPassiveUngrab: i32 = 5; +pub const XINotifyAncestor: i32 = 0; +pub const XINotifyVirtual: i32 = 1; +pub const XINotifyInferior: i32 = 2; +pub const XINotifyNonlinear: i32 = 3; +pub const XINotifyNonlinearVirtual: i32 = 4; +pub const XINotifyPointer: i32 = 5; +pub const XINotifyPointerRoot: i32 = 6; +pub const XINotifyDetailNone: i32 = 7; +pub const XIGrabModeSync: i32 = 0; +pub const XIGrabModeAsync: i32 = 1; +pub const XIGrabModeTouch: i32 = 2; +pub const XIGrabSuccess: i32 = 0; +pub const XIAlreadyGrabbed: i32 = 1; +pub const XIGrabInvalidTime: i32 = 2; +pub const XIGrabNotViewable: i32 = 3; +pub const XIGrabFrozen: i32 = 4; +pub const XIGrabtypeButton: i32 = 0; +pub const XIGrabtypeKeycode: i32 = 1; +pub const XIGrabtypeEnter: i32 = 2; +pub const XIGrabtypeFocusIn: i32 = 3; +pub const XIGrabtypeTouchBegin: i32 = 4; +pub const XIAnyButton: i32 = 0; +pub const XIAnyKeycode: i32 = 0; +pub const XIAsyncDevice: i32 = 0; +pub const XISyncDevice: i32 = 1; +pub const XIReplayDevice: i32 = 2; +pub const XIAsyncPairedDevice: i32 = 3; +pub const XIAsyncPair: i32 = 4; +pub const XISyncPair: i32 = 5; +pub const XIAcceptTouch: i32 = 6; +pub const XIRejectTouch: i32 = 7; +pub const XISlaveSwitch: i32 = 1; +pub const XIDeviceChange: i32 = 2; +pub const XIMasterAdded: i32 = (1 << 0); +pub const XIMasterRemoved: i32 = (1 << 1); +pub const XISlaveAdded: i32 = (1 << 2); +pub const XISlaveRemoved: i32 = (1 << 3); +pub const XISlaveAttached: i32 = (1 << 4); +pub const XISlaveDetached: i32 = (1 << 5); +pub const XIDeviceEnabled: i32 = (1 << 6); +pub const XIDeviceDisabled: i32 = (1 << 7); +pub const XIAddMaster: i32 = 1; +pub const XIRemoveMaster: i32 = 2; +pub const XIAttachSlave: i32 = 3; +pub const XIDetachSlave: i32 = 4; +pub const XIAttachToMaster: i32 = 1; +pub const XIFloating: i32 = 2; +pub const XIModeRelative: i32 = 0; +pub const XIModeAbsolute: i32 = 1; +pub const XIMasterPointer: i32 = 1; +pub const XIMasterKeyboard: i32 = 2; +pub const XISlavePointer: i32 = 3; +pub const XISlaveKeyboard: i32 = 4; +pub const XIFloatingSlave: i32 = 5; +pub const XIKeyClass: i32 = 0; +pub const XIButtonClass: i32 = 1; +pub const XIValuatorClass: i32 = 2; +pub const XIScrollClass: i32 = 3; +pub const XITouchClass: i32 = 8; +pub const XIScrollTypeVertical: i32 = 1; +pub const XIScrollTypeHorizontal: i32 = 2; +pub const XIScrollFlagNoEmulation: i32 = (1 << 0); +pub const XIScrollFlagPreferred: i32 = (1 << 1); +pub const XIKeyRepeat: i32 = (1 << 16); +pub const XIPointerEmulated: i32 = (1 << 16); +pub const XITouchPendingEnd: i32 = (1 << 16); +pub const XITouchEmulatingPointer: i32 = (1 << 17); +pub const XIBarrierPointerReleased: i32 = (1 << 0); +pub const XIBarrierDeviceIsGrabbed: i32 = (1 << 1); +pub const XIDirectTouch: i32 = 1; +pub const XIDependentTouch: i32 = 2; +pub const XIAllDevices: i32 = 0; +pub const XIAllMasterDevices: i32 = 1; +pub const XI_DeviceChanged: i32 = 1; +pub const XI_KeyPress: i32 = 2; +pub const XI_KeyRelease: i32 = 3; +pub const XI_ButtonPress: i32 = 4; +pub const XI_ButtonRelease: i32 = 5; +pub const XI_Motion: i32 = 6; +pub const XI_Enter: i32 = 7; +pub const XI_Leave: i32 = 8; +pub const XI_FocusIn: i32 = 9; +pub const XI_FocusOut: i32 = 10; +pub const XI_HierarchyChanged: i32 = 11; +pub const XI_PropertyEvent: i32 = 12; +pub const XI_RawKeyPress: i32 = 13; +pub const XI_RawKeyRelease: i32 = 14; +pub const XI_RawButtonPress: i32 = 15; +pub const XI_RawButtonRelease: i32 = 16; +pub const XI_RawMotion: i32 = 17; +pub const XI_TouchBegin: i32 = 18 /* XI 2.2 */; +pub const XI_TouchUpdate: i32 = 19; +pub const XI_TouchEnd: i32 = 20; +pub const XI_TouchOwnership: i32 = 21; +pub const XI_RawTouchBegin: i32 = 22; +pub const XI_RawTouchUpdate: i32 = 23; +pub const XI_RawTouchEnd: i32 = 24; +pub const XI_BarrierHit: i32 = 25 /* XI 2.3 */; +pub const XI_BarrierLeave: i32 = 26; +pub const XI_LASTEVENT: i32 = XI_BarrierLeave; +pub const XI_DeviceChangedMask: i32 = (1 << XI_DeviceChanged); +pub const XI_KeyPressMask: i32 = (1 << XI_KeyPress); +pub const XI_KeyReleaseMask: i32 = (1 << XI_KeyRelease); +pub const XI_ButtonPressMask: i32 = (1 << XI_ButtonPress); +pub const XI_ButtonReleaseMask: i32 = (1 << XI_ButtonRelease); +pub const XI_MotionMask: i32 = (1 << XI_Motion); +pub const XI_EnterMask: i32 = (1 << XI_Enter); +pub const XI_LeaveMask: i32 = (1 << XI_Leave); +pub const XI_FocusInMask: i32 = (1 << XI_FocusIn); +pub const XI_FocusOutMask: i32 = (1 << XI_FocusOut); +pub const XI_HierarchyChangedMask: i32 = (1 << XI_HierarchyChanged); +pub const XI_PropertyEventMask: i32 = (1 << XI_PropertyEvent); +pub const XI_RawKeyPressMask: i32 = (1 << XI_RawKeyPress); +pub const XI_RawKeyReleaseMask: i32 = (1 << XI_RawKeyRelease); +pub const XI_RawButtonPressMask: i32 = (1 << XI_RawButtonPress); +pub const XI_RawButtonReleaseMask: i32 = (1 << XI_RawButtonRelease); +pub const XI_RawMotionMask: i32 = (1 << XI_RawMotion); +pub const XI_TouchBeginMask: i32 = (1 << XI_TouchBegin); +pub const XI_TouchEndMask: i32 = (1 << XI_TouchEnd); +pub const XI_TouchOwnershipChangedMask: i32 = (1 << XI_TouchOwnership); +pub const XI_TouchUpdateMask: i32 = (1 << XI_TouchUpdate); +pub const XI_RawTouchBeginMask: i32 = (1 << XI_RawTouchBegin); +pub const XI_RawTouchEndMask: i32 = (1 << XI_RawTouchEnd); +pub const XI_RawTouchUpdateMask: i32 = (1 << XI_RawTouchUpdate); +pub const XI_BarrierHitMask: i32 = (1 << XI_BarrierHit); +pub const XI_BarrierLeaveMask: i32 = (1 << XI_BarrierLeave); + +// +// structs +// (auto-generated with rust-bindgen) +// + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIAddMasterInfo { + pub _type: ::std::os::raw::c_int, + pub name: *mut ::std::os::raw::c_char, + pub send_core: ::std::os::raw::c_int, + pub enable: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIAddMasterInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIAddMasterInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIRemoveMasterInfo { + pub _type: ::std::os::raw::c_int, + pub deviceid: ::std::os::raw::c_int, + pub return_mode: ::std::os::raw::c_int, + pub return_pointer: ::std::os::raw::c_int, + pub return_keyboard: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIRemoveMasterInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIRemoveMasterInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIAttachSlaveInfo { + pub _type: ::std::os::raw::c_int, + pub deviceid: ::std::os::raw::c_int, + pub new_master: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIAttachSlaveInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIAttachSlaveInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIDetachSlaveInfo { + pub _type: ::std::os::raw::c_int, + pub deviceid: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIDetachSlaveInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIDetachSlaveInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIAnyHierarchyChangeInfo { + pub _bindgen_data_: [u64; 3usize], +} +impl XIAnyHierarchyChangeInfo { + pub unsafe fn _type(&mut self) -> *mut ::std::os::raw::c_int { + let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); + ::std::mem::transmute(raw.offset(0)) + } + pub unsafe fn add(&mut self) -> *mut XIAddMasterInfo { + let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); + ::std::mem::transmute(raw.offset(0)) + } + pub unsafe fn remove(&mut self) -> *mut XIRemoveMasterInfo { + let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); + ::std::mem::transmute(raw.offset(0)) + } + pub unsafe fn attach(&mut self) -> *mut XIAttachSlaveInfo { + let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); + ::std::mem::transmute(raw.offset(0)) + } + pub unsafe fn detach(&mut self) -> *mut XIDetachSlaveInfo { + let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); + ::std::mem::transmute(raw.offset(0)) + } +} +impl ::std::clone::Clone for XIAnyHierarchyChangeInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIAnyHierarchyChangeInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIModifierState { + pub base: ::std::os::raw::c_int, + pub latched: ::std::os::raw::c_int, + pub locked: ::std::os::raw::c_int, + pub effective: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIModifierState { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIModifierState { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +pub type XIGroupState = XIModifierState; + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIButtonState { + pub mask_len: ::std::os::raw::c_int, + pub mask: *mut ::std::os::raw::c_uchar, +} +impl ::std::clone::Clone for XIButtonState { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIButtonState { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIValuatorState { + pub mask_len: ::std::os::raw::c_int, + pub mask: *mut ::std::os::raw::c_uchar, + pub values: *mut ::std::os::raw::c_double, +} +impl ::std::clone::Clone for XIValuatorState { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIValuatorState { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIEventMask { + pub deviceid: ::std::os::raw::c_int, + pub mask_len: ::std::os::raw::c_int, + pub mask: *mut ::std::os::raw::c_uchar, +} +impl ::std::clone::Clone for XIEventMask { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIEventMask { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIAnyClassInfo { + pub _type: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIAnyClassInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIAnyClassInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIButtonClassInfo { + pub _type: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub num_buttons: ::std::os::raw::c_int, + pub labels: *mut Atom, + pub state: XIButtonState, +} +impl ::std::clone::Clone for XIButtonClassInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIButtonClassInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIKeyClassInfo { + pub _type: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub num_keycodes: ::std::os::raw::c_int, + pub keycodes: *mut ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIKeyClassInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIKeyClassInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIValuatorClassInfo { + pub _type: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub number: ::std::os::raw::c_int, + pub label: Atom, + pub min: ::std::os::raw::c_double, + pub max: ::std::os::raw::c_double, + pub value: ::std::os::raw::c_double, + pub resolution: ::std::os::raw::c_int, + pub mode: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIValuatorClassInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIValuatorClassInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIScrollClassInfo { + pub _type: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub number: ::std::os::raw::c_int, + pub scroll_type: ::std::os::raw::c_int, + pub increment: ::std::os::raw::c_double, + pub flags: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIScrollClassInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIScrollClassInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XITouchClassInfo { + pub _type: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub mode: ::std::os::raw::c_int, + pub num_touches: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XITouchClassInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XITouchClassInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIDeviceInfo { + pub deviceid: ::std::os::raw::c_int, + pub name: *mut ::std::os::raw::c_char, + pub _use: ::std::os::raw::c_int, + pub attachment: ::std::os::raw::c_int, + pub enabled: ::std::os::raw::c_int, + pub num_classes: ::std::os::raw::c_int, + pub classes: *mut *mut XIAnyClassInfo, +} +impl ::std::clone::Clone for XIDeviceInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIDeviceInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIGrabModifiers { + pub modifiers: ::std::os::raw::c_int, + pub status: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIGrabModifiers { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIGrabModifiers { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +pub type BarrierEventID = ::std::os::raw::c_uint; + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIBarrierReleasePointerInfo { + pub deviceid: ::std::os::raw::c_int, + pub barrier: PointerBarrier, + pub eventid: BarrierEventID, +} +impl ::std::clone::Clone for XIBarrierReleasePointerInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIBarrierReleasePointerInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIEvent { + pub _type: ::std::os::raw::c_int, + pub serial: ::std::os::raw::c_ulong, + pub send_event: ::std::os::raw::c_int, + pub display: *mut Display, + pub extension: ::std::os::raw::c_int, + pub evtype: ::std::os::raw::c_int, + pub time: Time, +} +impl ::std::clone::Clone for XIEvent { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIEvent { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIHierarchyInfo { + pub deviceid: ::std::os::raw::c_int, + pub attachment: ::std::os::raw::c_int, + pub _use: ::std::os::raw::c_int, + pub enabled: ::std::os::raw::c_int, + pub flags: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIHierarchyInfo { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIHierarchyInfo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIHierarchyEvent { + pub _type: ::std::os::raw::c_int, + pub serial: ::std::os::raw::c_ulong, + pub send_event: ::std::os::raw::c_int, + pub display: *mut Display, + pub extension: ::std::os::raw::c_int, + pub evtype: ::std::os::raw::c_int, + pub time: Time, + pub flags: ::std::os::raw::c_int, + pub num_info: ::std::os::raw::c_int, + pub info: *mut XIHierarchyInfo, +} +impl ::std::clone::Clone for XIHierarchyEvent { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIHierarchyEvent { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIDeviceChangedEvent { + pub _type: ::std::os::raw::c_int, + pub serial: ::std::os::raw::c_ulong, + pub send_event: ::std::os::raw::c_int, + pub display: *mut Display, + pub extension: ::std::os::raw::c_int, + pub evtype: ::std::os::raw::c_int, + pub time: Time, + pub deviceid: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub reason: ::std::os::raw::c_int, + pub num_classes: ::std::os::raw::c_int, + pub classes: *mut *mut XIAnyClassInfo, +} +impl ::std::clone::Clone for XIDeviceChangedEvent { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIDeviceChangedEvent { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIDeviceEvent { + pub _type: ::std::os::raw::c_int, + pub serial: ::std::os::raw::c_ulong, + pub send_event: ::std::os::raw::c_int, + pub display: *mut Display, + pub extension: ::std::os::raw::c_int, + pub evtype: ::std::os::raw::c_int, + pub time: Time, + pub deviceid: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub detail: ::std::os::raw::c_int, + pub root: Window, + pub event: Window, + pub child: Window, + pub root_x: ::std::os::raw::c_double, + pub root_y: ::std::os::raw::c_double, + pub event_x: ::std::os::raw::c_double, + pub event_y: ::std::os::raw::c_double, + pub flags: ::std::os::raw::c_int, + pub buttons: XIButtonState, + pub valuators: XIValuatorState, + pub mods: XIModifierState, + pub group: XIGroupState, +} +impl ::std::clone::Clone for XIDeviceEvent { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIDeviceEvent { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIRawEvent { + pub _type: ::std::os::raw::c_int, + pub serial: ::std::os::raw::c_ulong, + pub send_event: ::std::os::raw::c_int, + pub display: *mut Display, + pub extension: ::std::os::raw::c_int, + pub evtype: ::std::os::raw::c_int, + pub time: Time, + pub deviceid: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub detail: ::std::os::raw::c_int, + pub flags: ::std::os::raw::c_int, + pub valuators: XIValuatorState, + pub raw_values: *mut ::std::os::raw::c_double, +} +impl ::std::clone::Clone for XIRawEvent { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIRawEvent { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIEnterEvent { + pub _type: ::std::os::raw::c_int, + pub serial: ::std::os::raw::c_ulong, + pub send_event: ::std::os::raw::c_int, + pub display: *mut Display, + pub extension: ::std::os::raw::c_int, + pub evtype: ::std::os::raw::c_int, + pub time: Time, + pub deviceid: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub detail: ::std::os::raw::c_int, + pub root: Window, + pub event: Window, + pub child: Window, + pub root_x: ::std::os::raw::c_double, + pub root_y: ::std::os::raw::c_double, + pub event_x: ::std::os::raw::c_double, + pub event_y: ::std::os::raw::c_double, + pub mode: ::std::os::raw::c_int, + pub focus: ::std::os::raw::c_int, + pub same_screen: ::std::os::raw::c_int, + pub buttons: XIButtonState, + pub mods: XIModifierState, + pub group: XIGroupState, +} +impl ::std::clone::Clone for XIEnterEvent { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIEnterEvent { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +pub type XILeaveEvent = XIEnterEvent; +pub type XIFocusInEvent = XIEnterEvent; +pub type XIFocusOutEvent = XIEnterEvent; + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIPropertyEvent { + pub _type: ::std::os::raw::c_int, + pub serial: ::std::os::raw::c_ulong, + pub send_event: ::std::os::raw::c_int, + pub display: *mut Display, + pub extension: ::std::os::raw::c_int, + pub evtype: ::std::os::raw::c_int, + pub time: Time, + pub deviceid: ::std::os::raw::c_int, + pub property: Atom, + pub what: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XIPropertyEvent { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIPropertyEvent { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XITouchOwnershipEvent { + pub _type: ::std::os::raw::c_int, + pub serial: ::std::os::raw::c_ulong, + pub send_event: ::std::os::raw::c_int, + pub display: *mut Display, + pub extension: ::std::os::raw::c_int, + pub evtype: ::std::os::raw::c_int, + pub time: Time, + pub deviceid: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub touchid: ::std::os::raw::c_uint, + pub root: Window, + pub event: Window, + pub child: Window, + pub flags: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for XITouchOwnershipEvent { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XITouchOwnershipEvent { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct XIBarrierEvent { + pub _type: ::std::os::raw::c_int, + pub serial: ::std::os::raw::c_ulong, + pub send_event: ::std::os::raw::c_int, + pub display: *mut Display, + pub extension: ::std::os::raw::c_int, + pub evtype: ::std::os::raw::c_int, + pub time: Time, + pub deviceid: ::std::os::raw::c_int, + pub sourceid: ::std::os::raw::c_int, + pub event: Window, + pub root: Window, + pub root_x: ::std::os::raw::c_double, + pub root_y: ::std::os::raw::c_double, + pub dx: ::std::os::raw::c_double, + pub dy: ::std::os::raw::c_double, + pub dtime: ::std::os::raw::c_int, + pub flags: ::std::os::raw::c_int, + pub barrier: PointerBarrier, + pub eventid: BarrierEventID, +} +impl ::std::clone::Clone for XIBarrierEvent { + fn clone(&self) -> Self { *self } +} +impl ::std::default::Default for XIBarrierEvent { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xlib.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xlib.rs new file mode 100644 index 0000000..62d4585 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xlib.rs @@ -0,0 +1,3404 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::slice; +use std::os::raw::{ + c_char, + c_double, + c_int, + c_long, + c_short, + c_schar, + c_uchar, + c_uint, + c_ulong, + c_ushort, + c_void, +}; +use std::fmt; + +use libc::wchar_t; + +use ::internal::{ + mem_eq, + transmute_union, +}; +use xf86vmode; +use xrandr; +use xss; + + +// deprecated +pub mod xkb {} + + +// +// functions +// + + +x11_link! { Xlib, x11, ["libX11.so.6", "libX11.so"], 767, + pub fn XActivateScreenSaver (_1: *mut Display) -> c_int, + pub fn XAddConnectionWatch (_3: *mut Display, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char, c_int, c_int, *mut *mut c_char)>, _1: *mut c_char) -> c_int, + pub fn XAddExtension (_1: *mut Display) -> *mut XExtCodes, + pub fn XAddHost (_2: *mut Display, _1: *mut XHostAddress) -> c_int, + pub fn XAddHosts (_3: *mut Display, _2: *mut XHostAddress, _1: c_int) -> c_int, + pub fn XAddPixel (_2: *mut XImage, _1: c_long) -> c_int, + pub fn XAddToExtensionList (_2: *mut *mut XExtData, _1: *mut XExtData) -> c_int, + pub fn XAddToSaveSet (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XAllocClassHint () -> *mut XClassHint, + pub fn XAllocColor (_3: *mut Display, _2: c_ulong, _1: *mut XColor) -> c_int, + pub fn XAllocColorCells (_7: *mut Display, _6: c_ulong, _5: c_int, _4: *mut c_ulong, _3: c_uint, _2: *mut c_ulong, _1: c_uint) -> c_int, + pub fn XAllocColorPlanes (_11: *mut Display, _10: c_ulong, _9: c_int, _8: *mut c_ulong, _7: c_int, _6: c_int, _5: c_int, _4: c_int, _3: *mut c_ulong, _2: *mut c_ulong, _1: *mut c_ulong) -> c_int, + pub fn XAllocIconSize () -> *mut XIconSize, + pub fn XAllocNamedColor (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: *mut XColor, _1: *mut XColor) -> c_int, + pub fn XAllocSizeHints () -> *mut XSizeHints, + pub fn XAllocStandardColormap () -> *mut XStandardColormap, + pub fn XAllocWMHints () -> *mut XWMHints, + pub fn XAllowEvents (_3: *mut Display, _2: c_int, _1: c_ulong) -> c_int, + pub fn XAllPlanes () -> c_ulong, + pub fn XAutoRepeatOff (_1: *mut Display) -> c_int, + pub fn XAutoRepeatOn (_1: *mut Display) -> c_int, + pub fn XBaseFontNameListOfFontSet (_1: XFontSet) -> *mut c_char, + pub fn XBell (_2: *mut Display, _1: c_int) -> c_int, + pub fn XBitmapBitOrder (_1: *mut Display) -> c_int, + pub fn XBitmapPad (_1: *mut Display) -> c_int, + pub fn XBitmapUnit (_1: *mut Display) -> c_int, + pub fn XBlackPixel (_2: *mut Display, _1: c_int) -> c_ulong, + pub fn XBlackPixelOfScreen (_1: *mut Screen) -> c_ulong, + pub fn XCellsOfScreen (_1: *mut Screen) -> c_int, + pub fn XChangeActivePointerGrab (_4: *mut Display, _3: c_uint, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XChangeGC (_4: *mut Display, _3: GC, _2: c_ulong, _1: *mut XGCValues) -> c_int, + pub fn XChangeKeyboardControl (_3: *mut Display, _2: c_ulong, _1: *mut XKeyboardControl) -> c_int, + pub fn XChangeKeyboardMapping (_5: *mut Display, _4: c_int, _3: c_int, _2: *mut c_ulong, _1: c_int) -> c_int, + pub fn XChangePointerControl (_6: *mut Display, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> c_int, + pub fn XChangeProperty (_8: *mut Display, _7: c_ulong, _6: c_ulong, _5: c_ulong, _4: c_int, _3: c_int, _2: *const c_uchar, _1: c_int) -> c_int, + pub fn XChangeSaveSet (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int, + pub fn XChangeWindowAttributes (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: *mut XSetWindowAttributes) -> c_int, + pub fn XCheckIfEvent (_4: *mut Display, _3: *mut XEvent, _2: Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut c_char) -> c_int>, _1: *mut c_char) -> c_int, + pub fn XCheckMaskEvent (_3: *mut Display, _2: c_long, _1: *mut XEvent) -> c_int, + pub fn XCheckTypedEvent (_3: *mut Display, _2: c_int, _1: *mut XEvent) -> c_int, + pub fn XCheckTypedWindowEvent (_4: *mut Display, _3: c_ulong, _2: c_int, _1: *mut XEvent) -> c_int, + pub fn XCheckWindowEvent (_4: *mut Display, _3: c_ulong, _2: c_long, _1: *mut XEvent) -> c_int, + pub fn XCirculateSubwindows (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int, + pub fn XCirculateSubwindowsDown (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XCirculateSubwindowsUp (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XClearArea (_7: *mut Display, _6: c_ulong, _5: c_int, _4: c_int, _3: c_uint, _2: c_uint, _1: c_int) -> c_int, + pub fn XClearWindow (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XClipBox (_2: Region, _1: *mut XRectangle) -> c_int, + pub fn XCloseDisplay (_1: *mut Display) -> c_int, + pub fn XCloseIM (_1: XIM) -> c_int, + pub fn XCloseOM (_1: XOM) -> c_int, + pub fn XcmsAddColorSpace (_1: *mut XcmsColorSpace) -> c_int, + pub fn XcmsAddFunctionSet (_1: *mut XcmsFunctionSet) -> c_int, + pub fn XcmsAllocColor (_4: *mut Display, _3: c_ulong, _2: *mut XcmsColor, _1: c_ulong) -> c_int, + pub fn XcmsAllocNamedColor (_6: *mut Display, _5: c_ulong, _4: *const c_char, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_ulong) -> c_int, + pub fn XcmsCCCOfColormap (_2: *mut Display, _1: c_ulong) -> XcmsCCC, + pub fn XcmsCIELabClipab (_5: XcmsCCC, _4: *mut XcmsColor, _3: c_uint, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsCIELabClipL (_5: XcmsCCC, _4: *mut XcmsColor, _3: c_uint, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsCIELabClipLab (_5: XcmsCCC, _4: *mut XcmsColor, _3: c_uint, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsCIELabQueryMaxC (_4: XcmsCCC, _3: c_double, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsCIELabQueryMaxL (_4: XcmsCCC, _3: c_double, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsCIELabQueryMaxLC (_3: XcmsCCC, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsCIELabQueryMinL (_4: XcmsCCC, _3: c_double, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsCIELabToCIEXYZ (_4: XcmsCCC, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsCIELabWhiteShiftColors (_7: XcmsCCC, _6: *mut XcmsColor, _5: *mut XcmsColor, _4: c_ulong, _3: *mut XcmsColor, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsCIELuvClipL (_5: XcmsCCC, _4: *mut XcmsColor, _3: c_uint, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsCIELuvClipLuv (_5: XcmsCCC, _4: *mut XcmsColor, _3: c_uint, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsCIELuvClipuv (_5: XcmsCCC, _4: *mut XcmsColor, _3: c_uint, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsCIELuvQueryMaxC (_4: XcmsCCC, _3: c_double, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsCIELuvQueryMaxL (_4: XcmsCCC, _3: c_double, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsCIELuvQueryMaxLC (_3: XcmsCCC, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsCIELuvQueryMinL (_4: XcmsCCC, _3: c_double, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsCIELuvToCIEuvY (_4: XcmsCCC, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsCIELuvWhiteShiftColors (_7: XcmsCCC, _6: *mut XcmsColor, _5: *mut XcmsColor, _4: c_ulong, _3: *mut XcmsColor, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsCIEuvYToCIELuv (_4: XcmsCCC, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsCIEuvYToCIEXYZ (_4: XcmsCCC, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsCIEuvYToTekHVC (_4: XcmsCCC, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsCIExyYToCIEXYZ (_4: XcmsCCC, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsCIEXYZToCIELab (_4: XcmsCCC, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsCIEXYZToCIEuvY (_4: XcmsCCC, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsCIEXYZToCIExyY (_4: XcmsCCC, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsCIEXYZToRGBi (_4: XcmsCCC, _3: *mut XcmsColor, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsClientWhitePointOfCCC (_1: XcmsCCC) -> *mut XcmsColor, + pub fn XcmsConvertColors (_5: XcmsCCC, _4: *mut XcmsColor, _3: c_uint, _2: c_ulong, _1: *mut c_int) -> c_int, + pub fn XcmsCreateCCC (_8: *mut Display, _7: c_int, _6: *mut Visual, _5: *mut XcmsColor, _4: Option<unsafe extern "C" fn (XcmsCCC, *mut XcmsColor, c_uint, c_uint, *mut c_int) -> c_int>, _3: *mut c_char, _2: Option<unsafe extern "C" fn (XcmsCCC, *mut XcmsColor, *mut XcmsColor, c_ulong, *mut XcmsColor, c_uint, *mut c_int) -> c_int>, _1: *mut c_char) -> XcmsCCC, + pub fn XcmsDefaultCCC (_2: *mut Display, _1: c_int) -> XcmsCCC, + pub fn XcmsDisplayOfCCC (_1: XcmsCCC) -> *mut Display, + pub fn XcmsFormatOfPrefix (_1: *mut c_char) -> c_ulong, + pub fn XcmsFreeCCC (_1: XcmsCCC) -> (), + pub fn XcmsLookupColor (_6: *mut Display, _5: c_ulong, _4: *const c_char, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_ulong) -> c_int, + pub fn XcmsPrefixOfFormat (_1: c_ulong) -> *mut c_char, + pub fn XcmsQueryBlack (_3: XcmsCCC, _2: c_ulong, _1: *mut XcmsColor) -> c_int, + pub fn XcmsQueryBlue (_3: XcmsCCC, _2: c_ulong, _1: *mut XcmsColor) -> c_int, + pub fn XcmsQueryColor (_4: *mut Display, _3: c_ulong, _2: *mut XcmsColor, _1: c_ulong) -> c_int, + pub fn XcmsQueryColors (_5: *mut Display, _4: c_ulong, _3: *mut XcmsColor, _2: c_uint, _1: c_ulong) -> c_int, + pub fn XcmsQueryGreen (_3: XcmsCCC, _2: c_ulong, _1: *mut XcmsColor) -> c_int, + pub fn XcmsQueryRed (_3: XcmsCCC, _2: c_ulong, _1: *mut XcmsColor) -> c_int, + pub fn XcmsQueryWhite (_3: XcmsCCC, _2: c_ulong, _1: *mut XcmsColor) -> c_int, + pub fn XcmsRGBiToCIEXYZ (_4: XcmsCCC, _3: *mut XcmsColor, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsRGBiToRGB (_4: XcmsCCC, _3: *mut XcmsColor, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsRGBToRGBi (_4: XcmsCCC, _3: *mut XcmsColor, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsScreenNumberOfCCC (_1: XcmsCCC) -> c_int, + pub fn XcmsScreenWhitePointOfCCC (_1: XcmsCCC) -> *mut XcmsColor, + pub fn XcmsSetCCCOfColormap (_3: *mut Display, _2: c_ulong, _1: XcmsCCC) -> XcmsCCC, + pub fn XcmsSetCompressionProc (_3: XcmsCCC, _2: Option<unsafe extern "C" fn (XcmsCCC, *mut XcmsColor, c_uint, c_uint, *mut c_int) -> c_int>, _1: *mut c_char) -> Option<unsafe extern "C" fn (XcmsCCC, *mut XcmsColor, c_uint, c_uint, *mut c_int) -> c_int>, + pub fn XcmsSetWhiteAdjustProc (_3: XcmsCCC, _2: Option<unsafe extern "C" fn (XcmsCCC, *mut XcmsColor, *mut XcmsColor, c_ulong, *mut XcmsColor, c_uint, *mut c_int) -> c_int>, _1: *mut c_char) -> Option<unsafe extern "C" fn (XcmsCCC, *mut XcmsColor, *mut XcmsColor, c_ulong, *mut XcmsColor, c_uint, *mut c_int) -> c_int>, + pub fn XcmsSetWhitePoint (_2: XcmsCCC, _1: *mut XcmsColor) -> c_int, + pub fn XcmsStoreColor (_3: *mut Display, _2: c_ulong, _1: *mut XcmsColor) -> c_int, + pub fn XcmsStoreColors (_5: *mut Display, _4: c_ulong, _3: *mut XcmsColor, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsTekHVCClipC (_5: XcmsCCC, _4: *mut XcmsColor, _3: c_uint, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsTekHVCClipV (_5: XcmsCCC, _4: *mut XcmsColor, _3: c_uint, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsTekHVCClipVC (_5: XcmsCCC, _4: *mut XcmsColor, _3: c_uint, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsTekHVCQueryMaxC (_4: XcmsCCC, _3: c_double, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsTekHVCQueryMaxV (_4: XcmsCCC, _3: c_double, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsTekHVCQueryMaxVC (_3: XcmsCCC, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsTekHVCQueryMaxVSamples (_4: XcmsCCC, _3: c_double, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsTekHVCQueryMinV (_4: XcmsCCC, _3: c_double, _2: c_double, _1: *mut XcmsColor) -> c_int, + pub fn XcmsTekHVCToCIEuvY (_4: XcmsCCC, _3: *mut XcmsColor, _2: *mut XcmsColor, _1: c_uint) -> c_int, + pub fn XcmsTekHVCWhiteShiftColors (_7: XcmsCCC, _6: *mut XcmsColor, _5: *mut XcmsColor, _4: c_ulong, _3: *mut XcmsColor, _2: c_uint, _1: *mut c_int) -> c_int, + pub fn XcmsVisualOfCCC (_1: XcmsCCC) -> *mut Visual, + pub fn XConfigureWindow (_4: *mut Display, _3: c_ulong, _2: c_uint, _1: *mut XWindowChanges) -> c_int, + pub fn XConnectionNumber (_1: *mut Display) -> c_int, + pub fn XContextDependentDrawing (_1: XFontSet) -> c_int, + pub fn XContextualDrawing (_1: XFontSet) -> c_int, + pub fn XConvertCase (_3: c_ulong, _2: *mut c_ulong, _1: *mut c_ulong) -> (), + pub fn XConvertSelection (_6: *mut Display, _5: c_ulong, _4: c_ulong, _3: c_ulong, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XCopyArea (_10: *mut Display, _9: c_ulong, _8: c_ulong, _7: GC, _6: c_int, _5: c_int, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int, + pub fn XCopyColormapAndFree (_2: *mut Display, _1: c_ulong) -> c_ulong, + pub fn XCopyGC (_4: *mut Display, _3: GC, _2: c_ulong, _1: GC) -> c_int, + pub fn XCopyPlane (_11: *mut Display, _10: c_ulong, _9: c_ulong, _8: GC, _7: c_int, _6: c_int, _5: c_uint, _4: c_uint, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XCreateBitmapFromData (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: c_uint, _1: c_uint) -> c_ulong, + pub fn XCreateColormap (_4: *mut Display, _3: c_ulong, _2: *mut Visual, _1: c_int) -> c_ulong, + pub fn XCreateFontCursor (_2: *mut Display, _1: c_uint) -> c_ulong, + pub fn XCreateFontSet (_5: *mut Display, _4: *const c_char, _3: *mut *mut *mut c_char, _2: *mut c_int, _1: *mut *mut c_char) -> XFontSet, + pub fn XCreateGC (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: *mut XGCValues) -> GC, + pub fn XCreateGlyphCursor (_7: *mut Display, _6: c_ulong, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *const XColor, _1: *const XColor) -> c_ulong, + pub fn XCreateImage (_10: *mut Display, _9: *mut Visual, _8: c_uint, _7: c_int, _6: c_int, _5: *mut c_char, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> *mut XImage, + pub fn XCreatePixmap (_5: *mut Display, _4: c_ulong, _3: c_uint, _2: c_uint, _1: c_uint) -> c_ulong, + pub fn XCreatePixmapCursor (_7: *mut Display, _6: c_ulong, _5: c_ulong, _4: *mut XColor, _3: *mut XColor, _2: c_uint, _1: c_uint) -> c_ulong, + pub fn XCreatePixmapFromBitmapData (_8: *mut Display, _7: c_ulong, _6: *mut c_char, _5: c_uint, _4: c_uint, _3: c_ulong, _2: c_ulong, _1: c_uint) -> c_ulong, + pub fn XCreateRegion () -> Region, + pub fn XCreateSimpleWindow (_9: *mut Display, _8: c_ulong, _7: c_int, _6: c_int, _5: c_uint, _4: c_uint, _3: c_uint, _2: c_ulong, _1: c_ulong) -> c_ulong, + pub fn XCreateWindow (_12: *mut Display, _11: c_ulong, _10: c_int, _9: c_int, _8: c_uint, _7: c_uint, _6: c_uint, _5: c_int, _4: c_uint, _3: *mut Visual, _2: c_ulong, _1: *mut XSetWindowAttributes) -> c_ulong, + pub fn XDefaultColormap (_2: *mut Display, _1: c_int) -> c_ulong, + pub fn XDefaultColormapOfScreen (_1: *mut Screen) -> c_ulong, + pub fn XDefaultDepth (_2: *mut Display, _1: c_int) -> c_int, + pub fn XDefaultDepthOfScreen (_1: *mut Screen) -> c_int, + pub fn XDefaultGC (_2: *mut Display, _1: c_int) -> GC, + pub fn XDefaultGCOfScreen (_1: *mut Screen) -> GC, + pub fn XDefaultRootWindow (_1: *mut Display) -> c_ulong, + pub fn XDefaultScreen (_1: *mut Display) -> c_int, + pub fn XDefaultScreenOfDisplay (_1: *mut Display) -> *mut Screen, + pub fn XDefaultString () -> *const c_char, + pub fn XDefaultVisual (_2: *mut Display, _1: c_int) -> *mut Visual, + pub fn XDefaultVisualOfScreen (_1: *mut Screen) -> *mut Visual, + pub fn XDefineCursor (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XDeleteContext (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int, + pub fn XDeleteModifiermapEntry (_3: *mut XModifierKeymap, _2: c_uchar, _1: c_int) -> *mut XModifierKeymap, + pub fn XDeleteProperty (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XDestroyIC (_1: XIC) -> (), + pub fn XDestroyImage (_1: *mut XImage) -> c_int, + pub fn XDestroyOC (_1: XFontSet) -> (), + pub fn XDestroyRegion (_1: Region) -> c_int, + pub fn XDestroySubwindows (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XDestroyWindow (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XDirectionalDependentDrawing (_1: XFontSet) -> c_int, + pub fn XDisableAccessControl (_1: *mut Display) -> c_int, + pub fn XDisplayCells (_2: *mut Display, _1: c_int) -> c_int, + pub fn XDisplayHeight (_2: *mut Display, _1: c_int) -> c_int, + pub fn XDisplayHeightMM (_2: *mut Display, _1: c_int) -> c_int, + pub fn XDisplayKeycodes (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XDisplayMotionBufferSize (_1: *mut Display) -> c_ulong, + pub fn XDisplayName (_1: *const c_char) -> *mut c_char, + pub fn XDisplayOfIM (_1: XIM) -> *mut Display, + pub fn XDisplayOfOM (_1: XOM) -> *mut Display, + pub fn XDisplayOfScreen (_1: *mut Screen) -> *mut Display, + pub fn XDisplayPlanes (_2: *mut Display, _1: c_int) -> c_int, + pub fn XDisplayString (_1: *mut Display) -> *mut c_char, + pub fn XDisplayWidth (_2: *mut Display, _1: c_int) -> c_int, + pub fn XDisplayWidthMM (_2: *mut Display, _1: c_int) -> c_int, + pub fn XDoesBackingStore (_1: *mut Screen) -> c_int, + pub fn XDoesSaveUnders (_1: *mut Screen) -> c_int, + pub fn XDrawArc (_9: *mut Display, _8: c_ulong, _7: GC, _6: c_int, _5: c_int, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int, + pub fn XDrawArcs (_5: *mut Display, _4: c_ulong, _3: GC, _2: *mut XArc, _1: c_int) -> c_int, + pub fn XDrawImageString (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> c_int, + pub fn XDrawImageString16 (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *const XChar2b, _1: c_int) -> c_int, + pub fn XDrawLine (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> c_int, + pub fn XDrawLines (_6: *mut Display, _5: c_ulong, _4: GC, _3: *mut XPoint, _2: c_int, _1: c_int) -> c_int, + pub fn XDrawPoint (_5: *mut Display, _4: c_ulong, _3: GC, _2: c_int, _1: c_int) -> c_int, + pub fn XDrawPoints (_6: *mut Display, _5: c_ulong, _4: GC, _3: *mut XPoint, _2: c_int, _1: c_int) -> c_int, + pub fn XDrawRectangle (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> c_int, + pub fn XDrawRectangles (_5: *mut Display, _4: c_ulong, _3: GC, _2: *mut XRectangle, _1: c_int) -> c_int, + pub fn XDrawSegments (_5: *mut Display, _4: c_ulong, _3: GC, _2: *mut XSegment, _1: c_int) -> c_int, + pub fn XDrawString (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> c_int, + pub fn XDrawString16 (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *const XChar2b, _1: c_int) -> c_int, + pub fn XDrawText (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *mut XTextItem, _1: c_int) -> c_int, + pub fn XDrawText16 (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *mut XTextItem16, _1: c_int) -> c_int, + pub fn XEHeadOfExtensionList (_1: XEDataObject) -> *mut *mut XExtData, + pub fn XEmptyRegion (_1: Region) -> c_int, + pub fn XEnableAccessControl (_1: *mut Display) -> c_int, + pub fn XEqualRegion (_2: Region, _1: Region) -> c_int, + pub fn XESetBeforeFlush (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XExtCodes, *const c_char, c_long)>) -> Option<unsafe extern "C" fn (*mut Display, *mut XExtCodes, *const c_char, c_long)>, + pub fn XESetCloseDisplay (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XExtCodes) -> c_int>, + pub fn XESetCopyEventCookie (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XGenericEventCookie, *mut XGenericEventCookie) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XGenericEventCookie, *mut XGenericEventCookie) -> c_int>, + pub fn XESetCopyGC (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>, + pub fn XESetCreateFont (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XFontStruct, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XFontStruct, *mut XExtCodes) -> c_int>, + pub fn XESetCreateGC (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>, + pub fn XESetError (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut xError, *mut XExtCodes, *mut c_int) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut xError, *mut XExtCodes, *mut c_int) -> c_int>, + pub fn XESetErrorString (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, c_int, *mut XExtCodes, *mut c_char, c_int) -> *mut c_char>) -> Option<unsafe extern "C" fn (*mut Display, c_int, *mut XExtCodes, *mut c_char, c_int) -> *mut c_char>, + pub fn XESetEventToWire (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut xEvent) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut xEvent) -> c_int>, + pub fn XESetFlushGC (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>, + pub fn XESetFreeFont (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XFontStruct, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XFontStruct, *mut XExtCodes) -> c_int>, + pub fn XESetFreeGC (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>, + pub fn XESetPrintErrorValues (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent, *mut c_void)>) -> Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent, *mut c_void)>, + pub fn XESetWireToError (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent, *mut xError) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent, *mut xError) -> c_int>, + pub fn XESetWireToEvent (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut xEvent) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut xEvent) -> c_int>, + pub fn XESetWireToEventCookie (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XGenericEventCookie, *mut xEvent) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XGenericEventCookie, *mut xEvent) -> c_int>, + pub fn XEventMaskOfScreen (_1: *mut Screen) -> c_long, + pub fn XEventsQueued (_2: *mut Display, _1: c_int) -> c_int, + pub fn XExtendedMaxRequestSize (_1: *mut Display) -> c_long, + pub fn XExtentsOfFontSet (_1: XFontSet) -> *mut XFontSetExtents, + pub fn XFetchBuffer (_3: *mut Display, _2: *mut c_int, _1: c_int) -> *mut c_char, + pub fn XFetchBytes (_2: *mut Display, _1: *mut c_int) -> *mut c_char, + pub fn XFetchName (_3: *mut Display, _2: c_ulong, _1: *mut *mut c_char) -> c_int, + pub fn XFillArc (_9: *mut Display, _8: c_ulong, _7: GC, _6: c_int, _5: c_int, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int, + pub fn XFillArcs (_5: *mut Display, _4: c_ulong, _3: GC, _2: *mut XArc, _1: c_int) -> c_int, + pub fn XFillPolygon (_7: *mut Display, _6: c_ulong, _5: GC, _4: *mut XPoint, _3: c_int, _2: c_int, _1: c_int) -> c_int, + pub fn XFillRectangle (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> c_int, + pub fn XFillRectangles (_5: *mut Display, _4: c_ulong, _3: GC, _2: *mut XRectangle, _1: c_int) -> c_int, + pub fn XFilterEvent (_2: *mut XEvent, _1: c_ulong) -> c_int, + pub fn XFindContext (_4: *mut Display, _3: c_ulong, _2: c_int, _1: *mut *mut c_char) -> c_int, + pub fn XFindOnExtensionList (_2: *mut *mut XExtData, _1: c_int) -> *mut XExtData, + pub fn XFlush (_1: *mut Display) -> c_int, + pub fn XFlushGC (_2: *mut Display, _1: GC) -> (), + pub fn XFontsOfFontSet (_3: XFontSet, _2: *mut *mut *mut XFontStruct, _1: *mut *mut *mut c_char) -> c_int, + pub fn XForceScreenSaver (_2: *mut Display, _1: c_int) -> c_int, + pub fn XFree (_1: *mut c_void) -> c_int, + pub fn XFreeColormap (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XFreeColors (_5: *mut Display, _4: c_ulong, _3: *mut c_ulong, _2: c_int, _1: c_ulong) -> c_int, + pub fn XFreeCursor (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XFreeEventData (_2: *mut Display, _1: *mut XGenericEventCookie) -> (), + pub fn XFreeExtensionList (_1: *mut *mut c_char) -> c_int, + pub fn XFreeFont (_2: *mut Display, _1: *mut XFontStruct) -> c_int, + pub fn XFreeFontInfo (_3: *mut *mut c_char, _2: *mut XFontStruct, _1: c_int) -> c_int, + pub fn XFreeFontNames (_1: *mut *mut c_char) -> c_int, + pub fn XFreeFontPath (_1: *mut *mut c_char) -> c_int, + pub fn XFreeFontSet (_2: *mut Display, _1: XFontSet) -> (), + pub fn XFreeGC (_2: *mut Display, _1: GC) -> c_int, + pub fn XFreeModifiermap (_1: *mut XModifierKeymap) -> c_int, + pub fn XFreePixmap (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XFreeStringList (_1: *mut *mut c_char) -> (), + pub fn XGContextFromGC (_1: GC) -> c_ulong, + pub fn XGeometry (_13: *mut Display, _12: c_int, _11: *const c_char, _10: *const c_char, _9: c_uint, _8: c_uint, _7: c_uint, _6: c_int, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XGetAtomName (_2: *mut Display, _1: c_ulong) -> *mut c_char, + pub fn XGetAtomNames (_4: *mut Display, _3: *mut c_ulong, _2: c_int, _1: *mut *mut c_char) -> c_int, + pub fn XGetClassHint (_3: *mut Display, _2: c_ulong, _1: *mut XClassHint) -> c_int, + pub fn XGetCommand (_4: *mut Display, _3: c_ulong, _2: *mut *mut *mut c_char, _1: *mut c_int) -> c_int, + pub fn XGetDefault (_3: *mut Display, _2: *const c_char, _1: *const c_char) -> *mut c_char, + pub fn XGetErrorDatabaseText (_6: *mut Display, _5: *const c_char, _4: *const c_char, _3: *const c_char, _2: *mut c_char, _1: c_int) -> c_int, + pub fn XGetErrorText (_4: *mut Display, _3: c_int, _2: *mut c_char, _1: c_int) -> c_int, + pub fn XGetEventData (_2: *mut Display, _1: *mut XGenericEventCookie) -> c_int, + pub fn XGetFontPath (_2: *mut Display, _1: *mut c_int) -> *mut *mut c_char, + pub fn XGetFontProperty (_3: *mut XFontStruct, _2: c_ulong, _1: *mut c_ulong) -> c_int, + pub fn XGetGCValues (_4: *mut Display, _3: GC, _2: c_ulong, _1: *mut XGCValues) -> c_int, + pub fn XGetGeometry (_9: *mut Display, _8: c_ulong, _7: *mut c_ulong, _6: *mut c_int, _5: *mut c_int, _4: *mut c_uint, _3: *mut c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int, + pub fn XGetIconName (_3: *mut Display, _2: c_ulong, _1: *mut *mut c_char) -> c_int, + pub fn XGetIconSizes (_4: *mut Display, _3: c_ulong, _2: *mut *mut XIconSize, _1: *mut c_int) -> c_int, + pub fn XGetImage (_8: *mut Display, _7: c_ulong, _6: c_int, _5: c_int, _4: c_uint, _3: c_uint, _2: c_ulong, _1: c_int) -> *mut XImage, + pub fn XGetInputFocus (_3: *mut Display, _2: *mut c_ulong, _1: *mut c_int) -> c_int, + pub fn XGetKeyboardControl (_2: *mut Display, _1: *mut XKeyboardState) -> c_int, + pub fn XGetKeyboardMapping (_4: *mut Display, _3: c_uchar, _2: c_int, _1: *mut c_int) -> *mut c_ulong, + pub fn XGetModifierMapping (_1: *mut Display) -> *mut XModifierKeymap, + pub fn XGetMotionEvents (_5: *mut Display, _4: c_ulong, _3: c_ulong, _2: c_ulong, _1: *mut c_int) -> *mut XTimeCoord, + pub fn XGetNormalHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> c_int, + pub fn XGetPixel (_3: *mut XImage, _2: c_int, _1: c_int) -> c_ulong, + pub fn XGetPointerControl (_4: *mut Display, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XGetPointerMapping (_3: *mut Display, _2: *mut c_uchar, _1: c_int) -> c_int, + pub fn XGetRGBColormaps (_5: *mut Display, _4: c_ulong, _3: *mut *mut XStandardColormap, _2: *mut c_int, _1: c_ulong) -> c_int, + pub fn XGetScreenSaver (_5: *mut Display, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XGetSelectionOwner (_2: *mut Display, _1: c_ulong) -> c_ulong, + pub fn XGetSizeHints (_4: *mut Display, _3: c_ulong, _2: *mut XSizeHints, _1: c_ulong) -> c_int, + pub fn XGetStandardColormap (_4: *mut Display, _3: c_ulong, _2: *mut XStandardColormap, _1: c_ulong) -> c_int, + pub fn XGetSubImage (_11: *mut Display, _10: c_ulong, _9: c_int, _8: c_int, _7: c_uint, _6: c_uint, _5: c_ulong, _4: c_int, _3: *mut XImage, _2: c_int, _1: c_int) -> *mut XImage, + pub fn XGetTextProperty (_4: *mut Display, _3: c_ulong, _2: *mut XTextProperty, _1: c_ulong) -> c_int, + pub fn XGetTransientForHint (_3: *mut Display, _2: c_ulong, _1: *mut c_ulong) -> c_int, + pub fn XGetVisualInfo (_4: *mut Display, _3: c_long, _2: *mut XVisualInfo, _1: *mut c_int) -> *mut XVisualInfo, + pub fn XGetWindowAttributes (_3: *mut Display, _2: c_ulong, _1: *mut XWindowAttributes) -> c_int, + pub fn XGetWindowProperty (_12: *mut Display, _11: c_ulong, _10: c_ulong, _9: c_long, _8: c_long, _7: c_int, _6: c_ulong, _5: *mut c_ulong, _4: *mut c_int, _3: *mut c_ulong, _2: *mut c_ulong, _1: *mut *mut c_uchar) -> c_int, + pub fn XGetWMClientMachine (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty) -> c_int, + pub fn XGetWMColormapWindows (_4: *mut Display, _3: c_ulong, _2: *mut *mut c_ulong, _1: *mut c_int) -> c_int, + pub fn XGetWMHints (_2: *mut Display, _1: c_ulong) -> *mut XWMHints, + pub fn XGetWMIconName (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty) -> c_int, + pub fn XGetWMName (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty) -> c_int, + pub fn XGetWMNormalHints (_4: *mut Display, _3: c_ulong, _2: *mut XSizeHints, _1: *mut c_long) -> c_int, + pub fn XGetWMProtocols (_4: *mut Display, _3: c_ulong, _2: *mut *mut c_ulong, _1: *mut c_int) -> c_int, + pub fn XGetWMSizeHints (_5: *mut Display, _4: c_ulong, _3: *mut XSizeHints, _2: *mut c_long, _1: c_ulong) -> c_int, + pub fn XGetZoomHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> c_int, + pub fn XGrabButton (_10: *mut Display, _9: c_uint, _8: c_uint, _7: c_ulong, _6: c_int, _5: c_uint, _4: c_int, _3: c_int, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XGrabKey (_7: *mut Display, _6: c_int, _5: c_uint, _4: c_ulong, _3: c_int, _2: c_int, _1: c_int) -> c_int, + pub fn XGrabKeyboard (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XGrabPointer (_9: *mut Display, _8: c_ulong, _7: c_int, _6: c_uint, _5: c_int, _4: c_int, _3: c_ulong, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XGrabServer (_1: *mut Display) -> c_int, + pub fn XHeightMMOfScreen (_1: *mut Screen) -> c_int, + pub fn XHeightOfScreen (_1: *mut Screen) -> c_int, + pub fn XIconifyWindow (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int, + pub fn XIfEvent (_4: *mut Display, _3: *mut XEvent, _2: Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut c_char) -> c_int>, _1: *mut c_char) -> c_int, + pub fn XImageByteOrder (_1: *mut Display) -> c_int, + pub fn XIMOfIC (_1: XIC) -> XIM, + pub fn XInitExtension (_2: *mut Display, _1: *const c_char) -> *mut XExtCodes, + pub fn XInitImage (_1: *mut XImage) -> c_int, + pub fn XInitThreads () -> c_int, + pub fn XInsertModifiermapEntry (_3: *mut XModifierKeymap, _2: c_uchar, _1: c_int) -> *mut XModifierKeymap, + pub fn XInstallColormap (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XInternalConnectionNumbers (_3: *mut Display, _2: *mut *mut c_int, _1: *mut c_int) -> c_int, + pub fn XInternAtom (_3: *mut Display, _2: *const c_char, _1: c_int) -> c_ulong, + pub fn XInternAtoms (_5: *mut Display, _4: *mut *mut c_char, _3: c_int, _2: c_int, _1: *mut c_ulong) -> c_int, + pub fn XIntersectRegion (_3: Region, _2: Region, _1: Region) -> c_int, + pub fn XkbAddDeviceLedInfo (_3: XkbDeviceInfoPtr, _2: c_uint, _1: c_uint) -> XkbDeviceLedInfoPtr, + pub fn XkbAddGeomColor (_3: XkbGeometryPtr, _2: *mut c_char, _1: c_uint) -> XkbColorPtr, + pub fn XkbAddGeomDoodad (_3: XkbGeometryPtr, _2: XkbSectionPtr, _1: c_ulong) -> XkbDoodadPtr, + pub fn XkbAddGeomKey (_1: XkbRowPtr) -> XkbKeyPtr, + pub fn XkbAddGeomKeyAlias (_3: XkbGeometryPtr, _2: *mut c_char, _1: *mut c_char) -> XkbKeyAliasPtr, + pub fn XkbAddGeomOutline (_2: XkbShapePtr, _1: c_int) -> XkbOutlinePtr, + pub fn XkbAddGeomOverlay (_3: XkbSectionPtr, _2: c_ulong, _1: c_int) -> XkbOverlayPtr, + pub fn XkbAddGeomOverlayKey (_4: XkbOverlayPtr, _3: XkbOverlayRowPtr, _2: *mut c_char, _1: *mut c_char) -> XkbOverlayKeyPtr, + pub fn XkbAddGeomOverlayRow (_3: XkbOverlayPtr, _2: c_int, _1: c_int) -> XkbOverlayRowPtr, + pub fn XkbAddGeomProperty (_3: XkbGeometryPtr, _2: *mut c_char, _1: *mut c_char) -> XkbPropertyPtr, + pub fn XkbAddGeomRow (_2: XkbSectionPtr, _1: c_int) -> XkbRowPtr, + pub fn XkbAddGeomSection (_5: XkbGeometryPtr, _4: c_ulong, _3: c_int, _2: c_int, _1: c_int) -> XkbSectionPtr, + pub fn XkbAddGeomShape (_3: XkbGeometryPtr, _2: c_ulong, _1: c_int) -> XkbShapePtr, + pub fn XkbAddKeyType (_5: XkbDescPtr, _4: c_ulong, _3: c_int, _2: c_int, _1: c_int) -> XkbKeyTypePtr, + pub fn XkbAllocClientMap (_3: XkbDescPtr, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbAllocCompatMap (_3: XkbDescPtr, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbAllocControls (_2: XkbDescPtr, _1: c_uint) -> c_int, + pub fn XkbAllocDeviceInfo (_3: c_uint, _2: c_uint, _1: c_uint) -> XkbDeviceInfoPtr, + pub fn XkbAllocGeomColors (_2: XkbGeometryPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomDoodads (_2: XkbGeometryPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeometry (_2: XkbDescPtr, _1: XkbGeometrySizesPtr) -> c_int, + pub fn XkbAllocGeomKeyAliases (_2: XkbGeometryPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomKeys (_2: XkbRowPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomOutlines (_2: XkbShapePtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomOverlayKeys (_2: XkbOverlayRowPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomOverlayRows (_2: XkbOverlayPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomOverlays (_2: XkbSectionPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomPoints (_2: XkbOutlinePtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomProps (_2: XkbGeometryPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomRows (_2: XkbSectionPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomSectionDoodads (_2: XkbSectionPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomSections (_2: XkbGeometryPtr, _1: c_int) -> c_int, + pub fn XkbAllocGeomShapes (_2: XkbGeometryPtr, _1: c_int) -> c_int, + pub fn XkbAllocIndicatorMaps (_1: XkbDescPtr) -> c_int, + pub fn XkbAllocKeyboard () -> XkbDescPtr, + pub fn XkbAllocNames (_4: XkbDescPtr, _3: c_uint, _2: c_int, _1: c_int) -> c_int, + pub fn XkbAllocServerMap (_3: XkbDescPtr, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbApplyCompatMapToKey (_3: XkbDescPtr, _2: c_uchar, _1: XkbChangesPtr) -> c_int, + pub fn XkbApplyVirtualModChanges (_3: XkbDescPtr, _2: c_uint, _1: XkbChangesPtr) -> c_int, + pub fn XkbBell (_4: *mut Display, _3: c_ulong, _2: c_int, _1: c_ulong) -> c_int, + pub fn XkbBellEvent (_4: *mut Display, _3: c_ulong, _2: c_int, _1: c_ulong) -> c_int, + pub fn XkbChangeDeviceInfo (_3: *mut Display, _2: XkbDeviceInfoPtr, _1: XkbDeviceChangesPtr) -> c_int, + pub fn XkbChangeEnabledControls (_4: *mut Display, _3: c_uint, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbChangeKeycodeRange (_4: XkbDescPtr, _3: c_int, _2: c_int, _1: XkbChangesPtr) -> c_int, + pub fn XkbChangeMap (_3: *mut Display, _2: XkbDescPtr, _1: XkbMapChangesPtr) -> c_int, + pub fn XkbChangeNames (_3: *mut Display, _2: XkbDescPtr, _1: XkbNameChangesPtr) -> c_int, + pub fn XkbChangeTypesOfKey (_6: XkbDescPtr, _5: c_int, _4: c_int, _3: c_uint, _2: *mut c_int, _1: XkbMapChangesPtr) -> c_int, + pub fn XkbComputeEffectiveMap (_3: XkbDescPtr, _2: XkbKeyTypePtr, _1: *mut c_uchar) -> c_int, + pub fn XkbComputeRowBounds (_3: XkbGeometryPtr, _2: XkbSectionPtr, _1: XkbRowPtr) -> c_int, + pub fn XkbComputeSectionBounds (_2: XkbGeometryPtr, _1: XkbSectionPtr) -> c_int, + pub fn XkbComputeShapeBounds (_1: XkbShapePtr) -> c_int, + pub fn XkbComputeShapeTop (_2: XkbShapePtr, _1: XkbBoundsPtr) -> c_int, + pub fn XkbCopyKeyType (_2: XkbKeyTypePtr, _1: XkbKeyTypePtr) -> c_int, + pub fn XkbCopyKeyTypes (_3: XkbKeyTypePtr, _2: XkbKeyTypePtr, _1: c_int) -> c_int, + pub fn XkbDeviceBell (_7: *mut Display, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XkbDeviceBellEvent (_7: *mut Display, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XkbFindOverlayForKey (_3: XkbGeometryPtr, _2: XkbSectionPtr, _1: *mut c_char) -> *mut c_char, + pub fn XkbForceBell (_2: *mut Display, _1: c_int) -> c_int, + pub fn XkbForceDeviceBell (_5: *mut Display, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> c_int, + pub fn XkbFreeClientMap (_3: XkbDescPtr, _2: c_uint, _1: c_int) -> (), + pub fn XkbFreeCompatMap (_3: XkbDescPtr, _2: c_uint, _1: c_int) -> (), + pub fn XkbFreeComponentList (_1: XkbComponentListPtr) -> (), + pub fn XkbFreeControls (_3: XkbDescPtr, _2: c_uint, _1: c_int) -> (), + pub fn XkbFreeDeviceInfo (_3: XkbDeviceInfoPtr, _2: c_uint, _1: c_int) -> (), + pub fn XkbFreeGeomColors (_4: XkbGeometryPtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomDoodads (_3: XkbDoodadPtr, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeometry (_3: XkbGeometryPtr, _2: c_uint, _1: c_int) -> (), + pub fn XkbFreeGeomKeyAliases (_4: XkbGeometryPtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomKeys (_4: XkbRowPtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomOutlines (_4: XkbShapePtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomOverlayKeys (_4: XkbOverlayRowPtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomOverlayRows (_4: XkbOverlayPtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomOverlays (_4: XkbSectionPtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomPoints (_4: XkbOutlinePtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomProperties (_4: XkbGeometryPtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomRows (_4: XkbSectionPtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomSections (_4: XkbGeometryPtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeGeomShapes (_4: XkbGeometryPtr, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XkbFreeIndicatorMaps (_1: XkbDescPtr) -> (), + pub fn XkbFreeKeyboard (_3: XkbDescPtr, _2: c_uint, _1: c_int) -> (), + pub fn XkbFreeNames (_3: XkbDescPtr, _2: c_uint, _1: c_int) -> (), + pub fn XkbFreeServerMap (_3: XkbDescPtr, _2: c_uint, _1: c_int) -> (), + pub fn XkbGetAutoRepeatRate (_4: *mut Display, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int, + pub fn XkbGetAutoResetControls (_3: *mut Display, _2: *mut c_uint, _1: *mut c_uint) -> c_int, + pub fn XkbGetCompatMap (_3: *mut Display, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetControls (_3: *mut Display, _2: c_ulong, _1: XkbDescPtr) -> c_int, + pub fn XkbGetDetectableAutoRepeat (_2: *mut Display, _1: *mut c_int) -> c_int, + pub fn XkbGetDeviceButtonActions (_5: *mut Display, _4: XkbDeviceInfoPtr, _3: c_int, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbGetDeviceInfo (_5: *mut Display, _4: c_uint, _3: c_uint, _2: c_uint, _1: c_uint) -> XkbDeviceInfoPtr, + pub fn XkbGetDeviceInfoChanges (_3: *mut Display, _2: XkbDeviceInfoPtr, _1: XkbDeviceChangesPtr) -> c_int, + pub fn XkbGetDeviceLedInfo (_5: *mut Display, _4: XkbDeviceInfoPtr, _3: c_uint, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbGetGeometry (_2: *mut Display, _1: XkbDescPtr) -> c_int, + pub fn XkbGetIndicatorMap (_3: *mut Display, _2: c_ulong, _1: XkbDescPtr) -> c_int, + pub fn XkbGetIndicatorState (_3: *mut Display, _2: c_uint, _1: *mut c_uint) -> c_int, + pub fn XkbGetKeyActions (_4: *mut Display, _3: c_uint, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetKeyBehaviors (_4: *mut Display, _3: c_uint, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetKeyboard (_3: *mut Display, _2: c_uint, _1: c_uint) -> XkbDescPtr, + pub fn XkbGetKeyboardByName (_6: *mut Display, _5: c_uint, _4: XkbComponentNamesPtr, _3: c_uint, _2: c_uint, _1: c_int) -> XkbDescPtr, + pub fn XkbGetKeyExplicitComponents (_4: *mut Display, _3: c_uint, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetKeyModifierMap (_4: *mut Display, _3: c_uint, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetKeySyms (_4: *mut Display, _3: c_uint, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetKeyTypes (_4: *mut Display, _3: c_uint, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetKeyVirtualModMap (_4: *mut Display, _3: c_uint, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetMap (_3: *mut Display, _2: c_uint, _1: c_uint) -> XkbDescPtr, + pub fn XkbGetMapChanges (_3: *mut Display, _2: XkbDescPtr, _1: XkbMapChangesPtr) -> c_int, + pub fn XkbGetNamedDeviceIndicator (_9: *mut Display, _8: c_uint, _7: c_uint, _6: c_uint, _5: c_ulong, _4: *mut c_int, _3: *mut c_int, _2: XkbIndicatorMapPtr, _1: *mut c_int) -> c_int, + pub fn XkbGetNamedGeometry (_3: *mut Display, _2: XkbDescPtr, _1: c_ulong) -> c_int, + pub fn XkbGetNamedIndicator (_6: *mut Display, _5: c_ulong, _4: *mut c_int, _3: *mut c_int, _2: XkbIndicatorMapPtr, _1: *mut c_int) -> c_int, + pub fn XkbGetNames (_3: *mut Display, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetPerClientControls (_2: *mut Display, _1: *mut c_uint) -> c_int, + pub fn XkbGetState (_3: *mut Display, _2: c_uint, _1: XkbStatePtr) -> c_int, + pub fn XkbGetUpdatedMap (_3: *mut Display, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetVirtualMods (_3: *mut Display, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbGetXlibControls (_1: *mut Display) -> c_uint, + pub fn XkbIgnoreExtension (_1: c_int) -> c_int, + pub fn XkbInitCanonicalKeyTypes (_3: XkbDescPtr, _2: c_uint, _1: c_int) -> c_int, + pub fn XkbKeycodeToKeysym (_4: *mut Display, _3: c_uchar, _2: c_int, _1: c_int) -> c_ulong, + pub fn XkbKeysymToModifiers (_2: *mut Display, _1: c_ulong) -> c_uint, + pub fn XkbKeyTypesForCoreSymbols (_6: XkbDescPtr, _5: c_int, _4: *mut c_ulong, _3: c_uint, _2: *mut c_int, _1: *mut c_ulong) -> c_int, + pub fn XkbLatchGroup (_3: *mut Display, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbLatchModifiers (_4: *mut Display, _3: c_uint, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbLibraryVersion (_2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XkbListComponents (_4: *mut Display, _3: c_uint, _2: XkbComponentNamesPtr, _1: *mut c_int) -> XkbComponentListPtr, + pub fn XkbLockGroup (_3: *mut Display, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbLockModifiers (_4: *mut Display, _3: c_uint, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbLookupKeyBinding (_6: *mut Display, _5: c_ulong, _4: c_uint, _3: *mut c_char, _2: c_int, _1: *mut c_int) -> c_int, + pub fn XkbLookupKeySym (_5: *mut Display, _4: c_uchar, _3: c_uint, _2: *mut c_uint, _1: *mut c_ulong) -> c_int, + pub fn XkbNoteControlsChanges (_3: XkbControlsChangesPtr, _2: *mut XkbControlsNotifyEvent, _1: c_uint) -> (), + pub fn XkbNoteDeviceChanges (_3: XkbDeviceChangesPtr, _2: *mut XkbExtensionDeviceNotifyEvent, _1: c_uint) -> (), + pub fn XkbNoteMapChanges (_3: XkbMapChangesPtr, _2: *mut XkbMapNotifyEvent, _1: c_uint) -> (), + pub fn XkbNoteNameChanges (_3: XkbNameChangesPtr, _2: *mut XkbNamesNotifyEvent, _1: c_uint) -> (), + pub fn XkbOpenDisplay (_6: *mut c_char, _5: *mut c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> *mut Display, + pub fn XkbQueryExtension (_6: *mut Display, _5: *mut c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XkbRefreshKeyboardMapping (_1: *mut XkbMapNotifyEvent) -> c_int, + pub fn XkbResizeDeviceButtonActions (_2: XkbDeviceInfoPtr, _1: c_uint) -> c_int, + pub fn XkbResizeKeyActions (_3: XkbDescPtr, _2: c_int, _1: c_int) -> *mut XkbAction, + pub fn XkbResizeKeySyms (_3: XkbDescPtr, _2: c_int, _1: c_int) -> *mut c_ulong, + pub fn XkbResizeKeyType (_5: XkbDescPtr, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> c_int, + pub fn XkbSelectEventDetails (_5: *mut Display, _4: c_uint, _3: c_uint, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XkbSelectEvents (_4: *mut Display, _3: c_uint, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XkbSetAtomFuncs (_2: Option<unsafe extern "C" fn (*mut Display, *const c_char, c_int) -> c_ulong>, _1: Option<unsafe extern "C" fn (*mut Display, c_ulong) -> *mut c_char>) -> (), + pub fn XkbSetAutoRepeatRate (_4: *mut Display, _3: c_uint, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbSetAutoResetControls (_4: *mut Display, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int, + pub fn XkbSetCompatMap (_4: *mut Display, _3: c_uint, _2: XkbDescPtr, _1: c_int) -> c_int, + pub fn XkbSetControls (_3: *mut Display, _2: c_ulong, _1: XkbDescPtr) -> c_int, + pub fn XkbSetDebuggingFlags (_8: *mut Display, _7: c_uint, _6: c_uint, _5: *mut c_char, _4: c_uint, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int, + pub fn XkbSetDetectableAutoRepeat (_3: *mut Display, _2: c_int, _1: *mut c_int) -> c_int, + pub fn XkbSetDeviceButtonActions (_4: *mut Display, _3: XkbDeviceInfoPtr, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbSetDeviceInfo (_3: *mut Display, _2: c_uint, _1: XkbDeviceInfoPtr) -> c_int, + pub fn XkbSetDeviceLedInfo (_5: *mut Display, _4: XkbDeviceInfoPtr, _3: c_uint, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbSetGeometry (_3: *mut Display, _2: c_uint, _1: XkbGeometryPtr) -> c_int, + pub fn XkbSetIgnoreLockMods (_6: *mut Display, _5: c_uint, _4: c_uint, _3: c_uint, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbSetIndicatorMap (_3: *mut Display, _2: c_ulong, _1: XkbDescPtr) -> c_int, + pub fn XkbSetMap (_3: *mut Display, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbSetNamedDeviceIndicator (_9: *mut Display, _8: c_uint, _7: c_uint, _6: c_uint, _5: c_ulong, _4: c_int, _3: c_int, _2: c_int, _1: XkbIndicatorMapPtr) -> c_int, + pub fn XkbSetNamedIndicator (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: c_int, _1: XkbIndicatorMapPtr) -> c_int, + pub fn XkbSetNames (_5: *mut Display, _4: c_uint, _3: c_uint, _2: c_uint, _1: XkbDescPtr) -> c_int, + pub fn XkbSetPerClientControls (_3: *mut Display, _2: c_uint, _1: *mut c_uint) -> c_int, + pub fn XkbSetServerInternalMods (_6: *mut Display, _5: c_uint, _4: c_uint, _3: c_uint, _2: c_uint, _1: c_uint) -> c_int, + pub fn XkbSetXlibControls (_3: *mut Display, _2: c_uint, _1: c_uint) -> c_uint, + pub fn XkbToControl (_1: c_char) -> c_char, + pub fn XkbTranslateKeyCode (_5: XkbDescPtr, _4: c_uchar, _3: c_uint, _2: *mut c_uint, _1: *mut c_ulong) -> c_int, + pub fn XkbTranslateKeySym (_6: *mut Display, _5: *mut c_ulong, _4: c_uint, _3: *mut c_char, _2: c_int, _1: *mut c_int) -> c_int, + pub fn XkbUpdateActionVirtualMods (_3: XkbDescPtr, _2: *mut XkbAction, _1: c_uint) -> c_int, + pub fn XkbUpdateKeyTypeVirtualMods (_4: XkbDescPtr, _3: XkbKeyTypePtr, _2: c_uint, _1: XkbChangesPtr) -> (), + pub fn XkbUpdateMapFromCore (_6: XkbDescPtr, _5: c_uchar, _4: c_int, _3: c_int, _2: *mut c_ulong, _1: XkbChangesPtr) -> c_int, + pub fn XkbUseExtension (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XkbVirtualModsToReal (_3: XkbDescPtr, _2: c_uint, _1: *mut c_uint) -> c_int, + pub fn XkbXlibControlsImplemented () -> c_uint, + pub fn XKeycodeToKeysym (_3: *mut Display, _2: c_uchar, _1: c_int) -> c_ulong, + pub fn XKeysymToKeycode (_2: *mut Display, _1: c_ulong) -> c_uchar, + pub fn XKeysymToString (_1: c_ulong) -> *mut c_char, + pub fn XKillClient (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XLastKnownRequestProcessed (_1: *mut Display) -> c_ulong, + pub fn XListDepths (_3: *mut Display, _2: c_int, _1: *mut c_int) -> *mut c_int, + pub fn XListExtensions (_2: *mut Display, _1: *mut c_int) -> *mut *mut c_char, + pub fn XListFonts (_4: *mut Display, _3: *const c_char, _2: c_int, _1: *mut c_int) -> *mut *mut c_char, + pub fn XListFontsWithInfo (_5: *mut Display, _4: *const c_char, _3: c_int, _2: *mut c_int, _1: *mut *mut XFontStruct) -> *mut *mut c_char, + pub fn XListHosts (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> *mut XHostAddress, + pub fn XListInstalledColormaps (_3: *mut Display, _2: c_ulong, _1: *mut c_int) -> *mut c_ulong, + pub fn XListPixmapFormats (_2: *mut Display, _1: *mut c_int) -> *mut XPixmapFormatValues, + pub fn XListProperties (_3: *mut Display, _2: c_ulong, _1: *mut c_int) -> *mut c_ulong, + pub fn XLoadFont (_2: *mut Display, _1: *const c_char) -> c_ulong, + pub fn XLoadQueryFont (_2: *mut Display, _1: *const c_char) -> *mut XFontStruct, + pub fn XLocaleOfFontSet (_1: XFontSet) -> *mut c_char, + pub fn XLocaleOfIM (_1: XIM) -> *mut c_char, + pub fn XLocaleOfOM (_1: XOM) -> *mut c_char, + pub fn XLockDisplay (_1: *mut Display) -> (), + pub fn XLookupColor (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: *mut XColor, _1: *mut XColor) -> c_int, + pub fn XLookupKeysym (_2: *mut XKeyEvent, _1: c_int) -> c_ulong, + pub fn XLookupString (_5: *mut XKeyEvent, _4: *mut c_char, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XLowerWindow (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XMapRaised (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XMapSubwindows (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XMapWindow (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XMaskEvent (_3: *mut Display, _2: c_long, _1: *mut XEvent) -> c_int, + pub fn XMatchVisualInfo (_5: *mut Display, _4: c_int, _3: c_int, _2: c_int, _1: *mut XVisualInfo) -> c_int, + pub fn XMaxCmapsOfScreen (_1: *mut Screen) -> c_int, + pub fn XMaxRequestSize (_1: *mut Display) -> c_long, + pub fn XmbDrawImageString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> (), + pub fn XmbDrawString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> (), + pub fn XmbDrawText (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *mut XmbTextItem, _1: c_int) -> (), + pub fn XmbLookupString (_6: XIC, _5: *mut XKeyEvent, _4: *mut c_char, _3: c_int, _2: *mut c_ulong, _1: *mut c_int) -> c_int, + pub fn XmbResetIC (_1: XIC) -> *mut c_char, + pub fn XmbSetWMProperties (_9: *mut Display, _8: c_ulong, _7: *const c_char, _6: *const c_char, _5: *mut *mut c_char, _4: c_int, _3: *mut XSizeHints, _2: *mut XWMHints, _1: *mut XClassHint) -> (), + pub fn XmbTextEscapement (_3: XFontSet, _2: *const c_char, _1: c_int) -> c_int, + pub fn XmbTextExtents (_5: XFontSet, _4: *const c_char, _3: c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int, + pub fn XmbTextListToTextProperty (_5: *mut Display, _4: *mut *mut c_char, _3: c_int, _2: XICCEncodingStyle, _1: *mut XTextProperty) -> c_int, + pub fn XmbTextPerCharExtents (_9: XFontSet, _8: *const c_char, _7: c_int, _6: *mut XRectangle, _5: *mut XRectangle, _4: c_int, _3: *mut c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int, + pub fn XmbTextPropertyToTextList (_4: *mut Display, _3: *const XTextProperty, _2: *mut *mut *mut c_char, _1: *mut c_int) -> c_int, + pub fn XMinCmapsOfScreen (_1: *mut Screen) -> c_int, + pub fn XMoveResizeWindow (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> c_int, + pub fn XMoveWindow (_4: *mut Display, _3: c_ulong, _2: c_int, _1: c_int) -> c_int, + pub fn XNewModifiermap (_1: c_int) -> *mut XModifierKeymap, + pub fn XNextEvent (_2: *mut Display, _1: *mut XEvent) -> c_int, + pub fn XNextRequest (_1: *mut Display) -> c_ulong, + pub fn XNoOp (_1: *mut Display) -> c_int, + pub fn XOffsetRegion (_3: Region, _2: c_int, _1: c_int) -> c_int, + pub fn XOMOfOC (_1: XFontSet) -> XOM, + pub fn XOpenDisplay (_1: *const c_char) -> *mut Display, + pub fn XOpenIM (_4: *mut Display, _3: XrmDatabase, _2: *mut c_char, _1: *mut c_char) -> XIM, + pub fn XOpenOM (_4: *mut Display, _3: XrmDatabase, _2: *const c_char, _1: *const c_char) -> XOM, + pub fn XParseColor (_4: *mut Display, _3: c_ulong, _2: *const c_char, _1: *mut XColor) -> c_int, + pub fn XParseGeometry (_5: *const c_char, _4: *mut c_int, _3: *mut c_int, _2: *mut c_uint, _1: *mut c_uint) -> c_int, + pub fn XPeekEvent (_2: *mut Display, _1: *mut XEvent) -> c_int, + pub fn XPeekIfEvent (_4: *mut Display, _3: *mut XEvent, _2: Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut c_char) -> c_int>, _1: *mut c_char) -> c_int, + pub fn XPending (_1: *mut Display) -> c_int, + pub fn Xpermalloc (_1: c_uint) -> *mut c_char, + pub fn XPlanesOfScreen (_1: *mut Screen) -> c_int, + pub fn XPointInRegion (_3: Region, _2: c_int, _1: c_int) -> c_int, + pub fn XPolygonRegion (_3: *mut XPoint, _2: c_int, _1: c_int) -> Region, + pub fn XProcessInternalConnection (_2: *mut Display, _1: c_int) -> (), + pub fn XProtocolRevision (_1: *mut Display) -> c_int, + pub fn XProtocolVersion (_1: *mut Display) -> c_int, + pub fn XPutBackEvent (_2: *mut Display, _1: *mut XEvent) -> c_int, + pub fn XPutImage (_10: *mut Display, _9: c_ulong, _8: GC, _7: *mut XImage, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> c_int, + pub fn XPutPixel (_4: *mut XImage, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XQLength (_1: *mut Display) -> c_int, + pub fn XQueryBestCursor (_6: *mut Display, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int, + pub fn XQueryBestSize (_7: *mut Display, _6: c_int, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int, + pub fn XQueryBestStipple (_6: *mut Display, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int, + pub fn XQueryBestTile (_6: *mut Display, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int, + pub fn XQueryColor (_3: *mut Display, _2: c_ulong, _1: *mut XColor) -> c_int, + pub fn XQueryColors (_4: *mut Display, _3: c_ulong, _2: *mut XColor, _1: c_int) -> c_int, + pub fn XQueryExtension (_5: *mut Display, _4: *const c_char, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XQueryFont (_2: *mut Display, _1: c_ulong) -> *mut XFontStruct, + pub fn XQueryKeymap (_2: *mut Display, _1: *mut c_char) -> c_int, + pub fn XQueryPointer (_9: *mut Display, _8: c_ulong, _7: *mut c_ulong, _6: *mut c_ulong, _5: *mut c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_uint) -> c_int, + pub fn XQueryTextExtents (_8: *mut Display, _7: c_ulong, _6: *const c_char, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut XCharStruct) -> c_int, + pub fn XQueryTextExtents16 (_8: *mut Display, _7: c_ulong, _6: *const XChar2b, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut XCharStruct) -> c_int, + pub fn XQueryTree (_6: *mut Display, _5: c_ulong, _4: *mut c_ulong, _3: *mut c_ulong, _2: *mut *mut c_ulong, _1: *mut c_uint) -> c_int, + pub fn XRaiseWindow (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XReadBitmapFile (_8: *mut Display, _7: c_ulong, _6: *const c_char, _5: *mut c_uint, _4: *mut c_uint, _3: *mut c_ulong, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XReadBitmapFileData (_6: *const c_char, _5: *mut c_uint, _4: *mut c_uint, _3: *mut *mut c_uchar, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XRebindKeysym (_6: *mut Display, _5: c_ulong, _4: *mut c_ulong, _3: c_int, _2: *const c_uchar, _1: c_int) -> c_int, + pub fn XRecolorCursor (_4: *mut Display, _3: c_ulong, _2: *mut XColor, _1: *mut XColor) -> c_int, + pub fn XReconfigureWMWindow (_5: *mut Display, _4: c_ulong, _3: c_int, _2: c_uint, _1: *mut XWindowChanges) -> c_int, + pub fn XRectInRegion (_5: Region, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> c_int, + pub fn XRefreshKeyboardMapping (_1: *mut XMappingEvent) -> c_int, + pub fn XRegisterIMInstantiateCallback (_6: *mut Display, _5: XrmDatabase, _4: *mut c_char, _3: *mut c_char, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char, *mut c_char)>, _1: *mut c_char) -> c_int, + pub fn XRemoveConnectionWatch (_3: *mut Display, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char, c_int, c_int, *mut *mut c_char)>, _1: *mut c_char) -> (), + pub fn XRemoveFromSaveSet (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XRemoveHost (_2: *mut Display, _1: *mut XHostAddress) -> c_int, + pub fn XRemoveHosts (_3: *mut Display, _2: *mut XHostAddress, _1: c_int) -> c_int, + pub fn XReparentWindow (_5: *mut Display, _4: c_ulong, _3: c_ulong, _2: c_int, _1: c_int) -> c_int, + pub fn XResetScreenSaver (_1: *mut Display) -> c_int, + pub fn XResizeWindow (_4: *mut Display, _3: c_ulong, _2: c_uint, _1: c_uint) -> c_int, + pub fn XResourceManagerString (_1: *mut Display) -> *mut c_char, + pub fn XRestackWindows (_3: *mut Display, _2: *mut c_ulong, _1: c_int) -> c_int, + pub fn XrmCombineDatabase (_3: XrmDatabase, _2: *mut XrmDatabase, _1: c_int) -> (), + pub fn XrmCombineFileDatabase (_3: *const c_char, _2: *mut XrmDatabase, _1: c_int) -> c_int, + pub fn XrmDestroyDatabase (_1: XrmDatabase) -> (), + pub fn XrmEnumerateDatabase (_6: XrmDatabase, _5: *mut c_int, _4: *mut c_int, _3: c_int, _2: Option<unsafe extern "C" fn (*mut XrmDatabase, *mut XrmBinding, *mut c_int, *mut c_int, *mut XrmValue, *mut c_char) -> c_int>, _1: *mut c_char) -> c_int, + pub fn XrmGetDatabase (_1: *mut Display) -> XrmDatabase, + pub fn XrmGetFileDatabase (_1: *const c_char) -> XrmDatabase, + pub fn XrmGetResource (_5: XrmDatabase, _4: *const c_char, _3: *const c_char, _2: *mut *mut c_char, _1: *mut XrmValue) -> c_int, + pub fn XrmGetStringDatabase (_1: *const c_char) -> XrmDatabase, + pub fn XrmInitialize () -> (), + pub fn XrmLocaleOfDatabase (_1: XrmDatabase) -> *const c_char, + pub fn XrmMergeDatabases (_2: XrmDatabase, _1: *mut XrmDatabase) -> (), + pub fn XrmParseCommand (_6: *mut XrmDatabase, _5: XrmOptionDescList, _4: c_int, _3: *const c_char, _2: *mut c_int, _1: *mut *mut c_char) -> (), + pub fn XrmPermStringToQuark (_1: *const c_char) -> c_int, + pub fn XrmPutFileDatabase (_2: XrmDatabase, _1: *const c_char) -> (), + pub fn XrmPutLineResource (_2: *mut XrmDatabase, _1: *const c_char) -> (), + pub fn XrmPutResource (_4: *mut XrmDatabase, _3: *const c_char, _2: *const c_char, _1: *mut XrmValue) -> (), + pub fn XrmPutStringResource (_3: *mut XrmDatabase, _2: *const c_char, _1: *const c_char) -> (), + pub fn XrmQGetResource (_5: XrmDatabase, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut XrmValue) -> c_int, + pub fn XrmQGetSearchList (_5: XrmDatabase, _4: *mut c_int, _3: *mut c_int, _2: *mut *mut XrmDatabase, _1: c_int) -> c_int, + pub fn XrmQGetSearchResource (_5: *mut *mut XrmDatabase, _4: c_int, _3: c_int, _2: *mut c_int, _1: *mut XrmValue) -> c_int, + pub fn XrmQPutResource (_5: *mut XrmDatabase, _4: *mut XrmBinding, _3: *mut c_int, _2: c_int, _1: *mut XrmValue) -> (), + pub fn XrmQPutStringResource (_4: *mut XrmDatabase, _3: *mut XrmBinding, _2: *mut c_int, _1: *const c_char) -> (), + pub fn XrmQuarkToString (_1: c_int) -> *mut c_char, + pub fn XrmSetDatabase (_2: *mut Display, _1: XrmDatabase) -> (), + pub fn XrmStringToBindingQuarkList (_3: *const c_char, _2: *mut XrmBinding, _1: *mut c_int) -> (), + pub fn XrmStringToQuark (_1: *const c_char) -> c_int, + pub fn XrmStringToQuarkList (_2: *const c_char, _1: *mut c_int) -> (), + pub fn XrmUniqueQuark () -> c_int, + pub fn XRootWindow (_2: *mut Display, _1: c_int) -> c_ulong, + pub fn XRootWindowOfScreen (_1: *mut Screen) -> c_ulong, + pub fn XRotateBuffers (_2: *mut Display, _1: c_int) -> c_int, + pub fn XRotateWindowProperties (_5: *mut Display, _4: c_ulong, _3: *mut c_ulong, _2: c_int, _1: c_int) -> c_int, + pub fn XSaveContext (_4: *mut Display, _3: c_ulong, _2: c_int, _1: *const c_char) -> c_int, + pub fn XScreenCount (_1: *mut Display) -> c_int, + pub fn XScreenNumberOfScreen (_1: *mut Screen) -> c_int, + pub fn XScreenOfDisplay (_2: *mut Display, _1: c_int) -> *mut Screen, + pub fn XScreenResourceString (_1: *mut Screen) -> *mut c_char, + pub fn XSelectInput (_3: *mut Display, _2: c_ulong, _1: c_long) -> c_int, + pub fn XSendEvent (_5: *mut Display, _4: c_ulong, _3: c_int, _2: c_long, _1: *mut XEvent) -> c_int, + pub fn XServerVendor (_1: *mut Display) -> *mut c_char, + pub fn XSetAccessControl (_2: *mut Display, _1: c_int) -> c_int, + pub fn XSetAfterFunction (_2: *mut Display, _1: Option<unsafe extern "C" fn (*mut Display) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display) -> c_int>, + pub fn XSetArcMode (_3: *mut Display, _2: GC, _1: c_int) -> c_int, + pub fn XSetAuthorization (_4: *mut c_char, _3: c_int, _2: *mut c_char, _1: c_int) -> (), + pub fn XSetBackground (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int, + pub fn XSetClassHint (_3: *mut Display, _2: c_ulong, _1: *mut XClassHint) -> c_int, + pub fn XSetClipMask (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int, + pub fn XSetClipOrigin (_4: *mut Display, _3: GC, _2: c_int, _1: c_int) -> c_int, + pub fn XSetClipRectangles (_7: *mut Display, _6: GC, _5: c_int, _4: c_int, _3: *mut XRectangle, _2: c_int, _1: c_int) -> c_int, + pub fn XSetCloseDownMode (_2: *mut Display, _1: c_int) -> c_int, + pub fn XSetCommand (_4: *mut Display, _3: c_ulong, _2: *mut *mut c_char, _1: c_int) -> c_int, + pub fn XSetDashes (_5: *mut Display, _4: GC, _3: c_int, _2: *const c_char, _1: c_int) -> c_int, + pub fn XSetErrorHandler (_1: Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent) -> c_int>, + pub fn XSetFillRule (_3: *mut Display, _2: GC, _1: c_int) -> c_int, + pub fn XSetFillStyle (_3: *mut Display, _2: GC, _1: c_int) -> c_int, + pub fn XSetFont (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int, + pub fn XSetFontPath (_3: *mut Display, _2: *mut *mut c_char, _1: c_int) -> c_int, + pub fn XSetForeground (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int, + pub fn XSetFunction (_3: *mut Display, _2: GC, _1: c_int) -> c_int, + pub fn XSetGraphicsExposures (_3: *mut Display, _2: GC, _1: c_int) -> c_int, + pub fn XSetICFocus (_1: XIC) -> (), + pub fn XSetIconName (_3: *mut Display, _2: c_ulong, _1: *const c_char) -> c_int, + pub fn XSetIconSizes (_4: *mut Display, _3: c_ulong, _2: *mut XIconSize, _1: c_int) -> c_int, + pub fn XSetInputFocus (_4: *mut Display, _3: c_ulong, _2: c_int, _1: c_ulong) -> c_int, + pub fn XSetIOErrorHandler (_1: Option<unsafe extern "C" fn (*mut Display) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display) -> c_int>, + pub fn XSetLineAttributes (_6: *mut Display, _5: GC, _4: c_uint, _3: c_int, _2: c_int, _1: c_int) -> c_int, + pub fn XSetLocaleModifiers (_1: *const c_char) -> *mut c_char, + pub fn XSetModifierMapping (_2: *mut Display, _1: *mut XModifierKeymap) -> c_int, + pub fn XSetNormalHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> c_int, + pub fn XSetPlaneMask (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int, + pub fn XSetPointerMapping (_3: *mut Display, _2: *const c_uchar, _1: c_int) -> c_int, + pub fn XSetRegion (_3: *mut Display, _2: GC, _1: Region) -> c_int, + pub fn XSetRGBColormaps (_5: *mut Display, _4: c_ulong, _3: *mut XStandardColormap, _2: c_int, _1: c_ulong) -> (), + pub fn XSetScreenSaver (_5: *mut Display, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> c_int, + pub fn XSetSelectionOwner (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XSetSizeHints (_4: *mut Display, _3: c_ulong, _2: *mut XSizeHints, _1: c_ulong) -> c_int, + pub fn XSetStandardColormap (_4: *mut Display, _3: c_ulong, _2: *mut XStandardColormap, _1: c_ulong) -> (), + pub fn XSetStandardProperties (_8: *mut Display, _7: c_ulong, _6: *const c_char, _5: *const c_char, _4: c_ulong, _3: *mut *mut c_char, _2: c_int, _1: *mut XSizeHints) -> c_int, + pub fn XSetState (_6: *mut Display, _5: GC, _4: c_ulong, _3: c_ulong, _2: c_int, _1: c_ulong) -> c_int, + pub fn XSetStipple (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int, + pub fn XSetSubwindowMode (_3: *mut Display, _2: GC, _1: c_int) -> c_int, + pub fn XSetTextProperty (_4: *mut Display, _3: c_ulong, _2: *mut XTextProperty, _1: c_ulong) -> (), + pub fn XSetTile (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int, + pub fn XSetTransientForHint (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XSetTSOrigin (_4: *mut Display, _3: GC, _2: c_int, _1: c_int) -> c_int, + pub fn XSetWindowBackground (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XSetWindowBackgroundPixmap (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XSetWindowBorder (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XSetWindowBorderPixmap (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XSetWindowBorderWidth (_3: *mut Display, _2: c_ulong, _1: c_uint) -> c_int, + pub fn XSetWindowColormap (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XSetWMClientMachine (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty) -> (), + pub fn XSetWMColormapWindows (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int, + pub fn XSetWMHints (_3: *mut Display, _2: c_ulong, _1: *mut XWMHints) -> c_int, + pub fn XSetWMIconName (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty) -> (), + pub fn XSetWMName (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty) -> (), + pub fn XSetWMNormalHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> (), + pub fn XSetWMProperties (_9: *mut Display, _8: c_ulong, _7: *mut XTextProperty, _6: *mut XTextProperty, _5: *mut *mut c_char, _4: c_int, _3: *mut XSizeHints, _2: *mut XWMHints, _1: *mut XClassHint) -> (), + pub fn XSetWMProtocols (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int, + pub fn XSetWMSizeHints (_4: *mut Display, _3: c_ulong, _2: *mut XSizeHints, _1: c_ulong) -> (), + pub fn XSetZoomHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> c_int, + pub fn XShrinkRegion (_3: Region, _2: c_int, _1: c_int) -> c_int, + pub fn XStoreBuffer (_4: *mut Display, _3: *const c_char, _2: c_int, _1: c_int) -> c_int, + pub fn XStoreBytes (_3: *mut Display, _2: *const c_char, _1: c_int) -> c_int, + pub fn XStoreColor (_3: *mut Display, _2: c_ulong, _1: *mut XColor) -> c_int, + pub fn XStoreColors (_4: *mut Display, _3: c_ulong, _2: *mut XColor, _1: c_int) -> c_int, + pub fn XStoreName (_3: *mut Display, _2: c_ulong, _1: *const c_char) -> c_int, + pub fn XStoreNamedColor (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: c_ulong, _1: c_int) -> c_int, + pub fn XStringListToTextProperty (_3: *mut *mut c_char, _2: c_int, _1: *mut XTextProperty) -> c_int, + pub fn XStringToKeysym (_1: *const c_char) -> c_ulong, + pub fn XSubImage (_5: *mut XImage, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> *mut XImage, + pub fn XSubtractRegion (_3: Region, _2: Region, _1: Region) -> c_int, + pub fn XSupportsLocale () -> c_int, + pub fn XSync (_2: *mut Display, _1: c_int) -> c_int, + pub fn XSynchronize (_2: *mut Display, _1: c_int) -> Option<unsafe extern "C" fn (*mut Display) -> c_int>, + pub fn XTextExtents (_7: *mut XFontStruct, _6: *const c_char, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut XCharStruct) -> c_int, + pub fn XTextExtents16 (_7: *mut XFontStruct, _6: *const XChar2b, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut XCharStruct) -> c_int, + pub fn XTextPropertyToStringList (_3: *mut XTextProperty, _2: *mut *mut *mut c_char, _1: *mut c_int) -> c_int, + pub fn XTextWidth (_3: *mut XFontStruct, _2: *const c_char, _1: c_int) -> c_int, + pub fn XTextWidth16 (_3: *mut XFontStruct, _2: *const XChar2b, _1: c_int) -> c_int, + pub fn XTranslateCoordinates (_8: *mut Display, _7: c_ulong, _6: c_ulong, _5: c_int, _4: c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_ulong) -> c_int, + pub fn XUndefineCursor (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XUngrabButton (_4: *mut Display, _3: c_uint, _2: c_uint, _1: c_ulong) -> c_int, + pub fn XUngrabKey (_4: *mut Display, _3: c_int, _2: c_uint, _1: c_ulong) -> c_int, + pub fn XUngrabKeyboard (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XUngrabPointer (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XUngrabServer (_1: *mut Display) -> c_int, + pub fn XUninstallColormap (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XUnionRectWithRegion (_3: *mut XRectangle, _2: Region, _1: Region) -> c_int, + pub fn XUnionRegion (_3: Region, _2: Region, _1: Region) -> c_int, + pub fn XUnloadFont (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XUnlockDisplay (_1: *mut Display) -> (), + pub fn XUnmapSubwindows (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XUnmapWindow (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XUnregisterIMInstantiateCallback (_6: *mut Display, _5: XrmDatabase, _4: *mut c_char, _3: *mut c_char, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char, *mut c_char)>, _1: *mut c_char) -> c_int, + pub fn XUnsetICFocus (_1: XIC) -> (), + pub fn Xutf8DrawImageString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> (), + pub fn Xutf8DrawString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> (), + pub fn Xutf8DrawText (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *mut XmbTextItem, _1: c_int) -> (), + pub fn Xutf8LookupString (_6: XIC, _5: *mut XKeyEvent, _4: *mut c_char, _3: c_int, _2: *mut c_ulong, _1: *mut c_int) -> c_int, + pub fn Xutf8ResetIC (_1: XIC) -> *mut c_char, + pub fn Xutf8SetWMProperties (_9: *mut Display, _8: c_ulong, _7: *const c_char, _6: *const c_char, _5: *mut *mut c_char, _4: c_int, _3: *mut XSizeHints, _2: *mut XWMHints, _1: *mut XClassHint) -> (), + pub fn Xutf8TextEscapement (_3: XFontSet, _2: *const c_char, _1: c_int) -> c_int, + pub fn Xutf8TextExtents (_5: XFontSet, _4: *const c_char, _3: c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int, + pub fn Xutf8TextListToTextProperty (_5: *mut Display, _4: *mut *mut c_char, _3: c_int, _2: XICCEncodingStyle, _1: *mut XTextProperty) -> c_int, + pub fn Xutf8TextPerCharExtents (_9: XFontSet, _8: *const c_char, _7: c_int, _6: *mut XRectangle, _5: *mut XRectangle, _4: c_int, _3: *mut c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int, + pub fn Xutf8TextPropertyToTextList (_4: *mut Display, _3: *const XTextProperty, _2: *mut *mut *mut c_char, _1: *mut c_int) -> c_int, + pub fn XVendorRelease (_1: *mut Display) -> c_int, + pub fn XVisualIDFromVisual (_1: *mut Visual) -> c_ulong, + pub fn XWarpPointer (_9: *mut Display, _8: c_ulong, _7: c_ulong, _6: c_int, _5: c_int, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int, + pub fn XwcDrawImageString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const wchar_t, _1: c_int) -> (), + pub fn XwcDrawString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const wchar_t, _1: c_int) -> (), + pub fn XwcDrawText (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *mut XwcTextItem, _1: c_int) -> (), + pub fn XwcFreeStringList (_1: *mut *mut wchar_t) -> (), + pub fn XwcLookupString (_6: XIC, _5: *mut XKeyEvent, _4: *mut wchar_t, _3: c_int, _2: *mut c_ulong, _1: *mut c_int) -> c_int, + pub fn XwcResetIC (_1: XIC) -> *mut wchar_t, + pub fn XwcTextEscapement (_3: XFontSet, _2: *const wchar_t, _1: c_int) -> c_int, + pub fn XwcTextExtents (_5: XFontSet, _4: *const wchar_t, _3: c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int, + pub fn XwcTextListToTextProperty (_5: *mut Display, _4: *mut *mut wchar_t, _3: c_int, _2: XICCEncodingStyle, _1: *mut XTextProperty) -> c_int, + pub fn XwcTextPerCharExtents (_9: XFontSet, _8: *const wchar_t, _7: c_int, _6: *mut XRectangle, _5: *mut XRectangle, _4: c_int, _3: *mut c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int, + pub fn XwcTextPropertyToTextList (_4: *mut Display, _3: *const XTextProperty, _2: *mut *mut *mut wchar_t, _1: *mut c_int) -> c_int, + pub fn XWhitePixel (_2: *mut Display, _1: c_int) -> c_ulong, + pub fn XWhitePixelOfScreen (_1: *mut Screen) -> c_ulong, + pub fn XWidthMMOfScreen (_1: *mut Screen) -> c_int, + pub fn XWidthOfScreen (_1: *mut Screen) -> c_int, + pub fn XWindowEvent (_4: *mut Display, _3: c_ulong, _2: c_long, _1: *mut XEvent) -> c_int, + pub fn XWithdrawWindow (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int, + pub fn XWMGeometry (_11: *mut Display, _10: c_int, _9: *const c_char, _8: *const c_char, _7: c_uint, _6: *mut XSizeHints, _5: *mut c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XWriteBitmapFile (_7: *mut Display, _6: *const c_char, _5: c_ulong, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int, + pub fn XXorRegion (_3: Region, _2: Region, _1: Region) -> c_int, +variadic: + pub fn XCreateIC (_1: XIM) -> XIC, + pub fn XCreateOC (_1: XOM) -> XFontSet, + pub fn XGetICValues (_1: XIC) -> *mut c_char, + pub fn XGetIMValues (_1: XIM) -> *mut c_char, + pub fn XGetOCValues (_1: XFontSet) -> *mut c_char, + pub fn XGetOMValues (_1: XOM) -> *mut c_char, + pub fn XSetICValues (_1: XIC) -> *mut c_char, + pub fn XSetIMValues (_1: XIM) -> *mut c_char, + pub fn XSetOCValues (_1: XFontSet) -> *mut c_char, + pub fn XSetOMValues (_1: XOM) -> *mut c_char, + pub fn XVaCreateNestedList (_1: c_int) -> *mut c_void, +globals: +} + + +// +// types +// + + +// common types +pub type Atom = XID; +pub type Bool = c_int; +pub type Colormap = XID; +pub type Cursor = XID; +pub type Drawable = XID; +pub type Font = XID; +pub type GContext = XID; +pub type KeyCode = c_uchar; +pub type KeySym = XID; +pub type Mask = c_ulong; +pub type Pixmap = XID; +pub type Status = Bool; +pub type Time = c_ulong; +pub type VisualID = XID; +pub type Window = XID; +pub type XID = c_ulong; +pub type XPointer = *mut c_char; + +// opaque structures +pub enum _XDisplay {} +pub enum xError {} +pub enum xEvent {} +pub enum _XGC {} +pub enum _XIC {} +pub enum _XIM {} +pub enum _XRegion {} +pub enum _XOC {} +pub enum _XOM {} +pub enum _XrmHashBucketRec {} + +// TODO structs +#[repr(C)] pub struct _XcmsCCC; +#[repr(C)] pub struct XcmsColor; +#[repr(C)] pub struct _XcmsColorSpace; +#[repr(C)] pub struct _XcmsFunctionSet; +#[repr(C)] pub struct _XkbAction; +#[repr(C)] pub struct _XkbBounds; +#[repr(C)] pub struct _XkbChanges; +#[repr(C)] pub struct _XkbClientMapRec; +#[repr(C)] pub struct _XkbColor; +#[repr(C)] pub struct _XkbComponentList; +#[repr(C)] pub struct _XkbComponentNames; +#[repr(C)] pub struct _XkbControls; +#[repr(C)] pub struct _XkbControlsChanges; +#[repr(C)] pub struct _XkbControlsNotify; +#[repr(C)] pub struct _XkbDeviceChanges; +#[repr(C)] pub struct _XkbDeviceInfo; +#[repr(C)] pub struct _XkbDeviceLedInfo; +#[repr(C)] pub struct _XkbDoodad; +#[repr(C)] pub struct _XkbExtensionDeviceNotify; +#[repr(C)] pub struct _XkbGeometry; +#[repr(C)] pub struct _XkbGeometrySizes; +#[repr(C)] pub struct _XkbIndicatorMapRec; +#[repr(C)] pub struct _XkbKey; +#[repr(C)] pub struct _XkbKeyType; +#[repr(C)] pub struct _XkbMapChanges; +#[repr(C)] pub struct _XkbMods; +#[repr(C)] pub struct _XkbNameChanges; +#[repr(C)] pub struct _XkbNamesNotify; +#[repr(C)] pub struct _XkbOutline; +#[repr(C)] pub struct _XkbOverlay; +#[repr(C)] pub struct _XkbOverlayKey; +#[repr(C)] pub struct _XkbOverlayRow; +#[repr(C)] pub struct _XkbProperty; +#[repr(C)] pub struct _XkbRow; +#[repr(C)] pub struct _XkbSection; +#[repr(C)] pub struct _XkbServerMapRec; +#[repr(C)] pub struct _XkbShape; +#[repr(C)] pub struct _XkbStateRec; +#[repr(C)] pub struct _XkbSymInterpretRec; + +// union placeholders +pub type XEDataObject = *mut c_void; + +// misc typedefs +pub type Display = _XDisplay; +pub type GC = *mut _XGC; +pub type Region = *mut _XRegion; +pub type XcmsCCC = *mut _XcmsCCC; +pub type XcmsColorSpace = _XcmsColorSpace; +pub type XcmsFunctionSet = _XcmsFunctionSet; +pub type XContext = c_int; +pub type XFontSet = *mut _XOC; +pub type XIC = *mut _XIC; +pub type XIM = *mut _XIM; +pub type XkbAction = _XkbAction; +pub type XkbBoundsPtr = *mut _XkbBounds; +pub type XkbChangesPtr = *mut _XkbChanges; +pub type XkbClientMapPtr = *mut _XkbClientMapRec; +pub type XkbColorPtr = *mut _XkbColor; +pub type XkbCompatMapPtr = *mut _XkbCompatMapRec; +pub type XkbComponentListPtr = *mut _XkbComponentList; +pub type XkbComponentNamesPtr = *mut _XkbComponentNames; +pub type XkbControlsChangesPtr = *mut _XkbControlsChanges; +pub type XkbControlsNotifyEvent = _XkbControlsNotify; +pub type XkbControlsPtr = *mut _XkbControls; +pub type XkbDescPtr = *mut _XkbDesc; +pub type XkbDeviceChangesPtr = *mut _XkbDeviceChanges; +pub type XkbDeviceInfoPtr = *mut _XkbDeviceInfo; +pub type XkbDeviceLedInfoPtr = *mut _XkbDeviceLedInfo; +pub type XkbDoodadPtr = *mut _XkbDoodad; +pub type XkbExtensionDeviceNotifyEvent = _XkbExtensionDeviceNotify; +pub type XkbGeometryPtr = *mut _XkbGeometry; +pub type XkbGeometrySizesPtr = *mut _XkbGeometrySizes; +pub type XkbIndicatorMapPtr = *mut _XkbIndicatorMapRec; +pub type XkbIndicatorMapRec = _XkbIndicatorMapRec; +pub type XkbIndicatorPtr = *mut _XkbIndicatorRec; +pub type XkbKeyTypePtr = *mut _XkbKeyType; +pub type XkbMapChangesPtr = *mut _XkbMapChanges; +pub type XkbMapNotifyEvent = _XkbMapNotifyEvent; +pub type XkbModsPtr = *mut _XkbMods; +pub type XkbModsRec = _XkbMods; +pub type XkbNameChangesPtr = *mut _XkbNameChanges; +pub type XkbNamesNotifyEvent = _XkbNamesNotify; +pub type XkbNamesPtr = *mut _XkbNamesRec; +pub type XkbKeyAliasPtr = *mut _XkbKeyAliasRec; +pub type XkbKeyNamePtr = *mut _XkbKeyNameRec; +pub type XkbKeyPtr = *mut _XkbKey; +pub type XkbOutlinePtr = *mut _XkbOutline; +pub type XkbOverlayKeyPtr = *mut _XkbOverlayKey; +pub type XkbOverlayPtr = *mut _XkbOverlay; +pub type XkbOverlayRowPtr = *mut _XkbOverlayRow; +pub type XkbPropertyPtr = *mut _XkbProperty; +pub type XkbRowPtr = *mut _XkbRow; +pub type XkbSectionPtr = *mut _XkbSection; +pub type XkbServerMapPtr = *mut _XkbServerMapRec; +pub type XkbShapePtr = *mut _XkbShape; +pub type XkbStatePtr = *mut _XkbStateRec; +pub type XkbSymInterpretPtr = *mut _XkbSymInterpretRec; +pub type XOM = *mut _XOM; +pub type XrmDatabase = *mut _XrmHashBucketRec; +pub type XrmOptionDescList = *mut XrmOptionDescRec; + +// function pointers +pub type XConnectionWatchProc = Option<unsafe extern "C" fn (*mut Display, XPointer, c_int, Bool, XPointer)>; +pub type XIMProc = Option<unsafe extern "C" fn (XIM, XPointer, XPointer)>; +pub type XICProc = Option<unsafe extern "C" fn (XIC, XPointer, XPointer) -> Bool>; + +// C enums +pub type XICCEncodingStyle = c_int; +pub type XOrientation = c_int; +pub type XrmBinding = c_int; +pub type XrmOptionKind = c_int; + +#[allow(dead_code)] +#[cfg(test)] +#[repr(C)] +enum TestEnum { + Variant1, + Variant2, +} + +#[test] +fn enum_size_test () { + assert!(::std::mem::size_of::<TestEnum>() == ::std::mem::size_of::<c_int>()); +} + + +// +// event structures +// + + +#[derive(Clone, Copy)] +#[repr(C)] +pub union XEvent { + pub type_: c_int, + pub any: XAnyEvent, + pub button: XButtonEvent, + pub circulate: XCirculateEvent, + pub circulate_request: XCirculateRequestEvent, + pub client_message: XClientMessageEvent, + pub colormap: XColormapEvent, + pub configure: XConfigureEvent, + pub configure_request: XConfigureRequestEvent, + pub create_window: XCreateWindowEvent, + pub crossing: XCrossingEvent, + pub destroy_window: XDestroyWindowEvent, + pub error: XErrorEvent, + pub expose: XExposeEvent, + pub focus_change: XFocusChangeEvent, + pub generic_event_cookie: XGenericEventCookie, + pub graphics_expose: XGraphicsExposeEvent, + pub gravity: XGravityEvent, + pub key: XKeyEvent, + pub keymap: XKeymapEvent, + pub map: XMapEvent, + pub mapping: XMappingEvent, + pub map_request: XMapRequestEvent, + pub motion: XMotionEvent, + pub no_expose: XNoExposeEvent, + pub property: XPropertyEvent, + pub reparent: XReparentEvent, + pub resize_request: XResizeRequestEvent, + pub selection_clear: XSelectionClearEvent, + pub selection: XSelectionEvent, + pub selection_request: XSelectionRequestEvent, + pub unmap: XUnmapEvent, + pub visibility: XVisibilityEvent, + pub pad: [c_long; 24], + // xf86vidmode + pub xf86vm_notify: xf86vmode::XF86VidModeNotifyEvent, + // xrandr + pub xrr_screen_change_notify: xrandr::XRRScreenChangeNotifyEvent, + pub xrr_notify: xrandr::XRRNotifyEvent, + pub xrr_output_change_notify: xrandr::XRROutputChangeNotifyEvent, + pub xrr_crtc_change_notify: xrandr::XRRCrtcChangeNotifyEvent, + pub xrr_output_property_notify: xrandr::XRROutputPropertyNotifyEvent, + pub xrr_provider_change_notify: xrandr::XRRProviderChangeNotifyEvent, + pub xrr_provider_property_notify: xrandr::XRRProviderPropertyNotifyEvent, + pub xrr_resource_change_notify: xrandr::XRRResourceChangeNotifyEvent, + // xscreensaver + pub xss_notify: xss::XScreenSaverNotifyEvent, +} + +impl XEvent { + pub fn get_type (&self) -> c_int { + unsafe { + self.type_ + } + } +} + +impl fmt::Debug for XEvent { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut d = f.debug_struct("XEvent"); + unsafe { + match self.type_ { + KeyPress => d.field("key", &self.key), + KeyRelease => d.field("key", &self.key), + ButtonPress => d.field("button", &self.button), + ButtonRelease => d.field("button", &self.button), + MotionNotify => d.field("motion", &self.motion), + EnterNotify => d.field("crossing", &self.crossing), + LeaveNotify => d.field("crossing", &self.crossing), + FocusIn => d.field("focus_change", &self.focus_change), + FocusOut => d.field("focus_change", &self.focus_change), + KeymapNotify => d.field("keymap", &self.keymap), + Expose => d.field("expose", &self.expose), + GraphicsExpose => d.field("graphics_expose", &self.graphics_expose), + NoExpose => d.field("no_expose", &self.no_expose), + VisibilityNotify => d.field("visibility", &self.visibility), + CreateNotify => d.field("create_window", &self.create_window), + DestroyNotify => d.field("destroy_window", &self.destroy_window), + UnmapNotify => d.field("unmap", &self.unmap), + MapNotify => d.field("map", &self.map), + MapRequest => d.field("map_request", &self.map_request), + ReparentNotify => d.field("reparent", &self.reparent), + ConfigureNotify => d.field("configure", &self.configure), + ConfigureRequest => d.field("configure_request", &self.configure_request), + GravityNotify => d.field("gravity", &self.gravity), + ResizeRequest => d.field("resize_request", &self.resize_request), + CirculateNotify => d.field("circulate", &self.circulate), + CirculateRequest => d.field("circulate_request", &self.circulate_request), + PropertyNotify => d.field("property", &self.property), + SelectionClear => d.field("selection_clear", &self.selection_clear), + SelectionRequest => d.field("selection_request", &self.selection_request), + SelectionNotify => d.field("selection", &self.selection), + ColormapNotify => d.field("colormap", &self.colormap), + ClientMessage => d.field("client_message", &self.client_message), + MappingNotify => d.field("mapping", &self.mapping), + GenericEvent => d.field("generic_event_cookie", &self.generic_event_cookie), + _ => d.field("any", &self.any), + } + }.finish() + } +} + +macro_rules! event_conversions_and_tests { + { $($field:ident: $ty:ty,)* } => { + #[test] + fn xevent_size_test () { + use std::mem::size_of; + let xevent_size = size_of::<XEvent>(); + $(assert!(xevent_size >= size_of::<$ty>());)* + } + + $( + impl AsMut<$ty> for XEvent { + fn as_mut (&mut self) -> &mut $ty { + unsafe { &mut self.$field } + } + } + + impl AsRef<$ty> for XEvent { + fn as_ref (&self) -> &$ty { + unsafe { &self.$field } + } + } + + impl From<$ty> for XEvent { + fn from (other: $ty) -> XEvent { + XEvent{ $field: other } + } + } + + impl<'a> From<&'a $ty> for XEvent { + fn from (other: &'a $ty) -> XEvent { + XEvent{ $field: other.clone() } + } + } + + impl From<XEvent> for $ty { + fn from (xevent: XEvent) -> $ty { + unsafe { xevent.$field } + } + } + + impl<'a> From<&'a XEvent> for $ty { + fn from (xevent: &'a XEvent) -> $ty { + unsafe { xevent.$field } + } + } + )* + }; +} + +event_conversions_and_tests! { + any: XAnyEvent, + button: XButtonEvent, + circulate: XCirculateEvent, + circulate_request: XCirculateRequestEvent, + client_message: XClientMessageEvent, + colormap: XColormapEvent, + configure: XConfigureEvent, + configure_request: XConfigureRequestEvent, + create_window: XCreateWindowEvent, + crossing: XCrossingEvent, + destroy_window: XDestroyWindowEvent, + error: XErrorEvent, + expose: XExposeEvent, + focus_change: XFocusChangeEvent, + generic_event_cookie: XGenericEventCookie, + graphics_expose: XGraphicsExposeEvent, + gravity: XGravityEvent, + key: XKeyEvent, + keymap: XKeymapEvent, + map: XMapEvent, + mapping: XMappingEvent, + map_request: XMapRequestEvent, + motion: XMotionEvent, + no_expose: XNoExposeEvent, + property: XPropertyEvent, + reparent: XReparentEvent, + resize_request: XResizeRequestEvent, + selection_clear: XSelectionClearEvent, + selection: XSelectionEvent, + selection_request: XSelectionRequestEvent, + unmap: XUnmapEvent, + visibility: XVisibilityEvent, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XAnyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XButtonEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub root: Window, + pub subwindow: Window, + pub time: Time, + pub x: c_int, + pub y: c_int, + pub x_root: c_int, + pub y_root: c_int, + pub state: c_uint, + pub button: c_uint, + pub same_screen: Bool, +} +pub type XButtonPressedEvent = XButtonEvent; +pub type XButtonReleasedEvent = XButtonEvent; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XCirculateEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub event: Window, + pub window: Window, + pub place: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XCirculateRequestEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub parent: Window, + pub window: Window, + pub place: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XClientMessageEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub message_type: Atom, + pub format: c_int, + pub data: ClientMessageData, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XColormapEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub colormap: Colormap, + pub new: Bool, + pub state: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XConfigureEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub event: Window, + pub window: Window, + pub x: c_int, + pub y: c_int, + pub width: c_int, + pub height: c_int, + pub border_width: c_int, + pub above: Window, + pub override_redirect: Bool, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XConfigureRequestEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub parent: Window, + pub window: Window, + pub x: c_int, + pub y: c_int, + pub width: c_int, + pub height: c_int, + pub border_width: c_int, + pub above: Window, + pub detail: c_int, + pub value_mask: c_ulong, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XCreateWindowEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub parent: Window, + pub window: Window, + pub x: c_int, + pub y: c_int, + pub width: c_int, + pub height: c_int, + pub border_width: c_int, + pub override_redirect: Bool, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XCrossingEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub root: Window, + pub subwindow: Window, + pub time: Time, + pub x: c_int, + pub y: c_int, + pub x_root: c_int, + pub y_root: c_int, + pub mode: c_int, + pub detail: c_int, + pub same_screen: Bool, + pub focus: Bool, + pub state: c_uint, +} +pub type XEnterWindowEvent = XCrossingEvent; +pub type XLeaveWindowEvent = XCrossingEvent; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XDestroyWindowEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub event: Window, + pub window: Window, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XErrorEvent { + pub type_: c_int, + pub display: *mut Display, + pub resourceid: XID, + pub serial: c_ulong, + pub error_code: c_uchar, + pub request_code: c_uchar, + pub minor_code: c_uchar, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XExposeEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub x: c_int, + pub y: c_int, + pub width: c_int, + pub height: c_int, + pub count: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XFocusChangeEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub mode: c_int, + pub detail: c_int, +} +pub type XFocusInEvent = XFocusChangeEvent; +pub type XFocusOutEvent = XFocusChangeEvent; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XGraphicsExposeEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub drawable: Drawable, + pub x: c_int, + pub y: c_int, + pub width: c_int, + pub height: c_int, + pub count: c_int, + pub major_code: c_int, + pub minor_code: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XGravityEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub event: Window, + pub window: Window, + pub x: c_int, + pub y: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XKeyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub root: Window, + pub subwindow: Window, + pub time: Time, + pub x: c_int, + pub y: c_int, + pub x_root: c_int, + pub y_root: c_int, + pub state: c_uint, + pub keycode: c_uint, + pub same_screen: Bool, +} +pub type XKeyPressedEvent = XKeyEvent; +pub type XKeyReleasedEvent = XKeyEvent; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XKeymapEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub key_vector: [c_char; 32], +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XMapEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub event: Window, + pub window: Window, + pub override_redirect: Bool, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XMappingEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub event: Window, + pub request: c_int, + pub first_keycode: c_int, + pub count: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XMapRequestEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub parent: Window, + pub window: Window, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XMotionEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub root: Window, + pub subwindow: Window, + pub time: Time, + pub x: c_int, + pub y: c_int, + pub x_root: c_int, + pub y_root: c_int, + pub state: c_uint, + pub is_hint: c_char, + pub same_screen: Bool, +} +pub type XPointerMovedEvent = XMotionEvent; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XNoExposeEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub drawable: Drawable, + pub major_code: c_int, + pub minor_code: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XPropertyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub atom: Atom, + pub time: Time, + pub state: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XReparentEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub event: Window, + pub window: Window, + pub parent: Window, + pub x: c_int, + pub y: c_int, + pub override_redirect: Bool, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XResizeRequestEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub width: c_int, + pub height: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XSelectionClearEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub selection: Atom, + pub time: Time, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XSelectionEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub requestor: Window, + pub selection: Atom, + pub target: Atom, + pub property: Atom, + pub time: Time, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XSelectionRequestEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub owner: Window, + pub requestor: Window, + pub selection: Atom, + pub target: Atom, + pub property: Atom, + pub time: Time, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XUnmapEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub event: Window, + pub window: Window, + pub from_configure: Bool, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XVisibilityEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub state: c_int, +} + + +// +// Xkb structs +// + + +#[repr(C)] +pub struct _XkbCompatMapRec { + pub sym_interpret: XkbSymInterpretPtr, + pub groups: [XkbModsRec; XkbNumKbdGroups], + pub num_si: c_ushort, + pub size_si: c_ushort, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XkbDesc { + pub dpy: *mut Display, + pub flags: c_ushort, + pub device_spec: c_ushort, + pub min_key_code: KeyCode, + pub max_key_code: KeyCode, + pub ctrls: XkbControlsPtr, + pub server: XkbServerMapPtr, + pub map: XkbClientMapPtr, + pub indicators: XkbIndicatorPtr, + pub names: XkbNamesPtr, + pub compat: XkbCompatMapPtr, + pub geom: XkbGeometryPtr, +} + +#[repr(C)] +pub struct _XkbIndicatorRec { + pub phys_indicators: c_ulong, + pub maps: [XkbIndicatorMapRec; XkbNumIndicators], +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XkbKeyAliasRec { + pub real: [c_char; XkbKeyNameLength], + pub alias: [c_char; XkbKeyNameLength], +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XkbKeyNameRec { + pub name: [c_char; XkbKeyNameLength], +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XkbNamesRec { + pub keycodes: Atom, + pub geometry: Atom, + pub symbols: Atom, + pub types: Atom, + pub compat: Atom, + pub vmods: [Atom; XkbNumVirtualMods], + pub indicators: [Atom; XkbNumIndicators], + pub groups: [Atom; XkbNumKbdGroups], + pub keys: XkbKeyNamePtr, + pub key_aliases: XkbKeyAliasPtr, + pub radio_groups: *mut Atom, + pub phys_symbols: Atom, + pub num_keys: c_uchar, + pub num_key_aliases: c_uchar, + pub num_rg: c_ushort, +} + + +// +// Xkb event structs +// + + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XkbAnyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_uint, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XkbNewKeyboardNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub old_device: c_int, + pub min_key_code: c_int, + pub max_key_code: c_int, + pub old_min_key_code: c_int, + pub old_max_key_code: c_int, + pub changed: c_uint, + pub req_major: c_char, + pub req_minor: c_char, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XkbMapNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub changed: c_uint, + pub flags: c_uint, + pub first_type: c_int, + pub num_types: c_int, + pub min_key_code: KeyCode, + pub max_key_code: KeyCode, + pub first_key_sym: KeyCode, + pub first_key_act: KeyCode, + pub first_key_bahavior: KeyCode, + pub first_key_explicit: KeyCode, + pub first_modmap_key: KeyCode, + pub first_vmodmap_key: KeyCode, + pub num_key_syms: c_int, + pub num_key_acts: c_int, + pub num_key_behaviors: c_int, + pub num_key_explicit: c_int, + pub num_modmap_keys: c_int, + pub num_vmodmap_keys: c_int, + pub vmods: c_uint, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XkbStateNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub changed: c_uint, + pub group: c_int, + pub base_group: c_int, + pub latched_group: c_int, + pub locked_group: c_int, + pub mods: c_uint, + pub base_mods: c_uint, + pub latched_mods: c_uint, + pub locked_mods: c_uint, + pub compat_state: c_int, + pub grab_mods: c_uchar, + pub compat_grab_mods: c_uchar, + pub lookup_mods: c_uchar, + pub compat_lookup_mods: c_uchar, + pub ptr_buttons: c_int, + pub keycode: KeyCode, + pub event_type: c_char, + pub req_major: c_char, + pub req_minor: c_char, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XkbControlsNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub changed_ctrls: c_uint, + pub enabled_ctrls: c_uint, + pub enabled_ctrl_changes: c_uint, + pub num_groups: c_int, + pub keycode: KeyCode, + pub event_type: c_char, + pub req_major: c_char, + pub req_minor: c_char, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XkbIndicatorNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub changed: c_uint, + pub state: c_uint, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XkbNamesNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub changed: c_uint, + pub first_type: c_int, + pub num_types: c_int, + pub first_lvl: c_int, + pub num_lvls: c_int, + pub num_aliases: c_int, + pub num_radio_groups: c_int, + pub changed_vmods: c_uint, + pub changed_groups: c_uint, + pub changed_indicators: c_uint, + pub first_key: c_int, + pub num_keys: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XkbCompatMapNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub changed_groups: c_uint, + pub first_si: c_int, + pub num_si: c_int, + pub num_total_si: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XkbBellNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub percent: c_int, + pub pitch: c_int, + pub duration: c_int, + pub bell_class: c_int, + pub bell_id: c_int, + pub name: Atom, + pub window: Window, + pub event_only: Bool, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XkbActionMessageEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub keycode: KeyCode, + pub press: Bool, + pub key_event_follows: Bool, + pub group: c_int, + pub mods: c_uint, + pub message: [c_char; XkbActionMessageLength + 1], +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XkbAccessXNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub detail: c_int, + pub keycode: c_int, + pub sk_delay: c_int, + pub debounce_delay: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XkbExtensionDeviceNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub time: Time, + pub xkb_type: c_int, + pub device: c_int, + pub reason: c_uint, + pub supported: c_uint, + pub unsupported: c_uint, + pub first_btn: c_int, + pub num_btns: c_int, + pub leds_defined: c_uint, + pub led_state: c_uint, + pub led_class: c_int, + pub led_id: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XkbEvent { + _pad: [c_long; 24], +} + +#[cfg(test)] +macro_rules! test_xkb_event_size { + { $($ty:ty,)* } => { $( + assert!(::std::mem::size_of::<XkbEvent>() >= ::std::mem::size_of::<$ty>()); + )* }; +} + +#[test] +fn xkb_event_size_test () { + test_xkb_event_size! { + XkbAnyEvent, + XkbNewKeyboardNotifyEvent, + XkbMapNotifyEvent, + XkbStateNotifyEvent, + XkbControlsNotifyEvent, + XkbIndicatorNotifyEvent, + XkbNamesNotifyEvent, + XkbCompatMapNotifyEvent, + XkbBellNotifyEvent, + XkbActionMessageEvent, + XkbAccessXNotifyEvent, + XkbExtensionDeviceNotifyEvent, + } +} + +pub enum XkbKbdDpyStateRec {} +pub type XkbKbdDpyStatePtr = *mut XkbKbdDpyStateRec; + + +// +// other structures +// + + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct Depth { + pub depth: c_int, + pub nvisuals: c_int, + pub visuals: *mut Visual, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct Screen { + pub ext_data: *mut XExtData, + pub display: *mut Display, + pub root: Window, + pub width: c_int, + pub height: c_int, + pub mwidth: c_int, + pub mheight: c_int, + pub ndepths: c_int, + pub depths: *mut Depth, + pub root_depth: c_int, + pub root_visual: *mut Visual, + pub default_gc: GC, + pub cmap: Colormap, + pub white_pixel: c_ulong, + pub black_pixel: c_ulong, + pub max_maps: c_int, + pub min_maps: c_int, + pub backing_store: c_int, + pub save_unders: Bool, + pub root_input_mask: c_long, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct ScreenFormat { + pub ext_data: *mut XExtData, + pub depth: c_int, + pub bits_per_pixel: c_int, + pub scanline_pad: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct Visual { + pub ext_data: *mut XExtData, + pub visualid: VisualID, + pub class: c_int, + pub red_mask: c_ulong, + pub green_mask: c_ulong, + pub blue_mask: c_ulong, + pub bits_per_rgb: c_int, + pub map_entries: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XArc { + pub x: c_short, + pub y: c_short, + pub width: c_ushort, + pub height: c_ushort, + pub angle1: c_short, + pub angle2: c_short, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XChar2b { + pub byte1: c_uchar, + pub byte2: c_uchar, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XCharStruct { + pub lbearing: c_short, + pub rbearing: c_short, + pub width: c_short, + pub ascent: c_short, + pub descent: c_short, + pub attributes: c_ushort, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XClassHint { + pub res_name: *mut c_char, + pub res_class: *mut c_char, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XColor { + pub pixel: c_ulong, + pub red: c_ushort, + pub green: c_ushort, + pub blue: c_ushort, + pub flags: c_char, + pub pad: c_char, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XComposeStatus { + pub compose_ptr: XPointer, + pub chars_matched: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XExtCodes { + pub extension: c_int, + pub major_opcode: c_int, + pub first_event: c_int, + pub first_error: c_int, +} + +#[repr(C)] +pub struct XExtData { + pub number: c_int, + pub next: *mut XExtData, + pub free_private: Option<unsafe extern "C" fn () -> c_int>, + pub private_data: XPointer, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XFontProp { + pub name: Atom, + pub card32: c_ulong, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XFontSetExtents { + pub max_ink_extent: XRectangle, + pub max_logical_extent: XRectangle, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XFontStruct { + pub ext_data: *mut XExtData, + pub fid: Font, + pub direction: c_uint, + pub min_char_or_byte2: c_uint, + pub max_char_or_byte2: c_uint, + pub min_byte1: c_uint, + pub max_byte1: c_uint, + pub all_chars_exist: Bool, + pub default_char: c_uint, + pub n_properties: c_int, + pub properties: *mut XFontProp, + pub min_bounds: XCharStruct, + pub max_bounds: XCharStruct, + pub per_char: *mut XCharStruct, + pub ascent: c_int, + pub descent: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XGCValues { + pub function: c_int, + pub plane_mask: c_ulong, + pub foreground: c_ulong, + pub background: c_ulong, + pub line_width: c_int, + pub line_style: c_int, + pub cap_style: c_int, + pub join_style: c_int, + pub fill_style: c_int, + pub fill_rule: c_int, + pub arc_mode: c_int, + pub tile: Pixmap, + pub stipple: Pixmap, + pub ts_x_origin: c_int, + pub ts_y_origin: c_int, + pub font: Font, + pub subwindow_mode: c_int, + pub graphics_exposures: Bool, + pub clip_x_origin: c_int, + pub clip_y_origin: c_int, + pub clip_mask: Pixmap, + pub dash_offset: c_int, + pub dashes: c_char, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XGenericEventCookie { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub extension: c_int, + pub evtype: c_int, + pub cookie: c_uint, + pub data: *mut c_void, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XHostAddress { + pub family: c_int, + pub length: c_int, + pub address: *mut c_char, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XIconSize { + pub min_width: c_int, + pub min_height: c_int, + pub max_width: c_int, + pub max_height: c_int, + pub width_inc: c_int, + pub height_inc: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XImage { + pub width: c_int, + pub height: c_int, + pub xoffset: c_int, + pub format: c_int, + pub data: *mut c_char, + pub byte_order: c_int, + pub bitmap_unit: c_int, + pub bitmap_bit_order: c_int, + pub bitmap_pad: c_int, + pub depth: c_int, + pub bytes_per_line: c_int, + pub bits_per_pixel: c_int, + pub red_mask: c_ulong, + pub green_mask: c_ulong, + pub blue_mask: c_ulong, + pub obdata: XPointer, + pub funcs: ImageFns, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XKeyboardControl { + pub key_click_percent: c_int, + pub bell_percent: c_int, + pub bell_pitch: c_int, + pub bell_duration: c_int, + pub led: c_int, + pub led_mode: c_int, + pub key: c_int, + pub auto_repeat_mode: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XKeyboardState { + pub key_click_percent: c_int, + pub bell_percent: c_int, + pub bell_pitch: c_uint, + pub bell_duration: c_uint, + pub led_mask: c_ulong, + pub global_auto_repeat: c_int, + pub auto_repeats: [c_char; 32], +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XmbTextItem { + pub chars: *mut c_char, + pub nchars: c_int, + pub delta: c_int, + pub font_set: XFontSet, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XModifierKeymap { + pub max_keypermod: c_int, + pub modifiermap: *mut KeyCode, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XOMCharSetList { + pub charset_count: c_int, + pub charset_list: *mut *mut c_char, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XPixmapFormatValues { + pub depth: c_int, + pub bits_per_pixel: c_int, + pub scanline_pad: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XPoint { + pub x: c_short, + pub y: c_short, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRectangle { + pub x: c_short, + pub y: c_short, + pub width: c_ushort, + pub height: c_ushort, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XrmOptionDescRec { + pub option: *mut c_char, + pub specifier: *mut c_char, + pub argKind: XrmOptionKind, + pub value: XPointer, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XrmValue { + pub size: c_uint, + pub addr: XPointer, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XSegment { + pub x1: c_short, + pub y1: c_short, + pub x2: c_short, + pub y2: c_short, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XSetWindowAttributes { + pub background_pixmap: Pixmap, + pub background_pixel: c_ulong, + pub border_pixmap: Pixmap, + pub border_pixel: c_ulong, + pub bit_gravity: c_int, + pub win_gravity: c_int, + pub backing_store: c_int, + pub backing_planes: c_ulong, + pub backing_pixel: c_ulong, + pub save_under: Bool, + pub event_mask: c_long, + pub do_not_propagate_mask: c_long, + pub override_redirect: Bool, + pub colormap: Colormap, + pub cursor: Cursor, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XSizeHints { + pub flags: c_long, + pub x: c_int, + pub y: c_int, + pub width: c_int, + pub height: c_int, + pub min_width: c_int, + pub min_height: c_int, + pub max_width: c_int, + pub max_height: c_int, + pub width_inc: c_int, + pub height_inc: c_int, + pub min_aspect: AspectRatio, + pub max_aspect: AspectRatio, + pub base_width: c_int, + pub base_height: c_int, + pub win_gravity: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XStandardColormap { + pub colormap: Colormap, + pub red_max: c_ulong, + pub red_mult: c_ulong, + pub green_max: c_ulong, + pub green_mult: c_ulong, + pub blue_max: c_ulong, + pub blue_mult: c_ulong, + pub base_pixel: c_ulong, + pub visualid: VisualID, + pub killid: XID, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XTextItem { + pub chars: *mut c_char, + pub nchars: c_int, + pub delta: c_int, + pub font: Font, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XTextItem16 { + pub chars: *mut XChar2b, + pub nchars: c_int, + pub delta: c_int, + pub font: Font, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XTextProperty { + pub value: *mut c_uchar, + pub encoding: Atom, + pub format: c_int, + pub nitems: c_ulong, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XTimeCoord { + pub time: Time, + pub x: c_short, + pub y: c_short, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XVisualInfo { + pub visual: *mut Visual, + pub visualid: VisualID, + pub screen: c_int, + pub depth: c_int, + pub class: c_int, + pub red_mask: c_ulong, + pub green_mask: c_ulong, + pub blue_mask: c_ulong, + pub colormap_size: c_int, + pub bits_per_rgb: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XwcTextItem { + pub chars: *mut wchar_t, + pub nchars: c_int, + pub delta: c_int, + pub font_set: XFontSet, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XWindowAttributes { + pub x: c_int, + pub y: c_int, + pub width: c_int, + pub height: c_int, + pub border_width: c_int, + pub depth: c_int, + pub visual: *mut Visual, + pub root: Window, + pub class: c_int, + pub bit_gravity: c_int, + pub win_gravity: c_int, + pub backing_store: c_int, + pub backing_planes: c_ulong, + pub backing_pixel: c_ulong, + pub save_under: Bool, + pub colormap: Colormap, + pub map_installed: Bool, + pub map_state: c_int, + pub all_event_masks: c_long, + pub your_event_mask: c_long, + pub do_not_propagate_mask: c_long, + pub override_redirect: Bool, + pub screen: *mut Screen, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XWindowChanges { + pub x: c_int, + pub y: c_int, + pub width: c_int, + pub height: c_int, + pub border_width: c_int, + pub sibling: Window, + pub stack_mode: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XWMHints { + pub flags: c_long, + pub input: Bool, + pub initial_state: c_int, + pub icon_pixmap: Pixmap, + pub icon_window: Window, + pub icon_x: c_int, + pub icon_y: c_int, + pub icon_mask: Pixmap, + pub window_group: XID, +} + +#[repr(C)] +pub struct XIMCallback { + pub client_data: XPointer, + pub callback: XIMProc, +} + +#[repr(C)] +pub struct XICCallback { + pub client_data: XPointer, + pub callback: XICProc, +} + +// +// anonymous structures +// + + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct AspectRatio { + pub x: c_int, + pub y: c_int, +} + +#[derive(Debug, Clone, Copy, Default, PartialEq)] +#[repr(C)] +pub struct ClientMessageData { + longs: [c_long; 5], +} + +impl ClientMessageData { + pub fn as_bytes (&self) -> &[c_char] { + self.as_ref() + } + + pub fn as_bytes_mut (&mut self) -> &mut [c_char] { + self.as_mut() + } + + pub fn as_longs (&self) -> &[c_long] { + self.as_ref() + } + + pub fn as_longs_mut (&mut self) -> &mut [c_long] { + self.as_mut() + } + + pub fn as_shorts (&self) -> &[c_short] { + self.as_ref() + } + + pub fn as_shorts_mut (&mut self) -> &mut [c_short] { + self.as_mut() + } + + pub fn get_byte (&self, index: usize) -> c_char { + self.as_bytes()[index] + } + + pub fn get_long (&self, index: usize) -> c_long { + self.longs[index] + } + + pub fn get_short (&self, index: usize) -> c_short { + self.as_shorts()[index] + } + + pub fn new() -> ClientMessageData { + ClientMessageData { longs: [0; 5] } + } + + pub fn set_byte (&mut self, index: usize, value: c_char) { + self.as_bytes_mut()[index] = value; + } + + pub fn set_long (&mut self, index: usize, value: c_long) { + self.longs[index] = value; + } + + pub fn set_short (&mut self, index: usize, value: c_short) { + self.as_shorts_mut()[index] = value; + } +} + +macro_rules! client_message_data_conversions { + { $($ty:ty[$n:expr],)* } => { + $( + impl AsMut<[$ty]> for ClientMessageData { + fn as_mut (&mut self) -> &mut [$ty] { + unsafe { slice::from_raw_parts_mut(self.longs.as_mut_ptr() as *mut $ty, $n) } + } + } + + impl AsRef<[$ty]> for ClientMessageData { + fn as_ref (&self) -> &[$ty] { + unsafe { slice::from_raw_parts(self.longs.as_ptr() as *mut $ty, $n) } + } + } + + impl From<[$ty; $n]> for ClientMessageData { + fn from (array: [$ty; $n]) -> ClientMessageData { + unsafe { transmute_union(&array) } + } + } + )* + }; +} + +client_message_data_conversions! { + c_schar[20], + c_uchar[20], + c_short[10], + c_ushort[10], + c_long[5], + c_ulong[5], +} + +#[test] +fn client_message_size_test () { + assert!(::std::mem::size_of::<ClientMessageData>() >= ::std::mem::size_of::<[c_char; 20]>()); + assert!(::std::mem::size_of::<ClientMessageData>() >= ::std::mem::size_of::<[c_short; 10]>()); +} + +#[derive(Debug, Copy)] +#[repr(C)] +pub struct ImageFns { + pub create_image: Option<unsafe extern "C" fn (*mut Display, *mut Visual, c_uint, c_int, c_int, *mut c_char, c_uint, c_uint, c_int, c_int) -> *mut XImage>, + pub destroy_image: Option<unsafe extern "C" fn (*mut XImage) -> c_int>, + pub get_pixel: Option<unsafe extern "C" fn (*mut XImage, c_int, c_int) -> c_ulong>, + pub put_pixel: Option<unsafe extern "C" fn (*mut XImage, c_int, c_int, c_ulong) -> c_int>, + pub sub_image: Option<unsafe extern "C" fn (*mut XImage, c_int, c_int, c_uint, c_uint) -> *mut XImage>, + pub add_pixel: Option<unsafe extern "C" fn (*mut XImage, c_long) -> c_int>, +} + +impl Clone for ImageFns { + fn clone (&self) -> ImageFns { + *self + } +} + +impl PartialEq for ImageFns { + fn eq (&self, rhs: &ImageFns) -> bool { + unsafe { mem_eq(self, rhs) } + } +} + + +// +// constants +// + + +// allocate colormap +pub const AllocNone: c_int = 0; +pub const AllocAll: c_int = 1; + +// array sizes +pub const XkbKeyNameLength: usize = 4; +pub const XkbNumIndicators: usize = 32; +pub const XkbNumKbdGroups: usize = 4; +pub const XkbNumVirtualMods: usize = 16; + +// atoms +pub const XA_PRIMARY: Atom = 1; +pub const XA_SECONDARY: Atom = 2; +pub const XA_ARC: Atom = 3; +pub const XA_ATOM: Atom = 4; +pub const XA_BITMAP: Atom = 5; +pub const XA_CARDINAL: Atom = 6; +pub const XA_COLORMAP: Atom = 7; +pub const XA_CURSOR: Atom = 8; +pub const XA_CUT_BUFFER0: Atom = 9; +pub const XA_CUT_BUFFER1: Atom = 10; +pub const XA_CUT_BUFFER2: Atom = 11; +pub const XA_CUT_BUFFER3: Atom = 12; +pub const XA_CUT_BUFFER4: Atom = 13; +pub const XA_CUT_BUFFER5: Atom = 14; +pub const XA_CUT_BUFFER6: Atom = 15; +pub const XA_CUT_BUFFER7: Atom = 16; +pub const XA_DRAWABLE: Atom = 17; +pub const XA_FONT: Atom = 18; +pub const XA_INTEGER: Atom = 19; +pub const XA_PIXMAP: Atom = 20; +pub const XA_POINT: Atom = 21; +pub const XA_RECTANGLE: Atom = 22; +pub const XA_RESOURCE_MANAGER: Atom = 23; +pub const XA_RGB_COLOR_MAP: Atom = 24; +pub const XA_RGB_BEST_MAP: Atom = 25; +pub const XA_RGB_BLUE_MAP: Atom = 26; +pub const XA_RGB_DEFAULT_MAP: Atom = 27; +pub const XA_RGB_GRAY_MAP: Atom = 28; +pub const XA_RGB_GREEN_MAP: Atom = 29; +pub const XA_RGB_RED_MAP: Atom = 30; +pub const XA_STRING: Atom = 31; +pub const XA_VISUALID: Atom = 32; +pub const XA_WINDOW: Atom = 33; +pub const XA_WM_COMMAND: Atom = 34; +pub const XA_WM_HINTS: Atom = 35; +pub const XA_WM_CLIENT_MACHINE: Atom = 36; +pub const XA_WM_ICON_NAME: Atom = 37; +pub const XA_WM_ICON_SIZE: Atom = 38; +pub const XA_WM_NAME: Atom = 39; +pub const XA_WM_NORMAL_HINTS: Atom = 40; +pub const XA_WM_SIZE_HINTS: Atom = 41; +pub const XA_WM_ZOOM_HINTS: Atom = 42; +pub const XA_MIN_SPACE: Atom = 43; +pub const XA_NORM_SPACE: Atom = 44; +pub const XA_MAX_SPACE: Atom = 45; +pub const XA_END_SPACE: Atom = 46; +pub const XA_SUPERSCRIPT_X: Atom = 47; +pub const XA_SUPERSCRIPT_Y: Atom = 48; +pub const XA_SUBSCRIPT_X: Atom = 49; +pub const XA_SUBSCRIPT_Y: Atom = 50; +pub const XA_UNDERLINE_POSITION: Atom = 51; +pub const XA_UNDERLINE_THICKNESS: Atom = 52; +pub const XA_STRIKEOUT_ASCENT: Atom = 53; +pub const XA_STRIKEOUT_DESCENT: Atom = 54; +pub const XA_ITALIC_ANGLE: Atom = 55; +pub const XA_X_HEIGHT: Atom = 56; +pub const XA_QUAD_WIDTH: Atom = 57; +pub const XA_WEIGHT: Atom = 58; +pub const XA_POINT_SIZE: Atom = 59; +pub const XA_RESOLUTION: Atom = 60; +pub const XA_COPYRIGHT: Atom = 61; +pub const XA_NOTICE: Atom = 62; +pub const XA_FONT_NAME: Atom = 63; +pub const XA_FAMILY_NAME: Atom = 64; +pub const XA_FULL_NAME: Atom = 65; +pub const XA_CAP_HEIGHT: Atom = 66; +pub const XA_WM_CLASS: Atom = 67; +pub const XA_WM_TRANSIENT_FOR: Atom = 68; + +// boolean values +pub const False: Bool = 0; +pub const True: Bool = 1; + +// clip rect ordering +pub const Unsorted: c_int = 0; +pub const YSorted: c_int = 1; +pub const YXSorted: c_int = 2; +pub const YXBanded: c_int = 3; + +// color component mask +pub const DoRed: c_char = 1; +pub const DoGreen: c_char = 2; +pub const DoBlue: c_char = 4; + +// error codes +pub const Success: c_uchar = 0; +pub const BadRequest: c_uchar = 1; +pub const BadValue: c_uchar = 2; +pub const BadWindow: c_uchar = 3; +pub const BadPixmap: c_uchar = 4; +pub const BadAtom: c_uchar = 5; +pub const BadCursor: c_uchar = 6; +pub const BadFont: c_uchar = 7; +pub const BadMatch: c_uchar = 8; +pub const BadDrawable: c_uchar = 9; +pub const BadAccess: c_uchar = 10; +pub const BadAlloc: c_uchar = 11; +pub const BadColor: c_uchar = 12; +pub const BadGC: c_uchar = 13; +pub const BadIDChoice: c_uchar = 14; +pub const BadName: c_uchar = 15; +pub const BadLength: c_uchar = 16; +pub const BadImplementation: c_uchar = 17; +pub const FirstExtensionError: c_uchar = 128; +pub const LastExtensionError: c_uchar = 255; + +// event kinds +pub const KeyPress: c_int = 2; +pub const KeyRelease: c_int = 3; +pub const ButtonPress: c_int = 4; +pub const ButtonRelease: c_int = 5; +pub const MotionNotify: c_int = 6; +pub const EnterNotify: c_int = 7; +pub const LeaveNotify: c_int = 8; +pub const FocusIn: c_int = 9; +pub const FocusOut: c_int = 10; +pub const KeymapNotify: c_int = 11; +pub const Expose: c_int = 12; +pub const GraphicsExpose: c_int = 13; +pub const NoExpose: c_int = 14; +pub const VisibilityNotify: c_int = 15; +pub const CreateNotify: c_int = 16; +pub const DestroyNotify: c_int = 17; +pub const UnmapNotify: c_int = 18; +pub const MapNotify: c_int = 19; +pub const MapRequest: c_int = 20; +pub const ReparentNotify: c_int = 21; +pub const ConfigureNotify: c_int = 22; +pub const ConfigureRequest: c_int = 23; +pub const GravityNotify: c_int = 24; +pub const ResizeRequest: c_int = 25; +pub const CirculateNotify: c_int = 26; +pub const CirculateRequest: c_int = 27; +pub const PropertyNotify: c_int = 28; +pub const SelectionClear: c_int = 29; +pub const SelectionRequest: c_int = 30; +pub const SelectionNotify: c_int = 31; +pub const ColormapNotify: c_int = 32; +pub const ClientMessage: c_int = 33; +pub const MappingNotify: c_int = 34; +pub const GenericEvent: c_int = 35; +pub const LASTEvent: c_int = 36; + +// event mask +pub const NoEventMask: c_long = 0; +pub const KeyPressMask: c_long = 0x0000_0001; +pub const KeyReleaseMask: c_long = 0x0000_0002; +pub const ButtonPressMask: c_long = 0x0000_0004; +pub const ButtonReleaseMask: c_long = 0x0000_0008; +pub const EnterWindowMask: c_long = 0x0000_0010; +pub const LeaveWindowMask: c_long = 0x0000_0020; +pub const PointerMotionMask: c_long = 0x0000_0040; +pub const PointerMotionHintMask: c_long = 0x0000_0080; +pub const Button1MotionMask: c_long = 0x0000_0100; +pub const Button2MotionMask: c_long = 0x0000_0200; +pub const Button3MotionMask: c_long = 0x0000_0400; +pub const Button4MotionMask: c_long = 0x0000_0800; +pub const Button5MotionMask: c_long = 0x0000_1000; +pub const ButtonMotionMask: c_long = 0x0000_2000; +pub const KeymapStateMask: c_long = 0x0000_4000; +pub const ExposureMask: c_long = 0x0000_8000; +pub const VisibilityChangeMask: c_long = 0x0001_0000; +pub const StructureNotifyMask: c_long = 0x0002_0000; +pub const ResizeRedirectMask: c_long = 0x0004_0000; +pub const SubstructureNotifyMask: c_long = 0x0008_0000; +pub const SubstructureRedirectMask: c_long = 0x0010_0000; +pub const FocusChangeMask: c_long = 0x0020_0000; +pub const PropertyChangeMask: c_long = 0x0040_0000; +pub const ColormapChangeMask: c_long = 0x0080_0000; +pub const OwnerGrabButtonMask: c_long = 0x0100_0000; + +// property modes +pub const PropModeReplace: c_int = 0; +pub const PropModePrepend: c_int = 1; +pub const PropModeAppend: c_int = 2; + +// modifier names +pub const ShiftMapIndex: c_int = 0; +pub const LockMapIndex: c_int = 1; +pub const ControlMapIndex: c_int = 2; +pub const Mod1MapIndex: c_int = 3; +pub const Mod2MapIndex: c_int = 4; +pub const Mod3MapIndex: c_int = 5; +pub const Mod4MapIndex: c_int = 6; +pub const Mod5MapIndex: c_int = 7; + +// button masks +pub const Button1Mask: c_uint = (1<<8); +pub const Button2Mask: c_uint = (1<<9); +pub const Button3Mask: c_uint = (1<<10); +pub const Button4Mask: c_uint = (1<<11); +pub const Button5Mask: c_uint = (1<<12); +pub const AnyModifier: c_uint = (1<<15); + +// Notify modes +pub const NotifyNormal: c_int = 0; +pub const NotifyGrab: c_int = 1; +pub const NotifyUngrab: c_int = 2; +pub const NotifyWhileGrabbed: c_int = 3; + +pub const NotifyHint: c_int = 1; + +// Notify detail +pub const NotifyAncestor: c_int = 0; +pub const NotifyVirtual: c_int = 1; +pub const NotifyInferior: c_int = 2; +pub const NotifyNonlinear: c_int = 3; +pub const NotifyNonlinearVirtual: c_int = 4; +pub const NotifyPointer: c_int = 5; +pub const NotifyPointerRoot: c_int = 6; +pub const NotifyDetailNone: c_int = 7; + +// Visibility notify +pub const VisibilityUnobscured: c_int = 0; +pub const VisibilityPartiallyObscured: c_int = 1; +pub const VisibilityFullyObscured: c_int = 2; + +// Circulation request +pub const PlaceOnTop: c_int = 0; +pub const PlaceOnBottom: c_int = 1; + +// protocol families +pub const FamilyInternet: c_int = 0; +pub const FamilyDECnet: c_int = 1; +pub const FamilyChaos: c_int = 2; +pub const FamilyInternet6: c_int = 6; + +// authentication families not tied to a specific protocol +pub const FamilyServerInterpreted: c_int = 5; + +// property notification +pub const PropertyNewValue: c_int = 0; +pub const PropertyDelete: c_int = 1; + +// Color Map notification +pub const ColormapUninstalled: c_int = 0; +pub const ColormapInstalled: c_int = 1; + +// grab modes +pub const GrabModeSync: c_int = 0; +pub const GrabModeAsync: c_int = 1; + +// grab status +pub const GrabSuccess: c_int = 0; +pub const AlreadyGrabbed: c_int = 1; +pub const GrabInvalidTime: c_int = 2; +pub const GrabNotViewable: c_int = 3; +pub const GrabFrozen: c_int = 4; + +// AllowEvents modes +pub const AsyncPointer: c_int = 0; +pub const SyncPointer: c_int = 1; +pub const ReplayPointer: c_int = 2; +pub const AsyncKeyboard: c_int = 3; +pub const SyncKeyboard: c_int = 4; +pub const ReplayKeyboard: c_int = 5; +pub const AsyncBoth: c_int = 6; +pub const SyncBoth: c_int = 7; + +// Used in SetInputFocus, GetInputFocus +pub const RevertToNone: c_int = 0; +pub const RevertToPointerRoot: c_int = 1; +pub const RevertToParent: c_int = 2; + + +// ConfigureWindow structure +pub const CWX: c_ushort = (1<<0); +pub const CWY: c_ushort = (1<<1); +pub const CWWidth: c_ushort = (1<<2); +pub const CWHeight: c_ushort = (1<<3); +pub const CWBorderWidth: c_ushort = (1<<4); +pub const CWSibling: c_ushort = (1<<5); +pub const CWStackMode: c_ushort = (1<<6); + +// gravity +pub const ForgetGravity: c_int = 0; +pub const UnmapGravity: c_int = 0; +pub const NorthWestGravity: c_int = 1; +pub const NorthGravity: c_int = 2; +pub const NorthEastGravity: c_int = 3; +pub const WestGravity: c_int = 4; +pub const CenterGravity: c_int = 5; +pub const EastGravity: c_int = 6; +pub const SouthWestGravity: c_int = 7; +pub const SouthGravity: c_int = 8; +pub const SouthEastGravity: c_int = 9; +pub const StaticGravity: c_int = 10; + +// image format +pub const XYBitmap: c_int = 0; +pub const XYPixmap: c_int = 1; +pub const ZPixmap: c_int = 2; + +// Used in CreateWindow for backing-store hint +pub const NotUseful: c_int = 0; +pub const WhenMapped: c_int = 1; +pub const Always: c_int = 2; + +// map state +pub const IsUnmapped: c_int = 0; +pub const IsUnviewable: c_int = 1; +pub const IsViewable: c_int = 2; + +// modifier keys mask +pub const ShiftMask: c_uint = 0x01; +pub const LockMask: c_uint = 0x02; +pub const ControlMask: c_uint = 0x04; +pub const Mod1Mask: c_uint = 0x08; +pub const Mod2Mask: c_uint = 0x10; +pub const Mod3Mask: c_uint = 0x20; +pub const Mod4Mask: c_uint = 0x40; +pub const Mod5Mask: c_uint = 0x80; + +// mouse buttons +pub const Button1: c_uint = 1; +pub const Button2: c_uint = 2; +pub const Button3: c_uint = 3; +pub const Button4: c_uint = 4; +pub const Button5: c_uint = 5; + +// size hints mask +pub const USPosition: c_long = 0x0001; +pub const USSize: c_long = 0x0002; +pub const PPosition: c_long = 0x0004; +pub const PSize: c_long = 0x0008; +pub const PMinSize: c_long = 0x0010; +pub const PMaxSize: c_long = 0x0020; +pub const PResizeInc: c_long = 0x0040; +pub const PAspect: c_long = 0x0080; +pub const PBaseSize: c_long = 0x0100; +pub const PWinGravity: c_long = 0x0200; +pub const PAllHints: c_long = PPosition | PSize | PMinSize | PMaxSize | PResizeInc | PAspect; + +// Used in ChangeSaveSet +pub const SetModeInsert: c_int = 0; +pub const SetModeDelete: c_int = 1; + +// Used in ChangeCloseDownMode +pub const DestroyAll: c_int = 0; +pub const RetainPermanent: c_int = 1; +pub const RetainTemporary: c_int = 2; + +// Window stacking method (in configureWindow) +pub const Above: c_int = 0; +pub const Below: c_int = 1; +pub const TopIf: c_int = 2; +pub const BottomIf: c_int = 3; +pub const Opposite: c_int = 4; + +// Circulation direction +pub const RaiseLowest: c_int = 0; +pub const LowerHighest: c_int = 1; + +// graphics functions +pub const GXclear: c_int = 0x0; +pub const GXand: c_int = 0x1; +pub const GXandReverse: c_int = 0x2; +pub const GXcopy: c_int = 0x3; +pub const GXandInverted: c_int = 0x4; +pub const GXnoop: c_int = 0x5; +pub const GXxor: c_int = 0x6; +pub const GXor: c_int = 0x7; +pub const GXnor: c_int = 0x8; +pub const GXequiv: c_int = 0x9; +pub const GXinvert: c_int = 0xa; +pub const GXorReverse: c_int = 0xb; +pub const GXcopyInverted: c_int = 0xc; +pub const GXorInverted: c_int = 0xd; +pub const GXnand: c_int = 0xe; +pub const GXset: c_int = 0xf; + +// LineStyle +pub const LineSolid: c_int = 0; +pub const LineOnOffDash: c_int = 1; +pub const LineDoubleDash: c_int = 2; + +// capStyle +pub const CapNotLast: c_int = 0; +pub const CapButt: c_int = 1; +pub const CapRound: c_int = 2; +pub const CapProjecting: c_int = 3; + +// joinStyle +pub const JoinMiter: c_int = 0; +pub const JoinRound: c_int = 1; +pub const JoinBevel: c_int = 2; + +// fillStyle +pub const FillSolid: c_int = 0; +pub const FillTiled: c_int = 1; +pub const FillStippled: c_int = 2; +pub const FillOpaqueStippled: c_int = 3; + +// fillRule +pub const EvenOddRule: c_int = 0; +pub const WindingRule: c_int = 1; + +// subwindow mode +pub const ClipByChildren: c_int = 0; +pub const IncludeInferiors: c_int = 1; + +// CoordinateMode for drawing routines +pub const CoordModeOrigin: c_int = 0; +pub const CoordModePrevious: c_int = 1; + +// Polygon shapes +pub const Complex: c_int = 0; +pub const Nonconvex: c_int = 1; +pub const Convex: c_int = 2; + +// Arc modes for PolyFillArc +pub const ArcChord: c_int = 0; +pub const ArcPieSlice: c_int = 1; + +// GC components +pub const GCFunction: c_uint = (1<<0); +pub const GCPlaneMask: c_uint = (1<<1); +pub const GCForeground: c_uint = (1<<2); +pub const GCBackground: c_uint = (1<<3); +pub const GCLineWidth: c_uint = (1<<4); +pub const GCLineStyle: c_uint = (1<<5); +pub const GCCapStyle: c_uint = (1<<6); +pub const GCJoinStyle: c_uint = (1<<7); +pub const GCFillStyle: c_uint = (1<<8); +pub const GCFillRule: c_uint = (1<<9); +pub const GCTile: c_uint = (1<<10); +pub const GCStipple: c_uint = (1<<11); +pub const GCTileStipXOrigin: c_uint = (1<<12); +pub const GCTileStipYOrigin: c_uint = (1<<13); +pub const GCFont : c_uint = (1<<14); +pub const GCSubwindowMode: c_uint = (1<<15); +pub const GCGraphicsExposures: c_uint = (1<<16); +pub const GCClipXOrigin: c_uint = (1<<17); +pub const GCClipYOrigin: c_uint = (1<<18); +pub const GCClipMask: c_uint = (1<<19); +pub const GCDashOffset: c_uint = (1<<20); +pub const GCDashList: c_uint = (1<<21); +pub const GCArcMode: c_uint = (1<<22); + +pub const GCLastBit: c_uint = 22; + +// draw direction +pub const FontLeftToRight: c_int = 0; +pub const FontRightToLeft: c_int = 1; + +pub const FontChange: c_uchar = 255; + +// QueryBestSize Class +pub const CursorShape: c_int = 0; +pub const TileShape: c_int = 1; +pub const StippleShape: c_int = 2; + +// keyboard autorepeat +pub const AutoRepeatModeOff: c_int = 0; +pub const AutoRepeatModeOn: c_int = 1; +pub const AutoRepeatModeDefault: c_int = 2; + +pub const LedModeOff: c_int = 0; +pub const LedModeOn: c_int = 1; + +// masks for ChangeKeyboardControl +pub const KBKeyClickPercent: c_ulong = (1<<0); +pub const KBBellPercent: c_ulong = (1<<1); +pub const KBBellPitch: c_ulong = (1<<2); +pub const KBBellDuration: c_ulong = (1<<3); +pub const KBLed: c_ulong = (1<<4); +pub const KBLedMode: c_ulong = (1<<5); +pub const KBKey: c_ulong = (1<<6); +pub const KBAutoRepeatMode: c_ulong = (1<<7); + +pub const MappingSuccess: c_uchar = 0; +pub const MappingBusy: c_uchar = 1; +pub const MappingFailed: c_uchar = 2; + +pub const MappingModifier: c_int = 0; +pub const MappingKeyboard: c_int = 1; +pub const MappingPointer: c_int = 2; + +// screensaver +pub const DontPreferBlanking: c_int = 0; +pub const PreferBlanking: c_int = 1; +pub const DefaultBlanking: c_int = 2; + +pub const DisableScreenSaver: c_int = 0; +pub const DisableScreenInterval: c_int = 0; + +pub const DontAllowExposures: c_int = 0; +pub const AllowExposures: c_int = 1; +pub const DefaultExposures: c_int = 2; + +pub const ScreenSaverReset: c_int = 0; +pub const ScreenSaverActive: c_int = 1; + +// hosts and connections +pub const HostInsert: c_uchar = 0; +pub const HostDelete: c_uchar = 1; + +pub const EnableAccess: c_int = 1; +pub const DisableAccess: c_int = 0; + +// visual class +pub const StaticGray: c_int = 0; +pub const GrayScale: c_int = 1; +pub const StaticColor: c_int = 2; +pub const PseudoColor: c_int = 3; +pub const TrueColor: c_int = 4; +pub const DirectColor: c_int = 5; + +// visual info mask +pub const VisualNoMask: c_long = 0x0000; +pub const VisualIDMask: c_long = 0x0001; +pub const VisualScreenMask: c_long = 0x0002; +pub const VisualDepthMask: c_long = 0x0004; +pub const VisualClassMask: c_long = 0x0008; +pub const VisualRedMaskMask: c_long = 0x0010; +pub const VisualGreenMaskMask: c_long = 0x0020; +pub const VisualBlueMaskMask: c_long = 0x0040; +pub const VisualColormapSizeMask: c_long = 0x0080; +pub const VisualBitsPerRGBMask: c_long = 0x0100; +pub const VisualAllMask: c_long = 0x01ff; + +// window attributes +pub const CWBackPixmap: c_ulong = 0x0001; +pub const CWBackPixel: c_ulong = 0x0002; +pub const CWBorderPixmap: c_ulong = 0x0004; +pub const CWBorderPixel: c_ulong = 0x0008; +pub const CWBitGravity: c_ulong = 0x0010; +pub const CWWinGravity: c_ulong = 0x0020; +pub const CWBackingStore: c_ulong = 0x0040; +pub const CWBackingPlanes: c_ulong = 0x0080; +pub const CWBackingPixel: c_ulong = 0x0100; +pub const CWOverrideRedirect: c_ulong = 0x0200; +pub const CWSaveUnder: c_ulong = 0x0400; +pub const CWEventMask: c_ulong = 0x0800; +pub const CWDontPropagate: c_ulong = 0x1000; +pub const CWColormap: c_ulong = 0x2000; +pub const CWCursor: c_ulong = 0x4000; + +// window classes +pub const InputOutput: c_int = 1; +pub const InputOnly: c_int = 2; + +// XCreateIC values +pub const XIMPreeditArea: c_int = 0x0001; +pub const XIMPreeditCallbacks: c_int = 0x0002; +pub const XIMPreeditPosition: c_int = 0x0004; +pub const XIMPreeditNothing: c_int = 0x0008; +pub const XIMPreeditNone: c_int = 0x0010; +pub const XIMStatusArea: c_int = 0x0100; +pub const XIMStatusCallbacks: c_int = 0x0200; +pub const XIMStatusNothing: c_int = 0x0400; +pub const XIMStatusNone: c_int = 0x0800; + +// Byte order used in imageByteOrder and bitmapBitOrder +pub const LSBFirst: c_int = 0; +pub const MSBFirst: c_int = 1; + +// Reserved resource and constant definitions +//pub const None: c_int = 0; +pub const ParentRelative: c_int = 1; +pub const CopyFromParent: c_int = 0; +pub const PointerWindow: c_int = 0; +pub const InputFocus: c_int = 1; +pub const PointerRoot: c_int = 1; +pub const AnyPropertyType: c_int = 0; +pub const AnyKey: c_int = 0; +pub const AnyButton: c_int = 0; +pub const AllTemporary: c_int = 0; +pub const CurrentTime: Time = 0; +pub const NoSymbol: c_int = 0; + +/* Definitions for the X window system likely to be used by applications */ +pub const X_PROTOCOL: c_int = 11; +pub const X_PROTOCOL_REVISION: c_int = 0; + +pub const XNVaNestedList: &'static str = "XNVaNestedList"; +pub const XNQueryInputStyle: &'static str = "queryInputStyle"; +pub const XNClientWindow: &'static str = "clientWindow"; +pub const XNInputStyle: &'static str = "inputStyle"; +pub const XNFocusWindow: &'static str = "focusWindow"; +pub const XNResourceName: &'static str = "resourceName"; +pub const XNResourceClass: &'static str = "resourceClass"; +pub const XNGeometryCallback: &'static str = "geometryCallback"; +pub const XNDestroyCallback: &'static str = "destroyCallback"; +pub const XNFilterEvents: &'static str = "filterEvents"; +pub const XNPreeditStartCallback: &'static str = "preeditStartCallback"; +pub const XNPreeditDoneCallback: &'static str = "preeditDoneCallback"; +pub const XNPreeditDrawCallback: &'static str = "preeditDrawCallback"; +pub const XNPreeditCaretCallback: &'static str = "preeditCaretCallback"; +pub const XNPreeditStateNotifyCallback: &'static str = "preeditStateNotifyCallback"; +pub const XNPreeditAttributes: &'static str = "preeditAttributes"; +pub const XNStatusStartCallback: &'static str = "statusStartCallback"; +pub const XNStatusDoneCallback: &'static str = "statusDoneCallback"; +pub const XNStatusDrawCallback: &'static str = "statusDrawCallback"; +pub const XNStatusAttributes: &'static str = "statusAttributes"; +pub const XNArea: &'static str = "area"; +pub const XNAreaNeeded: &'static str = "areaNeeded"; +pub const XNSpotLocation: &'static str = "spotLocation"; +pub const XNColormap: &'static str = "colorMap"; +pub const XNStdColormap: &'static str = "stdColorMap"; +pub const XNForeground: &'static str = "foreground"; +pub const XNBackground: &'static str = "background"; +pub const XNBackgroundPixmap: &'static str = "backgroundPixmap"; +pub const XNFontSet: &'static str = "fontSet"; +pub const XNLineSpace: &'static str = "lineSpace"; +pub const XNCursor: &'static str = "cursor"; + +pub const XNVaNestedList_0: &'static [u8] = b"XNVaNestedList\0"; +pub const XNQueryInputStyle_0: &'static [u8] = b"queryInputStyle\0"; +pub const XNClientWindow_0: &'static [u8] = b"clientWindow\0"; +pub const XNInputStyle_0: &'static [u8] = b"inputStyle\0"; +pub const XNFocusWindow_0: &'static [u8] = b"focusWindow\0"; +pub const XNResourceName_0: &'static [u8] = b"resourceName\0"; +pub const XNResourceClass_0: &'static [u8] = b"resourceClass\0"; +pub const XNGeometryCallback_0: &'static [u8] = b"geometryCallback\0"; +pub const XNDestroyCallback_0: &'static [u8] = b"destroyCallback\0"; +pub const XNFilterEvents_0: &'static [u8] = b"filterEvents\0"; +pub const XNPreeditStartCallback_0: &'static [u8] = b"preeditStartCallback\0"; +pub const XNPreeditDoneCallback_0: &'static [u8] = b"preeditDoneCallback\0"; +pub const XNPreeditDrawCallback_0: &'static [u8] = b"preeditDrawCallback\0"; +pub const XNPreeditCaretCallback_0: &'static [u8] = b"preeditCaretCallback\0"; +pub const XNPreeditStateNotifyCallback_0: &'static [u8] = b"preeditStateNotifyCallback\0"; +pub const XNPreeditAttributes_0: &'static [u8] = b"preeditAttributes\0"; +pub const XNStatusStartCallback_0: &'static [u8] = b"statusStartCallback\0"; +pub const XNStatusDoneCallback_0: &'static [u8] = b"statusDoneCallback\0"; +pub const XNStatusDrawCallback_0: &'static [u8] = b"statusDrawCallback\0"; +pub const XNStatusAttributes_0: &'static [u8] = b"statusAttributes\0"; +pub const XNArea_0: &'static [u8] = b"area\0"; +pub const XNAreaNeeded_0: &'static [u8] = b"areaNeeded\0"; +pub const XNSpotLocation_0: &'static [u8] = b"spotLocation\0"; +pub const XNColormap_0: &'static [u8] = b"colorMap\0"; +pub const XNStdColormap_0: &'static [u8] = b"stdColorMap\0"; +pub const XNForeground_0: &'static [u8] = b"foreground\0"; +pub const XNBackground_0: &'static [u8] = b"background\0"; +pub const XNBackgroundPixmap_0: &'static [u8] = b"backgroundPixmap\0"; +pub const XNFontSet_0: &'static [u8] = b"fontSet\0"; +pub const XNLineSpace_0: &'static [u8] = b"lineSpace\0"; +pub const XNCursor_0: &'static [u8] = b"cursor\0"; + +pub const XNQueryIMValuesList: &'static str = "queryIMValuesList"; +pub const XNQueryICValuesList: &'static str = "queryICValuesList"; +pub const XNVisiblePosition: &'static str = "visiblePosition"; +pub const XNR6PreeditCallback: &'static str = "r6PreeditCallback"; +pub const XNStringConversionCallback: &'static str = "stringConversionCallback"; +pub const XNStringConversion: &'static str = "stringConversion"; +pub const XNResetState: &'static str = "resetState"; +pub const XNHotKey: &'static str = "hotKey"; +pub const XNHotKeyState: &'static str = "hotKeyState"; +pub const XNPreeditState: &'static str = "preeditState"; +pub const XNSeparatorofNestedList: &'static str = "separatorofNestedList"; + +pub const XNQueryIMValuesList_0: &'static [u8] = b"queryIMValuesList\0"; +pub const XNQueryICValuesList_0: &'static [u8] = b"queryICValuesList\0"; +pub const XNVisiblePosition_0: &'static [u8] = b"visiblePosition\0"; +pub const XNR6PreeditCallback_0: &'static [u8] = b"r6PreeditCallback\0"; +pub const XNStringConversionCallback_0: &'static [u8] = b"stringConversionCallback\0"; +pub const XNStringConversion_0: &'static [u8] = b"stringConversion\0"; +pub const XNResetState_0: &'static [u8] = b"resetState\0"; +pub const XNHotKey_0: &'static [u8] = b"hotKey\0"; +pub const XNHotKeyState_0: &'static [u8] = b"hotKeyState\0"; +pub const XNPreeditState_0: &'static [u8] = b"preeditState\0"; +pub const XNSeparatorofNestedList_0: &'static [u8] = b"separatorofNestedList\0"; + +pub const XBufferOverflow: i32 = -1; +pub const XLookupNone: i32 = 1; +pub const XLookupChars: i32 = 2; +pub const XLookupKeySym: i32 = 3; +pub const XLookupBoth: i32 = 4; + +// Xkb constants +pub const XkbActionMessageLength: usize = 6; + +pub const XkbOD_Success: c_int = 0; +pub const XkbOD_BadLibraryVersion: c_int = 1; +pub const XkbOD_ConnectionRefused: c_int = 2; +pub const XkbOD_NonXkbServer: c_int = 3; +pub const XkbOD_BadServerVersion: c_int = 4; + +pub const XkbLC_ForceLatinLookup: c_uint = 1 << 0; +pub const XkbLC_ConsumeLookupMods: c_uint = 1 << 1; +pub const XkbLC_AlwaysConsumeShiftAndLock: c_uint = 1 << 2; +pub const XkbLC_IgnoreNewKeyboards: c_uint = 1 << 3; +pub const XkbLC_ControlFallback: c_uint = 1 << 4; +pub const XkbLC_ConsumeKeysOnComposeFail: c_uint = 1 << 29; +pub const XkbLC_ComposeLED: c_uint = 1 << 30; +pub const XkbLC_BeepOnComposeFail: c_uint = 1 << 31; + +pub const XkbLC_AllComposeControls: c_uint = 0xc000_0000; +pub const XkbLC_AllControls: c_uint = 0xc000_001f; + +pub const XkbNewKeyboardNotify: c_int = 0; +pub const XkbMapNotify: c_int = 1; +pub const XkbStateNotify: c_int = 2; +pub const XkbControlsNotify: c_int = 3; +pub const XkbIndicatorStateNotify: c_int = 4; +pub const XkbIndicatorMapNotify: c_int = 5; +pub const XkbNamesNotify: c_int = 6; +pub const XkbCompatMapNotify: c_int = 7; +pub const XkbBellNotify: c_int = 8; +pub const XkbActionMessage: c_int = 9; +pub const XkbAccessXNotify: c_int = 10; +pub const XkbExtensionDeviceNotify: c_int = 11; + +pub const XkbNewKeyboardNotifyMask: c_ulong = 1 << 0; +pub const XkbMapNotifyMask: c_ulong = 1 << 1; +pub const XkbStateNotifyMask: c_ulong = 1 << 2; +pub const XkbControlsNotifyMask: c_ulong = 1 << 3; +pub const XkbIndicatorStateNotifyMask: c_ulong = 1 << 4; +pub const XkbIndicatorMapNotifyMask: c_ulong = 1 << 5; +pub const XkbNamesNotifyMask: c_ulong = 1 << 6; +pub const XkbCompatMapNotifyMask: c_ulong = 1 << 7; +pub const XkbBellNotifyMask: c_ulong = 1 << 8; +pub const XkbActionMessageMask: c_ulong = 1 << 9; +pub const XkbAccessXNotifyMask: c_ulong = 1 << 10; +pub const XkbExtensionDeviceNotifyMask: c_ulong = 1 << 11; +pub const XkbAllEventsMask: c_ulong = 0xfff; + +// Bitmask returned by XParseGeometry +pub const NoValue: c_int = 0x0000; +pub const XValue: c_int = 0x0001; +pub const YValue: c_int = 0x0002; +pub const WidthValue: c_int = 0x0004; +pub const HeightValue: c_int = 0x0008; +pub const AllValues: c_int = 0x000f; +pub const XNegative: c_int = 0x0010; +pub const YNegative: c_int = 0x0020; + +// Definition for flags of XWMHints +pub const InputHint: c_long = 1 << 0; +pub const StateHint: c_long = 1 << 1; +pub const IconPixmapHint: c_long = 1 << 2; +pub const IconWindowHint: c_long = 1 << 3; +pub const IconPositionHint: c_long = 1 << 4; +pub const IconMaskHint: c_long = 1 << 5; +pub const WindowGroupHint: c_long = 1 << 6; +pub const AllHints: c_long = InputHint | StateHint | IconPixmapHint | IconWindowHint | IconPositionHint | IconMaskHint | WindowGroupHint; +pub const XUrgencyHint: c_long = 1 << 8; + +// XICCEncodingStyle +pub const XStringStyle: c_int = 0; +pub const XCompoundTextStyle: c_int = 1; +pub const XTextStyle: c_int = 2; +pub const XStdICCTextStyle: c_int = 3; +pub const XUTF8StringStyle: c_int = 4; + + +// +// inline functions +// + + +#[cfg(feature = "xlib")] +#[inline] +pub unsafe fn XUniqueContext () -> XContext { XrmUniqueQuark() } diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xlib_xcb.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xlib_xcb.rs new file mode 100644 index 0000000..c1a8145 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xlib_xcb.rs @@ -0,0 +1,10 @@ +use std::os::raw::c_void; +use ::xlib::Display; + +x11_link! { Xlib_xcb, xlib_xcb, ["libX11-xcb.so.1", "libX11-xcb.so"], 1, + pub fn XGetXCBConnection(_1: *mut Display) -> *mut xcb_connection_t, + variadic: + globals: +} + +pub type xcb_connection_t = c_void; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xmd.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xmd.rs new file mode 100644 index 0000000..12ec995 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xmd.rs @@ -0,0 +1,12 @@ +pub type INT8 = i8; +pub type INT16 = i16; +pub type INT32 = i32; +pub type INT64 = i64; + +pub type CARD8 = u8; +pub type CARD16 = u16; +pub type CARD32 = u32; +pub type CARD64 = u64; + +pub type BYTE = CARD8; +pub type BOOL = CARD8; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xmu.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xmu.rs new file mode 100644 index 0000000..937ddda --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xmu.rs @@ -0,0 +1,199 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ + c_char, + c_int, + c_uchar, + c_uint, + c_ulong, + c_void, +}; +use libc::FILE; + +use ::xlib::{ + Display, + GC, + Screen, + XColor, + XComposeStatus, + XErrorEvent, + XEvent, + XKeyEvent, + XrmValue, + XSizeHints, + XStandardColormap, + XVisualInfo, +}; +use ::xt::{ + Widget, + XtAppContext, +}; + + +// +// functions +// + + +x11_link! { Xmu, xmu, ["libXmu.so.6", "libXmu.so"], 132, + pub fn XmuAddCloseDisplayHook (_3: *mut Display, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char) -> c_int>, _1: *mut c_char) -> *mut c_char, + pub fn XmuAddInitializer (_2: Option<unsafe extern "C" fn (XtAppContext, *mut c_char)>, _1: *mut c_char) -> (), + pub fn XmuAllStandardColormaps (_1: *mut Display) -> c_int, + pub fn XmuAppendSegment (_2: *mut XmuSegment, _1: *mut XmuSegment) -> c_int, + pub fn XmuAreaAnd (_2: *mut XmuArea, _1: *mut XmuArea) -> *mut XmuArea, + pub fn XmuAreaCopy (_2: *mut XmuArea, _1: *mut XmuArea) -> *mut XmuArea, + pub fn XmuAreaDup (_1: *mut XmuArea) -> *mut XmuArea, + pub fn XmuAreaNot (_5: *mut XmuArea, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> *mut XmuArea, + pub fn XmuAreaOrXor (_3: *mut XmuArea, _2: *mut XmuArea, _1: c_int) -> *mut XmuArea, + pub fn XmuCallInitializers (_1: XtAppContext) -> (), + pub fn XmuClientWindow (_2: *mut Display, _1: c_ulong) -> c_ulong, + pub fn XmuCompareISOLatin1 (_2: *const c_char, _1: *const c_char) -> c_int, + pub fn XmuConvertStandardSelection (_8: Widget, _7: c_ulong, _6: *mut c_ulong, _5: *mut c_ulong, _4: *mut c_ulong, _3: *mut *mut c_char, _2: *mut c_ulong, _1: *mut c_int) -> c_char, + pub fn XmuCopyISOLatin1Lowered (_2: *mut c_char, _1: *const c_char) -> (), + pub fn XmuCopyISOLatin1Uppered (_2: *mut c_char, _1: *const c_char) -> (), + pub fn XmuCreateColormap (_2: *mut Display, _1: *mut XStandardColormap) -> c_int, + pub fn XmuCreatePixmapFromBitmap (_8: *mut Display, _7: c_ulong, _6: c_ulong, _5: c_uint, _4: c_uint, _3: c_uint, _2: c_ulong, _1: c_ulong) -> c_ulong, + pub fn XmuCreateStippledPixmap (_4: *mut Screen, _3: c_ulong, _2: c_ulong, _1: c_uint) -> c_ulong, + pub fn XmuCursorNameToIndex (_1: *const c_char) -> c_int, + pub fn XmuCvtBackingStoreToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XmuCvtFunctionToCallback (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), + pub fn XmuCvtGravityToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XmuCvtJustifyToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XmuCvtLongToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XmuCvtOrientationToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XmuCvtShapeStyleToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XmuCvtStringToBackingStore (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), + pub fn XmuCvtStringToBitmap (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), + pub fn XmuCvtStringToColorCursor (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XmuCvtStringToCursor (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), + pub fn XmuCvtStringToGravity (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), + pub fn XmuCvtStringToJustify (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), + pub fn XmuCvtStringToLong (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), + pub fn XmuCvtStringToOrientation (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), + pub fn XmuCvtStringToShapeStyle (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XmuCvtStringToWidget (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), + pub fn XmuCvtWidgetToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XmuDeleteStandardColormap (_3: *mut Display, _2: c_int, _1: c_ulong) -> (), + pub fn XmuDestroyScanlineList (_1: *mut XmuScanline) -> (), + pub fn XmuDestroySegmentList (_1: *mut XmuSegment) -> (), + pub fn XmuDistinguishableColors (_2: *mut XColor, _1: c_int) -> c_int, + pub fn XmuDistinguishablePixels (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int, + pub fn XmuDQAddDisplay (_3: *mut XmuDisplayQueue, _2: *mut Display, _1: *mut c_char) -> *mut XmuDisplayQueueEntry, + pub fn XmuDQCreate (_3: Option<unsafe extern "C" fn (*mut XmuDisplayQueue, *mut XmuDisplayQueueEntry) -> c_int>, _2: Option<unsafe extern "C" fn (*mut XmuDisplayQueue) -> c_int>, _1: *mut c_char) -> *mut XmuDisplayQueue, + pub fn XmuDQDestroy (_2: *mut XmuDisplayQueue, _1: c_int) -> c_int, + pub fn XmuDQLookupDisplay (_2: *mut XmuDisplayQueue, _1: *mut Display) -> *mut XmuDisplayQueueEntry, + pub fn XmuDQRemoveDisplay (_2: *mut XmuDisplayQueue, _1: *mut Display) -> c_int, + pub fn XmuDrawLogo (_8: *mut Display, _7: c_ulong, _6: GC, _5: GC, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> (), + pub fn XmuDrawRoundedRectangle (_9: *mut Display, _8: c_ulong, _7: GC, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XmuFillRoundedRectangle (_9: *mut Display, _8: c_ulong, _7: GC, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> (), + pub fn XmuGetAtomName (_2: *mut Display, _1: c_ulong) -> *mut c_char, + pub fn XmuGetColormapAllocation (_5: *mut XVisualInfo, _4: c_ulong, _3: *mut c_ulong, _2: *mut c_ulong, _1: *mut c_ulong) -> c_int, + pub fn XmuGetHostname (_2: *mut c_char, _1: c_int) -> c_int, + pub fn XmuInternAtom (_2: *mut Display, _1: AtomPtr) -> c_ulong, + pub fn XmuInternStrings (_4: *mut Display, _3: *mut *mut c_char, _2: c_uint, _1: *mut c_ulong) -> (), + pub fn XmuLocateBitmapFile (_8: *mut Screen, _7: *const c_char, _6: *mut c_char, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_ulong, + pub fn XmuLocatePixmapFile (_11: *mut Screen, _10: *const c_char, _9: c_ulong, _8: c_ulong, _7: c_uint, _6: *mut c_char, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_ulong, + pub fn XmuLookupAPL (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupArabic (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupCloseDisplayHook (_4: *mut Display, _3: *mut c_char, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char) -> c_int>, _1: *mut c_char) -> c_int, + pub fn XmuLookupCyrillic (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupGreek (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupHebrew (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupJISX0201 (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupKana (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupLatin1 (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupLatin2 (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupLatin3 (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupLatin4 (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, + pub fn XmuLookupStandardColormap (_7: *mut Display, _6: c_int, _5: c_ulong, _4: c_uint, _3: c_ulong, _2: c_int, _1: c_int) -> c_int, + pub fn XmuLookupString (_6: *mut XKeyEvent, _5: *mut c_uchar, _4: c_int, _3: *mut c_ulong, _2: *mut XComposeStatus, _1: c_ulong) -> c_int, + pub fn XmuMakeAtom (_1: *const c_char) -> AtomPtr, + pub fn XmuNameOfAtom (_1: AtomPtr) -> *mut c_char, + pub fn XmuNCopyISOLatin1Lowered (_3: *mut c_char, _2: *const c_char, _1: c_int) -> (), + pub fn XmuNCopyISOLatin1Uppered (_3: *mut c_char, _2: *const c_char, _1: c_int) -> (), + pub fn XmuNewArea (_4: c_int, _3: c_int, _2: c_int, _1: c_int) -> *mut XmuArea, + pub fn XmuNewCvtStringToWidget (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XmuNewScanline (_3: c_int, _2: c_int, _1: c_int) -> *mut XmuScanline, + pub fn XmuNewSegment (_2: c_int, _1: c_int) -> *mut XmuSegment, + pub fn XmuOptimizeArea (_1: *mut XmuArea) -> *mut XmuArea, + pub fn XmuOptimizeScanline (_1: *mut XmuScanline) -> *mut XmuScanline, + pub fn XmuPrintDefaultErrorMessage (_3: *mut Display, _2: *mut XErrorEvent, _1: *mut FILE) -> c_int, + pub fn XmuReadBitmapData (_6: *mut FILE, _5: *mut c_uint, _4: *mut c_uint, _3: *mut *mut c_uchar, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XmuReadBitmapDataFromFile (_6: *const c_char, _5: *mut c_uint, _4: *mut c_uint, _3: *mut *mut c_uchar, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XmuRegisterExternalAgent (_4: Widget, _3: *mut c_void, _2: *mut XEvent, _1: *mut c_char) -> (), + pub fn XmuReleaseStippledPixmap (_2: *mut Screen, _1: c_ulong) -> (), + pub fn XmuRemoveCloseDisplayHook (_4: *mut Display, _3: *mut c_char, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char) -> c_int>, _1: *mut c_char) -> c_int, + pub fn XmuReshapeWidget (_4: Widget, _3: c_int, _2: c_int, _1: c_int) -> c_char, + pub fn XmuScanlineAnd (_2: *mut XmuScanline, _1: *mut XmuScanline) -> *mut XmuScanline, + pub fn XmuScanlineAndSegment (_2: *mut XmuScanline, _1: *mut XmuSegment) -> *mut XmuScanline, + pub fn XmuScanlineCopy (_2: *mut XmuScanline, _1: *mut XmuScanline) -> *mut XmuScanline, + pub fn XmuScanlineEqu (_2: *mut XmuScanline, _1: *mut XmuScanline) -> c_int, + pub fn XmuScanlineNot (_3: *mut XmuScanline, _2: c_int, _1: c_int) -> *mut XmuScanline, + pub fn XmuScanlineOr (_2: *mut XmuScanline, _1: *mut XmuScanline) -> *mut XmuScanline, + pub fn XmuScanlineOrSegment (_2: *mut XmuScanline, _1: *mut XmuSegment) -> *mut XmuScanline, + pub fn XmuScanlineXor (_2: *mut XmuScanline, _1: *mut XmuScanline) -> *mut XmuScanline, + pub fn XmuScanlineXorSegment (_2: *mut XmuScanline, _1: *mut XmuSegment) -> *mut XmuScanline, + pub fn XmuScreenOfWindow (_2: *mut Display, _1: c_ulong) -> *mut Screen, + pub fn XmuSimpleErrorHandler (_2: *mut Display, _1: *mut XErrorEvent) -> c_int, + pub fn XmuStandardColormap (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_uint, _5: c_ulong, _4: c_ulong, _3: c_ulong, _2: c_ulong, _1: c_ulong) -> *mut XStandardColormap, + pub fn XmuUpdateMapHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> c_int, + pub fn XmuValidArea (_1: *mut XmuArea) -> c_int, + pub fn XmuValidScanline (_1: *mut XmuScanline) -> c_int, + pub fn XmuVisualStandardColormaps (_6: *mut Display, _5: c_int, _4: c_ulong, _3: c_uint, _2: c_int, _1: c_int) -> c_int, + pub fn XmuWnCountOwnedResources (_3: *mut XmuWidgetNode, _2: *mut XmuWidgetNode, _1: c_int) -> c_int, + pub fn XmuWnFetchResources (_3: *mut XmuWidgetNode, _2: Widget, _1: *mut XmuWidgetNode) -> (), + pub fn XmuWnInitializeNodes (_2: *mut XmuWidgetNode, _1: c_int) -> (), + pub fn XmuWnNameToNode (_3: *mut XmuWidgetNode, _2: c_int, _1: *const c_char) -> *mut XmuWidgetNode, +variadic: + pub fn XmuSnprintf (_3: *mut c_char, _2: c_int, _1: *const c_char) -> c_int, +globals: + pub static _XA_ATOM_PAIR: AtomPtr, + pub static _XA_CHARACTER_POSITION: AtomPtr, + pub static _XA_CLASS: AtomPtr, + pub static _XA_CLIENT_WINDOW: AtomPtr, + pub static _XA_CLIPBOARD: AtomPtr, + pub static _XA_COMPOUND_TEXT: AtomPtr, + pub static _XA_DECNET_ADDRESS: AtomPtr, + pub static _XA_DELETE: AtomPtr, + pub static _XA_FILENAME: AtomPtr, + pub static _XA_HOSTNAME: AtomPtr, + pub static _XA_IP_ADDRESS: AtomPtr, + pub static _XA_LENGTH: AtomPtr, + pub static _XA_LIST_LENGTH: AtomPtr, + pub static _XA_NAME: AtomPtr, + pub static _XA_NET_ADDRESS: AtomPtr, + pub static _XA_NULL: AtomPtr, + pub static _XA_OWNER_OS: AtomPtr, + pub static _XA_SPAN: AtomPtr, + pub static _XA_TARGETS: AtomPtr, + pub static _XA_TEXT: AtomPtr, + pub static _XA_TIMESTAMP: AtomPtr, + pub static _XA_USER: AtomPtr, + pub static _XA_UTF8_STRING: AtomPtr, +} + + +// +// types +// + + +// TODO structs +#[repr(C)] pub struct _AtomRec; +#[repr(C)] pub struct _XmuArea; +#[repr(C)] pub struct _XmuDisplayQueue; +#[repr(C)] pub struct _XmuDisplayQueueEntry; +#[repr(C)] pub struct _XmuScanline; +#[repr(C)] pub struct _XmuSegment; +#[repr(C)] pub struct _XmuWidgetNode; + +// struct typedefs +pub type AtomPtr = *mut _AtomRec; +pub type XmuArea = _XmuArea; +pub type XmuDisplayQueue = _XmuDisplayQueue; +pub type XmuDisplayQueueEntry = _XmuDisplayQueueEntry; +pub type XmuScanline = _XmuScanline; +pub type XmuSegment = _XmuSegment; +pub type XmuWidgetNode = _XmuWidgetNode; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xrandr.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xrandr.rs new file mode 100644 index 0000000..0b4f879 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xrandr.rs @@ -0,0 +1,558 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ c_char, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort }; + +use xlib::{ Atom, Bool, Display, Drawable, Status, Time, XEvent, XID, Window }; +use xrender::{ XFixed, XTransform }; + + +// +// functions +// + + +x11_link! { Xrandr, xrandr, ["libXrandr.so.2", "libXrandr.so"], 70, + pub fn XRRAddOutputMode (dpy: *mut Display, output: RROutput, mode: RRMode) -> (), + pub fn XRRAllocGamma (size: c_int) -> *mut XRRCrtcGamma, + pub fn XRRAllocModeInfo (name: *const c_char, nameLength: c_int) -> *mut XRRModeInfo, + pub fn XRRAllocateMonitor (dpy: *mut Display, noutput: c_int) -> *mut XRRMonitorInfo, + pub fn XRRChangeOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, type_: Atom, format: c_int, mode: c_int, data: *const c_uchar, nelements: c_int) -> (), + pub fn XRRChangeProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, type_: Atom, format: c_int, mode: c_int, data: *const c_uchar, nelements: c_int) -> (), + pub fn XRRConfigCurrentConfiguration (config: *mut XRRScreenConfiguration, rotation: *mut Rotation) -> SizeID, + pub fn XRRConfigCurrentRate (config: *mut XRRScreenConfiguration) -> c_short, + pub fn XRRConfigRates (config: *mut XRRScreenConfiguration, sizeID: c_int, nrates: *mut c_int) -> *mut c_short, + pub fn XRRConfigRotations (config: *mut XRRScreenConfiguration, current_rotation: *mut Rotation) -> Rotation, + pub fn XRRConfigSizes (config: *mut XRRScreenConfiguration, nsizes: *mut c_int) -> *mut XRRScreenSize, + pub fn XRRConfigTimes (config: *mut XRRScreenConfiguration, config_timestamp: *mut Time) -> Time, + pub fn XRRConfigureOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, pending: Bool, range: Bool, num_values: c_int, values: *mut c_long) -> (), + pub fn XRRConfigureProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, pending: Bool, range: Bool, num_values: c_int, values: *mut c_long) -> (), + pub fn XRRCreateMode (dpy: *mut Display, window: Window, modeInfo: *mut XRRModeInfo) -> RRMode, + pub fn XRRDeleteMonitor (dpy: *mut Display, window: Window, name: Atom) -> (), + pub fn XRRDeleteOutputMode (dpy: *mut Display, output: RROutput, mode: RRMode) -> (), + pub fn XRRDeleteOutputProperty (dpy: *mut Display, output: RROutput, property: Atom) -> (), + pub fn XRRDeleteProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom) -> (), + pub fn XRRDestroyMode (dpy: *mut Display, mode: RRMode) -> (), + pub fn XRRFreeCrtcInfo (crtcInfo: *mut XRRCrtcInfo) -> (), + pub fn XRRFreeGamma (gamma: *mut XRRCrtcGamma) -> (), + pub fn XRRFreeModeInfo (modeInfo: *mut XRRModeInfo) -> (), + pub fn XRRFreeMonitors (monitors: *mut XRRMonitorInfo) -> (), + pub fn XRRFreeOutputInfo (outputInfo: *mut XRROutputInfo) -> (), + pub fn XRRFreePanning (panning: *mut XRRPanning) -> (), + pub fn XRRFreeProviderInfo (provider: *mut XRRProviderInfo) -> (), + pub fn XRRFreeProviderResources (resources: *mut XRRProviderResources) -> (), + pub fn XRRFreeScreenConfigInfo (config: *mut XRRScreenConfiguration) -> (), + pub fn XRRFreeScreenResources (resources: *mut XRRScreenResources) -> (), + pub fn XRRGetCrtcGamma (dpy: *mut Display, crtc: RRCrtc) -> *mut XRRCrtcGamma, + pub fn XRRGetCrtcGammaSize (dpy: *mut Display, crtc: RRCrtc) -> c_int, + pub fn XRRGetCrtcInfo (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc) -> *mut XRRCrtcInfo, + pub fn XRRGetCrtcTransform (dpy: *mut Display, crtc: RRCrtc, attributes: *mut *mut XRRCrtcTransformAttributes) -> Status, + pub fn XRRGetMonitors (dpy: *mut Display, window: Window, get_active: Bool, nmonitors: *mut c_int) -> *mut XRRMonitorInfo, + pub fn XRRGetOutputInfo (dpy: *mut Display, resources: *mut XRRScreenResources, output: RROutput) -> *mut XRROutputInfo, + pub fn XRRGetOutputPrimary (dpy: *mut Display, window: Window) -> RROutput, + pub fn XRRGetOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, offset: c_long, length: c_long, _delete: Bool, pending: Bool, req_type: Atom, actual_type: *mut Atom, actual_format: *mut c_int, nitems: *mut c_ulong, bytes_after: *mut c_ulong, prop: *mut *mut c_uchar) -> c_int, + pub fn XRRGetPanning (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc) -> *mut XRRPanning, + pub fn XRRGetProviderInfo (dpy: *mut Display, resources: *mut XRRScreenResources, provider: RRProvider) -> *mut XRRProviderInfo, + pub fn XRRGetProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, offset: c_long, length: c_long, _delete: Bool, pending: Bool, req_type: Atom, actual_type: *mut Atom, actual_format: *mut c_int, nitems: *mut c_ulong, bytes_after: *mut c_ulong, prop: *mut *mut c_uchar) -> c_int, + pub fn XRRGetProviderResources (dpy: *mut Display, window: Window) -> *mut XRRProviderResources, + pub fn XRRGetScreenInfo (dpy: *mut Display, window: Window) -> *mut XRRScreenConfiguration, + pub fn XRRGetScreenResources (dpy: *mut Display, window: Window) -> *mut XRRScreenResources, + pub fn XRRGetScreenResourcesCurrent (dpy: *mut Display, window: Window) -> *mut XRRScreenResources, + pub fn XRRGetScreenSizeRange (dpy: *mut Display, window: Window, minWidth: *mut c_int, minHeight: *mut c_int, maxWidth: *mut c_int, maxHeight: *mut c_int) -> Status, + pub fn XRRListOutputProperties (dpy: *mut Display, output: RROutput, nprop: *mut c_int) -> *mut Atom, + pub fn XRRListProviderProperties (dpy: *mut Display, provider: RRProvider, nprop: *mut c_int) -> *mut Atom, + pub fn XRRQueryExtension (dpy: *mut Display, event_base_return: *mut c_int, error_base_return: *mut c_int) -> Bool, + pub fn XRRQueryOutputProperty (dpy: *mut Display, output: RROutput, property: Atom) -> *mut XRRPropertyInfo, + pub fn XRRQueryProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom) -> *mut XRRPropertyInfo, + pub fn XRRQueryVersion (dpy: *mut Display, major_version_return: *mut c_int, minor_version_return: *mut c_int) -> Status, + pub fn XRRRates (dpy: *mut Display, screen: c_int, sizeID: c_int, nrates: *mut c_int) -> *mut c_short, + pub fn XRRRootToScreen (dpy: *mut Display, root: Window) -> c_int, + pub fn XRRRotations (dpy: *mut Display, screen: c_int, current_rotation: *mut Rotation) -> Rotation, + pub fn XRRSelectInput (dpy: *mut Display, window: Window, mask: c_int) -> (), + pub fn XRRSetCrtcConfig (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc, timestamp: Time, x: c_int, y: c_int, mode: RRMode, rotation: Rotation, outputs: *mut RROutput, noutputs: c_int) -> Status, + pub fn XRRSetCrtcGamma (dpy: *mut Display, crtc: RRCrtc, gamma: *mut XRRCrtcGamma) -> (), + pub fn XRRSetCrtcTransform (dpy: *mut Display, crtc: RRCrtc, transform: *mut XTransform, filter: *const c_char, params: *mut XFixed, nparams: c_int) -> (), + pub fn XRRSetMonitor (dpy: *mut Display, window: Window, monitor: *mut XRRMonitorInfo) -> (), + pub fn XRRSetOutputPrimary (dpy: *mut Display, window: Window, output: RROutput) -> (), + pub fn XRRSetPanning (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc, panning: *mut XRRPanning) -> Status, + pub fn XRRSetProviderOffloadSink (dpy: *mut Display, provider: XID, sink_provider: XID) -> c_int, + pub fn XRRSetProviderOutputSource (dpy: *mut Display, provider: XID, source_provider: XID) -> c_int, + pub fn XRRSetScreenConfig (dpy: *mut Display, config: *mut XRRScreenConfiguration, draw: Drawable, size_index: c_int, rotation: Rotation, timestamp: Time) -> Status, + pub fn XRRSetScreenConfigAndRate (dpy: *mut Display, config: *mut XRRScreenConfiguration, draw: Drawable, size_index: c_int, rotation: Rotation, rate: c_short, timestamp: Time) -> Status, + pub fn XRRSetScreenSize (dpy: *mut Display, window: Window, width: c_int, height: c_int, mmWidth: c_int, mmHeight: c_int) -> (), + pub fn XRRSizes (dpy: *mut Display, screen: c_int, nsizes: *mut c_int) -> *mut XRRScreenSize, + pub fn XRRTimes (dpy: *mut Display, screen: c_int, config_timestamp: *mut Time) -> Time, + pub fn XRRUpdateConfiguration (event: *mut XEvent) -> c_int, +variadic: +globals: +} + + +// +// types +// + + +pub type Connection = c_ushort; +pub type Rotation = c_ushort; +pub type SizeID = c_ushort; +pub type SubpixelOrder = c_ushort; + +pub type RROutput = XID; +pub type RRCrtc = XID; +pub type RRMode = XID; +pub type RRProvider = XID; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRScreenSize { + pub width: c_int, + pub height: c_int, + pub mwidth: c_int, + pub mheight: c_int, +} + +#[repr(C)] pub struct XRRScreenConfiguration; + +pub type XRRModeFlags = c_ulong; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRModeInfo { + pub id: RRMode, + pub width: c_uint, + pub height: c_uint, + pub dotClock: c_ulong, + pub hSyncStart: c_uint, + pub hSyncEnd: c_uint, + pub hTotal: c_uint, + pub hSkew: c_uint, + pub vSyncStart: c_uint, + pub vSyncEnd: c_uint, + pub vTotal: c_uint, + pub name: *mut c_char, + pub nameLength: c_uint, + pub modeFlags: XRRModeFlags, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRScreenResources { + pub timestamp: Time, + pub configTimestamp: Time, + pub ncrtc: c_int, + pub crtcs: *mut RRCrtc, + pub noutput: c_int, + pub outputs: *mut RROutput, + pub nmode: c_int, + pub modes: *mut XRRModeInfo, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRROutputInfo { + pub timestamp: Time, + pub crtc: RRCrtc, + pub name: *mut c_char, + pub nameLen: c_int, + pub mm_width: c_ulong, + pub mm_height: c_ulong, + pub connection: Connection, + pub subpixel_order: SubpixelOrder, + pub ncrtc: c_int, + pub crtcs: *mut RRCrtc, + pub nclone: c_int, + pub clones: *mut RROutput, + pub nmode: c_int, + pub npreferred: c_int, + pub modes: *mut RRMode, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRPropertyInfo { + pub pending: Bool, + pub range: Bool, + pub immutable: Bool, + pub num_values: c_int, + pub values: *mut c_long, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRCrtcInfo { + pub timestamp: Time, + pub x: c_int, + pub y: c_int, + pub width: c_uint, + pub height: c_uint, + pub mode: RRMode, + pub rotation: Rotation, + pub noutput: c_int, + pub outputs: *mut RROutput, + pub rotations: Rotation, + pub npossible: c_int, + pub possible: *mut RROutput, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRCrtcGamma { + pub size: c_int, + pub red: *mut c_ushort, + pub green: *mut c_ushort, + pub blue: *mut c_ushort, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRCrtcTransformAttributes { + pub pendingTransform: XTransform, + pub pendingFilter: *mut c_char, + pub pendingNparams: c_int, + pub pendingParams: *mut XFixed, + pub currentTransform: XTransform, + pub currentFilter: *mut c_char, + pub currentNparams: c_int, + pub currentParams: *mut XFixed, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRPanning { + pub timestamp: Time, + pub left: c_uint, + pub top: c_uint, + pub width: c_uint, + pub height: c_uint, + pub track_left: c_uint, + pub track_top: c_uint, + pub track_width: c_uint, + pub track_height: c_uint, + pub border_left: c_int, + pub border_top: c_int, + pub border_right: c_int, + pub border_bottom: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRProviderResources { + pub timestamp: Time, + pub nproviders: c_int, + pub providers: *mut RRProvider, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRProviderInfo { + pub capabilities: c_uint, + pub ncrtcs: c_int, + pub crtcs: *mut RRCrtc, + pub noutputs: c_int, + pub outputs: *mut RROutput, + pub name: *mut c_char, + pub nassociatedproviders: c_int, + pub associated_providers: *mut RRProvider, + pub associated_capability: *mut c_uint, + pub nameLen: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRMonitorInfo { + pub name: Atom, + pub primary: Bool, + pub automatic: Bool, + pub noutput: c_int, + pub x: c_int, + pub y: c_int, + pub width: c_int, + pub height: c_int, + pub mwidth: c_int, + pub mheight: c_int, + pub outputs: *mut RROutput, +} + + +// +// event structures +// + + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRScreenChangeNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub root: Window, + pub timestamp: Time, + pub config_timestamp: Time, + pub size_index: SizeID, + pub subpixel_order: SubpixelOrder, + pub rotation: Rotation, + pub width: c_int, + pub height: c_int, + pub mwidth: c_int, + pub mheight: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub subtype: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRROutputChangeNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub subtype: c_int, + pub output: RROutput, + pub crtc: RRCrtc, + pub mode: RRMode, + pub rotation: Rotation, + pub connection: Connection, + pub subpixel_order: SubpixelOrder, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRCrtcChangeNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub subtype: c_int, + pub crtc: RRCrtc, + pub mode: RRMode, + pub rotation: Rotation, + pub x: c_int, + pub y: c_int, + pub width: c_uint, + pub height: c_uint, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRROutputPropertyNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub subtype: c_int, + pub output: RROutput, + pub property: Atom, + pub timestamp: Time, + pub state: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRProviderChangeNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub subtype: c_int, + pub provider: RRProvider, + pub timestamp: Time, + pub current_role: c_uint, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRProviderPropertyNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub subtype: c_int, + pub provider: RRProvider, + pub property: Atom, + pub timestamp: Time, + pub state: c_int, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRRResourceChangeNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub subtype: c_int, + pub timestamp: Time, +} + +event_conversions_and_tests! { + xrr_screen_change_notify: XRRScreenChangeNotifyEvent, + xrr_notify: XRRNotifyEvent, + xrr_output_change_notify: XRROutputChangeNotifyEvent, + xrr_crtc_change_notify: XRRCrtcChangeNotifyEvent, + xrr_output_property_notify: XRROutputPropertyNotifyEvent, + xrr_provider_change_notify: XRRProviderChangeNotifyEvent, + xrr_provider_property_notify: XRRProviderPropertyNotifyEvent, + xrr_resource_change_notify: XRRResourceChangeNotifyEvent, +} + + +// +// constants +// + + +pub const RANDR_NAME: &'static str = "RANDR"; +pub const RANDR_MAJOR: c_int = 1; +pub const RANDR_MINOR: c_int = 5; + +pub const RRNumberErrors: c_int = 4; +pub const RRNumberEvents: c_int = 2; +pub const RRNumberRequests: c_int = 45; + +pub const X_RRQueryVersion: c_int = 0; +pub const X_RROldGetScreenInfo: c_int = 1; +pub const X_RRSetScreenConfig: c_int = 2; +pub const X_RROldScreenChangeSelectInput: c_int = 3; +pub const X_RRSelectInput: c_int = 4; +pub const X_RRGetScreenInfo: c_int = 5; + +pub const X_RRGetScreenSizeRange: c_int = 6; +pub const X_RRSetScreenSize: c_int = 7; +pub const X_RRGetScreenResources: c_int = 8; +pub const X_RRGetOutputInfo: c_int = 9; +pub const X_RRListOutputProperties: c_int = 10; +pub const X_RRQueryOutputProperty: c_int = 11; +pub const X_RRConfigureOutputProperty: c_int = 12; +pub const X_RRChangeOutputProperty: c_int = 13; +pub const X_RRDeleteOutputProperty: c_int = 14; +pub const X_RRGetOutputProperty: c_int = 15; +pub const X_RRCreateMode: c_int = 16; +pub const X_RRDestroyMode: c_int = 17; +pub const X_RRAddOutputMode: c_int = 18; +pub const X_RRDeleteOutputMode: c_int = 19; +pub const X_RRGetCrtcInfo: c_int = 20; +pub const X_RRSetCrtcConfig: c_int = 21; +pub const X_RRGetCrtcGammaSize: c_int = 22; +pub const X_RRGetCrtcGamma: c_int = 23; +pub const X_RRSetCrtcGamma: c_int = 24; + +pub const X_RRGetScreenResourcesCurrent: c_int = 25; +pub const X_RRSetCrtcTransform: c_int = 26; +pub const X_RRGetCrtcTransform: c_int = 27; +pub const X_RRGetPanning: c_int = 28; +pub const X_RRSetPanning: c_int = 29; +pub const X_RRSetOutputPrimary: c_int = 30; +pub const X_RRGetOutputPrimary: c_int = 31; + +pub const X_RRGetProviders: c_int = 32; +pub const X_RRGetProviderInfo: c_int = 33; +pub const X_RRSetProviderOffloadSink: c_int = 34; +pub const X_RRSetProviderOutputSource: c_int = 35; +pub const X_RRListProviderProperties: c_int = 36; +pub const X_RRQueryProviderProperty: c_int = 37; +pub const X_RRConfigureProviderProperty: c_int = 38; +pub const X_RRChangeProviderProperty: c_int = 39; +pub const X_RRDeleteProviderProperty: c_int = 40; +pub const X_RRGetProviderProperty: c_int = 41; + +pub const X_RRGetMonitors: c_int = 42; +pub const X_RRSetMonitor: c_int = 43; +pub const X_RRDeleteMonitor: c_int = 44; + +pub const RRTransformUnit: c_int = 1 << 0; +pub const RRTransformScaleUp: c_int = 1 << 1; +pub const RRTransformScaleDown: c_int = 1 << 2; +pub const RRTransformProjective: c_int = 1 << 3; + +pub const RRScreenChangeNotifyMask: c_int = 1 << 0; +pub const RRCrtcChangeNotifyMask: c_int = 1 << 1; +pub const RROutputChangeNotifyMask: c_int = 1 << 2; +pub const RROutputPropertyNotifyMask: c_int = 1 << 3; +pub const RRProviderChangeNotifyMask: c_int = 1 << 4; +pub const RRProviderPropertyNotifyMask: c_int = 1 << 5; +pub const RRResourceChangeNotifyMask: c_int = 1 << 6; + +pub const RRScreenChangeNotify: c_int = 0; +pub const RRNotify: c_int = 1; +pub const RRNotify_CrtcChange: c_int = 0; +pub const RRNotify_OutputChange: c_int = 1; +pub const RRNotify_OutputProperty: c_int = 2; +pub const RRNotify_ProviderChange: c_int = 3; +pub const RRNotify_ProviderProperty: c_int = 4; +pub const RRNotify_ResourceChange: c_int = 5; + +pub const RR_Rotate_0: c_int = 1; +pub const RR_Rotate_90: c_int = 2; +pub const RR_Rotate_180: c_int = 4; +pub const RR_Rotate_270: c_int = 8; + +pub const RR_Reflect_X: c_int = 16; +pub const RR_Reflect_Y: c_int = 32; + +pub const RRSetConfigSuccess: c_int = 0; +pub const RRSetConfigInvalidConfigTime: c_int = 1; +pub const RRSetConfigInvalidTime: c_int = 2; +pub const RRSetConfigFailed: c_int = 3; + +pub const RR_HSyncPositive: c_int = 0x00000001; +pub const RR_HSyncNegative: c_int = 0x00000002; +pub const RR_VSyncPositive: c_int = 0x00000004; +pub const RR_VSyncNegative: c_int = 0x00000008; +pub const RR_Interlace: c_int = 0x00000010; +pub const RR_DoubleScan: c_int = 0x00000020; +pub const RR_CSync: c_int = 0x00000040; +pub const RR_CSyncPositive: c_int = 0x00000080; +pub const RR_CSyncNegative: c_int = 0x00000100; +pub const RR_HSkewPresent: c_int = 0x00000200; +pub const RR_BCast: c_int = 0x00000400; +pub const RR_PixelMultiplex: c_int = 0x00000800; +pub const RR_DoubleClock: c_int = 0x00001000; +pub const RR_ClockDivideBy2: c_int = 0x00002000; + +pub const RR_Connected: c_int = 0; +pub const RR_Disconnected: c_int = 1; +pub const RR_UnknownConnection: c_int = 2; + +pub const BadRROutput: c_int = 0; +pub const BadRRCrtc: c_int = 1; +pub const BadRRMode: c_int = 2; +pub const BadRRProvider: c_int = 3; + +pub const RR_PROPERTY_BACKLIGHT: &'static str = "Backlight"; +pub const RR_PROPERTY_RANDR_EDID: &'static str = "EDID"; +pub const RR_PROPERTY_SIGNAL_FORMAT: &'static str = "SignalFormat"; +pub const RR_PROPERTY_SIGNAL_PROPERTIES: &'static str = "SignalProperties"; +pub const RR_PROPERTY_CONNECTOR_TYPE: &'static str = "ConnectorType"; +pub const RR_PROPERTY_CONNECTOR_NUMBER: &'static str = "ConnectorNumber"; +pub const RR_PROPERTY_COMPATIBILITY_LIST: &'static str = "CompatibilityList"; +pub const RR_PROPERTY_CLONE_LIST: &'static str = "CloneList"; +pub const RR_PROPERTY_BORDER: &'static str = "Border"; +pub const RR_PROPERTY_BORDER_DIMENSIONS: &'static str = "BorderDimensions"; +pub const RR_PROPERTY_GUID: &'static str = "GUID"; +pub const RR_PROPERTY_RANDR_TILE: &'static str = "TILE"; + +pub const RR_Capability_None: c_int = 0; +pub const RR_Capability_SourceOutput: c_int = 1; +pub const RR_Capability_SinkOutput: c_int = 2; +pub const RR_Capability_SourceOffload: c_int = 4; +pub const RR_Capability_SinkOffload: c_int = 8; + diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xrecord.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xrecord.rs new file mode 100644 index 0000000..e11c36e --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xrecord.rs @@ -0,0 +1,137 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ + c_char, + c_int, + c_uchar, + c_ulong, + c_ushort, +}; + +use ::xlib::{ + Bool, + Display, + Time, + XID, +}; + + +// +// functions +// + + +x11_link! { Xf86vmode, xtst, ["libXtst.so.6", "libXtst.so"], 14, + pub fn XRecordAllocRange () -> *mut XRecordRange, + pub fn XRecordCreateContext (_6: *mut Display, _5: c_int, _4: *mut c_ulong, _3: c_int, _2: *mut *mut XRecordRange, _1: c_int) -> c_ulong, + pub fn XRecordDisableContext (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XRecordEnableContext (_4: *mut Display, _3: c_ulong, _2: Option<unsafe extern "C" fn (*mut c_char, *mut XRecordInterceptData)>, _1: *mut c_char) -> c_int, + pub fn XRecordEnableContextAsync (_4: *mut Display, _3: c_ulong, _2: Option<unsafe extern "C" fn (*mut c_char, *mut XRecordInterceptData)>, _1: *mut c_char) -> c_int, + pub fn XRecordFreeContext (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XRecordFreeData (_1: *mut XRecordInterceptData) -> (), + pub fn XRecordFreeState (_1: *mut XRecordState) -> (), + pub fn XRecordGetContext (_3: *mut Display, _2: c_ulong, _1: *mut *mut XRecordState) -> c_int, + pub fn XRecordIdBaseMask (_1: *mut Display) -> c_ulong, + pub fn XRecordProcessReplies (_1: *mut Display) -> (), + pub fn XRecordQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XRecordRegisterClients (_7: *mut Display, _6: c_ulong, _5: c_int, _4: *mut c_ulong, _3: c_int, _2: *mut *mut XRecordRange, _1: c_int) -> c_int, + pub fn XRecordUnregisterClients (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int, +variadic: +globals: +} + + +// +// constants +// + + +pub const XRecordFromServerTime: c_int = 0x01; +pub const XRecordFromClientTime: c_int = 0x02; +pub const XRecordFromClientSequence: c_int = 0x04; + +pub const XRecordCurrentClients: c_ulong = 1; +pub const XRecordFutureClients: c_ulong = 2; +pub const XRecordAllClients: c_ulong = 3; + +pub const XRecordFromServer: c_int = 0; +pub const XRecordFromClient: c_int = 1; +pub const XRecordClientStarted: c_int = 2; +pub const XRecordClientDied: c_int = 3; +pub const XRecordStartOfData: c_int = 4; +pub const XRecordEndOfData: c_int = 5; + + +// +// types +// + + +pub type XRecordClientSpec = c_ulong; +pub type XRecordContext = c_ulong; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRecordClientInfo { + pub client: XRecordClientSpec, + pub nranges: c_ulong, + pub ranges: *mut *mut XRecordRange, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRecordExtRange { + pub ext_major: XRecordRange8, + pub ext_minor: XRecordRange16, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRecordInterceptData { + pub id_base: XID, + pub server_time: Time, + pub client_seq: c_ulong, + pub category: c_int, + pub client_swapped: Bool, + pub data: *mut c_uchar, + pub data_len: c_ulong, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRecordRange { + pub core_requests: XRecordRange8, + pub core_replies: XRecordRange8, + pub ext_requests: XRecordExtRange, + pub ext_replies: XRecordExtRange, + pub delivered_events: XRecordRange8, + pub device_events: XRecordRange8, + pub errors: XRecordRange8, + pub client_started: Bool, + pub client_died: Bool, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRecordRange8 { + pub first: c_uchar, + pub last: c_uchar, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRecordRange16 { + pub first: c_ushort, + pub last: c_ushort, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRecordState { + pub enabled: Bool, + pub datum_flags: c_int, + pub nclients: c_ulong, + pub client_info: *mut *mut XRecordClientInfo, +} diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xrender.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xrender.rs new file mode 100644 index 0000000..9d6a3ac --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xrender.rs @@ -0,0 +1,463 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ + c_char, + c_double, + c_int, + c_short, + c_uint, + c_ulong, + c_ushort, +}; + +use ::xlib::{ + Atom, + Bool, + Colormap, + Cursor, + Display, + Pixmap, + Region, + Visual, + XID, + XRectangle, +}; + + +// +// functions +// + + +x11_link! { Xrender, xrender, ["libXrender.so.1", "libXrender.so"], 44, + pub fn XRenderAddGlyphs (_7: *mut Display, _6: c_ulong, _5: *const c_ulong, _4: *const XGlyphInfo, _3: c_int, _2: *const c_char, _1: c_int) -> (), + pub fn XRenderAddTraps (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: *const XTrap, _1: c_int) -> (), + pub fn XRenderChangePicture (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: *const XRenderPictureAttributes) -> (), + pub fn XRenderComposite (_13: *mut Display, _12: c_int, _11: c_ulong, _10: c_ulong, _9: c_ulong, _8: c_int, _7: c_int, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> (), + pub fn XRenderCompositeDoublePoly (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_int, _6: c_int, _5: c_int, _4: c_int, _3: *const XPointDouble, _2: c_int, _1: c_int) -> (), + pub fn XRenderCompositeString16 (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_ushort, _1: c_int) -> (), + pub fn XRenderCompositeString32 (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_uint, _1: c_int) -> (), + pub fn XRenderCompositeString8 (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> (), + pub fn XRenderCompositeText16 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: c_ulong, _7: *const XRenderPictFormat, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const XGlyphElt16, _1: c_int) -> (), + pub fn XRenderCompositeText32 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: c_ulong, _7: *const XRenderPictFormat, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const XGlyphElt32, _1: c_int) -> (), + pub fn XRenderCompositeText8 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: c_ulong, _7: *const XRenderPictFormat, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const XGlyphElt8, _1: c_int) -> (), + pub fn XRenderCompositeTrapezoids (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XTrapezoid, _1: c_int) -> (), + pub fn XRenderCompositeTriangles (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XTriangle, _1: c_int) -> (), + pub fn XRenderCompositeTriFan (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XPointFixed, _1: c_int) -> (), + pub fn XRenderCompositeTriStrip (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XPointFixed, _1: c_int) -> (), + pub fn XRenderCreateAnimCursor (_3: *mut Display, _2: c_int, _1: *mut XAnimCursor) -> c_ulong, + pub fn XRenderCreateConicalGradient (_5: *mut Display, _4: *const XConicalGradient, _3: *const c_int, _2: *const XRenderColor, _1: c_int) -> c_ulong, + pub fn XRenderCreateCursor (_4: *mut Display, _3: c_ulong, _2: c_uint, _1: c_uint) -> c_ulong, + pub fn XRenderCreateGlyphSet (_2: *mut Display, _1: *const XRenderPictFormat) -> c_ulong, + pub fn XRenderCreateLinearGradient (_5: *mut Display, _4: *const XLinearGradient, _3: *const c_int, _2: *const XRenderColor, _1: c_int) -> c_ulong, + pub fn XRenderCreatePicture (_5: *mut Display, _4: c_ulong, _3: *const XRenderPictFormat, _2: c_ulong, _1: *const XRenderPictureAttributes) -> c_ulong, + pub fn XRenderCreateRadialGradient (_5: *mut Display, _4: *const XRadialGradient, _3: *const c_int, _2: *const XRenderColor, _1: c_int) -> c_ulong, + pub fn XRenderCreateSolidFill (_2: *mut Display, _1: *const XRenderColor) -> c_ulong, + pub fn XRenderFillRectangle (_8: *mut Display, _7: c_int, _6: c_ulong, _5: *const XRenderColor, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> (), + pub fn XRenderFillRectangles (_6: *mut Display, _5: c_int, _4: c_ulong, _3: *const XRenderColor, _2: *const XRectangle, _1: c_int) -> (), + pub fn XRenderFindFormat (_4: *mut Display, _3: c_ulong, _2: *const XRenderPictFormat, _1: c_int) -> *mut XRenderPictFormat, + pub fn XRenderFindStandardFormat (_2: *mut Display, _1: c_int) -> *mut XRenderPictFormat, + pub fn XRenderFindVisualFormat (_2: *mut Display, _1: *const Visual) -> *mut XRenderPictFormat, + pub fn XRenderFreeGlyphs (_4: *mut Display, _3: c_ulong, _2: *const c_ulong, _1: c_int) -> (), + pub fn XRenderFreeGlyphSet (_2: *mut Display, _1: c_ulong) -> (), + pub fn XRenderFreePicture (_2: *mut Display, _1: c_ulong) -> (), + pub fn XRenderParseColor (_3: *mut Display, _2: *mut c_char, _1: *mut XRenderColor) -> c_int, + pub fn XRenderQueryExtension (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XRenderQueryFilters (_2: *mut Display, _1: c_ulong) -> *mut XFilters, + pub fn XRenderQueryFormats (_1: *mut Display) -> c_int, + pub fn XRenderQueryPictIndexValues (_3: *mut Display, _2: *const XRenderPictFormat, _1: *mut c_int) -> *mut XIndexValue, + pub fn XRenderQuerySubpixelOrder (_2: *mut Display, _1: c_int) -> c_int, + pub fn XRenderQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XRenderReferenceGlyphSet (_2: *mut Display, _1: c_ulong) -> c_ulong, + pub fn XRenderSetPictureClipRectangles (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: *const XRectangle, _1: c_int) -> (), + pub fn XRenderSetPictureClipRegion (_3: *mut Display, _2: c_ulong, _1: Region) -> (), + pub fn XRenderSetPictureFilter (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: *mut c_int, _1: c_int) -> (), + pub fn XRenderSetPictureTransform (_3: *mut Display, _2: c_ulong, _1: *mut XTransform) -> (), + pub fn XRenderSetSubpixelOrder (_3: *mut Display, _2: c_int, _1: c_int) -> c_int, +variadic: +globals: +} + + +// +// types +// + + +pub type Glyph = XID; +pub type GlyphSet = XID; +pub type PictFormat = XID; +pub type Picture = XID; +pub type XDouble = c_double; +pub type XFixed = c_int; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XAnimCursor { + pub cursor: Cursor, + pub delay: c_ulong, +} +pub type XAnimCursor = _XAnimCursor; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XCircle { + pub x: XFixed, + pub y: XFixed, + pub radius: XFixed, +} +pub type XCircle = _XCircle; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XConicalGradient { + pub center: XPointFixed, + pub angle: XFixed, +} +pub type XConicalGradient = _XConicalGradient; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XFilters { + pub nfilter: c_int, + pub filter: *mut *mut c_char, + pub nalias: c_int, + pub alias: *mut c_short, +} +pub type XFilters = _XFilters; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XGlyphElt8 { + pub glyphset: GlyphSet, + pub chars: *mut c_char, + pub nchars: c_int, + pub xOff: c_int, + pub yOff: c_int, +} +pub type XGlyphElt8 = _XGlyphElt8; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XGlyphElt16 { + pub glyphset: GlyphSet, + pub chars: *mut c_ushort, + pub nchars: c_int, + pub xOff: c_int, + pub yOff: c_int, +} +pub type XGlyphElt16 = _XGlyphElt16; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XGlyphElt32 { + pub glyphset: GlyphSet, + pub chars: *mut c_uint, + pub nchars: c_int, + pub xOff: c_int, + pub yOff: c_int, +} +pub type XGlyphElt32 = _XGlyphElt32; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XGlyphInfo { + pub width: c_ushort, + pub height: c_ushort, + pub x: c_short, + pub y: c_short, + pub xOff: c_short, + pub yOff: c_short, +} +pub type XGlyphInfo = _XGlyphInfo; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XIndexValue { + pub pixel: c_ulong, + pub red: c_ushort, + pub green: c_ushort, + pub blue: c_ushort, + pub alpha: c_ushort, +} +pub type XIndexValue = _XIndexValue; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XLinearGradient { + pub p1: XPointFixed, + pub p2: XPointFixed, +} +pub type XLinearGradient = _XLinearGradient; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XLineFixed { + pub p1: XPointFixed, + pub p2: XPointFixed, +} +pub type XLineFixed = _XLineFixed; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XPointDouble { + pub x: XDouble, + pub y: XDouble, +} +pub type XPointDouble = _XPointDouble; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XPointFixed { + pub x: XFixed, + pub y: XFixed, +} +pub type XPointFixed = _XPointFixed; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XRadialGradient { + pub inner: XCircle, + pub outer: XCircle, +} +pub type XRadialGradient = _XRadialGradient; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRenderColor { + pub red: c_ushort, + pub green: c_ushort, + pub blue: c_ushort, + pub alpha: c_ushort, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRenderDirectFormat { + pub red: c_short, + pub redMask: c_short, + pub green: c_short, + pub greenMask: c_short, + pub blue: c_short, + pub blueMask: c_short, + pub alpha: c_short, + pub alphaMask: c_short, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XRenderPictFormat { + pub id: PictFormat, + pub type_: c_int, + pub depth: c_int, + pub direct: XRenderDirectFormat, + pub colormap: Colormap, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XRenderPictureAttributes { + pub repeat: c_int, + pub alpha_map: Picture, + pub alpha_x_origin: c_int, + pub alpha_y_origin: c_int, + pub clip_x_origin: c_int, + pub clip_y_origin: c_int, + pub clip_mask: Pixmap, + pub graphics_exposures: Bool, + pub subwindow_mode: c_int, + pub poly_edge: c_int, + pub poly_mode: c_int, + pub dither: Atom, + pub component_alpha: Bool, +} +pub type XRenderPictureAttributes = _XRenderPictureAttributes; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XSpanFix { + pub left: XFixed, + pub right: XFixed, + pub y: XFixed, +} +pub type XSpanFix = _XSpanFix; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XTrap { + pub top: XSpanFix, + pub bottom: XSpanFix, +} +pub type XTrap = _XTrap; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XTrapezoid { + pub top: XFixed, + pub bottom: XFixed, + pub left: XLineFixed, + pub right: XLineFixed, +} +pub type XTrapezoid = _XTrapezoid; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XTriangle { + pub p1: XPointFixed, + pub p2: XPointFixed, + pub p3: XPointFixed, +} +pub type XTriangle = _XTriangle; + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct _XTransform { + pub matrix: [[XFixed; 3]; 3], +} +pub type XTransform = _XTransform; + + +// +// constants +// + + +// pict format mask +pub const PictFormatID: c_ulong = 1 << 0; +pub const PictFormatType: c_ulong = 1 << 1; +pub const PictFormatDepth: c_ulong = 1 << 2; +pub const PictFormatRed: c_ulong = 1 << 3; +pub const PictFormatRedMask: c_ulong = 1 << 4; +pub const PictFormatGreen: c_ulong = 1 << 5; +pub const PictFormatGreenMask: c_ulong = 1 << 6; +pub const PictFormatBlue: c_ulong = 1 << 7; +pub const PictFormatBlueMask: c_ulong = 1 << 8; +pub const PictFormatAlpha: c_ulong = 1 << 9; +pub const PictFormatAlphaMask: c_ulong = 1 << 10; +pub const PictFormatColormap: c_ulong = 1 << 11; + +// error codes +pub const BadPictFormat: c_int = 0; +pub const BadPicture: c_int = 1; +pub const BadPictOp: c_int = 2; +pub const BadGlyphSet: c_int = 3; +pub const BadGlyph: c_int = 4; +pub const RenderNumberErrors: c_int = BadGlyph + 1; + +// pict types +pub const PictTypeIndexed: c_int = 0; +pub const PictTypeDirect: c_int = 1; + +// ops +pub const PictOpMinimum: c_int = 0; +pub const PictOpClear: c_int = 0; +pub const PictOpSrc: c_int = 1; +pub const PictOpDst: c_int = 2; +pub const PictOpOver: c_int = 3; +pub const PictOpOverReverse: c_int = 4; +pub const PictOpIn: c_int = 5; +pub const PictOpInReverse: c_int = 6; +pub const PictOpOut: c_int = 7; +pub const PictOpOutReverse: c_int = 8; +pub const PictOpAtop: c_int = 9; +pub const PictOpAtopReverse: c_int = 10; +pub const PictOpXor: c_int = 11; +pub const PictOpAdd: c_int = 12; +pub const PictOpSaturate: c_int = 13; +pub const PictOpMaximum: c_int = 13; + +pub const PictOpDisjointMinimum: c_int = 0x10; +pub const PictOpDisjointClear: c_int = 0x10; +pub const PictOpDisjointSrc: c_int = 0x11; +pub const PictOpDisjointDst: c_int = 0x12; +pub const PictOpDisjointOver: c_int = 0x13; +pub const PictOpDisjointOverReverse: c_int = 0x14; +pub const PictOpDisjointIn: c_int = 0x15; +pub const PictOpDisjointInReverse: c_int = 0x16; +pub const PictOpDisjointOut: c_int = 0x17; +pub const PictOpDisjointOutReverse: c_int = 0x18; +pub const PictOpDisjointAtop: c_int = 0x19; +pub const PictOpDisjointAtopReverse: c_int = 0x1a; +pub const PictOpDisjointXor: c_int = 0x1b; +pub const PictOpDisjointMaximum: c_int = 0x1b; + +pub const PictOpConjointMinimum: c_int = 0x20; +pub const PictOpConjointClear: c_int = 0x20; +pub const PictOpConjointSrc: c_int = 0x21; +pub const PictOpConjointDst: c_int = 0x22; +pub const PictOpConjointOver: c_int = 0x23; +pub const PictOpConjointOverReverse: c_int = 0x24; +pub const PictOpConjointIn: c_int = 0x25; +pub const PictOpConjointInReverse: c_int = 0x26; +pub const PictOpConjointOut: c_int = 0x27; +pub const PictOpConjointOutReverse: c_int = 0x28; +pub const PictOpConjointAtop: c_int = 0x29; +pub const PictOpConjointAtopReverse: c_int = 0x2a; +pub const PictOpConjointXor: c_int = 0x2b; +pub const PictOpConjointMaximum: c_int = 0x2b; + +pub const PictOpBlendMinimum: c_int = 0x30; +pub const PictOpMultiply: c_int = 0x30; +pub const PictOpScreen: c_int = 0x31; +pub const PictOpOverlay: c_int = 0x32; +pub const PictOpDarken: c_int = 0x33; +pub const PictOpLighten: c_int = 0x34; +pub const PictOpColorDodge: c_int = 0x35; +pub const PictOpColorBurn: c_int = 0x36; +pub const PictOpHardLight: c_int = 0x37; +pub const PictOpSoftLight: c_int = 0x38; +pub const PictOpDifference: c_int = 0x39; +pub const PictOpExclusion: c_int = 0x3a; +pub const PictOpHSLHue: c_int = 0x3b; +pub const PictOpHSLSaturation: c_int = 0x3c; +pub const PictOpHSLColor: c_int = 0x3d; +pub const PictOpHSLLuminosity: c_int = 0x3e; +pub const PictOpBlendMaximum: c_int = 0x3e; + +// poly edge types +pub const PolyEdgeSharp: c_int = 0; +pub const PolyEdgeSmooth: c_int = 1; + +// poly modes +pub const PolyModePrecise: c_int = 0; +pub const PolyModeImprecise: c_int = 1; + +// picture attributes mask +pub const CPRepeat: c_int = 1 << 0; +pub const CPAlphaMap: c_int = 1 << 1; +pub const CPAlphaXOrigin: c_int = 1 << 2; +pub const CPAlphaYOrigin: c_int = 1 << 3; +pub const CPClipXOrigin: c_int = 1 << 4; +pub const CPClipYOrigin: c_int = 1 << 5; +pub const CPClipMask: c_int = 1 << 6; +pub const CPGraphicsExposure: c_int = 1 << 7; +pub const CPSubwindowMode: c_int = 1 << 8; +pub const CPPolyEdge: c_int = 1 << 9; +pub const CPPolyMode: c_int = 1 << 10; +pub const CPDither: c_int = 1 << 11; +pub const CPComponentAlpha: c_int = 1 << 12; +pub const CPLastBit: c_int = 12; + +// filter methods +pub const FilterNearest: &'static str = "nearest"; +pub const FilterBilinear: &'static str = "bilinear"; +pub const FilterConvolution: &'static str = "convolution"; +pub const FilterFast: &'static str = "fast"; +pub const FilterGood: &'static str = "good"; +pub const FilterBest: &'static str = "best"; + +// subpixel orders +pub const SubPixelUnknown: c_int = 0; +pub const SubPixelHorizontalRGB: c_int = 1; +pub const SubPixelHorizontalBGR: c_int = 2; +pub const SubPixelVerticalRGB: c_int = 3; +pub const SubPixelVerticalBGR: c_int = 4; +pub const SubPixelNone: c_int = 5; + +// repeat attributes +pub const RepeatNone: c_int = 0; +pub const RepeatNormal: c_int = 1; +pub const RepeatPad: c_int = 2; +pub const RepeatReflect: c_int = 3; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xss.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xss.rs new file mode 100644 index 0000000..27e35b7 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xss.rs @@ -0,0 +1,98 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ c_int, c_uint, c_ulong }; + +use xlib::{ Atom, Bool, Display, Drawable, Status, Time, Visual, XEvent, XID, XSetWindowAttributes, Window }; + + +// +// functions +// + + +x11_link! { Xss, xscrnsaver, ["libXss.so.2", "libXss.so"], 11, + pub fn XScreenSaverQueryExtension (_1: *mut Display, _2: *mut c_int, _3: *mut c_int) -> Bool, + pub fn XScreenSaverQueryVersion (_1: *mut Display, _2: *mut c_int, _3: *mut c_int) -> Status, + pub fn XScreenSaverAllocInfo () -> *mut XScreenSaverInfo, + pub fn XScreenSaverQueryInfo (_1: *mut Display, _2: Drawable, _3: *mut XScreenSaverInfo) -> Status, + pub fn XScreenSaverSelectInput (_1: *mut Display, _2: Drawable, _3: c_ulong) -> (), + pub fn XScreenSaverSetAttributes (_1: *mut Display, _2: Drawable, _3: c_int, _4: c_int, _5: c_uint, _6: c_uint, _7: c_uint, _8: c_int, _9: c_uint, _10: *mut Visual, _11: c_ulong, _12: *mut XSetWindowAttributes) -> (), + pub fn XScreenSaverUnsetAttributes (_1: *mut Display, _2: Drawable) -> (), + pub fn XScreenSaverRegister (_1: *mut Display, _2: c_int, _3: XID, _4: Atom) -> Status, + pub fn XScreenSaverUnregister (_1: *mut Display, _2: c_int) -> Status, + pub fn XScreenSaverGetRegistered (_1: *mut Display, _2: c_int, _3: *mut XID, _4: *mut Atom) -> Status, + pub fn XScreenSaverSuspend (_1: *mut Display, _2: Bool) -> (), +variadic: +globals: +} + + +// +// types +// + + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XScreenSaverInfo { + pub window: Window, + pub state: c_int, + pub kind: c_int, + pub til_or_since: c_ulong, + pub idle: c_ulong, + pub eventMask: c_ulong, +} + + +// +// event structures +// + + +#[derive(Debug, Clone, Copy, PartialEq)] +#[repr(C)] +pub struct XScreenSaverNotifyEvent { + pub type_: c_int, + pub serial: c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub window: Window, + pub root: Window, + pub state: c_int, + pub kind: c_int, + pub forced: Bool, + pub time: Time, +} + +event_conversions_and_tests! { + xss_notify: XScreenSaverNotifyEvent, +} + + +// +// constants +// + + +pub const ScreenSaverName: &'static str = "MIT-SCREEN-SAVER"; +pub const ScreenSaverPropertyName: &'static str = "_MIT_SCREEN_SAVER_ID"; + +pub const ScreenSaverNotifyMask: c_ulong = 0x00000001; +pub const ScreenSaverCycleMask: c_ulong = 0x00000002; + +pub const ScreenSaverMajorVersion: c_int = 1; +pub const ScreenSaverMinorVersion: c_int = 1; + +pub const ScreenSaverOff: c_int = 0; +pub const ScreenSaverOn: c_int = 1; +pub const ScreenSaverCycle: c_int = 2; +pub const ScreenSaverDisabled: c_int = 3; + +pub const ScreenSaverBlanked: c_int = 0; +pub const ScreenSaverInternal: c_int = 1; +pub const ScreenSaverExternal: c_int = 2; + +pub const ScreenSaverNotify: c_int = 0; +pub const ScreenSaverNumberEvents: c_int = 1; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xt.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xt.rs new file mode 100644 index 0000000..afecdd0 --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xt.rs @@ -0,0 +1,398 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ + c_char, + c_int, + c_long, + c_short, + c_uchar, + c_uint, + c_ulong, + c_ushort, + c_void, +}; + +use ::xlib::{ + Display, + GC, + Region, + Screen, + Visual, + XEvent, + XGCValues, + _XrmHashBucketRec, + XrmOptionDescList, + XrmValue, + XSelectionRequestEvent, + XSetWindowAttributes, +}; + + +// +// functions +// + + +x11_link! { Xt, xt, ["libXt.so.6", "libXt.so"], 300, + pub fn XtAddActions (_2: *mut XtActionsRec, _1: c_uint) -> (), + pub fn XtAddCallback (_4: Widget, _3: *const c_char, _2: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut c_void)>, _1: *mut c_void) -> (), + pub fn XtAddCallbacks (_3: Widget, _2: *const c_char, _1: XtCallbackList) -> (), + pub fn XtAddConverter (_5: *const c_char, _4: *const c_char, _3: Option<unsafe extern "C" fn (*mut XrmValue, *mut c_uint, *mut XrmValue, *mut XrmValue)>, _2: XtConvertArgList, _1: c_uint) -> (), + pub fn XtAddEventHandler (_5: Widget, _4: c_ulong, _3: c_char, _2: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut XEvent, *mut c_char)>, _1: *mut c_void) -> (), + pub fn XtAddExposureToRegion (_2: *mut XEvent, _1: Region) -> (), + pub fn XtAddGrab (_3: Widget, _2: c_char, _1: c_char) -> (), + pub fn XtAddInput (_4: c_int, _3: *mut c_void, _2: Option<unsafe extern "C" fn (*mut c_void, *mut c_int, *mut c_ulong)>, _1: *mut c_void) -> c_ulong, + pub fn XtAddRawEventHandler (_5: Widget, _4: c_ulong, _3: c_char, _2: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut XEvent, *mut c_char)>, _1: *mut c_void) -> (), + pub fn XtAddSignal (_2: Option<unsafe extern "C" fn (*mut c_void, *mut c_ulong)>, _1: *mut c_void) -> c_ulong, + pub fn XtAddTimeOut (_3: c_ulong, _2: Option<unsafe extern "C" fn (*mut c_void, *mut c_ulong)>, _1: *mut c_void) -> c_ulong, + pub fn XtAddWorkProc (_2: Option<unsafe extern "C" fn (*mut c_void) -> c_char>, _1: *mut c_void) -> c_ulong, + pub fn XtAllocateGC (_6: Widget, _5: c_uint, _4: c_ulong, _3: *mut XGCValues, _2: c_ulong, _1: c_ulong) -> GC, + pub fn XtAppAddActionHook (_3: XtAppContext, _2: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut c_char, *mut XEvent, *mut *mut c_char, *mut c_uint)>, _1: *mut c_void) -> *mut c_void, + pub fn XtAppAddActions (_3: XtAppContext, _2: *mut XtActionsRec, _1: c_uint) -> (), + pub fn XtAppAddBlockHook (_3: XtAppContext, _2: Option<unsafe extern "C" fn (*mut c_void)>, _1: *mut c_void) -> c_ulong, + pub fn XtAppAddConverter (_6: XtAppContext, _5: *const c_char, _4: *const c_char, _3: Option<unsafe extern "C" fn (*mut XrmValue, *mut c_uint, *mut XrmValue, *mut XrmValue)>, _2: XtConvertArgList, _1: c_uint) -> (), + pub fn XtAppAddInput (_5: XtAppContext, _4: c_int, _3: *mut c_void, _2: Option<unsafe extern "C" fn (*mut c_void, *mut c_int, *mut c_ulong)>, _1: *mut c_void) -> c_ulong, + pub fn XtAppAddSignal (_3: XtAppContext, _2: Option<unsafe extern "C" fn (*mut c_void, *mut c_ulong)>, _1: *mut c_void) -> c_ulong, + pub fn XtAppAddTimeOut (_4: XtAppContext, _3: c_ulong, _2: Option<unsafe extern "C" fn (*mut c_void, *mut c_ulong)>, _1: *mut c_void) -> c_ulong, + pub fn XtAppAddWorkProc (_3: XtAppContext, _2: Option<unsafe extern "C" fn (*mut c_void) -> c_char>, _1: *mut c_void) -> c_ulong, + pub fn XtAppCreateShell (_6: *const c_char, _5: *const c_char, _4: WidgetClass, _3: *mut Display, _2: *mut Arg, _1: c_uint) -> Widget, + pub fn XtAppError (_2: XtAppContext, _1: *const c_char) -> (), + pub fn XtAppErrorMsg (_7: XtAppContext, _6: *const c_char, _5: *const c_char, _4: *const c_char, _3: *const c_char, _2: *mut *mut c_char, _1: *mut c_uint) -> (), + pub fn XtAppGetErrorDatabase (_1: XtAppContext) -> *mut *mut _XrmHashBucketRec, + pub fn XtAppGetErrorDatabaseText (_8: XtAppContext, _7: *const c_char, _6: *const c_char, _5: *const c_char, _4: *const c_char, _3: *mut c_char, _2: c_int, _1: *mut _XrmHashBucketRec) -> (), + pub fn XtAppGetExitFlag (_1: XtAppContext) -> c_char, + pub fn XtAppGetSelectionTimeout (_1: XtAppContext) -> c_ulong, + pub fn XtAppInitialize (_9: *mut XtAppContext, _8: *const c_char, _7: XrmOptionDescList, _6: c_uint, _5: *mut c_int, _4: *mut *mut c_char, _3: *mut *mut c_char, _2: *mut Arg, _1: c_uint) -> Widget, + pub fn XtAppLock (_1: XtAppContext) -> (), + pub fn XtAppMainLoop (_1: XtAppContext) -> (), + pub fn XtAppNextEvent (_2: XtAppContext, _1: *mut XEvent) -> (), + pub fn XtAppPeekEvent (_2: XtAppContext, _1: *mut XEvent) -> c_char, + pub fn XtAppPending (_1: XtAppContext) -> c_ulong, + pub fn XtAppProcessEvent (_2: XtAppContext, _1: c_ulong) -> (), + pub fn XtAppReleaseCacheRefs (_2: XtAppContext, _1: *mut *mut c_void) -> (), + pub fn XtAppSetErrorHandler (_2: XtAppContext, _1: Option<unsafe extern "C" fn (*mut c_char)>) -> Option<unsafe extern "C" fn (*mut c_char)>, + pub fn XtAppSetErrorMsgHandler (_2: XtAppContext, _1: Option<unsafe extern "C" fn (*mut c_char, *mut c_char, *mut c_char, *mut c_char, *mut *mut c_char, *mut c_uint)>) -> Option<unsafe extern "C" fn (*mut c_char, *mut c_char, *mut c_char, *mut c_char, *mut *mut c_char, *mut c_uint)>, + pub fn XtAppSetExitFlag (_1: XtAppContext) -> (), + pub fn XtAppSetFallbackResources (_2: XtAppContext, _1: *mut *mut c_char) -> (), + pub fn XtAppSetSelectionTimeout (_2: XtAppContext, _1: c_ulong) -> (), + pub fn XtAppSetTypeConverter (_8: XtAppContext, _7: *const c_char, _6: *const c_char, _5: Option<unsafe extern "C" fn (*mut Display, *mut XrmValue, *mut c_uint, *mut XrmValue, *mut XrmValue, *mut *mut c_void) -> c_char>, _4: XtConvertArgList, _3: c_uint, _2: c_int, _1: Option<unsafe extern "C" fn (XtAppContext, *mut XrmValue, *mut c_void, *mut XrmValue, *mut c_uint)>) -> (), + pub fn XtAppSetWarningHandler (_2: XtAppContext, _1: Option<unsafe extern "C" fn (*mut c_char)>) -> Option<unsafe extern "C" fn (*mut c_char)>, + pub fn XtAppSetWarningMsgHandler (_2: XtAppContext, _1: Option<unsafe extern "C" fn (*mut c_char, *mut c_char, *mut c_char, *mut c_char, *mut *mut c_char, *mut c_uint)>) -> Option<unsafe extern "C" fn (*mut c_char, *mut c_char, *mut c_char, *mut c_char, *mut *mut c_char, *mut c_uint)>, + pub fn XtAppUnlock (_1: XtAppContext) -> (), + pub fn XtAppWarning (_2: XtAppContext, _1: *const c_char) -> (), + pub fn XtAppWarningMsg (_7: XtAppContext, _6: *const c_char, _5: *const c_char, _4: *const c_char, _3: *const c_char, _2: *mut *mut c_char, _1: *mut c_uint) -> (), + pub fn XtAugmentTranslations (_2: Widget, _1: *mut _TranslationData) -> (), + pub fn XtBuildEventMask (_1: Widget) -> c_ulong, + pub fn XtCallAcceptFocus (_2: Widget, _1: *mut c_ulong) -> c_char, + pub fn XtCallActionProc (_5: Widget, _4: *const c_char, _3: *mut XEvent, _2: *mut *mut c_char, _1: c_uint) -> (), + pub fn XtCallbackExclusive (_3: Widget, _2: *mut c_void, _1: *mut c_void) -> (), + pub fn XtCallbackNone (_3: Widget, _2: *mut c_void, _1: *mut c_void) -> (), + pub fn XtCallbackNonexclusive (_3: Widget, _2: *mut c_void, _1: *mut c_void) -> (), + pub fn XtCallbackPopdown (_3: Widget, _2: *mut c_void, _1: *mut c_void) -> (), + pub fn XtCallbackReleaseCacheRef (_3: Widget, _2: *mut c_void, _1: *mut c_void) -> (), + pub fn XtCallbackReleaseCacheRefList (_3: Widget, _2: *mut c_void, _1: *mut c_void) -> (), + pub fn XtCallCallbackList (_3: Widget, _2: XtCallbackList, _1: *mut c_void) -> (), + pub fn XtCallCallbacks (_3: Widget, _2: *const c_char, _1: *mut c_void) -> (), + pub fn XtCallConverter (_7: *mut Display, _6: Option<unsafe extern "C" fn (*mut Display, *mut XrmValue, *mut c_uint, *mut XrmValue, *mut XrmValue, *mut *mut c_void) -> c_char>, _5: *mut XrmValue, _4: c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCalloc (_2: c_uint, _1: c_uint) -> *mut c_char, + pub fn XtCancelSelectionRequest (_2: Widget, _1: c_ulong) -> (), + pub fn XtChangeManagedSet (_6: *mut Widget, _5: c_uint, _4: Option<unsafe extern "C" fn (Widget, *mut Widget, *mut c_uint, *mut Widget, *mut c_uint, *mut c_void)>, _3: *mut c_void, _2: *mut Widget, _1: c_uint) -> (), + pub fn XtClass (_1: Widget) -> WidgetClass, + pub fn XtCloseDisplay (_1: *mut Display) -> (), + pub fn XtConfigureWidget (_6: Widget, _5: c_short, _4: c_short, _3: c_ushort, _2: c_ushort, _1: c_ushort) -> (), + pub fn XtConvert (_5: Widget, _4: *const c_char, _3: *mut XrmValue, _2: *const c_char, _1: *mut XrmValue) -> (), + pub fn XtConvertAndStore (_5: Widget, _4: *const c_char, _3: *mut XrmValue, _2: *const c_char, _1: *mut XrmValue) -> c_char, + pub fn XtConvertCase (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: *mut c_ulong) -> (), + pub fn XtCreateApplicationContext () -> XtAppContext, + pub fn XtCreateApplicationShell (_4: *const c_char, _3: WidgetClass, _2: *mut Arg, _1: c_uint) -> Widget, + pub fn XtCreateManagedWidget (_5: *const c_char, _4: WidgetClass, _3: Widget, _2: *mut Arg, _1: c_uint) -> Widget, + pub fn XtCreatePopupShell (_5: *const c_char, _4: WidgetClass, _3: Widget, _2: *mut Arg, _1: c_uint) -> Widget, + pub fn XtCreateSelectionRequest (_2: Widget, _1: c_ulong) -> (), + pub fn XtCreateWidget (_5: *const c_char, _4: WidgetClass, _3: Widget, _2: *mut Arg, _1: c_uint) -> Widget, + pub fn XtCreateWindow (_5: Widget, _4: c_uint, _3: *mut Visual, _2: c_ulong, _1: *mut XSetWindowAttributes) -> (), + pub fn XtCvtColorToPixel (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtIntToBool (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtIntToBoolean (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtIntToColor (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtIntToFloat (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtIntToFont (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtIntToPixel (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtIntToPixmap (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtIntToShort (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtIntToUnsignedChar (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToAcceleratorTable (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToAtom (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToBool (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToBoolean (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToCommandArgArray (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToCursor (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToDimension (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToDirectoryString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToDisplay (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToFile (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToFloat (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToFont (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToFontSet (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToFontStruct (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToGravity (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToInitialState (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToInt (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToPixel (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToRestartStyle (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToShort (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToTranslationTable (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToUnsignedChar (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtCvtStringToVisual (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, + pub fn XtDatabase (_1: *mut Display) -> *mut _XrmHashBucketRec, + pub fn XtDestroyApplicationContext (_1: XtAppContext) -> (), + pub fn XtDestroyGC (_1: GC) -> (), + pub fn XtDestroyWidget (_1: Widget) -> (), + pub fn XtDirectConvert (_5: Option<unsafe extern "C" fn (*mut XrmValue, *mut c_uint, *mut XrmValue, *mut XrmValue)>, _4: *mut XrmValue, _3: c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), + pub fn XtDisownSelection (_3: Widget, _2: c_ulong, _1: c_ulong) -> (), + pub fn XtDispatchEvent (_1: *mut XEvent) -> c_char, + pub fn XtDispatchEventToWidget (_2: Widget, _1: *mut XEvent) -> c_char, + pub fn XtDisplay (_1: Widget) -> *mut Display, + pub fn XtDisplayInitialize (_8: XtAppContext, _7: *mut Display, _6: *const c_char, _5: *const c_char, _4: XrmOptionDescList, _3: c_uint, _2: *mut c_int, _1: *mut *mut c_char) -> (), + pub fn XtDisplayOfObject (_1: Widget) -> *mut Display, + pub fn XtDisplayStringConversionWarning (_3: *mut Display, _2: *const c_char, _1: *const c_char) -> (), + pub fn XtDisplayToApplicationContext (_1: *mut Display) -> XtAppContext, + pub fn XtError (_1: *const c_char) -> (), + pub fn XtErrorMsg (_6: *const c_char, _5: *const c_char, _4: *const c_char, _3: *const c_char, _2: *mut *mut c_char, _1: *mut c_uint) -> (), + pub fn XtFindFile (_4: *const c_char, _3: Substitution, _2: c_uint, _1: Option<unsafe extern "C" fn (*mut c_char) -> c_char>) -> *mut c_char, + pub fn XtFree (_1: *mut c_char) -> (), + pub fn XtGetActionKeysym (_2: *mut XEvent, _1: *mut c_uint) -> c_ulong, + pub fn XtGetActionList (_3: WidgetClass, _2: *mut *mut XtActionsRec, _1: *mut c_uint) -> (), + pub fn XtGetApplicationNameAndClass (_3: *mut Display, _2: *mut *mut c_char, _1: *mut *mut c_char) -> (), + pub fn XtGetApplicationResources (_6: Widget, _5: *mut c_void, _4: *mut XtResource, _3: c_uint, _2: *mut Arg, _1: c_uint) -> (), + pub fn XtGetClassExtension (_5: WidgetClass, _4: c_uint, _3: c_int, _2: c_long, _1: c_uint) -> *mut c_void, + pub fn XtGetConstraintResourceList (_3: WidgetClass, _2: *mut *mut XtResource, _1: *mut c_uint) -> (), + pub fn XtGetDisplays (_3: XtAppContext, _2: *mut *mut *mut Display, _1: *mut c_uint) -> (), + pub fn XtGetErrorDatabase () -> *mut *mut _XrmHashBucketRec, + pub fn XtGetErrorDatabaseText (_6: *const c_char, _5: *const c_char, _4: *const c_char, _3: *const c_char, _2: *mut c_char, _1: c_int) -> (), + pub fn XtGetGC (_3: Widget, _2: c_ulong, _1: *mut XGCValues) -> GC, + pub fn XtGetKeyboardFocusWidget (_1: Widget) -> Widget, + pub fn XtGetKeysymTable (_3: *mut Display, _2: *mut c_uchar, _1: *mut c_int) -> *mut c_ulong, + pub fn XtGetMultiClickTime (_1: *mut Display) -> c_int, + pub fn XtGetResourceList (_3: WidgetClass, _2: *mut *mut XtResource, _1: *mut c_uint) -> (), + pub fn XtGetSelectionParameters (_7: Widget, _6: c_ulong, _5: *mut c_void, _4: *mut c_ulong, _3: *mut *mut c_void, _2: *mut c_ulong, _1: *mut c_int) -> (), + pub fn XtGetSelectionRequest (_3: Widget, _2: c_ulong, _1: *mut c_void) -> *mut XSelectionRequestEvent, + pub fn XtGetSelectionTimeout () -> c_ulong, + pub fn XtGetSelectionValue (_6: Widget, _5: c_ulong, _4: c_ulong, _3: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut c_ulong, *mut c_ulong, *mut c_void, *mut c_ulong, *mut c_int)>, _2: *mut c_void, _1: c_ulong) -> (), + pub fn XtGetSelectionValueIncremental (_6: Widget, _5: c_ulong, _4: c_ulong, _3: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut c_ulong, *mut c_ulong, *mut c_void, *mut c_ulong, *mut c_int)>, _2: *mut c_void, _1: c_ulong) -> (), + pub fn XtGetSelectionValues (_7: Widget, _6: c_ulong, _5: *mut c_ulong, _4: c_int, _3: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut c_ulong, *mut c_ulong, *mut c_void, *mut c_ulong, *mut c_int)>, _2: *mut *mut c_void, _1: c_ulong) -> (), + pub fn XtGetSelectionValuesIncremental (_7: Widget, _6: c_ulong, _5: *mut c_ulong, _4: c_int, _3: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut c_ulong, *mut c_ulong, *mut c_void, *mut c_ulong, *mut c_int)>, _2: *mut *mut c_void, _1: c_ulong) -> (), + pub fn XtGetSubresources (_8: Widget, _7: *mut c_void, _6: *const c_char, _5: *const c_char, _4: *mut XtResource, _3: c_uint, _2: *mut Arg, _1: c_uint) -> (), + pub fn XtGetSubvalues (_5: *mut c_void, _4: *mut XtResource, _3: c_uint, _2: *mut Arg, _1: c_uint) -> (), + pub fn XtGetValues (_3: Widget, _2: *mut Arg, _1: c_uint) -> (), + pub fn XtGrabButton (_9: Widget, _8: c_int, _7: c_uint, _6: c_char, _5: c_uint, _4: c_int, _3: c_int, _2: c_ulong, _1: c_ulong) -> (), + pub fn XtGrabKey (_6: Widget, _5: c_uchar, _4: c_uint, _3: c_char, _2: c_int, _1: c_int) -> (), + pub fn XtGrabKeyboard (_5: Widget, _4: c_char, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XtGrabPointer (_8: Widget, _7: c_char, _6: c_uint, _5: c_int, _4: c_int, _3: c_ulong, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XtHasCallbacks (_2: Widget, _1: *const c_char) -> XtCallbackStatus, + pub fn XtHooksOfDisplay (_1: *mut Display) -> Widget, + pub fn XtInitialize (_6: *const c_char, _5: *const c_char, _4: XrmOptionDescList, _3: c_uint, _2: *mut c_int, _1: *mut *mut c_char) -> Widget, + pub fn XtInitializeWidgetClass (_1: WidgetClass) -> (), + pub fn XtInsertEventHandler (_6: Widget, _5: c_ulong, _4: c_char, _3: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut XEvent, *mut c_char)>, _2: *mut c_void, _1: XtListPosition) -> (), + pub fn XtInsertEventTypeHandler (_6: Widget, _5: c_int, _4: *mut c_void, _3: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut XEvent, *mut c_char)>, _2: *mut c_void, _1: XtListPosition) -> (), + pub fn XtInsertRawEventHandler (_6: Widget, _5: c_ulong, _4: c_char, _3: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut XEvent, *mut c_char)>, _2: *mut c_void, _1: XtListPosition) -> (), + pub fn XtInstallAccelerators (_2: Widget, _1: Widget) -> (), + pub fn XtInstallAllAccelerators (_2: Widget, _1: Widget) -> (), + pub fn XtIsApplicationShell (_1: Widget) -> c_char, + pub fn XtIsComposite (_1: Widget) -> c_char, + pub fn XtIsConstraint (_1: Widget) -> c_char, + pub fn XtIsManaged (_1: Widget) -> c_char, + pub fn XtIsObject (_1: Widget) -> c_char, + pub fn XtIsOverrideShell (_1: Widget) -> c_char, + pub fn XtIsRealized (_1: Widget) -> c_char, + pub fn XtIsRectObj (_1: Widget) -> c_char, + pub fn XtIsSensitive (_1: Widget) -> c_char, + pub fn XtIsSessionShell (_1: Widget) -> c_char, + pub fn XtIsShell (_1: Widget) -> c_char, + pub fn XtIsSubclass (_2: Widget, _1: WidgetClass) -> c_char, + pub fn XtIsTopLevelShell (_1: Widget) -> c_char, + pub fn XtIsTransientShell (_1: Widget) -> c_char, + pub fn XtIsVendorShell (_1: Widget) -> c_char, + pub fn XtIsWidget (_1: Widget) -> c_char, + pub fn XtIsWMShell (_1: Widget) -> c_char, + pub fn XtKeysymToKeycodeList (_4: *mut Display, _3: c_ulong, _2: *mut *mut c_uchar, _1: *mut c_uint) -> (), + pub fn XtLastEventProcessed (_1: *mut Display) -> *mut XEvent, + pub fn XtLastTimestampProcessed (_1: *mut Display) -> c_ulong, + pub fn XtMainLoop () -> (), + pub fn XtMakeGeometryRequest (_3: Widget, _2: *mut XtWidgetGeometry, _1: *mut XtWidgetGeometry) -> XtGeometryResult, + pub fn XtMakeResizeRequest (_5: Widget, _4: c_ushort, _3: c_ushort, _2: *mut c_ushort, _1: *mut c_ushort) -> XtGeometryResult, + pub fn XtMalloc (_1: c_uint) -> *mut c_char, + pub fn XtManageChild (_1: Widget) -> (), + pub fn XtManageChildren (_2: *mut Widget, _1: c_uint) -> (), + pub fn XtMapWidget (_1: Widget) -> (), + pub fn XtMenuPopupAction (_4: Widget, _3: *mut XEvent, _2: *mut *mut c_char, _1: *mut c_uint) -> (), + pub fn XtMergeArgLists (_4: *mut Arg, _3: c_uint, _2: *mut Arg, _1: c_uint) -> *mut Arg, + pub fn XtMoveWidget (_3: Widget, _2: c_short, _1: c_short) -> (), + pub fn XtName (_1: Widget) -> *mut c_char, + pub fn XtNameToWidget (_2: Widget, _1: *const c_char) -> Widget, + pub fn XtNewString (_1: *mut c_char) -> *mut c_char, + pub fn XtNextEvent (_1: *mut XEvent) -> (), + pub fn XtNoticeSignal (_1: c_ulong) -> (), + pub fn XtOpenApplication (_10: *mut XtAppContext, _9: *const c_char, _8: XrmOptionDescList, _7: c_uint, _6: *mut c_int, _5: *mut *mut c_char, _4: *mut *mut c_char, _3: WidgetClass, _2: *mut Arg, _1: c_uint) -> Widget, + pub fn XtOpenDisplay (_8: XtAppContext, _7: *const c_char, _6: *const c_char, _5: *const c_char, _4: XrmOptionDescList, _3: c_uint, _2: *mut c_int, _1: *mut *mut c_char) -> *mut Display, + pub fn XtOverrideTranslations (_2: Widget, _1: *mut _TranslationData) -> (), + pub fn XtOwnSelection (_6: Widget, _5: c_ulong, _4: c_ulong, _3: Option<unsafe extern "C" fn (Widget, *mut c_ulong, *mut c_ulong, *mut c_ulong, *mut *mut c_void, *mut c_ulong, *mut c_int) -> c_char>, _2: Option<unsafe extern "C" fn (Widget, *mut c_ulong)>, _1: Option<unsafe extern "C" fn (Widget, *mut c_ulong, *mut c_ulong)>) -> c_char, + pub fn XtOwnSelectionIncremental (_8: Widget, _7: c_ulong, _6: c_ulong, _5: Option<unsafe extern "C" fn (Widget, *mut c_ulong, *mut c_ulong, *mut c_ulong, *mut *mut c_void, *mut c_ulong, *mut c_int, *mut c_ulong, *mut c_void, *mut *mut c_void) -> c_char>, _4: Option<unsafe extern "C" fn (Widget, *mut c_ulong, *mut c_void)>, _3: Option<unsafe extern "C" fn (Widget, *mut c_ulong, *mut c_ulong, *mut *mut c_void, *mut c_void)>, _2: Option<unsafe extern "C" fn (Widget, *mut c_ulong, *mut c_ulong, *mut *mut c_void, *mut c_void)>, _1: *mut c_void) -> c_char, + pub fn XtParent (_1: Widget) -> Widget, + pub fn XtParseAcceleratorTable (_1: *const c_char) -> *mut _TranslationData, + pub fn XtParseTranslationTable (_1: *const c_char) -> *mut _TranslationData, + pub fn XtPeekEvent (_1: *mut XEvent) -> c_char, + pub fn XtPending () -> c_char, + pub fn XtPopdown (_1: Widget) -> (), + pub fn XtPopup (_2: Widget, _1: XtGrabKind) -> (), + pub fn XtPopupSpringLoaded (_1: Widget) -> (), + pub fn XtProcessEvent (_1: c_ulong) -> (), + pub fn XtProcessLock () -> (), + pub fn XtProcessUnlock () -> (), + pub fn XtQueryGeometry (_3: Widget, _2: *mut XtWidgetGeometry, _1: *mut XtWidgetGeometry) -> XtGeometryResult, + pub fn XtRealizeWidget (_1: Widget) -> (), + pub fn XtRealloc (_2: *mut c_char, _1: c_uint) -> *mut c_char, + pub fn XtRegisterCaseConverter (_4: *mut Display, _3: Option<unsafe extern "C" fn (*mut Display, c_ulong, *mut c_ulong, *mut c_ulong)>, _2: c_ulong, _1: c_ulong) -> (), + pub fn XtRegisterDrawable (_3: *mut Display, _2: c_ulong, _1: Widget) -> (), + pub fn XtRegisterExtensionSelector (_5: *mut Display, _4: c_int, _3: c_int, _2: Option<unsafe extern "C" fn (Widget, *mut c_int, *mut *mut c_void, c_int, *mut c_void)>, _1: *mut c_void) -> (), + pub fn XtRegisterGrabAction (_5: Option<unsafe extern "C" fn (Widget, *mut XEvent, *mut *mut c_char, *mut c_uint)>, _4: c_char, _3: c_uint, _2: c_int, _1: c_int) -> (), + pub fn XtReleaseGC (_2: Widget, _1: GC) -> (), + pub fn XtReleasePropertyAtom (_2: Widget, _1: c_ulong) -> (), + pub fn XtRemoveActionHook (_1: *mut c_void) -> (), + pub fn XtRemoveAllCallbacks (_2: Widget, _1: *const c_char) -> (), + pub fn XtRemoveBlockHook (_1: c_ulong) -> (), + pub fn XtRemoveCallback (_4: Widget, _3: *const c_char, _2: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut c_void)>, _1: *mut c_void) -> (), + pub fn XtRemoveCallbacks (_3: Widget, _2: *const c_char, _1: XtCallbackList) -> (), + pub fn XtRemoveEventHandler (_5: Widget, _4: c_ulong, _3: c_char, _2: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut XEvent, *mut c_char)>, _1: *mut c_void) -> (), + pub fn XtRemoveEventTypeHandler (_5: Widget, _4: c_int, _3: *mut c_void, _2: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut XEvent, *mut c_char)>, _1: *mut c_void) -> (), + pub fn XtRemoveGrab (_1: Widget) -> (), + pub fn XtRemoveInput (_1: c_ulong) -> (), + pub fn XtRemoveRawEventHandler (_5: Widget, _4: c_ulong, _3: c_char, _2: Option<unsafe extern "C" fn (Widget, *mut c_void, *mut XEvent, *mut c_char)>, _1: *mut c_void) -> (), + pub fn XtRemoveSignal (_1: c_ulong) -> (), + pub fn XtRemoveTimeOut (_1: c_ulong) -> (), + pub fn XtRemoveWorkProc (_1: c_ulong) -> (), + pub fn XtReservePropertyAtom (_1: Widget) -> c_ulong, + pub fn XtResizeWidget (_4: Widget, _3: c_ushort, _2: c_ushort, _1: c_ushort) -> (), + pub fn XtResizeWindow (_1: Widget) -> (), + pub fn XtResolvePathname (_8: *mut Display, _7: *const c_char, _6: *const c_char, _5: *const c_char, _4: *const c_char, _3: Substitution, _2: c_uint, _1: Option<unsafe extern "C" fn (*mut c_char) -> c_char>) -> *mut c_char, + pub fn XtScreen (_1: Widget) -> *mut Screen, + pub fn XtScreenDatabase (_1: *mut Screen) -> *mut _XrmHashBucketRec, + pub fn XtScreenOfObject (_1: Widget) -> *mut Screen, + pub fn XtSendSelectionRequest (_3: Widget, _2: c_ulong, _1: c_ulong) -> (), + pub fn XtSessionGetToken (_1: Widget) -> XtCheckpointToken, + pub fn XtSessionReturnToken (_1: XtCheckpointToken) -> (), + pub fn XtSetErrorHandler (_1: Option<unsafe extern "C" fn (*mut c_char)>) -> (), + pub fn XtSetErrorMsgHandler (_1: Option<unsafe extern "C" fn (*mut c_char, *mut c_char, *mut c_char, *mut c_char, *mut *mut c_char, *mut c_uint)>) -> (), + pub fn XtSetEventDispatcher (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut XEvent) -> c_char>) -> Option<unsafe extern "C" fn (*mut XEvent) -> c_char>, + pub fn XtSetKeyboardFocus (_2: Widget, _1: Widget) -> (), + pub fn XtSetKeyTranslator (_2: *mut Display, _1: Option<unsafe extern "C" fn (*mut Display, c_uchar, c_uint, *mut c_uint, *mut c_ulong)>) -> (), + pub fn XtSetLanguageProc (_3: XtAppContext, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char, *mut c_void) -> *mut c_char>, _1: *mut c_void) -> Option<unsafe extern "C" fn (*mut Display, *mut c_char, *mut c_void) -> *mut c_char>, + pub fn XtSetMappedWhenManaged (_2: Widget, _1: c_char) -> (), + pub fn XtSetMultiClickTime (_2: *mut Display, _1: c_int) -> (), + pub fn XtSetSelectionParameters (_6: Widget, _5: c_ulong, _4: c_ulong, _3: *mut c_void, _2: c_ulong, _1: c_int) -> (), + pub fn XtSetSelectionTimeout (_1: c_ulong) -> (), + pub fn XtSetSensitive (_2: Widget, _1: c_char) -> (), + pub fn XtSetSubvalues (_5: *mut c_void, _4: *mut XtResource, _3: c_uint, _2: *mut Arg, _1: c_uint) -> (), + pub fn XtSetTypeConverter (_7: *const c_char, _6: *const c_char, _5: Option<unsafe extern "C" fn (*mut Display, *mut XrmValue, *mut c_uint, *mut XrmValue, *mut XrmValue, *mut *mut c_void) -> c_char>, _4: XtConvertArgList, _3: c_uint, _2: c_int, _1: Option<unsafe extern "C" fn (XtAppContext, *mut XrmValue, *mut c_void, *mut XrmValue, *mut c_uint)>) -> (), + pub fn XtSetValues (_3: Widget, _2: *mut Arg, _1: c_uint) -> (), + pub fn XtSetWarningHandler (_1: Option<unsafe extern "C" fn (*mut c_char)>) -> (), + pub fn XtSetWarningMsgHandler (_1: Option<unsafe extern "C" fn (*mut c_char, *mut c_char, *mut c_char, *mut c_char, *mut *mut c_char, *mut c_uint)>) -> (), + pub fn XtSetWMColormapWindows (_3: Widget, _2: *mut Widget, _1: c_uint) -> (), + pub fn XtStringConversionWarning (_2: *const c_char, _1: *const c_char) -> (), + pub fn XtSuperclass (_1: Widget) -> WidgetClass, + pub fn XtToolkitInitialize () -> (), + pub fn XtToolkitThreadInitialize () -> c_char, + pub fn XtTranslateCoords (_5: Widget, _4: c_short, _3: c_short, _2: *mut c_short, _1: *mut c_short) -> (), + pub fn XtTranslateKey (_5: *mut Display, _4: c_uchar, _3: c_uint, _2: *mut c_uint, _1: *mut c_ulong) -> (), + pub fn XtTranslateKeycode (_5: *mut Display, _4: c_uchar, _3: c_uint, _2: *mut c_uint, _1: *mut c_ulong) -> (), + pub fn XtUngrabButton (_3: Widget, _2: c_uint, _1: c_uint) -> (), + pub fn XtUngrabKey (_3: Widget, _2: c_uchar, _1: c_uint) -> (), + pub fn XtUngrabKeyboard (_2: Widget, _1: c_ulong) -> (), + pub fn XtUngrabPointer (_2: Widget, _1: c_ulong) -> (), + pub fn XtUninstallTranslations (_1: Widget) -> (), + pub fn XtUnmanageChild (_1: Widget) -> (), + pub fn XtUnmanageChildren (_2: *mut Widget, _1: c_uint) -> (), + pub fn XtUnmapWidget (_1: Widget) -> (), + pub fn XtUnrealizeWidget (_1: Widget) -> (), + pub fn XtUnregisterDrawable (_2: *mut Display, _1: c_ulong) -> (), + pub fn XtWarning (_1: *const c_char) -> (), + pub fn XtWarningMsg (_6: *const c_char, _5: *const c_char, _4: *const c_char, _3: *const c_char, _2: *mut *mut c_char, _1: *mut c_uint) -> (), + pub fn XtWidgetToApplicationContext (_1: Widget) -> XtAppContext, + pub fn XtWindow (_1: Widget) -> c_ulong, + pub fn XtWindowOfObject (_1: Widget) -> c_ulong, + pub fn XtWindowToWidget (_2: *mut Display, _1: c_ulong) -> Widget, +variadic: + pub fn XtAsprintf (_2: *mut *mut c_char, _1: *const c_char) -> c_uint, + pub fn XtVaAppCreateShell (_4: *const c_char, _3: *const c_char, _2: WidgetClass, _1: *mut Display) -> Widget, + pub fn XtVaAppInitialize (_7: *mut XtAppContext, _6: *const c_char, _5: XrmOptionDescList, _4: c_uint, _3: *mut c_int, _2: *mut *mut c_char, _1: *mut *mut c_char) -> Widget, + pub fn XtVaCreateArgsList (_1: *mut c_void) -> *mut c_void, + pub fn XtVaCreateManagedWidget (_3: *const c_char, _2: WidgetClass, _1: Widget) -> Widget, + pub fn XtVaCreatePopupShell (_3: *const c_char, _2: WidgetClass, _1: Widget) -> Widget, + pub fn XtVaCreateWidget (_3: *const c_char, _2: WidgetClass, _1: Widget) -> Widget, + pub fn XtVaGetApplicationResources (_4: Widget, _3: *mut c_void, _2: *mut XtResource, _1: c_uint) -> (), + pub fn XtVaGetSubresources (_6: Widget, _5: *mut c_void, _4: *const c_char, _3: *const c_char, _2: *mut XtResource, _1: c_uint) -> (), + pub fn XtVaGetSubvalues (_3: *mut c_void, _2: *mut XtResource, _1: c_uint) -> (), + pub fn XtVaGetValues (_1: Widget) -> (), + pub fn XtVaOpenApplication (_8: *mut XtAppContext, _7: *const c_char, _6: XrmOptionDescList, _5: c_uint, _4: *mut c_int, _3: *mut *mut c_char, _2: *mut *mut c_char, _1: WidgetClass) -> Widget, + pub fn XtVaSetSubvalues (_3: *mut c_void, _2: *mut XtResource, _1: c_uint) -> (), + pub fn XtVaSetValues (_1: Widget) -> (), +globals: +} + + +// +// types +// + + +// TODO structs +#[repr(C)] pub struct Arg; +#[repr(C)] pub struct SubstitutionRec; +#[repr(C)] pub struct _TranslationData; +#[repr(C)] pub struct _WidgetClassRec; +#[repr(C)] pub struct _WidgetRec; +#[repr(C)] pub struct _XtActionsRec; +#[repr(C)] pub struct _XtAppStruct; +#[repr(C)] pub struct _XtCallbackRec; +#[repr(C)] pub struct _XtCheckpointTokenRec; +#[repr(C)] pub struct XtConvertArgRec; +#[repr(C)] pub struct _XtResource; +#[repr(C)] pub struct XtWidgetGeometry; + +// C enums +pub type XtCallbackStatus = c_int; +pub type XtGeometryResult = c_int; +pub type XtGrabKind = c_int; +pub type XtListPosition = c_int; + +#[allow(dead_code)] +#[cfg(test)] +#[repr(C)] +enum TestEnum { + Variant1, + Variant2, +} + +#[test] +fn enum_size_test () { + assert!(::std::mem::size_of::<TestEnum>() == ::std::mem::size_of::<c_int>()); +} + +// struct typedefs +pub type ArgList = *mut Arg; +pub type Substitution = *mut SubstitutionRec; +pub type Widget = *mut _WidgetRec; +pub type WidgetClass = *mut _WidgetClassRec; +pub type XtAccelerators = *mut _TranslationData; +pub type XtActionList = *mut _XtActionsRec; +pub type XtActionsRec = _XtActionsRec; +pub type XtAppContext = *mut _XtAppStruct; +pub type XtCallbackList = *mut _XtCallbackRec; +pub type XtCallbackRec = _XtCallbackRec; +pub type XtCheckpointToken = *mut _XtCheckpointTokenRec; +pub type XtCheckpointTokenRec = _XtCheckpointTokenRec; +pub type XtConvertArgList = *mut XtConvertArgRec; +pub type XtResource = _XtResource; +pub type XtResourceList = *mut _XtResource; +pub type XtTranslations = *mut _TranslationData; diff --git a/third_party/cargo/vendor/x11-dl-2.18.4/src/xtest.rs b/third_party/cargo/vendor/x11-dl-2.18.4/src/xtest.rs new file mode 100644 index 0000000..62cb7fb --- /dev/null +++ b/third_party/cargo/vendor/x11-dl-2.18.4/src/xtest.rs @@ -0,0 +1,42 @@ +// x11-rs: Rust bindings for X11 libraries +// The X11 libraries are available under the MIT license. +// These bindings are public domain. + +use std::os::raw::{ + c_int, + c_uint, + c_ulong, +}; + +use ::xinput::XDevice; +use ::xlib::{ + Display, + GC, + Visual, +}; + + +// +// functions +// + + +x11_link! { Xf86vmode, xtst, ["libXtst.so.6", "libXtst.so"], 15, + pub fn XTestCompareCurrentCursorWithWindow (_2: *mut Display, _1: c_ulong) -> c_int, + pub fn XTestCompareCursorWithWindow (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int, + pub fn XTestDiscard (_1: *mut Display) -> c_int, + pub fn XTestFakeButtonEvent (_4: *mut Display, _3: c_uint, _2: c_int, _1: c_ulong) -> c_int, + pub fn XTestFakeDeviceButtonEvent (_7: *mut Display, _6: *mut XDevice, _5: c_uint, _4: c_int, _3: *mut c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XTestFakeDeviceKeyEvent (_7: *mut Display, _6: *mut XDevice, _5: c_uint, _4: c_int, _3: *mut c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XTestFakeDeviceMotionEvent (_7: *mut Display, _6: *mut XDevice, _5: c_int, _4: c_int, _3: *mut c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XTestFakeKeyEvent (_4: *mut Display, _3: c_uint, _2: c_int, _1: c_ulong) -> c_int, + pub fn XTestFakeMotionEvent (_5: *mut Display, _4: c_int, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XTestFakeProximityEvent (_6: *mut Display, _5: *mut XDevice, _4: c_int, _3: *mut c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XTestFakeRelativeMotionEvent (_4: *mut Display, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, + pub fn XTestGrabControl (_2: *mut Display, _1: c_int) -> c_int, + pub fn XTestQueryExtension (_5: *mut Display, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int, + pub fn XTestSetGContextOfGC (_2: GC, _1: c_ulong) -> (), + pub fn XTestSetVisualIDOfVisual (_2: *mut Visual, _1: c_ulong) -> (), +variadic: +globals: +} diff --git a/third_party/cargo/vendor/xdg-2.2.0/.cargo-checksum.json b/third_party/cargo/vendor/xdg-2.2.0/.cargo-checksum.json new file mode 100644 index 0000000..80dbbde --- /dev/null +++ b/third_party/cargo/vendor/xdg-2.2.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"d7e9625f61f5d3a412ab49700bdb1626a0009b4126bd92f50099cfda4786280f","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"5d253b56ed5a9c999f48cff673d2683bd2888ce6e36c6b9f6dfe7739843f38d8","src/lib.rs":"e255d39d3d62691e9d7e2ccc573caf1004c159d84bc866096f4e20418f7454db","test_files/runtime-bad/everywhere":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/runtime-bad/runtime.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system1/config/both_system_config.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system1/config/everywhere":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system1/config/myapp/default_profile/system1_config.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system1/config/myapp/system1_config.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system1/config/system1_config.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system1/data/both_system_data.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system1/data/everywhere":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system1/data/system1_data.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system2/config/both_system_config.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system2/config/everywhere":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system2/config/system2_config.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system2/data/both_system_data.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system2/data/everywhere":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/system2/data/system2_data.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/user/cache/everywhere":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/user/cache/user_cache.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/user/config/everywhere":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/user/config/myapp/default_profile/user_config.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/user/config/myapp/user_config.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/user/config/user_config.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/user/data/everywhere":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","test_files/user/data/user_data.file":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"} \ No newline at end of file diff --git a/third_party/cargo/vendor/xdg-2.2.0/BUILD b/third_party/cargo/vendor/xdg-2.2.0/BUILD new file mode 100644 index 0000000..3a9c9ef --- /dev/null +++ b/third_party/cargo/vendor/xdg-2.2.0/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0,MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "xdg", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "2.2.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/xdg-2.2.0/Cargo.toml b/third_party/cargo/vendor/xdg-2.2.0/Cargo.toml new file mode 100644 index 0000000..8dd6b13 --- /dev/null +++ b/third_party/cargo/vendor/xdg-2.2.0/Cargo.toml @@ -0,0 +1,26 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "xdg" +version = "2.2.0" +authors = ["Ben Longbons <b.r.longbons@gmail.com>", "whitequark <whitequark@whitequark.org>"] +description = "A library for storing and retrieving files according to XDG Base Directory specification" +homepage = "https://github.com/whitequark/rust-xdg" +documentation = "https://docs.rs/xdg/" +readme = "README.md" +keywords = ["linux", "configuration"] +license = "Apache-2.0/MIT" +repository = "https://github.com/whitequark/rust-xdg" + +[lib] +doctest = false diff --git a/third_party/cargo/vendor/xdg-2.2.0/LICENSE-APACHE b/third_party/cargo/vendor/xdg-2.2.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/xdg-2.2.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/xdg-2.2.0/LICENSE-MIT b/third_party/cargo/vendor/xdg-2.2.0/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/third_party/cargo/vendor/xdg-2.2.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/xdg-2.2.0/README.md b/third_party/cargo/vendor/xdg-2.2.0/README.md new file mode 100644 index 0000000..996c9cd --- /dev/null +++ b/third_party/cargo/vendor/xdg-2.2.0/README.md @@ -0,0 +1,33 @@ +rust-xdg +======== + +rust-xdg is a library that makes it easy to follow the X Desktop Group +specifications. + +Currently, only [XDG Base Directory][basedir] specification is implemented. + +[basedir]: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html + +Installation +------------ + +Add the following to `Cargo.toml`: + +```toml +[dependencies] +xdg = "^2.1" +``` + +Examples +-------- + +See [documentation](https://whitequark.github.io/rust-xdg/xdg/). + +License +------- + +rust-xdg is distributed under the terms of both the MIT license +and the Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) +for details. diff --git a/third_party/cargo/vendor/xdg-2.2.0/src/lib.rs b/third_party/cargo/vendor/xdg-2.2.0/src/lib.rs new file mode 100644 index 0000000..e59efa0 --- /dev/null +++ b/third_party/cargo/vendor/xdg-2.2.0/src/lib.rs @@ -0,0 +1,873 @@ +#![cfg(any(unix, target_os = "redox"))] + +use std::fmt; +use std::convert; +use std::error; +use std::io; +use std::env; +use std::fs; +use std::path::{Path, PathBuf}; +use std::ffi::OsString; + +use std::os::unix::fs::PermissionsExt; + +use BaseDirectoriesErrorKind::*; +use BaseDirectoriesError as Error; + +/// BaseDirectories allows to look up paths to configuration, data, +/// cache and runtime files in well-known locations according to +/// the [X Desktop Group Base Directory specification][xdg-basedir]. +/// [xdg-basedir]: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html +/// +/// The Base Directory specification defines four kinds of files: +/// +/// * **Configuration files** store the application's settings and +/// are often modified during runtime; +/// * **Data files** store supplementary data, such as graphic assets, +/// precomputed tables, documentation, or architecture-independent +/// source code; +/// * **Cache files** store non-essential, transient data that provides +/// a runtime speedup; +/// * **Runtime files** include filesystem objects such are sockets or +/// named pipes that are used for communication internal to the application. +/// Runtime files must not be accessible to anyone except current user. +/// +/// # Examples +/// +/// To configure paths for application `myapp`: +/// +/// ``` +/// extern crate xdg; +/// let xdg_dirs = xdg::BaseDirectories::with_prefix("myapp").unwrap(); +/// ``` +/// +/// To store configuration: +/// +/// ``` +/// let config_path = xdg_dirs.place_config_file("config.ini") +/// .expect("cannot create configuration directory"); +/// let mut config_file = try!(File::create(config_path)); +/// try!(write!(&mut config_file, "configured = 1")); +/// ``` +/// +/// The `config.ini` file will appear in the proper location for desktop +/// configuration files, most likely `~/.config/myapp/config.ini`. +/// The leading directories will be automatically created. +/// +/// To retrieve supplementary data: +/// +/// ``` +/// let logo_path = xdg_dirs.find_data_file("logo.png") +/// .expect("application data not present"); +/// let mut logo_file = try!(File::open(logo_path)); +/// let mut logo = Vec::new(); +/// try!(logo_file.read_to_end(&mut logo)); +/// ``` +/// +/// The `logo.png` will be searched in the proper locations for +/// supplementary data files, most likely `~/.local/share/myapp/logo.png`, +/// then `/usr/local/share/myapp/logo.png` and `/usr/share/myapp/logo.png`. +#[derive(Debug, Clone)] +pub struct BaseDirectories { + shared_prefix: PathBuf, + user_prefix: PathBuf, + data_home: PathBuf, + config_home: PathBuf, + cache_home: PathBuf, + data_dirs: Vec<PathBuf>, + config_dirs: Vec<PathBuf>, + runtime_dir: Option<PathBuf>, +} + +pub struct BaseDirectoriesError { + kind: BaseDirectoriesErrorKind, +} + +impl BaseDirectoriesError { + fn new(kind: BaseDirectoriesErrorKind) -> BaseDirectoriesError { + BaseDirectoriesError { + kind: kind, + } + } +} + +impl fmt::Debug for BaseDirectoriesError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.kind.fmt(f) + } +} + +impl error::Error for BaseDirectoriesError { + fn description(&self) -> &str { + match self.kind { + HomeMissing => "$HOME must be set", + XdgRuntimeDirInaccessible(_, _) => + "$XDG_RUNTIME_DIR must be accessible by the current user", + XdgRuntimeDirInsecure(_, _) => + "$XDG_RUNTIME_DIR must be secure: have permissions 0700", + XdgRuntimeDirMissing => + "$XDG_RUNTIME_DIR is not set", + } + } + fn cause(&self) -> Option<&error::Error> { + match self.kind { + XdgRuntimeDirInaccessible(_, ref e) => Some(e), + _ => None, + } + } +} + +impl fmt::Display for BaseDirectoriesError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.kind { + HomeMissing => write!(f, "{}", error::Error::description(self)), + XdgRuntimeDirInaccessible(ref dir, ref error) => { + write!(f, "$XDG_RUNTIME_DIR (`{}`) must be accessible \ + by the current user (error: {})", dir.display(), error) + }, + XdgRuntimeDirInsecure(ref dir, permissions) => { + write!(f, "$XDG_RUNTIME_DIR (`{}`) must be secure: must have \ + permissions 0o700, got {}", dir.display(), permissions) + }, + XdgRuntimeDirMissing => { + write!(f, "$XDG_RUNTIME_DIR must be set") + }, + } + } +} + +impl convert::From<BaseDirectoriesError> for io::Error { + fn from(error: BaseDirectoriesError) -> io::Error { + match error.kind { + HomeMissing | XdgRuntimeDirMissing => + io::Error::new(io::ErrorKind::NotFound, error), + _ => io::Error::new(io::ErrorKind::Other, error) + } + } + +} + +#[derive(Copy, Clone)] +struct Permissions(u32); + +impl fmt::Debug for Permissions { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let Permissions(p) = *self; + write!(f, "{:#05o}", p) + } +} + +impl fmt::Display for Permissions { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(self, f) + } +} + +#[derive(Debug)] +enum BaseDirectoriesErrorKind { + HomeMissing, + XdgRuntimeDirInaccessible(PathBuf, io::Error), + XdgRuntimeDirInsecure(PathBuf, Permissions), + XdgRuntimeDirMissing, +} + +impl BaseDirectories { + /// Reads the process environment, determines the XDG base directories, + /// and returns a value that can be used for lookup. + /// The following environment variables are examined: + /// + /// * `HOME`; if not set: use the same fallback as `std::env::home_dir()`; + /// if still not available: return an error. + /// * `XDG_DATA_HOME`; if not set: assumed to be `$HOME/.local/share`. + /// * `XDG_CONFIG_HOME`; if not set: assumed to be `$HOME/.config`. + /// * `XDG_CACHE_HOME`; if not set: assumed to be `$HOME/.cache`. + /// * `XDG_DATA_DIRS`; if not set: assumed to be `/usr/local/share:/usr/share`. + /// * `XDG_CONFIG_DIRS`; if not set: assumed to be `/etc/xdg`. + /// * `XDG_RUNTIME_DIR`; if not accessible or permissions are not `0700`: + /// record as inaccessible (can be queried with + /// [has_runtime_directory](method.has_runtime_directory)). + /// + /// As per specification, if an environment variable contains a relative path, + /// the behavior is the same as if it was not set. + pub fn new() -> Result<BaseDirectories, BaseDirectoriesError> { + BaseDirectories::with_env("", "", &|name| env::var_os(name)) + } + + /// Same as [`new()`](#method.new), but `prefix` is implicitly prepended to + /// every path that is looked up. + pub fn with_prefix<P>(prefix: P) -> Result<BaseDirectories, BaseDirectoriesError> + where P: AsRef<Path> { + BaseDirectories::with_env(prefix, "", &|name| env::var_os(name)) + } + + /// Same as [`with_prefix()`](#method.with_prefix), + /// with `profile` also implicitly prepended to every path that is looked up, + /// but only for user-specific directories. + /// + /// This allows each user to have mutliple "profiles" with different user-specific data. + /// + /// For example: + /// + /// ```rust + /// let dirs = BaseDirectories::with_profile("program-name", "profile-name") + /// .unwrap(); + /// dirs.find_data_file("bar.jpg"); + /// dirs.find_config_file("foo.conf"); + /// ``` + /// + /// will find `/usr/share/program-name/bar.jpg` (without `profile-name`) + /// and `~/.config/program-name/profile-name/foo.conf`. + pub fn with_profile<P1, P2>(prefix: P1, profile: P2) + -> Result<BaseDirectories, BaseDirectoriesError> + where P1: AsRef<Path>, P2: AsRef<Path> { + BaseDirectories::with_env(prefix, profile, &|name| env::var_os(name)) + } + + fn with_env<P1, P2, T: ?Sized>(prefix: P1, profile: P2, env_var: &T) + -> Result<BaseDirectories, BaseDirectoriesError> + where P1: AsRef<Path>, P2: AsRef<Path>, T: Fn(&str) -> Option<OsString> { + BaseDirectories::with_env_impl(prefix.as_ref(), profile.as_ref(), env_var) + } + + fn with_env_impl<T: ?Sized>(prefix: &Path, profile: &Path, env_var: &T) + -> Result<BaseDirectories, BaseDirectoriesError> + where T: Fn(&str) -> Option<OsString> { + fn abspath(path: OsString) -> Option<PathBuf> { + let path = PathBuf::from(path); + if path.is_absolute() { + Some(path) + } else { + None + } + } + + fn abspaths(paths: OsString) -> Option<Vec<PathBuf>> { + let paths = env::split_paths(&paths) + .map(PathBuf::from) + .filter(|ref path| path.is_absolute()) + .collect::<Vec<_>>(); + if paths.is_empty() { + None + } else { + Some(paths) + } + } + + let home = try!(std::env::home_dir().ok_or(Error::new(HomeMissing))); + + let data_home = env_var("XDG_DATA_HOME") + .and_then(abspath) + .unwrap_or(home.join(".local/share")); + let config_home = env_var("XDG_CONFIG_HOME") + .and_then(abspath) + .unwrap_or(home.join(".config")); + let cache_home = env_var("XDG_CACHE_HOME") + .and_then(abspath) + .unwrap_or(home.join(".cache")); + let data_dirs = env_var("XDG_DATA_DIRS") + .and_then(abspaths) + .unwrap_or(vec![PathBuf::from("/usr/local/share"), + PathBuf::from("/usr/share")]); + let config_dirs = env_var("XDG_CONFIG_DIRS") + .and_then(abspaths) + .unwrap_or(vec![PathBuf::from("/etc/xdg")]); + let runtime_dir = env_var("XDG_RUNTIME_DIR") + .and_then(abspath); // optional + + let prefix = PathBuf::from(prefix); + Ok(BaseDirectories { + user_prefix: prefix.join(profile), + shared_prefix: prefix, + data_home: data_home, + config_home: config_home, + cache_home: cache_home, + data_dirs: data_dirs, + config_dirs: config_dirs, + runtime_dir: runtime_dir, + }) + } + + fn get_runtime_directory(&self) -> Result<&PathBuf, BaseDirectoriesError> { + if let Some(ref runtime_dir) = self.runtime_dir { + // If XDG_RUNTIME_DIR is in the environment but not secure, + // do not allow recovery. + try!(fs::read_dir(runtime_dir).map_err(|e| { + Error::new(XdgRuntimeDirInaccessible(runtime_dir.clone(), e)) + })); + let permissions = try!(fs::metadata(runtime_dir).map_err(|e| { + Error::new(XdgRuntimeDirInaccessible(runtime_dir.clone(), e)) + })).permissions().mode() as u32; + if permissions & 0o077 != 0 { + Err(Error::new(XdgRuntimeDirInsecure(runtime_dir.clone(), + Permissions(permissions)))) + } else { + Ok(&runtime_dir) + } + } else { + Err(Error::new(XdgRuntimeDirMissing)) + } + } + + /// Returns `true` if `XDG_RUNTIME_DIR` is available, `false` otherwise. + pub fn has_runtime_directory(&self) -> bool { + match self.get_runtime_directory() { + Ok(_) => true, + _ => false + } + } + + /// Given a relative path `path`, returns an absolute path in + /// `XDG_CONFIG_HOME` where a configuration file may be stored. + /// Leading directories in the returned path are pre-created; + /// if that is not possible, an error is returned. + pub fn place_config_file<P>(&self, path: P) -> io::Result<PathBuf> + where P: AsRef<Path> { + write_file(&self.config_home, self.user_prefix.join(path)) + } + + /// Like [`place_config_file()`](#method.place_config_file), but for + /// a data file in `XDG_DATA_HOME`. + pub fn place_data_file<P>(&self, path: P) -> io::Result<PathBuf> + where P: AsRef<Path> { + write_file(&self.data_home, self.user_prefix.join(path)) + } + + /// Like [`place_config_file()`](#method.place_config_file), but for + /// a cache file in `XDG_CACHE_HOME`. + pub fn place_cache_file<P>(&self, path: P) -> io::Result<PathBuf> + where P: AsRef<Path> { + write_file(&self.cache_home, self.user_prefix.join(path)) + } + + /// Like [`place_config_file()`](#method.place_config_file), but for + /// a runtime file in `XDG_RUNTIME_DIR`. + /// If `XDG_RUNTIME_DIR` is not available, returns an error. + pub fn place_runtime_file<P>(&self, path: P) -> io::Result<PathBuf> + where P: AsRef<Path> { + write_file(try!(self.get_runtime_directory()), self.user_prefix.join(path)) + } + + /// Given a relative path `path`, returns an absolute path to an existing + /// configuration file, or `None`. Searches `XDG_CONFIG_HOME` and then + /// `XDG_CONFIG_DIRS`. + pub fn find_config_file<P>(&self, path: P) -> Option<PathBuf> + where P: AsRef<Path> { + read_file(&self.config_home, &self.config_dirs, + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } + + /// Given a relative path `path`, returns an iterator yielding absolute + /// paths to existing configuration files, in `XDG_CONFIG_DIRS` and + /// `XDG_CONFIG_HOME`. Paths are produced in order from lowest priority + /// to highest. + pub fn find_config_files<P>(&self, path: P) -> FileFindIterator + where P: AsRef<Path> { + FileFindIterator::new(&self.config_home, &self.config_dirs, + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } + + /// Given a relative path `path`, returns an absolute path to an existing + /// data file, or `None`. Searches `XDG_DATA_HOME` and then + /// `XDG_DATA_DIRS`. + pub fn find_data_file<P>(&self, path: P) -> Option<PathBuf> + where P: AsRef<Path> { + read_file(&self.data_home, &self.data_dirs, + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } + + /// Given a relative path `path`, returns an iterator yielding absolute + /// paths to existing data files, in `XDG_DATA_DIRS` and + /// `XDG_DATA_HOME`. Paths are produced in order from lowest priority + /// to highest. + pub fn find_data_files<P>(&self, path: P) -> FileFindIterator + where P: AsRef<Path> { + FileFindIterator::new(&self.data_home, &self.data_dirs, + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } + + /// Given a relative path `path`, returns an absolute path to an existing + /// cache file, or `None`. Searches `XDG_CACHE_HOME`. + pub fn find_cache_file<P>(&self, path: P) -> Option<PathBuf> + where P: AsRef<Path> { + read_file(&self.cache_home, &Vec::new(), + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } + + /// Given a relative path `path`, returns an absolute path to an existing + /// runtime file, or `None`. Searches `XDG_RUNTIME_DIR`. + /// If `XDG_RUNTIME_DIR` is not available, returns `None`. + pub fn find_runtime_file<P>(&self, path: P) -> Option<PathBuf> + where P: AsRef<Path> { + if let Ok(runtime_dir) = self.get_runtime_directory() { + read_file(runtime_dir, &Vec::new(), + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } else { + None + } + } + + /// Given a relative path `path`, returns an absolute path to a configuration + /// directory in `XDG_CONFIG_HOME`. The directory and all directories + /// leading to it are created if they did not exist; + /// if that is not possible, an error is returned. + pub fn create_config_directory<P>(&self, path: P) -> io::Result<PathBuf> + where P: AsRef<Path> { + create_directory(&self.config_home, + self.user_prefix.join(path)) + } + + /// Like [`create_config_directory()`](#method.create_config_directory), + /// but for a data directory in `XDG_DATA_HOME`. + pub fn create_data_directory<P>(&self, path: P) -> io::Result<PathBuf> + where P: AsRef<Path> { + create_directory(&self.data_home, + self.user_prefix.join(path)) + } + + /// Like [`create_config_directory()`](#method.create_config_directory), + /// but for a cache directory in `XDG_CACHE_HOME`. + pub fn create_cache_directory<P>(&self, path: P) -> io::Result<PathBuf> + where P: AsRef<Path> { + create_directory(&self.cache_home, + self.user_prefix.join(path)) + } + + /// Like [`create_config_directory()`](#method.create_config_directory), + /// but for a runtime directory in `XDG_RUNTIME_DIR`. + /// If `XDG_RUNTIME_DIR` is not available, returns an error. + pub fn create_runtime_directory<P>(&self, path: P) -> io::Result<PathBuf> + where P: AsRef<Path> { + create_directory(try!(self.get_runtime_directory()), + self.user_prefix.join(path)) + } + + /// Given a relative path `path`, list absolute paths to all files + /// in directories with path `path` in `XDG_CONFIG_HOME` and + /// `XDG_CONFIG_DIRS`. + pub fn list_config_files<P>(&self, path: P) -> Vec<PathBuf> + where P: AsRef<Path> { + list_files(&self.config_home, &self.config_dirs, + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } + + /// Like [`list_config_files`](#method.list_config_files), but + /// only the first occurence of every distinct filename is returned. + pub fn list_config_files_once<P>(&self, path: P) -> Vec<PathBuf> + where P: AsRef<Path> { + list_files_once(&self.config_home, &self.config_dirs, + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } + + /// Given a relative path `path`, lists absolute paths to all files + /// in directories with path `path` in `XDG_DATA_HOME` and + /// `XDG_DATA_DIRS`. + pub fn list_data_files<P>(&self, path: P) -> Vec<PathBuf> + where P: AsRef<Path> { + list_files(&self.data_home, &self.data_dirs, + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } + + /// Like [`list_data_files`](#method.list_data_files), but + /// only the first occurence of every distinct filename is returned. + pub fn list_data_files_once<P>(&self, path: P) -> Vec<PathBuf> + where P: AsRef<Path> { + list_files_once(&self.data_home, &self.data_dirs, + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } + + /// Given a relative path `path`, lists absolute paths to all files + /// in directories with path `path` in `XDG_CACHE_HOME`. + pub fn list_cache_files<P>(&self, path: P) -> Vec<PathBuf> + where P: AsRef<Path> { + list_files(&self.cache_home, &Vec::new(), + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } + + /// Given a relative path `path`, lists absolute paths to all files + /// in directories with path `path` in `XDG_RUNTIME_DIR`. + /// If `XDG_RUNTIME_DIR` is not available, returns an empty `Vec`. + pub fn list_runtime_files<P>(&self, path: P) -> Vec<PathBuf> + where P: AsRef<Path> { + if let Ok(runtime_dir) = self.get_runtime_directory() { + list_files(runtime_dir, &Vec::new(), + &self.user_prefix, &self.shared_prefix, path.as_ref()) + } else { + Vec::new() + } + } + + /// Returns the user-specific data directory (set by `XDG_DATA_HOME`). + pub fn get_data_home(&self) -> PathBuf { + self.data_home.join(&self.user_prefix) + } + + /// Returns the user-specific configuration directory (set by + /// `XDG_CONFIG_HOME`). + pub fn get_config_home(&self) -> PathBuf { + self.config_home.join(&self.user_prefix) + } + + /// Returns the user-specific directory for non-essential (cached) data + /// (set by `XDG_CACHE_HOME`). + pub fn get_cache_home(&self) -> PathBuf { + self.cache_home.join(&self.user_prefix) + } + + /// Returns a preference ordered (preferred to less preferred) list of + /// supplementary data directories, ordered by preference (set by + /// `XDG_DATA_DIRS`). + pub fn get_data_dirs(&self) -> Vec<PathBuf> { + self.data_dirs.iter().map(|p| p.join(&self.shared_prefix)).collect() + } + + /// Returns a preference ordered (preferred to less preferred) list of + /// supplementary configuration directories (set by `XDG_CONFIG_DIRS`). + pub fn get_config_dirs(&self) -> Vec<PathBuf> { + self.config_dirs.iter().map(|p| p.join(&self.shared_prefix)).collect() + } +} + +fn write_file<P>(home: &PathBuf, path: P) -> io::Result<PathBuf> + where P: AsRef<Path> { + match path.as_ref().parent() { + Some(parent) => try!(fs::create_dir_all(home.join(parent))), + None => try!(fs::create_dir_all(home)), + } + Ok(PathBuf::from(home.join(path.as_ref()))) +} + +fn create_directory<P>(home: &PathBuf, path: P) -> io::Result<PathBuf> + where P: AsRef<Path> { + let full_path = home.join(path.as_ref()); + try!(fs::create_dir_all(&full_path)); + Ok(full_path) +} + +fn path_exists<P: ?Sized + AsRef<Path>>(path: &P) -> bool { + fn inner(path: &Path) -> bool { + fs::metadata(path).is_ok() + } + inner(path.as_ref()) +} + +#[cfg(test)] +fn path_is_dir<P: ?Sized + AsRef<Path>>(path: &P) -> bool { + fn inner(path: &Path) -> bool { + fs::metadata(path).map(|m| m.is_dir()).unwrap_or(false) + } + inner(path.as_ref()) +} + +fn read_file(home: &PathBuf, dirs: &Vec<PathBuf>, + user_prefix: &Path, shared_prefix: &Path, path: &Path) + -> Option<PathBuf> { + let full_path = home.join(user_prefix).join(path); + if path_exists(&full_path) { + return Some(full_path) + } + for dir in dirs.iter() { + let full_path = dir.join(shared_prefix).join(path); + if path_exists(&full_path) { + return Some(full_path) + } + } + None +} + +use std::iter::Iterator; +pub struct FileFindIterator { + search_dirs: Vec<PathBuf>, + position: usize, + relpath: PathBuf, +} + +impl FileFindIterator { + fn new(home: &PathBuf, dirs: &Vec<PathBuf>, + user_prefix: &Path, shared_prefix: &Path, path: &Path) + -> FileFindIterator { + let mut search_dirs = Vec::new(); + for dir in dirs.iter().rev() { + search_dirs.push(dir.join(shared_prefix)); + } + search_dirs.push(home.join(user_prefix)); + FileFindIterator { + search_dirs: search_dirs, + position: 0, + relpath: path.to_path_buf(), + } + } +} + +impl Iterator for FileFindIterator { + type Item = PathBuf; + + fn next(&mut self) -> Option<Self::Item> { + loop { + let dir = match self.search_dirs.get(self.position) { + Some(d) => d, + None => return None + }; + self.position += 1; + let candidate = dir.join(self.relpath.clone()); + if path_exists(&candidate) { + return Some(candidate) + } + } + } +} + +fn list_files(home: &Path, dirs: &[PathBuf], + user_prefix: &Path, shared_prefix: &Path, path: &Path) + -> Vec<PathBuf> { + fn read_dir(dir: &Path, into: &mut Vec<PathBuf>) { + if let Ok(entries) = fs::read_dir(dir) { + into.extend( + entries + .filter_map(|entry| entry.ok()) + .map(|entry| entry.path())) + } + } + let mut files = Vec::new(); + read_dir(&home.join(user_prefix).join(path), &mut files); + for dir in dirs { + read_dir(&dir.join(shared_prefix).join(path), &mut files); + } + files +} + +fn list_files_once(home: &Path, dirs: &[PathBuf], + user_prefix: &Path, shared_prefix: &Path, path: &Path) + -> Vec<PathBuf> { + let mut seen = std::collections::HashSet::new(); + list_files(home, dirs, user_prefix, shared_prefix, path).into_iter().filter(|path| { + match path.clone().file_name() { + None => false, + Some(filename) => { + if seen.contains(filename) { + false + } else { + seen.insert(filename.to_owned()); + true + } + } + } + }).collect::<Vec<_>>() +} + +#[cfg(test)] +fn make_absolute<P>(path: P) -> PathBuf where P: AsRef<Path> { + env::current_dir().unwrap().join(path.as_ref()) +} + +#[cfg(test)] +fn iter_after<A, I, J>(mut iter: I, mut prefix: J) -> Option<I> where + I: Iterator<Item=A> + Clone, J: Iterator<Item=A>, A: PartialEq +{ + loop { + let mut iter_next = iter.clone(); + match (iter_next.next(), prefix.next()) { + (Some(x), Some(y)) => { + if x != y { return None } + } + (Some(_), None) => return Some(iter), + (None, None) => return Some(iter), + (None, Some(_)) => return None, + } + iter = iter_next; + } +} + +#[cfg(test)] +fn make_relative<P>(path: P) -> PathBuf where P: AsRef<Path> { + iter_after(path.as_ref().components(), env::current_dir().unwrap().components()) + .unwrap().as_path().to_owned() +} + +#[cfg(test)] +fn make_env(vars: Vec<(&'static str, String)>) -> + Box<Fn(&str)->Option<OsString>> { + return Box::new(move |name| { + for &(key, ref value) in vars.iter() { + if key == name { return Some(OsString::from(value)) } + } + None + }) +} + +#[test] +fn test_files_exists() { + assert!(path_exists("test_files")); + assert!(fs::metadata("test_files/runtime-bad") + .unwrap().permissions().mode() & 0o077 != 0); +} + +#[test] +fn test_bad_environment() { + let xd = BaseDirectories::with_env("", "", &*make_env(vec![ + ("HOME", "test_files/user".to_string()), + ("XDG_DATA_HOME", "test_files/user/data".to_string()), + ("XDG_CONFIG_HOME", "test_files/user/config".to_string()), + ("XDG_CACHE_HOME", "test_files/user/cache".to_string()), + ("XDG_DATA_DIRS", "test_files/user/data".to_string()), + ("XDG_CONFIG_DIRS", "test_files/user/config".to_string()), + ("XDG_RUNTIME_DIR", "test_files/runtime-bad".to_string()) + ])).unwrap(); + assert_eq!(xd.find_data_file("everywhere"), None); + assert_eq!(xd.find_config_file("everywhere"), None); + assert_eq!(xd.find_cache_file("everywhere"), None); +} + +#[test] +fn test_good_environment() { + let cwd = env::current_dir().unwrap().to_string_lossy().into_owned(); + let xd = BaseDirectories::with_env("", "", &*make_env(vec![ + ("HOME", format!("{}/test_files/user", cwd)), + ("XDG_DATA_HOME", format!("{}/test_files/user/data", cwd)), + ("XDG_CONFIG_HOME", format!("{}/test_files/user/config", cwd)), + ("XDG_CACHE_HOME", format!("{}/test_files/user/cache", cwd)), + ("XDG_DATA_DIRS", format!("{}/test_files/system0/data:{}/test_files/system1/data:{}/test_files/system2/data:{}/test_files/system3/data", cwd, cwd, cwd, cwd)), + ("XDG_CONFIG_DIRS", format!("{}/test_files/system0/config:{}/test_files/system1/config:{}/test_files/system2/config:{}/test_files/system3/config", cwd, cwd, cwd, cwd)), + // ("XDG_RUNTIME_DIR", format!("{}/test_files/runtime-bad", cwd)), + ])).unwrap(); + assert!(xd.find_data_file("everywhere") != None); + assert!(xd.find_config_file("everywhere") != None); + assert!(xd.find_cache_file("everywhere") != None); + + let mut config_files = xd.find_config_files("everywhere"); + assert_eq!(config_files.next(), + Some(PathBuf::from(format!("{}/test_files/system2/config/everywhere", cwd)))); + assert_eq!(config_files.next(), + Some(PathBuf::from(format!("{}/test_files/system1/config/everywhere", cwd)))); + assert_eq!(config_files.next(), + Some(PathBuf::from(format!("{}/test_files/user/config/everywhere", cwd)))); + assert_eq!(config_files.next(), None); + + let mut data_files = xd.find_data_files("everywhere"); + assert_eq!(data_files.next(), + Some(PathBuf::from(format!("{}/test_files/system2/data/everywhere", cwd)))); + assert_eq!(data_files.next(), + Some(PathBuf::from(format!("{}/test_files/system1/data/everywhere", cwd)))); + assert_eq!(data_files.next(), + Some(PathBuf::from(format!("{}/test_files/user/data/everywhere", cwd)))); + assert_eq!(data_files.next(), None); +} + +#[test] +fn test_runtime_bad() { + let cwd = env::current_dir().unwrap().to_string_lossy().into_owned(); + let xd = BaseDirectories::with_env("", "", &*make_env(vec![ + ("HOME", format!("{}/test_files/user", cwd)), + ("XDG_RUNTIME_DIR", format!("{}/test_files/runtime-bad", cwd)), + ])).unwrap(); + assert!(xd.has_runtime_directory() == false); +} + +#[test] +fn test_runtime_good() { + use std::fs::File; + + let test_runtime_dir = make_absolute(&"test_files/runtime-good"); + let _ = fs::remove_dir_all(&test_runtime_dir); + fs::create_dir_all(&test_runtime_dir).unwrap(); + + let mut perms = fs::metadata(&test_runtime_dir).unwrap().permissions(); + perms.set_mode(0o700); + fs::set_permissions(&test_runtime_dir, perms).unwrap(); + + let cwd = env::current_dir().unwrap().to_string_lossy().into_owned(); + let xd = BaseDirectories::with_env("", "", &*make_env(vec![ + ("HOME", format!("{}/test_files/user", cwd)), + ("XDG_RUNTIME_DIR", format!("{}/test_files/runtime-good", cwd)), + ])).unwrap(); + + xd.create_runtime_directory("foo").unwrap(); + assert!(path_is_dir("test_files/runtime-good/foo")); + let w = xd.place_runtime_file("bar/baz").unwrap(); + assert!(path_is_dir("test_files/runtime-good/bar")); + assert!(!path_exists("test_files/runtime-good/bar/baz")); + File::create(&w).unwrap(); + assert!(path_exists("test_files/runtime-good/bar/baz")); + assert!(xd.find_runtime_file("bar/baz") == Some(w.clone())); + File::open(&w).unwrap(); + fs::remove_file(&w).unwrap(); + let root = xd.list_runtime_files("."); + let mut root = root.into_iter().map(|p| make_relative(&p)).collect::<Vec<_>>(); + root.sort(); + assert_eq!(root, + vec![PathBuf::from("test_files/runtime-good/bar"), + PathBuf::from("test_files/runtime-good/foo")]); + assert!(xd.list_runtime_files("bar").is_empty()); + assert!(xd.find_runtime_file("foo/qux").is_none()); + assert!(xd.find_runtime_file("qux/foo").is_none()); + assert!(!path_exists("test_files/runtime-good/qux")); +} + +#[test] +fn test_lists() { + let cwd = env::current_dir().unwrap().to_string_lossy().into_owned(); + let xd = BaseDirectories::with_env("", "", &*make_env(vec![ + ("HOME", format!("{}/test_files/user", cwd)), + ("XDG_DATA_HOME", format!("{}/test_files/user/data", cwd)), + ("XDG_CONFIG_HOME", format!("{}/test_files/user/config", cwd)), + ("XDG_CACHE_HOME", format!("{}/test_files/user/cache", cwd)), + ("XDG_DATA_DIRS", format!("{}/test_files/system0/data:{}/test_files/system1/data:{}/test_files/system2/data:{}/test_files/system3/data", cwd, cwd, cwd, cwd)), + ("XDG_CONFIG_DIRS", format!("{}/test_files/system0/config:{}/test_files/system1/config:{}/test_files/system2/config:{}/test_files/system3/config", cwd, cwd, cwd, cwd)), + ])).unwrap(); + + let files = xd.list_config_files("."); + let mut files = files.into_iter().map(|p| make_relative(&p)).collect::<Vec<_>>(); + files.sort(); + assert_eq!(files, + [ + "test_files/system1/config/both_system_config.file", + "test_files/system1/config/everywhere", + "test_files/system1/config/myapp", + "test_files/system1/config/system1_config.file", + "test_files/system2/config/both_system_config.file", + "test_files/system2/config/everywhere", + "test_files/system2/config/system2_config.file", + "test_files/user/config/everywhere", + "test_files/user/config/myapp", + "test_files/user/config/user_config.file", + ].iter().map(PathBuf::from).collect::<Vec<_>>()); + + let files = xd.list_config_files_once("."); + let mut files = files.into_iter().map(|p| make_relative(&p)).collect::<Vec<_>>(); + files.sort(); + assert_eq!(files, + [ + "test_files/system1/config/both_system_config.file", + "test_files/system1/config/system1_config.file", + "test_files/system2/config/system2_config.file", + "test_files/user/config/everywhere", + "test_files/user/config/myapp", + "test_files/user/config/user_config.file", + ].iter().map(PathBuf::from).collect::<Vec<_>>()); +} + +#[test] +fn test_prefix() { + let cwd = env::current_dir().unwrap().to_string_lossy().into_owned(); + let xd = BaseDirectories::with_env("myapp", "", &*make_env(vec![ + ("HOME", format!("{}/test_files/user", cwd)), + ("XDG_CACHE_HOME", format!("{}/test_files/user/cache", cwd)), + ])).unwrap(); + assert_eq!(xd.place_cache_file("cache.db").unwrap(), + PathBuf::from(&format!("{}/test_files/user/cache/myapp/cache.db", cwd))); +} + +#[test] +fn test_profile() { + let cwd = env::current_dir().unwrap().to_string_lossy().into_owned(); + let xd = BaseDirectories::with_env("myapp", "default_profile", &*make_env(vec![ + ("HOME", format!("{}/test_files/user", cwd)), + ("XDG_CONFIG_HOME", format!("{}/test_files/user/config", cwd)), + ("XDG_CONFIG_DIRS", format!("{}/test_files/system1/config", cwd)), + ])).unwrap(); + assert_eq!(xd.find_config_file("system1_config.file").unwrap(), + // Does *not* include default_profile + PathBuf::from(&format!("{}/test_files/system1/config/myapp/system1_config.file", cwd))); + assert_eq!(xd.find_config_file("user_config.file").unwrap(), + // Includes default_profile + PathBuf::from(&format!("{}/test_files/user/config/myapp/default_profile/user_config.file", cwd))); +} diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/runtime-bad/everywhere b/third_party/cargo/vendor/xdg-2.2.0/test_files/runtime-bad/everywhere new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/runtime-bad/runtime.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/runtime-bad/runtime.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/config/both_system_config.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/config/both_system_config.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/config/everywhere b/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/config/everywhere new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/config/myapp/default_profile/system1_config.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/config/myapp/default_profile/system1_config.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/config/myapp/system1_config.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/config/myapp/system1_config.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/config/system1_config.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/config/system1_config.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/data/both_system_data.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/data/both_system_data.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/data/everywhere b/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/data/everywhere new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/data/system1_data.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/system1/data/system1_data.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/config/both_system_config.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/config/both_system_config.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/config/everywhere b/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/config/everywhere new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/config/system2_config.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/config/system2_config.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/data/both_system_data.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/data/both_system_data.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/data/everywhere b/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/data/everywhere new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/data/system2_data.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/system2/data/system2_data.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/user/cache/everywhere b/third_party/cargo/vendor/xdg-2.2.0/test_files/user/cache/everywhere new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/user/cache/user_cache.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/user/cache/user_cache.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/user/config/everywhere b/third_party/cargo/vendor/xdg-2.2.0/test_files/user/config/everywhere new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/user/config/myapp/default_profile/user_config.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/user/config/myapp/default_profile/user_config.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/user/config/myapp/user_config.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/user/config/myapp/user_config.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/user/config/user_config.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/user/config/user_config.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/user/data/everywhere b/third_party/cargo/vendor/xdg-2.2.0/test_files/user/data/everywhere new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xdg-2.2.0/test_files/user/data/user_data.file b/third_party/cargo/vendor/xdg-2.2.0/test_files/user/data/user_data.file new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/.cargo-checksum.json b/third_party/cargo/vendor/xml-rs-0.8.0/.cargo-checksum.json new file mode 100644 index 0000000..f418028 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"444e5c26b1986ae6c0c549e877b3987cd5c2b439ee6d5521f7b6dc69b74ca92e","Changelog.md":"244e2dbd57656dc505f16ba1077528c30f310f6221f0995c70b37ef76c663599","LICENSE":"0dc18d924dc0a5f41172a393012843a5eaaef338e795b3645da9cc3b6068220b","Readme.md":"269b3cd4286727d936c28c29d3850564104653fc40b6a22bd095679142ce6b01","design.md":"59eb3e89c9fe3e2c9e7dfd464ddceb56d8bb0fac7459d5b12d3f304487fdfcde","src/analyze.rs":"6fc06790088cc19e2e9c8be9d4d3337fe31f741cf7d5850f4b2dc3522c3b2609","src/attribute.rs":"94cb1270e8247af01114b465bda181840b053942dfb7fb6b70d83d48f37f02e2","src/common.rs":"861dca93ca0c6cc7e30cd9f08f486b29dc89d89d361e246ef0947f7060e05ddb","src/escape.rs":"7df467344114064c3bd731c9e70e45c300f7b2704d6edf6e76daf6b32775b780","src/lib.rs":"0c63e2b37cc7e48546b21dfb967c628f38648d52b11323d02b71d8ddd8b41ae1","src/macros.rs":"8c7f9c18083fceb4af9e27a84d9130888829250c869771cb192eec19941988e0","src/name.rs":"fc0d5c0c1e11e14e06f4549a6ddc58cbf4f91f0272802f18591004daf781940a","src/namespace.rs":"d5e1b4b19025d6237f06e1dec3570f7d4f8301631610a93bb56a958d27999480","src/reader/config.rs":"d63ad011a9bded4031e2cc8a7e417b836bbec7b1d1bf106d771d0b506a2b4525","src/reader/error.rs":"bf6a889e9464f0b981ad5b761af46b53fed203b917265eaa0c439d5937a313f4","src/reader/events.rs":"4a07a3173f2613f6ea5b7880467152238a20de59dda42c95008d50ef80c9c3ed","src/reader/lexer.rs":"79fff053c0df98044144832d030dacf0debf8309ad825e57ceab3142d9db155f","src/reader/mod.rs":"4b7055cb60f736b71dabc91fb99bb1e1bf8429e8bf740f83d5e6e1d64cbe2012","src/reader/parser/inside_cdata.rs":"7217ab332a7e29f8a2282d1bfd4d493465e0d6921e0f9f077634fdcedac331c9","src/reader/parser/inside_closing_tag_name.rs":"595d7888180da8a5ed2003da215be3b8b6521ee0624080b18af4eb3f4a2a6901","src/reader/parser/inside_comment.rs":"1f6b077007422562be7793df0a1d7ace3b2d2afd134e621045cd6650088a438d","src/reader/parser/inside_declaration.rs":"ea00f620e0d2d4fe9024796c80a2b325db2a651fb12467a18ea00f280d83ac48","src/reader/parser/inside_doctype.rs":"c87d1e36aea80ca8443a1a59d5cf2ee32d899c04ccbe38492ce3d02536f8fffd","src/reader/parser/inside_opening_tag.rs":"55c49634886ba41f23ac5f7a8e14f5cb02befb4bf9ea6943b4cc2c31a5569d28","src/reader/parser/inside_processing_instruction.rs":"e9cc8c1f8dd8bb065465659533cf7730d53206a88b06f7385544ccaf54e80368","src/reader/parser/inside_reference.rs":"b87e07f8585fa3329d2527c57a5c8ff3deec889b012ebbef61e9440da54d3b45","src/reader/parser/mod.rs":"fcada7c13000b461ac79ad403b8eb2862e455b963074900227d75f92a250887c","src/reader/parser/outside_tag.rs":"77071f46398a04201e2a0e7ab0ff905165728d6e33e7eb6cc6ba56f772da2947","src/util.rs":"576d7db4550c2c38eb77af6545aebc42dcbe5a81eef190d472202d3ddcd7c97c","src/writer/config.rs":"3aaf615b13862e6daae943d27de05118524bb0d8d9444b1e4f245815696a6fea","src/writer/emitter.rs":"50b7d37ef749aab1bb921a4765887c325c295daf7be22e01c5b5e75fa7199459","src/writer/events.rs":"82db3d1c83144fe1abfa5a841de0593cfe85a1cf7b6563f611ef5dd52bb327d0","src/writer/mod.rs":"78c65cf1cf2d286bab3917c4e2c364f6289cdb665ece092422d905d00d1275f9","tests/documents/sample_1.xml":"79c9ba2d71d70906230905cef127ba8c09ae8701c60357d32cf581dbfc660237","tests/documents/sample_1_full.txt":"efc646390dd6693c4122bb4a7d0c77e31bba7fda0e5767aa1de501bddc64174f","tests/documents/sample_1_short.txt":"83ef8cca29ac8e4b20dc9aea182155ad39d090fb08b76b6abe581801211b10e4","tests/documents/sample_2.xml":"c8350272a8c205e4004fc7e10be1660a0e10d2c9dbf044395d52ad2ca08fa03a","tests/documents/sample_2_full.txt":"21a7b53ddfb8eeaf73d0f6d7a1f96b1af3188129d69f6a5fd4d21e6376f2fb7f","tests/documents/sample_2_short.txt":"b94bc0600a84acf0999775d19c5a7169d24f88c74cc605a1f30b981181bacfeb","tests/documents/sample_3.xml":"a29359438fe9ca025f09d62d4b96f51a89d4be9e634767a5bb447d555c75aef8","tests/documents/sample_3_full.txt":"3522aa83d2b0e942e963d234af0b3426ad3c08141d60ccacc18077c67e2b2194","tests/documents/sample_3_short.txt":"57a8cc41ec6fcebf854126b3c9bb933a1de8be6c5b62372e857906314bb8f13f","tests/documents/sample_4.xml":"7c0ae3ee71a9c94afe1a35480a8c3bf58ffe90b754bccf42f83784971584e9b8","tests/documents/sample_4_full.txt":"f4f2419b336b04af9746ee12ac908a9b82cebca8fc280ad5422d0ab5483ee817","tests/documents/sample_4_short.txt":"39e1b7947fc33276347031e12a0a3f0e5a70eee9e743aba7d5c45b08a454cfae","tests/documents/sample_5.xml":"356d33417665fee602eb9399a8fb58e9bfaa634bcadfcd97214302bdc32f33c4","tests/documents/sample_5_short.txt":"9b8e3a9e7a71c55ee30ee85d256b06079e2ea8029207efbfb62ca98add4ce585","tests/event_reader.rs":"c4e7c7fe13461502c895c8c2fd3b65ef74432ee41482b8400ea72b0f0be135b9","tests/event_writer.rs":"a0c92666af8f031e0376dfce20f9864c67cd83ec4256a52b8e7c60ed707b8d45","tests/streaming.rs":"1fc96cd6e1cfedddda534c5f07608df169bf3d054c32f4743f256dfc6731f93a"},"package":"541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5"} \ No newline at end of file diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/BUILD b/third_party/cargo/vendor/xml-rs-0.8.0/BUILD new file mode 100644 index 0000000..1ce70e0 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/BUILD @@ -0,0 +1,68 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "event_reader" with type "test" omitted +# Unsupported target "event_writer" with type "test" omitted +# Unsupported target "streaming" with type "test" omitted +alias( + name = "xml_rs", + actual = ":xml", +) + +rust_library( + name = "xml", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.8.0", + crate_features = [ + ], +) + +rust_binary( + # Prefix bin name to disambiguate from (probable) collision with lib name + # N.B.: The exact form of this is subject to change. + name = "cargo_bin_xml_analyze", + crate_root = "src/analyze.rs", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + # Binaries get an implicit dependency on their crate's lib + ":xml", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.8.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/Cargo.toml b/third_party/cargo/vendor/xml-rs-0.8.0/Cargo.toml new file mode 100644 index 0000000..d414649 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/Cargo.toml @@ -0,0 +1,30 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "xml-rs" +version = "0.8.0" +authors = ["Vladimir Matveev <vladimir.matweev@gmail.com>"] +description = "An XML library in pure Rust" +documentation = "http://netvl.github.io/xml-rs/" +readme = "Readme.md" +keywords = ["xml", "parsing", "parser"] +license = "MIT" +repository = "https://github.com/netvl/xml-rs" + +[lib] +name = "xml" +path = "src/lib.rs" + +[[bin]] +name = "xml-analyze" +path = "src/analyze.rs" diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/Changelog.md b/third_party/cargo/vendor/xml-rs-0.8.0/Changelog.md new file mode 100644 index 0000000..7bc817c --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/Changelog.md @@ -0,0 +1,97 @@ +## Version 0.8.0 + +* Same as 0.7.1, with 0.7.1 being yanked because of the incorrect semver bump. + +## Version 0.7.1 + +* Removed dependency on bitflags. +* Added the `XmlWriter::inner_mut()` method. +* Fixed some rustdoc warnings. + +## Version 0.7.0 + +* Same as 0.6.2, with 0.6.2 being yanked because of the incompatible bump of minimum required version of rustc. + +## Version 0.6.2 + +* Bumped `bitflags` to 1.0. + +## Version 0.6.1 + +* Fixed the writer to escape some special characters when writing attribute values. + +## Version 0.6.0 + +* Changed the target type of extra entities from `char` to `String`. This is an incompatible + change. + +## Version 0.5.0 + +* Added support for ignoring EOF errors in order to read documents from streams incrementally. +* Bumped `bitflags` to 0.9. + +## Version 0.4.1 + +* Added missing `Debug` implementation to `xml::writer::XmlEvent`. + +## Version 0.4.0 + +* Bumped version number, since changes introduced in 0.3.7 break backwards compatibility. + +## Version 0.3.8 + +* Fixed a problem introduced in 0.3.7 with entities in attributes causing parsing errors. + +## Version 0.3.7 + +* Fixed the problem with parsing non-whitespace character entities as whitespace (issue #140). +* Added support for configuring custom entities in the parser configuration. + +## Version 0.3.6 + +* Added an `Error` implementation for `EmitterError`. +* Fixed escaping of strings with multi-byte code points. + +## Version 0.3.5 + +* Added `Debug` implementation for `XmlVersion`. +* Fixed some failing tests. + +## Version 0.3.3 + +* Updated `bitflags` to 0.7. + +## Version 0.3.2 + +* Added `From<io::Error>` for `xml::reader::Error`, which improves usability of working with parsing errors. + +## Version 0.3.1 + +* Bumped `bitflags` dependency to 0.4, some internal warning fixes. + +## Version 0.3.0 + +* Changed error handling in `EventReader` - now I/O errors are properly bubbled up from the lexer. + +## Version 0.2.4 + +* Fixed #112 - incorrect handling of namespace redefinitions when writing a document. + +## Version 0.2.3 + +* Added `into_inner()` methods to `EventReader` and `EventWriter`. + +## Version 0.2.2 + +* Using `join` instead of the deprecated `connect`. +* Added a simple XML analyzer program which demonstrates library usage and can be used to check XML documents for well-formedness. +* Fixed incorrect handling of unqualified attribute names (#107). +* Added this changelog. + +## Version 0.2.1 + +* Fixed #105 - incorrect handling of double dashes. + +## Version 0.2.0 + +* Major update, includes proper document writing support and significant architecture changes. diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/LICENSE b/third_party/cargo/vendor/xml-rs-0.8.0/LICENSE new file mode 100644 index 0000000..6caa1d3 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Vladimir Matveev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/Readme.md b/third_party/cargo/vendor/xml-rs-0.8.0/Readme.md new file mode 100644 index 0000000..a1dec47 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/Readme.md @@ -0,0 +1,236 @@ +xml-rs, an XML library for Rust +=============================== + +[![Build Status][build-status-img]](https://travis-ci.org/netvl/xml-rs) +[![crates.io][crates-io-img]](https://crates.io/crates/xml-rs) +[![docs][docs-img]](https://netvl.github.io/xml-rs/) + +[Documentation](https://netvl.github.io/xml-rs/) + + [build-status-img]: https://img.shields.io/travis/netvl/xml-rs.svg?style=flat-square + [crates-io-img]: https://img.shields.io/crates/v/xml-rs.svg?style=flat-square + [docs-img]: https://img.shields.io/badge/docs-rust_beta-6495ed.svg?style=flat-square + +xml-rs is an XML library for [Rust](http://www.rust-lang.org/) programming language. +It is heavily inspired by Java [Streaming API for XML (StAX)][stax]. + + [stax]: https://en.wikipedia.org/wiki/StAX + +This library currently contains pull parser much like [StAX event reader][stax-reader]. +It provides iterator API, so you can leverage Rust's existing iterators library features. + + [stax-reader]: http://docs.oracle.com/javase/8/docs/api/javax/xml/stream/XMLEventReader.html + +It also provides a streaming document writer much like [StAX event writer][stax-writer]. +This writer consumes its own set of events, but reader events can be converted to +writer events easily, and so it is possible to write XML transformation chains in a pretty +clean manner. + + [stax-writer]: http://docs.oracle.com/javase/8/docs/api/javax/xml/stream/XMLEventWriter.html + +This parser is mostly full-featured, however, there are limitations: +* no other encodings but UTF-8 are supported yet, because no stream-based encoding library + is available now; when (or if) one will be available, I'll try to make use of it; +* DTD validation is not supported, `<!DOCTYPE>` declarations are completely ignored; thus no + support for custom entities too; internal DTD declarations are likely to cause parsing errors; +* attribute value normalization is not performed, and end-of-line characters are not normalized too. + +Other than that the parser tries to be mostly XML-1.0-compliant. + +Writer is also mostly full-featured with the following limitations: +* no support for encodings other than UTF-8, for the same reason as above; +* no support for emitting `<!DOCTYPE>` declarations; +* more validations of input are needed, for example, checking that namespace prefixes are bounded + or comments are well-formed. + +What is planned (highest priority first, approximately): + +0. missing features required by XML standard (e.g. aforementioned normalization and + proper DTD parsing); +1. miscellaneous features of the writer; +2. parsing into a DOM tree and its serialization back to XML text; +3. SAX-like callback-based parser (fairly easy to implement over pull parser); +4. DTD validation; +5. (let's dream a bit) XML Schema validation. + +Building and using +------------------ + +xml-rs uses [Cargo](http://crates.io), so just add a dependency section in your project's manifest: + +```toml +[dependencies] +xml-rs = "0.8" +``` + +The package exposes a single crate called `xml`: + +```rust +extern crate xml; +``` + +Reading XML documents +--------------------- + +`xml::reader::EventReader` requires a `Read` instance to read from. When a proper stream-based encoding +library is available, it is likely that xml-rs will be switched to use whatever character stream structure +this library would provide, but currently it is a `Read`. + +Using `EventReader` is very straightforward. Just provide a `Read` instance to obtain an iterator +over events: + +```rust +extern crate xml; + +use std::fs::File; +use std::io::BufReader; + +use xml::reader::{EventReader, XmlEvent}; + +fn indent(size: usize) -> String { + const INDENT: &'static str = " "; + (0..size).map(|_| INDENT) + .fold(String::with_capacity(size*INDENT.len()), |r, s| r + s) +} + +fn main() { + let file = File::open("file.xml").unwrap(); + let file = BufReader::new(file); + + let parser = EventReader::new(file); + let mut depth = 0; + for e in parser { + match e { + Ok(XmlEvent::StartElement { name, .. }) => { + println!("{}+{}", indent(depth), name); + depth += 1; + } + Ok(XmlEvent::EndElement { name }) => { + depth -= 1; + println!("{}-{}", indent(depth), name); + } + Err(e) => { + println!("Error: {}", e); + break; + } + _ => {} + } + } +} +``` + +`EventReader` implements `IntoIterator` trait, so you can just use it in a `for` loop directly. +Document parsing can end normally or with an error. Regardless of exact cause, the parsing +process will be stopped, and iterator will terminate normally. + +You can also have finer control over when to pull the next event from the parser using its own +`next()` method: + +```rust +match parser.next() { + ... +} +``` + +Upon the end of the document or an error the parser will remember that last event and will always +return it in the result of `next()` call afterwards. If iterator is used, then it will yield +error or end-of-document event once and will produce `None` afterwards. + +It is also possible to tweak parsing process a little using `xml::reader::ParserConfig` structure. +See its documentation for more information and examples. + +You can find a more extensive example of using `EventReader` in `src/analyze.rs`, which is a +small program (BTW, it is built with `cargo build` and can be run after that) which shows various +statistics about specified XML document. It can also be used to check for well-formedness of +XML documents - if a document is not well-formed, this program will exit with an error. + +Writing XML documents +--------------------- + +xml-rs also provides a streaming writer much like StAX event writer. With it you can write an +XML document to any `Write` implementor. + +```rust +extern crate xml; + +use std::fs::File; +use std::io::{self, Write}; + +use xml::writer::{EventWriter, EmitterConfig, XmlEvent, Result}; + +fn handle_event<W: Write>(w: &mut EventWriter<W>, line: String) -> Result<()> { + let line = line.trim(); + let event: XmlEvent = if line.starts_with("+") && line.len() > 1 { + XmlEvent::start_element(&line[1..]).into() + } else if line.starts_with("-") { + XmlEvent::end_element().into() + } else { + XmlEvent::characters(&line).into() + }; + w.write(event) +} + +fn main() { + let mut file = File::create("output.xml").unwrap(); + + let mut input = io::stdin(); + let mut output = io::stdout(); + let mut writer = EmitterConfig::new().perform_indent(true).create_writer(&mut file); + loop { + print!("> "); output.flush().unwrap(); + let mut line = String::new(); + match input.read_line(&mut line) { + Ok(0) => break, + Ok(_) => match handle_event(&mut writer, line) { + Ok(_) => {} + Err(e) => panic!("Write error: {}", e) + }, + Err(e) => panic!("Input error: {}", e) + } + } +} +``` + +The code example above also demonstrates how to create a writer out of its configuration. +Similar thing also works with `EventReader`. + +The library provides an XML event building DSL which helps to construct complex events, +e.g. ones having namespace definitions. Some examples: + +```rust +// <a:hello a:param="value" xmlns:a="urn:some:document"> +XmlEvent::start_element("a:hello").attr("a:param", "value").ns("a", "urn:some:document") + +// <hello b:config="name" xmlns="urn:default:uri"> +XmlEvent::start_element("hello").attr("b:config", "value").default_ns("urn:defaul:uri") + +// <![CDATA[some unescaped text]]> +XmlEvent::cdata("some unescaped text") +``` + +Of course, one can create `XmlEvent` enum variants directly instead of using the builder DSL. +There are more examples in `xml::writer::XmlEvent` documentation. + +The writer has multiple configuration options; see `EmitterConfig` documentation for more +information. + +Other things +------------ + +No performance tests or measurements are done. The implementation is rather naive, and no specific +optimizations are made. Hopefully the library is sufficiently fast to process documents of common size. +I intend to add benchmarks in future, but not until more important features are added. + +Known issues +------------ + +All known issues are present on GitHub issue tracker: <http://github.com/netvl/xml-rs/issues>. +Feel free to post any found problems there. + +License +------- + +This library is licensed under MIT license. + +--- +Copyright (C) Vladimir Matveev, 2014-2017 diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/design.md b/third_party/cargo/vendor/xml-rs-0.8.0/design.md new file mode 100644 index 0000000..da67c7b --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/design.md @@ -0,0 +1,37 @@ +# Reader + +Basic features: + * [x] Parsing XML 1.0 documents and returning a stream of events + - [ ] Support reading embedded DTD schemas + - [ ] Support for embedded entities + * [x] Support for namespaces and emitting namespace information in events + * [ ] \[maybe\] push-based wrapper + * Missing XML features + - [ ] Support for different encodings + - [ ] Attribute values normalization + - [ ] EOL characters normalization + +Advanced features: + * [ ] DTD schema validation + * [ ] XSD schema validation + +# Writer + +Basic features: + * [x] Writing basic XML 1.0 documents in UTF-8 + * [x] Writing XML 1.0 documents with namespace support + * [x] Support for writing elements with empty body as empty elements + * [x] Pretty-printed and compact output + * [ ] Writing XML document with embedded DTDs and DTD references + * Misc features: + - [ ] Support for different encodings + - [x] Support for writing CDATA as characters + - [ ] Checking events for invalid characters (e.g. `--` in comments) + - [ ] Check for namespaces more correctly, i.e. check both for prefix and namespace URI + - [ ] Support checking namespace prefix presence in the current namespace for events with prefix but without namespace + - [ ] Support checking namespace prefix for events with both prefix and namespace URI + +# Other + +DOM-based API: + * [ ] Basic support for DOM-based API diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/analyze.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/analyze.rs new file mode 100644 index 0000000..0a75298 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/analyze.rs @@ -0,0 +1,97 @@ +extern crate xml; + +use std::cmp; +use std::env; +use std::io::{self, Read, Write, BufReader}; +use std::fs::File; +use std::collections::HashSet; + +use xml::ParserConfig; +use xml::reader::XmlEvent; + +macro_rules! abort { + ($code:expr) => {::std::process::exit($code)}; + ($code:expr, $($args:tt)+) => {{ + writeln!(&mut ::std::io::stderr(), $($args)+).unwrap(); + ::std::process::exit($code); + }} +} + +fn main() { + let mut file; + let mut stdin; + let source: &mut Read = match env::args().nth(1) { + Some(file_name) => { + file = File::open(file_name) + .unwrap_or_else(|e| abort!(1, "Cannot open input file: {}", e)); + &mut file + } + None => { + stdin = io::stdin(); + &mut stdin + } + }; + + let reader = ParserConfig::new() + .whitespace_to_characters(true) + .ignore_comments(false) + .create_reader(BufReader::new(source)); + + let mut processing_instructions = 0; + let mut elements = 0; + let mut character_blocks = 0; + let mut cdata_blocks = 0; + let mut characters = 0; + let mut comment_blocks = 0; + let mut comment_characters = 0; + let mut namespaces = HashSet::new(); + let mut depth = 0; + let mut max_depth = 0; + + for e in reader { + match e { + Ok(e) => match e { + XmlEvent::StartDocument { version, encoding, standalone } => + println!( + "XML document version {}, encoded in {}, {}standalone", + version, encoding, if standalone.unwrap_or(false) { "" } else { "not " } + ), + XmlEvent::EndDocument => println!("Document finished"), + XmlEvent::ProcessingInstruction { .. } => processing_instructions += 1, + XmlEvent::Whitespace(_) => {} // can't happen due to configuration + XmlEvent::Characters(s) => { + character_blocks += 1; + characters += s.len(); + } + XmlEvent::CData(s) => { + cdata_blocks += 1; + characters += s.len(); + } + XmlEvent::Comment(s) => { + comment_blocks += 1; + comment_characters += s.len(); + } + XmlEvent::StartElement { namespace, .. } => { + depth += 1; + max_depth = cmp::max(max_depth, depth); + elements += 1; + namespaces.extend(namespace.0.into_iter().map(|(_, ns_uri)| ns_uri)); + } + XmlEvent::EndElement { .. } => { + depth -= 1; + } + }, + Err(e) => abort!(1, "Error parsing XML document: {}", e) + } + } + namespaces.remove(xml::namespace::NS_EMPTY_URI); + namespaces.remove(xml::namespace::NS_XMLNS_URI); + namespaces.remove(xml::namespace::NS_XML_URI); + + println!("Elements: {}, maximum depth: {}", elements, max_depth); + println!("Namespaces (excluding built-in): {}", namespaces.len()); + println!("Characters: {}, characters blocks: {}, CDATA blocks: {}", + characters, character_blocks, cdata_blocks); + println!("Comment blocks: {}, comment characters: {}", comment_blocks, comment_characters); + println!("Processing instructions (excluding built-in): {}", processing_instructions); +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/attribute.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/attribute.rs new file mode 100644 index 0000000..8728f49 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/attribute.rs @@ -0,0 +1,99 @@ +//! Contains XML attributes manipulation types and functions. +//! + +use std::fmt; + +use name::{Name, OwnedName}; +use escape::escape_str_attribute; + +/// A borrowed version of an XML attribute. +/// +/// Consists of a borrowed qualified name and a borrowed string value. +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub struct Attribute<'a> { + /// Attribute name. + pub name: Name<'a>, + + /// Attribute value. + pub value: &'a str +} + +impl<'a> fmt::Display for Attribute<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}=\"{}\"", self.name, escape_str_attribute(self.value)) + } +} + +impl<'a> Attribute<'a> { + /// Creates an owned attribute out of this borrowed one. + #[inline] + pub fn to_owned(&self) -> OwnedAttribute { + OwnedAttribute { + name: self.name.into(), + value: self.value.into(), + } + } + + /// Creates a borrowed attribute using the provided borrowed name and a borrowed string value. + #[inline] + pub fn new(name: Name<'a>, value: &'a str) -> Attribute<'a> { + Attribute { name, value, } + } +} + +/// An owned version of an XML attribute. +/// +/// Consists of an owned qualified name and an owned string value. +#[derive(Clone, Eq, PartialEq, Hash, Debug)] +pub struct OwnedAttribute { + /// Attribute name. + pub name: OwnedName, + + /// Attribute value. + pub value: String +} + +impl OwnedAttribute { + /// Returns a borrowed `Attribute` out of this owned one. + pub fn borrow(&self) -> Attribute { + Attribute { + name: self.name.borrow(), + value: &*self.value, + } + } + + /// Creates a new owned attribute using the provided owned name and an owned string value. + #[inline] + pub fn new<S: Into<String>>(name: OwnedName, value: S) -> OwnedAttribute { + OwnedAttribute { + name, + value: value.into(), + } + } +} + +impl fmt::Display for OwnedAttribute { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}=\"{}\"", self.name, escape_str_attribute(&*self.value)) + } +} + +#[cfg(test)] +mod tests { + use super::{Attribute}; + + use name::Name; + + #[test] + fn attribute_display() { + let attr = Attribute::new( + Name::qualified("attribute", "urn:namespace", Some("n")), + "its value with > & \" ' < weird symbols" + ); + + assert_eq!( + &*attr.to_string(), + "{urn:namespace}n:attribute=\"its value with > & " ' < weird symbols\"" + ) + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/common.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/common.rs new file mode 100644 index 0000000..5409212 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/common.rs @@ -0,0 +1,142 @@ +//! Contains common types and functions used throughout the library. + +use std::fmt; + +/// Represents a position inside some textual document. +#[derive(Copy, Clone, PartialEq, Eq)] +pub struct TextPosition { + /// Row, counting from 0 + pub row: u64, + /// Column, counting from 0 + pub column: u64, +} + +impl TextPosition { + /// Creates a new position initialized to the beginning of the document + #[inline] + pub fn new() -> TextPosition { + TextPosition { row: 0, column: 0 } + } + + /// Advances the position in a line + #[inline] + pub fn advance(&mut self, count: u8) { + self.column += count as u64; + } + + /// Advances the position in a line to the next tab position + #[inline] + pub fn advance_to_tab(&mut self, width: u8) { + let width = width as u64; + self.column += width - self.column % width + } + + /// Advances the position to the beginning of the next line + #[inline] + pub fn new_line(&mut self) { + self.column = 0; + self.row += 1; + } +} + +impl fmt::Debug for TextPosition { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}:{}", self.row + 1, self.column + 1) + } +} + +impl fmt::Display for TextPosition { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}:{}", self.row + 1, self.column + 1) + } +} + +/// Get the position in the document corresponding to the object +/// +/// This trait is implemented by parsers, lexers and errors. +pub trait Position { + /// Returns the current position or a position corresponding to the object. + fn position(&self) -> TextPosition; +} + +impl Position for TextPosition { + #[inline] + fn position(&self) -> TextPosition { + *self + } +} + +/// XML version enumeration. +#[derive(Copy, Clone, PartialEq, Eq)] +pub enum XmlVersion { + /// XML version 1.0. + Version10, + + /// XML version 1.1. + Version11 +} + +impl fmt::Display for XmlVersion { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + XmlVersion::Version10 => write!(f, "1.0"), + XmlVersion::Version11 => write!(f, "1.1") + } + } +} + +impl fmt::Debug for XmlVersion { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + +/// Checks whether the given character is a white space character (`S`) +/// as is defined by XML 1.1 specification, [section 2.3][1]. +/// +/// [1]: http://www.w3.org/TR/2006/REC-xml11-20060816/#sec-common-syn +pub fn is_whitespace_char(c: char) -> bool { + match c { + '\x20' | '\x09' | '\x0d' | '\x0a' => true, + _ => false + } +} + +/// Checks whether the given string is compound only by white space +/// characters (`S`) using the previous is_whitespace_char to check +/// all characters of this string +pub fn is_whitespace_str(s: &str) -> bool { + s.chars().all(is_whitespace_char) +} + +/// Checks whether the given character is a name start character (`NameStartChar`) +/// as is defined by XML 1.1 specification, [section 2.3][1]. +/// +/// [1]: http://www.w3.org/TR/2006/REC-xml11-20060816/#sec-common-syn +pub fn is_name_start_char(c: char) -> bool { + match c { + ':' | 'A'...'Z' | '_' | 'a'...'z' | + '\u{C0}'...'\u{D6}' | '\u{D8}'...'\u{F6}' | '\u{F8}'...'\u{2FF}' | + '\u{370}'...'\u{37D}' | '\u{37F}'...'\u{1FFF}' | + '\u{200C}'...'\u{200D}' | '\u{2070}'...'\u{218F}' | + '\u{2C00}'...'\u{2FEF}' | '\u{3001}'...'\u{D7FF}' | + '\u{F900}'...'\u{FDCF}' | '\u{FDF0}'...'\u{FFFD}' | + '\u{10000}'...'\u{EFFFF}' => true, + _ => false + } +} + +/// Checks whether the given character is a name character (`NameChar`) +/// as is defined by XML 1.1 specification, [section 2.3][1]. +/// +/// [1]: http://www.w3.org/TR/2006/REC-xml11-20060816/#sec-common-syn +pub fn is_name_char(c: char) -> bool { + match c { + _ if is_name_start_char(c) => true, + '-' | '.' | '0'...'9' | '\u{B7}' | + '\u{300}'...'\u{3F6}' | '\u{203F}'...'\u{2040}' => true, + _ => false + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/escape.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/escape.rs new file mode 100644 index 0000000..18298b9 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/escape.rs @@ -0,0 +1,126 @@ +//! Contains functions for performing XML special characters escaping. + +use std::borrow::Cow; + +enum Value { + Char(char), + Str(&'static str) +} + +impl Value { + fn dispatch_for_attribute(c: char) -> Value { + match c { + '<' => Value::Str("<"), + '>' => Value::Str(">"), + '"' => Value::Str("""), + '\'' => Value::Str("'"), + '&' => Value::Str("&"), + '\n' => Value::Str(" "), + '\r' => Value::Str(" "), + _ => Value::Char(c) + } + } + + fn dispatch_for_pcdata(c: char) -> Value { + match c { + '<' => Value::Str("<"), + '&' => Value::Str("&"), + _ => Value::Char(c) + } + } +} + +enum Process<'a> { + Borrowed(&'a str), + Owned(String) +} + +impl<'a> Process<'a> { + fn process(&mut self, (i, next): (usize, Value)) { + match next { + Value::Str(s) => match *self { + Process::Owned(ref mut o) => o.push_str(s), + Process::Borrowed(b) => { + let mut r = String::with_capacity(b.len() + s.len()); + r.push_str(&b[..i]); + r.push_str(s); + *self = Process::Owned(r); + } + }, + Value::Char(c) => match *self { + Process::Borrowed(_) => {} + Process::Owned(ref mut o) => o.push(c) + } + } + } + + fn into_result(self) -> Cow<'a, str> { + match self { + Process::Borrowed(b) => Cow::Borrowed(b), + Process::Owned(o) => Cow::Owned(o) + } + } +} + +impl<'a> Extend<(usize, Value)> for Process<'a> { + fn extend<I: IntoIterator<Item=(usize, Value)>>(&mut self, it: I) { + for v in it.into_iter() { + self.process(v); + } + } +} + +fn escape_str(s: &str, dispatch: fn(char) -> Value) -> Cow<str> { + let mut p = Process::Borrowed(s); + p.extend(s.char_indices().map(|(ind, c)| (ind, dispatch(c)))); + p.into_result() +} + +/// Performs escaping of common XML characters inside an attribute value. +/// +/// This function replaces several important markup characters with their +/// entity equivalents: +/// +/// * `<` → `<` +/// * `>` → `>` +/// * `"` → `"` +/// * `'` → `'` +/// * `&` → `&` +/// +/// The resulting string is safe to use inside XML attribute values or in PCDATA sections. +/// +/// Does not perform allocations if the given string does not contain escapable characters. +#[inline] +pub fn escape_str_attribute(s: &str) -> Cow<str> { + escape_str(s, Value::dispatch_for_attribute) +} + +/// Performs escaping of common XML characters inside PCDATA. +/// +/// This function replaces several important markup characters with their +/// entity equivalents: +/// +/// * `<` → `<` +/// * `&` → `&` +/// +/// The resulting string is safe to use inside PCDATA sections but NOT inside attribute values. +/// +/// Does not perform allocations if the given string does not contain escapable characters. +#[inline] +pub fn escape_str_pcdata(s: &str) -> Cow<str> { + escape_str(s, Value::dispatch_for_pcdata) +} + +#[cfg(test)] +mod tests { + use super::{escape_str_pcdata, escape_str_attribute}; + + // TODO: add more tests + + #[test] + fn test_escape_multibyte_code_points() { + assert_eq!(escape_str_attribute("☃<"), "☃<"); + assert_eq!(escape_str_pcdata("☃<"), "☃<"); + } +} + diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/lib.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/lib.rs new file mode 100644 index 0000000..15919e8 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/lib.rs @@ -0,0 +1,21 @@ +//#![warn(missing_doc)] +#![allow(dead_code)] +#![allow(unused_variables)] +#![forbid(non_camel_case_types)] + +//! This crate currently provides an almost XML 1.0/1.1-compliant pull parser. + +pub use reader::EventReader; +pub use reader::ParserConfig; +pub use writer::EventWriter; +pub use writer::EmitterConfig; + +pub mod macros; +pub mod name; +pub mod attribute; +pub mod common; +pub mod escape; +pub mod namespace; +pub mod reader; +pub mod writer; +mod util; diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/macros.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/macros.rs new file mode 100644 index 0000000..1cce3d6 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/macros.rs @@ -0,0 +1,30 @@ +#![macro_use] + +//! Contains several macros used in this crate. + +macro_rules! gen_setter { + ($target:ty, $field:ident : into $t:ty) => { + impl $target { + /// Sets the field to the provided value and returns updated config object. + pub fn $field<T: Into<$t>>(mut self, value: T) -> $target { + self.$field = value.into(); + self + } + } + }; + ($target:ty, $field:ident : val $t:ty) => { + impl $target { + /// Sets the field to the provided value and returns updated config object. + pub fn $field(mut self, value: $t) -> $target { + self.$field = value; + self + } + } + } +} + +macro_rules! gen_setters { + ($target:ty, $($field:ident : $k:tt $tpe:ty),+) => ($( + gen_setter! { $target, $field : $k $tpe } + )+) +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/name.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/name.rs new file mode 100644 index 0000000..a20eae2 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/name.rs @@ -0,0 +1,301 @@ +//! Contains XML qualified names manipulation types and functions. +//! + +use std::fmt; +use std::str::FromStr; + +use namespace::NS_NO_PREFIX; + +/// Represents a qualified XML name. +/// +/// A qualified name always consists at least of a local name. It can optionally contain +/// a prefix; when reading an XML document, if it contains a prefix, it must also contain a +/// namespace URI, but this is not enforced statically; see below. The name can contain a +/// namespace without a prefix; in that case a default, empty prefix is assumed. +/// +/// When writing XML documents, it is possible to omit the namespace URI, leaving only +/// the prefix. In this case the writer will check that the specifed prefix is bound to some +/// URI in the current namespace context. If both prefix and namespace URI are specified, +/// it is checked that the current namespace context contains this exact correspondence +/// between prefix and namespace URI. +/// +/// # Prefixes and URIs +/// +/// A qualified name with a prefix must always contain a proper namespace URI --- names with +/// a prefix but without a namespace associated with that prefix are meaningless. However, +/// it is impossible to obtain proper namespace URI by a prefix without a context, and such +/// context is only available when parsing a document (or it can be constructed manually +/// when writing a document). Tying a name to a context statically seems impractical. This +/// may change in future, though. +/// +/// # Conversions +/// +/// `Name` implements some `From` instances for conversion from strings and tuples. For example: +/// +/// ```rust +/// # use xml::name::Name; +/// let n1: Name = "p:some-name".into(); +/// let n2: Name = ("p", "some-name").into(); +/// +/// assert_eq!(n1, n2); +/// assert_eq!(n1.local_name, "some-name"); +/// assert_eq!(n1.prefix, Some("p")); +/// assert!(n1.namespace.is_none()); +/// ``` +/// +/// This is added to support easy specification of XML elements when writing XML documents. +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] +pub struct Name<'a> { + /// A local name, e.g. `string` in `xsi:string`. + pub local_name: &'a str, + + /// A namespace URI, e.g. `http://www.w3.org/2000/xmlns/`. + pub namespace: Option<&'a str>, + + /// A name prefix, e.g. `xsi` in `xsi:string`. + pub prefix: Option<&'a str> +} + +impl<'a> From<&'a str> for Name<'a> { + fn from(s: &'a str) -> Name<'a> { + let mut parts = s.splitn(2, ":").fuse(); + match (parts.next(), parts.next()) { + (Some(name), None) => Name::local(name), + (Some(prefix), Some(name)) => Name::prefixed(name, prefix), + _ => unreachable!() + } + } +} + +impl<'a> From<(&'a str, &'a str)> for Name<'a> { + fn from((prefix, name): (&'a str, &'a str)) -> Name<'a> { + Name::prefixed(name, prefix) + } +} + +impl<'a> fmt::Display for Name<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if let Some(namespace) = self.namespace { + write!(f, "{{{}}}", namespace)?; + } + + if let Some(prefix) = self.prefix { + write!(f, "{}:", prefix)?; + } + + write!(f, "{}", self.local_name) + } +} + +impl<'a> Name<'a> { + /// Returns an owned variant of the qualified name. + pub fn to_owned(&self) -> OwnedName { + OwnedName { + local_name: self.local_name.into(), + namespace: self.namespace.map(|s| s.into()), + prefix: self.prefix.map(|s| s.into()) + } + } + + /// Returns a new `Name` instance representing plain local name. + #[inline] + pub fn local(local_name: &str) -> Name { + Name { + local_name, + prefix: None, + namespace: None + } + } + + /// Returns a new `Name` instance with the given local name and prefix. + #[inline] + pub fn prefixed(local_name: &'a str, prefix: &'a str) -> Name<'a> { + Name { + local_name, + namespace: None, + prefix: Some(prefix) + } + } + + /// Returns a new `Name` instance representing a qualified name with or without a prefix and + /// with a namespace URI. + #[inline] + pub fn qualified(local_name: &'a str, namespace: &'a str, prefix: Option<&'a str>) -> Name<'a> { + Name { + local_name, + namespace: Some(namespace), + prefix, + } + } + + /// Returns a correct XML representation of this local name and prefix. + /// + /// This method is different from the autoimplemented `to_string()` because it does not + /// include namespace URI in the result. + pub fn to_repr(&self) -> String { + self.repr_display().to_string() + } + + /// Returns a structure which can be displayed with `std::fmt` machinery to obtain this + /// local name and prefix. + /// + /// This method is needed for efficiency purposes in order not to create unnecessary + /// allocations. + #[inline] + pub fn repr_display(&self) -> ReprDisplay { + ReprDisplay(self) + } + + /// Returns either a prefix of this name or `namespace::NS_NO_PREFIX` constant. + #[inline] + pub fn prefix_repr(&self) -> &str { + self.prefix.unwrap_or(NS_NO_PREFIX) + } +} + +/// A wrapper around `Name` whose `Display` implementation prints the wrapped name as it is +/// displayed in an XML document. +pub struct ReprDisplay<'a, 'b:'a>(&'a Name<'b>); + +impl<'a, 'b:'a> fmt::Display for ReprDisplay<'a, 'b> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.0.prefix { + Some(prefix) => write!(f, "{}:{}", prefix, self.0.local_name), + None => write!(f, "{}", self.0.local_name) + } + } +} + +/// An owned variant of `Name`. +/// +/// Everything about `Name` applies to this structure as well. +#[derive(Clone, PartialEq, Eq, Hash, Debug)] +pub struct OwnedName { + /// A local name, e.g. `string` in `xsi:string`. + pub local_name: String, + + /// A namespace URI, e.g. `http://www.w3.org/2000/xmlns/`. + pub namespace: Option<String>, + + /// A name prefix, e.g. `xsi` in `xsi:string`. + pub prefix: Option<String>, +} + +impl fmt::Display for OwnedName { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.borrow(), f) + } +} + +impl OwnedName { + /// Constructs a borrowed `Name` based on this owned name. + pub fn borrow(&self) -> Name { + Name { + local_name: &*self.local_name, + namespace: self.namespace.as_ref().map(|s| &**s), + prefix: self.prefix.as_ref().map(|s| &**s), + } + } + + /// Returns a new `OwnedName` instance representing a plain local name. + #[inline] + pub fn local<S>(local_name: S) -> OwnedName where S: Into<String> { + OwnedName { + local_name: local_name.into(), + namespace: None, + prefix: None, + } + } + + /// Returns a new `OwnedName` instance representing a qualified name with or without + /// a prefix and with a namespace URI. + #[inline] + pub fn qualified<S1, S2, S3>(local_name: S1, namespace: S2, prefix: Option<S3>) -> OwnedName + where S1: Into<String>, S2: Into<String>, S3: Into<String> + { + OwnedName { + local_name: local_name.into(), + namespace: Some(namespace.into()), + prefix: prefix.map(|v| v.into()) + } + } + + /// Returns an optional prefix by reference, equivalent to `self.borrow().prefix` + /// but avoids extra work. + #[inline] + pub fn prefix_ref(&self) -> Option<&str> { + self.prefix.as_ref().map(|s| &**s) + } + + /// Returns an optional namespace by reference, equivalen to `self.borrow().namespace` + /// but avoids extra work. + #[inline] + pub fn namespace_ref(&self) -> Option<&str> { + self.namespace.as_ref().map(|s| &**s) + } +} + +impl<'a> From<Name<'a>> for OwnedName { + #[inline] + fn from(n: Name<'a>) -> OwnedName { + n.to_owned() + } +} + +impl FromStr for OwnedName { + type Err = (); + + /// Parses the given string slice into a qualified name. + /// + /// This function, when finishes sucessfully, always return a qualified + /// name without a namespace (`name.namespace == None`). It should be filled later + /// using proper `NamespaceStack`. + /// + /// It is supposed that all characters in the argument string are correct + /// as defined by the XML specification. No additional checks except a check + /// for emptiness are done. + fn from_str(s: &str) -> Result<OwnedName, ()> { + let mut it = s.split(':'); + + let r = match (it.next(), it.next(), it.next()) { + (Some(prefix), Some(local_name), None) if !prefix.is_empty() && + !local_name.is_empty() => + Some((local_name.into(), Some(prefix.into()))), + (Some(local_name), None, None) if !local_name.is_empty() => + Some((local_name.into(), None)), + (_, _, _) => None + }; + r.map(|(local_name, prefix)| OwnedName { + local_name, + namespace: None, + prefix + }).ok_or(()) + } +} + +#[cfg(test)] +mod tests { + use super::OwnedName; + + #[test] + fn test_owned_name_from_str() { + assert_eq!("prefix:name".parse(), Ok(OwnedName { + local_name: "name".into(), + namespace: None, + prefix: Some("prefix".into()) + })); + + assert_eq!("name".parse(), Ok(OwnedName { + local_name: "name".into(), + namespace: None, + prefix: None + })); + + assert_eq!("".parse(), Err::<OwnedName, ()>(())); + assert_eq!(":".parse(), Err::<OwnedName, ()>(())); + assert_eq!(":a".parse(), Err::<OwnedName, ()>(())); + assert_eq!("a:".parse(), Err::<OwnedName, ()>(())); + assert_eq!("a:b:c".parse(), Err::<OwnedName, ()>(())); + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/namespace.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/namespace.rs new file mode 100644 index 0000000..1ab4a5c --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/namespace.rs @@ -0,0 +1,485 @@ +//! Contains namespace manipulation types and functions. + +use std::iter::{Map, Rev}; +use std::collections::btree_map::{BTreeMap, Entry}; +use std::collections::btree_map::Iter as Entries; +use std::collections::HashSet; +use std::slice::Iter; + +/// Designates prefix for namespace definitions. +/// +/// See [Namespaces in XML][namespace] spec for more information. +/// +/// [namespace]: http://www.w3.org/TR/xml-names/#ns-decl +pub const NS_XMLNS_PREFIX: &'static str = "xmlns"; + +/// Designates the standard URI for `xmlns` prefix. +/// +/// See [A Namespace Name for xmlns Attributes][1] for more information. +/// +/// [namespace]: http://www.w3.org/2000/xmlns/ +pub const NS_XMLNS_URI: &'static str = "http://www.w3.org/2000/xmlns/"; + +/// Designates prefix for a namespace containing several special predefined attributes. +/// +/// See [2.10 White Space handling][1], [2.1 Language Identification][2], +/// [XML Base specification][3] and [xml:id specification][4] for more information. +/// +/// [1]: http://www.w3.org/TR/REC-xml/#sec-white-space +/// [2]: http://www.w3.org/TR/REC-xml/#sec-lang-tag +/// [3]: http://www.w3.org/TR/xmlbase/ +/// [4]: http://www.w3.org/TR/xml-id/ +pub const NS_XML_PREFIX: &'static str = "xml"; + +/// Designates the standard URI for `xml` prefix. +/// +/// See `NS_XML_PREFIX` documentation for more information. +pub const NS_XML_URI: &'static str = "http://www.w3.org/XML/1998/namespace"; + +/// Designates the absence of prefix in a qualified name. +/// +/// This constant should be used to define or query default namespace which should be used +/// for element or attribute names without prefix. For example, if a namespace mapping +/// at a particular point in the document contains correspondence like +/// +/// ```none +/// NS_NO_PREFIX --> urn:some:namespace +/// ``` +/// +/// then all names declared without an explicit prefix `urn:some:namespace` is assumed as +/// a namespace URI. +/// +/// By default empty prefix corresponds to absence of namespace, but this can change either +/// when writing an XML document (manually) or when reading an XML document (based on namespace +/// declarations). +pub const NS_NO_PREFIX: &'static str = ""; + +/// Designates an empty namespace URI, which is equivalent to absence of namespace. +/// +/// This constant should not usually be used directly; it is used to designate that +/// empty prefix corresponds to absent namespace in `NamespaceStack` instances created with +/// `NamespaceStack::default()`. Therefore, it can be used to restore `NS_NO_PREFIX` mapping +/// in a namespace back to its default value. +pub const NS_EMPTY_URI: &'static str = ""; + +/// Namespace is a map from prefixes to namespace URIs. +/// +/// No prefix (i.e. default namespace) is designated by `NS_NO_PREFIX` constant. +#[derive(PartialEq, Eq, Clone, Debug)] +pub struct Namespace(pub BTreeMap<String, String>); + +impl Namespace { + /// Returns an empty namespace. + #[inline] + pub fn empty() -> Namespace { Namespace(BTreeMap::new()) } + + /// Checks whether this namespace is empty. + #[inline] + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } + + /// Checks whether this namespace is essentially empty, that is, it does not contain + /// anything but default mappings. + pub fn is_essentially_empty(&self) -> bool { + // a shortcut for a namespace which is definitely not empty + if self.0.len() > 3 { return false; } + + self.0.iter().all(|(k, v)| match (&**k, &**v) { + (NS_NO_PREFIX, NS_EMPTY_URI) => true, + (NS_XMLNS_PREFIX, NS_XMLNS_URI) => true, + (NS_XML_PREFIX, NS_XML_URI) => true, + _ => false + }) + } + + /// Checks whether this namespace mapping contains the given prefix. + /// + /// # Parameters + /// * `prefix` --- namespace prefix. + /// + /// # Return value + /// `true` if this namespace contains the given prefix, `false` otherwise. + #[inline] + pub fn contains<P: ?Sized+AsRef<str>>(&self, prefix: &P) -> bool { + self.0.contains_key(prefix.as_ref()) + } + + /// Puts a mapping into this namespace. + /// + /// This method does not override any already existing mappings. + /// + /// Returns a boolean flag indicating whether the map already contained + /// the given prefix. + /// + /// # Parameters + /// * `prefix` --- namespace prefix; + /// * `uri` --- namespace URI. + /// + /// # Return value + /// `true` if `prefix` has been inserted successfully; `false` if the `prefix` + /// was already present in the namespace. + pub fn put<P, U>(&mut self, prefix: P, uri: U) -> bool + where P: Into<String>, U: Into<String> + { + match self.0.entry(prefix.into()) { + Entry::Occupied(_) => false, + Entry::Vacant(ve) => { + ve.insert(uri.into()); + true + } + } + } + + /// Puts a mapping into this namespace forcefully. + /// + /// This method, unlike `put()`, does replace an already existing mapping. + /// + /// Returns previous URI which was assigned to the given prefix, if it is present. + /// + /// # Parameters + /// * `prefix` --- namespace prefix; + /// * `uri` --- namespace URI. + /// + /// # Return value + /// `Some(uri)` with `uri` being a previous URI assigned to the `prefix`, or + /// `None` if such prefix was not present in the namespace before. + pub fn force_put<P, U>(&mut self, prefix: P, uri: U) -> Option<String> + where P: Into<String>, U: Into<String> + { + self.0.insert(prefix.into(), uri.into()) + } + + /// Queries the namespace for the given prefix. + /// + /// # Parameters + /// * `prefix` --- namespace prefix. + /// + /// # Return value + /// Namespace URI corresponding to the given prefix, if it is present. + pub fn get<'a, P: ?Sized+AsRef<str>>(&'a self, prefix: &P) -> Option<&'a str> { + self.0.get(prefix.as_ref()).map(|s| &**s) + } +} + +/// An alias for iterator type for namespace mappings contained in a namespace. +pub type NamespaceMappings<'a> = Map< + Entries<'a, String, String>, + for<'b> fn((&'b String, &'b String)) -> UriMapping<'b> +>; + +impl<'a> IntoIterator for &'a Namespace { + type Item = UriMapping<'a>; + type IntoIter = NamespaceMappings<'a>; + + fn into_iter(self) -> Self::IntoIter { + fn mapper<'a>((prefix, uri): (&'a String, &'a String)) -> UriMapping<'a> { + (&*prefix, &*uri) + } + self.0.iter().map(mapper) + } +} + +/// Namespace stack is a sequence of namespaces. +/// +/// Namespace stack is used to represent cumulative namespace consisting of +/// combined namespaces from nested elements. +#[derive(Clone, Eq, PartialEq, Debug)] +pub struct NamespaceStack(pub Vec<Namespace>); + +impl NamespaceStack { + /// Returns an empty namespace stack. + #[inline] + pub fn empty() -> NamespaceStack { NamespaceStack(Vec::with_capacity(2)) } + + /// Returns a namespace stack with default items in it. + /// + /// Default items are the following: + /// + /// * `xml` → `http://www.w3.org/XML/1998/namespace`; + /// * `xmlns` → `http://www.w3.org/2000/xmlns/`. + #[inline] + pub fn default() -> NamespaceStack { + let mut nst = NamespaceStack::empty(); + nst.push_empty(); + // xml namespace + nst.put(NS_XML_PREFIX, NS_XML_URI); + // xmlns namespace + nst.put(NS_XMLNS_PREFIX, NS_XMLNS_URI); + // empty namespace + nst.put(NS_NO_PREFIX, NS_EMPTY_URI); + nst + } + + /// Adds an empty namespace to the top of this stack. + #[inline] + pub fn push_empty(&mut self) -> &mut NamespaceStack { + self.0.push(Namespace::empty()); + self + } + + /// Removes the topmost namespace in this stack. + /// + /// Panics if the stack is empty. + #[inline] + pub fn pop(&mut self) -> Namespace { + self.0.pop().unwrap() + } + + /// Removes the topmost namespace in this stack. + /// + /// Returns `Some(namespace)` if this stack is not empty and `None` otherwise. + #[inline] + pub fn try_pop(&mut self) -> Option<Namespace> { + self.0.pop() + } + + /// Borrows the topmost namespace mutably, leaving the stack intact. + /// + /// Panics if the stack is empty. + #[inline] + pub fn peek_mut(&mut self) -> &mut Namespace { + self.0.last_mut().unwrap() + } + + /// Borrows the topmost namespace immutably, leaving the stack intact. + /// + /// Panics if the stack is empty. + #[inline] + pub fn peek(&self) -> &Namespace { + self.0.last().unwrap() + } + + /// Puts a mapping into the topmost namespace if this stack does not already contain one. + /// + /// Returns a boolean flag indicating whether the insertion has completed successfully. + /// Note that both key and value are matched and the mapping is inserted if either + /// namespace prefix is not already mapped, or if it is mapped, but to a different URI. + /// + /// # Parameters + /// * `prefix` --- namespace prefix; + /// * `uri` --- namespace URI. + /// + /// # Return value + /// `true` if `prefix` has been inserted successfully; `false` if the `prefix` + /// was already present in the namespace stack. + pub fn put_checked<P, U>(&mut self, prefix: P, uri: U) -> bool + where P: Into<String> + AsRef<str>, + U: Into<String> + AsRef<str> + { + if self.0.iter().any(|ns| ns.get(&prefix) == Some(uri.as_ref())) { + false + } else { + self.put(prefix, uri); + true + } + } + + /// Puts a mapping into the topmost namespace in this stack. + /// + /// This method does not override a mapping in the topmost namespace if it is + /// already present, however, it does not depend on other namespaces in the stack, + /// so it is possible to put a mapping which is present in lower namespaces. + /// + /// Returns a boolean flag indicating whether the insertion has completed successfully. + /// + /// # Parameters + /// * `prefix` --- namespace prefix; + /// * `uri` --- namespace URI. + /// + /// # Return value + /// `true` if `prefix` has been inserted successfully; `false` if the `prefix` + /// was already present in the namespace. + #[inline] + pub fn put<P, U>(&mut self, prefix: P, uri: U) -> bool + where P: Into<String>, U: Into<String> + { + self.0.last_mut().unwrap().put(prefix, uri) + } + + /// Performs a search for the given prefix in the whole stack. + /// + /// This method walks the stack from top to bottom, querying each namespace + /// in order for the given prefix. If none of the namespaces contains the prefix, + /// `None` is returned. + /// + /// # Parameters + /// * `prefix` --- namespace prefix. + #[inline] + pub fn get<'a, P: ?Sized+AsRef<str>>(&'a self, prefix: &P) -> Option<&'a str> { + let prefix = prefix.as_ref(); + for ns in self.0.iter().rev() { + match ns.get(prefix) { + None => {}, + r => return r, + } + } + None + } + + /// Combines this stack of namespaces into a single namespace. + /// + /// Namespaces are combined in left-to-right order, that is, rightmost namespace + /// elements take priority over leftmost ones. + pub fn squash(&self) -> Namespace { + let mut result = BTreeMap::new(); + for ns in self.0.iter() { + result.extend(ns.0.iter().map(|(k, v)| (k.clone(), v.clone()))); + } + Namespace(result) + } + + /// Returns an object which implements `Extend` using `put_checked()` instead of `put()`. + /// + /// See `CheckedTarget` for more information. + #[inline] + pub fn checked_target(&mut self) -> CheckedTarget { + CheckedTarget(self) + } + + /// Returns an iterator over all mappings in this namespace stack. + #[inline] + pub fn iter(&self) -> NamespaceStackMappings { + self.into_iter() + } +} + +/// An iterator over mappings from prefixes to URIs in a namespace stack. +/// +/// # Example +/// ``` +/// # use xml::namespace::NamespaceStack; +/// let mut nst = NamespaceStack::empty(); +/// nst.push_empty(); +/// nst.put("a", "urn:A"); +/// nst.put("b", "urn:B"); +/// nst.push_empty(); +/// nst.put("c", "urn:C"); +/// +/// assert_eq!(vec![("c", "urn:C"), ("a", "urn:A"), ("b", "urn:B")], nst.iter().collect::<Vec<_>>()); +/// ``` +pub struct NamespaceStackMappings<'a> { + namespaces: Rev<Iter<'a, Namespace>>, + current_namespace: Option<NamespaceMappings<'a>>, + used_keys: HashSet<&'a str> +} + +impl<'a> NamespaceStackMappings<'a> { + fn go_to_next_namespace(&mut self) -> bool { + self.current_namespace = self.namespaces.next().map(|ns| ns.into_iter()); + self.current_namespace.is_some() + } +} + +impl<'a> Iterator for NamespaceStackMappings<'a> { + type Item = UriMapping<'a>; + + fn next(&mut self) -> Option<UriMapping<'a>> { + // If there is no current namespace and no next namespace, we're finished + if self.current_namespace.is_none() && !self.go_to_next_namespace() { + return None; + } + let next_item = self.current_namespace.as_mut().unwrap().next(); + + match next_item { + // There is an element in the current namespace + Some((k, v)) => if self.used_keys.contains(&k) { + // If the current key is used, go to the next one + self.next() + } else { + // Otherwise insert the current key to the set of used keys and + // return the mapping + self.used_keys.insert(k); + Some((k, v)) + }, + // Current namespace is exhausted + None => if self.go_to_next_namespace() { + // If there is next namespace, continue from it + self.next() + } else { + // No next namespace, exiting + None + } + } + } +} + +impl<'a> IntoIterator for &'a NamespaceStack { + type Item = UriMapping<'a>; + type IntoIter = NamespaceStackMappings<'a>; + + fn into_iter(self) -> Self::IntoIter { + NamespaceStackMappings { + namespaces: self.0.iter().rev(), + current_namespace: None, + used_keys: HashSet::new() + } + } +} + +/// A type alias for a pair of `(prefix, uri)` values returned by namespace iterators. +pub type UriMapping<'a> = (&'a str, &'a str); + +impl<'a> Extend<UriMapping<'a>> for Namespace { + fn extend<T>(&mut self, iterable: T) where T: IntoIterator<Item=UriMapping<'a>> { + for (prefix, uri) in iterable { + self.put(prefix, uri); + } + } +} + +impl<'a> Extend<UriMapping<'a>> for NamespaceStack { + fn extend<T>(&mut self, iterable: T) where T: IntoIterator<Item=UriMapping<'a>> { + for (prefix, uri) in iterable { + self.put(prefix, uri); + } + } +} + +/// A wrapper around `NamespaceStack` which implements `Extend` using `put_checked()`. +/// +/// # Example +/// +/// ``` +/// # use xml::namespace::NamespaceStack; +/// +/// let mut nst = NamespaceStack::empty(); +/// nst.push_empty(); +/// nst.put("a", "urn:A"); +/// nst.put("b", "urn:B"); +/// nst.push_empty(); +/// nst.put("c", "urn:C"); +/// +/// nst.checked_target().extend(vec![("a", "urn:Z"), ("b", "urn:B"), ("c", "urn:Y"), ("d", "urn:D")]); +/// assert_eq!( +/// vec![("a", "urn:Z"), ("c", "urn:C"), ("d", "urn:D"), ("b", "urn:B")], +/// nst.iter().collect::<Vec<_>>() +/// ); +/// ``` +/// +/// Compare: +/// +/// ``` +/// # use xml::namespace::NamespaceStack; +/// # let mut nst = NamespaceStack::empty(); +/// # nst.push_empty(); +/// # nst.put("a", "urn:A"); +/// # nst.put("b", "urn:B"); +/// # nst.push_empty(); +/// # nst.put("c", "urn:C"); +/// +/// nst.extend(vec![("a", "urn:Z"), ("b", "urn:B"), ("c", "urn:Y"), ("d", "urn:D")]); +/// assert_eq!( +/// vec![("a", "urn:Z"), ("b", "urn:B"), ("c", "urn:C"), ("d", "urn:D")], +/// nst.iter().collect::<Vec<_>>() +/// ); +/// ``` +pub struct CheckedTarget<'a>(&'a mut NamespaceStack); + +impl<'a, 'b> Extend<UriMapping<'b>> for CheckedTarget<'a> { + fn extend<T>(&mut self, iterable: T) where T: IntoIterator<Item=UriMapping<'b>> { + for (prefix, uri) in iterable { + self.0.put_checked(prefix, uri); + } + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/config.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/config.rs new file mode 100644 index 0000000..3800a6c --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/config.rs @@ -0,0 +1,164 @@ +//! Contains parser configuration structure. +use std::io::Read; +use std::collections::HashMap; + +use reader::EventReader; + +/// Parser configuration structure. +/// +/// This structure contains various configuration options which affect +/// behavior of the parser. +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct ParserConfig { + /// Whether or not should whitespace in textual events be removed. Default is false. + /// + /// When true, all standalone whitespace will be removed (this means no + /// `Whitespace` events will ve emitted), and leading and trailing whitespace + /// from `Character` events will be deleted. If after trimming `Characters` + /// event will be empty, it will also be omitted from output stream. This is + /// possible, however, only if `whitespace_to_characters` or + /// `cdata_to_characters` options are set. + /// + /// This option does not affect CDATA events, unless `cdata_to_characters` + /// option is also set. In that case CDATA content will also be trimmed. + pub trim_whitespace: bool, + + /// Whether or not should whitespace be converted to characters. + /// Default is false. + /// + /// If true, instead of `Whitespace` events `Characters` events with the + /// same content will be emitted. If `trim_whitespace` is also true, these + /// events will be trimmed to nothing and, consequently, not emitted. + pub whitespace_to_characters: bool, + + /// Whether or not should CDATA be converted to characters. + /// Default is false. + /// + /// If true, instead of `CData` events `Characters` events with the same + /// content will be emitted. If `trim_whitespace` is also true, these events + /// will be trimmed. If corresponding CDATA contained nothing but whitespace, + /// this event will be omitted from the stream. + pub cdata_to_characters: bool, + + /// Whether or not should comments be omitted. Default is true. + /// + /// If true, `Comment` events will not be emitted at all. + pub ignore_comments: bool, + + /// Whether or not should sequential `Characters` events be merged. + /// Default is true. + /// + /// If true, multiple sequential `Characters` events will be merged into + /// a single event, that is, their data will be concatenated. + /// + /// Multiple sequential `Characters` events are only possible if either + /// `cdata_to_characters` or `ignore_comments` are set. Otherwise character + /// events will always be separated by other events. + pub coalesce_characters: bool, + + /// A map of extra entities recognized by the parser. Default is an empty map. + /// + /// By default the XML parser recognizes the entities defined in the XML spec. Sometimes, + /// however, it is convenient to make the parser recognize additional entities which + /// are also not available through the DTD definitions (especially given that at the moment + /// DTD parsing is not supported). + pub extra_entities: HashMap<String, String>, + + /// Whether or not the parser should ignore the end of stream. Default is false. + /// + /// By default the parser will either error out when it encounters a premature end of + /// stream or complete normally if the end of stream was expected. If you want to continue + /// reading from a stream whose input is supplied progressively, you can set this option to true. + /// In this case the parser will allow you to invoke the next() method even if a supposed end + /// of stream has happened. + /// + /// Note that support for this functionality is incomplete; for example, the parser will fail if + /// the premature end of stream happens inside PCDATA. Therefore, use this option at your own risk. + pub ignore_end_of_stream: bool +} + +impl ParserConfig { + /// Returns a new config with default values. + /// + /// You can tweak default values using builder-like pattern: + /// + /// ```rust + /// use xml::reader::ParserConfig; + /// + /// let config = ParserConfig::new() + /// .trim_whitespace(true) + /// .ignore_comments(true) + /// .coalesce_characters(false); + /// ``` + pub fn new() -> ParserConfig { + ParserConfig { + trim_whitespace: false, + whitespace_to_characters: false, + cdata_to_characters: false, + ignore_comments: true, + coalesce_characters: true, + extra_entities: HashMap::new(), + ignore_end_of_stream: false + } + } + + /// Creates an XML reader with this configuration. + /// + /// This is a convenience method for configuring and creating a reader at the same time: + /// + /// ```rust + /// use xml::reader::ParserConfig; + /// + /// let mut source: &[u8] = b"..."; + /// + /// let reader = ParserConfig::new() + /// .trim_whitespace(true) + /// .ignore_comments(true) + /// .coalesce_characters(false) + /// .create_reader(&mut source); + /// ``` + /// + /// This method is exactly equivalent to calling `EventReader::new_with_config()` with + /// this configuration object. + #[inline] + pub fn create_reader<R: Read>(self, source: R) -> EventReader<R> { + EventReader::new_with_config(source, self) + } + + /// Adds a new entity mapping and returns an updated config object. + /// + /// This is a convenience method for adding external entities mappings to the XML parser. + /// An example: + /// + /// ```rust + /// use xml::reader::ParserConfig; + /// + /// let mut source: &[u8] = b"..."; + /// + /// let reader = ParserConfig::new() + /// .add_entity("nbsp", " ") + /// .add_entity("copy", "©") + /// .add_entity("reg", "®") + /// .create_reader(&mut source); + /// ``` + pub fn add_entity<S: Into<String>, T: Into<String>>(mut self, entity: S, value: T) -> ParserConfig { + self.extra_entities.insert(entity.into(), value.into()); + self + } +} + +impl Default for ParserConfig { + #[inline] + fn default() -> ParserConfig { + ParserConfig::new() + } +} + +gen_setters! { ParserConfig, + trim_whitespace: val bool, + whitespace_to_characters: val bool, + cdata_to_characters: val bool, + ignore_comments: val bool, + coalesce_characters: val bool, + ignore_end_of_stream: val bool +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/error.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/error.rs new file mode 100644 index 0000000..92378e6 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/error.rs @@ -0,0 +1,121 @@ + +use std::io; +use std::borrow::Cow; +use std::fmt; +use std::error; +use std::str; + +use util; +use common::{Position, TextPosition}; + +#[derive(Debug)] +pub enum ErrorKind { + Syntax(Cow<'static, str>), + Io(io::Error), + Utf8(str::Utf8Error), + UnexpectedEof, +} + +/// An XML parsing error. +/// +/// Consists of a 2D position in a document and a textual message describing the error. +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct Error { + pos: TextPosition, + kind: ErrorKind, +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} {}", self.pos, self.msg()) + } +} + +impl Position for Error { + #[inline] + fn position(&self) -> TextPosition { self.pos } +} + +impl Error { + /// Returns a reference to a message which is contained inside this error. + #[inline] + pub fn msg(&self) -> &str { + use self::ErrorKind::*; + match self.kind { + UnexpectedEof => &"Unexpected EOF", + Utf8(ref reason) => error_description(reason), + Io(ref io_error) => error_description(io_error), + Syntax(ref msg) => msg.as_ref(), + } + } + + pub fn kind(&self) -> &ErrorKind { &self.kind } +} + +impl error::Error for Error { + #[inline] + fn description(&self) -> &str { self.msg() } +} + +impl<'a, P, M> From<(&'a P, M)> for Error where P: Position, M: Into<Cow<'static, str>> { + fn from(orig: (&'a P, M)) -> Self { + Error{ + pos: orig.0.position(), + kind: ErrorKind::Syntax(orig.1.into()) + } + } +} + +impl From<util::CharReadError> for Error { + fn from(e: util::CharReadError) -> Self { + use util::CharReadError::*; + Error{ + pos: TextPosition::new(), + kind: match e { + UnexpectedEof => ErrorKind::UnexpectedEof, + Utf8(reason) => ErrorKind::Utf8(reason), + Io(io_error) => ErrorKind::Io(io_error), + } + } + } +} + +impl From<io::Error> for Error { + fn from(e: io::Error) -> Self { + Error { + pos: TextPosition::new(), + kind: ErrorKind::Io(e), + } + } +} + +impl Clone for ErrorKind { + fn clone(&self) -> Self { + use self::ErrorKind::*; + match *self { + UnexpectedEof => UnexpectedEof, + Utf8(ref reason) => Utf8(reason.clone()), + Io(ref io_error) => Io(io::Error::new(io_error.kind(), error_description(io_error))), + Syntax(ref msg) => Syntax(msg.clone()), + } + } +} +impl PartialEq for ErrorKind { + fn eq(&self, other: &ErrorKind) -> bool { + use self::ErrorKind::*; + match (self, other) { + (&UnexpectedEof, &UnexpectedEof) => true, + (&Utf8(ref left), &Utf8(ref right)) => left == right, + (&Io(ref left), &Io(ref right)) => + left.kind() == right.kind() && + error_description(left) == error_description(right), + (&Syntax(ref left), &Syntax(ref right)) => + left == right, + + (_, _) => false, + } + } +} +impl Eq for ErrorKind {} + +fn error_description(e: &error::Error) -> &str { e.description() } diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/events.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/events.rs new file mode 100644 index 0000000..46d7621 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/events.rs @@ -0,0 +1,219 @@ +//! Contains `XmlEvent` datatype, instances of which are emitted by the parser. + +use std::fmt; +use std::borrow::Cow; + +use name::OwnedName; +use attribute::OwnedAttribute; +use common::XmlVersion; +use namespace::Namespace; + +/// An element of an XML input stream. +/// +/// Items of this enum are emitted by `reader::EventReader`. They correspond to different +/// elements of an XML document. +#[derive(PartialEq, Clone)] +pub enum XmlEvent { + /// Corresponds to XML document declaration. + /// + /// This event is always emitted before any other event. It is emitted + /// even if the actual declaration is not present in the document. + StartDocument { + /// XML version. + /// + /// If XML declaration is not present, defaults to `Version10`. + version: XmlVersion, + + /// XML document encoding. + /// + /// If XML declaration is not present or does not contain `encoding` attribute, + /// defaults to `"UTF-8"`. This field is currently used for no other purpose than + /// informational. + encoding: String, + + /// XML standalone declaration. + /// + /// If XML document is not present or does not contain `standalone` attribute, + /// defaults to `None`. This field is currently used for no other purpose than + /// informational. + standalone: Option<bool> + }, + + /// Denotes to the end of the document stream. + /// + /// This event is always emitted after any other event (except `Error`). After it + /// is emitted for the first time, it will always be emitted on next event pull attempts. + EndDocument, + + /// Denotes an XML processing instruction. + /// + /// This event contains a processing instruction target (`name`) and opaque `data`. It + /// is up to the application to process them. + ProcessingInstruction { + /// Processing instruction target. + name: String, + + /// Processing instruction content. + data: Option<String> + }, + + /// Denotes a beginning of an XML element. + /// + /// This event is emitted after parsing opening tags or after parsing bodiless tags. In the + /// latter case `EndElement` event immediately follows. + StartElement { + /// Qualified name of the element. + name: OwnedName, + + /// A list of attributes associated with the element. + /// + /// Currently attributes are not checked for duplicates (TODO) + attributes: Vec<OwnedAttribute>, + + /// Contents of the namespace mapping at this point of the document. + namespace: Namespace, + }, + + /// Denotes an end of an XML element. + /// + /// This event is emitted after parsing closing tags or after parsing bodiless tags. In the + /// latter case it is emitted immediately after corresponding `StartElement` event. + EndElement { + /// Qualified name of the element. + name: OwnedName + }, + + /// Denotes CDATA content. + /// + /// This event contains unparsed data. No unescaping will be performed. + /// + /// It is possible to configure a parser to emit `Characters` event instead of `CData`. See + /// `pull::ParserConfiguration` structure for more information. + CData(String), + + /// Denotes a comment. + /// + /// It is possible to configure a parser to ignore comments, so this event will never be emitted. + /// See `pull::ParserConfiguration` structure for more information. + Comment(String), + + /// Denotes character data outside of tags. + /// + /// Contents of this event will always be unescaped, so no entities like `<` or `&` or `{` + /// will appear in it. + /// + /// It is possible to configure a parser to trim leading and trailing whitespace for this event. + /// See `pull::ParserConfiguration` structure for more information. + Characters(String), + + /// Denotes a chunk of whitespace outside of tags. + /// + /// It is possible to configure a parser to emit `Characters` event instead of `Whitespace`. + /// See `pull::ParserConfiguration` structure for more information. When combined with whitespace + /// trimming, it will eliminate standalone whitespace from the event stream completely. + Whitespace(String) +} + +impl fmt::Debug for XmlEvent { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + XmlEvent::StartDocument { ref version, ref encoding, ref standalone } => + write!(f, "StartDocument({}, {}, {:?})", version, *encoding, *standalone), + XmlEvent::EndDocument => + write!(f, "EndDocument"), + XmlEvent::ProcessingInstruction { ref name, ref data } => + write!(f, "ProcessingInstruction({}{})", *name, match *data { + Some(ref data) => format!(", {}", data), + None => String::new() + }), + XmlEvent::StartElement { ref name, ref attributes, namespace: Namespace(ref namespace) } => + write!(f, "StartElement({}, {:?}{})", name, namespace, if attributes.is_empty() { + String::new() + } else { + let attributes: Vec<String> = attributes.iter().map( + |a| format!("{} -> {}", a.name, a.value) + ).collect(); + format!(", [{}]", attributes.join(", ")) + }), + XmlEvent::EndElement { ref name } => + write!(f, "EndElement({})", name), + XmlEvent::Comment(ref data) => + write!(f, "Comment({})", data), + XmlEvent::CData(ref data) => + write!(f, "CData({})", data), + XmlEvent::Characters(ref data) => + write!(f, "Characters({})", data), + XmlEvent::Whitespace(ref data) => + write!(f, "Whitespace({})", data) + } + } +} + +impl XmlEvent { + /// Obtains a writer event from this reader event. + /// + /// This method is useful for streaming processing of XML documents where the output + /// is also an XML document. With this method it is possible to process some events + /// while passing other events through to the writer unchanged: + /// + /// ```rust + /// use std::str; + /// + /// use xml::{EventReader, EventWriter}; + /// use xml::reader::XmlEvent as ReaderEvent; + /// use xml::writer::XmlEvent as WriterEvent; + /// + /// let mut input: &[u8] = b"<hello>world</hello>"; + /// let mut output: Vec<u8> = Vec::new(); + /// + /// { + /// let mut reader = EventReader::new(&mut input); + /// let mut writer = EventWriter::new(&mut output); + /// + /// for e in reader { + /// match e.unwrap() { + /// ReaderEvent::Characters(s) => + /// writer.write(WriterEvent::characters(&s.to_uppercase())).unwrap(), + /// e => if let Some(e) = e.as_writer_event() { + /// writer.write(e).unwrap() + /// } + /// } + /// } + /// } + /// + /// assert_eq!( + /// str::from_utf8(&output).unwrap(), + /// r#"<?xml version="1.0" encoding="UTF-8"?><hello>WORLD</hello>"# + /// ); + /// ``` + /// + /// Note that this API may change or get additions in future to improve its ergonomics. + pub fn as_writer_event<'a>(&'a self) -> Option<::writer::events::XmlEvent<'a>> { + match *self { + XmlEvent::StartDocument { version, ref encoding, standalone } => + Some(::writer::events::XmlEvent::StartDocument { + version: version, + encoding: Some(encoding), + standalone: standalone + }), + XmlEvent::ProcessingInstruction { ref name, ref data } => + Some(::writer::events::XmlEvent::ProcessingInstruction { + name: name, + data: data.as_ref().map(|s| &s[..]) + }), + XmlEvent::StartElement { ref name, ref attributes, ref namespace } => + Some(::writer::events::XmlEvent::StartElement { + name: name.borrow(), + attributes: attributes.iter().map(|a| a.borrow()).collect(), + namespace: Cow::Borrowed(namespace) + }), + XmlEvent::EndElement { ref name } => + Some(::writer::events::XmlEvent::EndElement { name: Some(name.borrow()) }), + XmlEvent::Comment(ref data) => Some(::writer::events::XmlEvent::Comment(data)), + XmlEvent::CData(ref data) => Some(::writer::events::XmlEvent::CData(data)), + XmlEvent::Characters(ref data) => Some(::writer::events::XmlEvent::Characters(data)), + XmlEvent::Whitespace(ref data) => Some(::writer::events::XmlEvent::Characters(data)), + _ => None + } + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/lexer.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/lexer.rs new file mode 100644 index 0000000..8e805e2 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/lexer.rs @@ -0,0 +1,844 @@ +//! Contains simple lexer for XML documents. +//! +//! This module is for internal use. Use `xml::pull` module to do parsing. + +use std::fmt; +use std::collections::VecDeque; +use std::io::Read; +use std::result; +use std::borrow::Cow; + +use common::{Position, TextPosition, is_whitespace_char, is_name_char}; +use reader::Error; +use util; + +/// `Token` represents a single lexeme of an XML document. These lexemes +/// are used to perform actual parsing. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub enum Token { + /// `<?` + ProcessingInstructionStart, + /// `?>` + ProcessingInstructionEnd, + /// `<!DOCTYPE + DoctypeStart, + /// `<` + OpeningTagStart, + /// `</` + ClosingTagStart, + /// `>` + TagEnd, + /// `/>` + EmptyTagEnd, + /// `<!--` + CommentStart, + /// `-->` + CommentEnd, + /// A chunk of characters, used for errors recovery. + Chunk(&'static str), + /// Any non-special character except whitespace. + Character(char), + /// Whitespace character. + Whitespace(char), + /// `=` + EqualsSign, + /// `'` + SingleQuote, + /// `"` + DoubleQuote, + /// `<![CDATA[` + CDataStart, + /// `]]>` + CDataEnd, + /// `&` + ReferenceStart, + /// `;` + ReferenceEnd, +} + +impl fmt::Display for Token { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Token::Chunk(s) => write!(f, "{}", s), + Token::Character(c) | Token::Whitespace(c) => write!(f, "{}", c), + other => write!(f, "{}", match other { + Token::OpeningTagStart => "<", + Token::ProcessingInstructionStart => "<?", + Token::DoctypeStart => "<!DOCTYPE", + Token::ClosingTagStart => "</", + Token::CommentStart => "<!--", + Token::CDataStart => "<![CDATA[", + Token::TagEnd => ">", + Token::EmptyTagEnd => "/>", + Token::ProcessingInstructionEnd => "?>", + Token::CommentEnd => "-->", + Token::CDataEnd => "]]>", + Token::ReferenceStart => "&", + Token::ReferenceEnd => ";", + Token::EqualsSign => "=", + Token::SingleQuote => "'", + Token::DoubleQuote => "\"", + _ => unreachable!() + }) + } + } +} + +impl Token { + pub fn as_static_str(&self) -> Option<&'static str> { + match *self { + Token::OpeningTagStart => Some("<"), + Token::ProcessingInstructionStart => Some("<?"), + Token::DoctypeStart => Some("<!DOCTYPE"), + Token::ClosingTagStart => Some("</"), + Token::CommentStart => Some("<!--"), + Token::CDataStart => Some("<![CDATA["), + Token::TagEnd => Some(">"), + Token::EmptyTagEnd => Some("/>"), + Token::ProcessingInstructionEnd => Some("?>"), + Token::CommentEnd => Some("-->"), + Token::CDataEnd => Some("]]>"), + Token::ReferenceStart => Some("&"), + Token::ReferenceEnd => Some(";"), + Token::EqualsSign => Some("="), + Token::SingleQuote => Some("'"), + Token::DoubleQuote => Some("\""), + Token::Chunk(s) => Some(s), + _ => None + } + } + + // using String.push_str(token.to_string()) is simply way too slow + pub fn push_to_string(&self, target: &mut String) { + match self.as_static_str() { + Some(s) => { target.push_str(s); } + None => { + match *self { + Token::Character(c) | Token::Whitespace(c) => target.push(c), + _ => unreachable!() + } + } + } + } + + /// Returns `true` if this token contains data that can be interpreted + /// as a part of the text. Surprisingly, this also means '>' and '=' and '"' and "'" and '-->'. + #[inline] + pub fn contains_char_data(&self) -> bool { + match *self { + Token::Whitespace(_) | Token::Chunk(_) | Token::Character(_) | Token::CommentEnd | + Token::TagEnd | Token::EqualsSign | Token::DoubleQuote | Token::SingleQuote => true, + _ => false + } + } + + /// Returns `true` if this token corresponds to a white space character. + #[inline] + pub fn is_whitespace(&self) -> bool { + match *self { + Token::Whitespace(_) => true, + _ => false + } + } +} + +enum State { + /// Triggered on '<' + TagStarted, + /// Triggered on '<!' + CommentOrCDataOrDoctypeStarted, + /// Triggered on '<!-' + CommentStarted, + /// Triggered on '<!D' up to '<!DOCTYPE' + DoctypeStarted(DoctypeStartedSubstate), + /// Triggered on '<![' up to '<![CDATA' + CDataStarted(CDataStartedSubstate), + /// Triggered on '?' + ProcessingInstructionClosing, + /// Triggered on '/' + EmptyTagClosing, + /// Triggered on '-' up to '--' + CommentClosing(ClosingSubstate), + /// Triggered on ']' up to ']]' + CDataClosing(ClosingSubstate), + /// Default state + Normal +} + +#[derive(Copy, Clone)] +enum ClosingSubstate { + First, Second +} + +#[derive(Copy, Clone)] +enum DoctypeStartedSubstate { + D, DO, DOC, DOCT, DOCTY, DOCTYP +} + +#[derive(Copy, Clone)] +enum CDataStartedSubstate { + E, C, CD, CDA, CDAT, CDATA +} + +/// `Result` represents lexing result. It is either a token or an error message. +pub type Result = result::Result<Option<Token>, Error>; + +/// Helps to set up a dispatch table for lexing large unambigous tokens like +/// `<![CDATA[` or `<!DOCTYPE `. +macro_rules! dispatch_on_enum_state( + ($_self:ident, $s:expr, $c:expr, $is:expr, + $($st:ident; $stc:expr ; $next_st:ident ; $chunk:expr),+; + $end_st:ident ; $end_c:expr ; $end_chunk:expr ; $e:expr) => ( + match $s { + $( + $st => match $c { + $stc => $_self.move_to($is($next_st)), + _ => $_self.handle_error($chunk, $c) + }, + )+ + $end_st => match $c { + $end_c => $e, + _ => $_self.handle_error($end_chunk, $c) + } + } + ) +); + +/// `Lexer` is a lexer for XML documents, which implements pull API. +/// +/// Main method is `next_token` which accepts an `std::io::Read` instance and +/// tries to read the next lexeme from it. +/// +/// When `skip_errors` flag is set, invalid lexemes will be returned as `Chunk`s. +/// When it is not set, errors will be reported as `Err` objects with a string message. +/// By default this flag is not set. Use `enable_errors` and `disable_errors` methods +/// to toggle the behavior. +pub struct Lexer { + pos: TextPosition, + head_pos: TextPosition, + char_queue: VecDeque<char>, + st: State, + skip_errors: bool, + inside_comment: bool, + inside_token: bool, + eof_handled: bool +} + +impl Position for Lexer { + #[inline] + /// Returns the position of the last token produced by the lexer + fn position(&self) -> TextPosition { self.pos } +} + +impl Lexer { + /// Returns a new lexer with default state. + pub fn new() -> Lexer { + Lexer { + pos: TextPosition::new(), + head_pos: TextPosition::new(), + char_queue: VecDeque::with_capacity(4), // TODO: check size + st: State::Normal, + skip_errors: false, + inside_comment: false, + inside_token: false, + eof_handled: false + } + } + + /// Enables error handling so `next_token` will return `Some(Err(..))` + /// upon invalid lexeme. + #[inline] + pub fn enable_errors(&mut self) { self.skip_errors = false; } + + /// Disables error handling so `next_token` will return `Some(Chunk(..))` + /// upon invalid lexeme with this lexeme content. + #[inline] + pub fn disable_errors(&mut self) { self.skip_errors = true; } + + /// Enables special handling of some lexemes which should be done when we're parsing comment + /// internals. + #[inline] + pub fn inside_comment(&mut self) { self.inside_comment = true; } + + /// Disables the effect of `inside_comment()` method. + #[inline] + pub fn outside_comment(&mut self) { self.inside_comment = false; } + + /// Reset the eof handled flag of the lexer. + #[inline] + pub fn reset_eof_handled(&mut self) { self.eof_handled = false; } + + /// Tries to read the next token from the buffer. + /// + /// It is possible to pass different instaces of `BufReader` each time + /// this method is called, but the resulting behavior is undefined in this case. + /// + /// Return value: + /// * `Err(reason) where reason: reader::Error` - when an error occurs; + /// * `Ok(None)` - upon end of stream is reached; + /// * `Ok(Some(token)) where token: Token` - in case a complete-token has been read from the stream. + pub fn next_token<B: Read>(&mut self, b: &mut B) -> Result { + // Already reached end of buffer + if self.eof_handled { + return Ok(None); + } + + if !self.inside_token { + self.pos = self.head_pos; + self.inside_token = true; + } + + // Check if we have saved a char or two for ourselves + while let Some(c) = self.char_queue.pop_front() { + match try!(self.read_next_token(c)) { + Some(t) => { + self.inside_token = false; + return Ok(Some(t)); + } + None => {} // continue + } + } + + loop { + // TODO: this should handle multiple encodings + let c = match try!(util::next_char_from(b)) { + Some(c) => c, // got next char + None => break, // nothing to read left + }; + + match try!(self.read_next_token(c)) { + Some(t) => { + self.inside_token = false; + return Ok(Some(t)); + } + None => { + // continue + } + } + } + + // Handle end of stream + self.eof_handled = true; + self.pos = self.head_pos; + match self.st { + State::TagStarted | State::CommentOrCDataOrDoctypeStarted | + State::CommentStarted | State::CDataStarted(_)| State::DoctypeStarted(_) | + State::CommentClosing(ClosingSubstate::Second) => + Err(self.error("Unexpected end of stream")), + State::ProcessingInstructionClosing => + Ok(Some(Token::Character('?'))), + State::EmptyTagClosing => + Ok(Some(Token::Character('/'))), + State::CommentClosing(ClosingSubstate::First) => + Ok(Some(Token::Character('-'))), + State::CDataClosing(ClosingSubstate::First) => + Ok(Some(Token::Character(']'))), + State::CDataClosing(ClosingSubstate::Second) => + Ok(Some(Token::Chunk("]]"))), + State::Normal => + Ok(None) + } + } + + #[inline] + fn error<M: Into<Cow<'static, str>>>(&self, msg: M) -> Error { + (self, msg).into() + } + + #[inline] + fn read_next_token(&mut self, c: char) -> Result { + let res = self.dispatch_char(c); + if self.char_queue.is_empty() { + if c == '\n' { + self.head_pos.new_line(); + } else { + self.head_pos.advance(1); + } + } + res + } + + fn dispatch_char(&mut self, c: char) -> Result { + match self.st { + State::Normal => self.normal(c), + State::TagStarted => self.tag_opened(c), + State::CommentOrCDataOrDoctypeStarted => self.comment_or_cdata_or_doctype_started(c), + State::CommentStarted => self.comment_started(c), + State::CDataStarted(s) => self.cdata_started(c, s), + State::DoctypeStarted(s) => self.doctype_started(c, s), + State::ProcessingInstructionClosing => self.processing_instruction_closing(c), + State::EmptyTagClosing => self.empty_element_closing(c), + State::CommentClosing(s) => self.comment_closing(c, s), + State::CDataClosing(s) => self.cdata_closing(c, s) + } + } + + #[inline] + fn move_to(&mut self, st: State) -> Result { + self.st = st; + Ok(None) + } + + #[inline] + fn move_to_with(&mut self, st: State, token: Token) -> Result { + self.st = st; + Ok(Some(token)) + } + + #[inline] + fn move_to_with_unread(&mut self, st: State, cs: &[char], token: Token) -> Result { + self.char_queue.extend(cs.iter().cloned()); + self.move_to_with(st, token) + } + + fn handle_error(&mut self, chunk: &'static str, c: char) -> Result { + self.char_queue.push_back(c); + if self.skip_errors || (self.inside_comment && chunk != "--") { // FIXME: looks hacky + self.move_to_with(State::Normal, Token::Chunk(chunk)) + } else { + Err(self.error(format!("Unexpected token '{}' before '{}'", chunk, c))) + } + } + + /// Encountered a char + fn normal(&mut self, c: char) -> Result { + match c { + '<' => self.move_to(State::TagStarted), + '>' => Ok(Some(Token::TagEnd)), + '/' => self.move_to(State::EmptyTagClosing), + '=' => Ok(Some(Token::EqualsSign)), + '"' => Ok(Some(Token::DoubleQuote)), + '\'' => Ok(Some(Token::SingleQuote)), + '?' => self.move_to(State::ProcessingInstructionClosing), + '-' => self.move_to(State::CommentClosing(ClosingSubstate::First)), + ']' => self.move_to(State::CDataClosing(ClosingSubstate::First)), + '&' => Ok(Some(Token::ReferenceStart)), + ';' => Ok(Some(Token::ReferenceEnd)), + _ if is_whitespace_char(c) => Ok(Some(Token::Whitespace(c))), + _ => Ok(Some(Token::Character(c))) + } + } + + /// Encountered '<' + fn tag_opened(&mut self, c: char) -> Result { + match c { + '?' => self.move_to_with(State::Normal, Token::ProcessingInstructionStart), + '/' => self.move_to_with(State::Normal, Token::ClosingTagStart), + '!' => self.move_to(State::CommentOrCDataOrDoctypeStarted), + _ if is_whitespace_char(c) => self.move_to_with_unread(State::Normal, &[c], Token::OpeningTagStart), + _ if is_name_char(c) => self.move_to_with_unread(State::Normal, &[c], Token::OpeningTagStart), + _ => self.handle_error("<", c) + } + } + + /// Encountered '<!' + fn comment_or_cdata_or_doctype_started(&mut self, c: char) -> Result { + match c { + '-' => self.move_to(State::CommentStarted), + '[' => self.move_to(State::CDataStarted(CDataStartedSubstate::E)), + 'D' => self.move_to(State::DoctypeStarted(DoctypeStartedSubstate::D)), + _ => self.handle_error("<!", c) + } + } + + /// Encountered '<!-' + fn comment_started(&mut self, c: char) -> Result { + match c { + '-' => self.move_to_with(State::Normal, Token::CommentStart), + _ => self.handle_error("<!-", c) + } + } + + /// Encountered '<![' + fn cdata_started(&mut self, c: char, s: CDataStartedSubstate) -> Result { + use self::CDataStartedSubstate::{E, C, CD, CDA, CDAT, CDATA}; + dispatch_on_enum_state!(self, s, c, State::CDataStarted, + E ; 'C' ; C ; "<![", + C ; 'D' ; CD ; "<![C", + CD ; 'A' ; CDA ; "<![CD", + CDA ; 'T' ; CDAT ; "<![CDA", + CDAT ; 'A' ; CDATA ; "<![CDAT"; + CDATA ; '[' ; "<![CDATA" ; self.move_to_with(State::Normal, Token::CDataStart) + ) + } + + /// Encountered '<!D' + fn doctype_started(&mut self, c: char, s: DoctypeStartedSubstate) -> Result { + use self::DoctypeStartedSubstate::{D, DO, DOC, DOCT, DOCTY, DOCTYP}; + dispatch_on_enum_state!(self, s, c, State::DoctypeStarted, + D ; 'O' ; DO ; "<!D", + DO ; 'C' ; DOC ; "<!DO", + DOC ; 'T' ; DOCT ; "<!DOC", + DOCT ; 'Y' ; DOCTY ; "<!DOCT", + DOCTY ; 'P' ; DOCTYP ; "<!DOCTY"; + DOCTYP ; 'E' ; "<!DOCTYP" ; self.move_to_with(State::Normal, Token::DoctypeStart) + ) + } + + /// Encountered '?' + fn processing_instruction_closing(&mut self, c: char) -> Result { + match c { + '>' => self.move_to_with(State::Normal, Token::ProcessingInstructionEnd), + _ => self.move_to_with_unread(State::Normal, &[c], Token::Character('?')), + } + } + + /// Encountered '/' + fn empty_element_closing(&mut self, c: char) -> Result { + match c { + '>' => self.move_to_with(State::Normal, Token::EmptyTagEnd), + _ => self.move_to_with_unread(State::Normal, &[c], Token::Character('/')), + } + } + + /// Encountered '-' + fn comment_closing(&mut self, c: char, s: ClosingSubstate) -> Result { + match s { + ClosingSubstate::First => match c { + '-' => self.move_to(State::CommentClosing(ClosingSubstate::Second)), + _ => self.move_to_with_unread(State::Normal, &[c], Token::Character('-')) + }, + ClosingSubstate::Second => match c { + '>' => self.move_to_with(State::Normal, Token::CommentEnd), + // double dash not followed by a greater-than is a hard error inside comment + _ if self.inside_comment => self.handle_error("--", c), + // nothing else except comment closing starts with a double dash, and comment + // closing can never be after another dash, and also we're outside of a comment, + // therefore it is safe to push only the last read character to the list of unread + // characters and pass the double dash directly to the output + _ => self.move_to_with_unread(State::Normal, &[c], Token::Chunk("--")) + } + } + } + + /// Encountered ']' + fn cdata_closing(&mut self, c: char, s: ClosingSubstate) -> Result { + match s { + ClosingSubstate::First => match c { + ']' => self.move_to(State::CDataClosing(ClosingSubstate::Second)), + _ => self.move_to_with_unread(State::Normal, &[c], Token::Character(']')) + }, + ClosingSubstate::Second => match c { + '>' => self.move_to_with(State::Normal, Token::CDataEnd), + _ => self.move_to_with_unread(State::Normal, &[']', c], Token::Character(']')) + } + } + } +} + +#[cfg(test)] +mod tests { + use common::{Position}; + use std::io::{BufReader, Cursor}; + + use super::{Lexer, Token}; + + macro_rules! assert_oks( + (for $lex:ident and $buf:ident ; $($e:expr)+) => ({ + $( + assert_eq!(Ok(Some($e)), $lex.next_token(&mut $buf)); + )+ + }) + ); + + macro_rules! assert_err( + (for $lex:ident and $buf:ident expect row $r:expr ; $c:expr, $s:expr) => ({ + let err = $lex.next_token(&mut $buf); + assert!(err.is_err()); + let err = err.unwrap_err(); + assert_eq!($r as u64, err.position().row); + assert_eq!($c as u64, err.position().column); + assert_eq!($s, err.msg()); + }) + ); + + macro_rules! assert_none( + (for $lex:ident and $buf:ident) => ( + assert_eq!(Ok(None), $lex.next_token(&mut $buf)); + ) + ); + + fn make_lex_and_buf(s: &str) -> (Lexer, BufReader<Cursor<Vec<u8>>>) { + (Lexer::new(), BufReader::new(Cursor::new(s.to_owned().into_bytes()))) + } + + #[test] + fn simple_lexer_test() { + let (mut lex, mut buf) = make_lex_and_buf( + r#"<a p='q'> x<b z="y">d </b></a><p/> <?nm ?> <!-- a c -->  "# + ); + + assert_oks!(for lex and buf ; + Token::OpeningTagStart + Token::Character('a') + Token::Whitespace(' ') + Token::Character('p') + Token::EqualsSign + Token::SingleQuote + Token::Character('q') + Token::SingleQuote + Token::TagEnd + Token::Whitespace(' ') + Token::Character('x') + Token::OpeningTagStart + Token::Character('b') + Token::Whitespace(' ') + Token::Character('z') + Token::EqualsSign + Token::DoubleQuote + Token::Character('y') + Token::DoubleQuote + Token::TagEnd + Token::Character('d') + Token::Whitespace('\t') + Token::ClosingTagStart + Token::Character('b') + Token::TagEnd + Token::ClosingTagStart + Token::Character('a') + Token::TagEnd + Token::OpeningTagStart + Token::Character('p') + Token::EmptyTagEnd + Token::Whitespace(' ') + Token::ProcessingInstructionStart + Token::Character('n') + Token::Character('m') + Token::Whitespace(' ') + Token::ProcessingInstructionEnd + Token::Whitespace(' ') + Token::CommentStart + Token::Whitespace(' ') + Token::Character('a') + Token::Whitespace(' ') + Token::Character('c') + Token::Whitespace(' ') + Token::CommentEnd + Token::Whitespace(' ') + Token::ReferenceStart + Token::Character('n') + Token::Character('b') + Token::Character('s') + Token::Character('p') + Token::ReferenceEnd + ); + assert_none!(for lex and buf); + } + + #[test] + fn special_chars_test() { + let (mut lex, mut buf) = make_lex_and_buf( + r#"?x!+ // -| ]z]]"# + ); + + assert_oks!(for lex and buf ; + Token::Character('?') + Token::Character('x') + Token::Character('!') + Token::Character('+') + Token::Whitespace(' ') + Token::Character('/') + Token::Character('/') + Token::Whitespace(' ') + Token::Character('-') + Token::Character('|') + Token::Whitespace(' ') + Token::Character(']') + Token::Character('z') + Token::Chunk("]]") + ); + assert_none!(for lex and buf); + } + + #[test] + fn cdata_test() { + let (mut lex, mut buf) = make_lex_and_buf( + r#"<a><![CDATA[x y ?]]> </a>"# + ); + + assert_oks!(for lex and buf ; + Token::OpeningTagStart + Token::Character('a') + Token::TagEnd + Token::CDataStart + Token::Character('x') + Token::Whitespace(' ') + Token::Character('y') + Token::Whitespace(' ') + Token::Character('?') + Token::CDataEnd + Token::Whitespace(' ') + Token::ClosingTagStart + Token::Character('a') + Token::TagEnd + ); + assert_none!(for lex and buf); + } + + #[test] + fn doctype_test() { + let (mut lex, mut buf) = make_lex_and_buf( + r#"<a><!DOCTYPE ab xx z> "# + ); + assert_oks!(for lex and buf ; + Token::OpeningTagStart + Token::Character('a') + Token::TagEnd + Token::DoctypeStart + Token::Whitespace(' ') + Token::Character('a') + Token::Character('b') + Token::Whitespace(' ') + Token::Character('x') + Token::Character('x') + Token::Whitespace(' ') + Token::Character('z') + Token::TagEnd + Token::Whitespace(' ') + ); + assert_none!(for lex and buf) + } + + #[test] + fn end_of_stream_handling_ok() { + macro_rules! eof_check( + ($data:expr ; $token:expr) => ({ + let (mut lex, mut buf) = make_lex_and_buf($data); + assert_oks!(for lex and buf ; $token); + assert_none!(for lex and buf); + }) + ); + eof_check!("?" ; Token::Character('?')); + eof_check!("/" ; Token::Character('/')); + eof_check!("-" ; Token::Character('-')); + eof_check!("]" ; Token::Character(']')); + eof_check!("]]" ; Token::Chunk("]]")); + } + + #[test] + fn end_of_stream_handling_error() { + macro_rules! eof_check( + ($data:expr; $r:expr, $c:expr) => ({ + let (mut lex, mut buf) = make_lex_and_buf($data); + assert_err!(for lex and buf expect row $r ; $c, "Unexpected end of stream"); + assert_none!(for lex and buf); + }) + ); + eof_check!("<" ; 0, 1); + eof_check!("<!" ; 0, 2); + eof_check!("<!-" ; 0, 3); + eof_check!("<![" ; 0, 3); + eof_check!("<![C" ; 0, 4); + eof_check!("<![CD" ; 0, 5); + eof_check!("<![CDA" ; 0, 6); + eof_check!("<![CDAT" ; 0, 7); + eof_check!("<![CDATA" ; 0, 8); + eof_check!("--" ; 0, 2); + } + + #[test] + fn error_in_comment_or_cdata_prefix() { + let (mut lex, mut buf) = make_lex_and_buf("<!x"); + assert_err!(for lex and buf expect row 0 ; 0, + "Unexpected token '<!' before 'x'" + ); + + let (mut lex, mut buf) = make_lex_and_buf("<!x"); + lex.disable_errors(); + assert_oks!(for lex and buf ; + Token::Chunk("<!") + Token::Character('x') + ); + assert_none!(for lex and buf); + } + + #[test] + fn error_in_comment_started() { + let (mut lex, mut buf) = make_lex_and_buf("<!-\t"); + assert_err!(for lex and buf expect row 0 ; 0, + "Unexpected token '<!-' before '\t'" + ); + + let (mut lex, mut buf) = make_lex_and_buf("<!-\t"); + lex.disable_errors(); + assert_oks!(for lex and buf ; + Token::Chunk("<!-") + Token::Whitespace('\t') + ); + assert_none!(for lex and buf); + } + + #[test] + fn error_in_comment_two_dashes_not_at_end() { + let (mut lex, mut buf) = make_lex_and_buf("--x"); + lex.inside_comment(); + assert_err!(for lex and buf expect row 0; 0, + "Unexpected token '--' before 'x'" + ); + + let (mut lex, mut buf) = make_lex_and_buf("--x"); + assert_oks!(for lex and buf ; + Token::Chunk("--") + Token::Character('x') + ); + } + + macro_rules! check_case( + ($chunk:expr, $app:expr; $data:expr; $r:expr, $c:expr, $s:expr) => ({ + let (mut lex, mut buf) = make_lex_and_buf($data); + assert_err!(for lex and buf expect row $r ; $c, $s); + + let (mut lex, mut buf) = make_lex_and_buf($data); + lex.disable_errors(); + assert_oks!(for lex and buf ; + Token::Chunk($chunk) + Token::Character($app) + ); + assert_none!(for lex and buf); + }) + ); + + #[test] + fn error_in_cdata_started() { + check_case!("<![", '['; "<![[" ; 0, 0, "Unexpected token '<![' before '['"); + check_case!("<![C", '['; "<![C[" ; 0, 0, "Unexpected token '<![C' before '['"); + check_case!("<![CD", '['; "<![CD[" ; 0, 0, "Unexpected token '<![CD' before '['"); + check_case!("<![CDA", '['; "<![CDA[" ; 0, 0, "Unexpected token '<![CDA' before '['"); + check_case!("<![CDAT", '['; "<![CDAT[" ; 0, 0, "Unexpected token '<![CDAT' before '['"); + check_case!("<![CDATA", '|'; "<![CDATA|" ; 0, 0, "Unexpected token '<![CDATA' before '|'"); + } + + #[test] + fn error_in_doctype_started() { + check_case!("<!D", 'a'; "<!Da" ; 0, 0, "Unexpected token '<!D' before 'a'"); + check_case!("<!DO", 'b'; "<!DOb" ; 0, 0, "Unexpected token '<!DO' before 'b'"); + check_case!("<!DOC", 'c'; "<!DOCc" ; 0, 0, "Unexpected token '<!DOC' before 'c'"); + check_case!("<!DOCT", 'd'; "<!DOCTd" ; 0, 0, "Unexpected token '<!DOCT' before 'd'"); + check_case!("<!DOCTY", 'e'; "<!DOCTYe" ; 0, 0, "Unexpected token '<!DOCTY' before 'e'"); + check_case!("<!DOCTYP", 'f'; "<!DOCTYPf" ; 0, 0, "Unexpected token '<!DOCTYP' before 'f'"); + } + + + + #[test] + fn issue_98_cdata_ending_with_right_bracket() { + let (mut lex, mut buf) = make_lex_and_buf( + r#"<![CDATA[Foo [Bar]]]>"# + ); + + assert_oks!(for lex and buf ; + Token::CDataStart + Token::Character('F') + Token::Character('o') + Token::Character('o') + Token::Whitespace(' ') + Token::Character('[') + Token::Character('B') + Token::Character('a') + Token::Character('r') + Token::Character(']') + Token::CDataEnd + ); + assert_none!(for lex and buf); + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/mod.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/mod.rs new file mode 100644 index 0000000..90f5b52 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/mod.rs @@ -0,0 +1,129 @@ +//! Contains high-level interface for a pull-based XML parser. +//! +//! The most important type in this module is `EventReader`, which provides an iterator +//! view for events in XML document. + +use std::io::{Read}; +use std::result; + +use common::{Position, TextPosition}; + +pub use self::config::ParserConfig; +pub use self::events::XmlEvent; + +use self::parser::PullParser; + +mod lexer; +mod parser; +mod config; +mod events; + +mod error; +pub use self::error::{Error, ErrorKind}; + +/// A result type yielded by `XmlReader`. +pub type Result<T> = result::Result<T, Error>; + +/// A wrapper around an `std::io::Read` instance which provides pull-based XML parsing. +pub struct EventReader<R: Read> { + source: R, + parser: PullParser +} + +impl<R: Read> EventReader<R> { + /// Creates a new reader, consuming the given stream. + #[inline] + pub fn new(source: R) -> EventReader<R> { + EventReader::new_with_config(source, ParserConfig::new()) + } + + /// Creates a new reader with the provded configuration, consuming the given stream. + #[inline] + pub fn new_with_config(source: R, config: ParserConfig) -> EventReader<R> { + EventReader { source: source, parser: PullParser::new(config) } + } + + /// Pulls and returns next XML event from the stream. + /// + /// If returned event is `XmlEvent::Error` or `XmlEvent::EndDocument`, then + /// further calls to this method will return this event again. + #[inline] + pub fn next(&mut self) -> Result<XmlEvent> { + self.parser.next(&mut self.source) + } + + pub fn source(&self) -> &R { &self.source } + pub fn source_mut(&mut self) -> &mut R { &mut self.source } + + /// Unwraps this `EventReader`, returning the underlying reader. + /// + /// Note that this operation is destructive; unwrapping the reader and wrapping it + /// again with `EventReader::new()` will create a fresh reader which will attempt + /// to parse an XML document from the beginning. + pub fn into_inner(self) -> R { + self.source + } +} + +impl<B: Read> Position for EventReader<B> { + /// Returns the position of the last event produced by the reader. + #[inline] + fn position(&self) -> TextPosition { + self.parser.position() + } +} + +impl<R: Read> IntoIterator for EventReader<R> { + type Item = Result<XmlEvent>; + type IntoIter = Events<R>; + + fn into_iter(self) -> Events<R> { + Events { reader: self, finished: false } + } +} + +/// An iterator over XML events created from some type implementing `Read`. +/// +/// When the next event is `xml::event::Error` or `xml::event::EndDocument`, then +/// it will be returned by the iterator once, and then it will stop producing events. +pub struct Events<R: Read> { + reader: EventReader<R>, + finished: bool +} + +impl<R: Read> Events<R> { + /// Unwraps the iterator, returning the internal `EventReader`. + #[inline] + pub fn into_inner(self) -> EventReader<R> { + self.reader + } + + pub fn source(&self) -> &R { &self.reader.source } + pub fn source_mut(&mut self) -> &mut R { &mut self.reader.source } + +} + +impl<R: Read> Iterator for Events<R> { + type Item = Result<XmlEvent>; + + #[inline] + fn next(&mut self) -> Option<Result<XmlEvent>> { + if self.finished && !self.reader.parser.is_ignoring_end_of_stream() { None } + else { + let ev = self.reader.next(); + match ev { + Ok(XmlEvent::EndDocument) | Err(_) => self.finished = true, + _ => {} + } + Some(ev) + } + } +} + +impl<'r> EventReader<&'r [u8]> { + /// A convenience method to create an `XmlReader` from a string slice. + #[inline] + pub fn from_str(source: &'r str) -> EventReader<&'r [u8]> { + EventReader::new(source.as_bytes()) + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_cdata.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_cdata.rs new file mode 100644 index 0000000..3269fb4 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_cdata.rs @@ -0,0 +1,32 @@ +use reader::events::XmlEvent; +use reader::lexer::Token; + +use super::{Result, PullParser, State}; + +impl PullParser { + pub fn inside_cdata(&mut self, t: Token) -> Option<Result> { + match t { + Token::CDataEnd => { + self.lexer.enable_errors(); + let event = if self.config.cdata_to_characters { + None + } else { + let data = self.take_buf(); + Some(Ok(XmlEvent::CData(data))) + }; + self.into_state(State::OutsideTag, event) + } + + Token::Whitespace(_) => { + t.push_to_string(&mut self.buf); + None + } + + _ => { + self.inside_whitespace = false; + t.push_to_string(&mut self.buf); + None + } + } + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_closing_tag_name.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_closing_tag_name.rs new file mode 100644 index 0000000..1d8074a --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_closing_tag_name.rs @@ -0,0 +1,34 @@ +use namespace; + +use reader::lexer::Token; + +use super::{Result, PullParser, State, QualifiedNameTarget, ClosingTagSubstate}; + +impl PullParser { + pub fn inside_closing_tag_name(&mut self, t: Token, s: ClosingTagSubstate) -> Option<Result> { + match s { + ClosingTagSubstate::CTInsideName => self.read_qualified_name(t, QualifiedNameTarget::ClosingTagNameTarget, |this, token, name| { + match name.prefix_ref() { + Some(prefix) if prefix == namespace::NS_XML_PREFIX || + prefix == namespace::NS_XMLNS_PREFIX => + // TODO: {:?} is bad, need something better + Some(self_error!(this; "'{:?}' cannot be an element name prefix", name.prefix)), + _ => { + this.data.element_name = Some(name.clone()); + match token { + Token::Whitespace(_) => this.into_state_continue(State::InsideClosingTag(ClosingTagSubstate::CTAfterName)), + Token::TagEnd => this.emit_end_element(), + _ => Some(self_error!(this; "Unexpected token inside closing tag: {}", token)) + } + } + } + }), + ClosingTagSubstate::CTAfterName => match t { + Token::Whitespace(_) => None, // Skip whitespace + Token::TagEnd => self.emit_end_element(), + _ => Some(self_error!(self; "Unexpected token inside closing tag: {}", t)) + } + } + } + +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_comment.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_comment.rs new file mode 100644 index 0000000..fc98320 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_comment.rs @@ -0,0 +1,32 @@ +use reader::events::XmlEvent; +use reader::lexer::Token; + +use super::{Result, PullParser, State}; + +impl PullParser { + pub fn inside_comment(&mut self, t: Token) -> Option<Result> { + match t { + // Double dash is illegal inside a comment + Token::Chunk(ref s) if &s[..] == "--" => Some(self_error!(self; "Unexpected token inside a comment: --")), + + Token::CommentEnd if self.config.ignore_comments => { + self.lexer.outside_comment(); + self.into_state_continue(State::OutsideTag) + } + + Token::CommentEnd => { + self.lexer.outside_comment(); + let data = self.take_buf(); + self.into_state_emit(State::OutsideTag, Ok(XmlEvent::Comment(data))) + } + + _ if self.config.ignore_comments => None, // Do not modify buffer if ignoring the comment + + _ => { + t.push_to_string(&mut self.buf); + None + } + } + } + +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_declaration.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_declaration.rs new file mode 100644 index 0000000..af39d10 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_declaration.rs @@ -0,0 +1,151 @@ + +use common::XmlVersion; + +use reader::events::XmlEvent; +use reader::lexer::Token; + +use super::{ + Result, PullParser, State, DeclarationSubstate, QualifiedNameTarget, + DEFAULT_VERSION, DEFAULT_ENCODING +}; + +impl PullParser { + // TODO: remove redundancy via macros or extra methods + pub fn inside_declaration(&mut self, t: Token, s: DeclarationSubstate) -> Option<Result> { + macro_rules! unexpected_token( + ($this:expr; $t:expr) => (Some($this.error(format!("Unexpected token inside XML declaration: {}", $t)))); + ($t:expr) => (unexpected_token!(self; $t)); + ); + + #[inline] + fn emit_start_document(this: &mut PullParser) -> Option<Result> { + this.parsed_declaration = true; + let version = this.data.take_version(); + let encoding = this.data.take_encoding(); + let standalone = this.data.take_standalone(); + this.into_state_emit(State::OutsideTag, Ok(XmlEvent::StartDocument { + version: version.unwrap_or(DEFAULT_VERSION), + encoding: encoding.unwrap_or(DEFAULT_ENCODING.into()), + standalone: standalone + })) + } + + match s { + DeclarationSubstate::BeforeVersion => match t { + Token::Whitespace(_) => None, // continue + Token::Character('v') => self.into_state_continue(State::InsideDeclaration(DeclarationSubstate::InsideVersion)), + _ => unexpected_token!(t) + }, + + DeclarationSubstate::InsideVersion => self.read_qualified_name(t, QualifiedNameTarget::AttributeNameTarget, |this, token, name| { + match &name.local_name[..] { + "ersion" if name.namespace.is_none() => + this.into_state_continue(State::InsideDeclaration( + if token == Token::EqualsSign { + DeclarationSubstate::InsideVersionValue + } else { + DeclarationSubstate::AfterVersion + } + )), + _ => unexpected_token!(this; name) + } + }), + + DeclarationSubstate::AfterVersion => match t { + Token::Whitespace(_) => None, + Token::EqualsSign => self.into_state_continue(State::InsideDeclaration(DeclarationSubstate::InsideVersionValue)), + _ => unexpected_token!(t) + }, + + DeclarationSubstate::InsideVersionValue => self.read_attribute_value(t, |this, value| { + this.data.version = match &value[..] { + "1.0" => Some(XmlVersion::Version10), + "1.1" => Some(XmlVersion::Version11), + _ => None + }; + if this.data.version.is_some() { + this.into_state_continue(State::InsideDeclaration(DeclarationSubstate::AfterVersionValue)) + } else { + Some(self_error!(this; "Unexpected XML version value: {}", value)) + } + }), + + DeclarationSubstate::AfterVersionValue => match t { + Token::Whitespace(_) => None, // skip whitespace + Token::Character('e') => self.into_state_continue(State::InsideDeclaration(DeclarationSubstate::InsideEncoding)), + Token::Character('s') => self.into_state_continue(State::InsideDeclaration(DeclarationSubstate::InsideStandaloneDecl)), + Token::ProcessingInstructionEnd => emit_start_document(self), + _ => unexpected_token!(t) + }, + + DeclarationSubstate::InsideEncoding => self.read_qualified_name(t, QualifiedNameTarget::AttributeNameTarget, |this, token, name| { + match &name.local_name[..] { + "ncoding" if name.namespace.is_none() => + this.into_state_continue(State::InsideDeclaration( + if token == Token::EqualsSign { DeclarationSubstate::InsideEncodingValue } else { DeclarationSubstate::AfterEncoding } + )), + _ => unexpected_token!(this; name) + } + }), + + DeclarationSubstate::AfterEncoding => match t { + Token::Whitespace(_) => None, + Token::EqualsSign => self.into_state_continue(State::InsideDeclaration(DeclarationSubstate::InsideEncodingValue)), + _ => unexpected_token!(t) + }, + + DeclarationSubstate::InsideEncodingValue => self.read_attribute_value(t, |this, value| { + this.data.encoding = Some(value); + this.into_state_continue(State::InsideDeclaration(DeclarationSubstate::BeforeStandaloneDecl)) + }), + + DeclarationSubstate::BeforeStandaloneDecl => match t { + Token::Whitespace(_) => None, // skip whitespace + Token::Character('s') => self.into_state_continue(State::InsideDeclaration(DeclarationSubstate::InsideStandaloneDecl)), + Token::ProcessingInstructionEnd => emit_start_document(self), + _ => unexpected_token!(t) + }, + + DeclarationSubstate::InsideStandaloneDecl => self.read_qualified_name(t, QualifiedNameTarget::AttributeNameTarget, |this, token, name| { + match &name.local_name[..] { + "tandalone" if name.namespace.is_none() => + this.into_state_continue(State::InsideDeclaration( + if token == Token::EqualsSign { + DeclarationSubstate::InsideStandaloneDeclValue + } else { + DeclarationSubstate::AfterStandaloneDecl + } + )), + _ => unexpected_token!(this; name) + } + }), + + DeclarationSubstate::AfterStandaloneDecl => match t { + Token::Whitespace(_) => None, + Token::EqualsSign => self.into_state_continue(State::InsideDeclaration(DeclarationSubstate::InsideStandaloneDeclValue)), + _ => unexpected_token!(t) + }, + + DeclarationSubstate::InsideStandaloneDeclValue => self.read_attribute_value(t, |this, value| { + let standalone = match &value[..] { + "yes" => Some(true), + "no" => Some(false), + _ => None + }; + if standalone.is_some() { + this.data.standalone = standalone; + this.into_state_continue(State::InsideDeclaration(DeclarationSubstate::AfterStandaloneDeclValue)) + } else { + Some(self_error!(this; "Invalid standalone declaration value: {}", value)) + } + }), + + DeclarationSubstate::AfterStandaloneDeclValue => match t { + Token::Whitespace(_) => None, // skip whitespace + Token::ProcessingInstructionEnd => emit_start_document(self), + _ => unexpected_token!(t) + } + } + } + +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_doctype.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_doctype.rs new file mode 100644 index 0000000..8dcf367 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_doctype.rs @@ -0,0 +1,16 @@ +use reader::lexer::Token; + +use super::{Result, PullParser, State}; + +impl PullParser { + pub fn inside_doctype(&mut self, t: Token) -> Option<Result> { + match t { + Token::TagEnd => { + self.lexer.enable_errors(); + self.into_state_continue(State::OutsideTag) + } + + _ => None + } + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_opening_tag.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_opening_tag.rs new file mode 100644 index 0000000..533874f --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_opening_tag.rs @@ -0,0 +1,108 @@ +use common::is_name_start_char; +use attribute::OwnedAttribute; +use namespace; + +use reader::lexer::Token; + +use super::{Result, PullParser, State, OpeningTagSubstate, QualifiedNameTarget}; + +impl PullParser { + pub fn inside_opening_tag(&mut self, t: Token, s: OpeningTagSubstate) -> Option<Result> { + macro_rules! unexpected_token(($t:expr) => (Some(self_error!(self; "Unexpected token inside opening tag: {}", $t)))); + match s { + OpeningTagSubstate::InsideName => self.read_qualified_name(t, QualifiedNameTarget::OpeningTagNameTarget, |this, token, name| { + match name.prefix_ref() { + Some(prefix) if prefix == namespace::NS_XML_PREFIX || + prefix == namespace::NS_XMLNS_PREFIX => + Some(self_error!(this; "'{:?}' cannot be an element name prefix", name.prefix)), + _ => { + this.data.element_name = Some(name.clone()); + match token { + Token::TagEnd => this.emit_start_element(false), + Token::EmptyTagEnd => this.emit_start_element(true), + Token::Whitespace(_) => this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideTag)), + _ => unreachable!() + } + } + } + }), + + OpeningTagSubstate::InsideTag => match t { + Token::Whitespace(_) => None, // skip whitespace + Token::Character(c) if is_name_start_char(c) => { + self.buf.push(c); + self.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideAttributeName)) + } + Token::TagEnd => self.emit_start_element(false), + Token::EmptyTagEnd => self.emit_start_element(true), + _ => unexpected_token!(t) + }, + + OpeningTagSubstate::InsideAttributeName => self.read_qualified_name(t, QualifiedNameTarget::AttributeNameTarget, |this, token, name| { + this.data.attr_name = Some(name); + match token { + Token::Whitespace(_) => this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::AfterAttributeName)), + Token::EqualsSign => this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideAttributeValue)), + _ => unreachable!() + } + }), + + OpeningTagSubstate::AfterAttributeName => match t { + Token::Whitespace(_) => None, + Token::EqualsSign => self.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideAttributeValue)), + _ => unexpected_token!(t) + }, + + OpeningTagSubstate::InsideAttributeValue => self.read_attribute_value(t, |this, value| { + let name = this.data.take_attr_name().unwrap(); // unwrap() will always succeed here + + // check that no attribute with such name is already present + // if there is one, XML is not well-formed + if this.data.attributes.iter().find(|a| a.name == name).is_some() { // TODO: looks bad + // TODO: ideally this error should point to the beginning of the attribute, + // TODO: not the end of its value + Some(self_error!(this; "Attribute '{}' is redefined", name)) + } else { + match name.prefix_ref() { + // declaring a new prefix; it is sufficient to check prefix only + // because "xmlns" prefix is reserved + Some(namespace::NS_XMLNS_PREFIX) => { + let ln = &name.local_name[..]; + if ln == namespace::NS_XMLNS_PREFIX { + Some(self_error!(this; "Cannot redefine prefix '{}'", namespace::NS_XMLNS_PREFIX)) + } else if ln == namespace::NS_XML_PREFIX && &value[..] != namespace::NS_XML_URI { + Some(self_error!(this; "Prefix '{}' cannot be rebound to another value", namespace::NS_XML_PREFIX)) + } else if value.is_empty() { + Some(self_error!(this; "Cannot undefine prefix '{}'", ln)) + } else { + this.nst.put(name.local_name.clone(), value); + this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideTag)) + } + } + + // declaring default namespace + None if &name.local_name[..] == namespace::NS_XMLNS_PREFIX => + match &value[..] { + namespace::NS_XMLNS_PREFIX | namespace::NS_XML_PREFIX => + Some(self_error!(this; "Namespace '{}' cannot be default", value)), + _ => { + this.nst.put(namespace::NS_NO_PREFIX, value.clone()); + this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideTag)) + } + }, + + // regular attribute + _ => { + this.data.attributes.push(OwnedAttribute { + name: name.clone(), + value: value + }); + this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideTag)) + } + } + } + }) + } + } + +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_processing_instruction.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_processing_instruction.rs new file mode 100644 index 0000000..8ddf6b8 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_processing_instruction.rs @@ -0,0 +1,96 @@ +use common::{ + is_name_start_char, is_name_char, +}; + +use reader::events::XmlEvent; +use reader::lexer::Token; + +use super::{Result, PullParser, State, ProcessingInstructionSubstate, DeclarationSubstate}; + +impl PullParser { + pub fn inside_processing_instruction(&mut self, t: Token, s: ProcessingInstructionSubstate) -> Option<Result> { + match s { + ProcessingInstructionSubstate::PIInsideName => match t { + Token::Character(c) if !self.buf_has_data() && is_name_start_char(c) || + self.buf_has_data() && is_name_char(c) => self.append_char_continue(c), + + Token::ProcessingInstructionEnd => { + // self.buf contains PI name + let name = self.take_buf(); + + // Don't need to check for declaration because it has mandatory attributes + // but there is none + match &name[..] { + // Name is empty, it is an error + "" => Some(self_error!(self; "Encountered processing instruction without name")), + + // Found <?xml-like PI not at the beginning of a document, + // it is an error - see section 2.6 of XML 1.1 spec + "xml"|"xmL"|"xMl"|"xML"|"Xml"|"XmL"|"XMl"|"XML" => + Some(self_error!(self; "Invalid processing instruction: <?{}", name)), + + // All is ok, emitting event + _ => { + self.into_state_emit( + State::OutsideTag, + Ok(XmlEvent::ProcessingInstruction { + name: name, + data: None + }) + ) + } + } + } + + Token::Whitespace(_) => { + // self.buf contains PI name + let name = self.take_buf(); + + match &name[..] { + // We have not ever encountered an element and have not parsed XML declaration + "xml" if !self.encountered_element && !self.parsed_declaration => + self.into_state_continue(State::InsideDeclaration(DeclarationSubstate::BeforeVersion)), + + // Found <?xml-like PI after the beginning of a document, + // it is an error - see section 2.6 of XML 1.1 spec + "xml"|"xmL"|"xMl"|"xML"|"Xml"|"XmL"|"XMl"|"XML" + if self.encountered_element || self.parsed_declaration => + Some(self_error!(self; "Invalid processing instruction: <?{}", name)), + + // All is ok, starting parsing PI data + _ => { + self.lexer.disable_errors(); // data is arbitrary, so disable errors + self.data.name = name; + self.into_state_continue(State::InsideProcessingInstruction(ProcessingInstructionSubstate::PIInsideData)) + } + + } + } + + _ => Some(self_error!(self; "Unexpected token: <?{}{}", self.buf, t)) + }, + + ProcessingInstructionSubstate::PIInsideData => match t { + Token::ProcessingInstructionEnd => { + self.lexer.enable_errors(); + let name = self.data.take_name(); + let data = self.take_buf(); + self.into_state_emit( + State::OutsideTag, + Ok(XmlEvent::ProcessingInstruction { + name: name, + data: Some(data) + }) + ) + }, + + // Any other token should be treated as plain characters + _ => { + t.push_to_string(&mut self.buf); + None + } + }, + } + } + +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_reference.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_reference.rs new file mode 100644 index 0000000..343393a --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/inside_reference.rs @@ -0,0 +1,74 @@ +use std::char; + +use common::{is_name_start_char, is_name_char, is_whitespace_str}; + +use reader::lexer::Token; + +use super::{Result, PullParser, State}; + +impl PullParser { + pub fn inside_reference(&mut self, t: Token, prev_st: State) -> Option<Result> { + match t { + Token::Character(c) if !self.data.ref_data.is_empty() && is_name_char(c) || + self.data.ref_data.is_empty() && (is_name_start_char(c) || c == '#') => { + self.data.ref_data.push(c); + None + } + + Token::ReferenceEnd => { + // TODO: check for unicode correctness + let name = self.data.take_ref_data(); + let name_len = name.len(); // compute once + let c = match &name[..] { + "lt" => Ok('<'.to_string()), + "gt" => Ok('>'.to_string()), + "amp" => Ok('&'.to_string()), + "apos" => Ok('\''.to_string()), + "quot" => Ok('"'.to_string()), + "" => Err(self_error!(self; "Encountered empty entity")), + _ if name_len > 2 && name.starts_with("#x") => { + let num_str = &name[2..name_len]; + if num_str == "0" { + Err(self_error!(self; "Null character entity is not allowed")) + } else { + match u32::from_str_radix(num_str, 16).ok().and_then(char::from_u32) { + Some(c) => Ok(c.to_string()), + None => Err(self_error!(self; "Invalid hexadecimal character number in an entity: {}", name)) + } + } + } + _ if name_len > 1 && name.starts_with('#') => { + let num_str = &name[1..name_len]; + if num_str == "0" { + Err(self_error!(self; "Null character entity is not allowed")) + } else { + match u32::from_str_radix(num_str, 10).ok().and_then(char::from_u32) { + Some(c) => Ok(c.to_string()), + None => Err(self_error!(self; "Invalid decimal character number in an entity: {}", name)) + } + } + }, + _ => { + if let Some(v) = self.config.extra_entities.get(&name) { + Ok(v.clone()) + } else { + Err(self_error!(self; "Unexpected entity: {}", name)) + } + } + }; + match c { + Ok(c) => { + self.buf.push_str(&c); + if prev_st == State::OutsideTag && !is_whitespace_str(&c) { + self.inside_whitespace = false; + } + self.into_state_continue(prev_st) + } + Err(e) => Some(e) + } + } + + _ => Some(self_error!(self; "Unexpected token inside an entity: {}", t)) + } + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/mod.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/mod.rs new file mode 100644 index 0000000..58ca3a6 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/mod.rs @@ -0,0 +1,622 @@ +//! Contains an implementation of pull-based XML parser. + +use std::mem; +use std::borrow::Cow; +use std::io::prelude::*; + +use common::{ + self, + XmlVersion, Position, TextPosition, + is_name_start_char, is_name_char, +}; +use name::OwnedName; +use attribute::OwnedAttribute; +use namespace::NamespaceStack; + +use reader::events::XmlEvent; +use reader::config::ParserConfig; +use reader::lexer::{Lexer, Token}; + +macro_rules! gen_takes( + ($($field:ident -> $method:ident, $t:ty, $def:expr);+) => ( + $( + impl MarkupData { + #[inline] + fn $method(&mut self) -> $t { + mem::replace(&mut self.$field, $def) + } + } + )+ + ) +); + +gen_takes!( + name -> take_name, String, String::new(); + ref_data -> take_ref_data, String, String::new(); + + version -> take_version, Option<common::XmlVersion>, None; + encoding -> take_encoding, Option<String>, None; + standalone -> take_standalone, Option<bool>, None; + + element_name -> take_element_name, Option<OwnedName>, None; + + attr_name -> take_attr_name, Option<OwnedName>, None; + attributes -> take_attributes, Vec<OwnedAttribute>, vec!() +); + +macro_rules! self_error( + ($this:ident; $msg:expr) => ($this.error($msg)); + ($this:ident; $fmt:expr, $($arg:expr),+) => ($this.error(format!($fmt, $($arg),+))) +); + +mod outside_tag; +mod inside_processing_instruction; +mod inside_declaration; +mod inside_doctype; +mod inside_opening_tag; +mod inside_closing_tag_name; +mod inside_comment; +mod inside_cdata; +mod inside_reference; + +static DEFAULT_VERSION: XmlVersion = XmlVersion::Version10; +static DEFAULT_ENCODING: &'static str = "UTF-8"; +static DEFAULT_STANDALONE: Option<bool> = None; + +type ElementStack = Vec<OwnedName>; +pub type Result = super::Result<XmlEvent>; + +/// Pull-based XML parser. +pub struct PullParser { + config: ParserConfig, + lexer: Lexer, + st: State, + buf: String, + nst: NamespaceStack, + + data: MarkupData, + final_result: Option<Result>, + next_event: Option<Result>, + est: ElementStack, + pos: Vec<TextPosition>, + + encountered_element: bool, + parsed_declaration: bool, + inside_whitespace: bool, + read_prefix_separator: bool, + pop_namespace: bool +} + +impl PullParser { + /// Returns a new parser using the given config. + pub fn new(config: ParserConfig) -> PullParser { + PullParser { + config: config, + lexer: Lexer::new(), + st: State::OutsideTag, + buf: String::new(), + nst: NamespaceStack::default(), + + data: MarkupData { + name: String::new(), + version: None, + encoding: None, + standalone: None, + ref_data: String::new(), + element_name: None, + quote: None, + attr_name: None, + attributes: Vec::new() + }, + final_result: None, + next_event: None, + est: Vec::new(), + pos: vec![TextPosition::new()], + + encountered_element: false, + parsed_declaration: false, + inside_whitespace: true, + read_prefix_separator: false, + pop_namespace: false + } + } + + /// Checks if this parser ignores the end of stream errors. + pub fn is_ignoring_end_of_stream(&self) -> bool { self.config.ignore_end_of_stream } +} + +impl Position for PullParser { + /// Returns the position of the last event produced by the parser + #[inline] + fn position(&self) -> TextPosition { + self.pos[0] + } +} + +#[derive(Clone, PartialEq)] +pub enum State { + OutsideTag, + InsideOpeningTag(OpeningTagSubstate), + InsideClosingTag(ClosingTagSubstate), + InsideProcessingInstruction(ProcessingInstructionSubstate), + InsideComment, + InsideCData, + InsideDeclaration(DeclarationSubstate), + InsideDoctype, + InsideReference(Box<State>) +} + +#[derive(Clone, PartialEq)] +pub enum OpeningTagSubstate { + InsideName, + + InsideTag, + + InsideAttributeName, + AfterAttributeName, + + InsideAttributeValue, +} + +#[derive(Clone, PartialEq)] +pub enum ClosingTagSubstate { + CTInsideName, + CTAfterName +} + +#[derive(Clone, PartialEq)] +pub enum ProcessingInstructionSubstate { + PIInsideName, + PIInsideData +} + +#[derive(Clone, PartialEq)] +pub enum DeclarationSubstate { + BeforeVersion, + InsideVersion, + AfterVersion, + + InsideVersionValue, + AfterVersionValue, + + InsideEncoding, + AfterEncoding, + + InsideEncodingValue, + + BeforeStandaloneDecl, + InsideStandaloneDecl, + AfterStandaloneDecl, + + InsideStandaloneDeclValue, + AfterStandaloneDeclValue +} + +#[derive(PartialEq)] +enum QualifiedNameTarget { + AttributeNameTarget, + OpeningTagNameTarget, + ClosingTagNameTarget +} + +#[derive(Copy, Clone, PartialEq, Eq)] +enum QuoteToken { + SingleQuoteToken, + DoubleQuoteToken +} + +impl QuoteToken { + fn from_token(t: &Token) -> QuoteToken { + match *t { + Token::SingleQuote => QuoteToken::SingleQuoteToken, + Token::DoubleQuote => QuoteToken::DoubleQuoteToken, + _ => panic!("Unexpected token: {}", t) + } + } + + fn as_token(self) -> Token { + match self { + QuoteToken::SingleQuoteToken => Token::SingleQuote, + QuoteToken::DoubleQuoteToken => Token::DoubleQuote + } + } +} + +struct MarkupData { + name: String, // used for processing instruction name + ref_data: String, // used for reference content + + version: Option<common::XmlVersion>, // used for XML declaration version + encoding: Option<String>, // used for XML declaration encoding + standalone: Option<bool>, // used for XML declaration standalone parameter + + element_name: Option<OwnedName>, // used for element name + + quote: Option<QuoteToken>, // used to hold opening quote for attribute value + attr_name: Option<OwnedName>, // used to hold attribute name + attributes: Vec<OwnedAttribute> // used to hold all accumulated attributes +} + +impl PullParser { + /// Returns next event read from the given buffer. + /// + /// This method should be always called with the same buffer. If you call it + /// providing different buffers each time, the result will be undefined. + pub fn next<R: Read>(&mut self, r: &mut R) -> Result { + if let Some(ref ev) = self.final_result { + return ev.clone(); + } + + if let Some(ev) = self.next_event.take() { + return ev; + } + + if self.pop_namespace { + self.pop_namespace = false; + self.nst.pop(); + } + + loop { + // While lexer gives us Ok(maybe_token) -- we loop. + // Upon having a complete XML-event -- we return from the whole function. + match self.lexer.next_token(r) { + Ok(maybe_token) => + match maybe_token { + None => break, + Some(token) => + match self.dispatch_token(token) { + None => {} // continue + Some(Ok(XmlEvent::EndDocument)) => + return { + self.next_pos(); + self.set_final_result(Ok(XmlEvent::EndDocument)) + }, + Some(Ok(xml_event)) => + return { + self.next_pos(); + Ok(xml_event) + }, + Some(Err(xml_error)) => + return { + self.next_pos(); + self.set_final_result(Err(xml_error)) + }, + } + }, + Err(lexer_error) => + return self.set_final_result(Err(lexer_error)), + } + } + + // Handle end of stream + // Forward pos to the lexer head + self.next_pos(); + let ev = if self.depth() == 0 { + if self.encountered_element && self.st == State::OutsideTag { // all is ok + Ok(XmlEvent::EndDocument) + } else if !self.encountered_element { + self_error!(self; "Unexpected end of stream: no root element found") + } else { // self.st != State::OutsideTag + self_error!(self; "Unexpected end of stream") // TODO: add expected hint? + } + } else { + if self.config.ignore_end_of_stream { + self.final_result = None; + self.lexer.reset_eof_handled(); + return self_error!(self; "Unexpected end of stream: still inside the root element"); + } else { + self_error!(self; "Unexpected end of stream: still inside the root element") + } + }; + self.set_final_result(ev) + } + + // This function is to be called when a terminal event is reached. + // The function sets up the `self.final_result` into `Some(result)` and return `result`. + fn set_final_result(&mut self, result: Result) -> Result { + self.final_result = Some(result.clone()); + result + } + + #[inline] + fn error<M: Into<Cow<'static, str>>>(&self, msg: M) -> Result { + Err((&self.lexer, msg).into()) + } + + #[inline] + fn next_pos(&mut self) { + if self.pos.len() > 1 { + self.pos.remove(0); + } else { + self.pos[0] = self.lexer.position(); + } + } + + #[inline] + fn push_pos(&mut self) { + self.pos.push(self.lexer.position()); + } + + fn dispatch_token(&mut self, t: Token) -> Option<Result> { + match self.st.clone() { + State::OutsideTag => self.outside_tag(t), + State::InsideProcessingInstruction(s) => self.inside_processing_instruction(t, s), + State::InsideDeclaration(s) => self.inside_declaration(t, s), + State::InsideDoctype => self.inside_doctype(t), + State::InsideOpeningTag(s) => self.inside_opening_tag(t, s), + State::InsideClosingTag(s) => self.inside_closing_tag_name(t, s), + State::InsideComment => self.inside_comment(t), + State::InsideCData => self.inside_cdata(t), + State::InsideReference(s) => self.inside_reference(t, *s) + } + } + + #[inline] + fn depth(&self) -> usize { + self.est.len() + } + + #[inline] + fn buf_has_data(&self) -> bool { + self.buf.len() > 0 + } + + #[inline] + fn take_buf(&mut self) -> String { + mem::replace(&mut self.buf, String::new()) + } + + #[inline] + fn append_char_continue(&mut self, c: char) -> Option<Result> { + self.buf.push(c); + None + } + + #[inline] + fn into_state(&mut self, st: State, ev: Option<Result>) -> Option<Result> { + self.st = st; + ev + } + + #[inline] + fn into_state_continue(&mut self, st: State) -> Option<Result> { + self.into_state(st, None) + } + + #[inline] + fn into_state_emit(&mut self, st: State, ev: Result) -> Option<Result> { + self.into_state(st, Some(ev)) + } + + /// Dispatches tokens in order to process qualified name. If qualified name cannot be parsed, + /// an error is returned. + /// + /// # Parameters + /// * `t` --- next token; + /// * `on_name` --- a callback which is executed when whitespace is encountered. + fn read_qualified_name<F>(&mut self, t: Token, target: QualifiedNameTarget, on_name: F) -> Option<Result> + where F: Fn(&mut PullParser, Token, OwnedName) -> Option<Result> { + // We can get here for the first time only when self.data.name contains zero or one character, + // but first character cannot be a colon anyway + if self.buf.len() <= 1 { + self.read_prefix_separator = false; + } + + let invoke_callback = |this: &mut PullParser, t| { + let name = this.take_buf(); + match name.parse() { + Ok(name) => on_name(this, t, name), + Err(_) => Some(self_error!(this; "Qualified name is invalid: {}", name)) + } + }; + + match t { + // There can be only one colon, and not as the first character + Token::Character(':') if self.buf_has_data() && !self.read_prefix_separator => { + self.buf.push(':'); + self.read_prefix_separator = true; + None + } + + Token::Character(c) if c != ':' && (!self.buf_has_data() && is_name_start_char(c) || + self.buf_has_data() && is_name_char(c)) => + self.append_char_continue(c), + + Token::EqualsSign if target == QualifiedNameTarget::AttributeNameTarget => invoke_callback(self, t), + + Token::EmptyTagEnd if target == QualifiedNameTarget::OpeningTagNameTarget => invoke_callback(self, t), + + Token::TagEnd if target == QualifiedNameTarget::OpeningTagNameTarget || + target == QualifiedNameTarget::ClosingTagNameTarget => invoke_callback(self, t), + + Token::Whitespace(_) => invoke_callback(self, t), + + _ => Some(self_error!(self; "Unexpected token inside qualified name: {}", t)) + } + } + + /// Dispatches tokens in order to process attribute value. + /// + /// # Parameters + /// * `t` --- next token; + /// * `on_value` --- a callback which is called when terminating quote is encountered. + fn read_attribute_value<F>(&mut self, t: Token, on_value: F) -> Option<Result> + where F: Fn(&mut PullParser, String) -> Option<Result> { + match t { + Token::Whitespace(_) if self.data.quote.is_none() => None, // skip leading whitespace + + Token::DoubleQuote | Token::SingleQuote => match self.data.quote { + None => { // Entered attribute value + self.data.quote = Some(QuoteToken::from_token(&t)); + None + } + Some(q) if q.as_token() == t => { + self.data.quote = None; + let value = self.take_buf(); + on_value(self, value) + } + _ => { + t.push_to_string(&mut self.buf); + None + } + }, + + Token::ReferenceStart => { + let st = Box::new(self.st.clone()); + self.into_state_continue(State::InsideReference(st)) + } + + Token::OpeningTagStart => + Some(self_error!(self; "Unexpected token inside attribute value: <")), + + // Every character except " and ' and < is okay + _ => { + t.push_to_string(&mut self.buf); + None + } + } + } + + fn emit_start_element(&mut self, emit_end_element: bool) -> Option<Result> { + let mut name = self.data.take_element_name().unwrap(); + let mut attributes = self.data.take_attributes(); + + // check whether the name prefix is bound and fix its namespace + match self.nst.get(name.borrow().prefix_repr()) { + Some("") => name.namespace = None, // default namespace + Some(ns) => name.namespace = Some(ns.into()), + None => return Some(self_error!(self; "Element {} prefix is unbound", name)) + } + + // check and fix accumulated attributes prefixes + for attr in attributes.iter_mut() { + if let Some(ref pfx) = attr.name.prefix { + let new_ns = match self.nst.get(pfx) { + Some("") => None, // default namespace + Some(ns) => Some(ns.into()), + None => return Some(self_error!(self; "Attribute {} prefix is unbound", attr.name)) + }; + attr.name.namespace = new_ns; + } + } + + if emit_end_element { + self.pop_namespace = true; + self.next_event = Some(Ok(XmlEvent::EndElement { + name: name.clone() + })); + } else { + self.est.push(name.clone()); + } + let namespace = self.nst.squash(); + self.into_state_emit(State::OutsideTag, Ok(XmlEvent::StartElement { + name: name, + attributes: attributes, + namespace: namespace + })) + } + + fn emit_end_element(&mut self) -> Option<Result> { + let mut name = self.data.take_element_name().unwrap(); + + // check whether the name prefix is bound and fix its namespace + match self.nst.get(name.borrow().prefix_repr()) { + Some("") => name.namespace = None, // default namespace + Some(ns) => name.namespace = Some(ns.into()), + None => return Some(self_error!(self; "Element {} prefix is unbound", name)) + } + + let op_name = self.est.pop().unwrap(); + + if name == op_name { + self.pop_namespace = true; + self.into_state_emit(State::OutsideTag, Ok(XmlEvent::EndElement { name: name })) + } else { + Some(self_error!(self; "Unexpected closing tag: {}, expected {}", name, op_name)) + } + } + +} + +#[cfg(test)] +mod tests { + use std::io::BufReader; + + use common::{Position, TextPosition}; + use name::OwnedName; + use attribute::OwnedAttribute; + use reader::parser::PullParser; + use reader::ParserConfig; + use reader::events::XmlEvent; + + fn new_parser() -> PullParser { + PullParser::new(ParserConfig::new()) + } + + macro_rules! expect_event( + ($r:expr, $p:expr, $t:pat) => ( + match $p.next(&mut $r) { + $t => {} + e => panic!("Unexpected event: {:?}", e) + } + ); + ($r:expr, $p:expr, $t:pat => $c:expr ) => ( + match $p.next(&mut $r) { + $t if $c => {} + e => panic!("Unexpected event: {:?}", e) + } + ) + ); + + macro_rules! test_data( + ($d:expr) => ({ + static DATA: &'static str = $d; + let r = BufReader::new(DATA.as_bytes()); + let p = new_parser(); + (r, p) + }) + ); + + #[test] + fn issue_3_semicolon_in_attribute_value() { + let (mut r, mut p) = test_data!(r#" + <a attr="zzz;zzz" /> + "#); + + expect_event!(r, p, Ok(XmlEvent::StartDocument { .. })); + expect_event!(r, p, Ok(XmlEvent::StartElement { ref name, ref attributes, ref namespace }) => + *name == OwnedName::local("a") && + attributes.len() == 1 && + attributes[0] == OwnedAttribute::new(OwnedName::local("attr"), "zzz;zzz") && + namespace.is_essentially_empty() + ); + expect_event!(r, p, Ok(XmlEvent::EndElement { ref name }) => *name == OwnedName::local("a")); + expect_event!(r, p, Ok(XmlEvent::EndDocument)); + } + + #[test] + fn issue_140_entity_reference_inside_tag() { + let (mut r, mut p) = test_data!(r#" + <bla>♫</bla> + "#); + + expect_event!(r, p, Ok(XmlEvent::StartDocument { .. })); + expect_event!(r, p, Ok(XmlEvent::StartElement { ref name, .. }) => *name == OwnedName::local("bla")); + expect_event!(r, p, Ok(XmlEvent::Characters(ref s)) => s == "\u{266b}"); + expect_event!(r, p, Ok(XmlEvent::EndElement { ref name, .. }) => *name == OwnedName::local("bla")); + expect_event!(r, p, Ok(XmlEvent::EndDocument)); + } + + #[test] + fn opening_tag_in_attribute_value() { + let (mut r, mut p) = test_data!(r#" + <a attr="zzz<zzz" /> + "#); + + expect_event!(r, p, Ok(XmlEvent::StartDocument { .. })); + expect_event!(r, p, Err(ref e) => + e.msg() == "Unexpected token inside attribute value: <" && + e.position() == TextPosition { row: 1, column: 24 } + ); + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/outside_tag.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/outside_tag.rs new file mode 100644 index 0000000..8ddc515 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/reader/parser/outside_tag.rs @@ -0,0 +1,130 @@ +use common::is_whitespace_char; + +use reader::events::XmlEvent; +use reader::lexer::Token; + +use super::{ + Result, PullParser, State, ClosingTagSubstate, OpeningTagSubstate, + ProcessingInstructionSubstate, DEFAULT_VERSION, DEFAULT_ENCODING, DEFAULT_STANDALONE +}; + +impl PullParser { + pub fn outside_tag(&mut self, t: Token) -> Option<Result> { + match t { + Token::ReferenceStart => + self.into_state_continue(State::InsideReference(Box::new(State::OutsideTag))), + + Token::Whitespace(_) if self.depth() == 0 => None, // skip whitespace outside of the root element + + _ if t.contains_char_data() && self.depth() == 0 => + Some(self_error!(self; "Unexpected characters outside the root element: {}", t)), + + Token::Whitespace(_) if self.config.trim_whitespace && !self.buf_has_data() => None, + + Token::Whitespace(c) => { + if !self.buf_has_data() { + self.push_pos(); + } + self.append_char_continue(c) + } + + _ if t.contains_char_data() => { // Non-whitespace char data + if !self.buf_has_data() { + self.push_pos(); + } + self.inside_whitespace = false; + t.push_to_string(&mut self.buf); + None + } + + Token::ReferenceEnd => { // Semi-colon in a text outside an entity + self.inside_whitespace = false; + Token::ReferenceEnd.push_to_string(&mut self.buf); + None + } + + Token::CommentStart if self.config.coalesce_characters && self.config.ignore_comments => { + // We need to switch the lexer into a comment mode inside comments + self.lexer.inside_comment(); + self.into_state_continue(State::InsideComment) + } + + Token::CDataStart if self.config.coalesce_characters && self.config.cdata_to_characters => { + if !self.buf_has_data() { + self.push_pos(); + } + // We need to disable lexing errors inside CDATA + self.lexer.disable_errors(); + self.into_state_continue(State::InsideCData) + } + + _ => { + // Encountered some markup event, flush the buffer as characters + // or a whitespace + let mut next_event = if self.buf_has_data() { + let buf = self.take_buf(); + if self.inside_whitespace && self.config.trim_whitespace { + None + } else if self.inside_whitespace && !self.config.whitespace_to_characters { + Some(Ok(XmlEvent::Whitespace(buf))) + } else if self.config.trim_whitespace { + Some(Ok(XmlEvent::Characters(buf.trim_matches(is_whitespace_char).into()))) + } else { + Some(Ok(XmlEvent::Characters(buf))) + } + } else { None }; + self.inside_whitespace = true; // Reset inside_whitespace flag + self.push_pos(); + match t { + Token::ProcessingInstructionStart => + self.into_state(State::InsideProcessingInstruction(ProcessingInstructionSubstate::PIInsideName), next_event), + + Token::DoctypeStart if !self.encountered_element => { + // We don't have a doctype event so skip this position + // FIXME: update when we have a doctype event + self.next_pos(); + self.lexer.disable_errors(); + self.into_state(State::InsideDoctype, next_event) + } + + Token::OpeningTagStart => { + // If declaration was not parsed and we have encountered an element, + // emit this declaration as the next event. + if !self.parsed_declaration { + self.parsed_declaration = true; + let sd_event = XmlEvent::StartDocument { + version: DEFAULT_VERSION, + encoding: DEFAULT_ENCODING.into(), + standalone: DEFAULT_STANDALONE + }; + // next_event is always none here because we're outside of + // the root element + next_event = Some(Ok(sd_event)); + self.push_pos(); + } + self.encountered_element = true; + self.nst.push_empty(); + self.into_state(State::InsideOpeningTag(OpeningTagSubstate::InsideName), next_event) + } + + Token::ClosingTagStart if self.depth() > 0 => + self.into_state(State::InsideClosingTag(ClosingTagSubstate::CTInsideName), next_event), + + Token::CommentStart => { + // We need to switch the lexer into a comment mode inside comments + self.lexer.inside_comment(); + self.into_state(State::InsideComment, next_event) + } + + Token::CDataStart => { + // We need to disable lexing errors inside CDATA + self.lexer.disable_errors(); + self.into_state(State::InsideCData, next_event) + } + + _ => Some(self_error!(self; "Unexpected token: {}", t)) + } + } + } + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/util.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/util.rs new file mode 100644 index 0000000..23fee04 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/util.rs @@ -0,0 +1,107 @@ +use std::io::{self, Read}; +use std::str; +use std::fmt; + +#[derive(Debug)] +pub enum CharReadError { + UnexpectedEof, + Utf8(str::Utf8Error), + Io(io::Error) +} + +impl From<str::Utf8Error> for CharReadError { + fn from(e: str::Utf8Error) -> CharReadError { + CharReadError::Utf8(e) + } +} + +impl From<io::Error> for CharReadError { + fn from(e: io::Error) -> CharReadError { + CharReadError::Io(e) + } +} + +impl fmt::Display for CharReadError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use self::CharReadError::*; + match *self { + UnexpectedEof => write!(f, "unexpected end of stream"), + Utf8(ref e) => write!(f, "UTF-8 decoding error: {}", e), + Io(ref e) => write!(f, "I/O error: {}", e) + } + } +} + +pub fn next_char_from<R: Read>(source: &mut R) -> Result<Option<char>, CharReadError> { + const MAX_CODEPOINT_LEN: usize = 4; + + let mut bytes = source.bytes(); + let mut buf = [0u8; MAX_CODEPOINT_LEN]; + let mut pos = 0; + + loop { + let next = match bytes.next() { + Some(Ok(b)) => b, + Some(Err(e)) => return Err(e.into()), + None if pos == 0 => return Ok(None), + None => return Err(CharReadError::UnexpectedEof) + }; + buf[pos] = next; + pos += 1; + + match str::from_utf8(&buf[..pos]) { + Ok(s) => return Ok(s.chars().next()), // always Some(..) + Err(_) if pos < MAX_CODEPOINT_LEN => {}, + Err(e) => return Err(e.into()) + } + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_next_char_from() { + use std::io; + use std::error::Error; + + let mut bytes: &[u8] = "correct".as_bytes(); // correct ASCII + assert_eq!(super::next_char_from(&mut bytes).unwrap(), Some('c')); + + let mut bytes: &[u8] = "правильно".as_bytes(); // correct BMP + assert_eq!(super::next_char_from(&mut bytes).unwrap(), Some('п')); + + let mut bytes: &[u8] = "😊".as_bytes(); // correct non-BMP + assert_eq!(super::next_char_from(&mut bytes).unwrap(), Some('😊')); + + let mut bytes: &[u8] = b""; // empty + assert_eq!(super::next_char_from(&mut bytes).unwrap(), None); + + let mut bytes: &[u8] = b"\xf0\x9f\x98"; // incomplete code point + match super::next_char_from(&mut bytes).unwrap_err() { + super::CharReadError::UnexpectedEof => {}, + e => panic!("Unexpected result: {:?}", e) + }; + + let mut bytes: &[u8] = b"\xff\x9f\x98\x32"; // invalid code point + match super::next_char_from(&mut bytes).unwrap_err() { + super::CharReadError::Utf8(_) => {}, + e => panic!("Unexpected result: {:?}", e) + }; + + + // error during read + struct ErrorReader; + impl io::Read for ErrorReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { + Err(io::Error::new(io::ErrorKind::Other, "test error")) + } + } + + let mut r = ErrorReader; + match super::next_char_from(&mut r).unwrap_err() { + super::CharReadError::Io(ref e) if e.kind() == io::ErrorKind::Other && + e.description() == "test error" => {}, + e => panic!("Unexpected result: {:?}", e) + } + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/config.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/config.rs new file mode 100644 index 0000000..c3bcf2f --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/config.rs @@ -0,0 +1,146 @@ +//! Contains emitter configuration structure. + +use std::io::Write; +use std::borrow::Cow; + +use writer::EventWriter; + +/// Emitter configuration structure. +/// +/// This structure contains various options which control XML document emitter behavior. +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct EmitterConfig { + /// Line separator used to separate lines in formatted output. Default is `"\n"`. + pub line_separator: Cow<'static, str>, + + /// A string which will be used for a single level of indentation. Default is `" "` + /// (two spaces). + pub indent_string: Cow<'static, str>, + + /// Whether or not the emitted document should be indented. Default is false. + /// + /// The emitter is capable to perform automatic indentation of the emitted XML document. + /// It is done in stream-like fashion and does not require the knowledge of the whole + /// document in advance. + /// + /// Sometimes, however, automatic indentation is undesirable, e.g. when you want to keep + /// existing layout when processing an existing XML document. Also the indentiation algorithm + /// is not thoroughly tested. Hence by default it is disabled. + pub perform_indent: bool, + + /// Whether or not characters in output events will be escaped. Default is true. + /// + /// The emitter can automatically escape characters which can't appear in PCDATA sections + /// or element attributes of an XML document, like `<` or `"` (in attributes). This may + /// introduce some overhead because then every corresponding piece of character data + /// should be scanned for invalid characters. + /// + /// If this option is disabled, the XML writer may produce non-well-formed documents, so + /// use `false` value for this option with care. + pub perform_escaping: bool, + + /// Whether or not to write XML document declaration at the beginning of a document. + /// Default is true. + /// + /// This option controls whether the document declaration should be emitted automatically + /// before a root element is written if it was not emitted explicitly by the user. + pub write_document_declaration: bool, + + /// Whether or not to convert elements with empty content to empty elements. Default is true. + /// + /// This option allows turning elements like `<a></a>` (an element with empty content) + /// into `<a />` (an empty element). + pub normalize_empty_elements: bool, + + /// Whether or not to emit CDATA events as plain characters. Default is false. + /// + /// This option forces the emitter to convert CDATA events into regular character events, + /// performing all the necessary escaping beforehand. This may be occasionally useful + /// for feeding the document into incorrect parsers which do not support CDATA. + pub cdata_to_characters: bool, + + /// Whether or not to keep element names to support `EndElement` events without explicit names. + /// Default is true. + /// + /// This option makes the emitter to keep names of written elements in order to allow + /// omitting names when writing closing element tags. This could incur some memory overhead. + pub keep_element_names_stack: bool, + + /// Whether or not to automatically insert leading and trailing spaces in emitted comments, + /// if necessary. Default is true. + /// + /// This is a convenience option in order for the user not to append spaces before and after + /// comments text in order to get more pretty comments: `<!-- something -->` instead of + /// `<!--something-->`. + pub autopad_comments: bool, +} + +impl EmitterConfig { + /// Creates an emitter configuration with default values. + /// + /// You can tweak default options with builder-like pattern: + /// + /// ```rust + /// use xml::writer::EmitterConfig; + /// + /// let config = EmitterConfig::new() + /// .line_separator("\r\n") + /// .perform_indent(true) + /// .normalize_empty_elements(false); + /// ``` + #[inline] + pub fn new() -> EmitterConfig { + EmitterConfig { + line_separator: "\n".into(), + indent_string: " ".into(), // two spaces + perform_indent: false, + perform_escaping: true, + write_document_declaration: true, + normalize_empty_elements: true, + cdata_to_characters: false, + keep_element_names_stack: true, + autopad_comments: true + } + } + + /// Creates an XML writer with this configuration. + /// + /// This is a convenience method for configuring and creating a writer at the same time: + /// + /// ```rust + /// use xml::writer::EmitterConfig; + /// + /// let mut target: Vec<u8> = Vec::new(); + /// + /// let writer = EmitterConfig::new() + /// .line_separator("\r\n") + /// .perform_indent(true) + /// .normalize_empty_elements(false) + /// .create_writer(&mut target); + /// ``` + /// + /// This method is exactly equivalent to calling `EventWriter::new_with_config()` with + /// this configuration object. + #[inline] + pub fn create_writer<W: Write>(self, sink: W) -> EventWriter<W> { + EventWriter::new_with_config(sink, self) + } +} + +impl Default for EmitterConfig { + #[inline] + fn default() -> EmitterConfig { + EmitterConfig::new() + } +} + +gen_setters!(EmitterConfig, + line_separator: into Cow<'static, str>, + indent_string: into Cow<'static, str>, + perform_indent: val bool, + write_document_declaration: val bool, + normalize_empty_elements: val bool, + cdata_to_characters: val bool, + keep_element_names_stack: val bool, + autopad_comments: val bool +); diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/emitter.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/emitter.rs new file mode 100644 index 0000000..1b878b2 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/emitter.rs @@ -0,0 +1,447 @@ +use std::io; +use std::io::prelude::*; +use std::fmt; +use std::result; +use std::borrow::Cow; +use std::error::Error; + +use common; +use name::{Name, OwnedName}; +use attribute::Attribute; +use escape::{escape_str_attribute, escape_str_pcdata}; +use common::XmlVersion; +use namespace::{NamespaceStack, NS_NO_PREFIX, NS_EMPTY_URI, NS_XMLNS_PREFIX, NS_XML_PREFIX}; + +use writer::config::EmitterConfig; + +/// An error which may be returned by `XmlWriter` when writing XML events. +#[derive(Debug)] +pub enum EmitterError { + /// An I/O error occured in the underlying `Write` instance. + Io(io::Error), + + /// Document declaration has already been written to the output stream. + DocumentStartAlreadyEmitted, + + /// The name of the last opening element is not available. + LastElementNameNotAvailable, + + /// The name of the last opening element is not equal to the name of the provided + /// closing element. + EndElementNameIsNotEqualToLastStartElementName, + + /// End element name is not specified when it is needed, for example, when automatic + /// closing is not enabled in configuration. + EndElementNameIsNotSpecified +} + +impl From<io::Error> for EmitterError { + fn from(err: io::Error) -> EmitterError { + EmitterError::Io(err) + } +} + +impl fmt::Display for EmitterError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use std::error::Error; + + write!(f, "emitter error: ")?; + match *self { + EmitterError::Io(ref e) => + write!(f, "I/O error: {}", e), + ref other => + write!(f, "{}", other.description()), + } + } +} + +impl Error for EmitterError { + fn description(&self) -> &str { + match *self { + EmitterError::Io(_) => + "I/O error", + EmitterError::DocumentStartAlreadyEmitted => + "document start event has already been emitted", + EmitterError::LastElementNameNotAvailable => + "last element name is not available", + EmitterError::EndElementNameIsNotEqualToLastStartElementName => + "end element name is not equal to last start element name", + EmitterError::EndElementNameIsNotSpecified => + "end element name is not specified and can't be inferred", + } + } +} + +/// A result type yielded by `XmlWriter`. +pub type Result<T> = result::Result<T, EmitterError>; + +// TODO: split into a low-level fast writer without any checks and formatting logic and a +// high-level indenting validating writer +pub struct Emitter { + config: EmitterConfig, + + nst: NamespaceStack, + + indent_level: usize, + indent_stack: Vec<IndentFlags>, + + element_names: Vec<OwnedName>, + + start_document_emitted: bool, + just_wrote_start_element: bool +} + +impl Emitter { + pub fn new(config: EmitterConfig) -> Emitter { + Emitter { + config, + + nst: NamespaceStack::empty(), + + indent_level: 0, + indent_stack: vec![IndentFlags::WroteNothing], + + element_names: Vec::new(), + + start_document_emitted: false, + just_wrote_start_element: false + } + } +} + +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +enum IndentFlags { + WroteNothing, + WroteMarkup, + WroteText, +} + +impl Emitter { + /// Returns the current state of namespaces. + #[inline] + pub fn namespace_stack_mut(&mut self) -> &mut NamespaceStack { + &mut self.nst + } + + #[inline] + fn wrote_text(&self) -> bool { + *self.indent_stack.last().unwrap() == IndentFlags::WroteText + } + + #[inline] + fn wrote_markup(&self) -> bool { + *self.indent_stack.last().unwrap() == IndentFlags::WroteMarkup + } + + #[inline] + fn set_wrote_text(&mut self) { + *self.indent_stack.last_mut().unwrap() = IndentFlags::WroteText; + } + + #[inline] + fn set_wrote_markup(&mut self) { + *self.indent_stack.last_mut().unwrap() = IndentFlags::WroteMarkup; + } + + #[inline] + fn reset_state(&mut self) { + *self.indent_stack.last_mut().unwrap() = IndentFlags::WroteNothing; + } + + fn write_newline<W: Write>(&mut self, target: &mut W, level: usize) -> Result<()> { + target.write(self.config.line_separator.as_bytes())?; + for _ in 0..level { + target.write(self.config.indent_string.as_bytes())?; + } + Ok(()) + } + + fn before_markup<W: Write>(&mut self, target: &mut W) -> Result<()> { + if self.config.perform_indent && !self.wrote_text() && + (self.indent_level > 0 || self.wrote_markup()) { + let indent_level = self.indent_level; + self.write_newline(target, indent_level)?; + if self.indent_level > 0 && self.config.indent_string.len() > 0 { + self.after_markup(); + } + } + Ok(()) + } + + fn after_markup(&mut self) { + self.set_wrote_markup(); + } + + fn before_start_element<W: Write>(&mut self, target: &mut W) -> Result<()> { + self.before_markup(target)?; + self.indent_stack.push(IndentFlags::WroteNothing); + Ok(()) + } + + fn after_start_element(&mut self) { + self.after_markup(); + self.indent_level += 1; + } + + fn before_end_element<W: Write>(&mut self, target: &mut W) -> Result<()> { + if self.config.perform_indent && self.indent_level > 0 && self.wrote_markup() && + !self.wrote_text() { + let indent_level = self.indent_level; + self.write_newline(target, indent_level - 1) + } else { + Ok(()) + } + } + + fn after_end_element(&mut self) { + if self.indent_level > 0 { + self.indent_level -= 1; + self.indent_stack.pop(); + } + self.set_wrote_markup(); + } + + fn after_text(&mut self) { + self.set_wrote_text(); + } + + pub fn emit_start_document<W: Write>(&mut self, target: &mut W, + version: XmlVersion, + encoding: &str, + standalone: Option<bool>) -> Result<()> { + if self.start_document_emitted { + return Err(EmitterError::DocumentStartAlreadyEmitted); + } + self.start_document_emitted = true; + + self.before_markup(target)?; + let result = { + let mut write = move || { + write!(target, "<?xml version=\"{}\" encoding=\"{}\"", version, encoding)?; + + if let Some(standalone) = standalone { + write!(target, " standalone=\"{}\"", if standalone { "yes" } else { "no" })?; + } + + write!(target, "?>")?; + + Ok(()) + }; + write() + }; + self.after_markup(); + + result + } + + fn check_document_started<W: Write>(&mut self, target: &mut W) -> Result<()> { + if !self.start_document_emitted && self.config.write_document_declaration { + self.emit_start_document(target, common::XmlVersion::Version10, "utf-8", None) + } else { + Ok(()) + } + } + + fn fix_non_empty_element<W: Write>(&mut self, target: &mut W) -> Result<()> { + if self.config.normalize_empty_elements && self.just_wrote_start_element { + self.just_wrote_start_element = false; + target.write(b">").map(|_| ()).map_err(From::from) + } else { + Ok(()) + } + } + + pub fn emit_processing_instruction<W: Write>(&mut self, + target: &mut W, + name: &str, + data: Option<&str>) -> Result<()> { + self.check_document_started(target)?; + self.fix_non_empty_element(target)?; + + self.before_markup(target)?; + + let result = { + let mut write = || { + write!(target, "<?{}", name)?; + + if let Some(data) = data { + write!(target, " {}", data)?; + } + + write!(target, "?>")?; + + Ok(()) + }; + write() + }; + + self.after_markup(); + + result + } + + fn emit_start_element_initial<W>(&mut self, target: &mut W, + name: Name, + attributes: &[Attribute]) -> Result<()> + where W: Write + { + self.check_document_started(target)?; + self.fix_non_empty_element(target)?; + self.before_start_element(target)?; + write!(target, "<{}", name.repr_display())?; + self.emit_current_namespace_attributes(target)?; + self.emit_attributes(target, attributes)?; + self.after_start_element(); + Ok(()) + } + + pub fn emit_start_element<W>(&mut self, target: &mut W, + name: Name, + attributes: &[Attribute]) -> Result<()> + where W: Write + { + if self.config.keep_element_names_stack { + self.element_names.push(name.to_owned()); + } + + self.emit_start_element_initial(target, name, attributes)?; + self.just_wrote_start_element = true; + + if !self.config.normalize_empty_elements { + write!(target, ">")?; + } + + Ok(()) + } + + pub fn emit_current_namespace_attributes<W>(&mut self, target: &mut W) -> Result<()> + where W: Write + { + for (prefix, uri) in self.nst.peek() { + match prefix { + // internal namespaces are not emitted + NS_XMLNS_PREFIX | NS_XML_PREFIX => Ok(()), + //// there is already a namespace binding with this prefix in scope + //prefix if self.nst.get(prefix) == Some(uri) => Ok(()), + // emit xmlns only if it is overridden + NS_NO_PREFIX => if uri != NS_EMPTY_URI { + write!(target, " xmlns=\"{}\"", uri) + } else { Ok(()) }, + // everything else + prefix => write!(target, " xmlns:{}=\"{}\"", prefix, uri) + }?; + } + Ok(()) + } + + pub fn emit_attributes<W: Write>(&mut self, target: &mut W, + attributes: &[Attribute]) -> Result<()> { + for attr in attributes.iter() { + write!( + target, " {}=\"{}\"", + attr.name.repr_display(), + if self.config.perform_escaping { escape_str_attribute(attr.value) } else { Cow::Borrowed(attr.value) } + )? + } + Ok(()) + } + + pub fn emit_end_element<W: Write>(&mut self, target: &mut W, + name: Option<Name>) -> Result<()> { + let owned_name = if self.config.keep_element_names_stack { + Some(self.element_names.pop().ok_or(EmitterError::LastElementNameNotAvailable)?) + } else { + None + }; + + // Check that last started element name equals to the provided name, if there are both + if let Some(ref last_name) = owned_name { + if let Some(ref name) = name { + if last_name.borrow() != *name { + return Err(EmitterError::EndElementNameIsNotEqualToLastStartElementName); + } + } + } + + if let Some(name) = owned_name.as_ref().map(|n| n.borrow()).or(name) { + if self.config.normalize_empty_elements && self.just_wrote_start_element { + self.just_wrote_start_element = false; + // TODO: make this space configurable + let result = target.write(b" />").map_err(From::from); + self.after_end_element(); + result.map(|_| ()) + } else { + self.just_wrote_start_element = false; + + self.before_end_element(target)?; + let result = write!(target, "</{}>", name.repr_display()).map_err(From::from); + self.after_end_element(); + + result + } + } else { + Err(EmitterError::EndElementNameIsNotSpecified) + } + } + + pub fn emit_cdata<W: Write>(&mut self, target: &mut W, content: &str) -> Result<()> { + self.fix_non_empty_element(target)?; + if self.config.cdata_to_characters { + self.emit_characters(target, content) + } else { + // TODO: escape ']]>' characters in CDATA as two adjacent CDATA blocks + target.write(b"<![CDATA[")?; + target.write(content.as_bytes())?; + target.write(b"]]>")?; + + self.after_text(); + + Ok(()) + } + } + + pub fn emit_characters<W: Write>(&mut self, target: &mut W, + content: &str) -> Result<()> { + self.fix_non_empty_element(target)?; + target.write( + (if self.config.perform_escaping { + escape_str_pcdata(content) + } else { + Cow::Borrowed(content) + }).as_bytes() + )?; + self.after_text(); + Ok(()) + } + + pub fn emit_comment<W: Write>(&mut self, target: &mut W, content: &str) -> Result<()> { + self.fix_non_empty_element(target)?; + + // TODO: add escaping dashes at the end of the comment + + let autopad_comments = self.config.autopad_comments; + let write = |target: &mut W| -> Result<()> { + target.write(b"<!--")?; + + if autopad_comments && !content.starts_with(char::is_whitespace) { + target.write(b" ")?; + } + + target.write(content.as_bytes())?; + + if autopad_comments && !content.ends_with(char::is_whitespace) { + target.write(b" ")?; + } + + target.write(b"-->")?; + + Ok(()) + }; + + self.before_markup(target)?; + let result = write(target); + self.after_markup(); + + result + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/events.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/events.rs new file mode 100644 index 0000000..1f7040f --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/events.rs @@ -0,0 +1,241 @@ +//! Contains `XmlEvent` datatype, instances of which are consumed by the writer. + +use std::borrow::Cow; + +use name::Name; +use attribute::Attribute; +use common::XmlVersion; +use namespace::{Namespace, NS_NO_PREFIX}; + +/// A part of an XML output stream. +/// +/// Objects of this enum are consumed by `EventWriter`. They correspond to different parts of +/// an XML document. +#[derive(Debug)] +pub enum XmlEvent<'a> { + /// Corresponds to XML document declaration. + /// + /// This event should always be written before any other event. If it is not written + /// at all, a default XML declaration will be outputted if the corresponding option + /// is set in the configuration. Otherwise an error will be returned. + StartDocument { + /// XML version. + /// + /// Defaults to `XmlVersion::Version10`. + version: XmlVersion, + + /// XML document encoding. + /// + /// Defaults to `Some("UTF-8")`. + encoding: Option<&'a str>, + + /// XML standalone declaration. + /// + /// Defaults to `None`. + standalone: Option<bool> + }, + + /// Denotes an XML processing instruction. + ProcessingInstruction { + /// Processing instruction target. + name: &'a str, + + /// Processing instruction content. + data: Option<&'a str> + }, + + /// Denotes a beginning of an XML element. + StartElement { + /// Qualified name of the element. + name: Name<'a>, + + /// A list of attributes associated with the element. + /// + /// Currently attributes are not checked for duplicates (TODO). Attribute values + /// will be escaped, and all characters invalid for attribute values like `"` or `<` + /// will be changed into character entities. + attributes: Cow<'a, [Attribute<'a>]>, + + /// Contents of the namespace mapping at this point of the document. + /// + /// This mapping will be inspected for "new" entries, and if at this point of the document + /// a particular pair of prefix and namespace URI is already defined, no namespace + /// attributes will be emitted. + namespace: Cow<'a, Namespace>, + }, + + /// Denotes an end of an XML element. + EndElement { + /// Optional qualified name of the element. + /// + /// If `None`, then it is assumed that the element name should be the last valid one. + /// If `Some` and element names tracking is enabled, then the writer will check it for + /// correctness. + name: Option<Name<'a>> + }, + + /// Denotes CDATA content. + /// + /// This event contains unparsed data, and no escaping will be performed when writing it + /// to the output stream. + CData(&'a str), + + /// Denotes a comment. + /// + /// The string will be checked for invalid sequences and error will be returned by the + /// write operation + Comment(&'a str), + + /// Denotes character data outside of tags. + /// + /// Contents of this event will be escaped if `perform_escaping` option is enabled, + /// that is, every character invalid for PCDATA will appear as a character entity. + Characters(&'a str) +} + +impl<'a> XmlEvent<'a> { + /// Returns an writer event for a processing instruction. + #[inline] + pub fn processing_instruction(name: &'a str, data: Option<&'a str>) -> XmlEvent<'a> { + XmlEvent::ProcessingInstruction { name: name, data: data } + } + + /// Returns a builder for a starting element. + /// + /// This builder can then be used to tweak attributes and namespace starting at + /// this element. + #[inline] + pub fn start_element<S>(name: S) -> StartElementBuilder<'a> where S: Into<Name<'a>> { + StartElementBuilder { + name: name.into(), + attributes: Vec::new(), + namespace: Namespace::empty().into() + } + } + + /// Returns a builder for an closing element. + /// + /// This method, unline `start_element()`, does not accept a name because by default + /// the writer is able to determine it automatically. However, when this functionality + /// is disabled, it is possible to specify the name with `name()` method on the builder. + #[inline] + pub fn end_element() -> EndElementBuilder<'a> { + EndElementBuilder { name: None } + } + + /// Returns a CDATA event. + /// + /// Naturally, the provided string won't be escaped, except for closing CDATA token `]]>` + /// (depending on the configuration). + #[inline] + pub fn cdata(data: &'a str) -> XmlEvent<'a> { XmlEvent::CData(data) } + + /// Returns a regular characters (PCDATA) event. + /// + /// All offending symbols, in particular, `&` and `<`, will be escaped by the writer. + #[inline] + pub fn characters(data: &'a str) -> XmlEvent<'a> { XmlEvent::Characters(data) } + + /// Returns a comment event. + #[inline] + pub fn comment(data: &'a str) -> XmlEvent<'a> { XmlEvent::Comment(data) } +} + +impl<'a> From<&'a str> for XmlEvent<'a> { + #[inline] + fn from(s: &'a str) -> XmlEvent<'a> { XmlEvent::Characters(s) } +} + +pub struct EndElementBuilder<'a> { + name: Option<Name<'a>> +} + +/// A builder for a closing element event. +impl<'a> EndElementBuilder<'a> { + /// Sets the name of this closing element. + /// + /// Usually the writer is able to determine closing element names automatically. If + /// this functionality is enabled (by default it is), then this name is checked for correctness. + /// It is possible, however, to disable such behavior; then the user must ensure that + /// closing element name is correct manually. + #[inline] + pub fn name<N>(mut self, name: N) -> EndElementBuilder<'a> where N: Into<Name<'a>> { + self.name = Some(name.into()); + self + } +} + +impl<'a> From<EndElementBuilder<'a>> for XmlEvent<'a> { + fn from(b: EndElementBuilder<'a>) -> XmlEvent<'a> { + XmlEvent::EndElement { name: b.name } + } +} + +/// A builder for a starting element event. +pub struct StartElementBuilder<'a> { + name: Name<'a>, + attributes: Vec<Attribute<'a>>, + namespace: Namespace +} + +impl<'a> StartElementBuilder<'a> { + /// Sets an attribute value of this element to the given string. + /// + /// This method can be used to add attributes to the starting element. Name is a qualified + /// name; its namespace is ignored, but its prefix is checked for correctness, that is, + /// it is checked that the prefix is bound to some namespace in the current context. + /// + /// Currently attributes are not checked for duplicates. Note that duplicate attributes + /// are a violation of XML document well-formedness. + /// + /// The writer checks that you don't specify reserved prefix names, for example `xmlns`. + #[inline] + pub fn attr<N>(mut self, name: N, value: &'a str) -> StartElementBuilder<'a> + where N: Into<Name<'a>> + { + self.attributes.push(Attribute::new(name.into(), value)); + self + } + + /// Adds a namespace to the current namespace context. + /// + /// If no namespace URI was bound to the provided prefix at this point of the document, + /// then the mapping from the prefix to the provided namespace URI will be written as + /// a part of this element attribute set. + /// + /// If the same namespace URI was bound to the provided prefix at this point of the document, + /// then no namespace attributes will be emitted. + /// + /// If some other namespace URI was bound to the provided prefix at this point of the document, + /// then another binding will be added as a part of this element attribute set, shadowing + /// the outer binding. + #[inline] + pub fn ns<S1, S2>(mut self, prefix: S1, uri: S2) -> StartElementBuilder<'a> + where S1: Into<String>, S2: Into<String> + { + self.namespace.put(prefix, uri); + self + } + + /// Adds a default namespace mapping to the current namespace context. + /// + /// Same rules as for `ns()` are also valid for the default namespace mapping. + #[inline] + pub fn default_ns<S>(mut self, uri: S) -> StartElementBuilder<'a> + where S: Into<String> + { + self.namespace.put(NS_NO_PREFIX, uri); + self + } +} + +impl<'a> From<StartElementBuilder<'a>> for XmlEvent<'a> { + #[inline] + fn from(b: StartElementBuilder<'a>) -> XmlEvent<'a> { + XmlEvent::StartElement { + name: b.name, + attributes: Cow::Owned(b.attributes), + namespace: Cow::Owned(b.namespace) + } + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/mod.rs b/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/mod.rs new file mode 100644 index 0000000..ea1b242 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/src/writer/mod.rs @@ -0,0 +1,93 @@ +//! Contains high-level interface for an events-based XML emitter. +//! +//! The most important type in this module is `EventWriter` which allows writing an XML document +//! to some output stream. + +pub use self::emitter::Result; +pub use self::emitter::EmitterError as Error; +pub use self::config::EmitterConfig; +pub use self::events::XmlEvent; + +use self::emitter::Emitter; + +use std::io::prelude::*; + +mod emitter; +mod config; +pub mod events; + +/// A wrapper around an `std::io::Write` instance which emits XML document according to provided +/// events. +pub struct EventWriter<W> { + sink: W, + emitter: Emitter +} + +impl<W: Write> EventWriter<W> { + /// Creates a new `EventWriter` out of an `std::io::Write` instance using the default + /// configuration. + #[inline] + pub fn new(sink: W) -> EventWriter<W> { + EventWriter::new_with_config(sink, EmitterConfig::new()) + } + + /// Creates a new `EventWriter` out of an `std::io::Write` instance using the provided + /// configuration. + #[inline] + pub fn new_with_config(sink: W, config: EmitterConfig) -> EventWriter<W> { + EventWriter { + sink, + emitter: Emitter::new(config) + } + } + + /// Writes the next piece of XML document according to the provided event. + /// + /// Note that output data may not exactly correspond to the written event because + /// of various configuration options. For example, `XmlEvent::EndElement` may + /// correspond to a separate closing element or it may cause writing an empty element. + /// Another example is that `XmlEvent::CData` may be represented as characters in + /// the output stream. + pub fn write<'a, E>(&mut self, event: E) -> Result<()> where E: Into<XmlEvent<'a>> { + match event.into() { + XmlEvent::StartDocument { version, encoding, standalone } => + self.emitter.emit_start_document(&mut self.sink, version, encoding.unwrap_or("UTF-8"), standalone), + XmlEvent::ProcessingInstruction { name, data } => + self.emitter.emit_processing_instruction(&mut self.sink, name, data), + XmlEvent::StartElement { name, attributes, namespace } => { + self.emitter.namespace_stack_mut().push_empty().checked_target().extend(namespace.as_ref()); + self.emitter.emit_start_element(&mut self.sink, name, &attributes) + } + XmlEvent::EndElement { name } => { + let r = self.emitter.emit_end_element(&mut self.sink, name); + self.emitter.namespace_stack_mut().try_pop(); + r + } + XmlEvent::Comment(content) => + self.emitter.emit_comment(&mut self.sink, content), + XmlEvent::CData(content) => + self.emitter.emit_cdata(&mut self.sink, content), + XmlEvent::Characters(content) => + self.emitter.emit_characters(&mut self.sink, content) + } + } + + /// Returns a mutable reference to the underlying `Writer`. + /// + /// Note that having a reference to the underlying sink makes it very easy to emit invalid XML + /// documents. Use this method with care. Valid use cases for this method include accessing + /// methods like `Write::flush`, which do not emit new data but rather change the state + /// of the stream itself. + pub fn inner_mut(&mut self) -> &mut W { + &mut self.sink + } + + /// Unwraps this `EventWriter`, returning the underlying writer. + /// + /// Note that this is a destructive operation: unwrapping a writer and then wrapping + /// it again with `EventWriter::new()` will create a fresh writer whose state will be + /// blank; for example, accumulated namespaces will be reset. + pub fn into_inner(self) -> W { + self.sink + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_1.xml b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_1.xml new file mode 100644 index 0000000..4d1cbc0 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_1.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<project name="project-name"> + <libraries> + <library groupId="org.example" artifactId="<name>" version="0.1"/> + <library groupId="com.example" artifactId=""cool-lib&" version="999"/> + </libraries> + <module name="module-1"> + <files> + <file name="somefile.java" type="java"> + Some <java> class + </file> + <file name="another_file.java" type="java"> + Another "java" class + </file> + <file name="config.xml" type="xml"> + Weird 'XML' config + </file> + </files> + <libraries> + <library groupId="junit" artifactId="junit" version="1.9.5"/> + </libraries> + </module> + <module name="module-2"> + <files> + <file name="program.js" type="javascript"> + JavaScript & program + </file> + <file name="style.css" type="css"> + Cascading style sheet: © - ҉ + </file> + </files> + </module> +</project> + diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_1_full.txt b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_1_full.txt new file mode 100644 index 0000000..a8d64d0 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_1_full.txt @@ -0,0 +1,58 @@ +StartDocument(1.0, utf-8) +StartElement(project [name="project-name"]) +Whitespace("\n ") +StartElement(libraries) +Whitespace("\n ") +StartElement(library [groupId="org.example", artifactId="<name>", version="0.1"]) +EndElement(library) +Whitespace("\n ") +StartElement(library [groupId="com.example", artifactId="\"cool-lib&", version="999"]) +EndElement(library) +Whitespace("\n ") +EndElement(libraries) +Whitespace("\n ") +StartElement(module [name="module-1"]) +Whitespace("\n ") +StartElement(files) +Whitespace("\n ") +StartElement(file [name="somefile.java", type="java"]) +Characters("\n Some <java> class\n ") +EndElement(file) +Whitespace("\n ") +StartElement(file [name="another_file.java", type="java"]) +Characters("\n Another \"java\" class\n ") +EndElement(file) +Whitespace("\n ") +StartElement(file [name="config.xml", type="xml"]) +Characters("\n Weird \'XML\' config\n ") +EndElement(file) +Whitespace("\n ") +EndElement(files) +Whitespace("\n ") +StartElement(libraries) +Whitespace("\n ") +StartElement(library [groupId="junit", artifactId="junit", version="1.9.5"]) +EndElement(library) +Whitespace("\n ") +EndElement(libraries) +Whitespace("\n ") +EndElement(module) +Whitespace("\n ") +StartElement(module [name="module-2"]) +Whitespace("\n ") +StartElement(files) +Whitespace("\n ") +StartElement(file [name="program.js", type="javascript"]) +Characters("\n JavaScript & program\n ") +EndElement(file) +Whitespace("\n ") +StartElement(file [name="style.css", type="css"]) +Characters("\n Cascading style sheet: © - ҉\n ") +EndElement(file) +Whitespace("\n ") +EndElement(files) +Whitespace("\n ") +EndElement(module) +Whitespace("\n") +EndElement(project) +EndDocument diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_1_short.txt b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_1_short.txt new file mode 100644 index 0000000..4dbe285 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_1_short.txt @@ -0,0 +1,37 @@ +StartDocument(1.0, utf-8) +StartElement(project [name="project-name"]) +StartElement(libraries) +StartElement(library [groupId="org.example", artifactId="<name>", version="0.1"]) +EndElement(library) +StartElement(library [groupId="com.example", artifactId="\"cool-lib&", version="999"]) +EndElement(library) +EndElement(libraries) +StartElement(module [name="module-1"]) +StartElement(files) +StartElement(file [name="somefile.java", type="java"]) +Characters("Some <java> class") +EndElement(file) +StartElement(file [name="another_file.java", type="java"]) +Characters("Another \"java\" class") +EndElement(file) +StartElement(file [name="config.xml", type="xml"]) +Characters("Weird \'XML\' config") +EndElement(file) +EndElement(files) +StartElement(libraries) +StartElement(library [groupId="junit", artifactId="junit", version="1.9.5"]) +EndElement(library) +EndElement(libraries) +EndElement(module) +StartElement(module [name="module-2"]) +StartElement(files) +StartElement(file [name="program.js", type="javascript"]) +Characters("JavaScript & program") +EndElement(file) +StartElement(file [name="style.css", type="css"]) +Characters("Cascading style sheet: © - ҉") +EndElement(file) +EndElement(files) +EndElement(module) +EndElement(project) +EndDocument diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_2.xml b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_2.xml new file mode 100644 index 0000000..f9543ac --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_2.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<p:data xmlns:d="urn:example:double" xmlns:h="urn:example:header" xmlns:p="urn:example:namespace"> + <p:datum id="34"> + <p:name>Name</p:name> + <d:name>Another name</d:name> + <d:arg>0.3</d:arg> + <d:arg>0.2</d:arg> + <p:arg>0.1</p:arg> + <p:arg>0.01</p:arg> + <h:header name="Header-1">header 1 value</h:header> + <h:header name="Header-2"> + Some bigger value + </h:header> + </p:datum> +</p:data> diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_2_full.txt b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_2_full.txt new file mode 100644 index 0000000..75075cd --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_2_full.txt @@ -0,0 +1,41 @@ +StartDocument(1.0, utf-8) +StartElement({urn:example:namespace}p:data) +Whitespace("\n ") +StartElement({urn:example:namespace}p:datum [id="34"]) +Whitespace("\n ") +StartElement({urn:example:namespace}p:name) +Characters("Name") +EndElement({urn:example:namespace}p:name) +Whitespace("\n ") +StartElement({urn:example:double}d:name) +Characters("Another name") +EndElement({urn:example:double}d:name) +Whitespace("\n ") +StartElement({urn:example:double}d:arg) +Characters("0.3") +EndElement({urn:example:double}d:arg) +Whitespace("\n ") +StartElement({urn:example:double}d:arg) +Characters("0.2") +EndElement({urn:example:double}d:arg) +Whitespace("\n ") +StartElement({urn:example:namespace}p:arg) +Characters("0.1") +EndElement({urn:example:namespace}p:arg) +Whitespace("\n ") +StartElement({urn:example:namespace}p:arg) +Characters("0.01") +EndElement({urn:example:namespace}p:arg) +Whitespace("\n ") +StartElement({urn:example:header}h:header [name="Header-1"]) +Characters("header 1 value") +EndElement({urn:example:header}h:header) +Whitespace("\n ") +StartElement({urn:example:header}h:header [name="Header-2"]) +Characters("\n Some bigger value\n ") +EndElement({urn:example:header}h:header) +Whitespace("\n ") +EndElement({urn:example:namespace}p:datum) +Whitespace("\n") +EndElement({urn:example:namespace}p:data) +EndDocument diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_2_short.txt b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_2_short.txt new file mode 100644 index 0000000..2368025 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_2_short.txt @@ -0,0 +1,30 @@ +StartDocument(1.0, utf-8) +StartElement({urn:example:namespace}p:data) +StartElement({urn:example:namespace}p:datum [id="34"]) +StartElement({urn:example:namespace}p:name) +Characters("Name") +EndElement({urn:example:namespace}p:name) +StartElement({urn:example:double}d:name) +Characters("Another name") +EndElement({urn:example:double}d:name) +StartElement({urn:example:double}d:arg) +Characters("0.3") +EndElement({urn:example:double}d:arg) +StartElement({urn:example:double}d:arg) +Characters("0.2") +EndElement({urn:example:double}d:arg) +StartElement({urn:example:namespace}p:arg) +Characters("0.1") +EndElement({urn:example:namespace}p:arg) +StartElement({urn:example:namespace}p:arg) +Characters("0.01") +EndElement({urn:example:namespace}p:arg) +StartElement({urn:example:header}h:header [name="Header-1"]) +Characters("header 1 value") +EndElement({urn:example:header}h:header) +StartElement({urn:example:header}h:header [name="Header-2"]) +Characters("Some bigger value") +EndElement({urn:example:header}h:header) +EndElement({urn:example:namespace}p:datum) +EndElement({urn:example:namespace}p:data) +EndDocument diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_3.xml b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_3.xml new file mode 100644 index 0000000..657e37d --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_3.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<p:data xmlns:p="urn:x" z=">"> + <!-- abcd < > & --> + <a>test</a> + <b>kkss" = ddd' ></b> + <![CDATA[ + <a>ddddd</b>!e3--><!-- ddckx + ]]> + <c/> + <![CDATA[ + <![CDATA[zzzz]]]]><![CDATA[>]]> +</p:data> + diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_3_full.txt b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_3_full.txt new file mode 100644 index 0000000..e9a0f7e --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_3_full.txt @@ -0,0 +1,23 @@ +1:1 StartDocument(1.0, utf-8) +2:1 StartElement({urn:x}p:data [z=">"]) +2:31 Whitespace("\n ") +3:5 Comment(" abcd < > & ") +3:34 Whitespace("\n ") +4:5 StartElement(a) +4:8 Characters("test") +4:12 EndElement(a) +4:16 Whitespace("\n ") +5:5 StartElement(b) +5:8 Characters("kkss\" = ddd\' >") +5:22 EndElement(b) +5:26 Whitespace("\n ") +6:5 CData("\n <a>ddddd</b>!e3--><!-- ddckx\n ") +8:8 Characters("\n ") +9:5 StartElement(c) +9:5 EndElement(c) +9:9 Whitespace("\n ") +10:5 CData("\n <![CDATA[zzzz]]") +11:23 CData(">") +11:36 Characters("\n") +12:1 EndElement({urn:x}p:data) +14:1 EndDocument diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_3_short.txt b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_3_short.txt new file mode 100644 index 0000000..2582f33 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_3_short.txt @@ -0,0 +1,14 @@ +1:1 StartDocument(1.0, utf-8) +2:1 StartElement({urn:x}p:data [z=">"]) +4:5 StartElement(a) +4:8 Characters("test") +4:12 EndElement(a) +5:5 StartElement(b) +5:8 Characters("kkss\" = ddd\' >") +5:22 EndElement(b) +6:5 Characters("<a>ddddd</b>!e3--><!-- ddckx") +9:5 StartElement(c) +9:5 EndElement(c) +10:5 Characters("<![CDATA[zzzz]]>") +12:1 EndElement({urn:x}p:data) +14:1 EndDocument diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_4.xml b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_4.xml new file mode 100644 index 0000000..fb915ff --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_4.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE data SYSTEM "abcd.dtd"> +<p:data xmlns:p="urn:x" z=">"> + <!-- abcd < > & --> + <a>test</a> + <b>kkss" = ddd' ></b> + <![CDATA[ + <a>ddddd</b>!e3--><!-- ddckx + ]]> + <c/> + <![CDATA[ + <![CDATA[zzzz]]]]><![CDATA[>]]> +</p:data> + + diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_4_full.txt b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_4_full.txt new file mode 100644 index 0000000..4bdadfb --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_4_full.txt @@ -0,0 +1,23 @@ +StartDocument(1.0, utf-8) +StartElement({urn:x}p:data [z=">"]) +Whitespace("\n ") +Comment(" abcd < > & ") +Whitespace("\n ") +StartElement(a) +Characters("test") +EndElement(a) +Whitespace("\n ") +StartElement(b) +Characters("kkss\" = ddd\' >") +EndElement(b) +Whitespace("\n ") +CData("\n <a>ddddd</b>!e3--><!-- ddckx\n ") +Characters("\n ") +StartElement(c) +EndElement(c) +Whitespace("\n ") +CData("\n <![CDATA[zzzz]]") +CData(">") +Characters("\n") +EndElement({urn:x}p:data) +EndDocument diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_4_short.txt b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_4_short.txt new file mode 100644 index 0000000..52e4b83 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_4_short.txt @@ -0,0 +1,14 @@ +StartDocument(1.0, utf-8) +StartElement({urn:x}p:data [z=">"]) +StartElement(a) +Characters("test") +EndElement(a) +StartElement(b) +Characters("kkss\" = ddd\' >") +EndElement(b) +Characters("<a>ddddd</b>!e3--><!-- ddckx") +StartElement(c) +EndElement(c) +Characters("<![CDATA[zzzz]]>") +EndElement({urn:x}p:data) +EndDocument diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_5.xml b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_5.xml new file mode 100644 index 0000000..92aa31d --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_5.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE data SYSTEM "abcd.dtd"> +<p> + <a>test ©≂̸</a> +</p> + + diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_5_short.txt b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_5_short.txt new file mode 100644 index 0000000..3079811 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/documents/sample_5_short.txt @@ -0,0 +1,7 @@ +StartDocument(1.0, utf-8) +StartElement(p) +StartElement(a) +Characters("test ©≂̸") +EndElement(a) +EndElement(p) +EndDocument diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/event_reader.rs b/third_party/cargo/vendor/xml-rs-0.8.0/tests/event_reader.rs new file mode 100644 index 0000000..7f616bf --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/event_reader.rs @@ -0,0 +1,460 @@ +extern crate xml; + +use std::env; +use std::fmt; +use std::fs::File; +use std::io::{BufRead, BufReader, Write, stderr}; +use std::path::Path; +use std::sync::{Once, ONCE_INIT}; + +use xml::name::OwnedName; +use xml::common::Position; +use xml::reader::{Result, XmlEvent, ParserConfig, EventReader}; + +/// Dummy function that opens a file, parses it, and returns a `Result`. +/// There can be IO errors (from `File::open`) and XML errors (from the parser). +/// Having `impl From<std::io::Error> for xml::reader::Error` allows the user to +/// do this without defining their own error type. +#[allow(dead_code)] +fn count_event_in_file(name: &Path) -> Result<usize> { + let mut event_count = 0; + for event in EventReader::new(BufReader::new(try!(File::open(name)))) { + try!(event); + event_count += 1; + } + Ok(event_count) +} + +#[test] +fn sample_1_short() { + test( + include_bytes!("documents/sample_1.xml"), + include_bytes!("documents/sample_1_short.txt"), + ParserConfig::new() + .ignore_comments(true) + .whitespace_to_characters(true) + .cdata_to_characters(true) + .trim_whitespace(true) + .coalesce_characters(true), + false + ); +} + +#[test] +fn sample_1_full() { + test( + include_bytes!("documents/sample_1.xml"), + include_bytes!("documents/sample_1_full.txt"), + ParserConfig::new() + .ignore_comments(false) + .whitespace_to_characters(false) + .cdata_to_characters(false) + .trim_whitespace(false) + .coalesce_characters(false), + false + ); +} + +#[test] +fn sample_2_short() { + test( + include_bytes!("documents/sample_2.xml"), + include_bytes!("documents/sample_2_short.txt"), + ParserConfig::new() + .ignore_comments(true) + .whitespace_to_characters(true) + .cdata_to_characters(true) + .trim_whitespace(true) + .coalesce_characters(true), + false + ); +} + +#[test] +fn sample_2_full() { + test( + include_bytes!("documents/sample_2.xml"), + include_bytes!("documents/sample_2_full.txt"), + ParserConfig::new() + .ignore_comments(false) + .whitespace_to_characters(false) + .cdata_to_characters(false) + .trim_whitespace(false) + .coalesce_characters(false), + false + ); +} + +#[test] +fn sample_3_short() { + test( + include_bytes!("documents/sample_3.xml"), + include_bytes!("documents/sample_3_short.txt"), + ParserConfig::new() + .ignore_comments(true) + .whitespace_to_characters(true) + .cdata_to_characters(true) + .trim_whitespace(true) + .coalesce_characters(true), + true + ); +} + +#[test] +fn sample_3_full() { + test( + include_bytes!("documents/sample_3.xml"), + include_bytes!("documents/sample_3_full.txt"), + ParserConfig::new() + .ignore_comments(false) + .whitespace_to_characters(false) + .cdata_to_characters(false) + .trim_whitespace(false) + .coalesce_characters(false), + true + ); +} + +#[test] +fn sample_4_short() { + test( + include_bytes!("documents/sample_4.xml"), + include_bytes!("documents/sample_4_short.txt"), + ParserConfig::new() + .ignore_comments(true) + .whitespace_to_characters(true) + .cdata_to_characters(true) + .trim_whitespace(true) + .coalesce_characters(true), + false + ); +} + +#[test] +fn sample_4_full() { + test( + include_bytes!("documents/sample_4.xml"), + include_bytes!("documents/sample_4_full.txt"), + ParserConfig::new() + .ignore_comments(false) + .whitespace_to_characters(false) + .cdata_to_characters(false) + .trim_whitespace(false) + .coalesce_characters(false), + false + ); + +} + +#[test] +fn sample_5_short() { + test( + include_bytes!("documents/sample_5.xml"), + include_bytes!("documents/sample_5_short.txt"), + ParserConfig::new() + .ignore_comments(true) + .whitespace_to_characters(true) + .cdata_to_characters(true) + .trim_whitespace(true) + .coalesce_characters(true) + .add_entity("nbsp", " ") + .add_entity("copy", "©") + .add_entity("NotEqualTilde", "≂̸"), + false + ); +} + +#[test] +fn eof_1() { + test( + br#"<?xml"#, + br#"1:6 Unexpected end of stream: no root element found"#, + ParserConfig::new(), + false + ); +} + +#[test] +fn bad_1() { + test( + br#"<?xml&.,"#, + br#"1:6 Unexpected token: <?xml&"#, + ParserConfig::new(), + false + ); +} + +#[test] +fn dashes_in_comments() { + test( + br#"<!-- comment -- --><hello/>"#, + br#" + |1:14 Unexpected token '--' before ' ' + "#, + ParserConfig::new(), + false + ); + + test( + br#"<!-- comment ---><hello/>"#, + br#" + |1:14 Unexpected token '--' before '-' + "#, + ParserConfig::new(), + false + ); +} + +#[test] +fn tabs_1() { + test( + b"\t<a>\t<b/></a>", + br#" + |1:2 StartDocument(1.0, UTF-8) + |1:2 StartElement(a) + |1:6 StartElement(b) + |1:6 EndElement(b) + |1:10 EndElement(a) + |1:14 EndDocument + "#, + ParserConfig::new() + .trim_whitespace(true), + true + ); +} + +#[test] +fn issue_83_duplicate_attributes() { + test( + br#"<hello><some-tag a='10' a="20"></hello>"#, + br#" + |StartDocument(1.0, UTF-8) + |StartElement(hello) + |1:30 Attribute 'a' is redefined + "#, + ParserConfig::new(), + false + ); +} + +#[test] +fn issue_93_large_characters_in_entity_references() { + test( + r#"<hello>&𤶼;</hello>"#.as_bytes(), + r#" + |StartDocument(1.0, UTF-8) + |StartElement(hello) + |1:10 Unexpected entity: 𤶼 + "#.as_bytes(), // FIXME: it shouldn't be 10, looks like indices are off slightly + ParserConfig::new(), + false + ) +} + +#[test] +fn issue_98_cdata_ending_with_right_bracket() { + test( + br#"<hello><![CDATA[Foo [Bar]]]></hello>"#, + br#" + |StartDocument(1.0, UTF-8) + |StartElement(hello) + |CData("Foo [Bar]") + |EndElement(hello) + |EndDocument + "#, + ParserConfig::new(), + false + ) +} + +#[test] +fn issue_105_unexpected_double_dash() { + test( + br#"<hello>-- </hello>"#, + br#" + |StartDocument(1.0, UTF-8) + |StartElement(hello) + |Characters("-- ") + |EndElement(hello) + |EndDocument + "#, + ParserConfig::new(), + false + ); + + test( + br#"<hello>--</hello>"#, + br#" + |StartDocument(1.0, UTF-8) + |StartElement(hello) + |Characters("--") + |EndElement(hello) + |EndDocument + "#, + ParserConfig::new(), + false + ); + + test( + br#"<hello>--></hello>"#, + br#" + |StartDocument(1.0, UTF-8) + |StartElement(hello) + |Characters("-->") + |EndElement(hello) + |EndDocument + "#, + ParserConfig::new(), + false + ); + + test( + br#"<hello><![CDATA[--]]></hello>"#, + br#" + |StartDocument(1.0, UTF-8) + |StartElement(hello) + |CData("--") + |EndElement(hello) + |EndDocument + "#, + ParserConfig::new(), + false + ); +} + +#[test] +fn issue_attribues_have_no_default_namespace () { + test( + br#"<hello xmlns="urn:foo" x="y"/>"#, + br#" + |StartDocument(1.0, UTF-8) + |StartElement({urn:foo}hello [x="y"]) + |EndElement({urn:foo}hello) + |EndDocument + "#, + ParserConfig::new(), + false + ); +} + + +static START: Once = ONCE_INIT; +static mut PRINT: bool = false; + +// clones a lot but that's fine +fn trim_until_bar(s: String) -> String { + match s.trim() { + ts if ts.starts_with('|') => return ts[1..].to_owned(), + _ => {} + } + s +} + +fn test(input: &[u8], output: &[u8], config: ParserConfig, test_position: bool) { + // If PRINT_SPEC env variable is set, print the lines + // to stderr instead of comparing with the output + // it can be used like this: + // PRINT_SPEC=1 cargo test --test event_reader sample_1_full 2> sample_1_full.txt + START.call_once(|| { + for (key, value) in env::vars() { + if key == "PRINT_SPEC" && value == "1" { + unsafe { PRINT = true; } + } + } + }); + + let mut reader = config.create_reader(input); + let mut spec_lines = BufReader::new(output).lines() + .map(|line| line.unwrap()) + .enumerate() + .map(|(i, line)| (i, trim_until_bar(line))) + .filter(|&(_, ref line)| !line.trim().is_empty()); + + loop { + let e = reader.next(); + let line = + if test_position { + format!("{} {}", reader.position(), Event(&e)) + } else { + format!("{}", Event(&e)) + }; + + if unsafe { PRINT } { + writeln!(&mut stderr(), "{}", line).unwrap(); + } else { + if let Some((n, spec)) = spec_lines.next() { + if line != spec { + const SPLITTER: &'static str = "-------------------"; + panic!("\n{}\nUnexpected event at line {}:\nExpected: {}\nFound: {}\n{}\n", + SPLITTER, n + 1, spec, line, SPLITTER); + } + } else { + panic!("Unexpected event: {}", line); + } + } + + match e { + Ok(XmlEvent::EndDocument) | Err(_) => break, + _ => {}, + } + } +} + +// Here we define our own string representation of events so we don't depend +// on the specifics of Display implementation for XmlEvent and OwnedName. + +struct Name<'a>(&'a OwnedName); + +impl <'a> fmt::Display for Name<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if let Some(ref namespace) = self.0.namespace { + try! { write!(f, "{{{}}}", namespace) } + } + + if let Some(ref prefix) = self.0.prefix { + try! { write!(f, "{}:", prefix) } + } + + write!(f, "{}", self.0.local_name) + } +} + +struct Event<'a>(&'a Result<XmlEvent>); + +impl<'a> fmt::Display for Event<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let empty = String::new(); + match *self.0 { + Ok(ref e) => match *e { + XmlEvent::StartDocument { ref version, ref encoding, .. } => + write!(f, "StartDocument({}, {})", version, encoding), + XmlEvent::EndDocument => + write!(f, "EndDocument"), + XmlEvent::ProcessingInstruction { ref name, ref data } => + write!(f, "ProcessingInstruction({}={:?})", name, + data.as_ref().unwrap_or(&empty)), + XmlEvent::StartElement { ref name, ref attributes, .. } => { + if attributes.is_empty() { + write!(f, "StartElement({})", Name(name)) + } + else { + let attrs: Vec<_> = attributes.iter() + .map(|a| format!("{}={:?}", Name(&a.name), a.value)) .collect(); + write!(f, "StartElement({} [{}])", Name(name), attrs.join(", ")) + } + }, + XmlEvent::EndElement { ref name } => + write!(f, "EndElement({})", Name(name)), + XmlEvent::Comment(ref data) => + write!(f, "Comment({:?})", data), + XmlEvent::CData(ref data) => + write!(f, "CData({:?})", data), + XmlEvent::Characters(ref data) => + write!(f, "Characters({:?})", data), + XmlEvent::Whitespace(ref data) => + write!(f, "Whitespace({:?})", data), + }, + Err(ref e) => e.fmt(f), + } + } +} diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/event_writer.rs b/third_party/cargo/vendor/xml-rs-0.8.0/tests/event_writer.rs new file mode 100644 index 0000000..c72f335 --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/event_writer.rs @@ -0,0 +1,222 @@ +extern crate xml; + +use std::io::{BufReader, SeekFrom}; +use std::io::prelude::*; +use std::fs::File; +use std::str; + +use xml::reader::EventReader; +use xml::writer::EmitterConfig; + +macro_rules! unwrap_all { + ($($e:expr);+) => {{ + $($e.unwrap();)+ + }} +} + +#[test] +fn reading_writing_equal_with_namespaces() { + let mut f = File::open("tests/documents/sample_2.xml").unwrap(); + let mut b = Vec::new(); + + { + let r = EventReader::new(BufReader::new(&mut f)); + let mut w = EmitterConfig::default().perform_indent(true).create_writer(&mut b); + + for e in r { + match e { + Ok(e) => if let Some(e) = e.as_writer_event() { + match w.write(e) { + Ok(_) => {}, + Err(e) => panic!("Writer error: {:?}", e) + } + }, + Err(e) => panic!("Error: {}", e) + } + } + } + + f.seek(SeekFrom::Start(0)).unwrap(); + let mut fs = String::new(); + f.read_to_string(&mut fs).unwrap(); + + let bs = String::from_utf8(b).unwrap(); + + assert_eq!(fs.trim(), bs.trim()); +} + +#[test] +fn writing_simple() { + use xml::writer::XmlEvent; + + let mut b = Vec::new(); + + { + let mut w = EmitterConfig::new().write_document_declaration(false).create_writer(&mut b); + + w.write(XmlEvent::start_element("h:hello").ns("h", "urn:hello-world")).unwrap(); + w.write("hello world").unwrap(); + w.write(XmlEvent::end_element()).unwrap(); + } + + assert_eq!( + str::from_utf8(&b).unwrap(), + r#"<h:hello xmlns:h="urn:hello-world">hello world</h:hello>"# + ); +} + +#[test] +fn writing_empty_elements_with_normalizing() { + use xml::writer::XmlEvent; + + let mut b = Vec::new(); + + { + let mut w = EmitterConfig::new().write_document_declaration(false).create_writer(&mut b); + + unwrap_all! { + w.write(XmlEvent::start_element("hello")); + w.write(XmlEvent::start_element("world")); + w.write(XmlEvent::end_element()); + w.write(XmlEvent::end_element()) + } + } + + assert_eq!(str::from_utf8(&b).unwrap(), r#"<hello><world /></hello>"#); +} + +#[test] +fn writing_empty_elements_without_normalizing() { + use xml::writer::XmlEvent; + + let mut b = Vec::new(); + + { + let mut w = EmitterConfig::new() + .write_document_declaration(false) + .normalize_empty_elements(false) + .create_writer(&mut b); + + unwrap_all! { + w.write(XmlEvent::start_element("hello")); + w.write(XmlEvent::start_element("world")); + w.write(XmlEvent::end_element()); + w.write(XmlEvent::end_element()) + } + } + + assert_eq!(str::from_utf8(&b).unwrap(), r#"<hello><world></world></hello>"#); +} + +#[test] +fn writing_comments_with_indentation() { + use xml::writer::XmlEvent; + + let mut b = Vec::new(); + + { + let mut w = EmitterConfig::new() + .write_document_declaration(false) + .perform_indent(true) + .create_writer(&mut b); + + unwrap_all! { + w.write(XmlEvent::start_element("hello")); + w.write(XmlEvent::start_element("world")); + w.write(XmlEvent::comment(" this is a manually padded comment\t")); + w.write(XmlEvent::comment("this is an unpadded comment")); + w.write(XmlEvent::end_element()); + w.write(XmlEvent::end_element()) + } + } + + assert_eq!( + str::from_utf8(&b).unwrap(), + "<hello> + <world> + <!-- this is a manually padded comment\t--> + <!-- this is an unpadded comment --> + </world> +</hello>"); +} + +#[test] +fn issue_112_overriding_namepace_prefix() { + use xml::writer::XmlEvent; + + let mut b = Vec::new(); + + { + let mut w = EmitterConfig::new() + .write_document_declaration(false) + .create_writer(&mut b); + + unwrap_all! { + w.write(XmlEvent::start_element("iq").ns("", "jabber:client").ns("a", "urn:A")); + w.write(XmlEvent::start_element("bind").ns("", "urn:ietf:params:xml:ns:xmpp-bind")); + w.write(XmlEvent::end_element()); + w.write(XmlEvent::start_element("whatever").ns("a", "urn:X")); + w.write(XmlEvent::end_element()); + w.write(XmlEvent::end_element()) + } + } + + assert_eq!( + str::from_utf8(&b).unwrap(), + r#"<iq xmlns="jabber:client" xmlns:a="urn:A"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind" /><whatever xmlns:a="urn:X" /></iq>"# + ) +} + +#[test] +fn attribute_escaping() { + use xml::writer::XmlEvent; + + let mut b = Vec::new(); + + { + let mut w = EmitterConfig::new() + .write_document_declaration(false) + .perform_indent(true) + .create_writer(&mut b); + + unwrap_all! { + w.write( + XmlEvent::start_element("hello") + .attr("testLt", "<") + .attr("testGt", ">") + ); + w.write(XmlEvent::end_element()); + w.write( + XmlEvent::start_element("hello") + .attr("testQuot", "\"") + .attr("testApos", "\'") + ); + w.write(XmlEvent::end_element()); + w.write( + XmlEvent::start_element("hello") + .attr("testAmp", "&") + ); + w.write(XmlEvent::end_element()); + w.write( + XmlEvent::start_element("hello") + .attr("testNl", "\n") + .attr("testCr", "\r") + ); + w.write(XmlEvent::end_element()); + w.write( + XmlEvent::start_element("hello") + .attr("testNl", "\\n") + .attr("testCr", "\\r") + ); + w.write(XmlEvent::end_element()) + } + } + assert_eq!( + str::from_utf8(&b).unwrap(), + "<hello testLt=\"<\" testGt=\">\" /> +<hello testQuot=\""\" testApos=\"'\" /> +<hello testAmp=\"&\" /> +<hello testNl=\" \" testCr=\" \" /> +<hello testNl=\"\\n\" testCr=\"\\r\" />" + ); +} \ No newline at end of file diff --git a/third_party/cargo/vendor/xml-rs-0.8.0/tests/streaming.rs b/third_party/cargo/vendor/xml-rs-0.8.0/tests/streaming.rs new file mode 100644 index 0000000..6353aff --- /dev/null +++ b/third_party/cargo/vendor/xml-rs-0.8.0/tests/streaming.rs @@ -0,0 +1,101 @@ +extern crate xml; + +use std::io::{Cursor, Write}; + +use xml::EventReader; +use xml::reader::ParserConfig; +use xml::reader::XmlEvent; + +macro_rules! assert_match { + ($actual:expr, $expected:pat) => { + match $actual { + $expected => {}, + _ => panic!("assertion failed: `(left matches right)` \ + (left: `{:?}`, right: `{}`", $actual, stringify!($expected)) + } + }; + ($actual:expr, $expected:pat if $guard:expr) => { + match $actual { + $expected if $guard => {}, + _ => panic!("assertion failed: `(left matches right)` \ + (left: `{:?}`, right: `{} if {}`", + $actual, stringify!($expected), stringify!($guard)) + } + } +} + +fn write_and_reset_position<W>(c: &mut Cursor<W>, data: &[u8]) where Cursor<W>: Write { + let p = c.position(); + c.write_all(data).unwrap(); + c.set_position(p); +} + +#[test] +fn reading_streamed_content() { + let buf = Cursor::new(b"<root>".to_vec()); + let reader = EventReader::new(buf); + + let mut it = reader.into_iter(); + + assert_match!(it.next(), Some(Ok(XmlEvent::StartDocument { .. }))); + assert_match!(it.next(), Some(Ok(XmlEvent::StartElement { ref name, .. })) if name.local_name == "root"); + + write_and_reset_position(it.source_mut(), b"<child-1>content</child-1>"); + assert_match!(it.next(), Some(Ok(XmlEvent::StartElement { ref name, .. })) if name.local_name == "child-1"); + assert_match!(it.next(), Some(Ok(XmlEvent::Characters(ref c))) if c == "content"); + assert_match!(it.next(), Some(Ok(XmlEvent::EndElement { ref name })) if name.local_name == "child-1"); + + write_and_reset_position(it.source_mut(), b"<child-2/>"); + assert_match!(it.next(), Some(Ok(XmlEvent::StartElement { ref name, .. })) if name.local_name == "child-2"); + assert_match!(it.next(), Some(Ok(XmlEvent::EndElement { ref name })) if name.local_name == "child-2"); + + write_and_reset_position(it.source_mut(), b"<child-3/>"); + assert_match!(it.next(), Some(Ok(XmlEvent::StartElement { ref name, .. })) if name.local_name == "child-3"); + assert_match!(it.next(), Some(Ok(XmlEvent::EndElement { ref name })) if name.local_name == "child-3"); + // doesn't seem to work because of how tags parsing is done +// write_and_reset_position(it.source_mut(), b"some text"); + // assert_match!(it.next(), Some(Ok(XmlEvent::Characters(ref c))) if c == "some text"); + + write_and_reset_position(it.source_mut(), b"</root>"); + assert_match!(it.next(), Some(Ok(XmlEvent::EndElement { ref name })) if name.local_name == "root"); + assert_match!(it.next(), Some(Ok(XmlEvent::EndDocument))); + assert_match!(it.next(), None); +} + +#[test] +fn reading_streamed_content2() { + let buf = Cursor::new(b"<root>".to_vec()); + let mut config = ParserConfig::new(); + config.ignore_end_of_stream = true; + let readerb = EventReader::new_with_config(buf, config); + + let mut reader = readerb.into_iter(); + + assert_match!(reader.next(), Some(Ok(XmlEvent::StartDocument { .. }))); + assert_match!(reader.next(), Some(Ok(XmlEvent::StartElement { ref name, .. })) if name.local_name == "root"); + + write_and_reset_position(reader.source_mut(), b"<child-1>content</child-1>"); + assert_match!(reader.next(), Some(Ok(XmlEvent::StartElement { ref name, .. })) if name.local_name == "child-1"); + assert_match!(reader.next(), Some(Ok(XmlEvent::Characters(ref c))) if c == "content"); + assert_match!(reader.next(), Some(Ok(XmlEvent::EndElement { ref name })) if name.local_name == "child-1"); + + write_and_reset_position(reader.source_mut(), b"<child-2>content</child-2>"); + + assert_match!(reader.next(), Some(Ok(XmlEvent::StartElement { ref name, .. })) if name.local_name == "child-2"); + assert_match!(reader.next(), Some(Ok(XmlEvent::Characters(ref c))) if c == "content"); + assert_match!(reader.next(), Some(Ok(XmlEvent::EndElement { ref name })) if name.local_name == "child-2"); + assert_match!(reader.next(), Some(Err(_))); + write_and_reset_position(reader.source_mut(), b"<child-3></child-3>"); + assert_match!(reader.next(), Some(Ok(XmlEvent::StartElement { ref name, .. })) if name.local_name == "child-3"); + write_and_reset_position(reader.source_mut(), b"<child-4 type='get'"); + match reader.next() { + None | + Some(Ok(_)) => { + panic!("At this point, parser must not detect something."); + }, + Some(Err(_)) => {} + }; + write_and_reset_position(reader.source_mut(), b" />"); + assert_match!(reader.next(), Some(Ok(XmlEvent::StartElement { ref name, .. })) if name.local_name == "child-4"); +} +

(&mut self, p: P) -> &mut Build + where + P: IntoIterator, + P::Item: AsRef, + { + for file in p.into_iter() { + self.file(file); + } + self + } + + /// Set C++ support. + /// + /// The other `cpp_*` options will only become active if this is set to + /// `true`. + pub fn cpp(&mut self, cpp: bool) -> &mut Build { + self.cpp = cpp; + self + } + + /// Set CUDA C++ support. + /// + /// Enabling CUDA will pass the detected C/C++ toolchain as an argument to + /// the CUDA compiler, NVCC. NVCC itself accepts some limited GNU-like args; + /// any other arguments for the C/C++ toolchain will be redirected using + /// "-Xcompiler" flags. + /// + /// If enabled, this also implicitly enables C++ support. + pub fn cuda(&mut self, cuda: bool) -> &mut Build { + self.cuda = cuda; + if cuda { + self.cpp = true; + } + self + } + + /// Set warnings into errors flag. + /// + /// Disabled by default. + /// + /// Warning: turning warnings into errors only make sense + /// if you are a developer of the crate using cc-rs. + /// Some warnings only appear on some architecture or + /// specific version of the compiler. Any user of this crate, + /// or any other crate depending on it, could fail during + /// compile time. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .warnings_into_errors(true) + /// .compile("libfoo.a"); + /// ``` + pub fn warnings_into_errors(&mut self, warnings_into_errors: bool) -> &mut Build { + self.warnings_into_errors = warnings_into_errors; + self + } + + /// Set warnings flags. + /// + /// Adds some flags: + /// - "-Wall" for MSVC. + /// - "-Wall", "-Wextra" for GNU and Clang. + /// + /// Enabled by default. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .warnings(false) + /// .compile("libfoo.a"); + /// ``` + pub fn warnings(&mut self, warnings: bool) -> &mut Build { + self.warnings = Some(warnings); + self.extra_warnings = Some(warnings); + self + } + + /// Set extra warnings flags. + /// + /// Adds some flags: + /// - nothing for MSVC. + /// - "-Wextra" for GNU and Clang. + /// + /// Enabled by default. + /// + /// # Example + /// + /// ```no_run + /// // Disables -Wextra, -Wall remains enabled: + /// cc::Build::new() + /// .file("src/foo.c") + /// .extra_warnings(false) + /// .compile("libfoo.a"); + /// ``` + pub fn extra_warnings(&mut self, warnings: bool) -> &mut Build { + self.extra_warnings = Some(warnings); + self + } + + /// Set the standard library to link against when compiling with C++ + /// support. + /// + /// The default value of this property depends on the current target: On + /// OS X `Some("c++")` is used, when compiling for a Visual Studio based + /// target `None` is used and for other targets `Some("stdc++")` is used. + /// If the `CXXSTDLIB` environment variable is set, its value will + /// override the default value. + /// + /// A value of `None` indicates that no automatic linking should happen, + /// otherwise cargo will link against the specified library. + /// + /// The given library name must not contain the `lib` prefix. + /// + /// Common values: + /// - `stdc++` for GNU + /// - `c++` for Clang + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .shared_flag(true) + /// .cpp_link_stdlib("stdc++") + /// .compile("libfoo.so"); + /// ``` + pub fn cpp_link_stdlib<'a, V: Into>>( + &mut self, + cpp_link_stdlib: V, + ) -> &mut Build { + self.cpp_link_stdlib = Some(cpp_link_stdlib.into().map(|s| s.into())); + self + } + + /// Force the C++ compiler to use the specified standard library. + /// + /// Setting this option will automatically set `cpp_link_stdlib` to the same + /// value. + /// + /// The default value of this option is always `None`. + /// + /// This option has no effect when compiling for a Visual Studio based + /// target. + /// + /// This option sets the `-stdlib` flag, which is only supported by some + /// compilers (clang, icc) but not by others (gcc). The library will not + /// detect which compiler is used, as such it is the responsibility of the + /// caller to ensure that this option is only used in conjuction with a + /// compiler which supports the `-stdlib` flag. + /// + /// A value of `None` indicates that no specific C++ standard library should + /// be used, otherwise `-stdlib` is added to the compile invocation. + /// + /// The given library name must not contain the `lib` prefix. + /// + /// Common values: + /// - `stdc++` for GNU + /// - `c++` for Clang + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .cpp_set_stdlib("c++") + /// .compile("libfoo.a"); + /// ``` + pub fn cpp_set_stdlib<'a, V: Into>>( + &mut self, + cpp_set_stdlib: V, + ) -> &mut Build { + let cpp_set_stdlib = cpp_set_stdlib.into(); + self.cpp_set_stdlib = cpp_set_stdlib.map(|s| s.into()); + self.cpp_link_stdlib(cpp_set_stdlib); + self + } + + /// Configures the target this configuration will be compiling for. + /// + /// This option is automatically scraped from the `TARGET` environment + /// variable by build scripts, so it's not required to call this function. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .target("aarch64-linux-android") + /// .compile("foo"); + /// ``` + pub fn target(&mut self, target: &str) -> &mut Build { + self.target = Some(target.to_string()); + self + } + + /// Configures the host assumed by this configuration. + /// + /// This option is automatically scraped from the `HOST` environment + /// variable by build scripts, so it's not required to call this function. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .host("arm-linux-gnueabihf") + /// .compile("foo"); + /// ``` + pub fn host(&mut self, host: &str) -> &mut Build { + self.host = Some(host.to_string()); + self + } + + /// Configures the optimization level of the generated object files. + /// + /// This option is automatically scraped from the `OPT_LEVEL` environment + /// variable by build scripts, so it's not required to call this function. + pub fn opt_level(&mut self, opt_level: u32) -> &mut Build { + self.opt_level = Some(opt_level.to_string()); + self + } + + /// Configures the optimization level of the generated object files. + /// + /// This option is automatically scraped from the `OPT_LEVEL` environment + /// variable by build scripts, so it's not required to call this function. + pub fn opt_level_str(&mut self, opt_level: &str) -> &mut Build { + self.opt_level = Some(opt_level.to_string()); + self + } + + /// Configures whether the compiler will emit debug information when + /// generating object files. + /// + /// This option is automatically scraped from the `DEBUG` environment + /// variable by build scripts, so it's not required to call this function. + pub fn debug(&mut self, debug: bool) -> &mut Build { + self.debug = Some(debug); + self + } + + /// Configures whether the compiler will emit instructions to store + /// frame pointers during codegen. + /// + /// This option is automatically enabled when debug information is emitted. + /// Otherwise the target platform compiler's default will be used. + /// You can use this option to force a specific setting. + pub fn force_frame_pointer(&mut self, force: bool) -> &mut Build { + self.force_frame_pointer = Some(force); + self + } + + /// Configures the output directory where all object files and static + /// libraries will be located. + /// + /// This option is automatically scraped from the `OUT_DIR` environment + /// variable by build scripts, so it's not required to call this function. + pub fn out_dir>(&mut self, out_dir: P) -> &mut Build { + self.out_dir = Some(out_dir.as_ref().to_owned()); + self + } + + /// Configures the compiler to be used to produce output. + /// + /// This option is automatically determined from the target platform or a + /// number of environment variables, so it's not required to call this + /// function. + pub fn compiler>(&mut self, compiler: P) -> &mut Build { + self.compiler = Some(compiler.as_ref().to_owned()); + self + } + + /// Configures the tool used to assemble archives. + /// + /// This option is automatically determined from the target platform or a + /// number of environment variables, so it's not required to call this + /// function. + pub fn archiver>(&mut self, archiver: P) -> &mut Build { + self.archiver = Some(archiver.as_ref().to_owned()); + self + } + /// Define whether metadata should be emitted for cargo allowing it to + /// automatically link the binary. Defaults to `true`. + /// + /// The emitted metadata is: + /// + /// - `rustc-link-lib=static=`*compiled lib* + /// - `rustc-link-search=native=`*target folder* + /// - When target is MSVC, the ATL-MFC libs are added via `rustc-link-search=native=` + /// - When C++ is enabled, the C++ stdlib is added via `rustc-link-lib` + /// + pub fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Build { + self.cargo_metadata = cargo_metadata; + self + } + + /// Configures whether the compiler will emit position independent code. + /// + /// This option defaults to `false` for `windows-gnu` and `riscv` targets and + /// to `true` for all other targets. + pub fn pic(&mut self, pic: bool) -> &mut Build { + self.pic = Some(pic); + self + } + + /// Configures whether the Procedure Linkage Table is used for indirect + /// calls into shared libraries. + /// + /// The PLT is used to provide features like lazy binding, but introduces + /// a small performance loss due to extra pointer indirection. Setting + /// `use_plt` to `false` can provide a small performance increase. + /// + /// Note that skipping the PLT requires a recent version of GCC/Clang. + /// + /// This only applies to ELF targets. It has no effect on other platforms. + pub fn use_plt(&mut self, use_plt: bool) -> &mut Build { + self.use_plt = Some(use_plt); + self + } + + /// Configures whether the /MT flag or the /MD flag will be passed to msvc build tools. + /// + /// This option defaults to `false`, and affect only msvc targets. + pub fn static_crt(&mut self, static_crt: bool) -> &mut Build { + self.static_crt = Some(static_crt); + self + } + + #[doc(hidden)] + pub fn __set_env(&mut self, a: A, b: B) -> &mut Build + where + A: AsRef, + B: AsRef, + { + self.env + .push((a.as_ref().to_owned(), b.as_ref().to_owned())); + self + } + + /// Run the compiler, generating the file `output` + /// + /// This will return a result instead of panicing; see compile() for the complete description. + pub fn try_compile(&self, output: &str) -> Result<(), Error> { + let (lib_name, gnu_lib_name) = if output.starts_with("lib") && output.ends_with(".a") { + (&output[3..output.len() - 2], output.to_owned()) + } else { + let mut gnu = String::with_capacity(5 + output.len()); + gnu.push_str("lib"); + gnu.push_str(&output); + gnu.push_str(".a"); + (output, gnu) + }; + let dst = self.get_out_dir()?; + + let mut objects = Vec::new(); + for file in self.files.iter() { + let obj = dst.join(file).with_extension("o"); + let obj = if !obj.starts_with(&dst) { + dst.join(obj.file_name().ok_or_else(|| { + Error::new(ErrorKind::IOError, "Getting object file details failed.") + })?) + } else { + obj + }; + + match obj.parent() { + Some(s) => fs::create_dir_all(s)?, + None => { + return Err(Error::new( + ErrorKind::IOError, + "Getting object file details failed.", + )); + } + }; + + objects.push(Object::new(file.to_path_buf(), obj)); + } + self.compile_objects(&objects)?; + self.assemble(lib_name, &dst.join(gnu_lib_name), &objects)?; + + if self.get_target()?.contains("msvc") { + let compiler = self.get_base_compiler()?; + let atlmfc_lib = compiler + .env() + .iter() + .find(|&&(ref var, _)| var.as_os_str() == OsStr::new("LIB")) + .and_then(|&(_, ref lib_paths)| { + env::split_paths(lib_paths).find(|path| { + let sub = Path::new("atlmfc/lib"); + path.ends_with(sub) || path.parent().map_or(false, |p| p.ends_with(sub)) + }) + }); + + if let Some(atlmfc_lib) = atlmfc_lib { + self.print(&format!( + "cargo:rustc-link-search=native={}", + atlmfc_lib.display() + )); + } + } + + self.print(&format!("cargo:rustc-link-lib=static={}", lib_name)); + self.print(&format!("cargo:rustc-link-search=native={}", dst.display())); + + // Add specific C++ libraries, if enabled. + if self.cpp { + if let Some(stdlib) = self.get_cpp_link_stdlib()? { + self.print(&format!("cargo:rustc-link-lib={}", stdlib)); + } + } + + Ok(()) + } + + /// Run the compiler, generating the file `output` + /// + /// The name `output` should be the name of the library. For backwards compatibility, + /// the `output` may start with `lib` and end with `.a`. The Rust compilier will create + /// the assembly with the lib prefix and .a extension. MSVC will create a file without prefix, + /// ending with `.lib`. + /// + /// # Panics + /// + /// Panics if `output` is not formatted correctly or if one of the underlying + /// compiler commands fails. It can also panic if it fails reading file names + /// or creating directories. + pub fn compile(&self, output: &str) { + if let Err(e) = self.try_compile(output) { + fail(&e.message); + } + } + + #[cfg(feature = "parallel")] + fn compile_objects<'me>(&'me self, objs: &[Object]) -> Result<(), Error> { + use std::sync::atomic::{AtomicBool, Ordering::SeqCst}; + use std::sync::Once; + + // Limit our parallelism globally with a jobserver. Start off by + // releasing our own token for this process so we can have a bit of an + // easier to write loop below. If this fails, though, then we're likely + // on Windows with the main implicit token, so we just have a bit extra + // parallelism for a bit and don't reacquire later. + let server = jobserver(); + let reacquire = server.release_raw().is_ok(); + + // When compiling objects in parallel we do a few dirty tricks to speed + // things up: + // + // * First is that we use the `jobserver` crate to limit the parallelism + // of this build script. The `jobserver` crate will use a jobserver + // configured by Cargo for build scripts to ensure that parallelism is + // coordinated across C compilations and Rust compilations. Before we + // compile anything we make sure to wait until we acquire a token. + // + // Note that this jobserver is cached globally so we only used one per + // process and only worry about creating it once. + // + // * Next we use a raw `thread::spawn` per thread to actually compile + // objects in parallel. We only actually spawn a thread after we've + // acquired a token to perform some work + // + // * Finally though we want to keep the dependencies of this crate + // pretty light, so we avoid using a safe abstraction like `rayon` and + // instead rely on some bits of `unsafe` code. We know that this stack + // frame persists while everything is compiling so we use all the + // stack-allocated objects without cloning/reallocating. We use a + // transmute to `State` with a `'static` lifetime to persist + // everything we need across the boundary, and the join-on-drop + // semantics of `JoinOnDrop` should ensure that our stack frame is + // alive while threads are alive. + // + // With all that in mind we compile all objects in a loop here, after we + // acquire the appropriate tokens, Once all objects have been compiled + // we join on all the threads and propagate the results of compilation. + // + // Note that as a slight optimization we try to break out as soon as + // possible as soon as any compilation fails to ensure that errors get + // out to the user as fast as possible. + let error = AtomicBool::new(false); + let mut threads = Vec::new(); + for obj in objs { + if error.load(SeqCst) { + break; + } + let token = server.acquire()?; + let state = State { + build: self, + obj, + error: &error, + }; + let state = unsafe { std::mem::transmute::>(state) }; + let thread = thread::spawn(|| { + let state: State<'me> = state; // erase the `'static` lifetime + let result = state.build.compile_object(state.obj); + if result.is_err() { + state.error.store(true, SeqCst); + } + drop(token); // make sure our jobserver token is released after the compile + return result; + }); + threads.push(JoinOnDrop(Some(thread))); + } + + for mut thread in threads { + if let Some(thread) = thread.0.take() { + thread.join().expect("thread should not panic")?; + } + } + + // Reacquire our process's token before we proceed, which we released + // before entering the loop above. + if reacquire { + server.acquire_raw()?; + } + + return Ok(()); + + /// Shared state from the parent thread to the child thread. This + /// package of pointers is temporarily transmuted to a `'static` + /// lifetime to cross the thread boundary and then once the thread is + /// running we erase the `'static` to go back to an anonymous lifetime. + struct State<'a> { + build: &'a Build, + obj: &'a Object, + error: &'a AtomicBool, + } + + /// Returns a suitable `jobserver::Client` used to coordinate + /// parallelism between build scripts. + fn jobserver() -> &'static jobserver::Client { + static INIT: Once = Once::new(); + static mut JOBSERVER: Option = None; + + fn _assert_sync() {} + _assert_sync::(); + + unsafe { + INIT.call_once(|| { + let server = default_jobserver(); + JOBSERVER = Some(server); + }); + JOBSERVER.as_ref().unwrap() + } + } + + unsafe fn default_jobserver() -> jobserver::Client { + // Try to use the environmental jobserver which Cargo typically + // initializes for us... + if let Some(client) = jobserver::Client::from_env() { + return client; + } + + // ... but if that fails for whatever reason select something + // reasonable and crate a new jobserver. Use `NUM_JOBS` if set (it's + // configured by Cargo) and otherwise just fall back to a + // semi-reasonable number. Note that we could use `num_cpus` here + // but it's an extra dependency that will almost never be used, so + // it's generally not too worth it. + let mut parallelism = 4; + if let Ok(amt) = env::var("NUM_JOBS") { + if let Ok(amt) = amt.parse() { + parallelism = amt; + } + } + + // If we create our own jobserver then be sure to reserve one token + // for ourselves. + let client = jobserver::Client::new(parallelism).expect("failed to create jobserver"); + client.acquire_raw().expect("failed to acquire initial"); + return client; + } + + struct JoinOnDrop(Option>>); + + impl Drop for JoinOnDrop { + fn drop(&mut self) { + if let Some(thread) = self.0.take() { + drop(thread.join()); + } + } + } + } + + #[cfg(not(feature = "parallel"))] + fn compile_objects(&self, objs: &[Object]) -> Result<(), Error> { + for obj in objs { + self.compile_object(obj)?; + } + Ok(()) + } + + fn compile_object(&self, obj: &Object) -> Result<(), Error> { + let is_asm = obj.src.extension().and_then(|s| s.to_str()) == Some("asm"); + let target = self.get_target()?; + let msvc = target.contains("msvc"); + let (mut cmd, name) = if msvc && is_asm { + self.msvc_macro_assembler()? + } else { + let compiler = self.try_get_compiler()?; + let mut cmd = compiler.to_command(); + for &(ref a, ref b) in self.env.iter() { + cmd.env(a, b); + } + ( + cmd, + compiler + .path + .file_name() + .ok_or_else(|| Error::new(ErrorKind::IOError, "Failed to get compiler path."))? + .to_string_lossy() + .into_owned(), + ) + }; + let is_arm = target.contains("aarch64") || target.contains("arm"); + command_add_output_file(&mut cmd, &obj.dst, self.cuda, msvc, is_asm, is_arm); + // armasm and armasm64 don't requrie -c option + if !msvc || !is_asm || !is_arm { + cmd.arg("-c"); + } + cmd.arg(&obj.src); + + run(&mut cmd, &name)?; + Ok(()) + } + + /// This will return a result instead of panicing; see expand() for the complete description. + pub fn try_expand(&self) -> Result, Error> { + let compiler = self.try_get_compiler()?; + let mut cmd = compiler.to_command(); + for &(ref a, ref b) in self.env.iter() { + cmd.env(a, b); + } + cmd.arg("-E"); + + assert!( + self.files.len() <= 1, + "Expand may only be called for a single file" + ); + + for file in self.files.iter() { + cmd.arg(file); + } + + let name = compiler + .path + .file_name() + .ok_or_else(|| Error::new(ErrorKind::IOError, "Failed to get compiler path."))? + .to_string_lossy() + .into_owned(); + + Ok(run_output(&mut cmd, &name)?) + } + + /// Run the compiler, returning the macro-expanded version of the input files. + /// + /// This is only relevant for C and C++ files. + /// + /// # Panics + /// Panics if more than one file is present in the config, or if compiler + /// path has an invalid file name. + /// + /// # Example + /// ```no_run + /// let out = cc::Build::new().file("src/foo.c").expand(); + /// ``` + pub fn expand(&self) -> Vec { + match self.try_expand() { + Err(e) => fail(&e.message), + Ok(v) => v, + } + } + + /// Get the compiler that's in use for this configuration. + /// + /// This function will return a `Tool` which represents the culmination + /// of this configuration at a snapshot in time. The returned compiler can + /// be inspected (e.g. the path, arguments, environment) to forward along to + /// other tools, or the `to_command` method can be used to invoke the + /// compiler itself. + /// + /// This method will take into account all configuration such as debug + /// information, optimization level, include directories, defines, etc. + /// Additionally, the compiler binary in use follows the standard + /// conventions for this path, e.g. looking at the explicitly set compiler, + /// environment variables (a number of which are inspected here), and then + /// falling back to the default configuration. + /// + /// # Panics + /// + /// Panics if an error occurred while determining the architecture. + pub fn get_compiler(&self) -> Tool { + match self.try_get_compiler() { + Ok(tool) => tool, + Err(e) => fail(&e.message), + } + } + + /// Get the compiler that's in use for this configuration. + /// + /// This will return a result instead of panicing; see get_compiler() for the complete description. + pub fn try_get_compiler(&self) -> Result { + let opt_level = self.get_opt_level()?; + let target = self.get_target()?; + + let mut cmd = self.get_base_compiler()?; + let envflags = self.envflags(if self.cpp { "CXXFLAGS" } else { "CFLAGS" }); + + // Disable default flag generation via `no_default_flags` or environment variable + let no_defaults = self.no_default_flags || self.getenv("CRATE_CC_NO_DEFAULTS").is_some(); + + if !no_defaults { + self.add_default_flags(&mut cmd, &target, &opt_level)?; + } else { + println!("Info: default compiler flags are disabled"); + } + + for arg in envflags { + cmd.push_cc_arg(arg.into()); + } + + for directory in self.include_directories.iter() { + cmd.args.push("-I".into()); + cmd.args.push(directory.into()); + } + + // If warnings and/or extra_warnings haven't been explicitly set, + // then we set them only if the environment doesn't already have + // CFLAGS/CXXFLAGS, since those variables presumably already contain + // the desired set of warnings flags. + + if self + .warnings + .unwrap_or(if self.has_flags() { false } else { true }) + { + let wflags = cmd.family.warnings_flags().into(); + cmd.push_cc_arg(wflags); + } + + if self + .extra_warnings + .unwrap_or(if self.has_flags() { false } else { true }) + { + if let Some(wflags) = cmd.family.extra_warnings_flags() { + cmd.push_cc_arg(wflags.into()); + } + } + + for flag in self.flags.iter() { + cmd.args.push(flag.into()); + } + + for flag in self.flags_supported.iter() { + if self.is_flag_supported(flag).unwrap_or(false) { + cmd.push_cc_arg(flag.into()); + } + } + + for &(ref key, ref value) in self.definitions.iter() { + if let Some(ref value) = *value { + cmd.args.push(format!("-D{}={}", key, value).into()); + } else { + cmd.args.push(format!("-D{}", key).into()); + } + } + + if self.warnings_into_errors { + let warnings_to_errors_flag = cmd.family.warnings_to_errors_flag().into(); + cmd.push_cc_arg(warnings_to_errors_flag); + } + + Ok(cmd) + } + + fn add_default_flags( + &self, + cmd: &mut Tool, + target: &str, + opt_level: &str, + ) -> Result<(), Error> { + // Non-target flags + // If the flag is not conditioned on target variable, it belongs here :) + match cmd.family { + ToolFamily::Msvc { .. } => { + cmd.push_cc_arg("-nologo".into()); + + let crt_flag = match self.static_crt { + Some(true) => "-MT", + Some(false) => "-MD", + None => { + let features = self + .getenv("CARGO_CFG_TARGET_FEATURE") + .unwrap_or(String::new()); + if features.contains("crt-static") { + "-MT" + } else { + "-MD" + } + } + }; + cmd.push_cc_arg(crt_flag.into()); + + match &opt_level[..] { + // Msvc uses /O1 to enable all optimizations that minimize code size. + "z" | "s" | "1" => cmd.push_opt_unless_duplicate("-O1".into()), + // -O3 is a valid value for gcc and clang compilers, but not msvc. Cap to /O2. + "2" | "3" => cmd.push_opt_unless_duplicate("-O2".into()), + _ => {} + } + } + ToolFamily::Gnu | ToolFamily::Clang => { + // arm-linux-androideabi-gcc 4.8 shipped with Android NDK does + // not support '-Oz' + if opt_level == "z" && cmd.family != ToolFamily::Clang { + cmd.push_opt_unless_duplicate("-Os".into()); + } else { + cmd.push_opt_unless_duplicate(format!("-O{}", opt_level).into()); + } + + if !target.contains("-ios") { + cmd.push_cc_arg("-ffunction-sections".into()); + cmd.push_cc_arg("-fdata-sections".into()); + } + // Disable generation of PIC on bare-metal RISC-V for now: rust-lld doesn't support this yet + if self.pic.unwrap_or( + !target.contains("windows-gnu") + && !(target.contains("riscv") && target.contains("-none-")), + ) { + cmd.push_cc_arg("-fPIC".into()); + // PLT only applies if code is compiled with PIC support, + // and only for ELF targets. + if target.contains("linux") && !self.use_plt.unwrap_or(true) { + cmd.push_cc_arg("-fno-plt".into()); + } + } + } + } + + if self.get_debug() { + if self.cuda { + // NVCC debug flag + cmd.args.push("-G".into()); + } + let family = cmd.family; + family.add_debug_flags(cmd); + } + + if self.get_force_frame_pointer() { + let family = cmd.family; + family.add_force_frame_pointer(cmd); + } + + // Target flags + match cmd.family { + ToolFamily::Clang => { + cmd.args.push(format!("--target={}", target).into()); + } + ToolFamily::Msvc { clang_cl } => { + // This is an undocumented flag from MSVC but helps with making + // builds more reproducible by avoiding putting timestamps into + // files. + cmd.args.push("-Brepro".into()); + + if clang_cl { + if target.contains("x86_64") { + cmd.args.push("-m64".into()); + } else if target.contains("86") { + cmd.args.push("-m32".into()); + cmd.push_cc_arg("-arch:IA32".into()); + } else { + cmd.push_cc_arg(format!("--target={}", target).into()); + } + } else { + if target.contains("i586") { + cmd.push_cc_arg("-arch:IA32".into()); + } + } + + // There is a check in corecrt.h that will generate a + // compilation error if + // _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE is + // not defined to 1. The check was added in Windows + // 8 days because only store apps were allowed on ARM. + // This changed with the release of Windows 10 IoT Core. + // The check will be going away in future versions of + // the SDK, but for all released versions of the + // Windows SDK it is required. + if target.contains("arm") || target.contains("thumb") { + cmd.args + .push("-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1".into()); + } + } + ToolFamily::Gnu => { + if target.contains("i686") || target.contains("i586") { + cmd.args.push("-m32".into()); + } else if target == "x86_64-unknown-linux-gnux32" { + cmd.args.push("-mx32".into()); + } else if target.contains("x86_64") || target.contains("powerpc64") { + cmd.args.push("-m64".into()); + } + + if self.static_flag.is_none() { + let features = self + .getenv("CARGO_CFG_TARGET_FEATURE") + .unwrap_or(String::new()); + if features.contains("crt-static") { + cmd.args.push("-static".into()); + } + } + + // armv7 targets get to use armv7 instructions + if (target.starts_with("armv7") || target.starts_with("thumbv7")) + && target.contains("-linux-") + { + cmd.args.push("-march=armv7-a".into()); + } + + // (x86 Android doesn't say "eabi") + if target.contains("-androideabi") && target.contains("v7") { + // -march=armv7-a handled above + cmd.args.push("-mthumb".into()); + if !target.contains("neon") { + // On android we can guarantee some extra float instructions + // (specified in the android spec online) + // NEON guarantees even more; see below. + cmd.args.push("-mfpu=vfpv3-d16".into()); + } + cmd.args.push("-mfloat-abi=softfp".into()); + } + + if target.contains("neon") { + cmd.args.push("-mfpu=neon-vfpv4".into()); + } + + if target.starts_with("armv4t-unknown-linux-") { + cmd.args.push("-march=armv4t".into()); + cmd.args.push("-marm".into()); + cmd.args.push("-mfloat-abi=soft".into()); + } + + if target.starts_with("armv5te-unknown-linux-") { + cmd.args.push("-march=armv5te".into()); + cmd.args.push("-marm".into()); + cmd.args.push("-mfloat-abi=soft".into()); + } + + // For us arm == armv6 by default + if target.starts_with("arm-unknown-linux-") { + cmd.args.push("-march=armv6".into()); + cmd.args.push("-marm".into()); + if target.ends_with("hf") { + cmd.args.push("-mfpu=vfp".into()); + } else { + cmd.args.push("-mfloat-abi=soft".into()); + } + } + + // We can guarantee some settings for FRC + if target.starts_with("arm-frc-") { + cmd.args.push("-march=armv7-a".into()); + cmd.args.push("-mcpu=cortex-a9".into()); + cmd.args.push("-mfpu=vfpv3".into()); + cmd.args.push("-mfloat-abi=softfp".into()); + cmd.args.push("-marm".into()); + } + + // Turn codegen down on i586 to avoid some instructions. + if target.starts_with("i586-unknown-linux-") { + cmd.args.push("-march=pentium".into()); + } + + // Set codegen level for i686 correctly + if target.starts_with("i686-unknown-linux-") { + cmd.args.push("-march=i686".into()); + } + + // Looks like `musl-gcc` makes is hard for `-m32` to make its way + // all the way to the linker, so we need to actually instruct the + // linker that we're generating 32-bit executables as well. This'll + // typically only be used for build scripts which transitively use + // these flags that try to compile executables. + if target == "i686-unknown-linux-musl" || target == "i586-unknown-linux-musl" { + cmd.args.push("-Wl,-melf_i386".into()); + } + + if target.starts_with("thumb") { + cmd.args.push("-mthumb".into()); + + if target.ends_with("eabihf") { + cmd.args.push("-mfloat-abi=hard".into()) + } + } + if target.starts_with("thumbv6m") { + cmd.args.push("-march=armv6s-m".into()); + } + if target.starts_with("thumbv7em") { + cmd.args.push("-march=armv7e-m".into()); + + if target.ends_with("eabihf") { + cmd.args.push("-mfpu=fpv4-sp-d16".into()) + } + } + if target.starts_with("thumbv7m") { + cmd.args.push("-march=armv7-m".into()); + } + if target.starts_with("thumbv8m.base") { + cmd.args.push("-march=armv8-m.base".into()); + } + if target.starts_with("thumbv8m.main") { + cmd.args.push("-march=armv8-m.main".into()); + + if target.ends_with("eabihf") { + cmd.args.push("-mfpu=fpv5-sp-d16".into()) + } + } + if target.starts_with("armebv7r") | target.starts_with("armv7r") { + if target.starts_with("armeb") { + cmd.args.push("-mbig-endian".into()); + } else { + cmd.args.push("-mlittle-endian".into()); + } + + // ARM mode + cmd.args.push("-marm".into()); + + // R Profile + cmd.args.push("-march=armv7-r".into()); + + if target.ends_with("eabihf") { + // Calling convention + cmd.args.push("-mfloat-abi=hard".into()); + + // lowest common denominator FPU + // (see Cortex-R4 technical reference manual) + cmd.args.push("-mfpu=vfpv3-d16".into()) + } else { + // Calling convention + cmd.args.push("-mfloat-abi=soft".into()); + } + } + if target.starts_with("riscv32") || target.starts_with("riscv64") { + // get the 32i/32imac/32imc/64gc/64imac/... part + let mut parts = target.split('-'); + if let Some(arch) = parts.next() { + let arch = &arch[5..]; + cmd.args.push(("-march=rv".to_owned() + arch).into()); + if target.contains("linux") && arch.starts_with("64") { + cmd.args.push("-mabi=lp64d".into()); + } else if target.contains("linux") && arch.starts_with("32") { + cmd.args.push("-mabi=ilp32d".into()); + } else if arch.starts_with("64") { + cmd.args.push("-mabi=lp64".into()); + } else { + cmd.args.push("-mabi=ilp32".into()); + } + } + } + } + } + + if target.contains("-ios") { + // FIXME: potential bug. iOS is always compiled with Clang, but Gcc compiler may be + // detected instead. + self.ios_flags(cmd)?; + } + + if self.static_flag.unwrap_or(false) { + cmd.args.push("-static".into()); + } + if self.shared_flag.unwrap_or(false) { + cmd.args.push("-shared".into()); + } + + if self.cpp { + match (self.cpp_set_stdlib.as_ref(), cmd.family) { + (None, _) => {} + (Some(stdlib), ToolFamily::Gnu) | (Some(stdlib), ToolFamily::Clang) => { + cmd.push_cc_arg(format!("-stdlib=lib{}", stdlib).into()); + } + _ => { + println!( + "cargo:warning=cpp_set_stdlib is specified, but the {:?} compiler \ + does not support this option, ignored", + cmd.family + ); + } + } + } + + Ok(()) + } + + fn has_flags(&self) -> bool { + let flags_env_var_name = if self.cpp { "CXXFLAGS" } else { "CFLAGS" }; + let flags_env_var_value = self.get_var(flags_env_var_name); + if let Ok(_) = flags_env_var_value { + true + } else { + false + } + } + + fn msvc_macro_assembler(&self) -> Result<(Command, String), Error> { + let target = self.get_target()?; + let tool = if target.contains("x86_64") { + "ml64.exe" + } else if target.contains("arm") { + "armasm.exe" + } else if target.contains("aarch64") { + "armasm64.exe" + } else { + "ml.exe" + }; + let mut cmd = windows_registry::find(&target, tool).unwrap_or_else(|| self.cmd(tool)); + for directory in self.include_directories.iter() { + cmd.arg("-I").arg(directory); + } + for &(ref key, ref value) in self.definitions.iter() { + if let Some(ref value) = *value { + cmd.arg(&format!("-D{}={}", key, value)); + } else { + cmd.arg(&format!("-D{}", key)); + } + } + + if target.contains("i686") || target.contains("i586") { + cmd.arg("-safeseh"); + } + for flag in self.flags.iter() { + cmd.arg(flag); + } + + Ok((cmd, tool.to_string())) + } + + fn assemble(&self, lib_name: &str, dst: &Path, objs: &[Object]) -> Result<(), Error> { + // Delete the destination if it exists as the `ar` tool at least on Unix + // appends to it, which we don't want. + let _ = fs::remove_file(&dst); + + let objects: Vec<_> = objs.iter().map(|obj| obj.dst.clone()).collect(); + let target = self.get_target()?; + if target.contains("msvc") { + let (mut cmd, program) = self.get_ar()?; + let mut out = OsString::from("-out:"); + out.push(dst); + cmd.arg(out).arg("-nologo"); + for flag in self.ar_flags.iter() { + cmd.arg(flag); + } + + // Similar to https://github.com/rust-lang/rust/pull/47507 + // and https://github.com/rust-lang/rust/pull/48548 + let estimated_command_line_len = objects + .iter() + .chain(&self.objects) + .map(|a| a.as_os_str().len()) + .sum::(); + if estimated_command_line_len > 1024 * 6 { + let mut args = String::from("\u{FEFF}"); // BOM + for arg in objects.iter().chain(&self.objects) { + args.push('"'); + for c in arg.to_str().unwrap().chars() { + if c == '"' { + args.push('\\') + } + args.push(c) + } + args.push('"'); + args.push('\n'); + } + + let mut utf16le = Vec::new(); + for code_unit in args.encode_utf16() { + utf16le.push(code_unit as u8); + utf16le.push((code_unit >> 8) as u8); + } + + let mut args_file = OsString::from(dst); + args_file.push(".args"); + fs::File::create(&args_file) + .unwrap() + .write_all(&utf16le) + .unwrap(); + + let mut args_file_arg = OsString::from("@"); + args_file_arg.push(args_file); + cmd.arg(args_file_arg); + } else { + cmd.args(&objects).args(&self.objects); + } + run(&mut cmd, &program)?; + + // The Rust compiler will look for libfoo.a and foo.lib, but the + // MSVC linker will also be passed foo.lib, so be sure that both + // exist for now. + let lib_dst = dst.with_file_name(format!("{}.lib", lib_name)); + let _ = fs::remove_file(&lib_dst); + match fs::hard_link(&dst, &lib_dst).or_else(|_| { + // if hard-link fails, just copy (ignoring the number of bytes written) + fs::copy(&dst, &lib_dst).map(|_| ()) + }) { + Ok(_) => (), + Err(_) => { + return Err(Error::new( + ErrorKind::IOError, + "Could not copy or create a hard-link to the generated lib file.", + )); + } + }; + } else { + let (mut ar, cmd) = self.get_ar()?; + + // Set an environment variable to tell the OSX archiver to ensure + // that all dates listed in the archive are zero, improving + // determinism of builds. AFAIK there's not really official + // documentation of this but there's a lot of references to it if + // you search google. + // + // You can reproduce this locally on a mac with: + // + // $ touch foo.c + // $ cc -c foo.c -o foo.o + // + // # Notice that these two checksums are different + // $ ar crus libfoo1.a foo.o && sleep 2 && ar crus libfoo2.a foo.o + // $ md5sum libfoo*.a + // + // # Notice that these two checksums are the same + // $ export ZERO_AR_DATE=1 + // $ ar crus libfoo1.a foo.o && sleep 2 && touch foo.o && ar crus libfoo2.a foo.o + // $ md5sum libfoo*.a + // + // In any case if this doesn't end up getting read, it shouldn't + // cause that many issues! + ar.env("ZERO_AR_DATE", "1"); + for flag in self.ar_flags.iter() { + ar.arg(flag); + } + run( + ar.arg("crs").arg(dst).args(&objects).args(&self.objects), + &cmd, + )?; + } + + Ok(()) + } + + fn ios_flags(&self, cmd: &mut Tool) -> Result<(), Error> { + enum ArchSpec { + Device(&'static str), + Simulator(&'static str), + } + + let target = self.get_target()?; + let arch = target.split('-').nth(0).ok_or_else(|| { + Error::new( + ErrorKind::ArchitectureInvalid, + "Unknown architecture for iOS target.", + ) + })?; + let arch = match arch { + "arm" | "armv7" | "thumbv7" => ArchSpec::Device("armv7"), + "armv7s" | "thumbv7s" => ArchSpec::Device("armv7s"), + "arm64" | "aarch64" => ArchSpec::Device("arm64"), + "i386" | "i686" => ArchSpec::Simulator("-m32"), + "x86_64" => ArchSpec::Simulator("-m64"), + _ => { + return Err(Error::new( + ErrorKind::ArchitectureInvalid, + "Unknown architecture for iOS target.", + )); + } + }; + + let min_version = + std::env::var("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or_else(|_| "7.0".into()); + + let sdk = match arch { + ArchSpec::Device(arch) => { + cmd.args.push("-arch".into()); + cmd.args.push(arch.into()); + cmd.args + .push(format!("-miphoneos-version-min={}", min_version).into()); + "iphoneos" + } + ArchSpec::Simulator(arch) => { + cmd.args.push(arch.into()); + cmd.args + .push(format!("-mios-simulator-version-min={}", min_version).into()); + "iphonesimulator" + } + }; + + self.print(&format!("Detecting iOS SDK path for {}", sdk)); + let sdk_path = self + .cmd("xcrun") + .arg("--show-sdk-path") + .arg("--sdk") + .arg(sdk) + .stderr(Stdio::inherit()) + .output()? + .stdout; + + let sdk_path = match String::from_utf8(sdk_path) { + Ok(p) => p, + Err(_) => { + return Err(Error::new( + ErrorKind::IOError, + "Unable to determine iOS SDK path.", + )); + } + }; + + cmd.args.push("-isysroot".into()); + cmd.args.push(sdk_path.trim().into()); + cmd.args.push("-fembed-bitcode".into()); + /* + * TODO we probably ultimatedly want the -fembed-bitcode-marker flag + * but can't have it now because of an issue in LLVM: + * https://github.com/alexcrichton/cc-rs/issues/301 + * https://github.com/rust-lang/rust/pull/48896#comment-372192660 + */ + /* + if self.get_opt_level()? == "0" { + cmd.args.push("-fembed-bitcode-marker".into()); + } + */ + + Ok(()) + } + + fn cmd>(&self, prog: P) -> Command { + let mut cmd = Command::new(prog); + for &(ref a, ref b) in self.env.iter() { + cmd.env(a, b); + } + cmd + } + + fn get_base_compiler(&self) -> Result { + if let Some(ref c) = self.compiler { + return Ok(Tool::new(c.clone())); + } + let host = self.get_host()?; + let target = self.get_target()?; + let (env, msvc, gnu, traditional, clang) = if self.cpp { + ("CXX", "cl.exe", "g++", "c++", "clang++") + } else { + ("CC", "cl.exe", "gcc", "cc", "clang") + }; + + // On Solaris, c++/cc unlikely to exist or be correct. + let default = if host.contains("solaris") { + gnu + } else { + traditional + }; + + let cl_exe = windows_registry::find_tool(&target, "cl.exe"); + + let tool_opt: Option = self + .env_tool(env) + .map(|(tool, wrapper, args)| { + // find the driver mode, if any + const DRIVER_MODE: &str = "--driver-mode="; + let driver_mode = args + .iter() + .find(|a| a.starts_with(DRIVER_MODE)) + .map(|a| &a[DRIVER_MODE.len()..]); + // chop off leading/trailing whitespace to work around + // semi-buggy build scripts which are shared in + // makefiles/configure scripts (where spaces are far more + // lenient) + let mut t = Tool::with_clang_driver(PathBuf::from(tool.trim()), driver_mode); + if let Some(cc) = wrapper { + t.cc_wrapper_path = Some(PathBuf::from(cc)); + } + for arg in args { + t.cc_wrapper_args.push(arg.into()); + } + t + }) + .or_else(|| { + if target.contains("emscripten") { + let tool = if self.cpp { "em++" } else { "emcc" }; + // Windows uses bat file so we have to be a bit more specific + if cfg!(windows) { + let mut t = Tool::new(PathBuf::from("cmd")); + t.args.push("/c".into()); + t.args.push(format!("{}.bat", tool).into()); + Some(t) + } else { + Some(Tool::new(PathBuf::from(tool))) + } + } else { + None + } + }) + .or_else(|| cl_exe.clone()); + + let tool = match tool_opt { + Some(t) => t, + None => { + let compiler = if host.contains("windows") && target.contains("windows") { + if target.contains("msvc") { + msvc.to_string() + } else { + format!("{}.exe", gnu) + } + } else if target.contains("android") { + let target = target + .replace("armv7neon", "arm") + .replace("armv7", "arm") + .replace("thumbv7neon", "arm") + .replace("thumbv7", "arm"); + let gnu_compiler = format!("{}-{}", target, gnu); + let clang_compiler = format!("{}-{}", target, clang); + // Check if gnu compiler is present + // if not, use clang + if Command::new(&gnu_compiler).spawn().is_ok() { + gnu_compiler + } else { + clang_compiler + } + } else if target.contains("cloudabi") { + format!("{}-{}", target, traditional) + } else if target == "wasm32-wasi" + || target == "wasm32-unknown-wasi" + || target == "wasm32-unknown-unknown" + { + "clang".to_string() + } else if target.contains("vxworks") { + "wr-c++".to_string() + } else if self.get_host()? != target { + // CROSS_COMPILE is of the form: "arm-linux-gnueabi-" + let cc_env = self.getenv("CROSS_COMPILE"); + let cross_compile = cc_env.as_ref().map(|s| s.trim_right_matches('-')); + let prefix = cross_compile.or(match &target[..] { + "aarch64-unknown-linux-gnu" => Some("aarch64-linux-gnu"), + "aarch64-unknown-linux-musl" => Some("aarch64-linux-musl"), + "aarch64-unknown-netbsd" => Some("aarch64--netbsd"), + "arm-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"), + "armv4t-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"), + "armv5te-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"), + "arm-frc-linux-gnueabi" => Some("arm-frc-linux-gnueabi"), + "arm-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), + "arm-unknown-linux-musleabi" => Some("arm-linux-musleabi"), + "arm-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), + "arm-unknown-netbsd-eabi" => Some("arm--netbsdelf-eabi"), + "armv6-unknown-netbsd-eabihf" => Some("armv6--netbsdelf-eabihf"), + "armv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), + "armv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), + "armv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), + "armv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), + "thumbv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), + "thumbv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), + "thumbv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), + "thumbv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), + "armv7-unknown-netbsd-eabihf" => Some("armv7--netbsdelf-eabihf"), + "i586-unknown-linux-musl" => Some("musl"), + "i686-pc-windows-gnu" => Some("i686-w64-mingw32"), + "i686-uwp-windows-gnu" => Some("i686-w64-mingw32"), + "i686-unknown-linux-musl" => Some("musl"), + "i686-unknown-netbsd" => Some("i486--netbsdelf"), + "mips-unknown-linux-gnu" => Some("mips-linux-gnu"), + "mipsel-unknown-linux-gnu" => Some("mipsel-linux-gnu"), + "mips64-unknown-linux-gnuabi64" => Some("mips64-linux-gnuabi64"), + "mips64el-unknown-linux-gnuabi64" => Some("mips64el-linux-gnuabi64"), + "mipsisa32r6-unknown-linux-gnu" => Some("mipsisa32r6-linux-gnu"), + "mipsisa32r6el-unknown-linux-gnu" => Some("mipsisa32r6el-linux-gnu"), + "mipsisa64r6-unknown-linux-gnuabi64" => Some("mipsisa64r6-linux-gnuabi64"), + "mipsisa64r6el-unknown-linux-gnuabi64" => { + Some("mipsisa64r6el-linux-gnuabi64") + } + "powerpc-unknown-linux-gnu" => Some("powerpc-linux-gnu"), + "powerpc-unknown-linux-gnuspe" => Some("powerpc-linux-gnuspe"), + "powerpc-unknown-netbsd" => Some("powerpc--netbsd"), + "powerpc64-unknown-linux-gnu" => Some("powerpc-linux-gnu"), + "powerpc64le-unknown-linux-gnu" => Some("powerpc64le-linux-gnu"), + "riscv32i-unknown-none-elf" => Some("riscv32-unknown-elf"), + "riscv32imac-unknown-none-elf" => Some("riscv32-unknown-elf"), + "riscv32imc-unknown-none-elf" => Some("riscv32-unknown-elf"), + "riscv64gc-unknown-none-elf" => Some("riscv64-unknown-elf"), + "riscv64imac-unknown-none-elf" => Some("riscv64-unknown-elf"), + "riscv64gc-unknown-linux-gnu" => Some("riscv64-linux-gnu"), + "s390x-unknown-linux-gnu" => Some("s390x-linux-gnu"), + "sparc-unknown-linux-gnu" => Some("sparc-linux-gnu"), + "sparc64-unknown-linux-gnu" => Some("sparc64-linux-gnu"), + "sparc64-unknown-netbsd" => Some("sparc64--netbsd"), + "sparcv9-sun-solaris" => Some("sparcv9-sun-solaris"), + "armebv7r-none-eabi" => Some("arm-none-eabi"), + "armebv7r-none-eabihf" => Some("arm-none-eabi"), + "armv7r-none-eabi" => Some("arm-none-eabi"), + "armv7r-none-eabihf" => Some("arm-none-eabi"), + "thumbv6m-none-eabi" => Some("arm-none-eabi"), + "thumbv7em-none-eabi" => Some("arm-none-eabi"), + "thumbv7em-none-eabihf" => Some("arm-none-eabi"), + "thumbv7m-none-eabi" => Some("arm-none-eabi"), + "thumbv8m.base-none-eabi" => Some("arm-none-eabi"), + "thumbv8m.main-none-eabi" => Some("arm-none-eabi"), + "thumbv8m.main-none-eabihf" => Some("arm-none-eabi"), + "x86_64-pc-windows-gnu" => Some("x86_64-w64-mingw32"), + "x86_64-uwp-windows-gnu" => Some("x86_64-w64-mingw32"), + "x86_64-rumprun-netbsd" => Some("x86_64-rumprun-netbsd"), + "x86_64-unknown-linux-musl" => Some("musl"), + "x86_64-unknown-netbsd" => Some("x86_64--netbsd"), + _ => None, + }); + match prefix { + Some(prefix) => format!("{}-{}", prefix, gnu), + None => default.to_string(), + } + } else { + default.to_string() + }; + Tool::new(PathBuf::from(compiler)) + } + }; + + let mut tool = if self.cuda { + assert!( + tool.args.is_empty(), + "CUDA compilation currently assumes empty pre-existing args" + ); + let nvcc = match self.get_var("NVCC") { + Err(_) => "nvcc".into(), + Ok(nvcc) => nvcc, + }; + let mut nvcc_tool = Tool::with_features(PathBuf::from(nvcc), None, self.cuda); + nvcc_tool + .args + .push(format!("-ccbin={}", tool.path.display()).into()); + nvcc_tool.family = tool.family; + nvcc_tool + } else { + tool + }; + + // If we found `cl.exe` in our environment, the tool we're returning is + // an MSVC-like tool, *and* no env vars were set then set env vars for + // the tool that we're returning. + // + // Env vars are needed for things like `link.exe` being put into PATH as + // well as header include paths sometimes. These paths are automatically + // included by default but if the `CC` or `CXX` env vars are set these + // won't be used. This'll ensure that when the env vars are used to + // configure for invocations like `clang-cl` we still get a "works out + // of the box" experience. + if let Some(cl_exe) = cl_exe { + if tool.family == (ToolFamily::Msvc { clang_cl: true }) + && tool.env.len() == 0 + && target.contains("msvc") + { + for &(ref k, ref v) in cl_exe.env.iter() { + tool.env.push((k.to_owned(), v.to_owned())); + } + } + } + + Ok(tool) + } + + fn get_var(&self, var_base: &str) -> Result { + let target = self.get_target()?; + let host = self.get_host()?; + let kind = if host == target { "HOST" } else { "TARGET" }; + let target_u = target.replace("-", "_"); + let res = self + .getenv(&format!("{}_{}", var_base, target)) + .or_else(|| self.getenv(&format!("{}_{}", var_base, target_u))) + .or_else(|| self.getenv(&format!("{}_{}", kind, var_base))) + .or_else(|| self.getenv(var_base)); + + match res { + Some(res) => Ok(res), + None => Err(Error::new( + ErrorKind::EnvVarNotFound, + &format!("Could not find environment variable {}.", var_base), + )), + } + } + + fn envflags(&self, name: &str) -> Vec { + self.get_var(name) + .unwrap_or(String::new()) + .split(|c: char| c.is_whitespace()) + .filter(|s| !s.is_empty()) + .map(|s| s.to_string()) + .collect() + } + + /// Returns compiler path, optional modifier name from whitelist, and arguments vec + fn env_tool(&self, name: &str) -> Option<(String, Option, Vec)> { + let tool = match self.get_var(name) { + Ok(tool) => tool, + Err(_) => return None, + }; + + // If this is an exact path on the filesystem we don't want to do any + // interpretation at all, just pass it on through. This'll hopefully get + // us to support spaces-in-paths. + if Path::new(&tool).exists() { + return Some((tool, None, Vec::new())); + } + + // Ok now we want to handle a couple of scenarios. We'll assume from + // here on out that spaces are splitting separate arguments. Two major + // features we want to support are: + // + // CC='sccache cc' + // + // aka using `sccache` or any other wrapper/caching-like-thing for + // compilations. We want to know what the actual compiler is still, + // though, because our `Tool` API support introspection of it to see + // what compiler is in use. + // + // additionally we want to support + // + // CC='cc -flag' + // + // where the CC env var is used to also pass default flags to the C + // compiler. + // + // It's true that everything here is a bit of a pain, but apparently if + // you're not literally make or bash then you get a lot of bug reports. + let known_wrappers = ["ccache", "distcc", "sccache", "icecc"]; + + let mut parts = tool.split_whitespace(); + let maybe_wrapper = match parts.next() { + Some(s) => s, + None => return None, + }; + + let file_stem = Path::new(maybe_wrapper) + .file_stem() + .unwrap() + .to_str() + .unwrap(); + if known_wrappers.contains(&file_stem) { + if let Some(compiler) = parts.next() { + return Some(( + compiler.to_string(), + Some(maybe_wrapper.to_string()), + parts.map(|s| s.to_string()).collect(), + )); + } + } + + Some(( + maybe_wrapper.to_string(), + None, + parts.map(|s| s.to_string()).collect(), + )) + } + + /// Returns the default C++ standard library for the current target: `libc++` + /// for OS X and `libstdc++` for anything else. + fn get_cpp_link_stdlib(&self) -> Result, Error> { + match self.cpp_link_stdlib.clone() { + Some(s) => Ok(s), + None => { + if let Ok(stdlib) = self.get_var("CXXSTDLIB") { + if stdlib.is_empty() { + Ok(None) + } else { + Ok(Some(stdlib)) + } + } else { + let target = self.get_target()?; + if target.contains("msvc") { + Ok(None) + } else if target.contains("apple") { + Ok(Some("c++".to_string())) + } else if target.contains("freebsd") { + Ok(Some("c++".to_string())) + } else if target.contains("openbsd") { + Ok(Some("c++".to_string())) + } else { + Ok(Some("stdc++".to_string())) + } + } + } + } + } + + fn get_ar(&self) -> Result<(Command, String), Error> { + if let Some(ref p) = self.archiver { + let name = p.file_name().and_then(|s| s.to_str()).unwrap_or("ar"); + return Ok((self.cmd(p), name.to_string())); + } + if let Ok(p) = self.get_var("AR") { + return Ok((self.cmd(&p), p)); + } + let target = self.get_target()?; + let program = if target.contains("android") { + format!("{}-ar", target.replace("armv7", "arm")) + } else if target.contains("emscripten") { + // Windows use bat files so we have to be a bit more specific + if cfg!(windows) { + let mut cmd = self.cmd("cmd"); + cmd.arg("/c").arg("emar.bat"); + return Ok((cmd, "emar.bat".to_string())); + } + + "emar".to_string() + } else if target.contains("msvc") { + match windows_registry::find(&target, "lib.exe") { + Some(t) => return Ok((t, "lib.exe".to_string())), + None => "lib.exe".to_string(), + } + } else { + "ar".to_string() + }; + Ok((self.cmd(&program), program)) + } + + fn get_target(&self) -> Result { + match self.target.clone() { + Some(t) => Ok(t), + None => Ok(self.getenv_unwrap("TARGET")?), + } + } + + fn get_host(&self) -> Result { + match self.host.clone() { + Some(h) => Ok(h), + None => Ok(self.getenv_unwrap("HOST")?), + } + } + + fn get_opt_level(&self) -> Result { + match self.opt_level.as_ref().cloned() { + Some(ol) => Ok(ol), + None => Ok(self.getenv_unwrap("OPT_LEVEL")?), + } + } + + fn get_debug(&self) -> bool { + self.debug.unwrap_or_else(|| match self.getenv("DEBUG") { + Some(s) => s != "false", + None => false, + }) + } + + fn get_force_frame_pointer(&self) -> bool { + self.force_frame_pointer.unwrap_or_else(|| self.get_debug()) + } + + fn get_out_dir(&self) -> Result { + match self.out_dir.clone() { + Some(p) => Ok(p), + None => Ok(env::var_os("OUT_DIR").map(PathBuf::from).ok_or_else(|| { + Error::new( + ErrorKind::EnvVarNotFound, + "Environment variable OUT_DIR not defined.", + ) + })?), + } + } + + fn getenv(&self, v: &str) -> Option { + let mut cache = self.env_cache.lock().unwrap(); + if let Some(val) = cache.get(v) { + return val.clone(); + } + let r = env::var(v).ok(); + self.print(&format!("{} = {:?}", v, r)); + cache.insert(v.to_string(), r.clone()); + r + } + + fn getenv_unwrap(&self, v: &str) -> Result { + match self.getenv(v) { + Some(s) => Ok(s), + None => Err(Error::new( + ErrorKind::EnvVarNotFound, + &format!("Environment variable {} not defined.", v.to_string()), + )), + } + } + + fn print(&self, s: &str) { + if self.cargo_metadata { + println!("{}", s); + } + } +} + +impl Default for Build { + fn default() -> Build { + Build::new() + } +} + +impl Tool { + fn new(path: PathBuf) -> Self { + Tool::with_features(path, None, false) + } + + fn with_clang_driver(path: PathBuf, clang_driver: Option<&str>) -> Self { + Self::with_features(path, clang_driver, false) + } + + fn with_features(path: PathBuf, clang_driver: Option<&str>, cuda: bool) -> Self { + // Try to detect family of the tool from its name, falling back to Gnu. + let family = if let Some(fname) = path.file_name().and_then(|p| p.to_str()) { + if fname.contains("clang-cl") { + ToolFamily::Msvc { clang_cl: true } + } else if fname.contains("cl") + && !fname.contains("cloudabi") + && !fname.contains("uclibc") + && !fname.contains("clang") + { + ToolFamily::Msvc { clang_cl: false } + } else if fname.contains("clang") { + match clang_driver { + Some("cl") => ToolFamily::Msvc { clang_cl: true }, + _ => ToolFamily::Clang, + } + } else { + ToolFamily::Gnu + } + } else { + ToolFamily::Gnu + }; + + Tool { + path: path, + cc_wrapper_path: None, + cc_wrapper_args: Vec::new(), + args: Vec::new(), + env: Vec::new(), + family: family, + cuda: cuda, + removed_args: Vec::new(), + } + } + + /// Add an argument to be stripped from the final command arguments. + fn remove_arg(&mut self, flag: OsString) { + self.removed_args.push(flag); + } + + /// Add a flag, and optionally prepend the NVCC wrapper flag "-Xcompiler". + /// + /// Currently this is only used for compiling CUDA sources, since NVCC only + /// accepts a limited set of GNU-like flags, and the rest must be prefixed + /// with a "-Xcompiler" flag to get passed to the underlying C++ compiler. + fn push_cc_arg(&mut self, flag: OsString) { + if self.cuda { + self.args.push("-Xcompiler".into()); + } + self.args.push(flag); + } + + fn is_duplicate_opt_arg(&self, flag: &OsString) -> bool { + let flag = flag.to_str().unwrap(); + let mut chars = flag.chars(); + + // Only duplicate check compiler flags + if self.is_like_msvc() { + if chars.next() != Some('/') { + return false; + } + } else if self.is_like_gnu() || self.is_like_clang() { + if chars.next() != Some('-') { + return false; + } + } + + // Check for existing optimization flags (-O, /O) + if chars.next() == Some('O') { + return self + .args() + .iter() + .any(|ref a| a.to_str().unwrap_or("").chars().nth(1) == Some('O')); + } + + // TODO Check for existing -m..., -m...=..., /arch:... flags + return false; + } + + /// Don't push optimization arg if it conflicts with existing args + fn push_opt_unless_duplicate(&mut self, flag: OsString) { + if self.is_duplicate_opt_arg(&flag) { + println!("Info: Ignoring duplicate arg {:?}", &flag); + } else { + self.push_cc_arg(flag); + } + } + + /// Converts this compiler into a `Command` that's ready to be run. + /// + /// This is useful for when the compiler needs to be executed and the + /// command returned will already have the initial arguments and environment + /// variables configured. + pub fn to_command(&self) -> Command { + let mut cmd = match self.cc_wrapper_path { + Some(ref cc_wrapper_path) => { + let mut cmd = Command::new(&cc_wrapper_path); + cmd.arg(&self.path); + cmd + } + None => Command::new(&self.path), + }; + cmd.args(&self.cc_wrapper_args); + + let value = self + .args + .iter() + .filter(|a| !self.removed_args.contains(a)) + .collect::>(); + cmd.args(&value); + + for &(ref k, ref v) in self.env.iter() { + cmd.env(k, v); + } + cmd + } + + /// Returns the path for this compiler. + /// + /// Note that this may not be a path to a file on the filesystem, e.g. "cc", + /// but rather something which will be resolved when a process is spawned. + pub fn path(&self) -> &Path { + &self.path + } + + /// Returns the default set of arguments to the compiler needed to produce + /// executables for the target this compiler generates. + pub fn args(&self) -> &[OsString] { + &self.args + } + + /// Returns the set of environment variables needed for this compiler to + /// operate. + /// + /// This is typically only used for MSVC compilers currently. + pub fn env(&self) -> &[(OsString, OsString)] { + &self.env + } + + /// Returns the compiler command in format of CC environment variable. + /// Or empty string if CC env was not present + /// + /// This is typically used by configure script + pub fn cc_env(&self) -> OsString { + match self.cc_wrapper_path { + Some(ref cc_wrapper_path) => { + let mut cc_env = cc_wrapper_path.as_os_str().to_owned(); + cc_env.push(" "); + cc_env.push(self.path.to_path_buf().into_os_string()); + for arg in self.cc_wrapper_args.iter() { + cc_env.push(" "); + cc_env.push(arg); + } + cc_env + } + None => OsString::from(""), + } + } + + /// Returns the compiler flags in format of CFLAGS environment variable. + /// Important here - this will not be CFLAGS from env, its internal gcc's flags to use as CFLAGS + /// This is typically used by configure script + pub fn cflags_env(&self) -> OsString { + let mut flags = OsString::new(); + for (i, arg) in self.args.iter().enumerate() { + if i > 0 { + flags.push(" "); + } + flags.push(arg); + } + flags + } + + /// Whether the tool is GNU Compiler Collection-like. + pub fn is_like_gnu(&self) -> bool { + self.family == ToolFamily::Gnu + } + + /// Whether the tool is Clang-like. + pub fn is_like_clang(&self) -> bool { + self.family == ToolFamily::Clang + } + + /// Whether the tool is MSVC-like. + pub fn is_like_msvc(&self) -> bool { + match self.family { + ToolFamily::Msvc { .. } => true, + _ => false, + } + } +} + +fn run(cmd: &mut Command, program: &str) -> Result<(), Error> { + let (mut child, print) = spawn(cmd, program)?; + let status = match child.wait() { + Ok(s) => s, + Err(_) => { + return Err(Error::new( + ErrorKind::ToolExecError, + &format!( + "Failed to wait on spawned child process, command {:?} with args {:?}.", + cmd, program + ), + )); + } + }; + print.join().unwrap(); + println!("{}", status); + + if status.success() { + Ok(()) + } else { + Err(Error::new( + ErrorKind::ToolExecError, + &format!( + "Command {:?} with args {:?} did not execute successfully (status code {}).", + cmd, program, status + ), + )) + } +} + +fn run_output(cmd: &mut Command, program: &str) -> Result, Error> { + cmd.stdout(Stdio::piped()); + let (mut child, print) = spawn(cmd, program)?; + let mut stdout = vec![]; + child + .stdout + .take() + .unwrap() + .read_to_end(&mut stdout) + .unwrap(); + let status = match child.wait() { + Ok(s) => s, + Err(_) => { + return Err(Error::new( + ErrorKind::ToolExecError, + &format!( + "Failed to wait on spawned child process, command {:?} with args {:?}.", + cmd, program + ), + )); + } + }; + print.join().unwrap(); + println!("{}", status); + + if status.success() { + Ok(stdout) + } else { + Err(Error::new( + ErrorKind::ToolExecError, + &format!( + "Command {:?} with args {:?} did not execute successfully (status code {}).", + cmd, program, status + ), + )) + } +} + +fn spawn(cmd: &mut Command, program: &str) -> Result<(Child, JoinHandle<()>), Error> { + println!("running: {:?}", cmd); + + // Capture the standard error coming from these programs, and write it out + // with cargo:warning= prefixes. Note that this is a bit wonky to avoid + // requiring the output to be UTF-8, we instead just ship bytes from one + // location to another. + match cmd.stderr(Stdio::piped()).spawn() { + Ok(mut child) => { + let stderr = BufReader::new(child.stderr.take().unwrap()); + let print = thread::spawn(move || { + for line in stderr.split(b'\n').filter_map(|l| l.ok()) { + print!("cargo:warning="); + std::io::stdout().write_all(&line).unwrap(); + println!(""); + } + }); + Ok((child, print)) + } + Err(ref e) if e.kind() == io::ErrorKind::NotFound => { + let extra = if cfg!(windows) { + " (see https://github.com/alexcrichton/cc-rs#compile-time-requirements \ + for help)" + } else { + "" + }; + Err(Error::new( + ErrorKind::ToolNotFound, + &format!("Failed to find tool. Is `{}` installed?{}", program, extra), + )) + } + Err(_) => Err(Error::new( + ErrorKind::ToolExecError, + &format!("Command {:?} with args {:?} failed to start.", cmd, program), + )), + } +} + +fn fail(s: &str) -> ! { + let _ = writeln!(io::stderr(), "\n\nerror occurred: {}\n\n", s); + std::process::exit(1); +} + +fn command_add_output_file( + cmd: &mut Command, + dst: &Path, + cuda: bool, + msvc: bool, + is_asm: bool, + is_arm: bool, +) { + if msvc && !cuda && !(is_asm && is_arm) { + let mut s = OsString::from("-Fo"); + s.push(&dst); + cmd.arg(s); + } else { + cmd.arg("-o").arg(&dst); + } +} diff --git a/third_party/cargo/vendor/cc-1.0.50/src/registry.rs b/third_party/cargo/vendor/cc-1.0.50/src/registry.rs new file mode 100644 index 0000000..2ac2fa6 --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/src/registry.rs @@ -0,0 +1,204 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ffi::{OsStr, OsString}; +use std::io; +use std::ops::RangeFrom; +use std::os::raw; +use std::os::windows::prelude::*; + +pub struct RegistryKey(Repr); + +type HKEY = *mut u8; +type DWORD = u32; +type LPDWORD = *mut DWORD; +type LPCWSTR = *const u16; +type LPWSTR = *mut u16; +type LONG = raw::c_long; +type PHKEY = *mut HKEY; +type PFILETIME = *mut u8; +type LPBYTE = *mut u8; +type REGSAM = u32; + +const ERROR_SUCCESS: DWORD = 0; +const ERROR_NO_MORE_ITEMS: DWORD = 259; +const HKEY_LOCAL_MACHINE: HKEY = 0x80000002 as HKEY; +const REG_SZ: DWORD = 1; +const KEY_READ: DWORD = 0x20019; +const KEY_WOW64_32KEY: DWORD = 0x200; + +#[link(name = "advapi32")] +extern "system" { + fn RegOpenKeyExW( + key: HKEY, + lpSubKey: LPCWSTR, + ulOptions: DWORD, + samDesired: REGSAM, + phkResult: PHKEY, + ) -> LONG; + fn RegEnumKeyExW( + key: HKEY, + dwIndex: DWORD, + lpName: LPWSTR, + lpcName: LPDWORD, + lpReserved: LPDWORD, + lpClass: LPWSTR, + lpcClass: LPDWORD, + lpftLastWriteTime: PFILETIME, + ) -> LONG; + fn RegQueryValueExW( + hKey: HKEY, + lpValueName: LPCWSTR, + lpReserved: LPDWORD, + lpType: LPDWORD, + lpData: LPBYTE, + lpcbData: LPDWORD, + ) -> LONG; + fn RegCloseKey(hKey: HKEY) -> LONG; +} + +struct OwnedKey(HKEY); + +enum Repr { + Const(HKEY), + Owned(OwnedKey), +} + +pub struct Iter<'a> { + idx: RangeFrom, + key: &'a RegistryKey, +} + +unsafe impl Sync for Repr {} +unsafe impl Send for Repr {} + +pub static LOCAL_MACHINE: RegistryKey = RegistryKey(Repr::Const(HKEY_LOCAL_MACHINE)); + +impl RegistryKey { + fn raw(&self) -> HKEY { + match self.0 { + Repr::Const(val) => val, + Repr::Owned(ref val) => val.0, + } + } + + pub fn open(&self, key: &OsStr) -> io::Result { + let key = key.encode_wide().chain(Some(0)).collect::>(); + let mut ret = 0 as *mut _; + let err = unsafe { + RegOpenKeyExW( + self.raw(), + key.as_ptr(), + 0, + KEY_READ | KEY_WOW64_32KEY, + &mut ret, + ) + }; + if err == ERROR_SUCCESS as LONG { + Ok(RegistryKey(Repr::Owned(OwnedKey(ret)))) + } else { + Err(io::Error::from_raw_os_error(err as i32)) + } + } + + pub fn iter(&self) -> Iter { + Iter { + idx: 0.., + key: self, + } + } + + pub fn query_str(&self, name: &str) -> io::Result { + let name: &OsStr = name.as_ref(); + let name = name.encode_wide().chain(Some(0)).collect::>(); + let mut len = 0; + let mut kind = 0; + unsafe { + let err = RegQueryValueExW( + self.raw(), + name.as_ptr(), + 0 as *mut _, + &mut kind, + 0 as *mut _, + &mut len, + ); + if err != ERROR_SUCCESS as LONG { + return Err(io::Error::from_raw_os_error(err as i32)); + } + if kind != REG_SZ { + return Err(io::Error::new( + io::ErrorKind::Other, + "registry key wasn't a string", + )); + } + + // The length here is the length in bytes, but we're using wide + // characters so we need to be sure to halve it for the capacity + // passed in. + let mut v = Vec::with_capacity(len as usize / 2); + let err = RegQueryValueExW( + self.raw(), + name.as_ptr(), + 0 as *mut _, + 0 as *mut _, + v.as_mut_ptr() as *mut _, + &mut len, + ); + if err != ERROR_SUCCESS as LONG { + return Err(io::Error::from_raw_os_error(err as i32)); + } + v.set_len(len as usize / 2); + + // Some registry keys may have a terminating nul character, but + // we're not interested in that, so chop it off if it's there. + if v[v.len() - 1] == 0 { + v.pop(); + } + Ok(OsString::from_wide(&v)) + } + } +} + +impl Drop for OwnedKey { + fn drop(&mut self) { + unsafe { + RegCloseKey(self.0); + } + } +} + +impl<'a> Iterator for Iter<'a> { + type Item = io::Result; + + fn next(&mut self) -> Option> { + self.idx.next().and_then(|i| unsafe { + let mut v = Vec::with_capacity(256); + let mut len = v.capacity() as DWORD; + let ret = RegEnumKeyExW( + self.key.raw(), + i, + v.as_mut_ptr(), + &mut len, + 0 as *mut _, + 0 as *mut _, + 0 as *mut _, + 0 as *mut _, + ); + if ret == ERROR_NO_MORE_ITEMS as LONG { + None + } else if ret != ERROR_SUCCESS as LONG { + Some(Err(io::Error::from_raw_os_error(ret as i32))) + } else { + v.set_len(len as usize); + Some(Ok(OsString::from_wide(&v))) + } + }) + } +} diff --git a/third_party/cargo/vendor/cc-1.0.50/src/setup_config.rs b/third_party/cargo/vendor/cc-1.0.50/src/setup_config.rs new file mode 100644 index 0000000..bc2b1c2 --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/src/setup_config.rs @@ -0,0 +1,283 @@ +// Copyright © 2017 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. + +#![allow(bad_style)] +#![allow(unused)] + +use crate::winapi::Interface; +use crate::winapi::BSTR; +use crate::winapi::LPCOLESTR; +use crate::winapi::LPSAFEARRAY; +use crate::winapi::S_FALSE; +use crate::winapi::{CoCreateInstance, CLSCTX_ALL}; +use crate::winapi::{IUnknown, IUnknownVtbl}; +use crate::winapi::{HRESULT, LCID, LPCWSTR, PULONGLONG}; +use crate::winapi::{LPFILETIME, ULONG}; +use std::ffi::OsString; +use std::ptr::null_mut; + +use crate::com::{BStr, ComPtr}; + +// Bindings to the Setup.Configuration stuff +pub type InstanceState = u32; + +pub const eNone: InstanceState = 0; +pub const eLocal: InstanceState = 1; +pub const eRegistered: InstanceState = 2; +pub const eNoRebootRequired: InstanceState = 4; +pub const eComplete: InstanceState = -1i32 as u32; + +RIDL! {#[uuid(0xb41463c3, 0x8866, 0x43b5, 0xbc, 0x33, 0x2b, 0x06, 0x76, 0xf7, 0xf4, 0x2e)] +interface ISetupInstance(ISetupInstanceVtbl): IUnknown(IUnknownVtbl) { + fn GetInstanceId( + pbstrInstanceId: *mut BSTR, + ) -> HRESULT, + fn GetInstallDate( + pInstallDate: LPFILETIME, + ) -> HRESULT, + fn GetInstallationName( + pbstrInstallationName: *mut BSTR, + ) -> HRESULT, + fn GetInstallationPath( + pbstrInstallationPath: *mut BSTR, + ) -> HRESULT, + fn GetInstallationVersion( + pbstrInstallationVersion: *mut BSTR, + ) -> HRESULT, + fn GetDisplayName( + lcid: LCID, + pbstrDisplayName: *mut BSTR, + ) -> HRESULT, + fn GetDescription( + lcid: LCID, + pbstrDescription: *mut BSTR, + ) -> HRESULT, + fn ResolvePath( + pwszRelativePath: LPCOLESTR, + pbstrAbsolutePath: *mut BSTR, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0x89143c9a, 0x05af, 0x49b0, 0xb7, 0x17, 0x72, 0xe2, 0x18, 0xa2, 0x18, 0x5c)] +interface ISetupInstance2(ISetupInstance2Vtbl): ISetupInstance(ISetupInstanceVtbl) { + fn GetState( + pState: *mut InstanceState, + ) -> HRESULT, + fn GetPackages( + ppsaPackages: *mut LPSAFEARRAY, + ) -> HRESULT, + fn GetProduct( + ppPackage: *mut *mut ISetupPackageReference, + ) -> HRESULT, + fn GetProductPath( + pbstrProductPath: *mut BSTR, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0x6380bcff, 0x41d3, 0x4b2e, 0x8b, 0x2e, 0xbf, 0x8a, 0x68, 0x10, 0xc8, 0x48)] +interface IEnumSetupInstances(IEnumSetupInstancesVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut *mut ISetupInstance, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumSetupInstances, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0x42843719, 0xdb4c, 0x46c2, 0x8e, 0x7c, 0x64, 0xf1, 0x81, 0x6e, 0xfd, 0x5b)] +interface ISetupConfiguration(ISetupConfigurationVtbl): IUnknown(IUnknownVtbl) { + fn EnumInstances( + ppEnumInstances: *mut *mut IEnumSetupInstances, + ) -> HRESULT, + fn GetInstanceForCurrentProcess( + ppInstance: *mut *mut ISetupInstance, + ) -> HRESULT, + fn GetInstanceForPath( + wzPath: LPCWSTR, + ppInstance: *mut *mut ISetupInstance, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0x26aab78c, 0x4a60, 0x49d6, 0xaf, 0x3b, 0x3c, 0x35, 0xbc, 0x93, 0x36, 0x5d)] +interface ISetupConfiguration2(ISetupConfiguration2Vtbl): + ISetupConfiguration(ISetupConfigurationVtbl) { + fn EnumAllInstances( + ppEnumInstances: *mut *mut IEnumSetupInstances, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0xda8d8a16, 0xb2b6, 0x4487, 0xa2, 0xf1, 0x59, 0x4c, 0xcc, 0xcd, 0x6b, 0xf5)] +interface ISetupPackageReference(ISetupPackageReferenceVtbl): IUnknown(IUnknownVtbl) { + fn GetId( + pbstrId: *mut BSTR, + ) -> HRESULT, + fn GetVersion( + pbstrVersion: *mut BSTR, + ) -> HRESULT, + fn GetChip( + pbstrChip: *mut BSTR, + ) -> HRESULT, + fn GetLanguage( + pbstrLanguage: *mut BSTR, + ) -> HRESULT, + fn GetBranch( + pbstrBranch: *mut BSTR, + ) -> HRESULT, + fn GetType( + pbstrType: *mut BSTR, + ) -> HRESULT, + fn GetUniqueId( + pbstrUniqueId: *mut BSTR, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0x42b21b78, 0x6192, 0x463e, 0x87, 0xbf, 0xd5, 0x77, 0x83, 0x8f, 0x1d, 0x5c)] +interface ISetupHelper(ISetupHelperVtbl): IUnknown(IUnknownVtbl) { + fn ParseVersion( + pwszVersion: LPCOLESTR, + pullVersion: PULONGLONG, + ) -> HRESULT, + fn ParseVersionRange( + pwszVersionRange: LPCOLESTR, + pullMinVersion: PULONGLONG, + pullMaxVersion: PULONGLONG, + ) -> HRESULT, +}} + +DEFINE_GUID! {CLSID_SetupConfiguration, +0x177f0c4a, 0x1cd3, 0x4de7, 0xa3, 0x2c, 0x71, 0xdb, 0xbb, 0x9f, 0xa3, 0x6d} + +// Safe wrapper around the COM interfaces +pub struct SetupConfiguration(ComPtr); + +impl SetupConfiguration { + pub fn new() -> Result { + let mut obj = null_mut(); + let err = unsafe { + CoCreateInstance( + &CLSID_SetupConfiguration, + null_mut(), + CLSCTX_ALL, + &ISetupConfiguration::uuidof(), + &mut obj, + ) + }; + if err < 0 { + return Err(err); + } + let obj = unsafe { ComPtr::from_raw(obj as *mut ISetupConfiguration) }; + Ok(SetupConfiguration(obj)) + } + pub fn get_instance_for_current_process(&self) -> Result { + let mut obj = null_mut(); + let err = unsafe { self.0.GetInstanceForCurrentProcess(&mut obj) }; + if err < 0 { + return Err(err); + } + Ok(unsafe { SetupInstance::from_raw(obj) }) + } + pub fn enum_instances(&self) -> Result { + let mut obj = null_mut(); + let err = unsafe { self.0.EnumInstances(&mut obj) }; + if err < 0 { + return Err(err); + } + Ok(unsafe { EnumSetupInstances::from_raw(obj) }) + } + pub fn enum_all_instances(&self) -> Result { + let mut obj = null_mut(); + let this = self.0.cast::()?; + let err = unsafe { this.EnumAllInstances(&mut obj) }; + if err < 0 { + return Err(err); + } + Ok(unsafe { EnumSetupInstances::from_raw(obj) }) + } +} + +pub struct SetupInstance(ComPtr); + +impl SetupInstance { + pub unsafe fn from_raw(obj: *mut ISetupInstance) -> SetupInstance { + SetupInstance(ComPtr::from_raw(obj)) + } + pub fn instance_id(&self) -> Result { + let mut s = null_mut(); + let err = unsafe { self.0.GetInstanceId(&mut s) }; + let bstr = unsafe { BStr::from_raw(s) }; + if err < 0 { + return Err(err); + } + Ok(bstr.to_osstring()) + } + pub fn installation_name(&self) -> Result { + let mut s = null_mut(); + let err = unsafe { self.0.GetInstallationName(&mut s) }; + let bstr = unsafe { BStr::from_raw(s) }; + if err < 0 { + return Err(err); + } + Ok(bstr.to_osstring()) + } + pub fn installation_path(&self) -> Result { + let mut s = null_mut(); + let err = unsafe { self.0.GetInstallationPath(&mut s) }; + let bstr = unsafe { BStr::from_raw(s) }; + if err < 0 { + return Err(err); + } + Ok(bstr.to_osstring()) + } + pub fn installation_version(&self) -> Result { + let mut s = null_mut(); + let err = unsafe { self.0.GetInstallationVersion(&mut s) }; + let bstr = unsafe { BStr::from_raw(s) }; + if err < 0 { + return Err(err); + } + Ok(bstr.to_osstring()) + } + pub fn product_path(&self) -> Result { + let mut s = null_mut(); + let this = self.0.cast::()?; + let err = unsafe { this.GetProductPath(&mut s) }; + let bstr = unsafe { BStr::from_raw(s) }; + if err < 0 { + return Err(err); + } + Ok(bstr.to_osstring()) + } +} + +pub struct EnumSetupInstances(ComPtr); + +impl EnumSetupInstances { + pub unsafe fn from_raw(obj: *mut IEnumSetupInstances) -> EnumSetupInstances { + EnumSetupInstances(ComPtr::from_raw(obj)) + } +} + +impl Iterator for EnumSetupInstances { + type Item = Result; + fn next(&mut self) -> Option> { + let mut obj = null_mut(); + let err = unsafe { self.0.Next(1, &mut obj, null_mut()) }; + if err < 0 { + return Some(Err(err)); + } + if err == S_FALSE { + return None; + } + Some(Ok(unsafe { SetupInstance::from_raw(obj) })) + } +} diff --git a/third_party/cargo/vendor/cc-1.0.50/src/winapi.rs b/third_party/cargo/vendor/cc-1.0.50/src/winapi.rs new file mode 100644 index 0000000..c416325 --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/src/winapi.rs @@ -0,0 +1,218 @@ +// Copyright © 2015-2017 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. + +#![allow(bad_style)] + +use std::os::raw; + +pub type wchar_t = u16; + +pub type UINT = raw::c_uint; +pub type LPUNKNOWN = *mut IUnknown; +pub type REFIID = *const IID; +pub type IID = GUID; +pub type REFCLSID = *const IID; +pub type PVOID = *mut raw::c_void; +pub type USHORT = raw::c_ushort; +pub type ULONG = raw::c_ulong; +pub type LONG = raw::c_long; +pub type DWORD = u32; +pub type LPVOID = *mut raw::c_void; +pub type HRESULT = raw::c_long; +pub type LPFILETIME = *mut FILETIME; +pub type BSTR = *mut OLECHAR; +pub type OLECHAR = WCHAR; +pub type WCHAR = wchar_t; +pub type LPCOLESTR = *const OLECHAR; +pub type LCID = DWORD; +pub type LPCWSTR = *const WCHAR; +pub type PULONGLONG = *mut ULONGLONG; +pub type ULONGLONG = u64; + +pub const S_OK: HRESULT = 0; +pub const S_FALSE: HRESULT = 1; +pub const COINIT_MULTITHREADED: u32 = 0x0; + +pub type CLSCTX = u32; + +pub const CLSCTX_INPROC_SERVER: CLSCTX = 0x1; +pub const CLSCTX_INPROC_HANDLER: CLSCTX = 0x2; +pub const CLSCTX_LOCAL_SERVER: CLSCTX = 0x4; +pub const CLSCTX_REMOTE_SERVER: CLSCTX = 0x10; + +pub const CLSCTX_ALL: CLSCTX = + CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GUID { + pub Data1: raw::c_ulong, + pub Data2: raw::c_ushort, + pub Data3: raw::c_ushort, + pub Data4: [raw::c_uchar; 8], +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct FILETIME { + pub dwLowDateTime: DWORD, + pub dwHighDateTime: DWORD, +} + +pub trait Interface { + fn uuidof() -> GUID; +} + +#[link(name = "ole32")] +#[link(name = "oleaut32")] +extern "C" {} + +extern "system" { + pub fn CoInitializeEx(pvReserved: LPVOID, dwCoInit: DWORD) -> HRESULT; + pub fn CoCreateInstance( + rclsid: REFCLSID, + pUnkOuter: LPUNKNOWN, + dwClsContext: DWORD, + riid: REFIID, + ppv: *mut LPVOID, + ) -> HRESULT; + pub fn SysFreeString(bstrString: BSTR); + pub fn SysStringLen(pbstr: BSTR) -> UINT; +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct SAFEARRAYBOUND { + pub cElements: ULONG, + pub lLbound: LONG, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct SAFEARRAY { + pub cDims: USHORT, + pub fFeatures: USHORT, + pub cbElements: ULONG, + pub cLocks: ULONG, + pub pvData: PVOID, + pub rgsabound: [SAFEARRAYBOUND; 1], +} + +pub type LPSAFEARRAY = *mut SAFEARRAY; + +macro_rules! DEFINE_GUID { + ( + $name:ident, $l:expr, $w1:expr, $w2:expr, + $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr + ) => { + pub const $name: $crate::winapi::GUID = $crate::winapi::GUID { + Data1: $l, + Data2: $w1, + Data3: $w2, + Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + }; + }; +} + +macro_rules! RIDL { + (#[uuid($($uuid:expr),+)] + interface $interface:ident ($vtbl:ident) {$( + fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, + )+}) => ( + #[repr(C)] + pub struct $vtbl { + $(pub $method: unsafe extern "system" fn( + This: *mut $interface, + $($p: $t),* + ) -> $rtr,)+ + } + #[repr(C)] + pub struct $interface { + pub lpVtbl: *const $vtbl, + } + RIDL!{@impl $interface {$(fn $method($($p: $t,)*) -> $rtr,)+}} + RIDL!{@uuid $interface $($uuid),+} + ); + (#[uuid($($uuid:expr),+)] + interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) { + }) => ( + #[repr(C)] + pub struct $vtbl { + pub parent: $pvtbl, + } + #[repr(C)] + pub struct $interface { + pub lpVtbl: *const $vtbl, + } + RIDL!{@deref $interface $pinterface} + RIDL!{@uuid $interface $($uuid),+} + ); + (#[uuid($($uuid:expr),+)] + interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) {$( + fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, + )+}) => ( + #[repr(C)] + pub struct $vtbl { + pub parent: $pvtbl, + $(pub $method: unsafe extern "system" fn( + This: *mut $interface, + $($p: $t,)* + ) -> $rtr,)+ + } + #[repr(C)] + pub struct $interface { + pub lpVtbl: *const $vtbl, + } + RIDL!{@impl $interface {$(fn $method($($p: $t,)*) -> $rtr,)+}} + RIDL!{@deref $interface $pinterface} + RIDL!{@uuid $interface $($uuid),+} + ); + (@deref $interface:ident $pinterface:ident) => ( + impl ::std::ops::Deref for $interface { + type Target = $pinterface; + #[inline] + fn deref(&self) -> &$pinterface { + unsafe { &*(self as *const $interface as *const $pinterface) } + } + } + ); + (@impl $interface:ident {$( + fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, + )+}) => ( + impl $interface { + $(#[inline] pub unsafe fn $method(&self, $($p: $t,)*) -> $rtr { + ((*self.lpVtbl).$method)(self as *const _ as *mut _, $($p,)*) + })+ + } + ); + (@uuid $interface:ident + $l:expr, $w1:expr, $w2:expr, + $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr + ) => ( + impl $crate::winapi::Interface for $interface { + #[inline] + fn uuidof() -> $crate::winapi::GUID { + $crate::winapi::GUID { + Data1: $l, + Data2: $w1, + Data3: $w2, + Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + } + } + } + ); +} + +RIDL! {#[uuid(0x00000000, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IUnknown(IUnknownVtbl) { + fn QueryInterface( + riid: REFIID, + ppvObject: *mut *mut raw::c_void, + ) -> HRESULT, + fn AddRef() -> ULONG, + fn Release() -> ULONG, +}} diff --git a/third_party/cargo/vendor/cc-1.0.50/src/windows_registry.rs b/third_party/cargo/vendor/cc-1.0.50/src/windows_registry.rs new file mode 100644 index 0000000..5af3ff7 --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/src/windows_registry.rs @@ -0,0 +1,754 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A helper module to probe the Windows Registry when looking for +//! windows-specific tools. + +use std::process::Command; + +use crate::Tool; + +/// Attempts to find a tool within an MSVC installation using the Windows +/// registry as a point to search from. +/// +/// The `target` argument is the target that the tool should work for (e.g. +/// compile or link for) and the `tool` argument is the tool to find (e.g. +/// `cl.exe` or `link.exe`). +/// +/// This function will return `None` if the tool could not be found, or it will +/// return `Some(cmd)` which represents a command that's ready to execute the +/// tool with the appropriate environment variables set. +/// +/// Note that this function always returns `None` for non-MSVC targets. +pub fn find(target: &str, tool: &str) -> Option { + find_tool(target, tool).map(|c| c.to_command()) +} + +/// Similar to the `find` function above, this function will attempt the same +/// operation (finding a MSVC tool in a local install) but instead returns a +/// `Tool` which may be introspected. +#[cfg(not(windows))] +pub fn find_tool(_target: &str, _tool: &str) -> Option { + None +} + +/// Documented above. +#[cfg(windows)] +pub fn find_tool(target: &str, tool: &str) -> Option { + use std::env; + + // This logic is all tailored for MSVC, if we're not that then bail out + // early. + if !target.contains("msvc") { + return None; + } + + // Looks like msbuild isn't located in the same location as other tools like + // cl.exe and lib.exe. To handle this we probe for it manually with + // dedicated registry keys. + if tool.contains("msbuild") { + return impl_::find_msbuild(target); + } + + if tool.contains("devenv") { + return impl_::find_devenv(target); + } + + // If VCINSTALLDIR is set, then someone's probably already run vcvars and we + // should just find whatever that indicates. + if env::var_os("VCINSTALLDIR").is_some() { + return env::var_os("PATH") + .and_then(|path| { + env::split_paths(&path) + .map(|p| p.join(tool)) + .find(|p| p.exists()) + }) + .map(|path| Tool::new(path.into())); + } + + // Ok, if we're here, now comes the fun part of the probing. Default shells + // or shells like MSYS aren't really configured to execute `cl.exe` and the + // various compiler tools shipped as part of Visual Studio. Here we try to + // first find the relevant tool, then we also have to be sure to fill in + // environment variables like `LIB`, `INCLUDE`, and `PATH` to ensure that + // the tool is actually usable. + + return impl_::find_msvc_15(tool, target) + .or_else(|| impl_::find_msvc_14(tool, target)) + .or_else(|| impl_::find_msvc_12(tool, target)) + .or_else(|| impl_::find_msvc_11(tool, target)); +} + +/// A version of Visual Studio +#[derive(Debug, PartialEq, Eq, Copy, Clone)] +pub enum VsVers { + /// Visual Studio 12 (2013) + Vs12, + /// Visual Studio 14 (2015) + Vs14, + /// Visual Studio 15 (2017) + Vs15, + /// Visual Studio 16 (2019) + Vs16, + + /// Hidden variant that should not be matched on. Callers that want to + /// handle an enumeration of `VsVers` instances should always have a default + /// case meaning that it's a VS version they don't understand. + #[doc(hidden)] + #[allow(bad_style)] + __Nonexhaustive_do_not_match_this_or_your_code_will_break, +} + +/// Find the most recent installed version of Visual Studio +/// +/// This is used by the cmake crate to figure out the correct +/// generator. +#[cfg(not(windows))] +pub fn find_vs_version() -> Result { + Err(format!("not windows")) +} + +/// Documented above +#[cfg(windows)] +pub fn find_vs_version() -> Result { + use std::env; + + match env::var("VisualStudioVersion") { + Ok(version) => match &version[..] { + "16.0" => Ok(VsVers::Vs16), + "15.0" => Ok(VsVers::Vs15), + "14.0" => Ok(VsVers::Vs14), + "12.0" => Ok(VsVers::Vs12), + vers => Err(format!( + "\n\n\ + unsupported or unknown VisualStudio version: {}\n\ + if another version is installed consider running \ + the appropriate vcvars script before building this \ + crate\n\ + ", + vers + )), + }, + _ => { + // Check for the presense of a specific registry key + // that indicates visual studio is installed. + if impl_::has_msbuild_version("16.0") { + Ok(VsVers::Vs16) + } else if impl_::has_msbuild_version("15.0") { + Ok(VsVers::Vs15) + } else if impl_::has_msbuild_version("14.0") { + Ok(VsVers::Vs14) + } else if impl_::has_msbuild_version("12.0") { + Ok(VsVers::Vs12) + } else { + Err(format!( + "\n\n\ + couldn't determine visual studio generator\n\ + if VisualStudio is installed, however, consider \ + running the appropriate vcvars script before building \ + this crate\n\ + " + )) + } + } + } +} + +#[cfg(windows)] +mod impl_ { + use crate::com; + use crate::registry::{RegistryKey, LOCAL_MACHINE}; + use crate::setup_config::{EnumSetupInstances, SetupConfiguration, SetupInstance}; + use std::env; + use std::ffi::OsString; + use std::fs::File; + use std::io::Read; + use std::iter; + use std::mem; + use std::path::{Path, PathBuf}; + + use crate::Tool; + + struct MsvcTool { + tool: PathBuf, + libs: Vec, + path: Vec, + include: Vec, + } + + impl MsvcTool { + fn new(tool: PathBuf) -> MsvcTool { + MsvcTool { + tool: tool, + libs: Vec::new(), + path: Vec::new(), + include: Vec::new(), + } + } + + fn into_tool(self) -> Tool { + let MsvcTool { + tool, + libs, + path, + include, + } = self; + let mut tool = Tool::new(tool.into()); + add_env(&mut tool, "LIB", libs); + add_env(&mut tool, "PATH", path); + add_env(&mut tool, "INCLUDE", include); + tool + } + } + + #[allow(bare_trait_objects)] + fn vs16_instances() -> Box> { + let instances = if let Some(instances) = vs15_instances() { + instances + } else { + return Box::new(iter::empty()); + }; + Box::new(instances.filter_map(|instance| { + let instance = instance.ok()?; + let installation_name = instance.installation_name().ok()?; + if installation_name.to_str()?.starts_with("VisualStudio/16.") { + Some(PathBuf::from(instance.installation_path().ok()?)) + } else { + None + } + })) + } + + fn find_tool_in_vs16_path(tool: &str, target: &str) -> Option { + vs16_instances() + .filter_map(|path| { + let path = path.join(tool); + if !path.is_file() { + return None; + } + let mut tool = Tool::new(path); + if target.contains("x86_64") { + tool.env.push(("Platform".into(), "X64".into())); + } + Some(tool) + }) + .next() + } + + fn find_msbuild_vs16(target: &str) -> Option { + find_tool_in_vs16_path(r"MSBuild\Current\Bin\MSBuild.exe", target) + } + + // In MSVC 15 (2017) MS once again changed the scheme for locating + // the tooling. Now we must go through some COM interfaces, which + // is super fun for Rust. + // + // Note that much of this logic can be found [online] wrt paths, COM, etc. + // + // [online]: https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/ + fn vs15_instances() -> Option { + com::initialize().ok()?; + + let config = SetupConfiguration::new().ok()?; + config.enum_all_instances().ok() + } + + pub fn find_msvc_15(tool: &str, target: &str) -> Option { + let iter = vs15_instances()?; + for instance in iter { + let instance = instance.ok()?; + let tool = tool_from_vs15_instance(tool, target, &instance); + if tool.is_some() { + return tool; + } + } + + None + } + + // While the paths to Visual Studio 2017's devenv and MSBuild could + // potentially be retrieved from the registry, finding them via + // SetupConfiguration has shown to be [more reliable], and is preferred + // according to Microsoft. To help head off potential regressions though, + // we keep the registry method as a fallback option. + // + // [more reliable]: https://github.com/alexcrichton/cc-rs/pull/331 + fn find_tool_in_vs15_path(tool: &str, target: &str) -> Option { + let mut path = match vs15_instances() { + Some(instances) => instances + .filter_map(|instance| { + instance + .ok() + .and_then(|instance| instance.installation_path().ok()) + }) + .map(|path| PathBuf::from(path).join(tool)) + .find(|ref path| path.is_file()), + None => None, + }; + + if path.is_none() { + let key = r"SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7"; + path = LOCAL_MACHINE + .open(key.as_ref()) + .ok() + .and_then(|key| key.query_str("15.0").ok()) + .map(|path| PathBuf::from(path).join(tool)) + .and_then(|path| if path.is_file() { Some(path) } else { None }); + } + + path.map(|path| { + let mut tool = Tool::new(path); + if target.contains("x86_64") { + tool.env.push(("Platform".into(), "X64".into())); + } + tool + }) + } + + fn tool_from_vs15_instance(tool: &str, target: &str, instance: &SetupInstance) -> Option { + let (bin_path, host_dylib_path, lib_path, include_path) = vs15_vc_paths(target, instance)?; + let tool_path = bin_path.join(tool); + if !tool_path.exists() { + return None; + }; + + let mut tool = MsvcTool::new(tool_path); + tool.path.push(host_dylib_path); + tool.libs.push(lib_path); + tool.include.push(include_path); + + if let Some((atl_lib_path, atl_include_path)) = atl_paths(target, &bin_path) { + tool.libs.push(atl_lib_path); + tool.include.push(atl_include_path); + } + + add_sdks(&mut tool, target)?; + + Some(tool.into_tool()) + } + + fn vs15_vc_paths( + target: &str, + instance: &SetupInstance, + ) -> Option<(PathBuf, PathBuf, PathBuf, PathBuf)> { + let instance_path: PathBuf = instance.installation_path().ok()?.into(); + let version_path = + instance_path.join(r"VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"); + let mut version_file = File::open(version_path).ok()?; + let mut version = String::new(); + version_file.read_to_string(&mut version).ok()?; + let version = version.trim(); + let host = match host_arch() { + X86 => "X86", + X86_64 => "X64", + _ => return None, + }; + let target = lib_subdir(target)?; + // The directory layout here is MSVC/bin/Host$host/$target/ + let path = instance_path.join(r"VC\Tools\MSVC").join(version); + // This is the path to the toolchain for a particular target, running + // on a given host + let bin_path = path + .join("bin") + .join(&format!("Host{}", host)) + .join(&target); + // But! we also need PATH to contain the target directory for the host + // architecture, because it contains dlls like mspdb140.dll compiled for + // the host architecture. + let host_dylib_path = path + .join("bin") + .join(&format!("Host{}", host)) + .join(&host.to_lowercase()); + let lib_path = path.join("lib").join(&target); + let include_path = path.join("include"); + Some((bin_path, host_dylib_path, lib_path, include_path)) + } + + fn atl_paths(target: &str, path: &Path) -> Option<(PathBuf, PathBuf)> { + let atl_path = path.join("atlfmc"); + let sub = lib_subdir(target)?; + if atl_path.exists() { + Some((atl_path.join("lib").join(sub), atl_path.join("include"))) + } else { + None + } + } + + // For MSVC 14 we need to find the Universal CRT as well as either + // the Windows 10 SDK or Windows 8.1 SDK. + pub fn find_msvc_14(tool: &str, target: &str) -> Option { + let vcdir = get_vc_dir("14.0")?; + let mut tool = get_tool(tool, &vcdir, target)?; + add_sdks(&mut tool, target)?; + Some(tool.into_tool()) + } + + fn add_sdks(tool: &mut MsvcTool, target: &str) -> Option<()> { + let sub = lib_subdir(target)?; + let (ucrt, ucrt_version) = get_ucrt_dir()?; + + tool.path + .push(ucrt.join("bin").join(&ucrt_version).join(sub)); + + let ucrt_include = ucrt.join("include").join(&ucrt_version); + tool.include.push(ucrt_include.join("ucrt")); + + let ucrt_lib = ucrt.join("lib").join(&ucrt_version); + tool.libs.push(ucrt_lib.join("ucrt").join(sub)); + + if let Some((sdk, version)) = get_sdk10_dir() { + tool.path.push(sdk.join("bin").join(sub)); + let sdk_lib = sdk.join("lib").join(&version); + tool.libs.push(sdk_lib.join("um").join(sub)); + let sdk_include = sdk.join("include").join(&version); + tool.include.push(sdk_include.join("um")); + tool.include.push(sdk_include.join("cppwinrt")); + tool.include.push(sdk_include.join("winrt")); + tool.include.push(sdk_include.join("shared")); + } else if let Some(sdk) = get_sdk81_dir() { + tool.path.push(sdk.join("bin").join(sub)); + let sdk_lib = sdk.join("lib").join("winv6.3"); + tool.libs.push(sdk_lib.join("um").join(sub)); + let sdk_include = sdk.join("include"); + tool.include.push(sdk_include.join("um")); + tool.include.push(sdk_include.join("winrt")); + tool.include.push(sdk_include.join("shared")); + } + + Some(()) + } + + // For MSVC 12 we need to find the Windows 8.1 SDK. + pub fn find_msvc_12(tool: &str, target: &str) -> Option { + let vcdir = get_vc_dir("12.0")?; + let mut tool = get_tool(tool, &vcdir, target)?; + let sub = lib_subdir(target)?; + let sdk81 = get_sdk81_dir()?; + tool.path.push(sdk81.join("bin").join(sub)); + let sdk_lib = sdk81.join("lib").join("winv6.3"); + tool.libs.push(sdk_lib.join("um").join(sub)); + let sdk_include = sdk81.join("include"); + tool.include.push(sdk_include.join("shared")); + tool.include.push(sdk_include.join("um")); + tool.include.push(sdk_include.join("winrt")); + Some(tool.into_tool()) + } + + // For MSVC 11 we need to find the Windows 8 SDK. + pub fn find_msvc_11(tool: &str, target: &str) -> Option { + let vcdir = get_vc_dir("11.0")?; + let mut tool = get_tool(tool, &vcdir, target)?; + let sub = lib_subdir(target)?; + let sdk8 = get_sdk8_dir()?; + tool.path.push(sdk8.join("bin").join(sub)); + let sdk_lib = sdk8.join("lib").join("win8"); + tool.libs.push(sdk_lib.join("um").join(sub)); + let sdk_include = sdk8.join("include"); + tool.include.push(sdk_include.join("shared")); + tool.include.push(sdk_include.join("um")); + tool.include.push(sdk_include.join("winrt")); + Some(tool.into_tool()) + } + + fn add_env(tool: &mut Tool, env: &str, paths: Vec) { + let prev = env::var_os(env).unwrap_or(OsString::new()); + let prev = env::split_paths(&prev); + let new = paths.into_iter().chain(prev); + tool.env + .push((env.to_string().into(), env::join_paths(new).unwrap())); + } + + // Given a possible MSVC installation directory, we look for the linker and + // then add the MSVC library path. + fn get_tool(tool: &str, path: &Path, target: &str) -> Option { + bin_subdir(target) + .into_iter() + .map(|(sub, host)| { + ( + path.join("bin").join(sub).join(tool), + path.join("bin").join(host), + ) + }) + .filter(|&(ref path, _)| path.is_file()) + .map(|(path, host)| { + let mut tool = MsvcTool::new(path); + tool.path.push(host); + tool + }) + .filter_map(|mut tool| { + let sub = vc_lib_subdir(target)?; + tool.libs.push(path.join("lib").join(sub)); + tool.include.push(path.join("include")); + let atlmfc_path = path.join("atlmfc"); + if atlmfc_path.exists() { + tool.libs.push(atlmfc_path.join("lib").join(sub)); + tool.include.push(atlmfc_path.join("include")); + } + Some(tool) + }) + .next() + } + + // To find MSVC we look in a specific registry key for the version we are + // trying to find. + fn get_vc_dir(ver: &str) -> Option { + let key = r"SOFTWARE\Microsoft\VisualStudio\SxS\VC7"; + let key = LOCAL_MACHINE.open(key.as_ref()).ok()?; + let path = key.query_str(ver).ok()?; + Some(path.into()) + } + + // To find the Universal CRT we look in a specific registry key for where + // all the Universal CRTs are located and then sort them asciibetically to + // find the newest version. While this sort of sorting isn't ideal, it is + // what vcvars does so that's good enough for us. + // + // Returns a pair of (root, version) for the ucrt dir if found + fn get_ucrt_dir() -> Option<(PathBuf, String)> { + let key = r"SOFTWARE\Microsoft\Windows Kits\Installed Roots"; + let key = LOCAL_MACHINE.open(key.as_ref()).ok()?; + let root = key.query_str("KitsRoot10").ok()?; + let readdir = Path::new(&root).join("lib").read_dir().ok()?; + let max_libdir = readdir + .filter_map(|dir| dir.ok()) + .map(|dir| dir.path()) + .filter(|dir| { + dir.components() + .last() + .and_then(|c| c.as_os_str().to_str()) + .map(|c| c.starts_with("10.") && dir.join("ucrt").is_dir()) + .unwrap_or(false) + }) + .max()?; + let version = max_libdir.components().last().unwrap(); + let version = version.as_os_str().to_str().unwrap().to_string(); + Some((root.into(), version)) + } + + // Vcvars finds the correct version of the Windows 10 SDK by looking + // for the include `um\Windows.h` because sometimes a given version will + // only have UCRT bits without the rest of the SDK. Since we only care about + // libraries and not includes, we instead look for `um\x64\kernel32.lib`. + // Since the 32-bit and 64-bit libraries are always installed together we + // only need to bother checking x64, making this code a tiny bit simpler. + // Like we do for the Universal CRT, we sort the possibilities + // asciibetically to find the newest one as that is what vcvars does. + fn get_sdk10_dir() -> Option<(PathBuf, String)> { + let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0"; + let key = LOCAL_MACHINE.open(key.as_ref()).ok()?; + let root = key.query_str("InstallationFolder").ok()?; + let readdir = Path::new(&root).join("lib").read_dir().ok()?; + let mut dirs = readdir + .filter_map(|dir| dir.ok()) + .map(|dir| dir.path()) + .collect::>(); + dirs.sort(); + let dir = dirs + .into_iter() + .rev() + .filter(|dir| dir.join("um").join("x64").join("kernel32.lib").is_file()) + .next()?; + let version = dir.components().last().unwrap(); + let version = version.as_os_str().to_str().unwrap().to_string(); + Some((root.into(), version)) + } + + // Interestingly there are several subdirectories, `win7` `win8` and + // `winv6.3`. Vcvars seems to only care about `winv6.3` though, so the same + // applies to us. Note that if we were targetting kernel mode drivers + // instead of user mode applications, we would care. + fn get_sdk81_dir() -> Option { + let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1"; + let key = LOCAL_MACHINE.open(key.as_ref()).ok()?; + let root = key.query_str("InstallationFolder").ok()?; + Some(root.into()) + } + + fn get_sdk8_dir() -> Option { + let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0"; + let key = LOCAL_MACHINE.open(key.as_ref()).ok()?; + let root = key.query_str("InstallationFolder").ok()?; + Some(root.into()) + } + + const PROCESSOR_ARCHITECTURE_INTEL: u16 = 0; + const PROCESSOR_ARCHITECTURE_AMD64: u16 = 9; + const X86: u16 = PROCESSOR_ARCHITECTURE_INTEL; + const X86_64: u16 = PROCESSOR_ARCHITECTURE_AMD64; + + // When choosing the tool to use, we have to choose the one which matches + // the target architecture. Otherwise we end up in situations where someone + // on 32-bit Windows is trying to cross compile to 64-bit and it tries to + // invoke the native 64-bit compiler which won't work. + // + // For the return value of this function, the first member of the tuple is + // the folder of the tool we will be invoking, while the second member is + // the folder of the host toolchain for that tool which is essential when + // using a cross linker. We return a Vec since on x64 there are often two + // linkers that can target the architecture we desire. The 64-bit host + // linker is preferred, and hence first, due to 64-bit allowing it more + // address space to work with and potentially being faster. + fn bin_subdir(target: &str) -> Vec<(&'static str, &'static str)> { + let arch = target.split('-').next().unwrap(); + match (arch, host_arch()) { + ("i586", X86) | ("i686", X86) => vec![("", "")], + ("i586", X86_64) | ("i686", X86_64) => vec![("amd64_x86", "amd64"), ("", "")], + ("x86_64", X86) => vec![("x86_amd64", "")], + ("x86_64", X86_64) => vec![("amd64", "amd64"), ("x86_amd64", "")], + ("arm", X86) | ("thumbv7a", X86) => vec![("x86_arm", "")], + ("arm", X86_64) | ("thumbv7a", X86_64) => vec![("amd64_arm", "amd64"), ("x86_arm", "")], + _ => vec![], + } + } + + fn lib_subdir(target: &str) -> Option<&'static str> { + let arch = target.split('-').next().unwrap(); + match arch { + "i586" | "i686" => Some("x86"), + "x86_64" => Some("x64"), + "arm" | "thumbv7a" => Some("arm"), + "aarch64" => Some("arm64"), + _ => None, + } + } + + // MSVC's x86 libraries are not in a subfolder + fn vc_lib_subdir(target: &str) -> Option<&'static str> { + let arch = target.split('-').next().unwrap(); + match arch { + "i586" | "i686" => Some(""), + "x86_64" => Some("amd64"), + "arm" | "thumbv7a" => Some("arm"), + "aarch64" => Some("arm64"), + _ => None, + } + } + + #[allow(bad_style)] + fn host_arch() -> u16 { + type DWORD = u32; + type WORD = u16; + type LPVOID = *mut u8; + type DWORD_PTR = usize; + + #[repr(C)] + struct SYSTEM_INFO { + wProcessorArchitecture: WORD, + _wReserved: WORD, + _dwPageSize: DWORD, + _lpMinimumApplicationAddress: LPVOID, + _lpMaximumApplicationAddress: LPVOID, + _dwActiveProcessorMask: DWORD_PTR, + _dwNumberOfProcessors: DWORD, + _dwProcessorType: DWORD, + _dwAllocationGranularity: DWORD, + _wProcessorLevel: WORD, + _wProcessorRevision: WORD, + } + + extern "system" { + fn GetNativeSystemInfo(lpSystemInfo: *mut SYSTEM_INFO); + } + + unsafe { + let mut info = mem::zeroed(); + GetNativeSystemInfo(&mut info); + info.wProcessorArchitecture + } + } + + // Given a registry key, look at all the sub keys and find the one which has + // the maximal numeric value. + // + // Returns the name of the maximal key as well as the opened maximal key. + fn max_version(key: &RegistryKey) -> Option<(OsString, RegistryKey)> { + let mut max_vers = 0; + let mut max_key = None; + for subkey in key.iter().filter_map(|k| k.ok()) { + let val = subkey + .to_str() + .and_then(|s| s.trim_left_matches("v").replace(".", "").parse().ok()); + let val = match val { + Some(s) => s, + None => continue, + }; + if val > max_vers { + if let Ok(k) = key.open(&subkey) { + max_vers = val; + max_key = Some((subkey, k)); + } + } + } + max_key + } + + pub fn has_msbuild_version(version: &str) -> bool { + match version { + "16.0" => { + find_msbuild_vs16("x86_64-pc-windows-msvc").is_some() + || find_msbuild_vs16("i686-pc-windows-msvc").is_some() + } + "15.0" => { + find_msbuild_vs15("x86_64-pc-windows-msvc").is_some() + || find_msbuild_vs15("i686-pc-windows-msvc").is_some() + } + "12.0" | "14.0" => LOCAL_MACHINE + .open(&OsString::from(format!( + "SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\{}", + version + ))) + .is_ok(), + _ => false, + } + } + + pub fn find_devenv(target: &str) -> Option { + find_devenv_vs15(&target) + } + + fn find_devenv_vs15(target: &str) -> Option { + find_tool_in_vs15_path(r"Common7\IDE\devenv.exe", target) + } + + // see http://stackoverflow.com/questions/328017/path-to-msbuild + pub fn find_msbuild(target: &str) -> Option { + // VS 15 (2017) changed how to locate msbuild + if let Some(r) = find_msbuild_vs16(target) { + return Some(r); + } else if let Some(r) = find_msbuild_vs15(target) { + return Some(r); + } else { + find_old_msbuild(target) + } + } + + fn find_msbuild_vs15(target: &str) -> Option { + find_tool_in_vs15_path(r"MSBuild\15.0\Bin\MSBuild.exe", target) + } + + fn find_old_msbuild(target: &str) -> Option { + let key = r"SOFTWARE\Microsoft\MSBuild\ToolsVersions"; + LOCAL_MACHINE + .open(key.as_ref()) + .ok() + .and_then(|key| { + max_version(&key).and_then(|(_vers, key)| key.query_str("MSBuildToolsPath").ok()) + }) + .map(|path| { + let mut path = PathBuf::from(path); + path.push("MSBuild.exe"); + let mut tool = Tool::new(path); + if target.contains("x86_64") { + tool.env.push(("Platform".into(), "X64".into())); + } + tool + }) + } +} diff --git a/third_party/cargo/vendor/cc-1.0.50/tests/cc_env.rs b/third_party/cargo/vendor/cc-1.0.50/tests/cc_env.rs new file mode 100644 index 0000000..43eb689 --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/tests/cc_env.rs @@ -0,0 +1,118 @@ +use std::env; +use std::ffi::OsString; +use std::path::Path; + +mod support; +use crate::support::Test; + +#[test] +fn main() { + ccache(); + distcc(); + ccache_spaces(); + ccache_env_flags(); + leading_spaces(); + extra_flags(); + path_to_ccache(); + more_spaces(); +} + +fn ccache() { + let test = Test::gnu(); + + env::set_var("CC", "ccache cc"); + let compiler = test.gcc().file("foo.c").get_compiler(); + + assert_eq!(compiler.path(), Path::new("cc")); +} + +fn ccache_spaces() { + let test = Test::gnu(); + test.shim("ccache"); + + env::set_var("CC", "ccache cc"); + let compiler = test.gcc().file("foo.c").get_compiler(); + assert_eq!(compiler.path(), Path::new("cc")); +} + +fn distcc() { + let test = Test::gnu(); + test.shim("distcc"); + + env::set_var("CC", "distcc cc"); + let compiler = test.gcc().file("foo.c").get_compiler(); + assert_eq!(compiler.path(), Path::new("cc")); +} + +fn ccache_env_flags() { + let test = Test::gnu(); + test.shim("ccache"); + + env::set_var("CC", "ccache lol-this-is-not-a-compiler"); + let compiler = test.gcc().file("foo.c").get_compiler(); + assert_eq!(compiler.path(), Path::new("lol-this-is-not-a-compiler")); + assert_eq!( + compiler.cc_env(), + OsString::from("ccache lol-this-is-not-a-compiler") + ); + assert!( + compiler + .cflags_env() + .into_string() + .unwrap() + .contains("ccache") + == false + ); + assert!( + compiler + .cflags_env() + .into_string() + .unwrap() + .contains(" lol-this-is-not-a-compiler") + == false + ); + + env::set_var("CC", ""); +} + +fn leading_spaces() { + let test = Test::gnu(); + test.shim("ccache"); + + env::set_var("CC", " test "); + let compiler = test.gcc().file("foo.c").get_compiler(); + assert_eq!(compiler.path(), Path::new("test")); + + env::set_var("CC", ""); +} + +fn extra_flags() { + let test = Test::gnu(); + test.shim("ccache"); + + env::set_var("CC", "ccache cc -m32"); + let compiler = test.gcc().file("foo.c").get_compiler(); + assert_eq!(compiler.path(), Path::new("cc")); +} + +fn path_to_ccache() { + let test = Test::gnu(); + test.shim("ccache"); + + env::set_var("CC", "/path/to/ccache.exe cc -m32"); + let compiler = test.gcc().file("foo.c").get_compiler(); + assert_eq!(compiler.path(), Path::new("cc")); + assert_eq!( + compiler.cc_env(), + OsString::from("/path/to/ccache.exe cc -m32"), + ); +} + +fn more_spaces() { + let test = Test::gnu(); + test.shim("ccache"); + + env::set_var("CC", "cc -m32"); + let compiler = test.gcc().file("foo.c").get_compiler(); + assert_eq!(compiler.path(), Path::new("cc")); +} diff --git a/third_party/cargo/vendor/cc-1.0.50/tests/cflags.rs b/third_party/cargo/vendor/cc-1.0.50/tests/cflags.rs new file mode 100644 index 0000000..caec6ea --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/tests/cflags.rs @@ -0,0 +1,15 @@ +mod support; + +use crate::support::Test; +use std::env; + +/// This test is in its own module because it modifies the environment and would affect other tests +/// when run in parallel with them. +#[test] +fn gnu_no_warnings_if_cflags() { + env::set_var("CFLAGS", "-arbitrary"); + let test = Test::gnu(); + test.gcc().file("foo.c").compile("foo"); + + test.cmd(0).must_not_have("-Wall").must_not_have("-Wextra"); +} diff --git a/third_party/cargo/vendor/cc-1.0.50/tests/cxxflags.rs b/third_party/cargo/vendor/cc-1.0.50/tests/cxxflags.rs new file mode 100644 index 0000000..c524c7d --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/tests/cxxflags.rs @@ -0,0 +1,15 @@ +mod support; + +use crate::support::Test; +use std::env; + +/// This test is in its own module because it modifies the environment and would affect other tests +/// when run in parallel with them. +#[test] +fn gnu_no_warnings_if_cxxflags() { + env::set_var("CXXFLAGS", "-arbitrary"); + let test = Test::gnu(); + test.gcc().file("foo.cpp").cpp(true).compile("foo"); + + test.cmd(0).must_not_have("-Wall").must_not_have("-Wextra"); +} diff --git a/third_party/cargo/vendor/cc-1.0.50/tests/support/mod.rs b/third_party/cargo/vendor/cc-1.0.50/tests/support/mod.rs new file mode 100644 index 0000000..fe8acde --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/tests/support/mod.rs @@ -0,0 +1,161 @@ +#![allow(dead_code)] + +use std::env; +use std::ffi::{OsStr, OsString}; +use std::fs::{self, File}; +use std::io; +use std::io::prelude::*; +use std::path::{Path, PathBuf}; + +use cc; +use tempfile::{Builder, TempDir}; + +pub struct Test { + pub td: TempDir, + pub gcc: PathBuf, + pub msvc: bool, +} + +pub struct Execution { + args: Vec, +} + +impl Test { + pub fn new() -> Test { + let mut gcc = PathBuf::from(env::current_exe().unwrap()); + gcc.pop(); + if gcc.ends_with("deps") { + gcc.pop(); + } + let td = Builder::new().prefix("gcc-test").tempdir_in(&gcc).unwrap(); + gcc.push(format!("gcc-shim{}", env::consts::EXE_SUFFIX)); + Test { + td: td, + gcc: gcc, + msvc: false, + } + } + + pub fn gnu() -> Test { + let t = Test::new(); + t.shim("cc").shim("c++").shim("ar"); + t + } + + pub fn msvc() -> Test { + let mut t = Test::new(); + t.shim("cl").shim("lib.exe"); + t.msvc = true; + t + } + + pub fn shim(&self, name: &str) -> &Test { + link_or_copy( + &self.gcc, + self.td + .path() + .join(&format!("{}{}", name, env::consts::EXE_SUFFIX)), + ) + .unwrap(); + self + } + + pub fn gcc(&self) -> cc::Build { + let mut cfg = cc::Build::new(); + let target = if self.msvc { + "x86_64-pc-windows-msvc" + } else { + "x86_64-unknown-linux-gnu" + }; + + cfg.target(target) + .host(target) + .opt_level(2) + .debug(false) + .out_dir(self.td.path()) + .__set_env("PATH", self.path()) + .__set_env("GCCTEST_OUT_DIR", self.td.path()); + if self.msvc { + cfg.compiler(self.td.path().join("cl")); + cfg.archiver(self.td.path().join("lib.exe")); + } + cfg + } + + fn path(&self) -> OsString { + let mut path = env::split_paths(&env::var_os("PATH").unwrap()).collect::>(); + path.insert(0, self.td.path().to_owned()); + env::join_paths(path).unwrap() + } + + pub fn cmd(&self, i: u32) -> Execution { + let mut s = String::new(); + File::open(self.td.path().join(format!("out{}", i))) + .unwrap() + .read_to_string(&mut s) + .unwrap(); + Execution { + args: s.lines().map(|s| s.to_string()).collect(), + } + } +} + +impl Execution { + pub fn must_have>(&self, p: P) -> &Execution { + if !self.has(p.as_ref()) { + panic!("didn't find {:?} in {:?}", p.as_ref(), self.args); + } else { + self + } + } + + pub fn must_not_have>(&self, p: P) -> &Execution { + if self.has(p.as_ref()) { + panic!("found {:?}", p.as_ref()); + } else { + self + } + } + + pub fn has(&self, p: &OsStr) -> bool { + self.args.iter().any(|arg| OsStr::new(arg) == p) + } + + pub fn must_have_in_order(&self, before: &str, after: &str) -> &Execution { + let before_position = self + .args + .iter() + .rposition(|x| OsStr::new(x) == OsStr::new(before)); + let after_position = self + .args + .iter() + .rposition(|x| OsStr::new(x) == OsStr::new(after)); + match (before_position, after_position) { + (Some(b), Some(a)) if b < a => {} + (b, a) => panic!( + "{:?} (last position: {:?}) did not appear before {:?} (last position: {:?})", + before, b, after, a + ), + }; + self + } +} + +/// Hard link an executable or copy it if that fails. +/// +/// We first try to hard link an executable to save space. If that fails (as on Windows with +/// different mount points, issue #60), we copy. +#[cfg(not(target_os = "macos"))] +fn link_or_copy, Q: AsRef>(from: P, to: Q) -> io::Result<()> { + let from = from.as_ref(); + let to = to.as_ref(); + fs::hard_link(from, to).or_else(|_| fs::copy(from, to).map(|_| ())) +} + +/// Copy an executable. +/// +/// On macOS, hard linking the executable leads to strange failures (issue #419), so we just copy. +#[cfg(target_os = "macos")] +fn link_or_copy, Q: AsRef>(from: P, to: Q) -> io::Result<()> { + fs::copy(from, to).map(|_| ()) +} diff --git a/third_party/cargo/vendor/cc-1.0.50/tests/test.rs b/third_party/cargo/vendor/cc-1.0.50/tests/test.rs new file mode 100644 index 0000000..def11f0 --- /dev/null +++ b/third_party/cargo/vendor/cc-1.0.50/tests/test.rs @@ -0,0 +1,377 @@ +use crate::support::Test; + +mod support; + +#[test] +fn gnu_smoke() { + let test = Test::gnu(); + test.gcc().file("foo.c").compile("foo"); + + test.cmd(0) + .must_have("-O2") + .must_have("foo.c") + .must_not_have("-g") + .must_have("-c") + .must_have("-ffunction-sections") + .must_have("-fdata-sections"); + test.cmd(1).must_have(test.td.path().join("foo.o")); +} + +#[test] +fn gnu_opt_level_1() { + let test = Test::gnu(); + test.gcc().opt_level(1).file("foo.c").compile("foo"); + + test.cmd(0).must_have("-O1").must_not_have("-O2"); +} + +#[test] +fn gnu_opt_level_s() { + let test = Test::gnu(); + test.gcc().opt_level_str("s").file("foo.c").compile("foo"); + + test.cmd(0) + .must_have("-Os") + .must_not_have("-O1") + .must_not_have("-O2") + .must_not_have("-O3") + .must_not_have("-Oz"); +} + +#[test] +fn gnu_debug_fp_auto() { + let test = Test::gnu(); + test.gcc().debug(true).file("foo.c").compile("foo"); + test.cmd(0).must_have("-g"); + test.cmd(0).must_have("-fno-omit-frame-pointer"); +} + +#[test] +fn gnu_debug_fp() { + let test = Test::gnu(); + test.gcc().debug(true).file("foo.c").compile("foo"); + test.cmd(0).must_have("-g"); + test.cmd(0).must_have("-fno-omit-frame-pointer"); +} + +#[test] +fn gnu_debug_nofp() { + let test = Test::gnu(); + test.gcc() + .debug(true) + .force_frame_pointer(false) + .file("foo.c") + .compile("foo"); + test.cmd(0).must_have("-g"); + test.cmd(0).must_not_have("-fno-omit-frame-pointer"); + + let test = Test::gnu(); + test.gcc() + .force_frame_pointer(false) + .debug(true) + .file("foo.c") + .compile("foo"); + test.cmd(0).must_have("-g"); + test.cmd(0).must_not_have("-fno-omit-frame-pointer"); +} + +#[test] +fn gnu_warnings_into_errors() { + let test = Test::gnu(); + test.gcc() + .warnings_into_errors(true) + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_have("-Werror"); +} + +#[test] +fn gnu_warnings() { + let test = Test::gnu(); + test.gcc() + .warnings(true) + .flag("-Wno-missing-field-initializers") + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_have("-Wall").must_have("-Wextra"); +} + +#[test] +fn gnu_extra_warnings0() { + let test = Test::gnu(); + test.gcc() + .warnings(true) + .extra_warnings(false) + .flag("-Wno-missing-field-initializers") + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_have("-Wall").must_not_have("-Wextra"); +} + +#[test] +fn gnu_extra_warnings1() { + let test = Test::gnu(); + test.gcc() + .warnings(false) + .extra_warnings(true) + .flag("-Wno-missing-field-initializers") + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_not_have("-Wall").must_have("-Wextra"); +} + +#[test] +fn gnu_warnings_overridable() { + let test = Test::gnu(); + test.gcc() + .warnings(true) + .flag("-Wno-missing-field-initializers") + .file("foo.c") + .compile("foo"); + + test.cmd(0) + .must_have_in_order("-Wall", "-Wno-missing-field-initializers"); +} + +#[test] +fn gnu_x86_64() { + for vendor in &["unknown-linux-gnu", "apple-darwin"] { + let target = format!("x86_64-{}", vendor); + let test = Test::gnu(); + test.gcc() + .target(&target) + .host(&target) + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_have("-fPIC").must_have("-m64"); + } +} + +#[test] +fn gnu_x86_64_no_pic() { + for vendor in &["unknown-linux-gnu", "apple-darwin"] { + let target = format!("x86_64-{}", vendor); + let test = Test::gnu(); + test.gcc() + .pic(false) + .target(&target) + .host(&target) + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_not_have("-fPIC"); + } +} + +#[test] +fn gnu_i686() { + for vendor in &["unknown-linux-gnu", "apple-darwin"] { + let target = format!("i686-{}", vendor); + let test = Test::gnu(); + test.gcc() + .target(&target) + .host(&target) + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_have("-m32"); + } +} + +#[test] +fn gnu_i686_pic() { + for vendor in &["unknown-linux-gnu", "apple-darwin"] { + let target = format!("i686-{}", vendor); + let test = Test::gnu(); + test.gcc() + .pic(true) + .target(&target) + .host(&target) + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_have("-fPIC"); + } +} + +#[test] +fn gnu_x86_64_no_plt() { + let target = "x86_64-unknown-linux-gnu"; + let test = Test::gnu(); + test.gcc() + .pic(true) + .use_plt(false) + .target(&target) + .host(&target) + .file("foo.c") + .compile("foo"); + test.cmd(0).must_have("-fno-plt"); +} + +#[test] +fn gnu_set_stdlib() { + let test = Test::gnu(); + test.gcc() + .cpp_set_stdlib(Some("foo")) + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_not_have("-stdlib=foo"); +} + +#[test] +fn gnu_include() { + let test = Test::gnu(); + test.gcc().include("foo/bar").file("foo.c").compile("foo"); + + test.cmd(0).must_have("-I").must_have("foo/bar"); +} + +#[test] +fn gnu_define() { + let test = Test::gnu(); + test.gcc() + .define("FOO", "bar") + .define("BAR", None) + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_have("-DFOO=bar").must_have("-DBAR"); +} + +#[test] +fn gnu_compile_assembly() { + let test = Test::gnu(); + test.gcc().file("foo.S").compile("foo"); + test.cmd(0).must_have("foo.S"); +} + +#[test] +fn gnu_shared() { + let test = Test::gnu(); + test.gcc() + .file("foo.c") + .shared_flag(true) + .static_flag(false) + .compile("foo"); + + test.cmd(0).must_have("-shared").must_not_have("-static"); +} + +#[test] +fn gnu_flag_if_supported() { + if cfg!(windows) { + return; + } + let test = Test::gnu(); + test.gcc() + .file("foo.c") + .flag("-v") + .flag_if_supported("-Wall") + .flag_if_supported("-Wflag-does-not-exist") + .flag_if_supported("-std=c++11") + .compile("foo"); + + test.cmd(0) + .must_have("-v") + .must_have("-Wall") + .must_not_have("-Wflag-does-not-exist") + .must_not_have("-std=c++11"); +} + +#[test] +fn gnu_flag_if_supported_cpp() { + if cfg!(windows) { + return; + } + let test = Test::gnu(); + test.gcc() + .cpp(true) + .file("foo.cpp") + .flag_if_supported("-std=c++11") + .compile("foo"); + + test.cmd(0).must_have("-std=c++11"); +} + +#[test] +fn gnu_static() { + let test = Test::gnu(); + test.gcc() + .file("foo.c") + .shared_flag(false) + .static_flag(true) + .compile("foo"); + + test.cmd(0).must_have("-static").must_not_have("-shared"); +} + +#[test] +fn msvc_smoke() { + let test = Test::msvc(); + test.gcc().file("foo.c").compile("foo"); + + test.cmd(0) + .must_have("-O2") + .must_have("foo.c") + .must_not_have("-Z7") + .must_have("-c") + .must_have("-MD"); + test.cmd(1).must_have(test.td.path().join("foo.o")); +} + +#[test] +fn msvc_opt_level_0() { + let test = Test::msvc(); + test.gcc().opt_level(0).file("foo.c").compile("foo"); + + test.cmd(0).must_not_have("-O2"); +} + +#[test] +fn msvc_debug() { + let test = Test::msvc(); + test.gcc().debug(true).file("foo.c").compile("foo"); + test.cmd(0).must_have("-Z7"); +} + +#[test] +fn msvc_include() { + let test = Test::msvc(); + test.gcc().include("foo/bar").file("foo.c").compile("foo"); + + test.cmd(0).must_have("-I").must_have("foo/bar"); +} + +#[test] +fn msvc_define() { + let test = Test::msvc(); + test.gcc() + .define("FOO", "bar") + .define("BAR", None) + .file("foo.c") + .compile("foo"); + + test.cmd(0).must_have("-DFOO=bar").must_have("-DBAR"); +} + +#[test] +fn msvc_static_crt() { + let test = Test::msvc(); + test.gcc().static_crt(true).file("foo.c").compile("foo"); + + test.cmd(0).must_have("-MT"); +} + +#[test] +fn msvc_no_static_crt() { + let test = Test::msvc(); + test.gcc().static_crt(false).file("foo.c").compile("foo"); + + test.cmd(0).must_have("-MD"); +} diff --git a/third_party/cargo/vendor/cfg-if-0.1.10/.cargo-checksum.json b/third_party/cargo/vendor/cfg-if-0.1.10/.cargo-checksum.json new file mode 100644 index 0000000..c0c9f9d --- /dev/null +++ b/third_party/cargo/vendor/cfg-if-0.1.10/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"2cb2370b62c56a7d51b51f9e405b2f377b3ad6f7f8d33bc69e20eb819ad66012","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"2406e83ee174e30aa67f8ab266836fa78545012b196395aff37c152321e2c713","src/lib.rs":"8dfd667d32d8b06e529643c975dfa14c29ce9a894a80e381a1bd867252e65e56","tests/xcrate.rs":"c0734dae6e63beafcd60bf53546115a2320735b51035c9e2387fdf9301580934"},"package":"4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"} \ No newline at end of file diff --git a/third_party/cargo/vendor/cfg-if-0.1.10/BUILD b/third_party/cargo/vendor/cfg-if-0.1.10/BUILD new file mode 100644 index 0000000..8c99d36 --- /dev/null +++ b/third_party/cargo/vendor/cfg-if-0.1.10/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "cfg_if", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.10", + crate_features = [ + ], +) + +# Unsupported target "xcrate" with type "test" omitted diff --git a/third_party/cargo/vendor/cfg-if-0.1.10/Cargo.toml b/third_party/cargo/vendor/cfg-if-0.1.10/Cargo.toml new file mode 100644 index 0000000..5da1d1b --- /dev/null +++ b/third_party/cargo/vendor/cfg-if-0.1.10/Cargo.toml @@ -0,0 +1,36 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "cfg-if" +version = "0.1.10" +authors = ["Alex Crichton "] +description = "A macro to ergonomically define an item depending on a large number of #[cfg]\nparameters. Structured like an if-else chain, the first matching branch is the\nitem that gets emitted.\n" +homepage = "https://github.com/alexcrichton/cfg-if" +documentation = "https://docs.rs/cfg-if" +readme = "README.md" +license = "MIT/Apache-2.0" +repository = "https://github.com/alexcrichton/cfg-if" +[dependencies.compiler_builtins] +version = "0.1.2" +optional = true + +[dependencies.core] +version = "1.0.0" +optional = true +package = "rustc-std-workspace-core" + +[features] +rustc-dep-of-std = ["core", "compiler_builtins"] +[badges.travis-ci] +repository = "alexcrichton/cfg-if" diff --git a/third_party/cargo/vendor/cfg-if-0.1.10/LICENSE-APACHE b/third_party/cargo/vendor/cfg-if-0.1.10/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/cfg-if-0.1.10/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/cfg-if-0.1.10/LICENSE-MIT b/third_party/cargo/vendor/cfg-if-0.1.10/LICENSE-MIT new file mode 100644 index 0000000..39e0ed6 --- /dev/null +++ b/third_party/cargo/vendor/cfg-if-0.1.10/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/cfg-if-0.1.10/README.md b/third_party/cargo/vendor/cfg-if-0.1.10/README.md new file mode 100644 index 0000000..50b5e3b --- /dev/null +++ b/third_party/cargo/vendor/cfg-if-0.1.10/README.md @@ -0,0 +1,47 @@ +# cfg-if + +[Documentation](https://docs.rs/cfg-if) + +A macro to ergonomically define an item depending on a large number of #[cfg] +parameters. Structured like an if-else chain, the first matching branch is the +item that gets emitted. + +```toml +[dependencies] +cfg-if = "0.1" +``` + +## Example + +```rust +cfg_if::cfg_if! { + if #[cfg(unix)] { + fn foo() { /* unix specific functionality */ } + } else if #[cfg(target_pointer_width = "32")] { + fn foo() { /* non-unix, 32-bit functionality */ } + } else { + fn foo() { /* fallback implementation */ } + } +} + +fn main() { + foo(); +} +``` + +# License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in `cfg-if` by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/cfg-if-0.1.10/src/lib.rs b/third_party/cargo/vendor/cfg-if-0.1.10/src/lib.rs new file mode 100644 index 0000000..6c5058d --- /dev/null +++ b/third_party/cargo/vendor/cfg-if-0.1.10/src/lib.rs @@ -0,0 +1,176 @@ +//! A macro for defining `#[cfg]` if-else statements. +//! +//! The macro provided by this crate, `cfg_if`, is similar to the `if/elif` C +//! preprocessor macro by allowing definition of a cascade of `#[cfg]` cases, +//! emitting the implementation which matches first. +//! +//! This allows you to conveniently provide a long list `#[cfg]`'d blocks of code +//! without having to rewrite each clause multiple times. +//! +//! # Example +//! +//! ``` +//! cfg_if::cfg_if! { +//! if #[cfg(unix)] { +//! fn foo() { /* unix specific functionality */ } +//! } else if #[cfg(target_pointer_width = "32")] { +//! fn foo() { /* non-unix, 32-bit functionality */ } +//! } else { +//! fn foo() { /* fallback implementation */ } +//! } +//! } +//! +//! # fn main() {} +//! ``` + +#![no_std] +#![doc(html_root_url = "https://docs.rs/cfg-if")] +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] + +/// The main macro provided by this crate. See crate documentation for more +/// information. +#[macro_export] +macro_rules! cfg_if { + // match if/else chains with a final `else` + ($( + if #[cfg($($meta:meta),*)] { $($tokens:tt)* } + ) else * else { + $($tokens2:tt)* + }) => { + $crate::cfg_if! { + @__items + () ; + $( ( ($($meta),*) ($($tokens)*) ), )* + ( () ($($tokens2)*) ), + } + }; + + // match if/else chains lacking a final `else` + ( + if #[cfg($($i_met:meta),*)] { $($i_tokens:tt)* } + $( + else if #[cfg($($e_met:meta),*)] { $($e_tokens:tt)* } + )* + ) => { + $crate::cfg_if! { + @__items + () ; + ( ($($i_met),*) ($($i_tokens)*) ), + $( ( ($($e_met),*) ($($e_tokens)*) ), )* + ( () () ), + } + }; + + // Internal and recursive macro to emit all the items + // + // Collects all the negated cfgs in a list at the beginning and after the + // semicolon is all the remaining items + (@__items ($($not:meta,)*) ; ) => {}; + (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($tokens:tt)*) ), $($rest:tt)*) => { + // Emit all items within one block, applying an appropriate #[cfg]. The + // #[cfg] will require all `$m` matchers specified and must also negate + // all previous matchers. + #[cfg(all($($m,)* not(any($($not),*))))] $crate::cfg_if! { @__identity $($tokens)* } + + // Recurse to emit all other items in `$rest`, and when we do so add all + // our `$m` matchers to the list of `$not` matchers as future emissions + // will have to negate everything we just matched as well. + $crate::cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* } + }; + + // Internal macro to make __apply work out right for different match types, + // because of how macros matching/expand stuff. + (@__identity $($tokens:tt)*) => { + $($tokens)* + }; +} + +#[cfg(test)] +mod tests { + cfg_if! { + if #[cfg(test)] { + use core::option::Option as Option2; + fn works1() -> Option2 { Some(1) } + } else { + fn works1() -> Option { None } + } + } + + cfg_if! { + if #[cfg(foo)] { + fn works2() -> bool { false } + } else if #[cfg(test)] { + fn works2() -> bool { true } + } else { + fn works2() -> bool { false } + } + } + + cfg_if! { + if #[cfg(foo)] { + fn works3() -> bool { false } + } else { + fn works3() -> bool { true } + } + } + + cfg_if! { + if #[cfg(test)] { + use core::option::Option as Option3; + fn works4() -> Option3 { Some(1) } + } + } + + cfg_if! { + if #[cfg(foo)] { + fn works5() -> bool { false } + } else if #[cfg(test)] { + fn works5() -> bool { true } + } + } + + #[test] + fn it_works() { + assert!(works1().is_some()); + assert!(works2()); + assert!(works3()); + assert!(works4().is_some()); + assert!(works5()); + } + + #[test] + #[allow(clippy::assertions_on_constants)] + fn test_usage_within_a_function() { + cfg_if! {if #[cfg(debug_assertions)] { + // we want to put more than one thing here to make sure that they + // all get configured properly. + assert!(cfg!(debug_assertions)); + assert_eq!(4, 2+2); + } else { + assert!(works1().is_some()); + assert_eq!(10, 5+5); + }} + } + + trait Trait { + fn blah(&self); + } + + #[allow(dead_code)] + struct Struct; + + impl Trait for Struct { + cfg_if! { + if #[cfg(feature = "blah")] { + fn blah(&self) { + unimplemented!(); + } + } else { + fn blah(&self) { + unimplemented!(); + } + } + } + } +} diff --git a/third_party/cargo/vendor/cfg-if-0.1.10/tests/xcrate.rs b/third_party/cargo/vendor/cfg-if-0.1.10/tests/xcrate.rs new file mode 100644 index 0000000..e7b4a36 --- /dev/null +++ b/third_party/cargo/vendor/cfg-if-0.1.10/tests/xcrate.rs @@ -0,0 +1,14 @@ +cfg_if::cfg_if! { + if #[cfg(foo)] { + fn works() -> bool { false } + } else if #[cfg(test)] { + fn works() -> bool { true } + } else { + fn works() -> bool { false } + } +} + +#[test] +fn smoke() { + assert!(works()); +} diff --git a/third_party/cargo/vendor/cloudabi-0.0.3/.cargo-checksum.json b/third_party/cargo/vendor/cloudabi-0.0.3/.cargo-checksum.json new file mode 100644 index 0000000..f79ba65 --- /dev/null +++ b/third_party/cargo/vendor/cloudabi-0.0.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"16ef935056e2aaf48b28c1340a63cc75febaabc901c752da9a3a2edbe081b429","bitflags.rs":"4621173dcf1307094cf240d26955b6f25c2f770dfd4e975ec2728771209006b5","cloudabi.rs":"93e139ba72a04db4934b04a6f21b054757a218a687e0bd2f6ba32514ec8c5f38"},"package":"ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"} \ No newline at end of file diff --git a/third_party/cargo/vendor/cloudabi-0.0.3/BUILD b/third_party/cargo/vendor/cloudabi-0.0.3/BUILD new file mode 100644 index 0000000..a2ea462 --- /dev/null +++ b/third_party/cargo/vendor/cloudabi-0.0.3/BUILD @@ -0,0 +1,45 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "BSD-2-Clause" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "cloudabi", + crate_root = "cloudabi.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/bitflags-1.2.1:bitflags", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.0.3", + crate_features = [ + "bitflags", + "default", + ], +) + diff --git a/third_party/cargo/vendor/cloudabi-0.0.3/Cargo.toml b/third_party/cargo/vendor/cloudabi-0.0.3/Cargo.toml new file mode 100644 index 0000000..ed0daf9 --- /dev/null +++ b/third_party/cargo/vendor/cloudabi-0.0.3/Cargo.toml @@ -0,0 +1,31 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "cloudabi" +version = "0.0.3" +authors = ["Nuxi (https://nuxi.nl/) and contributors"] +description = "Low level interface to CloudABI. Contains all syscalls and related types." +homepage = "https://nuxi.nl/cloudabi/" +documentation = "https://docs.rs/cloudabi/" +keywords = ["cloudabi"] +license = "BSD-2-Clause" +repository = "https://github.com/nuxinl/cloudabi" + +[lib] +path = "cloudabi.rs" +[dependencies.bitflags] +version = "1.0" +optional = true + +[features] +default = ["bitflags"] diff --git a/third_party/cargo/vendor/cloudabi-0.0.3/bitflags.rs b/third_party/cargo/vendor/cloudabi-0.0.3/bitflags.rs new file mode 100644 index 0000000..f764cc1 --- /dev/null +++ b/third_party/cargo/vendor/cloudabi-0.0.3/bitflags.rs @@ -0,0 +1,51 @@ +// Copyright (c) 2018 Nuxi (https://nuxi.nl/) and contributors. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. + +// Appease Rust's tidy. +// ignore-license + +#[cfg(feature = "bitflags")] +#[macro_use] +extern crate bitflags; + +// Minimal implementation of bitflags! in case we can't depend on the bitflags +// crate. Only implements `bits()` and a `from_bits_truncate()` that doesn't +// actually truncate. +#[cfg(not(feature = "bitflags"))] +macro_rules! bitflags { + ( + $(#[$attr:meta])* + pub struct $name:ident: $type:ty { + $($(#[$const_attr:meta])* const $const:ident = $val:expr;)* + } + ) => { + $(#[$attr])* + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] + pub struct $name { bits: $type } + impl $name { + $($(#[$const_attr])* pub const $const: $name = $name{ bits: $val };)* + pub fn bits(&self) -> $type { self.bits } + pub fn from_bits_truncate(bits: $type) -> Self { $name{ bits } } + } + } +} diff --git a/third_party/cargo/vendor/cloudabi-0.0.3/cloudabi.rs b/third_party/cargo/vendor/cloudabi-0.0.3/cloudabi.rs new file mode 100644 index 0000000..2909db5 --- /dev/null +++ b/third_party/cargo/vendor/cloudabi-0.0.3/cloudabi.rs @@ -0,0 +1,2847 @@ +// Copyright (c) 2016-2017 Nuxi (https://nuxi.nl/) and contributors. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// This file is automatically generated. Do not edit. +// +// Source: https://github.com/NuxiNL/cloudabi + +// Appease Rust's tidy. +// ignore-license +// ignore-tidy-linelength + +//! **PLEASE NOTE: This entire crate including this +//! documentation is automatically generated from +//! [`cloudabi.txt`](https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt)** +//! +//! # Nuxi CloudABI +//! +//! CloudABI is what you get if you take POSIX, add capability-based +//! security, and remove everything that's incompatible with that. The +//! result is a minimal ABI consisting of only 49 syscalls. +//! +//! CloudABI doesn't have its own kernel, but instead is implemented in existing +//! kernels: FreeBSD has CloudABI support for x86-64 and arm64, and [a patch-set +//! for NetBSD](https://github.com/NuxiNL/netbsd) and [a patch-set for +//! Linux](https://github.com/NuxiNL/linux) are available as well. This means that +//! CloudABI binaries can be executed on different operating systems, without any +//! modification. +//! +//! ## Capability-Based Security +//! +//! Capability-based security means that processes can only perform +//! actions that have no global impact. Processes cannot open files by +//! their absolute path, cannot open network connections, and cannot +//! observe global system state such as the process table. +//! +//! The capabilities of a process are fully determined by its set of open +//! file descriptors (fds). For example, files can only be opened if the +//! process already has a file descriptor to a directory the file is in. +//! +//! Unlike in POSIX, where processes are normally started with file +//! descriptors 0, 1, and 2 reserved for standard input, output, and +//! error, CloudABI does not reserve any file descriptor numbers for +//! specific purposes. +//! +//! In CloudABI, a process depends on its parent process to launch it with +//! the right set of resources, since the process will not be able to open +//! any new resources. For example, a simple static web server would need +//! to be started with a file descriptor to a [TCP +//! listener](https://github.com/NuxiNL/flower), and a file descriptor to +//! the directory for which to serve files. The web server will then be +//! unable to do anything other than reading files in that directory, and +//! process incoming network connections. +//! +//! So, unknown CloudABI binaries can safely be executed without the need +//! for containers, virtual machines, or other sandboxing technologies. +//! +//! Watch [Ed Schouten's Talk at +//! 32C3](https://www.youtube.com/watch?v=3N29vrPoDv8) for more +//! information about what capability-based security for UNIX means. +//! +//! ## Cloudlibc +//! +//! [Cloudlibc](https://github.com/NuxiNL/cloudlibc) is an implementation +//! of the C standard library, without all CloudABI-incompatible +//! functions. For example, Cloudlibc does not have `printf`, but does +//! have `fprintf`. It does not have `open`, but does have `openat`. +//! +//! ## CloudABI-Ports +//! +//! [CloudABI-Ports](https://github.com/NuxiNL/cloudabi-ports) is a +//! collection of ports of commonly used libraries and applications to +//! CloudABI. It contains software such as `zlib`, `libpng`, `boost`, +//! `memcached`, and much more. The software is patched to not depend on +//! any global state, such as files in `/etc` or `/dev`, using `open()`, +//! etc. +//! +//! ## Using CloudABI +//! +//! Instructions for using CloudABI (including kernel modules/patches, +//! toolchain, and ports) are available for several operating systems: +//! +//! - [Arch Linux](https://nuxi.nl/cloudabi/archlinux/) +//! - [Debian, Ubuntu, and other Debian derivatives](https://nuxi.nl/cloudabi/debian/) +//! - [FreeBSD, PC-BSD and DragonFly BSD](https://nuxi.nl/cloudabi/freebsd/) +//! - [Mac OS X](https://nuxi.nl/cloudabi/mac/) +//! - [NetBSD](https://nuxi.nl/cloudabi/netbsd/) +//! +//! ## Specification of the ABI +//! +//! The entire ABI is specified in a a file called +//! [`cloudabi.txt`](https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt), +//! from which all +//! [headers](https://github.com/NuxiNL/cloudabi/tree/master/headers) +//! and documentation (including the one you're reading now) is generated. + +#![no_std] +#![allow(non_camel_case_types)] + +include!("bitflags.rs"); + +/// File or memory access pattern advisory information. +#[repr(u8)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub enum advice { + /// The application expects that it will not access the + /// specified data in the near future. + DONTNEED = 1, + /// The application expects to access the specified data + /// once and then not reuse it thereafter. + NOREUSE = 2, + /// The application has no advice to give on its behavior + /// with respect to the specified data. + NORMAL = 3, + /// The application expects to access the specified data + /// in a random order. + RANDOM = 4, + /// The application expects to access the specified data + /// sequentially from lower offsets to higher offsets. + SEQUENTIAL = 5, + /// The application expects to access the specified data + /// in the near future. + WILLNEED = 6, + #[doc(hidden)] _NonExhaustive = -1 as isize as u8, +} + +/// Enumeration describing the kind of value stored in [`auxv`](struct.auxv.html). +#[repr(u32)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub enum auxtype { + /// Base address of the binary argument data provided to + /// [`proc_exec()`](fn.proc_exec.html). + ARGDATA = 256, + /// Length of the binary argument data provided to + /// [`proc_exec()`](fn.proc_exec.html). + ARGDATALEN = 257, + /// Base address at which the executable is placed in + /// memory. + BASE = 7, + /// Base address of a buffer of random data that may be + /// used for non-cryptographic purposes, for example as a + /// canary for stack smashing protection. + CANARY = 258, + /// Length of a buffer of random data that may be used + /// for non-cryptographic purposes, for example as a + /// canary for stack smashing protection. + CANARYLEN = 259, + /// Number of CPUs that the system this process is running + /// on has. + NCPUS = 260, + /// Terminator of the auxiliary vector. + NULL = 0, + /// Smallest memory object size for which individual + /// memory protection controls can be configured. + PAGESZ = 6, + /// Address of the first ELF program header of the + /// executable. + PHDR = 3, + /// Number of ELF program headers of the executable. + PHNUM = 4, + /// Identifier of the process. + /// + /// This environment does not provide any simple numerical + /// process identifiers, for the reason that these are not + /// useful in distributed contexts. Instead, processes are + /// identified by a UUID. + /// + /// This record should point to sixteen bytes of binary + /// data, containing a version 4 UUID (fully random). + PID = 263, + /// Address of the ELF header of the vDSO. + /// + /// The vDSO is a shared library that is mapped in the + /// address space of the process. It provides entry points + /// for every system call supported by the environment, + /// all having a corresponding symbol that is prefixed + /// with `cloudabi_sys_`. System calls should be invoked + /// through these entry points. + /// + /// The first advantage of letting processes call into a + /// vDSO to perform system calls instead of raising + /// hardware traps is that it allows for easy emulation of + /// executables on top of existing operating systems. The + /// second advantage is that in cases where an operating + /// system provides native support for CloudABI executables, + /// it may still implement partial userspace + /// implementations of these system calls to improve + /// performance (e.g., [`clock_time_get()`](fn.clock_time_get.html)). It also provides + /// a more dynamic way of adding, removing or replacing + /// system calls. + SYSINFO_EHDR = 262, + /// Thread ID of the initial thread of the process. + TID = 261, + #[doc(hidden)] _NonExhaustive = -1 as isize as u32, +} + +/// Identifiers for clocks. +#[repr(u32)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub enum clockid { + /// The system-wide monotonic clock, which is defined as a + /// clock measuring real time, whose value cannot be + /// adjusted and which cannot have negative clock jumps. + /// + /// The epoch of this clock is undefined. The absolute + /// time value of this clock therefore has no meaning. + MONOTONIC = 1, + /// The CPU-time clock associated with the current + /// process. + PROCESS_CPUTIME_ID = 2, + /// The system-wide clock measuring real time. Time value + /// zero corresponds with 1970-01-01T00:00:00Z. + REALTIME = 3, + /// The CPU-time clock associated with the current thread. + THREAD_CPUTIME_ID = 4, + #[doc(hidden)] _NonExhaustive = -1 as isize as u32, +} + +/// A userspace condition variable. +#[repr(C)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub struct condvar(pub u32); +/// The condition variable is in its initial state. There +/// are no threads waiting to be woken up. If the +/// condition variable has any other value, the kernel +/// must be called to wake up any sleeping threads. +pub const CONDVAR_HAS_NO_WAITERS: condvar = condvar(0); + +/// Identifier for a device containing a file system. Can be used +/// in combination with [`inode`](struct.inode.html) to uniquely identify a file on the +/// local system. +#[repr(C)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub struct device(pub u64); + +/// A reference to the offset of a directory entry. +#[repr(C)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub struct dircookie(pub u64); +/// Permanent reference to the first directory entry +/// within a directory. +pub const DIRCOOKIE_START: dircookie = dircookie(0); + +/// Error codes returned by system calls. +/// +/// Not all of these error codes are returned by the system calls +/// provided by this environment, but are either used in userspace +/// exclusively or merely provided for alignment with POSIX. +#[repr(u16)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub enum errno { + /// No error occurred. System call completed successfully. + SUCCESS = 0, + /// Argument list too long. + TOOBIG = 1, + /// Permission denied. + ACCES = 2, + /// Address in use. + ADDRINUSE = 3, + /// Address not available. + ADDRNOTAVAIL = 4, + /// Address family not supported. + AFNOSUPPORT = 5, + /// Resource unavailable, or operation would block. + AGAIN = 6, + /// Connection already in progress. + ALREADY = 7, + /// Bad file descriptor. + BADF = 8, + /// Bad message. + BADMSG = 9, + /// Device or resource busy. + BUSY = 10, + /// Operation canceled. + CANCELED = 11, + /// No child processes. + CHILD = 12, + /// Connection aborted. + CONNABORTED = 13, + /// Connection refused. + CONNREFUSED = 14, + /// Connection reset. + CONNRESET = 15, + /// Resource deadlock would occur. + DEADLK = 16, + /// Destination address required. + DESTADDRREQ = 17, + /// Mathematics argument out of domain of function. + DOM = 18, + /// Reserved. + DQUOT = 19, + /// File exists. + EXIST = 20, + /// Bad address. + FAULT = 21, + /// File too large. + FBIG = 22, + /// Host is unreachable. + HOSTUNREACH = 23, + /// Identifier removed. + IDRM = 24, + /// Illegal byte sequence. + ILSEQ = 25, + /// Operation in progress. + INPROGRESS = 26, + /// Interrupted function. + INTR = 27, + /// Invalid argument. + INVAL = 28, + /// I/O error. + IO = 29, + /// Socket is connected. + ISCONN = 30, + /// Is a directory. + ISDIR = 31, + /// Too many levels of symbolic links. + LOOP = 32, + /// File descriptor value too large. + MFILE = 33, + /// Too many links. + MLINK = 34, + /// Message too large. + MSGSIZE = 35, + /// Reserved. + MULTIHOP = 36, + /// Filename too long. + NAMETOOLONG = 37, + /// Network is down. + NETDOWN = 38, + /// Connection aborted by network. + NETRESET = 39, + /// Network unreachable. + NETUNREACH = 40, + /// Too many files open in system. + NFILE = 41, + /// No buffer space available. + NOBUFS = 42, + /// No such device. + NODEV = 43, + /// No such file or directory. + NOENT = 44, + /// Executable file format error. + NOEXEC = 45, + /// No locks available. + NOLCK = 46, + /// Reserved. + NOLINK = 47, + /// Not enough space. + NOMEM = 48, + /// No message of the desired type. + NOMSG = 49, + /// Protocol not available. + NOPROTOOPT = 50, + /// No space left on device. + NOSPC = 51, + /// Function not supported. + NOSYS = 52, + /// The socket is not connected. + NOTCONN = 53, + /// Not a directory or a symbolic link to a directory. + NOTDIR = 54, + /// Directory not empty. + NOTEMPTY = 55, + /// State not recoverable. + NOTRECOVERABLE = 56, + /// Not a socket. + NOTSOCK = 57, + /// Not supported, or operation not supported on socket. + NOTSUP = 58, + /// Inappropriate I/O control operation. + NOTTY = 59, + /// No such device or address. + NXIO = 60, + /// Value too large to be stored in data type. + OVERFLOW = 61, + /// Previous owner died. + OWNERDEAD = 62, + /// Operation not permitted. + PERM = 63, + /// Broken pipe. + PIPE = 64, + /// Protocol error. + PROTO = 65, + /// Protocol not supported. + PROTONOSUPPORT = 66, + /// Protocol wrong type for socket. + PROTOTYPE = 67, + /// Result too large. + RANGE = 68, + /// Read-only file system. + ROFS = 69, + /// Invalid seek. + SPIPE = 70, + /// No such process. + SRCH = 71, + /// Reserved. + STALE = 72, + /// Connection timed out. + TIMEDOUT = 73, + /// Text file busy. + TXTBSY = 74, + /// Cross-device link. + XDEV = 75, + /// Extension: Capabilities insufficient. + NOTCAPABLE = 76, + #[doc(hidden)] _NonExhaustive = -1 as isize as u16, +} + +bitflags! { + /// The state of the file descriptor subscribed to with + /// [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE). + #[repr(C)] + pub struct eventrwflags: u16 { + /// The peer of this socket has closed or disconnected. + const HANGUP = 0x0001; + } +} + +/// Type of a subscription to an event or its occurrence. +#[repr(u8)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub enum eventtype { + /// The time value of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id) + /// has reached timestamp [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout). + CLOCK = 1, + /// Condition variable [`subscription.union.condvar.condvar`](struct.subscription_condvar.html#structfield.condvar) has + /// been woken up and [`subscription.union.condvar.lock`](struct.subscription_condvar.html#structfield.lock) has been + /// acquired for writing. + CONDVAR = 2, + /// File descriptor [`subscription.union.fd_readwrite.fd`](struct.subscription_fd_readwrite.html#structfield.fd) has + /// data available for reading. This event always triggers + /// for regular files. + FD_READ = 3, + /// File descriptor [`subscription.union.fd_readwrite.fd`](struct.subscription_fd_readwrite.html#structfield.fd) has + /// capacity available for writing. This event always + /// triggers for regular files. + FD_WRITE = 4, + /// Lock [`subscription.union.lock.lock`](struct.subscription_lock.html#structfield.lock) has been acquired for + /// reading. + LOCK_RDLOCK = 5, + /// Lock [`subscription.union.lock.lock`](struct.subscription_lock.html#structfield.lock) has been acquired for + /// writing. + LOCK_WRLOCK = 6, + /// The process associated with process descriptor + /// [`subscription.union.proc_terminate.fd`](struct.subscription_proc_terminate.html#structfield.fd) has terminated. + PROC_TERMINATE = 7, + #[doc(hidden)] _NonExhaustive = -1 as isize as u8, +} + +/// Exit code generated by a process when exiting. +pub type exitcode = u32; + +/// A file descriptor number. +/// +/// Unlike on POSIX-compliant systems, none of the file descriptor +/// numbers are reserved for a purpose (e.g., stdin, stdout, +/// stderr). Operating systems are not required to allocate new +/// file descriptors in ascending order. +#[repr(C)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub struct fd(pub u32); +/// Returned to the child process by [`proc_fork()`](fn.proc_fork.html). +pub const PROCESS_CHILD: fd = fd(0xffffffff); +/// Passed to [`mem_map()`](fn.mem_map.html) when creating a mapping to +/// anonymous memory. +pub const MAP_ANON_FD : fd = fd(0xffffffff); + +bitflags! { + /// File descriptor flags. + #[repr(C)] + pub struct fdflags: u16 { + /// Append mode: Data written to the file is always + /// appended to the file's end. + const APPEND = 0x0001; + /// Write according to synchronized I/O data integrity + /// completion. Only the data stored in the file is + /// synchronized. + const DSYNC = 0x0002; + /// Non-blocking mode. + const NONBLOCK = 0x0004; + /// Synchronized read I/O operations. + const RSYNC = 0x0008; + /// Write according to synchronized I/O file integrity + /// completion. In addition to synchronizing the data + /// stored in the file, the system may also synchronously + /// update the file's metadata. + const SYNC = 0x0010; + } +} + +bitflags! { + /// Which file descriptor attributes to adjust. + #[repr(C)] + pub struct fdsflags: u16 { + /// Adjust the file descriptor flags stored in + /// [`fdstat.fs_flags`](struct.fdstat.html#structfield.fs_flags). + const FLAGS = 0x0001; + /// Restrict the rights of the file descriptor to the + /// rights stored in [`fdstat.fs_rights_base`](struct.fdstat.html#structfield.fs_rights_base) and + /// [`fdstat.fs_rights_inheriting`](struct.fdstat.html#structfield.fs_rights_inheriting). + const RIGHTS = 0x0002; + } +} + +/// Relative offset within a file. +pub type filedelta = i64; + +/// Non-negative file size or length of a region within a file. +pub type filesize = u64; + +/// The type of a file descriptor or file. +#[repr(u8)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub enum filetype { + /// The type of the file descriptor or file is unknown or + /// is different from any of the other types specified. + UNKNOWN = 0, + /// The file descriptor or file refers to a block device + /// inode. + BLOCK_DEVICE = 16, + /// The file descriptor or file refers to a character + /// device inode. + CHARACTER_DEVICE = 17, + /// The file descriptor or file refers to a directory + /// inode. + DIRECTORY = 32, + /// The file descriptor refers to a process handle. + PROCESS = 80, + /// The file descriptor or file refers to a regular file + /// inode. + REGULAR_FILE = 96, + /// The file descriptor refers to a shared memory object. + SHARED_MEMORY = 112, + /// The file descriptor or file refers to a datagram + /// socket. + SOCKET_DGRAM = 128, + /// The file descriptor or file refers to a byte-stream + /// socket. + SOCKET_STREAM = 130, + /// The file refers to a symbolic link inode. + SYMBOLIC_LINK = 144, + #[doc(hidden)] _NonExhaustive = -1 as isize as u8, +} + +bitflags! { + /// Which file attributes to adjust. + #[repr(C)] + pub struct fsflags: u16 { + /// Adjust the last data access timestamp to the value + /// stored in [`filestat.st_atim`](struct.filestat.html#structfield.st_atim). + const ATIM = 0x0001; + /// Adjust the last data access timestamp to the time + /// of clock [`REALTIME`](enum.clockid.html#variant.REALTIME). + const ATIM_NOW = 0x0002; + /// Adjust the last data modification timestamp to the + /// value stored in [`filestat.st_mtim`](struct.filestat.html#structfield.st_mtim). + const MTIM = 0x0004; + /// Adjust the last data modification timestamp to the + /// time of clock [`REALTIME`](enum.clockid.html#variant.REALTIME). + const MTIM_NOW = 0x0008; + /// Truncate or extend the file to the size stored in + /// [`filestat.st_size`](struct.filestat.html#structfield.st_size). + const SIZE = 0x0010; + } +} + +/// File serial number that is unique within its file system. +#[repr(C)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub struct inode(pub u64); + +/// Number of hard links to an inode. +pub type linkcount = u32; + +/// A userspace read-recursive readers-writer lock, similar to a +/// Linux futex or a FreeBSD umtx. +#[repr(C)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub struct lock(pub u32); +/// Value indicating that the lock is in its initial +/// unlocked state. +pub const LOCK_UNLOCKED : lock = lock(0x00000000); +/// Bitmask indicating that the lock is write-locked. If +/// set, the lower 30 bits of the lock contain the +/// identifier of the thread that owns the write lock. +/// Otherwise, the lower 30 bits of the lock contain the +/// number of acquired read locks. +pub const LOCK_WRLOCKED : lock = lock(0x40000000); +/// Bitmask indicating that the lock is either read locked +/// or write locked, and that one or more threads have +/// their execution suspended, waiting to acquire the +/// lock. The last owner of the lock must call the +/// kernel to unlock. +/// +/// When the lock is acquired for reading and this bit is +/// set, it means that one or more threads are attempting +/// to acquire this lock for writing. In that case, other +/// threads should only acquire additional read locks if +/// suspending execution would cause a deadlock. It is +/// preferred to suspend execution, as this prevents +/// starvation of writers. +pub const LOCK_KERNEL_MANAGED: lock = lock(0x80000000); +/// Value indicating that the lock is in an incorrect +/// state. A lock cannot be in its initial unlocked state, +/// while also managed by the kernel. +pub const LOCK_BOGUS : lock = lock(0x80000000); + +bitflags! { + /// Flags determining the method of how paths are resolved. + #[repr(C)] + pub struct lookupflags: u32 { + /// As long as the resolved path corresponds to a symbolic + /// link, it is expanded. + const SYMLINK_FOLLOW = 0x00000001; + } +} + +bitflags! { + /// Memory mapping flags. + #[repr(C)] + pub struct mflags: u8 { + /// Instead of mapping the contents of the file provided, + /// create a mapping to anonymous memory. The file + /// descriptor argument must be set to [`MAP_ANON_FD`](constant.MAP_ANON_FD.html), + /// and the offset must be set to zero. + const ANON = 0x01; + /// Require that the mapping is performed at the base + /// address provided. + const FIXED = 0x02; + /// Changes are private. + const PRIVATE = 0x04; + /// Changes are shared. + const SHARED = 0x08; + } +} + +bitflags! { + /// Memory page protection options. + /// + /// This implementation enforces the `W^X` property: Pages cannot be + /// mapped for execution while also mapped for writing. + #[repr(C)] + pub struct mprot: u8 { + /// Page can be executed. + const EXEC = 0x01; + /// Page can be written. + const WRITE = 0x02; + /// Page can be read. + const READ = 0x04; + } +} + +bitflags! { + /// Methods of synchronizing memory with physical storage. + #[repr(C)] + pub struct msflags: u8 { + /// Perform asynchronous writes. + const ASYNC = 0x01; + /// Invalidate cached data. + const INVALIDATE = 0x02; + /// Perform synchronous writes. + const SYNC = 0x04; + } +} + +/// Specifies the number of threads sleeping on a condition +/// variable that should be woken up. +pub type nthreads = u32; + +bitflags! { + /// Open flags used by [`file_open()`](fn.file_open.html). + #[repr(C)] + pub struct oflags: u16 { + /// Create file if it does not exist. + const CREAT = 0x0001; + /// Fail if not a directory. + const DIRECTORY = 0x0002; + /// Fail if file already exists. + const EXCL = 0x0004; + /// Truncate file to size 0. + const TRUNC = 0x0008; + } +} + +bitflags! { + /// Flags provided to [`sock_recv()`](fn.sock_recv.html). + #[repr(C)] + pub struct riflags: u16 { + /// Returns the message without removing it from the + /// socket's receive queue. + const PEEK = 0x0004; + /// On byte-stream sockets, block until the full amount + /// of data can be returned. + const WAITALL = 0x0010; + } +} + +bitflags! { + /// File descriptor rights, determining which actions may be + /// performed. + #[repr(C)] + pub struct rights: u64 { + /// The right to invoke [`fd_datasync()`](fn.fd_datasync.html). + /// + /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to + /// invoke [`file_open()`](fn.file_open.html) with [`DSYNC`](struct.fdflags.html#associatedconstant.DSYNC). + const FD_DATASYNC = 0x0000000000000001; + /// The right to invoke [`fd_read()`](fn.fd_read.html) and [`sock_recv()`](fn.sock_recv.html). + /// + /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, includes the right to + /// invoke [`mem_map()`](fn.mem_map.html) with memory protection option + /// [`READ`](struct.mprot.html#associatedconstant.READ). + /// + /// If [`FD_SEEK`](struct.rights.html#associatedconstant.FD_SEEK) is set, includes the right to invoke + /// [`fd_pread()`](fn.fd_pread.html). + const FD_READ = 0x0000000000000002; + /// The right to invoke [`fd_seek()`](fn.fd_seek.html). This flag implies + /// [`FD_TELL`](struct.rights.html#associatedconstant.FD_TELL). + const FD_SEEK = 0x0000000000000004; + /// The right to invoke [`fd_stat_put()`](fn.fd_stat_put.html) with + /// [`FLAGS`](struct.fdsflags.html#associatedconstant.FLAGS). + const FD_STAT_PUT_FLAGS = 0x0000000000000008; + /// The right to invoke [`fd_sync()`](fn.fd_sync.html). + /// + /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to + /// invoke [`file_open()`](fn.file_open.html) with [`RSYNC`](struct.fdflags.html#associatedconstant.RSYNC) and + /// [`DSYNC`](struct.fdflags.html#associatedconstant.DSYNC). + const FD_SYNC = 0x0000000000000010; + /// The right to invoke [`fd_seek()`](fn.fd_seek.html) in such a way that the + /// file offset remains unaltered (i.e., [`CUR`](enum.whence.html#variant.CUR) with + /// offset zero). + const FD_TELL = 0x0000000000000020; + /// The right to invoke [`fd_write()`](fn.fd_write.html) and [`sock_send()`](fn.sock_send.html). + /// + /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, includes the right to + /// invoke [`mem_map()`](fn.mem_map.html) with memory protection option + /// [`WRITE`](struct.mprot.html#associatedconstant.WRITE). + /// + /// If [`FD_SEEK`](struct.rights.html#associatedconstant.FD_SEEK) is set, includes the right to + /// invoke [`fd_pwrite()`](fn.fd_pwrite.html). + const FD_WRITE = 0x0000000000000040; + /// The right to invoke [`file_advise()`](fn.file_advise.html). + const FILE_ADVISE = 0x0000000000000080; + /// The right to invoke [`file_allocate()`](fn.file_allocate.html). + const FILE_ALLOCATE = 0x0000000000000100; + /// The right to invoke [`file_create()`](fn.file_create.html) with + /// [`DIRECTORY`](enum.filetype.html#variant.DIRECTORY). + const FILE_CREATE_DIRECTORY = 0x0000000000000200; + /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, the right to invoke + /// [`file_open()`](fn.file_open.html) with [`CREAT`](struct.oflags.html#associatedconstant.CREAT). + const FILE_CREATE_FILE = 0x0000000000000400; + /// The right to invoke [`file_link()`](fn.file_link.html) with the file + /// descriptor as the source directory. + const FILE_LINK_SOURCE = 0x0000000000001000; + /// The right to invoke [`file_link()`](fn.file_link.html) with the file + /// descriptor as the target directory. + const FILE_LINK_TARGET = 0x0000000000002000; + /// The right to invoke [`file_open()`](fn.file_open.html). + const FILE_OPEN = 0x0000000000004000; + /// The right to invoke [`file_readdir()`](fn.file_readdir.html). + const FILE_READDIR = 0x0000000000008000; + /// The right to invoke [`file_readlink()`](fn.file_readlink.html). + const FILE_READLINK = 0x0000000000010000; + /// The right to invoke [`file_rename()`](fn.file_rename.html) with the file + /// descriptor as the source directory. + const FILE_RENAME_SOURCE = 0x0000000000020000; + /// The right to invoke [`file_rename()`](fn.file_rename.html) with the file + /// descriptor as the target directory. + const FILE_RENAME_TARGET = 0x0000000000040000; + /// The right to invoke [`file_stat_fget()`](fn.file_stat_fget.html). + const FILE_STAT_FGET = 0x0000000000080000; + /// The right to invoke [`file_stat_fput()`](fn.file_stat_fput.html) with + /// [`SIZE`](struct.fsflags.html#associatedconstant.SIZE). + /// + /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to + /// invoke [`file_open()`](fn.file_open.html) with [`TRUNC`](struct.oflags.html#associatedconstant.TRUNC). + const FILE_STAT_FPUT_SIZE = 0x0000000000100000; + /// The right to invoke [`file_stat_fput()`](fn.file_stat_fput.html) with + /// [`ATIM`](struct.fsflags.html#associatedconstant.ATIM), [`ATIM_NOW`](struct.fsflags.html#associatedconstant.ATIM_NOW), [`MTIM`](struct.fsflags.html#associatedconstant.MTIM), + /// and [`MTIM_NOW`](struct.fsflags.html#associatedconstant.MTIM_NOW). + const FILE_STAT_FPUT_TIMES = 0x0000000000200000; + /// The right to invoke [`file_stat_get()`](fn.file_stat_get.html). + const FILE_STAT_GET = 0x0000000000400000; + /// The right to invoke [`file_stat_put()`](fn.file_stat_put.html) with + /// [`ATIM`](struct.fsflags.html#associatedconstant.ATIM), [`ATIM_NOW`](struct.fsflags.html#associatedconstant.ATIM_NOW), [`MTIM`](struct.fsflags.html#associatedconstant.MTIM), + /// and [`MTIM_NOW`](struct.fsflags.html#associatedconstant.MTIM_NOW). + const FILE_STAT_PUT_TIMES = 0x0000000000800000; + /// The right to invoke [`file_symlink()`](fn.file_symlink.html). + const FILE_SYMLINK = 0x0000000001000000; + /// The right to invoke [`file_unlink()`](fn.file_unlink.html). + const FILE_UNLINK = 0x0000000002000000; + /// The right to invoke [`mem_map()`](fn.mem_map.html) with [`mprot`](struct.mprot.html) set to + /// zero. + const MEM_MAP = 0x0000000004000000; + /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, the right to invoke + /// [`mem_map()`](fn.mem_map.html) with [`EXEC`](struct.mprot.html#associatedconstant.EXEC). + const MEM_MAP_EXEC = 0x0000000008000000; + /// If [`FD_READ`](struct.rights.html#associatedconstant.FD_READ) is set, includes the right to + /// invoke [`poll()`](fn.poll.html) to subscribe to [`FD_READ`](enum.eventtype.html#variant.FD_READ). + /// + /// If [`FD_WRITE`](struct.rights.html#associatedconstant.FD_WRITE) is set, includes the right to + /// invoke [`poll()`](fn.poll.html) to subscribe to [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE). + const POLL_FD_READWRITE = 0x0000000010000000; + /// The right to invoke [`poll()`](fn.poll.html) to subscribe to + /// [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE). + const POLL_PROC_TERMINATE = 0x0000000040000000; + /// The right to invoke [`proc_exec()`](fn.proc_exec.html). + const PROC_EXEC = 0x0000000100000000; + /// The right to invoke [`sock_shutdown()`](fn.sock_shutdown.html). + const SOCK_SHUTDOWN = 0x0000008000000000; + } +} + +bitflags! { + /// Flags returned by [`sock_recv()`](fn.sock_recv.html). + #[repr(C)] + pub struct roflags: u16 { + /// Returned by [`sock_recv()`](fn.sock_recv.html): List of file descriptors + /// has been truncated. + const FDS_TRUNCATED = 0x0001; + /// Returned by [`sock_recv()`](fn.sock_recv.html): Message data has been + /// truncated. + const DATA_TRUNCATED = 0x0008; + } +} + +/// Indicates whether an object is stored in private or shared +/// memory. +#[repr(u8)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub enum scope { + /// The object is stored in private memory. + PRIVATE = 4, + /// The object is stored in shared memory. + SHARED = 8, + #[doc(hidden)] _NonExhaustive = -1 as isize as u8, +} + +bitflags! { + /// Which channels on a socket need to be shut down. + #[repr(C)] + pub struct sdflags: u8 { + /// Disables further receive operations. + const RD = 0x01; + /// Disables further send operations. + const WR = 0x02; + } +} + +bitflags! { + /// Flags provided to [`sock_send()`](fn.sock_send.html). As there are currently no flags + /// defined, it must be set to zero. + #[repr(C)] + pub struct siflags: u16 { + const DEFAULT = 0; + } +} + +/// Signal condition. +#[repr(u8)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub enum signal { + /// Process abort signal. + /// + /// Action: Terminates the process. + ABRT = 1, + /// Alarm clock. + /// + /// Action: Terminates the process. + ALRM = 2, + /// Access to an undefined portion of a memory object. + /// + /// Action: Terminates the process. + BUS = 3, + /// Child process terminated, stopped, or continued. + /// + /// Action: Ignored. + CHLD = 4, + /// Continue executing, if stopped. + /// + /// Action: Continues executing, if stopped. + CONT = 5, + /// Erroneous arithmetic operation. + /// + /// Action: Terminates the process. + FPE = 6, + /// Hangup. + /// + /// Action: Terminates the process. + HUP = 7, + /// Illegal instruction. + /// + /// Action: Terminates the process. + ILL = 8, + /// Terminate interrupt signal. + /// + /// Action: Terminates the process. + INT = 9, + /// Kill. + /// + /// Action: Terminates the process. + KILL = 10, + /// Write on a pipe with no one to read it. + /// + /// Action: Ignored. + PIPE = 11, + /// Terminal quit signal. + /// + /// Action: Terminates the process. + QUIT = 12, + /// Invalid memory reference. + /// + /// Action: Terminates the process. + SEGV = 13, + /// Stop executing. + /// + /// Action: Stops executing. + STOP = 14, + /// Bad system call. + /// + /// Action: Terminates the process. + SYS = 15, + /// Termination signal. + /// + /// Action: Terminates the process. + TERM = 16, + /// Trace/breakpoint trap. + /// + /// Action: Terminates the process. + TRAP = 17, + /// Terminal stop signal. + /// + /// Action: Stops executing. + TSTP = 18, + /// Background process attempting read. + /// + /// Action: Stops executing. + TTIN = 19, + /// Background process attempting write. + /// + /// Action: Stops executing. + TTOU = 20, + /// High bandwidth data is available at a socket. + /// + /// Action: Ignored. + URG = 21, + /// User-defined signal 1. + /// + /// Action: Terminates the process. + USR1 = 22, + /// User-defined signal 2. + /// + /// Action: Terminates the process. + USR2 = 23, + /// Virtual timer expired. + /// + /// Action: Terminates the process. + VTALRM = 24, + /// CPU time limit exceeded. + /// + /// Action: Terminates the process. + XCPU = 25, + /// File size limit exceeded. + /// + /// Action: Terminates the process. + XFSZ = 26, + #[doc(hidden)] _NonExhaustive = -1 as isize as u8, +} + +bitflags! { + /// Flags determining how the timestamp provided in + /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) should be interpreted. + #[repr(C)] + pub struct subclockflags: u16 { + /// If set, treat the timestamp provided in + /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) as an absolute timestamp + /// of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id). + /// + /// If clear, treat the timestamp provided in + /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) relative to the current + /// time value of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id). + const ABSTIME = 0x0001; + } +} + +bitflags! { + /// Flags influencing the method of polling for read or writing on + /// a file descriptor. + #[repr(C)] + pub struct subrwflags: u16 { + /// Deprecated. Must be set by callers and ignored by + /// implementations. + const POLL = 0x0001; + } +} + +/// Unique system-local identifier of a thread. This identifier is +/// only valid during the lifetime of the thread. +/// +/// Threads must be aware of their thread identifier, as it is +/// written it into locks when acquiring them for writing. It is +/// not advised to use these identifiers for any other purpose. +/// +/// As the thread identifier is also stored in [`lock`](struct.lock.html) when +/// [`LOCK_WRLOCKED`](constant.LOCK_WRLOCKED.html) is set, the top two bits of the thread +/// must always be set to zero. +#[repr(C)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub struct tid(pub u32); + +/// Timestamp in nanoseconds. +pub type timestamp = u64; + +bitflags! { + /// Specifies whether files are unlinked or directories are + /// removed. + #[repr(C)] + pub struct ulflags: u8 { + /// If set, removes a directory. Otherwise, unlinks any + /// non-directory file. + const REMOVEDIR = 0x01; + } +} + +/// User-provided value that can be attached to objects that is +/// retained when extracted from the kernel. +pub type userdata = u64; + +/// Relative to which position the offset of the file descriptor +/// should be set. +#[repr(u8)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub enum whence { + /// Seek relative to current position. + CUR = 1, + /// Seek relative to end-of-file. + END = 2, + /// Seek relative to start-of-file. + SET = 3, + #[doc(hidden)] _NonExhaustive = -1 as isize as u8, +} + +/// Auxiliary vector entry. +/// +/// The auxiliary vector is a list of key-value pairs that is +/// provided to the process on startup. Unlike structures, it is +/// extensible, as it is possible to add new records later on. +/// The auxiliary vector is always terminated by an entry having +/// type [`NULL`](enum.auxtype.html#variant.NULL). +/// +/// The auxiliary vector is part of the x86-64 ABI, but is used by +/// this environment on all architectures. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct auxv { + /// The type of the auxiliary vector entry. + pub a_type: auxtype, + pub union: auxv_union +} +/// A union inside `auxv`. +#[repr(C)] +#[derive(Copy, Clone)] +pub union auxv_union { + /// Used when `a_type` is [`ARGDATALEN`](enum.auxtype.html#variant.ARGDATALEN), [`CANARYLEN`](enum.auxtype.html#variant.CANARYLEN), [`NCPUS`](enum.auxtype.html#variant.NCPUS), [`PAGESZ`](enum.auxtype.html#variant.PAGESZ), [`PHNUM`](enum.auxtype.html#variant.PHNUM), or [`TID`](enum.auxtype.html#variant.TID). +/// A numerical value. + pub a_val: usize, + /// Used when `a_type` is [`ARGDATA`](enum.auxtype.html#variant.ARGDATA), [`BASE`](enum.auxtype.html#variant.BASE), [`CANARY`](enum.auxtype.html#variant.CANARY), [`PHDR`](enum.auxtype.html#variant.PHDR), [`PID`](enum.auxtype.html#variant.PID), or [`SYSINFO_EHDR`](enum.auxtype.html#variant.SYSINFO_EHDR). +/// A pointer value. + pub a_ptr: *mut (), +} +#[test] +#[cfg(target_pointer_width = "32")] +fn auxv_layout_test_32() { + assert_eq!(::core::mem::size_of::(), 8); + assert_eq!(::core::mem::align_of::(), 4); + unsafe { + let obj: auxv = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.a_type as *const _ as usize - base, 0); + assert_eq!(&obj.union.a_val as *const _ as usize - base, 4); + assert_eq!(&obj.union.a_ptr as *const _ as usize - base, 4); + } +} +#[test] +#[cfg(target_pointer_width = "64")] +fn auxv_layout_test_64() { + assert_eq!(::core::mem::size_of::(), 16); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: auxv = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.a_type as *const _ as usize - base, 0); + assert_eq!(&obj.union.a_val as *const _ as usize - base, 8); + assert_eq!(&obj.union.a_ptr as *const _ as usize - base, 8); + } +} + +/// A region of memory for scatter/gather writes. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct ciovec { + /// The address and length of the buffer to be written. + pub buf: (*const (), usize), +} +#[test] +#[cfg(target_pointer_width = "32")] +fn ciovec_layout_test_32() { + assert_eq!(::core::mem::size_of::(), 8); + assert_eq!(::core::mem::align_of::(), 4); + unsafe { + let obj: ciovec = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); + assert_eq!(&obj.buf.1 as *const _ as usize - base, 4); + } +} +#[test] +#[cfg(target_pointer_width = "64")] +fn ciovec_layout_test_64() { + assert_eq!(::core::mem::size_of::(), 16); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: ciovec = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); + assert_eq!(&obj.buf.1 as *const _ as usize - base, 8); + } +} + +/// A directory entry. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct dirent { + /// The offset of the next directory entry stored in this + /// directory. + pub d_next: dircookie, + /// The serial number of the file referred to by this + /// directory entry. + pub d_ino: inode, + /// The length of the name of the directory entry. + pub d_namlen: u32, + /// The type of the file referred to by this directory + /// entry. + pub d_type: filetype, +} +#[test] +fn dirent_layout_test() { + assert_eq!(::core::mem::size_of::(), 24); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: dirent = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.d_next as *const _ as usize - base, 0); + assert_eq!(&obj.d_ino as *const _ as usize - base, 8); + assert_eq!(&obj.d_namlen as *const _ as usize - base, 16); + assert_eq!(&obj.d_type as *const _ as usize - base, 20); + } +} + +/// An event that occurred. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct event { + /// User-provided value that got attached to + /// [`subscription.userdata`](struct.subscription.html#structfield.userdata). + pub userdata: userdata, + /// If non-zero, an error that occurred while processing + /// the subscription request. + pub error: errno, + /// The type of the event that occurred. + pub type_: eventtype, + pub union: event_union +} +/// A union inside `event`. +#[repr(C)] +#[derive(Copy, Clone)] +pub union event_union { + /// Used when `type_` is [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE). + pub fd_readwrite: event_fd_readwrite, + /// Used when `type_` is [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE). + pub proc_terminate: event_proc_terminate, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct event_fd_readwrite { + /// The number of bytes available + /// for reading or writing. + pub nbytes: filesize, + /// Obsolete. + pub unused: [u8; 4], + /// The state of the file + /// descriptor. + pub flags: eventrwflags, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct event_proc_terminate { + /// Obsolete. + pub unused: [u8; 4], + /// If zero, the process has + /// exited. + /// Otherwise, the signal + /// condition causing it to + /// terminated. + pub signal: signal, + /// If exited, the exit code of + /// the process. + pub exitcode: exitcode, +} +#[test] +fn event_layout_test() { + assert_eq!(::core::mem::size_of::(), 32); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: event = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.userdata as *const _ as usize - base, 0); + assert_eq!(&obj.error as *const _ as usize - base, 8); + assert_eq!(&obj.type_ as *const _ as usize - base, 10); + assert_eq!(&obj.union.fd_readwrite.nbytes as *const _ as usize - base, 16); + assert_eq!(&obj.union.fd_readwrite.unused as *const _ as usize - base, 24); + assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 28); + assert_eq!(&obj.union.proc_terminate.unused as *const _ as usize - base, 16); + assert_eq!(&obj.union.proc_terminate.signal as *const _ as usize - base, 20); + assert_eq!(&obj.union.proc_terminate.exitcode as *const _ as usize - base, 24); + } +} + +/// File descriptor attributes. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct fdstat { + /// File type. + pub fs_filetype: filetype, + /// File descriptor flags. + pub fs_flags: fdflags, + /// Rights that apply to this file descriptor. + pub fs_rights_base: rights, + /// Maximum set of rights that can be installed on new + /// file descriptors that are created through this file + /// descriptor, e.g., through [`file_open()`](fn.file_open.html). + pub fs_rights_inheriting: rights, +} +#[test] +fn fdstat_layout_test() { + assert_eq!(::core::mem::size_of::(), 24); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: fdstat = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.fs_filetype as *const _ as usize - base, 0); + assert_eq!(&obj.fs_flags as *const _ as usize - base, 2); + assert_eq!(&obj.fs_rights_base as *const _ as usize - base, 8); + assert_eq!(&obj.fs_rights_inheriting as *const _ as usize - base, 16); + } +} + +/// File attributes. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct filestat { + /// Device ID of device containing the file. + pub st_dev: device, + /// File serial number. + pub st_ino: inode, + /// File type. + pub st_filetype: filetype, + /// Number of hard links to the file. + pub st_nlink: linkcount, + /// For regular files, the file size in bytes. For + /// symbolic links, the length in bytes of the pathname + /// contained in the symbolic link. + pub st_size: filesize, + /// Last data access timestamp. + pub st_atim: timestamp, + /// Last data modification timestamp. + pub st_mtim: timestamp, + /// Last file status change timestamp. + pub st_ctim: timestamp, +} +#[test] +fn filestat_layout_test() { + assert_eq!(::core::mem::size_of::(), 56); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: filestat = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.st_dev as *const _ as usize - base, 0); + assert_eq!(&obj.st_ino as *const _ as usize - base, 8); + assert_eq!(&obj.st_filetype as *const _ as usize - base, 16); + assert_eq!(&obj.st_nlink as *const _ as usize - base, 20); + assert_eq!(&obj.st_size as *const _ as usize - base, 24); + assert_eq!(&obj.st_atim as *const _ as usize - base, 32); + assert_eq!(&obj.st_mtim as *const _ as usize - base, 40); + assert_eq!(&obj.st_ctim as *const _ as usize - base, 48); + } +} + +/// A region of memory for scatter/gather reads. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct iovec { + /// The address and length of the buffer to be filled. + pub buf: (*mut (), usize), +} +#[test] +#[cfg(target_pointer_width = "32")] +fn iovec_layout_test_32() { + assert_eq!(::core::mem::size_of::(), 8); + assert_eq!(::core::mem::align_of::(), 4); + unsafe { + let obj: iovec = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); + assert_eq!(&obj.buf.1 as *const _ as usize - base, 4); + } +} +#[test] +#[cfg(target_pointer_width = "64")] +fn iovec_layout_test_64() { + assert_eq!(::core::mem::size_of::(), 16); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: iovec = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); + assert_eq!(&obj.buf.1 as *const _ as usize - base, 8); + } +} + +/// Path lookup properties. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct lookup { + /// The working directory at which the resolution of the + /// path starts. + pub fd: fd, + /// Flags determining the method of how the path is + /// resolved. + pub flags: lookupflags, +} +#[test] +fn lookup_layout_test() { + assert_eq!(::core::mem::size_of::(), 8); + assert_eq!(::core::mem::align_of::(), 4); + unsafe { + let obj: lookup = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.fd as *const _ as usize - base, 0); + assert_eq!(&obj.flags as *const _ as usize - base, 4); + } +} + +/// Entry point for a process (`_start`). +/// +/// **auxv**: +/// The auxiliary vector. See [`auxv`](struct.auxv.html). +pub type processentry = unsafe extern "C" fn( + auxv: *const auxv, +) -> (); + +/// Arguments of [`sock_recv()`](fn.sock_recv.html). +#[repr(C)] +#[derive(Copy, Clone)] +pub struct recv_in { + /// List of scatter/gather vectors where message data + /// should be stored. + pub ri_data: (*const iovec, usize), + /// Buffer where numbers of incoming file descriptors + /// should be stored. + pub ri_fds: (*mut fd, usize), + /// Message flags. + pub ri_flags: riflags, +} +#[test] +#[cfg(target_pointer_width = "32")] +fn recv_in_layout_test_32() { + assert_eq!(::core::mem::size_of::(), 20); + assert_eq!(::core::mem::align_of::(), 4); + unsafe { + let obj: recv_in = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0); + assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 4); + assert_eq!(&obj.ri_fds.0 as *const _ as usize - base, 8); + assert_eq!(&obj.ri_fds.1 as *const _ as usize - base, 12); + assert_eq!(&obj.ri_flags as *const _ as usize - base, 16); + } +} +#[test] +#[cfg(target_pointer_width = "64")] +fn recv_in_layout_test_64() { + assert_eq!(::core::mem::size_of::(), 40); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: recv_in = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0); + assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 8); + assert_eq!(&obj.ri_fds.0 as *const _ as usize - base, 16); + assert_eq!(&obj.ri_fds.1 as *const _ as usize - base, 24); + assert_eq!(&obj.ri_flags as *const _ as usize - base, 32); + } +} + +/// Results of [`sock_recv()`](fn.sock_recv.html). +#[repr(C)] +#[derive(Copy, Clone)] +pub struct recv_out { + /// Number of bytes stored in [`recv_in.ri_data`](struct.recv_in.html#structfield.ri_data). + pub ro_datalen: usize, + /// Number of file descriptors stored in [`recv_in.ri_fds`](struct.recv_in.html#structfield.ri_fds). + pub ro_fdslen: usize, + /// Fields that were used by previous implementations. + pub ro_unused: [u8; 40], + /// Message flags. + pub ro_flags: roflags, +} +#[test] +#[cfg(target_pointer_width = "32")] +fn recv_out_layout_test_32() { + assert_eq!(::core::mem::size_of::(), 52); + assert_eq!(::core::mem::align_of::(), 4); + unsafe { + let obj: recv_out = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0); + assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 4); + assert_eq!(&obj.ro_unused as *const _ as usize - base, 8); + assert_eq!(&obj.ro_flags as *const _ as usize - base, 48); + } +} +#[test] +#[cfg(target_pointer_width = "64")] +fn recv_out_layout_test_64() { + assert_eq!(::core::mem::size_of::(), 64); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: recv_out = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0); + assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 8); + assert_eq!(&obj.ro_unused as *const _ as usize - base, 16); + assert_eq!(&obj.ro_flags as *const _ as usize - base, 56); + } +} + +/// Arguments of [`sock_send()`](fn.sock_send.html). +#[repr(C)] +#[derive(Copy, Clone)] +pub struct send_in { + /// List of scatter/gather vectors where message data + /// should be retrieved. + pub si_data: (*const ciovec, usize), + /// File descriptors that need to be attached to the + /// message. + pub si_fds: (*const fd, usize), + /// Message flags. + pub si_flags: siflags, +} +#[test] +#[cfg(target_pointer_width = "32")] +fn send_in_layout_test_32() { + assert_eq!(::core::mem::size_of::(), 20); + assert_eq!(::core::mem::align_of::(), 4); + unsafe { + let obj: send_in = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0); + assert_eq!(&obj.si_data.1 as *const _ as usize - base, 4); + assert_eq!(&obj.si_fds.0 as *const _ as usize - base, 8); + assert_eq!(&obj.si_fds.1 as *const _ as usize - base, 12); + assert_eq!(&obj.si_flags as *const _ as usize - base, 16); + } +} +#[test] +#[cfg(target_pointer_width = "64")] +fn send_in_layout_test_64() { + assert_eq!(::core::mem::size_of::(), 40); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: send_in = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0); + assert_eq!(&obj.si_data.1 as *const _ as usize - base, 8); + assert_eq!(&obj.si_fds.0 as *const _ as usize - base, 16); + assert_eq!(&obj.si_fds.1 as *const _ as usize - base, 24); + assert_eq!(&obj.si_flags as *const _ as usize - base, 32); + } +} + +/// Results of [`sock_send()`](fn.sock_send.html). +#[repr(C)] +#[derive(Copy, Clone)] +pub struct send_out { + /// Number of bytes transmitted. + pub so_datalen: usize, +} +#[test] +#[cfg(target_pointer_width = "32")] +fn send_out_layout_test_32() { + assert_eq!(::core::mem::size_of::(), 4); + assert_eq!(::core::mem::align_of::(), 4); + unsafe { + let obj: send_out = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.so_datalen as *const _ as usize - base, 0); + } +} +#[test] +#[cfg(target_pointer_width = "64")] +fn send_out_layout_test_64() { + assert_eq!(::core::mem::size_of::(), 8); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: send_out = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.so_datalen as *const _ as usize - base, 0); + } +} + +/// Subscription to an event. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct subscription { + /// User-provided value that is attached to the + /// subscription in the kernel and returned through + /// [`event.userdata`](struct.event.html#structfield.userdata). + pub userdata: userdata, + /// Used by previous implementations. Ignored. + pub unused: u16, + /// The type of the event to which to subscribe. + /// + /// Currently, [`CONDVAR`](enum.eventtype.html#variant.CONDVAR), + /// [`LOCK_RDLOCK`](enum.eventtype.html#variant.LOCK_RDLOCK), and [`LOCK_WRLOCK`](enum.eventtype.html#variant.LOCK_WRLOCK) + /// must be provided as the first subscription and may + /// only be followed by up to one other subscription, + /// having type [`CLOCK`](enum.eventtype.html#variant.CLOCK). + pub type_: eventtype, + pub union: subscription_union +} +/// A union inside `subscription`. +#[repr(C)] +#[derive(Copy, Clone)] +pub union subscription_union { + /// Used when `type_` is [`CLOCK`](enum.eventtype.html#variant.CLOCK). + pub clock: subscription_clock, + /// Used when `type_` is [`CONDVAR`](enum.eventtype.html#variant.CONDVAR). + pub condvar: subscription_condvar, + /// Used when `type_` is [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE). + pub fd_readwrite: subscription_fd_readwrite, + /// Used when `type_` is [`LOCK_RDLOCK`](enum.eventtype.html#variant.LOCK_RDLOCK) or [`LOCK_WRLOCK`](enum.eventtype.html#variant.LOCK_WRLOCK). + pub lock: subscription_lock, + /// Used when `type_` is [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE). + pub proc_terminate: subscription_proc_terminate, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct subscription_clock { + /// The user-defined unique + /// identifier of the clock. + pub identifier: userdata, + /// The clock against which the + /// timestamp should be compared. + pub clock_id: clockid, + /// The absolute or relative + /// timestamp. + pub timeout: timestamp, + /// The amount of time that the + /// kernel may wait additionally + /// to coalesce with other events. + pub precision: timestamp, + /// Flags specifying whether the + /// timeout is absolute or + /// relative. + pub flags: subclockflags, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct subscription_condvar { + /// The condition variable on + /// which to wait to be woken up. + pub condvar: *mut condvar, + /// The lock that will be + /// released while waiting. + /// + /// The lock will be reacquired + /// for writing when the condition + /// variable triggers. + pub lock: *mut lock, + /// Whether the condition variable + /// is stored in private or shared + /// memory. + pub condvar_scope: scope, + /// Whether the lock is stored in + /// private or shared memory. + pub lock_scope: scope, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct subscription_fd_readwrite { + /// The file descriptor on which + /// to wait for it to become ready + /// for reading or writing. + pub fd: fd, + /// Under which conditions to + /// trigger. + pub flags: subrwflags, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct subscription_lock { + /// The lock that will be acquired + /// for reading or writing. + pub lock: *mut lock, + /// Whether the lock is stored in + /// private or shared memory. + pub lock_scope: scope, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct subscription_proc_terminate { + /// The process descriptor on + /// which to wait for process + /// termination. + pub fd: fd, +} +#[test] +#[cfg(target_pointer_width = "32")] +fn subscription_layout_test_32() { + assert_eq!(::core::mem::size_of::(), 56); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: subscription = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.userdata as *const _ as usize - base, 0); + assert_eq!(&obj.unused as *const _ as usize - base, 8); + assert_eq!(&obj.type_ as *const _ as usize - base, 10); + assert_eq!(&obj.union.clock.identifier as *const _ as usize - base, 16); + assert_eq!(&obj.union.clock.clock_id as *const _ as usize - base, 24); + assert_eq!(&obj.union.clock.timeout as *const _ as usize - base, 32); + assert_eq!(&obj.union.clock.precision as *const _ as usize - base, 40); + assert_eq!(&obj.union.clock.flags as *const _ as usize - base, 48); + assert_eq!(&obj.union.condvar.condvar as *const _ as usize - base, 16); + assert_eq!(&obj.union.condvar.lock as *const _ as usize - base, 20); + assert_eq!(&obj.union.condvar.condvar_scope as *const _ as usize - base, 24); + assert_eq!(&obj.union.condvar.lock_scope as *const _ as usize - base, 25); + assert_eq!(&obj.union.fd_readwrite.fd as *const _ as usize - base, 16); + assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 20); + assert_eq!(&obj.union.lock.lock as *const _ as usize - base, 16); + assert_eq!(&obj.union.lock.lock_scope as *const _ as usize - base, 20); + assert_eq!(&obj.union.proc_terminate.fd as *const _ as usize - base, 16); + } +} +#[test] +#[cfg(target_pointer_width = "64")] +fn subscription_layout_test_64() { + assert_eq!(::core::mem::size_of::(), 56); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: subscription = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.userdata as *const _ as usize - base, 0); + assert_eq!(&obj.unused as *const _ as usize - base, 8); + assert_eq!(&obj.type_ as *const _ as usize - base, 10); + assert_eq!(&obj.union.clock.identifier as *const _ as usize - base, 16); + assert_eq!(&obj.union.clock.clock_id as *const _ as usize - base, 24); + assert_eq!(&obj.union.clock.timeout as *const _ as usize - base, 32); + assert_eq!(&obj.union.clock.precision as *const _ as usize - base, 40); + assert_eq!(&obj.union.clock.flags as *const _ as usize - base, 48); + assert_eq!(&obj.union.condvar.condvar as *const _ as usize - base, 16); + assert_eq!(&obj.union.condvar.lock as *const _ as usize - base, 24); + assert_eq!(&obj.union.condvar.condvar_scope as *const _ as usize - base, 32); + assert_eq!(&obj.union.condvar.lock_scope as *const _ as usize - base, 33); + assert_eq!(&obj.union.fd_readwrite.fd as *const _ as usize - base, 16); + assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 20); + assert_eq!(&obj.union.lock.lock as *const _ as usize - base, 16); + assert_eq!(&obj.union.lock.lock_scope as *const _ as usize - base, 24); + assert_eq!(&obj.union.proc_terminate.fd as *const _ as usize - base, 16); + } +} + +/// The Thread Control Block (TCB). +/// +/// After a thread begins execution (at program startup or when +/// created through [`thread_create()`](fn.thread_create.html)), the CPU's registers +/// controlling Thread-Local Storage (TLS) will already be +/// initialized. They will point to an area only containing the +/// TCB. +/// +/// If the thread needs space for storing thread-specific +/// variables, the thread may allocate a larger area and adjust +/// the CPU's registers to point to that area instead. However, it +/// does need to make sure that the TCB is copied over to the new +/// TLS area. +/// +/// The purpose of the TCB is that it allows light-weight +/// emulators to store information related to individual threads. +/// For example, it may be used to store a copy of the CPU +/// registers prior emulation, so that TLS for the host system +/// can be restored if needed. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tcb { + /// Pointer that may be freely assigned by the system. Its + /// value cannot be interpreted by the application. + pub parent: *mut (), +} +#[test] +#[cfg(target_pointer_width = "32")] +fn tcb_layout_test_32() { + assert_eq!(::core::mem::size_of::(), 4); + assert_eq!(::core::mem::align_of::(), 4); + unsafe { + let obj: tcb = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.parent as *const _ as usize - base, 0); + } +} +#[test] +#[cfg(target_pointer_width = "64")] +fn tcb_layout_test_64() { + assert_eq!(::core::mem::size_of::(), 8); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: tcb = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.parent as *const _ as usize - base, 0); + } +} + +/// Entry point for additionally created threads. +/// +/// **tid**: +/// Thread ID of the current thread. +/// +/// **aux**: +/// Copy of the value stored in +/// [`threadattr.argument`](struct.threadattr.html#structfield.argument). +pub type threadentry = unsafe extern "C" fn( + tid: tid, + aux: *mut (), +) -> (); + +/// Attributes for thread creation. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct threadattr { + /// Initial program counter value. + pub entry_point: threadentry, + /// Region allocated to serve as stack space. + pub stack: (*mut (), usize), + /// Argument to be forwarded to the entry point function. + pub argument: *mut (), +} +#[test] +#[cfg(target_pointer_width = "32")] +fn threadattr_layout_test_32() { + assert_eq!(::core::mem::size_of::(), 16); + assert_eq!(::core::mem::align_of::(), 4); + unsafe { + let obj: threadattr = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.entry_point as *const _ as usize - base, 0); + assert_eq!(&obj.stack.0 as *const _ as usize - base, 4); + assert_eq!(&obj.stack.1 as *const _ as usize - base, 8); + assert_eq!(&obj.argument as *const _ as usize - base, 12); + } +} +#[test] +#[cfg(target_pointer_width = "64")] +fn threadattr_layout_test_64() { + assert_eq!(::core::mem::size_of::(), 32); + assert_eq!(::core::mem::align_of::(), 8); + unsafe { + let obj: threadattr = ::core::mem::uninitialized(); + let base = &obj as *const _ as usize; + assert_eq!(&obj.entry_point as *const _ as usize - base, 0); + assert_eq!(&obj.stack.0 as *const _ as usize - base, 8); + assert_eq!(&obj.stack.1 as *const _ as usize - base, 16); + assert_eq!(&obj.argument as *const _ as usize - base, 24); + } +} + +/// The table with pointers to all syscall implementations. +#[allow(improper_ctypes)] +extern "C" { + fn cloudabi_sys_clock_res_get(_: clockid, _: *mut timestamp) -> errno; + fn cloudabi_sys_clock_time_get(_: clockid, _: timestamp, _: *mut timestamp) -> errno; + fn cloudabi_sys_condvar_signal(_: *mut condvar, _: scope, _: nthreads) -> errno; + fn cloudabi_sys_fd_close(_: fd) -> errno; + fn cloudabi_sys_fd_create1(_: filetype, _: *mut fd) -> errno; + fn cloudabi_sys_fd_create2(_: filetype, _: *mut fd, _: *mut fd) -> errno; + fn cloudabi_sys_fd_datasync(_: fd) -> errno; + fn cloudabi_sys_fd_dup(_: fd, _: *mut fd) -> errno; + fn cloudabi_sys_fd_pread(_: fd, _: *const iovec, _: usize, _: filesize, _: *mut usize) -> errno; + fn cloudabi_sys_fd_pwrite(_: fd, _: *const ciovec, _: usize, _: filesize, _: *mut usize) -> errno; + fn cloudabi_sys_fd_read(_: fd, _: *const iovec, _: usize, _: *mut usize) -> errno; + fn cloudabi_sys_fd_replace(_: fd, _: fd) -> errno; + fn cloudabi_sys_fd_seek(_: fd, _: filedelta, _: whence, _: *mut filesize) -> errno; + fn cloudabi_sys_fd_stat_get(_: fd, _: *mut fdstat) -> errno; + fn cloudabi_sys_fd_stat_put(_: fd, _: *const fdstat, _: fdsflags) -> errno; + fn cloudabi_sys_fd_sync(_: fd) -> errno; + fn cloudabi_sys_fd_write(_: fd, _: *const ciovec, _: usize, _: *mut usize) -> errno; + fn cloudabi_sys_file_advise(_: fd, _: filesize, _: filesize, _: advice) -> errno; + fn cloudabi_sys_file_allocate(_: fd, _: filesize, _: filesize) -> errno; + fn cloudabi_sys_file_create(_: fd, _: *const u8, _: usize, _: filetype) -> errno; + fn cloudabi_sys_file_link(_: lookup, _: *const u8, _: usize, _: fd, _: *const u8, _: usize) -> errno; + fn cloudabi_sys_file_open(_: lookup, _: *const u8, _: usize, _: oflags, _: *const fdstat, _: *mut fd) -> errno; + fn cloudabi_sys_file_readdir(_: fd, _: *mut (), _: usize, _: dircookie, _: *mut usize) -> errno; + fn cloudabi_sys_file_readlink(_: fd, _: *const u8, _: usize, _: *mut u8, _: usize, _: *mut usize) -> errno; + fn cloudabi_sys_file_rename(_: fd, _: *const u8, _: usize, _: fd, _: *const u8, _: usize) -> errno; + fn cloudabi_sys_file_stat_fget(_: fd, _: *mut filestat) -> errno; + fn cloudabi_sys_file_stat_fput(_: fd, _: *const filestat, _: fsflags) -> errno; + fn cloudabi_sys_file_stat_get(_: lookup, _: *const u8, _: usize, _: *mut filestat) -> errno; + fn cloudabi_sys_file_stat_put(_: lookup, _: *const u8, _: usize, _: *const filestat, _: fsflags) -> errno; + fn cloudabi_sys_file_symlink(_: *const u8, _: usize, _: fd, _: *const u8, _: usize) -> errno; + fn cloudabi_sys_file_unlink(_: fd, _: *const u8, _: usize, _: ulflags) -> errno; + fn cloudabi_sys_lock_unlock(_: *mut lock, _: scope) -> errno; + fn cloudabi_sys_mem_advise(_: *mut (), _: usize, _: advice) -> errno; + fn cloudabi_sys_mem_map(_: *mut (), _: usize, _: mprot, _: mflags, _: fd, _: filesize, _: *mut *mut ()) -> errno; + fn cloudabi_sys_mem_protect(_: *mut (), _: usize, _: mprot) -> errno; + fn cloudabi_sys_mem_sync(_: *mut (), _: usize, _: msflags) -> errno; + fn cloudabi_sys_mem_unmap(_: *mut (), _: usize) -> errno; + fn cloudabi_sys_poll(_: *const subscription, _: *mut event, _: usize, _: *mut usize) -> errno; + fn cloudabi_sys_proc_exec(_: fd, _: *const (), _: usize, _: *const fd, _: usize) -> errno; + fn cloudabi_sys_proc_exit(_: exitcode) -> !; + fn cloudabi_sys_proc_fork(_: *mut fd, _: *mut tid) -> errno; + fn cloudabi_sys_proc_raise(_: signal) -> errno; + fn cloudabi_sys_random_get(_: *mut (), _: usize) -> errno; + fn cloudabi_sys_sock_recv(_: fd, _: *const recv_in, _: *mut recv_out) -> errno; + fn cloudabi_sys_sock_send(_: fd, _: *const send_in, _: *mut send_out) -> errno; + fn cloudabi_sys_sock_shutdown(_: fd, _: sdflags) -> errno; + fn cloudabi_sys_thread_create(_: *mut threadattr, _: *mut tid) -> errno; + fn cloudabi_sys_thread_exit(_: *mut lock, _: scope) -> !; + fn cloudabi_sys_thread_yield() -> errno; +} + +/// Obtains the resolution of a clock. +/// +/// ## Parameters +/// +/// **clock_id**: +/// The clock for which the resolution needs to be +/// returned. +/// +/// **resolution**: +/// The resolution of the clock. +#[inline] +pub unsafe fn clock_res_get(clock_id_: clockid, resolution_: &mut timestamp) -> errno { + cloudabi_sys_clock_res_get(clock_id_, resolution_) +} + +/// Obtains the time value of a clock. +/// +/// ## Parameters +/// +/// **clock_id**: +/// The clock for which the time needs to be +/// returned. +/// +/// **precision**: +/// The maximum lag (exclusive) that the returned +/// time value may have, compared to its actual +/// value. +/// +/// **time**: +/// The time value of the clock. +#[inline] +pub unsafe fn clock_time_get(clock_id_: clockid, precision_: timestamp, time_: &mut timestamp) -> errno { + cloudabi_sys_clock_time_get(clock_id_, precision_, time_) +} + +/// Wakes up threads waiting on a userspace condition variable. +/// +/// If an invocation of this system call causes all waiting +/// threads to be woken up, the value of the condition variable +/// is set to [`CONDVAR_HAS_NO_WAITERS`](constant.CONDVAR_HAS_NO_WAITERS.html). As long as the condition +/// variable is set to this value, it is not needed to invoke this +/// system call. +/// +/// ## Parameters +/// +/// **condvar**: +/// The userspace condition variable that has +/// waiting threads. +/// +/// **scope**: +/// Whether the condition variable is stored in +/// private or shared memory. +/// +/// **nwaiters**: +/// The number of threads that need to be woken +/// up. If it exceeds the number of waiting +/// threads, all threads are woken up. +#[inline] +pub unsafe fn condvar_signal(condvar_: *mut condvar, scope_: scope, nwaiters_: nthreads) -> errno { + cloudabi_sys_condvar_signal(condvar_, scope_, nwaiters_) +} + +/// Closes a file descriptor. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor that needs to be closed. +#[inline] +pub unsafe fn fd_close(fd_: fd) -> errno { + cloudabi_sys_fd_close(fd_) +} + +/// Creates a file descriptor. +/// +/// ## Parameters +/// +/// **type**: +/// Possible values: +/// +/// - [`SHARED_MEMORY`](enum.filetype.html#variant.SHARED_MEMORY): +/// Creates an anonymous shared memory +/// object. +/// +/// **fd**: +/// The file descriptor that has been created. +#[inline] +pub unsafe fn fd_create1(type_: filetype, fd_: &mut fd) -> errno { + cloudabi_sys_fd_create1(type_, fd_) +} + +/// Creates a pair of file descriptors. +/// +/// ## Parameters +/// +/// **type**: +/// Possible values: +/// +/// - [`SOCKET_DGRAM`](enum.filetype.html#variant.SOCKET_DGRAM): +/// Creates a UNIX datagram socket pair. +/// - [`SOCKET_STREAM`](enum.filetype.html#variant.SOCKET_STREAM): +/// Creates a UNIX byte-stream socket +/// pair. +/// +/// **fd1**: +/// The first file descriptor of the pair. +/// +/// **fd2**: +/// The second file descriptor of the pair. +#[inline] +pub unsafe fn fd_create2(type_: filetype, fd1_: &mut fd, fd2_: &mut fd) -> errno { + cloudabi_sys_fd_create2(type_, fd1_, fd2_) +} + +/// Synchronizes the data of a file to disk. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor of the file whose data +/// needs to be synchronized to disk. +#[inline] +pub unsafe fn fd_datasync(fd_: fd) -> errno { + cloudabi_sys_fd_datasync(fd_) +} + +/// Duplicates a file descriptor. +/// +/// ## Parameters +/// +/// **from**: +/// The file descriptor that needs to be +/// duplicated. +/// +/// **fd**: +/// The new file descriptor. +#[inline] +pub unsafe fn fd_dup(from_: fd, fd_: &mut fd) -> errno { + cloudabi_sys_fd_dup(from_, fd_) +} + +/// Reads from a file descriptor, without using and updating the +/// file descriptor's offset. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor from which data should be +/// read. +/// +/// **iovs**: +/// List of scatter/gather vectors where data +/// should be stored. +/// +/// **offset**: +/// The offset within the file at which reading +/// should start. +/// +/// **nread**: +/// The number of bytes read. +#[inline] +pub unsafe fn fd_pread(fd_: fd, iovs_: &[iovec], offset_: filesize, nread_: &mut usize) -> errno { + cloudabi_sys_fd_pread(fd_, iovs_.as_ptr(), iovs_.len(), offset_, nread_) +} + +/// Writes to a file descriptor, without using and updating the +/// file descriptor's offset. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor to which data should be +/// written. +/// +/// **iovs**: +/// List of scatter/gather vectors where data +/// should be retrieved. +/// +/// **offset**: +/// The offset within the file at which writing +/// should start. +/// +/// **nwritten**: +/// The number of bytes written. +#[inline] +pub unsafe fn fd_pwrite(fd_: fd, iovs_: &[ciovec], offset_: filesize, nwritten_: &mut usize) -> errno { + cloudabi_sys_fd_pwrite(fd_, iovs_.as_ptr(), iovs_.len(), offset_, nwritten_) +} + +/// Reads from a file descriptor. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor from which data should be +/// read. +/// +/// **iovs**: +/// List of scatter/gather vectors where data +/// should be stored. +/// +/// **nread**: +/// The number of bytes read. +#[inline] +pub unsafe fn fd_read(fd_: fd, iovs_: &[iovec], nread_: &mut usize) -> errno { + cloudabi_sys_fd_read(fd_, iovs_.as_ptr(), iovs_.len(), nread_) +} + +/// Atomically replaces a file descriptor by a copy of another +/// file descriptor. +/// +/// Due to the strong focus on thread safety, this environment +/// does not provide a mechanism to duplicate a file descriptor to +/// an arbitrary number, like dup2(). This would be prone to race +/// conditions, as an actual file descriptor with the same number +/// could be allocated by a different thread at the same time. +/// +/// This system call provides a way to atomically replace file +/// descriptors, which would disappear if dup2() were to be +/// removed entirely. +/// +/// ## Parameters +/// +/// **from**: +/// The file descriptor that needs to be copied. +/// +/// **to**: +/// The file descriptor that needs to be +/// overwritten. +#[inline] +pub unsafe fn fd_replace(from_: fd, to_: fd) -> errno { + cloudabi_sys_fd_replace(from_, to_) +} + +/// Moves the offset of the file descriptor. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor whose offset has to be +/// moved. +/// +/// **offset**: +/// The number of bytes to move. +/// +/// **whence**: +/// Relative to which position the move should +/// take place. +/// +/// **newoffset**: +/// The new offset of the file descriptor, +/// relative to the start of the file. +#[inline] +pub unsafe fn fd_seek(fd_: fd, offset_: filedelta, whence_: whence, newoffset_: &mut filesize) -> errno { + cloudabi_sys_fd_seek(fd_, offset_, whence_, newoffset_) +} + +/// Gets attributes of a file descriptor. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor whose attributes have to +/// be obtained. +/// +/// **buf**: +/// The buffer where the file descriptor's +/// attributes are stored. +#[inline] +pub unsafe fn fd_stat_get(fd_: fd, buf_: *mut fdstat) -> errno { + cloudabi_sys_fd_stat_get(fd_, buf_) +} + +/// Adjusts attributes of a file descriptor. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor whose attributes have to +/// be adjusted. +/// +/// **buf**: +/// The desired values of the file descriptor +/// attributes that are adjusted. +/// +/// **flags**: +/// A bitmask indicating which attributes have to +/// be adjusted. +#[inline] +pub unsafe fn fd_stat_put(fd_: fd, buf_: *const fdstat, flags_: fdsflags) -> errno { + cloudabi_sys_fd_stat_put(fd_, buf_, flags_) +} + +/// Synchronizes the data and metadata of a file to disk. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor of the file whose data +/// and metadata needs to be synchronized to disk. +#[inline] +pub unsafe fn fd_sync(fd_: fd) -> errno { + cloudabi_sys_fd_sync(fd_) +} + +/// Writes to a file descriptor. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor to which data should be +/// written. +/// +/// **iovs**: +/// List of scatter/gather vectors where data +/// should be retrieved. +/// +/// **nwritten**: +/// The number of bytes written. +#[inline] +pub unsafe fn fd_write(fd_: fd, iovs_: &[ciovec], nwritten_: &mut usize) -> errno { + cloudabi_sys_fd_write(fd_, iovs_.as_ptr(), iovs_.len(), nwritten_) +} + +/// Provides file advisory information on a file descriptor. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor for which to provide file +/// advisory information. +/// +/// **offset**: +/// The offset within the file to which the +/// advisory applies. +/// +/// **len**: +/// The length of the region to which the advisory +/// applies. +/// +/// **advice**: +/// The advice. +#[inline] +pub unsafe fn file_advise(fd_: fd, offset_: filesize, len_: filesize, advice_: advice) -> errno { + cloudabi_sys_file_advise(fd_, offset_, len_, advice_) +} + +/// Forces the allocation of space in a file. +/// +/// ## Parameters +/// +/// **fd**: +/// The file in which the space should be +/// allocated. +/// +/// **offset**: +/// The offset at which the allocation should +/// start. +/// +/// **len**: +/// The length of the area that is allocated. +#[inline] +pub unsafe fn file_allocate(fd_: fd, offset_: filesize, len_: filesize) -> errno { + cloudabi_sys_file_allocate(fd_, offset_, len_) +} + +/// Creates a file of a specified type. +/// +/// ## Parameters +/// +/// **fd**: +/// The working directory at which the resolution +/// of the file to be created starts. +/// +/// **path**: +/// The path at which the file should be created. +/// +/// **type**: +/// Possible values: +/// +/// - [`DIRECTORY`](enum.filetype.html#variant.DIRECTORY): +/// Creates a directory. +#[inline] +pub unsafe fn file_create(fd_: fd, path_: &[u8], type_: filetype) -> errno { + cloudabi_sys_file_create(fd_, path_.as_ptr(), path_.len(), type_) +} + +/// Creates a hard link. +/// +/// ## Parameters +/// +/// **fd1**: +/// The working directory at which the resolution +/// of the source path starts. +/// +/// **path1**: +/// The source path of the file that should be +/// hard linked. +/// +/// **fd2**: +/// The working directory at which the resolution +/// of the destination path starts. +/// +/// **path2**: +/// The destination path at which the hard link +/// should be created. +#[inline] +pub unsafe fn file_link(fd1_: lookup, path1_: &[u8], fd2_: fd, path2_: &[u8]) -> errno { + cloudabi_sys_file_link(fd1_, path1_.as_ptr(), path1_.len(), fd2_, path2_.as_ptr(), path2_.len()) +} + +/// Opens a file. +/// +/// ## Parameters +/// +/// **dirfd**: +/// The working directory at which the resolution +/// of the file to be opened starts. +/// +/// **path**: +/// The path of the file that should be opened. +/// +/// **oflags**: +/// The method at which the file should be opened. +/// +/// **fds**: +/// [`fdstat.fs_rights_base`](struct.fdstat.html#structfield.fs_rights_base) and +/// [`fdstat.fs_rights_inheriting`](struct.fdstat.html#structfield.fs_rights_inheriting) specify the +/// initial rights of the newly created file +/// descriptor. The operating system is allowed to +/// return a file descriptor with fewer rights +/// than specified, if and only if those rights do +/// not apply to the type of file being opened. +/// +/// [`fdstat.fs_flags`](struct.fdstat.html#structfield.fs_flags) specifies the initial flags +/// of the file descriptor. +/// +/// [`fdstat.fs_filetype`](struct.fdstat.html#structfield.fs_filetype) is ignored. +/// +/// **fd**: +/// The file descriptor of the file that has been +/// opened. +#[inline] +pub unsafe fn file_open(dirfd_: lookup, path_: &[u8], oflags_: oflags, fds_: *const fdstat, fd_: &mut fd) -> errno { + cloudabi_sys_file_open(dirfd_, path_.as_ptr(), path_.len(), oflags_, fds_, fd_) +} + +/// Reads directory entries from a directory. +/// +/// When successful, the contents of the output buffer consist of +/// a sequence of directory entries. Each directory entry consists +/// of a [`dirent`](struct.dirent.html) object, followed by [`dirent.d_namlen`](struct.dirent.html#structfield.d_namlen) bytes +/// holding the name of the directory entry. +/// +/// This system call fills the output buffer as much as possible, +/// potentially truncating the last directory entry. This allows +/// the caller to grow its read buffer size in case it's too small +/// to fit a single large directory entry, or skip the oversized +/// directory entry. +/// +/// ## Parameters +/// +/// **fd**: +/// The directory from which to read the directory +/// entries. +/// +/// **buf**: +/// The buffer where directory entries are stored. +/// +/// **cookie**: +/// The location within the directory to start +/// reading. +/// +/// **bufused**: +/// The number of bytes stored in the read buffer. +/// If less than the size of the read buffer, the +/// end of the directory has been reached. +#[inline] +pub unsafe fn file_readdir(fd_: fd, buf_: &mut [u8], cookie_: dircookie, bufused_: &mut usize) -> errno { + cloudabi_sys_file_readdir(fd_, buf_.as_mut_ptr() as *mut (), buf_.len(), cookie_, bufused_) +} + +/// Reads the contents of a symbolic link. +/// +/// ## Parameters +/// +/// **fd**: +/// The working directory at which the resolution +/// of the path of the symbolic starts. +/// +/// **path**: +/// The path of the symbolic link whose contents +/// should be read. +/// +/// **buf**: +/// The buffer where the contents of the symbolic +/// link should be stored. +/// +/// **bufused**: +/// The number of bytes placed in the buffer. +#[inline] +pub unsafe fn file_readlink(fd_: fd, path_: &[u8], buf_: &mut [u8], bufused_: &mut usize) -> errno { + cloudabi_sys_file_readlink(fd_, path_.as_ptr(), path_.len(), buf_.as_mut_ptr(), buf_.len(), bufused_) +} + +/// Renames a file. +/// +/// ## Parameters +/// +/// **fd1**: +/// The working directory at which the resolution +/// of the source path starts. +/// +/// **path1**: +/// The source path of the file that should be +/// renamed. +/// +/// **fd2**: +/// The working directory at which the resolution +/// of the destination path starts. +/// +/// **path2**: +/// The destination path to which the file should +/// be renamed. +#[inline] +pub unsafe fn file_rename(fd1_: fd, path1_: &[u8], fd2_: fd, path2_: &[u8]) -> errno { + cloudabi_sys_file_rename(fd1_, path1_.as_ptr(), path1_.len(), fd2_, path2_.as_ptr(), path2_.len()) +} + +/// Gets attributes of a file by file descriptor. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor whose attributes have to +/// be obtained. +/// +/// **buf**: +/// The buffer where the file's attributes are +/// stored. +#[inline] +pub unsafe fn file_stat_fget(fd_: fd, buf_: *mut filestat) -> errno { + cloudabi_sys_file_stat_fget(fd_, buf_) +} + +/// Adjusts attributes of a file by file descriptor. +/// +/// ## Parameters +/// +/// **fd**: +/// The file descriptor whose attributes have to +/// be adjusted. +/// +/// **buf**: +/// The desired values of the file attributes that +/// are adjusted. +/// +/// **flags**: +/// A bitmask indicating which attributes have to +/// be adjusted. +#[inline] +pub unsafe fn file_stat_fput(fd_: fd, buf_: *const filestat, flags_: fsflags) -> errno { + cloudabi_sys_file_stat_fput(fd_, buf_, flags_) +} + +/// Gets attributes of a file by path. +/// +/// ## Parameters +/// +/// **fd**: +/// The working directory at which the resolution +/// of the path whose attributes have to be +/// obtained starts. +/// +/// **path**: +/// The path of the file whose attributes have to +/// be obtained. +/// +/// **buf**: +/// The buffer where the file's attributes are +/// stored. +#[inline] +pub unsafe fn file_stat_get(fd_: lookup, path_: &[u8], buf_: *mut filestat) -> errno { + cloudabi_sys_file_stat_get(fd_, path_.as_ptr(), path_.len(), buf_) +} + +/// Adjusts attributes of a file by path. +/// +/// ## Parameters +/// +/// **fd**: +/// The working directory at which the resolution +/// of the path whose attributes have to be +/// adjusted starts. +/// +/// **path**: +/// The path of the file whose attributes have to +/// be adjusted. +/// +/// **buf**: +/// The desired values of the file attributes that +/// are adjusted. +/// +/// **flags**: +/// A bitmask indicating which attributes have to +/// be adjusted. +#[inline] +pub unsafe fn file_stat_put(fd_: lookup, path_: &[u8], buf_: *const filestat, flags_: fsflags) -> errno { + cloudabi_sys_file_stat_put(fd_, path_.as_ptr(), path_.len(), buf_, flags_) +} + +/// Creates a symbolic link. +/// +/// ## Parameters +/// +/// **path1**: +/// The contents of the symbolic link. +/// +/// **fd**: +/// The working directory at which the resolution +/// of the destination path starts. +/// +/// **path2**: +/// The destination path at which the symbolic +/// link should be created. +#[inline] +pub unsafe fn file_symlink(path1_: &[u8], fd_: fd, path2_: &[u8]) -> errno { + cloudabi_sys_file_symlink(path1_.as_ptr(), path1_.len(), fd_, path2_.as_ptr(), path2_.len()) +} + +/// Unlinks a file, or removes a directory. +/// +/// ## Parameters +/// +/// **fd**: +/// The working directory at which the resolution +/// of the path starts. +/// +/// **path**: +/// The path that needs to be unlinked or removed. +/// +/// **flags**: +/// Possible values: +/// +/// - [`REMOVEDIR`](struct.ulflags.html#associatedconstant.REMOVEDIR): +/// If set, attempt to remove a directory. +/// Otherwise, unlink a file. +#[inline] +pub unsafe fn file_unlink(fd_: fd, path_: &[u8], flags_: ulflags) -> errno { + cloudabi_sys_file_unlink(fd_, path_.as_ptr(), path_.len(), flags_) +} + +/// Unlocks a write-locked userspace lock. +/// +/// If a userspace lock is unlocked while having its +/// [`LOCK_KERNEL_MANAGED`](constant.LOCK_KERNEL_MANAGED.html) flag set, the lock cannot be unlocked in +/// userspace directly. This system call needs to be performed +/// instead, so that any waiting threads can be woken up. +/// +/// To prevent spurious invocations of this system call, the lock +/// must be locked for writing. This prevents other threads from +/// acquiring additional read locks while the system call is in +/// progress. If the lock is acquired for reading, it must first +/// be upgraded to a write lock. +/// +/// ## Parameters +/// +/// **lock**: +/// The userspace lock that is locked for writing +/// by the calling thread. +/// +/// **scope**: +/// Whether the lock is stored in private or +/// shared memory. +#[inline] +pub unsafe fn lock_unlock(lock_: *mut lock, scope_: scope) -> errno { + cloudabi_sys_lock_unlock(lock_, scope_) +} + +/// Provides memory advisory information on a region of memory. +/// +/// ## Parameters +/// +/// **mapping**: +/// The pages for which to provide memory advisory +/// information. +/// +/// **advice**: +/// The advice. +#[inline] +pub unsafe fn mem_advise(mapping_: &mut [u8], advice_: advice) -> errno { + cloudabi_sys_mem_advise(mapping_.as_mut_ptr() as *mut (), mapping_.len(), advice_) +} + +/// Creates a memory mapping, making the contents of a file +/// accessible through memory. +/// +/// ## Parameters +/// +/// **addr**: +/// If [`FIXED`](struct.mflags.html#associatedconstant.FIXED) is set, specifies to which +/// address the file region is mapped. Otherwise, +/// the mapping is performed at an unused +/// location. +/// +/// **len**: +/// The length of the memory mapping to be +/// created. +/// +/// **prot**: +/// Initial memory protection options for the +/// memory mapping. +/// +/// **flags**: +/// Memory mapping flags. +/// +/// **fd**: +/// If [`ANON`](struct.mflags.html#associatedconstant.ANON) is set, this argument must be +/// [`MAP_ANON_FD`](constant.MAP_ANON_FD.html). Otherwise, this argument +/// specifies the file whose contents need to be +/// mapped. +/// +/// **off**: +/// If [`ANON`](struct.mflags.html#associatedconstant.ANON) is set, this argument must be +/// zero. Otherwise, this argument specifies the +/// offset within the file at which the mapping +/// starts. +/// +/// **mem**: +/// The starting address of the memory mapping. +#[inline] +pub unsafe fn mem_map(addr_: *mut (), len_: usize, prot_: mprot, flags_: mflags, fd_: fd, off_: filesize, mem_: &mut *mut ()) -> errno { + cloudabi_sys_mem_map(addr_, len_, prot_, flags_, fd_, off_, mem_) +} + +/// Change the protection of a memory mapping. +/// +/// ## Parameters +/// +/// **mapping**: +/// The pages that need their protection changed. +/// +/// **prot**: +/// New protection options. +#[inline] +pub unsafe fn mem_protect(mapping_: &mut [u8], prot_: mprot) -> errno { + cloudabi_sys_mem_protect(mapping_.as_mut_ptr() as *mut (), mapping_.len(), prot_) +} + +/// Synchronize a region of memory with its physical storage. +/// +/// ## Parameters +/// +/// **mapping**: +/// The pages that need to be synchronized. +/// +/// **flags**: +/// The method of synchronization. +#[inline] +pub unsafe fn mem_sync(mapping_: &mut [u8], flags_: msflags) -> errno { + cloudabi_sys_mem_sync(mapping_.as_mut_ptr() as *mut (), mapping_.len(), flags_) +} + +/// Unmaps a region of memory. +/// +/// ## Parameters +/// +/// **mapping**: +/// The pages that needs to be unmapped. +#[inline] +pub unsafe fn mem_unmap(mapping_: &mut [u8]) -> errno { + cloudabi_sys_mem_unmap(mapping_.as_mut_ptr() as *mut (), mapping_.len()) +} + +/// Concurrently polls for the occurrence of a set of events. +/// +/// ## Parameters +/// +/// **in**: +/// The events to which to subscribe. +/// +/// **out**: +/// The events that have occurred. +/// +/// **nsubscriptions**: +/// Both the number of subscriptions and events. +/// +/// **nevents**: +/// The number of events stored. +#[inline] +pub unsafe fn poll(in_: *const subscription, out_: *mut event, nsubscriptions_: usize, nevents_: &mut usize) -> errno { + cloudabi_sys_poll(in_, out_, nsubscriptions_, nevents_) +} + +/// Replaces the process by a new executable. +/// +/// Process execution in CloudABI differs from POSIX in two ways: +/// handling of arguments and inheritance of file descriptors. +/// +/// CloudABI does not use string command line arguments. Instead, +/// a buffer with binary data is copied into the address space of +/// the new executable. The kernel does not enforce any specific +/// structure to this data, although CloudABI's C library uses it +/// to store a tree structure that is semantically identical to +/// YAML. +/// +/// Due to the strong focus on thread safety, file descriptors +/// aren't inherited through close-on-exec flags. An explicit +/// list of file descriptors that need to be retained needs to be +/// provided. After execution, file descriptors are placed in the +/// order in which they are stored in the array. This not only +/// makes the execution process deterministic. It also prevents +/// potential information disclosures about the layout of the +/// original process. +/// +/// ## Parameters +/// +/// **fd**: +/// A file descriptor of the new executable. +/// +/// **data**: +/// Binary argument data that is passed on to the +/// new executable. +/// +/// **fds**: +/// The layout of the file descriptor table after +/// execution. +#[inline] +pub unsafe fn proc_exec(fd_: fd, data_: &[u8], fds_: &[fd]) -> errno { + cloudabi_sys_proc_exec(fd_, data_.as_ptr() as *const (), data_.len(), fds_.as_ptr(), fds_.len()) +} + +/// Terminates the process normally. +/// +/// ## Parameters +/// +/// **rval**: +/// The exit code returned by the process. The +/// exit code can be obtained by other processes +/// through [`event.union.proc_terminate.exitcode`](struct.event_proc_terminate.html#structfield.exitcode). +#[inline] +pub unsafe fn proc_exit(rval_: exitcode) -> ! { + cloudabi_sys_proc_exit(rval_) +} + +/// Forks the process of the calling thread. +/// +/// After forking, a new process shall be created, having only a +/// copy of the calling thread. The parent process will obtain a +/// process descriptor. When closed, the child process is +/// automatically signaled with [`KILL`](enum.signal.html#variant.KILL). +/// +/// ## Parameters +/// +/// **fd**: +/// In the parent process: the file descriptor +/// number of the process descriptor. +/// +/// In the child process: [`PROCESS_CHILD`](constant.PROCESS_CHILD.html). +/// +/// **tid**: +/// In the parent process: undefined. +/// +/// In the child process: the thread ID of the +/// initial thread of the child process. +#[inline] +pub unsafe fn proc_fork(fd_: &mut fd, tid_: &mut tid) -> errno { + cloudabi_sys_proc_fork(fd_, tid_) +} + +/// Sends a signal to the process of the calling thread. +/// +/// ## Parameters +/// +/// **sig**: +/// The signal condition that should be triggered. +/// If the signal causes the process to terminate, +/// its condition can be obtained by other +/// processes through +/// [`event.union.proc_terminate.signal`](struct.event_proc_terminate.html#structfield.signal). +#[inline] +pub unsafe fn proc_raise(sig_: signal) -> errno { + cloudabi_sys_proc_raise(sig_) +} + +/// Obtains random data from the kernel random number generator. +/// +/// As this interface is not guaranteed to be fast, it is advised +/// that the random data obtained through this system call is used +/// as the seed for a userspace pseudo-random number generator. +/// +/// ## Parameters +/// +/// **buf**: +/// The buffer that needs to be filled with random +/// data. +#[inline] +pub unsafe fn random_get(buf_: &mut [u8]) -> errno { + cloudabi_sys_random_get(buf_.as_mut_ptr() as *mut (), buf_.len()) +} + +/// Receives a message on a socket. +/// +/// ## Parameters +/// +/// **sock**: +/// The socket on which a message should be +/// received. +/// +/// **in**: +/// Input parameters. +/// +/// **out**: +/// Output parameters. +#[inline] +pub unsafe fn sock_recv(sock_: fd, in_: *const recv_in, out_: *mut recv_out) -> errno { + cloudabi_sys_sock_recv(sock_, in_, out_) +} + +/// Sends a message on a socket. +/// +/// ## Parameters +/// +/// **sock**: +/// The socket on which a message should be sent. +/// +/// **in**: +/// Input parameters. +/// +/// **out**: +/// Output parameters. +#[inline] +pub unsafe fn sock_send(sock_: fd, in_: *const send_in, out_: *mut send_out) -> errno { + cloudabi_sys_sock_send(sock_, in_, out_) +} + +/// Shuts down socket send and receive channels. +/// +/// ## Parameters +/// +/// **sock**: +/// The socket that needs its channels shut down. +/// +/// **how**: +/// Which channels on the socket need to be shut +/// down. +#[inline] +pub unsafe fn sock_shutdown(sock_: fd, how_: sdflags) -> errno { + cloudabi_sys_sock_shutdown(sock_, how_) +} + +/// Creates a new thread within the current process. +/// +/// ## Parameters +/// +/// **attr**: +/// The desired attributes of the new thread. +/// +/// **tid**: +/// The thread ID of the new thread. +#[inline] +pub unsafe fn thread_create(attr_: *mut threadattr, tid_: &mut tid) -> errno { + cloudabi_sys_thread_create(attr_, tid_) +} + +/// Terminates the calling thread. +/// +/// This system call can also unlock a single userspace lock +/// after termination, which can be used to implement thread +/// joining. +/// +/// ## Parameters +/// +/// **lock**: +/// Userspace lock that is locked for writing by +/// the calling thread. +/// +/// **scope**: +/// Whether the lock is stored in private or +/// shared memory. +#[inline] +pub unsafe fn thread_exit(lock_: *mut lock, scope_: scope) -> ! { + cloudabi_sys_thread_exit(lock_, scope_) +} + +/// Temporarily yields execution of the calling thread. +#[inline] +pub unsafe fn thread_yield() -> errno { + cloudabi_sys_thread_yield() +} diff --git a/third_party/cargo/vendor/cocoa-0.18.5/.cargo-checksum.json b/third_party/cargo/vendor/cocoa-0.18.5/.cargo-checksum.json new file mode 100644 index 0000000..a0c0c5d --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"20ce8f189d4910352c569016fec1e3a8c6b4a92c767f9d1c8507298abc49d3c4","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"6e4bf5158734b84c98500797326b90bb9da1d0b8dd6ccdba6dbc4284e41713a4","examples/fullscreen.rs":"f5ad7a0f9c44944c5ee84413ab9a106abd4d4e53534867c602651db7be722165","examples/hello_world.rs":"7efe2a29de4d4dfc1d8821f469e13b1456f72de478bab55f813d08d4e5aafd5c","examples/tab_view.rs":"e6a3187eeac2f46210994293c2db7756757f4cad07e519902fa994c6d5c1a7d6","src/appkit.rs":"24fff19b363dc1582557088856eb53642e6824761d60f8e0e11e5df0bfd9eccb","src/base.rs":"6c56d1758a9b0a7f8927771fe8b0bb43c6f19e4531bf9accecc786028eaad845","src/foundation.rs":"27f58705d615ddd401b710bf4741edb4f9cbf23d59dd3463a4b60f7d10eebde6","src/lib.rs":"55ba91363c74525de075864e78fc5f6ac8f3121daef9ed835988a09daae74d2d","src/quartzcore.rs":"cb4f96b4b095e9d623346a42b1e119a5299bf2af73ed81256dd548c688d525e2","tests/foundation.rs":"6a09eb4116e338281d7fdf6487fdebd580cfb82915627b58e8d8beeaec99eb5f"},"package":"1706996401131526e36b3b49f0c4d912639ce110996f3ca144d78946727bce54"} \ No newline at end of file diff --git a/third_party/cargo/vendor/cocoa-0.18.5/BUILD b/third_party/cargo/vendor/cocoa-0.18.5/BUILD new file mode 100644 index 0000000..76d4001 --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/BUILD @@ -0,0 +1,53 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "cocoa", + crate_root = "src/lib.rs", + crate_type = "rlib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/bitflags-1.2.1:bitflags", + "//third_party/cargo/vendor/block-0.1.6:block", + "//third_party/cargo/vendor/core-foundation-0.6.4:core_foundation", + "//third_party/cargo/vendor/core-graphics-0.17.3:core_graphics", + "//third_party/cargo/vendor/foreign-types-0.3.2:foreign_types", + "//third_party/cargo/vendor/libc-0.2.66:libc", + "//third_party/cargo/vendor/objc-0.2.7:objc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.18.5", + crate_features = [ + ], +) + +# Unsupported target "foundation" with type "test" omitted +# Unsupported target "fullscreen" with type "example" omitted +# Unsupported target "hello_world" with type "example" omitted +# Unsupported target "tab_view" with type "example" omitted diff --git a/third_party/cargo/vendor/cocoa-0.18.5/COPYRIGHT b/third_party/cargo/vendor/cocoa-0.18.5/COPYRIGHT new file mode 100644 index 0000000..8b7291a --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/COPYRIGHT @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 or the MIT license +, at your +option. All files in the project carrying such notice may not be +copied, modified, or distributed except according to those terms. diff --git a/third_party/cargo/vendor/cocoa-0.18.5/Cargo.toml b/third_party/cargo/vendor/cocoa-0.18.5/Cargo.toml new file mode 100644 index 0000000..dc11e2d --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/Cargo.toml @@ -0,0 +1,44 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "cocoa" +version = "0.18.5" +authors = ["The Servo Project Developers"] +description = "Bindings to Cocoa for OS X" +homepage = "https://github.com/servo/core-foundation-rs" +license = "MIT / Apache-2.0" +repository = "https://github.com/servo/core-foundation-rs" + +[lib] +name = "cocoa" +crate-type = ["rlib"] +[dependencies.bitflags] +version = "1.0" + +[dependencies.block] +version = "0.1" + +[dependencies.core-foundation] +version = "0.6" + +[dependencies.core-graphics] +version = "0.17" + +[dependencies.foreign-types] +version = "0.3" + +[dependencies.libc] +version = "0.2" + +[dependencies.objc] +version = "0.2.3" diff --git a/third_party/cargo/vendor/cocoa-0.18.5/LICENSE-APACHE b/third_party/cargo/vendor/cocoa-0.18.5/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/cocoa-0.18.5/LICENSE-MIT b/third_party/cargo/vendor/cocoa-0.18.5/LICENSE-MIT new file mode 100644 index 0000000..807526f --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2012-2013 Mozilla Foundation + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/cocoa-0.18.5/README.md b/third_party/cargo/vendor/cocoa-0.18.5/README.md new file mode 100644 index 0000000..3024bde --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/README.md @@ -0,0 +1,6 @@ +Cocoa-rs +-------- + +This crate provides Rust bindings to Cocoa for OSX. It's dual-licensed MIT / +Apache 2.0. If you'd like to help improve cocoa-rs, check out [the Servo +contributing guide](https://github.com/servo/servo/blob/master/CONTRIBUTING.md)! diff --git a/third_party/cargo/vendor/cocoa-0.18.5/examples/fullscreen.rs b/third_party/cargo/vendor/cocoa-0.18.5/examples/fullscreen.rs new file mode 100644 index 0000000..df09d57 --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/examples/fullscreen.rs @@ -0,0 +1,97 @@ +extern crate cocoa; +extern crate core_graphics; + +#[macro_use] +extern crate objc; + +use cocoa::base::{selector, nil, NO, id}; +use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo, + NSString, NSUInteger}; +use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular, NSWindow, + NSBackingStoreBuffered, NSMenu, NSMenuItem, NSWindowStyleMask, + NSRunningApplication, NSApplicationActivateIgnoringOtherApps, + NSWindowCollectionBehavior, NSApplicationPresentationOptions}; + +use core_graphics::display::CGDisplay; + +use objc::runtime::{Object, Sel}; +use objc::declare::ClassDecl; + +fn main() { + unsafe { + let _pool = NSAutoreleasePool::new(nil); + + let app = NSApp(); + app.setActivationPolicy_(NSApplicationActivationPolicyRegular); + + // create Menu Bar + let menubar = NSMenu::new(nil).autorelease(); + let app_menu_item = NSMenuItem::new(nil).autorelease(); + menubar.addItem_(app_menu_item); + app.setMainMenu_(menubar); + + // create Application menu + let app_menu = NSMenu::new(nil).autorelease(); + let quit_prefix = NSString::alloc(nil).init_str("Quit "); + let quit_title = + quit_prefix.stringByAppendingString_(NSProcessInfo::processInfo(nil).processName()); + let quit_action = selector("terminate:"); + let quit_key = NSString::alloc(nil).init_str("q"); + let quit_item = NSMenuItem::alloc(nil) + .initWithTitle_action_keyEquivalent_(quit_title, quit_action, quit_key) + .autorelease(); + app_menu.addItem_(quit_item); + app_menu_item.setSubmenu_(app_menu); + + // Create NSWindowDelegate + let superclass = class!(NSObject); + let mut decl = ClassDecl::new("MyWindowDelegate", superclass).unwrap(); + + extern fn will_use_fillscreen_presentation_options(_: &Object, _: Sel, _: id, _: NSUInteger) -> NSUInteger { + // Set initial presentation options for fullscreen + let options = NSApplicationPresentationOptions::NSApplicationPresentationFullScreen + | NSApplicationPresentationOptions::NSApplicationPresentationHideDock + | NSApplicationPresentationOptions::NSApplicationPresentationHideMenuBar + | NSApplicationPresentationOptions::NSApplicationPresentationDisableProcessSwitching; + options.bits() + } + + extern fn window_entering_fullscreen(_: &Object, _: Sel, _: id) { + // Reset HideDock and HideMenuBar settings during/after we entered fullscreen. + let options = NSApplicationPresentationOptions::NSApplicationPresentationHideDock | NSApplicationPresentationOptions::NSApplicationPresentationHideMenuBar; + unsafe { + NSApp().setPresentationOptions_(options); + } + } + + decl.add_method(sel!(window:willUseFullScreenPresentationOptions:), + will_use_fillscreen_presentation_options as extern fn(&Object, Sel, id, NSUInteger) -> NSUInteger); + decl.add_method(sel!(windowWillEnterFullScreen:), + window_entering_fullscreen as extern fn(&Object, Sel, id)); + decl.add_method(sel!(windowDidEnterFullScreen:), + window_entering_fullscreen as extern fn(&Object, Sel, id)); + + let delegate_class = decl.register(); + let delegate_object = msg_send![delegate_class, new]; + + // create Window + let display = CGDisplay::main(); + let size = NSSize::new(display.pixels_wide() as f64, display.pixels_high() as f64); + let window = NSWindow::alloc(nil) + .initWithContentRect_styleMask_backing_defer_(NSRect::new(NSPoint::new(0., 0.), size), + NSWindowStyleMask::NSTitledWindowMask, + NSBackingStoreBuffered, + NO) + .autorelease(); + window.setDelegate_(delegate_object); + let title = NSString::alloc(nil).init_str("Fullscreen!"); + window.setTitle_(title); + window.makeKeyAndOrderFront_(nil); + + let current_app = NSRunningApplication::currentApplication(nil); + current_app.activateWithOptions_(NSApplicationActivateIgnoringOtherApps); + window.setCollectionBehavior_(NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenPrimary); + window.toggleFullScreen_(nil); + app.run(); + } +} diff --git a/third_party/cargo/vendor/cocoa-0.18.5/examples/hello_world.rs b/third_party/cargo/vendor/cocoa-0.18.5/examples/hello_world.rs new file mode 100644 index 0000000..4d5c1b0 --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/examples/hello_world.rs @@ -0,0 +1,53 @@ +extern crate cocoa; + +use cocoa::base::{selector, nil, NO}; +use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo, + NSString}; +use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular, NSWindow, + NSBackingStoreBuffered, NSMenu, NSMenuItem, NSWindowStyleMask, + NSRunningApplication, NSApplicationActivateIgnoringOtherApps}; + +fn main() { + unsafe { + let _pool = NSAutoreleasePool::new(nil); + + let app = NSApp(); + app.setActivationPolicy_(NSApplicationActivationPolicyRegular); + + // create Menu Bar + let menubar = NSMenu::new(nil).autorelease(); + let app_menu_item = NSMenuItem::new(nil).autorelease(); + menubar.addItem_(app_menu_item); + app.setMainMenu_(menubar); + + // create Application menu + let app_menu = NSMenu::new(nil).autorelease(); + let quit_prefix = NSString::alloc(nil).init_str("Quit "); + let quit_title = + quit_prefix.stringByAppendingString_(NSProcessInfo::processInfo(nil).processName()); + let quit_action = selector("terminate:"); + let quit_key = NSString::alloc(nil).init_str("q"); + let quit_item = NSMenuItem::alloc(nil) + .initWithTitle_action_keyEquivalent_(quit_title, quit_action, quit_key) + .autorelease(); + app_menu.addItem_(quit_item); + app_menu_item.setSubmenu_(app_menu); + + // create Window + let window = NSWindow::alloc(nil) + .initWithContentRect_styleMask_backing_defer_(NSRect::new(NSPoint::new(0., 0.), + NSSize::new(200., 200.)), + NSWindowStyleMask::NSTitledWindowMask, + NSBackingStoreBuffered, + NO) + .autorelease(); + window.cascadeTopLeftFromPoint_(NSPoint::new(20., 20.)); + window.center(); + let title = NSString::alloc(nil).init_str("Hello World!"); + window.setTitle_(title); + window.makeKeyAndOrderFront_(nil); + let current_app = NSRunningApplication::currentApplication(nil); + current_app.activateWithOptions_(NSApplicationActivateIgnoringOtherApps); + app.run(); + } +} diff --git a/third_party/cargo/vendor/cocoa-0.18.5/examples/tab_view.rs b/third_party/cargo/vendor/cocoa-0.18.5/examples/tab_view.rs new file mode 100644 index 0000000..985487f --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/examples/tab_view.rs @@ -0,0 +1,87 @@ +extern crate cocoa; + +use cocoa::base::{selector, id, nil, NO}; + + +use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo, + NSString}; +use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular, NSWindow, + NSMenu, NSMenuItem, NSTabView, NSWindowStyleMask, NSBackingStoreType, + NSTabViewItem, NSRunningApplication, NSApplicationActivateIgnoringOtherApps}; + + +fn main() { + unsafe { + + // create a tab View + let tab_view = NSTabView::new(nil) + .initWithFrame_(NSRect::new(NSPoint::new(0., 0.), NSSize::new(200., 200.))); + + // create a tab view item + let tab_view_item = NSTabViewItem::new(nil) + .initWithIdentifier_(NSString::alloc(nil).init_str("TabView1")); + + tab_view_item.setLabel_(NSString::alloc(nil).init_str("Tab view item 1")); + tab_view.addTabViewItem_(tab_view_item); + + // create a second tab view item + let tab_view_item2 = NSTabViewItem::new(nil) + .initWithIdentifier_(NSString::alloc(nil).init_str("TabView2")); + + tab_view_item2.setLabel_(NSString::alloc(nil).init_str("Tab view item 2")); + tab_view.addTabViewItem_(tab_view_item2); + + // Create the app and set the content. + let app = create_app(NSString::alloc(nil).init_str("Tab View"), tab_view); + app.run(); + } +} + +unsafe fn create_app(title: id, content: id) -> id { + let _pool = NSAutoreleasePool::new(nil); + + let app = NSApp(); + app.setActivationPolicy_(NSApplicationActivationPolicyRegular); + + // create Menu Bar + let menubar = NSMenu::new(nil).autorelease(); + let app_menu_item = NSMenuItem::new(nil).autorelease(); + menubar.addItem_(app_menu_item); + app.setMainMenu_(menubar); + + // create Application menu + let app_menu = NSMenu::new(nil).autorelease(); + let quit_prefix = NSString::alloc(nil).init_str("Quit "); + let quit_title = + quit_prefix.stringByAppendingString_(NSProcessInfo::processInfo(nil).processName()); + let quit_action = selector("terminate:"); + let quit_key = NSString::alloc(nil).init_str("q"); + let quit_item = NSMenuItem::alloc(nil) + .initWithTitle_action_keyEquivalent_(quit_title, quit_action, quit_key) + .autorelease(); + app_menu.addItem_(quit_item); + app_menu_item.setSubmenu_(app_menu); + + // create Window + let window = NSWindow::alloc(nil).initWithContentRect_styleMask_backing_defer_( + NSRect::new(NSPoint::new(0., 0.), NSSize::new(200., 200.)), + NSWindowStyleMask::NSTitledWindowMask | + NSWindowStyleMask::NSClosableWindowMask | + NSWindowStyleMask::NSResizableWindowMask | + NSWindowStyleMask::NSMiniaturizableWindowMask | + NSWindowStyleMask::NSUnifiedTitleAndToolbarWindowMask, + NSBackingStoreType::NSBackingStoreBuffered, + NO + ).autorelease(); + window.cascadeTopLeftFromPoint_(NSPoint::new(20., 20.)); + window.center(); + + window.setTitle_(title); + window.makeKeyAndOrderFront_(nil); + + window.setContentView_(content); + let current_app = NSRunningApplication::currentApplication(nil); + current_app.activateWithOptions_(NSApplicationActivateIgnoringOtherApps); + + return app; +} diff --git a/third_party/cargo/vendor/cocoa-0.18.5/src/appkit.rs b/third_party/cargo/vendor/cocoa-0.18.5/src/appkit.rs new file mode 100644 index 0000000..883983b --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/src/appkit.rs @@ -0,0 +1,3858 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(non_upper_case_globals)] + +use base::{id, BOOL, SEL}; +use block::Block; +use foundation::{NSInteger, NSUInteger, NSTimeInterval, + NSPoint, NSSize, NSRect, NSRectEdge}; +use libc; + +pub use core_graphics::base::CGFloat; +pub use core_graphics::geometry::CGPoint; + +pub use self::NSApplicationActivationPolicy::*; +pub use self::NSApplicationActivationOptions::*; +pub use self::NSBackingStoreType::*; +pub use self::NSOpenGLPixelFormatAttribute::*; +pub use self::NSOpenGLPFAOpenGLProfiles::*; +pub use self::NSEventType::*; +use std::os::raw::c_void; + +pub type CGLContextObj = *mut c_void; + +pub type GLint = libc::int32_t; + +#[link(name = "AppKit", kind = "framework")] +extern { + pub static NSAppKitVersionNumber: f64; + + // Types for Standard Data - OS X v10.6 and later. (NSString *const) + pub static NSPasteboardTypeString: id; + pub static NSPasteboardTypePDF: id; + pub static NSPasteboardTypeTIFF: id; + pub static NSPasteboardTypePNG: id; + pub static NSPasteboardTypeRTF: id; + pub static NSPasteboardTypeRTFD: id; + pub static NSPasteboardTypeHTML: id; + pub static NSPasteboardTypeTabularText: id; + pub static NSPasteboardTypeFont: id; + pub static NSPasteboardTypeRuler: id; + pub static NSPasteboardTypeColor: id; + pub static NSPasteboardTypeSound: id; + pub static NSPasteboardTypeMultipleTextSelection: id; + pub static NSPasteboardTypeFindPanelSearchOptions: id; + + // Types for Standard Data - OS X v10.5 and earlier. (NSString *) + pub static NSStringPboardType: id; + pub static NSFilenamesPboardType: id; + pub static NSPostScriptPboardType: id; + pub static NSTIFFPboardType: id; + pub static NSRTFPboardType: id; + pub static NSTabularTextPboardType: id; + pub static NSFontPboardType: id; + pub static NSRulerPboardType: id; + pub static NSFileContentsPboardType: id; + pub static NSColorPboardType: id; + pub static NSRTFDPboardType: id; + pub static NSHTMLPboardType: id; + pub static NSPICTPboardType: id; + pub static NSURLPboardType: id; + pub static NSPDFPboardType: id; + pub static NSVCardPboardType: id; + pub static NSFilesPromisePboardType: id; + pub static NSMultipleTextSelectionPboardType: id; + pub static NSSoundPboardType: id; + + // Names of provided pasteboards. (NSString *) + pub static NSGeneralPboard: id; + pub static NSFontPboard: id; + pub static NSRulerPboard: id; + pub static NSFindPboard: id; + pub static NSDragPboard: id; + + // Pasteboard reading options - OS X v10.6 and later. (NSString *) + pub static NSPasteboardURLReadingFileURLsOnlyKey: id; + pub static NSPasteboardURLReadingContentsConformToTypesKey: id; + + // NSAppearance names. (NSString *) + pub static NSAppearanceNameVibrantDark: id; + pub static NSAppearanceNameVibrantLight: id; + + // Fullscreen mode options - OS X v10.5 and later. (NSString *) + pub static NSFullScreenModeAllScreens: id; + pub static NSFullScreenModeSetting: id; + pub static NSFullScreenModeWindowLevel: id; + pub static NSFullScreenModeApplicationPresentationOptions: id; +} + +pub const NSAppKitVersionNumber10_0: f64 = 577.0; +pub const NSAppKitVersionNumber10_1: f64 = 620.0; +pub const NSAppKitVersionNumber10_2: f64 = 663.0; +pub const NSAppKitVersionNumber10_2_3: f64 = 663.6; +pub const NSAppKitVersionNumber10_3: f64 = 743.0; +pub const NSAppKitVersionNumber10_3_2: f64 = 743.14; +pub const NSAppKitVersionNumber10_3_3: f64 = 743.2; +pub const NSAppKitVersionNumber10_3_5: f64 = 743.24; +pub const NSAppKitVersionNumber10_3_7: f64 = 743.33; +pub const NSAppKitVersionNumber10_3_9: f64 = 743.36; +pub const NSAppKitVersionNumber10_4: f64 = 824.0; +pub const NSAppKitVersionNumber10_4_1: f64 = 824.1; +pub const NSAppKitVersionNumber10_4_3: f64 = 824.23; +pub const NSAppKitVersionNumber10_4_4: f64 = 824.33; +pub const NSAppKitVersionNumber10_4_7: f64 = 824.41; +pub const NSAppKitVersionNumber10_5: f64 = 949.0; +pub const NSAppKitVersionNumber10_5_2: f64 = 949.27; +pub const NSAppKitVersionNumber10_5_3: f64 = 949.33; +pub const NSAppKitVersionNumber10_6: f64 = 1038.0; +pub const NSAppKitVersionNumber10_7: f64 = 1138.0; +pub const NSAppKitVersionNumber10_7_2: f64 = 1138.23; +pub const NSAppKitVersionNumber10_7_3: f64 = 1138.32; +pub const NSAppKitVersionNumber10_7_4: f64 = 1138.47; +pub const NSAppKitVersionNumber10_8: f64 = 1187.0; +pub const NSAppKitVersionNumber10_9: f64 = 1265.0; +pub const NSAppKitVersionNumber10_10: f64 = 1343.0; +pub const NSAppKitVersionNumber10_10_2: f64 = 1344.0; +pub const NSAppKitVersionNumber10_10_3: f64 = 1347.0; +pub const NSAppKitVersionNumber10_10_4: f64 = 1348.0; +pub const NSAppKitVersionNumber10_10_5: f64 = 1348.0; +pub const NSAppKitVersionNumber10_10_Max: f64 = 1349.0; +pub const NSAppKitVersionNumber10_11: f64 = 1404.0; +pub const NSAppKitVersionNumber10_11_1: f64 = 1404.13; +pub const NSAppKitVersionNumber10_11_2: f64 = 1404.34; +pub const NSAppKitVersionNumber10_11_3: f64 = 1404.34; +pub const NSAppKitVersionNumber10_12: f64 = 1504.0; +pub const NSAppKitVersionNumber10_12_1: f64 = 1504.60; +pub const NSAppKitVersionNumber10_12_2: f64 = 1504.76; +pub const NSAppKitVersionNumber10_13: f64 = 1561.0; +pub const NSAppKitVersionNumber10_13_1: f64 = 1561.1; +pub const NSAppKitVersionNumber10_13_2: f64 = 1561.2; +pub const NSAppKitVersionNumber10_13_4: f64 = 1561.4; + +pub unsafe fn NSApp() -> id { + msg_send![class!(NSApplication), sharedApplication] +} + +#[repr(i64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSApplicationActivationPolicy { + NSApplicationActivationPolicyRegular = 0, + NSApplicationActivationPolicyAccessory = 1, + NSApplicationActivationPolicyProhibited = 2, + NSApplicationActivationPolicyERROR = -1 +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSApplicationActivationOptions { + NSApplicationActivateAllWindows = 1 << 0, + NSApplicationActivateIgnoringOtherApps = 1 << 1 +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSApplicationTerminateReply { + NSTerminateCancel = 0, + NSTerminateNow = 1, + NSTerminateLater = 2, +} + +bitflags! { + pub struct NSApplicationPresentationOptions : NSUInteger { + const NSApplicationPresentationDefault = 0; + const NSApplicationPresentationAutoHideDock = 1 << 0; + const NSApplicationPresentationHideDock = 1 << 1; + const NSApplicationPresentationAutoHideMenuBar = 1 << 2; + const NSApplicationPresentationHideMenuBar = 1 << 3; + const NSApplicationPresentationDisableAppleMenu = 1 << 4; + const NSApplicationPresentationDisableProcessSwitching = 1 << 5; + const NSApplicationPresentationDisableForceQuit = 1 << 6; + const NSApplicationPresentationDisableSessionTermination = 1 << 7; + const NSApplicationPresentationDisableHideApplication = 1 << 8; + const NSApplicationPresentationDisableMenuBarTransparency = 1 << 9; + const NSApplicationPresentationFullScreen = 1 << 10; + const NSApplicationPresentationAutoHideToolbar = 1 << 11; + } +} + +bitflags! { + pub struct NSWindowStyleMask: NSUInteger { + const NSBorderlessWindowMask = 0; + const NSTitledWindowMask = 1 << 0; + const NSClosableWindowMask = 1 << 1; + const NSMiniaturizableWindowMask = 1 << 2; + const NSResizableWindowMask = 1 << 3; + + const NSTexturedBackgroundWindowMask = 1 << 8; + + const NSUnifiedTitleAndToolbarWindowMask = 1 << 12; + + const NSFullScreenWindowMask = 1 << 14; + + const NSFullSizeContentViewWindowMask = 1 << 15; + } +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSWindowTitleVisibility { + NSWindowTitleVisible = 0, + NSWindowTitleHidden = 1 +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSBackingStoreType { + NSBackingStoreRetained = 0, + NSBackingStoreNonretained = 1, + NSBackingStoreBuffered = 2 +} + +bitflags! { + pub struct NSWindowOrderingMode: NSInteger { + const NSWindowAbove = 1; + const NSWindowBelow = -1; + const NSWindowOut = 0; + } +} + +bitflags! { + pub struct NSAlignmentOptions: libc::c_ulonglong { + const NSAlignMinXInward = 1 << 0; + const NSAlignMinYInward = 1 << 1; + const NSAlignMaxXInward = 1 << 2; + const NSAlignMaxYInward = 1 << 3; + const NSAlignWidthInward = 1 << 4; + const NSAlignHeightInward = 1 << 5; + const NSAlignMinXOutward = 1 << 8; + const NSAlignMinYOutward = 1 << 9; + const NSAlignMaxXOutward = 1 << 10; + const NSAlignMaxYOutward = 1 << 11; + const NSAlignWidthOutward = 1 << 12; + const NSAlignHeightOutward = 1 << 13; + const NSAlignMinXNearest = 1 << 16; + const NSAlignMinYNearest = 1 << 17; + const NSAlignMaxXNearest = 1 << 18; + const NSAlignMaxYNearest = 1 << 19; + const NSAlignWidthNearest = 1 << 20; + const NSAlignHeightNearest = 1 << 21; + const NSAlignRectFlipped = 1 << 63; + const NSAlignAllEdgesInward = NSAlignmentOptions::NSAlignMinXInward.bits + | NSAlignmentOptions::NSAlignMaxXInward.bits + | NSAlignmentOptions::NSAlignMinYInward.bits + | NSAlignmentOptions::NSAlignMaxYInward.bits; + const NSAlignAllEdgesOutward = NSAlignmentOptions::NSAlignMinXOutward.bits + | NSAlignmentOptions::NSAlignMaxXOutward.bits + | NSAlignmentOptions::NSAlignMinYOutward.bits + | NSAlignmentOptions::NSAlignMaxYOutward.bits; + const NSAlignAllEdgesNearest = NSAlignmentOptions::NSAlignMinXNearest.bits + | NSAlignmentOptions::NSAlignMaxXNearest.bits + | NSAlignmentOptions::NSAlignMinYNearest.bits + | NSAlignmentOptions::NSAlignMaxYNearest.bits; + } +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSOpenGLPixelFormatAttribute { + NSOpenGLPFAAllRenderers = 1, + NSOpenGLPFATripleBuffer = 3, + NSOpenGLPFADoubleBuffer = 5, + NSOpenGLPFAStereo = 6, + NSOpenGLPFAAuxBuffers = 7, + NSOpenGLPFAColorSize = 8, + NSOpenGLPFAAlphaSize = 11, + NSOpenGLPFADepthSize = 12, + NSOpenGLPFAStencilSize = 13, + NSOpenGLPFAAccumSize = 14, + NSOpenGLPFAMinimumPolicy = 51, + NSOpenGLPFAMaximumPolicy = 52, + NSOpenGLPFAOffScreen = 53, + NSOpenGLPFAFullScreen = 54, + NSOpenGLPFASampleBuffers = 55, + NSOpenGLPFASamples = 56, + NSOpenGLPFAAuxDepthStencil = 57, + NSOpenGLPFAColorFloat = 58, + NSOpenGLPFAMultisample = 59, + NSOpenGLPFASupersample = 60, + NSOpenGLPFASampleAlpha = 61, + NSOpenGLPFARendererID = 70, + NSOpenGLPFASingleRenderer = 71, + NSOpenGLPFANoRecovery = 72, + NSOpenGLPFAAccelerated = 73, + NSOpenGLPFAClosestPolicy = 74, + NSOpenGLPFARobust = 75, + NSOpenGLPFABackingStore = 76, + NSOpenGLPFAMPSafe = 78, + NSOpenGLPFAWindow = 80, + NSOpenGLPFAMultiScreen = 81, + NSOpenGLPFACompliant = 83, + NSOpenGLPFAScreenMask = 84, + NSOpenGLPFAPixelBuffer = 90, + NSOpenGLPFARemotePixelBuffer = 91, + NSOpenGLPFAAllowOfflineRenderers = 96, + NSOpenGLPFAAcceleratedCompute = 97, + NSOpenGLPFAOpenGLProfile = 99, + NSOpenGLPFAVirtualScreenCount = 128, +} + +#[repr(u64)] +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSOpenGLPFAOpenGLProfiles { + NSOpenGLProfileVersionLegacy = 0x1000, + NSOpenGLProfileVersion3_2Core = 0x3200, + NSOpenGLProfileVersion4_1Core = 0x4100, +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSOpenGLContextParameter { + NSOpenGLCPSwapInterval = 222, + NSOpenGLCPSurfaceOrder = 235, + NSOpenGLCPSurfaceOpacity = 236, + NSOpenGLCPSurfaceBackingSize = 304, + NSOpenGLCPReclaimResources = 308, + NSOpenGLCPCurrentRendererID = 309, + NSOpenGLCPGPUVertexProcessing = 310, + NSOpenGLCPGPUFragmentProcessing = 311, + NSOpenGLCPHasDrawable = 314, + NSOpenGLCPMPSwapsInFlight = 315, +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSWindowButton { + NSWindowCloseButton = 0, + NSWindowMiniaturizeButton = 1, + NSWindowZoomButton = 2, + NSWindowToolbarButton = 3, + NSWindowDocumentIconButton = 4, + NSWindowDocumentVersionsButton = 6, + NSWindowFullScreenButton = 7, +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSBezelStyle { + NSRoundedBezelStyle = 1, + NSRegularSquareBezelStyle = 2, + NSDisclosureBezelStyle = 5, + NSShadowlessSquareBezelStyle = 6, + NSCircularBezelStyle = 7, + NSTexturedSquareBezelStyle = 8, + NSHelpButtonBezelStyle = 9, + NSSmallSquareBezelStyle = 10, + NSTexturedRoundedBezelStyle = 11, + NSRoundRectBezelStyle = 12, + NSRecessedBezelStyle = 13, + NSRoundedDisclosureBezelStyle = 14, +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSRequestUserAttentionType { + NSCriticalRequest = 0, + NSInformationalRequest = 10, +} + +pub static NSMainMenuWindowLevel: libc::int32_t = 24; + +pub trait NSApplication: Sized { + unsafe fn sharedApplication(_: Self) -> id { + msg_send![class!(NSApplication), sharedApplication] + } + + unsafe fn mainMenu(self) -> id; + unsafe fn setActivationPolicy_(self, policy: NSApplicationActivationPolicy) -> BOOL; + unsafe fn setPresentationOptions_(self, options: NSApplicationPresentationOptions) -> BOOL; + unsafe fn presentationOptions_(self) -> NSApplicationPresentationOptions; + unsafe fn setMainMenu_(self, menu: id); + unsafe fn setServicesMenu_(self, menu: id); + unsafe fn setWindowsMenu_(self, menu: id); + unsafe fn activateIgnoringOtherApps_(self, ignore: BOOL); + unsafe fn run(self); + unsafe fn finishLaunching(self); + unsafe fn nextEventMatchingMask_untilDate_inMode_dequeue_(self, + mask: NSUInteger, + expiration: id, + in_mode: id, + dequeue: BOOL) -> id; + unsafe fn sendEvent_(self, an_event: id); + unsafe fn postEvent_atStart_(self, anEvent: id, flag: BOOL); + unsafe fn stop_(self, sender: id); + unsafe fn setApplicationIconImage_(self, image: id); + unsafe fn requestUserAttention_(self, requestType: NSRequestUserAttentionType); +} + +impl NSApplication for id { + unsafe fn mainMenu(self) -> id { + msg_send![self, mainMenu] + } + + unsafe fn setActivationPolicy_(self, policy: NSApplicationActivationPolicy) -> BOOL { + msg_send![self, setActivationPolicy:policy as NSInteger] + } + + unsafe fn setPresentationOptions_(self, options: NSApplicationPresentationOptions) -> BOOL { + msg_send![self, setPresentationOptions:options.bits] + } + + unsafe fn presentationOptions_(self) -> NSApplicationPresentationOptions { + let options = msg_send![self, presentationOptions]; + return NSApplicationPresentationOptions::from_bits(options).unwrap(); + } + + unsafe fn setMainMenu_(self, menu: id) { + msg_send![self, setMainMenu:menu] + } + + unsafe fn setServicesMenu_(self, menu: id) { + msg_send![self, setServicesMenu:menu] + } + + unsafe fn setWindowsMenu_(self, menu: id) { + msg_send![self, setWindowsMenu:menu] + } + + unsafe fn activateIgnoringOtherApps_(self, ignore: BOOL) { + msg_send![self, activateIgnoringOtherApps:ignore] + } + + unsafe fn run(self) { + msg_send![self, run] + } + + unsafe fn finishLaunching(self) { + msg_send![self, finishLaunching] + } + + unsafe fn nextEventMatchingMask_untilDate_inMode_dequeue_(self, + mask: NSUInteger, + expiration: id, + in_mode: id, + dequeue: BOOL) -> id { + msg_send![self, nextEventMatchingMask:mask + untilDate:expiration + inMode:in_mode + dequeue:dequeue] + } + + unsafe fn sendEvent_(self, an_event: id) { + msg_send![self, sendEvent:an_event] + } + + unsafe fn postEvent_atStart_(self, anEvent: id, flag: BOOL) { + msg_send![self, postEvent:anEvent atStart:flag] + } + + unsafe fn stop_(self, sender: id) { + msg_send![self, stop:sender] + } + + unsafe fn setApplicationIconImage_(self, icon: id) { + msg_send![self, setApplicationIconImage:icon] + } + + unsafe fn requestUserAttention_(self, requestType: NSRequestUserAttentionType) { + msg_send![self, requestUserAttention:requestType] + } +} + +pub trait NSRunningApplication: Sized { + unsafe fn currentApplication(_: Self) -> id { + msg_send![class!(NSRunningApplication), currentApplication] + } + unsafe fn activateWithOptions_(self, options: NSApplicationActivationOptions) -> BOOL; +} + +impl NSRunningApplication for id { + unsafe fn activateWithOptions_(self, options: NSApplicationActivationOptions) -> BOOL { + msg_send![self, activateWithOptions:options as NSUInteger] + } +} + +pub trait NSPasteboard: Sized { + unsafe fn generalPasteboard(_: Self) -> id { + msg_send![class!(NSPasteboard), generalPasteboard] + } + + unsafe fn pasteboardByFilteringData_ofType(_: Self, data: id, _type: id) -> id { + msg_send![class!(NSPasteboard), pasteboardByFilteringData:data ofType:_type] + } + + unsafe fn pasteboardByFilteringFile(_: Self, file: id) -> id { + msg_send![class!(NSPasteboard), pasteboardByFilteringFile:file] + } + + unsafe fn pasteboardByFilteringTypesInPasteboard(_: Self, pboard: id) -> id { + msg_send![class!(NSPasteboard), pasteboardByFilteringTypesInPasteboard:pboard] + } + + unsafe fn pasteboardWithName(_: Self, name: id) -> id { + msg_send![class!(NSPasteboard), pasteboardWithName:name] + } + + unsafe fn pasteboardWithUniqueName(_: Self) -> id { + msg_send![class!(NSPasteboard), pasteboardWithUniqueName] + } + + unsafe fn releaseGlobally(self); + + unsafe fn clearContents(self) -> NSInteger; + unsafe fn writeObjects(self, objects: id) -> BOOL; + unsafe fn sendData_forType(self, data: id, dataType: id) -> BOOL; + unsafe fn setPropertyList_forType(self, plist: id, dataType: id) -> BOOL; + unsafe fn setString_forType(self, string: id, dataType: id) -> BOOL; + + unsafe fn readObjectsForClasses_options(self, classArray: id, options: id) -> id; + unsafe fn pasteboardItems(self) -> id; + unsafe fn indexOfPasteboardItem(self, pasteboardItem: id) -> NSInteger; + unsafe fn dataForType(self, dataType: id) -> id; + unsafe fn propertyListForType(self, dataType: id) -> id; + unsafe fn stringForType(self, dataType: id) -> id; + + unsafe fn availableTypeFromArray(self, types: id) -> id; + unsafe fn canReadItemWithDataConformingToTypes(self, types: id) -> BOOL; + unsafe fn canReadObjectForClasses_options(self, classArray: id, options: id) -> BOOL; + unsafe fn types(self) -> id; + unsafe fn typesFilterableTo(_: Self, _type: id) -> id { + msg_send![class!(NSPasteboard), typesFilterableTo:_type] + } + + unsafe fn name(self) -> id; + unsafe fn changeCount(self) -> NSInteger; + + unsafe fn declareTypes_owner(self, newTypes: id, newOwner: id) -> NSInteger; + unsafe fn addTypes_owner(self, newTypes: id, newOwner: id) -> NSInteger; + unsafe fn writeFileContents(self, filename: id) -> BOOL; + unsafe fn writeFileWrapper(self, wrapper: id) -> BOOL; + + unsafe fn readFileContentsType_toFile(self, _type: id, filename: id) -> id; + unsafe fn readFileWrapper(self) -> id; +} + +impl NSPasteboard for id { + unsafe fn releaseGlobally(self) { + msg_send![self, releaseGlobally] + } + + unsafe fn clearContents(self) -> NSInteger { + msg_send![self, clearContents] + } + + unsafe fn writeObjects(self, objects: id) -> BOOL { + msg_send![self, writeObjects:objects] + } + + unsafe fn sendData_forType(self, data: id, dataType: id) -> BOOL { + msg_send![self, sendData:data forType:dataType] + } + + unsafe fn setPropertyList_forType(self, plist: id, dataType: id) -> BOOL { + msg_send![self, setPropertyList:plist forType:dataType] + } + + unsafe fn setString_forType(self, string: id, dataType: id) -> BOOL { + msg_send![self, setString:string forType:dataType] + } + + unsafe fn readObjectsForClasses_options(self, classArray: id, options: id) -> id { + msg_send![self, readObjectsForClasses:classArray options:options] + } + + unsafe fn pasteboardItems(self) -> id { + msg_send![self, pasteboardItems] + } + + unsafe fn indexOfPasteboardItem(self, pasteboardItem: id) -> NSInteger { + msg_send![self, indexOfPasteboardItem:pasteboardItem] + } + + unsafe fn dataForType(self, dataType: id) -> id { + msg_send![self, dataForType:dataType] + } + + unsafe fn propertyListForType(self, dataType: id) -> id { + msg_send![self, propertyListForType:dataType] + } + + unsafe fn stringForType(self, dataType: id) -> id { + msg_send![self, stringForType:dataType] + } + + unsafe fn availableTypeFromArray(self, types: id) -> id { + msg_send![self, availableTypeFromArray:types] + } + + unsafe fn canReadItemWithDataConformingToTypes(self, types: id) -> BOOL { + msg_send![self, canReadItemWithDataConformingToTypes:types] + } + + unsafe fn canReadObjectForClasses_options(self, classArray: id, options: id) -> BOOL { + msg_send![self, canReadObjectForClasses:classArray options:options] + } + + unsafe fn types(self) -> id { + msg_send![self, types] + } + + unsafe fn name(self) -> id { + msg_send![self, name] + } + + unsafe fn changeCount(self) -> NSInteger { + msg_send![self, changeCount] + } + + unsafe fn declareTypes_owner(self, newTypes: id, newOwner: id) -> NSInteger { + msg_send![self, declareTypes:newTypes owner:newOwner] + } + + unsafe fn addTypes_owner(self, newTypes: id, newOwner: id) -> NSInteger { + msg_send![self, addTypes:newTypes owner:newOwner] + } + + unsafe fn writeFileContents(self, filename: id) -> BOOL { + msg_send![self, writeFileContents:filename] + } + + unsafe fn writeFileWrapper(self, wrapper: id) -> BOOL { + msg_send![self, writeFileWrapper:wrapper] + } + + unsafe fn readFileContentsType_toFile(self, _type: id, filename: id) -> id { + msg_send![self, readFileContentsType:_type toFile:filename] + } + + unsafe fn readFileWrapper(self) -> id { + msg_send![self, readFileWrapper] + } + +} + +pub trait NSPasteboardItem: Sized { + unsafe fn types(self) -> id; + + unsafe fn setDataProvider_forTypes(self, dataProvider: id, types: id) -> BOOL; + unsafe fn setData_forType(self, data: id, _type: id) -> BOOL; + unsafe fn setString_forType(self, string: id, _type: id) -> BOOL; + unsafe fn setPropertyList_forType(self, propertyList: id, _type: id) -> BOOL; + + unsafe fn dataForType(self, _type: id) -> id; + unsafe fn stringForType(self, _type: id) -> id; + unsafe fn propertyListForType(self, _type: id) -> id; +} + +impl NSPasteboardItem for id { + unsafe fn types(self) -> id { + msg_send![self, types] + } + + unsafe fn setDataProvider_forTypes(self, dataProvider: id, types: id) -> BOOL { + msg_send![self, setDataProvider:dataProvider forTypes:types] + } + + unsafe fn setData_forType(self, data: id, _type: id) -> BOOL { + msg_send![self, setData:data forType:_type] + } + + unsafe fn setString_forType(self, string: id, _type: id) -> BOOL { + msg_send![self, setString:string forType:_type] + } + + unsafe fn setPropertyList_forType(self, propertyList: id, _type: id) -> BOOL { + msg_send![self, setPropertyList:propertyList forType:_type] + } + + unsafe fn dataForType(self, _type: id) -> id { + msg_send![self, dataForType:_type] + } + + unsafe fn stringForType(self, _type: id) -> id { + msg_send![self, stringForType:_type] + } + + unsafe fn propertyListForType(self, _type: id) -> id { + msg_send![self, propertyListForType:_type] + } +} + +pub trait NSPasteboardItemDataProvider: Sized { + unsafe fn pasteboard_item_provideDataForType(self, pasteboard: id, item: id, _type: id); + unsafe fn pasteboardFinishedWithDataProvider(self, pasteboard: id); +} + +impl NSPasteboardItemDataProvider for id { + unsafe fn pasteboard_item_provideDataForType(self, pasteboard: id, item: id, _type: id) { + msg_send![self, pasteboard:pasteboard item:item provideDataForType:_type] + } + + unsafe fn pasteboardFinishedWithDataProvider(self, pasteboard: id) { + msg_send![self, pasteboardFinishedWithDataProvider:pasteboard] + } +} + +pub trait NSPasteboardWriting: Sized { + unsafe fn writableTypesForPasteboard(self, pasteboard: id) -> id; + unsafe fn writingOptionsForType_pasteboard(self, _type: id, pasteboard: id) -> NSPasteboardWritingOptions; + + unsafe fn pasteboardPropertyListForType(self, _type: id) -> id; +} + +impl NSPasteboardWriting for id { + unsafe fn writableTypesForPasteboard(self, pasteboard: id) -> id { + msg_send![self, writableTypesForPasteboard:pasteboard] + } + + unsafe fn writingOptionsForType_pasteboard(self, _type: id, pasteboard: id) -> NSPasteboardWritingOptions { + msg_send![self, writingOptionsForType:_type pasteboard:pasteboard] + } + + unsafe fn pasteboardPropertyListForType(self, _type: id) -> id { + msg_send![self, pasteboardPropertyListForType:_type] + } +} + +pub trait NSPasteboardReading: Sized { + unsafe fn initWithPasteboardPropertyList_ofType(self, propertyList: id, _type: id) -> id; + + unsafe fn readableTypesForPasteboard(self, pasteboard: id) -> id; + unsafe fn readingOptionsForType_pasteboard(self, _type: id, pasteboard: id) -> NSPasteboardReadingOptions; +} + +impl NSPasteboardReading for id { + unsafe fn initWithPasteboardPropertyList_ofType(self, propertyList: id, _type: id) -> id { + msg_send![self, initWithPasteboardPropertyList:propertyList ofType:_type] + } + + unsafe fn readableTypesForPasteboard(self, pasteboard: id) -> id { + let class: id = msg_send![self, class]; + msg_send![class, readableTypesForPasteboard:pasteboard] + } + unsafe fn readingOptionsForType_pasteboard(self, _type: id, pasteboard: id) -> NSPasteboardReadingOptions { + let class: id = msg_send![self, class]; + msg_send![class, readingOptionsForType:_type pasteboard:pasteboard] + } +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSPasteboardReadingOptions { + NSPasteboardReadingAsData = 0, + NSPasteboardReadingAsString = 1 << 0, + NSPasteboardReadingAsPropertyList = 1 << 1, + NSPasteboardReadingAsKeyedArchive = 1 << 2 +} + +#[repr(u64)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NSPasteboardWritingOptions { + NSPasteboardWritingPromised = 1 << 9, +} + +pub trait NSMenu: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSMenu), alloc] + } + + unsafe fn new(_: Self) -> id { + msg_send![class!(NSMenu), new] + } + + unsafe fn initWithTitle_(self, title: id /* NSString */) -> id; + unsafe fn setAutoenablesItems(self, state: BOOL); + + unsafe fn addItem_(self, menu_item: id); + unsafe fn addItemWithTitle_action_keyEquivalent(self, title: id, action: SEL, key: id) -> id; + unsafe fn itemAtIndex_(self, index: NSInteger) -> id; +} + +impl NSMenu for id { + unsafe fn initWithTitle_(self, title: id /* NSString */) -> id { + msg_send![self, initWithTitle:title] + } + + unsafe fn setAutoenablesItems(self, state: BOOL) { + msg_send![self, setAutoenablesItems: state] + } + + unsafe fn addItem_(self, menu_item: id) { + msg_send![self, addItem:menu_item] + } + + unsafe fn addItemWithTitle_action_keyEquivalent(self, title: id, action: SEL, key: id) -> id { + msg_send![self, addItemWithTitle:title action:action keyEquivalent:key] + } + + unsafe fn itemAtIndex_(self, index: NSInteger) -> id { + msg_send![self, itemAtIndex:index] + } +} + +pub trait NSMenuItem: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSMenuItem), alloc] + } + + unsafe fn new(_: Self) -> id { + msg_send![class!(NSMenuItem), new] + } + + unsafe fn separatorItem(_: Self) -> id { + msg_send![class!(NSMenuItem), separatorItem] + } + + unsafe fn initWithTitle_action_keyEquivalent_(self, title: id, action: SEL, key: id) -> id; + unsafe fn setKeyEquivalentModifierMask_(self, mask: NSEventModifierFlags); + unsafe fn setSubmenu_(self, submenu: id); +} + +impl NSMenuItem for id { + unsafe fn initWithTitle_action_keyEquivalent_(self, title: id, action: SEL, key: id) -> id { + msg_send![self, initWithTitle:title action:action keyEquivalent:key] + } + + unsafe fn setKeyEquivalentModifierMask_(self, mask: NSEventModifierFlags) { + msg_send![self, setKeyEquivalentModifierMask:mask] + } + + unsafe fn setSubmenu_(self, submenu: id) { + msg_send![self, setSubmenu:submenu] + } +} + +pub type NSWindowDepth = libc::c_int; + +bitflags! { + pub struct NSWindowCollectionBehavior: NSUInteger { + const NSWindowCollectionBehaviorDefault = 0; + const NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0; + const NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1; + + const NSWindowCollectionBehaviorManaged = 1 << 2; + const NSWindowCollectionBehaviorTransient = 1 << 3; + const NSWindowCollectionBehaviorStationary = 1 << 4; + + const NSWindowCollectionBehaviorParticipatesInCycle = 1 << 5; + const NSWindowCollectionBehaviorIgnoresCycle = 1 << 6; + + const NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7; + const NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8; + } +} + +bitflags! { + pub struct NSWindowOcclusionState: NSUInteger { + const NSWindowOcclusionStateVisible = 1 << 1; + } +} + +pub trait NSWindow: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSWindow), alloc] + } + + // Creating Windows + unsafe fn initWithContentRect_styleMask_backing_defer_(self, + rect: NSRect, + style: NSWindowStyleMask, + backing: NSBackingStoreType, + defer: BOOL) -> id; + unsafe fn initWithContentRect_styleMask_backing_defer_screen_(self, + rect: NSRect, + style: NSWindowStyleMask, + backing: NSBackingStoreType, + defer: BOOL, + screen: id) -> id; + + // Configuring Windows + unsafe fn styleMask(self) -> NSWindowStyleMask; + unsafe fn setStyleMask_(self, styleMask: NSWindowStyleMask); + unsafe fn toggleFullScreen_(self, sender: id); + unsafe fn worksWhenModal(self) -> BOOL; + unsafe fn alphaValue(self) -> CGFloat; + unsafe fn setAlphaValue_(self, windowAlpha: CGFloat); + unsafe fn backgroundColor(self) -> id; + unsafe fn setBackgroundColor_(self, color: id); + unsafe fn colorSpace(self) -> id; + unsafe fn setColorSpace_(self, colorSpace: id); + unsafe fn contentView(self) -> id; + unsafe fn setContentView_(self, view: id); + unsafe fn canHide(self) -> BOOL; + unsafe fn setCanHide_(self, canHide: BOOL); + unsafe fn hidesOnDeactivate(self) -> BOOL; + unsafe fn setHidesOnDeactivate_(self, hideOnDeactivate: BOOL); + unsafe fn collectionBehavior(self) -> NSWindowCollectionBehavior; + unsafe fn setCollectionBehavior_(self, collectionBehavior: NSWindowCollectionBehavior); + unsafe fn setOpaque_(self, opaque: BOOL); + unsafe fn hasShadow(self) -> BOOL; + unsafe fn setHasShadow_(self, hasShadow: BOOL); + unsafe fn invalidateShadow(self); + unsafe fn autorecalculatesContentBorderThicknessForEdge_(self, edge: NSRectEdge) -> BOOL; + unsafe fn setAutorecalculatesContentBorderThickness_forEdge_(self, + autorecalculateContentBorderThickness: BOOL, + edge: NSRectEdge) -> BOOL; + unsafe fn contentBorderThicknessForEdge_(self, edge: NSRectEdge) -> CGFloat; + unsafe fn setContentBorderThickness_forEdge_(self, borderThickness: CGFloat, edge: NSRectEdge); + unsafe fn delegate(self) -> id; + unsafe fn setDelegate_(self, delegate: id); + unsafe fn preventsApplicationTerminationWhenModal(self) -> BOOL; + unsafe fn setPreventsApplicationTerminationWhenModal_(self, flag: BOOL); + + // TODO: Accessing Window Information + + // Getting Layout Information + unsafe fn contentRectForFrameRect_styleMask_(self, windowFrame: NSRect, windowStyle: NSWindowStyleMask) -> NSRect; + unsafe fn frameRectForContentRect_styleMask_(self, windowContentRect: NSRect, windowStyle: NSWindowStyleMask) -> NSRect; + unsafe fn minFrameWidthWithTitle_styleMask_(self, windowTitle: id, windowStyle: NSWindowStyleMask) -> CGFloat; + unsafe fn contentRectForFrameRect_(self, windowFrame: NSRect) -> NSRect; + unsafe fn frameRectForContentRect_(self, windowContent: NSRect) -> NSRect; + + // Managing Windows + unsafe fn drawers(self) -> id; + unsafe fn windowController(self) -> id; + unsafe fn setWindowController_(self, windowController: id); + + // TODO: Managing Sheets + + // Sizing Windows + unsafe fn frame(self) -> NSRect; + unsafe fn setFrameOrigin_(self, point: NSPoint); + unsafe fn setFrameTopLeftPoint_(self, point: NSPoint); + unsafe fn constrainFrameRect_toScreen_(self, frameRect: NSRect, screen: id); + unsafe fn cascadeTopLeftFromPoint_(self, topLeft: NSPoint) -> NSPoint; + unsafe fn setFrame_display_(self, windowFrame: NSRect, display: BOOL); + unsafe fn setFrame_displayViews_(self, windowFrame: NSRect, display: BOOL); + unsafe fn aspectRatio(self) -> NSSize; + unsafe fn setAspectRatio_(self, aspectRatio: NSSize); + unsafe fn minSize(self) -> NSSize; + unsafe fn setMinSize_(self, minSize: NSSize); + unsafe fn maxSize(self) -> NSSize; + unsafe fn setMaxSize_(self, maxSize: NSSize); + unsafe fn performZoom_(self, sender: id); + unsafe fn zoom_(self, sender: id); + unsafe fn resizeFlags(self) -> NSInteger; + unsafe fn showsResizeIndicator(self) -> BOOL; + unsafe fn setShowsResizeIndicator_(self, showsResizeIndicator: BOOL); + unsafe fn resizeIncrements(self) -> NSSize; + unsafe fn setResizeIncrements_(self, resizeIncrements: NSSize); + unsafe fn preservesContentDuringLiveResize(self) -> BOOL; + unsafe fn setPreservesContentDuringLiveResize_(self, preservesContentDuringLiveResize: BOOL); + unsafe fn inLiveResize(self) -> BOOL; + + // Sizing Content + unsafe fn contentAspectRatio(self) -> NSSize; + unsafe fn setContentAspectRatio_(self, contentAspectRatio: NSSize); + unsafe fn contentMinSize(self) -> NSSize; + unsafe fn setContentMinSize_(self, contentMinSize: NSSize); + unsafe fn contentSize(self) -> NSSize; + unsafe fn setContentSize_(self, contentSize: NSSize); + unsafe fn contentMaxSize(self) -> NSSize; + unsafe fn setContentMaxSize_(self, contentMaxSize: NSSize); + unsafe fn contentResizeIncrements(self) -> NSSize; + unsafe fn setContentResizeIncrements_(self, contentResizeIncrements: NSSize); + + // Managing Window Visibility and Occlusion State + unsafe fn isVisible(self) -> BOOL; // NOTE: Deprecated in 10.9 + unsafe fn occlusionState(self) -> NSWindowOcclusionState; + + // Managing Window Layers + unsafe fn orderOut_(self, sender: id); + unsafe fn orderBack_(self, sender: id); + unsafe fn orderFront_(self, sender: id); + unsafe fn orderFrontRegardless(self); + unsafe fn orderFrontWindow_relativeTo_(self, orderingMode: NSWindowOrderingMode, otherWindowNumber: NSInteger); + unsafe fn level(self) -> NSInteger; + unsafe fn setLevel_(self, level: NSInteger); + + // Managing Key Status + unsafe fn canBecomeKeyWindow(self) -> BOOL; + unsafe fn makeKeyWindow(self); + unsafe fn makeKeyAndOrderFront_(self, sender: id); + // skipped: becomeKeyWindow (should not be invoked directly, according to Apple's documentation) + // skipped: resignKeyWindow (should not be invoked directly, according to Apple's documentation) + + // Managing Main Status + unsafe fn canBecomeMainWindow(self) -> BOOL; + unsafe fn makeMainWindow(self); + // skipped: becomeMainWindow (should not be invoked directly, according to Apple's documentation) + // skipped: resignMainWindow (should not be invoked directly, according to Apple's documentation) + + // Managing Toolbars + unsafe fn toolbar(self) -> id /* NSToolbar */; + unsafe fn setToolbar_(self, toolbar: id /* NSToolbar */); + unsafe fn runToolbarCustomizationPalette(self, sender: id); + + // TODO: Managing Attached Windows + // TODO: Managing Window Buffers + // TODO: Managing Default Buttons + // TODO: Managing Field Editors + // TODO: Managing the Window Menu + // TODO: Managing Cursor Rectangles + + // Managing Title Bars + unsafe fn standardWindowButton_(self, windowButtonKind: NSWindowButton) -> id; + + // TODO: Managing Tooltips + // TODO: Handling Events + + // Managing Responders + unsafe fn initialFirstResponder(self) -> id; + unsafe fn firstResponder(self) -> id; + unsafe fn setInitialFirstResponder_(self, responder: id); + unsafe fn makeFirstResponder_(self, responder: id) -> BOOL; + + // TODO: Managing the Key View Loop + + // Handling Keyboard Events + unsafe fn keyDown_(self, event: id); + + // Handling Mouse Events + unsafe fn acceptsMouseMovedEvents(self) -> BOOL; + unsafe fn ignoresMouseEvents(self) -> BOOL; + unsafe fn setIgnoresMouseEvents_(self, ignoreMouseEvents: BOOL); + unsafe fn mouseLocationOutsideOfEventStream(self) -> NSPoint; + unsafe fn setAcceptsMouseMovedEvents_(self, acceptMouseMovedEvents: BOOL); + unsafe fn windowNumberAtPoint_belowWindowWithWindowNumber_(self, + point: NSPoint, + windowNumber: NSInteger) -> NSInteger; + + // TODO: Handling Window Restoration + // TODO: Bracketing Drawing Operations + // TODO: Drawing Windows + // TODO: Window Animation + // TODO: Updating Windows + // TODO: Dragging Items + + // Converting Coordinates + unsafe fn backingScaleFactor(self) -> CGFloat; + unsafe fn backingAlignedRect_options_(self, rect: NSRect, options: NSAlignmentOptions) -> NSRect; + unsafe fn convertRectFromBacking_(self, rect: NSRect) -> NSRect; + unsafe fn convertRectToBacking_(self, rect: NSRect) -> NSRect; + unsafe fn convertRectToScreen_(self, rect: NSRect) -> NSRect; + unsafe fn convertRectFromScreen_(self, rect: NSRect) -> NSRect; + + // Accessing Edited Status + unsafe fn setDocumentEdited_(self, documentEdited: BOOL); + + // Managing Titles + unsafe fn title(self) -> id; + unsafe fn setTitle_(self, title: id); + unsafe fn setTitleWithRepresentedFilename_(self, filePath: id); + unsafe fn setTitleVisibility_(self, visibility: NSWindowTitleVisibility); + unsafe fn setTitlebarAppearsTransparent_(self, transparent: BOOL); + unsafe fn representedFilename(self) -> id; + unsafe fn setRepresentedFilename_(self, filePath: id); + unsafe fn representedURL(self) -> id; + unsafe fn setRepresentedURL_(self, representedURL: id); + + // Accessing Screen Information + unsafe fn screen(self) -> id; + unsafe fn deepestScreen(self) -> id; + unsafe fn displaysWhenScreenProfileChanges(self) -> BOOL; + unsafe fn setDisplaysWhenScreenProfileChanges_(self, displaysWhenScreenProfileChanges: BOOL); + + // Moving Windows + unsafe fn setMovableByWindowBackground_(self, movableByWindowBackground: BOOL); + unsafe fn setMovable_(self, movable: BOOL); + unsafe fn center(self); + + // Closing Windows + unsafe fn performClose_(self, sender: id); + unsafe fn close(self); + unsafe fn setReleasedWhenClosed_(self, releasedWhenClosed: BOOL); + + // Minimizing Windows + unsafe fn performMiniaturize_(self, sender: id); + unsafe fn miniaturize_(self, sender: id); + unsafe fn deminiaturize_(self, sender: id); + unsafe fn miniwindowImage(self) -> id; + unsafe fn setMiniwindowImage_(self, miniwindowImage: id); + unsafe fn miniwindowTitle(self) -> id; + unsafe fn setMiniwindowTitle_(self, miniwindowTitle: id); + + // TODO: Getting the Dock Tile + // TODO: Printing Windows + // TODO: Providing Services + // TODO: Working with Carbon + // TODO: Triggering Constraint-Based Layout + // TODO: Debugging Constraint-Based Layout + // TODO: Constraint-Based Layouts +} + +impl NSWindow for id { + // Creating Windows + + unsafe fn initWithContentRect_styleMask_backing_defer_(self, + rect: NSRect, + style: NSWindowStyleMask, + backing: NSBackingStoreType, + defer: BOOL) -> id { + msg_send![self, initWithContentRect:rect + styleMask:style.bits + backing:backing as NSUInteger + defer:defer] + } + + unsafe fn initWithContentRect_styleMask_backing_defer_screen_(self, + rect: NSRect, + style: NSWindowStyleMask, + backing: NSBackingStoreType, + defer: BOOL, + screen: id) -> id { + msg_send![self, initWithContentRect:rect + styleMask:style.bits + backing:backing as NSUInteger + defer:defer + screen:screen] + } + + // Configuring Windows + + unsafe fn styleMask(self) -> NSWindowStyleMask { + NSWindowStyleMask::from_bits_truncate(msg_send![self, styleMask]) + } + + unsafe fn setStyleMask_(self, styleMask: NSWindowStyleMask) { + msg_send![self, setStyleMask:styleMask.bits] + } + + unsafe fn toggleFullScreen_(self, sender: id) { + msg_send![self, toggleFullScreen:sender] + } + + unsafe fn worksWhenModal(self) -> BOOL { + msg_send![self, worksWhenModal] + } + + unsafe fn alphaValue(self) -> CGFloat { + msg_send![self, alphaValue] + } + + unsafe fn setAlphaValue_(self, windowAlpha: CGFloat) { + msg_send![self, setAlphaValue:windowAlpha] + } + + unsafe fn backgroundColor(self) -> id { + msg_send![self, backgroundColor] + } + + unsafe fn setBackgroundColor_(self, color: id) { + msg_send![self, setBackgroundColor:color] + } + + unsafe fn colorSpace(self) -> id { + msg_send![self, colorSpace] + } + + unsafe fn setColorSpace_(self, colorSpace: id) { + msg_send![self, setColorSpace:colorSpace] + } + + unsafe fn contentView(self) -> id { + msg_send![self, contentView] + } + + unsafe fn setContentView_(self, view: id) { + msg_send![self, setContentView:view] + } + + unsafe fn canHide(self) -> BOOL { + msg_send![self, canHide] + } + + unsafe fn setCanHide_(self, canHide: BOOL) { + msg_send![self, setCanHide:canHide] + } + + unsafe fn hidesOnDeactivate(self) -> BOOL { + msg_send![self, hidesOnDeactivate] + } + + unsafe fn setHidesOnDeactivate_(self, hideOnDeactivate: BOOL) { + msg_send![self, setHidesOnDeactivate:hideOnDeactivate] + } + + unsafe fn collectionBehavior(self) -> NSWindowCollectionBehavior { + msg_send![self, collectionBehavior] + } + + unsafe fn setCollectionBehavior_(self, collectionBehavior: NSWindowCollectionBehavior) { + msg_send![self, setCollectionBehavior:collectionBehavior] + } + + unsafe fn setOpaque_(self, opaque: BOOL) { + msg_send![self, setOpaque:opaque] + } + + unsafe fn hasShadow(self) -> BOOL { + msg_send![self, hasShadow] + } + + unsafe fn setHasShadow_(self, hasShadow: BOOL) { + msg_send![self, setHasShadow:hasShadow] + } + + unsafe fn invalidateShadow(self) { + msg_send![self, invalidateShadow] + } + + unsafe fn autorecalculatesContentBorderThicknessForEdge_(self, edge: NSRectEdge) -> BOOL { + msg_send![self, autorecalculatesContentBorderThicknessForEdge:edge] + } + + unsafe fn setAutorecalculatesContentBorderThickness_forEdge_(self, + autorecalculateContentBorderThickness: BOOL, + edge: NSRectEdge) -> BOOL { + msg_send![self, setAutorecalculatesContentBorderThickness: + autorecalculateContentBorderThickness forEdge:edge] + } + + unsafe fn contentBorderThicknessForEdge_(self, edge: NSRectEdge) -> CGFloat { + msg_send![self, contentBorderThicknessForEdge:edge] + } + + unsafe fn setContentBorderThickness_forEdge_(self, borderThickness: CGFloat, edge: NSRectEdge) { + msg_send![self, setContentBorderThickness:borderThickness forEdge:edge] + } + + unsafe fn delegate(self) -> id { + msg_send![self, delegate] + } + + unsafe fn setDelegate_(self, delegate: id) { + msg_send![self, setDelegate:delegate] + } + + unsafe fn preventsApplicationTerminationWhenModal(self) -> BOOL { + msg_send![self, preventsApplicationTerminationWhenModal] + } + + unsafe fn setPreventsApplicationTerminationWhenModal_(self, flag: BOOL) { + msg_send![self, setPreventsApplicationTerminationWhenModal:flag] + } + + // TODO: Accessing Window Information + + // Getting Layout Information + + unsafe fn contentRectForFrameRect_styleMask_(self, windowFrame: NSRect, windowStyle: NSWindowStyleMask) -> NSRect { + msg_send![self, contentRectForFrameRect:windowFrame styleMask:windowStyle.bits] + } + + unsafe fn frameRectForContentRect_styleMask_(self, windowContentRect: NSRect, windowStyle: NSWindowStyleMask) -> NSRect { + msg_send![self, frameRectForContentRect:windowContentRect styleMask:windowStyle.bits] + } + + unsafe fn minFrameWidthWithTitle_styleMask_(self, windowTitle: id, windowStyle: NSWindowStyleMask) -> CGFloat { + msg_send![self, minFrameWidthWithTitle:windowTitle styleMask:windowStyle.bits] + } + + unsafe fn contentRectForFrameRect_(self, windowFrame: NSRect) -> NSRect { + msg_send![self, contentRectForFrameRect:windowFrame] + } + + unsafe fn frameRectForContentRect_(self, windowContent: NSRect) -> NSRect { + msg_send![self, frameRectForContentRect:windowContent] + } + + // Managing Windows + + unsafe fn drawers(self) -> id { + msg_send![self, drawers] + } + + unsafe fn windowController(self) -> id { + msg_send![self, windowController] + } + + unsafe fn setWindowController_(self, windowController: id) { + msg_send![self, setWindowController:windowController] + } + + // TODO: Managing Sheets + + // Sizing Windows + + unsafe fn frame(self) -> NSRect { + msg_send![self, frame] + } + + unsafe fn setFrameOrigin_(self, point: NSPoint) { + msg_send![self, setFrameOrigin:point] + } + + unsafe fn setFrameTopLeftPoint_(self, point: NSPoint) { + msg_send![self, setFrameTopLeftPoint:point] + } + + unsafe fn constrainFrameRect_toScreen_(self, frameRect: NSRect, screen: id) { + msg_send![self, constrainFrameRect:frameRect toScreen:screen] + } + + unsafe fn cascadeTopLeftFromPoint_(self, topLeft: NSPoint) -> NSPoint { + msg_send![self, cascadeTopLeftFromPoint:topLeft] + } + + unsafe fn setFrame_display_(self, windowFrame: NSRect, display: BOOL) { + msg_send![self, setFrame:windowFrame display:display] + } + + unsafe fn setFrame_displayViews_(self, windowFrame: NSRect, display: BOOL) { + msg_send![self, setFrame:windowFrame displayViews:display] + } + + unsafe fn aspectRatio(self) -> NSSize { + msg_send![self, aspectRatio] + } + + unsafe fn setAspectRatio_(self, aspectRatio: NSSize) { + msg_send![self, setAspectRatio:aspectRatio] + } + + unsafe fn minSize(self) -> NSSize { + msg_send![self, minSize] + } + + unsafe fn setMinSize_(self, minSize: NSSize) { + msg_send![self, setMinSize:minSize] + } + + unsafe fn maxSize(self) -> NSSize { + msg_send![self, maxSize] + } + + unsafe fn setMaxSize_(self, maxSize: NSSize) { + msg_send![self, setMaxSize:maxSize] + } + + unsafe fn performZoom_(self, sender: id) { + msg_send![self, performZoom:sender] + } + + unsafe fn zoom_(self, sender: id) { + msg_send![self, zoom:sender] + } + + unsafe fn resizeFlags(self) -> NSInteger { + msg_send![self, resizeFlags] + } + + unsafe fn showsResizeIndicator(self) -> BOOL { + msg_send![self, showsResizeIndicator] + } + + unsafe fn setShowsResizeIndicator_(self, showsResizeIndicator: BOOL) { + msg_send![self, setShowsResizeIndicator:showsResizeIndicator] + } + + unsafe fn resizeIncrements(self) -> NSSize { + msg_send![self, resizeIncrements] + } + + unsafe fn setResizeIncrements_(self, resizeIncrements: NSSize) { + msg_send![self, setResizeIncrements:resizeIncrements] + } + + unsafe fn preservesContentDuringLiveResize(self) -> BOOL { + msg_send![self, preservesContentDuringLiveResize] + } + + unsafe fn setPreservesContentDuringLiveResize_(self, preservesContentDuringLiveResize: BOOL) { + msg_send![self, setPreservesContentDuringLiveResize:preservesContentDuringLiveResize] + } + + unsafe fn inLiveResize(self) -> BOOL { + msg_send![self, inLiveResize] + } + + // Sizing Content + + unsafe fn contentAspectRatio(self) -> NSSize { + msg_send![self, contentAspectRatio] + } + + unsafe fn setContentAspectRatio_(self, contentAspectRatio: NSSize) { + msg_send![self, setContentAspectRatio:contentAspectRatio] + } + + unsafe fn contentMinSize(self) -> NSSize { + msg_send![self, contentMinSize] + } + + unsafe fn setContentMinSize_(self, contentMinSize: NSSize) { + msg_send![self, setContentMinSize:contentMinSize] + } + + unsafe fn contentSize(self) -> NSSize { + msg_send![self, contentSize] + } + + unsafe fn setContentSize_(self, contentSize: NSSize) { + msg_send![self, setContentSize:contentSize] + } + + unsafe fn contentMaxSize(self) -> NSSize { + msg_send![self, contentMaxSize] + } + + unsafe fn setContentMaxSize_(self, contentMaxSize: NSSize) { + msg_send![self, setContentMaxSize:contentMaxSize] + } + + unsafe fn contentResizeIncrements(self) -> NSSize { + msg_send![self, contentResizeIncrements] + } + + unsafe fn setContentResizeIncrements_(self, contentResizeIncrements: NSSize) { + msg_send![self, setContentResizeIncrements:contentResizeIncrements] + } + + // Managing Window Visibility and Occlusion State + + unsafe fn isVisible(self) -> BOOL { + msg_send![self, isVisible] + } + + unsafe fn occlusionState(self) -> NSWindowOcclusionState { + msg_send![self, occlusionState] + } + + // Managing Window Layers + + unsafe fn orderOut_(self, sender: id) { + msg_send![self, orderOut:sender] + } + + unsafe fn orderBack_(self, sender: id) { + msg_send![self, orderBack:sender] + } + + unsafe fn orderFront_(self, sender: id) { + msg_send![self, orderFront:sender] + } + + unsafe fn orderFrontRegardless(self) { + msg_send![self, orderFrontRegardless] + } + + unsafe fn orderFrontWindow_relativeTo_(self, ordering_mode: NSWindowOrderingMode, other_window_number: NSInteger) { + msg_send![self, orderWindow:ordering_mode relativeTo:other_window_number] + } + + unsafe fn level(self) -> NSInteger { + msg_send![self, level] + } + + unsafe fn setLevel_(self, level: NSInteger) { + msg_send![self, setLevel:level] + } + + // Managing Key Status + + unsafe fn canBecomeKeyWindow(self) -> BOOL { + msg_send![self, canBecomeKeyWindow] + } + + unsafe fn makeKeyWindow(self) { + msg_send![self, makeKeyWindow] + } + + unsafe fn makeKeyAndOrderFront_(self, sender: id) { + msg_send![self, makeKeyAndOrderFront:sender] + } + + // Managing Main Status + + unsafe fn canBecomeMainWindow(self) -> BOOL { + msg_send![self, canBecomeMainWindow] + } + + unsafe fn makeMainWindow(self) { + msg_send![self, makeMainWindow] + } + + // Managing Toolbars + + unsafe fn toolbar(self) -> id /* NSToolbar */ { + msg_send![self, toolbar] + } + + unsafe fn setToolbar_(self, toolbar: id /* NSToolbar */) { + msg_send![self, setToolbar:toolbar] + } + + unsafe fn runToolbarCustomizationPalette(self, sender: id) { + msg_send![self, runToolbarCustomizationPalette:sender] + } + + // TODO: Managing Attached Windows + // TODO: Managing Window Buffers + // TODO: Managing Default Buttons + // TODO: Managing Field Editors + // TODO: Managing the Window Menu + // TODO: Managing Cursor Rectangles + + // Managing Title Bars + + unsafe fn standardWindowButton_(self, windowButtonKind: NSWindowButton) -> id { + msg_send![self, standardWindowButton:windowButtonKind] + } + + // TODO: Managing Tooltips + // TODO: Handling Events + + // Managing Responders + + unsafe fn initialFirstResponder(self) -> id { + msg_send![self, initialFirstResponder] + } + + unsafe fn firstResponder(self) -> id { + msg_send![self, firstResponder] + } + + unsafe fn setInitialFirstResponder_(self, responder: id) { + msg_send![self, setInitialFirstResponder:responder] + } + + unsafe fn makeFirstResponder_(self, responder: id) -> BOOL { + msg_send![self, makeFirstResponder:responder] + } + + // TODO: Managing the Key View Loop + + // Handling Keyboard Events + + unsafe fn keyDown_(self, event: id) { + msg_send![self, keyDown:event] + } + + // Handling Mouse Events + + unsafe fn acceptsMouseMovedEvents(self) -> BOOL { + msg_send![self, acceptsMouseMovedEvents] + } + + unsafe fn ignoresMouseEvents(self) -> BOOL { + msg_send![self, ignoresMouseEvents] + } + + unsafe fn setIgnoresMouseEvents_(self, ignoreMouseEvents: BOOL) { + msg_send![self, setIgnoresMouseEvents:ignoreMouseEvents] + } + + unsafe fn mouseLocationOutsideOfEventStream(self) -> NSPoint { + msg_send![self, mouseLocationOutsideOfEventStream] + } + + unsafe fn setAcceptsMouseMovedEvents_(self, acceptMouseMovedEvents: BOOL) { + msg_send![self, setAcceptsMouseMovedEvents:acceptMouseMovedEvents] + } + + unsafe fn windowNumberAtPoint_belowWindowWithWindowNumber_(self, + point: NSPoint, + windowNumber: NSInteger) -> NSInteger { + msg_send![self, windowNumberAtPoint:point belowWindowWithWindowNumber:windowNumber] + } + + // Converting Coordinates + + unsafe fn backingScaleFactor(self) -> CGFloat { + msg_send![self, backingScaleFactor] + } + + unsafe fn backingAlignedRect_options_(self, rect: NSRect, options: NSAlignmentOptions) -> NSRect { + msg_send![self, backingAlignedRect:rect options:options] + } + + unsafe fn convertRectFromBacking_(self, rect: NSRect) -> NSRect { + msg_send![self, convertRectFromBacking:rect] + } + + unsafe fn convertRectToBacking_(self, rect: NSRect) -> NSRect { + msg_send![self, convertRectToBacking:rect] + } + + unsafe fn convertRectToScreen_(self, rect: NSRect) -> NSRect { + msg_send![self, convertRectToScreen:rect] + } + + unsafe fn convertRectFromScreen_(self, rect: NSRect) -> NSRect { + msg_send![self, convertRectFromScreen:rect] + } + + // Accessing Edited Status + + unsafe fn setDocumentEdited_(self, documentEdited: BOOL) { + msg_send![self, setDocumentEdited:documentEdited] + } + + // Managing Titles + + unsafe fn title(self) -> id { + msg_send![self, title] + } + + unsafe fn setTitle_(self, title: id) { + msg_send![self, setTitle:title] + } + + unsafe fn setTitleWithRepresentedFilename_(self, filePath: id) { + msg_send![self, setTitleWithRepresentedFilename:filePath] + } + + unsafe fn setTitleVisibility_(self, visibility: NSWindowTitleVisibility) { + msg_send![self, setTitleVisibility:visibility] + } + + unsafe fn setTitlebarAppearsTransparent_(self, transparent: BOOL) { + msg_send![self, setTitlebarAppearsTransparent:transparent] + } + + unsafe fn representedFilename(self) -> id { + msg_send![self, representedFilename] + } + + unsafe fn setRepresentedFilename_(self, filePath: id) { + msg_send![self, setRepresentedFilename:filePath] + } + + unsafe fn representedURL(self) -> id { + msg_send![self, representedURL] + } + + unsafe fn setRepresentedURL_(self, representedURL: id) { + msg_send![self, setRepresentedURL:representedURL] + } + + // Accessing Screen Information + + unsafe fn screen(self) -> id { + msg_send![self, screen] + } + + unsafe fn deepestScreen(self) -> id { + msg_send![self, deepestScreen] + } + + unsafe fn displaysWhenScreenProfileChanges(self) -> BOOL { + msg_send![self, displaysWhenScreenProfileChanges] + } + + unsafe fn setDisplaysWhenScreenProfileChanges_(self, displaysWhenScreenProfileChanges: BOOL) { + msg_send![self, setDisplaysWhenScreenProfileChanges:displaysWhenScreenProfileChanges] + } + + // Moving Windows + + unsafe fn setMovableByWindowBackground_(self, movableByWindowBackground: BOOL) { + msg_send![self, setMovableByWindowBackground:movableByWindowBackground] + } + + unsafe fn setMovable_(self, movable: BOOL) { + msg_send![self, setMovable:movable] + } + + unsafe fn center(self) { + msg_send![self, center] + } + + // Closing Windows + + unsafe fn performClose_(self, sender: id) { + msg_send![self, performClose:sender] + } + + unsafe fn close(self) { + msg_send![self, close] + } + + unsafe fn setReleasedWhenClosed_(self, releasedWhenClosed: BOOL) { + msg_send![self, setReleasedWhenClosed:releasedWhenClosed] + } + + // Minimizing Windows + + unsafe fn performMiniaturize_(self, sender: id) { + msg_send![self, performMiniaturize:sender] + } + + unsafe fn miniaturize_(self, sender: id) { + msg_send![self, miniaturize:sender] + } + + unsafe fn deminiaturize_(self, sender: id) { + msg_send![self, deminiaturize:sender] + } + + unsafe fn miniwindowImage(self) -> id { + msg_send![self, miniwindowImage] + } + + unsafe fn setMiniwindowImage_(self, miniwindowImage: id) { + msg_send![self, setMiniwindowImage:miniwindowImage] + } + + unsafe fn miniwindowTitle(self) -> id { + msg_send![self, miniwindowTitle] + } + + unsafe fn setMiniwindowTitle_(self, miniwindowTitle: id) { + msg_send![self, setMiniwindowTitle:miniwindowTitle] + } + + // TODO: Getting the Dock Tile + // TODO: Printing Windows + // TODO: Providing Services + // TODO: Working with Carbon + // TODO: Triggering Constraint-Based Layout + // TODO: Debugging Constraint-Based Layout + // TODO: Constraint-Based Layouts +} + +pub trait NSView: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSView), alloc] + } + + unsafe fn init(self) -> id; + unsafe fn initWithFrame_(self, frameRect: NSRect) -> id; + unsafe fn bounds(self) -> NSRect; + unsafe fn frame(self) -> NSRect; + unsafe fn display_(self); + unsafe fn setWantsBestResolutionOpenGLSurface_(self, flag: BOOL); + unsafe fn convertPoint_fromView_(self, point: NSPoint, view: id) -> NSPoint; + unsafe fn addSubview_(self, view: id); + unsafe fn superview(self) -> id; + unsafe fn removeFromSuperview(self); + unsafe fn setAutoresizingMask_(self, autoresizingMask: NSAutoresizingMaskOptions); + + unsafe fn wantsLayer(self) -> BOOL; + unsafe fn setWantsLayer(self, wantsLayer: BOOL); + unsafe fn layer(self) -> id; + unsafe fn setLayer(self, layer: id); + + unsafe fn widthAnchor(self) -> id; + unsafe fn heightAnchor(self) -> id; + unsafe fn convertRectToBacking(self, rect: NSRect) -> NSRect; +} + +impl NSView for id { + unsafe fn init(self) -> id { + msg_send![self, init] + } + + unsafe fn initWithFrame_(self, frameRect: NSRect) -> id { + msg_send![self, initWithFrame:frameRect] + } + + unsafe fn bounds(self) -> NSRect { + msg_send![self, bounds] + } + + unsafe fn frame(self) -> NSRect { + msg_send![self, frame] + } + + unsafe fn display_(self) { + msg_send![self, display] + } + + unsafe fn setWantsBestResolutionOpenGLSurface_(self, flag: BOOL) { + msg_send![self, setWantsBestResolutionOpenGLSurface:flag] + } + + unsafe fn convertPoint_fromView_(self, point: NSPoint, view: id) -> NSPoint { + msg_send![self, convertPoint:point fromView:view] + } + + unsafe fn addSubview_(self, view: id) { + msg_send![self, addSubview:view] + } + + unsafe fn superview(self) -> id { + msg_send![self, superview] + } + + unsafe fn removeFromSuperview(self) { + msg_send![self, removeFromSuperview] + } + + unsafe fn setAutoresizingMask_(self, autoresizingMask: NSAutoresizingMaskOptions) { + msg_send![self, setAutoresizingMask:autoresizingMask] + } + + unsafe fn wantsLayer(self) -> BOOL { + msg_send![self, wantsLayer] + } + + unsafe fn setWantsLayer(self, wantsLayer: BOOL) { + msg_send![self, setWantsLayer:wantsLayer] + } + + unsafe fn layer(self) -> id { + msg_send![self, layer] + } + + unsafe fn setLayer(self, layer: id) { + msg_send![self, setLayer:layer] + } + + unsafe fn widthAnchor(self) -> id { + msg_send![self, widthAnchor] + } + + unsafe fn heightAnchor(self) -> id { + msg_send![self, heightAnchor] + } + + unsafe fn convertRectToBacking(self, rect: NSRect) -> NSRect { + msg_send![self, convertRectToBacking:rect] + } +} + +pub type NSAutoresizingMaskOptions = u64; + +pub const NSViewNotSizable: u64 = 0; +pub const NSViewMinXMargin: u64 = 1; +pub const NSViewWidthSizable: u64 = 2; +pub const NSViewMaxXMargin: u64 = 4; +pub const NSViewMinYMargin: u64 = 8; +pub const NSViewHeightSizable: u64 = 16; +pub const NSViewMaxYMargin: u64 = 32; + +pub trait NSOpenGLView: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSOpenGLView), alloc] + } + + unsafe fn initWithFrame_pixelFormat_(self, frameRect: NSRect, format: id) -> id; + unsafe fn display_(self); + unsafe fn setOpenGLContext_(self, context: id); + unsafe fn setPixelFormat_(self, pixelformat: id); +} + +impl NSOpenGLView for id { + unsafe fn initWithFrame_pixelFormat_(self, frameRect: NSRect, format: id) -> id { + msg_send![self, initWithFrame:frameRect pixelFormat:format] + } + + unsafe fn display_(self) { + msg_send![self, display] + } + + unsafe fn setOpenGLContext_(self, context: id) { + msg_send![self, setOpenGLContext:context] + } + + unsafe fn setPixelFormat_(self, pixelformat: id) { + msg_send![self, setPixelFormat:pixelformat] + } +} + +pub trait NSOpenGLPixelFormat: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSOpenGLPixelFormat), alloc] + } + + // Creating an NSOpenGLPixelFormat Object + + unsafe fn initWithAttributes_(self, attributes: &[u32]) -> id; + + // Managing the Pixel Format + + unsafe fn getValues_forAttribute_forVirtualScreen_(self, val: *mut GLint, attrib: NSOpenGLPixelFormatAttribute, screen: GLint); + unsafe fn numberOfVirtualScreens(self) -> GLint; + +} + +impl NSOpenGLPixelFormat for id { + // Creating an NSOpenGLPixelFormat Object + + unsafe fn initWithAttributes_(self, attributes: &[u32]) -> id { + msg_send![self, initWithAttributes:attributes] + } + + // Managing the Pixel Format + + unsafe fn getValues_forAttribute_forVirtualScreen_(self, val: *mut GLint, attrib: NSOpenGLPixelFormatAttribute, screen: GLint) { + msg_send![self, getValues:val forAttribute:attrib forVirtualScreen:screen] + } + + unsafe fn numberOfVirtualScreens(self) -> GLint { + msg_send![self, numberOfVirtualScreens] + } +} + +pub trait NSOpenGLContext: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSOpenGLContext), alloc] + } + + // Context Creation + unsafe fn initWithFormat_shareContext_(self, format: id /* (NSOpenGLPixelFormat *) */, shareContext: id /* (NSOpenGLContext *) */) -> id /* (instancetype) */; + unsafe fn initWithCGLContextObj_(self, context: CGLContextObj) -> id /* (instancetype) */; + + // Managing the Current Context + unsafe fn clearCurrentContext(_: Self); + unsafe fn currentContext(_: Self) -> id /* (NSOpenGLContext *) */; + unsafe fn makeCurrentContext(self); + + // Drawable Object Management + unsafe fn setView_(self, view: id /* (NSView *) */); + unsafe fn view(self) -> id /* (NSView *) */; + unsafe fn clearDrawable(self); + unsafe fn update(self); + + // Flushing the Drawing Buffer + unsafe fn flushBuffer(self); + + // Context Parameter Handling + unsafe fn setValues_forParameter_(self, vals: *const GLint, param: NSOpenGLContextParameter); + unsafe fn getValues_forParameter_(self, vals: *mut GLint, param: NSOpenGLContextParameter); + + // Working with Virtual Screens + unsafe fn setCurrentVirtualScreen_(self, screen: GLint); + unsafe fn currentVirtualScreen(self) -> GLint; + + // Getting the CGL Context Object + unsafe fn CGLContextObj(self) -> CGLContextObj; +} + +impl NSOpenGLContext for id { + // Context Creation + + unsafe fn initWithFormat_shareContext_(self, format: id /* (NSOpenGLPixelFormat *) */, shareContext: id /* (NSOpenGLContext *) */) -> id /* (instancetype) */ { + msg_send![self, initWithFormat:format shareContext:shareContext] + } + + unsafe fn initWithCGLContextObj_(self, context: CGLContextObj) -> id /* (instancetype) */ { + msg_send![self, initWithCGLContextObj:context] + } + + // Managing the Current Context + + unsafe fn clearCurrentContext(_: Self) { + msg_send![class!(NSOpenGLContext), clearCurrentContext] + } + + unsafe fn currentContext(_: Self) -> id /* (NSOpenGLContext *) */ { + msg_send![class!(NSOpenGLContext), currentContext] + } + + unsafe fn makeCurrentContext(self) { + msg_send![self, makeCurrentContext] + } + + // Drawable Object Management + + unsafe fn setView_(self, view: id /* (NSView *) */) { + msg_send![self, setView:view] + } + + unsafe fn view(self) -> id /* (NSView *) */ { + msg_send![self, view] + } + + unsafe fn clearDrawable(self) { + msg_send![self, clearDrawable] + } + + unsafe fn update(self) { + msg_send![self, update] + } + + // Flushing the Drawing Buffer + + unsafe fn flushBuffer(self) { + msg_send![self, flushBuffer] + } + + // Context Parameter Handling + + unsafe fn setValues_forParameter_(self, vals: *const GLint, param: NSOpenGLContextParameter) { + msg_send![self, setValues:vals forParameter:param] + } + + unsafe fn getValues_forParameter_(self, vals: *mut GLint, param: NSOpenGLContextParameter) { + msg_send![self, getValues:vals forParameter:param] + } + + // Working with Virtual Screens + + unsafe fn setCurrentVirtualScreen_(self, screen: GLint) { + msg_send![self, setCurrentVirtualScreen:screen] + } + + unsafe fn currentVirtualScreen(self) -> GLint { + msg_send![self, currentVirtualScreen] + } + + // Getting the CGL Context Object + + unsafe fn CGLContextObj(self) -> CGLContextObj { + msg_send![self, CGLContextObj] + } +} + +bitflags! { + pub struct NSEventSwipeTrackingOptions: NSUInteger { + const NSEventSwipeTrackingLockDirection = 0x1 << 0; + const NSEventSwipeTrackingClampGestureAmount = 0x1 << 1; + } +} + +#[repr(i64)] // NSInteger +pub enum NSEventGestureAxis { + NSEventGestureAxisNone = 0, + NSEventGestureAxisHorizontal, + NSEventGestureAxisVertical, +} + +bitflags! { + pub struct NSEventPhase: NSUInteger { + const NSEventPhaseNone = 0; + const NSEventPhaseBegan = 0x1 << 0; + const NSEventPhaseStationary = 0x1 << 1; + const NSEventPhaseChanged = 0x1 << 2; + const NSEventPhaseEnded = 0x1 << 3; + const NSEventPhaseCancelled = 0x1 << 4; + const NSEventPhaseMayBegin = 0x1 << 5; + } +} + +bitflags! { + pub struct NSTouchPhase: NSUInteger { + const NSTouchPhaseBegan = 1 << 0; + const NSTouchPhaseMoved = 1 << 1; + const NSTouchPhaseStationary = 1 << 2; + const NSTouchPhaseEnded = 1 << 3; + const NSTouchPhaseCancelled = 1 << 4; + const NSTouchPhaseTouching = NSTouchPhase::NSTouchPhaseBegan.bits + | NSTouchPhase::NSTouchPhaseMoved.bits + | NSTouchPhase::NSTouchPhaseStationary.bits; + const NSTouchPhaseAny = !0; // NSUIntegerMax + } +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(u64)] // NSUInteger +pub enum NSEventType { + NSLeftMouseDown = 1, + NSLeftMouseUp = 2, + NSRightMouseDown = 3, + NSRightMouseUp = 4, + NSMouseMoved = 5, + NSLeftMouseDragged = 6, + NSRightMouseDragged = 7, + NSMouseEntered = 8, + NSMouseExited = 9, + NSKeyDown = 10, + NSKeyUp = 11, + NSFlagsChanged = 12, + NSAppKitDefined = 13, + NSSystemDefined = 14, + NSApplicationDefined = 15, + NSPeriodic = 16, + NSCursorUpdate = 17, + NSScrollWheel = 22, + NSTabletPoint = 23, + NSTabletProximity = 24, + NSOtherMouseDown = 25, + NSOtherMouseUp = 26, + NSOtherMouseDragged = 27, + NSEventTypeGesture = 29, + NSEventTypeMagnify = 30, + NSEventTypeSwipe = 31, + NSEventTypeRotate = 18, + NSEventTypeBeginGesture = 19, + NSEventTypeEndGesture = 20, + NSEventTypePressure = 34, +} + +bitflags! { + pub struct NSEventMask: libc::c_ulonglong { + const NSLeftMouseDownMask = 1 << NSLeftMouseDown as libc::c_ulonglong; + const NSLeftMouseUpMask = 1 << NSLeftMouseUp as libc::c_ulonglong; + const NSRightMouseDownMask = 1 << NSRightMouseDown as libc::c_ulonglong; + const NSRightMouseUpMask = 1 << NSRightMouseUp as libc::c_ulonglong; + const NSMouseMovedMask = 1 << NSMouseMoved as libc::c_ulonglong; + const NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged as libc::c_ulonglong; + const NSRightMouseDraggedMask = 1 << NSRightMouseDragged as libc::c_ulonglong; + const NSMouseEnteredMask = 1 << NSMouseEntered as libc::c_ulonglong; + const NSMouseExitedMask = 1 << NSMouseExited as libc::c_ulonglong; + const NSKeyDownMask = 1 << NSKeyDown as libc::c_ulonglong; + const NSKeyUpMask = 1 << NSKeyUp as libc::c_ulonglong; + const NSFlagsChangedMask = 1 << NSFlagsChanged as libc::c_ulonglong; + const NSAppKitDefinedMask = 1 << NSAppKitDefined as libc::c_ulonglong; + const NSSystemDefinedMask = 1 << NSSystemDefined as libc::c_ulonglong; + const NSApplicationDefinedMask = 1 << NSApplicationDefined as libc::c_ulonglong; + const NSPeriodicMask = 1 << NSPeriodic as libc::c_ulonglong; + const NSCursorUpdateMask = 1 << NSCursorUpdate as libc::c_ulonglong; + const NSScrollWheelMask = 1 << NSScrollWheel as libc::c_ulonglong; + const NSTabletPointMask = 1 << NSTabletPoint as libc::c_ulonglong; + const NSTabletProximityMask = 1 << NSTabletProximity as libc::c_ulonglong; + const NSOtherMouseDownMask = 1 << NSOtherMouseDown as libc::c_ulonglong; + const NSOtherMouseUpMask = 1 << NSOtherMouseUp as libc::c_ulonglong; + const NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged as libc::c_ulonglong; + const NSEventMaskGesture = 1 << NSEventTypeGesture as libc::c_ulonglong; + const NSEventMaskSwipe = 1 << NSEventTypeSwipe as libc::c_ulonglong; + const NSEventMaskRotate = 1 << NSEventTypeRotate as libc::c_ulonglong; + const NSEventMaskBeginGesture = 1 << NSEventTypeBeginGesture as libc::c_ulonglong; + const NSEventMaskEndGesture = 1 << NSEventTypeEndGesture as libc::c_ulonglong; + const NSEventMaskPressure = 1 << NSEventTypePressure as libc::c_ulonglong; + const NSAnyEventMask = 0xffffffffffffffff; + } +} + +impl NSEventMask { + pub fn from_type(ty: NSEventType) -> NSEventMask { + NSEventMask { bits: 1 << ty as libc::c_ulonglong } + } +} + +bitflags! { + pub struct NSEventModifierFlags: NSUInteger { + const NSAlphaShiftKeyMask = 1 << 16; + const NSShiftKeyMask = 1 << 17; + const NSControlKeyMask = 1 << 18; + const NSAlternateKeyMask = 1 << 19; + const NSCommandKeyMask = 1 << 20; + const NSNumericPadKeyMask = 1 << 21; + const NSHelpKeyMask = 1 << 22; + const NSFunctionKeyMask = 1 << 23; + const NSDeviceIndependentModifierFlagsMask = 0xffff0000; + } +} + +// Not sure of the type here +pub enum NSPointingDeviceType { + // TODO: Not sure what these values are + // NSUnknownPointingDevice = NX_TABLET_POINTER_UNKNOWN, + // NSPenPointingDevice = NX_TABLET_POINTER_PEN, + // NSCursorPointingDevice = NX_TABLET_POINTER_CURSOR, + // NSEraserPointingDevice = NX_TABLET_POINTER_ERASER, +} + +// Not sure of the type here +pub enum NSEventButtonMask { + // TODO: Not sure what these values are + // NSPenTipMask = NX_TABLET_BUTTON_PENTIPMASK, + // NSPenLowerSideMask = NX_TABLET_BUTTON_PENLOWERSIDEMASK, + // NSPenUpperSideMask = NX_TABLET_BUTTON_PENUPPERSIDEMASK, +} + +#[repr(i16)] +pub enum NSEventSubtype { + // TODO: Not sure what these values are + // NSMouseEventSubtype = NX_SUBTYPE_DEFAULT, + // NSTabletPointEventSubtype = NX_SUBTYPE_TABLET_POINT, + // NSTabletProximityEventSubtype = NX_SUBTYPE_TABLET_PROXIMITY + // NSTouchEventSubtype = NX_SUBTYPE_MOUSE_TOUCH, + NSWindowExposedEventType = 0, + NSApplicationActivatedEventType = 1, + NSApplicationDeactivatedEventType = 2, + NSWindowMovedEventType = 4, + NSScreenChangedEventType = 8, + NSAWTEventType = 16, +} + +pub const NSUpArrowFunctionKey: libc::c_ushort = 0xF700; +pub const NSDownArrowFunctionKey: libc::c_ushort = 0xF701; +pub const NSLeftArrowFunctionKey: libc::c_ushort = 0xF702; +pub const NSRightArrowFunctionKey: libc::c_ushort = 0xF703; +pub const NSF1FunctionKey: libc::c_ushort = 0xF704; +pub const NSF2FunctionKey: libc::c_ushort = 0xF705; +pub const NSF3FunctionKey: libc::c_ushort = 0xF706; +pub const NSF4FunctionKey: libc::c_ushort = 0xF707; +pub const NSF5FunctionKey: libc::c_ushort = 0xF708; +pub const NSF6FunctionKey: libc::c_ushort = 0xF709; +pub const NSF7FunctionKey: libc::c_ushort = 0xF70A; +pub const NSF8FunctionKey: libc::c_ushort = 0xF70B; +pub const NSF9FunctionKey: libc::c_ushort = 0xF70C; +pub const NSF10FunctionKey: libc::c_ushort = 0xF70D; +pub const NSF11FunctionKey: libc::c_ushort = 0xF70E; +pub const NSF12FunctionKey: libc::c_ushort = 0xF70F; +pub const NSF13FunctionKey: libc::c_ushort = 0xF710; +pub const NSF14FunctionKey: libc::c_ushort = 0xF711; +pub const NSF15FunctionKey: libc::c_ushort = 0xF712; +pub const NSF16FunctionKey: libc::c_ushort = 0xF713; +pub const NSF17FunctionKey: libc::c_ushort = 0xF714; +pub const NSF18FunctionKey: libc::c_ushort = 0xF715; +pub const NSF19FunctionKey: libc::c_ushort = 0xF716; +pub const NSF20FunctionKey: libc::c_ushort = 0xF717; +pub const NSF21FunctionKey: libc::c_ushort = 0xF718; +pub const NSF22FunctionKey: libc::c_ushort = 0xF719; +pub const NSF23FunctionKey: libc::c_ushort = 0xF71A; +pub const NSF24FunctionKey: libc::c_ushort = 0xF71B; +pub const NSF25FunctionKey: libc::c_ushort = 0xF71C; +pub const NSF26FunctionKey: libc::c_ushort = 0xF71D; +pub const NSF27FunctionKey: libc::c_ushort = 0xF71E; +pub const NSF28FunctionKey: libc::c_ushort = 0xF71F; +pub const NSF29FunctionKey: libc::c_ushort = 0xF720; +pub const NSF30FunctionKey: libc::c_ushort = 0xF721; +pub const NSF31FunctionKey: libc::c_ushort = 0xF722; +pub const NSF32FunctionKey: libc::c_ushort = 0xF723; +pub const NSF33FunctionKey: libc::c_ushort = 0xF724; +pub const NSF34FunctionKey: libc::c_ushort = 0xF725; +pub const NSF35FunctionKey: libc::c_ushort = 0xF726; +pub const NSInsertFunctionKey: libc::c_ushort = 0xF727; +pub const NSDeleteFunctionKey: libc::c_ushort = 0xF728; +pub const NSHomeFunctionKey: libc::c_ushort = 0xF729; +pub const NSBeginFunctionKey: libc::c_ushort = 0xF72A; +pub const NSEndFunctionKey: libc::c_ushort = 0xF72B; +pub const NSPageUpFunctionKey: libc::c_ushort = 0xF72C; +pub const NSPageDownFunctionKey: libc::c_ushort = 0xF72D; +pub const NSPrintScreenFunctionKey: libc::c_ushort = 0xF72E; +pub const NSScrollLockFunctionKey: libc::c_ushort = 0xF72F; +pub const NSPauseFunctionKey: libc::c_ushort = 0xF730; +pub const NSSysReqFunctionKey: libc::c_ushort = 0xF731; +pub const NSBreakFunctionKey: libc::c_ushort = 0xF732; +pub const NSResetFunctionKey: libc::c_ushort = 0xF733; +pub const NSStopFunctionKey: libc::c_ushort = 0xF734; +pub const NSMenuFunctionKey: libc::c_ushort = 0xF735; +pub const NSUserFunctionKey: libc::c_ushort = 0xF736; +pub const NSSystemFunctionKey: libc::c_ushort = 0xF737; +pub const NSPrintFunctionKey: libc::c_ushort = 0xF738; +pub const NSClearLineFunctionKey: libc::c_ushort = 0xF739; +pub const NSClearDisplayFunctionKey: libc::c_ushort = 0xF73A; +pub const NSInsertLineFunctionKey: libc::c_ushort = 0xF73B; +pub const NSDeleteLineFunctionKey: libc::c_ushort = 0xF73C; +pub const NSInsertCharFunctionKey: libc::c_ushort = 0xF73D; +pub const NSDeleteCharFunctionKey: libc::c_ushort = 0xF73E; +pub const NSPrevFunctionKey: libc::c_ushort = 0xF73F; +pub const NSNextFunctionKey: libc::c_ushort = 0xF740; +pub const NSSelectFunctionKey: libc::c_ushort = 0xF741; +pub const NSExecuteFunctionKey: libc::c_ushort = 0xF742; +pub const NSUndoFunctionKey: libc::c_ushort = 0xF743; +pub const NSRedoFunctionKey: libc::c_ushort = 0xF744; +pub const NSFindFunctionKey: libc::c_ushort = 0xF745; +pub const NSHelpFunctionKey: libc::c_ushort = 0xF746; +pub const NSModeSwitchFunctionKey: libc::c_ushort = 0xF747; + +pub trait NSEvent: Sized { + // Creating Events + unsafe fn keyEventWithType_location_modifierFlags_timestamp_windowNumber_context_characters_charactersIgnoringModifiers_isARepeat_keyCode_( + _: Self, + eventType: NSEventType, + location: NSPoint, + modifierFlags: NSEventModifierFlags, + timestamp: NSTimeInterval, + windowNumber: NSInteger, + context: id /* (NSGraphicsContext *) */, + characters: id /* (NSString *) */, + unmodCharacters: id /* (NSString *) */, + repeatKey: BOOL, + code: libc::c_ushort) -> id /* (NSEvent *) */; + unsafe fn mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_( + _: Self, + eventType: NSEventType, + location: NSPoint, + modifierFlags: NSEventModifierFlags, + timestamp: NSTimeInterval, + windowNumber: NSInteger, + context: id /* (NSGraphicsContext *) */, + eventNumber: NSInteger, + clickCount: NSInteger, + pressure: libc::c_float) -> id /* (NSEvent *) */; + unsafe fn enterExitEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_trackingNumber_userData_( + _: Self, + eventType: NSEventType, + location: NSPoint, + modifierFlags: NSEventModifierFlags, + timestamp: NSTimeInterval, + windowNumber: NSInteger, + context: id /* (NSGraphicsContext *) */, + eventNumber: NSInteger, + trackingNumber: NSInteger, + userData: *mut c_void) -> id /* (NSEvent *) */; + unsafe fn otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_( + _: Self, + eventType: NSEventType, + location: NSPoint, + modifierFlags: NSEventModifierFlags, + timestamp: NSTimeInterval, + windowNumber: NSInteger, + context: id /* (NSGraphicsContext *) */, + subtype: NSEventSubtype, + data1: NSInteger, + data2: NSInteger) -> id /* (NSEvent *) */; + unsafe fn eventWithEventRef_(_: Self, eventRef: *const c_void) -> id; + unsafe fn eventWithCGEvent_(_: Self, cgEvent: *mut c_void /* CGEventRef */) -> id; + + // Getting General Event Information + unsafe fn context(self) -> id /* (NSGraphicsContext *) */; + unsafe fn locationInWindow(self) -> NSPoint; + unsafe fn modifierFlags(self) -> NSEventModifierFlags; + unsafe fn timestamp(self) -> NSTimeInterval; + // NOTE: renamed from `- type` due to Rust keyword collision + unsafe fn eventType(self) -> NSEventType; + unsafe fn window(self) -> id /* (NSWindow *) */; + unsafe fn windowNumber(self) -> NSInteger; + unsafe fn eventRef(self) -> *const c_void; + unsafe fn CGEvent(self) -> *mut c_void /* CGEventRef */; + + // Getting Key Event Information + // NOTE: renamed from `+ modifierFlags` due to conflict with `- modifierFlags` + unsafe fn currentModifierFlags(_: Self) -> NSEventModifierFlags; + unsafe fn keyRepeatDelay(_: Self) -> NSTimeInterval; + unsafe fn keyRepeatInterval(_: Self) -> NSTimeInterval; + unsafe fn characters(self) -> id /* (NSString *) */; + unsafe fn charactersIgnoringModifiers(self) -> id /* (NSString *) */; + unsafe fn keyCode(self) -> libc::c_ushort; + + // Getting Mouse Event Information + unsafe fn pressedMouseButtons(_: Self) -> NSUInteger; + unsafe fn doubleClickInterval(_: Self) -> NSTimeInterval; + unsafe fn mouseLocation(_: Self) -> NSPoint; + unsafe fn buttonNumber(self) -> NSInteger; + unsafe fn clickCount(self) -> NSInteger; + unsafe fn pressure(self) -> libc::c_float; + unsafe fn stage(self) -> NSInteger; + unsafe fn setMouseCoalescingEnabled_(_: Self, flag: BOOL); + unsafe fn isMouseCoalescingEnabled(_: Self) -> BOOL; + + // Getting Mouse-Tracking Event Information + unsafe fn eventNumber(self) -> NSInteger; + unsafe fn trackingNumber(self) -> NSInteger; + unsafe fn trackingArea(self) -> id /* (NSTrackingArea *) */; + unsafe fn userData(self) -> *const c_void; + + // Getting Custom Event Information + unsafe fn data1(self) -> NSInteger; + unsafe fn data2(self) -> NSInteger; + unsafe fn subtype(self) -> NSEventSubtype; + + // Getting Scroll Wheel Event Information + unsafe fn deltaX(self) -> CGFloat; + unsafe fn deltaY(self) -> CGFloat; + unsafe fn deltaZ(self) -> CGFloat; + + // Getting Tablet Proximity Information + unsafe fn capabilityMask(self) -> NSUInteger; + unsafe fn deviceID(self) -> NSUInteger; + unsafe fn pointingDeviceID(self) -> NSUInteger; + unsafe fn pointingDeviceSerialNumber(self) -> NSUInteger; + unsafe fn pointingDeviceType(self) -> NSPointingDeviceType; + unsafe fn systemTabletID(self) -> NSUInteger; + unsafe fn tabletID(self) -> NSUInteger; + unsafe fn uniqueID(self) -> libc::c_ulonglong; + unsafe fn vendorID(self) -> NSUInteger; + unsafe fn vendorPointingDeviceType(self) -> NSUInteger; + + // Getting Tablet Pointing Information + unsafe fn absoluteX(self) -> NSInteger; + unsafe fn absoluteY(self) -> NSInteger; + unsafe fn absoluteZ(self) -> NSInteger; + unsafe fn buttonMask(self) -> NSEventButtonMask; + unsafe fn rotation(self) -> libc::c_float; + unsafe fn tangentialPressure(self) -> libc::c_float; + unsafe fn tilt(self) -> NSPoint; + unsafe fn vendorDefined(self) -> id; + + // Requesting and Stopping Periodic Events + unsafe fn startPeriodicEventsAfterDelay_withPeriod_(_: Self, delaySeconds: NSTimeInterval, periodSeconds: NSTimeInterval); + unsafe fn stopPeriodicEvents(_: Self); + + // Getting Touch and Gesture Information + unsafe fn magnification(self) -> CGFloat; + unsafe fn touchesMatchingPhase_inView_(self, phase: NSTouchPhase, view: id /* (NSView *) */) -> id /* (NSSet *) */; + unsafe fn isSwipeTrackingFromScrollEventsEnabled(_: Self) -> BOOL; + + // Monitoring Application Events + // TODO: addGlobalMonitorForEventsMatchingMask_handler_ (unsure how to bind to blocks) + // TODO: addLocalMonitorForEventsMatchingMask_handler_ (unsure how to bind to blocks) + unsafe fn removeMonitor_(_: Self, eventMonitor: id); + + // Scroll Wheel and Flick Events + unsafe fn hasPreciseScrollingDeltas(self) -> BOOL; + unsafe fn scrollingDeltaX(self) -> CGFloat; + unsafe fn scrollingDeltaY(self) -> CGFloat; + unsafe fn momentumPhase(self) -> NSEventPhase; + unsafe fn phase(self) -> NSEventPhase; + // TODO: trackSwipeEventWithOptions_dampenAmountThresholdMin_max_usingHandler_ (unsure how to bind to blocks) + + // Converting a Mouse Event’s Position into a Sprite Kit Node’s Coordinate Space + unsafe fn locationInNode_(self, node: id /* (SKNode *) */) -> CGPoint; +} + +impl NSEvent for id { + // Creating Events + + unsafe fn keyEventWithType_location_modifierFlags_timestamp_windowNumber_context_characters_charactersIgnoringModifiers_isARepeat_keyCode_( + _: Self, + eventType: NSEventType, + location: NSPoint, + modifierFlags: NSEventModifierFlags, + timestamp: NSTimeInterval, + windowNumber: NSInteger, + context: id /* (NSGraphicsContext *) */, + characters: id /* (NSString *) */, + unmodCharacters: id /* (NSString *) */, + repeatKey: BOOL, + code: libc::c_ushort) -> id /* (NSEvent *) */ + { + msg_send![class!(NSEvent), keyEventWithType:eventType + location:location + modifierFlags:modifierFlags + timestamp:timestamp + windowNumber:windowNumber + context:context + characters:characters + charactersIgnoringModifiers:unmodCharacters + isARepeat:repeatKey + keyCode:code] + } + + unsafe fn mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_( + _: Self, + eventType: NSEventType, + location: NSPoint, + modifierFlags: NSEventModifierFlags, + timestamp: NSTimeInterval, + windowNumber: NSInteger, + context: id /* (NSGraphicsContext *) */, + eventNumber: NSInteger, + clickCount: NSInteger, + pressure: libc::c_float) -> id /* (NSEvent *) */ + { + msg_send![class!(NSEvent), mouseEventWithType:eventType + location:location + modifierFlags:modifierFlags + timestamp:timestamp + windowNumber:windowNumber + context:context + eventNumber:eventNumber + clickCount:clickCount + pressure:pressure] + } + + unsafe fn enterExitEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_trackingNumber_userData_( + _: Self, + eventType: NSEventType, + location: NSPoint, + modifierFlags: NSEventModifierFlags, + timestamp: NSTimeInterval, + windowNumber: NSInteger, + context: id /* (NSGraphicsContext *) */, + eventNumber: NSInteger, + trackingNumber: NSInteger, + userData: *mut c_void) -> id /* (NSEvent *) */ + { + msg_send![class!(NSEvent), enterExitEventWithType:eventType + location:location + modifierFlags:modifierFlags + timestamp:timestamp + windowNumber:windowNumber + context:context + eventNumber:eventNumber + trackingNumber:trackingNumber + userData:userData] + } + + unsafe fn otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_( + _: Self, + eventType: NSEventType, + location: NSPoint, + modifierFlags: NSEventModifierFlags, + timestamp: NSTimeInterval, + windowNumber: NSInteger, + context: id /* (NSGraphicsContext *) */, + subtype: NSEventSubtype, + data1: NSInteger, + data2: NSInteger) -> id /* (NSEvent *) */ + { + msg_send![class!(NSEvent), otherEventWithType:eventType + location:location + modifierFlags:modifierFlags + timestamp:timestamp + windowNumber:windowNumber + context:context + subtype:subtype + data1:data1 + data2:data2] + } + + unsafe fn eventWithEventRef_(_: Self, eventRef: *const c_void) -> id { + msg_send![class!(NSEvent), eventWithEventRef:eventRef] + } + + unsafe fn eventWithCGEvent_(_: Self, cgEvent: *mut c_void /* CGEventRef */) -> id { + msg_send![class!(NSEvent), eventWithCGEvent:cgEvent] + } + + // Getting General Event Information + + unsafe fn context(self) -> id /* (NSGraphicsContext *) */ { + msg_send![self, context] + } + + unsafe fn locationInWindow(self) -> NSPoint { + msg_send![self, locationInWindow] + } + + unsafe fn modifierFlags(self) -> NSEventModifierFlags { + msg_send![self, modifierFlags] + } + + unsafe fn timestamp(self) -> NSTimeInterval { + msg_send![self, timestamp] + } + // NOTE: renamed from `- type` due to Rust keyword collision + + unsafe fn eventType(self) -> NSEventType { + msg_send![self, type] + } + + unsafe fn window(self) -> id /* (NSWindow *) */ { + msg_send![self, window] + } + + unsafe fn windowNumber(self) -> NSInteger { + msg_send![self, windowNumber] + } + + unsafe fn eventRef(self) -> *const c_void { + msg_send![self, eventRef] + } + + unsafe fn CGEvent(self) -> *mut c_void /* CGEventRef */ { + msg_send![self, CGEvent] + } + + // Getting Key Event Information + + // NOTE: renamed from `+ modifierFlags` due to conflict with `- modifierFlags` + + unsafe fn currentModifierFlags(_: Self) -> NSEventModifierFlags { + msg_send![class!(NSEvent), currentModifierFlags] + } + + unsafe fn keyRepeatDelay(_: Self) -> NSTimeInterval { + msg_send![class!(NSEvent), keyRepeatDelay] + } + + unsafe fn keyRepeatInterval(_: Self) -> NSTimeInterval { + msg_send![class!(NSEvent), keyRepeatInterval] + } + + unsafe fn characters(self) -> id /* (NSString *) */ { + msg_send![self, characters] + } + + unsafe fn charactersIgnoringModifiers(self) -> id /* (NSString *) */ { + msg_send![self, charactersIgnoringModifiers] + } + + unsafe fn keyCode(self) -> libc::c_ushort { + msg_send![self, keyCode] + } + + // Getting Mouse Event Information + + unsafe fn pressedMouseButtons(_: Self) -> NSUInteger { + msg_send![class!(NSEvent), pressedMouseButtons] + } + + unsafe fn doubleClickInterval(_: Self) -> NSTimeInterval { + msg_send![class!(NSEvent), doubleClickInterval] + } + + unsafe fn mouseLocation(_: Self) -> NSPoint { + msg_send![class!(NSEvent), mouseLocation] + } + + unsafe fn buttonNumber(self) -> NSInteger { + msg_send![self, buttonNumber] + } + + unsafe fn clickCount(self) -> NSInteger { + msg_send![self, clickCount] + } + + unsafe fn pressure(self) -> libc::c_float { + msg_send![self, pressure] + } + + unsafe fn stage(self) -> NSInteger{ + msg_send![self, stage] + } + + unsafe fn setMouseCoalescingEnabled_(_: Self, flag: BOOL) { + msg_send![class!(NSEvent), setMouseCoalescingEnabled:flag] + } + + unsafe fn isMouseCoalescingEnabled(_: Self) -> BOOL { + msg_send![class!(NSEvent), isMouseCoalescingEnabled] + } + + // Getting Mouse-Tracking Event Information + + unsafe fn eventNumber(self) -> NSInteger { + msg_send![self, eventNumber] + } + + unsafe fn trackingNumber(self) -> NSInteger { + msg_send![self, trackingNumber] + } + + unsafe fn trackingArea(self) -> id /* (NSTrackingArea *) */ { + msg_send![self, trackingArea] + } + + unsafe fn userData(self) -> *const c_void { + msg_send![self, userData] + } + + // Getting Custom Event Information + + unsafe fn data1(self) -> NSInteger { + msg_send![self, data1] + } + + unsafe fn data2(self) -> NSInteger { + msg_send![self, data2] + } + + unsafe fn subtype(self) -> NSEventSubtype { + msg_send![self, subtype] + } + + // Getting Scroll Wheel Event Information + + unsafe fn deltaX(self) -> CGFloat { + msg_send![self, deltaX] + } + + unsafe fn deltaY(self) -> CGFloat { + msg_send![self, deltaY] + } + + unsafe fn deltaZ(self) -> CGFloat { + msg_send![self, deltaZ] + } + + // Getting Tablet Proximity Information + + unsafe fn capabilityMask(self) -> NSUInteger { + msg_send![self, capabilityMask] + } + + unsafe fn deviceID(self) -> NSUInteger { + msg_send![self, deviceID] + } + + unsafe fn pointingDeviceID(self) -> NSUInteger { + msg_send![self, pointingDeviceID] + } + + unsafe fn pointingDeviceSerialNumber(self) -> NSUInteger { + msg_send![self, pointingDeviceSerialNumber] + } + + unsafe fn pointingDeviceType(self) -> NSPointingDeviceType { + msg_send![self, pointingDeviceType] + } + + unsafe fn systemTabletID(self) -> NSUInteger { + msg_send![self, systemTabletID] + } + + unsafe fn tabletID(self) -> NSUInteger { + msg_send![self, tabletID] + } + + unsafe fn uniqueID(self) -> libc::c_ulonglong { + msg_send![self, uniqueID] + } + + unsafe fn vendorID(self) -> NSUInteger { + msg_send![self, vendorID] + } + + unsafe fn vendorPointingDeviceType(self) -> NSUInteger { + msg_send![self, vendorPointingDeviceType] + } + + // Getting Tablet Pointing Information + + unsafe fn absoluteX(self) -> NSInteger { + msg_send![self, absoluteX] + } + + unsafe fn absoluteY(self) -> NSInteger { + msg_send![self, absoluteY] + } + + unsafe fn absoluteZ(self) -> NSInteger { + msg_send![self, absoluteZ] + } + + unsafe fn buttonMask(self) -> NSEventButtonMask { + msg_send![self, buttonMask] + } + + unsafe fn rotation(self) -> libc::c_float { + msg_send![self, rotation] + } + + unsafe fn tangentialPressure(self) -> libc::c_float { + msg_send![self, tangentialPressure] + } + + unsafe fn tilt(self) -> NSPoint { + msg_send![self, tilt] + } + + unsafe fn vendorDefined(self) -> id { + msg_send![self, vendorDefined] + } + + // Requesting and Stopping Periodic Events + + unsafe fn startPeriodicEventsAfterDelay_withPeriod_(_: Self, delaySeconds: NSTimeInterval, periodSeconds: NSTimeInterval) { + msg_send![class!(NSEvent), startPeriodicEventsAfterDelay:delaySeconds withPeriod:periodSeconds] + } + + unsafe fn stopPeriodicEvents(_: Self) { + msg_send![class!(NSEvent), stopPeriodicEvents] + } + + // Getting Touch and Gesture Information + + unsafe fn magnification(self) -> CGFloat { + msg_send![self, magnification] + } + + unsafe fn touchesMatchingPhase_inView_(self, phase: NSTouchPhase, view: id /* (NSView *) */) -> id /* (NSSet *) */ { + msg_send![self, touchesMatchingPhase:phase inView:view] + } + + unsafe fn isSwipeTrackingFromScrollEventsEnabled(_: Self) -> BOOL { + msg_send![class!(NSEvent), isSwipeTrackingFromScrollEventsEnabled] + } + + // Monitoring Application Events + + // TODO: addGlobalMonitorForEventsMatchingMask_handler_ (unsure how to bind to blocks) + // TODO: addLocalMonitorForEventsMatchingMask_handler_ (unsure how to bind to blocks) + + unsafe fn removeMonitor_(_: Self, eventMonitor: id) { + msg_send![class!(NSEvent), removeMonitor:eventMonitor] + } + + // Scroll Wheel and Flick Events + + unsafe fn hasPreciseScrollingDeltas(self) -> BOOL { + msg_send![self, hasPreciseScrollingDeltas] + } + + unsafe fn scrollingDeltaX(self) -> CGFloat { + msg_send![self, scrollingDeltaX] + } + + unsafe fn scrollingDeltaY(self) -> CGFloat { + msg_send![self, scrollingDeltaY] + } + + unsafe fn momentumPhase(self) -> NSEventPhase { + msg_send![self, momentumPhase] + } + + unsafe fn phase(self) -> NSEventPhase { + msg_send![self, phase] + } + + // TODO: trackSwipeEventWithOptions_dampenAmountThresholdMin_max_usingHandler_ (unsure how to bind to blocks) + + // Converting a Mouse Event’s Position into a Sprite Kit Node’s Coordinate Space + unsafe fn locationInNode_(self, node: id /* (SKNode *) */) -> CGPoint { + msg_send![self, locationInNode:node] + } +} + +pub trait NSScreen: Sized { + // Getting NSScreen Objects + unsafe fn mainScreen(_: Self) -> id /* (NSScreen *) */; + unsafe fn deepestScreen(_: Self) -> id /* (NSScreen *) */; + unsafe fn screens(_: Self) -> id /* (NSArray *) */; + + // Getting Screen Information + unsafe fn depth(self) -> NSWindowDepth; + unsafe fn frame(self) -> NSRect; + unsafe fn supportedWindowDepths(self) -> *const NSWindowDepth; + unsafe fn deviceDescription(self) -> id /* (NSDictionary *) */; + unsafe fn visibleFrame(self) -> NSRect; + unsafe fn colorSpace(self) -> id /* (NSColorSpace *) */; + unsafe fn screensHaveSeparateSpaces(_: Self) -> BOOL; + + // Screen Backing Coordinate Conversion + unsafe fn backingAlignedRect_options_(self, aRect: NSRect, options: NSAlignmentOptions) -> NSRect; + unsafe fn backingScaleFactor(self) -> CGFloat; + unsafe fn convertRectFromBacking_(self, aRect: NSRect) -> NSRect; + unsafe fn convertRectToBacking_(self, aRect: NSRect) -> NSRect; +} + +impl NSScreen for id { + // Getting NSScreen Objects + + unsafe fn mainScreen(_: Self) -> id /* (NSScreen *) */ { + msg_send![class!(NSScreen), mainScreen] + } + + unsafe fn deepestScreen(_: Self) -> id /* (NSScreen *) */ { + msg_send![class!(NSScreen), deepestScreen] + } + + unsafe fn screens(_: Self) -> id /* (NSArray *) */ { + msg_send![class!(NSScreen), screens] + } + + // Getting Screen Information + + unsafe fn depth(self) -> NSWindowDepth { + msg_send![self, depth] + } + + unsafe fn frame(self) -> NSRect { + msg_send![self, frame] + } + + unsafe fn supportedWindowDepths(self) -> *const NSWindowDepth { + msg_send![self, supportedWindowDepths] + } + + unsafe fn deviceDescription(self) -> id /* (NSDictionary *) */ { + msg_send![self, deviceDescription] + } + + unsafe fn visibleFrame(self) -> NSRect { + msg_send![self, visibleFrame] + } + + unsafe fn colorSpace(self) -> id /* (NSColorSpace *) */ { + msg_send![self, colorSpace] + } + + unsafe fn screensHaveSeparateSpaces(_: Self) -> BOOL { + msg_send![class!(NSScreen), screensHaveSeparateSpaces] + } + + // Screen Backing Coordinate Conversion + + unsafe fn backingAlignedRect_options_(self, aRect: NSRect, options: NSAlignmentOptions) -> NSRect { + msg_send![self, backingAlignedRect:aRect options:options] + } + + unsafe fn backingScaleFactor(self) -> CGFloat { + msg_send![self, backingScaleFactor] + } + + unsafe fn convertRectFromBacking_(self, aRect: NSRect) -> NSRect { + msg_send![self, convertRectFromBacking:aRect] + } + + unsafe fn convertRectToBacking_(self, aRect: NSRect) -> NSRect { + msg_send![self, convertRectToBacking:aRect] + } +} + +pub trait NSButton: Sized { + unsafe fn setImage_(self, img: id /* (NSImage *) */); + unsafe fn setBezelStyle_(self, style: NSBezelStyle); + unsafe fn setTitle_(self, title: id /* (NSString*) */); + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSButton), alloc] + } + unsafe fn initWithFrame_(self, frameRect: NSRect) -> id; +} + +impl NSButton for id { + unsafe fn initWithFrame_(self, frameRect: NSRect) -> id { + msg_send![self, initWithFrame:frameRect] + } + unsafe fn setBezelStyle_(self, style: NSBezelStyle) { + msg_send![self, setBezelStyle:style] + } + unsafe fn setTitle_(self, title: id /* (NSString*) */) { + msg_send![self, setTitle:title] + } + unsafe fn setImage_(self, img: id /* (NSImage *) */) { + msg_send![self, setImage:img] + } +} + +pub trait NSImage: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSImage), alloc] + } + + unsafe fn initByReferencingFile_(self, file_name: id /* (NSString *) */) -> id; + unsafe fn initWithContentsOfFile_(self, file_name: id /* (NSString *) */) -> id; + unsafe fn initWithData_(self, data: id /* (NSData *) */) -> id; + unsafe fn initWithDataIgnoringOrientation_(self, data: id /* (NSData *) */) -> id; + unsafe fn initWithPasteboard_(self, pasteboard: id /* (NSPasteboard *) */) -> id; + unsafe fn initWithSize_flipped_drawingHandler_(self, size: NSSize, + drawingHandlerShouldBeCalledWithFlippedContext: BOOL, + drawingHandler: *mut Block<(NSRect,), BOOL>); + unsafe fn initWithSize_(self, aSize: NSSize) -> id; + + unsafe fn imageNamed_(_: Self, name: id /* (NSString *) */) -> id { + msg_send![class!(NSImage), imageNamed:name] + } + + unsafe fn name(self) -> id /* (NSString *) */; + unsafe fn setName_(self, name: id /* (NSString *) */) -> BOOL; + + unsafe fn size(self) -> NSSize; + unsafe fn template(self) -> BOOL; + + unsafe fn canInitWithPasteboard_(self, pasteboard: id /* (NSPasteboard *) */) -> BOOL; + unsafe fn imageTypes(self) -> id /* (NSArray ) */; + unsafe fn imageUnfilteredTypes(self) -> id /* (NSArray ) */; + + unsafe fn addRepresentation_(self, imageRep: id /* (NSImageRep *) */); + unsafe fn addRepresentations_(self, imageReps: id /* (NSArray *) */); + unsafe fn representations(self) -> id /* (NSArray *) */; + unsafe fn removeRepresentation_(self, imageRep: id /* (NSImageRep *) */); + unsafe fn bestRepresentationForRect_context_hints_(self, rect: NSRect, + referenceContext: id /* (NSGraphicsContext *) */, + hints: id /* (NSDictionary *) */) + -> id /* (NSImageRep *) */; + unsafe fn prefersColorMatch(self) -> BOOL; + unsafe fn usesEPSOnResolutionMismatch(self) -> BOOL; + unsafe fn matchesOnMultipleResolution(self) -> BOOL; + + unsafe fn drawInRect_(self, rect: NSRect); + unsafe fn drawAtPoint_fromRect_operation_fraction_(self, point: NSPoint, srcRect: NSRect, + op: NSCompositingOperation, delta: CGFloat); + unsafe fn drawInRect_fromRect_operation_fraction_(self, dstRect: NSRect, srcRect: NSRect, + op: NSCompositingOperation, delta: CGFloat); + unsafe fn drawInRect_fromRect_operation_fraction_respectFlipped_hints_(self, dstSpacePortionRect: NSRect, + srcSpacePortionRect: NSRect, op: NSCompositingOperation, delta: CGFloat, respectContextIsFlipped: BOOL, + hints: id /* (NSDictionary *) */); + unsafe fn drawRepresentation_inRect_(self, imageRep: id /* (NSImageRep *) */, dstRect: NSRect); + + unsafe fn isValid(self) -> BOOL; + unsafe fn backgroundColor(self) -> id /* (NSColor *) */; + + unsafe fn lockFocus(self); + unsafe fn lockFocusFlipped_(self, flipped: BOOL); + unsafe fn unlockFocus(self); + + unsafe fn alignmentRect(self) -> NSRect; + + unsafe fn cacheMode(self) -> NSImageCacheMode; + unsafe fn recache(self); + + unsafe fn delegate(self) -> id /* (id *) */; + + unsafe fn TIFFRepresentation(self) -> id /* (NSData *) */; + unsafe fn TIFFRepresentationUsingCompression_factor_(self, comp: NSTIFFCompression, aFloat: f32) + -> id /* (NSData *) */; + + unsafe fn cancelIncrementalLoad(self); + + unsafe fn hitTestRect_withImageDestinationRect_context_hints_flipped_(self, testRectDestSpace: NSRect, + imageRectDestSpace: NSRect, referenceContext: id /* (NSGraphicsContext *) */, + hints: id /* (NSDictionary *) */, flipped: BOOL) -> BOOL; + + unsafe fn accessibilityDescription(self) -> id /* (NSString *) */; + + unsafe fn layerContentsForContentsScale_(self, layerContentsScale: CGFloat) -> id /* (id) */; + unsafe fn recommendedLayerContentsScale_(self, preferredContentsScale: CGFloat) -> CGFloat; + + unsafe fn matchesOnlyOnBestFittingAxis(self) -> BOOL; +} + +impl NSImage for id { + unsafe fn initByReferencingFile_(self, file_name: id /* (NSString *) */) -> id { + msg_send![self, initByReferencingFile:file_name] + } + + unsafe fn initWithContentsOfFile_(self, file_name: id /* (NSString *) */) -> id { + msg_send![self, initWithContentsOfFile:file_name] + } + + unsafe fn initWithData_(self, data: id /* (NSData *) */) -> id { + msg_send![self, initWithData:data] + } + + unsafe fn initWithDataIgnoringOrientation_(self, data: id /* (NSData *) */) -> id { + msg_send![self, initWithDataIgnoringOrientation:data] + } + + unsafe fn initWithPasteboard_(self, pasteboard: id /* (NSPasteboard *) */) -> id { + msg_send![self, initWithPasteboard:pasteboard] + } + + unsafe fn initWithSize_flipped_drawingHandler_(self, size: NSSize, + drawingHandlerShouldBeCalledWithFlippedContext: BOOL, + drawingHandler: *mut Block<(NSRect,), BOOL>) { + msg_send![self, initWithSize:size + flipped:drawingHandlerShouldBeCalledWithFlippedContext + drawingHandler:drawingHandler] + } + + unsafe fn initWithSize_(self, aSize: NSSize) -> id { + msg_send![self, initWithSize:aSize] + } + + unsafe fn name(self) -> id /* (NSString *) */ { + msg_send![self, name] + } + + unsafe fn setName_(self, name: id /* (NSString *) */) -> BOOL { + msg_send![self, setName:name] + } + + unsafe fn size(self) -> NSSize { + msg_send![self, size] + } + + unsafe fn template(self) -> BOOL { + msg_send![self, template] + } + + unsafe fn canInitWithPasteboard_(self, pasteboard: id /* (NSPasteboard *) */) -> BOOL { + msg_send![self, canInitWithPasteboard:pasteboard] + } + + unsafe fn imageTypes(self) -> id /* (NSArray ) */ { + msg_send![self, imageTypes] + } + + unsafe fn imageUnfilteredTypes(self) -> id /* (NSArray ) */ { + msg_send![self, imageUnfilteredTypes] + } + + unsafe fn addRepresentation_(self, imageRep: id /* (NSImageRep *) */) { + msg_send![self, addRepresentation:imageRep] + } + + unsafe fn addRepresentations_(self, imageReps: id /* (NSArray *) */) { + msg_send![self, addRepresentations:imageReps] + } + + unsafe fn representations(self) -> id /* (NSArray *) */ { + msg_send![self, representations] + } + + unsafe fn removeRepresentation_(self, imageRep: id /* (NSImageRep *) */) { + msg_send![self, removeRepresentation:imageRep] + } + + unsafe fn bestRepresentationForRect_context_hints_(self, rect: NSRect, + referenceContext: id /* (NSGraphicsContext *) */, + hints: id /* (NSDictionary *) */) + -> id /* (NSImageRep *) */ { + msg_send![self, bestRepresentationForRect:rect context:referenceContext hints:hints] + } + + unsafe fn prefersColorMatch(self) -> BOOL { + msg_send![self, prefersColorMatch] + } + + unsafe fn usesEPSOnResolutionMismatch(self) -> BOOL { + msg_send![self, usesEPSOnResolutionMismatch] + } + + unsafe fn matchesOnMultipleResolution(self) -> BOOL { + msg_send![self, matchesOnMultipleResolution] + } + + unsafe fn drawInRect_(self, rect: NSRect) { + msg_send![self, drawInRect:rect] + } + + unsafe fn drawAtPoint_fromRect_operation_fraction_(self, point: NSPoint, srcRect: NSRect, + op: NSCompositingOperation, delta: CGFloat) { + msg_send![self, drawAtPoint:point fromRect:srcRect operation:op fraction:delta] + } + + unsafe fn drawInRect_fromRect_operation_fraction_(self, dstRect: NSRect, srcRect: NSRect, + op: NSCompositingOperation, delta: CGFloat) { + msg_send![self, drawInRect:dstRect fromRect:srcRect operation:op fraction:delta] + } + + unsafe fn drawInRect_fromRect_operation_fraction_respectFlipped_hints_(self, dstSpacePortionRect: NSRect, + srcSpacePortionRect: NSRect, op: NSCompositingOperation, delta: CGFloat, respectContextIsFlipped: BOOL, + hints: id /* (NSDictionary *) */) { + msg_send![self, drawInRect:dstSpacePortionRect + fromRect:srcSpacePortionRect + operation:op + fraction:delta + respectFlipped:respectContextIsFlipped + hints:hints] + } + + unsafe fn drawRepresentation_inRect_(self, imageRep: id /* (NSImageRep *) */, dstRect: NSRect) { + msg_send![self, drawRepresentation:imageRep inRect:dstRect] + } + + unsafe fn isValid(self) -> BOOL { + msg_send![self, isValid] + } + + unsafe fn backgroundColor(self) -> id /* (NSColor *) */ { + msg_send![self, backgroundColor] + } + + unsafe fn lockFocus(self) { + msg_send![self, lockFocus] + } + + unsafe fn lockFocusFlipped_(self, flipped: BOOL) { + msg_send![self, lockFocusFlipped:flipped] + } + + unsafe fn unlockFocus(self) { + msg_send![self, unlockFocus] + } + + unsafe fn alignmentRect(self) -> NSRect { + msg_send![self, alignmentRect] + } + + unsafe fn cacheMode(self) -> NSImageCacheMode { + msg_send![self, cacheMode] + } + + unsafe fn recache(self) { + msg_send![self, recache] + } + + unsafe fn delegate(self) -> id /* (id *) */ { + msg_send![self, delegate] + } + + unsafe fn TIFFRepresentation(self) -> id /* (NSData *) */ { + msg_send![self, TIFFRepresentation] + } + + unsafe fn TIFFRepresentationUsingCompression_factor_(self, comp: NSTIFFCompression, aFloat: f32) + -> id /* (NSData *) */ { + msg_send![self, TIFFRepresentationUsingCompression:comp factor:aFloat] + } + + unsafe fn cancelIncrementalLoad(self) { + msg_send![self, cancelIncrementalLoad] + } + + unsafe fn hitTestRect_withImageDestinationRect_context_hints_flipped_(self, testRectDestSpace: NSRect, + imageRectDestSpace: NSRect, referenceContext: id /* (NSGraphicsContext *) */, + hints: id /* (NSDictionary *) */, flipped: BOOL) -> BOOL { + msg_send![self, hitTestRect:testRectDestSpace + withImageDestinationRect:imageRectDestSpace + context:referenceContext + hints:hints + flipped:flipped] + } + + unsafe fn accessibilityDescription(self) -> id /* (NSString *) */ { + msg_send![self, accessibilityDescription] + } + + unsafe fn layerContentsForContentsScale_(self, layerContentsScale: CGFloat) -> id /* (id) */ { + msg_send![self, layerContentsForContentsScale:layerContentsScale] + } + + unsafe fn recommendedLayerContentsScale_(self, preferredContentsScale: CGFloat) -> CGFloat { + msg_send![self, recommendedLayerContentsScale:preferredContentsScale] + } + + unsafe fn matchesOnlyOnBestFittingAxis(self) -> BOOL { + msg_send![self, matchesOnlyOnBestFittingAxis] + } +} + +#[link(name = "AppKit", kind = "framework")] +extern { + // Image hints (NSString* const) + pub static NSImageHintCTM: id; + pub static NSImageHintInterpolation: id; + + // System image names (NSString const*) + pub static NSImageNameQuickLookTemplate: id; + pub static NSImageNameBluetoothTemplate: id; + pub static NSImageNameIChatTheaterTemplate: id; + pub static NSImageNameSlideshowTemplate: id; + pub static NSImageNameActionTemplate: id; + pub static NSImageNameSmartBadgeTemplate: id; + pub static NSImageNamePathTemplate: id; + pub static NSImageNameInvalidDataFreestandingTemplate: id; + pub static NSImageNameLockLockedTemplate: id; + pub static NSImageNameLockUnlockedTemplate: id; + pub static NSImageNameGoRightTemplate: id; + pub static NSImageNameGoLeftTemplate: id; + pub static NSImageNameRightFacingTriangleTemplate: id; + pub static NSImageNameLeftFacingTriangleTemplate: id; + pub static NSImageNameAddTemplate: id; + pub static NSImageNameRemoveTemplate: id; + pub static NSImageNameRevealFreestandingTemplate: id; + pub static NSImageNameFollowLinkFreestandingTemplate: id; + pub static NSImageNameEnterFullScreenTemplate: id; + pub static NSImageNameExitFullScreenTemplate: id; + pub static NSImageNameStopProgressTemplate: id; + pub static NSImageNameStopProgressFreestandingTemplate: id; + pub static NSImageNameRefreshTemplate: id; + pub static NSImageNameRefreshFreestandingTemplate: id; + + pub static NSImageNameMultipleDocuments: id; + + pub static NSImageNameUser: id; + pub static NSImageNameUserGroup: id; + pub static NSImageNameEveryone: id; + pub static NSImageNameUserGuest: id; + + pub static NSImageNameBonjour: id; + pub static NSImageNameDotMac: id; + pub static NSImageNameComputer: id; + pub static NSImageNameFolderBurnable: id; + pub static NSImageNameFolderSmart: id; + pub static NSImageNameNetwork: id; + + pub static NSImageNameUserAccounts: id; + pub static NSImageNamePreferencesGeneral: id; + pub static NSImageNameAdvanced: id; + pub static NSImageNameInfo: id; + pub static NSImageNameFontPanel: id; + pub static NSImageNameColorPanel: id; + pub static NSImageNameFolder: id; + pub static NSImageNameTrashEmpty: id; + pub static NSImageNameTrashFull: id; + pub static NSImageNameHomeTemplate: id; + pub static NSImageNameBookmarksTemplate: id; + pub static NSImageNameCaution: id; + pub static NSImageNameStatusAvailable: id; + pub static NSImageNameStatusPartiallyAvailable: id; + pub static NSImageNameStatusUnavailable: id; + pub static NSImageNameStatusNone: id; + pub static NSImageNameApplicationIcon: id; + pub static NSImageNameMenuOnStateTemplate: id; + pub static NSImageNameMenuMixedStateTemplate: id; + pub static NSImageNameMobileMe: id; + + pub static NSImageNameIconViewTemplate: id; + pub static NSImageNameListViewTemplate: id; + pub static NSImageNameColumnViewTemplate: id; + pub static NSImageNameFlowViewTemplate: id; + pub static NSImageNameShareTemplate: id; +} + +#[repr(usize)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum NSCompositingOperation { + NSCompositeClear = 0, + NSCompositeCopy = 1, + NSCompositeSourceOver = 2, + NSCompositeSourceIn = 3, + NSCompositeSourceOut = 4, + NSCompositeSourceAtop = 5, + NSCompositeDestinationOver = 6, + NSCompositeDestinationIn = 7, + NSCompositeDestinationOut = 8, + NSCompositeDestinationAtop = 9, + NSCompositeXOR = 10, + NSCompositePlusDarker = 11, + NSCompositeHighlight = 12, + NSCompositePlusLighter = 13 +} + +#[repr(usize)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum NSImageCacheMode { + NSImageCacheDefault, + NSImageCacheAlways, + NSImageCacheBySize, + NSImageCacheNever +} + +#[repr(usize)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum NSTIFFCompression { + NSTIFFCompressionNone = 1, + NSTIFFCompressionCCITTFAX3 = 3, + NSTIFFCompressionCCITTFAX4 = 4, + NSTIFFCompressionLZW = 5, + NSTIFFCompressionJPEG = 6, + NSTIFFCompressionNEXT = 32766, + NSTIFFCompressionPackBits = 32773, + NSTIFFCompressionOldJPEG = 32865 +} + +#[repr(usize)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum NSImageLoadStatus { + NSImageLoadStatusCompleted, + NSImageLoadStatusCancelled, + NSImageLoadStatusInvalidData, + NSImageLoadStatusUnexpectedEOF, + NSImageLoadStatusReadError +} + +pub trait NSSound: Sized { + unsafe fn canInitWithPasteboard_(_: Self, pasteboard: id) -> BOOL { + msg_send![class!(NSSound), canInitWithPasteboard:pasteboard] + } + + unsafe fn initWithContentsOfFile_withReference_(self, filepath: id, byRef: BOOL) -> id; + unsafe fn initWithContentsOfURL_withReference_(self, fileUrl: id, byRef: BOOL) -> id; + unsafe fn initWithData_(self, audioData: id) -> id; + unsafe fn initWithPasteboard_(self, pasteboard: id) -> id; + + unsafe fn name(self) -> id; + unsafe fn volume(self) -> f32; + unsafe fn currentTime(self) -> NSTimeInterval; + unsafe fn loops(self) -> BOOL; + unsafe fn playbackDeviceIdentifier(self) -> id; + unsafe fn delegate(self) -> id; + + unsafe fn soundUnfilteredTypes(_: Self) -> id { + msg_send![class!(NSSound), soundUnfilteredTypes] + } + + unsafe fn soundNamed_(_: Self, soundName: id) -> id { + msg_send![class!(NSSound), soundNamed:soundName] + } + + unsafe fn duration(self) -> NSTimeInterval; + + unsafe fn playing(self) -> BOOL; + unsafe fn pause(self) -> BOOL; + unsafe fn play(self) -> BOOL; + unsafe fn resume(self) -> BOOL; + unsafe fn stop(self) -> BOOL; + + unsafe fn writeToPasteboard_(self, pasteboard: id); +} + +impl NSSound for id { + unsafe fn initWithContentsOfFile_withReference_(self, filepath: id, byRef: BOOL) -> id { + msg_send![self, initWithContentsOfFile:filepath withReference:byRef] + } + + unsafe fn initWithContentsOfURL_withReference_(self, fileUrl: id, byRef: BOOL) -> id { + msg_send![self, initWithContentsOfURL:fileUrl withReference:byRef] + } + + unsafe fn initWithData_(self, audioData: id) -> id { + msg_send![self, initWithData:audioData] + } + + unsafe fn initWithPasteboard_(self, pasteboard: id) -> id { + msg_send![self, initWithPasteboard:pasteboard] + } + + unsafe fn name(self) -> id { + msg_send![self, name] + } + + unsafe fn volume(self) -> f32 { + msg_send![self, volume] + } + + unsafe fn currentTime(self) -> NSTimeInterval { + msg_send![self, currentTime] + } + + unsafe fn loops(self) -> BOOL { + msg_send![self, loops] + } + + unsafe fn playbackDeviceIdentifier(self) -> id { + msg_send![self, playbackDeviceIdentifier] + } + + unsafe fn delegate(self) -> id { + msg_send![self, delegate] + } + + unsafe fn duration(self) -> NSTimeInterval { + msg_send![self, duration] + } + + unsafe fn playing(self) -> BOOL { + msg_send![self, playing] + } + + unsafe fn pause(self) -> BOOL { + msg_send![self, pause] + } + + unsafe fn play(self) -> BOOL { + msg_send![self, play] + } + + unsafe fn resume(self) -> BOOL { + msg_send![self, resume] + } + + unsafe fn stop(self) -> BOOL { + msg_send![self, stop] + } + + unsafe fn writeToPasteboard_(self, pasteboard: id) { + msg_send![self, writeToPasteboard:pasteboard] + } +} + +pub const NSVariableStatusItemLength: CGFloat = -1.0; +pub const NSSquareStatusItemLength: CGFloat = -2.0; + +pub trait NSStatusItem: Sized { + unsafe fn statusBar(self) -> id /* (NSStatusBar *) */; + unsafe fn button(self) -> id /* (NSStatusBarButton *) */; + unsafe fn menu(self) -> id; + unsafe fn setMenu_(self, menu: id); + unsafe fn length(self) -> CGFloat; + unsafe fn setLength_(self, length: CGFloat); +} + +impl NSStatusItem for id { + unsafe fn statusBar(self) -> id /* (NSStatusBar *) */ { + msg_send![self, statusBar] + } + + unsafe fn button(self) -> id /* (NSStatusBarButton *) */ { + msg_send![self, button] + } + + unsafe fn menu(self) -> id { + msg_send![self, menu] + } + + unsafe fn setMenu_(self, menu: id) { + msg_send![self, setMenu:menu] + } + + unsafe fn length(self) -> CGFloat { + msg_send![self, length] + } + + unsafe fn setLength_(self, length: CGFloat) { + msg_send![self, setLength: length] + } +} + +pub trait NSStatusBar: Sized { + unsafe fn systemStatusBar(_: Self) -> id { + msg_send![class!(NSStatusBar), systemStatusBar] + } + + unsafe fn statusItemWithLength_(self, length: CGFloat) -> id /* (NSStatusItem *) */; + unsafe fn removeStatusItem_(self, item: id /* (NSStatusItem *) */); + unsafe fn isVertical(self) -> BOOL; +} + +impl NSStatusBar for id { + unsafe fn statusItemWithLength_(self, length: CGFloat) -> id /* (NSStatusItem *) */ { + msg_send![self, statusItemWithLength:length] + } + + unsafe fn removeStatusItem_(self, item: id /* (NSStatusItem *) */) { + msg_send![self, removeStatusItem:item] + } + + unsafe fn isVertical(self) -> BOOL { + msg_send![self, isVertical] + } +} + +extern { + pub fn NSRectFill(rect: NSRect); +} + +pub trait NSTextField: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSTextField), alloc] + } + unsafe fn initWithFrame_(self, frameRect: NSRect) -> id; + unsafe fn setEditable_(self, editable: BOOL); + unsafe fn setStringValue_(self, label: id /* NSString */); +} + +impl NSTextField for id { + unsafe fn initWithFrame_(self, frameRect: NSRect) -> id { + msg_send![self, initWithFrame:frameRect] + } + unsafe fn setEditable_(self, editable: BOOL) { + msg_send![self, setEditable:editable] + } + unsafe fn setStringValue_(self, label: id) { + msg_send![self, setStringValue:label] + } +} + +#[repr(u64)] +pub enum NSTabViewType { + NSTopTabsBezelBorder = 0, + NSLeftTabsBezelBorder = 1, + NSBottomTabsBezelBorder = 2, + NSRightTabsBezelBorder = 3, + NSNoTabsBezelBorder = 4, + NSNoTabsLineBorder = 5, + NSNoTabsNoBorder = 6 +} + +pub trait NSTabView: Sized { + unsafe fn new(_: Self) -> id { + msg_send![class!(NSTabView), new] + } + + unsafe fn initWithFrame_(self, frameRect: NSRect) -> id; + unsafe fn addTabViewItem_(self, tabViewItem: id); + unsafe fn insertTabViewItem_atIndex_(self,tabViewItem:id, index:NSInteger); + unsafe fn removeTabViewItem_(self,tabViewItem:id); + unsafe fn indexOfTabViewItem_(self, tabViewItem:id) -> id; + unsafe fn indexOfTabViewItemWithIdentifier_(self,identifier:id) -> id; + unsafe fn numberOfTabViewItems(self) -> id; + unsafe fn tabViewItemAtIndex_(self,index:id) -> id; + unsafe fn tabViewItems(self) -> id; + unsafe fn selectFirstTabViewItem_(self,sender:id); + unsafe fn selectLastTabViewItem_(self,sender:id); + unsafe fn selectNextTabViewItem_(self, sender:id); + unsafe fn selectPreviousTabViewItem_(self,sender:id); + unsafe fn selectTabViewItem_(self,tabViewItem:id); + unsafe fn selectTabViewItemAtIndex_(self,index:id); + unsafe fn selectTabViewItemWithIdentifier_(self,identifier:id); + unsafe fn selectedTabViewItem(self) -> id; + unsafe fn takeSelectedTabViewItemFromSender_(self,sender:id); + unsafe fn font(self) -> id; + unsafe fn setFont_(self, font:id); + unsafe fn tabViewType(self) -> NSTabViewType; + unsafe fn setTabViewType_(self,tabViewType: NSTabViewType); + unsafe fn controlTint(self) -> id; + unsafe fn setControlTint_(self,controlTint:id); + unsafe fn drawsBackground(self) -> BOOL; + unsafe fn setDrawsBackground_(self,drawsBackground:BOOL); + unsafe fn minimumSize(self) -> id; + unsafe fn contentRect(self) -> id; + unsafe fn controlSize(self) -> id; + unsafe fn setControlSize_(self,controlSize:id); + unsafe fn allowsTruncatedLabels(self) -> BOOL; + unsafe fn setAllowsTruncatedLabels_(self, allowTruncatedLabels:BOOL); + unsafe fn setDelegate_(self, delegate:id); + unsafe fn delegate(self) -> id ; + unsafe fn tabViewAtPoint_(self, point:id) -> id; +} + +impl NSTabView for id { + unsafe fn initWithFrame_(self, frameRect: NSRect) -> id { + msg_send![self, initWithFrame:frameRect] + } + + unsafe fn addTabViewItem_(self, tabViewItem: id) { + msg_send![self, addTabViewItem:tabViewItem] + } + unsafe fn insertTabViewItem_atIndex_(self, tabViewItem: id,index:NSInteger) { + msg_send![self, addTabViewItem:tabViewItem atIndex:index] + } + unsafe fn removeTabViewItem_(self,tabViewItem:id){ + msg_send![self, removeTabViewItem:tabViewItem] + } + + unsafe fn indexOfTabViewItem_(self, tabViewItem:id) -> id{ + msg_send![self, indexOfTabViewItem:tabViewItem] + } + + unsafe fn indexOfTabViewItemWithIdentifier_(self,identifier:id) -> id{ + msg_send![self, indexOfTabViewItemWithIdentifier:identifier] + } + unsafe fn numberOfTabViewItems(self) -> id{ + msg_send![self, numberOfTabViewItems] + } + + unsafe fn tabViewItemAtIndex_(self,index:id)->id{ + msg_send![self, tabViewItemAtIndex:index] + } + + unsafe fn tabViewItems(self)->id{ + msg_send![self, tabViewItems] + } + + unsafe fn selectFirstTabViewItem_(self,sender:id){ + msg_send![self, selectFirstTabViewItem:sender] + } + + unsafe fn selectLastTabViewItem_(self,sender:id){ + msg_send![self, selectLastTabViewItem:sender] + } + unsafe fn selectNextTabViewItem_(self, sender:id){ + msg_send![self, selectNextTabViewItem:sender] + } + unsafe fn selectPreviousTabViewItem_(self,sender:id){ + msg_send![self, selectPreviousTabViewItem:sender] + } + + unsafe fn selectTabViewItem_(self,tabViewItem:id){ + msg_send![self, selectTabViewItem:tabViewItem] + } + + unsafe fn selectTabViewItemAtIndex_(self,index:id){ + msg_send![self, selectTabViewItemAtIndex:index] + } + unsafe fn selectTabViewItemWithIdentifier_(self,identifier:id){ + msg_send![self, selectTabViewItemWithIdentifier:identifier] + } + unsafe fn selectedTabViewItem(self) -> id{ + msg_send![self, selectedTabViewItem] + } + unsafe fn takeSelectedTabViewItemFromSender_(self,sender:id){ + msg_send![self, takeSelectedTabViewItemFromSender:sender] + } + + unsafe fn font(self)->id{ + msg_send![self, font] + } + + unsafe fn setFont_(self, font:id){ + msg_send![self, setFont:font] + } + + unsafe fn tabViewType(self)->NSTabViewType{ + msg_send![self, tabViewType] + } + unsafe fn setTabViewType_(self,tabViewType: NSTabViewType){ + msg_send![self, setTabViewType:tabViewType] + } + + unsafe fn controlTint(self) -> id{ + msg_send![self, controlTint] + } + unsafe fn setControlTint_(self,controlTint:id){ + msg_send![self, setControlTint:controlTint] + } + + unsafe fn drawsBackground(self) -> BOOL{ + msg_send![self, drawsBackground] + } + unsafe fn setDrawsBackground_(self,drawsBackground:BOOL){ + msg_send![self, setDrawsBackground:drawsBackground as libc::c_int] + } + + unsafe fn minimumSize(self) -> id{ + msg_send![self, minimumSize] + } + unsafe fn contentRect(self) -> id{ + msg_send![self, contentRect] + } + unsafe fn controlSize(self) -> id{ + msg_send![self, controlSize] + } + unsafe fn setControlSize_(self,controlSize:id){ + msg_send![self, setControlSize:controlSize] + } + + unsafe fn allowsTruncatedLabels(self) -> BOOL{ + msg_send![self, allowsTruncatedLabels] + } + unsafe fn setAllowsTruncatedLabels_(self, allowTruncatedLabels:BOOL){ + msg_send![self, setAllowsTruncatedLabels:allowTruncatedLabels as libc::c_int] + } + + unsafe fn setDelegate_(self, delegate:id){ + msg_send![self, setDelegate:delegate] + } + unsafe fn delegate(self) -> id { + msg_send![self, delegate] + } + + unsafe fn tabViewAtPoint_(self, point:id) -> id{ + msg_send![self, tabViewAtPoint:point] + } +} + +#[repr(u64)] +pub enum NSTabState { + NSSelectedTab = 0, + NSBackgroundTab = 1, + NSPressedTab = 2 +} + +pub trait NSTabViewItem: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSTabViewItem), alloc] + } + unsafe fn new(_: Self) -> id { + msg_send![class!(NSTabViewItem), new] + } + + unsafe fn initWithIdentifier_(self, identifier:id) -> id; + unsafe fn drawLabel_inRect_(self,shouldTruncateLabel:BOOL,labelRect:NSRect); + unsafe fn label(self) -> id; + unsafe fn setLabel_(self,label:id); + unsafe fn sizeOfLabel_(self, computeMin:BOOL); + unsafe fn tabState(self) -> NSTabState; + unsafe fn identifier(self)-> id; + unsafe fn setIdentifier_(self,identifier:id); + unsafe fn color(self)-> id; + unsafe fn setColor_(self,color:id); + unsafe fn view(self) -> id; + unsafe fn setView_(self, view:id); + unsafe fn initialFirstResponder(self)->id; + unsafe fn setInitialFirstResponder_(self,initialFirstResponder:id); + unsafe fn tabView(self) -> id; + unsafe fn tooltip(self) -> id; + unsafe fn setTooltip_(self,toolTip:id); +} + +impl NSTabViewItem for id { + unsafe fn initWithIdentifier_(self, identifier: id) -> id { + msg_send![self, initWithIdentifier:identifier] + } + + unsafe fn drawLabel_inRect_(self, shouldTruncateLabel:BOOL,labelRect:NSRect){ + msg_send![self, drawLabel:shouldTruncateLabel as libc::c_int inRect:labelRect] + } + + unsafe fn label(self)->id{ + msg_send![self, label] + } + unsafe fn setLabel_(self,label : id){ + msg_send![self, setLabel:label] + } + + unsafe fn sizeOfLabel_(self,computeMin:BOOL){ + msg_send![self, sizeOfLabel:computeMin as libc::c_int] + } + + unsafe fn tabState(self) -> NSTabState{ + msg_send![self, tabState] + } + + unsafe fn identifier(self)-> id { + msg_send![self, identifier] + } + + unsafe fn setIdentifier_(self,identifier:id){ + msg_send![self, identifier:identifier] + } + + unsafe fn color(self)-> id{ + msg_send![self, color] + } + + unsafe fn setColor_(self,color:id){ + msg_send![self, color:color] + } + + unsafe fn view(self) -> id { + msg_send![self, view] + } + + unsafe fn setView_(self, view:id){ + msg_send![self, setView:view] + } + + unsafe fn initialFirstResponder(self)->id{ + msg_send![self, initialFirstResponder] + } + + unsafe fn setInitialFirstResponder_(self,initialFirstResponder:id){ + msg_send![self, setInitialFirstResponder:initialFirstResponder] + } + + unsafe fn tabView(self) -> id{ + msg_send![self, tabView] + } + + unsafe fn tooltip(self) -> id{ + msg_send![self, tooltip] + } + + unsafe fn setTooltip_(self,toolTip:id){ + msg_send![self, setTooltip:toolTip] + } +} + +pub trait NSLayoutConstraint: Sized { + unsafe fn activateConstraints(_: Self, constraints: id) -> id; +} + +impl NSLayoutConstraint for id { + unsafe fn activateConstraints(_: Self, constraints: id) -> id { + msg_send![class!(NSLayoutConstraint), activateConstraints:constraints] + } +} + +pub trait NSLayoutDimension: Sized { + unsafe fn constraintEqualToConstant(self, c: CGFloat) -> id; + unsafe fn constraintLessThanOrEqualToConstant(self, c: CGFloat) -> id; + unsafe fn constraintGreaterThanOrEqualToConstant(self, c: CGFloat) -> id; +} + +impl NSLayoutDimension for id { + unsafe fn constraintEqualToConstant(self, c: CGFloat) -> id { + msg_send![self, constraintEqualToConstant:c] + } + + unsafe fn constraintLessThanOrEqualToConstant(self, c: CGFloat) -> id { + msg_send![self, constraintLessThanOrEqualToConstant:c] + } + + unsafe fn constraintGreaterThanOrEqualToConstant(self, c: CGFloat) -> id { + msg_send![self, constraintGreaterThanOrEqualToConstant:c] + } + } + +pub trait NSColor: Sized { + unsafe fn clearColor(_: Self) -> id; +} + +impl NSColor for id { + unsafe fn clearColor(_: Self) -> id { + msg_send![class!(NSColor), clearColor] + } +} + +pub trait NSToolbar: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSToolbar), alloc] + } + + unsafe fn init_(self) -> id /* NSToolbar */; + unsafe fn initWithIdentifier_(self, identifier: id) -> id /* NSToolbar */; + + unsafe fn showsBaselineSeparator(self) -> BOOL; + unsafe fn setShowsBaselineSeparator_(self, value: BOOL); +} + +impl NSToolbar for id { + unsafe fn init_(self) -> id /* NSToolbar */ { + msg_send![self, init] + } + + unsafe fn initWithIdentifier_(self, identifier: id) -> id /* NSToolbar */ { + msg_send![self, initWithIdentifier:identifier] + } + + unsafe fn showsBaselineSeparator(self) -> BOOL { + msg_send![self, showsBaselineSeparator] + } + + unsafe fn setShowsBaselineSeparator_(self, value: BOOL) { + msg_send![self, setShowsBaselineSeparator:value] + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + pub fn test_nsapp() { + unsafe { + let _nsApp = NSApp(); + } + } +} diff --git a/third_party/cargo/vendor/cocoa-0.18.5/src/base.rs b/third_party/cargo/vendor/cocoa-0.18.5/src/base.rs new file mode 100644 index 0000000..028205e --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/src/base.rs @@ -0,0 +1,28 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use objc::runtime; + +pub use objc::runtime::{BOOL, NO, YES}; + +pub type Class = *mut runtime::Class; +#[allow(non_camel_case_types)] +pub type id = *mut runtime::Object; +pub type SEL = runtime::Sel; + +#[allow(non_upper_case_globals)] +pub const nil: id = 0 as id; +#[allow(non_upper_case_globals)] +pub const Nil: Class = 0 as Class; + +/// A convenience method to convert the name of a selector to the selector object. +#[inline] +pub fn selector(name: &str) -> SEL { + runtime::Sel::register(name) +} diff --git a/third_party/cargo/vendor/cocoa-0.18.5/src/foundation.rs b/third_party/cargo/vendor/cocoa-0.18.5/src/foundation.rs new file mode 100644 index 0000000..b70e0cd --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/src/foundation.rs @@ -0,0 +1,933 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(non_upper_case_globals)] + +use std::ptr; +use std::os::raw::c_void; +use base::{id, BOOL, NO, SEL, nil}; +use block::Block; +use libc; + + +#[cfg(target_pointer_width = "32")] +pub type NSInteger = libc::c_int; +#[cfg(target_pointer_width = "32")] +pub type NSUInteger = libc::c_uint; + +#[cfg(target_pointer_width = "64")] +pub type NSInteger = libc::c_long; +#[cfg(target_pointer_width = "64")] +pub type NSUInteger = libc::c_ulong; + +const UTF8_ENCODING: usize = 4; + +#[cfg(target_os = "macos")] +mod macos { + use std::mem; + use base::id; + use core_graphics::base::CGFloat; + use core_graphics::geometry::CGRect; + use objc; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct NSPoint { + pub x: f64, + pub y: f64, + } + + impl NSPoint { + #[inline] + pub fn new(x: f64, y: f64) -> NSPoint { + NSPoint { + x: x, + y: y, + } + } + } + + unsafe impl objc::Encode for NSPoint { + fn encode() -> objc::Encoding { + let encoding = format!("{{CGPoint={}{}}}", + f64::encode().as_str(), + f64::encode().as_str()); + unsafe { objc::Encoding::from_str(&encoding) } + } + } + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct NSSize { + pub width: f64, + pub height: f64, + } + + impl NSSize { + #[inline] + pub fn new(width: f64, height: f64) -> NSSize { + NSSize { + width: width, + height: height, + } + } + } + + unsafe impl objc::Encode for NSSize { + fn encode() -> objc::Encoding { + let encoding = format!("{{CGSize={}{}}}", + f64::encode().as_str(), + f64::encode().as_str()); + unsafe { objc::Encoding::from_str(&encoding) } + } + } + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct NSRect { + pub origin: NSPoint, + pub size: NSSize, + } + + impl NSRect { + #[inline] + pub fn new(origin: NSPoint, size: NSSize) -> NSRect { + NSRect { + origin: origin, + size: size + } + } + + #[inline] + pub fn as_CGRect(&self) -> &CGRect { + unsafe { + mem::transmute::<&NSRect, &CGRect>(self) + } + } + + #[inline] + pub fn inset(&self, x: CGFloat, y: CGFloat) -> NSRect { + unsafe { + NSInsetRect(*self, x, y) + } + } + } + + unsafe impl objc::Encode for NSRect { + fn encode() -> objc::Encoding { + let encoding = format!("{{CGRect={}{}}}", + NSPoint::encode().as_str(), + NSSize::encode().as_str()); + unsafe { objc::Encoding::from_str(&encoding) } + } + } + + // Same as CGRectEdge + #[repr(u32)] + pub enum NSRectEdge { + NSRectMinXEdge, + NSRectMinYEdge, + NSRectMaxXEdge, + NSRectMaxYEdge, + } + + #[link(name = "Foundation", kind = "framework")] + extern { + fn NSInsetRect(rect: NSRect, x: CGFloat, y: CGFloat) -> NSRect; + } + + pub trait NSValue: Sized { + unsafe fn valueWithPoint(_: Self, point: NSPoint) -> id { + msg_send![class!(NSValue), valueWithPoint:point] + } + + unsafe fn valueWithSize(_: Self, size: NSSize) -> id { + msg_send![class!(NSValue), valueWithSize:size] + } + } + + impl NSValue for id { + } +} + +#[cfg(target_os = "macos")] +pub use self::macos::*; + +#[repr(C)] +pub struct NSRange { + pub location: NSUInteger, + pub length: NSUInteger, +} + +impl NSRange { + #[inline] + pub fn new(location: NSUInteger, length: NSUInteger) -> NSRange { + NSRange { + location: location, + length: length + } + } +} + +#[link(name = "Foundation", kind = "framework")] +extern { + pub static NSDefaultRunLoopMode: id; +} + +pub trait NSAutoreleasePool: Sized { + unsafe fn new(_: Self) -> id { + msg_send![class!(NSAutoreleasePool), new] + } + + unsafe fn autorelease(self) -> Self; + unsafe fn drain(self); +} + +impl NSAutoreleasePool for id { + unsafe fn autorelease(self) -> id { + msg_send![self, autorelease] + } + + unsafe fn drain(self) { + msg_send![self, drain] + } +} + +pub trait NSProcessInfo: Sized { + unsafe fn processInfo(_: Self) -> id { + msg_send![class!(NSProcessInfo), processInfo] + } + + unsafe fn processName(self) -> id; +} + +impl NSProcessInfo for id { + unsafe fn processName(self) -> id { + msg_send![self, processName] + } +} + +pub type NSTimeInterval = libc::c_double; + +pub trait NSArray: Sized { + unsafe fn array(_: Self) -> id { + msg_send![class!(NSArray), array] + } + + unsafe fn arrayWithObjects(_: Self, objects: &[id]) -> id { + msg_send![class!(NSArray), arrayWithObjects:objects.as_ptr() + count:objects.len()] + } + + unsafe fn arrayWithObject(_: Self, object: id) -> id { + msg_send![class!(NSArray), arrayWithObject:object] + } + + unsafe fn arrayByAddingObjectFromArray(self, object: id) -> id; + unsafe fn arrayByAddingObjectsFromArray(self, objects: id) -> id; +} + +impl NSArray for id { + unsafe fn arrayByAddingObjectFromArray(self, object: id) -> id { + msg_send![self, arrayByAddingObjectFromArray:object] + } + + unsafe fn arrayByAddingObjectsFromArray(self, objects: id) -> id { + msg_send![self, arrayByAddingObjectsFromArray:objects] + } +} + +pub trait NSDictionary: Sized { + unsafe fn dictionary(_: Self) -> id { + msg_send![class!(NSDictionary), dictionary] + } + + unsafe fn dictionaryWithContentsOfFile_(_: Self, path: id) -> id { + msg_send![class!(NSDictionary), dictionaryWithContentsOfFile:path] + } + + unsafe fn dictionaryWithContentsOfURL_(_: Self, aURL: id) -> id { + msg_send![class!(NSDictionary), dictionaryWithContentsOfURL:aURL] + } + + unsafe fn dictionaryWithDictionary_(_: Self, otherDictionary: id) -> id { + msg_send![class!(NSDictionary), dictionaryWithDictionary:otherDictionary] + } + + unsafe fn dictionaryWithObject_forKey_(_: Self, anObject: id, aKey: id) -> id { + msg_send![class!(NSDictionary), dictionaryWithObject:anObject forKey:aKey] + } + + unsafe fn dictionaryWithObjects_forKeys_(_: Self, objects: id, keys: id) -> id { + msg_send![class!(NSDictionary), dictionaryWithObjects:objects forKeys:keys] + } + + unsafe fn dictionaryWithObjects_forKeys_count_(_: Self, objects: *const id, keys: *const id, count: NSUInteger) -> id { + msg_send![class!(NSDictionary), dictionaryWithObjects:objects forKeys:keys count:count] + } + + unsafe fn dictionaryWithObjectsAndKeys_(_: Self, firstObject: id) -> id { + msg_send![class!(NSDictionary), dictionaryWithObjectsAndKeys:firstObject] + } + + unsafe fn init(self) -> id; + unsafe fn initWithContentsOfFile_(self, path: id) -> id; + unsafe fn initWithContentsOfURL_(self, aURL: id) -> id; + unsafe fn initWithDictionary_(self, otherDicitonary: id) -> id; + unsafe fn initWithDictionary_copyItems_(self, otherDicitonary: id, flag: BOOL) -> id; + unsafe fn initWithObjects_forKeys_(self, objects: id, keys: id) -> id; + unsafe fn initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id; + unsafe fn initWithObjectsAndKeys_(self, firstObject: id) -> id; + + unsafe fn sharedKeySetForKeys_(_: Self, keys: id) -> id { + msg_send![class!(NSDictionary), sharedKeySetForKeys:keys] + } + + unsafe fn count(self) -> NSUInteger; + + unsafe fn isEqualToDictionary_(self, otherDictionary: id) -> BOOL; + + unsafe fn allKeys(self) -> id; + unsafe fn allKeysForObject_(self, anObject: id) -> id; + unsafe fn allValues(self) -> id; + unsafe fn objectForKey_(self, aKey: id) -> id; + unsafe fn objectForKeyedSubscript_(self, key: id) -> id; + unsafe fn objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id; + unsafe fn valueForKey_(self, key: id) -> id; + + unsafe fn keyEnumerator(self) -> id; + unsafe fn objectEnumerator(self) -> id; + unsafe fn enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>); + unsafe fn enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, + block: *mut Block<(id, id, *mut BOOL), ()>); + + unsafe fn keysSortedByValueUsingSelector_(self, comparator: SEL) -> id; + unsafe fn keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id; + unsafe fn keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id; + + unsafe fn keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id; + unsafe fn keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, + predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id; + + unsafe fn writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL; + unsafe fn writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL; + + unsafe fn fileCreationDate(self) -> id; + unsafe fn fileExtensionHidden(self) -> BOOL; + unsafe fn fileGroupOwnerAccountID(self) -> id; + unsafe fn fileGroupOwnerAccountName(self) -> id; + unsafe fn fileIsAppendOnly(self) -> BOOL; + unsafe fn fileIsImmutable(self) -> BOOL; + unsafe fn fileModificationDate(self) -> id; + unsafe fn fileOwnerAccountID(self) -> id; + unsafe fn fileOwnerAccountName(self) -> id; + unsafe fn filePosixPermissions(self) -> NSUInteger; + unsafe fn fileSize(self) -> libc::c_ulonglong; + unsafe fn fileSystemFileNumber(self) -> NSUInteger; + unsafe fn fileSystemNumber(self) -> NSInteger; + unsafe fn fileType(self) -> id; + + unsafe fn description(self) -> id; + unsafe fn descriptionInStringsFileFormat(self) -> id; + unsafe fn descriptionWithLocale_(self, locale: id) -> id; + unsafe fn descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id; +} + +impl NSDictionary for id { + unsafe fn init(self) -> id { + msg_send![self, init] + } + + unsafe fn initWithContentsOfFile_(self, path: id) -> id { + msg_send![self, initWithContentsOfFile:path] + } + + unsafe fn initWithContentsOfURL_(self, aURL: id) -> id { + msg_send![self, initWithContentsOfURL:aURL] + } + + unsafe fn initWithDictionary_(self, otherDictionary: id) -> id { + msg_send![self, initWithDictionary:otherDictionary] + } + + unsafe fn initWithDictionary_copyItems_(self, otherDictionary: id, flag: BOOL) -> id { + msg_send![self, initWithDictionary:otherDictionary copyItems:flag] + } + + unsafe fn initWithObjects_forKeys_(self, objects: id, keys: id) -> id { + msg_send![self, initWithObjects:objects forKeys:keys] + } + + unsafe fn initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id { + msg_send![self, initWithObjects:objects forKeys:keys count:count] + } + + unsafe fn initWithObjectsAndKeys_(self, firstObject: id) -> id { + msg_send![self, initWithObjectsAndKeys:firstObject] + } + + unsafe fn count(self) -> NSUInteger { + msg_send![self, count] + } + + unsafe fn isEqualToDictionary_(self, otherDictionary: id) -> BOOL { + msg_send![self, isEqualToDictionary:otherDictionary] + } + + unsafe fn allKeys(self) -> id { + msg_send![self, allKeys] + } + + unsafe fn allKeysForObject_(self, anObject: id) -> id { + msg_send![self, allKeysForObject:anObject] + } + + unsafe fn allValues(self) -> id { + msg_send![self, allValues] + } + + unsafe fn objectForKey_(self, aKey: id) -> id { + msg_send![self, objectForKey:aKey] + } + + unsafe fn objectForKeyedSubscript_(self, key: id) -> id { + msg_send![self, objectForKeyedSubscript:key] + } + + unsafe fn objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id { + msg_send![self, objectsForKeys:keys notFoundMarker:anObject] + } + + unsafe fn valueForKey_(self, key: id) -> id { + msg_send![self, valueForKey:key] + } + + unsafe fn keyEnumerator(self) -> id { + msg_send![self, keyEnumerator] + } + + unsafe fn objectEnumerator(self) -> id { + msg_send![self, objectEnumerator] + } + + unsafe fn enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>) { + msg_send![self, enumerateKeysAndObjectsUsingBlock:block] + } + + unsafe fn enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, + block: *mut Block<(id, id, *mut BOOL), ()>) { + msg_send![self, enumerateKeysAndObjectsWithOptions:opts usingBlock:block] + } + + unsafe fn keysSortedByValueUsingSelector_(self, comparator: SEL) -> id { + msg_send![self, keysSortedByValueUsingSelector:comparator] + } + + unsafe fn keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id { + msg_send![self, keysSortedByValueUsingComparator:cmptr] + } + + unsafe fn keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id { + let rv: id = msg_send![self, keysSortedByValueWithOptions:opts usingComparator:cmptr]; + rv + } + + unsafe fn keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id { + msg_send![self, keysOfEntriesPassingTest:predicate] + } + + unsafe fn keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, + predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id { + msg_send![self, keysOfEntriesWithOptions:opts PassingTest:predicate] + } + + unsafe fn writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL { + msg_send![self, writeToFile:path atomically:flag] + } + + unsafe fn writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL { + msg_send![self, writeToURL:aURL atomically:flag] + } + + unsafe fn fileCreationDate(self) -> id { + msg_send![self, fileCreationDate] + } + + unsafe fn fileExtensionHidden(self) -> BOOL { + msg_send![self, fileExtensionHidden] + } + + unsafe fn fileGroupOwnerAccountID(self) -> id { + msg_send![self, fileGroupOwnerAccountID] + } + + unsafe fn fileGroupOwnerAccountName(self) -> id { + msg_send![self, fileGroupOwnerAccountName] + } + + unsafe fn fileIsAppendOnly(self) -> BOOL { + msg_send![self, fileIsAppendOnly] + } + + unsafe fn fileIsImmutable(self) -> BOOL { + msg_send![self, fileIsImmutable] + } + + unsafe fn fileModificationDate(self) -> id { + msg_send![self, fileModificationDate] + } + + unsafe fn fileOwnerAccountID(self) -> id { + msg_send![self, fileOwnerAccountID] + } + + unsafe fn fileOwnerAccountName(self) -> id { + msg_send![self, fileOwnerAccountName] + } + + unsafe fn filePosixPermissions(self) -> NSUInteger { + msg_send![self, filePosixPermissions] + } + + unsafe fn fileSize(self) -> libc::c_ulonglong { + msg_send![self, fileSize] + } + + unsafe fn fileSystemFileNumber(self) -> NSUInteger { + msg_send![self, fileSystemFileNumber] + } + + unsafe fn fileSystemNumber(self) -> NSInteger { + msg_send![self, fileSystemNumber] + } + + unsafe fn fileType(self) -> id { + msg_send![self, fileType] + } + + unsafe fn description(self) -> id { + msg_send![self, description] + } + + unsafe fn descriptionInStringsFileFormat(self) -> id { + msg_send![self, descriptionInStringsFileFormat] + } + + unsafe fn descriptionWithLocale_(self, locale: id) -> id { + msg_send![self, descriptionWithLocale:locale] + } + + unsafe fn descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id { + msg_send![self, descriptionWithLocale:locale indent:indent] + } +} + +bitflags! { + pub struct NSEnumerationOptions: libc::c_ulonglong { + const NSEnumerationConcurrent = 1 << 0; + const NSEnumerationReverse = 1 << 1; + } +} + +pub type NSComparator = *mut Block<(id, id), NSComparisonResult>; + +#[repr(isize)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum NSComparisonResult { + NSOrderedAscending = -1, + NSOrderedSame = 0, + NSOrderedDescending = 1 +} + +pub trait NSString: Sized { + unsafe fn alloc(_: Self) -> id { + msg_send![class!(NSString), alloc] + } + + unsafe fn stringByAppendingString_(self, other: id) -> id; + unsafe fn init_str(self, string: &str) -> Self; + unsafe fn UTF8String(self) -> *const libc::c_char; + unsafe fn len(self) -> usize; + unsafe fn isEqualToString(self, &str) -> bool; +} + +impl NSString for id { + unsafe fn isEqualToString(self, other: &str) -> bool { + let other = NSString::alloc(nil).init_str(other); + let rv: BOOL = msg_send![self, isEqualToString:other]; + rv != NO + } + + unsafe fn stringByAppendingString_(self, other: id) -> id { + msg_send![self, stringByAppendingString:other] + } + + unsafe fn init_str(self, string: &str) -> id { + return msg_send![self, + initWithBytes:string.as_ptr() + length:string.len() + encoding:UTF8_ENCODING as id]; + } + + unsafe fn len(self) -> usize { + msg_send![self, lengthOfBytesUsingEncoding:UTF8_ENCODING] + } + + unsafe fn UTF8String(self) -> *const libc::c_char { + msg_send![self, UTF8String] + } +} + +pub trait NSDate: Sized { + unsafe fn distantPast(_: Self) -> id { + msg_send![class!(NSDate), distantPast] + } + + unsafe fn distantFuture(_: Self) -> id { + msg_send![class!(NSDate), distantFuture] + } +} + +impl NSDate for id { + +} + +#[repr(C)] +struct NSFastEnumerationState { + pub state: libc::c_ulong, + pub items_ptr: *mut id, + pub mutations_ptr: *mut libc::c_ulong, + pub extra: [libc::c_ulong; 5] +} + +const NS_FAST_ENUM_BUF_SIZE: usize = 16; + +pub struct NSFastIterator { + state: NSFastEnumerationState, + buffer: [id; NS_FAST_ENUM_BUF_SIZE], + mut_val: Option, + len: usize, + idx: usize, + object: id +} + +impl Iterator for NSFastIterator { + type Item = id; + + fn next(&mut self) -> Option { + if self.idx >= self.len { + self.len = unsafe { + msg_send![self.object, countByEnumeratingWithState:&mut self.state objects:self.buffer.as_mut_ptr() count:NS_FAST_ENUM_BUF_SIZE] + }; + self.idx = 0; + } + + let new_mut = unsafe { + *self.state.mutations_ptr + }; + + if let Some(old_mut) = self.mut_val { + assert!(old_mut == new_mut, "The collection was mutated while being enumerated"); + } + + if self.idx < self.len { + let object = unsafe { + *self.state.items_ptr.offset(self.idx as isize) + }; + self.mut_val = Some(new_mut); + self.idx += 1; + Some(object) + } else { + None + } + } +} + +pub trait NSFastEnumeration: Sized { + unsafe fn iter(self) -> NSFastIterator; +} + +impl NSFastEnumeration for id { + unsafe fn iter(self) -> NSFastIterator { + NSFastIterator { + state: NSFastEnumerationState { + state: 0, + items_ptr: ptr::null_mut(), + mutations_ptr: ptr::null_mut(), + extra: [0; 5] + }, + buffer: [nil; NS_FAST_ENUM_BUF_SIZE], + mut_val: None, + len: 0, + idx: 0, + object: self + } + } +} + +pub trait NSRunLoop: Sized { + unsafe fn currentRunLoop() -> Self; + + unsafe fn performSelector_target_argument_order_modes_(self, + aSelector: SEL, + target: id, + anArgument: id, + order: NSUInteger, + modes: id); +} + +impl NSRunLoop for id { + unsafe fn currentRunLoop() -> id { + msg_send![class!(NSRunLoop), currentRunLoop] + } + + unsafe fn performSelector_target_argument_order_modes_(self, + aSelector: SEL, + target: id, + anArgument: id, + order: NSUInteger, + modes: id) { + msg_send![self, performSelector:aSelector + target:target + argument:anArgument + order:order + modes:modes] + } +} + +pub trait NSData: Sized { + unsafe fn data(_: Self) -> id { + msg_send![class!(NSData), data] + } + + unsafe fn dataWithBytes_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id { + msg_send![class!(NSData), dataWithBytes:bytes length:length] + } + + unsafe fn dataWithBytesNoCopy_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id { + msg_send![class!(NSData), dataWithBytesNoCopy:bytes length:length] + } + + unsafe fn dataWithBytesNoCopy_length_freeWhenDone_(_: Self, bytes: *const c_void, + length: NSUInteger, freeWhenDone: BOOL) -> id { + msg_send![class!(NSData), dataWithBytesNoCopy:bytes length:length freeWhenDone:freeWhenDone] + } + + unsafe fn dataWithContentsOfFile_(_: Self, path: id) -> id { + msg_send![class!(NSData), dataWithContentsOfFile:path] + } + + unsafe fn dataWithContentsOfFile_options_error_(_: Self, path: id, mask: NSDataReadingOptions, + errorPtr: *mut id) -> id { + msg_send![class!(NSData), dataWithContentsOfFile:path options:mask error:errorPtr] + } + + unsafe fn dataWithContentsOfURL_(_: Self, aURL: id) -> id { + msg_send![class!(NSData), dataWithContentsOfURL:aURL] + } + + unsafe fn dataWithContentsOfURL_options_error_(_: Self, aURL: id, mask: NSDataReadingOptions, + errorPtr: *mut id) -> id { + msg_send![class!(NSData), dataWithContentsOfURL:aURL options:mask error:errorPtr] + } + + unsafe fn dataWithData_(_: Self, aData: id) -> id { + msg_send![class!(NSData), dataWithData:aData] + } + + unsafe fn initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) + -> id; + unsafe fn initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) + -> id; + unsafe fn initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id; + unsafe fn initWithBytesNoCopy_length_(self, bytes: *const c_void, length: NSUInteger) -> id; + unsafe fn initWithBytesNoCopy_length_deallocator_(self, bytes: *const c_void, length: NSUInteger, + deallocator: *mut Block<(*const c_void, NSUInteger), ()>) + -> id; + unsafe fn initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, + length: NSUInteger, freeWhenDone: BOOL) -> id; + unsafe fn initWithContentsOfFile_(self, path: id) -> id; + unsafe fn initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) + -> id; + unsafe fn initWithContentsOfURL_(self, aURL: id) -> id; + unsafe fn initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) + -> id; + unsafe fn initWithData_(self, data: id) -> id; + + unsafe fn bytes(self) -> *const c_void; + unsafe fn description(self) -> id; + unsafe fn enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>); + unsafe fn getBytes_length_(self, buffer: *mut c_void, length: NSUInteger); + unsafe fn getBytes_range_(self, buffer: *mut c_void, range: NSRange); + unsafe fn subdataWithRange_(self, range: NSRange) -> id; + unsafe fn rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) + -> NSRange; + + unsafe fn base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id; + unsafe fn base64EncodedStringWithOptions_(self, options: NSDataBase64EncodingOptions) -> id; + + unsafe fn isEqualToData_(self, otherData: id) -> id; + unsafe fn length(self) -> NSUInteger; + + unsafe fn writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL; + unsafe fn writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL; + unsafe fn writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL; + unsafe fn writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL; +} + +impl NSData for id { + unsafe fn initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) + -> id { + msg_send![self, initWithBase64EncodedData:base64Data options:options] + } + + unsafe fn initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) + -> id { + msg_send![self, initWithBase64EncodedString:base64String options:options] + } + + unsafe fn initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id { + msg_send![self,initWithBytes:bytes length:length] + } + + unsafe fn initWithBytesNoCopy_length_(self, bytes: *const c_void, length: NSUInteger) -> id { + msg_send![self, initWithBytesNoCopy:bytes length:length] + } + + unsafe fn initWithBytesNoCopy_length_deallocator_(self, bytes: *const c_void, length: NSUInteger, + deallocator: *mut Block<(*const c_void, NSUInteger), ()>) + -> id { + msg_send![self, initWithBytesNoCopy:bytes length:length deallocator:deallocator] + } + + unsafe fn initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, + length: NSUInteger, freeWhenDone: BOOL) -> id { + msg_send![self, initWithBytesNoCopy:bytes length:length freeWhenDone:freeWhenDone] + } + + unsafe fn initWithContentsOfFile_(self, path: id) -> id { + msg_send![self, initWithContentsOfFile:path] + } + + unsafe fn initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) + -> id { + msg_send![self, initWithContentsOfFile:path options:mask error:errorPtr] + } + + unsafe fn initWithContentsOfURL_(self, aURL: id) -> id { + msg_send![self, initWithContentsOfURL:aURL] + } + + unsafe fn initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) + -> id { + msg_send![self, initWithContentsOfURL:aURL options:mask error:errorPtr] + } + + unsafe fn initWithData_(self, data: id) -> id { + msg_send![self, initWithData:data] + } + + unsafe fn bytes(self) -> *const c_void { + msg_send![self, bytes] + } + + unsafe fn description(self) -> id { + msg_send![self, description] + } + + unsafe fn enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>) { + msg_send![self, enumerateByteRangesUsingBlock:block] + } + + unsafe fn getBytes_length_(self, buffer: *mut c_void, length: NSUInteger) { + msg_send![self, getBytes:buffer length:length] + } + + unsafe fn getBytes_range_(self, buffer: *mut c_void, range: NSRange) { + msg_send![self, getBytes:buffer range:range] + } + + unsafe fn subdataWithRange_(self, range: NSRange) -> id { + msg_send![self, subdataWithRange:range] + } + + unsafe fn rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) + -> NSRange { + msg_send![self, rangeOfData:dataToFind options:options range:searchRange] + } + + unsafe fn base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id { + msg_send![self, base64EncodedDataWithOptions:options] + } + + unsafe fn base64EncodedStringWithOptions_(self, options: NSDataBase64EncodingOptions) -> id { + msg_send![self, base64EncodedStringWithOptions:options] + } + + unsafe fn isEqualToData_(self, otherData: id) -> id { + msg_send![self, isEqualToData:otherData] + } + + unsafe fn length(self) -> NSUInteger { + msg_send![self, length] + } + + unsafe fn writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL { + msg_send![self, writeToFile:path atomically:atomically] + } + + unsafe fn writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL { + msg_send![self, writeToFile:path options:mask error:errorPtr] + } + + unsafe fn writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL { + msg_send![self, writeToURL:aURL atomically:atomically] + } + + unsafe fn writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL { + msg_send![self, writeToURL:aURL options:mask error:errorPtr] + } +} + +bitflags! { + pub struct NSDataReadingOptions: libc::c_ulonglong { + const NSDataReadingMappedIfSafe = 1 << 0; + const NSDataReadingUncached = 1 << 1; + const NSDataReadingMappedAlways = 1 << 3; + } +} + +bitflags! { + pub struct NSDataBase64EncodingOptions: libc::c_ulonglong { + const NSDataBase64Encoding64CharacterLineLength = 1 << 0; + const NSDataBase64Encoding76CharacterLineLength = 1 << 1; + const NSDataBase64EncodingEndLineWithCarriageReturn = 1 << 4; + const NSDataBase64EncodingEndLineWithLineFeed = 1 << 5; + } +} + +bitflags! { + pub struct NSDataBase64DecodingOptions: libc::c_ulonglong { + const NSDataBase64DecodingIgnoreUnknownCharacters = 1 << 0; + } +} + +bitflags! { + pub struct NSDataWritingOptions: libc::c_ulonglong { + const NSDataWritingAtomic = 1 << 0; + const NSDataWritingWithoutOverwriting = 1 << 1; + } +} + +bitflags! { + pub struct NSDataSearchOptions: libc::c_ulonglong { + const NSDataSearchBackwards = 1 << 0; + const NSDataSearchAnchored = 1 << 1; + } +} diff --git a/third_party/cargo/vendor/cocoa-0.18.5/src/lib.rs b/third_party/cargo/vendor/cocoa-0.18.5/src/lib.rs new file mode 100644 index 0000000..179c0d3 --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/src/lib.rs @@ -0,0 +1,30 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "cocoa"] +#![crate_type = "rlib"] + +#![allow(non_snake_case)] + +extern crate block; +#[macro_use] +extern crate bitflags; +extern crate core_foundation; +extern crate core_graphics; +extern crate foreign_types; +extern crate libc; +#[macro_use] +extern crate objc; + +#[cfg(target_os = "macos")] +pub mod appkit; +pub mod base; +pub mod foundation; +#[cfg(target_os = "macos")] +pub mod quartzcore; diff --git a/third_party/cargo/vendor/cocoa-0.18.5/src/quartzcore.rs b/third_party/cargo/vendor/cocoa-0.18.5/src/quartzcore.rs new file mode 100644 index 0000000..5a63f4a --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/src/quartzcore.rs @@ -0,0 +1,1859 @@ +// Copyright 2018 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(non_upper_case_globals)] + +use core_foundation::array::{CFArray, CFArrayRef}; +use core_foundation::base::{CFType, CFTypeRef, TCFType}; +use core_foundation::date::CFTimeInterval; +use core_foundation::dictionary::{CFDictionary, CFDictionaryRef}; +use core_foundation::string::{CFString, CFStringRef}; +use core_graphics::base::CGFloat; +use core_graphics::color::{CGColor, SysCGColorRef}; +use core_graphics::color_space::CGColorSpace; +use core_graphics::context::CGContext; +use core_graphics::geometry::{CGAffineTransform, CGPoint, CGRect, CGSize}; +use core_graphics::path::{CGPath, SysCGPathRef}; +use foreign_types::ForeignType; +use std::ops::Mul; +use std::ptr; + +use appkit::CGLContextObj; +use base::{BOOL, id, nil, YES}; +use foundation::NSUInteger; + +// CABase.h + +pub fn current_media_time() -> CFTimeInterval { + unsafe { + CACurrentMediaTime() + } +} + +// CALayer.h + +pub struct CALayer(id); + +unsafe impl Send for CALayer {} +unsafe impl Sync for CALayer {} + +impl Clone for CALayer { + #[inline] + fn clone(&self) -> CALayer { + unsafe { + CALayer(msg_send![self.id(), retain]) + } + } +} + +impl Drop for CALayer { + #[inline] + fn drop(&mut self) { + unsafe { + msg_send![self.id(), release] + } + } +} + +impl CALayer { + #[inline] + pub fn id(&self) -> id { + self.0 + } + + #[inline] + pub fn new() -> CALayer { + unsafe { + CALayer(msg_send![class!(CALayer), layer]) + } + } + + #[inline] + pub fn from_layer(other: &CALayer) -> CALayer { + unsafe { + let layer: id = msg_send![class!(CALayer), alloc]; + CALayer(msg_send![layer, initWithLayer:other.id()]) + } + } + + #[inline] + pub fn presentation_layer(&self) -> CALayer { + unsafe { + CALayer(msg_send![self.id(), presentationLayer]) + } + } + + #[inline] + pub fn model_layer(&self) -> CALayer { + unsafe { + CALayer(msg_send![self.id(), modelLayer]) + } + } + + #[inline] + pub fn default_value_for_key(key: &CFString) -> id { + unsafe { + msg_send![class!(CALayer), defaultValueForKey:(key.as_CFTypeRef())] + } + } + + #[inline] + pub fn needs_display_for_key(key: &CFString) -> bool { + unsafe { + let flag: BOOL = msg_send![class!(CALayer), needsDisplayForKey:(key.as_CFTypeRef())]; + flag == YES + } + } + + #[inline] + pub fn should_archive_value_for_key(key: &CFString) -> bool { + unsafe { + let flag: BOOL = msg_send![class!(CALayer), shouldArchiveValueForKey:(key.as_CFTypeRef())]; + flag == YES + } + } + + #[inline] + pub fn bounds(&self) -> CGRect { + unsafe { + msg_send![self.id(), bounds] + } + } + + #[inline] + pub fn set_bounds(&self, bounds: &CGRect) { + unsafe { + msg_send![self.id(), setBounds:*bounds] + } + } + + #[inline] + pub fn position(&self) -> CGPoint { + unsafe { + msg_send![self.id(), position] + } + } + + #[inline] + pub fn set_position(&self, position: &CGPoint) { + unsafe { + msg_send![self.id(), setPosition:*position] + } + } + + #[inline] + pub fn z_position(&self) -> CGFloat { + unsafe { + msg_send![self.id(), zPosition] + } + } + + #[inline] + pub fn set_z_position(&self, z_position: CGFloat) { + unsafe { + msg_send![self.id(), setZPosition:z_position] + } + } + + #[inline] + pub fn anchor_point(&self) -> CGPoint { + unsafe { + msg_send![self.id(), anchorPoint] + } + } + + #[inline] + pub fn set_anchor_point(&self, anchor_point: &CGPoint) { + unsafe { + msg_send![self.id(), setAnchorPoint:*anchor_point] + } + } + + #[inline] + pub fn anchor_point_z(&self) -> CGFloat { + unsafe { + msg_send![self.id(), anchorPointZ] + } + } + + #[inline] + pub fn set_anchor_point_z(&self, anchor_point_z: CGFloat) { + unsafe { + msg_send![self.id(), setAnchorPointZ:anchor_point_z] + } + } + + #[inline] + pub fn transform(&self) -> CATransform3D { + unsafe { + msg_send![self.id(), transform] + } + } + + #[inline] + pub fn set_transform(&self, transform: &CATransform3D) { + unsafe { + msg_send![self.id(), setTransform:*transform] + } + } + + #[inline] + pub fn affine_transform(&self) -> CGAffineTransform { + unsafe { + msg_send![self.id(), affineTransform] + } + } + + #[inline] + pub fn set_affine_transform(&self, affine_transform: &CGAffineTransform) { + unsafe { + msg_send![self.id(), setAffineTransform:*affine_transform] + } + } + + #[inline] + pub fn frame(&self) -> CGRect { + unsafe { + msg_send![self.id(), frame] + } + } + + #[inline] + pub fn set_frame(&self, frame: &CGRect) { + unsafe { + msg_send![self.id(), setFrame:*frame] + } + } + + #[inline] + pub fn is_hidden(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), isHidden]; + flag == YES + } + } + + #[inline] + pub fn set_hidden(&self, hidden: bool) { + unsafe { + msg_send![self.id(), setHidden:hidden as BOOL] + } + } + + #[inline] + pub fn is_double_sided(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), isDoubleSided]; + flag == YES + } + } + + #[inline] + pub fn set_double_sided(&self, double_sided: bool) { + unsafe { + msg_send![self.id(), setDoubleSided:double_sided as BOOL] + } + } + + #[inline] + pub fn is_geometry_flipped(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), isGeometryFlipped]; + flag == YES + } + } + + #[inline] + pub fn set_geometry_flipped(&self, geometry_flipped: bool) { + unsafe { + msg_send![self.id(), setGeometryFlipped:geometry_flipped as BOOL] + } + } + + #[inline] + pub fn contents_are_flipped(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), contentsAreFlipped]; + flag == YES + } + } + + #[inline] + pub fn superlayer(&self) -> Option { + unsafe { + let superlayer: id = msg_send![self.id(), superlayer]; + if superlayer.is_null() { + None + } else { + Some(CALayer(superlayer)) + } + } + } + + #[inline] + pub fn remove_from_superlayer(&self) { + unsafe { + msg_send![self.id(), removeFromSuperlayer] + } + } + + #[inline] + pub fn sublayers(&self) -> CFArray { + unsafe { + let sublayers: CFArrayRef = msg_send![self.id(), sublayers]; + TCFType::wrap_under_create_rule(sublayers) + } + } + + #[inline] + pub fn add_sublayer(&self, sublayer: &CALayer) { + unsafe { + msg_send![self.id(), addSublayer:sublayer.id()] + } + } + + #[inline] + pub fn insert_sublayer_at_index(&self, sublayer: &CALayer, index: u32) { + unsafe { + msg_send![self.id(), insertSublayer:sublayer.id() atIndex:index] + } + } + + #[inline] + pub fn insert_sublayer_below(&self, sublayer: &CALayer, sibling: &CALayer) { + unsafe { + msg_send![self.id(), insertSublayer:sublayer.id() below:sibling.id()] + } + } + + #[inline] + pub fn insert_sublayer_above(&self, sublayer: &CALayer, sibling: &CALayer) { + unsafe { + msg_send![self.id(), insertSublayer:sublayer.id() above:sibling.id()] + } + } + + #[inline] + pub fn replace_sublayer_with(&self, old_layer: &CALayer, new_layer: &CALayer) { + unsafe { + msg_send![self.id(), replaceSublayer:old_layer.id() with:new_layer.id()] + } + } + + #[inline] + pub fn sublayer_transform(&self) -> CATransform3D { + unsafe { + msg_send![self.id(), sublayerTransform] + } + } + + #[inline] + pub fn set_sublayer_transform(&self, sublayer_transform: CATransform3D) { + unsafe { + msg_send![self.id(), setSublayerTransform:sublayer_transform] + } + } + + #[inline] + pub fn mask(&self) -> Option { + unsafe { + let mask: id = msg_send![self.id(), mask]; + if mask.is_null() { + None + } else { + Some(CALayer(mask)) + } + } + } + + #[inline] + pub fn set_mask(&self, mask: Option) { + unsafe { + match mask { + None => msg_send![self.id(), setMask:nil], + Some(mask) => msg_send![self.id(), setMask:(mask.id())], + } + } + } + + #[inline] + pub fn masks_to_bounds(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), masksToBounds]; + flag == YES + } + } + + #[inline] + pub fn set_masks_to_bounds(&self, flag: bool) { + unsafe { + msg_send![self.id(), setMasksToBounds:flag as BOOL] + } + } + + #[inline] + pub fn convert_point_from_layer(&self, point: &CGPoint, layer: Option) -> CGPoint { + unsafe { + let layer = match layer { + None => nil, + Some(ref layer) => layer.id(), + }; + msg_send![self.id(), convertPoint:*point fromLayer:layer] + } + } + + #[inline] + pub fn convert_point_to_layer(&self, point: &CGPoint, layer: Option) -> CGPoint { + unsafe { + let layer = match layer { + None => nil, + Some(ref layer) => layer.id(), + }; + msg_send![self.id(), convertPoint:*point toLayer:layer] + } + } + + #[inline] + pub fn convert_rect_from_layer(&self, rect: &CGRect, layer: Option) -> CGRect { + unsafe { + let layer = match layer { + None => nil, + Some(ref layer) => layer.id(), + }; + msg_send![self.id(), convertRect:*rect fromLayer:layer] + } + } + + #[inline] + pub fn convert_rect_to_layer(&self, rect: &CGRect, layer: Option) -> CGRect { + unsafe { + let layer = match layer { + None => nil, + Some(ref layer) => layer.id(), + }; + msg_send![self.id(), convertRect:*rect toLayer:layer] + } + } + + #[inline] + pub fn convert_time_from_layer(&self, time: CFTimeInterval, layer: Option) + -> CFTimeInterval { + unsafe { + let layer = match layer { + None => nil, + Some(ref layer) => layer.id(), + }; + msg_send![self.id(), convertTime:time fromLayer:layer] + } + } + + #[inline] + pub fn convert_time_to_layer(&self, time: CFTimeInterval, layer: Option) + -> CFTimeInterval { + unsafe { + let layer = match layer { + None => nil, + Some(ref layer) => layer.id(), + }; + msg_send![self.id(), convertTime:time toLayer:layer] + } + } + + #[inline] + pub fn hit_test(&self, point: &CGPoint) -> Option { + unsafe { + let layer: id = msg_send![self.id(), hitTest:*point]; + if layer == nil { + None + } else { + Some(CALayer(layer)) + } + } + } + + #[inline] + pub fn contains_point(&self, point: &CGPoint) -> bool { + unsafe { + let result: BOOL = msg_send![self.id(), containsPoint:*point]; + result == YES + } + } + + #[inline] + pub fn contents(&self) -> id { + unsafe { + msg_send![self.id(), contents] + } + } + + #[inline] + pub unsafe fn set_contents(&self, contents: id) { + msg_send![self.id(), setContents:contents] + } + + #[inline] + pub fn contents_rect(&self) -> CGRect { + unsafe { + msg_send![self.id(), contentsRect] + } + } + + #[inline] + pub fn set_contents_rect(&self, contents_rect: &CGRect) { + unsafe { + msg_send![self.id(), setContentsRect:*contents_rect] + } + } + + #[inline] + pub fn contents_gravity(&self) -> ContentsGravity { + unsafe { + let string: CFStringRef = msg_send![self.id(), contentsGravity]; + ContentsGravity::from_CFString(TCFType::wrap_under_create_rule(string)) + } + } + + #[inline] + pub fn set_contents_gravity(&self, new_contents_gravity: ContentsGravity) { + unsafe { + let contents_gravity: CFString = new_contents_gravity.into_CFString(); + msg_send![self.id(), setContentsGravity:contents_gravity.as_CFTypeRef()] + } + } + + #[inline] + pub fn contents_scale(&self) -> CGFloat { + unsafe { + msg_send![self.id(), contentsScale] + } + } + + #[inline] + pub fn set_contents_scale(&self, new_contents_scale: CGFloat) { + unsafe { + msg_send![self.id(), setContentsScale:new_contents_scale] + } + } + + #[inline] + pub fn contents_center(&self) -> CGRect { + unsafe { + msg_send![self.id(), contentsCenter] + } + } + + #[inline] + pub fn set_contents_center(&self, new_rect: &CGRect) { + unsafe { + msg_send![self.id(), setContentsCenter:*new_rect] + } + } + + #[inline] + pub fn contents_format(&self) -> ContentsFormat { + unsafe { + let string: CFStringRef = msg_send![self.id(), contentsFormat]; + ContentsFormat::from_CFString(TCFType::wrap_under_create_rule(string)) + } + } + + #[inline] + pub fn set_contents_format(&self, new_contents_format: ContentsFormat) { + unsafe { + let contents_format: CFString = new_contents_format.into_CFString(); + msg_send![self.id(), setContentsFormat:contents_format.as_CFTypeRef()] + } + } + + #[inline] + pub fn minification_filter(&self) -> Filter { + unsafe { + let string: CFStringRef = msg_send![self.id(), minificationFilter]; + Filter::from_CFString(TCFType::wrap_under_create_rule(string)) + } + } + + #[inline] + pub fn set_minification_filter(&self, new_filter: Filter) { + unsafe { + let filter: CFString = new_filter.into_CFString(); + msg_send![self.id(), setMinificationFilter:filter.as_CFTypeRef()] + } + } + + #[inline] + pub fn magnification_filter(&self) -> Filter { + unsafe { + let string: CFStringRef = msg_send![self.id(), magnificationFilter]; + Filter::from_CFString(TCFType::wrap_under_create_rule(string)) + } + } + + #[inline] + pub fn set_magnification_filter(&self, new_filter: Filter) { + unsafe { + let filter: CFString = new_filter.into_CFString(); + msg_send![self.id(), setMagnificationFilter:filter.as_CFTypeRef()] + } + } + + #[inline] + pub fn minification_filter_bias(&self) -> f32 { + unsafe { + msg_send![self.id(), minificationFilterBias] + } + } + + #[inline] + pub fn set_minification_filter_bias(&self, new_filter_bias: f32) { + unsafe { + msg_send![self.id(), setMinificationFilterBias:new_filter_bias] + } + } + + #[inline] + pub fn is_opaque(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), isOpaque]; + flag == YES + } + } + + #[inline] + pub fn set_opaque(&self, opaque: bool) { + unsafe { + msg_send![self.id(), setOpaque:opaque as BOOL] + } + } + + #[inline] + pub fn display(&self) { + unsafe { + msg_send![self.id(), display] + } + } + + #[inline] + pub fn set_needs_display(&self) { + unsafe { + msg_send![self.id(), setNeedsDisplay] + } + } + + #[inline] + pub fn set_needs_display_in_rect(&self, rect: &CGRect) { + unsafe { + msg_send![self.id(), setNeedsDisplayInRect:*rect] + } + } + + #[inline] + pub fn needs_display(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), needsDisplay]; + flag == YES + } + } + + #[inline] + pub fn display_if_needed(&self) { + unsafe { + msg_send![self.id(), displayIfNeeded] + } + } + + #[inline] + pub fn needs_display_on_bounds_change(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), needsDisplayOnBoundsChange]; + flag == YES + } + } + + #[inline] + pub fn set_needs_display_on_bounds_change(&self, flag: bool) { + unsafe { + msg_send![self.id(), setNeedsDisplayOnBoundsChange:flag as BOOL] + } + } + + #[inline] + pub fn draws_asynchronously(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), drawsAsynchronously]; + flag == YES + } + } + + #[inline] + pub fn set_draws_asynchronously(&self, flag: bool) { + unsafe { + msg_send![self.id(), setDrawsAsynchronously:flag as BOOL] + } + } + + #[inline] + pub fn draw_in_context(&self, context: &CGContext) { + unsafe { + msg_send![self.id(), drawInContext:(*context).as_ptr()] + } + } + + #[inline] + pub fn render_in_context(&self, context: &CGContext) { + unsafe { + msg_send![self.id(), renderInContext:(*context).as_ptr()] + } + } + + #[inline] + pub fn edge_antialiasing_mask(&self) -> EdgeAntialiasingMask { + unsafe { + EdgeAntialiasingMask::from_bits_truncate(msg_send![self.id(), edgeAntialiasingMask]) + } + } + + #[inline] + pub fn set_edge_antialiasing_mask(&self, mask: EdgeAntialiasingMask) { + unsafe { + msg_send![self.id(), setEdgeAntialiasingMask:mask.bits()] + } + } + + #[inline] + pub fn background_color(&self) -> Option { + unsafe { + let color: SysCGColorRef = msg_send![self.id(), backgroundColor]; + if color.is_null() { + None + } else { + Some(CGColor::wrap_under_get_rule(color)) + } + } + } + + #[inline] + pub fn set_background_color(&self, color: Option) { + unsafe { + let color = match color { + None => ptr::null(), + Some(color) => color.as_CFTypeRef(), + }; + msg_send![self.id(), setBackgroundColor:color] + } + } + + #[inline] + pub fn corner_radius(&self) -> CGFloat { + unsafe { + msg_send![self.id(), cornerRadius] + } + } + + #[inline] + pub fn set_corner_radius(&self, radius: CGFloat) { + unsafe { + msg_send![self.id(), setCornerRadius:radius] + } + } + + #[inline] + pub fn masked_corners(&self) -> CornerMask { + unsafe { + CornerMask::from_bits_truncate(msg_send![self.id(), maskedCorners]) + } + } + + #[inline] + pub fn set_masked_corners(&self, mask: CornerMask) { + unsafe { + msg_send![self.id(), setCornerMask:mask.bits()] + } + } + + #[inline] + pub fn border_width(&self) -> CGFloat { + unsafe { + msg_send![self.id(), borderWidth] + } + } + + #[inline] + pub fn set_border_width(&self, border_width: CGFloat) { + unsafe { + msg_send![self.id(), setBorderWidth:border_width] + } + } + + #[inline] + pub fn border_color(&self) -> Option { + unsafe { + let color: SysCGColorRef = msg_send![self.id(), borderColor]; + if color.is_null() { + None + } else { + Some(CGColor::wrap_under_get_rule(color)) + } + } + } + + #[inline] + pub fn set_border_color(&self, color: Option) { + unsafe { + let color = match color { + None => ptr::null(), + Some(color) => color.as_CFTypeRef(), + }; + msg_send![self.id(), setBorderColor:color] + } + } + + #[inline] + pub fn opacity(&self) -> f32 { + unsafe { + msg_send![self.id(), opacity] + } + } + + #[inline] + pub fn set_opacity(&self, opacity: f32) { + unsafe { + msg_send![self.id(), setOpacity:opacity] + } + } + + #[inline] + pub fn compositing_filter(&self) -> id { + unsafe { + msg_send![self.id(), compositingFilter] + } + } + + #[inline] + pub unsafe fn set_compositing_filter(&self, filter: id) { + msg_send![self.id(), setCompositingFilter:filter] + } + + #[inline] + pub unsafe fn filters(&self) -> Option { + let filters: CFArrayRef = msg_send![self.id(), filters]; + if filters.is_null() { + None + } else { + Some(CFArray::wrap_under_get_rule(filters)) + } + } + + #[inline] + pub unsafe fn set_filters(&self, filters: Option) { + let filters: CFTypeRef = match filters { + Some(ref filters) => filters.as_CFTypeRef(), + None => ptr::null(), + }; + msg_send![self.id(), setFilters:filters] + } + + #[inline] + pub unsafe fn background_filters(&self) -> Option { + let filters: CFArrayRef = msg_send![self.id(), backgroundFilters]; + if filters.is_null() { + None + } else { + Some(CFArray::wrap_under_get_rule(filters)) + } + } + + #[inline] + pub unsafe fn set_background_filters(&self, filters: Option) { + let filters: CFTypeRef = match filters { + Some(ref filters) => filters.as_CFTypeRef(), + None => ptr::null(), + }; + msg_send![self.id(), setBackgroundFilters:filters] + } + + #[inline] + pub fn should_rasterize(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), shouldRasterize]; + flag == YES + } + } + + #[inline] + pub fn set_should_rasterize(&self, flag: bool) { + unsafe { + msg_send![self.id(), setShouldRasterize:(flag as BOOL)] + } + } + + #[inline] + pub fn rasterization_scale(&self) -> CGFloat { + unsafe { + msg_send![self.id(), rasterizationScale] + } + } + + #[inline] + pub fn set_rasterization_scale(&self, scale: CGFloat) { + unsafe { + msg_send![self.id(), setRasterizationScale:scale] + } + } + + // Shadow properties + + #[inline] + pub fn shadow_color(&self) -> Option { + unsafe { + let color: SysCGColorRef = msg_send![self.id(), shadowColor]; + if color.is_null() { + None + } else { + Some(CGColor::wrap_under_get_rule(color)) + } + } + } + + #[inline] + pub fn set_shadow_color(&self, color: Option) { + unsafe { + let color = match color { + None => ptr::null(), + Some(color) => color.as_CFTypeRef(), + }; + msg_send![self.id(), setShadowColor:color] + } + } + + #[inline] + pub fn shadow_opacity(&self) -> f32 { + unsafe { + msg_send![self.id(), shadowOpacity] + } + } + + #[inline] + pub fn set_shadow_opacity(&self, opacity: f32) { + unsafe { + msg_send![self.id(), setShadowOpacity:opacity] + } + } + + #[inline] + pub fn shadow_offset(&self) -> CGSize { + unsafe { + msg_send![self.id(), shadowOffset] + } + } + + #[inline] + pub fn set_shadow_offset(&self, offset: &CGSize) { + unsafe { + msg_send![self.id(), setShadowOffset:*offset] + } + } + + #[inline] + pub fn shadow_radius(&self) -> CGFloat { + unsafe { + msg_send![self.id(), shadowRadius] + } + } + + #[inline] + pub fn set_shadow_radius(&self, radius: CGFloat) { + unsafe { + msg_send![self.id(), setShadowRadius:radius] + } + } + + #[inline] + pub fn shadow_path(&self) -> Option { + unsafe { + let path: SysCGPathRef = msg_send![self.id(), shadowPath]; + if path.is_null() { + None + } else { + Some(CGPath::from_ptr(path)) + } + } + } + + #[inline] + pub fn set_shadow_path(&self, path: Option) { + unsafe { + let sys_path_ref = match path { + None => ptr::null(), + Some(path) => path.as_ptr(), + }; + msg_send![self.id(), setShadowPath:sys_path_ref] + } + } + + // Layout methods + + #[inline] + pub fn autoresizing_mask(&self) -> AutoresizingMask { + unsafe { + AutoresizingMask::from_bits_truncate(msg_send![self.id(), autoresizingMask]) + } + } + + #[inline] + pub fn set_autoresizing_mask(&self, mask: AutoresizingMask) { + unsafe { + msg_send![self.id(), setAutoresizingMask:mask.bits()] + } + } + + #[inline] + pub fn layout_manager(&self) -> id { + unsafe { + msg_send![self.id(), layoutManager] + } + } + + #[inline] + pub unsafe fn set_layout_manager(&self, manager: id) { + msg_send![self.id(), setLayoutManager:manager] + } + + #[inline] + pub fn preferred_frame_size(&self) -> CGSize { + unsafe { + msg_send![self.id(), preferredFrameSize] + } + } + + #[inline] + pub fn set_needs_layout(&self) { + unsafe { + msg_send![self.id(), setNeedsLayout] + } + } + + #[inline] + pub fn needs_layout(&self) -> bool { + unsafe { + let flag: BOOL = msg_send![self.id(), needsLayout]; + flag == YES + } + } + + #[inline] + pub fn layout_if_needed(&self) { + unsafe { + msg_send![self.id(), layoutIfNeeded] + } + } + + #[inline] + pub fn layout_sublayers(&self) { + unsafe { + msg_send![self.id(), layoutSublayers] + } + } + + #[inline] + pub fn resize_sublayers_with_old_size(&self, size: &CGSize) { + unsafe { + msg_send![self.id(), resizeSublayersWithOldSize:*size] + } + } + + #[inline] + pub fn resize_with_old_superlayer_size(&self, size: &CGSize) { + unsafe { + msg_send![self.id(), resizeWithOldSuperlayerSize:*size] + } + } + + // Action methods + + #[inline] + pub fn default_action_for_key(event: &str) -> id { + unsafe { + let event: CFString = CFString::from(event); + msg_send![class!(CALayer), defaultActionForKey:event.as_CFTypeRef()] + } + } + + #[inline] + pub fn action_for_key(&self, event: &str) -> id { + unsafe { + let event: CFString = CFString::from(event); + msg_send![self.id(), actionForKey:event.as_CFTypeRef()] + } + } + + #[inline] + pub fn actions(&self) -> CFDictionary { + unsafe { + msg_send![self.id(), actions] + } + } + + #[inline] + pub unsafe fn set_actions(&self, actions: CFDictionary) { + msg_send![self.id(), setActions:actions] + } + + // TODO(pcwalton): Wrap `CAAnimation`. + #[inline] + pub unsafe fn add_animation_for_key(&self, animation: id, for_key: Option<&str>) { + let for_key: Option = for_key.map(CFString::from); + let for_key: CFTypeRef = match for_key { + Some(ref for_key) => for_key.as_CFTypeRef(), + None => ptr::null(), + }; + msg_send![self.id(), addAnimation:animation forKey:for_key] + } + + #[inline] + pub fn remove_all_animation(&self) { + unsafe { + msg_send![self.id(), removeAllAnimations] + } + } + + #[inline] + pub fn remove_animation_for_key(&self, key: &str) { + unsafe { + let key = CFString::from(key); + msg_send![self.id(), removeAnimationForKey:key.as_CFTypeRef()] + } + } + + #[inline] + pub fn animation_keys(&self) -> Vec { + unsafe { + let keys: CFArrayRef = msg_send![self.id(), animationKeys]; + let keys: CFArray = TCFType::wrap_under_create_rule(keys); + keys.into_iter().map(|string| { + CFString::wrap_under_get_rule(*string as CFStringRef).to_string() + }).collect() + } + } + + #[inline] + pub fn animation_for_key(&self, key: &str) -> id { + unsafe { + let key = CFString::from(key); + msg_send![self.id(), animationForKey:key.as_CFTypeRef()] + } + } + + // Miscellaneous properties + + #[inline] + pub fn name(&self) -> String { + unsafe { + let name: CFStringRef = msg_send![self.id(), name]; + CFString::wrap_under_get_rule(name).to_string() + } + } + + #[inline] + pub fn set_name(&self, name: &str) { + unsafe { + let name = CFString::from(name); + msg_send![self.id(), setName:name.as_CFTypeRef()] + } + } + + #[inline] + pub fn delegate(&self) -> id { + unsafe { + msg_send![self.id(), delegate] + } + } + + #[inline] + pub unsafe fn set_delegate(&self, delegate: id) { + msg_send![self.id(), setDelegate:delegate] + } + + #[inline] + pub fn style(&self) -> Option { + unsafe { + let dictionary: CFDictionaryRef = msg_send![self.id(), style]; + if dictionary.is_null() { + None + } else { + Some(CFDictionary::wrap_under_get_rule(dictionary)) + } + } + } + + #[inline] + pub fn set_style(&self, dictionary: Option) { + unsafe { + let dictionary = match dictionary { + None => ptr::null(), + Some(ref dictionary) => dictionary.as_CFTypeRef(), + }; + msg_send![self.id(), setStyle:dictionary] + } + } + + // Private methods + + #[inline] + pub fn reload_value_for_key_path(&self, key: &str) { + unsafe { + let key = CFString::from(key); + msg_send![self.id(), reloadValueForKeyPath:key.as_CFTypeRef()] + } + } + + #[inline] + pub fn set_contents_opaque(&self, opaque: bool) { + unsafe { + msg_send![self.id(), setContentsOpaque:opaque as BOOL] + } + } +} + +#[derive(Clone, Debug, PartialEq)] +pub enum ContentsGravity { + Center, + Top, + Bottom, + Left, + Right, + TopLeft, + TopRight, + BottomLeft, + BottomRight, + Resize, + ResizeAspect, + ResizeAspectFill, + Other(CFString), +} + +impl ContentsGravity { + fn into_CFString(self) -> CFString { + let string = match self { + ContentsGravity::Center => "center", + ContentsGravity::Top => "top", + ContentsGravity::Bottom => "bottom", + ContentsGravity::Left => "left", + ContentsGravity::Right => "right", + ContentsGravity::TopLeft => "topLeft", + ContentsGravity::TopRight => "topRight", + ContentsGravity::BottomLeft => "bottomLeft", + ContentsGravity::BottomRight => "bottomRight", + ContentsGravity::Resize => "resize", + ContentsGravity::ResizeAspect => "resizeAspect", + ContentsGravity::ResizeAspectFill => "resizeAspectFill", + ContentsGravity::Other(other) => return other, + }; + CFString::from(string) + } + + // FIXME(pcwalton): Inefficient. + fn from_CFString(string: CFString) -> ContentsGravity { + match string.to_string() { + ref s if s == "center" => ContentsGravity::Center, + ref s if s == "top" => ContentsGravity::Top, + ref s if s == "bottom" => ContentsGravity::Bottom, + ref s if s == "left" => ContentsGravity::Left, + ref s if s == "right" => ContentsGravity::Right, + ref s if s == "topLeft" => ContentsGravity::TopLeft, + ref s if s == "topRight" => ContentsGravity::TopRight, + ref s if s == "bottomLeft" => ContentsGravity::BottomLeft, + ref s if s == "bottomRight" => ContentsGravity::BottomRight, + ref s if s == "resize" => ContentsGravity::Resize, + ref s if s == "resizeAspect" => ContentsGravity::ResizeAspect, + ref s if s == "resizeAspectFill" => ContentsGravity::ResizeAspectFill, + _ => ContentsGravity::Other(string), + } + } +} + +#[derive(Clone, Debug, PartialEq)] +pub enum ContentsFormat { + RGBA8Uint, // kCAContentsFormatRGBA8Uint, "RGBA" + RGBA16Float, // kCAContentsFormatRGBA16Float, "RGBAh" + Gray8Uint, // kCAContentsFormatGray8Uint, "Gray8" + Other(CFString), +} + +impl ContentsFormat { + fn into_CFString(self) -> CFString { + let string = match self { + ContentsFormat::RGBA8Uint => "RGBA8", + ContentsFormat::RGBA16Float => "RGBAh", + ContentsFormat::Gray8Uint => "Gray8", + ContentsFormat::Other(other) => return other, + }; + CFString::from(string) + } + + // FIXME(pcwalton): Inefficient. + fn from_CFString(string: CFString) -> ContentsFormat { + match string.to_string() { + ref s if s == "RGBA8" => ContentsFormat::RGBA8Uint, + ref s if s == "RGBAh" => ContentsFormat::RGBA16Float, + ref s if s == "Gray8" => ContentsFormat::Gray8Uint, + _ => ContentsFormat::Other(string), + } + } +} + +#[derive(Clone, Debug, PartialEq)] +pub enum Filter { + Nearest, + Linear, + Trilinear, + Other(CFString), +} + +impl Filter { + fn into_CFString(self) -> CFString { + let string = match self { + Filter::Nearest => "nearest", + Filter::Linear => "linear", + Filter::Trilinear => "trilinear", + Filter::Other(other) => return other, + }; + CFString::from(string) + } + + // FIXME(pcwalton): Inefficient. + fn from_CFString(string: CFString) -> Filter { + match string.to_string() { + ref s if s == "nearest" => Filter::Nearest, + ref s if s == "linear" => Filter::Linear, + ref s if s == "trilinear" => Filter::Trilinear, + _ => Filter::Other(string), + } + } +} + +bitflags! { + pub struct EdgeAntialiasingMask: u32 { + const LEFT_EDGE = 1 << 0; // kCALayerLeftEdge + const RIGHT_EDGE = 1 << 1; // kCALayerRightEdge + const BOTTOM_EDGE = 1 << 2; // kCALayerBottomEdge + const TOP_EDGE = 1 << 3; // kCALayerTopEdge + } +} + +bitflags! { + pub struct CornerMask: NSUInteger { + const MIN_X_MIN_Y_CORNER = 1 << 0; // kCALayerMinXMinYCorner + const MAX_X_MIN_Y_CORNER = 1 << 1; // kCALayerMaxXMinYCorner + const MIN_X_MAX_Y_CORNER = 1 << 2; // kCALayerMinXMaxYCorner + const MAX_X_MAX_Y_CORNER = 1 << 3; // kCALayerMaxXMaxYCorner + } +} + +bitflags! { + pub struct AutoresizingMask: u32 { + const NOT_SIZABLE = 0; // kCALayerNotSizable + const MIN_X_MARGIN = 1 << 0; // kCALayerMinXMargin + const WIDTH_SIZABLE = 1 << 1; // kCALayerWidthSizable + const MAX_X_MARGIN = 1 << 2; // kCALayerMaxXMargin + const MIN_Y_MARGIN = 1 << 3; // kCALayerMinYMargin + const HEIGHT_SIZABLE = 1 << 4; // kCALayerHeightSizable + const MAX_Y_MARGIN = 1 << 5; // kCALayerMaxYMargin + } +} + +// CARenderer.h + +pub struct CARenderer(id); + +unsafe impl Send for CARenderer {} +unsafe impl Sync for CARenderer {} + +impl Clone for CARenderer { + #[inline] + fn clone(&self) -> CARenderer { + unsafe { + CARenderer(msg_send![self.id(), retain]) + } + } +} + +impl Drop for CARenderer { + #[inline] + fn drop(&mut self) { + unsafe { + msg_send![self.id(), release] + } + } +} + +impl CARenderer { + #[inline] + pub fn id(&self) -> id { + self.0 + } + + #[inline] + pub unsafe fn from_cgl_context(context: CGLContextObj, color_space: Option) + -> CARenderer { + let mut pairs: Vec<(CFString, CFType)> = vec![]; + if let Some(color_space) = color_space { + pairs.push((CFString::wrap_under_get_rule(kCARendererColorSpace), + CFType::wrap_under_get_rule(color_space.as_ptr() as *const _ as *const _))) + } + + let options: CFDictionary = CFDictionary::from_CFType_pairs(&pairs); + + let renderer: id = + msg_send![class!(CARenderer), rendererWithCGLContext:context + options:options.as_CFTypeRef()]; + debug_assert!(renderer != nil); + CARenderer(renderer) + } + + #[inline] + pub unsafe fn from_metal_texture(metal_texture: id, + metal_command_queue: id, + color_space: Option) + -> CARenderer { + let mut pairs: Vec<(CFString, CFType)> = vec![ + (CFString::wrap_under_get_rule(kCARendererMetalCommandQueue), + CFType::wrap_under_get_rule(metal_command_queue as *const _ as *const _)), + ]; + if let Some(color_space) = color_space { + pairs.push((CFString::wrap_under_get_rule(kCARendererColorSpace), + CFType::wrap_under_get_rule(color_space.as_ptr() as *const _ as *const _))) + } + + let options: CFDictionary = CFDictionary::from_CFType_pairs(&pairs); + + let renderer: id = + msg_send![class!(CARenderer), rendererWithMTLTexture:metal_texture + options:options.as_CFTypeRef()]; + debug_assert!(renderer != nil); + CARenderer(renderer) + } + + #[inline] + pub fn layer(&self) -> Option { + unsafe { + let layer: id = msg_send![self.id(), layer]; + if layer.is_null() { + None + } else { + Some(CALayer(layer)) + } + } + } + + #[inline] + pub fn set_layer(&self, layer: Option) { + unsafe { + let layer = match layer { + Some(ref layer) => layer.id(), + None => nil, + }; + msg_send![self.id(), setLayer:layer] + } + } + + #[inline] + pub fn bounds(&self) -> CGRect { + unsafe { + msg_send![self.id(), bounds] + } + } + + #[inline] + pub fn set_bounds(&self, bounds: CGRect) { + unsafe { + msg_send![self.id(), setBounds:bounds] + } + } + + #[inline] + pub fn begin_frame_at(&self, time: CFTimeInterval, timestamp: Option<&CVTimeStamp>) { + unsafe { + msg_send![self.id(), beginFrameAtTime:time timeStamp:timestamp] + } + } + + #[inline] + pub fn update_bounds(&self) -> CGRect { + unsafe { + msg_send![self.id(), updateBounds] + } + } + + #[inline] + pub fn add_update_rect(&self, rect: CGRect) { + unsafe { + msg_send![self.id(), addUpdateRect:rect] + } + } + + #[inline] + pub fn render(&self) { + unsafe { + msg_send![self.id(), render] + } + } + + #[inline] + pub fn next_frame_time(&self) -> CFTimeInterval { + unsafe { + msg_send![self.id(), nextFrameTime] + } + } + + #[inline] + pub fn end_frame(&self) { + unsafe { + msg_send![self.id(), endFrame] + } + } + + #[inline] + pub unsafe fn set_destination(&self, metal_texture: id) { + msg_send![self.id(), setDestination:metal_texture] + } +} + +// CATransaction.h + +// You can't actually construct any `CATransaction` objects, so that class is +// really just a module. +pub mod transaction { + use block::{Block, ConcreteBlock, IntoConcreteBlock, RcBlock}; + use core_foundation::date::CFTimeInterval; + use core_foundation::string::CFString; + + use base::{BOOL, YES, id}; + + #[inline] + pub fn begin() { + unsafe { + msg_send![class!(CATransaction), begin] + } + } + + #[inline] + pub fn commit() { + unsafe { + msg_send![class!(CATransaction), commit] + } + } + + #[inline] + pub fn flush() { + unsafe { + msg_send![class!(CATransaction), flush] + } + } + + #[inline] + pub fn lock() { + unsafe { + msg_send![class!(CATransaction), lock] + } + } + + #[inline] + pub fn unlock() { + unsafe { + msg_send![class!(CATransaction), unlock] + } + } + + #[inline] + pub fn animation_duration() -> CFTimeInterval { + unsafe { + msg_send![class!(CATransaction), animationDuration] + } + } + + #[inline] + pub fn set_animation_duration(duration: CFTimeInterval) { + unsafe { + msg_send![class!(CATransaction), setAnimationDuration:duration] + } + } + + #[inline] + pub fn animation_timing_function() -> id { + unsafe { + msg_send![class!(CATransaction), animationTimingFunction] + } + } + + #[inline] + pub unsafe fn set_animation_timing_function(function: id) { + msg_send![class!(CATransaction), setAnimationTimingFunction:function] + } + + #[inline] + pub fn disable_actions() -> bool { + unsafe { + let flag: BOOL = msg_send![class!(CATransaction), disableActions]; + flag == YES + } + } + + #[inline] + pub fn set_disable_actions(flag: bool) { + unsafe { + msg_send![class!(CATransaction), setDisableActions:flag as BOOL] + } + } + + #[inline] + pub fn completion_block() -> Option> { + unsafe { + let completion_block: *mut Block<(), ()> = + msg_send![class!(CATransaction), completionBlock]; + if completion_block.is_null() { + None + } else { + Some(RcBlock::new(completion_block)) + } + } + } + + #[inline] + pub fn set_completion_block(block: ConcreteBlock<(), (), F>) + where F: 'static + IntoConcreteBlock<(), Ret = ()> { + unsafe { + let block = block.copy(); + msg_send![class!(CATransaction), setCompletionBlock:&*block] + } + } + + #[inline] + pub fn value_for_key(key: &str) -> id { + unsafe { + let key: CFString = CFString::from(key); + msg_send![class!(CATransaction), valueForKey:key] + } + } + + #[inline] + pub fn set_value_for_key(value: id, key: &str) { + unsafe { + let key: CFString = CFString::from(key); + msg_send![class!(CATransaction), setValue:value forKey:key] + } + } +} + +// CATransform3D.h + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CATransform3D { + pub m11: CGFloat, pub m12: CGFloat, pub m13: CGFloat, pub m14: CGFloat, + pub m21: CGFloat, pub m22: CGFloat, pub m23: CGFloat, pub m24: CGFloat, + pub m31: CGFloat, pub m32: CGFloat, pub m33: CGFloat, pub m34: CGFloat, + pub m41: CGFloat, pub m42: CGFloat, pub m43: CGFloat, pub m44: CGFloat, +} + +impl PartialEq for CATransform3D { + #[inline] + fn eq(&self, other: &CATransform3D) -> bool { + unsafe { + CATransform3DEqualToTransform(*self, *other) + } + } +} + +impl Mul for CATransform3D { + type Output = CATransform3D; + + #[inline] + fn mul(self, other: CATransform3D) -> CATransform3D { + unsafe { + CATransform3DConcat(self, other) + } + } +} + +impl CATransform3D { + pub const IDENTITY: CATransform3D = CATransform3D { + m11: 1.0, m12: 0.0, m13: 0.0, m14: 0.0, + m21: 0.0, m22: 1.0, m23: 0.0, m24: 0.0, + m31: 0.0, m32: 0.0, m33: 1.0, m34: 0.0, + m41: 0.0, m42: 0.0, m43: 0.0, m44: 1.0, + }; + + #[inline] + pub fn from_translation(tx: CGFloat, ty: CGFloat, tz: CGFloat) -> CATransform3D { + unsafe { + CATransform3DMakeTranslation(tx, ty, tz) + } + } + + #[inline] + pub fn from_scale(sx: CGFloat, sy: CGFloat, sz: CGFloat) -> CATransform3D { + unsafe { + CATransform3DMakeScale(sx, sy, sz) + } + } + + #[inline] + pub fn from_rotation(angle: CGFloat, x: CGFloat, y: CGFloat, z: CGFloat) -> CATransform3D { + unsafe { + CATransform3DMakeRotation(angle, x, y, z) + } + } + + #[inline] + pub fn affine(affine_transform: CGAffineTransform) -> CATransform3D { + unsafe { + CATransform3DMakeAffineTransform(affine_transform) + } + } + + #[inline] + pub fn is_identity(&self) -> bool { + unsafe { + CATransform3DIsIdentity(*self) + } + } + + #[inline] + pub fn translate(&self, tx: CGFloat, ty: CGFloat, tz: CGFloat) -> CATransform3D { + unsafe { + CATransform3DTranslate(*self, tx, ty, tz) + } + } + + #[inline] + pub fn scale(&self, sx: CGFloat, sy: CGFloat, sz: CGFloat) -> CATransform3D { + unsafe { + CATransform3DScale(*self, sx, sy, sz) + } + } + + #[inline] + pub fn rotate(&self, angle: CGFloat, x: CGFloat, y: CGFloat, z: CGFloat) -> CATransform3D { + unsafe { + CATransform3DRotate(*self, angle, x, y, z) + } + } + + #[inline] + pub fn invert(&self) -> CATransform3D { + unsafe { + CATransform3DInvert(*self) + } + } + + #[inline] + pub fn is_affine(&self) -> bool { + unsafe { + CATransform3DIsAffine(*self) + } + } + + #[inline] + pub fn to_affine(&self) -> CGAffineTransform { + unsafe { + CATransform3DGetAffineTransform(*self) + } + } +} + +#[link(name = "QuartzCore", kind = "framework")] +extern { + static kCARendererColorSpace: CFStringRef; + static kCARendererMetalCommandQueue: CFStringRef; + + fn CACurrentMediaTime() -> CFTimeInterval; + + fn CATransform3DIsIdentity(t: CATransform3D) -> bool; + fn CATransform3DEqualToTransform(a: CATransform3D, b: CATransform3D) -> bool; + fn CATransform3DMakeTranslation(tx: CGFloat, ty: CGFloat, tz: CGFloat) -> CATransform3D; + fn CATransform3DMakeScale(sx: CGFloat, sy: CGFloat, sz: CGFloat) -> CATransform3D; + fn CATransform3DMakeRotation(angle: CGFloat, x: CGFloat, y: CGFloat, z: CGFloat) + -> CATransform3D; + fn CATransform3DTranslate(t: CATransform3D, tx: CGFloat, ty: CGFloat, tz: CGFloat) + -> CATransform3D; + fn CATransform3DScale(t: CATransform3D, sx: CGFloat, sy: CGFloat, sz: CGFloat) + -> CATransform3D; + fn CATransform3DRotate(t: CATransform3D, angle: CGFloat, x: CGFloat, y: CGFloat, z: CGFloat) + -> CATransform3D; + fn CATransform3DConcat(a: CATransform3D, b: CATransform3D) -> CATransform3D; + fn CATransform3DInvert(t: CATransform3D) -> CATransform3D; + fn CATransform3DMakeAffineTransform(m: CGAffineTransform) -> CATransform3D; + fn CATransform3DIsAffine(t: CATransform3D) -> bool; + fn CATransform3DGetAffineTransform(t: CATransform3D) -> CGAffineTransform; +} + +// Miscellaneous structures in other frameworks. +// +// These should be moved elsewhere eventually. + +// CoreVideo/CVBase.h + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CVTimeStamp { + pub version: u32, + pub videoTimeScale: i32, + pub videoTime: i64, + pub hostTime: u64, + pub rateScalar: f64, + pub videoRefreshPeriod: i64, + pub smpteTime: CVSMPTETime, + pub flags: u64, + pub reserved: u64, +} + +pub type CVTimeStampFlags = u64; + +pub const kCVTimeStampVideoTimeValid: CVTimeStampFlags = 1 << 0; +pub const kCVTimeStampHostTimeValid: CVTimeStampFlags = 1 << 1; +pub const kCVTimeStampSMPTETimeValid: CVTimeStampFlags = 1 << 2; +pub const kCVTimeStampVideoRefreshPeriodValid: CVTimeStampFlags = 1 << 3; +pub const kCVTimeStampRateScalarValid: CVTimeStampFlags = 1 << 4; +pub const kCVTimeStampTopField: CVTimeStampFlags = 1 << 16; +pub const kCVTimeStampBottomField: CVTimeStampFlags = 1 << 17; +pub const kCVTimeStampVideoHostTimeValid: CVTimeStampFlags = + kCVTimeStampVideoTimeValid | kCVTimeStampHostTimeValid; +pub const kCVTimeStampIsInterlaced: CVTimeStampFlags = + kCVTimeStampTopField | kCVTimeStampBottomField; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CVSMPTETime { + pub subframes: i16, + pub subframeDivisor: i16, + pub counter: u32, + pub time_type: u32, + pub flags: u32, + pub hours: i16, + pub minutes: i16, + pub seconds: i16, + pub frames: i16, +} + +pub type CVSMPTETimeType = u32; + +pub const kCVSMPTETimeType24: CVSMPTETimeType = 0; +pub const kCVSMPTETimeType25: CVSMPTETimeType = 1; +pub const kCVSMPTETimeType30Drop: CVSMPTETimeType = 2; +pub const kCVSMPTETimeType30: CVSMPTETimeType = 3; +pub const kCVSMPTETimeType2997: CVSMPTETimeType = 4; +pub const kCVSMPTETimeType2997Drop: CVSMPTETimeType = 5; +pub const kCVSMPTETimeType60: CVSMPTETimeType = 6; +pub const kCVSMPTETimeType5994: CVSMPTETimeType = 7; + +pub type CVSMPTETimeFlags = u32; + +pub const kCVSMPTETimeValid: CVSMPTETimeFlags = 1 << 0; +pub const kCVSMPTETimeRunning: CVSMPTETimeFlags = 1 << 1; diff --git a/third_party/cargo/vendor/cocoa-0.18.5/tests/foundation.rs b/third_party/cargo/vendor/cocoa-0.18.5/tests/foundation.rs new file mode 100644 index 0000000..f1be870 --- /dev/null +++ b/third_party/cargo/vendor/cocoa-0.18.5/tests/foundation.rs @@ -0,0 +1,189 @@ +#[macro_use] +extern crate objc; +extern crate block; +extern crate cocoa; + +#[cfg(test)] +mod foundation { + mod nsstring { + use cocoa::foundation::NSString; + use cocoa::base::nil; + use std::slice; + use std::str; + + #[test] + fn test_utf8() { + let expected = "Iñtërnâtiônàlizætiøn"; + unsafe { + let built = NSString::alloc(nil).init_str(expected); + let bytes = built.UTF8String() as *const u8; + let objc_string = str::from_utf8(slice::from_raw_parts(bytes, built.len())) + .unwrap(); + assert!(objc_string.len() == expected.len()); + assert!(objc_string == expected); + } + } + + #[test] + fn test_string() { + let expected = "Hello World!"; + unsafe { + let built = NSString::alloc(nil).init_str(expected); + let bytes = built.UTF8String() as *const u8; + let objc_string = str::from_utf8(slice::from_raw_parts(bytes, built.len())) + .unwrap(); + assert!(objc_string.len() == expected.len()); + assert!(objc_string == expected); + } + } + + #[test] + fn test_length() { + let expected = "Hello!"; + unsafe { + let built = NSString::alloc(nil).init_str(expected); + assert!(built.len() == expected.len()); + } + } + + #[test] + fn test_append_by_appending_string() { + let initial_str = "Iñtërnâtiônàlizætiøn"; + let to_append = "_more_strings"; + let expected = concat!("Iñtërnâtiônàlizætiøn", "_more_strings"); + unsafe { + let built = NSString::alloc(nil).init_str(initial_str); + let built_to_append = NSString::alloc(nil).init_str(to_append); + let append_string = built.stringByAppendingString_(built_to_append); + let bytes = append_string.UTF8String() as *const u8; + let objc_string = str::from_utf8(slice::from_raw_parts(bytes, append_string.len())) + .unwrap(); + assert!(objc_string == expected); + } + } + } + + mod nsfastenumeration { + use std::str; + use std::slice; + use cocoa::foundation::{NSString, NSFastEnumeration}; + use cocoa::base::{id, nil}; + + #[test] + fn test_iter() { + unsafe { + let string = NSString::alloc(nil).init_str("this is a test string"); + let separator = NSString::alloc(nil).init_str(" "); + let components: id = msg_send![string, componentsSeparatedByString: separator]; + + let combined = components.iter() + .map(|s| { + let bytes = s.UTF8String() as *const u8; + str::from_utf8(slice::from_raw_parts(bytes, s.len())).unwrap() + }) + .fold(String::new(), |mut acc, s| { + acc.push_str(s); + acc + }); + + assert_eq!(combined, "thisisateststring"); + } + } + + #[test] + #[should_panic] + fn test_mutation() { + unsafe { + let string = NSString::alloc(nil).init_str("this is a test string"); + let separator = NSString::alloc(nil).init_str(" "); + let components: id = msg_send![string, componentsSeparatedByString: separator]; + let mut_components: id = msg_send![components, mutableCopy]; + let mut iter = mut_components.iter(); + iter.next(); + let () = msg_send![mut_components, removeObjectAtIndex:1]; + iter.next(); + } + } + } + + mod nsdictionary { + use block::ConcreteBlock; + use cocoa::foundation::{NSArray, NSComparisonResult, NSDictionary, NSFastEnumeration, + NSString}; + use cocoa::base::{id, nil}; + + #[test] + fn test_get() { + const KEY: &'static str = "The key"; + const VALUE: &'static str = "Some value"; + unsafe { + let key = NSString::alloc(nil).init_str(KEY); + let value = NSString::alloc(nil).init_str(VALUE); + let dict = NSDictionary::dictionaryWithObject_forKey_(nil, value, key); + + let retrieved_value = dict.objectForKey_(key); + assert!(retrieved_value.isEqualToString(VALUE)); + } + } + + #[test] + fn test_iter() { + let mkstr = |s| unsafe { NSString::alloc(nil).init_str(s) }; + let keys = vec!["a", "b", "c", "d", "e", "f"]; + let objects = vec!["1", "2", "3", "4", "5", "6"]; + unsafe { + use std::{slice, str}; + use std::cmp::{Ord, Ordering}; + + let keys_raw_vec = keys.clone().into_iter().map(&mkstr).collect::>(); + let objs_raw_vec = objects.clone().into_iter().map(&mkstr).collect::>(); + + let keys_array = NSArray::arrayWithObjects(nil, &keys_raw_vec); + let objs_array = NSArray::arrayWithObjects(nil, &objs_raw_vec); + + let dict = + NSDictionary::dictionaryWithObjects_forKeys_(nil, objs_array, keys_array); + + // NSDictionary does not store its contents in order of insertion, so ask for + // sorted iterators to ensure that each item is the same as its counterpart in + // the vector. + + // First test cocoa sorting... + let mut comparator = ConcreteBlock::new(|s0: id, s1: id| { + let (bytes0, len0) = (s0.UTF8String() as *const u8, s0.len()); + let (bytes1, len1) = (s1.UTF8String() as *const u8, s1.len()); + let (s0, s1) = (str::from_utf8(slice::from_raw_parts(bytes0, len0)).unwrap(), + str::from_utf8(slice::from_raw_parts(bytes1, len1)).unwrap()); + let (c0, c1) = (s0.chars().next().unwrap(), s1.chars().next().unwrap()); + match c0.cmp(&c1) { + Ordering::Less => NSComparisonResult::NSOrderedAscending, + Ordering::Equal => NSComparisonResult::NSOrderedSame, + Ordering::Greater => NSComparisonResult::NSOrderedDescending, + } + }); + + let associated_iter = keys.iter().zip(objects.iter()); + for (k_id, (k, v)) in dict.keysSortedByValueUsingComparator_(&mut *comparator) + .iter() + .zip(associated_iter) { + assert!(k_id.isEqualToString(k)); + let v_id = dict.objectForKey_(k_id); + assert!(v_id.isEqualToString(v)); + } + + // Then use rust sorting + let mut keys_arr = dict.allKeys().iter().collect::>(); + keys_arr.sort(); + for (k0, k1) in keys_arr.into_iter().zip(keys.iter()) { + assert!(k0.isEqualToString(k1)); + } + + let mut objects_arr = dict.allValues().iter().collect::>(); + objects_arr.sort(); + for (v0, v1) in objects_arr.into_iter().zip(objects.iter()) { + assert!(v0.isEqualToString(v1)); + } + } + } + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/.cargo-checksum.json b/third_party/cargo/vendor/core-foundation-0.6.4/.cargo-checksum.json new file mode 100644 index 0000000..2983bd4 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"fae948ff1642562b5418d560bdf07378973a71245bf6305550f0fc0eaa6a94cf","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","src/array.rs":"221e81de15d95ca453df39466ba65faf879f2923202145958dfcebe63bfef97f","src/attributed_string.rs":"e6b32d673fa957611dbac2480675fab3c697fca8043077f2015f0a0801b20425","src/base.rs":"394764fa59518507fd8d53024b9574ab914eb856c1a873e6b1b4d84cdcde1c31","src/boolean.rs":"f5b4d295aaf6cc3681212afebeae2974c5d551125badcc066e6089ac0d2a0873","src/bundle.rs":"7e0fbe7032c8658ba5751a236eaaaa4b031fef43daf0be3aa229de4beb83b52a","src/data.rs":"a1d7e6430c745731fc7b2aee49af9f14e79c8a288951c82ea6507689a3356af8","src/date.rs":"a02f6cca7b6e8fbabc7713177429012658dba5146556e14a08e7baaf81958d83","src/dictionary.rs":"ed8080eb00507e342521fb2c513a83c5706e883c3f8d67d8f38e9a0ed685c7eb","src/error.rs":"22c21087d9c2c103d1bcb2c4af33b684317bbda5d4747902e510d410f8c1a14b","src/filedescriptor.rs":"f01da404e42760a50d91a43af648e781916c0a10c23753bea94f0f67bdc4d00c","src/lib.rs":"174cefb465af31d86e878ebcb5fb44cf3faed5bf3d568e9ada33136bd4bf3ef0","src/number.rs":"5a6cc9036c156e7e9d787864dd671087677abf4175cd840cbf123ccd89abcafe","src/propertylist.rs":"557ff9c346fbc70d19a887e0ce9977b84066f5d4bb6ba53ece8b733a5f0526e3","src/runloop.rs":"98334ee796cea1634a5a9baf59d62f02c25b718d45baab5230a5cc14cb2ee6d5","src/set.rs":"c61d7cacdbe7c3c69b2add3d2f1721960f6df710ef4db6a442cd8b05e8e929f3","src/string.rs":"28cead4283dfeeeb1c8c8bcf855823ed4b952e3a54cb8ca1c8f5f9a25d77bc0b","src/timezone.rs":"65859378232ee55f04bc4544b88f5dbc21f5db01bd16f2df3e82136ee3ce26b4","src/url.rs":"dd1798276b273654fb3f6c9ebb871548ca40c7f7b0bc2b94fdf4a7291f6dc601","src/uuid.rs":"c3457e43fc22ba0f3fcab3ee8108500585ba005dbcbfa7edad0d389701ddf379","tests/use_macro_outside_crate.rs":"ed5e74ac9e988f2609c0b785189f1e6368d693f6401603ad065521f3ab51df94"},"package":"25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"} \ No newline at end of file diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/BUILD b/third_party/cargo/vendor/core-foundation-0.6.4/BUILD new file mode 100644 index 0000000..2e2075a --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/BUILD @@ -0,0 +1,45 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "core_foundation", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/core-foundation-sys-0.6.2:core_foundation_sys", + "//third_party/cargo/vendor/libc-0.2.66:libc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.4", + crate_features = [ + ], +) + +# Unsupported target "use_macro_outside_crate" with type "test" omitted diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/Cargo.toml b/third_party/cargo/vendor/core-foundation-0.6.4/Cargo.toml new file mode 100644 index 0000000..b9bcf07 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/Cargo.toml @@ -0,0 +1,41 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "core-foundation" +version = "0.6.4" +authors = ["The Servo Project Developers"] +description = "Bindings to Core Foundation for macOS" +homepage = "https://github.com/servo/core-foundation-rs" +keywords = ["macos", "framework", "objc"] +categories = ["os::macos-apis"] +license = "MIT / Apache-2.0" +repository = "https://github.com/servo/core-foundation-rs" +[dependencies.chrono] +version = "0.4" +optional = true + +[dependencies.core-foundation-sys] +version = "0.6.1" + +[dependencies.libc] +version = "0.2" + +[dependencies.uuid] +version = "0.5" +optional = true + +[features] +mac_os_10_7_support = ["core-foundation-sys/mac_os_10_7_support"] +mac_os_10_8_features = ["core-foundation-sys/mac_os_10_8_features"] +with-chrono = ["chrono"] +with-uuid = ["uuid"] diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/LICENSE-APACHE b/third_party/cargo/vendor/core-foundation-0.6.4/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/LICENSE-MIT b/third_party/cargo/vendor/core-foundation-0.6.4/LICENSE-MIT new file mode 100644 index 0000000..807526f --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2012-2013 Mozilla Foundation + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/array.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/array.rs new file mode 100644 index 0000000..f13ea19 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/array.rs @@ -0,0 +1,286 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Heterogeneous immutable arrays. + +pub use core_foundation_sys::array::*; +pub use core_foundation_sys::base::CFIndex; +use core_foundation_sys::base::{CFTypeRef, CFRelease, kCFAllocatorDefault}; +use std::mem; +use std::marker::PhantomData; +use std::os::raw::c_void; +use std::ptr; +use ConcreteCFType; + +use base::{CFIndexConvertible, TCFType, CFRange}; +use base::{FromVoid, ItemRef}; + +/// A heterogeneous immutable array. +pub struct CFArray(CFArrayRef, PhantomData); + +impl Drop for CFArray { + fn drop(&mut self) { + unsafe { CFRelease(self.as_CFTypeRef()) } + } +} + +pub struct CFArrayIterator<'a, T: 'a> { + array: &'a CFArray, + index: CFIndex, + len: CFIndex, +} + +impl<'a, T: FromVoid> Iterator for CFArrayIterator<'a, T> { + type Item = ItemRef<'a, T>; + + fn next(&mut self) -> Option> { + if self.index >= self.len { + None + } else { + let value = unsafe { self.array.get_unchecked(self.index) }; + self.index += 1; + Some(value) + } + } +} + +impl<'a, T: FromVoid> ExactSizeIterator for CFArrayIterator<'a, T> { + fn len(&self) -> usize { + (self.array.len() - self.index) as usize + } +} + +impl_TCFType!(CFArray, CFArrayRef, CFArrayGetTypeID); +impl_CFTypeDescription!(CFArray); + +unsafe impl ConcreteCFType for CFArray<*const c_void> {} + +impl CFArray { + /// Creates a new `CFArray` with the given elements, which must implement `Copy`. + pub fn from_copyable(elems: &[T]) -> CFArray where T: Copy { + unsafe { + let array_ref = CFArrayCreate(kCFAllocatorDefault, + elems.as_ptr() as *const *const c_void, + elems.len().to_CFIndex(), + ptr::null()); + TCFType::wrap_under_create_rule(array_ref) + } + } + + /// Creates a new `CFArray` with the given elements, which must be `CFType` objects. + pub fn from_CFTypes(elems: &[T]) -> CFArray where T: TCFType { + unsafe { + let elems: Vec = elems.iter().map(|elem| elem.as_CFTypeRef()).collect(); + let array_ref = CFArrayCreate(kCFAllocatorDefault, + elems.as_ptr(), + elems.len().to_CFIndex(), + &kCFTypeArrayCallBacks); + TCFType::wrap_under_create_rule(array_ref) + } + } + + #[inline] + pub fn to_untyped(&self) -> CFArray { + unsafe { CFArray::wrap_under_get_rule(self.0) } + } + + /// Returns the same array, but with the type reset to void pointers. + /// Equal to `to_untyped`, but is faster since it does not increment the retain count. + #[inline] + pub fn into_untyped(self) -> CFArray { + let reference = self.0; + mem::forget(self); + unsafe { CFArray::wrap_under_create_rule(reference) } + } + + /// Iterates over the elements of this `CFArray`. + /// + /// Careful; the loop body must wrap the reference properly. Generally, when array elements are + /// Core Foundation objects (not always true), they need to be wrapped with + /// `TCFType::wrap_under_get_rule()`. + #[inline] + pub fn iter<'a>(&'a self) -> CFArrayIterator<'a, T> { + CFArrayIterator { + array: self, + index: 0, + len: self.len(), + } + } + + #[inline] + pub fn len(&self) -> CFIndex { + unsafe { + CFArrayGetCount(self.0) + } + } + + #[inline] + pub unsafe fn get_unchecked<'a>(&'a self, index: CFIndex) -> ItemRef<'a, T> where T: FromVoid { + T::from_void(CFArrayGetValueAtIndex(self.0, index)) + } + + #[inline] + pub fn get<'a>(&'a self, index: CFIndex) -> Option> where T: FromVoid { + if index < self.len() { + Some(unsafe { T::from_void(CFArrayGetValueAtIndex(self.0, index)) } ) + } else { + None + } + } + + pub fn get_values(&self, range: CFRange) -> Vec<*const c_void> { + let mut vec = Vec::with_capacity(range.length as usize); + unsafe { + CFArrayGetValues(self.0, range, vec.as_mut_ptr()); + vec.set_len(range.length as usize); + vec + } + } + + pub fn get_all_values(&self) -> Vec<*const c_void> { + self.get_values(CFRange { + location: 0, + length: self.len() + }) + } +} + +impl<'a, T: FromVoid> IntoIterator for &'a CFArray { + type Item = ItemRef<'a, T>; + type IntoIter = CFArrayIterator<'a, T>; + + fn into_iter(self) -> CFArrayIterator<'a, T> { + self.iter() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::mem; + use base::CFType; + + #[test] + fn to_untyped_correct_retain_count() { + let array = CFArray::::from_CFTypes(&[]); + assert_eq!(array.retain_count(), 1); + + let untyped_array = array.to_untyped(); + assert_eq!(array.retain_count(), 2); + assert_eq!(untyped_array.retain_count(), 2); + + mem::drop(array); + assert_eq!(untyped_array.retain_count(), 1); + } + + #[test] + fn into_untyped() { + let array = CFArray::::from_CFTypes(&[]); + let array2 = array.to_untyped(); + assert_eq!(array.retain_count(), 2); + + let untyped_array = array.into_untyped(); + assert_eq!(untyped_array.retain_count(), 2); + + mem::drop(array2); + assert_eq!(untyped_array.retain_count(), 1); + } + + #[test] + fn borrow() { + use string::CFString; + + let string = CFString::from_static_string("bar"); + assert_eq!(string.retain_count(), 1); + let x; + { + let arr: CFArray = CFArray::from_CFTypes(&[string]); + { + let p = arr.get(0).unwrap(); + assert_eq!(p.retain_count(), 1); + } + { + x = arr.get(0).unwrap().clone(); + assert_eq!(x.retain_count(), 2); + assert_eq!(x.to_string(), "bar"); + } + } + assert_eq!(x.retain_count(), 1); + } + + #[test] + fn iter_untyped_array() { + use string::{CFString, CFStringRef}; + use base::TCFTypeRef; + + let cf_string = CFString::from_static_string("bar"); + let array: CFArray = CFArray::from_CFTypes(&[cf_string.clone()]).into_untyped(); + + let cf_strings = array.iter().map(|ptr| { + unsafe { CFString::wrap_under_get_rule(CFStringRef::from_void_ptr(*ptr)) } + }).collect::>(); + let strings = cf_strings.iter().map(|s| s.to_string()).collect::>(); + assert_eq!(cf_string.retain_count(), 3); + assert_eq!(&strings[..], &["bar"]); + } + + #[test] + fn should_box_and_unbox() { + use number::CFNumber; + + let n0 = CFNumber::from(0); + let n1 = CFNumber::from(1); + let n2 = CFNumber::from(2); + let n3 = CFNumber::from(3); + let n4 = CFNumber::from(4); + let n5 = CFNumber::from(5); + + let arr = CFArray::from_CFTypes(&[ + n0.as_CFType(), + n1.as_CFType(), + n2.as_CFType(), + n3.as_CFType(), + n4.as_CFType(), + n5.as_CFType(), + ]); + + assert_eq!( + arr.get_all_values(), + &[ + n0.as_CFTypeRef(), + n1.as_CFTypeRef(), + n2.as_CFTypeRef(), + n3.as_CFTypeRef(), + n4.as_CFTypeRef(), + n5.as_CFTypeRef() + ] + ); + + let mut sum = 0; + + let mut iter = arr.iter(); + assert_eq!(iter.len(), 6); + assert!(iter.next().is_some()); + assert_eq!(iter.len(), 5); + + for elem in iter { + let number: CFNumber = elem.downcast::().unwrap(); + sum += number.to_i64().unwrap() + } + + assert_eq!(sum, 15); + + for elem in arr.iter() { + let number: CFNumber = elem.downcast::().unwrap(); + sum += number.to_i64().unwrap() + } + + assert_eq!(sum, 30); + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/attributed_string.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/attributed_string.rs new file mode 100644 index 0000000..e0fa576 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/attributed_string.rs @@ -0,0 +1,85 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub use core_foundation_sys::attributed_string::*; + +use base::TCFType; +use core_foundation_sys::base::{CFIndex, CFRange, kCFAllocatorDefault}; +use std::ptr::null; +use string::{CFString, CFStringRef}; + +declare_TCFType!{ + CFAttributedString, CFAttributedStringRef +} +impl_TCFType!(CFAttributedString, CFAttributedStringRef, CFAttributedStringGetTypeID); + +impl CFAttributedString { + #[inline] + pub fn new(string: &CFString) -> Self { + unsafe { + let astr_ref = CFAttributedStringCreate( + kCFAllocatorDefault, string.as_concrete_TypeRef(), null()); + + CFAttributedString::wrap_under_create_rule(astr_ref) + } + } + + #[inline] + pub fn char_len(&self) -> CFIndex { + unsafe { + CFAttributedStringGetLength(self.0) + } + } +} + +declare_TCFType!{ + CFMutableAttributedString, CFMutableAttributedStringRef +} +impl_TCFType!(CFMutableAttributedString, CFMutableAttributedStringRef, CFMutableAttributedStringGetTypeID); + +impl CFMutableAttributedString { + #[inline] + pub fn new() -> Self { + unsafe { + let astr_ref = CFAttributedStringCreateMutable( + kCFAllocatorDefault, 0); + + CFMutableAttributedString::wrap_under_create_rule(astr_ref) + } + } + + #[inline] + pub fn char_len(&self) -> CFIndex { + unsafe { + CFAttributedStringGetLength(self.0) + } + } + + #[inline] + pub fn replace_str(&mut self, string: &CFString, range: CFRange) { + unsafe { + CFAttributedStringReplaceString( + self.0, range, string.as_concrete_TypeRef()); + } + } + + #[inline] + pub fn set_attribute(&mut self, range: CFRange, name: CFStringRef, value: T) { + unsafe { + CFAttributedStringSetAttribute( + self.0, range, name, value.as_CFTypeRef()); + } + } +} + +impl Default for CFMutableAttributedString { + fn default() -> Self { + Self::new() + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/base.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/base.rs new file mode 100644 index 0000000..1a09ee6 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/base.rs @@ -0,0 +1,450 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std; +use std::fmt; +use std::marker::PhantomData; +use std::mem; +use std::mem::ManuallyDrop; +use std::ops::{Deref, DerefMut}; +use std::os::raw::c_void; + +pub use core_foundation_sys::base::*; + +use string::CFString; +use ConcreteCFType; + +pub trait CFIndexConvertible { + /// Always use this method to construct a `CFIndex` value. It performs bounds checking to + /// ensure the value is in range. + fn to_CFIndex(self) -> CFIndex; +} + +impl CFIndexConvertible for usize { + #[inline] + fn to_CFIndex(self) -> CFIndex { + let max_CFIndex = CFIndex::max_value(); + if self > (max_CFIndex as usize) { + panic!("value out of range") + } + self as CFIndex + } +} + +declare_TCFType!{ + /// Superclass of all Core Foundation objects. + CFType, CFTypeRef +} + +impl CFType { + /// Try to downcast the `CFType` to a subclass. Checking if the instance is the + /// correct subclass happens at runtime and `None` is returned if it is not the correct type. + /// Works similar to [`Box::downcast`] and [`CFPropertyList::downcast`]. + /// + /// # Examples + /// + /// ``` + /// # use core_foundation::string::CFString; + /// # use core_foundation::boolean::CFBoolean; + /// # use core_foundation::base::{CFType, TCFType}; + /// # + /// // Create a string. + /// let string: CFString = CFString::from_static_string("FooBar"); + /// // Cast it up to a CFType. + /// let cf_type: CFType = string.as_CFType(); + /// // Cast it down again. + /// assert_eq!(cf_type.downcast::().unwrap().to_string(), "FooBar"); + /// // Casting it to some other type will yield `None` + /// assert!(cf_type.downcast::().is_none()); + /// ``` + /// + /// ```compile_fail + /// # use core_foundation::array::CFArray; + /// # use core_foundation::base::TCFType; + /// # use core_foundation::boolean::CFBoolean; + /// # use core_foundation::string::CFString; + /// # + /// let boolean_array = CFArray::from_CFTypes(&[CFBoolean::true_value()]).into_CFType(); + /// + /// // This downcast is not allowed and causes compiler error, since it would cause undefined + /// // behavior to access the elements of the array as a CFString: + /// let invalid_string_array = boolean_array + /// .downcast_into::>() + /// .unwrap(); + /// ``` + /// + /// [`Box::downcast`]: https://doc.rust-lang.org/std/boxed/struct.Box.html#method.downcast + /// [`CFPropertyList::downcast`]: ../propertylist/struct.CFPropertyList.html#method.downcast + #[inline] + pub fn downcast(&self) -> Option { + if self.instance_of::() { + unsafe { + let reference = T::Ref::from_void_ptr(self.0); + Some(T::wrap_under_get_rule(reference)) + } + } else { + None + } + } + + /// Similar to [`downcast`], but consumes self and can thus avoid touching the retain count. + /// + /// [`downcast`]: #method.downcast + #[inline] + pub fn downcast_into(self) -> Option { + if self.instance_of::() { + unsafe { + let reference = T::Ref::from_void_ptr(self.0); + mem::forget(self); + Some(T::wrap_under_create_rule(reference)) + } + } else { + None + } + } +} + +impl fmt::Debug for CFType { + /// Formats the value using [`CFCopyDescription`]. + /// + /// [`CFCopyDescription`]: https://developer.apple.com/documentation/corefoundation/1521252-cfcopydescription?language=objc + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let desc = unsafe { + CFString::wrap_under_create_rule(CFCopyDescription(self.0)) + }; + desc.fmt(f) + } +} + +impl Clone for CFType { + #[inline] + fn clone(&self) -> CFType { + unsafe { + TCFType::wrap_under_get_rule(self.0) + } + } +} + +impl PartialEq for CFType { + #[inline] + fn eq(&self, other: &CFType) -> bool { + unsafe { + CFEqual(self.as_CFTypeRef(), other.as_CFTypeRef()) != 0 + } + } +} + +declare_TCFType!(CFAllocator, CFAllocatorRef); +impl_TCFType!(CFAllocator, CFAllocatorRef, CFAllocatorGetTypeID); + +impl CFAllocator { + #[inline] + pub fn new(mut context: CFAllocatorContext) -> CFAllocator { + unsafe { + let allocator_ref = CFAllocatorCreate(kCFAllocatorDefault, &mut context); + TCFType::wrap_under_create_rule(allocator_ref) + } + } +} + + +/// All Core Foundation types implement this trait. The associated type `Ref` specifies the +/// associated Core Foundation type: e.g. for `CFType` this is `CFTypeRef`; for `CFArray` this is +/// `CFArrayRef`. +/// +/// Most structs that implement this trait will do so via the [`impl_TCFType`] macro. +/// +/// [`impl_TCFType`]: ../macro.impl_TCFType.html +pub trait TCFType { + /// The reference type wrapped inside this type. + type Ref: TCFTypeRef; + + /// Returns the object as its concrete TypeRef. + fn as_concrete_TypeRef(&self) -> Self::Ref; + + /// Returns an instance of the object, wrapping the underlying `CFTypeRef` subclass. Use this + /// when following Core Foundation's "Create Rule". The reference count is *not* bumped. + unsafe fn wrap_under_create_rule(obj: Self::Ref) -> Self; + + /// Returns the type ID for this class. + fn type_id() -> CFTypeID; + + /// Returns the object as a wrapped `CFType`. The reference count is incremented by one. + #[inline] + fn as_CFType(&self) -> CFType { + unsafe { + TCFType::wrap_under_get_rule(self.as_CFTypeRef()) + } + } + + /// Returns the object as a wrapped `CFType`. Consumes self and avoids changing the reference + /// count. + #[inline] + fn into_CFType(self) -> CFType + where + Self: Sized, + { + let reference = self.as_CFTypeRef(); + mem::forget(self); + unsafe { TCFType::wrap_under_create_rule(reference) } + } + + /// Returns the object as a raw `CFTypeRef`. The reference count is not adjusted. + fn as_CFTypeRef(&self) -> CFTypeRef; + + /// Returns an instance of the object, wrapping the underlying `CFTypeRef` subclass. Use this + /// when following Core Foundation's "Get Rule". The reference count *is* bumped. + unsafe fn wrap_under_get_rule(reference: Self::Ref) -> Self; + + /// Returns the reference count of the object. It is unwise to do anything other than test + /// whether the return value of this method is greater than zero. + #[inline] + fn retain_count(&self) -> CFIndex { + unsafe { + CFGetRetainCount(self.as_CFTypeRef()) + } + } + + /// Returns the type ID of this object. + #[inline] + fn type_of(&self) -> CFTypeID { + unsafe { + CFGetTypeID(self.as_CFTypeRef()) + } + } + + /// Writes a debugging version of this object on standard error. + fn show(&self) { + unsafe { + CFShow(self.as_CFTypeRef()) + } + } + + /// Returns true if this value is an instance of another type. + #[inline] + fn instance_of(&self) -> bool { + self.type_of() == OtherCFType::type_id() + } +} + +impl TCFType for CFType { + type Ref = CFTypeRef; + + #[inline] + fn as_concrete_TypeRef(&self) -> CFTypeRef { + self.0 + } + + #[inline] + unsafe fn wrap_under_get_rule(reference: CFTypeRef) -> CFType { + let reference: CFTypeRef = CFRetain(reference); + TCFType::wrap_under_create_rule(reference) + } + + #[inline] + fn as_CFTypeRef(&self) -> CFTypeRef { + self.as_concrete_TypeRef() + } + + #[inline] + unsafe fn wrap_under_create_rule(obj: CFTypeRef) -> CFType { + CFType(obj) + } + + #[inline] + fn type_id() -> CFTypeID { + // FIXME(pcwalton): Is this right? + 0 + } +} + +/// A reference to an element inside a container +pub struct ItemRef<'a, T: 'a>(ManuallyDrop, PhantomData<&'a T>); + +impl<'a, T> Deref for ItemRef<'a, T> { + type Target = T; + + fn deref(&self) -> &T { + &self.0 + } +} + +impl<'a, T: fmt::Debug> fmt::Debug for ItemRef<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + self.0.fmt(f) + } +} + +impl<'a, T: PartialEq> PartialEq for ItemRef<'a, T> { + fn eq(&self, other: &Self) -> bool { + self.0.eq(&other.0) + } +} + +/// A reference to a mutable element inside a container +pub struct ItemMutRef<'a, T: 'a>(ManuallyDrop, PhantomData<&'a T>); + +impl<'a, T> Deref for ItemMutRef<'a, T> { + type Target = T; + + fn deref(&self) -> &T { + &self.0 + } +} + +impl<'a, T> DerefMut for ItemMutRef<'a, T> { + fn deref_mut(&mut self) -> &mut T { + &mut self.0 + } +} + +impl<'a, T: fmt::Debug> fmt::Debug for ItemMutRef<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + self.0.fmt(f) + } +} + +impl<'a, T: PartialEq> PartialEq for ItemMutRef<'a, T> { + fn eq(&self, other: &Self) -> bool { + self.0.eq(&other.0) + } +} + +/// A trait describing how to convert from the stored *mut c_void to the desired T +pub unsafe trait FromMutVoid { + unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, Self> where Self: std::marker::Sized; +} + +unsafe impl FromMutVoid for u32 { + unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, Self> { + ItemMutRef(ManuallyDrop::new(x as u32), PhantomData) + } +} + +unsafe impl FromMutVoid for *const c_void { + unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, Self> { + ItemMutRef(ManuallyDrop::new(x), PhantomData) + } +} + +unsafe impl FromMutVoid for T { + unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, Self> { + ItemMutRef(ManuallyDrop::new(TCFType::wrap_under_create_rule(T::Ref::from_void_ptr(x))), PhantomData) + } +} + +/// A trait describing how to convert from the stored *const c_void to the desired T +pub unsafe trait FromVoid { + unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self> where Self: std::marker::Sized; +} + +unsafe impl FromVoid for u32 { + unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self> { + // Functions like CGFontCopyTableTags treat the void*'s as u32's + // so we convert by casting directly + ItemRef(ManuallyDrop::new(x as u32), PhantomData) + } +} + +unsafe impl FromVoid for *const c_void { + unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self> { + ItemRef(ManuallyDrop::new(x), PhantomData) + } +} + +unsafe impl FromVoid for T { + unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self> { + ItemRef(ManuallyDrop::new(TCFType::wrap_under_create_rule(T::Ref::from_void_ptr(x))), PhantomData) + } +} + +/// A trait describing how to convert from the stored *const c_void to the desired T +pub unsafe trait ToVoid { + fn to_void(&self) -> *const c_void; +} + +unsafe impl ToVoid<*const c_void> for *const c_void { + fn to_void(&self) -> *const c_void { + *self + } +} + +unsafe impl<'a> ToVoid for &'a CFType { + fn to_void(&self) -> *const ::std::os::raw::c_void { + self.as_concrete_TypeRef().as_void_ptr() + } +} + +unsafe impl ToVoid for CFType { + fn to_void(&self) -> *const ::std::os::raw::c_void { + self.as_concrete_TypeRef().as_void_ptr() + } +} + +unsafe impl ToVoid for CFTypeRef { + fn to_void(&self) -> *const ::std::os::raw::c_void { + self.as_void_ptr() + } +} + + +#[cfg(test)] +mod tests { + use super::*; + use std::mem; + use boolean::CFBoolean; + + #[test] + fn cftype_instance_of() { + let string = CFString::from_static_string("foo"); + let cftype = string.as_CFType(); + + assert!(cftype.instance_of::()); + assert!(!cftype.instance_of::()); + } + + #[test] + fn as_cftype_retain_count() { + let string = CFString::from_static_string("bar"); + assert_eq!(string.retain_count(), 1); + let cftype = string.as_CFType(); + assert_eq!(cftype.retain_count(), 2); + mem::drop(string); + assert_eq!(cftype.retain_count(), 1); + } + + #[test] + fn into_cftype_retain_count() { + let string = CFString::from_static_string("bar"); + assert_eq!(string.retain_count(), 1); + let cftype = string.into_CFType(); + assert_eq!(cftype.retain_count(), 1); + } + + #[test] + fn as_cftype_and_downcast() { + let string = CFString::from_static_string("bar"); + let cftype = string.as_CFType(); + let string2 = cftype.downcast::().unwrap(); + assert_eq!(string2.to_string(), "bar"); + + assert_eq!(string.retain_count(), 3); + assert_eq!(cftype.retain_count(), 3); + assert_eq!(string2.retain_count(), 3); + } + + #[test] + fn into_cftype_and_downcast_into() { + let string = CFString::from_static_string("bar"); + let cftype = string.into_CFType(); + let string2 = cftype.downcast_into::().unwrap(); + assert_eq!(string2.to_string(), "bar"); + assert_eq!(string2.retain_count(), 1); + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/boolean.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/boolean.rs new file mode 100644 index 0000000..8c13b90 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/boolean.rs @@ -0,0 +1,70 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A Boolean type. + +pub use core_foundation_sys::number::{CFBooleanRef, CFBooleanGetTypeID, kCFBooleanTrue, kCFBooleanFalse}; + +use base::TCFType; + + +declare_TCFType!{ + /// A Boolean type. + /// + /// FIXME(pcwalton): Should be a newtype struct, but that fails due to a Rust compiler bug. + CFBoolean, CFBooleanRef +} +impl_TCFType!(CFBoolean, CFBooleanRef, CFBooleanGetTypeID); +impl_CFTypeDescription!(CFBoolean); + +impl CFBoolean { + pub fn true_value() -> CFBoolean { + unsafe { + TCFType::wrap_under_get_rule(kCFBooleanTrue) + } + } + + pub fn false_value() -> CFBoolean { + unsafe { + TCFType::wrap_under_get_rule(kCFBooleanFalse) + } + } +} + +impl From for CFBoolean { + fn from(value: bool) -> CFBoolean { + if value { + CFBoolean::true_value() + } else { + CFBoolean::false_value() + } + } +} + +impl From for bool { + fn from(value: CFBoolean) -> bool { + value.0 == unsafe { kCFBooleanTrue } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn to_and_from_bool() { + let b_false = CFBoolean::from(false); + let b_true = CFBoolean::from(true); + assert_ne!(b_false, b_true); + assert_eq!(b_false, CFBoolean::false_value()); + assert_eq!(b_true, CFBoolean::true_value()); + assert!(!bool::from(b_false)); + assert!(bool::from(b_true)); + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/bundle.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/bundle.rs new file mode 100644 index 0000000..f23f9ae --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/bundle.rs @@ -0,0 +1,141 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Core Foundation Bundle Type + +pub use core_foundation_sys::bundle::*; +use core_foundation_sys::base::kCFAllocatorDefault; + +use base::{CFType, TCFType}; +use url::CFURL; +use dictionary::CFDictionary; +use std::os::raw::c_void; +use string::CFString; + +declare_TCFType!{ + /// A Bundle type. + CFBundle, CFBundleRef +} +impl_TCFType!(CFBundle, CFBundleRef, CFBundleGetTypeID); + +impl CFBundle { + pub fn new(bundleURL: CFURL) -> Option { + unsafe { + let bundle_ref = CFBundleCreate(kCFAllocatorDefault, bundleURL.as_concrete_TypeRef()); + if bundle_ref.is_null() { + None + } else { + Some(TCFType::wrap_under_create_rule(bundle_ref)) + } + } + } + + pub fn bundle_with_identifier(identifier: CFString) -> Option { + unsafe { + let bundle_ref = CFBundleGetBundleWithIdentifier(identifier.as_concrete_TypeRef()); + if bundle_ref.is_null() { + None + } else { + Some(TCFType::wrap_under_get_rule(bundle_ref)) + } + } + } + + pub fn function_pointer_for_name(&self, function_name: CFString) -> *const c_void { + unsafe { + CFBundleGetFunctionPointerForName(self.as_concrete_TypeRef(), + function_name.as_concrete_TypeRef()) + } + } + + pub fn main_bundle() -> CFBundle { + unsafe { + let bundle_ref = CFBundleGetMainBundle(); + TCFType::wrap_under_get_rule(bundle_ref) + } + } + + pub fn info_dictionary(&self) -> CFDictionary { + unsafe { + let info_dictionary = CFBundleGetInfoDictionary(self.0); + TCFType::wrap_under_get_rule(info_dictionary) + } + } + + pub fn executable_url(&self) -> Option { + unsafe { + let exe_url = CFBundleCopyExecutableURL(self.0); + if exe_url.is_null() { + None + } else { + Some(TCFType::wrap_under_create_rule(exe_url)) + } + } + } + + pub fn private_frameworks_url(&self) -> Option { + unsafe { + let fw_url = CFBundleCopyPrivateFrameworksURL(self.0); + if fw_url.is_null() { + None + } else { + Some(TCFType::wrap_under_create_rule(fw_url)) + } + } + } +} + + +#[test] +fn safari_executable_url() { + use string::CFString; + use url::{CFURL, kCFURLPOSIXPathStyle}; + + let cfstr_path = CFString::from_static_string("/Applications/Safari.app"); + let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true); + let cfurl_executable = CFBundle::new(cfurl_path) + .expect("Safari not present") + .executable_url(); + assert!(cfurl_executable.is_some()); + assert_eq!(cfurl_executable + .unwrap() + .absolute() + .get_file_system_path(kCFURLPOSIXPathStyle) + .to_string(), + "/Applications/Safari.app/Contents/MacOS/Safari"); +} + +#[test] +fn safari_private_frameworks_url() { + use string::CFString; + use url::{CFURL, kCFURLPOSIXPathStyle}; + + let cfstr_path = CFString::from_static_string("/Applications/Safari.app"); + let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true); + let cfurl_executable = CFBundle::new(cfurl_path) + .expect("Safari not present") + .private_frameworks_url(); + assert!(cfurl_executable.is_some()); + assert_eq!(cfurl_executable + .unwrap() + .absolute() + .get_file_system_path(kCFURLPOSIXPathStyle) + .to_string(), + "/Applications/Safari.app/Contents/Frameworks"); +} + +#[test] +fn non_existant_bundle() { + use string::CFString; + use url::{CFURL, kCFURLPOSIXPathStyle}; + + let cfstr_path = CFString::from_static_string("/usr/local/foo"); + let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true); + assert!(CFBundle::new(cfurl_path).is_none()); +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/data.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/data.rs new file mode 100644 index 0000000..2b5010a --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/data.rs @@ -0,0 +1,63 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Core Foundation byte buffers. + +pub use core_foundation_sys::data::*; +use core_foundation_sys::base::CFIndex; +use core_foundation_sys::base::{kCFAllocatorDefault}; +use std::ops::Deref; +use std::slice; + +use base::{CFIndexConvertible, TCFType}; + + +declare_TCFType!{ + /// A byte buffer. + CFData, CFDataRef +} +impl_TCFType!(CFData, CFDataRef, CFDataGetTypeID); +impl_CFTypeDescription!(CFData); + +impl CFData { + pub fn from_buffer(buffer: &[u8]) -> CFData { + unsafe { + let data_ref = CFDataCreate(kCFAllocatorDefault, + buffer.as_ptr(), + buffer.len().to_CFIndex()); + TCFType::wrap_under_create_rule(data_ref) + } + } + + /// Returns a pointer to the underlying bytes in this data. Note that this byte buffer is + /// read-only. + #[inline] + pub fn bytes<'a>(&'a self) -> &'a [u8] { + unsafe { + slice::from_raw_parts(CFDataGetBytePtr(self.0), self.len() as usize) + } + } + + /// Returns the length of this byte buffer. + #[inline] + pub fn len(&self) -> CFIndex { + unsafe { + CFDataGetLength(self.0) + } + } +} + +impl Deref for CFData { + type Target = [u8]; + + #[inline] + fn deref(&self) -> &[u8] { + self.bytes() + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/date.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/date.rs new file mode 100644 index 0000000..57ee721 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/date.rs @@ -0,0 +1,130 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Core Foundation date objects. + +pub use core_foundation_sys::date::*; +use core_foundation_sys::base::kCFAllocatorDefault; + +use base::TCFType; + +#[cfg(feature = "with-chrono")] +use chrono::NaiveDateTime; + + +declare_TCFType!{ + /// A date. + CFDate, CFDateRef +} +impl_TCFType!(CFDate, CFDateRef, CFDateGetTypeID); +impl_CFTypeDescription!(CFDate); +impl_CFComparison!(CFDate, CFDateCompare); + +impl CFDate { + #[inline] + pub fn new(time: CFAbsoluteTime) -> CFDate { + unsafe { + let date_ref = CFDateCreate(kCFAllocatorDefault, time); + TCFType::wrap_under_create_rule(date_ref) + } + } + + #[inline] + pub fn now() -> CFDate { + CFDate::new(unsafe { CFAbsoluteTimeGetCurrent() }) + } + + #[inline] + pub fn abs_time(&self) -> CFAbsoluteTime { + unsafe { + CFDateGetAbsoluteTime(self.0) + } + } + + #[cfg(feature = "with-chrono")] + pub fn naive_utc(&self) -> NaiveDateTime { + let ts = unsafe { + self.abs_time() + kCFAbsoluteTimeIntervalSince1970 + }; + let (secs, nanos) = if ts.is_sign_positive() { + (ts.trunc() as i64, ts.fract()) + } else { + // nanoseconds can't be negative in NaiveDateTime + (ts.trunc() as i64 - 1, 1.0 - ts.fract().abs()) + }; + NaiveDateTime::from_timestamp(secs, (nanos * 1e9).floor() as u32) + } + + #[cfg(feature = "with-chrono")] + pub fn from_naive_utc(time: NaiveDateTime) -> CFDate { + let secs = time.timestamp(); + let nanos = time.timestamp_subsec_nanos(); + let ts = unsafe { + secs as f64 + (nanos as f64 / 1e9) - kCFAbsoluteTimeIntervalSince1970 + }; + CFDate::new(ts) + } +} + +#[cfg(test)] +mod test { + use super::CFDate; + use std::cmp::Ordering; + + #[cfg(feature = "with-chrono")] + use chrono::NaiveDateTime; + + #[cfg(feature = "with-chrono")] + fn approx_eq(a: f64, b: f64) -> bool { + use std::f64; + + let same_sign = a.is_sign_positive() == b.is_sign_positive(); + let equal = ((a - b).abs() / f64::min(a.abs() + b.abs(), f64::MAX)) < f64::EPSILON; + (same_sign && equal) + } + + #[test] + fn date_comparison() { + let now = CFDate::now(); + let past = CFDate::new(now.abs_time() - 1.0); + assert_eq!(now.cmp(&past), Ordering::Greater); + assert_eq!(now.cmp(&now), Ordering::Equal); + assert_eq!(past.cmp(&now), Ordering::Less); + } + + #[test] + fn date_equality() { + let now = CFDate::now(); + let same_time = CFDate::new(now.abs_time()); + assert_eq!(now, same_time); + } + + #[test] + #[cfg(feature = "with-chrono")] + fn date_chrono_conversion_positive() { + let date = CFDate::now(); + let datetime = date.naive_utc(); + let converted = CFDate::from_naive_utc(datetime); + assert!(approx_eq(date.abs_time(), converted.abs_time())); + } + + #[test] + #[cfg(feature = "with-chrono")] + fn date_chrono_conversion_negative() { + use super::kCFAbsoluteTimeIntervalSince1970; + + let ts = unsafe { + kCFAbsoluteTimeIntervalSince1970 - 420.0 + }; + let date = CFDate::new(ts); + let datetime: NaiveDateTime = date.naive_utc(); + let converted = CFDate::from_naive_utc(datetime); + assert!(approx_eq(date.abs_time(), converted.abs_time())); + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/dictionary.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/dictionary.rs new file mode 100644 index 0000000..f954b71 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/dictionary.rs @@ -0,0 +1,409 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Dictionaries of key-value pairs. + +pub use core_foundation_sys::dictionary::*; + +use core_foundation_sys::base::{CFTypeRef, CFRelease, kCFAllocatorDefault}; +use std::mem; +use std::os::raw::c_void; +use std::ptr; +use std::marker::PhantomData; + +use base::{ItemRef, FromVoid, ToVoid}; +use base::{CFIndexConvertible, TCFType}; +use ConcreteCFType; + +// consume the type parameters with PhantomDatas +pub struct CFDictionary(CFDictionaryRef, PhantomData, PhantomData); + +impl Drop for CFDictionary { + fn drop(&mut self) { + unsafe { CFRelease(self.as_CFTypeRef()) } + } +} + +impl_TCFType!(CFDictionary, CFDictionaryRef, CFDictionaryGetTypeID); +impl_CFTypeDescription!(CFDictionary); + +unsafe impl ConcreteCFType for CFDictionary<*const c_void, *const c_void> {} + +impl CFDictionary { + pub fn from_CFType_pairs(pairs: &[(K, V)]) -> CFDictionary where K: TCFType, V: TCFType { + let (keys, values): (Vec, Vec) = pairs + .iter() + .map(|&(ref key, ref value)| (key.as_CFTypeRef(), value.as_CFTypeRef())) + .unzip(); + + unsafe { + let dictionary_ref = CFDictionaryCreate(kCFAllocatorDefault, + keys.as_ptr(), + values.as_ptr(), + keys.len().to_CFIndex(), + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + TCFType::wrap_under_create_rule(dictionary_ref) + } + } + + #[inline] + pub fn to_untyped(&self) -> CFDictionary { + unsafe { CFDictionary::wrap_under_get_rule(self.0) } + } + + /// Returns a `CFMutableDictionary` pointing to the same underlying dictionary as this immutable one. + /// This should only be used when the underlying dictionary is mutable. + #[inline] + pub unsafe fn to_mutable(&self) -> CFMutableDictionary { + CFMutableDictionary::wrap_under_get_rule(self.0 as CFMutableDictionaryRef) + } + + /// Returns the same dictionary, but with the types reset to void pointers. + /// Equal to `to_untyped`, but is faster since it does not increment the retain count. + #[inline] + pub fn into_untyped(self) -> CFDictionary { + let reference = self.0; + mem::forget(self); + unsafe { CFDictionary::wrap_under_create_rule(reference) } + } + + #[inline] + pub fn len(&self) -> usize { + unsafe { + CFDictionaryGetCount(self.0) as usize + } + } + + #[inline] + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + #[inline] + pub fn contains_key(&self, key: &K) -> bool where K: ToVoid { + unsafe { CFDictionaryContainsKey(self.0, key.to_void()) != 0 } + } + + #[inline] + pub fn find<'a, T: ToVoid>(&'a self, key: T) -> Option> where V: FromVoid, K: ToVoid { + unsafe { + let mut value: *const c_void = ptr::null(); + if CFDictionaryGetValueIfPresent(self.0, key.to_void(), &mut value) != 0 { + Some(V::from_void(value)) + } else { + None + } + } + } + + /// # Panics + /// + /// Panics if the key is not present in the dictionary. Use `find` to get an `Option` instead + /// of panicking. + #[inline] + pub fn get<'a, T: ToVoid>(&'a self, key: T) -> ItemRef<'a, V> where V: FromVoid, K: ToVoid { + let ptr = key.to_void(); + self.find(key).unwrap_or_else(|| panic!("No entry found for key {:p}", ptr)) + } + + pub fn get_keys_and_values(&self) -> (Vec<*const c_void>, Vec<*const c_void>) { + let length = self.len(); + let mut keys = Vec::with_capacity(length); + let mut values = Vec::with_capacity(length); + + unsafe { + CFDictionaryGetKeysAndValues(self.0, keys.as_mut_ptr(), values.as_mut_ptr()); + keys.set_len(length); + values.set_len(length); + } + + (keys, values) + } +} + +// consume the type parameters with PhantomDatas +pub struct CFMutableDictionary(CFMutableDictionaryRef, PhantomData, PhantomData); + +impl Drop for CFMutableDictionary { + fn drop(&mut self) { + unsafe { CFRelease(self.as_CFTypeRef()) } + } +} + +impl_TCFType!(CFMutableDictionary, CFMutableDictionaryRef, CFDictionaryGetTypeID); +impl_CFTypeDescription!(CFMutableDictionary); + +impl CFMutableDictionary { + pub fn new() -> Self { + Self::with_capacity(0) + } + + pub fn with_capacity(capacity: isize) -> Self { + unsafe { + let dictionary_ref = CFDictionaryCreateMutable(kCFAllocatorDefault, + capacity as _, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + TCFType::wrap_under_create_rule(dictionary_ref) + } + } + + pub fn copy_with_capacity(&self, capacity: isize) -> Self { + unsafe { + let dictionary_ref = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, capacity as _, self.0); + TCFType::wrap_under_get_rule(dictionary_ref) + } + } + + pub fn from_CFType_pairs(pairs: &[(K, V)]) -> CFMutableDictionary where K: ToVoid, V: ToVoid { + let mut result = Self::with_capacity(pairs.len() as _); + for &(ref key, ref value) in pairs { + result.add(key, value); + } + result + } + + #[inline] + pub fn to_untyped(&self) -> CFMutableDictionary { + unsafe { CFMutableDictionary::wrap_under_get_rule(self.0) } + } + + /// Returns the same dictionary, but with the types reset to void pointers. + /// Equal to `to_untyped`, but is faster since it does not increment the retain count. + #[inline] + pub fn into_untyped(self) -> CFMutableDictionary { + let reference = self.0; + mem::forget(self); + unsafe { CFMutableDictionary::wrap_under_create_rule(reference) } + } + + /// Returns a `CFDictionary` pointing to the same underlying dictionary as this mutable one. + #[inline] + pub fn to_immutable(&self) -> CFDictionary { + unsafe { CFDictionary::wrap_under_get_rule(self.0) } + } + + // Immutable interface + + #[inline] + pub fn len(&self) -> usize { + unsafe { + CFDictionaryGetCount(self.0) as usize + } + } + + #[inline] + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + #[inline] + pub fn contains_key(&self, key: *const c_void) -> bool { + unsafe { + CFDictionaryContainsKey(self.0, key) != 0 + } + } + + #[inline] + pub fn find<'a>(&'a self, key: &K) -> Option> where V: FromVoid, K: ToVoid { + unsafe { + let mut value: *const c_void = ptr::null(); + if CFDictionaryGetValueIfPresent(self.0, key.to_void(), &mut value) != 0 { + Some(V::from_void(value)) + } else { + None + } + } + } + + /// # Panics + /// + /// Panics if the key is not present in the dictionary. Use `find` to get an `Option` instead + /// of panicking. + #[inline] + pub fn get<'a>(&'a self, key: &K) -> ItemRef<'a, V> where V: FromVoid, K: ToVoid { + let ptr = key.to_void(); + self.find(&key).unwrap_or_else(|| panic!("No entry found for key {:p}", ptr)) + } + + pub fn get_keys_and_values(&self) -> (Vec<*const c_void>, Vec<*const c_void>) { + let length = self.len(); + let mut keys = Vec::with_capacity(length); + let mut values = Vec::with_capacity(length); + + unsafe { + CFDictionaryGetKeysAndValues(self.0, keys.as_mut_ptr(), values.as_mut_ptr()); + keys.set_len(length); + values.set_len(length); + } + + (keys, values) + } + + // Mutable interface + + /// Adds the key-value pair to the dictionary if no such key already exist. + #[inline] + pub fn add(&mut self, key: &K, value: &V) where K: ToVoid, V: ToVoid { + unsafe { CFDictionaryAddValue(self.0, key.to_void(), value.to_void()) } + } + + /// Sets the value of the key in the dictionary. + #[inline] + pub fn set(&mut self, key: K, value: V) where K: ToVoid, V: ToVoid { + unsafe { CFDictionarySetValue(self.0, key.to_void(), value.to_void()) } + } + + /// Replaces the value of the key in the dictionary. + #[inline] + pub fn replace(&mut self, key: K, value: V) where K: ToVoid, V: ToVoid { + unsafe { CFDictionaryReplaceValue(self.0, key.to_void(), value.to_void()) } + } + + /// Removes the value of the key from the dictionary. + #[inline] + pub fn remove(&mut self, key: K) where K: ToVoid { + unsafe { CFDictionaryRemoveValue(self.0, key.to_void()) } + } + + #[inline] + pub fn remove_all(&mut self) { + unsafe { CFDictionaryRemoveAllValues(self.0) } + } +} + +impl Default for CFMutableDictionary { + fn default() -> Self { + Self::new() + } +} + +impl<'a, K, V> From<&'a CFDictionary> for CFMutableDictionary { + /// Creates a new mutable dictionary with the key-value pairs from another dictionary. + /// The capacity of the new mutable dictionary is not limited. + fn from(dict: &'a CFDictionary) -> Self { + unsafe { + let mut_dict_ref = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, dict.0); + TCFType::wrap_under_create_rule(mut_dict_ref) + } + } +} + + +#[cfg(test)] +pub mod test { + use super::*; + use base::{CFType, TCFType}; + use boolean::CFBoolean; + use number::CFNumber; + use string::CFString; + + + #[test] + fn dictionary() { + let bar = CFString::from_static_string("Bar"); + let baz = CFString::from_static_string("Baz"); + let boo = CFString::from_static_string("Boo"); + let foo = CFString::from_static_string("Foo"); + let tru = CFBoolean::true_value(); + let n42 = CFNumber::from(42); + + let d = CFDictionary::from_CFType_pairs(&[ + (bar.as_CFType(), boo.as_CFType()), + (baz.as_CFType(), tru.as_CFType()), + (foo.as_CFType(), n42.as_CFType()), + ]); + + let (v1, v2) = d.get_keys_and_values(); + assert_eq!(v1, &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]); + assert_eq!(v2, &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]); + } + + #[test] + fn mutable_dictionary() { + let bar = CFString::from_static_string("Bar"); + let baz = CFString::from_static_string("Baz"); + let boo = CFString::from_static_string("Boo"); + let foo = CFString::from_static_string("Foo"); + let tru = CFBoolean::true_value(); + let n42 = CFNumber::from(42); + + let mut d = CFMutableDictionary::::new(); + d.add(&bar, &boo.as_CFType()); + d.add(&baz, &tru.as_CFType()); + d.add(&foo, &n42.as_CFType()); + assert_eq!(d.len(), 3); + + let (v1, v2) = d.get_keys_and_values(); + assert_eq!(v1, &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]); + assert_eq!(v2, &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]); + + d.remove(baz); + assert_eq!(d.len(), 2); + + let (v1, v2) = d.get_keys_and_values(); + assert_eq!(v1, &[bar.as_CFTypeRef(), foo.as_CFTypeRef()]); + assert_eq!(v2, &[boo.as_CFTypeRef(), n42.as_CFTypeRef()]); + + d.remove_all(); + assert_eq!(d.len(), 0) + } + + #[test] + fn dict_find_and_contains_key() { + let dict = CFDictionary::from_CFType_pairs(&[ + ( + CFString::from_static_string("hello"), + CFBoolean::true_value(), + ), + ]); + let key = CFString::from_static_string("hello"); + let invalid_key = CFString::from_static_string("foobar"); + + assert!(dict.contains_key(&key)); + assert!(!dict.contains_key(&invalid_key)); + + let value = dict.find(&key).unwrap().clone(); + assert_eq!(value, CFBoolean::true_value()); + assert_eq!(dict.find(&invalid_key), None); + } + + #[test] + fn convert_immutable_to_mutable_dict() { + let dict: CFDictionary = CFDictionary::from_CFType_pairs(&[ + (CFString::from_static_string("Foo"), CFBoolean::true_value()), + ]); + let mut mut_dict = CFMutableDictionary::from(&dict); + assert_eq!(dict.retain_count(), 1); + assert_eq!(mut_dict.retain_count(), 1); + + assert_eq!(mut_dict.len(), 1); + assert_eq!(*mut_dict.get(&CFString::from_static_string("Foo")), CFBoolean::true_value()); + + mut_dict.add(&CFString::from_static_string("Bar"), &CFBoolean::false_value()); + assert_eq!(dict.len(), 1); + assert_eq!(mut_dict.len(), 2); + } + + #[test] + fn mutable_dictionary_as_immutable() { + let mut mut_dict: CFMutableDictionary = CFMutableDictionary::new(); + mut_dict.add(&CFString::from_static_string("Bar"), &CFBoolean::false_value()); + assert_eq!(mut_dict.retain_count(), 1); + + let dict = mut_dict.to_immutable(); + assert_eq!(mut_dict.retain_count(), 2); + assert_eq!(dict.retain_count(), 2); + assert_eq!(*dict.get(&CFString::from_static_string("Bar")), CFBoolean::false_value()); + + mem::drop(dict); + assert_eq!(mut_dict.retain_count(), 1); + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/error.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/error.rs new file mode 100644 index 0000000..f100171 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/error.rs @@ -0,0 +1,71 @@ +// Copyright 2016 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Core Foundation errors. + +pub use core_foundation_sys::error::*; + +use std::error::Error; +use std::fmt; + +use base::{CFIndex, TCFType}; +use string::CFString; + + +declare_TCFType!{ + /// An error value. + CFError, CFErrorRef +} +impl_TCFType!(CFError, CFErrorRef, CFErrorGetTypeID); + +impl fmt::Debug for CFError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("CFError") + .field("domain", &self.domain()) + .field("code", &self.code()) + .field("description", &self.description()) + .finish() + } +} + +impl fmt::Display for CFError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + write!(fmt, "{}", self.description()) + } +} + +impl Error for CFError { + fn description(&self) -> &str { + "a Core Foundation error" + } +} + +impl CFError { + /// Returns a string identifying the domain with which this error is + /// associated. + pub fn domain(&self) -> CFString { + unsafe { + let s = CFErrorGetDomain(self.0); + CFString::wrap_under_get_rule(s) + } + } + + /// Returns the code identifying this type of error. + pub fn code(&self) -> CFIndex { + unsafe { CFErrorGetCode(self.0) } + } + + /// Returns a human-presentable description of the error. + pub fn description(&self) -> CFString { + unsafe { + let s = CFErrorCopyDescription(self.0); + CFString::wrap_under_create_rule(s) + } + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/filedescriptor.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/filedescriptor.rs new file mode 100644 index 0000000..2c999b5 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/filedescriptor.rs @@ -0,0 +1,210 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub use core_foundation_sys::filedescriptor::*; + +use core_foundation_sys::base::{Boolean, CFIndex}; +use core_foundation_sys::base::{kCFAllocatorDefault, CFOptionFlags}; + +use base::TCFType; +use runloop::CFRunLoopSource; + +use std::mem; +use std::os::unix::io::{AsRawFd, RawFd}; +use std::ptr; + +declare_TCFType!{ + CFFileDescriptor, CFFileDescriptorRef +} +impl_TCFType!(CFFileDescriptor, CFFileDescriptorRef, CFFileDescriptorGetTypeID); + +impl CFFileDescriptor { + pub fn new(fd: RawFd, + closeOnInvalidate: bool, + callout: CFFileDescriptorCallBack, + context: Option<&CFFileDescriptorContext>) -> Option { + let context = context.map_or(ptr::null(), |c| c as *const _); + unsafe { + let fd_ref = CFFileDescriptorCreate(kCFAllocatorDefault, + fd, + closeOnInvalidate as Boolean, + callout, + context); + if fd_ref.is_null() { + None + } else { + Some(TCFType::wrap_under_create_rule(fd_ref)) + } + } + } + + pub fn context(&self) -> CFFileDescriptorContext { + unsafe { + let mut context: CFFileDescriptorContext = mem::uninitialized(); + CFFileDescriptorGetContext(self.0, &mut context); + context + } + } + + pub fn enable_callbacks(&self, callback_types: CFOptionFlags) { + unsafe { + CFFileDescriptorEnableCallBacks(self.0, callback_types) + } + } + + pub fn disable_callbacks(&self, callback_types: CFOptionFlags) { + unsafe { + CFFileDescriptorDisableCallBacks(self.0, callback_types) + } + } + + pub fn valid(&self) -> bool { + unsafe { + CFFileDescriptorIsValid(self.0) != 0 + } + } + + pub fn invalidate(&self) { + unsafe { + CFFileDescriptorInvalidate(self.0) + } + } + + pub fn to_run_loop_source(&self, order: CFIndex) -> Option { + unsafe { + let source_ref = CFFileDescriptorCreateRunLoopSource( + kCFAllocatorDefault, + self.0, + order + ); + if source_ref.is_null() { + None + } else { + Some(TCFType::wrap_under_create_rule(source_ref)) + } + } + } +} + +impl AsRawFd for CFFileDescriptor { + fn as_raw_fd(&self) -> RawFd { + unsafe { + CFFileDescriptorGetNativeDescriptor(self.0) + } + } +} + + +#[cfg(test)] +mod test { + extern crate libc; + + use super::*; + use std::ffi::CString; + use std::os::raw::c_void; + use core_foundation_sys::base::{CFOptionFlags}; + use core_foundation_sys::runloop::{kCFRunLoopDefaultMode}; + use libc::O_RDWR; + use runloop::{CFRunLoop}; + + #[test] + fn test_consumed() { + let path = CString::new("/dev/null").unwrap(); + let raw_fd = unsafe { libc::open(path.as_ptr(), O_RDWR, 0) }; + let cf_fd = CFFileDescriptor::new(raw_fd, true, never_callback, None); + assert!(cf_fd.is_some()); + let cf_fd = cf_fd.unwrap(); + + assert!(cf_fd.valid()); + cf_fd.invalidate(); + assert!(!cf_fd.valid()); + + // close() should fail + assert_eq!(unsafe { libc::close(raw_fd) }, -1); + } + + #[test] + fn test_unconsumed() { + let path = CString::new("/dev/null").unwrap(); + let raw_fd = unsafe { libc::open(path.as_ptr(), O_RDWR, 0) }; + let cf_fd = CFFileDescriptor::new(raw_fd, false, never_callback, None); + assert!(cf_fd.is_some()); + let cf_fd = cf_fd.unwrap(); + + assert!(cf_fd.valid()); + cf_fd.invalidate(); + assert!(!cf_fd.valid()); + + // close() should succeed + assert_eq!(unsafe { libc::close(raw_fd) }, 0); + } + + extern "C" fn never_callback(_f: CFFileDescriptorRef, + _callback_types: CFOptionFlags, + _info_ptr: *mut c_void) { + unreachable!(); + } + + struct TestInfo { + value: CFOptionFlags + } + + #[test] + fn test_callback() { + let mut info = TestInfo { value: 0 }; + let context = CFFileDescriptorContext { + version: 0, + info: &mut info as *mut _ as *mut c_void, + retain: None, + release: None, + copyDescription: None + }; + + let path = CString::new("/dev/null").unwrap(); + let raw_fd = unsafe { libc::open(path.as_ptr(), O_RDWR, 0) }; + let cf_fd = CFFileDescriptor::new(raw_fd, true, callback, Some(&context)); + assert!(cf_fd.is_some()); + let cf_fd = cf_fd.unwrap(); + + assert!(cf_fd.valid()); + + let run_loop = CFRunLoop::get_current(); + let source = CFRunLoopSource::from_file_descriptor(&cf_fd, 0); + assert!(source.is_some()); + unsafe { + run_loop.add_source(&source.unwrap(), kCFRunLoopDefaultMode); + } + + info.value = 0; + cf_fd.enable_callbacks(kCFFileDescriptorReadCallBack); + CFRunLoop::run_current(); + assert_eq!(info.value, kCFFileDescriptorReadCallBack); + + info.value = 0; + cf_fd.enable_callbacks(kCFFileDescriptorWriteCallBack); + CFRunLoop::run_current(); + assert_eq!(info.value, kCFFileDescriptorWriteCallBack); + + info.value = 0; + cf_fd.disable_callbacks(kCFFileDescriptorReadCallBack | kCFFileDescriptorWriteCallBack); + + cf_fd.invalidate(); + assert!(!cf_fd.valid()); + } + + extern "C" fn callback(_f: CFFileDescriptorRef, callback_types: CFOptionFlags, info_ptr: *mut c_void) { + assert!(!info_ptr.is_null()); + + let info: *mut TestInfo = info_ptr as *mut TestInfo; + + unsafe { (*info).value = callback_types }; + + CFRunLoop::get_current().stop(); + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/lib.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/lib.rs new file mode 100644 index 0000000..cbffbd9 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/lib.rs @@ -0,0 +1,232 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(non_snake_case)] + +//! This crate provides wrappers around the underlying CoreFoundation +//! types and functions that are available on Apple's operating systems. +//! +//! It also provides a framework for other crates to use when wrapping +//! other frameworks that use the CoreFoundation framework. + +extern crate core_foundation_sys; +extern crate libc; + +#[cfg(feature = "with-chrono")] +extern crate chrono; + +use base::TCFType; + +pub unsafe trait ConcreteCFType: TCFType {} + +/// Declare a Rust type that wraps an underlying CoreFoundation type. +/// +/// This will provide an implementation of `Drop` using [`CFRelease`]. +/// The type must have an implementation of the [`TCFType`] trait, usually +/// provided using the [`impl_TCFType`] macro. +/// +/// ``` +/// #[macro_use] extern crate core_foundation; +/// // Make sure that the `TCFType` trait is in scope. +/// use core_foundation::base::{CFTypeID, TCFType}; +/// +/// extern "C" { +/// // We need a function that returns the `CFTypeID`. +/// pub fn ShrubberyGetTypeID() -> CFTypeID; +/// } +/// +/// pub struct __Shrubbery {} +/// // The ref type must be a pointer to the underlying struct. +/// pub type ShrubberyRef = *const __Shrubbery; +/// +/// declare_TCFType!(Shrubbery, ShrubberyRef); +/// impl_TCFType!(Shrubbery, ShrubberyRef, ShrubberyGetTypeID); +/// # fn main() {} +/// ``` +/// +/// [`CFRelease`]: https://developer.apple.com/documentation/corefoundation/1521153-cfrelease +/// [`TCFType`]: base/trait.TCFType.html +/// [`impl_TCFType`]: macro.impl_TCFType.html +#[macro_export] +macro_rules! declare_TCFType { + ( + $(#[$doc:meta])* + $ty:ident, $raw:ident + ) => { + $(#[$doc])* + pub struct $ty($raw); + + impl Drop for $ty { + fn drop(&mut self) { + unsafe { $crate::base::CFRelease(self.as_CFTypeRef()) } + } + } + } +} + +/// Provide an implementation of the [`TCFType`] trait for the Rust +/// wrapper type around an underlying CoreFoundation type. +/// +/// See [`declare_TCFType`] for details. +/// +/// [`declare_TCFType`]: macro.declare_TCFType.html +/// [`TCFType`]: base/trait.TCFType.html +#[macro_export] +macro_rules! impl_TCFType { + ($ty:ident, $ty_ref:ident, $ty_id:ident) => { + impl_TCFType!($ty<>, $ty_ref, $ty_id); + unsafe impl $crate::ConcreteCFType for $ty { } + }; + + ($ty:ident<$($p:ident $(: $bound:path)*),*>, $ty_ref:ident, $ty_id:ident) => { + impl<$($p $(: $bound)*),*> $crate::base::TCFType for $ty<$($p),*> { + type Ref = $ty_ref; + + #[inline] + fn as_concrete_TypeRef(&self) -> $ty_ref { + self.0 + } + + #[inline] + unsafe fn wrap_under_get_rule(reference: $ty_ref) -> Self { + let reference = $crate::base::CFRetain(reference as *const ::std::os::raw::c_void) as $ty_ref; + $crate::base::TCFType::wrap_under_create_rule(reference) + } + + #[inline] + fn as_CFTypeRef(&self) -> $crate::base::CFTypeRef { + self.as_concrete_TypeRef() as $crate::base::CFTypeRef + } + + #[inline] + unsafe fn wrap_under_create_rule(reference: $ty_ref) -> Self { + // we need one PhantomData for each type parameter so call ourselves + // again with @Phantom $p to produce that + $ty(reference $(, impl_TCFType!(@Phantom $p))*) + } + + #[inline] + fn type_id() -> $crate::base::CFTypeID { + unsafe { + $ty_id() + } + } + } + + impl Clone for $ty { + #[inline] + fn clone(&self) -> $ty { + unsafe { + $ty::wrap_under_get_rule(self.0) + } + } + } + + impl PartialEq for $ty { + #[inline] + fn eq(&self, other: &$ty) -> bool { + self.as_CFType().eq(&other.as_CFType()) + } + } + + impl Eq for $ty { } + + unsafe impl<'a> $crate::base::ToVoid<$ty> for &'a $ty { + fn to_void(&self) -> *const ::std::os::raw::c_void { + use $crate::base::TCFTypeRef; + self.as_concrete_TypeRef().as_void_ptr() + } + } + + unsafe impl $crate::base::ToVoid<$ty> for $ty { + fn to_void(&self) -> *const ::std::os::raw::c_void { + use $crate::base::TCFTypeRef; + self.as_concrete_TypeRef().as_void_ptr() + } + } + + unsafe impl $crate::base::ToVoid<$ty> for $ty_ref { + fn to_void(&self) -> *const ::std::os::raw::c_void { + use $crate::base::TCFTypeRef; + self.as_void_ptr() + } + } + + }; + + (@Phantom $x:ident) => { ::std::marker::PhantomData }; +} + + +/// Implement `std::fmt::Debug` for the given type. +/// +/// This will invoke the implementation of `Debug` for [`CFType`] +/// which invokes [`CFCopyDescription`]. +/// +/// The type must have an implementation of the [`TCFType`] trait, usually +/// provided using the [`impl_TCFType`] macro. +/// +/// [`CFType`]: base/struct.CFType.html#impl-Debug +/// [`CFCopyDescription`]: https://developer.apple.com/documentation/corefoundation/1521252-cfcopydescription?language=objc +/// [`TCFType`]: base/trait.TCFType.html +/// [`impl_TCFType`]: macro.impl_TCFType.html +#[macro_export] +macro_rules! impl_CFTypeDescription { + ($ty:ident) => { + // it's fine to use an empty <> list + impl_CFTypeDescription!($ty<>); + }; + ($ty:ident<$($p:ident $(: $bound:path)*),*>) => { + impl<$($p $(: $bound)*),*> ::std::fmt::Debug for $ty<$($p),*> { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + self.as_CFType().fmt(f) + } + } + } +} + +#[macro_export] +macro_rules! impl_CFComparison { + ($ty:ident, $compare:ident) => { + impl PartialOrd for $ty { + #[inline] + fn partial_cmp(&self, other: &$ty) -> Option<::std::cmp::Ordering> { + unsafe { + Some($compare(self.as_concrete_TypeRef(), other.as_concrete_TypeRef(), ::std::ptr::null_mut()).into()) + } + } + } + + impl Ord for $ty { + #[inline] + fn cmp(&self, other: &$ty) -> ::std::cmp::Ordering { + self.partial_cmp(other).unwrap() + } + } + } +} + +pub mod array; +pub mod attributed_string; +pub mod base; +pub mod boolean; +pub mod data; +pub mod date; +pub mod dictionary; +pub mod error; +pub mod filedescriptor; +pub mod number; +pub mod set; +pub mod string; +pub mod url; +pub mod bundle; +pub mod propertylist; +pub mod runloop; +pub mod timezone; +pub mod uuid; diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/number.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/number.rs new file mode 100644 index 0000000..a4b2aff --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/number.rs @@ -0,0 +1,120 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Immutable numbers. + +use core_foundation_sys::base::kCFAllocatorDefault; +pub use core_foundation_sys::number::*; +use std::os::raw::c_void; + +use base::TCFType; + + +declare_TCFType!{ + /// An immutable numeric value. + CFNumber, CFNumberRef +} +impl_TCFType!(CFNumber, CFNumberRef, CFNumberGetTypeID); +impl_CFTypeDescription!(CFNumber); +impl_CFComparison!(CFNumber, CFNumberCompare); + +impl CFNumber { + + #[inline] + pub fn to_i32(&self) -> Option { + unsafe { + let mut value: i32 = 0; + let ok = CFNumberGetValue(self.0, kCFNumberSInt32Type, &mut value as *mut i32 as *mut c_void); + if ok { Some(value) } else { None } + } + } + + #[inline] + pub fn to_i64(&self) -> Option { + unsafe { + let mut value: i64 = 0; + let ok = CFNumberGetValue(self.0, kCFNumberSInt64Type, &mut value as *mut i64 as *mut c_void); + if ok { Some(value) } else { None } + } + } + + #[inline] + pub fn to_f32(&self) -> Option { + unsafe { + let mut value: f32 = 0.0; + let ok = CFNumberGetValue(self.0, kCFNumberFloat32Type, &mut value as *mut f32 as *mut c_void); + if ok { Some(value) } else { None } + } + } + + #[inline] + pub fn to_f64(&self) -> Option { + unsafe { + let mut value: f64 = 0.0; + let ok = CFNumberGetValue(self.0, kCFNumberFloat64Type, &mut value as *mut f64 as *mut c_void); + if ok { Some(value) } else { None } + } + } +} + +impl From for CFNumber { + #[inline] + fn from(value: i32) -> Self { + unsafe { + let number_ref = CFNumberCreate( + kCFAllocatorDefault, + kCFNumberSInt32Type, + &value as *const i32 as *const c_void, + ); + TCFType::wrap_under_create_rule(number_ref) + } + } +} + +impl From for CFNumber { + #[inline] + fn from(value: i64) -> Self { + unsafe { + let number_ref = CFNumberCreate( + kCFAllocatorDefault, + kCFNumberSInt64Type, + &value as *const i64 as *const c_void, + ); + TCFType::wrap_under_create_rule(number_ref) + } + } +} + +impl From for CFNumber { + #[inline] + fn from(value: f32) -> Self { + unsafe { + let number_ref = CFNumberCreate( + kCFAllocatorDefault, + kCFNumberFloat32Type, + &value as *const f32 as *const c_void, + ); + TCFType::wrap_under_create_rule(number_ref) + } + } +} + +impl From for CFNumber { + #[inline] + fn from(value: f64) -> Self { + unsafe { + let number_ref = CFNumberCreate( + kCFAllocatorDefault, + kCFNumberFloat64Type, + &value as *const f64 as *const c_void, + ); + TCFType::wrap_under_create_rule(number_ref) + } + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/propertylist.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/propertylist.rs new file mode 100644 index 0000000..14ae173 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/propertylist.rs @@ -0,0 +1,325 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Core Foundation property lists + +use std::ptr; +use std::mem; +use std::os::raw::c_void; + +use error::CFError; +use data::CFData; +use base::{CFType, TCFType, TCFTypeRef}; + +pub use core_foundation_sys::propertylist::*; +use core_foundation_sys::error::CFErrorRef; +use core_foundation_sys::base::{CFGetRetainCount, CFGetTypeID, CFIndex, CFRetain, + CFShow, CFTypeID, kCFAllocatorDefault}; + +pub fn create_with_data(data: CFData, + options: CFPropertyListMutabilityOptions) + -> Result<(*const c_void, CFPropertyListFormat), CFError> { + unsafe { + let mut error: CFErrorRef = ptr::null_mut(); + let mut format: CFPropertyListFormat = 0; + let property_list = CFPropertyListCreateWithData(kCFAllocatorDefault, + data.as_concrete_TypeRef(), + options, + &mut format, + &mut error); + if property_list.is_null() { + Err(TCFType::wrap_under_create_rule(error)) + } else { + Ok((property_list, format)) + } + } +} + +pub fn create_data(property_list: *const c_void, format: CFPropertyListFormat) -> Result { + unsafe { + let mut error: CFErrorRef = ptr::null_mut(); + let data_ref = CFPropertyListCreateData(kCFAllocatorDefault, + property_list, + format, + 0, + &mut error); + if data_ref.is_null() { + Err(TCFType::wrap_under_create_rule(error)) + } else { + Ok(TCFType::wrap_under_create_rule(data_ref)) + } + } +} + + +/// Trait for all subclasses of [`CFPropertyList`]. +/// +/// [`CFPropertyList`]: struct.CFPropertyList.html +pub trait CFPropertyListSubClass: TCFType { + /// Create an instance of the superclass type [`CFPropertyList`] for this instance. + /// + /// [`CFPropertyList`]: struct.CFPropertyList.html + #[inline] + fn to_CFPropertyList(&self) -> CFPropertyList { + unsafe { CFPropertyList::wrap_under_get_rule(self.as_concrete_TypeRef().as_void_ptr()) } + } + + /// Equal to [`to_CFPropertyList`], but consumes self and avoids changing the reference count. + /// + /// [`to_CFPropertyList`]: #method.to_CFPropertyList + #[inline] + fn into_CFPropertyList(self) -> CFPropertyList + where + Self: Sized, + { + let reference = self.as_concrete_TypeRef().as_void_ptr(); + mem::forget(self); + unsafe { CFPropertyList::wrap_under_create_rule(reference) } + } +} + +impl CFPropertyListSubClass for ::data::CFData {} +impl CFPropertyListSubClass for ::string::CFString {} +impl CFPropertyListSubClass for ::array::CFArray {} +impl CFPropertyListSubClass for ::dictionary::CFDictionary {} +impl CFPropertyListSubClass for ::date::CFDate {} +impl CFPropertyListSubClass for ::boolean::CFBoolean {} +impl CFPropertyListSubClass for ::number::CFNumber {} + + +declare_TCFType!{ + /// A CFPropertyList struct. This is superclass to [`CFData`], [`CFString`], [`CFArray`], + /// [`CFDictionary`], [`CFDate`], [`CFBoolean`], and [`CFNumber`]. + /// + /// This superclass type does not have its own `CFTypeID`, instead each instance has the `CFTypeID` + /// of the subclass it is an instance of. Thus, this type cannot implement the [`TCFType`] trait, + /// since it cannot implement the static [`TCFType::type_id()`] method. + /// + /// [`CFData`]: ../data/struct.CFData.html + /// [`CFString`]: ../string/struct.CFString.html + /// [`CFArray`]: ../array/struct.CFArray.html + /// [`CFDictionary`]: ../dictionary/struct.CFDictionary.html + /// [`CFDate`]: ../date/struct.CFDate.html + /// [`CFBoolean`]: ../boolean/struct.CFBoolean.html + /// [`CFNumber`]: ../number/struct.CFNumber.html + /// [`TCFType`]: ../base/trait.TCFType.html + /// [`TCFType::type_id()`]: ../base/trait.TCFType.html#method.type_of + CFPropertyList, CFPropertyListRef +} + +impl CFPropertyList { + #[inline] + pub fn as_concrete_TypeRef(&self) -> CFPropertyListRef { + self.0 + } + + #[inline] + pub unsafe fn wrap_under_get_rule(reference: CFPropertyListRef) -> CFPropertyList { + let reference = CFRetain(reference); + CFPropertyList(reference) + } + + #[inline] + pub fn as_CFType(&self) -> CFType { + unsafe { CFType::wrap_under_get_rule(self.as_CFTypeRef()) } + } + + #[inline] + pub fn into_CFType(self) -> CFType + where + Self: Sized, + { + let reference = self.as_CFTypeRef(); + mem::forget(self); + unsafe { TCFType::wrap_under_create_rule(reference) } + } + + #[inline] + pub fn as_CFTypeRef(&self) -> ::core_foundation_sys::base::CFTypeRef { + self.as_concrete_TypeRef() + } + + #[inline] + pub unsafe fn wrap_under_create_rule(obj: CFPropertyListRef) -> CFPropertyList { + CFPropertyList(obj) + } + + /// Returns the reference count of the object. It is unwise to do anything other than test + /// whether the return value of this method is greater than zero. + #[inline] + pub fn retain_count(&self) -> CFIndex { + unsafe { CFGetRetainCount(self.as_CFTypeRef()) } + } + + /// Returns the type ID of this object. Will be one of CFData, CFString, CFArray, CFDictionary, + /// CFDate, CFBoolean, or CFNumber. + #[inline] + pub fn type_of(&self) -> CFTypeID { + unsafe { CFGetTypeID(self.as_CFTypeRef()) } + } + + /// Writes a debugging version of this object on standard error. + pub fn show(&self) { + unsafe { CFShow(self.as_CFTypeRef()) } + } + + /// Returns true if this value is an instance of another type. + #[inline] + pub fn instance_of(&self) -> bool { + self.type_of() == OtherCFType::type_id() + } +} + +impl Clone for CFPropertyList { + #[inline] + fn clone(&self) -> CFPropertyList { + unsafe { CFPropertyList::wrap_under_get_rule(self.0) } + } +} + +impl PartialEq for CFPropertyList { + #[inline] + fn eq(&self, other: &CFPropertyList) -> bool { + self.as_CFType().eq(&other.as_CFType()) + } +} + +impl Eq for CFPropertyList {} + +impl CFPropertyList { + /// Try to downcast the [`CFPropertyList`] to a subclass. Checking if the instance is the + /// correct subclass happens at runtime and `None` is returned if it is not the correct type. + /// Works similar to [`Box::downcast`] and [`CFType::downcast`]. + /// + /// # Examples + /// + /// ``` + /// # use core_foundation::string::CFString; + /// # use core_foundation::propertylist::{CFPropertyList, CFPropertyListSubClass}; + /// # + /// // Create a string. + /// let string: CFString = CFString::from_static_string("FooBar"); + /// // Cast it up to a property list. + /// let propertylist: CFPropertyList = string.to_CFPropertyList(); + /// // Cast it down again. + /// assert_eq!(propertylist.downcast::().unwrap().to_string(), "FooBar"); + /// ``` + /// + /// [`CFPropertyList`]: struct.CFPropertyList.html + /// [`Box::downcast`]: https://doc.rust-lang.org/std/boxed/struct.Box.html#method.downcast + pub fn downcast(&self) -> Option { + if self.instance_of::() { + unsafe { + let subclass_ref = T::Ref::from_void_ptr(self.0); + Some(T::wrap_under_get_rule(subclass_ref)) + } + } else { + None + } + } + + /// Similar to [`downcast`], but consumes self and can thus avoid touching the retain count. + /// + /// [`downcast`]: #method.downcast + pub fn downcast_into(self) -> Option { + if self.instance_of::() { + unsafe { + let subclass_ref = T::Ref::from_void_ptr(self.0); + mem::forget(self); + Some(T::wrap_under_create_rule(subclass_ref)) + } + } else { + None + } + } +} + + + +#[cfg(test)] +pub mod test { + use super::*; + use string::CFString; + use boolean::CFBoolean; + + #[test] + fn test_property_list_serialization() { + use base::{TCFType, CFEqual}; + use boolean::CFBoolean; + use number::CFNumber; + use dictionary::CFDictionary; + use string::CFString; + use super::*; + + let bar = CFString::from_static_string("Bar"); + let baz = CFString::from_static_string("Baz"); + let boo = CFString::from_static_string("Boo"); + let foo = CFString::from_static_string("Foo"); + let tru = CFBoolean::true_value(); + let n42 = CFNumber::from(42); + + let dict1 = CFDictionary::from_CFType_pairs(&[(bar.as_CFType(), boo.as_CFType()), + (baz.as_CFType(), tru.as_CFType()), + (foo.as_CFType(), n42.as_CFType())]); + + let data = create_data(dict1.as_CFTypeRef(), kCFPropertyListXMLFormat_v1_0).unwrap(); + let (dict2, _) = create_with_data(data, kCFPropertyListImmutable).unwrap(); + unsafe { + assert_eq!(CFEqual(dict1.as_CFTypeRef(), dict2), 1); + } + } + + #[test] + fn to_propertylist_retain_count() { + let string = CFString::from_static_string("Bar"); + assert_eq!(string.retain_count(), 1); + + let propertylist = string.to_CFPropertyList(); + assert_eq!(string.retain_count(), 2); + assert_eq!(propertylist.retain_count(), 2); + + mem::drop(string); + assert_eq!(propertylist.retain_count(), 1); + } + + #[test] + fn downcast_string() { + let propertylist = CFString::from_static_string("Bar").to_CFPropertyList(); + assert_eq!(propertylist.downcast::().unwrap().to_string(), "Bar"); + assert!(propertylist.downcast::().is_none()); + } + + #[test] + fn downcast_boolean() { + let propertylist = CFBoolean::true_value().to_CFPropertyList(); + assert!(propertylist.downcast::().is_some()); + assert!(propertylist.downcast::().is_none()); + } + + #[test] + fn downcast_into_fail() { + let string = CFString::from_static_string("Bar"); + let propertylist = string.to_CFPropertyList(); + assert_eq!(string.retain_count(), 2); + + assert!(propertylist.downcast_into::().is_none()); + assert_eq!(string.retain_count(), 1); + } + + #[test] + fn downcast_into() { + let string = CFString::from_static_string("Bar"); + let propertylist = string.to_CFPropertyList(); + assert_eq!(string.retain_count(), 2); + + let string2 = propertylist.downcast_into::().unwrap(); + assert_eq!(string2.to_string(), "Bar"); + assert_eq!(string2.retain_count(), 2); + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/runloop.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/runloop.rs new file mode 100644 index 0000000..24aa9a5 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/runloop.rs @@ -0,0 +1,199 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(non_upper_case_globals)] + +pub use core_foundation_sys::runloop::*; +use core_foundation_sys::base::CFIndex; +use core_foundation_sys::base::{kCFAllocatorDefault, CFOptionFlags}; +use core_foundation_sys::string::CFStringRef; + +use base::{TCFType}; +use date::{CFAbsoluteTime, CFTimeInterval}; +use filedescriptor::CFFileDescriptor; +use string::{CFString}; + +pub type CFRunLoopMode = CFStringRef; + + +declare_TCFType!(CFRunLoop, CFRunLoopRef); +impl_TCFType!(CFRunLoop, CFRunLoopRef, CFRunLoopGetTypeID); +impl_CFTypeDescription!(CFRunLoop); + +impl CFRunLoop { + pub fn get_current() -> CFRunLoop { + unsafe { + let run_loop_ref = CFRunLoopGetCurrent(); + TCFType::wrap_under_get_rule(run_loop_ref) + } + } + + pub fn get_main() -> CFRunLoop { + unsafe { + let run_loop_ref = CFRunLoopGetMain(); + TCFType::wrap_under_get_rule(run_loop_ref) + } + } + + pub fn run_current() { + unsafe { + CFRunLoopRun(); + } + } + + pub fn stop(&self) { + unsafe { + CFRunLoopStop(self.0); + } + } + + pub fn current_mode(&self) -> Option { + unsafe { + let string_ref = CFRunLoopCopyCurrentMode(self.0); + if string_ref.is_null() { + return None; + } + + let cf_string: CFString = TCFType::wrap_under_create_rule(string_ref); + Some(cf_string.to_string()) + } + } + + pub fn contains_timer(&self, timer: &CFRunLoopTimer, mode: CFRunLoopMode) -> bool { + unsafe { + CFRunLoopContainsTimer(self.0, timer.0, mode) != 0 + } + } + + pub fn add_timer(&self, timer: &CFRunLoopTimer, mode: CFRunLoopMode) { + unsafe { + CFRunLoopAddTimer(self.0, timer.0, mode); + } + } + + pub fn remove_timer(&self, timer: &CFRunLoopTimer, mode: CFRunLoopMode) { + unsafe { + CFRunLoopRemoveTimer(self.0, timer.0, mode); + } + } + + pub fn contains_source(&self, source: &CFRunLoopSource, mode: CFRunLoopMode) -> bool { + unsafe { + CFRunLoopContainsSource(self.0, source.0, mode) != 0 + } + } + + pub fn add_source(&self, source: &CFRunLoopSource, mode: CFRunLoopMode) { + unsafe { + CFRunLoopAddSource(self.0, source.0, mode); + } + } + + pub fn remove_source(&self, source: &CFRunLoopSource, mode: CFRunLoopMode) { + unsafe { + CFRunLoopRemoveSource(self.0, source.0, mode); + } + } + + pub fn contains_observer(&self, observer: &CFRunLoopObserver, mode: CFRunLoopMode) -> bool { + unsafe { + CFRunLoopContainsObserver(self.0, observer.0, mode) != 0 + } + } + + pub fn add_observer(&self, observer: &CFRunLoopObserver, mode: CFRunLoopMode) { + unsafe { + CFRunLoopAddObserver(self.0, observer.0, mode); + } + } + + pub fn remove_observer(&self, observer: &CFRunLoopObserver, mode: CFRunLoopMode) { + unsafe { + CFRunLoopRemoveObserver(self.0, observer.0, mode); + } + } + +} + + +declare_TCFType!(CFRunLoopTimer, CFRunLoopTimerRef); +impl_TCFType!(CFRunLoopTimer, CFRunLoopTimerRef, CFRunLoopTimerGetTypeID); + +impl CFRunLoopTimer { + pub fn new(fireDate: CFAbsoluteTime, interval: CFTimeInterval, flags: CFOptionFlags, order: CFIndex, callout: CFRunLoopTimerCallBack, context: *mut CFRunLoopTimerContext) -> CFRunLoopTimer { + unsafe { + let timer_ref = CFRunLoopTimerCreate(kCFAllocatorDefault, fireDate, interval, flags, order, callout, context); + TCFType::wrap_under_create_rule(timer_ref) + } + } +} + + +declare_TCFType!(CFRunLoopSource, CFRunLoopSourceRef); +impl_TCFType!(CFRunLoopSource, CFRunLoopSourceRef, CFRunLoopSourceGetTypeID); + +impl CFRunLoopSource { + pub fn from_file_descriptor(fd: &CFFileDescriptor, order: CFIndex) -> Option { + fd.to_run_loop_source(order) + } +} + +declare_TCFType!(CFRunLoopObserver, CFRunLoopObserverRef); +impl_TCFType!(CFRunLoopObserver, CFRunLoopObserverRef, CFRunLoopObserverGetTypeID); + +#[cfg(test)] +mod test { + use super::*; + use date::{CFDate, CFAbsoluteTime}; + use std::mem; + use std::os::raw::c_void; + use std::sync::mpsc; + + #[test] + fn wait_200_milliseconds() { + let run_loop = CFRunLoop::get_current(); + + let now = CFDate::now().abs_time(); + let (elapsed_tx, elapsed_rx) = mpsc::channel(); + let mut info = Info { + start_time: now, + elapsed_tx, + }; + let mut context = unsafe { CFRunLoopTimerContext { + version: 0, + info: &mut info as *mut _ as *mut c_void, + retain: mem::zeroed(), + release: mem::zeroed(), + copyDescription: mem::zeroed(), + } }; + + + let run_loop_timer = CFRunLoopTimer::new(now + 0.20f64, 0f64, 0, 0, timer_popped, &mut context); + unsafe { + run_loop.add_timer(&run_loop_timer, kCFRunLoopDefaultMode); + } + CFRunLoop::run_current(); + let elapsed = elapsed_rx.try_recv().unwrap(); + println!("wait_200_milliseconds, elapsed: {}", elapsed); + assert!(elapsed > 0.19 && elapsed < 0.30); + } + + struct Info { + start_time: CFAbsoluteTime, + elapsed_tx: mpsc::Sender, + } + + extern "C" fn timer_popped(_timer: CFRunLoopTimerRef, raw_info: *mut c_void) { + let info: *mut Info = unsafe { mem::transmute(raw_info) }; + let now = CFDate::now().abs_time(); + let elapsed = now - unsafe { (*info).start_time }; + let _ = unsafe { (*info).elapsed_tx.send(elapsed) }; + CFRunLoop::get_current().stop(); + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/set.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/set.rs new file mode 100644 index 0000000..f06d8a3 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/set.rs @@ -0,0 +1,44 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! An immutable bag of elements. + +pub use core_foundation_sys::set::*; +use core_foundation_sys::base::{CFTypeRef, CFRelease, kCFAllocatorDefault}; + +use base::{CFIndexConvertible, TCFType}; + +use std::os::raw::c_void; +use std::marker::PhantomData; + +/// An immutable bag of elements. +pub struct CFSet(CFSetRef, PhantomData); + +impl Drop for CFSet { + fn drop(&mut self) { + unsafe { CFRelease(self.as_CFTypeRef()) } + } +} + +impl_TCFType!(CFSet, CFSetRef, CFSetGetTypeID); +impl_CFTypeDescription!(CFSet); + +impl CFSet { + /// Creates a new set from a list of `CFType` instances. + pub fn from_slice(elems: &[T]) -> CFSet where T: TCFType { + unsafe { + let elems: Vec = elems.iter().map(|elem| elem.as_CFTypeRef()).collect(); + let set_ref = CFSetCreate(kCFAllocatorDefault, + elems.as_ptr(), + elems.len().to_CFIndex(), + &kCFTypeSetCallBacks); + TCFType::wrap_under_create_rule(set_ref) + } + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/string.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/string.rs new file mode 100644 index 0000000..021479c --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/string.rs @@ -0,0 +1,150 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Immutable strings. + +pub use core_foundation_sys::string::*; + +use base::{CFIndexConvertible, TCFType}; + +use core_foundation_sys::base::{Boolean, CFIndex, CFRange}; +use core_foundation_sys::base::{kCFAllocatorDefault, kCFAllocatorNull}; +use std::borrow::Cow; +use std::fmt; +use std::str::{self, FromStr}; +use std::ptr; +use std::ffi::CStr; + + +declare_TCFType!{ + /// An immutable string in one of a variety of encodings. + CFString, CFStringRef +} +impl_TCFType!(CFString, CFStringRef, CFStringGetTypeID); + +impl FromStr for CFString { + type Err = (); + + /// See also CFString::new for a variant of this which does not return a Result + #[inline] + fn from_str(string: &str) -> Result { + Ok(CFString::new(string)) + } +} + +impl<'a> From<&'a str> for CFString { + #[inline] + fn from(string: &'a str) -> CFString { + CFString::new(string) + } +} + +impl<'a> From<&'a CFString> for Cow<'a, str> { + fn from(cf_str: &'a CFString) -> Cow<'a, str> { + unsafe { + // Do this without allocating if we can get away with it + let c_string = CFStringGetCStringPtr(cf_str.0, kCFStringEncodingUTF8); + if !c_string.is_null() { + let c_str = CStr::from_ptr(c_string); + Cow::Borrowed(str::from_utf8_unchecked(c_str.to_bytes())) + } else { + let char_len = cf_str.char_len(); + + // First, ask how big the buffer ought to be. + let mut bytes_required: CFIndex = 0; + CFStringGetBytes(cf_str.0, + CFRange { location: 0, length: char_len }, + kCFStringEncodingUTF8, + 0, + false as Boolean, + ptr::null_mut(), + 0, + &mut bytes_required); + + // Then, allocate the buffer and actually copy. + let mut buffer = vec![b'\x00'; bytes_required as usize]; + + let mut bytes_used: CFIndex = 0; + let chars_written = CFStringGetBytes(cf_str.0, + CFRange { location: 0, length: char_len }, + kCFStringEncodingUTF8, + 0, + false as Boolean, + buffer.as_mut_ptr(), + buffer.len().to_CFIndex(), + &mut bytes_used); + assert_eq!(chars_written, char_len); + + // This is dangerous; we over-allocate and null-terminate the string (during + // initialization). + assert_eq!(bytes_used, buffer.len().to_CFIndex()); + Cow::Owned(String::from_utf8_unchecked(buffer)) + } + } + } +} + +impl fmt::Display for CFString { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.write_str(&Cow::from(self)) + } +} + +impl fmt::Debug for CFString { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "\"{}\"", self) + } +} + + +impl CFString { + /// Creates a new `CFString` instance from a Rust string. + #[inline] + pub fn new(string: &str) -> CFString { + unsafe { + let string_ref = CFStringCreateWithBytes(kCFAllocatorDefault, + string.as_ptr(), + string.len().to_CFIndex(), + kCFStringEncodingUTF8, + false as Boolean); + CFString::wrap_under_create_rule(string_ref) + } + } + + /// Like `CFString::new`, but references a string that can be used as a backing store + /// by virtue of being statically allocated. + #[inline] + pub fn from_static_string(string: &'static str) -> CFString { + unsafe { + let string_ref = CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, + string.as_ptr(), + string.len().to_CFIndex(), + kCFStringEncodingUTF8, + false as Boolean, + kCFAllocatorNull); + TCFType::wrap_under_create_rule(string_ref) + } + } + + /// Returns the number of characters in the string. + #[inline] + pub fn char_len(&self) -> CFIndex { + unsafe { + CFStringGetLength(self.0) + } + } +} + +#[test] +fn string_and_back() { + let original = "The quick brown fox jumped over the slow lazy dog."; + let cfstr = CFString::from_static_string(original); + let converted = cfstr.to_string(); + assert_eq!(converted, original); +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/timezone.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/timezone.rs new file mode 100644 index 0000000..66aadb7 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/timezone.rs @@ -0,0 +1,95 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Core Foundation time zone objects. + +pub use core_foundation_sys::timezone::*; +use core_foundation_sys::base::kCFAllocatorDefault; + +use base::TCFType; +use date::{CFDate, CFTimeInterval}; + +#[cfg(feature = "with-chrono")] +use chrono::{FixedOffset, NaiveDateTime}; + + +declare_TCFType!{ + /// A time zone. + CFTimeZone, CFTimeZoneRef +} +impl_TCFType!(CFTimeZone, CFTimeZoneRef, CFTimeZoneGetTypeID); +impl_CFTypeDescription!(CFTimeZone); + +impl Default for CFTimeZone { + fn default() -> CFTimeZone { + unsafe { + let tz_ref = CFTimeZoneCopyDefault(); + TCFType::wrap_under_create_rule(tz_ref) + } + } +} + +impl CFTimeZone { + #[inline] + pub fn new(interval: CFTimeInterval) -> CFTimeZone { + unsafe { + let tz_ref = CFTimeZoneCreateWithTimeIntervalFromGMT(kCFAllocatorDefault, interval); + TCFType::wrap_under_create_rule(tz_ref) + } + } + + #[inline] + pub fn system() -> CFTimeZone { + unsafe { + let tz_ref = CFTimeZoneCopySystem(); + TCFType::wrap_under_create_rule(tz_ref) + } + } + + pub fn seconds_from_gmt(&self, date: CFDate) -> CFTimeInterval { + unsafe { + CFTimeZoneGetSecondsFromGMT(self.0, date.abs_time()) + } + } + + #[cfg(feature = "with-chrono")] + pub fn offset_at_date(&self, date: NaiveDateTime) -> FixedOffset { + let date = CFDate::from_naive_utc(date); + FixedOffset::east(self.seconds_from_gmt(date) as i32) + } + + #[cfg(feature = "with-chrono")] + pub fn from_offset(offset: FixedOffset) -> CFTimeZone { + CFTimeZone::new(offset.local_minus_utc() as f64) + } +} + +#[cfg(test)] +mod test { + use super::CFTimeZone; + + #[cfg(feature = "with-chrono")] + use chrono::{NaiveDateTime, FixedOffset}; + + #[test] + fn timezone_comparison() { + let system = CFTimeZone::system(); + let default = CFTimeZone::default(); + assert_eq!(system, default); + } + + #[test] + #[cfg(feature = "with-chrono")] + fn timezone_chrono_conversion() { + let offset = FixedOffset::west(28800); + let tz = CFTimeZone::from_offset(offset); + let converted = tz.offset_at_date(NaiveDateTime::from_timestamp(0, 0)); + assert_eq!(offset, converted); + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/url.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/url.rs new file mode 100644 index 0000000..199ad2e --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/url.rs @@ -0,0 +1,156 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A URL type for Core Foundation. + +pub use core_foundation_sys::url::*; + +use base::{TCFType, CFIndex}; +use string::{CFString}; + +use core_foundation_sys::base::{kCFAllocatorDefault, Boolean}; +use std::fmt; +use std::ptr; +use std::path::{Path, PathBuf}; +use std::mem; + +use libc::{c_char, strlen, PATH_MAX}; + +#[cfg(unix)] +use std::os::unix::ffi::OsStrExt; +#[cfg(unix)] +use std::ffi::OsStr; + + +declare_TCFType!(CFURL, CFURLRef); +impl_TCFType!(CFURL, CFURLRef, CFURLGetTypeID); + +impl fmt::Debug for CFURL { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + unsafe { + let string: CFString = TCFType::wrap_under_get_rule(CFURLGetString(self.0)); + write!(f, "{}", string.to_string()) + } + } +} + +impl CFURL { + pub fn from_path>(path: P, isDirectory: bool) -> Option { + let path_bytes; + #[cfg(unix)] + { + path_bytes = path.as_ref().as_os_str().as_bytes() + } + #[cfg(not(unix))] + { + // XXX: Getting non-valid UTF8 paths into CoreFoundation on Windows is going to be unpleasant + // CFURLGetWideFileSystemRepresentation might help + path_bytes = match path.as_ref().to_str() { + Some(path) => path, + None => return None, + } + } + + unsafe { + let url_ref = CFURLCreateFromFileSystemRepresentation(ptr::null_mut(), path_bytes.as_ptr(), path_bytes.len() as CFIndex, isDirectory as u8); + if url_ref.is_null() { + return None; + } + Some(TCFType::wrap_under_create_rule(url_ref)) + } + } + + pub fn from_file_system_path(filePath: CFString, pathStyle: CFURLPathStyle, isDirectory: bool) -> CFURL { + unsafe { + let url_ref = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, filePath.as_concrete_TypeRef(), pathStyle, isDirectory as u8); + TCFType::wrap_under_create_rule(url_ref) + } + } + + #[cfg(unix)] + pub fn to_path(&self) -> Option { + // implementing this on Windows is more complicated because of the different OsStr representation + unsafe { + let mut buf: [u8; PATH_MAX as usize] = mem::uninitialized(); + let result = CFURLGetFileSystemRepresentation(self.0, true as Boolean, buf.as_mut_ptr(), buf.len() as CFIndex); + if result == false as Boolean { + return None; + } + let len = strlen(buf.as_ptr() as *const c_char); + let path = OsStr::from_bytes(&buf[0..len]); + Some(PathBuf::from(path)) + } + } + + pub fn get_string(&self) -> CFString { + unsafe { + TCFType::wrap_under_get_rule(CFURLGetString(self.0)) + } + } + + pub fn get_file_system_path(&self, pathStyle: CFURLPathStyle) -> CFString { + unsafe { + TCFType::wrap_under_create_rule(CFURLCopyFileSystemPath(self.as_concrete_TypeRef(), pathStyle)) + } + } + + pub fn absolute(&self) -> CFURL { + unsafe { + TCFType::wrap_under_create_rule(CFURLCopyAbsoluteURL(self.as_concrete_TypeRef())) + } + } +} + +#[test] +fn file_url_from_path() { + let path = "/usr/local/foo/"; + let cfstr_path = CFString::from_static_string(path); + let cfurl = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true); + assert_eq!(cfurl.get_string().to_string(), "file:///usr/local/foo/"); +} + +#[cfg(unix)] +#[test] +fn non_utf8() { + use std::ffi::OsStr; + let path = Path::new(OsStr::from_bytes(b"/\xC0/blame")); + let cfurl = CFURL::from_path(path, false).unwrap(); + assert_eq!(cfurl.to_path().unwrap(), path); + let len = unsafe { CFURLGetBytes(cfurl.as_concrete_TypeRef(), ptr::null_mut(), 0) }; + assert_eq!(len, 17); +} + +#[test] +fn absolute_file_url() { + use core_foundation_sys::url::CFURLCreateWithFileSystemPathRelativeToBase; + use std::path::PathBuf; + + let path = "/usr/local/foo"; + let file = "bar"; + + let cfstr_path = CFString::from_static_string(path); + let cfstr_file = CFString::from_static_string(file); + let cfurl_base = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true); + let cfurl_relative: CFURL = unsafe { + let url_ref = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorDefault, + cfstr_file.as_concrete_TypeRef(), + kCFURLPOSIXPathStyle, + false as u8, + cfurl_base.as_concrete_TypeRef()); + TCFType::wrap_under_create_rule(url_ref) + }; + + let mut absolute_path = PathBuf::from(path); + absolute_path.push(file); + + assert_eq!(cfurl_relative.get_file_system_path(kCFURLPOSIXPathStyle).to_string(), file); + assert_eq!(cfurl_relative.absolute().get_file_system_path(kCFURLPOSIXPathStyle).to_string(), + absolute_path.to_str().unwrap()); +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/src/uuid.rs b/third_party/cargo/vendor/core-foundation-0.6.4/src/uuid.rs new file mode 100644 index 0000000..6be734d --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/src/uuid.rs @@ -0,0 +1,118 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Core Foundation UUID objects. + +#[cfg(feature = "with-uuid")] +extern crate uuid; + +pub use core_foundation_sys::uuid::*; +use core_foundation_sys::base::kCFAllocatorDefault; + +use base::TCFType; + +#[cfg(feature = "with-uuid")] +use self::uuid::Uuid; + + +declare_TCFType! { + /// A UUID. + CFUUID, CFUUIDRef +} +impl_TCFType!(CFUUID, CFUUIDRef, CFUUIDGetTypeID); +impl_CFTypeDescription!(CFUUID); + +impl CFUUID { + #[inline] + pub fn new() -> CFUUID { + unsafe { + let uuid_ref = CFUUIDCreate(kCFAllocatorDefault); + TCFType::wrap_under_create_rule(uuid_ref) + } + } +} + +impl Default for CFUUID { + fn default() -> Self { + Self::new() + } +} + +#[cfg(feature = "with-uuid")] +impl Into for CFUUID { + fn into(self) -> Uuid { + let b = unsafe { + CFUUIDGetUUIDBytes(self.0) + }; + let bytes = [ + b.byte0, + b.byte1, + b.byte2, + b.byte3, + b.byte4, + b.byte5, + b.byte6, + b.byte7, + b.byte8, + b.byte9, + b.byte10, + b.byte11, + b.byte12, + b.byte13, + b.byte14, + b.byte15, + ]; + Uuid::from_bytes(&bytes).unwrap() + } +} + +#[cfg(feature = "with-uuid")] +impl From for CFUUID { + fn from(uuid: Uuid) -> CFUUID { + let b = uuid.as_bytes(); + let bytes = CFUUIDBytes { + byte0: b[0], + byte1: b[1], + byte2: b[2], + byte3: b[3], + byte4: b[4], + byte5: b[5], + byte6: b[6], + byte7: b[7], + byte8: b[8], + byte9: b[9], + byte10: b[10], + byte11: b[11], + byte12: b[12], + byte13: b[13], + byte14: b[14], + byte15: b[15], + }; + unsafe { + let uuid_ref = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, bytes); + TCFType::wrap_under_create_rule(uuid_ref) + } + } +} + + +#[cfg(test)] +#[cfg(feature = "with-uuid")] +mod test { + use super::CFUUID; + use uuid::Uuid; + + #[test] + fn uuid_conversion() { + let cf_uuid = CFUUID::new(); + let uuid: Uuid = cf_uuid.clone().into(); + let converted = CFUUID::from(uuid); + assert_eq!(cf_uuid, converted); + } +} diff --git a/third_party/cargo/vendor/core-foundation-0.6.4/tests/use_macro_outside_crate.rs b/third_party/cargo/vendor/core-foundation-0.6.4/tests/use_macro_outside_crate.rs new file mode 100644 index 0000000..ff1c17d --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-0.6.4/tests/use_macro_outside_crate.rs @@ -0,0 +1,28 @@ +#[macro_use] +extern crate core_foundation; + +use core_foundation::base::{CFComparisonResult, TCFType}; +use std::os::raw::c_void; + +// sys equivalent stuff that must be declared + +#[repr(C)] +pub struct __CFFooBar(c_void); + +pub type CFFooBarRef = *const __CFFooBar; + +extern "C" { + pub fn CFFooBarGetTypeID() -> core_foundation::base::CFTypeID; + pub fn fake_compare( + this: CFFooBarRef, + other: CFFooBarRef, + context: *mut c_void, + ) -> CFComparisonResult; +} + +// Try to use the macros outside of the crate + +declare_TCFType!(CFFooBar, CFFooBarRef); +impl_TCFType!(CFFooBar, CFFooBarRef, CFFooBarGetTypeID); +impl_CFTypeDescription!(CFFooBar); +impl_CFComparison!(CFFooBar, fake_compare); diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/.cargo-checksum.json b/third_party/cargo/vendor/core-foundation-sys-0.6.2/.cargo-checksum.json new file mode 100644 index 0000000..72cdec6 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"dc9a55f461f23bf82bb9b3ee7d9b74807b7a905e31f05074bb05b5e3cb1ab267","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","build.rs":"9433ed3b20cc99e716dda4c6d8507c29bc04882544cbbea8d4e48ba80fd0fa12","src/array.rs":"40c305658e16b07d86353a5ad34e7b5fb98720f19cc2b5173360d6a61ce2642f","src/attributed_string.rs":"693b6c745c5aef1929595c94363d500b4b25ebcfed0b4b8dee0103b8fc0537f8","src/base.rs":"f0f8424099a4269e2359b063c3f055e115aec6df0f6aa71695ca91257dfd64e2","src/bundle.rs":"e8ad47f9f0280e1eef7e9aea2eb88020443953ac2cda234396321450ffc3d48a","src/data.rs":"4547e98f4e25a99606d8f33e82f8de3d9889612485d445d4467138b8ad29b7e9","src/date.rs":"c064ee4c3ebd1927532c34871e2e41179d6e3c3e400f6b409a18ad9e2337477f","src/dictionary.rs":"3327a6f90f1e0db5e3fde1973e2df4143ca896716a816d03f2b17c8e988c5159","src/error.rs":"6205ebeb7631daa8bcd560862b6daa10f640c8c117ce5f6f7184f268dcbcb42a","src/filedescriptor.rs":"49580654b657811fade7adaa256f5f895cb011c9baa4731e2f44a6ec7fdba235","src/lib.rs":"af7183760214be155e2cf562bf4265bd2d73da079e35d05e29ea0146e3c87654","src/messageport.rs":"e9227d5907cba8e29cdeea41bcb3ae5c7840220442953ab19aace31a84542f47","src/number.rs":"b1154203e74cb2258ba5520e20bcd4d524f1a957e09a19dd026b18d23baa3868","src/propertylist.rs":"7ec928438826c4ce40befedf3de0a37c8ecbc0fc17896dfa629d5864000b2cfe","src/runloop.rs":"67a6c2e4773f13de9452c9f8e4791b9889e03e56c07a7bdf64dbba99e9821f45","src/set.rs":"8aef5f4ba75a067e271ad6cb960569f1d22a0acee0eb6c79e31bb8b636619d9d","src/string.rs":"3ebfa11bba928d0ab1b07ecc0bd0f11367642eb818c8e21f08c16a4be8f9494f","src/timezone.rs":"42741f556af081be32987d2705488959c60aeb794e7c737b092f0dce5851ca89","src/url.rs":"4cd2950660ad234f7f833b3f5c092f7322465085452cca8ced623564400cdef9","src/uuid.rs":"82f75efa73d0842dff2e13d299c166c6593a77fcb69c4b7629a2df1c17ae507d"},"package":"e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"} \ No newline at end of file diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/BUILD b/third_party/cargo/vendor/core-foundation-sys-0.6.2/BUILD new file mode 100644 index 0000000..a8e80a3 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted + +rust_library( + name = "core_foundation_sys", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.2", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/Cargo.toml b/third_party/cargo/vendor/core-foundation-sys-0.6.2/Cargo.toml new file mode 100644 index 0000000..565583b --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/Cargo.toml @@ -0,0 +1,27 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "core-foundation-sys" +version = "0.6.2" +authors = ["The Servo Project Developers"] +build = "build.rs" +description = "Bindings to Core Foundation for OS X" +homepage = "https://github.com/servo/core-foundation-rs" +license = "MIT / Apache-2.0" +repository = "https://github.com/servo/core-foundation-rs" + +[dependencies] + +[features] +mac_os_10_7_support = [] +mac_os_10_8_features = [] diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/LICENSE-APACHE b/third_party/cargo/vendor/core-foundation-sys-0.6.2/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/LICENSE-MIT b/third_party/cargo/vendor/core-foundation-sys-0.6.2/LICENSE-MIT new file mode 100644 index 0000000..807526f --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2012-2013 Mozilla Foundation + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/build.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/build.rs new file mode 100644 index 0000000..1f03b06 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/build.rs @@ -0,0 +1,14 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + if std::env::var("TARGET").unwrap().contains("-apple") { + println!("cargo:rustc-link-lib=framework=CoreFoundation"); + } +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/array.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/array.rs new file mode 100644 index 0000000..5090302 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/array.rs @@ -0,0 +1,55 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFRange, CFIndex, CFAllocatorRef, CFTypeID, Boolean}; +use string::CFStringRef; + +pub type CFArrayRetainCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void; +pub type CFArrayReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void); +pub type CFArrayCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef; +pub type CFArrayEqualCallBack = extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFArrayCallBacks { + pub version: CFIndex, + pub retain: CFArrayRetainCallBack, + pub release: CFArrayReleaseCallBack, + pub copyDescription: CFArrayCopyDescriptionCallBack, + pub equal: CFArrayEqualCallBack, +} + +#[repr(C)] +pub struct __CFArray(c_void); + +pub type CFArrayRef = *const __CFArray; + +extern { + /* + * CFArray.h + */ + pub static kCFTypeArrayCallBacks: CFArrayCallBacks; + + pub fn CFArrayCreate(allocator: CFAllocatorRef, values: *const *const c_void, + numValues: CFIndex, callBacks: *const CFArrayCallBacks) -> CFArrayRef; + pub fn CFArrayCreateCopy(allocator: CFAllocatorRef , theArray: CFArrayRef) -> CFArrayRef; + + // CFArrayBSearchValues + // CFArrayContainsValue + pub fn CFArrayGetCount(theArray: CFArrayRef) -> CFIndex; + // CFArrayGetCountOfValue + // CFArrayGetFirstIndexOfValue + // CFArrayGetLastIndexOfValue + pub fn CFArrayGetValues(theArray: CFArrayRef, range: CFRange, values: *mut *const c_void); + pub fn CFArrayGetValueAtIndex(theArray: CFArrayRef, idx: CFIndex) -> *const c_void; + // CFArrayApplyFunction + pub fn CFArrayGetTypeID() -> CFTypeID; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/attributed_string.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/attributed_string.rs new file mode 100644 index 0000000..ecdffe6 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/attributed_string.rs @@ -0,0 +1,56 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; +use base::{CFAllocatorRef, CFTypeRef, CFIndex, CFRange, CFTypeID}; +use string::CFStringRef; +use dictionary::CFDictionaryRef; + +#[repr(C)] +pub struct __CFAttributedString(c_void); + +pub type CFAttributedStringRef = *const __CFAttributedString; +pub type CFMutableAttributedStringRef = *const __CFAttributedString; + +extern { + /* CFAttributedString */ + + pub fn CFAttributedStringCreate( + allocator: CFAllocatorRef, + str: CFStringRef, + attributes: CFDictionaryRef, + ) -> CFAttributedStringRef; + + pub fn CFAttributedStringGetLength(astr: CFAttributedStringRef) -> CFIndex; + + pub fn CFAttributedStringGetTypeID() -> CFTypeID; + + /* CFMutableAttributedString */ + + pub fn CFAttributedStringCreateMutableCopy( + allocator: CFAllocatorRef, max_length: CFIndex, astr: CFAttributedStringRef + ) -> CFMutableAttributedStringRef; + + pub fn CFAttributedStringCreateMutable( + allocator: CFAllocatorRef, + max_length: CFIndex, + ) -> CFMutableAttributedStringRef; + + pub fn CFAttributedStringReplaceString( + astr: CFMutableAttributedStringRef, range: CFRange, replacement: CFStringRef); + + pub fn CFAttributedStringSetAttribute( + astr: CFMutableAttributedStringRef, + range: CFRange, + attr_name: CFStringRef, + value: CFTypeRef, + ); + + pub fn CFMutableAttributedStringGetTypeID() -> CFTypeID; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/base.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/base.rs new file mode 100644 index 0000000..8cbae38 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/base.rs @@ -0,0 +1,154 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cmp::Ordering; +use std::os::raw::{c_uint, c_long, c_ulong, c_void, c_int}; +use string::CFStringRef; + +pub type Boolean = u8; +pub type CFIndex = c_long; +pub type mach_port_t = c_uint; +pub type CFAllocatorRef = *const c_void; +pub type CFNullRef = *const c_void; +pub type CFHashCode = c_ulong; +pub type CFTypeID = c_ulong; +pub type CFTypeRef = *const c_void; +pub type CFOptionFlags = u32; +pub type OSStatus = i32; +pub type SInt32 = c_int; + +#[repr(i64)] +#[derive(Clone, Copy)] +pub enum CFComparisonResult { + LessThan = -1, + EqualTo = 0, + GreaterThan = 1, +} + +impl Into for CFComparisonResult { + fn into(self) -> Ordering { + match self { + CFComparisonResult::LessThan => Ordering::Less, + CFComparisonResult::EqualTo => Ordering::Equal, + CFComparisonResult::GreaterThan => Ordering::Greater + } + } +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFRange { + pub location: CFIndex, + pub length: CFIndex +} + +// for back-compat +impl CFRange { + pub fn init(location: CFIndex, length: CFIndex) -> CFRange { + CFRange { + location: location, + length: length, + } + } +} + +pub type CFAllocatorRetainCallBack = extern "C" fn(info: *mut c_void) -> *mut c_void; +pub type CFAllocatorReleaseCallBack = extern "C" fn(info: *mut c_void); +pub type CFAllocatorCopyDescriptionCallBack = extern "C" fn(info: *mut c_void) -> CFStringRef; +pub type CFAllocatorAllocateCallBack = extern "C" fn(allocSize: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> *mut c_void; +pub type CFAllocatorReallocateCallBack = extern "C" fn(ptr: *mut c_void, newsize: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> *mut c_void; +pub type CFAllocatorDeallocateCallBack = extern "C" fn(ptr: *mut c_void, info: *mut c_void); +pub type CFAllocatorPreferredSizeCallBack = extern "C" fn(size: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> CFIndex; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFAllocatorContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: CFAllocatorRetainCallBack, + pub release: CFAllocatorReleaseCallBack, + pub copyDescription: CFAllocatorCopyDescriptionCallBack, + pub allocate: CFAllocatorAllocateCallBack, + pub reallocate: CFAllocatorReallocateCallBack, + pub deallocate: CFAllocatorDeallocateCallBack, + pub preferredSize: CFAllocatorPreferredSizeCallBack +} + +/// Trait for all types which are Core Foundation reference types. +pub trait TCFTypeRef { + fn as_void_ptr(&self) -> *const c_void; + + unsafe fn from_void_ptr(ptr: *const c_void) -> Self; +} + +impl TCFTypeRef for *const T { + fn as_void_ptr(&self) -> *const c_void { + (*self) as *const c_void + } + + unsafe fn from_void_ptr(ptr: *const c_void) -> Self { + ptr as *const T + } +} + +impl TCFTypeRef for *mut T { + fn as_void_ptr(&self) -> *const c_void { + (*self) as *const T as *const c_void + } + + unsafe fn from_void_ptr(ptr: *const c_void) -> Self { + ptr as *const T as *mut T + } +} + +extern { + /* + * CFBase.h + */ + + /* CFAllocator Reference */ + + pub static kCFAllocatorDefault: CFAllocatorRef; + pub static kCFAllocatorSystemDefault: CFAllocatorRef; + pub static kCFAllocatorMalloc: CFAllocatorRef; + pub static kCFAllocatorMallocZone: CFAllocatorRef; + pub static kCFAllocatorNull: CFAllocatorRef; + pub static kCFAllocatorUseContext: CFAllocatorRef; + + pub fn CFAllocatorCreate(allocator: CFAllocatorRef, context: *mut CFAllocatorContext) -> CFAllocatorRef; + pub fn CFAllocatorAllocate(allocator: CFAllocatorRef, size: CFIndex, hint: CFOptionFlags) -> *mut c_void; + pub fn CFAllocatorDeallocate(allocator: CFAllocatorRef, ptr: *mut c_void); + pub fn CFAllocatorGetPreferredSizeForSize(allocator: CFAllocatorRef, size: CFIndex, hint: CFOptionFlags) -> CFIndex; + pub fn CFAllocatorReallocate(allocator: CFAllocatorRef, ptr: *mut c_void, newsize: CFIndex, hint: CFOptionFlags) -> *mut c_void; + pub fn CFAllocatorGetDefault() -> CFAllocatorRef; + pub fn CFAllocatorSetDefault(allocator: CFAllocatorRef); + pub fn CFAllocatorGetContext(allocator: CFAllocatorRef, context: *mut CFAllocatorContext); + pub fn CFAllocatorGetTypeID() -> CFTypeID; + + /* CFNull Reference */ + + pub static kCFNull: CFNullRef; + + /* CFType Reference */ + + //fn CFCopyTypeIDDescription + //fn CFGetAllocator + pub fn CFCopyDescription(cf: CFTypeRef) -> CFStringRef; + pub fn CFEqual(cf1: CFTypeRef, cf2: CFTypeRef) -> Boolean; + pub fn CFGetRetainCount(cf: CFTypeRef) -> CFIndex; + pub fn CFGetTypeID(cf: CFTypeRef) -> CFTypeID; + pub fn CFHash(cf: CFTypeRef) -> CFHashCode; + //fn CFMakeCollectable + pub fn CFRelease(cf: CFTypeRef); + pub fn CFRetain(cf: CFTypeRef) -> CFTypeRef; + pub fn CFShow(obj: CFTypeRef); + + /* Base Utilities Reference */ + // N.B. Some things missing here. +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/bundle.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/bundle.rs new file mode 100644 index 0000000..687b00e --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/bundle.rs @@ -0,0 +1,36 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFTypeID, CFAllocatorRef}; +use url::CFURLRef; +use dictionary::CFDictionaryRef; +use string::CFStringRef; + +#[repr(C)] +pub struct __CFBundle(c_void); + +pub type CFBundleRef = *mut __CFBundle; + +extern { + /* + * CFBundle.h + */ + pub fn CFBundleCreate(allocator: CFAllocatorRef, bundleURL: CFURLRef) -> CFBundleRef; + + pub fn CFBundleGetBundleWithIdentifier(bundleID: CFStringRef) -> CFBundleRef; + pub fn CFBundleGetFunctionPointerForName(bundle: CFBundleRef, function_name: CFStringRef) -> *const c_void; + pub fn CFBundleGetMainBundle() -> CFBundleRef; + pub fn CFBundleGetInfoDictionary(bundle: CFBundleRef) -> CFDictionaryRef; + + pub fn CFBundleGetTypeID() -> CFTypeID; + pub fn CFBundleCopyExecutableURL(bundle: CFBundleRef) -> CFURLRef; + pub fn CFBundleCopyPrivateFrameworksURL(bundle: CFBundleRef) -> CFURLRef; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/data.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/data.rs new file mode 100644 index 0000000..51b3a4c --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/data.rs @@ -0,0 +1,31 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFAllocatorRef, CFTypeID, CFIndex}; + +#[repr(C)] +pub struct __CFData(c_void); + +pub type CFDataRef = *const __CFData; + +extern { + /* + * CFData.h + */ + + pub fn CFDataCreate(allocator: CFAllocatorRef, + bytes: *const u8, length: CFIndex) -> CFDataRef; + //fn CFDataFind + pub fn CFDataGetBytePtr(theData: CFDataRef) -> *const u8; + pub fn CFDataGetLength(theData: CFDataRef) -> CFIndex; + + pub fn CFDataGetTypeID() -> CFTypeID; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/date.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/date.rs new file mode 100644 index 0000000..f83ce1d --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/date.rs @@ -0,0 +1,34 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFAllocatorRef, CFComparisonResult, CFTypeID}; + +#[repr(C)] +pub struct __CFDate(c_void); + +pub type CFDateRef = *const __CFDate; + +pub type CFTimeInterval = f64; +pub type CFAbsoluteTime = CFTimeInterval; + +extern { + pub static kCFAbsoluteTimeIntervalSince1904: CFTimeInterval; + pub static kCFAbsoluteTimeIntervalSince1970: CFTimeInterval; + + pub fn CFAbsoluteTimeGetCurrent() -> CFAbsoluteTime; + + pub fn CFDateCreate(allocator: CFAllocatorRef, at: CFAbsoluteTime) -> CFDateRef; + pub fn CFDateGetAbsoluteTime(date: CFDateRef) -> CFAbsoluteTime; + pub fn CFDateGetTimeIntervalSinceDate(date: CFDateRef, other: CFDateRef) -> CFTimeInterval; + pub fn CFDateCompare(date: CFDateRef, other: CFDateRef, context: *mut c_void) -> CFComparisonResult; + + pub fn CFDateGetTypeID() -> CFTypeID; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/dictionary.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/dictionary.rs new file mode 100644 index 0000000..d10e9c1 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/dictionary.rs @@ -0,0 +1,91 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFAllocatorRef, CFHashCode, CFIndex, CFTypeID, Boolean}; +use string::CFStringRef; + +pub type CFDictionaryApplierFunction = extern "C" fn(key: *const c_void, value: *const c_void, context: *mut c_void); + +pub type CFDictionaryRetainCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void; +pub type CFDictionaryReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void); +pub type CFDictionaryCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef; +pub type CFDictionaryEqualCallBack = extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean; +pub type CFDictionaryHashCallBack = extern "C" fn(value: *const c_void) -> CFHashCode; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFDictionaryKeyCallBacks { + pub version: CFIndex, + pub retain: CFDictionaryRetainCallBack, + pub release: CFDictionaryReleaseCallBack, + pub copyDescription: CFDictionaryCopyDescriptionCallBack, + pub equal: CFDictionaryEqualCallBack, + pub hash: CFDictionaryHashCallBack +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFDictionaryValueCallBacks { + pub version: CFIndex, + pub retain: CFDictionaryRetainCallBack, + pub release: CFDictionaryReleaseCallBack, + pub copyDescription: CFDictionaryCopyDescriptionCallBack, + pub equal: CFDictionaryEqualCallBack +} + +#[repr(C)] +pub struct __CFDictionary(c_void); + +pub type CFDictionaryRef = *const __CFDictionary; +pub type CFMutableDictionaryRef = *mut __CFDictionary; + +extern { + /* + * CFDictionary.h + */ + + pub static kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks; + pub static kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks; + + pub fn CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean; + pub fn CFDictionaryCreate(allocator: CFAllocatorRef, keys: *const *const c_void, values: *const *const c_void, + numValues: CFIndex, keyCallBacks: *const CFDictionaryKeyCallBacks, + valueCallBacks: *const CFDictionaryValueCallBacks) + -> CFDictionaryRef; + pub fn CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex; + pub fn CFDictionaryGetTypeID() -> CFTypeID; + pub fn CFDictionaryGetValueIfPresent(theDict: CFDictionaryRef, key: *const c_void, value: *mut *const c_void) + -> Boolean; + pub fn CFDictionaryApplyFunction(theDict: CFDictionaryRef, + applier: CFDictionaryApplierFunction, + context: *mut c_void); + pub fn CFDictionaryGetKeysAndValues(theDict: CFDictionaryRef, + keys: *mut *const c_void, + values: *mut *const c_void); + + pub fn CFDictionaryCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex, + keyCallbacks: *const CFDictionaryKeyCallBacks, + valueCallbacks: *const CFDictionaryValueCallBacks) -> CFMutableDictionaryRef; + pub fn CFDictionaryCreateMutableCopy(allocator: CFAllocatorRef, capacity: CFIndex, + theDict: CFDictionaryRef) -> CFMutableDictionaryRef; + pub fn CFDictionaryAddValue(theDict: CFMutableDictionaryRef, + key: *const c_void, + value: *const c_void); + pub fn CFDictionarySetValue(theDict: CFMutableDictionaryRef, + key: *const c_void, + value: *const c_void); + pub fn CFDictionaryReplaceValue(theDict: CFMutableDictionaryRef, + key: *const c_void, + value: *const c_void); + pub fn CFDictionaryRemoveValue(theDict: CFMutableDictionaryRef, + key: *const c_void); + pub fn CFDictionaryRemoveAllValues(theDict: CFMutableDictionaryRef); +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/error.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/error.rs new file mode 100644 index 0000000..8a4c1d4 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/error.rs @@ -0,0 +1,32 @@ +// Copyright 2016 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFTypeID, CFIndex}; +use string::CFStringRef; + +#[repr(C)] +pub struct __CFError(c_void); + +pub type CFErrorRef = *mut __CFError; + +extern "C" { + pub fn CFErrorGetTypeID() -> CFTypeID; + + pub static kCFErrorDomainPOSIX: CFStringRef; + pub static kCFErrorDomainOSStatus: CFStringRef; + pub static kCFErrorDomainMach: CFStringRef; + pub static kCFErrorDomainCocoa: CFStringRef; + + pub fn CFErrorGetDomain(err: CFErrorRef) -> CFStringRef; + pub fn CFErrorGetCode(err: CFErrorRef) -> CFIndex; + + pub fn CFErrorCopyDescription(err: CFErrorRef) -> CFStringRef; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/filedescriptor.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/filedescriptor.rs new file mode 100644 index 0000000..3f51d10 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/filedescriptor.rs @@ -0,0 +1,58 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::{c_int, c_void}; + +use base::{Boolean, CFIndex, CFTypeID, CFOptionFlags, CFAllocatorRef}; +use string::CFStringRef; +use runloop::CFRunLoopSourceRef; + +pub type CFFileDescriptorNativeDescriptor = c_int; + +#[repr(C)] +pub struct __CFFileDescriptor(c_void); + +pub type CFFileDescriptorRef = *mut __CFFileDescriptor; + +/* Callback Reason Types */ +pub const kCFFileDescriptorReadCallBack: CFOptionFlags = 1 << 0; +pub const kCFFileDescriptorWriteCallBack: CFOptionFlags = 1 << 1; + +pub type CFFileDescriptorCallBack = extern "C" fn (f: CFFileDescriptorRef, callBackTypes: CFOptionFlags, info: *mut c_void); + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFFileDescriptorContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: Option *const c_void>, + pub release: Option, + pub copyDescription: Option CFStringRef>, +} + +extern { + /* + * CFFileDescriptor.h + */ + pub fn CFFileDescriptorGetTypeID() -> CFTypeID; + + pub fn CFFileDescriptorCreate(allocator: CFAllocatorRef, fd: CFFileDescriptorNativeDescriptor, closeOnInvalidate: Boolean, callout: CFFileDescriptorCallBack, context: *const CFFileDescriptorContext) -> CFFileDescriptorRef; + + pub fn CFFileDescriptorGetNativeDescriptor(f: CFFileDescriptorRef) -> CFFileDescriptorNativeDescriptor; + + pub fn CFFileDescriptorGetContext(f: CFFileDescriptorRef, context: *mut CFFileDescriptorContext); + + pub fn CFFileDescriptorEnableCallBacks(f: CFFileDescriptorRef, callBackTypes: CFOptionFlags); + pub fn CFFileDescriptorDisableCallBacks(f: CFFileDescriptorRef, callBackTypes: CFOptionFlags); + + pub fn CFFileDescriptorInvalidate(f: CFFileDescriptorRef); + pub fn CFFileDescriptorIsValid(f: CFFileDescriptorRef) -> Boolean; + + pub fn CFFileDescriptorCreateRunLoopSource(allocator: CFAllocatorRef, f: CFFileDescriptorRef, order: CFIndex) -> CFRunLoopSourceRef; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/lib.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/lib.rs new file mode 100644 index 0000000..e03cddb --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/lib.rs @@ -0,0 +1,30 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, improper_ctypes)] + +#![cfg_attr(all(feature="mac_os_10_7_support", feature="mac_os_10_8_features"), feature(linkage))] // back-compat requires weak linkage + +pub mod array; +pub mod attributed_string; +pub mod base; +pub mod bundle; +pub mod data; +pub mod date; +pub mod dictionary; +pub mod error; +pub mod filedescriptor; +pub mod messageport; +pub mod number; +pub mod propertylist; +pub mod runloop; +pub mod set; +pub mod string; +pub mod timezone; +pub mod url; +pub mod uuid; diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/messageport.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/messageport.rs new file mode 100644 index 0000000..e33d9aa --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/messageport.rs @@ -0,0 +1,79 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFAllocatorRef, CFIndex, CFTypeID, Boolean}; +use data::CFDataRef; +use date::CFTimeInterval; +use runloop::CFRunLoopSourceRef; +use string::CFStringRef; + +#[repr(C)] +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct CFMessagePortContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: Option *const c_void>, + pub release: Option, + pub copyDescription: Option CFStringRef>, +} + +pub type CFMessagePortCallBack = Option< + unsafe extern fn(local: CFMessagePortRef, + msgid: i32, + data: CFDataRef, + info: *mut c_void) -> CFDataRef>; + +pub type CFMessagePortInvalidationCallBack = Option< + unsafe extern "C" fn(ms: CFMessagePortRef, info: *mut c_void)>; + +#[repr(C)] +pub struct __CFMessagePort(c_void); +pub type CFMessagePortRef = *mut __CFMessagePort; + +extern { + /* + * CFMessagePort.h + */ + pub fn CFMessagePortGetTypeID() -> CFTypeID; + pub fn CFMessagePortCreateLocal(allocator: CFAllocatorRef, + name: CFStringRef, + callout: CFMessagePortCallBack, + context: *const CFMessagePortContext, + shouldFreeInfo: *mut Boolean) + -> CFMessagePortRef; + pub fn CFMessagePortCreateRemote(allocator: CFAllocatorRef, + name: CFStringRef) -> CFMessagePortRef; + pub fn CFMessagePortIsRemote(ms: CFMessagePortRef) -> Boolean; + pub fn CFMessagePortGetName(ms: CFMessagePortRef) -> CFStringRef; + pub fn CFMessagePortSetName(ms: CFMessagePortRef, newName: CFStringRef) + -> Boolean; + pub fn CFMessagePortGetContext(ms: CFMessagePortRef, + context: *mut CFMessagePortContext); + pub fn CFMessagePortInvalidate(ms: CFMessagePortRef); + pub fn CFMessagePortIsValid(ms: CFMessagePortRef) -> Boolean; + pub fn CFMessagePortGetInvalidationCallBack(ms: CFMessagePortRef) + -> CFMessagePortInvalidationCallBack; + pub fn CFMessagePortSetInvalidationCallBack(ms: CFMessagePortRef, + callout: CFMessagePortInvalidationCallBack); + pub fn CFMessagePortSendRequest(remote: CFMessagePortRef, msgid: i32, + data: CFDataRef, + sendTimeout: CFTimeInterval, + rcvTimeout: CFTimeInterval, + replyMode: CFStringRef, + returnData: *mut CFDataRef) -> i32; + pub fn CFMessagePortCreateRunLoopSource(allocator: CFAllocatorRef, + local: CFMessagePortRef, + order: CFIndex) + -> CFRunLoopSourceRef; + // CFMessagePortSetDispatchQueue +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/number.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/number.rs new file mode 100644 index 0000000..931b95d --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/number.rs @@ -0,0 +1,60 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFAllocatorRef, CFTypeID, CFComparisonResult}; + +#[repr(C)] +pub struct __CFBoolean(c_void); + +pub type CFBooleanRef = *const __CFBoolean; + +pub type CFNumberType = u32; + +// members of enum CFNumberType +// static kCFNumberSInt8Type: CFNumberType = 1; +// static kCFNumberSInt16Type: CFNumberType = 2; +pub static kCFNumberSInt32Type: CFNumberType = 3; +pub static kCFNumberSInt64Type: CFNumberType = 4; +pub static kCFNumberFloat32Type: CFNumberType = 5; +pub static kCFNumberFloat64Type: CFNumberType = 6; +// static kCFNumberCharType: CFNumberType = 7; +// static kCFNumberShortType: CFNumberType = 8; +// static kCFNumberIntType: CFNumberType = 9; +// static kCFNumberLongType: CFNumberType = 10; +// static kCFNumberLongLongType: CFNumberType = 11; +// static kCFNumberFloatType: CFNumberType = 12; +// static kCFNumberDoubleType: CFNumberType = 13; +// static kCFNumberCFIndexType: CFNumberType = 14; +// static kCFNumberNSIntegerType: CFNumberType = 15; +// static kCFNumberCGFloatType: CFNumberType = 16; +// static kCFNumberMaxType: CFNumberType = 16; + +// This is an enum due to zero-sized types warnings. +// For more details see https://github.com/rust-lang/rust/issues/27303 +pub enum __CFNumber {} + +pub type CFNumberRef = *const __CFNumber; + +extern { + /* + * CFNumber.h + */ + pub static kCFBooleanTrue: CFBooleanRef; + pub static kCFBooleanFalse: CFBooleanRef; + + pub fn CFBooleanGetTypeID() -> CFTypeID; + pub fn CFNumberCreate(allocator: CFAllocatorRef, theType: CFNumberType, valuePtr: *const c_void) + -> CFNumberRef; + //fn CFNumberGetByteSize + pub fn CFNumberGetValue(number: CFNumberRef, theType: CFNumberType, valuePtr: *mut c_void) -> bool; + pub fn CFNumberCompare(date: CFNumberRef, other: CFNumberRef, context: *mut c_void) -> CFComparisonResult; + pub fn CFNumberGetTypeID() -> CFTypeID; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/propertylist.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/propertylist.rs new file mode 100644 index 0000000..574c4d1 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/propertylist.rs @@ -0,0 +1,46 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeRef}; +use data::CFDataRef; +use error::CFErrorRef; + +pub type CFPropertyListRef = CFTypeRef; + +pub type CFPropertyListFormat = CFIndex; +pub const kCFPropertyListOpenStepFormat: CFPropertyListFormat = 1; +pub const kCFPropertyListXMLFormat_v1_0: CFPropertyListFormat = 100; +pub const kCFPropertyListBinaryFormat_v1_0: CFPropertyListFormat = 200; + +pub type CFPropertyListMutabilityOptions = CFOptionFlags; +pub const kCFPropertyListImmutable: CFPropertyListMutabilityOptions = 0; +pub const kCFPropertyListMutableContainers: CFPropertyListMutabilityOptions = 1; +pub const kCFPropertyListMutableContainersAndLeaves: CFPropertyListMutabilityOptions = 2; + +extern "C" { + // CFPropertyList.h + // + + // fn CFPropertyListCreateDeepCopy + // fn CFPropertyListIsValid + pub fn CFPropertyListCreateWithData(allocator: CFAllocatorRef, + data: CFDataRef, + options: CFPropertyListMutabilityOptions, + format: *mut CFPropertyListFormat, + error: *mut CFErrorRef) + -> CFPropertyListRef; + // fn CFPropertyListCreateWithStream + // fn CFPropertyListWrite + pub fn CFPropertyListCreateData(allocator: CFAllocatorRef, + propertyList: CFPropertyListRef, + format: CFPropertyListFormat, + options: CFOptionFlags, + error: *mut CFErrorRef) + -> CFDataRef; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/runloop.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/runloop.rs new file mode 100644 index 0000000..5de7b87 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/runloop.rs @@ -0,0 +1,164 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use array::CFArrayRef; +use base::{Boolean, CFIndex, CFTypeID, CFAllocatorRef, CFOptionFlags, CFHashCode, mach_port_t}; +use date::{CFAbsoluteTime, CFTimeInterval}; +use string::CFStringRef; + +#[repr(C)] +pub struct __CFRunLoop(c_void); + +pub type CFRunLoopRef = *mut __CFRunLoop; + +#[repr(C)] +pub struct __CFRunLoopSource(c_void); + +pub type CFRunLoopSourceRef = *mut __CFRunLoopSource; + +#[repr(C)] +pub struct __CFRunLoopObserver(c_void); + +pub type CFRunLoopObserverRef = *mut __CFRunLoopObserver; + +// Reasons for CFRunLoopRunInMode() to Return +pub const kCFRunLoopRunFinished: i32 = 1; +pub const kCFRunLoopRunStopped: i32 = 2; +pub const kCFRunLoopRunTimedOut: i32 = 3; +pub const kCFRunLoopRunHandledSource: i32 = 4; + +// Run Loop Observer Activities +//typedef CF_OPTIONS(CFOptionFlags, CFRunLoopActivity) { +pub type CFRunLoopActivity = CFOptionFlags; +pub const kCFRunLoopEntry: CFOptionFlags = 1 << 0; +pub const kCFRunLoopBeforeTimers: CFOptionFlags = 1 << 1; +pub const kCFRunLoopBeforeSources: CFOptionFlags = 1 << 2; +pub const kCFRunLoopBeforeWaiting: CFOptionFlags = 1 << 5; +pub const kCFRunLoopAfterWaiting: CFOptionFlags = 1 << 6; +pub const kCFRunLoopExit: CFOptionFlags = 1 << 7; +pub const kCFRunLoopAllActivities: CFOptionFlags = 0x0FFFFFFF; + +#[repr(C)] +pub struct CFRunLoopSourceContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: extern "C" fn (info: *const c_void) -> *const c_void, + pub release: extern "C" fn (info: *const c_void), + pub copyDescription: extern "C" fn (info: *const c_void) -> CFStringRef, + pub equal: extern "C" fn (info1: *const c_void, info2: *const c_void) -> Boolean, + pub hash: extern "C" fn (info: *const c_void) -> CFHashCode, + pub schedule: extern "C" fn (info: *const c_void, rl: CFRunLoopRef, mode: CFStringRef), + pub cancel: extern "C" fn (info: *const c_void, rl: CFRunLoopRef, mode: CFStringRef), + pub perform: extern "C" fn (info: *const c_void), +} + +#[repr(C)] +pub struct CFRunLoopSourceContext1 { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: extern "C" fn (info: *const c_void) -> *const c_void, + pub release: extern "C" fn (info: *const c_void), + pub copyDescription: extern "C" fn (info: *const c_void) -> CFStringRef, + pub equal: extern "C" fn (info1: *const c_void, info2: *const c_void) -> Boolean, + pub hash: extern "C" fn (info: *const c_void) -> CFHashCode, + // note that the following two fields are platform dependent in the C header, the ones here are for OS X + pub getPort: extern "C" fn (info: *mut c_void) -> mach_port_t, + pub perform: extern "C" fn (msg: *mut c_void, size: CFIndex, allocator: CFAllocatorRef, info: *mut c_void) -> *mut c_void, +} + +#[repr(C)] +pub struct CFRunLoopObserverContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: extern "C" fn (info: *const c_void) -> *const c_void, + pub release: extern "C" fn (info: *const c_void), + pub copyDescription: extern "C" fn (info: *const c_void) -> CFStringRef, +} + +pub type CFRunLoopObserverCallBack = extern "C" fn (observer: CFRunLoopObserverRef, activity: CFRunLoopActivity, info: *mut c_void); + +#[repr(C)] +pub struct CFRunLoopTimerContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: extern "C" fn (info: *const c_void) -> *const c_void, + pub release: extern "C" fn (info: *const c_void), + pub copyDescription: extern "C" fn (info: *const c_void) -> CFStringRef, +} + +pub type CFRunLoopTimerCallBack = extern "C" fn (timer: CFRunLoopTimerRef, info: *mut c_void); + +#[repr(C)] +pub struct __CFRunLoopTimer; + +pub type CFRunLoopTimerRef = *mut __CFRunLoopTimer; + +extern { + /* + * CFRunLoop.h + */ + pub static kCFRunLoopDefaultMode: CFStringRef; + pub static kCFRunLoopCommonModes: CFStringRef; + pub fn CFRunLoopGetTypeID() -> CFTypeID; + pub fn CFRunLoopGetCurrent() -> CFRunLoopRef; + pub fn CFRunLoopGetMain() -> CFRunLoopRef; + pub fn CFRunLoopCopyCurrentMode(rl: CFRunLoopRef) -> CFStringRef; + pub fn CFRunLoopCopyAllModes(rl: CFRunLoopRef) -> CFArrayRef; + pub fn CFRunLoopAddCommonMode(rl: CFRunLoopRef, mode: CFStringRef); + pub fn CFRunLoopGetNextTimerFireDate(rl: CFRunLoopRef, mode: CFStringRef) -> CFAbsoluteTime; + pub fn CFRunLoopRun(); + pub fn CFRunLoopRunInMode(mode: CFStringRef, seconds: CFTimeInterval, returnAfterSourceHandled: Boolean) -> i32; + pub fn CFRunLoopIsWaiting(rl: CFRunLoopRef) -> Boolean; + pub fn CFRunLoopWakeUp(rl: CFRunLoopRef); + pub fn CFRunLoopStop(rl: CFRunLoopRef); + // fn CFRunLoopPerformBlock(rl: CFRunLoopRef, mode: CFTypeRef, block: void (^)(void)); + pub fn CFRunLoopContainsSource(rl: CFRunLoopRef, source: CFRunLoopSourceRef, mode: CFStringRef) -> Boolean; + pub fn CFRunLoopAddSource(rl: CFRunLoopRef, source: CFRunLoopSourceRef, mode: CFStringRef); + pub fn CFRunLoopRemoveSource(rl: CFRunLoopRef, source: CFRunLoopSourceRef, mode: CFStringRef); + pub fn CFRunLoopContainsObserver(rl: CFRunLoopRef, observer: CFRunLoopObserverRef, mode: CFStringRef) -> Boolean; + pub fn CFRunLoopAddObserver(rl: CFRunLoopRef, observer: CFRunLoopObserverRef, mode: CFStringRef); + pub fn CFRunLoopRemoveObserver(rl: CFRunLoopRef, observer: CFRunLoopObserverRef, mode: CFStringRef); + pub fn CFRunLoopContainsTimer(rl: CFRunLoopRef, timer: CFRunLoopTimerRef, mode: CFStringRef) -> Boolean; + pub fn CFRunLoopAddTimer(rl: CFRunLoopRef, timer: CFRunLoopTimerRef, mode: CFStringRef); + pub fn CFRunLoopRemoveTimer(rl: CFRunLoopRef, timer: CFRunLoopTimerRef, mode: CFStringRef); + + pub fn CFRunLoopSourceGetTypeID() -> CFTypeID; + pub fn CFRunLoopSourceCreate(allocator: CFAllocatorRef, order: CFIndex, context: *mut CFRunLoopSourceContext) -> CFRunLoopSourceRef; + pub fn CFRunLoopSourceGetOrder(source: CFRunLoopSourceRef) -> CFIndex; + pub fn CFRunLoopSourceInvalidate(source: CFRunLoopSourceRef); + pub fn CFRunLoopSourceIsValid(source: CFRunLoopSourceRef) -> Boolean; + pub fn CFRunLoopSourceGetContext(source: CFRunLoopSourceRef, context: *mut CFRunLoopSourceContext); + pub fn CFRunLoopSourceSignal(source: CFRunLoopSourceRef); + + pub fn CFRunLoopObserverGetTypeID() -> CFTypeID; + pub fn CFRunLoopObserverCreate(allocator: CFAllocatorRef, activities: CFOptionFlags, repeats: Boolean, order: CFIndex, callout: CFRunLoopObserverCallBack, context: *mut CFRunLoopObserverContext) -> CFRunLoopObserverRef; + // fn CFRunLoopObserverCreateWithHandler(allocator: CFAllocatorRef, activities: CFOptionFlags, repeats: Boolean, order: CFIndex, block: void (^) (CFRunLoopObserverRef observer, CFRunLoopActivity activity)) -> CFRunLoopObserverRef; + pub fn CFRunLoopObserverGetActivities(observer: CFRunLoopObserverRef) -> CFOptionFlags; + pub fn CFRunLoopObserverDoesRepeat(observer: CFRunLoopObserverRef) -> Boolean; + pub fn CFRunLoopObserverGetOrder(observer: CFRunLoopObserverRef) -> CFIndex; + pub fn CFRunLoopObserverInvalidate(observer: CFRunLoopObserverRef); + pub fn CFRunLoopObserverIsValid(observer: CFRunLoopObserverRef) -> Boolean; + pub fn CFRunLoopObserverGetContext(observer: CFRunLoopObserverRef, context: *mut CFRunLoopObserverContext); + + pub fn CFRunLoopTimerGetTypeID() -> CFTypeID; + pub fn CFRunLoopTimerCreate(allocator: CFAllocatorRef, fireDate: CFAbsoluteTime, interval: CFTimeInterval, flags: CFOptionFlags, order: CFIndex, callout: CFRunLoopTimerCallBack, context: *mut CFRunLoopTimerContext) -> CFRunLoopTimerRef; + // fn CFRunLoopTimerCreateWithHandler(allocator: CFAllocatorRef, fireDate: CFAbsoluteTime, interval: CFTimeInterval, flags: CFOptionFlags, order: CFIndex, block: void (^) (CFRunLoopTimerRef timer)) -> CFRunLoopTimerRef; + pub fn CFRunLoopTimerGetNextFireDate(timer: CFRunLoopTimerRef) -> CFAbsoluteTime; + pub fn CFRunLoopTimerSetNextFireDate(timer: CFRunLoopTimerRef, fireDate: CFAbsoluteTime); + pub fn CFRunLoopTimerGetInterval(timer: CFRunLoopTimerRef) -> CFTimeInterval; + pub fn CFRunLoopTimerDoesRepeat(timer: CFRunLoopTimerRef) -> Boolean; + pub fn CFRunLoopTimerGetOrder(timer: CFRunLoopTimerRef) -> CFIndex; + pub fn CFRunLoopTimerInvalidate(timer: CFRunLoopTimerRef); + pub fn CFRunLoopTimerIsValid(timer: CFRunLoopTimerRef) -> Boolean; + pub fn CFRunLoopTimerGetContext(timer: CFRunLoopTimerRef, context: *mut CFRunLoopTimerContext); + pub fn CFRunLoopTimerGetTolerance(timer: CFRunLoopTimerRef) -> CFTimeInterval; + pub fn CFRunLoopTimerSetTolerance(timer: CFRunLoopTimerRef, tolerance: CFTimeInterval); +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/set.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/set.rs new file mode 100644 index 0000000..ec4a4bd --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/set.rs @@ -0,0 +1,58 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFAllocatorRef, CFIndex, CFTypeID}; + +pub type CFSetApplierFunction = extern "C" fn (value: *const c_void, + context: *const c_void); +pub type CFSetRetainCallBack = *const u8; +pub type CFSetReleaseCallBack = *const u8; +pub type CFSetCopyDescriptionCallBack = *const u8; +pub type CFSetEqualCallBack = *const u8; +pub type CFSetHashCallBack = *const u8; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFSetCallBacks { + pub version: CFIndex, + pub retain: CFSetRetainCallBack, + pub release: CFSetReleaseCallBack, + pub copyDescription: CFSetCopyDescriptionCallBack, + pub equal: CFSetEqualCallBack, + pub hash: CFSetHashCallBack, +} + +#[repr(C)] +pub struct __CFSet(c_void); + +pub type CFSetRef = *const __CFSet; + +extern { + /* + * CFSet.h + */ + + pub static kCFTypeSetCallBacks: CFSetCallBacks; + + /* Creating Sets */ + pub fn CFSetCreate(allocator: CFAllocatorRef, values: *const *const c_void, numValues: CFIndex, + callBacks: *const CFSetCallBacks) -> CFSetRef; + + /* Applying a Function to Set Members */ + pub fn CFSetApplyFunction(theSet: CFSetRef, + applier: CFSetApplierFunction, + context: *const c_void); + + pub fn CFSetGetCount(theSet: CFSetRef) -> CFIndex; + + pub fn CFSetGetTypeID() -> CFTypeID; +} + diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/string.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/string.rs new file mode 100644 index 0000000..a990d96 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/string.rs @@ -0,0 +1,319 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::{c_char, c_ushort, c_void}; + +use base::{Boolean, CFOptionFlags, CFIndex, CFAllocatorRef, CFRange, CFTypeID}; + +pub type UniChar = c_ushort; + +// CFString.h + +pub type CFStringCompareFlags = CFOptionFlags; +//static kCFCompareCaseInsensitive: CFStringCompareFlags = 1; +//static kCFCompareBackwards: CFStringCompareFlags = 4; +//static kCFCompareAnchored: CFStringCompareFlags = 8; +//static kCFCompareNonliteral: CFStringCompareFlags = 16; +//static kCFCompareLocalized: CFStringCompareFlags = 32; +//static kCFCompareNumerically: CFStringCompareFlags = 64; +//static kCFCompareDiacriticInsensitive: CFStringCompareFlags = 128; +//static kCFCompareWidthInsensitive: CFStringCompareFlags = 256; +//static kCFCompareForcedOrdering: CFStringCompareFlags = 512; + +pub type CFStringEncoding = u32; + +// OS X built-in encodings. + +//static kCFStringEncodingMacRoman: CFStringEncoding = 0; +//static kCFStringEncodingWindowsLatin1: CFStringEncoding = 0x0500; +//static kCFStringEncodingISOLatin1: CFStringEncoding = 0x0201; +//static kCFStringEncodingNextStepLatin: CFStringEncoding = 0x0B01; +//static kCFStringEncodingASCII: CFStringEncoding = 0x0600; +//static kCFStringEncodingUnicode: CFStringEncoding = 0x0100; +pub static kCFStringEncodingUTF8: CFStringEncoding = 0x08000100; +//static kCFStringEncodingNonLossyASCII: CFStringEncoding = 0x0BFF; + +//static kCFStringEncodingUTF16: CFStringEncoding = 0x0100; +//static kCFStringEncodingUTF16BE: CFStringEncoding = 0x10000100; +//static kCFStringEncodingUTF16LE: CFStringEncoding = 0x14000100; +//static kCFStringEncodingUTF32: CFStringEncoding = 0x0c000100; +//static kCFStringEncodingUTF32BE: CFStringEncoding = 0x18000100; +//static kCFStringEncodingUTF32LE: CFStringEncoding = 0x1c000100; + + +// CFStringEncodingExt.h + +pub type CFStringEncodings = CFIndex; + +// External encodings, except those defined above. +// Defined above: kCFStringEncodingMacRoman = 0 +//static kCFStringEncodingMacJapanese: CFStringEncoding = 1; +//static kCFStringEncodingMacChineseTrad: CFStringEncoding = 2; +//static kCFStringEncodingMacKorean: CFStringEncoding = 3; +//static kCFStringEncodingMacArabic: CFStringEncoding = 4; +//static kCFStringEncodingMacHebrew: CFStringEncoding = 5; +//static kCFStringEncodingMacGreek: CFStringEncoding = 6; +//static kCFStringEncodingMacCyrillic: CFStringEncoding = 7; +//static kCFStringEncodingMacDevanagari: CFStringEncoding = 9; +//static kCFStringEncodingMacGurmukhi: CFStringEncoding = 10; +//static kCFStringEncodingMacGujarati: CFStringEncoding = 11; +//static kCFStringEncodingMacOriya: CFStringEncoding = 12; +//static kCFStringEncodingMacBengali: CFStringEncoding = 13; +//static kCFStringEncodingMacTamil: CFStringEncoding = 14; +//static kCFStringEncodingMacTelugu: CFStringEncoding = 15; +//static kCFStringEncodingMacKannada: CFStringEncoding = 16; +//static kCFStringEncodingMacMalayalam: CFStringEncoding = 17; +//static kCFStringEncodingMacSinhalese: CFStringEncoding = 18; +//static kCFStringEncodingMacBurmese: CFStringEncoding = 19; +//static kCFStringEncodingMacKhmer: CFStringEncoding = 20; +//static kCFStringEncodingMacThai: CFStringEncoding = 21; +//static kCFStringEncodingMacLaotian: CFStringEncoding = 22; +//static kCFStringEncodingMacGeorgian: CFStringEncoding = 23; +//static kCFStringEncodingMacArmenian: CFStringEncoding = 24; +//static kCFStringEncodingMacChineseSimp: CFStringEncoding = 25; +//static kCFStringEncodingMacTibetan: CFStringEncoding = 26; +//static kCFStringEncodingMacMongolian: CFStringEncoding = 27; +//static kCFStringEncodingMacEthiopic: CFStringEncoding = 28; +//static kCFStringEncodingMacCentralEurRoman: CFStringEncoding = 29; +//static kCFStringEncodingMacVietnamese: CFStringEncoding = 30; +//static kCFStringEncodingMacExtArabic: CFStringEncoding = 31; +//static kCFStringEncodingMacSymbol: CFStringEncoding = 33; +//static kCFStringEncodingMacDingbats: CFStringEncoding = 34; +//static kCFStringEncodingMacTurkish: CFStringEncoding = 35; +//static kCFStringEncodingMacCroatian: CFStringEncoding = 36; +//static kCFStringEncodingMacIcelandic: CFStringEncoding = 37; +//static kCFStringEncodingMacRomanian: CFStringEncoding = 38; +//static kCFStringEncodingMacCeltic: CFStringEncoding = 39; +//static kCFStringEncodingMacGaelic: CFStringEncoding = 40; +//static kCFStringEncodingMacFarsi: CFStringEncoding = 0x8C; +//static kCFStringEncodingMacUkrainian: CFStringEncoding = 0x98; +//static kCFStringEncodingMacInuit: CFStringEncoding = 0xEC; +//static kCFStringEncodingMacVT100: CFStringEncoding = 0xFC; +//static kCFStringEncodingMacHFS: CFStringEncoding = 0xFF; +// Defined above: kCFStringEncodingISOLatin1 = 0x0201 +//static kCFStringEncodingISOLatin2: CFStringEncoding = 0x0202; +//static kCFStringEncodingISOLatin3: CFStringEncoding = 0x0203; +//static kCFStringEncodingISOLatin4: CFStringEncoding = 0x0204; +//static kCFStringEncodingISOLatinCyrillic: CFStringEncoding = 0x0205; +//static kCFStringEncodingISOLatinArabic: CFStringEncoding = 0x0206; +//static kCFStringEncodingISOLatinGreek: CFStringEncoding = 0x0207; +//static kCFStringEncodingISOLatinHebrew: CFStringEncoding = 0x0208; +//static kCFStringEncodingISOLatin5: CFStringEncoding = 0x0209; +//static kCFStringEncodingISOLatin6: CFStringEncoding = 0x020A; +//static kCFStringEncodingISOLatinThai: CFStringEncoding = 0x020B; +//static kCFStringEncodingISOLatin7: CFStringEncoding = 0x020D; +//static kCFStringEncodingISOLatin8: CFStringEncoding = 0x020E; +//static kCFStringEncodingISOLatin9: CFStringEncoding = 0x020F; +//static kCFStringEncodingISOLatin10: CFStringEncoding = 0x0210; +//static kCFStringEncodingDOSLatinUS: CFStringEncoding = 0x0400; +//static kCFStringEncodingDOSGreek: CFStringEncoding = 0x0405; +//static kCFStringEncodingDOSBalticRim: CFStringEncoding = 0x0406; +//static kCFStringEncodingDOSLatin1: CFStringEncoding = 0x0410; +//static kCFStringEncodingDOSGreek1: CFStringEncoding = 0x0411; +//static kCFStringEncodingDOSLatin2: CFStringEncoding = 0x0412; +//static kCFStringEncodingDOSCyrillic: CFStringEncoding = 0x0413; +//static kCFStringEncodingDOSTurkish: CFStringEncoding = 0x0414; +//static kCFStringEncodingDOSPortuguese: CFStringEncoding = 0x0415; +//static kCFStringEncodingDOSIcelandic: CFStringEncoding = 0x0416; +//static kCFStringEncodingDOSHebrew: CFStringEncoding = 0x0417; +//static kCFStringEncodingDOSCanadianFrench: CFStringEncoding = 0x0418; +//static kCFStringEncodingDOSArabic: CFStringEncoding = 0x0419; +//static kCFStringEncodingDOSNordic: CFStringEncoding = 0x041A; +//static kCFStringEncodingDOSRussian: CFStringEncoding = 0x041B; +//static kCFStringEncodingDOSGreek2: CFStringEncoding = 0x041C; +//static kCFStringEncodingDOSThai: CFStringEncoding = 0x041D; +//static kCFStringEncodingDOSJapanese: CFStringEncoding = 0x0420; +//static kCFStringEncodingDOSChineseSimplif: CFStringEncoding = 0x0421; +//static kCFStringEncodingDOSKorean: CFStringEncoding = 0x0422; +//static kCFStringEncodingDOSChineseTrad: CFStringEncoding = 0x0423; +// Defined above: kCFStringEncodingWindowsLatin1 = 0x0500 +//static kCFStringEncodingWindowsLatin2: CFStringEncoding = 0x0501; +//static kCFStringEncodingWindowsCyrillic: CFStringEncoding = 0x0502; +//static kCFStringEncodingWindowsGreek: CFStringEncoding = 0x0503; +//static kCFStringEncodingWindowsLatin5: CFStringEncoding = 0x0504; +//static kCFStringEncodingWindowsHebrew: CFStringEncoding = 0x0505; +//static kCFStringEncodingWindowsArabic: CFStringEncoding = 0x0506; +//static kCFStringEncodingWindowsBalticRim: CFStringEncoding = 0x0507; +//static kCFStringEncodingWindowsVietnamese: CFStringEncoding = 0x0508; +//static kCFStringEncodingWindowsKoreanJohab: CFStringEncoding = 0x0510; +// Defined above: kCFStringEncodingASCII = 0x0600 +//static kCFStringEncodingANSEL: CFStringEncoding = 0x0601; +//static kCFStringEncodingJIS_X0201_76: CFStringEncoding = 0x0620; +//static kCFStringEncodingJIS_X0208_83: CFStringEncoding = 0x0621; +//static kCFStringEncodingJIS_X0208_90: CFStringEncoding = 0x0622; +//static kCFStringEncodingJIS_X0212_90: CFStringEncoding = 0x0623; +//static kCFStringEncodingJIS_C6226_78: CFStringEncoding = 0x0624; +//static kCFStringEncodingShiftJIS_X0213: CFStringEncoding = 0x0628; +//static kCFStringEncodingShiftJIS_X0213_MenKuTen: CFStringEncoding = 0x0629; +//static kCFStringEncodingGB_2312_80: CFStringEncoding = 0x0630; +//static kCFStringEncodingGBK_95: CFStringEncoding = 0x0631; +//static kCFStringEncodingGB_18030_2000: CFStringEncoding = 0x0632; +//static kCFStringEncodingKSC_5601_87: CFStringEncoding = 0x0640; +//static kCFStringEncodingKSC_5601_92_Johab: CFStringEncoding = 0x0641; +//static kCFStringEncodingCNS_11643_92_P1: CFStringEncoding = 0x0651; +//static kCFStringEncodingCNS_11643_92_P2: CFStringEncoding = 0x0652; +//static kCFStringEncodingCNS_11643_92_P3: CFStringEncoding = 0x0653; +//static kCFStringEncodingISO_2022_JP: CFStringEncoding = 0x0820; +//static kCFStringEncodingISO_2022_JP_2: CFStringEncoding = 0x0821; +//static kCFStringEncodingISO_2022_JP_1: CFStringEncoding = 0x0822; +//static kCFStringEncodingISO_2022_JP_3: CFStringEncoding = 0x0823; +//static kCFStringEncodingISO_2022_CN: CFStringEncoding = 0x0830; +//static kCFStringEncodingISO_2022_CN_EXT: CFStringEncoding = 0x0831; +//static kCFStringEncodingISO_2022_KR: CFStringEncoding = 0x0840; +//static kCFStringEncodingEUC_JP: CFStringEncoding = 0x0920; +//static kCFStringEncodingEUC_CN: CFStringEncoding = 0x0930; +//static kCFStringEncodingEUC_TW: CFStringEncoding = 0x0931; +//static kCFStringEncodingEUC_KR: CFStringEncoding = 0x0940; +//static kCFStringEncodingShiftJIS: CFStringEncoding = 0x0A01; +//static kCFStringEncodingKOI8_R: CFStringEncoding = 0x0A02; +//static kCFStringEncodingBig5: CFStringEncoding = 0x0A03; +//static kCFStringEncodingMacRomanLatin1: CFStringEncoding = 0x0A04; +//static kCFStringEncodingHZ_GB_2312: CFStringEncoding = 0x0A05; +//static kCFStringEncodingBig5_HKSCS_1999: CFStringEncoding = 0x0A06; +//static kCFStringEncodingVISCII: CFStringEncoding = 0x0A07; +//static kCFStringEncodingKOI8_U: CFStringEncoding = 0x0A08; +//static kCFStringEncodingBig5_E: CFStringEncoding = 0x0A09; +// Defined above: kCFStringEncodingNextStepLatin = 0x0B01 +//static kCFStringEncodingNextStepJapanese: CFStringEncoding = 0x0B02; +//static kCFStringEncodingEBCDIC_US: CFStringEncoding = 0x0C01; +//static kCFStringEncodingEBCDIC_CP037: CFStringEncoding = 0x0C02; +//static kCFStringEncodingUTF7: CFStringEncoding = 0x04000100; +//static kCFStringEncodingUTF7_IMAP: CFStringEncoding = 0x0A10; +//static kCFStringEncodingShiftJIS_X0213_00: CFStringEncoding = 0x0628; /* Deprecated */ + +#[repr(C)] +pub struct __CFString(c_void); + +pub type CFStringRef = *const __CFString; + +extern { + /* + * CFString.h + */ + + // N.B. organized according to "Functions by task" in docs + + /* Creating a CFString */ + //fn CFSTR + //fn CFStringCreateArrayBySeparatingStrings + //fn CFStringCreateByCombiningStrings + //fn CFStringCreateCopy + //fn CFStringCreateFromExternalRepresentation + pub fn CFStringCreateWithBytes(alloc: CFAllocatorRef, + bytes: *const u8, + numBytes: CFIndex, + encoding: CFStringEncoding, + isExternalRepresentation: Boolean) + -> CFStringRef; + pub fn CFStringCreateWithBytesNoCopy(alloc: CFAllocatorRef, + bytes: *const u8, + numBytes: CFIndex, + encoding: CFStringEncoding, + isExternalRepresentation: Boolean, + contentsDeallocator: CFAllocatorRef) + -> CFStringRef; + //fn CFStringCreateWithCharacters + //fn CFStringCreateWithCharactersNoCopy + pub fn CFStringCreateWithCString(alloc: CFAllocatorRef, + cStr: *const c_char, + encoding: CFStringEncoding) + -> CFStringRef; + //fn CFStringCreateWithCStringNoCopy + //fn CFStringCreateWithFormat + //fn CFStringCreateWithFormatAndArguments + //fn CFStringCreateWithPascalString + //fn CFStringCreateWithPascalStringNoCopy + //fn CFStringCreateWithSubstring + + /* Searching Strings */ + //fn CFStringCreateArrayWithFindResults + //fn CFStringFind + //fn CFStringFindCharacterFromSet + //fn CFStringFindWithOptions + //fn CFStringFindWithOptionsAndLocale + //fn CFStringGetLineBounds + + /* Comparing Strings */ + //fn CFStringCompare + //fn CFStringCompareWithOptions + //fn CFStringCompareWithOptionsAndLocale + //fn CFStringHasPrefix + //fn CFStringHasSuffix + + /* Accessing Characters */ + //fn CFStringCreateExternalRepresentation + pub fn CFStringGetBytes(theString: CFStringRef, + range: CFRange, + encoding: CFStringEncoding, + lossByte: u8, + isExternalRepresentation: Boolean, + buffer: *mut u8, + maxBufLen: CFIndex, + usedBufLen: *mut CFIndex) + -> CFIndex; + //fn CFStringGetCharacterAtIndex + //fn CFStringGetCharacters + //fn CFStringGetCharactersPtr + //fn CFStringGetCharacterFromInlineBuffer + pub fn CFStringGetCString(theString: CFStringRef, + buffer: *mut c_char, + bufferSize: CFIndex, + encoding: CFStringEncoding) + -> Boolean; + pub fn CFStringGetCStringPtr(theString: CFStringRef, + encoding: CFStringEncoding) + -> *const c_char; + pub fn CFStringGetLength(theString: CFStringRef) -> CFIndex; + //fn CFStringGetPascalString + //fn CFStringGetPascalStringPtr + //fn CFStringGetRangeOfComposedCharactersAtIndex + //fn CFStringInitInlineBuffer + + /* Working With Hyphenation */ + //fn CFStringGetHyphenationLocationBeforeIndex + //fn CFStringIsHyphenationAvailableForLocale + + /* Working With Encodings */ + //fn CFStringConvertEncodingToIANACharSetName + //fn CFStringConvertEncodingToNSStringEncoding + //fn CFStringConvertEncodingToWindowsCodepage + //fn CFStringConvertIANACharSetNameToEncoding + //fn CFStringConvertNSStringEncodingToEncoding + //fn CFStringConvertWindowsCodepageToEncoding + //fn CFStringGetFastestEncoding + //fn CFStringGetListOfAvailableEncodings + //fn CFStringGetMaximumSizeForEncoding + //fn CFStringGetMostCompatibleMacStringEncoding + //fn CFStringGetNameOfEncoding + //fn CFStringGetSmallestEncoding + //fn CFStringGetSystemEncoding + //fn CFStringIsEncodingAvailable + + /* Getting Numeric Values */ + //fn CFStringGetDoubleValue + //fn CFStringGetIntValue + + /* Getting String Properties */ + //fn CFShowStr + pub fn CFStringGetTypeID() -> CFTypeID; + + /* String File System Representations */ + //fn CFStringCreateWithFileSystemRepresentation + //fn CFStringGetFileSystemRepresentation + //fn CFStringGetMaximumSizeOfFileSystemRepresentation + + /* Getting Paragraph Bounds */ + //fn CFStringGetParagraphBounds + + /* Managing Surrogates */ + //fn CFStringGetLongCharacterForSurrogatePair + //fn CFStringGetSurrogatePairForLongCharacter + //fn CFStringIsSurrogateHighCharacter + //fn CFStringIsSurrogateLowCharacter +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/timezone.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/timezone.rs new file mode 100644 index 0000000..376cfdc --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/timezone.rs @@ -0,0 +1,27 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFAllocatorRef, CFTypeID}; +use date::{CFTimeInterval, CFAbsoluteTime}; + +#[repr(C)] +pub struct __CFTimeZone(c_void); + +pub type CFTimeZoneRef = *const __CFTimeZone; + +extern { + pub fn CFTimeZoneCopySystem() -> CFTimeZoneRef; + pub fn CFTimeZoneCopyDefault() -> CFTimeZoneRef; + pub fn CFTimeZoneCreateWithTimeIntervalFromGMT(allocator: CFAllocatorRef, interval: CFTimeInterval) -> CFTimeZoneRef; + pub fn CFTimeZoneGetSecondsFromGMT(tz: CFTimeZoneRef, time: CFAbsoluteTime) -> CFTimeInterval; + + pub fn CFTimeZoneGetTypeID() -> CFTypeID; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/url.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/url.rs new file mode 100644 index 0000000..9c4bc3e --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/url.rs @@ -0,0 +1,164 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFOptionFlags, CFIndex, CFAllocatorRef, Boolean, CFTypeID, CFTypeRef, SInt32}; +use string::{CFStringRef, CFStringEncoding}; +use error::CFErrorRef; + +#[repr(C)] +pub struct __CFURL(c_void); + +pub type CFURLRef = *const __CFURL; + +pub type CFURLBookmarkCreationOptions = CFOptionFlags; + +pub type CFURLPathStyle = CFIndex; + +/* typedef CF_ENUM(CFIndex, CFURLPathStyle) */ +pub const kCFURLPOSIXPathStyle: CFURLPathStyle = 0; +pub const kCFURLHFSPathStyle: CFURLPathStyle = 1; +pub const kCFURLWindowsPathStyle: CFURLPathStyle = 2; + +// static kCFURLBookmarkCreationPreferFileIDResolutionMask: CFURLBookmarkCreationOptions = +// (1 << 8) as u32; +// static kCFURLBookmarkCreationMinimalBookmarkMask: CFURLBookmarkCreationOptions = +// (1 << 9) as u32; +// static kCFURLBookmarkCreationSuitableForBookmarkFile: CFURLBookmarkCreationOptions = +// (1 << 10) as u32; +// static kCFURLBookmarkCreationWithSecurityScope: CFURLBookmarkCreationOptions = +// (1 << 11) as u32; +// static kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess: CFURLBookmarkCreationOptions = +// (1 << 12) as u32; + +// TODO: there are a lot of missing keys and constants. Add if you are bored or need them. + +extern { + /* + * CFURL.h + */ + + /* Common File System Resource Keys */ + pub static kCFURLAttributeModificationDateKey: CFStringRef; + pub static kCFURLContentAccessDateKey: CFStringRef; + pub static kCFURLContentModificationDateKey: CFStringRef; + pub static kCFURLCreationDateKey: CFStringRef; + pub static kCFURLFileResourceIdentifierKey: CFStringRef; + pub static kCFURLFileSecurityKey: CFStringRef; + pub static kCFURLHasHiddenExtensionKey: CFStringRef; + pub static kCFURLIsDirectoryKey: CFStringRef; + pub static kCFURLIsExecutableKey: CFStringRef; + pub static kCFURLIsHiddenKey: CFStringRef; + pub static kCFURLIsPackageKey: CFStringRef; + pub static kCFURLIsReadableKey: CFStringRef; + pub static kCFURLIsRegularFileKey: CFStringRef; + pub static kCFURLIsSymbolicLinkKey: CFStringRef; + pub static kCFURLIsSystemImmutableKey: CFStringRef; + pub static kCFURLIsUserImmutableKey: CFStringRef; + pub static kCFURLIsVolumeKey: CFStringRef; + pub static kCFURLIsWritableKey: CFStringRef; + pub static kCFURLLabelNumberKey: CFStringRef; + pub static kCFURLLinkCountKey: CFStringRef; + pub static kCFURLLocalizedLabelKey: CFStringRef; + pub static kCFURLLocalizedNameKey: CFStringRef; + pub static kCFURLLocalizedTypeDescriptionKey: CFStringRef; + pub static kCFURLNameKey: CFStringRef; + pub static kCFURLParentDirectoryURLKey: CFStringRef; + pub static kCFURLPreferredIOBlockSizeKey: CFStringRef; + pub static kCFURLTypeIdentifierKey: CFStringRef; + pub static kCFURLVolumeIdentifierKey: CFStringRef; + pub static kCFURLVolumeURLKey: CFStringRef; + + #[cfg(feature="mac_os_10_8_features")] + #[cfg_attr(feature = "mac_os_10_7_support", linkage = "extern_weak")] + pub static kCFURLIsExcludedFromBackupKey: CFStringRef; + pub static kCFURLFileResourceTypeKey: CFStringRef; + + /* Creating a CFURL */ + pub fn CFURLCopyAbsoluteURL(anURL: CFURLRef) -> CFURLRef; + //fn CFURLCreateAbsoluteURLWithBytes + //fn CFURLCreateByResolvingBookmarkData + //fn CFURLCreateCopyAppendingPathComponent + //fn CFURLCreateCopyAppendingPathExtension + //fn CFURLCreateCopyDeletingLastPathComponent + //fn CFURLCreateCopyDeletingPathExtension + pub fn CFURLCreateFilePathURL(allocator: CFAllocatorRef, url: CFURLRef, error: *mut CFErrorRef) -> CFURLRef; + //fn CFURLCreateFileReferenceURL + pub fn CFURLCreateFromFileSystemRepresentation(allocator: CFAllocatorRef, buffer: *const u8, bufLen: CFIndex, isDirectory: Boolean) -> CFURLRef; + //fn CFURLCreateFromFileSystemRepresentationRelativeToBase + //fn CFURLCreateFromFSRef + pub fn CFURLCreateWithBytes(allocator: CFAllocatorRef, URLBytes: *const u8, length: CFIndex, encoding: CFStringEncoding, baseURL: CFURLRef) -> CFURLRef; + pub fn CFURLCreateWithFileSystemPath(allocator: CFAllocatorRef, filePath: CFStringRef, pathStyle: CFURLPathStyle, isDirectory: Boolean) -> CFURLRef; + pub fn CFURLCreateWithFileSystemPathRelativeToBase(allocator: CFAllocatorRef, filePath: CFStringRef, pathStyle: CFURLPathStyle, isDirectory: Boolean, baseURL: CFURLRef) -> CFURLRef; + //fn CFURLCreateWithString(allocator: CFAllocatorRef, urlString: CFStringRef, + // baseURL: CFURLRef) -> CFURLRef; + + /* Accessing the Parts of a URL */ + pub fn CFURLCanBeDecomposed(anURL: CFURLRef) -> Boolean; + pub fn CFURLCopyFileSystemPath(anURL: CFURLRef, pathStyle: CFURLPathStyle) -> CFStringRef; + pub fn CFURLCopyFragment(anURL: CFURLRef, charactersToLeaveEscaped: CFStringRef) -> CFStringRef; + pub fn CFURLCopyHostName(anURL: CFURLRef) -> CFStringRef; + pub fn CFURLCopyLastPathComponent(anURL: CFURLRef) -> CFStringRef; + pub fn CFURLCopyNetLocation(anURL: CFURLRef) -> CFStringRef; + pub fn CFURLCopyParameterString(anURL: CFURLRef, charactersToLeaveEscaped: CFStringRef) -> CFStringRef; + pub fn CFURLCopyPassword(anURL: CFURLRef) -> CFStringRef; + pub fn CFURLCopyPath(anURL: CFURLRef) -> CFStringRef; + pub fn CFURLCopyPathExtension(anURL: CFURLRef) -> CFStringRef; + pub fn CFURLCopyQueryString(anURL: CFURLRef, charactersToLeaveEscaped: CFStringRef) -> CFStringRef; + pub fn CFURLCopyResourceSpecifier(anURL: CFURLRef) -> CFStringRef; + pub fn CFURLCopyScheme(anURL: CFURLRef) -> CFStringRef; + pub fn CFURLCopyStrictPath(anURL: CFURLRef, isAbsolute: *mut Boolean) -> CFStringRef; + pub fn CFURLCopyUserName(anURL: CFURLRef) -> CFStringRef; + pub fn CFURLGetPortNumber(anURL: CFURLRef) -> SInt32; + pub fn CFURLHasDirectoryPath(anURL: CFURLRef) -> Boolean; + + /* Converting URLs to Other Representations */ + //fn CFURLCreateData(allocator: CFAllocatorRef, url: CFURLRef, + // encoding: CFStringEncoding, escapeWhitespace: bool) -> CFDataRef; + //fn CFURLCreateStringByAddingPercentEscapes + //fn CFURLCreateStringByReplacingPercentEscapes + //fn CFURLCreateStringByReplacingPercentEscapesUsingEncoding + pub fn CFURLGetFileSystemRepresentation(anURL: CFURLRef, resolveAgainstBase: Boolean, buffer: *mut u8, maxBufLen: CFIndex) -> Boolean; + + //fn CFURLGetFSRef + pub fn CFURLGetString(anURL: CFURLRef) -> CFStringRef; + + /* Getting URL Properties */ + //fn CFURLGetBaseURL(anURL: CFURLRef) -> CFURLRef; + pub fn CFURLGetBytes(anURL: CFURLRef, buffer: *mut u8, bufferLength: CFIndex) -> CFIndex; + //fn CFURLGetByteRangeForComponent + pub fn CFURLGetTypeID() -> CFTypeID; + //fn CFURLResourceIsReachable + + /* Getting and Setting File System Resource Properties */ + pub fn CFURLClearResourcePropertyCache(url: CFURLRef); + //fn CFURLClearResourcePropertyCacheForKey + //fn CFURLCopyResourcePropertiesForKeys + //fn CFURLCopyResourcePropertyForKey + //fn CFURLCreateResourcePropertiesForKeysFromBookmarkData + //fn CFURLCreateResourcePropertyForKeyFromBookmarkData + //fn CFURLSetResourcePropertiesForKeys + pub fn CFURLSetResourcePropertyForKey(url: CFURLRef, key: CFStringRef, value: CFTypeRef, error: *mut CFErrorRef) -> Boolean; + //fn CFURLSetTemporaryResourcePropertyForKey + + /* Working with Bookmark Data */ + //fn CFURLCreateBookmarkData + //fn CFURLCreateBookmarkDataFromAliasRecord + //fn CFURLCreateBookmarkDataFromFile + //fn CFURLWriteBookmarkDataToFile + //fn CFURLStartAccessingSecurityScopedResource + //fn CFURLStopAccessingSecurityScopedResource +} + +#[test] +#[cfg(feature="mac_os_10_8_features")] +fn can_see_excluded_from_backup_key() { + let _ = unsafe { kCFURLIsExcludedFromBackupKey }; +} diff --git a/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/uuid.rs b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/uuid.rs new file mode 100644 index 0000000..4253952 --- /dev/null +++ b/third_party/cargo/vendor/core-foundation-sys-0.6.2/src/uuid.rs @@ -0,0 +1,49 @@ +// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFAllocatorRef, CFTypeID}; + +#[repr(C)] +pub struct __CFUUID(c_void); + +pub type CFUUIDRef = *const __CFUUID; + +#[repr(C)] +#[derive(Clone, Copy, Default)] +pub struct CFUUIDBytes { + pub byte0: u8, + pub byte1: u8, + pub byte2: u8, + pub byte3: u8, + pub byte4: u8, + pub byte5: u8, + pub byte6: u8, + pub byte7: u8, + pub byte8: u8, + pub byte9: u8, + pub byte10: u8, + pub byte11: u8, + pub byte12: u8, + pub byte13: u8, + pub byte14: u8, + pub byte15: u8 +} + +extern { + /* + * CFUUID.h + */ + pub fn CFUUIDCreate(allocator: CFAllocatorRef) -> CFUUIDRef; + pub fn CFUUIDCreateFromUUIDBytes(allocator: CFAllocatorRef, bytes: CFUUIDBytes) -> CFUUIDRef; + pub fn CFUUIDGetUUIDBytes(uuid: CFUUIDRef) -> CFUUIDBytes; + + pub fn CFUUIDGetTypeID() -> CFTypeID; +} diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/.cargo-checksum.json b/third_party/cargo/vendor/core-graphics-0.17.3/.cargo-checksum.json new file mode 100644 index 0000000..1dd1131 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"ff714d37c339428ee9c8958414b52f0f49578de1001cd27e732b8cc965ad0326","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"4a45abeb1e684e30bb361dfa7db59189423348e18d310cbae694b7c8c57cd86a","src/base.rs":"5faaadaf17d93c370a20f358be6c3f12958ab7d3f99ccc634421e28758fec88b","src/color.rs":"4c8ec4ab828cbc1b2a1538a34a51f5b380927f2f1daf187dff6f732f57a43656","src/color_space.rs":"b3d7ee8a21703c789160867cb8eb2188bd1daa193e3d030f21adb6f1a6f872de","src/context.rs":"6b14ec712e5d0af4af6beb0cb1a998bf1262ec6ab6ad2b3efad9e0362ade83c9","src/data_provider.rs":"22614a6ce7f857dec33e6d2dc01261b71b1bc5d5609a54ee55e04c049670c072","src/display.rs":"5b04d1fded021fc1eecb89b6350a66f6668e802b51e75cf69892ca082257443c","src/event.rs":"f2ade1c2c112bae7bc4f5df1eda63c13d1c32e5db255228f139ce17fb37c1a4b","src/event_source.rs":"d55a4f5b5e62789325028febc51bbf54c74b15ab1a4e70c6ad749a2f9753e081","src/font.rs":"63b7e50243a56254c800421df586abee59aead84f735f7df838ae04693aedf4b","src/geometry.rs":"cdeb9624df601d235bcc34d46e35bea302079ce1e3668253356a618486693a9f","src/image.rs":"0af720ee020fb1c6a2f4b1ce49e3d27f8f21f0be6b81ba4b9c824f87564efa58","src/lib.rs":"9b9601462de1bbc806e881b2b42e86b16372cad8eeefe1a96b772a9f7329958d","src/path.rs":"c429afeaed999b02ac00f89a867b5fc64f1e223039079a4e0529306b734ff117","src/private.rs":"da3fd61338bab2d8e26aa5433b2e18ecd2a0a408c62e1ac2b33a0f87f2dad88a","src/sys.rs":"cc90b690f172da51a87ffb234f6e74a9f501c4f1630d7b51fa2d5846e80fc164","src/window.rs":"2f6c3dc958ae2c0c9e2fc5033300b96e60ed0abee9823ea1f03797d64df0911a"},"package":"56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9"} \ No newline at end of file diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/BUILD b/third_party/cargo/vendor/core-graphics-0.17.3/BUILD new file mode 100644 index 0000000..dbafd04 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/BUILD @@ -0,0 +1,47 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "core_graphics", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/bitflags-1.2.1:bitflags", + "//third_party/cargo/vendor/core-foundation-0.6.4:core_foundation", + "//third_party/cargo/vendor/foreign-types-0.3.2:foreign_types", + "//third_party/cargo/vendor/libc-0.2.66:libc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.17.3", + crate_features = [ + "default", + ], +) + diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/COPYRIGHT b/third_party/cargo/vendor/core-graphics-0.17.3/COPYRIGHT new file mode 100644 index 0000000..8b7291a --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/COPYRIGHT @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 or the MIT license +, at your +option. All files in the project carrying such notice may not be +copied, modified, or distributed except according to those terms. diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/Cargo.toml b/third_party/cargo/vendor/core-graphics-0.17.3/Cargo.toml new file mode 100644 index 0000000..e445401 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/Cargo.toml @@ -0,0 +1,36 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "core-graphics" +version = "0.17.3" +authors = ["The Servo Project Developers"] +description = "Bindings to Core Graphics for OS X" +homepage = "https://github.com/servo/core-graphics-rs" +license = "MIT / Apache-2.0" +repository = "https://github.com/servo/core-foundation-rs" +[dependencies.bitflags] +version = "1.0" + +[dependencies.core-foundation] +version = "0.6" + +[dependencies.foreign-types] +version = "0.3.0" + +[dependencies.libc] +version = "0.2" + +[features] +default = [] +elcapitan = [] +highsierra = [] diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/LICENSE-APACHE b/third_party/cargo/vendor/core-graphics-0.17.3/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/LICENSE-MIT b/third_party/cargo/vendor/core-graphics-0.17.3/LICENSE-MIT new file mode 100644 index 0000000..807526f --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2012-2013 Mozilla Foundation + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/README.md b/third_party/cargo/vendor/core-graphics-0.17.3/README.md new file mode 100644 index 0000000..a23522d --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/README.md @@ -0,0 +1,3 @@ +# core-graphics-rs + +[![Build Status](https://travis-ci.org/servo/core-graphics-rs.svg?branch=master)](https://travis-ci.org/servo/core-graphics-rs) diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/base.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/base.rs new file mode 100644 index 0000000..e7b7a19 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/base.rs @@ -0,0 +1,59 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// this file defines CGFloat, as well as stubbed data types. + +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +use libc; + +#[cfg(any(target_arch = "x86", + target_arch = "arm", + target_arch = "aarch64"))] +pub type boolean_t = libc::c_int; +#[cfg(target_arch = "x86_64")] +pub type boolean_t = libc::c_uint; + +#[cfg(target_pointer_width = "64")] +pub type CGFloat = libc::c_double; +#[cfg(not(target_pointer_width = "64"))] +pub type CGFloat = libc::c_float; + +pub type CGError = libc::int32_t; + +pub const kCGImageAlphaNone: u32 = 0; +pub const kCGImageAlphaPremultipliedLast: u32 = 1; +pub const kCGImageAlphaPremultipliedFirst: u32 = 2; +pub const kCGImageAlphaLast: u32 = 3; +pub const kCGImageAlphaFirst: u32 = 4; +pub const kCGImageAlphaNoneSkipLast: u32 = 5; +pub const kCGImageAlphaNoneSkipFirst: u32 = 6; + +pub const kCGBitmapByteOrderDefault: u32 = (0 << 12); +pub const kCGBitmapByteOrder16Little: u32 = (1 << 12); +pub const kCGBitmapByteOrder32Little: u32 = (2 << 12); +pub const kCGBitmapByteOrder16Big: u32 = (3 << 12); +pub const kCGBitmapByteOrder32Big: u32 = (4 << 12); + +pub const kCGRenderingIntentDefault: u32 = 0; +pub const kCGRenderingIntentAbsoluteColorimetric: u32 = 1; +pub const kCGRenderingIntentRelativeColorimetric: u32 = 2; +pub const kCGRenderingIntentPerceptual: u32 = 3; +pub const kCGRenderingIntentSaturation: u32 = 4; + +#[cfg(target_endian = "big")] +pub const kCGBitmapByteOrder16Host: u32 = kCGBitmapByteOrder16Big; +#[cfg(target_endian = "big")] +pub const kCGBitmapByteOrder32Host: u32 = kCGBitmapByteOrder32Big; + +#[cfg(target_endian = "little")] +pub const kCGBitmapByteOrder16Host: u32 = kCGBitmapByteOrder16Little; +#[cfg(target_endian = "little")] +pub const kCGBitmapByteOrder32Host: u32 = kCGBitmapByteOrder32Little; diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/color.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/color.rs new file mode 100644 index 0000000..79ef9a0 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/color.rs @@ -0,0 +1,35 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use core_foundation::base::{CFTypeID}; +use base::CGFloat; +use core_foundation::base::TCFType; +use super::sys::{CGColorRef}; + +pub use super::sys::CGColorRef as SysCGColorRef; + +declare_TCFType!{ + CGColor, CGColorRef +} +impl_TCFType!(CGColor, CGColorRef, CGColorGetTypeID); + +impl CGColor { + pub fn rgb(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> Self { + unsafe { + let ptr = CGColorCreateGenericRGB(red, green, blue, alpha); + CGColor::wrap_under_create_rule(ptr) + } + } +} + +#[link(name = "CoreGraphics", kind = "framework")] +extern { + fn CGColorCreateGenericRGB(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> ::sys::CGColorRef; + fn CGColorGetTypeID() -> CFTypeID; +} diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/color_space.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/color_space.rs new file mode 100644 index 0000000..9eef09c --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/color_space.rs @@ -0,0 +1,69 @@ +// Copyright 2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use core_foundation::base::{CFRelease, CFRetain, CFTypeID}; +use core_foundation::string::CFStringRef; +use foreign_types::ForeignType; + +foreign_type! { + #[doc(hidden)] + type CType = ::sys::CGColorSpace; + fn drop = |p| CFRelease(p as *mut _); + fn clone = |p| CFRetain(p as *const _) as *mut _; + pub struct CGColorSpace; + pub struct CGColorSpaceRef; +} + +impl CGColorSpace { + pub fn type_id() -> CFTypeID { + unsafe { + CGColorSpaceGetTypeID() + } + } + + pub fn create_with_name(name: CFStringRef) -> Option { + unsafe { + let p = CGColorSpaceCreateWithName(name); + if !p.is_null() {Some(CGColorSpace::from_ptr(p))} else {None} + } + } + + #[inline] + pub fn create_device_rgb() -> CGColorSpace { + unsafe { + let result = CGColorSpaceCreateDeviceRGB(); + CGColorSpace::from_ptr(result) + } + } + + #[inline] + pub fn create_device_gray() -> CGColorSpace { + unsafe { + let result = CGColorSpaceCreateDeviceGray(); + CGColorSpace::from_ptr(result) + } + } +} + +#[link(name = "CoreGraphics", kind = "framework")] +extern { + pub static kCGColorSpaceSRGB: CFStringRef; + pub static kCGColorSpaceAdobeRGB1998: CFStringRef; + pub static kCGColorSpaceGenericGray: CFStringRef; + pub static kCGColorSpaceGenericRGB: CFStringRef; + pub static kCGColorSpaceGenericCMYK: CFStringRef; + pub static kCGColorSpaceGenericRGBLinear: CFStringRef; + pub static kCGColorSpaceGenericGrayGamma2_2: CFStringRef; + + fn CGColorSpaceCreateDeviceRGB() -> ::sys::CGColorSpaceRef; + fn CGColorSpaceCreateDeviceGray() -> ::sys::CGColorSpaceRef; + fn CGColorSpaceCreateWithName(name: CFStringRef) -> ::sys::CGColorSpaceRef; + fn CGColorSpaceGetTypeID() -> CFTypeID; +} + diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/context.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/context.rs new file mode 100644 index 0000000..1d73c23 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/context.rs @@ -0,0 +1,401 @@ +// Copyright 2015 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use base::CGFloat; +use color_space::CGColorSpace; +use core_foundation::base::{ToVoid, CFRelease, CFRetain, CFTypeID}; +use font::{CGFont, CGGlyph}; +use geometry::CGPoint; +use color::CGColor; +use path::CGPathRef; +use libc::{c_int, size_t}; +use std::os::raw::c_void; + +use std::cmp; +use std::ptr; +use std::slice; +use geometry::{CGAffineTransform, CGRect}; +use image::CGImage; +use foreign_types::{ForeignType, ForeignTypeRef}; + +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub enum CGBlendMode { + Normal = 0, + Multiply, + Screen, + Overlay, + Darken, + Lighten, + ColorDodge, + ColorBurn, + SoftLight, + HardLight, + Difference, + Exclusion, + Hue, + Saturation, + Color, + Luminosity, + // 10.5 and up: + Clear, + Copy, + SourceIn, + SourceOut, + SourceAtop, + DestinationOver, + DestinationIn, + DestinationOut, + DestinationAtop, + Xor, + PlusDarker, + PlusLighter, +} + +#[repr(C)] +pub enum CGTextDrawingMode { + CGTextFill, + CGTextStroke, + CGTextFillStroke, + CGTextInvisible, + CGTextFillClip, + CGTextStrokeClip, + CGTextClip +} + +foreign_type! { + #[doc(hidden)] + type CType = ::sys::CGContext; + fn drop = |cs| CFRelease(cs as *mut _); + fn clone = |p| CFRetain(p as *const _) as *mut _; + pub struct CGContext; + pub struct CGContextRef; +} + +impl CGContext { + pub fn type_id() -> CFTypeID { + unsafe { + CGContextGetTypeID() + } + } + + pub fn create_bitmap_context(data: Option<*mut c_void>, + width: size_t, + height: size_t, + bits_per_component: size_t, + bytes_per_row: size_t, + space: &CGColorSpace, + bitmap_info: u32) + -> CGContext { + unsafe { + let result = CGBitmapContextCreate(data.unwrap_or(ptr::null_mut()), + width, + height, + bits_per_component, + bytes_per_row, + space.as_ptr(), + bitmap_info); + assert!(!result.is_null()); + Self::from_ptr(result) + } + } + + pub fn data(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut( + CGBitmapContextGetData(self.as_ptr()) as *mut u8, + (self.height() * self.bytes_per_row()) as usize) + } + } +} + +impl CGContextRef { + pub fn flush(&self) { + unsafe { + CGContextFlush(self.as_ptr()) + } + } + + pub fn width(&self) -> size_t { + unsafe { + CGBitmapContextGetWidth(self.as_ptr()) + } + } + + pub fn height(&self) -> size_t { + unsafe { + CGBitmapContextGetHeight(self.as_ptr()) + } + } + + pub fn bytes_per_row(&self) -> size_t { + unsafe { + CGBitmapContextGetBytesPerRow(self.as_ptr()) + } + } + + pub fn set_fill_color(&self, color: &CGColor) { + unsafe { + CGContextSetFillColorWithColor(self.as_ptr(), color.to_void()); + } + } + + pub fn set_rgb_fill_color(&self, red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) { + unsafe { + CGContextSetRGBFillColor(self.as_ptr(), red, green, blue, alpha) + } + } + + pub fn set_gray_fill_color(&self, gray: CGFloat, alpha: CGFloat) { + unsafe { + CGContextSetGrayFillColor(self.as_ptr(), gray, alpha) + } + } + + pub fn set_blend_mode(&self, blend_mode: CGBlendMode) { + unsafe { + CGContextSetBlendMode(self.as_ptr(), blend_mode) + } + } + + pub fn set_allows_font_smoothing(&self, allows_font_smoothing: bool) { + unsafe { + CGContextSetAllowsFontSmoothing(self.as_ptr(), allows_font_smoothing) + } + } + + pub fn set_font_smoothing_style(&self, style: i32) { + unsafe { + CGContextSetFontSmoothingStyle(self.as_ptr(), style as _); + } + } + + pub fn set_should_smooth_fonts(&self, should_smooth_fonts: bool) { + unsafe { + CGContextSetShouldSmoothFonts(self.as_ptr(), should_smooth_fonts) + } + } + + pub fn set_allows_antialiasing(&self, allows_antialiasing: bool) { + unsafe { + CGContextSetAllowsAntialiasing(self.as_ptr(), allows_antialiasing) + } + } + + pub fn set_should_antialias(&self, should_antialias: bool) { + unsafe { + CGContextSetShouldAntialias(self.as_ptr(), should_antialias) + } + } + + pub fn set_allows_font_subpixel_quantization(&self, allows_font_subpixel_quantization: bool) { + unsafe { + CGContextSetAllowsFontSubpixelQuantization(self.as_ptr(), allows_font_subpixel_quantization) + } + } + + pub fn set_should_subpixel_quantize_fonts(&self, should_subpixel_quantize_fonts: bool) { + unsafe { + CGContextSetShouldSubpixelQuantizeFonts(self.as_ptr(), should_subpixel_quantize_fonts) + } + } + + pub fn set_allows_font_subpixel_positioning(&self, allows_font_subpixel_positioning: bool) { + unsafe { + CGContextSetAllowsFontSubpixelPositioning(self.as_ptr(), allows_font_subpixel_positioning) + } + } + + pub fn set_should_subpixel_position_fonts(&self, should_subpixel_position_fonts: bool) { + unsafe { + CGContextSetShouldSubpixelPositionFonts(self.as_ptr(), should_subpixel_position_fonts) + } + } + + pub fn set_text_drawing_mode(&self, mode: CGTextDrawingMode) { + unsafe { + CGContextSetTextDrawingMode(self.as_ptr(), mode) + } + } + + pub fn add_path(&self, path: &CGPathRef) { + unsafe { + CGContextAddPath(self.as_ptr(), path.as_ptr()); + } + } + + pub fn close_path(&self) { + unsafe { + CGContextClosePath(self.as_ptr()); + } + } + + pub fn fill_path(&self) { + unsafe { + CGContextFillPath(self.as_ptr()); + } + } + + pub fn fill_rect(&self, rect: CGRect) { + unsafe { + CGContextFillRect(self.as_ptr(), rect) + } + } + + pub fn draw_image(&self, rect: CGRect, image: &CGImage) { + unsafe { + CGContextDrawImage(self.as_ptr(), rect, image.as_ptr()); + } + } + + pub fn create_image(&self) -> Option { + let image = unsafe { CGBitmapContextCreateImage(self.as_ptr()) }; + if !image.is_null() { + Some(unsafe { CGImage::from_ptr(image) }) + } else { + None + } + } + + pub fn set_font(&self, font: &CGFont) { + unsafe { + CGContextSetFont(self.as_ptr(), font.as_ptr()) + } + } + + pub fn set_font_size(&self, size: CGFloat) { + unsafe { + CGContextSetFontSize(self.as_ptr(), size) + } + } + + pub fn set_text_matrix(&self, t: &CGAffineTransform) { + unsafe { + CGContextSetTextMatrix(self.as_ptr(), *t) + } + } + + pub fn show_glyphs_at_positions(&self, glyphs: &[CGGlyph], positions: &[CGPoint]) { + unsafe { + let count = cmp::min(glyphs.len(), positions.len()); + CGContextShowGlyphsAtPositions(self.as_ptr(), + glyphs.as_ptr(), + positions.as_ptr(), + count) + } + } + + pub fn save(&self) { + unsafe { + CGContextSaveGState(self.as_ptr()); + } + } + + pub fn restore(&self) { + unsafe { + CGContextRestoreGState(self.as_ptr()); + } + } + + pub fn translate(&self, tx: CGFloat, ty: CGFloat) { + unsafe { + CGContextTranslateCTM(self.as_ptr(), tx, ty); + } + } + + pub fn scale(&self, sx: CGFloat, sy: CGFloat) { + unsafe { + CGContextScaleCTM(self.as_ptr(), sx, sy); + } + } +} + +#[test] +fn create_bitmap_context_test() { + use geometry::*; + + let cs = CGColorSpace::create_device_rgb(); + let ctx = CGContext::create_bitmap_context(None, + 16, 8, + 8, 0, + &cs, + ::base::kCGImageAlphaPremultipliedLast); + ctx.set_rgb_fill_color(1.,0.,1.,1.); + ctx.fill_rect(CGRect::new(&CGPoint::new(0.,0.), &CGSize::new(8.,8.))); + let img = ctx.create_image().unwrap(); + assert_eq!(16, img.width()); + assert_eq!(8, img.height()); + assert_eq!(8, img.bits_per_component()); + assert_eq!(32, img.bits_per_pixel()); + let data = img.data(); + assert_eq!(255, data.bytes()[0]); + assert_eq!(0, data.bytes()[1]); + assert_eq!(255, data.bytes()[2]); + assert_eq!(255, data.bytes()[3]); +} + +#[link(name = "CoreGraphics", kind = "framework")] +extern { + fn CGBitmapContextCreate(data: *mut c_void, + width: size_t, + height: size_t, + bitsPerComponent: size_t, + bytesPerRow: size_t, + space: ::sys::CGColorSpaceRef, + bitmapInfo: u32) + -> ::sys::CGContextRef; + fn CGBitmapContextGetData(context: ::sys::CGContextRef) -> *mut c_void; + fn CGBitmapContextGetWidth(context: ::sys::CGContextRef) -> size_t; + fn CGBitmapContextGetHeight(context: ::sys::CGContextRef) -> size_t; + fn CGBitmapContextGetBytesPerRow(context: ::sys::CGContextRef) -> size_t; + fn CGBitmapContextCreateImage(context: ::sys::CGContextRef) -> ::sys::CGImageRef; + fn CGContextGetTypeID() -> CFTypeID; + fn CGContextFlush(c: ::sys::CGContextRef); + fn CGContextSetBlendMode(c: ::sys::CGContextRef, blendMode: CGBlendMode); + fn CGContextSetAllowsFontSmoothing(c: ::sys::CGContextRef, allowsFontSmoothing: bool); + fn CGContextSetShouldSmoothFonts(c: ::sys::CGContextRef, shouldSmoothFonts: bool); + fn CGContextSetFontSmoothingStyle(c: ::sys::CGContextRef, style: c_int); + fn CGContextSetAllowsAntialiasing(c: ::sys::CGContextRef, allowsAntialiasing: bool); + fn CGContextSetShouldAntialias(c: ::sys::CGContextRef, shouldAntialias: bool); + fn CGContextSetAllowsFontSubpixelQuantization(c: ::sys::CGContextRef, + allowsFontSubpixelQuantization: bool); + fn CGContextSetShouldSubpixelQuantizeFonts(c: ::sys::CGContextRef, + shouldSubpixelQuantizeFonts: bool); + fn CGContextSetAllowsFontSubpixelPositioning(c: ::sys::CGContextRef, + allowsFontSubpixelPositioning: bool); + fn CGContextSetShouldSubpixelPositionFonts(c: ::sys::CGContextRef, + shouldSubpixelPositionFonts: bool); + fn CGContextSetTextDrawingMode(c: ::sys::CGContextRef, mode: CGTextDrawingMode); + fn CGContextSetFillColorWithColor(c: ::sys::CGContextRef, color: *const c_void); + fn CGContextAddPath(c: ::sys::CGContextRef, path: ::sys::CGPathRef); + fn CGContextClosePath(c: ::sys::CGContextRef); + fn CGContextFillPath(c: ::sys::CGContextRef); + fn CGContextSetRGBFillColor(context: ::sys::CGContextRef, + red: CGFloat, + green: CGFloat, + blue: CGFloat, + alpha: CGFloat); + fn CGContextSetGrayFillColor(context: ::sys::CGContextRef, gray: CGFloat, alpha: CGFloat); + fn CGContextFillRect(context: ::sys::CGContextRef, + rect: CGRect); + fn CGContextDrawImage(c: ::sys::CGContextRef, rect: CGRect, image: ::sys::CGImageRef); + fn CGContextSetFont(c: ::sys::CGContextRef, font: ::sys::CGFontRef); + fn CGContextSetFontSize(c: ::sys::CGContextRef, size: CGFloat); + fn CGContextSetTextMatrix(c: ::sys::CGContextRef, t: CGAffineTransform); + fn CGContextShowGlyphsAtPositions(c: ::sys::CGContextRef, + glyphs: *const CGGlyph, + positions: *const CGPoint, + count: size_t); + + fn CGContextSaveGState(c: ::sys::CGContextRef); + fn CGContextRestoreGState(c: ::sys::CGContextRef); + fn CGContextTranslateCTM(c: ::sys::CGContextRef, tx: CGFloat, ty: CGFloat); + fn CGContextScaleCTM(c: ::sys::CGContextRef, sx: CGFloat, sy: CGFloat); +} + diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/data_provider.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/data_provider.rs new file mode 100644 index 0000000..b6388fc --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/data_provider.rs @@ -0,0 +1,125 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use core_foundation::base::{CFRelease, CFRetain, CFTypeID, TCFType}; +use core_foundation::data::{CFData, CFDataRef}; + +use libc::{size_t, off_t}; +use std::mem; +use std::ptr; +use std::sync::Arc; +use std::os::raw::c_void; + +use foreign_types::{ForeignType, ForeignTypeRef}; + +pub type CGDataProviderGetBytesCallback = Option size_t>; +pub type CGDataProviderReleaseInfoCallback = Option; +pub type CGDataProviderRewindCallback = Option; +pub type CGDataProviderSkipBytesCallback = Option; +pub type CGDataProviderSkipForwardCallback = Option off_t>; + +pub type CGDataProviderGetBytePointerCallback = Option *mut c_void>; +pub type CGDataProviderGetBytesAtOffsetCallback = Option; +pub type CGDataProviderReleaseBytePointerCallback = Option; +pub type CGDataProviderReleaseDataCallback = Option; +pub type CGDataProviderGetBytesAtPositionCallback = Option; + +foreign_type! { + #[doc(hidden)] + type CType = ::sys::CGDataProvider; + fn drop = |cs| CFRelease(cs as *mut _); + fn clone = |p| CFRetain(p as *const _) as *mut _; + pub struct CGDataProvider; + pub struct CGDataProviderRef; +} + +impl CGDataProvider { + pub fn type_id() -> CFTypeID { + unsafe { + CGDataProviderGetTypeID() + } + } + + /// Creates a data provider from the given reference-counted buffer. + /// + /// The `CGDataProvider` object takes ownership of the reference. Once the data provider + /// is destroyed, the reference count of the buffer is automatically decremented. + pub fn from_buffer(buffer: Arc>) -> Self { + unsafe { + let ptr = (*buffer).as_ptr() as *const c_void; + let len = buffer.len() as size_t; + let info = mem::transmute::>, *mut c_void>(buffer); + let result = CGDataProviderCreateWithData(info, ptr, len, Some(release)); + return CGDataProvider::from_ptr(result); + } + + unsafe extern "C" fn release(info: *mut c_void, _: *const c_void, _: size_t) { + drop(mem::transmute::<*mut c_void, Arc>>(info)) + } + } + + /// Creates a data prvider from a given slice. The data provider does not own the slice in this + /// case, so it's up to the user to ensure the memory safety here. + pub unsafe fn from_slice(buffer: &[u8]) -> Self { + let ptr = buffer.as_ptr() as *const c_void; + let len = buffer.len() as size_t; + let result = CGDataProviderCreateWithData(ptr::null_mut(), ptr, len, None); + CGDataProvider::from_ptr(result) + } + + /// Creates a data provider from the given raw pointer, length, and destructor function. + /// + /// This is double-boxed because the Core Text API requires that the userdata be a single + /// pointer. + pub unsafe fn from_custom_data(custom_data: Box>) -> Self { + let (ptr, len) = (custom_data.ptr() as *const c_void, custom_data.len()); + let userdata = mem::transmute::>, &mut c_void>(custom_data); + let data_provider = CGDataProviderCreateWithData(userdata, ptr, len, Some(release)); + return CGDataProvider::from_ptr(data_provider); + + unsafe extern "C" fn release(info: *mut c_void, _: *const c_void, _: size_t) { + drop(mem::transmute::<*mut c_void, Box>>(info)) + } + } +} + +impl CGDataProviderRef { + /// Creates a copy of the data from the underlying `CFDataProviderRef`. + pub fn copy_data(&self) -> CFData { + unsafe { CFData::wrap_under_create_rule(CGDataProviderCopyData(self.as_ptr())) } + } +} + +/// Encapsulates custom data that can be wrapped. +pub trait CustomData { + /// Returns a pointer to the start of the custom data. This pointer *must not change* during + /// the lifespan of this CustomData. + unsafe fn ptr(&self) -> *const u8; + /// Returns the length of this custom data. This value must not change during the lifespan of + /// this CustomData. + unsafe fn len(&self) -> usize; +} + +#[link(name = "CoreGraphics", kind = "framework")] +extern { + fn CGDataProviderCopyData(provider: ::sys::CGDataProviderRef) -> CFDataRef; + //fn CGDataProviderCreateDirect + //fn CGDataProviderCreateSequential + //fn CGDataProviderCreateWithCFData + fn CGDataProviderCreateWithData(info: *mut c_void, + data: *const c_void, + size: size_t, + releaseData: CGDataProviderReleaseDataCallback + ) -> ::sys::CGDataProviderRef; + //fn CGDataProviderCreateWithFilename(filename: *c_char) -> CGDataProviderRef; + //fn CGDataProviderCreateWithURL + fn CGDataProviderGetTypeID() -> CFTypeID; + //fn CGDataProviderRelease(provider: CGDataProviderRef); + //fn CGDataProviderRetain(provider: CGDataProviderRef) -> CGDataProviderRef; +} diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/display.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/display.rs new file mode 100644 index 0000000..bb2eec3 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/display.rs @@ -0,0 +1,671 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(non_upper_case_globals)] + +use libc; +use std::ptr; +use std::ops::Deref; + +pub use base::{CGError, boolean_t}; +pub use geometry::{CGRect, CGPoint, CGSize}; + +use core_foundation::string::{CFString, CFStringRef}; +use core_foundation::base::{CFRetain, TCFType}; +use image::CGImage; +use foreign_types::ForeignType; + +pub type CGDirectDisplayID = libc::uint32_t; +pub type CGWindowID = libc::uint32_t; + +pub const kCGNullWindowID: CGWindowID = 0 as CGWindowID; + + +pub type CGWindowListOption = libc::uint32_t; + +pub const kCGWindowListOptionAll: CGWindowListOption = 0; +pub const kCGWindowListOptionOnScreenOnly: CGWindowListOption = 1 << 0; +pub const kCGWindowListOptionOnScreenAboveWindow: CGWindowListOption = 1 << 1; +pub const kCGWindowListOptionOnScreenBelowWindow: CGWindowListOption = 1 << 2; +pub const kCGWindowListOptionIncludingWindow: CGWindowListOption = 1 << 3; +pub const kCGWindowListExcludeDesktopElements: CGWindowListOption = 1 << 4; + +pub type CGWindowImageOption = libc::uint32_t; + +pub const kCGWindowImageDefault: CGWindowImageOption = 0; +pub const kCGWindowImageBoundsIgnoreFraming: CGWindowImageOption = 1 << 0; +pub const kCGWindowImageShouldBeOpaque: CGWindowImageOption = 1 << 1; +pub const kCGWindowImageOnlyShadows: CGWindowImageOption = 1 << 2; +pub const kCGWindowImageBestResolution: CGWindowImageOption = 1 << 3; +pub const kCGWindowImageNominalResolution: CGWindowImageOption = 1 << 4; + +pub const kDisplayModeValidFlag: u32 = 0x00000001; +pub const kDisplayModeSafeFlag: u32 = 0x00000002; +pub const kDisplayModeDefaultFlag: u32 = 0x00000004; +pub const kDisplayModeAlwaysShowFlag: u32 = 0x00000008; +pub const kDisplayModeNeverShowFlag: u32 = 0x00000080; +pub const kDisplayModeNotResizeFlag: u32 = 0x00000010; +pub const kDisplayModeRequiresPanFlag: u32 = 0x00000020; +pub const kDisplayModeInterlacedFlag: u32 = 0x00000040; +pub const kDisplayModeSimulscanFlag: u32 = 0x00000100; +pub const kDisplayModeBuiltInFlag: u32 = 0x00000400; +pub const kDisplayModeNotPresetFlag: u32 = 0x00000200; +pub const kDisplayModeStretchedFlag: u32 = 0x00000800; +pub const kDisplayModeNotGraphicsQualityFlag: u32 = 0x00001000; +pub const kDisplayModeValidateAgainstDisplay: u32 = 0x00002000; +pub const kDisplayModeTelevisionFlag: u32 = 0x00100000; +pub const kDisplayModeValidForMirroringFlag: u32 = 0x00200000; +pub const kDisplayModeAcceleratorBackedFlag: u32 = 0x00400000; +pub const kDisplayModeValidForHiResFlag: u32 = 0x00800000; +pub const kDisplayModeValidForAirPlayFlag: u32 = 0x01000000; +pub const kDisplayModeNativeFlag: u32 = 0x02000000; + +pub const kDisplayModeSafetyFlags: u32 = 0x00000007; + +pub const IO1BitIndexedPixels: &str = "P"; +pub const IO2BitIndexedPixels: &str = "PP"; +pub const IO4BitIndexedPixels: &str = "PPPP"; +pub const IO8BitIndexedPixels: &str = "PPPPPPPP"; +pub const IO16BitDirectPixels: &str = "-RRRRRGGGGGBBBBB"; +pub const IO32BitDirectPixels: &str = "--------RRRRRRRRGGGGGGGGBBBBBBBB"; +pub const kIO30BitDirectPixels: &str = "--RRRRRRRRRRGGGGGGGGGGBBBBBBBBBB"; +pub const kIO64BitDirectPixels: &str = "-16R16G16B16"; +pub const kIO16BitFloatPixels: &str = "-16FR16FG16FB16"; +pub const kIO32BitFloatPixels: &str = "-32FR32FG32FB32"; +pub const IOYUV422Pixels: &str = "Y4U2V2"; +pub const IO8BitOverlayPixels: &str = "O8"; + + +pub use core_foundation::dictionary::{ CFDictionary, CFDictionaryRef, CFDictionaryGetValueIfPresent }; +pub use core_foundation::array::{ CFArray, CFArrayRef }; +pub use core_foundation::array::{ CFArrayGetCount, CFArrayGetValueAtIndex }; +pub use core_foundation::base::{ CFIndex, CFRelease, CFTypeRef }; + +pub type CGDisplayConfigRef = *mut libc::c_void; + +#[repr(u32)] +#[derive(Clone, Copy)] +pub enum CGConfigureOption { + ConfigureForAppOnly = 0, + ConfigureForSession = 1, + ConfigurePermanently = 2, +} + +#[derive(Copy, Clone, Debug)] +pub struct CGDisplay { + pub id: CGDirectDisplayID, +} + +foreign_type! { + #[doc(hidden)] + type CType = ::sys::CGDisplayMode; + fn drop = CGDisplayModeRelease; + fn clone = |p| CFRetain(p as *const _) as *mut _; + pub struct CGDisplayMode; + pub struct CGDisplayModeRef; +} + +impl CGDisplay { + #[inline] + pub fn new(id: CGDirectDisplayID) -> CGDisplay { + CGDisplay { id: id } + } + + /// Returns the the main display. + #[inline] + pub fn main() -> CGDisplay { + CGDisplay::new(unsafe { CGMainDisplayID() }) + } + + /// Returns the bounds of a display in the global display coordinate space. + #[inline] + pub fn bounds(&self) -> CGRect { + unsafe { CGDisplayBounds(self.id) } + } + + /// Returns information about a display's current configuration. + #[inline] + pub fn display_mode(&self) -> Option { + unsafe { + let mode_ref = CGDisplayCopyDisplayMode(self.id); + if !mode_ref.is_null() { + Some(CGDisplayMode::from_ptr(mode_ref)) + } else { + None + } + } + } + + /// Begins a new set of display configuration changes. + pub fn begin_configuration(&self) -> Result { + unsafe { + let mut config_ref: CGDisplayConfigRef = ptr::null_mut(); + let result = CGBeginDisplayConfiguration(&mut config_ref); + if result == 0 { + Ok(config_ref) + } else { + Err(result) + } + } + } + + /// Cancels a set of display configuration changes. + pub fn cancel_configuration(&self, config_ref: &CGDisplayConfigRef) -> Result<(), CGError> { + let result = unsafe { CGCancelDisplayConfiguration(*config_ref) }; + if result == 0 { + Ok(()) + } else { + Err(result) + } + } + + /// Completes a set of display configuration changes. + pub fn complete_configuration( + &self, + config_ref: &CGDisplayConfigRef, + option: CGConfigureOption, + ) -> Result<(), CGError> { + let result = unsafe { CGCompleteDisplayConfiguration(*config_ref, option) }; + if result == 0 { + Ok(()) + } else { + Err(result) + } + } + + /// Configures the display mode of a display. + pub fn configure_display_with_display_mode( + &self, + config_ref: &CGDisplayConfigRef, + display_mode: &CGDisplayMode, + ) -> Result<(), CGError> { + let result = unsafe { + CGConfigureDisplayWithDisplayMode( + *config_ref, + self.id, + display_mode.as_ptr(), + ptr::null(), + ) + }; + if result == 0 { + Ok(()) + } else { + Err(result) + } + } + + /// Returns an image containing the contents of the specified display. + #[inline] + pub fn image(&self) -> Option { + unsafe { + let image_ref = CGDisplayCreateImage(self.id); + if !image_ref.is_null() { + Some(CGImage::from_ptr(image_ref)) + } else { + None + } + } + } + + /// Returns a composite image based on a dynamically generated list of + /// windows. + #[inline] + pub fn screenshot( + bounds: CGRect, + list_option: CGWindowListOption, + window_id: CGWindowID, + image_option: CGWindowImageOption, + ) -> Option { + unsafe { + let image_ref = CGWindowListCreateImage(bounds, list_option, window_id, image_option); + if !image_ref.is_null() { + Some(CGImage::from_ptr(image_ref)) + } else { + None + } + } + } + + /// Returns a composite image of the specified windows. + #[inline] + pub fn screenshot_from_windows( + bounds: CGRect, + windows: CFArray, + image_option: CGWindowImageOption, + ) -> Option { + unsafe { + let image_ref = CGWindowListCreateImageFromArray( + bounds, + windows.as_concrete_TypeRef(), + image_option, + ); + if !image_ref.is_null() { + Some(CGImage::from_ptr(image_ref)) + } else { + None + } + } + } + + /// Generates and returns information about the selected windows in the + /// current user session. + pub fn window_list_info( + option: CGWindowListOption, + relative_to_window: Option, + ) -> Option { + let relative_to_window = relative_to_window.unwrap_or(kCGNullWindowID); + let array_ref = unsafe { CGWindowListCopyWindowInfo(option, relative_to_window) }; + if array_ref != ptr::null() { + Some(unsafe { TCFType::wrap_under_create_rule(array_ref) }) + } else { + None + } + } + + /// Returns a Boolean value indicating whether a display is active. + #[inline] + pub fn is_active(&self) -> bool { + unsafe { CGDisplayIsActive(self.id) != 0 } + } + + /// Returns a boolean indicating whether a display is always in a + /// mirroring set. + #[inline] + pub fn is_always_in_mirror_set(&self) -> bool { + unsafe { CGDisplayIsAlwaysInMirrorSet(self.id) != 0 } + } + + /// Returns a boolean indicating whether a display is sleeping (and is + /// therefore not drawable.) + #[inline] + pub fn is_asleep(&self) -> bool { + unsafe { CGDisplayIsAsleep(self.id) != 0 } + } + + /// Returns a boolean indicating whether a display is built-in, such as + /// the internal display in portable systems. + #[inline] + pub fn is_builtin(&self) -> bool { + unsafe { CGDisplayIsBuiltin(self.id) != 0 } + } + + /// Returns a boolean indicating whether a display is in a hardware + /// mirroring set. + #[inline] + pub fn is_in_hw_mirror_set(&self) -> bool { + unsafe { CGDisplayIsInHWMirrorSet(self.id) != 0 } + } + + /// Returns a boolean indicating whether a display is in a mirroring set. + #[inline] + pub fn is_in_mirror_set(&self) -> bool { + unsafe { CGDisplayIsInMirrorSet(self.id) != 0 } + } + + /// Returns a boolean indicating whether a display is the main display. + #[inline] + pub fn is_main(&self) -> bool { + unsafe { CGDisplayIsMain(self.id) != 0 } + } + + /// Returns a boolean indicating whether a display is connected or online. + #[inline] + pub fn is_online(&self) -> bool { + unsafe { CGDisplayIsOnline(self.id) != 0 } + } + + /// Returns a boolean indicating whether Quartz is using OpenGL-based + /// window acceleration (Quartz Extreme) to render in a display. + #[inline] + pub fn uses_open_gl_acceleration(&self) -> bool { + unsafe { CGDisplayUsesOpenGLAcceleration(self.id) != 0 } + } + + /// Returns a boolean indicating whether a display is running in a stereo + /// graphics mode. + #[inline] + pub fn is_stereo(&self) -> bool { + unsafe { CGDisplayIsStereo(self.id) != 0 } + } + + /// For a secondary display in a mirroring set, returns the primary + /// display. + #[inline] + pub fn mirrors_display(&self) -> CGDirectDisplayID { + unsafe { CGDisplayMirrorsDisplay(self.id) } + } + + /// Returns the primary display in a hardware mirroring set. + #[inline] + pub fn primary_display(&self) -> CGDirectDisplayID { + unsafe { CGDisplayPrimaryDisplay(self.id) } + } + + /// Returns the rotation angle of a display in degrees. + #[inline] + pub fn rotation(&self) -> f64 { + unsafe { CGDisplayRotation(self.id) } + } + + /// Returns the width and height of a display in millimeters. + #[inline] + pub fn screen_size(&self) -> CGSize { + unsafe { CGDisplayScreenSize(self.id) } + } + + /// Returns the serial number of a display monitor. + #[inline] + pub fn serial_number(&self) -> u32 { + unsafe { CGDisplaySerialNumber(self.id) } + } + + /// Returns the logical unit number of a display. + #[inline] + pub fn unit_number(&self) -> u32 { + unsafe { CGDisplayUnitNumber(self.id) } + } + + /// Returns the vendor number of the specified display's monitor. + #[inline] + pub fn vendor_number(&self) -> u32 { + unsafe { CGDisplayVendorNumber(self.id) } + } + + /// Returns the model number of a display monitor. + #[inline] + pub fn model_number(&self) -> u32 { + unsafe { CGDisplayModelNumber(self.id) } + } + + /// Returns the display height in pixel units. + #[inline] + pub fn pixels_high(&self) -> u64 { + unsafe { CGDisplayPixelsHigh(self.id) as u64 } + } + + /// Returns the display width in pixel units. + #[inline] + pub fn pixels_wide(&self) -> u64 { + unsafe { CGDisplayPixelsWide(self.id) as u64 } + } + + /// Provides a list of displays that are active (or drawable). + #[inline] + pub fn active_displays() -> Result, CGError> { + let count = try!(CGDisplay::active_display_count()); + let mut buf: Vec = vec![0; count as usize]; + let result = + unsafe { CGGetActiveDisplayList(count as u32, buf.as_mut_ptr(), ptr::null_mut()) }; + if result == 0 { + Ok(buf) + } else { + Err(result) + } + } + + /// Provides count of displays that are active (or drawable). + #[inline] + pub fn active_display_count() -> Result { + let mut count: libc::uint32_t = 0; + let result = unsafe { CGGetActiveDisplayList(0, ptr::null_mut(), &mut count) }; + if result == 0 { + Ok(count as u32) + } else { + Err(result) + } + } + + /// Hides the mouse cursor, and increments the hide cursor count. + #[inline] + pub fn hide_cursor(&self) -> Result<(), CGError> { + let result = unsafe { CGDisplayHideCursor(self.id) }; + if result == 0 { + Ok(()) + } else { + Err(result) + } + } + + /// Decrements the hide cursor count, and shows the mouse cursor if the + /// count is 0. + #[inline] + pub fn show_cursor(&self) -> Result<(), CGError> { + let result = unsafe { CGDisplayShowCursor(self.id) }; + if result == 0 { + Ok(()) + } else { + Err(result) + } + } + + /// Moves the mouse cursor to a specified point relative to the display + /// origin (the upper-left corner of the display). + #[inline] + pub fn move_cursor_to_point(&self, point: CGPoint) -> Result<(), CGError> { + let result = unsafe { CGDisplayMoveCursorToPoint(self.id, point) }; + if result == 0 { + Ok(()) + } else { + Err(result) + } + } + + /// Moves the mouse cursor without generating events. + #[inline] + pub fn warp_mouse_cursor_position(point: CGPoint) -> Result<(), CGError> { + let result = unsafe { CGWarpMouseCursorPosition(point) }; + if result == 0 { + Ok(()) + } else { + Err(result) + } + } + + /// Connects or disconnects the mouse and cursor while an application is + /// in the foreground. + #[inline] + pub fn associate_mouse_and_mouse_cursor_position(connected: bool) -> Result<(), CGError> { + let result = unsafe { CGAssociateMouseAndMouseCursorPosition(connected as boolean_t) }; + if result == 0 { + Ok(()) + } else { + Err(result) + } + } +} + +impl CGDisplayMode { + /// Returns all display modes for the specified display id. + pub fn all_display_modes( + display_id: CGDirectDisplayID, + options: CFDictionaryRef, + ) -> Option> { + let array_opt: Option = unsafe { + let array_ref = CGDisplayCopyAllDisplayModes(display_id, options); + if array_ref != ptr::null() { + Some(CFArray::wrap_under_create_rule(array_ref)) + } else { + None + } + }; + match array_opt { + Some(modes) => { + let vec: Vec = modes + .into_iter() + .map(|value0| { + let x = *value0.deref() as *mut ::sys::CGDisplayMode; + unsafe { CGDisplayMode::from_ptr(x) } + }).collect(); + Some(vec) + } + None => None, + } + } + + /// Returns the height of the specified display mode. + #[inline] + pub fn height(&self) -> u64 { + unsafe { CGDisplayModeGetHeight(self.as_ptr()) as u64 } + } + + /// Returns the width of the specified display mode. + #[inline] + pub fn width(&self) -> u64 { + unsafe { CGDisplayModeGetWidth(self.as_ptr()) as u64 } + } + + /// Returns the pixel height of the specified display mode. + #[inline] + pub fn pixel_height(&self) -> u64 { + unsafe { CGDisplayModeGetPixelHeight(self.as_ptr()) as u64 } + } + + /// Returns the pixel width of the specified display mode. + #[inline] + pub fn pixel_width(&self) -> u64 { + unsafe { CGDisplayModeGetPixelWidth(self.as_ptr()) as u64 } + } + + #[inline] + pub fn refresh_rate(&self) -> f64 { + unsafe { CGDisplayModeGetRefreshRate(self.as_ptr()) } + } + + /// Returns the I/O Kit flags of the specified display mode. + #[inline] + pub fn io_flags(&self) -> u32 { + unsafe { CGDisplayModeGetIOFlags(self.as_ptr()) as u32 } + } + + /// Returns the pixel encoding of the specified display mode. + #[inline] + pub fn pixel_encoding(&self) -> CFString { + unsafe { CFString::wrap_under_create_rule(CGDisplayModeCopyPixelEncoding(self.as_ptr())) } + } + + /// Returns the number of bits per pixel of the specified display mode. + pub fn bit_depth(&self) -> usize { + let pixel_encoding = self.pixel_encoding().to_string(); + // my numerical representation for kIO16BitFloatPixels and kIO32bitFloatPixels + // are made up and possibly non-sensical + if pixel_encoding.eq_ignore_ascii_case(kIO32BitFloatPixels) { + 96 + } else if pixel_encoding.eq_ignore_ascii_case(kIO64BitDirectPixels) { + 64 + } else if pixel_encoding.eq_ignore_ascii_case(kIO16BitFloatPixels) { + 48 + } else if pixel_encoding.eq_ignore_ascii_case(IO32BitDirectPixels) { + 32 + } else if pixel_encoding.eq_ignore_ascii_case(kIO30BitDirectPixels) { + 30 + } else if pixel_encoding.eq_ignore_ascii_case(IO16BitDirectPixels) { + 16 + } else if pixel_encoding.eq_ignore_ascii_case(IO8BitIndexedPixels) { + 8 + }else{ + 0 + } + } +} + +#[link(name = "CoreGraphics", kind = "framework")] +extern "C" { + pub static CGRectNull: CGRect; + pub static CGRectInfinite: CGRect; + + pub static kCGDisplayShowDuplicateLowResolutionModes: CFStringRef; + + pub fn CGDisplayModeRelease(mode: ::sys::CGDisplayModeRef); + + pub fn CGMainDisplayID() -> CGDirectDisplayID; + pub fn CGDisplayIsActive(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsAlwaysInMirrorSet(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsAsleep(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsBuiltin(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsInHWMirrorSet(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsInMirrorSet(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsMain(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsOnline(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsStereo(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayMirrorsDisplay(display: CGDirectDisplayID) -> CGDirectDisplayID; + pub fn CGDisplayPrimaryDisplay(display: CGDirectDisplayID) -> CGDirectDisplayID; + pub fn CGDisplayRotation(display: CGDirectDisplayID) -> libc::c_double; + pub fn CGDisplayScreenSize(display: CGDirectDisplayID) -> CGSize; + pub fn CGDisplaySerialNumber(display: CGDirectDisplayID) -> libc::uint32_t; + pub fn CGDisplayUnitNumber(display: CGDirectDisplayID) -> libc::uint32_t; + pub fn CGDisplayUsesOpenGLAcceleration(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayVendorNumber(display: CGDirectDisplayID) -> libc::uint32_t; + pub fn CGGetActiveDisplayList( + max_displays: libc::uint32_t, + active_displays: *mut CGDirectDisplayID, + display_count: *mut libc::uint32_t, + ) -> CGError; + pub fn CGGetDisplaysWithRect( + rect: CGRect, + max_displays: libc::uint32_t, + displays: *mut CGDirectDisplayID, + matching_display_count: *mut libc::uint32_t, + ) -> CGError; + pub fn CGDisplayModelNumber(display: CGDirectDisplayID) -> libc::uint32_t; + pub fn CGDisplayPixelsHigh(display: CGDirectDisplayID) -> libc::size_t; + pub fn CGDisplayPixelsWide(display: CGDirectDisplayID) -> libc::size_t; + pub fn CGDisplayBounds(display: CGDirectDisplayID) -> CGRect; + pub fn CGDisplayCreateImage(display: CGDirectDisplayID) -> ::sys::CGImageRef; + + pub fn CGBeginDisplayConfiguration(config: *const CGDisplayConfigRef) -> CGError; + pub fn CGCancelDisplayConfiguration(config: CGDisplayConfigRef) -> CGError; + pub fn CGCompleteDisplayConfiguration( + config: CGDisplayConfigRef, + option: CGConfigureOption, + ) -> CGError; + pub fn CGConfigureDisplayWithDisplayMode( + config: CGDisplayConfigRef, + display: CGDirectDisplayID, + mode: ::sys::CGDisplayModeRef, + options: CFDictionaryRef, + ) -> CGError; + + pub fn CGDisplayCopyDisplayMode(display: CGDirectDisplayID) -> ::sys::CGDisplayModeRef; + pub fn CGDisplayModeGetHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t; + pub fn CGDisplayModeGetWidth(mode: ::sys::CGDisplayModeRef) -> libc::size_t; + pub fn CGDisplayModeGetPixelHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t; + pub fn CGDisplayModeGetPixelWidth(mode: ::sys::CGDisplayModeRef) -> libc::size_t; + pub fn CGDisplayModeGetRefreshRate(mode: ::sys::CGDisplayModeRef) -> libc::c_double; + pub fn CGDisplayModeGetIOFlags(mode: ::sys::CGDisplayModeRef) -> libc::uint32_t; + pub fn CGDisplayModeCopyPixelEncoding(mode: ::sys::CGDisplayModeRef) -> CFStringRef; + + pub fn CGDisplayCopyAllDisplayModes( + display: CGDirectDisplayID, + options: CFDictionaryRef, + ) -> CFArrayRef; + + // mouse stuff + pub fn CGDisplayHideCursor(display: CGDirectDisplayID) -> CGError; + pub fn CGDisplayShowCursor(display: CGDirectDisplayID) -> CGError; + pub fn CGDisplayMoveCursorToPoint(display: CGDirectDisplayID, point: CGPoint) -> CGError; + pub fn CGWarpMouseCursorPosition(point: CGPoint) -> CGError; + pub fn CGAssociateMouseAndMouseCursorPosition(connected: boolean_t) -> CGError; + + // Window Services Reference + pub fn CGWindowListCopyWindowInfo( + option: CGWindowListOption, + relativeToWindow: CGWindowID, + ) -> CFArrayRef; + pub fn CGWindowListCreateImage( + screenBounds: CGRect, + listOptions: CGWindowListOption, + windowId: CGWindowID, + imageOptions: CGWindowImageOption, + ) -> ::sys::CGImageRef; + pub fn CGWindowListCreateImageFromArray( + screenBounds: CGRect, + windowArray: CFArrayRef, + imageOptions: CGWindowImageOption, + ) -> ::sys::CGImageRef; +} diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/event.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/event.rs new file mode 100644 index 0000000..9d9ca18 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/event.rs @@ -0,0 +1,669 @@ +#![allow(non_upper_case_globals)] + +use core_foundation::base::{CFRelease, CFRetain, CFTypeID}; +use geometry::CGPoint; +use event_source::CGEventSource; + +use libc; + +use foreign_types::ForeignType; + +pub type CGEventField = libc::uint32_t; +pub type CGKeyCode = libc::uint16_t; +pub type CGScrollEventUnit = libc::uint32_t; + +/// Flags for events +/// +/// [Ref](http://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-700/IOHIDSystem/IOKit/hidsystem/IOLLEvent.h) +bitflags! { + #[repr(C)] + pub struct CGEventFlags: u64 { + const CGEventFlagNull = 0; + + // Device-independent modifier key bits. + const CGEventFlagAlphaShift = 0x00010000; + const CGEventFlagShift = 0x00020000; + const CGEventFlagControl = 0x00040000; + const CGEventFlagAlternate = 0x00080000; + const CGEventFlagCommand = 0x00100000; + + // Special key identifiers. + const CGEventFlagHelp = 0x00400000; + const CGEventFlagSecondaryFn = 0x00800000; + + // Identifies key events from numeric keypad area on extended keyboards. + const CGEventFlagNumericPad = 0x00200000; + + // Indicates if mouse/pen movement events are not being coalesced + const CGEventFlagNonCoalesced = 0x00000100; + } +} + +/// Key codes for keys that are independent of keyboard layout. +/// +/// [Ref](https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.13.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h) +#[repr(C)] +pub struct KeyCode; +impl KeyCode { + pub const RETURN: CGKeyCode = 0x24; + pub const TAB: CGKeyCode = 0x30; + pub const SPACE: CGKeyCode = 0x31; + pub const DELETE: CGKeyCode = 0x33; + pub const ESCAPE: CGKeyCode = 0x35; + pub const COMMAND: CGKeyCode = 0x37; + pub const SHIFT: CGKeyCode = 0x38; + pub const CAPS_LOCK: CGKeyCode = 0x39; + pub const OPTION: CGKeyCode = 0x3A; + pub const CONTROL: CGKeyCode = 0x3B; + pub const RIGHT_COMMAND: CGKeyCode = 0x36; + pub const RIGHT_SHIFT: CGKeyCode = 0x3C; + pub const RIGHT_OPTION: CGKeyCode = 0x3D; + pub const RIGHT_CONTROL: CGKeyCode = 0x3E; + pub const FUNCTION: CGKeyCode = 0x3F; + pub const VOLUME_UP: CGKeyCode = 0x48; + pub const VOLUME_DOWN: CGKeyCode = 0x49; + pub const MUTE: CGKeyCode = 0x4A; + pub const F1: CGKeyCode = 0x7A; + pub const F2: CGKeyCode = 0x78; + pub const F3: CGKeyCode = 0x63; + pub const F4: CGKeyCode = 0x76; + pub const F5: CGKeyCode = 0x60; + pub const F6: CGKeyCode = 0x61; + pub const F7: CGKeyCode = 0x62; + pub const F8: CGKeyCode = 0x64; + pub const F9: CGKeyCode = 0x65; + pub const F10: CGKeyCode = 0x6D; + pub const F11: CGKeyCode = 0x67; + pub const F12: CGKeyCode = 0x6F; + pub const F13: CGKeyCode = 0x69; + pub const F14: CGKeyCode = 0x6B; + pub const F15: CGKeyCode = 0x71; + pub const F16: CGKeyCode = 0x6A; + pub const F17: CGKeyCode = 0x40; + pub const F18: CGKeyCode = 0x4F; + pub const F19: CGKeyCode = 0x50; + pub const F20: CGKeyCode = 0x5A; + pub const HELP: CGKeyCode = 0x72; + pub const HOME: CGKeyCode = 0x73; + pub const PAGE_UP: CGKeyCode = 0x74; + pub const FORWARD_DELETE: CGKeyCode = 0x75; + pub const END: CGKeyCode = 0x77; + pub const PAGE_DOWN: CGKeyCode = 0x79; + pub const LEFT_ARROW: CGKeyCode = 0x7B; + pub const RIGHT_ARROW: CGKeyCode = 0x7C; + pub const DOWN_ARROW: CGKeyCode = 0x7D; + pub const UP_ARROW: CGKeyCode = 0x7E; +} + +#[repr(C)] +pub struct ScrollEventUnit {} +impl ScrollEventUnit { + pub const PIXEL: CGScrollEventUnit = 0; + pub const LINE: CGScrollEventUnit = 1; +} + +/// Constants that specify the different types of input events. +/// +/// [Ref](http://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-700/IOHIDSystem/IOKit/hidsystem/IOLLEvent.h) +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub enum CGEventType { + Null = 0, + + // Mouse events. + LeftMouseDown = 1, + LeftMouseUp = 2, + RightMouseDown = 3, + RightMouseUp = 4, + MouseMoved = 5, + LeftMouseDragged = 6, + RightMouseDragged = 7, + + // Keyboard events. + KeyDown = 10, + KeyUp = 11, + FlagsChanged = 12, + + // Specialized control devices. + ScrollWheel = 22, + TabletPointer = 23, + TabletProximity = 24, + OtherMouseDown = 25, + OtherMouseUp = 26, + OtherMouseDragged = 27, + + // Out of band event types. These are delivered to the event tap callback + // to notify it of unusual conditions that disable the event tap. + TapDisabledByTimeout = 0xFFFFFFFE, + TapDisabledByUserInput = 0xFFFFFFFF, +} + +/// Constants used as keys to access specialized fields in low-level events. +/// +/// [Ref](https://developer.apple.com/documentation/coregraphics/cgeventfield) +pub struct EventField; +impl EventField { + /// Key to access an integer field that contains the mouse button event + /// number. Matching mouse-down and mouse-up events will have the same + /// event number. + pub const MOUSE_EVENT_NUMBER: CGEventField = 0; + + /// Key to access an integer field that contains the mouse button click + /// state. A click state of 1 represents a single click. A click state of + /// 2 represents a double-click. A click state of 3 represents a + /// triple-click. + pub const MOUSE_EVENT_CLICK_STATE: CGEventField = 1; + + /// Key to access a double field that contains the mouse button pressure. + /// The pressure value may range from 0 to 1, with 0 representing the + /// mouse being up. This value is commonly set by tablet pens mimicking a + /// mouse. + pub const MOUSE_EVENT_PRESSURE: CGEventField = 2; + + /// Key to access an integer field that contains the mouse button number. + pub const MOUSE_EVENT_BUTTON_NUMBER: CGEventField = 3; + + /// Key to access an integer field that contains the horizontal mouse + /// delta since the last mouse movement event. + pub const MOUSE_EVENT_DELTA_X: CGEventField = 4; + + /// Key to access an integer field that contains the vertical mouse delta + /// since the last mouse movement event. + pub const MOUSE_EVENT_DELTA_Y: CGEventField = 5; + + /// Key to access an integer field. The value is non-zero if the event + /// should be ignored by the Inkwell subsystem. + pub const MOUSE_EVENT_INSTANT_MOUSER: CGEventField = 6; + + /// Key to access an integer field that encodes the mouse event subtype as + /// a `kCFNumberIntType'. + pub const MOUSE_EVENT_SUB_TYPE: CGEventField = 7; + + /// Key to access an integer field, non-zero when this is an autorepeat of + /// a key-down, and zero otherwise. + pub const KEYBOARD_EVENT_AUTOREPEAT: CGEventField = 8; + + /// Key to access an integer field that contains the virtual keycode of the + /// key-down or key-up event. + pub const KEYBOARD_EVENT_KEYCODE: CGEventField = 9; + + /// Key to access an integer field that contains the keyboard type + /// identifier. + pub const KEYBOARD_EVENT_KEYBOARD_TYPE: CGEventField = 10; + + /// Key to access an integer field that contains scrolling data. This field + /// typically contains the change in vertical position since the last + /// scrolling event from a Mighty Mouse scroller or a single-wheel mouse + /// scroller. + pub const SCROLL_WHEEL_EVENT_DELTA_AXIS_1: CGEventField = 11; + + /// Key to access an integer field that contains scrolling data. This field + /// typically contains the change in horizontal position since the last + /// scrolling event from a Mighty Mouse scroller. + pub const SCROLL_WHEEL_EVENT_DELTA_AXIS_2: CGEventField = 12; + + /// Key to access a field that contains scrolling data. The scrolling data + /// represents a line-based or pixel-based change in vertical position + /// since the last scrolling event from a Mighty Mouse scroller or a + /// single-wheel mouse scroller. The scrolling data uses a fixed-point + /// 16.16 signed integer format. If this key is passed to + /// `CGEventGetDoubleValueField', the fixed-point value is converted to a + /// double value. + pub const SCROLL_WHEEL_EVENT_FIXED_POINT_DELTA_AXIS_1: CGEventField = 93; + + /// Key to access a field that contains scrolling data. The scrolling data + /// represents a line-based or pixel-based change in horizontal position + /// since the last scrolling event from a Mighty Mouse scroller. The + /// scrolling data uses a fixed-point 16.16 signed integer format. If this + /// key is passed to `CGEventGetDoubleValueField', the fixed-point value is + /// converted to a double value. + pub const SCROLL_WHEEL_EVENT_FIXED_POINT_DELTA_AXIS_2: CGEventField = 94; + + /// Key to access an integer field that contains pixel-based scrolling + /// data. The scrolling data represents the change in vertical position + /// since the last scrolling event from a Mighty Mouse scroller or a + /// single-wheel mouse scroller. + pub const SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_1: CGEventField = 96; + + /// Key to access an integer field that contains pixel-based scrolling + /// data. The scrolling data represents the change in horizontal position + /// since the last scrolling event from a Mighty Mouse scroller. + pub const SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_2: CGEventField = 97; + + /// Key to access an integer field that indicates whether the event should + /// be ignored by the Inkwell subsystem. If the value is non-zero, the + /// event should be ignored. + pub const SCROLL_WHEEL_EVENT_INSTANT_MOUSER: CGEventField = 14; + + /// Key to access an integer field that contains the absolute X coordinate + /// in tablet space at full tablet resolution. + pub const TABLET_EVENT_POINT_X: CGEventField = 15; + + /// Key to access an integer field that contains the absolute Y coordinate + /// in tablet space at full tablet resolution. + pub const TABLET_EVENT_POINT_Y: CGEventField = 16; + + /// Key to access an integer field that contains the absolute Z coordinate + /// in tablet space at full tablet resolution. + pub const TABLET_EVENT_POINT_Z: CGEventField = 17; + + /// Key to access an integer field that contains the tablet button state. + /// Bit 0 is the first button, and a set bit represents a closed or pressed + /// button. Up to 16 buttons are supported. + pub const TABLET_EVENT_POINT_BUTTONS: CGEventField = 18; + + /// Key to access a double field that contains the tablet pen pressure. A + /// value of 0.0 represents no pressure, and 1.0 represents maximum + /// pressure. + pub const TABLET_EVENT_POINT_PRESSURE: CGEventField = 19; + + /// Key to access a double field that contains the horizontal tablet pen + /// tilt. A value of 0 represents no tilt, and 1 represents maximum tilt. + pub const TABLET_EVENT_TILT_X: CGEventField = 20; + + /// Key to access a double field that contains the vertical tablet pen + /// tilt. A value of 0 represents no tilt, and 1 represents maximum tilt. + pub const TABLET_EVENT_TILT_Y: CGEventField = 21; + + /// Key to access a double field that contains the tablet pen rotation. + pub const TABLET_EVENT_ROTATION: CGEventField = 22; + + /// Key to access a double field that contains the tangential pressure on + /// the device. A value of 0.0 represents no pressure, and 1.0 represents + /// maximum pressure. + pub const TABLET_EVENT_TANGENTIAL_PRESSURE: CGEventField = 23; + + /// Key to access an integer field that contains the system-assigned unique + /// device ID. + pub const TABLET_EVENT_DEVICE_ID: CGEventField = 24; + + /// Key to access an integer field that contains a vendor-specified value. + pub const TABLET_EVENT_VENDOR_1: CGEventField = 25; + + /// Key to access an integer field that contains a vendor-specified value. + pub const TABLET_EVENT_VENDOR_2: CGEventField = 26; + + /// Key to access an integer field that contains a vendor-specified value. + pub const TABLET_EVENT_VENDOR_3: CGEventField = 27; + + /// Key to access an integer field that contains the vendor-defined ID, + /// typically the USB vendor ID. + pub const TABLET_PROXIMITY_EVENT_VENDOR_ID: CGEventField = 28; + + /// Key to access an integer field that contains the vendor-defined tablet + /// ID, typically the USB product ID. + pub const TABLET_PROXIMITY_EVENT_TABLET_ID: CGEventField = 29; + + /// Key to access an integer field that contains the vendor-defined ID of + /// the pointing device. + pub const TABLET_PROXIMITY_EVENT_POINTER_ID: CGEventField = 30; + + /// Key to access an integer field that contains the system-assigned + /// device ID. + pub const TABLET_PROXIMITY_EVENT_DEVICE_ID: CGEventField = 31; + + /// Key to access an integer field that contains the system-assigned + /// unique tablet ID. + pub const TABLET_PROXIMITY_EVENT_SYSTEM_TABLET_ID: CGEventField = 32; + + /// Key to access an integer field that contains the vendor-assigned + /// pointer type. + pub const TABLET_PROXIMITY_EVENT_VENDOR_POINTER_TYPE: CGEventField = 33; + + /// Key to access an integer field that contains the vendor-defined + /// pointer serial number. + pub const TABLET_PROXIMITY_EVENT_VENDOR_POINTER_SERIAL_NUMBER: CGEventField = 34; + + /// Key to access an integer field that contains the vendor-defined unique + /// ID. + pub const TABLET_PROXIMITY_EVENT_VENDOR_UNIQUE_ID: CGEventField = 35; + + /// Key to access an integer field that contains the device capabilities + /// mask. + pub const TABLET_PROXIMITY_EVENT_CAPABILITY_MASK: CGEventField = 36; + + /// Key to access an integer field that contains the pointer type. + pub const TABLET_PROXIMITY_EVENT_POINTER_TYPE: CGEventField = 37; + + /// Key to access an integer field that indicates whether the pen is in + /// proximity to the tablet. The value is non-zero if the pen is in + /// proximity to the tablet and zero when leaving the tablet. + pub const TABLET_PROXIMITY_EVENT_ENTER_PROXIMITY: CGEventField = 38; + + /// Key to access a field that contains the event target process serial + /// number. The value is a 64-bit value. + pub const EVENT_TARGET_PROCESS_SERIAL_NUMBER: CGEventField = 39; + + /// Key to access a field that contains the event target Unix process ID. + pub const EVENT_TARGET_UNIX_PROCESS_ID: CGEventField = 40; + + /// Key to access a field that contains the event source Unix process ID. + pub const EVENT_SOURCE_UNIX_PROCESS_ID: CGEventField = 41; + + /// Key to access a field that contains the event source user-supplied + /// data, up to 64 bits. + pub const EVENT_SOURCE_USER_DATA: CGEventField = 42; + + /// Key to access a field that contains the event source Unix effective UID. + pub const EVENT_SOURCE_USER_ID: CGEventField = 43; + + /// Key to access a field that contains the event source Unix effective + /// GID. + pub const EVENT_SOURCE_GROUP_ID: CGEventField = 44; + + /// Key to access a field that contains the event source state ID used to + /// create this event. + pub const EVENT_SOURCE_STATE_ID: CGEventField = 45; + + /// Key to access an integer field that indicates whether a scrolling event + /// contains continuous, pixel-based scrolling data. The value is non-zero + /// when the scrolling data is pixel-based and zero when the scrolling data + /// is line-based. + pub const SCROLL_WHEEL_EVENT_IS_CONTINUOUS: CGEventField = 88; + + /// Added in 10.5; made public in 10.7. + pub const MOUSE_EVENT_WINDOW_UNDER_MOUSE_POINTER: CGEventField = 91; + pub const MOUSE_EVENT_WINDOW_UNDER_MOUSE_POINTER_THAT_CAN_HANDLE_THIS_EVENT: CGEventField = 92; +} + +// Constants that specify buttons on a one, two, or three-button mouse. +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub enum CGMouseButton { + Left, + Right, + Center, +} + +/// Possible tapping points for events. +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub enum CGEventTapLocation { + HID, + Session, + AnnotatedSession, +} + +foreign_type! { + #[doc(hidden)] + type CType = ::sys::CGEvent; + fn drop = |p| CFRelease(p as *mut _); + fn clone = |p| CFRetain(p as *const _) as *mut _; + pub struct CGEvent; + pub struct CGEventRef; +} + +impl CGEvent { + pub fn type_id() -> CFTypeID { + unsafe { + CGEventGetTypeID() + } + } + + pub fn new(source: CGEventSource) -> Result { + unsafe { + let event_ref = CGEventCreate(source.as_ptr()); + if !event_ref.is_null() { + Ok(Self::from_ptr(event_ref)) + } else { + Err(()) + } + } + } + + pub fn new_keyboard_event( + source: CGEventSource, + keycode: CGKeyCode, + keydown: bool + ) -> Result { + unsafe { + let event_ref = CGEventCreateKeyboardEvent(source.as_ptr(), keycode, keydown); + if !event_ref.is_null() { + Ok(Self::from_ptr(event_ref)) + } else { + Err(()) + } + } + } + + pub fn new_mouse_event( + source: CGEventSource, + mouse_type: CGEventType, + mouse_cursor_position: CGPoint, + mouse_button: CGMouseButton + ) -> Result { + unsafe { + let event_ref = CGEventCreateMouseEvent(source.as_ptr(), mouse_type, + mouse_cursor_position, mouse_button); + if !event_ref.is_null() { + Ok(Self::from_ptr(event_ref)) + } else { + Err(()) + } + } + } + + #[cfg(feature = "highsierra")] + pub fn new_scroll_event( + source: CGEventSource, + units: CGScrollEventUnit, + wheel_count: u32, + wheel1: i32, + wheel2: i32, + wheel3: i32, + ) -> Result { + unsafe { + let event_ref = CGEventCreateScrollWheelEvent2( + source.as_ptr(), + units, + wheel_count, + wheel1, + wheel2, + wheel3, + ); + if !event_ref.is_null() { + Ok(Self::from_ptr(event_ref)) + } else { + Err(()) + } + } + } + + pub fn post(&self, tap_location: CGEventTapLocation) { + unsafe { + CGEventPost(tap_location, self.as_ptr()); + } + } + + pub fn location(&self) -> CGPoint { + unsafe { + CGEventGetLocation(self.as_ptr()) + } + } + + #[cfg(feature = "elcapitan")] + pub fn post_to_pid(&self, pid: libc::pid_t) { + unsafe { + CGEventPostToPid(pid, self.as_ptr()); + } + } + + pub fn set_flags(&self, flags: CGEventFlags) { + unsafe { + CGEventSetFlags(self.as_ptr(), flags); + } + } + + pub fn get_flags(&self) -> CGEventFlags { + unsafe { + CGEventGetFlags(self.as_ptr()) + } + } + + pub fn set_type(&self, event_type: CGEventType) { + unsafe { + CGEventSetType(self.as_ptr(), event_type); + } + } + + pub fn get_type(&self) -> CGEventType { + unsafe { + CGEventGetType(self.as_ptr()) + } + } + + pub fn set_string_from_utf16_unchecked(&self, buf: &[u16]) { + let buflen = buf.len() as libc::c_ulong; + unsafe { + CGEventKeyboardSetUnicodeString(self.as_ptr(), buflen, buf.as_ptr()); + } + } + + pub fn set_string(&self, string: &str) { + let buf: Vec = string.encode_utf16().collect(); + self.set_string_from_utf16_unchecked(&buf); + } + + pub fn get_integer_value_field(&self, field: CGEventField) -> i64 { + unsafe { CGEventGetIntegerValueField(self.as_ptr(), field) } + } + + pub fn set_integer_value_field(&self, field: CGEventField, value: i64) { + unsafe { CGEventSetIntegerValueField(self.as_ptr(), field, value) } + } + + pub fn get_double_value_field(&self, field: CGEventField) -> f64 { + unsafe { CGEventGetDoubleValueField(self.as_ptr(), field) } + } + + pub fn set_double_value_field(&self, field: CGEventField, value: f64) { + unsafe { CGEventSetDoubleValueField(self.as_ptr(), field, value) } + } +} + +#[link(name = "CoreGraphics", kind = "framework")] +extern { + /// Return the type identifier for the opaque type `CGEventRef'. + fn CGEventGetTypeID() -> CFTypeID; + + /// Return a new event using the event source `source'. If `source' is NULL, + /// the default source is used. + fn CGEventCreate(source: ::sys::CGEventSourceRef) -> ::sys::CGEventRef; + + /// Return a new keyboard event. + /// + /// The event source may be taken from another event, or may be NULL. Based + /// on the virtual key code values entered, the appropriate key down, key up, + /// or flags changed events are generated. + /// + /// All keystrokes needed to generate a character must be entered, including + /// SHIFT, CONTROL, OPTION, and COMMAND keys. For example, to produce a 'Z', + /// the SHIFT key must be down, the 'z' key must go down, and then the SHIFT + /// and 'z' key must be released: + fn CGEventCreateKeyboardEvent(source: ::sys::CGEventSourceRef, keycode: CGKeyCode, + keydown: bool) -> ::sys::CGEventRef; + + /// Return a new mouse event. + /// + /// The event source may be taken from another event, or may be NULL. + /// `mouseType' should be one of the mouse event types. `mouseCursorPosition' + /// should be the position of the mouse cursor in global coordinates. + /// `mouseButton' should be the button that's changing state; `mouseButton' + /// is ignored unless `mouseType' is one of `kCGEventOtherMouseDown', + /// `kCGEventOtherMouseDragged', or `kCGEventOtherMouseUp'. + /// + /// The current implementation of the event system supports a maximum of + /// thirty-two buttons. Mouse button 0 is the primary button on the mouse. + /// Mouse button 1 is the secondary mouse button (right). Mouse button 2 is + /// the center button, and the remaining buttons are in USB device order. + fn CGEventCreateMouseEvent(source: ::sys::CGEventSourceRef, mouseType: CGEventType, + mouseCursorPosition: CGPoint, mouseButton: CGMouseButton) -> ::sys::CGEventRef; + + /// A non-variadic variant version of CGEventCreateScrollWheelEvent. + /// + /// Returns a new Quartz scrolling event. + /// + /// This function allows you to create a scrolling event and customize the + /// event before posting it to the event system. + #[cfg(feature = "highsierra")] + fn CGEventCreateScrollWheelEvent2( + source: ::sys::CGEventSourceRef, + units: CGScrollEventUnit, + wheelCount: libc::uint32_t, + wheel1: libc::int32_t, + wheel2: libc::int32_t, + wheel3: libc::int32_t, + ) -> ::sys::CGEventRef; + + /// Post an event into the event stream at a specified location. + /// + /// This function posts the specified event immediately before any event taps + /// instantiated for that location, and the event passes through any such + /// taps. + fn CGEventPost(tapLocation: CGEventTapLocation, event: ::sys::CGEventRef); + + #[cfg(feature = "elcapitan")] + /// Post an event to a specified process ID + fn CGEventPostToPid(pid: libc::pid_t, event: ::sys::CGEventRef); + + /// Set the event flags of an event. + fn CGEventSetFlags(event: ::sys::CGEventRef, flags: CGEventFlags); + + /// Return the event flags of an event. + fn CGEventGetFlags(event: ::sys::CGEventRef) -> CGEventFlags; + + /// Return the location of an event in global display coordinates. + /// CGPointZero is returned if event is not a valid ::sys::CGEventRef. + fn CGEventGetLocation(event: ::sys::CGEventRef) -> CGPoint; + + /// Set the event type of an event. + fn CGEventSetType(event: ::sys::CGEventRef, eventType: CGEventType); + + /// Return the event type of an event (left mouse down, for example). + fn CGEventGetType(event: ::sys::CGEventRef) -> CGEventType; + + /// Set the Unicode string associated with a keyboard event. + /// + /// By default, the system translates the virtual key code in a keyboard + /// event into a Unicode string based on the keyboard ID in the event + /// source. This function allows you to manually override this string. + /// Note that application frameworks may ignore the Unicode string in a + /// keyboard event and do their own translation based on the virtual + /// keycode and perceived event state. + fn CGEventKeyboardSetUnicodeString(event: ::sys::CGEventRef, + length: libc::c_ulong, + string: *const u16); + + /// Return the integer value of a field in an event. + fn CGEventGetIntegerValueField(event: ::sys::CGEventRef, field: CGEventField) -> i64; + + /// Set the integer value of a field in an event. + /// + /// Before calling this function, the event type must be set using a typed + /// event creation function such as `CGEventCreateMouseEvent', or by + /// calling `CGEventSetType'. + /// + /// If you are creating a mouse event generated by a tablet, call this + /// function and specify the field `kCGMouseEventSubtype' with a value of + /// `kCGEventMouseSubtypeTabletPoint' or + /// `kCGEventMouseSubtypeTabletProximity' before setting other parameters. + fn CGEventSetIntegerValueField(event: ::sys::CGEventRef, field: CGEventField, value: i64); + + /// Return the floating-point value of a field in an event. + /// + /// In cases where the field value is represented within the event by a fixed + /// point number or an integer, the result is scaled to the appropriate range + /// as part of creating the floating-point representation. + fn CGEventGetDoubleValueField(event: ::sys::CGEventRef, field: CGEventField) -> f64; + + /// Set the floating-point value of a field in an event. + /// + /// Before calling this function, the event type must be set using a typed + /// event creation function such as `CGEventCreateMouseEvent', or by calling + /// `CGEventSetType'. + /// + /// In cases where the field’s value is represented within the event by a + /// fixed point number or integer, the value parameter is scaled as needed + /// and converted to the appropriate type. + fn CGEventSetDoubleValueField(event: ::sys::CGEventRef, field: CGEventField, value: f64); +} diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/event_source.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/event_source.rs new file mode 100644 index 0000000..ce13f5a --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/event_source.rs @@ -0,0 +1,48 @@ +use core_foundation::base::{CFRelease, CFRetain, CFTypeID}; +use foreign_types::ForeignType; + +/// Possible source states of an event source. +#[repr(C)] +#[derive(Clone, Copy, Debug)] +pub enum CGEventSourceStateID { + Private = -1, + CombinedSessionState = 0, + HIDSystemState = 1, +} + +foreign_type! { + #[doc(hidden)] + type CType = ::sys::CGEventSource; + fn drop = |p| CFRelease(p as *mut _); + fn clone = |p| CFRetain(p as *const _) as *mut _; + pub struct CGEventSource; + pub struct CGEventSourceRef; +} + +impl CGEventSource { + pub fn type_id() -> CFTypeID { + unsafe { + CGEventSourceGetTypeID() + } + } + + pub fn new(state_id: CGEventSourceStateID) -> Result { + unsafe { + let event_source_ref = CGEventSourceCreate(state_id); + if !event_source_ref.is_null() { + Ok(Self::from_ptr(event_source_ref)) + } else { + Err(()) + } + } + } +} + +#[link(name = "CoreGraphics", kind = "framework")] +extern { + /// Return the type identifier for the opaque type `CGEventSourceRef'. + fn CGEventSourceGetTypeID() -> CFTypeID; + + /// Return a Quartz event source created with a specified source state. + fn CGEventSourceCreate(stateID: CGEventSourceStateID) -> ::sys::CGEventSourceRef; +} diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/font.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/font.rs new file mode 100644 index 0000000..fc7a9ba --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/font.rs @@ -0,0 +1,157 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ptr; +use core_foundation::base::{CFRelease, CFRetain, CFTypeID, TCFType}; +use core_foundation::array::{CFArray, CFArrayRef}; +use core_foundation::data::{CFData, CFDataRef}; +use core_foundation::number::CFNumber; +use core_foundation::string::{CFString, CFStringRef}; +use core_foundation::dictionary::{CFDictionary, CFDictionaryRef}; +use data_provider::CGDataProvider; +use geometry::CGRect; + +use foreign_types::ForeignType; + +use libc::{self, c_int, size_t}; + +pub type CGGlyph = libc::c_ushort; + +foreign_type! { + #[doc(hidden)] + type CType = ::sys::CGFont; + fn drop = |p| CFRelease(p as *mut _); + fn clone = |p| CFRetain(p as *const _) as *mut _; + pub struct CGFont; + pub struct CGFontRef; +} + +unsafe impl Send for CGFont {} +unsafe impl Sync for CGFont {} + +impl CGFont { + pub fn type_id() -> CFTypeID { + unsafe { + CGFontGetTypeID() + } + } + + pub fn from_data_provider(provider: CGDataProvider) -> Result { + unsafe { + let font_ref = CGFontCreateWithDataProvider(provider.as_ptr()); + if !font_ref.is_null() { + Ok(CGFont::from_ptr(font_ref)) + } else { + Err(()) + } + } + } + + pub fn from_name(name: &CFString) -> Result { + unsafe { + let font_ref = CGFontCreateWithFontName(name.as_concrete_TypeRef()); + if !font_ref.is_null() { + Ok(CGFont::from_ptr(font_ref)) + } else { + Err(()) + } + } + } + + pub fn create_copy_from_variations(&self, vars: &CFDictionary) -> Result { + unsafe { + let font_ref = CGFontCreateCopyWithVariations(self.as_ptr(), + vars.as_concrete_TypeRef()); + if !font_ref.is_null() { + Ok(CGFont::from_ptr(font_ref)) + } else { + Err(()) + } + } + } + + pub fn postscript_name(&self) -> CFString { + unsafe { + let string_ref = CGFontCopyPostScriptName(self.as_ptr()); + TCFType::wrap_under_create_rule(string_ref) + } + } + + pub fn get_glyph_b_boxes(&self, glyphs: &[CGGlyph], bboxes: &mut [CGRect]) -> bool { + unsafe { + assert!(bboxes.len() >= glyphs.len()); + CGFontGetGlyphBBoxes(self.as_ptr(), + glyphs.as_ptr(), + glyphs.len(), + bboxes.as_mut_ptr()) + } + } + + pub fn get_glyph_advances(&self, glyphs: &[CGGlyph], advances: &mut [c_int]) -> bool { + unsafe { + assert!(advances.len() >= glyphs.len()); + CGFontGetGlyphAdvances(self.as_ptr(), + glyphs.as_ptr(), + glyphs.len(), + advances.as_mut_ptr()) + } + } + + pub fn get_units_per_em(&self) -> c_int { + unsafe { + CGFontGetUnitsPerEm(self.as_ptr()) + } + } + + pub fn copy_table_tags(&self) -> CFArray { + unsafe { + TCFType::wrap_under_create_rule(CGFontCopyTableTags(self.as_ptr())) + } + } + + pub fn copy_table_for_tag(&self, tag: u32) -> Option { + let data_ref = unsafe { CGFontCopyTableForTag(self.as_ptr(), tag) }; + if data_ref != ptr::null() { + Some(unsafe { TCFType::wrap_under_create_rule(data_ref) }) + } else { + None + } + } +} + +#[link(name = "CoreGraphics", kind = "framework")] +extern { + // TODO: basically nothing has bindings (even commented-out) besides what we use. + fn CGFontCreateWithDataProvider(provider: ::sys::CGDataProviderRef) -> ::sys::CGFontRef; + fn CGFontCreateWithFontName(name: CFStringRef) -> ::sys::CGFontRef; + fn CGFontCreateCopyWithVariations(font: ::sys::CGFontRef, vars: CFDictionaryRef) -> ::sys::CGFontRef; + fn CGFontGetTypeID() -> CFTypeID; + + fn CGFontCopyPostScriptName(font: ::sys::CGFontRef) -> CFStringRef; + + // These do the same thing as CFRetain/CFRelease, except + // gracefully handle a NULL argument. We don't use them. + //fn CGFontRetain(font: ::sys::CGFontRef); + //fn CGFontRelease(font: ::sys::CGFontRef); + + fn CGFontGetGlyphBBoxes(font: ::sys::CGFontRef, + glyphs: *const CGGlyph, + count: size_t, + bboxes: *mut CGRect) + -> bool; + fn CGFontGetGlyphAdvances(font: ::sys::CGFontRef, + glyphs: *const CGGlyph, + count: size_t, + advances: *mut c_int) + -> bool; + fn CGFontGetUnitsPerEm(font: ::sys::CGFontRef) -> c_int; + + fn CGFontCopyTableTags(font: ::sys::CGFontRef) -> CFArrayRef; + fn CGFontCopyTableForTag(font: ::sys::CGFontRef, tag: u32) -> CFDataRef; +} diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/geometry.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/geometry.rs new file mode 100644 index 0000000..b22c704 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/geometry.rs @@ -0,0 +1,205 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use base::CGFloat; +use core_foundation::base::TCFType; +use core_foundation::dictionary::CFDictionary; + +pub const CG_ZERO_POINT: CGPoint = CGPoint { + x: 0.0, + y: 0.0, +}; + +pub const CG_ZERO_SIZE: CGSize = CGSize { + width: 0.0, + height: 0.0, +}; + +pub const CG_ZERO_RECT: CGRect = CGRect { + origin: CG_ZERO_POINT, + size: CG_ZERO_SIZE, +}; + +pub const CG_AFFINE_TRANSFORM_IDENTITY: CGAffineTransform = CGAffineTransform { + a: 1.0, b: 0.0, + c: 0.0, d: 1.0, + tx: 0.0, ty: 0.0, +}; + +#[repr(C)] +#[derive(Clone, Copy, Debug, Default)] +pub struct CGSize { + pub width: CGFloat, + pub height: CGFloat, +} + +impl CGSize { + #[inline] + pub fn new(width: CGFloat, height: CGFloat) -> CGSize { + CGSize { + width: width, + height: height, + } + } + + #[inline] + pub fn apply_transform(&self, t: &CGAffineTransform) -> CGSize { + unsafe { + ffi::CGSizeApplyAffineTransform(*self, *t) + } + } +} + +#[repr(C)] +#[derive(Clone, Copy, Debug, Default)] +pub struct CGPoint { + pub x: CGFloat, + pub y: CGFloat, +} + +impl CGPoint { + #[inline] + pub fn new(x: CGFloat, y: CGFloat) -> CGPoint { + CGPoint { + x: x, + y: y, + } + } + + #[inline] + pub fn apply_transform(&self, t: &CGAffineTransform) -> CGPoint { + unsafe { + ffi::CGPointApplyAffineTransform(*self, *t) + } + } +} + +#[repr(C)] +#[derive(Clone, Copy, Debug, Default)] +pub struct CGRect { + pub origin: CGPoint, + pub size: CGSize +} + +impl CGRect { + #[inline] + pub fn new(origin: &CGPoint, size: &CGSize) -> CGRect { + CGRect { + origin: *origin, + size: *size, + } + } + + #[inline] + pub fn inset(&self, size: &CGSize) -> CGRect { + unsafe { + ffi::CGRectInset(*self, size.width, size.height) + } + } + + #[inline] + pub fn from_dict_representation(dict: &CFDictionary) -> Option { + let mut rect = CGRect::new(&CGPoint::new(0., 0.), &CGSize::new(0., 0.)); + let result = unsafe { + ffi::CGRectMakeWithDictionaryRepresentation(dict.as_concrete_TypeRef(), &mut rect) + }; + if result == 0 { + None + } else { + Some(rect) + } + } + + #[inline] + pub fn is_empty(&self) -> bool { + unsafe { + // I use one, as it seems that `YES` is not available from this crate. + ffi::CGRectIsEmpty(*self) == 1 + } + } + + #[inline] + pub fn is_intersects(&self, other: &CGRect) -> bool { + unsafe { + // I use one, as it seems that `YES` is not available from this crate. + ffi::CGRectIntersectsRect(*self, *other) == 1 + } + } + + #[inline] + pub fn apply_transform(&self, t: &CGAffineTransform) -> CGRect { + unsafe { + ffi::CGRectApplyAffineTransform(*self, *t) + } + } +} + +impl PartialEq for CGRect { + #[inline] + fn eq(&self, other: &CGRect) -> bool { + unsafe { + ffi::CGRectEqualToRect(*self, *other) != 0 + } + } +} + +#[repr(C)] +#[derive(Clone, Copy, Debug, Default)] +pub struct CGAffineTransform { + pub a: CGFloat, + pub b: CGFloat, + pub c: CGFloat, + pub d: CGFloat, + pub tx: CGFloat, + pub ty: CGFloat, +} + +impl CGAffineTransform { + #[inline] + pub fn new( + a: CGFloat, + b: CGFloat, + c: CGFloat, + d: CGFloat, + tx: CGFloat, + ty: CGFloat, + ) -> CGAffineTransform { + CGAffineTransform { a, b, c, d, tx, ty } + } + + #[inline] + pub fn invert(&self) -> CGAffineTransform { + unsafe { + ffi::CGAffineTransformInvert(*self) + } + } +} + +mod ffi { + use base::{CGFloat, boolean_t}; + use geometry::{CGAffineTransform, CGPoint, CGRect, CGSize}; + use core_foundation::dictionary::CFDictionaryRef; + + #[link(name = "CoreGraphics", kind = "framework")] + extern { + pub fn CGRectInset(rect: CGRect, dx: CGFloat, dy: CGFloat) -> CGRect; + pub fn CGRectMakeWithDictionaryRepresentation(dict: CFDictionaryRef, + rect: *mut CGRect) -> boolean_t; + pub fn CGRectIsEmpty(rect: CGRect) -> boolean_t; + pub fn CGRectIntersectsRect(rect1: CGRect, rect2: CGRect) -> boolean_t; + pub fn CGRectEqualToRect(rect1: CGRect, rect2: CGRect) -> boolean_t; + + pub fn CGAffineTransformInvert(t: CGAffineTransform) -> CGAffineTransform; + + pub fn CGPointApplyAffineTransform(point: CGPoint, t: CGAffineTransform) -> CGPoint; + pub fn CGRectApplyAffineTransform(rect: CGRect, t: CGAffineTransform) -> CGRect; + pub fn CGSizeApplyAffineTransform(size: CGSize, t: CGAffineTransform) -> CGSize; + } +} + diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/image.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/image.rs new file mode 100644 index 0000000..84945e8 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/image.rs @@ -0,0 +1,165 @@ +use std::ptr; + +use base::CGFloat; +use core_foundation::base::{CFRetain, CFTypeID}; +use core_foundation::data::CFData; +use color_space::CGColorSpace; +use data_provider::{CGDataProviderRef, CGDataProvider}; +use geometry::CGRect; +use libc::size_t; +use foreign_types::{ForeignType, ForeignTypeRef}; + +#[repr(C)] +pub enum CGImageAlphaInfo { + CGImageAlphaNone, /* For example, RGB. */ + CGImageAlphaPremultipliedLast, /* For example, premultiplied RGBA */ + CGImageAlphaPremultipliedFirst, /* For example, premultiplied ARGB */ + CGImageAlphaLast, /* For example, non-premultiplied RGBA */ + CGImageAlphaFirst, /* For example, non-premultiplied ARGB */ + CGImageAlphaNoneSkipLast, /* For example, RBGX. */ + CGImageAlphaNoneSkipFirst, /* For example, XRBG. */ + CGImageAlphaOnly /* No color data, alpha data only */ +} + +#[repr(C)] +pub enum CGImageByteOrderInfo { + CGImageByteOrderMask = 0x7000, + CGImageByteOrder16Little = (1 << 12), + CGImageByteOrder32Little = (2 << 12), + CGImageByteOrder16Big = (3 << 12), + CGImageByteOrder32Big = (4 << 12) +} + +foreign_type! { + #[doc(hidden)] + type CType = ::sys::CGImage; + fn drop = CGImageRelease; + fn clone = |p| CFRetain(p as *const _) as *mut _; + pub struct CGImage; + pub struct CGImageRef; +} + +impl CGImage { + pub fn new(width: size_t, + height: size_t, + bits_per_component: size_t, + bits_per_pixel: size_t, + bytes_per_row: size_t, + colorspace: &CGColorSpace, + bitmap_info: u32, + provider: &CGDataProvider, + should_interpolate: bool, + rendering_intent: u32) + -> Self { + unsafe { + let result = CGImageCreate(width, + height, + bits_per_component, + bits_per_pixel, + bytes_per_row, + colorspace.as_ptr(), + bitmap_info, + provider.as_ptr(), + ptr::null_mut(), + should_interpolate, + rendering_intent); + assert!(!result.is_null()); + Self::from_ptr(result) + } + } + + pub fn type_id() -> CFTypeID { + unsafe { + CGImageGetTypeID() + } + } +} + +impl CGImageRef { + pub fn width(&self) -> size_t { + unsafe { + CGImageGetWidth(self.as_ptr()) + } + } + + pub fn height(&self) -> size_t { + unsafe { + CGImageGetHeight(self.as_ptr()) + } + } + + pub fn bits_per_component(&self) -> size_t { + unsafe { + CGImageGetBitsPerComponent(self.as_ptr()) + } + } + + pub fn bits_per_pixel(&self) -> size_t { + unsafe { + CGImageGetBitsPerPixel(self.as_ptr()) + } + } + + pub fn bytes_per_row(&self) -> size_t { + unsafe { + CGImageGetBytesPerRow(self.as_ptr()) + } + } + + pub fn color_space(&self) -> CGColorSpace { + unsafe { + let cs = CGImageGetColorSpace(self.as_ptr()); + CFRetain(cs as *mut _); + CGColorSpace::from_ptr(cs) + } + } + + /// Returns the raw image bytes wrapped in `CFData`. Note, the returned `CFData` owns the + /// underlying buffer. + pub fn data(&self) -> CFData { + let data_provider = unsafe { + CGDataProviderRef::from_ptr(CGImageGetDataProvider(self.as_ptr())) + }; + data_provider.copy_data() + } + + /// Returns a cropped image. If the `rect` specifies a rectangle which lies outside of the + /// image bounds, the `None` is returned. + pub fn cropped(&self, rect: CGRect) -> Option { + let image_ptr = unsafe { CGImageCreateWithImageInRect(self.as_ptr(), rect) }; + if !image_ptr.is_null() { + Some(unsafe { CGImage::from_ptr(image_ptr) }) + } else { + None + } + } +} + +#[link(name = "CoreGraphics", kind = "framework")] +extern { + fn CGImageGetTypeID() -> CFTypeID; + fn CGImageGetWidth(image: ::sys::CGImageRef) -> size_t; + fn CGImageGetHeight(image: ::sys::CGImageRef) -> size_t; + fn CGImageGetBitsPerComponent(image: ::sys::CGImageRef) -> size_t; + fn CGImageGetBitsPerPixel(image: ::sys::CGImageRef) -> size_t; + fn CGImageGetBytesPerRow(image: ::sys::CGImageRef) -> size_t; + fn CGImageGetColorSpace(image: ::sys::CGImageRef) -> ::sys::CGColorSpaceRef; + fn CGImageGetDataProvider(image: ::sys::CGImageRef) -> ::sys::CGDataProviderRef; + fn CGImageRelease(image: ::sys::CGImageRef); + fn CGImageCreate(width: size_t, + height: size_t, + bitsPerComponent: size_t, + bitsPerPixel: size_t, + bytesPerRow: size_t, + space: ::sys::CGColorSpaceRef, + bitmapInfo: u32, + provider: ::sys::CGDataProviderRef, + decode: *const CGFloat, + shouldInterpolate: bool, + intent: u32) + -> ::sys::CGImageRef; + fn CGImageCreateWithImageInRect(image: ::sys::CGImageRef, rect: CGRect) -> ::sys::CGImageRef; + + //fn CGImageGetAlphaInfo(image: ::sys::CGImageRef) -> CGImageAlphaInfo; + //fn CGImageCreateCopyWithColorSpace(image: ::sys::CGImageRef, space: ::sys::CGColorSpaceRef) -> ::sys::CGImageRef +} diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/lib.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/lib.rs new file mode 100644 index 0000000..981883c --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/lib.rs @@ -0,0 +1,41 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate libc; + +#[macro_use] +extern crate core_foundation; + +#[macro_use] +#[cfg(target_os = "macos")] +extern crate bitflags; + +#[macro_use] +extern crate foreign_types; + +pub mod base; +pub mod color; +pub mod color_space; +pub mod context; +pub mod data_provider; +#[cfg(target_os = "macos")] +pub mod display; +#[cfg(target_os = "macos")] +pub mod event; +#[cfg(target_os = "macos")] +pub mod event_source; +pub mod font; +pub mod geometry; +#[cfg(target_os = "macos")] +pub mod window; +#[cfg(target_os = "macos")] +pub mod private; +pub mod image; +pub mod path; +mod sys; diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/path.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/path.rs new file mode 100644 index 0000000..dc1c804 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/path.rs @@ -0,0 +1,129 @@ +// Copyright 2017 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub use sys::CGPathRef as SysCGPathRef; + +use core_foundation::base::{CFRelease, CFRetain, CFTypeID}; +use foreign_types::ForeignType; +use geometry::{CGAffineTransform, CGPoint, CGRect}; +use libc::c_void; +use std::fmt::{self, Debug, Formatter}; +use std::marker::PhantomData; +use std::ops::Deref; +use std::ptr; +use std::slice; + +foreign_type! { + #[doc(hidden)] + type CType = ::sys::CGPath; + fn drop = |p| CFRelease(p as *mut _); + fn clone = |p| CFRetain(p as *const _) as *mut _; + pub struct CGPath; + pub struct CGPathRef; +} + +impl CGPath { + pub fn from_rect(rect: CGRect, transform: Option<&CGAffineTransform>) -> CGPath { + unsafe { + let transform = match transform { + None => ptr::null(), + Some(transform) => transform as *const CGAffineTransform, + }; + CGPath(CGPathCreateWithRect(rect, transform)) + } + } + + pub fn type_id() -> CFTypeID { + unsafe { + CGPathGetTypeID() + } + } + + pub fn apply<'a, F>(&'a self, mut closure: &'a F) where F: FnMut(CGPathElementRef<'a>) { + unsafe { + CGPathApply(self.as_ptr(), &mut closure as *mut _ as *mut c_void, do_apply::); + } + + unsafe extern "C" fn do_apply<'a, F>(info: *mut c_void, element: *const CGPathElement) + where F: FnMut(CGPathElementRef<'a>) { + let closure = info as *mut *mut F; + (**closure)(CGPathElementRef::new(element)) + } + } +} + +#[repr(i32)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum CGPathElementType { + MoveToPoint = 0, + AddLineToPoint = 1, + AddQuadCurveToPoint = 2, + AddCurveToPoint = 3, + CloseSubpath = 4, +} + +pub struct CGPathElementRef<'a> { + element: *const CGPathElement, + phantom: PhantomData<&'a CGPathElement>, +} + +impl<'a> CGPathElementRef<'a> { + fn new<'b>(element: *const CGPathElement) -> CGPathElementRef<'b> { + CGPathElementRef { + element: element, + phantom: PhantomData, + } + } +} + +impl<'a> Deref for CGPathElementRef<'a> { + type Target = CGPathElement; + fn deref(&self) -> &CGPathElement { + unsafe { + &*self.element + } + } +} + +#[repr(C)] +pub struct CGPathElement { + pub element_type: CGPathElementType, + points: *mut CGPoint, +} + +impl Debug for CGPathElement { + fn fmt(&self, formatter: &mut Formatter) -> Result<(), fmt::Error> { + write!(formatter, "{:?}: {:?}", self.element_type, self.points()) + } +} + +impl CGPathElement { + pub fn points(&self) -> &[CGPoint] { + unsafe { + match self.element_type { + CGPathElementType::CloseSubpath => &[], + CGPathElementType::MoveToPoint | CGPathElementType::AddLineToPoint => { + slice::from_raw_parts(self.points, 1) + } + CGPathElementType::AddQuadCurveToPoint => slice::from_raw_parts(self.points, 2), + CGPathElementType::AddCurveToPoint => slice::from_raw_parts(self.points, 3), + } + } + } +} + +type CGPathApplierFunction = unsafe extern "C" fn(info: *mut c_void, + element: *const CGPathElement); + +#[link(name = "CoreGraphics", kind = "framework")] +extern { + fn CGPathCreateWithRect(rect: CGRect, transform: *const CGAffineTransform) -> ::sys::CGPathRef; + fn CGPathApply(path: ::sys::CGPathRef, info: *mut c_void, function: CGPathApplierFunction); + fn CGPathGetTypeID() -> CFTypeID; +} diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/private.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/private.rs new file mode 100644 index 0000000..0bc193b --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/private.rs @@ -0,0 +1,116 @@ +// Copyright 2016 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Evil private APIs. +//! +//! These are liable to change at any time. Use with caution! + +use geometry::CGRect; +use libc::{c_int, c_uint}; +use std::ptr; + +pub struct CGSRegion { + region: ffi::CGSRegionRef, +} + +impl Drop for CGSRegion { + fn drop(&mut self) { + unsafe { + ffi::CGSRegionRelease(self.region) + } + } +} + +impl CGSRegion { + #[inline] + pub fn from_rect(rect: &CGRect) -> CGSRegion { + unsafe { + let mut region = ptr::null_mut(); + assert!(ffi::CGSNewRegionWithRect(rect, &mut region) == 0); + CGSRegion { + region: region, + } + } + } + + #[inline] + pub fn from_rects(rects: &[CGRect]) -> CGSRegion { + unsafe { + let mut region = ptr::null_mut(); + assert!(ffi::CGSNewRegionWithRectList(rects.as_ptr(), + rects.len() as c_uint, + &mut region) == 0); + CGSRegion { + region: region, + } + } + } +} + +/// This should always be memory-safe; the window server rejects any invalid surface IDs. +pub struct CGSSurface { + context_id: c_uint, + window_number: c_int, + surface_id: c_uint, +} + +impl CGSSurface { + #[inline] + pub fn from_ids(context_id: c_uint, window_number: c_int, surface_id: c_uint) -> CGSSurface { + CGSSurface { + context_id: context_id, + window_number: window_number, + surface_id: surface_id, + } + } + + #[inline] + pub fn id(&self) -> c_uint { + self.surface_id + } + + #[inline] + pub fn set_shape(&self, region: &CGSRegion) { + unsafe { + assert!(ffi::CGSSetSurfaceShape(self.context_id, + self.window_number, + self.surface_id, + region.region) == 0) + } + } +} + +mod ffi { + use geometry::CGRect; + use libc::{c_int, c_uint}; + + // This is an enum so that we can't easily make instances of this opaque type. + pub enum CGSRegionObject {} + + pub type CGError = OSStatus; + pub type CGSRegionRef = *mut CGSRegionObject; + pub type OSStatus = i32; + + #[link(name = "CoreGraphics", kind = "framework")] + extern { + pub fn CGSRegionRelease(region: CGSRegionRef); + pub fn CGSNewRegionWithRect(rect: *const CGRect, outRegion: *mut CGSRegionRef) -> CGError; + pub fn CGSNewRegionWithRectList(rects: *const CGRect, + rectCount: c_uint, + outRegion: *mut CGSRegionRef) + -> CGError; + + pub fn CGSSetSurfaceShape(contextID: c_uint, + windowNumber: c_int, + surfaceID: c_uint, + region: CGSRegionRef) + -> CGError; + } +} + diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/sys.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/sys.rs new file mode 100644 index 0000000..ccf0625 --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/sys.rs @@ -0,0 +1,39 @@ +use std::os::raw::c_void; + +pub enum CGImage {} +pub type CGImageRef = *mut CGImage; + +#[repr(C)] +pub struct __CGColor(c_void); + +pub type CGColorRef = *const __CGColor; + +pub enum CGColorSpace {} +pub type CGColorSpaceRef = *mut CGColorSpace; + +pub enum CGPath {} +pub type CGPathRef = *mut CGPath; + +pub enum CGDataProvider {} +pub type CGDataProviderRef = *mut CGDataProvider; + +pub enum CGFont {} +pub type CGFontRef = *mut CGFont; + +pub enum CGContext {} +pub type CGContextRef = *mut CGContext; + +#[cfg(target_os = "macos")] +mod macos { + pub enum CGEvent {} + pub type CGEventRef = *mut CGEvent; + + pub enum CGEventSource {} + pub type CGEventSourceRef = *mut CGEventSource; + + pub enum CGDisplayMode {} + pub type CGDisplayModeRef = *mut CGDisplayMode; +} + +#[cfg(target_os = "macos")] +pub use self::macos::*; diff --git a/third_party/cargo/vendor/core-graphics-0.17.3/src/window.rs b/third_party/cargo/vendor/core-graphics-0.17.3/src/window.rs new file mode 100644 index 0000000..aa7293f --- /dev/null +++ b/third_party/cargo/vendor/core-graphics-0.17.3/src/window.rs @@ -0,0 +1,149 @@ +// Copyright 2018 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(non_upper_case_globals)] + +use core_foundation::array::{CFArray, CFArrayRef}; +use core_foundation::base::{CFType, TCFType}; +use core_foundation::dictionary::CFDictionary; +use core_foundation::string::{CFString, CFStringRef}; +use foreign_types::ForeignType; + +use geometry::CGRect; +use image::CGImage; +use sys; + +pub type CGWindowID = u32; + +pub type CGWindowSharingType = u32; +pub const kCGWindowSharingNone: CGWindowSharingType = 0; +pub const kCGWindowSharingReadOnly: CGWindowSharingType = 1; +pub const kCGWindowSharingReadWrite: CGWindowSharingType = 1; + +pub type CGWindowBackingType = u32; +pub const kCGWindowBackingStoreRetained: CGWindowBackingType = 0; +pub const kCGWindowBackingStoreNonretained: CGWindowBackingType = 1; +pub const kCGWindowBackingStoreBuffered: CGWindowBackingType = 2; + +pub type CGWindowListOption = u32; +pub const kCGWindowListOptionAll: CGWindowListOption = 1 << 0; +pub const kCGWindowListOptionOnScreenOnly: CGWindowListOption = 1 << 1; +pub const kCGWindowListOptionOnScreenAboveWindow: CGWindowListOption = 1 << 2; +pub const kCGWindowListOptionOnScreenBelowWindow: CGWindowListOption = 1 << 3; +pub const kCGWindowListOptionIncludingWindow: CGWindowListOption = 1 << 4; +pub const kCGWindowListOptionExcludeDesktopElements: CGWindowListOption = 1 << 5; + +pub type CGWindowImageOption = u32; +pub const kCGWindowImageDefault: CGWindowImageOption = 0; +pub const kCGWindowImageBoundsIgnoreFraming: CGWindowImageOption = 1 << 0; +pub const kCGWindowImageShouldBeOpaque: CGWindowImageOption = 1 << 1; +pub const kCGWindowImageOnlyShadows: CGWindowImageOption = 1 << 2; +pub const kCGWindowImageBestResolution: CGWindowImageOption = 1 << 3; +pub const kCGWindowImageNominalResolution: CGWindowImageOption = 1 << 4; + +pub const kCGNullWindowID: CGWindowID = 0; + +pub fn copy_window_info(option: CGWindowListOption, relative_to_window: CGWindowID) + -> Option { + unsafe { + let array = CGWindowListCopyWindowInfo(option, relative_to_window); + if array.is_null() { + None + } else { + Some(TCFType::wrap_under_create_rule(array)) + } + } +} + +pub fn create_window_list(option: CGWindowListOption, relative_to_window: CGWindowID) + -> Option> { + unsafe { + let array = CGWindowListCreate(option, relative_to_window); + if array.is_null() { + None + } else { + Some(TCFType::wrap_under_create_rule(array)) + } + } +} + +pub fn create_description_from_array(window_array: CFArray) -> + Option>> { + unsafe { + let array = CGWindowListCreateDescriptionFromArray(window_array.as_concrete_TypeRef()); + if array.is_null() { + None + } else { + Some(TCFType::wrap_under_create_rule(array)) + } + } +} + +pub fn create_image(screen_bounds: CGRect, + list_option: CGWindowListOption, + window_id: CGWindowID, + image_option: CGWindowImageOption) + -> Option { + unsafe { + let image = CGWindowListCreateImage(screen_bounds, list_option, window_id, image_option); + if image.is_null() { + None + } else { + Some(CGImage::from_ptr(image)) + } + } +} + +pub fn create_image_from_array(screen_bounds: CGRect, + window_array: CFArray, + image_option: CGWindowImageOption) + -> Option { + unsafe { + let image = CGWindowListCreateImageFromArray(screen_bounds, + window_array.as_concrete_TypeRef(), + image_option); + if image.is_null() { + None + } else { + Some(CGImage::from_ptr(image)) + } + } +} + +#[link(name = "CoreGraphics", kind = "framework")] +extern { + pub static kCGWindowNumber: CFStringRef; + pub static kCGWindowStoreType: CFStringRef; + pub static kCGWindowLayer: CFStringRef; + pub static kCGWindowBounds: CFStringRef; + pub static kCGWindowSharingState: CFStringRef; + pub static kCGWindowAlpha: CFStringRef; + pub static kCGWindowOwnerPID: CFStringRef; + pub static kCGWindowMemoryUsage: CFStringRef; + pub static kCGWindowWorkspace: CFStringRef; + pub static kCGWindowOwnerName: CFStringRef; + pub static kCGWindowName: CFStringRef; + pub static kCGWindowIsOnscreen: CFStringRef; + pub static kCGWindowBackingLocationVideoMemory: CFStringRef; + + pub fn CGWindowListCopyWindowInfo(option: CGWindowListOption, relativeToWindow: CGWindowID) + -> CFArrayRef; + pub fn CGWindowListCreate(option: CGWindowListOption, relativeToWindow: CGWindowID) + -> CFArrayRef; + pub fn CGWindowListCreateDescriptionFromArray(windowArray: CFArrayRef) -> CFArrayRef; + pub fn CGWindowListCreateImage(screenBounds: CGRect, + listOption: CGWindowListOption, + windowID: CGWindowID, + imageOption: CGWindowImageOption) + -> *mut sys::CGImage; + pub fn CGWindowListCreateImageFromArray(screenBounds: CGRect, + windowArray: CFArrayRef, + imageOption: CGWindowImageOption) + -> *mut sys::CGImage; +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/.cargo-checksum.json b/third_party/cargo/vendor/crossbeam-0.5.0/.cargo-checksum.json new file mode 100644 index 0000000..0bb2060 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"036c480cc86b109f9df6aaf23a1fa7322ea27cd1119ad316a1f732ea11fe5c07","Cargo.toml":"6581ed402f6ae3b68043f72dbab0921a01ea6ac9e017778a70e5c3d4d8379fce","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"7b63ecd5f1902af1b63729947373683c32745c16a10e8e6292e2e2dcd7e90ae0","README.md":"2f985ee8cd18fece6bc6e8c24da3b49f7e77f37f5721bff1f378c3e2a72b308e","src/arc_cell.rs":"e3b159a4dda2df52f07c19e5622a8e09bb11a7b98df9b78c6dccd8d1c11d59b8","src/atomic_cell.rs":"501db20a0710025305c0d2ad4a6f969a3fb1c5443bf70495d36f0c8b50d9bf29","src/lib.rs":"98ccb355d6a31cf008a5f13310442dc5c49c2c0bb5d161c5daf29ec7bc4c95c1","src/ms_queue.rs":"2f540462df32968e07054aea4cb6e6378085c2f01641028e9b771c9cc84da96f","src/seg_queue.rs":"3c8831aabc4c7102bfb11f070c533fafc9f72eea909398eb26069b8b3d9da78e","src/sharded_lock.rs":"dd0eaf1b2cedae088702707ff3fde528fb74b85663e78b1ccb2dbd7a22d143b1","src/treiber_stack.rs":"44ae78ae52d75371b7159456773a58e191534b6394e644ecc031efabcaa118b9","src/wait_group.rs":"8ad847036fb440b7eab2eec8f9f4b966c337dae0c930518c2108f09691365e2f","tests/atomic_cell.rs":"1685dc1479c02f2986edf5e970c18f0cc32b2a17c85ffa8bb76a38199db61ddd","tests/subcrates.rs":"b67663afaedd59cd1f8b50b30cf727f073ecadbddc3d5ebc1304ef9f72c8827a","tests/wait_group.rs":"2d701e556f30d14b1a0c7878e1dcc2eba0277b50eb7199c61b921340f87678fe"},"package":"d1c92ff2d7a202d592f5a412d75cf421495c913817781c1cb383bf12a77e185f"} \ No newline at end of file diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/BUILD b/third_party/cargo/vendor/crossbeam-0.5.0/BUILD new file mode 100644 index 0000000..406126f --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/BUILD @@ -0,0 +1,57 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "atomic_cell" with type "test" omitted + +rust_library( + name = "crossbeam", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/cfg-if-0.1.10:cfg_if", + "//third_party/cargo/vendor/crossbeam-channel-0.3.9:crossbeam_channel", + "//third_party/cargo/vendor/crossbeam-deque-0.6.3:crossbeam_deque", + "//third_party/cargo/vendor/crossbeam-epoch-0.6.1:crossbeam_epoch", + "//third_party/cargo/vendor/crossbeam-utils-0.6.6:crossbeam_utils", + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + "//third_party/cargo/vendor/num_cpus-1.12.0:num_cpus", + "//third_party/cargo/vendor/parking_lot-0.6.4:parking_lot", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.5.0", + crate_features = [ + "crossbeam-epoch", + "crossbeam-utils", + "default", + "std", + ], +) + +# Unsupported target "subcrates" with type "test" omitted +# Unsupported target "wait_group" with type "test" omitted diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/CHANGELOG.md b/third_party/cargo/vendor/crossbeam-0.5.0/CHANGELOG.md new file mode 100644 index 0000000..7019fc0 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/CHANGELOG.md @@ -0,0 +1,48 @@ +# Version 0.5.0 + +- Update `crossbeam-channel` to 0.3. +- Update `crossbeam-utils` to 0.6. +- Add `AtomicCell`, `SharedLock`, and `WaitGroup`. + +# Version 0.4.1 + +- Fix a double-free bug in `MsQueue` and `SegQueue`. + +# Version 0.4 + +- Switch to the new implementation of epoch-based reclamation in + [`crossbeam-epoch`](https://github.com/crossbeam-rs/crossbeam-epoch), fixing numerous bugs in the + old implementation. Its API is changed in a backward-incompatible way. +- Switch to the new implementation of `CachePadded` and scoped thread in + [`crossbeam-utils`](https://github.com/crossbeam-rs/crossbeam-utils). The scoped thread API is + changed in a backward-incompatible way. +- Switch to the new implementation of Chase-Lev deque in + [`crossbeam-deque`](https://github.com/crossbeam-rs/crossbeam-deque). Its API is changed in a + backward-incompatible way. +- Export channel implemented in + [`crossbeam-channel`](https://github.com/crossbeam-rs/crossbeam-channel). +- Remove `AtomicOption`. +- Implement `Default` and `From` traits. + +# Version 0.3 + +- Introduced `ScopedThreadBuilder` with the ability to name threads and set stack size +- `Worker` methods in the Chase-Lev deque don't require mutable access anymore +- Fixed a bug when unblocking `pop()` in `MsQueue` +- Implemented `Drop` for `MsQueue`, `SegQueue`, and `TreiberStack` +- Implemented `Default` for `TreiberStack` +- Added `is_empty` to `SegQueue` +- Renamed `mem::epoch` to `epoch` +- Other bug fixes + +# Version 0.2 + +- Changed existing non-blocking `pop` methods to `try_pop` +- Added blocking `pop` support to Michael-Scott queue +- Added Chase-Lev work-stealing deque + +# Version 0.1 + +- Added [epoch-based memory management](http://aturon.github.io/blog/2015/08/27/epoch/) +- Added Michael-Scott queue +- Added Segmented array queue diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/Cargo.toml b/third_party/cargo/vendor/crossbeam-0.5.0/Cargo.toml new file mode 100644 index 0000000..b379854 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/Cargo.toml @@ -0,0 +1,57 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "crossbeam" +version = "0.5.0" +authors = ["The Crossbeam Project Developers"] +exclude = ["/ci/*", "/.travis.yml", "/bors.toml"] +description = "Support for concurrent programming: memory management, utilities, non-blocking data structures" +homepage = "https://github.com/crossbeam-rs/crossbeam" +documentation = "https://docs.rs/crossbeam" +readme = "README.md" +keywords = ["atomic", "garbage", "non-blocking", "lock-free", "rcu"] +categories = ["concurrency", "memory-management", "data-structures"] +license = "MIT/Apache-2.0" +repository = "https://github.com/crossbeam-rs/crossbeam" +[dependencies.cfg-if] +version = "0.1" + +[dependencies.crossbeam-channel] +version = "0.3" + +[dependencies.crossbeam-deque] +version = "0.6" + +[dependencies.crossbeam-epoch] +version = "0.6" + +[dependencies.crossbeam-utils] +version = "0.6" + +[dependencies.lazy_static] +version = "1.1.0" + +[dependencies.num_cpus] +version = "1.8.0" + +[dependencies.parking_lot] +version = "0.6.4" +[dev-dependencies.rand] +version = "0.5" + +[features] +default = ["std"] +nightly = ["crossbeam-epoch/nightly", "crossbeam-utils/nightly"] +std = ["crossbeam-epoch/std", "crossbeam-utils/std"] +[badges.travis-ci] +repository = "crossbeam-rs/crossbeam" diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/LICENSE-APACHE b/third_party/cargo/vendor/crossbeam-0.5.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/LICENSE-MIT b/third_party/cargo/vendor/crossbeam-0.5.0/LICENSE-MIT new file mode 100644 index 0000000..e69282e --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2015 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/README.md b/third_party/cargo/vendor/crossbeam-0.5.0/README.md new file mode 100644 index 0000000..ae9c9f8 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/README.md @@ -0,0 +1,69 @@ +# Crossbeam: support for concurrent programming + +[![Build Status](https://travis-ci.org/crossbeam-rs/crossbeam.svg?branch=master)]( +https://travis-ci.org/crossbeam-rs/crossbeam) +[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)]( +https://github.com/crossbeam-rs/crossbeam) +[![Cargo](https://img.shields.io/crates/v/crossbeam.svg)]( +https://crates.io/crates/crossbeam) +[![Documentation](https://docs.rs/crossbeam/badge.svg)]( +https://docs.rs/crossbeam) + +Crossbeam supports concurrent programming, especially focusing on memory +management, synchronization, and non-blocking data structures. + +Crossbeam consists of several submodules: + + - `atomic` for **enhancing `std::sync` API**. `AtomicConsume` provides + C/C++11-style "consume" atomic operations (re-exported from + [`crossbeam-utils`]). `ArcCell` provides atomic storage and retrieval of + `Arc`. + + - `utils` and `thread` for **utilities**, re-exported from [`crossbeam-utils`]. + The "scoped" thread API in `thread` makes it possible to spawn threads that + share stack data with their parents. The `utils::CachePadded` struct inserts + padding to align data with the size of a cacheline. This crate also seeks to + expand the standard library's few synchronization primitives (locks, + barriers, etc) to include advanced/niche primitives, as well as userspace + alternatives. + + - `epoch` for **memory management**, re-exported from [`crossbeam-epoch`]. + Because non-blocking data structures avoid global synchronization, it is not + easy to tell when internal data can be safely freed. The crate provides + generic, easy to use, and high-performance APIs for managing memory in these + cases. We plan to support other memory management schemes, e.g. hazard + pointers (HP) and quiescent state-based reclamation (QSBR). + + - **Concurrent data structures** which are non-blocking and much superior to + wrapping sequential ones with a `Mutex`. Crossbeam currently provides + channels (re-exported from [`crossbeam-channel`]), deques + (re-exported from [`crossbeam-deque`]), queues, and stacks. Ultimately the + goal is to also include bags, sets and maps. + +# Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +crossbeam = "0.5" +``` + +Next, add this to your crate: + +```rust +extern crate crossbeam; +``` + +The minimum required Rust version is 1.26. + +[`crossbeam-epoch`]: https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-epoch +[`crossbeam-utils`]: https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-utils +[`crossbeam-channel`]: https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel +[`crossbeam-deque`]: https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-deque + +## License + +Licensed under the terms of MIT license and the Apache License (Version 2.0). + +See [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE) for details. diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/src/arc_cell.rs b/third_party/cargo/vendor/crossbeam-0.5.0/src/arc_cell.rs new file mode 100644 index 0000000..ddec0fa --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/src/arc_cell.rs @@ -0,0 +1,109 @@ +use alloc::sync::Arc; +use core::marker::PhantomData; +use core::mem; +use core::sync::atomic::{AtomicUsize, Ordering}; + +/// A type providing atomic storage and retrieval of an `Arc`. +#[derive(Debug)] +pub struct ArcCell(AtomicUsize, PhantomData>); + +impl Drop for ArcCell { + fn drop(&mut self) { + self.take(); + } +} + +impl ArcCell { + /// Creates a new `ArcCell`. + pub fn new(t: Arc) -> ArcCell { + ArcCell(AtomicUsize::new(unsafe { mem::transmute(t) }), PhantomData) + } + + fn take(&self) -> Arc { + loop { + match self.0.swap(0, Ordering::Acquire) { + 0 => {} + n => return unsafe { mem::transmute(n) }, + } + } + } + + fn put(&self, t: Arc) { + debug_assert_eq!(self.0.load(Ordering::SeqCst), 0); + self.0 + .store(unsafe { mem::transmute(t) }, Ordering::Release); + } + + /// Stores a new value in the `ArcCell`, returning the previous + /// value. + pub fn set(&self, t: Arc) -> Arc { + let old = self.take(); + self.put(t); + old + } + + /// Returns a copy of the value stored by the `ArcCell`. + pub fn get(&self) -> Arc { + let t = self.take(); + // NB: correctness here depends on Arc's clone impl not panicking + let out = t.clone(); + self.put(t); + out + } +} + +impl Default for ArcCell { + fn default() -> Self { + ArcCell::new(Arc::default()) + } +} + +impl From> for ArcCell { + fn from(value: Arc) -> Self { + ArcCell::new(value) + } +} + +impl From for ArcCell { + fn from(value: T) -> Self { + ArcCell::new(Arc::new(value)) + } +} + +#[cfg(test)] +mod test { + use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; + use std::sync::Arc; + + use super::*; + + #[test] + fn basic() { + let r = ArcCell::new(Arc::new(0)); + assert_eq!(*r.get(), 0); + assert_eq!(*r.set(Arc::new(1)), 0); + assert_eq!(*r.get(), 1); + } + + #[test] + fn drop_runs() { + static DROPS: AtomicUsize = ATOMIC_USIZE_INIT; + + struct Foo; + + impl Drop for Foo { + fn drop(&mut self) { + DROPS.fetch_add(1, Ordering::SeqCst); + } + } + + let r = ArcCell::new(Arc::new(Foo)); + let _f = r.get(); + r.get(); + r.set(Arc::new(Foo)); + drop(_f); + assert_eq!(DROPS.load(Ordering::SeqCst), 1); + drop(r); + assert_eq!(DROPS.load(Ordering::SeqCst), 2); + } +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/src/atomic_cell.rs b/third_party/cargo/vendor/crossbeam-0.5.0/src/atomic_cell.rs new file mode 100644 index 0000000..a826130 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/src/atomic_cell.rs @@ -0,0 +1,904 @@ +use core::cell::UnsafeCell; +use core::fmt; +use core::mem; +use core::ptr; +use core::slice; +use core::sync::atomic::{self, AtomicBool, AtomicUsize, Ordering}; + +/// A thread-safe mutable memory location. +/// +/// This type is equivalent to [`Cell`], except it can also be shared among multiple threads. +/// +/// Operations on `AtomicCell`s use atomic instructions whenever possible, and synchronize using +/// global locks otherwise. You can call [`AtomicCell::::is_lock_free()`] to check whether +/// atomic instructions or locks will be used. +/// +/// [`Cell`]: https://doc.rust-lang.org/std/cell/struct.Cell.html +/// [`AtomicCell::::is_lock_free()`]: struct.AtomicCell.html#method.is_lock_free +pub struct AtomicCell { + /// The inner value. + /// + /// If this value can be transmuted into a primitive atomic type, it will be treated as such. + /// Otherwise, all potentially concurrent operations on this data will be protected by a global + /// lock. + value: UnsafeCell, +} + +unsafe impl Send for AtomicCell {} +unsafe impl Sync for AtomicCell {} + +impl AtomicCell { + /// Creates a new atomic cell initialized with `val`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(7); + /// ``` + pub fn new(val: T) -> AtomicCell { + AtomicCell { + value: UnsafeCell::new(val), + } + } + + /// Returns a mutable reference to the inner value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let mut a = AtomicCell::new(7); + /// *a.get_mut() += 1; + /// + /// assert_eq!(a.load(), 8); + /// ``` + pub fn get_mut(&mut self) -> &mut T { + unsafe { &mut *self.value.get() } + } + + /// Unwraps the atomic cell and returns its inner value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let mut a = AtomicCell::new(7); + /// let v = a.into_inner(); + /// + /// assert_eq!(v, 7); + /// ``` + pub fn into_inner(self) -> T { + self.value.into_inner() + } + + /// Returns `true` if operations on values of this type are lock-free. + /// + /// If the compiler or the platform doesn't support the necessary atomic instructions, + /// `AtomicCell` will use global locks for every potentially concurrent atomic operation. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// // This type is internally represented as `AtomicUsize` so we can just use atomic + /// // operations provided by it. + /// assert_eq!(AtomicCell::::is_lock_free(), true); + /// + /// // A wrapper struct around `isize`. + /// struct Foo { + /// bar: isize, + /// } + /// // `AtomicCell` will be internally represented as `AtomicIsize`. + /// assert_eq!(AtomicCell::::is_lock_free(), true); + /// + /// // Operations on zero-sized types are always lock-free. + /// assert_eq!(AtomicCell::<()>::is_lock_free(), true); + /// + /// // Very large types cannot be represented as any of the standard atomic types, so atomic + /// // operations on them will have to use global locks for synchronization. + /// assert_eq!(AtomicCell::<[u8; 1000]>::is_lock_free(), false); + /// ``` + pub fn is_lock_free() -> bool { + atomic_is_lock_free::() + } + + /// Stores `val` into the atomic cell. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(7); + /// + /// assert_eq!(a.load(), 7); + /// a.store(8); + /// assert_eq!(a.load(), 8); + /// ``` + pub fn store(&self, val: T) { + if mem::needs_drop::() { + drop(self.swap(val)); + } else { + unsafe { + atomic_store(self.value.get(), val); + } + } + } + + /// Stores `val` into the atomic cell and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(7); + /// + /// assert_eq!(a.load(), 7); + /// assert_eq!(a.swap(8), 7); + /// assert_eq!(a.load(), 8); + /// ``` + pub fn swap(&self, val: T) -> T { + unsafe { atomic_swap(self.value.get(), val) } + } +} + +impl AtomicCell { + /// Loads a value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(7); + /// + /// assert_eq!(a.load(), 7); + /// ``` + pub fn load(&self) -> T { + unsafe { atomic_load(self.value.get()) } + } +} + +impl AtomicCell { + /// If the current value equals `current`, stores `new` into the atomic cell. + /// + /// The return value is always the previous value. If it is equal to `current`, then the value + /// was updated. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(1); + /// + /// assert_eq!(a.compare_exchange(2, 3), Err(1)); + /// assert_eq!(a.load(), 1); + /// + /// assert_eq!(a.compare_exchange(1, 2), Ok(1)); + /// assert_eq!(a.load(), 2); + /// ``` + pub fn compare_and_swap(&self, current: T, new: T) -> T { + match self.compare_exchange(current, new) { + Ok(v) => v, + Err(v) => v, + } + } + + /// If the current value equals `current`, stores `new` into the atomic cell. + /// + /// The return value is a result indicating whether the new value was written and containing + /// the previous value. On success this value is guaranteed to be equal to `current`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(1); + /// + /// assert_eq!(a.compare_exchange(2, 3), Err(1)); + /// assert_eq!(a.load(), 1); + /// + /// assert_eq!(a.compare_exchange(1, 2), Ok(1)); + /// assert_eq!(a.load(), 2); + /// ``` + pub fn compare_exchange(&self, mut current: T, new: T) -> Result { + loop { + match unsafe { atomic_compare_exchange_weak(self.value.get(), current, new) } { + Ok(_) => return Ok(current), + Err(previous) => { + if previous != current { + return Err(previous); + } + + // The compare-exchange operation has failed and didn't store `new`. The + // failure is either spurious, or `previous` was semantically equal to + // `current` but not byte-equal. Let's retry with `previous` as the new + // `current`. + current = previous; + } + } + } + } +} + +macro_rules! impl_arithmetic { + ($t:ty, $example:tt) => { + impl AtomicCell<$t> { + /// Increments the current value by `val` and returns the previous value. + /// + /// The addition wraps on overflow. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_add(3), 7); + /// assert_eq!(a.load(), 10); + /// ``` + #[inline] + pub fn fetch_add(&self, val: $t) -> $t { + if can_transmute::<$t, atomic::AtomicUsize>() { + let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) }; + a.fetch_add(val as usize, Ordering::SeqCst) as $t + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = value.wrapping_add(val); + old + } + } + + /// Decrements the current value by `val` and returns the previous value. + /// + /// The subtraction wraps on overflow. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_sub(3), 7); + /// assert_eq!(a.load(), 4); + /// ``` + #[inline] + pub fn fetch_sub(&self, val: $t) -> $t { + if can_transmute::<$t, atomic::AtomicUsize>() { + let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) }; + a.fetch_sub(val as usize, Ordering::SeqCst) as $t + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = value.wrapping_sub(val); + old + } + } + + /// Applies bitwise "and" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_and(3), 7); + /// assert_eq!(a.load(), 3); + /// ``` + #[inline] + pub fn fetch_and(&self, val: $t) -> $t { + if can_transmute::<$t, atomic::AtomicUsize>() { + let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) }; + a.fetch_and(val as usize, Ordering::SeqCst) as $t + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value &= val; + old + } + } + + /// Applies bitwise "or" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_or(16), 7); + /// assert_eq!(a.load(), 23); + /// ``` + #[inline] + pub fn fetch_or(&self, val: $t) -> $t { + if can_transmute::<$t, atomic::AtomicUsize>() { + let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) }; + a.fetch_or(val as usize, Ordering::SeqCst) as $t + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value |= val; + old + } + } + + /// Applies bitwise "xor" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_xor(2), 7); + /// assert_eq!(a.load(), 5); + /// ``` + #[inline] + pub fn fetch_xor(&self, val: $t) -> $t { + if can_transmute::<$t, atomic::AtomicUsize>() { + let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) }; + a.fetch_xor(val as usize, Ordering::SeqCst) as $t + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value ^= val; + old + } + } + } + }; + ($t:ty, $atomic:ty, $example:tt) => { + impl AtomicCell<$t> { + /// Increments the current value by `val` and returns the previous value. + /// + /// The addition wraps on overflow. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_add(3), 7); + /// assert_eq!(a.load(), 10); + /// ``` + #[inline] + pub fn fetch_add(&self, val: $t) -> $t { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_add(val, Ordering::SeqCst) + } + + /// Decrements the current value by `val` and returns the previous value. + /// + /// The subtraction wraps on overflow. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_sub(3), 7); + /// assert_eq!(a.load(), 4); + /// ``` + #[inline] + pub fn fetch_sub(&self, val: $t) -> $t { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_sub(val, Ordering::SeqCst) + } + + /// Applies bitwise "and" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_and(3), 7); + /// assert_eq!(a.load(), 3); + /// ``` + #[inline] + pub fn fetch_and(&self, val: $t) -> $t { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_and(val, Ordering::SeqCst) + } + + /// Applies bitwise "or" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_or(16), 7); + /// assert_eq!(a.load(), 23); + /// ``` + #[inline] + pub fn fetch_or(&self, val: $t) -> $t { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_or(val, Ordering::SeqCst) + } + + /// Applies bitwise "xor" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_xor(2), 7); + /// assert_eq!(a.load(), 5); + /// ``` + #[inline] + pub fn fetch_xor(&self, val: $t) -> $t { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_xor(val, Ordering::SeqCst) + } + } + }; +} + +cfg_if! { + if #[cfg(feature = "nightly")] { + impl_arithmetic!(u8, atomic::AtomicU8, "let a = AtomicCell::new(7u8);"); + impl_arithmetic!(i8, atomic::AtomicI8, "let a = AtomicCell::new(7i8);"); + impl_arithmetic!(u16, atomic::AtomicU16, "let a = AtomicCell::new(7u16);"); + impl_arithmetic!(i16, atomic::AtomicI16, "let a = AtomicCell::new(7i16);"); + impl_arithmetic!(u32, atomic::AtomicU32, "let a = AtomicCell::new(7u32);"); + impl_arithmetic!(i32, atomic::AtomicI32, "let a = AtomicCell::new(7i32);"); + impl_arithmetic!(u64, atomic::AtomicU64, "let a = AtomicCell::new(7u64);"); + impl_arithmetic!(i64, atomic::AtomicI64, "let a = AtomicCell::new(7i64);"); + } else { + impl_arithmetic!(u8, "let a = AtomicCell::new(7u8);"); + impl_arithmetic!(i8, "let a = AtomicCell::new(7i8);"); + impl_arithmetic!(u16, "let a = AtomicCell::new(7u16);"); + impl_arithmetic!(i16, "let a = AtomicCell::new(7i16);"); + impl_arithmetic!(u32, "let a = AtomicCell::new(7u32);"); + impl_arithmetic!(i32, "let a = AtomicCell::new(7i32);"); + impl_arithmetic!(u64, "let a = AtomicCell::new(7u64);"); + impl_arithmetic!(i64, "let a = AtomicCell::new(7i64);"); + } +} + +impl_arithmetic!( + usize, + atomic::AtomicUsize, + "let a = AtomicCell::new(7usize);" +); +impl_arithmetic!( + isize, + atomic::AtomicIsize, + "let a = AtomicCell::new(7isize);" +); + +impl AtomicCell { + /// Applies logical "and" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(true); + /// + /// assert_eq!(a.fetch_and(true), true); + /// assert_eq!(a.load(), true); + /// + /// assert_eq!(a.fetch_and(false), true); + /// assert_eq!(a.load(), false); + /// ``` + #[inline] + pub fn fetch_and(&self, val: bool) -> bool { + let a = unsafe { &*(self.value.get() as *const AtomicBool) }; + a.fetch_and(val, Ordering::SeqCst) + } + + /// Applies logical "or" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(false); + /// + /// assert_eq!(a.fetch_or(false), false); + /// assert_eq!(a.load(), false); + /// + /// assert_eq!(a.fetch_or(true), false); + /// assert_eq!(a.load(), true); + /// ``` + #[inline] + pub fn fetch_or(&self, val: bool) -> bool { + let a = unsafe { &*(self.value.get() as *const AtomicBool) }; + a.fetch_or(val, Ordering::SeqCst) + } + + /// Applies logical "xor" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(true); + /// + /// assert_eq!(a.fetch_xor(false), true); + /// assert_eq!(a.load(), true); + /// + /// assert_eq!(a.fetch_xor(true), true); + /// assert_eq!(a.load(), false); + /// ``` + #[inline] + pub fn fetch_xor(&self, val: bool) -> bool { + let a = unsafe { &*(self.value.get() as *const AtomicBool) }; + a.fetch_xor(val, Ordering::SeqCst) + } +} + +impl Default for AtomicCell { + fn default() -> AtomicCell { + AtomicCell::new(T::default()) + } +} + +impl fmt::Debug for AtomicCell { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("AtomicCell") + .field("value", &self.load()) + .finish() + } +} + +/// Returns `true` if the two values are equal byte-for-byte. +fn byte_eq(a: &T, b: &T) -> bool { + unsafe { + let a = slice::from_raw_parts(a as *const _ as *const u8, mem::size_of::()); + let b = slice::from_raw_parts(b as *const _ as *const u8, mem::size_of::()); + a == b + } +} + +/// Returns `true` if values of type `A` can be transmuted into values of type `B`. +fn can_transmute() -> bool { + // Sizes must be equal, but alignment of `A` must be greater or equal than that of `B`. + mem::size_of::() == mem::size_of::() && mem::align_of::() >= mem::align_of::() +} + +/// A simple stamped lock. +struct Lock { + /// The current state of the lock. + /// + /// All bits except the least significant one hold the current stamp. When locked, the state + /// equals 1 and doesn't contain a valid stamp. + state: AtomicUsize, +} + +impl Lock { + /// If not locked, returns the current stamp. + /// + /// This method should be called before optimistic reads. + #[inline] + fn optimistic_read(&self) -> Option { + let state = self.state.load(Ordering::Acquire); + if state == 1 { + None + } else { + Some(state) + } + } + + /// Returns `true` if the current stamp is equal to `stamp`. + /// + /// This method should be called after optimistic reads to check whether they are valid. The + /// argument `stamp` should correspond to the one returned by method `optimistic_read`. + #[inline] + fn validate_read(&self, stamp: usize) -> bool { + atomic::fence(Ordering::Acquire); + self.state.load(Ordering::Relaxed) == stamp + } + + /// Grabs the lock for writing. + #[inline] + fn write(&'static self) -> WriteGuard { + let mut step = 0usize; + + loop { + let previous = self.state.swap(1, Ordering::Acquire); + + if previous != 1 { + atomic::fence(Ordering::Release); + + return WriteGuard { + lock: self, + state: previous, + }; + } + + if step < 10 { + atomic::spin_loop_hint(); + } else { + #[cfg(not(feature = "std"))] + atomic::spin_loop_hint(); + + #[cfg(feature = "std")] + ::std::thread::yield_now(); + } + + step = step.wrapping_add(1); + } + } +} + +/// A RAII guard that releases the lock and increments the stamp when dropped. +struct WriteGuard { + /// The parent lock. + lock: &'static Lock, + + /// The stamp before locking. + state: usize, +} + +impl WriteGuard { + /// Releases the lock without incrementing the stamp. + #[inline] + fn abort(self) { + self.lock.state.store(self.state, Ordering::Release); + } +} + +impl Drop for WriteGuard { + #[inline] + fn drop(&mut self) { + // Release the lock and increment the stamp. + self.lock + .state + .store(self.state.wrapping_add(2), Ordering::Release); + } +} + +/// Returns a reference to the global lock associated with the `AtomicCell` at address `addr`. +/// +/// This function is used to protect atomic data which doesn't fit into any of the primitive atomic +/// types in `std::sync::atomic`. Operations on such atomics must therefore use a global lock. +/// +/// However, there is not only one global lock but an array of many locks, and one of them is +/// picked based on the given address. Having many locks reduces contention and improves +/// scalability. +#[inline] +#[must_use] +fn lock(addr: usize) -> &'static Lock { + // The number of locks is prime. + const LEN: usize = 97; + + const L: Lock = Lock { + state: AtomicUsize::new(0), + }; + static LOCKS: [Lock; LEN] = [ + L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, + L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, + L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, + L, L, L, L, L, L, L, + ]; + + // If the modulus is a constant number, the compiler will use crazy math to transform this into + // a sequence of cheap arithmetic operations rather than using the slow modulo instruction. + &LOCKS[addr % LEN] +} + +/// An atomic `()`. +/// +/// All operations are noops. +struct AtomicUnit; + +impl AtomicUnit { + #[inline] + fn load(&self, _order: Ordering) {} + + #[inline] + fn store(&self, _val: (), _order: Ordering) {} + + #[inline] + fn swap(&self, _val: (), _order: Ordering) {} + + #[inline] + fn compare_exchange_weak( + &self, + _current: (), + _new: (), + _success: Ordering, + _failure: Ordering, + ) -> Result<(), ()> { + Ok(()) + } +} + +macro_rules! atomic { + // If values of type `$t` can be transmuted into values of the primitive atomic type `$atomic`, + // declares variable `$a` of type `$atomic` and executes `$atomic_op`, breaking out of the loop. + (@check, $t:ty, $atomic:ty, $a:ident, $atomic_op:expr) => { + if can_transmute::<$t, $atomic>() { + let $a: &$atomic; + break $atomic_op; + } + }; + + // If values of type `$t` can be transmuted into values of a primitive atomic type, declares + // variable `$a` of that type and executes `$atomic_op`. Otherwise, just executes + // `$fallback_op`. + ($t:ty, $a:ident, $atomic_op:expr, $fallback_op:expr) => { + loop { + atomic!(@check, $t, AtomicUnit, $a, $atomic_op); + atomic!(@check, $t, atomic::AtomicUsize, $a, $atomic_op); + + #[cfg(feature = "nightly")] + { + #[cfg(target_has_atomic = "8")] + atomic!(@check, $t, atomic::AtomicU8, $a, $atomic_op); + #[cfg(target_has_atomic = "16")] + atomic!(@check, $t, atomic::AtomicU16, $a, $atomic_op); + #[cfg(target_has_atomic = "32")] + atomic!(@check, $t, atomic::AtomicU32, $a, $atomic_op); + #[cfg(target_has_atomic = "64")] + atomic!(@check, $t, atomic::AtomicU64, $a, $atomic_op); + } + + break $fallback_op; + } + }; +} + +/// Returns `true` if operations on `AtomicCell` are lock-free. +fn atomic_is_lock_free() -> bool { + atomic! { T, _a, true, false } +} + +/// Atomically reads data from `src`. +/// +/// This operation uses the `SeqCst` ordering. If possible, an atomic instructions is used, and a +/// global lock otherwise. +unsafe fn atomic_load(src: *mut T) -> T +where + T: Copy, +{ + atomic! { + T, a, + { + a = &*(src as *const _ as *const _); + mem::transmute_copy(&a.load(Ordering::SeqCst)) + }, + { + let lock = lock(src as usize); + + // Try doing an optimistic read first. + if let Some(stamp) = lock.optimistic_read() { + // We need a volatile read here because other threads might concurrently modify the + // value. In theory, data races are *always* UB, even if we use volatile reads and + // discard the data when a data race is detected. The proper solution would be to + // do atomic reads and atomic writes, but we can't atomically read and write all + // kinds of data since `AtomicU8` is not available on stable Rust yet. + let val = ptr::read_volatile(src); + + if lock.validate_read(stamp) { + return val; + } + } + + // Grab a regular write lock so that writers don't starve this load. + let guard = lock.write(); + let val = ptr::read(src); + // The value hasn't been changed. Drop the guard without incrementing the stamp. + guard.abort(); + val + } + } +} + +/// Atomically writes `val` to `dst`. +/// +/// This operation uses the `SeqCst` ordering. If possible, an atomic instructions is used, and a +/// global lock otherwise. +unsafe fn atomic_store(dst: *mut T, val: T) { + atomic! { + T, a, + { + a = &*(dst as *const _ as *const _); + let res = a.store(mem::transmute_copy(&val), Ordering::SeqCst); + mem::forget(val); + res + }, + { + let _guard = lock(dst as usize).write(); + ptr::write(dst, val) + } + } +} + +/// Atomically swaps data at `dst` with `val`. +/// +/// This operation uses the `SeqCst` ordering. If possible, an atomic instructions is used, and a +/// global lock otherwise. +unsafe fn atomic_swap(dst: *mut T, val: T) -> T { + atomic! { + T, a, + { + a = &*(dst as *const _ as *const _); + let res = mem::transmute_copy(&a.swap(mem::transmute_copy(&val), Ordering::SeqCst)); + mem::forget(val); + res + }, + { + let _guard = lock(dst as usize).write(); + ptr::replace(dst, val) + } + } +} + +/// Atomically compares data at `dst` to `current` and, if equal byte-for-byte, exchanges data at +/// `dst` with `new`. +/// +/// Returns the old value on success, or the current value at `dst` on failure. +/// +/// This operation uses the `SeqCst` ordering. If possible, an atomic instructions is used, and a +/// global lock otherwise. +unsafe fn atomic_compare_exchange_weak(dst: *mut T, current: T, new: T) -> Result +where + T: Copy, +{ + atomic! { + T, a, + { + a = &*(dst as *const _ as *const _); + let res = a.compare_exchange_weak( + mem::transmute_copy(¤t), + mem::transmute_copy(&new), + Ordering::SeqCst, + Ordering::SeqCst, + ); + match res { + Ok(v) => Ok(mem::transmute_copy(&v)), + Err(v) => Err(mem::transmute_copy(&v)), + } + }, + { + let guard = lock(dst as usize).write(); + + if byte_eq(&*dst, ¤t) { + Ok(ptr::replace(dst, new)) + } else { + let val = ptr::read(dst); + // The value hasn't been changed. Drop the guard without incrementing the stamp. + guard.abort(); + Err(val) + } + } + } +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/src/lib.rs b/third_party/cargo/vendor/crossbeam-0.5.0/src/lib.rs new file mode 100644 index 0000000..68ae831 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/src/lib.rs @@ -0,0 +1,131 @@ +//! Crossbeam supports concurrent programming, especially focusing on memory +//! management, synchronization, and non-blocking data structures. +//! +//! Crossbeam consists of several submodules: +//! +//! - `atomic` for **enhancing `std::sync` API**. `AtomicConsume` provides +//! C/C++11-style "consume" atomic operations (re-exported from +//! [`crossbeam-utils`]). `ArcCell` provides atomic storage and retrieval of +//! `Arc`. +//! +//! - `utils` and `thread` for **utilities**, re-exported from [`crossbeam-utils`]. +//! The "scoped" thread API in `thread` makes it possible to spawn threads that +//! share stack data with their parents. The `utils::CachePadded` struct inserts +//! padding to align data with the size of a cacheline. This crate also seeks to +//! expand the standard library's few synchronization primitives (locks, +//! barriers, etc) to include advanced/niche primitives, as well as userspace +//! alternatives. +//! +//! - `epoch` for **memory management**, re-exported from [`crossbeam-epoch`]. +//! Because non-blocking data structures avoid global synchronization, it is not +//! easy to tell when internal data can be safely freed. The crate provides +//! generic, easy to use, and high-performance APIs for managing memory in these +//! cases. We plan to support other memory management schemes, e.g. hazard +//! pointers (HP) and quiescent state-based reclamation (QSBR). +//! +//! - **Concurrent data structures** which are non-blocking and much superior to +//! wrapping sequential ones with a `Mutex`. Crossbeam currently provides +//! channels (re-exported from [`crossbeam-channel`]), deques +//! (re-exported from [`crossbeam-deque`]), queues, and stacks. Ultimately the +//! goal is to also include bags, sets and maps. + +#![warn(missing_docs)] +// #![warn(missing_debug_implementations)] // TODO: Uncomment this. +#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(feature = "nightly", feature(alloc))] +#![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))] +#![cfg_attr(feature = "nightly", feature(integer_atomics))] + +#[macro_use] +extern crate cfg_if; +#[cfg(feature = "std")] +extern crate core; + +cfg_if! { + if #[cfg(feature = "nightly")] { + extern crate alloc; + } else { + mod alloc { + extern crate std; + pub use self::std::*; + } + } +} + +mod _epoch { + pub extern crate crossbeam_epoch; +} +pub use _epoch::crossbeam_epoch as epoch; + +mod arc_cell; +mod atomic_cell; + +extern crate crossbeam_utils; + +/// Additional utilities for atomics. +pub mod atomic { + pub use arc_cell::ArcCell; + pub use atomic_cell::AtomicCell; + pub use crossbeam_utils::atomic::AtomicConsume; +} + +/// Utilities for concurrent programming. +/// +/// See [the `crossbeam-utils` crate](https://github.com/crossbeam-rs/crossbeam-utils) for more +/// information. +pub mod utils { + pub use crossbeam_utils::CachePadded; +} + +cfg_if! { + if #[cfg(feature = "std")] { + pub use crossbeam_utils::thread; + + // Export `crossbeam_utils::thread::scope` into the crate root because it's become an + // established pattern. + pub use crossbeam_utils::thread::scope; + + mod _deque { + pub extern crate crossbeam_deque; + } + pub use _deque::crossbeam_deque as deque; + + mod _channel { + pub extern crate crossbeam_channel; + pub use self::crossbeam_channel::*; + } + pub use _channel::crossbeam_channel as channel; + + // HACK(stjepang): This is the only way to reexport `select!` in Rust older than 1.30.0 + #[doc(hidden)] + pub use _channel::*; + + #[macro_use] + extern crate lazy_static; + extern crate num_cpus; + extern crate parking_lot; + + mod ms_queue; + mod seg_queue; + mod sharded_lock; + mod treiber_stack; + mod wait_group; + + /// Concurrent queues. + pub mod queue { + pub use ms_queue::MsQueue; + pub use seg_queue::SegQueue; + } + + /// Concurrent stacks. + pub mod stack { + pub use treiber_stack::TreiberStack; + } + + /// Utilities for thread synchronization. + pub mod sync { + pub use sharded_lock::{ShardedLock, ShardedLockReadGuard, ShardedLockWriteGuard}; + pub use wait_group::WaitGroup; + } + } +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/src/ms_queue.rs b/third_party/cargo/vendor/crossbeam-0.5.0/src/ms_queue.rs new file mode 100644 index 0000000..49a4417 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/src/ms_queue.rs @@ -0,0 +1,557 @@ +use std::mem::{self, ManuallyDrop}; +use std::ptr; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering::{Acquire, Relaxed, Release}; +use std::thread::{self, Thread}; + +use epoch::{self, Atomic, Owned, Shared}; +use utils::CachePadded; + +/// A Michael-Scott lock-free queue, with support for blocking `pop`s. +/// +/// Usable with any number of producers and consumers. +// The representation here is a singly-linked list, with a sentinel +// node at the front. In general the `tail` pointer may lag behind the +// actual tail. Non-sentinel nodes are either all `Data` or all +// `Blocked` (requests for data from blocked threads). +#[derive(Debug)] +pub struct MsQueue { + head: CachePadded>>, + tail: CachePadded>>, +} + +#[derive(Debug)] +struct Node { + payload: Payload, + next: Atomic>, +} + +#[derive(Debug)] +enum Payload { + /// A node with actual data that can be popped. + Data(ManuallyDrop), + /// A node representing a blocked request for data. + Blocked(*mut Signal), +} + +/// A blocked request for data, which includes a slot to write the data. +#[derive(Debug)] +struct Signal { + /// Thread to unpark when data is ready. + thread: Thread, + /// The actual data, when available. + data: Option, + /// Is the data ready? Needed to cope with spurious wakeups. + ready: AtomicBool, +} + +impl Node { + fn is_data(&self) -> bool { + if let Payload::Data(_) = self.payload { + true + } else { + false + } + } +} + +// Any particular `T` should never accessed concurrently, so no need +// for Sync. +unsafe impl Sync for MsQueue {} +unsafe impl Send for MsQueue {} + +impl MsQueue { + /// Create a new, empty queue. + pub fn new() -> MsQueue { + let q = MsQueue { + head: CachePadded::new(Atomic::null()), + tail: CachePadded::new(Atomic::null()), + }; + let sentinel = Owned::new(Node { + payload: Payload::Data(unsafe { mem::uninitialized() }), + next: Atomic::null(), + }); + let guard = epoch::pin(); + let sentinel = sentinel.into_shared(&guard); + q.head.store(sentinel, Relaxed); + q.tail.store(sentinel, Relaxed); + q + } + + #[inline(always)] + /// Attempt to atomically place `n` into the `next` pointer of `onto`. + /// + /// If unsuccessful, returns ownership of `n`, possibly updating + /// the queue's `tail` pointer. + fn push_internal( + &self, + guard: &epoch::Guard, + onto: Shared>, + n: Owned>, + ) -> Result<(), Owned>> { + // is `onto` the actual tail? + let next_atomic = &unsafe { onto.as_ref() }.unwrap().next; + let next_shared = next_atomic.load(Acquire, guard); + if unsafe { next_shared.as_ref() }.is_some() { + // if not, try to "help" by moving the tail pointer forward + let _ = self.tail.compare_and_set(onto, next_shared, Release, guard); + Err(n) + } else { + // looks like the actual tail; attempt to link in `n` + next_atomic + .compare_and_set(Shared::null(), n, Release, guard) + .map(|shared| { + // try to move the tail pointer forward + let _ = self.tail.compare_and_set(onto, shared, Release, guard); + }).map_err(|e| e.new) + } + } + + /// Add `t` to the back of the queue, possibly waking up threads + /// blocked on `pop`. + pub fn push(&self, t: T) { + /// We may or may not need to allocate a node; once we do, + /// we cache that allocation. + enum Cache { + Data(T), + Node(Owned>), + } + + impl Cache { + /// Extract the node if cached, or allocate if not. + fn into_node(self) -> Owned> { + match self { + Cache::Data(t) => Owned::new(Node { + payload: Payload::Data(ManuallyDrop::new(t)), + next: Atomic::null(), + }), + Cache::Node(n) => n, + } + } + + /// Extract the data from the cache, deallocating any cached node. + fn into_data(self) -> T { + match self { + Cache::Data(t) => t, + Cache::Node(node) => match (*node.into_box()).payload { + Payload::Data(t) => ManuallyDrop::into_inner(t), + _ => unreachable!(), + }, + } + } + } + + let mut cache = Cache::Data(t); // don't allocate up front + let guard = epoch::pin(); + + loop { + // We push onto the tail, so we'll start optimistically by looking + // there first. + let tail_shared = self.tail.load(Acquire, &guard); + let tail_ref = unsafe { tail_shared.as_ref() }.unwrap(); + + // Is the queue in Data mode (empty queues can be viewed as either mode)? + if tail_ref.is_data() || self.head.load(Relaxed, &guard) == tail_shared { + // Attempt to push onto the `tail` snapshot; fails if + // `tail.next` has changed, which will always be the case if the + // queue has transitioned to blocking mode. + match self.push_internal(&guard, tail_shared, cache.into_node()) { + Ok(_) => return, + Err(n) => { + // replace the cache, retry whole thing + cache = Cache::Node(n) + } + } + } else { + // Queue is in blocking mode. Attempt to unblock a thread. + let head_shared = self.head.load(Acquire, &guard); + let head = unsafe { head_shared.as_ref() }.unwrap(); + // Get a handle on the first blocked node. Racy, so queue might + // be empty or in data mode by the time we see it. + let next_shared = head.next.load(Acquire, &guard); + let request = unsafe { next_shared.as_ref() }.and_then(|next| match next.payload { + Payload::Blocked(signal) => Some((next_shared, signal)), + Payload::Data(_) => None, + }); + if let Some((blocked_node, signal)) = request { + // race to dequeue the node + if self + .head + .compare_and_set(head_shared, blocked_node, Release, &guard) + .is_ok() + { + unsafe { + // signal the thread + (*signal).data = Some(cache.into_data()); + let thread = (*signal).thread.clone(); + + (*signal).ready.store(true, Release); + thread.unpark(); + guard.defer_destroy(head_shared); + return; + } + } + } + } + } + } + + // Attempt to pop a data node. `Ok(None)` if queue is empty or in blocking + // mode; `Err(())` if lost race to pop. + #[inline(always)] + fn pop_internal(&self, guard: &epoch::Guard) -> Result, ()> { + let head_shared = self.head.load(Acquire, guard); + let head = unsafe { head_shared.as_ref() }.unwrap(); + let next_shared = head.next.load(Acquire, guard); + if let Some(next) = unsafe { next_shared.as_ref() } { + if let Payload::Data(ref t) = next.payload { + unsafe { + if self + .head + .compare_and_set(head_shared, next_shared, Release, guard) + .is_ok() + { + guard.defer_destroy(head_shared); + Ok(Some(ManuallyDrop::into_inner(ptr::read(t)))) + } else { + Err(()) + } + } + } else { + Ok(None) + } + } else { + Ok(None) + } + } + + /// Check if this queue is empty. + pub fn is_empty(&self) -> bool { + let guard = epoch::pin(); + let head = unsafe { self.head.load(Acquire, &guard).as_ref() }.unwrap(); + + if let Some(next) = unsafe { head.next.load(Acquire, &guard).as_ref() } { + if let Payload::Data(_) = next.payload { + false + } else { + true + } + } else { + true + } + } + + /// Attempt to dequeue from the front. + /// + /// Returns `None` if the queue is observed to be empty. + pub fn try_pop(&self) -> Option { + let guard = epoch::pin(); + loop { + if let Ok(r) = self.pop_internal(&guard) { + return r; + } + } + } + + /// Dequeue an element from the front of the queue, blocking if the queue is + /// empty. + pub fn pop(&self) -> T { + let guard = epoch::pin(); + + // Fast path: keep retrying until we observe that the queue has no data, + // avoiding the allocation of a blocked node. + loop { + match self.pop_internal(&guard) { + Ok(Some(r)) => { + return r; + } + Ok(None) => { + break; + } + Err(()) => {} + } + } + + // The signal gets to live on the stack, since this stack frame will be + // blocked until receiving the signal. + let mut signal = Signal { + thread: thread::current(), + data: None, + ready: AtomicBool::new(false), + }; + + // Go ahead and allocate the blocked node; chances are, we'll need it. + let mut node = Owned::new(Node { + payload: Payload::Blocked(&mut signal), + next: Atomic::null(), + }); + + loop { + // try a normal pop + if let Ok(Some(r)) = self.pop_internal(&guard) { + return r; + } + + // At this point, we believe the queue is empty/blocked. + // Snapshot the tail, onto which we want to push a blocked node. + let tail_shared = self.tail.load(Acquire, &guard); + let tail = unsafe { tail_shared.as_ref() }.unwrap(); + + // Double-check that we're in blocking mode + if tail.is_data() { + // The current tail is in data mode, so we probably need to abort. + // BUT, it might be the sentinel, so check for that first. + let head_shared = self.head.load(Relaxed, &guard); + if tail.is_data() && tail_shared != head_shared { + continue; + } + } + + // At this point, the tail snapshot is either a blocked node deep in + // the queue, the sentinel, or no longer accessible from the queue. + // In *ALL* of these cases, if we succeed in pushing onto the + // snapshot, we know we are maintaining the core invariant: all + // reachable, non-sentinel nodes have the same payload mode, in this + // case, blocked. + match self.push_internal(&guard, tail_shared, node) { + Ok(()) => break, + Err(n) => { + node = n; + } + } + } + + drop(guard); + + while !signal.ready.load(Acquire) { + thread::park(); + } + signal.data.unwrap() + } +} + +impl Drop for MsQueue { + fn drop(&mut self) { + while self.try_pop().is_some() {} + + // Destroy the remaining sentinel node. + let guard = epoch::pin(); + let sentinel = self.head.load(Relaxed, &guard).as_raw() as *mut Node; + unsafe { + drop(Vec::from_raw_parts(sentinel, 0, 1)); + } + } +} + +impl Default for MsQueue { + fn default() -> Self { + MsQueue::new() + } +} + +#[cfg(test)] +mod test { + const CONC_COUNT: i64 = 1000000; + + use super::*; + use scope; + + #[test] + fn push_try_pop_1() { + let q: MsQueue = MsQueue::new(); + assert!(q.is_empty()); + q.push(37); + assert!(!q.is_empty()); + assert_eq!(q.try_pop(), Some(37)); + assert!(q.is_empty()); + } + + #[test] + fn push_try_pop_2() { + let q: MsQueue = MsQueue::new(); + assert!(q.is_empty()); + q.push(37); + q.push(48); + assert_eq!(q.try_pop(), Some(37)); + assert!(!q.is_empty()); + assert_eq!(q.try_pop(), Some(48)); + assert!(q.is_empty()); + } + + #[test] + fn push_try_pop_many_seq() { + let q: MsQueue = MsQueue::new(); + assert!(q.is_empty()); + for i in 0..200 { + q.push(i) + } + assert!(!q.is_empty()); + for i in 0..200 { + assert_eq!(q.try_pop(), Some(i)); + } + assert!(q.is_empty()); + } + + #[test] + fn push_pop_1() { + let q: MsQueue = MsQueue::new(); + assert!(q.is_empty()); + q.push(37); + assert!(!q.is_empty()); + assert_eq!(q.pop(), 37); + assert!(q.is_empty()); + } + + #[test] + fn push_pop_2() { + let q: MsQueue = MsQueue::new(); + q.push(37); + q.push(48); + assert_eq!(q.pop(), 37); + assert_eq!(q.pop(), 48); + } + + #[test] + fn push_pop_many_seq() { + let q: MsQueue = MsQueue::new(); + assert!(q.is_empty()); + for i in 0..200 { + q.push(i) + } + assert!(!q.is_empty()); + for i in 0..200 { + assert_eq!(q.pop(), i); + } + assert!(q.is_empty()); + } + + #[test] + fn push_try_pop_many_spsc() { + let q: MsQueue = MsQueue::new(); + assert!(q.is_empty()); + + scope(|scope| { + scope.spawn(|_| { + let mut next = 0; + + while next < CONC_COUNT { + if let Some(elem) = q.try_pop() { + assert_eq!(elem, next); + next += 1; + } + } + }); + + for i in 0..CONC_COUNT { + q.push(i) + } + }).unwrap(); + } + + #[test] + fn push_try_pop_many_spmc() { + fn recv(_t: i32, q: &MsQueue) { + let mut cur = -1; + for _i in 0..CONC_COUNT { + if let Some(elem) = q.try_pop() { + assert!(elem > cur); + cur = elem; + + if cur == CONC_COUNT - 1 { + break; + } + } + } + } + + let q: MsQueue = MsQueue::new(); + assert!(q.is_empty()); + let qr = &q; + scope(|scope| { + for i in 0..3 { + scope.spawn(|_| recv(i, qr)); + } + + scope.spawn(|_| { + for i in 0..CONC_COUNT { + q.push(i); + } + }); + }).unwrap(); + } + + #[test] + fn push_try_pop_many_mpmc() { + enum LR { + Left(i64), + Right(i64), + } + + let q: MsQueue = MsQueue::new(); + assert!(q.is_empty()); + + scope(|scope| { + for _t in 0..2 { + scope.spawn(|_| { + for i in CONC_COUNT - 1..CONC_COUNT { + q.push(LR::Left(i)) + } + }); + scope.spawn(|_| { + for i in CONC_COUNT - 1..CONC_COUNT { + q.push(LR::Right(i)) + } + }); + scope.spawn(|_| { + let mut vl = vec![]; + let mut vr = vec![]; + for _i in 0..CONC_COUNT { + match q.try_pop() { + Some(LR::Left(x)) => vl.push(x), + Some(LR::Right(x)) => vr.push(x), + _ => {} + } + } + + let mut vl2 = vl.clone(); + let mut vr2 = vr.clone(); + vl2.sort(); + vr2.sort(); + + assert_eq!(vl, vl2); + assert_eq!(vr, vr2); + }); + } + }).unwrap(); + } + + #[test] + fn push_pop_many_spsc() { + let q: MsQueue = MsQueue::new(); + + scope(|scope| { + scope.spawn(|_| { + let mut next = 0; + while next < CONC_COUNT { + assert_eq!(q.pop(), next); + next += 1; + } + }); + + for i in 0..CONC_COUNT { + q.push(i) + } + }).unwrap(); + assert!(q.is_empty()); + } + + #[test] + fn is_empty_dont_pop() { + let q: MsQueue = MsQueue::new(); + q.push(20); + q.push(20); + assert!(!q.is_empty()); + assert!(!q.is_empty()); + assert!(q.try_pop().is_some()); + } +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/src/seg_queue.rs b/third_party/cargo/vendor/crossbeam-0.5.0/src/seg_queue.rs new file mode 100644 index 0000000..dc9eac3 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/src/seg_queue.rs @@ -0,0 +1,313 @@ +use std::cell::UnsafeCell; +use std::cmp; +use std::fmt; +use std::mem::{self, ManuallyDrop}; +use std::ptr; +use std::sync::atomic::Ordering::{Acquire, Relaxed, Release}; +use std::sync::atomic::{AtomicBool, AtomicUsize}; + +use epoch::{self, Atomic, Owned}; + +const SEG_SIZE: usize = 32; + +/// A Michael-Scott queue that allocates "segments" (arrays of nodes) +/// for efficiency. +/// +/// Usable with any number of producers and consumers. +#[derive(Debug)] +pub struct SegQueue { + head: Atomic>, + tail: Atomic>, +} + +struct Segment { + low: AtomicUsize, + data: ManuallyDrop<[UnsafeCell<(T, AtomicBool)>; SEG_SIZE]>, + high: AtomicUsize, + next: Atomic>, +} + +impl fmt::Debug for Segment { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Segment {{ ... }}") + } +} + +unsafe impl Sync for Segment {} + +impl Segment { + fn new() -> Segment { + let rqueue = Segment { + data: unsafe { ManuallyDrop::new(mem::uninitialized()) }, + low: AtomicUsize::new(0), + high: AtomicUsize::new(0), + next: Atomic::null(), + }; + for val in rqueue.data.iter() { + unsafe { + (*val.get()).1 = AtomicBool::new(false); + } + } + rqueue + } +} + +impl SegQueue { + /// Create a new, empty queue. + pub fn new() -> SegQueue { + let q = SegQueue { + head: Atomic::null(), + tail: Atomic::null(), + }; + let sentinel = Owned::new(Segment::new()); + let guard = epoch::pin(); + let sentinel = sentinel.into_shared(&guard); + q.head.store(sentinel, Relaxed); + q.tail.store(sentinel, Relaxed); + q + } + + /// Add `t` to the back of the queue. + pub fn push(&self, t: T) { + let guard = epoch::pin(); + loop { + let tail = unsafe { self.tail.load(Acquire, &guard).as_ref() }.unwrap(); + if tail.high.load(Relaxed) >= SEG_SIZE { + continue; + } + let i = tail.high.fetch_add(1, Relaxed); + unsafe { + if i < SEG_SIZE { + let cell = (*tail).data.get_unchecked(i).get(); + ptr::write(&mut (*cell).0, t); + (*cell).1.store(true, Release); + + if i + 1 == SEG_SIZE { + let tail_new = Owned::new(Segment::new()).into_shared(&guard); + tail.next.store(tail_new, Release); + self.tail.store(tail_new, Release); + } + + return; + } + } + } + } + + /// Judge if the queue is empty. + /// + /// Returns `true` if the queue is empty. + pub fn is_empty(&self) -> bool { + let guard = epoch::pin(); + let head = self.head.load(Acquire, &guard); + let tail = self.tail.load(Acquire, &guard); + if head != tail { + return false; + } + + let head_ref = unsafe { head.as_ref() }.unwrap(); + let low = head_ref.low.load(Relaxed); + low >= cmp::min(head_ref.high.load(Relaxed), SEG_SIZE) + } + + /// Attempt to dequeue from the front. + /// + /// Returns `None` if the queue is observed to be empty. + pub fn try_pop(&self) -> Option { + let guard = epoch::pin(); + loop { + let head_shared = self.head.load(Acquire, &guard); + let head = unsafe { head_shared.as_ref() }.unwrap(); + loop { + let low = head.low.load(Relaxed); + if low >= cmp::min(head.high.load(Relaxed), SEG_SIZE) { + break; + } + if head.low.compare_and_swap(low, low + 1, Relaxed) == low { + unsafe { + let cell = (*head).data.get_unchecked(low).get(); + loop { + if (*cell).1.load(Acquire) { + break; + } + } + if low + 1 == SEG_SIZE { + loop { + let next_shared = head.next.load(Acquire, &guard); + if next_shared.as_ref().is_some() { + self.head.store(next_shared, Release); + guard.defer_destroy(head_shared); + break; + } + } + } + return Some(ptr::read(&(*cell).0)); + } + } + } + if head.next.load(Relaxed, &guard).is_null() { + return None; + } + } + } +} + +impl Drop for SegQueue { + fn drop(&mut self) { + while self.try_pop().is_some() {} + + // Destroy the remaining sentinel segment. + let guard = epoch::pin(); + let sentinel = self.head.load(Relaxed, &guard).as_raw() as *mut Segment; + unsafe { + drop(Vec::from_raw_parts(sentinel, 0, 1)); + } + } +} + +impl Default for SegQueue { + fn default() -> Self { + SegQueue::new() + } +} + +#[cfg(test)] +mod test { + const CONC_COUNT: i64 = 1000000; + + use super::*; + use scope; + + #[test] + fn push_pop_1() { + let q: SegQueue = SegQueue::new(); + q.push(37); + assert_eq!(q.try_pop(), Some(37)); + } + + #[test] + fn push_pop_2() { + let q: SegQueue = SegQueue::new(); + q.push(37); + q.push(48); + assert_eq!(q.try_pop(), Some(37)); + assert_eq!(q.try_pop(), Some(48)); + } + + #[test] + fn push_pop_empty_check() { + let q: SegQueue = SegQueue::new(); + assert_eq!(q.is_empty(), true); + q.push(42); + assert_eq!(q.is_empty(), false); + assert_eq!(q.try_pop(), Some(42)); + assert_eq!(q.is_empty(), true); + } + + #[test] + fn push_pop_many_seq() { + let q: SegQueue = SegQueue::new(); + for i in 0..200 { + q.push(i) + } + for i in 0..200 { + assert_eq!(q.try_pop(), Some(i)); + } + } + + #[test] + fn push_pop_many_spsc() { + let q: SegQueue = SegQueue::new(); + + scope(|scope| { + scope.spawn(|_| { + let mut next = 0; + + while next < CONC_COUNT { + if let Some(elem) = q.try_pop() { + assert_eq!(elem, next); + next += 1; + } + } + }); + + for i in 0..CONC_COUNT { + q.push(i) + } + }).unwrap(); + } + + #[test] + fn push_pop_many_spmc() { + fn recv(_t: i32, q: &SegQueue) { + let mut cur = -1; + for _i in 0..CONC_COUNT { + if let Some(elem) = q.try_pop() { + assert!(elem > cur); + cur = elem; + + if cur == CONC_COUNT - 1 { + break; + } + } + } + } + + let q: SegQueue = SegQueue::new(); + scope(|scope| { + for i in 0..3 { + scope.spawn(|_| recv(i, &q)); + } + + scope.spawn(|_| { + for i in 0..CONC_COUNT { + q.push(i); + } + }); + }).unwrap(); + } + + #[test] + fn push_pop_many_mpmc() { + enum LR { + Left(i64), + Right(i64), + } + + let q: SegQueue = SegQueue::new(); + + scope(|scope| { + for _t in 0..2 { + scope.spawn(|_| { + for i in CONC_COUNT - 1..CONC_COUNT { + q.push(LR::Left(i)) + } + }); + scope.spawn(|_| { + for i in CONC_COUNT - 1..CONC_COUNT { + q.push(LR::Right(i)) + } + }); + scope.spawn(|_| { + let mut vl = vec![]; + let mut vr = vec![]; + for _i in 0..CONC_COUNT { + match q.try_pop() { + Some(LR::Left(x)) => vl.push(x), + Some(LR::Right(x)) => vr.push(x), + _ => {} + } + } + + let mut vl2 = vl.clone(); + let mut vr2 = vr.clone(); + vl2.sort(); + vr2.sort(); + + assert_eq!(vl, vl2); + assert_eq!(vr, vr2); + }); + } + }).unwrap(); + } +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/src/sharded_lock.rs b/third_party/cargo/vendor/crossbeam-0.5.0/src/sharded_lock.rs new file mode 100644 index 0000000..a8709a1 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/src/sharded_lock.rs @@ -0,0 +1,217 @@ +//! A scalable reader-writer lock. +//! +//! This implementation makes read operations faster and more scalable due to less contention, +//! while making write operations slower. It also incurs much higher memory overhead than +//! traditional reader-writer locks. + +use std::cell::UnsafeCell; +use std::collections::HashMap; +use std::marker::PhantomData; +use std::mem; +use std::ops::{Deref, DerefMut}; +use std::thread::{self, ThreadId}; + +use crossbeam_utils::CachePadded; +use num_cpus; +use parking_lot::{Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard}; + +/// A scalable reader-writer lock. +/// +/// This type of lock allows a number of readers or at most one writer at any point in time. The +/// write portion of this lock typically allows modification of the underlying data (exclusive +/// access) and the read portion of this lock typically allows for read-only access (shared +/// access). +/// +/// This reader-writer lock differs from typical implementations in that it internally creates a +/// list of reader-writer locks called 'shards'. Shards are aligned and padded to the cache line +/// size. +/// +/// Read operations lock only one shard specific to the current thread, while write operations lock +/// every shard in succession. This strategy makes concurrent read operations faster due to less +/// contention, but write operations are slower due to increased amount of locking. +pub struct ShardedLock { + /// A list of locks protecting the internal data. + shards: Vec>>, + + /// The internal data. + value: UnsafeCell, +} + +unsafe impl Send for ShardedLock {} +unsafe impl Sync for ShardedLock {} + +impl ShardedLock { + /// Creates a new `ShardedLock` initialized with `value`. + pub fn new(value: T) -> ShardedLock { + // The number of shards is a power of two so that the modulo operation in `read` becomes a + // simple bitwise "and". + let num_shards = num_cpus::get().next_power_of_two(); + + ShardedLock { + shards: (0..num_shards) + .map(|_| CachePadded::new(RwLock::new(()))) + .collect(), + value: UnsafeCell::new(value), + } + } + + /// Locks with shared read access, blocking the current thread until it can be acquired. + /// + /// The calling thread will be blocked until there are no more writers which hold the lock. + /// There may be other readers currently inside the lock when this method returns. This method + /// does not provide any guarantees with respect to the ordering of whether contentious readers + /// or writers will acquire the lock first. + /// + /// Returns an RAII guard which will drop the read access of this lock when dropped. + pub fn read(&self) -> ShardedLockReadGuard { + // Take the current thread index and map it to a shard index. Thread indices will tend to + // distribute shards among threads equally, thus reducing contention due to read-locking. + let current_index = current_index().unwrap_or(0); + let shard_index = current_index & (self.shards.len() - 1); + + ShardedLockReadGuard { + parent: self, + _guard: self.shards[shard_index].read(), + _marker: PhantomData, + } + } + + /// Locks with exclusive write access, blocking the current thread until it can be acquired. + /// + /// This function will not return while other writers or other readers currently have access to + /// the lock. + /// + /// Returns an RAII guard which will drop the write access of this lock when dropped. + pub fn write(&self) -> ShardedLockWriteGuard { + // Write-lock each shard in succession. + for shard in &self.shards { + // The write guard is forgotten, but the lock will be manually unlocked in `drop`. + mem::forget(shard.write()); + } + + ShardedLockWriteGuard { + parent: self, + _marker: PhantomData, + } + } +} + +/// A guard used to release the shared read access of a `ShardedLock` when dropped. +pub struct ShardedLockReadGuard<'a, T: 'a> { + parent: &'a ShardedLock, + _guard: RwLockReadGuard<'a, ()>, + _marker: PhantomData>, +} + +unsafe impl<'a, T: Sync> Sync for ShardedLockReadGuard<'a, T> {} + +impl<'a, T> Deref for ShardedLockReadGuard<'a, T> { + type Target = T; + + fn deref(&self) -> &T { + unsafe { &*self.parent.value.get() } + } +} + +/// A guard used to release the exclusive write access of a `ShardedLock` when dropped. +pub struct ShardedLockWriteGuard<'a, T: 'a> { + parent: &'a ShardedLock, + _marker: PhantomData>, +} + +unsafe impl<'a, T: Sync> Sync for ShardedLockWriteGuard<'a, T> {} + +impl<'a, T> Drop for ShardedLockWriteGuard<'a, T> { + fn drop(&mut self) { + // Unlock the shards in reverse order of locking. + for shard in self.parent.shards.iter().rev() { + unsafe { + (**shard).force_unlock_write(); + } + } + } +} + +impl<'a, T> Deref for ShardedLockWriteGuard<'a, T> { + type Target = T; + + fn deref(&self) -> &T { + unsafe { &*self.parent.value.get() } + } +} + +impl<'a, T> DerefMut for ShardedLockWriteGuard<'a, T> { + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *self.parent.value.get() } + } +} + +/// Returns a `usize` that identifies the current thread. +/// +/// Each thread is associated with an 'index'. While there are no particular guarantees, indices +/// usually tend to be consecutive numbers between 0 and the number of running threads. +/// +/// Since this function accesses TLS, `None` might be returned if the current thread's TLS is +/// tearing down. +#[inline] +fn current_index() -> Option { + REGISTRATION.try_with(|reg| reg.index).ok() +} + +/// The global registry keeping track of registered threads and indices. +struct ThreadIndices { + /// Mapping from `ThreadId` to thread index. + mapping: HashMap, + + /// A list of free indices. + free_list: Vec, + + /// The next index to allocate if the free list is empty. + next_index: usize, +} + +lazy_static! { + static ref THREAD_INDICES: Mutex = Mutex::new(ThreadIndices { + mapping: HashMap::new(), + free_list: Vec::new(), + next_index: 0, + }); +} + +/// A registration of a thread with an index. +/// +/// When dropped, unregisters the thread and frees the reserved index. +struct Registration { + index: usize, + thread_id: ThreadId, +} + +impl Drop for Registration { + fn drop(&mut self) { + let mut indices = THREAD_INDICES.lock(); + indices.mapping.remove(&self.thread_id); + indices.free_list.push(self.index); + } +} + +thread_local! { + static REGISTRATION: Registration = { + let thread_id = thread::current().id(); + let mut indices = THREAD_INDICES.lock(); + + let index = match indices.free_list.pop() { + Some(i) => i, + None => { + let i = indices.next_index; + indices.next_index += 1; + i + } + }; + indices.mapping.insert(thread_id, index); + + Registration { + index, + thread_id, + } + }; +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/src/treiber_stack.rs b/third_party/cargo/vendor/crossbeam-0.5.0/src/treiber_stack.rs new file mode 100644 index 0000000..1fbd121 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/src/treiber_stack.rs @@ -0,0 +1,140 @@ +use std::mem::ManuallyDrop; +use std::ptr; +use std::sync::atomic::Ordering::{Acquire, Relaxed, Release}; + +use epoch::{self, Atomic, Owned}; + +/// Treiber's lock-free stack. +/// +/// Usable with any number of producers and consumers. +#[derive(Debug)] +pub struct TreiberStack { + head: Atomic>, +} + +#[derive(Debug)] +struct Node { + data: ManuallyDrop, + next: Atomic>, +} + +impl TreiberStack { + /// Create a new, empty stack. + pub fn new() -> TreiberStack { + TreiberStack { + head: Atomic::null(), + } + } + + /// Push `t` on top of the stack. + pub fn push(&self, t: T) { + let mut n = Owned::new(Node { + data: ManuallyDrop::new(t), + next: Atomic::null(), + }); + let guard = epoch::pin(); + loop { + let head = self.head.load(Relaxed, &guard); + n.next.store(head, Relaxed); + match self.head.compare_and_set(head, n, Release, &guard) { + Ok(_) => break, + Err(e) => n = e.new, + } + } + } + + /// Attempt to pop the top element of the stack. + /// + /// Returns `None` if the stack is observed to be empty. + pub fn try_pop(&self) -> Option { + let guard = epoch::pin(); + loop { + let head_shared = self.head.load(Acquire, &guard); + match unsafe { head_shared.as_ref() } { + Some(head) => { + let next = head.next.load(Relaxed, &guard); + if self + .head + .compare_and_set(head_shared, next, Release, &guard) + .is_ok() + { + unsafe { + guard.defer_destroy(head_shared); + return Some(ManuallyDrop::into_inner(ptr::read(&(*head).data))); + } + } + } + None => return None, + } + } + } + + /// Check if this queue is empty. + pub fn is_empty(&self) -> bool { + let guard = epoch::pin(); + self.head.load(Acquire, &guard).is_null() + } +} + +impl Drop for TreiberStack { + fn drop(&mut self) { + while self.try_pop().is_some() {} + } +} + +impl Default for TreiberStack { + fn default() -> Self { + TreiberStack::new() + } +} + +#[cfg(test)] +mod test { + use super::*; + use std::sync::atomic::{AtomicUsize, Ordering}; + use {epoch, thread}; + + #[test] + fn is_empty() { + let q: TreiberStack = TreiberStack::new(); + assert!(q.is_empty()); + q.push(20); + q.push(20); + assert!(!q.is_empty()); + assert!(!q.is_empty()); + assert!(q.try_pop().is_some()); + assert!(q.try_pop().is_some()); + assert!(q.is_empty()); + q.push(25); + assert!(!q.is_empty()); + } + + #[test] + fn no_double_drop() { + static DROP_COUNT: AtomicUsize = AtomicUsize::new(0); + + struct Dropper; + + impl Drop for Dropper { + fn drop(&mut self) { + DROP_COUNT.fetch_add(1, Ordering::SeqCst); + } + } + + const N_THREADS: usize = 8; + thread::scope(|s| { + for _ in 0..N_THREADS { + s.spawn(|_| { + let s: TreiberStack = TreiberStack::new(); + for _ in 0..4 { + s.push(Dropper); + } + drop(s); + epoch::pin().flush(); + }); + } + }).unwrap(); + + assert!(DROP_COUNT.load(Ordering::SeqCst) == N_THREADS * 4); + } +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/src/wait_group.rs b/third_party/cargo/vendor/crossbeam-0.5.0/src/wait_group.rs new file mode 100644 index 0000000..95755ab --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/src/wait_group.rs @@ -0,0 +1,144 @@ +use std::fmt; +use std::process; +use std::sync::Arc; + +use parking_lot::{Condvar, Mutex}; + +/// Enables multiple threads to synchronize the beginning or end of some computation. +/// +/// # Wait groups vs barriers +/// +/// `WaitGroup` is very similar to [`Barrier`], but there are a few differences: +/// +/// * `Barrier` needs to know the number of threads at construction, while `WaitGroup` is cloned to +/// register more threads. +/// +/// * A `Barrier` can be reused even after all threads have synchronized, while a `WaitGroup` +/// synchronizes threads only once. +/// +/// * All threads wait for others to reach the `Barrier`. With `WaitGroup`, each thread can choose +/// to either wait for other threads or to continue without blocking. +/// +/// # Examples +/// +/// ``` +/// use crossbeam::sync::WaitGroup; +/// use std::thread; +/// +/// // Create a new wait group. +/// let wg = WaitGroup::new(); +/// +/// for _ in 0..4 { +/// // Create another reference to the wait group. +/// let wg = wg.clone(); +/// +/// thread::spawn(move || { +/// // Do some work. +/// +/// // Drop the reference to the wait group. +/// drop(wg); +/// }); +/// } +/// +/// // Block until all threads have finished their work. +/// wg.wait(); +/// ``` +/// +/// [`Barrier`]: https://doc.rust-lang.org/std/sync/struct.Barrier.html +pub struct WaitGroup { + inner: Arc, +} + +/// Inner state of a `WaitGroup`. +struct Inner { + cvar: Condvar, + count: Mutex, +} + +impl WaitGroup { + /// Creates a new wait group and returns the single reference to it. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::sync::WaitGroup; + /// + /// let wg = WaitGroup::new(); + /// ``` + pub fn new() -> WaitGroup { + WaitGroup { + inner: Arc::new(Inner { + cvar: Condvar::new(), + count: Mutex::new(1), + }), + } + } + + /// Drops this reference and waits until all other references are dropped. + /// + /// # Examples + /// + /// ``` + /// use crossbeam::sync::WaitGroup; + /// use std::thread; + /// + /// let wg = WaitGroup::new(); + /// + /// thread::spawn({ + /// let wg = wg.clone(); + /// move || { + /// // Block until both threads have reached `wait()`. + /// wg.wait(); + /// } + /// }); + /// + /// // Block until both threads have reached `wait()`. + /// wg.wait(); + /// ``` + pub fn wait(self) { + if *self.inner.count.lock() == 1 { + return; + } + + let inner = self.inner.clone(); + drop(self); + + let mut count = inner.count.lock(); + while *count > 0 { + inner.cvar.wait(&mut count); + } + } +} + +impl Drop for WaitGroup { + fn drop(&mut self) { + let mut count = self.inner.count.lock(); + *count -= 1; + + if *count == 0 { + self.inner.cvar.notify_all(); + } + } +} + +impl Clone for WaitGroup { + fn clone(&self) -> WaitGroup { + let mut count = self.inner.count.lock(); + *count += 1; + + if *count > isize::max_value() as usize { + process::abort(); + } + + WaitGroup { + inner: self.inner.clone(), + } + } +} + +impl fmt::Debug for WaitGroup { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let count = self.inner.count.lock(); + write!(f, "WaitGroup {{ count: {:?} }}", *count) + } +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/tests/atomic_cell.rs b/third_party/cargo/vendor/crossbeam-0.5.0/tests/atomic_cell.rs new file mode 100644 index 0000000..d17b985 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/tests/atomic_cell.rs @@ -0,0 +1,208 @@ +extern crate crossbeam; + +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::SeqCst; + +use crossbeam::atomic::AtomicCell; + +#[test] +fn is_lock_free() { + struct UsizeWrap(usize); + struct U8Wrap(bool); + + assert_eq!(AtomicCell::::is_lock_free(), true); + assert_eq!(AtomicCell::::is_lock_free(), true); + assert_eq!(AtomicCell::::is_lock_free(), true); + + assert_eq!(AtomicCell::::is_lock_free(), cfg!(feature = "nightly")); + assert_eq!( + AtomicCell::::is_lock_free(), + cfg!(feature = "nightly") + ); + assert_eq!( + AtomicCell::::is_lock_free(), + cfg!(feature = "nightly") + ); +} + +#[test] +fn drops_unit() { + static CNT: AtomicUsize = AtomicUsize::new(0); + CNT.store(0, SeqCst); + + #[derive(Debug, PartialEq, Eq)] + struct Foo(); + + impl Foo { + fn new() -> Foo { + CNT.fetch_add(1, SeqCst); + Foo() + } + } + + impl Drop for Foo { + fn drop(&mut self) { + CNT.fetch_sub(1, SeqCst); + } + } + + impl Default for Foo { + fn default() -> Foo { + Foo::new() + } + } + + let a = AtomicCell::new(Foo::new()); + + assert_eq!(a.swap(Foo::new()), Foo::new()); + assert_eq!(CNT.load(SeqCst), 1); + + a.store(Foo::new()); + assert_eq!(CNT.load(SeqCst), 1); + + assert_eq!(a.swap(Foo::default()), Foo::new()); + assert_eq!(CNT.load(SeqCst), 1); + + drop(a); + assert_eq!(CNT.load(SeqCst), 0); +} + +#[test] +fn drops_u8() { + static CNT: AtomicUsize = AtomicUsize::new(0); + CNT.store(0, SeqCst); + + #[derive(Debug, PartialEq, Eq)] + struct Foo(u8); + + impl Foo { + fn new(val: u8) -> Foo { + CNT.fetch_add(1, SeqCst); + Foo(val) + } + } + + impl Drop for Foo { + fn drop(&mut self) { + CNT.fetch_sub(1, SeqCst); + } + } + + impl Default for Foo { + fn default() -> Foo { + Foo::new(0) + } + } + + let a = AtomicCell::new(Foo::new(5)); + + assert_eq!(a.swap(Foo::new(6)), Foo::new(5)); + assert_eq!(a.swap(Foo::new(1)), Foo::new(6)); + assert_eq!(CNT.load(SeqCst), 1); + + a.store(Foo::new(2)); + assert_eq!(CNT.load(SeqCst), 1); + + assert_eq!(a.swap(Foo::default()), Foo::new(2)); + assert_eq!(CNT.load(SeqCst), 1); + + assert_eq!(a.swap(Foo::default()), Foo::new(0)); + assert_eq!(CNT.load(SeqCst), 1); + + drop(a); + assert_eq!(CNT.load(SeqCst), 0); +} + +#[test] +fn drops_usize() { + static CNT: AtomicUsize = AtomicUsize::new(0); + CNT.store(0, SeqCst); + + #[derive(Debug, PartialEq, Eq)] + struct Foo(usize); + + impl Foo { + fn new(val: usize) -> Foo { + CNT.fetch_add(1, SeqCst); + Foo(val) + } + } + + impl Drop for Foo { + fn drop(&mut self) { + CNT.fetch_sub(1, SeqCst); + } + } + + impl Default for Foo { + fn default() -> Foo { + Foo::new(0) + } + } + + let a = AtomicCell::new(Foo::new(5)); + + assert_eq!(a.swap(Foo::new(6)), Foo::new(5)); + assert_eq!(a.swap(Foo::new(1)), Foo::new(6)); + assert_eq!(CNT.load(SeqCst), 1); + + a.store(Foo::new(2)); + assert_eq!(CNT.load(SeqCst), 1); + + assert_eq!(a.swap(Foo::default()), Foo::new(2)); + assert_eq!(CNT.load(SeqCst), 1); + + assert_eq!(a.swap(Foo::default()), Foo::new(0)); + assert_eq!(CNT.load(SeqCst), 1); + + drop(a); + assert_eq!(CNT.load(SeqCst), 0); +} + +#[test] +fn modular_u8() { + #[derive(Clone, Copy, Eq, Debug, Default)] + struct Foo(u8); + + impl PartialEq for Foo { + fn eq(&self, other: &Foo) -> bool { + self.0 % 5 == other.0 % 5 + } + } + + let a = AtomicCell::new(Foo(1)); + + assert_eq!(a.load(), Foo(1)); + assert_eq!(a.swap(Foo(2)), Foo(11)); + assert_eq!(a.load(), Foo(52)); + + a.store(Foo(0)); + assert_eq!(a.compare_exchange(Foo(0), Foo(5)), Ok(Foo(100))); + assert_eq!(a.load().0, 5); + assert_eq!(a.compare_exchange(Foo(10), Foo(15)), Ok(Foo(100))); + assert_eq!(a.load().0, 15); +} + +#[test] +fn modular_usize() { + #[derive(Clone, Copy, Eq, Debug, Default)] + struct Foo(usize); + + impl PartialEq for Foo { + fn eq(&self, other: &Foo) -> bool { + self.0 % 5 == other.0 % 5 + } + } + + let a = AtomicCell::new(Foo(1)); + + assert_eq!(a.load(), Foo(1)); + assert_eq!(a.swap(Foo(2)), Foo(11)); + assert_eq!(a.load(), Foo(52)); + + a.store(Foo(0)); + assert_eq!(a.compare_exchange(Foo(0), Foo(5)), Ok(Foo(100))); + assert_eq!(a.load().0, 5); + assert_eq!(a.compare_exchange(Foo(10), Foo(15)), Ok(Foo(100))); + assert_eq!(a.load().0, 15); +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/tests/subcrates.rs b/third_party/cargo/vendor/crossbeam-0.5.0/tests/subcrates.rs new file mode 100644 index 0000000..553684f --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/tests/subcrates.rs @@ -0,0 +1,40 @@ +//! Makes sure subcrates are properly reexported. + +#[macro_use] +extern crate crossbeam; + +#[test] +fn channel() { + let (s, r) = crossbeam::channel::bounded(1); + + select! { + send(s, 0) -> res => res.unwrap(), + recv(r) -> res => assert!(res.is_ok()), + } +} + +#[test] +fn deque() { + let (w, s) = crossbeam::deque::fifo(); + w.push(1); + let _ = w.pop(); + let _ = s.steal(); +} + +#[test] +fn epoch() { + crossbeam::epoch::pin(); +} + +#[test] +fn utils() { + crossbeam::utils::CachePadded::new(7); + + crossbeam::scope(|scope| { + scope.spawn(|_| ()); + }).unwrap(); + + crossbeam::thread::scope(|scope| { + scope.spawn(|_| ()); + }).unwrap(); +} diff --git a/third_party/cargo/vendor/crossbeam-0.5.0/tests/wait_group.rs b/third_party/cargo/vendor/crossbeam-0.5.0/tests/wait_group.rs new file mode 100644 index 0000000..bd15f61 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-0.5.0/tests/wait_group.rs @@ -0,0 +1,66 @@ +extern crate crossbeam; + +use std::sync::mpsc; +use std::thread; +use std::time::Duration; + +use crossbeam::sync::WaitGroup; + +const THREADS: usize = 10; + +#[test] +fn wait() { + let wg = WaitGroup::new(); + let (tx, rx) = mpsc::channel(); + + for _ in 0..THREADS { + let wg = wg.clone(); + let tx = tx.clone(); + + thread::spawn(move || { + wg.wait(); + tx.send(()).unwrap(); + }); + } + + thread::sleep(Duration::from_millis(100)); + + // At this point, all spawned threads should be blocked, so we shouldn't get anything from the + // channel. + assert!(rx.try_recv().is_err()); + + wg.wait(); + + // Now, the wait group is cleared and we should receive messages. + for _ in 0..THREADS { + rx.recv().unwrap(); + } +} + +#[test] +fn wait_and_drop() { + let wg = WaitGroup::new(); + let (tx, rx) = mpsc::channel(); + + for _ in 0..THREADS { + let wg = wg.clone(); + let tx = tx.clone(); + + thread::spawn(move || { + thread::sleep(Duration::from_millis(100)); + tx.send(()).unwrap(); + drop(wg); + }); + } + + // At this point, all spawned threads should be sleeping, so we shouldn't get anything from the + // channel. + assert!(rx.try_recv().is_err()); + + wg.wait(); + + // Now, the wait group is cleared and we should receive messages. + for _ in 0..THREADS { + rx.try_recv().unwrap(); + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/.cargo-checksum.json b/third_party/cargo/vendor/crossbeam-channel-0.3.9/.cargo-checksum.json new file mode 100644 index 0000000..30e766e --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"accbc6a8bd5581eebf4322ebd693a4594a991ab80f6ddbac113f30ec2c09d46f","Cargo.toml":"ee485fd4a91cbb65fcc1ee07e4dc1e76a3cbe61fa49626653fb1b95ee96a3f06","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","LICENSE-THIRD-PARTY":"924a49392dc8304def57586be4ebd69aaf51e16fd245b55b4b69ad2cce6b715a","README.md":"996dd8dedfb47a96f8c3b15abef9045285372893ed2f3ba89354d28a0af1c779","benches/crossbeam.rs":"baef02dffd58ee4d84d33a4e999254e81fcf45241623cfa6c4b1ef73dbd7479d","examples/fibonacci.rs":"8755bcb9cf05e391d8679fbb51db40ed9692703c3b66341cd1c1e4cca2068874","examples/matching.rs":"a1bdd7d211cf8612d649de3de3e24f56e911bc8d5e95b86b06f412314f9edd6c","examples/stopwatch.rs":"4e90ce134475859a421da0a095baea52a575b03e41fb8fb50cf47446f422ee6e","src/channel.rs":"4483ddf38c4b9b308b81dd156653ccb590524aae1e5ff8efcab6b8f44a8d3dfc","src/context.rs":"48eb848538482aeadd5bafb8fd24695dcf5635243d6f9d3b059a22538ce67014","src/counter.rs":"8b6d4d69db59bc992ddc7ed33f709788c3fab482521bb1adf985f77499506c09","src/err.rs":"1a9ac9d7f4d5561f9c3e513b2f776782783954efa0bf9428598f3ad9ccb9d5c9","src/flavors/after.rs":"4f761618efe21036145e44f01506bdfbc2524879368ac138600e0feed921a6a7","src/flavors/array.rs":"3726a68712c3ba25a325fe91fc74da831d27e22e751d0b8d5dfd9d7022f54e04","src/flavors/list.rs":"969f925ea094d7d4e25b7ff294ea5c9a62cdae17238b41b915ece211def666fe","src/flavors/mod.rs":"a5af9b6105207e293c0d64928b4486fb1da9bfe0318354c66c8b5069e41ec31f","src/flavors/never.rs":"86e21b4d8b154e5d795cf72c7203a1d16a846c4d670095c8b592c12569f35a98","src/flavors/tick.rs":"654e7874805eb37d1fbd81d88ca23697a05eeaaa308b748860b9d2342f9752bd","src/flavors/zero.rs":"a24c2fb547586ab4bf2a09efb8af5264274f7b373749cd259a7dd3c843c8aac5","src/lib.rs":"854539dd0e7519bb3b087269d294930dc1f5b1880a98f5ede9e9d6ac33ea9f21","src/select.rs":"56788172014c4f3365493f63506f252235142063a7b8af6d707d81aec3f6f40a","src/select_macro.rs":"fa4fd99e1eab0eed621106f9286cf767d14a0d7d446142937e9cce3b0a6723ad","src/utils.rs":"8b1184222df9047355e6044ad7e3fefd6065a5dda98b968cae45cca5f4b2fb5d","src/waker.rs":"345b551d467389a3a18dc22b351674dfbf288945b984450f607e644faa8a9731","tests/after.rs":"effb341c02f03a45ce09ab7862bc5b191191e0175997c494f988e6daca1ef8af","tests/array.rs":"3987b6cb98b38fbda6061106e8fe1794f9c73b119508a4f7fc1ff3f5af3872a4","tests/golang.rs":"84875ee41f19d7475de697f1bb5e93535b9e1fe0c90f76f1a2dbdfcc46aec30a","tests/iter.rs":"b6df3f21273bb21dfecda47ffc0c296541214cde6bed876a31db5f2410839e83","tests/list.rs":"531891f8f2e9961c729174063eeb2ef7a141b5f7883abf10ea14d11feac12423","tests/mpsc.rs":"965e18abbfcdebec09380f8ec9bb62e5556ad2aa0176ed088ce091994c1d2500","tests/never.rs":"cd455a4c78403d9a96fe0f3a4e968164cca533cc85c96aaa4558987f9b088fcc","tests/ready.rs":"8d394399aed5c928b9764493709e2907a652c909b4968abd26ce4801dffc5d69","tests/same_channel.rs":"bd93f72e982f9881235848a4a2da67276feca810ed1e4d22e0e2bda8675cae4a","tests/select.rs":"1b23969236f443a129c1dd4a4c5930c3ee60ecd04614ef7ef67d470bceef8d53","tests/select_macro.rs":"2fb99a1d72185301cad010e2c923bbf612ab9149ce0fe72b8e8f9068f7772322","tests/thread_locals.rs":"845f8c8f1a37a14e4235fc9fc20d8b7288fd9fda307c075c0e61e6ab79b33921","tests/tick.rs":"dd4257f1f8de01477d542e20a816eede3b4e2e4dc6fcdf07d554220f0ef8a86f","tests/zero.rs":"f65f69127bc0bc84e2c2b42cd3384ce5b099eb4d11b3df079b88f3f3ca5edb0a"},"package":"c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa"} \ No newline at end of file diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/BUILD b/third_party/cargo/vendor/crossbeam-channel-0.3.9/BUILD new file mode 100644 index 0000000..5788523 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/BUILD @@ -0,0 +1,62 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" + "restricted", # "Apache-2.0 AND BSD-2-Clause" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "after" with type "test" omitted +# Unsupported target "array" with type "test" omitted +# Unsupported target "crossbeam" with type "bench" omitted + +rust_library( + name = "crossbeam_channel", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/crossbeam-utils-0.6.6:crossbeam_utils", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.3.9", + crate_features = [ + ], +) + +# Unsupported target "fibonacci" with type "example" omitted +# Unsupported target "golang" with type "test" omitted +# Unsupported target "iter" with type "test" omitted +# Unsupported target "list" with type "test" omitted +# Unsupported target "matching" with type "example" omitted +# Unsupported target "mpsc" with type "test" omitted +# Unsupported target "never" with type "test" omitted +# Unsupported target "ready" with type "test" omitted +# Unsupported target "same_channel" with type "test" omitted +# Unsupported target "select" with type "test" omitted +# Unsupported target "select_macro" with type "test" omitted +# Unsupported target "stopwatch" with type "example" omitted +# Unsupported target "thread_locals" with type "test" omitted +# Unsupported target "tick" with type "test" omitted +# Unsupported target "zero" with type "test" omitted diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/CHANGELOG.md b/third_party/cargo/vendor/crossbeam-channel-0.3.9/CHANGELOG.md new file mode 100644 index 0000000..505ad25 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/CHANGELOG.md @@ -0,0 +1,144 @@ +# Version 0.3.9 + +- Fix a bug in reference counting. +- Optimize `recv_timeout()`. +- Add `Select::remove()`. +- Various small improvements, code cleanup, more tests. + +# Version 0.3.8 + +- Bump the minimum required version of `crossbeam-utils`. + +# Version 0.3.7 + +- Remove `parking_lot` and `rand` dependencies. +- Expand documentation. +- Implement `Default` for `Select`. +- Make `size_of::>()` smaller. +- Several minor optimizations. +- Add more tests. + +# Version 0.3.6 + +- Fix a bug in initialization of unbounded channels. + +# Version 0.3.5 + +- New implementation for unbounded channels. +- A number of small performance improvements. +- Remove `crossbeam-epoch` dependency. + +# Version 0.3.4 + +- Bump `crossbeam-epoch` to `0.7`. +- Improve documentation. + +# Version 0.3.3 + +- Relax the lifetime in `SelectedOperation<'_>`. +- Add `Select::try_ready()`, `Select::ready()`, and `Select::ready_timeout()`. +- Update licensing notices. +- Improve documentation. +- Add methods `is_disconnected()`, `is_timeout()`, `is_empty()`, and `is_full()` on error types. + +# Version 0.3.2 + +- More elaborate licensing notices. + +# Version 0.3.1 + +- Update `crossbeam-utils` to `0.6`. + +# Version 0.3.0 + +- Add a special `never` channel type. +- Dropping all receivers now closes the channel. +- The interface of sending and receiving methods is now very similar to those in v0.1. +- The syntax for `send` in `select!` is now `send(sender, msg) -> res => body`. +- The syntax for `recv` in `select!` is now `recv(receiver) -> res => body`. +- New, more efficient interface for `Select` without callbacks. +- Timeouts can be specified in `select!`. + +# Version 0.2.6 + +- `Select` struct that can add cases dynamically. +- More documentation (in particular, the FAQ section). +- Optimize contended sends/receives in unbounded channels. + +# Version 0.2.5 + +- Use `LocalKey::try_with` instead of `LocalKey::with`. +- Remove helper macros `__crossbeam_channel*`. + +# Version 0.2.4 + +- Make `select!` linearizable with other channel operations. +- Update `crossbeam-utils` to `0.5.0`. +- Update `parking_lot` to `0.6.3`. +- Remove Mac OS X tests. + +# Version 0.2.3 + +- Add Mac OS X tests. +- Lower some memory orderings. +- Eliminate calls to `mem::unitialized`, which caused bugs with ZST. + +# Version 0.2.2 + +- Add more tests. +- Update `crossbeam-epoch` to 0.5.0 +- Initialize the RNG seed to a random value. +- Replace `libc::abort` with `std::process::abort`. +- Ignore clippy warnings in `select!`. +- Better interaction of `select!` with the NLL borrow checker. + +# Version 0.2.1 + +- Fix compilation errors when using `select!` with `#[deny(unsafe_code)]`. + +# Version 0.2.0 + +- Implement `IntoIterator` for `Receiver`. +- Add a new `select!` macro. +- Add special channels `after` and `tick`. +- Dropping receivers doesn't close the channel anymore. +- Change the signature of `recv`, `send`, and `try_recv`. +- Remove `Sender::is_closed` and `Receiver::is_closed`. +- Remove `Sender::close` and `Receiver::close`. +- Remove `Sender::send_timeout` and `Receiver::recv_timeout`. +- Remove `Sender::try_send`. +- Remove `Select` and `select_loop!`. +- Remove all error types. +- Remove `Iter`, `TryIter`, and `IntoIter`. +- Remove the `nightly` feature. +- Remove ordering operators for `Sender` and `Receiver`. + +# Version 0.1.3 + +- Add `Sender::disconnect` and `Receiver::disconnect`. +- Implement comparison operators for `Sender` and `Receiver`. +- Allow arbitrary patterns in place of `msg` in `recv(r, msg)`. +- Add a few conversion impls between error types. +- Add benchmarks for `atomicring` and `mpmc`. +- Add benchmarks for different message sizes. +- Documentation improvements. +- Update `crossbeam-epoch` to 0.4.0 +- Update `crossbeam-utils` to 0.3.0 +- Update `parking_lot` to 0.5 +- Update `rand` to 0.4 + +# Version 0.1.2 + +- Allow conditional cases in `select_loop!` macro. +- Fix typos in documentation. +- Fix deadlock in selection when all channels are disconnected and a timeout is specified. + +# Version 0.1.1 + +- Implement `Debug` for `Sender`, `Receiver`, `Iter`, `TryIter`, `IntoIter`, and `Select`. +- Implement `Default` for `Select`. + +# Version 0.1.0 + +- First implementation of the channels. +- Add `select_loop!` macro by @TimNN. diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/Cargo.toml b/third_party/cargo/vendor/crossbeam-channel-0.3.9/Cargo.toml new file mode 100644 index 0000000..1e36a44 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/Cargo.toml @@ -0,0 +1,34 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "crossbeam-channel" +version = "0.3.9" +authors = ["The Crossbeam Project Developers"] +description = "Multi-producer multi-consumer channels for message passing" +homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel" +documentation = "https://docs.rs/crossbeam-channel" +readme = "README.md" +keywords = ["channel", "mpmc", "select", "golang", "message"] +categories = ["algorithms", "concurrency", "data-structures"] +license = "MIT/Apache-2.0 AND BSD-2-Clause" +repository = "https://github.com/crossbeam-rs/crossbeam" +[dependencies.crossbeam-utils] +version = "0.6.5" +[dev-dependencies.num_cpus] +version = "1.10.0" + +[dev-dependencies.rand] +version = "0.6" + +[dev-dependencies.signal-hook] +version = "0.1.5" diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/LICENSE-APACHE b/third_party/cargo/vendor/crossbeam-channel-0.3.9/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/LICENSE-MIT b/third_party/cargo/vendor/crossbeam-channel-0.3.9/LICENSE-MIT new file mode 100644 index 0000000..068d491 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/LICENSE-MIT @@ -0,0 +1,27 @@ +The MIT License (MIT) + +Copyright (c) 2019 The Crossbeam Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/LICENSE-THIRD-PARTY b/third_party/cargo/vendor/crossbeam-channel-0.3.9/LICENSE-THIRD-PARTY new file mode 100644 index 0000000..d15e32b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/LICENSE-THIRD-PARTY @@ -0,0 +1,625 @@ +=============================================================================== + +Bounded MPMC queue +http://www.1024cores.net/home/code-license + +Copyright (c) 2010-2011 Dmitry Vyukov. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY DMITRY VYUKOV "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL DMITRY VYUKOV OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of Dmitry Vyukov. + +=============================================================================== + +matching.go +https://creativecommons.org/licenses/by/3.0/legalcode + +Creative Commons Legal Code + +Attribution 3.0 Unported + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR + DAMAGES RESULTING FROM ITS USE. + +License + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE +COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY +COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS +AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE +TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY +BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS +CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND +CONDITIONS. + +1. Definitions + + a. "Adaptation" means a work based upon the Work, or upon the Work and + other pre-existing works, such as a translation, adaptation, + derivative work, arrangement of music or other alterations of a + literary or artistic work, or phonogram or performance and includes + cinematographic adaptations or any other form in which the Work may be + recast, transformed, or adapted including in any form recognizably + derived from the original, except that a work that constitutes a + Collection will not be considered an Adaptation for the purpose of + this License. For the avoidance of doubt, where the Work is a musical + work, performance or phonogram, the synchronization of the Work in + timed-relation with a moving image ("synching") will be considered an + Adaptation for the purpose of this License. + b. "Collection" means a collection of literary or artistic works, such as + encyclopedias and anthologies, or performances, phonograms or + broadcasts, or other works or subject matter other than works listed + in Section 1(f) below, which, by reason of the selection and + arrangement of their contents, constitute intellectual creations, in + which the Work is included in its entirety in unmodified form along + with one or more other contributions, each constituting separate and + independent works in themselves, which together are assembled into a + collective whole. A work that constitutes a Collection will not be + considered an Adaptation (as defined above) for the purposes of this + License. + c. "Distribute" means to make available to the public the original and + copies of the Work or Adaptation, as appropriate, through sale or + other transfer of ownership. + d. "Licensor" means the individual, individuals, entity or entities that + offer(s) the Work under the terms of this License. + e. "Original Author" means, in the case of a literary or artistic work, + the individual, individuals, entity or entities who created the Work + or if no individual or entity can be identified, the publisher; and in + addition (i) in the case of a performance the actors, singers, + musicians, dancers, and other persons who act, sing, deliver, declaim, + play in, interpret or otherwise perform literary or artistic works or + expressions of folklore; (ii) in the case of a phonogram the producer + being the person or legal entity who first fixes the sounds of a + performance or other sounds; and, (iii) in the case of broadcasts, the + organization that transmits the broadcast. + f. "Work" means the literary and/or artistic work offered under the terms + of this License including without limitation any production in the + literary, scientific and artistic domain, whatever may be the mode or + form of its expression including digital form, such as a book, + pamphlet and other writing; a lecture, address, sermon or other work + of the same nature; a dramatic or dramatico-musical work; a + choreographic work or entertainment in dumb show; a musical + composition with or without words; a cinematographic work to which are + assimilated works expressed by a process analogous to cinematography; + a work of drawing, painting, architecture, sculpture, engraving or + lithography; a photographic work to which are assimilated works + expressed by a process analogous to photography; a work of applied + art; an illustration, map, plan, sketch or three-dimensional work + relative to geography, topography, architecture or science; a + performance; a broadcast; a phonogram; a compilation of data to the + extent it is protected as a copyrightable work; or a work performed by + a variety or circus performer to the extent it is not otherwise + considered a literary or artistic work. + g. "You" means an individual or entity exercising rights under this + License who has not previously violated the terms of this License with + respect to the Work, or who has received express permission from the + Licensor to exercise rights under this License despite a previous + violation. + h. "Publicly Perform" means to perform public recitations of the Work and + to communicate to the public those public recitations, by any means or + process, including by wire or wireless means or public digital + performances; to make available to the public Works in such a way that + members of the public may access these Works from a place and at a + place individually chosen by them; to perform the Work to the public + by any means or process and the communication to the public of the + performances of the Work, including by public digital performance; to + broadcast and rebroadcast the Work by any means including signs, + sounds or images. + i. "Reproduce" means to make copies of the Work by any means including + without limitation by sound or visual recordings and the right of + fixation and reproducing fixations of the Work, including storage of a + protected performance or phonogram in digital form or other electronic + medium. + +2. Fair Dealing Rights. Nothing in this License is intended to reduce, +limit, or restrict any uses free from copyright or rights arising from +limitations or exceptions that are provided for in connection with the +copyright protection under copyright law or other applicable laws. + +3. License Grant. Subject to the terms and conditions of this License, +Licensor hereby grants You a worldwide, royalty-free, non-exclusive, +perpetual (for the duration of the applicable copyright) license to +exercise the rights in the Work as stated below: + + a. to Reproduce the Work, to incorporate the Work into one or more + Collections, and to Reproduce the Work as incorporated in the + Collections; + b. to create and Reproduce Adaptations provided that any such Adaptation, + including any translation in any medium, takes reasonable steps to + clearly label, demarcate or otherwise identify that changes were made + to the original Work. For example, a translation could be marked "The + original work was translated from English to Spanish," or a + modification could indicate "The original work has been modified."; + c. to Distribute and Publicly Perform the Work including as incorporated + in Collections; and, + d. to Distribute and Publicly Perform Adaptations. + e. For the avoidance of doubt: + + i. Non-waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme cannot be waived, the Licensor + reserves the exclusive right to collect such royalties for any + exercise by You of the rights granted under this License; + ii. Waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme can be waived, the Licensor waives the + exclusive right to collect such royalties for any exercise by You + of the rights granted under this License; and, + iii. Voluntary License Schemes. The Licensor waives the right to + collect royalties, whether individually or, in the event that the + Licensor is a member of a collecting society that administers + voluntary licensing schemes, via that society, from any exercise + by You of the rights granted under this License. + +The above rights may be exercised in all media and formats whether now +known or hereafter devised. The above rights include the right to make +such modifications as are technically necessary to exercise the rights in +other media and formats. Subject to Section 8(f), all rights not expressly +granted by Licensor are hereby reserved. + +4. Restrictions. The license granted in Section 3 above is expressly made +subject to and limited by the following restrictions: + + a. You may Distribute or Publicly Perform the Work only under the terms + of this License. You must include a copy of, or the Uniform Resource + Identifier (URI) for, this License with every copy of the Work You + Distribute or Publicly Perform. You may not offer or impose any terms + on the Work that restrict the terms of this License or the ability of + the recipient of the Work to exercise the rights granted to that + recipient under the terms of the License. You may not sublicense the + Work. You must keep intact all notices that refer to this License and + to the disclaimer of warranties with every copy of the Work You + Distribute or Publicly Perform. When You Distribute or Publicly + Perform the Work, You may not impose any effective technological + measures on the Work that restrict the ability of a recipient of the + Work from You to exercise the rights granted to that recipient under + the terms of the License. This Section 4(a) applies to the Work as + incorporated in a Collection, but this does not require the Collection + apart from the Work itself to be made subject to the terms of this + License. If You create a Collection, upon notice from any Licensor You + must, to the extent practicable, remove from the Collection any credit + as required by Section 4(b), as requested. If You create an + Adaptation, upon notice from any Licensor You must, to the extent + practicable, remove from the Adaptation any credit as required by + Section 4(b), as requested. + b. If You Distribute, or Publicly Perform the Work or any Adaptations or + Collections, You must, unless a request has been made pursuant to + Section 4(a), keep intact all copyright notices for the Work and + provide, reasonable to the medium or means You are utilizing: (i) the + name of the Original Author (or pseudonym, if applicable) if supplied, + and/or if the Original Author and/or Licensor designate another party + or parties (e.g., a sponsor institute, publishing entity, journal) for + attribution ("Attribution Parties") in Licensor's copyright notice, + terms of service or by other reasonable means, the name of such party + or parties; (ii) the title of the Work if supplied; (iii) to the + extent reasonably practicable, the URI, if any, that Licensor + specifies to be associated with the Work, unless such URI does not + refer to the copyright notice or licensing information for the Work; + and (iv) , consistent with Section 3(b), in the case of an Adaptation, + a credit identifying the use of the Work in the Adaptation (e.g., + "French translation of the Work by Original Author," or "Screenplay + based on original Work by Original Author"). The credit required by + this Section 4 (b) may be implemented in any reasonable manner; + provided, however, that in the case of a Adaptation or Collection, at + a minimum such credit will appear, if a credit for all contributing + authors of the Adaptation or Collection appears, then as part of these + credits and in a manner at least as prominent as the credits for the + other contributing authors. For the avoidance of doubt, You may only + use the credit required by this Section for the purpose of attribution + in the manner set out above and, by exercising Your rights under this + License, You may not implicitly or explicitly assert or imply any + connection with, sponsorship or endorsement by the Original Author, + Licensor and/or Attribution Parties, as appropriate, of You or Your + use of the Work, without the separate, express prior written + permission of the Original Author, Licensor and/or Attribution + Parties. + c. Except as otherwise agreed in writing by the Licensor or as may be + otherwise permitted by applicable law, if You Reproduce, Distribute or + Publicly Perform the Work either by itself or as part of any + Adaptations or Collections, You must not distort, mutilate, modify or + take other derogatory action in relation to the Work which would be + prejudicial to the Original Author's honor or reputation. Licensor + agrees that in those jurisdictions (e.g. Japan), in which any exercise + of the right granted in Section 3(b) of this License (the right to + make Adaptations) would be deemed to be a distortion, mutilation, + modification or other derogatory action prejudicial to the Original + Author's honor and reputation, the Licensor will waive or not assert, + as appropriate, this Section, to the fullest extent permitted by the + applicable national law, to enable You to reasonably exercise Your + right under Section 3(b) of this License (right to make Adaptations) + but not otherwise. + +5. Representations, Warranties and Disclaimer + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR +OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY +KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, +INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, +FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF +LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, +WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. + +6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE +LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR +ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES +ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. Termination + + a. This License and the rights granted hereunder will terminate + automatically upon any breach by You of the terms of this License. + Individuals or entities who have received Adaptations or Collections + from You under this License, however, will not have their licenses + terminated provided such individuals or entities remain in full + compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will + survive any termination of this License. + b. Subject to the above terms and conditions, the license granted here is + perpetual (for the duration of the applicable copyright in the Work). + Notwithstanding the above, Licensor reserves the right to release the + Work under different license terms or to stop distributing the Work at + any time; provided, however that any such election will not serve to + withdraw this License (or any other license that has been, or is + required to be, granted under the terms of this License), and this + License will continue in full force and effect unless terminated as + stated above. + +8. Miscellaneous + + a. Each time You Distribute or Publicly Perform the Work or a Collection, + the Licensor offers to the recipient a license to the Work on the same + terms and conditions as the license granted to You under this License. + b. Each time You Distribute or Publicly Perform an Adaptation, Licensor + offers to the recipient a license to the original Work on the same + terms and conditions as the license granted to You under this License. + c. If any provision of this License is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability of + the remainder of the terms of this License, and without further action + by the parties to this agreement, such provision shall be reformed to + the minimum extent necessary to make such provision valid and + enforceable. + d. No term or provision of this License shall be deemed waived and no + breach consented to unless such waiver or consent shall be in writing + and signed by the party to be charged with such waiver or consent. + e. This License constitutes the entire agreement between the parties with + respect to the Work licensed here. There are no understandings, + agreements or representations with respect to the Work not specified + here. Licensor shall not be bound by any additional provisions that + may appear in any communication from You. This License may not be + modified without the mutual written agreement of the Licensor and You. + f. The rights granted under, and the subject matter referenced, in this + License were drafted utilizing the terminology of the Berne Convention + for the Protection of Literary and Artistic Works (as amended on + September 28, 1979), the Rome Convention of 1961, the WIPO Copyright + Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 + and the Universal Copyright Convention (as revised on July 24, 1971). + These rights and subject matter take effect in the relevant + jurisdiction in which the License terms are sought to be enforced + according to the corresponding provisions of the implementation of + those treaty provisions in the applicable national law. If the + standard suite of rights granted under applicable copyright law + includes additional rights not granted under this License, such + additional rights are deemed to be included in the License; this + License is not intended to restrict the license of any rights under + applicable law. + + +Creative Commons Notice + + Creative Commons is not a party to this License, and makes no warranty + whatsoever in connection with the Work. Creative Commons will not be + liable to You or any party on any legal theory for any damages + whatsoever, including without limitation any general, special, + incidental or consequential damages arising in connection to this + license. Notwithstanding the foregoing two (2) sentences, if Creative + Commons has expressly identified itself as the Licensor hereunder, it + shall have all rights and obligations of Licensor. + + Except for the limited purpose of indicating to the public that the + Work is licensed under the CCPL, Creative Commons does not authorize + the use by either party of the trademark "Creative Commons" or any + related trademark or logo of Creative Commons without the prior + written consent of Creative Commons. Any permitted use will be in + compliance with Creative Commons' then-current trademark usage + guidelines, as may be published on its website or otherwise made + available upon request from time to time. For the avoidance of doubt, + this trademark restriction does not form part of this License. + + Creative Commons may be contacted at https://creativecommons.org/. + +=============================================================================== + +The Go Programming Language +https://golang.org/LICENSE + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================== + +The Rust Programming Language +https://github.com/rust-lang/rust/blob/master/LICENSE-MIT + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +=============================================================================== + +The Rust Programming Language +https://github.com/rust-lang/rust/blob/master/LICENSE-APACHE + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/README.md b/third_party/cargo/vendor/crossbeam-channel-0.3.9/README.md new file mode 100644 index 0000000..2e16a04 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/README.md @@ -0,0 +1,89 @@ +# Crossbeam Channel + +[![Build Status](https://travis-ci.org/crossbeam-rs/crossbeam.svg?branch=master)]( +https://travis-ci.org/crossbeam-rs/crossbeam) +[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)]( +https://github.com/crossbeam-rs/crossbeam-channel) +[![Cargo](https://img.shields.io/crates/v/crossbeam-channel.svg)]( +https://crates.io/crates/crossbeam-channel) +[![Documentation](https://docs.rs/crossbeam-channel/badge.svg)]( +https://docs.rs/crossbeam-channel) +[![Rust 1.26+](https://img.shields.io/badge/rust-1.26+-lightgray.svg)]( +https://www.rust-lang.org) +[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq) + +This crate provides multi-producer multi-consumer channels for message passing. +It is an alternative to [`std::sync::mpsc`] with more features and better performance. + +Some highlights: + +* [`Sender`]s and [`Receiver`]s can be cloned and shared among threads. +* Two main kinds of channels are [`bounded`] and [`unbounded`]. +* Convenient extra channels like [`after`], [`never`], and [`tick`]. +* The [`select!`] macro can block on multiple channel operations. +* [`Select`] can select over a dynamically built list of channel operations. +* Channels use locks very sparingly for maximum [performance](benchmarks). + +[`std::sync::mpsc`]: https://doc.rust-lang.org/std/sync/mpsc/index.html +[`Sender`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/struct.Sender.html +[`Receiver`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/struct.Receiver.html +[`bounded`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/fn.bounded.html +[`unbounded`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/fn.unbounded.html +[`after`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/fn.after.html +[`never`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/fn.never.html +[`tick`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/fn.tick.html +[`select!`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/macro.select.html +[`Select`]: https://docs.rs/crossbeam-channel/*/crossbeam_channel/struct.Select.html + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +crossbeam-channel = "0.3" +``` + +Next, add this to your crate: + +```rust +#[macro_use] +extern crate crossbeam_channel; +``` + +## License + +Licensed under either of + + * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +#### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. + +#### Third party software + +This product includes copies and modifications of software developed by third parties: + +* [examples/matching.rs](examples/matching.rs) includes + [matching.go](http://www.nada.kth.se/~snilsson/concurrency/src/matching.go) by Stefan Nilsson, + licensed under Creative Commons Attribution 3.0 Unported License. + +* [src/flavors/array.rs](src/flavors/array.rs) is based on + [Bounded MPMC queue](http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue) + by Dmitry Vyukov, licensed under the Simplified BSD License and the Apache License, Version 2.0. + +* [tests/mpsc.rs](tests/mpsc.rs) includes modifications of code from The Rust Programming Language, + licensed under the MIT License and the Apache License, Version 2.0. + +* [tests/golang.rs](tests/golang.rs) is based on code from The Go Programming Language, licensed + under the 3-Clause BSD License. + +See the source code files for more details. + +Copies of third party licenses can be found in [LICENSE-THIRD-PARTY](LICENSE-THIRD-PARTY). diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/benches/crossbeam.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/benches/crossbeam.rs new file mode 100644 index 0000000..4dd956b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/benches/crossbeam.rs @@ -0,0 +1,715 @@ +#![feature(test)] + +extern crate crossbeam_channel; +extern crate crossbeam_utils; +extern crate num_cpus; +extern crate test; + +use crossbeam_channel::{bounded, unbounded}; +use crossbeam_utils::thread::scope; +use test::Bencher; + +const TOTAL_STEPS: usize = 40_000; + +mod unbounded { + use super::*; + + #[bench] + fn create(b: &mut Bencher) { + b.iter(|| unbounded::()); + } + + #[bench] + fn oneshot(b: &mut Bencher) { + b.iter(|| { + let (s, r) = unbounded::(); + s.send(0).unwrap(); + r.recv().unwrap(); + }); + } + + #[bench] + fn inout(b: &mut Bencher) { + let (s, r) = unbounded::(); + b.iter(|| { + s.send(0).unwrap(); + r.recv().unwrap(); + }); + } + + #[bench] + fn par_inout(b: &mut Bencher) { + let threads = num_cpus::get(); + let steps = TOTAL_STEPS / threads; + let (s, r) = unbounded::(); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + r.recv().unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn spsc(b: &mut Bencher) { + let steps = TOTAL_STEPS; + let (s, r) = unbounded::(); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + + b.iter(|| { + s1.send(()).unwrap(); + for _ in 0..steps { + r.recv().unwrap(); + } + r2.recv().unwrap(); + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn spmc(b: &mut Bencher) { + let threads = num_cpus::get() - 1; + let steps = TOTAL_STEPS / threads; + let (s, r) = unbounded::(); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads { + scope.spawn(|_| { + while r1.recv().is_ok() { + for _ in 0..steps { + r.recv().unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for i in 0..steps * threads { + s.send(i as i32).unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn mpsc(b: &mut Bencher) { + let threads = num_cpus::get() - 1; + let steps = TOTAL_STEPS / threads; + let (s, r) = unbounded::(); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for _ in 0..steps * threads { + r.recv().unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn mpmc(b: &mut Bencher) { + let threads = num_cpus::get(); + let steps = TOTAL_STEPS / threads; + let (s, r) = unbounded::(); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads / 2 { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + for _ in 0..threads / 2 { + scope.spawn(|_| { + while r1.recv().is_ok() { + for _ in 0..steps { + r.recv().unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } +} + +mod bounded_n { + use super::*; + + #[bench] + fn spsc(b: &mut Bencher) { + let steps = TOTAL_STEPS; + let (s, r) = bounded::(steps); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + + b.iter(|| { + s1.send(()).unwrap(); + for _ in 0..steps { + r.recv().unwrap(); + } + r2.recv().unwrap(); + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn spmc(b: &mut Bencher) { + let threads = num_cpus::get() - 1; + let steps = TOTAL_STEPS / threads; + let (s, r) = bounded::(steps * threads); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads { + scope.spawn(|_| { + while r1.recv().is_ok() { + for _ in 0..steps { + r.recv().unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for i in 0..steps * threads { + s.send(i as i32).unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn mpsc(b: &mut Bencher) { + let threads = num_cpus::get() - 1; + let steps = TOTAL_STEPS / threads; + let (s, r) = bounded::(steps * threads); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for _ in 0..steps * threads { + r.recv().unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn par_inout(b: &mut Bencher) { + let threads = num_cpus::get(); + let steps = TOTAL_STEPS / threads; + let (s, r) = bounded::(threads); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + r.recv().unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn mpmc(b: &mut Bencher) { + let threads = num_cpus::get(); + assert_eq!(threads % 2, 0); + let steps = TOTAL_STEPS / threads; + let (s, r) = bounded::(steps * threads); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads / 2 { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + for _ in 0..threads / 2 { + scope.spawn(|_| { + while r1.recv().is_ok() { + for _ in 0..steps { + r.recv().unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } +} + +mod bounded_1 { + use super::*; + + #[bench] + fn create(b: &mut Bencher) { + b.iter(|| bounded::(1)); + } + + #[bench] + fn oneshot(b: &mut Bencher) { + b.iter(|| { + let (s, r) = bounded::(1); + s.send(0).unwrap(); + r.recv().unwrap(); + }); + } + + #[bench] + fn spsc(b: &mut Bencher) { + let steps = TOTAL_STEPS; + let (s, r) = bounded::(1); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + + b.iter(|| { + s1.send(()).unwrap(); + for _ in 0..steps { + r.recv().unwrap(); + } + r2.recv().unwrap(); + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn spmc(b: &mut Bencher) { + let threads = num_cpus::get() - 1; + let steps = TOTAL_STEPS / threads; + let (s, r) = bounded::(1); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads { + scope.spawn(|_| { + while r1.recv().is_ok() { + for _ in 0..steps { + r.recv().unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for i in 0..steps * threads { + s.send(i as i32).unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn mpsc(b: &mut Bencher) { + let threads = num_cpus::get() - 1; + let steps = TOTAL_STEPS / threads; + let (s, r) = bounded::(1); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for _ in 0..steps * threads { + r.recv().unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn mpmc(b: &mut Bencher) { + let threads = num_cpus::get(); + let steps = TOTAL_STEPS / threads; + let (s, r) = bounded::(1); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads / 2 { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + for _ in 0..threads / 2 { + scope.spawn(|_| { + while r1.recv().is_ok() { + for _ in 0..steps { + r.recv().unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } +} + +mod bounded_0 { + use super::*; + + #[bench] + fn create(b: &mut Bencher) { + b.iter(|| bounded::(0)); + } + + #[bench] + fn spsc(b: &mut Bencher) { + let steps = TOTAL_STEPS; + let (s, r) = bounded::(0); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + + b.iter(|| { + s1.send(()).unwrap(); + for _ in 0..steps { + r.recv().unwrap(); + } + r2.recv().unwrap(); + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn spmc(b: &mut Bencher) { + let threads = num_cpus::get() - 1; + let steps = TOTAL_STEPS / threads; + let (s, r) = bounded::(0); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads { + scope.spawn(|_| { + while r1.recv().is_ok() { + for _ in 0..steps { + r.recv().unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for i in 0..steps * threads { + s.send(i as i32).unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn mpsc(b: &mut Bencher) { + let threads = num_cpus::get() - 1; + let steps = TOTAL_STEPS / threads; + let (s, r) = bounded::(0); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for _ in 0..steps * threads { + r.recv().unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } + + #[bench] + fn mpmc(b: &mut Bencher) { + let threads = num_cpus::get(); + let steps = TOTAL_STEPS / threads; + let (s, r) = bounded::(0); + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + scope(|scope| { + for _ in 0..threads / 2 { + scope.spawn(|_| { + while r1.recv().is_ok() { + for i in 0..steps { + s.send(i as i32).unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + for _ in 0..threads / 2 { + scope.spawn(|_| { + while r1.recv().is_ok() { + for _ in 0..steps { + r.recv().unwrap(); + } + s2.send(()).unwrap(); + } + }); + } + + b.iter(|| { + for _ in 0..threads { + s1.send(()).unwrap(); + } + for _ in 0..threads { + r2.recv().unwrap(); + } + }); + drop(s1); + }) + .unwrap(); + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/examples/fibonacci.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/examples/fibonacci.rs new file mode 100644 index 0000000..499887a --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/examples/fibonacci.rs @@ -0,0 +1,27 @@ +//! An asynchronous fibonacci sequence generator. + +extern crate crossbeam_channel; + +use std::thread; + +use crossbeam_channel::{bounded, Sender}; + +// Sends the Fibonacci sequence into the channel until it becomes disconnected. +fn fibonacci(sender: Sender) { + let (mut x, mut y) = (0, 1); + while sender.send(x).is_ok() { + let tmp = x; + x = y; + y = tmp + y; + } +} + +fn main() { + let (s, r) = bounded(0); + thread::spawn(|| fibonacci(s)); + + // Print the first 20 Fibonacci numbers. + for num in r.iter().take(20) { + println!("{}", num); + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/examples/matching.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/examples/matching.rs new file mode 100644 index 0000000..4b157ff --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/examples/matching.rs @@ -0,0 +1,76 @@ +//! Using `select!` to send and receive on the same channel at the same time. +//! +//! This example is based on the following program in Go. +//! +//! Source: +//! - https://web.archive.org/web/20171209034309/https://www.nada.kth.se/~snilsson/concurrency +//! - http://www.nada.kth.se/~snilsson/concurrency/src/matching.go +//! +//! Copyright & License: +//! - Stefan Nilsson +//! - Creative Commons Attribution 3.0 Unported License +//! - https://creativecommons.org/licenses/by/3.0/ +//! +//! ```go +//! func main() { +//! people := []string{"Anna", "Bob", "Cody", "Dave", "Eva"} +//! match := make(chan string, 1) // Make room for one unmatched send. +//! wg := new(sync.WaitGroup) +//! for _, name := range people { +//! wg.Add(1) +//! go Seek(name, match, wg) +//! } +//! wg.Wait() +//! select { +//! case name := <-match: +//! fmt.Printf("No one received %s’s message.\n", name) +//! default: +//! // There was no pending send operation. +//! } +//! } +//! +//! // Seek either sends or receives, whichever possible, a name on the match +//! // channel and notifies the wait group when done. +//! func Seek(name string, match chan string, wg *sync.WaitGroup) { +//! select { +//! case peer := <-match: +//! fmt.Printf("%s received a message from %s.\n", name, peer) +//! case match <- name: +//! // Wait for someone to receive my message. +//! } +//! wg.Done() +//! } +//! ``` + +#[macro_use] +extern crate crossbeam_channel; +extern crate crossbeam_utils; + +use crossbeam_channel::bounded; +use crossbeam_utils::thread; + +fn main() { + let people = vec!["Anna", "Bob", "Cody", "Dave", "Eva"]; + let (s, r) = bounded(1); // Make room for one unmatched send. + + // Either send my name into the channel or receive someone else's, whatever happens first. + let seek = |name, s, r| { + select! { + recv(r) -> peer => println!("{} received a message from {}.", name, peer.unwrap()), + send(s, name) -> _ => {}, // Wait for someone to receive my message. + } + }; + + thread::scope(|scope| { + for name in people { + let (s, r) = (s.clone(), r.clone()); + scope.spawn(move |_| seek(name, s, r)); + } + }) + .unwrap(); + + // Check if there is a pending send operation. + if let Ok(name) = r.try_recv() { + println!("No one received {}’s message.", name); + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/examples/stopwatch.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/examples/stopwatch.rs new file mode 100644 index 0000000..137ea21 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/examples/stopwatch.rs @@ -0,0 +1,58 @@ +//! Prints the elapsed time every 1 second and quits on Ctrl+C. + +#[macro_use] +extern crate crossbeam_channel; +extern crate signal_hook; + +use std::io; +use std::thread; +use std::time::{Duration, Instant}; + +use crossbeam_channel::{bounded, tick, Receiver}; +use signal_hook::iterator::Signals; +use signal_hook::SIGINT; + +// Creates a channel that gets a message every time `SIGINT` is signalled. +fn sigint_notifier() -> io::Result> { + let (s, r) = bounded(100); + let signals = Signals::new(&[SIGINT])?; + + thread::spawn(move || { + for _ in signals.forever() { + if s.send(()).is_err() { + break; + } + } + }); + + Ok(r) +} + +// Prints the elapsed time. +fn show(dur: Duration) { + println!( + "Elapsed: {}.{:03} sec", + dur.as_secs(), + dur.subsec_nanos() / 1_000_000 + ); +} + +fn main() { + let start = Instant::now(); + let update = tick(Duration::from_secs(1)); + let ctrl_c = sigint_notifier().unwrap(); + + loop { + select! { + recv(update) -> _ => { + show(start.elapsed()); + } + recv(ctrl_c) -> _ => { + println!(); + println!("Goodbye!"); + show(start.elapsed()); + break; + } + } + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/channel.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/channel.rs new file mode 100644 index 0000000..bc7908f --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/channel.rs @@ -0,0 +1,1389 @@ +//! The channel interface. + +use std::fmt; +use std::iter::FusedIterator; +use std::mem; +use std::panic::{RefUnwindSafe, UnwindSafe}; +use std::sync::Arc; +use std::time::{Duration, Instant}; + +use context::Context; +use counter; +use err::{RecvError, RecvTimeoutError, SendError, SendTimeoutError, TryRecvError, TrySendError}; +use flavors; +use select::{Operation, SelectHandle, Token}; + +/// Creates a channel of unbounded capacity. +/// +/// This channel has a growable buffer that can hold any number of messages at a time. +/// +/// # Examples +/// +/// ``` +/// use std::thread; +/// use crossbeam_channel::unbounded; +/// +/// let (s, r) = unbounded(); +/// +/// // Computes the n-th Fibonacci number. +/// fn fib(n: i32) -> i32 { +/// if n <= 1 { +/// n +/// } else { +/// fib(n - 1) + fib(n - 2) +/// } +/// } +/// +/// // Spawn an asynchronous computation. +/// thread::spawn(move || s.send(fib(20)).unwrap()); +/// +/// // Print the result of the computation. +/// println!("{}", r.recv().unwrap()); +/// ``` +pub fn unbounded() -> (Sender, Receiver) { + let (s, r) = counter::new(flavors::list::Channel::new()); + let s = Sender { + flavor: SenderFlavor::List(s), + }; + let r = Receiver { + flavor: ReceiverFlavor::List(r), + }; + (s, r) +} + +/// Creates a channel of bounded capacity. +/// +/// This channel has a buffer that can hold at most `cap` messages at a time. +/// +/// A special case is zero-capacity channel, which cannot hold any messages. Instead, send and +/// receive operations must appear at the same time in order to pair up and pass the message over. +/// +/// # Examples +/// +/// A channel of capacity 1: +/// +/// ``` +/// use std::thread; +/// use std::time::Duration; +/// use crossbeam_channel::bounded; +/// +/// let (s, r) = bounded(1); +/// +/// // This call returns immediately because there is enough space in the channel. +/// s.send(1).unwrap(); +/// +/// thread::spawn(move || { +/// // This call blocks the current thread because the channel is full. +/// // It will be able to complete only after the first message is received. +/// s.send(2).unwrap(); +/// }); +/// +/// thread::sleep(Duration::from_secs(1)); +/// assert_eq!(r.recv(), Ok(1)); +/// assert_eq!(r.recv(), Ok(2)); +/// ``` +/// +/// A zero-capacity channel: +/// +/// ``` +/// use std::thread; +/// use std::time::Duration; +/// use crossbeam_channel::bounded; +/// +/// let (s, r) = bounded(0); +/// +/// thread::spawn(move || { +/// // This call blocks the current thread until a receive operation appears +/// // on the other side of the channel. +/// s.send(1).unwrap(); +/// }); +/// +/// thread::sleep(Duration::from_secs(1)); +/// assert_eq!(r.recv(), Ok(1)); +/// ``` +pub fn bounded(cap: usize) -> (Sender, Receiver) { + if cap == 0 { + let (s, r) = counter::new(flavors::zero::Channel::new()); + let s = Sender { + flavor: SenderFlavor::Zero(s), + }; + let r = Receiver { + flavor: ReceiverFlavor::Zero(r), + }; + (s, r) + } else { + let (s, r) = counter::new(flavors::array::Channel::with_capacity(cap)); + let s = Sender { + flavor: SenderFlavor::Array(s), + }; + let r = Receiver { + flavor: ReceiverFlavor::Array(r), + }; + (s, r) + } +} + +/// Creates a receiver that delivers a message after a certain duration of time. +/// +/// The channel is bounded with capacity of 1 and never gets disconnected. Exactly one message will +/// be sent into the channel after `duration` elapses. The message is the instant at which it is +/// sent. +/// +/// # Examples +/// +/// Using an `after` channel for timeouts: +/// +/// ``` +/// # #[macro_use] +/// # extern crate crossbeam_channel; +/// # fn main() { +/// use std::time::Duration; +/// use crossbeam_channel::{after, unbounded}; +/// +/// let (s, r) = unbounded::(); +/// let timeout = Duration::from_millis(100); +/// +/// select! { +/// recv(r) -> msg => println!("received {:?}", msg), +/// recv(after(timeout)) -> _ => println!("timed out"), +/// } +/// # } +/// ``` +/// +/// When the message gets sent: +/// +/// ``` +/// use std::thread; +/// use std::time::{Duration, Instant}; +/// use crossbeam_channel::after; +/// +/// // Converts a number of milliseconds into a `Duration`. +/// let ms = |ms| Duration::from_millis(ms); +/// +/// // Returns `true` if `a` and `b` are very close `Instant`s. +/// let eq = |a, b| a + ms(50) > b && b + ms(50) > a; +/// +/// let start = Instant::now(); +/// let r = after(ms(100)); +/// +/// thread::sleep(ms(500)); +/// +/// // This message was sent 100 ms from the start and received 500 ms from the start. +/// assert!(eq(r.recv().unwrap(), start + ms(100))); +/// assert!(eq(Instant::now(), start + ms(500))); +/// ``` +pub fn after(duration: Duration) -> Receiver { + Receiver { + flavor: ReceiverFlavor::After(Arc::new(flavors::after::Channel::new(duration))), + } +} + +/// Creates a receiver that never delivers messages. +/// +/// The channel is bounded with capacity of 0 and never gets disconnected. +/// +/// # Examples +/// +/// Using a `never` channel to optionally add a timeout to [`select!`]: +/// +/// ``` +/// # #[macro_use] +/// # extern crate crossbeam_channel; +/// # fn main() { +/// use std::thread; +/// use std::time::{Duration, Instant}; +/// use crossbeam_channel::{after, never, unbounded}; +/// +/// let (s, r) = unbounded(); +/// +/// thread::spawn(move || { +/// thread::sleep(Duration::from_secs(1)); +/// s.send(1).unwrap(); +/// }); +/// +/// // Suppose this duration can be a `Some` or a `None`. +/// let duration = Some(Duration::from_millis(100)); +/// +/// // Create a channel that times out after the specified duration. +/// let timeout = duration +/// .map(|d| after(d)) +/// .unwrap_or(never()); +/// +/// select! { +/// recv(r) -> msg => assert_eq!(msg, Ok(1)), +/// recv(timeout) -> _ => println!("timed out"), +/// } +/// # } +/// ``` +/// +/// [`select!`]: macro.select.html +pub fn never() -> Receiver { + Receiver { + flavor: ReceiverFlavor::Never(flavors::never::Channel::new()), + } +} + +/// Creates a receiver that delivers messages periodically. +/// +/// The channel is bounded with capacity of 1 and never gets disconnected. Messages will be +/// sent into the channel in intervals of `duration`. Each message is the instant at which it is +/// sent. +/// +/// # Examples +/// +/// Using a `tick` channel to periodically print elapsed time: +/// +/// ``` +/// use std::time::{Duration, Instant}; +/// use crossbeam_channel::tick; +/// +/// let start = Instant::now(); +/// let ticker = tick(Duration::from_millis(100)); +/// +/// for _ in 0..5 { +/// ticker.recv().unwrap(); +/// println!("elapsed: {:?}", start.elapsed()); +/// } +/// ``` +/// +/// When messages get sent: +/// +/// ``` +/// use std::thread; +/// use std::time::{Duration, Instant}; +/// use crossbeam_channel::tick; +/// +/// // Converts a number of milliseconds into a `Duration`. +/// let ms = |ms| Duration::from_millis(ms); +/// +/// // Returns `true` if `a` and `b` are very close `Instant`s. +/// let eq = |a, b| a + ms(50) > b && b + ms(50) > a; +/// +/// let start = Instant::now(); +/// let r = tick(ms(100)); +/// +/// // This message was sent 100 ms from the start and received 100 ms from the start. +/// assert!(eq(r.recv().unwrap(), start + ms(100))); +/// assert!(eq(Instant::now(), start + ms(100))); +/// +/// thread::sleep(ms(500)); +/// +/// // This message was sent 200 ms from the start and received 600 ms from the start. +/// assert!(eq(r.recv().unwrap(), start + ms(200))); +/// assert!(eq(Instant::now(), start + ms(600))); +/// +/// // This message was sent 700 ms from the start and received 700 ms from the start. +/// assert!(eq(r.recv().unwrap(), start + ms(700))); +/// assert!(eq(Instant::now(), start + ms(700))); +/// ``` +pub fn tick(duration: Duration) -> Receiver { + Receiver { + flavor: ReceiverFlavor::Tick(Arc::new(flavors::tick::Channel::new(duration))), + } +} + +/// The sending side of a channel. +/// +/// # Examples +/// +/// ``` +/// use std::thread; +/// use crossbeam_channel::unbounded; +/// +/// let (s1, r) = unbounded(); +/// let s2 = s1.clone(); +/// +/// thread::spawn(move || s1.send(1).unwrap()); +/// thread::spawn(move || s2.send(2).unwrap()); +/// +/// let msg1 = r.recv().unwrap(); +/// let msg2 = r.recv().unwrap(); +/// +/// assert_eq!(msg1 + msg2, 3); +/// ``` +pub struct Sender { + flavor: SenderFlavor, +} + +/// Sender flavors. +enum SenderFlavor { + /// Bounded channel based on a preallocated array. + Array(counter::Sender>), + + /// Unbounded channel implemented as a linked list. + List(counter::Sender>), + + /// Zero-capacity channel. + Zero(counter::Sender>), +} + +unsafe impl Send for Sender {} +unsafe impl Sync for Sender {} + +impl UnwindSafe for Sender {} +impl RefUnwindSafe for Sender {} + +impl Sender { + /// Attempts to send a message into the channel without blocking. + /// + /// This method will either send a message into the channel immediately or return an error if + /// the channel is full or disconnected. The returned error contains the original message. + /// + /// If called on a zero-capacity channel, this method will send the message only if there + /// happens to be a receive operation on the other side of the channel at the same time. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::{bounded, TrySendError}; + /// + /// let (s, r) = bounded(1); + /// + /// assert_eq!(s.try_send(1), Ok(())); + /// assert_eq!(s.try_send(2), Err(TrySendError::Full(2))); + /// + /// drop(r); + /// assert_eq!(s.try_send(3), Err(TrySendError::Disconnected(3))); + /// ``` + pub fn try_send(&self, msg: T) -> Result<(), TrySendError> { + match &self.flavor { + SenderFlavor::Array(chan) => chan.try_send(msg), + SenderFlavor::List(chan) => chan.try_send(msg), + SenderFlavor::Zero(chan) => chan.try_send(msg), + } + } + + /// Blocks the current thread until a message is sent or the channel is disconnected. + /// + /// If the channel is full and not disconnected, this call will block until the send operation + /// can proceed. If the channel becomes disconnected, this call will wake up and return an + /// error. The returned error contains the original message. + /// + /// If called on a zero-capacity channel, this method will wait for a receive operation to + /// appear on the other side of the channel. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use std::time::Duration; + /// use crossbeam_channel::{bounded, SendError}; + /// + /// let (s, r) = bounded(1); + /// assert_eq!(s.send(1), Ok(())); + /// + /// thread::spawn(move || { + /// assert_eq!(r.recv(), Ok(1)); + /// thread::sleep(Duration::from_secs(1)); + /// drop(r); + /// }); + /// + /// assert_eq!(s.send(2), Ok(())); + /// assert_eq!(s.send(3), Err(SendError(3))); + /// ``` + pub fn send(&self, msg: T) -> Result<(), SendError> { + match &self.flavor { + SenderFlavor::Array(chan) => chan.send(msg, None), + SenderFlavor::List(chan) => chan.send(msg, None), + SenderFlavor::Zero(chan) => chan.send(msg, None), + } + .map_err(|err| match err { + SendTimeoutError::Disconnected(msg) => SendError(msg), + SendTimeoutError::Timeout(_) => unreachable!(), + }) + } + + /// Waits for a message to be sent into the channel, but only for a limited time. + /// + /// If the channel is full and not disconnected, this call will block until the send operation + /// can proceed or the operation times out. If the channel becomes disconnected, this call will + /// wake up and return an error. The returned error contains the original message. + /// + /// If called on a zero-capacity channel, this method will wait for a receive operation to + /// appear on the other side of the channel. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use std::time::Duration; + /// use crossbeam_channel::{bounded, SendTimeoutError}; + /// + /// let (s, r) = bounded(0); + /// + /// thread::spawn(move || { + /// thread::sleep(Duration::from_secs(1)); + /// assert_eq!(r.recv(), Ok(2)); + /// drop(r); + /// }); + /// + /// assert_eq!( + /// s.send_timeout(1, Duration::from_millis(500)), + /// Err(SendTimeoutError::Timeout(1)), + /// ); + /// assert_eq!( + /// s.send_timeout(2, Duration::from_secs(1)), + /// Ok(()), + /// ); + /// assert_eq!( + /// s.send_timeout(3, Duration::from_millis(500)), + /// Err(SendTimeoutError::Disconnected(3)), + /// ); + /// ``` + pub fn send_timeout(&self, msg: T, timeout: Duration) -> Result<(), SendTimeoutError> { + let deadline = Instant::now() + timeout; + + match &self.flavor { + SenderFlavor::Array(chan) => chan.send(msg, Some(deadline)), + SenderFlavor::List(chan) => chan.send(msg, Some(deadline)), + SenderFlavor::Zero(chan) => chan.send(msg, Some(deadline)), + } + } + + /// Returns `true` if the channel is empty. + /// + /// Note: Zero-capacity channels are always empty. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::unbounded; + /// + /// let (s, r) = unbounded(); + /// assert!(s.is_empty()); + /// + /// s.send(0).unwrap(); + /// assert!(!s.is_empty()); + /// ``` + pub fn is_empty(&self) -> bool { + match &self.flavor { + SenderFlavor::Array(chan) => chan.is_empty(), + SenderFlavor::List(chan) => chan.is_empty(), + SenderFlavor::Zero(chan) => chan.is_empty(), + } + } + + /// Returns `true` if the channel is full. + /// + /// Note: Zero-capacity channels are always full. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::bounded; + /// + /// let (s, r) = bounded(1); + /// + /// assert!(!s.is_full()); + /// s.send(0).unwrap(); + /// assert!(s.is_full()); + /// ``` + pub fn is_full(&self) -> bool { + match &self.flavor { + SenderFlavor::Array(chan) => chan.is_full(), + SenderFlavor::List(chan) => chan.is_full(), + SenderFlavor::Zero(chan) => chan.is_full(), + } + } + + /// Returns the number of messages in the channel. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::unbounded; + /// + /// let (s, r) = unbounded(); + /// assert_eq!(s.len(), 0); + /// + /// s.send(1).unwrap(); + /// s.send(2).unwrap(); + /// assert_eq!(s.len(), 2); + /// ``` + pub fn len(&self) -> usize { + match &self.flavor { + SenderFlavor::Array(chan) => chan.len(), + SenderFlavor::List(chan) => chan.len(), + SenderFlavor::Zero(chan) => chan.len(), + } + } + + /// If the channel is bounded, returns its capacity. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::{bounded, unbounded}; + /// + /// let (s, _) = unbounded::(); + /// assert_eq!(s.capacity(), None); + /// + /// let (s, _) = bounded::(5); + /// assert_eq!(s.capacity(), Some(5)); + /// + /// let (s, _) = bounded::(0); + /// assert_eq!(s.capacity(), Some(0)); + /// ``` + pub fn capacity(&self) -> Option { + match &self.flavor { + SenderFlavor::Array(chan) => chan.capacity(), + SenderFlavor::List(chan) => chan.capacity(), + SenderFlavor::Zero(chan) => chan.capacity(), + } + } + + /// Returns `true` if senders belong to the same channel. + /// + /// # Examples + /// + /// ```rust + /// use crossbeam_channel::unbounded; + /// + /// let (s, _) = unbounded::(); + /// + /// let s2 = s.clone(); + /// assert!(s.same_channel(&s2)); + /// + /// let (s3, _) = unbounded(); + /// assert!(!s.same_channel(&s3)); + /// ``` + pub fn same_channel(&self, other: &Sender) -> bool { + match (&self.flavor, &other.flavor) { + (SenderFlavor::Array(ref a), SenderFlavor::Array(ref b)) => a == b, + (SenderFlavor::List(ref a), SenderFlavor::List(ref b)) => a == b, + (SenderFlavor::Zero(ref a), SenderFlavor::Zero(ref b)) => a == b, + _ => false, + } + } +} + +impl Drop for Sender { + fn drop(&mut self) { + unsafe { + match &self.flavor { + SenderFlavor::Array(chan) => chan.release(|c| c.disconnect()), + SenderFlavor::List(chan) => chan.release(|c| c.disconnect()), + SenderFlavor::Zero(chan) => chan.release(|c| c.disconnect()), + } + } + } +} + +impl Clone for Sender { + fn clone(&self) -> Self { + let flavor = match &self.flavor { + SenderFlavor::Array(chan) => SenderFlavor::Array(chan.acquire()), + SenderFlavor::List(chan) => SenderFlavor::List(chan.acquire()), + SenderFlavor::Zero(chan) => SenderFlavor::Zero(chan.acquire()), + }; + + Sender { flavor } + } +} + +impl fmt::Debug for Sender { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sender { .. }") + } +} + +/// The receiving side of a channel. +/// +/// # Examples +/// +/// ``` +/// use std::thread; +/// use std::time::Duration; +/// use crossbeam_channel::unbounded; +/// +/// let (s, r) = unbounded(); +/// +/// thread::spawn(move || { +/// s.send(1); +/// thread::sleep(Duration::from_secs(1)); +/// s.send(2); +/// }); +/// +/// assert_eq!(r.recv(), Ok(1)); // Received immediately. +/// assert_eq!(r.recv(), Ok(2)); // Received after 1 second. +/// ``` +pub struct Receiver { + flavor: ReceiverFlavor, +} + +/// Receiver flavors. +enum ReceiverFlavor { + /// Bounded channel based on a preallocated array. + Array(counter::Receiver>), + + /// Unbounded channel implemented as a linked list. + List(counter::Receiver>), + + /// Zero-capacity channel. + Zero(counter::Receiver>), + + /// The after flavor. + After(Arc), + + /// The tick flavor. + Tick(Arc), + + /// The never flavor. + Never(flavors::never::Channel), +} + +unsafe impl Send for Receiver {} +unsafe impl Sync for Receiver {} + +impl UnwindSafe for Receiver {} +impl RefUnwindSafe for Receiver {} + +impl Receiver { + /// Attempts to receive a message from the channel without blocking. + /// + /// This method will either receive a message from the channel immediately or return an error + /// if the channel is empty. + /// + /// If called on a zero-capacity channel, this method will receive a message only if there + /// happens to be a send operation on the other side of the channel at the same time. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::{unbounded, TryRecvError}; + /// + /// let (s, r) = unbounded(); + /// assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + /// + /// s.send(5).unwrap(); + /// drop(s); + /// + /// assert_eq!(r.try_recv(), Ok(5)); + /// assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)); + /// ``` + pub fn try_recv(&self) -> Result { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.try_recv(), + ReceiverFlavor::List(chan) => chan.try_recv(), + ReceiverFlavor::Zero(chan) => chan.try_recv(), + ReceiverFlavor::After(chan) => { + let msg = chan.try_recv(); + unsafe { + mem::transmute_copy::, Result>( + &msg, + ) + } + } + ReceiverFlavor::Tick(chan) => { + let msg = chan.try_recv(); + unsafe { + mem::transmute_copy::, Result>( + &msg, + ) + } + } + ReceiverFlavor::Never(chan) => chan.try_recv(), + } + } + + /// Blocks the current thread until a message is received or the channel is empty and + /// disconnected. + /// + /// If the channel is empty and not disconnected, this call will block until the receive + /// operation can proceed. If the channel is empty and becomes disconnected, this call will + /// wake up and return an error. + /// + /// If called on a zero-capacity channel, this method will wait for a send operation to appear + /// on the other side of the channel. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use std::time::Duration; + /// use crossbeam_channel::{unbounded, RecvError}; + /// + /// let (s, r) = unbounded(); + /// + /// thread::spawn(move || { + /// thread::sleep(Duration::from_secs(1)); + /// s.send(5).unwrap(); + /// drop(s); + /// }); + /// + /// assert_eq!(r.recv(), Ok(5)); + /// assert_eq!(r.recv(), Err(RecvError)); + /// ``` + pub fn recv(&self) -> Result { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.recv(None), + ReceiverFlavor::List(chan) => chan.recv(None), + ReceiverFlavor::Zero(chan) => chan.recv(None), + ReceiverFlavor::After(chan) => { + let msg = chan.recv(None); + unsafe { + mem::transmute_copy::< + Result, + Result, + >(&msg) + } + } + ReceiverFlavor::Tick(chan) => { + let msg = chan.recv(None); + unsafe { + mem::transmute_copy::< + Result, + Result, + >(&msg) + } + } + ReceiverFlavor::Never(chan) => chan.recv(None), + } + .map_err(|_| RecvError) + } + + /// Waits for a message to be received from the channel, but only for a limited time. + /// + /// If the channel is empty and not disconnected, this call will block until the receive + /// operation can proceed or the operation times out. If the channel is empty and becomes + /// disconnected, this call will wake up and return an error. + /// + /// If called on a zero-capacity channel, this method will wait for a send operation to appear + /// on the other side of the channel. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use std::time::Duration; + /// use crossbeam_channel::{unbounded, RecvTimeoutError}; + /// + /// let (s, r) = unbounded(); + /// + /// thread::spawn(move || { + /// thread::sleep(Duration::from_secs(1)); + /// s.send(5).unwrap(); + /// drop(s); + /// }); + /// + /// assert_eq!( + /// r.recv_timeout(Duration::from_millis(500)), + /// Err(RecvTimeoutError::Timeout), + /// ); + /// assert_eq!( + /// r.recv_timeout(Duration::from_secs(1)), + /// Ok(5), + /// ); + /// assert_eq!( + /// r.recv_timeout(Duration::from_secs(1)), + /// Err(RecvTimeoutError::Disconnected), + /// ); + /// ``` + pub fn recv_timeout(&self, timeout: Duration) -> Result { + let deadline = Instant::now() + timeout; + + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.recv(Some(deadline)), + ReceiverFlavor::List(chan) => chan.recv(Some(deadline)), + ReceiverFlavor::Zero(chan) => chan.recv(Some(deadline)), + ReceiverFlavor::After(chan) => { + let msg = chan.recv(Some(deadline)); + unsafe { + mem::transmute_copy::< + Result, + Result, + >(&msg) + } + } + ReceiverFlavor::Tick(chan) => { + let msg = chan.recv(Some(deadline)); + unsafe { + mem::transmute_copy::< + Result, + Result, + >(&msg) + } + } + ReceiverFlavor::Never(chan) => chan.recv(Some(deadline)), + } + } + + /// Returns `true` if the channel is empty. + /// + /// Note: Zero-capacity channels are always empty. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::unbounded; + /// + /// let (s, r) = unbounded(); + /// + /// assert!(r.is_empty()); + /// s.send(0).unwrap(); + /// assert!(!r.is_empty()); + /// ``` + pub fn is_empty(&self) -> bool { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.is_empty(), + ReceiverFlavor::List(chan) => chan.is_empty(), + ReceiverFlavor::Zero(chan) => chan.is_empty(), + ReceiverFlavor::After(chan) => chan.is_empty(), + ReceiverFlavor::Tick(chan) => chan.is_empty(), + ReceiverFlavor::Never(chan) => chan.is_empty(), + } + } + + /// Returns `true` if the channel is full. + /// + /// Note: Zero-capacity channels are always full. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::bounded; + /// + /// let (s, r) = bounded(1); + /// + /// assert!(!r.is_full()); + /// s.send(0).unwrap(); + /// assert!(r.is_full()); + /// ``` + pub fn is_full(&self) -> bool { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.is_full(), + ReceiverFlavor::List(chan) => chan.is_full(), + ReceiverFlavor::Zero(chan) => chan.is_full(), + ReceiverFlavor::After(chan) => chan.is_full(), + ReceiverFlavor::Tick(chan) => chan.is_full(), + ReceiverFlavor::Never(chan) => chan.is_full(), + } + } + + /// Returns the number of messages in the channel. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::unbounded; + /// + /// let (s, r) = unbounded(); + /// assert_eq!(r.len(), 0); + /// + /// s.send(1).unwrap(); + /// s.send(2).unwrap(); + /// assert_eq!(r.len(), 2); + /// ``` + pub fn len(&self) -> usize { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.len(), + ReceiverFlavor::List(chan) => chan.len(), + ReceiverFlavor::Zero(chan) => chan.len(), + ReceiverFlavor::After(chan) => chan.len(), + ReceiverFlavor::Tick(chan) => chan.len(), + ReceiverFlavor::Never(chan) => chan.len(), + } + } + + /// If the channel is bounded, returns its capacity. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::{bounded, unbounded}; + /// + /// let (_, r) = unbounded::(); + /// assert_eq!(r.capacity(), None); + /// + /// let (_, r) = bounded::(5); + /// assert_eq!(r.capacity(), Some(5)); + /// + /// let (_, r) = bounded::(0); + /// assert_eq!(r.capacity(), Some(0)); + /// ``` + pub fn capacity(&self) -> Option { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.capacity(), + ReceiverFlavor::List(chan) => chan.capacity(), + ReceiverFlavor::Zero(chan) => chan.capacity(), + ReceiverFlavor::After(chan) => chan.capacity(), + ReceiverFlavor::Tick(chan) => chan.capacity(), + ReceiverFlavor::Never(chan) => chan.capacity(), + } + } + + /// A blocking iterator over messages in the channel. + /// + /// Each call to [`next`] blocks waiting for the next message and then returns it. However, if + /// the channel becomes empty and disconnected, it returns [`None`] without blocking. + /// + /// [`next`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#tymethod.next + /// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use crossbeam_channel::unbounded; + /// + /// let (s, r) = unbounded(); + /// + /// thread::spawn(move || { + /// s.send(1).unwrap(); + /// s.send(2).unwrap(); + /// s.send(3).unwrap(); + /// drop(s); // Disconnect the channel. + /// }); + /// + /// // Collect all messages from the channel. + /// // Note that the call to `collect` blocks until the sender is dropped. + /// let v: Vec<_> = r.iter().collect(); + /// + /// assert_eq!(v, [1, 2, 3]); + /// ``` + pub fn iter(&self) -> Iter { + Iter { receiver: self } + } + + /// A non-blocking iterator over messages in the channel. + /// + /// Each call to [`next`] returns a message if there is one ready to be received. The iterator + /// never blocks waiting for the next message. + /// + /// [`next`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#tymethod.next + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use std::time::Duration; + /// use crossbeam_channel::unbounded; + /// + /// let (s, r) = unbounded::(); + /// + /// thread::spawn(move || { + /// s.send(1).unwrap(); + /// thread::sleep(Duration::from_secs(1)); + /// s.send(2).unwrap(); + /// thread::sleep(Duration::from_secs(2)); + /// s.send(3).unwrap(); + /// }); + /// + /// thread::sleep(Duration::from_secs(2)); + /// + /// // Collect all messages from the channel without blocking. + /// // The third message hasn't been sent yet so we'll collect only the first two. + /// let v: Vec<_> = r.try_iter().collect(); + /// + /// assert_eq!(v, [1, 2]); + /// ``` + pub fn try_iter(&self) -> TryIter { + TryIter { receiver: self } + } + + /// Returns `true` if receivers belong to the same channel. + /// + /// # Examples + /// + /// ```rust + /// use crossbeam_channel::unbounded; + /// + /// let (_, r) = unbounded::(); + /// + /// let r2 = r.clone(); + /// assert!(r.same_channel(&r2)); + /// + /// let (_, r3) = unbounded(); + /// assert!(!r.same_channel(&r3)); + /// ``` + pub fn same_channel(&self, other: &Receiver) -> bool { + match (&self.flavor, &other.flavor) { + (ReceiverFlavor::Array(a), ReceiverFlavor::Array(b)) => a == b, + (ReceiverFlavor::List(a), ReceiverFlavor::List(b)) => a == b, + (ReceiverFlavor::Zero(a), ReceiverFlavor::Zero(b)) => a == b, + (ReceiverFlavor::After(a), ReceiverFlavor::After(b)) => Arc::ptr_eq(a, b), + (ReceiverFlavor::Tick(a), ReceiverFlavor::Tick(b)) => Arc::ptr_eq(a, b), + (ReceiverFlavor::Never(_), ReceiverFlavor::Never(_)) => true, + _ => false, + } + } +} + +impl Drop for Receiver { + fn drop(&mut self) { + unsafe { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.release(|c| c.disconnect()), + ReceiverFlavor::List(chan) => chan.release(|c| c.disconnect()), + ReceiverFlavor::Zero(chan) => chan.release(|c| c.disconnect()), + ReceiverFlavor::After(_) => {} + ReceiverFlavor::Tick(_) => {} + ReceiverFlavor::Never(_) => {} + } + } + } +} + +impl Clone for Receiver { + fn clone(&self) -> Self { + let flavor = match &self.flavor { + ReceiverFlavor::Array(chan) => ReceiverFlavor::Array(chan.acquire()), + ReceiverFlavor::List(chan) => ReceiverFlavor::List(chan.acquire()), + ReceiverFlavor::Zero(chan) => ReceiverFlavor::Zero(chan.acquire()), + ReceiverFlavor::After(chan) => ReceiverFlavor::After(chan.clone()), + ReceiverFlavor::Tick(chan) => ReceiverFlavor::Tick(chan.clone()), + ReceiverFlavor::Never(_) => ReceiverFlavor::Never(flavors::never::Channel::new()), + }; + + Receiver { flavor } + } +} + +impl fmt::Debug for Receiver { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Receiver { .. }") + } +} + +impl<'a, T> IntoIterator for &'a Receiver { + type Item = T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + +impl IntoIterator for Receiver { + type Item = T; + type IntoIter = IntoIter; + + fn into_iter(self) -> Self::IntoIter { + IntoIter { receiver: self } + } +} + +/// A blocking iterator over messages in a channel. +/// +/// Each call to [`next`] blocks waiting for the next message and then returns it. However, if the +/// channel becomes empty and disconnected, it returns [`None`] without blocking. +/// +/// [`next`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#tymethod.next +/// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None +/// +/// # Examples +/// +/// ``` +/// use std::thread; +/// use crossbeam_channel::unbounded; +/// +/// let (s, r) = unbounded(); +/// +/// thread::spawn(move || { +/// s.send(1).unwrap(); +/// s.send(2).unwrap(); +/// s.send(3).unwrap(); +/// drop(s); // Disconnect the channel. +/// }); +/// +/// // Collect all messages from the channel. +/// // Note that the call to `collect` blocks until the sender is dropped. +/// let v: Vec<_> = r.iter().collect(); +/// +/// assert_eq!(v, [1, 2, 3]); +/// ``` +pub struct Iter<'a, T: 'a> { + receiver: &'a Receiver, +} + +impl<'a, T> FusedIterator for Iter<'a, T> {} + +impl<'a, T> Iterator for Iter<'a, T> { + type Item = T; + + fn next(&mut self) -> Option { + self.receiver.recv().ok() + } +} + +impl<'a, T> fmt::Debug for Iter<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Iter { .. }") + } +} + +/// A non-blocking iterator over messages in a channel. +/// +/// Each call to [`next`] returns a message if there is one ready to be received. The iterator +/// never blocks waiting for the next message. +/// +/// [`next`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#tymethod.next +/// +/// # Examples +/// +/// ``` +/// use std::thread; +/// use std::time::Duration; +/// use crossbeam_channel::unbounded; +/// +/// let (s, r) = unbounded::(); +/// +/// thread::spawn(move || { +/// s.send(1).unwrap(); +/// thread::sleep(Duration::from_secs(1)); +/// s.send(2).unwrap(); +/// thread::sleep(Duration::from_secs(2)); +/// s.send(3).unwrap(); +/// }); +/// +/// thread::sleep(Duration::from_secs(2)); +/// +/// // Collect all messages from the channel without blocking. +/// // The third message hasn't been sent yet so we'll collect only the first two. +/// let v: Vec<_> = r.try_iter().collect(); +/// +/// assert_eq!(v, [1, 2]); +/// ``` +pub struct TryIter<'a, T: 'a> { + receiver: &'a Receiver, +} + +impl<'a, T> Iterator for TryIter<'a, T> { + type Item = T; + + fn next(&mut self) -> Option { + self.receiver.try_recv().ok() + } +} + +impl<'a, T> fmt::Debug for TryIter<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("TryIter { .. }") + } +} + +/// A blocking iterator over messages in a channel. +/// +/// Each call to [`next`] blocks waiting for the next message and then returns it. However, if the +/// channel becomes empty and disconnected, it returns [`None`] without blocking. +/// +/// [`next`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#tymethod.next +/// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None +/// +/// # Examples +/// +/// ``` +/// use std::thread; +/// use crossbeam_channel::unbounded; +/// +/// let (s, r) = unbounded(); +/// +/// thread::spawn(move || { +/// s.send(1).unwrap(); +/// s.send(2).unwrap(); +/// s.send(3).unwrap(); +/// drop(s); // Disconnect the channel. +/// }); +/// +/// // Collect all messages from the channel. +/// // Note that the call to `collect` blocks until the sender is dropped. +/// let v: Vec<_> = r.into_iter().collect(); +/// +/// assert_eq!(v, [1, 2, 3]); +/// ``` +pub struct IntoIter { + receiver: Receiver, +} + +impl FusedIterator for IntoIter {} + +impl Iterator for IntoIter { + type Item = T; + + fn next(&mut self) -> Option { + self.receiver.recv().ok() + } +} + +impl fmt::Debug for IntoIter { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("IntoIter { .. }") + } +} + +impl SelectHandle for Sender { + fn try_select(&self, token: &mut Token) -> bool { + match &self.flavor { + SenderFlavor::Array(chan) => chan.sender().try_select(token), + SenderFlavor::List(chan) => chan.sender().try_select(token), + SenderFlavor::Zero(chan) => chan.sender().try_select(token), + } + } + + fn deadline(&self) -> Option { + None + } + + fn register(&self, oper: Operation, cx: &Context) -> bool { + match &self.flavor { + SenderFlavor::Array(chan) => chan.sender().register(oper, cx), + SenderFlavor::List(chan) => chan.sender().register(oper, cx), + SenderFlavor::Zero(chan) => chan.sender().register(oper, cx), + } + } + + fn unregister(&self, oper: Operation) { + match &self.flavor { + SenderFlavor::Array(chan) => chan.sender().unregister(oper), + SenderFlavor::List(chan) => chan.sender().unregister(oper), + SenderFlavor::Zero(chan) => chan.sender().unregister(oper), + } + } + + fn accept(&self, token: &mut Token, cx: &Context) -> bool { + match &self.flavor { + SenderFlavor::Array(chan) => chan.sender().accept(token, cx), + SenderFlavor::List(chan) => chan.sender().accept(token, cx), + SenderFlavor::Zero(chan) => chan.sender().accept(token, cx), + } + } + + fn is_ready(&self) -> bool { + match &self.flavor { + SenderFlavor::Array(chan) => chan.sender().is_ready(), + SenderFlavor::List(chan) => chan.sender().is_ready(), + SenderFlavor::Zero(chan) => chan.sender().is_ready(), + } + } + + fn watch(&self, oper: Operation, cx: &Context) -> bool { + match &self.flavor { + SenderFlavor::Array(chan) => chan.sender().watch(oper, cx), + SenderFlavor::List(chan) => chan.sender().watch(oper, cx), + SenderFlavor::Zero(chan) => chan.sender().watch(oper, cx), + } + } + + fn unwatch(&self, oper: Operation) { + match &self.flavor { + SenderFlavor::Array(chan) => chan.sender().unwatch(oper), + SenderFlavor::List(chan) => chan.sender().unwatch(oper), + SenderFlavor::Zero(chan) => chan.sender().unwatch(oper), + } + } +} + +impl SelectHandle for Receiver { + fn try_select(&self, token: &mut Token) -> bool { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.receiver().try_select(token), + ReceiverFlavor::List(chan) => chan.receiver().try_select(token), + ReceiverFlavor::Zero(chan) => chan.receiver().try_select(token), + ReceiverFlavor::After(chan) => chan.try_select(token), + ReceiverFlavor::Tick(chan) => chan.try_select(token), + ReceiverFlavor::Never(chan) => chan.try_select(token), + } + } + + fn deadline(&self) -> Option { + match &self.flavor { + ReceiverFlavor::Array(_) => None, + ReceiverFlavor::List(_) => None, + ReceiverFlavor::Zero(_) => None, + ReceiverFlavor::After(chan) => chan.deadline(), + ReceiverFlavor::Tick(chan) => chan.deadline(), + ReceiverFlavor::Never(chan) => chan.deadline(), + } + } + + fn register(&self, oper: Operation, cx: &Context) -> bool { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.receiver().register(oper, cx), + ReceiverFlavor::List(chan) => chan.receiver().register(oper, cx), + ReceiverFlavor::Zero(chan) => chan.receiver().register(oper, cx), + ReceiverFlavor::After(chan) => chan.register(oper, cx), + ReceiverFlavor::Tick(chan) => chan.register(oper, cx), + ReceiverFlavor::Never(chan) => chan.register(oper, cx), + } + } + + fn unregister(&self, oper: Operation) { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.receiver().unregister(oper), + ReceiverFlavor::List(chan) => chan.receiver().unregister(oper), + ReceiverFlavor::Zero(chan) => chan.receiver().unregister(oper), + ReceiverFlavor::After(chan) => chan.unregister(oper), + ReceiverFlavor::Tick(chan) => chan.unregister(oper), + ReceiverFlavor::Never(chan) => chan.unregister(oper), + } + } + + fn accept(&self, token: &mut Token, cx: &Context) -> bool { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.receiver().accept(token, cx), + ReceiverFlavor::List(chan) => chan.receiver().accept(token, cx), + ReceiverFlavor::Zero(chan) => chan.receiver().accept(token, cx), + ReceiverFlavor::After(chan) => chan.accept(token, cx), + ReceiverFlavor::Tick(chan) => chan.accept(token, cx), + ReceiverFlavor::Never(chan) => chan.accept(token, cx), + } + } + + fn is_ready(&self) -> bool { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.receiver().is_ready(), + ReceiverFlavor::List(chan) => chan.receiver().is_ready(), + ReceiverFlavor::Zero(chan) => chan.receiver().is_ready(), + ReceiverFlavor::After(chan) => chan.is_ready(), + ReceiverFlavor::Tick(chan) => chan.is_ready(), + ReceiverFlavor::Never(chan) => chan.is_ready(), + } + } + + fn watch(&self, oper: Operation, cx: &Context) -> bool { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.receiver().watch(oper, cx), + ReceiverFlavor::List(chan) => chan.receiver().watch(oper, cx), + ReceiverFlavor::Zero(chan) => chan.receiver().watch(oper, cx), + ReceiverFlavor::After(chan) => chan.watch(oper, cx), + ReceiverFlavor::Tick(chan) => chan.watch(oper, cx), + ReceiverFlavor::Never(chan) => chan.watch(oper, cx), + } + } + + fn unwatch(&self, oper: Operation) { + match &self.flavor { + ReceiverFlavor::Array(chan) => chan.receiver().unwatch(oper), + ReceiverFlavor::List(chan) => chan.receiver().unwatch(oper), + ReceiverFlavor::Zero(chan) => chan.receiver().unwatch(oper), + ReceiverFlavor::After(chan) => chan.unwatch(oper), + ReceiverFlavor::Tick(chan) => chan.unwatch(oper), + ReceiverFlavor::Never(chan) => chan.unwatch(oper), + } + } +} + +/// Writes a message into the channel. +pub unsafe fn write(s: &Sender, token: &mut Token, msg: T) -> Result<(), T> { + match &s.flavor { + SenderFlavor::Array(chan) => chan.write(token, msg), + SenderFlavor::List(chan) => chan.write(token, msg), + SenderFlavor::Zero(chan) => chan.write(token, msg), + } +} + +/// Reads a message from the channel. +pub unsafe fn read(r: &Receiver, token: &mut Token) -> Result { + match &r.flavor { + ReceiverFlavor::Array(chan) => chan.read(token), + ReceiverFlavor::List(chan) => chan.read(token), + ReceiverFlavor::Zero(chan) => chan.read(token), + ReceiverFlavor::After(chan) => { + mem::transmute_copy::, Result>(&chan.read(token)) + } + ReceiverFlavor::Tick(chan) => { + mem::transmute_copy::, Result>(&chan.read(token)) + } + ReceiverFlavor::Never(chan) => chan.read(token), + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/context.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/context.rs new file mode 100644 index 0000000..c6e5c15 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/context.rs @@ -0,0 +1,191 @@ +//! Thread-local context used in select. + +use std::cell::Cell; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::Arc; +use std::thread::{self, Thread, ThreadId}; +use std::time::Instant; + +use crossbeam_utils::Backoff; + +use select::Selected; + +/// Thread-local context used in select. +#[derive(Debug, Clone)] +pub struct Context { + inner: Arc, +} + +/// Inner representation of `Context`. +#[derive(Debug)] +struct Inner { + /// Selected operation. + select: AtomicUsize, + + /// A slot into which another thread may store a pointer to its `Packet`. + packet: AtomicUsize, + + /// Thread handle. + thread: Thread, + + /// Thread id. + thread_id: ThreadId, +} + +impl Context { + /// Creates a new context for the duration of the closure. + #[inline] + pub fn with(f: F) -> R + where + F: FnOnce(&Context) -> R, + { + thread_local! { + /// Cached thread-local context. + static CONTEXT: Cell> = Cell::new(Some(Context::new())); + } + + let mut f = Some(f); + let mut f = move |cx: &Context| -> R { + let f = f.take().unwrap(); + f(cx) + }; + + CONTEXT + .try_with(|cell| match cell.take() { + None => f(&Context::new()), + Some(cx) => { + cx.reset(); + let res = f(&cx); + cell.set(Some(cx)); + res + } + }) + .unwrap_or_else(|_| f(&Context::new())) + } + + /// Creates a new `Context`. + #[cold] + fn new() -> Context { + Context { + inner: Arc::new(Inner { + select: AtomicUsize::new(Selected::Waiting.into()), + packet: AtomicUsize::new(0), + thread: thread::current(), + thread_id: thread::current().id(), + }), + } + } + + /// Resets `select` and `packet`. + #[inline] + fn reset(&self) { + self.inner + .select + .store(Selected::Waiting.into(), Ordering::Release); + self.inner.packet.store(0, Ordering::Release); + } + + /// Attempts to select an operation. + /// + /// On failure, the previously selected operation is returned. + #[inline] + pub fn try_select(&self, select: Selected) -> Result<(), Selected> { + self.inner + .select + .compare_exchange( + Selected::Waiting.into(), + select.into(), + Ordering::AcqRel, + Ordering::Acquire, + ) + .map(|_| ()) + .map_err(|e| e.into()) + } + + /// Returns the selected operation. + #[inline] + pub fn selected(&self) -> Selected { + Selected::from(self.inner.select.load(Ordering::Acquire)) + } + + /// Stores a packet. + /// + /// This method must be called after `try_select` succeeds and there is a packet to provide. + #[inline] + pub fn store_packet(&self, packet: usize) { + if packet != 0 { + self.inner.packet.store(packet, Ordering::Release); + } + } + + /// Waits until a packet is provided and returns it. + #[inline] + pub fn wait_packet(&self) -> usize { + let backoff = Backoff::new(); + loop { + let packet = self.inner.packet.load(Ordering::Acquire); + if packet != 0 { + return packet; + } + backoff.snooze(); + } + } + + /// Waits until an operation is selected and returns it. + /// + /// If the deadline is reached, `Selected::Aborted` will be selected. + #[inline] + pub fn wait_until(&self, deadline: Option) -> Selected { + // Spin for a short time, waiting until an operation is selected. + let backoff = Backoff::new(); + loop { + let sel = Selected::from(self.inner.select.load(Ordering::Acquire)); + if sel != Selected::Waiting { + return sel; + } + + if backoff.is_completed() { + break; + } else { + backoff.snooze(); + } + } + + loop { + // Check whether an operation has been selected. + let sel = Selected::from(self.inner.select.load(Ordering::Acquire)); + if sel != Selected::Waiting { + return sel; + } + + // If there's a deadline, park the current thread until the deadline is reached. + if let Some(end) = deadline { + let now = Instant::now(); + + if now < end { + thread::park_timeout(end - now); + } else { + // The deadline has been reached. Try aborting select. + return match self.try_select(Selected::Aborted) { + Ok(()) => Selected::Aborted, + Err(s) => s, + }; + } + } else { + thread::park(); + } + } + } + + /// Unparks the thread this context belongs to. + #[inline] + pub fn unpark(&self) { + self.inner.thread.unpark(); + } + + /// Returns the id of the thread this context belongs to. + #[inline] + pub fn thread_id(&self) -> ThreadId { + self.inner.thread_id + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/counter.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/counter.rs new file mode 100644 index 0000000..2eaf067 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/counter.rs @@ -0,0 +1,144 @@ +//! Reference counter for channels. + +use std::isize; +use std::ops; +use std::process; +use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; + +/// Reference counter internals. +struct Counter { + /// The number of senders associated with the channel. + senders: AtomicUsize, + + /// The number of receivers associated with the channel. + receivers: AtomicUsize, + + /// Set to `true` if the last sender or the last receiver reference deallocates the channel. + destroy: AtomicBool, + + /// The internal channel. + chan: C, +} + +/// Wraps a channel into the reference counter. +pub fn new(chan: C) -> (Sender, Receiver) { + let counter = Box::into_raw(Box::new(Counter { + senders: AtomicUsize::new(1), + receivers: AtomicUsize::new(1), + destroy: AtomicBool::new(false), + chan, + })); + let s = Sender { counter }; + let r = Receiver { counter }; + (s, r) +} + +/// The sending side. +pub struct Sender { + counter: *mut Counter, +} + +impl Sender { + /// Returns the internal `Counter`. + fn counter(&self) -> &Counter { + unsafe { &*self.counter } + } + + /// Acquires another sender reference. + pub fn acquire(&self) -> Sender { + let count = self.counter().senders.fetch_add(1, Ordering::Relaxed); + + // Cloning senders and calling `mem::forget` on the clones could potentially overflow the + // counter. It's very difficult to recover sensibly from such degenerate scenarios so we + // just abort when the count becomes very large. + if count > isize::MAX as usize { + process::abort(); + } + + Sender { + counter: self.counter, + } + } + + /// Releases the sender reference. + /// + /// Function `disconnect` will be called if this is the last sender reference. + pub unsafe fn release bool>(&self, disconnect: F) { + if self.counter().senders.fetch_sub(1, Ordering::AcqRel) == 1 { + disconnect(&self.counter().chan); + + if self.counter().destroy.swap(true, Ordering::AcqRel) { + drop(Box::from_raw(self.counter)); + } + } + } +} + +impl ops::Deref for Sender { + type Target = C; + + fn deref(&self) -> &C { + &self.counter().chan + } +} + +impl PartialEq for Sender { + fn eq(&self, other: &Sender) -> bool { + self.counter == other.counter + } +} + +/// The receiving side. +pub struct Receiver { + counter: *mut Counter, +} + +impl Receiver { + /// Returns the internal `Counter`. + fn counter(&self) -> &Counter { + unsafe { &*self.counter } + } + + /// Acquires another receiver reference. + pub fn acquire(&self) -> Receiver { + let count = self.counter().receivers.fetch_add(1, Ordering::Relaxed); + + // Cloning receivers and calling `mem::forget` on the clones could potentially overflow the + // counter. It's very difficult to recover sensibly from such degenerate scenarios so we + // just abort when the count becomes very large. + if count > isize::MAX as usize { + process::abort(); + } + + Receiver { + counter: self.counter, + } + } + + /// Releases the receiver reference. + /// + /// Function `disconnect` will be called if this is the last receiver reference. + pub unsafe fn release bool>(&self, disconnect: F) { + if self.counter().receivers.fetch_sub(1, Ordering::AcqRel) == 1 { + disconnect(&self.counter().chan); + + if self.counter().destroy.swap(true, Ordering::AcqRel) { + drop(Box::from_raw(self.counter)); + } + } + } +} + +impl ops::Deref for Receiver { + type Target = C; + + fn deref(&self) -> &C { + &self.counter().chan + } +} + +impl PartialEq for Receiver { + fn eq(&self, other: &Receiver) -> bool { + self.counter == other.counter + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/err.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/err.rs new file mode 100644 index 0000000..02c7d44 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/err.rs @@ -0,0 +1,451 @@ +use std::error; +use std::fmt; + +/// An error returned from the [`send`] method. +/// +/// The message could not be sent because the channel is disconnected. +/// +/// The error contains the message so it can be recovered. +/// +/// [`send`]: struct.Sender.html#method.send +#[derive(PartialEq, Eq, Clone, Copy)] +pub struct SendError(pub T); + +/// An error returned from the [`try_send`] method. +/// +/// The error contains the message being sent so it can be recovered. +/// +/// [`try_send`]: struct.Sender.html#method.try_send +#[derive(PartialEq, Eq, Clone, Copy)] +pub enum TrySendError { + /// The message could not be sent because the channel is full. + /// + /// If this is a zero-capacity channel, then the error indicates that there was no receiver + /// available to receive the message at the time. + Full(T), + + /// The message could not be sent because the channel is disconnected. + Disconnected(T), +} + +/// An error returned from the [`send_timeout`] method. +/// +/// The error contains the message being sent so it can be recovered. +/// +/// [`send_timeout`]: struct.Sender.html#method.send_timeout +#[derive(PartialEq, Eq, Clone, Copy)] +pub enum SendTimeoutError { + /// The message could not be sent because the channel is full and the operation timed out. + /// + /// If this is a zero-capacity channel, then the error indicates that there was no receiver + /// available to receive the message and the operation timed out. + Timeout(T), + + /// The message could not be sent because the channel is disconnected. + Disconnected(T), +} + +/// An error returned from the [`recv`] method. +/// +/// A message could not be received because the channel is empty and disconnected. +/// +/// [`recv`]: struct.Receiver.html#method.recv +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub struct RecvError; + +/// An error returned from the [`try_recv`] method. +/// +/// [`try_recv`]: struct.Receiver.html#method.recv +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub enum TryRecvError { + /// A message could not be received because the channel is empty. + /// + /// If this is a zero-capacity channel, then the error indicates that there was no sender + /// available to send a message at the time. + Empty, + + /// The message could not be received because the channel is empty and disconnected. + Disconnected, +} + +/// An error returned from the [`recv_timeout`] method. +/// +/// [`recv_timeout`]: struct.Receiver.html#method.recv_timeout +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub enum RecvTimeoutError { + /// A message could not be received because the channel is empty and the operation timed out. + /// + /// If this is a zero-capacity channel, then the error indicates that there was no sender + /// available to send a message and the operation timed out. + Timeout, + + /// The message could not be received because the channel is empty and disconnected. + Disconnected, +} + +/// An error returned from the [`try_select`] method. +/// +/// Failed because none of the channel operations were ready. +/// +/// [`try_select`]: struct.Select.html#method.try_select +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub struct TrySelectError; + +/// An error returned from the [`select_timeout`] method. +/// +/// Failed because none of the channel operations became ready before the timeout. +/// +/// [`select_timeout`]: struct.Select.html#method.select_timeout +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub struct SelectTimeoutError; + +/// An error returned from the [`try_ready`] method. +/// +/// Failed because none of the channel operations were ready. +/// +/// [`try_ready`]: struct.Select.html#method.try_ready +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub struct TryReadyError; + +/// An error returned from the [`ready_timeout`] method. +/// +/// Failed because none of the channel operations became ready before the timeout. +/// +/// [`ready_timeout`]: struct.Select.html#method.ready_timeout +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub struct ReadyTimeoutError; + +impl fmt::Debug for SendError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + "SendError(..)".fmt(f) + } +} + +impl fmt::Display for SendError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + "sending on a disconnected channel".fmt(f) + } +} + +impl error::Error for SendError { + fn description(&self) -> &str { + "sending on a disconnected channel" + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + +impl SendError { + /// Unwraps the message. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::unbounded; + /// + /// let (s, r) = unbounded(); + /// drop(r); + /// + /// if let Err(err) = s.send("foo") { + /// assert_eq!(err.into_inner(), "foo"); + /// } + /// ``` + pub fn into_inner(self) -> T { + self.0 + } +} + +impl fmt::Debug for TrySendError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + TrySendError::Full(..) => "Full(..)".fmt(f), + TrySendError::Disconnected(..) => "Disconnected(..)".fmt(f), + } + } +} + +impl fmt::Display for TrySendError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + TrySendError::Full(..) => "sending on a full channel".fmt(f), + TrySendError::Disconnected(..) => "sending on a disconnected channel".fmt(f), + } + } +} + +impl error::Error for TrySendError { + fn description(&self) -> &str { + match *self { + TrySendError::Full(..) => "sending on a full channel", + TrySendError::Disconnected(..) => "sending on a disconnected channel", + } + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + +impl From> for TrySendError { + fn from(err: SendError) -> TrySendError { + match err { + SendError(t) => TrySendError::Disconnected(t), + } + } +} + +impl TrySendError { + /// Unwraps the message. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::bounded; + /// + /// let (s, r) = bounded(0); + /// + /// if let Err(err) = s.try_send("foo") { + /// assert_eq!(err.into_inner(), "foo"); + /// } + /// ``` + pub fn into_inner(self) -> T { + match self { + TrySendError::Full(v) => v, + TrySendError::Disconnected(v) => v, + } + } + + /// Returns `true` if the send operation failed because the channel is full. + pub fn is_full(&self) -> bool { + match self { + TrySendError::Full(_) => true, + _ => false, + } + } + + /// Returns `true` if the send operation failed because the channel is disconnected. + pub fn is_disconnected(&self) -> bool { + match self { + TrySendError::Disconnected(_) => true, + _ => false, + } + } +} + +impl fmt::Debug for SendTimeoutError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + "SendTimeoutError(..)".fmt(f) + } +} + +impl fmt::Display for SendTimeoutError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + SendTimeoutError::Timeout(..) => "timed out waiting on send operation".fmt(f), + SendTimeoutError::Disconnected(..) => "sending on a disconnected channel".fmt(f), + } + } +} + +impl error::Error for SendTimeoutError { + fn description(&self) -> &str { + "sending on an empty and disconnected channel" + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + +impl From> for SendTimeoutError { + fn from(err: SendError) -> SendTimeoutError { + match err { + SendError(e) => SendTimeoutError::Disconnected(e), + } + } +} + +impl SendTimeoutError { + /// Unwraps the message. + /// + /// # Examples + /// + /// ``` + /// use std::time::Duration; + /// use crossbeam_channel::unbounded; + /// + /// let (s, r) = unbounded(); + /// + /// if let Err(err) = s.send_timeout("foo", Duration::from_secs(1)) { + /// assert_eq!(err.into_inner(), "foo"); + /// } + /// ``` + pub fn into_inner(self) -> T { + match self { + SendTimeoutError::Timeout(v) => v, + SendTimeoutError::Disconnected(v) => v, + } + } + + /// Returns `true` if the send operation timed out. + pub fn is_timeout(&self) -> bool { + match self { + SendTimeoutError::Timeout(_) => true, + _ => false, + } + } + + /// Returns `true` if the send operation failed because the channel is disconnected. + pub fn is_disconnected(&self) -> bool { + match self { + SendTimeoutError::Disconnected(_) => true, + _ => false, + } + } +} + +impl fmt::Display for RecvError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + "receiving on an empty and disconnected channel".fmt(f) + } +} + +impl error::Error for RecvError { + fn description(&self) -> &str { + "receiving on an empty and disconnected channel" + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + +impl fmt::Display for TryRecvError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + TryRecvError::Empty => "receiving on an empty channel".fmt(f), + TryRecvError::Disconnected => "receiving on an empty and disconnected channel".fmt(f), + } + } +} + +impl error::Error for TryRecvError { + fn description(&self) -> &str { + match *self { + TryRecvError::Empty => "receiving on an empty channel", + TryRecvError::Disconnected => "receiving on an empty and disconnected channel", + } + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + +impl From for TryRecvError { + fn from(err: RecvError) -> TryRecvError { + match err { + RecvError => TryRecvError::Disconnected, + } + } +} + +impl TryRecvError { + /// Returns `true` if the receive operation failed because the channel is empty. + pub fn is_empty(&self) -> bool { + match self { + TryRecvError::Empty => true, + _ => false, + } + } + + /// Returns `true` if the receive operation failed because the channel is disconnected. + pub fn is_disconnected(&self) -> bool { + match self { + TryRecvError::Disconnected => true, + _ => false, + } + } +} + +impl fmt::Display for RecvTimeoutError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + RecvTimeoutError::Timeout => "timed out waiting on receive operation".fmt(f), + RecvTimeoutError::Disconnected => "channel is empty and disconnected".fmt(f), + } + } +} + +impl error::Error for RecvTimeoutError { + fn description(&self) -> &str { + match *self { + RecvTimeoutError::Timeout => "timed out waiting on receive operation", + RecvTimeoutError::Disconnected => "channel is empty and disconnected", + } + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + +impl From for RecvTimeoutError { + fn from(err: RecvError) -> RecvTimeoutError { + match err { + RecvError => RecvTimeoutError::Disconnected, + } + } +} + +impl RecvTimeoutError { + /// Returns `true` if the receive operation timed out. + pub fn is_timeout(&self) -> bool { + match self { + RecvTimeoutError::Timeout => true, + _ => false, + } + } + + /// Returns `true` if the receive operation failed because the channel is disconnected. + pub fn is_disconnected(&self) -> bool { + match self { + RecvTimeoutError::Disconnected => true, + _ => false, + } + } +} + +impl fmt::Display for TrySelectError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + "all operations in select would block".fmt(f) + } +} + +impl error::Error for TrySelectError { + fn description(&self) -> &str { + "all operations in select would block" + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + +impl fmt::Display for SelectTimeoutError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + "timed out waiting on select".fmt(f) + } +} + +impl error::Error for SelectTimeoutError { + fn description(&self) -> &str { + "timed out waiting on select" + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/after.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/after.rs new file mode 100644 index 0000000..b57f8a7 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/after.rs @@ -0,0 +1,200 @@ +//! Channel that delivers a message after a certain amount of time. +//! +//! Messages cannot be sent into this kind of channel; they are materialized on demand. + +use std::sync::atomic::{AtomicBool, Ordering}; +use std::thread; +use std::time::{Duration, Instant}; + +use context::Context; +use err::{RecvTimeoutError, TryRecvError}; +use select::{Operation, SelectHandle, Token}; +use utils; + +/// Result of a receive operation. +pub type AfterToken = Option; + +/// Channel that delivers a message after a certain amount of time. +pub struct Channel { + /// The instant at which the message will be delivered. + delivery_time: Instant, + + /// `true` if the message has been received. + received: AtomicBool, +} + +impl Channel { + /// Creates a channel that delivers a message after a certain duration of time. + #[inline] + pub fn new(dur: Duration) -> Self { + Channel { + delivery_time: Instant::now() + dur, + received: AtomicBool::new(false), + } + } + + /// Attempts to receive a message without blocking. + #[inline] + pub fn try_recv(&self) -> Result { + // We use relaxed ordering because this is just an optional optimistic check. + if self.received.load(Ordering::Relaxed) { + // The message has already been received. + return Err(TryRecvError::Empty); + } + + if Instant::now() < self.delivery_time { + // The message was not delivered yet. + return Err(TryRecvError::Empty); + } + + // Try receiving the message if it is still available. + if !self.received.swap(true, Ordering::SeqCst) { + // Success! Return delivery time as the message. + Ok(self.delivery_time) + } else { + // The message was already received. + Err(TryRecvError::Empty) + } + } + + /// Receives a message from the channel. + #[inline] + pub fn recv(&self, deadline: Option) -> Result { + // We use relaxed ordering because this is just an optional optimistic check. + if self.received.load(Ordering::Relaxed) { + // The message has already been received. + utils::sleep_until(deadline); + return Err(RecvTimeoutError::Timeout); + } + + // Wait until the message is received or the deadline is reached. + loop { + let now = Instant::now(); + + // Check if we can receive the next message. + if now >= self.delivery_time { + break; + } + + // Check if the deadline has been reached. + if let Some(d) = deadline { + if now >= d { + return Err(RecvTimeoutError::Timeout); + } + + thread::sleep(self.delivery_time.min(d) - now); + } else { + thread::sleep(self.delivery_time - now); + } + } + + // Try receiving the message if it is still available. + if !self.received.swap(true, Ordering::SeqCst) { + // Success! Return the message, which is the instant at which it was delivered. + Ok(self.delivery_time) + } else { + // The message was already received. Block forever. + utils::sleep_until(None); + unreachable!() + } + } + + /// Reads a message from the channel. + #[inline] + pub unsafe fn read(&self, token: &mut Token) -> Result { + token.after.ok_or(()) + } + + /// Returns `true` if the channel is empty. + #[inline] + pub fn is_empty(&self) -> bool { + // We use relaxed ordering because this is just an optional optimistic check. + if self.received.load(Ordering::Relaxed) { + return true; + } + + // If the delivery time hasn't been reached yet, the channel is empty. + if Instant::now() < self.delivery_time { + return true; + } + + // The delivery time has been reached. The channel is empty only if the message has already + // been received. + self.received.load(Ordering::SeqCst) + } + + /// Returns `true` if the channel is full. + #[inline] + pub fn is_full(&self) -> bool { + !self.is_empty() + } + + /// Returns the number of messages in the channel. + #[inline] + pub fn len(&self) -> usize { + if self.is_empty() { + 0 + } else { + 1 + } + } + + /// Returns the capacity of the channel. + #[inline] + pub fn capacity(&self) -> Option { + Some(1) + } +} + +impl SelectHandle for Channel { + #[inline] + fn try_select(&self, token: &mut Token) -> bool { + match self.try_recv() { + Ok(msg) => { + token.after = Some(msg); + true + } + Err(TryRecvError::Disconnected) => { + token.after = None; + true + } + Err(TryRecvError::Empty) => false, + } + } + + #[inline] + fn deadline(&self) -> Option { + // We use relaxed ordering because this is just an optional optimistic check. + if self.received.load(Ordering::Relaxed) { + None + } else { + Some(self.delivery_time) + } + } + + #[inline] + fn register(&self, _oper: Operation, _cx: &Context) -> bool { + self.is_ready() + } + + #[inline] + fn unregister(&self, _oper: Operation) {} + + #[inline] + fn accept(&self, token: &mut Token, _cx: &Context) -> bool { + self.try_select(token) + } + + #[inline] + fn is_ready(&self) -> bool { + !self.is_empty() + } + + #[inline] + fn watch(&self, _oper: Operation, _cx: &Context) -> bool { + self.is_ready() + } + + #[inline] + fn unwatch(&self, _oper: Operation) {} +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/array.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/array.rs new file mode 100644 index 0000000..1537c09 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/array.rs @@ -0,0 +1,632 @@ +//! Bounded channel based on a preallocated array. +//! +//! This flavor has a fixed, positive capacity. +//! +//! The implementation is based on Dmitry Vyukov's bounded MPMC queue. +//! +//! Source: +//! - http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue +//! - https://docs.google.com/document/d/1yIAYmbvL3JxOKOjuCyon7JhW4cSv1wy5hC0ApeGMV9s/pub +//! +//! Copyright & License: +//! - Copyright (c) 2010-2011 Dmitry Vyukov +//! - Simplified BSD License and Apache License, Version 2.0 +//! - http://www.1024cores.net/home/code-license + +use std::cell::UnsafeCell; +use std::marker::PhantomData; +use std::mem; +use std::ptr; +use std::sync::atomic::{self, AtomicUsize, Ordering}; +use std::time::Instant; + +use crossbeam_utils::{Backoff, CachePadded}; + +use context::Context; +use err::{RecvTimeoutError, SendTimeoutError, TryRecvError, TrySendError}; +use select::{Operation, SelectHandle, Selected, Token}; +use waker::SyncWaker; + +/// A slot in a channel. +struct Slot { + /// The current stamp. + stamp: AtomicUsize, + + /// The message in this slot. + msg: UnsafeCell, +} + +/// The token type for the array flavor. +#[derive(Debug)] +pub struct ArrayToken { + /// Slot to read from or write to. + slot: *const u8, + + /// Stamp to store into the slot after reading or writing. + stamp: usize, +} + +impl Default for ArrayToken { + #[inline] + fn default() -> Self { + ArrayToken { + slot: ptr::null(), + stamp: 0, + } + } +} + +/// Bounded channel based on a preallocated array. +pub struct Channel { + /// The head of the channel. + /// + /// This value is a "stamp" consisting of an index into the buffer, a mark bit, and a lap, but + /// packed into a single `usize`. The lower bits represent the index, while the upper bits + /// represent the lap. The mark bit in the head is always zero. + /// + /// Messages are popped from the head of the channel. + head: CachePadded, + + /// The tail of the channel. + /// + /// This value is a "stamp" consisting of an index into the buffer, a mark bit, and a lap, but + /// packed into a single `usize`. The lower bits represent the index, while the upper bits + /// represent the lap. The mark bit indicates that the channel is disconnected. + /// + /// Messages are pushed into the tail of the channel. + tail: CachePadded, + + /// The buffer holding slots. + buffer: *mut Slot, + + /// The channel capacity. + cap: usize, + + /// A stamp with the value of `{ lap: 1, mark: 0, index: 0 }`. + one_lap: usize, + + /// If this bit is set in the tail, that means the channel is disconnected. + mark_bit: usize, + + /// Senders waiting while the channel is full. + senders: SyncWaker, + + /// Receivers waiting while the channel is empty and not disconnected. + receivers: SyncWaker, + + /// Indicates that dropping a `Channel` may drop values of type `T`. + _marker: PhantomData, +} + +impl Channel { + /// Creates a bounded channel of capacity `cap`. + pub fn with_capacity(cap: usize) -> Self { + assert!(cap > 0, "capacity must be positive"); + + // Compute constants `mark_bit` and `one_lap`. + let mark_bit = (cap + 1).next_power_of_two(); + let one_lap = mark_bit * 2; + + // Head is initialized to `{ lap: 0, mark: 0, index: 0 }`. + let head = 0; + // Tail is initialized to `{ lap: 0, mark: 0, index: 0 }`. + let tail = 0; + + // Allocate a buffer of `cap` slots. + let buffer = { + let mut v = Vec::>::with_capacity(cap); + let ptr = v.as_mut_ptr(); + mem::forget(v); + ptr + }; + + // Initialize stamps in the slots. + for i in 0..cap { + unsafe { + // Set the stamp to `{ lap: 0, mark: 0, index: i }`. + let slot = buffer.add(i); + ptr::write(&mut (*slot).stamp, AtomicUsize::new(i)); + } + } + + Channel { + buffer, + cap, + one_lap, + mark_bit, + head: CachePadded::new(AtomicUsize::new(head)), + tail: CachePadded::new(AtomicUsize::new(tail)), + senders: SyncWaker::new(), + receivers: SyncWaker::new(), + _marker: PhantomData, + } + } + + /// Returns a receiver handle to the channel. + pub fn receiver(&self) -> Receiver { + Receiver(self) + } + + /// Returns a sender handle to the channel. + pub fn sender(&self) -> Sender { + Sender(self) + } + + /// Attempts to reserve a slot for sending a message. + fn start_send(&self, token: &mut Token) -> bool { + let backoff = Backoff::new(); + let mut tail = self.tail.load(Ordering::Relaxed); + + loop { + // Check if the channel is disconnected. + if tail & self.mark_bit != 0 { + token.array.slot = ptr::null(); + token.array.stamp = 0; + return true; + } + + // Deconstruct the tail. + let index = tail & (self.mark_bit - 1); + let lap = tail & !(self.one_lap - 1); + + // Inspect the corresponding slot. + let slot = unsafe { &*self.buffer.add(index) }; + let stamp = slot.stamp.load(Ordering::Acquire); + + // If the tail and the stamp match, we may attempt to push. + if tail == stamp { + let new_tail = if index + 1 < self.cap { + // Same lap, incremented index. + // Set to `{ lap: lap, mark: 0, index: index + 1 }`. + tail + 1 + } else { + // One lap forward, index wraps around to zero. + // Set to `{ lap: lap.wrapping_add(1), mark: 0, index: 0 }`. + lap.wrapping_add(self.one_lap) + }; + + // Try moving the tail. + match self.tail.compare_exchange_weak( + tail, + new_tail, + Ordering::SeqCst, + Ordering::Relaxed, + ) { + Ok(_) => { + // Prepare the token for the follow-up call to `write`. + token.array.slot = slot as *const Slot as *const u8; + token.array.stamp = tail + 1; + return true; + } + Err(t) => { + tail = t; + backoff.spin(); + } + } + } else if stamp.wrapping_add(self.one_lap) == tail + 1 { + atomic::fence(Ordering::SeqCst); + let head = self.head.load(Ordering::Relaxed); + + // If the head lags one lap behind the tail as well... + if head.wrapping_add(self.one_lap) == tail { + // ...then the channel is full. + return false; + } + + backoff.spin(); + tail = self.tail.load(Ordering::Relaxed); + } else { + // Snooze because we need to wait for the stamp to get updated. + backoff.snooze(); + tail = self.tail.load(Ordering::Relaxed); + } + } + } + + /// Writes a message into the channel. + pub unsafe fn write(&self, token: &mut Token, msg: T) -> Result<(), T> { + // If there is no slot, the channel is disconnected. + if token.array.slot.is_null() { + return Err(msg); + } + + let slot: &Slot = &*(token.array.slot as *const Slot); + + // Write the message into the slot and update the stamp. + slot.msg.get().write(msg); + slot.stamp.store(token.array.stamp, Ordering::Release); + + // Wake a sleeping receiver. + self.receivers.notify(); + Ok(()) + } + + /// Attempts to reserve a slot for receiving a message. + fn start_recv(&self, token: &mut Token) -> bool { + let backoff = Backoff::new(); + let mut head = self.head.load(Ordering::Relaxed); + + loop { + // Deconstruct the head. + let index = head & (self.mark_bit - 1); + let lap = head & !(self.one_lap - 1); + + // Inspect the corresponding slot. + let slot = unsafe { &*self.buffer.add(index) }; + let stamp = slot.stamp.load(Ordering::Acquire); + + // If the the stamp is ahead of the head by 1, we may attempt to pop. + if head + 1 == stamp { + let new = if index + 1 < self.cap { + // Same lap, incremented index. + // Set to `{ lap: lap, mark: 0, index: index + 1 }`. + head + 1 + } else { + // One lap forward, index wraps around to zero. + // Set to `{ lap: lap.wrapping_add(1), mark: 0, index: 0 }`. + lap.wrapping_add(self.one_lap) + }; + + // Try moving the head. + match self.head.compare_exchange_weak( + head, + new, + Ordering::SeqCst, + Ordering::Relaxed, + ) { + Ok(_) => { + // Prepare the token for the follow-up call to `read`. + token.array.slot = slot as *const Slot as *const u8; + token.array.stamp = head.wrapping_add(self.one_lap); + return true; + } + Err(h) => { + head = h; + backoff.spin(); + } + } + } else if stamp == head { + atomic::fence(Ordering::SeqCst); + let tail = self.tail.load(Ordering::Relaxed); + + // If the tail equals the head, that means the channel is empty. + if (tail & !self.mark_bit) == head { + // If the channel is disconnected... + if tail & self.mark_bit != 0 { + // ...then receive an error. + token.array.slot = ptr::null(); + token.array.stamp = 0; + return true; + } else { + // Otherwise, the receive operation is not ready. + return false; + } + } + + backoff.spin(); + head = self.head.load(Ordering::Relaxed); + } else { + // Snooze because we need to wait for the stamp to get updated. + backoff.snooze(); + head = self.head.load(Ordering::Relaxed); + } + } + } + + /// Reads a message from the channel. + pub unsafe fn read(&self, token: &mut Token) -> Result { + if token.array.slot.is_null() { + // The channel is disconnected. + return Err(()); + } + + let slot: &Slot = &*(token.array.slot as *const Slot); + + // Read the message from the slot and update the stamp. + let msg = slot.msg.get().read(); + slot.stamp.store(token.array.stamp, Ordering::Release); + + // Wake a sleeping sender. + self.senders.notify(); + Ok(msg) + } + + /// Attempts to send a message into the channel. + pub fn try_send(&self, msg: T) -> Result<(), TrySendError> { + let token = &mut Token::default(); + if self.start_send(token) { + unsafe { self.write(token, msg).map_err(TrySendError::Disconnected) } + } else { + Err(TrySendError::Full(msg)) + } + } + + /// Sends a message into the channel. + pub fn send(&self, msg: T, deadline: Option) -> Result<(), SendTimeoutError> { + let token = &mut Token::default(); + loop { + // Try sending a message several times. + let backoff = Backoff::new(); + loop { + if self.start_send(token) { + let res = unsafe { self.write(token, msg) }; + return res.map_err(SendTimeoutError::Disconnected); + } + + if backoff.is_completed() { + break; + } else { + backoff.snooze(); + } + } + + if let Some(d) = deadline { + if Instant::now() >= d { + return Err(SendTimeoutError::Timeout(msg)); + } + } + + Context::with(|cx| { + // Prepare for blocking until a receiver wakes us up. + let oper = Operation::hook(token); + self.senders.register(oper, cx); + + // Has the channel become ready just now? + if !self.is_full() || self.is_disconnected() { + let _ = cx.try_select(Selected::Aborted); + } + + // Block the current thread. + let sel = cx.wait_until(deadline); + + match sel { + Selected::Waiting => unreachable!(), + Selected::Aborted | Selected::Disconnected => { + self.senders.unregister(oper).unwrap(); + } + Selected::Operation(_) => {} + } + }); + } + } + + /// Attempts to receive a message without blocking. + pub fn try_recv(&self) -> Result { + let token = &mut Token::default(); + + if self.start_recv(token) { + unsafe { self.read(token).map_err(|_| TryRecvError::Disconnected) } + } else { + Err(TryRecvError::Empty) + } + } + + /// Receives a message from the channel. + pub fn recv(&self, deadline: Option) -> Result { + let token = &mut Token::default(); + loop { + // Try receiving a message several times. + let backoff = Backoff::new(); + loop { + if self.start_recv(token) { + let res = unsafe { self.read(token) }; + return res.map_err(|_| RecvTimeoutError::Disconnected); + } + + if backoff.is_completed() { + break; + } else { + backoff.snooze(); + } + } + + if let Some(d) = deadline { + if Instant::now() >= d { + return Err(RecvTimeoutError::Timeout); + } + } + + Context::with(|cx| { + // Prepare for blocking until a sender wakes us up. + let oper = Operation::hook(token); + self.receivers.register(oper, cx); + + // Has the channel become ready just now? + if !self.is_empty() || self.is_disconnected() { + let _ = cx.try_select(Selected::Aborted); + } + + // Block the current thread. + let sel = cx.wait_until(deadline); + + match sel { + Selected::Waiting => unreachable!(), + Selected::Aborted | Selected::Disconnected => { + self.receivers.unregister(oper).unwrap(); + // If the channel was disconnected, we still have to check for remaining + // messages. + } + Selected::Operation(_) => {} + } + }); + } + } + + /// Returns the current number of messages inside the channel. + pub fn len(&self) -> usize { + loop { + // Load the tail, then load the head. + let tail = self.tail.load(Ordering::SeqCst); + let head = self.head.load(Ordering::SeqCst); + + // If the tail didn't change, we've got consistent values to work with. + if self.tail.load(Ordering::SeqCst) == tail { + let hix = head & (self.mark_bit - 1); + let tix = tail & (self.mark_bit - 1); + + return if hix < tix { + tix - hix + } else if hix > tix { + self.cap - hix + tix + } else if (tail & !self.mark_bit) == head { + 0 + } else { + self.cap + }; + } + } + } + + /// Returns the capacity of the channel. + pub fn capacity(&self) -> Option { + Some(self.cap) + } + + /// Disconnects the channel and wakes up all blocked senders and receivers. + /// + /// Returns `true` if this call disconnected the channel. + pub fn disconnect(&self) -> bool { + let tail = self.tail.fetch_or(self.mark_bit, Ordering::SeqCst); + + if tail & self.mark_bit == 0 { + self.senders.disconnect(); + self.receivers.disconnect(); + true + } else { + false + } + } + + /// Returns `true` if the channel is disconnected. + pub fn is_disconnected(&self) -> bool { + self.tail.load(Ordering::SeqCst) & self.mark_bit != 0 + } + + /// Returns `true` if the channel is empty. + pub fn is_empty(&self) -> bool { + let head = self.head.load(Ordering::SeqCst); + let tail = self.tail.load(Ordering::SeqCst); + + // Is the tail equal to the head? + // + // Note: If the head changes just before we load the tail, that means there was a moment + // when the channel was not empty, so it is safe to just return `false`. + (tail & !self.mark_bit) == head + } + + /// Returns `true` if the channel is full. + pub fn is_full(&self) -> bool { + let tail = self.tail.load(Ordering::SeqCst); + let head = self.head.load(Ordering::SeqCst); + + // Is the head lagging one lap behind tail? + // + // Note: If the tail changes just before we load the head, that means there was a moment + // when the channel was not full, so it is safe to just return `false`. + head.wrapping_add(self.one_lap) == tail & !self.mark_bit + } +} + +impl Drop for Channel { + fn drop(&mut self) { + // Get the index of the head. + let hix = self.head.load(Ordering::Relaxed) & (self.mark_bit - 1); + + // Loop over all slots that hold a message and drop them. + for i in 0..self.len() { + // Compute the index of the next slot holding a message. + let index = if hix + i < self.cap { + hix + i + } else { + hix + i - self.cap + }; + + unsafe { + self.buffer.add(index).drop_in_place(); + } + } + + // Finally, deallocate the buffer, but don't run any destructors. + unsafe { + Vec::from_raw_parts(self.buffer, 0, self.cap); + } + } +} + +/// Receiver handle to a channel. +pub struct Receiver<'a, T: 'a>(&'a Channel); + +/// Sender handle to a channel. +pub struct Sender<'a, T: 'a>(&'a Channel); + +impl<'a, T> SelectHandle for Receiver<'a, T> { + fn try_select(&self, token: &mut Token) -> bool { + self.0.start_recv(token) + } + + fn deadline(&self) -> Option { + None + } + + fn register(&self, oper: Operation, cx: &Context) -> bool { + self.0.receivers.register(oper, cx); + self.is_ready() + } + + fn unregister(&self, oper: Operation) { + self.0.receivers.unregister(oper); + } + + fn accept(&self, token: &mut Token, _cx: &Context) -> bool { + self.try_select(token) + } + + fn is_ready(&self) -> bool { + !self.0.is_empty() || self.0.is_disconnected() + } + + fn watch(&self, oper: Operation, cx: &Context) -> bool { + self.0.receivers.watch(oper, cx); + self.is_ready() + } + + fn unwatch(&self, oper: Operation) { + self.0.receivers.unwatch(oper); + } +} + +impl<'a, T> SelectHandle for Sender<'a, T> { + fn try_select(&self, token: &mut Token) -> bool { + self.0.start_send(token) + } + + fn deadline(&self) -> Option { + None + } + + fn register(&self, oper: Operation, cx: &Context) -> bool { + self.0.senders.register(oper, cx); + self.is_ready() + } + + fn unregister(&self, oper: Operation) { + self.0.senders.unregister(oper); + } + + fn accept(&self, token: &mut Token, _cx: &Context) -> bool { + self.try_select(token) + } + + fn is_ready(&self) -> bool { + !self.0.is_full() || self.0.is_disconnected() + } + + fn watch(&self, oper: Operation, cx: &Context) -> bool { + self.0.senders.watch(oper, cx); + self.is_ready() + } + + fn unwatch(&self, oper: Operation) { + self.0.senders.unwatch(oper); + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/list.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/list.rs new file mode 100644 index 0000000..ae286d3 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/list.rs @@ -0,0 +1,664 @@ +//! Unbounded channel implemented as a linked list. + +use std::cell::UnsafeCell; +use std::marker::PhantomData; +use std::mem::{self, ManuallyDrop}; +use std::ptr; +use std::sync::atomic::{self, AtomicPtr, AtomicUsize, Ordering}; +use std::time::Instant; + +use crossbeam_utils::{Backoff, CachePadded}; + +use context::Context; +use err::{RecvTimeoutError, SendTimeoutError, TryRecvError, TrySendError}; +use select::{Operation, SelectHandle, Selected, Token}; +use waker::SyncWaker; + +// TODO(stjepang): Once we bump the minimum required Rust version to 1.28 or newer, re-apply the +// following changes by @kleimkuhler: +// +// 1. https://github.com/crossbeam-rs/crossbeam-channel/pull/100 +// 2. https://github.com/crossbeam-rs/crossbeam-channel/pull/101 + +// Bits indicating the state of a slot: +// * If a message has been written into the slot, `WRITE` is set. +// * If a message has been read from the slot, `READ` is set. +// * If the block is being destroyed, `DESTROY` is set. +const WRITE: usize = 1; +const READ: usize = 2; +const DESTROY: usize = 4; + +// Each block covers one "lap" of indices. +const LAP: usize = 32; +// The maximum number of messages a block can hold. +const BLOCK_CAP: usize = LAP - 1; +// How many lower bits are reserved for metadata. +const SHIFT: usize = 1; +// Has two different purposes: +// * If set in head, indicates that the block is not the last one. +// * If set in tail, indicates that the channel is disconnected. +const MARK_BIT: usize = 1; + +/// A slot in a block. +struct Slot { + /// The message. + msg: UnsafeCell>, + + /// The state of the slot. + state: AtomicUsize, +} + +impl Slot { + /// Waits until a message is written into the slot. + fn wait_write(&self) { + let backoff = Backoff::new(); + while self.state.load(Ordering::Acquire) & WRITE == 0 { + backoff.snooze(); + } + } +} + +/// A block in a linked list. +/// +/// Each block in the list can hold up to `BLOCK_CAP` messages. +struct Block { + /// The next block in the linked list. + next: AtomicPtr>, + + /// Slots for messages. + slots: [Slot; BLOCK_CAP], +} + +impl Block { + /// Creates an empty block. + fn new() -> Block { + unsafe { mem::zeroed() } + } + + /// Waits until the next pointer is set. + fn wait_next(&self) -> *mut Block { + let backoff = Backoff::new(); + loop { + let next = self.next.load(Ordering::Acquire); + if !next.is_null() { + return next; + } + backoff.snooze(); + } + } + + /// Sets the `DESTROY` bit in slots starting from `start` and destroys the block. + unsafe fn destroy(this: *mut Block, start: usize) { + // It is not necessary to set the `DESTROY bit in the last slot because that slot has begun + // destruction of the block. + for i in start..BLOCK_CAP - 1 { + let slot = (*this).slots.get_unchecked(i); + + // Mark the `DESTROY` bit if a thread is still using the slot. + if slot.state.load(Ordering::Acquire) & READ == 0 + && slot.state.fetch_or(DESTROY, Ordering::AcqRel) & READ == 0 + { + // If a thread is still using the slot, it will continue destruction of the block. + return; + } + } + + // No thread is using the block, now it is safe to destroy it. + drop(Box::from_raw(this)); + } +} + +/// A position in a channel. +#[derive(Debug)] +struct Position { + /// The index in the channel. + index: AtomicUsize, + + /// The block in the linked list. + block: AtomicPtr>, +} + +/// The token type for the list flavor. +#[derive(Debug)] +pub struct ListToken { + /// The block of slots. + block: *const u8, + + /// The offset into the block. + offset: usize, +} + +impl Default for ListToken { + #[inline] + fn default() -> Self { + ListToken { + block: ptr::null(), + offset: 0, + } + } +} + +/// Unbounded channel implemented as a linked list. +/// +/// Each message sent into the channel is assigned a sequence number, i.e. an index. Indices are +/// represented as numbers of type `usize` and wrap on overflow. +/// +/// Consecutive messages are grouped into blocks in order to put less pressure on the allocator and +/// improve cache efficiency. +pub struct Channel { + /// The head of the channel. + head: CachePadded>, + + /// The tail of the channel. + tail: CachePadded>, + + /// Receivers waiting while the channel is empty and not disconnected. + receivers: SyncWaker, + + /// Indicates that dropping a `Channel` may drop messages of type `T`. + _marker: PhantomData, +} + +impl Channel { + /// Creates a new unbounded channel. + pub fn new() -> Self { + Channel { + head: CachePadded::new(Position { + block: AtomicPtr::new(ptr::null_mut()), + index: AtomicUsize::new(0), + }), + tail: CachePadded::new(Position { + block: AtomicPtr::new(ptr::null_mut()), + index: AtomicUsize::new(0), + }), + receivers: SyncWaker::new(), + _marker: PhantomData, + } + } + + /// Returns a receiver handle to the channel. + pub fn receiver(&self) -> Receiver { + Receiver(self) + } + + /// Returns a sender handle to the channel. + pub fn sender(&self) -> Sender { + Sender(self) + } + + /// Attempts to reserve a slot for sending a message. + fn start_send(&self, token: &mut Token) -> bool { + let backoff = Backoff::new(); + let mut tail = self.tail.index.load(Ordering::Acquire); + let mut block = self.tail.block.load(Ordering::Acquire); + let mut next_block = None; + + loop { + // Check if the channel is disconnected. + if tail & MARK_BIT != 0 { + token.list.block = ptr::null(); + return true; + } + + // Calculate the offset of the index into the block. + let offset = (tail >> SHIFT) % LAP; + + // If we reached the end of the block, wait until the next one is installed. + if offset == BLOCK_CAP { + backoff.snooze(); + tail = self.tail.index.load(Ordering::Acquire); + block = self.tail.block.load(Ordering::Acquire); + continue; + } + + // If we're going to have to install the next block, allocate it in advance in order to + // make the wait for other threads as short as possible. + if offset + 1 == BLOCK_CAP && next_block.is_none() { + next_block = Some(Box::new(Block::::new())); + } + + // If this is the first message to be sent into the channel, we need to allocate the + // first block and install it. + if block.is_null() { + let new = Box::into_raw(Box::new(Block::::new())); + + if self + .tail + .block + .compare_and_swap(block, new, Ordering::Release) + == block + { + self.head.block.store(new, Ordering::Release); + block = new; + } else { + next_block = unsafe { Some(Box::from_raw(new)) }; + tail = self.tail.index.load(Ordering::Acquire); + block = self.tail.block.load(Ordering::Acquire); + continue; + } + } + + let new_tail = tail + (1 << SHIFT); + + // Try advancing the tail forward. + match self.tail.index.compare_exchange_weak( + tail, + new_tail, + Ordering::SeqCst, + Ordering::Acquire, + ) { + Ok(_) => unsafe { + // If we've reached the end of the block, install the next one. + if offset + 1 == BLOCK_CAP { + let next_block = Box::into_raw(next_block.unwrap()); + self.tail.block.store(next_block, Ordering::Release); + self.tail.index.fetch_add(1 << SHIFT, Ordering::Release); + (*block).next.store(next_block, Ordering::Release); + } + + token.list.block = block as *const u8; + token.list.offset = offset; + return true; + }, + Err(t) => { + tail = t; + block = self.tail.block.load(Ordering::Acquire); + backoff.spin(); + } + } + } + } + + /// Writes a message into the channel. + pub unsafe fn write(&self, token: &mut Token, msg: T) -> Result<(), T> { + // If there is no slot, the channel is disconnected. + if token.list.block.is_null() { + return Err(msg); + } + + // Write the message into the slot. + let block = token.list.block as *mut Block; + let offset = token.list.offset; + let slot = (*block).slots.get_unchecked(offset); + slot.msg.get().write(ManuallyDrop::new(msg)); + slot.state.fetch_or(WRITE, Ordering::Release); + + // Wake a sleeping receiver. + self.receivers.notify(); + Ok(()) + } + + /// Attempts to reserve a slot for receiving a message. + fn start_recv(&self, token: &mut Token) -> bool { + let backoff = Backoff::new(); + let mut head = self.head.index.load(Ordering::Acquire); + let mut block = self.head.block.load(Ordering::Acquire); + + loop { + // Calculate the offset of the index into the block. + let offset = (head >> SHIFT) % LAP; + + // If we reached the end of the block, wait until the next one is installed. + if offset == BLOCK_CAP { + backoff.snooze(); + head = self.head.index.load(Ordering::Acquire); + block = self.head.block.load(Ordering::Acquire); + continue; + } + + let mut new_head = head + (1 << SHIFT); + + if new_head & MARK_BIT == 0 { + atomic::fence(Ordering::SeqCst); + let tail = self.tail.index.load(Ordering::Relaxed); + + // If the tail equals the head, that means the channel is empty. + if head >> SHIFT == tail >> SHIFT { + // If the channel is disconnected... + if tail & MARK_BIT != 0 { + // ...then receive an error. + token.list.block = ptr::null(); + return true; + } else { + // Otherwise, the receive operation is not ready. + return false; + } + } + + // If head and tail are not in the same block, set `MARK_BIT` in head. + if (head >> SHIFT) / LAP != (tail >> SHIFT) / LAP { + new_head |= MARK_BIT; + } + } + + // The block can be null here only if the first message is being sent into the channel. + // In that case, just wait until it gets initialized. + if block.is_null() { + backoff.snooze(); + head = self.head.index.load(Ordering::Acquire); + block = self.head.block.load(Ordering::Acquire); + continue; + } + + // Try moving the head index forward. + match self.head.index.compare_exchange_weak( + head, + new_head, + Ordering::SeqCst, + Ordering::Acquire, + ) { + Ok(_) => unsafe { + // If we've reached the end of the block, move to the next one. + if offset + 1 == BLOCK_CAP { + let next = (*block).wait_next(); + let mut next_index = (new_head & !MARK_BIT).wrapping_add(1 << SHIFT); + if !(*next).next.load(Ordering::Relaxed).is_null() { + next_index |= MARK_BIT; + } + + self.head.block.store(next, Ordering::Release); + self.head.index.store(next_index, Ordering::Release); + } + + token.list.block = block as *const u8; + token.list.offset = offset; + return true; + }, + Err(h) => { + head = h; + block = self.head.block.load(Ordering::Acquire); + backoff.spin(); + } + } + } + } + + /// Reads a message from the channel. + pub unsafe fn read(&self, token: &mut Token) -> Result { + if token.list.block.is_null() { + // The channel is disconnected. + return Err(()); + } + + // Read the message. + let block = token.list.block as *mut Block; + let offset = token.list.offset; + let slot = (*block).slots.get_unchecked(offset); + slot.wait_write(); + let m = slot.msg.get().read(); + let msg = ManuallyDrop::into_inner(m); + + // Destroy the block if we've reached the end, or if another thread wanted to destroy but + // couldn't because we were busy reading from the slot. + if offset + 1 == BLOCK_CAP { + Block::destroy(block, 0); + } else if slot.state.fetch_or(READ, Ordering::AcqRel) & DESTROY != 0 { + Block::destroy(block, offset + 1); + } + + Ok(msg) + } + + /// Attempts to send a message into the channel. + pub fn try_send(&self, msg: T) -> Result<(), TrySendError> { + self.send(msg, None).map_err(|err| match err { + SendTimeoutError::Disconnected(msg) => TrySendError::Disconnected(msg), + SendTimeoutError::Timeout(_) => unreachable!(), + }) + } + + /// Sends a message into the channel. + pub fn send(&self, msg: T, _deadline: Option) -> Result<(), SendTimeoutError> { + let token = &mut Token::default(); + assert!(self.start_send(token)); + unsafe { + self.write(token, msg) + .map_err(SendTimeoutError::Disconnected) + } + } + + /// Attempts to receive a message without blocking. + pub fn try_recv(&self) -> Result { + let token = &mut Token::default(); + + if self.start_recv(token) { + unsafe { self.read(token).map_err(|_| TryRecvError::Disconnected) } + } else { + Err(TryRecvError::Empty) + } + } + + /// Receives a message from the channel. + pub fn recv(&self, deadline: Option) -> Result { + let token = &mut Token::default(); + loop { + // Try receiving a message several times. + let backoff = Backoff::new(); + loop { + if self.start_recv(token) { + unsafe { + return self.read(token).map_err(|_| RecvTimeoutError::Disconnected); + } + } + + if backoff.is_completed() { + break; + } else { + backoff.snooze(); + } + } + + if let Some(d) = deadline { + if Instant::now() >= d { + return Err(RecvTimeoutError::Timeout); + } + } + + // Prepare for blocking until a sender wakes us up. + Context::with(|cx| { + let oper = Operation::hook(token); + self.receivers.register(oper, cx); + + // Has the channel become ready just now? + if !self.is_empty() || self.is_disconnected() { + let _ = cx.try_select(Selected::Aborted); + } + + // Block the current thread. + let sel = cx.wait_until(deadline); + + match sel { + Selected::Waiting => unreachable!(), + Selected::Aborted | Selected::Disconnected => { + self.receivers.unregister(oper).unwrap(); + // If the channel was disconnected, we still have to check for remaining + // messages. + } + Selected::Operation(_) => {} + } + }); + } + } + + /// Returns the current number of messages inside the channel. + pub fn len(&self) -> usize { + loop { + // Load the tail index, then load the head index. + let mut tail = self.tail.index.load(Ordering::SeqCst); + let mut head = self.head.index.load(Ordering::SeqCst); + + // If the tail index didn't change, we've got consistent indices to work with. + if self.tail.index.load(Ordering::SeqCst) == tail { + // Erase the lower bits. + tail &= !((1 << SHIFT) - 1); + head &= !((1 << SHIFT) - 1); + + // Rotate indices so that head falls into the first block. + let lap = (head >> SHIFT) / LAP; + tail = tail.wrapping_sub((lap * LAP) << SHIFT); + head = head.wrapping_sub((lap * LAP) << SHIFT); + + // Remove the lower bits. + tail >>= SHIFT; + head >>= SHIFT; + + // Fix up indices if they fall onto block ends. + if head == BLOCK_CAP { + head = 0; + tail -= LAP; + } + if tail == BLOCK_CAP { + tail += 1; + } + + // Return the difference minus the number of blocks between tail and head. + return tail - head - tail / LAP; + } + } + } + + /// Returns the capacity of the channel. + pub fn capacity(&self) -> Option { + None + } + + /// Disconnects the channel and wakes up all blocked receivers. + /// + /// Returns `true` if this call disconnected the channel. + pub fn disconnect(&self) -> bool { + let tail = self.tail.index.fetch_or(MARK_BIT, Ordering::SeqCst); + + if tail & MARK_BIT == 0 { + self.receivers.disconnect(); + true + } else { + false + } + } + + /// Returns `true` if the channel is disconnected. + pub fn is_disconnected(&self) -> bool { + self.tail.index.load(Ordering::SeqCst) & MARK_BIT != 0 + } + + /// Returns `true` if the channel is empty. + pub fn is_empty(&self) -> bool { + let head = self.head.index.load(Ordering::SeqCst); + let tail = self.tail.index.load(Ordering::SeqCst); + head >> SHIFT == tail >> SHIFT + } + + /// Returns `true` if the channel is full. + pub fn is_full(&self) -> bool { + false + } +} + +impl Drop for Channel { + fn drop(&mut self) { + let mut head = self.head.index.load(Ordering::Relaxed); + let mut tail = self.tail.index.load(Ordering::Relaxed); + let mut block = self.head.block.load(Ordering::Relaxed); + + // Erase the lower bits. + head &= !((1 << SHIFT) - 1); + tail &= !((1 << SHIFT) - 1); + + unsafe { + // Drop all messages between head and tail and deallocate the heap-allocated blocks. + while head != tail { + let offset = (head >> SHIFT) % LAP; + + if offset < BLOCK_CAP { + // Drop the message in the slot. + let slot = (*block).slots.get_unchecked(offset); + ManuallyDrop::drop(&mut *(*slot).msg.get()); + } else { + // Deallocate the block and move to the next one. + let next = (*block).next.load(Ordering::Relaxed); + drop(Box::from_raw(block)); + block = next; + } + + head = head.wrapping_add(1 << SHIFT); + } + + // Deallocate the last remaining block. + if !block.is_null() { + drop(Box::from_raw(block)); + } + } + } +} + +/// Receiver handle to a channel. +pub struct Receiver<'a, T: 'a>(&'a Channel); + +/// Sender handle to a channel. +pub struct Sender<'a, T: 'a>(&'a Channel); + +impl<'a, T> SelectHandle for Receiver<'a, T> { + fn try_select(&self, token: &mut Token) -> bool { + self.0.start_recv(token) + } + + fn deadline(&self) -> Option { + None + } + + fn register(&self, oper: Operation, cx: &Context) -> bool { + self.0.receivers.register(oper, cx); + self.is_ready() + } + + fn unregister(&self, oper: Operation) { + self.0.receivers.unregister(oper); + } + + fn accept(&self, token: &mut Token, _cx: &Context) -> bool { + self.try_select(token) + } + + fn is_ready(&self) -> bool { + !self.0.is_empty() || self.0.is_disconnected() + } + + fn watch(&self, oper: Operation, cx: &Context) -> bool { + self.0.receivers.watch(oper, cx); + self.is_ready() + } + + fn unwatch(&self, oper: Operation) { + self.0.receivers.unwatch(oper); + } +} + +impl<'a, T> SelectHandle for Sender<'a, T> { + fn try_select(&self, token: &mut Token) -> bool { + self.0.start_send(token) + } + + fn deadline(&self) -> Option { + None + } + + fn register(&self, _oper: Operation, _cx: &Context) -> bool { + self.is_ready() + } + + fn unregister(&self, _oper: Operation) {} + + fn accept(&self, token: &mut Token, _cx: &Context) -> bool { + self.try_select(token) + } + + fn is_ready(&self) -> bool { + true + } + + fn watch(&self, _oper: Operation, _cx: &Context) -> bool { + self.is_ready() + } + + fn unwatch(&self, _oper: Operation) {} +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/mod.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/mod.rs new file mode 100644 index 0000000..ebd0cfa --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/mod.rs @@ -0,0 +1,17 @@ +//! Channel flavors. +//! +//! There are six flavors: +//! +//! 1. `after` - Channel that delivers a message after a certain amount of time. +//! 2. `array` - Bounded channel based on a preallocated array. +//! 3. `list` - Unbounded channel implemented as a linked list. +//! 4. `never` - Channel that never delivers messages. +//! 5. `tick` - Channel that delivers messages periodically. +//! 6. `zero` - Zero-capacity channel. + +pub mod after; +pub mod array; +pub mod list; +pub mod never; +pub mod tick; +pub mod zero; diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/never.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/never.rs new file mode 100644 index 0000000..5fb12e6 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/never.rs @@ -0,0 +1,110 @@ +//! Channel that never delivers messages. +//! +//! Messages cannot be sent into this kind of channel. + +use std::marker::PhantomData; +use std::time::Instant; + +use context::Context; +use err::{RecvTimeoutError, TryRecvError}; +use select::{Operation, SelectHandle, Token}; +use utils; + +/// This flavor doesn't need a token. +pub type NeverToken = (); + +/// Channel that never delivers messages. +pub struct Channel { + _marker: PhantomData, +} + +impl Channel { + /// Creates a channel that never delivers messages. + #[inline] + pub fn new() -> Self { + Channel { + _marker: PhantomData, + } + } + + /// Attempts to receive a message without blocking. + #[inline] + pub fn try_recv(&self) -> Result { + Err(TryRecvError::Empty) + } + + /// Receives a message from the channel. + #[inline] + pub fn recv(&self, deadline: Option) -> Result { + utils::sleep_until(deadline); + Err(RecvTimeoutError::Timeout) + } + + /// Reads a message from the channel. + #[inline] + pub unsafe fn read(&self, _token: &mut Token) -> Result { + Err(()) + } + + /// Returns `true` if the channel is empty. + #[inline] + pub fn is_empty(&self) -> bool { + true + } + + /// Returns `true` if the channel is full. + #[inline] + pub fn is_full(&self) -> bool { + true + } + + /// Returns the number of messages in the channel. + #[inline] + pub fn len(&self) -> usize { + 0 + } + + /// Returns the capacity of the channel. + #[inline] + pub fn capacity(&self) -> Option { + Some(0) + } +} + +impl SelectHandle for Channel { + #[inline] + fn try_select(&self, _token: &mut Token) -> bool { + false + } + + #[inline] + fn deadline(&self) -> Option { + None + } + + #[inline] + fn register(&self, _oper: Operation, _cx: &Context) -> bool { + self.is_ready() + } + + #[inline] + fn unregister(&self, _oper: Operation) {} + + #[inline] + fn accept(&self, token: &mut Token, _cx: &Context) -> bool { + self.try_select(token) + } + + #[inline] + fn is_ready(&self) -> bool { + false + } + + #[inline] + fn watch(&self, _oper: Operation, _cx: &Context) -> bool { + self.is_ready() + } + + #[inline] + fn unwatch(&self, _oper: Operation) {} +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/tick.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/tick.rs new file mode 100644 index 0000000..3933886 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/tick.rs @@ -0,0 +1,173 @@ +//! Channel that delivers messages periodically. +//! +//! Messages cannot be sent into this kind of channel; they are materialized on demand. + +use std::thread; +use std::time::{Duration, Instant}; + +use crossbeam_utils::atomic::AtomicCell; + +use context::Context; +use err::{RecvTimeoutError, TryRecvError}; +use select::{Operation, SelectHandle, Token}; + +/// Result of a receive operation. +pub type TickToken = Option; + +/// Channel that delivers messages periodically. +pub struct Channel { + /// The instant at which the next message will be delivered. + delivery_time: AtomicCell, + + /// The time interval in which messages get delivered. + duration: Duration, +} + +impl Channel { + /// Creates a channel that delivers messages periodically. + #[inline] + pub fn new(dur: Duration) -> Self { + Channel { + delivery_time: AtomicCell::new(Instant::now() + dur), + duration: dur, + } + } + + /// Attempts to receive a message without blocking. + #[inline] + pub fn try_recv(&self) -> Result { + loop { + let now = Instant::now(); + let delivery_time = self.delivery_time.load(); + + if now < delivery_time { + return Err(TryRecvError::Empty); + } + + if self + .delivery_time + .compare_exchange(delivery_time, now + self.duration) + .is_ok() + { + return Ok(delivery_time); + } + } + } + + /// Receives a message from the channel. + #[inline] + pub fn recv(&self, deadline: Option) -> Result { + loop { + // Compute the time to sleep until the next message or the deadline. + let offset = { + let delivery_time = self.delivery_time.load(); + let now = Instant::now(); + + // Check if we can receive the next message. + if now >= delivery_time + && self + .delivery_time + .compare_exchange(delivery_time, now + self.duration) + .is_ok() + { + return Ok(delivery_time); + } + + // Check if the operation deadline has been reached. + if let Some(d) = deadline { + if now >= d { + return Err(RecvTimeoutError::Timeout); + } + + delivery_time.min(d) - now + } else { + delivery_time - now + } + }; + + thread::sleep(offset); + } + } + + /// Reads a message from the channel. + #[inline] + pub unsafe fn read(&self, token: &mut Token) -> Result { + token.tick.ok_or(()) + } + + /// Returns `true` if the channel is empty. + #[inline] + pub fn is_empty(&self) -> bool { + Instant::now() < self.delivery_time.load() + } + + /// Returns `true` if the channel is full. + #[inline] + pub fn is_full(&self) -> bool { + !self.is_empty() + } + + /// Returns the number of messages in the channel. + #[inline] + pub fn len(&self) -> usize { + if self.is_empty() { + 0 + } else { + 1 + } + } + + /// Returns the capacity of the channel. + #[inline] + pub fn capacity(&self) -> Option { + Some(1) + } +} + +impl SelectHandle for Channel { + #[inline] + fn try_select(&self, token: &mut Token) -> bool { + match self.try_recv() { + Ok(msg) => { + token.tick = Some(msg); + true + } + Err(TryRecvError::Disconnected) => { + token.tick = None; + true + } + Err(TryRecvError::Empty) => false, + } + } + + #[inline] + fn deadline(&self) -> Option { + Some(self.delivery_time.load()) + } + + #[inline] + fn register(&self, _oper: Operation, _cx: &Context) -> bool { + self.is_ready() + } + + #[inline] + fn unregister(&self, _oper: Operation) {} + + #[inline] + fn accept(&self, token: &mut Token, _cx: &Context) -> bool { + self.try_select(token) + } + + #[inline] + fn is_ready(&self) -> bool { + !self.is_empty() + } + + #[inline] + fn watch(&self, _oper: Operation, _cx: &Context) -> bool { + self.is_ready() + } + + #[inline] + fn unwatch(&self, _oper: Operation) {} +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/zero.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/zero.rs new file mode 100644 index 0000000..ee1bfc5 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/flavors/zero.rs @@ -0,0 +1,466 @@ +//! Zero-capacity channel. +//! +//! This kind of channel is also known as *rendezvous* channel. + +use std::cell::UnsafeCell; +use std::marker::PhantomData; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::time::Instant; + +use crossbeam_utils::Backoff; + +use context::Context; +use err::{RecvTimeoutError, SendTimeoutError, TryRecvError, TrySendError}; +use select::{Operation, SelectHandle, Selected, Token}; +use utils::Spinlock; +use waker::Waker; + +/// A pointer to a packet. +pub type ZeroToken = usize; + +/// A slot for passing one message from a sender to a receiver. +struct Packet { + /// Equals `true` if the packet is allocated on the stack. + on_stack: bool, + + /// Equals `true` once the packet is ready for reading or writing. + ready: AtomicBool, + + /// The message. + msg: UnsafeCell>, +} + +impl Packet { + /// Creates an empty packet on the stack. + fn empty_on_stack() -> Packet { + Packet { + on_stack: true, + ready: AtomicBool::new(false), + msg: UnsafeCell::new(None), + } + } + + /// Creates an empty packet on the heap. + fn empty_on_heap() -> Box> { + Box::new(Packet { + on_stack: false, + ready: AtomicBool::new(false), + msg: UnsafeCell::new(None), + }) + } + + /// Creates a packet on the stack, containing a message. + fn message_on_stack(msg: T) -> Packet { + Packet { + on_stack: true, + ready: AtomicBool::new(false), + msg: UnsafeCell::new(Some(msg)), + } + } + + /// Waits until the packet becomes ready for reading or writing. + fn wait_ready(&self) { + let backoff = Backoff::new(); + while !self.ready.load(Ordering::Acquire) { + backoff.snooze(); + } + } +} + +/// Inner representation of a zero-capacity channel. +struct Inner { + /// Senders waiting to pair up with a receive operation. + senders: Waker, + + /// Receivers waiting to pair up with a send operation. + receivers: Waker, + + /// Equals `true` when the channel is disconnected. + is_disconnected: bool, +} + +/// Zero-capacity channel. +pub struct Channel { + /// Inner representation of the channel. + inner: Spinlock, + + /// Indicates that dropping a `Channel` may drop values of type `T`. + _marker: PhantomData, +} + +impl Channel { + /// Constructs a new zero-capacity channel. + pub fn new() -> Self { + Channel { + inner: Spinlock::new(Inner { + senders: Waker::new(), + receivers: Waker::new(), + is_disconnected: false, + }), + _marker: PhantomData, + } + } + + /// Returns a receiver handle to the channel. + pub fn receiver(&self) -> Receiver { + Receiver(self) + } + + /// Returns a sender handle to the channel. + pub fn sender(&self) -> Sender { + Sender(self) + } + + /// Attempts to reserve a slot for sending a message. + fn start_send(&self, token: &mut Token) -> bool { + let mut inner = self.inner.lock(); + + // If there's a waiting receiver, pair up with it. + if let Some(operation) = inner.receivers.try_select() { + token.zero = operation.packet; + true + } else if inner.is_disconnected { + token.zero = 0; + true + } else { + false + } + } + + /// Writes a message into the packet. + pub unsafe fn write(&self, token: &mut Token, msg: T) -> Result<(), T> { + // If there is no packet, the channel is disconnected. + if token.zero == 0 { + return Err(msg); + } + + let packet = &*(token.zero as *const Packet); + packet.msg.get().write(Some(msg)); + packet.ready.store(true, Ordering::Release); + Ok(()) + } + + /// Attempts to pair up with a sender. + fn start_recv(&self, token: &mut Token) -> bool { + let mut inner = self.inner.lock(); + + // If there's a waiting sender, pair up with it. + if let Some(operation) = inner.senders.try_select() { + token.zero = operation.packet; + true + } else if inner.is_disconnected { + token.zero = 0; + true + } else { + false + } + } + + /// Reads a message from the packet. + pub unsafe fn read(&self, token: &mut Token) -> Result { + // If there is no packet, the channel is disconnected. + if token.zero == 0 { + return Err(()); + } + + let packet = &*(token.zero as *const Packet); + + if packet.on_stack { + // The message has been in the packet from the beginning, so there is no need to wait + // for it. However, after reading the message, we need to set `ready` to `true` in + // order to signal that the packet can be destroyed. + let msg = packet.msg.get().replace(None).unwrap(); + packet.ready.store(true, Ordering::Release); + Ok(msg) + } else { + // Wait until the message becomes available, then read it and destroy the + // heap-allocated packet. + packet.wait_ready(); + let msg = packet.msg.get().replace(None).unwrap(); + drop(Box::from_raw(packet as *const Packet as *mut Packet)); + Ok(msg) + } + } + + /// Attempts to send a message into the channel. + pub fn try_send(&self, msg: T) -> Result<(), TrySendError> { + let token = &mut Token::default(); + let mut inner = self.inner.lock(); + + // If there's a waiting receiver, pair up with it. + if let Some(operation) = inner.receivers.try_select() { + token.zero = operation.packet; + drop(inner); + unsafe { + self.write(token, msg).ok().unwrap(); + } + Ok(()) + } else if inner.is_disconnected { + Err(TrySendError::Disconnected(msg)) + } else { + Err(TrySendError::Full(msg)) + } + } + + /// Sends a message into the channel. + pub fn send(&self, msg: T, deadline: Option) -> Result<(), SendTimeoutError> { + let token = &mut Token::default(); + let mut inner = self.inner.lock(); + + // If there's a waiting receiver, pair up with it. + if let Some(operation) = inner.receivers.try_select() { + token.zero = operation.packet; + drop(inner); + unsafe { + self.write(token, msg).ok().unwrap(); + } + return Ok(()); + } + + if inner.is_disconnected { + return Err(SendTimeoutError::Disconnected(msg)); + } + + Context::with(|cx| { + // Prepare for blocking until a receiver wakes us up. + let oper = Operation::hook(token); + let packet = Packet::::message_on_stack(msg); + inner + .senders + .register_with_packet(oper, &packet as *const Packet as usize, cx); + inner.receivers.notify(); + drop(inner); + + // Block the current thread. + let sel = cx.wait_until(deadline); + + match sel { + Selected::Waiting => unreachable!(), + Selected::Aborted => { + self.inner.lock().senders.unregister(oper).unwrap(); + let msg = unsafe { packet.msg.get().replace(None).unwrap() }; + Err(SendTimeoutError::Timeout(msg)) + } + Selected::Disconnected => { + self.inner.lock().senders.unregister(oper).unwrap(); + let msg = unsafe { packet.msg.get().replace(None).unwrap() }; + Err(SendTimeoutError::Disconnected(msg)) + } + Selected::Operation(_) => { + // Wait until the message is read, then drop the packet. + packet.wait_ready(); + Ok(()) + } + } + }) + } + + /// Attempts to receive a message without blocking. + pub fn try_recv(&self) -> Result { + let token = &mut Token::default(); + let mut inner = self.inner.lock(); + + // If there's a waiting sender, pair up with it. + if let Some(operation) = inner.senders.try_select() { + token.zero = operation.packet; + drop(inner); + unsafe { self.read(token).map_err(|_| TryRecvError::Disconnected) } + } else if inner.is_disconnected { + Err(TryRecvError::Disconnected) + } else { + Err(TryRecvError::Empty) + } + } + + /// Receives a message from the channel. + pub fn recv(&self, deadline: Option) -> Result { + let token = &mut Token::default(); + let mut inner = self.inner.lock(); + + // If there's a waiting sender, pair up with it. + if let Some(operation) = inner.senders.try_select() { + token.zero = operation.packet; + drop(inner); + unsafe { + return self.read(token).map_err(|_| RecvTimeoutError::Disconnected); + } + } + + if inner.is_disconnected { + return Err(RecvTimeoutError::Disconnected); + } + + Context::with(|cx| { + // Prepare for blocking until a sender wakes us up. + let oper = Operation::hook(token); + let packet = Packet::::empty_on_stack(); + inner + .receivers + .register_with_packet(oper, &packet as *const Packet as usize, cx); + inner.senders.notify(); + drop(inner); + + // Block the current thread. + let sel = cx.wait_until(deadline); + + match sel { + Selected::Waiting => unreachable!(), + Selected::Aborted => { + self.inner.lock().receivers.unregister(oper).unwrap(); + Err(RecvTimeoutError::Timeout) + } + Selected::Disconnected => { + self.inner.lock().receivers.unregister(oper).unwrap(); + Err(RecvTimeoutError::Disconnected) + } + Selected::Operation(_) => { + // Wait until the message is provided, then read it. + packet.wait_ready(); + unsafe { Ok(packet.msg.get().replace(None).unwrap()) } + } + } + }) + } + + /// Disconnects the channel and wakes up all blocked senders and receivers. + /// + /// Returns `true` if this call disconnected the channel. + pub fn disconnect(&self) -> bool { + let mut inner = self.inner.lock(); + + if !inner.is_disconnected { + inner.is_disconnected = true; + inner.senders.disconnect(); + inner.receivers.disconnect(); + true + } else { + false + } + } + + /// Returns the current number of messages inside the channel. + pub fn len(&self) -> usize { + 0 + } + + /// Returns the capacity of the channel. + pub fn capacity(&self) -> Option { + Some(0) + } + + /// Returns `true` if the channel is empty. + pub fn is_empty(&self) -> bool { + true + } + + /// Returns `true` if the channel is full. + pub fn is_full(&self) -> bool { + true + } +} + +/// Receiver handle to a channel. +pub struct Receiver<'a, T: 'a>(&'a Channel); + +/// Sender handle to a channel. +pub struct Sender<'a, T: 'a>(&'a Channel); + +impl<'a, T> SelectHandle for Receiver<'a, T> { + fn try_select(&self, token: &mut Token) -> bool { + self.0.start_recv(token) + } + + fn deadline(&self) -> Option { + None + } + + fn register(&self, oper: Operation, cx: &Context) -> bool { + let packet = Box::into_raw(Packet::::empty_on_heap()); + + let mut inner = self.0.inner.lock(); + inner + .receivers + .register_with_packet(oper, packet as usize, cx); + inner.senders.notify(); + inner.senders.can_select() || inner.is_disconnected + } + + fn unregister(&self, oper: Operation) { + if let Some(operation) = self.0.inner.lock().receivers.unregister(oper) { + unsafe { + drop(Box::from_raw(operation.packet as *mut Packet)); + } + } + } + + fn accept(&self, token: &mut Token, cx: &Context) -> bool { + token.zero = cx.wait_packet(); + true + } + + fn is_ready(&self) -> bool { + let inner = self.0.inner.lock(); + inner.senders.can_select() || inner.is_disconnected + } + + fn watch(&self, oper: Operation, cx: &Context) -> bool { + let mut inner = self.0.inner.lock(); + inner.receivers.watch(oper, cx); + inner.senders.can_select() || inner.is_disconnected + } + + fn unwatch(&self, oper: Operation) { + let mut inner = self.0.inner.lock(); + inner.receivers.unwatch(oper); + } +} + +impl<'a, T> SelectHandle for Sender<'a, T> { + fn try_select(&self, token: &mut Token) -> bool { + self.0.start_send(token) + } + + fn deadline(&self) -> Option { + None + } + + fn register(&self, oper: Operation, cx: &Context) -> bool { + let packet = Box::into_raw(Packet::::empty_on_heap()); + + let mut inner = self.0.inner.lock(); + inner + .senders + .register_with_packet(oper, packet as usize, cx); + inner.receivers.notify(); + inner.receivers.can_select() || inner.is_disconnected + } + + fn unregister(&self, oper: Operation) { + if let Some(operation) = self.0.inner.lock().senders.unregister(oper) { + unsafe { + drop(Box::from_raw(operation.packet as *mut Packet)); + } + } + } + + fn accept(&self, token: &mut Token, cx: &Context) -> bool { + token.zero = cx.wait_packet(); + true + } + + fn is_ready(&self) -> bool { + let inner = self.0.inner.lock(); + inner.receivers.can_select() || inner.is_disconnected + } + + fn watch(&self, oper: Operation, cx: &Context) -> bool { + let mut inner = self.0.inner.lock(); + inner.senders.watch(oper, cx); + inner.receivers.can_select() || inner.is_disconnected + } + + fn unwatch(&self, oper: Operation) { + let mut inner = self.0.inner.lock(); + inner.senders.unwatch(oper); + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/lib.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/lib.rs new file mode 100644 index 0000000..1d51600 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/lib.rs @@ -0,0 +1,378 @@ +//! Multi-producer multi-consumer channels for message passing. +//! +//! This crate is an alternative to [`std::sync::mpsc`] with more features and better performance. +//! +//! # Hello, world! +//! +//! ``` +//! use crossbeam_channel::unbounded; +//! +//! // Create a channel of unbounded capacity. +//! let (s, r) = unbounded(); +//! +//! // Send a message into the channel. +//! s.send("Hello, world!").unwrap(); +//! +//! // Receive the message from the channel. +//! assert_eq!(r.recv(), Ok("Hello, world!")); +//! ``` +//! +//! # Channel types +//! +//! Channels can be created using two functions: +//! +//! * [`bounded`] creates a channel of bounded capacity, i.e. there is a limit to how many messages +//! it can hold at a time. +//! +//! * [`unbounded`] creates a channel of unbounded capacity, i.e. it can hold any number of +//! messages at a time. +//! +//! Both functions return a [`Sender`] and a [`Receiver`], which represent the two opposite sides +//! of a channel. +//! +//! Creating a bounded channel: +//! +//! ``` +//! use crossbeam_channel::bounded; +//! +//! // Create a channel that can hold at most 5 messages at a time. +//! let (s, r) = bounded(5); +//! +//! // Can send only 5 messages without blocking. +//! for i in 0..5 { +//! s.send(i).unwrap(); +//! } +//! +//! // Another call to `send` would block because the channel is full. +//! // s.send(5).unwrap(); +//! ``` +//! +//! Creating an unbounded channel: +//! +//! ``` +//! use crossbeam_channel::unbounded; +//! +//! // Create an unbounded channel. +//! let (s, r) = unbounded(); +//! +//! // Can send any number of messages into the channel without blocking. +//! for i in 0..1000 { +//! s.send(i).unwrap(); +//! } +//! ``` +//! +//! A special case is zero-capacity channel, which cannot hold any messages. Instead, send and +//! receive operations must appear at the same time in order to pair up and pass the message over: +//! +//! ``` +//! use std::thread; +//! use crossbeam_channel::bounded; +//! +//! // Create a zero-capacity channel. +//! let (s, r) = bounded(0); +//! +//! // Sending blocks until a receive operation appears on the other side. +//! thread::spawn(move || s.send("Hi!").unwrap()); +//! +//! // Receiving blocks until a send operation appears on the other side. +//! assert_eq!(r.recv(), Ok("Hi!")); +//! ``` +//! +//! # Sharing channels +//! +//! Senders and receivers can be cloned and sent to other threads: +//! +//! ``` +//! use std::thread; +//! use crossbeam_channel::bounded; +//! +//! let (s1, r1) = bounded(0); +//! let (s2, r2) = (s1.clone(), r1.clone()); +//! +//! // Spawn a thread that receives a message and then sends one. +//! thread::spawn(move || { +//! r2.recv().unwrap(); +//! s2.send(2).unwrap(); +//! }); +//! +//! // Send a message and then receive one. +//! s1.send(1).unwrap(); +//! r1.recv().unwrap(); +//! ``` +//! +//! Note that cloning only creates a new handle to the same sending or receiving side. It does not +//! create a separate stream of messages in any way: +//! +//! ``` +//! use crossbeam_channel::unbounded; +//! +//! let (s1, r1) = unbounded(); +//! let (s2, r2) = (s1.clone(), r1.clone()); +//! let (s3, r3) = (s2.clone(), r2.clone()); +//! +//! s1.send(10).unwrap(); +//! s2.send(20).unwrap(); +//! s3.send(30).unwrap(); +//! +//! assert_eq!(r3.recv(), Ok(10)); +//! assert_eq!(r1.recv(), Ok(20)); +//! assert_eq!(r2.recv(), Ok(30)); +//! ``` +//! +//! It's also possible to share senders and receivers by reference: +//! +//! ``` +//! # extern crate crossbeam_channel; +//! # extern crate crossbeam_utils; +//! # fn main() { +//! use std::thread; +//! use crossbeam_channel::bounded; +//! use crossbeam_utils::thread::scope; +//! +//! let (s, r) = bounded(0); +//! +//! scope(|scope| { +//! // Spawn a thread that receives a message and then sends one. +//! scope.spawn(|_| { +//! r.recv().unwrap(); +//! s.send(2).unwrap(); +//! }); +//! +//! // Send a message and then receive one. +//! s.send(1).unwrap(); +//! r.recv().unwrap(); +//! }).unwrap(); +//! # } +//! ``` +//! +//! # Disconnection +//! +//! When all senders or all receivers associated with a channel get dropped, the channel becomes +//! disconnected. No more messages can be sent, but any remaining messages can still be received. +//! Send and receive operations on a disconnected channel never block. +//! +//! ``` +//! use crossbeam_channel::{unbounded, RecvError}; +//! +//! let (s, r) = unbounded(); +//! s.send(1).unwrap(); +//! s.send(2).unwrap(); +//! s.send(3).unwrap(); +//! +//! // The only sender is dropped, disconnecting the channel. +//! drop(s); +//! +//! // The remaining messages can be received. +//! assert_eq!(r.recv(), Ok(1)); +//! assert_eq!(r.recv(), Ok(2)); +//! assert_eq!(r.recv(), Ok(3)); +//! +//! // There are no more messages in the channel. +//! assert!(r.is_empty()); +//! +//! // Note that calling `r.recv()` does not block. +//! // Instead, `Err(RecvError)` is returned immediately. +//! assert_eq!(r.recv(), Err(RecvError)); +//! ``` +//! +//! # Blocking operations +//! +//! Send and receive operations come in three flavors: +//! +//! * Non-blocking (returns immediately with success or failure). +//! * Blocking (waits until the operation succeeds or the channel becomes disconnected). +//! * Blocking with a timeout (blocks only for a certain duration of time). +//! +//! A simple example showing the difference between non-blocking and blocking operations: +//! +//! ``` +//! use crossbeam_channel::{bounded, RecvError, TryRecvError}; +//! +//! let (s, r) = bounded(1); +//! +//! // Send a message into the channel. +//! s.send("foo").unwrap(); +//! +//! // This call would block because the channel is full. +//! // s.send("bar").unwrap(); +//! +//! // Receive the message. +//! assert_eq!(r.recv(), Ok("foo")); +//! +//! // This call would block because the channel is empty. +//! // r.recv(); +//! +//! // Try receiving a message without blocking. +//! assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +//! +//! // Disconnect the channel. +//! drop(s); +//! +//! // This call doesn't block because the channel is now disconnected. +//! assert_eq!(r.recv(), Err(RecvError)); +//! ``` +//! +//! # Iteration +//! +//! Receivers can be used as iterators. For example, method [`iter`] creates an iterator that +//! receives messages until the channel becomes empty and disconnected. Note that iteration may +//! block waiting for next message to arrive. +//! +//! ``` +//! use std::thread; +//! use crossbeam_channel::unbounded; +//! +//! let (s, r) = unbounded(); +//! +//! thread::spawn(move || { +//! s.send(1).unwrap(); +//! s.send(2).unwrap(); +//! s.send(3).unwrap(); +//! drop(s); // Disconnect the channel. +//! }); +//! +//! // Collect all messages from the channel. +//! // Note that the call to `collect` blocks until the sender is dropped. +//! let v: Vec<_> = r.iter().collect(); +//! +//! assert_eq!(v, [1, 2, 3]); +//! ``` +//! +//! A non-blocking iterator can be created using [`try_iter`], which receives all available +//! messages without blocking: +//! +//! ``` +//! use crossbeam_channel::unbounded; +//! +//! let (s, r) = unbounded(); +//! s.send(1).unwrap(); +//! s.send(2).unwrap(); +//! s.send(3).unwrap(); +//! // No need to drop the sender. +//! +//! // Receive all messages currently in the channel. +//! let v: Vec<_> = r.try_iter().collect(); +//! +//! assert_eq!(v, [1, 2, 3]); +//! ``` +//! +//! # Selection +//! +//! The [`select!`] macro allows you to define a set of channel operations, wait until any one of +//! them becomes ready, and finally execute it. If multiple operations are ready at the same time, +//! a random one among them is selected. +//! +//! It is also possible to define a `default` case that gets executed if none of the operations are +//! ready, either right away or for a certain duration of time. +//! +//! An operation is considered to be ready if it doesn't have to block. Note that it is ready even +//! when it will simply return an error because the channel is disconnected. +//! +//! An example of receiving a message from two channels: +//! +//! ``` +//! # #[macro_use] +//! # extern crate crossbeam_channel; +//! # fn main() { +//! use std::thread; +//! use std::time::Duration; +//! use crossbeam_channel::unbounded; +//! +//! let (s1, r1) = unbounded(); +//! let (s2, r2) = unbounded(); +//! +//! thread::spawn(move || s1.send(10).unwrap()); +//! thread::spawn(move || s2.send(20).unwrap()); +//! +//! // At most one of these two receive operations will be executed. +//! select! { +//! recv(r1) -> msg => assert_eq!(msg, Ok(10)), +//! recv(r2) -> msg => assert_eq!(msg, Ok(20)), +//! default(Duration::from_secs(1)) => println!("timed out"), +//! } +//! # } +//! ``` +//! +//! If you need to select over a dynamically created list of channel operations, use [`Select`] +//! instead. The [`select!`] macro is just a convenience wrapper around [`Select`]. +//! +//! # Extra channels +//! +//! Three functions can create special kinds of channels, all of which return just a [`Receiver`] +//! handle: +//! +//! * [`after`] creates a channel that delivers a single message after a certain duration of time. +//! * [`tick`] creates a channel that delivers messages periodically. +//! * [`never`] creates a channel that never delivers messages. +//! +//! These channels are very efficient because messages get lazily generated on receive operations. +//! +//! An example that prints elapsed time every 50 milliseconds for the duration of 1 second: +//! +//! ``` +//! # #[macro_use] +//! # extern crate crossbeam_channel; +//! # fn main() { +//! use std::time::{Duration, Instant}; +//! use crossbeam_channel::{after, tick}; +//! +//! let start = Instant::now(); +//! let ticker = tick(Duration::from_millis(50)); +//! let timeout = after(Duration::from_secs(1)); +//! +//! loop { +//! select! { +//! recv(ticker) -> _ => println!("elapsed: {:?}", start.elapsed()), +//! recv(timeout) -> _ => break, +//! } +//! } +//! # } +//! ``` +//! +//! [`std::sync::mpsc`]: https://doc.rust-lang.org/std/sync/mpsc/index.html +//! [`unbounded`]: fn.unbounded.html +//! [`bounded`]: fn.bounded.html +//! [`after`]: fn.after.html +//! [`tick`]: fn.tick.html +//! [`never`]: fn.never.html +//! [`send`]: struct.Sender.html#method.send +//! [`recv`]: struct.Receiver.html#method.recv +//! [`iter`]: struct.Receiver.html#method.iter +//! [`try_iter`]: struct.Receiver.html#method.try_iter +//! [`select!`]: macro.select.html +//! [`Select`]: struct.Select.html +//! [`Sender`]: struct.Sender.html +//! [`Receiver`]: struct.Receiver.html + +#![warn(missing_docs)] +#![warn(missing_debug_implementations)] + +extern crate crossbeam_utils; + +mod channel; +mod context; +mod counter; +mod err; +mod flavors; +mod select; +mod select_macro; +mod utils; +mod waker; + +/// Crate internals used by the `select!` macro. +#[doc(hidden)] +pub mod internal { + pub use select::SelectHandle; + pub use select::{select, select_timeout, try_select}; +} + +pub use channel::{after, never, tick}; +pub use channel::{bounded, unbounded}; +pub use channel::{IntoIter, Iter, TryIter}; +pub use channel::{Receiver, Sender}; + +pub use select::{Select, SelectedOperation}; + +pub use err::{ReadyTimeoutError, SelectTimeoutError, TryReadyError, TrySelectError}; +pub use err::{RecvError, RecvTimeoutError, TryRecvError}; +pub use err::{SendError, SendTimeoutError, TrySendError}; diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/select.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/select.rs new file mode 100644 index 0000000..a586c6b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/select.rs @@ -0,0 +1,1160 @@ +//! Interface to the select mechanism. + +use std::fmt; +use std::marker::PhantomData; +use std::mem; +use std::time::{Duration, Instant}; + +use crossbeam_utils::Backoff; + +use channel::{self, Receiver, Sender}; +use context::Context; +use err::{ReadyTimeoutError, TryReadyError}; +use err::{RecvError, SendError}; +use err::{SelectTimeoutError, TrySelectError}; +use flavors; +use utils; + +/// Temporary data that gets initialized during select or a blocking operation, and is consumed by +/// `read` or `write`. +/// +/// Each field contains data associated with a specific channel flavor. +#[derive(Debug, Default)] +pub struct Token { + pub after: flavors::after::AfterToken, + pub array: flavors::array::ArrayToken, + pub list: flavors::list::ListToken, + pub never: flavors::never::NeverToken, + pub tick: flavors::tick::TickToken, + pub zero: flavors::zero::ZeroToken, +} + +/// Identifier associated with an operation by a specific thread on a specific channel. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Operation(usize); + +impl Operation { + /// Creates an operation identifier from a mutable reference. + /// + /// This function essentially just turns the address of the reference into a number. The + /// reference should point to a variable that is specific to the thread and the operation, + /// and is alive for the entire duration of select or blocking operation. + #[inline] + pub fn hook(r: &mut T) -> Operation { + let val = r as *mut T as usize; + // Make sure that the pointer address doesn't equal the numerical representation of + // `Selected::{Waiting, Aborted, Disconnected}`. + assert!(val > 2); + Operation(val) + } +} + +/// Current state of a select or a blocking operation. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Selected { + /// Still waiting for an operation. + Waiting, + + /// The attempt to block the current thread has been aborted. + Aborted, + + /// An operation became ready because a channel is disconnected. + Disconnected, + + /// An operation became ready because a message can be sent or received. + Operation(Operation), +} + +impl From for Selected { + #[inline] + fn from(val: usize) -> Selected { + match val { + 0 => Selected::Waiting, + 1 => Selected::Aborted, + 2 => Selected::Disconnected, + oper => Selected::Operation(Operation(oper)), + } + } +} + +impl Into for Selected { + #[inline] + fn into(self) -> usize { + match self { + Selected::Waiting => 0, + Selected::Aborted => 1, + Selected::Disconnected => 2, + Selected::Operation(Operation(val)) => val, + } + } +} + +/// A receiver or a sender that can participate in select. +/// +/// This is a handle that assists select in executing an operation, registration, deciding on the +/// appropriate deadline for blocking, etc. +pub trait SelectHandle { + /// Attempts to select an operation and returns `true` on success. + fn try_select(&self, token: &mut Token) -> bool; + + /// Returns a deadline for an operation, if there is one. + fn deadline(&self) -> Option; + + /// Registers an operation for execution and returns `true` if it is now ready. + fn register(&self, oper: Operation, cx: &Context) -> bool; + + /// Unregisters an operation for execution. + fn unregister(&self, oper: Operation); + + /// Attempts to select an operation the thread got woken up for and returns `true` on success. + fn accept(&self, token: &mut Token, cx: &Context) -> bool; + + /// Returns `true` if an operation can be executed without blocking. + fn is_ready(&self) -> bool; + + /// Registers an operation for readiness notification and returns `true` if it is now ready. + fn watch(&self, oper: Operation, cx: &Context) -> bool; + + /// Unregisters an operation for readiness notification. + fn unwatch(&self, oper: Operation); +} + +impl<'a, T: SelectHandle> SelectHandle for &'a T { + fn try_select(&self, token: &mut Token) -> bool { + (**self).try_select(token) + } + + fn deadline(&self) -> Option { + (**self).deadline() + } + + fn register(&self, oper: Operation, cx: &Context) -> bool { + (**self).register(oper, cx) + } + + fn unregister(&self, oper: Operation) { + (**self).unregister(oper); + } + + fn accept(&self, token: &mut Token, cx: &Context) -> bool { + (**self).accept(token, cx) + } + + fn is_ready(&self) -> bool { + (**self).is_ready() + } + + fn watch(&self, oper: Operation, cx: &Context) -> bool { + (**self).watch(oper, cx) + } + + fn unwatch(&self, oper: Operation) { + (**self).unwatch(oper) + } +} + +/// Determines when a select operation should time out. +#[derive(Clone, Copy, Eq, PartialEq)] +enum Timeout { + /// No blocking. + Now, + + /// Block forever. + Never, + + /// Time out after the time instant. + At(Instant), +} + +/// Runs until one of the operations is selected, potentially blocking the current thread. +/// +/// Successful receive operations will have to be followed up by `channel::read()` and successful +/// send operations by `channel::write()`. +fn run_select( + handles: &mut [(&SelectHandle, usize, *const u8)], + timeout: Timeout, +) -> Option<(Token, usize, *const u8)> { + if handles.is_empty() { + // Wait until the timeout and return. + match timeout { + Timeout::Now => return None, + Timeout::Never => { + utils::sleep_until(None); + unreachable!(); + } + Timeout::At(when) => { + utils::sleep_until(Some(when)); + return None; + } + } + } + + // Shuffle the operations for fairness. + utils::shuffle(handles); + + // Create a token, which serves as a temporary variable that gets initialized in this function + // and is later used by a call to `channel::read()` or `channel::write()` that completes the + // selected operation. + let mut token = Token::default(); + + // Try selecting one of the operations without blocking. + for &(handle, i, ptr) in handles.iter() { + if handle.try_select(&mut token) { + return Some((token, i, ptr)); + } + } + + loop { + // Prepare for blocking. + let res = Context::with(|cx| { + let mut sel = Selected::Waiting; + let mut registered_count = 0; + let mut index_ready = None; + + if let Timeout::Now = timeout { + cx.try_select(Selected::Aborted).unwrap(); + } + + // Register all operations. + for (handle, i, _) in handles.iter_mut() { + registered_count += 1; + + // If registration returns `false`, that means the operation has just become ready. + if handle.register(Operation::hook::<&SelectHandle>(handle), cx) { + // Try aborting select. + sel = match cx.try_select(Selected::Aborted) { + Ok(()) => { + index_ready = Some(*i); + Selected::Aborted + } + Err(s) => s, + }; + break; + } + + // If another thread has already selected one of the operations, stop registration. + sel = cx.selected(); + if sel != Selected::Waiting { + break; + } + } + + if sel == Selected::Waiting { + // Check with each operation for how long we're allowed to block, and compute the + // earliest deadline. + let mut deadline: Option = match timeout { + Timeout::Now => return None, + Timeout::Never => None, + Timeout::At(when) => Some(when), + }; + for &(handle, _, _) in handles.iter() { + if let Some(x) = handle.deadline() { + deadline = deadline.map(|y| x.min(y)).or(Some(x)); + } + } + + // Block the current thread. + sel = cx.wait_until(deadline); + } + + // Unregister all registered operations. + for (handle, _, _) in handles.iter_mut().take(registered_count) { + handle.unregister(Operation::hook::<&SelectHandle>(handle)); + } + + match sel { + Selected::Waiting => unreachable!(), + Selected::Aborted => { + // If an operation became ready during registration, try selecting it. + if let Some(index_ready) = index_ready { + for &(handle, i, ptr) in handles.iter() { + if i == index_ready && handle.try_select(&mut token) { + return Some((i, ptr)); + } + } + } + } + Selected::Disconnected => {} + Selected::Operation(_) => { + // Find the selected operation. + for (handle, i, ptr) in handles.iter_mut() { + // Is this the selected operation? + if sel == Selected::Operation(Operation::hook::<&SelectHandle>(handle)) { + // Try selecting this operation. + if handle.accept(&mut token, cx) { + return Some((*i, *ptr)); + } + } + } + } + } + + None + }); + + // Return if an operation was selected. + if let Some((i, ptr)) = res { + return Some((token, i, ptr)); + } + + // Try selecting one of the operations without blocking. + for &(handle, i, ptr) in handles.iter() { + if handle.try_select(&mut token) { + return Some((token, i, ptr)); + } + } + + match timeout { + Timeout::Now => return None, + Timeout::Never => {} + Timeout::At(when) => { + if Instant::now() >= when { + return None; + } + } + } + } +} + +/// Runs until one of the operations becomes ready, potentially blocking the current thread. +fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout) -> Option { + if handles.is_empty() { + // Wait until the timeout and return. + match timeout { + Timeout::Now => return None, + Timeout::Never => { + utils::sleep_until(None); + unreachable!(); + } + Timeout::At(when) => { + utils::sleep_until(Some(when)); + return None; + } + } + } + + // Shuffle the operations for fairness. + utils::shuffle(handles); + + loop { + let backoff = Backoff::new(); + loop { + // Check operations for readiness. + for &(handle, i, _) in handles.iter() { + if handle.is_ready() { + return Some(i); + } + } + + if backoff.is_completed() { + break; + } else { + backoff.snooze(); + } + } + + // Check for timeout. + match timeout { + Timeout::Now => return None, + Timeout::Never => {} + Timeout::At(when) => { + if Instant::now() >= when { + return None; + } + } + } + + // Prepare for blocking. + let res = Context::with(|cx| { + let mut sel = Selected::Waiting; + let mut registered_count = 0; + + // Begin watching all operations. + for (handle, _, _) in handles.iter_mut() { + registered_count += 1; + let oper = Operation::hook::<&SelectHandle>(handle); + + // If registration returns `false`, that means the operation has just become ready. + if handle.watch(oper, cx) { + sel = match cx.try_select(Selected::Operation(oper)) { + Ok(()) => Selected::Operation(oper), + Err(s) => s, + }; + break; + } + + // If another thread has already chosen one of the operations, stop registration. + sel = cx.selected(); + if sel != Selected::Waiting { + break; + } + } + + if sel == Selected::Waiting { + // Check with each operation for how long we're allowed to block, and compute the + // earliest deadline. + let mut deadline: Option = match timeout { + Timeout::Now => unreachable!(), + Timeout::Never => None, + Timeout::At(when) => Some(when), + }; + for &(handle, _, _) in handles.iter() { + if let Some(x) = handle.deadline() { + deadline = deadline.map(|y| x.min(y)).or(Some(x)); + } + } + + // Block the current thread. + sel = cx.wait_until(deadline); + } + + // Unwatch all operations. + for (handle, _, _) in handles.iter_mut().take(registered_count) { + handle.unwatch(Operation::hook::<&SelectHandle>(handle)); + } + + match sel { + Selected::Waiting => unreachable!(), + Selected::Aborted => {} + Selected::Disconnected => {} + Selected::Operation(_) => { + for (handle, i, _) in handles.iter_mut() { + let oper = Operation::hook::<&SelectHandle>(handle); + if sel == Selected::Operation(oper) { + return Some(*i); + } + } + } + } + + None + }); + + // Return if an operation became ready. + if res.is_some() { + return res; + } + } +} + +/// Attempts to select one of the operations without blocking. +#[inline] +pub fn try_select<'a>( + handles: &mut [(&'a SelectHandle, usize, *const u8)], +) -> Result, TrySelectError> { + match run_select(handles, Timeout::Now) { + None => Err(TrySelectError), + Some((token, index, ptr)) => Ok(SelectedOperation { + token, + index, + ptr, + _marker: PhantomData, + }), + } +} + +/// Blocks until one of the operations becomes ready and selects it. +#[inline] +pub fn select<'a>(handles: &mut [(&'a SelectHandle, usize, *const u8)]) -> SelectedOperation<'a> { + if handles.is_empty() { + panic!("no operations have been added to `Select`"); + } + + let (token, index, ptr) = run_select(handles, Timeout::Never).unwrap(); + SelectedOperation { + token, + index, + ptr, + _marker: PhantomData, + } +} + +/// Blocks for a limited time until one of the operations becomes ready and selects it. +#[inline] +pub fn select_timeout<'a>( + handles: &mut [(&'a SelectHandle, usize, *const u8)], + timeout: Duration, +) -> Result, SelectTimeoutError> { + let timeout = Timeout::At(Instant::now() + timeout); + + match run_select(handles, timeout) { + None => Err(SelectTimeoutError), + Some((token, index, ptr)) => Ok(SelectedOperation { + token, + index, + ptr, + _marker: PhantomData, + }), + } +} + +/// Selects from a set of channel operations. +/// +/// `Select` allows you to define a set of channel operations, wait until any one of them becomes +/// ready, and finally execute it. If multiple operations are ready at the same time, a random one +/// among them is selected. +/// +/// An operation is considered to be ready if it doesn't have to block. Note that it is ready even +/// when it will simply return an error because the channel is disconnected. +/// +/// The [`select!`] macro is a convenience wrapper around `Select`. However, it cannot select over a +/// dynamically created list of channel operations. +/// +/// Once a list of operations has been built with `Select`, there are two different ways of +/// proceeding: +/// +/// * Select an operation with [`try_select`], [`select`], or [`select_timeout`]. If successful, +/// the returned selected operation has already begun and **must** be completed. If we don't +/// complete it, a panic will occur. +/// +/// * Wait for an operation to become ready with [`try_ready`], [`ready`], or [`ready_timeout`]. If +/// successful, we may attempt to execute the operation, but are not obliged to. In fact, it's +/// possible for another thread to make the operation not ready just before we try executing it, +/// so it's wise to use a retry loop. However, note that these methods might return with success +/// spuriously, so it's a good idea to always double check if the operation is really ready. +/// +/// # Examples +/// +/// Use [`select`] to receive a message from a list of receivers: +/// +/// ``` +/// use crossbeam_channel::{Receiver, RecvError, Select}; +/// +/// fn recv_multiple(rs: &[Receiver]) -> Result { +/// // Build a list of operations. +/// let mut sel = Select::new(); +/// for r in rs { +/// sel.recv(r); +/// } +/// +/// // Complete the selected operation. +/// let oper = sel.select(); +/// let index = oper.index(); +/// oper.recv(&rs[index]) +/// } +/// ``` +/// +/// Use [`ready`] to receive a message from a list of receivers: +/// +/// ``` +/// use crossbeam_channel::{Receiver, RecvError, Select}; +/// +/// fn recv_multiple(rs: &[Receiver]) -> Result { +/// // Build a list of operations. +/// let mut sel = Select::new(); +/// for r in rs { +/// sel.recv(r); +/// } +/// +/// loop { +/// // Wait until a receive operation becomes ready and try executing it. +/// let index = sel.ready(); +/// let res = rs[index].try_recv(); +/// +/// // If the operation turns out not to be ready, retry. +/// if let Err(e) = res { +/// if e.is_empty() { +/// continue; +/// } +/// } +/// +/// // Success! +/// return res.map_err(|_| RecvError); +/// } +/// } +/// ``` +/// +/// [`select!`]: macro.select.html +/// [`try_select`]: struct.Select.html#method.try_select +/// [`select`]: struct.Select.html#method.select +/// [`select_timeout`]: struct.Select.html#method.select_timeout +/// [`try_ready`]: struct.Select.html#method.try_ready +/// [`ready`]: struct.Select.html#method.ready +/// [`ready_timeout`]: struct.Select.html#method.ready_timeout +pub struct Select<'a> { + /// A list of senders and receivers participating in selection. + handles: Vec<(&'a SelectHandle, usize, *const u8)>, + + /// The next index to assign to an operation. + next_index: usize, +} + +unsafe impl<'a> Send for Select<'a> {} +unsafe impl<'a> Sync for Select<'a> {} + +impl<'a> Select<'a> { + /// Creates an empty list of channel operations for selection. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::Select; + /// + /// let mut sel = Select::new(); + /// + /// // The list of operations is empty, which means no operation can be selected. + /// assert!(sel.try_select().is_err()); + /// ``` + pub fn new() -> Select<'a> { + Select { + handles: Vec::with_capacity(4), + next_index: 0, + } + } + + /// Adds a send operation. + /// + /// Returns the index of the added operation. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use crossbeam_channel::{unbounded, Select}; + /// + /// let (s, r) = unbounded::(); + /// + /// let mut sel = Select::new(); + /// let index = sel.send(&s); + /// ``` + pub fn send(&mut self, s: &'a Sender) -> usize { + let i = self.next_index; + let ptr = s as *const Sender<_> as *const u8; + self.handles.push((s, i, ptr)); + self.next_index += 1; + i + } + + /// Adds a receive operation. + /// + /// Returns the index of the added operation. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use crossbeam_channel::{unbounded, Select}; + /// + /// let (s, r) = unbounded::(); + /// + /// let mut sel = Select::new(); + /// let index = sel.recv(&r); + /// ``` + pub fn recv(&mut self, r: &'a Receiver) -> usize { + let i = self.next_index; + let ptr = r as *const Receiver<_> as *const u8; + self.handles.push((r, i, ptr)); + self.next_index += 1; + i + } + + /// Removes a previously added operation. + /// + /// This is useful when an operation is selected because the channel got disconnected and we + /// want to try again to select a different operation instead. + /// + /// If new operations are added after removing some, the indices of removed operations will not + /// be reused. + /// + /// # Panics + /// + /// An attempt to remove a non-existing or already removed operation will panic. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use crossbeam_channel::{unbounded, Select}; + /// + /// let (s1, r1) = unbounded::(); + /// let (_, r2) = unbounded::(); + /// + /// let mut sel = Select::new(); + /// let oper1 = sel.recv(&r1); + /// let oper2 = sel.recv(&r2); + /// + /// // Both operations are initially ready, so a random one will be executed. + /// let oper = sel.select(); + /// assert_eq!(oper.index(), oper2); + /// assert!(oper.recv(&r2).is_err()); + /// sel.remove(oper2); + /// + /// s1.send(10).unwrap(); + /// + /// let oper = sel.select(); + /// assert_eq!(oper.index(), oper1); + /// assert_eq!(oper.recv(&r1), Ok(10)); + /// ``` + pub fn remove(&mut self, index: usize) { + assert!( + index < self.next_index, + "index out of bounds; {} >= {}", + index, + self.next_index, + ); + + let i = self + .handles + .iter() + .enumerate() + .find(|(_, (_, i, _))| *i == index) + .expect("no operation with this index") + .0; + + self.handles.swap_remove(i); + } + + /// Attempts to select one of the operations without blocking. + /// + /// If an operation is ready, it is selected and returned. If multiple operations are ready at + /// the same time, a random one among them is selected. If none of the operations are ready, an + /// error is returned. + /// + /// An operation is considered to be ready if it doesn't have to block. Note that it is ready + /// even when it will simply return an error because the channel is disconnected. + /// + /// The selected operation must be completed with [`SelectedOperation::send`] + /// or [`SelectedOperation::recv`]. + /// + /// [`SelectedOperation::send`]: struct.SelectedOperation.html#method.send + /// [`SelectedOperation::recv`]: struct.SelectedOperation.html#method.recv + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use crossbeam_channel::{unbounded, Select}; + /// + /// let (s1, r1) = unbounded(); + /// let (s2, r2) = unbounded(); + /// + /// s1.send(10).unwrap(); + /// s2.send(20).unwrap(); + /// + /// let mut sel = Select::new(); + /// let oper1 = sel.recv(&r1); + /// let oper2 = sel.recv(&r2); + /// + /// // Both operations are initially ready, so a random one will be executed. + /// let oper = sel.try_select(); + /// match oper { + /// Err(_) => panic!("both operations should be ready"), + /// Ok(oper) => match oper.index() { + /// i if i == oper1 => assert_eq!(oper.recv(&r1), Ok(10)), + /// i if i == oper2 => assert_eq!(oper.recv(&r2), Ok(20)), + /// _ => unreachable!(), + /// } + /// } + /// ``` + pub fn try_select(&mut self) -> Result, TrySelectError> { + try_select(&mut self.handles) + } + + /// Blocks until one of the operations becomes ready and selects it. + /// + /// Once an operation becomes ready, it is selected and returned. If multiple operations are + /// ready at the same time, a random one among them is selected. + /// + /// An operation is considered to be ready if it doesn't have to block. Note that it is ready + /// even when it will simply return an error because the channel is disconnected. + /// + /// The selected operation must be completed with [`SelectedOperation::send`] + /// or [`SelectedOperation::recv`]. + /// + /// [`SelectedOperation::send`]: struct.SelectedOperation.html#method.send + /// [`SelectedOperation::recv`]: struct.SelectedOperation.html#method.recv + /// + /// # Panics + /// + /// Panics if no operations have been added to `Select`. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use std::time::Duration; + /// use crossbeam_channel::{unbounded, Select}; + /// + /// let (s1, r1) = unbounded(); + /// let (s2, r2) = unbounded(); + /// + /// thread::spawn(move || { + /// thread::sleep(Duration::from_secs(1)); + /// s1.send(10).unwrap(); + /// }); + /// thread::spawn(move || s2.send(20).unwrap()); + /// + /// let mut sel = Select::new(); + /// let oper1 = sel.recv(&r1); + /// let oper2 = sel.recv(&r2); + /// + /// // The second operation will be selected because it becomes ready first. + /// let oper = sel.select(); + /// match oper.index() { + /// i if i == oper1 => assert_eq!(oper.recv(&r1), Ok(10)), + /// i if i == oper2 => assert_eq!(oper.recv(&r2), Ok(20)), + /// _ => unreachable!(), + /// } + /// ``` + pub fn select(&mut self) -> SelectedOperation<'a> { + select(&mut self.handles) + } + + /// Blocks for a limited time until one of the operations becomes ready and selects it. + /// + /// If an operation becomes ready, it is selected and returned. If multiple operations are + /// ready at the same time, a random one among them is selected. If none of the operations + /// become ready for the specified duration, an error is returned. + /// + /// An operation is considered to be ready if it doesn't have to block. Note that it is ready + /// even when it will simply return an error because the channel is disconnected. + /// + /// The selected operation must be completed with [`SelectedOperation::send`] + /// or [`SelectedOperation::recv`]. + /// + /// [`SelectedOperation::send`]: struct.SelectedOperation.html#method.send + /// [`SelectedOperation::recv`]: struct.SelectedOperation.html#method.recv + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use std::time::Duration; + /// use crossbeam_channel::{unbounded, Select}; + /// + /// let (s1, r1) = unbounded(); + /// let (s2, r2) = unbounded(); + /// + /// thread::spawn(move || { + /// thread::sleep(Duration::from_secs(1)); + /// s1.send(10).unwrap(); + /// }); + /// thread::spawn(move || s2.send(20).unwrap()); + /// + /// let mut sel = Select::new(); + /// let oper1 = sel.recv(&r1); + /// let oper2 = sel.recv(&r2); + /// + /// // The second operation will be selected because it becomes ready first. + /// let oper = sel.select_timeout(Duration::from_millis(500)); + /// match oper { + /// Err(_) => panic!("should not have timed out"), + /// Ok(oper) => match oper.index() { + /// i if i == oper1 => assert_eq!(oper.recv(&r1), Ok(10)), + /// i if i == oper2 => assert_eq!(oper.recv(&r2), Ok(20)), + /// _ => unreachable!(), + /// } + /// } + /// ``` + pub fn select_timeout( + &mut self, + timeout: Duration, + ) -> Result, SelectTimeoutError> { + select_timeout(&mut self.handles, timeout) + } + + /// Attempts to find a ready operation without blocking. + /// + /// If an operation is ready, its index is returned. If multiple operations are ready at the + /// same time, a random one among them is chosen. If none of the operations are ready, an error + /// is returned. + /// + /// An operation is considered to be ready if it doesn't have to block. Note that it is ready + /// even when it will simply return an error because the channel is disconnected. + /// + /// Note that this method might return with success spuriously, so it's a good idea to always + /// double check if the operation is really ready. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use crossbeam_channel::{unbounded, Select}; + /// + /// let (s1, r1) = unbounded(); + /// let (s2, r2) = unbounded(); + /// + /// s1.send(10).unwrap(); + /// s2.send(20).unwrap(); + /// + /// let mut sel = Select::new(); + /// let oper1 = sel.recv(&r1); + /// let oper2 = sel.recv(&r2); + /// + /// // Both operations are initially ready, so a random one will be chosen. + /// match sel.try_ready() { + /// Err(_) => panic!("both operations should be ready"), + /// Ok(i) if i == oper1 => assert_eq!(r1.try_recv(), Ok(10)), + /// Ok(i) if i == oper2 => assert_eq!(r2.try_recv(), Ok(20)), + /// Ok(_) => unreachable!(), + /// } + /// ``` + pub fn try_ready(&mut self) -> Result { + match run_ready(&mut self.handles, Timeout::Now) { + None => Err(TryReadyError), + Some(index) => Ok(index), + } + } + + /// Blocks until one of the operations becomes ready. + /// + /// Once an operation becomes ready, its index is returned. If multiple operations are ready at + /// the same time, a random one among them is chosen. + /// + /// An operation is considered to be ready if it doesn't have to block. Note that it is ready + /// even when it will simply return an error because the channel is disconnected. + /// + /// Note that this method might return with success spuriously, so it's a good idea to always + /// double check if the operation is really ready. + /// + /// # Panics + /// + /// Panics if no operations have been added to `Select`. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use std::time::Duration; + /// use crossbeam_channel::{unbounded, Select}; + /// + /// let (s1, r1) = unbounded(); + /// let (s2, r2) = unbounded(); + /// + /// thread::spawn(move || { + /// thread::sleep(Duration::from_secs(1)); + /// s1.send(10).unwrap(); + /// }); + /// thread::spawn(move || s2.send(20).unwrap()); + /// + /// let mut sel = Select::new(); + /// let oper1 = sel.recv(&r1); + /// let oper2 = sel.recv(&r2); + /// + /// // The second operation will be selected because it becomes ready first. + /// match sel.ready() { + /// i if i == oper1 => assert_eq!(r1.try_recv(), Ok(10)), + /// i if i == oper2 => assert_eq!(r2.try_recv(), Ok(20)), + /// _ => unreachable!(), + /// } + /// ``` + pub fn ready(&mut self) -> usize { + if self.handles.is_empty() { + panic!("no operations have been added to `Select`"); + } + + run_ready(&mut self.handles, Timeout::Never).unwrap() + } + + /// Blocks for a limited time until one of the operations becomes ready. + /// + /// If an operation becomes ready, its index is returned. If multiple operations are ready at + /// the same time, a random one among them is chosen. If none of the operations become ready + /// for the specified duration, an error is returned. + /// + /// An operation is considered to be ready if it doesn't have to block. Note that it is ready + /// even when it will simply return an error because the channel is disconnected. + /// + /// Note that this method might return with success spuriously, so it's a good idea to double + /// check if the operation is really ready. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use std::time::Duration; + /// use crossbeam_channel::{unbounded, Select}; + /// + /// let (s1, r1) = unbounded(); + /// let (s2, r2) = unbounded(); + /// + /// thread::spawn(move || { + /// thread::sleep(Duration::from_secs(1)); + /// s1.send(10).unwrap(); + /// }); + /// thread::spawn(move || s2.send(20).unwrap()); + /// + /// let mut sel = Select::new(); + /// let oper1 = sel.recv(&r1); + /// let oper2 = sel.recv(&r2); + /// + /// // The second operation will be selected because it becomes ready first. + /// match sel.ready_timeout(Duration::from_millis(500)) { + /// Err(_) => panic!("should not have timed out"), + /// Ok(i) if i == oper1 => assert_eq!(r1.try_recv(), Ok(10)), + /// Ok(i) if i == oper2 => assert_eq!(r2.try_recv(), Ok(20)), + /// Ok(_) => unreachable!(), + /// } + /// ``` + pub fn ready_timeout(&mut self, timeout: Duration) -> Result { + let timeout = Timeout::At(Instant::now() + timeout); + + match run_ready(&mut self.handles, timeout) { + None => Err(ReadyTimeoutError), + Some(index) => Ok(index), + } + } +} + +impl<'a> Clone for Select<'a> { + fn clone(&self) -> Select<'a> { + Select { + handles: self.handles.clone(), + next_index: self.next_index, + } + } +} + +impl<'a> Default for Select<'a> { + fn default() -> Select<'a> { + Select::new() + } +} + +impl<'a> fmt::Debug for Select<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Select { .. }") + } +} + +/// A selected operation that needs to be completed. +/// +/// To complete the operation, call [`send`] or [`recv`]. +/// +/// # Panics +/// +/// Forgetting to complete the operation is an error and might lead to deadlocks. If a +/// `SelectedOperation` is dropped without completion, a panic occurs. +/// +/// [`send`]: struct.SelectedOperation.html#method.send +/// [`recv`]: struct.SelectedOperation.html#method.recv +#[must_use] +pub struct SelectedOperation<'a> { + /// Token needed to complete the operation. + token: Token, + + /// The index of the selected operation. + index: usize, + + /// The address of the selected `Sender` or `Receiver`. + ptr: *const u8, + + /// Indicates that `Sender`s and `Receiver`s are borrowed. + _marker: PhantomData<&'a ()>, +} + +impl<'a> SelectedOperation<'a> { + /// Returns the index of the selected operation. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::{bounded, Select}; + /// + /// let (s1, r1) = bounded::<()>(0); + /// let (s2, r2) = bounded::<()>(0); + /// let (s3, r3) = bounded::<()>(1); + /// + /// let mut sel = Select::new(); + /// let oper1 = sel.send(&s1); + /// let oper2 = sel.recv(&r2); + /// let oper3 = sel.send(&s3); + /// + /// // Only the last operation is ready. + /// let oper = sel.select(); + /// assert_eq!(oper.index(), 2); + /// assert_eq!(oper.index(), oper3); + /// + /// // Complete the operation. + /// oper.send(&s3, ()).unwrap(); + /// ``` + pub fn index(&self) -> usize { + self.index + } + + /// Completes the send operation. + /// + /// The passed [`Sender`] reference must be the same one that was used in [`Select::send`] + /// when the operation was added. + /// + /// # Panics + /// + /// Panics if an incorrect [`Sender`] reference is passed. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::{bounded, Select, SendError}; + /// + /// let (s, r) = bounded::(0); + /// drop(r); + /// + /// let mut sel = Select::new(); + /// let oper1 = sel.send(&s); + /// + /// let oper = sel.select(); + /// assert_eq!(oper.index(), oper1); + /// assert_eq!(oper.send(&s, 10), Err(SendError(10))); + /// ``` + /// + /// [`Sender`]: struct.Sender.html + /// [`Select::send`]: struct.Select.html#method.send + pub fn send(mut self, s: &Sender, msg: T) -> Result<(), SendError> { + assert!( + s as *const Sender as *const u8 == self.ptr, + "passed a sender that wasn't selected", + ); + let res = unsafe { channel::write(s, &mut self.token, msg) }; + mem::forget(self); + res.map_err(SendError) + } + + /// Completes the receive operation. + /// + /// The passed [`Receiver`] reference must be the same one that was used in [`Select::recv`] + /// when the operation was added. + /// + /// # Panics + /// + /// Panics if an incorrect [`Receiver`] reference is passed. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_channel::{bounded, Select, RecvError}; + /// + /// let (s, r) = bounded::(0); + /// drop(s); + /// + /// let mut sel = Select::new(); + /// let oper1 = sel.recv(&r); + /// + /// let oper = sel.select(); + /// assert_eq!(oper.index(), oper1); + /// assert_eq!(oper.recv(&r), Err(RecvError)); + /// ``` + /// + /// [`Receiver`]: struct.Receiver.html + /// [`Select::recv`]: struct.Select.html#method.recv + pub fn recv(mut self, r: &Receiver) -> Result { + assert!( + r as *const Receiver as *const u8 == self.ptr, + "passed a receiver that wasn't selected", + ); + let res = unsafe { channel::read(r, &mut self.token) }; + mem::forget(self); + res.map_err(|_| RecvError) + } +} + +impl<'a> fmt::Debug for SelectedOperation<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("SelectedOperation { .. }") + } +} + +impl<'a> Drop for SelectedOperation<'a> { + fn drop(&mut self) { + panic!("dropped `SelectedOperation` without completing the operation"); + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/select_macro.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/select_macro.rs new file mode 100644 index 0000000..8116a5d --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/select_macro.rs @@ -0,0 +1,1214 @@ +//! The `select!` macro. + +/// A simple wrapper around the standard macros. +/// +/// This is just an ugly workaround until it becomes possible to import macros with `use` +/// statements. +/// +/// TODO(stjepang): Once we bump the minimum required Rust version to 1.30 or newer, we should: +/// +/// 1. Remove all `#[macro_export(local_inner_macros)]` lines. +/// 2. Replace `crossbeam_channel_delegate` with direct macro invocations. +#[doc(hidden)] +#[macro_export] +macro_rules! crossbeam_channel_delegate { + (concat($($args:tt)*)) => { + concat!($($args)*) + }; + (stringify($($args:tt)*)) => { + stringify!($($args)*) + }; + (unreachable($($args:tt)*)) => { + unreachable!($($args)*) + }; + (compile_error($($args:tt)*)) => { + compile_error!($($args)*) + }; +} + +/// A helper macro for `select!` to hide the long list of macro patterns from the documentation. +/// +/// The macro consists of two stages: +/// 1. Parsing +/// 2. Code generation +/// +/// The parsing stage consists of these subparts: +/// 1. `@list`: Turns a list of tokens into a list of cases. +/// 2. `@list_errorN`: Diagnoses the syntax error. +/// 3. `@case`: Parses a single case and verifies its argument list. +/// +/// The codegen stage consists of these subparts: +/// 1. `@init`: Attempts to optimize `select!` away and initializes the list of handles. +/// 1. `@count`: Counts the listed cases. +/// 3. `@add`: Adds send/receive operations to the list of handles and starts selection. +/// 4. `@complete`: Completes the selected send/receive operation. +/// +/// If the parsing stage encounters a syntax error or the codegen stage ends up with too many +/// cases to process, the macro fails with a compile-time error. +#[doc(hidden)] +#[macro_export(local_inner_macros)] +macro_rules! crossbeam_channel_internal { + // The list is empty. Now check the arguments of each processed case. + (@list + () + ($($head:tt)*) + ) => { + crossbeam_channel_internal!( + @case + ($($head)*) + () + () + ) + }; + // If necessary, insert an empty argument list after `default`. + (@list + (default => $($tail:tt)*) + ($($head:tt)*) + ) => { + crossbeam_channel_internal!( + @list + (default() => $($tail)*) + ($($head)*) + ) + }; + // But print an error if `default` is followed by a `->`. + (@list + (default -> $($tail:tt)*) + ($($head:tt)*) + ) => { + crossbeam_channel_delegate!(compile_error( + "expected `=>` after `default` case, found `->`" + )) + }; + // Print an error if there's an `->` after the argument list in the default case. + (@list + (default $args:tt -> $($tail:tt)*) + ($($head:tt)*) + ) => { + crossbeam_channel_delegate!(compile_error( + "expected `=>` after `default` case, found `->`" + )) + }; + // Print an error if there is a missing result in a recv case. + (@list + (recv($($args:tt)*) => $($tail:tt)*) + ($($head:tt)*) + ) => { + crossbeam_channel_delegate!(compile_error( + "expected `->` after `recv` case, found `=>`" + )) + }; + // Print an error if there is a missing result in a send case. + (@list + (send($($args:tt)*) => $($tail:tt)*) + ($($head:tt)*) + ) => { + crossbeam_channel_delegate!(compile_error( + "expected `->` after `send` operation, found `=>`" + )) + }; + // Make sure the arrow and the result are not repeated. + (@list + ($case:ident $args:tt -> $res:tt -> $($tail:tt)*) + ($($head:tt)*) + ) => { + crossbeam_channel_delegate!(compile_error("expected `=>`, found `->`")) + }; + // Print an error if there is a semicolon after the block. + (@list + ($case:ident $args:tt $(-> $res:pat)* => $body:block; $($tail:tt)*) + ($($head:tt)*) + ) => { + crossbeam_channel_delegate!(compile_error( + "did you mean to put a comma instead of the semicolon after `}`?" + )) + }; + // The first case is separated by a comma. + (@list + ($case:ident ($($args:tt)*) $(-> $res:pat)* => $body:expr, $($tail:tt)*) + ($($head:tt)*) + ) => { + crossbeam_channel_internal!( + @list + ($($tail)*) + ($($head)* $case ($($args)*) $(-> $res)* => { $body },) + ) + }; + // Don't require a comma after the case if it has a proper block. + (@list + ($case:ident ($($args:tt)*) $(-> $res:pat)* => $body:block $($tail:tt)*) + ($($head:tt)*) + ) => { + crossbeam_channel_internal!( + @list + ($($tail)*) + ($($head)* $case ($($args)*) $(-> $res)* => { $body },) + ) + }; + // Only one case remains. + (@list + ($case:ident ($($args:tt)*) $(-> $res:pat)* => $body:expr) + ($($head:tt)*) + ) => { + crossbeam_channel_internal!( + @list + () + ($($head)* $case ($($args)*) $(-> $res)* => { $body },) + ) + }; + // Accept a trailing comma at the end of the list. + (@list + ($case:ident ($($args:tt)*) $(-> $res:pat)* => $body:expr,) + ($($head:tt)*) + ) => { + crossbeam_channel_internal!( + @list + () + ($($head)* $case ($($args)*) $(-> $res)* => { $body },) + ) + }; + // Diagnose and print an error. + (@list + ($($tail:tt)*) + ($($head:tt)*) + ) => { + crossbeam_channel_internal!(@list_error1 $($tail)*) + }; + // Stage 1: check the case type. + (@list_error1 recv $($tail:tt)*) => { + crossbeam_channel_internal!(@list_error2 recv $($tail)*) + }; + (@list_error1 send $($tail:tt)*) => { + crossbeam_channel_internal!(@list_error2 send $($tail)*) + }; + (@list_error1 default $($tail:tt)*) => { + crossbeam_channel_internal!(@list_error2 default $($tail)*) + }; + (@list_error1 $t:tt $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected one of `recv`, `send`, or `default`, found `", + crossbeam_channel_delegate!(stringify($t)), + "`", + )) + )) + }; + (@list_error1 $($tail:tt)*) => { + crossbeam_channel_internal!(@list_error2 $($tail)*); + }; + // Stage 2: check the argument list. + (@list_error2 $case:ident) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "missing argument list after `", + crossbeam_channel_delegate!(stringify($case)), + "`", + )) + )) + }; + (@list_error2 $case:ident => $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "missing argument list after `", + crossbeam_channel_delegate!(stringify($case)), + "`", + )) + )) + }; + (@list_error2 $($tail:tt)*) => { + crossbeam_channel_internal!(@list_error3 $($tail)*) + }; + // Stage 3: check the `=>` and what comes after it. + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "missing `=>` after `", + crossbeam_channel_delegate!(stringify($case)), + "` case", + )) + )) + }; + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)* =>) => { + crossbeam_channel_delegate!(compile_error( + "expected expression after `=>`" + )) + }; + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)* => $body:expr; $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "did you mean to put a comma instead of the semicolon after `", + crossbeam_channel_delegate!(stringify($body)), + "`?", + )) + )) + }; + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)* => recv($($a:tt)*) $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + "expected an expression after `=>`" + )) + }; + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)* => send($($a:tt)*) $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + "expected an expression after `=>`" + )) + }; + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)* => default($($a:tt)*) $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + "expected an expression after `=>`" + )) + }; + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)* => $f:ident($($a:tt)*) $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "did you mean to put a comma after `", + crossbeam_channel_delegate!(stringify($f)), + "(", + crossbeam_channel_delegate!(stringify($($a)*)), + ")`?", + )) + )) + }; + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)* => $f:ident!($($a:tt)*) $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "did you mean to put a comma after `", + crossbeam_channel_delegate!(stringify($f)), + "!(", + crossbeam_channel_delegate!(stringify($($a)*)), + ")`?", + )) + )) + }; + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)* => $f:ident![$($a:tt)*] $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "did you mean to put a comma after `", + crossbeam_channel_delegate!(stringify($f)), + "![", + crossbeam_channel_delegate!(stringify($($a)*)), + "]`?", + )) + )) + }; + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)* => $f:ident!{$($a:tt)*} $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "did you mean to put a comma after `", + crossbeam_channel_delegate!(stringify($f)), + "!{", + crossbeam_channel_delegate!(stringify($($a)*)), + "}`?", + )) + )) + }; + (@list_error3 $case:ident($($args:tt)*) $(-> $r:pat)* => $body:tt $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "did you mean to put a comma after `", + crossbeam_channel_delegate!(stringify($body)), + "`?", + )) + )) + }; + (@list_error3 $case:ident($($args:tt)*) -> => $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error("missing pattern after `->`")) + }; + (@list_error3 $case:ident($($args:tt)*) $t:tt $(-> $r:pat)* => $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected `->`, found `", + crossbeam_channel_delegate!(stringify($t)), + "`", + )) + )) + }; + (@list_error3 $case:ident($($args:tt)*) -> $t:tt $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected a pattern, found `", + crossbeam_channel_delegate!(stringify($t)), + "`", + )) + )) + }; + (@list_error3 recv($($args:tt)*) $t:tt $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected `->`, found `", + crossbeam_channel_delegate!(stringify($t)), + "`", + )) + )) + }; + (@list_error3 send($($args:tt)*) $t:tt $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected `->`, found `", + crossbeam_channel_delegate!(stringify($t)), + "`", + )) + )) + }; + (@list_error3 recv $args:tt $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected an argument list after `recv`, found `", + crossbeam_channel_delegate!(stringify($args)), + "`", + )) + )) + }; + (@list_error3 send $args:tt $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected an argument list after `send`, found `", + crossbeam_channel_delegate!(stringify($args)), + "`", + )) + )) + }; + (@list_error3 default $args:tt $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected an argument list or `=>` after `default`, found `", + crossbeam_channel_delegate!(stringify($args)), + "`", + )) + )) + }; + (@list_error3 $($tail:tt)*) => { + crossbeam_channel_internal!(@list_error4 $($tail)*) + }; + // Stage 4: fail with a generic error message. + (@list_error4 $($tail:tt)*) => { + crossbeam_channel_delegate!(compile_error("invalid syntax")) + }; + + // Success! All cases were parsed. + (@case + () + $cases:tt + $default:tt + ) => { + crossbeam_channel_internal!( + @init + $cases + $default + ) + }; + + // Check the format of a recv case. + (@case + (recv($r:expr) -> $res:pat => $body:tt, $($tail:tt)*) + ($($cases:tt)*) + $default:tt + ) => { + crossbeam_channel_internal!( + @case + ($($tail)*) + ($($cases)* recv($r) -> $res => $body,) + $default + ) + }; + // Allow trailing comma... + (@case + (recv($r:expr,) -> $res:pat => $body:tt, $($tail:tt)*) + ($($cases:tt)*) + $default:tt + ) => { + crossbeam_channel_internal!( + @case + ($($tail)*) + ($($cases)* recv($r) -> $res => $body,) + $default + ) + }; + // Print an error if the argument list is invalid. + (@case + (recv($($args:tt)*) -> $res:pat => $body:tt, $($tail:tt)*) + ($($cases:tt)*) + $default:tt + ) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "invalid argument list in `recv(", + crossbeam_channel_delegate!(stringify($($args)*)), + ")`", + )) + )) + }; + // Print an error if there is no argument list. + (@case + (recv $t:tt $($tail:tt)*) + ($($cases:tt)*) + $default:tt + ) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected an argument list after `recv`, found `", + crossbeam_channel_delegate!(stringify($t)), + "`", + )) + )) + }; + + // Check the format of a send case. + (@case + (send($s:expr, $m:expr) -> $res:pat => $body:tt, $($tail:tt)*) + ($($cases:tt)*) + $default:tt + ) => { + crossbeam_channel_internal!( + @case + ($($tail)*) + ($($cases)* send($s, $m) -> $res => $body,) + $default + ) + }; + // Allow trailing comma... + (@case + (send($s:expr, $m:expr,) -> $res:pat => $body:tt, $($tail:tt)*) + ($($cases:tt)*) + $default:tt + ) => { + crossbeam_channel_internal!( + @case + ($($tail)*) + ($($cases)* send($s, $m) -> $res => $body,) + $default + ) + }; + // Print an error if the argument list is invalid. + (@case + (send($($args:tt)*) -> $res:pat => $body:tt, $($tail:tt)*) + ($($cases:tt)*) + $default:tt + ) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "invalid argument list in `send(", + crossbeam_channel_delegate!(stringify($($args)*)), + ")`", + )) + )) + }; + // Print an error if there is no argument list. + (@case + (send $t:tt $($tail:tt)*) + ($($cases:tt)*) + $default:tt + ) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected an argument list after `send`, found `", + crossbeam_channel_delegate!(stringify($t)), + "`", + )) + )) + }; + + // Check the format of a default case. + (@case + (default() => $body:tt, $($tail:tt)*) + $cases:tt + () + ) => { + crossbeam_channel_internal!( + @case + ($($tail)*) + $cases + (default() => $body,) + ) + }; + // Check the format of a default case with timeout. + (@case + (default($timeout:expr) => $body:tt, $($tail:tt)*) + $cases:tt + () + ) => { + crossbeam_channel_internal!( + @case + ($($tail)*) + $cases + (default($timeout) => $body,) + ) + }; + // Allow trailing comma... + (@case + (default($timeout:expr,) => $body:tt, $($tail:tt)*) + $cases:tt + () + ) => { + crossbeam_channel_internal!( + @case + ($($tail)*) + $cases + (default($timeout) => $body,) + ) + }; + // Check for duplicate default cases... + (@case + (default $($tail:tt)*) + $cases:tt + ($($def:tt)+) + ) => { + crossbeam_channel_delegate!(compile_error( + "there can be only one `default` case in a `select!` block" + )) + }; + // Print an error if the argument list is invalid. + (@case + (default($($args:tt)*) => $body:tt, $($tail:tt)*) + $cases:tt + $default:tt + ) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "invalid argument list in `default(", + crossbeam_channel_delegate!(stringify($($args)*)), + ")`", + )) + )) + }; + // Print an error if there is an unexpected token after `default`. + (@case + (default $t:tt $($tail:tt)*) + $cases:tt + $default:tt + ) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected an argument list or `=>` after `default`, found `", + crossbeam_channel_delegate!(stringify($t)), + "`", + )) + )) + }; + + // The case was not consumed, therefore it must be invalid. + (@case + ($case:ident $($tail:tt)*) + $cases:tt + $default:tt + ) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "expected one of `recv`, `send`, or `default`, found `", + crossbeam_channel_delegate!(stringify($case)), + "`", + )) + )) + }; + + // Optimize `select!` into `try_recv()`. + (@init + (recv($r:expr) -> $res:pat => $recv_body:tt,) + (default() => $default_body:tt,) + ) => {{ + match $r { + ref _r => { + let _r: &$crate::Receiver<_> = _r; + match _r.try_recv() { + ::std::result::Result::Err($crate::TryRecvError::Empty) => { + $default_body + } + _res => { + let _res = _res.map_err(|_| $crate::RecvError); + let $res = _res; + $recv_body + } + } + } + } + }}; + // Optimize `select!` into `recv()`. + (@init + (recv($r:expr) -> $res:pat => $body:tt,) + () + ) => {{ + match $r { + ref _r => { + let _r: &$crate::Receiver<_> = _r; + let _res = _r.recv(); + let $res = _res; + $body + } + } + }}; + // Optimize `select!` into `recv_timeout()`. + (@init + (recv($r:expr) -> $res:pat => $recv_body:tt,) + (default($timeout:expr) => $default_body:tt,) + ) => {{ + match $r { + ref _r => { + let _r: &$crate::Receiver<_> = _r; + match _r.recv_timeout($timeout) { + ::std::result::Result::Err($crate::RecvTimeoutError::Timeout) => { + $default_body + } + _res => { + let _res = _res.map_err(|_| $crate::RecvError); + let $res = _res; + $recv_body + } + } + } + } + }}; + + // // Optimize the non-blocking case with two receive operations. + // (@init + // (recv($r1:expr) -> $res1:pat => $recv_body1:tt,) + // (recv($r2:expr) -> $res2:pat => $recv_body2:tt,) + // (default() => $default_body:tt,) + // ) => {{ + // match $r1 { + // ref _r1 => { + // let _r1: &$crate::Receiver<_> = _r1; + // + // match $r2 { + // ref _r2 => { + // let _r2: &$crate::Receiver<_> = _r2; + // + // // TODO(stjepang): Implement this optimization. + // } + // } + // } + // } + // }}; + // // Optimize the blocking case with two receive operations. + // (@init + // (recv($r1:expr) -> $res1:pat => $body1:tt,) + // (recv($r2:expr) -> $res2:pat => $body2:tt,) + // () + // ) => {{ + // match $r1 { + // ref _r1 => { + // let _r1: &$crate::Receiver<_> = _r1; + // + // match $r2 { + // ref _r2 => { + // let _r2: &$crate::Receiver<_> = _r2; + // + // // TODO(stjepang): Implement this optimization. + // } + // } + // } + // } + // }}; + // // Optimize the case with two receive operations and a timeout. + // (@init + // (recv($r1:expr) -> $res1:pat => $recv_body1:tt,) + // (recv($r2:expr) -> $res2:pat => $recv_body2:tt,) + // (default($timeout:expr) => $default_body:tt,) + // ) => {{ + // match $r1 { + // ref _r1 => { + // let _r1: &$crate::Receiver<_> = _r1; + // + // match $r2 { + // ref _r2 => { + // let _r2: &$crate::Receiver<_> = _r2; + // + // // TODO(stjepang): Implement this optimization. + // } + // } + // } + // } + // }}; + + // // Optimize `select!` into `try_send()`. + // (@init + // (send($s:expr, $m:expr) -> $res:pat => $send_body:tt,) + // (default() => $default_body:tt,) + // ) => {{ + // match $s { + // ref _s => { + // let _s: &$crate::Sender<_> = _s; + // // TODO(stjepang): Implement this optimization. + // } + // } + // }}; + // // Optimize `select!` into `send()`. + // (@init + // (send($s:expr, $m:expr) -> $res:pat => $body:tt,) + // () + // ) => {{ + // match $s { + // ref _s => { + // let _s: &$crate::Sender<_> = _s; + // // TODO(stjepang): Implement this optimization. + // } + // } + // }}; + // // Optimize `select!` into `send_timeout()`. + // (@init + // (send($s:expr, $m:expr) -> $res:pat => $body:tt,) + // (default($timeout:expr) => $body:tt,) + // ) => {{ + // match $s { + // ref _s => { + // let _s: &$crate::Sender<_> = _s; + // // TODO(stjepang): Implement this optimization. + // } + // } + // }}; + + // Create the list of handles and add operations to it. + (@init + ($($cases:tt)*) + $default:tt + ) => {{ + const _LEN: usize = crossbeam_channel_internal!(@count ($($cases)*)); + let _handle: &$crate::internal::SelectHandle = &$crate::never::<()>(); + + #[allow(unused_mut)] + let mut _sel = [(_handle, 0, 0 as *const u8); _LEN]; + + crossbeam_channel_internal!( + @add + _sel + ($($cases)*) + $default + ( + (0usize _oper0) + (1usize _oper1) + (2usize _oper2) + (3usize _oper3) + (4usize _oper4) + (5usize _oper5) + (6usize _oper6) + (7usize _oper7) + (8usize _oper8) + (9usize _oper9) + (10usize _oper10) + (11usize _oper11) + (12usize _oper12) + (13usize _oper13) + (14usize _oper14) + (15usize _oper15) + (16usize _oper16) + (17usize _oper17) + (18usize _oper18) + (19usize _oper19) + (20usize _oper20) + (21usize _oper21) + (22usize _oper22) + (23usize _oper23) + (24usize _oper24) + (25usize _oper25) + (26usize _oper26) + (27usize _oper27) + (28usize _oper28) + (29usize _oper29) + (30usize _oper30) + (31usize _oper31) + ) + () + ) + }}; + + // Count the listed cases. + (@count ()) => { + 0 + }; + (@count ($oper:ident $args:tt -> $res:pat => $body:tt, $($cases:tt)*)) => { + 1 + crossbeam_channel_internal!(@count ($($cases)*)) + }; + + // Run blocking selection. + (@add + $sel:ident + () + () + $labels:tt + $cases:tt + ) => {{ + let _oper: $crate::SelectedOperation<'_> = { + let _oper = $crate::internal::select(&mut $sel); + + // Erase the lifetime so that `sel` can be dropped early even without NLL. + #[allow(unsafe_code)] + unsafe { ::std::mem::transmute(_oper) } + }; + + crossbeam_channel_internal! { + @complete + $sel + _oper + $cases + } + }}; + // Run non-blocking selection. + (@add + $sel:ident + () + (default() => $body:tt,) + $labels:tt + $cases:tt + ) => {{ + let _oper: ::std::option::Option<$crate::SelectedOperation<'_>> = { + let _oper = $crate::internal::try_select(&mut $sel); + + // Erase the lifetime so that `sel` can be dropped early even without NLL. + #[allow(unsafe_code)] + unsafe { ::std::mem::transmute(_oper) } + }; + + match _oper { + None => { + ::std::mem::drop($sel); + $body + } + Some(_oper) => { + crossbeam_channel_internal! { + @complete + $sel + _oper + $cases + } + } + } + }}; + // Run selection with a timeout. + (@add + $sel:ident + () + (default($timeout:expr) => $body:tt,) + $labels:tt + $cases:tt + ) => {{ + let _oper: ::std::option::Option<$crate::SelectedOperation<'_>> = { + let _oper = $crate::internal::select_timeout(&mut $sel, $timeout); + + // Erase the lifetime so that `sel` can be dropped early even without NLL. + #[allow(unsafe_code)] + unsafe { ::std::mem::transmute(_oper) } + }; + + match _oper { + ::std::option::Option::None => { + ::std::mem::drop($sel); + $body + } + ::std::option::Option::Some(_oper) => { + crossbeam_channel_internal! { + @complete + $sel + _oper + $cases + } + } + } + }}; + // Have we used up all labels? + (@add + $sel:ident + $input:tt + $default:tt + () + $cases:tt + ) => { + crossbeam_channel_delegate!(compile_error("too many operations in a `select!` block")) + }; + // Add a receive operation to `sel`. + (@add + $sel:ident + (recv($r:expr) -> $res:pat => $body:tt, $($tail:tt)*) + $default:tt + (($i:tt $var:ident) $($labels:tt)*) + ($($cases:tt)*) + ) => {{ + match $r { + ref _r => { + #[allow(unsafe_code)] + let $var: &$crate::Receiver<_> = unsafe { + let _r: &$crate::Receiver<_> = _r; + + // Erase the lifetime so that `sel` can be dropped early even without NLL. + unsafe fn unbind<'a, T>(x: &T) -> &'a T { + ::std::mem::transmute(x) + } + unbind(_r) + }; + $sel[$i] = ($var, $i, $var as *const $crate::Receiver<_> as *const u8); + + crossbeam_channel_internal!( + @add + $sel + ($($tail)*) + $default + ($($labels)*) + ($($cases)* [$i] recv($var) -> $res => $body,) + ) + } + } + }}; + // Add a send operation to `sel`. + (@add + $sel:ident + (send($s:expr, $m:expr) -> $res:pat => $body:tt, $($tail:tt)*) + $default:tt + (($i:tt $var:ident) $($labels:tt)*) + ($($cases:tt)*) + ) => {{ + match $s { + ref _s => { + #[allow(unsafe_code)] + let $var: &$crate::Sender<_> = unsafe { + let _s: &$crate::Sender<_> = _s; + + // Erase the lifetime so that `sel` can be dropped early even without NLL. + unsafe fn unbind<'a, T>(x: &T) -> &'a T { + ::std::mem::transmute(x) + } + unbind(_s) + }; + $sel[$i] = ($var, $i, $var as *const $crate::Sender<_> as *const u8); + + crossbeam_channel_internal!( + @add + $sel + ($($tail)*) + $default + ($($labels)*) + ($($cases)* [$i] send($var, $m) -> $res => $body,) + ) + } + } + }}; + + // Complete a receive operation. + (@complete + $sel:ident + $oper:ident + ([$i:tt] recv($r:ident) -> $res:pat => $body:tt, $($tail:tt)*) + ) => {{ + if $oper.index() == $i { + let _res = $oper.recv($r); + ::std::mem::drop($sel); + + let $res = _res; + $body + } else { + crossbeam_channel_internal! { + @complete + $sel + $oper + ($($tail)*) + } + } + }}; + // Complete a send operation. + (@complete + $sel:ident + $oper:ident + ([$i:tt] send($s:ident, $m:expr) -> $res:pat => $body:tt, $($tail:tt)*) + ) => {{ + if $oper.index() == $i { + let _res = $oper.send($s, $m); + ::std::mem::drop($sel); + + let $res = _res; + $body + } else { + crossbeam_channel_internal! { + @complete + $sel + $oper + ($($tail)*) + } + } + }}; + // Panic if we don't identify the selected case, but this should never happen. + (@complete + $sel:ident + $oper:ident + () + ) => {{ + crossbeam_channel_delegate!(unreachable( + "internal error in crossbeam-channel: invalid case" + )) + }}; + + // Catches a bug within this macro (should not happen). + (@$($tokens:tt)*) => { + crossbeam_channel_delegate!(compile_error( + crossbeam_channel_delegate!(concat( + "internal error in crossbeam-channel: ", + crossbeam_channel_delegate!(stringify(@$($tokens)*)), + )) + )) + }; + + // The entry points. + () => { + crossbeam_channel_delegate!(compile_error("empty `select!` block")) + }; + ($($case:ident $(($($args:tt)*))* => $body:expr $(,)*)*) => { + crossbeam_channel_internal!( + @list + ($($case $(($($args)*))* => { $body },)*) + () + ) + }; + ($($tokens:tt)*) => { + crossbeam_channel_internal!( + @list + ($($tokens)*) + () + ) + }; +} + +/// Selects from a set of channel operations. +/// +/// This macro allows you to define a set of channel operations, wait until any one of them becomes +/// ready, and finally execute it. If multiple operations are ready at the same time, a random one +/// among them is selected. +/// +/// It is also possible to define a `default` case that gets executed if none of the operations are +/// ready, either right away or for a certain duration of time. +/// +/// An operation is considered to be ready if it doesn't have to block. Note that it is ready even +/// when it will simply return an error because the channel is disconnected. +/// +/// The `select` macro is a convenience wrapper around [`Select`]. However, it cannot select over a +/// dynamically created list of channel operations. +/// +/// [`Select`]: struct.Select.html +/// +/// # Examples +/// +/// Block until a send or a receive operation is selected: +/// +/// ``` +/// # #[macro_use] +/// # extern crate crossbeam_channel; +/// # fn main() { +/// use std::thread; +/// use crossbeam_channel::unbounded; +/// +/// let (s1, r1) = unbounded(); +/// let (s2, r2) = unbounded(); +/// s1.send(10).unwrap(); +/// +/// // Since both operations are initially ready, a random one will be executed. +/// select! { +/// recv(r1) -> msg => assert_eq!(msg, Ok(10)), +/// send(s2, 20) -> res => { +/// assert_eq!(res, Ok(())); +/// assert_eq!(r2.recv(), Ok(20)); +/// } +/// } +/// # } +/// ``` +/// +/// Select from a set of operations without blocking: +/// +/// ``` +/// # #[macro_use] +/// # extern crate crossbeam_channel; +/// # fn main() { +/// use std::thread; +/// use std::time::Duration; +/// use crossbeam_channel::unbounded; +/// +/// let (s1, r1) = unbounded(); +/// let (s2, r2) = unbounded(); +/// +/// thread::spawn(move || { +/// thread::sleep(Duration::from_secs(1)); +/// s1.send(10).unwrap(); +/// }); +/// thread::spawn(move || { +/// thread::sleep(Duration::from_millis(500)); +/// s2.send(20).unwrap(); +/// }); +/// +/// // None of the operations are initially ready. +/// select! { +/// recv(r1) -> msg => panic!(), +/// recv(r2) -> msg => panic!(), +/// default => println!("not ready"), +/// } +/// # } +/// ``` +/// +/// Select over a set of operations with a timeout: +/// +/// ``` +/// # #[macro_use] +/// # extern crate crossbeam_channel; +/// # fn main() { +/// use std::thread; +/// use std::time::Duration; +/// use crossbeam_channel::unbounded; +/// +/// let (s1, r1) = unbounded(); +/// let (s2, r2) = unbounded(); +/// +/// thread::spawn(move || { +/// thread::sleep(Duration::from_secs(1)); +/// s1.send(10).unwrap(); +/// }); +/// thread::spawn(move || { +/// thread::sleep(Duration::from_millis(500)); +/// s2.send(20).unwrap(); +/// }); +/// +/// // None of the two operations will become ready within 100 milliseconds. +/// select! { +/// recv(r1) -> msg => panic!(), +/// recv(r2) -> msg => panic!(), +/// default(Duration::from_millis(100)) => println!("timed out"), +/// } +/// # } +/// ``` +/// +/// Optionally add a receive operation to `select!` using [`never`]: +/// +/// ``` +/// # #[macro_use] +/// # extern crate crossbeam_channel; +/// # fn main() { +/// use std::thread; +/// use std::time::Duration; +/// use crossbeam_channel::{never, unbounded}; +/// +/// let (s1, r1) = unbounded(); +/// let (s2, r2) = unbounded(); +/// +/// thread::spawn(move || { +/// thread::sleep(Duration::from_secs(1)); +/// s1.send(10).unwrap(); +/// }); +/// thread::spawn(move || { +/// thread::sleep(Duration::from_millis(500)); +/// s2.send(20).unwrap(); +/// }); +/// +/// // This receiver can be a `Some` or a `None`. +/// let r2 = Some(&r2); +/// +/// // None of the two operations will become ready within 100 milliseconds. +/// select! { +/// recv(r1) -> msg => panic!(), +/// recv(r2.unwrap_or(&never())) -> msg => assert_eq!(msg, Ok(20)), +/// } +/// # } +/// ``` +/// +/// To optionally add a timeout to `select!`, see the [example] for [`never`]. +/// +/// [`never`]: fn.never.html +/// [example]: fn.never.html#examples +#[macro_export(local_inner_macros)] +macro_rules! select { + ($($tokens:tt)*) => { + crossbeam_channel_internal!( + $($tokens)* + ) + }; +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/utils.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/utils.rs new file mode 100644 index 0000000..c6513bc --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/utils.rs @@ -0,0 +1,112 @@ +//! Miscellaneous utilities. + +use std::cell::{Cell, UnsafeCell}; +use std::num::Wrapping; +use std::ops::{Deref, DerefMut}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::thread; +use std::time::{Duration, Instant}; + +use crossbeam_utils::Backoff; + +/// Randomly shuffles a slice. +pub fn shuffle(v: &mut [T]) { + let len = v.len(); + if len <= 1 { + return; + } + + thread_local! { + static RNG: Cell> = Cell::new(Wrapping(1406868647)); + } + + let _ = RNG.try_with(|rng| { + for i in 1..len { + // This is the 32-bit variant of Xorshift. + // + // Source: https://en.wikipedia.org/wiki/Xorshift + let mut x = rng.get(); + x ^= x << 13; + x ^= x >> 17; + x ^= x << 5; + rng.set(x); + + let x = x.0; + let n = i + 1; + + // This is a fast alternative to `let j = x % n`. + // + // Author: Daniel Lemire + // Source: https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/ + let j = ((x as u64).wrapping_mul(n as u64) >> 32) as u32 as usize; + + v.swap(i, j); + } + }); +} + +/// Sleeps until the deadline, or forever if the deadline isn't specified. +pub fn sleep_until(deadline: Option) { + loop { + match deadline { + None => thread::sleep(Duration::from_secs(1000)), + Some(d) => { + let now = Instant::now(); + if now >= d { + break; + } + thread::sleep(d - now); + } + } + } +} + +/// A simple spinlock. +pub struct Spinlock { + flag: AtomicBool, + value: UnsafeCell, +} + +impl Spinlock { + /// Returns a new spinlock initialized with `value`. + pub fn new(value: T) -> Spinlock { + Spinlock { + flag: AtomicBool::new(false), + value: UnsafeCell::new(value), + } + } + + /// Locks the spinlock. + pub fn lock(&self) -> SpinlockGuard<'_, T> { + let backoff = Backoff::new(); + while self.flag.swap(true, Ordering::Acquire) { + backoff.snooze(); + } + SpinlockGuard { parent: self } + } +} + +/// A guard holding a spinlock locked. +pub struct SpinlockGuard<'a, T: 'a> { + parent: &'a Spinlock, +} + +impl<'a, T> Drop for SpinlockGuard<'a, T> { + fn drop(&mut self) { + self.parent.flag.store(false, Ordering::Release); + } +} + +impl<'a, T> Deref for SpinlockGuard<'a, T> { + type Target = T; + + fn deref(&self) -> &T { + unsafe { &*self.parent.value.get() } + } +} + +impl<'a, T> DerefMut for SpinlockGuard<'a, T> { + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *self.parent.value.get() } + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/waker.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/waker.rs new file mode 100644 index 0000000..7f3428b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/src/waker.rs @@ -0,0 +1,285 @@ +//! Waking mechanism for threads blocked on channel operations. + +use std::sync::atomic::{AtomicBool, Ordering}; +use std::thread::{self, ThreadId}; + +use context::Context; +use select::{Operation, Selected}; +use utils::Spinlock; + +/// Represents a thread blocked on a specific channel operation. +pub struct Entry { + /// The operation. + pub oper: Operation, + + /// Optional packet. + pub packet: usize, + + /// Context associated with the thread owning this operation. + pub cx: Context, +} + +/// A queue of threads blocked on channel operations. +/// +/// This data structure is used by threads to register blocking operations and get woken up once +/// an operation becomes ready. +pub struct Waker { + /// A list of select operations. + selectors: Vec, + + /// A list of operations waiting to be ready. + observers: Vec, +} + +impl Waker { + /// Creates a new `Waker`. + #[inline] + pub fn new() -> Self { + Waker { + selectors: Vec::new(), + observers: Vec::new(), + } + } + + /// Registers a select operation. + #[inline] + pub fn register(&mut self, oper: Operation, cx: &Context) { + self.register_with_packet(oper, 0, cx); + } + + /// Registers a select operation and a packet. + #[inline] + pub fn register_with_packet(&mut self, oper: Operation, packet: usize, cx: &Context) { + self.selectors.push(Entry { + oper, + packet, + cx: cx.clone(), + }); + } + + /// Unregisters a select operation. + #[inline] + pub fn unregister(&mut self, oper: Operation) -> Option { + if let Some((i, _)) = self + .selectors + .iter() + .enumerate() + .find(|&(_, entry)| entry.oper == oper) + { + let entry = self.selectors.remove(i); + Some(entry) + } else { + None + } + } + + /// Attempts to find another thread's entry, select the operation, and wake it up. + #[inline] + pub fn try_select(&mut self) -> Option { + let mut entry = None; + + if !self.selectors.is_empty() { + let thread_id = current_thread_id(); + + for i in 0..self.selectors.len() { + // Does the entry belong to a different thread? + if self.selectors[i].cx.thread_id() != thread_id { + // Try selecting this operation. + let sel = Selected::Operation(self.selectors[i].oper); + let res = self.selectors[i].cx.try_select(sel); + + if res.is_ok() { + // Provide the packet. + self.selectors[i].cx.store_packet(self.selectors[i].packet); + // Wake the thread up. + self.selectors[i].cx.unpark(); + + // Remove the entry from the queue to keep it clean and improve + // performance. + entry = Some(self.selectors.remove(i)); + break; + } + } + } + } + + entry + } + + /// Returns `true` if there is an entry which can be selected by the current thread. + #[inline] + pub fn can_select(&self) -> bool { + if self.selectors.is_empty() { + false + } else { + let thread_id = current_thread_id(); + + self.selectors.iter().any(|entry| { + entry.cx.thread_id() != thread_id && entry.cx.selected() == Selected::Waiting + }) + } + } + + /// Registers an operation waiting to be ready. + #[inline] + pub fn watch(&mut self, oper: Operation, cx: &Context) { + self.observers.push(Entry { + oper, + packet: 0, + cx: cx.clone(), + }); + } + + /// Unregisters an operation waiting to be ready. + #[inline] + pub fn unwatch(&mut self, oper: Operation) { + self.observers.retain(|e| e.oper != oper); + } + + /// Notifies all operations waiting to be ready. + #[inline] + pub fn notify(&mut self) { + for entry in self.observers.drain(..) { + if entry.cx.try_select(Selected::Operation(entry.oper)).is_ok() { + entry.cx.unpark(); + } + } + } + + /// Notifies all registered operations that the channel is disconnected. + #[inline] + pub fn disconnect(&mut self) { + for entry in self.selectors.iter() { + if entry.cx.try_select(Selected::Disconnected).is_ok() { + // Wake the thread up. + // + // Here we don't remove the entry from the queue. Registered threads must + // unregister from the waker by themselves. They might also want to recover the + // packet value and destroy it, if necessary. + entry.cx.unpark(); + } + } + + self.notify(); + } +} + +impl Drop for Waker { + #[inline] + fn drop(&mut self) { + debug_assert_eq!(self.selectors.len(), 0); + debug_assert_eq!(self.observers.len(), 0); + } +} + +/// A waker that can be shared among threads without locking. +/// +/// This is a simple wrapper around `Waker` that internally uses a mutex for synchronization. +pub struct SyncWaker { + /// The inner `Waker`. + inner: Spinlock, + + /// `true` if the waker is empty. + is_empty: AtomicBool, +} + +impl SyncWaker { + /// Creates a new `SyncWaker`. + #[inline] + pub fn new() -> Self { + SyncWaker { + inner: Spinlock::new(Waker::new()), + is_empty: AtomicBool::new(true), + } + } + + /// Registers the current thread with an operation. + #[inline] + pub fn register(&self, oper: Operation, cx: &Context) { + let mut inner = self.inner.lock(); + inner.register(oper, cx); + self.is_empty.store( + inner.selectors.is_empty() && inner.observers.is_empty(), + Ordering::SeqCst, + ); + } + + /// Unregisters an operation previously registered by the current thread. + #[inline] + pub fn unregister(&self, oper: Operation) -> Option { + let mut inner = self.inner.lock(); + let entry = inner.unregister(oper); + self.is_empty.store( + inner.selectors.is_empty() && inner.observers.is_empty(), + Ordering::SeqCst, + ); + entry + } + + /// Attempts to find one thread (not the current one), select its operation, and wake it up. + #[inline] + pub fn notify(&self) { + if !self.is_empty.load(Ordering::SeqCst) { + let mut inner = self.inner.lock(); + inner.try_select(); + inner.notify(); + self.is_empty.store( + inner.selectors.is_empty() && inner.observers.is_empty(), + Ordering::SeqCst, + ); + } + } + + /// Registers an operation waiting to be ready. + #[inline] + pub fn watch(&self, oper: Operation, cx: &Context) { + let mut inner = self.inner.lock(); + inner.watch(oper, cx); + self.is_empty.store( + inner.selectors.is_empty() && inner.observers.is_empty(), + Ordering::SeqCst, + ); + } + + /// Unregisters an operation waiting to be ready. + #[inline] + pub fn unwatch(&self, oper: Operation) { + let mut inner = self.inner.lock(); + inner.unwatch(oper); + self.is_empty.store( + inner.selectors.is_empty() && inner.observers.is_empty(), + Ordering::SeqCst, + ); + } + + /// Notifies all threads that the channel is disconnected. + #[inline] + pub fn disconnect(&self) { + let mut inner = self.inner.lock(); + inner.disconnect(); + self.is_empty.store( + inner.selectors.is_empty() && inner.observers.is_empty(), + Ordering::SeqCst, + ); + } +} + +impl Drop for SyncWaker { + #[inline] + fn drop(&mut self) { + debug_assert_eq!(self.is_empty.load(Ordering::SeqCst), true); + } +} + +/// Returns the id of the current thread. +#[inline] +fn current_thread_id() -> ThreadId { + thread_local! { + /// Cached thread-local id. + static THREAD_ID: ThreadId = thread::current().id(); + } + + THREAD_ID + .try_with(|id| *id) + .unwrap_or_else(|_| thread::current().id()) +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/after.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/after.rs new file mode 100644 index 0000000..1137bb1 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/after.rs @@ -0,0 +1,339 @@ +//! Tests for the after channel flavor. + +#[macro_use] +extern crate crossbeam_channel; +extern crate crossbeam_utils; +extern crate rand; + +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; +use std::thread; +use std::time::{Duration, Instant}; + +use crossbeam_channel::{after, Select, TryRecvError}; +use crossbeam_utils::thread::scope; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +fn fire() { + let start = Instant::now(); + let r = after(ms(50)); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + thread::sleep(ms(100)); + + let fired = r.try_recv().unwrap(); + assert!(start < fired); + assert!(fired - start >= ms(50)); + + let now = Instant::now(); + assert!(fired < now); + assert!(now - fired >= ms(50)); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + + select! { + recv(r) -> _ => panic!(), + default => {} + } + + select! { + recv(r) -> _ => panic!(), + recv(after(ms(200))) -> _ => {} + } +} + +#[test] +fn capacity() { + const COUNT: usize = 10; + + for i in 0..COUNT { + let r = after(ms(i as u64)); + assert_eq!(r.capacity(), Some(1)); + } +} + +#[test] +fn len_empty_full() { + let r = after(ms(50)); + + assert_eq!(r.len(), 0); + assert_eq!(r.is_empty(), true); + assert_eq!(r.is_full(), false); + + thread::sleep(ms(100)); + + assert_eq!(r.len(), 1); + assert_eq!(r.is_empty(), false); + assert_eq!(r.is_full(), true); + + r.try_recv().unwrap(); + + assert_eq!(r.len(), 0); + assert_eq!(r.is_empty(), true); + assert_eq!(r.is_full(), false); +} + +#[test] +fn try_recv() { + let r = after(ms(200)); + assert!(r.try_recv().is_err()); + + thread::sleep(ms(100)); + assert!(r.try_recv().is_err()); + + thread::sleep(ms(200)); + assert!(r.try_recv().is_ok()); + assert!(r.try_recv().is_err()); + + thread::sleep(ms(200)); + assert!(r.try_recv().is_err()); +} + +#[test] +fn recv() { + let start = Instant::now(); + let r = after(ms(50)); + + let fired = r.recv().unwrap(); + assert!(start < fired); + assert!(fired - start >= ms(50)); + + let now = Instant::now(); + assert!(fired < now); + assert!(now - fired < fired - start); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn recv_timeout() { + let start = Instant::now(); + let r = after(ms(200)); + + assert!(r.recv_timeout(ms(100)).is_err()); + let now = Instant::now(); + assert!(now - start >= ms(100)); + assert!(now - start <= ms(150)); + + let fired = r.recv_timeout(ms(200)).unwrap(); + assert!(fired - start >= ms(200)); + assert!(fired - start <= ms(250)); + + assert!(r.recv_timeout(ms(200)).is_err()); + let now = Instant::now(); + assert!(now - start >= ms(400)); + assert!(now - start <= ms(450)); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn recv_two() { + let r1 = after(ms(50)); + let r2 = after(ms(50)); + + scope(|scope| { + scope.spawn(|_| { + select! { + recv(r1) -> _ => {} + recv(r2) -> _ => {} + } + }); + scope.spawn(|_| { + select! { + recv(r1) -> _ => {} + recv(r2) -> _ => {} + } + }); + }) + .unwrap(); +} + +#[test] +fn recv_race() { + select! { + recv(after(ms(50))) -> _ => {} + recv(after(ms(100))) -> _ => panic!(), + } + + select! { + recv(after(ms(100))) -> _ => panic!(), + recv(after(ms(50))) -> _ => {} + } +} + +#[test] +fn stress_default() { + const COUNT: usize = 10; + + for _ in 0..COUNT { + select! { + recv(after(ms(0))) -> _ => {} + default => panic!(), + } + } + + for _ in 0..COUNT { + select! { + recv(after(ms(100))) -> _ => panic!(), + default => {} + } + } +} + +#[test] +fn select() { + const THREADS: usize = 4; + const COUNT: usize = 1000; + const TIMEOUT_MS: u64 = 100; + + let v = (0..COUNT) + .map(|i| after(ms(i as u64 / TIMEOUT_MS / 2))) + .collect::>(); + let hits = AtomicUsize::new(0); + + scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + let v: Vec<&_> = v.iter().collect(); + + loop { + let timeout = after(ms(TIMEOUT_MS)); + let mut sel = Select::new(); + for r in &v { + sel.recv(r); + } + let oper_timeout = sel.recv(&timeout); + + let oper = sel.select(); + match oper.index() { + i if i == oper_timeout => { + oper.recv(&timeout).unwrap(); + break; + } + i => { + oper.recv(&v[i]).unwrap(); + hits.fetch_add(1, Ordering::SeqCst); + } + } + } + }); + } + }) + .unwrap(); + + assert_eq!(hits.load(Ordering::SeqCst), COUNT); +} + +#[test] +fn ready() { + const THREADS: usize = 4; + const COUNT: usize = 1000; + const TIMEOUT_MS: u64 = 100; + + let v = (0..COUNT) + .map(|i| after(ms(i as u64 / TIMEOUT_MS / 2))) + .collect::>(); + let hits = AtomicUsize::new(0); + + scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + let v: Vec<&_> = v.iter().collect(); + + loop { + let timeout = after(ms(TIMEOUT_MS)); + let mut sel = Select::new(); + for r in &v { + sel.recv(r); + } + let oper_timeout = sel.recv(&timeout); + + loop { + let i = sel.ready(); + if i == oper_timeout { + timeout.try_recv().unwrap(); + return; + } else if v[i].try_recv().is_ok() { + hits.fetch_add(1, Ordering::SeqCst); + break; + } + } + } + }); + } + }) + .unwrap(); + + assert_eq!(hits.load(Ordering::SeqCst), COUNT); +} + +#[test] +fn stress_clone() { + const RUNS: usize = 1000; + const THREADS: usize = 10; + const COUNT: usize = 50; + + for i in 0..RUNS { + let r = after(ms(i as u64)); + + scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + let r = r.clone(); + let _ = r.try_recv(); + + for _ in 0..COUNT { + drop(r.clone()); + thread::yield_now(); + } + }); + } + }) + .unwrap(); + } +} + +#[test] +fn fairness() { + const COUNT: usize = 1000; + + for &dur in &[0, 1] { + let mut hits = [0usize; 2]; + + for _ in 0..COUNT { + select! { + recv(after(ms(dur))) -> _ => hits[0] += 1, + recv(after(ms(dur))) -> _ => hits[1] += 1, + } + } + + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); + } +} + +#[test] +fn fairness_duplicates() { + const COUNT: usize = 1000; + + for &dur in &[0, 1] { + let mut hits = [0usize; 5]; + + for _ in 0..COUNT { + let r = after(ms(dur)); + select! { + recv(r) -> _ => hits[0] += 1, + recv(r) -> _ => hits[1] += 1, + recv(r) -> _ => hits[2] += 1, + recv(r) -> _ => hits[3] += 1, + recv(r) -> _ => hits[4] += 1, + } + } + + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/array.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/array.rs new file mode 100644 index 0000000..bc97f8b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/array.rs @@ -0,0 +1,659 @@ +//! Tests for the array channel flavor. + +#[macro_use] +extern crate crossbeam_channel; +extern crate crossbeam_utils; +extern crate rand; + +use std::any::Any; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; +use std::thread; +use std::time::Duration; + +use crossbeam_channel::{bounded, Receiver}; +use crossbeam_channel::{RecvError, RecvTimeoutError, TryRecvError}; +use crossbeam_channel::{SendError, SendTimeoutError, TrySendError}; +use crossbeam_utils::thread::scope; +use rand::{thread_rng, Rng}; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +fn smoke() { + let (s, r) = bounded(1); + s.send(7).unwrap(); + assert_eq!(r.try_recv(), Ok(7)); + + s.send(8).unwrap(); + assert_eq!(r.recv(), Ok(8)); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + assert_eq!(r.recv_timeout(ms(1000)), Err(RecvTimeoutError::Timeout)); +} + +#[test] +fn capacity() { + for i in 1..10 { + let (s, r) = bounded::<()>(i); + assert_eq!(s.capacity(), Some(i)); + assert_eq!(r.capacity(), Some(i)); + } +} + +#[test] +fn len_empty_full() { + let (s, r) = bounded(2); + + assert_eq!(s.len(), 0); + assert_eq!(s.is_empty(), true); + assert_eq!(s.is_full(), false); + assert_eq!(r.len(), 0); + assert_eq!(r.is_empty(), true); + assert_eq!(r.is_full(), false); + + s.send(()).unwrap(); + + assert_eq!(s.len(), 1); + assert_eq!(s.is_empty(), false); + assert_eq!(s.is_full(), false); + assert_eq!(r.len(), 1); + assert_eq!(r.is_empty(), false); + assert_eq!(r.is_full(), false); + + s.send(()).unwrap(); + + assert_eq!(s.len(), 2); + assert_eq!(s.is_empty(), false); + assert_eq!(s.is_full(), true); + assert_eq!(r.len(), 2); + assert_eq!(r.is_empty(), false); + assert_eq!(r.is_full(), true); + + r.recv().unwrap(); + + assert_eq!(s.len(), 1); + assert_eq!(s.is_empty(), false); + assert_eq!(s.is_full(), false); + assert_eq!(r.len(), 1); + assert_eq!(r.is_empty(), false); + assert_eq!(r.is_full(), false); +} + +#[test] +fn try_recv() { + let (s, r) = bounded(100); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + thread::sleep(ms(1500)); + assert_eq!(r.try_recv(), Ok(7)); + thread::sleep(ms(500)); + assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + s.send(7).unwrap(); + }); + }) + .unwrap(); +} + +#[test] +fn recv() { + let (s, r) = bounded(100); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.recv(), Ok(7)); + thread::sleep(ms(1000)); + assert_eq!(r.recv(), Ok(8)); + thread::sleep(ms(1000)); + assert_eq!(r.recv(), Ok(9)); + assert_eq!(r.recv(), Err(RecvError)); + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + s.send(7).unwrap(); + s.send(8).unwrap(); + s.send(9).unwrap(); + }); + }) + .unwrap(); +} + +#[test] +fn recv_timeout() { + let (s, r) = bounded::(100); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.recv_timeout(ms(1000)), Err(RecvTimeoutError::Timeout)); + assert_eq!(r.recv_timeout(ms(1000)), Ok(7)); + assert_eq!( + r.recv_timeout(ms(1000)), + Err(RecvTimeoutError::Disconnected) + ); + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + s.send(7).unwrap(); + }); + }) + .unwrap(); +} + +#[test] +fn try_send() { + let (s, r) = bounded(1); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(s.try_send(1), Ok(())); + assert_eq!(s.try_send(2), Err(TrySendError::Full(2))); + thread::sleep(ms(1500)); + assert_eq!(s.try_send(3), Ok(())); + thread::sleep(ms(500)); + assert_eq!(s.try_send(4), Err(TrySendError::Disconnected(4))); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + assert_eq!(r.try_recv(), Ok(1)); + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + assert_eq!(r.recv(), Ok(3)); + }); + }) + .unwrap(); +} + +#[test] +fn send() { + let (s, r) = bounded(1); + + scope(|scope| { + scope.spawn(|_| { + s.send(7).unwrap(); + thread::sleep(ms(1000)); + s.send(8).unwrap(); + thread::sleep(ms(1000)); + s.send(9).unwrap(); + thread::sleep(ms(1000)); + s.send(10).unwrap(); + }); + scope.spawn(|_| { + thread::sleep(ms(1500)); + assert_eq!(r.recv(), Ok(7)); + assert_eq!(r.recv(), Ok(8)); + assert_eq!(r.recv(), Ok(9)); + }); + }) + .unwrap(); +} + +#[test] +fn send_timeout() { + let (s, r) = bounded(2); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(s.send_timeout(1, ms(1000)), Ok(())); + assert_eq!(s.send_timeout(2, ms(1000)), Ok(())); + assert_eq!( + s.send_timeout(3, ms(500)), + Err(SendTimeoutError::Timeout(3)) + ); + thread::sleep(ms(1000)); + assert_eq!(s.send_timeout(4, ms(1000)), Ok(())); + thread::sleep(ms(1000)); + assert_eq!(s.send(5), Err(SendError(5))); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + assert_eq!(r.recv(), Ok(1)); + thread::sleep(ms(1000)); + assert_eq!(r.recv(), Ok(2)); + assert_eq!(r.recv(), Ok(4)); + }); + }) + .unwrap(); +} + +#[test] +fn send_after_disconnect() { + let (s, r) = bounded(100); + + s.send(1).unwrap(); + s.send(2).unwrap(); + s.send(3).unwrap(); + + drop(r); + + assert_eq!(s.send(4), Err(SendError(4))); + assert_eq!(s.try_send(5), Err(TrySendError::Disconnected(5))); + assert_eq!( + s.send_timeout(6, ms(500)), + Err(SendTimeoutError::Disconnected(6)) + ); +} + +#[test] +fn recv_after_disconnect() { + let (s, r) = bounded(100); + + s.send(1).unwrap(); + s.send(2).unwrap(); + s.send(3).unwrap(); + + drop(s); + + assert_eq!(r.recv(), Ok(1)); + assert_eq!(r.recv(), Ok(2)); + assert_eq!(r.recv(), Ok(3)); + assert_eq!(r.recv(), Err(RecvError)); +} + +#[test] +fn len() { + const COUNT: usize = 25_000; + const CAP: usize = 1000; + + let (s, r) = bounded(CAP); + + assert_eq!(s.len(), 0); + assert_eq!(r.len(), 0); + + for _ in 0..CAP / 10 { + for i in 0..50 { + s.send(i).unwrap(); + assert_eq!(s.len(), i + 1); + } + + for i in 0..50 { + r.recv().unwrap(); + assert_eq!(r.len(), 50 - i - 1); + } + } + + assert_eq!(s.len(), 0); + assert_eq!(r.len(), 0); + + for i in 0..CAP { + s.send(i).unwrap(); + assert_eq!(s.len(), i + 1); + } + + for _ in 0..CAP { + r.recv().unwrap(); + } + + assert_eq!(s.len(), 0); + assert_eq!(r.len(), 0); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + assert_eq!(r.recv(), Ok(i)); + let len = r.len(); + assert!(len <= CAP); + } + }); + + scope.spawn(|_| { + for i in 0..COUNT { + s.send(i).unwrap(); + let len = s.len(); + assert!(len <= CAP); + } + }); + }) + .unwrap(); + + assert_eq!(s.len(), 0); + assert_eq!(r.len(), 0); +} + +#[test] +fn disconnect_wakes_sender() { + let (s, r) = bounded(1); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(s.send(()), Ok(())); + assert_eq!(s.send(()), Err(SendError(()))); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + drop(r); + }); + }) + .unwrap(); +} + +#[test] +fn disconnect_wakes_receiver() { + let (s, r) = bounded::<()>(1); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.recv(), Err(RecvError)); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + drop(s); + }); + }) + .unwrap(); +} + +#[test] +fn spsc() { + const COUNT: usize = 100_000; + + let (s, r) = bounded(3); + + scope(|scope| { + scope.spawn(move |_| { + for i in 0..COUNT { + assert_eq!(r.recv(), Ok(i)); + } + assert_eq!(r.recv(), Err(RecvError)); + }); + scope.spawn(move |_| { + for i in 0..COUNT { + s.send(i).unwrap(); + } + }); + }) + .unwrap(); +} + +#[test] +fn mpmc() { + const COUNT: usize = 25_000; + const THREADS: usize = 4; + + let (s, r) = bounded::(3); + let v = (0..COUNT).map(|_| AtomicUsize::new(0)).collect::>(); + + scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + for _ in 0..COUNT { + let n = r.recv().unwrap(); + v[n].fetch_add(1, Ordering::SeqCst); + } + }); + } + for _ in 0..THREADS { + scope.spawn(|_| { + for i in 0..COUNT { + s.send(i).unwrap(); + } + }); + } + }) + .unwrap(); + + for c in v { + assert_eq!(c.load(Ordering::SeqCst), THREADS); + } +} + +#[test] +fn stress_oneshot() { + const COUNT: usize = 10_000; + + for _ in 0..COUNT { + let (s, r) = bounded(1); + + scope(|scope| { + scope.spawn(|_| r.recv().unwrap()); + scope.spawn(|_| s.send(0).unwrap()); + }) + .unwrap(); + } +} + +#[test] +fn stress_iter() { + const COUNT: usize = 100_000; + + let (request_s, request_r) = bounded(1); + let (response_s, response_r) = bounded(1); + + scope(|scope| { + scope.spawn(move |_| { + let mut count = 0; + loop { + for x in response_r.try_iter() { + count += x; + if count == COUNT { + return; + } + } + request_s.send(()).unwrap(); + } + }); + + for _ in request_r.iter() { + if response_s.send(1).is_err() { + break; + } + } + }) + .unwrap(); +} + +#[test] +fn stress_timeout_two_threads() { + const COUNT: usize = 100; + + let (s, r) = bounded(2); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(50)); + } + loop { + if let Ok(()) = s.send_timeout(i, ms(10)) { + break; + } + } + } + }); + + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(50)); + } + loop { + if let Ok(x) = r.recv_timeout(ms(10)) { + assert_eq!(x, i); + break; + } + } + } + }); + }) + .unwrap(); +} + +#[test] +fn drops() { + const RUNS: usize = 100; + + static DROPS: AtomicUsize = AtomicUsize::new(0); + + #[derive(Debug, PartialEq)] + struct DropCounter; + + impl Drop for DropCounter { + fn drop(&mut self) { + DROPS.fetch_add(1, Ordering::SeqCst); + } + } + + let mut rng = thread_rng(); + + for _ in 0..RUNS { + let steps = rng.gen_range(0, 10_000); + let additional = rng.gen_range(0, 50); + + DROPS.store(0, Ordering::SeqCst); + let (s, r) = bounded::(50); + + scope(|scope| { + scope.spawn(|_| { + for _ in 0..steps { + r.recv().unwrap(); + } + }); + + scope.spawn(|_| { + for _ in 0..steps { + s.send(DropCounter).unwrap(); + } + }); + }) + .unwrap(); + + for _ in 0..additional { + s.send(DropCounter).unwrap(); + } + + assert_eq!(DROPS.load(Ordering::SeqCst), steps); + drop(s); + drop(r); + assert_eq!(DROPS.load(Ordering::SeqCst), steps + additional); + } +} + +#[test] +fn linearizable() { + const COUNT: usize = 25_000; + const THREADS: usize = 4; + + let (s, r) = bounded(THREADS); + + scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + for _ in 0..COUNT { + s.send(0).unwrap(); + r.try_recv().unwrap(); + } + }); + } + }) + .unwrap(); +} + +#[test] +fn fairness() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded::<()>(COUNT); + let (s2, r2) = bounded::<()>(COUNT); + + for _ in 0..COUNT { + s1.send(()).unwrap(); + s2.send(()).unwrap(); + } + + let mut hits = [0usize; 2]; + for _ in 0..COUNT { + select! { + recv(r1) -> _ => hits[0] += 1, + recv(r2) -> _ => hits[1] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); +} + +#[test] +fn fairness_duplicates() { + const COUNT: usize = 10_000; + + let (s, r) = bounded::<()>(COUNT); + + for _ in 0..COUNT { + s.send(()).unwrap(); + } + + let mut hits = [0usize; 5]; + for _ in 0..COUNT { + select! { + recv(r) -> _ => hits[0] += 1, + recv(r) -> _ => hits[1] += 1, + recv(r) -> _ => hits[2] += 1, + recv(r) -> _ => hits[3] += 1, + recv(r) -> _ => hits[4] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); +} + +#[test] +fn recv_in_send() { + let (s, _r) = bounded(1); + s.send(()).unwrap(); + + #[allow(unreachable_code)] + { + select! { + send(s, panic!()) -> _ => panic!(), + default => {} + } + } + + let (s, r) = bounded(2); + s.send(()).unwrap(); + + select! { + send(s, assert_eq!(r.recv(), Ok(()))) -> _ => {} + } +} + +#[test] +fn channel_through_channel() { + const COUNT: usize = 1000; + + type T = Box; + + let (s, r) = bounded::(1); + + scope(|scope| { + scope.spawn(move |_| { + let mut s = s; + + for _ in 0..COUNT { + let (new_s, new_r) = bounded(1); + let new_r: T = Box::new(Some(new_r)); + + s.send(new_r).unwrap(); + s = new_s; + } + }); + + scope.spawn(move |_| { + let mut r = r; + + for _ in 0..COUNT { + r = r + .recv() + .unwrap() + .downcast_mut::>>() + .unwrap() + .take() + .unwrap() + } + }); + }) + .unwrap(); +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/golang.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/golang.rs new file mode 100644 index 0000000..8f48db6 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/golang.rs @@ -0,0 +1,1448 @@ +//! Tests copied from Go and manually rewritten in Rust. +//! +//! Source: +//! - https://github.com/golang/go +//! +//! Copyright & License: +//! - Copyright (c) 2009 The Go Authors +//! - https://golang.org/AUTHORS +//! - https://golang.org/LICENSE +//! - https://golang.org/PATENTS + +#[macro_use] +extern crate crossbeam_channel; + +use std::any::Any; +use std::cell::Cell; +use std::collections::HashMap; +use std::sync::{Arc, Condvar, Mutex}; +use std::thread; +use std::time::Duration; + +use crossbeam_channel::{bounded, tick, Receiver, Select, Sender}; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +struct Chan { + inner: Arc>>, +} + +struct ChanInner { + s: Option>, + r: Receiver, +} + +impl Clone for Chan { + fn clone(&self) -> Chan { + Chan { + inner: self.inner.clone(), + } + } +} + +impl Chan { + fn send(&self, msg: T) { + let s = self + .inner + .lock() + .unwrap() + .s + .as_ref() + .expect("sending into closed channel") + .clone(); + let _ = s.send(msg); + } + + fn try_recv(&self) -> Option { + let r = self.inner.lock().unwrap().r.clone(); + r.try_recv().ok() + } + + fn recv(&self) -> Option { + let r = self.inner.lock().unwrap().r.clone(); + r.recv().ok() + } + + fn close(&self) { + self.inner + .lock() + .unwrap() + .s + .take() + .expect("channel already closed"); + } + + fn rx(&self) -> Receiver { + self.inner.lock().unwrap().r.clone() + } + + fn tx(&self) -> Sender { + match self.inner.lock().unwrap().s.as_ref() { + None => { + let (s, r) = bounded(0); + std::mem::forget(r); + s + } + Some(s) => s.clone(), + } + } +} + +impl Iterator for Chan { + type Item = T; + + fn next(&mut self) -> Option { + self.recv() + } +} + +impl<'a, T> IntoIterator for &'a Chan { + type Item = T; + type IntoIter = Chan; + + fn into_iter(self) -> Self::IntoIter { + self.clone() + } +} + +fn make(cap: usize) -> Chan { + let (s, r) = bounded(cap); + Chan { + inner: Arc::new(Mutex::new(ChanInner { s: Some(s), r })), + } +} + +#[derive(Clone)] +struct WaitGroup(Arc); + +struct WaitGroupInner { + cond: Condvar, + count: Mutex, +} + +impl WaitGroup { + fn new() -> WaitGroup { + WaitGroup(Arc::new(WaitGroupInner { + cond: Condvar::new(), + count: Mutex::new(0), + })) + } + + fn add(&self, delta: i32) { + let mut count = self.0.count.lock().unwrap(); + *count += delta; + assert!(*count >= 0); + self.0.cond.notify_all(); + } + + fn done(&self) { + self.add(-1); + } + + fn wait(&self) { + let mut count = self.0.count.lock().unwrap(); + while *count > 0 { + count = self.0.cond.wait(count).unwrap(); + } + } +} + +struct Defer { + f: Option>, +} + +impl Drop for Defer { + fn drop(&mut self) { + let f = self.f.take().unwrap(); + let mut f = Some(f); + let mut f = move || f.take().unwrap()(); + f(); + } +} + +macro_rules! defer { + ($body:expr) => { + let _defer = Defer { + f: Some(Box::new(|| $body)), + }; + }; +} + +macro_rules! go { + (@parse ref $v:ident, $($tail:tt)*) => {{ + let ref $v = $v; + go!(@parse $($tail)*) + }}; + (@parse move $v:ident, $($tail:tt)*) => {{ + let $v = $v; + go!(@parse $($tail)*) + }}; + (@parse $v:ident, $($tail:tt)*) => {{ + let $v = $v.clone(); + go!(@parse $($tail)*) + }}; + (@parse $body:expr) => { + ::std::thread::spawn(move || { + let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { + $body + })); + if res.is_err() { + eprintln!("goroutine panicked: {:?}", res); + ::std::process::abort(); + } + }) + }; + (@parse $($tail:tt)*) => { + compile_error!("invalid `go!` syntax") + }; + ($($tail:tt)*) => {{ + go!(@parse $($tail)*) + }}; +} + +// https://github.com/golang/go/blob/master/test/chan/doubleselect.go +mod doubleselect { + use super::*; + + const ITERATIONS: i32 = 10_000; + + fn sender(n: i32, c1: Chan, c2: Chan, c3: Chan, c4: Chan) { + defer! { c1.close() } + defer! { c2.close() } + defer! { c3.close() } + defer! { c4.close() } + + for i in 0..n { + select! { + send(c1.tx(), i) -> _ => {} + send(c2.tx(), i) -> _ => {} + send(c3.tx(), i) -> _ => {} + send(c4.tx(), i) -> _ => {} + } + } + } + + fn mux(out: Chan, inp: Chan, done: Chan) { + for v in inp { + out.send(v); + } + done.send(true); + } + + fn recver(inp: Chan) { + let mut seen = HashMap::new(); + + for v in &inp { + if seen.contains_key(&v) { + panic!("got duplicate value for {}", v); + } + seen.insert(v, true); + } + } + + #[test] + fn main() { + let c1 = make::(0); + let c2 = make::(0); + let c3 = make::(0); + let c4 = make::(0); + let done = make::(0); + let cmux = make::(0); + + go!(c1, c2, c3, c4, sender(ITERATIONS, c1, c2, c3, c4)); + go!(cmux, c1, done, mux(cmux, c1, done)); + go!(cmux, c2, done, mux(cmux, c2, done)); + go!(cmux, c3, done, mux(cmux, c3, done)); + go!(cmux, c4, done, mux(cmux, c4, done)); + go!(done, cmux, { + done.recv(); + done.recv(); + done.recv(); + done.recv(); + cmux.close(); + }); + recver(cmux); + } +} + +// https://github.com/golang/go/blob/master/test/chan/fifo.go +mod fifo { + use super::*; + + const N: i32 = 10; + + #[test] + fn asynch_fifo() { + let ch = make::(N as usize); + for i in 0..N { + ch.send(i); + } + for i in 0..N { + if ch.recv() != Some(i) { + panic!("bad receive"); + } + } + } + + fn chain(ch: Chan, val: i32, inp: Chan, out: Chan) { + inp.recv(); + if ch.recv() != Some(val) { + panic!(val); + } + out.send(1); + } + + #[test] + fn synch_fifo() { + let ch = make::(0); + let mut inp = make::(0); + let start = inp.clone(); + + for i in 0..N { + let out = make::(0); + go!(ch, i, inp, out, chain(ch, i, inp, out)); + inp = out; + } + + start.send(0); + for i in 0..N { + ch.send(i); + } + inp.recv(); + } +} + +// https://github.com/golang/go/blob/master/test/chan/goroutines.go +mod goroutines { + use super::*; + + fn f(left: Chan, right: Chan) { + left.send(right.recv().unwrap()); + } + + #[test] + fn main() { + let n = 100i32; + + let leftmost = make::(0); + let mut right = leftmost.clone(); + let mut left = leftmost.clone(); + + for _ in 0..n { + right = make::(0); + go!(left, right, f(left, right)); + left = right.clone(); + } + + go!(right, right.send(1)); + leftmost.recv().unwrap(); + } +} + +// https://github.com/golang/go/blob/master/test/chan/nonblock.go +mod nonblock { + use super::*; + + fn i32receiver(c: Chan, strobe: Chan) { + if c.recv().unwrap() != 123 { + panic!("i32 value"); + } + strobe.send(true); + } + + fn i32sender(c: Chan, strobe: Chan) { + c.send(234); + strobe.send(true); + } + + fn i64receiver(c: Chan, strobe: Chan) { + if c.recv().unwrap() != 123456 { + panic!("i64 value"); + } + strobe.send(true); + } + + fn i64sender(c: Chan, strobe: Chan) { + c.send(234567); + strobe.send(true); + } + + fn breceiver(c: Chan, strobe: Chan) { + if !c.recv().unwrap() { + panic!("b value"); + } + strobe.send(true); + } + + fn bsender(c: Chan, strobe: Chan) { + c.send(true); + strobe.send(true); + } + + fn sreceiver(c: Chan, strobe: Chan) { + if c.recv().unwrap() != "hello" { + panic!("x value"); + } + strobe.send(true); + } + + fn ssender(c: Chan, strobe: Chan) { + c.send("hello again".to_string()); + strobe.send(true); + } + + const MAX_TRIES: usize = 10000; // Up to 100ms per test. + + #[test] + fn main() { + let ticker = tick(Duration::new(0, 10_000)); // 10 us + let sleep = || { + ticker.recv().unwrap(); + ticker.recv().unwrap(); + thread::yield_now(); + thread::yield_now(); + thread::yield_now(); + }; + + let sync = make::(0); + + for buffer in 0..2 { + let c32 = make::(buffer); + let c64 = make::(buffer); + let cb = make::(buffer); + let cs = make::(buffer); + + select! { + recv(c32.rx()) -> _ => panic!("blocked i32sender"), + default => {} + } + + select! { + recv(c64.rx()) -> _ => panic!("blocked i64sender"), + default => {} + } + + select! { + recv(cb.rx()) -> _ => panic!("blocked bsender"), + default => {} + } + + select! { + recv(cs.rx()) -> _ => panic!("blocked ssender"), + default => {} + } + + go!(c32, sync, i32receiver(c32, sync)); + let mut try = 0; + loop { + select! { + send(c32.tx(), 123) -> _ => break, + default => { + try += 1; + if try > MAX_TRIES { + println!("i32receiver buffer={}", buffer); + panic!("fail") + } + sleep(); + } + } + } + sync.recv(); + go!(c32, sync, i32sender(c32, sync)); + if buffer > 0 { + sync.recv(); + } + let mut try = 0; + loop { + select! { + recv(c32.rx()) -> v => { + if v != Ok(234) { + panic!("i32sender value"); + } + break; + } + default => { + try += 1; + if try > MAX_TRIES { + println!("i32sender buffer={}", buffer); + panic!("fail"); + } + sleep(); + } + } + } + if buffer == 0 { + sync.recv(); + } + + go!(c64, sync, i64receiver(c64, sync)); + let mut try = 0; + loop { + select! { + send(c64.tx(), 123456) -> _ => break, + default => { + try += 1; + if try > MAX_TRIES { + println!("i64receiver buffer={}", buffer); + panic!("fail") + } + sleep(); + } + } + } + sync.recv(); + go!(c64, sync, i64sender(c64, sync)); + if buffer > 0 { + sync.recv(); + } + let mut try = 0; + loop { + select! { + recv(c64.rx()) -> v => { + if v != Ok(234567) { + panic!("i64sender value"); + } + break; + } + default => { + try += 1; + if try > MAX_TRIES { + println!("i64sender buffer={}", buffer); + panic!("fail"); + } + sleep(); + } + } + } + if buffer == 0 { + sync.recv(); + } + + go!(cb, sync, breceiver(cb, sync)); + let mut try = 0; + loop { + select! { + send(cb.tx(), true) -> _ => break, + default => { + try += 1; + if try > MAX_TRIES { + println!("breceiver buffer={}", buffer); + panic!("fail") + } + sleep(); + } + } + } + sync.recv(); + go!(cb, sync, bsender(cb, sync)); + if buffer > 0 { + sync.recv(); + } + let mut try = 0; + loop { + select! { + recv(cb.rx()) -> v => { + if v != Ok(true) { + panic!("bsender value"); + } + break; + } + default => { + try += 1; + if try > MAX_TRIES { + println!("bsender buffer={}", buffer); + panic!("fail"); + } + sleep(); + } + } + } + if buffer == 0 { + sync.recv(); + } + + go!(cs, sync, sreceiver(cs, sync)); + let mut try = 0; + loop { + select! { + send(cs.tx(), "hello".to_string()) -> _ => break, + default => { + try += 1; + if try > MAX_TRIES { + println!("sreceiver buffer={}", buffer); + panic!("fail") + } + sleep(); + } + } + } + sync.recv(); + go!(cs, sync, ssender(cs, sync)); + if buffer > 0 { + sync.recv(); + } + let mut try = 0; + loop { + select! { + recv(cs.rx()) -> v => { + if v != Ok("hello again".to_string()) { + panic!("ssender value"); + } + break; + } + default => { + try += 1; + if try > MAX_TRIES { + println!("ssender buffer={}", buffer); + panic!("fail"); + } + sleep(); + } + } + } + if buffer == 0 { + sync.recv(); + } + } + } +} + +// https://github.com/golang/go/blob/master/test/chan/select.go +mod select { + use super::*; + + #[test] + fn main() { + let shift = Cell::new(0); + let counter = Cell::new(0); + + let get_value = || { + counter.set(counter.get() + 1); + 1 << shift.get() + }; + + let send = |mut a: Option<&Chan>, mut b: Option<&Chan>| { + let mut i = 0; + let never = make::(0); + loop { + let nil1 = never.tx(); + let nil2 = never.tx(); + let v1 = get_value(); + let v2 = get_value(); + select! { + send(a.map(|c| c.tx()).unwrap_or(nil1), v1) -> _ => { + i += 1; + a = None; + } + send(b.map(|c| c.tx()).unwrap_or(nil2), v2) -> _ => { + i += 1; + b = None; + } + default => break, + } + shift.set(shift.get() + 1); + } + i + }; + + let a = make::(1); + let b = make::(1); + + assert_eq!(send(Some(&a), Some(&b)), 2); + + let av = a.recv().unwrap(); + let bv = b.recv().unwrap(); + assert_eq!(av | bv, 3); + + assert_eq!(send(Some(&a), None), 1); + assert_eq!(counter.get(), 10); + } +} + +// https://github.com/golang/go/blob/master/test/chan/select2.go +mod select2 { + // TODO +} + +// https://github.com/golang/go/blob/master/test/chan/select3.go +mod select3 { + // TODO +} + +// https://github.com/golang/go/blob/master/test/chan/select4.go +mod select4 { + use super::*; + + #[test] + fn main() { + let c = make::(1); + let c1 = make::(0); + c.send(42); + select! { + recv(c1.rx()) -> _ => panic!("BUG"), + recv(c.rx()) -> v => assert_eq!(v, Ok(42)), + } + } +} + +// https://github.com/golang/go/blob/master/test/chan/select6.go +mod select6 { + use super::*; + + #[test] + fn main() { + let c1 = make::(0); + let c2 = make::(0); + let c3 = make::(0); + + go!(c1, c1.recv()); + go!(c1, c2, c3, { + select! { + recv(c1.rx()) -> _ => panic!("dummy"), + recv(c2.rx()) -> _ => c3.send(true), + } + c1.recv(); + }); + go!(c2, c2.send(true)); + + c3.recv(); + c1.send(true); + c1.send(true); + } +} + +// https://github.com/golang/go/blob/master/test/chan/select7.go +mod select7 { + use super::*; + + fn recv1(c: Chan) { + c.recv().unwrap(); + } + + fn recv2(c: Chan) { + select! { + recv(c.rx()) -> _ => () + } + } + + fn recv3(c: Chan) { + let c2 = make::(1); + select! { + recv(c.rx()) -> _ => (), + recv(c2.rx()) -> _ => () + } + } + + fn send1(recv: fn(Chan)) { + let c = make::(1); + go!(c, recv(c)); + thread::yield_now(); + c.send(1); + } + + fn send2(recv: fn(Chan)) { + let c = make::(1); + go!(c, recv(c)); + thread::yield_now(); + select! { + send(c.tx(), 1) -> _ => () + } + } + + fn send3(recv: fn(Chan)) { + let c = make::(1); + go!(c, recv(c)); + thread::yield_now(); + let c2 = make::(1); + select! { + send(c.tx(), 1) -> _ => (), + send(c2.tx(), 1) -> _ => () + } + } + + #[test] + fn main() { + send1(recv1); + send2(recv1); + send3(recv1); + send1(recv2); + send2(recv2); + send3(recv2); + send1(recv3); + send2(recv3); + send3(recv3); + } +} + +// https://github.com/golang/go/blob/master/test/chan/sieve1.go +mod sieve1 { + use super::*; + + fn generate(ch: Chan) { + let mut i = 2; + loop { + ch.send(i); + i += 1; + } + } + + fn filter(in_ch: Chan, out_ch: Chan, prime: i32) { + for i in in_ch { + if i % prime != 0 { + out_ch.send(i); + } + } + } + + fn sieve(primes: Chan) { + let mut ch = make::(1); + go!(ch, generate(ch)); + loop { + let prime = ch.recv().unwrap(); + primes.send(prime); + + let ch1 = make::(1); + go!(ch, ch1, prime, filter(ch, ch1, prime)); + ch = ch1; + } + } + + #[test] + fn main() { + let primes = make::(1); + go!(primes, sieve(primes)); + + let a = [ + 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, + 89, 97, + ]; + for item in a.iter() { + let x = primes.recv().unwrap(); + if x != *item { + println!("{} != {}", x, item); + panic!("fail"); + } + } + } +} + +// https://github.com/golang/go/blob/master/test/chan/zerosize.go +mod zerosize { + use super::*; + + #[test] + fn zero_size_struct() { + struct ZeroSize; + let _ = make::(0); + } + + #[test] + fn zero_size_array() { + let _ = make::<[u8; 0]>(0); + } +} + +// https://github.com/golang/go/blob/master/src/runtime/chan_test.go +mod chan_test { + use super::*; + + #[test] + fn test_chan() { + const N: i32 = 200; + + for cap in 0..N { + { + // Ensure that receive from empty chan blocks. + let c = make::(cap as usize); + + let recv1 = Arc::new(Mutex::new(false)); + go!(c, recv1, { + c.recv(); + *recv1.lock().unwrap() = true; + }); + + let recv2 = Arc::new(Mutex::new(false)); + go!(c, recv2, { + c.recv(); + *recv2.lock().unwrap() = true; + }); + + thread::sleep(ms(1)); + + if *recv1.lock().unwrap() || *recv2.lock().unwrap() { + panic!(); + } + + // Ensure that non-blocking receive does not block. + select! { + recv(c.rx()) -> _ => panic!(), + default => {} + } + select! { + recv(c.rx()) -> _ => panic!(), + default => {} + } + + c.send(0); + c.send(0); + } + + { + // Ensure that send to full chan blocks. + let c = make::(cap as usize); + for i in 0..cap { + c.send(i); + } + + let sent = Arc::new(Mutex::new(0)); + go!(sent, c, { + c.send(0); + *sent.lock().unwrap() = 1; + }); + + thread::sleep(ms(1)); + + if *sent.lock().unwrap() != 0 { + panic!(); + } + + // Ensure that non-blocking send does not block. + select! { + send(c.tx(), 0) -> _ => panic!(), + default => {} + } + c.recv(); + } + + { + // Ensure that we receive 0 from closed chan. + let c = make::(cap as usize); + for i in 0..cap { + c.send(i); + } + c.close(); + + for i in 0..cap { + let v = c.recv(); + if v != Some(i) { + panic!(); + } + } + + if c.recv() != None { + panic!(); + } + if c.try_recv() != None { + panic!(); + } + } + + { + // Ensure that close unblocks receive. + let c = make::(cap as usize); + let done = make::(0); + + go!(c, done, { + let v = c.try_recv(); + done.send(v.is_some()); + }); + + thread::sleep(ms(1)); + c.close(); + + if !done.recv().unwrap() { + // panic!(); + } + } + + { + // Send 100 integers, + // ensure that we receive them non-corrupted in FIFO order. + let c = make::(cap as usize); + go!(c, { + for i in 0..100 { + c.send(i); + } + }); + for i in 0..100 { + if c.recv() != Some(i) { + panic!(); + } + } + + // Same, but using recv2. + go!(c, { + for i in 0..100 { + c.send(i); + } + }); + for i in 0..100 { + if c.recv() != Some(i) { + panic!(); + } + } + } + } + } + + #[test] + fn test_nonblock_recv_race() { + const N: usize = 1000; + + for _ in 0..N { + let c = make::(1); + c.send(1); + + let t = go!(c, { + select! { + recv(c.rx()) -> _ => {} + default => panic!("chan is not ready"), + } + }); + + c.close(); + c.recv(); + t.join().unwrap(); + } + } + + #[test] + fn test_nonblock_select_race() { + const N: usize = 1000; + + let done = make::(1); + for _ in 0..N { + let c1 = make::(1); + let c2 = make::(1); + c1.send(1); + + go!(c1, c2, done, { + select! { + recv(c1.rx()) -> _ => {} + recv(c2.rx()) -> _ => {} + default => { + done.send(false); + return; + } + } + done.send(true); + }); + + c2.send(1); + select! { + recv(c1.rx()) -> _ => {} + default => {} + } + if !done.recv().unwrap() { + panic!("no chan is ready"); + } + } + } + + #[test] + fn test_nonblock_select_race2() { + const N: usize = 1000; + + let done = make::(1); + for _ in 0..N { + let c1 = make::(1); + let c2 = make::(0); + c1.send(1); + + go!(c1, c2, done, { + select! { + recv(c1.rx()) -> _ => {} + recv(c2.rx()) -> _ => {} + default => { + done.send(false); + return; + } + } + done.send(true); + }); + + c2.close(); + select! { + recv(c1.rx()) -> _ => {} + default => {} + } + if !done.recv().unwrap() { + panic!("no chan is ready"); + } + } + } + + #[test] + fn test_self_select() { + // Ensure that send/recv on the same chan in select + // does not crash nor deadlock. + + for &cap in &[0, 10] { + let wg = WaitGroup::new(); + wg.add(2); + let c = make::(cap); + + for p in 0..2 { + let p = p; + go!(wg, p, c, { + defer! { wg.done() } + for i in 0..1000 { + if p == 0 || i % 2 == 0 { + select! { + send(c.tx(), p) -> _ => {} + recv(c.rx()) -> v => { + if cap == 0 && v.ok() == Some(p) { + panic!("self receive"); + } + } + } + } else { + select! { + recv(c.rx()) -> v => { + if cap == 0 && v.ok() == Some(p) { + panic!("self receive"); + } + } + send(c.tx(), p) -> _ => {} + } + } + } + }); + } + wg.wait(); + } + } + + #[test] + fn test_select_stress() { + let c = vec![ + make::(0), + make::(0), + make::(2), + make::(3), + ]; + + const N: usize = 10000; + + // There are 4 goroutines that send N values on each of the chans, + // + 4 goroutines that receive N values on each of the chans, + // + 1 goroutine that sends N values on each of the chans in a single select, + // + 1 goroutine that receives N values on each of the chans in a single select. + // All these sends, receives and selects interact chaotically at runtime, + // but we are careful that this whole construct does not deadlock. + let wg = WaitGroup::new(); + wg.add(10); + + for k in 0..4 { + go!(k, c, wg, { + for _ in 0..N { + c[k].send(0); + } + wg.done(); + }); + go!(k, c, wg, { + for _ in 0..N { + c[k].recv(); + } + wg.done(); + }); + } + + go!(c, wg, { + let mut n = [0; 4]; + let mut c1 = c.iter().map(|c| Some(c.rx().clone())).collect::>(); + + for _ in 0..4 * N { + let index = { + let mut sel = Select::new(); + let mut opers = [!0; 4]; + for &i in &[3, 2, 0, 1] { + if let Some(c) = &c1[i] { + opers[i] = sel.recv(c); + } + } + + let oper = sel.select(); + let mut index = !0; + for i in 0..4 { + if opers[i] == oper.index() { + index = i; + let _ = oper.recv(c1[i].as_ref().unwrap()); + break; + } + } + index + }; + + n[index] += 1; + if n[index] == N { + c1[index] = None; + } + } + wg.done(); + }); + + go!(c, wg, { + let mut n = [0; 4]; + let mut c1 = c.iter().map(|c| Some(c.tx().clone())).collect::>(); + + for _ in 0..4 * N { + let index = { + let mut sel = Select::new(); + let mut opers = [!0; 4]; + for &i in &[0, 1, 2, 3] { + if let Some(c) = &c1[i] { + opers[i] = sel.send(c); + } + } + + let oper = sel.select(); + let mut index = !0; + for i in 0..4 { + if opers[i] == oper.index() { + index = i; + let _ = oper.send(c1[i].as_ref().unwrap(), 0); + break; + } + } + index + }; + + n[index] += 1; + if n[index] == N { + c1[index] = None; + } + } + wg.done(); + }); + + wg.wait(); + } + + #[test] + fn test_select_fairness() { + const TRIALS: usize = 10000; + + let c1 = make::(TRIALS + 1); + let c2 = make::(TRIALS + 1); + + for _ in 0..TRIALS + 1 { + c1.send(1); + c2.send(2); + } + + let c3 = make::(0); + let c4 = make::(0); + let out = make::(0); + let done = make::(0); + let wg = WaitGroup::new(); + + wg.add(1); + go!(wg, c1, c2, c3, c4, out, done, { + defer! { wg.done() }; + loop { + let b; + select! { + recv(c3.rx()) -> m => b = m.unwrap(), + recv(c4.rx()) -> m => b = m.unwrap(), + recv(c1.rx()) -> m => b = m.unwrap(), + recv(c2.rx()) -> m => b = m.unwrap(), + } + select! { + send(out.tx(), b) -> _ => {} + recv(done.rx()) -> _ => return, + } + } + }); + + let (mut cnt1, mut cnt2) = (0, 0); + for _ in 0..TRIALS { + match out.recv() { + Some(1) => cnt1 += 1, + Some(2) => cnt2 += 1, + b => panic!("unexpected value {:?} on channel", b), + } + } + + // If the select in the goroutine is fair, + // cnt1 and cnt2 should be about the same value. + // With 10,000 trials, the expected margin of error at + // a confidence level of five nines is 4.4172 / (2 * Sqrt(10000)). + + let r = cnt1 as f64 / TRIALS as f64; + let e = (r - 0.5).abs(); + + if e > 4.4172 / (2.0 * (TRIALS as f64).sqrt()) { + panic!( + "unfair select: in {} trials, results were {}, {}", + TRIALS, cnt1, cnt2, + ); + } + + done.close(); + wg.wait(); + } + + #[test] + fn test_chan_send_interface() { + struct Mt; + + let c = make::>(1); + c.send(Box::new(Mt)); + + select! { + send(c.tx(), Box::new(Mt)) -> _ => {} + default => {} + } + + select! { + send(c.tx(), Box::new(Mt)) -> _ => {} + send(c.tx(), Box::new(Mt)) -> _ => {} + default => {} + } + } + + #[test] + fn test_pseudo_random_send() { + const N: usize = 100; + + for cap in 0..N { + let c = make::(cap); + let l = Arc::new(Mutex::new(vec![0i32; N])); + let done = make::(0); + + go!(c, done, l, { + let mut l = l.lock().unwrap(); + for i in 0..N { + thread::yield_now(); + l[i] = c.recv().unwrap(); + } + done.send(true); + }); + + for _ in 0..N { + select! { + send(c.tx(), 1) -> _ => {} + send(c.tx(), 0) -> _ => {} + } + } + done.recv(); + + let mut n0 = 0; + let mut n1 = 0; + for &i in l.lock().unwrap().iter() { + n0 += (i + 1) % 2; + n1 += i; + } + + if n0 <= N as i32 / 10 || n1 <= N as i32 / 10 { + panic!( + "Want pseudorandom, got {} zeros and {} ones (chan cap {})", + n0, n1, cap, + ); + } + } + } + + #[test] + fn test_multi_consumer() { + const NWORK: usize = 23; + const NITER: usize = 271828; + + let pn = [2, 3, 7, 11, 13, 17, 19, 23, 27, 31]; + + let q = make::(NWORK * 3); + let r = make::(NWORK * 3); + + let wg = WaitGroup::new(); + for i in 0..NWORK { + wg.add(1); + let w = i; + go!(q, r, wg, pn, { + for v in &q { + if pn[w % pn.len()] == v { + thread::yield_now(); + } + r.send(v); + } + wg.done(); + }); + } + + let expect = Arc::new(Mutex::new(0)); + go!(q, r, expect, wg, pn, { + for i in 0..NITER { + let v = pn[i % pn.len()]; + *expect.lock().unwrap() += v; + q.send(v); + } + q.close(); + wg.wait(); + r.close(); + }); + + let mut n = 0; + let mut s = 0; + for v in &r { + n += 1; + s += v; + } + + if n != NITER || s != *expect.lock().unwrap() { + panic!(); + } + } + + #[test] + fn test_select_duplicate_channel() { + // This test makes sure we can queue a G on + // the same channel multiple times. + let c = make::(0); + let d = make::(0); + let e = make::(0); + + go!(c, d, e, { + select! { + recv(c.rx()) -> _ => {} + recv(d.rx()) -> _ => {} + recv(e.rx()) -> _ => {} + } + e.send(9); + }); + thread::sleep(ms(1)); + + go!(c, c.recv()); + thread::sleep(ms(1)); + + d.send(7); + e.recv(); + c.send(8); + } +} + +// https://github.com/golang/go/blob/master/test/closedchan.go +mod closedchan { + // TODO +} + +// https://github.com/golang/go/blob/master/src/runtime/chanbarrier_test.go +mod chanbarrier_test { + // TODO +} + +// https://github.com/golang/go/blob/master/src/runtime/race/testdata/chan_test.go +mod race_chan_test { + // TODO +} + +// https://github.com/golang/go/blob/master/test/ken/chan.go +mod chan { + // TODO +} + +// https://github.com/golang/go/blob/master/test/ken/chan1.go +mod chan1 { + // TODO +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/iter.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/iter.rs new file mode 100644 index 0000000..6acec59 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/iter.rs @@ -0,0 +1,113 @@ +//! Tests for iteration over receivers. + +extern crate crossbeam_channel; +extern crate crossbeam_utils; + +use crossbeam_channel::unbounded; +use crossbeam_utils::thread::scope; + +#[test] +fn nested_recv_iter() { + let (s, r) = unbounded::(); + let (total_s, total_r) = unbounded::(); + + scope(|scope| { + scope.spawn(move |_| { + let mut acc = 0; + for x in r.iter() { + acc += x; + } + total_s.send(acc).unwrap(); + }); + + s.send(3).unwrap(); + s.send(1).unwrap(); + s.send(2).unwrap(); + drop(s); + assert_eq!(total_r.recv().unwrap(), 6); + }) + .unwrap(); +} + +#[test] +fn recv_iter_break() { + let (s, r) = unbounded::(); + let (count_s, count_r) = unbounded(); + + scope(|scope| { + scope.spawn(move |_| { + let mut count = 0; + for x in r.iter() { + if count >= 3 { + break; + } else { + count += x; + } + } + count_s.send(count).unwrap(); + }); + + s.send(2).unwrap(); + s.send(2).unwrap(); + s.send(2).unwrap(); + let _ = s.send(2); + drop(s); + assert_eq!(count_r.recv().unwrap(), 4); + }) + .unwrap(); +} + +#[test] +fn recv_try_iter() { + let (request_s, request_r) = unbounded(); + let (response_s, response_r) = unbounded(); + + scope(|scope| { + scope.spawn(move |_| { + let mut count = 0; + loop { + for x in response_r.try_iter() { + count += x; + if count == 6 { + return; + } + } + request_s.send(()).unwrap(); + } + }); + + for _ in request_r.iter() { + if response_s.send(2).is_err() { + break; + } + } + }) + .unwrap(); +} + +#[test] +fn recv_into_iter_owned() { + let mut iter = { + let (s, r) = unbounded::(); + s.send(1).unwrap(); + s.send(2).unwrap(); + r.into_iter() + }; + + assert_eq!(iter.next().unwrap(), 1); + assert_eq!(iter.next().unwrap(), 2); + assert_eq!(iter.next().is_none(), true); +} + +#[test] +fn recv_into_iter_borrowed() { + let (s, r) = unbounded::(); + s.send(1).unwrap(); + s.send(2).unwrap(); + drop(s); + + let mut iter = (&r).into_iter(); + assert_eq!(iter.next().unwrap(), 1); + assert_eq!(iter.next().unwrap(), 2); + assert_eq!(iter.next().is_none(), true); +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/list.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/list.rs new file mode 100644 index 0000000..2bf4c16 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/list.rs @@ -0,0 +1,538 @@ +//! Tests for the list channel flavor. + +#[macro_use] +extern crate crossbeam_channel; +extern crate crossbeam_utils; +extern crate rand; + +use std::any::Any; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; +use std::thread; +use std::time::Duration; + +use crossbeam_channel::{unbounded, Receiver}; +use crossbeam_channel::{RecvError, RecvTimeoutError, TryRecvError}; +use crossbeam_channel::{SendError, SendTimeoutError, TrySendError}; +use crossbeam_utils::thread::scope; +use rand::{thread_rng, Rng}; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +fn smoke() { + let (s, r) = unbounded(); + s.try_send(7).unwrap(); + assert_eq!(r.try_recv(), Ok(7)); + + s.send(8).unwrap(); + assert_eq!(r.recv(), Ok(8)); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + assert_eq!(r.recv_timeout(ms(1000)), Err(RecvTimeoutError::Timeout)); +} + +#[test] +fn capacity() { + let (s, r) = unbounded::<()>(); + assert_eq!(s.capacity(), None); + assert_eq!(r.capacity(), None); +} + +#[test] +fn len_empty_full() { + let (s, r) = unbounded(); + + assert_eq!(s.len(), 0); + assert_eq!(s.is_empty(), true); + assert_eq!(s.is_full(), false); + assert_eq!(r.len(), 0); + assert_eq!(r.is_empty(), true); + assert_eq!(r.is_full(), false); + + s.send(()).unwrap(); + + assert_eq!(s.len(), 1); + assert_eq!(s.is_empty(), false); + assert_eq!(s.is_full(), false); + assert_eq!(r.len(), 1); + assert_eq!(r.is_empty(), false); + assert_eq!(r.is_full(), false); + + r.recv().unwrap(); + + assert_eq!(s.len(), 0); + assert_eq!(s.is_empty(), true); + assert_eq!(s.is_full(), false); + assert_eq!(r.len(), 0); + assert_eq!(r.is_empty(), true); + assert_eq!(r.is_full(), false); +} + +#[test] +fn try_recv() { + let (s, r) = unbounded(); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + thread::sleep(ms(1500)); + assert_eq!(r.try_recv(), Ok(7)); + thread::sleep(ms(500)); + assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + s.send(7).unwrap(); + }); + }) + .unwrap(); +} + +#[test] +fn recv() { + let (s, r) = unbounded(); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.recv(), Ok(7)); + thread::sleep(ms(1000)); + assert_eq!(r.recv(), Ok(8)); + thread::sleep(ms(1000)); + assert_eq!(r.recv(), Ok(9)); + assert_eq!(r.recv(), Err(RecvError)); + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + s.send(7).unwrap(); + s.send(8).unwrap(); + s.send(9).unwrap(); + }); + }) + .unwrap(); +} + +#[test] +fn recv_timeout() { + let (s, r) = unbounded::(); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.recv_timeout(ms(1000)), Err(RecvTimeoutError::Timeout)); + assert_eq!(r.recv_timeout(ms(1000)), Ok(7)); + assert_eq!( + r.recv_timeout(ms(1000)), + Err(RecvTimeoutError::Disconnected) + ); + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + s.send(7).unwrap(); + }); + }) + .unwrap(); +} + +#[test] +fn try_send() { + let (s, r) = unbounded(); + for i in 0..1000 { + assert_eq!(s.try_send(i), Ok(())); + } + + drop(r); + assert_eq!(s.try_send(777), Err(TrySendError::Disconnected(777))); +} + +#[test] +fn send() { + let (s, r) = unbounded(); + for i in 0..1000 { + assert_eq!(s.send(i), Ok(())); + } + + drop(r); + assert_eq!(s.send(777), Err(SendError(777))); +} + +#[test] +fn send_timeout() { + let (s, r) = unbounded(); + for i in 0..1000 { + assert_eq!(s.send_timeout(i, ms(i as u64)), Ok(())); + } + + drop(r); + assert_eq!( + s.send_timeout(777, ms(0)), + Err(SendTimeoutError::Disconnected(777)) + ); +} + +#[test] +fn send_after_disconnect() { + let (s, r) = unbounded(); + + s.send(1).unwrap(); + s.send(2).unwrap(); + s.send(3).unwrap(); + + drop(r); + + assert_eq!(s.send(4), Err(SendError(4))); + assert_eq!(s.try_send(5), Err(TrySendError::Disconnected(5))); + assert_eq!( + s.send_timeout(6, ms(0)), + Err(SendTimeoutError::Disconnected(6)) + ); +} + +#[test] +fn recv_after_disconnect() { + let (s, r) = unbounded(); + + s.send(1).unwrap(); + s.send(2).unwrap(); + s.send(3).unwrap(); + + drop(s); + + assert_eq!(r.recv(), Ok(1)); + assert_eq!(r.recv(), Ok(2)); + assert_eq!(r.recv(), Ok(3)); + assert_eq!(r.recv(), Err(RecvError)); +} + +#[test] +fn len() { + let (s, r) = unbounded(); + + assert_eq!(s.len(), 0); + assert_eq!(r.len(), 0); + + for i in 0..50 { + s.send(i).unwrap(); + assert_eq!(s.len(), i + 1); + } + + for i in 0..50 { + r.recv().unwrap(); + assert_eq!(r.len(), 50 - i - 1); + } + + assert_eq!(s.len(), 0); + assert_eq!(r.len(), 0); +} + +#[test] +fn disconnect_wakes_receiver() { + let (s, r) = unbounded::<()>(); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.recv(), Err(RecvError)); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + drop(s); + }); + }) + .unwrap(); +} + +#[test] +fn spsc() { + const COUNT: usize = 100_000; + + let (s, r) = unbounded(); + + scope(|scope| { + scope.spawn(move |_| { + for i in 0..COUNT { + assert_eq!(r.recv(), Ok(i)); + } + assert_eq!(r.recv(), Err(RecvError)); + }); + scope.spawn(move |_| { + for i in 0..COUNT { + s.send(i).unwrap(); + } + }); + }) + .unwrap(); +} + +#[test] +fn mpmc() { + const COUNT: usize = 25_000; + const THREADS: usize = 4; + + let (s, r) = unbounded::(); + let v = (0..COUNT).map(|_| AtomicUsize::new(0)).collect::>(); + + scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + for _ in 0..COUNT { + let n = r.recv().unwrap(); + v[n].fetch_add(1, Ordering::SeqCst); + } + }); + } + for _ in 0..THREADS { + scope.spawn(|_| { + for i in 0..COUNT { + s.send(i).unwrap(); + } + }); + } + }) + .unwrap(); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + + for c in v { + assert_eq!(c.load(Ordering::SeqCst), THREADS); + } +} + +#[test] +fn stress_oneshot() { + const COUNT: usize = 10_000; + + for _ in 0..COUNT { + let (s, r) = unbounded(); + + scope(|scope| { + scope.spawn(|_| r.recv().unwrap()); + scope.spawn(|_| s.send(0).unwrap()); + }) + .unwrap(); + } +} + +#[test] +fn stress_iter() { + const COUNT: usize = 100_000; + + let (request_s, request_r) = unbounded(); + let (response_s, response_r) = unbounded(); + + scope(|scope| { + scope.spawn(move |_| { + let mut count = 0; + loop { + for x in response_r.try_iter() { + count += x; + if count == COUNT { + return; + } + } + request_s.send(()).unwrap(); + } + }); + + for _ in request_r.iter() { + if response_s.send(1).is_err() { + break; + } + } + }) + .unwrap(); +} + +#[test] +fn stress_timeout_two_threads() { + const COUNT: usize = 100; + + let (s, r) = unbounded(); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(50)); + } + s.send(i).unwrap(); + } + }); + + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(50)); + } + loop { + if let Ok(x) = r.recv_timeout(ms(10)) { + assert_eq!(x, i); + break; + } + } + } + }); + }) + .unwrap(); +} + +#[test] +fn drops() { + static DROPS: AtomicUsize = AtomicUsize::new(0); + + #[derive(Debug, PartialEq)] + struct DropCounter; + + impl Drop for DropCounter { + fn drop(&mut self) { + DROPS.fetch_add(1, Ordering::SeqCst); + } + } + + let mut rng = thread_rng(); + + for _ in 0..100 { + let steps = rng.gen_range(0, 10_000); + let additional = rng.gen_range(0, 1000); + + DROPS.store(0, Ordering::SeqCst); + let (s, r) = unbounded::(); + + scope(|scope| { + scope.spawn(|_| { + for _ in 0..steps { + r.recv().unwrap(); + } + }); + + scope.spawn(|_| { + for _ in 0..steps { + s.send(DropCounter).unwrap(); + } + }); + }) + .unwrap(); + + for _ in 0..additional { + s.try_send(DropCounter).unwrap(); + } + + assert_eq!(DROPS.load(Ordering::SeqCst), steps); + drop(s); + drop(r); + assert_eq!(DROPS.load(Ordering::SeqCst), steps + additional); + } +} + +#[test] +fn linearizable() { + const COUNT: usize = 25_000; + const THREADS: usize = 4; + + let (s, r) = unbounded(); + + scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + for _ in 0..COUNT { + s.send(0).unwrap(); + r.try_recv().unwrap(); + } + }); + } + }) + .unwrap(); +} + +#[test] +fn fairness() { + const COUNT: usize = 10_000; + + let (s1, r1) = unbounded::<()>(); + let (s2, r2) = unbounded::<()>(); + + for _ in 0..COUNT { + s1.send(()).unwrap(); + s2.send(()).unwrap(); + } + + let mut hits = [0usize; 2]; + for _ in 0..COUNT { + select! { + recv(r1) -> _ => hits[0] += 1, + recv(r2) -> _ => hits[1] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); +} + +#[test] +fn fairness_duplicates() { + const COUNT: usize = 10_000; + + let (s, r) = unbounded(); + + for _ in 0..COUNT { + s.send(()).unwrap(); + } + + let mut hits = [0usize; 5]; + for _ in 0..COUNT { + select! { + recv(r) -> _ => hits[0] += 1, + recv(r) -> _ => hits[1] += 1, + recv(r) -> _ => hits[2] += 1, + recv(r) -> _ => hits[3] += 1, + recv(r) -> _ => hits[4] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); +} + +#[test] +fn recv_in_send() { + let (s, r) = unbounded(); + s.send(()).unwrap(); + + select! { + send(s, assert_eq!(r.recv(), Ok(()))) -> _ => {} + } +} + +#[test] +fn channel_through_channel() { + const COUNT: usize = 1000; + + type T = Box; + + let (s, r) = unbounded::(); + + scope(|scope| { + scope.spawn(move |_| { + let mut s = s; + + for _ in 0..COUNT { + let (new_s, new_r) = unbounded(); + let new_r: T = Box::new(Some(new_r)); + + s.send(new_r).unwrap(); + s = new_s; + } + }); + + scope.spawn(move |_| { + let mut r = r; + + for _ in 0..COUNT { + r = r + .recv() + .unwrap() + .downcast_mut::>>() + .unwrap() + .take() + .unwrap() + } + }); + }) + .unwrap(); +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/mpsc.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/mpsc.rs new file mode 100644 index 0000000..213b9d8 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/mpsc.rs @@ -0,0 +1,2095 @@ +//! Tests copied from `std::sync::mpsc`. +//! +//! This is a copy of tests for the `std::sync::mpsc` channels from the standard library, but +//! modified to work with `crossbeam-channel` instead. +//! +//! Minor tweaks were needed to make the tests compile: +//! +//! - Replace `box` syntax with `Box::new`. +//! - Replace all uses of `Select` with `select!`. +//! - Change the imports. +//! - Join all spawned threads. +//! - Removed assertion from oneshot_multi_thread_send_close_stress tests. +//! +//! Source: +//! - https://github.com/rust-lang/rust/tree/master/src/libstd/sync/mpsc +//! +//! Copyright & License: +//! - Copyright 2013-2014 The Rust Project Developers +//! - Apache License, Version 2.0 or MIT license, at your option +//! - https://github.com/rust-lang/rust/blob/master/COPYRIGHT +//! - https://www.rust-lang.org/en-US/legal.html + +#[macro_use] +extern crate crossbeam_channel as cc; + +use std::sync::mpsc::{RecvError, RecvTimeoutError, TryRecvError}; +use std::sync::mpsc::{SendError, TrySendError}; +use std::thread::JoinHandle; +use std::time::Duration; + +pub struct Sender { + pub inner: cc::Sender, +} + +impl Sender { + pub fn send(&self, t: T) -> Result<(), SendError> { + self.inner.send(t).map_err(|cc::SendError(m)| SendError(m)) + } +} + +impl Clone for Sender { + fn clone(&self) -> Sender { + Sender { + inner: self.inner.clone(), + } + } +} + +pub struct SyncSender { + pub inner: cc::Sender, +} + +impl SyncSender { + pub fn send(&self, t: T) -> Result<(), SendError> { + self.inner.send(t).map_err(|cc::SendError(m)| SendError(m)) + } + + pub fn try_send(&self, t: T) -> Result<(), TrySendError> { + self.inner.try_send(t).map_err(|err| match err { + cc::TrySendError::Full(m) => TrySendError::Full(m), + cc::TrySendError::Disconnected(m) => TrySendError::Disconnected(m), + }) + } +} + +impl Clone for SyncSender { + fn clone(&self) -> SyncSender { + SyncSender { + inner: self.inner.clone(), + } + } +} + +pub struct Receiver { + pub inner: cc::Receiver, +} + +impl Receiver { + pub fn try_recv(&self) -> Result { + self.inner.try_recv().map_err(|err| match err { + cc::TryRecvError::Empty => TryRecvError::Empty, + cc::TryRecvError::Disconnected => TryRecvError::Disconnected, + }) + } + + pub fn recv(&self) -> Result { + self.inner.recv().map_err(|_| RecvError) + } + + pub fn recv_timeout(&self, timeout: Duration) -> Result { + self.inner.recv_timeout(timeout).map_err(|err| match err { + cc::RecvTimeoutError::Timeout => RecvTimeoutError::Timeout, + cc::RecvTimeoutError::Disconnected => RecvTimeoutError::Disconnected, + }) + } + + pub fn iter(&self) -> Iter { + Iter { inner: self } + } + + pub fn try_iter(&self) -> TryIter { + TryIter { inner: self } + } +} + +impl<'a, T> IntoIterator for &'a Receiver { + type Item = T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + +impl IntoIterator for Receiver { + type Item = T; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + IntoIter { inner: self } + } +} + +pub struct TryIter<'a, T: 'a> { + inner: &'a Receiver, +} + +impl<'a, T> Iterator for TryIter<'a, T> { + type Item = T; + + fn next(&mut self) -> Option { + self.inner.try_recv().ok() + } +} + +pub struct Iter<'a, T: 'a> { + inner: &'a Receiver, +} + +impl<'a, T> Iterator for Iter<'a, T> { + type Item = T; + + fn next(&mut self) -> Option { + self.inner.recv().ok() + } +} + +pub struct IntoIter { + inner: Receiver, +} + +impl Iterator for IntoIter { + type Item = T; + + fn next(&mut self) -> Option { + self.inner.recv().ok() + } +} + +pub fn channel() -> (Sender, Receiver) { + let (s, r) = cc::unbounded(); + let s = Sender { inner: s }; + let r = Receiver { inner: r }; + (s, r) +} + +pub fn sync_channel(bound: usize) -> (SyncSender, Receiver) { + let (s, r) = cc::bounded(bound); + let s = SyncSender { inner: s }; + let r = Receiver { inner: r }; + (s, r) +} + +macro_rules! select { + ( + $($name:pat = $rx:ident.$meth:ident() => $code:expr),+ + ) => ({ + crossbeam_channel_internal! { + $( + recv(($rx).inner) -> res => { + let $name = res.map_err(|_| ::std::sync::mpsc::RecvError); + $code + } + )+ + } + }) +} + +// Source: https://github.com/rust-lang/rust/blob/master/src/libstd/sync/mpsc/mod.rs +mod channel_tests { + use super::*; + + use std::env; + use std::thread; + use std::time::{Duration, Instant}; + + pub fn stress_factor() -> usize { + match env::var("RUST_TEST_STRESS") { + Ok(val) => val.parse().unwrap(), + Err(..) => 1, + } + } + + #[test] + fn smoke() { + let (tx, rx) = channel::(); + tx.send(1).unwrap(); + assert_eq!(rx.recv().unwrap(), 1); + } + + #[test] + fn drop_full() { + let (tx, _rx) = channel::>(); + tx.send(Box::new(1)).unwrap(); + } + + #[test] + fn drop_full_shared() { + let (tx, _rx) = channel::>(); + drop(tx.clone()); + drop(tx.clone()); + tx.send(Box::new(1)).unwrap(); + } + + #[test] + fn smoke_shared() { + let (tx, rx) = channel::(); + tx.send(1).unwrap(); + assert_eq!(rx.recv().unwrap(), 1); + let tx = tx.clone(); + tx.send(1).unwrap(); + assert_eq!(rx.recv().unwrap(), 1); + } + + #[test] + fn smoke_threads() { + let (tx, rx) = channel::(); + let t = thread::spawn(move || { + tx.send(1).unwrap(); + }); + assert_eq!(rx.recv().unwrap(), 1); + t.join().unwrap(); + } + + #[test] + fn smoke_port_gone() { + let (tx, rx) = channel::(); + drop(rx); + assert!(tx.send(1).is_err()); + } + + #[test] + fn smoke_shared_port_gone() { + let (tx, rx) = channel::(); + drop(rx); + assert!(tx.send(1).is_err()) + } + + #[test] + fn smoke_shared_port_gone2() { + let (tx, rx) = channel::(); + drop(rx); + let tx2 = tx.clone(); + drop(tx); + assert!(tx2.send(1).is_err()); + } + + #[test] + fn port_gone_concurrent() { + let (tx, rx) = channel::(); + let t = thread::spawn(move || { + rx.recv().unwrap(); + }); + while tx.send(1).is_ok() {} + t.join().unwrap(); + } + + #[test] + fn port_gone_concurrent_shared() { + let (tx, rx) = channel::(); + let tx2 = tx.clone(); + let t = thread::spawn(move || { + rx.recv().unwrap(); + }); + while tx.send(1).is_ok() && tx2.send(1).is_ok() {} + t.join().unwrap(); + } + + #[test] + fn smoke_chan_gone() { + let (tx, rx) = channel::(); + drop(tx); + assert!(rx.recv().is_err()); + } + + #[test] + fn smoke_chan_gone_shared() { + let (tx, rx) = channel::<()>(); + let tx2 = tx.clone(); + drop(tx); + drop(tx2); + assert!(rx.recv().is_err()); + } + + #[test] + fn chan_gone_concurrent() { + let (tx, rx) = channel::(); + let t = thread::spawn(move || { + tx.send(1).unwrap(); + tx.send(1).unwrap(); + }); + while rx.recv().is_ok() {} + t.join().unwrap(); + } + + #[test] + fn stress() { + let (tx, rx) = channel::(); + let t = thread::spawn(move || { + for _ in 0..10000 { + tx.send(1).unwrap(); + } + }); + for _ in 0..10000 { + assert_eq!(rx.recv().unwrap(), 1); + } + t.join().ok().unwrap(); + } + + #[test] + fn stress_shared() { + const AMT: u32 = 10000; + const NTHREADS: u32 = 8; + let (tx, rx) = channel::(); + + let t = thread::spawn(move || { + for _ in 0..AMT * NTHREADS { + assert_eq!(rx.recv().unwrap(), 1); + } + match rx.try_recv() { + Ok(..) => panic!(), + _ => {} + } + }); + + let mut ts = Vec::with_capacity(NTHREADS as usize); + for _ in 0..NTHREADS { + let tx = tx.clone(); + let t = thread::spawn(move || { + for _ in 0..AMT { + tx.send(1).unwrap(); + } + }); + ts.push(t); + } + drop(tx); + t.join().ok().unwrap(); + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn send_from_outside_runtime() { + let (tx1, rx1) = channel::<()>(); + let (tx2, rx2) = channel::(); + let t1 = thread::spawn(move || { + tx1.send(()).unwrap(); + for _ in 0..40 { + assert_eq!(rx2.recv().unwrap(), 1); + } + }); + rx1.recv().unwrap(); + let t2 = thread::spawn(move || { + for _ in 0..40 { + tx2.send(1).unwrap(); + } + }); + t1.join().ok().unwrap(); + t2.join().ok().unwrap(); + } + + #[test] + fn recv_from_outside_runtime() { + let (tx, rx) = channel::(); + let t = thread::spawn(move || { + for _ in 0..40 { + assert_eq!(rx.recv().unwrap(), 1); + } + }); + for _ in 0..40 { + tx.send(1).unwrap(); + } + t.join().ok().unwrap(); + } + + #[test] + fn no_runtime() { + let (tx1, rx1) = channel::(); + let (tx2, rx2) = channel::(); + let t1 = thread::spawn(move || { + assert_eq!(rx1.recv().unwrap(), 1); + tx2.send(2).unwrap(); + }); + let t2 = thread::spawn(move || { + tx1.send(1).unwrap(); + assert_eq!(rx2.recv().unwrap(), 2); + }); + t1.join().ok().unwrap(); + t2.join().ok().unwrap(); + } + + #[test] + fn oneshot_single_thread_close_port_first() { + // Simple test of closing without sending + let (_tx, rx) = channel::(); + drop(rx); + } + + #[test] + fn oneshot_single_thread_close_chan_first() { + // Simple test of closing without sending + let (tx, _rx) = channel::(); + drop(tx); + } + + #[test] + fn oneshot_single_thread_send_port_close() { + // Testing that the sender cleans up the payload if receiver is closed + let (tx, rx) = channel::>(); + drop(rx); + assert!(tx.send(Box::new(0)).is_err()); + } + + #[test] + fn oneshot_single_thread_recv_chan_close() { + let (tx, rx) = channel::(); + drop(tx); + assert_eq!(rx.recv(), Err(RecvError)); + } + + #[test] + fn oneshot_single_thread_send_then_recv() { + let (tx, rx) = channel::>(); + tx.send(Box::new(10)).unwrap(); + assert!(*rx.recv().unwrap() == 10); + } + + #[test] + fn oneshot_single_thread_try_send_open() { + let (tx, rx) = channel::(); + assert!(tx.send(10).is_ok()); + assert!(rx.recv().unwrap() == 10); + } + + #[test] + fn oneshot_single_thread_try_send_closed() { + let (tx, rx) = channel::(); + drop(rx); + assert!(tx.send(10).is_err()); + } + + #[test] + fn oneshot_single_thread_try_recv_open() { + let (tx, rx) = channel::(); + tx.send(10).unwrap(); + assert!(rx.recv() == Ok(10)); + } + + #[test] + fn oneshot_single_thread_try_recv_closed() { + let (tx, rx) = channel::(); + drop(tx); + assert!(rx.recv().is_err()); + } + + #[test] + fn oneshot_single_thread_peek_data() { + let (tx, rx) = channel::(); + assert_eq!(rx.try_recv(), Err(TryRecvError::Empty)); + tx.send(10).unwrap(); + assert_eq!(rx.try_recv(), Ok(10)); + } + + #[test] + fn oneshot_single_thread_peek_close() { + let (tx, rx) = channel::(); + drop(tx); + assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected)); + assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected)); + } + + #[test] + fn oneshot_single_thread_peek_open() { + let (_tx, rx) = channel::(); + assert_eq!(rx.try_recv(), Err(TryRecvError::Empty)); + } + + #[test] + fn oneshot_multi_task_recv_then_send() { + let (tx, rx) = channel::>(); + let t = thread::spawn(move || { + assert!(*rx.recv().unwrap() == 10); + }); + + tx.send(Box::new(10)).unwrap(); + t.join().unwrap(); + } + + #[test] + fn oneshot_multi_task_recv_then_close() { + let (tx, rx) = channel::>(); + let t = thread::spawn(move || { + drop(tx); + }); + thread::spawn(move || { + assert_eq!(rx.recv(), Err(RecvError)); + }) + .join() + .unwrap(); + t.join().unwrap(); + } + + #[test] + fn oneshot_multi_thread_close_stress() { + let stress_factor = stress_factor(); + let mut ts = Vec::with_capacity(stress_factor); + for _ in 0..stress_factor { + let (tx, rx) = channel::(); + let t = thread::spawn(move || { + drop(rx); + }); + ts.push(t); + drop(tx); + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn oneshot_multi_thread_send_close_stress() { + let stress_factor = stress_factor(); + let mut ts = Vec::with_capacity(2 * stress_factor); + for _ in 0..stress_factor { + let (tx, rx) = channel::(); + let t = thread::spawn(move || { + drop(rx); + }); + ts.push(t); + thread::spawn(move || { + let _ = tx.send(1); + }) + .join() + .unwrap(); + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn oneshot_multi_thread_recv_close_stress() { + let stress_factor = stress_factor(); + let mut ts = Vec::with_capacity(2 * stress_factor); + for _ in 0..stress_factor { + let (tx, rx) = channel::(); + let t = thread::spawn(move || { + thread::spawn(move || { + assert_eq!(rx.recv(), Err(RecvError)); + }) + .join() + .unwrap(); + }); + ts.push(t); + let t2 = thread::spawn(move || { + let t = thread::spawn(move || { + drop(tx); + }); + t.join().unwrap(); + }); + ts.push(t2); + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn oneshot_multi_thread_send_recv_stress() { + let stress_factor = stress_factor(); + let mut ts = Vec::with_capacity(stress_factor); + for _ in 0..stress_factor { + let (tx, rx) = channel::>(); + let t = thread::spawn(move || { + tx.send(Box::new(10)).unwrap(); + }); + ts.push(t); + assert!(*rx.recv().unwrap() == 10); + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn stream_send_recv_stress() { + let stress_factor = stress_factor(); + let mut ts = Vec::with_capacity(2 * stress_factor); + for _ in 0..stress_factor { + let (tx, rx) = channel(); + + if let Some(t) = send(tx, 0) { + ts.push(t); + } + if let Some(t2) = recv(rx, 0) { + ts.push(t2); + } + + fn send(tx: Sender>, i: i32) -> Option> { + if i == 10 { + return None; + } + + Some(thread::spawn(move || { + tx.send(Box::new(i)).unwrap(); + send(tx, i + 1); + })) + } + + fn recv(rx: Receiver>, i: i32) -> Option> { + if i == 10 { + return None; + } + + Some(thread::spawn(move || { + assert!(*rx.recv().unwrap() == i); + recv(rx, i + 1); + })) + } + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn oneshot_single_thread_recv_timeout() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Ok(())); + assert_eq!( + rx.recv_timeout(Duration::from_millis(1)), + Err(RecvTimeoutError::Timeout) + ); + tx.send(()).unwrap(); + assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Ok(())); + } + + #[test] + fn stress_recv_timeout_two_threads() { + let (tx, rx) = channel(); + let stress = stress_factor() + 100; + let timeout = Duration::from_millis(100); + + let t = thread::spawn(move || { + for i in 0..stress { + if i % 2 == 0 { + thread::sleep(timeout * 2); + } + tx.send(1usize).unwrap(); + } + }); + + let mut recv_count = 0; + loop { + match rx.recv_timeout(timeout) { + Ok(n) => { + assert_eq!(n, 1usize); + recv_count += 1; + } + Err(RecvTimeoutError::Timeout) => continue, + Err(RecvTimeoutError::Disconnected) => break, + } + } + + assert_eq!(recv_count, stress); + t.join().unwrap() + } + + #[test] + fn recv_timeout_upgrade() { + let (tx, rx) = channel::<()>(); + let timeout = Duration::from_millis(1); + let _tx_clone = tx.clone(); + + let start = Instant::now(); + assert_eq!(rx.recv_timeout(timeout), Err(RecvTimeoutError::Timeout)); + assert!(Instant::now() >= start + timeout); + } + + #[test] + fn stress_recv_timeout_shared() { + let (tx, rx) = channel(); + let stress = stress_factor() + 100; + + let mut ts = Vec::with_capacity(stress); + for i in 0..stress { + let tx = tx.clone(); + let t = thread::spawn(move || { + thread::sleep(Duration::from_millis(i as u64 * 10)); + tx.send(1usize).unwrap(); + }); + ts.push(t); + } + + drop(tx); + + let mut recv_count = 0; + loop { + match rx.recv_timeout(Duration::from_millis(10)) { + Ok(n) => { + assert_eq!(n, 1usize); + recv_count += 1; + } + Err(RecvTimeoutError::Timeout) => continue, + Err(RecvTimeoutError::Disconnected) => break, + } + } + + assert_eq!(recv_count, stress); + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn recv_a_lot() { + // Regression test that we don't run out of stack in scheduler context + let (tx, rx) = channel(); + for _ in 0..10000 { + tx.send(()).unwrap(); + } + for _ in 0..10000 { + rx.recv().unwrap(); + } + } + + #[test] + fn shared_recv_timeout() { + let (tx, rx) = channel(); + let total = 5; + let mut ts = Vec::with_capacity(total); + for _ in 0..total { + let tx = tx.clone(); + let t = thread::spawn(move || { + tx.send(()).unwrap(); + }); + ts.push(t); + } + + for _ in 0..total { + rx.recv().unwrap(); + } + + assert_eq!( + rx.recv_timeout(Duration::from_millis(1)), + Err(RecvTimeoutError::Timeout) + ); + tx.send(()).unwrap(); + assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Ok(())); + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn shared_chan_stress() { + let (tx, rx) = channel(); + let total = stress_factor() + 100; + let mut ts = Vec::with_capacity(total); + for _ in 0..total { + let tx = tx.clone(); + let t = thread::spawn(move || { + tx.send(()).unwrap(); + }); + ts.push(t); + } + + for _ in 0..total { + rx.recv().unwrap(); + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn test_nested_recv_iter() { + let (tx, rx) = channel::(); + let (total_tx, total_rx) = channel::(); + + let t = thread::spawn(move || { + let mut acc = 0; + for x in rx.iter() { + acc += x; + } + total_tx.send(acc).unwrap(); + }); + + tx.send(3).unwrap(); + tx.send(1).unwrap(); + tx.send(2).unwrap(); + drop(tx); + assert_eq!(total_rx.recv().unwrap(), 6); + t.join().unwrap(); + } + + #[test] + fn test_recv_iter_break() { + let (tx, rx) = channel::(); + let (count_tx, count_rx) = channel(); + + let t = thread::spawn(move || { + let mut count = 0; + for x in rx.iter() { + if count >= 3 { + break; + } else { + count += x; + } + } + count_tx.send(count).unwrap(); + }); + + tx.send(2).unwrap(); + tx.send(2).unwrap(); + tx.send(2).unwrap(); + let _ = tx.send(2); + drop(tx); + assert_eq!(count_rx.recv().unwrap(), 4); + t.join().unwrap(); + } + + #[test] + fn test_recv_try_iter() { + let (request_tx, request_rx) = channel(); + let (response_tx, response_rx) = channel(); + + // Request `x`s until we have `6`. + let t = thread::spawn(move || { + let mut count = 0; + loop { + for x in response_rx.try_iter() { + count += x; + if count == 6 { + return count; + } + } + request_tx.send(()).unwrap(); + } + }); + + for _ in request_rx.iter() { + if response_tx.send(2).is_err() { + break; + } + } + + assert_eq!(t.join().unwrap(), 6); + } + + #[test] + fn test_recv_into_iter_owned() { + let mut iter = { + let (tx, rx) = channel::(); + tx.send(1).unwrap(); + tx.send(2).unwrap(); + + rx.into_iter() + }; + assert_eq!(iter.next().unwrap(), 1); + assert_eq!(iter.next().unwrap(), 2); + assert_eq!(iter.next().is_none(), true); + } + + #[test] + fn test_recv_into_iter_borrowed() { + let (tx, rx) = channel::(); + tx.send(1).unwrap(); + tx.send(2).unwrap(); + drop(tx); + let mut iter = (&rx).into_iter(); + assert_eq!(iter.next().unwrap(), 1); + assert_eq!(iter.next().unwrap(), 2); + assert_eq!(iter.next().is_none(), true); + } + + #[test] + fn try_recv_states() { + let (tx1, rx1) = channel::(); + let (tx2, rx2) = channel::<()>(); + let (tx3, rx3) = channel::<()>(); + let t = thread::spawn(move || { + rx2.recv().unwrap(); + tx1.send(1).unwrap(); + tx3.send(()).unwrap(); + rx2.recv().unwrap(); + drop(tx1); + tx3.send(()).unwrap(); + }); + + assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); + tx2.send(()).unwrap(); + rx3.recv().unwrap(); + assert_eq!(rx1.try_recv(), Ok(1)); + assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); + tx2.send(()).unwrap(); + rx3.recv().unwrap(); + assert_eq!(rx1.try_recv(), Err(TryRecvError::Disconnected)); + t.join().unwrap(); + } + + // This bug used to end up in a livelock inside of the Receiver destructor + // because the internal state of the Shared packet was corrupted + #[test] + fn destroy_upgraded_shared_port_when_sender_still_active() { + let (tx, rx) = channel(); + let (tx2, rx2) = channel(); + let t = thread::spawn(move || { + rx.recv().unwrap(); // wait on a oneshot + drop(rx); // destroy a shared + tx2.send(()).unwrap(); + }); + // make sure the other thread has gone to sleep + for _ in 0..5000 { + thread::yield_now(); + } + + // upgrade to a shared chan and send a message + let tx2 = tx.clone(); + drop(tx); + tx2.send(()).unwrap(); + + // wait for the child thread to exit before we exit + rx2.recv().unwrap(); + t.join().unwrap(); + } + + #[test] + fn issue_32114() { + let (tx, _) = channel(); + let _ = tx.send(123); + assert_eq!(tx.send(123), Err(SendError(123))); + } +} + +// Source: https://github.com/rust-lang/rust/blob/master/src/libstd/sync/mpsc/mod.rs +mod sync_channel_tests { + use super::*; + + use std::env; + use std::thread; + use std::time::Duration; + + pub fn stress_factor() -> usize { + match env::var("RUST_TEST_STRESS") { + Ok(val) => val.parse().unwrap(), + Err(..) => 1, + } + } + + #[test] + fn smoke() { + let (tx, rx) = sync_channel::(1); + tx.send(1).unwrap(); + assert_eq!(rx.recv().unwrap(), 1); + } + + #[test] + fn drop_full() { + let (tx, _rx) = sync_channel::>(1); + tx.send(Box::new(1)).unwrap(); + } + + #[test] + fn smoke_shared() { + let (tx, rx) = sync_channel::(1); + tx.send(1).unwrap(); + assert_eq!(rx.recv().unwrap(), 1); + let tx = tx.clone(); + tx.send(1).unwrap(); + assert_eq!(rx.recv().unwrap(), 1); + } + + #[test] + fn recv_timeout() { + let (tx, rx) = sync_channel::(1); + assert_eq!( + rx.recv_timeout(Duration::from_millis(1)), + Err(RecvTimeoutError::Timeout) + ); + tx.send(1).unwrap(); + assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Ok(1)); + } + + #[test] + fn smoke_threads() { + let (tx, rx) = sync_channel::(0); + let t = thread::spawn(move || { + tx.send(1).unwrap(); + }); + assert_eq!(rx.recv().unwrap(), 1); + t.join().unwrap(); + } + + #[test] + fn smoke_port_gone() { + let (tx, rx) = sync_channel::(0); + drop(rx); + assert!(tx.send(1).is_err()); + } + + #[test] + fn smoke_shared_port_gone2() { + let (tx, rx) = sync_channel::(0); + drop(rx); + let tx2 = tx.clone(); + drop(tx); + assert!(tx2.send(1).is_err()); + } + + #[test] + fn port_gone_concurrent() { + let (tx, rx) = sync_channel::(0); + let t = thread::spawn(move || { + rx.recv().unwrap(); + }); + while tx.send(1).is_ok() {} + t.join().unwrap(); + } + + #[test] + fn port_gone_concurrent_shared() { + let (tx, rx) = sync_channel::(0); + let tx2 = tx.clone(); + let t = thread::spawn(move || { + rx.recv().unwrap(); + }); + while tx.send(1).is_ok() && tx2.send(1).is_ok() {} + t.join().unwrap(); + } + + #[test] + fn smoke_chan_gone() { + let (tx, rx) = sync_channel::(0); + drop(tx); + assert!(rx.recv().is_err()); + } + + #[test] + fn smoke_chan_gone_shared() { + let (tx, rx) = sync_channel::<()>(0); + let tx2 = tx.clone(); + drop(tx); + drop(tx2); + assert!(rx.recv().is_err()); + } + + #[test] + fn chan_gone_concurrent() { + let (tx, rx) = sync_channel::(0); + let t = thread::spawn(move || { + tx.send(1).unwrap(); + tx.send(1).unwrap(); + }); + while rx.recv().is_ok() {} + t.join().unwrap(); + } + + #[test] + fn stress() { + let (tx, rx) = sync_channel::(0); + let t = thread::spawn(move || { + for _ in 0..10000 { + tx.send(1).unwrap(); + } + }); + for _ in 0..10000 { + assert_eq!(rx.recv().unwrap(), 1); + } + t.join().unwrap(); + } + + #[test] + fn stress_recv_timeout_two_threads() { + let (tx, rx) = sync_channel::(0); + + let t = thread::spawn(move || { + for _ in 0..10000 { + tx.send(1).unwrap(); + } + }); + + let mut recv_count = 0; + loop { + match rx.recv_timeout(Duration::from_millis(1)) { + Ok(v) => { + assert_eq!(v, 1); + recv_count += 1; + } + Err(RecvTimeoutError::Timeout) => continue, + Err(RecvTimeoutError::Disconnected) => break, + } + } + + assert_eq!(recv_count, 10000); + t.join().unwrap(); + } + + #[test] + fn stress_recv_timeout_shared() { + const AMT: u32 = 1000; + const NTHREADS: u32 = 8; + let (tx, rx) = sync_channel::(0); + let (dtx, drx) = sync_channel::<()>(0); + + let t = thread::spawn(move || { + let mut recv_count = 0; + loop { + match rx.recv_timeout(Duration::from_millis(10)) { + Ok(v) => { + assert_eq!(v, 1); + recv_count += 1; + } + Err(RecvTimeoutError::Timeout) => continue, + Err(RecvTimeoutError::Disconnected) => break, + } + } + + assert_eq!(recv_count, AMT * NTHREADS); + assert!(rx.try_recv().is_err()); + + dtx.send(()).unwrap(); + }); + + let mut ts = Vec::with_capacity(NTHREADS as usize); + for _ in 0..NTHREADS { + let tx = tx.clone(); + let t = thread::spawn(move || { + for _ in 0..AMT { + tx.send(1).unwrap(); + } + }); + ts.push(t); + } + + drop(tx); + + drx.recv().unwrap(); + for t in ts { + t.join().unwrap(); + } + t.join().unwrap(); + } + + #[test] + fn stress_shared() { + const AMT: u32 = 1000; + const NTHREADS: u32 = 8; + let (tx, rx) = sync_channel::(0); + let (dtx, drx) = sync_channel::<()>(0); + + let t = thread::spawn(move || { + for _ in 0..AMT * NTHREADS { + assert_eq!(rx.recv().unwrap(), 1); + } + match rx.try_recv() { + Ok(..) => panic!(), + _ => {} + } + dtx.send(()).unwrap(); + }); + + let mut ts = Vec::with_capacity(NTHREADS as usize); + for _ in 0..NTHREADS { + let tx = tx.clone(); + let t = thread::spawn(move || { + for _ in 0..AMT { + tx.send(1).unwrap(); + } + }); + ts.push(t); + } + drop(tx); + drx.recv().unwrap(); + for t in ts { + t.join().unwrap(); + } + t.join().unwrap(); + } + + #[test] + fn oneshot_single_thread_close_port_first() { + // Simple test of closing without sending + let (_tx, rx) = sync_channel::(0); + drop(rx); + } + + #[test] + fn oneshot_single_thread_close_chan_first() { + // Simple test of closing without sending + let (tx, _rx) = sync_channel::(0); + drop(tx); + } + + #[test] + fn oneshot_single_thread_send_port_close() { + // Testing that the sender cleans up the payload if receiver is closed + let (tx, rx) = sync_channel::>(0); + drop(rx); + assert!(tx.send(Box::new(0)).is_err()); + } + + #[test] + fn oneshot_single_thread_recv_chan_close() { + let (tx, rx) = sync_channel::(0); + drop(tx); + assert_eq!(rx.recv(), Err(RecvError)); + } + + #[test] + fn oneshot_single_thread_send_then_recv() { + let (tx, rx) = sync_channel::>(1); + tx.send(Box::new(10)).unwrap(); + assert!(*rx.recv().unwrap() == 10); + } + + #[test] + fn oneshot_single_thread_try_send_open() { + let (tx, rx) = sync_channel::(1); + assert_eq!(tx.try_send(10), Ok(())); + assert!(rx.recv().unwrap() == 10); + } + + #[test] + fn oneshot_single_thread_try_send_closed() { + let (tx, rx) = sync_channel::(0); + drop(rx); + assert_eq!(tx.try_send(10), Err(TrySendError::Disconnected(10))); + } + + #[test] + fn oneshot_single_thread_try_send_closed2() { + let (tx, _rx) = sync_channel::(0); + assert_eq!(tx.try_send(10), Err(TrySendError::Full(10))); + } + + #[test] + fn oneshot_single_thread_try_recv_open() { + let (tx, rx) = sync_channel::(1); + tx.send(10).unwrap(); + assert!(rx.recv() == Ok(10)); + } + + #[test] + fn oneshot_single_thread_try_recv_closed() { + let (tx, rx) = sync_channel::(0); + drop(tx); + assert!(rx.recv().is_err()); + } + + #[test] + fn oneshot_single_thread_try_recv_closed_with_data() { + let (tx, rx) = sync_channel::(1); + tx.send(10).unwrap(); + drop(tx); + assert_eq!(rx.try_recv(), Ok(10)); + assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected)); + } + + #[test] + fn oneshot_single_thread_peek_data() { + let (tx, rx) = sync_channel::(1); + assert_eq!(rx.try_recv(), Err(TryRecvError::Empty)); + tx.send(10).unwrap(); + assert_eq!(rx.try_recv(), Ok(10)); + } + + #[test] + fn oneshot_single_thread_peek_close() { + let (tx, rx) = sync_channel::(0); + drop(tx); + assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected)); + assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected)); + } + + #[test] + fn oneshot_single_thread_peek_open() { + let (_tx, rx) = sync_channel::(0); + assert_eq!(rx.try_recv(), Err(TryRecvError::Empty)); + } + + #[test] + fn oneshot_multi_task_recv_then_send() { + let (tx, rx) = sync_channel::>(0); + let t = thread::spawn(move || { + assert!(*rx.recv().unwrap() == 10); + }); + + tx.send(Box::new(10)).unwrap(); + t.join().unwrap(); + } + + #[test] + fn oneshot_multi_task_recv_then_close() { + let (tx, rx) = sync_channel::>(0); + let t = thread::spawn(move || { + drop(tx); + }); + thread::spawn(move || { + assert_eq!(rx.recv(), Err(RecvError)); + }) + .join() + .unwrap(); + t.join().unwrap(); + } + + #[test] + fn oneshot_multi_thread_close_stress() { + let stress_factor = stress_factor(); + let mut ts = Vec::with_capacity(stress_factor); + for _ in 0..stress_factor { + let (tx, rx) = sync_channel::(0); + let t = thread::spawn(move || { + drop(rx); + }); + ts.push(t); + drop(tx); + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn oneshot_multi_thread_send_close_stress() { + let stress_factor = stress_factor(); + let mut ts = Vec::with_capacity(stress_factor); + for _ in 0..stress_factor { + let (tx, rx) = sync_channel::(0); + let t = thread::spawn(move || { + drop(rx); + }); + ts.push(t); + thread::spawn(move || { + let _ = tx.send(1); + }) + .join() + .unwrap(); + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn oneshot_multi_thread_recv_close_stress() { + let stress_factor = stress_factor(); + let mut ts = Vec::with_capacity(2 * stress_factor); + for _ in 0..stress_factor { + let (tx, rx) = sync_channel::(0); + let t = thread::spawn(move || { + thread::spawn(move || { + assert_eq!(rx.recv(), Err(RecvError)); + }) + .join() + .unwrap(); + }); + ts.push(t); + let t2 = thread::spawn(move || { + thread::spawn(move || { + drop(tx); + }); + }); + ts.push(t2); + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn oneshot_multi_thread_send_recv_stress() { + let stress_factor = stress_factor(); + let mut ts = Vec::with_capacity(stress_factor); + for _ in 0..stress_factor { + let (tx, rx) = sync_channel::>(0); + let t = thread::spawn(move || { + tx.send(Box::new(10)).unwrap(); + }); + ts.push(t); + assert!(*rx.recv().unwrap() == 10); + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn stream_send_recv_stress() { + let stress_factor = stress_factor(); + let mut ts = Vec::with_capacity(2 * stress_factor); + for _ in 0..stress_factor { + let (tx, rx) = sync_channel::>(0); + + if let Some(t) = send(tx, 0) { + ts.push(t); + } + if let Some(t) = recv(rx, 0) { + ts.push(t); + } + + fn send(tx: SyncSender>, i: i32) -> Option> { + if i == 10 { + return None; + } + + Some(thread::spawn(move || { + tx.send(Box::new(i)).unwrap(); + send(tx, i + 1); + })) + } + + fn recv(rx: Receiver>, i: i32) -> Option> { + if i == 10 { + return None; + } + + Some(thread::spawn(move || { + assert!(*rx.recv().unwrap() == i); + recv(rx, i + 1); + })) + } + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn recv_a_lot() { + // Regression test that we don't run out of stack in scheduler context + let (tx, rx) = sync_channel(10000); + for _ in 0..10000 { + tx.send(()).unwrap(); + } + for _ in 0..10000 { + rx.recv().unwrap(); + } + } + + #[test] + fn shared_chan_stress() { + let (tx, rx) = sync_channel(0); + let total = stress_factor() + 100; + let mut ts = Vec::with_capacity(total); + for _ in 0..total { + let tx = tx.clone(); + let t = thread::spawn(move || { + tx.send(()).unwrap(); + }); + ts.push(t); + } + + for _ in 0..total { + rx.recv().unwrap(); + } + for t in ts { + t.join().unwrap(); + } + } + + #[test] + fn test_nested_recv_iter() { + let (tx, rx) = sync_channel::(0); + let (total_tx, total_rx) = sync_channel::(0); + + let t = thread::spawn(move || { + let mut acc = 0; + for x in rx.iter() { + acc += x; + } + total_tx.send(acc).unwrap(); + }); + + tx.send(3).unwrap(); + tx.send(1).unwrap(); + tx.send(2).unwrap(); + drop(tx); + assert_eq!(total_rx.recv().unwrap(), 6); + t.join().unwrap(); + } + + #[test] + fn test_recv_iter_break() { + let (tx, rx) = sync_channel::(0); + let (count_tx, count_rx) = sync_channel(0); + + let t = thread::spawn(move || { + let mut count = 0; + for x in rx.iter() { + if count >= 3 { + break; + } else { + count += x; + } + } + count_tx.send(count).unwrap(); + }); + + tx.send(2).unwrap(); + tx.send(2).unwrap(); + tx.send(2).unwrap(); + let _ = tx.try_send(2); + drop(tx); + assert_eq!(count_rx.recv().unwrap(), 4); + t.join().unwrap(); + } + + #[test] + fn try_recv_states() { + let (tx1, rx1) = sync_channel::(1); + let (tx2, rx2) = sync_channel::<()>(1); + let (tx3, rx3) = sync_channel::<()>(1); + let t = thread::spawn(move || { + rx2.recv().unwrap(); + tx1.send(1).unwrap(); + tx3.send(()).unwrap(); + rx2.recv().unwrap(); + drop(tx1); + tx3.send(()).unwrap(); + }); + + assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); + tx2.send(()).unwrap(); + rx3.recv().unwrap(); + assert_eq!(rx1.try_recv(), Ok(1)); + assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); + tx2.send(()).unwrap(); + rx3.recv().unwrap(); + assert_eq!(rx1.try_recv(), Err(TryRecvError::Disconnected)); + t.join().unwrap(); + } + + // This bug used to end up in a livelock inside of the Receiver destructor + // because the internal state of the Shared packet was corrupted + #[test] + fn destroy_upgraded_shared_port_when_sender_still_active() { + let (tx, rx) = sync_channel::<()>(0); + let (tx2, rx2) = sync_channel::<()>(0); + let t = thread::spawn(move || { + rx.recv().unwrap(); // wait on a oneshot + drop(rx); // destroy a shared + tx2.send(()).unwrap(); + }); + // make sure the other thread has gone to sleep + for _ in 0..5000 { + thread::yield_now(); + } + + // upgrade to a shared chan and send a message + let tx2 = tx.clone(); + drop(tx); + tx2.send(()).unwrap(); + + // wait for the child thread to exit before we exit + rx2.recv().unwrap(); + t.join().unwrap(); + } + + #[test] + fn send1() { + let (tx, rx) = sync_channel::(0); + let t = thread::spawn(move || { + rx.recv().unwrap(); + }); + assert_eq!(tx.send(1), Ok(())); + t.join().unwrap(); + } + + #[test] + fn send2() { + let (tx, rx) = sync_channel::(0); + let t = thread::spawn(move || { + drop(rx); + }); + assert!(tx.send(1).is_err()); + t.join().unwrap(); + } + + #[test] + fn send3() { + let (tx, rx) = sync_channel::(1); + assert_eq!(tx.send(1), Ok(())); + let t = thread::spawn(move || { + drop(rx); + }); + assert!(tx.send(1).is_err()); + t.join().unwrap(); + } + + #[test] + fn send4() { + let (tx, rx) = sync_channel::(0); + let tx2 = tx.clone(); + let (done, donerx) = channel(); + let done2 = done.clone(); + let t = thread::spawn(move || { + assert!(tx.send(1).is_err()); + done.send(()).unwrap(); + }); + let t2 = thread::spawn(move || { + assert!(tx2.send(2).is_err()); + done2.send(()).unwrap(); + }); + drop(rx); + donerx.recv().unwrap(); + donerx.recv().unwrap(); + t.join().unwrap(); + t2.join().unwrap(); + } + + #[test] + fn try_send1() { + let (tx, _rx) = sync_channel::(0); + assert_eq!(tx.try_send(1), Err(TrySendError::Full(1))); + } + + #[test] + fn try_send2() { + let (tx, _rx) = sync_channel::(1); + assert_eq!(tx.try_send(1), Ok(())); + assert_eq!(tx.try_send(1), Err(TrySendError::Full(1))); + } + + #[test] + fn try_send3() { + let (tx, rx) = sync_channel::(1); + assert_eq!(tx.try_send(1), Ok(())); + drop(rx); + assert_eq!(tx.try_send(1), Err(TrySendError::Disconnected(1))); + } + + #[test] + fn issue_15761() { + fn repro() { + let (tx1, rx1) = sync_channel::<()>(3); + let (tx2, rx2) = sync_channel::<()>(3); + + let _t = thread::spawn(move || { + rx1.recv().unwrap(); + tx2.try_send(()).unwrap(); + }); + + tx1.try_send(()).unwrap(); + rx2.recv().unwrap(); + } + + for _ in 0..100 { + repro() + } + } +} + +// Source: https://github.com/rust-lang/rust/blob/master/src/libstd/sync/mpsc/select.rs +mod select_tests { + use super::*; + + use std::thread; + + #[test] + fn smoke() { + let (tx1, rx1) = channel::(); + let (tx2, rx2) = channel::(); + tx1.send(1).unwrap(); + select! { + foo = rx1.recv() => { assert_eq!(foo.unwrap(), 1); }, + _bar = rx2.recv() => { panic!() } + } + tx2.send(2).unwrap(); + select! { + _foo = rx1.recv() => { panic!() }, + bar = rx2.recv() => { assert_eq!(bar.unwrap(), 2) } + } + drop(tx1); + select! { + foo = rx1.recv() => { assert!(foo.is_err()); }, + _bar = rx2.recv() => { panic!() } + } + drop(tx2); + select! { + bar = rx2.recv() => { assert!(bar.is_err()); } + } + } + + #[test] + fn smoke2() { + let (_tx1, rx1) = channel::(); + let (_tx2, rx2) = channel::(); + let (_tx3, rx3) = channel::(); + let (_tx4, rx4) = channel::(); + let (tx5, rx5) = channel::(); + tx5.send(4).unwrap(); + select! { + _foo = rx1.recv() => { panic!("1") }, + _foo = rx2.recv() => { panic!("2") }, + _foo = rx3.recv() => { panic!("3") }, + _foo = rx4.recv() => { panic!("4") }, + foo = rx5.recv() => { assert_eq!(foo.unwrap(), 4); } + } + } + + #[test] + fn closed() { + let (_tx1, rx1) = channel::(); + let (tx2, rx2) = channel::(); + drop(tx2); + + select! { + _a1 = rx1.recv() => { panic!() }, + a2 = rx2.recv() => { assert!(a2.is_err()); } + } + } + + #[test] + fn unblocks() { + let (tx1, rx1) = channel::(); + let (_tx2, rx2) = channel::(); + let (tx3, rx3) = channel::(); + + let t = thread::spawn(move || { + for _ in 0..20 { + thread::yield_now(); + } + tx1.send(1).unwrap(); + rx3.recv().unwrap(); + for _ in 0..20 { + thread::yield_now(); + } + }); + + select! { + a = rx1.recv() => { assert_eq!(a.unwrap(), 1); }, + _b = rx2.recv() => { panic!() } + } + tx3.send(1).unwrap(); + select! { + a = rx1.recv() => { assert!(a.is_err()) }, + _b = rx2.recv() => { panic!() } + } + t.join().unwrap(); + } + + #[test] + fn both_ready() { + let (tx1, rx1) = channel::(); + let (tx2, rx2) = channel::(); + let (tx3, rx3) = channel::<()>(); + + let t = thread::spawn(move || { + for _ in 0..20 { + thread::yield_now(); + } + tx1.send(1).unwrap(); + tx2.send(2).unwrap(); + rx3.recv().unwrap(); + }); + + select! { + a = rx1.recv() => { assert_eq!(a.unwrap(), 1); }, + a = rx2.recv() => { assert_eq!(a.unwrap(), 2); } + } + select! { + a = rx1.recv() => { assert_eq!(a.unwrap(), 1); }, + a = rx2.recv() => { assert_eq!(a.unwrap(), 2); } + } + assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); + assert_eq!(rx2.try_recv(), Err(TryRecvError::Empty)); + tx3.send(()).unwrap(); + t.join().unwrap(); + } + + #[test] + fn stress() { + const AMT: i32 = 10000; + let (tx1, rx1) = channel::(); + let (tx2, rx2) = channel::(); + let (tx3, rx3) = channel::<()>(); + + let t = thread::spawn(move || { + for i in 0..AMT { + if i % 2 == 0 { + tx1.send(i).unwrap(); + } else { + tx2.send(i).unwrap(); + } + rx3.recv().unwrap(); + } + }); + + for i in 0..AMT { + select! { + i1 = rx1.recv() => { assert!(i % 2 == 0 && i == i1.unwrap()); }, + i2 = rx2.recv() => { assert!(i % 2 == 1 && i == i2.unwrap()); } + } + tx3.send(()).unwrap(); + } + t.join().unwrap(); + } + + #[allow(unused_must_use)] + #[test] + fn cloning() { + let (tx1, rx1) = channel::(); + let (_tx2, rx2) = channel::(); + let (tx3, rx3) = channel::<()>(); + + let t = thread::spawn(move || { + rx3.recv().unwrap(); + tx1.clone(); + assert_eq!(rx3.try_recv(), Err(TryRecvError::Empty)); + tx1.send(2).unwrap(); + rx3.recv().unwrap(); + }); + + tx3.send(()).unwrap(); + select! { + _i1 = rx1.recv() => {}, + _i2 = rx2.recv() => panic!() + } + tx3.send(()).unwrap(); + t.join().unwrap(); + } + + #[allow(unused_must_use)] + #[test] + fn cloning2() { + let (tx1, rx1) = channel::(); + let (_tx2, rx2) = channel::(); + let (tx3, rx3) = channel::<()>(); + + let t = thread::spawn(move || { + rx3.recv().unwrap(); + tx1.clone(); + assert_eq!(rx3.try_recv(), Err(TryRecvError::Empty)); + tx1.send(2).unwrap(); + rx3.recv().unwrap(); + }); + + tx3.send(()).unwrap(); + select! { + _i1 = rx1.recv() => {}, + _i2 = rx2.recv() => panic!() + } + tx3.send(()).unwrap(); + t.join().unwrap(); + } + + #[test] + fn cloning3() { + let (tx1, rx1) = channel::<()>(); + let (tx2, rx2) = channel::<()>(); + let (tx3, rx3) = channel::<()>(); + let t = thread::spawn(move || { + select! { + _ = rx1.recv() => panic!(), + _ = rx2.recv() => {} + } + tx3.send(()).unwrap(); + }); + + for _ in 0..1000 { + thread::yield_now(); + } + drop(tx1.clone()); + tx2.send(()).unwrap(); + rx3.recv().unwrap(); + t.join().unwrap(); + } + + #[test] + fn preflight1() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + select! { + _n = rx.recv() => {} + } + } + + #[test] + fn preflight2() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + tx.send(()).unwrap(); + select! { + _n = rx.recv() => {} + } + } + + #[test] + fn preflight3() { + let (tx, rx) = channel(); + drop(tx.clone()); + tx.send(()).unwrap(); + select! { + _n = rx.recv() => {} + } + } + + #[test] + fn preflight4() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + select! { + _ = rx.recv() => {} + } + } + + #[test] + fn preflight5() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + tx.send(()).unwrap(); + select! { + _ = rx.recv() => {} + } + } + + #[test] + fn preflight6() { + let (tx, rx) = channel(); + drop(tx.clone()); + tx.send(()).unwrap(); + select! { + _ = rx.recv() => {} + } + } + + #[test] + fn preflight7() { + let (tx, rx) = channel::<()>(); + drop(tx); + select! { + _ = rx.recv() => {} + } + } + + #[test] + fn preflight8() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + drop(tx); + rx.recv().unwrap(); + select! { + _ = rx.recv() => {} + } + } + + #[test] + fn preflight9() { + let (tx, rx) = channel(); + drop(tx.clone()); + tx.send(()).unwrap(); + drop(tx); + rx.recv().unwrap(); + select! { + _ = rx.recv() => {} + } + } + + #[test] + fn oneshot_data_waiting() { + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + let t = thread::spawn(move || { + select! { + _n = rx1.recv() => {} + } + tx2.send(()).unwrap(); + }); + + for _ in 0..100 { + thread::yield_now() + } + tx1.send(()).unwrap(); + rx2.recv().unwrap(); + t.join().unwrap(); + } + + #[test] + fn stream_data_waiting() { + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + tx1.send(()).unwrap(); + tx1.send(()).unwrap(); + rx1.recv().unwrap(); + rx1.recv().unwrap(); + let t = thread::spawn(move || { + select! { + _n = rx1.recv() => {} + } + tx2.send(()).unwrap(); + }); + + for _ in 0..100 { + thread::yield_now() + } + tx1.send(()).unwrap(); + rx2.recv().unwrap(); + t.join().unwrap(); + } + + #[test] + fn shared_data_waiting() { + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + drop(tx1.clone()); + tx1.send(()).unwrap(); + rx1.recv().unwrap(); + let t = thread::spawn(move || { + select! { + _n = rx1.recv() => {} + } + tx2.send(()).unwrap(); + }); + + for _ in 0..100 { + thread::yield_now() + } + tx1.send(()).unwrap(); + rx2.recv().unwrap(); + t.join().unwrap(); + } + + #[test] + fn sync1() { + let (tx, rx) = sync_channel::(1); + tx.send(1).unwrap(); + select! { + n = rx.recv() => { assert_eq!(n.unwrap(), 1); } + } + } + + #[test] + fn sync2() { + let (tx, rx) = sync_channel::(0); + let t = thread::spawn(move || { + for _ in 0..100 { + thread::yield_now() + } + tx.send(1).unwrap(); + }); + select! { + n = rx.recv() => { assert_eq!(n.unwrap(), 1); } + } + t.join().unwrap(); + } + + #[test] + fn sync3() { + let (tx1, rx1) = sync_channel::(0); + let (tx2, rx2): (Sender, Receiver) = channel(); + let t = thread::spawn(move || { + tx1.send(1).unwrap(); + }); + let t2 = thread::spawn(move || { + tx2.send(2).unwrap(); + }); + select! { + n = rx1.recv() => { + let n = n.unwrap(); + assert_eq!(n, 1); + assert_eq!(rx2.recv().unwrap(), 2); + }, + n = rx2.recv() => { + let n = n.unwrap(); + assert_eq!(n, 2); + assert_eq!(rx1.recv().unwrap(), 1); + } + } + t.join().unwrap(); + t2.join().unwrap(); + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/never.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/never.rs new file mode 100644 index 0000000..35b6f74 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/never.rs @@ -0,0 +1,99 @@ +//! Tests for the never channel flavor. + +#[macro_use] +extern crate crossbeam_channel; +extern crate rand; + +use std::thread; +use std::time::{Duration, Instant}; + +use crossbeam_channel::{never, tick, unbounded}; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +fn smoke() { + select! { + recv(never::()) -> _ => panic!(), + default => {} + } +} + +#[test] +fn optional() { + let (s, r) = unbounded::(); + s.send(1).unwrap(); + s.send(2).unwrap(); + + let mut r = Some(&r); + select! { + recv(r.unwrap_or(&never())) -> _ => {} + default => panic!(), + } + + r = None; + select! { + recv(r.unwrap_or(&never())) -> _ => panic!(), + default => {} + } +} + +#[test] +fn tick_n() { + let mut r = tick(ms(100)); + let mut step = 0; + + loop { + select! { + recv(r) -> _ => step += 1, + default(ms(500)) => break, + } + + if step == 10 { + r = never(); + } + } + + assert_eq!(step, 10); +} + +#[test] +fn capacity() { + let r = never::(); + assert_eq!(r.capacity(), Some(0)); +} + +#[test] +fn len_empty_full() { + let r = never::(); + assert_eq!(r.len(), 0); + assert_eq!(r.is_empty(), true); + assert_eq!(r.is_full(), true); +} + +#[test] +fn try_recv() { + let r = never::(); + assert!(r.try_recv().is_err()); + + thread::sleep(ms(100)); + assert!(r.try_recv().is_err()); +} + +#[test] +fn recv_timeout() { + let start = Instant::now(); + let r = never::(); + + assert!(r.recv_timeout(ms(100)).is_err()); + let now = Instant::now(); + assert!(now - start >= ms(100)); + assert!(now - start <= ms(150)); + + assert!(r.recv_timeout(ms(100)).is_err()); + let now = Instant::now(); + assert!(now - start >= ms(200)); + assert!(now - start <= ms(250)); +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/ready.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/ready.rs new file mode 100644 index 0000000..f5efd08 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/ready.rs @@ -0,0 +1,837 @@ +//! Tests for channel readiness using the `Select` struct. + +extern crate crossbeam_channel; +extern crate crossbeam_utils; + +use std::any::Any; +use std::cell::Cell; +use std::thread; +use std::time::{Duration, Instant}; + +use crossbeam_channel::{after, bounded, tick, unbounded}; +use crossbeam_channel::{Receiver, Select, TryRecvError, TrySendError}; +use crossbeam_utils::thread::scope; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +fn smoke1() { + let (s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + s1.send(1).unwrap(); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + assert_eq!(sel.ready(), 0); + assert_eq!(r1.try_recv(), Ok(1)); + + s2.send(2).unwrap(); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + assert_eq!(sel.ready(), 1); + assert_eq!(r2.try_recv(), Ok(2)); +} + +#[test] +fn smoke2() { + let (_s1, r1) = unbounded::(); + let (_s2, r2) = unbounded::(); + let (_s3, r3) = unbounded::(); + let (_s4, r4) = unbounded::(); + let (s5, r5) = unbounded::(); + + s5.send(5).unwrap(); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + sel.recv(&r3); + sel.recv(&r4); + sel.recv(&r5); + assert_eq!(sel.ready(), 4); + assert_eq!(r5.try_recv(), Ok(5)); +} + +#[test] +fn disconnected() { + let (s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + scope(|scope| { + scope.spawn(|_| { + drop(s1); + thread::sleep(ms(500)); + s2.send(5).unwrap(); + }); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + match sel.ready_timeout(ms(1000)) { + Ok(0) => assert_eq!(r1.try_recv(), Err(TryRecvError::Disconnected)), + _ => panic!(), + } + + r2.recv().unwrap(); + }) + .unwrap(); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + match sel.ready_timeout(ms(1000)) { + Ok(0) => assert_eq!(r1.try_recv(), Err(TryRecvError::Disconnected)), + _ => panic!(), + } + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + drop(s2); + }); + + let mut sel = Select::new(); + sel.recv(&r2); + match sel.ready_timeout(ms(1000)) { + Ok(0) => assert_eq!(r2.try_recv(), Err(TryRecvError::Disconnected)), + _ => panic!(), + } + }) + .unwrap(); +} + +#[test] +fn default() { + let (s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + assert!(sel.try_ready().is_err()); + + drop(s1); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + match sel.try_ready() { + Ok(0) => assert!(r1.try_recv().is_err()), + _ => panic!(), + } + + s2.send(2).unwrap(); + + let mut sel = Select::new(); + sel.recv(&r2); + match sel.try_ready() { + Ok(0) => assert_eq!(r2.try_recv(), Ok(2)), + _ => panic!(), + } + + let mut sel = Select::new(); + sel.recv(&r2); + assert!(sel.try_ready().is_err()); + + let mut sel = Select::new(); + assert!(sel.try_ready().is_err()); +} + +#[test] +fn timeout() { + let (_s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(1500)); + s2.send(2).unwrap(); + }); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + assert!(sel.ready_timeout(ms(1000)).is_err()); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + match sel.ready_timeout(ms(1000)) { + Ok(1) => assert_eq!(r2.try_recv(), Ok(2)), + _ => panic!(), + } + }) + .unwrap(); + + scope(|scope| { + let (s, r) = unbounded::(); + + scope.spawn(move |_| { + thread::sleep(ms(500)); + drop(s); + }); + + let mut sel = Select::new(); + assert!(sel.ready_timeout(ms(1000)).is_err()); + + let mut sel = Select::new(); + sel.recv(&r); + match sel.try_ready() { + Ok(0) => assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)), + _ => panic!(), + } + }) + .unwrap(); +} + +#[test] +fn default_when_disconnected() { + let (_, r) = unbounded::(); + + let mut sel = Select::new(); + sel.recv(&r); + match sel.try_ready() { + Ok(0) => assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)), + _ => panic!(), + } + + let (_, r) = unbounded::(); + + let mut sel = Select::new(); + sel.recv(&r); + match sel.ready_timeout(ms(1000)) { + Ok(0) => assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)), + _ => panic!(), + } + + let (s, _) = bounded::(0); + + let mut sel = Select::new(); + sel.send(&s); + match sel.try_ready() { + Ok(0) => assert_eq!(s.try_send(0), Err(TrySendError::Disconnected(0))), + _ => panic!(), + } + + let (s, _) = bounded::(0); + + let mut sel = Select::new(); + sel.send(&s); + match sel.ready_timeout(ms(1000)) { + Ok(0) => assert_eq!(s.try_send(0), Err(TrySendError::Disconnected(0))), + _ => panic!(), + } +} + +#[test] +fn default_only() { + let start = Instant::now(); + + let mut sel = Select::new(); + assert!(sel.try_ready().is_err()); + let now = Instant::now(); + assert!(now - start <= ms(50)); + + let start = Instant::now(); + let mut sel = Select::new(); + assert!(sel.ready_timeout(ms(500)).is_err()); + let now = Instant::now(); + assert!(now - start >= ms(450)); + assert!(now - start <= ms(550)); +} + +#[test] +fn unblocks() { + let (s1, r1) = bounded::(0); + let (s2, r2) = bounded::(0); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + s2.send(2).unwrap(); + }); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + match sel.ready_timeout(ms(1000)) { + Ok(1) => assert_eq!(r2.try_recv(), Ok(2)), + _ => panic!(), + } + }) + .unwrap(); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + assert_eq!(r1.recv().unwrap(), 1); + }); + + let mut sel = Select::new(); + let oper1 = sel.send(&s1); + let oper2 = sel.send(&s2); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => oper.send(&s1, 1).unwrap(), + i if i == oper2 => panic!(), + _ => unreachable!(), + }, + } + }) + .unwrap(); +} + +#[test] +fn both_ready() { + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + s1.send(1).unwrap(); + assert_eq!(r2.recv().unwrap(), 2); + }); + + for _ in 0..2 { + let mut sel = Select::new(); + sel.recv(&r1); + sel.send(&s2); + match sel.ready() { + 0 => assert_eq!(r1.try_recv(), Ok(1)), + 1 => s2.try_send(2).unwrap(), + _ => panic!(), + } + } + }) + .unwrap(); +} + +#[test] +fn cloning1() { + scope(|scope| { + let (s1, r1) = unbounded::(); + let (_s2, r2) = unbounded::(); + let (s3, r3) = unbounded::<()>(); + + scope.spawn(move |_| { + r3.recv().unwrap(); + drop(s1.clone()); + assert!(r3.try_recv().is_err()); + s1.send(1).unwrap(); + r3.recv().unwrap(); + }); + + s3.send(()).unwrap(); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + match sel.ready() { + 0 => drop(r1.try_recv()), + 1 => drop(r2.try_recv()), + _ => panic!(), + } + + s3.send(()).unwrap(); + }) + .unwrap(); +} + +#[test] +fn cloning2() { + let (s1, r1) = unbounded::<()>(); + let (s2, r2) = unbounded::<()>(); + let (_s3, _r3) = unbounded::<()>(); + + scope(|scope| { + scope.spawn(move |_| { + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + match sel.ready() { + 0 => panic!(), + 1 => drop(r2.try_recv()), + _ => panic!(), + } + }); + + thread::sleep(ms(500)); + drop(s1.clone()); + s2.send(()).unwrap(); + }) + .unwrap(); +} + +#[test] +fn preflight1() { + let (s, r) = unbounded(); + s.send(()).unwrap(); + + let mut sel = Select::new(); + sel.recv(&r); + match sel.ready() { + 0 => drop(r.try_recv()), + _ => panic!(), + } +} + +#[test] +fn preflight2() { + let (s, r) = unbounded(); + drop(s.clone()); + s.send(()).unwrap(); + drop(s); + + let mut sel = Select::new(); + sel.recv(&r); + match sel.ready() { + 0 => assert_eq!(r.try_recv(), Ok(())), + _ => panic!(), + } + + assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)); +} + +#[test] +fn preflight3() { + let (s, r) = unbounded(); + drop(s.clone()); + s.send(()).unwrap(); + drop(s); + r.recv().unwrap(); + + let mut sel = Select::new(); + sel.recv(&r); + match sel.ready() { + 0 => assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)), + _ => panic!(), + } +} + +#[test] +fn duplicate_operations() { + let (s, r) = unbounded::(); + let hit = vec![Cell::new(false); 4]; + + while hit.iter().map(|h| h.get()).any(|hit| !hit) { + let mut sel = Select::new(); + sel.recv(&r); + sel.recv(&r); + sel.send(&s); + sel.send(&s); + match sel.ready() { + 0 => { + assert!(r.try_recv().is_ok()); + hit[0].set(true); + } + 1 => { + assert!(r.try_recv().is_ok()); + hit[1].set(true); + } + 2 => { + assert!(s.try_send(0).is_ok()); + hit[2].set(true); + } + 3 => { + assert!(s.try_send(0).is_ok()); + hit[3].set(true); + } + _ => panic!(), + } + } +} + +#[test] +fn nesting() { + let (s, r) = unbounded::(); + + let mut sel = Select::new(); + sel.send(&s); + match sel.ready() { + 0 => { + assert!(s.try_send(0).is_ok()); + + let mut sel = Select::new(); + sel.recv(&r); + match sel.ready() { + 0 => { + assert_eq!(r.try_recv(), Ok(0)); + + let mut sel = Select::new(); + sel.send(&s); + match sel.ready() { + 0 => { + assert!(s.try_send(1).is_ok()); + + let mut sel = Select::new(); + sel.recv(&r); + match sel.ready() { + 0 => { + assert_eq!(r.try_recv(), Ok(1)); + } + _ => panic!(), + } + } + _ => panic!(), + } + } + _ => panic!(), + } + } + _ => panic!(), + } +} + +#[test] +fn stress_recv() { + const COUNT: usize = 10_000; + + let (s1, r1) = unbounded(); + let (s2, r2) = bounded(5); + let (s3, r3) = bounded(0); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + s1.send(i).unwrap(); + r3.recv().unwrap(); + + s2.send(i).unwrap(); + r3.recv().unwrap(); + } + }); + + for i in 0..COUNT { + for _ in 0..2 { + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + match sel.ready() { + 0 => assert_eq!(r1.try_recv(), Ok(i)), + 1 => assert_eq!(r2.try_recv(), Ok(i)), + _ => panic!(), + } + + s3.send(()).unwrap(); + } + } + }) + .unwrap(); +} + +#[test] +fn stress_send() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + let (s3, r3) = bounded(100); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + assert_eq!(r1.recv().unwrap(), i); + assert_eq!(r2.recv().unwrap(), i); + r3.recv().unwrap(); + } + }); + + for i in 0..COUNT { + for _ in 0..2 { + let mut sel = Select::new(); + sel.send(&s1); + sel.send(&s2); + match sel.ready() { + 0 => assert!(s1.try_send(i).is_ok()), + 1 => assert!(s2.try_send(i).is_ok()), + _ => panic!(), + } + } + s3.send(()).unwrap(); + } + }) + .unwrap(); +} + +#[test] +fn stress_mixed() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + let (s3, r3) = bounded(100); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + s1.send(i).unwrap(); + assert_eq!(r2.recv().unwrap(), i); + r3.recv().unwrap(); + } + }); + + for i in 0..COUNT { + for _ in 0..2 { + let mut sel = Select::new(); + sel.recv(&r1); + sel.send(&s2); + match sel.ready() { + 0 => assert_eq!(r1.try_recv(), Ok(i)), + 1 => assert!(s2.try_send(i).is_ok()), + _ => panic!(), + } + } + s3.send(()).unwrap(); + } + }) + .unwrap(); +} + +#[test] +fn stress_timeout_two_threads() { + const COUNT: usize = 20; + + let (s, r) = bounded(2); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(500)); + } + + let done = false; + while !done { + let mut sel = Select::new(); + sel.send(&s); + match sel.ready_timeout(ms(100)) { + Err(_) => {} + Ok(0) => { + assert!(s.try_send(i).is_ok()); + break; + } + Ok(_) => panic!(), + } + } + } + }); + + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(500)); + } + + let mut done = false; + while !done { + let mut sel = Select::new(); + sel.recv(&r); + match sel.ready_timeout(ms(100)) { + Err(_) => {} + Ok(0) => { + assert_eq!(r.try_recv(), Ok(i)); + done = true; + } + Ok(_) => panic!(), + } + } + } + }); + }) + .unwrap(); +} + +#[test] +fn send_recv_same_channel() { + let (s, r) = bounded::(0); + let mut sel = Select::new(); + sel.send(&s); + sel.recv(&r); + assert!(sel.ready_timeout(ms(100)).is_err()); + + let (s, r) = unbounded::(); + let mut sel = Select::new(); + sel.send(&s); + sel.recv(&r); + match sel.ready_timeout(ms(100)) { + Err(_) => panic!(), + Ok(0) => assert!(s.try_send(0).is_ok()), + Ok(_) => panic!(), + } +} + +#[test] +fn channel_through_channel() { + const COUNT: usize = 1000; + + type T = Box; + + for cap in 1..4 { + let (s, r) = bounded::(cap); + + scope(|scope| { + scope.spawn(move |_| { + let mut s = s; + + for _ in 0..COUNT { + let (new_s, new_r) = bounded(cap); + let new_r: T = Box::new(Some(new_r)); + + { + let mut sel = Select::new(); + sel.send(&s); + match sel.ready() { + 0 => assert!(s.try_send(new_r).is_ok()), + _ => panic!(), + } + } + + s = new_s; + } + }); + + scope.spawn(move |_| { + let mut r = r; + + for _ in 0..COUNT { + let new = { + let mut sel = Select::new(); + sel.recv(&r); + match sel.ready() { + 0 => r + .try_recv() + .unwrap() + .downcast_mut::>>() + .unwrap() + .take() + .unwrap(), + _ => panic!(), + } + }; + r = new; + } + }); + }) + .unwrap(); + } +} + +#[test] +fn fairness1() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded::<()>(COUNT); + let (s2, r2) = unbounded::<()>(); + + for _ in 0..COUNT { + s1.send(()).unwrap(); + s2.send(()).unwrap(); + } + + let hits = vec![Cell::new(0usize); 4]; + for _ in 0..COUNT { + let after = after(ms(0)); + let tick = tick(ms(0)); + + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + sel.recv(&after); + sel.recv(&tick); + match sel.ready() { + 0 => { + r1.try_recv().unwrap(); + hits[0].set(hits[0].get() + 1); + } + 1 => { + r2.try_recv().unwrap(); + hits[1].set(hits[1].get() + 1); + } + 2 => { + after.try_recv().unwrap(); + hits[2].set(hits[2].get() + 1); + } + 3 => { + tick.try_recv().unwrap(); + hits[3].set(hits[3].get() + 1); + } + _ => panic!(), + } + } + assert!(hits.iter().all(|x| x.get() >= COUNT / hits.len() / 2)); +} + +#[test] +fn fairness2() { + const COUNT: usize = 10_000; + + let (s1, r1) = unbounded::<()>(); + let (s2, r2) = bounded::<()>(1); + let (s3, r3) = bounded::<()>(0); + + scope(|scope| { + scope.spawn(|_| { + for _ in 0..COUNT { + let mut sel = Select::new(); + let mut oper1 = None; + let mut oper2 = None; + if s1.is_empty() { + oper1 = Some(sel.send(&s1)); + } + if s2.is_empty() { + oper2 = Some(sel.send(&s2)); + } + let oper3 = sel.send(&s3); + let oper = sel.select(); + match oper.index() { + i if Some(i) == oper1 => assert!(oper.send(&s1, ()).is_ok()), + i if Some(i) == oper2 => assert!(oper.send(&s2, ()).is_ok()), + i if i == oper3 => assert!(oper.send(&s3, ()).is_ok()), + _ => unreachable!(), + } + } + }); + + let hits = vec![Cell::new(0usize); 3]; + for _ in 0..COUNT { + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + sel.recv(&r3); + loop { + match sel.ready() { + 0 => { + if r1.try_recv().is_ok() { + hits[0].set(hits[0].get() + 1); + break; + } + } + 1 => { + if r2.try_recv().is_ok() { + hits[1].set(hits[1].get() + 1); + break; + } + } + 2 => { + if r3.try_recv().is_ok() { + hits[2].set(hits[2].get() + 1); + break; + } + } + _ => unreachable!(), + } + } + } + assert!(hits.iter().all(|x| x.get() >= COUNT / hits.len() / 10)); + }) + .unwrap(); +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/same_channel.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/same_channel.rs new file mode 100644 index 0000000..8e34faf --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/same_channel.rs @@ -0,0 +1,114 @@ +extern crate crossbeam_channel; + +use std::time::Duration; + +use crossbeam_channel::{after, bounded, never, tick, unbounded}; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +fn after_same_channel() { + let r = after(ms(50)); + + let r2 = r.clone(); + assert!(r.same_channel(&r2)); + + let r3 = after(ms(50)); + assert!(!r.same_channel(&r3)); + assert!(!r2.same_channel(&r3)); + + let r4 = after(ms(100)); + assert!(!r.same_channel(&r4)); + assert!(!r2.same_channel(&r4)); +} + +#[test] +fn array_same_channel() { + let (s, r) = bounded::(1); + + let s2 = s.clone(); + assert!(s.same_channel(&s2)); + + let r2 = r.clone(); + assert!(r.same_channel(&r2)); + + let (s3, r3) = bounded::(1); + assert!(!s.same_channel(&s3)); + assert!(!s2.same_channel(&s3)); + assert!(!r.same_channel(&r3)); + assert!(!r2.same_channel(&r3)); +} + +#[test] +fn list_same_channel() { + let (s, r) = unbounded::(); + + let s2 = s.clone(); + assert!(s.same_channel(&s2)); + + let r2 = r.clone(); + assert!(r.same_channel(&r2)); + + let (s3, r3) = unbounded::(); + assert!(!s.same_channel(&s3)); + assert!(!s2.same_channel(&s3)); + assert!(!r.same_channel(&r3)); + assert!(!r2.same_channel(&r3)); +} + +#[test] +fn never_same_channel() { + let r = never::(); + + let r2 = r.clone(); + assert!(r.same_channel(&r2)); + + // Never channel are always equal to one another. + let r3 = never::(); + assert!(r.same_channel(&r3)); + assert!(r2.same_channel(&r3)); +} + +#[test] +fn tick_same_channel() { + let r = tick(ms(50)); + + let r2 = r.clone(); + assert!(r.same_channel(&r2)); + + let r3 = tick(ms(50)); + assert!(!r.same_channel(&r3)); + assert!(!r2.same_channel(&r3)); + + let r4 = tick(ms(100)); + assert!(!r.same_channel(&r4)); + assert!(!r2.same_channel(&r4)); +} + +#[test] +fn zero_same_channel() { + let (s, r) = bounded::(0); + + let s2 = s.clone(); + assert!(s.same_channel(&s2)); + + let r2 = r.clone(); + assert!(r.same_channel(&r2)); + + let (s3, r3) = bounded::(0); + assert!(!s.same_channel(&s3)); + assert!(!s2.same_channel(&s3)); + assert!(!r.same_channel(&r3)); + assert!(!r2.same_channel(&r3)); +} + +#[test] +fn different_flavors_same_channel() { + let (s1, r1) = bounded::(0); + let (s2, r2) = unbounded::(); + + assert!(!s1.same_channel(&s2)); + assert!(!r1.same_channel(&r2)); +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/select.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/select.rs new file mode 100644 index 0000000..7c62a4c --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/select.rs @@ -0,0 +1,1304 @@ +//! Tests for channel selection using the `Select` struct. + +extern crate crossbeam_channel; +extern crate crossbeam_utils; + +use std::any::Any; +use std::cell::Cell; +use std::thread; +use std::time::{Duration, Instant}; + +use crossbeam_channel::{after, bounded, tick, unbounded, Receiver, Select, TryRecvError}; +use crossbeam_utils::thread::scope; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +fn smoke1() { + let (s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + s1.send(1).unwrap(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => assert_eq!(oper.recv(&r1), Ok(1)), + i if i == oper2 => panic!(), + _ => unreachable!(), + } + + s2.send(2).unwrap(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => panic!(), + i if i == oper2 => assert_eq!(oper.recv(&r2), Ok(2)), + _ => unreachable!(), + } +} + +#[test] +fn smoke2() { + let (_s1, r1) = unbounded::(); + let (_s2, r2) = unbounded::(); + let (_s3, r3) = unbounded::(); + let (_s4, r4) = unbounded::(); + let (s5, r5) = unbounded::(); + + s5.send(5).unwrap(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper3 = sel.recv(&r3); + let oper4 = sel.recv(&r4); + let oper5 = sel.recv(&r5); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => panic!(), + i if i == oper2 => panic!(), + i if i == oper3 => panic!(), + i if i == oper4 => panic!(), + i if i == oper5 => assert_eq!(oper.recv(&r5), Ok(5)), + _ => unreachable!(), + } +} + +#[test] +fn disconnected() { + let (s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + scope(|scope| { + scope.spawn(|_| { + drop(s1); + thread::sleep(ms(500)); + s2.send(5).unwrap(); + }); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => assert!(oper.recv(&r1).is_err()), + i if i == oper2 => panic!(), + _ => unreachable!(), + }, + } + + r2.recv().unwrap(); + }) + .unwrap(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => assert!(oper.recv(&r1).is_err()), + i if i == oper2 => panic!(), + _ => unreachable!(), + }, + } + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + drop(s2); + }); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r2); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => assert!(oper.recv(&r2).is_err()), + _ => unreachable!(), + }, + } + }) + .unwrap(); +} + +#[test] +fn default() { + let (s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + let mut sel = Select::new(); + let _oper1 = sel.recv(&r1); + let _oper2 = sel.recv(&r2); + let oper = sel.try_select(); + match oper { + Err(_) => {} + Ok(_) => panic!(), + } + + drop(s1); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.try_select(); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => assert!(oper.recv(&r1).is_err()), + i if i == oper2 => panic!(), + _ => unreachable!(), + }, + } + + s2.send(2).unwrap(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r2); + let oper = sel.try_select(); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => assert_eq!(oper.recv(&r2), Ok(2)), + _ => unreachable!(), + }, + } + + let mut sel = Select::new(); + let _oper1 = sel.recv(&r2); + let oper = sel.try_select(); + match oper { + Err(_) => {} + Ok(_) => panic!(), + } + + let mut sel = Select::new(); + let oper = sel.try_select(); + match oper { + Err(_) => {} + Ok(_) => panic!(), + } +} + +#[test] +fn timeout() { + let (_s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(1500)); + s2.send(2).unwrap(); + }); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => {} + Ok(oper) => match oper.index() { + i if i == oper1 => panic!(), + i if i == oper2 => panic!(), + _ => unreachable!(), + }, + } + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => panic!(), + i if i == oper2 => assert_eq!(oper.recv(&r2), Ok(2)), + _ => unreachable!(), + }, + } + }) + .unwrap(); + + scope(|scope| { + let (s, r) = unbounded::(); + + scope.spawn(move |_| { + thread::sleep(ms(500)); + drop(s); + }); + + let mut sel = Select::new(); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => { + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper = sel.try_select(); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => assert!(oper.recv(&r).is_err()), + _ => unreachable!(), + }, + } + } + Ok(_) => unreachable!(), + } + }) + .unwrap(); +} + +#[test] +fn default_when_disconnected() { + let (_, r) = unbounded::(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper = sel.try_select(); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => assert!(oper.recv(&r).is_err()), + _ => unreachable!(), + }, + } + + let (_, r) = unbounded::(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => assert!(oper.recv(&r).is_err()), + _ => unreachable!(), + }, + } + + let (s, _) = bounded::(0); + + let mut sel = Select::new(); + let oper1 = sel.send(&s); + let oper = sel.try_select(); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => assert!(oper.send(&s, 0).is_err()), + _ => unreachable!(), + }, + } + + let (s, _) = bounded::(0); + + let mut sel = Select::new(); + let oper1 = sel.send(&s); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => assert!(oper.send(&s, 0).is_err()), + _ => unreachable!(), + }, + } +} + +#[test] +fn default_only() { + let start = Instant::now(); + + let mut sel = Select::new(); + let oper = sel.try_select(); + assert!(oper.is_err()); + let now = Instant::now(); + assert!(now - start <= ms(50)); + + let start = Instant::now(); + let mut sel = Select::new(); + let oper = sel.select_timeout(ms(500)); + assert!(oper.is_err()); + let now = Instant::now(); + assert!(now - start >= ms(450)); + assert!(now - start <= ms(550)); +} + +#[test] +fn unblocks() { + let (s1, r1) = bounded::(0); + let (s2, r2) = bounded::(0); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + s2.send(2).unwrap(); + }); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => panic!(), + i if i == oper2 => assert_eq!(oper.recv(&r2), Ok(2)), + _ => unreachable!(), + }, + } + }) + .unwrap(); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + assert_eq!(r1.recv().unwrap(), 1); + }); + + let mut sel = Select::new(); + let oper1 = sel.send(&s1); + let oper2 = sel.send(&s2); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + i if i == oper1 => oper.send(&s1, 1).unwrap(), + i if i == oper2 => panic!(), + _ => unreachable!(), + }, + } + }) + .unwrap(); +} + +#[test] +fn both_ready() { + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + s1.send(1).unwrap(); + assert_eq!(r2.recv().unwrap(), 2); + }); + + for _ in 0..2 { + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.send(&s2); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => assert_eq!(oper.recv(&r1), Ok(1)), + i if i == oper2 => oper.send(&s2, 2).unwrap(), + _ => unreachable!(), + } + } + }) + .unwrap(); +} + +#[test] +fn loop_try() { + const RUNS: usize = 20; + + for _ in 0..RUNS { + let (s1, r1) = bounded::(0); + let (s2, r2) = bounded::(0); + let (s_end, r_end) = bounded::<()>(0); + + scope(|scope| { + scope.spawn(|_| loop { + let mut done = false; + + let mut sel = Select::new(); + let oper1 = sel.send(&s1); + let oper = sel.try_select(); + match oper { + Err(_) => {} + Ok(oper) => match oper.index() { + i if i == oper1 => { + let _ = oper.send(&s1, 1); + done = true; + } + _ => unreachable!(), + }, + } + if done { + break; + } + + let mut sel = Select::new(); + let oper1 = sel.recv(&r_end); + let oper = sel.try_select(); + match oper { + Err(_) => {} + Ok(oper) => match oper.index() { + i if i == oper1 => { + let _ = oper.recv(&r_end); + done = true; + } + _ => unreachable!(), + }, + } + if done { + break; + } + }); + + scope.spawn(|_| loop { + if let Ok(x) = r2.try_recv() { + assert_eq!(x, 2); + break; + } + + let mut done = false; + let mut sel = Select::new(); + let oper1 = sel.recv(&r_end); + let oper = sel.try_select(); + match oper { + Err(_) => {} + Ok(oper) => match oper.index() { + i if i == oper1 => { + let _ = oper.recv(&r_end); + done = true; + } + _ => unreachable!(), + }, + } + if done { + break; + } + }); + + scope.spawn(|_| { + thread::sleep(ms(500)); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.send(&s2); + let oper = sel.select_timeout(ms(1000)); + match oper { + Err(_) => {} + Ok(oper) => match oper.index() { + i if i == oper1 => assert_eq!(oper.recv(&r1), Ok(1)), + i if i == oper2 => assert!(oper.send(&s2, 2).is_ok()), + _ => unreachable!(), + }, + } + + drop(s_end); + }); + }) + .unwrap(); + } +} + +#[test] +fn cloning1() { + scope(|scope| { + let (s1, r1) = unbounded::(); + let (_s2, r2) = unbounded::(); + let (s3, r3) = unbounded::<()>(); + + scope.spawn(move |_| { + r3.recv().unwrap(); + drop(s1.clone()); + assert!(r3.try_recv().is_err()); + s1.send(1).unwrap(); + r3.recv().unwrap(); + }); + + s3.send(()).unwrap(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => drop(oper.recv(&r1)), + i if i == oper2 => drop(oper.recv(&r2)), + _ => unreachable!(), + } + + s3.send(()).unwrap(); + }) + .unwrap(); +} + +#[test] +fn cloning2() { + let (s1, r1) = unbounded::<()>(); + let (s2, r2) = unbounded::<()>(); + let (_s3, _r3) = unbounded::<()>(); + + scope(|scope| { + scope.spawn(move |_| { + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => panic!(), + i if i == oper2 => drop(oper.recv(&r2)), + _ => unreachable!(), + } + }); + + thread::sleep(ms(500)); + drop(s1.clone()); + s2.send(()).unwrap(); + }) + .unwrap(); +} + +#[test] +fn preflight1() { + let (s, r) = unbounded(); + s.send(()).unwrap(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => drop(oper.recv(&r)), + _ => unreachable!(), + } +} + +#[test] +fn preflight2() { + let (s, r) = unbounded(); + drop(s.clone()); + s.send(()).unwrap(); + drop(s); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => assert_eq!(oper.recv(&r), Ok(())), + _ => unreachable!(), + } + + assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)); +} + +#[test] +fn preflight3() { + let (s, r) = unbounded(); + drop(s.clone()); + s.send(()).unwrap(); + drop(s); + r.recv().unwrap(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => assert!(oper.recv(&r).is_err()), + _ => unreachable!(), + } +} + +#[test] +fn duplicate_operations() { + let (s, r) = unbounded::(); + let hit = vec![Cell::new(false); 4]; + + while hit.iter().map(|h| h.get()).any(|hit| !hit) { + let mut sel = Select::new(); + let oper0 = sel.recv(&r); + let oper1 = sel.recv(&r); + let oper2 = sel.send(&s); + let oper3 = sel.send(&s); + let oper = sel.select(); + match oper.index() { + i if i == oper0 => { + assert!(oper.recv(&r).is_ok()); + hit[0].set(true); + } + i if i == oper1 => { + assert!(oper.recv(&r).is_ok()); + hit[1].set(true); + } + i if i == oper2 => { + assert!(oper.send(&s, 0).is_ok()); + hit[2].set(true); + } + i if i == oper3 => { + assert!(oper.send(&s, 0).is_ok()); + hit[3].set(true); + } + _ => unreachable!(), + } + } +} + +#[test] +fn nesting() { + let (s, r) = unbounded::(); + + let mut sel = Select::new(); + let oper1 = sel.send(&s); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => { + assert!(oper.send(&s, 0).is_ok()); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => { + assert_eq!(oper.recv(&r), Ok(0)); + + let mut sel = Select::new(); + let oper1 = sel.send(&s); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => { + assert!(oper.send(&s, 1).is_ok()); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => { + assert_eq!(oper.recv(&r), Ok(1)); + } + _ => unreachable!(), + } + } + _ => unreachable!(), + } + } + _ => unreachable!(), + } + } + _ => unreachable!(), + } +} + +#[test] +fn stress_recv() { + const COUNT: usize = 10_000; + + let (s1, r1) = unbounded(); + let (s2, r2) = bounded(5); + let (s3, r3) = bounded(100); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + s1.send(i).unwrap(); + r3.recv().unwrap(); + + s2.send(i).unwrap(); + r3.recv().unwrap(); + } + }); + + for i in 0..COUNT { + for _ in 0..2 { + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select(); + match oper.index() { + ix if ix == oper1 => assert_eq!(oper.recv(&r1), Ok(i)), + ix if ix == oper2 => assert_eq!(oper.recv(&r2), Ok(i)), + _ => unreachable!(), + } + + s3.send(()).unwrap(); + } + } + }) + .unwrap(); +} + +#[test] +fn stress_send() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + let (s3, r3) = bounded(100); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + assert_eq!(r1.recv().unwrap(), i); + assert_eq!(r2.recv().unwrap(), i); + r3.recv().unwrap(); + } + }); + + for i in 0..COUNT { + for _ in 0..2 { + let mut sel = Select::new(); + let oper1 = sel.send(&s1); + let oper2 = sel.send(&s2); + let oper = sel.select(); + match oper.index() { + ix if ix == oper1 => assert!(oper.send(&s1, i).is_ok()), + ix if ix == oper2 => assert!(oper.send(&s2, i).is_ok()), + _ => unreachable!(), + } + } + s3.send(()).unwrap(); + } + }) + .unwrap(); +} + +#[test] +fn stress_mixed() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + let (s3, r3) = bounded(100); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + s1.send(i).unwrap(); + assert_eq!(r2.recv().unwrap(), i); + r3.recv().unwrap(); + } + }); + + for i in 0..COUNT { + for _ in 0..2 { + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.send(&s2); + let oper = sel.select(); + match oper.index() { + ix if ix == oper1 => assert_eq!(oper.recv(&r1), Ok(i)), + ix if ix == oper2 => assert!(oper.send(&s2, i).is_ok()), + _ => unreachable!(), + } + } + s3.send(()).unwrap(); + } + }) + .unwrap(); +} + +#[test] +fn stress_timeout_two_threads() { + const COUNT: usize = 20; + + let (s, r) = bounded(2); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(500)); + } + + let done = false; + while !done { + let mut sel = Select::new(); + let oper1 = sel.send(&s); + let oper = sel.select_timeout(ms(100)); + match oper { + Err(_) => {} + Ok(oper) => match oper.index() { + ix if ix == oper1 => { + assert!(oper.send(&s, i).is_ok()); + break; + } + _ => unreachable!(), + }, + } + } + } + }); + + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(500)); + } + + let mut done = false; + while !done { + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper = sel.select_timeout(ms(100)); + match oper { + Err(_) => {} + Ok(oper) => match oper.index() { + ix if ix == oper1 => { + assert_eq!(oper.recv(&r), Ok(i)); + done = true; + } + _ => unreachable!(), + }, + } + } + } + }); + }) + .unwrap(); +} + +#[test] +fn send_recv_same_channel() { + let (s, r) = bounded::(0); + let mut sel = Select::new(); + let oper1 = sel.send(&s); + let oper2 = sel.recv(&r); + let oper = sel.select_timeout(ms(100)); + match oper { + Err(_) => {} + Ok(oper) => match oper.index() { + ix if ix == oper1 => panic!(), + ix if ix == oper2 => panic!(), + _ => unreachable!(), + }, + } + + let (s, r) = unbounded::(); + let mut sel = Select::new(); + let oper1 = sel.send(&s); + let oper2 = sel.recv(&r); + let oper = sel.select_timeout(ms(100)); + match oper { + Err(_) => panic!(), + Ok(oper) => match oper.index() { + ix if ix == oper1 => assert!(oper.send(&s, 0).is_ok()), + ix if ix == oper2 => panic!(), + _ => unreachable!(), + }, + } +} + +#[test] +fn matching() { + const THREADS: usize = 44; + + let (s, r) = &bounded::(0); + + scope(|scope| { + for i in 0..THREADS { + scope.spawn(move |_| { + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper2 = sel.send(&s); + let oper = sel.select(); + match oper.index() { + ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)), + ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()), + _ => unreachable!(), + } + }); + } + }) + .unwrap(); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn matching_with_leftover() { + const THREADS: usize = 55; + + let (s, r) = &bounded::(0); + + scope(|scope| { + for i in 0..THREADS { + scope.spawn(move |_| { + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper2 = sel.send(&s); + let oper = sel.select(); + match oper.index() { + ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)), + ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()), + _ => unreachable!(), + } + }); + } + s.send(!0).unwrap(); + }) + .unwrap(); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn channel_through_channel() { + const COUNT: usize = 1000; + + type T = Box; + + for cap in 0..3 { + let (s, r) = bounded::(cap); + + scope(|scope| { + scope.spawn(move |_| { + let mut s = s; + + for _ in 0..COUNT { + let (new_s, new_r) = bounded(cap); + let new_r: T = Box::new(Some(new_r)); + + { + let mut sel = Select::new(); + let oper1 = sel.send(&s); + let oper = sel.select(); + match oper.index() { + ix if ix == oper1 => assert!(oper.send(&s, new_r).is_ok()), + _ => unreachable!(), + } + } + + s = new_s; + } + }); + + scope.spawn(move |_| { + let mut r = r; + + for _ in 0..COUNT { + let new = { + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper = sel.select(); + match oper.index() { + ix if ix == oper1 => oper + .recv(&r) + .unwrap() + .downcast_mut::>>() + .unwrap() + .take() + .unwrap(), + _ => unreachable!(), + } + }; + r = new; + } + }); + }) + .unwrap(); + } +} + +#[test] +fn linearizable_try() { + const COUNT: usize = 100_000; + + for step in 0..2 { + let (start_s, start_r) = bounded::<()>(0); + let (end_s, end_r) = bounded::<()>(0); + + let ((s1, r1), (s2, r2)) = if step == 0 { + (bounded::(1), bounded::(1)) + } else { + (unbounded::(), unbounded::()) + }; + + scope(|scope| { + scope.spawn(|_| { + for _ in 0..COUNT { + start_s.send(()).unwrap(); + + s1.send(1).unwrap(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.try_select(); + match oper { + Err(_) => unreachable!(), + Ok(oper) => match oper.index() { + ix if ix == oper1 => assert!(oper.recv(&r1).is_ok()), + ix if ix == oper2 => assert!(oper.recv(&r2).is_ok()), + _ => unreachable!(), + }, + } + + end_s.send(()).unwrap(); + let _ = r2.try_recv(); + } + }); + + for _ in 0..COUNT { + start_r.recv().unwrap(); + + s2.send(1).unwrap(); + let _ = r1.try_recv(); + + end_r.recv().unwrap(); + } + }) + .unwrap(); + } +} + +#[test] +fn linearizable_timeout() { + const COUNT: usize = 100_000; + + for step in 0..2 { + let (start_s, start_r) = bounded::<()>(0); + let (end_s, end_r) = bounded::<()>(0); + + let ((s1, r1), (s2, r2)) = if step == 0 { + (bounded::(1), bounded::(1)) + } else { + (unbounded::(), unbounded::()) + }; + + scope(|scope| { + scope.spawn(|_| { + for _ in 0..COUNT { + start_s.send(()).unwrap(); + + s1.send(1).unwrap(); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper = sel.select_timeout(ms(0)); + match oper { + Err(_) => unreachable!(), + Ok(oper) => match oper.index() { + ix if ix == oper1 => assert!(oper.recv(&r1).is_ok()), + ix if ix == oper2 => assert!(oper.recv(&r2).is_ok()), + _ => unreachable!(), + }, + } + + end_s.send(()).unwrap(); + let _ = r2.try_recv(); + } + }); + + for _ in 0..COUNT { + start_r.recv().unwrap(); + + s2.send(1).unwrap(); + let _ = r1.try_recv(); + + end_r.recv().unwrap(); + } + }) + .unwrap(); + } +} + +#[test] +fn fairness1() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded::<()>(COUNT); + let (s2, r2) = unbounded::<()>(); + + for _ in 0..COUNT { + s1.send(()).unwrap(); + s2.send(()).unwrap(); + } + + let hits = vec![Cell::new(0usize); 4]; + for _ in 0..COUNT { + let after = after(ms(0)); + let tick = tick(ms(0)); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper3 = sel.recv(&after); + let oper4 = sel.recv(&tick); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => { + oper.recv(&r1).unwrap(); + hits[0].set(hits[0].get() + 1); + } + i if i == oper2 => { + oper.recv(&r2).unwrap(); + hits[1].set(hits[1].get() + 1); + } + i if i == oper3 => { + oper.recv(&after).unwrap(); + hits[2].set(hits[2].get() + 1); + } + i if i == oper4 => { + oper.recv(&tick).unwrap(); + hits[3].set(hits[3].get() + 1); + } + _ => unreachable!(), + } + } + assert!(hits.iter().all(|x| x.get() >= COUNT / hits.len() / 2)); +} + +#[test] +fn fairness2() { + const COUNT: usize = 10_000; + + let (s1, r1) = unbounded::<()>(); + let (s2, r2) = bounded::<()>(1); + let (s3, r3) = bounded::<()>(0); + + scope(|scope| { + scope.spawn(|_| { + for _ in 0..COUNT { + let mut sel = Select::new(); + let mut oper1 = None; + let mut oper2 = None; + if s1.is_empty() { + oper1 = Some(sel.send(&s1)); + } + if s2.is_empty() { + oper2 = Some(sel.send(&s2)); + } + let oper3 = sel.send(&s3); + let oper = sel.select(); + match oper.index() { + i if Some(i) == oper1 => assert!(oper.send(&s1, ()).is_ok()), + i if Some(i) == oper2 => assert!(oper.send(&s2, ()).is_ok()), + i if i == oper3 => assert!(oper.send(&s3, ()).is_ok()), + _ => unreachable!(), + } + } + }); + + let hits = vec![Cell::new(0usize); 3]; + for _ in 0..COUNT { + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper3 = sel.recv(&r3); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => { + oper.recv(&r1).unwrap(); + hits[0].set(hits[0].get() + 1); + } + i if i == oper2 => { + oper.recv(&r2).unwrap(); + hits[1].set(hits[1].get() + 1); + } + i if i == oper3 => { + oper.recv(&r3).unwrap(); + hits[2].set(hits[2].get() + 1); + } + _ => unreachable!(), + } + } + assert!(hits.iter().all(|x| x.get() >= COUNT / hits.len() / 50)); + }) + .unwrap(); +} + +#[test] +fn sync_and_clone() { + const THREADS: usize = 20; + + let (s, r) = &bounded::(0); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper2 = sel.send(&s); + let sel = &sel; + + scope(|scope| { + for i in 0..THREADS { + scope.spawn(move |_| { + let mut sel = sel.clone(); + let oper = sel.select(); + match oper.index() { + ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)), + ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()), + _ => unreachable!(), + } + }); + } + }) + .unwrap(); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn send_and_clone() { + const THREADS: usize = 20; + + let (s, r) = &bounded::(0); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r); + let oper2 = sel.send(&s); + + scope(|scope| { + for i in 0..THREADS { + let mut sel = sel.clone(); + scope.spawn(move |_| { + let oper = sel.select(); + match oper.index() { + ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)), + ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()), + _ => unreachable!(), + } + }); + } + }) + .unwrap(); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn reuse() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + let (s3, r3) = bounded(100); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + s1.send(i).unwrap(); + assert_eq!(r2.recv().unwrap(), i); + r3.recv().unwrap(); + } + }); + + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.send(&s2); + + for i in 0..COUNT { + for _ in 0..2 { + let oper = sel.select(); + match oper.index() { + ix if ix == oper1 => assert_eq!(oper.recv(&r1), Ok(i)), + ix if ix == oper2 => assert!(oper.send(&s2, i).is_ok()), + _ => unreachable!(), + } + } + s3.send(()).unwrap(); + } + }) + .unwrap(); +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/select_macro.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/select_macro.rs new file mode 100644 index 0000000..0a7eddb --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/select_macro.rs @@ -0,0 +1,1440 @@ +//! Tests for the `select!` macro. + +#![deny(unsafe_code)] + +#[macro_use] +extern crate crossbeam_channel; +extern crate crossbeam_utils; + +use std::any::Any; +use std::cell::Cell; +use std::ops::Deref; +use std::thread; +use std::time::{Duration, Instant}; + +use crossbeam_channel::{after, bounded, never, tick, unbounded}; +use crossbeam_channel::{Receiver, RecvError, SendError, Sender, TryRecvError}; +use crossbeam_utils::thread::scope; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +fn smoke1() { + let (s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + s1.send(1).unwrap(); + + select! { + recv(r1) -> v => assert_eq!(v, Ok(1)), + recv(r2) -> _ => panic!(), + } + + s2.send(2).unwrap(); + + select! { + recv(r1) -> _ => panic!(), + recv(r2) -> v => assert_eq!(v, Ok(2)), + } +} + +#[test] +fn smoke2() { + let (_s1, r1) = unbounded::(); + let (_s2, r2) = unbounded::(); + let (_s3, r3) = unbounded::(); + let (_s4, r4) = unbounded::(); + let (s5, r5) = unbounded::(); + + s5.send(5).unwrap(); + + select! { + recv(r1) -> _ => panic!(), + recv(r2) -> _ => panic!(), + recv(r3) -> _ => panic!(), + recv(r4) -> _ => panic!(), + recv(r5) -> v => assert_eq!(v, Ok(5)), + } +} + +#[test] +fn disconnected() { + let (s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + scope(|scope| { + scope.spawn(|_| { + drop(s1); + thread::sleep(ms(500)); + s2.send(5).unwrap(); + }); + + select! { + recv(r1) -> v => assert!(v.is_err()), + recv(r2) -> _ => panic!(), + default(ms(1000)) => panic!(), + } + + r2.recv().unwrap(); + }) + .unwrap(); + + select! { + recv(r1) -> v => assert!(v.is_err()), + recv(r2) -> _ => panic!(), + default(ms(1000)) => panic!(), + } + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + drop(s2); + }); + + select! { + recv(r2) -> v => assert!(v.is_err()), + default(ms(1000)) => panic!(), + } + }) + .unwrap(); +} + +#[test] +fn default() { + let (s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + select! { + recv(r1) -> _ => panic!(), + recv(r2) -> _ => panic!(), + default => {} + } + + drop(s1); + + select! { + recv(r1) -> v => assert!(v.is_err()), + recv(r2) -> _ => panic!(), + default => panic!(), + } + + s2.send(2).unwrap(); + + select! { + recv(r2) -> v => assert_eq!(v, Ok(2)), + default => panic!(), + } + + select! { + recv(r2) -> _ => panic!(), + default => {}, + } + + select! { + default => {}, + } +} + +#[test] +fn timeout() { + let (_s1, r1) = unbounded::(); + let (s2, r2) = unbounded::(); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(1500)); + s2.send(2).unwrap(); + }); + + select! { + recv(r1) -> _ => panic!(), + recv(r2) -> _ => panic!(), + default(ms(1000)) => {}, + } + + select! { + recv(r1) -> _ => panic!(), + recv(r2) -> v => assert_eq!(v, Ok(2)), + default(ms(1000)) => panic!(), + } + }) + .unwrap(); + + scope(|scope| { + let (s, r) = unbounded::(); + + scope.spawn(move |_| { + thread::sleep(ms(500)); + drop(s); + }); + + select! { + default(ms(1000)) => { + select! { + recv(r) -> v => assert!(v.is_err()), + default => panic!(), + } + } + } + }) + .unwrap(); +} + +#[test] +fn default_when_disconnected() { + let (_, r) = unbounded::(); + + select! { + recv(r) -> res => assert!(res.is_err()), + default => panic!(), + } + + let (_, r) = unbounded::(); + + select! { + recv(r) -> res => assert!(res.is_err()), + default(ms(1000)) => panic!(), + } + + let (s, _) = bounded::(0); + + select! { + send(s, 0) -> res => assert!(res.is_err()), + default => panic!(), + } + + let (s, _) = bounded::(0); + + select! { + send(s, 0) -> res => assert!(res.is_err()), + default(ms(1000)) => panic!(), + } +} + +#[test] +fn default_only() { + let start = Instant::now(); + select! { + default => {} + } + let now = Instant::now(); + assert!(now - start <= ms(50)); + + let start = Instant::now(); + select! { + default(ms(500)) => {} + } + let now = Instant::now(); + assert!(now - start >= ms(450)); + assert!(now - start <= ms(550)); +} + +#[test] +fn unblocks() { + let (s1, r1) = bounded::(0); + let (s2, r2) = bounded::(0); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + s2.send(2).unwrap(); + }); + + select! { + recv(r1) -> _ => panic!(), + recv(r2) -> v => assert_eq!(v, Ok(2)), + default(ms(1000)) => panic!(), + } + }) + .unwrap(); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + assert_eq!(r1.recv().unwrap(), 1); + }); + + select! { + send(s1, 1) -> _ => {}, + send(s2, 2) -> _ => panic!(), + default(ms(1000)) => panic!(), + } + }) + .unwrap(); +} + +#[test] +fn both_ready() { + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(500)); + s1.send(1).unwrap(); + assert_eq!(r2.recv().unwrap(), 2); + }); + + for _ in 0..2 { + select! { + recv(r1) -> v => assert_eq!(v, Ok(1)), + send(s2, 2) -> _ => {}, + } + } + }) + .unwrap(); +} + +#[test] +fn loop_try() { + const RUNS: usize = 20; + + for _ in 0..RUNS { + let (s1, r1) = bounded::(0); + let (s2, r2) = bounded::(0); + let (s_end, r_end) = bounded::<()>(0); + + scope(|scope| { + scope.spawn(|_| loop { + select! { + send(s1, 1) -> _ => break, + default => {} + } + + select! { + recv(r_end) -> _ => break, + default => {} + } + }); + + scope.spawn(|_| loop { + if let Ok(x) = r2.try_recv() { + assert_eq!(x, 2); + break; + } + + select! { + recv(r_end) -> _ => break, + default => {} + } + }); + + scope.spawn(|_| { + thread::sleep(ms(500)); + + select! { + recv(r1) -> v => assert_eq!(v, Ok(1)), + send(s2, 2) -> _ => {}, + default(ms(500)) => panic!(), + } + + drop(s_end); + }); + }) + .unwrap(); + } +} + +#[test] +fn cloning1() { + scope(|scope| { + let (s1, r1) = unbounded::(); + let (_s2, r2) = unbounded::(); + let (s3, r3) = unbounded::<()>(); + + scope.spawn(move |_| { + r3.recv().unwrap(); + drop(s1.clone()); + assert_eq!(r3.try_recv(), Err(TryRecvError::Empty)); + s1.send(1).unwrap(); + r3.recv().unwrap(); + }); + + s3.send(()).unwrap(); + + select! { + recv(r1) -> _ => {}, + recv(r2) -> _ => {}, + } + + s3.send(()).unwrap(); + }) + .unwrap(); +} + +#[test] +fn cloning2() { + let (s1, r1) = unbounded::<()>(); + let (s2, r2) = unbounded::<()>(); + let (_s3, _r3) = unbounded::<()>(); + + scope(|scope| { + scope.spawn(move |_| { + select! { + recv(r1) -> _ => panic!(), + recv(r2) -> _ => {}, + } + }); + + thread::sleep(ms(500)); + drop(s1.clone()); + s2.send(()).unwrap(); + }) + .unwrap(); +} + +#[test] +fn preflight1() { + let (s, r) = unbounded(); + s.send(()).unwrap(); + + select! { + recv(r) -> _ => {} + } +} + +#[test] +fn preflight2() { + let (s, r) = unbounded(); + drop(s.clone()); + s.send(()).unwrap(); + drop(s); + + select! { + recv(r) -> v => assert!(v.is_ok()), + } + assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)); +} + +#[test] +fn preflight3() { + let (s, r) = unbounded(); + drop(s.clone()); + s.send(()).unwrap(); + drop(s); + r.recv().unwrap(); + + select! { + recv(r) -> v => assert!(v.is_err()) + } +} + +#[test] +fn duplicate_operations() { + let (s, r) = unbounded::(); + let mut hit = [false; 4]; + + while hit.iter().any(|hit| !hit) { + select! { + recv(r) -> _ => hit[0] = true, + recv(r) -> _ => hit[1] = true, + send(s, 0) -> _ => hit[2] = true, + send(s, 0) -> _ => hit[3] = true, + } + } +} + +#[test] +fn nesting() { + let (s, r) = unbounded::(); + + select! { + send(s, 0) -> _ => { + select! { + recv(r) -> v => { + assert_eq!(v, Ok(0)); + select! { + send(s, 1) -> _ => { + select! { + recv(r) -> v => { + assert_eq!(v, Ok(1)); + } + } + } + } + } + } + } + } +} + +#[test] +#[should_panic(expected = "send panicked")] +fn panic_sender() { + fn get() -> Sender { + panic!("send panicked") + } + + #[allow(unreachable_code)] + { + select! { + send(get(), panic!()) -> _ => {} + } + } +} + +#[test] +#[should_panic(expected = "recv panicked")] +fn panic_receiver() { + fn get() -> Receiver { + panic!("recv panicked") + } + + select! { + recv(get()) -> _ => {} + } +} + +#[test] +fn stress_recv() { + const COUNT: usize = 10_000; + + let (s1, r1) = unbounded(); + let (s2, r2) = bounded(5); + let (s3, r3) = bounded(100); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + s1.send(i).unwrap(); + r3.recv().unwrap(); + + s2.send(i).unwrap(); + r3.recv().unwrap(); + } + }); + + for i in 0..COUNT { + for _ in 0..2 { + select! { + recv(r1) -> v => assert_eq!(v, Ok(i)), + recv(r2) -> v => assert_eq!(v, Ok(i)), + } + + s3.send(()).unwrap(); + } + } + }) + .unwrap(); +} + +#[test] +fn stress_send() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + let (s3, r3) = bounded(100); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + assert_eq!(r1.recv().unwrap(), i); + assert_eq!(r2.recv().unwrap(), i); + r3.recv().unwrap(); + } + }); + + for i in 0..COUNT { + for _ in 0..2 { + select! { + send(s1, i) -> _ => {}, + send(s2, i) -> _ => {}, + } + } + s3.send(()).unwrap(); + } + }) + .unwrap(); +} + +#[test] +fn stress_mixed() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded(0); + let (s2, r2) = bounded(0); + let (s3, r3) = bounded(100); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + s1.send(i).unwrap(); + assert_eq!(r2.recv().unwrap(), i); + r3.recv().unwrap(); + } + }); + + for i in 0..COUNT { + for _ in 0..2 { + select! { + recv(r1) -> v => assert_eq!(v, Ok(i)), + send(s2, i) -> _ => {}, + } + } + s3.send(()).unwrap(); + } + }) + .unwrap(); +} + +#[test] +fn stress_timeout_two_threads() { + const COUNT: usize = 20; + + let (s, r) = bounded(2); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(500)); + } + + loop { + select! { + send(s, i) -> _ => break, + default(ms(100)) => {} + } + } + } + }); + + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(500)); + } + + loop { + select! { + recv(r) -> v => { + assert_eq!(v, Ok(i)); + break; + } + default(ms(100)) => {} + } + } + } + }); + }) + .unwrap(); +} + +#[test] +fn send_recv_same_channel() { + let (s, r) = bounded::(0); + select! { + send(s, 0) -> _ => panic!(), + recv(r) -> _ => panic!(), + default(ms(500)) => {} + } + + let (s, r) = unbounded::(); + select! { + send(s, 0) -> _ => {}, + recv(r) -> _ => panic!(), + default(ms(500)) => panic!(), + } +} + +#[test] +fn matching() { + const THREADS: usize = 44; + + let (s, r) = &bounded::(0); + + scope(|scope| { + for i in 0..THREADS { + scope.spawn(move |_| { + select! { + recv(r) -> v => assert_ne!(v.unwrap(), i), + send(s, i) -> _ => {}, + } + }); + } + }) + .unwrap(); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn matching_with_leftover() { + const THREADS: usize = 55; + + let (s, r) = &bounded::(0); + + scope(|scope| { + for i in 0..THREADS { + scope.spawn(move |_| { + select! { + recv(r) -> v => assert_ne!(v.unwrap(), i), + send(s, i) -> _ => {}, + } + }); + } + s.send(!0).unwrap(); + }) + .unwrap(); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn channel_through_channel() { + const COUNT: usize = 1000; + + type T = Box; + + for cap in 0..3 { + let (s, r) = bounded::(cap); + + scope(|scope| { + scope.spawn(move |_| { + let mut s = s; + + for _ in 0..COUNT { + let (new_s, new_r) = bounded(cap); + let new_r: T = Box::new(Some(new_r)); + + select! { + send(s, new_r) -> _ => {} + } + + s = new_s; + } + }); + + scope.spawn(move |_| { + let mut r = r; + + for _ in 0..COUNT { + r = select! { + recv(r) -> msg => { + msg.unwrap() + .downcast_mut::>>() + .unwrap() + .take() + .unwrap() + } + } + } + }); + }) + .unwrap(); + } +} + +#[test] +fn linearizable_default() { + const COUNT: usize = 100_000; + + for step in 0..2 { + let (start_s, start_r) = bounded::<()>(0); + let (end_s, end_r) = bounded::<()>(0); + + let ((s1, r1), (s2, r2)) = if step == 0 { + (bounded::(1), bounded::(1)) + } else { + (unbounded::(), unbounded::()) + }; + + scope(|scope| { + scope.spawn(|_| { + for _ in 0..COUNT { + start_s.send(()).unwrap(); + + s1.send(1).unwrap(); + select! { + recv(r1) -> _ => {} + recv(r2) -> _ => {} + default => unreachable!() + } + + end_s.send(()).unwrap(); + let _ = r2.try_recv(); + } + }); + + for _ in 0..COUNT { + start_r.recv().unwrap(); + + s2.send(1).unwrap(); + let _ = r1.try_recv(); + + end_r.recv().unwrap(); + } + }) + .unwrap(); + } +} + +#[test] +fn linearizable_timeout() { + const COUNT: usize = 100_000; + + for step in 0..2 { + let (start_s, start_r) = bounded::<()>(0); + let (end_s, end_r) = bounded::<()>(0); + + let ((s1, r1), (s2, r2)) = if step == 0 { + (bounded::(1), bounded::(1)) + } else { + (unbounded::(), unbounded::()) + }; + + scope(|scope| { + scope.spawn(|_| { + for _ in 0..COUNT { + start_s.send(()).unwrap(); + + s1.send(1).unwrap(); + select! { + recv(r1) -> _ => {} + recv(r2) -> _ => {} + default(ms(0)) => unreachable!() + } + + end_s.send(()).unwrap(); + let _ = r2.try_recv(); + } + }); + + for _ in 0..COUNT { + start_r.recv().unwrap(); + + s2.send(1).unwrap(); + let _ = r1.try_recv(); + + end_r.recv().unwrap(); + } + }) + .unwrap(); + } +} + +#[test] +fn fairness1() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded::<()>(COUNT); + let (s2, r2) = unbounded::<()>(); + + for _ in 0..COUNT { + s1.send(()).unwrap(); + s2.send(()).unwrap(); + } + + let mut hits = [0usize; 4]; + for _ in 0..COUNT { + select! { + recv(r1) -> _ => hits[0] += 1, + recv(r2) -> _ => hits[1] += 1, + recv(after(ms(0))) -> _ => hits[2] += 1, + recv(tick(ms(0))) -> _ => hits[3] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); +} + +#[test] +fn fairness2() { + const COUNT: usize = 10_000; + + let (s1, r1) = unbounded::<()>(); + let (s2, r2) = bounded::<()>(1); + let (s3, r3) = bounded::<()>(0); + + scope(|scope| { + scope.spawn(|_| { + let (hole, _r) = bounded(0); + + for _ in 0..COUNT { + let s1 = if s1.is_empty() { &s1 } else { &hole }; + let s2 = if s2.is_empty() { &s2 } else { &hole }; + + select! { + send(s1, ()) -> res => assert!(res.is_ok()), + send(s2, ()) -> res => assert!(res.is_ok()), + send(s3, ()) -> res => assert!(res.is_ok()), + } + } + }); + + let hits = vec![Cell::new(0usize); 3]; + for _ in 0..COUNT { + select! { + recv(r1) -> _ => hits[0].set(hits[0].get() + 1), + recv(r2) -> _ => hits[1].set(hits[1].get() + 1), + recv(r3) -> _ => hits[2].set(hits[2].get() + 1), + } + } + assert!(hits.iter().all(|x| x.get() >= COUNT / hits.len() / 50)); + }) + .unwrap(); +} + +#[test] +fn fairness_recv() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded::<()>(COUNT); + let (s2, r2) = unbounded::<()>(); + + for _ in 0..COUNT { + s1.send(()).unwrap(); + s2.send(()).unwrap(); + } + + let mut hits = [0usize; 2]; + while hits[0] + hits[1] < COUNT { + select! { + recv(r1) -> _ => hits[0] += 1, + recv(r2) -> _ => hits[1] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / 4)); +} + +#[test] +fn fairness_send() { + const COUNT: usize = 10_000; + + let (s1, _r1) = bounded::<()>(COUNT); + let (s2, _r2) = unbounded::<()>(); + + let mut hits = [0usize; 2]; + for _ in 0..COUNT { + select! { + send(s1, ()) -> _ => hits[0] += 1, + send(s2, ()) -> _ => hits[1] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / 4)); +} + +#[test] +fn references() { + let (s, r) = unbounded::(); + select! { + send(s, 0) -> _ => {} + recv(r) -> _ => {} + } + select! { + send(&&&&s, 0) -> _ => {} + recv(&&&&r) -> _ => {} + } + select! { + recv(Some(&r).unwrap_or(&never())) -> _ => {}, + default => {} + } + select! { + recv(Some(r).unwrap_or(never())) -> _ => {}, + default => {} + } +} + +#[test] +fn case_blocks() { + let (s, r) = unbounded::(); + + select! { + recv(r) -> _ => 3.0, + recv(r) -> _ => loop { + unreachable!() + }, + recv(r) -> _ => match 7 + 3 { + _ => unreachable!() + }, + default => 7. + }; + + select! { + recv(r) -> msg => if msg.is_ok() { + unreachable!() + }, + default => () + } + + drop(s); +} + +#[test] +fn move_handles() { + let (s, r) = unbounded::(); + select! { + recv((move || r)()) -> _ => {} + send((move || s)(), 0) -> _ => {} + } +} + +#[test] +fn infer_types() { + let (s, r) = unbounded(); + select! { + recv(r) -> _ => {} + default => {} + } + s.send(()).unwrap(); + + let (s, r) = unbounded(); + select! { + send(s, ()) -> _ => {} + } + r.recv().unwrap(); +} + +#[test] +fn default_syntax() { + let (s, r) = bounded::(0); + + select! { + recv(r) -> _ => panic!(), + default => {} + } + select! { + send(s, 0) -> _ => panic!(), + default() => {} + } + select! { + default => {} + } + select! { + default() => {} + } +} + +#[test] +fn same_variable_name() { + let (_, r) = unbounded::(); + select! { + recv(r) -> r => assert!(r.is_err()), + } +} + +#[test] +fn handles_on_heap() { + let (s, r) = unbounded::(); + let (s, r) = (Box::new(s), Box::new(r)); + + select! { + send(*s, 0) -> _ => {} + recv(*r) -> _ => {} + default => {} + } + + drop(s); + drop(r); +} + +#[test] +fn once_blocks() { + let (s, r) = unbounded::(); + + let once = Box::new(()); + select! { + send(s, 0) -> _ => drop(once), + } + + let once = Box::new(()); + select! { + recv(r) -> _ => drop(once), + } + + let once1 = Box::new(()); + let once2 = Box::new(()); + select! { + send(s, 0) -> _ => drop(once1), + default => drop(once2), + } + + let once1 = Box::new(()); + let once2 = Box::new(()); + select! { + recv(r) -> _ => drop(once1), + default => drop(once2), + } + + let once1 = Box::new(()); + let once2 = Box::new(()); + select! { + recv(r) -> _ => drop(once1), + send(s, 0) -> _ => drop(once2), + } +} + +#[test] +fn once_receiver() { + let (_, r) = unbounded::(); + + let once = Box::new(()); + let get = move || { + drop(once); + r + }; + + select! { + recv(get()) -> _ => {} + } +} + +#[test] +fn once_sender() { + let (s, _) = unbounded::(); + + let once = Box::new(()); + let get = move || { + drop(once); + s + }; + + select! { + send(get(), 5) -> _ => {} + } +} + +#[test] +fn parse_nesting() { + let (_, r) = unbounded::(); + + select! { + recv(r) -> _ => {} + recv(r) -> _ => { + select! { + recv(r) -> _ => {} + recv(r) -> _ => { + select! { + recv(r) -> _ => {} + recv(r) -> _ => { + select! { + default => {} + } + } + } + } + } + } + } +} + +#[test] +fn evaluate() { + let (s, r) = unbounded::(); + + let v = select! { + recv(r) -> _ => "foo".into(), + send(s, 0) -> _ => "bar".to_owned(), + default => "baz".to_string(), + }; + assert_eq!(v, "bar"); + + let v = select! { + recv(r) -> _ => "foo".into(), + default => "baz".to_string(), + }; + assert_eq!(v, "foo"); + + let v = select! { + recv(r) -> _ => "foo".into(), + default => "baz".to_string(), + }; + assert_eq!(v, "baz"); +} + +#[test] +fn deref() { + use crossbeam_channel as cc; + + struct Sender(cc::Sender); + struct Receiver(cc::Receiver); + + impl Deref for Receiver { + type Target = cc::Receiver; + + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + impl Deref for Sender { + type Target = cc::Sender; + + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + let (s, r) = bounded::(0); + let (s, r) = (Sender(s), Receiver(r)); + + select! { + send(s, 0) -> _ => panic!(), + recv(r) -> _ => panic!(), + default => {} + } +} + +#[test] +fn result_types() { + let (s, _) = bounded::(0); + let (_, r) = bounded::(0); + + select! { + recv(r) -> res => drop::>(res), + } + select! { + recv(r) -> res => drop::>(res), + default => {} + } + select! { + recv(r) -> res => drop::>(res), + default(ms(0)) => {} + } + + select! { + send(s, 0) -> res => drop::>>(res), + } + select! { + send(s, 0) -> res => drop::>>(res), + default => {} + } + select! { + send(s, 0) -> res => drop::>>(res), + default(ms(0)) => {} + } + + select! { + send(s, 0) -> res => drop::>>(res), + recv(r) -> res => drop::>(res), + } +} + +#[test] +fn try_recv() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + select! { + recv(r) -> _ => panic!(), + default => {} + } + thread::sleep(ms(1500)); + select! { + recv(r) -> v => assert_eq!(v, Ok(7)), + default => panic!(), + } + thread::sleep(ms(500)); + select! { + recv(r) -> v => assert_eq!(v, Err(RecvError)), + default => panic!(), + } + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + select! { + send(s, 7) -> res => res.unwrap(), + } + }); + }) + .unwrap(); +} + +#[test] +fn recv() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + select! { + recv(r) -> v => assert_eq!(v, Ok(7)), + } + thread::sleep(ms(1000)); + select! { + recv(r) -> v => assert_eq!(v, Ok(8)), + } + thread::sleep(ms(1000)); + select! { + recv(r) -> v => assert_eq!(v, Ok(9)), + } + select! { + recv(r) -> v => assert_eq!(v, Err(RecvError)), + } + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + select! { + send(s, 7) -> res => res.unwrap(), + } + select! { + send(s, 8) -> res => res.unwrap(), + } + select! { + send(s, 9) -> res => res.unwrap(), + } + }); + }) + .unwrap(); +} + +#[test] +fn recv_timeout() { + let (s, r) = bounded::(0); + + scope(|scope| { + scope.spawn(move |_| { + select! { + recv(r) -> _ => panic!(), + default(ms(1000)) => {} + } + select! { + recv(r) -> v => assert_eq!(v, Ok(7)), + default(ms(1000)) => panic!(), + } + select! { + recv(r) -> v => assert_eq!(v, Err(RecvError)), + default(ms(1000)) => panic!(), + } + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + select! { + send(s, 7) -> res => res.unwrap(), + } + }); + }) + .unwrap(); +} + +#[test] +fn try_send() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + select! { + send(s, 7) -> _ => panic!(), + default => {} + } + thread::sleep(ms(1500)); + select! { + send(s, 8) -> res => res.unwrap(), + default => panic!(), + } + thread::sleep(ms(500)); + select! { + send(s, 8) -> res => assert_eq!(res, Err(SendError(8))), + default => panic!(), + } + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + select! { + recv(r) -> v => assert_eq!(v, Ok(8)), + } + }); + }) + .unwrap(); +} + +#[test] +fn send() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + select! { + send(s, 7) -> res => res.unwrap(), + } + thread::sleep(ms(1000)); + select! { + send(s, 8) -> res => res.unwrap(), + } + thread::sleep(ms(1000)); + select! { + send(s, 9) -> res => res.unwrap(), + } + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + select! { + recv(r) -> v => assert_eq!(v, Ok(7)), + } + select! { + recv(r) -> v => assert_eq!(v, Ok(8)), + } + select! { + recv(r) -> v => assert_eq!(v, Ok(9)), + } + }); + }) + .unwrap(); +} + +#[test] +fn send_timeout() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + select! { + send(s, 7) -> _ => panic!(), + default(ms(1000)) => {} + } + select! { + send(s, 8) -> res => res.unwrap(), + default(ms(1000)) => panic!(), + } + select! { + send(s, 9) -> res => assert_eq!(res, Err(SendError(9))), + default(ms(1000)) => panic!(), + } + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + select! { + recv(r) -> v => assert_eq!(v, Ok(8)), + } + }); + }) + .unwrap(); +} + +#[test] +fn disconnect_wakes_sender() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + select! { + send(s, ()) -> res => assert_eq!(res, Err(SendError(()))), + } + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + drop(r); + }); + }) + .unwrap(); +} + +#[test] +fn disconnect_wakes_receiver() { + let (s, r) = bounded::<()>(0); + + scope(|scope| { + scope.spawn(move |_| { + select! { + recv(r) -> res => assert_eq!(res, Err(RecvError)), + } + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + drop(s); + }); + }) + .unwrap(); +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/thread_locals.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/thread_locals.rs new file mode 100644 index 0000000..fd319c7 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/thread_locals.rs @@ -0,0 +1,55 @@ +//! Tests that make sure accessing thread-locals while exiting the thread doesn't cause panics. + +#[macro_use] +extern crate crossbeam_channel; +extern crate crossbeam_utils; + +use std::thread; +use std::time::Duration; + +use crossbeam_channel::unbounded; +use crossbeam_utils::thread::scope; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +#[cfg_attr(target_os = "macos", ignore = "TLS is destroyed too early on macOS")] +fn use_while_exiting() { + struct Foo; + + impl Drop for Foo { + fn drop(&mut self) { + // A blocking operation after the thread-locals have been dropped. This will attempt to + // use the thread-locals and must not panic. + let (_s, r) = unbounded::<()>(); + select! { + recv(r) -> _ => {} + default(ms(100)) => {} + } + } + } + + thread_local! { + static FOO: Foo = Foo; + } + + let (s, r) = unbounded::<()>(); + + scope(|scope| { + scope.spawn(|_| { + // First initialize `FOO`, then the thread-locals related to crossbeam-channel. + FOO.with(|_| ()); + r.recv().unwrap(); + // At thread exit, thread-locals related to crossbeam-channel get dropped first and + // `FOO` is dropped last. + }); + + scope.spawn(|_| { + thread::sleep(ms(100)); + s.send(()).unwrap(); + }); + }) + .unwrap(); +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/tick.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/tick.rs new file mode 100644 index 0000000..34e55b3 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/tick.rs @@ -0,0 +1,353 @@ +//! Tests for the tick channel flavor. + +#[macro_use] +extern crate crossbeam_channel; +extern crate crossbeam_utils; +extern crate rand; + +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; +use std::thread; +use std::time::{Duration, Instant}; + +use crossbeam_channel::{after, tick, Select, TryRecvError}; +use crossbeam_utils::thread::scope; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +fn fire() { + let start = Instant::now(); + let r = tick(ms(50)); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + thread::sleep(ms(100)); + + let fired = r.try_recv().unwrap(); + assert!(start < fired); + assert!(fired - start >= ms(50)); + + let now = Instant::now(); + assert!(fired < now); + assert!(now - fired >= ms(50)); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + + select! { + recv(r) -> _ => panic!(), + default => {} + } + + select! { + recv(r) -> _ => {} + recv(tick(ms(200))) -> _ => panic!(), + } +} + +#[test] +fn intervals() { + let start = Instant::now(); + let r = tick(ms(50)); + + let t1 = r.recv().unwrap(); + assert!(start + ms(50) <= t1); + assert!(start + ms(100) > t1); + + thread::sleep(ms(300)); + let t2 = r.try_recv().unwrap(); + assert!(start + ms(100) <= t2); + assert!(start + ms(150) > t2); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + let t3 = r.recv().unwrap(); + assert!(start + ms(400) <= t3); + assert!(start + ms(450) > t3); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn capacity() { + const COUNT: usize = 10; + + for i in 0..COUNT { + let r = tick(ms(i as u64)); + assert_eq!(r.capacity(), Some(1)); + } +} + +#[test] +fn len_empty_full() { + let r = tick(ms(50)); + + assert_eq!(r.len(), 0); + assert_eq!(r.is_empty(), true); + assert_eq!(r.is_full(), false); + + thread::sleep(ms(100)); + + assert_eq!(r.len(), 1); + assert_eq!(r.is_empty(), false); + assert_eq!(r.is_full(), true); + + r.try_recv().unwrap(); + + assert_eq!(r.len(), 0); + assert_eq!(r.is_empty(), true); + assert_eq!(r.is_full(), false); +} + +#[test] +fn try_recv() { + let r = tick(ms(200)); + assert!(r.try_recv().is_err()); + + thread::sleep(ms(100)); + assert!(r.try_recv().is_err()); + + thread::sleep(ms(200)); + assert!(r.try_recv().is_ok()); + assert!(r.try_recv().is_err()); + + thread::sleep(ms(200)); + assert!(r.try_recv().is_ok()); + assert!(r.try_recv().is_err()); +} + +#[test] +fn recv() { + let start = Instant::now(); + let r = tick(ms(50)); + + let fired = r.recv().unwrap(); + assert!(start < fired); + assert!(fired - start >= ms(50)); + + let now = Instant::now(); + assert!(fired < now); + assert!(now - fired < fired - start); + + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn recv_timeout() { + let start = Instant::now(); + let r = tick(ms(200)); + + assert!(r.recv_timeout(ms(100)).is_err()); + let now = Instant::now(); + assert!(now - start >= ms(100)); + assert!(now - start <= ms(150)); + + let fired = r.recv_timeout(ms(200)).unwrap(); + assert!(fired - start >= ms(200)); + assert!(fired - start <= ms(250)); + + assert!(r.recv_timeout(ms(100)).is_err()); + let now = Instant::now(); + assert!(now - start >= ms(300)); + assert!(now - start <= ms(350)); + + let fired = r.recv_timeout(ms(200)).unwrap(); + assert!(fired - start >= ms(400)); + assert!(fired - start <= ms(450)); +} + +#[test] +fn recv_two() { + let r1 = tick(ms(50)); + let r2 = tick(ms(50)); + + scope(|scope| { + scope.spawn(|_| { + for _ in 0..10 { + select! { + recv(r1) -> _ => {} + recv(r2) -> _ => {} + } + } + }); + scope.spawn(|_| { + for _ in 0..10 { + select! { + recv(r1) -> _ => {} + recv(r2) -> _ => {} + } + } + }); + }) + .unwrap(); +} + +#[test] +fn recv_race() { + select! { + recv(tick(ms(50))) -> _ => {} + recv(tick(ms(100))) -> _ => panic!(), + } + + select! { + recv(tick(ms(100))) -> _ => panic!(), + recv(tick(ms(50))) -> _ => {} + } +} + +#[test] +fn stress_default() { + const COUNT: usize = 10; + + for _ in 0..COUNT { + select! { + recv(tick(ms(0))) -> _ => {} + default => panic!(), + } + } + + for _ in 0..COUNT { + select! { + recv(tick(ms(100))) -> _ => panic!(), + default => {} + } + } +} + +#[test] +fn select() { + const THREADS: usize = 4; + + let hits = AtomicUsize::new(0); + let r1 = tick(ms(200)); + let r2 = tick(ms(300)); + + scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + let timeout = after(ms(1100)); + loop { + let mut sel = Select::new(); + let oper1 = sel.recv(&r1); + let oper2 = sel.recv(&r2); + let oper3 = sel.recv(&timeout); + let oper = sel.select(); + match oper.index() { + i if i == oper1 => { + oper.recv(&r1).unwrap(); + hits.fetch_add(1, Ordering::SeqCst); + } + i if i == oper2 => { + oper.recv(&r2).unwrap(); + hits.fetch_add(1, Ordering::SeqCst); + } + i if i == oper3 => { + oper.recv(&timeout).unwrap(); + break; + } + _ => unreachable!(), + } + } + }); + } + }) + .unwrap(); + + assert_eq!(hits.load(Ordering::SeqCst), 8); +} + +#[test] +fn ready() { + const THREADS: usize = 4; + + let hits = AtomicUsize::new(0); + let r1 = tick(ms(200)); + let r2 = tick(ms(300)); + + scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + let timeout = after(ms(1100)); + 'outer: loop { + let mut sel = Select::new(); + sel.recv(&r1); + sel.recv(&r2); + sel.recv(&timeout); + loop { + match sel.ready() { + 0 => { + if r1.try_recv().is_ok() { + hits.fetch_add(1, Ordering::SeqCst); + break; + } + } + 1 => { + if r2.try_recv().is_ok() { + hits.fetch_add(1, Ordering::SeqCst); + break; + } + } + 2 => { + if timeout.try_recv().is_ok() { + break 'outer; + } + } + _ => unreachable!(), + } + } + } + }); + } + }) + .unwrap(); + + assert_eq!(hits.load(Ordering::SeqCst), 8); +} + +#[test] +fn fairness() { + const COUNT: usize = 30; + + for &dur in &[0, 1] { + let mut hits = [0usize; 2]; + + for _ in 0..COUNT { + let r1 = tick(ms(dur)); + let r2 = tick(ms(dur)); + + for _ in 0..COUNT { + select! { + recv(r1) -> _ => hits[0] += 1, + recv(r2) -> _ => hits[1] += 1, + } + } + } + + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); + } +} + +#[test] +fn fairness_duplicates() { + const COUNT: usize = 30; + + for &dur in &[0, 1] { + let mut hits = [0usize; 5]; + + for _ in 0..COUNT { + let r = tick(ms(dur)); + + for _ in 0..COUNT { + select! { + recv(r) -> _ => hits[0] += 1, + recv(r) -> _ => hits[1] += 1, + recv(r) -> _ => hits[2] += 1, + recv(r) -> _ => hits[3] += 1, + recv(r) -> _ => hits[4] += 1, + } + } + } + + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); + } +} diff --git a/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/zero.rs b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/zero.rs new file mode 100644 index 0000000..b38227d --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-channel-0.3.9/tests/zero.rs @@ -0,0 +1,559 @@ +//! Tests for the zero channel flavor. + +#[macro_use] +extern crate crossbeam_channel; +extern crate crossbeam_utils; +extern crate rand; + +use std::any::Any; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; +use std::thread; +use std::time::Duration; + +use crossbeam_channel::{bounded, Receiver}; +use crossbeam_channel::{RecvError, RecvTimeoutError, TryRecvError}; +use crossbeam_channel::{SendError, SendTimeoutError, TrySendError}; +use crossbeam_utils::thread::scope; +use rand::{thread_rng, Rng}; + +fn ms(ms: u64) -> Duration { + Duration::from_millis(ms) +} + +#[test] +fn smoke() { + let (s, r) = bounded(0); + assert_eq!(s.try_send(7), Err(TrySendError::Full(7))); + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn capacity() { + let (s, r) = bounded::<()>(0); + assert_eq!(s.capacity(), Some(0)); + assert_eq!(r.capacity(), Some(0)); +} + +#[test] +fn len_empty_full() { + let (s, r) = bounded(0); + + assert_eq!(s.len(), 0); + assert_eq!(s.is_empty(), true); + assert_eq!(s.is_full(), true); + assert_eq!(r.len(), 0); + assert_eq!(r.is_empty(), true); + assert_eq!(r.is_full(), true); + + scope(|scope| { + scope.spawn(|_| s.send(0).unwrap()); + scope.spawn(|_| r.recv().unwrap()); + }) + .unwrap(); + + assert_eq!(s.len(), 0); + assert_eq!(s.is_empty(), true); + assert_eq!(s.is_full(), true); + assert_eq!(r.len(), 0); + assert_eq!(r.is_empty(), true); + assert_eq!(r.is_full(), true); +} + +#[test] +fn try_recv() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.try_recv(), Err(TryRecvError::Empty)); + thread::sleep(ms(1500)); + assert_eq!(r.try_recv(), Ok(7)); + thread::sleep(ms(500)); + assert_eq!(r.try_recv(), Err(TryRecvError::Disconnected)); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + s.send(7).unwrap(); + }); + }) + .unwrap(); +} + +#[test] +fn recv() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.recv(), Ok(7)); + thread::sleep(ms(1000)); + assert_eq!(r.recv(), Ok(8)); + thread::sleep(ms(1000)); + assert_eq!(r.recv(), Ok(9)); + assert_eq!(r.recv(), Err(RecvError)); + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + s.send(7).unwrap(); + s.send(8).unwrap(); + s.send(9).unwrap(); + }); + }) + .unwrap(); +} + +#[test] +fn recv_timeout() { + let (s, r) = bounded::(0); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.recv_timeout(ms(1000)), Err(RecvTimeoutError::Timeout)); + assert_eq!(r.recv_timeout(ms(1000)), Ok(7)); + assert_eq!( + r.recv_timeout(ms(1000)), + Err(RecvTimeoutError::Disconnected) + ); + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + s.send(7).unwrap(); + }); + }) + .unwrap(); +} + +#[test] +fn try_send() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(s.try_send(7), Err(TrySendError::Full(7))); + thread::sleep(ms(1500)); + assert_eq!(s.try_send(8), Ok(())); + thread::sleep(ms(500)); + assert_eq!(s.try_send(9), Err(TrySendError::Disconnected(9))); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + assert_eq!(r.recv(), Ok(8)); + }); + }) + .unwrap(); +} + +#[test] +fn send() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + s.send(7).unwrap(); + thread::sleep(ms(1000)); + s.send(8).unwrap(); + thread::sleep(ms(1000)); + s.send(9).unwrap(); + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + assert_eq!(r.recv(), Ok(7)); + assert_eq!(r.recv(), Ok(8)); + assert_eq!(r.recv(), Ok(9)); + }); + }) + .unwrap(); +} + +#[test] +fn send_timeout() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!( + s.send_timeout(7, ms(1000)), + Err(SendTimeoutError::Timeout(7)) + ); + assert_eq!(s.send_timeout(8, ms(1000)), Ok(())); + assert_eq!( + s.send_timeout(9, ms(1000)), + Err(SendTimeoutError::Disconnected(9)) + ); + }); + scope.spawn(move |_| { + thread::sleep(ms(1500)); + assert_eq!(r.recv(), Ok(8)); + }); + }) + .unwrap(); +} + +#[test] +fn len() { + const COUNT: usize = 25_000; + + let (s, r) = bounded(0); + + assert_eq!(s.len(), 0); + assert_eq!(r.len(), 0); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + assert_eq!(r.recv(), Ok(i)); + assert_eq!(r.len(), 0); + } + }); + + scope.spawn(|_| { + for i in 0..COUNT { + s.send(i).unwrap(); + assert_eq!(s.len(), 0); + } + }); + }) + .unwrap(); + + assert_eq!(s.len(), 0); + assert_eq!(r.len(), 0); +} + +#[test] +fn disconnect_wakes_sender() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(s.send(()), Err(SendError(()))); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + drop(r); + }); + }) + .unwrap(); +} + +#[test] +fn disconnect_wakes_receiver() { + let (s, r) = bounded::<()>(0); + + scope(|scope| { + scope.spawn(move |_| { + assert_eq!(r.recv(), Err(RecvError)); + }); + scope.spawn(move |_| { + thread::sleep(ms(1000)); + drop(s); + }); + }) + .unwrap(); +} + +#[test] +fn spsc() { + const COUNT: usize = 100_000; + + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + for i in 0..COUNT { + assert_eq!(r.recv(), Ok(i)); + } + assert_eq!(r.recv(), Err(RecvError)); + }); + scope.spawn(move |_| { + for i in 0..COUNT { + s.send(i).unwrap(); + } + }); + }) + .unwrap(); +} + +#[test] +fn mpmc() { + const COUNT: usize = 25_000; + const THREADS: usize = 4; + + let (s, r) = bounded::(0); + let v = (0..COUNT).map(|_| AtomicUsize::new(0)).collect::>(); + + scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + for _ in 0..COUNT { + let n = r.recv().unwrap(); + v[n].fetch_add(1, Ordering::SeqCst); + } + }); + } + for _ in 0..THREADS { + scope.spawn(|_| { + for i in 0..COUNT { + s.send(i).unwrap(); + } + }); + } + }) + .unwrap(); + + for c in v { + assert_eq!(c.load(Ordering::SeqCst), THREADS); + } +} + +#[test] +fn stress_oneshot() { + const COUNT: usize = 10_000; + + for _ in 0..COUNT { + let (s, r) = bounded(1); + + scope(|scope| { + scope.spawn(|_| r.recv().unwrap()); + scope.spawn(|_| s.send(0).unwrap()); + }) + .unwrap(); + } +} + +#[test] +fn stress_iter() { + const COUNT: usize = 1000; + + let (request_s, request_r) = bounded(0); + let (response_s, response_r) = bounded(0); + + scope(|scope| { + scope.spawn(move |_| { + let mut count = 0; + loop { + for x in response_r.try_iter() { + count += x; + if count == COUNT { + return; + } + } + let _ = request_s.try_send(()); + } + }); + + for _ in request_r.iter() { + if response_s.send(1).is_err() { + break; + } + } + }) + .unwrap(); +} + +#[test] +fn stress_timeout_two_threads() { + const COUNT: usize = 100; + + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(50)); + } + loop { + if let Ok(()) = s.send_timeout(i, ms(10)) { + break; + } + } + } + }); + + scope.spawn(|_| { + for i in 0..COUNT { + if i % 2 == 0 { + thread::sleep(ms(50)); + } + loop { + if let Ok(x) = r.recv_timeout(ms(10)) { + assert_eq!(x, i); + break; + } + } + } + }); + }) + .unwrap(); +} + +#[test] +fn drops() { + static DROPS: AtomicUsize = AtomicUsize::new(0); + + #[derive(Debug, PartialEq)] + struct DropCounter; + + impl Drop for DropCounter { + fn drop(&mut self) { + DROPS.fetch_add(1, Ordering::SeqCst); + } + } + + let mut rng = thread_rng(); + + for _ in 0..100 { + let steps = rng.gen_range(0, 3_000); + + DROPS.store(0, Ordering::SeqCst); + let (s, r) = bounded::(0); + + scope(|scope| { + scope.spawn(|_| { + for _ in 0..steps { + r.recv().unwrap(); + } + }); + + scope.spawn(|_| { + for _ in 0..steps { + s.send(DropCounter).unwrap(); + } + }); + }) + .unwrap(); + + assert_eq!(DROPS.load(Ordering::SeqCst), steps); + drop(s); + drop(r); + assert_eq!(DROPS.load(Ordering::SeqCst), steps); + } +} + +#[test] +fn fairness() { + const COUNT: usize = 10_000; + + let (s1, r1) = bounded::<()>(0); + let (s2, r2) = bounded::<()>(0); + + scope(|scope| { + scope.spawn(|_| { + let mut hits = [0usize; 2]; + for _ in 0..COUNT { + select! { + recv(r1) -> _ => hits[0] += 1, + recv(r2) -> _ => hits[1] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); + }); + + let mut hits = [0usize; 2]; + for _ in 0..COUNT { + select! { + send(s1, ()) -> _ => hits[0] += 1, + send(s2, ()) -> _ => hits[1] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); + }) + .unwrap(); +} + +#[test] +fn fairness_duplicates() { + const COUNT: usize = 10_000; + + let (s, r) = bounded::<()>(0); + + scope(|scope| { + scope.spawn(|_| { + let mut hits = [0usize; 5]; + for _ in 0..COUNT { + select! { + recv(r) -> _ => hits[0] += 1, + recv(r) -> _ => hits[1] += 1, + recv(r) -> _ => hits[2] += 1, + recv(r) -> _ => hits[3] += 1, + recv(r) -> _ => hits[4] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); + }); + + let mut hits = [0usize; 5]; + for _ in 0..COUNT { + select! { + send(s, ()) -> _ => hits[0] += 1, + send(s, ()) -> _ => hits[1] += 1, + send(s, ()) -> _ => hits[2] += 1, + send(s, ()) -> _ => hits[3] += 1, + send(s, ()) -> _ => hits[4] += 1, + } + } + assert!(hits.iter().all(|x| *x >= COUNT / hits.len() / 2)); + }) + .unwrap(); +} + +#[test] +fn recv_in_send() { + let (s, r) = bounded(0); + + scope(|scope| { + scope.spawn(|_| { + thread::sleep(ms(100)); + r.recv() + }); + + scope.spawn(|_| { + thread::sleep(ms(500)); + s.send(()).unwrap(); + }); + + select! { + send(s, r.recv().unwrap()) -> _ => {} + } + }) + .unwrap(); +} + +#[test] +fn channel_through_channel() { + const COUNT: usize = 1000; + + type T = Box; + + let (s, r) = bounded::(0); + + scope(|scope| { + scope.spawn(move |_| { + let mut s = s; + + for _ in 0..COUNT { + let (new_s, new_r) = bounded(0); + let new_r: T = Box::new(Some(new_r)); + + s.send(new_r).unwrap(); + s = new_s; + } + }); + + scope.spawn(move |_| { + let mut r = r; + + for _ in 0..COUNT { + r = r + .recv() + .unwrap() + .downcast_mut::>>() + .unwrap() + .take() + .unwrap() + } + }); + }) + .unwrap(); +} diff --git a/third_party/cargo/vendor/crossbeam-deque-0.6.3/.cargo-checksum.json b/third_party/cargo/vendor/crossbeam-deque-0.6.3/.cargo-checksum.json new file mode 100644 index 0000000..924b2b0 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-deque-0.6.3/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"8c3a2735652220d8601067e0fa560b8c1146671fefb41a78f1cd4d08a12fe697","Cargo.toml":"f221e962c757551c11c9e145b5ef6dc943a8d4670d2230e76c8a6642c2667952","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"b9257b4c9a56e01992ad1ea6dc65e2928cfb27475222e5ef521f9469b8870e48","src/lib.rs":"54d40e045740c2ed857e0b04992b4f718404ec0af48938a9ae33ae59f73e2d84","tests/fifo.rs":"54b78bdd4f53e217291451bef579cdbe571b290ddde7f40dce05c5160a0c2de8","tests/lifo.rs":"8393e2f8f689135d4e9a3ea2da39d665b6cbe55a53be2d07f83969506a8003a6"},"package":"05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13"} \ No newline at end of file diff --git a/third_party/cargo/vendor/crossbeam-deque-0.6.3/BUILD b/third_party/cargo/vendor/crossbeam-deque-0.6.3/BUILD new file mode 100644 index 0000000..e9ba6b2 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-deque-0.6.3/BUILD @@ -0,0 +1,46 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "crossbeam_deque", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/crossbeam-epoch-0.7.2:crossbeam_epoch", + "//third_party/cargo/vendor/crossbeam-utils-0.6.6:crossbeam_utils", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.3", + crate_features = [ + ], +) + +# Unsupported target "fifo" with type "test" omitted +# Unsupported target "lifo" with type "test" omitted diff --git a/third_party/cargo/vendor/crossbeam-deque-0.6.3/CHANGELOG.md b/third_party/cargo/vendor/crossbeam-deque-0.6.3/CHANGELOG.md new file mode 100644 index 0000000..15fa29f --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-deque-0.6.3/CHANGELOG.md @@ -0,0 +1,71 @@ +# Version 0.6.3 + +- Bump `crossbeam-epoch` to `0.7`. + +# Version 0.6.2 + +- Update `crosbeam-utils` to `0.6`. + +# Version 0.6.1 + +- Change a few `Relaxed` orderings to `Release` in order to fix false positives by tsan. + +# Version 0.6.0 + +- Add `Stealer::steal_many` for batched stealing. +- Change the return type of `pop` to `Pop` so that spinning can be handled manually. + +# Version 0.5.2 + +- Update `crossbeam-utils` to `0.5.0`. + +# Version 0.5.1 + +- Minor optimizations. + +# Version 0.5.0 + +- Add two deque constructors : `fifo()` and `lifo()`. +- Update `rand` to `0.5.3`. +- Rename `Deque` to `Worker`. +- Return `Option` from `Stealer::steal`. +- Remove methods `Deque::len` and `Stealer::len`. +- Remove method `Deque::stealer`. +- Remove method `Deque::steal`. + +# Version 0.4.1 + +- Update `crossbeam-epoch` to `0.5.0`. + +# Version 0.4.0 + +- Update `crossbeam-epoch` to `0.4.2`. +- Update `crossbeam-utils` to `0.4.0`. +- Require minimum Rust version 1.25. + +# Version 0.3.1 + +- Add `Deque::capacity`. +- Add `Deque::min_capacity`. +- Add `Deque::shrink_to_fit`. +- Update `crossbeam-epoch` to `0.3.0`. +- Support Rust 1.20. +- Shrink the buffer in `Deque::push` if necessary. + +# Version 0.3.0 + +- Update `crossbeam-epoch` to `0.4.0`. +- Drop support for Rust 1.13. + +# Version 0.2.0 + +- Update `crossbeam-epoch` to `0.3.0`. +- Support Rust 1.13. + +# Version 0.1.1 + +- Update `crossbeam-epoch` to `0.2.0`. + +# Version 0.1.0 + +- First implementation of the Chase-Lev deque. diff --git a/third_party/cargo/vendor/crossbeam-deque-0.6.3/Cargo.toml b/third_party/cargo/vendor/crossbeam-deque-0.6.3/Cargo.toml new file mode 100644 index 0000000..f22f5aa --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-deque-0.6.3/Cargo.toml @@ -0,0 +1,31 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "crossbeam-deque" +version = "0.6.3" +authors = ["The Crossbeam Project Developers"] +description = "Concurrent work-stealing deque" +homepage = "https://github.com/crossbeam-rs/crossbeam" +documentation = "https://docs.rs/crossbeam-deque" +readme = "README.md" +keywords = ["chase-lev", "lock-free", "scheduler", "scheduling"] +categories = ["algorithms", "concurrency", "data-structures"] +license = "MIT/Apache-2.0" +repository = "https://github.com/crossbeam-rs/crossbeam" +[dependencies.crossbeam-epoch] +version = "0.7" + +[dependencies.crossbeam-utils] +version = "0.6" +[dev-dependencies.rand] +version = "0.6" diff --git a/third_party/cargo/vendor/crossbeam-deque-0.6.3/LICENSE-APACHE b/third_party/cargo/vendor/crossbeam-deque-0.6.3/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-deque-0.6.3/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/crossbeam-deque-0.6.3/LICENSE-MIT b/third_party/cargo/vendor/crossbeam-deque-0.6.3/LICENSE-MIT new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-deque-0.6.3/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/crossbeam-deque-0.6.3/README.md b/third_party/cargo/vendor/crossbeam-deque-0.6.3/README.md new file mode 100644 index 0000000..7ebebd0 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-deque-0.6.3/README.md @@ -0,0 +1,51 @@ +# Crossbeam Deque + +[![Build Status](https://travis-ci.org/crossbeam-rs/crossbeam.svg?branch=master)]( +https://travis-ci.org/crossbeam-rs/crossbeam) +[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)]( +https://github.com/crossbeam-rs/crossbeam-deque) +[![Cargo](https://img.shields.io/crates/v/crossbeam-deque.svg)]( +https://crates.io/crates/crossbeam-deque) +[![Documentation](https://docs.rs/crossbeam-deque/badge.svg)]( +https://docs.rs/crossbeam-deque) +[![Rust 1.26+](https://img.shields.io/badge/rust-1.26+-lightgray.svg)]( +https://www.rust-lang.org) + +This crate provides work-stealing deques, which are primarily intended for +building task schedulers. + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +crossbeam-deque = "0.6" +``` + +Next, add this to your crate: + +```rust +extern crate crossbeam_deque; +``` + +## Compatibility + +The minimum supported Rust version is 1.26. + +This crate does not work in `no_std` environments. + +## License + +Licensed under either of + + * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/crossbeam-deque-0.6.3/src/lib.rs b/third_party/cargo/vendor/crossbeam-deque-0.6.3/src/lib.rs new file mode 100644 index 0000000..87e8c77 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-deque-0.6.3/src/lib.rs @@ -0,0 +1,879 @@ +//! A concurrent work-stealing deque. +//! +//! This data structure is most commonly used in schedulers. The typical setup involves a number of +//! threads where each thread has its own deque containing tasks. A thread may push tasks into its +//! deque as well as pop tasks from it. Once it runs out of tasks, it may steal some from other +//! threads to help complete tasks more quickly. Therefore, work-stealing deques supports three +//! essential operations: *push*, *pop*, and *steal*. +//! +//! # Types of deques +//! +//! There are two types of deques, differing only in which order tasks get pushed and popped. The +//! two task ordering strategies are: +//! +//! * First-in first-out (FIFO) +//! * Last-in first-out (LIFO) +//! +//! A deque is a buffer with two ends, front and back. In a FIFO deque, tasks are pushed into the +//! back, popped from the front, and stolen from the front. However, in a LIFO deque, tasks are +//! popped from the back instead - that is the only difference. +//! +//! # Workers and stealers +//! +//! There are two functions that construct a deque: [`fifo`] and [`lifo`]. These functions return a +//! [`Worker`] and a [`Stealer`]. The thread which owns the deque is usually called *worker*, while +//! all other threads are *stealers*. +//! +//! [`Worker`] is able to push and pop tasks. It cannot be shared among multiple threads - only +//! one thread owns it. +//! +//! [`Stealer`] can only steal tasks. It can be shared among multiple threads by reference or by +//! cloning. Cloning a [`Stealer`] simply creates another one associated with the same deque. +//! +//! # Examples +//! +//! ``` +//! use crossbeam_deque::{self as deque, Pop, Steal}; +//! use std::thread; +//! +//! // Create a LIFO deque. +//! let (w, s) = deque::lifo(); +//! +//! // Push several elements into the back. +//! w.push(1); +//! w.push(2); +//! w.push(3); +//! +//! // This is a LIFO deque, which means an element is popped from the back. +//! // If it was a FIFO deque, `w.pop()` would return `Some(1)`. +//! assert_eq!(w.pop(), Pop::Data(3)); +//! +//! // Create a stealer thread. +//! thread::spawn(move || { +//! assert_eq!(s.steal(), Steal::Data(1)); +//! assert_eq!(s.steal(), Steal::Data(2)); +//! }).join().unwrap(); +//! ``` +//! +//! [`Worker`]: struct.Worker.html +//! [`Stealer`]: struct.Stealer.html +//! [`fifo`]: fn.fifo.html +//! [`lifo`]: fn.lifo.html + +#![warn(missing_docs)] +#![warn(missing_debug_implementations)] + +extern crate crossbeam_epoch as epoch; +extern crate crossbeam_utils as utils; + +use std::cell::Cell; +use std::cmp; +use std::fmt; +use std::marker::PhantomData; +use std::mem; +use std::ptr; +use std::sync::atomic::{self, AtomicIsize, Ordering}; +use std::sync::Arc; + +use epoch::{Atomic, Owned}; +use utils::CachePadded; + +/// Minimum buffer capacity for a deque. +const MIN_CAP: usize = 32; + +/// Maximum number of additional elements that can be stolen in `steal_many`. +const MAX_BATCH: usize = 128; + +/// If a buffer of at least this size is retired, thread-local garbage is flushed so that it gets +/// deallocated as soon as possible. +const FLUSH_THRESHOLD_BYTES: usize = 1 << 10; + +/// Creates a work-stealing deque with the first-in first-out strategy. +/// +/// Elements are pushed into the back, popped from the front, and stolen from the front. In other +/// words, the worker side behaves as a FIFO queue. +/// +/// # Examples +/// +/// ``` +/// use crossbeam_deque::{self as deque, Pop, Steal}; +/// +/// let (w, s) = deque::fifo::(); +/// w.push(1); +/// w.push(2); +/// w.push(3); +/// +/// assert_eq!(s.steal(), Steal::Data(1)); +/// assert_eq!(w.pop(), Pop::Data(2)); +/// assert_eq!(w.pop(), Pop::Data(3)); +/// ``` +pub fn fifo() -> (Worker, Stealer) { + let buffer = Buffer::alloc(MIN_CAP); + + let inner = Arc::new(CachePadded::new(Inner { + front: AtomicIsize::new(0), + back: AtomicIsize::new(0), + buffer: Atomic::new(buffer), + })); + + let w = Worker { + inner: inner.clone(), + cached_buffer: Cell::new(buffer), + flavor: Flavor::Fifo, + _marker: PhantomData, + }; + let s = Stealer { + inner, + flavor: Flavor::Fifo, + }; + (w, s) +} + +/// Creates a work-stealing deque with the last-in first-out strategy. +/// +/// Elements are pushed into the back, popped from the back, and stolen from the front. In other +/// words, the worker side behaves as a LIFO stack. +/// +/// # Examples +/// +/// ``` +/// use crossbeam_deque::{self as deque, Pop, Steal}; +/// +/// let (w, s) = deque::lifo::(); +/// w.push(1); +/// w.push(2); +/// w.push(3); +/// +/// assert_eq!(s.steal(), Steal::Data(1)); +/// assert_eq!(w.pop(), Pop::Data(3)); +/// assert_eq!(w.pop(), Pop::Data(2)); +/// ``` +pub fn lifo() -> (Worker, Stealer) { + let buffer = Buffer::alloc(MIN_CAP); + + let inner = Arc::new(CachePadded::new(Inner { + front: AtomicIsize::new(0), + back: AtomicIsize::new(0), + buffer: Atomic::new(buffer), + })); + + let w = Worker { + inner: inner.clone(), + cached_buffer: Cell::new(buffer), + flavor: Flavor::Lifo, + _marker: PhantomData, + }; + let s = Stealer { + inner, + flavor: Flavor::Lifo, + }; + (w, s) +} + +/// A buffer that holds elements in a deque. +/// +/// This is just a pointer to the buffer and its length - dropping an instance of this struct will +/// *not* deallocate the buffer. +struct Buffer { + /// Pointer to the allocated memory. + ptr: *mut T, + + /// Capacity of the buffer. Always a power of two. + cap: usize, +} + +unsafe impl Send for Buffer {} + +impl Buffer { + /// Allocates a new buffer with the specified capacity. + fn alloc(cap: usize) -> Self { + debug_assert_eq!(cap, cap.next_power_of_two()); + + let mut v = Vec::with_capacity(cap); + let ptr = v.as_mut_ptr(); + mem::forget(v); + + Buffer { ptr, cap } + } + + /// Deallocates the buffer. + unsafe fn dealloc(self) { + drop(Vec::from_raw_parts(self.ptr, 0, self.cap)); + } + + /// Returns a pointer to the element at the specified `index`. + unsafe fn at(&self, index: isize) -> *mut T { + // `self.cap` is always a power of two. + self.ptr.offset(index & (self.cap - 1) as isize) + } + + /// Writes `value` into the specified `index`. + /// + /// Using this concurrently with another `read` or `write` is technically + /// speaking UB due to data races. We should be using relaxed accesses, but + /// that would cost too much performance. Hence, as a HACK, we use volatile + /// accesses instead. Experimental evidence shows that this works. + unsafe fn write(&self, index: isize, value: T) { + ptr::write_volatile(self.at(index), value) + } + + /// Reads a value from the specified `index`. + /// + /// Using this concurrently with a `write` is technically speaking UB due to + /// data races. We should be using relaxed accesses, but that would cost + /// too much performance. Hence, as a HACK, we use volatile accesses + /// instead. Experimental evidence shows that this works. + unsafe fn read(&self, index: isize) -> T { + ptr::read_volatile(self.at(index)) + } +} + +impl Clone for Buffer { + fn clone(&self) -> Buffer { + Buffer { + ptr: self.ptr, + cap: self.cap, + } + } +} + +impl Copy for Buffer {} + +/// Possible outcomes of a pop operation. +#[must_use] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)] +pub enum Pop { + /// The deque was empty at the time of popping. + Empty, + + /// Some data has been successfully popped. + Data(T), + + /// Lost the race for popping data to another concurrent steal operation. Try again. + Retry, +} + +/// Possible outcomes of a steal operation. +#[must_use] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)] +pub enum Steal { + /// The deque was empty at the time of stealing. + Empty, + + /// Some data has been successfully stolen. + Data(T), + + /// Lost the race for stealing data to another concurrent steal or pop operation. Try again. + Retry, +} + +/// Internal data that is shared between the worker and stealers. +/// +/// The implementation is based on the following work: +/// +/// 1. [Chase and Lev. Dynamic circular work-stealing deque. SPAA 2005.][chase-lev] +/// 2. [Le, Pop, Cohen, and Nardelli. Correct and efficient work-stealing for weak memory models. +/// PPoPP 2013.][weak-mem] +/// 3. [Norris and Demsky. CDSchecker: checking concurrent data structures written with C/C++ +/// atomics. OOPSLA 2013.][checker] +/// +/// [chase-lev]: https://dl.acm.org/citation.cfm?id=1073974 +/// [weak-mem]: https://dl.acm.org/citation.cfm?id=2442524 +/// [checker]: https://dl.acm.org/citation.cfm?id=2509514 +struct Inner { + /// The front index. + front: AtomicIsize, + + /// The back index. + back: AtomicIsize, + + /// The underlying buffer. + buffer: Atomic>, +} + +impl Drop for Inner { + fn drop(&mut self) { + // Load the back index, front index, and buffer. + let b = self.back.load(Ordering::Relaxed); + let f = self.front.load(Ordering::Relaxed); + + unsafe { + let buffer = self.buffer.load(Ordering::Relaxed, epoch::unprotected()); + + // Go through the buffer from front to back and drop all elements in the deque. + let mut i = f; + while i != b { + ptr::drop_in_place(buffer.deref().at(i)); + i = i.wrapping_add(1); + } + + // Free the memory allocated by the buffer. + buffer.into_owned().into_box().dealloc(); + } + } +} + +/// The flavor of a deque: FIFO or LIFO. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +enum Flavor { + /// The first-in first-out flavor. + Fifo, + + /// The last-in first-out flavor. + Lifo, +} + +/// The worker side of a deque. +/// +/// Workers push elements into the back and pop elements depending on the strategy: +/// +/// * In FIFO deques, elements are popped from the front. +/// * In LIFO deques, elements are popped from the back. +/// +/// A deque has only one worker. Workers are not intended to be shared among multiple threads. +pub struct Worker { + /// A reference to the inner representation of the deque. + inner: Arc>>, + + /// A copy of `inner.buffer` for quick access. + cached_buffer: Cell>, + + /// The flavor of the deque. + flavor: Flavor, + + /// Indicates that the worker cannot be shared among threads. + _marker: PhantomData<*mut ()>, // !Send + !Sync +} + +unsafe impl Send for Worker {} + +impl Worker { + /// Resizes the internal buffer to the new capacity of `new_cap`. + #[cold] + unsafe fn resize(&self, new_cap: usize) { + // Load the back index, front index, and buffer. + let b = self.inner.back.load(Ordering::Relaxed); + let f = self.inner.front.load(Ordering::Relaxed); + let buffer = self.cached_buffer.get(); + + // Allocate a new buffer. + let new = Buffer::alloc(new_cap); + self.cached_buffer.set(new); + + // Copy data from the old buffer to the new one. + let mut i = f; + while i != b { + ptr::copy_nonoverlapping(buffer.at(i), new.at(i), 1); + i = i.wrapping_add(1); + } + + let guard = &epoch::pin(); + + // Replace the old buffer with the new one. + let old = + self.inner + .buffer + .swap(Owned::new(new).into_shared(guard), Ordering::Release, guard); + + // Destroy the old buffer later. + guard.defer_unchecked(move || old.into_owned().into_box().dealloc()); + + // If the buffer is very large, then flush the thread-local garbage in order to deallocate + // it as soon as possible. + if mem::size_of::() * new_cap >= FLUSH_THRESHOLD_BYTES { + guard.flush(); + } + } + + /// Reserves enough capacity so that `reserve_cap` elements can be pushed without growing the + /// buffer. + fn reserve(&self, reserve_cap: usize) { + if reserve_cap > 0 { + // Compute the current length. + let b = self.inner.back.load(Ordering::Relaxed); + let f = self.inner.front.load(Ordering::SeqCst); + let len = b.wrapping_sub(f) as usize; + + // The current capacity. + let cap = self.cached_buffer.get().cap; + + // Is there enough capacity to push `reserve_cap` elements? + if cap - len < reserve_cap { + // Keep doubling the capacity as much as is needed. + let mut new_cap = cap * 2; + while new_cap - len < reserve_cap { + new_cap *= 2; + } + + // Resize the buffer. + unsafe { + self.resize(new_cap); + } + } + } + } + + /// Returns `true` if the deque is empty. + /// + /// ``` + /// use crossbeam_deque as deque; + /// + /// let (w, _) = deque::lifo(); + /// assert!(w.is_empty()); + /// w.push(1); + /// assert!(!w.is_empty()); + /// ``` + pub fn is_empty(&self) -> bool { + let b = self.inner.back.load(Ordering::Relaxed); + let f = self.inner.front.load(Ordering::SeqCst); + b.wrapping_sub(f) <= 0 + } + + /// Pushes an element into the back of the deque. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_deque as deque; + /// + /// let (w, _) = deque::lifo(); + /// w.push(1); + /// w.push(2); + /// ``` + pub fn push(&self, value: T) { + // Load the back index, front index, and buffer. + let b = self.inner.back.load(Ordering::Relaxed); + let f = self.inner.front.load(Ordering::Acquire); + let mut buffer = self.cached_buffer.get(); + + // Calculate the length of the deque. + let len = b.wrapping_sub(f); + + // Is the deque full? + if len >= buffer.cap as isize { + // Yes. Grow the underlying buffer. + unsafe { + self.resize(2 * buffer.cap); + } + buffer = self.cached_buffer.get(); + } + + // Write `value` into the slot. + unsafe { + buffer.write(b, value); + } + + atomic::fence(Ordering::Release); + + // Increment the back index. + // + // This ordering could be `Relaxed`, but then thread sanitizer would falsely report data + // races because it doesn't understand fences. + self.inner.back.store(b.wrapping_add(1), Ordering::Release); + } + + /// Pops an element from the deque. + /// + /// Which end of the deque is used depends on the strategy: + /// + /// * If this is a FIFO deque, an element is popped from the front. + /// * If this is a LIFO deque, an element is popped from the back. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_deque::{self as deque, Pop}; + /// + /// let (w, _) = deque::fifo(); + /// w.push(1); + /// w.push(2); + /// + /// assert_eq!(w.pop(), Pop::Data(1)); + /// assert_eq!(w.pop(), Pop::Data(2)); + /// assert_eq!(w.pop(), Pop::Empty); + /// ``` + pub fn pop(&self) -> Pop { + // Load the back and front index. + let b = self.inner.back.load(Ordering::Relaxed); + let f = self.inner.front.load(Ordering::Relaxed); + + // Calculate the length of the deque. + let len = b.wrapping_sub(f); + + // Is the deque empty? + if len <= 0 { + return Pop::Empty; + } + + match self.flavor { + // Pop from the front of the deque. + Flavor::Fifo => { + // Try incrementing the front index to pop the value. + if self + .inner + .front + .compare_exchange(f, f.wrapping_add(1), Ordering::SeqCst, Ordering::Relaxed) + .is_ok() + { + unsafe { + // Read the popped value. + let buffer = self.cached_buffer.get(); + let data = buffer.read(f); + + // Shrink the buffer if `len - 1` is less than one fourth of the capacity. + if buffer.cap > MIN_CAP && len <= buffer.cap as isize / 4 { + self.resize(buffer.cap / 2); + } + + return Pop::Data(data); + } + } + + Pop::Retry + } + + // Pop from the back of the deque. + Flavor::Lifo => { + // Decrement the back index. + let b = b.wrapping_sub(1); + self.inner.back.store(b, Ordering::Relaxed); + + atomic::fence(Ordering::SeqCst); + + // Load the front index. + let f = self.inner.front.load(Ordering::Relaxed); + + // Compute the length after the back index was decremented. + let len = b.wrapping_sub(f); + + if len < 0 { + // The deque is empty. Restore the back index to the original value. + self.inner.back.store(b.wrapping_add(1), Ordering::Relaxed); + Pop::Empty + } else { + // Read the value to be popped. + let buffer = self.cached_buffer.get(); + let mut value = unsafe { Some(buffer.read(b)) }; + + // Are we popping the last element from the deque? + if len == 0 { + // Try incrementing the front index. + if self + .inner + .front + .compare_exchange( + f, + f.wrapping_add(1), + Ordering::SeqCst, + Ordering::Relaxed, + ).is_err() + { + // Failed. We didn't pop anything. + mem::forget(value.take()); + } + + // Restore the back index to the original value. + self.inner.back.store(b.wrapping_add(1), Ordering::Relaxed); + } else { + // Shrink the buffer if `len` is less than one fourth of the capacity. + if buffer.cap > MIN_CAP && len < buffer.cap as isize / 4 { + unsafe { + self.resize(buffer.cap / 2); + } + } + } + + match value { + None => Pop::Empty, + Some(data) => Pop::Data(data), + } + } + } + } + } +} + +impl fmt::Debug for Worker { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Worker { .. }") + } +} + +/// The stealer side of a deque. +/// +/// Stealers can only steal elements from the front of the deque. +/// +/// Stealers are cloneable so that they can be easily shared among multiple threads. +pub struct Stealer { + /// A reference to the inner representation of the deque. + inner: Arc>>, + + /// The flavor of the deque. + flavor: Flavor, +} + +unsafe impl Send for Stealer {} +unsafe impl Sync for Stealer {} + +impl Stealer { + /// Returns `true` if the deque is empty. + /// + /// ``` + /// use crossbeam_deque as deque; + /// + /// let (w, s) = deque::lifo(); + /// assert!(s.is_empty()); + /// w.push(1); + /// assert!(!s.is_empty()); + /// ``` + pub fn is_empty(&self) -> bool { + let f = self.inner.front.load(Ordering::Acquire); + atomic::fence(Ordering::SeqCst); + let b = self.inner.back.load(Ordering::Acquire); + b.wrapping_sub(f) <= 0 + } + + /// Steals an element from the front of the deque. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_deque::{self as deque, Steal}; + /// + /// let (w, s) = deque::lifo(); + /// w.push(1); + /// w.push(2); + /// + /// assert_eq!(s.steal(), Steal::Data(1)); + /// assert_eq!(s.steal(), Steal::Data(2)); + /// assert_eq!(s.steal(), Steal::Empty); + /// ``` + pub fn steal(&self) -> Steal { + // Load the front index. + let f = self.inner.front.load(Ordering::Acquire); + + // A SeqCst fence is needed here. + // + // If the current thread is already pinned (reentrantly), we must manually issue the + // fence. Otherwise, the following pinning will issue the fence anyway, so we don't + // have to. + if epoch::is_pinned() { + atomic::fence(Ordering::SeqCst); + } + + let guard = &epoch::pin(); + + // Load the back index. + let b = self.inner.back.load(Ordering::Acquire); + + // Is the deque empty? + if b.wrapping_sub(f) <= 0 { + return Steal::Empty; + } + + // Load the buffer and read the value at the front. + let buffer = self.inner.buffer.load(Ordering::Acquire, guard); + let value = unsafe { buffer.deref().read(f) }; + + // Try incrementing the front index to steal the value. + if self + .inner + .front + .compare_exchange(f, f.wrapping_add(1), Ordering::SeqCst, Ordering::Relaxed) + .is_err() + { + // We didn't steal this value, forget it. + mem::forget(value); + return Steal::Retry; + } + + // Return the stolen value. + Steal::Data(value) + } + + /// Steals elements from the front of the deque. + /// + /// If at least one element can be stolen, it will be returned. Additionally, some of the + /// remaining elements will be stolen and pushed into the back of worker `dest` in order to + /// balance the work among deques. There is no hard guarantee on exactly how many elements will + /// be stolen, but it should be around half of the deque. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_deque::{self as deque, Steal}; + /// + /// let (w1, s1) = deque::fifo(); + /// let (w2, s2) = deque::fifo(); + /// + /// w1.push(1); + /// w1.push(2); + /// w1.push(3); + /// w1.push(4); + /// + /// assert_eq!(s1.steal_many(&w2), Steal::Data(1)); + /// assert_eq!(s2.steal(), Steal::Data(2)); + /// ``` + pub fn steal_many(&self, dest: &Worker) -> Steal { + // Load the front index. + let mut f = self.inner.front.load(Ordering::Acquire); + + // A SeqCst fence is needed here. + // + // If the current thread is already pinned (reentrantly), we must manually issue the + // fence. Otherwise, the following pinning will issue the fence anyway, so we don't + // have to. + if epoch::is_pinned() { + atomic::fence(Ordering::SeqCst); + } + + let guard = &epoch::pin(); + + // Load the back index. + let b = self.inner.back.load(Ordering::Acquire); + + // Is the deque empty? + let len = b.wrapping_sub(f); + if len <= 0 { + return Steal::Empty; + } + + // Reserve capacity for the stolen additional elements. + let additional = cmp::min((len as usize - 1) / 2, MAX_BATCH); + dest.reserve(additional); + let additional = additional as isize; + + // Get the destination buffer and back index. + let dest_buffer = dest.cached_buffer.get(); + let mut dest_b = dest.inner.back.load(Ordering::Relaxed); + + // Load the buffer and read the value at the front. + let buffer = self.inner.buffer.load(Ordering::Acquire, guard); + let value = unsafe { buffer.deref().read(f) }; + + match self.flavor { + // Steal a batch of elements from the front at once. + Flavor::Fifo => { + // Copy the additional elements from the source to the destination buffer. + for i in 0..additional { + unsafe { + let value = buffer.deref().read(f.wrapping_add(i + 1)); + dest_buffer.write(dest_b.wrapping_add(i), value); + } + } + + // Try incrementing the front index to steal the batch. + if self + .inner + .front + .compare_exchange( + f, + f.wrapping_add(additional + 1), + Ordering::SeqCst, + Ordering::Relaxed, + ).is_err() + { + // We didn't steal this value, forget it. + mem::forget(value); + return Steal::Retry; + } + + atomic::fence(Ordering::Release); + + // Success! Update the back index in the destination deque. + // + // This ordering could be `Relaxed`, but then thread sanitizer would falsely report + // data races because it doesn't understand fences. + dest.inner + .back + .store(dest_b.wrapping_add(additional), Ordering::Release); + + // Return the first stolen value. + Steal::Data(value) + } + + // Steal a batch of elements from the front one by one. + Flavor::Lifo => { + // Try incrementing the front index to steal the value. + if self + .inner + .front + .compare_exchange(f, f.wrapping_add(1), Ordering::SeqCst, Ordering::Relaxed) + .is_err() + { + // We didn't steal this value, forget it. + mem::forget(value); + return Steal::Retry; + } + + // Move the front index one step forward. + f = f.wrapping_add(1); + + // Repeat the same procedure for the additional steals. + for _ in 0..additional { + // We've already got the current front index. Now execute the fence to + // synchronize with other threads. + atomic::fence(Ordering::SeqCst); + + // Load the back index. + let b = self.inner.back.load(Ordering::Acquire); + + // Is the deque empty? + if b.wrapping_sub(f) <= 0 { + break; + } + + // Read the value at the front. + let value = unsafe { buffer.deref().read(f) }; + + // Try incrementing the front index to steal the value. + if self + .inner + .front + .compare_exchange(f, f.wrapping_add(1), Ordering::SeqCst, Ordering::Relaxed) + .is_err() + { + // We didn't steal this value, forget it and break from the loop. + mem::forget(value); + break; + } + + // Write the stolen value into the destination buffer. + unsafe { + dest_buffer.write(dest_b, value); + } + + // Move the source front index and the destination back index one step forward. + f = f.wrapping_add(1); + dest_b = dest_b.wrapping_add(1); + + atomic::fence(Ordering::Release); + + // Update the destination back index. + // + // This ordering could be `Relaxed`, but then thread sanitizer would falsely + // report data races because it doesn't understand fences. + dest.inner.back.store(dest_b, Ordering::Release); + } + + // Return the first stolen value. + Steal::Data(value) + } + } + } +} + +impl Clone for Stealer { + fn clone(&self) -> Stealer { + Stealer { + inner: self.inner.clone(), + flavor: self.flavor, + } + } +} + +impl fmt::Debug for Stealer { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Stealer { .. }") + } +} diff --git a/third_party/cargo/vendor/crossbeam-deque-0.6.3/tests/fifo.rs b/third_party/cargo/vendor/crossbeam-deque-0.6.3/tests/fifo.rs new file mode 100644 index 0000000..e97db11 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-deque-0.6.3/tests/fifo.rs @@ -0,0 +1,371 @@ +extern crate crossbeam_deque as deque; +extern crate crossbeam_epoch as epoch; +extern crate rand; + +use std::sync::atomic::Ordering::SeqCst; +use std::sync::atomic::{AtomicBool, AtomicUsize}; +use std::sync::{Arc, Mutex}; +use std::thread; + +use deque::{Pop, Steal}; +use rand::Rng; + +#[test] +fn smoke() { + let (w, s) = deque::fifo::(); + assert_eq!(w.pop(), Pop::Empty); + assert_eq!(s.steal(), Steal::Empty); + + w.push(1); + assert_eq!(w.pop(), Pop::Data(1)); + assert_eq!(w.pop(), Pop::Empty); + assert_eq!(s.steal(), Steal::Empty); + + w.push(2); + assert_eq!(s.steal(), Steal::Data(2)); + assert_eq!(s.steal(), Steal::Empty); + assert_eq!(w.pop(), Pop::Empty); + + w.push(3); + w.push(4); + w.push(5); + assert_eq!(s.steal(), Steal::Data(3)); + assert_eq!(s.steal(), Steal::Data(4)); + assert_eq!(s.steal(), Steal::Data(5)); + assert_eq!(s.steal(), Steal::Empty); + + w.push(6); + w.push(7); + w.push(8); + w.push(9); + assert_eq!(w.pop(), Pop::Data(6)); + assert_eq!(s.steal(), Steal::Data(7)); + assert_eq!(w.pop(), Pop::Data(8)); + assert_eq!(w.pop(), Pop::Data(9)); + assert_eq!(w.pop(), Pop::Empty); +} + +#[test] +fn steal_push() { + const STEPS: usize = 50_000; + + let (w, s) = deque::fifo(); + let t = thread::spawn(move || { + for i in 0..STEPS { + loop { + if let Steal::Data(v) = s.steal() { + assert_eq!(i, v); + break; + } + } + } + }); + + for i in 0..STEPS { + w.push(i); + } + t.join().unwrap(); +} + +#[test] +fn stampede() { + const THREADS: usize = 8; + const COUNT: usize = 50_000; + + let (w, s) = deque::fifo(); + + for i in 0..COUNT { + w.push(Box::new(i + 1)); + } + let remaining = Arc::new(AtomicUsize::new(COUNT)); + + let threads = (0..THREADS) + .map(|_| { + let s = s.clone(); + let remaining = remaining.clone(); + + thread::spawn(move || { + let mut last = 0; + while remaining.load(SeqCst) > 0 { + if let Steal::Data(x) = s.steal() { + assert!(last < *x); + last = *x; + remaining.fetch_sub(1, SeqCst); + } + } + }) + }).collect::>(); + + let mut last = 0; + while remaining.load(SeqCst) > 0 { + loop { + match w.pop() { + Pop::Data(x) => { + assert!(last < *x); + last = *x; + remaining.fetch_sub(1, SeqCst); + break; + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + + for t in threads { + t.join().unwrap(); + } +} + +fn run_stress() { + const THREADS: usize = 8; + const COUNT: usize = 50_000; + + let (w, s) = deque::fifo(); + let done = Arc::new(AtomicBool::new(false)); + let hits = Arc::new(AtomicUsize::new(0)); + + let threads = (0..THREADS) + .map(|_| { + let s = s.clone(); + let done = done.clone(); + let hits = hits.clone(); + + thread::spawn(move || { + let (w2, _) = deque::fifo(); + + while !done.load(SeqCst) { + if let Steal::Data(_) = s.steal() { + hits.fetch_add(1, SeqCst); + } + + if let Steal::Data(_) = s.steal_many(&w2) { + hits.fetch_add(1, SeqCst); + + loop { + match w2.pop() { + Pop::Data(_) => { + hits.fetch_add(1, SeqCst); + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + } + }) + }).collect::>(); + + let mut rng = rand::thread_rng(); + let mut expected = 0; + while expected < COUNT { + if rng.gen_range(0, 3) == 0 { + loop { + match w.pop() { + Pop::Data(_) => { + hits.fetch_add(1, SeqCst); + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } else { + w.push(expected); + expected += 1; + } + } + + while hits.load(SeqCst) < COUNT { + loop { + match w.pop() { + Pop::Data(_) => { + hits.fetch_add(1, SeqCst); + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + done.store(true, SeqCst); + + for t in threads { + t.join().unwrap(); + } +} + +#[test] +fn stress() { + run_stress(); +} + +#[test] +fn stress_pinned() { + let _guard = epoch::pin(); + run_stress(); +} + +#[test] +fn no_starvation() { + const THREADS: usize = 8; + const COUNT: usize = 50_000; + + let (w, s) = deque::fifo(); + let done = Arc::new(AtomicBool::new(false)); + + let (threads, hits): (Vec<_>, Vec<_>) = (0..THREADS) + .map(|_| { + let s = s.clone(); + let done = done.clone(); + let hits = Arc::new(AtomicUsize::new(0)); + + let t = { + let hits = hits.clone(); + thread::spawn(move || { + let (w2, _) = deque::fifo(); + + while !done.load(SeqCst) { + if let Steal::Data(_) = s.steal() { + hits.fetch_add(1, SeqCst); + } + + if let Steal::Data(_) = s.steal_many(&w2) { + hits.fetch_add(1, SeqCst); + + loop { + match w2.pop() { + Pop::Data(_) => { + hits.fetch_add(1, SeqCst); + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + } + }) + }; + + (t, hits) + }).unzip(); + + let mut rng = rand::thread_rng(); + let mut my_hits = 0; + loop { + for i in 0..rng.gen_range(0, COUNT) { + if rng.gen_range(0, 3) == 0 && my_hits == 0 { + loop { + match w.pop() { + Pop::Data(_) => my_hits += 1, + Pop::Empty => break, + Pop::Retry => {} + } + } + } else { + w.push(i); + } + } + + if my_hits > 0 && hits.iter().all(|h| h.load(SeqCst) > 0) { + break; + } + } + done.store(true, SeqCst); + + for t in threads { + t.join().unwrap(); + } +} + +#[test] +fn destructors() { + const THREADS: usize = 8; + const COUNT: usize = 50_000; + const STEPS: usize = 1000; + + struct Elem(usize, Arc>>); + + impl Drop for Elem { + fn drop(&mut self) { + self.1.lock().unwrap().push(self.0); + } + } + + let (w, s) = deque::fifo(); + + let dropped = Arc::new(Mutex::new(Vec::new())); + let remaining = Arc::new(AtomicUsize::new(COUNT)); + for i in 0..COUNT { + w.push(Elem(i, dropped.clone())); + } + + let threads = (0..THREADS) + .map(|_| { + let remaining = remaining.clone(); + let s = s.clone(); + + thread::spawn(move || { + let (w2, _) = deque::fifo(); + let mut cnt = 0; + + while cnt < STEPS { + if let Steal::Data(_) = s.steal() { + cnt += 1; + remaining.fetch_sub(1, SeqCst); + } + + if let Steal::Data(_) = s.steal_many(&w2) { + cnt += 1; + remaining.fetch_sub(1, SeqCst); + + loop { + match w2.pop() { + Pop::Data(_) => { + cnt += 1; + remaining.fetch_sub(1, SeqCst); + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + } + }) + }).collect::>(); + + for _ in 0..STEPS { + loop { + match w.pop() { + Pop::Data(_) => { + remaining.fetch_sub(1, SeqCst); + break; + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + + for t in threads { + t.join().unwrap(); + } + + let rem = remaining.load(SeqCst); + assert!(rem > 0); + + { + let mut v = dropped.lock().unwrap(); + assert_eq!(v.len(), COUNT - rem); + v.clear(); + } + + drop((w, s)); + + { + let mut v = dropped.lock().unwrap(); + assert_eq!(v.len(), rem); + v.sort(); + for pair in v.windows(2) { + assert_eq!(pair[0] + 1, pair[1]); + } + } +} diff --git a/third_party/cargo/vendor/crossbeam-deque-0.6.3/tests/lifo.rs b/third_party/cargo/vendor/crossbeam-deque-0.6.3/tests/lifo.rs new file mode 100644 index 0000000..e566327 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-deque-0.6.3/tests/lifo.rs @@ -0,0 +1,371 @@ +extern crate crossbeam_deque as deque; +extern crate crossbeam_epoch as epoch; +extern crate rand; + +use std::sync::atomic::Ordering::SeqCst; +use std::sync::atomic::{AtomicBool, AtomicUsize}; +use std::sync::{Arc, Mutex}; +use std::thread; + +use deque::{Pop, Steal}; +use rand::Rng; + +#[test] +fn smoke() { + let (w, s) = deque::lifo::(); + assert_eq!(w.pop(), Pop::Empty); + assert_eq!(s.steal(), Steal::Empty); + + w.push(1); + assert_eq!(w.pop(), Pop::Data(1)); + assert_eq!(w.pop(), Pop::Empty); + assert_eq!(s.steal(), Steal::Empty); + + w.push(2); + assert_eq!(s.steal(), Steal::Data(2)); + assert_eq!(s.steal(), Steal::Empty); + assert_eq!(w.pop(), Pop::Empty); + + w.push(3); + w.push(4); + w.push(5); + assert_eq!(s.steal(), Steal::Data(3)); + assert_eq!(s.steal(), Steal::Data(4)); + assert_eq!(s.steal(), Steal::Data(5)); + assert_eq!(s.steal(), Steal::Empty); + + w.push(6); + w.push(7); + w.push(8); + w.push(9); + assert_eq!(w.pop(), Pop::Data(9)); + assert_eq!(s.steal(), Steal::Data(6)); + assert_eq!(w.pop(), Pop::Data(8)); + assert_eq!(w.pop(), Pop::Data(7)); + assert_eq!(w.pop(), Pop::Empty); +} + +#[test] +fn steal_push() { + const STEPS: usize = 50_000; + + let (w, s) = deque::lifo(); + let t = thread::spawn(move || { + for i in 0..STEPS { + loop { + if let Steal::Data(v) = s.steal() { + assert_eq!(i, v); + break; + } + } + } + }); + + for i in 0..STEPS { + w.push(i); + } + t.join().unwrap(); +} + +#[test] +fn stampede() { + const THREADS: usize = 8; + const COUNT: usize = 50_000; + + let (w, s) = deque::lifo(); + + for i in 0..COUNT { + w.push(Box::new(i + 1)); + } + let remaining = Arc::new(AtomicUsize::new(COUNT)); + + let threads = (0..THREADS) + .map(|_| { + let s = s.clone(); + let remaining = remaining.clone(); + + thread::spawn(move || { + let mut last = 0; + while remaining.load(SeqCst) > 0 { + if let Steal::Data(x) = s.steal() { + assert!(last < *x); + last = *x; + remaining.fetch_sub(1, SeqCst); + } + } + }) + }).collect::>(); + + let mut last = COUNT + 1; + while remaining.load(SeqCst) > 0 { + loop { + match w.pop() { + Pop::Data(x) => { + assert!(last > *x); + last = *x; + remaining.fetch_sub(1, SeqCst); + break; + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + + for t in threads { + t.join().unwrap(); + } +} + +fn run_stress() { + const THREADS: usize = 8; + const COUNT: usize = 50_000; + + let (w, s) = deque::lifo(); + let done = Arc::new(AtomicBool::new(false)); + let hits = Arc::new(AtomicUsize::new(0)); + + let threads = (0..THREADS) + .map(|_| { + let s = s.clone(); + let done = done.clone(); + let hits = hits.clone(); + + thread::spawn(move || { + let (w2, _) = deque::lifo(); + + while !done.load(SeqCst) { + if let Steal::Data(_) = s.steal() { + hits.fetch_add(1, SeqCst); + } + + if let Steal::Data(_) = s.steal_many(&w2) { + hits.fetch_add(1, SeqCst); + + loop { + match w2.pop() { + Pop::Data(_) => { + hits.fetch_add(1, SeqCst); + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + } + }) + }).collect::>(); + + let mut rng = rand::thread_rng(); + let mut expected = 0; + while expected < COUNT { + if rng.gen_range(0, 3) == 0 { + loop { + match w.pop() { + Pop::Data(_) => { + hits.fetch_add(1, SeqCst); + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } else { + w.push(expected); + expected += 1; + } + } + + while hits.load(SeqCst) < COUNT { + loop { + match w.pop() { + Pop::Data(_) => { + hits.fetch_add(1, SeqCst); + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + done.store(true, SeqCst); + + for t in threads { + t.join().unwrap(); + } +} + +#[test] +fn stress() { + run_stress(); +} + +#[test] +fn stress_pinned() { + let _guard = epoch::pin(); + run_stress(); +} + +#[test] +fn no_starvation() { + const THREADS: usize = 8; + const COUNT: usize = 50_000; + + let (w, s) = deque::lifo(); + let done = Arc::new(AtomicBool::new(false)); + + let (threads, hits): (Vec<_>, Vec<_>) = (0..THREADS) + .map(|_| { + let s = s.clone(); + let done = done.clone(); + let hits = Arc::new(AtomicUsize::new(0)); + + let t = { + let hits = hits.clone(); + thread::spawn(move || { + let (w2, _) = deque::lifo(); + + while !done.load(SeqCst) { + if let Steal::Data(_) = s.steal() { + hits.fetch_add(1, SeqCst); + } + + if let Steal::Data(_) = s.steal_many(&w2) { + hits.fetch_add(1, SeqCst); + + loop { + match w2.pop() { + Pop::Data(_) => { + hits.fetch_add(1, SeqCst); + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + } + }) + }; + + (t, hits) + }).unzip(); + + let mut rng = rand::thread_rng(); + let mut my_hits = 0; + loop { + for i in 0..rng.gen_range(0, COUNT) { + if rng.gen_range(0, 3) == 0 && my_hits == 0 { + loop { + match w.pop() { + Pop::Data(_) => my_hits += 1, + Pop::Empty => break, + Pop::Retry => {} + } + } + } else { + w.push(i); + } + } + + if my_hits > 0 && hits.iter().all(|h| h.load(SeqCst) > 0) { + break; + } + } + done.store(true, SeqCst); + + for t in threads { + t.join().unwrap(); + } +} + +#[test] +fn destructors() { + const THREADS: usize = 8; + const COUNT: usize = 50_000; + const STEPS: usize = 1000; + + struct Elem(usize, Arc>>); + + impl Drop for Elem { + fn drop(&mut self) { + self.1.lock().unwrap().push(self.0); + } + } + + let (w, s) = deque::lifo(); + + let dropped = Arc::new(Mutex::new(Vec::new())); + let remaining = Arc::new(AtomicUsize::new(COUNT)); + for i in 0..COUNT { + w.push(Elem(i, dropped.clone())); + } + + let threads = (0..THREADS) + .map(|_| { + let remaining = remaining.clone(); + let s = s.clone(); + + thread::spawn(move || { + let (w2, _) = deque::lifo(); + let mut cnt = 0; + + while cnt < STEPS { + if let Steal::Data(_) = s.steal() { + cnt += 1; + remaining.fetch_sub(1, SeqCst); + } + + if let Steal::Data(_) = s.steal_many(&w2) { + cnt += 1; + remaining.fetch_sub(1, SeqCst); + + loop { + match w2.pop() { + Pop::Data(_) => { + cnt += 1; + remaining.fetch_sub(1, SeqCst); + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + } + }) + }).collect::>(); + + for _ in 0..STEPS { + loop { + match w.pop() { + Pop::Data(_) => { + remaining.fetch_sub(1, SeqCst); + break; + } + Pop::Empty => break, + Pop::Retry => {} + } + } + } + + for t in threads { + t.join().unwrap(); + } + + let rem = remaining.load(SeqCst); + assert!(rem > 0); + + { + let mut v = dropped.lock().unwrap(); + assert_eq!(v.len(), COUNT - rem); + v.clear(); + } + + drop((w, s)); + + { + let mut v = dropped.lock().unwrap(); + assert_eq!(v.len(), rem); + v.sort(); + for pair in v.windows(2) { + assert_eq!(pair[0] + 1, pair[1]); + } + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/.cargo-checksum.json b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/.cargo-checksum.json new file mode 100644 index 0000000..3d5e5a5 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"20401c46253ffb390d38018099328d3437b609bcf96264870367240af6938f3e","Cargo.toml":"e352fedefc606af80d9a858d84983da613f3b444f6ca1dde20312062ef670945","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0621878e61f0d0fda054bcbe02df75192c28bde1ecc8289cbd86aeba2dd72720","README.md":"7fa0403233bce3f904f368981e4ce13b6769cf920154f31393dd4ef3574eb974","benches/defer.rs":"c4fcf1ebb596c1cde9661b64d6ea18e380b4ef56ae426d0c76edb5226cc591bb","benches/flush.rs":"773685fe76781e0d2d295af2153cf8a0320559306f2dab5bb407bfa94f8442c5","benches/pin.rs":"260ff2bc470b7e39075163a7eb70d4576b179873b460b6b58e37ddb5eac13d7e","examples/sanitize.rs":"487855c366f86e9fa8036a7ac8698fb318e03b01cbb7e8591cf9deff18c2cdc4","src/atomic.rs":"f2690b5fcf263355eb59ad57c470e90ff7435929bf7732f8bc3abf840e392f53","src/collector.rs":"6ee2c88365b458c93eec150d283487c028cd9a004d1af23a3015c442c63461de","src/default.rs":"6afda8fd141ad594bed62baeb73f2e97c5ef33b051969a542bb908946fe39dd1","src/deferred.rs":"0da22346bd86e25b5b676e6aefd80a1aaac12e12df267cac550ab893cb08d07b","src/epoch.rs":"76dd63356d5bc52e741883d39abb636e4ccb04d20499fb2a0ce797bb81aa4e91","src/guard.rs":"b56f1b2cf75f3f1af9ca138422e44bf0c9d6835f19e5c346e49d25f6240931c8","src/internal.rs":"7b9d705261ee490048cd493662eeac0e13569a41dbbb072828ace7deca9b7ac6","src/lib.rs":"8633a59dd9a4d167dfb3b4470102fa6e70f6902f265f179f5bf522b9084ec6a6","src/sync/list.rs":"96f0acfa33197c6ba0711e1a7e21eab68faa811283544317b6844bf00f6be490","src/sync/mod.rs":"2da979ca3a2293f7626a2e6a9ab2fad758d92e3d2bed6cc712ef59eeeea87eab","src/sync/queue.rs":"d34c527178c77b4936390f4c8c140e8d8a5873294926261902ee014b9fcaaa82"},"package":"2449aaa4ec7ef96e5fb24db16024b935df718e9ae1cec0a1e68feeca2efca7b8"} \ No newline at end of file diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/BUILD b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/BUILD new file mode 100644 index 0000000..f157a14 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/BUILD @@ -0,0 +1,56 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "crossbeam_epoch", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/arrayvec-0.4.12:arrayvec", + "//third_party/cargo/vendor/cfg-if-0.1.10:cfg_if", + "//third_party/cargo/vendor/crossbeam-utils-0.6.6:crossbeam_utils", + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + "//third_party/cargo/vendor/memoffset-0.2.1:memoffset", + "//third_party/cargo/vendor/scopeguard-0.3.3:scopeguard", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.1", + crate_features = [ + "crossbeam-utils", + "default", + "lazy_static", + "std", + ], +) + +# Unsupported target "defer" with type "bench" omitted +# Unsupported target "flush" with type "bench" omitted +# Unsupported target "pin" with type "bench" omitted +# Unsupported target "sanitize" with type "example" omitted diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/CHANGELOG.md b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/CHANGELOG.md new file mode 100644 index 0000000..fab4f70 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/CHANGELOG.md @@ -0,0 +1,66 @@ +# Version 0.6.1 + +- Update `crossbeam-utils` to `0.6`. + +# Version 0.6.0 + +- `defer` now requires `F: Send + 'static`. +- Bump the minimum Rust version to 1.26. +- Pinning while TLS is tearing down does not fail anymore. +- Rename `Handle` to `LocalHandle`. +- Add `defer_unchecked` and `defer_destroy`. +- Remove `Clone` impl for `LocalHandle`. + +# Version 0.5.2 + +- Update `crossbeam-utils` to `0.5`. + +# Version 0.5.1 + +- Fix compatibility with the latest Rust nightly. + +# Version 0.5.0 + +- Update `crossbeam-utils` to `0.4`. +- Specify the minimum Rust version to `1.25.0`. + +# Version 0.4.3 + +- Downgrade `crossbeam-utils` to `0.3` because it was a breaking change. + +# Version 0.4.2 + +- Expose the `Pointer` trait. +- Warn missing docs and missing debug impls. +- Update `crossbeam-utils` to `0.4`. + +# Version 0.4.1 + +- Add `Debug` impls for `Collector`, `Handle`, and `Guard`. +- Add `load_consume` to `Atomic`. +- Rename `Collector::handle` to `Collector::register`. +- Remove the `Send` implementation for `Handle` (this was a bug). Only + `Collector`s can be shared among multiple threads, while `Handle`s and + `Guard`s must stay within the thread in which they were created. + +# Version 0.4.0 + +- Update dependencies. +- Remove support for Rust 1.13. + +# Version 0.3.0 + +- Add support for Rust 1.13. +- Improve documentation for CAS. + +# Version 0.2.0 + +- Add method `Owned::into_box`. +- Fix a use-after-free bug in `Local::finalize`. +- Fix an ordering bug in `Global::push_bag`. +- Fix a bug in calculating distance between epochs. +- Remove `impl Into> for Owned`. + +# Version 0.1.0 + +- First version of the new epoch-based GC. diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/Cargo.toml b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/Cargo.toml new file mode 100644 index 0000000..4d99b26 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/Cargo.toml @@ -0,0 +1,53 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "crossbeam-epoch" +version = "0.6.1" +authors = ["The Crossbeam Project Developers"] +description = "Epoch-based garbage collection" +homepage = "https://github.com/crossbeam-rs/crossbeam" +documentation = "https://docs.rs/crossbeam-epoch" +readme = "README.md" +keywords = ["lock-free", "rcu", "atomic", "garbage"] +categories = ["concurrency", "memory-management"] +license = "MIT/Apache-2.0" +repository = "https://github.com/crossbeam-rs/crossbeam" +[dependencies.arrayvec] +version = "0.4" +default-features = false + +[dependencies.cfg-if] +version = "0.1" + +[dependencies.crossbeam-utils] +version = "0.6" +default-features = false + +[dependencies.lazy_static] +version = "1" +optional = true + +[dependencies.memoffset] +version = "0.2" + +[dependencies.scopeguard] +version = "0.3" +default-features = false +[dev-dependencies.rand] +version = "0.5" + +[features] +default = ["std"] +nightly = ["arrayvec/use_union"] +sanitize = [] +std = ["lazy_static", "crossbeam-utils/std"] diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/LICENSE-APACHE b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/LICENSE-MIT b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/LICENSE-MIT new file mode 100644 index 0000000..25597d5 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2010 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/README.md b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/README.md new file mode 100644 index 0000000..d5c1e6d --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/README.md @@ -0,0 +1,39 @@ +# Epoch-based garbage collection + +[![Build Status](https://travis-ci.org/crossbeam-rs/crossbeam.svg?branch=master)]( +https://travis-ci.org/crossbeam-rs/crossbeam) +[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)]( +https://github.com/crossbeam-rs/crossbeam-epoch) +[![Cargo](https://img.shields.io/crates/v/crossbeam-epoch.svg)]( +https://crates.io/crates/crossbeam-epoch) +[![Documentation](https://docs.rs/crossbeam-epoch/badge.svg)]( +https://docs.rs/crossbeam-epoch) + +This crate provides epoch-based garbage collection for use in concurrent data structures. + +If a thread removes a node from a concurrent data structure, other threads +may still have pointers to that node, so it cannot be immediately destructed. +Epoch GC allows deferring destruction until it becomes safe to do so. + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +crossbeam-epoch = "0.6" +``` + +Next, add this to your crate: + +```rust +extern crate crossbeam_epoch as epoch; +``` + +The minimum required Rust version is 1.26. + +## License + +Licensed under the terms of MIT license and the Apache License (Version 2.0). + +See [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE) for details. diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/benches/defer.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/benches/defer.rs new file mode 100644 index 0000000..7d0bace --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/benches/defer.rs @@ -0,0 +1,69 @@ +#![feature(test)] + +extern crate crossbeam_epoch as epoch; +extern crate crossbeam_utils as utils; +extern crate test; + +use epoch::Owned; +use test::Bencher; +use utils::thread::scope; + +#[bench] +fn single_alloc_defer_free(b: &mut Bencher) { + b.iter(|| { + let guard = &epoch::pin(); + let p = Owned::new(1).into_shared(guard); + unsafe { + guard.defer_destroy(p); + } + }); +} + +#[bench] +fn single_defer(b: &mut Bencher) { + b.iter(|| { + let guard = &epoch::pin(); + guard.defer(move || ()); + }); +} + +#[bench] +fn multi_alloc_defer_free(b: &mut Bencher) { + const THREADS: usize = 16; + const STEPS: usize = 10_000; + + b.iter(|| { + scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + for _ in 0..STEPS { + let guard = &epoch::pin(); + let p = Owned::new(1).into_shared(guard); + unsafe { + guard.defer_destroy(p); + } + } + }); + } + }).unwrap(); + }); +} + +#[bench] +fn multi_defer(b: &mut Bencher) { + const THREADS: usize = 16; + const STEPS: usize = 10_000; + + b.iter(|| { + scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + for _ in 0..STEPS { + let guard = &epoch::pin(); + guard.defer(move || ()); + } + }); + } + }).unwrap(); + }); +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/benches/flush.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/benches/flush.rs new file mode 100644 index 0000000..4503ae9 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/benches/flush.rs @@ -0,0 +1,51 @@ +#![feature(test)] + +extern crate crossbeam_epoch as epoch; +extern crate crossbeam_utils as utils; +extern crate test; + +use std::sync::Barrier; + +use test::Bencher; +use utils::thread::scope; + +#[bench] +fn single_flush(b: &mut Bencher) { + const THREADS: usize = 16; + + let start = Barrier::new(THREADS + 1); + let end = Barrier::new(THREADS + 1); + + scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + epoch::pin(); + start.wait(); + end.wait(); + }); + } + + start.wait(); + b.iter(|| epoch::pin().flush()); + end.wait(); + }).unwrap(); +} + +#[bench] +fn multi_flush(b: &mut Bencher) { + const THREADS: usize = 16; + const STEPS: usize = 10_000; + + b.iter(|| { + scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + for _ in 0..STEPS { + let guard = &epoch::pin(); + guard.flush(); + } + }); + } + }).unwrap(); + }); +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/benches/pin.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/benches/pin.rs new file mode 100644 index 0000000..b709782 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/benches/pin.rs @@ -0,0 +1,31 @@ +#![feature(test)] + +extern crate crossbeam_epoch as epoch; +extern crate crossbeam_utils as utils; +extern crate test; + +use test::Bencher; +use utils::thread::scope; + +#[bench] +fn single_pin(b: &mut Bencher) { + b.iter(|| epoch::pin()); +} + +#[bench] +fn multi_pin(b: &mut Bencher) { + const THREADS: usize = 16; + const STEPS: usize = 100_000; + + b.iter(|| { + scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + for _ in 0..STEPS { + epoch::pin(); + } + }); + } + }).unwrap(); + }); +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/examples/sanitize.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/examples/sanitize.rs new file mode 100644 index 0000000..4586cd5 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/examples/sanitize.rs @@ -0,0 +1,68 @@ +extern crate crossbeam_epoch as epoch; +extern crate rand; + +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed}; +use std::sync::Arc; +use std::thread; +use std::time::{Duration, Instant}; + +use epoch::{Atomic, Collector, LocalHandle, Owned, Shared}; +use rand::Rng; + +fn worker(a: Arc>, handle: LocalHandle) -> usize { + let mut rng = rand::thread_rng(); + let mut sum = 0; + + if rng.gen() { + thread::sleep(Duration::from_millis(1)); + } + let timeout = Duration::from_millis(rng.gen_range(0, 10)); + let now = Instant::now(); + + while now.elapsed() < timeout { + for _ in 0..100 { + let guard = &handle.pin(); + guard.flush(); + + let val = if rng.gen() { + let p = a.swap(Owned::new(AtomicUsize::new(sum)), AcqRel, guard); + unsafe { + guard.defer_destroy(p); + guard.flush(); + p.deref().load(Relaxed) + } + } else { + let p = a.load(Acquire, guard); + unsafe { p.deref().fetch_add(sum, Relaxed) } + }; + + sum = sum.wrapping_add(val); + } + } + + sum +} + +fn main() { + for _ in 0..100 { + let collector = Collector::new(); + let a = Arc::new(Atomic::new(AtomicUsize::new(777))); + + let threads = (0..16) + .map(|_| { + let a = a.clone(); + let c = collector.clone(); + thread::spawn(move || worker(a, c.register())) + }).collect::>(); + + for t in threads { + t.join().unwrap(); + } + + unsafe { + a.swap(Shared::null(), AcqRel, epoch::unprotected()) + .into_owned(); + } + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/atomic.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/atomic.rs new file mode 100644 index 0000000..a69e061 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/atomic.rs @@ -0,0 +1,1124 @@ +use alloc::boxed::Box; +use core::borrow::{Borrow, BorrowMut}; +use core::cmp; +use core::fmt; +use core::marker::PhantomData; +use core::mem; +use core::ops::{Deref, DerefMut}; +use core::ptr; +use core::sync::atomic::Ordering; +use core::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT}; + +use crossbeam_utils::atomic::AtomicConsume; +use guard::Guard; + +/// Given ordering for the success case in a compare-exchange operation, returns the strongest +/// appropriate ordering for the failure case. +#[inline] +fn strongest_failure_ordering(ord: Ordering) -> Ordering { + use self::Ordering::*; + match ord { + Relaxed | Release => Relaxed, + Acquire | AcqRel => Acquire, + _ => SeqCst, + } +} + +/// The error returned on failed compare-and-set operation. +pub struct CompareAndSetError<'g, T: 'g, P: Pointer> { + /// The value in the atomic pointer at the time of the failed operation. + pub current: Shared<'g, T>, + + /// The new value, which the operation failed to store. + pub new: P, +} + +impl<'g, T: 'g, P: Pointer + fmt::Debug> fmt::Debug for CompareAndSetError<'g, T, P> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("CompareAndSetError") + .field("current", &self.current) + .field("new", &self.new) + .finish() + } +} + +/// Memory orderings for compare-and-set operations. +/// +/// A compare-and-set operation can have different memory orderings depending on whether it +/// succeeds or fails. This trait generalizes different ways of specifying memory orderings. +/// +/// The two ways of specifying orderings for compare-and-set are: +/// +/// 1. Just one `Ordering` for the success case. In case of failure, the strongest appropriate +/// ordering is chosen. +/// 2. A pair of `Ordering`s. The first one is for the success case, while the second one is +/// for the failure case. +pub trait CompareAndSetOrdering { + /// The ordering of the operation when it succeeds. + fn success(&self) -> Ordering; + + /// The ordering of the operation when it fails. + /// + /// The failure ordering can't be `Release` or `AcqRel` and must be equivalent or weaker than + /// the success ordering. + fn failure(&self) -> Ordering; +} + +impl CompareAndSetOrdering for Ordering { + #[inline] + fn success(&self) -> Ordering { + *self + } + + #[inline] + fn failure(&self) -> Ordering { + strongest_failure_ordering(*self) + } +} + +impl CompareAndSetOrdering for (Ordering, Ordering) { + #[inline] + fn success(&self) -> Ordering { + self.0 + } + + #[inline] + fn failure(&self) -> Ordering { + self.1 + } +} + +/// Panics if the pointer is not properly unaligned. +#[inline] +fn ensure_aligned(raw: *const T) { + assert_eq!(raw as usize & low_bits::(), 0, "unaligned pointer"); +} + +/// Returns a bitmask containing the unused least significant bits of an aligned pointer to `T`. +#[inline] +fn low_bits() -> usize { + (1 << mem::align_of::().trailing_zeros()) - 1 +} + +/// Given a tagged pointer `data`, returns the same pointer, but tagged with `tag`. +/// +/// `tag` is truncated to fit into the unused bits of the pointer to `T`. +#[inline] +fn data_with_tag(data: usize, tag: usize) -> usize { + (data & !low_bits::()) | (tag & low_bits::()) +} + +/// Decomposes a tagged pointer `data` into the pointer and the tag. +#[inline] +fn decompose_data(data: usize) -> (*mut T, usize) { + let raw = (data & !low_bits::()) as *mut T; + let tag = data & low_bits::(); + (raw, tag) +} + +/// An atomic pointer that can be safely shared between threads. +/// +/// The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused +/// least significant bits of the address. More precisely, a tag should be less than `(1 << +/// mem::align_of::().trailing_zeros())`. +/// +/// Any method that loads the pointer must be passed a reference to a [`Guard`]. +/// +/// [`Guard`]: struct.Guard.html +pub struct Atomic { + data: AtomicUsize, + _marker: PhantomData<*mut T>, +} + +unsafe impl Send for Atomic {} +unsafe impl Sync for Atomic {} + +impl Atomic { + /// Returns a new atomic pointer pointing to the tagged pointer `data`. + fn from_usize(data: usize) -> Self { + Self { + data: AtomicUsize::new(data), + _marker: PhantomData, + } + } + + /// Returns a new null atomic pointer. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Atomic; + /// + /// let a = Atomic::::null(); + /// ``` + #[cfg(not(feature = "nightly"))] + pub fn null() -> Atomic { + Self { + data: ATOMIC_USIZE_INIT, + _marker: PhantomData, + } + } + + /// Returns a new null atomic pointer. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Atomic; + /// + /// let a = Atomic::::null(); + /// ``` + #[cfg(feature = "nightly")] + pub const fn null() -> Atomic { + Self { + data: ATOMIC_USIZE_INIT, + _marker: PhantomData, + } + } + + /// Allocates `value` on the heap and returns a new atomic pointer pointing to it. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Atomic; + /// + /// let a = Atomic::new(1234); + /// ``` + pub fn new(value: T) -> Atomic { + Self::from(Owned::new(value)) + } + + /// Loads a `Shared` from the atomic pointer. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// let p = a.load(SeqCst, guard); + /// ``` + pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.load(ord)) } + } + + /// Loads a `Shared` from the atomic pointer using a "consume" memory ordering. + /// + /// This is similar to the "acquire" ordering, except that an ordering is + /// only guaranteed with operations that "depend on" the result of the load. + /// However consume loads are usually much faster than acquire loads on + /// architectures with a weak memory model since they don't require memory + /// fence instructions. + /// + /// The exact definition of "depend on" is a bit vague, but it works as you + /// would expect in practice since a lot of software, especially the Linux + /// kernel, rely on this behavior. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// let p = a.load_consume(guard); + /// ``` + pub fn load_consume<'g>(&self, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.load_consume()) } + } + + /// Stores a `Shared` or `Owned` pointer into the atomic pointer. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// a.store(Shared::null(), SeqCst); + /// a.store(Owned::new(1234), SeqCst); + /// ``` + pub fn store<'g, P: Pointer>(&self, new: P, ord: Ordering) { + self.data.store(new.into_usize(), ord); + } + + /// Stores a `Shared` or `Owned` pointer into the atomic pointer, returning the previous + /// `Shared`. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// let p = a.swap(Shared::null(), SeqCst, guard); + /// ``` + pub fn swap<'g, P: Pointer>(&self, new: P, ord: Ordering, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.swap(new.into_usize(), ord)) } + } + + /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current + /// value is the same as `current`. The tag is also taken into account, so two pointers to the + /// same object, but with different tags, will not be considered equal. + /// + /// The return value is a result indicating whether the new pointer was written. On success the + /// pointer that was written is returned. On failure the actual current value and `new` are + /// returned. + /// + /// This method takes a [`CompareAndSetOrdering`] argument which describes the memory + /// ordering of this operation. + /// + /// [`CompareAndSetOrdering`]: trait.CompareAndSetOrdering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// + /// let guard = &epoch::pin(); + /// let mut curr = a.load(SeqCst, guard); + /// let res1 = a.compare_and_set(curr, Shared::null(), SeqCst, guard); + /// let res2 = a.compare_and_set(curr, Owned::new(5678), SeqCst, guard); + /// ``` + pub fn compare_and_set<'g, O, P>( + &self, + current: Shared, + new: P, + ord: O, + _: &'g Guard, + ) -> Result, CompareAndSetError<'g, T, P>> + where + O: CompareAndSetOrdering, + P: Pointer, + { + let new = new.into_usize(); + self.data + .compare_exchange(current.into_usize(), new, ord.success(), ord.failure()) + .map(|_| unsafe { Shared::from_usize(new) }) + .map_err(|current| unsafe { + CompareAndSetError { + current: Shared::from_usize(current), + new: P::from_usize(new), + } + }) + } + + /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current + /// value is the same as `current`. The tag is also taken into account, so two pointers to the + /// same object, but with different tags, will not be considered equal. + /// + /// Unlike [`compare_and_set`], this method is allowed to spuriously fail even when comparison + /// succeeds, which can result in more efficient code on some platforms. The return value is a + /// result indicating whether the new pointer was written. On success the pointer that was + /// written is returned. On failure the actual current value and `new` are returned. + /// + /// This method takes a [`CompareAndSetOrdering`] argument which describes the memory + /// ordering of this operation. + /// + /// [`compare_and_set`]: struct.Atomic.html#method.compare_and_set + /// [`CompareAndSetOrdering`]: trait.CompareAndSetOrdering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// + /// let mut new = Owned::new(5678); + /// let mut ptr = a.load(SeqCst, guard); + /// loop { + /// match a.compare_and_set_weak(ptr, new, SeqCst, guard) { + /// Ok(p) => { + /// ptr = p; + /// break; + /// } + /// Err(err) => { + /// ptr = err.current; + /// new = err.new; + /// } + /// } + /// } + /// + /// let mut curr = a.load(SeqCst, guard); + /// loop { + /// match a.compare_and_set_weak(curr, Shared::null(), SeqCst, guard) { + /// Ok(_) => break, + /// Err(err) => curr = err.current, + /// } + /// } + /// ``` + pub fn compare_and_set_weak<'g, O, P>( + &self, + current: Shared, + new: P, + ord: O, + _: &'g Guard, + ) -> Result, CompareAndSetError<'g, T, P>> + where + O: CompareAndSetOrdering, + P: Pointer, + { + let new = new.into_usize(); + self.data + .compare_exchange_weak(current.into_usize(), new, ord.success(), ord.failure()) + .map(|_| unsafe { Shared::from_usize(new) }) + .map_err(|current| unsafe { + CompareAndSetError { + current: Shared::from_usize(current), + new: P::from_usize(new), + } + }) + } + + /// Bitwise "and" with the current tag. + /// + /// Performs a bitwise "and" operation on the current tag and the argument `val`, and sets the + /// new tag to the result. Returns the previous pointer. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::::from(Shared::null().with_tag(3)); + /// let guard = &epoch::pin(); + /// assert_eq!(a.fetch_and(2, SeqCst, guard).tag(), 3); + /// assert_eq!(a.load(SeqCst, guard).tag(), 2); + /// ``` + pub fn fetch_and<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.fetch_and(val | !low_bits::(), ord)) } + } + + /// Bitwise "or" with the current tag. + /// + /// Performs a bitwise "or" operation on the current tag and the argument `val`, and sets the + /// new tag to the result. Returns the previous pointer. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::::from(Shared::null().with_tag(1)); + /// let guard = &epoch::pin(); + /// assert_eq!(a.fetch_or(2, SeqCst, guard).tag(), 1); + /// assert_eq!(a.load(SeqCst, guard).tag(), 3); + /// ``` + pub fn fetch_or<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.fetch_or(val & low_bits::(), ord)) } + } + + /// Bitwise "xor" with the current tag. + /// + /// Performs a bitwise "xor" operation on the current tag and the argument `val`, and sets the + /// new tag to the result. Returns the previous pointer. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::::from(Shared::null().with_tag(1)); + /// let guard = &epoch::pin(); + /// assert_eq!(a.fetch_xor(3, SeqCst, guard).tag(), 1); + /// assert_eq!(a.load(SeqCst, guard).tag(), 2); + /// ``` + pub fn fetch_xor<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.fetch_xor(val & low_bits::(), ord)) } + } +} + +impl fmt::Debug for Atomic { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let data = self.data.load(Ordering::SeqCst); + let (raw, tag) = decompose_data::(data); + + f.debug_struct("Atomic") + .field("raw", &raw) + .field("tag", &tag) + .finish() + } +} + +impl fmt::Pointer for Atomic { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let data = self.data.load(Ordering::SeqCst); + let (raw, _) = decompose_data::(data); + fmt::Pointer::fmt(&raw, f) + } +} + +impl Clone for Atomic { + /// Returns a copy of the atomic value. + /// + /// Note that a `Relaxed` load is used here. If you need synchronization, use it with other + /// atomics or fences. + fn clone(&self) -> Self { + let data = self.data.load(Ordering::Relaxed); + Atomic::from_usize(data) + } +} + +impl Default for Atomic { + fn default() -> Self { + Atomic::null() + } +} + +impl From> for Atomic { + /// Returns a new atomic pointer pointing to `owned`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{Atomic, Owned}; + /// + /// let a = Atomic::::from(Owned::new(1234)); + /// ``` + fn from(owned: Owned) -> Self { + let data = owned.data; + mem::forget(owned); + Self::from_usize(data) + } +} + +impl From> for Atomic { + fn from(b: Box) -> Self { + Self::from(Owned::from(b)) + } +} + +impl From for Atomic { + fn from(t: T) -> Self { + Self::new(t) + } +} + +impl<'g, T> From> for Atomic { + /// Returns a new atomic pointer pointing to `ptr`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{Atomic, Shared}; + /// + /// let a = Atomic::::from(Shared::::null()); + /// ``` + fn from(ptr: Shared<'g, T>) -> Self { + Self::from_usize(ptr.data) + } +} + +impl From<*const T> for Atomic { + /// Returns a new atomic pointer pointing to `raw`. + /// + /// # Examples + /// + /// ``` + /// use std::ptr; + /// use crossbeam_epoch::Atomic; + /// + /// let a = Atomic::::from(ptr::null::()); + /// ``` + fn from(raw: *const T) -> Self { + Self::from_usize(raw as usize) + } +} + +/// A trait for either `Owned` or `Shared` pointers. +pub trait Pointer { + /// Returns the machine representation of the pointer. + fn into_usize(self) -> usize; + + /// Returns a new pointer pointing to the tagged pointer `data`. + unsafe fn from_usize(data: usize) -> Self; +} + +/// An owned heap-allocated object. +/// +/// This type is very similar to `Box`. +/// +/// The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused +/// least significant bits of the address. +pub struct Owned { + data: usize, + _marker: PhantomData>, +} + +impl Pointer for Owned { + #[inline] + fn into_usize(self) -> usize { + let data = self.data; + mem::forget(self); + data + } + + /// Returns a new pointer pointing to the tagged pointer `data`. + /// + /// # Panics + /// + /// Panics if the data is zero in debug mode. + #[inline] + unsafe fn from_usize(data: usize) -> Self { + debug_assert!(data != 0, "converting zero into `Owned`"); + Owned { + data: data, + _marker: PhantomData, + } + } +} + +impl Owned { + /// Allocates `value` on the heap and returns a new owned pointer pointing to it. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Owned; + /// + /// let o = Owned::new(1234); + /// ``` + pub fn new(value: T) -> Owned { + Self::from(Box::new(value)) + } + + /// Returns a new owned pointer pointing to `raw`. + /// + /// This function is unsafe because improper use may lead to memory problems. Argument `raw` + /// must be a valid pointer. Also, a double-free may occur if the function is called twice on + /// the same raw pointer. + /// + /// # Panics + /// + /// Panics if `raw` is not properly aligned. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Owned; + /// + /// let o = unsafe { Owned::from_raw(Box::into_raw(Box::new(1234))) }; + /// ``` + pub unsafe fn from_raw(raw: *mut T) -> Owned { + ensure_aligned(raw); + Self::from_usize(raw as usize) + } + + /// Converts the owned pointer into a [`Shared`]. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Owned}; + /// + /// let o = Owned::new(1234); + /// let guard = &epoch::pin(); + /// let p = o.into_shared(guard); + /// ``` + /// + /// [`Shared`]: struct.Shared.html + pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.into_usize()) } + } + + /// Converts the owned pointer into a `Box`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Owned}; + /// + /// let o = Owned::new(1234); + /// let b: Box = o.into_box(); + /// assert_eq!(*b, 1234); + /// ``` + pub fn into_box(self) -> Box { + let (raw, _) = decompose_data::(self.data); + mem::forget(self); + unsafe { Box::from_raw(raw) } + } + + /// Returns the tag stored within the pointer. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Owned; + /// + /// assert_eq!(Owned::new(1234).tag(), 0); + /// ``` + pub fn tag(&self) -> usize { + let (_, tag) = decompose_data::(self.data); + tag + } + + /// Returns the same pointer, but tagged with `tag`. `tag` is truncated to be fit into the + /// unused bits of the pointer to `T`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Owned; + /// + /// let o = Owned::new(0u64); + /// assert_eq!(o.tag(), 0); + /// let o = o.with_tag(2); + /// assert_eq!(o.tag(), 2); + /// ``` + pub fn with_tag(self, tag: usize) -> Owned { + let data = self.into_usize(); + unsafe { Self::from_usize(data_with_tag::(data, tag)) } + } +} + +impl Drop for Owned { + fn drop(&mut self) { + let (raw, _) = decompose_data::(self.data); + unsafe { + drop(Box::from_raw(raw)); + } + } +} + +impl fmt::Debug for Owned { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let (raw, tag) = decompose_data::(self.data); + + f.debug_struct("Owned") + .field("raw", &raw) + .field("tag", &tag) + .finish() + } +} + +impl Clone for Owned { + fn clone(&self) -> Self { + Owned::new((**self).clone()).with_tag(self.tag()) + } +} + +impl Deref for Owned { + type Target = T; + + fn deref(&self) -> &T { + let (raw, _) = decompose_data::(self.data); + unsafe { &*raw } + } +} + +impl DerefMut for Owned { + fn deref_mut(&mut self) -> &mut T { + let (raw, _) = decompose_data::(self.data); + unsafe { &mut *raw } + } +} + +impl From for Owned { + fn from(t: T) -> Self { + Owned::new(t) + } +} + +impl From> for Owned { + /// Returns a new owned pointer pointing to `b`. + /// + /// # Panics + /// + /// Panics if the pointer (the `Box`) is not properly aligned. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Owned; + /// + /// let o = unsafe { Owned::from_raw(Box::into_raw(Box::new(1234))) }; + /// ``` + fn from(b: Box) -> Self { + unsafe { Self::from_raw(Box::into_raw(b)) } + } +} + +impl Borrow for Owned { + fn borrow(&self) -> &T { + &**self + } +} + +impl BorrowMut for Owned { + fn borrow_mut(&mut self) -> &mut T { + &mut **self + } +} + +impl AsRef for Owned { + fn as_ref(&self) -> &T { + &**self + } +} + +impl AsMut for Owned { + fn as_mut(&mut self) -> &mut T { + &mut **self + } +} + +/// A pointer to an object protected by the epoch GC. +/// +/// The pointer is valid for use only during the lifetime `'g`. +/// +/// The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused +/// least significant bits of the address. +pub struct Shared<'g, T: 'g> { + data: usize, + _marker: PhantomData<(&'g (), *const T)>, +} + +impl<'g, T> Clone for Shared<'g, T> { + fn clone(&self) -> Self { + Shared { + data: self.data, + _marker: PhantomData, + } + } +} + +impl<'g, T> Copy for Shared<'g, T> {} + +impl<'g, T> Pointer for Shared<'g, T> { + #[inline] + fn into_usize(self) -> usize { + self.data + } + + #[inline] + unsafe fn from_usize(data: usize) -> Self { + Shared { + data: data, + _marker: PhantomData, + } + } +} + +impl<'g, T> Shared<'g, T> { + /// Returns a new null pointer. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Shared; + /// + /// let p = Shared::::null(); + /// assert!(p.is_null()); + /// ``` + pub fn null() -> Shared<'g, T> { + Shared { + data: 0, + _marker: PhantomData, + } + } + + /// Returns `true` if the pointer is null. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::null(); + /// let guard = &epoch::pin(); + /// assert!(a.load(SeqCst, guard).is_null()); + /// a.store(Owned::new(1234), SeqCst); + /// assert!(!a.load(SeqCst, guard).is_null()); + /// ``` + pub fn is_null(&self) -> bool { + self.as_raw().is_null() + } + + /// Converts the pointer to a raw pointer (without the tag). + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let o = Owned::new(1234); + /// let raw = &*o as *const _; + /// let a = Atomic::from(o); + /// + /// let guard = &epoch::pin(); + /// let p = a.load(SeqCst, guard); + /// assert_eq!(p.as_raw(), raw); + /// ``` + pub fn as_raw(&self) -> *const T { + let (raw, _) = decompose_data::(self.data); + raw + } + + /// Dereferences the pointer. + /// + /// Returns a reference to the pointee that is valid during the lifetime `'g`. + /// + /// # Safety + /// + /// Dereferencing a pointer is unsafe because it could be pointing to invalid memory. + /// + /// Another concern is the possiblity of data races due to lack of proper synchronization. + /// For example, consider the following scenario: + /// + /// 1. A thread creates a new object: `a.store(Owned::new(10), Relaxed)` + /// 2. Another thread reads it: `*a.load(Relaxed, guard).as_ref().unwrap()` + /// + /// The problem is that relaxed orderings don't synchronize initialization of the object with + /// the read from the second thread. This is a data race. A possible solution would be to use + /// `Release` and `Acquire` orderings. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// let p = a.load(SeqCst, guard); + /// unsafe { + /// assert_eq!(p.deref(), &1234); + /// } + /// ``` + pub unsafe fn deref(&self) -> &'g T { + &*self.as_raw() + } + + /// Converts the pointer to a reference. + /// + /// Returns `None` if the pointer is null, or else a reference to the object wrapped in `Some`. + /// + /// # Safety + /// + /// Dereferencing a pointer is unsafe because it could be pointing to invalid memory. + /// + /// Another concern is the possiblity of data races due to lack of proper synchronization. + /// For example, consider the following scenario: + /// + /// 1. A thread creates a new object: `a.store(Owned::new(10), Relaxed)` + /// 2. Another thread reads it: `*a.load(Relaxed, guard).as_ref().unwrap()` + /// + /// The problem is that relaxed orderings don't synchronize initialization of the object with + /// the read from the second thread. This is a data race. A possible solution would be to use + /// `Release` and `Acquire` orderings. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// let p = a.load(SeqCst, guard); + /// unsafe { + /// assert_eq!(p.as_ref(), Some(&1234)); + /// } + /// ``` + pub unsafe fn as_ref(&self) -> Option<&'g T> { + self.as_raw().as_ref() + } + + /// Takes ownership of the pointee. + /// + /// # Panics + /// + /// Panics if this pointer is null, but only in debug mode. + /// + /// # Safety + /// + /// This method may be called only if the pointer is valid and nobody else is holding a + /// reference to the same object. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// unsafe { + /// let guard = &epoch::unprotected(); + /// let p = a.load(SeqCst, guard); + /// drop(p.into_owned()); + /// } + /// ``` + pub unsafe fn into_owned(self) -> Owned { + debug_assert!( + self.as_raw() != ptr::null(), + "converting a null `Shared` into `Owned`" + ); + Owned::from_usize(self.data) + } + + /// Returns the tag stored within the pointer. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::::from(Owned::new(0u64).with_tag(2)); + /// let guard = &epoch::pin(); + /// let p = a.load(SeqCst, guard); + /// assert_eq!(p.tag(), 2); + /// ``` + pub fn tag(&self) -> usize { + let (_, tag) = decompose_data::(self.data); + tag + } + + /// Returns the same pointer, but tagged with `tag`. `tag` is truncated to be fit into the + /// unused bits of the pointer to `T`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(0u64); + /// let guard = &epoch::pin(); + /// let p1 = a.load(SeqCst, guard); + /// let p2 = p1.with_tag(2); + /// + /// assert_eq!(p1.tag(), 0); + /// assert_eq!(p2.tag(), 2); + /// assert_eq!(p1.as_raw(), p2.as_raw()); + /// ``` + pub fn with_tag(&self, tag: usize) -> Shared<'g, T> { + unsafe { Self::from_usize(data_with_tag::(self.data, tag)) } + } +} + +impl<'g, T> From<*const T> for Shared<'g, T> { + /// Returns a new pointer pointing to `raw`. + /// + /// # Panics + /// + /// Panics if `raw` is not properly aligned. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Shared; + /// + /// let p = unsafe { Shared::from(Box::into_raw(Box::new(1234)) as *const _) }; + /// assert!(!p.is_null()); + /// ``` + fn from(raw: *const T) -> Self { + ensure_aligned(raw); + unsafe { Self::from_usize(raw as usize) } + } +} + +impl<'g, T> PartialEq> for Shared<'g, T> { + fn eq(&self, other: &Self) -> bool { + self.data == other.data + } +} + +impl<'g, T> Eq for Shared<'g, T> {} + +impl<'g, T> PartialOrd> for Shared<'g, T> { + fn partial_cmp(&self, other: &Self) -> Option { + self.data.partial_cmp(&other.data) + } +} + +impl<'g, T> Ord for Shared<'g, T> { + fn cmp(&self, other: &Self) -> cmp::Ordering { + self.data.cmp(&other.data) + } +} + +impl<'g, T> fmt::Debug for Shared<'g, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let (raw, tag) = decompose_data::(self.data); + + f.debug_struct("Shared") + .field("raw", &raw) + .field("tag", &tag) + .finish() + } +} + +impl<'g, T> fmt::Pointer for Shared<'g, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Pointer::fmt(&self.as_raw(), f) + } +} + +impl<'g, T> Default for Shared<'g, T> { + fn default() -> Self { + Shared::null() + } +} + +#[cfg(test)] +mod tests { + use super::Shared; + + #[test] + fn valid_tag_i8() { + Shared::::null().with_tag(0); + } + + #[test] + fn valid_tag_i64() { + Shared::::null().with_tag(7); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/collector.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/collector.rs new file mode 100644 index 0000000..4b17ba5 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/collector.rs @@ -0,0 +1,433 @@ +/// Epoch-based garbage collector. +/// +/// # Examples +/// +/// ``` +/// use crossbeam_epoch::Collector; +/// +/// let collector = Collector::new(); +/// +/// let handle = collector.register(); +/// drop(collector); // `handle` still works after dropping `collector` +/// +/// handle.pin().flush(); +/// ``` +use alloc::sync::Arc; +use core::fmt; + +use guard::Guard; +use internal::{Global, Local}; + +/// An epoch-based garbage collector. +pub struct Collector { + pub(crate) global: Arc, +} + +unsafe impl Send for Collector {} +unsafe impl Sync for Collector {} + +impl Collector { + /// Creates a new collector. + pub fn new() -> Self { + Collector { + global: Arc::new(Global::new()), + } + } + + /// Registers a new handle for the collector. + pub fn register(&self) -> LocalHandle { + Local::register(self) + } +} + +impl Clone for Collector { + /// Creates another reference to the same garbage collector. + fn clone(&self) -> Self { + Collector { + global: self.global.clone(), + } + } +} + +impl fmt::Debug for Collector { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Collector").finish() + } +} + +impl PartialEq for Collector { + /// Checks if both handles point to the same collector. + fn eq(&self, rhs: &Collector) -> bool { + Arc::ptr_eq(&self.global, &rhs.global) + } +} +impl Eq for Collector {} + +/// A handle to a garbage collector. +pub struct LocalHandle { + pub(crate) local: *const Local, +} + +impl LocalHandle { + /// Pins the handle. + #[inline] + pub fn pin(&self) -> Guard { + unsafe { (*self.local).pin() } + } + + /// Returns `true` if the handle is pinned. + #[inline] + pub fn is_pinned(&self) -> bool { + unsafe { (*self.local).is_pinned() } + } + + /// Returns the `Collector` associated with this handle. + #[inline] + pub fn collector(&self) -> &Collector { + unsafe { (*self.local).collector() } + } +} + +impl Drop for LocalHandle { + #[inline] + fn drop(&mut self) { + unsafe { + Local::release_handle(&*self.local); + } + } +} + +impl fmt::Debug for LocalHandle { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("LocalHandle").finish() + } +} + +#[cfg(test)] +mod tests { + use std::mem; + use std::sync::atomic::Ordering; + use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT}; + + use crossbeam_utils::thread; + + use {Collector, Owned}; + + const NUM_THREADS: usize = 8; + + #[test] + fn pin_reentrant() { + let collector = Collector::new(); + let handle = collector.register(); + drop(collector); + + assert!(!handle.is_pinned()); + { + let _guard = &handle.pin(); + assert!(handle.is_pinned()); + { + let _guard = &handle.pin(); + assert!(handle.is_pinned()); + } + assert!(handle.is_pinned()); + } + assert!(!handle.is_pinned()); + } + + #[test] + fn flush_local_bag() { + let collector = Collector::new(); + let handle = collector.register(); + drop(collector); + + for _ in 0..100 { + let guard = &handle.pin(); + unsafe { + let a = Owned::new(7).into_shared(guard); + guard.defer_destroy(a); + + assert!(!(*(*guard.local).bag.get()).is_empty()); + + while !(*(*guard.local).bag.get()).is_empty() { + guard.flush(); + } + } + } + } + + #[test] + fn garbage_buffering() { + let collector = Collector::new(); + let handle = collector.register(); + drop(collector); + + let guard = &handle.pin(); + unsafe { + for _ in 0..10 { + let a = Owned::new(7).into_shared(guard); + guard.defer_destroy(a); + } + assert!(!(*(*guard.local).bag.get()).is_empty()); + } + } + + #[test] + fn pin_holds_advance() { + let collector = Collector::new(); + + thread::scope(|scope| { + for _ in 0..NUM_THREADS { + scope.spawn(|_| { + let handle = collector.register(); + for _ in 0..500_000 { + let guard = &handle.pin(); + + let before = collector.global.epoch.load(Ordering::Relaxed); + collector.global.collect(guard); + let after = collector.global.epoch.load(Ordering::Relaxed); + + assert!(after.wrapping_sub(before) <= 2); + } + }); + } + }).unwrap(); + } + + #[test] + fn incremental() { + const COUNT: usize = 100_000; + static DESTROYS: AtomicUsize = ATOMIC_USIZE_INIT; + + let collector = Collector::new(); + let handle = collector.register(); + + unsafe { + let guard = &handle.pin(); + for _ in 0..COUNT { + let a = Owned::new(7i32).into_shared(guard); + guard.defer_unchecked(move || { + drop(a.into_owned()); + DESTROYS.fetch_add(1, Ordering::Relaxed); + }); + } + guard.flush(); + } + + let mut last = 0; + + while last < COUNT { + let curr = DESTROYS.load(Ordering::Relaxed); + assert!(curr - last <= 1024); + last = curr; + + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert!(DESTROYS.load(Ordering::Relaxed) == 100_000); + } + + #[test] + fn buffering() { + const COUNT: usize = 10; + static DESTROYS: AtomicUsize = ATOMIC_USIZE_INIT; + + let collector = Collector::new(); + let handle = collector.register(); + + unsafe { + let guard = &handle.pin(); + for _ in 0..COUNT { + let a = Owned::new(7i32).into_shared(guard); + guard.defer_unchecked(move || { + drop(a.into_owned()); + DESTROYS.fetch_add(1, Ordering::Relaxed); + }); + } + } + + for _ in 0..100_000 { + collector.global.collect(&handle.pin()); + } + assert!(DESTROYS.load(Ordering::Relaxed) < COUNT); + + handle.pin().flush(); + + while DESTROYS.load(Ordering::Relaxed) < COUNT { + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert_eq!(DESTROYS.load(Ordering::Relaxed), COUNT); + } + + #[test] + fn count_drops() { + const COUNT: usize = 100_000; + static DROPS: AtomicUsize = ATOMIC_USIZE_INIT; + + struct Elem(i32); + + impl Drop for Elem { + fn drop(&mut self) { + DROPS.fetch_add(1, Ordering::Relaxed); + } + } + + let collector = Collector::new(); + let handle = collector.register(); + + unsafe { + let guard = &handle.pin(); + + for _ in 0..COUNT { + let a = Owned::new(Elem(7i32)).into_shared(guard); + guard.defer_destroy(a); + } + guard.flush(); + } + + while DROPS.load(Ordering::Relaxed) < COUNT { + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert_eq!(DROPS.load(Ordering::Relaxed), COUNT); + } + + #[test] + fn count_destroy() { + const COUNT: usize = 100_000; + static DESTROYS: AtomicUsize = ATOMIC_USIZE_INIT; + + let collector = Collector::new(); + let handle = collector.register(); + + unsafe { + let guard = &handle.pin(); + + for _ in 0..COUNT { + let a = Owned::new(7i32).into_shared(guard); + guard.defer_unchecked(move || { + drop(a.into_owned()); + DESTROYS.fetch_add(1, Ordering::Relaxed); + }); + } + guard.flush(); + } + + while DESTROYS.load(Ordering::Relaxed) < COUNT { + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert_eq!(DESTROYS.load(Ordering::Relaxed), COUNT); + } + + #[test] + fn drop_array() { + const COUNT: usize = 700; + static DROPS: AtomicUsize = ATOMIC_USIZE_INIT; + + struct Elem(i32); + + impl Drop for Elem { + fn drop(&mut self) { + DROPS.fetch_add(1, Ordering::Relaxed); + } + } + + let collector = Collector::new(); + let handle = collector.register(); + + let mut guard = handle.pin(); + + let mut v = Vec::with_capacity(COUNT); + for i in 0..COUNT { + v.push(Elem(i as i32)); + } + + { + let a = Owned::new(v).into_shared(&guard); + unsafe { + guard.defer_destroy(a); + } + guard.flush(); + } + + while DROPS.load(Ordering::Relaxed) < COUNT { + guard.repin(); + collector.global.collect(&guard); + } + assert_eq!(DROPS.load(Ordering::Relaxed), COUNT); + } + + #[test] + fn destroy_array() { + const COUNT: usize = 100_000; + static DESTROYS: AtomicUsize = ATOMIC_USIZE_INIT; + + let collector = Collector::new(); + let handle = collector.register(); + + unsafe { + let guard = &handle.pin(); + + let mut v = Vec::with_capacity(COUNT); + for i in 0..COUNT { + v.push(i as i32); + } + + let ptr = v.as_mut_ptr() as usize; + let len = v.len(); + guard.defer_unchecked(move || { + drop(Vec::from_raw_parts(ptr as *const u8 as *mut u8, len, len)); + DESTROYS.fetch_add(len, Ordering::Relaxed); + }); + guard.flush(); + + mem::forget(v); + } + + while DESTROYS.load(Ordering::Relaxed) < COUNT { + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert_eq!(DESTROYS.load(Ordering::Relaxed), COUNT); + } + + #[test] + fn stress() { + const THREADS: usize = 8; + const COUNT: usize = 100_000; + static DROPS: AtomicUsize = ATOMIC_USIZE_INIT; + + struct Elem(i32); + + impl Drop for Elem { + fn drop(&mut self) { + DROPS.fetch_add(1, Ordering::Relaxed); + } + } + + let collector = Collector::new(); + + thread::scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + let handle = collector.register(); + for _ in 0..COUNT { + let guard = &handle.pin(); + unsafe { + let a = Owned::new(Elem(7i32)).into_shared(guard); + guard.defer_destroy(a); + } + } + }); + } + }).unwrap(); + + let handle = collector.register(); + while DROPS.load(Ordering::Relaxed) < COUNT * THREADS { + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert_eq!(DROPS.load(Ordering::Relaxed), COUNT * THREADS); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/default.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/default.rs new file mode 100644 index 0000000..734a624 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/default.rs @@ -0,0 +1,75 @@ +//! The default garbage collector. +//! +//! For each thread, a participant is lazily initialized on its first use, when the current thread +//! is registered in the default collector. If initialized, the thread's participant will get +//! destructed on thread exit, which in turn unregisters the thread. + +use collector::{Collector, LocalHandle}; +use guard::Guard; + +lazy_static! { + /// The global data for the default garbage collector. + static ref COLLECTOR: Collector = Collector::new(); +} + +thread_local! { + /// The per-thread participant for the default garbage collector. + static HANDLE: LocalHandle = COLLECTOR.register(); +} + +/// Pins the current thread. +#[inline] +pub fn pin() -> Guard { + with_handle(|handle| handle.pin()) +} + +/// Returns `true` if the current thread is pinned. +#[inline] +pub fn is_pinned() -> bool { + with_handle(|handle| handle.is_pinned()) +} + +/// Returns the default global collector. +pub fn default_collector() -> &'static Collector { + &COLLECTOR +} + +#[inline] +fn with_handle(mut f: F) -> R +where + F: FnMut(&LocalHandle) -> R, +{ + HANDLE + .try_with(|h| f(h)) + .unwrap_or_else(|_| f(&COLLECTOR.register())) +} + +#[cfg(test)] +mod tests { + use crossbeam_utils::thread; + + #[test] + fn pin_while_exiting() { + struct Foo; + + impl Drop for Foo { + fn drop(&mut self) { + // Pin after `HANDLE` has been dropped. This must not panic. + super::pin(); + } + } + + thread_local! { + static FOO: Foo = Foo; + } + + thread::scope(|scope| { + scope.spawn(|_| { + // Initialize `FOO` and then `HANDLE`. + FOO.with(|_| ()); + super::pin(); + // At thread exit, `HANDLE` gets dropped first and `FOO` second. + }); + }).unwrap(); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/deferred.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/deferred.rs new file mode 100644 index 0000000..411428d --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/deferred.rs @@ -0,0 +1,134 @@ +use alloc::boxed::Box; +use core::fmt; +use core::marker::PhantomData; +use core::mem; +use core::ptr; + +/// Number of words a piece of `Data` can hold. +/// +/// Three words should be enough for the majority of cases. For example, you can fit inside it the +/// function pointer together with a fat pointer representing an object that needs to be destroyed. +const DATA_WORDS: usize = 3; + +/// Some space to keep a `FnOnce()` object on the stack. +type Data = [usize; DATA_WORDS]; + +/// A `FnOnce()` that is stored inline if small, or otherwise boxed on the heap. +/// +/// This is a handy way of keeping an unsized `FnOnce()` within a sized structure. +pub struct Deferred { + call: unsafe fn(*mut u8), + data: Data, + _marker: PhantomData<*mut ()>, // !Send + !Sync +} + +impl fmt::Debug for Deferred { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(f, "Deferred {{ ... }}") + } +} + +impl Deferred { + /// Constructs a new `Deferred` from a `FnOnce()`. + pub fn new(f: F) -> Self { + let size = mem::size_of::(); + let align = mem::align_of::(); + + unsafe { + if size <= mem::size_of::() && align <= mem::align_of::() { + let mut data: Data = mem::uninitialized(); + ptr::write(&mut data as *mut Data as *mut F, f); + + unsafe fn call(raw: *mut u8) { + let f: F = ptr::read(raw as *mut F); + f(); + } + + Deferred { + call: call::, + data, + _marker: PhantomData, + } + } else { + let b: Box = Box::new(f); + let mut data: Data = mem::uninitialized(); + ptr::write(&mut data as *mut Data as *mut Box, b); + + unsafe fn call(raw: *mut u8) { + let b: Box = ptr::read(raw as *mut Box); + (*b)(); + } + + Deferred { + call: call::, + data, + _marker: PhantomData, + } + } + } + } + + /// Calls the function. + #[inline] + pub fn call(mut self) { + let call = self.call; + unsafe { call(&mut self.data as *mut Data as *mut u8) }; + } +} + +#[cfg(test)] +mod tests { + use super::Deferred; + use std::cell::Cell; + + #[test] + fn on_stack() { + let fired = &Cell::new(false); + let a = [0usize; 1]; + + let d = Deferred::new(move || { + drop(a); + fired.set(true); + }); + + assert!(!fired.get()); + d.call(); + assert!(fired.get()); + } + + #[test] + fn on_heap() { + let fired = &Cell::new(false); + let a = [0usize; 10]; + + let d = Deferred::new(move || { + drop(a); + fired.set(true); + }); + + assert!(!fired.get()); + d.call(); + assert!(fired.get()); + } + + #[test] + fn string() { + let a = "hello".to_string(); + let d = Deferred::new(move || assert_eq!(a, "hello")); + d.call(); + } + + #[test] + fn boxed_slice_i32() { + let a: Box<[i32]> = vec![2, 3, 5, 7].into_boxed_slice(); + let d = Deferred::new(move || assert_eq!(*a, [2, 3, 5, 7])); + d.call(); + } + + #[test] + fn long_slice_usize() { + let a: [usize; 5] = [2, 3, 5, 7, 11]; + let d = Deferred::new(move || assert_eq!(a, [2, 3, 5, 7, 11])); + d.call(); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/epoch.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/epoch.rs new file mode 100644 index 0000000..e7759d9 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/epoch.rs @@ -0,0 +1,114 @@ +//! The global epoch +//! +//! The last bit in this number is unused and is always zero. Every so often the global epoch is +//! incremented, i.e. we say it "advances". A pinned participant may advance the global epoch only +//! if all currently pinned participants have been pinned in the current epoch. +//! +//! If an object became garbage in some epoch, then we can be sure that after two advancements no +//! participant will hold a reference to it. That is the crux of safe memory reclamation. + +use core::sync::atomic::{AtomicUsize, Ordering}; + +/// An epoch that can be marked as pinned or unpinned. +/// +/// Internally, the epoch is represented as an integer that wraps around at some unspecified point +/// and a flag that represents whether it is pinned or unpinned. +#[derive(Copy, Clone, Default, Debug, Eq, PartialEq)] +pub struct Epoch { + /// The least significant bit is set if pinned. The rest of the bits hold the epoch. + data: usize, +} + +impl Epoch { + /// Returns the starting epoch in unpinned state. + #[inline] + pub fn starting() -> Self { + Self::default() + } + + /// Returns the number of epochs `self` is ahead of `rhs`. + /// + /// Internally, epochs are represented as numbers in the range `(isize::MIN / 2) .. (isize::MAX + /// / 2)`, so the returned distance will be in the same interval. + pub fn wrapping_sub(self, rhs: Self) -> isize { + // The result is the same with `(self.data & !1).wrapping_sub(rhs.data & !1) as isize >> 1`, + // because the possible difference of LSB in `(self.data & !1).wrapping_sub(rhs.data & !1)` + // will be ignored in the shift operation. + self.data.wrapping_sub(rhs.data & !1) as isize >> 1 + } + + /// Returns `true` if the epoch is marked as pinned. + #[inline] + pub fn is_pinned(self) -> bool { + (self.data & 1) == 1 + } + + /// Returns the same epoch, but marked as pinned. + #[inline] + pub fn pinned(self) -> Epoch { + Epoch { + data: self.data | 1, + } + } + + /// Returns the same epoch, but marked as unpinned. + #[inline] + pub fn unpinned(self) -> Epoch { + Epoch { + data: self.data & !1, + } + } + + /// Returns the successor epoch. + /// + /// The returned epoch will be marked as pinned only if the previous one was as well. + #[inline] + pub fn successor(self) -> Epoch { + Epoch { + data: self.data.wrapping_add(2), + } + } +} + +/// An atomic value that holds an `Epoch`. +#[derive(Default, Debug)] +pub struct AtomicEpoch { + /// Since `Epoch` is just a wrapper around `usize`, an `AtomicEpoch` is similarly represented + /// using an `AtomicUsize`. + data: AtomicUsize, +} + +impl AtomicEpoch { + /// Creates a new atomic epoch. + #[inline] + pub fn new(epoch: Epoch) -> Self { + let data = AtomicUsize::new(epoch.data); + AtomicEpoch { data } + } + + /// Loads a value from the atomic epoch. + #[inline] + pub fn load(&self, ord: Ordering) -> Epoch { + Epoch { + data: self.data.load(ord), + } + } + + /// Stores a value into the atomic epoch. + #[inline] + pub fn store(&self, epoch: Epoch, ord: Ordering) { + self.data.store(epoch.data, ord); + } + + /// Stores a value into the atomic epoch if the current value is the same as `current`. + /// + /// The return value is always the previous value. If it is equal to `current`, then the value + /// is updated. + /// + /// The `Ordering` argument describes the memory ordering of this operation. + #[inline] + pub fn compare_and_swap(&self, current: Epoch, new: Epoch, ord: Ordering) -> Epoch { + let data = self.data.compare_and_swap(current.data, new.data, ord); + Epoch { data } + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/guard.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/guard.rs new file mode 100644 index 0000000..04ca6f5 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/guard.rs @@ -0,0 +1,547 @@ +use core::fmt; +use core::mem; +use core::ptr; + +use atomic::Shared; +use collector::Collector; +use deferred::Deferred; +use internal::Local; + +/// A guard that keeps the current thread pinned. +/// +/// # Pinning +/// +/// The current thread is pinned by calling [`pin`], which returns a new guard: +/// +/// ``` +/// use crossbeam_epoch as epoch; +/// +/// // It is often convenient to prefix a call to `pin` with a `&` in order to create a reference. +/// // This is not really necessary, but makes passing references to the guard a bit easier. +/// let guard = &epoch::pin(); +/// ``` +/// +/// When a guard gets dropped, the current thread is automatically unpinned. +/// +/// # Pointers on the stack +/// +/// Having a guard allows us to create pointers on the stack to heap-allocated objects. +/// For example: +/// +/// ``` +/// use crossbeam_epoch::{self as epoch, Atomic, Owned}; +/// use std::sync::atomic::Ordering::SeqCst; +/// +/// // Create a heap-allocated number. +/// let a = Atomic::new(777); +/// +/// // Pin the current thread. +/// let guard = &epoch::pin(); +/// +/// // Load the heap-allocated object and create pointer `p` on the stack. +/// let p = a.load(SeqCst, guard); +/// +/// // Dereference the pointer and print the value: +/// if let Some(num) = unsafe { p.as_ref() } { +/// println!("The number is {}.", num); +/// } +/// ``` +/// +/// # Multiple guards +/// +/// Pinning is reentrant and it is perfectly legal to create multiple guards. In that case, the +/// thread will actually be pinned only when the first guard is created and unpinned when the last +/// one is dropped: +/// +/// ``` +/// use crossbeam_epoch as epoch; +/// +/// let guard1 = epoch::pin(); +/// let guard2 = epoch::pin(); +/// assert!(epoch::is_pinned()); +/// drop(guard1); +/// assert!(epoch::is_pinned()); +/// drop(guard2); +/// assert!(!epoch::is_pinned()); +/// ``` +/// +/// The same can be achieved by cloning guards: +/// +/// ``` +/// use crossbeam_epoch as epoch; +/// +/// let guard1 = epoch::pin(); +/// let guard2 = guard1.clone(); +/// ``` +/// +/// [`pin`]: fn.pin.html +pub struct Guard { + pub(crate) local: *const Local, +} + +impl Guard { + /// Stores a function so that it can be executed at some point after all currently pinned + /// threads get unpinned. + /// + /// This method first stores `f` into the thread-local (or handle-local) cache. If this cache + /// becomes full, some functions are moved into the global cache. At the same time, some + /// functions from both local and global caches may get executed in order to incrementally + /// clean up the caches as they fill up. + /// + /// There is no guarantee when exactly `f` will be executed. The only guarantee is that it + /// won't be executed until all currently pinned threads get unpinned. In theory, `f` might + /// never run, but the epoch-based garbage collection will make an effort to execute it + /// reasonably soon. + /// + /// If this method is called from an [`unprotected`] guard, the function will simply be + /// executed immediately. + /// + /// [`unprotected`]: fn.unprotected.html + pub fn defer(&self, f: F) + where + F: FnOnce() -> R, + F: Send + 'static, + { + unsafe { + self.defer_unchecked(f); + } + } + + /// Stores a function so that it can be executed at some point after all currently pinned + /// threads get unpinned. + /// + /// This method first stores `f` into the thread-local (or handle-local) cache. If this cache + /// becomes full, some functions are moved into the global cache. At the same time, some + /// functions from both local and global caches may get executed in order to incrementally + /// clean up the caches as they fill up. + /// + /// There is no guarantee when exactly `f` will be executed. The only guarantee is that it + /// won't be executed until all currently pinned threads get unpinned. In theory, `f` might + /// never run, but the epoch-based garbage collection will make an effort to execute it + /// reasonably soon. + /// + /// If this method is called from an [`unprotected`] guard, the function will simply be + /// executed immediately. + /// + /// # Safety + /// + /// The given function must not hold reference onto the stack. It is highly recommended that + /// the passed function is **always** marked with `move` in order to prevent accidental + /// borrows. + /// + /// ``` + /// use crossbeam_epoch as epoch; + /// + /// let guard = &epoch::pin(); + /// let message = "Hello!"; + /// unsafe { + /// // ALWAYS use `move` when sending a closure into `defer_unchecked`. + /// guard.defer_unchecked(move || { + /// println!("{}", message); + /// }); + /// } + /// ``` + /// + /// Apart from that, keep in mind that another thread may execute `f`, so anything accessed by + /// the closure must be `Send`. + /// + /// We intentionally didn't require `F: Send`, because Rust's type systems usually cannot prove + /// `F: Send` for typical use cases. For example, consider the following code snippet, which + /// exemplifies the typical use case of deferring the deallocation of a shared reference: + /// + /// ```ignore + /// let shared = Owned::new(7i32).into_shared(guard); + /// guard.defer_unchecked(move || shared.into_owned()); // `Shared` is not `Send`! + /// ``` + /// + /// While `Shared` is not `Send`, it's safe for another thread to call the deferred function, + /// because it's called only after the grace period and `shared` is no longer shared with other + /// threads. But we don't expect type systems to prove this. + /// + /// # Examples + /// + /// When a heap-allocated object in a data structure becomes unreachable, it has to be + /// deallocated. However, the current thread and other threads may be still holding references + /// on the stack to that same object. Therefore it cannot be deallocated before those references + /// get dropped. This method can defer deallocation until all those threads get unpinned and + /// consequently drop all their references on the stack. + /// + /// ```rust + /// use crossbeam_epoch::{self as epoch, Atomic, Owned}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new("foo"); + /// + /// // Now suppose that `a` is shared among multiple threads and concurrently + /// // accessed and modified... + /// + /// // Pin the current thread. + /// let guard = &epoch::pin(); + /// + /// // Steal the object currently stored in `a` and swap it with another one. + /// let p = a.swap(Owned::new("bar").into_shared(guard), SeqCst, guard); + /// + /// if !p.is_null() { + /// // The object `p` is pointing to is now unreachable. + /// // Defer its deallocation until all currently pinned threads get unpinned. + /// unsafe { + /// // ALWAYS use `move` when sending a closure into `defer_unchecked`. + /// guard.defer_unchecked(move || { + /// println!("{} is now being deallocated.", p.deref()); + /// // Now we have unique access to the object pointed to by `p` and can turn it + /// // into an `Owned`. Dropping the `Owned` will deallocate the object. + /// drop(p.into_owned()); + /// }); + /// } + /// } + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub unsafe fn defer_unchecked(&self, f: F) + where + F: FnOnce() -> R, + { + if let Some(local) = self.local.as_ref() { + local.defer(Deferred::new(move || drop(f())), self); + } + } + + /// Stores a destructor for an object so that it can be deallocated and dropped at some point + /// after all currently pinned threads get unpinned. + /// + /// This method first stores the destructor into the thread-local (or handle-local) cache. If + /// this cache becomes full, some destructors are moved into the global cache. At the same + /// time, some destructors from both local and global caches may get executed in order to + /// incrementally clean up the caches as they fill up. + /// + /// There is no guarantee when exactly the destructor will be executed. The only guarantee is + /// that it won't be executed until all currently pinned threads get unpinned. In theory, the + /// destructor might never run, but the epoch-based garbage collection will make an effort to + /// execute it reasonably soon. + /// + /// If this method is called from an [`unprotected`] guard, the destructor will simply be + /// executed immediately. + /// + /// # Safety + /// + /// The object must not be reachable by other threads anymore, otherwise it might be still in + /// use when the destructor runs. + /// + /// Apart from that, keep in mind that another thread may execute the destructor, so the object + /// must be sendable to other threads. + /// + /// We intentionally didn't require `T: Send`, because Rust's type systems usually cannot prove + /// `T: Send` for typical use cases. For example, consider the following code snippet, which + /// exemplifies the typical use case of deferring the deallocation of a shared reference: + /// + /// ```ignore + /// let shared = Owned::new(7i32).into_shared(guard); + /// guard.defer_destroy(shared); // `Shared` is not `Send`! + /// ``` + /// + /// While `Shared` is not `Send`, it's safe for another thread to call the destructor, because + /// it's called only after the grace period and `shared` is no longer shared with other + /// threads. But we don't expect type systems to prove this. + /// + /// # Examples + /// + /// When a heap-allocated object in a data structure becomes unreachable, it has to be + /// deallocated. However, the current thread and other threads may be still holding references + /// on the stack to that same object. Therefore it cannot be deallocated before those references + /// get dropped. This method can defer deallocation until all those threads get unpinned and + /// consequently drop all their references on the stack. + /// + /// ```rust + /// use crossbeam_epoch::{self as epoch, Atomic, Owned}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new("foo"); + /// + /// // Now suppose that `a` is shared among multiple threads and concurrently + /// // accessed and modified... + /// + /// // Pin the current thread. + /// let guard = &epoch::pin(); + /// + /// // Steal the object currently stored in `a` and swap it with another one. + /// let p = a.swap(Owned::new("bar").into_shared(guard), SeqCst, guard); + /// + /// if !p.is_null() { + /// // The object `p` is pointing to is now unreachable. + /// // Defer its deallocation until all currently pinned threads get unpinned. + /// unsafe { + /// guard.defer_destroy(p); + /// } + /// } + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub unsafe fn defer_destroy(&self, ptr: Shared) { + self.defer_unchecked(move || ptr.into_owned()); + } + + /// Clears up the thread-local cache of deferred functions by executing them or moving into the + /// global cache. + /// + /// Call this method after deferring execution of a function if you want to get it executed as + /// soon as possible. Flushing will make sure it is residing in in the global cache, so that + /// any thread has a chance of taking the function and executing it. + /// + /// If this method is called from an [`unprotected`] guard, it is a no-op (nothing happens). + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch as epoch; + /// + /// let guard = &epoch::pin(); + /// unsafe { + /// guard.defer(move || { + /// println!("This better be printed as soon as possible!"); + /// }); + /// } + /// guard.flush(); + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub fn flush(&self) { + if let Some(local) = unsafe { self.local.as_ref() } { + local.flush(self); + } + } + + /// Unpins and then immediately re-pins the thread. + /// + /// This method is useful when you don't want delay the advancement of the global epoch by + /// holding an old epoch. For safety, you should not maintain any guard-based reference across + /// the call (the latter is enforced by `&mut self`). The thread will only be repinned if this + /// is the only active guard for the current thread. + /// + /// If this method is called from an [`unprotected`] guard, then the call will be just no-op. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// use std::thread; + /// use std::time::Duration; + /// + /// let a = Atomic::new(777); + /// let mut guard = epoch::pin(); + /// { + /// let p = a.load(SeqCst, &guard); + /// assert_eq!(unsafe { p.as_ref() }, Some(&777)); + /// } + /// guard.repin(); + /// { + /// let p = a.load(SeqCst, &guard); + /// assert_eq!(unsafe { p.as_ref() }, Some(&777)); + /// } + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub fn repin(&mut self) { + if let Some(local) = unsafe { self.local.as_ref() } { + local.repin(); + } + } + + /// Temporarily unpins the thread, executes the given function and then re-pins the thread. + /// + /// This method is useful when you need to perform a long-running operation (e.g. sleeping) + /// and don't need to maintain any guard-based reference across the call (the latter is enforced + /// by `&mut self`). The thread will only be unpinned if this is the only active guard for the + /// current thread. + /// + /// If this method is called from an [`unprotected`] guard, then the passed function is called + /// directly without unpinning the thread. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// use std::thread; + /// use std::time::Duration; + /// + /// let a = Atomic::new(777); + /// let mut guard = epoch::pin(); + /// { + /// let p = a.load(SeqCst, &guard); + /// assert_eq!(unsafe { p.as_ref() }, Some(&777)); + /// } + /// guard.repin_after(|| thread::sleep(Duration::from_millis(50))); + /// { + /// let p = a.load(SeqCst, &guard); + /// assert_eq!(unsafe { p.as_ref() }, Some(&777)); + /// } + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub fn repin_after(&mut self, f: F) -> R + where + F: FnOnce() -> R, + { + if let Some(local) = unsafe { self.local.as_ref() } { + // We need to acquire a handle here to ensure the Local doesn't + // disappear from under us. + local.acquire_handle(); + local.unpin(); + } + + // Ensure the Guard is re-pinned even if the function panics + defer! { + if let Some(local) = unsafe { self.local.as_ref() } { + mem::forget(local.pin()); + local.release_handle(); + } + } + + f() + } + + /// Returns the `Collector` associated with this guard. + /// + /// This method is useful when you need to ensure that all guards used with + /// a data structure come from the same collector. + /// + /// If this method is called from an [`unprotected`] guard, then `None` is returned. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch as epoch; + /// + /// let mut guard1 = epoch::pin(); + /// let mut guard2 = epoch::pin(); + /// assert!(guard1.collector() == guard2.collector()); + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub fn collector(&self) -> Option<&Collector> { + unsafe { self.local.as_ref().map(|local| local.collector()) } + } +} + +impl Drop for Guard { + #[inline] + fn drop(&mut self) { + if let Some(local) = unsafe { self.local.as_ref() } { + local.unpin(); + } + } +} + +impl Clone for Guard { + #[inline] + fn clone(&self) -> Guard { + match unsafe { self.local.as_ref() } { + None => Guard { local: ptr::null() }, + Some(local) => local.pin(), + } + } +} + +impl fmt::Debug for Guard { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Guard").finish() + } +} + +/// Returns a reference to a dummy guard that allows unprotected access to [`Atomic`]s. +/// +/// This guard should be used in special occasions only. Note that it doesn't actually keep any +/// thread pinned - it's just a fake guard that allows loading from [`Atomic`]s unsafely. +/// +/// Note that calling [`defer`] with a dummy guard will not defer the function - it will just +/// execute the function immediately. +/// +/// If necessary, it's possible to create more dummy guards by cloning: `unprotected().clone()`. +/// +/// # Safety +/// +/// Loading and dereferencing data from an [`Atomic`] using this guard is safe only if the +/// [`Atomic`] is not being concurrently modified by other threads. +/// +/// # Examples +/// +/// ``` +/// use crossbeam_epoch::{self as epoch, Atomic}; +/// use std::sync::atomic::Ordering::Relaxed; +/// +/// let a = Atomic::new(7); +/// +/// unsafe { +/// // Load `a` without pinning the current thread. +/// a.load(Relaxed, epoch::unprotected()); +/// +/// // It's possible to create more dummy guards by calling `clone()`. +/// let dummy = &epoch::unprotected().clone(); +/// +/// dummy.defer(move || { +/// println!("This gets executed immediately."); +/// }); +/// +/// // Dropping `dummy` doesn't affect the current thread - it's just a noop. +/// } +/// ``` +/// +/// The most common use of this function is when constructing or destructing a data structure. +/// +/// For example, we can use a dummy guard in the destructor of a Treiber stack because at that +/// point no other thread could concurrently modify the [`Atomic`]s we are accessing. +/// +/// If we were to actually pin the current thread during destruction, that would just unnecessarily +/// delay garbage collection and incur some performance cost, so in cases like these `unprotected` +/// is very helpful. +/// +/// ``` +/// use crossbeam_epoch::{self as epoch, Atomic}; +/// use std::mem::ManuallyDrop; +/// use std::sync::atomic::Ordering::Relaxed; +/// +/// struct Stack { +/// head: Atomic>, +/// } +/// +/// struct Node { +/// data: ManuallyDrop, +/// next: Atomic>, +/// } +/// +/// impl Drop for Stack { +/// fn drop(&mut self) { +/// unsafe { +/// // Unprotected load. +/// let mut node = self.head.load(Relaxed, epoch::unprotected()); +/// +/// while let Some(n) = node.as_ref() { +/// // Unprotected load. +/// let next = n.next.load(Relaxed, epoch::unprotected()); +/// +/// // Take ownership of the node, then drop its data and deallocate it. +/// let mut o = node.into_owned(); +/// ManuallyDrop::drop(&mut o.data); +/// drop(o); +/// +/// node = next; +/// } +/// } +/// } +/// } +/// ``` +/// +/// [`Atomic`]: struct.Atomic.html +/// [`defer`]: struct.Guard.html#method.defer +#[inline] +pub unsafe fn unprotected() -> &'static Guard { + // HACK(stjepang): An unprotected guard is just a `Guard` with its field `local` set to null. + // Since this function returns a `'static` reference to a `Guard`, we must return a reference + // to a global guard. However, it's not possible to create a `static` `Guard` because it does + // not implement `Sync`. To get around the problem, we create a static `usize` initialized to + // zero and then transmute it into a `Guard`. This is safe because `usize` and `Guard` + // (consisting of a single pointer) have the same representation in memory. + static UNPROTECTED: usize = 0; + &*(&UNPROTECTED as *const _ as *const Guard) +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/internal.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/internal.rs new file mode 100644 index 0000000..8104748 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/internal.rs @@ -0,0 +1,546 @@ +//! The global data and participant for garbage collection. +//! +//! # Registration +//! +//! In order to track all participants in one place, we need some form of participant +//! registration. When a participant is created, it is registered to a global lock-free +//! singly-linked list of registries; and when a participant is leaving, it is unregistered from the +//! list. +//! +//! # Pinning +//! +//! Every participant contains an integer that tells whether the participant is pinned and if so, +//! what was the global epoch at the time it was pinned. Participants also hold a pin counter that +//! aids in periodic global epoch advancement. +//! +//! When a participant is pinned, a `Guard` is returned as a witness that the participant is pinned. +//! Guards are necessary for performing atomic operations, and for freeing/dropping locations. +//! +//! # Thread-local bag +//! +//! Objects that get unlinked from concurrent data structures must be stashed away until the global +//! epoch sufficiently advances so that they become safe for destruction. Pointers to such objects +//! are pushed into a thread-local bag, and when it becomes full, the bag is marked with the current +//! global epoch and pushed into the global queue of bags. We store objects in thread-local storages +//! for amortizing the synchronization cost of pushing the garbages to a global queue. +//! +//! # Global queue +//! +//! Whenever a bag is pushed into a queue, the objects in some bags in the queue are collected and +//! destroyed along the way. This design reduces contention on data structures. The global queue +//! cannot be explicitly accessed: the only way to interact with it is by calling functions +//! `defer()` that adds an object tothe thread-local bag, or `collect()` that manually triggers +//! garbage collection. +//! +//! Ideally each instance of concurrent data structure may have its own queue that gets fully +//! destroyed as soon as the data structure gets dropped. + +use alloc::boxed::Box; +use core::cell::{Cell, UnsafeCell}; +use core::mem::{self, ManuallyDrop}; +use core::num::Wrapping; +use core::ptr; +use core::sync::atomic; +use core::sync::atomic::Ordering; + +use arrayvec::ArrayVec; +use crossbeam_utils::CachePadded; + +use atomic::Owned; +use collector::{Collector, LocalHandle}; +use deferred::Deferred; +use epoch::{AtomicEpoch, Epoch}; +use guard::{unprotected, Guard}; +use sync::list::{Entry, IsElement, IterError, List}; +use sync::queue::Queue; + +/// Maximum number of objects a bag can contain. +#[cfg(not(feature = "sanitize"))] +const MAX_OBJECTS: usize = 64; +#[cfg(feature = "sanitize")] +const MAX_OBJECTS: usize = 4; + +/// A bag of deferred functions. +#[derive(Default, Debug)] +pub struct Bag { + /// Stashed objects. + deferreds: ArrayVec<[Deferred; MAX_OBJECTS]>, +} + +/// `Bag::try_push()` requires that it is safe for another thread to execute the given functions. +unsafe impl Send for Bag {} + +impl Bag { + /// Returns a new, empty bag. + pub fn new() -> Self { + Self::default() + } + + /// Returns `true` if the bag is empty. + pub fn is_empty(&self) -> bool { + self.deferreds.is_empty() + } + + /// Attempts to insert a deferred function into the bag. + /// + /// Returns `Ok(())` if successful, and `Err(deferred)` for the given `deferred` if the bag is + /// full. + /// + /// # Safety + /// + /// It should be safe for another thread to execute the given function. + pub unsafe fn try_push(&mut self, deferred: Deferred) -> Result<(), Deferred> { + self.deferreds.try_push(deferred).map_err(|e| e.element()) + } + + /// Seals the bag with the given epoch. + fn seal(self, epoch: Epoch) -> SealedBag { + SealedBag { epoch, bag: self } + } +} + +impl Drop for Bag { + fn drop(&mut self) { + // Call all deferred functions. + for deferred in self.deferreds.drain(..) { + deferred.call(); + } + } +} + +/// A pair of an epoch and a bag. +#[derive(Default, Debug)] +struct SealedBag { + epoch: Epoch, + bag: Bag, +} + +/// It is safe to share `SealedBag` because `is_expired` only inspects the epoch. +unsafe impl Sync for SealedBag {} + +impl SealedBag { + /// Checks if it is safe to drop the bag w.r.t. the given global epoch. + fn is_expired(&self, global_epoch: Epoch) -> bool { + // A pinned participant can witness at most one epoch advancement. Therefore, any bag that + // is within one epoch of the current one cannot be destroyed yet. + global_epoch.wrapping_sub(self.epoch) >= 2 + } +} + +/// The global data for a garbage collector. +pub struct Global { + /// The intrusive linked list of `Local`s. + locals: List, + + /// The global queue of bags of deferred functions. + queue: Queue, + + /// The global epoch. + pub(crate) epoch: CachePadded, +} + +impl Global { + /// Number of bags to destroy. + const COLLECT_STEPS: usize = 8; + + /// Creates a new global data for garbage collection. + #[inline] + pub fn new() -> Self { + Self { + locals: List::new(), + queue: Queue::new(), + epoch: CachePadded::new(AtomicEpoch::new(Epoch::starting())), + } + } + + /// Pushes the bag into the global queue and replaces the bag with a new empty bag. + pub fn push_bag(&self, bag: &mut Bag, guard: &Guard) { + let bag = mem::replace(bag, Bag::new()); + + atomic::fence(Ordering::SeqCst); + + let epoch = self.epoch.load(Ordering::Relaxed); + self.queue.push(bag.seal(epoch), guard); + } + + /// Collects several bags from the global queue and executes deferred functions in them. + /// + /// Note: This may itself produce garbage and in turn allocate new bags. + /// + /// `pin()` rarely calls `collect()`, so we want the compiler to place that call on a cold + /// path. In other words, we want the compiler to optimize branching for the case when + /// `collect()` is not called. + #[cold] + pub fn collect(&self, guard: &Guard) { + let global_epoch = self.try_advance(guard); + + let steps = if cfg!(feature = "sanitize") { + usize::max_value() + } else { + Self::COLLECT_STEPS + }; + + for _ in 0..steps { + match self.queue.try_pop_if( + &|sealed_bag: &SealedBag| sealed_bag.is_expired(global_epoch), + guard, + ) { + None => break, + Some(sealed_bag) => drop(sealed_bag), + } + } + } + + /// Attempts to advance the global epoch. + /// + /// The global epoch can advance only if all currently pinned participants have been pinned in + /// the current epoch. + /// + /// Returns the current global epoch. + /// + /// `try_advance()` is annotated `#[cold]` because it is rarely called. + #[cold] + pub fn try_advance(&self, guard: &Guard) -> Epoch { + let global_epoch = self.epoch.load(Ordering::Relaxed); + atomic::fence(Ordering::SeqCst); + + // TODO(stjepang): `Local`s are stored in a linked list because linked lists are fairly + // easy to implement in a lock-free manner. However, traversal can be slow due to cache + // misses and data dependencies. We should experiment with other data structures as well. + for local in self.locals.iter(&guard) { + match local { + Err(IterError::Stalled) => { + // A concurrent thread stalled this iteration. That thread might also try to + // advance the epoch, in which case we leave the job to it. Otherwise, the + // epoch will not be advanced. + return global_epoch; + } + Ok(local) => { + let local_epoch = local.epoch.load(Ordering::Relaxed); + + // If the participant was pinned in a different epoch, we cannot advance the + // global epoch just yet. + if local_epoch.is_pinned() && local_epoch.unpinned() != global_epoch { + return global_epoch; + } + } + } + } + atomic::fence(Ordering::Acquire); + + // All pinned participants were pinned in the current global epoch. + // Now let's advance the global epoch... + // + // Note that if another thread already advanced it before us, this store will simply + // overwrite the global epoch with the same value. This is true because `try_advance` was + // called from a thread that was pinned in `global_epoch`, and the global epoch cannot be + // advanced two steps ahead of it. + let new_epoch = global_epoch.successor(); + self.epoch.store(new_epoch, Ordering::Release); + new_epoch + } +} + +/// Participant for garbage collection. +pub struct Local { + /// A node in the intrusive linked list of `Local`s. + entry: Entry, + + /// The local epoch. + epoch: AtomicEpoch, + + /// A reference to the global data. + /// + /// When all guards and handles get dropped, this reference is destroyed. + collector: UnsafeCell>, + + /// The local bag of deferred functions. + pub(crate) bag: UnsafeCell, + + /// The number of guards keeping this participant pinned. + guard_count: Cell, + + /// The number of active handles. + handle_count: Cell, + + /// Total number of pinnings performed. + /// + /// This is just an auxilliary counter that sometimes kicks off collection. + pin_count: Cell>, +} + +impl Local { + /// Number of pinnings after which a participant will execute some deferred functions from the + /// global queue. + const PINNINGS_BETWEEN_COLLECT: usize = 128; + + /// Registers a new `Local` in the provided `Global`. + pub fn register(collector: &Collector) -> LocalHandle { + unsafe { + // Since we dereference no pointers in this block, it is safe to use `unprotected`. + + let local = Owned::new(Local { + entry: Entry::default(), + epoch: AtomicEpoch::new(Epoch::starting()), + collector: UnsafeCell::new(ManuallyDrop::new(collector.clone())), + bag: UnsafeCell::new(Bag::new()), + guard_count: Cell::new(0), + handle_count: Cell::new(1), + pin_count: Cell::new(Wrapping(0)), + }).into_shared(&unprotected()); + collector.global.locals.insert(local, &unprotected()); + LocalHandle { + local: local.as_raw(), + } + } + } + + /// Returns a reference to the `Global` in which this `Local` resides. + #[inline] + pub fn global(&self) -> &Global { + &self.collector().global + } + + /// Returns a reference to the `Collector` in which this `Local` resides. + #[inline] + pub fn collector(&self) -> &Collector { + unsafe { &**self.collector.get() } + } + + /// Returns `true` if the current participant is pinned. + #[inline] + pub fn is_pinned(&self) -> bool { + self.guard_count.get() > 0 + } + + /// Adds `deferred` to the thread-local bag. + /// + /// # Safety + /// + /// It should be safe for another thread to execute the given function. + pub unsafe fn defer(&self, mut deferred: Deferred, guard: &Guard) { + let bag = &mut *self.bag.get(); + + while let Err(d) = bag.try_push(deferred) { + self.global().push_bag(bag, guard); + deferred = d; + } + } + + pub fn flush(&self, guard: &Guard) { + let bag = unsafe { &mut *self.bag.get() }; + + if !bag.is_empty() { + self.global().push_bag(bag, guard); + } + + self.global().collect(guard); + } + + /// Pins the `Local`. + #[inline] + pub fn pin(&self) -> Guard { + let guard = Guard { local: self }; + + let guard_count = self.guard_count.get(); + self.guard_count.set(guard_count.checked_add(1).unwrap()); + + if guard_count == 0 { + let global_epoch = self.global().epoch.load(Ordering::Relaxed); + let new_epoch = global_epoch.pinned(); + + // Now we must store `new_epoch` into `self.epoch` and execute a `SeqCst` fence. + // The fence makes sure that any future loads from `Atomic`s will not happen before + // this store. + if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { + // HACK(stjepang): On x86 architectures there are two different ways of executing + // a `SeqCst` fence. + // + // 1. `atomic::fence(SeqCst)`, which compiles into a `mfence` instruction. + // 2. `_.compare_and_swap(_, _, SeqCst)`, which compiles into a `lock cmpxchg` + // instruction. + // + // Both instructions have the effect of a full barrier, but benchmarks have shown + // that the second one makes pinning faster in this particular case. + let current = Epoch::starting(); + let previous = self + .epoch + .compare_and_swap(current, new_epoch, Ordering::SeqCst); + debug_assert_eq!(current, previous, "participant was expected to be unpinned"); + } else { + self.epoch.store(new_epoch, Ordering::Relaxed); + atomic::fence(Ordering::SeqCst); + } + + // Increment the pin counter. + let count = self.pin_count.get(); + self.pin_count.set(count + Wrapping(1)); + + // After every `PINNINGS_BETWEEN_COLLECT` try advancing the epoch and collecting + // some garbage. + if count.0 % Self::PINNINGS_BETWEEN_COLLECT == 0 { + self.global().collect(&guard); + } + } + + guard + } + + /// Unpins the `Local`. + #[inline] + pub fn unpin(&self) { + let guard_count = self.guard_count.get(); + self.guard_count.set(guard_count - 1); + + if guard_count == 1 { + self.epoch.store(Epoch::starting(), Ordering::Release); + + if self.handle_count.get() == 0 { + self.finalize(); + } + } + } + + /// Unpins and then pins the `Local`. + #[inline] + pub fn repin(&self) { + let guard_count = self.guard_count.get(); + + // Update the local epoch only if there's only one guard. + if guard_count == 1 { + let epoch = self.epoch.load(Ordering::Relaxed); + let global_epoch = self.global().epoch.load(Ordering::Relaxed).pinned(); + + // Update the local epoch only if the global epoch is greater than the local epoch. + if epoch != global_epoch { + // We store the new epoch with `Release` because we need to ensure any memory + // accesses from the previous epoch do not leak into the new one. + self.epoch.store(global_epoch, Ordering::Release); + + // However, we don't need a following `SeqCst` fence, because it is safe for memory + // accesses from the new epoch to be executed before updating the local epoch. At + // worse, other threads will see the new epoch late and delay GC slightly. + } + } + } + + /// Increments the handle count. + #[inline] + pub fn acquire_handle(&self) { + let handle_count = self.handle_count.get(); + debug_assert!(handle_count >= 1); + self.handle_count.set(handle_count + 1); + } + + /// Decrements the handle count. + #[inline] + pub fn release_handle(&self) { + let guard_count = self.guard_count.get(); + let handle_count = self.handle_count.get(); + debug_assert!(handle_count >= 1); + self.handle_count.set(handle_count - 1); + + if guard_count == 0 && handle_count == 1 { + self.finalize(); + } + } + + /// Removes the `Local` from the global linked list. + #[cold] + fn finalize(&self) { + debug_assert_eq!(self.guard_count.get(), 0); + debug_assert_eq!(self.handle_count.get(), 0); + + // Temporarily increment handle count. This is required so that the following call to `pin` + // doesn't call `finalize` again. + self.handle_count.set(1); + unsafe { + // Pin and move the local bag into the global queue. It's important that `push_bag` + // doesn't defer destruction on any new garbage. + let guard = &self.pin(); + self.global().push_bag(&mut *self.bag.get(), guard); + } + // Revert the handle count back to zero. + self.handle_count.set(0); + + unsafe { + // Take the reference to the `Global` out of this `Local`. Since we're not protected + // by a guard at this time, it's crucial that the reference is read before marking the + // `Local` as deleted. + let collector: Collector = ptr::read(&*(*self.collector.get())); + + // Mark this node in the linked list as deleted. + self.entry.delete(&unprotected()); + + // Finally, drop the reference to the global. Note that this might be the last reference + // to the `Global`. If so, the global data will be destroyed and all deferred functions + // in its queue will be executed. + drop(collector); + } + } +} + +impl IsElement for Local { + fn entry_of(local: &Local) -> &Entry { + let entry_ptr = (local as *const Local as usize + offset_of!(Local, entry)) as *const Entry; + unsafe { &*entry_ptr } + } + + unsafe fn element_of(entry: &Entry) -> &Local { + // offset_of! macro uses unsafe, but it's unnecessary in this context. + #[allow(unused_unsafe)] + let local_ptr = (entry as *const Entry as usize - offset_of!(Local, entry)) as *const Local; + &*local_ptr + } + + unsafe fn finalize(entry: &Entry) { + let local = Self::element_of(entry); + drop(Box::from_raw(local as *const Local as *mut Local)); + } +} + +#[cfg(test)] +mod tests { + use std::sync::atomic::Ordering; + use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT}; + + use super::*; + + #[test] + fn check_defer() { + static FLAG: AtomicUsize = ATOMIC_USIZE_INIT; + fn set() { + FLAG.store(42, Ordering::Relaxed); + } + + let d = Deferred::new(set); + assert_eq!(FLAG.load(Ordering::Relaxed), 0); + d.call(); + assert_eq!(FLAG.load(Ordering::Relaxed), 42); + } + + #[test] + fn check_bag() { + static FLAG: AtomicUsize = ATOMIC_USIZE_INIT; + fn incr() { + FLAG.fetch_add(1, Ordering::Relaxed); + } + + let mut bag = Bag::new(); + assert!(bag.is_empty()); + + for _ in 0..MAX_OBJECTS { + assert!(unsafe { bag.try_push(Deferred::new(incr)).is_ok() }); + assert!(!bag.is_empty()); + assert_eq!(FLAG.load(Ordering::Relaxed), 0); + } + + let result = unsafe { bag.try_push(Deferred::new(incr)) }; + assert!(result.is_err()); + assert!(!bag.is_empty()); + assert_eq!(FLAG.load(Ordering::Relaxed), 0); + + drop(bag); + assert_eq!(FLAG.load(Ordering::Relaxed), MAX_OBJECTS); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/lib.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/lib.rs new file mode 100644 index 0000000..8662571 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/lib.rs @@ -0,0 +1,106 @@ +//! Epoch-based memory reclamation. +//! +//! An interesting problem concurrent collections deal with comes from the remove operation. +//! Suppose that a thread removes an element from a lock-free map, while another thread is reading +//! that same element at the same time. The first thread must wait until the second thread stops +//! reading the element. Only then it is safe to destruct it. +//! +//! Programming languages that come with garbage collectors solve this problem trivially. The +//! garbage collector will destruct the removed element when no thread can hold a reference to it +//! anymore. +//! +//! This crate implements a basic memory reclamation mechanism, which is based on epochs. When an +//! element gets removed from a concurrent collection, it is inserted into a pile of garbage and +//! marked with the current epoch. Every time a thread accesses a collection, it checks the current +//! epoch, attempts to increment it, and destructs some garbage that became so old that no thread +//! can be referencing it anymore. +//! +//! That is the general mechanism behind epoch-based memory reclamation, but the details are a bit +//! more complicated. Anyhow, memory reclamation is designed to be fully automatic and something +//! users of concurrent collections don't have to worry much about. +//! +//! # Pointers +//! +//! Concurrent collections are built using atomic pointers. This module provides [`Atomic`], which +//! is just a shared atomic pointer to a heap-allocated object. Loading an [`Atomic`] yields a +//! [`Shared`], which is an epoch-protected pointer through which the loaded object can be safely +//! read. +//! +//! # Pinning +//! +//! Before an [`Atomic`] can be loaded, a participant must be [`pin`]ned. By pinning a participant +//! we declare that any object that gets removed from now on must not be destructed just +//! yet. Garbage collection of newly removed objects is suspended until the participant gets +//! unpinned. +//! +//! # Garbage +//! +//! Objects that get removed from concurrent collections must be stashed away until all currently +//! pinned participants get unpinned. Such objects can be stored into a thread-local or global +//! storage, where they are kept until the right time for their destruction comes. +//! +//! There is a global shared instance of garbage queue. You can [`defer`] the execution of an +//! arbitrary function until the global epoch is advanced enough. Most notably, concurrent data +//! structures may defer the deallocation of an object. +//! +//! # APIs +//! +//! For majority of use cases, just use the default garbage collector by invoking [`pin`]. If you +//! want to create your own garbage collector, use the [`Collector`] API. +//! +//! [`Atomic`]: struct.Atomic.html +//! [`Collector`]: struct.Collector.html +//! [`Shared`]: struct.Shared.html +//! [`pin`]: fn.pin.html +//! [`defer`]: fn.defer.html + +#![warn(missing_docs)] +#![warn(missing_debug_implementations)] +#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(feature = "nightly", feature(alloc))] +#![cfg_attr(feature = "nightly", feature(const_fn))] + +#[macro_use] +extern crate cfg_if; +#[cfg(feature = "std")] +extern crate core; + +cfg_if! { + if #[cfg(feature = "nightly")] { + extern crate alloc; + } else { + mod alloc { + extern crate std; + pub use self::std::*; + } + } +} + +extern crate arrayvec; +extern crate crossbeam_utils; +#[macro_use] +extern crate memoffset; +#[macro_use] +extern crate scopeguard; + +mod atomic; +mod collector; +mod deferred; +mod epoch; +mod guard; +mod internal; +mod sync; + +pub use self::atomic::{Atomic, CompareAndSetError, CompareAndSetOrdering, Owned, Pointer, Shared}; +pub use self::collector::{Collector, LocalHandle}; +pub use self::guard::{unprotected, Guard}; + +cfg_if! { + if #[cfg(feature = "std")] { + #[macro_use] + extern crate lazy_static; + + mod default; + pub use self::default::{default_collector, is_pinned, pin}; + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/sync/list.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/sync/list.rs new file mode 100644 index 0000000..ac1b49b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/sync/list.rs @@ -0,0 +1,477 @@ +//! Lock-free intrusive linked list. +//! +//! Ideas from Michael. High Performance Dynamic Lock-Free Hash Tables and List-Based Sets. SPAA +//! 2002. http://dl.acm.org/citation.cfm?id=564870.564881 + +use core::marker::PhantomData; +use core::sync::atomic::Ordering::{Acquire, Relaxed, Release}; + +use {unprotected, Atomic, Guard, Shared}; + +/// An entry in a linked list. +/// +/// An Entry is accessed from multiple threads, so it would be beneficial to put it in a different +/// cache-line than thread-local data in terms of performance. +#[derive(Debug)] +pub struct Entry { + /// The next entry in the linked list. + /// If the tag is 1, this entry is marked as deleted. + next: Atomic, +} + +/// Implementing this trait asserts that the type `T` can be used as an element in the intrusive +/// linked list defined in this module. `T` has to contain (or otherwise be linked to) an instance +/// of `Entry`. +/// +/// # Example +/// +/// ```ignore +/// struct A { +/// entry: Entry, +/// data: usize, +/// } +/// +/// impl IsElement for A { +/// fn entry_of(a: &A) -> &Entry { +/// let entry_ptr = ((a as usize) + offset_of!(A, entry)) as *const Entry; +/// unsafe { &*entry_ptr } +/// } +/// +/// unsafe fn element_of(entry: &Entry) -> &T { +/// let elem_ptr = ((entry as usize) - offset_of!(A, entry)) as *const T; +/// &*elem_ptr +/// } +/// +/// unsafe fn finalize(entry: &Entry) { +/// let elem = Self::element_of(entry); +/// drop(Box::from_raw(elem as *const A as *mut A)); +/// } +/// } +/// ``` +/// +/// This trait is implemented on a type separate from `T` (although it can be just `T`), because +/// one type might be placeable into multiple lists, in which case it would require multiple +/// implementations of `IsElement`. In such cases, each struct implementing `IsElement` +/// represents a distinct `Entry` in `T`. +/// +/// For example, we can insert the following struct into two lists using `entry1` for one +/// and `entry2` for the other: +/// +/// ```ignore +/// struct B { +/// entry1: Entry, +/// entry2: Entry, +/// data: usize, +/// } +/// ``` +/// +pub trait IsElement { + /// Returns a reference to this element's `Entry`. + fn entry_of(&T) -> &Entry; + + /// Given a reference to an element's entry, returns that element. + /// + /// ```ignore + /// let elem = ListElement::new(); + /// assert_eq!(elem.entry_of(), + /// unsafe { ListElement::element_of(elem.entry_of()) } ); + /// ``` + /// + /// # Safety + /// The caller has to guarantee that the `Entry` it + /// is called with was retrieved from an instance of the element type (`T`). + unsafe fn element_of(&Entry) -> &T; + + /// Deallocates the whole element given its `Entry`. This is called when the list + /// is ready to actually free the element. + /// + /// # Safety + /// The caller has to guarantee that the `Entry` it + /// is called with was retrieved from an instance of the element type (`T`). + unsafe fn finalize(&Entry); +} + +/// A lock-free, intrusive linked list of type `T`. +#[derive(Debug)] +pub struct List = T> { + /// The head of the linked list. + head: Atomic, + + /// The phantom data for using `T` and `C`. + _marker: PhantomData<(T, C)>, +} + +/// An iterator used for retrieving values from the list. +pub struct Iter<'g, T: 'g, C: IsElement> { + /// The guard that protects the iteration. + guard: &'g Guard, + + /// Pointer from the predecessor to the current entry. + pred: &'g Atomic, + + /// The current entry. + curr: Shared<'g, Entry>, + + /// The list head, needed for restarting iteration. + head: &'g Atomic, + + /// Logically, we store a borrow of an instance of `T` and + /// use the type information from `C`. + _marker: PhantomData<(&'g T, C)>, +} + +/// An error that occurs during iteration over the list. +#[derive(PartialEq, Debug)] +pub enum IterError { + /// A concurrent thread modified the state of the list at the same place that this iterator + /// was inspecting. Subsequent iteration will restart from the beginning of the list. + Stalled, +} + +impl Default for Entry { + /// Returns the empty entry. + fn default() -> Self { + Self { + next: Atomic::null(), + } + } +} + +impl Entry { + /// Marks this entry as deleted, deferring the actual deallocation to a later iteration. + /// + /// # Safety + /// + /// The entry should be a member of a linked list, and it should not have been deleted. + /// It should be safe to call `C::finalize` on the entry after the `guard` is dropped, where `C` + /// is the associated helper for the linked list. + pub unsafe fn delete(&self, guard: &Guard) { + self.next.fetch_or(1, Release, guard); + } +} + +impl> List { + /// Returns a new, empty linked list. + pub fn new() -> Self { + Self { + head: Atomic::null(), + _marker: PhantomData, + } + } + + /// Inserts `entry` into the head of the list. + /// + /// # Safety + /// + /// You should guarantee that: + /// + /// - `container` is not null + /// - `container` is immovable, e.g. inside a `Box` + /// - the same `Entry` is not inserted more than once + /// - the inserted object will be removed before the list is dropped + pub unsafe fn insert<'g>(&'g self, container: Shared<'g, T>, guard: &'g Guard) { + // Insert right after head, i.e. at the beginning of the list. + let to = &self.head; + // Get the intrusively stored Entry of the new element to insert. + let entry: &Entry = C::entry_of(container.deref()); + // Make a Shared ptr to that Entry. + let entry_ptr = Shared::from(entry as *const _); + // Read the current successor of where we want to insert. + let mut next = to.load(Relaxed, guard); + + loop { + // Set the Entry of the to-be-inserted element to point to the previous successor of + // `to`. + entry.next.store(next, Relaxed); + match to.compare_and_set_weak(next, entry_ptr, Release, guard) { + Ok(_) => break, + // We lost the race or weak CAS failed spuriously. Update the successor and try + // again. + Err(err) => next = err.current, + } + } + } + + /// Returns an iterator over all objects. + /// + /// # Caveat + /// + /// Every object that is inserted at the moment this function is called and persists at least + /// until the end of iteration will be returned. Since this iterator traverses a lock-free + /// linked list that may be concurrently modified, some additional caveats apply: + /// + /// 1. If a new object is inserted during iteration, it may or may not be returned. + /// 2. If an object is deleted during iteration, it may or may not be returned. + /// 3. The iteration may be aborted when it lost in a race condition. In this case, the winning + /// thread will continue to iterate over the same list. + pub fn iter<'g>(&'g self, guard: &'g Guard) -> Iter<'g, T, C> { + Iter { + guard, + pred: &self.head, + curr: self.head.load(Acquire, guard), + head: &self.head, + _marker: PhantomData, + } + } +} + +impl> Drop for List { + fn drop(&mut self) { + unsafe { + let guard = &unprotected(); + let mut curr = self.head.load(Relaxed, guard); + while let Some(c) = curr.as_ref() { + let succ = c.next.load(Relaxed, guard); + // Verify that all elements have been removed from the list. + assert_eq!(succ.tag(), 1); + + C::finalize(curr.deref()); + curr = succ; + } + } + } +} + +impl<'g, T: 'g, C: IsElement> Iterator for Iter<'g, T, C> { + type Item = Result<&'g T, IterError>; + + fn next(&mut self) -> Option { + while let Some(c) = unsafe { self.curr.as_ref() } { + let succ = c.next.load(Acquire, self.guard); + + if succ.tag() == 1 { + // This entry was removed. Try unlinking it from the list. + let succ = succ.with_tag(0); + + // The tag should never be zero, because removing a node after a logically deleted + // node leaves the list in an invalid state. + debug_assert!(self.curr.tag() == 0); + + match self + .pred + .compare_and_set(self.curr, succ, Acquire, self.guard) + { + Ok(_) => { + // We succeeded in unlinking this element from the list, so we have to + // schedule deallocation. Deferred drop is okay, because `list.delete()` + // can only be called if `T: 'static`. + unsafe { + let p = self.curr; + self.guard.defer_unchecked(move || C::finalize(p.deref())); + } + + // Move over the removed by only advancing `curr`, not `pred`. + self.curr = succ; + continue; + } + Err(_) => { + // A concurrent thread modified the predecessor node. Since it might've + // been deleted, we need to restart from `head`. + self.pred = self.head; + self.curr = self.head.load(Acquire, self.guard); + + return Some(Err(IterError::Stalled)); + } + } + } + + // Move one step forward. + self.pred = &c.next; + self.curr = succ; + + return Some(Ok(unsafe { C::element_of(c) })); + } + + // We reached the end of the list. + None + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crossbeam_utils::thread; + use std::sync::Barrier; + use {Collector, Owned}; + + impl IsElement for Entry { + fn entry_of(entry: &Entry) -> &Entry { + entry + } + + unsafe fn element_of(entry: &Entry) -> &Entry { + entry + } + + unsafe fn finalize(entry: &Entry) { + drop(Box::from_raw(entry as *const Entry as *mut Entry)); + } + } + + /// Checks whether the list retains inserted elements + /// and returns them in the correct order. + #[test] + fn insert() { + let collector = Collector::new(); + let handle = collector.register(); + let guard = handle.pin(); + + let l: List = List::new(); + + let e1 = Owned::new(Entry::default()).into_shared(&guard); + let e2 = Owned::new(Entry::default()).into_shared(&guard); + let e3 = Owned::new(Entry::default()).into_shared(&guard); + + unsafe { + l.insert(e1, &guard); + l.insert(e2, &guard); + l.insert(e3, &guard); + } + + let mut iter = l.iter(&guard); + let maybe_e3 = iter.next(); + assert!(maybe_e3.is_some()); + assert!(maybe_e3.unwrap().unwrap() as *const Entry == e3.as_raw()); + let maybe_e2 = iter.next(); + assert!(maybe_e2.is_some()); + assert!(maybe_e2.unwrap().unwrap() as *const Entry == e2.as_raw()); + let maybe_e1 = iter.next(); + assert!(maybe_e1.is_some()); + assert!(maybe_e1.unwrap().unwrap() as *const Entry == e1.as_raw()); + assert!(iter.next().is_none()); + + unsafe { + e1.as_ref().unwrap().delete(&guard); + e2.as_ref().unwrap().delete(&guard); + e3.as_ref().unwrap().delete(&guard); + } + } + + /// Checks whether elements can be removed from the list and whether + /// the correct elements are removed. + #[test] + fn delete() { + let collector = Collector::new(); + let handle = collector.register(); + let guard = handle.pin(); + + let l: List = List::new(); + + let e1 = Owned::new(Entry::default()).into_shared(&guard); + let e2 = Owned::new(Entry::default()).into_shared(&guard); + let e3 = Owned::new(Entry::default()).into_shared(&guard); + unsafe { + l.insert(e1, &guard); + l.insert(e2, &guard); + l.insert(e3, &guard); + e2.as_ref().unwrap().delete(&guard); + } + + let mut iter = l.iter(&guard); + let maybe_e3 = iter.next(); + assert!(maybe_e3.is_some()); + assert!(maybe_e3.unwrap().unwrap() as *const Entry == e3.as_raw()); + let maybe_e1 = iter.next(); + assert!(maybe_e1.is_some()); + assert!(maybe_e1.unwrap().unwrap() as *const Entry == e1.as_raw()); + assert!(iter.next().is_none()); + + unsafe { + e1.as_ref().unwrap().delete(&guard); + e3.as_ref().unwrap().delete(&guard); + } + + let mut iter = l.iter(&guard); + assert!(iter.next().is_none()); + } + + const THREADS: usize = 8; + const ITERS: usize = 512; + + /// Contends the list on insert and delete operations to make sure they can run concurrently. + #[test] + fn insert_delete_multi() { + let collector = Collector::new(); + + let l: List = List::new(); + let b = Barrier::new(THREADS); + + thread::scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + b.wait(); + + let handle = collector.register(); + let guard: Guard = handle.pin(); + let mut v = Vec::with_capacity(ITERS); + + for _ in 0..ITERS { + let e = Owned::new(Entry::default()).into_shared(&guard); + v.push(e); + unsafe { + l.insert(e, &guard); + } + } + + for e in v { + unsafe { + e.as_ref().unwrap().delete(&guard); + } + } + }); + } + }).unwrap(); + + let handle = collector.register(); + let guard = handle.pin(); + + let mut iter = l.iter(&guard); + assert!(iter.next().is_none()); + } + + /// Contends the list on iteration to make sure that it can be iterated over concurrently. + #[test] + fn iter_multi() { + let collector = Collector::new(); + + let l: List = List::new(); + let b = Barrier::new(THREADS); + + thread::scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + b.wait(); + + let handle = collector.register(); + let guard: Guard = handle.pin(); + let mut v = Vec::with_capacity(ITERS); + + for _ in 0..ITERS { + let e = Owned::new(Entry::default()).into_shared(&guard); + v.push(e); + unsafe { + l.insert(e, &guard); + } + } + + let mut iter = l.iter(&guard); + for _ in 0..ITERS { + assert!(iter.next().is_some()); + } + + for e in v { + unsafe { + e.as_ref().unwrap().delete(&guard); + } + } + }); + } + }).unwrap(); + + let handle = collector.register(); + let guard = handle.pin(); + + let mut iter = l.iter(&guard); + assert!(iter.next().is_none()); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/sync/mod.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/sync/mod.rs new file mode 100644 index 0000000..f8eb259 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/sync/mod.rs @@ -0,0 +1,4 @@ +//! Synchronization primitives. + +pub mod list; +pub mod queue; diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/sync/queue.rs b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/sync/queue.rs new file mode 100644 index 0000000..9c3372f --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.6.1/src/sync/queue.rs @@ -0,0 +1,434 @@ +//! Michael-Scott lock-free queue. +//! +//! Usable with any number of producers and consumers. +//! +//! Michael and Scott. Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue +//! Algorithms. PODC 1996. http://dl.acm.org/citation.cfm?id=248106 + +use core::mem::{self, ManuallyDrop}; +use core::ptr; +use core::sync::atomic::Ordering::{Acquire, Relaxed, Release}; + +use crossbeam_utils::CachePadded; + +use {unprotected, Atomic, Guard, Owned, Shared}; + +// The representation here is a singly-linked list, with a sentinel node at the front. In general +// the `tail` pointer may lag behind the actual tail. Non-sentinel nodes are either all `Data` or +// all `Blocked` (requests for data from blocked threads). +#[derive(Debug)] +pub struct Queue { + head: CachePadded>>, + tail: CachePadded>>, +} + +#[derive(Debug)] +struct Node { + /// The slot in which a value of type `T` can be stored. + /// + /// The type of `data` is `ManuallyDrop` because a `Node` doesn't always contain a `T`. + /// For example, the sentinel node in a queue never contains a value: its slot is always empty. + /// Other nodes start their life with a push operation and contain a value until it gets popped + /// out. After that such empty nodes get added to the collector for destruction. + data: ManuallyDrop, + + next: Atomic>, +} + +// Any particular `T` should never be accessed concurrently, so no need for `Sync`. +unsafe impl Sync for Queue {} +unsafe impl Send for Queue {} + +impl Queue { + /// Create a new, empty queue. + pub fn new() -> Queue { + let q = Queue { + head: CachePadded::new(Atomic::null()), + tail: CachePadded::new(Atomic::null()), + }; + let sentinel = Owned::new(Node { + data: unsafe { mem::uninitialized() }, + next: Atomic::null(), + }); + unsafe { + let guard = &unprotected(); + let sentinel = sentinel.into_shared(guard); + q.head.store(sentinel, Relaxed); + q.tail.store(sentinel, Relaxed); + q + } + } + + /// Attempts to atomically place `n` into the `next` pointer of `onto`, and returns `true` on + /// success. The queue's `tail` pointer may be updated. + #[inline(always)] + fn push_internal(&self, onto: Shared>, new: Shared>, guard: &Guard) -> bool { + // is `onto` the actual tail? + let o = unsafe { onto.deref() }; + let next = o.next.load(Acquire, guard); + if unsafe { next.as_ref().is_some() } { + // if not, try to "help" by moving the tail pointer forward + let _ = self.tail.compare_and_set(onto, next, Release, guard); + false + } else { + // looks like the actual tail; attempt to link in `n` + let result = o + .next + .compare_and_set(Shared::null(), new, Release, guard) + .is_ok(); + if result { + // try to move the tail pointer forward + let _ = self.tail.compare_and_set(onto, new, Release, guard); + } + result + } + } + + /// Adds `t` to the back of the queue, possibly waking up threads blocked on `pop`. + pub fn push(&self, t: T, guard: &Guard) { + let new = Owned::new(Node { + data: ManuallyDrop::new(t), + next: Atomic::null(), + }); + let new = Owned::into_shared(new, guard); + + loop { + // We push onto the tail, so we'll start optimistically by looking there first. + let tail = self.tail.load(Acquire, guard); + + // Attempt to push onto the `tail` snapshot; fails if `tail.next` has changed. + if self.push_internal(tail, new, guard) { + break; + } + } + } + + /// Attempts to pop a data node. `Ok(None)` if queue is empty; `Err(())` if lost race to pop. + #[inline(always)] + fn pop_internal(&self, guard: &Guard) -> Result, ()> { + let head = self.head.load(Acquire, guard); + let h = unsafe { head.deref() }; + let next = h.next.load(Acquire, guard); + match unsafe { next.as_ref() } { + Some(n) => unsafe { + self.head + .compare_and_set(head, next, Release, guard) + .map(|_| { + guard.defer_destroy(head); + Some(ManuallyDrop::into_inner(ptr::read(&n.data))) + }).map_err(|_| ()) + }, + None => Ok(None), + } + } + + /// Attempts to pop a data node, if the data satisfies the given condition. `Ok(None)` if queue + /// is empty or the data does not satisfy the condition; `Err(())` if lost race to pop. + #[inline(always)] + fn pop_if_internal(&self, condition: F, guard: &Guard) -> Result, ()> + where + T: Sync, + F: Fn(&T) -> bool, + { + let head = self.head.load(Acquire, guard); + let h = unsafe { head.deref() }; + let next = h.next.load(Acquire, guard); + match unsafe { next.as_ref() } { + Some(n) if condition(&n.data) => unsafe { + self.head + .compare_and_set(head, next, Release, guard) + .map(|_| { + guard.defer_destroy(head); + Some(ManuallyDrop::into_inner(ptr::read(&n.data))) + }).map_err(|_| ()) + }, + None | Some(_) => Ok(None), + } + } + + /// Attempts to dequeue from the front. + /// + /// Returns `None` if the queue is observed to be empty. + pub fn try_pop(&self, guard: &Guard) -> Option { + loop { + if let Ok(head) = self.pop_internal(guard) { + return head; + } + } + } + + /// Attempts to dequeue from the front, if the item satisfies the given condition. + /// + /// Returns `None` if the queue is observed to be empty, or the head does not satisfy the given + /// condition. + pub fn try_pop_if(&self, condition: F, guard: &Guard) -> Option + where + T: Sync, + F: Fn(&T) -> bool, + { + loop { + if let Ok(head) = self.pop_if_internal(&condition, guard) { + return head; + } + } + } +} + +impl Drop for Queue { + fn drop(&mut self) { + unsafe { + let guard = &unprotected(); + + while let Some(_) = self.try_pop(guard) {} + + // Destroy the remaining sentinel node. + let sentinel = self.head.load(Relaxed, guard); + drop(sentinel.into_owned()); + } + } +} + +#[cfg(test)] +mod test { + use super::*; + use crossbeam_utils::thread; + use pin; + + struct Queue { + queue: super::Queue, + } + + impl Queue { + pub fn new() -> Queue { + Queue { + queue: super::Queue::new(), + } + } + + pub fn push(&self, t: T) { + let guard = &pin(); + self.queue.push(t, guard); + } + + pub fn is_empty(&self) -> bool { + let guard = &pin(); + let head = self.queue.head.load(Acquire, guard); + let h = unsafe { head.deref() }; + h.next.load(Acquire, guard).is_null() + } + + pub fn try_pop(&self) -> Option { + let guard = &pin(); + self.queue.try_pop(guard) + } + + pub fn pop(&self) -> T { + loop { + match self.try_pop() { + None => continue, + Some(t) => return t, + } + } + } + } + + const CONC_COUNT: i64 = 1000000; + + #[test] + fn push_try_pop_1() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + q.push(37); + assert!(!q.is_empty()); + assert_eq!(q.try_pop(), Some(37)); + assert!(q.is_empty()); + } + + #[test] + fn push_try_pop_2() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + q.push(37); + q.push(48); + assert_eq!(q.try_pop(), Some(37)); + assert!(!q.is_empty()); + assert_eq!(q.try_pop(), Some(48)); + assert!(q.is_empty()); + } + + #[test] + fn push_try_pop_many_seq() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + for i in 0..200 { + q.push(i) + } + assert!(!q.is_empty()); + for i in 0..200 { + assert_eq!(q.try_pop(), Some(i)); + } + assert!(q.is_empty()); + } + + #[test] + fn push_pop_1() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + q.push(37); + assert!(!q.is_empty()); + assert_eq!(q.pop(), 37); + assert!(q.is_empty()); + } + + #[test] + fn push_pop_2() { + let q: Queue = Queue::new(); + q.push(37); + q.push(48); + assert_eq!(q.pop(), 37); + assert_eq!(q.pop(), 48); + } + + #[test] + fn push_pop_many_seq() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + for i in 0..200 { + q.push(i) + } + assert!(!q.is_empty()); + for i in 0..200 { + assert_eq!(q.pop(), i); + } + assert!(q.is_empty()); + } + + #[test] + fn push_try_pop_many_spsc() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + + thread::scope(|scope| { + scope.spawn(|_| { + let mut next = 0; + + while next < CONC_COUNT { + if let Some(elem) = q.try_pop() { + assert_eq!(elem, next); + next += 1; + } + } + }); + + for i in 0..CONC_COUNT { + q.push(i) + } + }).unwrap(); + } + + #[test] + fn push_try_pop_many_spmc() { + fn recv(_t: i32, q: &Queue) { + let mut cur = -1; + for _i in 0..CONC_COUNT { + if let Some(elem) = q.try_pop() { + assert!(elem > cur); + cur = elem; + + if cur == CONC_COUNT - 1 { + break; + } + } + } + } + + let q: Queue = Queue::new(); + assert!(q.is_empty()); + thread::scope(|scope| { + for i in 0..3 { + scope.spawn(|_| recv(i, &q)); + } + + scope.spawn(|_| { + for i in 0..CONC_COUNT { + q.push(i); + } + }); + }).unwrap(); + } + + #[test] + fn push_try_pop_many_mpmc() { + enum LR { + Left(i64), + Right(i64), + } + + let q: Queue = Queue::new(); + assert!(q.is_empty()); + + thread::scope(|scope| { + for _t in 0..2 { + scope.spawn(|_| { + for i in CONC_COUNT - 1..CONC_COUNT { + q.push(LR::Left(i)) + } + }); + scope.spawn(|_| { + for i in CONC_COUNT - 1..CONC_COUNT { + q.push(LR::Right(i)) + } + }); + scope.spawn(|_| { + let mut vl = vec![]; + let mut vr = vec![]; + for _i in 0..CONC_COUNT { + match q.try_pop() { + Some(LR::Left(x)) => vl.push(x), + Some(LR::Right(x)) => vr.push(x), + _ => {} + } + } + + let mut vl2 = vl.clone(); + let mut vr2 = vr.clone(); + vl2.sort(); + vr2.sort(); + + assert_eq!(vl, vl2); + assert_eq!(vr, vr2); + }); + } + }).unwrap(); + } + + #[test] + fn push_pop_many_spsc() { + let q: Queue = Queue::new(); + + thread::scope(|scope| { + scope.spawn(|_| { + let mut next = 0; + while next < CONC_COUNT { + assert_eq!(q.pop(), next); + next += 1; + } + }); + + for i in 0..CONC_COUNT { + q.push(i) + } + }).unwrap(); + assert!(q.is_empty()); + } + + #[test] + fn is_empty_dont_pop() { + let q: Queue = Queue::new(); + q.push(20); + q.push(20); + assert!(!q.is_empty()); + assert!(!q.is_empty()); + assert!(q.try_pop().is_some()); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/.cargo-checksum.json b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/.cargo-checksum.json new file mode 100644 index 0000000..81aef2a --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"fdffb6df6ae4827aa7c6543788a474ed47d96eb0b1e9d6f4d41ee922f921e9a9","Cargo.toml":"abb9a5a47d688f63ee2f82fa62900d357a8cce329f98a615a5a5a6e8c4516d41","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","README.md":"2f095ef276fadd1bc42e4ea16c6f9a8d098ff3c39f1e72a899ae02326bcf14a5","benches/defer.rs":"a4b17e7b96bef2f268c76925cfa58744b81504146426fab6f781ff0b2f666f2b","benches/flush.rs":"1d93ac40cb78bf2c55332869d4f7d1b283571bff4a0c6dbe245f02dd65e8e1d8","benches/pin.rs":"dd937ecfc8d7353995d438a7f4be383e91c002e9ee6acd4caa703bb340c97383","examples/sanitize.rs":"90f80709cd620e994f699d84ab9ce88f8552500d08bac64d60def5792460495a","examples/treiber_stack.rs":"b5d3bafa6d57af435b00d04145572a51ea871f64ff2c23ba544054c4c4145d65","src/atomic.rs":"8fc50bf82b298298b6512311df5f6da2c5c909d0b6eafa7776850538e65045e6","src/collector.rs":"a783049d3cb22989ec978366fd865f31562b0acbfbd0bc9ff9b600ceaa5ffa87","src/default.rs":"6afda8fd141ad594bed62baeb73f2e97c5ef33b051969a542bb908946fe39dd1","src/deferred.rs":"d5ace4be72e926cedb699cd19ae4076bbe87d795d650aa68f264106e6ff15bee","src/epoch.rs":"76dd63356d5bc52e741883d39abb636e4ccb04d20499fb2a0ce797bb81aa4e91","src/guard.rs":"1d90d690b02ee735263e845827f720be44faea871852731dd8444b92796f1539","src/internal.rs":"9ff5b0fa05cbfa550ef9eaf8bd2025445a097d9da59efb7b976580dd0a09a2ff","src/lib.rs":"6eaea9a81b55844c1fd084924b8b7f750fed33aae2a75e2d5f430ed054092a44","src/sync/list.rs":"43e09e9cf79d7cf95b5110051de9dd47ab7761e3bc90ea3be16c4cbabce6d4be","src/sync/mod.rs":"2da979ca3a2293f7626a2e6a9ab2fad758d92e3d2bed6cc712ef59eeeea87eab","src/sync/queue.rs":"34991ba75fbc8ba3494bf91559727feb1919f9f39b3c67d6e2aca82376ef9d3c"},"package":"fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9"} \ No newline at end of file diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/BUILD b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/BUILD new file mode 100644 index 0000000..be359dd --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/BUILD @@ -0,0 +1,57 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "crossbeam_epoch", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/arrayvec-0.4.12:arrayvec", + "//third_party/cargo/vendor/cfg-if-0.1.10:cfg_if", + "//third_party/cargo/vendor/crossbeam-utils-0.6.6:crossbeam_utils", + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + "//third_party/cargo/vendor/memoffset-0.5.3:memoffset", + "//third_party/cargo/vendor/scopeguard-1.0.0:scopeguard", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.7.2", + crate_features = [ + "crossbeam-utils", + "default", + "lazy_static", + "std", + ], +) + +# Unsupported target "defer" with type "bench" omitted +# Unsupported target "flush" with type "bench" omitted +# Unsupported target "pin" with type "bench" omitted +# Unsupported target "sanitize" with type "example" omitted +# Unsupported target "treiber_stack" with type "example" omitted diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/CHANGELOG.md b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/CHANGELOG.md new file mode 100644 index 0000000..f47f7b8 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/CHANGELOG.md @@ -0,0 +1,81 @@ +# Version 0.7.2 + +- Add `Atomic::into_owned()`. +- Update `memoffset` dependency. + +# Version 0.7.1 + +- Add `Shared::deref_mut()`. +- Add a Treiber stack to examples. + +# Version 0.7.0 + +- Remove `Guard::clone()`. +- Bump dependencies. + +# Version 0.6.1 + +- Update `crossbeam-utils` to `0.6`. + +# Version 0.6.0 + +- `defer` now requires `F: Send + 'static`. +- Bump the minimum Rust version to 1.26. +- Pinning while TLS is tearing down does not fail anymore. +- Rename `Handle` to `LocalHandle`. +- Add `defer_unchecked` and `defer_destroy`. +- Remove `Clone` impl for `LocalHandle`. + +# Version 0.5.2 + +- Update `crossbeam-utils` to `0.5`. + +# Version 0.5.1 + +- Fix compatibility with the latest Rust nightly. + +# Version 0.5.0 + +- Update `crossbeam-utils` to `0.4`. +- Specify the minimum Rust version to `1.25.0`. + +# Version 0.4.3 + +- Downgrade `crossbeam-utils` to `0.3` because it was a breaking change. + +# Version 0.4.2 + +- Expose the `Pointer` trait. +- Warn missing docs and missing debug impls. +- Update `crossbeam-utils` to `0.4`. + +# Version 0.4.1 + +- Add `Debug` impls for `Collector`, `Handle`, and `Guard`. +- Add `load_consume` to `Atomic`. +- Rename `Collector::handle` to `Collector::register`. +- Remove the `Send` implementation for `Handle` (this was a bug). Only + `Collector`s can be shared among multiple threads, while `Handle`s and + `Guard`s must stay within the thread in which they were created. + +# Version 0.4.0 + +- Update dependencies. +- Remove support for Rust 1.13. + +# Version 0.3.0 + +- Add support for Rust 1.13. +- Improve documentation for CAS. + +# Version 0.2.0 + +- Add method `Owned::into_box`. +- Fix a use-after-free bug in `Local::finalize`. +- Fix an ordering bug in `Global::push_bag`. +- Fix a bug in calculating distance between epochs. +- Remove `impl Into> for Owned`. + +# Version 0.1.0 + +- First version of the new epoch-based GC. diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/Cargo.toml b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/Cargo.toml new file mode 100644 index 0000000..93de822 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/Cargo.toml @@ -0,0 +1,54 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "crossbeam-epoch" +version = "0.7.2" +authors = ["The Crossbeam Project Developers"] +description = "Epoch-based garbage collection" +homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-epoch" +documentation = "https://docs.rs/crossbeam-epoch" +readme = "README.md" +keywords = ["lock-free", "rcu", "atomic", "garbage"] +categories = ["concurrency", "memory-management", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/crossbeam-rs/crossbeam" +[dependencies.arrayvec] +version = "0.4" +default-features = false + +[dependencies.cfg-if] +version = "0.1.2" + +[dependencies.crossbeam-utils] +version = "0.6" +default-features = false + +[dependencies.lazy_static] +version = "1" +optional = true + +[dependencies.memoffset] +version = "0.5" + +[dependencies.scopeguard] +version = "1" +default-features = false +[dev-dependencies.rand] +version = "0.6" + +[features] +alloc = ["crossbeam-utils/alloc"] +default = ["std"] +nightly = ["crossbeam-utils/nightly", "arrayvec/use_union"] +sanitize = [] +std = ["crossbeam-utils/std", "lazy_static"] diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/LICENSE-APACHE b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/LICENSE-MIT b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/LICENSE-MIT new file mode 100644 index 0000000..068d491 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/LICENSE-MIT @@ -0,0 +1,27 @@ +The MIT License (MIT) + +Copyright (c) 2019 The Crossbeam Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/README.md b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/README.md new file mode 100644 index 0000000..a1fb414 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/README.md @@ -0,0 +1,53 @@ +# Crossbeam Epoch + +[![Build Status](https://travis-ci.org/crossbeam-rs/crossbeam.svg?branch=master)]( +https://travis-ci.org/crossbeam-rs/crossbeam) +[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)]( +https://github.com/crossbeam-rs/crossbeam-epoch) +[![Cargo](https://img.shields.io/crates/v/crossbeam-epoch.svg)]( +https://crates.io/crates/crossbeam-epoch) +[![Documentation](https://docs.rs/crossbeam-epoch/badge.svg)]( +https://docs.rs/crossbeam-epoch) +[![Rust 1.26+](https://img.shields.io/badge/rust-1.26+-lightgray.svg)]( +https://www.rust-lang.org) +[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq) + +This crate provides epoch-based garbage collection for building concurrent data structures. + +When a thread removes an object from a concurrent data structure, other threads +may be still using pointers to it at the same time, so it cannot be destroyed +immediately. Epoch-based GC is an efficient mechanism for deferring destruction of +shared objects until no pointers to them can exist. + +Everything in this crate except the global GC can be used in `no_std` environments, provided that +features `alloc` and `nightly` are enabled. + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +crossbeam-epoch = "0.7" +``` + +Next, add this to your crate: + +```rust +extern crate crossbeam_epoch as epoch; +``` + +## License + +Licensed under either of + + * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +#### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/benches/defer.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/benches/defer.rs new file mode 100644 index 0000000..e3693e7 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/benches/defer.rs @@ -0,0 +1,71 @@ +#![feature(test)] + +extern crate crossbeam_epoch as epoch; +extern crate crossbeam_utils as utils; +extern crate test; + +use epoch::Owned; +use test::Bencher; +use utils::thread::scope; + +#[bench] +fn single_alloc_defer_free(b: &mut Bencher) { + b.iter(|| { + let guard = &epoch::pin(); + let p = Owned::new(1).into_shared(guard); + unsafe { + guard.defer_destroy(p); + } + }); +} + +#[bench] +fn single_defer(b: &mut Bencher) { + b.iter(|| { + let guard = &epoch::pin(); + guard.defer(move || ()); + }); +} + +#[bench] +fn multi_alloc_defer_free(b: &mut Bencher) { + const THREADS: usize = 16; + const STEPS: usize = 10_000; + + b.iter(|| { + scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + for _ in 0..STEPS { + let guard = &epoch::pin(); + let p = Owned::new(1).into_shared(guard); + unsafe { + guard.defer_destroy(p); + } + } + }); + } + }) + .unwrap(); + }); +} + +#[bench] +fn multi_defer(b: &mut Bencher) { + const THREADS: usize = 16; + const STEPS: usize = 10_000; + + b.iter(|| { + scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + for _ in 0..STEPS { + let guard = &epoch::pin(); + guard.defer(move || ()); + } + }); + } + }) + .unwrap(); + }); +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/benches/flush.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/benches/flush.rs new file mode 100644 index 0000000..156d4b0 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/benches/flush.rs @@ -0,0 +1,53 @@ +#![feature(test)] + +extern crate crossbeam_epoch as epoch; +extern crate crossbeam_utils as utils; +extern crate test; + +use std::sync::Barrier; + +use test::Bencher; +use utils::thread::scope; + +#[bench] +fn single_flush(b: &mut Bencher) { + const THREADS: usize = 16; + + let start = Barrier::new(THREADS + 1); + let end = Barrier::new(THREADS + 1); + + scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + epoch::pin(); + start.wait(); + end.wait(); + }); + } + + start.wait(); + b.iter(|| epoch::pin().flush()); + end.wait(); + }) + .unwrap(); +} + +#[bench] +fn multi_flush(b: &mut Bencher) { + const THREADS: usize = 16; + const STEPS: usize = 10_000; + + b.iter(|| { + scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + for _ in 0..STEPS { + let guard = &epoch::pin(); + guard.flush(); + } + }); + } + }) + .unwrap(); + }); +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/benches/pin.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/benches/pin.rs new file mode 100644 index 0000000..4b26f22 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/benches/pin.rs @@ -0,0 +1,32 @@ +#![feature(test)] + +extern crate crossbeam_epoch as epoch; +extern crate crossbeam_utils as utils; +extern crate test; + +use test::Bencher; +use utils::thread::scope; + +#[bench] +fn single_pin(b: &mut Bencher) { + b.iter(|| epoch::pin()); +} + +#[bench] +fn multi_pin(b: &mut Bencher) { + const THREADS: usize = 16; + const STEPS: usize = 100_000; + + b.iter(|| { + scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + for _ in 0..STEPS { + epoch::pin(); + } + }); + } + }) + .unwrap(); + }); +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/examples/sanitize.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/examples/sanitize.rs new file mode 100644 index 0000000..12f1263 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/examples/sanitize.rs @@ -0,0 +1,69 @@ +extern crate crossbeam_epoch as epoch; +extern crate rand; + +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed}; +use std::sync::Arc; +use std::thread; +use std::time::{Duration, Instant}; + +use epoch::{Atomic, Collector, LocalHandle, Owned, Shared}; +use rand::Rng; + +fn worker(a: Arc>, handle: LocalHandle) -> usize { + let mut rng = rand::thread_rng(); + let mut sum = 0; + + if rng.gen() { + thread::sleep(Duration::from_millis(1)); + } + let timeout = Duration::from_millis(rng.gen_range(0, 10)); + let now = Instant::now(); + + while now.elapsed() < timeout { + for _ in 0..100 { + let guard = &handle.pin(); + guard.flush(); + + let val = if rng.gen() { + let p = a.swap(Owned::new(AtomicUsize::new(sum)), AcqRel, guard); + unsafe { + guard.defer_destroy(p); + guard.flush(); + p.deref().load(Relaxed) + } + } else { + let p = a.load(Acquire, guard); + unsafe { p.deref().fetch_add(sum, Relaxed) } + }; + + sum = sum.wrapping_add(val); + } + } + + sum +} + +fn main() { + for _ in 0..100 { + let collector = Collector::new(); + let a = Arc::new(Atomic::new(AtomicUsize::new(777))); + + let threads = (0..16) + .map(|_| { + let a = a.clone(); + let c = collector.clone(); + thread::spawn(move || worker(a, c.register())) + }) + .collect::>(); + + for t in threads { + t.join().unwrap(); + } + + unsafe { + a.swap(Shared::null(), AcqRel, epoch::unprotected()) + .into_owned(); + } + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/examples/treiber_stack.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/examples/treiber_stack.rs new file mode 100644 index 0000000..cc15c0d --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/examples/treiber_stack.rs @@ -0,0 +1,110 @@ +extern crate crossbeam_epoch as epoch; +extern crate crossbeam_utils as utils; + +use std::mem::ManuallyDrop; +use std::ptr; +use std::sync::atomic::Ordering::{Acquire, Relaxed, Release}; + +use epoch::{Atomic, Owned}; +use utils::thread::scope; + +/// Treiber's lock-free stack. +/// +/// Usable with any number of producers and consumers. +#[derive(Debug)] +pub struct TreiberStack { + head: Atomic>, +} + +#[derive(Debug)] +struct Node { + data: ManuallyDrop, + next: Atomic>, +} + +impl TreiberStack { + /// Creates a new, empty stack. + pub fn new() -> TreiberStack { + TreiberStack { + head: Atomic::null(), + } + } + + /// Pushes a value on top of the stack. + pub fn push(&self, t: T) { + let mut n = Owned::new(Node { + data: ManuallyDrop::new(t), + next: Atomic::null(), + }); + + let guard = epoch::pin(); + + loop { + let head = self.head.load(Relaxed, &guard); + n.next.store(head, Relaxed); + + match self.head.compare_and_set(head, n, Release, &guard) { + Ok(_) => break, + Err(e) => n = e.new, + } + } + } + + /// Attempts to pop the top element from the stack. + /// + /// Returns `None` if the stack is empty. + pub fn pop(&self) -> Option { + let guard = epoch::pin(); + loop { + let head = self.head.load(Acquire, &guard); + + match unsafe { head.as_ref() } { + Some(h) => { + let next = h.next.load(Relaxed, &guard); + + if self + .head + .compare_and_set(head, next, Release, &guard) + .is_ok() + { + unsafe { + guard.defer_destroy(head); + return Some(ManuallyDrop::into_inner(ptr::read(&(*h).data))); + } + } + } + None => return None, + } + } + } + + /// Returns `true` if the stack is empty. + pub fn is_empty(&self) -> bool { + let guard = epoch::pin(); + self.head.load(Acquire, &guard).is_null() + } +} + +impl Drop for TreiberStack { + fn drop(&mut self) { + while self.pop().is_some() {} + } +} + +fn main() { + let stack = TreiberStack::new(); + + scope(|scope| { + for _ in 0..10 { + scope.spawn(|_| { + for i in 0..10_000 { + stack.push(i); + assert!(stack.pop().is_some()); + } + }); + } + }) + .unwrap(); + + assert!(stack.pop().is_none()); +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/atomic.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/atomic.rs new file mode 100644 index 0000000..0444c11 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/atomic.rs @@ -0,0 +1,1201 @@ +use alloc::boxed::Box; +use core::borrow::{Borrow, BorrowMut}; +use core::cmp; +use core::fmt; +use core::marker::PhantomData; +use core::mem; +use core::ops::{Deref, DerefMut}; +use core::ptr; +use core::sync::atomic::{AtomicUsize, Ordering}; + +use crossbeam_utils::atomic::AtomicConsume; +use guard::Guard; + +/// Given ordering for the success case in a compare-exchange operation, returns the strongest +/// appropriate ordering for the failure case. +#[inline] +fn strongest_failure_ordering(ord: Ordering) -> Ordering { + use self::Ordering::*; + match ord { + Relaxed | Release => Relaxed, + Acquire | AcqRel => Acquire, + _ => SeqCst, + } +} + +/// The error returned on failed compare-and-set operation. +pub struct CompareAndSetError<'g, T: 'g, P: Pointer> { + /// The value in the atomic pointer at the time of the failed operation. + pub current: Shared<'g, T>, + + /// The new value, which the operation failed to store. + pub new: P, +} + +impl<'g, T: 'g, P: Pointer + fmt::Debug> fmt::Debug for CompareAndSetError<'g, T, P> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("CompareAndSetError") + .field("current", &self.current) + .field("new", &self.new) + .finish() + } +} + +/// Memory orderings for compare-and-set operations. +/// +/// A compare-and-set operation can have different memory orderings depending on whether it +/// succeeds or fails. This trait generalizes different ways of specifying memory orderings. +/// +/// The two ways of specifying orderings for compare-and-set are: +/// +/// 1. Just one `Ordering` for the success case. In case of failure, the strongest appropriate +/// ordering is chosen. +/// 2. A pair of `Ordering`s. The first one is for the success case, while the second one is +/// for the failure case. +pub trait CompareAndSetOrdering { + /// The ordering of the operation when it succeeds. + fn success(&self) -> Ordering; + + /// The ordering of the operation when it fails. + /// + /// The failure ordering can't be `Release` or `AcqRel` and must be equivalent or weaker than + /// the success ordering. + fn failure(&self) -> Ordering; +} + +impl CompareAndSetOrdering for Ordering { + #[inline] + fn success(&self) -> Ordering { + *self + } + + #[inline] + fn failure(&self) -> Ordering { + strongest_failure_ordering(*self) + } +} + +impl CompareAndSetOrdering for (Ordering, Ordering) { + #[inline] + fn success(&self) -> Ordering { + self.0 + } + + #[inline] + fn failure(&self) -> Ordering { + self.1 + } +} + +/// Panics if the pointer is not properly unaligned. +#[inline] +fn ensure_aligned(raw: *const T) { + assert_eq!(raw as usize & low_bits::(), 0, "unaligned pointer"); +} + +/// Returns a bitmask containing the unused least significant bits of an aligned pointer to `T`. +#[inline] +fn low_bits() -> usize { + (1 << mem::align_of::().trailing_zeros()) - 1 +} + +/// Given a tagged pointer `data`, returns the same pointer, but tagged with `tag`. +/// +/// `tag` is truncated to fit into the unused bits of the pointer to `T`. +#[inline] +fn data_with_tag(data: usize, tag: usize) -> usize { + (data & !low_bits::()) | (tag & low_bits::()) +} + +/// Decomposes a tagged pointer `data` into the pointer and the tag. +#[inline] +fn decompose_data(data: usize) -> (*mut T, usize) { + let raw = (data & !low_bits::()) as *mut T; + let tag = data & low_bits::(); + (raw, tag) +} + +/// An atomic pointer that can be safely shared between threads. +/// +/// The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused +/// least significant bits of the address. More precisely, a tag should be less than `(1 << +/// mem::align_of::().trailing_zeros())`. +/// +/// Any method that loads the pointer must be passed a reference to a [`Guard`]. +/// +/// [`Guard`]: struct.Guard.html +pub struct Atomic { + data: AtomicUsize, + _marker: PhantomData<*mut T>, +} + +unsafe impl Send for Atomic {} +unsafe impl Sync for Atomic {} + +impl Atomic { + /// Returns a new atomic pointer pointing to the tagged pointer `data`. + fn from_usize(data: usize) -> Self { + Self { + data: AtomicUsize::new(data), + _marker: PhantomData, + } + } + + /// Returns a new null atomic pointer. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Atomic; + /// + /// let a = Atomic::::null(); + /// ``` + #[cfg(not(feature = "nightly"))] + pub fn null() -> Atomic { + Self { + data: AtomicUsize::new(0), + _marker: PhantomData, + } + } + + /// Returns a new null atomic pointer. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Atomic; + /// + /// let a = Atomic::::null(); + /// ``` + #[cfg(feature = "nightly")] + pub const fn null() -> Atomic { + Self { + data: AtomicUsize::new(0), + _marker: PhantomData, + } + } + + /// Allocates `value` on the heap and returns a new atomic pointer pointing to it. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Atomic; + /// + /// let a = Atomic::new(1234); + /// ``` + pub fn new(value: T) -> Atomic { + Self::from(Owned::new(value)) + } + + /// Loads a `Shared` from the atomic pointer. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// let p = a.load(SeqCst, guard); + /// ``` + pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.load(ord)) } + } + + /// Loads a `Shared` from the atomic pointer using a "consume" memory ordering. + /// + /// This is similar to the "acquire" ordering, except that an ordering is + /// only guaranteed with operations that "depend on" the result of the load. + /// However consume loads are usually much faster than acquire loads on + /// architectures with a weak memory model since they don't require memory + /// fence instructions. + /// + /// The exact definition of "depend on" is a bit vague, but it works as you + /// would expect in practice since a lot of software, especially the Linux + /// kernel, rely on this behavior. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// let p = a.load_consume(guard); + /// ``` + pub fn load_consume<'g>(&self, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.load_consume()) } + } + + /// Stores a `Shared` or `Owned` pointer into the atomic pointer. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// a.store(Shared::null(), SeqCst); + /// a.store(Owned::new(1234), SeqCst); + /// ``` + pub fn store<'g, P: Pointer>(&self, new: P, ord: Ordering) { + self.data.store(new.into_usize(), ord); + } + + /// Stores a `Shared` or `Owned` pointer into the atomic pointer, returning the previous + /// `Shared`. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// let p = a.swap(Shared::null(), SeqCst, guard); + /// ``` + pub fn swap<'g, P: Pointer>(&self, new: P, ord: Ordering, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.swap(new.into_usize(), ord)) } + } + + /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current + /// value is the same as `current`. The tag is also taken into account, so two pointers to the + /// same object, but with different tags, will not be considered equal. + /// + /// The return value is a result indicating whether the new pointer was written. On success the + /// pointer that was written is returned. On failure the actual current value and `new` are + /// returned. + /// + /// This method takes a [`CompareAndSetOrdering`] argument which describes the memory + /// ordering of this operation. + /// + /// [`CompareAndSetOrdering`]: trait.CompareAndSetOrdering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// + /// let guard = &epoch::pin(); + /// let mut curr = a.load(SeqCst, guard); + /// let res1 = a.compare_and_set(curr, Shared::null(), SeqCst, guard); + /// let res2 = a.compare_and_set(curr, Owned::new(5678), SeqCst, guard); + /// ``` + pub fn compare_and_set<'g, O, P>( + &self, + current: Shared, + new: P, + ord: O, + _: &'g Guard, + ) -> Result, CompareAndSetError<'g, T, P>> + where + O: CompareAndSetOrdering, + P: Pointer, + { + let new = new.into_usize(); + self.data + .compare_exchange(current.into_usize(), new, ord.success(), ord.failure()) + .map(|_| unsafe { Shared::from_usize(new) }) + .map_err(|current| unsafe { + CompareAndSetError { + current: Shared::from_usize(current), + new: P::from_usize(new), + } + }) + } + + /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current + /// value is the same as `current`. The tag is also taken into account, so two pointers to the + /// same object, but with different tags, will not be considered equal. + /// + /// Unlike [`compare_and_set`], this method is allowed to spuriously fail even when comparison + /// succeeds, which can result in more efficient code on some platforms. The return value is a + /// result indicating whether the new pointer was written. On success the pointer that was + /// written is returned. On failure the actual current value and `new` are returned. + /// + /// This method takes a [`CompareAndSetOrdering`] argument which describes the memory + /// ordering of this operation. + /// + /// [`compare_and_set`]: struct.Atomic.html#method.compare_and_set + /// [`CompareAndSetOrdering`]: trait.CompareAndSetOrdering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// + /// let mut new = Owned::new(5678); + /// let mut ptr = a.load(SeqCst, guard); + /// loop { + /// match a.compare_and_set_weak(ptr, new, SeqCst, guard) { + /// Ok(p) => { + /// ptr = p; + /// break; + /// } + /// Err(err) => { + /// ptr = err.current; + /// new = err.new; + /// } + /// } + /// } + /// + /// let mut curr = a.load(SeqCst, guard); + /// loop { + /// match a.compare_and_set_weak(curr, Shared::null(), SeqCst, guard) { + /// Ok(_) => break, + /// Err(err) => curr = err.current, + /// } + /// } + /// ``` + pub fn compare_and_set_weak<'g, O, P>( + &self, + current: Shared, + new: P, + ord: O, + _: &'g Guard, + ) -> Result, CompareAndSetError<'g, T, P>> + where + O: CompareAndSetOrdering, + P: Pointer, + { + let new = new.into_usize(); + self.data + .compare_exchange_weak(current.into_usize(), new, ord.success(), ord.failure()) + .map(|_| unsafe { Shared::from_usize(new) }) + .map_err(|current| unsafe { + CompareAndSetError { + current: Shared::from_usize(current), + new: P::from_usize(new), + } + }) + } + + /// Bitwise "and" with the current tag. + /// + /// Performs a bitwise "and" operation on the current tag and the argument `val`, and sets the + /// new tag to the result. Returns the previous pointer. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::::from(Shared::null().with_tag(3)); + /// let guard = &epoch::pin(); + /// assert_eq!(a.fetch_and(2, SeqCst, guard).tag(), 3); + /// assert_eq!(a.load(SeqCst, guard).tag(), 2); + /// ``` + pub fn fetch_and<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.fetch_and(val | !low_bits::(), ord)) } + } + + /// Bitwise "or" with the current tag. + /// + /// Performs a bitwise "or" operation on the current tag and the argument `val`, and sets the + /// new tag to the result. Returns the previous pointer. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::::from(Shared::null().with_tag(1)); + /// let guard = &epoch::pin(); + /// assert_eq!(a.fetch_or(2, SeqCst, guard).tag(), 1); + /// assert_eq!(a.load(SeqCst, guard).tag(), 3); + /// ``` + pub fn fetch_or<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.fetch_or(val & low_bits::(), ord)) } + } + + /// Bitwise "xor" with the current tag. + /// + /// Performs a bitwise "xor" operation on the current tag and the argument `val`, and sets the + /// new tag to the result. Returns the previous pointer. + /// + /// This method takes an [`Ordering`] argument which describes the memory ordering of this + /// operation. + /// + /// [`Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Shared}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::::from(Shared::null().with_tag(1)); + /// let guard = &epoch::pin(); + /// assert_eq!(a.fetch_xor(3, SeqCst, guard).tag(), 1); + /// assert_eq!(a.load(SeqCst, guard).tag(), 2); + /// ``` + pub fn fetch_xor<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.data.fetch_xor(val & low_bits::(), ord)) } + } + + /// Takes ownership of the pointee. + /// + /// This consumes the atomic and converts it into [`Owned`]. As [`Atomic`] doesn't have a + /// destructor and doesn't drop the pointee while [`Owned`] does, this is suitable for + /// destructors of data structures. + /// + /// # Panics + /// + /// Panics if this pointer is null, but only in debug mode. + /// + /// # Safety + /// + /// This method may be called only if the pointer is valid and nobody else is holding a + /// reference to the same object. + /// + /// # Examples + /// + /// ```rust + /// # use std::mem; + /// # use crossbeam_epoch::Atomic; + /// struct DataStructure { + /// ptr: Atomic, + /// } + /// + /// impl Drop for DataStructure { + /// fn drop(&mut self) { + /// // By now the DataStructure lives only in our thread and we are sure we don't hold + /// // any Shared or & to it ourselves. + /// unsafe { + /// drop(mem::replace(&mut self.ptr, Atomic::null()).into_owned()); + /// } + /// } + /// } + /// ``` + pub unsafe fn into_owned(self) -> Owned { + Owned::from_usize(self.data.into_inner()) + } +} + +impl fmt::Debug for Atomic { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let data = self.data.load(Ordering::SeqCst); + let (raw, tag) = decompose_data::(data); + + f.debug_struct("Atomic") + .field("raw", &raw) + .field("tag", &tag) + .finish() + } +} + +impl fmt::Pointer for Atomic { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let data = self.data.load(Ordering::SeqCst); + let (raw, _) = decompose_data::(data); + fmt::Pointer::fmt(&raw, f) + } +} + +impl Clone for Atomic { + /// Returns a copy of the atomic value. + /// + /// Note that a `Relaxed` load is used here. If you need synchronization, use it with other + /// atomics or fences. + fn clone(&self) -> Self { + let data = self.data.load(Ordering::Relaxed); + Atomic::from_usize(data) + } +} + +impl Default for Atomic { + fn default() -> Self { + Atomic::null() + } +} + +impl From> for Atomic { + /// Returns a new atomic pointer pointing to `owned`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{Atomic, Owned}; + /// + /// let a = Atomic::::from(Owned::new(1234)); + /// ``` + fn from(owned: Owned) -> Self { + let data = owned.data; + mem::forget(owned); + Self::from_usize(data) + } +} + +impl From> for Atomic { + fn from(b: Box) -> Self { + Self::from(Owned::from(b)) + } +} + +impl From for Atomic { + fn from(t: T) -> Self { + Self::new(t) + } +} + +impl<'g, T> From> for Atomic { + /// Returns a new atomic pointer pointing to `ptr`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{Atomic, Shared}; + /// + /// let a = Atomic::::from(Shared::::null()); + /// ``` + fn from(ptr: Shared<'g, T>) -> Self { + Self::from_usize(ptr.data) + } +} + +impl From<*const T> for Atomic { + /// Returns a new atomic pointer pointing to `raw`. + /// + /// # Examples + /// + /// ``` + /// use std::ptr; + /// use crossbeam_epoch::Atomic; + /// + /// let a = Atomic::::from(ptr::null::()); + /// ``` + fn from(raw: *const T) -> Self { + Self::from_usize(raw as usize) + } +} + +/// A trait for either `Owned` or `Shared` pointers. +pub trait Pointer { + /// Returns the machine representation of the pointer. + fn into_usize(self) -> usize; + + /// Returns a new pointer pointing to the tagged pointer `data`. + unsafe fn from_usize(data: usize) -> Self; +} + +/// An owned heap-allocated object. +/// +/// This type is very similar to `Box`. +/// +/// The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused +/// least significant bits of the address. +pub struct Owned { + data: usize, + _marker: PhantomData>, +} + +impl Pointer for Owned { + #[inline] + fn into_usize(self) -> usize { + let data = self.data; + mem::forget(self); + data + } + + /// Returns a new pointer pointing to the tagged pointer `data`. + /// + /// # Panics + /// + /// Panics if the data is zero in debug mode. + #[inline] + unsafe fn from_usize(data: usize) -> Self { + debug_assert!(data != 0, "converting zero into `Owned`"); + Owned { + data: data, + _marker: PhantomData, + } + } +} + +impl Owned { + /// Allocates `value` on the heap and returns a new owned pointer pointing to it. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Owned; + /// + /// let o = Owned::new(1234); + /// ``` + pub fn new(value: T) -> Owned { + Self::from(Box::new(value)) + } + + /// Returns a new owned pointer pointing to `raw`. + /// + /// This function is unsafe because improper use may lead to memory problems. Argument `raw` + /// must be a valid pointer. Also, a double-free may occur if the function is called twice on + /// the same raw pointer. + /// + /// # Panics + /// + /// Panics if `raw` is not properly aligned. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Owned; + /// + /// let o = unsafe { Owned::from_raw(Box::into_raw(Box::new(1234))) }; + /// ``` + pub unsafe fn from_raw(raw: *mut T) -> Owned { + ensure_aligned(raw); + Self::from_usize(raw as usize) + } + + /// Converts the owned pointer into a [`Shared`]. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Owned}; + /// + /// let o = Owned::new(1234); + /// let guard = &epoch::pin(); + /// let p = o.into_shared(guard); + /// ``` + /// + /// [`Shared`]: struct.Shared.html + pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> { + unsafe { Shared::from_usize(self.into_usize()) } + } + + /// Converts the owned pointer into a `Box`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Owned}; + /// + /// let o = Owned::new(1234); + /// let b: Box = o.into_box(); + /// assert_eq!(*b, 1234); + /// ``` + pub fn into_box(self) -> Box { + let (raw, _) = decompose_data::(self.data); + mem::forget(self); + unsafe { Box::from_raw(raw) } + } + + /// Returns the tag stored within the pointer. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Owned; + /// + /// assert_eq!(Owned::new(1234).tag(), 0); + /// ``` + pub fn tag(&self) -> usize { + let (_, tag) = decompose_data::(self.data); + tag + } + + /// Returns the same pointer, but tagged with `tag`. `tag` is truncated to be fit into the + /// unused bits of the pointer to `T`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Owned; + /// + /// let o = Owned::new(0u64); + /// assert_eq!(o.tag(), 0); + /// let o = o.with_tag(2); + /// assert_eq!(o.tag(), 2); + /// ``` + pub fn with_tag(self, tag: usize) -> Owned { + let data = self.into_usize(); + unsafe { Self::from_usize(data_with_tag::(data, tag)) } + } +} + +impl Drop for Owned { + fn drop(&mut self) { + let (raw, _) = decompose_data::(self.data); + unsafe { + drop(Box::from_raw(raw)); + } + } +} + +impl fmt::Debug for Owned { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let (raw, tag) = decompose_data::(self.data); + + f.debug_struct("Owned") + .field("raw", &raw) + .field("tag", &tag) + .finish() + } +} + +impl Clone for Owned { + fn clone(&self) -> Self { + Owned::new((**self).clone()).with_tag(self.tag()) + } +} + +impl Deref for Owned { + type Target = T; + + fn deref(&self) -> &T { + let (raw, _) = decompose_data::(self.data); + unsafe { &*raw } + } +} + +impl DerefMut for Owned { + fn deref_mut(&mut self) -> &mut T { + let (raw, _) = decompose_data::(self.data); + unsafe { &mut *raw } + } +} + +impl From for Owned { + fn from(t: T) -> Self { + Owned::new(t) + } +} + +impl From> for Owned { + /// Returns a new owned pointer pointing to `b`. + /// + /// # Panics + /// + /// Panics if the pointer (the `Box`) is not properly aligned. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Owned; + /// + /// let o = unsafe { Owned::from_raw(Box::into_raw(Box::new(1234))) }; + /// ``` + fn from(b: Box) -> Self { + unsafe { Self::from_raw(Box::into_raw(b)) } + } +} + +impl Borrow for Owned { + fn borrow(&self) -> &T { + &**self + } +} + +impl BorrowMut for Owned { + fn borrow_mut(&mut self) -> &mut T { + &mut **self + } +} + +impl AsRef for Owned { + fn as_ref(&self) -> &T { + &**self + } +} + +impl AsMut for Owned { + fn as_mut(&mut self) -> &mut T { + &mut **self + } +} + +/// A pointer to an object protected by the epoch GC. +/// +/// The pointer is valid for use only during the lifetime `'g`. +/// +/// The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused +/// least significant bits of the address. +pub struct Shared<'g, T: 'g> { + data: usize, + _marker: PhantomData<(&'g (), *const T)>, +} + +impl<'g, T> Clone for Shared<'g, T> { + fn clone(&self) -> Self { + Shared { + data: self.data, + _marker: PhantomData, + } + } +} + +impl<'g, T> Copy for Shared<'g, T> {} + +impl<'g, T> Pointer for Shared<'g, T> { + #[inline] + fn into_usize(self) -> usize { + self.data + } + + #[inline] + unsafe fn from_usize(data: usize) -> Self { + Shared { + data: data, + _marker: PhantomData, + } + } +} + +impl<'g, T> Shared<'g, T> { + /// Returns a new null pointer. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Shared; + /// + /// let p = Shared::::null(); + /// assert!(p.is_null()); + /// ``` + pub fn null() -> Shared<'g, T> { + Shared { + data: 0, + _marker: PhantomData, + } + } + + /// Returns `true` if the pointer is null. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::null(); + /// let guard = &epoch::pin(); + /// assert!(a.load(SeqCst, guard).is_null()); + /// a.store(Owned::new(1234), SeqCst); + /// assert!(!a.load(SeqCst, guard).is_null()); + /// ``` + pub fn is_null(&self) -> bool { + self.as_raw().is_null() + } + + /// Converts the pointer to a raw pointer (without the tag). + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let o = Owned::new(1234); + /// let raw = &*o as *const _; + /// let a = Atomic::from(o); + /// + /// let guard = &epoch::pin(); + /// let p = a.load(SeqCst, guard); + /// assert_eq!(p.as_raw(), raw); + /// ``` + pub fn as_raw(&self) -> *const T { + let (raw, _) = decompose_data::(self.data); + raw + } + + /// Dereferences the pointer. + /// + /// Returns a reference to the pointee that is valid during the lifetime `'g`. + /// + /// # Safety + /// + /// Dereferencing a pointer is unsafe because it could be pointing to invalid memory. + /// + /// Another concern is the possiblity of data races due to lack of proper synchronization. + /// For example, consider the following scenario: + /// + /// 1. A thread creates a new object: `a.store(Owned::new(10), Relaxed)` + /// 2. Another thread reads it: `*a.load(Relaxed, guard).as_ref().unwrap()` + /// + /// The problem is that relaxed orderings don't synchronize initialization of the object with + /// the read from the second thread. This is a data race. A possible solution would be to use + /// `Release` and `Acquire` orderings. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// let p = a.load(SeqCst, guard); + /// unsafe { + /// assert_eq!(p.deref(), &1234); + /// } + /// ``` + pub unsafe fn deref(&self) -> &'g T { + &*self.as_raw() + } + + /// Dereferences the pointer. + /// + /// Returns a mutable reference to the pointee that is valid during the lifetime `'g`. + /// + /// # Safety + /// + /// * There is no guarantee that there are no more threads attempting to read/write from/to the + /// actual object at the same time. + /// + /// The user must know that there are no concurrent accesses towards the object itself. + /// + /// * Other than the above, all safety concerns of `deref()` applies here. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(vec![1, 2, 3, 4]); + /// let guard = &epoch::pin(); + /// + /// let mut p = a.load(SeqCst, guard); + /// unsafe { + /// assert!(!p.is_null()); + /// let b = p.deref_mut(); + /// assert_eq!(b, &vec![1, 2, 3, 4]); + /// b.push(5); + /// assert_eq!(b, &vec![1, 2, 3, 4, 5]); + /// } + /// + /// let p = a.load(SeqCst, guard); + /// unsafe { + /// assert_eq!(p.deref(), &vec![1, 2, 3, 4, 5]); + /// } + /// ``` + pub unsafe fn deref_mut(&mut self) -> &'g mut T { + &mut *(self.as_raw() as *mut T) + } + + /// Converts the pointer to a reference. + /// + /// Returns `None` if the pointer is null, or else a reference to the object wrapped in `Some`. + /// + /// # Safety + /// + /// Dereferencing a pointer is unsafe because it could be pointing to invalid memory. + /// + /// Another concern is the possiblity of data races due to lack of proper synchronization. + /// For example, consider the following scenario: + /// + /// 1. A thread creates a new object: `a.store(Owned::new(10), Relaxed)` + /// 2. Another thread reads it: `*a.load(Relaxed, guard).as_ref().unwrap()` + /// + /// The problem is that relaxed orderings don't synchronize initialization of the object with + /// the read from the second thread. This is a data race. A possible solution would be to use + /// `Release` and `Acquire` orderings. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// let p = a.load(SeqCst, guard); + /// unsafe { + /// assert_eq!(p.as_ref(), Some(&1234)); + /// } + /// ``` + pub unsafe fn as_ref(&self) -> Option<&'g T> { + self.as_raw().as_ref() + } + + /// Takes ownership of the pointee. + /// + /// # Panics + /// + /// Panics if this pointer is null, but only in debug mode. + /// + /// # Safety + /// + /// This method may be called only if the pointer is valid and nobody else is holding a + /// reference to the same object. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// unsafe { + /// let guard = &epoch::unprotected(); + /// let p = a.load(SeqCst, guard); + /// drop(p.into_owned()); + /// } + /// ``` + pub unsafe fn into_owned(self) -> Owned { + debug_assert!( + self.as_raw() != ptr::null(), + "converting a null `Shared` into `Owned`" + ); + Owned::from_usize(self.data) + } + + /// Returns the tag stored within the pointer. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::::from(Owned::new(0u64).with_tag(2)); + /// let guard = &epoch::pin(); + /// let p = a.load(SeqCst, guard); + /// assert_eq!(p.tag(), 2); + /// ``` + pub fn tag(&self) -> usize { + let (_, tag) = decompose_data::(self.data); + tag + } + + /// Returns the same pointer, but tagged with `tag`. `tag` is truncated to be fit into the + /// unused bits of the pointer to `T`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(0u64); + /// let guard = &epoch::pin(); + /// let p1 = a.load(SeqCst, guard); + /// let p2 = p1.with_tag(2); + /// + /// assert_eq!(p1.tag(), 0); + /// assert_eq!(p2.tag(), 2); + /// assert_eq!(p1.as_raw(), p2.as_raw()); + /// ``` + pub fn with_tag(&self, tag: usize) -> Shared<'g, T> { + unsafe { Self::from_usize(data_with_tag::(self.data, tag)) } + } +} + +impl<'g, T> From<*const T> for Shared<'g, T> { + /// Returns a new pointer pointing to `raw`. + /// + /// # Panics + /// + /// Panics if `raw` is not properly aligned. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::Shared; + /// + /// let p = unsafe { Shared::from(Box::into_raw(Box::new(1234)) as *const _) }; + /// assert!(!p.is_null()); + /// ``` + fn from(raw: *const T) -> Self { + ensure_aligned(raw); + unsafe { Self::from_usize(raw as usize) } + } +} + +impl<'g, T> PartialEq> for Shared<'g, T> { + fn eq(&self, other: &Self) -> bool { + self.data == other.data + } +} + +impl<'g, T> Eq for Shared<'g, T> {} + +impl<'g, T> PartialOrd> for Shared<'g, T> { + fn partial_cmp(&self, other: &Self) -> Option { + self.data.partial_cmp(&other.data) + } +} + +impl<'g, T> Ord for Shared<'g, T> { + fn cmp(&self, other: &Self) -> cmp::Ordering { + self.data.cmp(&other.data) + } +} + +impl<'g, T> fmt::Debug for Shared<'g, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let (raw, tag) = decompose_data::(self.data); + + f.debug_struct("Shared") + .field("raw", &raw) + .field("tag", &tag) + .finish() + } +} + +impl<'g, T> fmt::Pointer for Shared<'g, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Pointer::fmt(&self.as_raw(), f) + } +} + +impl<'g, T> Default for Shared<'g, T> { + fn default() -> Self { + Shared::null() + } +} + +#[cfg(test)] +mod tests { + use super::Shared; + + #[test] + fn valid_tag_i8() { + Shared::::null().with_tag(0); + } + + #[test] + fn valid_tag_i64() { + Shared::::null().with_tag(7); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/collector.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/collector.rs new file mode 100644 index 0000000..1817d9a --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/collector.rs @@ -0,0 +1,434 @@ +/// Epoch-based garbage collector. +/// +/// # Examples +/// +/// ``` +/// use crossbeam_epoch::Collector; +/// +/// let collector = Collector::new(); +/// +/// let handle = collector.register(); +/// drop(collector); // `handle` still works after dropping `collector` +/// +/// handle.pin().flush(); +/// ``` +use alloc::sync::Arc; +use core::fmt; + +use guard::Guard; +use internal::{Global, Local}; + +/// An epoch-based garbage collector. +pub struct Collector { + pub(crate) global: Arc, +} + +unsafe impl Send for Collector {} +unsafe impl Sync for Collector {} + +impl Collector { + /// Creates a new collector. + pub fn new() -> Self { + Collector { + global: Arc::new(Global::new()), + } + } + + /// Registers a new handle for the collector. + pub fn register(&self) -> LocalHandle { + Local::register(self) + } +} + +impl Clone for Collector { + /// Creates another reference to the same garbage collector. + fn clone(&self) -> Self { + Collector { + global: self.global.clone(), + } + } +} + +impl fmt::Debug for Collector { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Collector { .. }") + } +} + +impl PartialEq for Collector { + /// Checks if both handles point to the same collector. + fn eq(&self, rhs: &Collector) -> bool { + Arc::ptr_eq(&self.global, &rhs.global) + } +} +impl Eq for Collector {} + +/// A handle to a garbage collector. +pub struct LocalHandle { + pub(crate) local: *const Local, +} + +impl LocalHandle { + /// Pins the handle. + #[inline] + pub fn pin(&self) -> Guard { + unsafe { (*self.local).pin() } + } + + /// Returns `true` if the handle is pinned. + #[inline] + pub fn is_pinned(&self) -> bool { + unsafe { (*self.local).is_pinned() } + } + + /// Returns the `Collector` associated with this handle. + #[inline] + pub fn collector(&self) -> &Collector { + unsafe { (*self.local).collector() } + } +} + +impl Drop for LocalHandle { + #[inline] + fn drop(&mut self) { + unsafe { + Local::release_handle(&*self.local); + } + } +} + +impl fmt::Debug for LocalHandle { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("LocalHandle { .. }") + } +} + +#[cfg(test)] +mod tests { + use std::mem; + use std::sync::atomic::{AtomicUsize, Ordering}; + + use crossbeam_utils::thread; + + use {Collector, Owned}; + + const NUM_THREADS: usize = 8; + + #[test] + fn pin_reentrant() { + let collector = Collector::new(); + let handle = collector.register(); + drop(collector); + + assert!(!handle.is_pinned()); + { + let _guard = &handle.pin(); + assert!(handle.is_pinned()); + { + let _guard = &handle.pin(); + assert!(handle.is_pinned()); + } + assert!(handle.is_pinned()); + } + assert!(!handle.is_pinned()); + } + + #[test] + fn flush_local_bag() { + let collector = Collector::new(); + let handle = collector.register(); + drop(collector); + + for _ in 0..100 { + let guard = &handle.pin(); + unsafe { + let a = Owned::new(7).into_shared(guard); + guard.defer_destroy(a); + + assert!(!(*(*guard.local).bag.get()).is_empty()); + + while !(*(*guard.local).bag.get()).is_empty() { + guard.flush(); + } + } + } + } + + #[test] + fn garbage_buffering() { + let collector = Collector::new(); + let handle = collector.register(); + drop(collector); + + let guard = &handle.pin(); + unsafe { + for _ in 0..10 { + let a = Owned::new(7).into_shared(guard); + guard.defer_destroy(a); + } + assert!(!(*(*guard.local).bag.get()).is_empty()); + } + } + + #[test] + fn pin_holds_advance() { + let collector = Collector::new(); + + thread::scope(|scope| { + for _ in 0..NUM_THREADS { + scope.spawn(|_| { + let handle = collector.register(); + for _ in 0..500_000 { + let guard = &handle.pin(); + + let before = collector.global.epoch.load(Ordering::Relaxed); + collector.global.collect(guard); + let after = collector.global.epoch.load(Ordering::Relaxed); + + assert!(after.wrapping_sub(before) <= 2); + } + }); + } + }) + .unwrap(); + } + + #[test] + fn incremental() { + const COUNT: usize = 100_000; + static DESTROYS: AtomicUsize = AtomicUsize::new(0); + + let collector = Collector::new(); + let handle = collector.register(); + + unsafe { + let guard = &handle.pin(); + for _ in 0..COUNT { + let a = Owned::new(7i32).into_shared(guard); + guard.defer_unchecked(move || { + drop(a.into_owned()); + DESTROYS.fetch_add(1, Ordering::Relaxed); + }); + } + guard.flush(); + } + + let mut last = 0; + + while last < COUNT { + let curr = DESTROYS.load(Ordering::Relaxed); + assert!(curr - last <= 1024); + last = curr; + + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert!(DESTROYS.load(Ordering::Relaxed) == 100_000); + } + + #[test] + fn buffering() { + const COUNT: usize = 10; + static DESTROYS: AtomicUsize = AtomicUsize::new(0); + + let collector = Collector::new(); + let handle = collector.register(); + + unsafe { + let guard = &handle.pin(); + for _ in 0..COUNT { + let a = Owned::new(7i32).into_shared(guard); + guard.defer_unchecked(move || { + drop(a.into_owned()); + DESTROYS.fetch_add(1, Ordering::Relaxed); + }); + } + } + + for _ in 0..100_000 { + collector.global.collect(&handle.pin()); + } + assert!(DESTROYS.load(Ordering::Relaxed) < COUNT); + + handle.pin().flush(); + + while DESTROYS.load(Ordering::Relaxed) < COUNT { + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert_eq!(DESTROYS.load(Ordering::Relaxed), COUNT); + } + + #[test] + fn count_drops() { + const COUNT: usize = 100_000; + static DROPS: AtomicUsize = AtomicUsize::new(0); + + struct Elem(i32); + + impl Drop for Elem { + fn drop(&mut self) { + DROPS.fetch_add(1, Ordering::Relaxed); + } + } + + let collector = Collector::new(); + let handle = collector.register(); + + unsafe { + let guard = &handle.pin(); + + for _ in 0..COUNT { + let a = Owned::new(Elem(7i32)).into_shared(guard); + guard.defer_destroy(a); + } + guard.flush(); + } + + while DROPS.load(Ordering::Relaxed) < COUNT { + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert_eq!(DROPS.load(Ordering::Relaxed), COUNT); + } + + #[test] + fn count_destroy() { + const COUNT: usize = 100_000; + static DESTROYS: AtomicUsize = AtomicUsize::new(0); + + let collector = Collector::new(); + let handle = collector.register(); + + unsafe { + let guard = &handle.pin(); + + for _ in 0..COUNT { + let a = Owned::new(7i32).into_shared(guard); + guard.defer_unchecked(move || { + drop(a.into_owned()); + DESTROYS.fetch_add(1, Ordering::Relaxed); + }); + } + guard.flush(); + } + + while DESTROYS.load(Ordering::Relaxed) < COUNT { + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert_eq!(DESTROYS.load(Ordering::Relaxed), COUNT); + } + + #[test] + fn drop_array() { + const COUNT: usize = 700; + static DROPS: AtomicUsize = AtomicUsize::new(0); + + struct Elem(i32); + + impl Drop for Elem { + fn drop(&mut self) { + DROPS.fetch_add(1, Ordering::Relaxed); + } + } + + let collector = Collector::new(); + let handle = collector.register(); + + let mut guard = handle.pin(); + + let mut v = Vec::with_capacity(COUNT); + for i in 0..COUNT { + v.push(Elem(i as i32)); + } + + { + let a = Owned::new(v).into_shared(&guard); + unsafe { + guard.defer_destroy(a); + } + guard.flush(); + } + + while DROPS.load(Ordering::Relaxed) < COUNT { + guard.repin(); + collector.global.collect(&guard); + } + assert_eq!(DROPS.load(Ordering::Relaxed), COUNT); + } + + #[test] + fn destroy_array() { + const COUNT: usize = 100_000; + static DESTROYS: AtomicUsize = AtomicUsize::new(0); + + let collector = Collector::new(); + let handle = collector.register(); + + unsafe { + let guard = &handle.pin(); + + let mut v = Vec::with_capacity(COUNT); + for i in 0..COUNT { + v.push(i as i32); + } + + let ptr = v.as_mut_ptr() as usize; + let len = v.len(); + guard.defer_unchecked(move || { + drop(Vec::from_raw_parts(ptr as *const u8 as *mut u8, len, len)); + DESTROYS.fetch_add(len, Ordering::Relaxed); + }); + guard.flush(); + + mem::forget(v); + } + + while DESTROYS.load(Ordering::Relaxed) < COUNT { + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert_eq!(DESTROYS.load(Ordering::Relaxed), COUNT); + } + + #[test] + fn stress() { + const THREADS: usize = 8; + const COUNT: usize = 100_000; + static DROPS: AtomicUsize = AtomicUsize::new(0); + + struct Elem(i32); + + impl Drop for Elem { + fn drop(&mut self) { + DROPS.fetch_add(1, Ordering::Relaxed); + } + } + + let collector = Collector::new(); + + thread::scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + let handle = collector.register(); + for _ in 0..COUNT { + let guard = &handle.pin(); + unsafe { + let a = Owned::new(Elem(7i32)).into_shared(guard); + guard.defer_destroy(a); + } + } + }); + } + }) + .unwrap(); + + let handle = collector.register(); + while DROPS.load(Ordering::Relaxed) < COUNT * THREADS { + let guard = &handle.pin(); + collector.global.collect(guard); + } + assert_eq!(DROPS.load(Ordering::Relaxed), COUNT * THREADS); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/default.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/default.rs new file mode 100644 index 0000000..734a624 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/default.rs @@ -0,0 +1,75 @@ +//! The default garbage collector. +//! +//! For each thread, a participant is lazily initialized on its first use, when the current thread +//! is registered in the default collector. If initialized, the thread's participant will get +//! destructed on thread exit, which in turn unregisters the thread. + +use collector::{Collector, LocalHandle}; +use guard::Guard; + +lazy_static! { + /// The global data for the default garbage collector. + static ref COLLECTOR: Collector = Collector::new(); +} + +thread_local! { + /// The per-thread participant for the default garbage collector. + static HANDLE: LocalHandle = COLLECTOR.register(); +} + +/// Pins the current thread. +#[inline] +pub fn pin() -> Guard { + with_handle(|handle| handle.pin()) +} + +/// Returns `true` if the current thread is pinned. +#[inline] +pub fn is_pinned() -> bool { + with_handle(|handle| handle.is_pinned()) +} + +/// Returns the default global collector. +pub fn default_collector() -> &'static Collector { + &COLLECTOR +} + +#[inline] +fn with_handle(mut f: F) -> R +where + F: FnMut(&LocalHandle) -> R, +{ + HANDLE + .try_with(|h| f(h)) + .unwrap_or_else(|_| f(&COLLECTOR.register())) +} + +#[cfg(test)] +mod tests { + use crossbeam_utils::thread; + + #[test] + fn pin_while_exiting() { + struct Foo; + + impl Drop for Foo { + fn drop(&mut self) { + // Pin after `HANDLE` has been dropped. This must not panic. + super::pin(); + } + } + + thread_local! { + static FOO: Foo = Foo; + } + + thread::scope(|scope| { + scope.spawn(|_| { + // Initialize `FOO` and then `HANDLE`. + FOO.with(|_| ()); + super::pin(); + // At thread exit, `HANDLE` gets dropped first and `FOO` second. + }); + }).unwrap(); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/deferred.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/deferred.rs new file mode 100644 index 0000000..574b954 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/deferred.rs @@ -0,0 +1,134 @@ +use alloc::boxed::Box; +use core::fmt; +use core::marker::PhantomData; +use core::mem; +use core::ptr; + +/// Number of words a piece of `Data` can hold. +/// +/// Three words should be enough for the majority of cases. For example, you can fit inside it the +/// function pointer together with a fat pointer representing an object that needs to be destroyed. +const DATA_WORDS: usize = 3; + +/// Some space to keep a `FnOnce()` object on the stack. +type Data = [usize; DATA_WORDS]; + +/// A `FnOnce()` that is stored inline if small, or otherwise boxed on the heap. +/// +/// This is a handy way of keeping an unsized `FnOnce()` within a sized structure. +pub struct Deferred { + call: unsafe fn(*mut u8), + data: Data, + _marker: PhantomData<*mut ()>, // !Send + !Sync +} + +impl fmt::Debug for Deferred { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + f.pad("Deferred { .. }") + } +} + +impl Deferred { + /// Constructs a new `Deferred` from a `FnOnce()`. + pub fn new(f: F) -> Self { + let size = mem::size_of::(); + let align = mem::align_of::(); + + unsafe { + if size <= mem::size_of::() && align <= mem::align_of::() { + let mut data: Data = mem::uninitialized(); + ptr::write(&mut data as *mut Data as *mut F, f); + + unsafe fn call(raw: *mut u8) { + let f: F = ptr::read(raw as *mut F); + f(); + } + + Deferred { + call: call::, + data, + _marker: PhantomData, + } + } else { + let b: Box = Box::new(f); + let mut data: Data = mem::uninitialized(); + ptr::write(&mut data as *mut Data as *mut Box, b); + + unsafe fn call(raw: *mut u8) { + let b: Box = ptr::read(raw as *mut Box); + (*b)(); + } + + Deferred { + call: call::, + data, + _marker: PhantomData, + } + } + } + } + + /// Calls the function. + #[inline] + pub fn call(mut self) { + let call = self.call; + unsafe { call(&mut self.data as *mut Data as *mut u8) }; + } +} + +#[cfg(test)] +mod tests { + use super::Deferred; + use std::cell::Cell; + + #[test] + fn on_stack() { + let fired = &Cell::new(false); + let a = [0usize; 1]; + + let d = Deferred::new(move || { + drop(a); + fired.set(true); + }); + + assert!(!fired.get()); + d.call(); + assert!(fired.get()); + } + + #[test] + fn on_heap() { + let fired = &Cell::new(false); + let a = [0usize; 10]; + + let d = Deferred::new(move || { + drop(a); + fired.set(true); + }); + + assert!(!fired.get()); + d.call(); + assert!(fired.get()); + } + + #[test] + fn string() { + let a = "hello".to_string(); + let d = Deferred::new(move || assert_eq!(a, "hello")); + d.call(); + } + + #[test] + fn boxed_slice_i32() { + let a: Box<[i32]> = vec![2, 3, 5, 7].into_boxed_slice(); + let d = Deferred::new(move || assert_eq!(*a, [2, 3, 5, 7])); + d.call(); + } + + #[test] + fn long_slice_usize() { + let a: [usize; 5] = [2, 3, 5, 7, 11]; + let d = Deferred::new(move || assert_eq!(a, [2, 3, 5, 7, 11])); + d.call(); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/epoch.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/epoch.rs new file mode 100644 index 0000000..e7759d9 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/epoch.rs @@ -0,0 +1,114 @@ +//! The global epoch +//! +//! The last bit in this number is unused and is always zero. Every so often the global epoch is +//! incremented, i.e. we say it "advances". A pinned participant may advance the global epoch only +//! if all currently pinned participants have been pinned in the current epoch. +//! +//! If an object became garbage in some epoch, then we can be sure that after two advancements no +//! participant will hold a reference to it. That is the crux of safe memory reclamation. + +use core::sync::atomic::{AtomicUsize, Ordering}; + +/// An epoch that can be marked as pinned or unpinned. +/// +/// Internally, the epoch is represented as an integer that wraps around at some unspecified point +/// and a flag that represents whether it is pinned or unpinned. +#[derive(Copy, Clone, Default, Debug, Eq, PartialEq)] +pub struct Epoch { + /// The least significant bit is set if pinned. The rest of the bits hold the epoch. + data: usize, +} + +impl Epoch { + /// Returns the starting epoch in unpinned state. + #[inline] + pub fn starting() -> Self { + Self::default() + } + + /// Returns the number of epochs `self` is ahead of `rhs`. + /// + /// Internally, epochs are represented as numbers in the range `(isize::MIN / 2) .. (isize::MAX + /// / 2)`, so the returned distance will be in the same interval. + pub fn wrapping_sub(self, rhs: Self) -> isize { + // The result is the same with `(self.data & !1).wrapping_sub(rhs.data & !1) as isize >> 1`, + // because the possible difference of LSB in `(self.data & !1).wrapping_sub(rhs.data & !1)` + // will be ignored in the shift operation. + self.data.wrapping_sub(rhs.data & !1) as isize >> 1 + } + + /// Returns `true` if the epoch is marked as pinned. + #[inline] + pub fn is_pinned(self) -> bool { + (self.data & 1) == 1 + } + + /// Returns the same epoch, but marked as pinned. + #[inline] + pub fn pinned(self) -> Epoch { + Epoch { + data: self.data | 1, + } + } + + /// Returns the same epoch, but marked as unpinned. + #[inline] + pub fn unpinned(self) -> Epoch { + Epoch { + data: self.data & !1, + } + } + + /// Returns the successor epoch. + /// + /// The returned epoch will be marked as pinned only if the previous one was as well. + #[inline] + pub fn successor(self) -> Epoch { + Epoch { + data: self.data.wrapping_add(2), + } + } +} + +/// An atomic value that holds an `Epoch`. +#[derive(Default, Debug)] +pub struct AtomicEpoch { + /// Since `Epoch` is just a wrapper around `usize`, an `AtomicEpoch` is similarly represented + /// using an `AtomicUsize`. + data: AtomicUsize, +} + +impl AtomicEpoch { + /// Creates a new atomic epoch. + #[inline] + pub fn new(epoch: Epoch) -> Self { + let data = AtomicUsize::new(epoch.data); + AtomicEpoch { data } + } + + /// Loads a value from the atomic epoch. + #[inline] + pub fn load(&self, ord: Ordering) -> Epoch { + Epoch { + data: self.data.load(ord), + } + } + + /// Stores a value into the atomic epoch. + #[inline] + pub fn store(&self, epoch: Epoch, ord: Ordering) { + self.data.store(epoch.data, ord); + } + + /// Stores a value into the atomic epoch if the current value is the same as `current`. + /// + /// The return value is always the previous value. If it is equal to `current`, then the value + /// is updated. + /// + /// The `Ordering` argument describes the memory ordering of this operation. + #[inline] + pub fn compare_and_swap(&self, current: Epoch, new: Epoch, ord: Ordering) -> Epoch { + let data = self.data.compare_and_swap(current.data, new.data, ord); + Epoch { data } + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/guard.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/guard.rs new file mode 100644 index 0000000..6777d97 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/guard.rs @@ -0,0 +1,527 @@ +use core::fmt; +use core::mem; + +use atomic::Shared; +use collector::Collector; +use deferred::Deferred; +use internal::Local; + +/// A guard that keeps the current thread pinned. +/// +/// # Pinning +/// +/// The current thread is pinned by calling [`pin`], which returns a new guard: +/// +/// ``` +/// use crossbeam_epoch as epoch; +/// +/// // It is often convenient to prefix a call to `pin` with a `&` in order to create a reference. +/// // This is not really necessary, but makes passing references to the guard a bit easier. +/// let guard = &epoch::pin(); +/// ``` +/// +/// When a guard gets dropped, the current thread is automatically unpinned. +/// +/// # Pointers on the stack +/// +/// Having a guard allows us to create pointers on the stack to heap-allocated objects. +/// For example: +/// +/// ``` +/// use crossbeam_epoch::{self as epoch, Atomic, Owned}; +/// use std::sync::atomic::Ordering::SeqCst; +/// +/// // Create a heap-allocated number. +/// let a = Atomic::new(777); +/// +/// // Pin the current thread. +/// let guard = &epoch::pin(); +/// +/// // Load the heap-allocated object and create pointer `p` on the stack. +/// let p = a.load(SeqCst, guard); +/// +/// // Dereference the pointer and print the value: +/// if let Some(num) = unsafe { p.as_ref() } { +/// println!("The number is {}.", num); +/// } +/// ``` +/// +/// # Multiple guards +/// +/// Pinning is reentrant and it is perfectly legal to create multiple guards. In that case, the +/// thread will actually be pinned only when the first guard is created and unpinned when the last +/// one is dropped: +/// +/// ``` +/// use crossbeam_epoch as epoch; +/// +/// let guard1 = epoch::pin(); +/// let guard2 = epoch::pin(); +/// assert!(epoch::is_pinned()); +/// drop(guard1); +/// assert!(epoch::is_pinned()); +/// drop(guard2); +/// assert!(!epoch::is_pinned()); +/// ``` +/// +/// [`pin`]: fn.pin.html +pub struct Guard { + pub(crate) local: *const Local, +} + +impl Guard { + /// Stores a function so that it can be executed at some point after all currently pinned + /// threads get unpinned. + /// + /// This method first stores `f` into the thread-local (or handle-local) cache. If this cache + /// becomes full, some functions are moved into the global cache. At the same time, some + /// functions from both local and global caches may get executed in order to incrementally + /// clean up the caches as they fill up. + /// + /// There is no guarantee when exactly `f` will be executed. The only guarantee is that it + /// won't be executed until all currently pinned threads get unpinned. In theory, `f` might + /// never run, but the epoch-based garbage collection will make an effort to execute it + /// reasonably soon. + /// + /// If this method is called from an [`unprotected`] guard, the function will simply be + /// executed immediately. + /// + /// [`unprotected`]: fn.unprotected.html + pub fn defer(&self, f: F) + where + F: FnOnce() -> R, + F: Send + 'static, + { + unsafe { + self.defer_unchecked(f); + } + } + + /// Stores a function so that it can be executed at some point after all currently pinned + /// threads get unpinned. + /// + /// This method first stores `f` into the thread-local (or handle-local) cache. If this cache + /// becomes full, some functions are moved into the global cache. At the same time, some + /// functions from both local and global caches may get executed in order to incrementally + /// clean up the caches as they fill up. + /// + /// There is no guarantee when exactly `f` will be executed. The only guarantee is that it + /// won't be executed until all currently pinned threads get unpinned. In theory, `f` might + /// never run, but the epoch-based garbage collection will make an effort to execute it + /// reasonably soon. + /// + /// If this method is called from an [`unprotected`] guard, the function will simply be + /// executed immediately. + /// + /// # Safety + /// + /// The given function must not hold reference onto the stack. It is highly recommended that + /// the passed function is **always** marked with `move` in order to prevent accidental + /// borrows. + /// + /// ``` + /// use crossbeam_epoch as epoch; + /// + /// let guard = &epoch::pin(); + /// let message = "Hello!"; + /// unsafe { + /// // ALWAYS use `move` when sending a closure into `defer_unchecked`. + /// guard.defer_unchecked(move || { + /// println!("{}", message); + /// }); + /// } + /// ``` + /// + /// Apart from that, keep in mind that another thread may execute `f`, so anything accessed by + /// the closure must be `Send`. + /// + /// We intentionally didn't require `F: Send`, because Rust's type systems usually cannot prove + /// `F: Send` for typical use cases. For example, consider the following code snippet, which + /// exemplifies the typical use case of deferring the deallocation of a shared reference: + /// + /// ```ignore + /// let shared = Owned::new(7i32).into_shared(guard); + /// guard.defer_unchecked(move || shared.into_owned()); // `Shared` is not `Send`! + /// ``` + /// + /// While `Shared` is not `Send`, it's safe for another thread to call the deferred function, + /// because it's called only after the grace period and `shared` is no longer shared with other + /// threads. But we don't expect type systems to prove this. + /// + /// # Examples + /// + /// When a heap-allocated object in a data structure becomes unreachable, it has to be + /// deallocated. However, the current thread and other threads may be still holding references + /// on the stack to that same object. Therefore it cannot be deallocated before those references + /// get dropped. This method can defer deallocation until all those threads get unpinned and + /// consequently drop all their references on the stack. + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new("foo"); + /// + /// // Now suppose that `a` is shared among multiple threads and concurrently + /// // accessed and modified... + /// + /// // Pin the current thread. + /// let guard = &epoch::pin(); + /// + /// // Steal the object currently stored in `a` and swap it with another one. + /// let p = a.swap(Owned::new("bar").into_shared(guard), SeqCst, guard); + /// + /// if !p.is_null() { + /// // The object `p` is pointing to is now unreachable. + /// // Defer its deallocation until all currently pinned threads get unpinned. + /// unsafe { + /// // ALWAYS use `move` when sending a closure into `defer_unchecked`. + /// guard.defer_unchecked(move || { + /// println!("{} is now being deallocated.", p.deref()); + /// // Now we have unique access to the object pointed to by `p` and can turn it + /// // into an `Owned`. Dropping the `Owned` will deallocate the object. + /// drop(p.into_owned()); + /// }); + /// } + /// } + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub unsafe fn defer_unchecked(&self, f: F) + where + F: FnOnce() -> R, + { + if let Some(local) = self.local.as_ref() { + local.defer(Deferred::new(move || drop(f())), self); + } + } + + /// Stores a destructor for an object so that it can be deallocated and dropped at some point + /// after all currently pinned threads get unpinned. + /// + /// This method first stores the destructor into the thread-local (or handle-local) cache. If + /// this cache becomes full, some destructors are moved into the global cache. At the same + /// time, some destructors from both local and global caches may get executed in order to + /// incrementally clean up the caches as they fill up. + /// + /// There is no guarantee when exactly the destructor will be executed. The only guarantee is + /// that it won't be executed until all currently pinned threads get unpinned. In theory, the + /// destructor might never run, but the epoch-based garbage collection will make an effort to + /// execute it reasonably soon. + /// + /// If this method is called from an [`unprotected`] guard, the destructor will simply be + /// executed immediately. + /// + /// # Safety + /// + /// The object must not be reachable by other threads anymore, otherwise it might be still in + /// use when the destructor runs. + /// + /// Apart from that, keep in mind that another thread may execute the destructor, so the object + /// must be sendable to other threads. + /// + /// We intentionally didn't require `T: Send`, because Rust's type systems usually cannot prove + /// `T: Send` for typical use cases. For example, consider the following code snippet, which + /// exemplifies the typical use case of deferring the deallocation of a shared reference: + /// + /// ```ignore + /// let shared = Owned::new(7i32).into_shared(guard); + /// guard.defer_destroy(shared); // `Shared` is not `Send`! + /// ``` + /// + /// While `Shared` is not `Send`, it's safe for another thread to call the destructor, because + /// it's called only after the grace period and `shared` is no longer shared with other + /// threads. But we don't expect type systems to prove this. + /// + /// # Examples + /// + /// When a heap-allocated object in a data structure becomes unreachable, it has to be + /// deallocated. However, the current thread and other threads may be still holding references + /// on the stack to that same object. Therefore it cannot be deallocated before those references + /// get dropped. This method can defer deallocation until all those threads get unpinned and + /// consequently drop all their references on the stack. + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic, Owned}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new("foo"); + /// + /// // Now suppose that `a` is shared among multiple threads and concurrently + /// // accessed and modified... + /// + /// // Pin the current thread. + /// let guard = &epoch::pin(); + /// + /// // Steal the object currently stored in `a` and swap it with another one. + /// let p = a.swap(Owned::new("bar").into_shared(guard), SeqCst, guard); + /// + /// if !p.is_null() { + /// // The object `p` is pointing to is now unreachable. + /// // Defer its deallocation until all currently pinned threads get unpinned. + /// unsafe { + /// guard.defer_destroy(p); + /// } + /// } + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub unsafe fn defer_destroy(&self, ptr: Shared) { + self.defer_unchecked(move || ptr.into_owned()); + } + + /// Clears up the thread-local cache of deferred functions by executing them or moving into the + /// global cache. + /// + /// Call this method after deferring execution of a function if you want to get it executed as + /// soon as possible. Flushing will make sure it is residing in in the global cache, so that + /// any thread has a chance of taking the function and executing it. + /// + /// If this method is called from an [`unprotected`] guard, it is a no-op (nothing happens). + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch as epoch; + /// + /// let guard = &epoch::pin(); + /// unsafe { + /// guard.defer(move || { + /// println!("This better be printed as soon as possible!"); + /// }); + /// } + /// guard.flush(); + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub fn flush(&self) { + if let Some(local) = unsafe { self.local.as_ref() } { + local.flush(self); + } + } + + /// Unpins and then immediately re-pins the thread. + /// + /// This method is useful when you don't want delay the advancement of the global epoch by + /// holding an old epoch. For safety, you should not maintain any guard-based reference across + /// the call (the latter is enforced by `&mut self`). The thread will only be repinned if this + /// is the only active guard for the current thread. + /// + /// If this method is called from an [`unprotected`] guard, then the call will be just no-op. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// use std::thread; + /// use std::time::Duration; + /// + /// let a = Atomic::new(777); + /// let mut guard = epoch::pin(); + /// { + /// let p = a.load(SeqCst, &guard); + /// assert_eq!(unsafe { p.as_ref() }, Some(&777)); + /// } + /// guard.repin(); + /// { + /// let p = a.load(SeqCst, &guard); + /// assert_eq!(unsafe { p.as_ref() }, Some(&777)); + /// } + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub fn repin(&mut self) { + if let Some(local) = unsafe { self.local.as_ref() } { + local.repin(); + } + } + + /// Temporarily unpins the thread, executes the given function and then re-pins the thread. + /// + /// This method is useful when you need to perform a long-running operation (e.g. sleeping) + /// and don't need to maintain any guard-based reference across the call (the latter is enforced + /// by `&mut self`). The thread will only be unpinned if this is the only active guard for the + /// current thread. + /// + /// If this method is called from an [`unprotected`] guard, then the passed function is called + /// directly without unpinning the thread. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// use std::thread; + /// use std::time::Duration; + /// + /// let a = Atomic::new(777); + /// let mut guard = epoch::pin(); + /// { + /// let p = a.load(SeqCst, &guard); + /// assert_eq!(unsafe { p.as_ref() }, Some(&777)); + /// } + /// guard.repin_after(|| thread::sleep(Duration::from_millis(50))); + /// { + /// let p = a.load(SeqCst, &guard); + /// assert_eq!(unsafe { p.as_ref() }, Some(&777)); + /// } + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub fn repin_after(&mut self, f: F) -> R + where + F: FnOnce() -> R, + { + if let Some(local) = unsafe { self.local.as_ref() } { + // We need to acquire a handle here to ensure the Local doesn't + // disappear from under us. + local.acquire_handle(); + local.unpin(); + } + + // Ensure the Guard is re-pinned even if the function panics + defer! { + if let Some(local) = unsafe { self.local.as_ref() } { + mem::forget(local.pin()); + local.release_handle(); + } + } + + f() + } + + /// Returns the `Collector` associated with this guard. + /// + /// This method is useful when you need to ensure that all guards used with + /// a data structure come from the same collector. + /// + /// If this method is called from an [`unprotected`] guard, then `None` is returned. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch as epoch; + /// + /// let mut guard1 = epoch::pin(); + /// let mut guard2 = epoch::pin(); + /// assert!(guard1.collector() == guard2.collector()); + /// ``` + /// + /// [`unprotected`]: fn.unprotected.html + pub fn collector(&self) -> Option<&Collector> { + unsafe { self.local.as_ref().map(|local| local.collector()) } + } +} + +impl Drop for Guard { + #[inline] + fn drop(&mut self) { + if let Some(local) = unsafe { self.local.as_ref() } { + local.unpin(); + } + } +} + +impl fmt::Debug for Guard { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Guard { .. }") + } +} + +/// Returns a reference to a dummy guard that allows unprotected access to [`Atomic`]s. +/// +/// This guard should be used in special occasions only. Note that it doesn't actually keep any +/// thread pinned - it's just a fake guard that allows loading from [`Atomic`]s unsafely. +/// +/// Note that calling [`defer`] with a dummy guard will not defer the function - it will just +/// execute the function immediately. +/// +/// If necessary, it's possible to create more dummy guards by cloning: `unprotected().clone()`. +/// +/// # Safety +/// +/// Loading and dereferencing data from an [`Atomic`] using this guard is safe only if the +/// [`Atomic`] is not being concurrently modified by other threads. +/// +/// # Examples +/// +/// ``` +/// use crossbeam_epoch::{self as epoch, Atomic}; +/// use std::sync::atomic::Ordering::Relaxed; +/// +/// let a = Atomic::new(7); +/// +/// unsafe { +/// // Load `a` without pinning the current thread. +/// a.load(Relaxed, epoch::unprotected()); +/// +/// // It's possible to create more dummy guards by calling `clone()`. +/// let dummy = &epoch::unprotected().clone(); +/// +/// dummy.defer(move || { +/// println!("This gets executed immediately."); +/// }); +/// +/// // Dropping `dummy` doesn't affect the current thread - it's just a noop. +/// } +/// ``` +/// +/// The most common use of this function is when constructing or destructing a data structure. +/// +/// For example, we can use a dummy guard in the destructor of a Treiber stack because at that +/// point no other thread could concurrently modify the [`Atomic`]s we are accessing. +/// +/// If we were to actually pin the current thread during destruction, that would just unnecessarily +/// delay garbage collection and incur some performance cost, so in cases like these `unprotected` +/// is very helpful. +/// +/// ``` +/// use crossbeam_epoch::{self as epoch, Atomic}; +/// use std::mem::ManuallyDrop; +/// use std::sync::atomic::Ordering::Relaxed; +/// +/// struct Stack { +/// head: Atomic>, +/// } +/// +/// struct Node { +/// data: ManuallyDrop, +/// next: Atomic>, +/// } +/// +/// impl Drop for Stack { +/// fn drop(&mut self) { +/// unsafe { +/// // Unprotected load. +/// let mut node = self.head.load(Relaxed, epoch::unprotected()); +/// +/// while let Some(n) = node.as_ref() { +/// // Unprotected load. +/// let next = n.next.load(Relaxed, epoch::unprotected()); +/// +/// // Take ownership of the node, then drop its data and deallocate it. +/// let mut o = node.into_owned(); +/// ManuallyDrop::drop(&mut o.data); +/// drop(o); +/// +/// node = next; +/// } +/// } +/// } +/// } +/// ``` +/// +/// [`Atomic`]: struct.Atomic.html +/// [`defer`]: struct.Guard.html#method.defer +#[inline] +pub unsafe fn unprotected() -> &'static Guard { + // HACK(stjepang): An unprotected guard is just a `Guard` with its field `local` set to null. + // Since this function returns a `'static` reference to a `Guard`, we must return a reference + // to a global guard. However, it's not possible to create a `static` `Guard` because it does + // not implement `Sync`. To get around the problem, we create a static `usize` initialized to + // zero and then transmute it into a `Guard`. This is safe because `usize` and `Guard` + // (consisting of a single pointer) have the same representation in memory. + static UNPROTECTED: usize = 0; + &*(&UNPROTECTED as *const _ as *const Guard) +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/internal.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/internal.rs new file mode 100644 index 0000000..819e6bd --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/internal.rs @@ -0,0 +1,552 @@ +//! The global data and participant for garbage collection. +//! +//! # Registration +//! +//! In order to track all participants in one place, we need some form of participant +//! registration. When a participant is created, it is registered to a global lock-free +//! singly-linked list of registries; and when a participant is leaving, it is unregistered from the +//! list. +//! +//! # Pinning +//! +//! Every participant contains an integer that tells whether the participant is pinned and if so, +//! what was the global epoch at the time it was pinned. Participants also hold a pin counter that +//! aids in periodic global epoch advancement. +//! +//! When a participant is pinned, a `Guard` is returned as a witness that the participant is pinned. +//! Guards are necessary for performing atomic operations, and for freeing/dropping locations. +//! +//! # Thread-local bag +//! +//! Objects that get unlinked from concurrent data structures must be stashed away until the global +//! epoch sufficiently advances so that they become safe for destruction. Pointers to such objects +//! are pushed into a thread-local bag, and when it becomes full, the bag is marked with the current +//! global epoch and pushed into the global queue of bags. We store objects in thread-local storages +//! for amortizing the synchronization cost of pushing the garbages to a global queue. +//! +//! # Global queue +//! +//! Whenever a bag is pushed into a queue, the objects in some bags in the queue are collected and +//! destroyed along the way. This design reduces contention on data structures. The global queue +//! cannot be explicitly accessed: the only way to interact with it is by calling functions +//! `defer()` that adds an object tothe thread-local bag, or `collect()` that manually triggers +//! garbage collection. +//! +//! Ideally each instance of concurrent data structure may have its own queue that gets fully +//! destroyed as soon as the data structure gets dropped. + +use core::cell::{Cell, UnsafeCell}; +use core::mem::{self, ManuallyDrop}; +use core::num::Wrapping; +use core::ptr; +use core::sync::atomic; +use core::sync::atomic::Ordering; + +use arrayvec::ArrayVec; +use crossbeam_utils::CachePadded; + +use atomic::{Shared, Owned}; +use collector::{Collector, LocalHandle}; +use deferred::Deferred; +use epoch::{AtomicEpoch, Epoch}; +use guard::{unprotected, Guard}; +use sync::list::{Entry, IsElement, IterError, List}; +use sync::queue::Queue; + +/// Maximum number of objects a bag can contain. +#[cfg(not(feature = "sanitize"))] +const MAX_OBJECTS: usize = 64; +#[cfg(feature = "sanitize")] +const MAX_OBJECTS: usize = 4; + +/// A bag of deferred functions. +#[derive(Default, Debug)] +pub struct Bag { + /// Stashed objects. + deferreds: ArrayVec<[Deferred; MAX_OBJECTS]>, +} + +/// `Bag::try_push()` requires that it is safe for another thread to execute the given functions. +unsafe impl Send for Bag {} + +impl Bag { + /// Returns a new, empty bag. + pub fn new() -> Self { + Self::default() + } + + /// Returns `true` if the bag is empty. + pub fn is_empty(&self) -> bool { + self.deferreds.is_empty() + } + + /// Attempts to insert a deferred function into the bag. + /// + /// Returns `Ok(())` if successful, and `Err(deferred)` for the given `deferred` if the bag is + /// full. + /// + /// # Safety + /// + /// It should be safe for another thread to execute the given function. + pub unsafe fn try_push(&mut self, deferred: Deferred) -> Result<(), Deferred> { + self.deferreds.try_push(deferred).map_err(|e| e.element()) + } + + /// Seals the bag with the given epoch. + fn seal(self, epoch: Epoch) -> SealedBag { + SealedBag { epoch, bag: self } + } +} + +impl Drop for Bag { + fn drop(&mut self) { + // Call all deferred functions. + for deferred in self.deferreds.drain(..) { + deferred.call(); + } + } +} + +/// A pair of an epoch and a bag. +#[derive(Default, Debug)] +struct SealedBag { + epoch: Epoch, + bag: Bag, +} + +/// It is safe to share `SealedBag` because `is_expired` only inspects the epoch. +unsafe impl Sync for SealedBag {} + +impl SealedBag { + /// Checks if it is safe to drop the bag w.r.t. the given global epoch. + fn is_expired(&self, global_epoch: Epoch) -> bool { + // A pinned participant can witness at most one epoch advancement. Therefore, any bag that + // is within one epoch of the current one cannot be destroyed yet. + global_epoch.wrapping_sub(self.epoch) >= 2 + } +} + +/// The global data for a garbage collector. +pub struct Global { + /// The intrusive linked list of `Local`s. + locals: List, + + /// The global queue of bags of deferred functions. + queue: Queue, + + /// The global epoch. + pub(crate) epoch: CachePadded, +} + +impl Global { + /// Number of bags to destroy. + const COLLECT_STEPS: usize = 8; + + /// Creates a new global data for garbage collection. + #[inline] + pub fn new() -> Self { + Self { + locals: List::new(), + queue: Queue::new(), + epoch: CachePadded::new(AtomicEpoch::new(Epoch::starting())), + } + } + + /// Pushes the bag into the global queue and replaces the bag with a new empty bag. + pub fn push_bag(&self, bag: &mut Bag, guard: &Guard) { + let bag = mem::replace(bag, Bag::new()); + + atomic::fence(Ordering::SeqCst); + + let epoch = self.epoch.load(Ordering::Relaxed); + self.queue.push(bag.seal(epoch), guard); + } + + /// Collects several bags from the global queue and executes deferred functions in them. + /// + /// Note: This may itself produce garbage and in turn allocate new bags. + /// + /// `pin()` rarely calls `collect()`, so we want the compiler to place that call on a cold + /// path. In other words, we want the compiler to optimize branching for the case when + /// `collect()` is not called. + #[cold] + pub fn collect(&self, guard: &Guard) { + let global_epoch = self.try_advance(guard); + + let steps = if cfg!(feature = "sanitize") { + usize::max_value() + } else { + Self::COLLECT_STEPS + }; + + for _ in 0..steps { + match self.queue.try_pop_if( + &|sealed_bag: &SealedBag| sealed_bag.is_expired(global_epoch), + guard, + ) { + None => break, + Some(sealed_bag) => drop(sealed_bag), + } + } + } + + /// Attempts to advance the global epoch. + /// + /// The global epoch can advance only if all currently pinned participants have been pinned in + /// the current epoch. + /// + /// Returns the current global epoch. + /// + /// `try_advance()` is annotated `#[cold]` because it is rarely called. + #[cold] + pub fn try_advance(&self, guard: &Guard) -> Epoch { + let global_epoch = self.epoch.load(Ordering::Relaxed); + atomic::fence(Ordering::SeqCst); + + // TODO(stjepang): `Local`s are stored in a linked list because linked lists are fairly + // easy to implement in a lock-free manner. However, traversal can be slow due to cache + // misses and data dependencies. We should experiment with other data structures as well. + for local in self.locals.iter(&guard) { + match local { + Err(IterError::Stalled) => { + // A concurrent thread stalled this iteration. That thread might also try to + // advance the epoch, in which case we leave the job to it. Otherwise, the + // epoch will not be advanced. + return global_epoch; + } + Ok(local) => { + let local_epoch = local.epoch.load(Ordering::Relaxed); + + // If the participant was pinned in a different epoch, we cannot advance the + // global epoch just yet. + if local_epoch.is_pinned() && local_epoch.unpinned() != global_epoch { + return global_epoch; + } + } + } + } + atomic::fence(Ordering::Acquire); + + // All pinned participants were pinned in the current global epoch. + // Now let's advance the global epoch... + // + // Note that if another thread already advanced it before us, this store will simply + // overwrite the global epoch with the same value. This is true because `try_advance` was + // called from a thread that was pinned in `global_epoch`, and the global epoch cannot be + // advanced two steps ahead of it. + let new_epoch = global_epoch.successor(); + self.epoch.store(new_epoch, Ordering::Release); + new_epoch + } +} + +/// Participant for garbage collection. +pub struct Local { + /// A node in the intrusive linked list of `Local`s. + entry: Entry, + + /// The local epoch. + epoch: AtomicEpoch, + + /// A reference to the global data. + /// + /// When all guards and handles get dropped, this reference is destroyed. + collector: UnsafeCell>, + + /// The local bag of deferred functions. + pub(crate) bag: UnsafeCell, + + /// The number of guards keeping this participant pinned. + guard_count: Cell, + + /// The number of active handles. + handle_count: Cell, + + /// Total number of pinnings performed. + /// + /// This is just an auxilliary counter that sometimes kicks off collection. + pin_count: Cell>, +} + +impl Local { + /// Number of pinnings after which a participant will execute some deferred functions from the + /// global queue. + const PINNINGS_BETWEEN_COLLECT: usize = 128; + + /// Registers a new `Local` in the provided `Global`. + pub fn register(collector: &Collector) -> LocalHandle { + unsafe { + // Since we dereference no pointers in this block, it is safe to use `unprotected`. + + let local = Owned::new(Local { + entry: Entry::default(), + epoch: AtomicEpoch::new(Epoch::starting()), + collector: UnsafeCell::new(ManuallyDrop::new(collector.clone())), + bag: UnsafeCell::new(Bag::new()), + guard_count: Cell::new(0), + handle_count: Cell::new(1), + pin_count: Cell::new(Wrapping(0)), + }) + .into_shared(&unprotected()); + collector.global.locals.insert(local, &unprotected()); + LocalHandle { + local: local.as_raw(), + } + } + } + + /// Returns a reference to the `Global` in which this `Local` resides. + #[inline] + pub fn global(&self) -> &Global { + &self.collector().global + } + + /// Returns a reference to the `Collector` in which this `Local` resides. + #[inline] + pub fn collector(&self) -> &Collector { + unsafe { &**self.collector.get() } + } + + /// Returns `true` if the current participant is pinned. + #[inline] + pub fn is_pinned(&self) -> bool { + self.guard_count.get() > 0 + } + + /// Adds `deferred` to the thread-local bag. + /// + /// # Safety + /// + /// It should be safe for another thread to execute the given function. + pub unsafe fn defer(&self, mut deferred: Deferred, guard: &Guard) { + let bag = &mut *self.bag.get(); + + while let Err(d) = bag.try_push(deferred) { + self.global().push_bag(bag, guard); + deferred = d; + } + } + + pub fn flush(&self, guard: &Guard) { + let bag = unsafe { &mut *self.bag.get() }; + + if !bag.is_empty() { + self.global().push_bag(bag, guard); + } + + self.global().collect(guard); + } + + /// Pins the `Local`. + #[inline] + pub fn pin(&self) -> Guard { + let guard = Guard { local: self }; + + let guard_count = self.guard_count.get(); + self.guard_count.set(guard_count.checked_add(1).unwrap()); + + if guard_count == 0 { + let global_epoch = self.global().epoch.load(Ordering::Relaxed); + let new_epoch = global_epoch.pinned(); + + // Now we must store `new_epoch` into `self.epoch` and execute a `SeqCst` fence. + // The fence makes sure that any future loads from `Atomic`s will not happen before + // this store. + if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { + // HACK(stjepang): On x86 architectures there are two different ways of executing + // a `SeqCst` fence. + // + // 1. `atomic::fence(SeqCst)`, which compiles into a `mfence` instruction. + // 2. `_.compare_and_swap(_, _, SeqCst)`, which compiles into a `lock cmpxchg` + // instruction. + // + // Both instructions have the effect of a full barrier, but benchmarks have shown + // that the second one makes pinning faster in this particular case. It is not + // clear that this is permitted by the C++ memory model (SC fences work very + // differently from SC accesses), but experimental evidence suggests that this + // works fine. Using inline assembly would be a viable (and correct) alternative, + // but alas, that is not possible on stable Rust. + let current = Epoch::starting(); + let previous = self + .epoch + .compare_and_swap(current, new_epoch, Ordering::SeqCst); + debug_assert_eq!(current, previous, "participant was expected to be unpinned"); + // We add a compiler fence to make it less likely for LLVM to do something wrong + // here. Formally, this is not enough to get rid of data races; practically, + // it should go a long way. + atomic::compiler_fence(Ordering::SeqCst); + } else { + self.epoch.store(new_epoch, Ordering::Relaxed); + atomic::fence(Ordering::SeqCst); + } + + // Increment the pin counter. + let count = self.pin_count.get(); + self.pin_count.set(count + Wrapping(1)); + + // After every `PINNINGS_BETWEEN_COLLECT` try advancing the epoch and collecting + // some garbage. + if count.0 % Self::PINNINGS_BETWEEN_COLLECT == 0 { + self.global().collect(&guard); + } + } + + guard + } + + /// Unpins the `Local`. + #[inline] + pub fn unpin(&self) { + let guard_count = self.guard_count.get(); + self.guard_count.set(guard_count - 1); + + if guard_count == 1 { + self.epoch.store(Epoch::starting(), Ordering::Release); + + if self.handle_count.get() == 0 { + self.finalize(); + } + } + } + + /// Unpins and then pins the `Local`. + #[inline] + pub fn repin(&self) { + let guard_count = self.guard_count.get(); + + // Update the local epoch only if there's only one guard. + if guard_count == 1 { + let epoch = self.epoch.load(Ordering::Relaxed); + let global_epoch = self.global().epoch.load(Ordering::Relaxed).pinned(); + + // Update the local epoch only if the global epoch is greater than the local epoch. + if epoch != global_epoch { + // We store the new epoch with `Release` because we need to ensure any memory + // accesses from the previous epoch do not leak into the new one. + self.epoch.store(global_epoch, Ordering::Release); + + // However, we don't need a following `SeqCst` fence, because it is safe for memory + // accesses from the new epoch to be executed before updating the local epoch. At + // worse, other threads will see the new epoch late and delay GC slightly. + } + } + } + + /// Increments the handle count. + #[inline] + pub fn acquire_handle(&self) { + let handle_count = self.handle_count.get(); + debug_assert!(handle_count >= 1); + self.handle_count.set(handle_count + 1); + } + + /// Decrements the handle count. + #[inline] + pub fn release_handle(&self) { + let guard_count = self.guard_count.get(); + let handle_count = self.handle_count.get(); + debug_assert!(handle_count >= 1); + self.handle_count.set(handle_count - 1); + + if guard_count == 0 && handle_count == 1 { + self.finalize(); + } + } + + /// Removes the `Local` from the global linked list. + #[cold] + fn finalize(&self) { + debug_assert_eq!(self.guard_count.get(), 0); + debug_assert_eq!(self.handle_count.get(), 0); + + // Temporarily increment handle count. This is required so that the following call to `pin` + // doesn't call `finalize` again. + self.handle_count.set(1); + unsafe { + // Pin and move the local bag into the global queue. It's important that `push_bag` + // doesn't defer destruction on any new garbage. + let guard = &self.pin(); + self.global().push_bag(&mut *self.bag.get(), guard); + } + // Revert the handle count back to zero. + self.handle_count.set(0); + + unsafe { + // Take the reference to the `Global` out of this `Local`. Since we're not protected + // by a guard at this time, it's crucial that the reference is read before marking the + // `Local` as deleted. + let collector: Collector = ptr::read(&*(*self.collector.get())); + + // Mark this node in the linked list as deleted. + self.entry.delete(&unprotected()); + + // Finally, drop the reference to the global. Note that this might be the last reference + // to the `Global`. If so, the global data will be destroyed and all deferred functions + // in its queue will be executed. + drop(collector); + } + } +} + +impl IsElement for Local { + fn entry_of(local: &Local) -> &Entry { + let entry_ptr = (local as *const Local as usize + offset_of!(Local, entry)) as *const Entry; + unsafe { &*entry_ptr } + } + + unsafe fn element_of(entry: &Entry) -> &Local { + // offset_of! macro uses unsafe, but it's unnecessary in this context. + #[allow(unused_unsafe)] + let local_ptr = (entry as *const Entry as usize - offset_of!(Local, entry)) as *const Local; + &*local_ptr + } + + unsafe fn finalize(entry: &Entry, guard: &Guard) { + guard.defer_destroy(Shared::from(Self::element_of(entry) as *const _)); + } +} + +#[cfg(test)] +mod tests { + use std::sync::atomic::{AtomicUsize, Ordering}; + + use super::*; + + #[test] + fn check_defer() { + static FLAG: AtomicUsize = AtomicUsize::new(0); + fn set() { + FLAG.store(42, Ordering::Relaxed); + } + + let d = Deferred::new(set); + assert_eq!(FLAG.load(Ordering::Relaxed), 0); + d.call(); + assert_eq!(FLAG.load(Ordering::Relaxed), 42); + } + + #[test] + fn check_bag() { + static FLAG: AtomicUsize = AtomicUsize::new(0); + fn incr() { + FLAG.fetch_add(1, Ordering::Relaxed); + } + + let mut bag = Bag::new(); + assert!(bag.is_empty()); + + for _ in 0..MAX_OBJECTS { + assert!(unsafe { bag.try_push(Deferred::new(incr)).is_ok() }); + assert!(!bag.is_empty()); + assert_eq!(FLAG.load(Ordering::Relaxed), 0); + } + + let result = unsafe { bag.try_push(Deferred::new(incr)) }; + assert!(result.is_err()); + assert!(!bag.is_empty()); + assert_eq!(FLAG.load(Ordering::Relaxed), 0); + + drop(bag); + assert_eq!(FLAG.load(Ordering::Relaxed), MAX_OBJECTS); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/lib.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/lib.rs new file mode 100644 index 0000000..8ff4bfd --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/lib.rs @@ -0,0 +1,111 @@ +//! Epoch-based memory reclamation. +//! +//! An interesting problem concurrent collections deal with comes from the remove operation. +//! Suppose that a thread removes an element from a lock-free map, while another thread is reading +//! that same element at the same time. The first thread must wait until the second thread stops +//! reading the element. Only then it is safe to destruct it. +//! +//! Programming languages that come with garbage collectors solve this problem trivially. The +//! garbage collector will destruct the removed element when no thread can hold a reference to it +//! anymore. +//! +//! This crate implements a basic memory reclamation mechanism, which is based on epochs. When an +//! element gets removed from a concurrent collection, it is inserted into a pile of garbage and +//! marked with the current epoch. Every time a thread accesses a collection, it checks the current +//! epoch, attempts to increment it, and destructs some garbage that became so old that no thread +//! can be referencing it anymore. +//! +//! That is the general mechanism behind epoch-based memory reclamation, but the details are a bit +//! more complicated. Anyhow, memory reclamation is designed to be fully automatic and something +//! users of concurrent collections don't have to worry much about. +//! +//! # Pointers +//! +//! Concurrent collections are built using atomic pointers. This module provides [`Atomic`], which +//! is just a shared atomic pointer to a heap-allocated object. Loading an [`Atomic`] yields a +//! [`Shared`], which is an epoch-protected pointer through which the loaded object can be safely +//! read. +//! +//! # Pinning +//! +//! Before an [`Atomic`] can be loaded, a participant must be [`pin`]ned. By pinning a participant +//! we declare that any object that gets removed from now on must not be destructed just +//! yet. Garbage collection of newly removed objects is suspended until the participant gets +//! unpinned. +//! +//! # Garbage +//! +//! Objects that get removed from concurrent collections must be stashed away until all currently +//! pinned participants get unpinned. Such objects can be stored into a thread-local or global +//! storage, where they are kept until the right time for their destruction comes. +//! +//! There is a global shared instance of garbage queue. You can [`defer`] the execution of an +//! arbitrary function until the global epoch is advanced enough. Most notably, concurrent data +//! structures may defer the deallocation of an object. +//! +//! # APIs +//! +//! For majority of use cases, just use the default garbage collector by invoking [`pin`]. If you +//! want to create your own garbage collector, use the [`Collector`] API. +//! +//! [`Atomic`]: struct.Atomic.html +//! [`Collector`]: struct.Collector.html +//! [`Shared`]: struct.Shared.html +//! [`pin`]: fn.pin.html +//! [`defer`]: fn.defer.html + +#![warn(missing_docs)] +#![warn(missing_debug_implementations)] +#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(feature = "nightly", feature(const_fn))] +#![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))] + +#[macro_use] +extern crate cfg_if; +#[cfg(feature = "std")] +extern crate core; + +cfg_if! { + if #[cfg(feature = "alloc")] { + extern crate alloc; + } else if #[cfg(feature = "std")] { + extern crate std as alloc; + } +} + +#[cfg_attr( + feature = "nightly", + cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr")) +)] +cfg_if! { + if #[cfg(any(feature = "alloc", feature = "std"))] { + extern crate arrayvec; + extern crate crossbeam_utils; + #[macro_use] + extern crate memoffset; + #[macro_use] + extern crate scopeguard; + + mod atomic; + mod collector; + mod deferred; + mod epoch; + mod guard; + mod internal; + mod sync; + + pub use self::atomic::{Atomic, CompareAndSetError, CompareAndSetOrdering, Owned, Pointer, Shared}; + pub use self::collector::{Collector, LocalHandle}; + pub use self::guard::{unprotected, Guard}; + } +} + +cfg_if! { + if #[cfg(feature = "std")] { + #[macro_use] + extern crate lazy_static; + + mod default; + pub use self::default::{default_collector, is_pinned, pin}; + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/sync/list.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/sync/list.rs new file mode 100644 index 0000000..623fbd2 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/sync/list.rs @@ -0,0 +1,478 @@ +//! Lock-free intrusive linked list. +//! +//! Ideas from Michael. High Performance Dynamic Lock-Free Hash Tables and List-Based Sets. SPAA +//! 2002. http://dl.acm.org/citation.cfm?id=564870.564881 + +use core::marker::PhantomData; +use core::sync::atomic::Ordering::{Acquire, Relaxed, Release}; + +use {unprotected, Atomic, Guard, Shared}; + +/// An entry in a linked list. +/// +/// An Entry is accessed from multiple threads, so it would be beneficial to put it in a different +/// cache-line than thread-local data in terms of performance. +#[derive(Debug)] +pub struct Entry { + /// The next entry in the linked list. + /// If the tag is 1, this entry is marked as deleted. + next: Atomic, +} + +/// Implementing this trait asserts that the type `T` can be used as an element in the intrusive +/// linked list defined in this module. `T` has to contain (or otherwise be linked to) an instance +/// of `Entry`. +/// +/// # Example +/// +/// ```ignore +/// struct A { +/// entry: Entry, +/// data: usize, +/// } +/// +/// impl IsElement for A { +/// fn entry_of(a: &A) -> &Entry { +/// let entry_ptr = ((a as usize) + offset_of!(A, entry)) as *const Entry; +/// unsafe { &*entry_ptr } +/// } +/// +/// unsafe fn element_of(entry: &Entry) -> &T { +/// let elem_ptr = ((entry as usize) - offset_of!(A, entry)) as *const T; +/// &*elem_ptr +/// } +/// +/// unsafe fn finalize(entry: &Entry, guard: &Guard) { +/// guard.defer_destroy(Shared::from(Self::element_of(entry) as *const _)); +/// } +/// } +/// ``` +/// +/// This trait is implemented on a type separate from `T` (although it can be just `T`), because +/// one type might be placeable into multiple lists, in which case it would require multiple +/// implementations of `IsElement`. In such cases, each struct implementing `IsElement` +/// represents a distinct `Entry` in `T`. +/// +/// For example, we can insert the following struct into two lists using `entry1` for one +/// and `entry2` for the other: +/// +/// ```ignore +/// struct B { +/// entry1: Entry, +/// entry2: Entry, +/// data: usize, +/// } +/// ``` +/// +pub trait IsElement { + /// Returns a reference to this element's `Entry`. + fn entry_of(&T) -> &Entry; + + /// Given a reference to an element's entry, returns that element. + /// + /// ```ignore + /// let elem = ListElement::new(); + /// assert_eq!(elem.entry_of(), + /// unsafe { ListElement::element_of(elem.entry_of()) } ); + /// ``` + /// + /// # Safety + /// + /// The caller has to guarantee that the `Entry` is called with was retrieved from an instance + /// of the element type (`T`). + unsafe fn element_of(&Entry) -> &T; + + /// The function that is called when an entry is unlinked from list. + /// + /// # Safety + /// + /// The caller has to guarantee that the `Entry` is called with was retrieved from an instance + /// of the element type (`T`). + unsafe fn finalize(&Entry, &Guard); +} + +/// A lock-free, intrusive linked list of type `T`. +#[derive(Debug)] +pub struct List = T> { + /// The head of the linked list. + head: Atomic, + + /// The phantom data for using `T` and `C`. + _marker: PhantomData<(T, C)>, +} + +/// An iterator used for retrieving values from the list. +pub struct Iter<'g, T: 'g, C: IsElement> { + /// The guard that protects the iteration. + guard: &'g Guard, + + /// Pointer from the predecessor to the current entry. + pred: &'g Atomic, + + /// The current entry. + curr: Shared<'g, Entry>, + + /// The list head, needed for restarting iteration. + head: &'g Atomic, + + /// Logically, we store a borrow of an instance of `T` and + /// use the type information from `C`. + _marker: PhantomData<(&'g T, C)>, +} + +/// An error that occurs during iteration over the list. +#[derive(PartialEq, Debug)] +pub enum IterError { + /// A concurrent thread modified the state of the list at the same place that this iterator + /// was inspecting. Subsequent iteration will restart from the beginning of the list. + Stalled, +} + +impl Default for Entry { + /// Returns the empty entry. + fn default() -> Self { + Self { + next: Atomic::null(), + } + } +} + +impl Entry { + /// Marks this entry as deleted, deferring the actual deallocation to a later iteration. + /// + /// # Safety + /// + /// The entry should be a member of a linked list, and it should not have been deleted. + /// It should be safe to call `C::finalize` on the entry after the `guard` is dropped, where `C` + /// is the associated helper for the linked list. + pub unsafe fn delete(&self, guard: &Guard) { + self.next.fetch_or(1, Release, guard); + } +} + +impl> List { + /// Returns a new, empty linked list. + pub fn new() -> Self { + Self { + head: Atomic::null(), + _marker: PhantomData, + } + } + + /// Inserts `entry` into the head of the list. + /// + /// # Safety + /// + /// You should guarantee that: + /// + /// - `container` is not null + /// - `container` is immovable, e.g. inside an `Owned` + /// - the same `Entry` is not inserted more than once + /// - the inserted object will be removed before the list is dropped + pub unsafe fn insert<'g>(&'g self, container: Shared<'g, T>, guard: &'g Guard) { + // Insert right after head, i.e. at the beginning of the list. + let to = &self.head; + // Get the intrusively stored Entry of the new element to insert. + let entry: &Entry = C::entry_of(container.deref()); + // Make a Shared ptr to that Entry. + let entry_ptr = Shared::from(entry as *const _); + // Read the current successor of where we want to insert. + let mut next = to.load(Relaxed, guard); + + loop { + // Set the Entry of the to-be-inserted element to point to the previous successor of + // `to`. + entry.next.store(next, Relaxed); + match to.compare_and_set_weak(next, entry_ptr, Release, guard) { + Ok(_) => break, + // We lost the race or weak CAS failed spuriously. Update the successor and try + // again. + Err(err) => next = err.current, + } + } + } + + /// Returns an iterator over all objects. + /// + /// # Caveat + /// + /// Every object that is inserted at the moment this function is called and persists at least + /// until the end of iteration will be returned. Since this iterator traverses a lock-free + /// linked list that may be concurrently modified, some additional caveats apply: + /// + /// 1. If a new object is inserted during iteration, it may or may not be returned. + /// 2. If an object is deleted during iteration, it may or may not be returned. + /// 3. The iteration may be aborted when it lost in a race condition. In this case, the winning + /// thread will continue to iterate over the same list. + pub fn iter<'g>(&'g self, guard: &'g Guard) -> Iter<'g, T, C> { + Iter { + guard, + pred: &self.head, + curr: self.head.load(Acquire, guard), + head: &self.head, + _marker: PhantomData, + } + } +} + +impl> Drop for List { + fn drop(&mut self) { + unsafe { + let guard = &unprotected(); + let mut curr = self.head.load(Relaxed, guard); + while let Some(c) = curr.as_ref() { + let succ = c.next.load(Relaxed, guard); + // Verify that all elements have been removed from the list. + assert_eq!(succ.tag(), 1); + + C::finalize(curr.deref(), guard); + curr = succ; + } + } + } +} + +impl<'g, T: 'g, C: IsElement> Iterator for Iter<'g, T, C> { + type Item = Result<&'g T, IterError>; + + fn next(&mut self) -> Option { + while let Some(c) = unsafe { self.curr.as_ref() } { + let succ = c.next.load(Acquire, self.guard); + + if succ.tag() == 1 { + // This entry was removed. Try unlinking it from the list. + let succ = succ.with_tag(0); + + // The tag should never be zero, because removing a node after a logically deleted + // node leaves the list in an invalid state. + debug_assert!(self.curr.tag() == 0); + + match self + .pred + .compare_and_set(self.curr, succ, Acquire, self.guard) + { + Ok(_) => { + // We succeeded in unlinking this element from the list, so we have to + // schedule deallocation. Deferred drop is okay, because `list.delete()` + // can only be called if `T: 'static`. + unsafe { + C::finalize(self.curr.deref(), self.guard); + } + + // Move over the removed by only advancing `curr`, not `pred`. + self.curr = succ; + continue; + } + Err(_) => { + // A concurrent thread modified the predecessor node. Since it might've + // been deleted, we need to restart from `head`. + self.pred = self.head; + self.curr = self.head.load(Acquire, self.guard); + + return Some(Err(IterError::Stalled)); + } + } + } + + // Move one step forward. + self.pred = &c.next; + self.curr = succ; + + return Some(Ok(unsafe { C::element_of(c) })); + } + + // We reached the end of the list. + None + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crossbeam_utils::thread; + use std::sync::Barrier; + use {Collector, Owned}; + + impl IsElement for Entry { + fn entry_of(entry: &Entry) -> &Entry { + entry + } + + unsafe fn element_of(entry: &Entry) -> &Entry { + entry + } + + unsafe fn finalize(entry: &Entry, guard: &Guard) { + guard.defer_destroy(Shared::from(Self::element_of(entry) as *const _)); + } + } + + /// Checks whether the list retains inserted elements + /// and returns them in the correct order. + #[test] + fn insert() { + let collector = Collector::new(); + let handle = collector.register(); + let guard = handle.pin(); + + let l: List = List::new(); + + let e1 = Owned::new(Entry::default()).into_shared(&guard); + let e2 = Owned::new(Entry::default()).into_shared(&guard); + let e3 = Owned::new(Entry::default()).into_shared(&guard); + + unsafe { + l.insert(e1, &guard); + l.insert(e2, &guard); + l.insert(e3, &guard); + } + + let mut iter = l.iter(&guard); + let maybe_e3 = iter.next(); + assert!(maybe_e3.is_some()); + assert!(maybe_e3.unwrap().unwrap() as *const Entry == e3.as_raw()); + let maybe_e2 = iter.next(); + assert!(maybe_e2.is_some()); + assert!(maybe_e2.unwrap().unwrap() as *const Entry == e2.as_raw()); + let maybe_e1 = iter.next(); + assert!(maybe_e1.is_some()); + assert!(maybe_e1.unwrap().unwrap() as *const Entry == e1.as_raw()); + assert!(iter.next().is_none()); + + unsafe { + e1.as_ref().unwrap().delete(&guard); + e2.as_ref().unwrap().delete(&guard); + e3.as_ref().unwrap().delete(&guard); + } + } + + /// Checks whether elements can be removed from the list and whether + /// the correct elements are removed. + #[test] + fn delete() { + let collector = Collector::new(); + let handle = collector.register(); + let guard = handle.pin(); + + let l: List = List::new(); + + let e1 = Owned::new(Entry::default()).into_shared(&guard); + let e2 = Owned::new(Entry::default()).into_shared(&guard); + let e3 = Owned::new(Entry::default()).into_shared(&guard); + unsafe { + l.insert(e1, &guard); + l.insert(e2, &guard); + l.insert(e3, &guard); + e2.as_ref().unwrap().delete(&guard); + } + + let mut iter = l.iter(&guard); + let maybe_e3 = iter.next(); + assert!(maybe_e3.is_some()); + assert!(maybe_e3.unwrap().unwrap() as *const Entry == e3.as_raw()); + let maybe_e1 = iter.next(); + assert!(maybe_e1.is_some()); + assert!(maybe_e1.unwrap().unwrap() as *const Entry == e1.as_raw()); + assert!(iter.next().is_none()); + + unsafe { + e1.as_ref().unwrap().delete(&guard); + e3.as_ref().unwrap().delete(&guard); + } + + let mut iter = l.iter(&guard); + assert!(iter.next().is_none()); + } + + const THREADS: usize = 8; + const ITERS: usize = 512; + + /// Contends the list on insert and delete operations to make sure they can run concurrently. + #[test] + fn insert_delete_multi() { + let collector = Collector::new(); + + let l: List = List::new(); + let b = Barrier::new(THREADS); + + thread::scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + b.wait(); + + let handle = collector.register(); + let guard: Guard = handle.pin(); + let mut v = Vec::with_capacity(ITERS); + + for _ in 0..ITERS { + let e = Owned::new(Entry::default()).into_shared(&guard); + v.push(e); + unsafe { + l.insert(e, &guard); + } + } + + for e in v { + unsafe { + e.as_ref().unwrap().delete(&guard); + } + } + }); + } + }) + .unwrap(); + + let handle = collector.register(); + let guard = handle.pin(); + + let mut iter = l.iter(&guard); + assert!(iter.next().is_none()); + } + + /// Contends the list on iteration to make sure that it can be iterated over concurrently. + #[test] + fn iter_multi() { + let collector = Collector::new(); + + let l: List = List::new(); + let b = Barrier::new(THREADS); + + thread::scope(|s| { + for _ in 0..THREADS { + s.spawn(|_| { + b.wait(); + + let handle = collector.register(); + let guard: Guard = handle.pin(); + let mut v = Vec::with_capacity(ITERS); + + for _ in 0..ITERS { + let e = Owned::new(Entry::default()).into_shared(&guard); + v.push(e); + unsafe { + l.insert(e, &guard); + } + } + + let mut iter = l.iter(&guard); + for _ in 0..ITERS { + assert!(iter.next().is_some()); + } + + for e in v { + unsafe { + e.as_ref().unwrap().delete(&guard); + } + } + }); + } + }) + .unwrap(); + + let handle = collector.register(); + let guard = handle.pin(); + + let mut iter = l.iter(&guard); + assert!(iter.next().is_none()); + } +} diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/sync/mod.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/sync/mod.rs new file mode 100644 index 0000000..f8eb259 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/sync/mod.rs @@ -0,0 +1,4 @@ +//! Synchronization primitives. + +pub mod list; +pub mod queue; diff --git a/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/sync/queue.rs b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/sync/queue.rs new file mode 100644 index 0000000..671d046 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-epoch-0.7.2/src/sync/queue.rs @@ -0,0 +1,441 @@ +//! Michael-Scott lock-free queue. +//! +//! Usable with any number of producers and consumers. +//! +//! Michael and Scott. Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue +//! Algorithms. PODC 1996. http://dl.acm.org/citation.cfm?id=248106 + +use core::mem::{self, ManuallyDrop}; +use core::ptr; +use core::sync::atomic::Ordering::{Acquire, Relaxed, Release}; + +use crossbeam_utils::CachePadded; + +use {unprotected, Atomic, Guard, Owned, Shared}; + +// The representation here is a singly-linked list, with a sentinel node at the front. In general +// the `tail` pointer may lag behind the actual tail. Non-sentinel nodes are either all `Data` or +// all `Blocked` (requests for data from blocked threads). +#[derive(Debug)] +pub struct Queue { + head: CachePadded>>, + tail: CachePadded>>, +} + +#[derive(Debug)] +struct Node { + /// The slot in which a value of type `T` can be stored. + /// + /// The type of `data` is `ManuallyDrop` because a `Node` doesn't always contain a `T`. + /// For example, the sentinel node in a queue never contains a value: its slot is always empty. + /// Other nodes start their life with a push operation and contain a value until it gets popped + /// out. After that such empty nodes get added to the collector for destruction. + data: ManuallyDrop, + + next: Atomic>, +} + +// Any particular `T` should never be accessed concurrently, so no need for `Sync`. +unsafe impl Sync for Queue {} +unsafe impl Send for Queue {} + +impl Queue { + /// Create a new, empty queue. + pub fn new() -> Queue { + let q = Queue { + head: CachePadded::new(Atomic::null()), + tail: CachePadded::new(Atomic::null()), + }; + let sentinel = Owned::new(Node { + data: unsafe { mem::uninitialized() }, + next: Atomic::null(), + }); + unsafe { + let guard = &unprotected(); + let sentinel = sentinel.into_shared(guard); + q.head.store(sentinel, Relaxed); + q.tail.store(sentinel, Relaxed); + q + } + } + + /// Attempts to atomically place `n` into the `next` pointer of `onto`, and returns `true` on + /// success. The queue's `tail` pointer may be updated. + #[inline(always)] + fn push_internal(&self, onto: Shared>, new: Shared>, guard: &Guard) -> bool { + // is `onto` the actual tail? + let o = unsafe { onto.deref() }; + let next = o.next.load(Acquire, guard); + if unsafe { next.as_ref().is_some() } { + // if not, try to "help" by moving the tail pointer forward + let _ = self.tail.compare_and_set(onto, next, Release, guard); + false + } else { + // looks like the actual tail; attempt to link in `n` + let result = o + .next + .compare_and_set(Shared::null(), new, Release, guard) + .is_ok(); + if result { + // try to move the tail pointer forward + let _ = self.tail.compare_and_set(onto, new, Release, guard); + } + result + } + } + + /// Adds `t` to the back of the queue, possibly waking up threads blocked on `pop`. + pub fn push(&self, t: T, guard: &Guard) { + let new = Owned::new(Node { + data: ManuallyDrop::new(t), + next: Atomic::null(), + }); + let new = Owned::into_shared(new, guard); + + loop { + // We push onto the tail, so we'll start optimistically by looking there first. + let tail = self.tail.load(Acquire, guard); + + // Attempt to push onto the `tail` snapshot; fails if `tail.next` has changed. + if self.push_internal(tail, new, guard) { + break; + } + } + } + + /// Attempts to pop a data node. `Ok(None)` if queue is empty; `Err(())` if lost race to pop. + #[inline(always)] + fn pop_internal(&self, guard: &Guard) -> Result, ()> { + let head = self.head.load(Acquire, guard); + let h = unsafe { head.deref() }; + let next = h.next.load(Acquire, guard); + match unsafe { next.as_ref() } { + Some(n) => unsafe { + self.head + .compare_and_set(head, next, Release, guard) + .map(|_| { + guard.defer_destroy(head); + Some(ManuallyDrop::into_inner(ptr::read(&n.data))) + }) + .map_err(|_| ()) + }, + None => Ok(None), + } + } + + /// Attempts to pop a data node, if the data satisfies the given condition. `Ok(None)` if queue + /// is empty or the data does not satisfy the condition; `Err(())` if lost race to pop. + #[inline(always)] + fn pop_if_internal(&self, condition: F, guard: &Guard) -> Result, ()> + where + T: Sync, + F: Fn(&T) -> bool, + { + let head = self.head.load(Acquire, guard); + let h = unsafe { head.deref() }; + let next = h.next.load(Acquire, guard); + match unsafe { next.as_ref() } { + Some(n) if condition(&n.data) => unsafe { + self.head + .compare_and_set(head, next, Release, guard) + .map(|_| { + guard.defer_destroy(head); + Some(ManuallyDrop::into_inner(ptr::read(&n.data))) + }) + .map_err(|_| ()) + }, + None | Some(_) => Ok(None), + } + } + + /// Attempts to dequeue from the front. + /// + /// Returns `None` if the queue is observed to be empty. + pub fn try_pop(&self, guard: &Guard) -> Option { + loop { + if let Ok(head) = self.pop_internal(guard) { + return head; + } + } + } + + /// Attempts to dequeue from the front, if the item satisfies the given condition. + /// + /// Returns `None` if the queue is observed to be empty, or the head does not satisfy the given + /// condition. + pub fn try_pop_if(&self, condition: F, guard: &Guard) -> Option + where + T: Sync, + F: Fn(&T) -> bool, + { + loop { + if let Ok(head) = self.pop_if_internal(&condition, guard) { + return head; + } + } + } +} + +impl Drop for Queue { + fn drop(&mut self) { + unsafe { + let guard = &unprotected(); + + while let Some(_) = self.try_pop(guard) {} + + // Destroy the remaining sentinel node. + let sentinel = self.head.load(Relaxed, guard); + drop(sentinel.into_owned()); + } + } +} + +#[cfg(test)] +mod test { + use super::*; + use crossbeam_utils::thread; + use pin; + + struct Queue { + queue: super::Queue, + } + + impl Queue { + pub fn new() -> Queue { + Queue { + queue: super::Queue::new(), + } + } + + pub fn push(&self, t: T) { + let guard = &pin(); + self.queue.push(t, guard); + } + + pub fn is_empty(&self) -> bool { + let guard = &pin(); + let head = self.queue.head.load(Acquire, guard); + let h = unsafe { head.deref() }; + h.next.load(Acquire, guard).is_null() + } + + pub fn try_pop(&self) -> Option { + let guard = &pin(); + self.queue.try_pop(guard) + } + + pub fn pop(&self) -> T { + loop { + match self.try_pop() { + None => continue, + Some(t) => return t, + } + } + } + } + + const CONC_COUNT: i64 = 1000000; + + #[test] + fn push_try_pop_1() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + q.push(37); + assert!(!q.is_empty()); + assert_eq!(q.try_pop(), Some(37)); + assert!(q.is_empty()); + } + + #[test] + fn push_try_pop_2() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + q.push(37); + q.push(48); + assert_eq!(q.try_pop(), Some(37)); + assert!(!q.is_empty()); + assert_eq!(q.try_pop(), Some(48)); + assert!(q.is_empty()); + } + + #[test] + fn push_try_pop_many_seq() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + for i in 0..200 { + q.push(i) + } + assert!(!q.is_empty()); + for i in 0..200 { + assert_eq!(q.try_pop(), Some(i)); + } + assert!(q.is_empty()); + } + + #[test] + fn push_pop_1() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + q.push(37); + assert!(!q.is_empty()); + assert_eq!(q.pop(), 37); + assert!(q.is_empty()); + } + + #[test] + fn push_pop_2() { + let q: Queue = Queue::new(); + q.push(37); + q.push(48); + assert_eq!(q.pop(), 37); + assert_eq!(q.pop(), 48); + } + + #[test] + fn push_pop_many_seq() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + for i in 0..200 { + q.push(i) + } + assert!(!q.is_empty()); + for i in 0..200 { + assert_eq!(q.pop(), i); + } + assert!(q.is_empty()); + } + + #[test] + fn push_try_pop_many_spsc() { + let q: Queue = Queue::new(); + assert!(q.is_empty()); + + thread::scope(|scope| { + scope.spawn(|_| { + let mut next = 0; + + while next < CONC_COUNT { + if let Some(elem) = q.try_pop() { + assert_eq!(elem, next); + next += 1; + } + } + }); + + for i in 0..CONC_COUNT { + q.push(i) + } + }) + .unwrap(); + } + + #[test] + fn push_try_pop_many_spmc() { + fn recv(_t: i32, q: &Queue) { + let mut cur = -1; + for _i in 0..CONC_COUNT { + if let Some(elem) = q.try_pop() { + assert!(elem > cur); + cur = elem; + + if cur == CONC_COUNT - 1 { + break; + } + } + } + } + + let q: Queue = Queue::new(); + assert!(q.is_empty()); + thread::scope(|scope| { + for i in 0..3 { + let q = &q; + scope.spawn(move |_| recv(i, q)); + } + + scope.spawn(|_| { + for i in 0..CONC_COUNT { + q.push(i); + } + }); + }) + .unwrap(); + } + + #[test] + fn push_try_pop_many_mpmc() { + enum LR { + Left(i64), + Right(i64), + } + + let q: Queue = Queue::new(); + assert!(q.is_empty()); + + thread::scope(|scope| { + for _t in 0..2 { + scope.spawn(|_| { + for i in CONC_COUNT - 1..CONC_COUNT { + q.push(LR::Left(i)) + } + }); + scope.spawn(|_| { + for i in CONC_COUNT - 1..CONC_COUNT { + q.push(LR::Right(i)) + } + }); + scope.spawn(|_| { + let mut vl = vec![]; + let mut vr = vec![]; + for _i in 0..CONC_COUNT { + match q.try_pop() { + Some(LR::Left(x)) => vl.push(x), + Some(LR::Right(x)) => vr.push(x), + _ => {} + } + } + + let mut vl2 = vl.clone(); + let mut vr2 = vr.clone(); + vl2.sort(); + vr2.sort(); + + assert_eq!(vl, vl2); + assert_eq!(vr, vr2); + }); + } + }) + .unwrap(); + } + + #[test] + fn push_pop_many_spsc() { + let q: Queue = Queue::new(); + + thread::scope(|scope| { + scope.spawn(|_| { + let mut next = 0; + while next < CONC_COUNT { + assert_eq!(q.pop(), next); + next += 1; + } + }); + + for i in 0..CONC_COUNT { + q.push(i) + } + }) + .unwrap(); + assert!(q.is_empty()); + } + + #[test] + fn is_empty_dont_pop() { + let q: Queue = Queue::new(); + q.push(20); + q.push(20); + assert!(!q.is_empty()); + assert!(!q.is_empty()); + assert!(q.try_pop().is_some()); + } +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/.cargo-checksum.json b/third_party/cargo/vendor/crossbeam-utils-0.6.6/.cargo-checksum.json new file mode 100644 index 0000000..b100cb8 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"cb975f0361e0cccfe00da4f32d4c87308b20e40f6444d2ef474640fbb15567de","Cargo.toml":"8ad804e9e161a564e57e2cea30349d9658fd3d32bd0b065868073cdcc70a78cb","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","README.md":"0b293d1b9b129a58f504ff4bc061161ddfaf7c8594e0ca2b526458d4e9acb194","benches/atomic_cell.rs":"fa38d34ddc593bf0999fd65d95ee349c53a11290fbe7bf24870a7e24754ae2ac","src/atomic/atomic_cell.rs":"9f18d8cf7d91750f7646bc2ef7bf5b7444b2c9acdc2e8b6dffd8f0ff696e113b","src/atomic/consume.rs":"bfdc7e2d8370a5a3bb1699b6214347c359d66fcc92a2d1345a513676ac91d821","src/atomic/mod.rs":"404eacae422012f3628cb44262df73a5891fe02a17ab345b832e3062982b5a20","src/backoff.rs":"bc9d2afdd070e0746bc48ff2159bf47b0cfaa68ea09f47eaed18ccc32fc87d67","src/cache_padded.rs":"864f210089eddfd130830f5c700115c2f8b974b71659d7e8ef7bd5e09d7e1f96","src/lib.rs":"3138911610fa97a412c62e4aa5a6cd50524a04f6746c08a5cda8fd1c1d954555","src/sync/mod.rs":"4c8ad6ec4601f212791b0b531b46ee5decec2f1d14746aa7f2c18e36c609cd8e","src/sync/parker.rs":"55324bbea5b7c6838a0f8467a5b8a5dbd5526c8e1c7fd4f6d64dad1ab19f9be9","src/sync/sharded_lock.rs":"7a401ba621233732c26cf49324748269359d7bc5dc27e0ec26c9493e9a5ec97d","src/sync/wait_group.rs":"21708bbd46daa98e9f788765a9a4ef3b087a8d1e97a6e9406b4a960c95e44ca0","src/thread.rs":"ee89256b619c7ed55e04519bb3b9f29e72e6ce1e61e8ba9782a984f5e9fc1bad","tests/atomic_cell.rs":"4423b41f6f23ff2519f4a1f9970436b7fb49968be5bc14dbdbd5ab2d5b1048df","tests/cache_padded.rs":"02235757a554279dae5053d46314a765059ec036c63a05336353994c2aa344d1","tests/parker.rs":"3e5c4e170cebdd9f815f2b31a2b6a01da753fc03e2b1d8e9b899d009f62c6b83","tests/sharded_lock.rs":"3b42218397f1260bed4e0a229f55da83439c0ec9effbbefc86251c9d208979bb","tests/thread.rs":"42baefda11ccd87d9fe1a93bb7d6186b17a86afcf3b9d8f739bc0deefa11ae0f","tests/wait_group.rs":"e3d5168581fb511b760f4249ca487b919cffc60ac2b4610a78db99899772dd5b"},"package":"04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"} \ No newline at end of file diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/BUILD b/third_party/cargo/vendor/crossbeam-utils-0.6.6/BUILD new file mode 100644 index 0000000..4f69595 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/BUILD @@ -0,0 +1,54 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "atomic_cell" with type "bench" omitted +# Unsupported target "atomic_cell" with type "test" omitted +# Unsupported target "cache_padded" with type "test" omitted + +rust_library( + name = "crossbeam_utils", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/cfg-if-0.1.10:cfg_if", + "//third_party/cargo/vendor/lazy_static-1.4.0:lazy_static", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.6", + crate_features = [ + "default", + "lazy_static", + "std", + ], +) + +# Unsupported target "parker" with type "test" omitted +# Unsupported target "sharded_lock" with type "test" omitted +# Unsupported target "thread" with type "test" omitted +# Unsupported target "wait_group" with type "test" omitted diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/CHANGELOG.md b/third_party/cargo/vendor/crossbeam-utils-0.6.6/CHANGELOG.md new file mode 100644 index 0000000..6e21023 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/CHANGELOG.md @@ -0,0 +1,97 @@ +# Version 0.6.6 + +- Add `UnwindSafe` and `RefUnwindSafe` impls for `AtomicCell`. +- Add `AtomicCell::as_ptr()`. +- Add `AtomicCell::take()`. +- Fix a bug in `AtomicCell::compare_exchange()` and `AtomicCell::compare_and_swap()`. +- Various documentation improvements. + +# Version 0.6.5 + +- Rename `Backoff::is_complete()` to `Backoff::is_completed()`. + +# Version 0.6.4 + +- Add `WaitGroup`, `ShardedLock`, and `Backoff`. +- Add `fetch_*` methods for `AtomicCell` and `AtomicCell`. +- Expand documentation. + +# Version 0.6.3 + +- Add `AtomicCell`. +- Improve documentation. + +# Version 0.6.2 + +- Add `Parker`. +- Improve documentation. + +# Version 0.6.1 + +- Fix a soundness bug in `Scope::spawn()`. +- Remove the `T: 'scope` bound on `ScopedJoinHandle`. + +# Version 0.6.0 + +- Move `AtomicConsume` to `atomic` module. +- `scope()` returns a `Result` of thread joins. +- Remove `spawn_unchecked`. +- Fix a soundness bug due to incorrect lifetimes. +- Improve documentation. +- Support nested scoped spawns. +- Implement `Copy`, `Hash`, `PartialEq`, and `Eq` for `CachePadded`. +- Add `CachePadded::into_inner()`. + +# Version 0.5.0 + +- Reorganize sub-modules and rename functions. + +# Version 0.4.1 + +- Fix a documentation link. + +# Version 0.4.0 + +- `CachePadded` supports types bigger than 64 bytes. +- Fix a bug in scoped threads where unitialized memory was being dropped. +- Minimum required Rust version is now 1.25. + +# Version 0.3.2 + +- Mark `load_consume` with `#[inline]`. + +# Version 0.3.1 + +- `load_consume` on ARM and AArch64. + +# Version 0.3.0 + +- Add `join` for scoped thread API. +- Add `load_consume` for atomic load-consume memory ordering. +- Remove `AtomicOption`. + +# Version 0.2.2 + +- Support Rust 1.12.1. +- Call `T::clone` when cloning a `CachePadded`. + +# Version 0.2.1 + +- Add `use_std` feature. + +# Version 0.2.0 + +- Add `nightly` feature. +- Use `repr(align(64))` on `CachePadded` with the `nightly` feature. +- Implement `Drop` for `CachePadded`. +- Implement `Clone` for `CachePadded`. +- Implement `From` for `CachePadded`. +- Implement better `Debug` for `CachePadded`. +- Write more tests. +- Add this changelog. +- Change cache line length to 64 bytes. +- Remove `ZerosValid`. + +# Version 0.1.0 + +- Old implementation of `CachePadded` from `crossbeam` version 0.3.0 diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/Cargo.toml b/third_party/cargo/vendor/crossbeam-utils-0.6.6/Cargo.toml new file mode 100644 index 0000000..1dbd675 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/Cargo.toml @@ -0,0 +1,38 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "crossbeam-utils" +version = "0.6.6" +authors = ["The Crossbeam Project Developers"] +description = "Utilities for concurrent programming" +homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-utils" +documentation = "https://docs.rs/crossbeam-utils" +readme = "README.md" +keywords = ["scoped", "thread", "atomic", "cache"] +categories = ["algorithms", "concurrency", "data-structures", "no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/crossbeam-rs/crossbeam" +[dependencies.cfg-if] +version = "0.1.2" + +[dependencies.lazy_static] +version = "1.1.0" +optional = true +[dev-dependencies.rand] +version = "0.6" + +[features] +alloc = [] +default = ["std"] +nightly = [] +std = ["lazy_static"] diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/LICENSE-APACHE b/third_party/cargo/vendor/crossbeam-utils-0.6.6/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/LICENSE-MIT b/third_party/cargo/vendor/crossbeam-utils-0.6.6/LICENSE-MIT new file mode 100644 index 0000000..068d491 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/LICENSE-MIT @@ -0,0 +1,27 @@ +The MIT License (MIT) + +Copyright (c) 2019 The Crossbeam Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/README.md b/third_party/cargo/vendor/crossbeam-utils-0.6.6/README.md new file mode 100644 index 0000000..b4a0f6b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/README.md @@ -0,0 +1,73 @@ +# Crossbeam Utils + +[![Build Status](https://travis-ci.org/crossbeam-rs/crossbeam.svg?branch=master)]( +https://travis-ci.org/crossbeam-rs/crossbeam) +[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)]( +https://github.com/crossbeam-rs/crossbeam-utils/tree/master/src) +[![Cargo](https://img.shields.io/crates/v/crossbeam-utils.svg)]( +https://crates.io/crates/crossbeam-utils) +[![Documentation](https://docs.rs/crossbeam-utils/badge.svg)]( +https://docs.rs/crossbeam-utils) +[![Rust 1.26+](https://img.shields.io/badge/rust-1.26+-lightgray.svg)]( +https://www.rust-lang.org) +[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq) + +This crate provides miscellaneous tools for concurrent programming: + +#### Atomics + +* [`AtomicCell`], a thread-safe mutable memory location.(no_std) +* [`AtomicConsume`], for reading from primitive atomic types with "consume" ordering.(no_std) + +#### Thread synchronization + +* [`Parker`], a thread parking primitive. +* [`ShardedLock`], a sharded reader-writer lock with fast concurrent reads. +* [`WaitGroup`], for synchronizing the beginning or end of some computation. + +#### Utilities + +* [`Backoff`], for exponential backoff in spin loops.(no_std) +* [`CachePadded`], for padding and aligning a value to the length of a cache line.(no_std) +* [`scope`], for spawning threads that borrow local variables from the stack. + +*Features marked with (no_std) can be used in `no_std` environments.*
+ +[`AtomicCell`]: https://docs.rs/crossbeam-utils/*/crossbeam_utils/atomic/struct.AtomicCell.html +[`AtomicConsume`]: https://docs.rs/crossbeam-utils/*/crossbeam_utils/atomic/trait.AtomicConsume.html +[`Parker`]: https://docs.rs/crossbeam-utils/*/crossbeam_utils/sync/struct.Parker.html +[`ShardedLock`]: https://docs.rs/crossbeam-utils/*/crossbeam_utils/sync/struct.ShardedLock.html +[`WaitGroup`]: https://docs.rs/crossbeam-utils/*/crossbeam_utils/sync/struct.WaitGroup.html +[`Backoff`]: https://docs.rs/crossbeam-utils/*/crossbeam_utils/struct.Backoff.html +[`CachePadded`]: https://docs.rs/crossbeam-utils/*/crossbeam_utils/struct.CachePadded.html +[`scope`]: https://docs.rs/crossbeam-utils/*/crossbeam_utils/thread/fn.scope.html + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +crossbeam-utils = "0.6" +``` + +Next, add this to your crate: + +```rust +extern crate crossbeam_utils; +``` + +## License + +Licensed under either of + + * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +#### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/benches/atomic_cell.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/benches/atomic_cell.rs new file mode 100644 index 0000000..8587dba --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/benches/atomic_cell.rs @@ -0,0 +1,157 @@ +#![feature(test)] + +extern crate crossbeam_utils; +extern crate test; + +use std::sync::Barrier; + +use crossbeam_utils::atomic::AtomicCell; +use crossbeam_utils::thread; + +#[bench] +fn load_u8(b: &mut test::Bencher) { + let a = AtomicCell::new(0u8); + let mut sum = 0; + b.iter(|| sum += a.load()); + test::black_box(sum); +} + +#[bench] +fn store_u8(b: &mut test::Bencher) { + let a = AtomicCell::new(0u8); + b.iter(|| a.store(1)); +} + +#[bench] +fn fetch_add_u8(b: &mut test::Bencher) { + let a = AtomicCell::new(0u8); + b.iter(|| a.fetch_add(1)); +} + +#[bench] +fn compare_and_swap_u8(b: &mut test::Bencher) { + let a = AtomicCell::new(0u8); + let mut i = 0; + b.iter(|| { + a.compare_and_swap(i, i.wrapping_add(1)); + i = i.wrapping_add(1); + }); +} + +#[bench] +fn concurrent_load_u8(b: &mut test::Bencher) { + const THREADS: usize = 2; + const STEPS: usize = 1_000_000; + + let start = Barrier::new(THREADS + 1); + let end = Barrier::new(THREADS + 1); + let exit = AtomicCell::new(false); + + let a = AtomicCell::new(0u8); + + thread::scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| loop { + start.wait(); + + let mut sum = 0; + for _ in 0..STEPS { + sum += a.load(); + } + test::black_box(sum); + + end.wait(); + if exit.load() { + break; + } + }); + } + + start.wait(); + end.wait(); + + b.iter(|| { + start.wait(); + end.wait(); + }); + + start.wait(); + exit.store(true); + end.wait(); + }) + .unwrap(); +} + +#[bench] +fn load_usize(b: &mut test::Bencher) { + let a = AtomicCell::new(0usize); + let mut sum = 0; + b.iter(|| sum += a.load()); + test::black_box(sum); +} + +#[bench] +fn store_usize(b: &mut test::Bencher) { + let a = AtomicCell::new(0usize); + b.iter(|| a.store(1)); +} + +#[bench] +fn fetch_add_usize(b: &mut test::Bencher) { + let a = AtomicCell::new(0usize); + b.iter(|| a.fetch_add(1)); +} + +#[bench] +fn compare_and_swap_usize(b: &mut test::Bencher) { + let a = AtomicCell::new(0usize); + let mut i = 0; + b.iter(|| { + a.compare_and_swap(i, i.wrapping_add(1)); + i = i.wrapping_add(1); + }); +} + +#[bench] +fn concurrent_load_usize(b: &mut test::Bencher) { + const THREADS: usize = 2; + const STEPS: usize = 1_000_000; + + let start = Barrier::new(THREADS + 1); + let end = Barrier::new(THREADS + 1); + let exit = AtomicCell::new(false); + + let a = AtomicCell::new(0usize); + + thread::scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| loop { + start.wait(); + + let mut sum = 0; + for _ in 0..STEPS { + sum += a.load(); + } + test::black_box(sum); + + end.wait(); + if exit.load() { + break; + } + }); + } + + start.wait(); + end.wait(); + + b.iter(|| { + start.wait(); + end.wait(); + }); + + start.wait(); + exit.store(true); + end.wait(); + }) + .unwrap(); +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/atomic/atomic_cell.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/atomic/atomic_cell.rs new file mode 100644 index 0000000..f3118ec --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/atomic/atomic_cell.rs @@ -0,0 +1,968 @@ +use core::cell::UnsafeCell; +use core::fmt; +use core::mem; +use core::ptr; +use core::sync::atomic::{self, AtomicBool, AtomicUsize, Ordering}; + +#[cfg(feature = "std")] +use std::panic::{RefUnwindSafe, UnwindSafe}; + +use Backoff; + +/// A thread-safe mutable memory location. +/// +/// This type is equivalent to [`Cell`], except it can also be shared among multiple threads. +/// +/// Operations on `AtomicCell`s use atomic instructions whenever possible, and synchronize using +/// global locks otherwise. You can call [`AtomicCell::::is_lock_free()`] to check whether +/// atomic instructions or locks will be used. +/// +/// Atomic loads use the [`Acquire`] ordering and atomic stores use the [`Release`] ordering. +/// +/// [`Cell`]: https://doc.rust-lang.org/std/cell/struct.Cell.html +/// [`AtomicCell::::is_lock_free()`]: struct.AtomicCell.html#method.is_lock_free +/// [`Acquire`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html#variant.Acquire +/// [`Release`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html#variant.Release +// TODO(@jeehoonkang): when the minimum supported Rust version is bumped to 1.28+, apply the +// attribute `#[repr(transparent)]`. +pub struct AtomicCell { + /// The inner value. + /// + /// If this value can be transmuted into a primitive atomic type, it will be treated as such. + /// Otherwise, all potentially concurrent operations on this data will be protected by a global + /// lock. + value: UnsafeCell, +} + +unsafe impl Send for AtomicCell {} +unsafe impl Sync for AtomicCell {} + +#[cfg(feature = "std")] +impl UnwindSafe for AtomicCell {} +#[cfg(feature = "std")] +impl RefUnwindSafe for AtomicCell {} + +impl AtomicCell { + /// Creates a new atomic cell initialized with `val`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(7); + /// ``` + pub fn new(val: T) -> AtomicCell { + AtomicCell { + value: UnsafeCell::new(val), + } + } + + /// Unwraps the atomic cell and returns its inner value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let mut a = AtomicCell::new(7); + /// let v = a.into_inner(); + /// + /// assert_eq!(v, 7); + /// ``` + pub fn into_inner(self) -> T { + self.value.into_inner() + } + + /// Returns `true` if operations on values of this type are lock-free. + /// + /// If the compiler or the platform doesn't support the necessary atomic instructions, + /// `AtomicCell` will use global locks for every potentially concurrent atomic operation. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// // This type is internally represented as `AtomicUsize` so we can just use atomic + /// // operations provided by it. + /// assert_eq!(AtomicCell::::is_lock_free(), true); + /// + /// // A wrapper struct around `isize`. + /// struct Foo { + /// bar: isize, + /// } + /// // `AtomicCell` will be internally represented as `AtomicIsize`. + /// assert_eq!(AtomicCell::::is_lock_free(), true); + /// + /// // Operations on zero-sized types are always lock-free. + /// assert_eq!(AtomicCell::<()>::is_lock_free(), true); + /// + /// // Very large types cannot be represented as any of the standard atomic types, so atomic + /// // operations on them will have to use global locks for synchronization. + /// assert_eq!(AtomicCell::<[u8; 1000]>::is_lock_free(), false); + /// ``` + pub fn is_lock_free() -> bool { + atomic_is_lock_free::() + } + + /// Stores `val` into the atomic cell. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(7); + /// + /// assert_eq!(a.load(), 7); + /// a.store(8); + /// assert_eq!(a.load(), 8); + /// ``` + pub fn store(&self, val: T) { + if mem::needs_drop::() { + drop(self.swap(val)); + } else { + unsafe { + atomic_store(self.value.get(), val); + } + } + } + + /// Stores `val` into the atomic cell and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(7); + /// + /// assert_eq!(a.load(), 7); + /// assert_eq!(a.swap(8), 7); + /// assert_eq!(a.load(), 8); + /// ``` + pub fn swap(&self, val: T) -> T { + unsafe { atomic_swap(self.value.get(), val) } + } +} + +impl AtomicCell { + /// Returns a raw pointer to the underlying data in this atomic cell. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let mut a = AtomicCell::new(5); + /// + /// let ptr = a.as_ptr(); + /// ``` + #[inline] + pub fn as_ptr(&self) -> *mut T { + self.value.get() + } + + /// Returns a mutable reference to the inner value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let mut a = AtomicCell::new(7); + /// *a.get_mut() += 1; + /// + /// assert_eq!(a.load(), 8); + /// ``` + #[doc(hidden)] + #[deprecated(note = "this method is unsound and will be removed in the next release")] + pub fn get_mut(&mut self) -> &mut T { + unsafe { &mut *self.value.get() } + } +} + +impl AtomicCell { + /// Takes the value of the atomic cell, leaving `Default::default()` in its place. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(5); + /// let five = a.take(); + /// + /// assert_eq!(five, 5); + /// assert_eq!(a.into_inner(), 0); + /// ``` + pub fn take(&self) -> T { + self.swap(Default::default()) + } +} + +impl AtomicCell { + /// Loads a value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(7); + /// + /// assert_eq!(a.load(), 7); + /// ``` + pub fn load(&self) -> T { + unsafe { atomic_load(self.value.get()) } + } +} + +impl AtomicCell { + /// If the current value equals `current`, stores `new` into the atomic cell. + /// + /// The return value is always the previous value. If it is equal to `current`, then the value + /// was updated. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(1); + /// + /// assert_eq!(a.compare_and_swap(2, 3), 1); + /// assert_eq!(a.load(), 1); + /// + /// assert_eq!(a.compare_and_swap(1, 2), 1); + /// assert_eq!(a.load(), 2); + /// ``` + pub fn compare_and_swap(&self, current: T, new: T) -> T { + match self.compare_exchange(current, new) { + Ok(v) => v, + Err(v) => v, + } + } + + /// If the current value equals `current`, stores `new` into the atomic cell. + /// + /// The return value is a result indicating whether the new value was written and containing + /// the previous value. On success this value is guaranteed to be equal to `current`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(1); + /// + /// assert_eq!(a.compare_exchange(2, 3), Err(1)); + /// assert_eq!(a.load(), 1); + /// + /// assert_eq!(a.compare_exchange(1, 2), Ok(1)); + /// assert_eq!(a.load(), 2); + /// ``` + pub fn compare_exchange(&self, current: T, new: T) -> Result { + unsafe { atomic_compare_exchange_weak(self.value.get(), current, new) } + } +} + +macro_rules! impl_arithmetic { + ($t:ty, $example:tt) => { + impl AtomicCell<$t> { + /// Increments the current value by `val` and returns the previous value. + /// + /// The addition wraps on overflow. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_add(3), 7); + /// assert_eq!(a.load(), 10); + /// ``` + #[inline] + pub fn fetch_add(&self, val: $t) -> $t { + if can_transmute::<$t, atomic::AtomicUsize>() { + let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) }; + a.fetch_add(val as usize, Ordering::AcqRel) as $t + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = value.wrapping_add(val); + old + } + } + + /// Decrements the current value by `val` and returns the previous value. + /// + /// The subtraction wraps on overflow. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_sub(3), 7); + /// assert_eq!(a.load(), 4); + /// ``` + #[inline] + pub fn fetch_sub(&self, val: $t) -> $t { + if can_transmute::<$t, atomic::AtomicUsize>() { + let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) }; + a.fetch_sub(val as usize, Ordering::AcqRel) as $t + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = value.wrapping_sub(val); + old + } + } + + /// Applies bitwise "and" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_and(3), 7); + /// assert_eq!(a.load(), 3); + /// ``` + #[inline] + pub fn fetch_and(&self, val: $t) -> $t { + if can_transmute::<$t, atomic::AtomicUsize>() { + let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) }; + a.fetch_and(val as usize, Ordering::AcqRel) as $t + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value &= val; + old + } + } + + /// Applies bitwise "or" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_or(16), 7); + /// assert_eq!(a.load(), 23); + /// ``` + #[inline] + pub fn fetch_or(&self, val: $t) -> $t { + if can_transmute::<$t, atomic::AtomicUsize>() { + let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) }; + a.fetch_or(val as usize, Ordering::AcqRel) as $t + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value |= val; + old + } + } + + /// Applies bitwise "xor" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_xor(2), 7); + /// assert_eq!(a.load(), 5); + /// ``` + #[inline] + pub fn fetch_xor(&self, val: $t) -> $t { + if can_transmute::<$t, atomic::AtomicUsize>() { + let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) }; + a.fetch_xor(val as usize, Ordering::AcqRel) as $t + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value ^= val; + old + } + } + } + }; + ($t:ty, $atomic:ty, $example:tt) => { + impl AtomicCell<$t> { + /// Increments the current value by `val` and returns the previous value. + /// + /// The addition wraps on overflow. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_add(3), 7); + /// assert_eq!(a.load(), 10); + /// ``` + #[inline] + pub fn fetch_add(&self, val: $t) -> $t { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_add(val, Ordering::AcqRel) + } + + /// Decrements the current value by `val` and returns the previous value. + /// + /// The subtraction wraps on overflow. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_sub(3), 7); + /// assert_eq!(a.load(), 4); + /// ``` + #[inline] + pub fn fetch_sub(&self, val: $t) -> $t { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_sub(val, Ordering::AcqRel) + } + + /// Applies bitwise "and" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_and(3), 7); + /// assert_eq!(a.load(), 3); + /// ``` + #[inline] + pub fn fetch_and(&self, val: $t) -> $t { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_and(val, Ordering::AcqRel) + } + + /// Applies bitwise "or" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_or(16), 7); + /// assert_eq!(a.load(), 23); + /// ``` + #[inline] + pub fn fetch_or(&self, val: $t) -> $t { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_or(val, Ordering::AcqRel) + } + + /// Applies bitwise "xor" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_xor(2), 7); + /// assert_eq!(a.load(), 5); + /// ``` + #[inline] + pub fn fetch_xor(&self, val: $t) -> $t { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_xor(val, Ordering::AcqRel) + } + } + }; + ($t:ty, $size:tt, $atomic:ty, $example:tt) => { + #[cfg(target_has_atomic = $size)] + impl_arithmetic!($t, $atomic, $example); + }; +} + +cfg_if! { + if #[cfg(feature = "nightly")] { + impl_arithmetic!(u8, "8", atomic::AtomicU8, "let a = AtomicCell::new(7u8);"); + impl_arithmetic!(i8, "8", atomic::AtomicI8, "let a = AtomicCell::new(7i8);"); + impl_arithmetic!(u16, "16", atomic::AtomicU16, "let a = AtomicCell::new(7u16);"); + impl_arithmetic!(i16, "16", atomic::AtomicI16, "let a = AtomicCell::new(7i16);"); + impl_arithmetic!(u32, "32", atomic::AtomicU32, "let a = AtomicCell::new(7u32);"); + impl_arithmetic!(i32, "32", atomic::AtomicI32, "let a = AtomicCell::new(7i32);"); + impl_arithmetic!(u64, "64", atomic::AtomicU64, "let a = AtomicCell::new(7u64);"); + impl_arithmetic!(i64, "64", atomic::AtomicI64, "let a = AtomicCell::new(7i64);"); + impl_arithmetic!(u128, "let a = AtomicCell::new(7u128);"); + impl_arithmetic!(i128, "let a = AtomicCell::new(7i128);"); + } else { + impl_arithmetic!(u8, "let a = AtomicCell::new(7u8);"); + impl_arithmetic!(i8, "let a = AtomicCell::new(7i8);"); + impl_arithmetic!(u16, "let a = AtomicCell::new(7u16);"); + impl_arithmetic!(i16, "let a = AtomicCell::new(7i16);"); + impl_arithmetic!(u32, "let a = AtomicCell::new(7u32);"); + impl_arithmetic!(i32, "let a = AtomicCell::new(7i32);"); + impl_arithmetic!(u64, "let a = AtomicCell::new(7u64);"); + impl_arithmetic!(i64, "let a = AtomicCell::new(7i64);"); + impl_arithmetic!(u128, "let a = AtomicCell::new(7u128);"); + impl_arithmetic!(i128, "let a = AtomicCell::new(7i128);"); + } +} + +impl_arithmetic!( + usize, + atomic::AtomicUsize, + "let a = AtomicCell::new(7usize);" +); +impl_arithmetic!( + isize, + atomic::AtomicIsize, + "let a = AtomicCell::new(7isize);" +); + +impl AtomicCell { + /// Applies logical "and" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(true); + /// + /// assert_eq!(a.fetch_and(true), true); + /// assert_eq!(a.load(), true); + /// + /// assert_eq!(a.fetch_and(false), true); + /// assert_eq!(a.load(), false); + /// ``` + #[inline] + pub fn fetch_and(&self, val: bool) -> bool { + let a = unsafe { &*(self.value.get() as *const AtomicBool) }; + a.fetch_and(val, Ordering::AcqRel) + } + + /// Applies logical "or" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(false); + /// + /// assert_eq!(a.fetch_or(false), false); + /// assert_eq!(a.load(), false); + /// + /// assert_eq!(a.fetch_or(true), false); + /// assert_eq!(a.load(), true); + /// ``` + #[inline] + pub fn fetch_or(&self, val: bool) -> bool { + let a = unsafe { &*(self.value.get() as *const AtomicBool) }; + a.fetch_or(val, Ordering::AcqRel) + } + + /// Applies logical "xor" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(true); + /// + /// assert_eq!(a.fetch_xor(false), true); + /// assert_eq!(a.load(), true); + /// + /// assert_eq!(a.fetch_xor(true), true); + /// assert_eq!(a.load(), false); + /// ``` + #[inline] + pub fn fetch_xor(&self, val: bool) -> bool { + let a = unsafe { &*(self.value.get() as *const AtomicBool) }; + a.fetch_xor(val, Ordering::AcqRel) + } +} + +impl Default for AtomicCell { + fn default() -> AtomicCell { + AtomicCell::new(T::default()) + } +} + +impl fmt::Debug for AtomicCell { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("AtomicCell") + .field("value", &self.load()) + .finish() + } +} + +/// Returns `true` if values of type `A` can be transmuted into values of type `B`. +fn can_transmute() -> bool { + // Sizes must be equal, but alignment of `A` must be greater or equal than that of `B`. + mem::size_of::
() == mem::size_of::() && mem::align_of::() >= mem::align_of::() +} + +/// A simple stamped lock. +struct Lock { + /// The current state of the lock. + /// + /// All bits except the least significant one hold the current stamp. When locked, the state + /// equals 1 and doesn't contain a valid stamp. + state: AtomicUsize, +} + +impl Lock { + /// If not locked, returns the current stamp. + /// + /// This method should be called before optimistic reads. + #[inline] + fn optimistic_read(&self) -> Option { + let state = self.state.load(Ordering::Acquire); + if state == 1 { + None + } else { + Some(state) + } + } + + /// Returns `true` if the current stamp is equal to `stamp`. + /// + /// This method should be called after optimistic reads to check whether they are valid. The + /// argument `stamp` should correspond to the one returned by method `optimistic_read`. + #[inline] + fn validate_read(&self, stamp: usize) -> bool { + atomic::fence(Ordering::Acquire); + self.state.load(Ordering::Relaxed) == stamp + } + + /// Grabs the lock for writing. + #[inline] + fn write(&'static self) -> WriteGuard { + let backoff = Backoff::new(); + loop { + let previous = self.state.swap(1, Ordering::Acquire); + + if previous != 1 { + atomic::fence(Ordering::Release); + + return WriteGuard { + lock: self, + state: previous, + }; + } + + backoff.snooze(); + } + } +} + +/// A RAII guard that releases the lock and increments the stamp when dropped. +struct WriteGuard { + /// The parent lock. + lock: &'static Lock, + + /// The stamp before locking. + state: usize, +} + +impl WriteGuard { + /// Releases the lock without incrementing the stamp. + #[inline] + fn abort(self) { + self.lock.state.store(self.state, Ordering::Release); + } +} + +impl Drop for WriteGuard { + #[inline] + fn drop(&mut self) { + // Release the lock and increment the stamp. + self.lock + .state + .store(self.state.wrapping_add(2), Ordering::Release); + } +} + +/// Returns a reference to the global lock associated with the `AtomicCell` at address `addr`. +/// +/// This function is used to protect atomic data which doesn't fit into any of the primitive atomic +/// types in `std::sync::atomic`. Operations on such atomics must therefore use a global lock. +/// +/// However, there is not only one global lock but an array of many locks, and one of them is +/// picked based on the given address. Having many locks reduces contention and improves +/// scalability. +#[inline] +#[must_use] +fn lock(addr: usize) -> &'static Lock { + // The number of locks is a prime number because we want to make sure `addr % LEN` gets + // dispersed across all locks. + // + // Note that addresses are always aligned to some power of 2, depending on type `T` in + // `AtomicCell`. If `LEN` was an even number, then `addr % LEN` would be an even number, + // too, which means only half of the locks would get utilized! + // + // It is also possible for addresses to accidentally get aligned to a number that is not a + // power of 2. Consider this example: + // + // ``` + // #[repr(C)] + // struct Foo { + // a: AtomicCell, + // b: u8, + // c: u8, + // } + // ``` + // + // Now, if we have a slice of type `&[Foo]`, it is possible that field `a` in all items gets + // stored at addresses that are multiples of 3. It'd be too bad if `LEN` was divisible by 3. + // In order to protect from such cases, we simply choose a large prime number for `LEN`. + const LEN: usize = 97; + + const L: Lock = Lock { + state: AtomicUsize::new(0), + }; + static LOCKS: [Lock; LEN] = [ + L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, + L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, + L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, + L, L, L, L, L, L, L, + ]; + + // If the modulus is a constant number, the compiler will use crazy math to transform this into + // a sequence of cheap arithmetic operations rather than using the slow modulo instruction. + &LOCKS[addr % LEN] +} + +/// An atomic `()`. +/// +/// All operations are noops. +struct AtomicUnit; + +impl AtomicUnit { + #[inline] + fn load(&self, _order: Ordering) {} + + #[inline] + fn store(&self, _val: (), _order: Ordering) {} + + #[inline] + fn swap(&self, _val: (), _order: Ordering) {} + + #[inline] + fn compare_exchange_weak( + &self, + _current: (), + _new: (), + _success: Ordering, + _failure: Ordering, + ) -> Result<(), ()> { + Ok(()) + } +} + +macro_rules! atomic { + // If values of type `$t` can be transmuted into values of the primitive atomic type `$atomic`, + // declares variable `$a` of type `$atomic` and executes `$atomic_op`, breaking out of the loop. + (@check, $t:ty, $atomic:ty, $a:ident, $atomic_op:expr) => { + if can_transmute::<$t, $atomic>() { + let $a: &$atomic; + break $atomic_op; + } + }; + + // If values of type `$t` can be transmuted into values of a primitive atomic type, declares + // variable `$a` of that type and executes `$atomic_op`. Otherwise, just executes + // `$fallback_op`. + ($t:ty, $a:ident, $atomic_op:expr, $fallback_op:expr) => { + loop { + atomic!(@check, $t, AtomicUnit, $a, $atomic_op); + atomic!(@check, $t, atomic::AtomicUsize, $a, $atomic_op); + + #[cfg(feature = "nightly")] + { + #[cfg(target_has_atomic = "8")] + atomic!(@check, $t, atomic::AtomicU8, $a, $atomic_op); + #[cfg(target_has_atomic = "16")] + atomic!(@check, $t, atomic::AtomicU16, $a, $atomic_op); + #[cfg(target_has_atomic = "32")] + atomic!(@check, $t, atomic::AtomicU32, $a, $atomic_op); + #[cfg(target_has_atomic = "64")] + atomic!(@check, $t, atomic::AtomicU64, $a, $atomic_op); + } + + break $fallback_op; + } + }; +} + +/// Returns `true` if operations on `AtomicCell` are lock-free. +fn atomic_is_lock_free() -> bool { + atomic! { T, _a, true, false } +} + +/// Atomically reads data from `src`. +/// +/// This operation uses the `Acquire` ordering. If possible, an atomic instructions is used, and a +/// global lock otherwise. +unsafe fn atomic_load(src: *mut T) -> T +where + T: Copy, +{ + atomic! { + T, a, + { + a = &*(src as *const _ as *const _); + mem::transmute_copy(&a.load(Ordering::Acquire)) + }, + { + let lock = lock(src as usize); + + // Try doing an optimistic read first. + if let Some(stamp) = lock.optimistic_read() { + // We need a volatile read here because other threads might concurrently modify the + // value. In theory, data races are *always* UB, even if we use volatile reads and + // discard the data when a data race is detected. The proper solution would be to + // do atomic reads and atomic writes, but we can't atomically read and write all + // kinds of data since `AtomicU8` is not available on stable Rust yet. + let val = ptr::read_volatile(src); + + if lock.validate_read(stamp) { + return val; + } + } + + // Grab a regular write lock so that writers don't starve this load. + let guard = lock.write(); + let val = ptr::read(src); + // The value hasn't been changed. Drop the guard without incrementing the stamp. + guard.abort(); + val + } + } +} + +/// Atomically writes `val` to `dst`. +/// +/// This operation uses the `Release` ordering. If possible, an atomic instructions is used, and a +/// global lock otherwise. +unsafe fn atomic_store(dst: *mut T, val: T) { + atomic! { + T, a, + { + a = &*(dst as *const _ as *const _); + a.store(mem::transmute_copy(&val), Ordering::Release); + mem::forget(val); + }, + { + let _guard = lock(dst as usize).write(); + ptr::write(dst, val); + } + } +} + +/// Atomically swaps data at `dst` with `val`. +/// +/// This operation uses the `AcqRel` ordering. If possible, an atomic instructions is used, and a +/// global lock otherwise. +unsafe fn atomic_swap(dst: *mut T, val: T) -> T { + atomic! { + T, a, + { + a = &*(dst as *const _ as *const _); + let res = mem::transmute_copy(&a.swap(mem::transmute_copy(&val), Ordering::AcqRel)); + mem::forget(val); + res + }, + { + let _guard = lock(dst as usize).write(); + ptr::replace(dst, val) + } + } +} + +/// Atomically compares data at `dst` to `current` and, if equal byte-for-byte, exchanges data at +/// `dst` with `new`. +/// +/// Returns the old value on success, or the current value at `dst` on failure. +/// +/// This operation uses the `AcqRel` ordering. If possible, an atomic instructions is used, and a +/// global lock otherwise. +unsafe fn atomic_compare_exchange_weak(dst: *mut T, mut current: T, new: T) -> Result +where + T: Copy + Eq, +{ + atomic! { + T, a, + { + a = &*(dst as *const _ as *const _); + let mut current_raw = mem::transmute_copy(¤t); + let new_raw = mem::transmute_copy(&new); + + loop { + match a.compare_exchange_weak( + current_raw, + new_raw, + Ordering::AcqRel, + Ordering::Acquire, + ) { + Ok(_) => break Ok(current), + Err(previous_raw) => { + let previous = mem::transmute_copy(&previous_raw); + + if !T::eq(&previous, ¤t) { + break Err(previous); + } + + // The compare-exchange operation has failed and didn't store `new`. The + // failure is either spurious, or `previous` was semantically equal to + // `current` but not byte-equal. Let's retry with `previous` as the new + // `current`. + current = previous; + current_raw = previous_raw; + } + } + } + }, + { + let guard = lock(dst as usize).write(); + + if T::eq(&*dst, ¤t) { + Ok(ptr::replace(dst, new)) + } else { + let val = ptr::read(dst); + // The value hasn't been changed. Drop the guard without incrementing the stamp. + guard.abort(); + Err(val) + } + } + } +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/atomic/consume.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/atomic/consume.rs new file mode 100644 index 0000000..9be5464 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/atomic/consume.rs @@ -0,0 +1,82 @@ +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +use core::sync::atomic::compiler_fence; +use core::sync::atomic::Ordering; + +/// Trait which allows reading from primitive atomic types with "consume" ordering. +pub trait AtomicConsume { + /// Type returned by `load_consume`. + type Val; + + /// Loads a value from the atomic using a "consume" memory ordering. + /// + /// This is similar to the "acquire" ordering, except that an ordering is + /// only guaranteed with operations that "depend on" the result of the load. + /// However consume loads are usually much faster than acquire loads on + /// architectures with a weak memory model since they don't require memory + /// fence instructions. + /// + /// The exact definition of "depend on" is a bit vague, but it works as you + /// would expect in practice since a lot of software, especially the Linux + /// kernel, rely on this behavior. + /// + /// This is currently only implemented on ARM and AArch64, where a fence + /// can be avoided. On other architectures this will fall back to a simple + /// `load(Ordering::Acquire)`. + fn load_consume(&self) -> Self::Val; +} + +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +macro_rules! impl_consume { + () => { + #[inline] + fn load_consume(&self) -> Self::Val { + let result = self.load(Ordering::Relaxed); + compiler_fence(Ordering::Acquire); + result + } + }; +} + +#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] +macro_rules! impl_consume { + () => { + #[inline] + fn load_consume(&self) -> Self::Val { + self.load(Ordering::Acquire) + } + }; +} + +macro_rules! impl_atomic { + ($atomic:ident, $val:ty) => { + impl AtomicConsume for ::core::sync::atomic::$atomic { + type Val = $val; + impl_consume!(); + } + }; +} + +impl_atomic!(AtomicBool, bool); +impl_atomic!(AtomicUsize, usize); +impl_atomic!(AtomicIsize, isize); +#[cfg(all(feature = "nightly", target_has_atomic = "8"))] +impl_atomic!(AtomicU8, u8); +#[cfg(all(feature = "nightly", target_has_atomic = "8"))] +impl_atomic!(AtomicI8, i8); +#[cfg(all(feature = "nightly", target_has_atomic = "16"))] +impl_atomic!(AtomicU16, u16); +#[cfg(all(feature = "nightly", target_has_atomic = "16"))] +impl_atomic!(AtomicI16, i16); +#[cfg(all(feature = "nightly", target_has_atomic = "32"))] +impl_atomic!(AtomicU32, u32); +#[cfg(all(feature = "nightly", target_has_atomic = "32"))] +impl_atomic!(AtomicI32, i32); +#[cfg(all(feature = "nightly", target_has_atomic = "64"))] +impl_atomic!(AtomicU64, u64); +#[cfg(all(feature = "nightly", target_has_atomic = "64"))] +impl_atomic!(AtomicI64, i64); + +impl AtomicConsume for ::core::sync::atomic::AtomicPtr { + type Val = *mut T; + impl_consume!(); +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/atomic/mod.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/atomic/mod.rs new file mode 100644 index 0000000..4205993 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/atomic/mod.rs @@ -0,0 +1,7 @@ +//! Atomic types. + +mod atomic_cell; +mod consume; + +pub use self::atomic_cell::AtomicCell; +pub use self::consume::AtomicConsume; diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/backoff.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/backoff.rs new file mode 100644 index 0000000..446755b --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/backoff.rs @@ -0,0 +1,292 @@ +use core::cell::Cell; +use core::fmt; +use core::sync::atomic; + +const SPIN_LIMIT: u32 = 6; +const YIELD_LIMIT: u32 = 10; + +/// Performs exponential backoff in spin loops. +/// +/// Backing off in spin loops reduces contention and improves overall performance. +/// +/// This primitive can execute *YIELD* and *PAUSE* instructions, yield the current thread to the OS +/// scheduler, and tell when is a good time to block the thread using a different synchronization +/// mechanism. Each step of the back off procedure takes roughly twice as long as the previous +/// step. +/// +/// # Examples +/// +/// Backing off in a lock-free loop: +/// +/// ``` +/// use crossbeam_utils::Backoff; +/// use std::sync::atomic::AtomicUsize; +/// use std::sync::atomic::Ordering::SeqCst; +/// +/// fn fetch_mul(a: &AtomicUsize, b: usize) -> usize { +/// let backoff = Backoff::new(); +/// loop { +/// let val = a.load(SeqCst); +/// if a.compare_and_swap(val, val.wrapping_mul(b), SeqCst) == val { +/// return val; +/// } +/// backoff.spin(); +/// } +/// } +/// ``` +/// +/// Waiting for an [`AtomicBool`] to become `true`: +/// +/// ``` +/// use crossbeam_utils::Backoff; +/// use std::sync::atomic::AtomicBool; +/// use std::sync::atomic::Ordering::SeqCst; +/// +/// fn spin_wait(ready: &AtomicBool) { +/// let backoff = Backoff::new(); +/// while !ready.load(SeqCst) { +/// backoff.snooze(); +/// } +/// } +/// ``` +/// +/// Waiting for an [`AtomicBool`] to become `true` and parking the thread after a long wait. +/// Note that whoever sets the atomic variable to `true` must notify the parked thread by calling +/// [`unpark()`]: +/// +/// ``` +/// use crossbeam_utils::Backoff; +/// use std::sync::atomic::AtomicBool; +/// use std::sync::atomic::Ordering::SeqCst; +/// use std::thread; +/// +/// fn blocking_wait(ready: &AtomicBool) { +/// let backoff = Backoff::new(); +/// while !ready.load(SeqCst) { +/// if backoff.is_completed() { +/// thread::park(); +/// } else { +/// backoff.snooze(); +/// } +/// } +/// } +/// ``` +/// +/// [`is_completed`]: struct.Backoff.html#method.is_completed +/// [`std::thread::park()`]: https://doc.rust-lang.org/std/thread/fn.park.html +/// [`Condvar`]: https://doc.rust-lang.org/std/sync/struct.Condvar.html +/// [`AtomicBool`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html +/// [`unpark()`]: https://doc.rust-lang.org/std/thread/struct.Thread.html#method.unpark +pub struct Backoff { + step: Cell, +} + +impl Backoff { + /// Creates a new `Backoff`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::Backoff; + /// + /// let backoff = Backoff::new(); + /// ``` + #[inline] + pub fn new() -> Self { + Backoff { step: Cell::new(0) } + } + + /// Resets the `Backoff`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::Backoff; + /// + /// let backoff = Backoff::new(); + /// backoff.reset(); + /// ``` + #[inline] + pub fn reset(&self) { + self.step.set(0); + } + + /// Backs off in a lock-free loop. + /// + /// This method should be used when we need to retry an operation because another thread made + /// progress. + /// + /// The processor may yield using the *YIELD* or *PAUSE* instruction. + /// + /// # Examples + /// + /// Backing off in a lock-free loop: + /// + /// ``` + /// use crossbeam_utils::Backoff; + /// use std::sync::atomic::AtomicUsize; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// fn fetch_mul(a: &AtomicUsize, b: usize) -> usize { + /// let backoff = Backoff::new(); + /// loop { + /// let val = a.load(SeqCst); + /// if a.compare_and_swap(val, val.wrapping_mul(b), SeqCst) == val { + /// return val; + /// } + /// backoff.spin(); + /// } + /// } + /// + /// let a = AtomicUsize::new(7); + /// assert_eq!(fetch_mul(&a, 8), 7); + /// assert_eq!(a.load(SeqCst), 56); + /// ``` + #[inline] + pub fn spin(&self) { + for _ in 0..1 << self.step.get().min(SPIN_LIMIT) { + atomic::spin_loop_hint(); + } + + if self.step.get() <= SPIN_LIMIT { + self.step.set(self.step.get() + 1); + } + } + + /// Backs off in a blocking loop. + /// + /// This method should be used when we need to wait for another thread to make progress. + /// + /// The processor may yield using the *YIELD* or *PAUSE* instruction and the current thread + /// may yield by giving up a timeslice to the OS scheduler. + /// + /// In `#[no_std]` environments, this method is equivalent to [`spin`]. + /// + /// If possible, use [`is_completed`] to check when it is advised to stop using backoff and + /// block the current thread using a different synchronization mechanism instead. + /// + /// [`spin`]: struct.Backoff.html#method.spin + /// [`is_completed`]: struct.Backoff.html#method.is_completed + /// + /// # Examples + /// + /// Waiting for an [`AtomicBool`] to become `true`: + /// + /// ``` + /// use crossbeam_utils::Backoff; + /// use std::sync::Arc; + /// use std::sync::atomic::AtomicBool; + /// use std::sync::atomic::Ordering::SeqCst; + /// use std::thread; + /// use std::time::Duration; + /// + /// fn spin_wait(ready: &AtomicBool) { + /// let backoff = Backoff::new(); + /// while !ready.load(SeqCst) { + /// backoff.snooze(); + /// } + /// } + /// + /// let ready = Arc::new(AtomicBool::new(false)); + /// let ready2 = ready.clone(); + /// + /// thread::spawn(move || { + /// thread::sleep(Duration::from_millis(100)); + /// ready2.store(true, SeqCst); + /// }); + /// + /// assert_eq!(ready.load(SeqCst), false); + /// spin_wait(&ready); + /// assert_eq!(ready.load(SeqCst), true); + /// ``` + /// + /// [`AtomicBool`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html + #[inline] + pub fn snooze(&self) { + if self.step.get() <= SPIN_LIMIT { + for _ in 0..1 << self.step.get() { + atomic::spin_loop_hint(); + } + } else { + #[cfg(not(feature = "std"))] + for _ in 0..1 << self.step.get() { + atomic::spin_loop_hint(); + } + + #[cfg(feature = "std")] + ::std::thread::yield_now(); + } + + if self.step.get() <= YIELD_LIMIT { + self.step.set(self.step.get() + 1); + } + } + + /// Returns `true` if exponential backoff has completed and blocking the thread is advised. + /// + /// # Examples + /// + /// Waiting for an [`AtomicBool`] to become `true` and parking the thread after a long wait: + /// + /// ``` + /// use crossbeam_utils::Backoff; + /// use std::sync::Arc; + /// use std::sync::atomic::AtomicBool; + /// use std::sync::atomic::Ordering::SeqCst; + /// use std::thread; + /// use std::time::Duration; + /// + /// fn blocking_wait(ready: &AtomicBool) { + /// let backoff = Backoff::new(); + /// while !ready.load(SeqCst) { + /// if backoff.is_completed() { + /// thread::park(); + /// } else { + /// backoff.snooze(); + /// } + /// } + /// } + /// + /// let ready = Arc::new(AtomicBool::new(false)); + /// let ready2 = ready.clone(); + /// let waiter = thread::current(); + /// + /// thread::spawn(move || { + /// thread::sleep(Duration::from_millis(100)); + /// ready2.store(true, SeqCst); + /// waiter.unpark(); + /// }); + /// + /// assert_eq!(ready.load(SeqCst), false); + /// blocking_wait(&ready); + /// assert_eq!(ready.load(SeqCst), true); + /// ``` + /// + /// [`AtomicBool`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html + #[inline] + pub fn is_completed(&self) -> bool { + self.step.get() > YIELD_LIMIT + } + + #[inline] + #[doc(hidden)] + #[deprecated(note = "use `is_completed` instead")] + pub fn is_complete(&self) -> bool { + self.is_completed() + } +} + +impl fmt::Debug for Backoff { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Backoff") + .field("step", &self.step) + .field("is_completed", &self.is_completed()) + .finish() + } +} + +impl Default for Backoff { + fn default() -> Backoff { + Backoff::new() + } +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/cache_padded.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/cache_padded.rs new file mode 100644 index 0000000..bb864a4 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/cache_padded.rs @@ -0,0 +1,131 @@ +use core::fmt; +use core::ops::{Deref, DerefMut}; + +/// Pads and aligns a value to the length of a cache line. +/// +/// In concurrent programming, sometimes it is desirable to make sure commonly accessed pieces of +/// data are not placed into the same cache line. Updating an atomic value invalides the whole +/// cache line it belongs to, which makes the next access to the same cache line slower for other +/// CPU cores. Use `CachePadded` to ensure updating one piece of data doesn't invalidate other +/// cached data. +/// +/// # Size and alignment +/// +/// Cache lines are assumed to be N bytes long, depending on the architecture: +/// +/// * On x86-64, N = 128. +/// * On all others, N = 64. +/// +/// Note that N is just a reasonable guess and is not guaranteed to match the actual cache line +/// length of the machine the program is running on. On modern Intel architectures, spatial +/// prefetcher is pulling pairs of 64-byte cache lines at a time, so we pessimistically assume that +/// cache lines are 128 bytes long. +/// +/// The size of `CachePadded` is the smallest multiple of N bytes large enough to accommodate +/// a value of type `T`. +/// +/// The alignment of `CachePadded` is the maximum of N bytes and the alignment of `T`. +/// +/// # Examples +/// +/// Alignment and padding: +/// +/// ``` +/// use crossbeam_utils::CachePadded; +/// +/// let array = [CachePadded::new(1i8), CachePadded::new(2i8)]; +/// let addr1 = &*array[0] as *const i8 as usize; +/// let addr2 = &*array[1] as *const i8 as usize; +/// +/// assert!(addr2 - addr1 >= 64); +/// assert_eq!(addr1 % 64, 0); +/// assert_eq!(addr2 % 64, 0); +/// ``` +/// +/// When building a concurrent queue with a head and a tail index, it is wise to place them in +/// different cache lines so that concurrent threads pushing and popping elements don't invalidate +/// each other's cache lines: +/// +/// ``` +/// use crossbeam_utils::CachePadded; +/// use std::sync::atomic::AtomicUsize; +/// +/// struct Queue { +/// head: CachePadded, +/// tail: CachePadded, +/// buffer: *mut T, +/// } +/// ``` +#[derive(Clone, Copy, Default, Hash, PartialEq, Eq)] +// Starting from Intel's Sandy Bridge, spatial prefetcher is now pulling pairs of 64-byte cache +// lines at a time, so we have to align to 128 bytes rather than 64. +// +// Sources: +// - https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf +// - https://github.com/facebook/folly/blob/1b5288e6eea6df074758f877c849b6e73bbb9fbb/folly/lang/Align.h#L107 +#[cfg_attr(target_arch = "x86_64", repr(align(128)))] +#[cfg_attr(not(target_arch = "x86_64"), repr(align(64)))] +pub struct CachePadded { + value: T, +} + +unsafe impl Send for CachePadded {} +unsafe impl Sync for CachePadded {} + +impl CachePadded { + /// Pads and aligns a value to the length of a cache line. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::CachePadded; + /// + /// let padded_value = CachePadded::new(1); + /// ``` + pub fn new(t: T) -> CachePadded { + CachePadded:: { value: t } + } + + /// Returns the inner value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::CachePadded; + /// + /// let padded_value = CachePadded::new(7); + /// let value = padded_value.into_inner(); + /// assert_eq!(value, 7); + /// ``` + pub fn into_inner(self) -> T { + self.value + } +} + +impl Deref for CachePadded { + type Target = T; + + fn deref(&self) -> &T { + &self.value + } +} + +impl DerefMut for CachePadded { + fn deref_mut(&mut self) -> &mut T { + &mut self.value + } +} + +impl fmt::Debug for CachePadded { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("CachePadded") + .field("value", &self.value) + .finish() + } +} + +impl From for CachePadded { + fn from(t: T) -> Self { + CachePadded::new(t) + } +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/lib.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/lib.rs new file mode 100644 index 0000000..4df2ac8 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/lib.rs @@ -0,0 +1,67 @@ +//! Miscellaneous tools for concurrent programming. +//! +//! ## Atomics +//! +//! * [`AtomicCell`], a thread-safe mutable memory location. +//! * [`AtomicConsume`], for reading from primitive atomic types with "consume" ordering. +//! +//! ## Thread synchronization +//! +//! * [`Parker`], a thread parking primitive. +//! * [`ShardedLock`], a sharded reader-writer lock with fast concurrent reads. +//! * [`WaitGroup`], for synchronizing the beginning or end of some computation. +//! +//! ## Utilities +//! +//! * [`Backoff`], for exponential backoff in spin loops. +//! * [`CachePadded`], for padding and aligning a value to the length of a cache line. +//! * [`scope`], for spawning threads that borrow local variables from the stack. +//! +//! [`AtomicCell`]: atomic/struct.AtomicCell.html +//! [`AtomicConsume`]: atomic/trait.AtomicConsume.html +//! [`Parker`]: sync/struct.Parker.html +//! [`ShardedLock`]: sync/struct.ShardedLock.html +//! [`WaitGroup`]: sync/struct.WaitGroup.html +//! [`Backoff`]: struct.Backoff.html +//! [`CachePadded`]: struct.CachePadded.html +//! [`scope`]: thread/fn.scope.html + +#![warn(missing_docs)] +#![warn(missing_debug_implementations)] +#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))] + +#[macro_use] +extern crate cfg_if; +#[cfg(feature = "std")] +extern crate core; + +cfg_if! { + if #[cfg(feature = "alloc")] { + extern crate alloc; + } else if #[cfg(feature = "std")] { + extern crate std as alloc; + } +} + +#[cfg_attr( + feature = "nightly", + cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr")) +)] +pub mod atomic; + +mod cache_padded; +pub use cache_padded::CachePadded; + +mod backoff; +pub use backoff::Backoff; + +cfg_if! { + if #[cfg(feature = "std")] { + #[macro_use] + extern crate lazy_static; + + pub mod sync; + pub mod thread; + } +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/mod.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/mod.rs new file mode 100644 index 0000000..31c8ffe --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/mod.rs @@ -0,0 +1,17 @@ +//! Thread synchronization primitives. +//! +//! * [`Parker`], a thread parking primitive. +//! * [`ShardedLock`], a sharded reader-writer lock with fast concurrent reads. +//! * [`WaitGroup`], for synchronizing the beginning or end of some computation. +//! +//! [`Parker`]: struct.Parker.html +//! [`ShardedLock`]: struct.ShardedLock.html +//! [`WaitGroup`]: struct.WaitGroup.html + +mod parker; +mod sharded_lock; +mod wait_group; + +pub use self::sharded_lock::{ShardedLock, ShardedLockReadGuard, ShardedLockWriteGuard}; +pub use self::parker::{Parker, Unparker}; +pub use self::wait_group::WaitGroup; diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/parker.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/parker.rs new file mode 100644 index 0000000..506db8e --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/parker.rs @@ -0,0 +1,311 @@ +use std::fmt; +use std::marker::PhantomData; +use std::sync::{Arc, Condvar, Mutex}; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::SeqCst; +use std::time::Duration; + +/// A thread parking primitive. +/// +/// Conceptually, each `Parker` has an associated token which is initially not present: +/// +/// * The [`park`] method blocks the current thread unless or until the token is available, at +/// which point it automatically consumes the token. It may also return *spuriously*, without +/// consuming the token. +/// +/// * The [`park_timeout`] method works the same as [`park`], but blocks for a specified maximum +/// time. +/// +/// * The [`unpark`] method atomically makes the token available if it wasn't already. Because the +/// token is initially absent, [`unpark`] followed by [`park`] will result in the second call +/// returning immediately. +/// +/// In other words, each `Parker` acts a bit like a spinlock that can be locked and unlocked using +/// [`park`] and [`unpark`]. +/// +/// # Examples +/// +/// ``` +/// use std::thread; +/// use std::time::Duration; +/// use crossbeam_utils::sync::Parker; +/// +/// let mut p = Parker::new(); +/// let u = p.unparker().clone(); +/// +/// // Make the token available. +/// u.unpark(); +/// // Wakes up immediately and consumes the token. +/// p.park(); +/// +/// thread::spawn(move || { +/// thread::sleep(Duration::from_millis(500)); +/// u.unpark(); +/// }); +/// +/// // Wakes up when `u.unpark()` provides the token, but may also wake up +/// // spuriously before that without consuming the token. +/// p.park(); +/// ``` +/// +/// [`park`]: struct.Parker.html#method.park +/// [`park_timeout`]: struct.Parker.html#method.park_timeout +/// [`unpark`]: struct.Unparker.html#method.unpark +pub struct Parker { + unparker: Unparker, + _marker: PhantomData<*const ()>, +} + +unsafe impl Send for Parker {} + +impl Parker { + /// Creates a new `Parker`. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::Parker; + /// + /// let p = Parker::new(); + /// ``` + /// + pub fn new() -> Parker { + Parker { + unparker: Unparker { + inner: Arc::new(Inner { + state: AtomicUsize::new(EMPTY), + lock: Mutex::new(()), + cvar: Condvar::new(), + }), + }, + _marker: PhantomData, + } + } + + /// Blocks the current thread until the token is made available. + /// + /// A call to `park` may wake up spuriously without consuming the token, and callers should be + /// prepared for this possibility. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::Parker; + /// + /// let mut p = Parker::new(); + /// let u = p.unparker().clone(); + /// + /// // Make the token available. + /// u.unpark(); + /// + /// // Wakes up immediately and consumes the token. + /// p.park(); + /// ``` + pub fn park(&self) { + self.unparker.inner.park(None); + } + + /// Blocks the current thread until the token is made available, but only for a limited time. + /// + /// A call to `park_timeout` may wake up spuriously without consuming the token, and callers + /// should be prepared for this possibility. + /// + /// # Examples + /// + /// ``` + /// use std::time::Duration; + /// use crossbeam_utils::sync::Parker; + /// + /// let mut p = Parker::new(); + /// + /// // Waits for the token to become available, but will not wait longer than 500 ms. + /// p.park_timeout(Duration::from_millis(500)); + /// ``` + pub fn park_timeout(&self, timeout: Duration) { + self.unparker.inner.park(Some(timeout)); + } + + /// Returns a reference to an associated [`Unparker`]. + /// + /// The returned [`Unparker`] doesn't have to be used by reference - it can also be cloned. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::Parker; + /// + /// let mut p = Parker::new(); + /// let u = p.unparker().clone(); + /// + /// // Make the token available. + /// u.unpark(); + /// // Wakes up immediately and consumes the token. + /// p.park(); + /// ``` + /// + /// [`park`]: struct.Parker.html#method.park + /// [`park_timeout`]: struct.Parker.html#method.park_timeout + /// + /// [`Unparker`]: struct.Unparker.html + pub fn unparker(&self) -> &Unparker { + &self.unparker + } +} + +impl fmt::Debug for Parker { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Parker { .. }") + } +} + +/// Unparks a thread parked by the associated [`Parker`]. +/// +/// [`Parker`]: struct.Parker.html +pub struct Unparker { + inner: Arc, +} + +unsafe impl Send for Unparker {} +unsafe impl Sync for Unparker {} + +impl Unparker { + /// Atomically makes the token available if it is not already. + /// + /// This method will wake up the thread blocked on [`park`] or [`park_timeout`], if there is + /// any. + /// + /// # Examples + /// + /// ``` + /// use std::thread; + /// use std::time::Duration; + /// use crossbeam_utils::sync::Parker; + /// + /// let mut p = Parker::new(); + /// let u = p.unparker().clone(); + /// + /// thread::spawn(move || { + /// thread::sleep(Duration::from_millis(500)); + /// u.unpark(); + /// }); + /// + /// // Wakes up when `u.unpark()` provides the token, but may also wake up + /// // spuriously before that without consuming the token. + /// p.park(); + /// ``` + /// + /// [`park`]: struct.Parker.html#method.park + /// [`park_timeout`]: struct.Parker.html#method.park_timeout + pub fn unpark(&self) { + self.inner.unpark() + } +} + +impl fmt::Debug for Unparker { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Unparker { .. }") + } +} + +impl Clone for Unparker { + fn clone(&self) -> Unparker { + Unparker { + inner: self.inner.clone(), + } + } +} + +const EMPTY: usize = 0; +const PARKED: usize = 1; +const NOTIFIED: usize = 2; + +struct Inner { + state: AtomicUsize, + lock: Mutex<()>, + cvar: Condvar, +} + +impl Inner { + fn park(&self, timeout: Option) { + // If we were previously notified then we consume this notification and return quickly. + if self.state.compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst).is_ok() { + return; + } + + // If the timeout is zero, then there is no need to actually block. + if let Some(ref dur) = timeout { + if *dur == Duration::from_millis(0) { + return; + } + } + + // Otherwise we need to coordinate going to sleep. + let mut m = self.lock.lock().unwrap(); + + match self.state.compare_exchange(EMPTY, PARKED, SeqCst, SeqCst) { + Ok(_) => {} + // Consume this notification to avoid spurious wakeups in the next park. + Err(NOTIFIED) => { + // We must read `state` here, even though we know it will be `NOTIFIED`. This is + // because `unpark` may have been called again since we read `NOTIFIED` in the + // `compare_exchange` above. We must perform an acquire operation that synchronizes + // with that `unpark` to observe any writes it made before the call to `unpark`. To + // do that we must read from the write it made to `state`. + let old = self.state.swap(EMPTY, SeqCst); + assert_eq!(old, NOTIFIED, "park state changed unexpectedly"); + return; + } + Err(n) => panic!("inconsistent park_timeout state: {}", n), + } + + match timeout { + None => { + loop { + // Block the current thread on the conditional variable. + m = self.cvar.wait(m).unwrap(); + + match self.state.compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst) { + Ok(_) => return, // got a notification + Err(_) => {} // spurious wakeup, go back to sleep + } + } + } + Some(timeout) => { + // Wait with a timeout, and if we spuriously wake up or otherwise wake up from a + // notification we just want to unconditionally set `state` back to `EMPTY`, either + // consuming a notification or un-flagging ourselves as parked. + let (_m, _result) = self.cvar.wait_timeout(m, timeout).unwrap(); + + match self.state.swap(EMPTY, SeqCst) { + NOTIFIED => {} // got a notification + PARKED => {} // no notification + n => panic!("inconsistent park_timeout state: {}", n), + } + } + } + } + + pub fn unpark(&self) { + // To ensure the unparked thread will observe any writes we made before this call, we must + // perform a release operation that `park` can synchronize with. To do that we must write + // `NOTIFIED` even if `state` is already `NOTIFIED`. That is why this must be a swap rather + // than a compare-and-swap that returns if it reads `NOTIFIED` on failure. + match self.state.swap(NOTIFIED, SeqCst) { + EMPTY => return, // no one was waiting + NOTIFIED => return, // already unparked + PARKED => {} // gotta go wake someone up + _ => panic!("inconsistent state in unpark"), + } + + // There is a period between when the parked thread sets `state` to `PARKED` (or last + // checked `state` in the case of a spurious wakeup) and when it actually waits on `cvar`. + // If we were to notify during this period it would be ignored and then when the parked + // thread went to sleep it would never wake up. Fortunately, it has `lock` locked at this + // stage so we can acquire `lock` to wait until it is ready to receive the notification. + // + // Releasing `lock` before the call to `notify_one` means that when the parked thread wakes + // it doesn't get woken only to have to wait for us to release `lock`. + drop(self.lock.lock().unwrap()); + self.cvar.notify_one(); + } +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/sharded_lock.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/sharded_lock.rs new file mode 100644 index 0000000..0fbb291 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/sharded_lock.rs @@ -0,0 +1,600 @@ +use std::cell::UnsafeCell; +use std::collections::HashMap; +use std::fmt; +use std::marker::PhantomData; +use std::mem; +use std::ops::{Deref, DerefMut}; +use std::panic::{RefUnwindSafe, UnwindSafe}; +use std::sync::{Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard}; +use std::sync::{LockResult, PoisonError, TryLockError, TryLockResult}; +use std::thread::{self, ThreadId}; + +use CachePadded; + +/// The number of shards per sharded lock. Must be a power of two. +const NUM_SHARDS: usize = 8; + +/// A shard containing a single reader-writer lock. +struct Shard { + /// The inner reader-writer lock. + lock: RwLock<()>, + + /// The write-guard keeping this shard locked. + /// + /// Write operations will lock each shard and store the guard here. These guards get dropped at + /// the same time the big guard is dropped. + write_guard: UnsafeCell>>, +} + +/// A sharded reader-writer lock. +/// +/// This lock is equivalent to [`RwLock`], except read operations are faster and write operations +/// are slower. +/// +/// A `ShardedLock` is internally made of a list of *shards*, each being a [`RwLock`] occupying a +/// single cache line. Read operations will pick one of the shards depending on the current thread +/// and lock it. Write operations need to lock all shards in succession. +/// +/// By splitting the lock into shards, concurrent read operations will in most cases choose +/// different shards and thus update different cache lines, which is good for scalability. However, +/// write operations need to do more work and are therefore slower than usual. +/// +/// The priority policy of the lock is dependent on the underlying operating system's +/// implementation, and this type does not guarantee that any particular policy will be used. +/// +/// # Poisoning +/// +/// A `ShardedLock`, like [`RwLock`], will become poisoned on a panic. Note that it may only be +/// poisoned if a panic occurs while a write operation is in progress. If a panic occurs in any +/// read operation, the lock will not be poisoned. +/// +/// # Examples +/// +/// ``` +/// use crossbeam_utils::sync::ShardedLock; +/// +/// let lock = ShardedLock::new(5); +/// +/// // Any number of read locks can be held at once. +/// { +/// let r1 = lock.read().unwrap(); +/// let r2 = lock.read().unwrap(); +/// assert_eq!(*r1, 5); +/// assert_eq!(*r2, 5); +/// } // Read locks are dropped at this point. +/// +/// // However, only one write lock may be held. +/// { +/// let mut w = lock.write().unwrap(); +/// *w += 1; +/// assert_eq!(*w, 6); +/// } // Write lock is dropped here. +/// ``` +/// +/// [`RwLock`]: https://doc.rust-lang.org/std/sync/struct.RwLock.html +pub struct ShardedLock { + /// A list of locks protecting the internal data. + shards: Box<[CachePadded]>, + + /// The internal data. + value: UnsafeCell, +} + +unsafe impl Send for ShardedLock {} +unsafe impl Sync for ShardedLock {} + +impl UnwindSafe for ShardedLock {} +impl RefUnwindSafe for ShardedLock {} + +impl ShardedLock { + /// Creates a new sharded reader-writer lock. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::ShardedLock; + /// + /// let lock = ShardedLock::new(5); + /// ``` + pub fn new(value: T) -> ShardedLock { + ShardedLock { + shards: (0..NUM_SHARDS) + .map(|_| CachePadded::new(Shard { + lock: RwLock::new(()), + write_guard: UnsafeCell::new(None), + })) + .collect::>() + .into_boxed_slice(), + value: UnsafeCell::new(value), + } + } + + /// Consumes this lock, returning the underlying data. + /// + /// This method will return an error if the lock is poisoned. A lock gets poisoned when a write + /// operation panics. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::ShardedLock; + /// + /// let lock = ShardedLock::new(String::new()); + /// { + /// let mut s = lock.write().unwrap(); + /// *s = "modified".to_owned(); + /// } + /// assert_eq!(lock.into_inner().unwrap(), "modified"); + /// ``` + pub fn into_inner(self) -> LockResult { + let is_poisoned = self.is_poisoned(); + let inner = self.value.into_inner(); + + if is_poisoned { + Err(PoisonError::new(inner)) + } else { + Ok(inner) + } + } +} + +impl ShardedLock { + /// Returns `true` if the lock is poisoned. + /// + /// If another thread can still access the lock, it may become poisoned at any time. A `false` + /// result should not be trusted without additional synchronization. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::ShardedLock; + /// use std::sync::Arc; + /// use std::thread; + /// + /// let lock = Arc::new(ShardedLock::new(0)); + /// let c_lock = lock.clone(); + /// + /// let _ = thread::spawn(move || { + /// let _lock = c_lock.write().unwrap(); + /// panic!(); // the lock gets poisoned + /// }).join(); + /// assert_eq!(lock.is_poisoned(), true); + /// ``` + pub fn is_poisoned(&self) -> bool { + self.shards[0].lock.is_poisoned() + } + + /// Returns a mutable reference to the underlying data. + /// + /// Since this call borrows the lock mutably, no actual locking needs to take place. + /// + /// This method will return an error if the lock is poisoned. A lock gets poisoned when a write + /// operation panics. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::ShardedLock; + /// + /// let mut lock = ShardedLock::new(0); + /// *lock.get_mut().unwrap() = 10; + /// assert_eq!(*lock.read().unwrap(), 10); + /// ``` + pub fn get_mut(&mut self) -> LockResult<&mut T> { + let is_poisoned = self.is_poisoned(); + let inner = unsafe { &mut *self.value.get() }; + + if is_poisoned { + Err(PoisonError::new(inner)) + } else { + Ok(inner) + } + } + + /// Attempts to acquire this lock with shared read access. + /// + /// If the access could not be granted at this time, an error is returned. Otherwise, a guard + /// is returned which will release the shared access when it is dropped. This method does not + /// provide any guarantees with respect to the ordering of whether contentious readers or + /// writers will acquire the lock first. + /// + /// This method will return an error if the lock is poisoned. A lock gets poisoned when a write + /// operation panics. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::ShardedLock; + /// + /// let lock = ShardedLock::new(1); + /// + /// match lock.try_read() { + /// Ok(n) => assert_eq!(*n, 1), + /// Err(_) => unreachable!(), + /// }; + /// ``` + pub fn try_read(&self) -> TryLockResult> { + // Take the current thread index and map it to a shard index. Thread indices will tend to + // distribute shards among threads equally, thus reducing contention due to read-locking. + let current_index = current_index().unwrap_or(0); + let shard_index = current_index & (self.shards.len() - 1); + + match self.shards[shard_index].lock.try_read() { + Ok(guard) => Ok(ShardedLockReadGuard { + lock: self, + _guard: guard, + _marker: PhantomData, + }), + Err(TryLockError::Poisoned(err)) => { + let guard = ShardedLockReadGuard { + lock: self, + _guard: err.into_inner(), + _marker: PhantomData, + }; + Err(TryLockError::Poisoned(PoisonError::new(guard))) + }, + Err(TryLockError::WouldBlock) => Err(TryLockError::WouldBlock), + } + } + + /// Locks with shared read access, blocking the current thread until it can be acquired. + /// + /// The calling thread will be blocked until there are no more writers which hold the lock. + /// There may be other readers currently inside the lock when this method returns. This method + /// does not provide any guarantees with respect to the ordering of whether contentious readers + /// or writers will acquire the lock first. + /// + /// Returns a guard which will release the shared access when dropped. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::ShardedLock; + /// use std::sync::Arc; + /// use std::thread; + /// + /// let lock = Arc::new(ShardedLock::new(1)); + /// let c_lock = lock.clone(); + /// + /// let n = lock.read().unwrap(); + /// assert_eq!(*n, 1); + /// + /// thread::spawn(move || { + /// let r = c_lock.read(); + /// assert!(r.is_ok()); + /// }).join().unwrap(); + /// ``` + pub fn read(&self) -> LockResult> { + // Take the current thread index and map it to a shard index. Thread indices will tend to + // distribute shards among threads equally, thus reducing contention due to read-locking. + let current_index = current_index().unwrap_or(0); + let shard_index = current_index & (self.shards.len() - 1); + + match self.shards[shard_index].lock.read() { + Ok(guard) => Ok(ShardedLockReadGuard { + lock: self, + _guard: guard, + _marker: PhantomData, + }), + Err(err) => Err(PoisonError::new(ShardedLockReadGuard { + lock: self, + _guard: err.into_inner(), + _marker: PhantomData, + })), + } + } + + /// Attempts to acquire this lock with exclusive write access. + /// + /// If the access could not be granted at this time, an error is returned. Otherwise, a guard + /// is returned which will release the exclusive access when it is dropped. This method does + /// not provide any guarantees with respect to the ordering of whether contentious readers or + /// writers will acquire the lock first. + /// + /// This method will return an error if the lock is poisoned. A lock gets poisoned when a write + /// operation panics. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::ShardedLock; + /// + /// let lock = ShardedLock::new(1); + /// + /// let n = lock.read().unwrap(); + /// assert_eq!(*n, 1); + /// + /// assert!(lock.try_write().is_err()); + /// ``` + pub fn try_write(&self) -> TryLockResult> { + let mut poisoned = false; + let mut blocked = None; + + // Write-lock each shard in succession. + for (i, shard) in self.shards.iter().enumerate() { + let guard = match shard.lock.try_write() { + Ok(guard) => guard, + Err(TryLockError::Poisoned(err)) => { + poisoned = true; + err.into_inner() + }, + Err(TryLockError::WouldBlock) => { + blocked = Some(i); + break; + } + }; + + // Store the guard into the shard. + unsafe { + let guard: RwLockWriteGuard<'static, ()> = mem::transmute(guard); + let dest: *mut _ = shard.write_guard.get(); + *dest = Some(guard); + } + } + + if let Some(i) = blocked { + // Unlock the shards in reverse order of locking. + for shard in self.shards[0..i].iter().rev() { + unsafe { + let dest: *mut _ = shard.write_guard.get(); + let guard = mem::replace(&mut *dest, None); + drop(guard); + } + } + Err(TryLockError::WouldBlock) + } else if poisoned { + let guard = ShardedLockWriteGuard { + lock: self, + _marker: PhantomData, + }; + Err(TryLockError::Poisoned(PoisonError::new(guard))) + } else { + Ok(ShardedLockWriteGuard { + lock: self, + _marker: PhantomData, + }) + } + } + + /// Locks with exclusive write access, blocking the current thread until it can be acquired. + /// + /// The calling thread will be blocked until there are no more writers which hold the lock. + /// There may be other readers currently inside the lock when this method returns. This method + /// does not provide any guarantees with respect to the ordering of whether contentious readers + /// or writers will acquire the lock first. + /// + /// Returns a guard which will release the exclusive access when dropped. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::ShardedLock; + /// + /// let lock = ShardedLock::new(1); + /// + /// let mut n = lock.write().unwrap(); + /// *n = 2; + /// + /// assert!(lock.try_read().is_err()); + /// ``` + pub fn write(&self) -> LockResult> { + let mut poisoned = false; + + // Write-lock each shard in succession. + for shard in self.shards.iter() { + let guard = match shard.lock.write() { + Ok(guard) => guard, + Err(err) => { + poisoned = true; + err.into_inner() + } + }; + + // Store the guard into the shard. + unsafe { + let guard: RwLockWriteGuard<'_, ()> = guard; + let guard: RwLockWriteGuard<'static, ()> = mem::transmute(guard); + let dest: *mut _ = shard.write_guard.get(); + *dest = Some(guard); + } + } + + if poisoned { + Err(PoisonError::new(ShardedLockWriteGuard { + lock: self, + _marker: PhantomData, + })) + } else { + Ok(ShardedLockWriteGuard { + lock: self, + _marker: PhantomData, + }) + } + } +} + +impl fmt::Debug for ShardedLock { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.try_read() { + Ok(guard) => f.debug_struct("ShardedLock").field("data", &&*guard).finish(), + Err(TryLockError::Poisoned(err)) => { + f.debug_struct("ShardedLock").field("data", &&**err.get_ref()).finish() + }, + Err(TryLockError::WouldBlock) => { + struct LockedPlaceholder; + impl fmt::Debug for LockedPlaceholder { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("") + } + } + f.debug_struct("ShardedLock").field("data", &LockedPlaceholder).finish() + } + } + } +} + +impl Default for ShardedLock { + fn default() -> ShardedLock { + ShardedLock::new(Default::default()) + } +} + +impl From for ShardedLock { + fn from(t: T) -> Self { + ShardedLock::new(t) + } +} + +/// A guard used to release the shared read access of a [`ShardedLock`] when dropped. +/// +/// [`ShardedLock`]: struct.ShardedLock.html +pub struct ShardedLockReadGuard<'a, T: ?Sized + 'a> { + lock: &'a ShardedLock, + _guard: RwLockReadGuard<'a, ()>, + _marker: PhantomData>, +} + +unsafe impl<'a, T: ?Sized + Sync> Sync for ShardedLockReadGuard<'a, T> {} + +impl<'a, T: ?Sized> Deref for ShardedLockReadGuard<'a, T> { + type Target = T; + + fn deref(&self) -> &T { + unsafe { &*self.lock.value.get() } + } +} + +impl<'a, T: fmt::Debug> fmt::Debug for ShardedLockReadGuard<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("ShardedLockReadGuard") + .field("lock", &self.lock) + .finish() + } +} + +impl<'a, T: ?Sized + fmt::Display> fmt::Display for ShardedLockReadGuard<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + (**self).fmt(f) + } +} + +/// A guard used to release the exclusive write access of a [`ShardedLock`] when dropped. +/// +/// [`ShardedLock`]: struct.ShardedLock.html +pub struct ShardedLockWriteGuard<'a, T: ?Sized + 'a> { + lock: &'a ShardedLock, + _marker: PhantomData>, +} + +unsafe impl<'a, T: ?Sized + Sync> Sync for ShardedLockWriteGuard<'a, T> {} + +impl<'a, T: ?Sized> Drop for ShardedLockWriteGuard<'a, T> { + fn drop(&mut self) { + // Unlock the shards in reverse order of locking. + for shard in self.lock.shards.iter().rev() { + unsafe { + let dest: *mut _ = shard.write_guard.get(); + let guard = mem::replace(&mut *dest, None); + drop(guard); + } + } + } +} + +impl<'a, T: fmt::Debug> fmt::Debug for ShardedLockWriteGuard<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("ShardedLockWriteGuard") + .field("lock", &self.lock) + .finish() + } +} + +impl<'a, T: ?Sized + fmt::Display> fmt::Display for ShardedLockWriteGuard<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + (**self).fmt(f) + } +} + +impl<'a, T: ?Sized> Deref for ShardedLockWriteGuard<'a, T> { + type Target = T; + + fn deref(&self) -> &T { + unsafe { &*self.lock.value.get() } + } +} + +impl<'a, T: ?Sized> DerefMut for ShardedLockWriteGuard<'a, T> { + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *self.lock.value.get() } + } +} + +/// Returns a `usize` that identifies the current thread. +/// +/// Each thread is associated with an 'index'. While there are no particular guarantees, indices +/// usually tend to be consecutive numbers between 0 and the number of running threads. +/// +/// Since this function accesses TLS, `None` might be returned if the current thread's TLS is +/// tearing down. +#[inline] +fn current_index() -> Option { + REGISTRATION.try_with(|reg| reg.index).ok() +} + +/// The global registry keeping track of registered threads and indices. +struct ThreadIndices { + /// Mapping from `ThreadId` to thread index. + mapping: HashMap, + + /// A list of free indices. + free_list: Vec, + + /// The next index to allocate if the free list is empty. + next_index: usize, +} + +lazy_static! { + static ref THREAD_INDICES: Mutex = Mutex::new(ThreadIndices { + mapping: HashMap::new(), + free_list: Vec::new(), + next_index: 0, + }); +} + +/// A registration of a thread with an index. +/// +/// When dropped, unregisters the thread and frees the reserved index. +struct Registration { + index: usize, + thread_id: ThreadId, +} + +impl Drop for Registration { + fn drop(&mut self) { + let mut indices = THREAD_INDICES.lock().unwrap(); + indices.mapping.remove(&self.thread_id); + indices.free_list.push(self.index); + } +} + +thread_local! { + static REGISTRATION: Registration = { + let thread_id = thread::current().id(); + let mut indices = THREAD_INDICES.lock().unwrap(); + + let index = match indices.free_list.pop() { + Some(i) => i, + None => { + let i = indices.next_index; + indices.next_index += 1; + i + } + }; + indices.mapping.insert(thread_id, index); + + Registration { + index, + thread_id, + } + }; +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/wait_group.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/wait_group.rs new file mode 100644 index 0000000..16ddc30 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/sync/wait_group.rs @@ -0,0 +1,139 @@ +use std::fmt; +use std::sync::{Arc, Condvar, Mutex}; + +/// Enables threads to synchronize the beginning or end of some computation. +/// +/// # Wait groups vs barriers +/// +/// `WaitGroup` is very similar to [`Barrier`], but there are a few differences: +/// +/// * `Barrier` needs to know the number of threads at construction, while `WaitGroup` is cloned to +/// register more threads. +/// +/// * A `Barrier` can be reused even after all threads have synchronized, while a `WaitGroup` +/// synchronizes threads only once. +/// +/// * All threads wait for others to reach the `Barrier`. With `WaitGroup`, each thread can choose +/// to either wait for other threads or to continue without blocking. +/// +/// # Examples +/// +/// ``` +/// use crossbeam_utils::sync::WaitGroup; +/// use std::thread; +/// +/// // Create a new wait group. +/// let wg = WaitGroup::new(); +/// +/// for _ in 0..4 { +/// // Create another reference to the wait group. +/// let wg = wg.clone(); +/// +/// thread::spawn(move || { +/// // Do some work. +/// +/// // Drop the reference to the wait group. +/// drop(wg); +/// }); +/// } +/// +/// // Block until all threads have finished their work. +/// wg.wait(); +/// ``` +/// +/// [`Barrier`]: https://doc.rust-lang.org/std/sync/struct.Barrier.html +pub struct WaitGroup { + inner: Arc, +} + +/// Inner state of a `WaitGroup`. +struct Inner { + cvar: Condvar, + count: Mutex, +} + +impl WaitGroup { + /// Creates a new wait group and returns the single reference to it. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::WaitGroup; + /// + /// let wg = WaitGroup::new(); + /// ``` + pub fn new() -> WaitGroup { + WaitGroup { + inner: Arc::new(Inner { + cvar: Condvar::new(), + count: Mutex::new(1), + }), + } + } + + /// Drops this reference and waits until all other references are dropped. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::sync::WaitGroup; + /// use std::thread; + /// + /// let wg = WaitGroup::new(); + /// + /// thread::spawn({ + /// let wg = wg.clone(); + /// move || { + /// // Block until both threads have reached `wait()`. + /// wg.wait(); + /// } + /// }); + /// + /// // Block until both threads have reached `wait()`. + /// wg.wait(); + /// ``` + pub fn wait(self) { + if *self.inner.count.lock().unwrap() == 1 { + return; + } + + let inner = self.inner.clone(); + drop(self); + + let mut count = inner.count.lock().unwrap(); + while *count > 0 { + count = inner.cvar.wait(count).unwrap(); + } + } +} + +impl Drop for WaitGroup { + fn drop(&mut self) { + let mut count = self.inner.count.lock().unwrap(); + *count -= 1; + + if *count == 0 { + self.inner.cvar.notify_all(); + } + } +} + +impl Clone for WaitGroup { + fn clone(&self) -> WaitGroup { + let mut count = self.inner.count.lock().unwrap(); + *count += 1; + + WaitGroup { + inner: self.inner.clone(), + } + } +} + +impl fmt::Debug for WaitGroup { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let count: &usize = &*self.inner.count.lock().unwrap(); + f.debug_struct("WaitGroup") + .field("count", count) + .finish() + } +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/thread.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/thread.rs new file mode 100644 index 0000000..2613fb7 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/src/thread.rs @@ -0,0 +1,529 @@ +//! Threads that can borrow variables from the stack. +//! +//! Create a scope when spawned threads need to access variables on the stack: +//! +//! ``` +//! use crossbeam_utils::thread; +//! +//! let people = vec![ +//! "Alice".to_string(), +//! "Bob".to_string(), +//! "Carol".to_string(), +//! ]; +//! +//! thread::scope(|s| { +//! for person in &people { +//! s.spawn(move |_| { +//! println!("Hello, {}!", person); +//! }); +//! } +//! }).unwrap(); +//! ``` +//! +//! # Why scoped threads? +//! +//! Suppose we wanted to re-write the previous example using plain threads: +//! +//! ```ignore +//! use std::thread; +//! +//! let people = vec![ +//! "Alice".to_string(), +//! "Bob".to_string(), +//! "Carol".to_string(), +//! ]; +//! +//! let mut threads = Vec::new(); +//! +//! for person in &people { +//! threads.push(thread::spawn(move |_| { +//! println!("Hello, {}!", person); +//! })); +//! } +//! +//! for thread in threads { +//! thread.join().unwrap(); +//! } +//! ``` +//! +//! This doesn't work because the borrow checker complains about `people` not living long enough: +//! +//! ```text +//! error[E0597]: `people` does not live long enough +//! --> src/main.rs:12:20 +//! | +//! 12 | for person in &people { +//! | ^^^^^^ borrowed value does not live long enough +//! ... +//! 21 | } +//! | - borrowed value only lives until here +//! | +//! = note: borrowed value must be valid for the static lifetime... +//! ``` +//! +//! The problem here is that spawned threads are not allowed to borrow variables on stack because +//! the compiler cannot prove they will be joined before `people` is destroyed. +//! +//! Scoped threads are a mechanism to guarantee to the compiler that spawned threads will be joined +//! before the scope ends. +//! +//! # How scoped threads work +//! +//! If a variable is borrowed by a thread, the thread must complete before the variable is +//! destroyed. Threads spawned using [`std::thread::spawn`] can only borrow variables with the +//! `'static` lifetime because the borrow checker cannot be sure when the thread will complete. +//! +//! A scope creates a clear boundary between variables outside the scope and threads inside the +//! scope. Whenever a scope spawns a thread, it promises to join the thread before the scope ends. +//! This way we guarantee to the borrow checker that scoped threads only live within the scope and +//! can safely access variables outside it. +//! +//! # Nesting scoped threads +//! +//! Sometimes scoped threads need to spawn more threads within the same scope. This is a little +//! tricky because argument `s` lives *inside* the invocation of `thread::scope()` and as such +//! cannot be borrowed by scoped threads: +//! +//! ```ignore +//! use crossbeam_utils::thread; +//! +//! thread::scope(|s| { +//! s.spawn(|_| { +//! // Not going to compile because we're trying to borrow `s`, +//! // which lives *inside* the scope! :( +//! s.spawn(|_| println!("nested thread")); +//! }); +//! }); +//! ``` +//! +//! Fortunately, there is a solution. Every scoped thread is passed a reference to its scope as an +//! argument, which can be used for spawning nested threads: +//! +//! ``` +//! use crossbeam_utils::thread; +//! +//! thread::scope(|s| { +//! // Note the `|s|` here. +//! s.spawn(|s| { +//! // Yay, this works because we're using a fresh argument `s`! :) +//! s.spawn(|_| println!("nested thread")); +//! }); +//! }); +//! ``` +//! +//! [`std::thread::spawn`]: https://doc.rust-lang.org/std/thread/fn.spawn.html + +use std::fmt; +use std::io; +use std::marker::PhantomData; +use std::mem; +use std::panic; +use std::sync::{Arc, Mutex}; +use std::thread; + +use sync::WaitGroup; + +type SharedVec = Arc>>; +type SharedOption = Arc>>; + +/// Creates a new scope for spawning threads. +/// +/// All child threads that haven't been manually joined will be automatically joined just before +/// this function invocation ends. If all joined threads have successfully completed, `Ok` is +/// returned with the return value of `f`. If any of the joined threads has panicked, an `Err` is +/// returned containing errors from panicked threads. +/// +/// # Examples +/// +/// ``` +/// use crossbeam_utils::thread; +/// +/// let var = vec![1, 2, 3]; +/// +/// thread::scope(|s| { +/// s.spawn(|_| { +/// println!("A child thread borrowing `var`: {:?}", var); +/// }); +/// }).unwrap(); +/// ``` +pub fn scope<'env, F, R>(f: F) -> thread::Result +where + F: FnOnce(&Scope<'env>) -> R, +{ + let wg = WaitGroup::new(); + let scope = Scope::<'env> { + handles: SharedVec::default(), + wait_group: wg.clone(), + _marker: PhantomData, + }; + + // Execute the scoped function, but catch any panics. + let result = panic::catch_unwind(panic::AssertUnwindSafe(|| f(&scope))); + + // Wait until all nested scopes are dropped. + drop(scope.wait_group); + wg.wait(); + + // Join all remaining spawned threads. + let panics: Vec<_> = { + let mut handles = scope.handles.lock().unwrap(); + + // Filter handles that haven't been joined, join them, and collect errors. + let panics = handles + .drain(..) + .filter_map(|handle| handle.lock().unwrap().take()) + .filter_map(|handle| handle.join().err()) + .collect(); + + panics + }; + + // If `f` has panicked, resume unwinding. + // If any of the child threads have panicked, return the panic errors. + // Otherwise, everything is OK and return the result of `f`. + match result { + Err(err) => panic::resume_unwind(err), + Ok(res) => { + if panics.is_empty() { + Ok(res) + } else { + Err(Box::new(panics)) + } + } + } +} + +/// A scope for spawning threads. +pub struct Scope<'env> { + /// The list of the thread join handles. + handles: SharedVec>>, + + /// Used to wait until all subscopes all dropped. + wait_group: WaitGroup, + + /// Borrows data with invariant lifetime `'env`. + _marker: PhantomData<&'env mut &'env ()>, +} + +unsafe impl<'env> Sync for Scope<'env> {} + +impl<'env> Scope<'env> { + /// Spawns a scoped thread. + /// + /// This method is similar to the [`spawn`] function in Rust's standard library. The difference + /// is that this thread is scoped, meaning it's guaranteed to terminate before the scope exits, + /// allowing it to reference variables outside the scope. + /// + /// The scoped thread is passed a reference to this scope as an argument, which can be used for + /// spawning nested threads. + /// + /// The returned handle can be used to manually join the thread before the scope exits. + /// + /// [`spawn`]: https://doc.rust-lang.org/std/thread/fn.spawn.html + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::thread; + /// + /// thread::scope(|s| { + /// let handle = s.spawn(|_| { + /// println!("A child thread is running"); + /// 42 + /// }); + /// + /// // Join the thread and retrieve its result. + /// let res = handle.join().unwrap(); + /// assert_eq!(res, 42); + /// }).unwrap(); + /// ``` + pub fn spawn<'scope, F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T> + where + F: FnOnce(&Scope<'env>) -> T, + F: Send + 'env, + T: Send + 'env, + { + self.builder().spawn(f).unwrap() + } + + /// Creates a builder that can configure a thread before spawning. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::thread; + /// use std::thread::current; + /// + /// thread::scope(|s| { + /// s.builder() + /// .spawn(|_| println!("A child thread is running")) + /// .unwrap(); + /// }).unwrap(); + /// ``` + pub fn builder<'scope>(&'scope self) -> ScopedThreadBuilder<'scope, 'env> { + ScopedThreadBuilder { + scope: self, + builder: thread::Builder::new(), + } + } +} + +impl<'env> fmt::Debug for Scope<'env> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Scope { .. }") + } +} + +/// Configures the properties of a new thread. +/// +/// The two configurable properties are: +/// +/// - [`name`]: Specifies an [associated name for the thread][naming-threads]. +/// - [`stack_size`]: Specifies the [desired stack size for the thread][stack-size]. +/// +/// The [`spawn`] method will take ownership of the builder and return an [`io::Result`] of the +/// thread handle with the given configuration. +/// +/// The [`Scope::spawn`] method uses a builder with default configuration and unwraps its return +/// value. You may want to use this builder when you want to recover from a failure to launch a +/// thread. +/// +/// # Examples +/// +/// ``` +/// use crossbeam_utils::thread; +/// +/// thread::scope(|s| { +/// s.builder() +/// .spawn(|_| println!("Running a child thread")) +/// .unwrap(); +/// }).unwrap(); +/// ``` +/// +/// [`name`]: struct.ScopedThreadBuilder.html#method.name +/// [`stack_size`]: struct.ScopedThreadBuilder.html#method.stack_size +/// [`spawn`]: struct.ScopedThreadBuilder.html#method.spawn +/// [`Scope::spawn`]: struct.Scope.html#method.spawn +/// [`io::Result`]: https://doc.rust-lang.org/std/io/type.Result.html +/// [naming-threads]: https://doc.rust-lang.org/std/thread/index.html#naming-threads +/// [stack-size]: https://doc.rust-lang.org/std/thread/index.html#stack-size +#[derive(Debug)] +pub struct ScopedThreadBuilder<'scope, 'env: 'scope> { + scope: &'scope Scope<'env>, + builder: thread::Builder, +} + +impl<'scope, 'env> ScopedThreadBuilder<'scope, 'env> { + /// Sets the name for the new thread. + /// + /// The name must not contain null bytes. For more information about named threads, see + /// [here][naming-threads]. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::thread; + /// use std::thread::current; + /// + /// thread::scope(|s| { + /// s.builder() + /// .name("my thread".to_string()) + /// .spawn(|_| assert_eq!(current().name(), Some("my thread"))) + /// .unwrap(); + /// }).unwrap(); + /// ``` + /// + /// [naming-threads]: https://doc.rust-lang.org/std/thread/index.html#naming-threads + pub fn name(mut self, name: String) -> ScopedThreadBuilder<'scope, 'env> { + self.builder = self.builder.name(name); + self + } + + /// Sets the size of the stack for the new thread. + /// + /// The stack size is measured in bytes. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::thread; + /// + /// thread::scope(|s| { + /// s.builder() + /// .stack_size(32 * 1024) + /// .spawn(|_| println!("Running a child thread")) + /// .unwrap(); + /// }).unwrap(); + /// ``` + pub fn stack_size(mut self, size: usize) -> ScopedThreadBuilder<'scope, 'env> { + self.builder = self.builder.stack_size(size); + self + } + + /// Spawns a scoped thread with this configuration. + /// + /// The scoped thread is passed a reference to this scope as an argument, which can be used for + /// spawning nested threads. + /// + /// The returned handle can be used to manually join the thread before the scope exits. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::thread; + /// + /// thread::scope(|s| { + /// let handle = s.builder() + /// .spawn(|_| { + /// println!("A child thread is running"); + /// 42 + /// }) + /// .unwrap(); + /// + /// // Join the thread and retrieve its result. + /// let res = handle.join().unwrap(); + /// assert_eq!(res, 42); + /// }).unwrap(); + /// ``` + pub fn spawn(self, f: F) -> io::Result> + where + F: FnOnce(&Scope<'env>) -> T, + F: Send + 'env, + T: Send + 'env, + { + // The result of `f` will be stored here. + let result = SharedOption::default(); + + // Spawn the thread and grab its join handle and thread handle. + let (handle, thread) = { + let result = Arc::clone(&result); + + // A clone of the scope that will be moved into the new thread. + let scope = Scope::<'env> { + handles: Arc::clone(&self.scope.handles), + wait_group: self.scope.wait_group.clone(), + _marker: PhantomData, + }; + + // Spawn the thread. + let handle = { + let closure = move || { + // Make sure the scope is inside the closure with the proper `'env` lifetime. + let scope: Scope<'env> = scope; + + // Run the closure. + let res = f(&scope); + + // Store the result if the closure didn't panic. + *result.lock().unwrap() = Some(res); + }; + + // Change the type of `closure` from `FnOnce() -> T` to `FnMut() -> T`. + let mut closure = Some(closure); + let closure = move || closure.take().unwrap()(); + + // Allocate `clsoure` on the heap and erase the `'env` bound. + let closure: Box = Box::new(closure); + let closure: Box = unsafe { mem::transmute(closure) }; + + // Finally, spawn the closure. + let mut closure = closure; + self.builder.spawn(move || closure())? + }; + + let thread = handle.thread().clone(); + let handle = Arc::new(Mutex::new(Some(handle))); + (handle, thread) + }; + + // Add the handle to the shared list of join handles. + self.scope.handles.lock().unwrap().push(Arc::clone(&handle)); + + Ok(ScopedJoinHandle { + handle, + result, + thread, + _marker: PhantomData, + }) + } +} + +unsafe impl<'scope, T> Send for ScopedJoinHandle<'scope, T> {} +unsafe impl<'scope, T> Sync for ScopedJoinHandle<'scope, T> {} + +/// A handle that can be used to join its scoped thread. +pub struct ScopedJoinHandle<'scope, T> { + /// A join handle to the spawned thread. + handle: SharedOption>, + + /// Holds the result of the inner closure. + result: SharedOption, + + /// A handle to the the spawned thread. + thread: thread::Thread, + + /// Borrows the parent scope with lifetime `'scope`. + _marker: PhantomData<&'scope ()>, +} + +impl<'scope, T> ScopedJoinHandle<'scope, T> { + /// Waits for the thread to finish and returns its result. + /// + /// If the child thread panics, an error is returned. + /// + /// # Panics + /// + /// This function may panic on some platforms if a thread attempts to join itself or otherwise + /// may create a deadlock with joining threads. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::thread; + /// + /// thread::scope(|s| { + /// let handle1 = s.spawn(|_| println!("I'm a happy thread :)")); + /// let handle2 = s.spawn(|_| panic!("I'm a sad thread :(")); + /// + /// // Join the first thread and verify that it succeeded. + /// let res = handle1.join(); + /// assert!(res.is_ok()); + /// + /// // Join the second thread and verify that it panicked. + /// let res = handle2.join(); + /// assert!(res.is_err()); + /// }).unwrap(); + /// ``` + pub fn join(self) -> thread::Result { + // Take out the handle. The handle will surely be available because the root scope waits + // for nested scopes before joining remaining threads. + let handle = self.handle.lock().unwrap().take().unwrap(); + + // Join the thread and then take the result out of its inner closure. + handle + .join() + .map(|()| self.result.lock().unwrap().take().unwrap()) + } + + /// Returns a handle to the underlying thread. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::thread; + /// + /// thread::scope(|s| { + /// let handle = s.spawn(|_| println!("A child thread is running")); + /// println!("The child thread ID: {:?}", handle.thread().id()); + /// }).unwrap(); + /// ``` + pub fn thread(&self) -> &thread::Thread { + &self.thread + } +} + +impl<'scope, T> fmt::Debug for ScopedJoinHandle<'scope, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("ScopedJoinHandle { .. }") + } +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/atomic_cell.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/atomic_cell.rs new file mode 100644 index 0000000..9406192 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/atomic_cell.rs @@ -0,0 +1,225 @@ +extern crate crossbeam_utils; + +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::SeqCst; + +use crossbeam_utils::atomic::AtomicCell; + +#[test] +fn is_lock_free() { + struct UsizeWrap(usize); + struct U8Wrap(bool); + + assert_eq!(AtomicCell::::is_lock_free(), true); + assert_eq!(AtomicCell::::is_lock_free(), true); + assert_eq!(AtomicCell::::is_lock_free(), true); + + assert_eq!(AtomicCell::::is_lock_free(), cfg!(feature = "nightly")); + assert_eq!( + AtomicCell::::is_lock_free(), + cfg!(feature = "nightly") + ); + assert_eq!( + AtomicCell::::is_lock_free(), + cfg!(feature = "nightly") + ); +} + +#[test] +fn drops_unit() { + static CNT: AtomicUsize = AtomicUsize::new(0); + CNT.store(0, SeqCst); + + #[derive(Debug, PartialEq, Eq)] + struct Foo(); + + impl Foo { + fn new() -> Foo { + CNT.fetch_add(1, SeqCst); + Foo() + } + } + + impl Drop for Foo { + fn drop(&mut self) { + CNT.fetch_sub(1, SeqCst); + } + } + + impl Default for Foo { + fn default() -> Foo { + Foo::new() + } + } + + let a = AtomicCell::new(Foo::new()); + + assert_eq!(a.swap(Foo::new()), Foo::new()); + assert_eq!(CNT.load(SeqCst), 1); + + a.store(Foo::new()); + assert_eq!(CNT.load(SeqCst), 1); + + assert_eq!(a.swap(Foo::default()), Foo::new()); + assert_eq!(CNT.load(SeqCst), 1); + + drop(a); + assert_eq!(CNT.load(SeqCst), 0); +} + +#[test] +fn drops_u8() { + static CNT: AtomicUsize = AtomicUsize::new(0); + CNT.store(0, SeqCst); + + #[derive(Debug, PartialEq, Eq)] + struct Foo(u8); + + impl Foo { + fn new(val: u8) -> Foo { + CNT.fetch_add(1, SeqCst); + Foo(val) + } + } + + impl Drop for Foo { + fn drop(&mut self) { + CNT.fetch_sub(1, SeqCst); + } + } + + impl Default for Foo { + fn default() -> Foo { + Foo::new(0) + } + } + + let a = AtomicCell::new(Foo::new(5)); + + assert_eq!(a.swap(Foo::new(6)), Foo::new(5)); + assert_eq!(a.swap(Foo::new(1)), Foo::new(6)); + assert_eq!(CNT.load(SeqCst), 1); + + a.store(Foo::new(2)); + assert_eq!(CNT.load(SeqCst), 1); + + assert_eq!(a.swap(Foo::default()), Foo::new(2)); + assert_eq!(CNT.load(SeqCst), 1); + + assert_eq!(a.swap(Foo::default()), Foo::new(0)); + assert_eq!(CNT.load(SeqCst), 1); + + drop(a); + assert_eq!(CNT.load(SeqCst), 0); +} + +#[test] +fn drops_usize() { + static CNT: AtomicUsize = AtomicUsize::new(0); + CNT.store(0, SeqCst); + + #[derive(Debug, PartialEq, Eq)] + struct Foo(usize); + + impl Foo { + fn new(val: usize) -> Foo { + CNT.fetch_add(1, SeqCst); + Foo(val) + } + } + + impl Drop for Foo { + fn drop(&mut self) { + CNT.fetch_sub(1, SeqCst); + } + } + + impl Default for Foo { + fn default() -> Foo { + Foo::new(0) + } + } + + let a = AtomicCell::new(Foo::new(5)); + + assert_eq!(a.swap(Foo::new(6)), Foo::new(5)); + assert_eq!(a.swap(Foo::new(1)), Foo::new(6)); + assert_eq!(CNT.load(SeqCst), 1); + + a.store(Foo::new(2)); + assert_eq!(CNT.load(SeqCst), 1); + + assert_eq!(a.swap(Foo::default()), Foo::new(2)); + assert_eq!(CNT.load(SeqCst), 1); + + assert_eq!(a.swap(Foo::default()), Foo::new(0)); + assert_eq!(CNT.load(SeqCst), 1); + + drop(a); + assert_eq!(CNT.load(SeqCst), 0); +} + +#[test] +fn modular_u8() { + #[derive(Clone, Copy, Eq, Debug, Default)] + struct Foo(u8); + + impl PartialEq for Foo { + fn eq(&self, other: &Foo) -> bool { + self.0 % 5 == other.0 % 5 + } + } + + let a = AtomicCell::new(Foo(1)); + + assert_eq!(a.load(), Foo(1)); + assert_eq!(a.swap(Foo(2)), Foo(11)); + assert_eq!(a.load(), Foo(52)); + + a.store(Foo(0)); + assert_eq!(a.compare_exchange(Foo(0), Foo(5)), Ok(Foo(100))); + assert_eq!(a.load().0, 5); + assert_eq!(a.compare_exchange(Foo(10), Foo(15)), Ok(Foo(100))); + assert_eq!(a.load().0, 15); +} + +#[test] +fn modular_usize() { + #[derive(Clone, Copy, Eq, Debug, Default)] + struct Foo(usize); + + impl PartialEq for Foo { + fn eq(&self, other: &Foo) -> bool { + self.0 % 5 == other.0 % 5 + } + } + + let a = AtomicCell::new(Foo(1)); + + assert_eq!(a.load(), Foo(1)); + assert_eq!(a.swap(Foo(2)), Foo(11)); + assert_eq!(a.load(), Foo(52)); + + a.store(Foo(0)); + assert_eq!(a.compare_exchange(Foo(0), Foo(5)), Ok(Foo(100))); + assert_eq!(a.load().0, 5); + assert_eq!(a.compare_exchange(Foo(10), Foo(15)), Ok(Foo(100))); + assert_eq!(a.load().0, 15); +} + +#[test] +fn garbage_padding() { + #[derive(Copy, Clone, Eq, PartialEq)] + struct Object { + a: i64, + b: i32, + } + + let cell = AtomicCell::new(Object { a: 0, b: 0 }); + let _garbage = [0xfe, 0xfe, 0xfe, 0xfe, 0xfe]; // Needed + let next = Object { a: 0, b: 0 }; + + let prev = cell.load(); + assert!(cell.compare_exchange(prev, next).is_ok()); + println!(); +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/cache_padded.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/cache_padded.rs new file mode 100644 index 0000000..8ad7d40 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/cache_padded.rs @@ -0,0 +1,112 @@ +extern crate crossbeam_utils; + +use std::cell::Cell; +use std::mem; + +use crossbeam_utils::CachePadded; + +#[test] +fn default() { + let x: CachePadded = Default::default(); + assert_eq!(*x, 0); +} + +#[test] +fn store_u64() { + let x: CachePadded = CachePadded::new(17); + assert_eq!(*x, 17); +} + +#[test] +fn store_pair() { + let x: CachePadded<(u64, u64)> = CachePadded::new((17, 37)); + assert_eq!(x.0, 17); + assert_eq!(x.1, 37); +} + +#[test] +fn distance() { + let arr = [CachePadded::new(17u8), CachePadded::new(37u8)]; + let a = &*arr[0] as *const u8; + let b = &*arr[1] as *const u8; + assert!(unsafe { a.offset(64) } <= b); +} + +#[test] +fn different_sizes() { + CachePadded::new(17u8); + CachePadded::new(17u16); + CachePadded::new(17u32); + CachePadded::new([17u64; 0]); + CachePadded::new([17u64; 1]); + CachePadded::new([17u64; 2]); + CachePadded::new([17u64; 3]); + CachePadded::new([17u64; 4]); + CachePadded::new([17u64; 5]); + CachePadded::new([17u64; 6]); + CachePadded::new([17u64; 7]); + CachePadded::new([17u64; 8]); +} + +#[test] +fn large() { + let a = [17u64; 9]; + let b = CachePadded::new(a); + assert!(mem::size_of_val(&a) <= mem::size_of_val(&b)); +} + +#[test] +fn debug() { + assert_eq!( + format!("{:?}", CachePadded::new(17u64)), + "CachePadded { value: 17 }" + ); +} + +#[test] +fn drops() { + let count = Cell::new(0); + + struct Foo<'a>(&'a Cell); + + impl<'a> Drop for Foo<'a> { + fn drop(&mut self) { + self.0.set(self.0.get() + 1); + } + } + + let a = CachePadded::new(Foo(&count)); + let b = CachePadded::new(Foo(&count)); + + assert_eq!(count.get(), 0); + drop(a); + assert_eq!(count.get(), 1); + drop(b); + assert_eq!(count.get(), 2); +} + +#[test] +fn clone() { + let a = CachePadded::new(17); + let b = a.clone(); + assert_eq!(*a, *b); +} + +#[test] +fn runs_custom_clone() { + let count = Cell::new(0); + + struct Foo<'a>(&'a Cell); + + impl<'a> Clone for Foo<'a> { + fn clone(&self) -> Foo<'a> { + self.0.set(self.0.get() + 1); + Foo::<'a>(self.0) + } + } + + let a = CachePadded::new(Foo(&count)); + let _ = a.clone(); + + assert_eq!(count.get(), 1); +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/parker.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/parker.rs new file mode 100644 index 0000000..3f45146 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/parker.rs @@ -0,0 +1,43 @@ +extern crate crossbeam_utils; + +use std::thread::sleep; +use std::time::Duration; +use std::u32; + +use crossbeam_utils::sync::Parker; +use crossbeam_utils::thread; + +#[test] +fn park_timeout_unpark_before() { + let p = Parker::new(); + for _ in 0..10 { + p.unparker().unpark(); + p.park_timeout(Duration::from_millis(u32::MAX as u64)); + } +} + +#[test] +fn park_timeout_unpark_not_called() { + let p = Parker::new(); + for _ in 0..10 { + p.park_timeout(Duration::from_millis(10)); + } +} + +#[test] +fn park_timeout_unpark_called_other_thread() { + for _ in 0..10 { + let p = Parker::new(); + let u = p.unparker().clone(); + + thread::scope(|scope| { + scope.spawn(move |_| { + sleep(Duration::from_millis(50)); + u.unpark(); + }); + + p.park_timeout(Duration::from_millis(u32::MAX as u64)); + }) + .unwrap(); + } +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/sharded_lock.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/sharded_lock.rs new file mode 100644 index 0000000..c98de79 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/sharded_lock.rs @@ -0,0 +1,255 @@ +extern crate crossbeam_utils; +extern crate rand; + +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::mpsc::channel; +use std::sync::{Arc, TryLockError}; +use std::thread; + +use crossbeam_utils::sync::ShardedLock; +use rand::Rng; + +#[derive(Eq, PartialEq, Debug)] +struct NonCopy(i32); + +#[test] +fn smoke() { + let l = ShardedLock::new(()); + drop(l.read().unwrap()); + drop(l.write().unwrap()); + drop((l.read().unwrap(), l.read().unwrap())); + drop(l.write().unwrap()); +} + +#[test] +fn frob() { + const N: u32 = 10; + const M: usize = 1000; + + let r = Arc::new(ShardedLock::new(())); + + let (tx, rx) = channel::<()>(); + for _ in 0..N { + let tx = tx.clone(); + let r = r.clone(); + thread::spawn(move || { + let mut rng = rand::thread_rng(); + for _ in 0..M { + if rng.gen_bool(1.0 / (N as f64)) { + drop(r.write().unwrap()); + } else { + drop(r.read().unwrap()); + } + } + drop(tx); + }); + } + drop(tx); + let _ = rx.recv(); +} + +#[test] +fn arc_poison_wr() { + let arc = Arc::new(ShardedLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.write().unwrap(); + panic!(); + }) + .join(); + assert!(arc.read().is_err()); +} + +#[test] +fn arc_poison_ww() { + let arc = Arc::new(ShardedLock::new(1)); + assert!(!arc.is_poisoned()); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.write().unwrap(); + panic!(); + }) + .join(); + assert!(arc.write().is_err()); + assert!(arc.is_poisoned()); +} + +#[test] +fn arc_no_poison_rr() { + let arc = Arc::new(ShardedLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.read().unwrap(); + panic!(); + }) + .join(); + let lock = arc.read().unwrap(); + assert_eq!(*lock, 1); +} +#[test] +fn arc_no_poison_sl() { + let arc = Arc::new(ShardedLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let _lock = arc2.read().unwrap(); + panic!() + }) + .join(); + let lock = arc.write().unwrap(); + assert_eq!(*lock, 1); +} + +#[test] +fn arc() { + let arc = Arc::new(ShardedLock::new(0)); + let arc2 = arc.clone(); + let (tx, rx) = channel(); + + thread::spawn(move || { + let mut lock = arc2.write().unwrap(); + for _ in 0..10 { + let tmp = *lock; + *lock = -1; + thread::yield_now(); + *lock = tmp + 1; + } + tx.send(()).unwrap(); + }); + + // Readers try to catch the writer in the act + let mut children = Vec::new(); + for _ in 0..5 { + let arc3 = arc.clone(); + children.push(thread::spawn(move || { + let lock = arc3.read().unwrap(); + assert!(*lock >= 0); + })); + } + + // Wait for children to pass their asserts + for r in children { + assert!(r.join().is_ok()); + } + + // Wait for writer to finish + rx.recv().unwrap(); + let lock = arc.read().unwrap(); + assert_eq!(*lock, 10); +} + +#[test] +fn arc_access_in_unwind() { + let arc = Arc::new(ShardedLock::new(1)); + let arc2 = arc.clone(); + let _ = thread::spawn(move || -> () { + struct Unwinder { + i: Arc>, + } + impl Drop for Unwinder { + fn drop(&mut self) { + let mut lock = self.i.write().unwrap(); + *lock += 1; + } + } + let _u = Unwinder { i: arc2 }; + panic!(); + }) + .join(); + let lock = arc.read().unwrap(); + assert_eq!(*lock, 2); +} + +#[test] +fn unsized_type() { + let sl: &ShardedLock<[i32]> = &ShardedLock::new([1, 2, 3]); + { + let b = &mut *sl.write().unwrap(); + b[0] = 4; + b[2] = 5; + } + let comp: &[i32] = &[4, 2, 5]; + assert_eq!(&*sl.read().unwrap(), comp); +} + +#[test] +fn try_write() { + let lock = ShardedLock::new(0isize); + let read_guard = lock.read().unwrap(); + + let write_result = lock.try_write(); + match write_result { + Err(TryLockError::WouldBlock) => (), + Ok(_) => assert!( + false, + "try_write should not succeed while read_guard is in scope" + ), + Err(_) => assert!(false, "unexpected error"), + } + + drop(read_guard); +} + +#[test] +fn test_into_inner() { + let m = ShardedLock::new(NonCopy(10)); + assert_eq!(m.into_inner().unwrap(), NonCopy(10)); +} + +#[test] +fn test_into_inner_drop() { + struct Foo(Arc); + impl Drop for Foo { + fn drop(&mut self) { + self.0.fetch_add(1, Ordering::SeqCst); + } + } + let num_drops = Arc::new(AtomicUsize::new(0)); + let m = ShardedLock::new(Foo(num_drops.clone())); + assert_eq!(num_drops.load(Ordering::SeqCst), 0); + { + let _inner = m.into_inner().unwrap(); + assert_eq!(num_drops.load(Ordering::SeqCst), 0); + } + assert_eq!(num_drops.load(Ordering::SeqCst), 1); +} + +#[test] +fn test_into_inner_poison() { + let m = Arc::new(ShardedLock::new(NonCopy(10))); + let m2 = m.clone(); + let _ = thread::spawn(move || { + let _lock = m2.write().unwrap(); + panic!("test panic in inner thread to poison ShardedLock"); + }) + .join(); + + assert!(m.is_poisoned()); + match Arc::try_unwrap(m).unwrap().into_inner() { + Err(e) => assert_eq!(e.into_inner(), NonCopy(10)), + Ok(x) => panic!("into_inner of poisoned ShardedLock is Ok: {:?}", x), + } +} + +#[test] +fn test_get_mut() { + let mut m = ShardedLock::new(NonCopy(10)); + *m.get_mut().unwrap() = NonCopy(20); + assert_eq!(m.into_inner().unwrap(), NonCopy(20)); +} + +#[test] +fn test_get_mut_poison() { + let m = Arc::new(ShardedLock::new(NonCopy(10))); + let m2 = m.clone(); + let _ = thread::spawn(move || { + let _lock = m2.write().unwrap(); + panic!("test panic in inner thread to poison ShardedLock"); + }) + .join(); + + assert!(m.is_poisoned()); + match Arc::try_unwrap(m).unwrap().get_mut() { + Err(e) => assert_eq!(*e.into_inner(), NonCopy(10)), + Ok(x) => panic!("get_mut of poisoned ShardedLock is Ok: {:?}", x), + } +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/thread.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/thread.rs new file mode 100644 index 0000000..b691745 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/thread.rs @@ -0,0 +1,181 @@ +extern crate crossbeam_utils; + +use std::any::Any; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::thread::sleep; +use std::time::Duration; + +use crossbeam_utils::thread; + +const THREADS: usize = 10; +const SMALL_STACK_SIZE: usize = 20; + +#[test] +fn join() { + let counter = AtomicUsize::new(0); + thread::scope(|scope| { + let handle = scope.spawn(|_| { + counter.store(1, Ordering::Relaxed); + }); + assert!(handle.join().is_ok()); + + let panic_handle = scope.spawn(|_| { + panic!("\"My honey is running out!\", said Pooh."); + }); + assert!(panic_handle.join().is_err()); + }) + .unwrap(); + + // There should be sufficient synchronization. + assert_eq!(1, counter.load(Ordering::Relaxed)); +} + +#[test] +fn counter() { + let counter = AtomicUsize::new(0); + thread::scope(|scope| { + for _ in 0..THREADS { + scope.spawn(|_| { + counter.fetch_add(1, Ordering::Relaxed); + }); + } + }) + .unwrap(); + + assert_eq!(THREADS, counter.load(Ordering::Relaxed)); +} + +#[test] +fn counter_builder() { + let counter = AtomicUsize::new(0); + thread::scope(|scope| { + for i in 0..THREADS { + scope + .builder() + .name(format!("child-{}", i)) + .stack_size(SMALL_STACK_SIZE) + .spawn(|_| { + counter.fetch_add(1, Ordering::Relaxed); + }) + .unwrap(); + } + }) + .unwrap(); + + assert_eq!(THREADS, counter.load(Ordering::Relaxed)); +} + +#[test] +fn counter_panic() { + let counter = AtomicUsize::new(0); + let result = thread::scope(|scope| { + scope.spawn(|_| { + panic!("\"My honey is running out!\", said Pooh."); + }); + sleep(Duration::from_millis(100)); + + for _ in 0..THREADS { + scope.spawn(|_| { + counter.fetch_add(1, Ordering::Relaxed); + }); + } + }); + + assert_eq!(THREADS, counter.load(Ordering::Relaxed)); + assert!(result.is_err()); +} + +#[test] +fn panic_twice() { + let result = thread::scope(|scope| { + scope.spawn(|_| { + sleep(Duration::from_millis(500)); + panic!("thread #1"); + }); + scope.spawn(|_| { + panic!("thread #2"); + }); + }); + + let err = result.unwrap_err(); + let vec = err + .downcast_ref::>>() + .unwrap(); + assert_eq!(2, vec.len()); + + let first = vec[0].downcast_ref::<&str>().unwrap(); + let second = vec[1].downcast_ref::<&str>().unwrap(); + assert_eq!("thread #1", *first); + assert_eq!("thread #2", *second) +} + +#[test] +fn panic_many() { + let result = thread::scope(|scope| { + scope.spawn(|_| panic!("deliberate panic #1")); + scope.spawn(|_| panic!("deliberate panic #2")); + scope.spawn(|_| panic!("deliberate panic #3")); + }); + + let err = result.unwrap_err(); + let vec = err + .downcast_ref::>>() + .unwrap(); + assert_eq!(3, vec.len()); + + for panic in vec.iter() { + let panic = panic.downcast_ref::<&str>().unwrap(); + assert!( + *panic == "deliberate panic #1" + || *panic == "deliberate panic #2" + || *panic == "deliberate panic #3" + ); + } +} + +#[test] +fn nesting() { + let var = "foo".to_string(); + + struct Wrapper<'a> { + var: &'a String, + } + + impl<'a> Wrapper<'a> { + fn recurse(&'a self, scope: &thread::Scope<'a>, depth: usize) { + assert_eq!(self.var, "foo"); + + if depth > 0 { + scope.spawn(move |scope| { + self.recurse(scope, depth - 1); + }); + } + } + } + + let wrapper = Wrapper { var: &var }; + + thread::scope(|scope| { + scope.spawn(|scope| { + scope.spawn(|scope| { + wrapper.recurse(scope, 5); + }); + }); + }) + .unwrap(); +} + +#[test] +fn join_nested() { + thread::scope(|scope| { + scope.spawn(|scope| { + let handle = scope.spawn(|_| 7); + + sleep(Duration::from_millis(200)); + handle.join().unwrap(); + }); + + sleep(Duration::from_millis(100)); + }) + .unwrap(); +} diff --git a/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/wait_group.rs b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/wait_group.rs new file mode 100644 index 0000000..1aa9199 --- /dev/null +++ b/third_party/cargo/vendor/crossbeam-utils-0.6.6/tests/wait_group.rs @@ -0,0 +1,66 @@ +extern crate crossbeam_utils; + +use std::sync::mpsc; +use std::thread; +use std::time::Duration; + +use crossbeam_utils::sync::WaitGroup; + +const THREADS: usize = 10; + +#[test] +fn wait() { + let wg = WaitGroup::new(); + let (tx, rx) = mpsc::channel(); + + for _ in 0..THREADS { + let wg = wg.clone(); + let tx = tx.clone(); + + thread::spawn(move || { + wg.wait(); + tx.send(()).unwrap(); + }); + } + + thread::sleep(Duration::from_millis(100)); + + // At this point, all spawned threads should be blocked, so we shouldn't get anything from the + // channel. + assert!(rx.try_recv().is_err()); + + wg.wait(); + + // Now, the wait group is cleared and we should receive messages. + for _ in 0..THREADS { + rx.recv().unwrap(); + } +} + +#[test] +fn wait_and_drop() { + let wg = WaitGroup::new(); + let (tx, rx) = mpsc::channel(); + + for _ in 0..THREADS { + let wg = wg.clone(); + let tx = tx.clone(); + + thread::spawn(move || { + thread::sleep(Duration::from_millis(100)); + tx.send(()).unwrap(); + drop(wg); + }); + } + + // At this point, all spawned threads should be sleeping, so we shouldn't get anything from the + // channel. + assert!(rx.try_recv().is_err()); + + wg.wait(); + + // Now, the wait group is cleared and we should receive messages. + for _ in 0..THREADS { + rx.try_recv().unwrap(); + } +} diff --git a/third_party/cargo/vendor/dlib-0.4.1/.cargo-checksum.json b/third_party/cargo/vendor/dlib-0.4.1/.cargo-checksum.json new file mode 100644 index 0000000..3c4a555 --- /dev/null +++ b/third_party/cargo/vendor/dlib-0.4.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"524bcad39403900e9789765368e3314f0852ec11a85238122301acaa9e97eb78","LICENSE.txt":"10e5daea68c3ab7da6468ea51860e9d4ac87ea6a9a2d34127beff17b7193b618","README.md":"1c0305cb5f45f0381423fde9f460f8855c486583cb9a9a72643c97295b6223cc","src/lib.rs":"93f12f1151ab5b49352048273f2d7c0a2099cb23c8ba0ec99b3c63deba69ece0"},"package":"77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"} \ No newline at end of file diff --git a/third_party/cargo/vendor/dlib-0.4.1/BUILD b/third_party/cargo/vendor/dlib-0.4.1/BUILD new file mode 100644 index 0000000..d72b6ce --- /dev/null +++ b/third_party/cargo/vendor/dlib-0.4.1/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "dlib", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libloading-0.5.2:libloading", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.4.1", + crate_features = [ + "dlopen", + ], +) + diff --git a/third_party/cargo/vendor/dlib-0.4.1/Cargo.toml b/third_party/cargo/vendor/dlib-0.4.1/Cargo.toml new file mode 100644 index 0000000..ac817b2 --- /dev/null +++ b/third_party/cargo/vendor/dlib-0.4.1/Cargo.toml @@ -0,0 +1,24 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "dlib" +version = "0.4.1" +authors = ["Victor Berger "] +description = "Helper macros for handling manually loading optional system libraries." +license = "MIT" +repository = "https://github.com/vberger/dlib" +[dependencies.libloading] +version = "0.5.0" + +[features] +dlopen = [] diff --git a/third_party/cargo/vendor/dlib-0.4.1/LICENSE.txt b/third_party/cargo/vendor/dlib-0.4.1/LICENSE.txt new file mode 100644 index 0000000..6193f35 --- /dev/null +++ b/third_party/cargo/vendor/dlib-0.4.1/LICENSE.txt @@ -0,0 +1,19 @@ +Copyright (c) 2015 Victor Berger + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/third_party/cargo/vendor/dlib-0.4.1/README.md b/third_party/cargo/vendor/dlib-0.4.1/README.md new file mode 100644 index 0000000..eda797c --- /dev/null +++ b/third_party/cargo/vendor/dlib-0.4.1/README.md @@ -0,0 +1,109 @@ +# dlib, making native libraries optional + +[![](http://meritbadge.herokuapp.com/dlib)](https://crates.io/crates/dlib) +[![Docs.rs](https://docs.rs/dlib/badge.svg)](https://docs.rs/dlib) + +dlib is a small crate providing macros to make easy the use of external system libraries +that can or cannot be optionally loaded at runtime, depending on whether the `dlopen` cargo +feature is enabled. + +## Usage + +dlib defines the `external_library!` macro, which can be invoked with way: + +```rust +external_library!(Foo, "foo", + statics: + me: c_int, + you: c_float, + functions: + fn foo() -> c_int, + fn bar(c_int, c_float) -> (), + fn baz(*const c_int) -> c_int, + varargs: + fn blah(c_int, c_int ...) -> *const c_void, + fn bleh(c_int ...) -> (), +); +``` + +As you can see, it is required to separate static values from functions and from function +having variadic arguments. Each of these 3 categories is optional, but the ones used must appear +in this order. Return types of the functions must all be explicit (hence `-> ()` for void functions). + +If the feature `dlopen` is absent, this macro will expand to an extern block defining each of the +items, using the second argument of the macro as a link name: + +```rust +#[link(name = "foo")] +extern "C" { + pub static me: c_int; + pub static you: c_float; + pub fn foo() -> c_int; + pub fn bar(_: c_int, _: c_float) -> (); + pub fn baz(_: *const c_int) -> c_int; + pub fn blah(_: c_int, _: c_int, ...) -> *const c_void; + pub fn bleh(_: c_int, ...) -> (); +} + +``` + +If the feature `dlopen` is present, it will expand to a `struct` named by the first argument of the macro, +with one field for each of the symbols defined, and a method `open`, which tries to load the library +from the name or path given as argument + +```rust +pub struct Foo { + pub me: &'static c_int, + pub you: &'static c_float, + pub foo: unsafe extern "C" fn() -> c_int, + pub bar: unsafe extern "C" fn(c_int, c_float) -> (), + pub baz: unsafe extern "C" fn(*const c_int) -> c_int, + pub blah: unsafe extern "C" fn(c_int, c_int, ...) -> *const c_void, + pub bleh: unsafe extern "C" fn(c_int, ...) -> (), +} + + +impl Foo { + pub fn open(name: &str) -> Result { /* ... */ } +} +``` + +This method returns `Ok(..)` if the loading was successful. It contains an instance of the defined struct +with all of its fields pointing to the appropriate symbol. + +If the library specified by `name` could not be found, it returns `Err(DlError::NotFount)`. + +It will also fail on the first missing symbol, with `Err(DlError::MissingSymbol(symb))` where `symb` is a `&str` +containing the missing symbol name. + +## Remaining generic in your crate + +If you want your crate to remain generic over the `dlopen` cargo feature, simply add this to your `Cargo.toml` + +``` +[dependencies] +dlib = "0.2" + +[features] +dlopen = ["dlib/dlopen"] +``` + +And the library also provides helper macros to dispatch the access to foreign symbols: + +```rust +ffi_dispatch!(Foo, function, arg1, arg2); +ffi_dispatch_static!(Foo, static); +``` + +These will expand to the appropriate value or function call depending on the presence of the `dlopen` feature. + +You must still ensure that the functions/statics or the wrapper struct `Foo` are in scope. A simple pattern would be +for example to use the `lazy_static!` crate to do the initialization and store the wrapper struct in a static, that you then +just need to import everywhere needed. Then, it can become as simple as putting this on top of all modules using the FFI: + +```rust +#[cfg(features = "dlopen")] +use ffi::FOO_STATIC; +#[cfg(not(features = "dlopen"))] +use ffi::*; +``` diff --git a/third_party/cargo/vendor/dlib-0.4.1/src/lib.rs b/third_party/cargo/vendor/dlib-0.4.1/src/lib.rs new file mode 100644 index 0000000..98e3110 --- /dev/null +++ b/third_party/cargo/vendor/dlib-0.4.1/src/lib.rs @@ -0,0 +1,179 @@ +extern crate libloading; + +pub use libloading::{Library, Symbol}; + +#[cfg(feature = "dlopen")] +#[macro_export] +macro_rules! ffi_dispatch( + ($handle: ident, $func: ident, $($arg: expr),*) => ( + ($handle.$func)($($arg),*) + ) +); + +#[cfg(not(feature = "dlopen"))] +#[macro_export] +macro_rules! ffi_dispatch( + ($handle: ident, $func: ident, $($arg: expr),*) => ( + $func($($arg),*) + ) +); + +#[cfg(feature = "dlopen")] +#[macro_export] +macro_rules! ffi_dispatch_static( + ($handle: ident, $name: ident) => ( + $handle.$name + ) +); + +#[cfg(not(feature = "dlopen"))] +#[macro_export] +macro_rules! ffi_dispatch_static( + ($handle: ident, $name: ident) => ( + &$name + ) +); + +#[macro_export] +macro_rules! link_external_library( + ($link: expr, + $(statics: $($sname: ident: $stype: ty),+,)|* + $(functions: $(fn $fname: ident($($farg: ty),*) -> $fret:ty),+,)|* + $(varargs: $(fn $vname: ident($($vargs: ty),+) -> $vret: ty),+,)|* + ) => ( + #[link(name = $link)] + extern "C" { + $($( + pub static $sname: $stype; + )+)* + $($( + pub fn $fname($(_: $farg),*) -> $fret; + )+)* + $($( + pub fn $vname($(_: $vargs),+ , ...) -> $vret; + )+)* + } + ); +); + +pub enum DlError { + NotFound, + MissingSymbol(&'static str) +} + +#[macro_export] +macro_rules! dlopen_external_library( + (__struct, $structname: ident, + $(statics: $($sname: ident: $stype: ty),+,)|* + $(functions: $(fn $fname: ident($($farg: ty),*) -> $fret:ty),+,)|* + $(varargs: $(fn $vname: ident($($vargs: ty),+) -> $vret: ty),+,)|* + ) => ( + pub struct $structname { + __lib: $crate::Library, + $($( + pub $sname: $crate::Symbol<'static, &'static $stype>, + )+)* + $($( + pub $fname: $crate::Symbol<'static, unsafe extern "C" fn($($farg),*) -> $fret>, + )+)* + $($( + pub $vname: $crate::Symbol<'static, unsafe extern "C" fn($($vargs),+ , ...) -> $vret>, + )+)* + } + ); + (__impl, $structname: ident, + $(statics: $($sname: ident: $stype: ty),+,)|* + $(functions: $(fn $fname: ident($($farg: ty),*) -> $fret:ty),+,)|* + $(varargs: $(fn $vname: ident($($vargs: ty),+) -> $vret: ty),+,)|* + ) => ( + impl $structname { + pub fn open(name: &str) -> Result<$structname, $crate::DlError> { + // we use it to ensure the 'static lifetime + use std::mem::transmute; + let lib = match $crate::Library::new(name) { + Ok(l) => l, + Err(_) => return Err($crate::DlError::NotFound) + }; + unsafe { + let s = $structname { + $($($sname: { + let s_name = concat!(stringify!($sname), "\0"); + transmute(match lib.get::<&'static $stype>(s_name.as_bytes()) { + Ok(s) => s, + Err(_) => return Err($crate::DlError::MissingSymbol(s_name)) + }) + }, + )+)* + $($($fname: { + let s_name = concat!(stringify!($fname), "\0"); + transmute(match lib.get:: $fret>(s_name.as_bytes()) { + Ok(s) => s, + Err(_) => return Err($crate::DlError::MissingSymbol(s_name)) + }) + }, + )+)* + $($($vname: { + let s_name = concat!(stringify!($vname), "\0"); + transmute(match lib.get:: $vret>(s_name.as_bytes()) { + Ok(s) => s, + Err(_) => return Err($crate::DlError::MissingSymbol(s_name)) + }) + }, + )+)* + __lib: lib + }; + Ok(s) + } + } + } + ); + ($structname: ident, + $(statics: $($sname: ident: $stype: ty),+,)|* + $(functions: $(fn $fname: ident($($farg: ty),*) -> $fret:ty),+,)|* + $(varargs: $(fn $vname: ident($($vargs: ty),+) -> $vret: ty),+,)|* + ) => ( + dlopen_external_library!(__struct, + $structname, $(statics: $($sname: $stype),+,)|* + $(functions: $(fn $fname($($farg),*) -> $fret),+,)|* + $(varargs: $(fn $vname($($vargs),+) -> $vret),+,)|* + ); + dlopen_external_library!(__impl, + $structname, $(statics: $($sname: $stype),+,)|* + $(functions: $(fn $fname($($farg),*) -> $fret),+,)|* + $(varargs: $(fn $vname($($vargs),+) -> $vret),+,)|* + ); + unsafe impl Sync for $structname { } + ); +); + +#[cfg(not(feature = "dlopen"))] +#[macro_export] +macro_rules! external_library( + ($structname: ident, $link: expr, + $(statics: $($sname: ident: $stype: ty),+,)|* + $(functions: $(fn $fname: ident($($farg: ty),*) -> $fret:ty),+,)|* + $(varargs: $(fn $vname: ident($($vargs: ty),+) -> $vret: ty),+,)|* + ) => ( + link_external_library!( + $link, $(statics: $($sname: $stype),+,)|* + $(functions: $(fn $fname($($farg),*) -> $fret),+,)|* + $(varargs: $(fn $vname($($vargs),+) -> $vret),+,)|* + ); + ); +); + +#[cfg(feature = "dlopen")] +#[macro_export] +macro_rules! external_library( + ($structname: ident, $link: expr, + $(statics: $($sname: ident: $stype: ty),+,)|* + $(functions: $(fn $fname: ident($($farg: ty),*) -> $fret:ty),+,)|* + $(varargs: $(fn $vname: ident($($vargs: ty),+) -> $vret: ty),+,)|* + ) => ( + dlopen_external_library!( + $structname, $(statics: $($sname: $stype),+,)|* + $(functions: $(fn $fname($($farg),*) -> $fret),+,)|* + $(varargs: $(fn $vname($($vargs),+) -> $vret),+,)|* + ); + ); +); diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/.cargo-checksum.json b/third_party/cargo/vendor/downcast-rs-1.1.1/.cargo-checksum.json new file mode 100644 index 0000000..d488ae4 --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"924dcbf92b15834b1c8a562a92086009345a7eb475113734b667610d67228274","Cargo.toml":"8d2da785bddff1a916045dcb013a00273e0f344d0f39828fffb9a989b0021d68","LICENSE-APACHE":"8173d5c29b4f956d532781d2b86e4e30f83e6b7878dce18c919451d6ba707c90","LICENSE-MIT":"2f4746eca0952212fb5570645b56612df13e94783887bd8271e75645b468c061","README.md":"40369085e0116592fa9c5f43a5894a6c4b2d46293e572ea39710630f195b6fb1","README.tpl":"a93f069faae39bbed04b1d26ee7f48a5fbf51b120b5f63d8f24eeab4f0cabf25","src/lib.rs":"ed80d4d9ba62cd4fca2b3a26e3a274ddebd9238aafb4aa2a6c79e1a1f7b5c852","tests/import_via_macro_use.rs":"621d22294eb802e82dc8393d344c706f97b8347da49084135a75aa1331553548","tests/use_via_namespace.rs":"013640597d3b2d8719d3857cfc721942738e4a3eeba61517b25d45ba4165da3c"},"package":"52ba6eb47c2131e784a38b726eb54c1e1484904f013e576a25354d0124161af6"} \ No newline at end of file diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/BUILD b/third_party/cargo/vendor/downcast-rs-1.1.1/BUILD new file mode 100644 index 0000000..52e83a2 --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "downcast_rs", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.1.1", + crate_features = [ + ], +) + +# Unsupported target "import_via_macro_use" with type "test" omitted +# Unsupported target "use_via_namespace" with type "test" omitted diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/CHANGELOG.md b/third_party/cargo/vendor/downcast-rs-1.1.1/CHANGELOG.md new file mode 100644 index 0000000..5d6b167 --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/CHANGELOG.md @@ -0,0 +1,49 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## 1.1.1 - 2019-10-28 +### Changed +- Used `dyn Trait` syntax everywhere since it is supported by downcast-rs's + min-supported rust version (1.33). + +## 1.1.0 - 2019-10-07 +### Added +- Support for downcasting `Rc` and `Arc`. +### Changed +- Minimum supported Rust version upped to 1.33 to support `Rc` and `Arc` in the + receiver position. + +## 1.0.4 - 2019-04-08 +### Changed +- Added `local_inner_macros` to `impl_downcast` to allow invoking via namespace. + +## 1.0.3 - 2018-05-21 +### Fixed +- Use global path for Result, Option, Box in macro expansion to avoid name + conflicts with locally-defined symbols. + +## 1.0.2 - 2018-05-12 +### Added +- Support for downcasting `Box` to `Box`. + +## 1.0.1 - 2018-03-08 +### Fixed +- Don't use types as traits in macros. + +## 1.0.0 - 2017-02-05 +### Changed +- Cleaned up README and published 1.0. + +## 0.1.2 - 2016-11-22 +### Added +- Support for associated types as well. + +## 0.1.1 - 2016-09-04 +### Added +- Downcast functionality to downcast borrowed mutable and immutable trait + objects to concrete types. Supports concrete type parameters and type + variables with optional constraints. + diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/Cargo.toml b/third_party/cargo/vendor/downcast-rs-1.1.1/Cargo.toml new file mode 100644 index 0000000..940af82 --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/Cargo.toml @@ -0,0 +1,21 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "downcast-rs" +version = "1.1.1" +authors = ["Ashish Myles "] +description = "Trait object downcasting support using only safe Rust. It supports type\nparameters, associated types, and type constraints.\n" +readme = "README.md" +keywords = ["downcast", "any", "trait", "associated", "constraint"] +license = "MIT/Apache-2.0" +repository = "https://github.com/marcianx/downcast-rs" diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/LICENSE-APACHE b/third_party/cargo/vendor/downcast-rs-1.1.1/LICENSE-APACHE new file mode 100644 index 0000000..11069ed --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/LICENSE-MIT b/third_party/cargo/vendor/downcast-rs-1.1.1/LICENSE-MIT new file mode 100644 index 0000000..6d1a88b --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2015 Ashish Myles + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/README.md b/third_party/cargo/vendor/downcast-rs-1.1.1/README.md new file mode 100644 index 0000000..58e020d --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/README.md @@ -0,0 +1,139 @@ +# downcast-rs + +Rust enums are great for types where all variations are known beforehand. But a +container of user-defined types requires an open-ended type like a **trait +object**. Some applications may want to cast these trait objects back to the +original concrete types to access additional functionality and performant +inlined implementations. + +`downcast-rs` adds this downcasting support to trait objects using only safe +Rust. It supports **type parameters**, **associated types**, and **constraints**. + +To make a trait downcastable, make it extend either `downcast::Downcast` or +`downcast::DowncastSync` and invoke `impl_downcast!` on it as in the examples +below. + +Since 1.1.0, the minimum supported Rust version is 1.33 to support `Rc` and `Arc` +in the receiver position. + +```rust +trait Trait: Downcast {} +impl_downcast!(Trait); + +// Also supports downcasting `Arc`-ed trait objects by extending `DowncastSync` +// and starting `impl_downcast!` with `sync`. +trait TraitSync: DowncastSync {} +impl_downcast!(sync TraitSync); + +// With type parameters. +trait TraitGeneric1: Downcast {} +impl_downcast!(TraitGeneric1); + +// With associated types. +trait TraitGeneric2: Downcast { type G; type H; } +impl_downcast!(TraitGeneric2 assoc G, H); + +// With constraints on types. +trait TraitGeneric3: Downcast { + type H: Clone; +} +impl_downcast!(TraitGeneric3 assoc H where T: Copy, H: Clone); + +// With concrete types. +trait TraitConcrete1: Downcast {} +impl_downcast!(concrete TraitConcrete1); + +trait TraitConcrete2: Downcast { type H; } +impl_downcast!(concrete TraitConcrete2 assoc H=f64); +``` + +## Example without generics + +```rust +// Import macro via `macro_use` pre-1.30. +#[macro_use] +extern crate downcast_rs; +use downcast_rs::DowncastSync; + +// To create a trait with downcasting methods, extend `Downcast` or `DowncastSync` +// and run `impl_downcast!()` on the trait. +trait Base: DowncastSync {} +impl_downcast!(sync Base); // `sync` => also produce `Arc` downcasts. + +// Concrete types implementing Base. +#[derive(Debug)] +struct Foo(u32); +impl Base for Foo {} +#[derive(Debug)] +struct Bar(f64); +impl Base for Bar {} + +fn main() { + // Create a trait object. + let mut base: Box = Box::new(Foo(42)); + + // Try sequential downcasts. + if let Some(foo) = base.downcast_ref::() { + assert_eq!(foo.0, 42); + } else if let Some(bar) = base.downcast_ref::() { + assert_eq!(bar.0, 42.0); + } + + assert!(base.is::()); + + // Fail to convert `Box` into `Box`. + let res = base.downcast::(); + assert!(res.is_err()); + let base = res.unwrap_err(); + // Convert `Box` into `Box`. + assert_eq!(42, base.downcast::().map_err(|_| "Shouldn't happen.").unwrap().0); + + // Also works with `Rc`. + let mut rc: Rc = Rc::new(Foo(42)); + assert_eq!(42, rc.downcast_rc::().map_err(|_| "Shouldn't happen.").unwrap().0); + + // Since this trait is `Sync`, it also supports `Arc` downcasts. + let mut arc: Arc = Arc::new(Foo(42)); + assert_eq!(42, arc.downcast_arc::().map_err(|_| "Shouldn't happen.").unwrap().0); +} +``` + +## Example with a generic trait with associated types and constraints + +```rust +// Can call macro via namespace since rust 1.30. +extern crate downcast_rs; +use downcast_rs::Downcast; + +// To create a trait with downcasting methods, extend `Downcast` or `DowncastSync` +// and run `impl_downcast!()` on the trait. +trait Base: Downcast { type H: Copy; } +downcast_rs::impl_downcast!(Base assoc H where T: Clone, H: Copy); +// or: impl_downcast!(concrete Base assoc H=f32) + +// Concrete types implementing Base. +struct Foo(u32); +impl Base for Foo { type H = f32; } +struct Bar(f64); +impl Base for Bar { type H = f32; } + +fn main() { + // Create a trait object. + let mut base: Box> = Box::new(Bar(42.0)); + + // Try sequential downcasts. + if let Some(foo) = base.downcast_ref::() { + assert_eq!(foo.0, 42); + } else if let Some(bar) = base.downcast_ref::() { + assert_eq!(bar.0, 42.0); + } + + assert!(base.is::()); +} +``` + +## License + +Copyright 2015, Ashish Myles. +This software is dual-licensed under the [MIT](LICENSE-MIT) and +[Apache 2.0](LICENSE-APACHE) licenses. diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/README.tpl b/third_party/cargo/vendor/downcast-rs-1.1.1/README.tpl new file mode 100644 index 0000000..ac71891 --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/README.tpl @@ -0,0 +1,8 @@ +{{readme}} + +## License + +Copyright 2015, Ashish Myles. +This software is dual-licensed under the [MIT](LICENSE-MIT) and +[Apache 2.0](LICENSE-APACHE) licenses. + diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/src/lib.rs b/third_party/cargo/vendor/downcast-rs-1.1.1/src/lib.rs new file mode 100644 index 0000000..384166f --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/src/lib.rs @@ -0,0 +1,660 @@ +#![deny(unsafe_code)] +//! Rust enums are great for types where all variations are known beforehand. But a +//! container of user-defined types requires an open-ended type like a **trait +//! object**. Some applications may want to cast these trait objects back to the +//! original concrete types to access additional functionality and performant +//! inlined implementations. +//! +//! `downcast-rs` adds this downcasting support to trait objects using only safe +//! Rust. It supports **type parameters**, **associated types**, and **constraints**. +//! +//! To make a trait downcastable, make it extend either `downcast::Downcast` or +//! `downcast::DowncastSync` and invoke `impl_downcast!` on it as in the examples +//! below. +//! +//! Since 1.1.0, the minimum supported Rust version is 1.33 to support `Rc` and `Arc` +//! in the receiver position. +//! +//! ``` +//! # #[macro_use] +//! # extern crate downcast_rs; +//! # use downcast_rs::{Downcast, DowncastSync}; +//! trait Trait: Downcast {} +//! impl_downcast!(Trait); +//! +//! // Also supports downcasting `Arc`-ed trait objects by extending `DowncastSync` +//! // and starting `impl_downcast!` with `sync`. +//! trait TraitSync: DowncastSync {} +//! impl_downcast!(sync TraitSync); +//! +//! // With type parameters. +//! trait TraitGeneric1: Downcast {} +//! impl_downcast!(TraitGeneric1); +//! +//! // With associated types. +//! trait TraitGeneric2: Downcast { type G; type H; } +//! impl_downcast!(TraitGeneric2 assoc G, H); +//! +//! // With constraints on types. +//! trait TraitGeneric3: Downcast { +//! type H: Clone; +//! } +//! impl_downcast!(TraitGeneric3 assoc H where T: Copy, H: Clone); +//! +//! // With concrete types. +//! trait TraitConcrete1: Downcast {} +//! impl_downcast!(concrete TraitConcrete1); +//! +//! trait TraitConcrete2: Downcast { type H; } +//! impl_downcast!(concrete TraitConcrete2 assoc H=f64); +//! # fn main() {} +//! ``` +//! +//! # Example without generics +//! +//! ``` +//! # use std::rc::Rc; +//! # use std::sync::Arc; +//! // Import macro via `macro_use` pre-1.30. +//! #[macro_use] +//! extern crate downcast_rs; +//! use downcast_rs::DowncastSync; +//! +//! // To create a trait with downcasting methods, extend `Downcast` or `DowncastSync` +//! // and run `impl_downcast!()` on the trait. +//! trait Base: DowncastSync {} +//! impl_downcast!(sync Base); // `sync` => also produce `Arc` downcasts. +//! +//! // Concrete types implementing Base. +//! #[derive(Debug)] +//! struct Foo(u32); +//! impl Base for Foo {} +//! #[derive(Debug)] +//! struct Bar(f64); +//! impl Base for Bar {} +//! +//! fn main() { +//! // Create a trait object. +//! let mut base: Box = Box::new(Foo(42)); +//! +//! // Try sequential downcasts. +//! if let Some(foo) = base.downcast_ref::() { +//! assert_eq!(foo.0, 42); +//! } else if let Some(bar) = base.downcast_ref::() { +//! assert_eq!(bar.0, 42.0); +//! } +//! +//! assert!(base.is::()); +//! +//! // Fail to convert `Box` into `Box`. +//! let res = base.downcast::(); +//! assert!(res.is_err()); +//! let base = res.unwrap_err(); +//! // Convert `Box` into `Box`. +//! assert_eq!(42, base.downcast::().map_err(|_| "Shouldn't happen.").unwrap().0); +//! +//! // Also works with `Rc`. +//! let mut rc: Rc = Rc::new(Foo(42)); +//! assert_eq!(42, rc.downcast_rc::().map_err(|_| "Shouldn't happen.").unwrap().0); +//! +//! // Since this trait is `Sync`, it also supports `Arc` downcasts. +//! let mut arc: Arc = Arc::new(Foo(42)); +//! assert_eq!(42, arc.downcast_arc::().map_err(|_| "Shouldn't happen.").unwrap().0); +//! } +//! ``` +//! +//! # Example with a generic trait with associated types and constraints +//! +//! ``` +//! // Can call macro via namespace since rust 1.30. +//! extern crate downcast_rs; +//! use downcast_rs::Downcast; +//! +//! // To create a trait with downcasting methods, extend `Downcast` or `DowncastSync` +//! // and run `impl_downcast!()` on the trait. +//! trait Base: Downcast { type H: Copy; } +//! downcast_rs::impl_downcast!(Base assoc H where T: Clone, H: Copy); +//! // or: impl_downcast!(concrete Base assoc H=f32) +//! +//! // Concrete types implementing Base. +//! struct Foo(u32); +//! impl Base for Foo { type H = f32; } +//! struct Bar(f64); +//! impl Base for Bar { type H = f32; } +//! +//! fn main() { +//! // Create a trait object. +//! let mut base: Box> = Box::new(Bar(42.0)); +//! +//! // Try sequential downcasts. +//! if let Some(foo) = base.downcast_ref::() { +//! assert_eq!(foo.0, 42); +//! } else if let Some(bar) = base.downcast_ref::() { +//! assert_eq!(bar.0, 42.0); +//! } +//! +//! assert!(base.is::()); +//! } +//! ``` + +use std::any::Any; + +/// Supports conversion to `Any`. Traits to be extended by `impl_downcast!` must extend `Downcast`. +pub trait Downcast: Any { + /// Convert `Box` (where `Trait: Downcast`) to `Box`. `Box` can + /// then be further `downcast` into `Box` where `ConcreteType` implements `Trait`. + fn into_any(self: Box) -> Box; + /// Convert `Rc` (where `Trait: Downcast`) to `Rc`. `Rc` can then be + /// further `downcast` into `Rc` where `ConcreteType` implements `Trait`. + fn into_any_rc(self: ::std::rc::Rc) -> ::std::rc::Rc; + /// Convert `&Trait` (where `Trait: Downcast`) to `&Any`. This is needed since Rust cannot + /// generate `&Any`'s vtable from `&Trait`'s. + fn as_any(&self) -> &dyn Any; + /// Convert `&mut Trait` (where `Trait: Downcast`) to `&Any`. This is needed since Rust cannot + /// generate `&mut Any`'s vtable from `&mut Trait`'s. + fn as_any_mut(&mut self) -> &mut dyn Any; +} + +impl Downcast for T { + fn into_any(self: Box) -> Box { self } + fn into_any_rc(self: ::std::rc::Rc) -> ::std::rc::Rc { self } + fn as_any(&self) -> &dyn Any { self } + fn as_any_mut(&mut self) -> &mut dyn Any { self } +} + +/// Extends `Downcast` to support `Sync` traits that thus support `Arc` downcasting as well. +pub trait DowncastSync: Downcast + Send + Sync { + /// Convert `Arc` (where `Trait: Downcast`) to `Arc`. `Arc` can then be + /// further `downcast` into `Arc` where `ConcreteType` implements `Trait`. + fn into_any_arc(self: ::std::sync::Arc) -> ::std::sync::Arc; +} + +impl DowncastSync for T { + fn into_any_arc(self: ::std::sync::Arc) -> ::std::sync::Arc { self } +} + +/// Adds downcasting support to traits that extend `downcast::Downcast` by defining forwarding +/// methods to the corresponding implementations on `std::any::Any` in the standard library. +/// +/// See https://users.rust-lang.org/t/how-to-create-a-macro-to-impl-a-provided-type-parametrized-trait/5289 +/// for why this is implemented this way to support templatized traits. +#[macro_export(local_inner_macros)] +macro_rules! impl_downcast { + (@impl_full + $trait_:ident [$($param_types:tt)*] + for [$($forall_types:ident),*] + where [$($preds:tt)*] + ) => { + impl_downcast! { + @inject_where + [impl<$($forall_types),*> dyn $trait_<$($param_types)*>] + types [$($forall_types),*] + where [$($preds)*] + [{ + impl_downcast! { @impl_body $trait_ [$($param_types)*] } + }] + } + }; + + (@impl_full_sync + $trait_:ident [$($param_types:tt)*] + for [$($forall_types:ident),*] + where [$($preds:tt)*] + ) => { + impl_downcast! { + @inject_where + [impl<$($forall_types),*> dyn $trait_<$($param_types)*>] + types [$($forall_types),*] + where [$($preds)*] + [{ + impl_downcast! { @impl_body $trait_ [$($param_types)*] } + impl_downcast! { @impl_body_sync $trait_ [$($param_types)*] } + }] + } + }; + + (@impl_body $trait_:ident [$($types:tt)*]) => { + /// Returns true if the trait object wraps an object of type `__T`. + #[inline] + pub fn is<__T: $trait_<$($types)*>>(&self) -> bool { + $crate::Downcast::as_any(self).is::<__T>() + } + /// Returns a boxed object from a boxed trait object if the underlying object is of type + /// `__T`. Returns the original boxed trait if it isn't. + #[inline] + pub fn downcast<__T: $trait_<$($types)*>>( + self: ::std::boxed::Box + ) -> ::std::result::Result<::std::boxed::Box<__T>, ::std::boxed::Box> { + if self.is::<__T>() { + Ok($crate::Downcast::into_any(self).downcast::<__T>().unwrap()) + } else { + Err(self) + } + } + /// Returns an `Rc`-ed object from an `Rc`-ed trait object if the underlying object is of + /// type `__T`. Returns the original `Rc`-ed trait if it isn't. + #[inline] + pub fn downcast_rc<__T: $trait_<$($types)*>>( + self: ::std::rc::Rc + ) -> ::std::result::Result<::std::rc::Rc<__T>, ::std::rc::Rc> { + if self.is::<__T>() { + Ok($crate::Downcast::into_any_rc(self).downcast::<__T>().unwrap()) + } else { + Err(self) + } + } + /// Returns a reference to the object within the trait object if it is of type `__T`, or + /// `None` if it isn't. + #[inline] + pub fn downcast_ref<__T: $trait_<$($types)*>>(&self) -> ::std::option::Option<&__T> { + $crate::Downcast::as_any(self).downcast_ref::<__T>() + } + /// Returns a mutable reference to the object within the trait object if it is of type + /// `__T`, or `None` if it isn't. + #[inline] + pub fn downcast_mut<__T: $trait_<$($types)*>>(&mut self) -> ::std::option::Option<&mut __T> { + $crate::Downcast::as_any_mut(self).downcast_mut::<__T>() + } + }; + + (@impl_body_sync $trait_:ident [$($types:tt)*]) => { + /// Returns an `Arc`-ed object from an `Arc`-ed trait object if the underlying object is of + /// type `__T`. Returns the original `Arc`-ed trait if it isn't. + #[inline] + pub fn downcast_arc<__T: $trait_<$($types)*>>( + self: ::std::sync::Arc, + ) -> ::std::result::Result<::std::sync::Arc<__T>, ::std::sync::Arc> + where __T: ::std::any::Any + ::std::marker::Send + ::std::marker::Sync + { + if self.is::<__T>() { + Ok($crate::DowncastSync::into_any_arc(self).downcast::<__T>().unwrap()) + } else { + Err(self) + } + } + }; + + (@inject_where [$($before:tt)*] types [] where [] [$($after:tt)*]) => { + impl_downcast! { @as_item $($before)* $($after)* } + }; + + (@inject_where [$($before:tt)*] types [$($types:ident),*] where [] [$($after:tt)*]) => { + impl_downcast! { + @as_item + $($before)* + where $( $types: ::std::any::Any + 'static ),* + $($after)* + } + }; + (@inject_where [$($before:tt)*] types [$($types:ident),*] where [$($preds:tt)+] [$($after:tt)*]) => { + impl_downcast! { + @as_item + $($before)* + where + $( $types: ::std::any::Any + 'static, )* + $($preds)* + $($after)* + } + }; + + (@as_item $i:item) => { $i }; + + // No type parameters. + ($trait_:ident ) => { impl_downcast! { @impl_full $trait_ [] for [] where [] } }; + ($trait_:ident <>) => { impl_downcast! { @impl_full $trait_ [] for [] where [] } }; + (sync $trait_:ident ) => { impl_downcast! { @impl_full_sync $trait_ [] for [] where [] } }; + (sync $trait_:ident <>) => { impl_downcast! { @impl_full_sync $trait_ [] for [] where [] } }; + // Type parameters. + ($trait_:ident < $($types:ident),* >) => { + impl_downcast! { @impl_full $trait_ [$($types),*] for [$($types),*] where [] } + }; + (sync $trait_:ident < $($types:ident),* >) => { + impl_downcast! { @impl_full_sync $trait_ [$($types),*] for [$($types),*] where [] } + }; + // Type parameters and where clauses. + ($trait_:ident < $($types:ident),* > where $($preds:tt)+) => { + impl_downcast! { @impl_full $trait_ [$($types),*] for [$($types),*] where [$($preds)*] } + }; + (sync $trait_:ident < $($types:ident),* > where $($preds:tt)+) => { + impl_downcast! { @impl_full_sync $trait_ [$($types),*] for [$($types),*] where [$($preds)*] } + }; + // Associated types. + ($trait_:ident assoc $($atypes:ident),*) => { + impl_downcast! { @impl_full $trait_ [$($atypes = $atypes),*] for [$($atypes),*] where [] } + }; + (sync $trait_:ident assoc $($atypes:ident),*) => { + impl_downcast! { @impl_full_sync $trait_ [$($atypes = $atypes),*] for [$($atypes),*] where [] } + }; + // Associated types and where clauses. + ($trait_:ident assoc $($atypes:ident),* where $($preds:tt)+) => { + impl_downcast! { @impl_full $trait_ [$($atypes = $atypes),*] for [$($atypes),*] where [$($preds)*] } + }; + (sync $trait_:ident assoc $($atypes:ident),* where $($preds:tt)+) => { + impl_downcast! { @impl_full_sync $trait_ [$($atypes = $atypes),*] for [$($atypes),*] where [$($preds)*] } + }; + // Type parameters and associated types. + ($trait_:ident < $($types:ident),* > assoc $($atypes:ident),*) => { + impl_downcast! { + @impl_full + $trait_ [$($types),*, $($atypes = $atypes),*] + for [$($types),*, $($atypes),*] + where [] + } + }; + (sync $trait_:ident < $($types:ident),* > assoc $($atypes:ident),*) => { + impl_downcast! { + @impl_full_sync + $trait_ [$($types),*, $($atypes = $atypes),*] + for [$($types),*, $($atypes),*] + where [] + } + }; + // Type parameters, associated types, and where clauses. + ($trait_:ident < $($types:ident),* > assoc $($atypes:ident),* where $($preds:tt)+) => { + impl_downcast! { + @impl_full + $trait_ [$($types),*, $($atypes = $atypes),*] + for [$($types),*, $($atypes),*] + where [$($preds)*] + } + }; + (sync $trait_:ident < $($types:ident),* > assoc $($atypes:ident),* where $($preds:tt)+) => { + impl_downcast! { + @impl_full_sync + $trait_ [$($types),*, $($atypes = $atypes),*] + for [$($types),*, $($atypes),*] + where [$($preds)*] + } + }; + // Concretely-parametrized types. + (concrete $trait_:ident < $($types:ident),* >) => { + impl_downcast! { @impl_full $trait_ [$($types),*] for [] where [] } + }; + (sync concrete $trait_:ident < $($types:ident),* >) => { + impl_downcast! { @impl_full_sync $trait_ [$($types),*] for [] where [] } + }; + // Concretely-associated types types. + (concrete $trait_:ident assoc $($atypes:ident = $aty:ty),*) => { + impl_downcast! { @impl_full $trait_ [$($atypes = $aty),*] for [] where [] } + }; + (sync concrete $trait_:ident assoc $($atypes:ident = $aty:ty),*) => { + impl_downcast! { @impl_full_sync $trait_ [$($atypes = $aty),*] for [] where [] } + }; + // Concretely-parametrized types with concrete associated types. + (concrete $trait_:ident < $($types:ident),* > assoc $($atypes:ident = $aty:ty),*) => { + impl_downcast! { @impl_full $trait_ [$($types),*, $($atypes = $aty),*] for [] where [] } + }; + (sync concrete $trait_:ident < $($types:ident),* > assoc $($atypes:ident = $aty:ty),*) => { + impl_downcast! { @impl_full_sync $trait_ [$($types),*, $($atypes = $aty),*] for [] where [] } + }; +} + + +#[cfg(test)] +mod test { + macro_rules! test_mod { + ( + $test_mod_name:ident, + trait $base_trait:path { $($base_impl:tt)* }, + non_sync: { $($non_sync_def:tt)+ }, + sync: { $($sync_def:tt)+ } + ) => { + test_mod! { + $test_mod_name, + trait $base_trait { $($base_impl:tt)* }, + type dyn $base_trait, + non_sync: { $($non_sync_def)* }, + sync: { $($sync_def)* } + } + }; + + ( + $test_mod_name:ident, + trait $base_trait:path { $($base_impl:tt)* }, + type $base_type:ty, + non_sync: { $($non_sync_def:tt)+ }, + sync: { $($sync_def:tt)+ } + ) => { + mod $test_mod_name { + test_mod!( + @test + $test_mod_name, + test_name: test_non_sync, + trait $base_trait { $($base_impl)* }, + type $base_type, + { $($non_sync_def)+ }, + []); + + test_mod!( + @test + $test_mod_name, + test_name: test_sync, + trait $base_trait { $($base_impl)* }, + type $base_type, + { $($sync_def)+ }, + [{ + // Fail to convert Arc into Arc. + let arc: ::std::sync::Arc<$base_type> = ::std::sync::Arc::new(Foo(42)); + let res = arc.downcast_arc::(); + assert!(res.is_err()); + let arc = res.unwrap_err(); + // Convert Arc into Arc. + assert_eq!( + 42, arc.downcast_arc::().map_err(|_| "Shouldn't happen.").unwrap().0); + }]); + } + }; + + ( + @test + $test_mod_name:ident, + test_name: $test_name:ident, + trait $base_trait:path { $($base_impl:tt)* }, + type $base_type:ty, + { $($def:tt)+ }, + [ $($more_tests:block)* ] + ) => { + #[test] + fn $test_name() { + #[allow(unused_imports)] + use super::super::{Downcast, DowncastSync}; + + // Should work even if standard objects (especially those in the prelude) are + // aliased to something else. + #[allow(dead_code)] struct Any; + #[allow(dead_code)] struct Arc; + #[allow(dead_code)] struct Box; + #[allow(dead_code)] struct Option; + #[allow(dead_code)] struct Result; + #[allow(dead_code)] struct Rc; + #[allow(dead_code)] struct Send; + #[allow(dead_code)] struct Sync; + + // A trait that can be downcast. + $($def)* + + // Concrete type implementing Base. + #[derive(Debug)] + struct Foo(u32); + impl $base_trait for Foo { $($base_impl)* } + #[derive(Debug)] + struct Bar(f64); + impl $base_trait for Bar { $($base_impl)* } + + // Functions that can work on references to Base trait objects. + fn get_val(base: &::std::boxed::Box<$base_type>) -> u32 { + match base.downcast_ref::() { + Some(val) => val.0, + None => 0 + } + } + fn set_val(base: &mut ::std::boxed::Box<$base_type>, val: u32) { + if let Some(foo) = base.downcast_mut::() { + foo.0 = val; + } + } + + let mut base: ::std::boxed::Box<$base_type> = ::std::boxed::Box::new(Foo(42)); + assert_eq!(get_val(&base), 42); + + // Try sequential downcasts. + if let Some(foo) = base.downcast_ref::() { + assert_eq!(foo.0, 42); + } else if let Some(bar) = base.downcast_ref::() { + assert_eq!(bar.0, 42.0); + } + + set_val(&mut base, 6*9); + assert_eq!(get_val(&base), 6*9); + + assert!(base.is::()); + + // Fail to convert Box into Box. + let res = base.downcast::(); + assert!(res.is_err()); + let base = res.unwrap_err(); + // Convert Box into Box. + assert_eq!( + 6*9, base.downcast::().map_err(|_| "Shouldn't happen.").unwrap().0); + + // Fail to convert Rc into Rc. + let rc: ::std::rc::Rc<$base_type> = ::std::rc::Rc::new(Foo(42)); + let res = rc.downcast_rc::(); + assert!(res.is_err()); + let rc = res.unwrap_err(); + // Convert Rc into Rc. + assert_eq!( + 42, rc.downcast_rc::().map_err(|_| "Shouldn't happen.").unwrap().0); + + $($more_tests)* + } + }; + ( + $test_mod_name:ident, + trait $base_trait:path { $($base_impl:tt)* }, + non_sync: { $($non_sync_def:tt)+ }, + sync: { $($sync_def:tt)+ } + ) => { + test_mod! { + $test_mod_name, + trait $base_trait { $($base_impl:tt)* }, + type $base_trait, + non_sync: { $($non_sync_def)* }, + sync: { $($sync_def)* } + } + }; + + } + + test_mod!(non_generic, trait Base {}, + non_sync: { + trait Base: Downcast {} + impl_downcast!(Base); + }, + sync: { + trait Base: DowncastSync {} + impl_downcast!(sync Base); + }); + + test_mod!(generic, trait Base {}, + non_sync: { + trait Base: Downcast {} + impl_downcast!(Base); + }, + sync: { + trait Base: DowncastSync {} + impl_downcast!(sync Base); + }); + + test_mod!(constrained_generic, trait Base {}, + non_sync: { + trait Base: Downcast {} + impl_downcast!(Base where T: Copy); + }, + sync: { + trait Base: DowncastSync {} + impl_downcast!(sync Base where T: Copy); + }); + + test_mod!(associated, + trait Base { type H = f32; }, + type dyn Base, + non_sync: { + trait Base: Downcast { type H; } + impl_downcast!(Base assoc H); + }, + sync: { + trait Base: DowncastSync { type H; } + impl_downcast!(sync Base assoc H); + }); + + test_mod!(constrained_associated, + trait Base { type H = f32; }, + type dyn Base, + non_sync: { + trait Base: Downcast { type H: Copy; } + impl_downcast!(Base assoc H where H: Copy); + }, + sync: { + trait Base: DowncastSync { type H: Copy; } + impl_downcast!(sync Base assoc H where H: Copy); + }); + + test_mod!(param_and_associated, + trait Base { type H = f32; }, + type dyn Base, + non_sync: { + trait Base: Downcast { type H; } + impl_downcast!(Base assoc H); + }, + sync: { + trait Base: DowncastSync { type H; } + impl_downcast!(sync Base assoc H); + }); + + test_mod!(constrained_param_and_associated, + trait Base { type H = f32; }, + type dyn Base, + non_sync: { + trait Base: Downcast { type H: Copy; } + impl_downcast!(Base assoc H where T: Clone, H: Copy); + }, + sync: { + trait Base: DowncastSync { type H: Copy; } + impl_downcast!(sync Base assoc H where T: Clone, H: Copy); + }); + + test_mod!(concrete_parametrized, trait Base {}, + non_sync: { + trait Base: Downcast {} + impl_downcast!(concrete Base); + }, + sync: { + trait Base: DowncastSync {} + impl_downcast!(sync concrete Base); + }); + + test_mod!(concrete_associated, + trait Base { type H = u32; }, + type dyn Base, + non_sync: { + trait Base: Downcast { type H; } + impl_downcast!(concrete Base assoc H=u32); + }, + sync: { + trait Base: DowncastSync { type H; } + impl_downcast!(sync concrete Base assoc H=u32); + }); + + test_mod!(concrete_parametrized_associated, + trait Base { type H = f32; }, + type dyn Base, + non_sync: { + trait Base: Downcast { type H; } + impl_downcast!(concrete Base assoc H=f32); + }, + sync: { + trait Base: DowncastSync { type H; } + impl_downcast!(sync concrete Base assoc H=f32); + }); +} diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/tests/import_via_macro_use.rs b/third_party/cargo/vendor/downcast-rs-1.1.1/tests/import_via_macro_use.rs new file mode 100644 index 0000000..fc2fab2 --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/tests/import_via_macro_use.rs @@ -0,0 +1,9 @@ +#[macro_use] +extern crate downcast_rs; + +#[test] +fn test() { + use downcast_rs::Downcast; + trait Trait: Downcast {} + impl_downcast!(Trait); +} diff --git a/third_party/cargo/vendor/downcast-rs-1.1.1/tests/use_via_namespace.rs b/third_party/cargo/vendor/downcast-rs-1.1.1/tests/use_via_namespace.rs new file mode 100644 index 0000000..19f630c --- /dev/null +++ b/third_party/cargo/vendor/downcast-rs-1.1.1/tests/use_via_namespace.rs @@ -0,0 +1,8 @@ +extern crate downcast_rs; + +#[test] +fn test() { + use downcast_rs::Downcast; + trait Trait: Downcast {} + downcast_rs::impl_downcast!(Trait); +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/.cargo-checksum.json b/third_party/cargo/vendor/env_logger-0.6.2/.cargo-checksum.json new file mode 100644 index 0000000..f4c02e3 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"7c044d74477515ab39287a4caff27eb96daebaed8b9f9b6a1d1c081a7b42d4a7","Cargo.toml":"b60137f1fd54001ca4d8be1d0bbec154225a44c8f4fa3576078bdad55216d357","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"0e231c1c4ad51ff0239062297bdaa69aeb34a8692e3f814188ce1e0ade8583d5","examples/custom_default_format.rs":"799c439f61cb711078f8aa584db537a5758c25b90d44767849dae2ad3822885c","examples/custom_format.rs":"ac8323e2febf8b8ff7238bd254fbbbfb3183da5af84f7f3a261fd9ad892c9ab6","examples/custom_logger.rs":"99fb3c9761ad4c5fe73f4ec2a2bd44b4acf6d1f7b7cfaa16bf0373665d3e2a4b","examples/default.rs":"ac96427611784d310704f738c7a29ebddd7930c8a70ad3c464c4d3eae4cf74a3","examples/direct_logger.rs":"549f6a10e0903d06aca2cc7ba82415b07a23392676101c9bc7aa72b4a9b0b9e2","examples/filters_from_code.rs":"84bd82803683d19ae96f85edcf4ee38cda028c2dbde923dddecc8563453b18e2","src/filter/mod.rs":"de471579c5db400c5ed11b9d7c9fc62686068b42798c58f7165806319ab7ec09","src/filter/regex.rs":"5fff47d1d4d0aa3f2bab90636127d3e72aebf800c3b78faba99637220ffdf865","src/filter/string.rs":"52bbd047c31a1afdb3cd1c11629b956f21b3f47bf22e06421baf3d693a045e59","src/fmt/humantime/extern_impl.rs":"cd2538e7a03fd3ad6c843af3c3d4016ca96cadaefee32cf9b37329c4787e6552","src/fmt/humantime/mod.rs":"408496eb21344c654b9e06da2a2df86de56e427147bb7f7b47851e0da976c003","src/fmt/humantime/shim_impl.rs":"7c2fdf4031f5568b716df14842b0d32bc03ff398763f4849960df7f9632a5bb2","src/fmt/mod.rs":"5104dad2fd14bc18ab6ab46e7c2bc5752b509d9fc934fb99f0ebc126728f8f04","src/fmt/writer/atty.rs":"3e9fd61d291d0919f7aa7119a26dd15d920df8783b4ae57bcf2c3cb6f3ff06b5","src/fmt/writer/mod.rs":"583f6616e0cf21955a530baa332fb7a99bf4fcd418a2367bbd1e733a06a22318","src/fmt/writer/termcolor/extern_impl.rs":"15e048be128568abcdd0ce99dafffe296df26131d4aa05921585761d31c11db5","src/fmt/writer/termcolor/mod.rs":"a3cf956aec030e0f940e4eaefe58d7703857eb900022286e328e05e5f61de183","src/fmt/writer/termcolor/shim_impl.rs":"bdd479c4e933b14ba02a3c1a9fe30eb51bcdf600e23cebd044d68683fdaad037","src/lib.rs":"2c5ab92ee141022f3e657b0f81e84e5ee4e7fad9fb648204e00ed4fb03d4166f","tests/init-twice-retains-filter.rs":"00524ce0f6779981b695bad1fdd244f87b76c126aeccd8b4ff77ef9e6325478b","tests/log-in-log.rs":"41126910998adfbac771c2a1237fecbc5437344f8e4dfc2f93235bab764a087e","tests/regexp_filter.rs":"44aa6c39de894be090e37083601e501cfffb15e3c0cd36209c48abdf3e2cb120"},"package":"aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"} \ No newline at end of file diff --git a/third_party/cargo/vendor/env_logger-0.6.2/BUILD b/third_party/cargo/vendor/env_logger-0.6.2/BUILD new file mode 100644 index 0000000..5d0eb64 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/BUILD @@ -0,0 +1,61 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "custom_default_format" with type "example" omitted +# Unsupported target "custom_format" with type "example" omitted +# Unsupported target "custom_logger" with type "example" omitted +# Unsupported target "default" with type "example" omitted +# Unsupported target "direct_logger" with type "example" omitted + +rust_library( + name = "env_logger", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/atty-0.2.14:atty", + "//third_party/cargo/vendor/humantime-1.3.0:humantime", + "//third_party/cargo/vendor/log-0.4.8:log", + "//third_party/cargo/vendor/regex-1.3.3:regex", + "//third_party/cargo/vendor/termcolor-1.1.0:termcolor", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.6.2", + crate_features = [ + "atty", + "default", + "humantime", + "regex", + "termcolor", + ], +) + +# Unsupported target "filters_from_code" with type "example" omitted +# Unsupported target "init-twice-retains-filter" with type "test" omitted +# Unsupported target "log-in-log" with type "test" omitted +# Unsupported target "regexp_filter" with type "test" omitted diff --git a/third_party/cargo/vendor/env_logger-0.6.2/CHANGELOG.md b/third_party/cargo/vendor/env_logger-0.6.2/CHANGELOG.md new file mode 100644 index 0000000..f849eef --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/CHANGELOG.md @@ -0,0 +1,3 @@ +Changes to this crate are tracked via [GitHub Releases][releases]. + +[releases]: https://github.com/sebasmagri/env_logger/releases diff --git a/third_party/cargo/vendor/env_logger-0.6.2/Cargo.toml b/third_party/cargo/vendor/env_logger-0.6.2/Cargo.toml new file mode 100644 index 0000000..1d028ba --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/Cargo.toml @@ -0,0 +1,57 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "env_logger" +version = "0.6.2" +authors = ["The Rust Project Developers"] +description = "A logging implementation for `log` which is configured via an environment\nvariable.\n" +documentation = "https://docs.rs/env_logger" +readme = "README.md" +keywords = ["logging", "log", "logger"] +categories = ["development-tools::debugging"] +license = "MIT/Apache-2.0" +repository = "https://github.com/sebasmagri/env_logger/" + +[[test]] +name = "regexp_filter" +harness = false + +[[test]] +name = "log-in-log" +harness = false + +[[test]] +name = "init-twice-retains-filter" +harness = false +[dependencies.atty] +version = "0.2.5" +optional = true + +[dependencies.humantime] +version = "1.1" +optional = true + +[dependencies.log] +version = "0.4" +features = ["std"] + +[dependencies.regex] +version = "1.0.3" +optional = true + +[dependencies.termcolor] +version = "1.0.2" +optional = true + +[features] +default = ["termcolor", "atty", "humantime", "regex"] diff --git a/third_party/cargo/vendor/env_logger-0.6.2/LICENSE-APACHE b/third_party/cargo/vendor/env_logger-0.6.2/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/env_logger-0.6.2/LICENSE-MIT b/third_party/cargo/vendor/env_logger-0.6.2/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/env_logger-0.6.2/README.md b/third_party/cargo/vendor/env_logger-0.6.2/README.md new file mode 100644 index 0000000..8dc92f1 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/README.md @@ -0,0 +1,152 @@ +env_logger [![Build Status](https://travis-ci.org/sebasmagri/env_logger.svg?branch=master)](https://travis-ci.org/sebasmagri/env_logger) [![Maintenance](https://img.shields.io/badge/maintenance-actively%20maintained-brightgreen.svg)](https://github.com/sebasmagri/env_logger) [![crates.io](https://img.shields.io/crates/v/env_logger.svg)](https://crates.io/crates/env_logger) [![Documentation](https://img.shields.io/badge/docs-current-blue.svg)](https://docs.rs/env_logger) +========== + +Implements a logger that can be configured via environment variables. + +## Usage + +### In libraries + +`env_logger` makes sense when used in executables (binary projects). Libraries should use the [`log`](https://doc.rust-lang.org/log) crate instead. + +### In executables + +It must be added along with `log` to the project dependencies: + +```toml +[dependencies] +log = "0.4.0" +env_logger = "0.6.2" +``` + +`env_logger` must be initialized as early as possible in the project. After it's initialized, you can use the `log` macros to do actual logging. + +```rust +#[macro_use] +extern crate log; +extern crate env_logger; + +fn main() { + env_logger::init(); + + info!("starting up"); + + // ... +} +``` + +Then when running the executable, specify a value for the `RUST_LOG` +environment variable that corresponds with the log messages you want to show. + +```bash +$ RUST_LOG=info ./main +[2018-11-03T06:09:06Z INFO default] starting up +``` + +`env_logger` can be configured in other ways besides an environment variable. See [the examples](https://github.com/sebasmagri/env_logger/tree/master/examples) for more approaches. + +### In tests + +Tests can use the `env_logger` crate to see log messages generated during that test: + +```toml +[dependencies] +log = "0.4.0" + +[dev-dependencies] +env_logger = "0.6.2" +``` + +```rust +#[macro_use] +extern crate log; + +fn add_one(num: i32) -> i32 { + info!("add_one called with {}", num); + num + 1 +} + +#[cfg(test)] +mod tests { + use super::*; + extern crate env_logger; + + fn init() { + let _ = env_logger::builder().is_test(true).try_init(); + } + + #[test] + fn it_adds_one() { + init(); + + info!("can log from the test too"); + assert_eq!(3, add_one(2)); + } + + #[test] + fn it_handles_negative_numbers() { + init(); + + info!("logging from another test"); + assert_eq!(-7, add_one(-8)); + } +} +``` + +Assuming the module under test is called `my_lib`, running the tests with the +`RUST_LOG` filtering to info messages from this module looks like: + +```bash +$ RUST_LOG=my_lib=info cargo test + Running target/debug/my_lib-... + +running 2 tests +[INFO my_lib::tests] logging from another test +[INFO my_lib] add_one called with -8 +test tests::it_handles_negative_numbers ... ok +[INFO my_lib::tests] can log from the test too +[INFO my_lib] add_one called with 2 +test tests::it_adds_one ... ok + +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured +``` + +Note that `env_logger::try_init()` needs to be called in each test in which you +want to enable logging. Additionally, the default behavior of tests to +run in parallel means that logging output may be interleaved with test output. +Either run tests in a single thread by specifying `RUST_TEST_THREADS=1` or by +running one test by specifying its name as an argument to the test binaries as +directed by the `cargo test` help docs: + +```bash +$ RUST_LOG=my_lib=info cargo test it_adds_one + Running target/debug/my_lib-... + +running 1 test +[INFO my_lib::tests] can log from the test too +[INFO my_lib] add_one called with 2 +test tests::it_adds_one ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured +``` + +## Configuring log target + +By default, `env_logger` logs to stderr. If you want to log to stdout instead, +you can use the `Builder` to change the log target: + +```rust +use std::env; +use env_logger::{Builder, Target}; + +let mut builder = Builder::from_default_env(); +builder.target(Target::Stdout); + +builder.init(); +``` + +## Stability of the default format + +The default format won't optimise for long-term stability, and explicitly makes no guarantees about the stability of its output across major, minor or patch version bumps during `0.x`. + +If you want to capture or interpret the output of `env_logger` programmatically then you should use a custom format. diff --git a/third_party/cargo/vendor/env_logger-0.6.2/examples/custom_default_format.rs b/third_party/cargo/vendor/env_logger-0.6.2/examples/custom_default_format.rs new file mode 100644 index 0000000..d1a45b6 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/examples/custom_default_format.rs @@ -0,0 +1,44 @@ +/*! +Disabling parts of the default format. + +Before running this example, try setting the `MY_LOG_LEVEL` environment variable to `info`: + +```no_run,shell +$ export MY_LOG_LEVEL='info' +``` + +Also try setting the `MY_LOG_STYLE` environment variable to `never` to disable colors +or `auto` to enable them: + +```no_run,shell +$ export MY_LOG_STYLE=never +``` + +If you want to control the logging output completely, see the `custom_logger` example. +*/ + +#[macro_use] +extern crate log; +extern crate env_logger; + +use env_logger::{Env, Builder}; + +fn init_logger() { + let env = Env::default() + .filter("MY_LOG_LEVEL") + .write_style("MY_LOG_STYLE"); + + let mut builder = Builder::from_env(env); + + builder + .default_format_level(false) + .default_format_timestamp_nanos(true); + + builder.init(); +} + +fn main() { + init_logger(); + + info!("a log from `MyLogger`"); +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/examples/custom_format.rs b/third_party/cargo/vendor/env_logger-0.6.2/examples/custom_format.rs new file mode 100644 index 0000000..c4563f5 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/examples/custom_format.rs @@ -0,0 +1,54 @@ +/*! +Changing the default logging format. + +Before running this example, try setting the `MY_LOG_LEVEL` environment variable to `info`: + +```no_run,shell +$ export MY_LOG_LEVEL='info' +``` + +Also try setting the `MY_LOG_STYLE` environment variable to `never` to disable colors +or `auto` to enable them: + +```no_run,shell +$ export MY_LOG_STYLE=never +``` + +If you want to control the logging output completely, see the `custom_logger` example. +*/ + +#[macro_use] +extern crate log; +extern crate env_logger; + +use std::io::Write; + +use env_logger::{Env, Builder, fmt}; + +fn init_logger() { + let env = Env::default() + .filter("MY_LOG_LEVEL") + .write_style("MY_LOG_STYLE"); + + let mut builder = Builder::from_env(env); + + // Use a different format for writing log records + // The colors are only available when the `termcolor` dependency is (which it is by default) + #[cfg(feature = "termcolor")] + builder.format(|buf, record| { + let mut style = buf.style(); + style.set_bg(fmt::Color::Yellow).set_bold(true); + + let timestamp = buf.timestamp(); + + writeln!(buf, "My formatted log ({}): {}", timestamp, style.value(record.args())) + }); + + builder.init(); +} + +fn main() { + init_logger(); + + info!("a log from `MyLogger`"); +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/examples/custom_logger.rs b/third_party/cargo/vendor/env_logger-0.6.2/examples/custom_logger.rs new file mode 100644 index 0000000..792c9c8 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/examples/custom_logger.rs @@ -0,0 +1,60 @@ +/*! +Using `env_logger` to drive a custom logger. + +Before running this example, try setting the `MY_LOG_LEVEL` environment variable to `info`: + +```no_run,shell +$ export MY_LOG_LEVEL='info' +``` + +If you only want to change the way logs are formatted, look at the `custom_format` example. +*/ + +#[macro_use] +extern crate log; +extern crate env_logger; +use env_logger::filter::Filter; +use log::{Log, Metadata, Record, SetLoggerError}; + +struct MyLogger { + inner: Filter +} + +impl MyLogger { + fn new() -> MyLogger { + use env_logger::filter::Builder; + let mut builder = Builder::from_env("MY_LOG_LEVEL"); + + MyLogger { + inner: builder.build() + } + } + + fn init() -> Result<(), SetLoggerError> { + let logger = Self::new(); + + log::set_max_level(logger.inner.filter()); + log::set_boxed_logger(Box::new(logger)) + } +} + +impl Log for MyLogger { + fn enabled(&self, metadata: &Metadata) -> bool { + self.inner.enabled(metadata) + } + + fn log(&self, record: &Record) { + // Check if the record is matched by the logger before logging + if self.inner.matches(record) { + println!("{} - {}", record.level(), record.args()); + } + } + + fn flush(&self) { } +} + +fn main() { + MyLogger::init().unwrap(); + + info!("a log from `MyLogger`"); +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/examples/default.rs b/third_party/cargo/vendor/env_logger-0.6.2/examples/default.rs new file mode 100644 index 0000000..302e38a --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/examples/default.rs @@ -0,0 +1,39 @@ +/*! +Using `env_logger`. + +Before running this example, try setting the `MY_LOG_LEVEL` environment variable to `info`: + +```no_run,shell +$ export MY_LOG_LEVEL='info' +``` + +Also try setting the `MY_LOG_STYLE` environment variable to `never` to disable colors +or `auto` to enable them: + +```no_run,shell +$ export MY_LOG_STYLE=never +``` +*/ + +#[macro_use] +extern crate log; +extern crate env_logger; + +use env_logger::Env; + +fn main() { + // The `Env` lets us tweak what the environment + // variables to read are and what the default + // value is if they're missing + let env = Env::default() + .filter_or("MY_LOG_LEVEL", "trace") + .write_style_or("MY_LOG_STYLE", "always"); + + env_logger::init_from_env(env); + + trace!("some trace log"); + debug!("some debug log"); + info!("some information log"); + warn!("some warning log"); + error!("some error log"); +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/examples/direct_logger.rs b/third_party/cargo/vendor/env_logger-0.6.2/examples/direct_logger.rs new file mode 100644 index 0000000..410230b --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/examples/direct_logger.rs @@ -0,0 +1,40 @@ +/*! +Using `env_logger::Logger` and the `log::Log` trait directly. + +This example doesn't rely on environment variables, or having a static logger installed. +*/ + +extern crate log; +extern crate env_logger; + +fn record() -> log::Record<'static> { + let error_metadata = log::MetadataBuilder::new() + .target("myApp") + .level(log::Level::Error) + .build(); + + log::Record::builder() + .metadata(error_metadata) + .args(format_args!("Error!")) + .line(Some(433)) + .file(Some("app.rs")) + .module_path(Some("server")) + .build() +} + +fn main() { + use log::Log; + + let stylish_logger = env_logger::Builder::new() + .filter(None, log::LevelFilter::Error) + .write_style(env_logger::WriteStyle::Always) + .build(); + + let unstylish_logger = env_logger::Builder::new() + .filter(None, log::LevelFilter::Error) + .write_style(env_logger::WriteStyle::Never) + .build(); + + stylish_logger.log(&record()); + unstylish_logger.log(&record()); +} \ No newline at end of file diff --git a/third_party/cargo/vendor/env_logger-0.6.2/examples/filters_from_code.rs b/third_party/cargo/vendor/env_logger-0.6.2/examples/filters_from_code.rs new file mode 100644 index 0000000..ef5b969 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/examples/filters_from_code.rs @@ -0,0 +1,19 @@ +/*! +Specify logging filters in code instead of using an environment variable. +*/ + +#[macro_use] +extern crate log; +extern crate env_logger; + +fn main() { + env_logger::builder() + .filter_level(log::LevelFilter::Trace) + .init(); + + trace!("some trace log"); + debug!("some debug log"); + info!("some information log"); + warn!("some warning log"); + error!("some error log"); +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/filter/mod.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/filter/mod.rs new file mode 100644 index 0000000..a0fe6a2 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/filter/mod.rs @@ -0,0 +1,579 @@ +//! Filtering for log records. +//! +//! This module contains the log filtering used by `env_logger` to match records. +//! You can use the `Filter` type in your own logger implementation to use the same +//! filter parsing and matching as `env_logger`. For more details about the format +//! for directive strings see [Enabling Logging]. +//! +//! ## Using `env_logger` in your own logger +//! +//! You can use `env_logger`'s filtering functionality with your own logger. +//! Call [`Builder::parse`] to parse directives from a string when constructing +//! your logger. Call [`Filter::matches`] to check whether a record should be +//! logged based on the parsed filters when log records are received. +//! +//! ``` +//! extern crate log; +//! extern crate env_logger; +//! use env_logger::filter::Filter; +//! use log::{Log, Metadata, Record}; +//! +//! struct MyLogger { +//! filter: Filter +//! } +//! +//! impl MyLogger { +//! fn new() -> MyLogger { +//! use env_logger::filter::Builder; +//! let mut builder = Builder::new(); +//! +//! // Parse a directives string from an environment variable +//! if let Ok(ref filter) = std::env::var("MY_LOG_LEVEL") { +//! builder.parse(filter); +//! } +//! +//! MyLogger { +//! filter: builder.build() +//! } +//! } +//! } +//! +//! impl Log for MyLogger { +//! fn enabled(&self, metadata: &Metadata) -> bool { +//! self.filter.enabled(metadata) +//! } +//! +//! fn log(&self, record: &Record) { +//! // Check if the record is matched by the filter +//! if self.filter.matches(record) { +//! println!("{:?}", record); +//! } +//! } +//! +//! fn flush(&self) {} +//! } +//! # fn main() {} +//! ``` +//! +//! [Enabling Logging]: ../index.html#enabling-logging +//! [`Builder::parse`]: struct.Builder.html#method.parse +//! [`Filter::matches`]: struct.Filter.html#method.matches + +use std::env; +use std::mem; +use std::fmt; +use log::{Level, LevelFilter, Record, Metadata}; + +#[cfg(feature = "regex")] +#[path = "regex.rs"] +mod inner; + +#[cfg(not(feature = "regex"))] +#[path = "string.rs"] +mod inner; + +/// A log filter. +/// +/// This struct can be used to determine whether or not a log record +/// should be written to the output. +/// Use the [`Builder`] type to parse and construct a `Filter`. +/// +/// [`Builder`]: struct.Builder.html +pub struct Filter { + directives: Vec, + filter: Option, +} + +/// A builder for a log filter. +/// +/// It can be used to parse a set of directives from a string before building +/// a [`Filter`] instance. +/// +/// ## Example +/// +/// ``` +/// #[macro_use] +/// extern crate log; +/// extern crate env_logger; +/// +/// use std::env; +/// use std::io; +/// use env_logger::filter::Builder; +/// +/// fn main() { +/// let mut builder = Builder::new(); +/// +/// // Parse a logging filter from an environment variable. +/// if let Ok(rust_log) = env::var("RUST_LOG") { +/// builder.parse(&rust_log); +/// } +/// +/// let filter = builder.build(); +/// } +/// ``` +/// +/// [`Filter`]: struct.Filter.html +pub struct Builder { + directives: Vec, + filter: Option, + built: bool, +} + +#[derive(Debug)] +struct Directive { + name: Option, + level: LevelFilter, +} + +impl Filter { + /// Returns the maximum `LevelFilter` that this filter instance is + /// configured to output. + /// + /// # Example + /// + /// ```rust + /// extern crate log; + /// extern crate env_logger; + /// + /// use log::LevelFilter; + /// use env_logger::filter::Builder; + /// + /// fn main() { + /// let mut builder = Builder::new(); + /// builder.filter(Some("module1"), LevelFilter::Info); + /// builder.filter(Some("module2"), LevelFilter::Error); + /// + /// let filter = builder.build(); + /// assert_eq!(filter.filter(), LevelFilter::Info); + /// } + /// ``` + pub fn filter(&self) -> LevelFilter { + self.directives.iter() + .map(|d| d.level) + .max() + .unwrap_or(LevelFilter::Off) + } + + /// Checks if this record matches the configured filter. + pub fn matches(&self, record: &Record) -> bool { + if !self.enabled(record.metadata()) { + return false; + } + + if let Some(filter) = self.filter.as_ref() { + if !filter.is_match(&*record.args().to_string()) { + return false; + } + } + + true + } + + /// Determines if a log message with the specified metadata would be logged. + pub fn enabled(&self, metadata: &Metadata) -> bool { + let level = metadata.level(); + let target = metadata.target(); + + enabled(&self.directives, level, target) + } +} + +impl Builder { + /// Initializes the filter builder with defaults. + pub fn new() -> Builder { + Builder { + directives: Vec::new(), + filter: None, + built: false, + } + } + + /// Initializes the filter builder from an environment. + pub fn from_env(env: &str) -> Builder { + let mut builder = Builder::new(); + + if let Ok(s) = env::var(env) { + builder.parse(&s); + } + + builder + } + + /// Adds a directive to the filter for a specific module. + pub fn filter_module(&mut self, module: &str, level: LevelFilter) -> &mut Self { + self.filter(Some(module), level) + } + + /// Adds a directive to the filter for all modules. + pub fn filter_level(&mut self, level: LevelFilter) -> &mut Self { + self.filter(None, level) + } + + /// Adds a directive to the filter. + /// + /// The given module (if any) will log at most the specified level provided. + /// If no module is provided then the filter will apply to all log messages. + pub fn filter(&mut self, + module: Option<&str>, + level: LevelFilter) -> &mut Self { + self.directives.push(Directive { + name: module.map(|s| s.to_string()), + level, + }); + self + } + + /// Parses the directives string. + /// + /// See the [Enabling Logging] section for more details. + /// + /// [Enabling Logging]: ../index.html#enabling-logging + pub fn parse(&mut self, filters: &str) -> &mut Self { + let (directives, filter) = parse_spec(filters); + + self.filter = filter; + + for directive in directives { + self.directives.push(directive); + } + self + } + + /// Build a log filter. + pub fn build(&mut self) -> Filter { + assert!(!self.built, "attempt to re-use consumed builder"); + self.built = true; + + if self.directives.is_empty() { + // Adds the default filter if none exist + self.directives.push(Directive { + name: None, + level: LevelFilter::Error, + }); + } else { + // Sort the directives by length of their name, this allows a + // little more efficient lookup at runtime. + self.directives.sort_by(|a, b| { + let alen = a.name.as_ref().map(|a| a.len()).unwrap_or(0); + let blen = b.name.as_ref().map(|b| b.len()).unwrap_or(0); + alen.cmp(&blen) + }); + } + + Filter { + directives: mem::replace(&mut self.directives, Vec::new()), + filter: mem::replace(&mut self.filter, None), + } + } +} + +impl Default for Builder { + fn default() -> Self { + Builder::new() + } +} + +impl fmt::Debug for Filter { + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + f.debug_struct("Filter") + .field("filter", &self.filter) + .field("directives", &self.directives) + .finish() + } +} + +impl fmt::Debug for Builder { + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + if self.built { + f.debug_struct("Filter") + .field("built", &true) + .finish() + } else { + f.debug_struct("Filter") + .field("filter", &self.filter) + .field("directives", &self.directives) + .finish() + } + } +} + +/// Parse a logging specification string (e.g: "crate1,crate2::mod3,crate3::x=error/foo") +/// and return a vector with log directives. +fn parse_spec(spec: &str) -> (Vec, Option) { + let mut dirs = Vec::new(); + + let mut parts = spec.split('/'); + let mods = parts.next(); + let filter = parts.next(); + if parts.next().is_some() { + eprintln!("warning: invalid logging spec '{}', \ + ignoring it (too many '/'s)", spec); + return (dirs, None); + } + mods.map(|m| { for s in m.split(',') { + if s.len() == 0 { continue } + let mut parts = s.split('='); + let (log_level, name) = match (parts.next(), parts.next().map(|s| s.trim()), parts.next()) { + (Some(part0), None, None) => { + // if the single argument is a log-level string or number, + // treat that as a global fallback + match part0.parse() { + Ok(num) => (num, None), + Err(_) => (LevelFilter::max(), Some(part0)), + } + } + (Some(part0), Some(""), None) => (LevelFilter::max(), Some(part0)), + (Some(part0), Some(part1), None) => { + match part1.parse() { + Ok(num) => (num, Some(part0)), + _ => { + eprintln!("warning: invalid logging spec '{}', \ + ignoring it", part1); + continue + } + } + }, + _ => { + eprintln!("warning: invalid logging spec '{}', \ + ignoring it", s); + continue + } + }; + dirs.push(Directive { + name: name.map(|s| s.to_string()), + level: log_level, + }); + }}); + + let filter = filter.map_or(None, |filter| { + match inner::Filter::new(filter) { + Ok(re) => Some(re), + Err(e) => { + eprintln!("warning: invalid regex filter - {}", e); + None + } + } + }); + + return (dirs, filter); +} + + +// Check whether a level and target are enabled by the set of directives. +fn enabled(directives: &[Directive], level: Level, target: &str) -> bool { + // Search for the longest match, the vector is assumed to be pre-sorted. + for directive in directives.iter().rev() { + match directive.name { + Some(ref name) if !target.starts_with(&**name) => {}, + Some(..) | None => { + return level <= directive.level + } + } + } + false +} + +#[cfg(test)] +mod tests { + use log::{Level, LevelFilter}; + + use super::{Builder, Filter, Directive, parse_spec, enabled}; + + fn make_logger_filter(dirs: Vec) -> Filter { + let mut logger = Builder::new().build(); + logger.directives = dirs; + logger + } + + #[test] + fn filter_info() { + let logger = Builder::new().filter(None, LevelFilter::Info).build(); + assert!(enabled(&logger.directives, Level::Info, "crate1")); + assert!(!enabled(&logger.directives, Level::Debug, "crate1")); + } + + #[test] + fn filter_beginning_longest_match() { + let logger = Builder::new() + .filter(Some("crate2"), LevelFilter::Info) + .filter(Some("crate2::mod"), LevelFilter::Debug) + .filter(Some("crate1::mod1"), LevelFilter::Warn) + .build(); + assert!(enabled(&logger.directives, Level::Debug, "crate2::mod1")); + assert!(!enabled(&logger.directives, Level::Debug, "crate2")); + } + + #[test] + fn parse_default() { + let logger = Builder::new().parse("info,crate1::mod1=warn").build(); + assert!(enabled(&logger.directives, Level::Warn, "crate1::mod1")); + assert!(enabled(&logger.directives, Level::Info, "crate2::mod2")); + } + + #[test] + fn match_full_path() { + let logger = make_logger_filter(vec![ + Directive { + name: Some("crate2".to_string()), + level: LevelFilter::Info + }, + Directive { + name: Some("crate1::mod1".to_string()), + level: LevelFilter::Warn + } + ]); + assert!(enabled(&logger.directives, Level::Warn, "crate1::mod1")); + assert!(!enabled(&logger.directives, Level::Info, "crate1::mod1")); + assert!(enabled(&logger.directives, Level::Info, "crate2")); + assert!(!enabled(&logger.directives, Level::Debug, "crate2")); + } + + #[test] + fn no_match() { + let logger = make_logger_filter(vec![ + Directive { name: Some("crate2".to_string()), level: LevelFilter::Info }, + Directive { name: Some("crate1::mod1".to_string()), level: LevelFilter::Warn } + ]); + assert!(!enabled(&logger.directives, Level::Warn, "crate3")); + } + + #[test] + fn match_beginning() { + let logger = make_logger_filter(vec![ + Directive { name: Some("crate2".to_string()), level: LevelFilter::Info }, + Directive { name: Some("crate1::mod1".to_string()), level: LevelFilter::Warn } + ]); + assert!(enabled(&logger.directives, Level::Info, "crate2::mod1")); + } + + #[test] + fn match_beginning_longest_match() { + let logger = make_logger_filter(vec![ + Directive { name: Some("crate2".to_string()), level: LevelFilter::Info }, + Directive { name: Some("crate2::mod".to_string()), level: LevelFilter::Debug }, + Directive { name: Some("crate1::mod1".to_string()), level: LevelFilter::Warn } + ]); + assert!(enabled(&logger.directives, Level::Debug, "crate2::mod1")); + assert!(!enabled(&logger.directives, Level::Debug, "crate2")); + } + + #[test] + fn match_default() { + let logger = make_logger_filter(vec![ + Directive { name: None, level: LevelFilter::Info }, + Directive { name: Some("crate1::mod1".to_string()), level: LevelFilter::Warn } + ]); + assert!(enabled(&logger.directives, Level::Warn, "crate1::mod1")); + assert!(enabled(&logger.directives, Level::Info, "crate2::mod2")); + } + + #[test] + fn zero_level() { + let logger = make_logger_filter(vec![ + Directive { name: None, level: LevelFilter::Info }, + Directive { name: Some("crate1::mod1".to_string()), level: LevelFilter::Off } + ]); + assert!(!enabled(&logger.directives, Level::Error, "crate1::mod1")); + assert!(enabled(&logger.directives, Level::Info, "crate2::mod2")); + } + + #[test] + fn parse_spec_valid() { + let (dirs, filter) = parse_spec("crate1::mod1=error,crate1::mod2,crate2=debug"); + assert_eq!(dirs.len(), 3); + assert_eq!(dirs[0].name, Some("crate1::mod1".to_string())); + assert_eq!(dirs[0].level, LevelFilter::Error); + + assert_eq!(dirs[1].name, Some("crate1::mod2".to_string())); + assert_eq!(dirs[1].level, LevelFilter::max()); + + assert_eq!(dirs[2].name, Some("crate2".to_string())); + assert_eq!(dirs[2].level, LevelFilter::Debug); + assert!(filter.is_none()); + } + + #[test] + fn parse_spec_invalid_crate() { + // test parse_spec with multiple = in specification + let (dirs, filter) = parse_spec("crate1::mod1=warn=info,crate2=debug"); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate2".to_string())); + assert_eq!(dirs[0].level, LevelFilter::Debug); + assert!(filter.is_none()); + } + + #[test] + fn parse_spec_invalid_level() { + // test parse_spec with 'noNumber' as log level + let (dirs, filter) = parse_spec("crate1::mod1=noNumber,crate2=debug"); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate2".to_string())); + assert_eq!(dirs[0].level, LevelFilter::Debug); + assert!(filter.is_none()); + } + + #[test] + fn parse_spec_string_level() { + // test parse_spec with 'warn' as log level + let (dirs, filter) = parse_spec("crate1::mod1=wrong,crate2=warn"); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate2".to_string())); + assert_eq!(dirs[0].level, LevelFilter::Warn); + assert!(filter.is_none()); + } + + #[test] + fn parse_spec_empty_level() { + // test parse_spec with '' as log level + let (dirs, filter) = parse_spec("crate1::mod1=wrong,crate2="); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate2".to_string())); + assert_eq!(dirs[0].level, LevelFilter::max()); + assert!(filter.is_none()); + } + + #[test] + fn parse_spec_global() { + // test parse_spec with no crate + let (dirs, filter) = parse_spec("warn,crate2=debug"); + assert_eq!(dirs.len(), 2); + assert_eq!(dirs[0].name, None); + assert_eq!(dirs[0].level, LevelFilter::Warn); + assert_eq!(dirs[1].name, Some("crate2".to_string())); + assert_eq!(dirs[1].level, LevelFilter::Debug); + assert!(filter.is_none()); + } + + #[test] + fn parse_spec_valid_filter() { + let (dirs, filter) = parse_spec("crate1::mod1=error,crate1::mod2,crate2=debug/abc"); + assert_eq!(dirs.len(), 3); + assert_eq!(dirs[0].name, Some("crate1::mod1".to_string())); + assert_eq!(dirs[0].level, LevelFilter::Error); + + assert_eq!(dirs[1].name, Some("crate1::mod2".to_string())); + assert_eq!(dirs[1].level, LevelFilter::max()); + + assert_eq!(dirs[2].name, Some("crate2".to_string())); + assert_eq!(dirs[2].level, LevelFilter::Debug); + assert!(filter.is_some() && filter.unwrap().to_string() == "abc"); + } + + #[test] + fn parse_spec_invalid_crate_filter() { + let (dirs, filter) = parse_spec("crate1::mod1=error=warn,crate2=debug/a.c"); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate2".to_string())); + assert_eq!(dirs[0].level, LevelFilter::Debug); + assert!(filter.is_some() && filter.unwrap().to_string() == "a.c"); + } + + #[test] + fn parse_spec_empty_with_filter() { + let (dirs, filter) = parse_spec("crate1/a*c"); + assert_eq!(dirs.len(), 1); + assert_eq!(dirs[0].name, Some("crate1".to_string())); + assert_eq!(dirs[0].level, LevelFilter::max()); + assert!(filter.is_some() && filter.unwrap().to_string() == "a*c"); + } +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/filter/regex.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/filter/regex.rs new file mode 100644 index 0000000..a042654 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/filter/regex.rs @@ -0,0 +1,29 @@ +extern crate regex; + +use std::fmt; + +use self::regex::Regex; + +#[derive(Debug)] +pub struct Filter { + inner: Regex, +} + +impl Filter { + pub fn new(spec: &str) -> Result { + match Regex::new(spec){ + Ok(r) => Ok(Filter { inner: r }), + Err(e) => Err(e.to_string()), + } + } + + pub fn is_match(&self, s: &str) -> bool { + self.inner.is_match(s) + } +} + +impl fmt::Display for Filter { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/filter/string.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/filter/string.rs new file mode 100644 index 0000000..96d7ecc --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/filter/string.rs @@ -0,0 +1,22 @@ +use std::fmt; + +#[derive(Debug)] +pub struct Filter { + inner: String, +} + +impl Filter { + pub fn new(spec: &str) -> Result { + Ok(Filter { inner: spec.to_string() }) + } + + pub fn is_match(&self, s: &str) -> bool { + s.contains(&self.inner) + } +} + +impl fmt::Display for Filter { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/humantime/extern_impl.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/humantime/extern_impl.rs new file mode 100644 index 0000000..596a281 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/humantime/extern_impl.rs @@ -0,0 +1,84 @@ +use std::fmt; +use std::time::SystemTime; + +use humantime::{format_rfc3339_nanos, format_rfc3339_seconds}; + +use ::fmt::Formatter; + +pub(in ::fmt) mod glob { + pub use super::*; +} + +impl Formatter { + /// Get a [`Timestamp`] for the current date and time in UTC. + /// + /// # Examples + /// + /// Include the current timestamp with the log record: + /// + /// ``` + /// use std::io::Write; + /// + /// let mut builder = env_logger::Builder::new(); + /// + /// builder.format(|buf, record| { + /// let ts = buf.timestamp(); + /// + /// writeln!(buf, "{}: {}: {}", ts, record.level(), record.args()) + /// }); + /// ``` + /// + /// [`Timestamp`]: struct.Timestamp.html + pub fn timestamp(&self) -> Timestamp { + Timestamp(SystemTime::now()) + } + + /// Get a [`PreciseTimestamp`] for the current date and time in UTC with nanos. + pub fn precise_timestamp(&self) -> PreciseTimestamp { + PreciseTimestamp(SystemTime::now()) + } +} + +/// An [RFC3339] formatted timestamp. +/// +/// The timestamp implements [`Display`] and can be written to a [`Formatter`]. +/// +/// [RFC3339]: https://www.ietf.org/rfc/rfc3339.txt +/// [`Display`]: https://doc.rust-lang.org/stable/std/fmt/trait.Display.html +/// [`Formatter`]: struct.Formatter.html +pub struct Timestamp(SystemTime); + +/// An [RFC3339] formatted timestamp with nanos. +/// +/// [RFC3339]: https://www.ietf.org/rfc/rfc3339.txt +#[derive(Debug)] +pub struct PreciseTimestamp(SystemTime); + +impl fmt::Debug for Timestamp { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// A `Debug` wrapper for `Timestamp` that uses the `Display` implementation. + struct TimestampValue<'a>(&'a Timestamp); + + impl<'a> fmt::Debug for TimestampValue<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.0, f) + } + } + + f.debug_tuple("Timestamp") + .field(&TimestampValue(&self)) + .finish() + } +} + +impl fmt::Display for Timestamp { + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + format_rfc3339_seconds(self.0).fmt(f) + } +} + +impl fmt::Display for PreciseTimestamp { + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + format_rfc3339_nanos(self.0).fmt(f) + } +} \ No newline at end of file diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/humantime/mod.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/humantime/mod.rs new file mode 100644 index 0000000..c4f7599 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/humantime/mod.rs @@ -0,0 +1,11 @@ +/* +This internal module contains the timestamp implementation. + +Its public API is available when the `humantime` crate is available. +*/ + +#[cfg_attr(feature = "humantime", path = "extern_impl.rs")] +#[cfg_attr(not(feature = "humantime"), path = "shim_impl.rs")] +mod imp; + +pub(in ::fmt) use self::imp::*; diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/humantime/shim_impl.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/humantime/shim_impl.rs new file mode 100644 index 0000000..0f75340 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/humantime/shim_impl.rs @@ -0,0 +1,7 @@ +/* +Timestamps aren't available when we don't have a `humantime` dependency. +*/ + +pub(in ::fmt) mod glob { + +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/mod.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/mod.rs new file mode 100644 index 0000000..3f3d497 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/mod.rs @@ -0,0 +1,358 @@ +//! Formatting for log records. +//! +//! This module contains a [`Formatter`] that can be used to format log records +//! into without needing temporary allocations. Usually you won't need to worry +//! about the contents of this module and can use the `Formatter` like an ordinary +//! [`Write`]. +//! +//! # Formatting log records +//! +//! The format used to print log records can be customised using the [`Builder::format`] +//! method. +//! Custom formats can apply different color and weight to printed values using +//! [`Style`] builders. +//! +//! ``` +//! use std::io::Write; +//! +//! let mut builder = env_logger::Builder::new(); +//! +//! builder.format(|buf, record| { +//! writeln!(buf, "{}: {}", +//! record.level(), +//! record.args()) +//! }); +//! ``` +//! +//! [`Formatter`]: struct.Formatter.html +//! [`Style`]: struct.Style.html +//! [`Builder::format`]: ../struct.Builder.html#method.format +//! [`Write`]: https://doc.rust-lang.org/stable/std/io/trait.Write.html + +use std::io::prelude::*; +use std::{io, fmt, mem}; +use std::rc::Rc; +use std::cell::RefCell; +use std::fmt::Display; + +use log::Record; + +pub(crate) mod writer; +mod humantime; + +pub use self::humantime::glob::*; +pub use self::writer::glob::*; + +use self::writer::{Writer, Buffer}; + +pub(crate) mod glob { + pub use super::{Target, WriteStyle}; +} + +/// A formatter to write logs into. +/// +/// `Formatter` implements the standard [`Write`] trait for writing log records. +/// It also supports terminal colors, through the [`style`] method. +/// +/// # Examples +/// +/// Use the [`writeln`] macro to format a log record. +/// An instance of a `Formatter` is passed to an `env_logger` format as `buf`: +/// +/// ``` +/// use std::io::Write; +/// +/// let mut builder = env_logger::Builder::new(); +/// +/// builder.format(|buf, record| writeln!(buf, "{}: {}", record.level(), record.args())); +/// ``` +/// +/// [`Write`]: https://doc.rust-lang.org/stable/std/io/trait.Write.html +/// [`writeln`]: https://doc.rust-lang.org/stable/std/macro.writeln.html +/// [`style`]: #method.style +pub struct Formatter { + buf: Rc>, + write_style: WriteStyle, +} + +impl Formatter { + pub(crate) fn new(writer: &Writer) -> Self { + Formatter { + buf: Rc::new(RefCell::new(writer.buffer())), + write_style: writer.write_style(), + } + } + + pub(crate) fn write_style(&self) -> WriteStyle { + self.write_style + } + + pub(crate) fn print(&self, writer: &Writer) -> io::Result<()> { + writer.print(&self.buf.borrow()) + } + + pub(crate) fn clear(&mut self) { + self.buf.borrow_mut().clear() + } +} + +impl Write for Formatter { + fn write(&mut self, buf: &[u8]) -> io::Result { + self.buf.borrow_mut().write(buf) + } + + fn flush(&mut self) -> io::Result<()> { + self.buf.borrow_mut().flush() + } +} + +impl fmt::Debug for Formatter { + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + f.debug_struct("Formatter").finish() + } +} + +pub(crate) struct Builder { + pub default_format_timestamp: bool, + pub default_format_timestamp_nanos: bool, + pub default_format_module_path: bool, + pub default_format_level: bool, + #[allow(unknown_lints, bare_trait_objects)] + pub custom_format: Option io::Result<()> + Sync + Send>>, + built: bool, +} + +impl Default for Builder { + fn default() -> Self { + Builder { + default_format_timestamp: true, + default_format_timestamp_nanos: false, + default_format_module_path: true, + default_format_level: true, + custom_format: None, + built: false, + } + } +} + +impl Builder { + /// Convert the format into a callable function. + /// + /// If the `custom_format` is `Some`, then any `default_format` switches are ignored. + /// If the `custom_format` is `None`, then a default format is returned. + /// Any `default_format` switches set to `false` won't be written by the format. + #[allow(unknown_lints, bare_trait_objects)] + pub fn build(&mut self) -> Box io::Result<()> + Sync + Send> { + assert!(!self.built, "attempt to re-use consumed builder"); + + let built = mem::replace(self, Builder { + built: true, + ..Default::default() + }); + + if let Some(fmt) = built.custom_format { + fmt + } + else { + Box::new(move |buf, record| { + let fmt = DefaultFormat { + timestamp: built.default_format_timestamp, + timestamp_nanos: built.default_format_timestamp_nanos, + module_path: built.default_format_module_path, + level: built.default_format_level, + written_header_value: false, + buf, + }; + + fmt.write(record) + }) + } + } +} + +#[cfg(feature = "termcolor")] +type SubtleStyle = StyledValue<'static, &'static str>; +#[cfg(not(feature = "termcolor"))] +type SubtleStyle = &'static str; + +/// The default format. +/// +/// This format needs to work with any combination of crate features. +struct DefaultFormat<'a> { + timestamp: bool, + module_path: bool, + level: bool, + timestamp_nanos: bool, + written_header_value: bool, + buf: &'a mut Formatter, +} + +impl<'a> DefaultFormat<'a> { + fn write(mut self, record: &Record) -> io::Result<()> { + self.write_timestamp()?; + self.write_level(record)?; + self.write_module_path(record)?; + self.finish_header()?; + + self.write_args(record) + } + + fn subtle_style(&self, text: &'static str) -> SubtleStyle { + #[cfg(feature = "termcolor")] + { + self.buf.style() + .set_color(Color::Black) + .set_intense(true) + .into_value(text) + } + #[cfg(not(feature = "termcolor"))] + { + text + } + } + + fn write_header_value(&mut self, value: T) -> io::Result<()> + where + T: Display, + { + if !self.written_header_value { + self.written_header_value = true; + + let open_brace = self.subtle_style("["); + write!(self.buf, "{}{}", open_brace, value) + } else { + write!(self.buf, " {}", value) + } + } + + fn write_level(&mut self, record: &Record) -> io::Result<()> { + if !self.level { + return Ok(()) + } + + let level = { + #[cfg(feature = "termcolor")] + { + self.buf.default_styled_level(record.level()) + } + #[cfg(not(feature = "termcolor"))] + { + record.level() + } + }; + + self.write_header_value(format_args!("{:<5}", level)) + } + + fn write_timestamp(&mut self) -> io::Result<()> { + #[cfg(feature = "humantime")] + { + if !self.timestamp { + return Ok(()) + } + + if self.timestamp_nanos { + let ts_nanos = self.buf.precise_timestamp(); + self.write_header_value(ts_nanos) + } else { + let ts = self.buf.timestamp(); + self.write_header_value(ts) + } + } + #[cfg(not(feature = "humantime"))] + { + let _ = self.timestamp; + let _ = self.timestamp_nanos; + Ok(()) + } + } + + fn write_module_path(&mut self, record: &Record) -> io::Result<()> { + if !self.module_path { + return Ok(()) + } + + if let Some(module_path) = record.module_path() { + self.write_header_value(module_path) + } else { + Ok(()) + } + } + + fn finish_header(&mut self) -> io::Result<()> { + if self.written_header_value { + let close_brace = self.subtle_style("]"); + write!(self.buf, "{} ", close_brace) + } else { + Ok(()) + } + } + + fn write_args(&mut self, record: &Record) -> io::Result<()> { + writeln!(self.buf, "{}", record.args()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + use log::{Level, Record}; + + fn write(fmt: DefaultFormat) -> String { + let buf = fmt.buf.buf.clone(); + + let record = Record::builder() + .args(format_args!("log message")) + .level(Level::Info) + .file(Some("test.rs")) + .line(Some(144)) + .module_path(Some("test::path")) + .build(); + + fmt.write(&record).expect("failed to write record"); + + let buf = buf.borrow(); + String::from_utf8(buf.bytes().to_vec()).expect("failed to read record") + } + + #[test] + fn default_format_with_header() { + let writer = writer::Builder::new() + .write_style(WriteStyle::Never) + .build(); + + let mut f = Formatter::new(&writer); + + let written = write(DefaultFormat { + timestamp: false, + timestamp_nanos: false, + module_path: true, + level: true, + written_header_value: false, + buf: &mut f, + }); + + assert_eq!("[INFO test::path] log message\n", written); + } + + #[test] + fn default_format_no_header() { + let writer = writer::Builder::new() + .write_style(WriteStyle::Never) + .build(); + + let mut f = Formatter::new(&writer); + + let written = write(DefaultFormat { + timestamp: false, + timestamp_nanos: false, + module_path: false, + level: false, + written_header_value: false, + buf: &mut f, + }); + + assert_eq!("log message\n", written); + } +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/atty.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/atty.rs new file mode 100644 index 0000000..c441cf0 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/atty.rs @@ -0,0 +1,34 @@ +/* +This internal module contains the terminal detection implementation. + +If the `atty` crate is available then we use it to detect whether we're +attached to a particular TTY. If the `atty` crate is not available we +assume we're not attached to anything. This effectively prevents styles +from being printed. +*/ + +#[cfg(feature = "atty")] +mod imp { + use atty; + + pub(in ::fmt) fn is_stdout() -> bool { + atty::is(atty::Stream::Stdout) + } + + pub(in ::fmt) fn is_stderr() -> bool { + atty::is(atty::Stream::Stderr) + } +} + +#[cfg(not(feature = "atty"))] +mod imp { + pub(in ::fmt) fn is_stdout() -> bool { + false + } + + pub(in ::fmt) fn is_stderr() -> bool { + false + } +} + +pub(in ::fmt) use self::imp::*; diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/mod.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/mod.rs new file mode 100644 index 0000000..d84e414 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/mod.rs @@ -0,0 +1,206 @@ +mod termcolor; +mod atty; + +use std::{fmt, io}; +use self::termcolor::BufferWriter; +use self::atty::{is_stdout, is_stderr}; + +pub(in ::fmt) mod glob { + pub use super::termcolor::glob::*; + pub use super::*; +} + +pub(in ::fmt) use self::termcolor::Buffer; + +/// Log target, either `stdout` or `stderr`. +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub enum Target { + /// Logs will be sent to standard output. + Stdout, + /// Logs will be sent to standard error. + Stderr, +} + +impl Default for Target { + fn default() -> Self { + Target::Stderr + } +} + +/// Whether or not to print styles to the target. +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub enum WriteStyle { + /// Try to print styles, but don't force the issue. + Auto, + /// Try very hard to print styles. + Always, + /// Never print styles. + Never, +} + +impl Default for WriteStyle { + fn default() -> Self { + WriteStyle::Auto + } +} + +/// A terminal target with color awareness. +pub(crate) struct Writer { + inner: BufferWriter, + write_style: WriteStyle, +} + +impl Writer { + pub fn write_style(&self) -> WriteStyle { + self.write_style + } + + pub(in ::fmt) fn buffer(&self) -> Buffer { + self.inner.buffer() + } + + pub(in ::fmt) fn print(&self, buf: &Buffer) -> io::Result<()> { + self.inner.print(buf) + } +} + +/// A builder for a terminal writer. +/// +/// The target and style choice can be configured before building. +pub(crate) struct Builder { + target: Target, + write_style: WriteStyle, + is_test: bool, + built: bool, +} + +impl Builder { + /// Initialize the writer builder with defaults. + pub(crate) fn new() -> Self { + Builder { + target: Default::default(), + write_style: Default::default(), + is_test: false, + built: false, + } + } + + /// Set the target to write to. + pub(crate) fn target(&mut self, target: Target) -> &mut Self { + self.target = target; + self + } + + /// Parses a style choice string. + /// + /// See the [Disabling colors] section for more details. + /// + /// [Disabling colors]: ../index.html#disabling-colors + pub(crate) fn parse_write_style(&mut self, write_style: &str) -> &mut Self { + self.write_style(parse_write_style(write_style)) + } + + /// Whether or not to print style characters when writing. + pub(crate) fn write_style(&mut self, write_style: WriteStyle) -> &mut Self { + self.write_style = write_style; + self + } + + /// Whether or not to capture logs for `cargo test`. + pub(crate) fn is_test(&mut self, is_test: bool) -> &mut Self { + self.is_test = is_test; + self + } + + /// Build a terminal writer. + pub(crate) fn build(&mut self) -> Writer { + assert!(!self.built, "attempt to re-use consumed builder"); + self.built = true; + + let color_choice = match self.write_style { + WriteStyle::Auto => { + if match self.target { + Target::Stderr => is_stderr(), + Target::Stdout => is_stdout(), + } { + WriteStyle::Auto + } else { + WriteStyle::Never + } + }, + color_choice => color_choice, + }; + + let writer = match self.target { + Target::Stderr => BufferWriter::stderr(self.is_test, color_choice), + Target::Stdout => BufferWriter::stdout(self.is_test, color_choice), + }; + + Writer { + inner: writer, + write_style: self.write_style, + } + } +} + +impl Default for Builder { + fn default() -> Self { + Builder::new() + } +} + +impl fmt::Debug for Builder { + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + f.debug_struct("Logger") + .field("target", &self.target) + .field("write_style", &self.write_style) + .finish() + } +} + +impl fmt::Debug for Writer { + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + f.debug_struct("Writer").finish() + } +} + +fn parse_write_style(spec: &str) -> WriteStyle { + match spec { + "auto" => WriteStyle::Auto, + "always" => WriteStyle::Always, + "never" => WriteStyle::Never, + _ => Default::default(), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_write_style_valid() { + let inputs = vec![ + ("auto", WriteStyle::Auto), + ("always", WriteStyle::Always), + ("never", WriteStyle::Never), + ]; + + for (input, expected) in inputs { + assert_eq!(expected, parse_write_style(input)); + } + } + + #[test] + fn parse_write_style_invalid() { + let inputs = vec![ + "", + "true", + "false", + "NEVER!!" + ]; + + for input in inputs { + assert_eq!(WriteStyle::Auto, parse_write_style(input)); + } + } +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/termcolor/extern_impl.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/termcolor/extern_impl.rs new file mode 100644 index 0000000..0c2d138 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/termcolor/extern_impl.rs @@ -0,0 +1,490 @@ +use std::borrow::Cow; +use std::fmt; +use std::io::{self, Write}; +use std::cell::RefCell; +use std::rc::Rc; + +use log::Level; +use termcolor::{self, ColorChoice, ColorSpec, WriteColor}; + +use ::WriteStyle; +use ::fmt::{Formatter, Target}; + +pub(in ::fmt::writer) mod glob { + pub use super::*; +} + +impl Formatter { + /// Begin a new [`Style`]. + /// + /// # Examples + /// + /// Create a bold, red colored style and use it to print the log level: + /// + /// ``` + /// use std::io::Write; + /// use env_logger::fmt::Color; + /// + /// let mut builder = env_logger::Builder::new(); + /// + /// builder.format(|buf, record| { + /// let mut level_style = buf.style(); + /// + /// level_style.set_color(Color::Red).set_bold(true); + /// + /// writeln!(buf, "{}: {}", + /// level_style.value(record.level()), + /// record.args()) + /// }); + /// ``` + /// + /// [`Style`]: struct.Style.html + pub fn style(&self) -> Style { + Style { + buf: self.buf.clone(), + spec: ColorSpec::new(), + } + } + + /// Get the default [`Style`] for the given level. + /// + /// The style can be used to print other values besides the level. + pub fn default_level_style(&self, level: Level) -> Style { + let mut level_style = self.style(); + match level { + Level::Trace => level_style.set_color(Color::Black).set_intense(true), + Level::Debug => level_style.set_color(Color::White), + Level::Info => level_style.set_color(Color::Green), + Level::Warn => level_style.set_color(Color::Yellow), + Level::Error => level_style.set_color(Color::Red).set_bold(true), + }; + level_style + } + + /// Get a printable [`Style`] for the given level. + /// + /// The style can only be used to print the level. + pub fn default_styled_level(&self, level: Level) -> StyledValue<'static, Level> { + self.default_level_style(level).into_value(level) + } +} + +pub(in ::fmt::writer) struct BufferWriter { + inner: termcolor::BufferWriter, + test_target: Option, +} + +pub(in ::fmt) struct Buffer { + inner: termcolor::Buffer, + test_target: Option, +} + +impl BufferWriter { + pub(in ::fmt::writer) fn stderr(is_test: bool, write_style: WriteStyle) -> Self { + BufferWriter { + inner: termcolor::BufferWriter::stderr(write_style.into_color_choice()), + test_target: if is_test { + Some(Target::Stderr) + } else { + None + }, + } + } + + pub(in ::fmt::writer) fn stdout(is_test: bool, write_style: WriteStyle) -> Self { + BufferWriter { + inner: termcolor::BufferWriter::stdout(write_style.into_color_choice()), + test_target: if is_test { + Some(Target::Stdout) + } else { + None + }, + } + } + + pub(in ::fmt::writer) fn buffer(&self) -> Buffer { + Buffer { + inner: self.inner.buffer(), + test_target: self.test_target, + } + } + + pub(in ::fmt::writer) fn print(&self, buf: &Buffer) -> io::Result<()> { + if let Some(target) = self.test_target { + // This impl uses the `eprint` and `print` macros + // instead of `termcolor`'s buffer. + // This is so their output can be captured by `cargo test` + let log = String::from_utf8_lossy(buf.bytes()); + + match target { + Target::Stderr => eprint!("{}", log), + Target::Stdout => print!("{}", log), + } + + Ok(()) + } else { + self.inner.print(&buf.inner) + } + } +} + +impl Buffer { + pub(in ::fmt) fn clear(&mut self) { + self.inner.clear() + } + + pub(in ::fmt) fn write(&mut self, buf: &[u8]) -> io::Result { + self.inner.write(buf) + } + + pub(in ::fmt) fn flush(&mut self) -> io::Result<()> { + self.inner.flush() + } + + pub(in ::fmt) fn bytes(&self) -> &[u8] { + self.inner.as_slice() + } + + fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { + // Ignore styles for test captured logs because they can't be printed + if self.test_target.is_none() { + self.inner.set_color(spec) + } else { + Ok(()) + } + } + + fn reset(&mut self) -> io::Result<()> { + // Ignore styles for test captured logs because they can't be printed + if self.test_target.is_none() { + self.inner.reset() + } else { + Ok(()) + } + } +} + +impl WriteStyle { + fn into_color_choice(self) -> ColorChoice { + match self { + WriteStyle::Always => ColorChoice::Always, + WriteStyle::Auto => ColorChoice::Auto, + WriteStyle::Never => ColorChoice::Never, + } + } +} + +/// A set of styles to apply to the terminal output. +/// +/// Call [`Formatter::style`] to get a `Style` and use the builder methods to +/// set styling properties, like [color] and [weight]. +/// To print a value using the style, wrap it in a call to [`value`] when the log +/// record is formatted. +/// +/// # Examples +/// +/// Create a bold, red colored style and use it to print the log level: +/// +/// ``` +/// use std::io::Write; +/// use env_logger::fmt::Color; +/// +/// let mut builder = env_logger::Builder::new(); +/// +/// builder.format(|buf, record| { +/// let mut level_style = buf.style(); +/// +/// level_style.set_color(Color::Red).set_bold(true); +/// +/// writeln!(buf, "{}: {}", +/// level_style.value(record.level()), +/// record.args()) +/// }); +/// ``` +/// +/// Styles can be re-used to output multiple values: +/// +/// ``` +/// use std::io::Write; +/// use env_logger::fmt::Color; +/// +/// let mut builder = env_logger::Builder::new(); +/// +/// builder.format(|buf, record| { +/// let mut bold = buf.style(); +/// +/// bold.set_bold(true); +/// +/// writeln!(buf, "{}: {} {}", +/// bold.value(record.level()), +/// bold.value("some bold text"), +/// record.args()) +/// }); +/// ``` +/// +/// [`Formatter::style`]: struct.Formatter.html#method.style +/// [color]: #method.set_color +/// [weight]: #method.set_bold +/// [`value`]: #method.value +#[derive(Clone)] +pub struct Style { + buf: Rc>, + spec: ColorSpec, +} + +/// A value that can be printed using the given styles. +/// +/// It is the result of calling [`Style::value`]. +/// +/// [`Style::value`]: struct.Style.html#method.value +pub struct StyledValue<'a, T> { + style: Cow<'a, Style>, + value: T, +} + +impl Style { + /// Set the text color. + /// + /// # Examples + /// + /// Create a style with red text: + /// + /// ``` + /// use std::io::Write; + /// use env_logger::fmt::Color; + /// + /// let mut builder = env_logger::Builder::new(); + /// + /// builder.format(|buf, record| { + /// let mut style = buf.style(); + /// + /// style.set_color(Color::Red); + /// + /// writeln!(buf, "{}", style.value(record.args())) + /// }); + /// ``` + pub fn set_color(&mut self, color: Color) -> &mut Style { + self.spec.set_fg(color.into_termcolor()); + self + } + + /// Set the text weight. + /// + /// If `yes` is true then text will be written in bold. + /// If `yes` is false then text will be written in the default weight. + /// + /// # Examples + /// + /// Create a style with bold text: + /// + /// ``` + /// use std::io::Write; + /// + /// let mut builder = env_logger::Builder::new(); + /// + /// builder.format(|buf, record| { + /// let mut style = buf.style(); + /// + /// style.set_bold(true); + /// + /// writeln!(buf, "{}", style.value(record.args())) + /// }); + /// ``` + pub fn set_bold(&mut self, yes: bool) -> &mut Style { + self.spec.set_bold(yes); + self + } + + /// Set the text intensity. + /// + /// If `yes` is true then text will be written in a brighter color. + /// If `yes` is false then text will be written in the default color. + /// + /// # Examples + /// + /// Create a style with intense text: + /// + /// ``` + /// use std::io::Write; + /// + /// let mut builder = env_logger::Builder::new(); + /// + /// builder.format(|buf, record| { + /// let mut style = buf.style(); + /// + /// style.set_intense(true); + /// + /// writeln!(buf, "{}", style.value(record.args())) + /// }); + /// ``` + pub fn set_intense(&mut self, yes: bool) -> &mut Style { + self.spec.set_intense(yes); + self + } + + /// Set the background color. + /// + /// # Examples + /// + /// Create a style with a yellow background: + /// + /// ``` + /// use std::io::Write; + /// use env_logger::fmt::Color; + /// + /// let mut builder = env_logger::Builder::new(); + /// + /// builder.format(|buf, record| { + /// let mut style = buf.style(); + /// + /// style.set_bg(Color::Yellow); + /// + /// writeln!(buf, "{}", style.value(record.args())) + /// }); + /// ``` + pub fn set_bg(&mut self, color: Color) -> &mut Style { + self.spec.set_bg(color.into_termcolor()); + self + } + + /// Wrap a value in the style. + /// + /// The same `Style` can be used to print multiple different values. + /// + /// # Examples + /// + /// Create a bold, red colored style and use it to print the log level: + /// + /// ``` + /// use std::io::Write; + /// use env_logger::fmt::Color; + /// + /// let mut builder = env_logger::Builder::new(); + /// + /// builder.format(|buf, record| { + /// let mut style = buf.style(); + /// + /// style.set_color(Color::Red).set_bold(true); + /// + /// writeln!(buf, "{}: {}", + /// style.value(record.level()), + /// record.args()) + /// }); + /// ``` + pub fn value(&self, value: T) -> StyledValue { + StyledValue { + style: Cow::Borrowed(self), + value + } + } + + /// Wrap a value in the style by taking ownership of it. + pub(crate) fn into_value(&mut self, value: T) -> StyledValue<'static, T> { + StyledValue { + style: Cow::Owned(self.clone()), + value + } + } +} + +impl<'a, T> StyledValue<'a, T> { + fn write_fmt(&self, f: F) -> fmt::Result + where + F: FnOnce() -> fmt::Result, + { + self.style.buf.borrow_mut().set_color(&self.style.spec).map_err(|_| fmt::Error)?; + + // Always try to reset the terminal style, even if writing failed + let write = f(); + let reset = self.style.buf.borrow_mut().reset().map_err(|_| fmt::Error); + + write.and(reset) + } +} + +impl fmt::Debug for Style { + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + f.debug_struct("Style").field("spec", &self.spec).finish() + } +} + +macro_rules! impl_styled_value_fmt { + ($($fmt_trait:path),*) => { + $( + impl<'a, T: $fmt_trait> $fmt_trait for StyledValue<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + self.write_fmt(|| T::fmt(&self.value, f)) + } + } + )* + }; +} + +impl_styled_value_fmt!( + fmt::Debug, + fmt::Display, + fmt::Pointer, + fmt::Octal, + fmt::Binary, + fmt::UpperHex, + fmt::LowerHex, + fmt::UpperExp, + fmt::LowerExp); + +// The `Color` type is copied from https://github.com/BurntSushi/ripgrep/tree/master/termcolor + +/// The set of available colors for the terminal foreground/background. +/// +/// The `Ansi256` and `Rgb` colors will only output the correct codes when +/// paired with the `Ansi` `WriteColor` implementation. +/// +/// The `Ansi256` and `Rgb` color types are not supported when writing colors +/// on Windows using the console. If they are used on Windows, then they are +/// silently ignored and no colors will be emitted. +/// +/// This set may expand over time. +/// +/// This type has a `FromStr` impl that can parse colors from their human +/// readable form. The format is as follows: +/// +/// 1. Any of the explicitly listed colors in English. They are matched +/// case insensitively. +/// 2. A single 8-bit integer, in either decimal or hexadecimal format. +/// 3. A triple of 8-bit integers separated by a comma, where each integer is +/// in decimal or hexadecimal format. +/// +/// Hexadecimal numbers are written with a `0x` prefix. +#[allow(missing_docs)] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Color { + Black, + Blue, + Green, + Red, + Cyan, + Magenta, + Yellow, + White, + Ansi256(u8), + Rgb(u8, u8, u8), + #[doc(hidden)] + __Nonexhaustive, +} + +impl Color { + fn into_termcolor(self) -> Option { + match self { + Color::Black => Some(termcolor::Color::Black), + Color::Blue => Some(termcolor::Color::Blue), + Color::Green => Some(termcolor::Color::Green), + Color::Red => Some(termcolor::Color::Red), + Color::Cyan => Some(termcolor::Color::Cyan), + Color::Magenta => Some(termcolor::Color::Magenta), + Color::Yellow => Some(termcolor::Color::Yellow), + Color::White => Some(termcolor::Color::White), + Color::Ansi256(value) => Some(termcolor::Color::Ansi256(value)), + Color::Rgb(r, g, b) => Some(termcolor::Color::Rgb(r, g, b)), + _ => None, + } + } +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/termcolor/mod.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/termcolor/mod.rs new file mode 100644 index 0000000..df0f785 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/termcolor/mod.rs @@ -0,0 +1,12 @@ +/* +This internal module contains the style and terminal writing implementation. + +Its public API is available when the `termcolor` crate is available. +The terminal printing is shimmed when the `termcolor` crate is not available. +*/ + +#[cfg_attr(feature = "termcolor", path = "extern_impl.rs")] +#[cfg_attr(not(feature = "termcolor"), path = "shim_impl.rs")] +mod imp; + +pub(in ::fmt) use self::imp::*; diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/termcolor/shim_impl.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/termcolor/shim_impl.rs new file mode 100644 index 0000000..fb47359 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/fmt/writer/termcolor/shim_impl.rs @@ -0,0 +1,65 @@ +use std::io; + +use fmt::{WriteStyle, Target}; + +pub(in ::fmt::writer) mod glob { + +} + +pub(in ::fmt::writer) struct BufferWriter { + target: Target, +} + +pub(in ::fmt) struct Buffer(Vec); + +impl BufferWriter { + pub(in ::fmt::writer) fn stderr(_is_test: bool, _write_style: WriteStyle) -> Self { + BufferWriter { + target: Target::Stderr, + } + } + + pub(in ::fmt::writer) fn stdout(_is_test: bool, _write_style: WriteStyle) -> Self { + BufferWriter { + target: Target::Stdout, + } + } + + pub(in ::fmt::writer) fn buffer(&self) -> Buffer { + Buffer(Vec::new()) + } + + pub(in ::fmt::writer) fn print(&self, buf: &Buffer) -> io::Result<()> { + // This impl uses the `eprint` and `print` macros + // instead of using the streams directly. + // This is so their output can be captured by `cargo test` + let log = String::from_utf8_lossy(&buf.0); + + match self.target { + Target::Stderr => eprint!("{}", log), + Target::Stdout => print!("{}", log), + } + + Ok(()) + } +} + +impl Buffer { + pub(in ::fmt) fn clear(&mut self) { + self.0.clear(); + } + + pub(in ::fmt) fn write(&mut self, buf: &[u8]) -> io::Result { + self.0.extend(buf); + Ok(buf.len()) + } + + pub(in ::fmt) fn flush(&mut self) -> io::Result<()> { + Ok(()) + } + + #[cfg(test)] + pub(in ::fmt) fn bytes(&self) -> &[u8] { + &self.0 + } +} \ No newline at end of file diff --git a/third_party/cargo/vendor/env_logger-0.6.2/src/lib.rs b/third_party/cargo/vendor/env_logger-0.6.2/src/lib.rs new file mode 100644 index 0000000..37c4322 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/src/lib.rs @@ -0,0 +1,1173 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A simple logger configured via environment variables which writes +//! to stdout or stderr, for use with the logging facade exposed by the +//! [`log` crate][log-crate-url]. +//! +//! ## Example +//! +//! ``` +//! #[macro_use] extern crate log; +//! extern crate env_logger; +//! +//! use log::Level; +//! +//! fn main() { +//! env_logger::init(); +//! +//! debug!("this is a debug {}", "message"); +//! error!("this is printed by default"); +//! +//! if log_enabled!(Level::Info) { +//! let x = 3 * 4; // expensive computation +//! info!("the answer was: {}", x); +//! } +//! } +//! ``` +//! +//! Assumes the binary is `main`: +//! +//! ```{.bash} +//! $ RUST_LOG=error ./main +//! [2017-11-09T02:12:24Z ERROR main] this is printed by default +//! ``` +//! +//! ```{.bash} +//! $ RUST_LOG=info ./main +//! [2017-11-09T02:12:24Z ERROR main] this is printed by default +//! [2017-11-09T02:12:24Z INFO main] the answer was: 12 +//! ``` +//! +//! ```{.bash} +//! $ RUST_LOG=debug ./main +//! [2017-11-09T02:12:24Z DEBUG main] this is a debug message +//! [2017-11-09T02:12:24Z ERROR main] this is printed by default +//! [2017-11-09T02:12:24Z INFO main] the answer was: 12 +//! ``` +//! +//! You can also set the log level on a per module basis: +//! +//! ```{.bash} +//! $ RUST_LOG=main=info ./main +//! [2017-11-09T02:12:24Z ERROR main] this is printed by default +//! [2017-11-09T02:12:24Z INFO main] the answer was: 12 +//! ``` +//! +//! And enable all logging: +//! +//! ```{.bash} +//! $ RUST_LOG=main ./main +//! [2017-11-09T02:12:24Z DEBUG main] this is a debug message +//! [2017-11-09T02:12:24Z ERROR main] this is printed by default +//! [2017-11-09T02:12:24Z INFO main] the answer was: 12 +//! ``` +//! +//! If the binary name contains hyphens, you will need to replace +//! them with underscores: +//! +//! ```{.bash} +//! $ RUST_LOG=my_app ./my-app +//! [2017-11-09T02:12:24Z DEBUG my_app] this is a debug message +//! [2017-11-09T02:12:24Z ERROR my_app] this is printed by default +//! [2017-11-09T02:12:24Z INFO my_app] the answer was: 12 +//! ``` +//! +//! This is because Rust modules and crates cannot contain hyphens +//! in their name, although `cargo` continues to accept them. +//! +//! See the documentation for the [`log` crate][log-crate-url] for more +//! information about its API. +//! +//! ## Enabling logging +//! +//! Log levels are controlled on a per-module basis, and by default all logging +//! is disabled except for `error!`. Logging is controlled via the `RUST_LOG` +//! environment variable. The value of this environment variable is a +//! comma-separated list of logging directives. A logging directive is of the +//! form: +//! +//! ```text +//! path::to::module=level +//! ``` +//! +//! The path to the module is rooted in the name of the crate it was compiled +//! for, so if your program is contained in a file `hello.rs`, for example, to +//! turn on logging for this file you would use a value of `RUST_LOG=hello`. +//! Furthermore, this path is a prefix-search, so all modules nested in the +//! specified module will also have logging enabled. +//! +//! The actual `level` is optional to specify. If omitted, all logging will +//! be enabled. If specified, it must be one of the strings `debug`, `error`, +//! `info`, `warn`, or `trace`. +//! +//! As the log level for a module is optional, the module to enable logging for +//! is also optional. If only a `level` is provided, then the global log +//! level for all modules is set to this value. +//! +//! Some examples of valid values of `RUST_LOG` are: +//! +//! * `hello` turns on all logging for the 'hello' module +//! * `info` turns on all info logging +//! * `hello=debug` turns on debug logging for 'hello' +//! * `hello,std::option` turns on hello, and std's option logging +//! * `error,hello=warn` turn on global error logging and also warn for hello +//! +//! ## Filtering results +//! +//! A `RUST_LOG` directive may include a regex filter. The syntax is to append `/` +//! followed by a regex. Each message is checked against the regex, and is only +//! logged if it matches. Note that the matching is done after formatting the +//! log string but before adding any logging meta-data. There is a single filter +//! for all modules. +//! +//! Some examples: +//! +//! * `hello/foo` turns on all logging for the 'hello' module where the log +//! message includes 'foo'. +//! * `info/f.o` turns on all info logging where the log message includes 'foo', +//! 'f1o', 'fao', etc. +//! * `hello=debug/foo*foo` turns on debug logging for 'hello' where the log +//! message includes 'foofoo' or 'fofoo' or 'fooooooofoo', etc. +//! * `error,hello=warn/[0-9]scopes` turn on global error logging and also +//! warn for hello. In both cases the log message must include a single digit +//! number followed by 'scopes'. +//! +//! ## Capturing logs in tests +//! +//! Records logged during `cargo test` will not be captured by the test harness by default. +//! The [`Builder::is_test`] method can be used in unit tests to ensure logs will be captured: +//! +//! ``` +//! # #[macro_use] extern crate log; +//! # extern crate env_logger; +//! # fn main() {} +//! #[cfg(test)] +//! mod tests { +//! fn init() { +//! let _ = env_logger::builder().is_test(true).try_init(); +//! } +//! +//! #[test] +//! fn it_works() { +//! init(); +//! +//! info!("This record will be captured by `cargo test`"); +//! +//! assert_eq!(2, 1 + 1); +//! } +//! } +//! ``` +//! +//! Enabling test capturing comes at the expense of color and other style support +//! and may have performance implications. +//! +//! ## Disabling colors +//! +//! Colors and other styles can be configured with the `RUST_LOG_STYLE` +//! environment variable. It accepts the following values: +//! +//! * `auto` (default) will attempt to print style characters, but don't force the issue. +//! If the console isn't available on Windows, or if TERM=dumb, for example, then don't print colors. +//! * `always` will always print style characters even if they aren't supported by the terminal. +//! This includes emitting ANSI colors on Windows if the console API is unavailable. +//! * `never` will never print style characters. +//! +//! ## Tweaking the default format +//! +//! Parts of the default format can be excluded from the log output using the [`Builder`]. +//! The following example excludes the timestamp from the log output: +//! +//! ``` +//! env_logger::builder() +//! .default_format_timestamp(false) +//! .init(); +//! ``` +//! +//! ### Stability of the default format +//! +//! The default format won't optimise for long-term stability, and explicitly makes no +//! guarantees about the stability of its output across major, minor or patch version +//! bumps during `0.x`. +//! +//! If you want to capture or interpret the output of `env_logger` programmatically +//! then you should use a custom format. +//! +//! ### Using a custom format +//! +//! Custom formats can be provided as closures to the [`Builder`]. +//! These closures take a [`Formatter`] and `log::Record` as arguments: +//! +//! ``` +//! use std::io::Write; +//! +//! env_logger::builder() +//! .format(|buf, record| { +//! writeln!(buf, "{}: {}", record.level(), record.args()) +//! }) +//! .init(); +//! ``` +//! +//! See the [`fmt`] module for more details about custom formats. +//! +//! ## Specifying defaults for environment variables +//! +//! `env_logger` can read configuration from environment variables. +//! If these variables aren't present, the default value to use can be tweaked with the [`Env`] type. +//! The following example defaults to log `warn` and above if the `RUST_LOG` environment variable +//! isn't set: +//! +//! ``` +//! use env_logger::Env; +//! +//! env_logger::from_env(Env::default().default_filter_or("warn")).init(); +//! ``` +//! +//! [log-crate-url]: https://docs.rs/log/ +//! [`Builder`]: struct.Builder.html +//! [`Builder::is_test`]: struct.Builder.html#method.is_test +//! [`Env`]: struct.Env.html +//! [`fmt`]: fmt/index.html + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "https://www.rust-lang.org/static/images/favicon.ico", + html_root_url = "https://docs.rs/env_logger/0.6.2")] +#![cfg_attr(test, deny(warnings))] + +// When compiled for the rustc compiler itself we want to make sure that this is +// an unstable crate +#![cfg_attr(rustbuild, feature(staged_api, rustc_private))] +#![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))] + +#![deny(missing_debug_implementations, missing_docs, warnings)] + +extern crate log; + +#[cfg(feature = "termcolor")] +extern crate termcolor; +#[cfg(feature = "humantime")] +extern crate humantime; +#[cfg(feature = "atty")] +extern crate atty; + +use std::{env, io}; +use std::borrow::Cow; +use std::cell::RefCell; + +use log::{Log, LevelFilter, Record, SetLoggerError, Metadata}; + +pub mod filter; +pub mod fmt; + +pub use self::fmt::glob::*; + +use self::filter::Filter; +use self::fmt::Formatter; +use self::fmt::writer::{self, Writer}; + +/// The default name for the environment variable to read filters from. +pub const DEFAULT_FILTER_ENV: &'static str = "RUST_LOG"; + +/// The default name for the environment variable to read style preferences from. +pub const DEFAULT_WRITE_STYLE_ENV: &'static str = "RUST_LOG_STYLE"; + +/// Set of environment variables to configure from. +/// +/// # Default environment variables +/// +/// By default, the `Env` will read the following environment variables: +/// +/// - `RUST_LOG`: the level filter +/// - `RUST_LOG_STYLE`: whether or not to print styles with records. +/// +/// These sources can be configured using the builder methods on `Env`. +#[derive(Debug)] +pub struct Env<'a> { + filter: Var<'a>, + write_style: Var<'a>, +} + +#[derive(Debug)] +struct Var<'a> { + name: Cow<'a, str>, + default: Option>, +} + +/// The env logger. +/// +/// This struct implements the `Log` trait from the [`log` crate][log-crate-url], +/// which allows it to act as a logger. +/// +/// The [`init()`], [`try_init()`], [`Builder::init()`] and [`Builder::try_init()`] +/// methods will each construct a `Logger` and immediately initialize it as the +/// default global logger. +/// +/// If you'd instead need access to the constructed `Logger`, you can use +/// the associated [`Builder`] and install it with the +/// [`log` crate][log-crate-url] directly. +/// +/// [log-crate-url]: https://docs.rs/log/ +/// [`init()`]: fn.init.html +/// [`try_init()`]: fn.try_init.html +/// [`Builder::init()`]: struct.Builder.html#method.init +/// [`Builder::try_init()`]: struct.Builder.html#method.try_init +/// [`Builder`]: struct.Builder.html +pub struct Logger { + writer: Writer, + filter: Filter, + #[allow(unknown_lints, bare_trait_objects)] + format: Box io::Result<()> + Sync + Send>, +} + +/// `Builder` acts as builder for initializing a `Logger`. +/// +/// It can be used to customize the log format, change the environment variable used +/// to provide the logging directives and also set the default log level filter. +/// +/// # Examples +/// +/// ``` +/// #[macro_use] +/// extern crate log; +/// extern crate env_logger; +/// +/// use std::env; +/// use std::io::Write; +/// use log::LevelFilter; +/// use env_logger::Builder; +/// +/// fn main() { +/// let mut builder = Builder::from_default_env(); +/// +/// builder.format(|buf, record| writeln!(buf, "{} - {}", record.level(), record.args())) +/// .filter(None, LevelFilter::Info) +/// .init(); +/// +/// error!("error message"); +/// info!("info message"); +/// } +/// ``` +#[derive(Default)] +pub struct Builder { + filter: filter::Builder, + writer: writer::Builder, + format: fmt::Builder, + built: bool, +} + +impl Builder { + /// Initializes the log builder with defaults. + /// + /// **NOTE:** This method won't read from any environment variables. + /// Use the [`filter`] and [`write_style`] methods to configure the builder + /// or use [`from_env`] or [`from_default_env`] instead. + /// + /// # Examples + /// + /// Create a new builder and configure filters and style: + /// + /// ``` + /// # extern crate log; + /// # extern crate env_logger; + /// # fn main() { + /// use log::LevelFilter; + /// use env_logger::{Builder, WriteStyle}; + /// + /// let mut builder = Builder::new(); + /// + /// builder.filter(None, LevelFilter::Info) + /// .write_style(WriteStyle::Always) + /// .init(); + /// # } + /// ``` + /// + /// [`filter`]: #method.filter + /// [`write_style`]: #method.write_style + /// [`from_env`]: #method.from_env + /// [`from_default_env`]: #method.from_default_env + pub fn new() -> Builder { + Default::default() + } + + /// Initializes the log builder from the environment. + /// + /// The variables used to read configuration from can be tweaked before + /// passing in. + /// + /// # Examples + /// + /// Initialise a logger reading the log filter from an environment variable + /// called `MY_LOG`: + /// + /// ``` + /// use env_logger::Builder; + /// + /// let mut builder = Builder::from_env("MY_LOG"); + /// builder.init(); + /// ``` + /// + /// Initialise a logger using the `MY_LOG` variable for filtering and + /// `MY_LOG_STYLE` for whether or not to write styles: + /// + /// ``` + /// use env_logger::{Builder, Env}; + /// + /// let env = Env::new().filter("MY_LOG").write_style("MY_LOG_STYLE"); + /// + /// let mut builder = Builder::from_env(env); + /// builder.init(); + /// ``` + pub fn from_env<'a, E>(env: E) -> Self + where + E: Into> + { + let mut builder = Builder::new(); + let env = env.into(); + + if let Some(s) = env.get_filter() { + builder.parse_filters(&s); + } + + if let Some(s) = env.get_write_style() { + builder.parse_write_style(&s); + } + + builder + } + + /// Initializes the log builder from the environment using default variable names. + /// + /// This method is a convenient way to call `from_env(Env::default())` without + /// having to use the `Env` type explicitly. The builder will use the + /// [default environment variables]. + /// + /// # Examples + /// + /// Initialise a logger using the default environment variables: + /// + /// ``` + /// use env_logger::Builder; + /// + /// let mut builder = Builder::from_default_env(); + /// builder.init(); + /// ``` + /// + /// [default environment variables]: struct.Env.html#default-environment-variables + pub fn from_default_env() -> Self { + Self::from_env(Env::default()) + } + + /// Sets the format function for formatting the log output. + /// + /// This function is called on each record logged and should format the + /// log record and output it to the given [`Formatter`]. + /// + /// The format function is expected to output the string directly to the + /// `Formatter` so that implementations can use the [`std::fmt`] macros + /// to format and output without intermediate heap allocations. The default + /// `env_logger` formatter takes advantage of this. + /// + /// # Examples + /// + /// Use a custom format to write only the log message: + /// + /// ``` + /// use std::io::Write; + /// use env_logger::Builder; + /// + /// let mut builder = Builder::new(); + /// + /// builder.format(|buf, record| writeln!(buf, "{}", record.args())); + /// ``` + /// + /// [`Formatter`]: fmt/struct.Formatter.html + /// [`String`]: https://doc.rust-lang.org/stable/std/string/struct.String.html + /// [`std::fmt`]: https://doc.rust-lang.org/std/fmt/index.html + pub fn format(&mut self, format: F) -> &mut Self + where F: Fn(&mut Formatter, &Record) -> io::Result<()> + Sync + Send + { + self.format.custom_format = Some(Box::new(format)); + self + } + + /// Use the default format. + /// + /// This method will clear any custom format set on the builder. + pub fn default_format(&mut self) -> &mut Self { + self.format.custom_format = None; + self + } + + /// Whether or not to write the level in the default format. + pub fn default_format_level(&mut self, write: bool) -> &mut Self { + self.format.default_format_level = write; + self + } + + /// Whether or not to write the module path in the default format. + pub fn default_format_module_path(&mut self, write: bool) -> &mut Self { + self.format.default_format_module_path = write; + self + } + + /// Whether or not to write the timestamp in the default format. + pub fn default_format_timestamp(&mut self, write: bool) -> &mut Self { + self.format.default_format_timestamp = write; + self + } + + /// Whether or not to write the timestamp with nanos. + pub fn default_format_timestamp_nanos(&mut self, write: bool) -> &mut Self { + self.format.default_format_timestamp_nanos = write; + self + } + + /// Adds a directive to the filter for a specific module. + /// + /// # Examples + /// + /// Only include messages for warning and above for logs in `path::to::module`: + /// + /// ``` + /// # extern crate log; + /// # extern crate env_logger; + /// # fn main() { + /// use log::LevelFilter; + /// use env_logger::Builder; + /// + /// let mut builder = Builder::new(); + /// + /// builder.filter_module("path::to::module", LevelFilter::Info); + /// # } + /// ``` + pub fn filter_module(&mut self, module: &str, level: LevelFilter) -> &mut Self { + self.filter.filter_module(module, level); + self + } + + /// Adds a directive to the filter for all modules. + /// + /// # Examples + /// + /// Only include messages for warning and above for logs in `path::to::module`: + /// + /// ``` + /// # extern crate log; + /// # extern crate env_logger; + /// # fn main() { + /// use log::LevelFilter; + /// use env_logger::Builder; + /// + /// let mut builder = Builder::new(); + /// + /// builder.filter_level(LevelFilter::Info); + /// # } + /// ``` + pub fn filter_level(&mut self, level: LevelFilter) -> &mut Self { + self.filter.filter_level(level); + self + } + + /// Adds filters to the logger. + /// + /// The given module (if any) will log at most the specified level provided. + /// If no module is provided then the filter will apply to all log messages. + /// + /// # Examples + /// + /// Only include messages for warning and above for logs in `path::to::module`: + /// + /// ``` + /// # extern crate log; + /// # extern crate env_logger; + /// # fn main() { + /// use log::LevelFilter; + /// use env_logger::Builder; + /// + /// let mut builder = Builder::new(); + /// + /// builder.filter(Some("path::to::module"), LevelFilter::Info); + /// # } + /// ``` + pub fn filter(&mut self, + module: Option<&str>, + level: LevelFilter) -> &mut Self { + self.filter.filter(module, level); + self + } + + /// Parses the directives string in the same form as the `RUST_LOG` + /// environment variable. + /// + /// See the module documentation for more details. + #[deprecated(since = "0.6.1", note = "use `parse_filters` instead.")] + pub fn parse(&mut self, filters: &str) -> &mut Self { + self.parse_filters(filters) + } + + /// Parses the directives string in the same form as the `RUST_LOG` + /// environment variable. + /// + /// See the module documentation for more details. + pub fn parse_filters(&mut self, filters: &str) -> &mut Self { + self.filter.parse(filters); + self + } + + /// Sets the target for the log output. + /// + /// Env logger can log to either stdout or stderr. The default is stderr. + /// + /// # Examples + /// + /// Write log message to `stdout`: + /// + /// ``` + /// use env_logger::{Builder, Target}; + /// + /// let mut builder = Builder::new(); + /// + /// builder.target(Target::Stdout); + /// ``` + pub fn target(&mut self, target: fmt::Target) -> &mut Self { + self.writer.target(target); + self + } + + /// Sets whether or not styles will be written. + /// + /// This can be useful in environments that don't support control characters + /// for setting colors. + /// + /// # Examples + /// + /// Never attempt to write styles: + /// + /// ``` + /// use env_logger::{Builder, WriteStyle}; + /// + /// let mut builder = Builder::new(); + /// + /// builder.write_style(WriteStyle::Never); + /// ``` + pub fn write_style(&mut self, write_style: fmt::WriteStyle) -> &mut Self { + self.writer.write_style(write_style); + self + } + + /// Parses whether or not to write styles in the same form as the `RUST_LOG_STYLE` + /// environment variable. + /// + /// See the module documentation for more details. + pub fn parse_write_style(&mut self, write_style: &str) -> &mut Self { + self.writer.parse_write_style(write_style); + self + } + + /// Sets whether or not the logger will be used in unit tests. + /// + /// If `is_test` is `true` then the logger will allow the testing framework to + /// capture log records rather than printing them to the terminal directly. + pub fn is_test(&mut self, is_test: bool) -> &mut Self { + self.writer.is_test(is_test); + self + } + + /// Initializes the global logger with the built env logger. + /// + /// This should be called early in the execution of a Rust program. Any log + /// events that occur before initialization will be ignored. + /// + /// # Errors + /// + /// This function will fail if it is called more than once, or if another + /// library has already initialized a global logger. + pub fn try_init(&mut self) -> Result<(), SetLoggerError> { + let logger = self.build(); + + let max_level = logger.filter(); + let r = log::set_boxed_logger(Box::new(logger)); + + if r.is_ok() { + log::set_max_level(max_level); + } + + r + } + + /// Initializes the global logger with the built env logger. + /// + /// This should be called early in the execution of a Rust program. Any log + /// events that occur before initialization will be ignored. + /// + /// # Panics + /// + /// This function will panic if it is called more than once, or if another + /// library has already initialized a global logger. + pub fn init(&mut self) { + self.try_init().expect("Builder::init should not be called after logger initialized"); + } + + /// Build an env logger. + /// + /// The returned logger implements the `Log` trait and can be installed manually + /// or nested within another logger. + pub fn build(&mut self) -> Logger { + assert!(!self.built, "attempt to re-use consumed builder"); + self.built = true; + + Logger { + writer: self.writer.build(), + filter: self.filter.build(), + format: self.format.build(), + } + } +} + +impl Logger { + /// Creates the logger from the environment. + /// + /// The variables used to read configuration from can be tweaked before + /// passing in. + /// + /// # Examples + /// + /// Create a logger reading the log filter from an environment variable + /// called `MY_LOG`: + /// + /// ``` + /// use env_logger::Logger; + /// + /// let logger = Logger::from_env("MY_LOG"); + /// ``` + /// + /// Create a logger using the `MY_LOG` variable for filtering and + /// `MY_LOG_STYLE` for whether or not to write styles: + /// + /// ``` + /// use env_logger::{Logger, Env}; + /// + /// let env = Env::new().filter_or("MY_LOG", "info").write_style_or("MY_LOG_STYLE", "always"); + /// + /// let logger = Logger::from_env(env); + /// ``` + pub fn from_env<'a, E>(env: E) -> Self + where + E: Into> + { + Builder::from_env(env).build() + } + + /// Creates the logger from the environment using default variable names. + /// + /// This method is a convenient way to call `from_env(Env::default())` without + /// having to use the `Env` type explicitly. The logger will use the + /// [default environment variables]. + /// + /// # Examples + /// + /// Creates a logger using the default environment variables: + /// + /// ``` + /// use env_logger::Logger; + /// + /// let logger = Logger::from_default_env(); + /// ``` + /// + /// [default environment variables]: struct.Env.html#default-environment-variables + pub fn from_default_env() -> Self { + Builder::from_default_env().build() + } + + /// Returns the maximum `LevelFilter` that this env logger instance is + /// configured to output. + pub fn filter(&self) -> LevelFilter { + self.filter.filter() + } + + /// Checks if this record matches the configured filter. + pub fn matches(&self, record: &Record) -> bool { + self.filter.matches(record) + } +} + +impl Log for Logger { + fn enabled(&self, metadata: &Metadata) -> bool { + self.filter.enabled(metadata) + } + + fn log(&self, record: &Record) { + if self.matches(record) { + // Log records are written to a thread-local buffer before being printed + // to the terminal. We clear these buffers afterwards, but they aren't shrinked + // so will always at least have capacity for the largest log record formatted + // on that thread. + // + // If multiple `Logger`s are used by the same threads then the thread-local + // formatter might have different color support. If this is the case the + // formatter and its buffer are discarded and recreated. + + thread_local! { + static FORMATTER: RefCell> = RefCell::new(None); + } + + FORMATTER.with(|tl_buf| { + // It's possible for implementations to sometimes + // log-while-logging (e.g. a `std::fmt` implementation logs + // internally) but it's super rare. If this happens make sure we + // at least don't panic and ship some output to the screen. + let mut a; + let mut b = None; + let tl_buf = match tl_buf.try_borrow_mut() { + Ok(f) => { + a = f; + &mut *a + } + Err(_) => &mut b, + }; + + // Check the buffer style. If it's different from the logger's + // style then drop the buffer and recreate it. + match *tl_buf { + Some(ref mut formatter) => { + if formatter.write_style() != self.writer.write_style() { + *formatter = Formatter::new(&self.writer) + } + }, + ref mut tl_buf => *tl_buf = Some(Formatter::new(&self.writer)) + } + + // The format is guaranteed to be `Some` by this point + let mut formatter = tl_buf.as_mut().unwrap(); + + let _ = (self.format)(&mut formatter, record).and_then(|_| formatter.print(&self.writer)); + + // Always clear the buffer afterwards + formatter.clear(); + }); + } + } + + fn flush(&self) {} +} + +impl<'a> Env<'a> { + /// Get a default set of environment variables. + pub fn new() -> Self { + Self::default() + } + + /// Specify an environment variable to read the filter from. + pub fn filter(mut self, filter_env: E) -> Self + where + E: Into> + { + self.filter = Var::new(filter_env); + + self + } + + /// Specify an environment variable to read the filter from. + /// + /// If the variable is not set, the default value will be used. + pub fn filter_or(mut self, filter_env: E, default: V) -> Self + where + E: Into>, + V: Into>, + { + self.filter = Var::new_with_default(filter_env, default); + + self + } + + /// Use the default environment variable to read the filter from. + /// + /// If the variable is not set, the default value will be used. + pub fn default_filter_or(mut self, default: V) -> Self + where + V: Into>, + { + self.filter = Var::new_with_default(DEFAULT_FILTER_ENV, default); + + self + } + + fn get_filter(&self) -> Option { + self.filter.get() + } + + /// Specify an environment variable to read the style from. + pub fn write_style(mut self, write_style_env: E) -> Self + where + E: Into> + { + self.write_style = Var::new(write_style_env); + + self + } + + /// Specify an environment variable to read the style from. + /// + /// If the variable is not set, the default value will be used. + pub fn write_style_or(mut self, write_style_env: E, default: V) -> Self + where + E: Into>, + V: Into>, + { + self.write_style = Var::new_with_default(write_style_env, default); + + self + } + + /// Use the default environment variable to read the style from. + /// + /// If the variable is not set, the default value will be used. + pub fn default_write_style_or(mut self, default: V) -> Self + where + V: Into>, + { + self.write_style = Var::new_with_default(DEFAULT_WRITE_STYLE_ENV, default); + + self + } + + fn get_write_style(&self) -> Option { + self.write_style.get() + } +} + +impl<'a> Var<'a> { + fn new(name: E) -> Self + where + E: Into>, + { + Var { + name: name.into(), + default: None, + } + } + + fn new_with_default(name: E, default: V) -> Self + where + E: Into>, + V: Into>, + { + Var { + name: name.into(), + default: Some(default.into()), + } + } + + fn get(&self) -> Option { + env::var(&*self.name) + .ok() + .or_else(|| self.default + .to_owned() + .map(|v| v.into_owned())) + } +} + +impl<'a, T> From for Env<'a> +where + T: Into> +{ + fn from(filter_env: T) -> Self { + Env::default().filter(filter_env.into()) + } +} + +impl<'a> Default for Env<'a> { + fn default() -> Self { + Env { + filter: Var::new(DEFAULT_FILTER_ENV), + write_style: Var::new(DEFAULT_WRITE_STYLE_ENV), + } + } +} + +mod std_fmt_impls { + use std::fmt; + use super::*; + + impl fmt::Debug for Logger{ + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + f.debug_struct("Logger") + .field("filter", &self.filter) + .finish() + } + } + + impl fmt::Debug for Builder{ + fn fmt(&self, f: &mut fmt::Formatter)->fmt::Result { + if self.built { + f.debug_struct("Logger") + .field("built", &true) + .finish() + } else { + f.debug_struct("Logger") + .field("filter", &self.filter) + .field("writer", &self.writer) + .finish() + } + } + } +} + +/// Attempts to initialize the global logger with an env logger. +/// +/// This should be called early in the execution of a Rust program. Any log +/// events that occur before initialization will be ignored. +/// +/// # Errors +/// +/// This function will fail if it is called more than once, or if another +/// library has already initialized a global logger. +pub fn try_init() -> Result<(), SetLoggerError> { + try_init_from_env(Env::default()) +} + +/// Initializes the global logger with an env logger. +/// +/// This should be called early in the execution of a Rust program. Any log +/// events that occur before initialization will be ignored. +/// +/// # Panics +/// +/// This function will panic if it is called more than once, or if another +/// library has already initialized a global logger. +pub fn init() { + try_init().expect("env_logger::init should not be called after logger initialized"); +} + +/// Attempts to initialize the global logger with an env logger from the given +/// environment variables. +/// +/// This should be called early in the execution of a Rust program. Any log +/// events that occur before initialization will be ignored. +/// +/// # Examples +/// +/// Initialise a logger using the `MY_LOG` environment variable for filters +/// and `MY_LOG_STYLE` for writing colors: +/// +/// ``` +/// # extern crate env_logger; +/// use env_logger::{Builder, Env}; +/// +/// # fn run() -> Result<(), Box<::std::error::Error>> { +/// let env = Env::new().filter("MY_LOG").write_style("MY_LOG_STYLE"); +/// +/// env_logger::try_init_from_env(env)?; +/// +/// Ok(()) +/// # } +/// # fn main() { run().unwrap(); } +/// ``` +/// +/// # Errors +/// +/// This function will fail if it is called more than once, or if another +/// library has already initialized a global logger. +pub fn try_init_from_env<'a, E>(env: E) -> Result<(), SetLoggerError> +where + E: Into> +{ + let mut builder = Builder::from_env(env); + + builder.try_init() +} + +/// Initializes the global logger with an env logger from the given environment +/// variables. +/// +/// This should be called early in the execution of a Rust program. Any log +/// events that occur before initialization will be ignored. +/// +/// # Examples +/// +/// Initialise a logger using the `MY_LOG` environment variable for filters +/// and `MY_LOG_STYLE` for writing colors: +/// +/// ``` +/// use env_logger::{Builder, Env}; +/// +/// let env = Env::new().filter("MY_LOG").write_style("MY_LOG_STYLE"); +/// +/// env_logger::init_from_env(env); +/// ``` +/// +/// # Panics +/// +/// This function will panic if it is called more than once, or if another +/// library has already initialized a global logger. +pub fn init_from_env<'a, E>(env: E) +where + E: Into> +{ + try_init_from_env(env).expect("env_logger::init_from_env should not be called after logger initialized"); +} + +/// Create a new builder with the default environment variables. +/// +/// The builder can be configured before being initialized. +pub fn builder() -> Builder { + Builder::from_default_env() +} + +/// Create a builder from the given environment variables. +/// +/// The builder can be configured before being initialized. +pub fn from_env<'a, E>(env: E) -> Builder +where + E: Into> +{ + Builder::from_env(env) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn env_get_filter_reads_from_var_if_set() { + env::set_var("env_get_filter_reads_from_var_if_set", "from var"); + + let env = Env::new().filter_or("env_get_filter_reads_from_var_if_set", "from default"); + + assert_eq!(Some("from var".to_owned()), env.get_filter()); + } + + #[test] + fn env_get_filter_reads_from_default_if_var_not_set() { + env::remove_var("env_get_filter_reads_from_default_if_var_not_set"); + + let env = Env::new().filter_or("env_get_filter_reads_from_default_if_var_not_set", "from default"); + + assert_eq!(Some("from default".to_owned()), env.get_filter()); + } + + #[test] + fn env_get_write_style_reads_from_var_if_set() { + env::set_var("env_get_write_style_reads_from_var_if_set", "from var"); + + let env = Env::new().write_style_or("env_get_write_style_reads_from_var_if_set", "from default"); + + assert_eq!(Some("from var".to_owned()), env.get_write_style()); + } + + #[test] + fn env_get_write_style_reads_from_default_if_var_not_set() { + env::remove_var("env_get_write_style_reads_from_default_if_var_not_set"); + + let env = Env::new().write_style_or("env_get_write_style_reads_from_default_if_var_not_set", "from default"); + + assert_eq!(Some("from default".to_owned()), env.get_write_style()); + } +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/tests/init-twice-retains-filter.rs b/third_party/cargo/vendor/env_logger-0.6.2/tests/init-twice-retains-filter.rs new file mode 100644 index 0000000..c1256ef --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/tests/init-twice-retains-filter.rs @@ -0,0 +1,40 @@ +extern crate log; +extern crate env_logger; + +use std::process; +use std::env; +use std::str; + +fn main() { + if env::var("YOU_ARE_TESTING_NOW").is_ok() { + // Init from the env (which should set the max level to `Debug`) + env_logger::init(); + + assert_eq!(log::LevelFilter::Debug, log::max_level()); + + // Init again using a different max level + // This shouldn't clobber the level that was previously set + env_logger::Builder::new() + .parse_filters("info") + .try_init() + .unwrap_err(); + + assert_eq!(log::LevelFilter::Debug, log::max_level()); + return + } + + let exe = env::current_exe().unwrap(); + let out = process::Command::new(exe) + .env("YOU_ARE_TESTING_NOW", "1") + .env("RUST_LOG", "debug") + .output() + .unwrap_or_else(|e| panic!("Unable to start child process: {}", e)); + if out.status.success() { + return + } + + println!("test failed: {}", out.status); + println!("--- stdout\n{}", str::from_utf8(&out.stdout).unwrap()); + println!("--- stderr\n{}", str::from_utf8(&out.stderr).unwrap()); + process::exit(1); +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/tests/log-in-log.rs b/third_party/cargo/vendor/env_logger-0.6.2/tests/log-in-log.rs new file mode 100644 index 0000000..6b2c47e --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/tests/log-in-log.rs @@ -0,0 +1,38 @@ +#[macro_use] extern crate log; +extern crate env_logger; + +use std::process; +use std::fmt; +use std::env; +use std::str; + +struct Foo; + +impl fmt::Display for Foo { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + info!("test"); + f.write_str("bar") + } +} + +fn main() { + env_logger::init(); + if env::var("YOU_ARE_TESTING_NOW").is_ok() { + return info!("{}", Foo); + } + + let exe = env::current_exe().unwrap(); + let out = process::Command::new(exe) + .env("YOU_ARE_TESTING_NOW", "1") + .env("RUST_LOG", "debug") + .output() + .unwrap_or_else(|e| panic!("Unable to start child process: {}", e)); + if out.status.success() { + return + } + + println!("test failed: {}", out.status); + println!("--- stdout\n{}", str::from_utf8(&out.stdout).unwrap()); + println!("--- stderr\n{}", str::from_utf8(&out.stderr).unwrap()); + process::exit(1); +} diff --git a/third_party/cargo/vendor/env_logger-0.6.2/tests/regexp_filter.rs b/third_party/cargo/vendor/env_logger-0.6.2/tests/regexp_filter.rs new file mode 100644 index 0000000..d23e922 --- /dev/null +++ b/third_party/cargo/vendor/env_logger-0.6.2/tests/regexp_filter.rs @@ -0,0 +1,51 @@ +#[macro_use] extern crate log; +extern crate env_logger; + +use std::process; +use std::env; +use std::str; + +fn main() { + if env::var("LOG_REGEXP_TEST").ok() == Some(String::from("1")) { + child_main(); + } else { + parent_main() + } +} + +fn child_main() { + env_logger::init(); + info!("XYZ Message"); +} + +fn run_child(rust_log: String) -> bool { + let exe = env::current_exe().unwrap(); + let out = process::Command::new(exe) + .env("LOG_REGEXP_TEST", "1") + .env("RUST_LOG", rust_log) + .output() + .unwrap_or_else(|e| panic!("Unable to start child process: {}", e)); + str::from_utf8(out.stderr.as_ref()).unwrap().contains("XYZ Message") +} + +fn assert_message_printed(rust_log: &str) { + if !run_child(rust_log.to_string()) { + panic!("RUST_LOG={} should allow the test log message", rust_log) + } +} + +fn assert_message_not_printed(rust_log: &str) { + if run_child(rust_log.to_string()) { + panic!("RUST_LOG={} should not allow the test log message", rust_log) + } +} + +fn parent_main() { + // test normal log severity levels + assert_message_printed("info"); + assert_message_not_printed("warn"); + + // test of regular expression filters + assert_message_printed("info/XYZ"); + assert_message_not_printed("info/XXX"); +} diff --git a/third_party/cargo/vendor/fnv-1.0.6/.cargo-checksum.json b/third_party/cargo/vendor/fnv-1.0.6/.cargo-checksum.json new file mode 100644 index 0000000..b1fb191 --- /dev/null +++ b/third_party/cargo/vendor/fnv-1.0.6/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"8a89e16dc6b373aa151fb2d1221c699b39b1dd5599aa616897fa85511b71104f","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"65fdb6c76cd61612070c066eec9ecdb30ee74fb27859d0d9af58b9f499fd0c3e","README.md":"9398b0785fdaf32fe61dca3d6f16e69cf53ab2911c9435053d1ec962cd92b8fa","lib.rs":"0303c8c75e9cf35f5379f67cfc003ba0b51e9643dc8f3bd346322595d7685d97"},"package":"2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"} \ No newline at end of file diff --git a/third_party/cargo/vendor/fnv-1.0.6/BUILD b/third_party/cargo/vendor/fnv-1.0.6/BUILD new file mode 100644 index 0000000..d0e714a --- /dev/null +++ b/third_party/cargo/vendor/fnv-1.0.6/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "Apache-2.0,MIT" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "fnv", + crate_root = "lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.0.6", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/fnv-1.0.6/Cargo.toml b/third_party/cargo/vendor/fnv-1.0.6/Cargo.toml new file mode 100644 index 0000000..1157799 --- /dev/null +++ b/third_party/cargo/vendor/fnv-1.0.6/Cargo.toml @@ -0,0 +1,25 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "fnv" +version = "1.0.6" +authors = ["Alex Crichton "] +description = "Fowler–Noll–Vo hash function" +documentation = "https://doc.servo.org/fnv/" +readme = "README.md" +license = "Apache-2.0 / MIT" +repository = "https://github.com/servo/rust-fnv" + +[lib] +name = "fnv" +path = "lib.rs" diff --git a/third_party/cargo/vendor/fnv-1.0.6/LICENSE-APACHE b/third_party/cargo/vendor/fnv-1.0.6/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/fnv-1.0.6/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/fnv-1.0.6/LICENSE-MIT b/third_party/cargo/vendor/fnv-1.0.6/LICENSE-MIT new file mode 100644 index 0000000..bc976a2 --- /dev/null +++ b/third_party/cargo/vendor/fnv-1.0.6/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2017 Contributors + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/fnv-1.0.6/README.md b/third_party/cargo/vendor/fnv-1.0.6/README.md new file mode 100644 index 0000000..6a4c4ae --- /dev/null +++ b/third_party/cargo/vendor/fnv-1.0.6/README.md @@ -0,0 +1,81 @@ +# rust-fnv + +An implementation of the [Fowler–Noll–Vo hash function][chongo]. + +### [Read the documentation](https://doc.servo.org/fnv/) + + +## About + +The FNV hash function is a custom `Hasher` implementation that is more +efficient for smaller hash keys. + +[The Rust FAQ states that][faq] while the default `Hasher` implementation, +SipHash, is good in many cases, it is notably slower than other algorithms +with short keys, such as when you have a map of integers to other values. +In cases like these, [FNV is demonstrably faster][graphs]. + +Its disadvantages are that it performs badly on larger inputs, and +provides no protection against collision attacks, where a malicious user +can craft specific keys designed to slow a hasher down. Thus, it is +important to profile your program to ensure that you are using small hash +keys, and be certain that your program could not be exposed to malicious +inputs (including being a networked server). + +The Rust compiler itself uses FNV, as it is not worried about +denial-of-service attacks, and can assume that its inputs are going to be +small—a perfect use case for FNV. + + +## Usage + +To include this crate in your program, add the following to your `Cargo.toml`: + +```toml +[dependencies] +fnv = "1.0.3" +``` + + +## Using FNV in a HashMap + +The `FnvHashMap` type alias is the easiest way to use the standard library’s +`HashMap` with FNV. + +```rust +use fnv::FnvHashMap; + +let mut map = FnvHashMap::default(); +map.insert(1, "one"); +map.insert(2, "two"); + +map = FnvHashMap::with_capacity_and_hasher(10, Default::default()); +map.insert(1, "one"); +map.insert(2, "two"); +``` + +Note, the standard library’s `HashMap::new` and `HashMap::with_capacity` +are only implemented for the `RandomState` hasher, so using `Default` to +get the hasher is the next best option. + + +## Using FNV in a HashSet + +Similarly, `FnvHashSet` is a type alias for the standard library’s `HashSet` +with FNV. + +```rust +use fnv::FnvHashSet; + +let mut set = FnvHashSet::default(); +set.insert(1); +set.insert(2); + +set = FnvHashSet::with_capacity_and_hasher(10, Default::default()); +set.insert(1); +set.insert(2); +``` + +[chongo]: http://www.isthe.com/chongo/tech/comp/fnv/index.html +[faq]: https://www.rust-lang.org/en-US/faq.html#why-are-rusts-hashmaps-slow +[graphs]: http://cglab.ca/~abeinges/blah/hash-rs/ diff --git a/third_party/cargo/vendor/fnv-1.0.6/lib.rs b/third_party/cargo/vendor/fnv-1.0.6/lib.rs new file mode 100644 index 0000000..eaf3d44 --- /dev/null +++ b/third_party/cargo/vendor/fnv-1.0.6/lib.rs @@ -0,0 +1,349 @@ +//! An implementation of the [Fowler–Noll–Vo hash function][chongo]. +//! +//! ## About +//! +//! The FNV hash function is a custom `Hasher` implementation that is more +//! efficient for smaller hash keys. +//! +//! [The Rust FAQ states that][faq] while the default `Hasher` implementation, +//! SipHash, is good in many cases, it is notably slower than other algorithms +//! with short keys, such as when you have a map of integers to other values. +//! In cases like these, [FNV is demonstrably faster][graphs]. +//! +//! Its disadvantages are that it performs badly on larger inputs, and +//! provides no protection against collision attacks, where a malicious user +//! can craft specific keys designed to slow a hasher down. Thus, it is +//! important to profile your program to ensure that you are using small hash +//! keys, and be certain that your program could not be exposed to malicious +//! inputs (including being a networked server). +//! +//! The Rust compiler itself uses FNV, as it is not worried about +//! denial-of-service attacks, and can assume that its inputs are going to be +//! small—a perfect use case for FNV. +//! +//! +//! ## Using FNV in a `HashMap` +//! +//! The `FnvHashMap` type alias is the easiest way to use the standard library’s +//! `HashMap` with FNV. +//! +//! ```rust +//! use fnv::FnvHashMap; +//! +//! let mut map = FnvHashMap::default(); +//! map.insert(1, "one"); +//! map.insert(2, "two"); +//! +//! map = FnvHashMap::with_capacity_and_hasher(10, Default::default()); +//! map.insert(1, "one"); +//! map.insert(2, "two"); +//! ``` +//! +//! Note, the standard library’s `HashMap::new` and `HashMap::with_capacity` +//! are only implemented for the `RandomState` hasher, so using `Default` to +//! get the hasher is the next best option. +//! +//! ## Using FNV in a `HashSet` +//! +//! Similarly, `FnvHashSet` is a type alias for the standard library’s `HashSet` +//! with FNV. +//! +//! ```rust +//! use fnv::FnvHashSet; +//! +//! let mut set = FnvHashSet::default(); +//! set.insert(1); +//! set.insert(2); +//! +//! set = FnvHashSet::with_capacity_and_hasher(10, Default::default()); +//! set.insert(1); +//! set.insert(2); +//! ``` +//! +//! [chongo]: http://www.isthe.com/chongo/tech/comp/fnv/index.html +//! [faq]: https://www.rust-lang.org/en-US/faq.html#why-are-rusts-hashmaps-slow +//! [graphs]: http://cglab.ca/~abeinges/blah/hash-rs/ + + +use std::default::Default; +use std::hash::{Hasher, BuildHasherDefault}; +use std::collections::{HashMap, HashSet}; + +/// An implementation of the Fowler–Noll–Vo hash function. +/// +/// See the [crate documentation](index.html) for more details. +#[allow(missing_copy_implementations)] +pub struct FnvHasher(u64); + +impl Default for FnvHasher { + + #[inline] + fn default() -> FnvHasher { + FnvHasher(0xcbf29ce484222325) + } +} + +impl FnvHasher { + /// Create an FNV hasher starting with a state corresponding + /// to the hash `key`. + #[inline] + pub fn with_key(key: u64) -> FnvHasher { + FnvHasher(key) + } +} + +impl Hasher for FnvHasher { + #[inline] + fn finish(&self) -> u64 { + self.0 + } + + #[inline] + fn write(&mut self, bytes: &[u8]) { + let FnvHasher(mut hash) = *self; + + for byte in bytes.iter() { + hash = hash ^ (*byte as u64); + hash = hash.wrapping_mul(0x100000001b3); + } + + *self = FnvHasher(hash); + } +} + +/// A builder for default FNV hashers. +pub type FnvBuildHasher = BuildHasherDefault; + +/// A `HashMap` using a default FNV hasher. +pub type FnvHashMap = HashMap; + +/// A `HashSet` using a default FNV hasher. +pub type FnvHashSet = HashSet; + + +#[cfg(test)] +mod test { + use super::*; + use std::hash::Hasher; + + fn fnv1a(bytes: &[u8]) -> u64 { + let mut hasher = FnvHasher::default(); + hasher.write(bytes); + hasher.finish() + } + + fn repeat_10(bytes: &[u8]) -> Vec { + (0..10).flat_map(|_| bytes.iter().cloned()).collect() + } + + fn repeat_500(bytes: &[u8]) -> Vec { + (0..500).flat_map(|_| bytes.iter().cloned()).collect() + } + + #[test] + fn basic_tests() { + assert_eq!(fnv1a(b""), 0xcbf29ce484222325); + assert_eq!(fnv1a(b"a"), 0xaf63dc4c8601ec8c); + assert_eq!(fnv1a(b"b"), 0xaf63df4c8601f1a5); + assert_eq!(fnv1a(b"c"), 0xaf63de4c8601eff2); + assert_eq!(fnv1a(b"d"), 0xaf63d94c8601e773); + assert_eq!(fnv1a(b"e"), 0xaf63d84c8601e5c0); + assert_eq!(fnv1a(b"f"), 0xaf63db4c8601ead9); + assert_eq!(fnv1a(b"fo"), 0x08985907b541d342); + assert_eq!(fnv1a(b"foo"), 0xdcb27518fed9d577); + assert_eq!(fnv1a(b"foob"), 0xdd120e790c2512af); + assert_eq!(fnv1a(b"fooba"), 0xcac165afa2fef40a); + assert_eq!(fnv1a(b"foobar"), 0x85944171f73967e8); + assert_eq!(fnv1a(b"\0"), 0xaf63bd4c8601b7df); + assert_eq!(fnv1a(b"a\0"), 0x089be207b544f1e4); + assert_eq!(fnv1a(b"b\0"), 0x08a61407b54d9b5f); + assert_eq!(fnv1a(b"c\0"), 0x08a2ae07b54ab836); + assert_eq!(fnv1a(b"d\0"), 0x0891b007b53c4869); + assert_eq!(fnv1a(b"e\0"), 0x088e4a07b5396540); + assert_eq!(fnv1a(b"f\0"), 0x08987c07b5420ebb); + assert_eq!(fnv1a(b"fo\0"), 0xdcb28a18fed9f926); + assert_eq!(fnv1a(b"foo\0"), 0xdd1270790c25b935); + assert_eq!(fnv1a(b"foob\0"), 0xcac146afa2febf5d); + assert_eq!(fnv1a(b"fooba\0"), 0x8593d371f738acfe); + assert_eq!(fnv1a(b"foobar\0"), 0x34531ca7168b8f38); + assert_eq!(fnv1a(b"ch"), 0x08a25607b54a22ae); + assert_eq!(fnv1a(b"cho"), 0xf5faf0190cf90df3); + assert_eq!(fnv1a(b"chon"), 0xf27397910b3221c7); + assert_eq!(fnv1a(b"chong"), 0x2c8c2b76062f22e0); + assert_eq!(fnv1a(b"chongo"), 0xe150688c8217b8fd); + assert_eq!(fnv1a(b"chongo "), 0xf35a83c10e4f1f87); + assert_eq!(fnv1a(b"chongo w"), 0xd1edd10b507344d0); + assert_eq!(fnv1a(b"chongo wa"), 0x2a5ee739b3ddb8c3); + assert_eq!(fnv1a(b"chongo was"), 0xdcfb970ca1c0d310); + assert_eq!(fnv1a(b"chongo was "), 0x4054da76daa6da90); + assert_eq!(fnv1a(b"chongo was h"), 0xf70a2ff589861368); + assert_eq!(fnv1a(b"chongo was he"), 0x4c628b38aed25f17); + assert_eq!(fnv1a(b"chongo was her"), 0x9dd1f6510f78189f); + assert_eq!(fnv1a(b"chongo was here"), 0xa3de85bd491270ce); + assert_eq!(fnv1a(b"chongo was here!"), 0x858e2fa32a55e61d); + assert_eq!(fnv1a(b"chongo was here!\n"), 0x46810940eff5f915); + assert_eq!(fnv1a(b"ch\0"), 0xf5fadd190cf8edaa); + assert_eq!(fnv1a(b"cho\0"), 0xf273ed910b32b3e9); + assert_eq!(fnv1a(b"chon\0"), 0x2c8c5276062f6525); + assert_eq!(fnv1a(b"chong\0"), 0xe150b98c821842a0); + assert_eq!(fnv1a(b"chongo\0"), 0xf35aa3c10e4f55e7); + assert_eq!(fnv1a(b"chongo \0"), 0xd1ed680b50729265); + assert_eq!(fnv1a(b"chongo w\0"), 0x2a5f0639b3dded70); + assert_eq!(fnv1a(b"chongo wa\0"), 0xdcfbaa0ca1c0f359); + assert_eq!(fnv1a(b"chongo was\0"), 0x4054ba76daa6a430); + assert_eq!(fnv1a(b"chongo was \0"), 0xf709c7f5898562b0); + assert_eq!(fnv1a(b"chongo was h\0"), 0x4c62e638aed2f9b8); + assert_eq!(fnv1a(b"chongo was he\0"), 0x9dd1a8510f779415); + assert_eq!(fnv1a(b"chongo was her\0"), 0xa3de2abd4911d62d); + assert_eq!(fnv1a(b"chongo was here\0"), 0x858e0ea32a55ae0a); + assert_eq!(fnv1a(b"chongo was here!\0"), 0x46810f40eff60347); + assert_eq!(fnv1a(b"chongo was here!\n\0"), 0xc33bce57bef63eaf); + assert_eq!(fnv1a(b"cu"), 0x08a24307b54a0265); + assert_eq!(fnv1a(b"cur"), 0xf5b9fd190cc18d15); + assert_eq!(fnv1a(b"curd"), 0x4c968290ace35703); + assert_eq!(fnv1a(b"curds"), 0x07174bd5c64d9350); + assert_eq!(fnv1a(b"curds "), 0x5a294c3ff5d18750); + assert_eq!(fnv1a(b"curds a"), 0x05b3c1aeb308b843); + assert_eq!(fnv1a(b"curds an"), 0xb92a48da37d0f477); + assert_eq!(fnv1a(b"curds and"), 0x73cdddccd80ebc49); + assert_eq!(fnv1a(b"curds and "), 0xd58c4c13210a266b); + assert_eq!(fnv1a(b"curds and w"), 0xe78b6081243ec194); + assert_eq!(fnv1a(b"curds and wh"), 0xb096f77096a39f34); + assert_eq!(fnv1a(b"curds and whe"), 0xb425c54ff807b6a3); + assert_eq!(fnv1a(b"curds and whey"), 0x23e520e2751bb46e); + assert_eq!(fnv1a(b"curds and whey\n"), 0x1a0b44ccfe1385ec); + assert_eq!(fnv1a(b"cu\0"), 0xf5ba4b190cc2119f); + assert_eq!(fnv1a(b"cur\0"), 0x4c962690ace2baaf); + assert_eq!(fnv1a(b"curd\0"), 0x0716ded5c64cda19); + assert_eq!(fnv1a(b"curds\0"), 0x5a292c3ff5d150f0); + assert_eq!(fnv1a(b"curds \0"), 0x05b3e0aeb308ecf0); + assert_eq!(fnv1a(b"curds a\0"), 0xb92a5eda37d119d9); + assert_eq!(fnv1a(b"curds an\0"), 0x73ce41ccd80f6635); + assert_eq!(fnv1a(b"curds and\0"), 0xd58c2c132109f00b); + assert_eq!(fnv1a(b"curds and \0"), 0xe78baf81243f47d1); + assert_eq!(fnv1a(b"curds and w\0"), 0xb0968f7096a2ee7c); + assert_eq!(fnv1a(b"curds and wh\0"), 0xb425a84ff807855c); + assert_eq!(fnv1a(b"curds and whe\0"), 0x23e4e9e2751b56f9); + assert_eq!(fnv1a(b"curds and whey\0"), 0x1a0b4eccfe1396ea); + assert_eq!(fnv1a(b"curds and whey\n\0"), 0x54abd453bb2c9004); + assert_eq!(fnv1a(b"hi"), 0x08ba5f07b55ec3da); + assert_eq!(fnv1a(b"hi\0"), 0x337354193006cb6e); + assert_eq!(fnv1a(b"hello"), 0xa430d84680aabd0b); + assert_eq!(fnv1a(b"hello\0"), 0xa9bc8acca21f39b1); + assert_eq!(fnv1a(b"\xff\x00\x00\x01"), 0x6961196491cc682d); + assert_eq!(fnv1a(b"\x01\x00\x00\xff"), 0xad2bb1774799dfe9); + assert_eq!(fnv1a(b"\xff\x00\x00\x02"), 0x6961166491cc6314); + assert_eq!(fnv1a(b"\x02\x00\x00\xff"), 0x8d1bb3904a3b1236); + assert_eq!(fnv1a(b"\xff\x00\x00\x03"), 0x6961176491cc64c7); + assert_eq!(fnv1a(b"\x03\x00\x00\xff"), 0xed205d87f40434c7); + assert_eq!(fnv1a(b"\xff\x00\x00\x04"), 0x6961146491cc5fae); + assert_eq!(fnv1a(b"\x04\x00\x00\xff"), 0xcd3baf5e44f8ad9c); + assert_eq!(fnv1a(b"\x40\x51\x4e\x44"), 0xe3b36596127cd6d8); + assert_eq!(fnv1a(b"\x44\x4e\x51\x40"), 0xf77f1072c8e8a646); + assert_eq!(fnv1a(b"\x40\x51\x4e\x4a"), 0xe3b36396127cd372); + assert_eq!(fnv1a(b"\x4a\x4e\x51\x40"), 0x6067dce9932ad458); + assert_eq!(fnv1a(b"\x40\x51\x4e\x54"), 0xe3b37596127cf208); + assert_eq!(fnv1a(b"\x54\x4e\x51\x40"), 0x4b7b10fa9fe83936); + assert_eq!(fnv1a(b"127.0.0.1"), 0xaabafe7104d914be); + assert_eq!(fnv1a(b"127.0.0.1\0"), 0xf4d3180b3cde3eda); + assert_eq!(fnv1a(b"127.0.0.2"), 0xaabafd7104d9130b); + assert_eq!(fnv1a(b"127.0.0.2\0"), 0xf4cfb20b3cdb5bb1); + assert_eq!(fnv1a(b"127.0.0.3"), 0xaabafc7104d91158); + assert_eq!(fnv1a(b"127.0.0.3\0"), 0xf4cc4c0b3cd87888); + assert_eq!(fnv1a(b"64.81.78.68"), 0xe729bac5d2a8d3a7); + assert_eq!(fnv1a(b"64.81.78.68\0"), 0x74bc0524f4dfa4c5); + assert_eq!(fnv1a(b"64.81.78.74"), 0xe72630c5d2a5b352); + assert_eq!(fnv1a(b"64.81.78.74\0"), 0x6b983224ef8fb456); + assert_eq!(fnv1a(b"64.81.78.84"), 0xe73042c5d2ae266d); + assert_eq!(fnv1a(b"64.81.78.84\0"), 0x8527e324fdeb4b37); + assert_eq!(fnv1a(b"feedface"), 0x0a83c86fee952abc); + assert_eq!(fnv1a(b"feedface\0"), 0x7318523267779d74); + assert_eq!(fnv1a(b"feedfacedaffdeed"), 0x3e66d3d56b8caca1); + assert_eq!(fnv1a(b"feedfacedaffdeed\0"), 0x956694a5c0095593); + assert_eq!(fnv1a(b"feedfacedeadbeef"), 0xcac54572bb1a6fc8); + assert_eq!(fnv1a(b"feedfacedeadbeef\0"), 0xa7a4c9f3edebf0d8); + assert_eq!(fnv1a(b"line 1\nline 2\nline 3"), 0x7829851fac17b143); + assert_eq!(fnv1a(b"chongo /\\../\\"), 0x2c8f4c9af81bcf06); + assert_eq!(fnv1a(b"chongo /\\../\\\0"), 0xd34e31539740c732); + assert_eq!(fnv1a(b"chongo (Landon Curt Noll) /\\../\\"), 0x3605a2ac253d2db1); + assert_eq!(fnv1a(b"chongo (Landon Curt Noll) /\\../\\\0"), 0x08c11b8346f4a3c3); + assert_eq!(fnv1a(b"http://antwrp.gsfc.nasa.gov/apod/astropix.html"), 0x6be396289ce8a6da); + assert_eq!(fnv1a(b"http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash"), 0xd9b957fb7fe794c5); + assert_eq!(fnv1a(b"http://epod.usra.edu/"), 0x05be33da04560a93); + assert_eq!(fnv1a(b"http://exoplanet.eu/"), 0x0957f1577ba9747c); + assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/cam3/"), 0xda2cc3acc24fba57); + assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/cams/HMcam/"), 0x74136f185b29e7f0); + assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/kilauea/update/deformation.html"), 0xb2f2b4590edb93b2); + assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/kilauea/update/images.html"), 0xb3608fce8b86ae04); + assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/kilauea/update/maps.html"), 0x4a3a865079359063); + assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/volcanowatch/current_issue.html"), 0x5b3a7ef496880a50); + assert_eq!(fnv1a(b"http://neo.jpl.nasa.gov/risk/"), 0x48fae3163854c23b); + assert_eq!(fnv1a(b"http://norvig.com/21-days.html"), 0x07aaa640476e0b9a); + assert_eq!(fnv1a(b"http://primes.utm.edu/curios/home.php"), 0x2f653656383a687d); + assert_eq!(fnv1a(b"http://slashdot.org/"), 0xa1031f8e7599d79c); + assert_eq!(fnv1a(b"http://tux.wr.usgs.gov/Maps/155.25-19.5.html"), 0xa31908178ff92477); + assert_eq!(fnv1a(b"http://volcano.wr.usgs.gov/kilaueastatus.php"), 0x097edf3c14c3fb83); + assert_eq!(fnv1a(b"http://www.avo.alaska.edu/activity/Redoubt.php"), 0xb51ca83feaa0971b); + assert_eq!(fnv1a(b"http://www.dilbert.com/fast/"), 0xdd3c0d96d784f2e9); + assert_eq!(fnv1a(b"http://www.fourmilab.ch/gravitation/orbits/"), 0x86cd26a9ea767d78); + assert_eq!(fnv1a(b"http://www.fpoa.net/"), 0xe6b215ff54a30c18); + assert_eq!(fnv1a(b"http://www.ioccc.org/index.html"), 0xec5b06a1c5531093); + assert_eq!(fnv1a(b"http://www.isthe.com/cgi-bin/number.cgi"), 0x45665a929f9ec5e5); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/bio.html"), 0x8c7609b4a9f10907); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/index.html"), 0x89aac3a491f0d729); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/src/calc/lucas-calc"), 0x32ce6b26e0f4a403); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/astro/venus2004.html"), 0x614ab44e02b53e01); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/astro/vita.html"), 0xfa6472eb6eef3290); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/comp/c/expert.html"), 0x9e5d75eb1948eb6a); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/comp/calc/index.html"), 0xb6d12ad4a8671852); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/comp/fnv/index.html"), 0x88826f56eba07af1); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/math/number/howhigh.html"), 0x44535bf2645bc0fd); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/math/number/number.html"), 0x169388ffc21e3728); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/math/prime/mersenne.html"), 0xf68aac9e396d8224); + assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/math/prime/mersenne.html#largest"), 0x8e87d7e7472b3883); + assert_eq!(fnv1a(b"http://www.lavarnd.org/cgi-bin/corpspeak.cgi"), 0x295c26caa8b423de); + assert_eq!(fnv1a(b"http://www.lavarnd.org/cgi-bin/haiku.cgi"), 0x322c814292e72176); + assert_eq!(fnv1a(b"http://www.lavarnd.org/cgi-bin/rand-none.cgi"), 0x8a06550eb8af7268); + assert_eq!(fnv1a(b"http://www.lavarnd.org/cgi-bin/randdist.cgi"), 0xef86d60e661bcf71); + assert_eq!(fnv1a(b"http://www.lavarnd.org/index.html"), 0x9e5426c87f30ee54); + assert_eq!(fnv1a(b"http://www.lavarnd.org/what/nist-test.html"), 0xf1ea8aa826fd047e); + assert_eq!(fnv1a(b"http://www.macosxhints.com/"), 0x0babaf9a642cb769); + assert_eq!(fnv1a(b"http://www.mellis.com/"), 0x4b3341d4068d012e); + assert_eq!(fnv1a(b"http://www.nature.nps.gov/air/webcams/parks/havoso2alert/havoalert.cfm"), 0xd15605cbc30a335c); + assert_eq!(fnv1a(b"http://www.nature.nps.gov/air/webcams/parks/havoso2alert/timelines_24.cfm"), 0x5b21060aed8412e5); + assert_eq!(fnv1a(b"http://www.paulnoll.com/"), 0x45e2cda1ce6f4227); + assert_eq!(fnv1a(b"http://www.pepysdiary.com/"), 0x50ae3745033ad7d4); + assert_eq!(fnv1a(b"http://www.sciencenews.org/index/home/activity/view"), 0xaa4588ced46bf414); + assert_eq!(fnv1a(b"http://www.skyandtelescope.com/"), 0xc1b0056c4a95467e); + assert_eq!(fnv1a(b"http://www.sput.nl/~rob/sirius.html"), 0x56576a71de8b4089); + assert_eq!(fnv1a(b"http://www.systemexperts.com/"), 0xbf20965fa6dc927e); + assert_eq!(fnv1a(b"http://www.tq-international.com/phpBB3/index.php"), 0x569f8383c2040882); + assert_eq!(fnv1a(b"http://www.travelquesttours.com/index.htm"), 0xe1e772fba08feca0); + assert_eq!(fnv1a(b"http://www.wunderground.com/global/stations/89606.html"), 0x4ced94af97138ac4); + assert_eq!(fnv1a(&repeat_10(b"21701")), 0xc4112ffb337a82fb); + assert_eq!(fnv1a(&repeat_10(b"M21701")), 0xd64a4fd41de38b7d); + assert_eq!(fnv1a(&repeat_10(b"2^21701-1")), 0x4cfc32329edebcbb); + assert_eq!(fnv1a(&repeat_10(b"\x54\xc5")), 0x0803564445050395); + assert_eq!(fnv1a(&repeat_10(b"\xc5\x54")), 0xaa1574ecf4642ffd); + assert_eq!(fnv1a(&repeat_10(b"23209")), 0x694bc4e54cc315f9); + assert_eq!(fnv1a(&repeat_10(b"M23209")), 0xa3d7cb273b011721); + assert_eq!(fnv1a(&repeat_10(b"2^23209-1")), 0x577c2f8b6115bfa5); + assert_eq!(fnv1a(&repeat_10(b"\x5a\xa9")), 0xb7ec8c1a769fb4c1); + assert_eq!(fnv1a(&repeat_10(b"\xa9\x5a")), 0x5d5cfce63359ab19); + assert_eq!(fnv1a(&repeat_10(b"391581216093")), 0x33b96c3cd65b5f71); + assert_eq!(fnv1a(&repeat_10(b"391581*2^216093-1")), 0xd845097780602bb9); + assert_eq!(fnv1a(&repeat_10(b"\x05\xf9\x9d\x03\x4c\x81")), 0x84d47645d02da3d5); + assert_eq!(fnv1a(&repeat_10(b"FEDCBA9876543210")), 0x83544f33b58773a5); + assert_eq!(fnv1a(&repeat_10(b"\xfe\xdc\xba\x98\x76\x54\x32\x10")), 0x9175cbb2160836c5); + assert_eq!(fnv1a(&repeat_10(b"EFCDAB8967452301")), 0xc71b3bc175e72bc5); + assert_eq!(fnv1a(&repeat_10(b"\xef\xcd\xab\x89\x67\x45\x23\x01")), 0x636806ac222ec985); + assert_eq!(fnv1a(&repeat_10(b"0123456789ABCDEF")), 0xb6ef0e6950f52ed5); + assert_eq!(fnv1a(&repeat_10(b"\x01\x23\x45\x67\x89\xab\xcd\xef")), 0xead3d8a0f3dfdaa5); + assert_eq!(fnv1a(&repeat_10(b"1032547698BADCFE")), 0x922908fe9a861ba5); + assert_eq!(fnv1a(&repeat_10(b"\x10\x32\x54\x76\x98\xba\xdc\xfe")), 0x6d4821de275fd5c5); + assert_eq!(fnv1a(&repeat_500(b"\x00")), 0x1fe3fce62bd816b5); + assert_eq!(fnv1a(&repeat_500(b"\x07")), 0xc23e9fccd6f70591); + assert_eq!(fnv1a(&repeat_500(b"~")), 0xc1af12bdfe16b5b5); + assert_eq!(fnv1a(&repeat_500(b"\x7f")), 0x39e9f18f2f85e221); + } +} diff --git a/third_party/cargo/vendor/foreign-types-0.3.2/.cargo-checksum.json b/third_party/cargo/vendor/foreign-types-0.3.2/.cargo-checksum.json new file mode 100644 index 0000000..7e74bd5 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-0.3.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"1a667c28f60115423b68fea369255c2dcb129b8dce10f30e0e1da73d05f9adab","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"333ea3aaa3cadb819f4acd9f9153f9feee060a995ca8710f32bc5bd9a4b91734","README.md":"6f3f1429f2724a481df811842f318d0d3b83160ada953fd869d4b685f7fd72e4","src/lib.rs":"4f0a33bf8ec94a57d1b71e50f1af8ca410985e447f69fdc9c680545b03ea4566"},"package":"f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"} \ No newline at end of file diff --git a/third_party/cargo/vendor/foreign-types-0.3.2/BUILD b/third_party/cargo/vendor/foreign-types-0.3.2/BUILD new file mode 100644 index 0000000..e2782e8 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-0.3.2/BUILD @@ -0,0 +1,43 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "foreign_types", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/foreign-types-shared-0.1.1:foreign_types_shared", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.3.2", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/foreign-types-0.3.2/Cargo.toml b/third_party/cargo/vendor/foreign-types-0.3.2/Cargo.toml new file mode 100644 index 0000000..6ff5567 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-0.3.2/Cargo.toml @@ -0,0 +1,22 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "foreign-types" +version = "0.3.2" +authors = ["Steven Fackler "] +description = "A framework for Rust wrappers over C APIs" +readme = "README.md" +license = "MIT/Apache-2.0" +repository = "https://github.com/sfackler/foreign-types" +[dependencies.foreign-types-shared] +version = "0.1" diff --git a/third_party/cargo/vendor/foreign-types-0.3.2/LICENSE-APACHE b/third_party/cargo/vendor/foreign-types-0.3.2/LICENSE-APACHE new file mode 100644 index 0000000..8f71f43 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-0.3.2/LICENSE-APACHE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/third_party/cargo/vendor/foreign-types-0.3.2/LICENSE-MIT b/third_party/cargo/vendor/foreign-types-0.3.2/LICENSE-MIT new file mode 100644 index 0000000..bb76d01 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-0.3.2/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) 2017 The foreign-types Developers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/foreign-types-0.3.2/README.md b/third_party/cargo/vendor/foreign-types-0.3.2/README.md new file mode 100644 index 0000000..cd15965 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-0.3.2/README.md @@ -0,0 +1,23 @@ +# foreign-types + +[![CircleCI](https://circleci.com/gh/sfackler/foreign-types.svg?style=shield)](https://circleci.com/gh/sfackler/foreign-types) + +[Documentation](https://docs.rs/foreign-types) + +A framework for Rust wrappers over C APIs. + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally +submitted for inclusion in the work by you, as defined in the Apache-2.0 +license, shall be dual licensed as above, without any additional terms or +conditions. diff --git a/third_party/cargo/vendor/foreign-types-0.3.2/src/lib.rs b/third_party/cargo/vendor/foreign-types-0.3.2/src/lib.rs new file mode 100644 index 0000000..6ce9592 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-0.3.2/src/lib.rs @@ -0,0 +1,306 @@ +//! A framework for Rust wrappers over C APIs. +//! +//! Ownership is as important in C as it is in Rust, but the semantics are often implicit. In +//! particular, pointer-to-value is commonly used to pass C values both when transferring ownership +//! or a borrow. +//! +//! This crate provides a framework to define a Rust wrapper over these kinds of raw C APIs in a way +//! that allows ownership semantics to be expressed in an ergonomic manner. The framework takes a +//! dual-type approach similar to APIs in the standard library such as `PathBuf`/`Path` or `String`/ +//! `str`. One type represents an owned value and references to the other represent borrowed +//! values. +//! +//! # Examples +//! +//! ``` +//! use foreign_types::{ForeignType, ForeignTypeRef, Opaque}; +//! use std::ops::{Deref, DerefMut}; +//! +//! mod foo_sys { +//! pub enum FOO {} +//! +//! extern { +//! pub fn FOO_free(foo: *mut FOO); +//! } +//! } +//! +//! // The borrowed type is a newtype wrapper around an `Opaque` value. +//! // +//! // `FooRef` values never exist; we instead create references to `FooRef`s +//! // from raw C pointers. +//! pub struct FooRef(Opaque); +//! +//! impl ForeignTypeRef for FooRef { +//! type CType = foo_sys::FOO; +//! } +//! +//! // The owned type is simply a newtype wrapper around the raw C type. +//! // +//! // It dereferences to `FooRef`, so methods that do not require ownership +//! // should be defined there. +//! pub struct Foo(*mut foo_sys::FOO); +//! +//! impl Drop for Foo { +//! fn drop(&mut self) { +//! unsafe { foo_sys::FOO_free(self.0) } +//! } +//! } +//! +//! impl ForeignType for Foo { +//! type CType = foo_sys::FOO; +//! type Ref = FooRef; +//! +//! unsafe fn from_ptr(ptr: *mut foo_sys::FOO) -> Foo { +//! Foo(ptr) +//! } +//! +//! fn as_ptr(&self) -> *mut foo_sys::FOO { +//! self.0 +//! } +//! } +//! +//! impl Deref for Foo { +//! type Target = FooRef; +//! +//! fn deref(&self) -> &FooRef { +//! unsafe { FooRef::from_ptr(self.0) } +//! } +//! } +//! +//! impl DerefMut for Foo { +//! fn deref_mut(&mut self) -> &mut FooRef { +//! unsafe { FooRef::from_ptr_mut(self.0) } +//! } +//! } +//! ``` +//! +//! The `foreign_type!` macro can generate this boilerplate for you: +//! +//! ``` +//! #[macro_use] +//! extern crate foreign_types; +//! +//! mod foo_sys { +//! pub enum FOO {} +//! +//! extern { +//! pub fn FOO_free(foo: *mut FOO); +//! pub fn FOO_duplicate(foo: *mut FOO) -> *mut FOO; // Optional +//! } +//! } +//! +//! foreign_type! { +//! type CType = foo_sys::FOO; +//! fn drop = foo_sys::FOO_free; +//! fn clone = foo_sys::FOO_duplicate; // Optional +//! /// A Foo. +//! pub struct Foo; +//! /// A borrowed Foo. +//! pub struct FooRef; +//! } +//! +//! # fn main() {} +//! ``` +//! +//! If `fn clone` is specified, then it must take `CType` as an argument and return a copy of it as `CType`. +//! It will be used to implement `ToOwned` and `Clone`. +//! +//! `#[derive(…)] is permitted before the lines with `pub struct`. +//! `#[doc(hidden)]` before the `type CType` line will hide the `foreign_type!` implementations from documentation. +//! +//! Say we then have a separate type in our C API that contains a `FOO`: +//! +//! ``` +//! mod foo_sys { +//! pub enum FOO {} +//! pub enum BAR {} +//! +//! extern { +//! pub fn FOO_free(foo: *mut FOO); +//! pub fn BAR_free(bar: *mut BAR); +//! pub fn BAR_get_foo(bar: *mut BAR) -> *mut FOO; +//! } +//! } +//! ``` +//! +//! The documentation for the C library states that `BAR_get_foo` returns a reference into the `BAR` +//! passed to it, which translates into a reference in Rust. It also says that we're allowed to +//! modify the `FOO`, so we'll define a pair of accessor methods, one immutable and one mutable: +//! +//! ``` +//! #[macro_use] +//! extern crate foreign_types; +//! +//! use foreign_types::ForeignTypeRef; +//! +//! mod foo_sys { +//! pub enum FOO {} +//! pub enum BAR {} +//! +//! extern { +//! pub fn FOO_free(foo: *mut FOO); +//! pub fn BAR_free(bar: *mut BAR); +//! pub fn BAR_get_foo(bar: *mut BAR) -> *mut FOO; +//! } +//! } +//! +//! foreign_type! { +//! #[doc(hidden)] +//! type CType = foo_sys::FOO; +//! fn drop = foo_sys::FOO_free; +//! /// A Foo. +//! pub struct Foo; +//! /// A borrowed Foo. +//! pub struct FooRef; +//! } +//! +//! foreign_type! { +//! type CType = foo_sys::BAR; +//! fn drop = foo_sys::BAR_free; +//! /// A Foo. +//! pub struct Bar; +//! /// A borrowed Bar. +//! pub struct BarRef; +//! } +//! +//! impl BarRef { +//! fn foo(&self) -> &FooRef { +//! unsafe { FooRef::from_ptr(foo_sys::BAR_get_foo(self.as_ptr())) } +//! } +//! +//! fn foo_mut(&mut self) -> &mut FooRef { +//! unsafe { FooRef::from_ptr_mut(foo_sys::BAR_get_foo(self.as_ptr())) } +//! } +//! } +//! +//! # fn main() {} +//! ``` +#![no_std] +#![warn(missing_docs)] +#![doc(html_root_url="https://docs.rs/foreign-types/0.3")] +extern crate foreign_types_shared; + +#[doc(inline)] +pub use foreign_types_shared::*; + +/// A macro to easily define wrappers for foreign types. +/// +/// # Examples +/// +/// ``` +/// #[macro_use] +/// extern crate foreign_types; +/// +/// # mod openssl_sys { pub type SSL = (); pub unsafe fn SSL_free(_: *mut SSL) {} pub unsafe fn SSL_dup(x: *mut SSL) -> *mut SSL {x} } +/// foreign_type! { +/// type CType = openssl_sys::SSL; +/// fn drop = openssl_sys::SSL_free; +/// fn clone = openssl_sys::SSL_dup; +/// /// Documentation for the owned type. +/// pub struct Ssl; +/// /// Documentation for the borrowed type. +/// pub struct SslRef; +/// } +/// +/// # fn main() {} +/// ``` +#[macro_export] +macro_rules! foreign_type { + ( + $(#[$impl_attr:meta])* + type CType = $ctype:ty; + fn drop = $drop:expr; + $(fn clone = $clone:expr;)* + $(#[$owned_attr:meta])* + pub struct $owned:ident; + $(#[$borrowed_attr:meta])* + pub struct $borrowed:ident; + ) => { + $(#[$owned_attr])* + pub struct $owned(*mut $ctype); + + $(#[$impl_attr])* + impl $crate::ForeignType for $owned { + type CType = $ctype; + type Ref = $borrowed; + + #[inline] + unsafe fn from_ptr(ptr: *mut $ctype) -> $owned { + $owned(ptr) + } + + #[inline] + fn as_ptr(&self) -> *mut $ctype { + self.0 + } + } + + impl Drop for $owned { + #[inline] + fn drop(&mut self) { + unsafe { $drop(self.0) } + } + } + + $( + impl Clone for $owned { + #[inline] + fn clone(&self) -> $owned { + unsafe { + let handle: *mut $ctype = $clone(self.0); + $crate::ForeignType::from_ptr(handle) + } + } + } + + impl ::std::borrow::ToOwned for $borrowed { + type Owned = $owned; + #[inline] + fn to_owned(&self) -> $owned { + unsafe { + let handle: *mut $ctype = $clone($crate::ForeignTypeRef::as_ptr(self)); + $crate::ForeignType::from_ptr(handle) + } + } + } + )* + + impl ::std::ops::Deref for $owned { + type Target = $borrowed; + + #[inline] + fn deref(&self) -> &$borrowed { + unsafe { $crate::ForeignTypeRef::from_ptr(self.0) } + } + } + + impl ::std::ops::DerefMut for $owned { + #[inline] + fn deref_mut(&mut self) -> &mut $borrowed { + unsafe { $crate::ForeignTypeRef::from_ptr_mut(self.0) } + } + } + + impl ::std::borrow::Borrow<$borrowed> for $owned { + #[inline] + fn borrow(&self) -> &$borrowed { + &**self + } + } + + impl ::std::convert::AsRef<$borrowed> for $owned { + #[inline] + fn as_ref(&self) -> &$borrowed { + &**self + } + } + + $(#[$borrowed_attr])* + pub struct $borrowed($crate::Opaque); + + $(#[$impl_attr])* + impl $crate::ForeignTypeRef for $borrowed { + type CType = $ctype; + } + } +} diff --git a/third_party/cargo/vendor/foreign-types-shared-0.1.1/.cargo-checksum.json b/third_party/cargo/vendor/foreign-types-shared-0.1.1/.cargo-checksum.json new file mode 100644 index 0000000..2d6d891 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-shared-0.1.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"6b91ae600fe7b521537096b2269ab7bfd606f8a1fcd97749634dd03ba18daf53","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"333ea3aaa3cadb819f4acd9f9153f9feee060a995ca8710f32bc5bd9a4b91734","src/lib.rs":"77aed289fd36258c273f033e766e572ee05330249083c017d045f0a75662f5df"},"package":"00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"} \ No newline at end of file diff --git a/third_party/cargo/vendor/foreign-types-shared-0.1.1/BUILD b/third_party/cargo/vendor/foreign-types-shared-0.1.1/BUILD new file mode 100644 index 0000000..980b3f7 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-shared-0.1.1/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "foreign_types_shared", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/foreign-types-shared-0.1.1/Cargo.toml b/third_party/cargo/vendor/foreign-types-shared-0.1.1/Cargo.toml new file mode 100644 index 0000000..e2cb783 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-shared-0.1.1/Cargo.toml @@ -0,0 +1,21 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "foreign-types-shared" +version = "0.1.1" +authors = ["Steven Fackler "] +description = "An internal crate used by foreign-types" +license = "MIT/Apache-2.0" +repository = "https://github.com/sfackler/foreign-types" + +[dependencies] diff --git a/third_party/cargo/vendor/foreign-types-shared-0.1.1/LICENSE-APACHE b/third_party/cargo/vendor/foreign-types-shared-0.1.1/LICENSE-APACHE new file mode 100644 index 0000000..8f71f43 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-shared-0.1.1/LICENSE-APACHE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/third_party/cargo/vendor/foreign-types-shared-0.1.1/LICENSE-MIT b/third_party/cargo/vendor/foreign-types-shared-0.1.1/LICENSE-MIT new file mode 100644 index 0000000..bb76d01 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-shared-0.1.1/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) 2017 The foreign-types Developers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/foreign-types-shared-0.1.1/src/lib.rs b/third_party/cargo/vendor/foreign-types-shared-0.1.1/src/lib.rs new file mode 100644 index 0000000..cbebc33 --- /dev/null +++ b/third_party/cargo/vendor/foreign-types-shared-0.1.1/src/lib.rs @@ -0,0 +1,51 @@ +//! Internal crate used by foreign-types + +#![no_std] +#![warn(missing_docs)] +#![doc(html_root_url="https://docs.rs/foreign-types-shared/0.1")] + +use core::cell::UnsafeCell; + +/// An opaque type used to define `ForeignTypeRef` types. +/// +/// A type implementing `ForeignTypeRef` should simply be a newtype wrapper around this type. +pub struct Opaque(UnsafeCell<()>); + +/// A type implemented by wrappers over foreign types. +pub trait ForeignType: Sized { + /// The raw C type. + type CType; + + /// The type representing a reference to this type. + type Ref: ForeignTypeRef; + + /// Constructs an instance of this type from its raw type. + unsafe fn from_ptr(ptr: *mut Self::CType) -> Self; + + /// Returns a raw pointer to the wrapped value. + fn as_ptr(&self) -> *mut Self::CType; +} + +/// A trait implemented by types which reference borrowed foreign types. +pub trait ForeignTypeRef: Sized { + /// The raw C type. + type CType; + + /// Constructs a shared instance of this type from its raw type. + #[inline] + unsafe fn from_ptr<'a>(ptr: *mut Self::CType) -> &'a Self { + &*(ptr as *mut _) + } + + /// Constructs a mutable reference of this type from its raw type. + #[inline] + unsafe fn from_ptr_mut<'a>(ptr: *mut Self::CType) -> &'a mut Self { + &mut *(ptr as *mut _) + } + + /// Returns a raw pointer to the wrapped value. + #[inline] + fn as_ptr(&self) -> *mut Self::CType { + self as *const _ as *mut _ + } +} diff --git a/third_party/cargo/vendor/fuchsia-cprng-0.1.1/.cargo-checksum.json b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/.cargo-checksum.json new file mode 100644 index 0000000..d92a5f0 --- /dev/null +++ b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"AUTHORS":"f82920a5bcfc71b86c1de4be4cdea8af2009ba9e5735824f95ed5043a03e46f0","Cargo.toml":"bb2497b2907c3af499ce7ac3722dae044968e13409a372b7760150f8a01c74c5","LICENSE":"03b114f53e6587a398931762ee11e2395bfdba252a329940e2c8c9e81813845b","PATENTS":"52beb3ac72a0e7f5060384d16e4e6f91573016448fbff363c0b01a66fe99f547","src/lib.rs":"3d76c35c13203093ddf7ce2a3be5e98d768a8091cd9d99bd083fe8db35364096"},"package":"a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"} \ No newline at end of file diff --git a/third_party/cargo/vendor/fuchsia-cprng-0.1.1/AUTHORS b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/AUTHORS new file mode 100644 index 0000000..61ae302 --- /dev/null +++ b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/AUTHORS @@ -0,0 +1,10 @@ +# This is the list of Fuchsia Authors. + +# Names should be added to this file as one of +# Organization's name +# Individual's name +# Individual's name + +Google Inc. +The Chromium Authors +The Go Authors diff --git a/third_party/cargo/vendor/fuchsia-cprng-0.1.1/BUILD b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/BUILD new file mode 100644 index 0000000..9ea8962 --- /dev/null +++ b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/BUILD @@ -0,0 +1,42 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "no license" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "fuchsia_cprng", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.1", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/fuchsia-cprng-0.1.1/Cargo.toml b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/Cargo.toml new file mode 100644 index 0000000..917b430 --- /dev/null +++ b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/Cargo.toml @@ -0,0 +1,22 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "fuchsia-cprng" +version = "0.1.1" +authors = ["Erick Tryzelaar "] +include = ["src/*.rs", "Cargo.toml", "AUTHORS", "LICENSE", "PATENTS"] +description = "Rust crate for the Fuchsia cryptographically secure pseudorandom number generator" +readme = "README.md" +license-file = "LICENSE" +repository = "https://fuchsia.googlesource.com/fuchsia/+/master/garnet/public/rust/fuchsia-cprng" diff --git a/third_party/cargo/vendor/fuchsia-cprng-0.1.1/LICENSE b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/LICENSE new file mode 100644 index 0000000..87f152c --- /dev/null +++ b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/LICENSE @@ -0,0 +1,27 @@ +Copyright 2019 The Fuchsia Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/third_party/cargo/vendor/fuchsia-cprng-0.1.1/PATENTS b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/PATENTS new file mode 100644 index 0000000..2746e78 --- /dev/null +++ b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Fuchsia project. + +Google hereby grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this +section) patent license to make, have made, use, offer to sell, sell, +import, transfer, and otherwise run, modify and propagate the contents +of this implementation of Fuchsia, where such license applies only to +those patent claims, both currently owned by Google and acquired in +the future, licensable by Google that are necessarily infringed by +this implementation. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute +or order or agree to the institution of patent litigation or any other +patent enforcement activity against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that this +implementation of Fuchsia constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of +Fuchsia shall terminate as of the date such litigation is filed. diff --git a/third_party/cargo/vendor/fuchsia-cprng-0.1.1/src/lib.rs b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/src/lib.rs new file mode 100644 index 0000000..5074690 --- /dev/null +++ b/third_party/cargo/vendor/fuchsia-cprng-0.1.1/src/lib.rs @@ -0,0 +1,57 @@ +// Copyright 2019 The Fuchsia Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +//! Type-safe bindings for the Zircon kernel's CPRNG. + +#![no_std] +#![deny(warnings)] + +/// Draw random bytes from the kernel's CPRNG to fill the given buffer. +/// +/// Wraps the +/// [zx_cprng_draw](https://fuchsia.googlesource.com/fuchsia/+/master/zircon/docs/syscalls/cprng_draw.md) +/// syscall. +pub fn cprng_draw(buffer: &mut [u8]) { + unsafe { zx_cprng_draw(buffer.as_mut_ptr(), buffer.len()) }; +} + +#[link(name = "zircon")] +extern "C" { + fn zx_cprng_draw(buffer: *mut u8, length: usize); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn cprng() { + let mut buffer = [0; 20]; + cprng_draw(&mut buffer); + let mut first_zero = 0; + let mut last_zero = 0; + for _ in 0..30 { + let mut buffer = [0; 20]; + cprng_draw(&mut buffer); + if buffer[0] == 0 { + first_zero += 1; + } + if buffer[19] == 0 { + last_zero += 1; + } + } + assert_ne!(first_zero, 30); + assert_ne!(last_zero, 30); + } + + #[test] + fn cprng_large() { + let mut buffer = [0; 1024]; + cprng_draw(&mut buffer); + + for mut s in buffer.chunks_mut(256) { + cprng_draw(&mut s); + } + } +} diff --git a/third_party/cargo/vendor/half-1.4.0/.cargo-checksum.json b/third_party/cargo/vendor/half-1.4.0/.cargo-checksum.json new file mode 100644 index 0000000..57afc93 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"7d7fdbc8076d3b67d2cc0e4dc8ca65d6e1fc4359295678c58acf5a45481a9e0a","Cargo.toml":"06d86b5350a08a702b25667b16cfa1fdaee12854303e7cf820e2663547120191","LICENSE-APACHE":"98811e25dec78a24fb82837189c32bbe92da4c451b6025f298e1211c3d54ece7","LICENSE-MIT":"324c631f284305f692d67146145d452f3cb7289e4790c9313e6a4e0042338fa3","README.md":"b780bb92d399b277beacfbc21a2f224dee361f2c8f59879228df3da9a0cfc866","appveyor.yml":"883c3c7deffed426381a5fba0d40bf0475367cd0d78253a4648d2b19d6784ecd","benches/convert.rs":"203b5fa6a9279109f959802d2583e5a9e7dd22759476e5d83071038c743698a1","src/bfloat.rs":"159ddc802ea69ff1ffc81a9e0d6037ab170b1676b185e0f6abc278b57c086829","src/bfloat/convert.rs":"0acf69a85ed51eb7ac0ad689b513873e5276c839f7db143a2e1721331b321af6","src/binary16.rs":"4775701c63f1c6a5ab5a7ec132fbcc77c42d145814d01adddb92aef6dcda5523","src/binary16/convert.rs":"64345616f8058670c159cde04a58665219116116646c75b48e894a442268a67b","src/lib.rs":"f4be76526b881cdbe119d8aa58bf15b14f8979f38b9684708827701bb5f8e538","src/slice.rs":"826961d337748c98ccb09f6a9f18a571024568b1716af27cc7463333e4f44b38","src/vec.rs":"8f5ab19d30af4e3ff6b92169d81c74f40112c371c4c9c58bd5821892c6b9f13d","tests/version-numbers.rs":"370467b40ce930d655389ba82015ae2842b3361bf24280c3dc7214d3ac163a2d"},"package":"9ff54597ea139063f4225f1ec47011b03c9de4a486957ff3fc506881dac951d0"} \ No newline at end of file diff --git a/third_party/cargo/vendor/half-1.4.0/BUILD b/third_party/cargo/vendor/half-1.4.0/BUILD new file mode 100644 index 0000000..0dba0f5 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "convert" with type "bench" omitted + +rust_library( + name = "half", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2018", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.4.0", + crate_features = [ + ], +) + +# Unsupported target "version-numbers" with type "test" omitted diff --git a/third_party/cargo/vendor/half-1.4.0/CHANGELOG.md b/third_party/cargo/vendor/half-1.4.0/CHANGELOG.md new file mode 100644 index 0000000..d593dc3 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/CHANGELOG.md @@ -0,0 +1,143 @@ +# Changelog + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.4.0] - 2019-10-13 +### Added +- Added a `bf16` type implementing the alternative + [`bfloat16`](https://en.wikipedia.org/wiki/Bfloat16_floating-point_format) 16-bit floating point + format. By [@tspiteri]. +- `f16::from_bits`, `f16::to_bits`, `f16::is_nan`, `f16::is_infinite`, `f16::is_finite`, + `f16::is_sign_positive`, and `f16::is_sign_negative` are now `const` fns. +- `slice::HalfBitsSliceExt` and `slice::HalfBitsSliceExt` extension traits have been added for + performing efficient reinterpret casts and conversions of slices to and from `[f16]` and + `[bf16]`. These traits will use hardware SIMD conversion instructions when available and the + `use-intrinsics` cargo feature is enabled. +- `vec::HalfBitsVecExt` and `vec::HalfFloatVecExt` extension traits have been added for + performing efficient reinterpret casts to and from `Vec` and `Vec`. These traits + are only available with the `std` cargo feature. +- `prelude` has been added, for easy importing of most common functionality. Currently the + prelude imports `f16`, `bf16`, and the new slice and vec extension traits. +- New associated constants on `f16` type to replace deprecated `consts` module. + +### Fixed +- Software conversion (when not using `use-intrinsics` feature) now matches hardware rounding + by rounding to nearest, ties to even. Fixes [#24], by [@tspiteri]. +- NaN value conversions now behave like `f32` to `f64` conversions, retaining sign. Fixes [#23], + by [@tspiteri]. + +### Changed +- Minimum rustc version bumped to 1.32. +- Runtime target host feature detection is now used if both `std` and `use-intrinsics` features are enabled + and the compile target host does not support required features. +- When `use-intrinsics` feature is enabled, will now always compile and run without error correctly regardless + of compile target options. + +### Deprecated +- `consts` module and all its constants have been deprecated; use the associated constants on `f16` instead. +- `slice::from_bits` has been deprecated; use `slice::HalfBitsSliceExt::reinterpret_cast` instead. +- `slice::from_bits_mut` has been deprecated; use `slice::HalfBitsSliceExt::reinterpret_cast_mut` instead. +- `slice::to_bits` has been deprecated; use `slice::HalfFloatSliceExt::reinterpret_cast` instead. +- `slice::to_bits_mut` has been deprecated; use `slice::HalfFloatSliceExt::reinterpret_cast_mut` instead. +- `vec::from_bits` has been deprecated; use `vec::HalfBitsVecExt::reinterpret_into` instead. +- `vec::to_bits` has been deprecated; use `vec::HalfFloatVecExt::reinterpret_into` instead. + +## [1.3.1] - 2019-10-04 +### Fixed +- Corrected values of constants `EPSILON`, `MAX_10_EXP`, `MAX_EXP`, `MIN_10_EXP`, and `MIN_EXP` + in `consts` module, as well as setting `consts::NAN` to match value of `f32::NAN` converted to + `f16`. By [@tspiteri]. + +## [1.3.0] - 2018-10-02 +### Added +- `slice::from_bits_mut` and `slice::to_bits_mut` for conversion between mutable `u16` and `f16` +slices. Fixes [#16], by [@johannesvollmer]. + +## [1.2.0] - 2018-09-03 +### Added +- `slice` and optional `vec` (only included with `std` feature) modules for conversions between `u16` and `f16` +buffers. Fixes [#14], by [@johannesvollmer]. +- `to_bits` added to replace `as_bits`. Fixes [#12], by [@tspiteri]. +### Fixed +- `serde` optional dependency no longer uses its default `std` feature. +### Deprecated +- `as_bits` has been deprecated; use `to_bits` instead. +- `serialize` cargo feature is deprecated; use `serde` instead. + +## [1.1.2] - 2018-07-12 +### Fixed +- Fixed compilation error in 1.1.1 on rustc < 1.27, now compiles again on rustc >= 1.10. Fixes [#11]. + +## [1.1.1] - 2018-06-24 - **Yanked** +### ***Yanked*** +*Not recommended due to introducing compilation error on rustc versions prior to 1.27.* +### Fixed +- Fix subnormal float conversions when `use-intrinsics` is not enabled. By [@Moongoodboy-K]. + +## [1.1.0] - 2018-03-17 +### Added +- Made `to_f32` and `to_f64` public. Fixes [#7], by [@PSeitz]. + +## [1.0.2] - 2018-01-12 +### Changed +- Update behavior of `is_sign_positive` and `is_sign_negative` to match the IEEE754 conforming +behavior of the standard library since Rust 1.20.0. Fixes [#3], by [@tspiteri]. +- Small optimization on `is_nan` and `is_infinite` from [@tspiteri]. +### Fixed +- Fix comparisons of +0 to -0 and comparisons involving negative numbers. Fixes [#2], by [@tspiteri]. +- Fix loss of sign when converting `f16` and `f32` to `f16`, and case where `f64` NaN could be +converted to `f16` infinity instead of NaN. Fixes [#5], by [@tspiteri]. + +## [1.0.1] - 2017-08-30 +### Added +- More README documentation. +- Badges and categories in crate metadata. +### Changed +- `serde` dependency updated to 1.0 stable. +- Writing changelog manually. + +## [1.0.0] - 2017-02-03 +### Added +- Update to `serde` 0.9 and stable Rust 1.15 for `serialize` feature. + +## [0.1.1] - 2017-01-08 +### Added +- Add `serde` support under new `serialize` feature. +### Changed +- Use `no_std` for crate by default. + +## 0.1.0 - 2016-03-17 +### Added +- Initial release of `f16` type. + +[#2]: https://github.com/starkat99/half-rs/issues/2 +[#3]: https://github.com/starkat99/half-rs/issues/3 +[#5]: https://github.com/starkat99/half-rs/issues/5 +[#7]: https://github.com/starkat99/half-rs/issues/7 +[#11]: https://github.com/starkat99/half-rs/issues/11 +[#12]: https://github.com/starkat99/half-rs/issues/12 +[#14]: https://github.com/starkat99/half-rs/issues/14 +[#16]: https://github.com/starkat99/half-rs/issues/16 +[#23]: https://github.com/starkat99/half-rs/issues/23 +[#24]: https://github.com/starkat99/half-rs/issues/24 + +[@tspiteri]: https://github.com/tspiteri +[@PSeitz]: https://github.com/PSeitz +[@Moongoodboy-K]: https://github.com/Moongoodboy-K +[@johannesvollmer]: https://github.com/johannesvollmer + +[Unreleased]: https://github.com/starkat99/half-rs/compare/v1.4.0...HEAD +[1.4.0]: https://github.com/starkat99/half-rs/compare/v1.3.1...v1.4.0 +[1.3.1]: https://github.com/starkat99/half-rs/compare/v1.3.0...v1.3.1 +[1.3.0]: https://github.com/starkat99/half-rs/compare/v1.2.0...v1.3.0 +[1.2.0]: https://github.com/starkat99/half-rs/compare/v1.1.2...v1.2.0 +[1.1.2]: https://github.com/starkat99/half-rs/compare/v1.1.1...v1.1.2 +[1.1.1]: https://github.com/starkat99/half-rs/compare/v1.1.0...v1.1.1 +[1.1.0]: https://github.com/starkat99/half-rs/compare/v1.0.2...v1.1.0 +[1.0.2]: https://github.com/starkat99/half-rs/compare/v1.0.1...v1.0.2 +[1.0.1]: https://github.com/starkat99/half-rs/compare/v1.0.0...v1.0.1 +[1.0.0]: https://github.com/starkat99/half-rs/compare/v0.1.1...v1.0.0 +[0.1.1]: https://github.com/starkat99/half-rs/compare/v0.1.0...v0.1.1 diff --git a/third_party/cargo/vendor/half-1.4.0/Cargo.toml b/third_party/cargo/vendor/half-1.4.0/Cargo.toml new file mode 100644 index 0000000..f5a26ab --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/Cargo.toml @@ -0,0 +1,61 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "half" +version = "1.4.0" +authors = ["Kathryn Long "] +description = "Half-precision floating point f16 and bf16 types for Rust implementing the IEEE 754-2008 standard binary16 and bfloat16 types." +readme = "README.md" +keywords = ["f16", "bfloat16", "no_std"] +categories = ["no-std", "data-structures", "encoding"] +license = "MIT/Apache-2.0" +repository = "https://github.com/starkat99/half-rs" +[package.metadata.docs.rs] +features = ["std", "serde"] + +[[bench]] +name = "convert" +harness = false +[dependencies.serde] +version = "1.0" +features = ["derive"] +optional = true +default-features = false +[dev-dependencies.criterion] +version = "0.3" + +[dev-dependencies.quickcheck] +version = "0.9" + +[dev-dependencies.quickcheck_macros] +version = "0.8" + +[dev-dependencies.rand] +version = "0.7" + +[dev-dependencies.version-sync] +version = "0.8.1" + +[features] +serialize = ["serde"] +std = [] +use-intrinsics = [] +[badges.appveyor] +repository = "starkat99/half-rs" + +[badges.maintenance] +status = "passively-maintained" + +[badges.travis-ci] +repository = "starkat99/half-rs" diff --git a/third_party/cargo/vendor/half-1.4.0/LICENSE-APACHE b/third_party/cargo/vendor/half-1.4.0/LICENSE-APACHE new file mode 100644 index 0000000..453d41b --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/third_party/cargo/vendor/half-1.4.0/LICENSE-MIT b/third_party/cargo/vendor/half-1.4.0/LICENSE-MIT new file mode 100644 index 0000000..1d563bc --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 Kathryn Long + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/third_party/cargo/vendor/half-1.4.0/README.md b/third_party/cargo/vendor/half-1.4.0/README.md new file mode 100644 index 0000000..1c53bc2 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/README.md @@ -0,0 +1,57 @@ +# `f16` and `bf16` floating point types for Rust +[![Crates.io](https://img.shields.io/crates/v/half.svg)](https://crates.io/crates/half/) [![docs.rs](https://docs.rs/half/badge.svg)](https://docs.rs/half/) [![Build Status](https://travis-ci.org/starkat99/half-rs.svg?branch=master)](https://travis-ci.org/starkat99/half-rs) [![Build status](https://ci.appveyor.com/api/projects/status/bi18aypi3h5r88gs?svg=true)](https://ci.appveyor.com/project/starkat99/half-rs) + +This crate implements a half-precision floating point `f16` type for Rust implementing the IEEE 754-2008 standard +[`binary16`](https://en.wikipedia.org/wiki/Half-precision_floating-point_format) a.k.a `half` format, +as well as a `bf16` type implementing the [`bfloat16`](https://en.wikipedia.org/wiki/Bfloat16_floating-point_format) format. + +## Usage + +The `f16` and `bf16` types provides conversion operations as a normal Rust floating point type, but since they are primarily leveraged for +minimal floating point storage and most major hardware does not implement them, all math operations should be done as an `f32` type. + +This crate provides [`no_std`](https://rust-embedded.github.io/book/intro/no-std.html) support by default so can easily be used in embedded +code where a smaller float format is most useful. + +*Requries Rust 1.32 or greater.* If you need support for older versions of Rust, use versions 1.3 and earlier of this crate. + +See the [crate documentation](https://docs.rs/half/) for more details. + +### Optional Features + +- **`serde`** - Implement `Serialize` and `Deserialize` traits for `f16` and `bf16`. This adds a dependency on the +[`serde`](https://crates.io/crates/serde) crate. + +- **`use-intrinsics`** - Use hardware intrinsics for `f16` and `bf16` conversions if available on the compiler host target. By +default, without this feature, conversions are done only in software, which will be the fallback if the host target does +not have hardware support. **Available only on Rust nightly channel.** + +- **`std`** - Enable features that depend on the Rust `std` library. + + This enables the `vec` module, which contains zero-copy conversions for the `Vec` type. This allows fast conversion between + raw `Vec` bits and `Vec` or `Vec` arrays, and vice versa. + + In addition, enabling the `std` feature enables runtime CPU feature detection when the `use-intrsincis` feature is also enabled. + Without this feature detection, intrinsics are only used when compiler host target supports them. + +### More Documentation + +- [Crate API Reference](https://docs.rs/half/) +- [Latest Changes](CHANGELOG.md) + +## License + +This library is distributed under the terms of either of: + +* MIT license ([LICENSE-MIT](LICENSE-MIT) or +[http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT)) +* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or +[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)) + +at your option. + +### Contributing + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the +work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any +additional terms or conditions. \ No newline at end of file diff --git a/third_party/cargo/vendor/half-1.4.0/appveyor.yml b/third_party/cargo/vendor/half-1.4.0/appveyor.yml new file mode 100644 index 0000000..39ed022 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/appveyor.yml @@ -0,0 +1,141 @@ +# Appveyor configuration template for Rust using rustup for Rust installation +# https://github.com/starkat99/appveyor-rust + +branches: + except: + - gh-pages + +## Operating System (VM environment) ## + +# Rust needs at least Visual Studio 2013 Appveyor OS for MSVC targets. +os: Visual Studio 2015 + +## Build Matrix ## + +# This configuration will setup a build for each channel & target combination (12 windows +# combinations in all). +# +# There are 3 channels: stable, beta, and nightly. +# +# Alternatively, the full version may be specified for the channel to build using that specific +# version (e.g. channel: 1.5.0) +# +# The values for target are the set of windows Rust build targets. Each value is of the form +# +# ARCH-pc-windows-TOOLCHAIN +# +# Where ARCH is the target architecture, either x86_64 or i686, and TOOLCHAIN is the linker +# toolchain to use, either msvc or gnu. See https://www.rust-lang.org/downloads.html#win-foot for +# a description of the toolchain differences. +# See https://github.com/rust-lang-nursery/rustup.rs/#toolchain-specification for description of +# toolchains and host triples. +# +# Comment out channel/target combos you do not wish to build in CI. +# +# You may use the `cargoflags` and `RUSTFLAGS` variables to set additional flags for cargo commands +# and rustc, respectively. For instance, you can uncomment the cargoflags lines in the nightly +# channels to enable unstable features when building for nightly. Or you could add additional +# matrix entries to test different combinations of features. +environment: + matrix: + +### MSVC Toolchains ### + + # Stable 64-bit MSVC + - channel: stable + target: x86_64-pc-windows-msvc + # Stable 32-bit MSVC + - channel: stable + target: i686-pc-windows-msvc + # Stable 64-bit MSVC w/ optional features + - channel: stable + target: x86_64-pc-windows-msvc + cargoflags: --features "std serde" + # Stable 32-bit MSVC w/ optional features + - channel: stable + target: i686-pc-windows-msvc + cargoflags: --features "std serde" + # Beta 64-bit MSVC + - channel: beta + target: x86_64-pc-windows-msvc + # Beta 32-bit MSVC + - channel: beta + target: i686-pc-windows-msvc + # Nightly 64-bit MSVC w/ nightly features + - channel: nightly + target: x86_64-pc-windows-msvc + cargoflags: --features "use-intrinsics" + # Nightly 32-bit MSVC w/ nightly features + - channel: nightly + target: i686-pc-windows-msvc + cargoflags: --features "use-intrinsics" + +### GNU Toolchains ### + + # Stable 64-bit GNU + - channel: stable + target: x86_64-pc-windows-gnu + # Stable 32-bit GNU + - channel: stable + target: i686-pc-windows-gnu + # Stable 64-bit GNU w/ optional features + - channel: stable + target: x86_64-pc-windows-gnu + cargoflags: --features "std serde" + # Stable 32-bit GNU w/ optional features + - channel: stable + target: i686-pc-windows-gnu + cargoflags: --features "std serde" + # Beta 64-bit GNU + - channel: beta + target: x86_64-pc-windows-gnu + # Beta 32-bit GNU + - channel: beta + target: i686-pc-windows-gnu + # Nightly 64-bit GNU w/ nightly features + - channel: nightly + target: x86_64-pc-windows-gnu + cargoflags: --features "use-intrinsics" + # Nightly 32-bit GNU w/ nightly features + - channel: nightly + target: i686-pc-windows-gnu + cargoflags: --features "use-intrinsics" + +### Allowed failures ### + +# See Appveyor documentation for specific details. In short, place any channel or targets you wish +# to allow build failures on (usually nightly at least is a wise choice). This will prevent a build +# or test failure in the matching channels/targets from failing the entire build. +#matrix: +# allow_failures: +# - channel: nightly + +# If you only care about stable channel build failures, uncomment the following line: + #- channel: beta + +## Install Script ## + +# This is the most important part of the Appveyor configuration. This installs the version of Rust +# specified by the 'channel' and 'target' environment variables from the build matrix. This uses +# rustup to install Rust. +# +# For simple configurations, instead of using the build matrix, you can simply set the +# default-toolchain and default-host manually here. +install: + - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe + - rustup-init -yv --default-toolchain %channel% --default-host %target% + - set PATH=%PATH%;%USERPROFILE%\.cargo\bin + - rustc -vV + - cargo -vV + +## Build Script ## + +# 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents +# the "directory does not contain a project or solution file" error. +build: false + +# Uses 'cargo test' to run tests and build. Alternatively, the project may call compiled programs +#directly or perform other testing commands. Rust will automatically be placed in the PATH +# environment variable. +test_script: + - cargo test --verbose %cargoflags% diff --git a/third_party/cargo/vendor/half-1.4.0/benches/convert.rs b/third_party/cargo/vendor/half-1.4.0/benches/convert.rs new file mode 100644 index 0000000..1ae261f --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/benches/convert.rs @@ -0,0 +1,319 @@ +use criterion::{criterion_group, criterion_main, Bencher, Criterion}; +use half::prelude::*; +use std::{f32, f64, iter}; + +const SIMD_LARGE_BENCH_SLICE_LEN: usize = 1024; + +fn bench_f32_to_f16(c: &mut Criterion) { + c.bench_function_over_inputs( + "f16::from_f32", + |b: &mut Bencher<'_>, i: &f32| b.iter(|| f16::from_f32(*i)), + vec![ + 0., + -0., + 1., + f32::MIN, + f32::MAX, + f32::MIN_POSITIVE, + f32::NEG_INFINITY, + f32::INFINITY, + f32::NAN, + f32::consts::E, + f32::consts::PI, + ], + ); +} + +fn bench_f64_to_f16(c: &mut Criterion) { + c.bench_function_over_inputs( + "f16::from_f64", + |b: &mut Bencher<'_>, i: &f64| b.iter(|| f16::from_f64(*i)), + vec![ + 0., + -0., + 1., + f64::MIN, + f64::MAX, + f64::MIN_POSITIVE, + f64::NEG_INFINITY, + f64::INFINITY, + f64::NAN, + f64::consts::E, + f64::consts::PI, + ], + ); +} + +fn bench_f16_to_f32(c: &mut Criterion) { + c.bench_function_over_inputs( + "f16::to_f32", + |b: &mut Bencher<'_>, i: &f16| b.iter(|| i.to_f32()), + vec![ + f16::ZERO, + f16::NEG_ZERO, + f16::ONE, + f16::MIN, + f16::MAX, + f16::MIN_POSITIVE, + f16::NEG_INFINITY, + f16::INFINITY, + f16::NAN, + f16::E, + f16::PI, + ], + ); +} + +fn bench_f16_to_f64(c: &mut Criterion) { + c.bench_function_over_inputs( + "f16::to_f64", + |b: &mut Bencher<'_>, i: &f16| b.iter(|| i.to_f64()), + vec![ + f16::ZERO, + f16::NEG_ZERO, + f16::ONE, + f16::MIN, + f16::MAX, + f16::MIN_POSITIVE, + f16::NEG_INFINITY, + f16::INFINITY, + f16::NAN, + f16::E, + f16::PI, + ], + ); +} + +criterion_group!( + f16_sisd, + bench_f32_to_f16, + bench_f64_to_f16, + bench_f16_to_f32, + bench_f16_to_f64 +); + +fn bench_slice_f32_to_f16(c: &mut Criterion) { + let mut constant_buffer = [f16::ZERO; 11]; + let constants = [ + 0., + -0., + 1., + f32::MIN, + f32::MAX, + f32::MIN_POSITIVE, + f32::NEG_INFINITY, + f32::INFINITY, + f32::NAN, + f32::consts::E, + f32::consts::PI, + ]; + c.bench_function( + "HalfFloatSliceExt::convert_from_f32_slice/constants", + |b: &mut Bencher<'_>| b.iter(|| constant_buffer.convert_from_f32_slice(&constants)), + ); + + let large: Vec<_> = iter::repeat(0) + .enumerate() + .map(|(i, _)| i as f32) + .take(SIMD_LARGE_BENCH_SLICE_LEN) + .collect(); + let mut large_buffer = [f16::ZERO; SIMD_LARGE_BENCH_SLICE_LEN]; + c.bench_function( + "HalfFloatSliceExt::convert_from_f32_slice/large", + |b: &mut Bencher<'_>| b.iter(|| large_buffer.convert_from_f32_slice(&large)), + ); +} + +fn bench_slice_f64_to_f16(c: &mut Criterion) { + let mut constant_buffer = [f16::ZERO; 11]; + let constants = [ + 0., + -0., + 1., + f64::MIN, + f64::MAX, + f64::MIN_POSITIVE, + f64::NEG_INFINITY, + f64::INFINITY, + f64::NAN, + f64::consts::E, + f64::consts::PI, + ]; + c.bench_function( + "HalfFloatSliceExt::convert_from_f64_slice/constants", + |b: &mut Bencher<'_>| b.iter(|| constant_buffer.convert_from_f64_slice(&constants)), + ); + + let large: Vec<_> = iter::repeat(0) + .enumerate() + .map(|(i, _)| i as f64) + .take(SIMD_LARGE_BENCH_SLICE_LEN) + .collect(); + let mut large_buffer = [f16::ZERO; SIMD_LARGE_BENCH_SLICE_LEN]; + c.bench_function( + "HalfFloatSliceExt::convert_from_f64_slice/large", + |b: &mut Bencher<'_>| b.iter(|| large_buffer.convert_from_f64_slice(&large)), + ); +} + +fn bench_slice_f16_to_f32(c: &mut Criterion) { + let mut constant_buffer = [0f32; 11]; + let constants = [ + f16::ZERO, + f16::NEG_ZERO, + f16::ONE, + f16::MIN, + f16::MAX, + f16::MIN_POSITIVE, + f16::NEG_INFINITY, + f16::INFINITY, + f16::NAN, + f16::E, + f16::PI, + ]; + c.bench_function( + "HalfFloatSliceExt::convert_to_f32_slice/constants", + |b: &mut Bencher<'_>| b.iter(|| constants.convert_to_f32_slice(&mut constant_buffer)), + ); + + let large: Vec<_> = iter::repeat(0) + .enumerate() + .map(|(i, _)| f16::from_f32(i as f32)) + .take(SIMD_LARGE_BENCH_SLICE_LEN) + .collect(); + let mut large_buffer = [0f32; SIMD_LARGE_BENCH_SLICE_LEN]; + c.bench_function( + "HalfFloatSliceExt::convert_to_f32_slice/large", + |b: &mut Bencher<'_>| b.iter(|| large.convert_to_f32_slice(&mut large_buffer)), + ); +} + +fn bench_slice_f16_to_f64(c: &mut Criterion) { + let mut constant_buffer = [0f64; 11]; + let constants = [ + f16::ZERO, + f16::NEG_ZERO, + f16::ONE, + f16::MIN, + f16::MAX, + f16::MIN_POSITIVE, + f16::NEG_INFINITY, + f16::INFINITY, + f16::NAN, + f16::E, + f16::PI, + ]; + c.bench_function( + "HalfFloatSliceExt::convert_to_f64_slice/constants", + |b: &mut Bencher<'_>| b.iter(|| constants.convert_to_f64_slice(&mut constant_buffer)), + ); + + let large: Vec<_> = iter::repeat(0) + .enumerate() + .map(|(i, _)| f16::from_f64(i as f64)) + .take(SIMD_LARGE_BENCH_SLICE_LEN) + .collect(); + let mut large_buffer = [0f64; SIMD_LARGE_BENCH_SLICE_LEN]; + c.bench_function( + "HalfFloatSliceExt::convert_to_f64_slice/large", + |b: &mut Bencher<'_>| b.iter(|| large.convert_to_f64_slice(&mut large_buffer)), + ); +} + +criterion_group!( + f16_simd, + bench_slice_f32_to_f16, + bench_slice_f64_to_f16, + bench_slice_f16_to_f32, + bench_slice_f16_to_f64 +); + +fn bench_f32_to_bf16(c: &mut Criterion) { + c.bench_function_over_inputs( + "bf16::from_f32", + |b: &mut Bencher<'_>, i: &f32| b.iter(|| bf16::from_f32(*i)), + vec![ + 0., + -0., + 1., + f32::MIN, + f32::MAX, + f32::MIN_POSITIVE, + f32::NEG_INFINITY, + f32::INFINITY, + f32::NAN, + f32::consts::E, + f32::consts::PI, + ], + ); +} + +fn bench_f64_to_bf16(c: &mut Criterion) { + c.bench_function_over_inputs( + "bf16::from_f64", + |b: &mut Bencher<'_>, i: &f64| b.iter(|| bf16::from_f64(*i)), + vec![ + 0., + -0., + 1., + f64::MIN, + f64::MAX, + f64::MIN_POSITIVE, + f64::NEG_INFINITY, + f64::INFINITY, + f64::NAN, + f64::consts::E, + f64::consts::PI, + ], + ); +} + +fn bench_bf16_to_f32(c: &mut Criterion) { + c.bench_function_over_inputs( + "bf16::to_f32", + |b: &mut Bencher<'_>, i: &bf16| b.iter(|| i.to_f32()), + vec![ + bf16::ZERO, + bf16::NEG_ZERO, + bf16::ONE, + bf16::MIN, + bf16::MAX, + bf16::MIN_POSITIVE, + bf16::NEG_INFINITY, + bf16::INFINITY, + bf16::NAN, + bf16::E, + bf16::PI, + ], + ); +} + +fn bench_bf16_to_f64(c: &mut Criterion) { + c.bench_function_over_inputs( + "bf16::to_f64", + |b: &mut Bencher<'_>, i: &bf16| b.iter(|| i.to_f64()), + vec![ + bf16::ZERO, + bf16::NEG_ZERO, + bf16::ONE, + bf16::MIN, + bf16::MAX, + bf16::MIN_POSITIVE, + bf16::NEG_INFINITY, + bf16::INFINITY, + bf16::NAN, + bf16::E, + bf16::PI, + ], + ); +} + +criterion_group!( + bf16_sisd, + bench_f32_to_bf16, + bench_f64_to_bf16, + bench_bf16_to_f32, + bench_bf16_to_f64 +); + +criterion_main!(f16_sisd, bf16_sisd, f16_simd); diff --git a/third_party/cargo/vendor/half-1.4.0/src/bfloat.rs b/third_party/cargo/vendor/half-1.4.0/src/bfloat.rs new file mode 100644 index 0000000..20b7c7e --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/src/bfloat.rs @@ -0,0 +1,985 @@ +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + +use core::{ + cmp::Ordering, + fmt::{Debug, Display, Error, Formatter, LowerExp, UpperExp}, + num::{FpCategory, ParseFloatError}, + str::FromStr, +}; + +pub(crate) mod convert; + +/// A 16-bit floating point type implementing the [`bfloat16`] format. +/// +/// The [`bfloat16`] floating point format is a truncated 16-bit version of the IEEE 754 standard +/// `binary32`, a.k.a `f32`. [`bf16`] has approximately the same dynamic range as `f32` by having +/// a lower precision than [`f16`]. While [`f16`] has a precision of 11 bits, [`bf16`] has a +/// precision of only 8 bits. +/// +/// Like [`f16`], [`bf16`] does not offer arithmetic operations as it is intended for compact +/// storage rather than calculations. Operations should be performed with `f32` or higher-precision +/// types and converted to/from [`bf16`] as necessary. +/// +/// [`bfloat16`]: https://en.wikipedia.org/wiki/Bfloat16_floating-point_format +/// [`bf16`]: struct.bf16.html +/// [`f16`]: struct.f16.html +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, Default)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub struct bf16(u16); + +impl bf16 { + /// Constructs a [`bf16`](struct.bf16.html) value from the raw bits. + #[inline] + pub const fn from_bits(bits: u16) -> bf16 { + bf16(bits) + } + + /// Constructs a [`bf16`](struct.bf16.html) value from a 32-bit floating point value. + /// + /// If the 32-bit value is too large to fit, ±∞ will result. NaN values are preserved. + /// Subnormal values that are too tiny to be represented will result in ±0. All other values + /// are truncated and rounded to the nearest representable value. + #[inline] + pub fn from_f32(value: f32) -> bf16 { + bf16(convert::f32_to_bf16(value)) + } + + /// Constructs a [`bf16`](struct.bf16.html) value from a 64-bit floating point value. + /// + /// If the 64-bit value is to large to fit, ±∞ will result. NaN values are preserved. + /// 64-bit subnormal values are too tiny to be represented and result in ±0. Exponents that + /// underflow the minimum exponent will result in subnormals or ±0. All other values are + /// truncated and rounded to the nearest representable value. + #[inline] + pub fn from_f64(value: f64) -> bf16 { + bf16(convert::f64_to_bf16(value)) + } + + /// Converts a [`bf16`](struct.bf16.html) into the underlying bit representation. + #[inline] + pub const fn to_bits(self) -> u16 { + self.0 + } + + /// Converts a [`bf16`](struct.bf16.html) value into an `f32` value. + /// + /// This conversion is lossless as all values can be represented exactly in `f32`. + #[inline] + pub fn to_f32(self) -> f32 { + convert::bf16_to_f32(self.0) + } + + /// Converts a [`bf16`](struct.bf16.html) value into an `f64` value. + /// + /// This conversion is lossless as all values can be represented exactly in `f64`. + #[inline] + pub fn to_f64(self) -> f64 { + convert::bf16_to_f64(self.0) + } + + /// Returns `true` if this value is NaN and `false` otherwise. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let nan = bf16::NAN; + /// let f = bf16::from_f32(7.0_f32); + /// + /// assert!(nan.is_nan()); + /// assert!(!f.is_nan()); + /// ``` + #[inline] + pub const fn is_nan(self) -> bool { + self.0 & 0x7FFFu16 > 0x7F80u16 + } + + /// Returns `true` if this value is ±∞ and `false` otherwise. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let f = bf16::from_f32(7.0f32); + /// let inf = bf16::INFINITY; + /// let neg_inf = bf16::NEG_INFINITY; + /// let nan = bf16::NAN; + /// + /// assert!(!f.is_infinite()); + /// assert!(!nan.is_infinite()); + /// + /// assert!(inf.is_infinite()); + /// assert!(neg_inf.is_infinite()); + /// ``` + #[inline] + pub const fn is_infinite(self) -> bool { + self.0 & 0x7FFFu16 == 0x7F80u16 + } + + /// Returns `true` if this number is neither infinite nor NaN. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let f = bf16::from_f32(7.0f32); + /// let inf = bf16::INFINITY; + /// let neg_inf = bf16::NEG_INFINITY; + /// let nan = bf16::NAN; + /// + /// assert!(f.is_finite()); + /// + /// assert!(!nan.is_finite()); + /// assert!(!inf.is_finite()); + /// assert!(!neg_inf.is_finite()); + /// ``` + #[inline] + pub const fn is_finite(self) -> bool { + self.0 & 0x7F80u16 != 0x7F80u16 + } + + /// Returns `true` if the number is neither zero, infinite, subnormal, or NaN. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let min = bf16::MIN_POSITIVE; + /// let max = bf16::MAX; + /// let lower_than_min = bf16::from_f32(1.0e-39_f32); + /// let zero = bf16::from_f32(0.0_f32); + /// + /// assert!(min.is_normal()); + /// assert!(max.is_normal()); + /// + /// assert!(!zero.is_normal()); + /// assert!(!bf16::NAN.is_normal()); + /// assert!(!bf16::INFINITY.is_normal()); + /// // Values between 0 and `min` are subnormal. + /// assert!(!lower_than_min.is_normal()); + /// ``` + #[inline] + pub fn is_normal(self) -> bool { + let exp = self.0 & 0x7F80u16; + exp != 0x7F80u16 && exp != 0 + } + + /// Returns the floating point category of the number. + /// + /// If only one property is going to be tested, it is generally faster to use the specific + /// predicate instead. + /// + /// # Examples + /// + /// ```rust + /// use std::num::FpCategory; + /// # use half::prelude::*; + /// + /// let num = bf16::from_f32(12.4_f32); + /// let inf = bf16::INFINITY; + /// + /// assert_eq!(num.classify(), FpCategory::Normal); + /// assert_eq!(inf.classify(), FpCategory::Infinite); + /// ``` + pub fn classify(self) -> FpCategory { + let exp = self.0 & 0x7F80u16; + let man = self.0 & 0x007Fu16; + match (exp, man) { + (0, 0) => FpCategory::Zero, + (0, _) => FpCategory::Subnormal, + (0x7F80u16, 0) => FpCategory::Infinite, + (0x7F80u16, _) => FpCategory::Nan, + _ => FpCategory::Normal, + } + } + + /// Returns a number that represents the sign of `self`. + /// + /// * 1.0 if the number is positive, +0.0 or `INFINITY` + /// * −1.0 if the number is negative, −0.0` or `NEG_INFINITY` + /// * NaN if the number is NaN + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let f = bf16::from_f32(3.5_f32); + /// + /// assert_eq!(f.signum(), bf16::from_f32(1.0)); + /// assert_eq!(bf16::NEG_INFINITY.signum(), bf16::from_f32(-1.0)); + /// + /// assert!(bf16::NAN.signum().is_nan()); + /// ``` + pub fn signum(self) -> bf16 { + if self.is_nan() { + self + } else if self.0 & 0x8000u16 != 0 { + bf16::from_f32(-1.0) + } else { + bf16::from_f32(1.0) + } + } + + /// Returns `true` if and only if `self` has a positive sign, including +0.0, NaNs with a + /// positive sign bit and +∞. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let nan = bf16::NAN; + /// let f = bf16::from_f32(7.0_f32); + /// let g = bf16::from_f32(-7.0_f32); + /// + /// assert!(f.is_sign_positive()); + /// assert!(!g.is_sign_positive()); + /// // NaN can be either positive or negative + /// assert!(nan.is_sign_positive() != nan.is_sign_negative()); + /// ``` + #[inline] + pub const fn is_sign_positive(self) -> bool { + self.0 & 0x8000u16 == 0 + } + + /// Returns `true` if and only if `self` has a negative sign, including −0.0, NaNs with a + /// negative sign bit and −∞. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let nan = bf16::NAN; + /// let f = bf16::from_f32(7.0f32); + /// let g = bf16::from_f32(-7.0f32); + /// + /// assert!(!f.is_sign_negative()); + /// assert!(g.is_sign_negative()); + /// // NaN can be either positive or negative + /// assert!(nan.is_sign_positive() != nan.is_sign_negative()); + /// ``` + #[inline] + pub const fn is_sign_negative(self) -> bool { + self.0 & 0x8000u16 != 0 + } + + /// Approximate number of [`bf16`](struct.bf16.html) significant digits in base 10. + pub const DIGITS: u32 = 2; + /// [`bf16`](struct.bf16.html) + /// [machine epsilon](https://en.wikipedia.org/wiki/Machine_epsilon) value. + /// + /// This is the difference between 1.0 and the next largest representable number. + pub const EPSILON: bf16 = bf16(0x3C00u16); + /// [`bf16`](struct.bf16.html) positive Infinity (+∞). + pub const INFINITY: bf16 = bf16(0x7F80u16); + /// Number of [`bf16`](struct.bf16.html) significant digits in base 2. + pub const MANTISSA_DIGITS: u32 = 8; + /// Largest finite [`bf16`](struct.bf16.html) value. + pub const MAX: bf16 = bf16(0x7F7F); + /// Maximum possible [`bf16`](struct.bf16.html) power of 10 exponent. + pub const MAX_10_EXP: i32 = 38; + /// Maximum possible [`bf16`](struct.bf16.html) power of 2 exponent. + pub const MAX_EXP: i32 = 128; + /// Smallest finite [`bf16`](struct.bf16.html) value. + pub const MIN: bf16 = bf16(0xFF7F); + /// Minimum possible normal [`bf16`](struct.bf16.html) power of 10 exponent. + pub const MIN_10_EXP: i32 = -37; + /// One greater than the minimum possible normal [`bf16`](struct.bf16.html) power of 2 exponent. + pub const MIN_EXP: i32 = -125; + /// Smallest positive normal [`bf16`](struct.bf16.html) value. + pub const MIN_POSITIVE: bf16 = bf16(0x0080u16); + /// [`bf16`](struct.bf16.html) Not a Number (NaN). + pub const NAN: bf16 = bf16(0x7FC0u16); + /// [`bf16`](struct.bf16.html) negative infinity (-∞). + pub const NEG_INFINITY: bf16 = bf16(0xFF80u16); + /// The radix or base of the internal representation of [`bf16`](struct.bf16.html). + pub const RADIX: u32 = 2; + + /// Minimum positive subnormal [`bf16`](struct.bf16.html) value. + pub const MIN_POSITIVE_SUBNORMAL: bf16 = bf16(0x0001u16); + /// Maximum subnormal [`bf16`](struct.bf16.html) value. + pub const MAX_SUBNORMAL: bf16 = bf16(0x007Fu16); + + /// [`bf16`](struct.bf16.html) 1 + pub const ONE: bf16 = bf16(0x3F80u16); + /// [`bf16`](struct.bf16.html) 0 + pub const ZERO: bf16 = bf16(0x0000u16); + /// [`bf16`](struct.bf16.html) -0 + pub const NEG_ZERO: bf16 = bf16(0x8000u16); + + /// [`bf16`](struct.bf16.html) Euler's number (ℯ). + pub const E: bf16 = bf16(0x402Eu16); + /// [`bf16`](struct.bf16.html) Archimedes' constant (π). + pub const PI: bf16 = bf16(0x4049u16); + /// [`bf16`](struct.bf16.html) 1/π + pub const FRAC_1_PI: bf16 = bf16(0x3EA3u16); + /// [`bf16`](struct.bf16.html) 1/√2 + pub const FRAC_1_SQRT_2: bf16 = bf16(0x3F35u16); + /// [`bf16`](struct.bf16.html) 2/π + pub const FRAC_2_PI: bf16 = bf16(0x3F23u16); + /// [`bf16`](struct.bf16.html) 2/√π + pub const FRAC_2_SQRT_PI: bf16 = bf16(0x3F90u16); + /// [`bf16`](struct.bf16.html) π/2 + pub const FRAC_PI_2: bf16 = bf16(0x3FC9u16); + /// [`bf16`](struct.bf16.html) π/3 + pub const FRAC_PI_3: bf16 = bf16(0x3F86u16); + /// [`bf16`](struct.bf16.html) π/4 + pub const FRAC_PI_4: bf16 = bf16(0x3F49u16); + /// [`bf16`](struct.bf16.html) π/6 + pub const FRAC_PI_6: bf16 = bf16(0x3F06u16); + /// [`bf16`](struct.bf16.html) π/8 + pub const FRAC_PI_8: bf16 = bf16(0x3EC9u16); + /// [`bf16`](struct.bf16.html) 𝗅𝗇 10 + pub const LN_10: bf16 = bf16(0x4013u16); + /// [`bf16`](struct.bf16.html) 𝗅𝗇 2 + pub const LN_2: bf16 = bf16(0x3F31u16); + /// [`bf16`](struct.bf16.html) 𝗅𝗈𝗀₁₀ℯ + pub const LOG10_E: bf16 = bf16(0x3EDEu16); + /// [`bf16`](struct.bf16.html) 𝗅𝗈𝗀₂ℯ + pub const LOG2_E: bf16 = bf16(0x3FB9u16); + /// [`bf16`](struct.bf16.html) √2 + pub const SQRT_2: bf16 = bf16(0x3FB5u16); +} + +impl From for f32 { + #[inline] + fn from(x: bf16) -> f32 { + x.to_f32() + } +} + +impl From for f64 { + #[inline] + fn from(x: bf16) -> f64 { + x.to_f64() + } +} + +impl From for bf16 { + #[inline] + fn from(x: i8) -> bf16 { + // Convert to f32, then to bf16 + bf16::from_f32(f32::from(x)) + } +} + +impl From for bf16 { + #[inline] + fn from(x: u8) -> bf16 { + // Convert to f32, then to f16 + bf16::from_f32(f32::from(x)) + } +} + +impl PartialEq for bf16 { + fn eq(&self, other: &bf16) -> bool { + if self.is_nan() || other.is_nan() { + false + } else { + (self.0 == other.0) || ((self.0 | other.0) & 0x7FFFu16 == 0) + } + } +} + +impl PartialOrd for bf16 { + fn partial_cmp(&self, other: &bf16) -> Option { + if self.is_nan() || other.is_nan() { + None + } else { + let neg = self.0 & 0x8000u16 != 0; + let other_neg = other.0 & 0x8000u16 != 0; + match (neg, other_neg) { + (false, false) => Some(self.0.cmp(&other.0)), + (false, true) => { + if (self.0 | other.0) & 0x7FFFu16 == 0 { + Some(Ordering::Equal) + } else { + Some(Ordering::Greater) + } + } + (true, false) => { + if (self.0 | other.0) & 0x7FFFu16 == 0 { + Some(Ordering::Equal) + } else { + Some(Ordering::Less) + } + } + (true, true) => Some(other.0.cmp(&self.0)), + } + } + } + + fn lt(&self, other: &bf16) -> bool { + if self.is_nan() || other.is_nan() { + false + } else { + let neg = self.0 & 0x8000u16 != 0; + let other_neg = other.0 & 0x8000u16 != 0; + match (neg, other_neg) { + (false, false) => self.0 < other.0, + (false, true) => false, + (true, false) => (self.0 | other.0) & 0x7FFFu16 != 0, + (true, true) => self.0 > other.0, + } + } + } + + fn le(&self, other: &bf16) -> bool { + if self.is_nan() || other.is_nan() { + false + } else { + let neg = self.0 & 0x8000u16 != 0; + let other_neg = other.0 & 0x8000u16 != 0; + match (neg, other_neg) { + (false, false) => self.0 <= other.0, + (false, true) => (self.0 | other.0) & 0x7FFFu16 == 0, + (true, false) => true, + (true, true) => self.0 >= other.0, + } + } + } + + fn gt(&self, other: &bf16) -> bool { + if self.is_nan() || other.is_nan() { + false + } else { + let neg = self.0 & 0x8000u16 != 0; + let other_neg = other.0 & 0x8000u16 != 0; + match (neg, other_neg) { + (false, false) => self.0 > other.0, + (false, true) => (self.0 | other.0) & 0x7FFFu16 != 0, + (true, false) => false, + (true, true) => self.0 < other.0, + } + } + } + + fn ge(&self, other: &bf16) -> bool { + if self.is_nan() || other.is_nan() { + false + } else { + let neg = self.0 & 0x8000u16 != 0; + let other_neg = other.0 & 0x8000u16 != 0; + match (neg, other_neg) { + (false, false) => self.0 >= other.0, + (false, true) => true, + (true, false) => (self.0 | other.0) & 0x7FFFu16 == 0, + (true, true) => self.0 <= other.0, + } + } + } +} + +impl FromStr for bf16 { + type Err = ParseFloatError; + fn from_str(src: &str) -> Result { + f32::from_str(src).map(bf16::from_f32) + } +} + +impl Debug for bf16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "0x{:X}", self.0) + } +} + +impl Display for bf16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{}", self.to_f32()) + } +} + +impl LowerExp for bf16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:e}", self.to_f32()) + } +} + +impl UpperExp for bf16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:E}", self.to_f32()) + } +} + +#[allow( + clippy::cognitive_complexity, + clippy::float_cmp, + clippy::neg_cmp_op_on_partial_ord +)] +#[cfg(test)] +mod test { + use super::*; + use core; + use core::cmp::Ordering; + use quickcheck_macros::quickcheck; + + #[test] + fn test_bf16_consts_from_f32() { + let one = bf16::from_f32(1.0); + let zero = bf16::from_f32(0.0); + let neg_zero = bf16::from_f32(-0.0); + let inf = bf16::from_f32(core::f32::INFINITY); + let neg_inf = bf16::from_f32(core::f32::NEG_INFINITY); + let nan = bf16::from_f32(core::f32::NAN); + + assert_eq!(bf16::ONE, one); + assert_eq!(bf16::ZERO, zero); + assert_eq!(bf16::NEG_ZERO, neg_zero); + assert_eq!(bf16::INFINITY, inf); + assert_eq!(bf16::NEG_INFINITY, neg_inf); + assert!(nan.is_nan()); + assert!(bf16::NAN.is_nan()); + + let e = bf16::from_f32(core::f32::consts::E); + let pi = bf16::from_f32(core::f32::consts::PI); + let frac_1_pi = bf16::from_f32(core::f32::consts::FRAC_1_PI); + let frac_1_sqrt_2 = bf16::from_f32(core::f32::consts::FRAC_1_SQRT_2); + let frac_2_pi = bf16::from_f32(core::f32::consts::FRAC_2_PI); + let frac_2_sqrt_pi = bf16::from_f32(core::f32::consts::FRAC_2_SQRT_PI); + let frac_pi_2 = bf16::from_f32(core::f32::consts::FRAC_PI_2); + let frac_pi_3 = bf16::from_f32(core::f32::consts::FRAC_PI_3); + let frac_pi_4 = bf16::from_f32(core::f32::consts::FRAC_PI_4); + let frac_pi_6 = bf16::from_f32(core::f32::consts::FRAC_PI_6); + let frac_pi_8 = bf16::from_f32(core::f32::consts::FRAC_PI_8); + let ln_10 = bf16::from_f32(core::f32::consts::LN_10); + let ln_2 = bf16::from_f32(core::f32::consts::LN_2); + let log10_e = bf16::from_f32(core::f32::consts::LOG10_E); + let log2_e = bf16::from_f32(core::f32::consts::LOG2_E); + let sqrt_2 = bf16::from_f32(core::f32::consts::SQRT_2); + + assert_eq!(bf16::E, e); + assert_eq!(bf16::PI, pi); + assert_eq!(bf16::FRAC_1_PI, frac_1_pi); + assert_eq!(bf16::FRAC_1_SQRT_2, frac_1_sqrt_2); + assert_eq!(bf16::FRAC_2_PI, frac_2_pi); + assert_eq!(bf16::FRAC_2_SQRT_PI, frac_2_sqrt_pi); + assert_eq!(bf16::FRAC_PI_2, frac_pi_2); + assert_eq!(bf16::FRAC_PI_3, frac_pi_3); + assert_eq!(bf16::FRAC_PI_4, frac_pi_4); + assert_eq!(bf16::FRAC_PI_6, frac_pi_6); + assert_eq!(bf16::FRAC_PI_8, frac_pi_8); + assert_eq!(bf16::LN_10, ln_10); + assert_eq!(bf16::LN_2, ln_2); + assert_eq!(bf16::LOG10_E, log10_e); + assert_eq!(bf16::LOG2_E, log2_e); + assert_eq!(bf16::SQRT_2, sqrt_2); + } + + #[test] + fn test_bf16_consts_from_f64() { + let one = bf16::from_f64(1.0); + let zero = bf16::from_f64(0.0); + let neg_zero = bf16::from_f64(-0.0); + let inf = bf16::from_f64(core::f64::INFINITY); + let neg_inf = bf16::from_f64(core::f64::NEG_INFINITY); + let nan = bf16::from_f64(core::f64::NAN); + + assert_eq!(bf16::ONE, one); + assert_eq!(bf16::ZERO, zero); + assert_eq!(bf16::NEG_ZERO, neg_zero); + assert_eq!(bf16::INFINITY, inf); + assert_eq!(bf16::NEG_INFINITY, neg_inf); + assert!(nan.is_nan()); + assert!(bf16::NAN.is_nan()); + + let e = bf16::from_f64(core::f64::consts::E); + let pi = bf16::from_f64(core::f64::consts::PI); + let frac_1_pi = bf16::from_f64(core::f64::consts::FRAC_1_PI); + let frac_1_sqrt_2 = bf16::from_f64(core::f64::consts::FRAC_1_SQRT_2); + let frac_2_pi = bf16::from_f64(core::f64::consts::FRAC_2_PI); + let frac_2_sqrt_pi = bf16::from_f64(core::f64::consts::FRAC_2_SQRT_PI); + let frac_pi_2 = bf16::from_f64(core::f64::consts::FRAC_PI_2); + let frac_pi_3 = bf16::from_f64(core::f64::consts::FRAC_PI_3); + let frac_pi_4 = bf16::from_f64(core::f64::consts::FRAC_PI_4); + let frac_pi_6 = bf16::from_f64(core::f64::consts::FRAC_PI_6); + let frac_pi_8 = bf16::from_f64(core::f64::consts::FRAC_PI_8); + let ln_10 = bf16::from_f64(core::f64::consts::LN_10); + let ln_2 = bf16::from_f64(core::f64::consts::LN_2); + let log10_e = bf16::from_f64(core::f64::consts::LOG10_E); + let log2_e = bf16::from_f64(core::f64::consts::LOG2_E); + let sqrt_2 = bf16::from_f64(core::f64::consts::SQRT_2); + + assert_eq!(bf16::E, e); + assert_eq!(bf16::PI, pi); + assert_eq!(bf16::FRAC_1_PI, frac_1_pi); + assert_eq!(bf16::FRAC_1_SQRT_2, frac_1_sqrt_2); + assert_eq!(bf16::FRAC_2_PI, frac_2_pi); + assert_eq!(bf16::FRAC_2_SQRT_PI, frac_2_sqrt_pi); + assert_eq!(bf16::FRAC_PI_2, frac_pi_2); + assert_eq!(bf16::FRAC_PI_3, frac_pi_3); + assert_eq!(bf16::FRAC_PI_4, frac_pi_4); + assert_eq!(bf16::FRAC_PI_6, frac_pi_6); + assert_eq!(bf16::FRAC_PI_8, frac_pi_8); + assert_eq!(bf16::LN_10, ln_10); + assert_eq!(bf16::LN_2, ln_2); + assert_eq!(bf16::LOG10_E, log10_e); + assert_eq!(bf16::LOG2_E, log2_e); + assert_eq!(bf16::SQRT_2, sqrt_2); + } + + #[test] + fn test_nan_conversion_to_smaller() { + let nan64 = f64::from_bits(0x7FF0_0000_0000_0001u64); + let neg_nan64 = f64::from_bits(0xFFF0_0000_0000_0001u64); + let nan32 = f32::from_bits(0x7F80_0001u32); + let neg_nan32 = f32::from_bits(0xFF80_0001u32); + let nan32_from_64 = nan64 as f32; + let neg_nan32_from_64 = neg_nan64 as f32; + let nan16_from_64 = bf16::from_f64(nan64); + let neg_nan16_from_64 = bf16::from_f64(neg_nan64); + let nan16_from_32 = bf16::from_f32(nan32); + let neg_nan16_from_32 = bf16::from_f32(neg_nan32); + + assert!(nan64.is_nan() && nan64.is_sign_positive()); + assert!(neg_nan64.is_nan() && neg_nan64.is_sign_negative()); + assert!(nan32.is_nan() && nan32.is_sign_positive()); + assert!(neg_nan32.is_nan() && neg_nan32.is_sign_negative()); + assert!(nan32_from_64.is_nan() && nan32_from_64.is_sign_positive()); + assert!(neg_nan32_from_64.is_nan() && neg_nan32_from_64.is_sign_negative()); + assert!(nan16_from_64.is_nan() && nan16_from_64.is_sign_positive()); + assert!(neg_nan16_from_64.is_nan() && neg_nan16_from_64.is_sign_negative()); + assert!(nan16_from_32.is_nan() && nan16_from_32.is_sign_positive()); + assert!(neg_nan16_from_32.is_nan() && neg_nan16_from_32.is_sign_negative()); + } + + #[test] + fn test_nan_conversion_to_larger() { + let nan16 = bf16::from_bits(0x7F81u16); + let neg_nan16 = bf16::from_bits(0xFF81u16); + let nan32 = f32::from_bits(0x7F80_0001u32); + let neg_nan32 = f32::from_bits(0xFF80_0001u32); + let nan32_from_16 = f32::from(nan16); + let neg_nan32_from_16 = f32::from(neg_nan16); + let nan64_from_16 = f64::from(nan16); + let neg_nan64_from_16 = f64::from(neg_nan16); + let nan64_from_32 = f64::from(nan32); + let neg_nan64_from_32 = f64::from(neg_nan32); + + assert!(nan16.is_nan() && nan16.is_sign_positive()); + assert!(neg_nan16.is_nan() && neg_nan16.is_sign_negative()); + assert!(nan32.is_nan() && nan32.is_sign_positive()); + assert!(neg_nan32.is_nan() && neg_nan32.is_sign_negative()); + assert!(nan32_from_16.is_nan() && nan32_from_16.is_sign_positive()); + assert!(neg_nan32_from_16.is_nan() && neg_nan32_from_16.is_sign_negative()); + assert!(nan64_from_16.is_nan() && nan64_from_16.is_sign_positive()); + assert!(neg_nan64_from_16.is_nan() && neg_nan64_from_16.is_sign_negative()); + assert!(nan64_from_32.is_nan() && nan64_from_32.is_sign_positive()); + assert!(neg_nan64_from_32.is_nan() && neg_nan64_from_32.is_sign_negative()); + } + + #[test] + fn test_bf16_to_f32() { + let f = bf16::from_f32(7.0); + assert_eq!(f.to_f32(), 7.0f32); + + // 7.1 is NOT exactly representable in 16-bit, it's rounded + let f = bf16::from_f32(7.1); + let diff = (f.to_f32() - 7.1f32).abs(); + // diff must be <= 4 * EPSILON, as 7 has two more significant bits than 1 + assert!(diff <= 4.0 * bf16::EPSILON.to_f32()); + + let tiny32 = f32::from_bits(0x0001_0000u32); + assert_eq!(bf16::from_bits(0x0001).to_f32(), tiny32); + assert_eq!(bf16::from_bits(0x0005).to_f32(), 5.0 * tiny32); + + assert_eq!(bf16::from_bits(0x0001), bf16::from_f32(tiny32)); + assert_eq!(bf16::from_bits(0x0005), bf16::from_f32(5.0 * tiny32)); + } + + #[test] + fn test_bf16_to_f64() { + let f = bf16::from_f64(7.0); + assert_eq!(f.to_f64(), 7.0f64); + + // 7.1 is NOT exactly representable in 16-bit, it's rounded + let f = bf16::from_f64(7.1); + let diff = (f.to_f64() - 7.1f64).abs(); + // diff must be <= 4 * EPSILON, as 7 has two more significant bits than 1 + assert!(diff <= 4.0 * bf16::EPSILON.to_f64()); + + let tiny64 = 2.0f64.powi(-133); + assert_eq!(bf16::from_bits(0x0001).to_f64(), tiny64); + assert_eq!(bf16::from_bits(0x0005).to_f64(), 5.0 * tiny64); + + assert_eq!(bf16::from_bits(0x0001), bf16::from_f64(tiny64)); + assert_eq!(bf16::from_bits(0x0005), bf16::from_f64(5.0 * tiny64)); + } + + #[test] + fn test_comparisons() { + let zero = bf16::from_f64(0.0); + let one = bf16::from_f64(1.0); + let neg_zero = bf16::from_f64(-0.0); + let neg_one = bf16::from_f64(-1.0); + + assert_eq!(zero.partial_cmp(&neg_zero), Some(Ordering::Equal)); + assert_eq!(neg_zero.partial_cmp(&zero), Some(Ordering::Equal)); + assert!(zero == neg_zero); + assert!(neg_zero == zero); + assert!(!(zero != neg_zero)); + assert!(!(neg_zero != zero)); + assert!(!(zero < neg_zero)); + assert!(!(neg_zero < zero)); + assert!(zero <= neg_zero); + assert!(neg_zero <= zero); + assert!(!(zero > neg_zero)); + assert!(!(neg_zero > zero)); + assert!(zero >= neg_zero); + assert!(neg_zero >= zero); + + assert_eq!(one.partial_cmp(&neg_zero), Some(Ordering::Greater)); + assert_eq!(neg_zero.partial_cmp(&one), Some(Ordering::Less)); + assert!(!(one == neg_zero)); + assert!(!(neg_zero == one)); + assert!(one != neg_zero); + assert!(neg_zero != one); + assert!(!(one < neg_zero)); + assert!(neg_zero < one); + assert!(!(one <= neg_zero)); + assert!(neg_zero <= one); + assert!(one > neg_zero); + assert!(!(neg_zero > one)); + assert!(one >= neg_zero); + assert!(!(neg_zero >= one)); + + assert_eq!(one.partial_cmp(&neg_one), Some(Ordering::Greater)); + assert_eq!(neg_one.partial_cmp(&one), Some(Ordering::Less)); + assert!(!(one == neg_one)); + assert!(!(neg_one == one)); + assert!(one != neg_one); + assert!(neg_one != one); + assert!(!(one < neg_one)); + assert!(neg_one < one); + assert!(!(one <= neg_one)); + assert!(neg_one <= one); + assert!(one > neg_one); + assert!(!(neg_one > one)); + assert!(one >= neg_one); + assert!(!(neg_one >= one)); + } + + #[test] + #[allow(clippy::erasing_op, clippy::identity_op)] + fn round_to_even_f32() { + // smallest positive subnormal = 0b0.0000_001 * 2^-126 = 2^-133 + let min_sub = bf16::from_bits(1); + let min_sub_f = (-133f32).exp2(); + assert_eq!(bf16::from_f32(min_sub_f).to_bits(), min_sub.to_bits()); + assert_eq!(f32::from(min_sub).to_bits(), min_sub_f.to_bits()); + + // 0.0000000_011111 rounded to 0.0000000 (< tie, no rounding) + // 0.0000000_100000 rounded to 0.0000000 (tie and even, remains at even) + // 0.0000000_100001 rounded to 0.0000001 (> tie, rounds up) + assert_eq!( + bf16::from_f32(min_sub_f * 0.49).to_bits(), + min_sub.to_bits() * 0 + ); + assert_eq!( + bf16::from_f32(min_sub_f * 0.50).to_bits(), + min_sub.to_bits() * 0 + ); + assert_eq!( + bf16::from_f32(min_sub_f * 0.51).to_bits(), + min_sub.to_bits() * 1 + ); + + // 0.0000001_011111 rounded to 0.0000001 (< tie, no rounding) + // 0.0000001_100000 rounded to 0.0000010 (tie and odd, rounds up to even) + // 0.0000001_100001 rounded to 0.0000010 (> tie, rounds up) + assert_eq!( + bf16::from_f32(min_sub_f * 1.49).to_bits(), + min_sub.to_bits() * 1 + ); + assert_eq!( + bf16::from_f32(min_sub_f * 1.50).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + bf16::from_f32(min_sub_f * 1.51).to_bits(), + min_sub.to_bits() * 2 + ); + + // 0.0000010_011111 rounded to 0.0000010 (< tie, no rounding) + // 0.0000010_100000 rounded to 0.0000010 (tie and even, remains at even) + // 0.0000010_100001 rounded to 0.0000011 (> tie, rounds up) + assert_eq!( + bf16::from_f32(min_sub_f * 2.49).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + bf16::from_f32(min_sub_f * 2.50).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + bf16::from_f32(min_sub_f * 2.51).to_bits(), + min_sub.to_bits() * 3 + ); + + assert_eq!( + bf16::from_f32(250.49f32).to_bits(), + bf16::from_f32(250.0).to_bits() + ); + assert_eq!( + bf16::from_f32(250.50f32).to_bits(), + bf16::from_f32(250.0).to_bits() + ); + assert_eq!( + bf16::from_f32(250.51f32).to_bits(), + bf16::from_f32(251.0).to_bits() + ); + assert_eq!( + bf16::from_f32(251.49f32).to_bits(), + bf16::from_f32(251.0).to_bits() + ); + assert_eq!( + bf16::from_f32(251.50f32).to_bits(), + bf16::from_f32(252.0).to_bits() + ); + assert_eq!( + bf16::from_f32(251.51f32).to_bits(), + bf16::from_f32(252.0).to_bits() + ); + assert_eq!( + bf16::from_f32(252.49f32).to_bits(), + bf16::from_f32(252.0).to_bits() + ); + assert_eq!( + bf16::from_f32(252.50f32).to_bits(), + bf16::from_f32(252.0).to_bits() + ); + assert_eq!( + bf16::from_f32(252.51f32).to_bits(), + bf16::from_f32(253.0).to_bits() + ); + } + + #[test] + #[allow(clippy::erasing_op, clippy::identity_op)] + fn round_to_even_f64() { + // smallest positive subnormal = 0b0.0000_001 * 2^-126 = 2^-133 + let min_sub = bf16::from_bits(1); + let min_sub_f = (-133f64).exp2(); + assert_eq!(bf16::from_f64(min_sub_f).to_bits(), min_sub.to_bits()); + assert_eq!(f64::from(min_sub).to_bits(), min_sub_f.to_bits()); + + // 0.0000000_011111 rounded to 0.0000000 (< tie, no rounding) + // 0.0000000_100000 rounded to 0.0000000 (tie and even, remains at even) + // 0.0000000_100001 rounded to 0.0000001 (> tie, rounds up) + assert_eq!( + bf16::from_f64(min_sub_f * 0.49).to_bits(), + min_sub.to_bits() * 0 + ); + assert_eq!( + bf16::from_f64(min_sub_f * 0.50).to_bits(), + min_sub.to_bits() * 0 + ); + assert_eq!( + bf16::from_f64(min_sub_f * 0.51).to_bits(), + min_sub.to_bits() * 1 + ); + + // 0.0000001_011111 rounded to 0.0000001 (< tie, no rounding) + // 0.0000001_100000 rounded to 0.0000010 (tie and odd, rounds up to even) + // 0.0000001_100001 rounded to 0.0000010 (> tie, rounds up) + assert_eq!( + bf16::from_f64(min_sub_f * 1.49).to_bits(), + min_sub.to_bits() * 1 + ); + assert_eq!( + bf16::from_f64(min_sub_f * 1.50).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + bf16::from_f64(min_sub_f * 1.51).to_bits(), + min_sub.to_bits() * 2 + ); + + // 0.0000010_011111 rounded to 0.0000010 (< tie, no rounding) + // 0.0000010_100000 rounded to 0.0000010 (tie and even, remains at even) + // 0.0000010_100001 rounded to 0.0000011 (> tie, rounds up) + assert_eq!( + bf16::from_f64(min_sub_f * 2.49).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + bf16::from_f64(min_sub_f * 2.50).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + bf16::from_f64(min_sub_f * 2.51).to_bits(), + min_sub.to_bits() * 3 + ); + + assert_eq!( + bf16::from_f64(250.49f64).to_bits(), + bf16::from_f64(250.0).to_bits() + ); + assert_eq!( + bf16::from_f64(250.50f64).to_bits(), + bf16::from_f64(250.0).to_bits() + ); + assert_eq!( + bf16::from_f64(250.51f64).to_bits(), + bf16::from_f64(251.0).to_bits() + ); + assert_eq!( + bf16::from_f64(251.49f64).to_bits(), + bf16::from_f64(251.0).to_bits() + ); + assert_eq!( + bf16::from_f64(251.50f64).to_bits(), + bf16::from_f64(252.0).to_bits() + ); + assert_eq!( + bf16::from_f64(251.51f64).to_bits(), + bf16::from_f64(252.0).to_bits() + ); + assert_eq!( + bf16::from_f64(252.49f64).to_bits(), + bf16::from_f64(252.0).to_bits() + ); + assert_eq!( + bf16::from_f64(252.50f64).to_bits(), + bf16::from_f64(252.0).to_bits() + ); + assert_eq!( + bf16::from_f64(252.51f64).to_bits(), + bf16::from_f64(253.0).to_bits() + ); + } + + impl quickcheck::Arbitrary for bf16 { + fn arbitrary(g: &mut G) -> Self { + use rand::Rng; + bf16(g.gen()) + } + } + + #[quickcheck] + fn qc_roundtrip_bf16_f32_is_identity(f: bf16) -> bool { + let roundtrip = bf16::from_f32(f.to_f32()); + if f.is_nan() { + roundtrip.is_nan() && f.is_sign_negative() == roundtrip.is_sign_negative() + } else { + f.0 == roundtrip.0 + } + } + + #[quickcheck] + fn qc_roundtrip_bf16_f64_is_identity(f: bf16) -> bool { + let roundtrip = bf16::from_f64(f.to_f64()); + if f.is_nan() { + roundtrip.is_nan() && f.is_sign_negative() == roundtrip.is_sign_negative() + } else { + f.0 == roundtrip.0 + } + } +} diff --git a/third_party/cargo/vendor/half-1.4.0/src/bfloat/convert.rs b/third_party/cargo/vendor/half-1.4.0/src/bfloat/convert.rs new file mode 100644 index 0000000..bdfabc5 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/src/bfloat/convert.rs @@ -0,0 +1,135 @@ +pub(crate) fn f32_to_bf16(value: f32) -> u16 { + // Convert to raw bytes + let x = value.to_bits(); + + // check for NaN + if x & 0x7FFF_FFFFu32 > 0x7F80_0000u32 { + // Keep high part of current mantissa but also set most significiant mantissa bit + return ((x >> 16) | 0x0040u32) as u16; + } + + // round and shift + let round_bit = 0x0000_8000u32; + if (x & round_bit) != 0 && (x & (3 * round_bit - 1)) != 0 { + (x >> 16) as u16 + 1 + } else { + (x >> 16) as u16 + } +} + +pub(crate) fn f64_to_bf16(value: f64) -> u16 { + // Convert to raw bytes, truncating the last 32-bits of mantissa; that precision will always + // be lost on half-precision. + let val = value.to_bits(); + let x = (val >> 32) as u32; + + // Extract IEEE754 components + let sign = x & 0x8000_0000u32; + let exp = x & 0x7FF0_0000u32; + let man = x & 0x000F_FFFFu32; + + // Check for all exponent bits being set, which is Infinity or NaN + if exp == 0x7FF0_0000u32 { + // Set mantissa MSB for NaN (and also keep shifted mantissa bits). + // We also have to check the last 32 bits. + let nan_bit = if man == 0 && (val as u32 == 0) { + 0 + } else { + 0x0040u32 + }; + return ((sign >> 16) | 0x7F80u32 | nan_bit | (man >> 13)) as u16; + } + + // The number is normalized, start assembling half precision version + let half_sign = sign >> 16; + // Unbias the exponent, then bias for bfloat16 precision + let unbiased_exp = ((exp >> 20) as i64) - 1023; + let half_exp = unbiased_exp + 127; + + // Check for exponent overflow, return +infinity + if half_exp >= 0xFF { + return (half_sign | 0x7F80u32) as u16; + } + + // Check for underflow + if half_exp <= 0 { + // Check mantissa for what we can do + if 7 - half_exp > 21 { + // No rounding possibility, so this is a full underflow, return signed zero + return half_sign as u16; + } + // Don't forget about hidden leading mantissa bit when assembling mantissa + let man = man | 0x0010_0000u32; + let mut half_man = man >> (14 - half_exp); + // Check for rounding + let round_bit = 1 << (13 - half_exp); + if (man & round_bit) != 0 && (man & (3 * round_bit - 1)) != 0 { + half_man += 1; + } + // No exponent for subnormals + return (half_sign | half_man) as u16; + } + + // Rebias the exponent + let half_exp = (half_exp as u32) << 7; + let half_man = man >> 13; + // Check for rounding + let round_bit = 0x0000_1000u32; + if (man & round_bit) != 0 && (man & (3 * round_bit - 1)) != 0 { + // Round it + ((half_sign | half_exp | half_man) + 1) as u16 + } else { + (half_sign | half_exp | half_man) as u16 + } +} + +pub(crate) fn bf16_to_f32(i: u16) -> f32 { + // If NaN, keep current mantissa but also set most significiant mantissa bit + if i & 0x7FFFu16 > 0x7F80u16 { + f32::from_bits((i as u32 | 0x0040u32) << 16) + } else { + f32::from_bits((i as u32) << 16) + } +} + +pub(crate) fn bf16_to_f64(i: u16) -> f64 { + // Check for signed zero + if i & 0x7FFFu16 == 0 { + return f64::from_bits((i as u64) << 48); + } + + let half_sign = (i & 0x8000u16) as u64; + let half_exp = (i & 0x7F80u16) as u64; + let half_man = (i & 0x007Fu16) as u64; + + // Check for an infinity or NaN when all exponent bits set + if half_exp == 0x7F80u64 { + // Check for signed infinity if mantissa is zero + if half_man == 0 { + return f64::from_bits((half_sign << 48) | 0x7FF0_0000_0000_0000u64); + } else { + // NaN, keep current mantissa but also set most significiant mantissa bit + return f64::from_bits((half_sign << 48) | 0x7FF8_0000_0000_0000u64 | (half_man << 45)); + } + } + + // Calculate double-precision components with adjusted exponent + let sign = half_sign << 48; + // Unbias exponent + let unbiased_exp = ((half_exp as i64) >> 7) - 127; + + // Check for subnormals, which will be normalized by adjusting exponent + if half_exp == 0 { + // Calculate how much to adjust the exponent by + let e = (half_man as u16).leading_zeros() - 9; + + // Rebias and adjust exponent + let exp = ((1023 - 127 - e) as u64) << 52; + let man = (half_man << (46 + e)) & 0xF_FFFF_FFFF_FFFFu64; + return f64::from_bits(sign | exp | man); + } + // Rebias exponent for a normalized normal + let exp = ((unbiased_exp + 1023) as u64) << 52; + let man = (half_man & 0x007Fu64) << 45; + f64::from_bits(sign | exp | man) +} diff --git a/third_party/cargo/vendor/half-1.4.0/src/binary16.rs b/third_party/cargo/vendor/half-1.4.0/src/binary16.rs new file mode 100644 index 0000000..86fc57e --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/src/binary16.rs @@ -0,0 +1,1280 @@ +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + +use core::{ + cmp::Ordering, + fmt::{Debug, Display, Error, Formatter, LowerExp, UpperExp}, + num::{FpCategory, ParseFloatError}, + str::FromStr, +}; + +pub(crate) mod convert; + +/// A 16-bit floating point type implementing the IEEE 754-2008 standard [`binary16`] a.k.a `half` +/// format. +/// +/// This 16-bit floating point type is intended for efficient storage where the full range and +/// precision of a larger floating point value is not required. Because [`f16`] is primarily for +/// efficient storage, floating point operations such as addition, multiplication, etc. are not +/// implemented. Operations should be performed with `f32` or higher-precision types and converted +/// to/from [`f16`] as necessary. +/// +/// [`f16`]: struct.f16.html +/// [`binary16`]: https://en.wikipedia.org/wiki/Half-precision_floating-point_format +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, Default)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub struct f16(u16); + +#[deprecated( + since = "1.4.0", + note = "all constants moved to associated constants of [`f16`](../struct.f16.html)" +)] +pub mod consts { + //! Useful `f16` constants. + + use super::f16; + + /// Approximate number of [`f16`](../struct.f16.html) significant digits in base 10. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::DIGITS`](../struct.f16.html#associatedconstant.DIGITS)" + )] + pub const DIGITS: u32 = f16::DIGITS; + /// [`f16`](../struct.f16.html) + /// [machine epsilon](https://en.wikipedia.org/wiki/Machine_epsilon) value. + /// + /// This is the difference between 1.0 and the next largest representable number. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::EPSILON`](../struct.f16.html#associatedconstant.EPSILON)" + )] + pub const EPSILON: f16 = f16::EPSILON; + /// [`f16`](../struct.f16.html) positive Infinity (+∞). + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::INFINITY`](../struct.f16.html#associatedconstant.INFINITY)" + )] + pub const INFINITY: f16 = f16::INFINITY; + /// Number of [`f16`](../struct.f16.html) significant digits in base 2. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::MANTISSA_DIGITS`](../struct.f16.html#associatedconstant.MANTISSA_DIGITS)" + )] + pub const MANTISSA_DIGITS: u32 = f16::MANTISSA_DIGITS; + /// Largest finite [`f16`](../struct.f16.html) value. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::MAX`](../struct.f16.html#associatedconstant.MAX)" + )] + pub const MAX: f16 = f16::MAX; + /// Maximum possible [`f16`](../struct.f16.html) power of 10 exponent. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::MAX_10_EXP`](../struct.f16.html#associatedconstant.MAX_10_EXP)" + )] + pub const MAX_10_EXP: i32 = f16::MAX_10_EXP; + /// Maximum possible [`f16`](../struct.f16.html) power of 2 exponent. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::MAX_EXP`](../struct.f16.html#associatedconstant.MAX_EXP)" + )] + pub const MAX_EXP: i32 = f16::MAX_EXP; + /// Smallest finite [`f16`](../struct.f16.html) value. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::MIN`](../struct.f16.html#associatedconstant.MIN)" + )] + pub const MIN: f16 = f16::MIN; + /// Minimum possible normal [`f16`](../struct.f16.html) power of 10 exponent. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::MIN_10_EXP`](../struct.f16.html#associatedconstant.MIN_10_EXP)" + )] + pub const MIN_10_EXP: i32 = f16::MIN_10_EXP; + /// One greater than the minimum possible normal [`f16`](../struct.f16.html) power of 2 exponent. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::MIN_EXP`](../struct.f16.html#associatedconstant.MIN_EXP)" + )] + pub const MIN_EXP: i32 = f16::MIN_EXP; + /// Smallest positive normal [`f16`](../struct.f16.html) value. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::MIN_POSITIVE`](../struct.f16.html#associatedconstant.MIN_POSITIVE)" + )] + pub const MIN_POSITIVE: f16 = f16::MIN_POSITIVE; + /// [`f16`](../struct.f16.html) Not a Number (NaN). + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::NAN`](../struct.f16.html#associatedconstant.NAN)" + )] + pub const NAN: f16 = f16::NAN; + /// [`f16`](../struct.f16.html) negative infinity (-∞). + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::NEG_INFINITY`](../struct.f16.html#associatedconstant.NEG_INFINITY)" + )] + pub const NEG_INFINITY: f16 = f16::NEG_INFINITY; + /// The radix or base of the internal representation of [`f16`](../struct.f16.html). + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::RADIX`](../struct.f16.html#associatedconstant.RADIX)" + )] + pub const RADIX: u32 = f16::RADIX; + + /// Minimum positive subnormal [`f16`](../struct.f16.html) value. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::MIN_POSITIVE_SUBNORMAL`](../struct.f16.html#associatedconstant.MIN_POSITIVE_SUBNORMAL)" + )] + pub const MIN_POSITIVE_SUBNORMAL: f16 = f16::MIN_POSITIVE_SUBNORMAL; + /// Maximum subnormal [`f16`](../struct.f16.html) value. + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::MAX_SUBNORMAL`](../struct.f16.html#associatedconstant.MAX_SUBNORMAL)" + )] + pub const MAX_SUBNORMAL: f16 = f16::MAX_SUBNORMAL; + + /// [`f16`](../struct.f16.html) 1 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::ONE`](../struct.f16.html#associatedconstant.ONE)" + )] + pub const ONE: f16 = f16::ONE; + /// [`f16`](../struct.f16.html) 0 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::ZERO`](../struct.f16.html#associatedconstant.ZERO)" + )] + pub const ZERO: f16 = f16::ZERO; + /// [`f16`](../struct.f16.html) -0 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::NEG_ZERO`](../struct.f16.html#associatedconstant.NEG_ZERO)" + )] + pub const NEG_ZERO: f16 = f16::NEG_ZERO; + + /// [`f16`](../struct.f16.html) Euler's number (ℯ). + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::E`](../struct.f16.html#associatedconstant.E)" + )] + pub const E: f16 = f16::E; + /// [`f16`](../struct.f16.html) Archimedes' constant (π). + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::PI`](../struct.f16.html#associatedconstant.PI)" + )] + pub const PI: f16 = f16::PI; + /// [`f16`](../struct.f16.html) 1/π + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::FRAC_1_PI`](../struct.f16.html#associatedconstant.FRAC_1_PI)" + )] + pub const FRAC_1_PI: f16 = f16::FRAC_1_PI; + /// [`f16`](../struct.f16.html) 1/√2 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::FRAC_1_SQRT_2`](../struct.f16.html#associatedconstant.FRAC_1_SQRT_2)" + )] + pub const FRAC_1_SQRT_2: f16 = f16::FRAC_1_SQRT_2; + /// [`f16`](../struct.f16.html) 2/π + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::FRAC_2_PI`](../struct.f16.html#associatedconstant.FRAC_2_PI)" + )] + pub const FRAC_2_PI: f16 = f16::FRAC_2_PI; + /// [`f16`](../struct.f16.html) 2/√π + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::FRAC_2_SQRT_PI`](../struct.f16.html#associatedconstant.FRAC_2_SQRT_PI)" + )] + pub const FRAC_2_SQRT_PI: f16 = f16::FRAC_2_SQRT_PI; + /// [`f16`](../struct.f16.html) π/2 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::FRAC_PI_2`](../struct.f16.html#associatedconstant.FRAC_PI_2)" + )] + pub const FRAC_PI_2: f16 = f16::FRAC_PI_2; + /// [`f16`](../struct.f16.html) π/3 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::FRAC_PI_3`](../struct.f16.html#associatedconstant.FRAC_PI_3)" + )] + pub const FRAC_PI_3: f16 = f16::FRAC_PI_3; + /// [`f16`](../struct.f16.html) π/4 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::FRAC_PI_4`](../struct.f16.html#associatedconstant.FRAC_PI_4)" + )] + pub const FRAC_PI_4: f16 = f16::FRAC_PI_4; + /// [`f16`](../struct.f16.html) π/6 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::FRAC_PI_6`](../struct.f16.html#associatedconstant.FRAC_PI_6)" + )] + pub const FRAC_PI_6: f16 = f16::FRAC_PI_6; + /// [`f16`](../struct.f16.html) π/8 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::FRAC_PI_8`](../struct.f16.html#associatedconstant.FRAC_PI_8)" + )] + pub const FRAC_PI_8: f16 = f16::FRAC_PI_8; + /// [`f16`](../struct.f16.html) 𝗅𝗇 10 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::LN_10`](../struct.f16.html#associatedconstant.LN_10)" + )] + pub const LN_10: f16 = f16::LN_10; + /// [`f16`](../struct.f16.html) 𝗅𝗇 2 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::LN_2`](../struct.f16.html#associatedconstant.LN_2)" + )] + pub const LN_2: f16 = f16::LN_2; + /// [`f16`](../struct.f16.html) 𝗅𝗈𝗀₁₀ℯ + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::LOG10_E`](../struct.f16.html#associatedconstant.LOG10_E)" + )] + pub const LOG10_E: f16 = f16::LOG10_E; + /// [`f16`](../struct.f16.html) 𝗅𝗈𝗀₂ℯ + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::LOG2_E`](../struct.f16.html#associatedconstant.LOG2_E)" + )] + pub const LOG2_E: f16 = f16::LOG2_E; + /// [`f16`](../struct.f16.html) √2 + #[deprecated( + since = "1.4.0", + note = "moved to [`f16::SQRT_2`](../struct.f16.html#associatedconstant.SQRT_2)" + )] + pub const SQRT_2: f16 = f16::SQRT_2; +} + +impl f16 { + /// Constructs a 16-bit floating point value from the raw bits. + #[inline] + pub const fn from_bits(bits: u16) -> f16 { + f16(bits) + } + + /// Constructs a 16-bit floating point value from a 32-bit floating point value. + /// + /// If the 32-bit value is to large to fit in 16-bits, ±∞ will result. NaN values are + /// preserved. 32-bit subnormal values are too tiny to be represented in 16-bits and result in + /// ±0. Exponents that underflow the minimum 16-bit exponent will result in 16-bit subnormals + /// or ±0. All other values are truncated and rounded to the nearest representable 16-bit + /// value. + #[inline] + pub fn from_f32(value: f32) -> f16 { + f16(convert::f32_to_f16(value)) + } + + /// Constructs a 16-bit floating point value from a 64-bit floating point value. + /// + /// If the 64-bit value is to large to fit in 16-bits, ±∞ will result. NaN values are + /// preserved. 64-bit subnormal values are too tiny to be represented in 16-bits and result in + /// ±0. Exponents that underflow the minimum 16-bit exponent will result in 16-bit subnormals + /// or ±0. All other values are truncated and rounded to the nearest representable 16-bit + /// value. + #[inline] + pub fn from_f64(value: f64) -> f16 { + f16(convert::f64_to_f16(value)) + } + + /// Converts a [`f16`](struct.f16.html) into the underlying bit representation. + #[inline] + pub const fn to_bits(self) -> u16 { + self.0 + } + + /// Converts a [`f16`](struct.f16.html) into the underlying bit representation. + #[deprecated(since = "1.2.0", note = "renamed to [`to_bits`](#method.to_bits)")] + #[inline] + pub fn as_bits(self) -> u16 { + self.to_bits() + } + + /// Converts a [`f16`](struct.f16.html) value into a `f32` value. + /// + /// This conversion is lossless as all 16-bit floating point values can be represented exactly + /// in 32-bit floating point. + #[inline] + pub fn to_f32(self) -> f32 { + convert::f16_to_f32(self.0) + } + + /// Converts a [`f16`](struct.f16.html) value into a `f64` value. + /// + /// This conversion is lossless as all 16-bit floating point values can be represented exactly + /// in 64-bit floating point. + #[inline] + pub fn to_f64(self) -> f64 { + convert::f16_to_f64(self.0) + } + + /// Returns `true` if this value is `NaN` and `false` otherwise. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let nan = f16::NAN; + /// let f = f16::from_f32(7.0_f32); + /// + /// assert!(nan.is_nan()); + /// assert!(!f.is_nan()); + /// ``` + #[inline] + pub const fn is_nan(self) -> bool { + self.0 & 0x7FFFu16 > 0x7C00u16 + } + + /// Returns `true` if this value is ±∞ and `false` + /// otherwise. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let f = f16::from_f32(7.0f32); + /// let inf = f16::INFINITY; + /// let neg_inf = f16::NEG_INFINITY; + /// let nan = f16::NAN; + /// + /// assert!(!f.is_infinite()); + /// assert!(!nan.is_infinite()); + /// + /// assert!(inf.is_infinite()); + /// assert!(neg_inf.is_infinite()); + /// ``` + #[inline] + pub const fn is_infinite(self) -> bool { + self.0 & 0x7FFFu16 == 0x7C00u16 + } + + /// Returns `true` if this number is neither infinite nor `NaN`. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let f = f16::from_f32(7.0f32); + /// let inf = f16::INFINITY; + /// let neg_inf = f16::NEG_INFINITY; + /// let nan = f16::NAN; + /// + /// assert!(f.is_finite()); + /// + /// assert!(!nan.is_finite()); + /// assert!(!inf.is_finite()); + /// assert!(!neg_inf.is_finite()); + /// ``` + #[inline] + pub const fn is_finite(self) -> bool { + self.0 & 0x7C00u16 != 0x7C00u16 + } + + /// Returns `true` if the number is neither zero, infinite, subnormal, or `NaN`. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let min = f16::MIN_POSITIVE; + /// let max = f16::MAX; + /// let lower_than_min = f16::from_f32(1.0e-10_f32); + /// let zero = f16::from_f32(0.0_f32); + /// + /// assert!(min.is_normal()); + /// assert!(max.is_normal()); + /// + /// assert!(!zero.is_normal()); + /// assert!(!f16::NAN.is_normal()); + /// assert!(!f16::INFINITY.is_normal()); + /// // Values between `0` and `min` are Subnormal. + /// assert!(!lower_than_min.is_normal()); + /// ``` + #[inline] + pub fn is_normal(self) -> bool { + let exp = self.0 & 0x7C00u16; + exp != 0x7C00u16 && exp != 0 + } + + /// Returns the floating point category of the number. + /// + /// If only one property is going to be tested, it is generally faster to use the specific + /// predicate instead. + /// + /// # Examples + /// + /// ```rust + /// use std::num::FpCategory; + /// # use half::prelude::*; + /// + /// let num = f16::from_f32(12.4_f32); + /// let inf = f16::INFINITY; + /// + /// assert_eq!(num.classify(), FpCategory::Normal); + /// assert_eq!(inf.classify(), FpCategory::Infinite); + /// ``` + pub fn classify(self) -> FpCategory { + let exp = self.0 & 0x7C00u16; + let man = self.0 & 0x03FFu16; + match (exp, man) { + (0, 0) => FpCategory::Zero, + (0, _) => FpCategory::Subnormal, + (0x7C00u16, 0) => FpCategory::Infinite, + (0x7C00u16, _) => FpCategory::Nan, + _ => FpCategory::Normal, + } + } + + /// Returns a number that represents the sign of `self`. + /// + /// * `1.0` if the number is positive, `+0.0` or `INFINITY` + /// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` + /// * `NAN` if the number is `NAN` + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let f = f16::from_f32(3.5_f32); + /// + /// assert_eq!(f.signum(), f16::from_f32(1.0)); + /// assert_eq!(f16::NEG_INFINITY.signum(), f16::from_f32(-1.0)); + /// + /// assert!(f16::NAN.signum().is_nan()); + /// ``` + pub fn signum(self) -> f16 { + if self.is_nan() { + self + } else if self.0 & 0x8000u16 != 0 { + f16::from_f32(-1.0) + } else { + f16::from_f32(1.0) + } + } + + /// Returns `true` if and only if `self` has a positive sign, including `+0.0`, `NaNs` with a + /// positive sign bit and +∞. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let nan = f16::NAN; + /// let f = f16::from_f32(7.0_f32); + /// let g = f16::from_f32(-7.0_f32); + /// + /// assert!(f.is_sign_positive()); + /// assert!(!g.is_sign_positive()); + /// // `NaN` can be either positive or negative + /// assert!(nan.is_sign_positive() != nan.is_sign_negative()); + /// ``` + #[inline] + pub const fn is_sign_positive(self) -> bool { + self.0 & 0x8000u16 == 0 + } + + /// Returns `true` if and only if `self` has a negative sign, including `-0.0`, `NaNs` with a + /// negative sign bit and −∞. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// + /// let nan = f16::NAN; + /// let f = f16::from_f32(7.0f32); + /// let g = f16::from_f32(-7.0f32); + /// + /// assert!(!f.is_sign_negative()); + /// assert!(g.is_sign_negative()); + /// // `NaN` can be either positive or negative + /// assert!(nan.is_sign_positive() != nan.is_sign_negative()); + /// ``` + #[inline] + pub const fn is_sign_negative(self) -> bool { + self.0 & 0x8000u16 != 0 + } + + /// Approximate number of [`f16`](struct.f16.html) significant digits in base 10. + pub const DIGITS: u32 = 3; + /// [`f16`](struct.f16.html) + /// [machine epsilon](https://en.wikipedia.org/wiki/Machine_epsilon) value. + /// + /// This is the difference between 1.0 and the next largest representable number. + pub const EPSILON: f16 = f16(0x1400u16); + /// [`f16`](struct.f16.html) positive Infinity (+∞). + pub const INFINITY: f16 = f16(0x7C00u16); + /// Number of [`f16`](struct.f16.html) significant digits in base 2. + pub const MANTISSA_DIGITS: u32 = 11; + /// Largest finite [`f16`](struct.f16.html) value. + pub const MAX: f16 = f16(0x7BFF); + /// Maximum possible [`f16`](struct.f16.html) power of 10 exponent. + pub const MAX_10_EXP: i32 = 4; + /// Maximum possible [`f16`](struct.f16.html) power of 2 exponent. + pub const MAX_EXP: i32 = 16; + /// Smallest finite [`f16`](struct.f16.html) value. + pub const MIN: f16 = f16(0xFBFF); + /// Minimum possible normal [`f16`](struct.f16.html) power of 10 exponent. + pub const MIN_10_EXP: i32 = -4; + /// One greater than the minimum possible normal [`f16`](struct.f16.html) power of 2 exponent. + pub const MIN_EXP: i32 = -13; + /// Smallest positive normal [`f16`](struct.f16.html) value. + pub const MIN_POSITIVE: f16 = f16(0x0400u16); + /// [`f16`](struct.f16.html) Not a Number (NaN). + pub const NAN: f16 = f16(0x7E00u16); + /// [`f16`](struct.f16.html) negative infinity (-∞). + pub const NEG_INFINITY: f16 = f16(0xFC00u16); + /// The radix or base of the internal representation of [`f16`](struct.f16.html). + pub const RADIX: u32 = 2; + + /// Minimum positive subnormal [`f16`](struct.f16.html) value. + pub const MIN_POSITIVE_SUBNORMAL: f16 = f16(0x0001u16); + /// Maximum subnormal [`f16`](struct.f16.html) value. + pub const MAX_SUBNORMAL: f16 = f16(0x03FFu16); + + /// [`f16`](struct.f16.html) 1 + pub const ONE: f16 = f16(0x3C00u16); + /// [`f16`](struct.f16.html) 0 + pub const ZERO: f16 = f16(0x0000u16); + /// [`f16`](struct.f16.html) -0 + pub const NEG_ZERO: f16 = f16(0x8000u16); + + /// [`f16`](struct.f16.html) Euler's number (ℯ). + pub const E: f16 = f16(0x4170u16); + /// [`f16`](struct.f16.html) Archimedes' constant (π). + pub const PI: f16 = f16(0x4248u16); + /// [`f16`](struct.f16.html) 1/π + pub const FRAC_1_PI: f16 = f16(0x3518u16); + /// [`f16`](struct.f16.html) 1/√2 + pub const FRAC_1_SQRT_2: f16 = f16(0x39A8u16); + /// [`f16`](struct.f16.html) 2/π + pub const FRAC_2_PI: f16 = f16(0x3918u16); + /// [`f16`](struct.f16.html) 2/√π + pub const FRAC_2_SQRT_PI: f16 = f16(0x3C83u16); + /// [`f16`](struct.f16.html) π/2 + pub const FRAC_PI_2: f16 = f16(0x3E48u16); + /// [`f16`](struct.f16.html) π/3 + pub const FRAC_PI_3: f16 = f16(0x3C30u16); + /// [`f16`](struct.f16.html) π/4 + pub const FRAC_PI_4: f16 = f16(0x3A48u16); + /// [`f16`](struct.f16.html) π/6 + pub const FRAC_PI_6: f16 = f16(0x3830u16); + /// [`f16`](struct.f16.html) π/8 + pub const FRAC_PI_8: f16 = f16(0x3648u16); + /// [`f16`](struct.f16.html) 𝗅𝗇 10 + pub const LN_10: f16 = f16(0x409Bu16); + /// [`f16`](struct.f16.html) 𝗅𝗇 2 + pub const LN_2: f16 = f16(0x398Cu16); + /// [`f16`](struct.f16.html) 𝗅𝗈𝗀₁₀ℯ + pub const LOG10_E: f16 = f16(0x36F3u16); + /// [`f16`](struct.f16.html) 𝗅𝗈𝗀₂ℯ + pub const LOG2_E: f16 = f16(0x3DC5u16); + /// [`f16`](struct.f16.html) √2 + pub const SQRT_2: f16 = f16(0x3DA8u16); +} + +impl From for f32 { + #[inline] + fn from(x: f16) -> f32 { + x.to_f32() + } +} + +impl From for f64 { + #[inline] + fn from(x: f16) -> f64 { + x.to_f64() + } +} + +impl From for f16 { + #[inline] + fn from(x: i8) -> f16 { + // Convert to f32, then to f16 + f16::from_f32(f32::from(x)) + } +} + +impl From for f16 { + #[inline] + fn from(x: u8) -> f16 { + // Convert to f32, then to f16 + f16::from_f32(f32::from(x)) + } +} + +impl PartialEq for f16 { + fn eq(&self, other: &f16) -> bool { + if self.is_nan() || other.is_nan() { + false + } else { + (self.0 == other.0) || ((self.0 | other.0) & 0x7FFFu16 == 0) + } + } +} + +impl PartialOrd for f16 { + fn partial_cmp(&self, other: &f16) -> Option { + if self.is_nan() || other.is_nan() { + None + } else { + let neg = self.0 & 0x8000u16 != 0; + let other_neg = other.0 & 0x8000u16 != 0; + match (neg, other_neg) { + (false, false) => Some(self.0.cmp(&other.0)), + (false, true) => { + if (self.0 | other.0) & 0x7FFFu16 == 0 { + Some(Ordering::Equal) + } else { + Some(Ordering::Greater) + } + } + (true, false) => { + if (self.0 | other.0) & 0x7FFFu16 == 0 { + Some(Ordering::Equal) + } else { + Some(Ordering::Less) + } + } + (true, true) => Some(other.0.cmp(&self.0)), + } + } + } + + fn lt(&self, other: &f16) -> bool { + if self.is_nan() || other.is_nan() { + false + } else { + let neg = self.0 & 0x8000u16 != 0; + let other_neg = other.0 & 0x8000u16 != 0; + match (neg, other_neg) { + (false, false) => self.0 < other.0, + (false, true) => false, + (true, false) => (self.0 | other.0) & 0x7FFFu16 != 0, + (true, true) => self.0 > other.0, + } + } + } + + fn le(&self, other: &f16) -> bool { + if self.is_nan() || other.is_nan() { + false + } else { + let neg = self.0 & 0x8000u16 != 0; + let other_neg = other.0 & 0x8000u16 != 0; + match (neg, other_neg) { + (false, false) => self.0 <= other.0, + (false, true) => (self.0 | other.0) & 0x7FFFu16 == 0, + (true, false) => true, + (true, true) => self.0 >= other.0, + } + } + } + + fn gt(&self, other: &f16) -> bool { + if self.is_nan() || other.is_nan() { + false + } else { + let neg = self.0 & 0x8000u16 != 0; + let other_neg = other.0 & 0x8000u16 != 0; + match (neg, other_neg) { + (false, false) => self.0 > other.0, + (false, true) => (self.0 | other.0) & 0x7FFFu16 != 0, + (true, false) => false, + (true, true) => self.0 < other.0, + } + } + } + + fn ge(&self, other: &f16) -> bool { + if self.is_nan() || other.is_nan() { + false + } else { + let neg = self.0 & 0x8000u16 != 0; + let other_neg = other.0 & 0x8000u16 != 0; + match (neg, other_neg) { + (false, false) => self.0 >= other.0, + (false, true) => true, + (true, false) => (self.0 | other.0) & 0x7FFFu16 == 0, + (true, true) => self.0 <= other.0, + } + } + } +} + +impl FromStr for f16 { + type Err = ParseFloatError; + fn from_str(src: &str) -> Result { + f32::from_str(src).map(f16::from_f32) + } +} + +impl Debug for f16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "0x{:X}", self.0) + } +} + +impl Display for f16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{}", self.to_f32()) + } +} + +impl LowerExp for f16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:e}", self.to_f32()) + } +} + +impl UpperExp for f16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:E}", self.to_f32()) + } +} + +#[allow( + clippy::cognitive_complexity, + clippy::float_cmp, + clippy::neg_cmp_op_on_partial_ord +)] +#[cfg(test)] +mod test { + use super::*; + use core; + use core::cmp::Ordering; + use quickcheck_macros::quickcheck; + + #[test] + fn test_f16_consts() { + // DIGITS + let digits = ((f16::MANTISSA_DIGITS as f32 - 1.0) * 2f32.log10()).floor() as u32; + assert_eq!(f16::DIGITS, digits); + // sanity check to show test is good + let digits32 = ((core::f32::MANTISSA_DIGITS as f32 - 1.0) * 2f32.log10()).floor() as u32; + assert_eq!(core::f32::DIGITS, digits32); + + // EPSILON + let one = f16::from_f32(1.0); + let one_plus_epsilon = f16::from_bits(one.to_bits() + 1); + let epsilon = f16::from_f32(one_plus_epsilon.to_f32() - 1.0); + assert_eq!(f16::EPSILON, epsilon); + // sanity check to show test is good + let one_plus_epsilon32 = f32::from_bits(1.0f32.to_bits() + 1); + let epsilon32 = one_plus_epsilon32 - 1f32; + assert_eq!(core::f32::EPSILON, epsilon32); + + // MAX, MIN and MIN_POSITIVE + let max = f16::from_bits(f16::INFINITY.to_bits() - 1); + let min = f16::from_bits(f16::NEG_INFINITY.to_bits() - 1); + let min_pos = f16::from_f32(2f32.powi(f16::MIN_EXP - 1)); + assert_eq!(f16::MAX, max); + assert_eq!(f16::MIN, min); + assert_eq!(f16::MIN_POSITIVE, min_pos); + // sanity check to show test is good + let max32 = f32::from_bits(core::f32::INFINITY.to_bits() - 1); + let min32 = f32::from_bits(core::f32::NEG_INFINITY.to_bits() - 1); + let min_pos32 = 2f32.powi(core::f32::MIN_EXP - 1); + assert_eq!(core::f32::MAX, max32); + assert_eq!(core::f32::MIN, min32); + assert_eq!(core::f32::MIN_POSITIVE, min_pos32); + + // MIN_10_EXP and MAX_10_EXP + let ten_to_min = 10f32.powi(f16::MIN_10_EXP); + assert!(ten_to_min / 10.0 < f16::MIN_POSITIVE.to_f32()); + assert!(ten_to_min > f16::MIN_POSITIVE.to_f32()); + let ten_to_max = 10f32.powi(f16::MAX_10_EXP); + assert!(ten_to_max < f16::MAX.to_f32()); + assert!(ten_to_max * 10.0 > f16::MAX.to_f32()); + // sanity check to show test is good + let ten_to_min32 = 10f64.powi(core::f32::MIN_10_EXP); + assert!(ten_to_min32 / 10.0 < f64::from(core::f32::MIN_POSITIVE)); + assert!(ten_to_min32 > f64::from(core::f32::MIN_POSITIVE)); + let ten_to_max32 = 10f64.powi(core::f32::MAX_10_EXP); + assert!(ten_to_max32 < f64::from(core::f32::MAX)); + assert!(ten_to_max32 * 10.0 > f64::from(core::f32::MAX)); + } + + #[test] + fn test_f16_consts_from_f32() { + let one = f16::from_f32(1.0); + let zero = f16::from_f32(0.0); + let neg_zero = f16::from_f32(-0.0); + let inf = f16::from_f32(core::f32::INFINITY); + let neg_inf = f16::from_f32(core::f32::NEG_INFINITY); + let nan = f16::from_f32(core::f32::NAN); + + assert_eq!(f16::ONE, one); + assert_eq!(f16::ZERO, zero); + assert!(zero.is_sign_positive()); + assert_eq!(f16::NEG_ZERO, neg_zero); + assert!(neg_zero.is_sign_negative()); + assert_eq!(f16::INFINITY, inf); + assert_eq!(f16::NEG_INFINITY, neg_inf); + assert!(nan.is_nan()); + assert!(f16::NAN.is_nan()); + + let e = f16::from_f32(core::f32::consts::E); + let pi = f16::from_f32(core::f32::consts::PI); + let frac_1_pi = f16::from_f32(core::f32::consts::FRAC_1_PI); + let frac_1_sqrt_2 = f16::from_f32(core::f32::consts::FRAC_1_SQRT_2); + let frac_2_pi = f16::from_f32(core::f32::consts::FRAC_2_PI); + let frac_2_sqrt_pi = f16::from_f32(core::f32::consts::FRAC_2_SQRT_PI); + let frac_pi_2 = f16::from_f32(core::f32::consts::FRAC_PI_2); + let frac_pi_3 = f16::from_f32(core::f32::consts::FRAC_PI_3); + let frac_pi_4 = f16::from_f32(core::f32::consts::FRAC_PI_4); + let frac_pi_6 = f16::from_f32(core::f32::consts::FRAC_PI_6); + let frac_pi_8 = f16::from_f32(core::f32::consts::FRAC_PI_8); + let ln_10 = f16::from_f32(core::f32::consts::LN_10); + let ln_2 = f16::from_f32(core::f32::consts::LN_2); + let log10_e = f16::from_f32(core::f32::consts::LOG10_E); + let log2_e = f16::from_f32(core::f32::consts::LOG2_E); + let sqrt_2 = f16::from_f32(core::f32::consts::SQRT_2); + + assert_eq!(f16::E, e); + assert_eq!(f16::PI, pi); + assert_eq!(f16::FRAC_1_PI, frac_1_pi); + assert_eq!(f16::FRAC_1_SQRT_2, frac_1_sqrt_2); + assert_eq!(f16::FRAC_2_PI, frac_2_pi); + assert_eq!(f16::FRAC_2_SQRT_PI, frac_2_sqrt_pi); + assert_eq!(f16::FRAC_PI_2, frac_pi_2); + assert_eq!(f16::FRAC_PI_3, frac_pi_3); + assert_eq!(f16::FRAC_PI_4, frac_pi_4); + assert_eq!(f16::FRAC_PI_6, frac_pi_6); + assert_eq!(f16::FRAC_PI_8, frac_pi_8); + assert_eq!(f16::LN_10, ln_10); + assert_eq!(f16::LN_2, ln_2); + assert_eq!(f16::LOG10_E, log10_e); + assert_eq!(f16::LOG2_E, log2_e); + assert_eq!(f16::SQRT_2, sqrt_2); + } + + #[test] + fn test_f16_consts_from_f64() { + let one = f16::from_f64(1.0); + let zero = f16::from_f64(0.0); + let neg_zero = f16::from_f64(-0.0); + let inf = f16::from_f64(core::f64::INFINITY); + let neg_inf = f16::from_f64(core::f64::NEG_INFINITY); + let nan = f16::from_f64(core::f64::NAN); + + assert_eq!(f16::ONE, one); + assert_eq!(f16::ZERO, zero); + assert!(zero.is_sign_positive()); + assert_eq!(f16::NEG_ZERO, neg_zero); + assert!(neg_zero.is_sign_negative()); + assert_eq!(f16::INFINITY, inf); + assert_eq!(f16::NEG_INFINITY, neg_inf); + assert!(nan.is_nan()); + assert!(f16::NAN.is_nan()); + + let e = f16::from_f64(core::f64::consts::E); + let pi = f16::from_f64(core::f64::consts::PI); + let frac_1_pi = f16::from_f64(core::f64::consts::FRAC_1_PI); + let frac_1_sqrt_2 = f16::from_f64(core::f64::consts::FRAC_1_SQRT_2); + let frac_2_pi = f16::from_f64(core::f64::consts::FRAC_2_PI); + let frac_2_sqrt_pi = f16::from_f64(core::f64::consts::FRAC_2_SQRT_PI); + let frac_pi_2 = f16::from_f64(core::f64::consts::FRAC_PI_2); + let frac_pi_3 = f16::from_f64(core::f64::consts::FRAC_PI_3); + let frac_pi_4 = f16::from_f64(core::f64::consts::FRAC_PI_4); + let frac_pi_6 = f16::from_f64(core::f64::consts::FRAC_PI_6); + let frac_pi_8 = f16::from_f64(core::f64::consts::FRAC_PI_8); + let ln_10 = f16::from_f64(core::f64::consts::LN_10); + let ln_2 = f16::from_f64(core::f64::consts::LN_2); + let log10_e = f16::from_f64(core::f64::consts::LOG10_E); + let log2_e = f16::from_f64(core::f64::consts::LOG2_E); + let sqrt_2 = f16::from_f64(core::f64::consts::SQRT_2); + + assert_eq!(f16::E, e); + assert_eq!(f16::PI, pi); + assert_eq!(f16::FRAC_1_PI, frac_1_pi); + assert_eq!(f16::FRAC_1_SQRT_2, frac_1_sqrt_2); + assert_eq!(f16::FRAC_2_PI, frac_2_pi); + assert_eq!(f16::FRAC_2_SQRT_PI, frac_2_sqrt_pi); + assert_eq!(f16::FRAC_PI_2, frac_pi_2); + assert_eq!(f16::FRAC_PI_3, frac_pi_3); + assert_eq!(f16::FRAC_PI_4, frac_pi_4); + assert_eq!(f16::FRAC_PI_6, frac_pi_6); + assert_eq!(f16::FRAC_PI_8, frac_pi_8); + assert_eq!(f16::LN_10, ln_10); + assert_eq!(f16::LN_2, ln_2); + assert_eq!(f16::LOG10_E, log10_e); + assert_eq!(f16::LOG2_E, log2_e); + assert_eq!(f16::SQRT_2, sqrt_2); + } + + #[test] + fn test_nan_conversion_to_smaller() { + let nan64 = f64::from_bits(0x7FF0_0000_0000_0001u64); + let neg_nan64 = f64::from_bits(0xFFF0_0000_0000_0001u64); + let nan32 = f32::from_bits(0x7F80_0001u32); + let neg_nan32 = f32::from_bits(0xFF80_0001u32); + let nan32_from_64 = nan64 as f32; + let neg_nan32_from_64 = neg_nan64 as f32; + let nan16_from_64 = f16::from_f64(nan64); + let neg_nan16_from_64 = f16::from_f64(neg_nan64); + let nan16_from_32 = f16::from_f32(nan32); + let neg_nan16_from_32 = f16::from_f32(neg_nan32); + + assert!(nan64.is_nan() && nan64.is_sign_positive()); + assert!(neg_nan64.is_nan() && neg_nan64.is_sign_negative()); + assert!(nan32.is_nan() && nan32.is_sign_positive()); + assert!(neg_nan32.is_nan() && neg_nan32.is_sign_negative()); + assert!(nan32_from_64.is_nan() && nan32_from_64.is_sign_positive()); + assert!(neg_nan32_from_64.is_nan() && neg_nan32_from_64.is_sign_negative()); + assert!(nan16_from_64.is_nan() && nan16_from_64.is_sign_positive()); + assert!(neg_nan16_from_64.is_nan() && neg_nan16_from_64.is_sign_negative()); + assert!(nan16_from_32.is_nan() && nan16_from_32.is_sign_positive()); + assert!(neg_nan16_from_32.is_nan() && neg_nan16_from_32.is_sign_negative()); + } + + #[test] + fn test_nan_conversion_to_larger() { + let nan16 = f16::from_bits(0x7C01u16); + let neg_nan16 = f16::from_bits(0xFC01u16); + let nan32 = f32::from_bits(0x7F80_0001u32); + let neg_nan32 = f32::from_bits(0xFF80_0001u32); + let nan32_from_16 = f32::from(nan16); + let neg_nan32_from_16 = f32::from(neg_nan16); + let nan64_from_16 = f64::from(nan16); + let neg_nan64_from_16 = f64::from(neg_nan16); + let nan64_from_32 = f64::from(nan32); + let neg_nan64_from_32 = f64::from(neg_nan32); + + assert!(nan16.is_nan() && nan16.is_sign_positive()); + assert!(neg_nan16.is_nan() && neg_nan16.is_sign_negative()); + assert!(nan32.is_nan() && nan32.is_sign_positive()); + assert!(neg_nan32.is_nan() && neg_nan32.is_sign_negative()); + assert!(nan32_from_16.is_nan() && nan32_from_16.is_sign_positive()); + assert!(neg_nan32_from_16.is_nan() && neg_nan32_from_16.is_sign_negative()); + assert!(nan64_from_16.is_nan() && nan64_from_16.is_sign_positive()); + assert!(neg_nan64_from_16.is_nan() && neg_nan64_from_16.is_sign_negative()); + assert!(nan64_from_32.is_nan() && nan64_from_32.is_sign_positive()); + assert!(neg_nan64_from_32.is_nan() && neg_nan64_from_32.is_sign_negative()); + } + + #[test] + fn test_f16_to_f32() { + let f = f16::from_f32(7.0); + assert_eq!(f.to_f32(), 7.0f32); + + // 7.1 is NOT exactly representable in 16-bit, it's rounded + let f = f16::from_f32(7.1); + let diff = (f.to_f32() - 7.1f32).abs(); + // diff must be <= 4 * EPSILON, as 7 has two more significant bits than 1 + assert!(diff <= 4.0 * f16::EPSILON.to_f32()); + + assert_eq!(f16::from_bits(0x0000_0001).to_f32(), 2.0f32.powi(-24)); + assert_eq!(f16::from_bits(0x0000_0005).to_f32(), 5.0 * 2.0f32.powi(-24)); + + assert_eq!(f16::from_bits(0x0000_0001), f16::from_f32(2.0f32.powi(-24))); + assert_eq!( + f16::from_bits(0x0000_0005), + f16::from_f32(5.0 * 2.0f32.powi(-24)) + ); + } + + #[test] + fn test_f16_to_f64() { + let f = f16::from_f64(7.0); + assert_eq!(f.to_f64(), 7.0f64); + + // 7.1 is NOT exactly representable in 16-bit, it's rounded + let f = f16::from_f64(7.1); + let diff = (f.to_f64() - 7.1f64).abs(); + // diff must be <= 4 * EPSILON, as 7 has two more significant bits than 1 + assert!(diff <= 4.0 * f16::EPSILON.to_f64()); + + assert_eq!(f16::from_bits(0x0000_0001).to_f64(), 2.0f64.powi(-24)); + assert_eq!(f16::from_bits(0x0000_0005).to_f64(), 5.0 * 2.0f64.powi(-24)); + + assert_eq!(f16::from_bits(0x0000_0001), f16::from_f64(2.0f64.powi(-24))); + assert_eq!( + f16::from_bits(0x0000_0005), + f16::from_f64(5.0 * 2.0f64.powi(-24)) + ); + } + + #[test] + fn test_comparisons() { + let zero = f16::from_f64(0.0); + let one = f16::from_f64(1.0); + let neg_zero = f16::from_f64(-0.0); + let neg_one = f16::from_f64(-1.0); + + assert_eq!(zero.partial_cmp(&neg_zero), Some(Ordering::Equal)); + assert_eq!(neg_zero.partial_cmp(&zero), Some(Ordering::Equal)); + assert!(zero == neg_zero); + assert!(neg_zero == zero); + assert!(!(zero != neg_zero)); + assert!(!(neg_zero != zero)); + assert!(!(zero < neg_zero)); + assert!(!(neg_zero < zero)); + assert!(zero <= neg_zero); + assert!(neg_zero <= zero); + assert!(!(zero > neg_zero)); + assert!(!(neg_zero > zero)); + assert!(zero >= neg_zero); + assert!(neg_zero >= zero); + + assert_eq!(one.partial_cmp(&neg_zero), Some(Ordering::Greater)); + assert_eq!(neg_zero.partial_cmp(&one), Some(Ordering::Less)); + assert!(!(one == neg_zero)); + assert!(!(neg_zero == one)); + assert!(one != neg_zero); + assert!(neg_zero != one); + assert!(!(one < neg_zero)); + assert!(neg_zero < one); + assert!(!(one <= neg_zero)); + assert!(neg_zero <= one); + assert!(one > neg_zero); + assert!(!(neg_zero > one)); + assert!(one >= neg_zero); + assert!(!(neg_zero >= one)); + + assert_eq!(one.partial_cmp(&neg_one), Some(Ordering::Greater)); + assert_eq!(neg_one.partial_cmp(&one), Some(Ordering::Less)); + assert!(!(one == neg_one)); + assert!(!(neg_one == one)); + assert!(one != neg_one); + assert!(neg_one != one); + assert!(!(one < neg_one)); + assert!(neg_one < one); + assert!(!(one <= neg_one)); + assert!(neg_one <= one); + assert!(one > neg_one); + assert!(!(neg_one > one)); + assert!(one >= neg_one); + assert!(!(neg_one >= one)); + } + + #[test] + #[allow(clippy::erasing_op, clippy::identity_op)] + fn round_to_even_f32() { + // smallest positive subnormal = 0b0.0000_0000_01 * 2^-14 = 2^-24 + let min_sub = f16::from_bits(1); + let min_sub_f = (-24f32).exp2(); + assert_eq!(f16::from_f32(min_sub_f).to_bits(), min_sub.to_bits()); + assert_eq!(f32::from(min_sub).to_bits(), min_sub_f.to_bits()); + + // 0.0000000000_011111 rounded to 0.0000000000 (< tie, no rounding) + // 0.0000000000_100000 rounded to 0.0000000000 (tie and even, remains at even) + // 0.0000000000_100001 rounded to 0.0000000001 (> tie, rounds up) + assert_eq!( + f16::from_f32(min_sub_f * 0.49).to_bits(), + min_sub.to_bits() * 0 + ); + assert_eq!( + f16::from_f32(min_sub_f * 0.50).to_bits(), + min_sub.to_bits() * 0 + ); + assert_eq!( + f16::from_f32(min_sub_f * 0.51).to_bits(), + min_sub.to_bits() * 1 + ); + + // 0.0000000001_011111 rounded to 0.0000000001 (< tie, no rounding) + // 0.0000000001_100000 rounded to 0.0000000010 (tie and odd, rounds up to even) + // 0.0000000001_100001 rounded to 0.0000000010 (> tie, rounds up) + assert_eq!( + f16::from_f32(min_sub_f * 1.49).to_bits(), + min_sub.to_bits() * 1 + ); + assert_eq!( + f16::from_f32(min_sub_f * 1.50).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + f16::from_f32(min_sub_f * 1.51).to_bits(), + min_sub.to_bits() * 2 + ); + + // 0.0000000010_011111 rounded to 0.0000000010 (< tie, no rounding) + // 0.0000000010_100000 rounded to 0.0000000010 (tie and even, remains at even) + // 0.0000000010_100001 rounded to 0.0000000011 (> tie, rounds up) + assert_eq!( + f16::from_f32(min_sub_f * 2.49).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + f16::from_f32(min_sub_f * 2.50).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + f16::from_f32(min_sub_f * 2.51).to_bits(), + min_sub.to_bits() * 3 + ); + + assert_eq!( + f16::from_f32(2000.49f32).to_bits(), + f16::from_f32(2000.0).to_bits() + ); + assert_eq!( + f16::from_f32(2000.50f32).to_bits(), + f16::from_f32(2000.0).to_bits() + ); + assert_eq!( + f16::from_f32(2000.51f32).to_bits(), + f16::from_f32(2001.0).to_bits() + ); + assert_eq!( + f16::from_f32(2001.49f32).to_bits(), + f16::from_f32(2001.0).to_bits() + ); + assert_eq!( + f16::from_f32(2001.50f32).to_bits(), + f16::from_f32(2002.0).to_bits() + ); + assert_eq!( + f16::from_f32(2001.51f32).to_bits(), + f16::from_f32(2002.0).to_bits() + ); + assert_eq!( + f16::from_f32(2002.49f32).to_bits(), + f16::from_f32(2002.0).to_bits() + ); + assert_eq!( + f16::from_f32(2002.50f32).to_bits(), + f16::from_f32(2002.0).to_bits() + ); + assert_eq!( + f16::from_f32(2002.51f32).to_bits(), + f16::from_f32(2003.0).to_bits() + ); + } + + #[test] + #[allow(clippy::erasing_op, clippy::identity_op)] + fn round_to_even_f64() { + // smallest positive subnormal = 0b0.0000_0000_01 * 2^-14 = 2^-24 + let min_sub = f16::from_bits(1); + let min_sub_f = (-24f64).exp2(); + assert_eq!(f16::from_f64(min_sub_f).to_bits(), min_sub.to_bits()); + assert_eq!(f64::from(min_sub).to_bits(), min_sub_f.to_bits()); + + // 0.0000000000_011111 rounded to 0.0000000000 (< tie, no rounding) + // 0.0000000000_100000 rounded to 0.0000000000 (tie and even, remains at even) + // 0.0000000000_100001 rounded to 0.0000000001 (> tie, rounds up) + assert_eq!( + f16::from_f64(min_sub_f * 0.49).to_bits(), + min_sub.to_bits() * 0 + ); + assert_eq!( + f16::from_f64(min_sub_f * 0.50).to_bits(), + min_sub.to_bits() * 0 + ); + assert_eq!( + f16::from_f64(min_sub_f * 0.51).to_bits(), + min_sub.to_bits() * 1 + ); + + // 0.0000000001_011111 rounded to 0.0000000001 (< tie, no rounding) + // 0.0000000001_100000 rounded to 0.0000000010 (tie and odd, rounds up to even) + // 0.0000000001_100001 rounded to 0.0000000010 (> tie, rounds up) + assert_eq!( + f16::from_f64(min_sub_f * 1.49).to_bits(), + min_sub.to_bits() * 1 + ); + assert_eq!( + f16::from_f64(min_sub_f * 1.50).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + f16::from_f64(min_sub_f * 1.51).to_bits(), + min_sub.to_bits() * 2 + ); + + // 0.0000000010_011111 rounded to 0.0000000010 (< tie, no rounding) + // 0.0000000010_100000 rounded to 0.0000000010 (tie and even, remains at even) + // 0.0000000010_100001 rounded to 0.0000000011 (> tie, rounds up) + assert_eq!( + f16::from_f64(min_sub_f * 2.49).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + f16::from_f64(min_sub_f * 2.50).to_bits(), + min_sub.to_bits() * 2 + ); + assert_eq!( + f16::from_f64(min_sub_f * 2.51).to_bits(), + min_sub.to_bits() * 3 + ); + + assert_eq!( + f16::from_f64(2000.49f64).to_bits(), + f16::from_f64(2000.0).to_bits() + ); + assert_eq!( + f16::from_f64(2000.50f64).to_bits(), + f16::from_f64(2000.0).to_bits() + ); + assert_eq!( + f16::from_f64(2000.51f64).to_bits(), + f16::from_f64(2001.0).to_bits() + ); + assert_eq!( + f16::from_f64(2001.49f64).to_bits(), + f16::from_f64(2001.0).to_bits() + ); + assert_eq!( + f16::from_f64(2001.50f64).to_bits(), + f16::from_f64(2002.0).to_bits() + ); + assert_eq!( + f16::from_f64(2001.51f64).to_bits(), + f16::from_f64(2002.0).to_bits() + ); + assert_eq!( + f16::from_f64(2002.49f64).to_bits(), + f16::from_f64(2002.0).to_bits() + ); + assert_eq!( + f16::from_f64(2002.50f64).to_bits(), + f16::from_f64(2002.0).to_bits() + ); + assert_eq!( + f16::from_f64(2002.51f64).to_bits(), + f16::from_f64(2003.0).to_bits() + ); + } + + impl quickcheck::Arbitrary for f16 { + fn arbitrary(g: &mut G) -> Self { + use rand::Rng; + f16(g.gen()) + } + } + + #[quickcheck] + fn qc_roundtrip_f16_f32_is_identity(f: f16) -> bool { + let roundtrip = f16::from_f32(f.to_f32()); + if f.is_nan() { + roundtrip.is_nan() && f.is_sign_negative() == roundtrip.is_sign_negative() + } else { + f.0 == roundtrip.0 + } + } + + #[quickcheck] + fn qc_roundtrip_f16_f64_is_identity(f: f16) -> bool { + let roundtrip = f16::from_f64(f.to_f64()); + if f.is_nan() { + roundtrip.is_nan() && f.is_sign_negative() == roundtrip.is_sign_negative() + } else { + f.0 == roundtrip.0 + } + } +} diff --git a/third_party/cargo/vendor/half-1.4.0/src/binary16/convert.rs b/third_party/cargo/vendor/half-1.4.0/src/binary16/convert.rs new file mode 100644 index 0000000..23c71a8 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/src/binary16/convert.rs @@ -0,0 +1,491 @@ +#![allow(dead_code, unused_imports)] + +macro_rules! convert_fn { + (fn $name:ident($var:ident : $vartype:ty) -> $restype:ty { + if feature("f16c") { $f16c:expr } + else { $fallback:expr }}) => { + #[inline] + pub(crate) fn $name($var: $vartype) -> $restype { + // Use CPU feature detection if using std + #[cfg(all( + feature = "use-intrinsics", + feature = "std", + any(target_arch = "x86", target_arch = "x86_64"), + not(target_feature = "f16c") + ))] + { + if is_x86_feature_detected!("f16c") { + $f16c + } else { + $fallback + } + } + // Use intrinsics directly when a compile target or using no_std + #[cfg(all( + feature = "use-intrinsics", + any(target_arch = "x86", target_arch = "x86_64"), + target_feature = "f16c" + ))] + { + $f16c + } + // Fallback to software + #[cfg(any( + not(feature = "use-intrinsics"), + not(any(target_arch = "x86", target_arch = "x86_64")), + all(not(feature = "std"), not(target_feature = "f16c")) + ))] + { + $fallback + } + } + }; +} + +convert_fn! { + fn f32_to_f16(f: f32) -> u16 { + if feature("f16c") { + unsafe { x86::f32_to_f16_x86_f16c(f) } + } else { + f32_to_f16_fallback(f) + } + } +} + +convert_fn! { + fn f64_to_f16(f: f64) -> u16 { + if feature("f16c") { + unsafe { x86::f32_to_f16_x86_f16c(f as f32) } + } else { + f64_to_f16_fallback(f) + } + } +} + +convert_fn! { + fn f16_to_f32(i: u16) -> f32 { + if feature("f16c") { + unsafe { x86::f16_to_f32_x86_f16c(i) } + } else { + f16_to_f32_fallback(i) + } + } +} + +convert_fn! { + fn f16_to_f64(i: u16) -> f64 { + if feature("f16c") { + unsafe { x86::f16_to_f32_x86_f16c(i) as f64 } + } else { + f16_to_f64_fallback(i) + } + } +} + +// TODO: While SIMD versions are faster, further improvements can be made by doing runtime feature +// detection once at beginning of convert slice method, rather than per chunk + +convert_fn! { + fn f32x4_to_f16x4(f: &[f32]) -> [u16; 4] { + if feature("f16c") { + unsafe { x86::f32x4_to_f16x4_x86_f16c(f) } + } else { + f32x4_to_f16x4_fallback(f) + } + } +} + +convert_fn! { + fn f16x4_to_f32x4(i: &[u16]) -> [f32; 4] { + if feature("f16c") { + unsafe { x86::f16x4_to_f32x4_x86_f16c(i) } + } else { + f16x4_to_f32x4_fallback(i) + } + } +} + +convert_fn! { + fn f64x4_to_f16x4(f: &[f64]) -> [u16; 4] { + if feature("f16c") { + unsafe { x86::f64x4_to_f16x4_x86_f16c(f) } + } else { + f64x4_to_f16x4_fallback(f) + } + } +} + +convert_fn! { + fn f16x4_to_f64x4(i: &[u16]) -> [f64; 4] { + if feature("f16c") { + unsafe { x86::f16x4_to_f64x4_x86_f16c(i) } + } else { + f16x4_to_f64x4_fallback(i) + } + } +} + +/////////////// Fallbacks //////////////// + +// In the below functions, round to nearest, with ties to even. +// Let us call the most significant bit that will be shifted out the round_bit. +// +// Round up if either +// a) Removed part > tie. +// (mantissa & round_bit) != 0 && (mantissa & (round_bit - 1)) != 0 +// b) Removed part == tie, and retained part is odd. +// (mantissa & round_bit) != 0 && (mantissa & (2 * round_bit)) != 0 +// (If removed part == tie and retained part is even, do not round up.) +// These two conditions can be combined into one: +// (mantissa & round_bit) != 0 && (mantissa & ((round_bit - 1) | (2 * round_bit))) != 0 +// which can be simplified into +// (mantissa & round_bit) != 0 && (mantissa & (3 * round_bit - 1)) != 0 + +fn f32_to_f16_fallback(value: f32) -> u16 { + // Convert to raw bytes + let x = value.to_bits(); + + // Extract IEEE754 components + let sign = x & 0x8000_0000u32; + let exp = x & 0x7F80_0000u32; + let man = x & 0x007F_FFFFu32; + + // Check for all exponent bits being set, which is Infinity or NaN + if exp == 0x7F80_0000u32 { + // Set mantissa MSB for NaN (and also keep shifted mantissa bits) + let nan_bit = if man == 0 { 0 } else { 0x0200u32 }; + return ((sign >> 16) | 0x7C00u32 | nan_bit | (man >> 13)) as u16; + } + + // The number is normalized, start assembling half precision version + let half_sign = sign >> 16; + // Unbias the exponent, then bias for half precision + let unbiased_exp = ((exp >> 23) as i32) - 127; + let half_exp = unbiased_exp + 15; + + // Check for exponent overflow, return +infinity + if half_exp >= 0x1F { + return (half_sign | 0x7C00u32) as u16; + } + + // Check for underflow + if half_exp <= 0 { + // Check mantissa for what we can do + if 14 - half_exp > 24 { + // No rounding possibility, so this is a full underflow, return signed zero + return half_sign as u16; + } + // Don't forget about hidden leading mantissa bit when assembling mantissa + let man = man | 0x0080_0000u32; + let mut half_man = man >> (14 - half_exp); + // Check for rounding (see comment above functions) + let round_bit = 1 << (13 - half_exp); + if (man & round_bit) != 0 && (man & (3 * round_bit - 1)) != 0 { + half_man += 1; + } + // No exponent for subnormals + return (half_sign | half_man) as u16; + } + + // Rebias the exponent + let half_exp = (half_exp as u32) << 10; + let half_man = man >> 13; + // Check for rounding (see comment above functions) + let round_bit = 0x0000_1000u32; + if (man & round_bit) != 0 && (man & (3 * round_bit - 1)) != 0 { + // Round it + ((half_sign | half_exp | half_man) + 1) as u16 + } else { + (half_sign | half_exp | half_man) as u16 + } +} + +fn f64_to_f16_fallback(value: f64) -> u16 { + // Convert to raw bytes, truncating the last 32-bits of mantissa; that precision will always + // be lost on half-precision. + let val = value.to_bits(); + let x = (val >> 32) as u32; + + // Extract IEEE754 components + let sign = x & 0x8000_0000u32; + let exp = x & 0x7FF0_0000u32; + let man = x & 0x000F_FFFFu32; + + // Check for all exponent bits being set, which is Infinity or NaN + if exp == 0x7FF0_0000u32 { + // Set mantissa MSB for NaN (and also keep shifted mantissa bits). + // We also have to check the last 32 bits. + let nan_bit = if man == 0 && (val as u32 == 0) { + 0 + } else { + 0x0200u32 + }; + return ((sign >> 16) | 0x7C00u32 | nan_bit | (man >> 10)) as u16; + } + + // The number is normalized, start assembling half precision version + let half_sign = sign >> 16; + // Unbias the exponent, then bias for half precision + let unbiased_exp = ((exp >> 20) as i64) - 1023; + let half_exp = unbiased_exp + 15; + + // Check for exponent overflow, return +infinity + if half_exp >= 0x1F { + return (half_sign | 0x7C00u32) as u16; + } + + // Check for underflow + if half_exp <= 0 { + // Check mantissa for what we can do + if 10 - half_exp > 21 { + // No rounding possibility, so this is a full underflow, return signed zero + return half_sign as u16; + } + // Don't forget about hidden leading mantissa bit when assembling mantissa + let man = man | 0x0010_0000u32; + let mut half_man = man >> (11 - half_exp); + // Check for rounding (see comment above functions) + let round_bit = 1 << (10 - half_exp); + if (man & round_bit) != 0 && (man & (3 * round_bit - 1)) != 0 { + half_man += 1; + } + // No exponent for subnormals + return (half_sign | half_man) as u16; + } + + // Rebias the exponent + let half_exp = (half_exp as u32) << 10; + let half_man = man >> 10; + // Check for rounding (see comment above functions) + let round_bit = 0x0000_0200u32; + if (man & round_bit) != 0 && (man & (3 * round_bit - 1)) != 0 { + // Round it + ((half_sign | half_exp | half_man) + 1) as u16 + } else { + (half_sign | half_exp | half_man) as u16 + } +} + +fn f16_to_f32_fallback(i: u16) -> f32 { + // Check for signed zero + if i & 0x7FFFu16 == 0 { + return f32::from_bits((i as u32) << 16); + } + + let half_sign = (i & 0x8000u16) as u32; + let half_exp = (i & 0x7C00u16) as u32; + let half_man = (i & 0x03FFu16) as u32; + + // Check for an infinity or NaN when all exponent bits set + if half_exp == 0x7C00u32 { + // Check for signed infinity if mantissa is zero + if half_man == 0 { + return f32::from_bits((half_sign << 16) | 0x7F80_0000u32); + } else { + // NaN, keep current mantissa but also set most significiant mantissa bit + return f32::from_bits((half_sign << 16) | 0x7FC0_0000u32 | (half_man << 13)); + } + } + + // Calculate single-precision components with adjusted exponent + let sign = half_sign << 16; + // Unbias exponent + let unbiased_exp = ((half_exp as i32) >> 10) - 15; + + // Check for subnormals, which will be normalized by adjusting exponent + if half_exp == 0 { + // Calculate how much to adjust the exponent by + let e = (half_man as u16).leading_zeros() - 6; + + // Rebias and adjust exponent + let exp = (127 - 15 - e) << 23; + let man = (half_man << (14 + e)) & 0x7F_FF_FFu32; + return f32::from_bits(sign | exp | man); + } + + // Rebias exponent for a normalized normal + let exp = ((unbiased_exp + 127) as u32) << 23; + let man = (half_man & 0x03FFu32) << 13; + f32::from_bits(sign | exp | man) +} + +fn f16_to_f64_fallback(i: u16) -> f64 { + // Check for signed zero + if i & 0x7FFFu16 == 0 { + return f64::from_bits((i as u64) << 48); + } + + let half_sign = (i & 0x8000u16) as u64; + let half_exp = (i & 0x7C00u16) as u64; + let half_man = (i & 0x03FFu16) as u64; + + // Check for an infinity or NaN when all exponent bits set + if half_exp == 0x7C00u64 { + // Check for signed infinity if mantissa is zero + if half_man == 0 { + return f64::from_bits((half_sign << 48) | 0x7FF0_0000_0000_0000u64); + } else { + // NaN, keep current mantissa but also set most significiant mantissa bit + return f64::from_bits((half_sign << 48) | 0x7FF8_0000_0000_0000u64 | (half_man << 42)); + } + } + + // Calculate double-precision components with adjusted exponent + let sign = half_sign << 48; + // Unbias exponent + let unbiased_exp = ((half_exp as i64) >> 10) - 15; + + // Check for subnormals, which will be normalized by adjusting exponent + if half_exp == 0 { + // Calculate how much to adjust the exponent by + let e = (half_man as u16).leading_zeros() - 6; + + // Rebias and adjust exponent + let exp = ((1023 - 15 - e) as u64) << 52; + let man = (half_man << (43 + e)) & 0xF_FFFF_FFFF_FFFFu64; + return f64::from_bits(sign | exp | man); + } + + // Rebias exponent for a normalized normal + let exp = ((unbiased_exp + 1023) as u64) << 52; + let man = (half_man & 0x03FFu64) << 42; + f64::from_bits(sign | exp | man) +} + +#[inline] +fn f16x4_to_f32x4_fallback(v: &[u16]) -> [f32; 4] { + debug_assert!(v.len() >= 4); + + [ + f16_to_f32_fallback(v[0]), + f16_to_f32_fallback(v[1]), + f16_to_f32_fallback(v[2]), + f16_to_f32_fallback(v[3]), + ] +} + +#[inline] +fn f32x4_to_f16x4_fallback(v: &[f32]) -> [u16; 4] { + debug_assert!(v.len() >= 4); + + [ + f32_to_f16_fallback(v[0]), + f32_to_f16_fallback(v[1]), + f32_to_f16_fallback(v[2]), + f32_to_f16_fallback(v[3]), + ] +} + +#[inline] +fn f16x4_to_f64x4_fallback(v: &[u16]) -> [f64; 4] { + debug_assert!(v.len() >= 4); + + [ + f16_to_f64_fallback(v[0]), + f16_to_f64_fallback(v[1]), + f16_to_f64_fallback(v[2]), + f16_to_f64_fallback(v[3]), + ] +} + +#[inline] +fn f64x4_to_f16x4_fallback(v: &[f64]) -> [u16; 4] { + debug_assert!(v.len() >= 4); + + [ + f64_to_f16_fallback(v[0]), + f64_to_f16_fallback(v[1]), + f64_to_f16_fallback(v[2]), + f64_to_f16_fallback(v[3]), + ] +} + +/////////////// x86/x86_64 f16c //////////////// +#[cfg(all( + feature = "use-intrinsics", + any(target_arch = "x86", target_arch = "x86_64") +))] +mod x86 { + use core::{mem::MaybeUninit, ptr}; + + #[cfg(target_arch = "x86")] + use core::arch::x86::{__m128, __m128i, _mm_cvtph_ps, _mm_cvtps_ph, _MM_FROUND_TO_NEAREST_INT}; + #[cfg(target_arch = "x86_64")] + use core::arch::x86_64::{ + __m128, __m128i, _mm_cvtph_ps, _mm_cvtps_ph, _MM_FROUND_TO_NEAREST_INT, + }; + + #[target_feature(enable = "f16c")] + #[inline] + pub(super) unsafe fn f16_to_f32_x86_f16c(i: u16) -> f32 { + let mut vec = MaybeUninit::<__m128i>::zeroed(); + vec.as_mut_ptr().cast::().write(i); + let retval = _mm_cvtph_ps(vec.assume_init()); + *(&retval as *const __m128).cast() + } + + #[target_feature(enable = "f16c")] + #[inline] + pub(super) unsafe fn f32_to_f16_x86_f16c(f: f32) -> u16 { + let mut vec = MaybeUninit::<__m128>::zeroed(); + vec.as_mut_ptr().cast::().write(f); + let retval = _mm_cvtps_ph(vec.assume_init(), _MM_FROUND_TO_NEAREST_INT); + *(&retval as *const __m128i).cast() + } + + #[target_feature(enable = "f16c")] + #[inline] + pub(super) unsafe fn f16x4_to_f32x4_x86_f16c(v: &[u16]) -> [f32; 4] { + debug_assert!(v.len() >= 4); + + let mut vec = MaybeUninit::<__m128i>::zeroed(); + ptr::copy_nonoverlapping(v.as_ptr(), vec.as_mut_ptr().cast(), 4); + let retval = _mm_cvtph_ps(vec.assume_init()); + *(&retval as *const __m128).cast() + } + + #[target_feature(enable = "f16c")] + #[inline] + pub(super) unsafe fn f32x4_to_f16x4_x86_f16c(v: &[f32]) -> [u16; 4] { + debug_assert!(v.len() >= 4); + + let mut vec = MaybeUninit::<__m128>::uninit(); + ptr::copy_nonoverlapping(v.as_ptr(), vec.as_mut_ptr().cast(), 4); + let retval = _mm_cvtps_ph(vec.assume_init(), _MM_FROUND_TO_NEAREST_INT); + *(&retval as *const __m128i).cast() + } + + #[target_feature(enable = "f16c")] + #[inline] + pub(super) unsafe fn f16x4_to_f64x4_x86_f16c(v: &[u16]) -> [f64; 4] { + debug_assert!(v.len() >= 4); + + let mut vec = MaybeUninit::<__m128i>::zeroed(); + ptr::copy_nonoverlapping(v.as_ptr(), vec.as_mut_ptr().cast(), 4); + let retval = _mm_cvtph_ps(vec.assume_init()); + let array = *(&retval as *const __m128).cast::<[f32; 4]>(); + // Let compiler vectorize this regular cast for now. + // TODO: investigate auto-detecting sse2/avx convert features + [ + array[0] as f64, + array[1] as f64, + array[2] as f64, + array[3] as f64, + ] + } + + #[target_feature(enable = "f16c")] + #[inline] + pub(super) unsafe fn f64x4_to_f16x4_x86_f16c(v: &[f64]) -> [u16; 4] { + debug_assert!(v.len() >= 4); + + // Let compiler vectorize this regular cast for now. + // TODO: investigate auto-detecting sse2/avx convert features + let v = [v[0] as f32, v[1] as f32, v[2] as f32, v[3] as f32]; + + let mut vec = MaybeUninit::<__m128>::uninit(); + ptr::copy_nonoverlapping(v.as_ptr(), vec.as_mut_ptr().cast(), 4); + let retval = _mm_cvtps_ph(vec.assume_init(), _MM_FROUND_TO_NEAREST_INT); + *(&retval as *const __m128i).cast() + } +} diff --git a/third_party/cargo/vendor/half-1.4.0/src/lib.rs b/third_party/cargo/vendor/half-1.4.0/src/lib.rs new file mode 100644 index 0000000..f5d5f57 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/src/lib.rs @@ -0,0 +1,108 @@ +//! A crate that provides support for half-precision 16-bit floating point types. +//! +//! This crate provides the [`f16`] type, which is an implementation of the IEEE 754-2008 standard +//! [`binary16`] a.k.a `half` floating point type. This 16-bit floating point type is intended for +//! efficient storage where the full range and precision of a larger floating point value is not +//! required. This is especially useful for image storage formats. +//! +//! This crate also provides a [`bf16`] type, an alternative 16-bit floating point format. The +//! [`bfloat16`] format is a truncated IEEE 754 standard `binary32` float that preserves the +//! exponent to allow the same range as `f32` but with only 8 bits of precision (instead of 11 +//! bits for [`f16`]). See the [`bf16`] type for details. +//! +//! Because [`f16`] and [`bf16`] are primarily for efficient storage, floating point operations such as +//! addition, multiplication, etc. are not implemented. Operations should be performed with `f32` +//! or higher-precision types and converted to/from [`f16`] or [`bf16`] as necessary. +//! +//! This crate also provides a [`slice`] module for zero-copy in-place conversions of `u16` slices +//! to both [`f16`] and [`bf16`], as well as efficient vectorized conversions of larger buffers of +//! floating point values to and from these half formats. +//! +//! A [`prelude`] module is provided for easy importing of available utility traits. +//! +//! Some hardware architectures provide support for 16-bit floating point conversions. Enable the +//! `use-intrinsics` feature to use LLVM intrinsics for hardware conversions. This crate does no +//! checks on whether the hardware supports the feature. This feature currently only works on +//! nightly Rust due to a compiler feature gate. When this feature is enabled and the hardware +//! supports it, the [`slice`] trait conversions will use vectorized SIMD intructions for +//! increased efficiency. +//! +//! Support for [`serde`] crate `Serialize` and `Deserialize` traits is provided when the `serde` +//! feature is enabled. This adds a dependency on [`serde`] crate so is an optional cargo feature. +//! +//! The crate uses `#[no_std]` by default, so can be used in embedded environments without using the +//! Rust `std` library. A `std` feature is available, which enables additional utilities using the +//! `std` library, such as the [`vec`] module that provides zero-copy `Vec` conversions. +//! +//! [`f16`]: struct.f16.html +//! [`binary16`]: https://en.wikipedia.org/wiki/Half-precision_floating-point_format +//! [`bf16`]: struct.bf16.html +//! [`bfloat16`]: https://en.wikipedia.org/wiki/Bfloat16_floating-point_format +//! [`slice`]: slice/index.html +//! [`prelude`]: prelude/index.html +//! [`serde`]: https://crates.io/crates/serde +//! [`vec`]: vec/index.html + +#![warn( + missing_docs, + missing_copy_implementations, + missing_debug_implementations, + trivial_numeric_casts, + unused_extern_crates, + unused_import_braces, + future_incompatible, + rust_2018_compatibility, + rust_2018_idioms, + clippy::all +)] +#![allow(clippy::verbose_bit_mask, clippy::cast_lossless)] +#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr( + all( + feature = "use-intrinsics", + any(target_arch = "x86", target_arch = "x86_64") + ), + feature(stdsimd, f16c_target_feature) +)] +#![doc(html_root_url = "https://docs.rs/half/1.4.0")] + +mod bfloat; +mod binary16; +pub mod slice; +#[cfg(feature = "std")] +pub mod vec; + +pub use binary16::f16; + +#[allow(deprecated)] +pub use binary16::consts; + +pub use bfloat::bf16; + +/// A collection of the most used items and traits in this crate for easy importing. +/// +/// # Examples +/// +/// ```rust +/// use half::prelude::*; +/// ``` +pub mod prelude { + #[doc(no_inline)] + pub use crate::{ + bf16, f16, + slice::{HalfBitsSliceExt, HalfFloatSliceExt}, + }; + + #[cfg(feature = "std")] + pub use crate::vec::{HalfBitsVecExt, HalfFloatVecExt}; +} + +// Keep this module private to crate +pub(crate) mod private { + use crate::{bf16, f16}; + + pub trait SealedHalf {} + + impl SealedHalf for f16 {} + impl SealedHalf for bf16 {} +} diff --git a/third_party/cargo/vendor/half-1.4.0/src/slice.rs b/third_party/cargo/vendor/half-1.4.0/src/slice.rs new file mode 100644 index 0000000..5b4c184 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/src/slice.rs @@ -0,0 +1,973 @@ +//! Contains utility functions and traits to convert between slices of `u16` bits and `f16` or +//! `bf16` numbers. +//! +//! The utility [`HalfBitsSliceExt`] sealed extension trait is implemented for `[u16]` slices, +//! while the utility [`HalfFloatSliceExt`] sealed extension trait is implemented for both `[f16]` +//! and `[bf16]` slices. These traits provide efficient conversions and reinterpret casting of +//! larger buffers of floating point values, and are automatically included in the [`prelude`] +//! module. +//! +//! [`HalfBitsSliceExt`]: trait.HalfBitsSliceExt.html +//! [`HalfFloatSliceExt`]: trait.HalfFloatSliceExt.html +//! [`prelude`]: ../prelude/index.html + +use crate::{bf16, binary16::convert, f16}; +use core::slice; + +/// Extensions to `[f16]` and `[bf16]` slices to support conversion and reinterpret operations. +/// +/// This trait is sealed and cannot be implemented outside of this crate. +pub trait HalfFloatSliceExt: private::SealedHalfFloatSlice { + /// Reinterpret a slice of [`f16`](../struct.f16.html) or [`bf16`](../struct.bf16.html) + /// numbers as a slice of `u16` bits. + /// + /// This is a zero-copy operation. The reinterpreted slice has the same lifetime and memory + /// location as `self`. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// let float_buffer = [f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.)]; + /// let int_buffer = float_buffer.reinterpret_cast(); + /// + /// assert_eq!(int_buffer, [float_buffer[0].to_bits(), float_buffer[1].to_bits(), float_buffer[2].to_bits()]); + /// ``` + fn reinterpret_cast(&self) -> &[u16]; + + /// Reinterpret a mutable slice of [`f16`](../struct.f16.html) or + /// [`bf16`](../struct.bf16.html) numbers as a mutable slice of `u16` bits. + /// + /// This is a zero-copy operation. The transmuted slice has the same lifetime as the original, + /// which prevents mutating `self` as long as the returned `&mut [u16]` is borrowed. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// let mut float_buffer = [f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.)]; + /// + /// { + /// let int_buffer = float_buffer.reinterpret_cast_mut(); + /// + /// assert_eq!(int_buffer, [f16::from_f32(1.).to_bits(), f16::from_f32(2.).to_bits(), f16::from_f32(3.).to_bits()]); + /// + /// // Mutating the u16 slice will mutating the original + /// int_buffer[0] = 0; + /// } + /// + /// // Note that we need to drop int_buffer before using float_buffer again or we will get a borrow error. + /// assert_eq!(float_buffer, [f16::from_f32(0.), f16::from_f32(2.), f16::from_f32(3.)]); + /// ``` + fn reinterpret_cast_mut(&mut self) -> &mut [u16]; + + /// Convert all of the elements of a `[f32]` slice into [`f16`](../struct.f16.html) or + /// [`bf16`](../struct.bf16.html) values in `self`. + /// + /// The length of `src` must be the same as `self`. + /// + /// The conversion operation is vectorized over the slice, meaning the conversion may be more + /// efficient than converting individual elements on some hardware that supports SIMD + /// conversions. See [crate documentation](../index.html) for more information on hardware + /// conversion support. + /// + /// # Panics + /// + /// This function will panic if the two slices have different lengths. + /// + /// # Examples + /// ```rust + /// # use half::prelude::*; + /// // Initialize an empty buffer + /// let mut buffer = [0u16; 4]; + /// let buffer = buffer.reinterpret_cast_mut::(); + /// + /// let float_values = [1., 2., 3., 4.]; + /// + /// // Now convert + /// buffer.convert_from_f32_slice(&float_values); + /// + /// assert_eq!(buffer, [f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.), f16::from_f32(4.)]); + /// ``` + fn convert_from_f32_slice(&mut self, src: &[f32]); + + /// Convert all of the elements of a `[f64]` slice into [`f16`](../struct.f16.html) or + /// [`bf16`](../struct.bf16.html) values in `self`. + /// + /// The length of `src` must be the same as `self`. + /// + /// The conversion operation is vectorized over the slice, meaning the conversion may be more + /// efficient than converting individual elements on some hardware that supports SIMD + /// conversions. See [crate documentation](../index.html) for more information on hardware + /// conversion support. + /// + /// # Panics + /// + /// This function will panic if the two slices have different lengths. + /// + /// # Examples + /// ```rust + /// # use half::prelude::*; + /// // Initialize an empty buffer + /// let mut buffer = [0u16; 4]; + /// let buffer = buffer.reinterpret_cast_mut::(); + /// + /// let float_values = [1., 2., 3., 4.]; + /// + /// // Now convert + /// buffer.convert_from_f64_slice(&float_values); + /// + /// assert_eq!(buffer, [f16::from_f64(1.), f16::from_f64(2.), f16::from_f64(3.), f16::from_f64(4.)]); + /// ``` + fn convert_from_f64_slice(&mut self, src: &[f64]); + + /// Convert all of the [`f16`](../struct.f16.html) or [`bf16`](../struct.bf16.html) + /// elements of `self` into `f32` values in `dst`. + /// + /// The length of `src` must be the same as `self`. + /// + /// The conversion operation is vectorized over the slice, meaning the conversion may be more + /// efficient than converting individual elements on some hardware that supports SIMD + /// conversions. See [crate documentation](../index.html) for more information on hardware + /// conversion support. + /// + /// # Panics + /// + /// This function will panic if the two slices have different lengths. + /// + /// # Examples + /// ```rust + /// # use half::prelude::*; + /// // Initialize an empty buffer + /// let mut buffer = [0f32; 4]; + /// + /// let half_values = [f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.), f16::from_f32(4.)]; + /// + /// // Now convert + /// half_values.convert_to_f32_slice(&mut buffer); + /// + /// assert_eq!(buffer, [1., 2., 3., 4.]); + /// ``` + fn convert_to_f32_slice(&self, dst: &mut [f32]); + + /// Convert all of the [`f16`](../struct.f16.html) or [`bf16`](../struct.bf16.html) + /// elements of `self` into `f64` values in `dst`. + /// + /// The length of `src` must be the same as `self`. + /// + /// The conversion operation is vectorized over the slice, meaning the conversion may be more + /// efficient than converting individual elements on some hardware that supports SIMD + /// conversions. See [crate documentation](../index.html) for more information on hardware + /// conversion support. + /// + /// # Panics + /// + /// This function will panic if the two slices have different lengths. + /// + /// # Examples + /// ```rust + /// # use half::prelude::*; + /// // Initialize an empty buffer + /// let mut buffer = [0f64; 4]; + /// + /// let half_values = [f16::from_f64(1.), f16::from_f64(2.), f16::from_f64(3.), f16::from_f64(4.)]; + /// + /// // Now convert + /// half_values.convert_to_f64_slice(&mut buffer); + /// + /// assert_eq!(buffer, [1., 2., 3., 4.]); + /// ``` + fn convert_to_f64_slice(&self, dst: &mut [f64]); + + // Because trait is sealed, we can get away with different interfaces between features + + #[cfg(feature = "std")] + /// Convert all of the [`f16`](../struct.f16.html) or [`bf16`](../struct.bf16.html) + /// elements of `self` into `f32` values in a new vector. + /// + /// The conversion operation is vectorized over the slice, meaning the conversion may be more + /// efficient than converting individual elements on some hardware that supports SIMD + /// conversions. See [crate documentation](../index.html) for more information on hardware + /// conversion support. + /// + /// This method is only available with the `std` feature. + /// + /// # Examples + /// ```rust + /// # use half::prelude::*; + /// let half_values = [f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.), f16::from_f32(4.)]; + /// let vec = half_values.to_f32_vec(); + /// + /// assert_eq!(vec, vec![1., 2., 3., 4.]); + /// ``` + fn to_f32_vec(&self) -> Vec; + + /// Convert all of the [`f16`](../struct.f16.html) or [`bf16`](../struct.bf16.html) + /// elements of `self` into `f64` values in a new vector. + /// + /// The conversion operation is vectorized over the slice, meaning the conversion may be more + /// efficient than converting individual elements on some hardware that supports SIMD + /// conversions. See [crate documentation](../index.html) for more information on hardware + /// conversion support. + /// + /// This method is only available with the `std` feature. + /// + /// # Examples + /// ```rust + /// # use half::prelude::*; + /// let half_values = [f16::from_f64(1.), f16::from_f64(2.), f16::from_f64(3.), f16::from_f64(4.)]; + /// let vec = half_values.to_f64_vec(); + /// + /// assert_eq!(vec, vec![1., 2., 3., 4.]); + /// ``` + #[cfg(feature = "std")] + fn to_f64_vec(&self) -> Vec; +} + +/// Extensions to `[u16]` slices to support reinterpret operations. +/// +/// This trait is sealed and cannot be implemented outside of this crate. +pub trait HalfBitsSliceExt: private::SealedHalfBitsSlice { + /// Reinterpret a slice of `u16` bits as a slice of [`f16`](../struct.f16.html) or + /// [`bf16`](../struct.bf16.html) numbers. + /// + /// `H` is the type to cast to, and must be either the [`f16`](../struct.f16.html) or + /// [`bf16`](../struct.bf16.html) type. + /// + /// This is a zero-copy operation. The reinterpreted slice has the same lifetime and memory + /// location as `self`. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// let int_buffer = [f16::from_f32(1.).to_bits(), f16::from_f32(2.).to_bits(), f16::from_f32(3.).to_bits()]; + /// let float_buffer: &[f16] = int_buffer.reinterpret_cast(); + /// + /// assert_eq!(float_buffer, [f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.)]); + /// + /// // You may have to specify the cast type directly if the compiler can't infer the type. + /// // The following is also valid in Rust. + /// let typed_buffer = int_buffer.reinterpret_cast::(); + /// ``` + fn reinterpret_cast(&self) -> &[H] + where + H: crate::private::SealedHalf; + + /// Reinterpret a mutable slice of `u16` bits as a mutable slice of [`f16`](../struct.f16.html) + /// or [`bf16`](../struct.bf16.html) numbers. + /// + /// `H` is the type to cast to, and must be either the [`f16`](../struct.f16.html) or + /// [`bf16`](../struct.bf16.html) type. + /// + /// This is a zero-copy operation. The transmuted slice has the same lifetime as the original, + /// which prevents mutating `self` as long as the returned `&mut [f16]` is borrowed. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// let mut int_buffer = [f16::from_f32(1.).to_bits(), f16::from_f32(2.).to_bits(), f16::from_f32(3.).to_bits()]; + /// + /// { + /// let float_buffer: &mut [f16] = int_buffer.reinterpret_cast_mut(); + /// + /// assert_eq!(float_buffer, [f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.)]); + /// + /// // Mutating the f16 slice will mutating the original + /// float_buffer[0] = f16::from_f32(0.); + /// } + /// + /// // Note that we need to drop float_buffer before using int_buffer again or we will get a borrow error. + /// assert_eq!(int_buffer, [f16::from_f32(0.).to_bits(), f16::from_f32(2.).to_bits(), f16::from_f32(3.).to_bits()]); + /// + /// // You may have to specify the cast type directly if the compiler can't infer the type. + /// // The following is also valid in Rust. + /// let typed_buffer = int_buffer.reinterpret_cast_mut::(); + /// ``` + fn reinterpret_cast_mut(&mut self) -> &mut [H] + where + H: crate::private::SealedHalf; +} + +mod private { + use crate::{bf16, f16}; + + pub trait SealedHalfFloatSlice {} + impl SealedHalfFloatSlice for [f16] {} + impl SealedHalfFloatSlice for [bf16] {} + + pub trait SealedHalfBitsSlice {} + impl SealedHalfBitsSlice for [u16] {} +} + +impl HalfFloatSliceExt for [f16] { + #[inline] + fn reinterpret_cast(&self) -> &[u16] { + let pointer = self.as_ptr() as *const u16; + let length = self.len(); + // SAFETY: We are reconstructing full length of original slice, using its same lifetime, + // and the size of elements are identical + unsafe { slice::from_raw_parts(pointer, length) } + } + + #[inline] + fn reinterpret_cast_mut(&mut self) -> &mut [u16] { + let pointer = self.as_ptr() as *mut u16; + let length = self.len(); + // SAFETY: We are reconstructing full length of original slice, using its same lifetime, + // and the size of elements are identical + unsafe { slice::from_raw_parts_mut(pointer, length) } + } + + fn convert_from_f32_slice(&mut self, src: &[f32]) { + assert_eq!( + self.len(), + src.len(), + "destination and source slices have different lengths" + ); + + let mut chunks = src.chunks_exact(4); + let mut chunk_count = 0usize; // Not using .enumerate() because we need this value for remainder + for chunk in &mut chunks { + let vec = convert::f32x4_to_f16x4(chunk); + let dst_idx = chunk_count * 4; + self[dst_idx..dst_idx + 4].copy_from_slice(vec.reinterpret_cast()); + chunk_count += 1; + } + + // Process remainder + if !chunks.remainder().is_empty() { + let mut buf = [0f32; 4]; + buf[..chunks.remainder().len()].copy_from_slice(chunks.remainder()); + let vec = convert::f32x4_to_f16x4(&buf); + let dst_idx = chunk_count * 4; + self[dst_idx..dst_idx + chunks.remainder().len()] + .copy_from_slice(vec[..chunks.remainder().len()].reinterpret_cast()); + } + } + + fn convert_from_f64_slice(&mut self, src: &[f64]) { + assert_eq!( + self.len(), + src.len(), + "destination and source slices have different lengths" + ); + + let mut chunks = src.chunks_exact(4); + let mut chunk_count = 0usize; // Not using .enumerate() because we need this value for remainder + for chunk in &mut chunks { + let vec = convert::f64x4_to_f16x4(chunk); + let dst_idx = chunk_count * 4; + self[dst_idx..dst_idx + 4].copy_from_slice(vec.reinterpret_cast()); + chunk_count += 1; + } + + // Process remainder + if !chunks.remainder().is_empty() { + let mut buf = [0f64; 4]; + buf[..chunks.remainder().len()].copy_from_slice(chunks.remainder()); + let vec = convert::f64x4_to_f16x4(&buf); + let dst_idx = chunk_count * 4; + self[dst_idx..dst_idx + chunks.remainder().len()] + .copy_from_slice(vec[..chunks.remainder().len()].reinterpret_cast()); + } + } + + fn convert_to_f32_slice(&self, dst: &mut [f32]) { + assert_eq!( + self.len(), + dst.len(), + "destination and source slices have different lengths" + ); + + let mut chunks = self.chunks_exact(4); + let mut chunk_count = 0usize; // Not using .enumerate() because we need this value for remainder + for chunk in &mut chunks { + let vec = convert::f16x4_to_f32x4(chunk.reinterpret_cast()); + let dst_idx = chunk_count * 4; + dst[dst_idx..dst_idx + 4].copy_from_slice(&vec); + chunk_count += 1; + } + + // Process remainder + if !chunks.remainder().is_empty() { + let mut buf = [0u16; 4]; + buf[..chunks.remainder().len()].copy_from_slice(chunks.remainder().reinterpret_cast()); + let vec = convert::f16x4_to_f32x4(&buf); + let dst_idx = chunk_count * 4; + dst[dst_idx..dst_idx + chunks.remainder().len()] + .copy_from_slice(&vec[..chunks.remainder().len()]); + } + } + + fn convert_to_f64_slice(&self, dst: &mut [f64]) { + assert_eq!( + self.len(), + dst.len(), + "destination and source slices have different lengths" + ); + + let mut chunks = self.chunks_exact(4); + let mut chunk_count = 0usize; // Not using .enumerate() because we need this value for remainder + for chunk in &mut chunks { + let vec = convert::f16x4_to_f64x4(chunk.reinterpret_cast()); + let dst_idx = chunk_count * 4; + dst[dst_idx..dst_idx + 4].copy_from_slice(&vec); + chunk_count += 1; + } + + // Process remainder + if !chunks.remainder().is_empty() { + let mut buf = [0u16; 4]; + buf[..chunks.remainder().len()].copy_from_slice(chunks.remainder().reinterpret_cast()); + let vec = convert::f16x4_to_f64x4(&buf); + let dst_idx = chunk_count * 4; + dst[dst_idx..dst_idx + chunks.remainder().len()] + .copy_from_slice(&vec[..chunks.remainder().len()]); + } + } + + #[cfg(feature = "std")] + #[inline] + fn to_f32_vec(&self) -> Vec { + let mut vec = Vec::with_capacity(self.len()); + // SAFETY: convert will initialize every value in the vector without reading them, + // so this is safe to do instead of double initialize from resize, and we're setting it to + // same value as capacity. + unsafe { vec.set_len(self.len()) }; + self.convert_to_f32_slice(&mut vec); + vec + } + + #[cfg(feature = "std")] + #[inline] + fn to_f64_vec(&self) -> Vec { + let mut vec = Vec::with_capacity(self.len()); + // SAFETY: convert will initialize every value in the vector without reading them, + // so this is safe to do instead of double initialize from resize, and we're setting it to + // same value as capacity. + unsafe { vec.set_len(self.len()) }; + self.convert_to_f64_slice(&mut vec); + vec + } +} + +impl HalfFloatSliceExt for [bf16] { + #[inline] + fn reinterpret_cast(&self) -> &[u16] { + let pointer = self.as_ptr() as *const u16; + let length = self.len(); + // SAFETY: We are reconstructing full length of original slice, using its same lifetime, + // and the size of elements are identical + unsafe { slice::from_raw_parts(pointer, length) } + } + + #[inline] + fn reinterpret_cast_mut(&mut self) -> &mut [u16] { + let pointer = self.as_ptr() as *mut u16; + let length = self.len(); + // SAFETY: We are reconstructing full length of original slice, using its same lifetime, + // and the size of elements are identical + unsafe { slice::from_raw_parts_mut(pointer, length) } + } + + fn convert_from_f32_slice(&mut self, src: &[f32]) { + assert_eq!( + self.len(), + src.len(), + "destination and source slices have different lengths" + ); + + // Just use regular loop here until there's any bf16 SIMD support. + for (i, f) in src.iter().enumerate() { + self[i] = bf16::from_f32(*f); + } + } + + fn convert_from_f64_slice(&mut self, src: &[f64]) { + assert_eq!( + self.len(), + src.len(), + "destination and source slices have different lengths" + ); + + // Just use regular loop here until there's any bf16 SIMD support. + for (i, f) in src.iter().enumerate() { + self[i] = bf16::from_f64(*f); + } + } + + fn convert_to_f32_slice(&self, dst: &mut [f32]) { + assert_eq!( + self.len(), + dst.len(), + "destination and source slices have different lengths" + ); + + // Just use regular loop here until there's any bf16 SIMD support. + for (i, f) in self.iter().enumerate() { + dst[i] = f.to_f32(); + } + } + + fn convert_to_f64_slice(&self, dst: &mut [f64]) { + assert_eq!( + self.len(), + dst.len(), + "destination and source slices have different lengths" + ); + + // Just use regular loop here until there's any bf16 SIMD support. + for (i, f) in self.iter().enumerate() { + dst[i] = f.to_f64(); + } + } + + #[cfg(feature = "std")] + #[inline] + fn to_f32_vec(&self) -> Vec { + let mut vec = Vec::with_capacity(self.len()); + // SAFETY: convert will initialize every value in the vector without reading them, + // so this is safe to do instead of double initialize from resize, and we're setting it to + // same value as capacity. + unsafe { vec.set_len(self.len()) }; + self.convert_to_f32_slice(&mut vec); + vec + } + + #[cfg(feature = "std")] + #[inline] + fn to_f64_vec(&self) -> Vec { + let mut vec = Vec::with_capacity(self.len()); + // SAFETY: convert will initialize every value in the vector without reading them, + // so this is safe to do instead of double initialize from resize, and we're setting it to + // same value as capacity. + unsafe { vec.set_len(self.len()) }; + self.convert_to_f64_slice(&mut vec); + vec + } +} + +impl HalfBitsSliceExt for [u16] { + // Since we sealed all the traits involved, these are safe. + #[inline] + fn reinterpret_cast(&self) -> &[H] + where + H: crate::private::SealedHalf, + { + let pointer = self.as_ptr() as *const H; + let length = self.len(); + // SAFETY: We are reconstructing full length of original slice, using its same lifetime, + // and the size of elements are identical + unsafe { slice::from_raw_parts(pointer, length) } + } + + #[inline] + fn reinterpret_cast_mut(&mut self) -> &mut [H] + where + H: crate::private::SealedHalf, + { + let pointer = self.as_ptr() as *mut H; + let length = self.len(); + // SAFETY: We are reconstructing full length of original slice, using its same lifetime, + // and the size of elements are identical + unsafe { slice::from_raw_parts_mut(pointer, length) } + } +} + +/// Reinterpret a mutable slice of `u16` bits as a mutable slice of [`f16`](../struct.f16.html) +/// numbers. +/// +/// The transmuted slice has the same life time as the original, which prevents mutating the borrowed +/// `mut [u16]` argument as long as the returned `mut [f16]` is borrowed. +#[deprecated( + since = "1.4.0", + note = "use [`HalfBitsSliceExt::reinterpret_cast_mut`](trait.HalfBitsSliceExt.html#tymethod.reinterpret_cast_mut) instead" +)] +#[inline] +pub fn from_bits_mut(bits: &mut [u16]) -> &mut [f16] { + bits.reinterpret_cast_mut() +} + +/// Reinterpret a mutable slice of [`f16`](../struct.f16.html) numbers as a mutable slice of `u16` +/// bits. +/// +///The transmuted slice has the same life time as the original, which prevents mutating the +/// borrowed `mut [f16]` argument as long as the returned `mut [u16]` is borrowed. +#[deprecated( + since = "1.4.0", + note = "use [`HalfFloatSliceExt::reinterpret_cast_mut`](trait.HalfFloatSliceExt.html#tymethod.reinterpret_cast_mut) instead" +)] +#[inline] +pub fn to_bits_mut(bits: &mut [f16]) -> &mut [u16] { + bits.reinterpret_cast_mut() +} + +/// Reinterpret a slice of `u16` bits as a slice of [`f16`](../struct.f16.html) numbers. +/// +/// The transmuted slice has the same life time as the original. +#[deprecated( + since = "1.4.0", + note = "use [`HalfBitsSliceExt::reinterpret_cast`](trait.HalfBitsSliceExt.html#tymethod.reinterpret_cast) instead" +)] +#[inline] +pub fn from_bits(bits: &[u16]) -> &[f16] { + bits.reinterpret_cast() +} + +/// Reinterpret a slice of [`f16`](../struct.f16.html) numbers as a slice of `u16` bits. +/// +/// The transmuted slice has the same life time as the original. +#[deprecated( + since = "1.4.0", + note = "use [`HalfFloatSliceExt::reinterpret_cast`](trait.HalfFloatSliceExt.html#tymethod.reinterpret_cast) instead" +)] +#[inline] +pub fn to_bits(bits: &[f16]) -> &[u16] { + bits.reinterpret_cast() +} + +#[cfg(test)] +mod test { + use super::{HalfBitsSliceExt, HalfFloatSliceExt}; + use crate::{bf16, f16}; + + #[test] + fn test_slice_conversions_f16() { + let bits = &[ + f16::E.to_bits(), + f16::PI.to_bits(), + f16::EPSILON.to_bits(), + f16::FRAC_1_SQRT_2.to_bits(), + ]; + let numbers = &[f16::E, f16::PI, f16::EPSILON, f16::FRAC_1_SQRT_2]; + + // Convert from bits to numbers + let from_bits = bits.reinterpret_cast::(); + assert_eq!(from_bits, numbers); + + // Convert from numbers back to bits + let to_bits = from_bits.reinterpret_cast(); + assert_eq!(to_bits, bits); + } + + #[test] + fn test_mutablility_f16() { + let mut bits_array = [f16::PI.to_bits()]; + let bits = &mut bits_array[..]; + + { + // would not compile without these braces + // TODO: add automated test to check that it does not compile without braces + let numbers = bits.reinterpret_cast_mut(); + numbers[0] = f16::E; + } + + assert_eq!(bits, &[f16::E.to_bits()]); + + bits[0] = f16::LN_2.to_bits(); + assert_eq!(bits, &[f16::LN_2.to_bits()]); + } + + #[test] + fn test_slice_conversions_bf16() { + let bits = &[ + bf16::E.to_bits(), + bf16::PI.to_bits(), + bf16::EPSILON.to_bits(), + bf16::FRAC_1_SQRT_2.to_bits(), + ]; + let numbers = &[bf16::E, bf16::PI, bf16::EPSILON, bf16::FRAC_1_SQRT_2]; + + // Convert from bits to numbers + let from_bits = bits.reinterpret_cast::(); + assert_eq!(from_bits, numbers); + + // Convert from numbers back to bits + let to_bits = from_bits.reinterpret_cast(); + assert_eq!(to_bits, bits); + } + + #[test] + fn test_mutablility_bf16() { + let mut bits_array = [bf16::PI.to_bits()]; + let bits = &mut bits_array[..]; + + { + // would not compile without these braces + // TODO: add automated test to check that it does not compile without braces + let numbers = bits.reinterpret_cast_mut(); + numbers[0] = bf16::E; + } + + assert_eq!(bits, &[bf16::E.to_bits()]); + + bits[0] = bf16::LN_2.to_bits(); + assert_eq!(bits, &[bf16::LN_2.to_bits()]); + } + + #[test] + fn slice_convert_f16_f32() { + // Exact chunks + let vf32 = [1., 2., 3., 4., 5., 6., 7., 8.]; + let vf16 = [ + f16::from_f32(1.), + f16::from_f32(2.), + f16::from_f32(3.), + f16::from_f32(4.), + f16::from_f32(5.), + f16::from_f32(6.), + f16::from_f32(7.), + f16::from_f32(8.), + ]; + let mut buf32 = vf32; + let mut buf16 = vf16; + + vf16.convert_to_f32_slice(&mut buf32); + assert_eq!(&vf32, &buf32); + + buf16.convert_from_f32_slice(&vf32); + assert_eq!(&vf16, &buf16); + + // Partial with chunks + let vf32 = [1., 2., 3., 4., 5., 6., 7., 8., 9.]; + let vf16 = [ + f16::from_f32(1.), + f16::from_f32(2.), + f16::from_f32(3.), + f16::from_f32(4.), + f16::from_f32(5.), + f16::from_f32(6.), + f16::from_f32(7.), + f16::from_f32(8.), + f16::from_f32(9.), + ]; + let mut buf32 = vf32; + let mut buf16 = vf16; + + vf16.convert_to_f32_slice(&mut buf32); + assert_eq!(&vf32, &buf32); + + buf16.convert_from_f32_slice(&vf32); + assert_eq!(&vf16, &buf16); + + // Partial with chunks + let vf32 = [1., 2.]; + let vf16 = [f16::from_f32(1.), f16::from_f32(2.)]; + let mut buf32 = vf32; + let mut buf16 = vf16; + + vf16.convert_to_f32_slice(&mut buf32); + assert_eq!(&vf32, &buf32); + + buf16.convert_from_f32_slice(&vf32); + assert_eq!(&vf16, &buf16); + } + + #[test] + fn slice_convert_bf16_f32() { + // Exact chunks + let vf32 = [1., 2., 3., 4., 5., 6., 7., 8.]; + let vf16 = [ + bf16::from_f32(1.), + bf16::from_f32(2.), + bf16::from_f32(3.), + bf16::from_f32(4.), + bf16::from_f32(5.), + bf16::from_f32(6.), + bf16::from_f32(7.), + bf16::from_f32(8.), + ]; + let mut buf32 = vf32; + let mut buf16 = vf16; + + vf16.convert_to_f32_slice(&mut buf32); + assert_eq!(&vf32, &buf32); + + buf16.convert_from_f32_slice(&vf32); + assert_eq!(&vf16, &buf16); + + // Partial with chunks + let vf32 = [1., 2., 3., 4., 5., 6., 7., 8., 9.]; + let vf16 = [ + bf16::from_f32(1.), + bf16::from_f32(2.), + bf16::from_f32(3.), + bf16::from_f32(4.), + bf16::from_f32(5.), + bf16::from_f32(6.), + bf16::from_f32(7.), + bf16::from_f32(8.), + bf16::from_f32(9.), + ]; + let mut buf32 = vf32; + let mut buf16 = vf16; + + vf16.convert_to_f32_slice(&mut buf32); + assert_eq!(&vf32, &buf32); + + buf16.convert_from_f32_slice(&vf32); + assert_eq!(&vf16, &buf16); + + // Partial with chunks + let vf32 = [1., 2.]; + let vf16 = [bf16::from_f32(1.), bf16::from_f32(2.)]; + let mut buf32 = vf32; + let mut buf16 = vf16; + + vf16.convert_to_f32_slice(&mut buf32); + assert_eq!(&vf32, &buf32); + + buf16.convert_from_f32_slice(&vf32); + assert_eq!(&vf16, &buf16); + } + + #[test] + fn slice_convert_f16_f64() { + // Exact chunks + let vf64 = [1., 2., 3., 4., 5., 6., 7., 8.]; + let vf16 = [ + f16::from_f64(1.), + f16::from_f64(2.), + f16::from_f64(3.), + f16::from_f64(4.), + f16::from_f64(5.), + f16::from_f64(6.), + f16::from_f64(7.), + f16::from_f64(8.), + ]; + let mut buf64 = vf64; + let mut buf16 = vf16; + + vf16.convert_to_f64_slice(&mut buf64); + assert_eq!(&vf64, &buf64); + + buf16.convert_from_f64_slice(&vf64); + assert_eq!(&vf16, &buf16); + + // Partial with chunks + let vf64 = [1., 2., 3., 4., 5., 6., 7., 8., 9.]; + let vf16 = [ + f16::from_f64(1.), + f16::from_f64(2.), + f16::from_f64(3.), + f16::from_f64(4.), + f16::from_f64(5.), + f16::from_f64(6.), + f16::from_f64(7.), + f16::from_f64(8.), + f16::from_f64(9.), + ]; + let mut buf64 = vf64; + let mut buf16 = vf16; + + vf16.convert_to_f64_slice(&mut buf64); + assert_eq!(&vf64, &buf64); + + buf16.convert_from_f64_slice(&vf64); + assert_eq!(&vf16, &buf16); + + // Partial with chunks + let vf64 = [1., 2.]; + let vf16 = [f16::from_f64(1.), f16::from_f64(2.)]; + let mut buf64 = vf64; + let mut buf16 = vf16; + + vf16.convert_to_f64_slice(&mut buf64); + assert_eq!(&vf64, &buf64); + + buf16.convert_from_f64_slice(&vf64); + assert_eq!(&vf16, &buf16); + } + + #[test] + fn slice_convert_bf16_f64() { + // Exact chunks + let vf64 = [1., 2., 3., 4., 5., 6., 7., 8.]; + let vf16 = [ + bf16::from_f64(1.), + bf16::from_f64(2.), + bf16::from_f64(3.), + bf16::from_f64(4.), + bf16::from_f64(5.), + bf16::from_f64(6.), + bf16::from_f64(7.), + bf16::from_f64(8.), + ]; + let mut buf64 = vf64; + let mut buf16 = vf16; + + vf16.convert_to_f64_slice(&mut buf64); + assert_eq!(&vf64, &buf64); + + buf16.convert_from_f64_slice(&vf64); + assert_eq!(&vf16, &buf16); + + // Partial with chunks + let vf64 = [1., 2., 3., 4., 5., 6., 7., 8., 9.]; + let vf16 = [ + bf16::from_f64(1.), + bf16::from_f64(2.), + bf16::from_f64(3.), + bf16::from_f64(4.), + bf16::from_f64(5.), + bf16::from_f64(6.), + bf16::from_f64(7.), + bf16::from_f64(8.), + bf16::from_f64(9.), + ]; + let mut buf64 = vf64; + let mut buf16 = vf16; + + vf16.convert_to_f64_slice(&mut buf64); + assert_eq!(&vf64, &buf64); + + buf16.convert_from_f64_slice(&vf64); + assert_eq!(&vf16, &buf16); + + // Partial with chunks + let vf64 = [1., 2.]; + let vf16 = [bf16::from_f64(1.), bf16::from_f64(2.)]; + let mut buf64 = vf64; + let mut buf16 = vf16; + + vf16.convert_to_f64_slice(&mut buf64); + assert_eq!(&vf64, &buf64); + + buf16.convert_from_f64_slice(&vf64); + assert_eq!(&vf16, &buf16); + } + + #[test] + #[should_panic] + fn convert_from_f32_slice_len_mismatch_panics() { + let mut slice1 = [f16::ZERO; 3]; + let slice2 = [0f32; 4]; + slice1.convert_from_f32_slice(&slice2); + } + + #[test] + #[should_panic] + fn convert_from_f64_slice_len_mismatch_panics() { + let mut slice1 = [f16::ZERO; 3]; + let slice2 = [0f64; 4]; + slice1.convert_from_f64_slice(&slice2); + } + + #[test] + #[should_panic] + fn convert_to_f32_slice_len_mismatch_panics() { + let slice1 = [f16::ZERO; 3]; + let mut slice2 = [0f32; 4]; + slice1.convert_to_f32_slice(&mut slice2); + } + + #[test] + #[should_panic] + fn convert_to_f64_slice_len_mismatch_panics() { + let slice1 = [f16::ZERO; 3]; + let mut slice2 = [0f64; 4]; + slice1.convert_to_f64_slice(&mut slice2); + } +} diff --git a/third_party/cargo/vendor/half-1.4.0/src/vec.rs b/third_party/cargo/vendor/half-1.4.0/src/vec.rs new file mode 100644 index 0000000..db57670 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/src/vec.rs @@ -0,0 +1,295 @@ +//! Contains utility functions and traits to convert between vectors of `u16` bits and `f16` or +//! `bf16` vectors. +//! +//! The utility [`HalfBitsVecExt`] sealed extension trait is implemented for `Vec` vectors, +//! while the utility [`HalfFloatVecExt`] sealed extension trait is implemented for both `Vec` +//! and `Vec` vectors. These traits provide efficient conversions and reinterpret casting of +//! larger buffers of floating point values, and are automatically included in the [`prelude`] +//! module. +//! +//! This module is only available with the `std` feature. +//! +//! [`HalfBitsVecExt`]: trait.HalfBitsVecExt.html +//! [`HalfFloatVecExt`]: trait.HalfFloatVecExt.html +//! [`prelude`]: ../prelude/index.html + +#![cfg(feature = "std")] + +use super::{bf16, f16, slice::HalfFloatSliceExt}; +use core::mem; + +/// Extensions to `Vec` and `Vec` to support reinterpret operations. +/// +/// This trait is sealed and cannot be implemented outside of this crate. +pub trait HalfFloatVecExt: private::SealedHalfFloatVec { + /// Reinterpret a vector of [`f16`](../struct.f16.html) or [`bf16`](../struct.bf16.html) + /// numbers as a vector of `u16` bits. + /// + /// This is a zero-copy operation. The reinterpreted vector has the same memory location as + /// `self`. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// let float_buffer = vec![f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.)]; + /// let int_buffer = float_buffer.reinterpret_into(); + /// + /// assert_eq!(int_buffer, [f16::from_f32(1.).to_bits(), f16::from_f32(2.).to_bits(), f16::from_f32(3.).to_bits()]); + /// ``` + fn reinterpret_into(self) -> Vec; + + /// Convert all of the elements of a `[f32]` slice into a new [`f16`](../struct.f16.html) or + /// [`bf16`](../struct.bf16.html) vector. + /// + /// The conversion operation is vectorized over the slice, meaning the conversion may be more + /// efficient than converting individual elements on some hardware that supports SIMD + /// conversions. See [crate documentation](../index.html) for more information on hardware + /// conversion support. + /// + /// # Examples + /// ```rust + /// # use half::prelude::*; + /// let float_values = [1., 2., 3., 4.]; + /// let vec: Vec = Vec::from_f32_slice(&float_values); + /// + /// assert_eq!(vec, vec![f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.), f16::from_f32(4.)]); + /// ``` + fn from_f32_slice(slice: &[f32]) -> Self; + + /// Convert all of the elements of a `[f64]` slice into a new [`f16`](../struct.f16.html) or + /// [`bf16`](../struct.bf16.html) vector. + /// + /// The conversion operation is vectorized over the slice, meaning the conversion may be more + /// efficient than converting individual elements on some hardware that supports SIMD + /// conversions. See [crate documentation](../index.html) for more information on hardware + /// conversion support. + /// + /// # Examples + /// ```rust + /// # use half::prelude::*; + /// let float_values = [1., 2., 3., 4.]; + /// let vec: Vec = Vec::from_f64_slice(&float_values); + /// + /// assert_eq!(vec, vec![f16::from_f64(1.), f16::from_f64(2.), f16::from_f64(3.), f16::from_f64(4.)]); + /// ``` + fn from_f64_slice(slice: &[f64]) -> Self; +} + +/// Extensions to `Vec` to support reinterpret operations. +/// +/// This trait is sealed and cannot be implemented outside of this crate. +pub trait HalfBitsVecExt: private::SealedHalfBitsVec { + /// Reinterpret a vector of `u16` bits as a vector of [`f16`](../struct.f16.html) or + /// [`bf16`](../struct.bf16.html) numbers. + /// + /// `H` is the type to cast to, and must be either the [`f16`](../struct.f16.html) or + /// [`bf16`](../struct.bf16.html) type. + /// + /// This is a zero-copy operation. The reinterpreted vector has the same memory location as + /// `self`. + /// + /// # Examples + /// + /// ```rust + /// # use half::prelude::*; + /// let int_buffer = vec![f16::from_f32(1.).to_bits(), f16::from_f32(2.).to_bits(), f16::from_f32(3.).to_bits()]; + /// let float_buffer = int_buffer.reinterpret_into::(); + /// + /// assert_eq!(float_buffer, [f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.)]); + /// ``` + fn reinterpret_into(self) -> Vec + where + H: crate::private::SealedHalf; +} + +mod private { + use crate::{bf16, f16}; + + pub trait SealedHalfFloatVec {} + impl SealedHalfFloatVec for Vec {} + impl SealedHalfFloatVec for Vec {} + + pub trait SealedHalfBitsVec {} + impl SealedHalfBitsVec for Vec {} +} + +impl HalfFloatVecExt for Vec { + #[inline] + fn reinterpret_into(mut self) -> Vec { + // An f16 array has same length and capacity as u16 array + let length = self.len(); + let capacity = self.capacity(); + + // Actually reinterpret the contents of the Vec as u16, + // knowing that structs are represented as only their members in memory, + // which is the u16 part of `f16(u16)` + let pointer = self.as_mut_ptr() as *mut u16; + + // Prevent running a destructor on the old Vec, so the pointer won't be deleted + mem::forget(self); + + // Finally construct a new Vec from the raw pointer + // SAFETY: We are reconstructing full length and capacity of original vector, + // using its original pointer, and the size of elements are identical. + unsafe { Vec::from_raw_parts(pointer, length, capacity) } + } + + fn from_f32_slice(slice: &[f32]) -> Self { + let mut vec = Vec::with_capacity(slice.len()); + // SAFETY: convert will initialize every value in the vector without reading them, + // so this is safe to do instead of double initialize from resize, and we're setting it to + // same value as capacity. + unsafe { vec.set_len(slice.len()) }; + vec.convert_from_f32_slice(&slice); + vec + } + + fn from_f64_slice(slice: &[f64]) -> Self { + let mut vec = Vec::with_capacity(slice.len()); + // SAFETY: convert will initialize every value in the vector without reading them, + // so this is safe to do instead of double initialize from resize, and we're setting it to + // same value as capacity. + unsafe { vec.set_len(slice.len()) }; + vec.convert_from_f64_slice(&slice); + vec + } +} + +impl HalfFloatVecExt for Vec { + #[inline] + fn reinterpret_into(mut self) -> Vec { + // An f16 array has same length and capacity as u16 array + let length = self.len(); + let capacity = self.capacity(); + + // Actually reinterpret the contents of the Vec as u16, + // knowing that structs are represented as only their members in memory, + // which is the u16 part of `f16(u16)` + let pointer = self.as_mut_ptr() as *mut u16; + + // Prevent running a destructor on the old Vec, so the pointer won't be deleted + mem::forget(self); + + // Finally construct a new Vec from the raw pointer + // SAFETY: We are reconstructing full length and capacity of original vector, + // using its original pointer, and the size of elements are identical. + unsafe { Vec::from_raw_parts(pointer, length, capacity) } + } + + fn from_f32_slice(slice: &[f32]) -> Self { + let mut vec = Vec::with_capacity(slice.len()); + // SAFETY: convert will initialize every value in the vector without reading them, + // so this is safe to do instead of double initialize from resize, and we're setting it to + // same value as capacity. + unsafe { vec.set_len(slice.len()) }; + vec.convert_from_f32_slice(&slice); + vec + } + + fn from_f64_slice(slice: &[f64]) -> Self { + let mut vec = Vec::with_capacity(slice.len()); + // SAFETY: convert will initialize every value in the vector without reading them, + // so this is safe to do instead of double initialize from resize, and we're setting it to + // same value as capacity. + unsafe { vec.set_len(slice.len()) }; + vec.convert_from_f64_slice(&slice); + vec + } +} + +impl HalfBitsVecExt for Vec { + // This is safe because all traits are sealed + #[inline] + fn reinterpret_into(mut self) -> Vec + where + H: crate::private::SealedHalf, + { + // An f16 array has same length and capacity as u16 array + let length = self.len(); + let capacity = self.capacity(); + + // Actually reinterpret the contents of the Vec as f16, + // knowing that structs are represented as only their members in memory, + // which is the u16 part of `f16(u16)` + let pointer = self.as_mut_ptr() as *mut H; + + // Prevent running a destructor on the old Vec, so the pointer won't be deleted + mem::forget(self); + + // Finally construct a new Vec from the raw pointer + // SAFETY: We are reconstructing full length and capacity of original vector, + // using its original pointer, and the size of elements are identical. + unsafe { Vec::from_raw_parts(pointer, length, capacity) } + } +} + +/// Converts a vector of `u16` elements into a vector of [`f16`](../struct.f16.html) elements. +/// +/// This function merely reinterprets the contents of the vector, so it's a zero-copy operation. +#[deprecated( + since = "1.4.0", + note = "use [`HalfBitsVecExt::reinterpret_into`](trait.HalfBitsVecExt.html#tymethod.reinterpret_into) instead" +)] +#[inline] +pub fn from_bits(bits: Vec) -> Vec { + bits.reinterpret_into() +} + +/// Converts a vector of [`f16`](../struct.f16.html) elements into a vector of `u16` elements. +/// +/// This function merely reinterprets the contents of the vector, so it's a zero-copy operation. +#[deprecated( + since = "1.4.0", + note = "use [`HalfFloatVecExt::reinterpret_into`](trait.HalfFloatVecExt.html#tymethod.reinterpret_into) instead" +)] +#[inline] +pub fn to_bits(numbers: Vec) -> Vec { + numbers.reinterpret_into() +} + +#[cfg(test)] +mod test { + use super::{HalfBitsVecExt, HalfFloatVecExt}; + use crate::{bf16, f16}; + + #[test] + fn test_vec_conversions_f16() { + let numbers = vec![f16::E, f16::PI, f16::EPSILON, f16::FRAC_1_SQRT_2]; + let bits = vec![ + f16::E.to_bits(), + f16::PI.to_bits(), + f16::EPSILON.to_bits(), + f16::FRAC_1_SQRT_2.to_bits(), + ]; + let bits_cloned = bits.clone(); + + // Convert from bits to numbers + let from_bits = bits.reinterpret_into::(); + assert_eq!(&from_bits[..], &numbers[..]); + + // Convert from numbers back to bits + let to_bits = from_bits.reinterpret_into(); + assert_eq!(&to_bits[..], &bits_cloned[..]); + } + + #[test] + fn test_vec_conversions_bf16() { + let numbers = vec![bf16::E, bf16::PI, bf16::EPSILON, bf16::FRAC_1_SQRT_2]; + let bits = vec![ + bf16::E.to_bits(), + bf16::PI.to_bits(), + bf16::EPSILON.to_bits(), + bf16::FRAC_1_SQRT_2.to_bits(), + ]; + let bits_cloned = bits.clone(); + + // Convert from bits to numbers + let from_bits = bits.reinterpret_into::(); + assert_eq!(&from_bits[..], &numbers[..]); + + // Convert from numbers back to bits + let to_bits = from_bits.reinterpret_into(); + assert_eq!(&to_bits[..], &bits_cloned[..]); + } +} diff --git a/third_party/cargo/vendor/half-1.4.0/tests/version-numbers.rs b/third_party/cargo/vendor/half-1.4.0/tests/version-numbers.rs new file mode 100644 index 0000000..41a5ea4 --- /dev/null +++ b/third_party/cargo/vendor/half-1.4.0/tests/version-numbers.rs @@ -0,0 +1,9 @@ +#[test] +fn test_readme_deps() { + version_sync::assert_markdown_deps_updated!("README.md"); +} + +#[test] +fn test_html_root_url() { + version_sync::assert_html_root_url_updated!("src/lib.rs"); +} diff --git a/third_party/cargo/vendor/hermit-abi-0.1.6/.cargo-checksum.json b/third_party/cargo/vendor/hermit-abi-0.1.6/.cargo-checksum.json new file mode 100644 index 0000000..3cb0bd8 --- /dev/null +++ b/third_party/cargo/vendor/hermit-abi-0.1.6/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"26ee33ceca1395ce44f45fe667835137340ab18948835ccd4153033a9e0372f4","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"813151bae1178f5f322aa33c46c46199e1e9c23a108bb2f3e4e5a45df3b7ef26","rust-toolchain":"58bea07cb6d97f9cfcd5c8f98b1feca0fb81cce5b0bf29a8e70ed2641956e9a6","src/lib.rs":"01dcc3693682fdba2684932a7dfeab695c88a27aa93dc72b5b68ee127718dcf2"},"package":"eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772"} \ No newline at end of file diff --git a/third_party/cargo/vendor/hermit-abi-0.1.6/BUILD b/third_party/cargo/vendor/hermit-abi-0.1.6/BUILD new file mode 100644 index 0000000..81ea9f3 --- /dev/null +++ b/third_party/cargo/vendor/hermit-abi-0.1.6/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "hermit_abi", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/libc-0.2.66:libc", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.1.6", + crate_features = [ + "default", + ], +) + diff --git a/third_party/cargo/vendor/hermit-abi-0.1.6/Cargo.toml b/third_party/cargo/vendor/hermit-abi-0.1.6/Cargo.toml new file mode 100644 index 0000000..cfcd07e --- /dev/null +++ b/third_party/cargo/vendor/hermit-abi-0.1.6/Cargo.toml @@ -0,0 +1,41 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "hermit-abi" +version = "0.1.6" +authors = ["Stefan Lankes"] +description = "hermit-abi is small interface to call functions from the unikernel RustyHermit.\nIt is used to build the target `x86_64-unknown-hermit`.\n" +readme = "README.md" +keywords = ["unikernel", "libos"] +categories = ["os"] +license = "MIT/Apache-2.0" +repository = "https://github.com/hermitcore/rusty-hermit" +[package.metadata.docs.rs] +features = ["docs"] +[dependencies.compiler_builtins] +version = "0.1.0" +optional = true + +[dependencies.core] +version = "1.0.0" +optional = true +package = "rustc-std-workspace-core" + +[dependencies.libc] +version = "0.2.51" +default-features = false + +[features] +default = [] +docs = [] +rustc-dep-of-std = ["core", "compiler_builtins/rustc-dep-of-std", "libc/rustc-dep-of-std"] diff --git a/third_party/cargo/vendor/hermit-abi-0.1.6/LICENSE-APACHE b/third_party/cargo/vendor/hermit-abi-0.1.6/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/hermit-abi-0.1.6/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/hermit-abi-0.1.6/LICENSE-MIT b/third_party/cargo/vendor/hermit-abi-0.1.6/LICENSE-MIT new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/third_party/cargo/vendor/hermit-abi-0.1.6/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/hermit-abi-0.1.6/README.md b/third_party/cargo/vendor/hermit-abi-0.1.6/README.md new file mode 100644 index 0000000..a2874fe --- /dev/null +++ b/third_party/cargo/vendor/hermit-abi-0.1.6/README.md @@ -0,0 +1,17 @@ +# hermit-abi + +[![Crates.io](https://img.shields.io/crates/v/hermit-abi.svg)](https://crates.io/crates/hermit-abi) +[![License](https://img.shields.io/crates/l/hermit-abi.svg)](https://img.shields.io/crates/l/hermit-abi.svg) + +This is small interface to call functions from the unikernel [RustyHermit](https://github.com/hermitcore/libhermit-rs). + +Please read the README of [RustyHermit](https://github.com/hermitcore/libhermit-rs) for more information. + +## License + +Licensed under either of + +* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. diff --git a/third_party/cargo/vendor/hermit-abi-0.1.6/rust-toolchain b/third_party/cargo/vendor/hermit-abi-0.1.6/rust-toolchain new file mode 100644 index 0000000..bf867e0 --- /dev/null +++ b/third_party/cargo/vendor/hermit-abi-0.1.6/rust-toolchain @@ -0,0 +1 @@ +nightly diff --git a/third_party/cargo/vendor/hermit-abi-0.1.6/src/lib.rs b/third_party/cargo/vendor/hermit-abi-0.1.6/src/lib.rs new file mode 100644 index 0000000..0faa874 --- /dev/null +++ b/third_party/cargo/vendor/hermit-abi-0.1.6/src/lib.rs @@ -0,0 +1,226 @@ +#![feature(const_raw_ptr_to_usize_cast)] +#![cfg_attr(feature = "rustc-dep-of-std", no_std)] +extern crate libc; + +use libc::c_void; + +extern "C" { + fn _start(); + fn sys_get_processor_count() -> usize; + fn sys_malloc(size: usize, align: usize) -> *mut u8; + fn sys_realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8; + fn sys_free(ptr: *mut u8, size: usize, align: usize); + fn sys_notify(id: usize, count: i32) -> i32; + fn sys_add_queue(id: usize, timeout_ns: i64) -> i32; + fn sys_wait(id: usize) -> i32; + fn sys_destroy_queue(id: usize) -> i32; + fn sys_read(fd: i32, buf: *mut u8, len: usize) -> isize; + fn sys_write(fd: i32, buf: *const u8, len: usize) -> isize; + fn sys_close(fd: i32) -> i32; + fn sys_sem_init(sem: *mut *const c_void, value: u32) -> i32; + fn sys_sem_destroy(sem: *const c_void) -> i32; + fn sys_sem_post(sem: *const c_void) -> i32; + fn sys_sem_trywait(sem: *const c_void) -> i32; + fn sys_sem_timedwait(sem: *const c_void, ms: u32) -> i32; + fn sys_recmutex_init(recmutex: *mut *const c_void) -> i32; + fn sys_recmutex_destroy(recmutex: *const c_void) -> i32; + fn sys_recmutex_lock(recmutex: *const c_void) -> i32; + fn sys_recmutex_unlock(recmutex: *const c_void) -> i32; + fn sys_getpid() -> u32; + fn sys_exit(arg: i32) -> !; + fn sys_abort() -> !; + fn sys_usleep(usecs: u64); + fn sys_spawn( + id: *mut Tid, + func: extern "C" fn(usize), + arg: usize, + prio: u8, + core_id: isize, + ) -> i32; + fn sys_join(id: Tid) -> i32; + fn sys_yield(); + fn sys_clock_gettime(clock_id: u64, tp: *mut timespec) -> i32; + fn sys_open(name: *const i8, flags: i32, mode: i32) -> i32; + fn sys_unlink(name: *const i8) -> i32; +} + +pub type Tid = u32; + +pub const NSEC_PER_SEC: u64 = 1_000_000_000; +pub const CLOCK_REALTIME: u64 = 1; +pub const CLOCK_MONOTONIC: u64 = 4; +pub const STDIN_FILENO: libc::c_int = 0; +pub const STDOUT_FILENO: libc::c_int = 1; +pub const STDERR_FILENO: libc::c_int = 2; + +/// returns true if this is a tty +pub fn isatty(_fd: libc::c_int) -> bool { + false +} + +#[derive(Copy, Clone, Debug)] +#[repr(C)] +pub struct timespec { + pub tv_sec: i64, + pub tv_nsec: i64, +} + +pub unsafe fn call_start() { + _start(); +} + +#[inline(always)] +pub unsafe fn get_processor_count() -> usize { + sys_get_processor_count() +} + +#[inline(always)] +pub unsafe fn malloc(size: usize, align: usize) -> *mut u8 { + sys_malloc(size, align) +} + +#[inline(always)] +pub unsafe fn realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8 { + sys_realloc(ptr, size, align, new_size) +} + +#[inline(always)] +pub unsafe fn free(ptr: *mut u8, size: usize, align: usize) { + sys_free(ptr, size, align) +} + +#[inline(always)] +pub unsafe fn notify(id: usize, count: i32) -> i32 { + sys_notify(id, count) +} + +#[inline(always)] +pub unsafe fn add_queue(id: usize, timeout_ns: i64) -> i32 { + sys_add_queue(id, timeout_ns) +} + +#[inline(always)] +pub unsafe fn wait(id: usize) -> i32 { + sys_wait(id) +} + +#[inline(always)] +pub unsafe fn destroy_queue(id: usize) -> i32 { + sys_destroy_queue(id) +} + +#[inline(always)] +pub unsafe fn read(fd: i32, buf: *mut u8, len: usize) -> isize { + sys_read(fd, buf, len) +} + +#[inline(always)] +pub unsafe fn write(fd: i32, buf: *const u8, len: usize) -> isize { + sys_write(fd, buf, len) +} + +#[inline(always)] +pub unsafe fn close(fd: i32) -> i32 { + sys_close(fd) +} + +#[inline(always)] +pub unsafe fn sem_init(sem: *mut *const c_void, value: u32) -> i32 { + sys_sem_init(sem, value) +} + +#[inline(always)] +pub unsafe fn sem_destroy(sem: *const c_void) -> i32 { + sys_sem_destroy(sem) +} + +#[inline(always)] +pub unsafe fn sem_post(sem: *const c_void) -> i32 { + sys_sem_post(sem) +} + +#[inline(always)] +pub unsafe fn sem_trywait(sem: *const c_void) -> i32 { + sys_sem_trywait(sem) +} + +#[inline(always)] +pub unsafe fn sem_timedwait(sem: *const c_void, ms: u32) -> i32 { + sys_sem_timedwait(sem, ms) +} + +#[inline(always)] +pub unsafe fn recmutex_init(recmutex: *mut *const c_void) -> i32 { + sys_recmutex_init(recmutex) +} + +#[inline(always)] +pub unsafe fn recmutex_destroy(recmutex: *const c_void) -> i32 { + sys_recmutex_destroy(recmutex) +} + +#[inline(always)] +pub unsafe fn recmutex_lock(recmutex: *const c_void) -> i32 { + sys_recmutex_lock(recmutex) +} + +#[inline(always)] +pub unsafe fn recmutex_unlock(recmutex: *const c_void) -> i32 { + sys_recmutex_unlock(recmutex) +} + +#[inline(always)] +pub unsafe fn getpid() -> u32 { + sys_getpid() +} + +#[inline(always)] +pub unsafe fn exit(arg: i32) -> ! { + sys_exit(arg) +} + +#[inline(always)] +pub unsafe fn abort() -> ! { + sys_abort() +} + +#[inline(always)] +pub unsafe fn usleep(usecs: u64) { + sys_usleep(usecs) +} + +#[inline(always)] +pub unsafe fn spawn( + id: *mut Tid, + func: extern "C" fn(usize), + arg: usize, + prio: u8, + core_id: isize, +) -> i32 { + sys_spawn(id, func, arg, prio, core_id) +} + +#[inline(always)] +pub unsafe fn join(id: Tid) -> i32 { + sys_join(id) +} + +#[inline(always)] +pub unsafe fn yield_now() { + sys_yield() +} + +#[inline(always)] +pub unsafe fn clock_gettime(clock_id: u64, tp: *mut timespec) -> i32 { + sys_clock_gettime(clock_id, tp) +} + +#[inline(always)] +pub unsafe fn open(name: *const i8, flags: i32, mode: i32) -> i32 { + sys_open(name, flags, mode) +} + +#[inline(always)] +pub unsafe fn unlink(name: *const i8) -> i32 { + sys_unlink(name) +} diff --git a/third_party/cargo/vendor/humantime-1.3.0/.cargo-checksum.json b/third_party/cargo/vendor/humantime-1.3.0/.cargo-checksum.json new file mode 100644 index 0000000..2ffd8f0 --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"ae7f884d13f5d849afd58b5db15510396832df7f648b0095e43bfdfa600b2ba3","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"f6deca8261a8f4a3403dc74c725c46051157fd36c27cd4b100277eb1f303ad11","README.md":"e4bb65f28ddffb11d7eb337e9585947651f2fc11a5e4290f0ca126e21c582c1e","benches/datetime_format.rs":"a44c7ffb3c9515e92828564df8f91a86470343a2fa7e1a08bc2bc7397ba2591c","benches/datetime_parse.rs":"336a241755ccfa546d1840e56a40218c4f98f22d7d274829c5102ec280f2d963","bulk.yaml":"17c2548388e0cd3a63473021a2f1e4ddedee082d79d9167cb31ad06a1890d3fc","src/date.rs":"ea9924869a2484e333df2a845009593dd0062bb3b3e1a5ef9cefc05ec0a41196","src/duration.rs":"a5d4756451f495a3d5df0c872caa6304dd81ae075f0e204c8145c11c7c8f698b","src/lib.rs":"59dcc8a1ed89ecde199d59a7f71e550b461f87858b4becffb0a183994bafdd7c","src/wrapper.rs":"5bbdaf43256b445a8ca3a6b3eded9dd4fa8fb4dadf3683a5bac9648d91117396","vagga.yaml":"59761e5138a3015ef5654fec095ac8f1587cd23529b37822dd540b866fe4cd5b"},"package":"df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"} \ No newline at end of file diff --git a/third_party/cargo/vendor/humantime-1.3.0/BUILD b/third_party/cargo/vendor/humantime-1.3.0/BUILD new file mode 100644 index 0000000..984762b --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/BUILD @@ -0,0 +1,45 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "datetime_format" with type "bench" omitted +# Unsupported target "datetime_parse" with type "bench" omitted + +rust_library( + name = "humantime", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + "//third_party/cargo/vendor/quick-error-1.2.3:quick_error", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.3.0", + crate_features = [ + ], +) + diff --git a/third_party/cargo/vendor/humantime-1.3.0/Cargo.toml b/third_party/cargo/vendor/humantime-1.3.0/Cargo.toml new file mode 100644 index 0000000..53bdcfd --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/Cargo.toml @@ -0,0 +1,37 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "humantime" +version = "1.3.0" +authors = ["Paul Colomiets "] +description = " A parser and formatter for std::time::{Duration, SystemTime}\n" +homepage = "https://github.com/tailhook/humantime" +documentation = "https://docs.rs/humantime" +readme = "README.md" +keywords = ["time", "human", "human-friendly", "parser", "duration"] +categories = ["date-and-time"] +license = "MIT/Apache-2.0" + +[lib] +name = "humantime" +path = "src/lib.rs" +[dependencies.quick-error] +version = "1.0.0" +[dev-dependencies.chrono] +version = "0.4.0" + +[dev-dependencies.rand] +version = "0.4.2" + +[dev-dependencies.time] +version = "0.1.39" diff --git a/third_party/cargo/vendor/humantime-1.3.0/LICENSE-APACHE b/third_party/cargo/vendor/humantime-1.3.0/LICENSE-APACHE new file mode 100644 index 0000000..8f71f43 --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/LICENSE-APACHE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/third_party/cargo/vendor/humantime-1.3.0/LICENSE-MIT b/third_party/cargo/vendor/humantime-1.3.0/LICENSE-MIT new file mode 100644 index 0000000..a099fba --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright (c) 2016 The humantime Developers + +Includes parts of http date with the following copyright: +Copyright (c) 2016 Pyfisch + +Includes portions of musl libc with the following copyright: +Copyright © 2005-2013 Rich Felker + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cargo/vendor/humantime-1.3.0/README.md b/third_party/cargo/vendor/humantime-1.3.0/README.md new file mode 100644 index 0000000..39156dc --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/README.md @@ -0,0 +1,68 @@ +Human Time +========== + +**Status: stable** + +[Documentation](https://docs.rs/humantime) | +[Github](https://github.com/tailhook/humantime) | +[Crate](https://crates.io/crates/humantime) + + +Features: + +* Parses durations in free form like `15days 2min 2s` +* Formats durations in similar form `2years 2min 12us` +* Parses and formats timestamp in `rfc3339` format: `2018-01-01T12:53:00Z` +* Parses timestamps in a weaker format: `2018-01-01 12:53:00` + +Timestamp parsing/formatting is super-fast because format is basically +fixed. + +Here are some micro-benchmarks: + +``` +test result: ok. 0 passed; 0 failed; 26 ignored; 0 measured; 0 filtered out + + Running target/release/deps/datetime_format-8facb4ac832d9770 + +running 2 tests +test rfc3339_chrono ... bench: 737 ns/iter (+/- 37) +test rfc3339_humantime_seconds ... bench: 73 ns/iter (+/- 2) + +test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured; 0 filtered out + + Running target/release/deps/datetime_parse-342628f877d7867c + +running 6 tests +test datetime_utc_parse_millis ... bench: 228 ns/iter (+/- 11) +test datetime_utc_parse_nanos ... bench: 236 ns/iter (+/- 10) +test datetime_utc_parse_seconds ... bench: 204 ns/iter (+/- 18) +test rfc3339_humantime_millis ... bench: 28 ns/iter (+/- 1) +test rfc3339_humantime_nanos ... bench: 36 ns/iter (+/- 2) +test rfc3339_humantime_seconds ... bench: 24 ns/iter (+/- 1) + +test result: ok. 0 passed; 0 failed; 0 ignored; 6 measured; 0 filtered out +``` + +See [humantime-serde] for serde integration (previous crate [serde-humantime] looks unmaintained). + +[serde-humantime]: https://docs.rs/serde-humantime/0.1.1/serde_humantime/ +[humantime-serde]: https://docs.rs/humantime-serde + +License +======= + +Licensed under either of + +* Apache License, Version 2.0, (./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) +* MIT license (./LICENSE-MIT or http://opensource.org/licenses/MIT) + +at your option. + +Contribution +------------ + +Unless you explicitly state otherwise, any contribution intentionally +submitted for inclusion in the work by you, as defined in the Apache-2.0 +license, shall be dual licensed as above, without any additional terms or +conditions. diff --git a/third_party/cargo/vendor/humantime-1.3.0/benches/datetime_format.rs b/third_party/cargo/vendor/humantime-1.3.0/benches/datetime_format.rs new file mode 100644 index 0000000..7f6dca7 --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/benches/datetime_format.rs @@ -0,0 +1,58 @@ +#![feature(test)] +extern crate chrono; +extern crate humantime; +extern crate test; + +use std::io::Write; +use std::time::{Duration, UNIX_EPOCH}; +use humantime::format_rfc3339; + + +#[bench] +fn rfc3339_humantime_seconds(b: &mut test::Bencher) { + let time = UNIX_EPOCH + Duration::new(1483228799, 0); + let mut buf = Vec::with_capacity(100); + b.iter(|| { + buf.truncate(0); + write!(&mut buf, "{}", format_rfc3339(time)).unwrap() + }); +} + +#[bench] +fn rfc3339_chrono(b: &mut test::Bencher) { + use chrono::{DateTime, NaiveDateTime, Utc}; + use chrono::format::Item; + use chrono::format::Item::*; + use chrono::format::Numeric::*; + use chrono::format::Fixed::*; + use chrono::format::Pad::*; + + let time = DateTime::::from_utc( + NaiveDateTime::from_timestamp(1483228799, 0), Utc); + let mut buf = Vec::with_capacity(100); + + // formatting code from env_logger + const ITEMS: &'static [Item<'static>] = { + &[ + Numeric(Year, Zero), + Literal("-"), + Numeric(Month, Zero), + Literal("-"), + Numeric(Day, Zero), + Literal("T"), + Numeric(Hour, Zero), + Literal(":"), + Numeric(Minute, Zero), + Literal(":"), + Numeric(Second, Zero), + Fixed(TimezoneOffsetZ), + ] + }; + + + b.iter(|| { + buf.truncate(0); + write!(&mut buf, "{}", time.format_with_items(ITEMS.iter().cloned())) + .unwrap() + }); +} diff --git a/third_party/cargo/vendor/humantime-1.3.0/benches/datetime_parse.rs b/third_party/cargo/vendor/humantime-1.3.0/benches/datetime_parse.rs new file mode 100644 index 0000000..785d713 --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/benches/datetime_parse.rs @@ -0,0 +1,50 @@ +#![feature(test)] +extern crate chrono; +extern crate humantime; +extern crate test; + +use chrono::{DateTime}; +use humantime::parse_rfc3339; + + +#[bench] +fn rfc3339_humantime_seconds(b: &mut test::Bencher) { + b.iter(|| { + parse_rfc3339("2018-02-13T23:08:32Z").unwrap() + }); +} + +#[bench] +fn datetime_utc_parse_seconds(b: &mut test::Bencher) { + b.iter(|| { + DateTime::parse_from_rfc3339("2018-02-13T23:08:32Z").unwrap() + }); +} + +#[bench] +fn rfc3339_humantime_millis(b: &mut test::Bencher) { + b.iter(|| { + parse_rfc3339("2018-02-13T23:08:32.123Z").unwrap() + }); +} + +#[bench] +fn datetime_utc_parse_millis(b: &mut test::Bencher) { + b.iter(|| { + DateTime::parse_from_rfc3339("2018-02-13T23:08:32.123Z").unwrap() + }); +} + +#[bench] +fn rfc3339_humantime_nanos(b: &mut test::Bencher) { + b.iter(|| { + parse_rfc3339("2018-02-13T23:08:32.123456983Z").unwrap() + }); +} + +#[bench] +fn datetime_utc_parse_nanos(b: &mut test::Bencher) { + b.iter(|| { + DateTime::parse_from_rfc3339("2018-02-13T23:08:32.123456983Z").unwrap() + }); +} diff --git a/third_party/cargo/vendor/humantime-1.3.0/bulk.yaml b/third_party/cargo/vendor/humantime-1.3.0/bulk.yaml new file mode 100644 index 0000000..cdb9763 --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/bulk.yaml @@ -0,0 +1,8 @@ +minimum-bulk: v0.4.5 + +versions: + +- file: Cargo.toml + block-start: ^\[package\] + block-end: ^\[.*\] + regex: ^version\s*=\s*"(\S+)" diff --git a/third_party/cargo/vendor/humantime-1.3.0/src/date.rs b/third_party/cargo/vendor/humantime-1.3.0/src/date.rs new file mode 100644 index 0000000..d5bc82c --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/src/date.rs @@ -0,0 +1,614 @@ +use std::fmt; +use std::str; +use std::time::{SystemTime, Duration, UNIX_EPOCH}; + +#[cfg(target_os="cloudabi")] +mod max { + pub const SECONDS: u64 = ::std::u64::MAX / 1_000_000_000; + #[allow(unused)] + pub const TIMESTAMP: &'static str = "2554-07-21T23:34:33Z"; +} +#[cfg(all( + target_pointer_width="32", + not(target_os="cloudabi"), + not(target_os="windows"), + not(all(target_arch="wasm32", not(target_os="emscripten"))) +))] +mod max { + pub const SECONDS: u64 = ::std::i32::MAX as u64; + #[allow(unused)] + pub const TIMESTAMP: &'static str = "2038-01-19T03:14:07Z"; +} + +#[cfg(any( + target_pointer_width="64", + target_os="windows", + all(target_arch="wasm32", not(target_os="emscripten")), +))] +mod max { + pub const SECONDS: u64 = 253402300800-1; // last second of year 9999 + #[allow(unused)] + pub const TIMESTAMP: &'static str = "9999-12-31T23:59:59Z"; +} + +quick_error! { + /// Error parsing datetime (timestamp) + #[derive(Debug, PartialEq, Clone, Copy)] + pub enum Error { + /// Numeric component is out of range + OutOfRange { + display("numeric component is out of range") + } + /// Bad character where digit is expected + InvalidDigit { + display("bad character where digit is expected") + } + /// Other formatting errors + InvalidFormat { + display("timestamp format is invalid") + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq)] +enum Precision { + Smart, + Seconds, + Millis, + Micros, + Nanos, +} + +/// A wrapper type that allows you to Display a SystemTime +#[derive(Debug, Clone)] +pub struct Rfc3339Timestamp(SystemTime, Precision); + +#[inline] +fn two_digits(b1: u8, b2: u8) -> Result { + if b1 < b'0' || b2 < b'0' || b1 > b'9' || b2 > b'9' { + return Err(Error::InvalidDigit); + } + Ok(((b1 - b'0')*10 + (b2 - b'0')) as u64) +} + +/// Parse RFC3339 timestamp `2018-02-14T00:28:07Z` +/// +/// Supported feature: any precision of fractional +/// digits `2018-02-14T00:28:07.133Z`. +/// +/// Unsupported feature: localized timestamps. Only UTC is supported. +pub fn parse_rfc3339(s: &str) -> Result { + if s.len() < "2018-02-14T00:28:07Z".len() { + return Err(Error::InvalidFormat); + } + let b = s.as_bytes(); + if b[10] != b'T' || b[b.len()-1] != b'Z' { + return Err(Error::InvalidFormat); + } + return parse_rfc3339_weak(s); +} + +/// Parse RFC3339-like timestamp `2018-02-14 00:28:07` +/// +/// Supported features: +/// +/// 1. Any precision of fractional digits `2018-02-14 00:28:07.133`. +/// 2. Supports timestamp with or without either of `T` or `Z` +/// 3. Anything valid for `parse_3339` is valid for this function +/// +/// Unsupported feature: localized timestamps. Only UTC is supported, even if +/// `Z` is not specified. +/// +/// This function is intended to use for parsing human input. Whereas +/// `parse_rfc3339` is for strings generated programmatically. +pub fn parse_rfc3339_weak(s: &str) -> Result { + if s.len() < "2018-02-14T00:28:07".len() { + return Err(Error::InvalidFormat); + } + let b = s.as_bytes(); // for careless slicing + if b[4] != b'-' || b[7] != b'-' || (b[10] != b'T' && b[10] != b' ') || + b[13] != b':' || b[16] != b':' + { + return Err(Error::InvalidFormat); + } + let year = two_digits(b[0], b[1])? * 100 + two_digits(b[2], b[3])?; + let month = two_digits(b[5], b[6])?; + let day = two_digits(b[8], b[9])?; + let hour = two_digits(b[11], b[12])?; + let minute = two_digits(b[14], b[15])?; + let mut second = two_digits(b[17], b[18])?; + + if year < 1970 || hour > 23 || minute > 59 || second > 60 { + return Err(Error::OutOfRange); + } + // TODO(tailhook) should we check that leaps second is only on midnight ? + if second == 60 { + second = 59 + }; + let leap_years = ((year - 1) - 1968) / 4 - ((year - 1) - 1900) / 100 + + ((year - 1) - 1600) / 400; + let leap = is_leap_year(year); + let (mut ydays, mdays) = match month { + 1 => (0, 31), + 2 if leap => (31, 29), + 2 => (31, 28), + 3 => (59, 31), + 4 => (90, 30), + 5 => (120, 31), + 6 => (151, 30), + 7 => (181, 31), + 8 => (212, 31), + 9 => (243, 30), + 10 => (273, 31), + 11 => (304, 30), + 12 => (334, 31), + _ => return Err(Error::OutOfRange), + }; + if day > mdays || day == 0 { + return Err(Error::OutOfRange); + } + ydays += day - 1; + if leap && month > 2 { + ydays += 1; + } + let days = (year - 1970) * 365 + leap_years + ydays; + + let time = second + minute * 60 + hour * 3600; + + let mut nanos = 0; + let mut mult = 100_000_000; + if b.get(19) == Some(&b'.') { + for idx in 20..b.len() { + if b[idx] == b'Z' { + if idx == b.len()-1 { + break; + } else { + return Err(Error::InvalidDigit); + } + } + if b[idx] < b'0' || b[idx] > b'9' { + return Err(Error::InvalidDigit); + } + nanos += mult * (b[idx] - b'0') as u32; + mult /= 10; + } + } else { + if b.len() != 19 && (b.len() > 20 || b[19] != b'Z') { + return Err(Error::InvalidFormat); + } + } + + let total_seconds = time + days * 86400; + if total_seconds > max::SECONDS { + return Err(Error::OutOfRange); + } + + return Ok(UNIX_EPOCH + Duration::new(total_seconds, nanos)); +} + +fn is_leap_year(y: u64) -> bool { + y % 4 == 0 && (!(y % 100 == 0) || y % 400 == 0) +} + +/// Format an RFC3339 timestamp `2018-02-14T00:28:07Z` +/// +/// This function formats timestamp with smart precision: i.e. if it has no +/// fractional seconds, they aren't written at all. And up to nine digits if +/// they are. +/// +/// The value is always UTC and ignores system timezone. +pub fn format_rfc3339(system_time: SystemTime) -> Rfc3339Timestamp { + return Rfc3339Timestamp(system_time, Precision::Smart); +} + +/// Format an RFC3339 timestamp `2018-02-14T00:28:07Z` +/// +/// This format always shows timestamp without fractional seconds. +/// +/// The value is always UTC and ignores system timezone. +pub fn format_rfc3339_seconds(system_time: SystemTime) -> Rfc3339Timestamp { + return Rfc3339Timestamp(system_time, Precision::Seconds); +} + +/// Format an RFC3339 timestamp `2018-02-14T00:28:07.000Z` +/// +/// This format always shows milliseconds even if millisecond value is zero. +/// +/// The value is always UTC and ignores system timezone. +pub fn format_rfc3339_millis(system_time: SystemTime) -> Rfc3339Timestamp { + return Rfc3339Timestamp(system_time, Precision::Millis); +} + +/// Format an RFC3339 timestamp `2018-02-14T00:28:07.000000Z` +/// +/// This format always shows microseconds even if microsecond value is zero. +/// +/// The value is always UTC and ignores system timezone. +pub fn format_rfc3339_micros(system_time: SystemTime) -> Rfc3339Timestamp { + return Rfc3339Timestamp(system_time, Precision::Micros); +} + +/// Format an RFC3339 timestamp `2018-02-14T00:28:07.000000000Z` +/// +/// This format always shows nanoseconds even if nanosecond value is zero. +/// +/// The value is always UTC and ignores system timezone. +pub fn format_rfc3339_nanos(system_time: SystemTime) -> Rfc3339Timestamp { + return Rfc3339Timestamp(system_time, Precision::Nanos); +} + +impl fmt::Display for Rfc3339Timestamp { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use self::Precision::*; + + let dur = self.0.duration_since(UNIX_EPOCH) + .expect("all times should be after the epoch"); + let secs_since_epoch = dur.as_secs(); + let nanos = dur.subsec_nanos(); + + if secs_since_epoch >= 253402300800 { // year 9999 + return Err(fmt::Error); + } + + /* 2000-03-01 (mod 400 year, immediately after feb29 */ + const LEAPOCH: i64 = 11017; + const DAYS_PER_400Y: i64 = 365*400 + 97; + const DAYS_PER_100Y: i64 = 365*100 + 24; + const DAYS_PER_4Y: i64 = 365*4 + 1; + + let days = (secs_since_epoch / 86400) as i64 - LEAPOCH; + let secs_of_day = secs_since_epoch % 86400; + + let mut qc_cycles = days / DAYS_PER_400Y; + let mut remdays = days % DAYS_PER_400Y; + + if remdays < 0 { + remdays += DAYS_PER_400Y; + qc_cycles -= 1; + } + + let mut c_cycles = remdays / DAYS_PER_100Y; + if c_cycles == 4 { c_cycles -= 1; } + remdays -= c_cycles * DAYS_PER_100Y; + + let mut q_cycles = remdays / DAYS_PER_4Y; + if q_cycles == 25 { q_cycles -= 1; } + remdays -= q_cycles * DAYS_PER_4Y; + + let mut remyears = remdays / 365; + if remyears == 4 { remyears -= 1; } + remdays -= remyears * 365; + + let mut year = 2000 + + remyears + 4*q_cycles + 100*c_cycles + 400*qc_cycles; + + let months = [31,30,31,30,31,31,30,31,30,31,31,29]; + let mut mon = 0; + for mon_len in months.iter() { + mon += 1; + if remdays < *mon_len { + break; + } + remdays -= *mon_len; + } + let mday = remdays+1; + let mon = if mon + 2 > 12 { + year += 1; + mon - 10 + } else { + mon + 2 + }; + + let mut buf: [u8; 30] = [ + // Too long to write as: b"0000-00-00T00:00:00.000000000Z" + b'0', b'0', b'0', b'0', b'-', b'0', b'0', b'-', b'0', b'0', b'T', + b'0', b'0', b':', b'0', b'0', b':', b'0', b'0', + b'.', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'Z', + ]; + buf[0] = b'0' + (year / 1000) as u8; + buf[1] = b'0' + (year / 100 % 10) as u8; + buf[2] = b'0' + (year / 10 % 10) as u8; + buf[3] = b'0' + (year % 10) as u8; + buf[5] = b'0' + (mon / 10) as u8; + buf[6] = b'0' + (mon % 10) as u8; + buf[8] = b'0' + (mday / 10) as u8; + buf[9] = b'0' + (mday % 10) as u8; + buf[11] = b'0' + (secs_of_day / 3600 / 10) as u8; + buf[12] = b'0' + (secs_of_day / 3600 % 10) as u8; + buf[14] = b'0' + (secs_of_day / 60 / 10 % 6) as u8; + buf[15] = b'0' + (secs_of_day / 60 % 10) as u8; + buf[17] = b'0' + (secs_of_day / 10 % 6) as u8; + buf[18] = b'0' + (secs_of_day % 10) as u8; + + let offset = if self.1 == Seconds || nanos == 0 && self.1 == Smart { + buf[19] = b'Z'; + 19 + } else if self.1 == Millis { + buf[20] = b'0' + (nanos / 100_000_000) as u8; + buf[21] = b'0' + (nanos / 10_000_000 % 10) as u8; + buf[22] = b'0' + (nanos / 1_000_000 % 10) as u8; + buf[23] = b'Z'; + 23 + } else if self.1 == Micros { + buf[20] = b'0' + (nanos / 100_000_000) as u8; + buf[21] = b'0' + (nanos / 10_000_000 % 10) as u8; + buf[22] = b'0' + (nanos / 1_000_000 % 10) as u8; + buf[23] = b'0' + (nanos / 100_000 % 10) as u8; + buf[24] = b'0' + (nanos / 10_000 % 10) as u8; + buf[25] = b'0' + (nanos / 1_000 % 10) as u8; + buf[26] = b'Z'; + 26 + } else { + buf[20] = b'0' + (nanos / 100_000_000) as u8; + buf[21] = b'0' + (nanos / 10_000_000 % 10) as u8; + buf[22] = b'0' + (nanos / 1_000_000 % 10) as u8; + buf[23] = b'0' + (nanos / 100_000 % 10) as u8; + buf[24] = b'0' + (nanos / 10_000 % 10) as u8; + buf[25] = b'0' + (nanos / 1_000 % 10) as u8; + buf[26] = b'0' + (nanos / 100 % 10) as u8; + buf[27] = b'0' + (nanos / 10 % 10) as u8; + buf[28] = b'0' + (nanos / 1 % 10) as u8; + // 29th is 'Z' + 29 + }; + + // we know our chars are all ascii + f.write_str(unsafe { str::from_utf8_unchecked(&buf[..offset+1]) }) + } +} + +#[cfg(test)] +mod test { + extern crate time; + extern crate rand; + + use std::str::from_utf8; + use self::rand::Rng; + use std::time::{UNIX_EPOCH, SystemTime, Duration}; + use super::{parse_rfc3339, parse_rfc3339_weak, format_rfc3339}; + use super::{format_rfc3339_millis, format_rfc3339_micros}; + use super::{format_rfc3339_nanos}; + use super::max; + + fn from_sec(sec: u64) -> (String, SystemTime) { + let s = time::at_utc(time::Timespec { sec: sec as i64, nsec: 0 }) + .rfc3339().to_string(); + let time = UNIX_EPOCH + Duration::new(sec, 0); + return (s, time) + } + + #[test] + #[cfg(all(target_pointer_width="32", target_os="linux"))] + fn year_after_2038_fails_gracefully() { + // next second + assert_eq!(parse_rfc3339("2038-01-19T03:14:08Z").unwrap_err(), + super::Error::OutOfRange); + assert_eq!(parse_rfc3339("9999-12-31T23:59:59Z").unwrap_err(), + super::Error::OutOfRange); + } + + #[test] + fn smoke_tests_parse() { + assert_eq!(parse_rfc3339("1970-01-01T00:00:00Z").unwrap(), + UNIX_EPOCH + Duration::new(0, 0)); + assert_eq!(parse_rfc3339("1970-01-01T00:00:01Z").unwrap(), + UNIX_EPOCH + Duration::new(1, 0)); + assert_eq!(parse_rfc3339("2018-02-13T23:08:32Z").unwrap(), + UNIX_EPOCH + Duration::new(1518563312, 0)); + assert_eq!(parse_rfc3339("2012-01-01T00:00:00Z").unwrap(), + UNIX_EPOCH + Duration::new(1325376000, 0)); + } + + #[test] + fn smoke_tests_format() { + assert_eq!( + format_rfc3339(UNIX_EPOCH + Duration::new(0, 0)).to_string(), + "1970-01-01T00:00:00Z"); + assert_eq!( + format_rfc3339(UNIX_EPOCH + Duration::new(1, 0)).to_string(), + "1970-01-01T00:00:01Z"); + assert_eq!( + format_rfc3339(UNIX_EPOCH + Duration::new(1518563312, 0)).to_string(), + "2018-02-13T23:08:32Z"); + assert_eq!( + format_rfc3339(UNIX_EPOCH + Duration::new(1325376000, 0)).to_string(), + "2012-01-01T00:00:00Z"); + } + + #[test] + fn smoke_tests_format_millis() { + assert_eq!( + format_rfc3339_millis(UNIX_EPOCH + + Duration::new(0, 0)).to_string(), + "1970-01-01T00:00:00.000Z"); + assert_eq!( + format_rfc3339_millis(UNIX_EPOCH + + Duration::new(1518563312, 123_000_000)).to_string(), + "2018-02-13T23:08:32.123Z"); + } + + #[test] + fn smoke_tests_format_micros() { + assert_eq!( + format_rfc3339_micros(UNIX_EPOCH + + Duration::new(0, 0)).to_string(), + "1970-01-01T00:00:00.000000Z"); + assert_eq!( + format_rfc3339_micros(UNIX_EPOCH + + Duration::new(1518563312, 123_000_000)).to_string(), + "2018-02-13T23:08:32.123000Z"); + assert_eq!( + format_rfc3339_micros(UNIX_EPOCH + + Duration::new(1518563312, 456_123_000)).to_string(), + "2018-02-13T23:08:32.456123Z"); + } + + #[test] + fn smoke_tests_format_nanos() { + assert_eq!( + format_rfc3339_nanos(UNIX_EPOCH + + Duration::new(0, 0)).to_string(), + "1970-01-01T00:00:00.000000000Z"); + assert_eq!( + format_rfc3339_nanos(UNIX_EPOCH + + Duration::new(1518563312, 123_000_000)).to_string(), + "2018-02-13T23:08:32.123000000Z"); + assert_eq!( + format_rfc3339_nanos(UNIX_EPOCH + + Duration::new(1518563312, 789_456_123)).to_string(), + "2018-02-13T23:08:32.789456123Z"); + } + + #[test] + fn upper_bound() { + let max = UNIX_EPOCH + Duration::new(max::SECONDS, 0); + assert_eq!(parse_rfc3339(&max::TIMESTAMP).unwrap(), max); + assert_eq!(format_rfc3339(max).to_string(), max::TIMESTAMP); + } + + #[test] + fn leap_second() { + assert_eq!(parse_rfc3339("2016-12-31T23:59:60Z").unwrap(), + UNIX_EPOCH + Duration::new(1483228799, 0)); + } + + #[test] + fn first_731_days() { + let year_start = 0; // 1970 + for day in 0.. (365 * 2 + 1) { // scan leap year and non-leap year + let (s, time) = from_sec(year_start + day * 86400); + assert_eq!(parse_rfc3339(&s).unwrap(), time); + assert_eq!(format_rfc3339(time).to_string(), s); + } + } + + #[test] + fn the_731_consecutive_days() { + let year_start = 1325376000; // 2012 + for day in 0.. (365 * 2 + 1) { // scan leap year and non-leap year + let (s, time) = from_sec(year_start + day * 86400); + assert_eq!(parse_rfc3339(&s).unwrap(), time); + assert_eq!(format_rfc3339(time).to_string(), s); + } + } + + #[test] + fn all_86400_seconds() { + let day_start = 1325376000; + for second in 0..86400 { // scan leap year and non-leap year + let (s, time) = from_sec(day_start + second); + assert_eq!(parse_rfc3339(&s).unwrap(), time); + assert_eq!(format_rfc3339(time).to_string(), s); + } + } + + #[test] + fn random_past() { + let upper = SystemTime::now().duration_since(UNIX_EPOCH).unwrap() + .as_secs(); + for _ in 0..10000 { + let sec = rand::thread_rng().gen_range(0, upper); + let (s, time) = from_sec(sec); + assert_eq!(parse_rfc3339(&s).unwrap(), time); + assert_eq!(format_rfc3339(time).to_string(), s); + } + } + + #[test] + fn random_wide_range() { + for _ in 0..100000 { + let sec = rand::thread_rng().gen_range(0, max::SECONDS); + let (s, time) = from_sec(sec); + assert_eq!(parse_rfc3339(&s).unwrap(), time); + assert_eq!(format_rfc3339(time).to_string(), s); + } + } + + #[test] + fn milliseconds() { + assert_eq!(parse_rfc3339("1970-01-01T00:00:00.123Z").unwrap(), + UNIX_EPOCH + Duration::new(0, 123000000)); + assert_eq!(format_rfc3339(UNIX_EPOCH + Duration::new(0, 123000000)) + .to_string(), "1970-01-01T00:00:00.123000000Z"); + } + + #[test] + #[should_panic(expected="OutOfRange")] + fn zero_month() { + parse_rfc3339("1970-00-01T00:00:00Z").unwrap(); + } + + #[test] + #[should_panic(expected="OutOfRange")] + fn big_month() { + parse_rfc3339("1970-32-01T00:00:00Z").unwrap(); + } + + #[test] + #[should_panic(expected="OutOfRange")] + fn zero_day() { + parse_rfc3339("1970-01-00T00:00:00Z").unwrap(); + } + + #[test] + #[should_panic(expected="OutOfRange")] + fn big_day() { + parse_rfc3339("1970-12-35T00:00:00Z").unwrap(); + } + + #[test] + #[should_panic(expected="OutOfRange")] + fn big_day2() { + parse_rfc3339("1970-02-30T00:00:00Z").unwrap(); + } + + #[test] + #[should_panic(expected="OutOfRange")] + fn big_second() { + parse_rfc3339("1970-12-30T00:00:78Z").unwrap(); + } + + #[test] + #[should_panic(expected="OutOfRange")] + fn big_minute() { + parse_rfc3339("1970-12-30T00:78:00Z").unwrap(); + } + + #[test] + #[should_panic(expected="OutOfRange")] + fn big_hour() { + parse_rfc3339("1970-12-30T24:00:00Z").unwrap(); + } + + #[test] + fn break_data() { + for pos in 0.."2016-12-31T23:59:60Z".len() { + let mut s = b"2016-12-31T23:59:60Z".to_vec(); + s[pos] = b'x'; + parse_rfc3339(from_utf8(&s).unwrap()).unwrap_err(); + } + } + + #[test] + fn weak_smoke_tests() { + assert_eq!(parse_rfc3339_weak("1970-01-01 00:00:00").unwrap(), + UNIX_EPOCH + Duration::new(0, 0)); + parse_rfc3339("1970-01-01 00:00:00").unwrap_err(); + + assert_eq!(parse_rfc3339_weak("1970-01-01 00:00:00.000123").unwrap(), + UNIX_EPOCH + Duration::new(0, 123000)); + parse_rfc3339("1970-01-01 00:00:00.000123").unwrap_err(); + + assert_eq!(parse_rfc3339_weak("1970-01-01T00:00:00.000123").unwrap(), + UNIX_EPOCH + Duration::new(0, 123000)); + parse_rfc3339("1970-01-01T00:00:00.000123").unwrap_err(); + + assert_eq!(parse_rfc3339_weak("1970-01-01 00:00:00.000123Z").unwrap(), + UNIX_EPOCH + Duration::new(0, 123000)); + parse_rfc3339("1970-01-01 00:00:00.000123Z").unwrap_err(); + + assert_eq!(parse_rfc3339_weak("1970-01-01 00:00:00Z").unwrap(), + UNIX_EPOCH + Duration::new(0, 0)); + parse_rfc3339("1970-01-01 00:00:00Z").unwrap_err(); + } +} diff --git a/third_party/cargo/vendor/humantime-1.3.0/src/duration.rs b/third_party/cargo/vendor/humantime-1.3.0/src/duration.rs new file mode 100644 index 0000000..9fafa84 --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/src/duration.rs @@ -0,0 +1,411 @@ +use std::fmt; +use std::str::Chars; +use std::time::Duration; +use std::error::Error as StdError; + +quick_error! { + /// Error parsing human-friendly duration + #[derive(Debug, PartialEq, Clone, Copy)] + pub enum Error { + /// Invalid character during parsing + /// + /// More specifically anything that is not alphanumeric is prohibited + /// + /// The field is an byte offset of the character in the string. + InvalidCharacter(offset: usize) { + display("invalid character at {}", offset) + description("invalid character") + } + /// Non-numeric value where number is expected + /// + /// This usually means that either time unit is broken into words, + /// e.g. `m sec` instead of `msec`, or just number is omitted, + /// for example `2 hours min` instead of `2 hours 1 min` + /// + /// The field is an byte offset of the errorneous character + /// in the string. + NumberExpected(offset: usize) { + display("expected number at {}", offset) + description("expected number") + } + /// Unit in the number is not one of allowed units + /// + /// See documentation of `parse_duration` for the list of supported + /// time units. + /// + /// The two fields are start and end (exclusive) of the slice from + /// the original string, containing errorneous value + UnknownUnit(start: usize, end: usize) { + display("unknown unit at {}-{}", start, end) + description("unknown unit") + } + /// The numeric value is too large + /// + /// Usually this means value is too large to be useful. If user writes + /// data in subsecond units, then the maximum is about 3k years. When + /// using seconds, or larger units, the limit is even larger. + NumberOverflow { + display(self_) -> ("{}", self_.description()) + description("number is too large") + } + /// The value was an empty string (or consists only whitespace) + Empty { + display(self_) -> ("{}", self_.description()) + description("value was empty") + } + } + +} + +/// A wrapper type that allows you to Display a Duration +#[derive(Debug, Clone)] +pub struct FormattedDuration(Duration); + +trait OverflowOp: Sized { + fn mul(self, other: Self) -> Result; + fn add(self, other: Self) -> Result; +} + +impl OverflowOp for u64 { + fn mul(self, other: Self) -> Result { + self.checked_mul(other).ok_or(Error::NumberOverflow) + } + fn add(self, other: Self) -> Result { + self.checked_add(other).ok_or(Error::NumberOverflow) + } +} + +struct Parser<'a> { + iter: Chars<'a>, + src: &'a str, + current: (u64, u64), +} + +impl<'a> Parser<'a> { + fn off(&self) -> usize { + self.src.len() - self.iter.as_str().len() + } + + fn parse_first_char(&mut self) -> Result, Error> { + let off = self.off(); + for c in self.iter.by_ref() { + match c { + '0'...'9' => { + return Ok(Some(c as u64 - '0' as u64)); + } + c if c.is_whitespace() => continue, + _ => { + return Err(Error::NumberExpected(off)); + } + } + } + return Ok(None); + } + fn parse_unit(&mut self, n: u64, start: usize, end: usize) + -> Result<(), Error> + { + let (mut sec, nsec) = match &self.src[start..end] { + "nanos" | "nsec" | "ns" => (0u64, n), + "usec" | "us" => (0u64, try!(n.mul(1000))), + "millis" | "msec" | "ms" => (0u64, try!(n.mul(1000_000))), + "seconds" | "second" | "secs" | "sec" | "s" => (n, 0), + "minutes" | "minute" | "min" | "mins" | "m" + => (try!(n.mul(60)), 0), + "hours" | "hour" | "hr" | "hrs" | "h" => (try!(n.mul(3600)), 0), + "days" | "day" | "d" => (try!(n.mul(86400)), 0), + "weeks" | "week" | "w" => (try!(n.mul(86400*7)), 0), + "months" | "month" | "M" => (try!(n.mul(2630016)), 0), // 30.44d + "years" | "year" | "y" => (try!(n.mul(31557600)), 0), // 365.25d + _ => return Err(Error::UnknownUnit(start, end)), + }; + let mut nsec = try!(self.current.1.add(nsec)); + if nsec > 1000_000_000 { + sec = try!(sec.add(nsec / 1000_000_000)); + nsec %= 1000_000_000; + } + sec = try!(self.current.0.add(sec)); + self.current = (sec, nsec); + Ok(()) + } + + fn parse(mut self) -> Result { + let mut n = try!(try!(self.parse_first_char()).ok_or(Error::Empty)); + 'outer: loop { + let mut off = self.off(); + while let Some(c) = self.iter.next() { + match c { + '0'...'9' => { + n = try!(n.checked_mul(10) + .and_then(|x| x.checked_add(c as u64 - '0' as u64)) + .ok_or(Error::NumberOverflow)); + } + c if c.is_whitespace() => {} + 'a'...'z' | 'A'...'Z' => { + break; + } + _ => { + return Err(Error::InvalidCharacter(off)); + } + } + off = self.off(); + } + let start = off; + let mut off = self.off(); + while let Some(c) = self.iter.next() { + match c { + '0'...'9' => { + try!(self.parse_unit(n, start, off)); + n = c as u64 - '0' as u64; + continue 'outer; + } + c if c.is_whitespace() => break, + 'a'...'z' | 'A'...'Z' => {} + _ => { + return Err(Error::InvalidCharacter(off)); + } + } + off = self.off(); + } + try!(self.parse_unit(n, start, off)); + n = match try!(self.parse_first_char()) { + Some(n) => n, + None => return Ok( + Duration::new(self.current.0, self.current.1 as u32)), + }; + } + } + +} + +/// Parse duration object `1hour 12min 5s` +/// +/// The duration object is a concatenation of time spans. Where each time +/// span is an integer number and a suffix. Supported suffixes: +/// +/// * `nsec`, `ns` -- microseconds +/// * `usec`, `us` -- microseconds +/// * `msec`, `ms` -- milliseconds +/// * `seconds`, `second`, `sec`, `s` +/// * `minutes`, `minute`, `min`, `m` +/// * `hours`, `hour`, `hr`, `h` +/// * `days`, `day`, `d` +/// * `weeks`, `week`, `w` +/// * `months`, `month`, `M` -- defined as 30.44 days +/// * `years`, `year`, `y` -- defined as 365.25 days +/// +/// # Examples +/// +/// ``` +/// use std::time::Duration; +/// use humantime::parse_duration; +/// +/// assert_eq!(parse_duration("2h 37min"), Ok(Duration::new(9420, 0))); +/// assert_eq!(parse_duration("32ms"), Ok(Duration::new(0, 32_000_000))); +/// ``` +pub fn parse_duration(s: &str) -> Result { + Parser { + iter: s.chars(), + src: s, + current: (0, 0), + }.parse() +} + +/// Formats duration into a human-readable string +/// +/// Note: this format is guaranteed to have same value when using +/// parse_duration, but we can change some details of the exact composition +/// of the value. +/// +/// # Examples +/// +/// ``` +/// use std::time::Duration; +/// use humantime::format_duration; +/// +/// let val1 = Duration::new(9420, 0); +/// assert_eq!(format_duration(val1).to_string(), "2h 37m"); +/// let val2 = Duration::new(0, 32_000_000); +/// assert_eq!(format_duration(val2).to_string(), "32ms"); +/// ``` +pub fn format_duration(val: Duration) -> FormattedDuration { + FormattedDuration(val) +} + +fn item_plural(f: &mut fmt::Formatter, started: &mut bool, + name: &str, value: u64) + -> fmt::Result +{ + if value > 0 { + if *started { + f.write_str(" ")?; + } + write!(f, "{}{}", value, name)?; + if value > 1 { + f.write_str("s")?; + } + *started = true; + } + Ok(()) +} +fn item(f: &mut fmt::Formatter, started: &mut bool, name: &str, value: u32) + -> fmt::Result +{ + if value > 0 { + if *started { + f.write_str(" ")?; + } + write!(f, "{}{}", value, name)?; + *started = true; + } + Ok(()) +} + +impl fmt::Display for FormattedDuration { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let secs = self.0.as_secs(); + let nanos = self.0.subsec_nanos(); + + if secs == 0 && nanos == 0 { + f.write_str("0s")?; + return Ok(()); + } + + let years = secs / 31557600; // 365.25d + let ydays = secs % 31557600; + let months = ydays / 2630016; // 30.44d + let mdays = ydays % 2630016; + let days = mdays / 86400; + let day_secs = mdays % 86400; + let hours = day_secs / 3600; + let minutes = day_secs % 3600 / 60; + let seconds = day_secs % 60; + + let millis = nanos / 1_000_000; + let micros = nanos / 1000 % 1000; + let nanosec = nanos % 1000; + + let ref mut started = false; + item_plural(f, started, "year", years)?; + item_plural(f, started, "month", months)?; + item_plural(f, started, "day", days)?; + item(f, started, "h", hours as u32)?; + item(f, started, "m", minutes as u32)?; + item(f, started, "s", seconds as u32)?; + item(f, started, "ms", millis)?; + item(f, started, "us", micros)?; + item(f, started, "ns", nanosec)?; + Ok(()) + } +} + +#[cfg(test)] +mod test { + extern crate rand; + + use std::time::Duration; + use self::rand::Rng; + use super::{parse_duration, format_duration}; + use super::Error; + + #[test] + fn test_units() { + assert_eq!(parse_duration("17nsec"), Ok(Duration::new(0, 17))); + assert_eq!(parse_duration("17nanos"), Ok(Duration::new(0, 17))); + assert_eq!(parse_duration("33ns"), Ok(Duration::new(0, 33))); + assert_eq!(parse_duration("3usec"), Ok(Duration::new(0, 3000))); + assert_eq!(parse_duration("78us"), Ok(Duration::new(0, 78000))); + assert_eq!(parse_duration("31msec"), Ok(Duration::new(0, 31000000))); + assert_eq!(parse_duration("31millis"), Ok(Duration::new(0, 31000000))); + assert_eq!(parse_duration("6ms"), Ok(Duration::new(0, 6000000))); + assert_eq!(parse_duration("3000s"), Ok(Duration::new(3000, 0))); + assert_eq!(parse_duration("300sec"), Ok(Duration::new(300, 0))); + assert_eq!(parse_duration("300secs"), Ok(Duration::new(300, 0))); + assert_eq!(parse_duration("50seconds"), Ok(Duration::new(50, 0))); + assert_eq!(parse_duration("1second"), Ok(Duration::new(1, 0))); + assert_eq!(parse_duration("100m"), Ok(Duration::new(6000, 0))); + assert_eq!(parse_duration("12min"), Ok(Duration::new(720, 0))); + assert_eq!(parse_duration("12mins"), Ok(Duration::new(720, 0))); + assert_eq!(parse_duration("1minute"), Ok(Duration::new(60, 0))); + assert_eq!(parse_duration("7minutes"), Ok(Duration::new(420, 0))); + assert_eq!(parse_duration("2h"), Ok(Duration::new(7200, 0))); + assert_eq!(parse_duration("7hr"), Ok(Duration::new(25200, 0))); + assert_eq!(parse_duration("7hrs"), Ok(Duration::new(25200, 0))); + assert_eq!(parse_duration("1hour"), Ok(Duration::new(3600, 0))); + assert_eq!(parse_duration("24hours"), Ok(Duration::new(86400, 0))); + assert_eq!(parse_duration("1day"), Ok(Duration::new(86400, 0))); + assert_eq!(parse_duration("2days"), Ok(Duration::new(172800, 0))); + assert_eq!(parse_duration("365d"), Ok(Duration::new(31536000, 0))); + assert_eq!(parse_duration("1week"), Ok(Duration::new(604800, 0))); + assert_eq!(parse_duration("7weeks"), Ok(Duration::new(4233600, 0))); + assert_eq!(parse_duration("52w"), Ok(Duration::new(31449600, 0))); + assert_eq!(parse_duration("1month"), Ok(Duration::new(2630016, 0))); + assert_eq!(parse_duration("3months"), Ok(Duration::new(3*2630016, 0))); + assert_eq!(parse_duration("12M"), Ok(Duration::new(31560192, 0))); + assert_eq!(parse_duration("1year"), Ok(Duration::new(31557600, 0))); + assert_eq!(parse_duration("7years"), Ok(Duration::new(7*31557600, 0))); + assert_eq!(parse_duration("17y"), Ok(Duration::new(536479200, 0))); + } + + #[test] + fn test_combo() { + assert_eq!(parse_duration("20 min 17 nsec "), Ok(Duration::new(1200, 17))); + assert_eq!(parse_duration("2h 15m"), Ok(Duration::new(8100, 0))); + } + + #[test] + fn all_86400_seconds() { + for second in 0..86400 { // scan leap year and non-leap year + let d = Duration::new(second, 0); + assert_eq!(d, + parse_duration(&format_duration(d).to_string()).unwrap()); + } + } + + #[test] + fn random_second() { + for _ in 0..10000 { + let sec = rand::thread_rng().gen_range(0, 253370764800); + let d = Duration::new(sec, 0); + assert_eq!(d, + parse_duration(&format_duration(d).to_string()).unwrap()); + } + } + + #[test] + fn random_any() { + for _ in 0..10000 { + let sec = rand::thread_rng().gen_range(0, 253370764800); + let nanos = rand::thread_rng().gen_range(0, 1_000_000_000); + let d = Duration::new(sec, nanos); + assert_eq!(d, + parse_duration(&format_duration(d).to_string()).unwrap()); + } + } + + #[test] + fn test_overlow() { + // Overflow on subseconds is earlier because of how we do conversion + // we could fix it, but I don't see any good reason for this + assert_eq!(parse_duration("100000000000000000000ns"), + Err(Error::NumberOverflow)); + assert_eq!(parse_duration("100000000000000000us"), + Err(Error::NumberOverflow)); + assert_eq!(parse_duration("100000000000000ms"), + Err(Error::NumberOverflow)); + + assert_eq!(parse_duration("100000000000000000000s"), + Err(Error::NumberOverflow)); + assert_eq!(parse_duration("10000000000000000000m"), + Err(Error::NumberOverflow)); + assert_eq!(parse_duration("1000000000000000000h"), + Err(Error::NumberOverflow)); + assert_eq!(parse_duration("100000000000000000d"), + Err(Error::NumberOverflow)); + assert_eq!(parse_duration("10000000000000000w"), + Err(Error::NumberOverflow)); + assert_eq!(parse_duration("1000000000000000M"), + Err(Error::NumberOverflow)); + assert_eq!(parse_duration("10000000000000y"), + Err(Error::NumberOverflow)); + } +} diff --git a/third_party/cargo/vendor/humantime-1.3.0/src/lib.rs b/third_party/cargo/vendor/humantime-1.3.0/src/lib.rs new file mode 100644 index 0000000..6d6c707 --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/src/lib.rs @@ -0,0 +1,33 @@ +//! Human-friendly time parser and formatter +//! +//! Features: +//! +//! * Parses durations in free form like `15days 2min 2s` +//! * Formats durations in similar form `2years 2min 12us` +//! * Parses and formats timestamp in `rfc3339` format: `2018-01-01T12:53:00Z` +//! * Parses timestamps in a weaker format: `2018-01-01 12:53:00` +//! +//! Timestamp parsing/formatting is super-fast because format is basically +//! fixed. +//! +//! See [serde-humantime] for serde integration. +//! +//! [serde-humantime]: https://docs.rs/serde-humantime/0.1.1/serde_humantime/ +#![warn(missing_debug_implementations)] +#![warn(missing_docs)] + +#[macro_use] extern crate quick_error; + +mod duration; +mod wrapper; +mod date; + +pub use duration::{parse_duration, Error as DurationError}; +pub use duration::{format_duration, FormattedDuration}; +pub use wrapper::{Duration, Timestamp}; +pub use date::{parse_rfc3339, parse_rfc3339_weak, Error as TimestampError}; +pub use date::{ + format_rfc3339, format_rfc3339_micros, format_rfc3339_millis, format_rfc3339_nanos, + format_rfc3339_seconds, +}; +pub use date::{Rfc3339Timestamp}; diff --git a/third_party/cargo/vendor/humantime-1.3.0/src/wrapper.rs b/third_party/cargo/vendor/humantime-1.3.0/src/wrapper.rs new file mode 100644 index 0000000..df01d79 --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/src/wrapper.rs @@ -0,0 +1,107 @@ +use std::str::FromStr; +use std::ops::Deref; +use std::fmt; +use std::time::{Duration as StdDuration, SystemTime}; + +use duration::{self, parse_duration, format_duration}; +use date::{self, parse_rfc3339_weak, format_rfc3339}; + +/// A wrapper for duration that has `FromStr` implementation +/// +/// This is useful if you want to use it somewhere where `FromStr` is +/// expected. +/// +/// See `parse_duration` for the description of the format. +/// +/// # Example +/// +/// ``` +/// use std::time::Duration; +/// let x: Duration; +/// x = "12h 5min 2ns".parse::().unwrap().into(); +/// assert_eq!(x, Duration::new(12*3600 + 5*60, 2)) +/// ``` +/// +#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] +pub struct Duration(StdDuration); + +/// A wrapper for SystemTime that has `FromStr` implementation +/// +/// This is useful if you want to use it somewhere where `FromStr` is +/// expected. +/// +/// See `parse_rfc3339_weak` for the description of the format. The "weak" +/// format is used as it's more pemissive for human input as this is the +/// expected use of the type (e.g. command-line parsing). +/// +/// # Example +/// +/// ``` +/// use std::time::SystemTime; +/// let x: SystemTime; +/// x = "2018-02-16T00:31:37Z".parse::().unwrap().into(); +/// assert_eq!(humantime::format_rfc3339(x).to_string(), "2018-02-16T00:31:37Z"); +/// ``` +/// +#[derive(Debug, PartialEq, Eq, Clone)] +pub struct Timestamp(SystemTime); + +impl AsRef for Duration { + fn as_ref(&self) -> &StdDuration { &self.0 } +} + +impl Deref for Duration { + type Target = StdDuration; + fn deref(&self) -> &StdDuration { &self.0 } +} + +impl Into for Duration { + fn into(self) -> StdDuration { self.0 } +} + +impl From for Duration { + fn from(dur: StdDuration) -> Duration { Duration(dur) } +} + +impl FromStr for Duration { + type Err = duration::Error; + fn from_str(s: &str) -> Result { + parse_duration(s).map(Duration) + } +} + +impl fmt::Display for Duration { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + format_duration(self.0).fmt(f) + } +} + +impl AsRef for Timestamp { + fn as_ref(&self) -> &SystemTime { &self.0 } +} + +impl Deref for Timestamp { + type Target = SystemTime; + fn deref(&self) -> &SystemTime { &self.0 } +} + +impl Into for Timestamp { + fn into(self) -> SystemTime { self.0 } +} + +impl From for Timestamp { + fn from(dur: SystemTime) -> Timestamp { Timestamp(dur) } +} + +impl FromStr for Timestamp { + type Err = date::Error; + fn from_str(s: &str) -> Result { + parse_rfc3339_weak(s).map(Timestamp) + } +} + +impl fmt::Display for Timestamp { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + format_rfc3339(self.0).fmt(f) + } +} diff --git a/third_party/cargo/vendor/humantime-1.3.0/vagga.yaml b/third_party/cargo/vendor/humantime-1.3.0/vagga.yaml new file mode 100644 index 0000000..b5d6b8b --- /dev/null +++ b/third_party/cargo/vendor/humantime-1.3.0/vagga.yaml @@ -0,0 +1,92 @@ +commands: + + cargo: !Command + description: Run any cargo command + container: ubuntu + run: [cargo] + + make: !Command + description: Build the library + container: ubuntu + run: [cargo, build] + + test64: !Command + description: Test the 64bit library + container: ubuntu + environ: { RUST_BACKTRACE: 1 } + run: [cargo, test] + + test32: !Command + description: Test the 32bit library + container: ubuntu32 + environ: { RUST_BACKTRACE: 1 } + run: [cargo, test] + + test: !Command + description: Test the 64bit library + container: ubuntu + environ: { RUST_BACKTRACE: 1 } + prerequisites: [test64, test32] + run: [echo, okay] + + bench: !Command + description: Run benchmarks + container: bench + environ: { RUST_BACKTRACE: 1 } + run: [cargo, bench] + + _bulk: !Command + description: Run `bulk` command (for version bookkeeping) + container: ubuntu + run: [bulk] + +containers: + + ubuntu: + setup: + - !Ubuntu xenial + - !UbuntuUniverse + - !Install [ca-certificates, build-essential, vim] + + - !TarInstall + url: "https://static.rust-lang.org/dist/rust-1.24.0-x86_64-unknown-linux-gnu.tar.gz" + script: "./install.sh --prefix=/usr \ + --components=rustc,rust-std-x86_64-unknown-linux-gnu,cargo" + - &bulk !Tar + url: "https://github.com/tailhook/bulk/releases/download/v0.4.10/bulk-v0.4.10.tar.gz" + sha256: 481513f8a0306a9857d045497fb5b50b50a51e9ff748909ecf7d2bda1de275ab + path: / + + environ: + HOME: /work/target + USER: pc + + ubuntu32: + setup: + - !UbuntuRelease + codename: xenial + arch: i386 + - !UbuntuUniverse + - !Install [ca-certificates, build-essential, vim] + + - !TarInstall + url: "https://static.rust-lang.org/dist/rust-1.24.0-i686-unknown-linux-gnu.tar.gz" + script: "./install.sh --prefix=/usr \ + --components=rustc,rust-std-i686-unknown-linux-gnu,cargo" + + environ: + HOME: /work/target + USER: pc + + bench: + setup: + - !Ubuntu xenial + - !Install [ca-certificates, wget, build-essential] + - !TarInstall + url: https://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz + script: | + ./install.sh --prefix=/usr \ + --components=rustc,rust-std-x86_64-unknown-linux-gnu,cargo + environ: + HOME: /work/target + USER: pc diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/.cargo-checksum.json b/third_party/cargo/vendor/lazy_static-1.4.0/.cargo-checksum.json new file mode 100644 index 0000000..fa241ed --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"05e37a4e63dc4a495998bb5133252a51d671c4e99061a6342089ed6eab43978a","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0621878e61f0d0fda054bcbe02df75192c28bde1ecc8289cbd86aeba2dd72720","README.md":"e2effacb5bbd7c01523f9a9e4a6a59c0f9b8698753b210fec5742408498197df","src/core_lazy.rs":"6b9fb6a4f553058e240756125b6b9ca43a83ed1fb72964343038ea0ea2e1af10","src/inline_lazy.rs":"f6184afbca4b477616f270790edc180263be806aa92ef0a9de681b4aac9e88c4","src/lib.rs":"99096a5d3089c0d86646f0805d1455befe2cb09683704af29c5c9d99ecab2683","tests/no_std.rs":"d68b149ee51ef5ae2b2906c0c94f5a9812d3b02811b13365c5a35e2ef90d25cf","tests/test.rs":"b3f7d805375dc5af7a2aa4b869944ad2ab4fc982b35ad718ea58f6914dc0a698"},"package":"e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"} \ No newline at end of file diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/BUILD b/third_party/cargo/vendor/lazy_static-1.4.0/BUILD new file mode 100644 index 0000000..2578fe8 --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/BUILD @@ -0,0 +1,44 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # "MIT,Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + + +rust_library( + name = "lazy_static", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "1.4.0", + crate_features = [ + ], +) + +# Unsupported target "no_std" with type "test" omitted +# Unsupported target "test" with type "test" omitted diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/Cargo.toml b/third_party/cargo/vendor/lazy_static-1.4.0/Cargo.toml new file mode 100644 index 0000000..7f930c5 --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/Cargo.toml @@ -0,0 +1,46 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "lazy_static" +version = "1.4.0" +authors = ["Marvin Löbel "] +exclude = ["/.travis.yml", "/appveyor.yml"] +description = "A macro for declaring lazily evaluated statics in Rust." +documentation = "https://docs.rs/lazy_static" +readme = "README.md" +keywords = ["macro", "lazy", "static"] +categories = ["no-std", "rust-patterns", "memory-management"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-lang-nursery/lazy-static.rs" +[dependencies.spin] +version = "0.5.0" +optional = true +[dev-dependencies.doc-comment] +version = "0.3.1" + +[features] +spin_no_std = ["spin"] +[badges.appveyor] +repository = "rust-lang-nursery/lazy-static.rs" + +[badges.is-it-maintained-issue-resolution] +repository = "rust-lang-nursery/lazy-static.rs" + +[badges.is-it-maintained-open-issues] +repository = "rust-lang-nursery/lazy-static.rs" + +[badges.maintenance] +status = "passively-maintained" + +[badges.travis-ci] +repository = "rust-lang-nursery/lazy-static.rs" diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/LICENSE-APACHE b/third_party/cargo/vendor/lazy_static-1.4.0/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/LICENSE-MIT b/third_party/cargo/vendor/lazy_static-1.4.0/LICENSE-MIT new file mode 100644 index 0000000..25597d5 --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2010 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/README.md b/third_party/cargo/vendor/lazy_static-1.4.0/README.md new file mode 100644 index 0000000..aa9f828 --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/README.md @@ -0,0 +1,79 @@ +lazy-static.rs +============== + +A macro for declaring lazily evaluated statics in Rust. + +Using this macro, it is possible to have `static`s that require code to be +executed at runtime in order to be initialized. +This includes anything requiring heap allocations, like vectors or hash maps, +as well as anything that requires non-const function calls to be computed. + +[![Travis-CI Status](https://travis-ci.com/rust-lang-nursery/lazy-static.rs.svg?branch=master)](https://travis-ci.com/rust-lang-nursery/lazy-static.rs) +[![Latest version](https://img.shields.io/crates/v/lazy_static.svg)](https://crates.io/crates/lazy_static) +[![Documentation](https://docs.rs/lazy_static/badge.svg)](https://docs.rs/lazy_static) +[![License](https://img.shields.io/crates/l/lazy_static.svg)](https://github.com/rust-lang-nursery/lazy-static.rs#license) + +## Minimum supported `rustc` + +`1.27.2+` + +This version is explicitly tested in CI and may only be bumped in new minor versions. Any changes to the supported minimum version will be called out in the release notes. + + +# Getting Started + +[lazy-static.rs is available on crates.io](https://crates.io/crates/lazy_static). +It is recommended to look there for the newest released version, as well as links to the newest builds of the docs. + +At the point of the last update of this README, the latest published version could be used like this: + +Add the following dependency to your Cargo manifest... + +```toml +[dependencies] +lazy_static = "1.4.0" +``` + +...and see the [docs](https://docs.rs/lazy_static) for how to use it. + +# Example + +```rust +#[macro_use] +extern crate lazy_static; + +use std::collections::HashMap; + +lazy_static! { + static ref HASHMAP: HashMap = { + let mut m = HashMap::new(); + m.insert(0, "foo"); + m.insert(1, "bar"); + m.insert(2, "baz"); + m + }; +} + +fn main() { + // First access to `HASHMAP` initializes it + println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap()); + + // Any further access to `HASHMAP` just returns the computed value + println!("The entry for `1` is \"{}\".", HASHMAP.get(&1).unwrap()); +} +``` + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any +additional terms or conditions. diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/src/core_lazy.rs b/third_party/cargo/vendor/lazy_static-1.4.0/src/core_lazy.rs new file mode 100644 index 0000000..b66c3e0 --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/src/core_lazy.rs @@ -0,0 +1,31 @@ +// Copyright 2016 lazy-static.rs Developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate spin; + +use self::spin::Once; + +pub struct Lazy(Once); + +impl Lazy { + pub const INIT: Self = Lazy(Once::INIT); + + #[inline(always)] + pub fn get(&'static self, builder: F) -> &T + where F: FnOnce() -> T + { + self.0.call_once(builder) + } +} + +#[macro_export] +#[doc(hidden)] +macro_rules! __lazy_static_create { + ($NAME:ident, $T:ty) => { + static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT; + } +} diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/src/inline_lazy.rs b/third_party/cargo/vendor/lazy_static-1.4.0/src/inline_lazy.rs new file mode 100644 index 0000000..219ce9c --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/src/inline_lazy.rs @@ -0,0 +1,57 @@ +// Copyright 2016 lazy-static.rs Developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +extern crate core; +extern crate std; + +use self::std::prelude::v1::*; +use self::std::cell::Cell; +use self::std::hint::unreachable_unchecked; +use self::std::sync::Once; +#[allow(deprecated)] +pub use self::std::sync::ONCE_INIT; + +// FIXME: Replace Option with MaybeUninit (stable since 1.36.0) +pub struct Lazy(Cell>, Once); + +impl Lazy { + #[allow(deprecated)] + pub const INIT: Self = Lazy(Cell::new(None), ONCE_INIT); + + #[inline(always)] + pub fn get(&'static self, f: F) -> &T + where + F: FnOnce() -> T, + { + self.1.call_once(|| { + self.0.set(Some(f())); + }); + + // `self.0` is guaranteed to be `Some` by this point + // The `Once` will catch and propagate panics + unsafe { + match *self.0.as_ptr() { + Some(ref x) => x, + None => { + debug_assert!(false, "attempted to derefence an uninitialized lazy static. This is a bug"); + + unreachable_unchecked() + }, + } + } + } +} + +unsafe impl Sync for Lazy {} + +#[macro_export] +#[doc(hidden)] +macro_rules! __lazy_static_create { + ($NAME:ident, $T:ty) => { + static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT; + }; +} diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/src/lib.rs b/third_party/cargo/vendor/lazy_static-1.4.0/src/lib.rs new file mode 100644 index 0000000..cada0dc --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/src/lib.rs @@ -0,0 +1,215 @@ +// Copyright 2016 lazy-static.rs Developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +/*! +A macro for declaring lazily evaluated statics. + +Using this macro, it is possible to have `static`s that require code to be +executed at runtime in order to be initialized. +This includes anything requiring heap allocations, like vectors or hash maps, +as well as anything that requires function calls to be computed. + +# Syntax + +```ignore +lazy_static! { + [pub] static ref NAME_1: TYPE_1 = EXPR_1; + [pub] static ref NAME_2: TYPE_2 = EXPR_2; + ... + [pub] static ref NAME_N: TYPE_N = EXPR_N; +} +``` + +Attributes (including doc comments) are supported as well: + +```rust +# #[macro_use] +# extern crate lazy_static; +# fn main() { +lazy_static! { + /// This is an example for using doc comment attributes + static ref EXAMPLE: u8 = 42; +} +# } +``` + +# Semantics + +For a given `static ref NAME: TYPE = EXPR;`, the macro generates a unique type that +implements `Deref` and stores it in a static with name `NAME`. (Attributes end up +attaching to this type.) + +On first deref, `EXPR` gets evaluated and stored internally, such that all further derefs +can return a reference to the same object. Note that this can lead to deadlocks +if you have multiple lazy statics that depend on each other in their initialization. + +Apart from the lazy initialization, the resulting "static ref" variables +have generally the same properties as regular "static" variables: + +- Any type in them needs to fulfill the `Sync` trait. +- If the type has a destructor, then it will not run when the process exits. + +# Example + +Using the macro: + +```rust +#[macro_use] +extern crate lazy_static; + +use std::collections::HashMap; + +lazy_static! { + static ref HASHMAP: HashMap = { + let mut m = HashMap::new(); + m.insert(0, "foo"); + m.insert(1, "bar"); + m.insert(2, "baz"); + m + }; + static ref COUNT: usize = HASHMAP.len(); + static ref NUMBER: u32 = times_two(21); +} + +fn times_two(n: u32) -> u32 { n * 2 } + +fn main() { + println!("The map has {} entries.", *COUNT); + println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap()); + println!("A expensive calculation on a static results in: {}.", *NUMBER); +} +``` + +# Implementation details + +The `Deref` implementation uses a hidden static variable that is guarded by an atomic check on each access. + +# Cargo features + +This crate provides one cargo feature: + +- `spin_no_std`: This allows using this crate in a no-std environment, by depending on the standalone `spin` crate. + +*/ + +#![doc(html_root_url = "https://docs.rs/lazy_static/1.4.0")] +#![no_std] + +#[cfg(not(feature = "spin_no_std"))] +#[path="inline_lazy.rs"] +#[doc(hidden)] +pub mod lazy; + +#[cfg(test)] +#[macro_use] +extern crate doc_comment; + +#[cfg(test)] +doctest!("../README.md"); + +#[cfg(feature = "spin_no_std")] +#[path="core_lazy.rs"] +#[doc(hidden)] +pub mod lazy; + +#[doc(hidden)] +pub use core::ops::Deref as __Deref; + +#[macro_export(local_inner_macros)] +#[doc(hidden)] +macro_rules! __lazy_static_internal { + // optional visibility restrictions are wrapped in `()` to allow for + // explicitly passing otherwise implicit information about private items + ($(#[$attr:meta])* ($($vis:tt)*) static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { + __lazy_static_internal!(@MAKE TY, $(#[$attr])*, ($($vis)*), $N); + __lazy_static_internal!(@TAIL, $N : $T = $e); + lazy_static!($($t)*); + }; + (@TAIL, $N:ident : $T:ty = $e:expr) => { + impl $crate::__Deref for $N { + type Target = $T; + fn deref(&self) -> &$T { + #[inline(always)] + fn __static_ref_initialize() -> $T { $e } + + #[inline(always)] + fn __stability() -> &'static $T { + __lazy_static_create!(LAZY, $T); + LAZY.get(__static_ref_initialize) + } + __stability() + } + } + impl $crate::LazyStatic for $N { + fn initialize(lazy: &Self) { + let _ = &**lazy; + } + } + }; + // `vis` is wrapped in `()` to prevent parsing ambiguity + (@MAKE TY, $(#[$attr:meta])*, ($($vis:tt)*), $N:ident) => { + #[allow(missing_copy_implementations)] + #[allow(non_camel_case_types)] + #[allow(dead_code)] + $(#[$attr])* + $($vis)* struct $N {__private_field: ()} + #[doc(hidden)] + $($vis)* static $N: $N = $N {__private_field: ()}; + }; + () => () +} + +#[macro_export(local_inner_macros)] +macro_rules! lazy_static { + ($(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { + // use `()` to explicitly forward the information about private items + __lazy_static_internal!($(#[$attr])* () static ref $N : $T = $e; $($t)*); + }; + ($(#[$attr:meta])* pub static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { + __lazy_static_internal!($(#[$attr])* (pub) static ref $N : $T = $e; $($t)*); + }; + ($(#[$attr:meta])* pub ($($vis:tt)+) static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { + __lazy_static_internal!($(#[$attr])* (pub ($($vis)+)) static ref $N : $T = $e; $($t)*); + }; + () => () +} + +/// Support trait for enabling a few common operation on lazy static values. +/// +/// This is implemented by each defined lazy static, and +/// used by the free functions in this crate. +pub trait LazyStatic { + #[doc(hidden)] + fn initialize(lazy: &Self); +} + +/// Takes a shared reference to a lazy static and initializes +/// it if it has not been already. +/// +/// This can be used to control the initialization point of a lazy static. +/// +/// Example: +/// +/// ```rust +/// #[macro_use] +/// extern crate lazy_static; +/// +/// lazy_static! { +/// static ref BUFFER: Vec = (0..255).collect(); +/// } +/// +/// fn main() { +/// lazy_static::initialize(&BUFFER); +/// +/// // ... +/// work_with_initialized_data(&BUFFER); +/// } +/// # fn work_with_initialized_data(_: &[u8]) {} +/// ``` +pub fn initialize(lazy: &T) { + LazyStatic::initialize(lazy); +} diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/tests/no_std.rs b/third_party/cargo/vendor/lazy_static-1.4.0/tests/no_std.rs new file mode 100644 index 0000000..f94a1aa --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/tests/no_std.rs @@ -0,0 +1,20 @@ +#![cfg(feature="spin_no_std")] + +#![no_std] + +#[macro_use] +extern crate lazy_static; + +lazy_static! { + /// Documentation! + pub static ref NUMBER: u32 = times_two(3); +} + +fn times_two(n: u32) -> u32 { + n * 2 +} + +#[test] +fn test_basic() { + assert_eq!(*NUMBER, 6); +} diff --git a/third_party/cargo/vendor/lazy_static-1.4.0/tests/test.rs b/third_party/cargo/vendor/lazy_static-1.4.0/tests/test.rs new file mode 100644 index 0000000..03d0ab6 --- /dev/null +++ b/third_party/cargo/vendor/lazy_static-1.4.0/tests/test.rs @@ -0,0 +1,164 @@ +#[macro_use] +extern crate lazy_static; +use std::collections::HashMap; + +lazy_static! { + /// Documentation! + pub static ref NUMBER: u32 = times_two(3); + + static ref ARRAY_BOXES: [Box; 3] = [Box::new(1), Box::new(2), Box::new(3)]; + + /// More documentation! + #[allow(unused_variables)] + #[derive(Copy, Clone, Debug)] + pub static ref STRING: String = "hello".to_string(); + + static ref HASHMAP: HashMap = { + let mut m = HashMap::new(); + m.insert(0, "abc"); + m.insert(1, "def"); + m.insert(2, "ghi"); + m + }; + + // This should not compile if the unsafe is removed. + static ref UNSAFE: u32 = unsafe { + std::mem::transmute::(-1) + }; +} + +lazy_static! { + static ref S1: &'static str = "a"; + static ref S2: &'static str = "b"; +} +lazy_static! { + static ref S3: String = [*S1, *S2].join(""); +} + +#[test] +fn s3() { + assert_eq!(&*S3, "ab"); +} + +fn times_two(n: u32) -> u32 { + n * 2 +} + +#[test] +fn test_basic() { + assert_eq!(&**STRING, "hello"); + assert_eq!(*NUMBER, 6); + assert!(HASHMAP.get(&1).is_some()); + assert!(HASHMAP.get(&3).is_none()); + assert_eq!(&*ARRAY_BOXES, &[Box::new(1), Box::new(2), Box::new(3)]); + assert_eq!(*UNSAFE, std::u32::MAX); +} + +#[test] +fn test_repeat() { + assert_eq!(*NUMBER, 6); + assert_eq!(*NUMBER, 6); + assert_eq!(*NUMBER, 6); +} + +#[test] +fn test_meta() { + // this would not compile if STRING were not marked #[derive(Copy, Clone)] + let copy_of_string = STRING; + // just to make sure it was copied + assert!(&STRING as *const _ != ©_of_string as *const _); + + // this would not compile if STRING were not marked #[derive(Debug)] + assert_eq!(format!("{:?}", STRING), "STRING { __private_field: () }".to_string()); +} + +mod visibility { + lazy_static! { + pub static ref FOO: Box = Box::new(0); + static ref BAR: Box = Box::new(98); + } + + pub mod inner { + lazy_static! { + pub(in visibility) static ref BAZ: Box = Box::new(42); + pub(crate) static ref BAG: Box = Box::new(37); + } + } + + #[test] + fn sub_test() { + assert_eq!(**FOO, 0); + assert_eq!(**BAR, 98); + assert_eq!(**inner::BAZ, 42); + assert_eq!(**inner::BAG, 37); + } +} + +#[test] +fn test_visibility() { + assert_eq!(*visibility::FOO, Box::new(0)); + assert_eq!(*visibility::inner::BAG, Box::new(37)); +} + +// This should not cause a warning about a missing Copy implementation +lazy_static! { + pub static ref VAR: i32 = { 0 }; +} + +#[derive(Copy, Clone, Debug, PartialEq)] +struct X; +struct Once(X); +const ONCE_INIT: Once = Once(X); +static DATA: X = X; +static ONCE: X = X; +fn require_sync() -> X { X } +fn transmute() -> X { X } +fn __static_ref_initialize() -> X { X } +fn test(_: Vec) -> X { X } + +// All these names should not be shadowed +lazy_static! { + static ref ITEM_NAME_TEST: X = { + test(vec![X, Once(X).0, ONCE_INIT.0, DATA, ONCE, + require_sync(), transmute(), + // Except this, which will sadly be shadowed by internals: + // __static_ref_initialize() + ]) + }; +} + +#[test] +fn item_name_shadowing() { + assert_eq!(*ITEM_NAME_TEST, X); +} + +use std::sync::atomic::AtomicBool; +#[allow(deprecated)] +use std::sync::atomic::ATOMIC_BOOL_INIT; +use std::sync::atomic::Ordering::SeqCst; + +#[allow(deprecated)] +static PRE_INIT_FLAG: AtomicBool = ATOMIC_BOOL_INIT; + +lazy_static! { + static ref PRE_INIT: () = { + PRE_INIT_FLAG.store(true, SeqCst); + () + }; +} + +#[test] +fn pre_init() { + assert_eq!(PRE_INIT_FLAG.load(SeqCst), false); + lazy_static::initialize(&PRE_INIT); + assert_eq!(PRE_INIT_FLAG.load(SeqCst), true); +} + +lazy_static! { + static ref LIFETIME_NAME: for<'a> fn(&'a u8) = { fn f(_: &u8) {} f }; +} + +#[test] +fn lifetime_name() { + let _ = LIFETIME_NAME; +} diff --git a/third_party/cargo/vendor/libc-0.2.66/.cargo-checksum.json b/third_party/cargo/vendor/libc-0.2.66/.cargo-checksum.json new file mode 100644 index 0000000..d9cfd8d --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CONTRIBUTING.md":"cc340197d05fd8f069dfda6347b97d3da92c8f260c75ac78fb6970f08dba7638","Cargo.toml":"ed3453ae907b85221c1c628d3bb3edd72719be5874a2373ead3f57564f938d18","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"3d4ffed8a5f477b249d4e9684937b9b01b78994ded690d9712c1dbf13a8a1b31","build.rs":"ab351d7171b14f8032948e843841ebe8518ed95eb1abf0b1e689700c7cef4bf5","rustfmt.toml":"8a654d5787585ca8f2c20580737336fc327f411a07b0dbd4870adf6e9bdf624f","src/cloudabi/aarch64.rs":"b8550bf1fd7344972aa4db29441486f39f31482d0327534981dbb75959c29114","src/cloudabi/arm.rs":"c197e2781c2839808bd6fcef219a29705b27b992d3ef920e9cf6ac96e2022bbf","src/cloudabi/mod.rs":"7b36bc7429863346f11a395dbbc200a38b789066ee9aefeac808ecefda9a1a88","src/cloudabi/x86.rs":"33eb97f272d2201f3838ae74d444583c7de8f67856852ca375293b20bbd05636","src/cloudabi/x86_64.rs":"400d85d4fe39e26cf2e6ece9ee31c75fe9e88c4bcf4d836ca9f765c05c9c5be3","src/fixed_width_ints.rs":"34c60f12ec5eeb90f13ec3b954427532111c2446e69617616a97aefc1086a9f1","src/fuchsia/aarch64.rs":"378776a9e40766154a54c94c2a7b4675b5c302a38e6e42da99e67bfbaee60e56","src/fuchsia/align.rs":"ae1cf8f011a99737eabeb14ffff768e60f13b13363d7646744dbb0f443dab3d6","src/fuchsia/mod.rs":"8ab46872899b06f46b54bfa39cce3bd7e8a43abe871d9ea821dba1c16a3348d7","src/fuchsia/no_align.rs":"303f3f1b255e0088b5715094353cf00476131d8e94e6aebb3f469557771c8b8a","src/fuchsia/x86_64.rs":"93a3632b5cf67d2a6bcb7dc0a558605252d5fe689e0f38d8aa2ec5852255ac87","src/hermit/aarch64.rs":"86048676e335944c37a63d0083d0f368ae10ceccefeed9debb3bbe08777fc682","src/hermit/mod.rs":"aeda183662787a44c4bd26645cea76f31bf5f7c63d4d59118118c360705fb9eb","src/hermit/x86_64.rs":"ab832b7524e5fb15c49ff7431165ab1a37dc4667ae0b58e8306f4c539bfa110c","src/lib.rs":"1397a0db2d265c5777d4a405b4a92e875bc308449be8daae341c3eeabe82d72e","src/macros.rs":"f75e6eb90c38c35292ee3664f8e0c65723703cf36cb04ebb88ac509006ac872a","src/sgx.rs":"16a95cdefc81c5ee00d8353a60db363c4cc3e0f75abcd5d0144723f2a306ed1b","src/switch.rs":"9da3dd39b3de45a7928789926e8572d00e1e11a39e6f7289a1349aadce90edba","src/unix/align.rs":"2cdc7c826ef7ae61f5171c5ae8c445a743d86f1a7f2d9d7e4ceeec56d6874f65","src/unix/bsd/apple/b32/align.rs":"ec833a747866fe19ca2d9b4d3c9ff0385faba5edf4bd0d15fa68884c40b0e26c","src/unix/bsd/apple/b32/mod.rs":"6a4ce300da0d2b0db04b18548286603ffe4b47d679a41cf60f1902895894aa1f","src/unix/bsd/apple/b64/align.rs":"ec833a747866fe19ca2d9b4d3c9ff0385faba5edf4bd0d15fa68884c40b0e26c","src/unix/bsd/apple/b64/mod.rs":"76e172191d70e7ea7ca194aaa2d002e50db5724bf24526c3be5028cfd2085897","src/unix/bsd/apple/mod.rs":"665972cfeb4a71da514c86718e3075d15d13d181be45d4ec5de2b45c1ab73f0c","src/unix/bsd/freebsdlike/dragonfly/errno.rs":"ae5e8e6b0f610ec015dfcc2928609037d7ea7b94570c72bcc5bdd588424c6259","src/unix/bsd/freebsdlike/dragonfly/mod.rs":"dbf5e940cae86f38e103134746c5b865342f04fb3009afbc88fb06dbeb41340e","src/unix/bsd/freebsdlike/freebsd/aarch64.rs":"e528191e42977fa4c226d8850c47d3e526e951cca46ea9a4a87af40221f79d63","src/unix/bsd/freebsdlike/freebsd/arm.rs":"10fe01bc6269b47da72d1e9f8bdae2fcc7d4f332540e8ce1756e1f58d506bf8c","src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs":"3d96c3bbd507688099ace8650ea2934cd7d85650d2e3a0981c6f916597edd09d","src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs":"9808d152c1196aa647f1b0f0cf84dac8c930da7d7f897a44975545e3d9d17681","src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs":"ceb4d5bd386f13bbf11499e12b5d4c377bd78ecca06fd65b0d08a6b25fba5ca4","src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs":"61cbe45f8499bedb168106b686d4f8239472f25c7553b069eec2afe197ff2df6","src/unix/bsd/freebsdlike/freebsd/mod.rs":"82f01098b820ef0f0450ddadfd2c3009182a4c2427df0150900fad0f2e96429b","src/unix/bsd/freebsdlike/freebsd/powerpc64.rs":"125457305b14309cbad4c46fd2fbd54e2f96d37adfec6c89ae9ed8cedfa015bc","src/unix/bsd/freebsdlike/freebsd/x86.rs":"4e0813f01a017dc148262d7c40dfadb964eb7eb6138dc2b0b83d0b51dbe4d467","src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs":"7169d07a9fd4716f7512719aec9fda5d8bed306dc0720ffc1b21696c9951e3c6","src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs":"fcf38f59ac1e8f90d5a26c6a434b6874972955404cb8cc33c17b1a583e3b3014","src/unix/bsd/freebsdlike/mod.rs":"2e0f5a0f768748a48caf05552956158c066db64ef59b935439f3a9e51ed1b93c","src/unix/bsd/mod.rs":"d8cf315174e6d97d87b44253fc4e4ef2570a495df8eec71f7571359c756ad039","src/unix/bsd/netbsdlike/mod.rs":"100b5fac3769b32be3cc7ea686cfd2a85fb2a55f154781a7ce44d65b163e0959","src/unix/bsd/netbsdlike/netbsd/aarch64.rs":"b38fc046f9a40fea28bd26328b96629f4d5d63d7524936bd6af1865d401a8716","src/unix/bsd/netbsdlike/netbsd/arm.rs":"58cdbb70b0d6f536551f0f3bb3725d2d75c4690db12c26c034e7d6ec4a924452","src/unix/bsd/netbsdlike/netbsd/mod.rs":"a50f20e60eb24e13c10425876771d3d6537c755fca558980e4ad45eab70d23f9","src/unix/bsd/netbsdlike/netbsd/powerpc.rs":"ee7ff5d89d0ed22f531237b5059aa669df93a3b5c489fa641465ace8d405bf41","src/unix/bsd/netbsdlike/netbsd/sparc64.rs":"9489f4b3e4566f43bb12dfb92238960613dac7f6a45cc13068a8d152b902d7d9","src/unix/bsd/netbsdlike/netbsd/x86.rs":"20692320e36bfe028d1a34d16fe12ca77aa909cb02bda167376f98f1a09aefe7","src/unix/bsd/netbsdlike/netbsd/x86_64.rs":"135509edeaf3fb3f102d89d51ff1a8f82323497336a8dc7e1f0f23b5c2434b73","src/unix/bsd/netbsdlike/openbsd/aarch64.rs":"1dd5449dd1fd3d51e30ffdeeaece91d0aaf05c710e0ac699fecc5461cfa2c28e","src/unix/bsd/netbsdlike/openbsd/mod.rs":"9b90e73d4f6139436dd93e76ce584c48698c97d892ea7ff57b8b3aad354609d3","src/unix/bsd/netbsdlike/openbsd/sparc64.rs":"d04fd287afbaa2c5df9d48c94e8374a532a3ba491b424ddf018270c7312f4085","src/unix/bsd/netbsdlike/openbsd/x86.rs":"6f7f5c4fde2a2259eb547890cbd86570cea04ef85347d7569e94e679448bec87","src/unix/bsd/netbsdlike/openbsd/x86_64.rs":"e59b7fd65f68f8e857eec39e0c03bac1d3af6ddc26c9ba58494336b83659bb9b","src/unix/haiku/b32.rs":"69ae47fc52c6880e85416b4744500d5655c9ec6131cb737f3b649fceaadce15a","src/unix/haiku/b64.rs":"73e64db09275a8da8d50a13cce2cfa2b136036ddf3a930d2939f337fc995900b","src/unix/haiku/mod.rs":"acd18f665908abcddc7e0a217708238d602f3ca827a3a46cd3bd8c7cd8a8d8b5","src/unix/hermit/aarch64.rs":"86048676e335944c37a63d0083d0f368ae10ceccefeed9debb3bbe08777fc682","src/unix/hermit/mod.rs":"878e02b4b3ceafdfce3746efadb621ec1baacfe93e385556c6e505bae5c3eaaf","src/unix/hermit/x86_64.rs":"ab832b7524e5fb15c49ff7431165ab1a37dc4667ae0b58e8306f4c539bfa110c","src/unix/linux_like/android/b32/arm.rs":"3625a32c7e58cfe683a53486fbe3d42d4e28f00bea31e19cb46ed2bb0b6a140b","src/unix/linux_like/android/b32/mod.rs":"c997e59bc7a5abe0f37dd87fcc206651dcb2c9837c3f4c2437f9d7944a30717c","src/unix/linux_like/android/b32/x86/align.rs":"812914e4241df82e32b12375ca3374615dc3a4bdd4cf31f0423c5815320c0dab","src/unix/linux_like/android/b32/x86/mod.rs":"edc810399ce9db38c1042c653f05d7f3571f711fa2c16917e8b543df01f065a5","src/unix/linux_like/android/b64/aarch64/align.rs":"0bf138f84e5327d8339bcd4adf071a6832b516445e597552c82bbd881095e3a8","src/unix/linux_like/android/b64/aarch64/mod.rs":"d832328045ed4d65e06ecd072cbe32336a5023664ad85e3961cb1bde8e9d69ba","src/unix/linux_like/android/b64/mod.rs":"2577fa47de16e819569b4d02aeb5f30e8367d85b169fdcc1789f0b404ad6b957","src/unix/linux_like/android/b64/x86_64/align.rs":"7169d07a9fd4716f7512719aec9fda5d8bed306dc0720ffc1b21696c9951e3c6","src/unix/linux_like/android/b64/x86_64/mod.rs":"c6eff774c053f7c8e7a895906ad23e7f835e7349260b40f0ee1689e4d1139ec8","src/unix/linux_like/android/mod.rs":"36866cd3766d899e7557b80f6049af632f7fe7cdcbd62d9edf267b0234acd584","src/unix/linux_like/emscripten/align.rs":"3f40c9cd6ba8b49b4129b53ae43ae8590dfdf21ecc7d20c306d35faf1b470872","src/unix/linux_like/emscripten/mod.rs":"62037212af196240b6469d5cd41ddc81b18d379e346e78e77d6e467f4a4ca47e","src/unix/linux_like/emscripten/no_align.rs":"0128e4aa721a9902754828b61b5ec7d8a86619983ed1e0544a85d35b1051fad6","src/unix/linux_like/linux/align.rs":"15957efd9b772280eb28447849f3aad38fff0c5d65a02566a7ebfba2e7107437","src/unix/linux_like/linux/gnu/align.rs":"e4a3c27fe20a57b8d612c34cb05bc70646edb5cec7251957315afa53a7b9f936","src/unix/linux_like/linux/gnu/b32/arm/align.rs":"3fed009dc9af3cc81be7087da9d2d7d1f39845e4497e290259c5cdbae25f039d","src/unix/linux_like/linux/gnu/b32/arm/mod.rs":"48bea857c59cd3f45c78fb737e048c37174d58d06d20b21c91928f373510ba19","src/unix/linux_like/linux/gnu/b32/mips/align.rs":"429fb5e005cb7143602d430098b6ebfb7d360685b194f333dfd587472ae954ee","src/unix/linux_like/linux/gnu/b32/mips/mod.rs":"e2d2e51fea73210d9705b7eaa37de8baa7152b71ae3a10a316c277345c529b5c","src/unix/linux_like/linux/gnu/b32/mod.rs":"c65adabb73b2b145a9311e0c2abd4075bf1b763b7bea5b26fbd938199e462f37","src/unix/linux_like/linux/gnu/b32/powerpc.rs":"ba9f549679f66ba15e007a5ded4fe9d10d2e9283a5ce95e6bdfb110089bf15f6","src/unix/linux_like/linux/gnu/b32/sparc/align.rs":"21adbed27df73e2d1ed934aaf733a643003d7baf2bde9c48ea440895bcca6d41","src/unix/linux_like/linux/gnu/b32/sparc/mod.rs":"690357fa2a9a9bf895c59d44d73842e7ee2e5de4decb803b61ec1c9491f32fc0","src/unix/linux_like/linux/gnu/b32/x86/align.rs":"e4bafdc4a519a7922a81b37a62bbfd1177a2f620890eef8f1fbc47162e9eb413","src/unix/linux_like/linux/gnu/b32/x86/mod.rs":"403dc6de6fb22d1eefdbe5e3e4977fd972c15335c3d9d5a394f17c5c1b35a205","src/unix/linux_like/linux/gnu/b64/aarch64/align.rs":"0bf138f84e5327d8339bcd4adf071a6832b516445e597552c82bbd881095e3a8","src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs":"72779fa53260d2e72d01a8cf387da0948cd93072b8b31937d51d3b6c25a44f03","src/unix/linux_like/linux/gnu/b64/mips64/align.rs":"7169d07a9fd4716f7512719aec9fda5d8bed306dc0720ffc1b21696c9951e3c6","src/unix/linux_like/linux/gnu/b64/mips64/mod.rs":"44261e37fd6b3ff5cb091a5c973faa75b157bac91a9eac9d9cb78bf34f6c2a2f","src/unix/linux_like/linux/gnu/b64/mod.rs":"b90d87f76bff37707a1725551fe45d70d0c106e01b1dbbcd5f60460e0a19b4c3","src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs":"e29c4868bbecfa4a6cd8a2ad06193f3bbc78a468cc1dc9df83f002f1268130d9","src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs":"fc4d6613805fdedfff9455d736819a146f5403354a26c902b8c82003b2452629","src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs":"4a5dada65294246696b8114accb38d003e66b1b1c165a49abb41073bab504d82","src/unix/linux_like/linux/gnu/b64/s390x.rs":"f796526968527985a0bbb89eb4f7347a193eb515932504aa32712ca2f07fa4a1","src/unix/linux_like/linux/gnu/b64/sparc64/align.rs":"e29c4868bbecfa4a6cd8a2ad06193f3bbc78a468cc1dc9df83f002f1268130d9","src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs":"239dd7dfa45c078adc0d188dca8e54a9cef1814f1c331bed4eacb87fd7578615","src/unix/linux_like/linux/gnu/b64/x86_64/align.rs":"7169d07a9fd4716f7512719aec9fda5d8bed306dc0720ffc1b21696c9951e3c6","src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs":"33d9c3c191591d50df619c1bd8913ba06559cf924023d626fdc71c4ba893c299","src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs":"c1862036556262f076eda2008470b8a351b9c371d70664f54387c46890e8cd18","src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs":"30f88d0fa9e7807ee4cbe89fd274061f810099567d5e68fa829277d7d27ba708","src/unix/linux_like/linux/gnu/mod.rs":"220fcb634cf7653344e4202d131bd86477c5d357b30b28ae85f5663e7ab32896","src/unix/linux_like/linux/gnu/no_align.rs":"9cd223135de75315840ff9c3fd5441ba1cb632b96b5c85a76f8316c86653db25","src/unix/linux_like/linux/mod.rs":"e3b0b9d48b0290283a9f45bffbcfdfc4221c6541eee7893d84dc429b60c41b36","src/unix/linux_like/linux/musl/b32/arm/align.rs":"3e8ac052c1043764776b54c93ba4260e061df998631737a897d9d47d54f7b80c","src/unix/linux_like/linux/musl/b32/arm/mod.rs":"2a57708c5c2976896697ea497be32e0d03573fe44e940df8ddcd4cb06350212c","src/unix/linux_like/linux/musl/b32/hexagon.rs":"e945250ac42713836cae8e4820fc395d374535fce332dbd3ef68109c392290a0","src/unix/linux_like/linux/musl/b32/mips/align.rs":"429fb5e005cb7143602d430098b6ebfb7d360685b194f333dfd587472ae954ee","src/unix/linux_like/linux/musl/b32/mips/mod.rs":"eb65de7aeefed797129c9521785eaa99cdac0644efd826fc6efbab5afc760bf2","src/unix/linux_like/linux/musl/b32/mod.rs":"011c23053388aaacf9aaa17c92b2a918d0fa054410bb1640e61cc4e6d00b0b75","src/unix/linux_like/linux/musl/b32/powerpc.rs":"e3bb421df570b8b154d89969c5a045573c369c2b043ebd93b1d1d2211684dca5","src/unix/linux_like/linux/musl/b32/x86/align.rs":"08e77fbd7435d7dec2ff56932433bece3f02e47ce810f89004a275a86d39cbe1","src/unix/linux_like/linux/musl/b32/x86/mod.rs":"4698f7c107451e7db247e75ade30095b634cb0bfec9605e273975e75c1907420","src/unix/linux_like/linux/musl/b64/aarch64/align.rs":"0bf138f84e5327d8339bcd4adf071a6832b516445e597552c82bbd881095e3a8","src/unix/linux_like/linux/musl/b64/aarch64/mod.rs":"81c4be3f230a60263b57e1d1766420d620e50d8cca04d5a75f48a2a5fe30622e","src/unix/linux_like/linux/musl/b64/mips64.rs":"e8206d97833a50b980aa36a42b02e6197d903a1db4f4314a53b7289308c28bdd","src/unix/linux_like/linux/musl/b64/mod.rs":"317d1cb47ccc87cb7f8ed677bab799fa6eb1b8fd7fbd57d1896005644e02a010","src/unix/linux_like/linux/musl/b64/powerpc64.rs":"9b3faba7fa4f3a660e744ec7bdb71a759ac7d4d78a51b3374d004d5494f8332a","src/unix/linux_like/linux/musl/b64/x86_64/align.rs":"7169d07a9fd4716f7512719aec9fda5d8bed306dc0720ffc1b21696c9951e3c6","src/unix/linux_like/linux/musl/b64/x86_64/mod.rs":"f317c46a2fe4e91e0aaabcaad9bd7535e9d286f0d41caa77bc1d706e37e6a762","src/unix/linux_like/linux/musl/mod.rs":"786c8b5bd7eaabc072351bf83063a4449c7a6bde563962bde800d3eb5c4f6f0f","src/unix/linux_like/linux/no_align.rs":"b94d6612cb8cb1eea947afc825cf8acaddc7f14835a15d2a6e691765de975fcd","src/unix/linux_like/mod.rs":"2dec8d58e9f7afc9b1f81515b05b6799def02e677cdbc08bea283c83e6cbddc7","src/unix/mod.rs":"a9f4dbf822ff2ed420a0ecddee9f531b528bf97fc7896011e63d191d18039ec2","src/unix/newlib/aarch64/mod.rs":"934754e14de392703fd380e0a443fd19a85a405d6c9310d9f855288dd8e76343","src/unix/newlib/align.rs":"28aaf87fafbc6b312622719d472d8cf65f9e5467d15339df5f73e66d8502b28a","src/unix/newlib/arm/mod.rs":"69756a6ba4b75d8cdeae1843bd6d079c42c94e3e61e6e09f169bd20cebec8b0e","src/unix/newlib/mod.rs":"fc2a6cef4ab8f19f16d5ef5d18e206a5514c5ae39091b8d69c7cc1229a3c1f7f","src/unix/newlib/no_align.rs":"7123dcec13604a11b7765c380ff3a4d0da19c39f4b03919de7857723c0cf1502","src/unix/no_align.rs":"c06e95373b9088266e0b14bba0954eef95f93fb2b01d951855e382d22de78e53","src/unix/redox/mod.rs":"4ae29abc41e72723171d434a034374b499dfb6b6fd32e910e7ade88dfecc7601","src/unix/solarish/compat.rs":"cf4ee4cf0d7d45b253b01d1cf823d7f007e3e71aeb5cd8ffe77ef3d722255e68","src/unix/solarish/mod.rs":"cd266cee38f25fe9ed896ba88ddd3530eca352c4d260671fb63d315890bc49e6","src/unix/uclibc/align.rs":"a8540e1cce5913a45bc8d7422b79e86c0b12740e8a679478e0e4d863a31f8cc1","src/unix/uclibc/arm/align.rs":"e4a3c27fe20a57b8d612c34cb05bc70646edb5cec7251957315afa53a7b9f936","src/unix/uclibc/arm/mod.rs":"d67dd46bc6f417169fc6a23832bde7ccdafc5d1bcb08b10debdd82edaf75d529","src/unix/uclibc/arm/no_align.rs":"9cd223135de75315840ff9c3fd5441ba1cb632b96b5c85a76f8316c86653db25","src/unix/uclibc/mips/mips32/align.rs":"e4a3c27fe20a57b8d612c34cb05bc70646edb5cec7251957315afa53a7b9f936","src/unix/uclibc/mips/mips32/mod.rs":"a045ebc6619f540adf670b88a987abd2d6e42e440a552e8cfe9f8c77f397e873","src/unix/uclibc/mips/mips32/no_align.rs":"9cd223135de75315840ff9c3fd5441ba1cb632b96b5c85a76f8316c86653db25","src/unix/uclibc/mips/mips64/align.rs":"a7bdcb18a37a2d91e64d5fad83ea3edc78f5412adb28f77ab077dbb26dd08b2d","src/unix/uclibc/mips/mips64/mod.rs":"e3085ba56cfbc528d7c3c55065880603238c333b6047ef51c58177508a487fcd","src/unix/uclibc/mips/mips64/no_align.rs":"4a18e3875698c85229599225ac3401a2a40da87e77b2ad4ef47c6fcd5a24ed30","src/unix/uclibc/mips/mod.rs":"1054d0bfeb506b3346b9a4148564beced8a22da0d9c9a612101f6237756795fb","src/unix/uclibc/mod.rs":"4c20de4d16a0a3efd67a9fd742f5146b77cfb7c24a18fac8728085ad5f52618e","src/unix/uclibc/no_align.rs":"3f28637046524618adaa1012e26cb7ffe94b9396e6b518cccdc69d59f274d709","src/unix/uclibc/x86_64/align.rs":"c44ee7782b74733bee5659dfd7eb32d5901c17c99cb540b1a08291859f6238c6","src/unix/uclibc/x86_64/l4re.rs":"bb31053d6403091e11f95ac2203982f279f8b984a19adf30796878c45fdd8c25","src/unix/uclibc/x86_64/mod.rs":"df78de7e0234192c0559b9820c0034a24d72a0820d361f9aad05a9eac36e80ff","src/unix/uclibc/x86_64/no_align.rs":"b308f7b110caf7405b57186882cfc4804caae49a8287f8ab612ec8548467f2f4","src/unix/uclibc/x86_64/other.rs":"42c3f71e58cabba373f6a55a623f3c31b85049eb64824c09c2b082b3b2d6a0a8","src/vxworks/aarch64.rs":"98f0afdc511cd02557e506c21fed6737585490a1dce7a9d4941d08c437762b99","src/vxworks/arm.rs":"acb7968ce99fe3f4abdf39d98f8133d21a4fba435b8ef7084777cb181d788e88","src/vxworks/mod.rs":"b62f34937aa6943a7348ec69cb338fa04cddba200f108f2a5a61e4b0a6fae252","src/vxworks/powerpc.rs":"acb7968ce99fe3f4abdf39d98f8133d21a4fba435b8ef7084777cb181d788e88","src/vxworks/powerpc64.rs":"98f0afdc511cd02557e506c21fed6737585490a1dce7a9d4941d08c437762b99","src/vxworks/x86.rs":"552f007f38317620b23889cb7c49d1d115841252439060122f52f434fbc6e5ba","src/vxworks/x86_64.rs":"018d92be3ad628a129eff9f2f5dfbc0883d8b8e5f2fa917b900a7f98ed6b514a","src/wasi.rs":"f1995eee58f872de81197983b5683fe83dc396e16344db0fe52b3d63d061a5e4","src/windows/gnu/align.rs":"b2c13ec1b9f3b39a75c452c80c951dff9d0215e31d77e883b4502afb31794647","src/windows/gnu/mod.rs":"dc8e2f8d32280394d2bc386f804ce1c71f751590cfeed7db9220e231acc766e3","src/windows/mod.rs":"591ab70bf20a8871b33f27c1975acc7304cb11018d84355002dc6463c5a91cbf","src/windows/msvc.rs":"2c2bfce66027d88021e7289139ebf5b0db258a7b6443f18872c84dbd4ef57131","tests/const_fn.rs":"cb75a1f0864f926aebe79118fc34d51a0d1ade2c20a394e7774c7e545f21f1f4"},"package":"d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"} \ No newline at end of file diff --git a/third_party/cargo/vendor/libc-0.2.66/BUILD b/third_party/cargo/vendor/libc-0.2.66/BUILD new file mode 100644 index 0000000..493872c --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/BUILD @@ -0,0 +1,46 @@ +""" +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//third_party/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # "MIT OR Apache-2.0" +]) + +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_library", + "rust_binary", + "rust_test", +) + + +# Unsupported target "build-script-build" with type "custom-build" omitted +# Unsupported target "const_fn" with type "test" omitted + +rust_library( + name = "libc", + crate_root = "src/lib.rs", + crate_type = "lib", + edition = "2015", + srcs = glob(["**/*.rs"]), + deps = [ + ], + rustc_flags = [ + "--cap-lints=allow", + ], + version = "0.2.66", + crate_features = [ + "default", + "std", + ], +) + diff --git a/third_party/cargo/vendor/libc-0.2.66/CONTRIBUTING.md b/third_party/cargo/vendor/libc-0.2.66/CONTRIBUTING.md new file mode 100644 index 0000000..052777f --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/CONTRIBUTING.md @@ -0,0 +1,66 @@ +# Contributing to `libc` + +Welcome! If you are reading this document, it means you are interested in contributing +to the `libc` crate. + +## Adding an API + +Want to use an API which currently isn't bound in `libc`? It's quite easy to add +one! + +The internal structure of this crate is designed to minimize the number of +`#[cfg]` attributes in order to easily be able to add new items which apply +to all platforms in the future. As a result, the crate is organized +hierarchically based on platform. Each module has a number of `#[cfg]`'d +children, but only one is ever actually compiled. Each module then reexports all +the contents of its children. + +This means that for each platform that libc supports, the path from a +leaf module to the root will contain all bindings for the platform in question. +Consequently, this indicates where an API should be added! Adding an API at a +particular level in the hierarchy means that it is supported on all the child +platforms of that level. For example, when adding a Unix API it should be added +to `src/unix/mod.rs`, but when adding a Linux-only API it should be added to +`src/unix/linux_like/linux/mod.rs`. + +If you're not 100% sure at what level of the hierarchy an API should be added +at, fear not! This crate has CI support which tests any binding against all +platforms supported, so you'll see failures if an API is added at the wrong +level or has different signatures across platforms. + +With that in mind, the steps for adding a new API are: + +1. Determine where in the module hierarchy your API should be added. +2. Add the API. +3. Send a PR to this repo. +4. Wait for CI to pass, fixing errors. +5. Wait for a merge! + +### Test before you commit + +We have two automated tests running on [Azure Pipelines](https://dev.azure.com/rust-lang2/libc/_build?definitionId=1&_a=summary): + +1. [`libc-test`](https://github.com/gnzlbg/ctest) + - `cd libc-test && cargo test` + - Use the `skip_*()` functions in `build.rs` if you really need a workaround. +2. Style checker + - `rustc ci/style.rs && ./style src` + +### Releasing your change to crates.io + +Now that you've done the amazing job of landing your new API or your new +platform in this crate, the next step is to get that sweet, sweet usage from +crates.io! The only next step is to bump the version of libc and then publish +it. If you'd like to get a release out ASAP you can follow these steps: + +1. Update the version number in `Cargo.toml`, you'll just be bumping the patch + version number. +2. Run `cargo update` to regenerate the lockfile to encode your version bump in + the lock file. You may pull in some other updated dependencies, that's ok. +3. Send a PR to this repository. It should [look like this][example], but it'd + also be nice to fill out the description with a small rationale for the + release (any rationale is ok though!) +4. Once merged the release will be tagged and published by one of the libc crate + maintainers. + +[example]: https://github.com/rust-lang/libc/pull/583 diff --git a/third_party/cargo/vendor/libc-0.2.66/Cargo.toml b/third_party/cargo/vendor/libc-0.2.66/Cargo.toml new file mode 100644 index 0000000..41c07ff --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/Cargo.toml @@ -0,0 +1,44 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "libc" +version = "0.2.66" +authors = ["The Rust Project Developers"] +build = "build.rs" +exclude = ["/ci/*", "/azure-pipelines.yml"] +description = "Raw FFI bindings to platform libraries like libc.\n" +homepage = "https://github.com/rust-lang/libc" +documentation = "http://doc.rust-lang.org/libc" +readme = "README.md" +keywords = ["libc", "ffi", "bindings", "operating", "system"] +categories = ["external-ffi-bindings", "no-std", "os"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/libc" +[dependencies.rustc-std-workspace-core] +version = "1.0.0" +optional = true + +[features] +align = [] +const-extern-fn = [] +default = ["std"] +extra_traits = [] +rustc-dep-of-std = ["align", "rustc-std-workspace-core"] +std = [] +use_std = ["std"] +[badges.appveyor] +project_name = "rust-lang-libs/libc" +repository = "rust-lang/libc" + +[badges.travis-ci] +repository = "rust-lang/libc" diff --git a/third_party/cargo/vendor/libc-0.2.66/LICENSE-APACHE b/third_party/cargo/vendor/libc-0.2.66/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/cargo/vendor/libc-0.2.66/LICENSE-MIT b/third_party/cargo/vendor/libc-0.2.66/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/cargo/vendor/libc-0.2.66/README.md b/third_party/cargo/vendor/libc-0.2.66/README.md new file mode 100644 index 0000000..8a36881 --- /dev/null +++ b/third_party/cargo/vendor/libc-0.2.66/README.md @@ -0,0 +1,106 @@ +[![Azure Status]][Azure] [![Cirrus CI Status]][Cirrus CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License] + +libc - Raw FFI bindings to platforms' system libraries +==== + +`libc` provides all of the definitions necessary to easily interoperate with C +code (or "C-like" code) on each of the platforms that Rust supports. This +includes type definitions (e.g. `c_int`), constants (e.g. `EINVAL`) as well as +function headers (e.g. `malloc`). + +This crate exports all underlying platform types, functions, and constants under +the crate root, so all items are accessible as `libc::foo`. The types and values +of all the exported APIs match the platform that libc is compiled for. + +More detailed information about the design of this library can be found in its +[associated RFC][rfc]. + +[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1291-promote-libc.md + +## Usage + +Add the following to your `Cargo.toml`: + +```toml +[dependencies] +libc = "0.2" +``` + +## Features + +* `std`: by default `libc` links to the standard library. Disable this + feature remove this dependency and be able to use `libc` in `#![no_std]` + crates. + +* `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`. + This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`. + +* `const-extern-fn`: Changes some `extern fn`s into `const extern fn`s. + This features requires a nightly rustc + +* **deprecated**: `use_std` is deprecated, and is equivalent to `std`. + +## Rust version support + +The minimum supported Rust toolchain version is **Rust 1.13.0** . APIs requiring +newer Rust features are only available on newer Rust toolchains: + +| Feature | Version | +|----------------------|---------| +| `union` | 1.19.0 | +| `const mem::size_of` | 1.24.0 | +| `repr(align)` | 1.25.0 | +| `extra_traits` | 1.25.0 | +| `core::ffi::c_void` | 1.30.0 | +| `repr(packed(N))` | 1.33.0 | + +## Platform support + +[Platform-specific documentation (master branch)][docs.master]. + +See +[`ci/build.sh`](https://github.com/rust-lang/libc/blob/master/ci/build.sh) +for the platforms on which `libc` is guaranteed to build for each Rust +toolchain. The test-matrix at [Azure] and [Cirrus CI] show the +platforms in which `libc` tests are run. + +